@steerprotocol/app-loader 1.0.1 → 1.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.
Files changed (3) hide show
  1. package/lib/index.d.ts +3 -3
  2. package/lib/index.js +183 -275
  3. package/package.json +14 -13
package/lib/index.d.ts CHANGED
@@ -1,6 +1,6 @@
1
- import { Candle } from './Candle';
2
- import { RawTradeData } from './RawTradeData';
3
- import { WasmModule } from './WasmModule';
1
+ import { Candle } from "./Candle";
2
+ import { RawTradeData } from "./RawTradeData";
3
+ import { WasmModule } from "./WasmModule";
4
4
  export { Candle, RawTradeData, WasmModule };
5
5
  /**
6
6
  * Load a wasm bundle synchronously. Only accepts the actual binary data.
package/lib/index.js CHANGED
@@ -31,36 +31,24 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
31
31
  step((generator = generator.apply(thisArg, _arguments || [])).next());
32
32
  });
33
33
  };
34
- var __importDefault = (this && this.__importDefault) || function (mod) {
35
- return (mod && mod.__esModule) ? mod : { "default": mod };
36
- };
37
34
  Object.defineProperty(exports, "__esModule", { value: true });
38
35
  exports.loadWasm = exports.loadWasmSync = exports.RawTradeData = exports.Candle = void 0;
39
- /* eslint-disable @typescript-eslint/ban-ts-comment */
40
- const ccxt_1 = __importDefault(require("ccxt"));
41
36
  const Candle_1 = require("./Candle");
42
37
  Object.defineProperty(exports, "Candle", { enumerable: true, get: function () { return Candle_1.Candle; } });
43
38
  const RawTradeData_1 = require("./RawTradeData");
44
39
  Object.defineProperty(exports, "RawTradeData", { enumerable: true, get: function () { return RawTradeData_1.RawTradeData; } });
45
- const ARRAYBUFFER_ID = 1;
46
- const STRING_ID = 2;
47
- // Globals
48
- let WASM_MEMORY;
49
- let WASM_EXPORTS;
50
- let WASM_DV;
51
- // Constants required by Asyncify
52
- let ASYNCIFY_PTR = 0;
53
- let ASYNCIFY_MEM;
54
- let ASYNCIFY_INITIALIZED = false;
55
- let fetchFn = null;
56
- let ccxtFn = null;
40
+ let isNode = process || null;
41
+ let fetchImpl = null;
42
+ let fsImpl = null;
43
+ let ccxt = null;
44
+ if (globalThis["fetch"])
45
+ fetchImpl = fetch;
57
46
  var State;
58
47
  (function (State) {
59
48
  State[State["None"] = 0] = "None";
60
49
  State[State["Unwinding"] = 1] = "Unwinding";
61
50
  State[State["Rewinding"] = 2] = "Rewinding";
62
51
  })(State || (State = {}));
