@aresdefencelabs/wasm-http-runtime 0.2.2 → 0.2.3
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.
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
let cloudflareEnv
|
|
1
2
|
export function createWasmHttpRuntime(config) {
|
|
2
3
|
const {
|
|
3
4
|
wasmModule,
|
|
@@ -11,6 +12,7 @@ export function createWasmHttpRuntime(config) {
|
|
|
11
12
|
onError = null,
|
|
12
13
|
beforeOutboundFetch = null,
|
|
13
14
|
afterOutboundFetch = null,
|
|
15
|
+
onInitialise = null,
|
|
14
16
|
} = config ?? {};
|
|
15
17
|
|
|
16
18
|
if (!wasmModule) {
|
|
@@ -39,6 +41,7 @@ export function createWasmHttpRuntime(config) {
|
|
|
39
41
|
onError,
|
|
40
42
|
beforeOutboundFetch,
|
|
41
43
|
afterOutboundFetch,
|
|
44
|
+
onInitialise
|
|
42
45
|
},
|
|
43
46
|
};
|
|
44
47
|
|
|
@@ -572,6 +575,13 @@ export function createWasmHttpRuntime(config) {
|
|
|
572
575
|
|
|
573
576
|
const appInit = pickExport(mod, ["_app_init", "app_init"]);
|
|
574
577
|
if (appInit) {
|
|
578
|
+
if (typeof state.options.onInitialise === "function") {
|
|
579
|
+
await state.options.onInitialise({
|
|
580
|
+
state,
|
|
581
|
+
getModule: () => mod,
|
|
582
|
+
});
|
|
583
|
+
}
|
|
584
|
+
|
|
575
585
|
const rc = await Promise.resolve(appInit());
|
|
576
586
|
if (rc !== 0) {
|
|
577
587
|
throw new Error(`WASM app_init failed rc=${rc}`);
|
package/package.json
CHANGED