@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 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: (url: string, imports?: {}) => Promise<WasmModule>;
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 = (url, imports = {}) => __awaiter(void 0, void 0, void 0, function* () {
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
- try {
179
- return yield globalThis.WebAssembly.compileStreaming(globalThis.fetch(url));
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
- catch (_a) {
182
- return globalThis.WebAssembly.compile(yield (yield Promise.resolve().then(() => __importStar(require('node:fs/promises')))).readFile(url));
191
+ else {
192
+ return globalThis.WebAssembly.compile(input);
183
193
  }
184
194
  }))(), imports);
185
195
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@steerprotocol/app-loader",
3
- "version": "0.0.1",
3
+ "version": "0.0.3",
4
4
  "description": "App Loader for Steer Protocol",
5
5
  "main": "lib/index.js",
6
6
  "types": "lib/index.d.ts",