forked from dotnet/runtime
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathindex.ts
More file actions
43 lines (37 loc) · 1.86 KB
/
Copy pathindex.ts
File metadata and controls
43 lines (37 loc) · 1.86 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
// 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, BrowserHostExportsTable } from "./types";
import { InternalExchangeIndex } from "./types";
import { } from "./cross-linked"; // ensure ambient symbols are declared
import GitHash from "consts:gitHash";
import { runMain, runMainAndExit, registerDllBytes, installVfsFile, loadIcuData, initializeCoreCLR } from "./host";
export function dotnetInitializeModule(internals: InternalExchange): void {
if (!Array.isArray(internals)) throw new Error("Expected internals to be an array");
const runtimeApiLocal: Partial<RuntimeAPI> = {
runMain,
runMainAndExit,
};
const runtimeApi = internals[InternalExchangeIndex.RuntimeAPI];
if (typeof runtimeApi !== "object") throw new Error("Expected internals to have RuntimeAPI");
Object.assign(runtimeApi, runtimeApiLocal);
if (runtimeApi.runtimeBuildInfo.gitHash && runtimeApi.runtimeBuildInfo.gitHash !== GitHash) {
throw new Error(`Mismatched git hashes between loader and runtime. Loader: ${runtimeApi.runtimeBuildInfo.gitHash}, BrowserHost: ${GitHash}`);
}
internals[InternalExchangeIndex.BrowserHostExportsTable] = browserHostExportsToTable({
registerDllBytes,
installVfsFile,
loadIcuData,
initializeCoreCLR,
});
dotnetUpdateInternals(internals, dotnetUpdateInternalsSubscriber);
function browserHostExportsToTable(map: BrowserHostExports): BrowserHostExportsTable {
// keep in sync with browserHostExportsFromTable()
return [
map.registerDllBytes,
map.installVfsFile,
map.loadIcuData,
map.initializeCoreCLR,
];
}
}
export { BrowserHost_ExternalAssemblyProbe } from "./host";