@steerprotocol/app-loader 0.0.1 → 0.0.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.
- package/lib/index.d.ts +1 -1
- package/lib/index.js +15 -5
- package/package.json +1 -1
package/lib/index.d.ts
CHANGED
|
@@ -26,5 +26,5 @@ export type WasmModule = {
|
|
|
26
26
|
version: typeof version;
|
|
27
27
|
memory: WebAssembly.Memory;
|
|
28
28
|
};
|
|
29
|
-
export declare const loadWasm: (
|
|
29
|
+
export declare const loadWasm: (input: string | ArrayBuffer, imports?: {}) => Promise<WasmModule>;
|
|
30
30
|
export {};
|
package/lib/index.js
CHANGED
|
@@ -51,6 +51,11 @@ function instantiate(module, imports = {}) {
|
|
|
51
51
|
})();
|
|
52
52
|
},
|
|
53
53
|
}),
|
|
54
|
+
console: {
|
|
55
|
+
log: (msg) => {
|
|
56
|
+
console.log(msg);
|
|
57
|
+
},
|
|
58
|
+
}
|
|
54
59
|
};
|
|
55
60
|
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
56
61
|
// @ts-ignore
|
|
@@ -173,13 +178,18 @@ function instantiate(module, imports = {}) {
|
|
|
173
178
|
return adaptedExports;
|
|
174
179
|
});
|
|
175
180
|
}
|
|
176
|
-
const loadWasm = (
|
|
181
|
+
const loadWasm = (input, imports = {}) => __awaiter(void 0, void 0, void 0, function* () {
|
|
177
182
|
return instantiate(yield (() => __awaiter(void 0, void 0, void 0, function* () {
|
|
178
|
-
|
|
179
|
-
|
|
183
|
+
if (typeof input === 'string') {
|
|
184
|
+
try {
|
|
185
|
+
return yield globalThis.WebAssembly.compileStreaming(globalThis.fetch(input));
|
|
186
|
+
}
|
|
187
|
+
catch (_a) {
|
|
188
|
+
return globalThis.WebAssembly.compile(yield (yield Promise.resolve().then(() => __importStar(require('node:fs/promises')))).readFile(input));
|
|
189
|
+
}
|
|
180
190
|
}
|
|
181
|
-
|
|
182
|
-
return globalThis.WebAssembly.compile(
|
|
191
|
+
else {
|
|
192
|
+
return globalThis.WebAssembly.compile(input);
|
|
183
193
|
}
|
|
184
194
|
}))(), imports);
|
|
185
195
|
});
|