@steerprotocol/app-loader 0.2.2 → 1.0.0
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/Candle.d.ts +2 -0
- package/lib/Candle.js +55 -1
- package/lib/WasmModule.d.ts +22 -0
- package/lib/WasmModule.js +2 -0
- package/lib/index.d.ts +10 -17
- package/lib/index.js +415 -328
- package/package.json +2 -2
package/lib/Candle.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { RawTradeData } from './RawTradeData';
|
|
1
2
|
export declare class Candle {
|
|
2
3
|
timestamp: number;
|
|
3
4
|
high: number;
|
|
@@ -10,3 +11,4 @@ export declare class Candle {
|
|
|
10
11
|
}
|
|
11
12
|
export declare function encodeCandle(candle: Candle): Uint32Array;
|
|
12
13
|
export declare function decodeCandle(buffer: Uint32Array): Candle;
|
|
14
|
+
export declare function generateCandles(data: RawTradeData[], candleSize: string): Candle[];
|
package/lib/Candle.js
CHANGED
|
@@ -1,6 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
2
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.decodeCandle = exports.encodeCandle = exports.Candle = void 0;
|
|
6
|
+
exports.generateCandles = exports.decodeCandle = exports.encodeCandle = exports.Candle = void 0;
|
|
7
|
+
const timestring_1 = __importDefault(require("timestring"));
|
|
4
8
|
class Candle {
|
|
5
9
|
constructor(timestamp, high, low, open, close, volume) {
|
|
6
10
|
this.timestamp = timestamp;
|
|
@@ -30,3 +34,53 @@ function decodeCandle(buffer) {
|
|
|
30
34
|
return new Candle(buffer[0], buffer[1], buffer[2], buffer[3], buffer[4], buffer[5]);
|
|
31
35
|
}
|
|
32
36
|
exports.decodeCandle = decodeCandle;
|
|
37
|
+
function generateCandles(data, candleSize) {
|
|
38
|
+
const candleWidth = (0, timestring_1.default)(candleSize, 'ms', {});
|
|
39
|
+
if (data.length === 0) {
|
|
40
|
+
throw new Error('Input data is empty');
|
|
41
|
+
}
|
|
42
|
+
const _data = data.map((point) => {
|
|
43
|
+
return Object.assign(Object.assign({}, point), {
|
|
44
|
+
// This will convert the timestamp to milliseconds if it's in seconds
|
|
45
|
+
timestamp: point.timestamp && String(point.timestamp).length == 10 ? point.timestamp * 1000 : point.timestamp,
|
|
46
|
+
});
|
|
47
|
+
});
|
|
48
|
+
if (_data[0] === undefined || Object.keys(_data[0]).length === 0) {
|
|
49
|
+
return [];
|
|
50
|
+
}
|
|
51
|
+
const ohlcvData = [];
|
|
52
|
+
let i = 0;
|
|
53
|
+
let currentTimestamp = Math.floor(_data[0].timestamp / candleWidth) * candleWidth;
|
|
54
|
+
let open = _data[0].price;
|
|
55
|
+
let high = _data[0].price;
|
|
56
|
+
let low = _data[0].price;
|
|
57
|
+
let close = _data[0].price;
|
|
58
|
+
let volume = 0.0;
|
|
59
|
+
while (i < _data.length) {
|
|
60
|
+
open = close;
|
|
61
|
+
high = close;
|
|
62
|
+
low = close;
|
|
63
|
+
volume = 0.0;
|
|
64
|
+
let innerI = i;
|
|
65
|
+
while (innerI < _data.length && _data[innerI].timestamp < currentTimestamp + candleWidth) {
|
|
66
|
+
open = innerI === 0 ? _data[innerI].price : open;
|
|
67
|
+
high = Math.max(high, _data[innerI].price);
|
|
68
|
+
low = Math.min(low, _data[innerI].price);
|
|
69
|
+
close = _data[innerI].price;
|
|
70
|
+
volume += _data[innerI].volume;
|
|
71
|
+
innerI++;
|
|
72
|
+
}
|
|
73
|
+
ohlcvData.push({
|
|
74
|
+
timestamp: currentTimestamp,
|
|
75
|
+
high,
|
|
76
|
+
low,
|
|
77
|
+
open,
|
|
78
|
+
close,
|
|
79
|
+
volume,
|
|
80
|
+
});
|
|
81
|
+
currentTimestamp += candleWidth;
|
|
82
|
+
i = innerI;
|
|
83
|
+
}
|
|
84
|
+
return ohlcvData;
|
|
85
|
+
}
|
|
86
|
+
exports.generateCandles = generateCandles;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
declare function responseHandler(body: ArrayBuffer, statusCode: number, redirected: number, callbackID: number): void;
|
|
2
|
+
declare function initialize(config: string): void;
|
|
3
|
+
declare function config(): string;
|
|
4
|
+
declare function version(): string;
|
|
5
|
+
declare function transform(): string;
|
|
6
|
+
declare function execute(...params: number[] | string[] | ArrayBuffer[] | null[]): string;
|
|
7
|
+
declare function __new(size: number, id: number): number;
|
|
8
|
+
declare function __pin(ptr: number): number;
|
|
9
|
+
declare function __unpin(ptr: number): number;
|
|
10
|
+
export type WasmModule = {
|
|
11
|
+
responseHandler: typeof responseHandler;
|
|
12
|
+
initialize: typeof initialize;
|
|
13
|
+
execute: typeof execute;
|
|
14
|
+
config: typeof config;
|
|
15
|
+
version: typeof version;
|
|
16
|
+
transform: typeof transform;
|
|
17
|
+
memory: WebAssembly.Memory;
|
|
18
|
+
__new: typeof __new;
|
|
19
|
+
__pin: typeof __pin;
|
|
20
|
+
__unpin: typeof __unpin;
|
|
21
|
+
};
|
|
22
|
+
export {};
|
package/lib/index.d.ts
CHANGED
|
@@ -1,19 +1,12 @@
|
|
|
1
1
|
import { Candle } from './Candle';
|
|
2
2
|
import { RawTradeData } from './RawTradeData';
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
execute: typeof execute;
|
|
14
|
-
config: typeof config;
|
|
15
|
-
version: typeof version;
|
|
16
|
-
transform: typeof transform;
|
|
17
|
-
memory: WebAssembly.Memory;
|
|
18
|
-
};
|
|
19
|
-
export declare const loadWasm: (input: string | ArrayBuffer, imports?: {}) => Promise<WasmModule>;
|
|
3
|
+
import { WasmModule } from './WasmModule';
|
|
4
|
+
export { Candle, RawTradeData, WasmModule };
|
|
5
|
+
/**
|
|
6
|
+
* Load a wasm bundle synchronously. Only accepts the actual binary data.
|
|
7
|
+
* @param input - Wasm bundle data
|
|
8
|
+
* @param imports - Imports
|
|
9
|
+
* @returns
|
|
10
|
+
*/
|
|
11
|
+
export declare function loadWasmSync(input: ArrayBuffer, imports?: {}): WasmModule;
|
|
12
|
+
export declare function loadWasm(input: string | ArrayBuffer, imports?: {}): Promise<WasmModule>;
|
package/lib/index.js
CHANGED
|
@@ -35,371 +35,458 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
35
35
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
36
36
|
};
|
|
37
37
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
38
|
-
exports.loadWasm = exports.RawTradeData = exports.Candle = void 0;
|
|
38
|
+
exports.loadWasm = exports.loadWasmSync = exports.RawTradeData = exports.Candle = void 0;
|
|
39
39
|
/* eslint-disable @typescript-eslint/ban-ts-comment */
|
|
40
40
|
const ccxt_1 = __importDefault(require("ccxt"));
|
|
41
|
-
const timestring_1 = __importDefault(require("timestring"));
|
|
42
41
|
const Candle_1 = require("./Candle");
|
|
43
42
|
Object.defineProperty(exports, "Candle", { enumerable: true, get: function () { return Candle_1.Candle; } });
|
|
44
43
|
const RawTradeData_1 = require("./RawTradeData");
|
|
45
44
|
Object.defineProperty(exports, "RawTradeData", { enumerable: true, get: function () { return RawTradeData_1.RawTradeData; } });
|
|
45
|
+
const ARRAYBUFFER_ID = 1;
|
|
46
|
+
const STRING_ID = 2;
|
|
47
|
+
// Pointers (for asyncify)
|
|
46
48
|
let _fetchGETSyncPtr = 0;
|
|
47
49
|
let _fetchPOSTSyncPtr = 0;
|
|
48
50
|
let _ohlcvPtr = 0;
|
|
51
|
+
// Globals
|
|
52
|
+
let WASM_MEMORY;
|
|
53
|
+
let WASM_EXPORTS;
|
|
54
|
+
let WASM_DV;
|
|
55
|
+
// Constants required by Asyncify
|
|
49
56
|
let ASYNCIFY_PTR = 0;
|
|
50
57
|
let ASYNCIFY_MEM;
|
|
51
|
-
let
|
|
52
|
-
|
|
58
|
+
let ASYNCIFY_INITIALIZED = false;
|
|
59
|
+
/**
|
|
60
|
+
* Load a wasm bundle synchronously. Only accepts the actual binary data.
|
|
61
|
+
* @param input - Wasm bundle data
|
|
62
|
+
* @param imports - Imports
|
|
63
|
+
* @returns
|
|
64
|
+
*/
|
|
65
|
+
function loadWasmSync(input, imports = {}) {
|
|
66
|
+
return instantiate(new WebAssembly.Module(input), imports);
|
|
67
|
+
}
|
|
68
|
+
exports.loadWasmSync = loadWasmSync;
|
|
69
|
+
function loadWasm(input, imports = {}) {
|
|
53
70
|
return __awaiter(this, void 0, void 0, function* () {
|
|
54
|
-
const
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
71
|
+
const mod = instantiate(yield (() => __awaiter(this, void 0, void 0, function* () {
|
|
72
|
+
if (typeof input === 'string') {
|
|
73
|
+
try {
|
|
74
|
+
return yield WebAssembly.compileStreaming(fetch(input));
|
|
75
|
+
}
|
|
76
|
+
catch (_a) {
|
|
77
|
+
return WebAssembly.compile(yield (yield Promise.resolve().then(() => __importStar(require('fs/promises')))).readFile(input));
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
else {
|
|
81
|
+
return WebAssembly.compile(input);
|
|
82
|
+
}
|
|
83
|
+
}))(), imports);
|
|
84
|
+
return mod;
|
|
85
|
+
});
|
|
86
|
+
}
|
|
87
|
+
exports.loadWasm = loadWasm;
|
|
88
|
+
function instantiate(module, imports = {}) {
|
|
89
|
+
const adaptedImports = Object.assign({
|
|
90
|
+
console: {
|
|
91
|
+
log(text) {
|
|
92
|
+
console.log(__liftString(text));
|
|
93
|
+
},
|
|
94
|
+
},
|
|
95
|
+
// @ts-ignore
|
|
96
|
+
env: {
|
|
97
|
+
abort(message, fileName, lineNumber, columnNumber) {
|
|
98
|
+
(() => {
|
|
99
|
+
throw Error(`${__liftString(message)} in ${__liftString(fileName)}:${lineNumber}:${columnNumber}`);
|
|
100
|
+
})();
|
|
101
|
+
},
|
|
102
|
+
_initAsyncify(frame_ptr, stack_ptr) {
|
|
103
|
+
// @ts-ignore
|
|
104
|
+
if (!WASM_EXPORTS['asyncify_get_state'])
|
|
105
|
+
throw new Error('Asyncify initialized, but not enabled when run! Compile with the --runPasses asyncify flag or asyncify-shim transform!');
|
|
106
|
+
if (ASYNCIFY_INITIALIZED)
|
|
107
|
+
return;
|
|
108
|
+
ASYNCIFY_PTR = frame_ptr;
|
|
109
|
+
ASYNCIFY_MEM[ASYNCIFY_PTR >> 2] = ASYNCIFY_PTR + 8;
|
|
110
|
+
// I don't know if I need to reserve all this memory...
|
|
111
|
+
ASYNCIFY_MEM[(ASYNCIFY_PTR + 4) >> 2] = stack_ptr;
|
|
112
|
+
ASYNCIFY_INITIALIZED = true;
|
|
113
|
+
},
|
|
114
|
+
generateCandles(data, candleSize) {
|
|
115
|
+
const _data = __liftString(data) || '[]';
|
|
116
|
+
const _candleSize = __liftString(candleSize) || '69m';
|
|
117
|
+
const candles = (0, Candle_1.generateCandles)(JSON.parse(_data), _candleSize);
|
|
118
|
+
return __lowerString(JSON.stringify(candles));
|
|
119
|
+
},
|
|
120
|
+
'console.log': (text) => {
|
|
121
|
+
console.log(__liftString(text));
|
|
122
|
+
},
|
|
123
|
+
ccxt_fetchOHLCV: (exchangeId, symbol, timeframe, limit, since) => {
|
|
124
|
+
// Since may need to be passed as 64-bit?
|
|
125
|
+
// Timestamps are large
|
|
126
|
+
// @ts-ignore
|
|
127
|
+
const currentState = WASM_EXPORTS.asyncify_get_state();
|
|
128
|
+
if (currentState === 2) {
|
|
129
|
+
//console.log("asyncify_stop_rewind() [resume wasm]");
|
|
105
130
|
// @ts-ignore
|
|
106
|
-
|
|
107
|
-
|
|
131
|
+
WASM_EXPORTS.asyncify_stop_rewind();
|
|
132
|
+
return _ohlcvPtr;
|
|
133
|
+
}
|
|
134
|
+
else if (currentState === 0) {
|
|
135
|
+
//console.log("asyncify_start_unwind() [pause wasm]");
|
|
136
|
+
// @ts-ignore
|
|
137
|
+
WASM_EXPORTS.asyncify_start_unwind(ASYNCIFY_PTR);
|
|
138
|
+
// How about we pass an Enum back and forth?
|
|
139
|
+
const _exchange = __liftString(exchangeId);
|
|
140
|
+
const _symbol = __liftString(symbol);
|
|
141
|
+
const _timeframe = __liftString(timeframe);
|
|
142
|
+
if (!_exchange || !_symbol || !_timeframe)
|
|
143
|
+
throw new Error('Exchange, Symbol, or Timeframe not provided when fetching OHCLV data.');
|
|
144
|
+
// @ts-ignore
|
|
145
|
+
new ccxt_1.default[_exchange]({
|
|
146
|
+
apiKey: '',
|
|
147
|
+
secret: '',
|
|
148
|
+
})
|
|
149
|
+
.fetchOHLCV(_symbol, _timeframe, since, limit)
|
|
150
|
+
.then((data) => {
|
|
151
|
+
//console.log("asyncify_stop_unwind() [unpause wasm]");
|
|
108
152
|
// @ts-ignore
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
153
|
+
WASM_EXPORTS.asyncify_stop_unwind();
|
|
154
|
+
// @ts-ignore: __new is defined
|
|
155
|
+
_ohlcvPtr = __lowerStaticArray((pointer, value) => {
|
|
156
|
+
__setU32(pointer, __lowerStaticArray(__setF64, 7, 3, value, Float64Array));
|
|
157
|
+
}, 8, 2, data);
|
|
158
|
+
//console.log("asyncify_start_rewind() [resuming wasm]");
|
|
113
159
|
// @ts-ignore
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
const _timeframe = __liftString(timeframe);
|
|
118
|
-
const _since = since;
|
|
119
|
-
const _limit = limit;
|
|
120
|
-
if (_exchangeId &&
|
|
121
|
-
_symbol &&
|
|
122
|
-
_timeframe &&
|
|
123
|
-
_since &&
|
|
124
|
-
_limit) {
|
|
125
|
-
try {
|
|
126
|
-
// @ts-ignore
|
|
127
|
-
_exports.asyncify_stop_unwind();
|
|
128
|
-
// @ts-ignore
|
|
129
|
-
new ccxt_1.default[exchangeId]({
|
|
130
|
-
apiKey: "",
|
|
131
|
-
secret: ""
|
|
132
|
-
}).fetchOHLCV(_symbol, _timeframe, _limit, _since).then((data) => {
|
|
133
|
-
// @ts-ignore
|
|
134
|
-
_exports.asyncify_start_rewind(ASYNCIFY_PTR);
|
|
135
|
-
_ohlcvPtr = __lowerString(JSON.stringify(data));
|
|
136
|
-
_exports.execute();
|
|
137
|
-
});
|
|
138
|
-
}
|
|
139
|
-
catch (e) {
|
|
140
|
-
// @ts-ignore
|
|
141
|
-
_exports.asyncify_start_rewind(ASYNCIFY_PTR);
|
|
142
|
-
process.env.DEBUG && console.error(e);
|
|
143
|
-
_exports.execute();
|
|
144
|
-
}
|
|
145
|
-
}
|
|
146
|
-
}
|
|
160
|
+
WASM_EXPORTS.asyncify_start_rewind(ASYNCIFY_PTR);
|
|
161
|
+
WASM_EXPORTS.execute();
|
|
162
|
+
});
|
|
147
163
|
}
|
|
148
|
-
}
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
164
|
+
},
|
|
165
|
+
},
|
|
166
|
+
'as-fetch': {
|
|
167
|
+
_initAsyncify(frame_ptr, stack_ptr) {
|
|
168
|
+
// @ts-ignore
|
|
169
|
+
if (!WASM_EXPORTS['asyncify_get_state'])
|
|
170
|
+
throw new Error('Asyncify initialized, but not enabled when run! Compile with the --runPasses asyncify flag or asyncify-shim transform!');
|
|
171
|
+
if (ASYNCIFY_INITIALIZED)
|
|
172
|
+
return;
|
|
173
|
+
ASYNCIFY_PTR = frame_ptr;
|
|
174
|
+
ASYNCIFY_MEM[ASYNCIFY_PTR >> 2] = ASYNCIFY_PTR + 8;
|
|
175
|
+
// I don't know if I need to reserve all this memory...
|
|
176
|
+
ASYNCIFY_MEM[(ASYNCIFY_PTR + 4) >> 2] = stack_ptr;
|
|
177
|
+
ASYNCIFY_INITIALIZED = true;
|
|
178
|
+
},
|
|
179
|
+
_fetchPOSTSync(url, mode, headers, body) {
|
|
180
|
+
var _a;
|
|
181
|
+
// @ts-ignore
|
|
182
|
+
const currentState = WASM_EXPORTS.asyncify_get_state();
|
|
183
|
+
if (currentState === 2) {
|
|
184
|
+
//console.log("asyncify_stop_rewind() [resume wasm]");
|
|
158
185
|
// @ts-ignore
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
186
|
+
WASM_EXPORTS.asyncify_stop_rewind();
|
|
187
|
+
const ptr = _fetchPOSTSyncPtr;
|
|
188
|
+
_fetchPOSTSyncPtr = 0;
|
|
189
|
+
return ptr;
|
|
190
|
+
}
|
|
191
|
+
else if (currentState === 0) {
|
|
192
|
+
//console.log("asyncify_start_unwind() [pause wasm]");
|
|
193
|
+
// @ts-ignore
|
|
194
|
+
WASM_EXPORTS.asyncify_start_unwind(ASYNCIFY_PTR);
|
|
195
|
+
fetch((_a = __liftString(url)) !== null && _a !== void 0 ? _a : '', {
|
|
196
|
+
method: 'POST',
|
|
197
|
+
mode: modeToString(mode) || 'cors',
|
|
198
|
+
headers: __liftArray((pointer) => __liftArray((pointer) => __liftString(__getU32(pointer)), 2, __getU32(pointer)), 2, headers) || [],
|
|
199
|
+
body: __liftBuffer(body),
|
|
200
|
+
}).then((res) => __awaiter(this, void 0, void 0, function* () {
|
|
201
|
+
const value = yield res.arrayBuffer();
|
|
202
|
+
//console.log("asyncify_stop_unwind() [unpause wasm]");
|
|
162
203
|
// @ts-ignore
|
|
163
|
-
|
|
164
|
-
return _fetchPOSTSyncPtr;
|
|
165
|
-
}
|
|
166
|
-
else if (currentState === 0) {
|
|
167
|
-
//console.log("asyncify_start_unwind() [pause wasm]");
|
|
204
|
+
WASM_EXPORTS.asyncify_stop_unwind();
|
|
168
205
|
// @ts-ignore
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
headers: __liftArray((pointer) => __liftArray((pointer) => __liftString(__getU32(pointer)), 2, __getU32(pointer)), 2, headers) || [],
|
|
174
|
-
body: __liftBuffer(body)
|
|
175
|
-
}).then((res) => __awaiter(this, void 0, void 0, function* () {
|
|
176
|
-
//console.log("asyncify_stop_unwind() [unpause wasm]");
|
|
177
|
-
// @ts-ignore
|
|
178
|
-
_exports.asyncify_stop_unwind();
|
|
179
|
-
const value = yield res.arrayBuffer();
|
|
180
|
-
// @ts-ignore
|
|
181
|
-
_fetchPOSTSyncPtr = _exports.__new(value.byteLength, 1);
|
|
182
|
-
new Uint8Array(_exports.memory.buffer).set(new Uint8Array(value), _fetchPOSTSyncPtr);
|
|
183
|
-
//console.log("asyncify_start_rewind() [resuming wasm]");
|
|
184
|
-
// @ts-ignore
|
|
185
|
-
_exports.asyncify_start_rewind(ASYNCIFY_PTR);
|
|
186
|
-
// @ts-ignore
|
|
187
|
-
// Set to your execute function that your fetch calls are in. I would go and create a _start func
|
|
188
|
-
_exports.execute();
|
|
189
|
-
}));
|
|
190
|
-
}
|
|
191
|
-
},
|
|
192
|
-
_fetchGETSync(url, mode, headers) {
|
|
193
|
-
// @ts-ignore
|
|
194
|
-
const currentState = _exports.asyncify_get_state();
|
|
195
|
-
if (currentState === 2) {
|
|
206
|
+
_fetchPOSTSyncPtr = __lowerBuffer(value);
|
|
207
|
+
//wasm_exports.__new(value.byteLength, 1);
|
|
208
|
+
//new Uint8Array(wasm_exports.memory.buffer).set(new Uint8Array(value), _fetchPOSTSyncPtr);
|
|
209
|
+
//console.log("asyncify_start_rewind() [resuming wasm]");
|
|
196
210
|
// @ts-ignore
|
|
197
|
-
|
|
198
|
-
_exports.asyncify_stop_rewind();
|
|
199
|
-
return _fetchGETSyncPtr;
|
|
200
|
-
}
|
|
201
|
-
else if (currentState === 0) {
|
|
211
|
+
WASM_EXPORTS.asyncify_start_rewind(ASYNCIFY_PTR);
|
|
202
212
|
// @ts-ignore
|
|
203
|
-
//
|
|
204
|
-
|
|
205
|
-
fetch(__liftString(url) || "", {
|
|
206
|
-
method: "GET",
|
|
207
|
-
mode: modeToString(mode) || "cors",
|
|
208
|
-
headers: __liftArray((pointer) => __liftArray((pointer) => __liftString(__getU32(pointer)), 2, __getU32(pointer)), 2, headers) || []
|
|
209
|
-
}).then((res) => __awaiter(this, void 0, void 0, function* () {
|
|
210
|
-
// @ts-ignore
|
|
211
|
-
//console.log("asyncify_stop_unwind() [unpause wasm]");
|
|
212
|
-
_exports.asyncify_stop_unwind();
|
|
213
|
-
const value = yield res.arrayBuffer();
|
|
214
|
-
// @ts-ignore
|
|
215
|
-
_fetchGETSyncPtr = _exports.__new(value.byteLength, 1);
|
|
216
|
-
new Uint8Array(_exports.memory.buffer).set(new Uint8Array(value), _fetchGETSyncPtr);
|
|
217
|
-
// @ts-ignore
|
|
218
|
-
//console.log("asyncify_start_rewind() [resuming wasm]");
|
|
219
|
-
_exports.asyncify_start_rewind(ASYNCIFY_PTR);
|
|
220
|
-
// @ts-ignore
|
|
221
|
-
_exports.execute();
|
|
222
|
-
}));
|
|
223
|
-
}
|
|
224
|
-
},
|
|
225
|
-
_fetchGET(url, mode, headers, callbackID) {
|
|
226
|
-
fetch(__liftString(url) || "", {
|
|
227
|
-
method: "GET",
|
|
228
|
-
mode: modeToString(mode) || "cors",
|
|
229
|
-
headers: __liftArray((pointer) => __liftArray((pointer) => __liftString(__getU32(pointer)), 2, __getU32(pointer)), 2, headers) || []
|
|
230
|
-
}).then((res) => __awaiter(this, void 0, void 0, function* () {
|
|
231
|
-
const body = yield res.arrayBuffer();
|
|
232
|
-
_exports.responseHandler(body, res.status, res.redirected ? 1 : 0, callbackID);
|
|
213
|
+
// Set to your execute function that your fetch calls are in. I would go and create a _start func
|
|
214
|
+
WASM_EXPORTS.execute();
|
|
233
215
|
}));
|
|
234
|
-
}
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
216
|
+
}
|
|
217
|
+
},
|
|
218
|
+
_fetchGETSync(url, mode, headers) {
|
|
219
|
+
// @ts-ignore
|
|
220
|
+
const currentState = WASM_EXPORTS.asyncify_get_state();
|
|
221
|
+
if (currentState === 2) {
|
|
222
|
+
// @ts-ignore
|
|
223
|
+
//console.log("asyncify_stop_rewind() [resume wasm]");
|
|
224
|
+
WASM_EXPORTS.asyncify_stop_rewind();
|
|
225
|
+
const ptr = _fetchGETSyncPtr;
|
|
226
|
+
_fetchGETSyncPtr = 0;
|
|
227
|
+
return ptr;
|
|
228
|
+
}
|
|
229
|
+
else if (currentState === 0) {
|
|
230
|
+
// @ts-ignore
|
|
231
|
+
//console.log("asyncify_start_unwind() [pause wasm]");
|
|
232
|
+
WASM_EXPORTS.asyncify_start_unwind(ASYNCIFY_PTR);
|
|
233
|
+
fetch(__liftString(url) || '', {
|
|
234
|
+
method: 'GET',
|
|
235
|
+
mode: modeToString(mode) || 'cors',
|
|
240
236
|
headers: __liftArray((pointer) => __liftArray((pointer) => __liftString(__getU32(pointer)), 2, __getU32(pointer)), 2, headers) || [],
|
|
241
237
|
}).then((res) => __awaiter(this, void 0, void 0, function* () {
|
|
242
|
-
const
|
|
243
|
-
|
|
238
|
+
const value = yield res.arrayBuffer();
|
|
239
|
+
// @ts-ignore
|
|
240
|
+
//console.log("asyncify_stop_unwind() [unpause wasm]");
|
|
241
|
+
WASM_EXPORTS.asyncify_stop_unwind();
|
|
242
|
+
// @ts-ignore
|
|
243
|
+
_fetchGETSyncPtr = __lowerBuffer(value);
|
|
244
|
+
// @ts-ignore
|
|
245
|
+
//console.log("asyncify_start_rewind() [resuming wasm]");
|
|
246
|
+
WASM_EXPORTS.asyncify_start_rewind(ASYNCIFY_PTR);
|
|
247
|
+
// @ts-ignore
|
|
248
|
+
WASM_EXPORTS.execute();
|
|
244
249
|
}));
|
|
245
250
|
}
|
|
246
251
|
},
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
if (exports['responseHandler']) {
|
|
257
|
-
exports.responseHandler(__lowerBuffer(body), statusCode, redirected ? 1 : 0, callbackID);
|
|
258
|
-
}
|
|
252
|
+
_fetchGET(url, mode, headers, callbackID) {
|
|
253
|
+
fetch(__liftString(url) || '', {
|
|
254
|
+
method: 'GET',
|
|
255
|
+
mode: modeToString(mode) || 'cors',
|
|
256
|
+
headers: __liftArray((pointer) => __liftArray((pointer) => __liftString(__getU32(pointer)), 2, __getU32(pointer)), 2, headers) || [],
|
|
257
|
+
}).then((res) => __awaiter(this, void 0, void 0, function* () {
|
|
258
|
+
const body = yield res.arrayBuffer();
|
|
259
|
+
WASM_EXPORTS.responseHandler(body, res.status, res.redirected ? 1 : 0, callbackID);
|
|
260
|
+
}));
|
|
259
261
|
},
|
|
260
|
-
|
|
261
|
-
|
|
262
|
+
_fetchPOST(url, mode, headers, body, callbackID) {
|
|
263
|
+
fetch(__liftString(url) || '', {
|
|
264
|
+
method: 'POST',
|
|
265
|
+
mode: modeToString(mode) || 'cors',
|
|
266
|
+
body: body,
|
|
267
|
+
headers: __liftArray((pointer) => __liftArray((pointer) => __liftString(__getU32(pointer)), 2, __getU32(pointer)), 2, headers) || [],
|
|
268
|
+
}).then((res) => __awaiter(this, void 0, void 0, function* () {
|
|
269
|
+
const body = yield res.arrayBuffer();
|
|
270
|
+
WASM_EXPORTS.responseHandler(body, res.status, res.redirected ? 1 : 0, callbackID);
|
|
271
|
+
}));
|
|
262
272
|
},
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
},
|
|
273
|
-
transform() {
|
|
274
|
-
try {
|
|
275
|
-
return __liftString(exports.transform());
|
|
276
|
-
}
|
|
277
|
-
catch (e) {
|
|
278
|
-
console.error(e);
|
|
279
|
-
throw new Error('Unable to call .transform on wasm module. Are you sure this is a data connector?');
|
|
280
|
-
}
|
|
281
|
-
},
|
|
282
|
-
}, exports);
|
|
283
|
-
function __liftBuffer(pointer) {
|
|
284
|
-
if (!pointer)
|
|
285
|
-
return null;
|
|
286
|
-
return memory.buffer.slice(pointer, pointer + new Uint32Array(memory.buffer)[(pointer - 4) >>> 2]);
|
|
287
|
-
}
|
|
288
|
-
function __lowerBuffer(value) {
|
|
289
|
-
if (value == null)
|
|
290
|
-
return 0;
|
|
291
|
-
// @ts-ignore
|
|
292
|
-
const pointer = exports.__new(value.byteLength, 1);
|
|
293
|
-
new Uint8Array(memory.buffer).set(new Uint8Array(value), pointer);
|
|
294
|
-
return pointer;
|
|
295
|
-
}
|
|
296
|
-
function __liftString(pointer) {
|
|
297
|
-
if (!pointer)
|
|
298
|
-
return null;
|
|
299
|
-
const end = (pointer + new Uint32Array(memory.buffer)[(pointer - 4) >>> 2]) >>> 1, memoryU16 = new Uint16Array(memory.buffer);
|
|
300
|
-
let start = pointer >>> 1, string = '';
|
|
301
|
-
while (end - start > 1024)
|
|
302
|
-
string += String.fromCharCode(...memoryU16.subarray(start, (start += 1024)));
|
|
303
|
-
return string + String.fromCharCode(...memoryU16.subarray(start, end));
|
|
304
|
-
}
|
|
305
|
-
function __lowerString(value) {
|
|
306
|
-
if (value === null)
|
|
307
|
-
return 0;
|
|
308
|
-
const length = value.length;
|
|
309
|
-
// @ts-ignore
|
|
310
|
-
const pointer = exports.__new(length << 1, 2);
|
|
311
|
-
const memoryU16 = new Uint16Array(memory.buffer);
|
|
312
|
-
for (let i = 0; i < length; ++i)
|
|
313
|
-
memoryU16[(pointer >>> 1) + i] = value.charCodeAt(i);
|
|
314
|
-
return pointer;
|
|
315
|
-
}
|
|
316
|
-
function __liftArray(liftElement, align, pointer) {
|
|
317
|
-
if (!pointer)
|
|
318
|
-
return null;
|
|
319
|
-
const dataStart = __getU32(pointer + 4), length = __dataview.getUint32(pointer + 12, true), values = new Array(length);
|
|
320
|
-
for (let i = 0; i < length; ++i)
|
|
321
|
-
values[i] = liftElement(dataStart + (i << align));
|
|
322
|
-
return values;
|
|
323
|
-
}
|
|
324
|
-
let __dataview = new DataView(memory.buffer);
|
|
325
|
-
function __getU32(pointer) {
|
|
273
|
+
},
|
|
274
|
+
}, imports);
|
|
275
|
+
const mod = new WebAssembly.Instance(module, adaptedImports);
|
|
276
|
+
WASM_EXPORTS = mod.exports;
|
|
277
|
+
// @ts-ignore
|
|
278
|
+
WASM_MEMORY = WASM_EXPORTS.memory || adaptedImports.env.memory;
|
|
279
|
+
ASYNCIFY_MEM = new Uint32Array(WASM_MEMORY.buffer);
|
|
280
|
+
const handledExports = Object.setPrototypeOf({
|
|
281
|
+
responseHandler(body, statusCode, redirected, callbackID) {
|
|
326
282
|
try {
|
|
327
|
-
|
|
283
|
+
// @ts-ignore
|
|
284
|
+
WASM_EXPORTS.responseHandler(__lowerBuffer(body), statusCode, redirected ? 1 : 0, callbackID);
|
|
328
285
|
}
|
|
329
|
-
catch (
|
|
330
|
-
|
|
331
|
-
|
|
286
|
+
catch (e) {
|
|
287
|
+
console.error(e);
|
|
288
|
+
throw new Error('Unable to call .responseHandler on wasm module. Add the line export { responseHandler } from "as-fetch/assembly" to your entry file.');
|
|
332
289
|
}
|
|
333
|
-
}
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
290
|
+
},
|
|
291
|
+
initialize(config) {
|
|
292
|
+
// @ts-ignore
|
|
293
|
+
WASM_EXPORTS.initialize(__lowerString(config));
|
|
294
|
+
},
|
|
295
|
+
execute(...params) {
|
|
296
|
+
const loweredArgs = new Array(params.length);
|
|
297
|
+
for (let i = 0; i < params.length; i++) {
|
|
298
|
+
loweredArgs[i] = __lowerRetained(params[i]);
|
|
338
299
|
}
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
timestamp: point.timestamp && String(point.timestamp).length == 10 ? point.timestamp * 1000 : point.timestamp,
|
|
343
|
-
});
|
|
344
|
-
});
|
|
345
|
-
if (_data[0] === undefined || Object.keys(_data[0]).length === 0) {
|
|
346
|
-
return [];
|
|
300
|
+
for (let i = 0; i < loweredArgs.length; i++) {
|
|
301
|
+
if (typeof params[i] !== 'number')
|
|
302
|
+
__release(loweredArgs[i]);
|
|
347
303
|
}
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
let volume = 0.0;
|
|
356
|
-
while (i < _data.length) {
|
|
357
|
-
open = close;
|
|
358
|
-
high = close;
|
|
359
|
-
low = close;
|
|
360
|
-
volume = 0.0;
|
|
361
|
-
let innerI = i;
|
|
362
|
-
while (innerI < _data.length && _data[innerI].timestamp < currentTimestamp + candleWidth) {
|
|
363
|
-
open = innerI === 0 ? _data[innerI].price : open;
|
|
364
|
-
high = Math.max(high, _data[innerI].price);
|
|
365
|
-
low = Math.min(low, _data[innerI].price);
|
|
366
|
-
close = _data[innerI].price;
|
|
367
|
-
volume += _data[innerI].volume;
|
|
368
|
-
innerI++;
|
|
369
|
-
}
|
|
370
|
-
ohlcvData.push({
|
|
371
|
-
timestamp: currentTimestamp,
|
|
372
|
-
high,
|
|
373
|
-
low,
|
|
374
|
-
open,
|
|
375
|
-
close,
|
|
376
|
-
volume,
|
|
377
|
-
});
|
|
378
|
-
currentTimestamp += candleWidth;
|
|
379
|
-
i = innerI;
|
|
380
|
-
}
|
|
381
|
-
return ohlcvData;
|
|
382
|
-
}
|
|
383
|
-
return adaptedExports;
|
|
384
|
-
});
|
|
385
|
-
}
|
|
386
|
-
const loadWasm = (input, imports = {}) => __awaiter(void 0, void 0, void 0, function* () {
|
|
387
|
-
const mod = (yield instantiate(yield (() => __awaiter(void 0, void 0, void 0, function* () {
|
|
388
|
-
if (typeof input === 'string') {
|
|
304
|
+
// @ts-ignore
|
|
305
|
+
return __liftString(WASM_EXPORTS.execute(...loweredArgs));
|
|
306
|
+
},
|
|
307
|
+
config() {
|
|
308
|
+
return __liftString(WASM_EXPORTS.config());
|
|
309
|
+
},
|
|
310
|
+
transform() {
|
|
389
311
|
try {
|
|
390
|
-
return
|
|
312
|
+
return __liftString(WASM_EXPORTS.transform());
|
|
391
313
|
}
|
|
392
|
-
catch (
|
|
393
|
-
|
|
314
|
+
catch (e) {
|
|
315
|
+
console.error(e);
|
|
316
|
+
throw new Error('Unable to call .transform on wasm module. Are you sure this is a data connector?');
|
|
394
317
|
}
|
|
395
|
-
}
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
318
|
+
},
|
|
319
|
+
}, WASM_EXPORTS);
|
|
320
|
+
WASM_DV = new DataView(WASM_MEMORY.buffer);
|
|
321
|
+
return handledExports;
|
|
322
|
+
}
|
|
323
|
+
const refcounts = new Map();
|
|
324
|
+
function __retain(ptr) {
|
|
325
|
+
if (ptr) {
|
|
326
|
+
const refcount = refcounts.get(ptr);
|
|
327
|
+
if (refcount)
|
|
328
|
+
refcounts.set(ptr, refcount + 1);
|
|
329
|
+
else
|
|
330
|
+
refcounts.set(WASM_EXPORTS.__pin(ptr), 1);
|
|
331
|
+
}
|
|
332
|
+
return ptr;
|
|
333
|
+
}
|
|
334
|
+
function __release(ptr) {
|
|
335
|
+
if (ptr) {
|
|
336
|
+
const refcount = refcounts.get(ptr);
|
|
337
|
+
if (refcount === 1)
|
|
338
|
+
WASM_EXPORTS.__unpin(ptr), refcounts.delete(ptr);
|
|
339
|
+
else if (refcount)
|
|
340
|
+
refcounts.set(ptr, refcount - 1);
|
|
341
|
+
else
|
|
342
|
+
throw Error(`invalid refcount '${refcount}' for reference '${ptr}'`);
|
|
343
|
+
}
|
|
344
|
+
}
|
|
345
|
+
function __lowerRetained(val) {
|
|
346
|
+
if (typeof val === 'number') {
|
|
347
|
+
return val;
|
|
348
|
+
}
|
|
349
|
+
else if (typeof val === 'string') {
|
|
350
|
+
return __lowerStringRetained(val);
|
|
351
|
+
}
|
|
352
|
+
else if (val instanceof ArrayBuffer) {
|
|
353
|
+
return __lowerBufferRetained(val);
|
|
354
|
+
}
|
|
355
|
+
else {
|
|
356
|
+
return 0;
|
|
357
|
+
}
|
|
358
|
+
}
|
|
359
|
+
function __liftString(ptr) {
|
|
360
|
+
if (!ptr)
|
|
361
|
+
return null;
|
|
362
|
+
const end = (ptr + new Uint32Array(WASM_MEMORY.buffer)[(ptr - 4) >>> 2]) >>> 1;
|
|
363
|
+
const memoryU16 = new Uint16Array(WASM_MEMORY.buffer);
|
|
364
|
+
let start = ptr >>> 1;
|
|
365
|
+
let str = '';
|
|
366
|
+
while (end - start > 1024)
|
|
367
|
+
str += String.fromCharCode(...memoryU16.subarray(start, (start += 1024)));
|
|
368
|
+
return str + String.fromCharCode(...memoryU16.subarray(start, end));
|
|
369
|
+
}
|
|
370
|
+
function __lowerString(str) {
|
|
371
|
+
if (str === null)
|
|
372
|
+
return 0;
|
|
373
|
+
const length = str.length;
|
|
374
|
+
// @ts-ignore
|
|
375
|
+
const ptr = WASM_EXPORTS.__new(length << 1, STRING_ID);
|
|
376
|
+
__retain(ptr);
|
|
377
|
+
const memoryU16 = new Uint16Array(WASM_MEMORY.buffer);
|
|
378
|
+
for (let i = 0; i < length; ++i)
|
|
379
|
+
memoryU16[(ptr >>> 1) + i] = str.charCodeAt(i);
|
|
380
|
+
return ptr;
|
|
381
|
+
}
|
|
382
|
+
function __lowerStringRetained(str) {
|
|
383
|
+
if (str === null)
|
|
384
|
+
return 0;
|
|
385
|
+
const length = str.length;
|
|
386
|
+
// @ts-ignore
|
|
387
|
+
const ptr = WASM_EXPORTS.__new(length << 1, STRING_ID);
|
|
388
|
+
__retain(ptr);
|
|
389
|
+
const memoryU16 = new Uint16Array(WASM_MEMORY.buffer);
|
|
390
|
+
for (let i = 0; i < length; ++i)
|
|
391
|
+
memoryU16[(ptr >>> 1) + i] = str.charCodeAt(i);
|
|
392
|
+
return ptr;
|
|
393
|
+
}
|
|
394
|
+
function __liftArray(liftElement, align, ptr) {
|
|
395
|
+
if (!ptr)
|
|
396
|
+
return null;
|
|
397
|
+
let dataStart;
|
|
398
|
+
try {
|
|
399
|
+
dataStart = WASM_DV.getUint32(ptr + 4, true);
|
|
400
|
+
}
|
|
401
|
+
catch (_a) {
|
|
402
|
+
WASM_DV = new DataView(WASM_MEMORY.buffer);
|
|
403
|
+
dataStart = WASM_DV.getUint32(ptr + 4, true);
|
|
404
|
+
}
|
|
405
|
+
const length = WASM_DV.getUint32(ptr + 12, true);
|
|
406
|
+
const values = new Array(length);
|
|
407
|
+
for (let i = 0; i < length; ++i)
|
|
408
|
+
values[i] = liftElement(dataStart + ((i << align) >>> 0));
|
|
409
|
+
return values;
|
|
410
|
+
}
|
|
411
|
+
function __lowerArray(lowerElement, id, align, values) {
|
|
412
|
+
if (values == null)
|
|
413
|
+
return 0;
|
|
414
|
+
const length = values.length;
|
|
415
|
+
const buffer = WASM_EXPORTS.__pin(WASM_EXPORTS.__new(length << align, 1)) >>> 0;
|
|
416
|
+
const header = WASM_EXPORTS.__pin(WASM_EXPORTS.__new(16, id)) >>> 0;
|
|
417
|
+
WASM_DV.setUint32(header, buffer, true);
|
|
418
|
+
WASM_DV.setUint32(header + 4, buffer, true);
|
|
419
|
+
WASM_DV.setUint32(header + 8, length << align, true);
|
|
420
|
+
WASM_DV.setUint32(header + 12, length, true);
|
|
421
|
+
for (let i = 0; i < length; ++i)
|
|
422
|
+
lowerElement(buffer + ((i << align) >>> 0), values[i]);
|
|
423
|
+
WASM_EXPORTS.__unpin(buffer);
|
|
424
|
+
WASM_EXPORTS.__unpin(header);
|
|
425
|
+
return header;
|
|
426
|
+
}
|
|
427
|
+
function __liftBuffer(ptr) {
|
|
428
|
+
if (!ptr)
|
|
429
|
+
return null;
|
|
430
|
+
const len = new Uint32Array(WASM_MEMORY.buffer)[(ptr - 4) >>> 2];
|
|
431
|
+
return WASM_MEMORY.buffer.slice(ptr, ptr + len);
|
|
432
|
+
}
|
|
433
|
+
function __lowerBuffer(buf) {
|
|
434
|
+
if (buf == null)
|
|
435
|
+
return 0;
|
|
436
|
+
const ptr = WASM_EXPORTS.__new(buf.byteLength, ARRAYBUFFER_ID) >>> 0;
|
|
437
|
+
new Uint8Array(WASM_MEMORY.buffer).set(new Uint8Array(buf), ptr);
|
|
438
|
+
return ptr;
|
|
439
|
+
}
|
|
440
|
+
function __lowerBufferRetained(buf) {
|
|
441
|
+
if (buf == null)
|
|
442
|
+
return 0;
|
|
443
|
+
const ptr = WASM_EXPORTS.__new(buf.byteLength, ARRAYBUFFER_ID) >>> 0;
|
|
444
|
+
__retain(ptr);
|
|
445
|
+
new Uint8Array(WASM_MEMORY.buffer).set(new Uint8Array(buf), ptr);
|
|
446
|
+
return ptr;
|
|
447
|
+
}
|
|
448
|
+
function __lowerStaticArray(lowerElement, id, align, values, typedConstructor) {
|
|
449
|
+
if (values == null)
|
|
450
|
+
return 0;
|
|
451
|
+
const length = values.length;
|
|
452
|
+
const ptr = WASM_EXPORTS.__pin(WASM_EXPORTS.__new(length << align, id)) >>> 0;
|
|
453
|
+
if (typedConstructor) {
|
|
454
|
+
new typedConstructor(WASM_EXPORTS.memory.buffer, ptr, length).set(values);
|
|
455
|
+
}
|
|
456
|
+
else {
|
|
457
|
+
for (let i = 0; i < length; i++)
|
|
458
|
+
lowerElement(ptr + ((i << align) >>> 0), values[i]);
|
|
459
|
+
}
|
|
460
|
+
WASM_EXPORTS.__unpin(ptr);
|
|
461
|
+
return ptr;
|
|
462
|
+
}
|
|
463
|
+
function __setF64(ptr, val) {
|
|
464
|
+
try {
|
|
465
|
+
WASM_DV.setFloat64(ptr, val, true);
|
|
466
|
+
}
|
|
467
|
+
catch (_a) {
|
|
468
|
+
WASM_DV = new DataView(WASM_MEMORY.buffer);
|
|
469
|
+
WASM_DV.setFloat64(ptr, val, true);
|
|
470
|
+
}
|
|
471
|
+
}
|
|
472
|
+
function __getU32(ptr) {
|
|
473
|
+
try {
|
|
474
|
+
return WASM_DV.getUint32(ptr, true);
|
|
475
|
+
}
|
|
476
|
+
catch (_a) {
|
|
477
|
+
WASM_DV = new DataView(WASM_MEMORY.buffer);
|
|
478
|
+
return WASM_DV.getUint32(ptr, true);
|
|
479
|
+
}
|
|
480
|
+
}
|
|
481
|
+
function __setU32(ptr, val) {
|
|
482
|
+
try {
|
|
483
|
+
WASM_DV.setUint32(ptr, val, true);
|
|
484
|
+
}
|
|
485
|
+
catch (_a) {
|
|
486
|
+
WASM_DV = new DataView(WASM_MEMORY.buffer);
|
|
487
|
+
WASM_DV.setUint32(ptr, val, true);
|
|
488
|
+
}
|
|
489
|
+
}
|
|
403
490
|
function modeToString(mode) {
|
|
404
491
|
if (mode == 1)
|
|
405
492
|
return 'cors';
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@steerprotocol/app-loader",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "1.0.0",
|
|
4
4
|
"description": "App Loader for Steer Protocol",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"types": "lib/index.d.ts",
|
|
@@ -46,7 +46,7 @@
|
|
|
46
46
|
"lib/**/*"
|
|
47
47
|
],
|
|
48
48
|
"dependencies": {
|
|
49
|
-
"ccxt": "^
|
|
49
|
+
"ccxt": "^4.0.52",
|
|
50
50
|
"timestring": "^7.0.0"
|
|
51
51
|
}
|
|
52
52
|
}
|