piral-blazor 1.0.0-pre.2217 → 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +1 -1
- package/README.md +55 -12
- package/convert.d.ts +13 -10
- package/convert.js +17 -12
- package/esm/converter.d.ts +10 -6
- package/esm/converter.js +164 -48
- package/esm/converter.js.map +1 -1
- package/esm/create.d.ts +21 -1
- package/esm/create.js +29 -15
- package/esm/create.js.map +1 -1
- package/esm/dependencies.d.ts +6 -3
- package/esm/dependencies.js +104 -14
- package/esm/dependencies.js.map +1 -1
- package/esm/events.d.ts +6 -0
- package/esm/events.js +145 -0
- package/esm/events.js.map +1 -0
- package/esm/interop.d.ts +29 -0
- package/esm/interop.js +205 -0
- package/esm/interop.js.map +1 -0
- package/esm/navigation.d.ts +2 -0
- package/esm/navigation.js +30 -0
- package/esm/navigation.js.map +1 -0
- package/esm/types.d.ts +97 -4
- package/infra.codegen +53 -68
- package/lib/converter.d.ts +10 -6
- package/lib/converter.js +164 -48
- package/lib/converter.js.map +1 -1
- package/lib/create.d.ts +21 -1
- package/lib/create.js +31 -17
- package/lib/create.js.map +1 -1
- package/lib/dependencies.d.ts +6 -3
- package/lib/dependencies.js +104 -14
- package/lib/dependencies.js.map +1 -1
- package/lib/events.d.ts +6 -0
- package/lib/events.js +154 -0
- package/lib/events.js.map +1 -0
- package/lib/index.js +1 -1
- package/lib/interop.d.ts +29 -0
- package/lib/interop.js +226 -0
- package/lib/interop.js.map +1 -0
- package/lib/navigation.d.ts +2 -0
- package/lib/navigation.js +35 -0
- package/lib/navigation.js.map +1 -0
- package/lib/types.d.ts +97 -4
- package/package.json +26 -13
- package/src/converter.ts +237 -57
- package/src/create.ts +53 -9
- package/src/dependencies.ts +122 -14
- package/src/events.ts +174 -0
- package/src/interop.ts +273 -0
- package/src/navigation.ts +36 -0
- package/src/types.ts +115 -4
- package/convert.ts +0 -17
- package/esm/internal/Environment.d.ts +0 -3
- package/esm/internal/Environment.js +0 -6
- package/esm/internal/Environment.js.map +0 -1
- package/esm/internal/Platform/BootConfig.d.ts +0 -20
- package/esm/internal/Platform/BootConfig.js +0 -10
- package/esm/internal/Platform/BootConfig.js.map +0 -1
- package/esm/internal/Platform/Mono/MonoDebugger.d.ts +0 -3
- package/esm/internal/Platform/Mono/MonoDebugger.js +0 -43
- package/esm/internal/Platform/Mono/MonoDebugger.js.map +0 -1
- package/esm/internal/Platform/Mono/MonoPlatform.d.ts +0 -2
- package/esm/internal/Platform/Mono/MonoPlatform.js +0 -403
- package/esm/internal/Platform/Mono/MonoPlatform.js.map +0 -1
- package/esm/internal/Platform/Mono/TimezoneDataFile.d.ts +0 -1
- package/esm/internal/Platform/Mono/TimezoneDataFile.js +0 -51
- package/esm/internal/Platform/Mono/TimezoneDataFile.js.map +0 -1
- package/esm/internal/Platform/Platform.d.ts +0 -31
- package/esm/internal/Platform/Platform.js +0 -2
- package/esm/internal/Platform/Platform.js.map +0 -1
- package/esm/internal/Platform/Url.d.ts +0 -2
- package/esm/internal/Platform/Url.js +0 -11
- package/esm/internal/Platform/Url.js.map +0 -1
- package/esm/internal/Platform/WebAssemblyConfigLoader.d.ts +0 -4
- package/esm/internal/Platform/WebAssemblyConfigLoader.js +0 -64
- package/esm/internal/Platform/WebAssemblyConfigLoader.js.map +0 -1
- package/esm/internal/Platform/WebAssemblyResourceLoader.d.ts +0 -24
- package/esm/internal/Platform/WebAssemblyResourceLoader.js +0 -223
- package/esm/internal/Platform/WebAssemblyResourceLoader.js.map +0 -1
- package/esm/internal/Platform/WebAssemblyStartOptions.d.ts +0 -13
- package/esm/internal/Platform/WebAssemblyStartOptions.js +0 -2
- package/esm/internal/Platform/WebAssemblyStartOptions.js.map +0 -1
- package/esm/internal/Rendering/BrowserRenderer.d.ts +0 -38
- package/esm/internal/Rendering/BrowserRenderer.js +0 -458
- package/esm/internal/Rendering/BrowserRenderer.js.map +0 -1
- package/esm/internal/Rendering/ElementReferenceCapture.d.ts +0 -1
- package/esm/internal/Rendering/ElementReferenceCapture.js +0 -24
- package/esm/internal/Rendering/ElementReferenceCapture.js.map +0 -1
- package/esm/internal/Rendering/EventDelegator.d.ts +0 -20
- package/esm/internal/Rendering/EventDelegator.js +0 -236
- package/esm/internal/Rendering/EventDelegator.js.map +0 -1
- package/esm/internal/Rendering/EventFieldInfo.d.ts +0 -6
- package/esm/internal/Rendering/EventFieldInfo.js +0 -32
- package/esm/internal/Rendering/EventFieldInfo.js.map +0 -1
- package/esm/internal/Rendering/EventForDotNet.d.ts +0 -10
- package/esm/internal/Rendering/EventForDotNet.js +0 -194
- package/esm/internal/Rendering/EventForDotNet.js.map +0 -1
- package/esm/internal/Rendering/LogicalElements.d.ts +0 -19
- package/esm/internal/Rendering/LogicalElements.js +0 -250
- package/esm/internal/Rendering/LogicalElements.js.map +0 -1
- package/esm/internal/Rendering/RenderBatch/BinaryDecoder.d.ts +0 -5
- package/esm/internal/Rendering/RenderBatch/BinaryDecoder.js +0 -34
- package/esm/internal/Rendering/RenderBatch/BinaryDecoder.js.map +0 -1
- package/esm/internal/Rendering/RenderBatch/OutOfProcessRenderBatch.d.ts +0 -18
- package/esm/internal/Rendering/RenderBatch/OutOfProcessRenderBatch.js +0 -190
- package/esm/internal/Rendering/RenderBatch/OutOfProcessRenderBatch.js.map +0 -1
- package/esm/internal/Rendering/RenderBatch/RenderBatch.d.ts +0 -87
- package/esm/internal/Rendering/RenderBatch/RenderBatch.js +0 -26
- package/esm/internal/Rendering/RenderBatch/RenderBatch.js.map +0 -1
- package/esm/internal/Rendering/RenderBatch/SharedMemoryRenderBatch.d.ts +0 -52
- package/esm/internal/Rendering/RenderBatch/SharedMemoryRenderBatch.js +0 -103
- package/esm/internal/Rendering/RenderBatch/SharedMemoryRenderBatch.js.map +0 -1
- package/esm/internal/Rendering/RenderBatch/Utf8Decoder.d.ts +0 -1
- package/esm/internal/Rendering/RenderBatch/Utf8Decoder.js +0 -63
- package/esm/internal/Rendering/RenderBatch/Utf8Decoder.js.map +0 -1
- package/esm/internal/Rendering/Renderer.d.ts +0 -8
- package/esm/internal/Rendering/Renderer.js +0 -69
- package/esm/internal/Rendering/Renderer.js.map +0 -1
- package/esm/internal/Rendering/RendererEventDispatcher.d.ts +0 -4
- package/esm/internal/Rendering/RendererEventDispatcher.js +0 -11
- package/esm/internal/Rendering/RendererEventDispatcher.js.map +0 -1
- package/esm/internal/Services/NavigationManager.d.ts +0 -16
- package/esm/internal/Services/NavigationManager.js +0 -138
- package/esm/internal/Services/NavigationManager.js.map +0 -1
- package/esm/internal/globals.d.ts +0 -1
- package/esm/internal/globals.js +0 -5
- package/esm/internal/globals.js.map +0 -1
- package/esm/internal/index.d.ts +0 -15
- package/esm/internal/index.js +0 -152
- package/esm/internal/index.js.map +0 -1
- package/lib/internal/Environment.d.ts +0 -3
- package/lib/internal/Environment.js +0 -9
- package/lib/internal/Environment.js.map +0 -1
- package/lib/internal/Platform/BootConfig.d.ts +0 -20
- package/lib/internal/Platform/BootConfig.js +0 -13
- package/lib/internal/Platform/BootConfig.js.map +0 -1
- package/lib/internal/Platform/Mono/MonoDebugger.d.ts +0 -3
- package/lib/internal/Platform/Mono/MonoDebugger.js +0 -48
- package/lib/internal/Platform/Mono/MonoDebugger.js.map +0 -1
- package/lib/internal/Platform/Mono/MonoPlatform.d.ts +0 -2
- package/lib/internal/Platform/Mono/MonoPlatform.js +0 -406
- package/lib/internal/Platform/Mono/MonoPlatform.js.map +0 -1
- package/lib/internal/Platform/Mono/TimezoneDataFile.d.ts +0 -1
- package/lib/internal/Platform/Mono/TimezoneDataFile.js +0 -55
- package/lib/internal/Platform/Mono/TimezoneDataFile.js.map +0 -1
- package/lib/internal/Platform/Platform.d.ts +0 -31
- package/lib/internal/Platform/Platform.js +0 -3
- package/lib/internal/Platform/Platform.js.map +0 -1
- package/lib/internal/Platform/Url.d.ts +0 -2
- package/lib/internal/Platform/Url.js +0 -16
- package/lib/internal/Platform/Url.js.map +0 -1
- package/lib/internal/Platform/WebAssemblyConfigLoader.d.ts +0 -4
- package/lib/internal/Platform/WebAssemblyConfigLoader.js +0 -67
- package/lib/internal/Platform/WebAssemblyConfigLoader.js.map +0 -1
- package/lib/internal/Platform/WebAssemblyResourceLoader.d.ts +0 -24
- package/lib/internal/Platform/WebAssemblyResourceLoader.js +0 -226
- package/lib/internal/Platform/WebAssemblyResourceLoader.js.map +0 -1
- package/lib/internal/Platform/WebAssemblyStartOptions.d.ts +0 -13
- package/lib/internal/Platform/WebAssemblyStartOptions.js +0 -3
- package/lib/internal/Platform/WebAssemblyStartOptions.js.map +0 -1
- package/lib/internal/Rendering/BrowserRenderer.d.ts +0 -38
- package/lib/internal/Rendering/BrowserRenderer.js +0 -461
- package/lib/internal/Rendering/BrowserRenderer.js.map +0 -1
- package/lib/internal/Rendering/ElementReferenceCapture.d.ts +0 -1
- package/lib/internal/Rendering/ElementReferenceCapture.js +0 -28
- package/lib/internal/Rendering/ElementReferenceCapture.js.map +0 -1
- package/lib/internal/Rendering/EventDelegator.d.ts +0 -20
- package/lib/internal/Rendering/EventDelegator.js +0 -239
- package/lib/internal/Rendering/EventDelegator.js.map +0 -1
- package/lib/internal/Rendering/EventFieldInfo.d.ts +0 -6
- package/lib/internal/Rendering/EventFieldInfo.js +0 -35
- package/lib/internal/Rendering/EventFieldInfo.js.map +0 -1
- package/lib/internal/Rendering/EventForDotNet.d.ts +0 -10
- package/lib/internal/Rendering/EventForDotNet.js +0 -197
- package/lib/internal/Rendering/EventForDotNet.js.map +0 -1
- package/lib/internal/Rendering/LogicalElements.d.ts +0 -19
- package/lib/internal/Rendering/LogicalElements.js +0 -265
- package/lib/internal/Rendering/LogicalElements.js.map +0 -1
- package/lib/internal/Rendering/RenderBatch/BinaryDecoder.d.ts +0 -5
- package/lib/internal/Rendering/RenderBatch/BinaryDecoder.js +0 -42
- package/lib/internal/Rendering/RenderBatch/BinaryDecoder.js.map +0 -1
- package/lib/internal/Rendering/RenderBatch/OutOfProcessRenderBatch.d.ts +0 -18
- package/lib/internal/Rendering/RenderBatch/OutOfProcessRenderBatch.js +0 -193
- package/lib/internal/Rendering/RenderBatch/OutOfProcessRenderBatch.js.map +0 -1
- package/lib/internal/Rendering/RenderBatch/RenderBatch.d.ts +0 -87
- package/lib/internal/Rendering/RenderBatch/RenderBatch.js +0 -29
- package/lib/internal/Rendering/RenderBatch/RenderBatch.js.map +0 -1
- package/lib/internal/Rendering/RenderBatch/SharedMemoryRenderBatch.d.ts +0 -52
- package/lib/internal/Rendering/RenderBatch/SharedMemoryRenderBatch.js +0 -106
- package/lib/internal/Rendering/RenderBatch/SharedMemoryRenderBatch.js.map +0 -1
- package/lib/internal/Rendering/RenderBatch/Utf8Decoder.d.ts +0 -1
- package/lib/internal/Rendering/RenderBatch/Utf8Decoder.js +0 -66
- package/lib/internal/Rendering/RenderBatch/Utf8Decoder.js.map +0 -1
- package/lib/internal/Rendering/Renderer.d.ts +0 -8
- package/lib/internal/Rendering/Renderer.js +0 -76
- package/lib/internal/Rendering/Renderer.js.map +0 -1
- package/lib/internal/Rendering/RendererEventDispatcher.d.ts +0 -4
- package/lib/internal/Rendering/RendererEventDispatcher.js +0 -16
- package/lib/internal/Rendering/RendererEventDispatcher.js.map +0 -1
- package/lib/internal/Services/NavigationManager.d.ts +0 -16
- package/lib/internal/Services/NavigationManager.js +0 -144
- package/lib/internal/Services/NavigationManager.js.map +0 -1
- package/lib/internal/globals.d.ts +0 -1
- package/lib/internal/globals.js +0 -7
- package/lib/internal/globals.js.map +0 -1
- package/lib/internal/index.d.ts +0 -15
- package/lib/internal/index.js +0 -161
- package/lib/internal/index.js.map +0 -1
- package/src/internal/Environment.ts +0 -11
- package/src/internal/Platform/BootConfig.ts +0 -21
- package/src/internal/Platform/Mono/MonoDebugger.ts +0 -48
- package/src/internal/Platform/Mono/MonoPlatform.ts +0 -494
- package/src/internal/Platform/Mono/MonoTypes.d.ts +0 -27
- package/src/internal/Platform/Mono/TimezoneDataFile.ts +0 -46
- package/src/internal/Platform/Platform.ts +0 -40
- package/src/internal/Platform/Url.ts +0 -11
- package/src/internal/Platform/WebAssemblyConfigLoader.ts +0 -34
- package/src/internal/Platform/WebAssemblyResourceLoader.ts +0 -234
- package/src/internal/Platform/WebAssemblyStartOptions.ts +0 -22
- package/src/internal/Rendering/BrowserRenderer.ts +0 -616
- package/src/internal/Rendering/ElementReferenceCapture.ts +0 -27
- package/src/internal/Rendering/EventDelegator.ts +0 -293
- package/src/internal/Rendering/EventFieldInfo.ts +0 -31
- package/src/internal/Rendering/EventForDotNet.ts +0 -370
- package/src/internal/Rendering/LogicalElements.ts +0 -289
- package/src/internal/Rendering/RenderBatch/BinaryDecoder.ts +0 -43
- package/src/internal/Rendering/RenderBatch/OutOfProcessRenderBatch.ts +0 -244
- package/src/internal/Rendering/RenderBatch/RenderBatch.ts +0 -100
- package/src/internal/Rendering/RenderBatch/SharedMemoryRenderBatch.ts +0 -137
- package/src/internal/Rendering/RenderBatch/Utf8Decoder.ts +0 -66
- package/src/internal/Rendering/Renderer.ts +0 -98
- package/src/internal/Rendering/RendererEventDispatcher.ts +0 -20
- package/src/internal/Services/NavigationManager.ts +0 -157
- package/src/internal/globals.ts +0 -5
- package/src/internal/index.ts +0 -170
|
@@ -1,494 +0,0 @@
|
|
|
1
|
-
import { attachDebuggerHotkey, hasDebuggingEnabled } from './MonoDebugger';
|
|
2
|
-
import { WebAssemblyResourceLoader, LoadingResource } from '../WebAssemblyResourceLoader';
|
|
3
|
-
import { Platform, System_Array, Pointer, System_Object, System_String } from '../Platform';
|
|
4
|
-
import { loadTimezoneData } from './TimezoneDataFile';
|
|
5
|
-
import { WebAssemblyBootResourceType } from '../WebAssemblyStartOptions';
|
|
6
|
-
|
|
7
|
-
declare const Module: EmscriptenModule;
|
|
8
|
-
|
|
9
|
-
let mono_string_get_utf8: (managedString: System_String) => Pointer;
|
|
10
|
-
let mono_wasm_add_assembly: (name: string, heapAddress: number, length: number) => void;
|
|
11
|
-
const appBinDirName = 'appBinDir';
|
|
12
|
-
const uint64HighOrderShift = Math.pow(2, 32);
|
|
13
|
-
const maxSafeNumberHighPart = Math.pow(2, 21) - 1; // The high-order int32 from Number.MAX_SAFE_INTEGER
|
|
14
|
-
|
|
15
|
-
// Memory access helpers
|
|
16
|
-
// The implementations are exactly equivalent to what the global getValue(addr, type) function does,
|
|
17
|
-
// except without having to parse the 'type' parameter, and with less risk of mistakes at the call site
|
|
18
|
-
function getValueI16(ptr: number) {
|
|
19
|
-
return Module.HEAP16[ptr >> 1];
|
|
20
|
-
}
|
|
21
|
-
function getValueI32(ptr: number) {
|
|
22
|
-
return Module.HEAP32[ptr >> 2];
|
|
23
|
-
}
|
|
24
|
-
function getValueFloat(ptr: number) {
|
|
25
|
-
return Module.HEAPF32[ptr >> 2];
|
|
26
|
-
}
|
|
27
|
-
function getValueU64(ptr: number) {
|
|
28
|
-
// There is no Module.HEAPU64, and Module.getValue(..., 'i64') doesn't work because the implementation
|
|
29
|
-
// treats 'i64' as being the same as 'i32'. Also we must take care to read both halves as unsigned.
|
|
30
|
-
const heapU32Index = ptr >> 2;
|
|
31
|
-
const highPart = Module.HEAPU32[heapU32Index + 1];
|
|
32
|
-
if (highPart > maxSafeNumberHighPart) {
|
|
33
|
-
throw new Error(
|
|
34
|
-
`Cannot read uint64 with high order part ${highPart}, because the result would exceed Number.MAX_SAFE_INTEGER.`,
|
|
35
|
-
);
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
return highPart * uint64HighOrderShift + Module.HEAPU32[heapU32Index];
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
export const monoPlatform: Platform = {
|
|
42
|
-
start: function start(resourceLoader: WebAssemblyResourceLoader) {
|
|
43
|
-
return new Promise<void>((resolve, reject) => {
|
|
44
|
-
attachDebuggerHotkey(resourceLoader);
|
|
45
|
-
|
|
46
|
-
// dotnet.js assumes the existence of this
|
|
47
|
-
window['Browser'] = {
|
|
48
|
-
init: () => {},
|
|
49
|
-
};
|
|
50
|
-
|
|
51
|
-
// Emscripten works by expecting the module config to be a global
|
|
52
|
-
// For compatibility with macOS Catalina, we have to assign a temporary value to window.Module
|
|
53
|
-
// before we start loading the WebAssembly files
|
|
54
|
-
addGlobalModuleScriptTagsToDocument(() => {
|
|
55
|
-
window['Module'] = createEmscriptenModuleInstance(resourceLoader, resolve, reject);
|
|
56
|
-
addScriptTagsToDocument(resourceLoader);
|
|
57
|
-
});
|
|
58
|
-
});
|
|
59
|
-
},
|
|
60
|
-
|
|
61
|
-
callEntryPoint: function callEntryPoint(assemblyName: string) {
|
|
62
|
-
// Instead of using Module.mono_call_assembly_entry_point, we have our own logic for invoking
|
|
63
|
-
// the entrypoint which adds support for async main.
|
|
64
|
-
// Currently we disregard the return value from the entrypoint, whether it's sync or async.
|
|
65
|
-
// In the future, we might want Blazor.start to return a Promise<Promise<value>>, where the
|
|
66
|
-
// outer promise reflects the startup process, and the inner one reflects the possibly-async
|
|
67
|
-
// .NET entrypoint method.
|
|
68
|
-
const invokeEntrypoint = bindStaticMethod(
|
|
69
|
-
'Microsoft.AspNetCore.Components.WebAssembly',
|
|
70
|
-
'Microsoft.AspNetCore.Components.WebAssembly.Hosting.EntrypointInvoker',
|
|
71
|
-
'InvokeEntrypoint',
|
|
72
|
-
);
|
|
73
|
-
// Note we're passing in null because passing arrays is problematic until https://github.com/mono/mono/issues/18245 is resolved.
|
|
74
|
-
invokeEntrypoint(assemblyName, null);
|
|
75
|
-
},
|
|
76
|
-
|
|
77
|
-
toUint8Array: function toUint8Array(array: System_Array<any>): Uint8Array {
|
|
78
|
-
const dataPtr = getArrayDataPointer(array);
|
|
79
|
-
const length = getValueI32(dataPtr);
|
|
80
|
-
return new Uint8Array(Module.HEAPU8.buffer, dataPtr + 4, length);
|
|
81
|
-
},
|
|
82
|
-
|
|
83
|
-
getArrayLength: function getArrayLength(array: System_Array<any>): number {
|
|
84
|
-
return getValueI32(getArrayDataPointer(array));
|
|
85
|
-
},
|
|
86
|
-
|
|
87
|
-
getArrayEntryPtr: function getArrayEntryPtr<TPtr extends Pointer>(
|
|
88
|
-
array: System_Array<TPtr>,
|
|
89
|
-
index: number,
|
|
90
|
-
itemSize: number,
|
|
91
|
-
): TPtr {
|
|
92
|
-
// First byte is array length, followed by entries
|
|
93
|
-
const address = getArrayDataPointer(array) + 4 + index * itemSize;
|
|
94
|
-
return (address as any) as TPtr;
|
|
95
|
-
},
|
|
96
|
-
|
|
97
|
-
getObjectFieldsBaseAddress: function getObjectFieldsBaseAddress(referenceTypedObject: System_Object): Pointer {
|
|
98
|
-
// The first two int32 values are internal Mono data
|
|
99
|
-
return ((((referenceTypedObject as any) as number) + 8) as any) as Pointer;
|
|
100
|
-
},
|
|
101
|
-
|
|
102
|
-
readInt16Field: function readHeapInt16(baseAddress: Pointer, fieldOffset?: number): number {
|
|
103
|
-
return getValueI16(((baseAddress as any) as number) + (fieldOffset || 0));
|
|
104
|
-
},
|
|
105
|
-
|
|
106
|
-
readInt32Field: function readHeapInt32(baseAddress: Pointer, fieldOffset?: number): number {
|
|
107
|
-
return getValueI32(((baseAddress as any) as number) + (fieldOffset || 0));
|
|
108
|
-
},
|
|
109
|
-
|
|
110
|
-
readUint64Field: function readHeapUint64(baseAddress: Pointer, fieldOffset?: number): number {
|
|
111
|
-
return getValueU64(((baseAddress as any) as number) + (fieldOffset || 0));
|
|
112
|
-
},
|
|
113
|
-
|
|
114
|
-
readFloatField: function readHeapFloat(baseAddress: Pointer, fieldOffset?: number): number {
|
|
115
|
-
return getValueFloat(((baseAddress as any) as number) + (fieldOffset || 0));
|
|
116
|
-
},
|
|
117
|
-
|
|
118
|
-
readObjectField: function readHeapObject<T extends System_Object>(baseAddress: Pointer, fieldOffset?: number): T {
|
|
119
|
-
return (getValueI32(((baseAddress as any) as number) + (fieldOffset || 0)) as any) as T;
|
|
120
|
-
},
|
|
121
|
-
|
|
122
|
-
readStringField: function readHeapObject(
|
|
123
|
-
baseAddress: Pointer,
|
|
124
|
-
fieldOffset?: number,
|
|
125
|
-
readBoolValueAsString?: boolean,
|
|
126
|
-
): string | null {
|
|
127
|
-
const fieldValue = getValueI32(((baseAddress as any) as number) + (fieldOffset || 0));
|
|
128
|
-
if (fieldValue === 0) {
|
|
129
|
-
return null;
|
|
130
|
-
}
|
|
131
|
-
|
|
132
|
-
if (readBoolValueAsString) {
|
|
133
|
-
// Some fields are stored as a union of bool | string | null values, but need to read as a string.
|
|
134
|
-
// If the stored value is a bool, the behavior we want is empty string ('') for true, or null for false.
|
|
135
|
-
const unboxedValue = BINDING.unbox_mono_obj((fieldValue as any) as System_Object);
|
|
136
|
-
if (typeof unboxedValue === 'boolean') {
|
|
137
|
-
return unboxedValue ? '' : null;
|
|
138
|
-
}
|
|
139
|
-
return unboxedValue;
|
|
140
|
-
}
|
|
141
|
-
|
|
142
|
-
return BINDING.conv_string((fieldValue as any) as System_String);
|
|
143
|
-
},
|
|
144
|
-
|
|
145
|
-
readStructField: function readStructField<T extends Pointer>(baseAddress: Pointer, fieldOffset?: number): T {
|
|
146
|
-
return ((((baseAddress as any) as number) + (fieldOffset || 0)) as any) as T;
|
|
147
|
-
},
|
|
148
|
-
};
|
|
149
|
-
|
|
150
|
-
function addScriptTagsToDocument(resourceLoader: WebAssemblyResourceLoader) {
|
|
151
|
-
const browserSupportsNativeWebAssembly = typeof WebAssembly !== 'undefined' && WebAssembly.validate;
|
|
152
|
-
if (!browserSupportsNativeWebAssembly) {
|
|
153
|
-
throw new Error('This browser does not support WebAssembly.');
|
|
154
|
-
}
|
|
155
|
-
|
|
156
|
-
// The dotnet.*.js file has a version or hash in its name as a form of cache-busting. This is needed
|
|
157
|
-
// because it's the only part of the loading process that can't use cache:'no-cache' (because it's
|
|
158
|
-
// not a 'fetch') and isn't controllable by the developer (so they can't put in their own cache-busting
|
|
159
|
-
// querystring). So, to find out the exact URL we have to search the boot manifest.
|
|
160
|
-
const dotnetJsResourceName = Object.keys(resourceLoader.bootConfig.resources.runtime).filter(
|
|
161
|
-
(n) => n.startsWith('dotnet.') && n.endsWith('.js'),
|
|
162
|
-
)[0];
|
|
163
|
-
const dotnetJsContentHash = resourceLoader.bootConfig.resources.runtime[dotnetJsResourceName];
|
|
164
|
-
const scriptElem = document.createElement('script');
|
|
165
|
-
scriptElem.src = `_framework/wasm/${dotnetJsResourceName}`;
|
|
166
|
-
scriptElem.defer = true;
|
|
167
|
-
|
|
168
|
-
// For consistency with WebAssemblyResourceLoader, we only enforce SRI if caching is allowed
|
|
169
|
-
if (resourceLoader.bootConfig.cacheBootResources) {
|
|
170
|
-
scriptElem.integrity = dotnetJsContentHash;
|
|
171
|
-
scriptElem.crossOrigin = 'anonymous';
|
|
172
|
-
}
|
|
173
|
-
|
|
174
|
-
// Allow overriding the URI from which the dotnet.*.js file is loaded
|
|
175
|
-
if (resourceLoader.startOptions.loadBootResource) {
|
|
176
|
-
const resourceType: WebAssemblyBootResourceType = 'dotnetjs';
|
|
177
|
-
const customSrc = resourceLoader.startOptions.loadBootResource(
|
|
178
|
-
resourceType,
|
|
179
|
-
dotnetJsResourceName,
|
|
180
|
-
scriptElem.src,
|
|
181
|
-
dotnetJsContentHash,
|
|
182
|
-
);
|
|
183
|
-
if (typeof customSrc === 'string') {
|
|
184
|
-
scriptElem.src = customSrc;
|
|
185
|
-
} else if (customSrc) {
|
|
186
|
-
// Since we must load this via a <script> tag, it's only valid to supply a URI (and not a Request, say)
|
|
187
|
-
throw new Error(`For a ${resourceType} resource, custom loaders must supply a URI string.`);
|
|
188
|
-
}
|
|
189
|
-
}
|
|
190
|
-
|
|
191
|
-
document.body.appendChild(scriptElem);
|
|
192
|
-
}
|
|
193
|
-
|
|
194
|
-
// Due to a strange behavior in macOS Catalina, we have to delay loading the WebAssembly files
|
|
195
|
-
// until after it finishes evaluating a <script> element that assigns a value to window.Module.
|
|
196
|
-
// This may be fixed in a later version of macOS/iOS, or even if not it may be possible to reduce
|
|
197
|
-
// this to a smaller workaround.
|
|
198
|
-
function addGlobalModuleScriptTagsToDocument(callback: () => void) {
|
|
199
|
-
const scriptElem = document.createElement('script');
|
|
200
|
-
|
|
201
|
-
// This pollutes global but is needed so it can be called from the script.
|
|
202
|
-
// The callback is put in the global scope so that it can be run after the script is loaded.
|
|
203
|
-
// onload cannot be used in this case for non-file scripts.
|
|
204
|
-
window['__wasmmodulecallback__'] = callback;
|
|
205
|
-
scriptElem.type = 'text/javascript';
|
|
206
|
-
scriptElem.text = 'var Module; window.__wasmmodulecallback__(); delete window.__wasmmodulecallback__;';
|
|
207
|
-
|
|
208
|
-
document.body.appendChild(scriptElem);
|
|
209
|
-
}
|
|
210
|
-
|
|
211
|
-
function createEmscriptenModuleInstance(
|
|
212
|
-
resourceLoader: WebAssemblyResourceLoader,
|
|
213
|
-
onReady: () => void,
|
|
214
|
-
onError: (reason?: any) => void,
|
|
215
|
-
) {
|
|
216
|
-
const resources = resourceLoader.bootConfig.resources;
|
|
217
|
-
const module = (window['Module'] || {}) as typeof Module;
|
|
218
|
-
const suppressMessages = ['DEBUGGING ENABLED'];
|
|
219
|
-
|
|
220
|
-
module.print = (line) => suppressMessages.indexOf(line) < 0 && console.log(line);
|
|
221
|
-
|
|
222
|
-
module.printErr = (line) => {
|
|
223
|
-
// If anything writes to stderr, treat it as a critical exception. The underlying runtime writes
|
|
224
|
-
// to stderr if a truly critical problem occurs outside .NET code. Note that .NET unhandled
|
|
225
|
-
// exceptions also reach this, but via a different code path - see dotNetCriticalError below.
|
|
226
|
-
console.error(line);
|
|
227
|
-
};
|
|
228
|
-
module.preRun = module.preRun || [];
|
|
229
|
-
module.postRun = module.postRun || [];
|
|
230
|
-
(module as any).preloadPlugins = [];
|
|
231
|
-
|
|
232
|
-
// Begin loading the .dll/.pdb/.wasm files, but don't block here. Let other loading processes run in parallel.
|
|
233
|
-
const dotnetWasmResourceName = 'dotnet.wasm';
|
|
234
|
-
const assembliesBeingLoaded = resourceLoader.loadResources(
|
|
235
|
-
resources.assembly,
|
|
236
|
-
(filename) => `_framework/_bin/${filename}`,
|
|
237
|
-
'assembly',
|
|
238
|
-
);
|
|
239
|
-
const pdbsBeingLoaded = resourceLoader.loadResources(
|
|
240
|
-
resources.pdb || {},
|
|
241
|
-
(filename) => `_framework/_bin/${filename}`,
|
|
242
|
-
'pdb',
|
|
243
|
-
);
|
|
244
|
-
const wasmBeingLoaded = resourceLoader.loadResource(
|
|
245
|
-
/* name */ dotnetWasmResourceName,
|
|
246
|
-
/* url */ `_framework/wasm/${dotnetWasmResourceName}`,
|
|
247
|
-
/* hash */ resourceLoader.bootConfig.resources.runtime[dotnetWasmResourceName],
|
|
248
|
-
/* type */ 'dotnetwasm',
|
|
249
|
-
);
|
|
250
|
-
|
|
251
|
-
const dotnetTimeZoneResourceName = 'dotnet.timezones.dat';
|
|
252
|
-
let timeZoneResource: LoadingResource | undefined;
|
|
253
|
-
if (resourceLoader.bootConfig.resources.runtime.hasOwnProperty(dotnetTimeZoneResourceName)) {
|
|
254
|
-
timeZoneResource = resourceLoader.loadResource(
|
|
255
|
-
dotnetTimeZoneResourceName,
|
|
256
|
-
`_framework/wasm/${dotnetTimeZoneResourceName}`,
|
|
257
|
-
resourceLoader.bootConfig.resources.runtime[dotnetTimeZoneResourceName],
|
|
258
|
-
'timezonedata',
|
|
259
|
-
);
|
|
260
|
-
}
|
|
261
|
-
|
|
262
|
-
// Override the mechanism for fetching the main wasm file so we can connect it to our cache
|
|
263
|
-
module.instantiateWasm = (imports, successCallback): Emscripten.WebAssemblyExports => {
|
|
264
|
-
(async () => {
|
|
265
|
-
let compiledInstance: WebAssembly.Instance;
|
|
266
|
-
try {
|
|
267
|
-
const dotnetWasmResource = await wasmBeingLoaded;
|
|
268
|
-
compiledInstance = await compileWasmModule(dotnetWasmResource, imports);
|
|
269
|
-
} catch (ex) {
|
|
270
|
-
module.printErr(ex);
|
|
271
|
-
throw ex;
|
|
272
|
-
}
|
|
273
|
-
successCallback(compiledInstance);
|
|
274
|
-
})();
|
|
275
|
-
return []; // No exports
|
|
276
|
-
};
|
|
277
|
-
|
|
278
|
-
module.preRun.push(() => {
|
|
279
|
-
// By now, emscripten should be initialised enough that we can capture these methods for later use
|
|
280
|
-
mono_wasm_add_assembly = cwrap('mono_wasm_add_assembly', null, ['string', 'number', 'number']);
|
|
281
|
-
mono_string_get_utf8 = cwrap('mono_wasm_string_get_utf8', 'number', ['number']);
|
|
282
|
-
MONO.loaded_files = [];
|
|
283
|
-
|
|
284
|
-
if (timeZoneResource) {
|
|
285
|
-
loadTimezone(timeZoneResource);
|
|
286
|
-
}
|
|
287
|
-
|
|
288
|
-
// Fetch the assemblies and PDBs in the background, telling Mono to wait until they are loaded
|
|
289
|
-
// Mono requires the assembly filenames to have a '.dll' extension, so supply such names regardless
|
|
290
|
-
// of the extensions in the URLs. This allows loading assemblies with arbitrary filenames.
|
|
291
|
-
assembliesBeingLoaded.forEach((r) => addResourceAsAssembly(r, changeExtension(r.name, '.dll')));
|
|
292
|
-
pdbsBeingLoaded.forEach((r) => addResourceAsAssembly(r, r.name));
|
|
293
|
-
|
|
294
|
-
window['Blazor']._internal.dotNetCriticalError = (message: System_String) => {
|
|
295
|
-
module.printErr(BINDING.conv_string(message) || '(null)');
|
|
296
|
-
};
|
|
297
|
-
|
|
298
|
-
// Wire-up callbacks for satellite assemblies. Blazor will call these as part of the application
|
|
299
|
-
// startup sequence to load satellite assemblies for the application's culture.
|
|
300
|
-
window['Blazor']._internal.getSatelliteAssemblies = (
|
|
301
|
-
culturesToLoadDotNetArray: System_Array<System_String>,
|
|
302
|
-
): System_Object => {
|
|
303
|
-
const culturesToLoad = BINDING.mono_array_to_js_array<System_String, string>(culturesToLoadDotNetArray);
|
|
304
|
-
const satelliteResources = resourceLoader.bootConfig.resources.satelliteResources;
|
|
305
|
-
|
|
306
|
-
if (satelliteResources) {
|
|
307
|
-
const resourcePromises = Promise.all(
|
|
308
|
-
culturesToLoad
|
|
309
|
-
.filter((culture) => satelliteResources.hasOwnProperty(culture))
|
|
310
|
-
.map((culture) =>
|
|
311
|
-
resourceLoader.loadResources(
|
|
312
|
-
satelliteResources[culture],
|
|
313
|
-
(fileName) => `_framework/_bin/${fileName}`,
|
|
314
|
-
'assembly',
|
|
315
|
-
),
|
|
316
|
-
)
|
|
317
|
-
.reduce((previous, next) => previous.concat(next), new Array<LoadingResource>())
|
|
318
|
-
.map(async (resource) => (await resource.response).arrayBuffer()),
|
|
319
|
-
);
|
|
320
|
-
|
|
321
|
-
return BINDING.js_to_mono_obj(
|
|
322
|
-
resourcePromises.then((resourcesToLoad) => {
|
|
323
|
-
if (resourcesToLoad.length) {
|
|
324
|
-
window['Blazor']._internal.readSatelliteAssemblies = () => {
|
|
325
|
-
const array = BINDING.mono_obj_array_new(resourcesToLoad.length);
|
|
326
|
-
for (var i = 0; i < resourcesToLoad.length; i++) {
|
|
327
|
-
BINDING.mono_obj_array_set(
|
|
328
|
-
array,
|
|
329
|
-
i,
|
|
330
|
-
BINDING.js_typed_array_to_array(new Uint8Array(resourcesToLoad[i])),
|
|
331
|
-
);
|
|
332
|
-
}
|
|
333
|
-
return array;
|
|
334
|
-
};
|
|
335
|
-
}
|
|
336
|
-
|
|
337
|
-
return resourcesToLoad.length;
|
|
338
|
-
}),
|
|
339
|
-
);
|
|
340
|
-
}
|
|
341
|
-
return BINDING.js_to_mono_obj(Promise.resolve(0));
|
|
342
|
-
};
|
|
343
|
-
});
|
|
344
|
-
|
|
345
|
-
module.postRun.push(() => {
|
|
346
|
-
if (resourceLoader.bootConfig.debugBuild && resourceLoader.bootConfig.cacheBootResources) {
|
|
347
|
-
resourceLoader.logToConsole();
|
|
348
|
-
}
|
|
349
|
-
resourceLoader.purgeUnusedCacheEntriesAsync(); // Don't await - it's fine to run in background
|
|
350
|
-
|
|
351
|
-
MONO.mono_wasm_setenv('MONO_URI_DOTNETRELATIVEORABSOLUTE', 'true');
|
|
352
|
-
const load_runtime = cwrap('mono_wasm_load_runtime', null, ['string', 'number']);
|
|
353
|
-
// -1 enables debugging with logging disabled. 0 disables debugging entirely.
|
|
354
|
-
load_runtime(appBinDirName, hasDebuggingEnabled() ? -1 : 0);
|
|
355
|
-
MONO.mono_wasm_runtime_ready();
|
|
356
|
-
attachInteropInvoker();
|
|
357
|
-
onReady();
|
|
358
|
-
});
|
|
359
|
-
|
|
360
|
-
return module;
|
|
361
|
-
|
|
362
|
-
async function addResourceAsAssembly(dependency: LoadingResource, loadAsName: string) {
|
|
363
|
-
const runDependencyId = `blazor:${dependency.name}`;
|
|
364
|
-
addRunDependency(runDependencyId);
|
|
365
|
-
|
|
366
|
-
try {
|
|
367
|
-
// Wait for the data to be loaded and verified
|
|
368
|
-
const dataBuffer = await dependency.response.then((r) => r.arrayBuffer());
|
|
369
|
-
|
|
370
|
-
// Load it into the Mono runtime
|
|
371
|
-
const data = new Uint8Array(dataBuffer);
|
|
372
|
-
const heapAddress = Module._malloc(data.length);
|
|
373
|
-
const heapMemory = new Uint8Array(Module.HEAPU8.buffer, heapAddress, data.length);
|
|
374
|
-
heapMemory.set(data);
|
|
375
|
-
mono_wasm_add_assembly(loadAsName, heapAddress, data.length);
|
|
376
|
-
MONO.loaded_files.push(toAbsoluteUrl(dependency.url));
|
|
377
|
-
} catch (errorInfo) {
|
|
378
|
-
onError(errorInfo);
|
|
379
|
-
return;
|
|
380
|
-
}
|
|
381
|
-
|
|
382
|
-
removeRunDependency(runDependencyId);
|
|
383
|
-
}
|
|
384
|
-
}
|
|
385
|
-
|
|
386
|
-
const anchorTagForAbsoluteUrlConversions = document.createElement('a');
|
|
387
|
-
function toAbsoluteUrl(possiblyRelativeUrl: string) {
|
|
388
|
-
anchorTagForAbsoluteUrlConversions.href = possiblyRelativeUrl;
|
|
389
|
-
return anchorTagForAbsoluteUrlConversions.href;
|
|
390
|
-
}
|
|
391
|
-
|
|
392
|
-
function getArrayDataPointer<T>(array: System_Array<T>): number {
|
|
393
|
-
return <number>(<any>array) + 12; // First byte from here is length, then following bytes are entries
|
|
394
|
-
}
|
|
395
|
-
|
|
396
|
-
function bindStaticMethod(assembly: string, typeName: string, method: string) {
|
|
397
|
-
// Fully qualified name looks like this: "[debugger-test] Math:IntAdd"
|
|
398
|
-
const fqn = `[${assembly}] ${typeName}:${method}`;
|
|
399
|
-
return BINDING.bind_static_method(fqn);
|
|
400
|
-
}
|
|
401
|
-
|
|
402
|
-
function attachInteropInvoker(): void {
|
|
403
|
-
const dotNetDispatcherInvokeMethodHandle = bindStaticMethod(
|
|
404
|
-
'Microsoft.AspNetCore.Components.WebAssembly',
|
|
405
|
-
'Microsoft.AspNetCore.Components.WebAssembly.Services.DefaultWebAssemblyJSRuntime',
|
|
406
|
-
'InvokeDotNet',
|
|
407
|
-
);
|
|
408
|
-
const dotNetDispatcherBeginInvokeMethodHandle = bindStaticMethod(
|
|
409
|
-
'Microsoft.AspNetCore.Components.WebAssembly',
|
|
410
|
-
'Microsoft.AspNetCore.Components.WebAssembly.Services.DefaultWebAssemblyJSRuntime',
|
|
411
|
-
'BeginInvokeDotNet',
|
|
412
|
-
);
|
|
413
|
-
const dotNetDispatcherEndInvokeJSMethodHandle = bindStaticMethod(
|
|
414
|
-
'Microsoft.AspNetCore.Components.WebAssembly',
|
|
415
|
-
'Microsoft.AspNetCore.Components.WebAssembly.Services.DefaultWebAssemblyJSRuntime',
|
|
416
|
-
'EndInvokeJS',
|
|
417
|
-
);
|
|
418
|
-
|
|
419
|
-
DotNet.attachDispatcher({
|
|
420
|
-
beginInvokeDotNetFromJS: (
|
|
421
|
-
callId: number,
|
|
422
|
-
assemblyName: string | null,
|
|
423
|
-
methodIdentifier: string,
|
|
424
|
-
dotNetObjectId: any | null,
|
|
425
|
-
argsJson: string,
|
|
426
|
-
): void => {
|
|
427
|
-
if (!dotNetObjectId && !assemblyName) {
|
|
428
|
-
throw new Error('Either assemblyName or dotNetObjectId must have a non null value.');
|
|
429
|
-
}
|
|
430
|
-
// As a current limitation, we can only pass 4 args. Fortunately we only need one of
|
|
431
|
-
// 'assemblyName' or 'dotNetObjectId', so overload them in a single slot
|
|
432
|
-
const assemblyNameOrDotNetObjectId: string = dotNetObjectId ? dotNetObjectId.toString() : assemblyName;
|
|
433
|
-
|
|
434
|
-
dotNetDispatcherBeginInvokeMethodHandle(
|
|
435
|
-
callId ? callId.toString() : null,
|
|
436
|
-
assemblyNameOrDotNetObjectId,
|
|
437
|
-
methodIdentifier,
|
|
438
|
-
argsJson,
|
|
439
|
-
);
|
|
440
|
-
},
|
|
441
|
-
endInvokeJSFromDotNet: (asyncHandle, succeeded, serializedArgs): void => {
|
|
442
|
-
dotNetDispatcherEndInvokeJSMethodHandle(serializedArgs);
|
|
443
|
-
},
|
|
444
|
-
invokeDotNetFromJS: (assemblyName, methodIdentifier, dotNetObjectId, argsJson) => {
|
|
445
|
-
return dotNetDispatcherInvokeMethodHandle(
|
|
446
|
-
assemblyName ? assemblyName : null,
|
|
447
|
-
methodIdentifier,
|
|
448
|
-
dotNetObjectId ? dotNetObjectId.toString() : null,
|
|
449
|
-
argsJson,
|
|
450
|
-
) as string;
|
|
451
|
-
},
|
|
452
|
-
});
|
|
453
|
-
}
|
|
454
|
-
|
|
455
|
-
async function loadTimezone(timeZoneResource: LoadingResource): Promise<void> {
|
|
456
|
-
const runDependencyId = `blazor:timezonedata`;
|
|
457
|
-
addRunDependency(runDependencyId);
|
|
458
|
-
|
|
459
|
-
const request = await timeZoneResource.response;
|
|
460
|
-
const arrayBuffer = await request.arrayBuffer();
|
|
461
|
-
loadTimezoneData(arrayBuffer);
|
|
462
|
-
|
|
463
|
-
removeRunDependency(runDependencyId);
|
|
464
|
-
}
|
|
465
|
-
|
|
466
|
-
async function compileWasmModule(wasmResource: LoadingResource, imports: any): Promise<WebAssembly.Instance> {
|
|
467
|
-
// This is the same logic as used in emscripten's generated js. We can't use emscripten's js because
|
|
468
|
-
// it doesn't provide any method for supplying a custom response provider, and we want to integrate
|
|
469
|
-
// with our resource loader cache.
|
|
470
|
-
|
|
471
|
-
if (typeof WebAssembly['instantiateStreaming'] === 'function') {
|
|
472
|
-
try {
|
|
473
|
-
const streamingResult = await WebAssembly['instantiateStreaming'](wasmResource.response, imports);
|
|
474
|
-
return streamingResult.instance;
|
|
475
|
-
} catch (ex) {
|
|
476
|
-
console.info('Streaming compilation failed. Falling back to ArrayBuffer instantiation. ', ex);
|
|
477
|
-
}
|
|
478
|
-
}
|
|
479
|
-
|
|
480
|
-
// If that's not available or fails (e.g., due to incorrect content-type header),
|
|
481
|
-
// fall back to ArrayBuffer instantiation
|
|
482
|
-
const arrayBuffer = await wasmResource.response.then((r) => r.arrayBuffer());
|
|
483
|
-
const arrayBufferResult = await WebAssembly.instantiate(arrayBuffer, imports);
|
|
484
|
-
return arrayBufferResult.instance;
|
|
485
|
-
}
|
|
486
|
-
|
|
487
|
-
function changeExtension(filename: string, newExtensionWithLeadingDot: string) {
|
|
488
|
-
const lastDotIndex = filename.lastIndexOf('.');
|
|
489
|
-
if (lastDotIndex < 0) {
|
|
490
|
-
throw new Error(`No extension to replace in '${filename}'`);
|
|
491
|
-
}
|
|
492
|
-
|
|
493
|
-
return filename.substr(0, lastDotIndex) + newExtensionWithLeadingDot;
|
|
494
|
-
}
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
import { Pointer, System_String, System_Array, System_Object } from '../Platform';
|
|
2
|
-
|
|
3
|
-
// Mono uses this global to hang various debugging-related items on
|
|
4
|
-
|
|
5
|
-
declare interface MONO {
|
|
6
|
-
loaded_files: string[];
|
|
7
|
-
mono_wasm_runtime_ready(): void;
|
|
8
|
-
mono_wasm_setenv(name: string, value: string): void;
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
// Mono uses this global to hold low-level interop APIs
|
|
12
|
-
declare interface BINDING {
|
|
13
|
-
mono_obj_array_new(length: number): System_Array<System_Object>;
|
|
14
|
-
mono_obj_array_set(array: System_Array<System_Object>, index: Number, value: System_Object): void;
|
|
15
|
-
js_string_to_mono_string(jsString: string): System_String;
|
|
16
|
-
js_typed_array_to_array(array: Uint8Array): System_Object;
|
|
17
|
-
js_to_mono_obj(jsObject: any): System_Object;
|
|
18
|
-
mono_array_to_js_array<TInput, TOutput>(array: System_Array<TInput>): Array<TOutput>;
|
|
19
|
-
conv_string(dotnetString: System_String | null): string | null;
|
|
20
|
-
bind_static_method(fqn: string, signature?: string): Function;
|
|
21
|
-
unbox_mono_obj(object: System_Object): any;
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
declare global {
|
|
25
|
-
var MONO: MONO;
|
|
26
|
-
var BINDING: BINDING;
|
|
27
|
-
}
|
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
import { readInt32LE } from '../../Rendering/RenderBatch/BinaryDecoder';
|
|
2
|
-
import { decodeUtf8 } from '../../Rendering/RenderBatch/Utf8Decoder';
|
|
3
|
-
|
|
4
|
-
declare const Module: EmscriptenModule;
|
|
5
|
-
|
|
6
|
-
export function loadTimezoneData(arrayBuffer: ArrayBuffer) {
|
|
7
|
-
let remainingData = new Uint8Array(arrayBuffer);
|
|
8
|
-
|
|
9
|
-
// The timezone file is generated by https://github.com/dotnet/blazor/tree/master/src/TimeZoneData.
|
|
10
|
-
// The file format of the TZ file look like so
|
|
11
|
-
//
|
|
12
|
-
// [4 - byte length of manifest]
|
|
13
|
-
// [json manifest]
|
|
14
|
-
// [data bytes]
|
|
15
|
-
//
|
|
16
|
-
// The json manifest is an array that looks like so:
|
|
17
|
-
//
|
|
18
|
-
// [...["America/Fort_Nelson",2249],["America/Glace_Bay",2206]..]
|
|
19
|
-
//
|
|
20
|
-
// where the first token in each array is the relative path of the file on disk, and the second is the
|
|
21
|
-
// length of the file. The starting offset of a file can be calculated using the lengths of all files
|
|
22
|
-
// that appear prior to it.
|
|
23
|
-
const manifestSize = readInt32LE(remainingData, 0);
|
|
24
|
-
remainingData = remainingData.slice(4);
|
|
25
|
-
const manifestContent = decodeUtf8(remainingData.slice(0, manifestSize));
|
|
26
|
-
const manifest = JSON.parse(manifestContent) as ManifestEntry[];
|
|
27
|
-
remainingData = remainingData.slice(manifestSize);
|
|
28
|
-
|
|
29
|
-
// Create the folder structure
|
|
30
|
-
// /zoneinfo
|
|
31
|
-
// /zoneinfo/Africa
|
|
32
|
-
// /zoneinfo/Asia
|
|
33
|
-
// ..
|
|
34
|
-
Module['FS_createPath']('/', 'zoneinfo', true, true);
|
|
35
|
-
new Set(manifest.map((m) => m[0].split('/')![0])).forEach((folder) =>
|
|
36
|
-
Module['FS_createPath']('/zoneinfo', folder, true, true),
|
|
37
|
-
);
|
|
38
|
-
|
|
39
|
-
for (const [name, length] of manifest) {
|
|
40
|
-
const bytes = remainingData.slice(0, length);
|
|
41
|
-
Module['FS_createDataFile'](`/zoneinfo/${name}`, null, bytes, true, true, true);
|
|
42
|
-
remainingData = remainingData.slice(length);
|
|
43
|
-
}
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
type ManifestEntry = [string, number];
|
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
import { WebAssemblyResourceLoader } from './WebAssemblyResourceLoader';
|
|
2
|
-
|
|
3
|
-
export interface Platform {
|
|
4
|
-
start(resourceLoader: WebAssemblyResourceLoader): Promise<void>;
|
|
5
|
-
|
|
6
|
-
callEntryPoint(assemblyName: string): void;
|
|
7
|
-
|
|
8
|
-
toUint8Array(array: System_Array<any>): Uint8Array;
|
|
9
|
-
|
|
10
|
-
getArrayLength(array: System_Array<any>): number;
|
|
11
|
-
getArrayEntryPtr<TPtr extends Pointer>(array: System_Array<TPtr>, index: number, itemSize: number): TPtr;
|
|
12
|
-
|
|
13
|
-
getObjectFieldsBaseAddress(referenceTypedObject: System_Object): Pointer;
|
|
14
|
-
readInt16Field(baseAddress: Pointer, fieldOffset?: number): number;
|
|
15
|
-
readInt32Field(baseAddress: Pointer, fieldOffset?: number): number;
|
|
16
|
-
readUint64Field(baseAddress: Pointer, fieldOffset?: number): number;
|
|
17
|
-
readFloatField(baseAddress: Pointer, fieldOffset?: number): number;
|
|
18
|
-
readObjectField<T extends System_Object>(baseAddress: Pointer, fieldOffset?: number): T;
|
|
19
|
-
readStringField(baseAddress: Pointer, fieldOffset?: number, readBoolValueAsString?: boolean): string | null;
|
|
20
|
-
readStructField<T extends Pointer>(baseAddress: Pointer, fieldOffset?: number): T;
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
// We don't actually instantiate any of these at runtime. For perf it's preferable to
|
|
24
|
-
// use the original 'number' instances without any boxing. The definitions are just
|
|
25
|
-
// for compile-time checking, since TypeScript doesn't support nominal types.
|
|
26
|
-
export interface MethodHandle {
|
|
27
|
-
MethodHandle__DO_NOT_IMPLEMENT: any;
|
|
28
|
-
}
|
|
29
|
-
export interface System_Object {
|
|
30
|
-
System_Object__DO_NOT_IMPLEMENT: any;
|
|
31
|
-
}
|
|
32
|
-
export interface System_String extends System_Object {
|
|
33
|
-
System_String__DO_NOT_IMPLEMENT: any;
|
|
34
|
-
}
|
|
35
|
-
export interface System_Array<T> extends System_Object {
|
|
36
|
-
System_Array__DO_NOT_IMPLEMENT: any;
|
|
37
|
-
}
|
|
38
|
-
export interface Pointer {
|
|
39
|
-
Pointer__DO_NOT_IMPLEMENT: any;
|
|
40
|
-
}
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
export function getFileNameFromUrl(url: string) {
|
|
2
|
-
// This could also be called "get last path segment from URL", but the primary
|
|
3
|
-
// use case is to extract things that look like filenames
|
|
4
|
-
const lastSegment = url.substring(url.lastIndexOf('/') + 1);
|
|
5
|
-
const queryStringStartPos = lastSegment.indexOf('?');
|
|
6
|
-
return queryStringStartPos < 0 ? lastSegment : lastSegment.substring(0, queryStringStartPos);
|
|
7
|
-
}
|
|
8
|
-
|
|
9
|
-
export function getAssemblyNameFromUrl(url: string) {
|
|
10
|
-
return getFileNameFromUrl(url).replace(/\.dll$/, '');
|
|
11
|
-
}
|
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
import { BootConfigResult } from './BootConfig';
|
|
2
|
-
import { System_String, System_Object } from './Platform';
|
|
3
|
-
|
|
4
|
-
export class WebAssemblyConfigLoader {
|
|
5
|
-
static async initAsync(bootConfigResult: BootConfigResult): Promise<void> {
|
|
6
|
-
window['Blazor']._internal.getApplicationEnvironment = () =>
|
|
7
|
-
BINDING.js_string_to_mono_string(bootConfigResult.applicationEnvironment);
|
|
8
|
-
|
|
9
|
-
const configFiles = await Promise.all(
|
|
10
|
-
(bootConfigResult.bootConfig.config || [])
|
|
11
|
-
.filter(
|
|
12
|
-
(name) =>
|
|
13
|
-
name === 'appsettings.json' || name === `appsettings.${bootConfigResult.applicationEnvironment}.json`,
|
|
14
|
-
)
|
|
15
|
-
.map(async (name) => ({ name, content: await getConfigBytes(name) })),
|
|
16
|
-
);
|
|
17
|
-
|
|
18
|
-
window['Blazor']._internal.getConfig = (dotNetFileName: System_String): System_Object | undefined => {
|
|
19
|
-
const fileName = BINDING.conv_string(dotNetFileName);
|
|
20
|
-
const resolvedFile = configFiles.find((f) => f.name === fileName);
|
|
21
|
-
return resolvedFile ? BINDING.js_typed_array_to_array(resolvedFile.content) : undefined;
|
|
22
|
-
};
|
|
23
|
-
|
|
24
|
-
async function getConfigBytes(file: string): Promise<Uint8Array> {
|
|
25
|
-
const response = await fetch(file, {
|
|
26
|
-
method: 'GET',
|
|
27
|
-
credentials: 'include',
|
|
28
|
-
cache: 'no-cache',
|
|
29
|
-
});
|
|
30
|
-
|
|
31
|
-
return new Uint8Array(await response.arrayBuffer());
|
|
32
|
-
}
|
|
33
|
-
}
|
|
34
|
-
}
|