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