63
- let detachedValue = null;
64
52
  /**
65
53
  * Load a wasm bundle synchronously. Only accepts the actual binary data.
66
54
  * @param input - Wasm bundle data
@@ -80,13 +68,17 @@ exports.loadWasmSync = loadWasmSync;
80
68
  function loadWasm(input, imports = {}) {
81
69
  return __awaiter(this, void 0, void 0, function* () {
82
70
  const mod = instantiate(yield (() => __awaiter(this, void 0, void 0, function* () {
83
- if (typeof input === 'string') {
84
- try {
85
- return yield WebAssembly.compileStreaming(fetch(input));
86
- }
87
- catch (_a) {
88
- return WebAssembly.compile(yield (yield Promise.resolve().then(() => __importStar(require('fs/promises')))).readFile(input));
71
+ if (typeof input === "string") {
72
+ if (isNode) {
73
+ if (!fetchImpl)
74
+ fetchImpl = (yield Promise.resolve().then(() => __importStar(require("undici")))).fetch;
75
+ if (!fsImpl)
76
+ fsImpl = yield Promise.resolve().then(() => __importStar(require("fs/promises")));
77
+ if (!ccxt)
78
+ ccxt = (yield Promise.resolve().then(() => __importStar(require("ccxt")))).default;
79
+ return WebAssembly.compile(yield fsImpl.readFile(input));
89
80
  }
81
+ return yield WebAssembly.compileStreaming(globalThis.fetch(input));
90
82
  }
91
83
  else {
92
84
  return WebAssembly.compile(input);
@@ -97,6 +89,15 @@ function loadWasm(input, imports = {}) {
97
89
  }
98
90
  exports.loadWasm = loadWasm;
99
91
  function instantiate(module, imports = {}) {
92
+ let WASM_MEMORY;
93
+ let WASM_EXPORTS;
94
+ let WASM_DV;
95
+ let ASYNCIFY_PTR = 0;
96
+ let ASYNCIFY_MEM;
97
+ let ASYNCIFY_INITIALIZED = false;
98
+ let fetchFn = null;
99
+ let ccxtFn = null;
100
+ let detachedValue = null;
100
101
  const adaptedImports = Object.assign({
101
102
  console: {
102
103
  log(text) {
@@ -112,8 +113,8 @@ function instantiate(module, imports = {}) {
112
113
  },
113
114
  _initAsyncify(frame_ptr, stack_ptr) {
114
115
  // @ts-ignore
115
- if (!WASM_EXPORTS['asyncify_get_state'])
116
- throw new Error('Asyncify initialized, but not enabled when run! Compile with the --runPasses asyncify flag or asyncify-shim transform!');
116
+ if (!WASM_EXPORTS["asyncify_get_state"])
117
+ throw new Error("Asyncify initialized, but not enabled when run! Compile with the --runPasses asyncify flag or asyncify-shim transform!");
117
118
  if (ASYNCIFY_INITIALIZED)
118
119
  return;
119
120
  ASYNCIFY_PTR = frame_ptr;
@@ -122,12 +123,12 @@ function instantiate(module, imports = {}) {
122
123
  ASYNCIFY_INITIALIZED = true;
123
124
  },
124
125
  generateCandles(data, candleSize) {
125
- const _data = __liftString(data) || '[]';
126
- const _candleSize = __liftString(candleSize) || '69m';
126
+ const _data = __liftString(data) || "[]";
127
+ const _candleSize = __liftString(candleSize) || "69m";
127
128
  const candles = (0, Candle_1.generateCandles)(JSON.parse(_data), _candleSize);
128
129
  return __lowerString(JSON.stringify(candles));
129
130
  },
130
- 'console.log': (text) => {
131
+ "console.log": (text) => {
131
132
  console.log(__liftString(text));
132
133
  },
133
134
  ccxt_fetchOHLCV: (exchangeId, symbol, timeframe, limit, since) => {
@@ -147,11 +148,11 @@ function instantiate(module, imports = {}) {
147
148
  const _timeframe = __liftString(timeframe);
148
149
  ccxtFn = (() => __awaiter(this, void 0, void 0, function* () {
149
150
  if (!_exchange || !_symbol || !_timeframe)
150
- throw new Error('Exchange, Symbol, or Timeframe not provided when fetching OHCLV data.');
151
+ throw new Error("Exchange, Symbol, or Timeframe not provided when fetching OHCLV data.");
151
152
  // @ts-ignore
152
- const data = yield new ccxt_1.default[_exchange]({
153
- apiKey: '',
154
- secret: '',
153
+ const data = yield new ccxt[_exchange]({
154
+ apiKey: "",
155
+ secret: "",
155
156
  }).fetchOHLCV(_symbol, _timeframe, since, limit);
156
157
  return data;
157
158
  }));
@@ -159,16 +160,16 @@ function instantiate(module, imports = {}) {
159
160
  WASM_EXPORTS.asyncify_start_unwind(ASYNCIFY_PTR);
160
161
  }
161
162
  },
162
- 'as-fetch': {
163
+ "as-fetch": {
163
164
  _initAsyncify(frame_ptr, stack_ptr) {
164
165
  // @ts-ignore
165
- if (!WASM_EXPORTS['asyncify_get_state'])
166
- throw new Error('Asyncify initialized, but not enabled when run! Compile with the --runPasses asyncify flag or asyncify-shim transform!');
166
+ if (!WASM_EXPORTS["asyncify_get_state"])
167
+ throw new Error("Asyncify initialized, but not enabled when run! Compile with the --runPasses asyncify flag or asyncify-shim transform!");
167
168
  if (ASYNCIFY_INITIALIZED)
168
169
  return;
169
170
  ASYNCIFY_PTR = frame_ptr;
170
171
  ASYNCIFY_MEM[ASYNCIFY_PTR >> 2] = ASYNCIFY_PTR + 8;
171
- // I don't know if I need to reserve all this memory...
172
+ // I don"t know if I need to reserve all this memory...
172
173
  ASYNCIFY_MEM[(ASYNCIFY_PTR + 4) >> 2] = stack_ptr;
173
174
  ASYNCIFY_INITIALIZED = true;
174
175
  },
@@ -183,9 +184,9 @@ function instantiate(module, imports = {}) {
183
184
  return ptr;
184
185
  }
185
186
  fetchFn = (() => __awaiter(this, void 0, void 0, function* () {
186
- const res = yield fetch(__liftString(url) || '', {
187
- method: 'POST',
188
- mode: modeToString(mode) || 'cors',
187
+ const res = yield fetchImpl(__liftString(url) || "", {
188
+ method: "POST",
189
+ mode: modeToString(mode) || "cors",
189
190
  headers: __liftArray((pointer) => __liftArray((pointer) => __liftString(__getU32(pointer)), 2, __getU32(pointer)), 2, headers) || [],
190
191
  body: __liftBuffer(body)
191
192
  });
@@ -206,9 +207,9 @@ function instantiate(module, imports = {}) {
206
207
  return ptr;
207
208
  }
208
209
  fetchFn = (() => __awaiter(this, void 0, void 0, function* () {
209
- const res = yield fetch(__liftString(url) || '', {
210
- method: 'GET',
211
- mode: modeToString(mode) || 'cors',
210
+ const res = yield fetchImpl(__liftString(url) || "", {
211
+ method: "GET",
212
+ mode: modeToString(mode) || "cors",
212
213
  headers: __liftArray((pointer) => __liftArray((pointer) => __liftString(__getU32(pointer)), 2, __getU32(pointer)), 2, headers) || [],
213
214
  });
214
215
  const value = yield res.arrayBuffer();
@@ -218,9 +219,9 @@ function instantiate(module, imports = {}) {
218
219
  WASM_EXPORTS.asyncify_start_unwind(ASYNCIFY_PTR);
219
220
  },
220
221
  _fetchGET(url, mode, headers, callbackID) {
221
- fetch(__liftString(url) || '', {
222
- method: 'GET',
223
- mode: modeToString(mode) || 'cors',
222
+ fetchImpl(__liftString(url) || "", {
223
+ method: "GET",
224
+ mode: modeToString(mode) || "cors",
224
225
  headers: __liftArray((pointer) => __liftArray((pointer) => __liftString(__getU32(pointer)), 2, __getU32(pointer)), 2, headers) || [],
225
226
  }).then((res) => __awaiter(this, void 0, void 0, function* () {
226
227
  const body = yield res.arrayBuffer();
@@ -228,9 +229,9 @@ function instantiate(module, imports = {}) {
228
229
  }));
229
230
  },
230
231
  _fetchPOST(url, mode, headers, body, callbackID) {
231
- fetch(__liftString(url) || '', {
232
- method: 'POST',
233
- mode: modeToString(mode) || 'cors',
232
+ fetchImpl(__liftString(url) || "", {
233
+ method: "POST",
234
+ mode: modeToString(mode) || "cors",
234
235
  body: body,
235
236
  headers: __liftArray((pointer) => __liftArray((pointer) => __liftString(__getU32(pointer)), 2, __getU32(pointer)), 2, headers) || [],
236
237
  }).then((res) => __awaiter(this, void 0, void 0, function* () {
@@ -247,272 +248,179 @@ function instantiate(module, imports = {}) {
247
248
  ASYNCIFY_MEM = new Uint32Array(WASM_MEMORY.buffer);
248
249
  const handledExports = Object.setPrototypeOf({
249
250
  responseHandler(body, statusCode, redirected, callbackID) {
250
- try {
251
- // @ts-ignore
252
- WASM_EXPORTS.responseHandler(__lowerBuffer(body), statusCode, redirected ? 1 : 0, callbackID);
253
- }
254
- catch (e) {
255
- console.error(e);
256
- throw new Error('Unable to call .responseHandler on wasm module. Add the line export { responseHandler } from "as-fetch/assembly" to your entry file.');
257
- }
251
+ if (!WASM_EXPORTS["responseHandler"])
252
+ throw new Error("Unable to call .responseHandler on wasm module. Add the line export { responseHandler } from \"as-fetch/assembly\" to your entry file.");
253
+ // @ts-ignore
254
+ WASM_EXPORTS.responseHandler(__lowerBuffer(body), statusCode, redirected ? 1 : 0, callbackID);
258
255
  },
259
256
  initialize(config) {
257
+ if (!WASM_EXPORTS["initialize"])
258
+ throw new Error("Unable to call .initialize on wasm module. Are you sure this is a data connector?");
260
259
  try {
261
260
  // @ts-ignore
262
- WASM_EXPORTS.initialize(__lowerStringRetained(config));
261
+ WASM_EXPORTS.initialize(__lowerString(config));
262
+ return true;
263
263
  }
264
264
  catch (e) {
265
265
  console.error(e);
266
- throw new Error('Unable to call .initialize on wasm module. Are you sure this is a data connector?');
266
+ return false;
267
267
  }
268
268
  },
269
269
  execute(...params) {
270
270
  return __awaiter(this, void 0, void 0, function* () {
271
- try {
272
- const loweredArgs = new Array(params.length);
273
- for (let i = 0; i < params.length; i++) {
274
- loweredArgs[i] = __lowerRetained(params[i]);
275
- }
276
- /*for (let i = 0; i < loweredArgs.length; i++) {
277
- if (typeof params[i] !== 'number') __release(loweredArgs[i]);
278
- }*/
279
- let result = WASM_EXPORTS.execute(...loweredArgs);
280
- if (ASYNCIFY_INITIALIZED) {
271
+ if (!WASM_EXPORTS["execute"])
272
+ throw new Error("Unable to call .execute on wasm module. Are you sure this is a data connector?");
273
+ const loweredArgs = new Array(params.length);
274
+ for (let i = 0; i < params.length; i++) {
275
+ loweredArgs[i] = __lower(params[i]);
276
+ }
277
+ let result = WASM_EXPORTS.execute(...loweredArgs);
278
+ if (ASYNCIFY_INITIALIZED) {
279
+ // @ts-ignore
280
+ while (WASM_EXPORTS.asyncify_get_state() === State.Unwinding) {
281
281
  // @ts-ignore
282
- while (WASM_EXPORTS.asyncify_get_state() === State.Unwinding) {
283
- // @ts-ignore
284
- WASM_EXPORTS.asyncify_stop_unwind();
285
- if (fetchFn)
286
- detachedValue = yield fetchFn();
287
- if (ccxtFn)
288
- detachedValue = yield ccxtFn();
289
- // @ts-ignore
290
- WASM_EXPORTS.asyncify_start_rewind(ASYNCIFY_PTR);
291
- result = WASM_EXPORTS.execute();
292
- }
282
+ WASM_EXPORTS.asyncify_stop_unwind();
283
+ if (fetchFn)
284
+ detachedValue = yield fetchFn();
285
+ if (ccxtFn)
286
+ detachedValue = yield ccxtFn();
287
+ // @ts-ignore
288
+ WASM_EXPORTS.asyncify_start_rewind(ASYNCIFY_PTR);
289
+ result = WASM_EXPORTS.execute();
293
290
  }
294
- if (fetchFn)
295
- fetchFn = null;
296
- if (ccxtFn)
297
- ccxtFn = null;
298
- // @ts-ignore
299
- return result ? __liftString(result) : null;
300
- }
301
- catch (e) {
302
- console.error(e);
303
- throw new Error('Unable to call .execute on wasm module. Are you sure this is a data connector?');
304
291
  }
292
+ if (fetchFn)
293
+ fetchFn = null;
294
+ if (ccxtFn)
295
+ ccxtFn = null;
296
+ // @ts-ignore
297
+ return __liftString(result);
305
298
  });
