forked from dotnet/runtime
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathlibSystem.Native.Browser.footer.js
More file actions
53 lines (48 loc) · 2.16 KB
/
libSystem.Native.Browser.footer.js
File metadata and controls
53 lines (48 loc) · 2.16 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
44
45
46
47
48
49
50
51
52
53
//! 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.
*/
/* eslint-disable no-undef */
/* eslint-disable space-before-function-paren */
(function () {
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 `reserved` there
const exports = {};
libNativeBrowser(exports);
let commonDeps = [
"$BROWSER_UTILS",
"SystemJS_ExecuteTimerCallback",
"SystemJS_ExecuteBackgroundJobCallback",
"SystemJS_ExecuteFinalizationCallback",
];
const lib = {
$DOTNET: {
selfInitialize: () => {
if (typeof dotnetInternals !== "undefined") {
DOTNET.dotnetInternals = dotnetInternals;
DOTNET.dotnetInitializeModule(dotnetInternals);
}
},
dotnetInitializeModule: exports.dotnetInitializeModule,
gitHash: exports.gitHash,
},
$DOTNET__deps: commonDeps,
$DOTNET__postset: "DOTNET.selfInitialize()",
};
for (const exportName of Reflect.ownKeys(exports)) {
const name = String(exportName);
if (name === "dotnetInitializeModule") continue;
lib[name] = exports[name];
}
autoAddDeps(lib, "$DOTNET");
addToLibrary(lib);
}
libFactory();
})();