Skip to content

Commit e6924ee

Browse files
authored
[browser] cleanup of early startup code (#83411)
1 parent e6f9af1 commit e6924ee

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

73 files changed

+1281
-1200
lines changed

src/installer/pkg/sfx/Microsoft.NETCore.App/Directory.Build.props

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -253,7 +253,6 @@
253253
<PlatformManifestFileEntry Include="runtime.es6.iffe.js" IsNative="true" />
254254
<PlatformManifestFileEntry Include="dotnet.es6.pre.js" IsNative="true" />
255255
<PlatformManifestFileEntry Include="dotnet.es6.lib.js" IsNative="true" />
256-
<PlatformManifestFileEntry Include="dotnet.es6.post.js" IsNative="true" />
257256
<PlatformManifestFileEntry Include="dotnet.es6.extpost.js" IsNative="true" />
258257
<PlatformManifestFileEntry Include="corebindings.c" IsNative="true" />
259258
<PlatformManifestFileEntry Include="driver.c" IsNative="true" />

src/mono/wasm/debugger/tests/debugger-test/debugger-main.js

Lines changed: 15 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -3,26 +3,23 @@
33

44
"use strict";
55

6-
import createDotnetRuntime from './dotnet.js'
6+
import { dotnet, exit } from './dotnet.js'
77

88
try {
9-
const runtime = await createDotnetRuntime(({ INTERNAL }) => ({
10-
configSrc: "./mono-config.json",
11-
onConfigLoaded: (config) => {
12-
config.environmentVariables["DOTNET_MODIFIABLE_ASSEMBLIES"] = "debug";
13-
/* For custom logging patch the functions below
14-
config.diagnosticTracing = true;
15-
config.environmentVariables["MONO_LOG_LEVEL"] = "debug";
16-
config.environmentVariables["MONO_LOG_MASK"] = "all";
17-
INTERNAL.logging = {
18-
trace: (domain, log_level, message, isFatal, dataPtr) => console.log({ domain, log_level, message, isFatal, dataPtr }),
19-
debugger: (level, message) => console.log({ level, message }),
20-
};
21-
*/
22-
},
23-
}));
9+
const runtime = await dotnet
10+
.withEnvironmentVariable("DOTNET_MODIFIABLE_ASSEMBLIES", "debug")
11+
// For custom logging patch the functions below
12+
//.withDiagnosticTracing(true)
13+
//.withEnvironmentVariable("MONO_LOG_LEVEL", "debug")
14+
//.withEnvironmentVariable("MONO_LOG_MASK", "all")
15+
.create();
16+
/*runtime.INTERNAL.logging = {
17+
trace: (domain, log_level, message, isFatal, dataPtr) => console.log({ domain, log_level, message, isFatal, dataPtr }),
18+
debugger: (level, message) => console.log({ level, message }),
19+
};*/
2420
App.runtime = runtime;
2521
await App.init();
26-
} catch (err) {
27-
console.log(`WASM ERROR ${err}`);
2822
}
23+
catch (err) {
24+
exit(2, err);
25+
}

src/mono/wasm/runtime/CMakeLists.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,8 @@ target_link_libraries(dotnet
3434
${NATIVE_BIN_DIR}/libSystem.IO.Compression.Native.a)
3535

3636
set_target_properties(dotnet PROPERTIES
37-
LINK_DEPENDS "${NATIVE_BIN_DIR}/src/emcc-default.rsp;${NATIVE_BIN_DIR}/src/es6/dotnet.es6.pre.js;${NATIVE_BIN_DIR}/src/es6/runtime.es6.iffe.js;${NATIVE_BIN_DIR}/src/es6/dotnet.es6.lib.js;${NATIVE_BIN_DIR}/src/pal_random.lib.js;${NATIVE_BIN_DIR}/src/es6/dotnet.es6.post.js;${NATIVE_BIN_DIR}/src/es6/dotnet.es6.extpost.js;"
38-
LINK_FLAGS "@${NATIVE_BIN_DIR}/src/emcc-default.rsp @${NATIVE_BIN_DIR}/src/emcc-link.rsp ${CONFIGURATION_LINK_FLAGS} --extern-pre-js ${NATIVE_BIN_DIR}/src/es6/runtime.es6.iffe.js --pre-js ${NATIVE_BIN_DIR}/src/es6/dotnet.es6.pre.js --js-library ${NATIVE_BIN_DIR}/src/es6/dotnet.es6.lib.js --js-library ${NATIVE_BIN_DIR}/src/pal_random.lib.js --post-js ${NATIVE_BIN_DIR}/src/es6/dotnet.es6.post.js --extern-post-js ${NATIVE_BIN_DIR}/src/es6/dotnet.es6.extpost.js "
37+
LINK_DEPENDS "${NATIVE_BIN_DIR}/src/emcc-default.rsp;${NATIVE_BIN_DIR}/src/es6/dotnet.es6.pre.js;${NATIVE_BIN_DIR}/src/es6/runtime.es6.iffe.js;${NATIVE_BIN_DIR}/src/es6/dotnet.es6.lib.js;${NATIVE_BIN_DIR}/src/pal_random.lib.js;${NATIVE_BIN_DIR}/src/es6/dotnet.es6.extpost.js;"
38+
LINK_FLAGS "@${NATIVE_BIN_DIR}/src/emcc-default.rsp @${NATIVE_BIN_DIR}/src/emcc-link.rsp ${CONFIGURATION_LINK_FLAGS} --extern-pre-js ${NATIVE_BIN_DIR}/src/es6/runtime.es6.iffe.js --pre-js ${NATIVE_BIN_DIR}/src/es6/dotnet.es6.pre.js --js-library ${NATIVE_BIN_DIR}/src/es6/dotnet.es6.lib.js --js-library ${NATIVE_BIN_DIR}/src/pal_random.lib.js --extern-post-js ${NATIVE_BIN_DIR}/src/es6/dotnet.es6.extpost.js "
3939
RUNTIME_OUTPUT_DIRECTORY "${NATIVE_BIN_DIR}")
4040

4141
set(ignoreMeWasmOptFlags "${CONFIGURATION_WASM_OPT_FLAGS}")

src/mono/wasm/runtime/assets.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,15 @@
33

44
import cwraps from "./cwraps";
55
import { mono_wasm_load_icu_data } from "./icu";
6-
import { ENVIRONMENT_IS_NODE, ENVIRONMENT_IS_SHELL, ENVIRONMENT_IS_WEB, Module, runtimeHelpers } from "./imports";
6+
import { ENVIRONMENT_IS_NODE, ENVIRONMENT_IS_SHELL, ENVIRONMENT_IS_WEB, Module, runtimeHelpers } from "./globals";
77
import { parseSymbolMapFile } from "./logging";
88
import { mono_wasm_load_bytes_into_heap } from "./memory";
99
import { endMeasure, MeasuredBlock, startMeasure } from "./profiler";
1010
import { createPromiseController, PromiseAndController } from "./promise-controller";
1111
import { delay } from "./promise-utils";
1212
import { abort_startup, beforeOnRuntimeInitialized, memorySnapshotSkippedOrDone } from "./startup";
13-
import { AssetBehaviours, AssetEntry, AssetEntryInternal, LoadingResource, mono_assert, ResourceRequest } from "./types";
13+
import { AssetEntryInternal, mono_assert } from "./types";
14+
import { AssetBehaviours, AssetEntry, LoadingResource, ResourceRequest } from "./types-api";
1415
import { InstantiateWasmSuccessCallback, VoidPtr } from "./types/emscripten";
1516

1617
const allAssetsInMemory = createPromiseController<void>();
@@ -314,7 +315,7 @@ async function start_asset_download_sources(asset: AssetEntryInternal): Promise<
314315
const loadingResource = download_resource(asset);
315316
asset.pendingDownloadInternal = loadingResource;
316317
response = await loadingResource.response;
317-
if (!response.ok) {
318+
if (!response || !response.ok) {
318319
continue;// next source
319320
}
320321
return response;

src/mono/wasm/runtime/blazor/BootConfig.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
// Licensed to the .NET Foundation under one or more agreements.
22
// The .NET Foundation licenses this file to you under the MIT license.
33

4-
import { Module } from "../imports";
5-
import { WebAssemblyBootResourceType } from "./WebAssemblyStartOptions";
4+
import { Module } from "../globals";
5+
import { WebAssemblyBootResourceType } from "../types-api";
66

77
type LoadBootResourceCallback = (type: WebAssemblyBootResourceType, name: string, defaultUri: string, integrity: string) => string | Promise<Response> | null | undefined;
88

src/mono/wasm/runtime/blazor/WebAssemblyResourceLoader.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
// Licensed to the .NET Foundation under one or more agreements.
22
// The .NET Foundation licenses this file to you under the MIT license.
33

4+
import { WebAssemblyBootResourceType, WebAssemblyStartOptions } from "../types-api";
45
import { toAbsoluteUri } from "./_Polyfill";
56
import { BootJsonData, ResourceList } from "./BootConfig";
6-
import { WebAssemblyStartOptions, WebAssemblyBootResourceType } from "./WebAssemblyStartOptions";
77
const networkFetchCacheMode = "no-cache";
88

99
export class WebAssemblyResourceLoader {

src/mono/wasm/runtime/blazor/WebAssemblyStartOptions.ts

Lines changed: 0 additions & 30 deletions
This file was deleted.

src/mono/wasm/runtime/blazor/_Integration.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
import { INTERNAL, Module } from "../imports";
2-
import { AssetEntry, LoadingResource, MonoConfigInternal } from "../types";
1+
import { INTERNAL, Module } from "../globals";
2+
import { MonoConfigInternal } from "../types";
3+
import { AssetEntry, LoadingResource, WebAssemblyBootResourceType } from "../types-api";
34
import { BootConfigResult, BootJsonData, ICUDataMode } from "./BootConfig";
45
import { WebAssemblyResourceLoader } from "./WebAssemblyResourceLoader";
5-
import { WebAssemblyBootResourceType } from "./WebAssemblyStartOptions";
66
import { hasDebuggingEnabled } from "./_Polyfill";
77

88
export async function loadBootConfig(config: MonoConfigInternal,) {

src/mono/wasm/runtime/config.ts

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
import type { DotnetModuleInternal, MonoConfigInternal } from "./types";
2+
import { DotnetModuleConfig } from "./types-api";
3+
4+
export function deep_merge_config(target: MonoConfigInternal, source: MonoConfigInternal): MonoConfigInternal {
5+
const providedConfig: MonoConfigInternal = { ...source };
6+
if (providedConfig.assets) {
7+
providedConfig.assets = [...(target.assets || []), ...(providedConfig.assets || [])];
8+
}
9+
if (providedConfig.environmentVariables) {
10+
providedConfig.environmentVariables = { ...(target.environmentVariables || {}), ...(providedConfig.environmentVariables || {}) };
11+
}
12+
if (providedConfig.startupOptions) {
13+
providedConfig.startupOptions = { ...(target.startupOptions || {}), ...(providedConfig.startupOptions || {}) };
14+
}
15+
if (providedConfig.runtimeOptions) {
16+
providedConfig.runtimeOptions = [...(target.runtimeOptions || []), ...(providedConfig.runtimeOptions || [])];
17+
}
18+
return Object.assign(target, providedConfig);
19+
}
20+
21+
export function deep_merge_module(target: DotnetModuleInternal, source: DotnetModuleConfig): DotnetModuleInternal {
22+
const providedConfig: DotnetModuleConfig = { ...source };
23+
if (providedConfig.config) {
24+
if (!target.config) target.config = {};
25+
providedConfig.config = deep_merge_config(target.config, providedConfig.config);
26+
}
27+
return Object.assign(target, providedConfig);
28+
}

src/mono/wasm/runtime/cwraps.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import type {
88
} from "./types";
99
import type { VoidPtr, CharPtrPtr, Int32Ptr, CharPtr, ManagedPointer } from "./types/emscripten";
1010
import WasmEnableLegacyJsInterop from "consts:WasmEnableLegacyJsInterop";
11-
import { disableLegacyJsInterop, Module } from "./imports";
11+
import { disableLegacyJsInterop, Module } from "./globals";
1212

1313
type SigLine = [lazy: boolean, name: string, returnType: string | null, argTypes?: string[], opts?: any];
1414

0 commit comments

Comments
 (0)