306
299
  },
307
300
  config() {
308
- try {
309
- return __liftString(WASM_EXPORTS.config());
310
- }
311
- catch (e) {
312
- console.error(e);
313
- throw new Error('Unable to call .config on wasm module. Are you sure this is a data connector?');
314
- }
301
+ if (!WASM_EXPORTS["config"])
302
+ throw new Error("Unable to call .config on wasm module. Are you sure this is a data connector?");
303
+ return __liftString(WASM_EXPORTS.config());
315
304
  },
316
305
  transform() {
317
- try {
318
- return __liftString(WASM_EXPORTS.transform());
319
- }
320
- catch (e) {
321
- console.error(e);
322
- throw new Error('Unable to call .transform on wasm module. Are you sure this is a data connector?');
323
- }
306
+ if (!WASM_EXPORTS["transform"])
307
+ throw new Error("Unable to call .transform on wasm module. Are you sure this is a data connector?");
308
+ return __liftString(WASM_EXPORTS.transform());
324
309
  },
325
310
  reset() {
326
- try {
311
+ if (WASM_EXPORTS["reset"])
327
312
  WASM_EXPORTS.reset();
328
- }
329
- catch (e) {
330
- console.log(e);
331
- }
332
313
  }
333
314
  }, WASM_EXPORTS);
