From 47a0b01eb91e27b81f9b05c808ab6cef2f6252dd Mon Sep 17 00:00:00 2001 From: pavelsavara Date: Thu, 25 Sep 2025 12:03:10 +0200 Subject: [PATCH 01/25] rebase --- .../corehost/browserhost/CMakeLists.txt | 8 +- .../corehost/browserhost/browserhost.cpp | 28 +- .../corehost/browserhost/cross-module.ts | 4 + .../corehost/browserhost/host/cross-linked.ts | 5 + src/native/corehost/browserhost/host/host.ts | 94 + src/native/corehost/browserhost/host/index.ts | 36 + .../corehost/browserhost/host/memory.ts | 271 +++ src/native/corehost/browserhost/host/types.ts | 4 + .../browserhost/libBrowserHost.footer.js | 66 + .../corehost/browserhost/libBrowserHost.js | 550 ------ .../corehost/browserhost/loader/bootstrap.ts | 137 ++ .../corehost/browserhost/loader/config.ts | 140 ++ .../browserhost/loader/cross-module.ts | 4 + .../corehost/browserhost/loader/dotnet.d.ts | 3 +- .../corehost/browserhost/loader/dotnet.js | 948 ---------- .../corehost/browserhost/loader/dotnet.ts | 24 + .../corehost/browserhost/loader/exit.ts | 15 + .../browserhost/loader/host-builder.ts | 174 ++ .../corehost/browserhost/loader/index.ts | 86 + .../browserhost/loader/lib-initializers.ts | 7 + .../corehost/browserhost/loader/logging.ts | 37 + .../corehost/browserhost/loader/polyfills.ts | 145 ++ .../loader/promise-completion-source.ts | 54 + src/native/corehost/browserhost/loader/run.ts | 35 + .../browserhost/loader/runtime-list.ts | 36 + .../corehost/browserhost/loader/types.ts | 4 + .../browserhost/sample/CMakeLists.txt | 2 + src/native/corehost/browserhost/types.ts | 4 + .../Common/JavaScript/cross-linked/index.ts | 23 + .../Common/JavaScript/cross-module/index.ts | 171 ++ .../libs/Common/JavaScript/types/exchange.ts | 12 +- .../libs/Common/JavaScript/types/internal.ts | 32 +- .../libs/System.Native.Browser/CMakeLists.txt | 30 +- .../System.Native.Browser/cross-module.ts | 4 + .../libSystem.Native.Browser.extpost.js | 12 +- .../libSystem.Native.Browser.footer.js | 56 + .../libSystem.Native.Browser.js | 279 --- .../native/cross-linked.ts | 22 + .../System.Native.Browser/native/crypto.ts | 40 + .../System.Native.Browser/native/index.ts | 19 + .../libs/System.Native.Browser/types.ts | 5 + .../dotnet.runtime.js | 177 -- .../dotnet.runtime.ts | 4 + .../interop/cross-module.ts | 4 + .../interop/index.ts | 30 + .../interop/types.ts | 22 + ...nteropServices.JavaScript.Native.footer.js | 46 + ...ntime.InteropServices.JavaScript.Native.js | 253 --- .../native/cross-linked.ts | 5 + .../native/index.ts | 21 + .../types.ts | 4 + src/native/package-lock.json | 1652 ++++++++--------- src/native/package.json | 31 +- src/native/rollup.config.defines.js | 40 + src/native/rollup.config.js | 163 ++ src/native/rollup.config.plugins.js | 156 ++ src/native/rollup.stub.js | 45 - src/native/tsconfig.json | 2 +- 58 files changed, 3065 insertions(+), 3216 deletions(-) create mode 100644 src/native/corehost/browserhost/cross-module.ts create mode 100644 src/native/corehost/browserhost/host/cross-linked.ts create mode 100644 src/native/corehost/browserhost/host/host.ts create mode 100644 src/native/corehost/browserhost/host/index.ts create mode 100644 src/native/corehost/browserhost/host/memory.ts create mode 100644 src/native/corehost/browserhost/host/types.ts create mode 100644 src/native/corehost/browserhost/libBrowserHost.footer.js delete mode 100644 src/native/corehost/browserhost/libBrowserHost.js create mode 100644 src/native/corehost/browserhost/loader/bootstrap.ts create mode 100644 src/native/corehost/browserhost/loader/config.ts create mode 100644 src/native/corehost/browserhost/loader/cross-module.ts delete mode 100644 src/native/corehost/browserhost/loader/dotnet.js create mode 100644 src/native/corehost/browserhost/loader/dotnet.ts create mode 100644 src/native/corehost/browserhost/loader/exit.ts create mode 100644 src/native/corehost/browserhost/loader/host-builder.ts create mode 100644 src/native/corehost/browserhost/loader/index.ts create mode 100644 src/native/corehost/browserhost/loader/lib-initializers.ts create mode 100644 src/native/corehost/browserhost/loader/logging.ts create mode 100644 src/native/corehost/browserhost/loader/polyfills.ts create mode 100644 src/native/corehost/browserhost/loader/promise-completion-source.ts create mode 100644 src/native/corehost/browserhost/loader/run.ts create mode 100644 src/native/corehost/browserhost/loader/runtime-list.ts create mode 100644 src/native/corehost/browserhost/loader/types.ts create mode 100644 src/native/corehost/browserhost/types.ts create mode 100644 src/native/libs/Common/JavaScript/cross-linked/index.ts create mode 100644 src/native/libs/Common/JavaScript/cross-module/index.ts create mode 100644 src/native/libs/System.Native.Browser/cross-module.ts create mode 100644 src/native/libs/System.Native.Browser/libSystem.Native.Browser.footer.js delete mode 100644 src/native/libs/System.Native.Browser/libSystem.Native.Browser.js create mode 100644 src/native/libs/System.Native.Browser/native/cross-linked.ts create mode 100644 src/native/libs/System.Native.Browser/native/crypto.ts create mode 100644 src/native/libs/System.Native.Browser/native/index.ts create mode 100644 src/native/libs/System.Native.Browser/types.ts delete mode 100644 src/native/libs/System.Runtime.InteropServices.JavaScript.Native/dotnet.runtime.js create mode 100644 src/native/libs/System.Runtime.InteropServices.JavaScript.Native/dotnet.runtime.ts create mode 100644 src/native/libs/System.Runtime.InteropServices.JavaScript.Native/interop/cross-module.ts create mode 100644 src/native/libs/System.Runtime.InteropServices.JavaScript.Native/interop/index.ts create mode 100644 src/native/libs/System.Runtime.InteropServices.JavaScript.Native/interop/types.ts create mode 100644 src/native/libs/System.Runtime.InteropServices.JavaScript.Native/libSystem.Runtime.InteropServices.JavaScript.Native.footer.js delete mode 100644 src/native/libs/System.Runtime.InteropServices.JavaScript.Native/libSystem.Runtime.InteropServices.JavaScript.Native.js create mode 100644 src/native/libs/System.Runtime.InteropServices.JavaScript.Native/native/cross-linked.ts create mode 100644 src/native/libs/System.Runtime.InteropServices.JavaScript.Native/native/index.ts create mode 100644 src/native/libs/System.Runtime.InteropServices.JavaScript.Native/types.ts create mode 100644 src/native/rollup.config.defines.js create mode 100644 src/native/rollup.config.js create mode 100644 src/native/rollup.config.plugins.js delete mode 100644 src/native/rollup.stub.js diff --git a/src/native/corehost/browserhost/CMakeLists.txt b/src/native/corehost/browserhost/CMakeLists.txt index bd3b54b9ffb521..c6254318d65634 100644 --- a/src/native/corehost/browserhost/CMakeLists.txt +++ b/src/native/corehost/browserhost/CMakeLists.txt @@ -72,9 +72,9 @@ if (UPPERCASE_CMAKE_BUILD_TYPE STREQUAL DEBUG) ) endif () -# TODO-WASM -sWASM_BIGINT=1 -# TODO-WASM -emit-llvm -# TODO-WASM --source-map-base http://microsoft.com +# WASM-TODO -sWASM_BIGINT=1 +# WASM-TODO -emit-llvm +# WASM-TODO --source-map-base http://microsoft.com target_link_options(browserhost PRIVATE -sINITIAL_MEMORY=134217728 -sMAXIMUM_MEMORY=2147483648 @@ -85,7 +85,7 @@ target_link_options(browserhost PRIVATE -sEXPORT_ES6=1 -sEXIT_RUNTIME=0 -sEXPORTED_RUNTIME_METHODS=UTF8ToString,cwrap,ccall,HEAPU8,HEAPU32,HEAPU64,BROWSER_HOST - -sEXPORTED_FUNCTIONS=_posix_memalign,_free,stackAlloc,stackRestore,stackSave,_browserHostInitializeCoreCLR,_browserHostExecuteAssembly,___cpp_exception + -sEXPORTED_FUNCTIONS=_posix_memalign,_free,stackAlloc,stackRestore,stackSave,_BrowserHost_InitializeCoreCLR,_BrowserHost_ExecuteAssembly,___cpp_exception -sEXPORT_NAME=createDotnetRuntime -fwasm-exceptions -msimd128 diff --git a/src/native/corehost/browserhost/browserhost.cpp b/src/native/corehost/browserhost/browserhost.cpp index 2bfd4850e3ede0..f975fedfeba9a8 100644 --- a/src/native/corehost/browserhost/browserhost.cpp +++ b/src/native/corehost/browserhost/browserhost.cpp @@ -50,9 +50,9 @@ extern "C" const void* GlobalizationResolveDllImport(const char* name); const void* CompressionResolveDllImport(const char* name); - bool browserHostExternalAssemblyProbe(const char* pathPtr, /*out*/ void **outDataStartPtr, /*out*/ int64_t* outSize); - void browserHostResolveMain(int exitCode); - void browserHostRejectMain(const char *reason); + bool BrowserHost_ExternalAssemblyProbe(const char* pathPtr, /*out*/ void **outDataStartPtr, /*out*/ int64_t* outSize); + void BrowserHost_ResolveMain(int exitCode); + void BrowserHost_RejectMain(const char *reason); } // The current CoreCLR instance details. @@ -64,13 +64,6 @@ static void log_error_info(const char* line) std::fprintf(stderr, "log error: %s\n", line); } -static bool external_assembly_probe(const char* path, /*out*/ void **data_start, /*out*/ int64_t* size) -{ - *size = 0; - *data_start = nullptr; - return browserHostExternalAssemblyProbe(path, data_start, size);; -} - static const void* pinvoke_override(const char* library_name, const char* entry_point_name) { if (strcmp(library_name, "libSystem.Native") == 0) @@ -107,9 +100,11 @@ static std::vector propertyKeys; static std::vector propertyValues; static pal::char_t ptr_to_string_buffer[STRING_LENGTH("0xffffffffffffffff") + 1]; -extern "C" int browserHostInitializeCoreCLR(void) +// WASM-TODO: pass TPA via argument, not env +// WASM-TODO: pass app_path via argument, not env +// WASM-TODO: pass search_paths via argument, not env +extern "C" int BrowserHost_InitializeCoreCLR(void) { - //WASM-TODO: does getenv return UTF8 ? pal::getenv(HOST_PROPERTY_APP_PATHS, &app_path); pal::getenv(HOST_PROPERTY_NATIVE_DLL_SEARCH_DIRECTORIES, &search_paths); pal::getenv(HOST_PROPERTY_TRUSTED_PLATFORM_ASSEMBLIES, &tpa); @@ -124,7 +119,7 @@ extern "C" int browserHostInitializeCoreCLR(void) host_runtime_contract host_contract = { sizeof(host_runtime_contract), nullptr }; host_contract.pinvoke_override = &pinvoke_override; - host_contract.external_assembly_probe = &external_assembly_probe; + host_contract.external_assembly_probe = &BrowserHost_ExternalAssemblyProbe; pal::snwprintf(ptr_to_string_buffer, ARRAY_SIZE(ptr_to_string_buffer), _X("0x%zx"), (size_t)(&host_contract)); @@ -144,7 +139,8 @@ extern "C" int browserHostInitializeCoreCLR(void) } // WASM-TODO: browser needs async entrypoint -extern "C" int browserHostExecuteAssembly(const char* assemblyPath) +// WASM-TODO: don't coreclr_shutdown_2 when browser +extern "C" int BrowserHost_ExecuteAssembly(const char* assemblyPath) { int exit_code; int retval = coreclr_execute_assembly(CurrentClrInstance, CurrentAppDomainId, 0, nullptr, assemblyPath, (uint32_t*)&exit_code); @@ -164,11 +160,11 @@ extern "C" int browserHostExecuteAssembly(const char* assemblyPath) std::fprintf(stderr, "coreclr_shutdown_2 failed - Error: 0x%08x\n", retval); exit_code = -1; // WASM-TODO: this is too trivial - browserHostRejectMain("coreclr_shutdown_2 failed"); + BrowserHost_RejectMain("coreclr_shutdown_2 failed"); } // WASM-TODO: this is too trivial // because nothing runs continuations yet and also coreclr_execute_assembly is sync looping - browserHostResolveMain(exit_code); + BrowserHost_ResolveMain(exit_code); return retval; } diff --git a/src/native/corehost/browserhost/cross-module.ts b/src/native/corehost/browserhost/cross-module.ts new file mode 100644 index 00000000000000..fb464fa0869070 --- /dev/null +++ b/src/native/corehost/browserhost/cross-module.ts @@ -0,0 +1,4 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +export * from "../../libs/Common/JavaScript/cross-module"; diff --git a/src/native/corehost/browserhost/host/cross-linked.ts b/src/native/corehost/browserhost/host/cross-linked.ts new file mode 100644 index 00000000000000..4feb7945cefe29 --- /dev/null +++ b/src/native/corehost/browserhost/host/cross-linked.ts @@ -0,0 +1,5 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +import { } from "../../../libs/Common/JavaScript/cross-linked"; + diff --git a/src/native/corehost/browserhost/host/host.ts b/src/native/corehost/browserhost/host/host.ts new file mode 100644 index 00000000000000..84a4edfac889e3 --- /dev/null +++ b/src/native/corehost/browserhost/host/host.ts @@ -0,0 +1,94 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +import type { CharPtr, VoidPtr, VoidPtrPtr } from "./types"; +import { } from "./cross-linked"; // ensure ambient symbols are declared + +const loadedAssemblies : Map = new Map(); + +export function registerDllBytes(bytes: Uint8Array, asset: { name: string }) { + const sp = Module.stackSave(); + try { + const sizeOfPtr = 4; + const ptrPtr = Module.stackAlloc(sizeOfPtr); + if (Module._posix_memalign(ptrPtr as any, 16, bytes.length)) { + throw new Error("posix_memalign failed"); + } + + const ptr = Module.HEAPU32[ptrPtr as any >>> 2]; + Module.HEAPU8.set(bytes, ptr); + loadedAssemblies.set(asset.name, { ptr, length: bytes.length }); + } finally { + Module.stackRestore(sp); + } +} + +// bool BrowserHost_ExternalAssemblyProbe(const char* pathPtr, /*out*/ void **outDataStartPtr, /*out*/ int64_t* outSize); +export function BrowserHost_ExternalAssemblyProbe(pathPtr:CharPtr, outDataStartPtr:VoidPtrPtr, outSize:VoidPtr) { + const path = Module.UTF8ToString(pathPtr); + const assembly = loadedAssemblies.get(path); + if (assembly) { + Module.HEAPU32[outDataStartPtr as any >>> 2] = assembly.ptr; + // int64_t target + Module.HEAPU32[outSize as any >>> 2] = assembly.length; + Module.HEAPU32[((outSize as any) + 4) >>> 2] = 0; + return true; + } + Module.HEAPU32[outDataStartPtr as any >>> 2] = 0; + Module.HEAPU32[outSize as any >>> 2] = 0; + Module.HEAPU32[((outSize as any) + 4) >>> 2] = 0; + return false; +} + +export function BrowserHost_ResolveMain(exitCode:number) { + netLoaderExports.resolveRunMainPromise(exitCode); +} + +export function BrowserHost_RejectMain(reason:any) { + netLoaderExports.rejectRunMainPromise(reason); +} + +// WASM-TODO: take ideas from Mono +// - second call to exit should be silent +// - second call to exit not override the first exit code +// - improve reason extraction +// - install global handler for unhandled exceptions and promise rejections +export function exit(exit_code: number, reason: any): void { + const reasonStr = reason ? (reason.stack ? reason.stack || reason.message : reason.toString()) : ""; + if (exit_code !== 0) { + Logger.error(`Exit with code ${exit_code} ${reason ? "and reason: " + reasonStr : ""}`); + } + if (netJSEngine.IS_NODE) { + (globalThis as any).process.exit(exit_code); + } +} + +// eslint-disable-next-line @typescript-eslint/no-unused-vars +export async function runMain(mainAssemblyName?: string, args?: string[]): Promise { + // int BrowserHost_ExecuteAssembly(char * assemblyPath) + const res = Module.ccall("BrowserHost_ExecuteAssembly", "number", ["string"], [mainAssemblyName]) as number; + if (res != 0) { + const reason = new Error("Failed to execute assembly"); + exit(res, reason); + throw reason; + } + + return netLoaderExports.getRunMainPromise(); +} + +// eslint-disable-next-line @typescript-eslint/no-unused-vars +export async function runMainAndExit(mainAssemblyName?: string, args?: string[]): Promise { + try { + await runMain(mainAssemblyName, args); + } catch (error) { + exit(1, error); + throw error; + } + exit(0, null); + return 0; +} + +// eslint-disable-next-line @typescript-eslint/no-unused-vars +export function setEnvironmentVariable(name: string, value: string): void { + throw new Error("Not implemented"); +} diff --git a/src/native/corehost/browserhost/host/index.ts b/src/native/corehost/browserhost/host/index.ts new file mode 100644 index 00000000000000..95904ecabfd43c --- /dev/null +++ b/src/native/corehost/browserhost/host/index.ts @@ -0,0 +1,36 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +import type { InternalExchange, HostNativeExports, RuntimeAPI } from "./types"; +import { } from "./cross-linked"; // ensure ambient symbols are declared + +import { exit, runMain, runMainAndExit, setEnvironmentVariable, registerDllBytes } from "./host"; +import { + setHeapB32, setHeapB8, setHeapU8, setHeapU16, setHeapU32, setHeapI8, setHeapI16, setHeapI32, setHeapI52, setHeapU52, setHeapI64Big, setHeapF32, setHeapF64, + getHeapB32, getHeapB8, getHeapU8, getHeapU16, getHeapU32, getHeapI8, getHeapI16, getHeapI32, getHeapI52, getHeapU52, getHeapI64Big, getHeapF32, getHeapF64, + localHeapViewI8, localHeapViewI16, localHeapViewI32, localHeapViewI64Big, localHeapViewU8, localHeapViewU16, localHeapViewU32, localHeapViewF32, localHeapViewF64, + isSharedArrayBuffer, +} from "./memory"; + +export function netInitializeModule(internals: InternalExchange): void { + const runtimeApiLocal: Partial = { + runMain, + runMainAndExit, + setEnvironmentVariable, + exit, + setHeapB32, setHeapB8, setHeapU8, setHeapU16, setHeapU32, setHeapI8, setHeapI16, setHeapI32, setHeapI52, setHeapU52, setHeapI64Big, setHeapF32, setHeapF64, + getHeapB32, getHeapB8, getHeapU8, getHeapU16, getHeapU32, getHeapI8, getHeapI16, getHeapI32, getHeapI52, getHeapU52, getHeapI64Big, getHeapF32, getHeapF64, + localHeapViewI8, localHeapViewI16, localHeapViewI32, localHeapViewI64Big, localHeapViewU8, localHeapViewU16, localHeapViewU32, localHeapViewF32, localHeapViewF64, + }; + + const hostNativeExportsLocal: HostNativeExports = { + registerDllBytes, + isSharedArrayBuffer + }; + netSetInternals(internals); + Object.assign(internals.netPublicApi, runtimeApiLocal); + internals.netBrowserHostExportsTable = [...netTabulateHE(hostNativeExportsLocal)]; + netUpdateAllInternals(); +} + +export { BrowserHost_ExternalAssemblyProbe, BrowserHost_ResolveMain, BrowserHost_RejectMain } from "./host"; diff --git a/src/native/corehost/browserhost/host/memory.ts b/src/native/corehost/browserhost/host/memory.ts new file mode 100644 index 00000000000000..1262382c46aac4 --- /dev/null +++ b/src/native/corehost/browserhost/host/memory.ts @@ -0,0 +1,271 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +import type { MemOffset, NumberOrPointer, VoidPtr } from "./types"; +import { } from "./cross-linked"; // ensure ambient symbols are declared + +export const max_int64_big = BigInt("9223372036854775807"); +export const min_int64_big = BigInt("-9223372036854775808"); +export const sharedArrayBufferDefined = typeof SharedArrayBuffer !== "undefined"; + +export function assert_int_in_range(value: Number, min: Number, max: Number) { + Assert.check(Number.isSafeInteger(value), () => `Value is not an integer: ${value} (${typeof (value)})`); + Assert.check(value >= min && value <= max, () => `Overflow: value ${value} is out of ${min} ${max} range`); +} + +export function _zero_region(byteOffset: VoidPtr, sizeBytes: number): void { + localHeapViewU8().fill(0, byteOffset, byteOffset + sizeBytes); +} + +/** note: boolean is 8 bits not 32 bits when inside a structure or array */ +export function setHeapB32(offset: MemOffset, value: number | boolean): void { + const boolValue = !!value; + if (typeof (value) === "number") + assert_int_in_range(value, 0, 1); + Module.HEAP32[offset >>> 2] = boolValue ? 1 : 0; +} + +export function setHeapB8(offset: MemOffset, value: number | boolean): void { + const boolValue = !!value; + if (typeof (value) === "number") + assert_int_in_range(value, 0, 1); + Module.HEAPU8[offset] = boolValue ? 1 : 0; +} + +export function setHeapU8(offset: MemOffset, value: number): void { + assert_int_in_range(value, 0, 0xFF); + Module.HEAPU8[offset] = value; +} + +export function setHeapU16(offset: MemOffset, value: number): void { + assert_int_in_range(value, 0, 0xFFFF); + Module.HEAPU16[offset >>> 1] = value; +} + +// does not check for growable heap +export function setHeapU16_local(localView: Uint16Array, offset: MemOffset, value: number): void { + assert_int_in_range(value, 0, 0xFFFF); + localView[offset >>> 1] = value; +} + +// does not check for overflow nor growable heap +export function setHeapU16_unchecked(offset: MemOffset, value: number): void { + Module.HEAPU16[offset >>> 1] = value; +} + +// does not check for overflow nor growable heap +export function setHeapU32_unchecked(offset: MemOffset, value: NumberOrPointer): void { + Module.HEAPU32[offset >>> 2] = value; +} + +export function setHeapU32(offset: MemOffset, value: NumberOrPointer): void { + assert_int_in_range(value, 0, 0xFFFF_FFFF); + Module.HEAPU32[offset >>> 2] = value; +} + +export function setHeapI8(offset: MemOffset, value: number): void { + assert_int_in_range(value, -0x80, 0x7F); + Module.HEAP8[offset] = value; +} + +export function setHeapI16(offset: MemOffset, value: number): void { + assert_int_in_range(value, -0x8000, 0x7FFF); + Module.HEAP16[offset >>> 1] = value; +} + +export function setHeapI32_unchecked(offset: MemOffset, value: number): void { + Module.HEAP32[offset >>> 2] = value; +} + +export function setHeapI32(offset: MemOffset, value: number): void { + assert_int_in_range(value, -0x8000_0000, 0x7FFF_FFFF); + Module.HEAP32[offset >>> 2] = value; +} + +/** + * Throws for values which are not 52 bit integer. See Number.isSafeInteger() + */ +export function setHeapI52(offset: MemOffset, value: number): void { + Assert.check(Number.isSafeInteger(value), () => `Value is not a safe integer: ${value} (${typeof (value)})`); + throw new Error("TODO"); + // const error = cwraps.mono_wasm_f64_to_i52(offset, value); + // autoThrowI52(error); +} + +/** + * Throws for values which are not 52 bit integer or are negative. See Number.isSafeInteger(). + */ +export function setHeapU52(offset: MemOffset, value: number): void { + Assert.check(Number.isSafeInteger(value), () => `Value is not a safe integer: ${value} (${typeof (value)})`); + Assert.check(value >= 0, "Can't convert negative Number into UInt64"); + throw new Error("TODO"); + //const error = cwraps.mono_wasm_f64_to_u52(offset, value); + //autoThrowI52(error); +} + +export function setHeapI64Big(offset: MemOffset, value: bigint): void { + Assert.check(typeof value === "bigint", () => `Value is not an bigint: ${value} (${typeof (value)})`); + Assert.check(value >= min_int64_big && value <= max_int64_big, () => `Overflow: value ${value} is out of ${min_int64_big} ${max_int64_big} range`); + + Module.HEAP64[offset >>> 3] = value; +} + +export function setHeapF32(offset: MemOffset, value: number): void { + Assert.check(typeof value === "number", () => `Value is not a Number: ${value} (${typeof (value)})`); + Module.HEAPF32[offset >>> 2] = value; +} + +export function setHeapF64(offset: MemOffset, value: number): void { + Assert.check(typeof value === "number", () => `Value is not a Number: ${value} (${typeof (value)})`); + Module.HEAPF64[offset >>> 3] = value; +} + +export function getHeapB32(offset: MemOffset): boolean { + const value = (Module.HEAPU32[offset >>> 2]); + if (value > 1 && !(getHeapB32 as any).warnDirtyBool) { + (getHeapB32 as any).warnDirtyBool = true; + Logger.warn(`getB32: value at ${offset} is not a boolean, but a number: ${value}`); + } + return !!value; +} + +export function getHeapB8(offset: MemOffset): boolean { + return !!(Module.HEAPU8[offset]); +} + +export function getHeapU8(offset: MemOffset): number { + return Module.HEAPU8[offset]; +} + +export function getHeapU16(offset: MemOffset): number { + return Module.HEAPU16[offset >>> 1]; +} + +// does not check for growable heap +export function getHeapU16_local(localView: Uint16Array, offset: MemOffset): number { + return localView[offset >>> 1]; +} + +export function getHeapU32(offset: MemOffset): number { + return Module.HEAPU32[offset >>> 2]; +} + +// does not check for growable heap +export function getHeapU32_local(localView: Uint32Array, offset: MemOffset): number { + return localView[offset >>> 2]; +} + +export function getHeapI8(offset: MemOffset): number { + return Module.HEAP8[offset]; +} + +export function getHeapI16(offset: MemOffset): number { + return Module.HEAP16[offset >>> 1]; +} + +// does not check for growable heap +export function getHeapI16_local(localView: Int16Array, offset: MemOffset): number { + return localView[offset >>> 1]; +} + +export function getHeapI32(offset: MemOffset): number { + return Module.HEAP32[offset >>> 2]; +} + +// does not check for growable heap +export function getHeapI32_local(localView: Int32Array, offset: MemOffset): number { + return localView[offset >>> 2]; +} + +/** + * Throws for Number.MIN_SAFE_INTEGER > value > Number.MAX_SAFE_INTEGER + */ +// eslint-disable-next-line @typescript-eslint/no-unused-vars +export function getHeapI52(offset: MemOffset): number { + throw new Error("TODO"); + //const result = cwraps.mono_wasm_i52_to_f64(offset, runtimeHelpers._i52_error_scratch_buffer); + //const error = getI32(runtimeHelpers._i52_error_scratch_buffer); + //autoThrowI52(error); + //return result; +} + +/** + * Throws for 0 > value > Number.MAX_SAFE_INTEGER + */ +// eslint-disable-next-line @typescript-eslint/no-unused-vars +export function getHeapU52(offset: MemOffset): number { + throw new Error("TODO"); + //const result = cwraps.mono_wasm_u52_to_f64(offset, runtimeHelpers._i52_error_scratch_buffer); + //const error = getI32(runtimeHelpers._i52_error_scratch_buffer); + //autoThrowI52(error); + //return result; +} + +export function getHeapI64Big(offset: MemOffset): bigint { + return Module.HEAP64[offset >>> 3]; +} + +export function getHeapF32(offset: MemOffset): number { + return Module.HEAPF32[offset >>> 2]; +} + +export function getHeapF64(offset: MemOffset): number { + return Module.HEAPF64[offset >>> 3]; +} + +// returns memory view which is valid within current synchronous call stack +export function localHeapViewI8(): Int8Array { + return Module.HEAP8; +} + +// returns memory view which is valid within current synchronous call stack +export function localHeapViewI16(): Int16Array { + return Module.HEAP16; +} + +// returns memory view which is valid within current synchronous call stack +export function localHeapViewI32(): Int32Array { + return Module.HEAP32; +} + +// returns memory view which is valid within current synchronous call stack +export function localHeapViewI64Big(): BigInt64Array { + return Module.HEAP64; +} + +// returns memory view which is valid within current synchronous call stack +export function localHeapViewU8(): Uint8Array { + return Module.HEAPU8; +} + +// returns memory view which is valid within current synchronous call stack +export function localHeapViewU16(): Uint16Array { + return Module.HEAPU16; +} + +// returns memory view which is valid within current synchronous call stack +export function localHeapViewU32(): Uint32Array { + return Module.HEAPU32; +} + +// returns memory view which is valid within current synchronous call stack +export function localHeapViewF32(): Float32Array { + return Module.HEAPF32; +} + +// returns memory view which is valid within current synchronous call stack +export function localHeapViewF64(): Float64Array { + return Module.HEAPF64; +} + +export function copyBytes(srcPtr: VoidPtr, dstPtr: VoidPtr, bytes: number): void { + const heap = localHeapViewU8(); + heap.copyWithin(dstPtr as any, srcPtr as any, srcPtr as any + bytes); +} + +export function isSharedArrayBuffer(buffer: any): buffer is SharedArrayBuffer { + // BEWARE: In some cases, `instanceof SharedArrayBuffer` returns false even though buffer is an SAB. + // Patch adapted from https://github.com/emscripten-core/emscripten/pull/16994 + // See also https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Symbol/toStringTag + return sharedArrayBufferDefined && buffer[Symbol.toStringTag] === "SharedArrayBuffer"; +} diff --git a/src/native/corehost/browserhost/host/types.ts b/src/native/corehost/browserhost/host/types.ts new file mode 100644 index 00000000000000..2786379af7369f --- /dev/null +++ b/src/native/corehost/browserhost/host/types.ts @@ -0,0 +1,4 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +export * from "../types"; diff --git a/src/native/corehost/browserhost/libBrowserHost.footer.js b/src/native/corehost/browserhost/libBrowserHost.footer.js new file mode 100644 index 00000000000000..d563164e28a9f0 --- /dev/null +++ b/src/native/corehost/browserhost/libBrowserHost.footer.js @@ -0,0 +1,66 @@ +//! Licensed to the .NET Foundation under one or more agreements. +//! The .NET Foundation licenses this file to you under the MIT license. + +/** + * This is root of **Emscripten library** that would become part of `dotnet.native.js` + * It implements the corehost and a part of public JS API related to memory and runtime hosting. + */ + +(function (exports) { + function libFactory() { + const lib = { + $BROWSER_HOST: { + selfInitialize: () => { + if (typeof netInternals !== "undefined") { + BROWSER_HOST.netInternals = netInternals; + + const exports = {}; + libBrowserHostFn(exports); + exports.netInitializeModule(netInternals); + BROWSER_HOST.assignExports(exports, BROWSER_HOST); + + const HOST_PROPERTY_TRUSTED_PLATFORM_ASSEMBLIES = "TRUSTED_PLATFORM_ASSEMBLIES"; + const HOST_PROPERTY_ENTRY_ASSEMBLY_NAME = "ENTRY_ASSEMBLY_NAME"; + const HOST_PROPERTY_NATIVE_DLL_SEARCH_DIRECTORIES = "NATIVE_DLL_SEARCH_DIRECTORIES"; + const HOST_PROPERTY_APP_PATHS = "APP_PATHS"; + + const config = netInternals.netLoaderConfig; + const assemblyPaths = config.resources.assembly.map(a => a.virtualPath); + const coreAssemblyPaths = config.resources.coreAssembly.map(a => a.virtualPath); + // WASM-TODO: pass TPA via argument, not env + ENV[HOST_PROPERTY_TRUSTED_PLATFORM_ASSEMBLIES] = config.environmentVariables[HOST_PROPERTY_TRUSTED_PLATFORM_ASSEMBLIES] = [...coreAssemblyPaths, ...assemblyPaths].join(":"); + ENV[HOST_PROPERTY_NATIVE_DLL_SEARCH_DIRECTORIES] = config.environmentVariables[HOST_PROPERTY_NATIVE_DLL_SEARCH_DIRECTORIES] = config.virtualWorkingDirectory; + ENV[HOST_PROPERTY_APP_PATHS] = config.environmentVariables[HOST_PROPERTY_APP_PATHS] = config.virtualWorkingDirectory; + ENV[HOST_PROPERTY_ENTRY_ASSEMBLY_NAME] = config.environmentVariables[HOST_PROPERTY_ENTRY_ASSEMBLY_NAME] = config.mainAssemblyName; + } + }, + }, + $libBrowserHostFn: libBrowserHost, + $BROWSER_HOST__postset: "BROWSER_HOST.selfInitialize()", + }; + + // this executes the function at link time in order to capture exports + // this is what Emscripten does for linking JS libraries + // https://emscripten.org/docs/porting/connecting_cpp_and_javascript/Interacting-with-code.html#javascript-limits-in-library-files + // it would execute the code at link time and call .toString() on functions to move it to the final output + // this process would loose any closure references, unless they are passed to `__deps` and also explicitly given to the linker + // JS name mangling and minification also applies, see src\native\rollup.config.defines.js and `reservedRx` there + const exports = {} + libBrowserHost(exports); + let commonDeps = ["$libBrowserHostFn", "$DOTNET", "$DOTNET_INTEROP", "$ENV"]; + let assignExportsBuilder = ""; + for (const exportName of Reflect.ownKeys(exports)) { + const name = String(exportName); + if (name === "netInitializeModule") continue; + lib[name] = () => "dummy"; + assignExportsBuilder += `_${String(name)} = exports.${String(name)};\n`; + } + lib.$BROWSER_HOST.assignExports = new Function("exports", assignExportsBuilder); + lib["$BROWSER_HOST__deps"] = commonDeps; + + autoAddDeps(lib, "$BROWSER_HOST"); + addToLibrary(lib); + } + libFactory(); + return exports; +})({}); \ No newline at end of file diff --git a/src/native/corehost/browserhost/libBrowserHost.js b/src/native/corehost/browserhost/libBrowserHost.js deleted file mode 100644 index b9b27dd9436849..00000000000000 --- a/src/native/corehost/browserhost/libBrowserHost.js +++ /dev/null @@ -1,550 +0,0 @@ -//! Licensed to the .NET Foundation under one or more agreements. -//! The .NET Foundation licenses this file to you under the MIT license. -//! This is generated file, see src/native/libs/Browser/rollup.config.defines.js - - -var libBrowserHost = (function (exports) { - 'use strict'; - - // Licensed to the .NET Foundation under one or more agreements. - // The .NET Foundation licenses this file to you under the MIT license. - let Module; - let runtimeApi; - let Logger = {}; - let Assert = {}; - let JSEngine = {}; - let loaderExports = {}; - let runtimeExports = {}; - let hostExports = {}; - let interopExports = {}; - let nativeBrowserExports = {}; - let dotnetInternals; - function getInternals() { - return dotnetInternals; - } - function setInternals(internal) { - dotnetInternals = internal; - runtimeApi = dotnetInternals.runtimeApi; - Module = dotnetInternals.runtimeApi.Module; - } - function updateAllInternals() { - if (dotnetInternals.updates === undefined) { - dotnetInternals.updates = []; - } - for (const updateImpl of dotnetInternals.updates) { - updateImpl(); - } - } - function updateMyInternals() { - if (Object.keys(loaderExports).length === 0 && dotnetInternals.loaderExportsTable) { - loaderExports = {}; - Logger = {}; - Assert = {}; - JSEngine = {}; - expandLE(dotnetInternals.loaderExportsTable, Logger, Assert, JSEngine, loaderExports); - } - if (Object.keys(runtimeExports).length === 0 && dotnetInternals.runtimeExportsTable) { - runtimeExports = {}; - expandRE(dotnetInternals.runtimeExportsTable, runtimeExports); - } - if (Object.keys(hostExports).length === 0 && dotnetInternals.hostNativeExportsTable) { - hostExports = {}; - expandHE(dotnetInternals.hostNativeExportsTable, hostExports); - } - if (Object.keys(interopExports).length === 0 && dotnetInternals.interopJavaScriptNativeExportsTable) { - interopExports = {}; - expandJSNE(dotnetInternals.interopJavaScriptNativeExportsTable, interopExports); - } - if (Object.keys(nativeBrowserExports).length === 0 && dotnetInternals.nativeBrowserExportsTable) { - nativeBrowserExports = {}; - expandNBE(dotnetInternals.nativeBrowserExportsTable, nativeBrowserExports); - } - } - /** - * Functions below allow our JS modules to exchange internal interfaces by passing tables of functions in known order instead of using string symbols. - * IMPORTANT: If you need to add more functions, make sure that you add them at the end of the table, so that the order of existing functions does not change. - */ - function tabulateLE(logger, assert, loaderExports) { - return [ - logger.info, - logger.warn, - logger.error, - assert.check, - loaderExports.ENVIRONMENT_IS_NODE, - loaderExports.ENVIRONMENT_IS_SHELL, - loaderExports.ENVIRONMENT_IS_WEB, - loaderExports.ENVIRONMENT_IS_WORKER, - loaderExports.ENVIRONMENT_IS_SIDECAR, - loaderExports.browserHostResolveMain, - loaderExports.browserHostRejectMain, - loaderExports.getRunMainPromise, - ]; - } - function expandLE(table, logger, assert, jsEngine, loaderExports) { - const loggerLocal = { - info: table[0], - warn: table[1], - error: table[2], - }; - const assertLocal = { - check: table[3], - }; - const loaderExportsLocal = { - ENVIRONMENT_IS_NODE: table[4], - ENVIRONMENT_IS_SHELL: table[5], - ENVIRONMENT_IS_WEB: table[6], - ENVIRONMENT_IS_WORKER: table[7], - ENVIRONMENT_IS_SIDECAR: table[8], - browserHostResolveMain: table[9], - browserHostRejectMain: table[10], - getRunMainPromise: table[11], - }; - const jsEngineLocal = { - IS_NODE: loaderExportsLocal.ENVIRONMENT_IS_NODE(), - IS_SHELL: loaderExportsLocal.ENVIRONMENT_IS_SHELL(), - IS_WEB: loaderExportsLocal.ENVIRONMENT_IS_WEB(), - IS_WORKER: loaderExportsLocal.ENVIRONMENT_IS_WORKER(), - IS_SIDECAR: loaderExportsLocal.ENVIRONMENT_IS_SIDECAR(), - }; - Object.assign(loaderExports, loaderExportsLocal); - Object.assign(logger, loggerLocal); - Object.assign(assert, assertLocal); - Object.assign(jsEngine, jsEngineLocal); - } - // eslint-disable-next-line @typescript-eslint/no-unused-vars - function tabulateRE(map) { - return []; - } - function expandRE(table, runtime) { - Object.assign(runtime, {}); - } - function tabulateHE(map) { - return [ - map.registerDllBytes, - map.isSharedArrayBuffer, - ]; - } - function expandHE(table, native) { - const nativeLocal = { - registerDllBytes: table[0], - isSharedArrayBuffer: table[1], - }; - Object.assign(native, nativeLocal); - } - // eslint-disable-next-line @typescript-eslint/no-unused-vars - function tabulateJSNE(map) { - return []; - } - function expandJSNE(table, interop) { - const interopLocal = {}; - Object.assign(interop, interopLocal); - } - // eslint-disable-next-line @typescript-eslint/no-unused-vars - function tabulateNBE(map) { - return []; - } - function expandNBE(table, interop) { - const interopLocal = {}; - Object.assign(interop, interopLocal); - } - - // Licensed to the .NET Foundation under one or more agreements. - // The .NET Foundation licenses this file to you under the MIT license. - - // Licensed to the .NET Foundation under one or more agreements. - // The .NET Foundation licenses this file to you under the MIT license. - // see also `reserved` in `rollup.config.defines.js` - - // Licensed to the .NET Foundation under one or more agreements. - // The .NET Foundation licenses this file to you under the MIT license. - const loadedAssemblies = {}; - function registerDllBytes(bytes, asset) { - const sp = Module.stackSave(); - try { - const sizeOfPtr = 4; - const ptrPtr = Module.stackAlloc(sizeOfPtr); - if (Module._posix_memalign(ptrPtr, 16, bytes.length)) { - throw new Error("posix_memalign failed"); - } - const ptr = Module.HEAPU32[ptrPtr >>> 2]; - Module.HEAPU8.set(bytes, ptr); - loadedAssemblies[asset.name] = { ptr, length: bytes.length }; - } - finally { - Module.stackRestore(sp); - } - } - // bool browserHostExternalAssemblyProbe(const char* pathPtr, /*out*/ void **outDataStartPtr, /*out*/ int64_t* outSize); - function browserHostExternalAssemblyProbe(pathPtr, outDataStartPtr, outSize) { - const path = Module.UTF8ToString(pathPtr); - const assembly = loadedAssemblies[path]; - if (assembly) { - Module.HEAPU32[outDataStartPtr >>> 2] = assembly.ptr; - // int64_t target - Module.HEAPU32[outSize >>> 2] = assembly.length; - Module.HEAPU32[(outSize + 4) >>> 2] = 0; - return true; - } - Module.HEAPU32[outDataStartPtr >>> 2] = 0; - Module.HEAPU32[outSize >>> 2] = 0; - Module.HEAPU32[(outSize + 4) >>> 2] = 0; - return false; - } - function browserHostResolveMain(exitCode) { - loaderExports.browserHostResolveMain(exitCode); - } - function browserHostRejectMain(reason) { - loaderExports.browserHostRejectMain(reason); - } - // TODO-WASM: take ideas from Mono - // - second call to exit should be silent - // - second call to exit not override the first exit code - // - improve reason extraction - // - install global handler for unhandled exceptions and promise rejections - function exit(exit_code, reason) { - const reasonStr = reason ? (reason.stack ? reason.stack || reason.message : reason.toString()) : ""; - if (exit_code !== 0) { - Logger.error(`Exit with code ${exit_code} ${reason ? "and reason: " + reasonStr : ""}`); - } - if (JSEngine.IS_NODE) { - globalThis.process.exit(exit_code); - } - } - // eslint-disable-next-line @typescript-eslint/no-unused-vars - async function runMain(mainAssemblyName, args) { - // int browserHostExecuteAssembly(char * assemblyPath) - const res = Module.ccall("browserHostExecuteAssembly", "number", ["string"], [mainAssemblyName]); - if (res != 0) { - const reason = new Error("Failed to execute assembly"); - exit(res, reason); - throw reason; - } - return loaderExports.getRunMainPromise(); - } - // eslint-disable-next-line @typescript-eslint/no-unused-vars - async function runMainAndExit(mainAssemblyName, args) { - try { - await runMain(mainAssemblyName, args); - } - catch (error) { - exit(1, error); - throw error; - } - exit(0, null); - return 0; - } - // eslint-disable-next-line @typescript-eslint/no-unused-vars - function setEnvironmentVariable(name, value) { - throw new Error("Not implemented"); - } - - // Licensed to the .NET Foundation under one or more agreements. - // The .NET Foundation licenses this file to you under the MIT license. - const max_int64_big = BigInt("9223372036854775807"); - const min_int64_big = BigInt("-9223372036854775808"); - const sharedArrayBufferDefined = typeof SharedArrayBuffer !== "undefined"; - function assert_int_in_range(value, min, max) { - Assert.check(Number.isSafeInteger(value), () => `Value is not an integer: ${value} (${typeof (value)})`); - Assert.check(value >= min && value <= max, () => `Overflow: value ${value} is out of ${min} ${max} range`); - } - function _zero_region(byteOffset, sizeBytes) { - localHeapViewU8().fill(0, byteOffset, byteOffset + sizeBytes); - } - /** note: boolean is 8 bits not 32 bits when inside a structure or array */ - function setHeapB32(offset, value) { - const boolValue = !!value; - if (typeof (value) === "number") - assert_int_in_range(value, 0, 1); - Module.HEAP32[offset >>> 2] = boolValue ? 1 : 0; - } - function setHeapB8(offset, value) { - const boolValue = !!value; - if (typeof (value) === "number") - assert_int_in_range(value, 0, 1); - Module.HEAPU8[offset] = boolValue ? 1 : 0; - } - function setHeapU8(offset, value) { - assert_int_in_range(value, 0, 0xFF); - Module.HEAPU8[offset] = value; - } - function setHeapU16(offset, value) { - assert_int_in_range(value, 0, 0xFFFF); - Module.HEAPU16[offset >>> 1] = value; - } - // does not check for growable heap - function setHeapU16_local(localView, offset, value) { - assert_int_in_range(value, 0, 0xFFFF); - localView[offset >>> 1] = value; - } - // does not check for overflow nor growable heap - function setHeapU16_unchecked(offset, value) { - Module.HEAPU16[offset >>> 1] = value; - } - // does not check for overflow nor growable heap - function setHeapU32_unchecked(offset, value) { - Module.HEAPU32[offset >>> 2] = value; - } - function setHeapU32(offset, value) { - assert_int_in_range(value, 0, 4294967295); - Module.HEAPU32[offset >>> 2] = value; - } - function setHeapI8(offset, value) { - assert_int_in_range(value, -0x80, 0x7F); - Module.HEAP8[offset] = value; - } - function setHeapI16(offset, value) { - assert_int_in_range(value, -0x8000, 0x7FFF); - Module.HEAP16[offset >>> 1] = value; - } - function setHeapI32_unchecked(offset, value) { - Module.HEAP32[offset >>> 2] = value; - } - function setHeapI32(offset, value) { - assert_int_in_range(value, -2147483648, 2147483647); - Module.HEAP32[offset >>> 2] = value; - } - /** - * Throws for values which are not 52 bit integer. See Number.isSafeInteger() - */ - function setHeapI52(offset, value) { - Assert.check(Number.isSafeInteger(value), () => `Value is not a safe integer: ${value} (${typeof (value)})`); - throw new Error("TODO"); - // const error = cwraps.mono_wasm_f64_to_i52(offset, value); - // autoThrowI52(error); - } - /** - * Throws for values which are not 52 bit integer or are negative. See Number.isSafeInteger(). - */ - function setHeapU52(offset, value) { - Assert.check(Number.isSafeInteger(value), () => `Value is not a safe integer: ${value} (${typeof (value)})`); - Assert.check(value >= 0, "Can't convert negative Number into UInt64"); - throw new Error("TODO"); - //const error = cwraps.mono_wasm_f64_to_u52(offset, value); - //autoThrowI52(error); - } - function setHeapI64Big(offset, value) { - Assert.check(typeof value === "bigint", () => `Value is not an bigint: ${value} (${typeof (value)})`); - Assert.check(value >= min_int64_big && value <= max_int64_big, () => `Overflow: value ${value} is out of ${min_int64_big} ${max_int64_big} range`); - Module.HEAP64[offset >>> 3] = value; - } - function setHeapF32(offset, value) { - Assert.check(typeof value === "number", () => `Value is not a Number: ${value} (${typeof (value)})`); - Module.HEAPF32[offset >>> 2] = value; - } - function setHeapF64(offset, value) { - Assert.check(typeof value === "number", () => `Value is not a Number: ${value} (${typeof (value)})`); - Module.HEAPF64[offset >>> 3] = value; - } - function getHeapB32(offset) { - const value = (Module.HEAPU32[offset >>> 2]); - if (value > 1 && !getHeapB32.warnDirtyBool) { - getHeapB32.warnDirtyBool = true; - Logger.warn(`getB32: value at ${offset} is not a boolean, but a number: ${value}`); - } - return !!value; - } - function getHeapB8(offset) { - return !!(Module.HEAPU8[offset]); - } - function getHeapU8(offset) { - return Module.HEAPU8[offset]; - } - function getHeapU16(offset) { - return Module.HEAPU16[offset >>> 1]; - } - // does not check for growable heap - function getHeapU16_local(localView, offset) { - return localView[offset >>> 1]; - } - function getHeapU32(offset) { - return Module.HEAPU32[offset >>> 2]; - } - // does not check for growable heap - function getHeapU32_local(localView, offset) { - return localView[offset >>> 2]; - } - function getHeapI8(offset) { - return Module.HEAP8[offset]; - } - function getHeapI16(offset) { - return Module.HEAP16[offset >>> 1]; - } - // does not check for growable heap - function getHeapI16_local(localView, offset) { - return localView[offset >>> 1]; - } - function getHeapI32(offset) { - return Module.HEAP32[offset >>> 2]; - } - // does not check for growable heap - function getHeapI32_local(localView, offset) { - return localView[offset >>> 2]; - } - /** - * Throws for Number.MIN_SAFE_INTEGER > value > Number.MAX_SAFE_INTEGER - */ - // eslint-disable-next-line @typescript-eslint/no-unused-vars - function getHeapI52(offset) { - throw new Error("TODO"); - //const result = cwraps.mono_wasm_i52_to_f64(offset, runtimeHelpers._i52_error_scratch_buffer); - //const error = getI32(runtimeHelpers._i52_error_scratch_buffer); - //autoThrowI52(error); - //return result; - } - /** - * Throws for 0 > value > Number.MAX_SAFE_INTEGER - */ - // eslint-disable-next-line @typescript-eslint/no-unused-vars - function getHeapU52(offset) { - throw new Error("TODO"); - //const result = cwraps.mono_wasm_u52_to_f64(offset, runtimeHelpers._i52_error_scratch_buffer); - //const error = getI32(runtimeHelpers._i52_error_scratch_buffer); - //autoThrowI52(error); - //return result; - } - function getHeapI64Big(offset) { - return Module.HEAP64[offset >>> 3]; - } - function getHeapF32(offset) { - return Module.HEAPF32[offset >>> 2]; - } - function getHeapF64(offset) { - return Module.HEAPF64[offset >>> 3]; - } - // returns memory view which is valid within current synchronous call stack - function localHeapViewI8() { - return Module.HEAP8; - } - // returns memory view which is valid within current synchronous call stack - function localHeapViewI16() { - return Module.HEAP16; - } - // returns memory view which is valid within current synchronous call stack - function localHeapViewI32() { - return Module.HEAP32; - } - // returns memory view which is valid within current synchronous call stack - function localHeapViewI64Big() { - return Module.HEAP64; - } - // returns memory view which is valid within current synchronous call stack - function localHeapViewU8() { - return Module.HEAPU8; - } - // returns memory view which is valid within current synchronous call stack - function localHeapViewU16() { - return Module.HEAPU16; - } - // returns memory view which is valid within current synchronous call stack - function localHeapViewU32() { - return Module.HEAPU32; - } - // returns memory view which is valid within current synchronous call stack - function localHeapViewF32() { - return Module.HEAPF32; - } - // returns memory view which is valid within current synchronous call stack - function localHeapViewF64() { - return Module.HEAPF64; - } - function copyBytes(srcPtr, dstPtr, bytes) { - const heap = localHeapViewU8(); - heap.copyWithin(dstPtr, srcPtr, srcPtr + bytes); - } - function isSharedArrayBuffer(buffer) { - // BEWARE: In some cases, `instanceof SharedArrayBuffer` returns false even though buffer is an SAB. - // Patch adapted from https://github.com/emscripten-core/emscripten/pull/16994 - // See also https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Symbol/toStringTag - return sharedArrayBufferDefined && buffer[Symbol.toStringTag] === "SharedArrayBuffer"; - } - - // Licensed to the .NET Foundation under one or more agreements. - // The .NET Foundation licenses this file to you under the MIT license. - function initialize(internals) { - const runtimeApiLocal = { - runMain, - runMainAndExit, - setEnvironmentVariable, - exit, - setHeapB32, setHeapB8, setHeapU8, setHeapU16, setHeapU32, setHeapI8, setHeapI16, setHeapI32, setHeapI52, setHeapU52, setHeapI64Big, setHeapF32, setHeapF64, - getHeapB32, getHeapB8, getHeapU8, getHeapU16, getHeapU32, getHeapI8, getHeapI16, getHeapI32, getHeapI52, getHeapU52, getHeapI64Big, getHeapF32, getHeapF64, - localHeapViewI8, localHeapViewI16, localHeapViewI32, localHeapViewI64Big, localHeapViewU8, localHeapViewU16, localHeapViewU32, localHeapViewF32, localHeapViewF64, - }; - const hostNativeExportsLocal = { - registerDllBytes, - isSharedArrayBuffer - }; - setInternals(internals); - Object.assign(internals.runtimeApi, runtimeApiLocal); - internals.hostNativeExportsTable = [...tabulateHE(hostNativeExportsLocal)]; - internals.updates.push(updateMyInternals); - updateAllInternals(); - } - - exports.browserHostExternalAssemblyProbe = browserHostExternalAssemblyProbe; - exports.browserHostRejectMain = browserHostRejectMain; - exports.browserHostResolveMain = browserHostResolveMain; - exports.initialize = initialize; - - return exports; - -}); -//! Licensed to the .NET Foundation under one or more agreements. -//! The .NET Foundation licenses this file to you under the MIT license. - -/** - * This is root of **Emscripten library** that would become part of `dotnet.native.js` - * It implements the corehost and a part of public JS API related to memory and runtime hosting. - */ - -(function (exports) { - function libFactory() { - const lib = { - $BROWSER_HOST: { - selfInitialize: () => { - if (typeof dotnetInternals !== "undefined") { - BROWSER_HOST.dotnetInternals = dotnetInternals; - - const exports = libBrowserHostFn(BROWSER_HOST); - exports.initialize(dotnetInternals); - BROWSER_HOST.assignExports(exports, BROWSER_HOST); - - const HOST_PROPERTY_TRUSTED_PLATFORM_ASSEMBLIES = "TRUSTED_PLATFORM_ASSEMBLIES"; - const HOST_PROPERTY_ENTRY_ASSEMBLY_NAME = "ENTRY_ASSEMBLY_NAME"; - const HOST_PROPERTY_NATIVE_DLL_SEARCH_DIRECTORIES = "NATIVE_DLL_SEARCH_DIRECTORIES"; - const HOST_PROPERTY_APP_PATHS = "APP_PATHS"; - - const config = dotnetInternals.config; - const assemblyPaths = config.resources.assembly.map(a => a.virtualPath); - const coreAssemblyPaths = config.resources.coreAssembly.map(a => a.virtualPath); - ENV[HOST_PROPERTY_TRUSTED_PLATFORM_ASSEMBLIES] = config.environmentVariables[HOST_PROPERTY_TRUSTED_PLATFORM_ASSEMBLIES] = [...coreAssemblyPaths, ...assemblyPaths].join(":"); - ENV[HOST_PROPERTY_NATIVE_DLL_SEARCH_DIRECTORIES] = config.environmentVariables[HOST_PROPERTY_NATIVE_DLL_SEARCH_DIRECTORIES] = config.virtualWorkingDirectory; - ENV[HOST_PROPERTY_APP_PATHS] = config.environmentVariables[HOST_PROPERTY_APP_PATHS] = config.virtualWorkingDirectory; - ENV[HOST_PROPERTY_ENTRY_ASSEMBLY_NAME] = config.environmentVariables[HOST_PROPERTY_ENTRY_ASSEMBLY_NAME] = config.mainAssemblyName; - } - }, - }, - "$libBrowserHostFn": libBrowserHost, - "$BROWSER_HOST__postset": "BROWSER_HOST.selfInitialize();", - }; - - // this executes the function at compile time in order to capture export names - const exports = libBrowserHost({}); - let commonDeps = ["$libBrowserHostFn", "$DOTNET", "$DOTNET_INTEROP", "$ENV"]; - let assignExportsBuilder = ""; - for (const exportName of Reflect.ownKeys(exports)) { - const name = String(exportName); - if (name === "cross") continue; - if (name === "initialize") continue; - lib[name] = () => "dummy"; - assignExportsBuilder += `_${String(name)} = exports.${String(name)};\n`; - } - lib.$BROWSER_HOST.assignExports = new Function("exports", assignExportsBuilder); - lib["$BROWSER_HOST__deps"] = commonDeps; - - autoAddDeps(lib, "$BROWSER_HOST"); - addToLibrary(lib); - } - libFactory(); - return exports; -})({}); diff --git a/src/native/corehost/browserhost/loader/bootstrap.ts b/src/native/corehost/browserhost/loader/bootstrap.ts new file mode 100644 index 00000000000000..5185b7366908ab --- /dev/null +++ b/src/native/corehost/browserhost/loader/bootstrap.ts @@ -0,0 +1,137 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +import type { LoadBootResourceCallback, JsModuleExports, JsAsset, AssemblyAsset, PdbAsset, WasmAsset, IcuAsset, EmscriptenModuleInternal } from "./types"; + +import { Assert, netJSEngine, getInternals, netBrowserHostExports, netUpdateAllInternals } from "./cross-module"; +import { getLoaderConfig } from "./config"; +import { BrowserHost_InitializeCoreCLR } from "./run"; +import { createPromiseCompletionSource } from "./promise-completion-source"; + +const scriptUrlQuery = /*! webpackIgnore: true */import.meta.url; +const queryIndex = scriptUrlQuery.indexOf("?"); +const modulesUniqueQuery = queryIndex > 0 ? scriptUrlQuery.substring(queryIndex) : ""; +const scriptUrl = normalizeFileUrl(scriptUrlQuery); +const scriptDirectory = normalizeDirectoryUrl(scriptUrl); + +const nativeModulePromiseController = createPromiseCompletionSource(() => { + netUpdateAllInternals(); +}); + +// WASM-TODO: retry logic +// WASM-TODO: throttling logic +// WASM-TODO: load icu data +// WASM-TODO: invokeLibraryInitializers +// WASM-TODO: webCIL +// WASM-TODO: downloadOnly - blazor render mode auto pre-download. Really no start. + +export async function createRuntime(downloadOnly: boolean, loadBootResource?: LoadBootResourceCallback): Promise { + const config = getLoaderConfig(); + if (!config.resources || !config.resources.coreAssembly || !config.resources.coreAssembly.length) throw new Error("Invalid config, resources is not set"); + + const coreAssembliesPromise = Promise.all(config.resources.coreAssembly.map(fetchDll)); + const assembliesPromise = Promise.all(config.resources.assembly.map(fetchDll)); + const runtimeModulePromise = loadJSModule(config.resources.jsModuleRuntime[0], loadBootResource); + const nativeModulePromise = loadJSModule(config.resources.jsModuleNative[0], loadBootResource); + // WASM-TODO fetchWasm(config.resources.wasmNative[0]);// start loading early, no await + + const nativeModule = await nativeModulePromise; + const modulePromise = nativeModule.netInitializeModule(getInternals()); + nativeModulePromiseController.propagateFrom(modulePromise); + + const runtimeModule = await runtimeModulePromise; + const runtimeModuleReady = runtimeModule.netInitializeModule(getInternals()); + + await nativeModulePromiseController.promise; + await coreAssembliesPromise; + + if (!downloadOnly) { + BrowserHost_InitializeCoreCLR(); + } + + await assembliesPromise; + await runtimeModuleReady; +} + +async function loadJSModule(asset: JsAsset, loadBootResource?: LoadBootResourceCallback): Promise { + if (loadBootResource) throw new Error("TODO: loadBootResource is not implemented yet"); + if (asset.name && !asset.resolvedUrl) { + asset.resolvedUrl = locateFile(asset.name); + } + if (!asset.resolvedUrl) throw new Error("Invalid config, resources is not set"); + return await import(/* webpackIgnore: true */ asset.resolvedUrl); +} + +/* WASM-TODO function fetchWasm(asset: WasmAsset): Promise { + if (asset.name && !asset.resolvedUrl) { + asset.resolvedUrl = locateFile(asset.name); + } + return fetchBytes(asset); +}*/ + +async function fetchDll(asset: AssemblyAsset): Promise { + if (asset.name && !asset.resolvedUrl) { + asset.resolvedUrl = locateFile(asset.name); + } + const bytes = await fetchBytes(asset); + await nativeModulePromiseController.promise; + + netBrowserHostExports.registerDllBytes(bytes, asset); +} + +async function fetchBytes(asset: WasmAsset|AssemblyAsset|PdbAsset|IcuAsset): Promise { + Assert.check(asset && asset.resolvedUrl, "Bad asset.resolvedUrl"); + if (netJSEngine.IS_NODE) { + const { promises: fs } = await import("fs"); + const { fileURLToPath } = await import(/*! webpackIgnore: true */"url"); + const isFileUrl = asset.resolvedUrl!.startsWith("file://"); + if (isFileUrl) { + asset.resolvedUrl = fileURLToPath(asset.resolvedUrl!); + } + const buffer = await fs.readFile(asset.resolvedUrl!); + return new Uint8Array(buffer); + } else { + const response = await fetch(asset.resolvedUrl!); + if (!response.ok) { + throw new Error(`Failed to load ${asset.resolvedUrl} with ${response.status} ${response.statusText}`); + } + const buffer = await response.arrayBuffer(); + return new Uint8Array(buffer); + } +} + +function locateFile(path: string) { + if ("URL" in globalThis) { + return new URL(path, scriptDirectory).toString(); + } + + if (isPathAbsolute(path)) return path; + return scriptDirectory + path + modulesUniqueQuery; +} + +function normalizeFileUrl(filename: string) { + // unix vs windows + // remove query string + return filename.replace(/\\/g, "/").replace(/[?#].*/, ""); +} + +function normalizeDirectoryUrl(dir: string) { + return dir.slice(0, dir.lastIndexOf("/")) + "/"; +} + +const protocolRx = /^[a-zA-Z][a-zA-Z\d+\-.]*?:\/\//; +const windowsAbsoluteRx = /[a-zA-Z]:[\\/]/; +function isPathAbsolute(path: string): boolean { + if (netJSEngine.IS_NODE || netJSEngine.IS_SHELL) { + // unix /x.json + // windows \x.json + // windows C:\x.json + // windows C:/x.json + return path.startsWith("/") || path.startsWith("\\") || path.indexOf("///") !== -1 || windowsAbsoluteRx.test(path); + } + + // anything with protocol is always absolute + // windows file:///C:/x.json + // windows http://C:/x.json + return protocolRx.test(path); +} diff --git a/src/native/corehost/browserhost/loader/config.ts b/src/native/corehost/browserhost/loader/config.ts new file mode 100644 index 00000000000000..2e7a5a8397ddab --- /dev/null +++ b/src/native/corehost/browserhost/loader/config.ts @@ -0,0 +1,140 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +import type { Assets, LoadBootResourceCallback, LoaderConfig, LoaderConfigInternal } from "./types"; + +export const netLoaderConfig: LoaderConfigInternal = {}; +let isConfigDownloaded = false; + +export async function downloadConfig(url: string|undefined, loadBootResource?: LoadBootResourceCallback): Promise { + if (loadBootResource) throw new Error("TODO: loadBootResource is not implemented yet"); + if (isConfigDownloaded) return; // only download config once + if (!url) { + url = "./dotnet.boot.js"; + } + + // url ends with .json + if (url.endsWith(".json")) { + const response = await fetch(url); + if (!response.ok) { + throw new Error(`Failed to download config from ${url}: ${response.status} ${response.statusText}`); + } + const newConfig = await response.json() as Partial; + mergeLoaderConfig(newConfig); + } else if (url.endsWith(".js") || url.endsWith(".mjs")) { + const module = await import(/* webpackIgnore: true */ url); + mergeLoaderConfig(module.config); + } + isConfigDownloaded = true; +} + +export function getLoaderConfig(): LoaderConfig { + return netLoaderConfig; +} + +export function mergeLoaderConfig(source: Partial): void { + normalizeConfig(netLoaderConfig); + normalizeConfig(source); + mergeConfigs(netLoaderConfig, source); +} + +function mergeConfigs(target: LoaderConfigInternal, source: Partial): LoaderConfigInternal { + // no need to merge the same object + if (target === source || source === undefined || source === null) return target; + + mergeResources(target.resources!, source.resources!); + source.appendElementOnExit = source.appendElementOnExit !== undefined ? source.appendElementOnExit : target.appendElementOnExit; + source.applicationArguments = source.applicationArguments !== undefined ? [...target.applicationArguments! || [], ...source.applicationArguments] : target.applicationArguments; + source.applicationCulture = source.applicationCulture !== undefined ? source.applicationCulture : target.applicationCulture; + source.applicationEnvironment = source.applicationEnvironment !== undefined ? source.applicationEnvironment : target.applicationEnvironment; + source.appsettings = source.appsettings !== undefined ? [...target.appsettings! || [], ...source.appsettings] : target.appsettings; + source.debugLevel = source.debugLevel !== undefined ? source.debugLevel : target.debugLevel; + source.diagnosticTracing = source.diagnosticTracing !== undefined ? source.diagnosticTracing : target.diagnosticTracing; + source.disableIntegrityCheck = source.disableIntegrityCheck !== undefined ? source.disableIntegrityCheck : target.disableIntegrityCheck; + source.disableNoCacheFetch = source.disableNoCacheFetch !== undefined ? source.disableNoCacheFetch : target.disableNoCacheFetch; + source.enableDownloadRetry = source.enableDownloadRetry !== undefined ? source.enableDownloadRetry : target.enableDownloadRetry; + source.environmentVariables = { ...target.environmentVariables, ...source.environmentVariables }; + source.exitOnUnhandledError = source.exitOnUnhandledError !== undefined ? source.exitOnUnhandledError : target.exitOnUnhandledError; + source.extensions = { ...target.extensions, ...source.extensions }; + source.globalizationMode = source.globalizationMode !== undefined ? source.globalizationMode : target.globalizationMode; + source.ignorePdbLoadErrors = source.ignorePdbLoadErrors !== undefined ? source.ignorePdbLoadErrors : target.ignorePdbLoadErrors; + source.interpreterPgo = source.interpreterPgo !== undefined ? source.interpreterPgo : target.interpreterPgo; + source.interpreterPgoSaveDelay = source.interpreterPgoSaveDelay !== undefined ? source.interpreterPgoSaveDelay : target.interpreterPgoSaveDelay; + source.loadAllSatelliteResources = source.loadAllSatelliteResources !== undefined ? source.loadAllSatelliteResources : target.loadAllSatelliteResources; + source.logExitCode = source.logExitCode !== undefined ? source.logExitCode : target.logExitCode; + source.mainAssemblyName = source.mainAssemblyName !== undefined ? source.mainAssemblyName : target.mainAssemblyName; + source.maxParallelDownloads = source.maxParallelDownloads !== undefined ? source.maxParallelDownloads : target.maxParallelDownloads; + source.pthreadPoolInitialSize = source.pthreadPoolInitialSize !== undefined ? source.pthreadPoolInitialSize : target.pthreadPoolInitialSize; + source.pthreadPoolUnusedSize = source.pthreadPoolUnusedSize !== undefined ? source.pthreadPoolUnusedSize : target.pthreadPoolUnusedSize; + source.remoteSources = source.remoteSources !== undefined ? [...target.remoteSources! || [], ...source.remoteSources] : target.remoteSources; + source.runtimeConfig = source.runtimeConfig !== undefined ? { ...target.runtimeConfig, ...source.runtimeConfig } : target.runtimeConfig; + source.runtimeOptions = [...target.runtimeOptions!, ...source.runtimeOptions!]; + source.virtualWorkingDirectory = source.virtualWorkingDirectory !== undefined ? source.virtualWorkingDirectory : target.virtualWorkingDirectory; + Object.assign(target, source); + if (target.resources!.coreAssembly!.length) { + isConfigDownloaded = true; + } + return target; +} + +function mergeResources(target: Assets, source: Assets): Assets { + // no need to merge the same object + if (target === source || source === undefined || source === null) return target; + + source.assembly = [...target.assembly!, ...source.assembly!]; + source.coreAssembly = [...target.coreAssembly!, ...source.coreAssembly!]; + source.corePdb = [...target.corePdb!, ...source.corePdb!]; + source.extensions = { ...target.extensions!, ...source.extensions! }; + source.icu = [...target.icu!, ...source.icu!]; + source.jsModuleDiagnostics = [...target.jsModuleDiagnostics!, ...source.jsModuleDiagnostics!]; + source.jsModuleNative = [...target.jsModuleNative!, ...source.jsModuleNative!]; + source.jsModuleRuntime = [...target.jsModuleRuntime!, ...source.jsModuleRuntime!]; + source.jsModuleWorker = [...target.jsModuleWorker!, ...source.jsModuleWorker!]; + source.lazyAssembly = [...target.lazyAssembly!, ...source.lazyAssembly!]; + source.modulesAfterConfigLoaded = [...target.modulesAfterConfigLoaded!, ...source.modulesAfterConfigLoaded!]; + source.modulesAfterRuntimeReady = [...target.modulesAfterRuntimeReady!, ...source.modulesAfterRuntimeReady!]; + source.pdb = [...target.pdb!, ...source.pdb!]; + source.vfs = [...target.vfs!, ...source.vfs!]; + source.wasmNative = [...target.wasmNative!, ...source.wasmNative!]; + source.wasmSymbols = [...target.wasmSymbols!, ...source.wasmSymbols!]; + for (const key in source.satelliteResources) { + source.satelliteResources![key] = [...target.satelliteResources![key] || [], ...source.satelliteResources![key] || []]; + } + return Object.assign(target, source); +} + + +function normalizeConfig(target: LoaderConfigInternal) { + if (!target.resources) target.resources = {} as any; + normalizeResources(target.resources!); + if (!target.environmentVariables) target.environmentVariables = {}; + if (!target.runtimeOptions) target.runtimeOptions = []; + if (target.appendElementOnExit === undefined) target.appendElementOnExit = false; + if (target.logExitCode === undefined) target.logExitCode = false; + if (target.exitOnUnhandledError === undefined) target.exitOnUnhandledError = false; + if (target.loadAllSatelliteResources === undefined) target.loadAllSatelliteResources = false; + if (target.debugLevel === undefined) target.debugLevel = 0; + if (target.diagnosticTracing === undefined) target.diagnosticTracing = false; + if (target.virtualWorkingDirectory === undefined) target.virtualWorkingDirectory = "/"; + if (target.mainAssemblyName === undefined) target.mainAssemblyName = "HelloWorld.dll"; +} + +function normalizeResources(target: Assets) { + if (!target.coreAssembly) target.coreAssembly = []; + if (!target.assembly) target.assembly = []; + if (!target.lazyAssembly) target.lazyAssembly = []; + if (!target.corePdb) target.corePdb = []; + if (!target.pdb) target.pdb = []; + if (!target.jsModuleWorker) target.jsModuleWorker = []; + if (!target.jsModuleNative) target.jsModuleNative = []; + if (!target.jsModuleDiagnostics) target.jsModuleDiagnostics = []; + if (!target.jsModuleRuntime) target.jsModuleRuntime = []; + if (!target.wasmSymbols) target.wasmSymbols = []; + if (!target.wasmNative) target.wasmNative = []; + if (!target.icu) target.icu = []; + if (!target.modulesAfterConfigLoaded) target.modulesAfterConfigLoaded = []; + if (!target.modulesAfterRuntimeReady) target.modulesAfterRuntimeReady = []; + if (!target.satelliteResources) target.satelliteResources = {}; + if (!target.extensions) target.extensions = {}; + if (!target.vfs) target.vfs = []; +} diff --git a/src/native/corehost/browserhost/loader/cross-module.ts b/src/native/corehost/browserhost/loader/cross-module.ts new file mode 100644 index 00000000000000..7e45f1da5f993b --- /dev/null +++ b/src/native/corehost/browserhost/loader/cross-module.ts @@ -0,0 +1,4 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +export * from "../cross-module"; diff --git a/src/native/corehost/browserhost/loader/dotnet.d.ts b/src/native/corehost/browserhost/loader/dotnet.d.ts index 3e878a4724ee72..c333eafe29af10 100644 --- a/src/native/corehost/browserhost/loader/dotnet.d.ts +++ b/src/native/corehost/browserhost/loader/dotnet.d.ts @@ -779,4 +779,5 @@ declare global { } declare const createDotnetRuntime: CreateDotnetRuntimeType; -export { type AssetBehaviors, type AssetEntry, type CreateDotnetRuntimeType, type DotnetHostBuilder, type DotnetModuleConfig, type EmscriptenModule, GlobalizationMode, type IMemoryView, type LoaderConfig, type ModuleAPI, type RuntimeAPI, createDotnetRuntime as default, dotnet, exit }; +export { GlobalizationMode, createDotnetRuntime as default, dotnet, exit }; +export type { AssetBehaviors, AssetEntry, CreateDotnetRuntimeType, DotnetHostBuilder, DotnetModuleConfig, EmscriptenModule, IMemoryView, LoaderConfig, ModuleAPI, RuntimeAPI }; diff --git a/src/native/corehost/browserhost/loader/dotnet.js b/src/native/corehost/browserhost/loader/dotnet.js deleted file mode 100644 index 9b96e58e74ef0c..00000000000000 --- a/src/native/corehost/browserhost/loader/dotnet.js +++ /dev/null @@ -1,948 +0,0 @@ -//! Licensed to the .NET Foundation under one or more agreements. -//! The .NET Foundation licenses this file to you under the MIT license. -//! This is generated file, see src/native/libs/Browser/rollup.config.defines.js - - -/*! bundlerFriendlyImports */ - -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -let Module; -let runtimeApi; -let Logger = {}; -let Assert = {}; -let JSEngine = {}; -let loaderExports = {}; -let runtimeExports = {}; -let hostExports = {}; -let interopExports = {}; -let nativeBrowserExports = {}; -let dotnetInternals; -function getInternals() { - return dotnetInternals; -} -function setInternals(internal) { - dotnetInternals = internal; - runtimeApi = dotnetInternals.runtimeApi; - Module = dotnetInternals.runtimeApi.Module; -} -function updateAllInternals() { - if (dotnetInternals.updates === undefined) { - dotnetInternals.updates = []; - } - for (const updateImpl of dotnetInternals.updates) { - updateImpl(); - } -} -function updateMyInternals() { - if (Object.keys(loaderExports).length === 0 && dotnetInternals.loaderExportsTable) { - loaderExports = {}; - Logger = {}; - Assert = {}; - JSEngine = {}; - expandLE(dotnetInternals.loaderExportsTable, Logger, Assert, JSEngine, loaderExports); - } - if (Object.keys(runtimeExports).length === 0 && dotnetInternals.runtimeExportsTable) { - runtimeExports = {}; - expandRE(dotnetInternals.runtimeExportsTable, runtimeExports); - } - if (Object.keys(hostExports).length === 0 && dotnetInternals.hostNativeExportsTable) { - hostExports = {}; - expandHE(dotnetInternals.hostNativeExportsTable, hostExports); - } - if (Object.keys(interopExports).length === 0 && dotnetInternals.interopJavaScriptNativeExportsTable) { - interopExports = {}; - expandJSNE(dotnetInternals.interopJavaScriptNativeExportsTable, interopExports); - } - if (Object.keys(nativeBrowserExports).length === 0 && dotnetInternals.nativeBrowserExportsTable) { - nativeBrowserExports = {}; - expandNBE(dotnetInternals.nativeBrowserExportsTable, nativeBrowserExports); - } -} -/** - * Functions below allow our JS modules to exchange internal interfaces by passing tables of functions in known order instead of using string symbols. - * IMPORTANT: If you need to add more functions, make sure that you add them at the end of the table, so that the order of existing functions does not change. - */ -function tabulateLE(logger, assert, loaderExports) { - return [ - logger.info, - logger.warn, - logger.error, - assert.check, - loaderExports.ENVIRONMENT_IS_NODE, - loaderExports.ENVIRONMENT_IS_SHELL, - loaderExports.ENVIRONMENT_IS_WEB, - loaderExports.ENVIRONMENT_IS_WORKER, - loaderExports.ENVIRONMENT_IS_SIDECAR, - loaderExports.browserHostResolveMain, - loaderExports.browserHostRejectMain, - loaderExports.getRunMainPromise, - ]; -} -function expandLE(table, logger, assert, jsEngine, loaderExports) { - const loggerLocal = { - info: table[0], - warn: table[1], - error: table[2], - }; - const assertLocal = { - check: table[3], - }; - const loaderExportsLocal = { - ENVIRONMENT_IS_NODE: table[4], - ENVIRONMENT_IS_SHELL: table[5], - ENVIRONMENT_IS_WEB: table[6], - ENVIRONMENT_IS_WORKER: table[7], - ENVIRONMENT_IS_SIDECAR: table[8], - browserHostResolveMain: table[9], - browserHostRejectMain: table[10], - getRunMainPromise: table[11], - }; - const jsEngineLocal = { - IS_NODE: loaderExportsLocal.ENVIRONMENT_IS_NODE(), - IS_SHELL: loaderExportsLocal.ENVIRONMENT_IS_SHELL(), - IS_WEB: loaderExportsLocal.ENVIRONMENT_IS_WEB(), - IS_WORKER: loaderExportsLocal.ENVIRONMENT_IS_WORKER(), - IS_SIDECAR: loaderExportsLocal.ENVIRONMENT_IS_SIDECAR(), - }; - Object.assign(loaderExports, loaderExportsLocal); - Object.assign(logger, loggerLocal); - Object.assign(assert, assertLocal); - Object.assign(jsEngine, jsEngineLocal); -} -// eslint-disable-next-line @typescript-eslint/no-unused-vars -function tabulateRE(map) { - return []; -} -function expandRE(table, runtime) { - Object.assign(runtime, {}); -} -function tabulateHE(map) { - return [ - map.registerDllBytes, - map.isSharedArrayBuffer, - ]; -} -function expandHE(table, native) { - const nativeLocal = { - registerDllBytes: table[0], - isSharedArrayBuffer: table[1], - }; - Object.assign(native, nativeLocal); -} -// eslint-disable-next-line @typescript-eslint/no-unused-vars -function tabulateJSNE(map) { - return []; -} -function expandJSNE(table, interop) { - const interopLocal = {}; - Object.assign(interop, interopLocal); -} -// eslint-disable-next-line @typescript-eslint/no-unused-vars -function tabulateNBE(map) { - return []; -} -function expandNBE(table, interop) { - const interopLocal = {}; - Object.assign(interop, interopLocal); -} - -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -const config = {}; -let isConfigDownloaded = false; -async function downloadConfig(url, loadBootResource) { - if (loadBootResource) - throw new Error("TODO: loadBootResource is not implemented yet"); - if (isConfigDownloaded) - return; // only download config once - if (!url) { - url = "./dotnet.boot.js"; - } - // url ends with .json - if (url.endsWith(".json")) { - const response = await fetch(url); - if (!response.ok) { - throw new Error(`Failed to download config from ${url}: ${response.status} ${response.statusText}`); - } - const newConfig = await response.json(); - mergeConfig(newConfig); - } - else if (url.endsWith(".js") || url.endsWith(".mjs")) { - const module = await import(/* webpackIgnore: true */ url); - mergeConfig(module.config); - } - isConfigDownloaded = true; -} -function getConfig() { - return config; -} -function mergeConfig(source) { - normalizeConfig(config); - normalizeConfig(source); - mergeConfigs(config, source); -} -function mergeConfigs(target, source) { - // no need to merge the same object - if (target === source || source === undefined || source === null) - return target; - mergeResources(target.resources, source.resources); - source.appendElementOnExit = source.appendElementOnExit !== undefined ? source.appendElementOnExit : target.appendElementOnExit; - source.logExitCode = source.logExitCode !== undefined ? source.logExitCode : target.logExitCode; - source.exitOnUnhandledError = source.exitOnUnhandledError !== undefined ? source.exitOnUnhandledError : target.exitOnUnhandledError; - source.loadAllSatelliteResources = source.loadAllSatelliteResources !== undefined ? source.loadAllSatelliteResources : target.loadAllSatelliteResources; - source.mainAssemblyName = source.mainAssemblyName !== undefined ? source.mainAssemblyName : target.mainAssemblyName; - source.virtualWorkingDirectory = source.virtualWorkingDirectory !== undefined ? source.virtualWorkingDirectory : target.virtualWorkingDirectory; - source.debugLevel = source.debugLevel !== undefined ? source.debugLevel : target.debugLevel; - source.diagnosticTracing = source.diagnosticTracing !== undefined ? source.diagnosticTracing : target.diagnosticTracing; - source.environmentVariables = { ...target.environmentVariables, ...source.environmentVariables }; - source.runtimeOptions = [...target.runtimeOptions, ...source.runtimeOptions]; - Object.assign(target, source); - if (target.resources.coreAssembly.length) { - isConfigDownloaded = true; - } - return target; -} -function mergeResources(target, source) { - // no need to merge the same object - if (target === source || source === undefined || source === null) - return target; - source.coreAssembly = [...target.coreAssembly, ...source.coreAssembly]; - source.assembly = [...target.assembly, ...source.assembly]; - source.lazyAssembly = [...target.lazyAssembly, ...source.lazyAssembly]; - source.corePdb = [...target.corePdb, ...source.corePdb]; - source.pdb = [...target.pdb, ...source.pdb]; - source.jsModuleWorker = [...target.jsModuleWorker, ...source.jsModuleWorker]; - source.jsModuleNative = [...target.jsModuleNative, ...source.jsModuleNative]; - source.jsModuleDiagnostics = [...target.jsModuleDiagnostics, ...source.jsModuleDiagnostics]; - source.jsModuleRuntime = [...target.jsModuleRuntime, ...source.jsModuleRuntime]; - source.wasmSymbols = [...target.wasmSymbols, ...source.wasmSymbols]; - source.wasmNative = [...target.wasmNative, ...source.wasmNative]; - source.icu = [...target.icu, ...source.icu]; - source.vfs = [...target.vfs, ...source.vfs]; - source.modulesAfterConfigLoaded = [...target.modulesAfterConfigLoaded, ...source.modulesAfterConfigLoaded]; - source.modulesAfterRuntimeReady = [...target.modulesAfterRuntimeReady, ...source.modulesAfterRuntimeReady]; - source.extensions = { ...target.extensions, ...source.extensions }; - for (const key in source.satelliteResources) { - source.satelliteResources[key] = [...target.satelliteResources[key] || [], ...source.satelliteResources[key] || []]; - } - return Object.assign(target, source); -} -function normalizeConfig(target) { - if (!target.resources) - target.resources = {}; - normalizeResources(target.resources); - if (!target.environmentVariables) - target.environmentVariables = {}; - if (!target.runtimeOptions) - target.runtimeOptions = []; - if (target.appendElementOnExit === undefined) - target.appendElementOnExit = false; - if (target.logExitCode === undefined) - target.logExitCode = false; - if (target.exitOnUnhandledError === undefined) - target.exitOnUnhandledError = false; - if (target.loadAllSatelliteResources === undefined) - target.loadAllSatelliteResources = false; - if (target.debugLevel === undefined) - target.debugLevel = 0; - if (target.diagnosticTracing === undefined) - target.diagnosticTracing = false; - if (target.virtualWorkingDirectory === undefined) - target.virtualWorkingDirectory = "/"; - if (target.mainAssemblyName === undefined) - target.mainAssemblyName = "HelloWorld.dll"; -} -function normalizeResources(target) { - if (!target.coreAssembly) - target.coreAssembly = []; - if (!target.assembly) - target.assembly = []; - if (!target.lazyAssembly) - target.lazyAssembly = []; - if (!target.corePdb) - target.corePdb = []; - if (!target.pdb) - target.pdb = []; - if (!target.jsModuleWorker) - target.jsModuleWorker = []; - if (!target.jsModuleNative) - target.jsModuleNative = []; - if (!target.jsModuleDiagnostics) - target.jsModuleDiagnostics = []; - if (!target.jsModuleRuntime) - target.jsModuleRuntime = []; - if (!target.wasmSymbols) - target.wasmSymbols = []; - if (!target.wasmNative) - target.wasmNative = []; - if (!target.icu) - target.icu = []; - if (!target.modulesAfterConfigLoaded) - target.modulesAfterConfigLoaded = []; - if (!target.modulesAfterRuntimeReady) - target.modulesAfterRuntimeReady = []; - if (!target.satelliteResources) - target.satelliteResources = {}; - if (!target.extensions) - target.extensions = {}; - if (!target.vfs) - target.vfs = []; -} - -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// eslint-disable-next-line @typescript-eslint/no-unused-vars -function exit(exit_code, reason) { - const reasonStr = reason ? (reason.stack ? reason.stack || reason.message : reason.toString()) : ""; - if (exit_code !== 0) { - Logger.error(`Exit with code ${exit_code} ${reason ? "and reason: " + reasonStr : ""}`); - } - if (JSEngine.IS_NODE) { - globalThis.process.exit(exit_code); - } -} - -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -/// a unique symbol used to mark a promise as controllable -const promise_control_symbol = Symbol.for("wasm promise_control"); -/// Creates a new promise together with a controller that can be used to resolve or reject that promise. -/// Optionally takes callbacks to be called immediately after a promise is resolved or rejected. -function createPromiseController(afterResolve, afterReject) { - let promiseControl = null; - const promise = new Promise((resolve, reject) => { - promiseControl = { - isDone: false, - promise: null, - resolve: (data) => { - if (!promiseControl.isDone) { - promiseControl.isDone = true; - resolve(data); - if (afterResolve) { - afterResolve(); - } - } - }, - reject: (reason) => { - if (!promiseControl.isDone) { - promiseControl.isDone = true; - reject(reason); - if (afterReject) { - afterReject(); - } - } - }, - propagateFrom: (other) => { - other.then(promiseControl.resolve).catch(promiseControl.reject); - } - }; - }); - promiseControl.promise = promise; - const controllablePromise = promise; - controllablePromise[promise_control_symbol] = promiseControl; - return promiseControl; -} -function getPromiseController(promise) { - return promise[promise_control_symbol]; -} -function isControllablePromise(promise) { - return promise[promise_control_symbol] !== undefined; -} - -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -let CoreCLRInitialized = false; -const runMainPromiseController = createPromiseController(); -function browserHostInitializeCoreCLR() { - if (CoreCLRInitialized) { - return; - } - // int browserHostInitializeCoreCLR(void) - const res = Module.ccall("browserHostInitializeCoreCLR", "number"); - if (res != 0) { - const reason = new Error("Failed to initialize CoreCLR"); - runMainPromiseController.reject(reason); - exit(res, reason); - } - CoreCLRInitialized = true; -} -function browserHostResolveMain(exitCode) { - runMainPromiseController.resolve(exitCode); -} -function browserHostRejectMain(reason) { - runMainPromiseController.reject(reason); -} -function getRunMainPromise() { - return runMainPromiseController.promise; -} - -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -const scriptUrlQuery = /*! webpackIgnore: true */ import.meta.url; -const queryIndex = scriptUrlQuery.indexOf("?"); -const modulesUniqueQuery = queryIndex > 0 ? scriptUrlQuery.substring(queryIndex) : ""; -const scriptUrl = normalizeFileUrl(scriptUrlQuery); -const scriptDirectory = normalizeDirectoryUrl(scriptUrl); -const nativeModulePromiseController = createPromiseController(() => { - updateAllInternals(); -}); -// WASM-TODO: retry logic -// WASM-TODO: throttling logic -// WASM-TODO: load icu data -// WASM-TODO: invokeLibraryInitializers -// WASM-TODO: webCIL -async function createRuntime(downloadOnly, loadBootResource) { - const config = getConfig(); - if (!config.resources || !config.resources.coreAssembly || !config.resources.coreAssembly.length) - throw new Error("Invalid config, resources is not set"); - const coreAssembliesPromise = Promise.all(config.resources.coreAssembly.map(fetchDll)); - const assembliesPromise = Promise.all(config.resources.assembly.map(fetchDll)); - const runtimeModulePromise = loadModule(config.resources.jsModuleRuntime[0], loadBootResource); - const nativeModulePromise = loadModule(config.resources.jsModuleNative[0], loadBootResource); - const nativeModule = await nativeModulePromise; - const modulePromise = nativeModule.initialize(getInternals()); - nativeModulePromiseController.propagateFrom(modulePromise); - const runtimeModule = await runtimeModulePromise; - const runtimeModuleReady = runtimeModule.initialize(getInternals()); - await nativeModulePromiseController.promise; - await coreAssembliesPromise; - if (!downloadOnly) { - browserHostInitializeCoreCLR(); - } - await assembliesPromise; - await runtimeModuleReady; -} -async function loadModule(asset, loadBootResource) { - if (loadBootResource) - throw new Error("TODO: loadBootResource is not implemented yet"); - if (asset.name && !asset.resolvedUrl) { - asset.resolvedUrl = locateFile(asset.name); - } - if (!asset.resolvedUrl) - throw new Error("Invalid config, resources is not set"); - return await import(/* webpackIgnore: true */ asset.resolvedUrl); -} -function fetchWasm(asset) { - if (asset.name && !asset.resolvedUrl) { - asset.resolvedUrl = locateFile(asset.name); - } - return fetchBytes(asset); -} -async function fetchDll(asset) { - if (asset.name && !asset.resolvedUrl) { - asset.resolvedUrl = locateFile(asset.name); - } - const bytes = await fetchBytes(asset); - await nativeModulePromiseController.promise; - hostExports.registerDllBytes(bytes, asset); -} -async function fetchBytes(asset) { - Assert.check(asset && asset.resolvedUrl, "Bad asset.resolvedUrl"); - if (JSEngine.IS_NODE) { - const { promises: fs } = await import('fs'); - const { fileURLToPath } = await import(/*! webpackIgnore: true */ 'url'); - const isFileUrl = asset.resolvedUrl.startsWith("file://"); - if (isFileUrl) { - asset.resolvedUrl = fileURLToPath(asset.resolvedUrl); - } - const buffer = await fs.readFile(asset.resolvedUrl); - return new Uint8Array(buffer); - } - else { - const response = await fetch(asset.resolvedUrl); - if (!response.ok) { - throw new Error(`Failed to load ${asset.resolvedUrl} with ${response.status} ${response.statusText}`); - } - const buffer = await response.arrayBuffer(); - return new Uint8Array(buffer); - } -} -function locateFile(path) { - if ("URL" in globalThis) { - return new URL(path, scriptDirectory).toString(); - } - if (isPathAbsolute(path)) - return path; - return scriptDirectory + path + modulesUniqueQuery; -} -function normalizeFileUrl(filename) { - // unix vs windows - // remove query string - return filename.replace(/\\/g, "/").replace(/[?#].*/, ""); -} -function normalizeDirectoryUrl(dir) { - return dir.slice(0, dir.lastIndexOf("/")) + "/"; -} -const protocolRx = /^[a-zA-Z][a-zA-Z\d+\-.]*?:\/\//; -const windowsAbsoluteRx = /[a-zA-Z]:[\\/]/; -function isPathAbsolute(path) { - if (JSEngine.IS_NODE || JSEngine.IS_SHELL) { - // unix /x.json - // windows \x.json - // windows C:\x.json - // windows C:/x.json - return path.startsWith("/") || path.startsWith("\\") || path.indexOf("///") !== -1 || windowsAbsoluteRx.test(path); - } - // anything with protocol is always absolute - // windows file:///C:/x.json - // windows http://C:/x.json - return protocolRx.test(path); -} - -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -let configUrl = undefined; -let applicationArguments = []; -let loadBootResourceCallback = undefined; -/* eslint-disable @typescript-eslint/no-unused-vars */ -class HostBuilder { - withConfig(config) { - mergeConfig(config); - return this; - } - withConfigSrc(configSrc) { - configUrl = configSrc; - return this; - } - withApplicationArguments(...args) { - applicationArguments = args; - return this; - } - withEnvironmentVariable(name, value) { - mergeConfig({ - environmentVariables: { - [name]: value - } - }); - return this; - } - withEnvironmentVariables(variables) { - mergeConfig({ - environmentVariables: variables - }); - return this; - } - withVirtualWorkingDirectory(vfsPath) { - mergeConfig({ - virtualWorkingDirectory: vfsPath - }); - return this; - } - withDiagnosticTracing(enabled) { - mergeConfig({ - diagnosticTracing: enabled - }); - return this; - } - withDebugging(level) { - mergeConfig({ - debugLevel: level - }); - return this; - } - withMainAssembly(mainAssemblyName) { - mergeConfig({ - mainAssemblyName: mainAssemblyName - }); - return this; - } - withApplicationArgumentsFromQuery() { - if (!globalThis.window) { - throw new Error("Missing window to the query parameters from"); - } - if (typeof globalThis.URLSearchParams == "undefined") { - throw new Error("URLSearchParams is supported"); - } - const params = new URLSearchParams(globalThis.window.location.search); - const values = params.getAll("arg"); - return this.withApplicationArguments(...values); - } - withApplicationEnvironment(applicationEnvironment) { - mergeConfig({ - applicationEnvironment: applicationEnvironment - }); - return this; - } - withApplicationCulture(applicationCulture) { - mergeConfig({ - applicationCulture: applicationCulture - }); - return this; - } - withResourceLoader(loadBootResource) { - loadBootResourceCallback = loadBootResource; - return this; - } - // internal - withModuleConfig(moduleConfig) { - Object.assign(Module, moduleConfig); - return this; - } - // internal - withConsoleForwarding() { - // TODO - return this; - } - // internal - withExitOnUnhandledError() { - // TODO - return this; - } - // internal - withAsyncFlushOnExit() { - // TODO - return this; - } - // internal - withExitCodeLogging() { - // TODO - return this; - } - // internal - withElementOnExit() { - // TODO - return this; - } - // internal - withInteropCleanupOnExit() { - // TODO - return this; - } - async download() { - try { - await downloadConfig(configUrl, loadBootResourceCallback); - return createRuntime(true, loadBootResourceCallback); - } - catch (err) { - exit(1, err); - throw err; - } - } - async create() { - try { - await downloadConfig(configUrl, loadBootResourceCallback); - await createRuntime(false, loadBootResourceCallback); - this.runtimeApi = runtimeApi; - return this.runtimeApi; - } - catch (err) { - exit(1, err); - throw err; - } - } - async run() { - try { - if (!this.runtimeApi) { - await this.create(); - } - const config = getConfig(); - return this.runtimeApi.runMainAndExit(config.mainAssemblyName, applicationArguments); - } - catch (err) { - exit(1, err); - throw err; - } - } -} - -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -function initPolyfills() { - if (typeof globalThis.WeakRef !== "function") { - class WeakRefPolyfill { - constructor(value) { - this._value = value; - } - deref() { - return this._value; - } - } - globalThis.WeakRef = WeakRefPolyfill; - } - if (typeof globalThis.fetch !== "function") { - globalThis.fetch = fetchLike; - } -} -async function initPolyfillsAsync() { - if (JSEngine.IS_NODE) { - if (!globalThis.crypto) { - globalThis.crypto = {}; - } - if (!globalThis.crypto.getRandomValues) { - let nodeCrypto = undefined; - try { - // eslint-disable-next-line @typescript-eslint/ban-ts-comment - // @ts-ignore: - nodeCrypto = await import(/*! webpackIgnore: true */ 'node:crypto'); - } - catch (err) { - // Noop, error throwing polyfill provided bellow - } - if (!nodeCrypto) { - globalThis.crypto.getRandomValues = () => { - throw new Error("Using node without crypto support. To enable current operation, either provide polyfill for 'globalThis.crypto.getRandomValues' or enable 'node:crypto' module."); - }; - } - else if (nodeCrypto.webcrypto) { - globalThis.crypto = nodeCrypto.webcrypto; - } - else if (nodeCrypto.randomBytes) { - const getRandomValues = (buffer) => { - if (buffer) { - buffer.set(nodeCrypto.randomBytes(buffer.length)); - } - }; - globalThis.crypto.getRandomValues = getRandomValues; - } - } - if (!globalThis.performance) { - // eslint-disable-next-line @typescript-eslint/ban-ts-comment - // @ts-ignore: - globalThis.performance = (await import(/*! webpackIgnore: true */ 'perf_hooks')).performance; - } - } -} -async function fetchLike(url, init) { - let node_fs = undefined; - let node_url = undefined; - try { - // this need to be detected only after we import node modules in onConfigLoaded - const hasFetch = typeof (globalThis.fetch) === "function"; - if (JSEngine.IS_NODE) { - const isFileUrl = url.startsWith("file://"); - if (!isFileUrl && hasFetch) { - return globalThis.fetch(url, init || { credentials: "same-origin" }); - } - if (!node_fs) { - // eslint-disable-next-line @typescript-eslint/ban-ts-comment - // @ts-ignore: - node_url = await import(/*! webpackIgnore: true */ 'url'); - // eslint-disable-next-line @typescript-eslint/ban-ts-comment - // @ts-ignore: - node_fs = await import(/*! webpackIgnore: true */ 'fs'); - } - if (isFileUrl) { - url = node_url.fileURLToPath(url); - } - const arrayBuffer = await node_fs.promises.readFile(url); - return { - ok: true, - headers: { - length: 0, - get: () => null - }, - url, - arrayBuffer: () => arrayBuffer, - json: () => JSON.parse(arrayBuffer), - text: () => { - throw new Error("NotImplementedException"); - } - }; - } - else if (hasFetch) { - return globalThis.fetch(url, init || { credentials: "same-origin" }); - } - else if (typeof (read) === "function") { - // note that it can't open files with unicode names, like Strae.xml - // https://bugs.chromium.org/p/v8/issues/detail?id=12541 - return { - ok: true, - url, - headers: { - length: 0, - get: () => null - }, - arrayBuffer: () => { - return new Uint8Array(read(url, "binary")); - }, - json: () => { - return JSON.parse(read(url, "utf8")); - }, - text: () => read(url, "utf8") - }; - } - } - catch (e) { - return { - ok: false, - url, - status: 500, - headers: { - length: 0, - get: () => null - }, - statusText: "ERR28: " + e, - arrayBuffer: () => { - throw e; - }, - json: () => { - throw e; - }, - text: () => { - throw e; - } - }; - } - throw new Error("No fetch implementation available"); -} - -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -let runtimeList; -class RuntimeList { - constructor() { - this.list = {}; - } - registerRuntime(api) { - if (api.runtimeId === undefined) { - api.runtimeId = Object.keys(this.list).length; - } - this.list[api.runtimeId] = new globalThis.WeakRef(api); - return api.runtimeId; - } - getRuntime(runtimeId) { - const wr = this.list[runtimeId]; - return wr ? wr.deref() : undefined; - } -} -function registerRuntime(api) { - const globalThisAny = globalThis; - // this code makes it possible to find dotnet runtime on a page via global namespace, even when there are multiple runtimes at the same time - if (!globalThisAny.getDotnetRuntime) { - globalThisAny.getDotnetRuntime = (runtimeId) => globalThisAny.getDotnetRuntime.__list.getRuntime(runtimeId); - globalThisAny.getDotnetRuntime.__list = runtimeList = new RuntimeList(); - } - else { - runtimeList = globalThisAny.getDotnetRuntime.__list; - } - return runtimeList.registerRuntime(api); -} - -var ProductVersion = "10.0.0-dev"; - -var BuildConfiguration = "Debug"; - -var GitHash = "3f5c7d9c448b99bdeae770df46ffc3c923f7ccf4"; - -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// eslint-disable-next-line @typescript-eslint/no-unused-vars -async function invokeLibraryInitializers(functionName, args) { - throw new Error("Not implemented"); -} - -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// WASMTODO inline the code -function check(condition, messageFactory) { - if (!condition) { - const message = typeof messageFactory === "string" ? messageFactory : messageFactory(); - throw new Error(`Assert failed: ${message}`); - } -} -/* eslint-disable no-console */ -const prefix = "CLR_WASM: "; -function info(msg, ...data) { - console.info(prefix + msg, ...data); -} -function warn(msg, ...data) { - console.warn(prefix + msg, ...data); -} -function error(msg, ...data) { - if (data && data.length > 0 && data[0] && typeof data[0] === "object") { - // don't log silent errors - if (data[0].silent) { - return; - } - if (data[0].toString) { - console.error(prefix + msg, data[0].toString()); - return; - } - } - console.error(prefix + msg, ...data); -} - -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -function initialize() { - const ENVIRONMENT_IS_NODE = () => typeof process == "object" && typeof process.versions == "object" && typeof process.versions.node == "string"; - const ENVIRONMENT_IS_WEB_WORKER = () => typeof importScripts == "function"; - const ENVIRONMENT_IS_SIDECAR = () => ENVIRONMENT_IS_WEB_WORKER() && typeof dotnetSidecar !== "undefined"; // sidecar is emscripten main running in a web worker - const ENVIRONMENT_IS_WORKER = () => ENVIRONMENT_IS_WEB_WORKER() && !ENVIRONMENT_IS_SIDECAR(); // we redefine what ENVIRONMENT_IS_WORKER, we replace it in emscripten internals, so that sidecar works - const ENVIRONMENT_IS_WEB = () => typeof window == "object" || (ENVIRONMENT_IS_WEB_WORKER() && !ENVIRONMENT_IS_NODE()); - const ENVIRONMENT_IS_SHELL = () => !ENVIRONMENT_IS_WEB() && !ENVIRONMENT_IS_NODE(); - const runtimeApi = { - INTERNAL: {}, - Module: {}, - runtimeId: -1, - runtimeBuildInfo: { - productVersion: ProductVersion, - gitHash: GitHash, - buildConfiguration: BuildConfiguration, - wasmEnableThreads: false, - wasmEnableSIMD: true, - wasmEnableExceptionHandling: true, - }, - }; - const updates = []; - setInternals({ - config: config, - runtimeApi: runtimeApi, - updates, - }); - const runtimeApiFunctions = { - getConfig, - exit, - invokeLibraryInitializers, - }; - const loaderFunctions = { - ENVIRONMENT_IS_NODE, - ENVIRONMENT_IS_SHELL, - ENVIRONMENT_IS_WEB, - ENVIRONMENT_IS_WORKER, - ENVIRONMENT_IS_SIDECAR, - getRunMainPromise, - browserHostRejectMain, - browserHostResolveMain, - }; - const jsEngine = { - IS_NODE: ENVIRONMENT_IS_NODE(), - IS_SHELL: ENVIRONMENT_IS_SHELL(), - IS_WEB: ENVIRONMENT_IS_WEB(), - IS_WORKER: ENVIRONMENT_IS_WORKER(), - IS_SIDECAR: ENVIRONMENT_IS_SIDECAR(), - }; - const logger = { - info, - warn, - error, - }; - const assert = { - check, - }; - Object.assign(runtimeApi, runtimeApiFunctions); - Object.assign(Logger, logger); - Object.assign(Assert, assert); - Object.assign(JSEngine, jsEngine); - Object.assign(loaderExports, loaderFunctions); - dotnetInternals.loaderExportsTable = [...tabulateLE(Logger, Assert, loaderExports)]; - updates.push(updateMyInternals); - updateAllInternals(); - return runtimeApi; -} - -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -initPolyfills(); -registerRuntime(initialize()); -await initPolyfillsAsync(); -const dotnet = new HostBuilder(); - -export { dotnet, exit }; diff --git a/src/native/corehost/browserhost/loader/dotnet.ts b/src/native/corehost/browserhost/loader/dotnet.ts new file mode 100644 index 00000000000000..5bbba2005bdd1b --- /dev/null +++ b/src/native/corehost/browserhost/loader/dotnet.ts @@ -0,0 +1,24 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +/** + * This is root of **JavaScript module** that would become of `dotnet.js`. + * It implements host for the browser together with `src/native/corehost/browserhost`. + * It exposes the public JS runtime APIs that is implemented in `Dotnet.Runtime.ts`. + * It's good to keep this file small. + */ + +import type { DotnetHostBuilder } from "./types"; + +import { HostBuilder } from "./host-builder"; +import { initPolyfills, initPolyfillsAsync } from "./polyfills"; +import { registerRuntime } from "./runtime-list"; +import { exit } from "./exit"; +import { netInitializeModule } from "."; + +initPolyfills(); +registerRuntime(netInitializeModule()); +await initPolyfillsAsync(); + +export const dotnet: DotnetHostBuilder | undefined = new HostBuilder() as DotnetHostBuilder; +export { exit }; diff --git a/src/native/corehost/browserhost/loader/exit.ts b/src/native/corehost/browserhost/loader/exit.ts new file mode 100644 index 00000000000000..f64a68a27d19ee --- /dev/null +++ b/src/native/corehost/browserhost/loader/exit.ts @@ -0,0 +1,15 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +import { netJSEngine, Logger } from "./cross-module"; + +// eslint-disable-next-line @typescript-eslint/no-unused-vars +export function exit(exit_code: number, reason: any): void { + const reasonStr = reason ? (reason.stack ? reason.stack || reason.message : reason.toString()) : ""; + if (exit_code !== 0) { + Logger.error(`Exit with code ${exit_code} ${reason ? "and reason: " + reasonStr : ""}`); + } + if (netJSEngine.IS_NODE) { + (globalThis as any).process.exit(exit_code); + } +} diff --git a/src/native/corehost/browserhost/loader/host-builder.ts b/src/native/corehost/browserhost/loader/host-builder.ts new file mode 100644 index 00000000000000..81e754a1edf455 --- /dev/null +++ b/src/native/corehost/browserhost/loader/host-builder.ts @@ -0,0 +1,174 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +import type { DotnetHostBuilder, LoaderConfig, RuntimeAPI, LoadBootResourceCallback, DotnetModuleConfig } from "./types"; + +import { Module, netPublicApi } from "./cross-module"; +import { downloadConfig, getLoaderConfig, mergeLoaderConfig } from "./config"; +import { createRuntime } from "./bootstrap"; +import { exit } from "./exit"; + +let configUrl: string | undefined = undefined; +let applicationArguments: string[] | undefined = []; +let loadBootResourceCallback: LoadBootResourceCallback | undefined = undefined; + +/* eslint-disable @typescript-eslint/no-unused-vars */ +export class HostBuilder implements DotnetHostBuilder { + private netPublicApi: RuntimeAPI | undefined; + withConfig(config: LoaderConfig): DotnetHostBuilder { + mergeLoaderConfig(config); + return this; + } + withConfigSrc(configSrc: string): DotnetHostBuilder { + configUrl = configSrc; + return this; + } + withApplicationArguments(...args: string[]): DotnetHostBuilder { + applicationArguments = args; + return this; + } + withEnvironmentVariable(name: string, value: string): DotnetHostBuilder { + mergeLoaderConfig({ + environmentVariables: { + [name]: value + } + }); + return this; + } + withEnvironmentVariables(variables: { [i: string]: string; }): DotnetHostBuilder { + mergeLoaderConfig({ + environmentVariables: variables + }); + return this; + } + withVirtualWorkingDirectory(vfsPath: string): DotnetHostBuilder { + mergeLoaderConfig({ + virtualWorkingDirectory: vfsPath + }); + return this; + } + withDiagnosticTracing(enabled: boolean): DotnetHostBuilder { + mergeLoaderConfig({ + diagnosticTracing: enabled + }); + return this; + } + withDebugging(level: number): DotnetHostBuilder { + mergeLoaderConfig({ + debugLevel: level + }); + return this; + } + withMainAssembly(mainAssemblyName: string): DotnetHostBuilder { + mergeLoaderConfig({ + mainAssemblyName: mainAssemblyName + }); + return this; + } + withApplicationArgumentsFromQuery(): DotnetHostBuilder { + if (!globalThis.window) { + throw new Error("Missing window to the query parameters from"); + } + + if (typeof globalThis.URLSearchParams == "undefined") { + throw new Error("URLSearchParams is supported"); + } + + const params = new URLSearchParams(globalThis.window.location.search); + const values = params.getAll("arg"); + return this.withApplicationArguments(...values); + } + withApplicationEnvironment(applicationEnvironment?: string): DotnetHostBuilder { + mergeLoaderConfig({ + applicationEnvironment: applicationEnvironment + }); + return this; + } + withApplicationCulture(applicationCulture?: string): DotnetHostBuilder { + mergeLoaderConfig({ + applicationCulture: applicationCulture + }); + return this; + } + withResourceLoader(loadBootResource?: LoadBootResourceCallback): DotnetHostBuilder { + loadBootResourceCallback = loadBootResource; + return this; + } + + // internal + withModuleConfig(moduleConfig: DotnetModuleConfig): DotnetHostBuilder { + Object.assign(Module, moduleConfig); + return this; + } + + // internal + withConsoleForwarding(): DotnetHostBuilder { + // TODO + return this; + } + + // internal + withExitOnUnhandledError(): DotnetHostBuilder { + // TODO + return this; + } + + // internal + withAsyncFlushOnExit(): DotnetHostBuilder { + // TODO + return this; + } + + // internal + withExitCodeLogging(): DotnetHostBuilder { + // TODO + return this; + } + + // internal + withElementOnExit(): DotnetHostBuilder { + // TODO + return this; + } + + // internal + withInteropCleanupOnExit(): DotnetHostBuilder { + // TODO + return this; + } + + async download(): Promise { + try { + await downloadConfig(configUrl, loadBootResourceCallback); + return createRuntime(true, loadBootResourceCallback); + } catch (err) { + exit(1, err); + throw err; + } + } + + async create(): Promise { + try { + await downloadConfig(configUrl, loadBootResourceCallback); + await createRuntime(false, loadBootResourceCallback); + this.netPublicApi = netPublicApi; + return this.netPublicApi; + } catch (err) { + exit(1, err); + throw err; + } + } + + async run(): Promise { + try { + if (!this.netPublicApi) { + await this.create(); + } + const config = getLoaderConfig(); + return this.netPublicApi!.runMainAndExit(config.mainAssemblyName, applicationArguments); + } catch (err) { + exit(1, err); + throw err; + } + } +} diff --git a/src/native/corehost/browserhost/loader/index.ts b/src/native/corehost/browserhost/loader/index.ts new file mode 100644 index 00000000000000..64abae3fdd2cd8 --- /dev/null +++ b/src/native/corehost/browserhost/loader/index.ts @@ -0,0 +1,86 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +import type { LoggerType, AssertType, RuntimeAPI, LoaderExports } from "./types"; + +import ProductVersion from "consts:productVersion"; +import BuildConfiguration from "consts:configuration"; +import GitHash from "consts:gitHash"; + +import { netLoaderConfig, getLoaderConfig } from "./config"; +import { exit } from "./exit"; +import { invokeLibraryInitializers } from "./lib-initializers"; +import { check, error, info, warn } from "./logging"; + +import { Assert, netInternals, netJSEngine, netLoaderExports, netTabulateLE, Logger, netSetInternals, netUpdateAllInternals, netUpdateModuleInternals } from "./cross-module"; +import { rejectRunMainPromise, resolveRunMainPromise, getRunMainPromise } from "./run"; + +export function netInitializeModule(): RuntimeAPI { + const ENVIRONMENT_IS_NODE = () => typeof process == "object" && typeof process.versions == "object" && typeof process.versions.node == "string"; + const ENVIRONMENT_IS_WEB_WORKER = () => typeof importScripts == "function"; + const ENVIRONMENT_IS_SIDECAR = () => ENVIRONMENT_IS_WEB_WORKER() && typeof dotnetSidecar !== "undefined"; // sidecar is emscripten main running in a web worker + const ENVIRONMENT_IS_WORKER = () => ENVIRONMENT_IS_WEB_WORKER() && !ENVIRONMENT_IS_SIDECAR(); // we redefine what ENVIRONMENT_IS_WORKER, we replace it in emscripten internals, so that sidecar works + const ENVIRONMENT_IS_WEB = () => typeof window == "object" || (ENVIRONMENT_IS_WEB_WORKER() && !ENVIRONMENT_IS_NODE()); + const ENVIRONMENT_IS_SHELL = () => !ENVIRONMENT_IS_WEB() && !ENVIRONMENT_IS_NODE(); + + const netPublicApi: Partial = { + INTERNAL: {}, + Module: {} as any, + runtimeId: -1, + runtimeBuildInfo: { + productVersion: ProductVersion, + gitHash: GitHash, + buildConfiguration: BuildConfiguration, + wasmEnableThreads: false, + wasmEnableSIMD: true, + wasmEnableExceptionHandling: true, + }, + }; + + const netInternalUpdates: (() => void)[] = []; + netSetInternals({ + netLoaderConfig: netLoaderConfig, + netPublicApi: netPublicApi as RuntimeAPI, + netInternalUpdates, + }); + const runtimeApiFunctions: Partial = { + getConfig: getLoaderConfig, + exit, + invokeLibraryInitializers, + }; + const loaderFunctions: LoaderExports = { + ENVIRONMENT_IS_NODE, + ENVIRONMENT_IS_SHELL, + ENVIRONMENT_IS_WEB, + ENVIRONMENT_IS_WORKER, + ENVIRONMENT_IS_SIDECAR, + getRunMainPromise, + rejectRunMainPromise, + resolveRunMainPromise, + }; + const jsEngine = { + IS_NODE: ENVIRONMENT_IS_NODE(), + IS_SHELL: ENVIRONMENT_IS_SHELL(), + IS_WEB: ENVIRONMENT_IS_WEB(), + IS_WORKER: ENVIRONMENT_IS_WORKER(), + IS_SIDECAR: ENVIRONMENT_IS_SIDECAR(), + }; + const logger: LoggerType = { + info, + warn, + error, + }; + const assert: AssertType = { + check, + }; + Object.assign(netPublicApi, runtimeApiFunctions); + Object.assign(Logger, logger); + Object.assign(Assert, assert); + Object.assign(netJSEngine, jsEngine); + Object.assign(netLoaderExports, loaderFunctions); + netInternals.netLoaderExportsTable = [...netTabulateLE(Logger, Assert, netLoaderExports)]; + netInternalUpdates.push(netUpdateModuleInternals); + netUpdateAllInternals(); + + return netPublicApi as RuntimeAPI; +} diff --git a/src/native/corehost/browserhost/loader/lib-initializers.ts b/src/native/corehost/browserhost/loader/lib-initializers.ts new file mode 100644 index 00000000000000..171d2855d8bfa0 --- /dev/null +++ b/src/native/corehost/browserhost/loader/lib-initializers.ts @@ -0,0 +1,7 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +// eslint-disable-next-line @typescript-eslint/no-unused-vars +export async function invokeLibraryInitializers(functionName: string, args: any[]): Promise { + throw new Error("Not implemented"); +} diff --git a/src/native/corehost/browserhost/loader/logging.ts b/src/native/corehost/browserhost/loader/logging.ts new file mode 100644 index 00000000000000..a4527d96b72c0d --- /dev/null +++ b/src/native/corehost/browserhost/loader/logging.ts @@ -0,0 +1,37 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +// WASM-TODO: inline the code + +export function check(condition: unknown, messageFactory: string | (() => string)): asserts condition { + if (!condition) { + const message = typeof messageFactory === "string" ? messageFactory : messageFactory(); + throw new Error(`Assert failed: ${message}`); + } +} + +/* eslint-disable no-console */ + +const prefix = "CLR_WASM: "; + +export function info(msg: string, ...data: any) { + console.info(prefix + msg, ...data); +} + +export function warn(msg: string, ...data: any) { + console.warn(prefix + msg, ...data); +} + +export function error(msg: string, ...data: any) { + if (data && data.length > 0 && data[0] && typeof data[0] === "object") { + // don't log silent errors + if (data[0].silent) { + return; + } + if (data[0].toString) { + console.error(prefix + msg, data[0].toString()); + return; + } + } + console.error(prefix + msg, ...data); +} diff --git a/src/native/corehost/browserhost/loader/polyfills.ts b/src/native/corehost/browserhost/loader/polyfills.ts new file mode 100644 index 00000000000000..e6c179d5c7957a --- /dev/null +++ b/src/native/corehost/browserhost/loader/polyfills.ts @@ -0,0 +1,145 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +import { netJSEngine } from "./cross-module"; + +export function initPolyfills(): void { + if (typeof globalThis.WeakRef !== "function") { + class WeakRefPolyfill { + private _value: T | undefined; + + constructor(value: T) { + this._value = value; + } + + deref(): T | undefined { + return this._value; + } + } + globalThis.WeakRef = WeakRefPolyfill as any; + } + if (typeof globalThis.fetch !== "function") { + globalThis.fetch = fetchLike as any; + } +} + +export async function initPolyfillsAsync(): Promise { + if (netJSEngine.IS_NODE) { + if (!globalThis.crypto) { + globalThis.crypto = {}; + } + if (!globalThis.crypto.getRandomValues) { + let nodeCrypto: any = undefined; + try { + // eslint-disable-next-line @typescript-eslint/ban-ts-comment + // @ts-ignore: + nodeCrypto = await import(/*! webpackIgnore: true */"node:crypto"); + } catch (err: any) { + // Noop, error throwing polyfill provided bellow + } + + if (!nodeCrypto) { + globalThis.crypto.getRandomValues = () => { + throw new Error("Using node without crypto support. To enable current operation, either provide polyfill for 'globalThis.crypto.getRandomValues' or enable 'node:crypto' module."); + }; + } else if (nodeCrypto.webcrypto) { + globalThis.crypto = nodeCrypto.webcrypto; + } else if (nodeCrypto.randomBytes) { + const getRandomValues = (buffer: Uint8Array) => { + if (buffer) { + buffer.set(nodeCrypto.randomBytes(buffer.length)); + } + }; + globalThis.crypto.getRandomValues = getRandomValues as any; + } + } + if (!globalThis.performance) { + // eslint-disable-next-line @typescript-eslint/ban-ts-comment + // @ts-ignore: + globalThis.performance = (await import(/*! webpackIgnore: true */"perf_hooks")).performance; + } + } + // WASM-TODO: performance polyfill for V8 +} + +export async function fetchLike(url: string, init?: RequestInit): Promise { + let node_fs: any | undefined = undefined; + let node_url: any | undefined = undefined; + try { + // this need to be detected only after we import node modules in onConfigLoaded + const hasFetch = typeof (globalThis.fetch) === "function"; + if (netJSEngine.IS_NODE) { + const isFileUrl = url.startsWith("file://"); + if (!isFileUrl && hasFetch) { + return globalThis.fetch(url, init || { credentials: "same-origin" }); + } + if (!node_fs) { + // eslint-disable-next-line @typescript-eslint/ban-ts-comment + // @ts-ignore: + node_url = await import(/*! webpackIgnore: true */"url"); + // eslint-disable-next-line @typescript-eslint/ban-ts-comment + // @ts-ignore: + node_fs = await import(/*! webpackIgnore: true */"fs"); + } + if (isFileUrl) { + url = node_url.fileURLToPath(url); + } + + const arrayBuffer = await node_fs.promises.readFile(url); + return { + ok: true, + headers: { + length: 0, + get: () => null + }, + url, + arrayBuffer: () => arrayBuffer, + json: () => JSON.parse(arrayBuffer), + text: () => { + throw new Error("NotImplementedException"); + } + }; + } else if (hasFetch) { + return globalThis.fetch(url, init || { credentials: "same-origin" }); + } else if (typeof (read) === "function") { + // note that it can't open files with unicode names, like Strae.xml + // https://bugs.chromium.org/p/v8/issues/detail?id=12541 + return { + ok: true, + url, + headers: { + length: 0, + get: () => null + }, + arrayBuffer: () => { + return new Uint8Array(read(url, "binary")); + }, + json: () => { + return JSON.parse(read(url, "utf8")); + }, + text: () => read(url, "utf8") + }; + } + } catch (e: any) { + return { + ok: false, + url, + status: 500, + headers: { + length: 0, + get: () => null + }, + statusText: "ERR28: " + e, + arrayBuffer: () => { + throw e; + }, + json: () => { + throw e; + }, + text: () => { + throw e; + } + }; + } + throw new Error("No fetch implementation available"); +} diff --git a/src/native/corehost/browserhost/loader/promise-completion-source.ts b/src/native/corehost/browserhost/loader/promise-completion-source.ts new file mode 100644 index 00000000000000..ee059c19234d0e --- /dev/null +++ b/src/native/corehost/browserhost/loader/promise-completion-source.ts @@ -0,0 +1,54 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +import type { ControllablePromise, PromiseCompletionSource } from "./types"; + +/// a unique symbol used to mark a promise as controllable +export const controllablePromiseSymbol = Symbol.for("ControllablePromise"); + +/// Creates a new promise together with a controller that can be used to resolve or reject that promise. +/// Optionally takes callbacks to be called immediately after a promise is resolved or rejected. +export function createPromiseCompletionSource(afterResolve?: () => void, afterReject?: () => void): PromiseCompletionSource { + let promiseControl: PromiseCompletionSource = null as unknown as PromiseCompletionSource; + const promise = new Promise((resolve, reject) => { + promiseControl = { + isDone: false, + promise: null as unknown as ControllablePromise, + resolve: (data: TResult | PromiseLike) => { + if (!promiseControl!.isDone) { + promiseControl!.isDone = true; + resolve(data); + if (afterResolve) { + afterResolve(); + } + } + }, + reject: (reason: any) => { + if (!promiseControl!.isDone) { + promiseControl!.isDone = true; + reject(reason); + if (afterReject) { + afterReject(); + } + } + }, + propagateFrom: (other: Promise) => { + other.then(promiseControl!.resolve).catch(promiseControl!.reject); + } + }; + }); + (promiseControl).promise = promise; + const controllablePromise = promise as ControllablePromise; + (controllablePromise as any)[controllablePromiseSymbol] = promiseControl; + return promiseControl; +} + +export function getPromiseCompletionSource(promise: ControllablePromise): PromiseCompletionSource; +export function getPromiseCompletionSource(promise: Promise): PromiseCompletionSource | undefined { + return (promise as any)[controllablePromiseSymbol]; +} + +export function isControllablePromise(promise: Promise): promise is ControllablePromise { + return (promise as any)[controllablePromiseSymbol] !== undefined; +} + diff --git a/src/native/corehost/browserhost/loader/run.ts b/src/native/corehost/browserhost/loader/run.ts new file mode 100644 index 00000000000000..c343fefcb08b81 --- /dev/null +++ b/src/native/corehost/browserhost/loader/run.ts @@ -0,0 +1,35 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +import { Module } from "./cross-module"; +import { exit } from "./exit"; +import { createPromiseCompletionSource } from "./promise-completion-source"; + +let CoreCLRInitialized = false; +const runMainPromiseController = createPromiseCompletionSource(); + +export function BrowserHost_InitializeCoreCLR():void { + if (CoreCLRInitialized) { + return; + } + // int BrowserHost_InitializeCoreCLR(void) + const res = Module.ccall("BrowserHost_InitializeCoreCLR", "number") as number; + if (res != 0) { + const reason = new Error("Failed to netInitializeModule CoreCLR"); + runMainPromiseController.reject(reason); + exit(res, reason); + } + CoreCLRInitialized = true; +} + +export function resolveRunMainPromise(exitCode:number):void { + runMainPromiseController.resolve(exitCode); +} + +export function rejectRunMainPromise(reason:any):void { + runMainPromiseController.reject(reason); +} + +export function getRunMainPromise():Promise { + return runMainPromiseController.promise; +} diff --git a/src/native/corehost/browserhost/loader/runtime-list.ts b/src/native/corehost/browserhost/loader/runtime-list.ts new file mode 100644 index 00000000000000..32f65011ed63fa --- /dev/null +++ b/src/native/corehost/browserhost/loader/runtime-list.ts @@ -0,0 +1,36 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +import type { RuntimeAPI } from "./types"; + +let runtimeList: RuntimeList; + +class RuntimeList { + private list: { [runtimeId: number]: WeakRef } = {}; + + public registerRuntime(api: RuntimeAPI): number { + if (api.runtimeId === undefined) { + api.runtimeId = Object.keys(this.list).length; + } + this.list[api.runtimeId] = new (globalThis as any).WeakRef(api); + return api.runtimeId; + } + + public getRuntime(runtimeId: number): RuntimeAPI | undefined { + const wr = this.list[runtimeId]; + return wr ? wr.deref() : undefined; + } +} + +export function registerRuntime(api: RuntimeAPI): number { + const globalThisAny = globalThis as any; + // this code makes it possible to find dotnet runtime on a page via global namespace, even when there are multiple runtimes at the same time + if (!globalThisAny.getDotnetRuntime) { + globalThisAny.getDotnetRuntime = (runtimeId: string) => globalThisAny.getDotnetRuntime.__list.getRuntime(runtimeId); + globalThisAny.getDotnetRuntime.__list = runtimeList = new RuntimeList(); + } else { + runtimeList = globalThisAny.getDotnetRuntime.__list; + } + + return runtimeList.registerRuntime(api); +} diff --git a/src/native/corehost/browserhost/loader/types.ts b/src/native/corehost/browserhost/loader/types.ts new file mode 100644 index 00000000000000..2786379af7369f --- /dev/null +++ b/src/native/corehost/browserhost/loader/types.ts @@ -0,0 +1,4 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +export * from "../types"; diff --git a/src/native/corehost/browserhost/sample/CMakeLists.txt b/src/native/corehost/browserhost/sample/CMakeLists.txt index ad0437cbdbdd0f..7f1d30ff7a099b 100644 --- a/src/native/corehost/browserhost/sample/CMakeLists.txt +++ b/src/native/corehost/browserhost/sample/CMakeLists.txt @@ -9,8 +9,10 @@ set(SAMPLE_ASSETS main.mjs dotnet.boot.js ${CLR_ARTIFACTS_OBJ_DIR}/coreclr/browser.wasm.${CMAKE_BUILD_TYPE}/corehost/dotnet.js + ${CLR_ARTIFACTS_OBJ_DIR}/coreclr/browser.wasm.${CMAKE_BUILD_TYPE}/corehost/dotnet.js.map ${CLR_ARTIFACTS_OBJ_DIR}/coreclr/browser.wasm.${CMAKE_BUILD_TYPE}/corehost/dotnet.d.ts ${CLR_ARTIFACTS_OBJ_DIR}/native/browser-${CMAKE_BUILD_TYPE}-wasm/System.Runtime.InteropServices.JavaScript.Native/dotnet.runtime.js + ${CLR_ARTIFACTS_OBJ_DIR}/native/browser-${CMAKE_BUILD_TYPE}-wasm/System.Runtime.InteropServices.JavaScript.Native/dotnet.runtime.js.map # Bring your own DLLs and update the dotnet.boot.js to match # HelloWorld.dll diff --git a/src/native/corehost/browserhost/types.ts b/src/native/corehost/browserhost/types.ts new file mode 100644 index 00000000000000..b586a5ddc79cad --- /dev/null +++ b/src/native/corehost/browserhost/types.ts @@ -0,0 +1,4 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +export * from "../../libs/Common/JavaScript/types"; diff --git a/src/native/libs/Common/JavaScript/cross-linked/index.ts b/src/native/libs/Common/JavaScript/cross-linked/index.ts new file mode 100644 index 00000000000000..839a0d855aa5f9 --- /dev/null +++ b/src/native/libs/Common/JavaScript/cross-linked/index.ts @@ -0,0 +1,23 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +import type { AssertType, EmscriptenModuleInternal, JSEngineType, LoggerType, LoaderExports, InternalExchange, RuntimeExports, RuntimeExportsTable, HostNativeExportsTable, HostNativeExports, InteropJavaScriptNativeExports, InteropJavaScriptNativeExportsTable, NativeBrowserExports, NativeBrowserExportsTable } from "../types"; + +// we want to use the cross-module symbols defined in closure of dotnet.native.js +// which are installed there by libSystem.Native.Browser.footer.js +// see also `reserved` in `rollup.config.defines.js` +declare global { + export const Assert:AssertType; + export const Logger:LoggerType; + export const Module:EmscriptenModuleInternal; + export const netJSEngine:JSEngineType; + export const netLoaderExports:LoaderExports; + export const netTabulateJSNE:(hostNativeExports:InteropJavaScriptNativeExports) => InteropJavaScriptNativeExportsTable; + export const netTabulateRE:(hostNativeExports:RuntimeExports) => RuntimeExportsTable; + export const netTabulateHE:(hostNativeExports:HostNativeExports) => HostNativeExportsTable; + export const netTabulateNBE:(hostNativeExports:NativeBrowserExports) => NativeBrowserExportsTable; + export const netTabulateLE:(hostNativeExports:HostNativeExports) => HostNativeExportsTable; + export const netSetInternals:(internals:Partial) => void; + export const netUpdateAllInternals:() => void; + export const netUpdateModuleInternals:() => void; +} diff --git a/src/native/libs/Common/JavaScript/cross-module/index.ts b/src/native/libs/Common/JavaScript/cross-module/index.ts new file mode 100644 index 00000000000000..6130a5aa3c6373 --- /dev/null +++ b/src/native/libs/Common/JavaScript/cross-module/index.ts @@ -0,0 +1,171 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +/** + * Common symbols shared between multiple JS modules. + * IMPORTANT: Anything you add into this folder could be duplicated into multiple JS bundles! + * Please keep it small and register it into emscripten as dependency. + */ + +import type { DotnetModuleInternal, InternalExchange, RuntimeExports, LoaderExports, RuntimeAPI, LoggerType, AssertType, JSEngineType, HostNativeExports, InteropJavaScriptNativeExports, LoaderExportsTable, RuntimeExportsTable, HostNativeExportsTable, InteropJavaScriptNativeExportsTable, NativeBrowserExports, NativeBrowserExportsTable } from "../types"; + +export let Module: DotnetModuleInternal; +export let netPublicApi: RuntimeAPI; +export let Logger: LoggerType = {} as any; +export let Assert: AssertType = {} as any; +export let netJSEngine: JSEngineType = {}as any; +export let netLoaderExports: LoaderExports = {} as any; +export let netRuntimeExports: RuntimeExports = {} as any; +export let netBrowserHostExports: HostNativeExports = {} as any; +export let netInteropJSExports: InteropJavaScriptNativeExports = {} as any; +export let netNativeBrowserExports: NativeBrowserExports = {} as any; +export let netInternals: InternalExchange; + +export function getInternals(): InternalExchange { + return netInternals; +} + +export function netSetInternals(internal: Partial) { + netInternals = internal as InternalExchange; + netPublicApi = netInternals.netPublicApi; + Module = netInternals.netPublicApi.Module as any; + if (netInternals.netInternalUpdates === undefined) { + netInternals.netInternalUpdates = []; + } +} + +export function netUpdateAllInternals() { + for (const updateImpl of netInternals.netInternalUpdates) { + updateImpl(); + } +} + +export function netUpdateModuleInternals() { + if (Object.keys(netLoaderExports).length === 0 && netInternals.netLoaderExportsTable) { + netLoaderExports = {} as LoaderExports; + Logger = {} as LoggerType; + Assert = {} as AssertType; + netJSEngine = {} as JSEngineType; + expandLE(netInternals.netLoaderExportsTable, Logger, Assert, netJSEngine, netLoaderExports); + } + if (Object.keys(netRuntimeExports).length === 0 && netInternals.netRuntimeExportsTable) { + netRuntimeExports = {} as RuntimeExports; + expandRE(netInternals.netRuntimeExportsTable, netRuntimeExports); + } + if (Object.keys(netBrowserHostExports).length === 0 && netInternals.netBrowserHostExportsTable) { + netBrowserHostExports = {} as HostNativeExports; + expandHE(netInternals.netBrowserHostExportsTable, netBrowserHostExports); + } + if (Object.keys(netInteropJSExports).length === 0 && netInternals.netInteropJSExportsTable) { + netInteropJSExports = {} as InteropJavaScriptNativeExports; + expandJSNE(netInternals.netInteropJSExportsTable, netInteropJSExports); + } + if (Object.keys(netNativeBrowserExports).length === 0 && netInternals.netNativeBrowserExportsTable) { + netNativeBrowserExports = {} as NativeBrowserExports; + expandNBE(netInternals.netNativeBrowserExportsTable, netNativeBrowserExports); + } +} + +/** + * Functions below allow our JS modules to exchange internal interfaces by passing tables of functions in known order instead of using string symbols. + * IMPORTANT: If you need to add more functions, make sure that you add them at the end of the table, so that the order of existing functions does not change. + */ + +export function netTabulateLE(logger:LoggerType, assert:AssertType, netLoaderExports:LoaderExports):LoaderExportsTable { + return [ + logger.info, + logger.warn, + logger.error, + assert.check, + netLoaderExports.ENVIRONMENT_IS_NODE, + netLoaderExports.ENVIRONMENT_IS_SHELL, + netLoaderExports.ENVIRONMENT_IS_WEB, + netLoaderExports.ENVIRONMENT_IS_WORKER, + netLoaderExports.ENVIRONMENT_IS_SIDECAR, + netLoaderExports.resolveRunMainPromise, + netLoaderExports.rejectRunMainPromise, + netLoaderExports.getRunMainPromise, + ]; +} + +function expandLE(table:LoaderExportsTable, logger:LoggerType, assert:AssertType, jsEngine:JSEngineType, netLoaderExports:LoaderExports):void { + const loggerLocal :LoggerType = { + info: table[0], + warn: table[1], + error: table[2], + }; + const assertLocal :AssertType = { + check: table[3], + }; + const loaderExportsLocal :LoaderExports = { + ENVIRONMENT_IS_NODE: table[4], + ENVIRONMENT_IS_SHELL: table[5], + ENVIRONMENT_IS_WEB: table[6], + ENVIRONMENT_IS_WORKER: table[7], + ENVIRONMENT_IS_SIDECAR: table[8], + resolveRunMainPromise: table[9], + rejectRunMainPromise: table[10], + getRunMainPromise: table[11], + }; + const jsEngineLocal :JSEngineType = { + IS_NODE: loaderExportsLocal.ENVIRONMENT_IS_NODE(), + IS_SHELL: loaderExportsLocal.ENVIRONMENT_IS_SHELL(), + IS_WEB: loaderExportsLocal.ENVIRONMENT_IS_WEB(), + IS_WORKER: loaderExportsLocal.ENVIRONMENT_IS_WORKER(), + IS_SIDECAR: loaderExportsLocal.ENVIRONMENT_IS_SIDECAR(), + }; + Object.assign(netLoaderExports, loaderExportsLocal); + Object.assign(logger, loggerLocal); + Object.assign(assert, assertLocal); + Object.assign(jsEngine, jsEngineLocal); +} + +// eslint-disable-next-line @typescript-eslint/no-unused-vars +export function netTabulateRE(map:RuntimeExports):RuntimeExportsTable { + return [ + ]; +} + +function expandRE(table:RuntimeExportsTable, runtime:RuntimeExports):void { + Object.assign(runtime, { + }); +} + +export function netTabulateHE(map:HostNativeExports):HostNativeExportsTable { + return [ + map.registerDllBytes, + map.isSharedArrayBuffer, + ]; +} + +function expandHE(table:HostNativeExportsTable, native:HostNativeExports):void { + const nativeLocal :HostNativeExports = { + registerDllBytes: table[0], + isSharedArrayBuffer: table[1], + }; + Object.assign(native, nativeLocal); +} + +// eslint-disable-next-line @typescript-eslint/no-unused-vars +export function netTabulateJSNE(map:InteropJavaScriptNativeExports):InteropJavaScriptNativeExportsTable { + return [ + ]; +} + +function expandJSNE(table:InteropJavaScriptNativeExportsTable, interop:InteropJavaScriptNativeExports):void { + const interopLocal :InteropJavaScriptNativeExports = { + }; + Object.assign(interop, interopLocal); +} + +// eslint-disable-next-line @typescript-eslint/no-unused-vars +export function netTabulateNBE(map:NativeBrowserExports):NativeBrowserExportsTable { + return [ + ]; +} + +function expandNBE(table:NativeBrowserExportsTable, interop:NativeBrowserExports):void { + const interopLocal :NativeBrowserExports = { + }; + Object.assign(interop, interopLocal); +} diff --git a/src/native/libs/Common/JavaScript/types/exchange.ts b/src/native/libs/Common/JavaScript/types/exchange.ts index da388fb591910f..d0c8e4c2c14484 100644 --- a/src/native/libs/Common/JavaScript/types/exchange.ts +++ b/src/native/libs/Common/JavaScript/types/exchange.ts @@ -4,9 +4,9 @@ import type { registerDllBytes } from "../../../../corehost/browserhost/host/host"; import type { isSharedArrayBuffer } from "../../../../corehost/browserhost/host/memory"; import type { check, error, info, warn } from "../../../../corehost/browserhost/loader/logging"; -import type { browserHostResolveMain, browserHostRejectMain, getRunMainPromise } from "../../../../corehost/browserhost/loader/run"; +import type { resolveRunMainPromise, rejectRunMainPromise, getRunMainPromise } from "../../../../corehost/browserhost/loader/run"; -export type EnvironmentType = { +export type JSEngineType = { IS_NODE: boolean, IS_SHELL: boolean, IS_WEB: boolean, @@ -36,8 +36,8 @@ export type LoaderExports = { ENVIRONMENT_IS_WEB: ()=> boolean, ENVIRONMENT_IS_WORKER: ()=> boolean, ENVIRONMENT_IS_SIDECAR: ()=> boolean, - browserHostResolveMain:typeof browserHostResolveMain, - browserHostRejectMain:typeof browserHostRejectMain, + resolveRunMainPromise:typeof resolveRunMainPromise, + rejectRunMainPromise:typeof rejectRunMainPromise, getRunMainPromise:typeof getRunMainPromise, } @@ -51,8 +51,8 @@ export type LoaderExportsTable = [ ()=> boolean, ()=> boolean, ()=> boolean, - typeof browserHostResolveMain, - typeof browserHostRejectMain, + typeof resolveRunMainPromise, + typeof rejectRunMainPromise, typeof getRunMainPromise, ] diff --git a/src/native/libs/Common/JavaScript/types/internal.ts b/src/native/libs/Common/JavaScript/types/internal.ts index d05e1f8f0e8305..40a22496bb6b10 100644 --- a/src/native/libs/Common/JavaScript/types/internal.ts +++ b/src/native/libs/Common/JavaScript/types/internal.ts @@ -3,7 +3,7 @@ import type { DotnetModuleConfig, RuntimeAPI, AssetEntry, LoaderConfig, LoadingResource } from "./public-api"; import type { CharPtr, EmscriptenModule, ManagedPointer, NativePointer, VoidPtr } from "./emscripten"; -import { InteropJavaScriptNativeExportsTable, LoaderExportsTable, HostNativeExportsTable, RuntimeExportsTable, NativeBrowserExportsTable } from "./exchange"; +import { InteropJavaScriptNativeExportsTable as InteropJavaScriptExportsTable, LoaderExportsTable, HostNativeExportsTable, RuntimeExportsTable, NativeBrowserExportsTable } from "./exchange"; export type GCHandle = { __brand: "GCHandle" @@ -92,32 +92,32 @@ export type LoaderConfigInternal = LoaderConfig & { /// A Promise with a controller attached -export interface ControllablePromise extends Promise { +export interface ControllablePromise extends Promise { __brand: "ControllablePromise" } /// Just a pair of a promise and its controller -export interface PromiseController { - readonly promise: ControllablePromise; +export interface PromiseCompletionSource { + readonly promise: ControllablePromise; isDone: boolean; - resolve: (value: T | PromiseLike) => void; + resolve: (value: TResult | PromiseLike) => void; reject: (reason?: any) => void; - propagateFrom: (other: Promise) => void; + propagateFrom: (other: Promise) => void; } -export type InternalApis = { - runtimeApi: RuntimeAPI, - runtimeExportsTable: RuntimeExportsTable, - loaderExportsTable: LoaderExportsTable, - hostNativeExportsTable: HostNativeExportsTable, - interopJavaScriptNativeExportsTable: InteropJavaScriptNativeExportsTable, - nativeBrowserExportsTable: NativeBrowserExportsTable, - config: LoaderConfigInternal, - updates: (() => void)[], +export type InternalExchange = { + netPublicApi: RuntimeAPI, + netRuntimeExportsTable: RuntimeExportsTable, + netLoaderExportsTable: LoaderExportsTable, + netBrowserHostExportsTable: HostNativeExportsTable, + netInteropJSExportsTable: InteropJavaScriptExportsTable, + netNativeBrowserExportsTable: NativeBrowserExportsTable, + netLoaderConfig: LoaderConfigInternal, + netInternalUpdates: (() => void)[], } export type JsModuleExports = { - initialize(internals: InternalApis): Promise; + netInitializeModule(internals: InternalExchange): Promise; }; diff --git a/src/native/libs/System.Native.Browser/CMakeLists.txt b/src/native/libs/System.Native.Browser/CMakeLists.txt index ef53459c67af5a..9ba68b404a0cb0 100644 --- a/src/native/libs/System.Native.Browser/CMakeLists.txt +++ b/src/native/libs/System.Native.Browser/CMakeLists.txt @@ -13,29 +13,33 @@ add_library(System.Native.Browser-Static set_target_properties(System.Native.Browser-Static PROPERTIES OUTPUT_NAME System.Native.Browser CLEAN_DIRECT_OUTPUT 1) install(TARGETS System.Native.Browser-Static DESTINATION ${STATIC_LIB_DESTINATION} COMPONENT libs) -# WASM-TODO *.ts files instead -set(ROLLUP_TS_SOURCES - "${CMAKE_CURRENT_SOURCE_DIR}/../../corehost/browserhost/loader/dotnet.js" - "${CMAKE_CURRENT_SOURCE_DIR}/../../corehost/browserhost/loader/dotnet.d.ts" - "${CMAKE_CURRENT_SOURCE_DIR}/../../corehost/browserhost/libBrowserHost.js" - "${CMAKE_CURRENT_SOURCE_DIR}/libSystem.Native.Browser.js" - "${CMAKE_CURRENT_SOURCE_DIR}/libSystem.Native.Browser.extpost.js" - "${CMAKE_CURRENT_SOURCE_DIR}/../System.Runtime.InteropServices.JavaScript.Native/libSystem.Runtime.InteropServices.JavaScript.Native.js" - "${CMAKE_CURRENT_SOURCE_DIR}/../System.Runtime.InteropServices.JavaScript.Native/dotnet.runtime.js" - "${CMAKE_CURRENT_SOURCE_DIR}/./libSystem.Native.Browser.extpost.js" - "${CMAKE_CURRENT_SOURCE_DIR}/./libSystem.Native.Browser.js" + +file(GLOB_RECURSE ROLLUP_TS_SOURCES + "${CMAKE_CURRENT_SOURCE_DIR}/*.ts" + "${CMAKE_CURRENT_SOURCE_DIR}/*.js" + "${CMAKE_CURRENT_SOURCE_DIR}/../System.Runtime.InteropServices.JavaScript.Native/*.ts" + "${CMAKE_CURRENT_SOURCE_DIR}/../System.Runtime.InteropServices.JavaScript.Native/*.js" + "${CMAKE_CURRENT_SOURCE_DIR}/../Common/JavaScript/*.ts" + "${CMAKE_CURRENT_SOURCE_DIR}/../Common/JavaScript/*.js" + "${CMAKE_CURRENT_SOURCE_DIR}/../../corehost/browserhost/*.ts" + "${CMAKE_CURRENT_SOURCE_DIR}/../../corehost/browserhost/*.js" "${CMAKE_CURRENT_SOURCE_DIR}/../../package.json" "${CMAKE_CURRENT_SOURCE_DIR}/../../tsconfig.json" + "${CMAKE_CURRENT_SOURCE_DIR}/../../node_modules/.npm-stamp" ) -# WASM-TODO *.js.map files set(ROLLUP_OUTPUTS "${CLR_ARTIFACTS_OBJ_DIR}/coreclr/browser.wasm.${CMAKE_BUILD_TYPE}/corehost/dotnet.js" + "${CLR_ARTIFACTS_OBJ_DIR}/coreclr/browser.wasm.${CMAKE_BUILD_TYPE}/corehost/dotnet.js.map" "${CLR_ARTIFACTS_OBJ_DIR}/coreclr/browser.wasm.${CMAKE_BUILD_TYPE}/corehost/dotnet.d.ts" "${CLR_ARTIFACTS_OBJ_DIR}/coreclr/browser.wasm.${CMAKE_BUILD_TYPE}/corehost/libBrowserHost.js" + "${CLR_ARTIFACTS_OBJ_DIR}/coreclr/browser.wasm.${CMAKE_BUILD_TYPE}/corehost/libBrowserHost.js.map" "${CLR_ARTIFACTS_OBJ_DIR}/native/browser-${CMAKE_BUILD_TYPE}-wasm/System.Native.Browser/libSystem.Native.Browser.js" + "${CLR_ARTIFACTS_OBJ_DIR}/native/browser-${CMAKE_BUILD_TYPE}-wasm/System.Native.Browser/libSystem.Native.Browser.js.map" "${CLR_ARTIFACTS_OBJ_DIR}/native/browser-${CMAKE_BUILD_TYPE}-wasm/System.Native.Browser/dotnet.runtime.js" + "${CLR_ARTIFACTS_OBJ_DIR}/native/browser-${CMAKE_BUILD_TYPE}-wasm/System.Native.Browser/dotnet.runtime.js.map" "${CLR_ARTIFACTS_OBJ_DIR}/native/browser-${CMAKE_BUILD_TYPE}-wasm/System.Runtime.InteropServices.JavaScript.Native/libSystem.Runtime.InteropServices.JavaScript.Native.js" + "${CLR_ARTIFACTS_OBJ_DIR}/native/browser-${CMAKE_BUILD_TYPE}-wasm/System.Runtime.InteropServices.JavaScript.Native/libSystem.Runtime.InteropServices.JavaScript.Native.js.map" ) set(ROLLUP_STAMP @@ -54,7 +58,7 @@ endif() add_custom_command( OUTPUT ${ROLLUP_STAMP} BYPRODUCTS ${ROLLUP_OUTPUTS} - COMMAND npm run rollup:stub -- ${CMAKE_BUILD_TYPE} ${PRODUCT_VERSION_JS} ${CI_BUILD_JS} + COMMAND npm run rollup:cmake -- "Configuration:${CMAKE_BUILD_TYPE},ProductVersion:${PRODUCT_VERSION_JS},ContinuousIntegrationBuild:${CI_BUILD_JS}" WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/../.." COMMENT "Running 'npm run rollup' to generate JavaScript bundles" DEPENDS ${ROLLUP_TS_SOURCES} diff --git a/src/native/libs/System.Native.Browser/cross-module.ts b/src/native/libs/System.Native.Browser/cross-module.ts new file mode 100644 index 00000000000000..cc943b5b433b19 --- /dev/null +++ b/src/native/libs/System.Native.Browser/cross-module.ts @@ -0,0 +1,4 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +export * from "../Common/JavaScript/cross-module"; diff --git a/src/native/libs/System.Native.Browser/libSystem.Native.Browser.extpost.js b/src/native/libs/System.Native.Browser/libSystem.Native.Browser.extpost.js index 81df9991c0d16d..8dd8d661d657b4 100644 --- a/src/native/libs/System.Native.Browser/libSystem.Native.Browser.extpost.js +++ b/src/native/libs/System.Native.Browser/libSystem.Native.Browser.extpost.js @@ -1,10 +1,10 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -var fetch = fetch || undefined; var _nativeModuleLoaded = false; var dotnetInternals = null; -export function initialize(internals) { - if (_nativeModuleLoaded) throw new Error("Native module already loaded"); - dotnetInternals = internals; - _nativeModuleLoaded = true; - return createDotnetRuntime(dotnetInternals.runtimeApi.Module); +var fetch = fetch || undefined; var netNativeModuleLoaded = false; var netInternals = null; +export function netInitializeModule(internals) { + if (netNativeModuleLoaded) throw new Error("Native module already loaded"); + netInternals = internals; + netNativeModuleLoaded = true; + return createDotnetRuntime(netInternals.netPublicApi.Module); } diff --git a/src/native/libs/System.Native.Browser/libSystem.Native.Browser.footer.js b/src/native/libs/System.Native.Browser/libSystem.Native.Browser.footer.js new file mode 100644 index 00000000000000..7e96f63546fd45 --- /dev/null +++ b/src/native/libs/System.Native.Browser/libSystem.Native.Browser.footer.js @@ -0,0 +1,56 @@ +//! Licensed to the .NET Foundation under one or more agreements. +//! The .NET Foundation licenses this file to you under the MIT license. + +/** + * This is root of **Emscripten library** that would become part of `dotnet.native.js` + * It implements PAL for the VM/runtime. + */ + +(function (exports) { + function libFactory() { + // this executes the function at link time in order to capture exports + // this is what Emscripten does for linking JS libraries + // https://emscripten.org/docs/porting/connecting_cpp_and_javascript/Interacting-with-code.html#javascript-limits-in-library-files + // it would execute the code at link time and call .toString() on functions to move it to the final output + // this process would loose any closure references, unless they are passed to `__deps` and also explicitly given to the linker + // JS name mangling and minification also applies, see src\native\rollup.config.defines.js and `reservedRx` there + const exports = {}; + libNativeBrowser(exports); + + let commonDeps = []; + const lib = { + $DOTNET: { + selfInitialize: () => { + if (typeof netInternals !== "undefined") { + DOTNET.netInternals = netInternals; + DOTNET.netInitializeModule(netInternals); + } + }, + netInitializeModule: exports.netInitializeModule, + }, + $DOTNET__deps: commonDeps, + $DOTNET__postset: "DOTNET.selfInitialize()", + }; + + // keep in sync with `crossModule`+`crossModuleFn` in src\native\rollup.config.defines.js + for (const exportName of Reflect.ownKeys(exports.cross)) { + const name = String(exportName); + if (name === "netInternals") continue; + if (name === "Module") continue; + const emName = "$" + name; + lib[emName] = exports.cross[exportName]; + commonDeps.push(emName); + } + for (const exportName of Reflect.ownKeys(exports)) { + const name = String(exportName); + if (name === "cross") continue; + if (name === "netInitializeModule") continue; + lib[name] = exports[name]; + } + + autoAddDeps(lib, "$DOTNET"); + addToLibrary(lib); + } + libFactory(); + return exports; +})({}); diff --git a/src/native/libs/System.Native.Browser/libSystem.Native.Browser.js b/src/native/libs/System.Native.Browser/libSystem.Native.Browser.js deleted file mode 100644 index 42dae127fd3568..00000000000000 --- a/src/native/libs/System.Native.Browser/libSystem.Native.Browser.js +++ /dev/null @@ -1,279 +0,0 @@ -//! Licensed to the .NET Foundation under one or more agreements. -//! The .NET Foundation licenses this file to you under the MIT license. -//! This is generated file, see src/native/libs/Browser/rollup.config.defines.js - - -var libNativeBrowser = (function (exports) { - 'use strict'; - - // Licensed to the .NET Foundation under one or more agreements. - // The .NET Foundation licenses this file to you under the MIT license. - let Module; - let runtimeApi; - let Logger = {}; - let Assert = {}; - let JSEngine = {}; - let loaderExports = {}; - let runtimeExports = {}; - let hostExports = {}; - let interopExports = {}; - let nativeBrowserExports = {}; - let dotnetInternals; - function getInternals() { - return dotnetInternals; - } - function setInternals(internal) { - dotnetInternals = internal; - runtimeApi = dotnetInternals.runtimeApi; - Module = dotnetInternals.runtimeApi.Module; - } - function updateAllInternals() { - if (dotnetInternals.updates === undefined) { - dotnetInternals.updates = []; - } - for (const updateImpl of dotnetInternals.updates) { - updateImpl(); - } - } - function updateMyInternals() { - if (Object.keys(loaderExports).length === 0 && dotnetInternals.loaderExportsTable) { - loaderExports = {}; - Logger = {}; - Assert = {}; - JSEngine = {}; - expandLE(dotnetInternals.loaderExportsTable, Logger, Assert, JSEngine, loaderExports); - } - if (Object.keys(runtimeExports).length === 0 && dotnetInternals.runtimeExportsTable) { - runtimeExports = {}; - expandRE(dotnetInternals.runtimeExportsTable, runtimeExports); - } - if (Object.keys(hostExports).length === 0 && dotnetInternals.hostNativeExportsTable) { - hostExports = {}; - expandHE(dotnetInternals.hostNativeExportsTable, hostExports); - } - if (Object.keys(interopExports).length === 0 && dotnetInternals.interopJavaScriptNativeExportsTable) { - interopExports = {}; - expandJSNE(dotnetInternals.interopJavaScriptNativeExportsTable, interopExports); - } - if (Object.keys(nativeBrowserExports).length === 0 && dotnetInternals.nativeBrowserExportsTable) { - nativeBrowserExports = {}; - expandNBE(dotnetInternals.nativeBrowserExportsTable, nativeBrowserExports); - } - } - /** - * Functions below allow our JS modules to exchange internal interfaces by passing tables of functions in known order instead of using string symbols. - * IMPORTANT: If you need to add more functions, make sure that you add them at the end of the table, so that the order of existing functions does not change. - */ - function tabulateLE(logger, assert, loaderExports) { - return [ - logger.info, - logger.warn, - logger.error, - assert.check, - loaderExports.ENVIRONMENT_IS_NODE, - loaderExports.ENVIRONMENT_IS_SHELL, - loaderExports.ENVIRONMENT_IS_WEB, - loaderExports.ENVIRONMENT_IS_WORKER, - loaderExports.ENVIRONMENT_IS_SIDECAR, - loaderExports.browserHostResolveMain, - loaderExports.browserHostRejectMain, - loaderExports.getRunMainPromise, - ]; - } - function expandLE(table, logger, assert, jsEngine, loaderExports) { - const loggerLocal = { - info: table[0], - warn: table[1], - error: table[2], - }; - const assertLocal = { - check: table[3], - }; - const loaderExportsLocal = { - ENVIRONMENT_IS_NODE: table[4], - ENVIRONMENT_IS_SHELL: table[5], - ENVIRONMENT_IS_WEB: table[6], - ENVIRONMENT_IS_WORKER: table[7], - ENVIRONMENT_IS_SIDECAR: table[8], - browserHostResolveMain: table[9], - browserHostRejectMain: table[10], - getRunMainPromise: table[11], - }; - const jsEngineLocal = { - IS_NODE: loaderExportsLocal.ENVIRONMENT_IS_NODE(), - IS_SHELL: loaderExportsLocal.ENVIRONMENT_IS_SHELL(), - IS_WEB: loaderExportsLocal.ENVIRONMENT_IS_WEB(), - IS_WORKER: loaderExportsLocal.ENVIRONMENT_IS_WORKER(), - IS_SIDECAR: loaderExportsLocal.ENVIRONMENT_IS_SIDECAR(), - }; - Object.assign(loaderExports, loaderExportsLocal); - Object.assign(logger, loggerLocal); - Object.assign(assert, assertLocal); - Object.assign(jsEngine, jsEngineLocal); - } - // eslint-disable-next-line @typescript-eslint/no-unused-vars - function tabulateRE(map) { - return []; - } - function expandRE(table, runtime) { - Object.assign(runtime, {}); - } - function tabulateHE(map) { - return [ - map.registerDllBytes, - map.isSharedArrayBuffer, - ]; - } - function expandHE(table, native) { - const nativeLocal = { - registerDllBytes: table[0], - isSharedArrayBuffer: table[1], - }; - Object.assign(native, nativeLocal); - } - // eslint-disable-next-line @typescript-eslint/no-unused-vars - function tabulateJSNE(map) { - return []; - } - function expandJSNE(table, interop) { - const interopLocal = {}; - Object.assign(interop, interopLocal); - } - // eslint-disable-next-line @typescript-eslint/no-unused-vars - function tabulateNBE(map) { - return []; - } - function expandNBE(table, interop) { - const interopLocal = {}; - Object.assign(interop, interopLocal); - } - - // Licensed to the .NET Foundation under one or more agreements. - // The .NET Foundation licenses this file to you under the MIT license. - - var crossModule = /*#__PURE__*/Object.freeze({ - __proto__: null, - get Assert() { return Assert; }, - get JSEngine() { return JSEngine; }, - get Logger() { return Logger; }, - get Module() { return Module; }, - get dotnetInternals() { return dotnetInternals; }, - expandHE: expandHE, - expandJSNE: expandJSNE, - expandLE: expandLE, - expandNBE: expandNBE, - expandRE: expandRE, - getInternals: getInternals, - get hostExports() { return hostExports; }, - get interopExports() { return interopExports; }, - get loaderExports() { return loaderExports; }, - get nativeBrowserExports() { return nativeBrowserExports; }, - get runtimeApi() { return runtimeApi; }, - get runtimeExports() { return runtimeExports; }, - setInternals: setInternals, - tabulateHE: tabulateHE, - tabulateJSNE: tabulateJSNE, - tabulateLE: tabulateLE, - tabulateNBE: tabulateNBE, - tabulateRE: tabulateRE, - updateAllInternals: updateAllInternals, - updateMyInternals: updateMyInternals - }); - - // Licensed to the .NET Foundation under one or more agreements. - // The .NET Foundation licenses this file to you under the MIT license. - function SystemJS_RandomBytes(bufferPtr, bufferLength) { - // batchedQuotaMax is the max number of bytes as specified by the api spec. - // If the byteLength of array is greater than 65536, throw a QuotaExceededError and terminate the algorithm. - // https://www.w3.org/TR/WebCryptoAPI/#Crypto-method-getRandomValues - const batchedQuotaMax = 65536; - if (!globalThis.crypto || !globalThis.crypto.getRandomValues) { - if (!globalThis["cryptoWarnOnce"]) { - Logger.warn("This engine doesn't support crypto.getRandomValues. Please use a modern version or provide polyfill for 'globalThis.crypto.getRandomValues'."); - globalThis["cryptoWarnOnce"] = true; - } - return -1; - } - const memoryView = runtimeApi.localHeapViewU8(); - const targetView = memoryView.subarray(bufferPtr, bufferPtr + bufferLength); - // When threading is enabled, Chrome doesn't want SharedArrayBuffer to be passed to crypto APIs - const needsCopy = hostExports.isSharedArrayBuffer(memoryView.buffer); - const targetBuffer = needsCopy - ? new Uint8Array(bufferLength) - : targetView; - // fill the targetBuffer in batches of batchedQuotaMax - for (let i = 0; i < bufferLength; i += batchedQuotaMax) { - const targetBatch = targetBuffer.subarray(i, i + Math.min(bufferLength - i, batchedQuotaMax)); - globalThis.crypto.getRandomValues(targetBatch); - } - if (needsCopy) { - targetView.set(targetBuffer); - } - return 0; - } - - // Licensed to the .NET Foundation under one or more agreements. - // The .NET Foundation licenses this file to you under the MIT license. - function initialize(internals) { - const nativeBrowserExportsLocal = {}; - setInternals(internals); - internals.nativeBrowserExportsTable = [...tabulateNBE(nativeBrowserExportsLocal)]; - internals.updates.push(updateMyInternals); - updateAllInternals(); - } - - exports.SystemJS_RandomBytes = SystemJS_RandomBytes; - exports.cross = crossModule; - exports.initialize = initialize; - - return exports; - -}); -//! Licensed to the .NET Foundation under one or more agreements. -//! The .NET Foundation licenses this file to you under the MIT license. - -/** - * This is root of **Emscripten library** that would become part of `dotnet.native.js` - * It implements PAL for the VM/runtime. - */ - -(function (exports) { - function libFactory() { - const lib = { - $DOTNET: { - selfInitialize: () => { - if (typeof dotnetInternals !== "undefined") { - DOTNET.dotnetInternals = dotnetInternals; - DOTNET.initialize(dotnetInternals); - } - }, - }, - "$DOTNET__postset": "DOTNET.selfInitialize();", - }; - - // this executes the function at compile time in order to capture exports - const exports = libNativeBrowser({}); - let commonDeps = []; - for (const exportName of Reflect.ownKeys(exports.cross)) { - const name = String(exportName); - if (name === "dotnetInternals") continue; - if (name === "Module") continue; - const emName = "$" + name; - lib[emName] = exports.cross[exportName]; - commonDeps.push(emName); - } - for (const exportName of Reflect.ownKeys(exports)) { - const name = String(exportName); - if (name === "cross") continue; - if (name === "initialize") continue; - lib[name] = exports[name]; - } - lib["$DOTNET__deps"] = commonDeps; - lib.$DOTNET.initialize = exports.initialize; - - autoAddDeps(lib, "$DOTNET"); - addToLibrary(lib); - } - libFactory(); - return exports; -})({}); diff --git a/src/native/libs/System.Native.Browser/native/cross-linked.ts b/src/native/libs/System.Native.Browser/native/cross-linked.ts new file mode 100644 index 00000000000000..c890d08d47e3e1 --- /dev/null +++ b/src/native/libs/System.Native.Browser/native/cross-linked.ts @@ -0,0 +1,22 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +import { + Assert, Logger, Module, + netInternals, netLoaderExports, netPublicApi, netNativeBrowserExports, netRuntimeExports, netJSEngine, netBrowserHostExports, netInteropJSExports, + netTabulateNBE, netTabulateHE, netTabulateJSNE, netTabulateLE, netTabulateRE, + getInternals, netSetInternals, netUpdateAllInternals, netUpdateModuleInternals, +} from "../cross-module"; + +import { } from "../../Common/JavaScript/cross-linked"; + +// this dummy function helps rollup to keep functions below from trimming +// we are installing them into emscripten closure +export function crossLink() { + return [ + Assert, Logger, Module, + netInternals, netLoaderExports, netPublicApi, netNativeBrowserExports, netRuntimeExports, netJSEngine, netBrowserHostExports, netInteropJSExports, + getInternals, netSetInternals, netUpdateAllInternals, netUpdateModuleInternals, + netTabulateHE, netTabulateJSNE, netTabulateLE, netTabulateNBE, netTabulateRE + ]; +} diff --git a/src/native/libs/System.Native.Browser/native/crypto.ts b/src/native/libs/System.Native.Browser/native/crypto.ts new file mode 100644 index 00000000000000..3ac6b00e54853d --- /dev/null +++ b/src/native/libs/System.Native.Browser/native/crypto.ts @@ -0,0 +1,40 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +import { netPublicApi, Logger, netBrowserHostExports } from "../cross-module"; + +export function SystemJS_RandomBytes(bufferPtr: number, bufferLength: number): number { + // batchedQuotaMax is the max number of bytes as specified by the api spec. + // If the byteLength of array is greater than 65536, throw a QuotaExceededError and terminate the algorithm. + // https://www.w3.org/TR/WebCryptoAPI/#Crypto-method-getRandomValues + const batchedQuotaMax = 65536; + + if (!globalThis.crypto || !globalThis.crypto.getRandomValues) { + if (!(globalThis as any)["cryptoWarnOnce"]) { + Logger.warn("This engine doesn't support crypto.getRandomValues. Please use a modern version or provide polyfill for 'globalThis.crypto.getRandomValues'."); + (globalThis as any)["cryptoWarnOnce"] = true; + } + return -1; + } + + const memoryView = netPublicApi.localHeapViewU8(); + const targetView = memoryView.subarray(bufferPtr, bufferPtr + bufferLength); + + // When threading is enabled, Chrome doesn't want SharedArrayBuffer to be passed to crypto APIs + const needsCopy = netBrowserHostExports.isSharedArrayBuffer(memoryView.buffer); + const targetBuffer = needsCopy + ? new Uint8Array(bufferLength) + : targetView; + + // fill the targetBuffer in batches of batchedQuotaMax + for (let i = 0; i < bufferLength; i += batchedQuotaMax) { + const targetBatch = targetBuffer.subarray(i, i + Math.min(bufferLength - i, batchedQuotaMax)); + globalThis.crypto.getRandomValues(targetBatch); + } + + if (needsCopy) { + targetView.set(targetBuffer); + } + + return 0; +} diff --git a/src/native/libs/System.Native.Browser/native/index.ts b/src/native/libs/System.Native.Browser/native/index.ts new file mode 100644 index 00000000000000..ef4f9fbb941895 --- /dev/null +++ b/src/native/libs/System.Native.Browser/native/index.ts @@ -0,0 +1,19 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +import type { InternalExchange, NativeBrowserExports } from "../types"; + +export { SystemJS_RandomBytes } from "./crypto"; + +export function netInitializeModule(internals: InternalExchange): void { + const nativeBrowserExportsLocal: NativeBrowserExports = { + }; + netSetInternals(internals); + internals.netNativeBrowserExportsTable = [...netTabulateNBE(nativeBrowserExportsLocal)]; + internals.netInternalUpdates.push(netUpdateModuleInternals); + netUpdateAllInternals(); +} + + +// see also `reserved` in `rollup.config.defines.js` +export * as cross from "../cross-module"; diff --git a/src/native/libs/System.Native.Browser/types.ts b/src/native/libs/System.Native.Browser/types.ts new file mode 100644 index 00000000000000..c8fb6fdaccc4d2 --- /dev/null +++ b/src/native/libs/System.Native.Browser/types.ts @@ -0,0 +1,5 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +export * from "../Common/JavaScript/types"; + diff --git a/src/native/libs/System.Runtime.InteropServices.JavaScript.Native/dotnet.runtime.js b/src/native/libs/System.Runtime.InteropServices.JavaScript.Native/dotnet.runtime.js deleted file mode 100644 index eb2e761bf9984b..00000000000000 --- a/src/native/libs/System.Runtime.InteropServices.JavaScript.Native/dotnet.runtime.js +++ /dev/null @@ -1,177 +0,0 @@ -//! Licensed to the .NET Foundation under one or more agreements. -//! The .NET Foundation licenses this file to you under the MIT license. -//! This is generated file, see src/native/libs/Browser/rollup.config.defines.js - - -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -let Module; -let runtimeApi; -let Logger = {}; -let Assert = {}; -let JSEngine = {}; -let loaderExports = {}; -let runtimeExports = {}; -let hostExports = {}; -let interopExports = {}; -let nativeBrowserExports = {}; -let dotnetInternals; -function getInternals() { - return dotnetInternals; -} -function setInternals(internal) { - dotnetInternals = internal; - runtimeApi = dotnetInternals.runtimeApi; - Module = dotnetInternals.runtimeApi.Module; -} -function updateAllInternals() { - if (dotnetInternals.updates === undefined) { - dotnetInternals.updates = []; - } - for (const updateImpl of dotnetInternals.updates) { - updateImpl(); - } -} -function updateMyInternals() { - if (Object.keys(loaderExports).length === 0 && dotnetInternals.loaderExportsTable) { - loaderExports = {}; - Logger = {}; - Assert = {}; - JSEngine = {}; - expandLE(dotnetInternals.loaderExportsTable, Logger, Assert, JSEngine, loaderExports); - } - if (Object.keys(runtimeExports).length === 0 && dotnetInternals.runtimeExportsTable) { - runtimeExports = {}; - expandRE(dotnetInternals.runtimeExportsTable, runtimeExports); - } - if (Object.keys(hostExports).length === 0 && dotnetInternals.hostNativeExportsTable) { - hostExports = {}; - expandHE(dotnetInternals.hostNativeExportsTable, hostExports); - } - if (Object.keys(interopExports).length === 0 && dotnetInternals.interopJavaScriptNativeExportsTable) { - interopExports = {}; - expandJSNE(dotnetInternals.interopJavaScriptNativeExportsTable, interopExports); - } - if (Object.keys(nativeBrowserExports).length === 0 && dotnetInternals.nativeBrowserExportsTable) { - nativeBrowserExports = {}; - expandNBE(dotnetInternals.nativeBrowserExportsTable, nativeBrowserExports); - } -} -/** - * Functions below allow our JS modules to exchange internal interfaces by passing tables of functions in known order instead of using string symbols. - * IMPORTANT: If you need to add more functions, make sure that you add them at the end of the table, so that the order of existing functions does not change. - */ -function tabulateLE(logger, assert, loaderExports) { - return [ - logger.info, - logger.warn, - logger.error, - assert.check, - loaderExports.ENVIRONMENT_IS_NODE, - loaderExports.ENVIRONMENT_IS_SHELL, - loaderExports.ENVIRONMENT_IS_WEB, - loaderExports.ENVIRONMENT_IS_WORKER, - loaderExports.ENVIRONMENT_IS_SIDECAR, - loaderExports.browserHostResolveMain, - loaderExports.browserHostRejectMain, - loaderExports.getRunMainPromise, - ]; -} -function expandLE(table, logger, assert, jsEngine, loaderExports) { - const loggerLocal = { - info: table[0], - warn: table[1], - error: table[2], - }; - const assertLocal = { - check: table[3], - }; - const loaderExportsLocal = { - ENVIRONMENT_IS_NODE: table[4], - ENVIRONMENT_IS_SHELL: table[5], - ENVIRONMENT_IS_WEB: table[6], - ENVIRONMENT_IS_WORKER: table[7], - ENVIRONMENT_IS_SIDECAR: table[8], - browserHostResolveMain: table[9], - browserHostRejectMain: table[10], - getRunMainPromise: table[11], - }; - const jsEngineLocal = { - IS_NODE: loaderExportsLocal.ENVIRONMENT_IS_NODE(), - IS_SHELL: loaderExportsLocal.ENVIRONMENT_IS_SHELL(), - IS_WEB: loaderExportsLocal.ENVIRONMENT_IS_WEB(), - IS_WORKER: loaderExportsLocal.ENVIRONMENT_IS_WORKER(), - IS_SIDECAR: loaderExportsLocal.ENVIRONMENT_IS_SIDECAR(), - }; - Object.assign(loaderExports, loaderExportsLocal); - Object.assign(logger, loggerLocal); - Object.assign(assert, assertLocal); - Object.assign(jsEngine, jsEngineLocal); -} -// eslint-disable-next-line @typescript-eslint/no-unused-vars -function tabulateRE(map) { - return []; -} -function expandRE(table, runtime) { - Object.assign(runtime, {}); -} -function tabulateHE(map) { - return [ - map.registerDllBytes, - map.isSharedArrayBuffer, - ]; -} -function expandHE(table, native) { - const nativeLocal = { - registerDllBytes: table[0], - isSharedArrayBuffer: table[1], - }; - Object.assign(native, nativeLocal); -} -// eslint-disable-next-line @typescript-eslint/no-unused-vars -function tabulateJSNE(map) { - return []; -} -function expandJSNE(table, interop) { - const interopLocal = {}; - Object.assign(interop, interopLocal); -} -// eslint-disable-next-line @typescript-eslint/no-unused-vars -function tabulateNBE(map) { - return []; -} -function expandNBE(table, interop) { - const interopLocal = {}; - Object.assign(interop, interopLocal); -} - -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -function initialize(internals) { - const runtimeApiLocal = { - getAssemblyExports, - setModuleImports, - }; - const runtimeExportsLocal = {}; - setInternals(internals); - Object.assign(internals.runtimeApi, runtimeApiLocal); - internals.runtimeExportsTable = [...tabulateRE(runtimeExportsLocal)]; - internals.updates.push(updateMyInternals); - updateAllInternals(); -} -// eslint-disable-next-line @typescript-eslint/no-unused-vars -async function getAssemblyExports(assemblyName) { - throw new Error("Not implemented"); -} -// eslint-disable-next-line @typescript-eslint/no-unused-vars -function setModuleImports(moduleName, moduleImports) { - throw new Error("Not implemented"); -} - -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -export { initialize }; diff --git a/src/native/libs/System.Runtime.InteropServices.JavaScript.Native/dotnet.runtime.ts b/src/native/libs/System.Runtime.InteropServices.JavaScript.Native/dotnet.runtime.ts new file mode 100644 index 00000000000000..bb92a95e41edc2 --- /dev/null +++ b/src/native/libs/System.Runtime.InteropServices.JavaScript.Native/dotnet.runtime.ts @@ -0,0 +1,4 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +export { netInitializeModule } from "./interop"; diff --git a/src/native/libs/System.Runtime.InteropServices.JavaScript.Native/interop/cross-module.ts b/src/native/libs/System.Runtime.InteropServices.JavaScript.Native/interop/cross-module.ts new file mode 100644 index 00000000000000..8e72db213b830d --- /dev/null +++ b/src/native/libs/System.Runtime.InteropServices.JavaScript.Native/interop/cross-module.ts @@ -0,0 +1,4 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +export * from "../../Common/JavaScript/cross-module"; diff --git a/src/native/libs/System.Runtime.InteropServices.JavaScript.Native/interop/index.ts b/src/native/libs/System.Runtime.InteropServices.JavaScript.Native/interop/index.ts new file mode 100644 index 00000000000000..0ebe68f4dd510b --- /dev/null +++ b/src/native/libs/System.Runtime.InteropServices.JavaScript.Native/interop/index.ts @@ -0,0 +1,30 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +import type { InternalExchange, RuntimeAPI, RuntimeExports } from "./types"; +import { netSetInternals, netUpdateAllInternals, netUpdateModuleInternals, netTabulateRE } from "./cross-module"; + +export function netInitializeModule(internals: InternalExchange): void { + const runtimeApiLocal: Partial = { + getAssemblyExports, + setModuleImports, + }; + const runtimeExportsLocal: RuntimeExports = { + }; + netSetInternals(internals); + Object.assign(internals.netPublicApi, runtimeApiLocal); + internals.netRuntimeExportsTable = [...netTabulateRE(runtimeExportsLocal)]; + internals.netInternalUpdates.push(netUpdateModuleInternals); + netUpdateAllInternals(); +} + +// eslint-disable-next-line @typescript-eslint/no-unused-vars +export async function getAssemblyExports(assemblyName: string): Promise { + throw new Error("Not implemented"); +} + +// eslint-disable-next-line @typescript-eslint/no-unused-vars +export function setModuleImports(moduleName: string, moduleImports: any): void { + throw new Error("Not implemented"); +} + diff --git a/src/native/libs/System.Runtime.InteropServices.JavaScript.Native/interop/types.ts b/src/native/libs/System.Runtime.InteropServices.JavaScript.Native/interop/types.ts new file mode 100644 index 00000000000000..95021536b19918 --- /dev/null +++ b/src/native/libs/System.Runtime.InteropServices.JavaScript.Native/interop/types.ts @@ -0,0 +1,22 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +import { NativePointer } from "../types"; + +export interface JSMarshalerArguments extends NativePointer { + __brand: "JSMarshalerArguments" +} + +export interface JSFunctionSignature extends NativePointer { + __brand: "JSFunctionSignatures" +} + +export interface JSMarshalerType extends NativePointer { + __brand: "JSMarshalerType" +} + +export interface JSMarshalerArgument extends NativePointer { + __brand: "JSMarshalerArgument" +} + +export * from "../types"; diff --git a/src/native/libs/System.Runtime.InteropServices.JavaScript.Native/libSystem.Runtime.InteropServices.JavaScript.Native.footer.js b/src/native/libs/System.Runtime.InteropServices.JavaScript.Native/libSystem.Runtime.InteropServices.JavaScript.Native.footer.js new file mode 100644 index 00000000000000..1b34c72bd50084 --- /dev/null +++ b/src/native/libs/System.Runtime.InteropServices.JavaScript.Native/libSystem.Runtime.InteropServices.JavaScript.Native.footer.js @@ -0,0 +1,46 @@ +//! Licensed to the .NET Foundation under one or more agreements. +//! The .NET Foundation licenses this file to you under the MIT license. + +/** + * This is root of **Emscripten library** that would become part of `dotnet.native.js` + * It implements interop between JS and .NET + */ + +(function (exports) { + function libFactory() { + // this executes the function at link time in order to capture exports + // this is what Emscripten does for linking JS libraries + // https://emscripten.org/docs/porting/connecting_cpp_and_javascript/Interacting-with-code.html#javascript-limits-in-library-files + // it would execute the code at link time and call .toString() on functions to move it to the final output + // this process would loose any closure references, unless they are passed to `__deps` and also explicitly given to the linker + // JS name mangling and minification also applies, see src\native\rollup.config.defines.js and `reservedRx` there + const exports = {}; + libInteropJavaScriptNative(exports); + + let commonDeps = ["$DOTNET"]; + const lib = { + $DOTNET_INTEROP: { + selfInitialize: () => { + if (typeof netInternals !== "undefined") { + DOTNET_INTEROP.netInternals = netInternals; + DOTNET_INTEROP.netInitializeModule(netInternals); + } + }, + netInitializeModule: exports.netInitializeModule, + }, + $DOTNET_INTEROP__postset: "DOTNET_INTEROP.selfInitialize()", + $DOTNET_INTEROP__deps: commonDeps, + }; + + for (const exportName of Reflect.ownKeys(exports)) { + const name = String(exportName); + if (name === "netInitializeModule") continue; + lib[name] = exports[name]; + } + + autoAddDeps(lib, "$DOTNET_INTEROP"); + addToLibrary(lib); + } + libFactory(); + return exports; +})({}); diff --git a/src/native/libs/System.Runtime.InteropServices.JavaScript.Native/libSystem.Runtime.InteropServices.JavaScript.Native.js b/src/native/libs/System.Runtime.InteropServices.JavaScript.Native/libSystem.Runtime.InteropServices.JavaScript.Native.js deleted file mode 100644 index 84efa97500a1ec..00000000000000 --- a/src/native/libs/System.Runtime.InteropServices.JavaScript.Native/libSystem.Runtime.InteropServices.JavaScript.Native.js +++ /dev/null @@ -1,253 +0,0 @@ -//! Licensed to the .NET Foundation under one or more agreements. -//! The .NET Foundation licenses this file to you under the MIT license. -//! This is generated file, see src/native/libs/Browser/rollup.config.defines.js - - -var libInteropJavaScriptNative = (function (exports) { - 'use strict'; - - // Licensed to the .NET Foundation under one or more agreements. - // The .NET Foundation licenses this file to you under the MIT license. - let Module; - let runtimeApi; - let Logger = {}; - let Assert = {}; - let JSEngine = {}; - let loaderExports = {}; - let runtimeExports = {}; - let hostExports = {}; - let interopExports = {}; - let nativeBrowserExports = {}; - let dotnetInternals; - function getInternals() { - return dotnetInternals; - } - function setInternals(internal) { - dotnetInternals = internal; - runtimeApi = dotnetInternals.runtimeApi; - Module = dotnetInternals.runtimeApi.Module; - } - function updateAllInternals() { - if (dotnetInternals.updates === undefined) { - dotnetInternals.updates = []; - } - for (const updateImpl of dotnetInternals.updates) { - updateImpl(); - } - } - function updateMyInternals() { - if (Object.keys(loaderExports).length === 0 && dotnetInternals.loaderExportsTable) { - loaderExports = {}; - Logger = {}; - Assert = {}; - JSEngine = {}; - expandLE(dotnetInternals.loaderExportsTable, Logger, Assert, JSEngine, loaderExports); - } - if (Object.keys(runtimeExports).length === 0 && dotnetInternals.runtimeExportsTable) { - runtimeExports = {}; - expandRE(dotnetInternals.runtimeExportsTable, runtimeExports); - } - if (Object.keys(hostExports).length === 0 && dotnetInternals.hostNativeExportsTable) { - hostExports = {}; - expandHE(dotnetInternals.hostNativeExportsTable, hostExports); - } - if (Object.keys(interopExports).length === 0 && dotnetInternals.interopJavaScriptNativeExportsTable) { - interopExports = {}; - expandJSNE(dotnetInternals.interopJavaScriptNativeExportsTable, interopExports); - } - if (Object.keys(nativeBrowserExports).length === 0 && dotnetInternals.nativeBrowserExportsTable) { - nativeBrowserExports = {}; - expandNBE(dotnetInternals.nativeBrowserExportsTable, nativeBrowserExports); - } - } - /** - * Functions below allow our JS modules to exchange internal interfaces by passing tables of functions in known order instead of using string symbols. - * IMPORTANT: If you need to add more functions, make sure that you add them at the end of the table, so that the order of existing functions does not change. - */ - function tabulateLE(logger, assert, loaderExports) { - return [ - logger.info, - logger.warn, - logger.error, - assert.check, - loaderExports.ENVIRONMENT_IS_NODE, - loaderExports.ENVIRONMENT_IS_SHELL, - loaderExports.ENVIRONMENT_IS_WEB, - loaderExports.ENVIRONMENT_IS_WORKER, - loaderExports.ENVIRONMENT_IS_SIDECAR, - loaderExports.browserHostResolveMain, - loaderExports.browserHostRejectMain, - loaderExports.getRunMainPromise, - ]; - } - function expandLE(table, logger, assert, jsEngine, loaderExports) { - const loggerLocal = { - info: table[0], - warn: table[1], - error: table[2], - }; - const assertLocal = { - check: table[3], - }; - const loaderExportsLocal = { - ENVIRONMENT_IS_NODE: table[4], - ENVIRONMENT_IS_SHELL: table[5], - ENVIRONMENT_IS_WEB: table[6], - ENVIRONMENT_IS_WORKER: table[7], - ENVIRONMENT_IS_SIDECAR: table[8], - browserHostResolveMain: table[9], - browserHostRejectMain: table[10], - getRunMainPromise: table[11], - }; - const jsEngineLocal = { - IS_NODE: loaderExportsLocal.ENVIRONMENT_IS_NODE(), - IS_SHELL: loaderExportsLocal.ENVIRONMENT_IS_SHELL(), - IS_WEB: loaderExportsLocal.ENVIRONMENT_IS_WEB(), - IS_WORKER: loaderExportsLocal.ENVIRONMENT_IS_WORKER(), - IS_SIDECAR: loaderExportsLocal.ENVIRONMENT_IS_SIDECAR(), - }; - Object.assign(loaderExports, loaderExportsLocal); - Object.assign(logger, loggerLocal); - Object.assign(assert, assertLocal); - Object.assign(jsEngine, jsEngineLocal); - } - // eslint-disable-next-line @typescript-eslint/no-unused-vars - function tabulateRE(map) { - return []; - } - function expandRE(table, runtime) { - Object.assign(runtime, {}); - } - function tabulateHE(map) { - return [ - map.registerDllBytes, - map.isSharedArrayBuffer, - ]; - } - function expandHE(table, native) { - const nativeLocal = { - registerDllBytes: table[0], - isSharedArrayBuffer: table[1], - }; - Object.assign(native, nativeLocal); - } - // eslint-disable-next-line @typescript-eslint/no-unused-vars - function tabulateJSNE(map) { - return []; - } - function expandJSNE(table, interop) { - const interopLocal = {}; - Object.assign(interop, interopLocal); - } - // eslint-disable-next-line @typescript-eslint/no-unused-vars - function tabulateNBE(map) { - return []; - } - function expandNBE(table, interop) { - const interopLocal = {}; - Object.assign(interop, interopLocal); - } - - // Licensed to the .NET Foundation under one or more agreements. - // The .NET Foundation licenses this file to you under the MIT license. - - var crossModule = /*#__PURE__*/Object.freeze({ - __proto__: null, - get Assert() { return Assert; }, - get JSEngine() { return JSEngine; }, - get Logger() { return Logger; }, - get Module() { return Module; }, - get dotnetInternals() { return dotnetInternals; }, - expandHE: expandHE, - expandJSNE: expandJSNE, - expandLE: expandLE, - expandNBE: expandNBE, - expandRE: expandRE, - getInternals: getInternals, - get hostExports() { return hostExports; }, - get interopExports() { return interopExports; }, - get loaderExports() { return loaderExports; }, - get nativeBrowserExports() { return nativeBrowserExports; }, - get runtimeApi() { return runtimeApi; }, - get runtimeExports() { return runtimeExports; }, - setInternals: setInternals, - tabulateHE: tabulateHE, - tabulateJSNE: tabulateJSNE, - tabulateLE: tabulateLE, - tabulateNBE: tabulateNBE, - tabulateRE: tabulateRE, - updateAllInternals: updateAllInternals, - updateMyInternals: updateMyInternals - }); - - // Licensed to the .NET Foundation under one or more agreements. - // The .NET Foundation licenses this file to you under the MIT license. - // eslint-disable-next-line @typescript-eslint/no-unused-vars - function SystemInteropJS_InvokeJSImportST(function_handle, args) { - // WASMTODO implementation - Logger.error("SystemInteropJS_InvokeJSImportST called"); - return -1; - } - function initialize(internals) { - const interopJavaScriptNativeExportsLocal = {}; - setInternals(internals); - internals.interopJavaScriptNativeExportsTable = [...tabulateJSNE(interopJavaScriptNativeExportsLocal)]; - internals.updates.push(updateMyInternals); - updateAllInternals(); - } - - exports.SystemInteropJS_InvokeJSImportST = SystemInteropJS_InvokeJSImportST; - exports.cross = crossModule; - exports.initialize = initialize; - - return exports; - -}); -//! Licensed to the .NET Foundation under one or more agreements. -//! The .NET Foundation licenses this file to you under the MIT license. - -/** - * This is root of **Emscripten library** that would become part of `dotnet.native.js` - * It implements interop between JS and .NET - */ - -(function (exports) { - function libFactory() { - const lib = { - $DOTNET_INTEROP: { - selfInitialize: () => { - if (typeof dotnetInternals !== "undefined") { - DOTNET_INTEROP.dotnetInternals = dotnetInternals; - DOTNET_INTEROP.initialize(dotnetInternals); - } - }, - }, - "$DOTNET_INTEROP__postset": "DOTNET_INTEROP.selfInitialize();", - }; - - // this executes the function at compile time in order to capture exports - const exports = libInteropJavaScriptNative({}); - let commonDeps = ["$DOTNET"]; - for (const exportName of Reflect.ownKeys(exports.cross)) { - const name = String(exportName); - if (name === "dotnetInternals") continue; - if (name === "Module") continue; - const emName = "$" + name; - commonDeps.push(emName); - } - for (const exportName of Reflect.ownKeys(exports)) { - const name = String(exportName); - if (name === "cross") continue; - if (name === "initialize") continue; - lib[name] = exports[name]; - } - - lib["$DOTNET_INTEROP__deps"] = commonDeps; - lib.$DOTNET_INTEROP.initialize = exports.initialize; - - autoAddDeps(lib, "$DOTNET_INTEROP"); - addToLibrary(lib); - } - libFactory(); - return exports; -})({}); diff --git a/src/native/libs/System.Runtime.InteropServices.JavaScript.Native/native/cross-linked.ts b/src/native/libs/System.Runtime.InteropServices.JavaScript.Native/native/cross-linked.ts new file mode 100644 index 00000000000000..ea10f4707c6a6c --- /dev/null +++ b/src/native/libs/System.Runtime.InteropServices.JavaScript.Native/native/cross-linked.ts @@ -0,0 +1,5 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +import { } from "../../Common/JavaScript/cross-linked"; + diff --git a/src/native/libs/System.Runtime.InteropServices.JavaScript.Native/native/index.ts b/src/native/libs/System.Runtime.InteropServices.JavaScript.Native/native/index.ts new file mode 100644 index 00000000000000..07874f91b26633 --- /dev/null +++ b/src/native/libs/System.Runtime.InteropServices.JavaScript.Native/native/index.ts @@ -0,0 +1,21 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +import type { InternalExchange, InteropJavaScriptNativeExports, JSFnHandle, JSMarshalerArguments } from "../interop/types"; +import { } from "./cross-linked"; // ensure ambient symbols are declared + +// eslint-disable-next-line @typescript-eslint/no-unused-vars +export function SystemInteropJS_InvokeJSImportST(function_handle: JSFnHandle, args: JSMarshalerArguments) { + // WASM-TODO implementation + Logger.error("SystemInteropJS_InvokeJSImportST called"); + return - 1; +} + +export function netInitializeModule(internals: InternalExchange): void { + const interopJavaScriptNativeExportsLocal: InteropJavaScriptNativeExports = { + }; + netSetInternals(internals); + internals.netInteropJSExportsTable = [...netTabulateJSNE(interopJavaScriptNativeExportsLocal)]; + internals.netInternalUpdates.push(netUpdateModuleInternals); + netUpdateAllInternals(); +} diff --git a/src/native/libs/System.Runtime.InteropServices.JavaScript.Native/types.ts b/src/native/libs/System.Runtime.InteropServices.JavaScript.Native/types.ts new file mode 100644 index 00000000000000..3ff5080c66dfd1 --- /dev/null +++ b/src/native/libs/System.Runtime.InteropServices.JavaScript.Native/types.ts @@ -0,0 +1,4 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +export * from "../Common/JavaScript/types"; diff --git a/src/native/package-lock.json b/src/native/package-lock.json index 675f79827e3614..32399d8ed4d1d7 100644 --- a/src/native/package-lock.json +++ b/src/native/package-lock.json @@ -9,175 +9,77 @@ "version": "1.0.0", "license": "MIT", "dependencies": { - "wasm-feature-detect": "1.6.1" + "wasm-feature-detect": "1.8.0" }, "devDependencies": { - "@rollup/plugin-node-resolve": "15.2.3", + "@rollup/plugin-node-resolve": "16.0.1", "@rollup/plugin-terser": "0.4.4", - "@rollup/plugin-typescript": "11.1.6", + "@rollup/plugin-typescript": "12.1.4", "@rollup/plugin-virtual": "3.0.2", - "@types/node": "^24.5.2", - "@typescript-eslint/eslint-plugin": "5.59.1", - "@typescript-eslint/parser": "5.59.1", - "eslint": "8.44.0", - "fast-glob": "3.3.2", + "@types/node": "24.5.2", + "@typescript-eslint/eslint-plugin": "6.21.0", + "@typescript-eslint/parser": "6.21.0", + "eslint": "8.57.0", + "fast-glob": "3.3.3", "git-commit-info": "2.0.2", - "magic-string": "0.30.10", - "rollup": "4.34.9", - "rollup-plugin-dts": "6.1.1", - "terser": "5.31.1", - "tslib": "2.6.3", - "typescript": "5.4.5" + "magic-string": "0.30.19", + "rollup": "4.52.2", + "rollup-plugin-dts": "6.2.3", + "terser": "5.44.0", + "tslib": "2.8.1", + "typescript": "5.9.2" } }, "node_modules/@babel/code-frame": { - "version": "7.24.7", - "resolved": "https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet-public-npm/npm/registry/@babel/code-frame/-/code-frame-7.24.7.tgz", - "integrity": "sha1-iC/Z4J6O4yTklr0EBAHG8EbvRGU=", + "version": "7.27.1", + "resolved": "https://registry.npmjs.org/@babel/code-frame/-/code-frame-7.27.1.tgz", + "integrity": "sha512-cjQ7ZlQ0Mv3b47hABuTevyTuYN4i+loJKGeV9flcCgIK37cCXRh+L1bd3iBHlynerhQ7BhCkn2BPbQUL+rGqFg==", "dev": true, "license": "MIT", "optional": true, "dependencies": { - "@babel/highlight": "^7.24.7", - "picocolors": "^1.0.0" + "@babel/helper-validator-identifier": "^7.27.1", + "js-tokens": "^4.0.0", + "picocolors": "^1.1.1" }, "engines": { "node": ">=6.9.0" } }, "node_modules/@babel/helper-validator-identifier": { - "version": "7.24.7", - "resolved": "https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet-public-npm/npm/registry/@babel/helper-validator-identifier/-/helper-validator-identifier-7.24.7.tgz", - "integrity": "sha1-dbiJz6+eNcKq9Czw1yyOkXGSUds=", - "dev": true, - "license": "MIT", - "optional": true, - "engines": { - "node": ">=6.9.0" - } - }, - "node_modules/@babel/highlight": { - "version": "7.24.7", - "resolved": "https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet-public-npm/npm/registry/@babel/highlight/-/highlight-7.24.7.tgz", - "integrity": "sha1-oFqx3xNLKGVYquDtQebF9zG/QJ0=", + "version": "7.27.1", + "resolved": "https://registry.npmjs.org/@babel/helper-validator-identifier/-/helper-validator-identifier-7.27.1.tgz", + "integrity": "sha512-D2hP9eA+Sqx1kBZgzxZh0y1trbuU+JoDkiEwqhQ36nodYqJwyEIhPSdMNd7lOm/4io72luTPWH20Yda0xOuUow==", "dev": true, "license": "MIT", "optional": true, - "dependencies": { - "@babel/helper-validator-identifier": "^7.24.7", - "chalk": "^2.4.2", - "js-tokens": "^4.0.0", - "picocolors": "^1.0.0" - }, "engines": { "node": ">=6.9.0" } }, - "node_modules/@babel/highlight/node_modules/ansi-styles": { - "version": "3.2.1", - "resolved": "https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet-public-npm/npm/registry/ansi-styles/-/ansi-styles-3.2.1.tgz", - "integrity": "sha1-QfuyAkPlCxK+DwS43tvwdSDOhB0=", - "dev": true, - "license": "MIT", - "optional": true, - "dependencies": { - "color-convert": "^1.9.0" - }, - "engines": { - "node": ">=4" - } - }, - "node_modules/@babel/highlight/node_modules/chalk": { - "version": "2.4.2", - "resolved": "https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet-public-npm/npm/registry/chalk/-/chalk-2.4.2.tgz", - "integrity": "sha1-zUJUFnelQzPPVBpJEIwUMrRMlCQ=", - "dev": true, - "license": "MIT", - "optional": true, - "dependencies": { - "ansi-styles": "^3.2.1", - "escape-string-regexp": "^1.0.5", - "supports-color": "^5.3.0" - }, - "engines": { - "node": ">=4" - } - }, - "node_modules/@babel/highlight/node_modules/color-convert": { - "version": "1.9.3", - "resolved": "https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet-public-npm/npm/registry/color-convert/-/color-convert-1.9.3.tgz", - "integrity": "sha1-u3GFBpDh8TZWfeYp0tVHHe2kweg=", - "dev": true, - "license": "MIT", - "optional": true, - "dependencies": { - "color-name": "1.1.3" - } - }, - "node_modules/@babel/highlight/node_modules/color-name": { - "version": "1.1.3", - "resolved": "https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet-public-npm/npm/registry/color-name/-/color-name-1.1.3.tgz", - "integrity": "sha1-p9BVi9icQveV3UIyj3QIMcpTvCU=", - "dev": true, - "license": "MIT", - "optional": true - }, - "node_modules/@babel/highlight/node_modules/escape-string-regexp": { - "version": "1.0.5", - "resolved": "https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet-public-npm/npm/registry/escape-string-regexp/-/escape-string-regexp-1.0.5.tgz", - "integrity": "sha1-G2HAViGQqN/2rjuyzwIAyhMLhtQ=", - "dev": true, - "license": "MIT", - "optional": true, - "engines": { - "node": ">=0.8.0" - } - }, - "node_modules/@babel/highlight/node_modules/has-flag": { - "version": "3.0.0", - "resolved": "https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet-public-npm/npm/registry/has-flag/-/has-flag-3.0.0.tgz", - "integrity": "sha1-tdRU3CGZriJWmfNGfloH87lVuv0=", - "dev": true, - "license": "MIT", - "optional": true, - "engines": { - "node": ">=4" - } - }, - "node_modules/@babel/highlight/node_modules/supports-color": { - "version": "5.5.0", - "resolved": "https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet-public-npm/npm/registry/supports-color/-/supports-color-5.5.0.tgz", - "integrity": "sha1-4uaaRKyHcveKHsCzW2id9lMO/I8=", - "dev": true, - "license": "MIT", - "optional": true, - "dependencies": { - "has-flag": "^3.0.0" - }, - "engines": { - "node": ">=4" - } - }, "node_modules/@eslint-community/eslint-utils": { - "version": "4.4.0", - "resolved": "https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet-public-npm/npm/registry/@eslint-community/eslint-utils/-/eslint-utils-4.4.0.tgz", - "integrity": "sha1-ojUU6Pua8SadX3eIqlVnmNYca1k=", + "version": "4.9.0", + "resolved": "https://registry.npmjs.org/@eslint-community/eslint-utils/-/eslint-utils-4.9.0.tgz", + "integrity": "sha512-ayVFHdtZ+hsq1t2Dy24wCmGXGe4q9Gu3smhLYALJrr473ZH27MsnSL+LKUlimp4BWJqMDMLmPpx/Q9R3OAlL4g==", "dev": true, "license": "MIT", "dependencies": { - "eslint-visitor-keys": "^3.3.0" + "eslint-visitor-keys": "^3.4.3" }, "engines": { "node": "^12.22.0 || ^14.17.0 || >=16.0.0" }, + "funding": { + "url": "https://opencollective.com/eslint" + }, "peerDependencies": { "eslint": "^6.0.0 || ^7.0.0 || >=8.0.0" } }, "node_modules/@eslint-community/regexpp": { - "version": "4.10.1", - "resolved": "https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet-public-npm/npm/registry/@eslint-community/regexpp/-/regexpp-4.10.1.tgz", - "integrity": "sha1-NhRh5cs4Rdh05hcxwRz+3WZNg6A=", + "version": "4.12.1", + "resolved": "https://registry.npmjs.org/@eslint-community/regexpp/-/regexpp-4.12.1.tgz", + "integrity": "sha512-CCZCDJuduB9OUkFkY2IgppNZMi2lBQgD2qzwXkEia16cge2pijY/aXi96CJMquDMn3nJdlPV1A5KrJEXwfLNzQ==", "dev": true, "license": "MIT", "engines": { @@ -186,8 +88,8 @@ }, "node_modules/@eslint/eslintrc": { "version": "2.1.4", - "resolved": "https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet-public-npm/npm/registry/@eslint/eslintrc/-/eslintrc-2.1.4.tgz", - "integrity": "sha1-OIomnw8lwbatwxe1osVXFIlMcK0=", + "resolved": "https://registry.npmjs.org/@eslint/eslintrc/-/eslintrc-2.1.4.tgz", + "integrity": "sha512-269Z39MS6wVJtsoUl10L60WdkhJVdPG24Q4eZTH3nnF6lpvSShEK3wQjDX9JRWAUPvPh7COouPpU9IrqaZFvtQ==", "dev": true, "license": "MIT", "dependencies": { @@ -208,26 +110,34 @@ "url": "https://opencollective.com/eslint" } }, - "node_modules/@eslint/eslintrc/node_modules/globals": { - "version": "13.24.0", - "resolved": "https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet-public-npm/npm/registry/globals/-/globals-13.24.0.tgz", - "integrity": "sha1-hDKhnXjODB6DOUnDats0VAC7EXE=", + "node_modules/@eslint/eslintrc/node_modules/brace-expansion": { + "version": "1.1.12", + "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.12.tgz", + "integrity": "sha512-9T9UjW3r0UW5c1Q7GTwllptXwhvYmEzFhzMfZ9H7FQWt+uZePjZPjBP/W1ZEyZ1twGWom5/56TF4lPcqjnDHcg==", "dev": true, "license": "MIT", "dependencies": { - "type-fest": "^0.20.2" + "balanced-match": "^1.0.0", + "concat-map": "0.0.1" + } + }, + "node_modules/@eslint/eslintrc/node_modules/minimatch": { + "version": "3.1.2", + "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.1.2.tgz", + "integrity": "sha512-J7p63hRiAjw1NDEww1W7i37+ByIrOWO5XQQAzZ3VOcL0PNybwpfmV/N05zFAzwQ9USyEcX6t3UO+K5aqBQOIHw==", + "dev": true, + "license": "ISC", + "dependencies": { + "brace-expansion": "^1.1.7" }, "engines": { - "node": ">=8" - }, - "funding": { - "url": "https://github.com/sponsors/sindresorhus" + "node": "*" } }, "node_modules/@eslint/js": { - "version": "8.44.0", - "resolved": "https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet-public-npm/npm/registry/@eslint/js/-/js-8.44.0.tgz", - "integrity": "sha1-lhpZA8dBOTkEeL3ICLzeP8Rat68=", + "version": "8.57.0", + "resolved": "https://registry.npmjs.org/@eslint/js/-/js-8.57.0.tgz", + "integrity": "sha512-Ys+3g2TaW7gADOJzPt83SJtCDhMjndcDMFVQ/Tj9iA1BfJzFKD9mAUXT3OenpuPHbI6P/myECxRJrofUsDx/5g==", "dev": true, "license": "MIT", "engines": { @@ -236,8 +146,9 @@ }, "node_modules/@humanwhocodes/config-array": { "version": "0.11.14", - "resolved": "https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet-public-npm/npm/registry/@humanwhocodes/config-array/-/config-array-0.11.14.tgz", - "integrity": "sha1-145IGgOfdWbsyWYLTqf+ax/sRCs=", + "resolved": "https://registry.npmjs.org/@humanwhocodes/config-array/-/config-array-0.11.14.tgz", + "integrity": "sha512-3T8LkOmg45BV5FICb15QQMsyUSWrQ8AygVfC7ZG32zOalnqrilm018ZVCw0eapXux8FtA33q8PSRSstjee3jSg==", + "deprecated": "Use @eslint/config-array instead", "dev": true, "license": "Apache-2.0", "dependencies": { @@ -249,10 +160,34 @@ "node": ">=10.10.0" } }, + "node_modules/@humanwhocodes/config-array/node_modules/brace-expansion": { + "version": "1.1.12", + "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.12.tgz", + "integrity": "sha512-9T9UjW3r0UW5c1Q7GTwllptXwhvYmEzFhzMfZ9H7FQWt+uZePjZPjBP/W1ZEyZ1twGWom5/56TF4lPcqjnDHcg==", + "dev": true, + "license": "MIT", + "dependencies": { + "balanced-match": "^1.0.0", + "concat-map": "0.0.1" + } + }, + "node_modules/@humanwhocodes/config-array/node_modules/minimatch": { + "version": "3.1.2", + "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.1.2.tgz", + "integrity": "sha512-J7p63hRiAjw1NDEww1W7i37+ByIrOWO5XQQAzZ3VOcL0PNybwpfmV/N05zFAzwQ9USyEcX6t3UO+K5aqBQOIHw==", + "dev": true, + "license": "ISC", + "dependencies": { + "brace-expansion": "^1.1.7" + }, + "engines": { + "node": "*" + } + }, "node_modules/@humanwhocodes/module-importer": { "version": "1.0.1", - "resolved": "https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet-public-npm/npm/registry/@humanwhocodes/module-importer/-/module-importer-1.0.1.tgz", - "integrity": "sha1-r1smkaIrRL6EewyoFkHF+2rQFyw=", + "resolved": "https://registry.npmjs.org/@humanwhocodes/module-importer/-/module-importer-1.0.1.tgz", + "integrity": "sha512-bxveV4V8v5Yb4ncFTT3rPSgZBOpCkjfK0y4oVVVJwIuDVBRMDXrPyXRL988i5ap9m9bnyEEjWfm5WkBmtffLfA==", "dev": true, "license": "Apache-2.0", "engines": { @@ -265,40 +200,27 @@ }, "node_modules/@humanwhocodes/object-schema": { "version": "2.0.3", - "resolved": "https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet-public-npm/npm/registry/@humanwhocodes/object-schema/-/object-schema-2.0.3.tgz", - "integrity": "sha1-Siho111taWPkI7z5C3/RvjQ0CdM=", + "resolved": "https://registry.npmjs.org/@humanwhocodes/object-schema/-/object-schema-2.0.3.tgz", + "integrity": "sha512-93zYdMES/c1D69yZiKDBj0V24vqNzB/koF26KPaagAfd3P/4gUlh3Dys5ogAK+Exi9QyzlD8x/08Zt7wIKcDcA==", + "deprecated": "Use @eslint/object-schema instead", "dev": true, "license": "BSD-3-Clause" }, "node_modules/@jridgewell/gen-mapping": { - "version": "0.3.5", - "resolved": "https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet-public-npm/npm/registry/@jridgewell/gen-mapping/-/gen-mapping-0.3.5.tgz", - "integrity": "sha1-3M5q/3S99trRqVgCtpsEovyx+zY=", + "version": "0.3.13", + "resolved": "https://registry.npmjs.org/@jridgewell/gen-mapping/-/gen-mapping-0.3.13.tgz", + "integrity": "sha512-2kkt/7niJ6MgEPxF0bYdQ6etZaA+fQvDcLKckhy1yIQOzaoKjBBjSj63/aLVjYE3qhRt5dvM+uUyfCg6UKCBbA==", "dev": true, "license": "MIT", "dependencies": { - "@jridgewell/set-array": "^1.2.1", - "@jridgewell/sourcemap-codec": "^1.4.10", + "@jridgewell/sourcemap-codec": "^1.5.0", "@jridgewell/trace-mapping": "^0.3.24" - }, - "engines": { - "node": ">=6.0.0" } }, "node_modules/@jridgewell/resolve-uri": { "version": "3.1.2", - "resolved": "https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet-public-npm/npm/registry/@jridgewell/resolve-uri/-/resolve-uri-3.1.2.tgz", - "integrity": "sha1-eg7mAfYPmaIMfHxf8MgDiMEYm9Y=", - "dev": true, - "license": "MIT", - "engines": { - "node": ">=6.0.0" - } - }, - "node_modules/@jridgewell/set-array": { - "version": "1.2.1", - "resolved": "https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet-public-npm/npm/registry/@jridgewell/set-array/-/set-array-1.2.1.tgz", - "integrity": "sha1-VY+2Ry7RakyFC4iVMOazZDjEkoA=", + "resolved": "https://registry.npmjs.org/@jridgewell/resolve-uri/-/resolve-uri-3.1.2.tgz", + "integrity": "sha512-bRISgCIjP20/tbWSPWMEi54QVPRZExkuD9lJL+UIxUKtwVJA8wW1Trb1jMs1RFXo1CBTNZ/5hpC9QvmKWdopKw==", "dev": true, "license": "MIT", "engines": { @@ -306,9 +228,9 @@ } }, "node_modules/@jridgewell/source-map": { - "version": "0.3.6", - "resolved": "https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet-public-npm/npm/registry/@jridgewell/source-map/-/source-map-0.3.6.tgz", - "integrity": "sha1-nXHKiG4yUC65NiyadKRnh8Nt+Bo=", + "version": "0.3.11", + "resolved": "https://registry.npmjs.org/@jridgewell/source-map/-/source-map-0.3.11.tgz", + "integrity": "sha512-ZMp1V8ZFcPG5dIWnQLr3NSI1MiCU7UETdS/A0G8V/XWHvJv3ZsFqutJn1Y5RPmAPX6F3BiE397OqveU/9NCuIA==", "dev": true, "license": "MIT", "dependencies": { @@ -317,16 +239,16 @@ } }, "node_modules/@jridgewell/sourcemap-codec": { - "version": "1.4.15", - "resolved": "https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet-public-npm/npm/registry/@jridgewell/sourcemap-codec/-/sourcemap-codec-1.4.15.tgz", - "integrity": "sha1-18bmdVx4VnqVHgSrUu8P0m3lnzI=", + "version": "1.5.5", + "resolved": "https://registry.npmjs.org/@jridgewell/sourcemap-codec/-/sourcemap-codec-1.5.5.tgz", + "integrity": "sha512-cYQ9310grqxueWbl+WuIUIaiUaDcj7WOq5fVhEljNVgRfOUhY9fy2zTvfoqWsnebh8Sl70VScFbICvJnLKB0Og==", "dev": true, "license": "MIT" }, "node_modules/@jridgewell/trace-mapping": { - "version": "0.3.25", - "resolved": "https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet-public-npm/npm/registry/@jridgewell/trace-mapping/-/trace-mapping-0.3.25.tgz", - "integrity": "sha1-FfGQ6YiV8/wjJ27hS8drZ1wuUPA=", + "version": "0.3.31", + "resolved": "https://registry.npmjs.org/@jridgewell/trace-mapping/-/trace-mapping-0.3.31.tgz", + "integrity": "sha512-zzNR+SdQSDJzc8joaeP8QQoCQr8NuYx2dIIytl1QeBEZHJ9uW6hebsrYgbz8hJwUQao3TWCMtmfV8Nu1twOLAw==", "dev": true, "license": "MIT", "dependencies": { @@ -336,8 +258,8 @@ }, "node_modules/@nodelib/fs.scandir": { "version": "2.1.5", - "resolved": "https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet-public-npm/npm/registry/@nodelib/fs.scandir/-/fs.scandir-2.1.5.tgz", - "integrity": "sha1-dhnC6yGyVIP20WdUi0z9WnSIw9U=", + "resolved": "https://registry.npmjs.org/@nodelib/fs.scandir/-/fs.scandir-2.1.5.tgz", + "integrity": "sha512-vq24Bq3ym5HEQm2NKCr3yXDwjc7vTsEThRDnkp2DK9p1uqLR+DHurm/NOTo0KG7HYHU7eppKZj3MyqYuMBf62g==", "dev": true, "license": "MIT", "dependencies": { @@ -350,8 +272,8 @@ }, "node_modules/@nodelib/fs.stat": { "version": "2.0.5", - "resolved": "https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet-public-npm/npm/registry/@nodelib/fs.stat/-/fs.stat-2.0.5.tgz", - "integrity": "sha1-W9Jir5Tp0lvR5xsF3u1Eh2oiLos=", + "resolved": "https://registry.npmjs.org/@nodelib/fs.stat/-/fs.stat-2.0.5.tgz", + "integrity": "sha512-RkhPPp2zrqDAQA/2jNhnztcPAlv64XdhIp7a7454A5ovI7Bukxgt7MX7udwAu3zg1DcpPU0rz3VV1SeaqvY4+A==", "dev": true, "license": "MIT", "engines": { @@ -360,8 +282,8 @@ }, "node_modules/@nodelib/fs.walk": { "version": "1.2.8", - "resolved": "https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet-public-npm/npm/registry/@nodelib/fs.walk/-/fs.walk-1.2.8.tgz", - "integrity": "sha1-6Vc36LtnRt3t9pxVaVNJTxlv5po=", + "resolved": "https://registry.npmjs.org/@nodelib/fs.walk/-/fs.walk-1.2.8.tgz", + "integrity": "sha512-oGB+UxlgWcgQkgwo8GcEGwemoTFt3FIO9ababBmaGwXIoBKZ+GTy0pP185beGg7Llih/NSHSV2XAs1lnznocSg==", "dev": true, "license": "MIT", "dependencies": { @@ -373,16 +295,15 @@ } }, "node_modules/@rollup/plugin-node-resolve": { - "version": "15.2.3", - "resolved": "https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet-public-npm/npm/registry/@rollup/plugin-node-resolve/-/plugin-node-resolve-15.2.3.tgz", - "integrity": "sha1-5eCwWb2FyldIlJLylc6IwtSw2vk=", + "version": "16.0.1", + "resolved": "https://registry.npmjs.org/@rollup/plugin-node-resolve/-/plugin-node-resolve-16.0.1.tgz", + "integrity": "sha512-tk5YCxJWIG81umIvNkSod2qK5KyQW19qcBF/B78n1bjtOON6gzKoVeSzAE8yHCZEDmqkHKkxplExA8KzdJLJpA==", "dev": true, "license": "MIT", "dependencies": { "@rollup/pluginutils": "^5.0.1", "@types/resolve": "1.20.2", "deepmerge": "^4.2.2", - "is-builtin-module": "^3.2.1", "is-module": "^1.0.0", "resolve": "^1.22.1" }, @@ -400,8 +321,8 @@ }, "node_modules/@rollup/plugin-terser": { "version": "0.4.4", - "resolved": "https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet-public-npm/npm/registry/@rollup/plugin-terser/-/plugin-terser-0.4.4.tgz", - "integrity": "sha1-Fd/9s/c/Ehqk+7N+fKa+mu6pGWI=", + "resolved": "https://registry.npmjs.org/@rollup/plugin-terser/-/plugin-terser-0.4.4.tgz", + "integrity": "sha512-XHeJC5Bgvs8LfukDwWZp7yeqin6ns8RTl2B9avbejt6tZqsqvVoWI7ZTQrcNsfKEDWBTnTxM8nMDkO2IFFbd0A==", "dev": true, "license": "MIT", "dependencies": { @@ -422,9 +343,9 @@ } }, "node_modules/@rollup/plugin-typescript": { - "version": "11.1.6", - "resolved": "https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet-public-npm/npm/registry/@rollup/plugin-typescript/-/plugin-typescript-11.1.6.tgz", - "integrity": "sha1-ckI31ewSYJ7AFCn2GdKj59TRsis=", + "version": "12.1.4", + "resolved": "https://registry.npmjs.org/@rollup/plugin-typescript/-/plugin-typescript-12.1.4.tgz", + "integrity": "sha512-s5Hx+EtN60LMlDBvl5f04bEiFZmAepk27Q+mr85L/00zPDn1jtzlTV6FWn81MaIwqfWzKxmOJrBWHU6vtQyedQ==", "dev": true, "license": "MIT", "dependencies": { @@ -450,8 +371,8 @@ }, "node_modules/@rollup/plugin-virtual": { "version": "3.0.2", - "resolved": "https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet-public-npm/npm/registry/@rollup/plugin-virtual/-/plugin-virtual-3.0.2.tgz", - "integrity": "sha1-F+F+7stMn6HApucsnl9mOC/du4I=", + "resolved": "https://registry.npmjs.org/@rollup/plugin-virtual/-/plugin-virtual-3.0.2.tgz", + "integrity": "sha512-10monEYsBp3scM4/ND4LNH5Rxvh3e/cVeL3jWTgZ2SrQ+BmUoQcopVQvnaMcOnykb1VkxUFuDAN+0FnpTFRy2A==", "dev": true, "license": "MIT", "engines": { @@ -467,15 +388,15 @@ } }, "node_modules/@rollup/pluginutils": { - "version": "5.1.0", - "resolved": "https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet-public-npm/npm/registry/@rollup/pluginutils/-/pluginutils-5.1.0.tgz", - "integrity": "sha1-flPt3Ix/SDpK0LlK+x9/X9PHceA=", + "version": "5.3.0", + "resolved": "https://registry.npmjs.org/@rollup/pluginutils/-/pluginutils-5.3.0.tgz", + "integrity": "sha512-5EdhGZtnu3V88ces7s53hhfK5KSASnJZv8Lulpc04cWO3REESroJXg73DFsOmgbU2BhwV0E20bu2IDZb3VKW4Q==", "dev": true, "license": "MIT", "dependencies": { "@types/estree": "^1.0.0", "estree-walker": "^2.0.2", - "picomatch": "^2.3.1" + "picomatch": "^4.0.2" }, "engines": { "node": ">=14.0.0" @@ -490,9 +411,9 @@ } }, "node_modules/@rollup/rollup-android-arm-eabi": { - "version": "4.34.9", - "resolved": "https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet-public-npm/npm/registry/@rollup/rollup-android-arm-eabi/-/rollup-android-arm-eabi-4.34.9.tgz", - "integrity": "sha1-ZhpFpHCccOWeWW7HjaqcuLjSdgQ=", + "version": "4.52.2", + "resolved": "https://registry.npmjs.org/@rollup/rollup-android-arm-eabi/-/rollup-android-arm-eabi-4.52.2.tgz", + "integrity": "sha512-o3pcKzJgSGt4d74lSZ+OCnHwkKBeAbFDmbEm5gg70eA8VkyCuC/zV9TwBnmw6VjDlRdF4Pshfb+WE9E6XY1PoQ==", "cpu": [ "arm" ], @@ -504,9 +425,9 @@ ] }, "node_modules/@rollup/rollup-android-arm64": { - "version": "4.34.9", - "resolved": "https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet-public-npm/npm/registry/@rollup/rollup-android-arm64/-/rollup-android-arm64-4.34.9.tgz", - "integrity": "sha1-Eo/o3VENiAz5i0y2x63TJoFaDEs=", + "version": "4.52.2", + "resolved": "https://registry.npmjs.org/@rollup/rollup-android-arm64/-/rollup-android-arm64-4.52.2.tgz", + "integrity": "sha512-cqFSWO5tX2vhC9hJTK8WAiPIm4Q8q/cU8j2HQA0L3E1uXvBYbOZMhE2oFL8n2pKB5sOCHY6bBuHaRwG7TkfJyw==", "cpu": [ "arm64" ], @@ -518,9 +439,9 @@ ] }, "node_modules/@rollup/rollup-darwin-arm64": { - "version": "4.34.9", - "resolved": "https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet-public-npm/npm/registry/@rollup/rollup-darwin-arm64/-/rollup-darwin-arm64-4.34.9.tgz", - "integrity": "sha1-NjRnvEn9Cx4XB1eYrI6a0eHilTU=", + "version": "4.52.2", + "resolved": "https://registry.npmjs.org/@rollup/rollup-darwin-arm64/-/rollup-darwin-arm64-4.52.2.tgz", + "integrity": "sha512-vngduywkkv8Fkh3wIZf5nFPXzWsNsVu1kvtLETWxTFf/5opZmflgVSeLgdHR56RQh71xhPhWoOkEBvbehwTlVA==", "cpu": [ "arm64" ], @@ -532,9 +453,9 @@ ] }, "node_modules/@rollup/rollup-darwin-x64": { - "version": "4.34.9", - "resolved": "https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet-public-npm/npm/registry/@rollup/rollup-darwin-x64/-/rollup-darwin-x64-4.34.9.tgz", - "integrity": "sha1-wv49hf/+R/DtDwdrNWOtoiyK8Zw=", + "version": "4.52.2", + "resolved": "https://registry.npmjs.org/@rollup/rollup-darwin-x64/-/rollup-darwin-x64-4.52.2.tgz", + "integrity": "sha512-h11KikYrUCYTrDj6h939hhMNlqU2fo/X4NB0OZcys3fya49o1hmFaczAiJWVAFgrM1NCP6RrO7lQKeVYSKBPSQ==", "cpu": [ "x64" ], @@ -546,9 +467,9 @@ ] }, "node_modules/@rollup/rollup-freebsd-arm64": { - "version": "4.34.9", - "resolved": "https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet-public-npm/npm/registry/@rollup/rollup-freebsd-arm64/-/rollup-freebsd-arm64-4.34.9.tgz", - "integrity": "sha1-2VvY9uqvgpeBFE/IvS1dcdn2qfU=", + "version": "4.52.2", + "resolved": "https://registry.npmjs.org/@rollup/rollup-freebsd-arm64/-/rollup-freebsd-arm64-4.52.2.tgz", + "integrity": "sha512-/eg4CI61ZUkLXxMHyVlmlGrSQZ34xqWlZNW43IAU4RmdzWEx0mQJ2mN/Cx4IHLVZFL6UBGAh+/GXhgvGb+nVxw==", "cpu": [ "arm64" ], @@ -560,9 +481,9 @@ ] }, "node_modules/@rollup/rollup-freebsd-x64": { - "version": "4.34.9", - "resolved": "https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet-public-npm/npm/registry/@rollup/rollup-freebsd-x64/-/rollup-freebsd-x64-4.34.9.tgz", - "integrity": "sha1-w1dsYBFlbklm3tKfBR7exja0RWQ=", + "version": "4.52.2", + "resolved": "https://registry.npmjs.org/@rollup/rollup-freebsd-x64/-/rollup-freebsd-x64-4.52.2.tgz", + "integrity": "sha512-QOWgFH5X9+p+S1NAfOqc0z8qEpJIoUHf7OWjNUGOeW18Mx22lAUOiA9b6r2/vpzLdfxi/f+VWsYjUOMCcYh0Ng==", "cpu": [ "x64" ], @@ -574,9 +495,9 @@ ] }, "node_modules/@rollup/rollup-linux-arm-gnueabihf": { - "version": "4.34.9", - "resolved": "https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet-public-npm/npm/registry/@rollup/rollup-linux-arm-gnueabihf/-/rollup-linux-arm-gnueabihf-4.34.9.tgz", - "integrity": "sha1-SMh9De5PjclZGkFnF/kbSonXfj0=", + "version": "4.52.2", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-arm-gnueabihf/-/rollup-linux-arm-gnueabihf-4.52.2.tgz", + "integrity": "sha512-kDWSPafToDd8LcBYd1t5jw7bD5Ojcu12S3uT372e5HKPzQt532vW+rGFFOaiR0opxePyUkHrwz8iWYEyH1IIQA==", "cpu": [ "arm" ], @@ -588,9 +509,9 @@ ] }, "node_modules/@rollup/rollup-linux-arm-musleabihf": { - "version": "4.34.9", - "resolved": "https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet-public-npm/npm/registry/@rollup/rollup-linux-arm-musleabihf/-/rollup-linux-arm-musleabihf-4.34.9.tgz", - "integrity": "sha1-9MTnwDp3Z/Llqp0MXPv1wPWfLUE=", + "version": "4.52.2", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-arm-musleabihf/-/rollup-linux-arm-musleabihf-4.52.2.tgz", + "integrity": "sha512-gKm7Mk9wCv6/rkzwCiUC4KnevYhlf8ztBrDRT9g/u//1fZLapSRc+eDZj2Eu2wpJ+0RzUKgtNijnVIB4ZxyL+w==", "cpu": [ "arm" ], @@ -602,9 +523,9 @@ ] }, "node_modules/@rollup/rollup-linux-arm64-gnu": { - "version": "4.34.9", - "resolved": "https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet-public-npm/npm/registry/@rollup/rollup-linux-arm64-gnu/-/rollup-linux-arm64-gnu-4.34.9.tgz", - "integrity": "sha1-EBXJ0HqZAFAl0TuGIrdgACnQtS8=", + "version": "4.52.2", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-arm64-gnu/-/rollup-linux-arm64-gnu-4.52.2.tgz", + "integrity": "sha512-66lA8vnj5mB/rtDNwPgrrKUOtCLVQypkyDa2gMfOefXK6rcZAxKLO9Fy3GkW8VkPnENv9hBkNOFfGLf6rNKGUg==", "cpu": [ "arm64" ], @@ -616,9 +537,9 @@ ] }, "node_modules/@rollup/rollup-linux-arm64-musl": { - "version": "4.34.9", - "resolved": "https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet-public-npm/npm/registry/@rollup/rollup-linux-arm64-musl/-/rollup-linux-arm64-musl-4.34.9.tgz", - "integrity": "sha1-j4letVd3SPx1ryG+rjJDlibgoUw=", + "version": "4.52.2", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-arm64-musl/-/rollup-linux-arm64-musl-4.52.2.tgz", + "integrity": "sha512-s+OPucLNdJHvuZHuIz2WwncJ+SfWHFEmlC5nKMUgAelUeBUnlB4wt7rXWiyG4Zn07uY2Dd+SGyVa9oyLkVGOjA==", "cpu": [ "arm64" ], @@ -629,10 +550,10 @@ "linux" ] }, - "node_modules/@rollup/rollup-linux-loongarch64-gnu": { - "version": "4.34.9", - "resolved": "https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet-public-npm/npm/registry/@rollup/rollup-linux-loongarch64-gnu/-/rollup-linux-loongarch64-gnu-4.34.9.tgz", - "integrity": "sha1-yc1du9xrPKTb7rAzdJjPMZSQBKA=", + "node_modules/@rollup/rollup-linux-loong64-gnu": { + "version": "4.52.2", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-loong64-gnu/-/rollup-linux-loong64-gnu-4.52.2.tgz", + "integrity": "sha512-8wTRM3+gVMDLLDdaT6tKmOE3lJyRy9NpJUS/ZRWmLCmOPIJhVyXwjBo+XbrrwtV33Em1/eCTd5TuGJm4+DmYjw==", "cpu": [ "loong64" ], @@ -643,10 +564,10 @@ "linux" ] }, - "node_modules/@rollup/rollup-linux-powerpc64le-gnu": { - "version": "4.34.9", - "resolved": "https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet-public-npm/npm/registry/@rollup/rollup-linux-powerpc64le-gnu/-/rollup-linux-powerpc64le-gnu-4.34.9.tgz", - "integrity": "sha1-frtbREH6oXhDohD30Fg6IMk7QOQ=", + "node_modules/@rollup/rollup-linux-ppc64-gnu": { + "version": "4.52.2", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-ppc64-gnu/-/rollup-linux-ppc64-gnu-4.52.2.tgz", + "integrity": "sha512-6yqEfgJ1anIeuP2P/zhtfBlDpXUb80t8DpbYwXQ3bQd95JMvUaqiX+fKqYqUwZXqdJDd8xdilNtsHM2N0cFm6A==", "cpu": [ "ppc64" ], @@ -658,9 +579,23 @@ ] }, "node_modules/@rollup/rollup-linux-riscv64-gnu": { - "version": "4.34.9", - "resolved": "https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet-public-npm/npm/registry/@rollup/rollup-linux-riscv64-gnu/-/rollup-linux-riscv64-gnu-4.34.9.tgz", - "integrity": "sha1-EPXXNJ+9L+ePnjbsyQqrMVRDXI0=", + "version": "4.52.2", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-riscv64-gnu/-/rollup-linux-riscv64-gnu-4.52.2.tgz", + "integrity": "sha512-sshYUiYVSEI2B6dp4jMncwxbrUqRdNApF2c3bhtLAU0qA8Lrri0p0NauOsTWh3yCCCDyBOjESHMExonp7Nzc0w==", + "cpu": [ + "riscv64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ] + }, + "node_modules/@rollup/rollup-linux-riscv64-musl": { + "version": "4.52.2", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-riscv64-musl/-/rollup-linux-riscv64-musl-4.52.2.tgz", + "integrity": "sha512-duBLgd+3pqC4MMwBrKkFxaZerUxZcYApQVC5SdbF5/e/589GwVvlRUnyqMFbM8iUSb1BaoX/3fRL7hB9m2Pj8Q==", "cpu": [ "riscv64" ], @@ -672,9 +607,9 @@ ] }, "node_modules/@rollup/rollup-linux-s390x-gnu": { - "version": "4.34.9", - "resolved": "https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet-public-npm/npm/registry/@rollup/rollup-linux-s390x-gnu/-/rollup-linux-s390x-gnu-4.34.9.tgz", - "integrity": "sha1-GWNH0vogWTqwnQt+JYn7ab33QsY=", + "version": "4.52.2", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-s390x-gnu/-/rollup-linux-s390x-gnu-4.52.2.tgz", + "integrity": "sha512-tzhYJJidDUVGMgVyE+PmxENPHlvvqm1KILjjZhB8/xHYqAGeizh3GBGf9u6WdJpZrz1aCpIIHG0LgJgH9rVjHQ==", "cpu": [ "s390x" ], @@ -686,9 +621,9 @@ ] }, "node_modules/@rollup/rollup-linux-x64-gnu": { - "version": "4.34.9", - "resolved": "https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet-public-npm/npm/registry/@rollup/rollup-linux-x64-gnu/-/rollup-linux-x64-gnu-4.34.9.tgz", - "integrity": "sha1-cZPL2NEoISuKzaN+AbOdnpYlnvg=", + "version": "4.52.2", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-x64-gnu/-/rollup-linux-x64-gnu-4.52.2.tgz", + "integrity": "sha512-opH8GSUuVcCSSyHHcl5hELrmnk4waZoVpgn/4FDao9iyE4WpQhyWJ5ryl5M3ocp4qkRuHfyXnGqg8M9oKCEKRA==", "cpu": [ "x64" ], @@ -700,9 +635,9 @@ ] }, "node_modules/@rollup/rollup-linux-x64-musl": { - "version": "4.34.9", - "resolved": "https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet-public-npm/npm/registry/@rollup/rollup-linux-x64-musl/-/rollup-linux-x64-musl-4.34.9.tgz", - "integrity": "sha1-KaaGcnjKBCC4kVdM+rmOytcMWdE=", + "version": "4.52.2", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-x64-musl/-/rollup-linux-x64-musl-4.52.2.tgz", + "integrity": "sha512-LSeBHnGli1pPKVJ79ZVJgeZWWZXkEe/5o8kcn23M8eMKCUANejchJbF/JqzM4RRjOJfNRhKJk8FuqL1GKjF5oQ==", "cpu": [ "x64" ], @@ -713,10 +648,24 @@ "linux" ] }, + "node_modules/@rollup/rollup-openharmony-arm64": { + "version": "4.52.2", + "resolved": "https://registry.npmjs.org/@rollup/rollup-openharmony-arm64/-/rollup-openharmony-arm64-4.52.2.tgz", + "integrity": "sha512-uPj7MQ6/s+/GOpolavm6BPo+6CbhbKYyZHUDvZ/SmJM7pfDBgdGisFX3bY/CBDMg2ZO4utfhlApkSfZ92yXw7Q==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "openharmony" + ] + }, "node_modules/@rollup/rollup-win32-arm64-msvc": { - "version": "4.34.9", - "resolved": "https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet-public-npm/npm/registry/@rollup/rollup-win32-arm64-msvc/-/rollup-win32-arm64-msvc-4.34.9.tgz", - "integrity": "sha1-iUJ9ysDI46bTKxOgOilqJ10N6ak=", + "version": "4.52.2", + "resolved": "https://registry.npmjs.org/@rollup/rollup-win32-arm64-msvc/-/rollup-win32-arm64-msvc-4.52.2.tgz", + "integrity": "sha512-Z9MUCrSgIaUeeHAiNkm3cQyst2UhzjPraR3gYYfOjAuZI7tcFRTOD+4cHLPoS/3qinchth+V56vtqz1Tv+6KPA==", "cpu": [ "arm64" ], @@ -728,9 +677,9 @@ ] }, "node_modules/@rollup/rollup-win32-ia32-msvc": { - "version": "4.34.9", - "resolved": "https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet-public-npm/npm/registry/@rollup/rollup-win32-ia32-msvc/-/rollup-win32-ia32-msvc-4.34.9.tgz", - "integrity": "sha1-7LlxG6K20r9u5RJlq+BXq5CRPes=", + "version": "4.52.2", + "resolved": "https://registry.npmjs.org/@rollup/rollup-win32-ia32-msvc/-/rollup-win32-ia32-msvc-4.52.2.tgz", + "integrity": "sha512-+GnYBmpjldD3XQd+HMejo+0gJGwYIOfFeoBQv32xF/RUIvccUz20/V6Otdv+57NE70D5pa8W/jVGDoGq0oON4A==", "cpu": [ "ia32" ], @@ -741,10 +690,24 @@ "win32" ] }, + "node_modules/@rollup/rollup-win32-x64-gnu": { + "version": "4.52.2", + "resolved": "https://registry.npmjs.org/@rollup/rollup-win32-x64-gnu/-/rollup-win32-x64-gnu-4.52.2.tgz", + "integrity": "sha512-ApXFKluSB6kDQkAqZOKXBjiaqdF1BlKi+/eqnYe9Ee7U2K3pUDKsIyr8EYm/QDHTJIM+4X+lI0gJc3TTRhd+dA==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "win32" + ] + }, "node_modules/@rollup/rollup-win32-x64-msvc": { - "version": "4.34.9", - "resolved": "https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet-public-npm/npm/registry/@rollup/rollup-win32-x64-msvc/-/rollup-win32-x64-msvc-4.34.9.tgz", - "integrity": "sha1-GXOHGFCFaucrxniusGarlSMw6SM=", + "version": "4.52.2", + "resolved": "https://registry.npmjs.org/@rollup/rollup-win32-x64-msvc/-/rollup-win32-x64-msvc-4.52.2.tgz", + "integrity": "sha512-ARz+Bs8kY6FtitYM96PqPEVvPXqEZmPZsSkXvyX19YzDqkCaIlhCieLLMI5hxO9SRZ2XtCtm8wxhy0iJ2jxNfw==", "cpu": [ "x64" ], @@ -756,9 +719,9 @@ ] }, "node_modules/@types/estree": { - "version": "1.0.6", - "resolved": "https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet-public-npm/npm/registry/@types/estree/-/estree-1.0.6.tgz", - "integrity": "sha1-Yo7/7q4gZKG055946B2Ht+X8e1A=", + "version": "1.0.8", + "resolved": "https://registry.npmjs.org/@types/estree/-/estree-1.0.8.tgz", + "integrity": "sha512-dWHzHa2WqEXI/O1E9OjrocMTKJl2mSrEolh1Iomrv6U+JuNwaHXsXx9bLu5gG7BUWFIN0skIQJQ/L1rIex4X6w==", "dev": true, "license": "MIT" }, @@ -781,46 +744,47 @@ }, "node_modules/@types/resolve": { "version": "1.20.2", - "resolved": "https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet-public-npm/npm/registry/@types/resolve/-/resolve-1.20.2.tgz", - "integrity": "sha1-l9JuAM1KBCO0r2IKvs8+b0QreXU=", + "resolved": "https://registry.npmjs.org/@types/resolve/-/resolve-1.20.2.tgz", + "integrity": "sha512-60BCwRFOZCQhDncwQdxxeOEEkbc5dIMccYLwbxsS4TUNeVECQ/pBJ0j09mrHOl/JJvpRPGwO9SvE4nR2Nb/a4Q==", "dev": true, "license": "MIT" }, "node_modules/@types/semver": { - "version": "7.5.8", - "resolved": "https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet-public-npm/npm/registry/@types/semver/-/semver-7.5.8.tgz", - "integrity": "sha1-gmioxXo+Sr0lwWXs02I323lIpV4=", + "version": "7.7.1", + "resolved": "https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet-public-npm/npm/registry/@types/semver/-/semver-7.7.1.tgz", + "integrity": "sha1-POOvGlUk7zJ9Lank/YttlcjXBSg=", "dev": true, "license": "MIT" }, "node_modules/@typescript-eslint/eslint-plugin": { - "version": "5.59.1", - "resolved": "https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet-public-npm/npm/registry/@typescript-eslint/eslint-plugin/-/eslint-plugin-5.59.1.tgz", - "integrity": "sha1-mwnuFUG/8dLOvcuH585KQAOs3gg=", + "version": "6.21.0", + "resolved": "https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet-public-npm/npm/registry/@typescript-eslint/eslint-plugin/-/eslint-plugin-6.21.0.tgz", + "integrity": "sha1-MIMMHKgf1fPCcU5STEMD4BlPnNM=", "dev": true, "license": "MIT", "dependencies": { - "@eslint-community/regexpp": "^4.4.0", - "@typescript-eslint/scope-manager": "5.59.1", - "@typescript-eslint/type-utils": "5.59.1", - "@typescript-eslint/utils": "5.59.1", + "@eslint-community/regexpp": "^4.5.1", + "@typescript-eslint/scope-manager": "6.21.0", + "@typescript-eslint/type-utils": "6.21.0", + "@typescript-eslint/utils": "6.21.0", + "@typescript-eslint/visitor-keys": "6.21.0", "debug": "^4.3.4", - "grapheme-splitter": "^1.0.4", - "ignore": "^5.2.0", - "natural-compare-lite": "^1.4.0", - "semver": "^7.3.7", - "tsutils": "^3.21.0" + "graphemer": "^1.4.0", + "ignore": "^5.2.4", + "natural-compare": "^1.4.0", + "semver": "^7.5.4", + "ts-api-utils": "^1.0.1" }, "engines": { - "node": "^12.22.0 || ^14.17.0 || >=16.0.0" + "node": "^16.0.0 || >=18.0.0" }, "funding": { "type": "opencollective", "url": "https://opencollective.com/typescript-eslint" }, "peerDependencies": { - "@typescript-eslint/parser": "^5.0.0", - "eslint": "^6.0.0 || ^7.0.0 || ^8.0.0" + "@typescript-eslint/parser": "^6.0.0 || ^6.0.0-alpha", + "eslint": "^7.0.0 || ^8.0.0" }, "peerDependenciesMeta": { "typescript": { @@ -829,26 +793,27 @@ } }, "node_modules/@typescript-eslint/parser": { - "version": "5.59.1", - "resolved": "https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet-public-npm/npm/registry/@typescript-eslint/parser/-/parser-5.59.1.tgz", - "integrity": "sha1-c8LBISfFwRgtLltxqPoqhdIVy7Q=", + "version": "6.21.0", + "resolved": "https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet-public-npm/npm/registry/@typescript-eslint/parser/-/parser-6.21.0.tgz", + "integrity": "sha1-r4/PZv7uLtyGvF0c9F4zsGML81s=", "dev": true, "license": "BSD-2-Clause", "dependencies": { - "@typescript-eslint/scope-manager": "5.59.1", - "@typescript-eslint/types": "5.59.1", - "@typescript-eslint/typescript-estree": "5.59.1", + "@typescript-eslint/scope-manager": "6.21.0", + "@typescript-eslint/types": "6.21.0", + "@typescript-eslint/typescript-estree": "6.21.0", + "@typescript-eslint/visitor-keys": "6.21.0", "debug": "^4.3.4" }, "engines": { - "node": "^12.22.0 || ^14.17.0 || >=16.0.0" + "node": "^16.0.0 || >=18.0.0" }, "funding": { "type": "opencollective", "url": "https://opencollective.com/typescript-eslint" }, "peerDependencies": { - "eslint": "^6.0.0 || ^7.0.0 || ^8.0.0" + "eslint": "^7.0.0 || ^8.0.0" }, "peerDependenciesMeta": { "typescript": { @@ -857,17 +822,17 @@ } }, "node_modules/@typescript-eslint/scope-manager": { - "version": "5.59.1", - "resolved": "https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet-public-npm/npm/registry/@typescript-eslint/scope-manager/-/scope-manager-5.59.1.tgz", - "integrity": "sha1-iiAiJxnOvFGYYYpdRBE3BbUf1/4=", + "version": "6.21.0", + "resolved": "https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet-public-npm/npm/registry/@typescript-eslint/scope-manager/-/scope-manager-6.21.0.tgz", + "integrity": "sha1-6oqb/I8VBKasXVmm3zCNOgYworE=", "dev": true, "license": "MIT", "dependencies": { - "@typescript-eslint/types": "5.59.1", - "@typescript-eslint/visitor-keys": "5.59.1" + "@typescript-eslint/types": "6.21.0", + "@typescript-eslint/visitor-keys": "6.21.0" }, "engines": { - "node": "^12.22.0 || ^14.17.0 || >=16.0.0" + "node": "^16.0.0 || >=18.0.0" }, "funding": { "type": "opencollective", @@ -875,26 +840,26 @@ } }, "node_modules/@typescript-eslint/type-utils": { - "version": "5.59.1", - "resolved": "https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet-public-npm/npm/registry/@typescript-eslint/type-utils/-/type-utils-5.59.1.tgz", - "integrity": "sha1-Y5gdYWhP0k7aL58IwKR+ywAKIRE=", + "version": "6.21.0", + "resolved": "https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet-public-npm/npm/registry/@typescript-eslint/type-utils/-/type-utils-6.21.0.tgz", + "integrity": "sha1-ZHMoHP7U2sq+gAToUhzuC9nUwB4=", "dev": true, "license": "MIT", "dependencies": { - "@typescript-eslint/typescript-estree": "5.59.1", - "@typescript-eslint/utils": "5.59.1", + "@typescript-eslint/typescript-estree": "6.21.0", + "@typescript-eslint/utils": "6.21.0", "debug": "^4.3.4", - "tsutils": "^3.21.0" + "ts-api-utils": "^1.0.1" }, "engines": { - "node": "^12.22.0 || ^14.17.0 || >=16.0.0" + "node": "^16.0.0 || >=18.0.0" }, "funding": { "type": "opencollective", "url": "https://opencollective.com/typescript-eslint" }, "peerDependencies": { - "eslint": "*" + "eslint": "^7.0.0 || ^8.0.0" }, "peerDependenciesMeta": { "typescript": { @@ -903,13 +868,13 @@ } }, "node_modules/@typescript-eslint/types": { - "version": "5.59.1", - "resolved": "https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet-public-npm/npm/registry/@typescript-eslint/types/-/types-5.59.1.tgz", - "integrity": "sha1-A/P+3RwETLM268NMx4VfEhmR9B0=", + "version": "6.21.0", + "resolved": "https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet-public-npm/npm/registry/@typescript-eslint/types/-/types-6.21.0.tgz", + "integrity": "sha1-IFckxRI6j+9+zRlQdfpuhbrDQ20=", "dev": true, "license": "MIT", "engines": { - "node": "^12.22.0 || ^14.17.0 || >=16.0.0" + "node": "^16.0.0 || >=18.0.0" }, "funding": { "type": "opencollective", @@ -917,22 +882,23 @@ } }, "node_modules/@typescript-eslint/typescript-estree": { - "version": "5.59.1", - "resolved": "https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet-public-npm/npm/registry/@typescript-eslint/typescript-estree/-/typescript-estree-5.59.1.tgz", - "integrity": "sha1-SqVG0n/Q1HfGGPDKALSD8OyExDw=", + "version": "6.21.0", + "resolved": "https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet-public-npm/npm/registry/@typescript-eslint/typescript-estree/-/typescript-estree-6.21.0.tgz", + "integrity": "sha1-xHrnkB2zuL3cPs1z2v8tCJVojEY=", "dev": true, "license": "BSD-2-Clause", "dependencies": { - "@typescript-eslint/types": "5.59.1", - "@typescript-eslint/visitor-keys": "5.59.1", + "@typescript-eslint/types": "6.21.0", + "@typescript-eslint/visitor-keys": "6.21.0", "debug": "^4.3.4", "globby": "^11.1.0", "is-glob": "^4.0.3", - "semver": "^7.3.7", - "tsutils": "^3.21.0" + "minimatch": "9.0.3", + "semver": "^7.5.4", + "ts-api-utils": "^1.0.1" }, "engines": { - "node": "^12.22.0 || ^14.17.0 || >=16.0.0" + "node": "^16.0.0 || >=18.0.0" }, "funding": { "type": "opencollective", @@ -945,54 +911,60 @@ } }, "node_modules/@typescript-eslint/utils": { - "version": "5.59.1", - "resolved": "https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet-public-npm/npm/registry/@typescript-eslint/utils/-/utils-5.59.1.tgz", - "integrity": "sha1-2J/HWK0j0hV8+uU/C0Kb3xXblHM=", + "version": "6.21.0", + "resolved": "https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet-public-npm/npm/registry/@typescript-eslint/utils/-/utils-6.21.0.tgz", + "integrity": "sha1-RxTnprOedzwcjpfsWH9SCEDNgTQ=", "dev": true, "license": "MIT", "dependencies": { - "@eslint-community/eslint-utils": "^4.2.0", - "@types/json-schema": "^7.0.9", - "@types/semver": "^7.3.12", - "@typescript-eslint/scope-manager": "5.59.1", - "@typescript-eslint/types": "5.59.1", - "@typescript-eslint/typescript-estree": "5.59.1", - "eslint-scope": "^5.1.1", - "semver": "^7.3.7" + "@eslint-community/eslint-utils": "^4.4.0", + "@types/json-schema": "^7.0.12", + "@types/semver": "^7.5.0", + "@typescript-eslint/scope-manager": "6.21.0", + "@typescript-eslint/types": "6.21.0", + "@typescript-eslint/typescript-estree": "6.21.0", + "semver": "^7.5.4" }, "engines": { - "node": "^12.22.0 || ^14.17.0 || >=16.0.0" + "node": "^16.0.0 || >=18.0.0" }, "funding": { "type": "opencollective", "url": "https://opencollective.com/typescript-eslint" }, "peerDependencies": { - "eslint": "^6.0.0 || ^7.0.0 || ^8.0.0" + "eslint": "^7.0.0 || ^8.0.0" } }, "node_modules/@typescript-eslint/visitor-keys": { - "version": "5.59.1", - "resolved": "https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet-public-npm/npm/registry/@typescript-eslint/visitor-keys/-/visitor-keys-5.59.1.tgz", - "integrity": "sha1-DZbDbvtlYNf7jrhd4QRCwQ2PYFg=", + "version": "6.21.0", + "resolved": "https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet-public-npm/npm/registry/@typescript-eslint/visitor-keys/-/visitor-keys-6.21.0.tgz", + "integrity": "sha1-h6mdB3qlB+IOI4sR1WzCat5F/kc=", "dev": true, "license": "MIT", "dependencies": { - "@typescript-eslint/types": "5.59.1", - "eslint-visitor-keys": "^3.3.0" + "@typescript-eslint/types": "6.21.0", + "eslint-visitor-keys": "^3.4.1" }, "engines": { - "node": "^12.22.0 || ^14.17.0 || >=16.0.0" + "node": "^16.0.0 || >=18.0.0" }, "funding": { "type": "opencollective", "url": "https://opencollective.com/typescript-eslint" } }, + "node_modules/@ungap/structured-clone": { + "version": "1.3.0", + "resolved": "https://registry.npmjs.org/@ungap/structured-clone/-/structured-clone-1.3.0.tgz", + "integrity": "sha512-WmoN8qaIAo7WTYWbAZuG8PYEhn5fkz7dZrqTBZ7dtt//lL2Gwms1IcnQ5yHqjDfX8Ft5j4YzDM23f87zBfDe9g==", + "dev": true, + "license": "ISC" + }, "node_modules/acorn": { - "version": "8.12.0", - "resolved": "https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet-public-npm/npm/registry/acorn/-/acorn-8.12.0.tgz", - "integrity": "sha1-Fie/ouBYFIA2EzuNm1GnAGY8KUw=", + "version": "8.15.0", + "resolved": "https://registry.npmjs.org/acorn/-/acorn-8.15.0.tgz", + "integrity": "sha512-NZyJarBfL7nWwIq+FDL6Zp/yHEhePMNnnJ0y3qfieCrmNvYct8uvtiV41UvlSe6apAfk0fY1FbWx+NwfmpvtTg==", "dev": true, "license": "MIT", "bin": { @@ -1004,8 +976,8 @@ }, "node_modules/acorn-jsx": { "version": "5.3.2", - "resolved": "https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet-public-npm/npm/registry/acorn-jsx/-/acorn-jsx-5.3.2.tgz", - "integrity": "sha1-ftW7VZCLOy8bxVxq8WU7rafweTc=", + "resolved": "https://registry.npmjs.org/acorn-jsx/-/acorn-jsx-5.3.2.tgz", + "integrity": "sha512-rq9s+JNhf0IChjtDXxllJ7g41oZk5SlXtp0LHwyA5cejwn7vKmKp4pPri6YEePv2PU65sAsegbXtIinmDFDXgQ==", "dev": true, "license": "MIT", "peerDependencies": { @@ -1014,8 +986,8 @@ }, "node_modules/ajv": { "version": "6.12.6", - "resolved": "https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet-public-npm/npm/registry/ajv/-/ajv-6.12.6.tgz", - "integrity": "sha1-uvWmLoArB9l3A0WG+MO69a3ybfQ=", + "resolved": "https://registry.npmjs.org/ajv/-/ajv-6.12.6.tgz", + "integrity": "sha512-j3fVLgvTo527anyYyJOGTYJbG+vnnQYvE0m5mmkc1TK+nxAppkCLMIL0aZ4dblVCNoGShhm+kzE4ZUykBoMg4g==", "dev": true, "license": "MIT", "dependencies": { @@ -1031,8 +1003,8 @@ }, "node_modules/ansi-regex": { "version": "5.0.1", - "resolved": "https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet-public-npm/npm/registry/ansi-regex/-/ansi-regex-5.0.1.tgz", - "integrity": "sha1-CCyyyJyf6GWaMRpTvWpNxTAdswQ=", + "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-5.0.1.tgz", + "integrity": "sha512-quJQXlTSUGL2LH9SUXo8VwsY4soanhgo6LNSm84E1LBcE8s3O0wpdiRzyR9z/ZZJMlMWv37qOOb9pdJlMUEKFQ==", "dev": true, "license": "MIT", "engines": { @@ -1041,8 +1013,8 @@ }, "node_modules/ansi-styles": { "version": "4.3.0", - "resolved": "https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet-public-npm/npm/registry/ansi-styles/-/ansi-styles-4.3.0.tgz", - "integrity": "sha1-7dgDYornHATIWuegkG7a00tkiTc=", + "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-4.3.0.tgz", + "integrity": "sha512-zbB9rCJAT1rbjiVDb2hqKFHNYLxgtk8NURxZ3IZwD3F6NtxbXZQCnnSi1Lkx+IDohdPlFp222wVALIheZJQSEg==", "dev": true, "license": "MIT", "dependencies": { @@ -1057,8 +1029,8 @@ }, "node_modules/argparse": { "version": "2.0.1", - "resolved": "https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet-public-npm/npm/registry/argparse/-/argparse-2.0.1.tgz", - "integrity": "sha1-JG9Q88p4oyQPbJl+ipvR6sSeSzg=", + "resolved": "https://registry.npmjs.org/argparse/-/argparse-2.0.1.tgz", + "integrity": "sha512-8+9WqebbFzpX9OR+Wa6O29asIogeRMzcGtAINdpMHHyAg10f05aSFVBbcEqGf/PXw1EjAZ+q2/bEBg3DvurK3Q==", "dev": true, "license": "Python-2.0" }, @@ -1074,26 +1046,25 @@ }, "node_modules/balanced-match": { "version": "1.0.2", - "resolved": "https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet-public-npm/npm/registry/balanced-match/-/balanced-match-1.0.2.tgz", - "integrity": "sha1-6D46fj8wCzTLnYf2FfoMvzV2kO4=", + "resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.2.tgz", + "integrity": "sha512-3oSeUO0TMV67hN1AmbXsK4yaqU7tjiHlbxRDZOpH0KW9+CeX4bRAaX0Anxt0tx2MrpRpWwQaPwIlISEJhYU5Pw==", "dev": true, "license": "MIT" }, "node_modules/brace-expansion": { - "version": "1.1.11", - "resolved": "https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet-public-npm/npm/registry/brace-expansion/-/brace-expansion-1.1.11.tgz", - "integrity": "sha1-PH/L9SnYcibz0vUrlm/1Jx60Qd0=", + "version": "2.0.2", + "resolved": "https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet-public-npm/npm/registry/brace-expansion/-/brace-expansion-2.0.2.tgz", + "integrity": "sha1-VPxTI3phPYVMe9N0Y6rRffhyFOc=", "dev": true, "license": "MIT", "dependencies": { - "balanced-match": "^1.0.0", - "concat-map": "0.0.1" + "balanced-match": "^1.0.0" } }, "node_modules/braces": { "version": "3.0.3", - "resolved": "https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet-public-npm/npm/registry/braces/-/braces-3.0.3.tgz", - "integrity": "sha1-SQMy9AkZRSJy1VqEgK3AxEE1h4k=", + "resolved": "https://registry.npmjs.org/braces/-/braces-3.0.3.tgz", + "integrity": "sha512-yQbXgO/OSZVD2IsiLlro+7Hf6Q18EJrKSEsdoMzKePKXct3gvD8oLcOQdIzGupr5Fj+EDe8gO/lxc1BzfMpxvA==", "dev": true, "license": "MIT", "dependencies": { @@ -1105,28 +1076,15 @@ }, "node_modules/buffer-from": { "version": "1.1.2", - "resolved": "https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet-public-npm/npm/registry/buffer-from/-/buffer-from-1.1.2.tgz", - "integrity": "sha1-KxRqb9cugLT1XSVfNe1Zo6mkG9U=", + "resolved": "https://registry.npmjs.org/buffer-from/-/buffer-from-1.1.2.tgz", + "integrity": "sha512-E+XQCRwSbaaiChtv6k6Dwgc+bx+Bs6vuKJHHl5kox/BaKbhiXzqQOwK4cO22yElGp2OCmjwVhT3HmxgyPGnJfQ==", "dev": true, "license": "MIT" }, - "node_modules/builtin-modules": { - "version": "3.3.0", - "resolved": "https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet-public-npm/npm/registry/builtin-modules/-/builtin-modules-3.3.0.tgz", - "integrity": "sha1-yuYoEriYAellYzbkYiPgMDhr57Y=", - "dev": true, - "license": "MIT", - "engines": { - "node": ">=6" - }, - "funding": { - "url": "https://github.com/sponsors/sindresorhus" - } - }, "node_modules/callsites": { "version": "3.1.0", - "resolved": "https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet-public-npm/npm/registry/callsites/-/callsites-3.1.0.tgz", - "integrity": "sha1-s2MKvYlDQy9Us/BRkjjjPNffL3M=", + "resolved": "https://registry.npmjs.org/callsites/-/callsites-3.1.0.tgz", + "integrity": "sha512-P8BjAsXvZS+VIDUI11hHCQEv74YT67YUi5JJFNWIqL235sBmjX4+qx9Muvls5ivyNENctx46xQLQ3aTuE7ssaQ==", "dev": true, "license": "MIT", "engines": { @@ -1135,8 +1093,8 @@ }, "node_modules/chalk": { "version": "4.1.2", - "resolved": "https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet-public-npm/npm/registry/chalk/-/chalk-4.1.2.tgz", - "integrity": "sha1-qsTit3NKdAhnrrFr8CqtVWoeegE=", + "resolved": "https://registry.npmjs.org/chalk/-/chalk-4.1.2.tgz", + "integrity": "sha512-oKnbhFyRIXpUuez8iBMmyEa4nbj4IOQyuhc/wy9kY7/WVPcwIO9VA668Pu8RkO7+0G76SLROeyw9CpQ061i4mA==", "dev": true, "license": "MIT", "dependencies": { @@ -1152,8 +1110,8 @@ }, "node_modules/color-convert": { "version": "2.0.1", - "resolved": "https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet-public-npm/npm/registry/color-convert/-/color-convert-2.0.1.tgz", - "integrity": "sha1-ctOmjVmMm9s68q0ehPIdiWq9TeM=", + "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-2.0.1.tgz", + "integrity": "sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ==", "dev": true, "license": "MIT", "dependencies": { @@ -1165,29 +1123,29 @@ }, "node_modules/color-name": { "version": "1.1.4", - "resolved": "https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet-public-npm/npm/registry/color-name/-/color-name-1.1.4.tgz", - "integrity": "sha1-wqCah6y95pVD3m9j+jmVyCbFNqI=", + "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.4.tgz", + "integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==", "dev": true, "license": "MIT" }, "node_modules/commander": { "version": "2.20.3", - "resolved": "https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet-public-npm/npm/registry/commander/-/commander-2.20.3.tgz", - "integrity": "sha1-/UhehMA+tIgcIHIrpIA16FMa6zM=", + "resolved": "https://registry.npmjs.org/commander/-/commander-2.20.3.tgz", + "integrity": "sha512-GpVkmM8vF2vQUkj2LvZmD35JxeJOLCwJ9cUkugyk2nuhbv3+mJvpLYYt+0+USMxE+oj+ey/lJEnhZw75x/OMcQ==", "dev": true, "license": "MIT" }, "node_modules/concat-map": { "version": "0.0.1", - "resolved": "https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet-public-npm/npm/registry/concat-map/-/concat-map-0.0.1.tgz", - "integrity": "sha1-2Klr13/Wjfd5OnMDajug1UBdR3s=", + "resolved": "https://registry.npmjs.org/concat-map/-/concat-map-0.0.1.tgz", + "integrity": "sha512-/Srv4dswyQNBfohGpz9o6Yb3Gz3SrUDqBH5rTuhGR7ahtlbYKnVxw2bCFMRljaA7EXHaXZ8wsHdodFvbkhKmqg==", "dev": true, "license": "MIT" }, "node_modules/cross-spawn": { - "version": "7.0.3", - "resolved": "https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet-public-npm/npm/registry/cross-spawn/-/cross-spawn-7.0.3.tgz", - "integrity": "sha1-9zqFudXUHQRVUcF34ogtSshXKKY=", + "version": "7.0.6", + "resolved": "https://registry.npmjs.org/cross-spawn/-/cross-spawn-7.0.6.tgz", + "integrity": "sha512-uV2QOWP2nWzsy2aMp8aRibhi9dlzF5Hgh5SHaB9OiTGEyDTiJJyx0uy51QXdyWbtAHNua4XJzUKca3OzKUd3vA==", "dev": true, "license": "MIT", "dependencies": { @@ -1200,13 +1158,13 @@ } }, "node_modules/debug": { - "version": "4.3.5", - "resolved": "https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet-public-npm/npm/registry/debug/-/debug-4.3.5.tgz", - "integrity": "sha1-6DRE7Ouf7dSh2lbWca4kRqAabh4=", + "version": "4.4.3", + "resolved": "https://registry.npmjs.org/debug/-/debug-4.4.3.tgz", + "integrity": "sha512-RGwwWnwQvkVfavKVt22FGLw+xYSdzARwm0ru6DhTVA3umU5hZc28V3kO4stgYryrTlLpuvgI9GiijltAjNbcqA==", "dev": true, "license": "MIT", "dependencies": { - "ms": "2.1.2" + "ms": "^2.1.3" }, "engines": { "node": ">=6.0" @@ -1219,15 +1177,15 @@ }, "node_modules/deep-is": { "version": "0.1.4", - "resolved": "https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet-public-npm/npm/registry/deep-is/-/deep-is-0.1.4.tgz", - "integrity": "sha1-pvLc5hL63S7x9Rm3NVHxfoUZmDE=", + "resolved": "https://registry.npmjs.org/deep-is/-/deep-is-0.1.4.tgz", + "integrity": "sha512-oIPzksmTg4/MriiaYGO+okXDT7ztn/w3Eptv/+gSIdMdKsJo0u4CfYNFJPy+4SKMuCqGw2wxnA+URMg3t8a/bQ==", "dev": true, "license": "MIT" }, "node_modules/deepmerge": { "version": "4.3.1", - "resolved": "https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet-public-npm/npm/registry/deepmerge/-/deepmerge-4.3.1.tgz", - "integrity": "sha1-RLXyFHzTsA1LVhN2hZZvJv0l3Uo=", + "resolved": "https://registry.npmjs.org/deepmerge/-/deepmerge-4.3.1.tgz", + "integrity": "sha512-3sUqbMEc77XqpdNO7FRyRog+eW3ph+GYCbj+rK+uYyRMuwsVy0rMiVtPn+QJlKFvWP/1PYpapqYn0Me2knFn+A==", "dev": true, "license": "MIT", "engines": { @@ -1249,8 +1207,8 @@ }, "node_modules/doctrine": { "version": "3.0.0", - "resolved": "https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet-public-npm/npm/registry/doctrine/-/doctrine-3.0.0.tgz", - "integrity": "sha1-rd6+rXKmV023g2OdyHoSF3OXOWE=", + "resolved": "https://registry.npmjs.org/doctrine/-/doctrine-3.0.0.tgz", + "integrity": "sha512-yS+Q5i3hBf7GBkd4KG8a7eBNNWNGLTaEwwYWUijIYM7zrlYDM0BFXHjjPWlWZ1Rg7UaddZeIDmi9jF3HmqiQ2w==", "dev": true, "license": "Apache-2.0", "dependencies": { @@ -1261,9 +1219,9 @@ } }, "node_modules/end-of-stream": { - "version": "1.4.4", - "resolved": "https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet-public-npm/npm/registry/end-of-stream/-/end-of-stream-1.4.4.tgz", - "integrity": "sha1-WuZKX0UFe682JuwU2gyl5LJDHrA=", + "version": "1.4.5", + "resolved": "https://registry.npmjs.org/end-of-stream/-/end-of-stream-1.4.5.tgz", + "integrity": "sha512-ooEGc6HP26xXq/N+GCGOT0JKCLDGrq2bQUZrQ7gyrJiZANJ/8YDTxTpQBXGMn+WbIQXNVpyWymm7KYVICQnyOg==", "dev": true, "license": "MIT", "dependencies": { @@ -1272,8 +1230,8 @@ }, "node_modules/escape-string-regexp": { "version": "4.0.0", - "resolved": "https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet-public-npm/npm/registry/escape-string-regexp/-/escape-string-regexp-4.0.0.tgz", - "integrity": "sha1-FLqDpdNz49MR5a/KKc9b+tllvzQ=", + "resolved": "https://registry.npmjs.org/escape-string-regexp/-/escape-string-regexp-4.0.0.tgz", + "integrity": "sha512-TtpcNJ3XAzx3Gq8sWRzJaVajRs0uVxA2YAkdb1jm2YkPz4G6egUFAyA3n5vtEIZefPk5Wa4UXbKuS5fKkJWdgA==", "dev": true, "license": "MIT", "engines": { @@ -1284,28 +1242,30 @@ } }, "node_modules/eslint": { - "version": "8.44.0", - "resolved": "https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet-public-npm/npm/registry/eslint/-/eslint-8.44.0.tgz", - "integrity": "sha1-USRuOImyWbvNHX1zagwQrdTw5QA=", + "version": "8.57.0", + "resolved": "https://registry.npmjs.org/eslint/-/eslint-8.57.0.tgz", + "integrity": "sha512-dZ6+mexnaTIbSBZWgou51U6OmzIhYM2VcNdtiTtI7qPNZm35Akpr0f6vtw3w1Kmn5PYo+tZVfh13WrhpS6oLqQ==", + "deprecated": "This version is no longer supported. Please see https://eslint.org/version-support for other options.", "dev": true, "license": "MIT", "dependencies": { "@eslint-community/eslint-utils": "^4.2.0", - "@eslint-community/regexpp": "^4.4.0", - "@eslint/eslintrc": "^2.1.0", - "@eslint/js": "8.44.0", - "@humanwhocodes/config-array": "^0.11.10", + "@eslint-community/regexpp": "^4.6.1", + "@eslint/eslintrc": "^2.1.4", + "@eslint/js": "8.57.0", + "@humanwhocodes/config-array": "^0.11.14", "@humanwhocodes/module-importer": "^1.0.1", "@nodelib/fs.walk": "^1.2.8", - "ajv": "^6.10.0", + "@ungap/structured-clone": "^1.2.0", + "ajv": "^6.12.4", "chalk": "^4.0.0", "cross-spawn": "^7.0.2", "debug": "^4.3.2", "doctrine": "^3.0.0", "escape-string-regexp": "^4.0.0", - "eslint-scope": "^7.2.0", - "eslint-visitor-keys": "^3.4.1", - "espree": "^9.6.0", + "eslint-scope": "^7.2.2", + "eslint-visitor-keys": "^3.4.3", + "espree": "^9.6.1", "esquery": "^1.4.2", "esutils": "^2.0.2", "fast-deep-equal": "^3.1.3", @@ -1315,7 +1275,6 @@ "globals": "^13.19.0", "graphemer": "^1.4.0", "ignore": "^5.2.0", - "import-fresh": "^3.0.0", "imurmurhash": "^0.1.4", "is-glob": "^4.0.0", "is-path-inside": "^3.0.3", @@ -1327,7 +1286,6 @@ "natural-compare": "^1.4.0", "optionator": "^0.9.3", "strip-ansi": "^6.0.1", - "strip-json-comments": "^3.1.0", "text-table": "^0.2.0" }, "bin": { @@ -1341,25 +1299,15 @@ } }, "node_modules/eslint-scope": { - "version": "5.1.1", - "resolved": "https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet-public-npm/npm/registry/eslint-scope/-/eslint-scope-5.1.1.tgz", - "integrity": "sha1-54blmmbLkrP2wfsNUIqrF0hI9Iw=", + "version": "7.2.2", + "resolved": "https://registry.npmjs.org/eslint-scope/-/eslint-scope-7.2.2.tgz", + "integrity": "sha512-dOt21O7lTMhDM+X9mB4GX+DZrZtCUJPL/wlcTqxyrx5IvO0IYtILdtrQGQp+8n5S0gwSVmOf9NQrjMOgfQZlIg==", "dev": true, "license": "BSD-2-Clause", "dependencies": { "esrecurse": "^4.3.0", - "estraverse": "^4.1.1" + "estraverse": "^5.2.0" }, - "engines": { - "node": ">=8.0.0" - } - }, - "node_modules/eslint-visitor-keys": { - "version": "3.4.3", - "resolved": "https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet-public-npm/npm/registry/eslint-visitor-keys/-/eslint-visitor-keys-3.4.3.tgz", - "integrity": "sha1-DNcv6FUOPC6uFWqWpN3c0cisWAA=", - "dev": true, - "license": "Apache-2.0", "engines": { "node": "^12.22.0 || ^14.17.0 || >=16.0.0" }, @@ -1367,16 +1315,12 @@ "url": "https://opencollective.com/eslint" } }, - "node_modules/eslint/node_modules/eslint-scope": { - "version": "7.2.2", - "resolved": "https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet-public-npm/npm/registry/eslint-scope/-/eslint-scope-7.2.2.tgz", - "integrity": "sha1-3rT5JWM5DzIAaJSvYqItuhxGQj8=", + "node_modules/eslint-visitor-keys": { + "version": "3.4.3", + "resolved": "https://registry.npmjs.org/eslint-visitor-keys/-/eslint-visitor-keys-3.4.3.tgz", + "integrity": "sha512-wpc+LXeiyiisxPlEkUzU6svyS1frIO3Mgxj1fdy7Pm8Ygzguax2N3Fa/D/ag1WqbOprdI+uY6wMUl8/a2G+iag==", "dev": true, - "license": "BSD-2-Clause", - "dependencies": { - "esrecurse": "^4.3.0", - "estraverse": "^5.2.0" - }, + "license": "Apache-2.0", "engines": { "node": "^12.22.0 || ^14.17.0 || >=16.0.0" }, @@ -1384,36 +1328,34 @@ "url": "https://opencollective.com/eslint" } }, - "node_modules/eslint/node_modules/estraverse": { - "version": "5.3.0", - "resolved": "https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet-public-npm/npm/registry/estraverse/-/estraverse-5.3.0.tgz", - "integrity": "sha1-LupSkHAvJquP5TcDcP+GyWXSESM=", + "node_modules/eslint/node_modules/brace-expansion": { + "version": "1.1.12", + "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.12.tgz", + "integrity": "sha512-9T9UjW3r0UW5c1Q7GTwllptXwhvYmEzFhzMfZ9H7FQWt+uZePjZPjBP/W1ZEyZ1twGWom5/56TF4lPcqjnDHcg==", "dev": true, - "license": "BSD-2-Clause", - "engines": { - "node": ">=4.0" + "license": "MIT", + "dependencies": { + "balanced-match": "^1.0.0", + "concat-map": "0.0.1" } }, - "node_modules/eslint/node_modules/globals": { - "version": "13.24.0", - "resolved": "https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet-public-npm/npm/registry/globals/-/globals-13.24.0.tgz", - "integrity": "sha1-hDKhnXjODB6DOUnDats0VAC7EXE=", + "node_modules/eslint/node_modules/minimatch": { + "version": "3.1.2", + "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.1.2.tgz", + "integrity": "sha512-J7p63hRiAjw1NDEww1W7i37+ByIrOWO5XQQAzZ3VOcL0PNybwpfmV/N05zFAzwQ9USyEcX6t3UO+K5aqBQOIHw==", "dev": true, - "license": "MIT", + "license": "ISC", "dependencies": { - "type-fest": "^0.20.2" + "brace-expansion": "^1.1.7" }, "engines": { - "node": ">=8" - }, - "funding": { - "url": "https://github.com/sponsors/sindresorhus" + "node": "*" } }, "node_modules/espree": { "version": "9.6.1", - "resolved": "https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet-public-npm/npm/registry/espree/-/espree-9.6.1.tgz", - "integrity": "sha1-oqF7jkNGkKVDLy+AGM5x0zGkjG8=", + "resolved": "https://registry.npmjs.org/espree/-/espree-9.6.1.tgz", + "integrity": "sha512-oruZaFkjorTpF32kDSI5/75ViwGeZginGGy2NoOSg3Q9bnwlnmDm4HLnkl0RE3n+njDXR037aY1+x58Z/zFdwQ==", "dev": true, "license": "BSD-2-Clause", "dependencies": { @@ -1429,9 +1371,9 @@ } }, "node_modules/esquery": { - "version": "1.5.0", - "resolved": "https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet-public-npm/npm/registry/esquery/-/esquery-1.5.0.tgz", - "integrity": "sha1-bOF3ON6Fd2lO3XNhxXGCrIyw2ws=", + "version": "1.6.0", + "resolved": "https://registry.npmjs.org/esquery/-/esquery-1.6.0.tgz", + "integrity": "sha512-ca9pw9fomFcKPvFLXhBKUK90ZvGibiGOvRJNbjljY7s7uq/5YO4BOzcYtJqExdx99rF6aAcnRxHmcUHcz6sQsg==", "dev": true, "license": "BSD-3-Clause", "dependencies": { @@ -1441,20 +1383,10 @@ "node": ">=0.10" } }, - "node_modules/esquery/node_modules/estraverse": { - "version": "5.3.0", - "resolved": "https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet-public-npm/npm/registry/estraverse/-/estraverse-5.3.0.tgz", - "integrity": "sha1-LupSkHAvJquP5TcDcP+GyWXSESM=", - "dev": true, - "license": "BSD-2-Clause", - "engines": { - "node": ">=4.0" - } - }, "node_modules/esrecurse": { "version": "4.3.0", - "resolved": "https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet-public-npm/npm/registry/esrecurse/-/esrecurse-4.3.0.tgz", - "integrity": "sha1-eteWTWeauyi+5yzsY3WLHF0smSE=", + "resolved": "https://registry.npmjs.org/esrecurse/-/esrecurse-4.3.0.tgz", + "integrity": "sha512-KmfKL3b6G+RXvP8N1vr3Tq1kL/oCFgn2NYXEtqP8/L3pKapUA4G8cFVaoF3SU323CD4XypR/ffioHmkti6/Tag==", "dev": true, "license": "BSD-2-Clause", "dependencies": { @@ -1464,20 +1396,10 @@ "node": ">=4.0" } }, - "node_modules/esrecurse/node_modules/estraverse": { - "version": "5.3.0", - "resolved": "https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet-public-npm/npm/registry/estraverse/-/estraverse-5.3.0.tgz", - "integrity": "sha1-LupSkHAvJquP5TcDcP+GyWXSESM=", - "dev": true, - "license": "BSD-2-Clause", - "engines": { - "node": ">=4.0" - } - }, "node_modules/estraverse": { - "version": "4.3.0", - "resolved": "https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet-public-npm/npm/registry/estraverse/-/estraverse-4.3.0.tgz", - "integrity": "sha1-OYrT88WiSUi+dyXoPRGn3ijNvR0=", + "version": "5.3.0", + "resolved": "https://registry.npmjs.org/estraverse/-/estraverse-5.3.0.tgz", + "integrity": "sha512-MMdARuVEQziNTeJD8DgMqmhwR11BRQ/cBP+pLtYdSTnf3MIO8fFeiINEbX36ZdNlfU/7A9f3gUw49B3oQsvwBA==", "dev": true, "license": "BSD-2-Clause", "engines": { @@ -1486,15 +1408,15 @@ }, "node_modules/estree-walker": { "version": "2.0.2", - "resolved": "https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet-public-npm/npm/registry/estree-walker/-/estree-walker-2.0.2.tgz", - "integrity": "sha1-UvAQF4wqTBF6d1fP6UKtt9LaTKw=", + "resolved": "https://registry.npmjs.org/estree-walker/-/estree-walker-2.0.2.tgz", + "integrity": "sha512-Rfkk/Mp/DL7JVje3u18FxFujQlTNR2q6QfMSMB7AvCBx91NGj/ba3kCfza0f6dVDbw7YlRf/nDrn7pQrCCyQ/w==", "dev": true, "license": "MIT" }, "node_modules/esutils": { "version": "2.0.3", - "resolved": "https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet-public-npm/npm/registry/esutils/-/esutils-2.0.3.tgz", - "integrity": "sha1-dNLrTeC42hKTcRkQ1Qd1ubcQ72Q=", + "resolved": "https://registry.npmjs.org/esutils/-/esutils-2.0.3.tgz", + "integrity": "sha512-kVscqXk4OCp68SZ0dkgEKVi6/8ij300KBWTJq32P/dYeWTSwK41WyTxalN1eRmA5Z9UU/LX9D7FWSmV9SAYx6g==", "dev": true, "license": "BSD-2-Clause", "engines": { @@ -1503,8 +1425,8 @@ }, "node_modules/execa": { "version": "4.1.0", - "resolved": "https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet-public-npm/npm/registry/execa/-/execa-4.1.0.tgz", - "integrity": "sha1-TlSRrRVy8vF6d9OIxshXE1sihHo=", + "resolved": "https://registry.npmjs.org/execa/-/execa-4.1.0.tgz", + "integrity": "sha512-j5W0//W7f8UxAn8hXVnwG8tLwdiUy4FJLcSupCg6maBYZDpyBvTApK7KyuI4bKj8KOh1r2YH+6ucuYtJv1bTZA==", "dev": true, "license": "MIT", "dependencies": { @@ -1527,15 +1449,15 @@ }, "node_modules/fast-deep-equal": { "version": "3.1.3", - "resolved": "https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet-public-npm/npm/registry/fast-deep-equal/-/fast-deep-equal-3.1.3.tgz", - "integrity": "sha1-On1WtVnWy8PrUSMlJE5hmmXGxSU=", + "resolved": "https://registry.npmjs.org/fast-deep-equal/-/fast-deep-equal-3.1.3.tgz", + "integrity": "sha512-f3qQ9oQy9j2AhBe/H9VC91wLmKBCCU/gDOnKNAYG5hswO7BLKj09Hc5HYNz9cGI++xlpDCIgDaitVs03ATR84Q==", "dev": true, "license": "MIT" }, "node_modules/fast-glob": { - "version": "3.3.2", - "resolved": "https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet-public-npm/npm/registry/fast-glob/-/fast-glob-3.3.2.tgz", - "integrity": "sha1-qQRQHlfP3S/83tRemaVP71XkYSk=", + "version": "3.3.3", + "resolved": "https://registry.npmjs.org/fast-glob/-/fast-glob-3.3.3.tgz", + "integrity": "sha512-7MptL8U0cqcFdzIzwOTHoilX9x5BrNqye7Z/LuC7kCMRio1EMSyqRK3BEAUD7sXRq4iT4AzTVuZdhgQ2TCvYLg==", "dev": true, "license": "MIT", "dependencies": { @@ -1543,7 +1465,7 @@ "@nodelib/fs.walk": "^1.2.3", "glob-parent": "^5.1.2", "merge2": "^1.3.0", - "micromatch": "^4.0.4" + "micromatch": "^4.0.8" }, "engines": { "node": ">=8.6.0" @@ -1551,8 +1473,8 @@ }, "node_modules/fast-glob/node_modules/glob-parent": { "version": "5.1.2", - "resolved": "https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet-public-npm/npm/registry/glob-parent/-/glob-parent-5.1.2.tgz", - "integrity": "sha1-hpgyxYA0/mikCTwX3BXoNA2EAcQ=", + "resolved": "https://registry.npmjs.org/glob-parent/-/glob-parent-5.1.2.tgz", + "integrity": "sha512-AOIgSQCepiJYwP3ARnGx+5VnTu2HBYdzbGP45eLw1vr3zB3vZLeyed1sC9hnbcOc9/SrMyM5RPQrkGz4aS9Zow==", "dev": true, "license": "ISC", "dependencies": { @@ -1564,22 +1486,22 @@ }, "node_modules/fast-json-stable-stringify": { "version": "2.1.0", - "resolved": "https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet-public-npm/npm/registry/fast-json-stable-stringify/-/fast-json-stable-stringify-2.1.0.tgz", - "integrity": "sha1-h0v2nG9ATCtdmcSBNBOZ/VWJJjM=", + "resolved": "https://registry.npmjs.org/fast-json-stable-stringify/-/fast-json-stable-stringify-2.1.0.tgz", + "integrity": "sha512-lhd/wF+Lk98HZoTCtlVraHtfh5XYijIjalXck7saUtuanSDyLMxnHhSXEDJqHxD7msR8D0uCmqlkwjCV8xvwHw==", "dev": true, "license": "MIT" }, "node_modules/fast-levenshtein": { "version": "2.0.6", - "resolved": "https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet-public-npm/npm/registry/fast-levenshtein/-/fast-levenshtein-2.0.6.tgz", - "integrity": "sha1-PYpcZog6FqMMqGQ+hR8Zuqd5eRc=", + "resolved": "https://registry.npmjs.org/fast-levenshtein/-/fast-levenshtein-2.0.6.tgz", + "integrity": "sha512-DCXu6Ifhqcks7TZKY3Hxp3y6qphY5SJZmrWMDrKcERSOXWQdMhU9Ig/PYrzyw/ul9jOIyh0N4M0tbC5hodg8dw==", "dev": true, "license": "MIT" }, "node_modules/fastq": { - "version": "1.17.1", - "resolved": "https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet-public-npm/npm/registry/fastq/-/fastq-1.17.1.tgz", - "integrity": "sha1-KlI/B6TnsegaQrkbi/IlQQd1O0c=", + "version": "1.19.1", + "resolved": "https://registry.npmjs.org/fastq/-/fastq-1.19.1.tgz", + "integrity": "sha512-GwLTyxkCXjXbxqIhTsMI2Nui8huMPtnxg7krajPJAjnEG/iiOS7i+zCtWGZR9G0NBKbXKh6X9m9UIsYX/N6vvQ==", "dev": true, "license": "ISC", "dependencies": { @@ -1588,8 +1510,8 @@ }, "node_modules/file-entry-cache": { "version": "6.0.1", - "resolved": "https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet-public-npm/npm/registry/file-entry-cache/-/file-entry-cache-6.0.1.tgz", - "integrity": "sha1-IRst2WWcsDlLBz5zI6w8kz1SICc=", + "resolved": "https://registry.npmjs.org/file-entry-cache/-/file-entry-cache-6.0.1.tgz", + "integrity": "sha512-7Gps/XWymbLk2QLYK4NzpMOrYjMhdIxXuIvy2QBsLE6ljuodKvdkWs/cpyJJ3CVIVpH0Oi1Hvg1ovbMzLdFBBg==", "dev": true, "license": "MIT", "dependencies": { @@ -1601,8 +1523,8 @@ }, "node_modules/fill-range": { "version": "7.1.1", - "resolved": "https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet-public-npm/npm/registry/fill-range/-/fill-range-7.1.1.tgz", - "integrity": "sha1-RCZdPKwH4+p9wkdRY4BkN1SgUpI=", + "resolved": "https://registry.npmjs.org/fill-range/-/fill-range-7.1.1.tgz", + "integrity": "sha512-YsGpe3WHLK8ZYi4tWDg2Jy3ebRz2rXowDxnld4bkQB00cc/1Zw9AWnC0i9ztDJitivtQvaI9KaLyKrc+hBW0yg==", "dev": true, "license": "MIT", "dependencies": { @@ -1614,8 +1536,8 @@ }, "node_modules/find-up": { "version": "5.0.0", - "resolved": "https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet-public-npm/npm/registry/find-up/-/find-up-5.0.0.tgz", - "integrity": "sha1-TJKBnstwg1YeT0okCoa+UZj1Nvw=", + "resolved": "https://registry.npmjs.org/find-up/-/find-up-5.0.0.tgz", + "integrity": "sha512-78/PXT1wlLLDgTzDs7sjq9hzz0vXD+zn+7wypEe4fXQxCmdmqfGsEPQxmiCSQI3ajFV91bVSsvNtrJRiW6nGng==", "dev": true, "license": "MIT", "dependencies": { @@ -1631,8 +1553,8 @@ }, "node_modules/flat-cache": { "version": "3.2.0", - "resolved": "https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet-public-npm/npm/registry/flat-cache/-/flat-cache-3.2.0.tgz", - "integrity": "sha1-LAwtUEDJmxYydxqdEFclwBFTY+4=", + "resolved": "https://registry.npmjs.org/flat-cache/-/flat-cache-3.2.0.tgz", + "integrity": "sha512-CYcENa+FtcUKLmhhqyctpclsq7QF38pKjZHsGNiSQF5r4FtoKDWabFDl3hzaEQMvT1LHEysw5twgLvpYYb4vbw==", "dev": true, "license": "MIT", "dependencies": { @@ -1645,24 +1567,25 @@ } }, "node_modules/flatted": { - "version": "3.3.1", - "resolved": "https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet-public-npm/npm/registry/flatted/-/flatted-3.3.1.tgz", - "integrity": "sha1-IdtHBymmc01JlwAvQ5yzCJh/Vno=", + "version": "3.3.3", + "resolved": "https://registry.npmjs.org/flatted/-/flatted-3.3.3.tgz", + "integrity": "sha512-GX+ysw4PBCz0PzosHDepZGANEuFCMLrnRTiEy9McGjmkCQYwRq4A/X786G/fjM/+OjsWSU1ZrY5qyARZmO/uwg==", "dev": true, "license": "ISC" }, "node_modules/fs.realpath": { "version": "1.0.0", - "resolved": "https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet-public-npm/npm/registry/fs.realpath/-/fs.realpath-1.0.0.tgz", - "integrity": "sha1-FQStJSMVjKpA20onh8sBQRmU6k8=", + "resolved": "https://registry.npmjs.org/fs.realpath/-/fs.realpath-1.0.0.tgz", + "integrity": "sha512-OO0pH2lK6a0hZnAdau5ItzHPI6pUlvI7jMVnxUQRtw4owF2wk8lOSabtGDCTP4Ggrg2MbGnWO9X8K1t4+fGMDw==", "dev": true, "license": "ISC" }, "node_modules/fsevents": { "version": "2.3.3", - "resolved": "https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet-public-npm/npm/registry/fsevents/-/fsevents-2.3.3.tgz", - "integrity": "sha1-ysZAd4XQNnWipeGlMFxpezR9kNY=", + "resolved": "https://registry.npmjs.org/fsevents/-/fsevents-2.3.3.tgz", + "integrity": "sha512-5xoDfX+fL7faATnagmWPpbFtwh/R77WmMMqqHGS65C3vvB0YHrgF+B1YmZ3441tMj5n63k0212XNoJwzlhffQw==", "dev": true, + "hasInstallScript": true, "license": "MIT", "optional": true, "os": [ @@ -1674,8 +1597,8 @@ }, "node_modules/function-bind": { "version": "1.1.2", - "resolved": "https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet-public-npm/npm/registry/function-bind/-/function-bind-1.1.2.tgz", - "integrity": "sha1-LALYZNl/PqbIgwxGTL0Rq26rehw=", + "resolved": "https://registry.npmjs.org/function-bind/-/function-bind-1.1.2.tgz", + "integrity": "sha512-7XHNxH7qX9xG5mIwxkhumTox/MIRNcOgDrxWsMt2pAr23WHp6MrRlN7FBSFpCpr+oVO0F744iUgR82nJMfG2SA==", "dev": true, "license": "MIT", "funding": { @@ -1684,8 +1607,8 @@ }, "node_modules/get-stream": { "version": "5.2.0", - "resolved": "https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet-public-npm/npm/registry/get-stream/-/get-stream-5.2.0.tgz", - "integrity": "sha1-SWaheV7lrOZecGxLe+txJX1uItM=", + "resolved": "https://registry.npmjs.org/get-stream/-/get-stream-5.2.0.tgz", + "integrity": "sha512-nBF+F1rAZVCu/p7rjzgA+Yb4lfYXrpl7a6VmJrU8wF9I1CKvP/QwPNZHnOlwbTkY6dvtFIzFMSyQXbLoTQPRpA==", "dev": true, "license": "MIT", "dependencies": { @@ -1700,8 +1623,8 @@ }, "node_modules/git-commit-info": { "version": "2.0.2", - "resolved": "https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet-public-npm/npm/registry/git-commit-info/-/git-commit-info-2.0.2.tgz", - "integrity": "sha1-XrAre34zk+zq+6KsIH3l2ceMzxs=", + "resolved": "https://registry.npmjs.org/git-commit-info/-/git-commit-info-2.0.2.tgz", + "integrity": "sha512-QOgPqeTkFiIQr3TW/ekG2U6s1x7OkNdR+2XsapmXHiGImO5Qx2cilx2HmGPrihIqmV0WWCo5H+B938lQ/vAAfA==", "dev": true, "license": "MIT", "dependencies": { @@ -1712,8 +1635,9 @@ }, "node_modules/glob": { "version": "7.2.3", - "resolved": "https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet-public-npm/npm/registry/glob/-/glob-7.2.3.tgz", - "integrity": "sha1-uN8PuAK7+o6JvR2Ti04WV47UTys=", + "resolved": "https://registry.npmjs.org/glob/-/glob-7.2.3.tgz", + "integrity": "sha512-nFR0zLpU2YCaRxwoCJvL6UvCH2JFyFVIvwTLsIf21AuHlMskA1hhTdk+LlYJtOlYt9v6dvszD2BGRqBL+iQK9Q==", + "deprecated": "Glob versions prior to v9 are no longer supported", "dev": true, "license": "ISC", "dependencies": { @@ -1733,8 +1657,8 @@ }, "node_modules/glob-parent": { "version": "6.0.2", - "resolved": "https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet-public-npm/npm/registry/glob-parent/-/glob-parent-6.0.2.tgz", - "integrity": "sha1-bSN9mQg5UMeSkPJMdkKj3poo+eM=", + "resolved": "https://registry.npmjs.org/glob-parent/-/glob-parent-6.0.2.tgz", + "integrity": "sha512-XxwI8EOhVQgWp6iDL+3b0r86f4d6AX6zSU55HfB4ydCEuXLXc5FcYeOu+nnGftS4TEju/11rt4KJPTMgbfmv4A==", "dev": true, "license": "ISC", "dependencies": { @@ -1744,6 +1668,46 @@ "node": ">=10.13.0" } }, + "node_modules/glob/node_modules/brace-expansion": { + "version": "1.1.12", + "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.12.tgz", + "integrity": "sha512-9T9UjW3r0UW5c1Q7GTwllptXwhvYmEzFhzMfZ9H7FQWt+uZePjZPjBP/W1ZEyZ1twGWom5/56TF4lPcqjnDHcg==", + "dev": true, + "license": "MIT", + "dependencies": { + "balanced-match": "^1.0.0", + "concat-map": "0.0.1" + } + }, + "node_modules/glob/node_modules/minimatch": { + "version": "3.1.2", + "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.1.2.tgz", + "integrity": "sha512-J7p63hRiAjw1NDEww1W7i37+ByIrOWO5XQQAzZ3VOcL0PNybwpfmV/N05zFAzwQ9USyEcX6t3UO+K5aqBQOIHw==", + "dev": true, + "license": "ISC", + "dependencies": { + "brace-expansion": "^1.1.7" + }, + "engines": { + "node": "*" + } + }, + "node_modules/globals": { + "version": "13.24.0", + "resolved": "https://registry.npmjs.org/globals/-/globals-13.24.0.tgz", + "integrity": "sha512-AhO5QUcj8llrbG09iWhPU2B204J1xnPeL8kQmVorSsy+Sjj1sk8gIyh6cUocGmH4L0UuhAJy+hJMRA4mgA4mFQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "type-fest": "^0.20.2" + }, + "engines": { + "node": ">=8" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, "node_modules/globby": { "version": "11.1.0", "resolved": "https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet-public-npm/npm/registry/globby/-/globby-11.1.0.tgz", @@ -1765,24 +1729,17 @@ "url": "https://github.com/sponsors/sindresorhus" } }, - "node_modules/grapheme-splitter": { - "version": "1.0.4", - "resolved": "https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet-public-npm/npm/registry/grapheme-splitter/-/grapheme-splitter-1.0.4.tgz", - "integrity": "sha1-nPOmZcYkdHmJaDSvNc8du0QAdn4=", - "dev": true, - "license": "MIT" - }, "node_modules/graphemer": { "version": "1.4.0", - "resolved": "https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet-public-npm/npm/registry/graphemer/-/graphemer-1.4.0.tgz", - "integrity": "sha1-+y8dVeDjoYSa7/yQxPoN1ToOZsY=", + "resolved": "https://registry.npmjs.org/graphemer/-/graphemer-1.4.0.tgz", + "integrity": "sha512-EtKwoO6kxCL9WO5xipiHTZlSzBm7WLT627TqC/uVRd0HKmq8NXyebnNYxDoBi7wt8eTWrUrKXCOVaFq9x1kgag==", "dev": true, "license": "MIT" }, "node_modules/has-flag": { "version": "4.0.0", - "resolved": "https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet-public-npm/npm/registry/has-flag/-/has-flag-4.0.0.tgz", - "integrity": "sha1-lEdx/ZyByBJlxNaUGGDaBrtZR5s=", + "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-4.0.0.tgz", + "integrity": "sha512-EykJT/Q1KjTWctppgIAgfSO0tKVuZUjhgMr17kqTumMl6Afv3EISleU7qZUzoXDFTAHTDC4NOoG/ZxU3EvlMPQ==", "dev": true, "license": "MIT", "engines": { @@ -1791,8 +1748,8 @@ }, "node_modules/hasown": { "version": "2.0.2", - "resolved": "https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet-public-npm/npm/registry/hasown/-/hasown-2.0.2.tgz", - "integrity": "sha1-AD6vkb563DcuhOxZ3DclLO24AAM=", + "resolved": "https://registry.npmjs.org/hasown/-/hasown-2.0.2.tgz", + "integrity": "sha512-0hJU9SCPvmMzIBdZFqNPXWa6dqh7WdH0cII9y+CyS8rG3nL48Bclra9HmKhVVUHyPWNH5Y7xDwAB7bfgSjkUMQ==", "dev": true, "license": "MIT", "dependencies": { @@ -1804,8 +1761,8 @@ }, "node_modules/human-signals": { "version": "1.1.1", - "resolved": "https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet-public-npm/npm/registry/human-signals/-/human-signals-1.1.1.tgz", - "integrity": "sha1-xbHNFPUK6uCatsWf5jujOV/k36M=", + "resolved": "https://registry.npmjs.org/human-signals/-/human-signals-1.1.1.tgz", + "integrity": "sha512-SEQu7vl8KjNL2eoGBLF3+wAjpsNfA9XMlXAYj/3EdaNfAlxKthD1xjEQfGOUhllCGGJVNY34bRr6lPINhNjyZw==", "dev": true, "license": "Apache-2.0", "engines": { @@ -1813,9 +1770,9 @@ } }, "node_modules/ignore": { - "version": "5.3.1", - "resolved": "https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet-public-npm/npm/registry/ignore/-/ignore-5.3.1.tgz", - "integrity": "sha1-UHPlVM1CxbM7OUN19Ti4WT401O8=", + "version": "5.3.2", + "resolved": "https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet-public-npm/npm/registry/ignore/-/ignore-5.3.2.tgz", + "integrity": "sha1-PNQOcp82Q/2HywTlC/DrcivFlvU=", "dev": true, "license": "MIT", "engines": { @@ -1823,9 +1780,9 @@ } }, "node_modules/import-fresh": { - "version": "3.3.0", - "resolved": "https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet-public-npm/npm/registry/import-fresh/-/import-fresh-3.3.0.tgz", - "integrity": "sha1-NxYsJfy566oublPVtNiM4X2eDCs=", + "version": "3.3.1", + "resolved": "https://registry.npmjs.org/import-fresh/-/import-fresh-3.3.1.tgz", + "integrity": "sha512-TR3KfrTZTYLPB6jUjfx6MF9WcWrHL9su5TObK4ZkYgBdWKPOFoSoQIdEuTuR82pmtxH2spWG9h6etwfr1pLBqQ==", "dev": true, "license": "MIT", "dependencies": { @@ -1841,8 +1798,8 @@ }, "node_modules/imurmurhash": { "version": "0.1.4", - "resolved": "https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet-public-npm/npm/registry/imurmurhash/-/imurmurhash-0.1.4.tgz", - "integrity": "sha1-khi5srkoojixPcT7a21XbyMUU+o=", + "resolved": "https://registry.npmjs.org/imurmurhash/-/imurmurhash-0.1.4.tgz", + "integrity": "sha512-JmXMZ6wuvDmLiHEml9ykzqO6lwFbof0GG4IkcGaENdCRDDmMVnny7s5HsIgHCbaq0w2MyPhDqkhTUgS2LU2PHA==", "dev": true, "license": "MIT", "engines": { @@ -1851,8 +1808,9 @@ }, "node_modules/inflight": { "version": "1.0.6", - "resolved": "https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet-public-npm/npm/registry/inflight/-/inflight-1.0.6.tgz", - "integrity": "sha1-Sb1jMdfQLQwJvJEKEHW6gWW1bfk=", + "resolved": "https://registry.npmjs.org/inflight/-/inflight-1.0.6.tgz", + "integrity": "sha512-k92I/b08q4wvFscXCLvqfsHCrjrF7yiXsQuIVvVE7N82W3+aqpzuUdBbfhWcy/FZR3/4IgflMgKLOsvPDrGCJA==", + "deprecated": "This module is not supported, and leaks memory. Do not use it. Check out lru-cache if you want a good and tested way to coalesce async requests by a key value, which is much more comprehensive and powerful.", "dev": true, "license": "ISC", "dependencies": { @@ -1862,35 +1820,22 @@ }, "node_modules/inherits": { "version": "2.0.4", - "resolved": "https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet-public-npm/npm/registry/inherits/-/inherits-2.0.4.tgz", - "integrity": "sha1-D6LGT5MpF8NDOg3tVTY6rjdBa3w=", + "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.4.tgz", + "integrity": "sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ==", "dev": true, "license": "ISC" }, - "node_modules/is-builtin-module": { - "version": "3.2.1", - "resolved": "https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet-public-npm/npm/registry/is-builtin-module/-/is-builtin-module-3.2.1.tgz", - "integrity": "sha1-8DJxcX2GVM/K8HqwRj+qNXFYEWk=", + "node_modules/is-core-module": { + "version": "2.16.1", + "resolved": "https://registry.npmjs.org/is-core-module/-/is-core-module-2.16.1.tgz", + "integrity": "sha512-UfoeMA6fIJ8wTYFEUjelnaGI67v6+N7qXJEvQuIGa99l4xsCruSYOVSQ0uPANn4dAzm8lkYPaKLrrijLq7x23w==", "dev": true, "license": "MIT", "dependencies": { - "builtin-modules": "^3.3.0" + "hasown": "^2.0.2" }, "engines": { - "node": ">=6" - }, - "funding": { - "url": "https://github.com/sponsors/sindresorhus" - } - }, - "node_modules/is-core-module": { - "version": "2.13.1", - "resolved": "https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet-public-npm/npm/registry/is-core-module/-/is-core-module-2.13.1.tgz", - "integrity": "sha1-rQ11Msb+qdoevcgnQtdFJcYnM4Q=", - "dev": true, - "license": "MIT", - "dependencies": { - "hasown": "^2.0.0" + "node": ">= 0.4" }, "funding": { "url": "https://github.com/sponsors/ljharb" @@ -1898,8 +1843,8 @@ }, "node_modules/is-extglob": { "version": "2.1.1", - "resolved": "https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet-public-npm/npm/registry/is-extglob/-/is-extglob-2.1.1.tgz", - "integrity": "sha1-qIwCU1eR8C7TfHahueqXc8gz+MI=", + "resolved": "https://registry.npmjs.org/is-extglob/-/is-extglob-2.1.1.tgz", + "integrity": "sha512-SbKbANkN603Vi4jEZv49LeVJMn4yGwsbzZworEoyEiutsN3nJYdbO36zfhGJ6QEDpOZIFkDtnq5JRxmvl3jsoQ==", "dev": true, "license": "MIT", "engines": { @@ -1908,8 +1853,8 @@ }, "node_modules/is-git-repository": { "version": "1.1.1", - "resolved": "https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet-public-npm/npm/registry/is-git-repository/-/is-git-repository-1.1.1.tgz", - "integrity": "sha1-xo5LeoBkIjSarsSIlzqQVY1+m+A=", + "resolved": "https://registry.npmjs.org/is-git-repository/-/is-git-repository-1.1.1.tgz", + "integrity": "sha512-hxLpJytJnIZ5Og5QsxSkzmb8Qx8rGau9bio1JN/QtXcGEFuSsQYau0IiqlsCwftsfVYjF1mOq6uLdmwNSspgpA==", "dev": true, "license": "MIT", "dependencies": { @@ -1917,22 +1862,10 @@ "path-is-absolute": "^1.0.1" } }, - "node_modules/is-git-repository/node_modules/cross-spawn": { - "version": "5.1.0", - "resolved": "https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet-public-npm/npm/registry/cross-spawn/-/cross-spawn-5.1.0.tgz", - "integrity": "sha1-6L0O/uWPz/b4+UUQoKVUu/ojVEk=", - "dev": true, - "license": "MIT", - "dependencies": { - "lru-cache": "^4.0.1", - "shebang-command": "^1.2.0", - "which": "^1.2.9" - } - }, "node_modules/is-git-repository/node_modules/execa": { "version": "0.6.3", - "resolved": "https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet-public-npm/npm/registry/execa/-/execa-0.6.3.tgz", - "integrity": "sha1-V7aaWU8IF1nGnlNw8NF7nLEWWP4=", + "resolved": "https://registry.npmjs.org/execa/-/execa-0.6.3.tgz", + "integrity": "sha512-/teX3MDLFBdYUhRk8WCBYboIMUmqeizu0m9Z3YF3JWrbEh/SlZg00vLJSaAGWw3wrZ9tE0buNw79eaAPYhUuvg==", "dev": true, "license": "MIT", "dependencies": { @@ -1950,8 +1883,8 @@ }, "node_modules/is-git-repository/node_modules/get-stream": { "version": "3.0.0", - "resolved": "https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet-public-npm/npm/registry/get-stream/-/get-stream-3.0.0.tgz", - "integrity": "sha1-jpQ9E1jcN1VQVOy+LtsFqhdO3hQ=", + "resolved": "https://registry.npmjs.org/get-stream/-/get-stream-3.0.0.tgz", + "integrity": "sha512-GlhdIUuVakc8SJ6kK0zAFbiGzRFzNnY4jUuEbV9UROo4Y+0Ny4fjvcZFVTeDA4odpFyOQzaw6hXukJSq/f28sQ==", "dev": true, "license": "MIT", "engines": { @@ -1960,8 +1893,8 @@ }, "node_modules/is-git-repository/node_modules/is-stream": { "version": "1.1.0", - "resolved": "https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet-public-npm/npm/registry/is-stream/-/is-stream-1.1.0.tgz", - "integrity": "sha1-EtSj3U5o4Lec6428hBc66A2RykQ=", + "resolved": "https://registry.npmjs.org/is-stream/-/is-stream-1.1.0.tgz", + "integrity": "sha512-uQPm8kcs47jx38atAcWTVxyltQYoPT68y9aWYdV6yWXSyW8mzSat0TL6CiWdZeCdF3KrAvpVtnHbTv4RN+rqdQ==", "dev": true, "license": "MIT", "engines": { @@ -1970,8 +1903,8 @@ }, "node_modules/is-git-repository/node_modules/npm-run-path": { "version": "2.0.2", - "resolved": "https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet-public-npm/npm/registry/npm-run-path/-/npm-run-path-2.0.2.tgz", - "integrity": "sha1-NakjLfo11wZ7TLLd8jV7GHFTbF8=", + "resolved": "https://registry.npmjs.org/npm-run-path/-/npm-run-path-2.0.2.tgz", + "integrity": "sha512-lJxZYlT4DW/bRUtFh1MQIWqmLwQfAxnqWG4HhEdjMlkrJYnJn0Jrr2u3mgxqaWsdiBc76TYkTG/mhrnYTuzfHw==", "dev": true, "license": "MIT", "dependencies": { @@ -1983,54 +1916,18 @@ }, "node_modules/is-git-repository/node_modules/path-key": { "version": "2.0.1", - "resolved": "https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet-public-npm/npm/registry/path-key/-/path-key-2.0.1.tgz", - "integrity": "sha1-QRyttXTFoUDTpLGRDUDYDMn0C0A=", + "resolved": "https://registry.npmjs.org/path-key/-/path-key-2.0.1.tgz", + "integrity": "sha512-fEHGKCSmUSDPv4uoj8AlD+joPlq3peND+HRYyxFz4KPw4z926S/b8rIuFs2FYJg3BwsxJf6A9/3eIdLaYC+9Dw==", "dev": true, "license": "MIT", "engines": { "node": ">=4" } }, - "node_modules/is-git-repository/node_modules/shebang-command": { - "version": "1.2.0", - "resolved": "https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet-public-npm/npm/registry/shebang-command/-/shebang-command-1.2.0.tgz", - "integrity": "sha1-RKrGW2lbAzmJaMOfNj/uXer98eo=", - "dev": true, - "license": "MIT", - "dependencies": { - "shebang-regex": "^1.0.0" - }, - "engines": { - "node": ">=0.10.0" - } - }, - "node_modules/is-git-repository/node_modules/shebang-regex": { - "version": "1.0.0", - "resolved": "https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet-public-npm/npm/registry/shebang-regex/-/shebang-regex-1.0.0.tgz", - "integrity": "sha1-2kL0l0DAtC2yypcoVxyxkMmO/qM=", - "dev": true, - "license": "MIT", - "engines": { - "node": ">=0.10.0" - } - }, - "node_modules/is-git-repository/node_modules/which": { - "version": "1.3.1", - "resolved": "https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet-public-npm/npm/registry/which/-/which-1.3.1.tgz", - "integrity": "sha1-pFBD1U9YBTFtqNYvn1CRjT2nCwo=", - "dev": true, - "license": "ISC", - "dependencies": { - "isexe": "^2.0.0" - }, - "bin": { - "which": "bin/which" - } - }, "node_modules/is-glob": { "version": "4.0.3", - "resolved": "https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet-public-npm/npm/registry/is-glob/-/is-glob-4.0.3.tgz", - "integrity": "sha1-ZPYeQsu7LuwgcanawLKLoeZdUIQ=", + "resolved": "https://registry.npmjs.org/is-glob/-/is-glob-4.0.3.tgz", + "integrity": "sha512-xelSayHH36ZgE7ZWhli7pW34hNbNl8Ojv5KVmkJD4hBdD3th8Tfk9vYasLM+mXWOZhFkgZfxhLSnrwRr4elSSg==", "dev": true, "license": "MIT", "dependencies": { @@ -2042,15 +1939,15 @@ }, "node_modules/is-module": { "version": "1.0.0", - "resolved": "https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet-public-npm/npm/registry/is-module/-/is-module-1.0.0.tgz", - "integrity": "sha1-Mlj7afeMFNW4FdZkM2tM/7ZEFZE=", + "resolved": "https://registry.npmjs.org/is-module/-/is-module-1.0.0.tgz", + "integrity": "sha512-51ypPSPCoTEIN9dy5Oy+h4pShgJmPCygKfyRCISBI+JoWT/2oJvK8QPxmwv7b/p239jXrm9M1mlQbyKJ5A152g==", "dev": true, "license": "MIT" }, "node_modules/is-number": { "version": "7.0.0", - "resolved": "https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet-public-npm/npm/registry/is-number/-/is-number-7.0.0.tgz", - "integrity": "sha1-dTU0W4lnNNX4DE0GxQlVUnoU8Ss=", + "resolved": "https://registry.npmjs.org/is-number/-/is-number-7.0.0.tgz", + "integrity": "sha512-41Cifkg6e8TylSpdtTpeLVMqvSBEVzTttHvERD741+pnZ8ANv0004MRL43QKPDlK9cGvNp6NZWZUBlbGXYxxng==", "dev": true, "license": "MIT", "engines": { @@ -2059,8 +1956,8 @@ }, "node_modules/is-path-inside": { "version": "3.0.3", - "resolved": "https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet-public-npm/npm/registry/is-path-inside/-/is-path-inside-3.0.3.tgz", - "integrity": "sha1-0jE2LlOgf/Kw4Op/7QSRYf/RYoM=", + "resolved": "https://registry.npmjs.org/is-path-inside/-/is-path-inside-3.0.3.tgz", + "integrity": "sha512-Fd4gABb+ycGAmKou8eMftCupSir5lRxqf4aD/vd0cD2qc4HL07OjCeuHMr8Ro4CoMaeCKDB0/ECBOVWjTwUvPQ==", "dev": true, "license": "MIT", "engines": { @@ -2069,8 +1966,8 @@ }, "node_modules/is-stream": { "version": "2.0.1", - "resolved": "https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet-public-npm/npm/registry/is-stream/-/is-stream-2.0.1.tgz", - "integrity": "sha1-+sHj1TuXrVqdCunO8jifWBClwHc=", + "resolved": "https://registry.npmjs.org/is-stream/-/is-stream-2.0.1.tgz", + "integrity": "sha512-hFoiJiTl63nn+kstHGBtewWSKnQLpyb155KHheA1l39uvtO9nWIop1p3udqPcUd/xbF1VLMO4n7OI6p7RbngDg==", "dev": true, "license": "MIT", "engines": { @@ -2082,23 +1979,23 @@ }, "node_modules/isexe": { "version": "2.0.0", - "resolved": "https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet-public-npm/npm/registry/isexe/-/isexe-2.0.0.tgz", - "integrity": "sha1-6PvzdNxVb/iUehDcsFctYz8s+hA=", + "resolved": "https://registry.npmjs.org/isexe/-/isexe-2.0.0.tgz", + "integrity": "sha512-RHxMLp9lnKHGHRng9QFhRCMbYAcVpn69smSGcq3f36xjgVVWThj4qqLbTLlq7Ssj8B+fIQ1EuCEGI2lKsyQeIw==", "dev": true, "license": "ISC" }, "node_modules/js-tokens": { "version": "4.0.0", - "resolved": "https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet-public-npm/npm/registry/js-tokens/-/js-tokens-4.0.0.tgz", - "integrity": "sha1-GSA/tZmR35jjoocFDUZHzerzJJk=", + "resolved": "https://registry.npmjs.org/js-tokens/-/js-tokens-4.0.0.tgz", + "integrity": "sha512-RdJUflcE3cUzKiMqQgsCu06FPu9UdIJO0beYbPhHN4k6apgJtifcoCtT9bcxOpYBtpD2kCM6Sbzg4CausW/PKQ==", "dev": true, "license": "MIT", "optional": true }, "node_modules/js-yaml": { "version": "4.1.0", - "resolved": "https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet-public-npm/npm/registry/js-yaml/-/js-yaml-4.1.0.tgz", - "integrity": "sha1-wftl+PUBeQHN0slRhkuhhFihBgI=", + "resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-4.1.0.tgz", + "integrity": "sha512-wpxZs9NoxZaJESJGIZTyDEaYpl0FKSA+FB9aJiyemKhMwkxQg63h4T1KJgUGHpTqPDNRcmmYLugrRjJlBtWvRA==", "dev": true, "license": "MIT", "dependencies": { @@ -2110,29 +2007,29 @@ }, "node_modules/json-buffer": { "version": "3.0.1", - "resolved": "https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet-public-npm/npm/registry/json-buffer/-/json-buffer-3.0.1.tgz", - "integrity": "sha1-kziAKjDTtmBfvgYT4JQAjKjAWhM=", + "resolved": "https://registry.npmjs.org/json-buffer/-/json-buffer-3.0.1.tgz", + "integrity": "sha512-4bV5BfR2mqfQTJm+V5tPPdf+ZpuhiIvTuAB5g8kcrXOZpTT/QwwVRWBywX1ozr6lEuPdbHxwaJlm9G6mI2sfSQ==", "dev": true, "license": "MIT" }, "node_modules/json-schema-traverse": { "version": "0.4.1", - "resolved": "https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet-public-npm/npm/registry/json-schema-traverse/-/json-schema-traverse-0.4.1.tgz", - "integrity": "sha1-afaofZUTq4u4/mO9sJecRI5oRmA=", + "resolved": "https://registry.npmjs.org/json-schema-traverse/-/json-schema-traverse-0.4.1.tgz", + "integrity": "sha512-xbbCH5dCYU5T8LcEhhuh7HJ88HXuW3qsI3Y0zOZFKfZEHcpWiHU/Jxzk629Brsab/mMiHQti9wMP+845RPe3Vg==", "dev": true, "license": "MIT" }, "node_modules/json-stable-stringify-without-jsonify": { "version": "1.0.1", - "resolved": "https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet-public-npm/npm/registry/json-stable-stringify-without-jsonify/-/json-stable-stringify-without-jsonify-1.0.1.tgz", - "integrity": "sha1-nbe1lJatPzz+8wp1FC0tkwrXJlE=", + "resolved": "https://registry.npmjs.org/json-stable-stringify-without-jsonify/-/json-stable-stringify-without-jsonify-1.0.1.tgz", + "integrity": "sha512-Bdboy+l7tA3OGW6FjyFHWkP5LuByj1Tk33Ljyq0axyzdk9//JSi2u3fP1QSmd1KNwq6VOKYGlAu87CisVir6Pw==", "dev": true, "license": "MIT" }, "node_modules/keyv": { "version": "4.5.4", - "resolved": "https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet-public-npm/npm/registry/keyv/-/keyv-4.5.4.tgz", - "integrity": "sha1-qHmpnilFL5QkOfKkBeOvizHU3pM=", + "resolved": "https://registry.npmjs.org/keyv/-/keyv-4.5.4.tgz", + "integrity": "sha512-oxVHkHR/EJf2CNXnWxRLW6mg7JyCCUcG0DtEGmL2ctUo1PNTin1PUil+r/+4r5MpVgC/fn1kjsx7mjSujKqIpw==", "dev": true, "license": "MIT", "dependencies": { @@ -2141,8 +2038,8 @@ }, "node_modules/levn": { "version": "0.4.1", - "resolved": "https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet-public-npm/npm/registry/levn/-/levn-0.4.1.tgz", - "integrity": "sha1-rkViwAdHO5MqYgDUAyaN0v/8at4=", + "resolved": "https://registry.npmjs.org/levn/-/levn-0.4.1.tgz", + "integrity": "sha512-+bT2uH4E5LGE7h/n3evcS/sQlJXCpIp6ym8OWJ5eV6+67Dsql/LaaT7qJBAt2rzfoa/5QBGBhxDix1dMt2kQKQ==", "dev": true, "license": "MIT", "dependencies": { @@ -2155,8 +2052,8 @@ }, "node_modules/locate-path": { "version": "6.0.0", - "resolved": "https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet-public-npm/npm/registry/locate-path/-/locate-path-6.0.0.tgz", - "integrity": "sha1-VTIeswn+u8WcSAHZMackUqaB0oY=", + "resolved": "https://registry.npmjs.org/locate-path/-/locate-path-6.0.0.tgz", + "integrity": "sha512-iPZK6eYjbxRu3uB4/WZ3EsEIMJFMqAoopl3R+zuq0UjcAm/MO6KCweDgPfP3elTztoKP3KtnVHxTn2NHBSDVUw==", "dev": true, "license": "MIT", "dependencies": { @@ -2171,43 +2068,32 @@ }, "node_modules/lodash.merge": { "version": "4.6.2", - "resolved": "https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet-public-npm/npm/registry/lodash.merge/-/lodash.merge-4.6.2.tgz", - "integrity": "sha1-VYqlO0O2YeGSWgr9+japoQhf5Xo=", + "resolved": "https://registry.npmjs.org/lodash.merge/-/lodash.merge-4.6.2.tgz", + "integrity": "sha512-0KpjqXRVvrYyCsX1swR/XTK0va6VQkQM6MNo7PqW77ByjAhoARA8EfrP1N4+KlKj8YS0ZUCtRT/YUuhyYDujIQ==", "dev": true, "license": "MIT" }, - "node_modules/lru-cache": { - "version": "4.1.5", - "resolved": "https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet-public-npm/npm/registry/lru-cache/-/lru-cache-4.1.5.tgz", - "integrity": "sha1-i75Q6oW+1ZvJ4z3KuCNe6bz0Q80=", - "dev": true, - "license": "ISC", - "dependencies": { - "pseudomap": "^1.0.2", - "yallist": "^2.1.2" - } - }, "node_modules/magic-string": { - "version": "0.30.10", - "resolved": "https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet-public-npm/npm/registry/magic-string/-/magic-string-0.30.10.tgz", - "integrity": "sha1-Ej2cQaDLVkDIkrBB1M+zvQqks54=", + "version": "0.30.19", + "resolved": "https://registry.npmjs.org/magic-string/-/magic-string-0.30.19.tgz", + "integrity": "sha512-2N21sPY9Ws53PZvsEpVtNuSW+ScYbQdp4b9qUaL+9QkHUrGFKo56Lg9Emg5s9V/qrtNBmiR01sYhUOwu3H+VOw==", "dev": true, "license": "MIT", "dependencies": { - "@jridgewell/sourcemap-codec": "^1.4.15" + "@jridgewell/sourcemap-codec": "^1.5.5" } }, "node_modules/merge-stream": { "version": "2.0.0", - "resolved": "https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet-public-npm/npm/registry/merge-stream/-/merge-stream-2.0.0.tgz", - "integrity": "sha1-UoI2KaFN0AyXcPtq1H3GMQ8sH2A=", + "resolved": "https://registry.npmjs.org/merge-stream/-/merge-stream-2.0.0.tgz", + "integrity": "sha512-abv/qOcuPfk3URPfDzmZU1LKmuw8kT+0nIHvKrKgFrwifol/doWcdA4ZqsWQ8ENrFKkd67Mfpo/LovbIUsbt3w==", "dev": true, "license": "MIT" }, "node_modules/merge2": { "version": "1.4.1", - "resolved": "https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet-public-npm/npm/registry/merge2/-/merge2-1.4.1.tgz", - "integrity": "sha1-Q2iJL4hekHRVpv19xVwMnUBJkK4=", + "resolved": "https://registry.npmjs.org/merge2/-/merge2-1.4.1.tgz", + "integrity": "sha512-8q7VEgMJW4J8tcfVPy8g09NcQwZdbwFEqhe/WZkoIzjn/3TGDwtOCYtXGxA3O8tPzpczCCDgv+P2P5y00ZJOOg==", "dev": true, "license": "MIT", "engines": { @@ -2215,9 +2101,9 @@ } }, "node_modules/micromatch": { - "version": "4.0.7", - "resolved": "https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet-public-npm/npm/registry/micromatch/-/micromatch-4.0.7.tgz", - "integrity": "sha1-M+gZDZ/kdKmJVSX1YY7uE21GwuU=", + "version": "4.0.8", + "resolved": "https://registry.npmjs.org/micromatch/-/micromatch-4.0.8.tgz", + "integrity": "sha512-PXwfBhYu0hBCPw8Dn0E+WDYb7af3dSLVWKi3HGv84IdF4TyFoC0ysxFd0Goxw7nSv4T/PzEJQxsYsEiFCKo2BA==", "dev": true, "license": "MIT", "dependencies": { @@ -2228,10 +2114,23 @@ "node": ">=8.6" } }, + "node_modules/micromatch/node_modules/picomatch": { + "version": "2.3.1", + "resolved": "https://registry.npmjs.org/picomatch/-/picomatch-2.3.1.tgz", + "integrity": "sha512-JU3teHTNjmE2VCGFzuY8EXzCDVwEqB2a8fsIvwaStHhAWJEeVd1o1QD80CU6+ZdEXXSLbSsuLwJjkCBWqRQUVA==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=8.6" + }, + "funding": { + "url": "https://github.com/sponsors/jonschlinkert" + } + }, "node_modules/mimic-fn": { "version": "2.1.0", - "resolved": "https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet-public-npm/npm/registry/mimic-fn/-/mimic-fn-2.1.0.tgz", - "integrity": "sha1-ftLCzMyvhNP/y3pptXcR/CCDQBs=", + "resolved": "https://registry.npmjs.org/mimic-fn/-/mimic-fn-2.1.0.tgz", + "integrity": "sha512-OqbOk5oEQeAZ8WXWydlu9HJjz9WVdEIvamMCcXmuqUYjTknH/sqsWvhQ3vgwKFRR1HpjvNBKQ37nbJgYzGqGcg==", "dev": true, "license": "MIT", "engines": { @@ -2239,43 +2138,39 @@ } }, "node_modules/minimatch": { - "version": "3.1.2", - "resolved": "https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet-public-npm/npm/registry/minimatch/-/minimatch-3.1.2.tgz", - "integrity": "sha1-Gc0ZS/0+Qo8EmnCBfAONiatL41s=", + "version": "9.0.3", + "resolved": "https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet-public-npm/npm/registry/minimatch/-/minimatch-9.0.3.tgz", + "integrity": "sha1-puAMPeRMOlQr+q5wq/wiQgptqCU=", "dev": true, "license": "ISC", "dependencies": { - "brace-expansion": "^1.1.7" + "brace-expansion": "^2.0.1" }, "engines": { - "node": "*" + "node": ">=16 || 14 >=14.17" + }, + "funding": { + "url": "https://github.com/sponsors/isaacs" } }, "node_modules/ms": { - "version": "2.1.2", - "resolved": "https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet-public-npm/npm/registry/ms/-/ms-2.1.2.tgz", - "integrity": "sha1-0J0fNXtEP0kzgqjrPM0YOHKuYAk=", + "version": "2.1.3", + "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.3.tgz", + "integrity": "sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA==", "dev": true, "license": "MIT" }, "node_modules/natural-compare": { "version": "1.4.0", - "resolved": "https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet-public-npm/npm/registry/natural-compare/-/natural-compare-1.4.0.tgz", - "integrity": "sha1-Sr6/7tdUHywnrPspvbvRXI1bpPc=", - "dev": true, - "license": "MIT" - }, - "node_modules/natural-compare-lite": { - "version": "1.4.0", - "resolved": "https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet-public-npm/npm/registry/natural-compare-lite/-/natural-compare-lite-1.4.0.tgz", - "integrity": "sha1-F7CVgZiJef3a/gIB6TG6kzyWy7Q=", + "resolved": "https://registry.npmjs.org/natural-compare/-/natural-compare-1.4.0.tgz", + "integrity": "sha512-OWND8ei3VtNC9h7V60qff3SVobHr996CTwgxubgyQYEpg290h9J0buyECNNJexkFm5sOajh5G116RYA1c8ZMSw==", "dev": true, "license": "MIT" }, "node_modules/npm-run-path": { "version": "4.0.1", - "resolved": "https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet-public-npm/npm/registry/npm-run-path/-/npm-run-path-4.0.1.tgz", - "integrity": "sha1-t+zR5e1T2o43pV4cImnguX7XSOo=", + "resolved": "https://registry.npmjs.org/npm-run-path/-/npm-run-path-4.0.1.tgz", + "integrity": "sha512-S48WzZW777zhNIrn7gxOlISNAqi9ZC/uQFnRdbeIHhZhCA6UqpkOT8T1G7BvfdgP4Er8gF4sUbaS0i7QvIfCWw==", "dev": true, "license": "MIT", "dependencies": { @@ -2287,8 +2182,8 @@ }, "node_modules/once": { "version": "1.4.0", - "resolved": "https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet-public-npm/npm/registry/once/-/once-1.4.0.tgz", - "integrity": "sha1-WDsap3WWHUsROsF9nFC6753Xa9E=", + "resolved": "https://registry.npmjs.org/once/-/once-1.4.0.tgz", + "integrity": "sha512-lNaJgI+2Q5URQBkccEKHTQOPaXdUxnZZElQTZY0MFUAuaEqe1E+Nyvgdz/aIyNi6Z9MzO5dv1H8n58/GELp3+w==", "dev": true, "license": "ISC", "dependencies": { @@ -2297,8 +2192,8 @@ }, "node_modules/onetime": { "version": "5.1.2", - "resolved": "https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet-public-npm/npm/registry/onetime/-/onetime-5.1.2.tgz", - "integrity": "sha1-0Oluu1awdHbfHdnEgG5SN5hcpF4=", + "resolved": "https://registry.npmjs.org/onetime/-/onetime-5.1.2.tgz", + "integrity": "sha512-kbpaSSGJTWdAY5KPVeMOKXSrPtr8C8C7wodJbcsd51jRnmD+GZu8Y0VoU6Dm5Z4vWr0Ig/1NKuWRKf7j5aaYSg==", "dev": true, "license": "MIT", "dependencies": { @@ -2313,8 +2208,8 @@ }, "node_modules/optionator": { "version": "0.9.4", - "resolved": "https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet-public-npm/npm/registry/optionator/-/optionator-0.9.4.tgz", - "integrity": "sha1-fqHBpdkddk+yghOciP4R4YKjpzQ=", + "resolved": "https://registry.npmjs.org/optionator/-/optionator-0.9.4.tgz", + "integrity": "sha512-6IpQ7mKUxRcZNLIObR0hz7lxsapSSIYNZJwXPGeF0mTVqGKFIXj1DQcMoT22S3ROcLyY/rz0PWaWZ9ayWmad9g==", "dev": true, "license": "MIT", "dependencies": { @@ -2331,8 +2226,8 @@ }, "node_modules/p-finally": { "version": "1.0.0", - "resolved": "https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet-public-npm/npm/registry/p-finally/-/p-finally-1.0.0.tgz", - "integrity": "sha1-P7z7FbiZpEEjs0ttzBi3JDNqLK4=", + "resolved": "https://registry.npmjs.org/p-finally/-/p-finally-1.0.0.tgz", + "integrity": "sha512-LICb2p9CB7FS+0eR1oqWnHhp0FljGLZCWBE9aix0Uye9W8LTQPwMTYVGWQWIw9RdQiDg4+epXQODwIYJtSJaow==", "dev": true, "license": "MIT", "engines": { @@ -2341,8 +2236,8 @@ }, "node_modules/p-limit": { "version": "3.1.0", - "resolved": "https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet-public-npm/npm/registry/p-limit/-/p-limit-3.1.0.tgz", - "integrity": "sha1-4drMvnjQ0TiMoYxk/qOOPlfjcGs=", + "resolved": "https://registry.npmjs.org/p-limit/-/p-limit-3.1.0.tgz", + "integrity": "sha512-TYOanM3wGwNGsZN2cVTYPArw454xnXj5qmWF1bEoAc4+cU/ol7GVh7odevjp1FNHduHc3KZMcFduxU5Xc6uJRQ==", "dev": true, "license": "MIT", "dependencies": { @@ -2357,8 +2252,8 @@ }, "node_modules/p-locate": { "version": "5.0.0", - "resolved": "https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet-public-npm/npm/registry/p-locate/-/p-locate-5.0.0.tgz", - "integrity": "sha1-g8gxXGeFAF470CGDlBHJ4RDm2DQ=", + "resolved": "https://registry.npmjs.org/p-locate/-/p-locate-5.0.0.tgz", + "integrity": "sha512-LaNjtRWUBY++zB5nE/NwcaoMylSPk+S+ZHNB1TzdbMJMny6dynpAGt7X/tl/QYq3TIeE6nxHppbo2LGymrG5Pw==", "dev": true, "license": "MIT", "dependencies": { @@ -2373,8 +2268,8 @@ }, "node_modules/parent-module": { "version": "1.0.1", - "resolved": "https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet-public-npm/npm/registry/parent-module/-/parent-module-1.0.1.tgz", - "integrity": "sha1-aR0nCeeMefrjoVZiJFLQB2LKqqI=", + "resolved": "https://registry.npmjs.org/parent-module/-/parent-module-1.0.1.tgz", + "integrity": "sha512-GQ2EWRpQV8/o+Aw8YqtfZZPfNRWZYkbidE9k5rpl/hC3vtHHBfGm2Ifi6qWV+coDGkrUKZAxE3Lot5kcsRlh+g==", "dev": true, "license": "MIT", "dependencies": { @@ -2386,8 +2281,8 @@ }, "node_modules/path-exists": { "version": "4.0.0", - "resolved": "https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet-public-npm/npm/registry/path-exists/-/path-exists-4.0.0.tgz", - "integrity": "sha1-UTvb4tO5XXdi6METfvoZXGxhtbM=", + "resolved": "https://registry.npmjs.org/path-exists/-/path-exists-4.0.0.tgz", + "integrity": "sha512-ak9Qy5Q7jYb2Wwcey5Fpvg2KoAc/ZIhLSLOSBmRmygPsGwkVVt0fZa0qrtMz+m6tJTAHfZQ8FnmB4MG4LWy7/w==", "dev": true, "license": "MIT", "engines": { @@ -2396,8 +2291,8 @@ }, "node_modules/path-is-absolute": { "version": "1.0.1", - "resolved": "https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet-public-npm/npm/registry/path-is-absolute/-/path-is-absolute-1.0.1.tgz", - "integrity": "sha1-F0uSaHNVNP+8es5r9TpanhtcX18=", + "resolved": "https://registry.npmjs.org/path-is-absolute/-/path-is-absolute-1.0.1.tgz", + "integrity": "sha512-AVbw3UJ2e9bq64vSaS9Am0fje1Pa8pbGqTTsmXfaIiMpnr5DlDhfJOuLj9Sf95ZPVDAUerDfEk88MPmPe7UCQg==", "dev": true, "license": "MIT", "engines": { @@ -2406,8 +2301,8 @@ }, "node_modules/path-key": { "version": "3.1.1", - "resolved": "https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet-public-npm/npm/registry/path-key/-/path-key-3.1.1.tgz", - "integrity": "sha1-WB9q3mWMu6ZaDTOA3ndTKVBU83U=", + "resolved": "https://registry.npmjs.org/path-key/-/path-key-3.1.1.tgz", + "integrity": "sha512-ojmeN0qd+y0jszEtoY48r0Peq5dwMEkIlCOu6Q5f41lfkswXuKtYrhgoTpLnyIcHm24Uhqx+5Tqm2InSwLhE6Q==", "dev": true, "license": "MIT", "engines": { @@ -2416,8 +2311,8 @@ }, "node_modules/path-parse": { "version": "1.0.7", - "resolved": "https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet-public-npm/npm/registry/path-parse/-/path-parse-1.0.7.tgz", - "integrity": "sha1-+8EUtgykKzDZ2vWFjkvWi77bZzU=", + "resolved": "https://registry.npmjs.org/path-parse/-/path-parse-1.0.7.tgz", + "integrity": "sha512-LDJzPVEEEPR+y48z93A0Ed0yXb8pAByGWo/k5YYdYgpY2/2EsOsksJrq7lOHxryrVOn1ejG6oAp8ahvOIQD8sw==", "dev": true, "license": "MIT" }, @@ -2432,21 +2327,21 @@ } }, "node_modules/picocolors": { - "version": "1.0.1", - "resolved": "https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet-public-npm/npm/registry/picocolors/-/picocolors-1.0.1.tgz", - "integrity": "sha1-qK1Xm1cZUvDl0liS3lRFvP4lqqE=", + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/picocolors/-/picocolors-1.1.1.tgz", + "integrity": "sha512-xceH2snhtb5M9liqDsmEw56le376mTZkEX/jEb/RxNFyegNul7eNslCXP9FDj/Lcu0X8KEyMceP2ntpaHrDEVA==", "dev": true, "license": "ISC", "optional": true }, "node_modules/picomatch": { - "version": "2.3.1", - "resolved": "https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet-public-npm/npm/registry/picomatch/-/picomatch-2.3.1.tgz", - "integrity": "sha1-O6ODNzNkbZ0+SZWUbBNlpn+wekI=", + "version": "4.0.3", + "resolved": "https://registry.npmjs.org/picomatch/-/picomatch-4.0.3.tgz", + "integrity": "sha512-5gTmgEY/sqK6gFXLIsQNH19lWb4ebPDLA4SdLP7dsWkIXHWlG66oPuVvXSGFPppYZz8ZDZq0dYYrbHfBCVUb1Q==", "dev": true, "license": "MIT", "engines": { - "node": ">=8.6" + "node": ">=12" }, "funding": { "url": "https://github.com/sponsors/jonschlinkert" @@ -2454,25 +2349,18 @@ }, "node_modules/prelude-ls": { "version": "1.2.1", - "resolved": "https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet-public-npm/npm/registry/prelude-ls/-/prelude-ls-1.2.1.tgz", - "integrity": "sha1-3rxkidem5rDnYRiIzsiAM30xY5Y=", + "resolved": "https://registry.npmjs.org/prelude-ls/-/prelude-ls-1.2.1.tgz", + "integrity": "sha512-vkcDPrRZo1QZLbn5RLGPpg/WmIQ65qoWWhcGKf/b5eplkkarX0m9z8ppCat4mlOqUsWpyNuYgO3VRyrYHSzX5g==", "dev": true, "license": "MIT", "engines": { "node": ">= 0.8.0" } }, - "node_modules/pseudomap": { - "version": "1.0.2", - "resolved": "https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet-public-npm/npm/registry/pseudomap/-/pseudomap-1.0.2.tgz", - "integrity": "sha1-8FKijacOYYkX7wqKw0wa5aaChrM=", - "dev": true, - "license": "ISC" - }, "node_modules/pump": { - "version": "3.0.0", - "resolved": "https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet-public-npm/npm/registry/pump/-/pump-3.0.0.tgz", - "integrity": "sha1-tKIRaBW94vTh6mAjVOjHVWUQemQ=", + "version": "3.0.3", + "resolved": "https://registry.npmjs.org/pump/-/pump-3.0.3.tgz", + "integrity": "sha512-todwxLMY7/heScKmntwQG8CXVkWUOdYxIvY2s0VWAAMh/nd8SoYiRaKjlr7+iCs984f2P8zvrfWcDDYVb73NfA==", "dev": true, "license": "MIT", "dependencies": { @@ -2482,8 +2370,8 @@ }, "node_modules/punycode": { "version": "2.3.1", - "resolved": "https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet-public-npm/npm/registry/punycode/-/punycode-2.3.1.tgz", - "integrity": "sha1-AnQi4vrsCyXhVJw+G9gwm5EztuU=", + "resolved": "https://registry.npmjs.org/punycode/-/punycode-2.3.1.tgz", + "integrity": "sha512-vYt7UD1U9Wg6138shLtLOvdAu+8DsC/ilFtEVHcH+wydcSpNE20AfSOduf6MkRFahL5FY7X1oU7nKVZFtfq8Fg==", "dev": true, "license": "MIT", "engines": { @@ -2492,8 +2380,8 @@ }, "node_modules/queue-microtask": { "version": "1.2.3", - "resolved": "https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet-public-npm/npm/registry/queue-microtask/-/queue-microtask-1.2.3.tgz", - "integrity": "sha1-SSkii7xyTfrEPg77BYyve2z7YkM=", + "resolved": "https://registry.npmjs.org/queue-microtask/-/queue-microtask-1.2.3.tgz", + "integrity": "sha512-NuaNSa6flKT5JaSYQzJok04JzTL1CA6aGhv5rfLW3PgqA+M2ChpZQnAC8h8i4ZFkBS8X5RqkDBHA7r4hej3K9A==", "dev": true, "funding": [ { @@ -2513,8 +2401,8 @@ }, "node_modules/randombytes": { "version": "2.1.0", - "resolved": "https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet-public-npm/npm/registry/randombytes/-/randombytes-2.1.0.tgz", - "integrity": "sha1-32+ENy8CcNxlzfYpE0mrekc9Tyo=", + "resolved": "https://registry.npmjs.org/randombytes/-/randombytes-2.1.0.tgz", + "integrity": "sha512-vYl3iOX+4CKUWuxGi9Ukhie6fsqXqS9FE2Zaic4tNFD2N2QQaXOMFbuKK4QmDHC0JO6B1Zp41J0LpT0oR68amQ==", "dev": true, "license": "MIT", "dependencies": { @@ -2522,27 +2410,30 @@ } }, "node_modules/resolve": { - "version": "1.22.8", - "resolved": "https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet-public-npm/npm/registry/resolve/-/resolve-1.22.8.tgz", - "integrity": "sha1-tsh6nyqgbfq1Lj1wrIzeMh+lpI0=", + "version": "1.22.10", + "resolved": "https://registry.npmjs.org/resolve/-/resolve-1.22.10.tgz", + "integrity": "sha512-NPRy+/ncIMeDlTAsuqwKIiferiawhefFJtkNSW0qZJEqMEb+qBt/77B/jGeeek+F0uOeN05CDa6HXbbIgtVX4w==", "dev": true, "license": "MIT", "dependencies": { - "is-core-module": "^2.13.0", + "is-core-module": "^2.16.0", "path-parse": "^1.0.7", "supports-preserve-symlinks-flag": "^1.0.0" }, "bin": { "resolve": "bin/resolve" }, + "engines": { + "node": ">= 0.4" + }, "funding": { "url": "https://github.com/sponsors/ljharb" } }, "node_modules/resolve-from": { "version": "4.0.0", - "resolved": "https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet-public-npm/npm/registry/resolve-from/-/resolve-from-4.0.0.tgz", - "integrity": "sha1-SrzYUq0y3Xuqv+m0DgCjbbXzkuY=", + "resolved": "https://registry.npmjs.org/resolve-from/-/resolve-from-4.0.0.tgz", + "integrity": "sha512-pb/MYmXstAkysRFx8piNI1tGFNQIFA3vkE3Gq4EuA1dF6gHp/+vgZqsCGJapvy8N3Q+4o7FwvquPJcnZ7RYy4g==", "dev": true, "license": "MIT", "engines": { @@ -2550,9 +2441,9 @@ } }, "node_modules/reusify": { - "version": "1.0.4", - "resolved": "https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet-public-npm/npm/registry/reusify/-/reusify-1.0.4.tgz", - "integrity": "sha1-kNo4Kx4SbvwCFG6QhFqI2xKSXXY=", + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/reusify/-/reusify-1.1.0.tgz", + "integrity": "sha512-g6QUff04oZpHs0eG5p83rFLhHeV00ug/Yf9nZM6fLeUrPguBTkTQOdpAWWspMh55TZfVQDPaN3NQJfbVRAxdIw==", "dev": true, "license": "MIT", "engines": { @@ -2562,8 +2453,9 @@ }, "node_modules/rimraf": { "version": "3.0.2", - "resolved": "https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet-public-npm/npm/registry/rimraf/-/rimraf-3.0.2.tgz", - "integrity": "sha1-8aVAK6YiCtUswSgrrBrjqkn9Bho=", + "resolved": "https://registry.npmjs.org/rimraf/-/rimraf-3.0.2.tgz", + "integrity": "sha512-JZkJMZkAGFFPP2YqXZXPbMlMBgsxzE8ILs4lMIX/2o0L9UBw9O/Y3o6wFw/i9YLapcUJWwqbi3kdxIPdC62TIA==", + "deprecated": "Rimraf versions prior to v4 are no longer supported", "dev": true, "license": "ISC", "dependencies": { @@ -2577,13 +2469,13 @@ } }, "node_modules/rollup": { - "version": "4.34.9", - "resolved": "https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet-public-npm/npm/registry/rollup/-/rollup-4.34.9.tgz", - "integrity": "sha1-4es5eFZHZ3iutqwqw9CbLOF3pVg=", + "version": "4.52.2", + "resolved": "https://registry.npmjs.org/rollup/-/rollup-4.52.2.tgz", + "integrity": "sha512-I25/2QgoROE1vYV+NQ1En9T9UFB9Cmfm2CJ83zZOlaDpvz29wGQSZXWKw7MiNXau7wYgB/T9fVIdIuEQ+KbiiA==", "dev": true, "license": "MIT", "dependencies": { - "@types/estree": "1.0.6" + "@types/estree": "1.0.8" }, "bin": { "rollup": "dist/bin/rollup" @@ -2593,36 +2485,39 @@ "npm": ">=8.0.0" }, "optionalDependencies": { - "@rollup/rollup-android-arm-eabi": "4.34.9", - "@rollup/rollup-android-arm64": "4.34.9", - "@rollup/rollup-darwin-arm64": "4.34.9", - "@rollup/rollup-darwin-x64": "4.34.9", - "@rollup/rollup-freebsd-arm64": "4.34.9", - "@rollup/rollup-freebsd-x64": "4.34.9", - "@rollup/rollup-linux-arm-gnueabihf": "4.34.9", - "@rollup/rollup-linux-arm-musleabihf": "4.34.9", - "@rollup/rollup-linux-arm64-gnu": "4.34.9", - "@rollup/rollup-linux-arm64-musl": "4.34.9", - "@rollup/rollup-linux-loongarch64-gnu": "4.34.9", - "@rollup/rollup-linux-powerpc64le-gnu": "4.34.9", - "@rollup/rollup-linux-riscv64-gnu": "4.34.9", - "@rollup/rollup-linux-s390x-gnu": "4.34.9", - "@rollup/rollup-linux-x64-gnu": "4.34.9", - "@rollup/rollup-linux-x64-musl": "4.34.9", - "@rollup/rollup-win32-arm64-msvc": "4.34.9", - "@rollup/rollup-win32-ia32-msvc": "4.34.9", - "@rollup/rollup-win32-x64-msvc": "4.34.9", + "@rollup/rollup-android-arm-eabi": "4.52.2", + "@rollup/rollup-android-arm64": "4.52.2", + "@rollup/rollup-darwin-arm64": "4.52.2", + "@rollup/rollup-darwin-x64": "4.52.2", + "@rollup/rollup-freebsd-arm64": "4.52.2", + "@rollup/rollup-freebsd-x64": "4.52.2", + "@rollup/rollup-linux-arm-gnueabihf": "4.52.2", + "@rollup/rollup-linux-arm-musleabihf": "4.52.2", + "@rollup/rollup-linux-arm64-gnu": "4.52.2", + "@rollup/rollup-linux-arm64-musl": "4.52.2", + "@rollup/rollup-linux-loong64-gnu": "4.52.2", + "@rollup/rollup-linux-ppc64-gnu": "4.52.2", + "@rollup/rollup-linux-riscv64-gnu": "4.52.2", + "@rollup/rollup-linux-riscv64-musl": "4.52.2", + "@rollup/rollup-linux-s390x-gnu": "4.52.2", + "@rollup/rollup-linux-x64-gnu": "4.52.2", + "@rollup/rollup-linux-x64-musl": "4.52.2", + "@rollup/rollup-openharmony-arm64": "4.52.2", + "@rollup/rollup-win32-arm64-msvc": "4.52.2", + "@rollup/rollup-win32-ia32-msvc": "4.52.2", + "@rollup/rollup-win32-x64-gnu": "4.52.2", + "@rollup/rollup-win32-x64-msvc": "4.52.2", "fsevents": "~2.3.2" } }, "node_modules/rollup-plugin-dts": { - "version": "6.1.1", - "resolved": "https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet-public-npm/npm/registry/rollup-plugin-dts/-/rollup-plugin-dts-6.1.1.tgz", - "integrity": "sha1-RrM/TR1/TmbxFxztmygqwRoVolQ=", + "version": "6.2.3", + "resolved": "https://registry.npmjs.org/rollup-plugin-dts/-/rollup-plugin-dts-6.2.3.tgz", + "integrity": "sha512-UgnEsfciXSPpASuOelix7m4DrmyQgiaWBnvI0TM4GxuDh5FkqW8E5hu57bCxXB90VvR1WNfLV80yEDN18UogSA==", "dev": true, "license": "LGPL-3.0-only", "dependencies": { - "magic-string": "^0.30.10" + "magic-string": "^0.30.17" }, "engines": { "node": ">=16" @@ -2631,7 +2526,7 @@ "url": "https://github.com/sponsors/Swatinem" }, "optionalDependencies": { - "@babel/code-frame": "^7.24.2" + "@babel/code-frame": "^7.27.1" }, "peerDependencies": { "rollup": "^3.29.4 || ^4", @@ -2640,8 +2535,8 @@ }, "node_modules/run-parallel": { "version": "1.2.0", - "resolved": "https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet-public-npm/npm/registry/run-parallel/-/run-parallel-1.2.0.tgz", - "integrity": "sha1-ZtE2jae9+SHrnZW9GpIp5/IaQ+4=", + "resolved": "https://registry.npmjs.org/run-parallel/-/run-parallel-1.2.0.tgz", + "integrity": "sha512-5l4VyZR86LZ/lDxZTR6jqL8AFE2S0IFLMP26AbjsLVADxHdhB/c0GUsH+y39UfCi3dzz8OlQuPmnaJOMoDHQBA==", "dev": true, "funding": [ { @@ -2664,8 +2559,8 @@ }, "node_modules/safe-buffer": { "version": "5.2.1", - "resolved": "https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet-public-npm/npm/registry/safe-buffer/-/safe-buffer-5.2.1.tgz", - "integrity": "sha1-Hq+fqb2x/dTsdfWPnNtOa3gn7sY=", + "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.2.1.tgz", + "integrity": "sha512-rp3So07KcdmmKbGvgaNxQSJr7bGVSVk5S9Eq1F+ppbRo70+YeaDxkw5Dd8NPN+GD6bjnYm2VuPuCXmpuYvmCXQ==", "dev": true, "funding": [ { @@ -2684,9 +2579,9 @@ "license": "MIT" }, "node_modules/semver": { - "version": "7.6.2", - "resolved": "https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet-public-npm/npm/registry/semver/-/semver-7.6.2.tgz", - "integrity": "sha1-Hjs0dZ+Jbo8U1hNHMs55iusMbhM=", + "version": "7.7.2", + "resolved": "https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet-public-npm/npm/registry/semver/-/semver-7.7.2.tgz", + "integrity": "sha1-Z9mf3NNc7CHm+Lh6f9UVoz+YK1g=", "dev": true, "license": "ISC", "bin": { @@ -2698,8 +2593,8 @@ }, "node_modules/serialize-javascript": { "version": "6.0.2", - "resolved": "https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet-public-npm/npm/registry/serialize-javascript/-/serialize-javascript-6.0.2.tgz", - "integrity": "sha1-3voeBVyDv21Z6oBdjahiJU62psI=", + "resolved": "https://registry.npmjs.org/serialize-javascript/-/serialize-javascript-6.0.2.tgz", + "integrity": "sha512-Saa1xPByTTq2gdeFZYLLo+RFE35NHZkAbqZeWNd3BpzppeVisAqpDjcp8dyf6uIvEqJRd46jemmyA4iFIeVk8g==", "dev": true, "license": "BSD-3-Clause", "dependencies": { @@ -2708,8 +2603,8 @@ }, "node_modules/shebang-command": { "version": "2.0.0", - "resolved": "https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet-public-npm/npm/registry/shebang-command/-/shebang-command-2.0.0.tgz", - "integrity": "sha1-zNCvT4g1+9wmW4JGGq8MNmY/NOo=", + "resolved": "https://registry.npmjs.org/shebang-command/-/shebang-command-2.0.0.tgz", + "integrity": "sha512-kHxr2zZpYtdmrN1qDjrrX/Z1rR1kG8Dx+gkpK1G4eXmvXswmcE1hTWBWYUzlraYw1/yZp6YuDY77YtvbN0dmDA==", "dev": true, "license": "MIT", "dependencies": { @@ -2721,8 +2616,8 @@ }, "node_modules/shebang-regex": { "version": "3.0.0", - "resolved": "https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet-public-npm/npm/registry/shebang-regex/-/shebang-regex-3.0.0.tgz", - "integrity": "sha1-rhbxZE2HPsrYQ7AwexQzYtTEIXI=", + "resolved": "https://registry.npmjs.org/shebang-regex/-/shebang-regex-3.0.0.tgz", + "integrity": "sha512-7++dFhtcx3353uBaq8DDR4NuxBetBzC7ZQOhmTQInHEd6bSrXdiEyzCvG07Z44UYdLShWUyXt5M/yhz8ekcb1A==", "dev": true, "license": "MIT", "engines": { @@ -2731,8 +2626,8 @@ }, "node_modules/signal-exit": { "version": "3.0.7", - "resolved": "https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet-public-npm/npm/registry/signal-exit/-/signal-exit-3.0.7.tgz", - "integrity": "sha1-qaF2f4r4QVURTqq9c/mSc8j1mtk=", + "resolved": "https://registry.npmjs.org/signal-exit/-/signal-exit-3.0.7.tgz", + "integrity": "sha512-wnD2ZE+l+SPC/uoS0vXeE9L1+0wuaMqKlfz9AMUo38JsyLSBWSFcHR1Rri62LZc12vLr1gb3jl7iwQhgwpAbGQ==", "dev": true, "license": "ISC" }, @@ -2748,15 +2643,15 @@ }, "node_modules/smob": { "version": "1.5.0", - "resolved": "https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet-public-npm/npm/registry/smob/-/smob-1.5.0.tgz", - "integrity": "sha1-hdeaFAOr8SjSTT68HNxeGpVI06s=", + "resolved": "https://registry.npmjs.org/smob/-/smob-1.5.0.tgz", + "integrity": "sha512-g6T+p7QO8npa+/hNx9ohv1E5pVCmWrVCUzUXJyLdMmftX6ER0oiWY/w9knEonLpnOp6b6FenKnMfR8gqwWdwig==", "dev": true, "license": "MIT" }, "node_modules/source-map": { "version": "0.6.1", - "resolved": "https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet-public-npm/npm/registry/source-map/-/source-map-0.6.1.tgz", - "integrity": "sha1-dHIq8y6WFOnCh6jQu95IteLxomM=", + "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.6.1.tgz", + "integrity": "sha512-UjgapumWlbMhkBgzT7Ykc5YXUT46F0iKu8SGXq0bcwP5dz/h0Plj6enJqjz1Zbq2l5WaqYnrVbwWOWMyF3F47g==", "dev": true, "license": "BSD-3-Clause", "engines": { @@ -2765,8 +2660,8 @@ }, "node_modules/source-map-support": { "version": "0.5.21", - "resolved": "https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet-public-npm/npm/registry/source-map-support/-/source-map-support-0.5.21.tgz", - "integrity": "sha1-BP58f54e0tZiIzwoyys1ufY/bk8=", + "resolved": "https://registry.npmjs.org/source-map-support/-/source-map-support-0.5.21.tgz", + "integrity": "sha512-uBHU3L3czsIyYXKX88fdrGovxdSCoTGDRZ6SYXtSRxLZUzHg5P/66Ht6uoUlHu9EZod+inXhKo3qQgwXUT/y1w==", "dev": true, "license": "MIT", "dependencies": { @@ -2776,8 +2671,8 @@ }, "node_modules/strip-ansi": { "version": "6.0.1", - "resolved": "https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet-public-npm/npm/registry/strip-ansi/-/strip-ansi-6.0.1.tgz", - "integrity": "sha1-nibGPTD1NEPpSJSVshBdN7Z6hdk=", + "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-6.0.1.tgz", + "integrity": "sha512-Y38VPSHcqkFrCpFnQ9vuSXmquuv5oXOKpGeT6aGrr3o3Gc9AlVa6JBfUSOCnbxGGZF+/0ooI7KrPuUSztUdU5A==", "dev": true, "license": "MIT", "dependencies": { @@ -2789,8 +2684,8 @@ }, "node_modules/strip-eof": { "version": "1.0.0", - "resolved": "https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet-public-npm/npm/registry/strip-eof/-/strip-eof-1.0.0.tgz", - "integrity": "sha1-u0P/VZim6wXYm1n80SnJgzE2Br8=", + "resolved": "https://registry.npmjs.org/strip-eof/-/strip-eof-1.0.0.tgz", + "integrity": "sha512-7FCwGGmx8mD5xQd3RPUvnSpUXHM3BWuzjtpD4TXsfcZ9EL4azvVVUscFYwD9nx8Kh+uCBC00XBtAykoMHwTh8Q==", "dev": true, "license": "MIT", "engines": { @@ -2799,8 +2694,8 @@ }, "node_modules/strip-final-newline": { "version": "2.0.0", - "resolved": "https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet-public-npm/npm/registry/strip-final-newline/-/strip-final-newline-2.0.0.tgz", - "integrity": "sha1-ibhS+y/L6Tb29LMYevsKEsGrWK0=", + "resolved": "https://registry.npmjs.org/strip-final-newline/-/strip-final-newline-2.0.0.tgz", + "integrity": "sha512-BrpvfNAE3dcvq7ll3xVumzjKjZQ5tI1sEUIKr3Uoks0XUl45St3FlatVqef9prk4jRDzhW6WZg+3bk93y6pLjA==", "dev": true, "license": "MIT", "engines": { @@ -2809,8 +2704,8 @@ }, "node_modules/strip-json-comments": { "version": "3.1.1", - "resolved": "https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet-public-npm/npm/registry/strip-json-comments/-/strip-json-comments-3.1.1.tgz", - "integrity": "sha1-MfEoGzgyYwQ0gxwxDAHMzajL4AY=", + "resolved": "https://registry.npmjs.org/strip-json-comments/-/strip-json-comments-3.1.1.tgz", + "integrity": "sha512-6fPc+R4ihwqP6N/aIv2f1gMH8lOVtWQHoqC4yK6oSDVVocumAsfCqjkXnqiYMhmMwS/mEHLp7Vehlt3ql6lEig==", "dev": true, "license": "MIT", "engines": { @@ -2822,8 +2717,8 @@ }, "node_modules/supports-color": { "version": "7.2.0", - "resolved": "https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet-public-npm/npm/registry/supports-color/-/supports-color-7.2.0.tgz", - "integrity": "sha1-G33NyzK4E4gBs+R4umpRyqiWSNo=", + "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-7.2.0.tgz", + "integrity": "sha512-qpCAvRl9stuOHveKsn7HncJRvv501qIacKzQlO/+Lwxc9+0q2wLyv4Dfvt80/DPn2pqOBsJdDiogXGR9+OvwRw==", "dev": true, "license": "MIT", "dependencies": { @@ -2835,8 +2730,8 @@ }, "node_modules/supports-preserve-symlinks-flag": { "version": "1.0.0", - "resolved": "https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet-public-npm/npm/registry/supports-preserve-symlinks-flag/-/supports-preserve-symlinks-flag-1.0.0.tgz", - "integrity": "sha1-btpL00SjyUrqN21MwxvHcxEDngk=", + "resolved": "https://registry.npmjs.org/supports-preserve-symlinks-flag/-/supports-preserve-symlinks-flag-1.0.0.tgz", + "integrity": "sha512-ot0WnXS9fgdkgIcePe6RHNk1WA8+muPa6cSjeR3V8K27q9BB1rTE3R1p7Hv0z1ZyAc8s6Vvv8DIyWf681MAt0w==", "dev": true, "license": "MIT", "engines": { @@ -2847,14 +2742,14 @@ } }, "node_modules/terser": { - "version": "5.31.1", - "resolved": "https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet-public-npm/npm/registry/terser/-/terser-5.31.1.tgz", - "integrity": "sha1-c13jyYfdZx6VGQ5rmM/i8H888NQ=", + "version": "5.44.0", + "resolved": "https://registry.npmjs.org/terser/-/terser-5.44.0.tgz", + "integrity": "sha512-nIVck8DK+GM/0Frwd+nIhZ84pR/BX7rmXMfYwyg+Sri5oGVE99/E3KvXqpC2xHFxyqXyGHTKBSioxxplrO4I4w==", "dev": true, "license": "BSD-2-Clause", "dependencies": { "@jridgewell/source-map": "^0.3.3", - "acorn": "^8.8.2", + "acorn": "^8.15.0", "commander": "^2.20.0", "source-map-support": "~0.5.20" }, @@ -2867,15 +2762,15 @@ }, "node_modules/text-table": { "version": "0.2.0", - "resolved": "https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet-public-npm/npm/registry/text-table/-/text-table-0.2.0.tgz", - "integrity": "sha1-f17oI66AUgfACvLfSoTsP8+lcLQ=", + "resolved": "https://registry.npmjs.org/text-table/-/text-table-0.2.0.tgz", + "integrity": "sha512-N+8UisAXDGk8PFXP4HAzVR9nbfmVJ3zYLAWiTIoqC5v5isinhr+r5uaO8+7r3BMfuNIufIsA7RdpVgacC2cSpw==", "dev": true, "license": "MIT" }, "node_modules/to-regex-range": { "version": "5.0.1", - "resolved": "https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet-public-npm/npm/registry/to-regex-range/-/to-regex-range-5.0.1.tgz", - "integrity": "sha1-FkjESq58jZiKMmAY7XL1tN0DkuQ=", + "resolved": "https://registry.npmjs.org/to-regex-range/-/to-regex-range-5.0.1.tgz", + "integrity": "sha512-65P7iz6X5yEr1cwcgvQxbbIw7Uk3gOy5dIdtZ4rDveLqhrdJP+Li/Hx6tyK0NEb+2GCyneCMJiGqrADCSNk8sQ==", "dev": true, "license": "MIT", "dependencies": { @@ -2885,40 +2780,30 @@ "node": ">=8.0" } }, - "node_modules/tslib": { - "version": "2.6.3", - "resolved": "https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet-public-npm/npm/registry/tslib/-/tslib-2.6.3.tgz", - "integrity": "sha1-BDj4EK16ntzeeiQcPYDbaTyMv+A=", - "dev": true, - "license": "0BSD" - }, - "node_modules/tsutils": { - "version": "3.21.0", - "resolved": "https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet-public-npm/npm/registry/tsutils/-/tsutils-3.21.0.tgz", - "integrity": "sha1-tIcX05TOpsHglpg+7Vjp1hcVtiM=", + "node_modules/ts-api-utils": { + "version": "1.4.3", + "resolved": "https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet-public-npm/npm/registry/ts-api-utils/-/ts-api-utils-1.4.3.tgz", + "integrity": "sha1-v8IhX+ZSj+yrKw+6VwouikJjsGQ=", "dev": true, "license": "MIT", - "dependencies": { - "tslib": "^1.8.1" - }, "engines": { - "node": ">= 6" + "node": ">=16" }, "peerDependencies": { - "typescript": ">=2.8.0 || >= 3.2.0-dev || >= 3.3.0-dev || >= 3.4.0-dev || >= 3.5.0-dev || >= 3.6.0-dev || >= 3.6.0-beta || >= 3.7.0-dev || >= 3.7.0-beta" + "typescript": ">=4.2.0" } }, - "node_modules/tsutils/node_modules/tslib": { - "version": "1.14.1", - "resolved": "https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet-public-npm/npm/registry/tslib/-/tslib-1.14.1.tgz", - "integrity": "sha1-zy04vcNKE0vK8QkcQfZhni9nLQA=", + "node_modules/tslib": { + "version": "2.8.1", + "resolved": "https://registry.npmjs.org/tslib/-/tslib-2.8.1.tgz", + "integrity": "sha512-oJFu94HQb+KVduSUQL7wnpmqnfmLsOA/nAh6b6EH0wCEoK0/mPeXU6c3wKDV83MkOuHPRHtSXKKU99IBazS/2w==", "dev": true, "license": "0BSD" }, "node_modules/type-check": { "version": "0.4.0", - "resolved": "https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet-public-npm/npm/registry/type-check/-/type-check-0.4.0.tgz", - "integrity": "sha1-B7ggO/pwVsBlcFDjzNLDdzC6uPE=", + "resolved": "https://registry.npmjs.org/type-check/-/type-check-0.4.0.tgz", + "integrity": "sha512-XleUoc9uwGXqjWwXaUTZAmzMcFZ5858QA2vvx1Ur5xIcixXIP+8LnFDgRplU30us6teqdlskFfu+ae4K79Ooew==", "dev": true, "license": "MIT", "dependencies": { @@ -2930,8 +2815,8 @@ }, "node_modules/type-fest": { "version": "0.20.2", - "resolved": "https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet-public-npm/npm/registry/type-fest/-/type-fest-0.20.2.tgz", - "integrity": "sha1-G/IH9LKPkVg2ZstfvTJ4hzAc1fQ=", + "resolved": "https://registry.npmjs.org/type-fest/-/type-fest-0.20.2.tgz", + "integrity": "sha512-Ne+eE4r0/iWnpAxD852z3A+N0Bt5RN//NjJwRd2VFHEmrywxf5vsZlh4R6lixl6B+wz/8d+maTSAkN1FIkI3LQ==", "dev": true, "license": "(MIT OR CC0-1.0)", "engines": { @@ -2942,9 +2827,9 @@ } }, "node_modules/typescript": { - "version": "5.4.5", - "resolved": "https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet-public-npm/npm/registry/typescript/-/typescript-5.4.5.tgz", - "integrity": "sha1-QszvLFcf29D2cYsdH15uXvAG9hE=", + "version": "5.9.2", + "resolved": "https://registry.npmjs.org/typescript/-/typescript-5.9.2.tgz", + "integrity": "sha512-CWBzXQrc/qOkhidw1OzBTQuYRbfyxDXJMVJ1XNwUHGROVmuaeiEm3OslpZ1RV96d7SKKjZKrSJu3+t/xlw3R9A==", "dev": true, "license": "Apache-2.0", "bin": { @@ -2964,8 +2849,8 @@ }, "node_modules/uri-js": { "version": "4.4.1", - "resolved": "https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet-public-npm/npm/registry/uri-js/-/uri-js-4.4.1.tgz", - "integrity": "sha1-mxpSWVIlhZ5V9mnZKPiMbFfyp34=", + "resolved": "https://registry.npmjs.org/uri-js/-/uri-js-4.4.1.tgz", + "integrity": "sha512-7rKUyy33Q1yc98pQ1DAmLtwX109F7TIfWlW1Ydo8Wl1ii1SeHieeh0HHfPeL2fMXK6z0s8ecKs9frCuLJvndBg==", "dev": true, "license": "BSD-2-Clause", "dependencies": { @@ -2973,15 +2858,15 @@ } }, "node_modules/wasm-feature-detect": { - "version": "1.6.1", - "resolved": "https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet-public-npm/npm/registry/wasm-feature-detect/-/wasm-feature-detect-1.6.1.tgz", - "integrity": "sha1-IcfDX5sjPXHSlI1Kiz4gmMRSuUA=", + "version": "1.8.0", + "resolved": "https://registry.npmjs.org/wasm-feature-detect/-/wasm-feature-detect-1.8.0.tgz", + "integrity": "sha512-zksaLKM2fVlnB5jQQDqKXXwYHLQUVH9es+5TOOHwGOVJOCeRBCiPjwSg+3tN2AdTCzjgli4jijCH290kXb/zWQ==", "license": "Apache-2.0" }, "node_modules/which": { "version": "2.0.2", - "resolved": "https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet-public-npm/npm/registry/which/-/which-2.0.2.tgz", - "integrity": "sha1-fGqN0KY2oDJ+ELWckobu6T8/UbE=", + "resolved": "https://registry.npmjs.org/which/-/which-2.0.2.tgz", + "integrity": "sha512-BLI3Tl1TW3Pvl70l3yq3Y64i+awpwXqsGBYWkkqMtnbXgrMD+yj7rhW0kuEDxzJaYXGjEW5ogapKNMEKNMjibA==", "dev": true, "license": "ISC", "dependencies": { @@ -2996,8 +2881,8 @@ }, "node_modules/word-wrap": { "version": "1.2.5", - "resolved": "https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet-public-npm/npm/registry/word-wrap/-/word-wrap-1.2.5.tgz", - "integrity": "sha1-0sRcbdT7zmIaZvE2y+Mor9BBCzQ=", + "resolved": "https://registry.npmjs.org/word-wrap/-/word-wrap-1.2.5.tgz", + "integrity": "sha512-BN22B5eaMMI9UMtjrGd5g5eCYPpCPDUy0FJXbYsaT5zYxjFOckS53SQDE3pWkVoWpHXVb3BrYcEN4Twa55B5cA==", "dev": true, "license": "MIT", "engines": { @@ -3006,22 +2891,15 @@ }, "node_modules/wrappy": { "version": "1.0.2", - "resolved": "https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet-public-npm/npm/registry/wrappy/-/wrappy-1.0.2.tgz", - "integrity": "sha1-tSQ9jz7BqjXxNkYFvA0QNuMKtp8=", - "dev": true, - "license": "ISC" - }, - "node_modules/yallist": { - "version": "2.1.2", - "resolved": "https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet-public-npm/npm/registry/yallist/-/yallist-2.1.2.tgz", - "integrity": "sha1-HBH5IY8HYImkfdUS+TxmmaaoHVI=", + "resolved": "https://registry.npmjs.org/wrappy/-/wrappy-1.0.2.tgz", + "integrity": "sha512-l4Sp/DRseor9wL6EvV2+TuQn63dMkPjZ/sp9XkghTEbV9KlPS1xUsZ3u7/IQO4wxtcFB4bgpQPRcR3QCvezPcQ==", "dev": true, "license": "ISC" }, "node_modules/yocto-queue": { "version": "0.1.0", - "resolved": "https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet-public-npm/npm/registry/yocto-queue/-/yocto-queue-0.1.0.tgz", - "integrity": "sha1-ApTrPe4FAo0x7hpfosVWpqrxChs=", + "resolved": "https://registry.npmjs.org/yocto-queue/-/yocto-queue-0.1.0.tgz", + "integrity": "sha512-rVksvsnNCdJ/ohGc6xgPwyN8eheCxsiLM8mxuE/t/mOVqJewPuO1miLpTHQiRgTKCLexL4MeAFVagts7HmNZ2Q==", "dev": true, "license": "MIT", "engines": { diff --git a/src/native/package.json b/src/native/package.json index c67c0721191489..8ef54c8d42faad 100644 --- a/src/native/package.json +++ b/src/native/package.json @@ -25,24 +25,27 @@ "author": "Microsoft", "license": "MIT", "devDependencies": { - "@rollup/plugin-node-resolve": "15.2.3", + "@rollup/plugin-node-resolve": "16.0.1", "@rollup/plugin-terser": "0.4.4", - "@rollup/plugin-typescript": "11.1.6", + "@rollup/plugin-typescript": "12.1.4", "@rollup/plugin-virtual": "3.0.2", - "@types/node": "^24.5.2", - "@typescript-eslint/eslint-plugin": "5.59.1", - "@typescript-eslint/parser": "5.59.1", - "eslint": "8.44.0", - "fast-glob": "3.3.2", + "@types/node": "24.5.2", + "@typescript-eslint/eslint-plugin": "6.21.0", + "@typescript-eslint/parser": "6.21.0", + "eslint": "8.57.0", + "fast-glob": "3.3.3", "git-commit-info": "2.0.2", - "magic-string": "0.30.10", - "rollup": "4.34.9", - "rollup-plugin-dts": "6.1.1", - "terser": "5.31.1", - "tslib": "2.6.3", - "typescript": "5.4.5" + "magic-string": "0.30.19", + "rollup": "4.52.2", + "rollup-plugin-dts": "6.2.3", + "terser": "5.44.0", + "tslib": "2.8.1", + "typescript": "5.9.2" + }, + "overrides": { + "cross-spawn": "7.0.6" }, "dependencies": { - "wasm-feature-detect": "1.6.1" + "wasm-feature-detect": "1.8.0" } } \ No newline at end of file diff --git a/src/native/rollup.config.defines.js b/src/native/rollup.config.defines.js new file mode 100644 index 00000000000000..e95ae9d2f2969d --- /dev/null +++ b/src/native/rollup.config.defines.js @@ -0,0 +1,40 @@ +//! Licensed to the .NET Foundation under one or more agreements. +//! The .NET Foundation licenses this file to you under the MIT license. + +import gitCommitInfo from "git-commit-info"; + +export const configuration = process.env.Configuration || "Debug"; +export const productVersion = process.env.ProductVersion || "10.0.0-dev"; +export const isContinuousIntegrationBuild = process.env.ContinuousIntegrationBuild === "true" ? true : false; + +console.log(`Rollup configuration: Configuration=${configuration}, ProductVersion=${productVersion}, ContinuousIntegrationBuild=${isContinuousIntegrationBuild}`); + +export const banner = "//! Licensed to the .NET Foundation under one or more agreements.\n//! The .NET Foundation licenses this file to you under the MIT license.\n//! This is generated file, see src/native/libs/Browser/rollup.config.defines.js\n\n"; +export const banner_dts = banner + "//! This is not considered public API with backward compatibility guarantees. \n"; +export const keep_classnames = /(ManagedObject|ManagedError|Span|ArraySegment)/; +export const keep_fnames = /(netSetInternals|netUpdateAllInternals|netUpdateModuleInternals|netTabulateLE|netTabulateRE|netTabulateHE|netTabulateJSNE|netTabulateNBE)/; +export const reserved = [ + "Logger", "Assert", "netJSEngine", "Module", "netInternals", "netPublicApi", "netInternalUpdates", + "netSetInternals", "netUpdateAllInternals", "netUpdateModuleInternals", "netInitializeModule", + "netLoaderExports", "netRuntimeExports", "netBrowserHostExports", "netInteropJSExports", "netNativeBrowserExports", + "netTabulateLE", "netTabulateRE", "netTabulateHE", "netTabulateJSNE", "netTabulateNBE" +]; + +export const externalDependencies = ["module", "process", "perf_hooks", "node:crypto"]; +export const artifactsObjDir = "../../artifacts/obj"; +export const isDebug = process.env.Configuration !== "Release"; + +let gitHash; +try { + const gitInfo = gitCommitInfo(); + gitHash = gitInfo.hash; +} catch (e) { + gitHash = "unknown"; +} + +export const envConstants = { + productVersion, + configuration, + gitHash, + isContinuousIntegrationBuild, +}; diff --git a/src/native/rollup.config.js b/src/native/rollup.config.js new file mode 100644 index 00000000000000..6684639c2764fb --- /dev/null +++ b/src/native/rollup.config.js @@ -0,0 +1,163 @@ +//! Licensed to the .NET Foundation under one or more agreements. +//! The .NET Foundation licenses this file to you under the MIT license. + +import { defineConfig } from "rollup"; +import typescript from "@rollup/plugin-typescript"; +import { nodeResolve } from "@rollup/plugin-node-resolve"; +import dts from "rollup-plugin-dts"; +import { + externalDependencies, isDebug, artifactsObjDir, envConstants, banner, banner_dts, configuration, + keep_classnames, keep_fnames, reserved +} from "./rollup.config.defines.js" +import { terserPlugin, writeOnChangePlugin, consts, onwarn, alwaysLF, iife2fe, sourcemapPathTransform } from "./rollup.config.plugins.js" +import { promises as fs } from "fs"; + +const dotnetDTS = { + input: "./libs/Common/JavaScript/types/export-api.ts", + output: [ + { + format: "es", + file: artifactsObjDir + `/coreclr/browser.wasm.${configuration}/corehost/dotnet.d.ts`, + banner: banner_dts, + plugins: [writeOnChangePlugin()], + }, + ...(isDebug ? [{ + format: "es", + file: "./corehost/browserhost/loader/dotnet.d.ts", + banner: banner_dts, + plugins: [alwaysLF(), writeOnChangePlugin()], + }] : []) + ], + external: externalDependencies, + plugins: [dts()], + onwarn +}; + +const dotnetJS = configure({ + input: "./corehost/browserhost/loader/dotnet.ts", + output: [{ + file: artifactsObjDir + `/coreclr/browser.wasm.${configuration}/corehost/dotnet.js`, + intro: "/*! bundlerFriendlyImports */", + }], + terser: { + compress: { + module: true, + }, mangle: { + module: true, + reserved + } + } +}); + +const libNativeBrowser = configure({ + input: "./libs/System.Native.Browser/native/index.ts", + output: [{ + name: "libNativeBrowser", + format: "iife", + file: artifactsObjDir + `/native/browser-${configuration}-wasm/System.Native.Browser/libSystem.Native.Browser.js`, + footer: await fs.readFile("./libs/System.Native.Browser/libSystem.Native.Browser.footer.js"), + }], + terser: { + compress: { + toplevel: true, + keep_fnames, + }, mangle: { + toplevel: true, + keep_fnames, + reserved, + } + } +}); + +const dotnetRuntimeJS = configure({ + input: "./libs/System.Runtime.InteropServices.JavaScript.Native/dotnet.runtime.ts", + output: [{ + file: artifactsObjDir + `/native/browser-${configuration}-wasm/System.Runtime.InteropServices.JavaScript.Native/dotnet.runtime.js`, + }], + terser: { + compress: { + module: true, + }, mangle: { + module: true, + keep_classnames, + reserved + } + } +}); + +const libInteropJavaScriptNative = configure({ + input: "./libs/System.Runtime.InteropServices.JavaScript.Native/native/index.ts", + output: [{ + name: "libInteropJavaScriptNative", + format: "iife", + file: artifactsObjDir + `/native/browser-${configuration}-wasm/System.Runtime.InteropServices.JavaScript.Native/libSystem.Runtime.InteropServices.JavaScript.Native.js`, + footer: await fs.readFile("./libs/System.Runtime.InteropServices.JavaScript.Native/libSystem.Runtime.InteropServices.JavaScript.Native.footer.js"), + }], + terser: { + compress: { + toplevel: true, + keep_fnames, + }, mangle: { + toplevel: true, + keep_fnames, + reserved, + } + } +}); + +const libBrowserHost = configure({ + input: "./corehost/browserhost/host/index.ts", + output: [{ + name: "libBrowserHost", + format: "iife", + file: artifactsObjDir + `/coreclr/browser.wasm.${configuration}/corehost/libBrowserHost.js`, + footer: await fs.readFile("./corehost/browserhost/libBrowserHost.footer.js"), + }], + terser: { + compress: { + toplevel: true, + keep_fnames, + }, mangle: { + toplevel: true, + keep_fnames, + reserved, + } + } +}); + +export default defineConfig([ + dotnetJS, + dotnetDTS, + libNativeBrowser, + dotnetRuntimeJS, + libInteropJavaScriptNative, + libBrowserHost, +]); + +function configure({ input, output, terser }) { + return { + treeshake: !isDebug, + input, + output: output.map(o => { + return { + banner, + format: "es", + plugins: isDebug + ? [iife2fe(), writeOnChangePlugin()] + : [terserPlugin(terser), iife2fe(), writeOnChangePlugin()], + sourcemap: true, //isDebug ? true : "hidden", + sourcemapPathTransform, + ...o + } + }), + external: externalDependencies, + plugins: [ + nodeResolve(), + consts(envConstants), + typescript({ + tsconfig: "./tsconfig.json", + }) + ], + onwarn, + } +} diff --git a/src/native/rollup.config.plugins.js b/src/native/rollup.config.plugins.js new file mode 100644 index 00000000000000..33eb8ba4a693f5 --- /dev/null +++ b/src/native/rollup.config.plugins.js @@ -0,0 +1,156 @@ +//! Licensed to the .NET Foundation under one or more agreements. +//! The .NET Foundation licenses this file to you under the MIT license. + +import { createHash } from "crypto"; +import { readFile, writeFile, mkdir } from "fs/promises"; +import virtual from "@rollup/plugin-virtual"; +import * as fs from "fs"; +import * as path from "path"; +import terser from "@rollup/plugin-terser"; + +import { isContinuousIntegrationBuild } from "./rollup.config.defines.js" + +export const terserPlugin = (terserOptions) => { + let { compress, mangle } = terserOptions || {}; + compress = compress || {}; + mangle = mangle || {}; + return terser({ + ecma: "2020", + compress: { + defaults: true, + passes: 2, + drop_debugger: false, // we invoke debugger + drop_console: false, // we log to console + ...compress + }, + // WASM-TODO: remove beautify + format: { + beautify: true, + }, + mangle: { + ...mangle, + }, + }) +} + +// this would create .sha256 file next to the output file, so that we do not touch datetime of the file if it's same -> faster incremental build. +export const writeOnChangePlugin = () => ({ + name: "writeOnChange", + generateBundle: writeWhenChanged +}); + +// Drop invocation from IIFE +export function iife2fe() { + return { + name: "iife2fe", + generateBundle: (options, bundle) => { + const name = Object.keys(bundle)[0]; + if (name.endsWith(".map")) return; + const asset = bundle[name]; + const code = asset.code; + //throw new Error("iife2fe " + code); + asset.code = code + .replace(/}\({}\);/, "};") // }({}); ->}; + .replace(/}\)\({}\);/, "});") // })({}); ->}); + ; + } + }; +} + +// force always unix line ending +export const alwaysLF = () => ({ + name: "writeOnChange", + generateBundle: (options, bundle) => { + const name = Object.keys(bundle)[0]; + const asset = bundle[name]; + const code = asset.code; + asset.code = code.replace(/\r/g, ""); + } +}); + +async function writeWhenChanged(options, bundle) { + try { + const name = Object.keys(bundle)[0]; + const asset = bundle[name]; + const code = asset.code; + const hashFileName = options.file + ".sha256"; + const oldHashExists = await checkFileExists(hashFileName); + const oldFileExists = await checkFileExists(options.file); + + const newHash = createHash("sha256").update(code).digest("hex"); + + let isOutputChanged = true; + if (oldHashExists && oldFileExists) { + const oldHash = await readFile(hashFileName, { encoding: "ascii" }); + isOutputChanged = oldHash !== newHash; + } + if (isOutputChanged) { + const dir = path.dirname(options.file); + if (!await checkFileExists(dir)) { + await mkdir(dir, { recursive: true }); + } + await writeFile(hashFileName, newHash); + } else { + // this.warn('No change in ' + options.file) + delete bundle[name]; + } + } catch (ex) { + this.warn(ex.toString()); + } +} + +function checkFileExists(file) { + return fs.promises.access(file, fs.constants.F_OK) + .then(() => true) + .catch(() => false); +} + +export function onwarn(warning) { + if (warning.code === "CIRCULAR_DEPENDENCY") { + return; + } + + if (warning.code === "UNRESOLVED_IMPORT" && warning.exporter === "process") { + return; + } + + if (warning.code === "PLUGIN_WARNING" && warning.message.indexOf("sourcemap") !== -1) { + return; + } + + // eslint-disable-next-line no-console + console.warn(`(!) ${warning.toString()} ${warning.code}`); +} + +export function consts(dict) { + // implement rollup-plugin-const in terms of @rollup/plugin-virtual + // It's basically the same thing except "consts" names all its modules with a "consts:" prefix, + // and the virtual module always exports a single default binding (the const value). + + let newDict = {}; + for (const k in dict) { + const newKey = "consts:" + k; + const newVal = JSON.stringify(dict[k]); + newDict[newKey] = `export default ${newVal}`; + } + return virtual(newDict); +} + +const locationCache = {}; +export function sourcemapPathTransform(relativeSourcePath, sourcemapPath) { + let res = locationCache[relativeSourcePath]; + if (res === undefined) { + if (!isContinuousIntegrationBuild) { + const sourcePath = path.resolve( + path.dirname(sourcemapPath), + relativeSourcePath + ); + res = `file:///${sourcePath.replace(/\\/g, "/")}`; + } else { + relativeSourcePath = relativeSourcePath.substring(12); + res = `https://raw.githubusercontent.com/dotnet/runtime/${gitHash}/${relativeSourcePath}`; + } + locationCache[relativeSourcePath] = res; + } + return res; +} diff --git a/src/native/rollup.stub.js b/src/native/rollup.stub.js deleted file mode 100644 index 1b59e429abce59..00000000000000 --- a/src/native/rollup.stub.js +++ /dev/null @@ -1,45 +0,0 @@ -//! Licensed to the .NET Foundation under one or more agreements. -//! The .NET Foundation licenses this file to you under the MIT license. - -import { promises as fs } from "fs"; -import path from "path"; - -/** - * This would be replace by real rollup with TypeScript compilation in next iteration - */ - - -const artifactsObjDir = "../../artifacts/obj"; -const configuration = process.argv[2] || "Debug"; -const productVersion = process.argv[3] || "10.0.0-dev"; -const isContinuousIntegrationBuild = process.argv[4] === "true" ? true : false; - -console.log(`Rollup configuration: Configuration=${configuration}, ProductVersion=${productVersion}, ContinuousIntegrationBuild=${isContinuousIntegrationBuild}`); - -const copies = [ - ["./corehost/browserhost/loader/dotnet.d.ts", - `${artifactsObjDir}/coreclr/browser.wasm.${configuration}/corehost/dotnet.d.ts`], - ["./corehost/browserhost/loader/dotnet.js", - `${artifactsObjDir}/coreclr/browser.wasm.${configuration}/corehost/dotnet.js`], - ["./corehost/browserhost/libBrowserHost.js", - `${artifactsObjDir}/coreclr/browser.wasm.${configuration}/corehost/libBrowserHost.js`], - ["./libs/System.Native.Browser/libSystem.Native.Browser.js", - `${artifactsObjDir}/native/browser-${configuration}-wasm/System.Native.Browser/libSystem.Native.Browser.js`], - ["./libs/System.Runtime.InteropServices.JavaScript.Native/dotnet.runtime.js", - `${artifactsObjDir}/native/browser-${configuration}-wasm/System.Runtime.InteropServices.JavaScript.Native/dotnet.runtime.js`], - ["./libs/System.Runtime.InteropServices.JavaScript.Native/libSystem.Runtime.InteropServices.JavaScript.Native.js", - `${artifactsObjDir}/native/browser-${configuration}-wasm/System.Runtime.InteropServices.JavaScript.Native/libSystem.Runtime.InteropServices.JavaScript.Native.js`] -]; - -const now = new Date(); -for (const [src, dest] of copies) { - const absoluteSrc = path.resolve(src); - const absoluteDest = path.resolve(dest); - const destDir = path.resolve(path.dirname(dest)); - console.log(`Copying ${absoluteSrc} to ${destDir}`); - await fs.mkdir(destDir, { recursive: true }); - await fs.copyFile(absoluteSrc, absoluteDest); - // TODO-WASM: make rollup incremental - // await fs.utimes(absoluteDest, now, now); -} -await fs.writeFile(`${artifactsObjDir}/coreclr/browser.wasm.${configuration}/corehost/.rollup.stamp`, new Date().toISOString()); diff --git a/src/native/tsconfig.json b/src/native/tsconfig.json index 6709400b3bc508..04ecb2b6b8e572 100644 --- a/src/native/tsconfig.json +++ b/src/native/tsconfig.json @@ -5,7 +5,7 @@ "removeComments": false, "module": "esnext", "sourceMap": true, - "target": "ES2018", + "target": "ES2020", "moduleResolution": "Node", "strict": true, "lib": [ From 32680f9527e37aa1a06ae0c5f9c8c6c8efe67d3c Mon Sep 17 00:00:00 2001 From: pavelsavara Date: Thu, 25 Sep 2025 12:12:00 +0200 Subject: [PATCH 02/25] more --- .../browserhost/libBrowserHost.footer.js | 1 - .../corehost/browserhost/loader/bootstrap.ts | 4 +- .../corehost/browserhost/loader/config.ts | 47 ++++++------------- ...letion-source.ts => promise-controller.ts} | 30 ++++++------ src/native/corehost/browserhost/loader/run.ts | 4 +- .../libs/Common/JavaScript/types/internal.ts | 10 ++-- .../native/cross-linked.ts | 2 - src/native/rollup.config.defines.js | 3 +- 8 files changed, 41 insertions(+), 60 deletions(-) rename src/native/corehost/browserhost/loader/{promise-completion-source.ts => promise-controller.ts} (55%) diff --git a/src/native/corehost/browserhost/libBrowserHost.footer.js b/src/native/corehost/browserhost/libBrowserHost.footer.js index d563164e28a9f0..7a64e08ef534ac 100644 --- a/src/native/corehost/browserhost/libBrowserHost.footer.js +++ b/src/native/corehost/browserhost/libBrowserHost.footer.js @@ -27,7 +27,6 @@ const config = netInternals.netLoaderConfig; const assemblyPaths = config.resources.assembly.map(a => a.virtualPath); const coreAssemblyPaths = config.resources.coreAssembly.map(a => a.virtualPath); - // WASM-TODO: pass TPA via argument, not env ENV[HOST_PROPERTY_TRUSTED_PLATFORM_ASSEMBLIES] = config.environmentVariables[HOST_PROPERTY_TRUSTED_PLATFORM_ASSEMBLIES] = [...coreAssemblyPaths, ...assemblyPaths].join(":"); ENV[HOST_PROPERTY_NATIVE_DLL_SEARCH_DIRECTORIES] = config.environmentVariables[HOST_PROPERTY_NATIVE_DLL_SEARCH_DIRECTORIES] = config.virtualWorkingDirectory; ENV[HOST_PROPERTY_APP_PATHS] = config.environmentVariables[HOST_PROPERTY_APP_PATHS] = config.virtualWorkingDirectory; diff --git a/src/native/corehost/browserhost/loader/bootstrap.ts b/src/native/corehost/browserhost/loader/bootstrap.ts index 5185b7366908ab..1cd5938c727798 100644 --- a/src/native/corehost/browserhost/loader/bootstrap.ts +++ b/src/native/corehost/browserhost/loader/bootstrap.ts @@ -6,7 +6,7 @@ import type { LoadBootResourceCallback, JsModuleExports, JsAsset, AssemblyAsset, import { Assert, netJSEngine, getInternals, netBrowserHostExports, netUpdateAllInternals } from "./cross-module"; import { getLoaderConfig } from "./config"; import { BrowserHost_InitializeCoreCLR } from "./run"; -import { createPromiseCompletionSource } from "./promise-completion-source"; +import { createPromiseController } from "./promise-controller"; const scriptUrlQuery = /*! webpackIgnore: true */import.meta.url; const queryIndex = scriptUrlQuery.indexOf("?"); @@ -14,7 +14,7 @@ const modulesUniqueQuery = queryIndex > 0 ? scriptUrlQuery.substring(queryIndex) const scriptUrl = normalizeFileUrl(scriptUrlQuery); const scriptDirectory = normalizeDirectoryUrl(scriptUrl); -const nativeModulePromiseController = createPromiseCompletionSource(() => { +const nativeModulePromiseController = createPromiseController(() => { netUpdateAllInternals(); }); diff --git a/src/native/corehost/browserhost/loader/config.ts b/src/native/corehost/browserhost/loader/config.ts index 2e7a5a8397ddab..8f56444ca1f2b5 100644 --- a/src/native/corehost/browserhost/loader/config.ts +++ b/src/native/corehost/browserhost/loader/config.ts @@ -44,32 +44,15 @@ function mergeConfigs(target: LoaderConfigInternal, source: Partial(afterResolve?: () => void, afterReject?: () => void): PromiseCompletionSource { - let promiseControl: PromiseCompletionSource = null as unknown as PromiseCompletionSource; - const promise = new Promise((resolve, reject) => { +export function createPromiseController(afterResolve?: () => void, afterReject?: () => void): PromiseController { + let promiseControl: PromiseController = null as unknown as PromiseController; + const promise = new Promise((resolve, reject) => { promiseControl = { isDone: false, - promise: null as unknown as ControllablePromise, - resolve: (data: TResult | PromiseLike) => { + promise: null as unknown as ControllablePromise, + resolve: (data: T | PromiseLike) => { if (!promiseControl!.isDone) { promiseControl!.isDone = true; resolve(data); @@ -32,23 +34,23 @@ export function createPromiseCompletionSource(afterResolve?: () => void } } }, - propagateFrom: (other: Promise) => { + propagateFrom: (other: Promise) => { other.then(promiseControl!.resolve).catch(promiseControl!.reject); } }; }); (promiseControl).promise = promise; - const controllablePromise = promise as ControllablePromise; - (controllablePromise as any)[controllablePromiseSymbol] = promiseControl; + const controllablePromise = promise as ControllablePromise; + (controllablePromise as any)[promiseControlSymbol] = promiseControl; return promiseControl; } -export function getPromiseCompletionSource(promise: ControllablePromise): PromiseCompletionSource; -export function getPromiseCompletionSource(promise: Promise): PromiseCompletionSource | undefined { - return (promise as any)[controllablePromiseSymbol]; +export function getPromiseController(promise: ControllablePromise): PromiseController; +export function getPromiseController(promise: Promise): PromiseController | undefined { + return (promise as any)[promiseControlSymbol]; } export function isControllablePromise(promise: Promise): promise is ControllablePromise { - return (promise as any)[controllablePromiseSymbol] !== undefined; + return (promise as any)[promiseControlSymbol] !== undefined; } diff --git a/src/native/corehost/browserhost/loader/run.ts b/src/native/corehost/browserhost/loader/run.ts index c343fefcb08b81..1ec137cd4d47fe 100644 --- a/src/native/corehost/browserhost/loader/run.ts +++ b/src/native/corehost/browserhost/loader/run.ts @@ -3,10 +3,10 @@ import { Module } from "./cross-module"; import { exit } from "./exit"; -import { createPromiseCompletionSource } from "./promise-completion-source"; +import { createPromiseController } from "./promise-controller"; let CoreCLRInitialized = false; -const runMainPromiseController = createPromiseCompletionSource(); +const runMainPromiseController = createPromiseController(); export function BrowserHost_InitializeCoreCLR():void { if (CoreCLRInitialized) { diff --git a/src/native/libs/Common/JavaScript/types/internal.ts b/src/native/libs/Common/JavaScript/types/internal.ts index 40a22496bb6b10..4e4bfd7b3e8abf 100644 --- a/src/native/libs/Common/JavaScript/types/internal.ts +++ b/src/native/libs/Common/JavaScript/types/internal.ts @@ -92,17 +92,17 @@ export type LoaderConfigInternal = LoaderConfig & { /// A Promise with a controller attached -export interface ControllablePromise extends Promise { +export interface ControllablePromise extends Promise { __brand: "ControllablePromise" } /// Just a pair of a promise and its controller -export interface PromiseCompletionSource { - readonly promise: ControllablePromise; +export interface PromiseController { + readonly promise: ControllablePromise; isDone: boolean; - resolve: (value: TResult | PromiseLike) => void; + resolve: (value: T | PromiseLike) => void; reject: (reason?: any) => void; - propagateFrom: (other: Promise) => void; + propagateFrom: (other: Promise) => void; } diff --git a/src/native/libs/System.Native.Browser/native/cross-linked.ts b/src/native/libs/System.Native.Browser/native/cross-linked.ts index c890d08d47e3e1..954c6bab1adf9d 100644 --- a/src/native/libs/System.Native.Browser/native/cross-linked.ts +++ b/src/native/libs/System.Native.Browser/native/cross-linked.ts @@ -10,8 +10,6 @@ import { import { } from "../../Common/JavaScript/cross-linked"; -// this dummy function helps rollup to keep functions below from trimming -// we are installing them into emscripten closure export function crossLink() { return [ Assert, Logger, Module, diff --git a/src/native/rollup.config.defines.js b/src/native/rollup.config.defines.js index e95ae9d2f2969d..eb7edf563c23a7 100644 --- a/src/native/rollup.config.defines.js +++ b/src/native/rollup.config.defines.js @@ -17,8 +17,7 @@ export const reserved = [ "Logger", "Assert", "netJSEngine", "Module", "netInternals", "netPublicApi", "netInternalUpdates", "netSetInternals", "netUpdateAllInternals", "netUpdateModuleInternals", "netInitializeModule", "netLoaderExports", "netRuntimeExports", "netBrowserHostExports", "netInteropJSExports", "netNativeBrowserExports", - "netTabulateLE", "netTabulateRE", "netTabulateHE", "netTabulateJSNE", "netTabulateNBE" -]; + "netTabulateLE", "netTabulateRE", "netTabulateHE", "netTabulateJSNE", "netTabulateNBE"]; export const externalDependencies = ["module", "process", "perf_hooks", "node:crypto"]; export const artifactsObjDir = "../../artifacts/obj"; From b4d1f975d58ab2d75db7faca464878c45026eebd Mon Sep 17 00:00:00 2001 From: pavelsavara Date: Thu, 25 Sep 2025 13:53:35 +0200 Subject: [PATCH 03/25] fix --- .../Common/JavaScript/cross-module/index.ts | 113 +++++++++--------- 1 file changed, 57 insertions(+), 56 deletions(-) diff --git a/src/native/libs/Common/JavaScript/cross-module/index.ts b/src/native/libs/Common/JavaScript/cross-module/index.ts index 6130a5aa3c6373..d56aa8cc7f125c 100644 --- a/src/native/libs/Common/JavaScript/cross-module/index.ts +++ b/src/native/libs/Common/JavaScript/cross-module/index.ts @@ -64,6 +64,63 @@ export function netUpdateModuleInternals() { netNativeBrowserExports = {} as NativeBrowserExports; expandNBE(netInternals.netNativeBrowserExportsTable, netNativeBrowserExports); } + + function expandRE(table:RuntimeExportsTable, runtime:RuntimeExports):void { + Object.assign(runtime, { + }); + } + + function expandLE(table:LoaderExportsTable, logger:LoggerType, assert:AssertType, jsEngine:JSEngineType, netLoaderExports:LoaderExports):void { + const loggerLocal :LoggerType = { + info: table[0], + warn: table[1], + error: table[2], + }; + const assertLocal :AssertType = { + check: table[3], + }; + const loaderExportsLocal :LoaderExports = { + ENVIRONMENT_IS_NODE: table[4], + ENVIRONMENT_IS_SHELL: table[5], + ENVIRONMENT_IS_WEB: table[6], + ENVIRONMENT_IS_WORKER: table[7], + ENVIRONMENT_IS_SIDECAR: table[8], + resolveRunMainPromise: table[9], + rejectRunMainPromise: table[10], + getRunMainPromise: table[11], + }; + const jsEngineLocal :JSEngineType = { + IS_NODE: loaderExportsLocal.ENVIRONMENT_IS_NODE(), + IS_SHELL: loaderExportsLocal.ENVIRONMENT_IS_SHELL(), + IS_WEB: loaderExportsLocal.ENVIRONMENT_IS_WEB(), + IS_WORKER: loaderExportsLocal.ENVIRONMENT_IS_WORKER(), + IS_SIDECAR: loaderExportsLocal.ENVIRONMENT_IS_SIDECAR(), + }; + Object.assign(netLoaderExports, loaderExportsLocal); + Object.assign(logger, loggerLocal); + Object.assign(assert, assertLocal); + Object.assign(jsEngine, jsEngineLocal); + } + + function expandHE(table:HostNativeExportsTable, native:HostNativeExports):void { + const nativeLocal :HostNativeExports = { + registerDllBytes: table[0], + isSharedArrayBuffer: table[1], + }; + Object.assign(native, nativeLocal); + } + + function expandJSNE(table:InteropJavaScriptNativeExportsTable, interop:InteropJavaScriptNativeExports):void { + const interopLocal :InteropJavaScriptNativeExports = { + }; + Object.assign(interop, interopLocal); + } + + function expandNBE(table:NativeBrowserExportsTable, interop:NativeBrowserExports):void { + const interopLocal :NativeBrowserExports = { + }; + Object.assign(interop, interopLocal); + } } /** @@ -88,49 +145,12 @@ export function netTabulateLE(logger:LoggerType, assert:AssertType, netLoaderExp ]; } -function expandLE(table:LoaderExportsTable, logger:LoggerType, assert:AssertType, jsEngine:JSEngineType, netLoaderExports:LoaderExports):void { - const loggerLocal :LoggerType = { - info: table[0], - warn: table[1], - error: table[2], - }; - const assertLocal :AssertType = { - check: table[3], - }; - const loaderExportsLocal :LoaderExports = { - ENVIRONMENT_IS_NODE: table[4], - ENVIRONMENT_IS_SHELL: table[5], - ENVIRONMENT_IS_WEB: table[6], - ENVIRONMENT_IS_WORKER: table[7], - ENVIRONMENT_IS_SIDECAR: table[8], - resolveRunMainPromise: table[9], - rejectRunMainPromise: table[10], - getRunMainPromise: table[11], - }; - const jsEngineLocal :JSEngineType = { - IS_NODE: loaderExportsLocal.ENVIRONMENT_IS_NODE(), - IS_SHELL: loaderExportsLocal.ENVIRONMENT_IS_SHELL(), - IS_WEB: loaderExportsLocal.ENVIRONMENT_IS_WEB(), - IS_WORKER: loaderExportsLocal.ENVIRONMENT_IS_WORKER(), - IS_SIDECAR: loaderExportsLocal.ENVIRONMENT_IS_SIDECAR(), - }; - Object.assign(netLoaderExports, loaderExportsLocal); - Object.assign(logger, loggerLocal); - Object.assign(assert, assertLocal); - Object.assign(jsEngine, jsEngineLocal); -} - // eslint-disable-next-line @typescript-eslint/no-unused-vars export function netTabulateRE(map:RuntimeExports):RuntimeExportsTable { return [ ]; } -function expandRE(table:RuntimeExportsTable, runtime:RuntimeExports):void { - Object.assign(runtime, { - }); -} - export function netTabulateHE(map:HostNativeExports):HostNativeExportsTable { return [ map.registerDllBytes, @@ -138,34 +158,15 @@ export function netTabulateHE(map:HostNativeExports):HostNativeExportsTable { ]; } -function expandHE(table:HostNativeExportsTable, native:HostNativeExports):void { - const nativeLocal :HostNativeExports = { - registerDllBytes: table[0], - isSharedArrayBuffer: table[1], - }; - Object.assign(native, nativeLocal); -} - // eslint-disable-next-line @typescript-eslint/no-unused-vars export function netTabulateJSNE(map:InteropJavaScriptNativeExports):InteropJavaScriptNativeExportsTable { return [ ]; } -function expandJSNE(table:InteropJavaScriptNativeExportsTable, interop:InteropJavaScriptNativeExports):void { - const interopLocal :InteropJavaScriptNativeExports = { - }; - Object.assign(interop, interopLocal); -} - // eslint-disable-next-line @typescript-eslint/no-unused-vars export function netTabulateNBE(map:NativeBrowserExports):NativeBrowserExportsTable { return [ ]; } -function expandNBE(table:NativeBrowserExportsTable, interop:NativeBrowserExports):void { - const interopLocal :NativeBrowserExports = { - }; - Object.assign(interop, interopLocal); -} From 1b932b5eb9d28ec9bf1654081ba7b982c5f49725 Mon Sep 17 00:00:00 2001 From: pavelsavara Date: Thu, 25 Sep 2025 13:58:14 +0200 Subject: [PATCH 04/25] more --- .../System.Native.Browser/libSystem.Native.Browser.extpost.js | 1 + 1 file changed, 1 insertion(+) diff --git a/src/native/libs/System.Native.Browser/libSystem.Native.Browser.extpost.js b/src/native/libs/System.Native.Browser/libSystem.Native.Browser.extpost.js index 8dd8d661d657b4..4a2892ad110b97 100644 --- a/src/native/libs/System.Native.Browser/libSystem.Native.Browser.extpost.js +++ b/src/native/libs/System.Native.Browser/libSystem.Native.Browser.extpost.js @@ -1,3 +1,4 @@ +// // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. From 1cf1e516ffa1109e2e69c49b9caf0c434ea2d65c Mon Sep 17 00:00:00 2001 From: Pavel Savara Date: Thu, 25 Sep 2025 16:06:01 +0200 Subject: [PATCH 05/25] Update src/native/corehost/browserhost/loader/run.ts Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> --- src/native/corehost/browserhost/loader/run.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/native/corehost/browserhost/loader/run.ts b/src/native/corehost/browserhost/loader/run.ts index 1ec137cd4d47fe..d9cef3137fac31 100644 --- a/src/native/corehost/browserhost/loader/run.ts +++ b/src/native/corehost/browserhost/loader/run.ts @@ -15,7 +15,7 @@ export function BrowserHost_InitializeCoreCLR():void { // int BrowserHost_InitializeCoreCLR(void) const res = Module.ccall("BrowserHost_InitializeCoreCLR", "number") as number; if (res != 0) { - const reason = new Error("Failed to netInitializeModule CoreCLR"); + const reason = new Error("Failed to initialize CoreCLR"); runMainPromiseController.reject(reason); exit(res, reason); } From 828f9e969567e4bedef1f3fcc11cb7b1b9c62b71 Mon Sep 17 00:00:00 2001 From: pavelsavara Date: Thu, 25 Sep 2025 16:19:31 +0200 Subject: [PATCH 06/25] feedback --- src/native/rollup.config.defines.js | 2 +- src/native/rollup.config.plugins.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/native/rollup.config.defines.js b/src/native/rollup.config.defines.js index eb7edf563c23a7..55dfb21a9e3bab 100644 --- a/src/native/rollup.config.defines.js +++ b/src/native/rollup.config.defines.js @@ -23,7 +23,7 @@ export const externalDependencies = ["module", "process", "perf_hooks", "node:cr export const artifactsObjDir = "../../artifacts/obj"; export const isDebug = process.env.Configuration !== "Release"; -let gitHash; +export let gitHash; try { const gitInfo = gitCommitInfo(); gitHash = gitInfo.hash; diff --git a/src/native/rollup.config.plugins.js b/src/native/rollup.config.plugins.js index 33eb8ba4a693f5..b4ba790adb91ea 100644 --- a/src/native/rollup.config.plugins.js +++ b/src/native/rollup.config.plugins.js @@ -8,7 +8,7 @@ import * as fs from "fs"; import * as path from "path"; import terser from "@rollup/plugin-terser"; -import { isContinuousIntegrationBuild } from "./rollup.config.defines.js" +import { isContinuousIntegrationBuild, gitHash } from "./rollup.config.defines.js" export const terserPlugin = (terserOptions) => { let { compress, mangle } = terserOptions || {}; From 8b0301cf84fd8e104c5e496097d65614d829827c Mon Sep 17 00:00:00 2001 From: pavelsavara Date: Thu, 25 Sep 2025 20:49:06 +0200 Subject: [PATCH 07/25] more sharing by table/index some renames --- src/native/corehost/browserhost/host/index.ts | 11 ++-- .../browserhost/libBrowserHost.footer.js | 4 +- .../corehost/browserhost/loader/index.ts | 24 ++++---- .../Common/JavaScript/cross-linked/index.ts | 8 +-- .../Common/JavaScript/cross-module/index.ts | 57 ++++++++++--------- .../libs/Common/JavaScript/types/exchange.ts | 8 +-- .../libs/Common/JavaScript/types/internal.ts | 30 ++++++---- .../libSystem.Native.Browser.extpost.js | 2 +- .../libSystem.Native.Browser.footer.js | 2 +- .../native/cross-linked.ts | 4 +- .../System.Native.Browser/native/index.ts | 6 +- .../interop/index.ts | 7 ++- ...nteropServices.JavaScript.Native.footer.js | 2 +- .../native/index.ts | 10 ++-- src/native/rollup.config.defines.js | 8 +-- src/native/rollup.config.js | 2 - 16 files changed, 103 insertions(+), 82 deletions(-) diff --git a/src/native/corehost/browserhost/host/index.ts b/src/native/corehost/browserhost/host/index.ts index 95904ecabfd43c..8efebf378a6ec4 100644 --- a/src/native/corehost/browserhost/host/index.ts +++ b/src/native/corehost/browserhost/host/index.ts @@ -1,7 +1,8 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -import type { InternalExchange, HostNativeExports, RuntimeAPI } from "./types"; +import type { InternalExchange, BrowserHostExports, RuntimeAPI } from "./types"; +import { InternalExchangeIndex } from "./types"; import { } from "./cross-linked"; // ensure ambient symbols are declared import { exit, runMain, runMainAndExit, setEnvironmentVariable, registerDllBytes } from "./host"; @@ -23,13 +24,15 @@ export function netInitializeModule(internals: InternalExchange): void { localHeapViewI8, localHeapViewI16, localHeapViewI32, localHeapViewI64Big, localHeapViewU8, localHeapViewU16, localHeapViewU32, localHeapViewF32, localHeapViewF64, }; - const hostNativeExportsLocal: HostNativeExports = { + const hostNativeExportsLocal: BrowserHostExports = { registerDllBytes, isSharedArrayBuffer }; netSetInternals(internals); - Object.assign(internals.netPublicApi, runtimeApiLocal); - internals.netBrowserHostExportsTable = [...netTabulateHE(hostNativeExportsLocal)]; + Object.assign(internals[InternalExchangeIndex.RuntimeAPI], runtimeApiLocal); + internals[InternalExchangeIndex.BrowserHostExportsTable] = netTabulateBHE(hostNativeExportsLocal); + const updates = internals[InternalExchangeIndex.InternalUpdatesCallbacks]; + if (!updates.includes(netUpdateModuleInternals)) updates.push(netUpdateModuleInternals); netUpdateAllInternals(); } diff --git a/src/native/corehost/browserhost/libBrowserHost.footer.js b/src/native/corehost/browserhost/libBrowserHost.footer.js index 7a64e08ef534ac..7ac2b53ed58393 100644 --- a/src/native/corehost/browserhost/libBrowserHost.footer.js +++ b/src/native/corehost/browserhost/libBrowserHost.footer.js @@ -24,7 +24,7 @@ const HOST_PROPERTY_NATIVE_DLL_SEARCH_DIRECTORIES = "NATIVE_DLL_SEARCH_DIRECTORIES"; const HOST_PROPERTY_APP_PATHS = "APP_PATHS"; - const config = netInternals.netLoaderConfig; + const config = netInternals[2/*InternalExchangeIndex.LoaderConfig*/]; const assemblyPaths = config.resources.assembly.map(a => a.virtualPath); const coreAssemblyPaths = config.resources.coreAssembly.map(a => a.virtualPath); ENV[HOST_PROPERTY_TRUSTED_PLATFORM_ASSEMBLIES] = config.environmentVariables[HOST_PROPERTY_TRUSTED_PLATFORM_ASSEMBLIES] = [...coreAssemblyPaths, ...assemblyPaths].join(":"); @@ -43,7 +43,7 @@ // https://emscripten.org/docs/porting/connecting_cpp_and_javascript/Interacting-with-code.html#javascript-limits-in-library-files // it would execute the code at link time and call .toString() on functions to move it to the final output // this process would loose any closure references, unless they are passed to `__deps` and also explicitly given to the linker - // JS name mangling and minification also applies, see src\native\rollup.config.defines.js and `reservedRx` there + // JS name mangling and minification also applies, see src\native\rollup.config.defines.js and `reserved` there const exports = {} libBrowserHost(exports); let commonDeps = ["$libBrowserHostFn", "$DOTNET", "$DOTNET_INTEROP", "$ENV"]; diff --git a/src/native/corehost/browserhost/loader/index.ts b/src/native/corehost/browserhost/loader/index.ts index 64abae3fdd2cd8..a46c502c397141 100644 --- a/src/native/corehost/browserhost/loader/index.ts +++ b/src/native/corehost/browserhost/loader/index.ts @@ -1,7 +1,8 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -import type { LoggerType, AssertType, RuntimeAPI, LoaderExports } from "./types"; +import type { LoggerType, AssertType, RuntimeAPI, LoaderExports, NativeBrowserExportsTable, LoaderExportsTable, RuntimeExportsTable, InternalExchange, BrowserHostExportsTable, InteropJavaScriptExportsTable } from "./types"; +import { InternalExchangeIndex } from "../types"; import ProductVersion from "consts:productVersion"; import BuildConfiguration from "consts:configuration"; @@ -37,12 +38,17 @@ export function netInitializeModule(): RuntimeAPI { }, }; - const netInternalUpdates: (() => void)[] = []; - netSetInternals({ - netLoaderConfig: netLoaderConfig, - netPublicApi: netPublicApi as RuntimeAPI, - netInternalUpdates, - }); + const internals:InternalExchange = [ + netPublicApi as RuntimeAPI, //0 + [netUpdateModuleInternals], //1 + netLoaderConfig, //2 + null as any as RuntimeExportsTable, //3 + null as any as LoaderExportsTable, //4 + null as any as BrowserHostExportsTable, //5 + null as any as InteropJavaScriptExportsTable, //6 + null as any as NativeBrowserExportsTable, //7 + ]; + netSetInternals(internals); const runtimeApiFunctions: Partial = { getConfig: getLoaderConfig, exit, @@ -78,9 +84,7 @@ export function netInitializeModule(): RuntimeAPI { Object.assign(Assert, assert); Object.assign(netJSEngine, jsEngine); Object.assign(netLoaderExports, loaderFunctions); - netInternals.netLoaderExportsTable = [...netTabulateLE(Logger, Assert, netLoaderExports)]; - netInternalUpdates.push(netUpdateModuleInternals); + netInternals[InternalExchangeIndex.LoaderExportsTable] = netTabulateLE(Logger, Assert, netLoaderExports); netUpdateAllInternals(); - return netPublicApi as RuntimeAPI; } diff --git a/src/native/libs/Common/JavaScript/cross-linked/index.ts b/src/native/libs/Common/JavaScript/cross-linked/index.ts index 839a0d855aa5f9..1fcfa075e0eb57 100644 --- a/src/native/libs/Common/JavaScript/cross-linked/index.ts +++ b/src/native/libs/Common/JavaScript/cross-linked/index.ts @@ -1,7 +1,7 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -import type { AssertType, EmscriptenModuleInternal, JSEngineType, LoggerType, LoaderExports, InternalExchange, RuntimeExports, RuntimeExportsTable, HostNativeExportsTable, HostNativeExports, InteropJavaScriptNativeExports, InteropJavaScriptNativeExportsTable, NativeBrowserExports, NativeBrowserExportsTable } from "../types"; +import type { AssertType, EmscriptenModuleInternal, JSEngineType, LoggerType, LoaderExports, InternalExchange, RuntimeExports, RuntimeExportsTable, BrowserHostExportsTable, BrowserHostExports, InteropJavaScriptExports, InteropJavaScriptExportsTable, NativeBrowserExports, NativeBrowserExportsTable } from "../types"; // we want to use the cross-module symbols defined in closure of dotnet.native.js // which are installed there by libSystem.Native.Browser.footer.js @@ -12,11 +12,11 @@ declare global { export const Module:EmscriptenModuleInternal; export const netJSEngine:JSEngineType; export const netLoaderExports:LoaderExports; - export const netTabulateJSNE:(hostNativeExports:InteropJavaScriptNativeExports) => InteropJavaScriptNativeExportsTable; + export const netTabulateIJSE:(hostNativeExports:InteropJavaScriptExports) => InteropJavaScriptExportsTable; export const netTabulateRE:(hostNativeExports:RuntimeExports) => RuntimeExportsTable; - export const netTabulateHE:(hostNativeExports:HostNativeExports) => HostNativeExportsTable; + export const netTabulateBHE:(hostNativeExports:BrowserHostExports) => BrowserHostExportsTable; export const netTabulateNBE:(hostNativeExports:NativeBrowserExports) => NativeBrowserExportsTable; - export const netTabulateLE:(hostNativeExports:HostNativeExports) => HostNativeExportsTable; + export const netTabulateLE:(hostNativeExports:BrowserHostExports) => BrowserHostExportsTable; export const netSetInternals:(internals:Partial) => void; export const netUpdateAllInternals:() => void; export const netUpdateModuleInternals:() => void; diff --git a/src/native/libs/Common/JavaScript/cross-module/index.ts b/src/native/libs/Common/JavaScript/cross-module/index.ts index d56aa8cc7f125c..860878dab919a8 100644 --- a/src/native/libs/Common/JavaScript/cross-module/index.ts +++ b/src/native/libs/Common/JavaScript/cross-module/index.ts @@ -7,7 +7,8 @@ * Please keep it small and register it into emscripten as dependency. */ -import type { DotnetModuleInternal, InternalExchange, RuntimeExports, LoaderExports, RuntimeAPI, LoggerType, AssertType, JSEngineType, HostNativeExports, InteropJavaScriptNativeExports, LoaderExportsTable, RuntimeExportsTable, HostNativeExportsTable, InteropJavaScriptNativeExportsTable, NativeBrowserExports, NativeBrowserExportsTable } from "../types"; +import type { DotnetModuleInternal, InternalExchange, RuntimeExports, LoaderExports, RuntimeAPI, LoggerType, AssertType, JSEngineType, BrowserHostExports, InteropJavaScriptExports, LoaderExportsTable, RuntimeExportsTable, BrowserHostExportsTable, InteropJavaScriptExportsTable, NativeBrowserExports, NativeBrowserExportsTable } from "../types"; +import { InternalExchangeIndex } from "../types"; export let Module: DotnetModuleInternal; export let netPublicApi: RuntimeAPI; @@ -16,8 +17,8 @@ export let Assert: AssertType = {} as any; export let netJSEngine: JSEngineType = {}as any; export let netLoaderExports: LoaderExports = {} as any; export let netRuntimeExports: RuntimeExports = {} as any; -export let netBrowserHostExports: HostNativeExports = {} as any; -export let netInteropJSExports: InteropJavaScriptNativeExports = {} as any; +export let netBrowserHostExports: BrowserHostExports = {} as any; +export let netInteropJSExports: InteropJavaScriptExports = {} as any; export let netNativeBrowserExports: NativeBrowserExports = {} as any; export let netInternals: InternalExchange; @@ -25,44 +26,44 @@ export function getInternals(): InternalExchange { return netInternals; } -export function netSetInternals(internal: Partial) { - netInternals = internal as InternalExchange; - netPublicApi = netInternals.netPublicApi; - Module = netInternals.netPublicApi.Module as any; - if (netInternals.netInternalUpdates === undefined) { - netInternals.netInternalUpdates = []; +export function netSetInternals(internal: InternalExchange) { + netInternals = internal; + netPublicApi = netInternals[InternalExchangeIndex.RuntimeAPI]; + Module = netPublicApi.Module as any; + if (netInternals[InternalExchangeIndex.InternalUpdatesCallbacks] === undefined) { + netInternals[InternalExchangeIndex.InternalUpdatesCallbacks] = []; } } export function netUpdateAllInternals() { - for (const updateImpl of netInternals.netInternalUpdates) { + for (const updateImpl of netInternals[InternalExchangeIndex.InternalUpdatesCallbacks]) { updateImpl(); } } export function netUpdateModuleInternals() { - if (Object.keys(netLoaderExports).length === 0 && netInternals.netLoaderExportsTable) { + if (Object.keys(netLoaderExports).length === 0 && netInternals[InternalExchangeIndex.LoaderExportsTable]) { netLoaderExports = {} as LoaderExports; Logger = {} as LoggerType; Assert = {} as AssertType; netJSEngine = {} as JSEngineType; - expandLE(netInternals.netLoaderExportsTable, Logger, Assert, netJSEngine, netLoaderExports); + expandLE(netInternals[InternalExchangeIndex.LoaderExportsTable], Logger, Assert, netJSEngine, netLoaderExports); } - if (Object.keys(netRuntimeExports).length === 0 && netInternals.netRuntimeExportsTable) { + if (Object.keys(netRuntimeExports).length === 0 && netInternals[InternalExchangeIndex.RuntimeExportsTable]) { netRuntimeExports = {} as RuntimeExports; - expandRE(netInternals.netRuntimeExportsTable, netRuntimeExports); + expandRE(netInternals[InternalExchangeIndex.RuntimeExportsTable], netRuntimeExports); } - if (Object.keys(netBrowserHostExports).length === 0 && netInternals.netBrowserHostExportsTable) { - netBrowserHostExports = {} as HostNativeExports; - expandHE(netInternals.netBrowserHostExportsTable, netBrowserHostExports); + if (Object.keys(netBrowserHostExports).length === 0 && netInternals[InternalExchangeIndex.BrowserHostExportsTable]) { + netBrowserHostExports = {} as BrowserHostExports; + expandBHE(netInternals[InternalExchangeIndex.BrowserHostExportsTable], netBrowserHostExports); } - if (Object.keys(netInteropJSExports).length === 0 && netInternals.netInteropJSExportsTable) { - netInteropJSExports = {} as InteropJavaScriptNativeExports; - expandJSNE(netInternals.netInteropJSExportsTable, netInteropJSExports); + if (Object.keys(netInteropJSExports).length === 0 && netInternals[InternalExchangeIndex.InteropJavaScriptExportsTable]) { + netInteropJSExports = {} as InteropJavaScriptExports; + expandIJSE(netInternals[InternalExchangeIndex.InteropJavaScriptExportsTable], netInteropJSExports); } - if (Object.keys(netNativeBrowserExports).length === 0 && netInternals.netNativeBrowserExportsTable) { + if (Object.keys(netNativeBrowserExports).length === 0 && netInternals[InternalExchangeIndex.NativeBrowserExportsTable]) { netNativeBrowserExports = {} as NativeBrowserExports; - expandNBE(netInternals.netNativeBrowserExportsTable, netNativeBrowserExports); + expandNBE(netInternals[InternalExchangeIndex.NativeBrowserExportsTable], netNativeBrowserExports); } function expandRE(table:RuntimeExportsTable, runtime:RuntimeExports):void { @@ -102,16 +103,16 @@ export function netUpdateModuleInternals() { Object.assign(jsEngine, jsEngineLocal); } - function expandHE(table:HostNativeExportsTable, native:HostNativeExports):void { - const nativeLocal :HostNativeExports = { + function expandBHE(table:BrowserHostExportsTable, native:BrowserHostExports):void { + const nativeLocal :BrowserHostExports = { registerDllBytes: table[0], isSharedArrayBuffer: table[1], }; Object.assign(native, nativeLocal); } - function expandJSNE(table:InteropJavaScriptNativeExportsTable, interop:InteropJavaScriptNativeExports):void { - const interopLocal :InteropJavaScriptNativeExports = { + function expandIJSE(table:InteropJavaScriptExportsTable, interop:InteropJavaScriptExports):void { + const interopLocal :InteropJavaScriptExports = { }; Object.assign(interop, interopLocal); } @@ -151,7 +152,7 @@ export function netTabulateRE(map:RuntimeExports):RuntimeExportsTable { ]; } -export function netTabulateHE(map:HostNativeExports):HostNativeExportsTable { +export function netTabulateBHE(map:BrowserHostExports):BrowserHostExportsTable { return [ map.registerDllBytes, map.isSharedArrayBuffer, @@ -159,7 +160,7 @@ export function netTabulateHE(map:HostNativeExports):HostNativeExportsTable { } // eslint-disable-next-line @typescript-eslint/no-unused-vars -export function netTabulateJSNE(map:InteropJavaScriptNativeExports):InteropJavaScriptNativeExportsTable { +export function netTabulateIJSE(map:InteropJavaScriptExports):InteropJavaScriptExportsTable { return [ ]; } diff --git a/src/native/libs/Common/JavaScript/types/exchange.ts b/src/native/libs/Common/JavaScript/types/exchange.ts index d0c8e4c2c14484..b7913331f0a651 100644 --- a/src/native/libs/Common/JavaScript/types/exchange.ts +++ b/src/native/libs/Common/JavaScript/types/exchange.ts @@ -56,20 +56,20 @@ export type LoaderExportsTable = [ typeof getRunMainPromise, ] -export type HostNativeExports = { +export type BrowserHostExports = { isSharedArrayBuffer : typeof isSharedArrayBuffer, registerDllBytes: typeof registerDllBytes } -export type HostNativeExportsTable = [ +export type BrowserHostExportsTable = [ typeof registerDllBytes, typeof isSharedArrayBuffer, ] -export type InteropJavaScriptNativeExports = { +export type InteropJavaScriptExports = { } -export type InteropJavaScriptNativeExportsTable = [ +export type InteropJavaScriptExportsTable = [ ] export type NativeBrowserExports = { diff --git a/src/native/libs/Common/JavaScript/types/internal.ts b/src/native/libs/Common/JavaScript/types/internal.ts index 4e4bfd7b3e8abf..317e6eabef5ac9 100644 --- a/src/native/libs/Common/JavaScript/types/internal.ts +++ b/src/native/libs/Common/JavaScript/types/internal.ts @@ -3,7 +3,7 @@ import type { DotnetModuleConfig, RuntimeAPI, AssetEntry, LoaderConfig, LoadingResource } from "./public-api"; import type { CharPtr, EmscriptenModule, ManagedPointer, NativePointer, VoidPtr } from "./emscripten"; -import { InteropJavaScriptNativeExportsTable as InteropJavaScriptExportsTable, LoaderExportsTable, HostNativeExportsTable, RuntimeExportsTable, NativeBrowserExportsTable } from "./exchange"; +import { InteropJavaScriptExportsTable as InteropJavaScriptExportsTable, LoaderExportsTable, BrowserHostExportsTable, RuntimeExportsTable, NativeBrowserExportsTable } from "./exchange"; export type GCHandle = { __brand: "GCHandle" @@ -106,15 +106,25 @@ export interface PromiseController { } -export type InternalExchange = { - netPublicApi: RuntimeAPI, - netRuntimeExportsTable: RuntimeExportsTable, - netLoaderExportsTable: LoaderExportsTable, - netBrowserHostExportsTable: HostNativeExportsTable, - netInteropJSExportsTable: InteropJavaScriptExportsTable, - netNativeBrowserExportsTable: NativeBrowserExportsTable, - netLoaderConfig: LoaderConfigInternal, - netInternalUpdates: (() => void)[], +export type InternalExchange = [ + RuntimeAPI, //0 + (() => void)[], //1 + LoaderConfigInternal, //2 + RuntimeExportsTable, //3 + LoaderExportsTable, //4 + BrowserHostExportsTable, //5 + InteropJavaScriptExportsTable, //6 + NativeBrowserExportsTable, //7 +] +export const enum InternalExchangeIndex { + RuntimeAPI = 0, + InternalUpdatesCallbacks = 1, + LoaderConfig = 2, + RuntimeExportsTable = 3, + LoaderExportsTable = 4, + BrowserHostExportsTable = 5, + InteropJavaScriptExportsTable = 6, + NativeBrowserExportsTable = 7, } export type JsModuleExports = { diff --git a/src/native/libs/System.Native.Browser/libSystem.Native.Browser.extpost.js b/src/native/libs/System.Native.Browser/libSystem.Native.Browser.extpost.js index 4a2892ad110b97..f55d3485ef8c24 100644 --- a/src/native/libs/System.Native.Browser/libSystem.Native.Browser.extpost.js +++ b/src/native/libs/System.Native.Browser/libSystem.Native.Browser.extpost.js @@ -7,5 +7,5 @@ export function netInitializeModule(internals) { if (netNativeModuleLoaded) throw new Error("Native module already loaded"); netInternals = internals; netNativeModuleLoaded = true; - return createDotnetRuntime(netInternals.netPublicApi.Module); + return createDotnetRuntime(netInternals[0/*InternalExchangeIndex.RuntimeAPI*/].Module); } diff --git a/src/native/libs/System.Native.Browser/libSystem.Native.Browser.footer.js b/src/native/libs/System.Native.Browser/libSystem.Native.Browser.footer.js index 7e96f63546fd45..661c1a6ceaa95e 100644 --- a/src/native/libs/System.Native.Browser/libSystem.Native.Browser.footer.js +++ b/src/native/libs/System.Native.Browser/libSystem.Native.Browser.footer.js @@ -13,7 +13,7 @@ // https://emscripten.org/docs/porting/connecting_cpp_and_javascript/Interacting-with-code.html#javascript-limits-in-library-files // it would execute the code at link time and call .toString() on functions to move it to the final output // this process would loose any closure references, unless they are passed to `__deps` and also explicitly given to the linker - // JS name mangling and minification also applies, see src\native\rollup.config.defines.js and `reservedRx` there + // JS name mangling and minification also applies, see src\native\rollup.config.defines.js and `reserved` there const exports = {}; libNativeBrowser(exports); diff --git a/src/native/libs/System.Native.Browser/native/cross-linked.ts b/src/native/libs/System.Native.Browser/native/cross-linked.ts index 954c6bab1adf9d..e14aeaa23d696b 100644 --- a/src/native/libs/System.Native.Browser/native/cross-linked.ts +++ b/src/native/libs/System.Native.Browser/native/cross-linked.ts @@ -4,7 +4,7 @@ import { Assert, Logger, Module, netInternals, netLoaderExports, netPublicApi, netNativeBrowserExports, netRuntimeExports, netJSEngine, netBrowserHostExports, netInteropJSExports, - netTabulateNBE, netTabulateHE, netTabulateJSNE, netTabulateLE, netTabulateRE, + netTabulateNBE, netTabulateBHE, netTabulateIJSE, netTabulateLE, netTabulateRE, getInternals, netSetInternals, netUpdateAllInternals, netUpdateModuleInternals, } from "../cross-module"; @@ -15,6 +15,6 @@ export function crossLink() { Assert, Logger, Module, netInternals, netLoaderExports, netPublicApi, netNativeBrowserExports, netRuntimeExports, netJSEngine, netBrowserHostExports, netInteropJSExports, getInternals, netSetInternals, netUpdateAllInternals, netUpdateModuleInternals, - netTabulateHE, netTabulateJSNE, netTabulateLE, netTabulateNBE, netTabulateRE + netTabulateBHE, netTabulateIJSE, netTabulateLE, netTabulateNBE, netTabulateRE ]; } diff --git a/src/native/libs/System.Native.Browser/native/index.ts b/src/native/libs/System.Native.Browser/native/index.ts index ef4f9fbb941895..8fe2cb5f2be3a1 100644 --- a/src/native/libs/System.Native.Browser/native/index.ts +++ b/src/native/libs/System.Native.Browser/native/index.ts @@ -2,6 +2,7 @@ // The .NET Foundation licenses this file to you under the MIT license. import type { InternalExchange, NativeBrowserExports } from "../types"; +import { InternalExchangeIndex } from "../types"; export { SystemJS_RandomBytes } from "./crypto"; @@ -9,8 +10,9 @@ export function netInitializeModule(internals: InternalExchange): void { const nativeBrowserExportsLocal: NativeBrowserExports = { }; netSetInternals(internals); - internals.netNativeBrowserExportsTable = [...netTabulateNBE(nativeBrowserExportsLocal)]; - internals.netInternalUpdates.push(netUpdateModuleInternals); + internals[InternalExchangeIndex.NativeBrowserExportsTable] = netTabulateNBE(nativeBrowserExportsLocal); + const updates = internals[InternalExchangeIndex.InternalUpdatesCallbacks]; + if (!updates.includes(netUpdateModuleInternals)) updates.push(netUpdateModuleInternals); netUpdateAllInternals(); } diff --git a/src/native/libs/System.Runtime.InteropServices.JavaScript.Native/interop/index.ts b/src/native/libs/System.Runtime.InteropServices.JavaScript.Native/interop/index.ts index 0ebe68f4dd510b..e0edb0e0954528 100644 --- a/src/native/libs/System.Runtime.InteropServices.JavaScript.Native/interop/index.ts +++ b/src/native/libs/System.Runtime.InteropServices.JavaScript.Native/interop/index.ts @@ -2,6 +2,7 @@ // The .NET Foundation licenses this file to you under the MIT license. import type { InternalExchange, RuntimeAPI, RuntimeExports } from "./types"; +import { InternalExchangeIndex } from "../types"; import { netSetInternals, netUpdateAllInternals, netUpdateModuleInternals, netTabulateRE } from "./cross-module"; export function netInitializeModule(internals: InternalExchange): void { @@ -12,9 +13,9 @@ export function netInitializeModule(internals: InternalExchange): void { const runtimeExportsLocal: RuntimeExports = { }; netSetInternals(internals); - Object.assign(internals.netPublicApi, runtimeApiLocal); - internals.netRuntimeExportsTable = [...netTabulateRE(runtimeExportsLocal)]; - internals.netInternalUpdates.push(netUpdateModuleInternals); + Object.assign(internals[InternalExchangeIndex.RuntimeAPI], runtimeApiLocal); + internals[InternalExchangeIndex.RuntimeExportsTable] = netTabulateRE(runtimeExportsLocal); + internals[InternalExchangeIndex.InternalUpdatesCallbacks].push(netUpdateModuleInternals); netUpdateAllInternals(); } diff --git a/src/native/libs/System.Runtime.InteropServices.JavaScript.Native/libSystem.Runtime.InteropServices.JavaScript.Native.footer.js b/src/native/libs/System.Runtime.InteropServices.JavaScript.Native/libSystem.Runtime.InteropServices.JavaScript.Native.footer.js index 1b34c72bd50084..c77ba573b51105 100644 --- a/src/native/libs/System.Runtime.InteropServices.JavaScript.Native/libSystem.Runtime.InteropServices.JavaScript.Native.footer.js +++ b/src/native/libs/System.Runtime.InteropServices.JavaScript.Native/libSystem.Runtime.InteropServices.JavaScript.Native.footer.js @@ -13,7 +13,7 @@ // https://emscripten.org/docs/porting/connecting_cpp_and_javascript/Interacting-with-code.html#javascript-limits-in-library-files // it would execute the code at link time and call .toString() on functions to move it to the final output // this process would loose any closure references, unless they are passed to `__deps` and also explicitly given to the linker - // JS name mangling and minification also applies, see src\native\rollup.config.defines.js and `reservedRx` there + // JS name mangling and minification also applies, see src\native\rollup.config.defines.js and `reserved` there const exports = {}; libInteropJavaScriptNative(exports); diff --git a/src/native/libs/System.Runtime.InteropServices.JavaScript.Native/native/index.ts b/src/native/libs/System.Runtime.InteropServices.JavaScript.Native/native/index.ts index 07874f91b26633..293d95089fcdbd 100644 --- a/src/native/libs/System.Runtime.InteropServices.JavaScript.Native/native/index.ts +++ b/src/native/libs/System.Runtime.InteropServices.JavaScript.Native/native/index.ts @@ -1,7 +1,8 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -import type { InternalExchange, InteropJavaScriptNativeExports, JSFnHandle, JSMarshalerArguments } from "../interop/types"; +import type { InternalExchange, InteropJavaScriptExports, JSFnHandle, JSMarshalerArguments } from "../interop/types"; +import { InternalExchangeIndex } from "../types"; import { } from "./cross-linked"; // ensure ambient symbols are declared // eslint-disable-next-line @typescript-eslint/no-unused-vars @@ -12,10 +13,11 @@ export function SystemInteropJS_InvokeJSImportST(function_handle: JSFnHandle, ar } export function netInitializeModule(internals: InternalExchange): void { - const interopJavaScriptNativeExportsLocal: InteropJavaScriptNativeExports = { + const interopJavaScriptNativeExportsLocal: InteropJavaScriptExports = { }; netSetInternals(internals); - internals.netInteropJSExportsTable = [...netTabulateJSNE(interopJavaScriptNativeExportsLocal)]; - internals.netInternalUpdates.push(netUpdateModuleInternals); + internals[InternalExchangeIndex.InteropJavaScriptExportsTable] = netTabulateIJSE(interopJavaScriptNativeExportsLocal); + const updates = internals[InternalExchangeIndex.InternalUpdatesCallbacks]; + if (!updates.includes(netUpdateModuleInternals)) updates.push(netUpdateModuleInternals); netUpdateAllInternals(); } diff --git a/src/native/rollup.config.defines.js b/src/native/rollup.config.defines.js index 55dfb21a9e3bab..fcd4605dd08634 100644 --- a/src/native/rollup.config.defines.js +++ b/src/native/rollup.config.defines.js @@ -12,16 +12,16 @@ console.log(`Rollup configuration: Configuration=${configuration}, ProductVersio export const banner = "//! Licensed to the .NET Foundation under one or more agreements.\n//! The .NET Foundation licenses this file to you under the MIT license.\n//! This is generated file, see src/native/libs/Browser/rollup.config.defines.js\n\n"; export const banner_dts = banner + "//! This is not considered public API with backward compatibility guarantees. \n"; export const keep_classnames = /(ManagedObject|ManagedError|Span|ArraySegment)/; -export const keep_fnames = /(netSetInternals|netUpdateAllInternals|netUpdateModuleInternals|netTabulateLE|netTabulateRE|netTabulateHE|netTabulateJSNE|netTabulateNBE)/; +export const keep_fnames = /(netSetInternals|netUpdateAllInternals|netUpdateModuleInternals|netTabulateLE|netTabulateRE|netTabulateBHE|netTabulateIJSE|netTabulateNBE)/; export const reserved = [ - "Logger", "Assert", "netJSEngine", "Module", "netInternals", "netPublicApi", "netInternalUpdates", + "Logger", "Assert", "netJSEngine", "Module", "netInternals", "netPublicApi", "netSetInternals", "netUpdateAllInternals", "netUpdateModuleInternals", "netInitializeModule", "netLoaderExports", "netRuntimeExports", "netBrowserHostExports", "netInteropJSExports", "netNativeBrowserExports", - "netTabulateLE", "netTabulateRE", "netTabulateHE", "netTabulateJSNE", "netTabulateNBE"]; + "netTabulateLE", "netTabulateRE", "netTabulateBHE", "netTabulateIJSE", "netTabulateNBE"]; export const externalDependencies = ["module", "process", "perf_hooks", "node:crypto"]; export const artifactsObjDir = "../../artifacts/obj"; -export const isDebug = process.env.Configuration !== "Release"; +export const isDebug = false;//process.env.Configuration !== "Release"; export let gitHash; try { diff --git a/src/native/rollup.config.js b/src/native/rollup.config.js index 6684639c2764fb..f0f6e7bf4415e4 100644 --- a/src/native/rollup.config.js +++ b/src/native/rollup.config.js @@ -44,7 +44,6 @@ const dotnetJS = configure({ module: true, }, mangle: { module: true, - reserved } } }); @@ -80,7 +79,6 @@ const dotnetRuntimeJS = configure({ }, mangle: { module: true, keep_classnames, - reserved } } }); From 4af1ad6b40e587882e84b7c026b4a6a7370d8c26 Mon Sep 17 00:00:00 2001 From: pavelsavara Date: Thu, 25 Sep 2025 20:58:23 +0200 Subject: [PATCH 08/25] fix --- src/native/rollup.config.defines.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/native/rollup.config.defines.js b/src/native/rollup.config.defines.js index fcd4605dd08634..89bdf74783679a 100644 --- a/src/native/rollup.config.defines.js +++ b/src/native/rollup.config.defines.js @@ -21,7 +21,7 @@ export const reserved = [ export const externalDependencies = ["module", "process", "perf_hooks", "node:crypto"]; export const artifactsObjDir = "../../artifacts/obj"; -export const isDebug = false;//process.env.Configuration !== "Release"; +export const isDebug = process.env.Configuration !== "Release"; export let gitHash; try { From 12619cf3d907d47f42d30b5a820b5919be95b511 Mon Sep 17 00:00:00 2001 From: pavelsavara Date: Thu, 25 Sep 2025 20:58:46 +0200 Subject: [PATCH 09/25] fix --- src/native/rollup.config.plugins.js | 4 ---- 1 file changed, 4 deletions(-) diff --git a/src/native/rollup.config.plugins.js b/src/native/rollup.config.plugins.js index b4ba790adb91ea..9e877d5467b456 100644 --- a/src/native/rollup.config.plugins.js +++ b/src/native/rollup.config.plugins.js @@ -23,10 +23,6 @@ export const terserPlugin = (terserOptions) => { drop_console: false, // we log to console ...compress }, - // WASM-TODO: remove beautify - format: { - beautify: true, - }, mangle: { ...mangle, }, From ac5aa58d261804c54a68133a97b33159dbe8325c Mon Sep 17 00:00:00 2001 From: pavelsavara Date: Thu, 25 Sep 2025 21:02:30 +0200 Subject: [PATCH 10/25] comment --- .../System.Native.Browser/libSystem.Native.Browser.footer.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/native/libs/System.Native.Browser/libSystem.Native.Browser.footer.js b/src/native/libs/System.Native.Browser/libSystem.Native.Browser.footer.js index 661c1a6ceaa95e..f783fe3c2b9965 100644 --- a/src/native/libs/System.Native.Browser/libSystem.Native.Browser.footer.js +++ b/src/native/libs/System.Native.Browser/libSystem.Native.Browser.footer.js @@ -32,7 +32,7 @@ $DOTNET__postset: "DOTNET.selfInitialize()", }; - // keep in sync with `crossModule`+`crossModuleFn` in src\native\rollup.config.defines.js + // keep in sync with `reserved`+`keep_fnames` in src\native\rollup.config.defines.js for (const exportName of Reflect.ownKeys(exports.cross)) { const name = String(exportName); if (name === "netInternals") continue; From 3fa7292b5f9b4248e7a99099aee364ac920ee46d Mon Sep 17 00:00:00 2001 From: pavelsavara Date: Thu, 25 Sep 2025 21:31:51 +0200 Subject: [PATCH 11/25] feedback: dotnet prefix --- src/native/corehost/browserhost/host/host.ts | 10 +- src/native/corehost/browserhost/host/index.ts | 10 +- .../corehost/browserhost/host/memory.ts | 20 +-- .../browserhost/libBrowserHost.footer.js | 10 +- .../corehost/browserhost/loader/bootstrap.ts | 16 +-- .../corehost/browserhost/loader/dotnet.ts | 4 +- .../corehost/browserhost/loader/exit.ts | 6 +- .../browserhost/loader/host-builder.ts | 12 +- .../corehost/browserhost/loader/index.ts | 34 ++--- .../corehost/browserhost/loader/logging.ts | 2 +- .../corehost/browserhost/loader/polyfills.ts | 6 +- .../Common/JavaScript/cross-linked/index.ts | 26 ++-- .../Common/JavaScript/cross-module/index.ts | 116 +++++++++--------- .../libs/Common/JavaScript/types/exchange.ts | 4 +- .../libs/Common/JavaScript/types/internal.ts | 2 +- .../libSystem.Native.Browser.extpost.js | 8 +- .../libSystem.Native.Browser.footer.js | 12 +- .../native/cross-linked.ts | 16 +-- .../System.Native.Browser/native/crypto.ts | 8 +- .../System.Native.Browser/native/index.ts | 10 +- .../dotnet.runtime.ts | 2 +- .../interop/index.ts | 12 +- ...nteropServices.JavaScript.Native.footer.js | 10 +- .../native/index.ts | 12 +- src/native/rollup.config.defines.js | 11 +- 25 files changed, 190 insertions(+), 189 deletions(-) diff --git a/src/native/corehost/browserhost/host/host.ts b/src/native/corehost/browserhost/host/host.ts index 84a4edfac889e3..d9b98ca9c4ae33 100644 --- a/src/native/corehost/browserhost/host/host.ts +++ b/src/native/corehost/browserhost/host/host.ts @@ -41,11 +41,11 @@ export function BrowserHost_ExternalAssemblyProbe(pathPtr:CharPtr, outDataStartP } export function BrowserHost_ResolveMain(exitCode:number) { - netLoaderExports.resolveRunMainPromise(exitCode); + dotnetLoaderExports.resolveRunMainPromise(exitCode); } export function BrowserHost_RejectMain(reason:any) { - netLoaderExports.rejectRunMainPromise(reason); + dotnetLoaderExports.rejectRunMainPromise(reason); } // WASM-TODO: take ideas from Mono @@ -56,9 +56,9 @@ export function BrowserHost_RejectMain(reason:any) { export function exit(exit_code: number, reason: any): void { const reasonStr = reason ? (reason.stack ? reason.stack || reason.message : reason.toString()) : ""; if (exit_code !== 0) { - Logger.error(`Exit with code ${exit_code} ${reason ? "and reason: " + reasonStr : ""}`); + dotnetLogger.error(`Exit with code ${exit_code} ${reason ? "and reason: " + reasonStr : ""}`); } - if (netJSEngine.IS_NODE) { + if (dotnetJSEngine.IS_NODE) { (globalThis as any).process.exit(exit_code); } } @@ -73,7 +73,7 @@ export async function runMain(mainAssemblyName?: string, args?: string[]): Promi throw reason; } - return netLoaderExports.getRunMainPromise(); + return dotnetLoaderExports.getRunMainPromise(); } // eslint-disable-next-line @typescript-eslint/no-unused-vars diff --git a/src/native/corehost/browserhost/host/index.ts b/src/native/corehost/browserhost/host/index.ts index 8efebf378a6ec4..80643f45ace852 100644 --- a/src/native/corehost/browserhost/host/index.ts +++ b/src/native/corehost/browserhost/host/index.ts @@ -13,7 +13,7 @@ import { isSharedArrayBuffer, } from "./memory"; -export function netInitializeModule(internals: InternalExchange): void { +export function dotnetInitializeModule(internals: InternalExchange): void { const runtimeApiLocal: Partial = { runMain, runMainAndExit, @@ -28,12 +28,12 @@ export function netInitializeModule(internals: InternalExchange): void { registerDllBytes, isSharedArrayBuffer }; - netSetInternals(internals); + dotnetSetInternals(internals); Object.assign(internals[InternalExchangeIndex.RuntimeAPI], runtimeApiLocal); - internals[InternalExchangeIndex.BrowserHostExportsTable] = netTabulateBHE(hostNativeExportsLocal); + internals[InternalExchangeIndex.BrowserHostExportsTable] = dotnetTabBHE(hostNativeExportsLocal); const updates = internals[InternalExchangeIndex.InternalUpdatesCallbacks]; - if (!updates.includes(netUpdateModuleInternals)) updates.push(netUpdateModuleInternals); - netUpdateAllInternals(); + if (!updates.includes(dotnetUpdateModuleInternals)) updates.push(dotnetUpdateModuleInternals); + dotnetUpdateAllInternals(); } export { BrowserHost_ExternalAssemblyProbe, BrowserHost_ResolveMain, BrowserHost_RejectMain } from "./host"; diff --git a/src/native/corehost/browserhost/host/memory.ts b/src/native/corehost/browserhost/host/memory.ts index 1262382c46aac4..67daa9467e143e 100644 --- a/src/native/corehost/browserhost/host/memory.ts +++ b/src/native/corehost/browserhost/host/memory.ts @@ -9,8 +9,8 @@ export const min_int64_big = BigInt("-9223372036854775808"); export const sharedArrayBufferDefined = typeof SharedArrayBuffer !== "undefined"; export function assert_int_in_range(value: Number, min: Number, max: Number) { - Assert.check(Number.isSafeInteger(value), () => `Value is not an integer: ${value} (${typeof (value)})`); - Assert.check(value >= min && value <= max, () => `Overflow: value ${value} is out of ${min} ${max} range`); + dotnetAssert.check(Number.isSafeInteger(value), () => `Value is not an integer: ${value} (${typeof (value)})`); + dotnetAssert.check(value >= min && value <= max, () => `Overflow: value ${value} is out of ${min} ${max} range`); } export function _zero_region(byteOffset: VoidPtr, sizeBytes: number): void { @@ -86,7 +86,7 @@ export function setHeapI32(offset: MemOffset, value: number): void { * Throws for values which are not 52 bit integer. See Number.isSafeInteger() */ export function setHeapI52(offset: MemOffset, value: number): void { - Assert.check(Number.isSafeInteger(value), () => `Value is not a safe integer: ${value} (${typeof (value)})`); + dotnetAssert.check(Number.isSafeInteger(value), () => `Value is not a safe integer: ${value} (${typeof (value)})`); throw new Error("TODO"); // const error = cwraps.mono_wasm_f64_to_i52(offset, value); // autoThrowI52(error); @@ -96,27 +96,27 @@ export function setHeapI52(offset: MemOffset, value: number): void { * Throws for values which are not 52 bit integer or are negative. See Number.isSafeInteger(). */ export function setHeapU52(offset: MemOffset, value: number): void { - Assert.check(Number.isSafeInteger(value), () => `Value is not a safe integer: ${value} (${typeof (value)})`); - Assert.check(value >= 0, "Can't convert negative Number into UInt64"); + dotnetAssert.check(Number.isSafeInteger(value), () => `Value is not a safe integer: ${value} (${typeof (value)})`); + dotnetAssert.check(value >= 0, "Can't convert negative Number into UInt64"); throw new Error("TODO"); //const error = cwraps.mono_wasm_f64_to_u52(offset, value); //autoThrowI52(error); } export function setHeapI64Big(offset: MemOffset, value: bigint): void { - Assert.check(typeof value === "bigint", () => `Value is not an bigint: ${value} (${typeof (value)})`); - Assert.check(value >= min_int64_big && value <= max_int64_big, () => `Overflow: value ${value} is out of ${min_int64_big} ${max_int64_big} range`); + dotnetAssert.check(typeof value === "bigint", () => `Value is not an bigint: ${value} (${typeof (value)})`); + dotnetAssert.check(value >= min_int64_big && value <= max_int64_big, () => `Overflow: value ${value} is out of ${min_int64_big} ${max_int64_big} range`); Module.HEAP64[offset >>> 3] = value; } export function setHeapF32(offset: MemOffset, value: number): void { - Assert.check(typeof value === "number", () => `Value is not a Number: ${value} (${typeof (value)})`); + dotnetAssert.check(typeof value === "number", () => `Value is not a Number: ${value} (${typeof (value)})`); Module.HEAPF32[offset >>> 2] = value; } export function setHeapF64(offset: MemOffset, value: number): void { - Assert.check(typeof value === "number", () => `Value is not a Number: ${value} (${typeof (value)})`); + dotnetAssert.check(typeof value === "number", () => `Value is not a Number: ${value} (${typeof (value)})`); Module.HEAPF64[offset >>> 3] = value; } @@ -124,7 +124,7 @@ export function getHeapB32(offset: MemOffset): boolean { const value = (Module.HEAPU32[offset >>> 2]); if (value > 1 && !(getHeapB32 as any).warnDirtyBool) { (getHeapB32 as any).warnDirtyBool = true; - Logger.warn(`getB32: value at ${offset} is not a boolean, but a number: ${value}`); + dotnetLogger.warn(`getB32: value at ${offset} is not a boolean, but a number: ${value}`); } return !!value; } diff --git a/src/native/corehost/browserhost/libBrowserHost.footer.js b/src/native/corehost/browserhost/libBrowserHost.footer.js index 7ac2b53ed58393..f6afcdb9ee5f3b 100644 --- a/src/native/corehost/browserhost/libBrowserHost.footer.js +++ b/src/native/corehost/browserhost/libBrowserHost.footer.js @@ -11,12 +11,12 @@ const lib = { $BROWSER_HOST: { selfInitialize: () => { - if (typeof netInternals !== "undefined") { - BROWSER_HOST.netInternals = netInternals; + if (typeof dotnetInternals !== "undefined") { + BROWSER_HOST.dotnetInternals = dotnetInternals; const exports = {}; libBrowserHostFn(exports); - exports.netInitializeModule(netInternals); + exports.dotnetInitializeModule(dotnetInternals); BROWSER_HOST.assignExports(exports, BROWSER_HOST); const HOST_PROPERTY_TRUSTED_PLATFORM_ASSEMBLIES = "TRUSTED_PLATFORM_ASSEMBLIES"; @@ -24,7 +24,7 @@ const HOST_PROPERTY_NATIVE_DLL_SEARCH_DIRECTORIES = "NATIVE_DLL_SEARCH_DIRECTORIES"; const HOST_PROPERTY_APP_PATHS = "APP_PATHS"; - const config = netInternals[2/*InternalExchangeIndex.LoaderConfig*/]; + const config = dotnetInternals[2/*InternalExchangeIndex.LoaderConfig*/]; const assemblyPaths = config.resources.assembly.map(a => a.virtualPath); const coreAssemblyPaths = config.resources.coreAssembly.map(a => a.virtualPath); ENV[HOST_PROPERTY_TRUSTED_PLATFORM_ASSEMBLIES] = config.environmentVariables[HOST_PROPERTY_TRUSTED_PLATFORM_ASSEMBLIES] = [...coreAssemblyPaths, ...assemblyPaths].join(":"); @@ -50,7 +50,7 @@ let assignExportsBuilder = ""; for (const exportName of Reflect.ownKeys(exports)) { const name = String(exportName); - if (name === "netInitializeModule") continue; + if (name === "dotnetInitializeModule") continue; lib[name] = () => "dummy"; assignExportsBuilder += `_${String(name)} = exports.${String(name)};\n`; } diff --git a/src/native/corehost/browserhost/loader/bootstrap.ts b/src/native/corehost/browserhost/loader/bootstrap.ts index 1cd5938c727798..6b3088e5b7127c 100644 --- a/src/native/corehost/browserhost/loader/bootstrap.ts +++ b/src/native/corehost/browserhost/loader/bootstrap.ts @@ -3,7 +3,7 @@ import type { LoadBootResourceCallback, JsModuleExports, JsAsset, AssemblyAsset, PdbAsset, WasmAsset, IcuAsset, EmscriptenModuleInternal } from "./types"; -import { Assert, netJSEngine, getInternals, netBrowserHostExports, netUpdateAllInternals } from "./cross-module"; +import { dotnetAssert, dotnetJSEngine, dotnetGetInternals, dotnetBrowserHostExports, dotnetUpdateAllInternals } from "./cross-module"; import { getLoaderConfig } from "./config"; import { BrowserHost_InitializeCoreCLR } from "./run"; import { createPromiseController } from "./promise-controller"; @@ -15,7 +15,7 @@ const scriptUrl = normalizeFileUrl(scriptUrlQuery); const scriptDirectory = normalizeDirectoryUrl(scriptUrl); const nativeModulePromiseController = createPromiseController(() => { - netUpdateAllInternals(); + dotnetUpdateAllInternals(); }); // WASM-TODO: retry logic @@ -36,11 +36,11 @@ export async function createRuntime(downloadOnly: boolean, loadBootResource?: Lo // WASM-TODO fetchWasm(config.resources.wasmNative[0]);// start loading early, no await const nativeModule = await nativeModulePromise; - const modulePromise = nativeModule.netInitializeModule(getInternals()); + const modulePromise = nativeModule.dotnetInitializeModule(dotnetGetInternals()); nativeModulePromiseController.propagateFrom(modulePromise); const runtimeModule = await runtimeModulePromise; - const runtimeModuleReady = runtimeModule.netInitializeModule(getInternals()); + const runtimeModuleReady = runtimeModule.dotnetInitializeModule(dotnetGetInternals()); await nativeModulePromiseController.promise; await coreAssembliesPromise; @@ -76,12 +76,12 @@ async function fetchDll(asset: AssemblyAsset): Promise { const bytes = await fetchBytes(asset); await nativeModulePromiseController.promise; - netBrowserHostExports.registerDllBytes(bytes, asset); + dotnetBrowserHostExports.registerDllBytes(bytes, asset); } async function fetchBytes(asset: WasmAsset|AssemblyAsset|PdbAsset|IcuAsset): Promise { - Assert.check(asset && asset.resolvedUrl, "Bad asset.resolvedUrl"); - if (netJSEngine.IS_NODE) { + dotnetAssert.check(asset && asset.resolvedUrl, "Bad asset.resolvedUrl"); + if (dotnetJSEngine.IS_NODE) { const { promises: fs } = await import("fs"); const { fileURLToPath } = await import(/*! webpackIgnore: true */"url"); const isFileUrl = asset.resolvedUrl!.startsWith("file://"); @@ -122,7 +122,7 @@ function normalizeDirectoryUrl(dir: string) { const protocolRx = /^[a-zA-Z][a-zA-Z\d+\-.]*?:\/\//; const windowsAbsoluteRx = /[a-zA-Z]:[\\/]/; function isPathAbsolute(path: string): boolean { - if (netJSEngine.IS_NODE || netJSEngine.IS_SHELL) { + if (dotnetJSEngine.IS_NODE || dotnetJSEngine.IS_SHELL) { // unix /x.json // windows \x.json // windows C:\x.json diff --git a/src/native/corehost/browserhost/loader/dotnet.ts b/src/native/corehost/browserhost/loader/dotnet.ts index 5bbba2005bdd1b..a6bf53a108ab87 100644 --- a/src/native/corehost/browserhost/loader/dotnet.ts +++ b/src/native/corehost/browserhost/loader/dotnet.ts @@ -14,10 +14,10 @@ import { HostBuilder } from "./host-builder"; import { initPolyfills, initPolyfillsAsync } from "./polyfills"; import { registerRuntime } from "./runtime-list"; import { exit } from "./exit"; -import { netInitializeModule } from "."; +import { dotnetInitializeModule } from "."; initPolyfills(); -registerRuntime(netInitializeModule()); +registerRuntime(dotnetInitializeModule()); await initPolyfillsAsync(); export const dotnet: DotnetHostBuilder | undefined = new HostBuilder() as DotnetHostBuilder; diff --git a/src/native/corehost/browserhost/loader/exit.ts b/src/native/corehost/browserhost/loader/exit.ts index f64a68a27d19ee..b964d787fd164d 100644 --- a/src/native/corehost/browserhost/loader/exit.ts +++ b/src/native/corehost/browserhost/loader/exit.ts @@ -1,15 +1,15 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -import { netJSEngine, Logger } from "./cross-module"; +import { dotnetJSEngine, dotnetLogger } from "./cross-module"; // eslint-disable-next-line @typescript-eslint/no-unused-vars export function exit(exit_code: number, reason: any): void { const reasonStr = reason ? (reason.stack ? reason.stack || reason.message : reason.toString()) : ""; if (exit_code !== 0) { - Logger.error(`Exit with code ${exit_code} ${reason ? "and reason: " + reasonStr : ""}`); + dotnetLogger.error(`Exit with code ${exit_code} ${reason ? "and reason: " + reasonStr : ""}`); } - if (netJSEngine.IS_NODE) { + if (dotnetJSEngine.IS_NODE) { (globalThis as any).process.exit(exit_code); } } diff --git a/src/native/corehost/browserhost/loader/host-builder.ts b/src/native/corehost/browserhost/loader/host-builder.ts index 81e754a1edf455..6078b8272e042b 100644 --- a/src/native/corehost/browserhost/loader/host-builder.ts +++ b/src/native/corehost/browserhost/loader/host-builder.ts @@ -3,7 +3,7 @@ import type { DotnetHostBuilder, LoaderConfig, RuntimeAPI, LoadBootResourceCallback, DotnetModuleConfig } from "./types"; -import { Module, netPublicApi } from "./cross-module"; +import { Module, dotnetApi } from "./cross-module"; import { downloadConfig, getLoaderConfig, mergeLoaderConfig } from "./config"; import { createRuntime } from "./bootstrap"; import { exit } from "./exit"; @@ -14,7 +14,7 @@ let loadBootResourceCallback: LoadBootResourceCallback | undefined = undefined; /* eslint-disable @typescript-eslint/no-unused-vars */ export class HostBuilder implements DotnetHostBuilder { - private netPublicApi: RuntimeAPI | undefined; + private dotnetApi: RuntimeAPI | undefined; withConfig(config: LoaderConfig): DotnetHostBuilder { mergeLoaderConfig(config); return this; @@ -151,8 +151,8 @@ export class HostBuilder implements DotnetHostBuilder { try { await downloadConfig(configUrl, loadBootResourceCallback); await createRuntime(false, loadBootResourceCallback); - this.netPublicApi = netPublicApi; - return this.netPublicApi; + this.dotnetApi = dotnetApi; + return this.dotnetApi; } catch (err) { exit(1, err); throw err; @@ -161,11 +161,11 @@ export class HostBuilder implements DotnetHostBuilder { async run(): Promise { try { - if (!this.netPublicApi) { + if (!this.dotnetApi) { await this.create(); } const config = getLoaderConfig(); - return this.netPublicApi!.runMainAndExit(config.mainAssemblyName, applicationArguments); + return this.dotnetApi!.runMainAndExit(config.mainAssemblyName, applicationArguments); } catch (err) { exit(1, err); throw err; diff --git a/src/native/corehost/browserhost/loader/index.ts b/src/native/corehost/browserhost/loader/index.ts index a46c502c397141..8f6466867d51fd 100644 --- a/src/native/corehost/browserhost/loader/index.ts +++ b/src/native/corehost/browserhost/loader/index.ts @@ -1,7 +1,7 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -import type { LoggerType, AssertType, RuntimeAPI, LoaderExports, NativeBrowserExportsTable, LoaderExportsTable, RuntimeExportsTable, InternalExchange, BrowserHostExportsTable, InteropJavaScriptExportsTable } from "./types"; +import type { dotnetLoggerType, dotnetAssertType, RuntimeAPI, LoaderExports, NativeBrowserExportsTable, LoaderExportsTable, RuntimeExportsTable, InternalExchange, BrowserHostExportsTable, InteropJavaScriptExportsTable } from "./types"; import { InternalExchangeIndex } from "../types"; import ProductVersion from "consts:productVersion"; @@ -13,10 +13,10 @@ import { exit } from "./exit"; import { invokeLibraryInitializers } from "./lib-initializers"; import { check, error, info, warn } from "./logging"; -import { Assert, netInternals, netJSEngine, netLoaderExports, netTabulateLE, Logger, netSetInternals, netUpdateAllInternals, netUpdateModuleInternals } from "./cross-module"; +import { dotnetAssert, dotnetInternals, dotnetJSEngine, dotnetLoaderExports, dotnetTabLE, dotnetLogger, dotnetSetInternals, dotnetUpdateAllInternals, dotnetUpdateModuleInternals } from "./cross-module"; import { rejectRunMainPromise, resolveRunMainPromise, getRunMainPromise } from "./run"; -export function netInitializeModule(): RuntimeAPI { +export function dotnetInitializeModule(): RuntimeAPI { const ENVIRONMENT_IS_NODE = () => typeof process == "object" && typeof process.versions == "object" && typeof process.versions.node == "string"; const ENVIRONMENT_IS_WEB_WORKER = () => typeof importScripts == "function"; const ENVIRONMENT_IS_SIDECAR = () => ENVIRONMENT_IS_WEB_WORKER() && typeof dotnetSidecar !== "undefined"; // sidecar is emscripten main running in a web worker @@ -24,7 +24,7 @@ export function netInitializeModule(): RuntimeAPI { const ENVIRONMENT_IS_WEB = () => typeof window == "object" || (ENVIRONMENT_IS_WEB_WORKER() && !ENVIRONMENT_IS_NODE()); const ENVIRONMENT_IS_SHELL = () => !ENVIRONMENT_IS_WEB() && !ENVIRONMENT_IS_NODE(); - const netPublicApi: Partial = { + const dotnetApi: Partial = { INTERNAL: {}, Module: {} as any, runtimeId: -1, @@ -39,8 +39,8 @@ export function netInitializeModule(): RuntimeAPI { }; const internals:InternalExchange = [ - netPublicApi as RuntimeAPI, //0 - [netUpdateModuleInternals], //1 + dotnetApi as RuntimeAPI, //0 + [dotnetUpdateModuleInternals], //1 netLoaderConfig, //2 null as any as RuntimeExportsTable, //3 null as any as LoaderExportsTable, //4 @@ -48,7 +48,7 @@ export function netInitializeModule(): RuntimeAPI { null as any as InteropJavaScriptExportsTable, //6 null as any as NativeBrowserExportsTable, //7 ]; - netSetInternals(internals); + dotnetSetInternals(internals); const runtimeApiFunctions: Partial = { getConfig: getLoaderConfig, exit, @@ -71,20 +71,20 @@ export function netInitializeModule(): RuntimeAPI { IS_WORKER: ENVIRONMENT_IS_WORKER(), IS_SIDECAR: ENVIRONMENT_IS_SIDECAR(), }; - const logger: LoggerType = { + const logger: dotnetLoggerType = { info, warn, error, }; - const assert: AssertType = { + const assert: dotnetAssertType = { check, }; - Object.assign(netPublicApi, runtimeApiFunctions); - Object.assign(Logger, logger); - Object.assign(Assert, assert); - Object.assign(netJSEngine, jsEngine); - Object.assign(netLoaderExports, loaderFunctions); - netInternals[InternalExchangeIndex.LoaderExportsTable] = netTabulateLE(Logger, Assert, netLoaderExports); - netUpdateAllInternals(); - return netPublicApi as RuntimeAPI; + Object.assign(dotnetApi, runtimeApiFunctions); + Object.assign(dotnetLogger, logger); + Object.assign(dotnetAssert, assert); + Object.assign(dotnetJSEngine, jsEngine); + Object.assign(dotnetLoaderExports, loaderFunctions); + dotnetInternals[InternalExchangeIndex.LoaderExportsTable] = dotnetTabLE(dotnetLogger, dotnetAssert, dotnetLoaderExports); + dotnetUpdateAllInternals(); + return dotnetApi as RuntimeAPI; } diff --git a/src/native/corehost/browserhost/loader/logging.ts b/src/native/corehost/browserhost/loader/logging.ts index a4527d96b72c0d..a51b8afd4114f2 100644 --- a/src/native/corehost/browserhost/loader/logging.ts +++ b/src/native/corehost/browserhost/loader/logging.ts @@ -6,7 +6,7 @@ export function check(condition: unknown, messageFactory: string | (() => string)): asserts condition { if (!condition) { const message = typeof messageFactory === "string" ? messageFactory : messageFactory(); - throw new Error(`Assert failed: ${message}`); + throw new Error(`dotnetAssert failed: ${message}`); } } diff --git a/src/native/corehost/browserhost/loader/polyfills.ts b/src/native/corehost/browserhost/loader/polyfills.ts index e6c179d5c7957a..860c125e8ce10e 100644 --- a/src/native/corehost/browserhost/loader/polyfills.ts +++ b/src/native/corehost/browserhost/loader/polyfills.ts @@ -1,7 +1,7 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -import { netJSEngine } from "./cross-module"; +import { dotnetJSEngine } from "./cross-module"; export function initPolyfills(): void { if (typeof globalThis.WeakRef !== "function") { @@ -24,7 +24,7 @@ export function initPolyfills(): void { } export async function initPolyfillsAsync(): Promise { - if (netJSEngine.IS_NODE) { + if (dotnetJSEngine.IS_NODE) { if (!globalThis.crypto) { globalThis.crypto = {}; } @@ -68,7 +68,7 @@ export async function fetchLike(url: string, init?: RequestInit): Promise InteropJavaScriptExportsTable; - export const netTabulateRE:(hostNativeExports:RuntimeExports) => RuntimeExportsTable; - export const netTabulateBHE:(hostNativeExports:BrowserHostExports) => BrowserHostExportsTable; - export const netTabulateNBE:(hostNativeExports:NativeBrowserExports) => NativeBrowserExportsTable; - export const netTabulateLE:(hostNativeExports:BrowserHostExports) => BrowserHostExportsTable; - export const netSetInternals:(internals:Partial) => void; - export const netUpdateAllInternals:() => void; - export const netUpdateModuleInternals:() => void; + export const dotnetAssert:dotnetAssertType; + export const dotnetLogger:dotnetLoggerType; + export const dotnetJSEngine:JSEngineType; + export const dotnetLoaderExports:LoaderExports; + export const dotnetTabIJSE:(hostNativeExports:InteropJavaScriptExports) => InteropJavaScriptExportsTable; + export const dotnetTabRE:(hostNativeExports:RuntimeExports) => RuntimeExportsTable; + export const dotnetTabBHE:(hostNativeExports:BrowserHostExports) => BrowserHostExportsTable; + export const dotnetTabNBE:(hostNativeExports:NativeBrowserExports) => NativeBrowserExportsTable; + export const dotnetTabLE:(hostNativeExports:BrowserHostExports) => BrowserHostExportsTable; + export const dotnetSetInternals:(internals:Partial) => void; + export const dotnetUpdateAllInternals:() => void; + export const dotnetUpdateModuleInternals:() => void; } diff --git a/src/native/libs/Common/JavaScript/cross-module/index.ts b/src/native/libs/Common/JavaScript/cross-module/index.ts index 860878dab919a8..8675c05df1b64d 100644 --- a/src/native/libs/Common/JavaScript/cross-module/index.ts +++ b/src/native/libs/Common/JavaScript/cross-module/index.ts @@ -7,63 +7,63 @@ * Please keep it small and register it into emscripten as dependency. */ -import type { DotnetModuleInternal, InternalExchange, RuntimeExports, LoaderExports, RuntimeAPI, LoggerType, AssertType, JSEngineType, BrowserHostExports, InteropJavaScriptExports, LoaderExportsTable, RuntimeExportsTable, BrowserHostExportsTable, InteropJavaScriptExportsTable, NativeBrowserExports, NativeBrowserExportsTable } from "../types"; +import type { DotnetModuleInternal, InternalExchange, RuntimeExports, LoaderExports, RuntimeAPI, dotnetLoggerType, dotnetAssertType, JSEngineType, BrowserHostExports, InteropJavaScriptExports, LoaderExportsTable, RuntimeExportsTable, BrowserHostExportsTable, InteropJavaScriptExportsTable, NativeBrowserExports, NativeBrowserExportsTable } from "../types"; import { InternalExchangeIndex } from "../types"; export let Module: DotnetModuleInternal; -export let netPublicApi: RuntimeAPI; -export let Logger: LoggerType = {} as any; -export let Assert: AssertType = {} as any; -export let netJSEngine: JSEngineType = {}as any; -export let netLoaderExports: LoaderExports = {} as any; -export let netRuntimeExports: RuntimeExports = {} as any; -export let netBrowserHostExports: BrowserHostExports = {} as any; -export let netInteropJSExports: InteropJavaScriptExports = {} as any; -export let netNativeBrowserExports: NativeBrowserExports = {} as any; -export let netInternals: InternalExchange; - -export function getInternals(): InternalExchange { - return netInternals; +export let dotnetApi: RuntimeAPI; +export let dotnetLogger: dotnetLoggerType = {} as any; +export let dotnetAssert: dotnetAssertType = {} as any; +export let dotnetJSEngine: JSEngineType = {}as any; +export let dotnetLoaderExports: LoaderExports = {} as any; +export let dotnetRuntimeExports: RuntimeExports = {} as any; +export let dotnetBrowserHostExports: BrowserHostExports = {} as any; +export let dotnetInteropJSExports: InteropJavaScriptExports = {} as any; +export let dotnetNativeBrowserExports: NativeBrowserExports = {} as any; +export let dotnetInternals: InternalExchange; + +export function dotnetGetInternals(): InternalExchange { + return dotnetInternals; } -export function netSetInternals(internal: InternalExchange) { - netInternals = internal; - netPublicApi = netInternals[InternalExchangeIndex.RuntimeAPI]; - Module = netPublicApi.Module as any; - if (netInternals[InternalExchangeIndex.InternalUpdatesCallbacks] === undefined) { - netInternals[InternalExchangeIndex.InternalUpdatesCallbacks] = []; +export function dotnetSetInternals(internal: InternalExchange) { + dotnetInternals = internal; + dotnetApi = dotnetInternals[InternalExchangeIndex.RuntimeAPI]; + Module = dotnetApi.Module as any; + if (dotnetInternals[InternalExchangeIndex.InternalUpdatesCallbacks] === undefined) { + dotnetInternals[InternalExchangeIndex.InternalUpdatesCallbacks] = []; } } -export function netUpdateAllInternals() { - for (const updateImpl of netInternals[InternalExchangeIndex.InternalUpdatesCallbacks]) { +export function dotnetUpdateAllInternals() { + for (const updateImpl of dotnetInternals[InternalExchangeIndex.InternalUpdatesCallbacks]) { updateImpl(); } } -export function netUpdateModuleInternals() { - if (Object.keys(netLoaderExports).length === 0 && netInternals[InternalExchangeIndex.LoaderExportsTable]) { - netLoaderExports = {} as LoaderExports; - Logger = {} as LoggerType; - Assert = {} as AssertType; - netJSEngine = {} as JSEngineType; - expandLE(netInternals[InternalExchangeIndex.LoaderExportsTable], Logger, Assert, netJSEngine, netLoaderExports); +export function dotnetUpdateModuleInternals() { + if (Object.keys(dotnetLoaderExports).length === 0 && dotnetInternals[InternalExchangeIndex.LoaderExportsTable]) { + dotnetLoaderExports = {} as LoaderExports; + dotnetLogger = {} as dotnetLoggerType; + dotnetAssert = {} as dotnetAssertType; + dotnetJSEngine = {} as JSEngineType; + expandLE(dotnetInternals[InternalExchangeIndex.LoaderExportsTable], dotnetLogger, dotnetAssert, dotnetJSEngine, dotnetLoaderExports); } - if (Object.keys(netRuntimeExports).length === 0 && netInternals[InternalExchangeIndex.RuntimeExportsTable]) { - netRuntimeExports = {} as RuntimeExports; - expandRE(netInternals[InternalExchangeIndex.RuntimeExportsTable], netRuntimeExports); + if (Object.keys(dotnetRuntimeExports).length === 0 && dotnetInternals[InternalExchangeIndex.RuntimeExportsTable]) { + dotnetRuntimeExports = {} as RuntimeExports; + expandRE(dotnetInternals[InternalExchangeIndex.RuntimeExportsTable], dotnetRuntimeExports); } - if (Object.keys(netBrowserHostExports).length === 0 && netInternals[InternalExchangeIndex.BrowserHostExportsTable]) { - netBrowserHostExports = {} as BrowserHostExports; - expandBHE(netInternals[InternalExchangeIndex.BrowserHostExportsTable], netBrowserHostExports); + if (Object.keys(dotnetBrowserHostExports).length === 0 && dotnetInternals[InternalExchangeIndex.BrowserHostExportsTable]) { + dotnetBrowserHostExports = {} as BrowserHostExports; + expandBHE(dotnetInternals[InternalExchangeIndex.BrowserHostExportsTable], dotnetBrowserHostExports); } - if (Object.keys(netInteropJSExports).length === 0 && netInternals[InternalExchangeIndex.InteropJavaScriptExportsTable]) { - netInteropJSExports = {} as InteropJavaScriptExports; - expandIJSE(netInternals[InternalExchangeIndex.InteropJavaScriptExportsTable], netInteropJSExports); + if (Object.keys(dotnetInteropJSExports).length === 0 && dotnetInternals[InternalExchangeIndex.InteropJavaScriptExportsTable]) { + dotnetInteropJSExports = {} as InteropJavaScriptExports; + expandIJSE(dotnetInternals[InternalExchangeIndex.InteropJavaScriptExportsTable], dotnetInteropJSExports); } - if (Object.keys(netNativeBrowserExports).length === 0 && netInternals[InternalExchangeIndex.NativeBrowserExportsTable]) { - netNativeBrowserExports = {} as NativeBrowserExports; - expandNBE(netInternals[InternalExchangeIndex.NativeBrowserExportsTable], netNativeBrowserExports); + if (Object.keys(dotnetNativeBrowserExports).length === 0 && dotnetInternals[InternalExchangeIndex.NativeBrowserExportsTable]) { + dotnetNativeBrowserExports = {} as NativeBrowserExports; + expandNBE(dotnetInternals[InternalExchangeIndex.NativeBrowserExportsTable], dotnetNativeBrowserExports); } function expandRE(table:RuntimeExportsTable, runtime:RuntimeExports):void { @@ -71,13 +71,13 @@ export function netUpdateModuleInternals() { }); } - function expandLE(table:LoaderExportsTable, logger:LoggerType, assert:AssertType, jsEngine:JSEngineType, netLoaderExports:LoaderExports):void { - const loggerLocal :LoggerType = { + function expandLE(table:LoaderExportsTable, logger:dotnetLoggerType, assert:dotnetAssertType, jsEngine:JSEngineType, dotnetLoaderExports:LoaderExports):void { + const loggerLocal :dotnetLoggerType = { info: table[0], warn: table[1], error: table[2], }; - const assertLocal :AssertType = { + const assertLocal :dotnetAssertType = { check: table[3], }; const loaderExportsLocal :LoaderExports = { @@ -97,7 +97,7 @@ export function netUpdateModuleInternals() { IS_WORKER: loaderExportsLocal.ENVIRONMENT_IS_WORKER(), IS_SIDECAR: loaderExportsLocal.ENVIRONMENT_IS_SIDECAR(), }; - Object.assign(netLoaderExports, loaderExportsLocal); + Object.assign(dotnetLoaderExports, loaderExportsLocal); Object.assign(logger, loggerLocal); Object.assign(assert, assertLocal); Object.assign(jsEngine, jsEngineLocal); @@ -129,30 +129,30 @@ export function netUpdateModuleInternals() { * IMPORTANT: If you need to add more functions, make sure that you add them at the end of the table, so that the order of existing functions does not change. */ -export function netTabulateLE(logger:LoggerType, assert:AssertType, netLoaderExports:LoaderExports):LoaderExportsTable { +export function dotnetTabLE(logger:dotnetLoggerType, assert:dotnetAssertType, dotnetLoaderExports:LoaderExports):LoaderExportsTable { return [ logger.info, logger.warn, logger.error, assert.check, - netLoaderExports.ENVIRONMENT_IS_NODE, - netLoaderExports.ENVIRONMENT_IS_SHELL, - netLoaderExports.ENVIRONMENT_IS_WEB, - netLoaderExports.ENVIRONMENT_IS_WORKER, - netLoaderExports.ENVIRONMENT_IS_SIDECAR, - netLoaderExports.resolveRunMainPromise, - netLoaderExports.rejectRunMainPromise, - netLoaderExports.getRunMainPromise, + dotnetLoaderExports.ENVIRONMENT_IS_NODE, + dotnetLoaderExports.ENVIRONMENT_IS_SHELL, + dotnetLoaderExports.ENVIRONMENT_IS_WEB, + dotnetLoaderExports.ENVIRONMENT_IS_WORKER, + dotnetLoaderExports.ENVIRONMENT_IS_SIDECAR, + dotnetLoaderExports.resolveRunMainPromise, + dotnetLoaderExports.rejectRunMainPromise, + dotnetLoaderExports.getRunMainPromise, ]; } // eslint-disable-next-line @typescript-eslint/no-unused-vars -export function netTabulateRE(map:RuntimeExports):RuntimeExportsTable { +export function dotnetTabRE(map:RuntimeExports):RuntimeExportsTable { return [ ]; } -export function netTabulateBHE(map:BrowserHostExports):BrowserHostExportsTable { +export function dotnetTabBHE(map:BrowserHostExports):BrowserHostExportsTable { return [ map.registerDllBytes, map.isSharedArrayBuffer, @@ -160,13 +160,13 @@ export function netTabulateBHE(map:BrowserHostExports):BrowserHostExportsTable { } // eslint-disable-next-line @typescript-eslint/no-unused-vars -export function netTabulateIJSE(map:InteropJavaScriptExports):InteropJavaScriptExportsTable { +export function dotnetTabIJSE(map:InteropJavaScriptExports):InteropJavaScriptExportsTable { return [ ]; } // eslint-disable-next-line @typescript-eslint/no-unused-vars -export function netTabulateNBE(map:NativeBrowserExports):NativeBrowserExportsTable { +export function dotnetTabNBE(map:NativeBrowserExports):NativeBrowserExportsTable { return [ ]; } diff --git a/src/native/libs/Common/JavaScript/types/exchange.ts b/src/native/libs/Common/JavaScript/types/exchange.ts index b7913331f0a651..502a7fef630898 100644 --- a/src/native/libs/Common/JavaScript/types/exchange.ts +++ b/src/native/libs/Common/JavaScript/types/exchange.ts @@ -20,13 +20,13 @@ export type RuntimeExports = { export type RuntimeExportsTable = [ ] -export type LoggerType = { +export type dotnetLoggerType = { info: typeof info, warn: typeof warn, error: typeof error, } -export type AssertType = { +export type dotnetAssertType = { check: typeof check, } diff --git a/src/native/libs/Common/JavaScript/types/internal.ts b/src/native/libs/Common/JavaScript/types/internal.ts index 317e6eabef5ac9..3eb0f4da630e0a 100644 --- a/src/native/libs/Common/JavaScript/types/internal.ts +++ b/src/native/libs/Common/JavaScript/types/internal.ts @@ -128,6 +128,6 @@ export const enum InternalExchangeIndex { } export type JsModuleExports = { - netInitializeModule(internals: InternalExchange): Promise; + dotnetInitializeModule(internals: InternalExchange): Promise; }; diff --git a/src/native/libs/System.Native.Browser/libSystem.Native.Browser.extpost.js b/src/native/libs/System.Native.Browser/libSystem.Native.Browser.extpost.js index f55d3485ef8c24..bc2e783ad756c2 100644 --- a/src/native/libs/System.Native.Browser/libSystem.Native.Browser.extpost.js +++ b/src/native/libs/System.Native.Browser/libSystem.Native.Browser.extpost.js @@ -2,10 +2,10 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -var fetch = fetch || undefined; var netNativeModuleLoaded = false; var netInternals = null; -export function netInitializeModule(internals) { +var fetch = fetch || undefined; var netNativeModuleLoaded = false; var dotnetInternals = null; +export function dotnetInitializeModule(internals) { if (netNativeModuleLoaded) throw new Error("Native module already loaded"); - netInternals = internals; + dotnetInternals = internals; netNativeModuleLoaded = true; - return createDotnetRuntime(netInternals[0/*InternalExchangeIndex.RuntimeAPI*/].Module); + return createDotnetRuntime(dotnetInternals[0/*InternalExchangeIndex.RuntimeAPI*/].Module); } diff --git a/src/native/libs/System.Native.Browser/libSystem.Native.Browser.footer.js b/src/native/libs/System.Native.Browser/libSystem.Native.Browser.footer.js index f783fe3c2b9965..14264e95eccd21 100644 --- a/src/native/libs/System.Native.Browser/libSystem.Native.Browser.footer.js +++ b/src/native/libs/System.Native.Browser/libSystem.Native.Browser.footer.js @@ -21,12 +21,12 @@ const lib = { $DOTNET: { selfInitialize: () => { - if (typeof netInternals !== "undefined") { - DOTNET.netInternals = netInternals; - DOTNET.netInitializeModule(netInternals); + if (typeof dotnetInternals !== "undefined") { + DOTNET.dotnetInternals = dotnetInternals; + DOTNET.dotnetInitializeModule(dotnetInternals); } }, - netInitializeModule: exports.netInitializeModule, + dotnetInitializeModule: exports.dotnetInitializeModule, }, $DOTNET__deps: commonDeps, $DOTNET__postset: "DOTNET.selfInitialize()", @@ -35,7 +35,7 @@ // keep in sync with `reserved`+`keep_fnames` in src\native\rollup.config.defines.js for (const exportName of Reflect.ownKeys(exports.cross)) { const name = String(exportName); - if (name === "netInternals") continue; + if (name === "dotnetInternals") continue; if (name === "Module") continue; const emName = "$" + name; lib[emName] = exports.cross[exportName]; @@ -44,7 +44,7 @@ for (const exportName of Reflect.ownKeys(exports)) { const name = String(exportName); if (name === "cross") continue; - if (name === "netInitializeModule") continue; + if (name === "dotnetInitializeModule") continue; lib[name] = exports[name]; } diff --git a/src/native/libs/System.Native.Browser/native/cross-linked.ts b/src/native/libs/System.Native.Browser/native/cross-linked.ts index e14aeaa23d696b..0850aadc1d91c2 100644 --- a/src/native/libs/System.Native.Browser/native/cross-linked.ts +++ b/src/native/libs/System.Native.Browser/native/cross-linked.ts @@ -2,19 +2,19 @@ // The .NET Foundation licenses this file to you under the MIT license. import { - Assert, Logger, Module, - netInternals, netLoaderExports, netPublicApi, netNativeBrowserExports, netRuntimeExports, netJSEngine, netBrowserHostExports, netInteropJSExports, - netTabulateNBE, netTabulateBHE, netTabulateIJSE, netTabulateLE, netTabulateRE, - getInternals, netSetInternals, netUpdateAllInternals, netUpdateModuleInternals, + dotnetAssert, dotnetLogger, Module, + dotnetInternals, dotnetLoaderExports, dotnetApi, dotnetNativeBrowserExports, dotnetRuntimeExports, dotnetJSEngine, dotnetBrowserHostExports, dotnetInteropJSExports, + dotnetTabNBE, dotnetTabBHE, dotnetTabIJSE, dotnetTabLE, dotnetTabRE, + dotnetGetInternals, dotnetSetInternals, dotnetUpdateAllInternals, dotnetUpdateModuleInternals, } from "../cross-module"; import { } from "../../Common/JavaScript/cross-linked"; export function crossLink() { return [ - Assert, Logger, Module, - netInternals, netLoaderExports, netPublicApi, netNativeBrowserExports, netRuntimeExports, netJSEngine, netBrowserHostExports, netInteropJSExports, - getInternals, netSetInternals, netUpdateAllInternals, netUpdateModuleInternals, - netTabulateBHE, netTabulateIJSE, netTabulateLE, netTabulateNBE, netTabulateRE + dotnetAssert, dotnetLogger, Module, + dotnetInternals, dotnetLoaderExports, dotnetApi, dotnetNativeBrowserExports, dotnetRuntimeExports, dotnetJSEngine, dotnetBrowserHostExports, dotnetInteropJSExports, + dotnetGetInternals, dotnetSetInternals, dotnetUpdateAllInternals, dotnetUpdateModuleInternals, + dotnetTabBHE, dotnetTabIJSE, dotnetTabLE, dotnetTabNBE, dotnetTabRE ]; } diff --git a/src/native/libs/System.Native.Browser/native/crypto.ts b/src/native/libs/System.Native.Browser/native/crypto.ts index 3ac6b00e54853d..1b3b13763a756c 100644 --- a/src/native/libs/System.Native.Browser/native/crypto.ts +++ b/src/native/libs/System.Native.Browser/native/crypto.ts @@ -1,7 +1,7 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -import { netPublicApi, Logger, netBrowserHostExports } from "../cross-module"; +import { dotnetApi, dotnetLogger, dotnetBrowserHostExports } from "../cross-module"; export function SystemJS_RandomBytes(bufferPtr: number, bufferLength: number): number { // batchedQuotaMax is the max number of bytes as specified by the api spec. @@ -11,17 +11,17 @@ export function SystemJS_RandomBytes(bufferPtr: number, bufferLength: number): n if (!globalThis.crypto || !globalThis.crypto.getRandomValues) { if (!(globalThis as any)["cryptoWarnOnce"]) { - Logger.warn("This engine doesn't support crypto.getRandomValues. Please use a modern version or provide polyfill for 'globalThis.crypto.getRandomValues'."); + dotnetLogger.warn("This engine doesn't support crypto.getRandomValues. Please use a modern version or provide polyfill for 'globalThis.crypto.getRandomValues'."); (globalThis as any)["cryptoWarnOnce"] = true; } return -1; } - const memoryView = netPublicApi.localHeapViewU8(); + const memoryView = dotnetApi.localHeapViewU8(); const targetView = memoryView.subarray(bufferPtr, bufferPtr + bufferLength); // When threading is enabled, Chrome doesn't want SharedArrayBuffer to be passed to crypto APIs - const needsCopy = netBrowserHostExports.isSharedArrayBuffer(memoryView.buffer); + const needsCopy = dotnetBrowserHostExports.isSharedArrayBuffer(memoryView.buffer); const targetBuffer = needsCopy ? new Uint8Array(bufferLength) : targetView; diff --git a/src/native/libs/System.Native.Browser/native/index.ts b/src/native/libs/System.Native.Browser/native/index.ts index 8fe2cb5f2be3a1..a950202c2b6374 100644 --- a/src/native/libs/System.Native.Browser/native/index.ts +++ b/src/native/libs/System.Native.Browser/native/index.ts @@ -6,14 +6,14 @@ import { InternalExchangeIndex } from "../types"; export { SystemJS_RandomBytes } from "./crypto"; -export function netInitializeModule(internals: InternalExchange): void { +export function dotnetInitializeModule(internals: InternalExchange): void { const nativeBrowserExportsLocal: NativeBrowserExports = { }; - netSetInternals(internals); - internals[InternalExchangeIndex.NativeBrowserExportsTable] = netTabulateNBE(nativeBrowserExportsLocal); + dotnetSetInternals(internals); + internals[InternalExchangeIndex.NativeBrowserExportsTable] = dotnetTabNBE(nativeBrowserExportsLocal); const updates = internals[InternalExchangeIndex.InternalUpdatesCallbacks]; - if (!updates.includes(netUpdateModuleInternals)) updates.push(netUpdateModuleInternals); - netUpdateAllInternals(); + if (!updates.includes(dotnetUpdateModuleInternals)) updates.push(dotnetUpdateModuleInternals); + dotnetUpdateAllInternals(); } diff --git a/src/native/libs/System.Runtime.InteropServices.JavaScript.Native/dotnet.runtime.ts b/src/native/libs/System.Runtime.InteropServices.JavaScript.Native/dotnet.runtime.ts index bb92a95e41edc2..09cd302590cf6f 100644 --- a/src/native/libs/System.Runtime.InteropServices.JavaScript.Native/dotnet.runtime.ts +++ b/src/native/libs/System.Runtime.InteropServices.JavaScript.Native/dotnet.runtime.ts @@ -1,4 +1,4 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -export { netInitializeModule } from "./interop"; +export { dotnetInitializeModule } from "./interop"; diff --git a/src/native/libs/System.Runtime.InteropServices.JavaScript.Native/interop/index.ts b/src/native/libs/System.Runtime.InteropServices.JavaScript.Native/interop/index.ts index e0edb0e0954528..6f45fbcd593d69 100644 --- a/src/native/libs/System.Runtime.InteropServices.JavaScript.Native/interop/index.ts +++ b/src/native/libs/System.Runtime.InteropServices.JavaScript.Native/interop/index.ts @@ -3,20 +3,20 @@ import type { InternalExchange, RuntimeAPI, RuntimeExports } from "./types"; import { InternalExchangeIndex } from "../types"; -import { netSetInternals, netUpdateAllInternals, netUpdateModuleInternals, netTabulateRE } from "./cross-module"; +import { dotnetSetInternals, dotnetUpdateAllInternals, dotnetUpdateModuleInternals, dotnetTabRE } from "./cross-module"; -export function netInitializeModule(internals: InternalExchange): void { +export function dotnetInitializeModule(internals: InternalExchange): void { const runtimeApiLocal: Partial = { getAssemblyExports, setModuleImports, }; const runtimeExportsLocal: RuntimeExports = { }; - netSetInternals(internals); + dotnetSetInternals(internals); Object.assign(internals[InternalExchangeIndex.RuntimeAPI], runtimeApiLocal); - internals[InternalExchangeIndex.RuntimeExportsTable] = netTabulateRE(runtimeExportsLocal); - internals[InternalExchangeIndex.InternalUpdatesCallbacks].push(netUpdateModuleInternals); - netUpdateAllInternals(); + internals[InternalExchangeIndex.RuntimeExportsTable] = dotnetTabRE(runtimeExportsLocal); + internals[InternalExchangeIndex.InternalUpdatesCallbacks].push(dotnetUpdateModuleInternals); + dotnetUpdateAllInternals(); } // eslint-disable-next-line @typescript-eslint/no-unused-vars diff --git a/src/native/libs/System.Runtime.InteropServices.JavaScript.Native/libSystem.Runtime.InteropServices.JavaScript.Native.footer.js b/src/native/libs/System.Runtime.InteropServices.JavaScript.Native/libSystem.Runtime.InteropServices.JavaScript.Native.footer.js index c77ba573b51105..faa07191f95527 100644 --- a/src/native/libs/System.Runtime.InteropServices.JavaScript.Native/libSystem.Runtime.InteropServices.JavaScript.Native.footer.js +++ b/src/native/libs/System.Runtime.InteropServices.JavaScript.Native/libSystem.Runtime.InteropServices.JavaScript.Native.footer.js @@ -21,12 +21,12 @@ const lib = { $DOTNET_INTEROP: { selfInitialize: () => { - if (typeof netInternals !== "undefined") { - DOTNET_INTEROP.netInternals = netInternals; - DOTNET_INTEROP.netInitializeModule(netInternals); + if (typeof dotnetInternals !== "undefined") { + DOTNET_INTEROP.dotnetInternals = dotnetInternals; + DOTNET_INTEROP.dotnetInitializeModule(dotnetInternals); } }, - netInitializeModule: exports.netInitializeModule, + dotnetInitializeModule: exports.dotnetInitializeModule, }, $DOTNET_INTEROP__postset: "DOTNET_INTEROP.selfInitialize()", $DOTNET_INTEROP__deps: commonDeps, @@ -34,7 +34,7 @@ for (const exportName of Reflect.ownKeys(exports)) { const name = String(exportName); - if (name === "netInitializeModule") continue; + if (name === "dotnetInitializeModule") continue; lib[name] = exports[name]; } diff --git a/src/native/libs/System.Runtime.InteropServices.JavaScript.Native/native/index.ts b/src/native/libs/System.Runtime.InteropServices.JavaScript.Native/native/index.ts index 293d95089fcdbd..befac3fdcfce6a 100644 --- a/src/native/libs/System.Runtime.InteropServices.JavaScript.Native/native/index.ts +++ b/src/native/libs/System.Runtime.InteropServices.JavaScript.Native/native/index.ts @@ -8,16 +8,16 @@ import { } from "./cross-linked"; // ensure ambient symbols are declared // eslint-disable-next-line @typescript-eslint/no-unused-vars export function SystemInteropJS_InvokeJSImportST(function_handle: JSFnHandle, args: JSMarshalerArguments) { // WASM-TODO implementation - Logger.error("SystemInteropJS_InvokeJSImportST called"); + dotnetLogger.error("SystemInteropJS_InvokeJSImportST called"); return - 1; } -export function netInitializeModule(internals: InternalExchange): void { +export function dotnetInitializeModule(internals: InternalExchange): void { const interopJavaScriptNativeExportsLocal: InteropJavaScriptExports = { }; - netSetInternals(internals); - internals[InternalExchangeIndex.InteropJavaScriptExportsTable] = netTabulateIJSE(interopJavaScriptNativeExportsLocal); + dotnetSetInternals(internals); + internals[InternalExchangeIndex.InteropJavaScriptExportsTable] = dotnetTabIJSE(interopJavaScriptNativeExportsLocal); const updates = internals[InternalExchangeIndex.InternalUpdatesCallbacks]; - if (!updates.includes(netUpdateModuleInternals)) updates.push(netUpdateModuleInternals); - netUpdateAllInternals(); + if (!updates.includes(dotnetUpdateModuleInternals)) updates.push(dotnetUpdateModuleInternals); + dotnetUpdateAllInternals(); } diff --git a/src/native/rollup.config.defines.js b/src/native/rollup.config.defines.js index 89bdf74783679a..294375775a5006 100644 --- a/src/native/rollup.config.defines.js +++ b/src/native/rollup.config.defines.js @@ -12,12 +12,13 @@ console.log(`Rollup configuration: Configuration=${configuration}, ProductVersio export const banner = "//! Licensed to the .NET Foundation under one or more agreements.\n//! The .NET Foundation licenses this file to you under the MIT license.\n//! This is generated file, see src/native/libs/Browser/rollup.config.defines.js\n\n"; export const banner_dts = banner + "//! This is not considered public API with backward compatibility guarantees. \n"; export const keep_classnames = /(ManagedObject|ManagedError|Span|ArraySegment)/; -export const keep_fnames = /(netSetInternals|netUpdateAllInternals|netUpdateModuleInternals|netTabulateLE|netTabulateRE|netTabulateBHE|netTabulateIJSE|netTabulateNBE)/; +export const keep_fnames = /(dotnetSetInternals|dotnetUpdateAllInternals|dotnetUpdateModuleInternals|dotnetTabLE|dotnetTabRE|dotnetTabBHE|dotnetTabIJSE|dotnetTabNBE)/; export const reserved = [ - "Logger", "Assert", "netJSEngine", "Module", "netInternals", "netPublicApi", - "netSetInternals", "netUpdateAllInternals", "netUpdateModuleInternals", "netInitializeModule", - "netLoaderExports", "netRuntimeExports", "netBrowserHostExports", "netInteropJSExports", "netNativeBrowserExports", - "netTabulateLE", "netTabulateRE", "netTabulateBHE", "netTabulateIJSE", "netTabulateNBE"]; + "Module", "dotnetApi", + "dotnetInternals", "dotnetLogger", "dotnetAssert", "dotnetJSEngine", + "dotnetSetInternals", "dotnetUpdateAllInternals", "dotnetUpdateModuleInternals", "dotnetInitializeModule", + "dotnetLoaderExports", "dotnetRuntimeExports", "dotnetBrowserHostExports", "dotnetInteropJSExports", "dotnetNativeBrowserExports", + "dotnetTabLE", "dotnetTabRE", "dotnetTabBHE", "dotnetTabIJSE", "dotnetTabNBE"]; export const externalDependencies = ["module", "process", "perf_hooks", "node:crypto"]; export const artifactsObjDir = "../../artifacts/obj"; From c456f3d001ddb6e1cbc3a12172f0318de7a882a3 Mon Sep 17 00:00:00 2001 From: pavelsavara Date: Fri, 26 Sep 2025 08:59:26 +0200 Subject: [PATCH 12/25] feedback about names in dotnetUpdateModuleInternals() --- src/native/corehost/browserhost/host/index.ts | 12 ++- .../corehost/browserhost/loader/index.ts | 20 ++++- .../Common/JavaScript/cross-linked/index.ts | 7 +- .../Common/JavaScript/cross-module/index.ts | 78 +++++-------------- .../native/cross-linked.ts | 2 - .../System.Native.Browser/native/index.ts | 11 ++- .../interop/index.ts | 12 ++- .../native/index.ts | 11 ++- src/native/rollup.config.defines.js | 4 +- 9 files changed, 79 insertions(+), 78 deletions(-) diff --git a/src/native/corehost/browserhost/host/index.ts b/src/native/corehost/browserhost/host/index.ts index 80643f45ace852..ba49fe37b95065 100644 --- a/src/native/corehost/browserhost/host/index.ts +++ b/src/native/corehost/browserhost/host/index.ts @@ -1,7 +1,7 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -import type { InternalExchange, BrowserHostExports, RuntimeAPI } from "./types"; +import type { InternalExchange, BrowserHostExports, RuntimeAPI, BrowserHostExportsTable } from "./types"; import { InternalExchangeIndex } from "./types"; import { } from "./cross-linked"; // ensure ambient symbols are declared @@ -30,10 +30,18 @@ export function dotnetInitializeModule(internals: InternalExchange): void { }; dotnetSetInternals(internals); Object.assign(internals[InternalExchangeIndex.RuntimeAPI], runtimeApiLocal); - internals[InternalExchangeIndex.BrowserHostExportsTable] = dotnetTabBHE(hostNativeExportsLocal); + internals[InternalExchangeIndex.BrowserHostExportsTable] = tabulateBrowserHostExports(hostNativeExportsLocal); const updates = internals[InternalExchangeIndex.InternalUpdatesCallbacks]; if (!updates.includes(dotnetUpdateModuleInternals)) updates.push(dotnetUpdateModuleInternals); dotnetUpdateAllInternals(); + + function tabulateBrowserHostExports(map:BrowserHostExports):BrowserHostExportsTable { + // keep in sync with dotnetUpdateModuleInternals() + return [ + map.registerDllBytes, + map.isSharedArrayBuffer, + ]; + } } export { BrowserHost_ExternalAssemblyProbe, BrowserHost_ResolveMain, BrowserHost_RejectMain } from "./host"; diff --git a/src/native/corehost/browserhost/loader/index.ts b/src/native/corehost/browserhost/loader/index.ts index 8f6466867d51fd..2ad1f7c03358b5 100644 --- a/src/native/corehost/browserhost/loader/index.ts +++ b/src/native/corehost/browserhost/loader/index.ts @@ -13,7 +13,7 @@ import { exit } from "./exit"; import { invokeLibraryInitializers } from "./lib-initializers"; import { check, error, info, warn } from "./logging"; -import { dotnetAssert, dotnetInternals, dotnetJSEngine, dotnetLoaderExports, dotnetTabLE, dotnetLogger, dotnetSetInternals, dotnetUpdateAllInternals, dotnetUpdateModuleInternals } from "./cross-module"; +import { dotnetAssert, dotnetInternals, dotnetJSEngine, dotnetLoaderExports, dotnetLogger, dotnetSetInternals, dotnetUpdateAllInternals, dotnetUpdateModuleInternals } from "./cross-module"; import { rejectRunMainPromise, resolveRunMainPromise, getRunMainPromise } from "./run"; export function dotnetInitializeModule(): RuntimeAPI { @@ -87,4 +87,22 @@ export function dotnetInitializeModule(): RuntimeAPI { dotnetInternals[InternalExchangeIndex.LoaderExportsTable] = dotnetTabLE(dotnetLogger, dotnetAssert, dotnetLoaderExports); dotnetUpdateAllInternals(); return dotnetApi as RuntimeAPI; + + function dotnetTabLE(logger:dotnetLoggerType, assert:dotnetAssertType, dotnetLoaderExports:LoaderExports):LoaderExportsTable { + // keep in sync with dotnetUpdateModuleInternals() + return [ + logger.info, + logger.warn, + logger.error, + assert.check, + dotnetLoaderExports.ENVIRONMENT_IS_NODE, + dotnetLoaderExports.ENVIRONMENT_IS_SHELL, + dotnetLoaderExports.ENVIRONMENT_IS_WEB, + dotnetLoaderExports.ENVIRONMENT_IS_WORKER, + dotnetLoaderExports.ENVIRONMENT_IS_SIDECAR, + dotnetLoaderExports.resolveRunMainPromise, + dotnetLoaderExports.rejectRunMainPromise, + dotnetLoaderExports.getRunMainPromise, + ]; + } } diff --git a/src/native/libs/Common/JavaScript/cross-linked/index.ts b/src/native/libs/Common/JavaScript/cross-linked/index.ts index e93d20e24de28f..36e472b53bb69d 100644 --- a/src/native/libs/Common/JavaScript/cross-linked/index.ts +++ b/src/native/libs/Common/JavaScript/cross-linked/index.ts @@ -1,7 +1,7 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -import type { dotnetAssertType, EmscriptenModuleInternal, JSEngineType, dotnetLoggerType, LoaderExports, InternalExchange, RuntimeExports, RuntimeExportsTable, BrowserHostExportsTable, BrowserHostExports, InteropJavaScriptExports, InteropJavaScriptExportsTable, NativeBrowserExports, NativeBrowserExportsTable } from "../types"; +import type { dotnetAssertType, EmscriptenModuleInternal, JSEngineType, dotnetLoggerType, LoaderExports, InternalExchange } from "../types"; // we want to use the cross-module symbols defined in closure of dotnet.native.js // which are installed there by libSystem.Native.Browser.footer.js @@ -12,11 +12,6 @@ declare global { export const dotnetLogger:dotnetLoggerType; export const dotnetJSEngine:JSEngineType; export const dotnetLoaderExports:LoaderExports; - export const dotnetTabIJSE:(hostNativeExports:InteropJavaScriptExports) => InteropJavaScriptExportsTable; - export const dotnetTabRE:(hostNativeExports:RuntimeExports) => RuntimeExportsTable; - export const dotnetTabBHE:(hostNativeExports:BrowserHostExports) => BrowserHostExportsTable; - export const dotnetTabNBE:(hostNativeExports:NativeBrowserExports) => NativeBrowserExportsTable; - export const dotnetTabLE:(hostNativeExports:BrowserHostExports) => BrowserHostExportsTable; export const dotnetSetInternals:(internals:Partial) => void; export const dotnetUpdateAllInternals:() => void; export const dotnetUpdateModuleInternals:() => void; diff --git a/src/native/libs/Common/JavaScript/cross-module/index.ts b/src/native/libs/Common/JavaScript/cross-module/index.ts index 8675c05df1b64d..84fd7acb713263 100644 --- a/src/native/libs/Common/JavaScript/cross-module/index.ts +++ b/src/native/libs/Common/JavaScript/cross-module/index.ts @@ -42,36 +42,43 @@ export function dotnetUpdateAllInternals() { } export function dotnetUpdateModuleInternals() { + /** + * Functions below allow our JS modules to exchange internal interfaces by passing tables of functions in known order instead of using string symbols. + * IMPORTANT: If you need to add more functions, make sure that you add them at the end of the table, so that the order of existing functions does not change. + */ + if (Object.keys(dotnetLoaderExports).length === 0 && dotnetInternals[InternalExchangeIndex.LoaderExportsTable]) { dotnetLoaderExports = {} as LoaderExports; dotnetLogger = {} as dotnetLoggerType; dotnetAssert = {} as dotnetAssertType; dotnetJSEngine = {} as JSEngineType; - expandLE(dotnetInternals[InternalExchangeIndex.LoaderExportsTable], dotnetLogger, dotnetAssert, dotnetJSEngine, dotnetLoaderExports); + expandLoaderExports(dotnetInternals[InternalExchangeIndex.LoaderExportsTable], dotnetLogger, dotnetAssert, dotnetJSEngine, dotnetLoaderExports); } if (Object.keys(dotnetRuntimeExports).length === 0 && dotnetInternals[InternalExchangeIndex.RuntimeExportsTable]) { dotnetRuntimeExports = {} as RuntimeExports; - expandRE(dotnetInternals[InternalExchangeIndex.RuntimeExportsTable], dotnetRuntimeExports); + expandRuntimeExports(dotnetInternals[InternalExchangeIndex.RuntimeExportsTable], dotnetRuntimeExports); } if (Object.keys(dotnetBrowserHostExports).length === 0 && dotnetInternals[InternalExchangeIndex.BrowserHostExportsTable]) { dotnetBrowserHostExports = {} as BrowserHostExports; - expandBHE(dotnetInternals[InternalExchangeIndex.BrowserHostExportsTable], dotnetBrowserHostExports); + expandBrowserHostExports(dotnetInternals[InternalExchangeIndex.BrowserHostExportsTable], dotnetBrowserHostExports); } if (Object.keys(dotnetInteropJSExports).length === 0 && dotnetInternals[InternalExchangeIndex.InteropJavaScriptExportsTable]) { dotnetInteropJSExports = {} as InteropJavaScriptExports; - expandIJSE(dotnetInternals[InternalExchangeIndex.InteropJavaScriptExportsTable], dotnetInteropJSExports); + expandInteropJavaScriptExports(dotnetInternals[InternalExchangeIndex.InteropJavaScriptExportsTable], dotnetInteropJSExports); } if (Object.keys(dotnetNativeBrowserExports).length === 0 && dotnetInternals[InternalExchangeIndex.NativeBrowserExportsTable]) { dotnetNativeBrowserExports = {} as NativeBrowserExports; - expandNBE(dotnetInternals[InternalExchangeIndex.NativeBrowserExportsTable], dotnetNativeBrowserExports); + expandNativeBrowserExports(dotnetInternals[InternalExchangeIndex.NativeBrowserExportsTable], dotnetNativeBrowserExports); } - function expandRE(table:RuntimeExportsTable, runtime:RuntimeExports):void { + // keep in sync with tabulateRuntimeExports() + function expandRuntimeExports(table:RuntimeExportsTable, runtime:RuntimeExports):void { Object.assign(runtime, { }); } - function expandLE(table:LoaderExportsTable, logger:dotnetLoggerType, assert:dotnetAssertType, jsEngine:JSEngineType, dotnetLoaderExports:LoaderExports):void { + // keep in sync with tabulateLoaderExports() + function expandLoaderExports(table:LoaderExportsTable, logger:dotnetLoggerType, assert:dotnetAssertType, jsEngine:JSEngineType, dotnetLoaderExports:LoaderExports):void { const loggerLocal :dotnetLoggerType = { info: table[0], warn: table[1], @@ -103,7 +110,8 @@ export function dotnetUpdateModuleInternals() { Object.assign(jsEngine, jsEngineLocal); } - function expandBHE(table:BrowserHostExportsTable, native:BrowserHostExports):void { + // keep in sync with tabulateBrowserHostExports() + function expandBrowserHostExports(table:BrowserHostExportsTable, native:BrowserHostExports):void { const nativeLocal :BrowserHostExports = { registerDllBytes: table[0], isSharedArrayBuffer: table[1], @@ -111,63 +119,17 @@ export function dotnetUpdateModuleInternals() { Object.assign(native, nativeLocal); } - function expandIJSE(table:InteropJavaScriptExportsTable, interop:InteropJavaScriptExports):void { + // keep in sync with tabulateInteropJavaScriptExports() + function expandInteropJavaScriptExports(table:InteropJavaScriptExportsTable, interop:InteropJavaScriptExports):void { const interopLocal :InteropJavaScriptExports = { }; Object.assign(interop, interopLocal); } - function expandNBE(table:NativeBrowserExportsTable, interop:NativeBrowserExports):void { + // keep in sync with tabulateNativeBrowserExports() + function expandNativeBrowserExports(table:NativeBrowserExportsTable, interop:NativeBrowserExports):void { const interopLocal :NativeBrowserExports = { }; Object.assign(interop, interopLocal); } } - -/** - * Functions below allow our JS modules to exchange internal interfaces by passing tables of functions in known order instead of using string symbols. - * IMPORTANT: If you need to add more functions, make sure that you add them at the end of the table, so that the order of existing functions does not change. - */ - -export function dotnetTabLE(logger:dotnetLoggerType, assert:dotnetAssertType, dotnetLoaderExports:LoaderExports):LoaderExportsTable { - return [ - logger.info, - logger.warn, - logger.error, - assert.check, - dotnetLoaderExports.ENVIRONMENT_IS_NODE, - dotnetLoaderExports.ENVIRONMENT_IS_SHELL, - dotnetLoaderExports.ENVIRONMENT_IS_WEB, - dotnetLoaderExports.ENVIRONMENT_IS_WORKER, - dotnetLoaderExports.ENVIRONMENT_IS_SIDECAR, - dotnetLoaderExports.resolveRunMainPromise, - dotnetLoaderExports.rejectRunMainPromise, - dotnetLoaderExports.getRunMainPromise, - ]; -} - -// eslint-disable-next-line @typescript-eslint/no-unused-vars -export function dotnetTabRE(map:RuntimeExports):RuntimeExportsTable { - return [ - ]; -} - -export function dotnetTabBHE(map:BrowserHostExports):BrowserHostExportsTable { - return [ - map.registerDllBytes, - map.isSharedArrayBuffer, - ]; -} - -// eslint-disable-next-line @typescript-eslint/no-unused-vars -export function dotnetTabIJSE(map:InteropJavaScriptExports):InteropJavaScriptExportsTable { - return [ - ]; -} - -// eslint-disable-next-line @typescript-eslint/no-unused-vars -export function dotnetTabNBE(map:NativeBrowserExports):NativeBrowserExportsTable { - return [ - ]; -} - diff --git a/src/native/libs/System.Native.Browser/native/cross-linked.ts b/src/native/libs/System.Native.Browser/native/cross-linked.ts index 0850aadc1d91c2..41615262167952 100644 --- a/src/native/libs/System.Native.Browser/native/cross-linked.ts +++ b/src/native/libs/System.Native.Browser/native/cross-linked.ts @@ -4,7 +4,6 @@ import { dotnetAssert, dotnetLogger, Module, dotnetInternals, dotnetLoaderExports, dotnetApi, dotnetNativeBrowserExports, dotnetRuntimeExports, dotnetJSEngine, dotnetBrowserHostExports, dotnetInteropJSExports, - dotnetTabNBE, dotnetTabBHE, dotnetTabIJSE, dotnetTabLE, dotnetTabRE, dotnetGetInternals, dotnetSetInternals, dotnetUpdateAllInternals, dotnetUpdateModuleInternals, } from "../cross-module"; @@ -15,6 +14,5 @@ export function crossLink() { dotnetAssert, dotnetLogger, Module, dotnetInternals, dotnetLoaderExports, dotnetApi, dotnetNativeBrowserExports, dotnetRuntimeExports, dotnetJSEngine, dotnetBrowserHostExports, dotnetInteropJSExports, dotnetGetInternals, dotnetSetInternals, dotnetUpdateAllInternals, dotnetUpdateModuleInternals, - dotnetTabBHE, dotnetTabIJSE, dotnetTabLE, dotnetTabNBE, dotnetTabRE ]; } diff --git a/src/native/libs/System.Native.Browser/native/index.ts b/src/native/libs/System.Native.Browser/native/index.ts index a950202c2b6374..db18156ac4d32f 100644 --- a/src/native/libs/System.Native.Browser/native/index.ts +++ b/src/native/libs/System.Native.Browser/native/index.ts @@ -1,7 +1,7 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -import type { InternalExchange, NativeBrowserExports } from "../types"; +import type { InternalExchange, NativeBrowserExports, NativeBrowserExportsTable } from "../types"; import { InternalExchangeIndex } from "../types"; export { SystemJS_RandomBytes } from "./crypto"; @@ -10,10 +10,17 @@ export function dotnetInitializeModule(internals: InternalExchange): void { const nativeBrowserExportsLocal: NativeBrowserExports = { }; dotnetSetInternals(internals); - internals[InternalExchangeIndex.NativeBrowserExportsTable] = dotnetTabNBE(nativeBrowserExportsLocal); + internals[InternalExchangeIndex.NativeBrowserExportsTable] = tabulateNativeBrowserExports(nativeBrowserExportsLocal); const updates = internals[InternalExchangeIndex.InternalUpdatesCallbacks]; if (!updates.includes(dotnetUpdateModuleInternals)) updates.push(dotnetUpdateModuleInternals); dotnetUpdateAllInternals(); + + // eslint-disable-next-line @typescript-eslint/no-unused-vars + function tabulateNativeBrowserExports(map:NativeBrowserExports):NativeBrowserExportsTable { + // keep in sync with dotnetUpdateModuleInternals() + return [ + ]; + } } diff --git a/src/native/libs/System.Runtime.InteropServices.JavaScript.Native/interop/index.ts b/src/native/libs/System.Runtime.InteropServices.JavaScript.Native/interop/index.ts index 6f45fbcd593d69..da0b9d0c755c8d 100644 --- a/src/native/libs/System.Runtime.InteropServices.JavaScript.Native/interop/index.ts +++ b/src/native/libs/System.Runtime.InteropServices.JavaScript.Native/interop/index.ts @@ -1,9 +1,9 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -import type { InternalExchange, RuntimeAPI, RuntimeExports } from "./types"; +import type { InternalExchange, RuntimeAPI, RuntimeExports, RuntimeExportsTable } from "./types"; import { InternalExchangeIndex } from "../types"; -import { dotnetSetInternals, dotnetUpdateAllInternals, dotnetUpdateModuleInternals, dotnetTabRE } from "./cross-module"; +import { dotnetSetInternals, dotnetUpdateAllInternals, dotnetUpdateModuleInternals } from "./cross-module"; export function dotnetInitializeModule(internals: InternalExchange): void { const runtimeApiLocal: Partial = { @@ -14,9 +14,15 @@ export function dotnetInitializeModule(internals: InternalExchange): void { }; dotnetSetInternals(internals); Object.assign(internals[InternalExchangeIndex.RuntimeAPI], runtimeApiLocal); - internals[InternalExchangeIndex.RuntimeExportsTable] = dotnetTabRE(runtimeExportsLocal); + internals[InternalExchangeIndex.RuntimeExportsTable] = tabulateRuntimeExports(runtimeExportsLocal); internals[InternalExchangeIndex.InternalUpdatesCallbacks].push(dotnetUpdateModuleInternals); dotnetUpdateAllInternals(); + // eslint-disable-next-line @typescript-eslint/no-unused-vars + function tabulateRuntimeExports(map:RuntimeExports):RuntimeExportsTable { + // keep in sync with dotnetUpdateModuleInternals() + return [ + ]; + } } // eslint-disable-next-line @typescript-eslint/no-unused-vars diff --git a/src/native/libs/System.Runtime.InteropServices.JavaScript.Native/native/index.ts b/src/native/libs/System.Runtime.InteropServices.JavaScript.Native/native/index.ts index befac3fdcfce6a..0c29a9c89976ca 100644 --- a/src/native/libs/System.Runtime.InteropServices.JavaScript.Native/native/index.ts +++ b/src/native/libs/System.Runtime.InteropServices.JavaScript.Native/native/index.ts @@ -1,7 +1,7 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -import type { InternalExchange, InteropJavaScriptExports, JSFnHandle, JSMarshalerArguments } from "../interop/types"; +import type { InternalExchange, InteropJavaScriptExports, InteropJavaScriptExportsTable, JSFnHandle, JSMarshalerArguments } from "../interop/types"; import { InternalExchangeIndex } from "../types"; import { } from "./cross-linked"; // ensure ambient symbols are declared @@ -16,8 +16,15 @@ export function dotnetInitializeModule(internals: InternalExchange): void { const interopJavaScriptNativeExportsLocal: InteropJavaScriptExports = { }; dotnetSetInternals(internals); - internals[InternalExchangeIndex.InteropJavaScriptExportsTable] = dotnetTabIJSE(interopJavaScriptNativeExportsLocal); + internals[InternalExchangeIndex.InteropJavaScriptExportsTable] = tabulateInteropJavaScriptExports(interopJavaScriptNativeExportsLocal); const updates = internals[InternalExchangeIndex.InternalUpdatesCallbacks]; if (!updates.includes(dotnetUpdateModuleInternals)) updates.push(dotnetUpdateModuleInternals); dotnetUpdateAllInternals(); + + // eslint-disable-next-line @typescript-eslint/no-unused-vars + function tabulateInteropJavaScriptExports(map:InteropJavaScriptExports):InteropJavaScriptExportsTable { + // keep in sync with dotnetUpdateModuleInternals() + return [ + ]; + } } diff --git a/src/native/rollup.config.defines.js b/src/native/rollup.config.defines.js index 294375775a5006..4fefead9841f5e 100644 --- a/src/native/rollup.config.defines.js +++ b/src/native/rollup.config.defines.js @@ -12,13 +12,13 @@ console.log(`Rollup configuration: Configuration=${configuration}, ProductVersio export const banner = "//! Licensed to the .NET Foundation under one or more agreements.\n//! The .NET Foundation licenses this file to you under the MIT license.\n//! This is generated file, see src/native/libs/Browser/rollup.config.defines.js\n\n"; export const banner_dts = banner + "//! This is not considered public API with backward compatibility guarantees. \n"; export const keep_classnames = /(ManagedObject|ManagedError|Span|ArraySegment)/; -export const keep_fnames = /(dotnetSetInternals|dotnetUpdateAllInternals|dotnetUpdateModuleInternals|dotnetTabLE|dotnetTabRE|dotnetTabBHE|dotnetTabIJSE|dotnetTabNBE)/; +export const keep_fnames = /(dotnetSetInternals|dotnetUpdateAllInternals|dotnetUpdateModuleInternals)/; export const reserved = [ "Module", "dotnetApi", "dotnetInternals", "dotnetLogger", "dotnetAssert", "dotnetJSEngine", "dotnetSetInternals", "dotnetUpdateAllInternals", "dotnetUpdateModuleInternals", "dotnetInitializeModule", "dotnetLoaderExports", "dotnetRuntimeExports", "dotnetBrowserHostExports", "dotnetInteropJSExports", "dotnetNativeBrowserExports", - "dotnetTabLE", "dotnetTabRE", "dotnetTabBHE", "dotnetTabIJSE", "dotnetTabNBE"]; +]; export const externalDependencies = ["module", "process", "perf_hooks", "node:crypto"]; export const artifactsObjDir = "../../artifacts/obj"; From 549a859455101c155341c5ac6f42e9d4cb63d4d6 Mon Sep 17 00:00:00 2001 From: pavelsavara Date: Fri, 26 Sep 2025 09:07:27 +0200 Subject: [PATCH 13/25] ecma feedback --- src/native/rollup.config.plugins.js | 1 + src/native/tsconfig.json | 1 + 2 files changed, 2 insertions(+) diff --git a/src/native/rollup.config.plugins.js b/src/native/rollup.config.plugins.js index 9e877d5467b456..f9146efcdd8eb0 100644 --- a/src/native/rollup.config.plugins.js +++ b/src/native/rollup.config.plugins.js @@ -15,6 +15,7 @@ export const terserPlugin = (terserOptions) => { compress = compress || {}; mangle = mangle || {}; return terser({ + // keep in sync with src/native/tsconfig.json ecma: "2020", compress: { defaults: true, diff --git a/src/native/tsconfig.json b/src/native/tsconfig.json index 04ecb2b6b8e572..9ef2a54d8676bf 100644 --- a/src/native/tsconfig.json +++ b/src/native/tsconfig.json @@ -5,6 +5,7 @@ "removeComments": false, "module": "esnext", "sourceMap": true, + // keep in sync with src/native/rollup.config.defines.js "target": "ES2020", "moduleResolution": "Node", "strict": true, From 7e2b05297974dbbf43ea635aa1e1f7be4b5737e2 Mon Sep 17 00:00:00 2001 From: pavelsavara Date: Fri, 26 Sep 2025 09:13:40 +0200 Subject: [PATCH 14/25] feedback about rollup config flags --- src/native/rollup.config.defines.js | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/src/native/rollup.config.defines.js b/src/native/rollup.config.defines.js index 4fefead9841f5e..b89850e338abcd 100644 --- a/src/native/rollup.config.defines.js +++ b/src/native/rollup.config.defines.js @@ -3,8 +3,18 @@ import gitCommitInfo from "git-commit-info"; -export const configuration = process.env.Configuration || "Debug"; -export const productVersion = process.env.ProductVersion || "10.0.0-dev"; +if (process.env.ContinuousIntegrationBuild === undefined) { + throw new Error("ContinuousIntegrationBuild environment variable is not defined"); +} +if (process.env.Configuration === undefined) { + throw new Error("Configuration environment variable is not defined"); +} +if (process.env.ProductVersion === undefined) { + throw new Error("ProductVersion environment variable is not defined"); +} + +export const configuration = process.env.Configuration; +export const productVersion = process.env.ProductVersion; export const isContinuousIntegrationBuild = process.env.ContinuousIntegrationBuild === "true" ? true : false; console.log(`Rollup configuration: Configuration=${configuration}, ProductVersion=${productVersion}, ContinuousIntegrationBuild=${isContinuousIntegrationBuild}`); From 7258af3939915b11d1db16a9d512c506fe040e42 Mon Sep 17 00:00:00 2001 From: pavelsavara Date: Fri, 26 Sep 2025 09:15:45 +0200 Subject: [PATCH 15/25] todo feedback in memory --- .../corehost/browserhost/host/memory.ts | 20 ++++--------------- 1 file changed, 4 insertions(+), 16 deletions(-) diff --git a/src/native/corehost/browserhost/host/memory.ts b/src/native/corehost/browserhost/host/memory.ts index 67daa9467e143e..9767a9d9e5d464 100644 --- a/src/native/corehost/browserhost/host/memory.ts +++ b/src/native/corehost/browserhost/host/memory.ts @@ -87,9 +87,7 @@ export function setHeapI32(offset: MemOffset, value: number): void { */ export function setHeapI52(offset: MemOffset, value: number): void { dotnetAssert.check(Number.isSafeInteger(value), () => `Value is not a safe integer: ${value} (${typeof (value)})`); - throw new Error("TODO"); - // const error = cwraps.mono_wasm_f64_to_i52(offset, value); - // autoThrowI52(error); + throw new Error("TODO-WASM"); } /** @@ -98,9 +96,7 @@ export function setHeapI52(offset: MemOffset, value: number): void { export function setHeapU52(offset: MemOffset, value: number): void { dotnetAssert.check(Number.isSafeInteger(value), () => `Value is not a safe integer: ${value} (${typeof (value)})`); dotnetAssert.check(value >= 0, "Can't convert negative Number into UInt64"); - throw new Error("TODO"); - //const error = cwraps.mono_wasm_f64_to_u52(offset, value); - //autoThrowI52(error); + throw new Error("TODO-WASM"); } export function setHeapI64Big(offset: MemOffset, value: bigint): void { @@ -182,11 +178,7 @@ export function getHeapI32_local(localView: Int32Array, offset: MemOffset): numb */ // eslint-disable-next-line @typescript-eslint/no-unused-vars export function getHeapI52(offset: MemOffset): number { - throw new Error("TODO"); - //const result = cwraps.mono_wasm_i52_to_f64(offset, runtimeHelpers._i52_error_scratch_buffer); - //const error = getI32(runtimeHelpers._i52_error_scratch_buffer); - //autoThrowI52(error); - //return result; + throw new Error("TODO-WASM"); } /** @@ -194,11 +186,7 @@ export function getHeapI52(offset: MemOffset): number { */ // eslint-disable-next-line @typescript-eslint/no-unused-vars export function getHeapU52(offset: MemOffset): number { - throw new Error("TODO"); - //const result = cwraps.mono_wasm_u52_to_f64(offset, runtimeHelpers._i52_error_scratch_buffer); - //const error = getI32(runtimeHelpers._i52_error_scratch_buffer); - //autoThrowI52(error); - //return result; + throw new Error("TODO-WASM"); } export function getHeapI64Big(offset: MemOffset): bigint { From bd33d27f3fcfc8de85f39e3d4c6d8053bd406707 Mon Sep 17 00:00:00 2001 From: pavelsavara Date: Fri, 26 Sep 2025 09:17:31 +0200 Subject: [PATCH 16/25] ExceptionHandling.RaiseAppDomainUnhandledExceptionEvent --- src/native/corehost/browserhost/host/host.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/src/native/corehost/browserhost/host/host.ts b/src/native/corehost/browserhost/host/host.ts index d9b98ca9c4ae33..7f8784b3f81551 100644 --- a/src/native/corehost/browserhost/host/host.ts +++ b/src/native/corehost/browserhost/host/host.ts @@ -53,6 +53,7 @@ export function BrowserHost_RejectMain(reason:any) { // - second call to exit not override the first exit code // - improve reason extraction // - install global handler for unhandled exceptions and promise rejections +// - raise ExceptionHandling.RaiseAppDomainUnhandledExceptionEvent() export function exit(exit_code: number, reason: any): void { const reasonStr = reason ? (reason.stack ? reason.stack || reason.message : reason.toString()) : ""; if (exit_code !== 0) { From ddbfa3e372370b364b6e71bd92dbee8f54e930e9 Mon Sep 17 00:00:00 2001 From: pavelsavara Date: Fri, 26 Sep 2025 09:29:22 +0200 Subject: [PATCH 17/25] todo fetchWasm feedback --- src/native/corehost/browserhost/loader/bootstrap.ts | 7 ------- 1 file changed, 7 deletions(-) diff --git a/src/native/corehost/browserhost/loader/bootstrap.ts b/src/native/corehost/browserhost/loader/bootstrap.ts index 6b3088e5b7127c..dbd116888d6bcd 100644 --- a/src/native/corehost/browserhost/loader/bootstrap.ts +++ b/src/native/corehost/browserhost/loader/bootstrap.ts @@ -62,13 +62,6 @@ async function loadJSModule(asset: JsAsset, loadBootResource?: LoadBootResourceC return await import(/* webpackIgnore: true */ asset.resolvedUrl); } -/* WASM-TODO function fetchWasm(asset: WasmAsset): Promise { - if (asset.name && !asset.resolvedUrl) { - asset.resolvedUrl = locateFile(asset.name); - } - return fetchBytes(asset); -}*/ - async function fetchDll(asset: AssemblyAsset): Promise { if (asset.name && !asset.resolvedUrl) { asset.resolvedUrl = locateFile(asset.name); From df9f8c24987f02a2925cdafda6c53b045393e4c4 Mon Sep 17 00:00:00 2001 From: pavelsavara Date: Fri, 26 Sep 2025 09:40:43 +0200 Subject: [PATCH 18/25] missing config feedback --- src/native/corehost/browserhost/libBrowserHost.footer.js | 8 ++++++++ src/native/corehost/browserhost/loader/config.ts | 1 - src/native/corehost/browserhost/loader/exit.ts | 2 +- 3 files changed, 9 insertions(+), 2 deletions(-) diff --git a/src/native/corehost/browserhost/libBrowserHost.footer.js b/src/native/corehost/browserhost/libBrowserHost.footer.js index f6afcdb9ee5f3b..2e623505a03e2e 100644 --- a/src/native/corehost/browserhost/libBrowserHost.footer.js +++ b/src/native/corehost/browserhost/libBrowserHost.footer.js @@ -25,6 +25,14 @@ const HOST_PROPERTY_APP_PATHS = "APP_PATHS"; const config = dotnetInternals[2/*InternalExchangeIndex.LoaderConfig*/]; + if (!config.resources.assembly || + !config.resources.coreAssembly || + config.resources.coreAssembly.length === 0 || + !config.mainAssemblyName || + !config.virtualWorkingDirectory || + !config.environmentVariables) { + throw new Error("Invalid runtime config, cannot initialize the runtime."); + } const assemblyPaths = config.resources.assembly.map(a => a.virtualPath); const coreAssemblyPaths = config.resources.coreAssembly.map(a => a.virtualPath); ENV[HOST_PROPERTY_TRUSTED_PLATFORM_ASSEMBLIES] = config.environmentVariables[HOST_PROPERTY_TRUSTED_PLATFORM_ASSEMBLIES] = [...coreAssemblyPaths, ...assemblyPaths].join(":"); diff --git a/src/native/corehost/browserhost/loader/config.ts b/src/native/corehost/browserhost/loader/config.ts index 8f56444ca1f2b5..1373468922c733 100644 --- a/src/native/corehost/browserhost/loader/config.ts +++ b/src/native/corehost/browserhost/loader/config.ts @@ -99,7 +99,6 @@ function normalizeConfig(target: LoaderConfigInternal) { if (target.debugLevel === undefined) target.debugLevel = 0; if (target.diagnosticTracing === undefined) target.diagnosticTracing = false; if (target.virtualWorkingDirectory === undefined) target.virtualWorkingDirectory = "/"; - if (target.mainAssemblyName === undefined) target.mainAssemblyName = "HelloWorld.dll"; } function normalizeResources(target: Assets) { diff --git a/src/native/corehost/browserhost/loader/exit.ts b/src/native/corehost/browserhost/loader/exit.ts index b964d787fd164d..5200aa2d9ac995 100644 --- a/src/native/corehost/browserhost/loader/exit.ts +++ b/src/native/corehost/browserhost/loader/exit.ts @@ -3,7 +3,7 @@ import { dotnetJSEngine, dotnetLogger } from "./cross-module"; -// eslint-disable-next-line @typescript-eslint/no-unused-vars +// WASM-TODO: redirect to host.ts export function exit(exit_code: number, reason: any): void { const reasonStr = reason ? (reason.stack ? reason.stack || reason.message : reason.toString()) : ""; if (exit_code !== 0) { From d197301a30e75284eb1a603ad116e98153e85e5f Mon Sep 17 00:00:00 2001 From: pavelsavara Date: Fri, 26 Sep 2025 09:41:45 +0200 Subject: [PATCH 19/25] DotnetHostBuilder todo feedback --- .../browserhost/loader/host-builder.ts | 36 ------------------- 1 file changed, 36 deletions(-) diff --git a/src/native/corehost/browserhost/loader/host-builder.ts b/src/native/corehost/browserhost/loader/host-builder.ts index 6078b8272e042b..57fbbc8f834d24 100644 --- a/src/native/corehost/browserhost/loader/host-builder.ts +++ b/src/native/corehost/browserhost/loader/host-builder.ts @@ -101,42 +101,6 @@ export class HostBuilder implements DotnetHostBuilder { return this; } - // internal - withConsoleForwarding(): DotnetHostBuilder { - // TODO - return this; - } - - // internal - withExitOnUnhandledError(): DotnetHostBuilder { - // TODO - return this; - } - - // internal - withAsyncFlushOnExit(): DotnetHostBuilder { - // TODO - return this; - } - - // internal - withExitCodeLogging(): DotnetHostBuilder { - // TODO - return this; - } - - // internal - withElementOnExit(): DotnetHostBuilder { - // TODO - return this; - } - - // internal - withInteropCleanupOnExit(): DotnetHostBuilder { - // TODO - return this; - } - async download(): Promise { try { await downloadConfig(configUrl, loadBootResourceCallback); From d82c891e8bada7bc11864e3cdd3ec5f82f663a18 Mon Sep 17 00:00:00 2001 From: pavelsavara Date: Fri, 26 Sep 2025 09:47:36 +0200 Subject: [PATCH 20/25] cwraps todo --- src/native/corehost/browserhost/loader/run.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/src/native/corehost/browserhost/loader/run.ts b/src/native/corehost/browserhost/loader/run.ts index d9cef3137fac31..2aff971d23c9da 100644 --- a/src/native/corehost/browserhost/loader/run.ts +++ b/src/native/corehost/browserhost/loader/run.ts @@ -13,6 +13,7 @@ export function BrowserHost_InitializeCoreCLR():void { return; } // int BrowserHost_InitializeCoreCLR(void) + // WASM-TODO: add more formal ccall wrapper like cwraps in Mono const res = Module.ccall("BrowserHost_InitializeCoreCLR", "number") as number; if (res != 0) { const reason = new Error("Failed to initialize CoreCLR"); From 3779a395286455a2533b9a0f0ef02a5d4039bc33 Mon Sep 17 00:00:00 2001 From: pavelsavara Date: Fri, 26 Sep 2025 12:20:56 +0200 Subject: [PATCH 21/25] isConfigReady feedback --- src/native/corehost/browserhost/loader/config.ts | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/native/corehost/browserhost/loader/config.ts b/src/native/corehost/browserhost/loader/config.ts index 1373468922c733..5e6587cab616b2 100644 --- a/src/native/corehost/browserhost/loader/config.ts +++ b/src/native/corehost/browserhost/loader/config.ts @@ -4,11 +4,11 @@ import type { Assets, LoadBootResourceCallback, LoaderConfig, LoaderConfigInternal } from "./types"; export const netLoaderConfig: LoaderConfigInternal = {}; -let isConfigDownloaded = false; +let isConfigReady = false; export async function downloadConfig(url: string|undefined, loadBootResource?: LoadBootResourceCallback): Promise { if (loadBootResource) throw new Error("TODO: loadBootResource is not implemented yet"); - if (isConfigDownloaded) return; // only download config once + if (isConfigReady) return; // only download if necessary if (!url) { url = "./dotnet.boot.js"; } @@ -25,7 +25,7 @@ export async function downloadConfig(url: string|undefined, loadBootResource?: L const module = await import(/* webpackIgnore: true */ url); mergeLoaderConfig(module.config); } - isConfigDownloaded = true; + isConfigReady = true; } export function getLoaderConfig(): LoaderConfig { @@ -55,7 +55,7 @@ function mergeConfigs(target: LoaderConfigInternal, source: Partial Date: Fri, 26 Sep 2025 12:24:34 +0200 Subject: [PATCH 22/25] WASM-TODO --- src/native/corehost/browserhost/host/memory.ts | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/native/corehost/browserhost/host/memory.ts b/src/native/corehost/browserhost/host/memory.ts index 9767a9d9e5d464..a4f402f63c72f2 100644 --- a/src/native/corehost/browserhost/host/memory.ts +++ b/src/native/corehost/browserhost/host/memory.ts @@ -87,7 +87,7 @@ export function setHeapI32(offset: MemOffset, value: number): void { */ export function setHeapI52(offset: MemOffset, value: number): void { dotnetAssert.check(Number.isSafeInteger(value), () => `Value is not a safe integer: ${value} (${typeof (value)})`); - throw new Error("TODO-WASM"); + throw new Error("WASM-TODO"); } /** @@ -96,7 +96,7 @@ export function setHeapI52(offset: MemOffset, value: number): void { export function setHeapU52(offset: MemOffset, value: number): void { dotnetAssert.check(Number.isSafeInteger(value), () => `Value is not a safe integer: ${value} (${typeof (value)})`); dotnetAssert.check(value >= 0, "Can't convert negative Number into UInt64"); - throw new Error("TODO-WASM"); + throw new Error("WASM-TODO"); } export function setHeapI64Big(offset: MemOffset, value: bigint): void { @@ -178,7 +178,7 @@ export function getHeapI32_local(localView: Int32Array, offset: MemOffset): numb */ // eslint-disable-next-line @typescript-eslint/no-unused-vars export function getHeapI52(offset: MemOffset): number { - throw new Error("TODO-WASM"); + throw new Error("WASM-TODO"); } /** @@ -186,7 +186,7 @@ export function getHeapI52(offset: MemOffset): number { */ // eslint-disable-next-line @typescript-eslint/no-unused-vars export function getHeapU52(offset: MemOffset): number { - throw new Error("TODO-WASM"); + throw new Error("WASM-TODO"); } export function getHeapI64Big(offset: MemOffset): bigint { From 9d02e42c58155d6931d0b3b369954a4d278196e4 Mon Sep 17 00:00:00 2001 From: pavelsavara Date: Fri, 26 Sep 2025 14:55:22 +0200 Subject: [PATCH 23/25] fix type names --- src/native/corehost/browserhost/loader/index.ts | 8 ++++---- .../libs/Common/JavaScript/cross-linked/index.ts | 6 +++--- .../libs/Common/JavaScript/cross-module/index.ts | 16 ++++++++-------- .../libs/Common/JavaScript/types/exchange.ts | 4 ++-- 4 files changed, 17 insertions(+), 17 deletions(-) diff --git a/src/native/corehost/browserhost/loader/index.ts b/src/native/corehost/browserhost/loader/index.ts index 2ad1f7c03358b5..150f2e03520e1d 100644 --- a/src/native/corehost/browserhost/loader/index.ts +++ b/src/native/corehost/browserhost/loader/index.ts @@ -1,7 +1,7 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -import type { dotnetLoggerType, dotnetAssertType, RuntimeAPI, LoaderExports, NativeBrowserExportsTable, LoaderExportsTable, RuntimeExportsTable, InternalExchange, BrowserHostExportsTable, InteropJavaScriptExportsTable } from "./types"; +import type { LoggerType, AssertType, RuntimeAPI, LoaderExports, NativeBrowserExportsTable, LoaderExportsTable, RuntimeExportsTable, InternalExchange, BrowserHostExportsTable, InteropJavaScriptExportsTable } from "./types"; import { InternalExchangeIndex } from "../types"; import ProductVersion from "consts:productVersion"; @@ -71,12 +71,12 @@ export function dotnetInitializeModule(): RuntimeAPI { IS_WORKER: ENVIRONMENT_IS_WORKER(), IS_SIDECAR: ENVIRONMENT_IS_SIDECAR(), }; - const logger: dotnetLoggerType = { + const logger: LoggerType = { info, warn, error, }; - const assert: dotnetAssertType = { + const assert: AssertType = { check, }; Object.assign(dotnetApi, runtimeApiFunctions); @@ -88,7 +88,7 @@ export function dotnetInitializeModule(): RuntimeAPI { dotnetUpdateAllInternals(); return dotnetApi as RuntimeAPI; - function dotnetTabLE(logger:dotnetLoggerType, assert:dotnetAssertType, dotnetLoaderExports:LoaderExports):LoaderExportsTable { + function dotnetTabLE(logger:LoggerType, assert:AssertType, dotnetLoaderExports:LoaderExports):LoaderExportsTable { // keep in sync with dotnetUpdateModuleInternals() return [ logger.info, diff --git a/src/native/libs/Common/JavaScript/cross-linked/index.ts b/src/native/libs/Common/JavaScript/cross-linked/index.ts index 36e472b53bb69d..f7be8c372ba8a8 100644 --- a/src/native/libs/Common/JavaScript/cross-linked/index.ts +++ b/src/native/libs/Common/JavaScript/cross-linked/index.ts @@ -1,15 +1,15 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -import type { dotnetAssertType, EmscriptenModuleInternal, JSEngineType, dotnetLoggerType, LoaderExports, InternalExchange } from "../types"; +import type { AssertType, EmscriptenModuleInternal, JSEngineType, LoggerType, LoaderExports, InternalExchange } from "../types"; // we want to use the cross-module symbols defined in closure of dotnet.native.js // which are installed there by libSystem.Native.Browser.footer.js // see also `reserved` in `rollup.config.defines.js` declare global { export const Module:EmscriptenModuleInternal; - export const dotnetAssert:dotnetAssertType; - export const dotnetLogger:dotnetLoggerType; + export const dotnetAssert:AssertType; + export const dotnetLogger:LoggerType; export const dotnetJSEngine:JSEngineType; export const dotnetLoaderExports:LoaderExports; export const dotnetSetInternals:(internals:Partial) => void; diff --git a/src/native/libs/Common/JavaScript/cross-module/index.ts b/src/native/libs/Common/JavaScript/cross-module/index.ts index 84fd7acb713263..141fdc67c448f2 100644 --- a/src/native/libs/Common/JavaScript/cross-module/index.ts +++ b/src/native/libs/Common/JavaScript/cross-module/index.ts @@ -7,13 +7,13 @@ * Please keep it small and register it into emscripten as dependency. */ -import type { DotnetModuleInternal, InternalExchange, RuntimeExports, LoaderExports, RuntimeAPI, dotnetLoggerType, dotnetAssertType, JSEngineType, BrowserHostExports, InteropJavaScriptExports, LoaderExportsTable, RuntimeExportsTable, BrowserHostExportsTable, InteropJavaScriptExportsTable, NativeBrowserExports, NativeBrowserExportsTable } from "../types"; +import type { DotnetModuleInternal, InternalExchange, RuntimeExports, LoaderExports, RuntimeAPI, LoggerType, AssertType, JSEngineType, BrowserHostExports, InteropJavaScriptExports, LoaderExportsTable, RuntimeExportsTable, BrowserHostExportsTable, InteropJavaScriptExportsTable, NativeBrowserExports, NativeBrowserExportsTable } from "../types"; import { InternalExchangeIndex } from "../types"; export let Module: DotnetModuleInternal; export let dotnetApi: RuntimeAPI; -export let dotnetLogger: dotnetLoggerType = {} as any; -export let dotnetAssert: dotnetAssertType = {} as any; +export let dotnetLogger: LoggerType = {} as any; +export let dotnetAssert: AssertType = {} as any; export let dotnetJSEngine: JSEngineType = {}as any; export let dotnetLoaderExports: LoaderExports = {} as any; export let dotnetRuntimeExports: RuntimeExports = {} as any; @@ -49,8 +49,8 @@ export function dotnetUpdateModuleInternals() { if (Object.keys(dotnetLoaderExports).length === 0 && dotnetInternals[InternalExchangeIndex.LoaderExportsTable]) { dotnetLoaderExports = {} as LoaderExports; - dotnetLogger = {} as dotnetLoggerType; - dotnetAssert = {} as dotnetAssertType; + dotnetLogger = {} as LoggerType; + dotnetAssert = {} as AssertType; dotnetJSEngine = {} as JSEngineType; expandLoaderExports(dotnetInternals[InternalExchangeIndex.LoaderExportsTable], dotnetLogger, dotnetAssert, dotnetJSEngine, dotnetLoaderExports); } @@ -78,13 +78,13 @@ export function dotnetUpdateModuleInternals() { } // keep in sync with tabulateLoaderExports() - function expandLoaderExports(table:LoaderExportsTable, logger:dotnetLoggerType, assert:dotnetAssertType, jsEngine:JSEngineType, dotnetLoaderExports:LoaderExports):void { - const loggerLocal :dotnetLoggerType = { + function expandLoaderExports(table:LoaderExportsTable, logger:LoggerType, assert:AssertType, jsEngine:JSEngineType, dotnetLoaderExports:LoaderExports):void { + const loggerLocal :LoggerType = { info: table[0], warn: table[1], error: table[2], }; - const assertLocal :dotnetAssertType = { + const assertLocal :AssertType = { check: table[3], }; const loaderExportsLocal :LoaderExports = { diff --git a/src/native/libs/Common/JavaScript/types/exchange.ts b/src/native/libs/Common/JavaScript/types/exchange.ts index 502a7fef630898..b7913331f0a651 100644 --- a/src/native/libs/Common/JavaScript/types/exchange.ts +++ b/src/native/libs/Common/JavaScript/types/exchange.ts @@ -20,13 +20,13 @@ export type RuntimeExports = { export type RuntimeExportsTable = [ ] -export type dotnetLoggerType = { +export type LoggerType = { info: typeof info, warn: typeof warn, error: typeof error, } -export type dotnetAssertType = { +export type AssertType = { check: typeof check, } From 763ab3cdcee9c81cd3caa390b19d69948d6347e3 Mon Sep 17 00:00:00 2001 From: pavelsavara Date: Fri, 26 Sep 2025 14:57:49 +0200 Subject: [PATCH 24/25] draft SystemJS_GetLocaleInfo and dependencies --- .../Common/JavaScript/cross-module/index.ts | 3 + .../libs/Common/JavaScript/types/exchange.ts | 7 ++ .../libs/System.Native.Browser/entrypoints.c | 2 + .../native/globalization-locale.ts | 92 +++++++++++++++++++ .../interop/index.ts | 7 ++ .../interop/memory.ts | 37 ++++++++ .../interop/strings.ts | 58 ++++++++++++ src/tests/build.cmd | 4 +- 8 files changed, 209 insertions(+), 1 deletion(-) create mode 100644 src/native/libs/System.Native.Browser/native/globalization-locale.ts create mode 100644 src/native/libs/System.Runtime.InteropServices.JavaScript.Native/interop/memory.ts create mode 100644 src/native/libs/System.Runtime.InteropServices.JavaScript.Native/interop/strings.ts diff --git a/src/native/libs/Common/JavaScript/cross-module/index.ts b/src/native/libs/Common/JavaScript/cross-module/index.ts index 141fdc67c448f2..affc6e791f0985 100644 --- a/src/native/libs/Common/JavaScript/cross-module/index.ts +++ b/src/native/libs/Common/JavaScript/cross-module/index.ts @@ -74,6 +74,9 @@ export function dotnetUpdateModuleInternals() { // keep in sync with tabulateRuntimeExports() function expandRuntimeExports(table:RuntimeExportsTable, runtime:RuntimeExports):void { Object.assign(runtime, { + utf16ToString: table[0], + stringToUTF16: table[1], + stringToUTF16Ptr: table[2], }); } diff --git a/src/native/libs/Common/JavaScript/types/exchange.ts b/src/native/libs/Common/JavaScript/types/exchange.ts index b7913331f0a651..ac630558e2e93f 100644 --- a/src/native/libs/Common/JavaScript/types/exchange.ts +++ b/src/native/libs/Common/JavaScript/types/exchange.ts @@ -5,6 +5,7 @@ import type { registerDllBytes } from "../../../../corehost/browserhost/host/hos import type { isSharedArrayBuffer } from "../../../../corehost/browserhost/host/memory"; import type { check, error, info, warn } from "../../../../corehost/browserhost/loader/logging"; import type { resolveRunMainPromise, rejectRunMainPromise, getRunMainPromise } from "../../../../corehost/browserhost/loader/run"; +import type { stringToUTF16, stringToUTF16Ptr, utf16ToString } from "../../../System.Runtime.InteropServices.JavaScript.Native/interop/strings"; export type JSEngineType = { IS_NODE: boolean, @@ -15,9 +16,15 @@ export type JSEngineType = { } export type RuntimeExports = { + utf16ToString: typeof utf16ToString, + stringToUTF16: typeof stringToUTF16, + stringToUTF16Ptr: typeof stringToUTF16Ptr, } export type RuntimeExportsTable = [ + typeof utf16ToString, + typeof stringToUTF16, + typeof stringToUTF16Ptr, ] export type LoggerType = { diff --git a/src/native/libs/System.Native.Browser/entrypoints.c b/src/native/libs/System.Native.Browser/entrypoints.c index de5c91cf87238b..39b08164047aa5 100644 --- a/src/native/libs/System.Native.Browser/entrypoints.c +++ b/src/native/libs/System.Native.Browser/entrypoints.c @@ -10,10 +10,12 @@ // implemented in JavaScript EXTERN_C int32_t SystemJS_RandomBytes(uint8_t* buffer, int32_t bufferLength); +EXTERN_C char16_t* SystemJS_GetLocaleInfo (const uint16_t* locale, int32_t localeLength, const uint16_t* culture, int32_t cultureLength, const uint16_t* result, int32_t resultMaxLength, int *resultLength); static const Entry s_browserNative[] = { DllImportEntry(SystemJS_RandomBytes) + DllImportEntry(SystemJS_GetLocaleInfo) }; EXTERN_C const void* SystemJSResolveDllImport(const char* name); diff --git a/src/native/libs/System.Native.Browser/native/globalization-locale.ts b/src/native/libs/System.Native.Browser/native/globalization-locale.ts new file mode 100644 index 00000000000000..eed5b625307c94 --- /dev/null +++ b/src/native/libs/System.Native.Browser/native/globalization-locale.ts @@ -0,0 +1,92 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +import { dotnetApi, dotnetRuntimeExports } from "../cross-module"; +import { Int32Ptr, VoidPtr, VoidPtrNull } from "../types"; + +// char16_t* SystemJS_GetLocaleInfo (const uint16_t* locale, int32_t localeLength, const uint16_t* culture, int32_t cultureLength, const uint16_t* result, int32_t resultMaxLength, int *resultLength); +export function SystemJS_GetLocaleInfo(culture: number, cultureLength: number, locale: number, localeLength: number, dst: number, dstMaxLength: number, dstLength: Int32Ptr): VoidPtr { + const OUTER_SEPARATOR = "##"; + try { + const localeNameOriginal = dotnetRuntimeExports.utf16ToString(locale, (locale + 2 * localeLength)); + const localeName = normalizeLocale(localeNameOriginal); + if (!localeName && localeNameOriginal) { + // handle non-standard or malformed locales by forwarding the locale code + dotnetRuntimeExports.stringToUTF16(dst, dst + 2 * localeNameOriginal.length, localeNameOriginal); + dotnetApi.setHeapI32( dstLength, localeNameOriginal.length); + return VoidPtrNull; + } + const cultureNameOriginal = dotnetRuntimeExports.utf16ToString(culture, (culture + 2 * cultureLength)); + const cultureName = normalizeLocale(cultureNameOriginal); + + if (!localeName || !cultureName) + throw new Error(`Locale or culture name is null or empty. localeName=${localeName}, cultureName=${cultureName}`); + + const localeParts = localeName.split("-"); + // cultureName can be in a form of: + // 1) "language", e.g. "zh" + // 2) "language-region", e.g. "zn-CN" + // 3) "language-script-region", e.g. "zh-Hans-CN" + // 4) "language-script", e.g. "zh-Hans" (served in the catch block below) + let languageName, regionName; + try { + const region = localeParts.length > 1 ? localeParts.pop() : undefined; + // this line might fail if form 4 from the comment above is used: + regionName = region ? new Intl.DisplayNames([cultureName], { type: "region" }).of(region) : undefined; + const language = localeParts.join("-"); + languageName = new Intl.DisplayNames([cultureName], { type: "language" }).of(language); + } catch (error) { + if (error instanceof RangeError) { + // if it failed from this reason then cultureName is in a form "language-script", without region + try { + languageName = new Intl.DisplayNames([cultureName], { type: "language" }).of(localeName); + } catch (error) { + if (error instanceof RangeError && localeNameOriginal) { + // handle non-standard or malformed locales by forwarding the locale code, e.g. "xx-u-xx" + dotnetRuntimeExports.stringToUTF16(dst, dst + 2 * localeNameOriginal.length, localeNameOriginal); + dotnetApi.setHeapI32(dstLength, localeNameOriginal.length); + return VoidPtrNull; + } + throw error; + } + } else { + throw error; + } + } + const localeInfo = { + LanguageName: languageName, + RegionName: regionName, + }; + const result = Object.values(localeInfo).join(OUTER_SEPARATOR); + + if (!result) + throw new Error(`Locale info for locale=${localeName} is null or empty.`); + + if (result.length > dstMaxLength) + throw new Error(`Locale info for locale=${localeName} exceeds length of ${dstMaxLength}.`); + + dotnetRuntimeExports.stringToUTF16(dst, dst + 2 * result.length, result); + dotnetApi.setHeapI32(dstLength, result.length); + return VoidPtrNull; + } catch (ex: any) { + dotnetApi.setHeapI32(dstLength, -1); + return dotnetRuntimeExports.stringToUTF16Ptr(ex.toString()); + } + + function normalizeLocale(locale: string | null) { + if (!locale) + return undefined; + try { + locale = locale.toLocaleLowerCase().replace("_", "-"); + if (locale.startsWith("zh-")) { + // browser does not recognize "zh-chs" and "zh-cht" as equivalents of "zh-Hans" "zh-Hant", we are helping, otherwise + // it would throw on getCanonicalLocales with "RangeError: Incorrect locale information provided" + locale = locale.replace("-chs", "-Hans").replace("-cht", "-Hant"); + } + const canonicalLocales = (Intl as any).getCanonicalLocales(locale); + return canonicalLocales.length > 0 ? canonicalLocales[0] : undefined; + } catch { + return undefined; + } + } +} diff --git a/src/native/libs/System.Runtime.InteropServices.JavaScript.Native/interop/index.ts b/src/native/libs/System.Runtime.InteropServices.JavaScript.Native/interop/index.ts index da0b9d0c755c8d..d66b3b98beb0e8 100644 --- a/src/native/libs/System.Runtime.InteropServices.JavaScript.Native/interop/index.ts +++ b/src/native/libs/System.Runtime.InteropServices.JavaScript.Native/interop/index.ts @@ -4,6 +4,7 @@ import type { InternalExchange, RuntimeAPI, RuntimeExports, RuntimeExportsTable } from "./types"; import { InternalExchangeIndex } from "../types"; import { dotnetSetInternals, dotnetUpdateAllInternals, dotnetUpdateModuleInternals } from "./cross-module"; +import { stringToUTF16, stringToUTF16Ptr, utf16ToString } from "./strings"; export function dotnetInitializeModule(internals: InternalExchange): void { const runtimeApiLocal: Partial = { @@ -11,6 +12,9 @@ export function dotnetInitializeModule(internals: InternalExchange): void { setModuleImports, }; const runtimeExportsLocal: RuntimeExports = { + utf16ToString, + stringToUTF16, + stringToUTF16Ptr, }; dotnetSetInternals(internals); Object.assign(internals[InternalExchangeIndex.RuntimeAPI], runtimeApiLocal); @@ -21,6 +25,9 @@ export function dotnetInitializeModule(internals: InternalExchange): void { function tabulateRuntimeExports(map:RuntimeExports):RuntimeExportsTable { // keep in sync with dotnetUpdateModuleInternals() return [ + map.utf16ToString, + map.stringToUTF16, + map.stringToUTF16Ptr, ]; } } diff --git a/src/native/libs/System.Runtime.InteropServices.JavaScript.Native/interop/memory.ts b/src/native/libs/System.Runtime.InteropServices.JavaScript.Native/interop/memory.ts new file mode 100644 index 00000000000000..97f980f22499d0 --- /dev/null +++ b/src/native/libs/System.Runtime.InteropServices.JavaScript.Native/interop/memory.ts @@ -0,0 +1,37 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +import { CharPtr, MemOffset, VoidPtr } from "./types"; +import { dotnetBrowserHostExports, dotnetApi } from "./cross-module"; + +// does not check for growable heap +export function getU16Local(localView: Uint16Array, offset: MemOffset): number { + return localView[offset >>> 1]; +} + +// does not check for growable heap +export function setU16Local(localView: Uint16Array, offset: MemOffset, value: number): void { + assertIntInRange(value, 0, 0xFFFF); + localView[offset >>> 1] = value; +} + +// When threading is enabled, TextDecoder does not accept a view of a +// SharedArrayBuffer, we must make a copy of the array first. +// See https://github.com/whatwg/encoding/issues/172 +export function viewOrCopy(view: Uint8Array, start: CharPtr, end: CharPtr): Uint8Array { + // this condition should be eliminated by rollup on non-threading builds + const needsCopy = dotnetBrowserHostExports.isSharedArrayBuffer(view.buffer); + return needsCopy + ? view.slice(start, end) + : view.subarray(start, end); +} + +export function assertIntInRange(value: Number, min: Number, max: Number) { + dotnetAssert.check(Number.isSafeInteger(value), () => `Value is not an integer: ${value} (${typeof (value)})`); + dotnetAssert.check(value >= min && value <= max, () => `Overflow: value ${value} is out of ${min} ${max} range`); +} + +export function ZeroRegion(byteOffset: VoidPtr, sizeBytes: number): void { + dotnetApi.localHeapViewU8().fill(0, byteOffset, byteOffset + sizeBytes); +} + diff --git a/src/native/libs/System.Runtime.InteropServices.JavaScript.Native/interop/strings.ts b/src/native/libs/System.Runtime.InteropServices.JavaScript.Native/interop/strings.ts new file mode 100644 index 00000000000000..c17408341f5e70 --- /dev/null +++ b/src/native/libs/System.Runtime.InteropServices.JavaScript.Native/interop/strings.ts @@ -0,0 +1,58 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +import { dotnetApi } from "./cross-module"; +import { getU16Local, setU16Local, viewOrCopy, ZeroRegion } from "./memory"; +import { VoidPtr } from "./types"; + +let textDecoderUtf16: TextDecoder | undefined | null; +let stringsInitialized = false; + +export function stringsInit(): void { + if (!stringsInitialized) { + // V8 does not provide TextDecoder + if (typeof TextDecoder !== "undefined") { + textDecoderUtf16 = new TextDecoder("utf-16le"); + } + stringsInitialized = true; + } +} + +export function stringToUTF16(dstPtr: number, endPtr: number, text: string) { + const heapI16 = dotnetApi.localHeapViewU16(); + const len = text.length; + for (let i = 0; i < len; i++) { + setU16Local(heapI16, dstPtr, text.charCodeAt(i)); + dstPtr += 2; + if (dstPtr >= endPtr) break; + } +} + +export function stringToUTF16Ptr(str: string): VoidPtr { + const bytes = (str.length + 1) * 2; + const ptr = Module._malloc(bytes) as any; + ZeroRegion(ptr, str.length * 2); + stringToUTF16(ptr, ptr + bytes, str); + return ptr; +} + +export function utf16ToString(startPtr: number, endPtr: number): string { + stringsInit(); + if (textDecoderUtf16) { + const subArray = viewOrCopy(dotnetApi.localHeapViewU8(), startPtr as any, endPtr as any); + return textDecoderUtf16.decode(subArray); + } else { + return utf16ToStringLoop(startPtr, endPtr); + } +} + +// V8 does not provide TextDecoder +export function utf16ToStringLoop(startPtr: number, endPtr: number): string { + let str = ""; + const heapU16 = dotnetApi.localHeapViewU16(); + for (let i = startPtr; i < endPtr; i += 2) { + const char = getU16Local(heapU16, i); + str += String.fromCharCode(char); + } + return str; +} diff --git a/src/tests/build.cmd b/src/tests/build.cmd index c500bcb1cc30d4..37d195c62266e5 100644 --- a/src/tests/build.cmd +++ b/src/tests/build.cmd @@ -72,6 +72,8 @@ if /i "%1" == "--" (set processedArgs=!processedArgs! %1&s if /i "%1" == "x64" (set __BuildArch=x64&set processedArgs=!processedArgs! %1&shift&goto Arg_Loop) if /i "%1" == "x86" (set __BuildArch=x86&set processedArgs=!processedArgs! %1&shift&goto Arg_Loop) if /i "%1" == "arm64" (set __BuildArch=arm64&set processedArgs=!processedArgs! %1&shift&goto Arg_Loop) +if /i "%1" == "wasm" (set __BuildArch=wasm&set processedArgs=!processedArgs! %1&shift&goto Arg_Loop) +if /i "%1" == "browser" (set __TargetOS=browser&set processedArgs=!processedArgs! %1&shift&goto Arg_Loop) if /i "%1" == "debug" (set __BuildType=Debug&set processedArgs=!processedArgs! %1&shift&goto Arg_Loop) if /i "%1" == "release" (set __BuildType=Release&set processedArgs=!processedArgs! %1&shift&goto Arg_Loop) @@ -374,7 +376,7 @@ echo All arguments are optional and case-insensitive, and the '-' prefix is opti echo. echo.-? -h --help: View this message. echo. -echo Build architecture: one of "x64", "x86", "arm64" ^(default: x64^). +echo Build architecture: one of "x64", "x86", "arm64", "wasm" ^(default: x64^). echo Build type: one of "Debug", "Checked", "Release" ^(default: Debug^). echo. echo -Rebuild: Clean up all test artifacts prior to building tests. From bfc7617d31e2b182d47e8a17c191ed83832e981c Mon Sep 17 00:00:00 2001 From: pavelsavara Date: Fri, 26 Sep 2025 15:47:27 +0200 Subject: [PATCH 25/25] fix --- src/native/libs/System.Native.Browser/entrypoints.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/native/libs/System.Native.Browser/entrypoints.c b/src/native/libs/System.Native.Browser/entrypoints.c index 39b08164047aa5..7fb0248ef2e7a6 100644 --- a/src/native/libs/System.Native.Browser/entrypoints.c +++ b/src/native/libs/System.Native.Browser/entrypoints.c @@ -10,7 +10,7 @@ // implemented in JavaScript EXTERN_C int32_t SystemJS_RandomBytes(uint8_t* buffer, int32_t bufferLength); -EXTERN_C char16_t* SystemJS_GetLocaleInfo (const uint16_t* locale, int32_t localeLength, const uint16_t* culture, int32_t cultureLength, const uint16_t* result, int32_t resultMaxLength, int *resultLength); +EXTERN_C uint16_t* SystemJS_GetLocaleInfo (const uint16_t* locale, int32_t localeLength, const uint16_t* culture, int32_t cultureLength, const uint16_t* result, int32_t resultMaxLength, int *resultLength); static const Entry s_browserNative[] = {