@steerprotocol/app-loader 0.0.2 → 0.0.4

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
@@ -19,12 +19,14 @@ declare function config(): string;
19
19
  * @returns `i32`
20
20
  */
21
21
  declare function version(): number;
22
+ export declare function transform(): string;
22
23
  export type WasmModule = {
23
24
  initialize: typeof initialize;
24
25
  execute: typeof execute;
25
26
  config: typeof config;
26
27
  version: typeof version;
28
+ transform: typeof transform;
27
29
  memory: WebAssembly.Memory;
28
30
  };
29
- export declare const loadWasm: (url: string, imports?: {}) => Promise<WasmModule>;
31
+ export declare const loadWasm: (input: string | ArrayBuffer, imports?: {}) => Promise<WasmModule>;
30
32
  export {};
package/lib/index.js CHANGED
@@ -78,6 +78,15 @@ function instantiate(module, imports = {}) {
78
78
  // assembly/index/config() => ~lib/string/String
79
79
  return __liftString(exports.config() >>> 0);
80
80
  },
81
+ transform() {
82
+ try {
83
+ // assembly/index/transform() => ~lib/string/String
84
+ return __liftString(exports.transform() >>> 0);
85
+ }
86
+ catch (e) {
87
+ throw new Error('Unable to call .transform on wasm module. Are you sure this is a data connector?');
88
+ }
89
+ },
81
90
  }, exports);
82
91
  function __liftString(pointer) {
83
92
  if (!pointer)
@@ -178,13 +187,18 @@ function instantiate(module, imports = {}) {
178
187
  return adaptedExports;
179
188
  });
180
189
  }
181
- const loadWasm = (url, imports = {}) => __awaiter(void 0, void 0, void 0, function* () {
190
+ const loadWasm = (input, imports = {}) => __awaiter(void 0, void 0, void 0, function* () {
182
191
  return instantiate(yield (() => __awaiter(void 0, void 0, void 0, function* () {
183
- try {
184
- return yield globalThis.WebAssembly.compileStreaming(globalThis.fetch(url));
192
+ if (typeof input === 'string') {
193
+ try {
194
+ return yield globalThis.WebAssembly.compileStreaming(globalThis.fetch(input));
195
+ }
196
+ catch (_a) {
197
+ return globalThis.WebAssembly.compile(yield (yield Promise.resolve().then(() => __importStar(require('node:fs/promises')))).readFile(input));
198
+ }
185
199
  }
186
- catch (_a) {
187
- return globalThis.WebAssembly.compile(yield (yield Promise.resolve().then(() => __importStar(require('node:fs/promises')))).readFile(url));
200
+ else {
201
+ return globalThis.WebAssembly.compile(input);
188
202
  }
189
203
  }))(), imports);
190
204
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@steerprotocol/app-loader",
3
- "version": "0.0.2",
3
+ "version": "0.0.4",
4
4
  "description": "App Loader for Steer Protocol",
5
5
  "main": "lib/index.js",
6
6
  "types": "lib/index.d.ts",