334
315
  WASM_DV = new DataView(WASM_MEMORY.buffer);
335
- return handledExports;
336
- }
337
- const refcounts = new Map();
338
- function __retain(ptr) {
339
- if (ptr) {
340
- const refcount = refcounts.get(ptr);
341
- if (refcount)
342
- refcounts.set(ptr, refcount + 1);
343
- else
344
- refcounts.set(WASM_EXPORTS.__pin(ptr), 1);
345
- }
346
- return ptr;
347
- }
348
- // eslint-disable-next-line @typescript-eslint/no-explicit-any, @typescript-eslint/no-unused-vars
349
- function __release(ptr) {
350
- if (ptr) {
351
- const refcount = refcounts.get(ptr);
352
- if (refcount === 1)
353
- WASM_EXPORTS.__unpin(ptr), refcounts.delete(ptr);
354
- else if (refcount)
355
- refcounts.set(ptr, refcount - 1);
356
- else
357
- throw Error(`invalid refcount '${refcount}' for reference '${ptr}'`);
316
+ function __lower(val) {
317
+ if (typeof val === "number") {
318
+ return val;
319
+ }
320
+ else if (typeof val === "string") {
321
+ return __lowerString(val);
322
+ }
323
+ else if (val instanceof ArrayBuffer) {
324
+ return __lowerBuffer(val);
325
+ }
326
+ else {
327
+ return 0;
328
+ }
358
329
  }
359
- }
360
- function __lowerRetained(val) {
361
- if (typeof val === 'number') {
362
- return val;
330
+ function __liftString(ptr) {
331
+ if (!ptr)
332
+ return null;
333
+ const end = ptr + new Uint32Array(WASM_MEMORY.buffer)[ptr - 4 >>> 2] >>> 1;
334
+ const memoryU16 = new Uint16Array(WASM_MEMORY.buffer);
335
+ let start = ptr >>> 1;
336
+ let string = "";
337
+ while (end - start > 1024)
338
+ string += String.fromCharCode(...memoryU16.subarray(start, start += 1024));
339
+ return string + String.fromCharCode(...memoryU16.subarray(start, end));
363
340
  }
364
- else if (typeof val === 'string') {
365
- return __lowerStringRetained(val);
341
+ function __lowerString(value) {
342
+ if (value == null)
343
+ return 0;
344
+ const length = value.length;
345
+ const ptr = WASM_EXPORTS.__pin(WASM_EXPORTS.__new(length << 1, 2) >>> 0);
346
+ const memoryU16 = new Uint16Array(WASM_MEMORY.buffer);
347
+ for (let i = 0; i < length; ++i)
348
+ memoryU16[(ptr >>> 1) + i] = value.charCodeAt(i);
349
+ return ptr;
366
350
  }
367
- else if (val instanceof ArrayBuffer) {
368
- return __lowerBufferRetained(val);
351
+ function __liftBuffer(ptr) {
352
+ if (!ptr)
353
+ return null;
354
+ return WASM_MEMORY.buffer.slice(ptr, ptr + new Uint32Array(WASM_MEMORY.buffer)[ptr - 4 >>> 2]);
369
355
  }
370
- else {
371
- return 0;
356
+ function __lowerBuffer(value) {
357
+ if (value == null)
358
+ return 0;
359
+ const ptr = WASM_EXPORTS.__pin(WASM_EXPORTS.__new(value.byteLength, 1) >>> 0);
360
+ new Uint8Array(WASM_MEMORY.buffer).set(new Uint8Array(value), ptr);
361
+ return ptr;
372
362
  }
373
- }
374
- function __liftString(ptr) {
375
- if (!ptr)
376
- return null;
377
- const end = (ptr + new Uint32Array(WASM_MEMORY.buffer)[(ptr - 4) >>> 2]) >>> 1;
378
- const memoryU16 = new Uint16Array(WASM_MEMORY.buffer);
379
- let start = ptr >>> 1;
380
- let str = '';
381
- while (end - start > 1024)
382
- str += String.fromCharCode(...memoryU16.subarray(start, (start += 1024)));
383
- return str + String.fromCharCode(...memoryU16.subarray(start, end));
384
- }
385
- function __lowerString(str) {
386
- if (str === null)
387
- return 0;
388
- const length = str.length;
389
- // @ts-ignore
390
- const ptr = WASM_EXPORTS.__new(length << 1, STRING_ID);
391
- __retain(ptr);
392
- const memoryU16 = new Uint16Array(WASM_MEMORY.buffer);
393
- for (let i = 0; i < length; ++i)
394
- memoryU16[(ptr >>> 1) + i] = str.charCodeAt(i);
395
- return ptr;
396
- }
397
- function __lowerStringRetained(str) {
398
- if (str === null)
399
- return 0;
400
- const length = str.length;
401
- // @ts-ignore
402
- const ptr = WASM_EXPORTS.__new(length << 1, STRING_ID);
403
- __retain(ptr);
404
- const memoryU16 = new Uint16Array(WASM_MEMORY.buffer);
405
- for (let i = 0; i < length; ++i)
406
- memoryU16[(ptr >>> 1) + i] = str.charCodeAt(i);
407
- return ptr;
408
- }
409
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
410
- function __liftArray(liftElement, align, ptr) {
411
- if (!ptr)
412
- return null;
413
- let dataStart;
414
- try {
415
- dataStart = WASM_DV.getUint32(ptr + 4, true);
363
+ function __liftArray(liftElement, align, ptr) {
364
+ if (!ptr)
365
+ return null;
366
+ const dataStart = __getU32(ptr + 4);
367
+ const length = WASM_DV.getUint32(ptr + 12, true);
368
+ const values = new Array(length);
369
+ for (let i = 0; i < length; ++i)
370
+ values[i] = liftElement(dataStart + (i << align >>> 0));
371
+ return values;
416
372
  }
417
- catch (_a) {
418
- WASM_DV = new DataView(WASM_MEMORY.buffer);
419
- dataStart = WASM_DV.getUint32(ptr + 4, true);
420
- }
421
- const length = WASM_DV.getUint32(ptr + 12, true);
422
- const values = new Array(length);
423
- for (let i = 0; i < length; ++i)
424
- values[i] = liftElement(dataStart + ((i << align) >>> 0));
425
- return values;
426
- }
427
- // eslint-disable-next-line @typescript-eslint/no-explicit-any, @typescript-eslint/no-unused-vars
428
- function __lowerArray(lowerElement, id, align, values) {
429
- if (values == null)
430
- return 0;
431
- const length = values.length;
432
- const buffer = WASM_EXPORTS.__pin(WASM_EXPORTS.__new(length << align, 1)) >>> 0;
433
- const header = WASM_EXPORTS.__pin(WASM_EXPORTS.__new(16, id)) >>> 0;
434
- WASM_DV.setUint32(header, buffer, true);
435
- WASM_DV.setUint32(header + 4, buffer, true);
436
- WASM_DV.setUint32(header + 8, length << align, true);
437
- WASM_DV.setUint32(header + 12, length, true);
438
- for (let i = 0; i < length; ++i)
439
- lowerElement(buffer + ((i << align) >>> 0), values[i]);
440
- WASM_EXPORTS.__unpin(buffer);
441
- WASM_EXPORTS.__unpin(header);
442
- return header;
443
- }
444
- function __liftBuffer(ptr) {
445
- if (!ptr)
446
- return null;
447
- const len = new Uint32Array(WASM_MEMORY.buffer)[(ptr - 4) >>> 2];
448
- return WASM_MEMORY.buffer.slice(ptr, ptr + len);
449
- }
450
- function __lowerBuffer(buf) {
451
- if (buf == null)
452
- return 0;
453
- const ptr = WASM_EXPORTS.__new(buf.byteLength, ARRAYBUFFER_ID) >>> 0;
454
- new Uint8Array(WASM_MEMORY.buffer).set(new Uint8Array(buf), ptr);
455
- return ptr;
456
- }
457
- function __lowerBufferRetained(buf) {
458
- if (buf == null)
459
- return 0;
460
- const ptr = WASM_EXPORTS.__new(buf.byteLength, ARRAYBUFFER_ID) >>> 0;
461
- __retain(ptr);
462
- new Uint8Array(WASM_MEMORY.buffer).set(new Uint8Array(buf), ptr);
463
- return ptr;
464
- }
465
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
466
- function __lowerStaticArray(lowerElement, id, align, values, typedConstructor) {
467
- if (values == null)
468
- return 0;
469
- const length = values.length;
470
- const ptr = WASM_EXPORTS.__pin(WASM_EXPORTS.__new(length << align, id)) >>> 0;
471
- if (typedConstructor) {
472
- new typedConstructor(WASM_EXPORTS.memory.buffer, ptr, length).set(values);
473
- }
474
- else {
475
- for (let i = 0; i < length; i++)
476
- lowerElement(ptr + ((i << align) >>> 0), values[i]);
477
- }
478
- WASM_EXPORTS.__unpin(ptr);
479
- return ptr;
480
- }
481
- function __setF64(ptr, val) {
482
- try {
483
- WASM_DV.setFloat64(ptr, val, true);
484
- }
485
- catch (_a) {
486
- WASM_DV = new DataView(WASM_MEMORY.buffer);
487
- WASM_DV.setFloat64(ptr, val, true);
488
- }
489
- }
490
- function __getU32(ptr) {
491
- try {
492
- return WASM_DV.getUint32(ptr, true);
373
+ function __lowerStaticArray(lowerElement, id, align, values, typedConstructor = null) {
374
+ if (values == null)
375
+ return 0;
376
+ const length = values.length;
377
+ const buffer = WASM_EXPORTS.__pin(WASM_EXPORTS.__new(length << align, id)) >>> 0;
378
+ if (typedConstructor) {
379
+ new typedConstructor(WASM_MEMORY.buffer, buffer, length).set(values);
380
+ }
381
+ else {
382
+ for (let i = 0; i < length; i++)
383
+ lowerElement(buffer + (i << align >>> 0), values[i]);
384
+ }
385
+ return buffer;
493
386
  }
494
- catch (_a) {
495
- WASM_DV = new DataView(WASM_MEMORY.buffer);
496
- return WASM_DV.getUint32(ptr, true);
387
+ function __setU32(ptr, value) {
388
+ try {
389
+ WASM_DV.setUint32(ptr, value, true);
390
+ }
391
+ catch (_a) {
392
+ WASM_DV = new DataView(WASM_MEMORY.buffer);
393
+ WASM_DV.setUint32(ptr, value, true);
394
+ }
497
395
  }
498
- }
499
- function __setU32(ptr, val) {
500
- try {
501
- WASM_DV.setUint32(ptr, val, true);
396
+ function __setF64(ptr, value) {
397
+ try {
398
+ WASM_DV.setFloat64(ptr, value, true);
399
+ }
400
+ catch (_a) {
401
+ WASM_DV = new DataView(WASM_MEMORY.buffer);
402
+ WASM_DV.setFloat64(ptr, value, true);
403
+ }
502
404
  }
503
- catch (_a) {
504
- WASM_DV = new DataView(WASM_MEMORY.buffer);
505
- WASM_DV.setUint32(ptr, val, true);
405
+ function __getU32(ptr) {
406
+ try {
407
+ return WASM_DV.getUint32(ptr, true);
408
+ }
409
+ catch (_a) {
410
+ WASM_DV = new DataView(WASM_MEMORY.buffer);
411
+ return WASM_DV.getUint32(ptr, true);
412
+ }
506
413
  }
414
+ return handledExports;
507
415
  }
508
416
  function modeToString(mode) {
509
417
  if (mode == 1)
510
- return 'cors';
418
+ return "cors";
511
419
  if (mode == 2)
512
- return 'no-cors';
420
+ return "no-cors";
513
421
  if (mode == 3)
514
- return 'same-origin';
422
+ return "same-origin";
515
423
  if (mode == 4)
516
- return 'navigate';
424
+ return "navigate";
517
425
  return null;
518
426
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@steerprotocol/app-loader",
3
- "version": "1.0.1",
3
+ "version": "1.0.3",
4
4
  "description": "App Loader for Steer Protocol",
5
5
  "main": "lib/index.js",
6
6
  "types": "lib/index.d.ts",
@@ -31,22 +31,23 @@
31
31
  },
32
32
  "homepage": "https://github.com/hebertcisco/ts-npm-package-boilerplate#readme",
33
33
  "devDependencies": {
34
- "@types/jest": "29.2.4",
35
- "@types/timestring": "^6.0.2",
36
- "@typescript-eslint/eslint-plugin": "5.46.0",
37
- "@typescript-eslint/parser": "5.47.1",
38
- "eslint": "8.30.0",
39
- "eslint-plugin-jest": "27.1.7",
40
- "jest": "29.3.1",
41
- "prettier": "2.8.1",
42
- "ts-jest": "29.0.3",
43
- "typescript": "4.9.4"
34
+ "@types/jest": "29.5.6",
35
+ "@types/timestring": "^6.0.4",
36
+ "@typescript-eslint/eslint-plugin": "6.8.0",
37
+ "@typescript-eslint/parser": "6.8.0",
38
+ "eslint": "8.51.0",
39
+ "eslint-plugin-jest": "27.4.2",
40
+ "jest": "29.7.0",
41
+ "prettier": "3.0.3",
42
+ "ts-jest": "29.1.1",
43
+ "typescript": "5.2.2"
44
44
  },
45
45
  "files": [
46
46
  "lib/**/*"
47
47
  ],
48
48
  "dependencies": {
49
- "ccxt": "^4.0.52",
50
- "timestring": "^7.0.0"
49
+ "ccxt": "^4.1.19",
50
+ "timestring": "^7.0.0",
51
+ "undici": "^5.26.4"
51
52
  }
52
53
  }