@steerprotocol/app-loader 1.1.0 → 2.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.js +1 -8
- package/lib/esm/Candle.d.ts +14 -0
- package/lib/esm/Candle.js +75 -0
- package/lib/esm/RawTradeData.d.ts +6 -0
- package/lib/esm/RawTradeData.js +10 -0
- package/lib/esm/WasmModule.d.ts +24 -0
- package/lib/esm/WasmModule.js +1 -0
- package/lib/esm/index.d.ts +18 -0
- package/lib/esm/index.js +397 -0
- package/lib/esm/package.json +1 -0
- package/lib/index.d.ts +3 -3
- package/lib/index.js +61 -61
- package/package.json +30 -5
package/lib/Candle.js
CHANGED
|
@@ -20,14 +20,7 @@ class Candle {
|
|
|
20
20
|
}
|
|
21
21
|
exports.Candle = Candle;
|
|
22
22
|
function encodeCandle(candle) {
|
|
23
|
-
return new Uint32Array([
|
|
24
|
-
candle.timestamp,
|
|
25
|
-
candle.high,
|
|
26
|
-
candle.low,
|
|
27
|
-
candle.open,
|
|
28
|
-
candle.close,
|
|
29
|
-
candle.volume
|
|
30
|
-
]);
|
|
23
|
+
return new Uint32Array([candle.timestamp, candle.high, candle.low, candle.open, candle.close, candle.volume]);
|
|
31
24
|
}
|
|
32
25
|
exports.encodeCandle = encodeCandle;
|
|
33
26
|
function decodeCandle(buffer) {
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { RawTradeData } from './RawTradeData';
|
|
2
|
+
export declare class Candle {
|
|
3
|
+
timestamp: number;
|
|
4
|
+
high: number;
|
|
5
|
+
low: number;
|
|
6
|
+
open: number;
|
|
7
|
+
close: number;
|
|
8
|
+
volume: number;
|
|
9
|
+
constructor(timestamp: number, high: number, low: number, open: number, close: number, volume: number);
|
|
10
|
+
toString(): string;
|
|
11
|
+
}
|
|
12
|
+
export declare function encodeCandle(candle: Candle): Uint32Array;
|
|
13
|
+
export declare function decodeCandle(buffer: Uint32Array): Candle;
|
|
14
|
+
export declare function generateCandles(data: RawTradeData[], candleSize: string): Candle[];
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
import timestring from 'timestring';
|
|
2
|
+
export class Candle {
|
|
3
|
+
timestamp;
|
|
4
|
+
high;
|
|
5
|
+
low;
|
|
6
|
+
open;
|
|
7
|
+
close;
|
|
8
|
+
volume;
|
|
9
|
+
constructor(timestamp, high, low, open, close, volume) {
|
|
10
|
+
this.timestamp = timestamp;
|
|
11
|
+
this.high = high;
|
|
12
|
+
this.low = low;
|
|
13
|
+
this.open = open;
|
|
14
|
+
this.close = close;
|
|
15
|
+
this.volume = volume;
|
|
16
|
+
}
|
|
17
|
+
toString() {
|
|
18
|
+
return JSON.stringify(this);
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
export function encodeCandle(candle) {
|
|
22
|
+
return new Uint32Array([candle.timestamp, candle.high, candle.low, candle.open, candle.close, candle.volume]);
|
|
23
|
+
}
|
|
24
|
+
export function decodeCandle(buffer) {
|
|
25
|
+
return new Candle(buffer[0], buffer[1], buffer[2], buffer[3], buffer[4], buffer[5]);
|
|
26
|
+
}
|
|
27
|
+
export function generateCandles(data, candleSize) {
|
|
28
|
+
const candleWidth = timestring(candleSize, 'ms', {});
|
|
29
|
+
if (data.length === 0) {
|
|
30
|
+
throw new Error('Input data is empty');
|
|
31
|
+
}
|
|
32
|
+
const _data = data.map((point) => {
|
|
33
|
+
return Object.assign(Object.assign({}, point), {
|
|
34
|
+
// This will convert the timestamp to milliseconds if it's in seconds
|
|
35
|
+
timestamp: point.timestamp && String(point.timestamp).length == 10 ? point.timestamp * 1000 : point.timestamp,
|
|
36
|
+
});
|
|
37
|
+
});
|
|
38
|
+
if (_data[0] === undefined || Object.keys(_data[0]).length === 0) {
|
|
39
|
+
return [];
|
|
40
|
+
}
|
|
41
|
+
const ohlcvData = [];
|
|
42
|
+
let i = 0;
|
|
43
|
+
let currentTimestamp = Math.floor(_data[0].timestamp / candleWidth) * candleWidth;
|
|
44
|
+
let open = _data[0].price;
|
|
45
|
+
let high = _data[0].price;
|
|
46
|
+
let low = _data[0].price;
|
|
47
|
+
let close = _data[0].price;
|
|
48
|
+
let volume = 0.0;
|
|
49
|
+
while (i < _data.length) {
|
|
50
|
+
open = close;
|
|
51
|
+
high = close;
|
|
52
|
+
low = close;
|
|
53
|
+
volume = 0.0;
|
|
54
|
+
let innerI = i;
|
|
55
|
+
while (innerI < _data.length && _data[innerI].timestamp < currentTimestamp + candleWidth) {
|
|
56
|
+
open = innerI === 0 ? _data[innerI].price : open;
|
|
57
|
+
high = Math.max(high, _data[innerI].price);
|
|
58
|
+
low = Math.min(low, _data[innerI].price);
|
|
59
|
+
close = _data[innerI].price;
|
|
60
|
+
volume += _data[innerI].volume;
|
|
61
|
+
innerI++;
|
|
62
|
+
}
|
|
63
|
+
ohlcvData.push({
|
|
64
|
+
timestamp: currentTimestamp,
|
|
65
|
+
high,
|
|
66
|
+
low,
|
|
67
|
+
open,
|
|
68
|
+
close,
|
|
69
|
+
volume,
|
|
70
|
+
});
|
|
71
|
+
currentTimestamp += candleWidth;
|
|
72
|
+
i = innerI;
|
|
73
|
+
}
|
|
74
|
+
return ohlcvData;
|
|
75
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
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(): number;
|
|
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
|
+
declare function reset(): void;
|
|
11
|
+
export type WasmModule = {
|
|
12
|
+
responseHandler: typeof responseHandler;
|
|
13
|
+
initialize: typeof initialize;
|
|
14
|
+
execute: typeof execute;
|
|
15
|
+
config: typeof config;
|
|
16
|
+
version: typeof version;
|
|
17
|
+
transform: typeof transform;
|
|
18
|
+
memory: WebAssembly.Memory;
|
|
19
|
+
__new: typeof __new;
|
|
20
|
+
__pin: typeof __pin;
|
|
21
|
+
__unpin: typeof __unpin;
|
|
22
|
+
reset: typeof reset;
|
|
23
|
+
};
|
|
24
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { Candle } from './Candle';
|
|
2
|
+
import { RawTradeData } from './RawTradeData';
|
|
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
|
+
/**
|
|
13
|
+
* Load a wasm bundle asynchronously. Accepts the actual binary data or file path.
|
|
14
|
+
* @param input - Wasm bundle data or path
|
|
15
|
+
* @param imports - Imports
|
|
16
|
+
* @returns
|
|
17
|
+
*/
|
|
18
|
+
export declare function loadWasm(input: string | ArrayBuffer, imports?: {}): Promise<WasmModule>;
|
package/lib/esm/index.js
ADDED
|
@@ -0,0 +1,397 @@
|
|
|
1
|
+
import { ethers } from 'ethers';
|
|
2
|
+
import { Candle, generateCandles } from './Candle';
|
|
3
|
+
import { RawTradeData } from './RawTradeData';
|
|
4
|
+
let isNode = process || null;
|
|
5
|
+
let fetchImpl = null;
|
|
6
|
+
let fsImpl = null;
|
|
7
|
+
let ccxt = null;
|
|
8
|
+
if (globalThis['fetch'])
|
|
9
|
+
fetchImpl = fetch;
|
|
10
|
+
export { Candle, RawTradeData };
|
|
11
|
+
var State;
|
|
12
|
+
(function (State) {
|
|
13
|
+
State[State["None"] = 0] = "None";
|
|
14
|
+
State[State["Unwinding"] = 1] = "Unwinding";
|
|
15
|
+
State[State["Rewinding"] = 2] = "Rewinding";
|
|
16
|
+
})(State || (State = {}));
|
|
17
|
+
/**
|
|
18
|
+
* Load a wasm bundle synchronously. Only accepts the actual binary data.
|
|
19
|
+
* @param input - Wasm bundle data
|
|
20
|
+
* @param imports - Imports
|
|
21
|
+
* @returns
|
|
22
|
+
*/
|
|
23
|
+
export function loadWasmSync(input, imports = {}) {
|
|
24
|
+
return instantiate(new WebAssembly.Module(input), imports);
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Load a wasm bundle asynchronously. Accepts the actual binary data or file path.
|
|
28
|
+
* @param input - Wasm bundle data or path
|
|
29
|
+
* @param imports - Imports
|
|
30
|
+
* @returns
|
|
31
|
+
*/
|
|
32
|
+
export async function loadWasm(input, imports = {}) {
|
|
33
|
+
const mod = instantiate(await (async () => {
|
|
34
|
+
if (typeof input === 'string') {
|
|
35
|
+
if (isNode) {
|
|
36
|
+
if (!fetchImpl)
|
|
37
|
+
fetchImpl = (await import('undici')).fetch;
|
|
38
|
+
if (!fsImpl)
|
|
39
|
+
fsImpl = await import('fs/promises');
|
|
40
|
+
if (!ccxt)
|
|
41
|
+
ccxt = (await import('ccxt')).default;
|
|
42
|
+
return WebAssembly.compile(await fsImpl.readFile(input));
|
|
43
|
+
}
|
|
44
|
+
return await WebAssembly.compileStreaming(globalThis.fetch(input));
|
|
45
|
+
}
|
|
46
|
+
else {
|
|
47
|
+
return WebAssembly.compile(input);
|
|
48
|
+
}
|
|
49
|
+
})(), imports);
|
|
50
|
+
return mod;
|
|
51
|
+
}
|
|
52
|
+
function instantiate(module, imports = {}) {
|
|
53
|
+
let WASM_MEMORY;
|
|
54
|
+
let WASM_EXPORTS;
|
|
55
|
+
let WASM_DV;
|
|
56
|
+
let ASYNCIFY_PTR = 0;
|
|
57
|
+
let ASYNCIFY_MEM;
|
|
58
|
+
let ASYNCIFY_INITIALIZED = false;
|
|
59
|
+
let fetchFn = null;
|
|
60
|
+
let ccxtFn = null;
|
|
61
|
+
let detachedValue = null;
|
|
62
|
+
const adaptedImports = Object.assign({
|
|
63
|
+
console: {
|
|
64
|
+
log(text) {
|
|
65
|
+
console.log(__liftString(text));
|
|
66
|
+
},
|
|
67
|
+
},
|
|
68
|
+
ethers: {
|
|
69
|
+
keccak256_str(str_ptr) {
|
|
70
|
+
const str = __liftString(str_ptr);
|
|
71
|
+
const hash = ethers.keccak256(str);
|
|
72
|
+
return __lowerString(hash);
|
|
73
|
+
},
|
|
74
|
+
keccak256_buf(buf_ptr) {
|
|
75
|
+
const buf = __liftBuffer(buf_ptr);
|
|
76
|
+
const hash = ethers.keccak256(new Uint8Array(buf));
|
|
77
|
+
return __lowerString(hash);
|
|
78
|
+
},
|
|
79
|
+
},
|
|
80
|
+
// @ts-ignore
|
|
81
|
+
env: {
|
|
82
|
+
abort(message, fileName, lineNumber, columnNumber) {
|
|
83
|
+
(() => {
|
|
84
|
+
throw Error(`${__liftString(message)} in ${__liftString(fileName)}:${lineNumber}:${columnNumber}`);
|
|
85
|
+
})();
|
|
86
|
+
},
|
|
87
|
+
_initAsyncify(frame_ptr, stack_ptr) {
|
|
88
|
+
// @ts-ignore
|
|
89
|
+
if (!WASM_EXPORTS['asyncify_get_state'])
|
|
90
|
+
throw new Error('Asyncify initialized, but not enabled when run! Compile with the --runPasses asyncify flag or asyncify-shim transform!');
|
|
91
|
+
if (ASYNCIFY_INITIALIZED)
|
|
92
|
+
return;
|
|
93
|
+
ASYNCIFY_PTR = frame_ptr;
|
|
94
|
+
ASYNCIFY_MEM[ASYNCIFY_PTR >> 2] = ASYNCIFY_PTR + 8;
|
|
95
|
+
ASYNCIFY_MEM[(ASYNCIFY_PTR + 4) >> 2] = stack_ptr;
|
|
96
|
+
ASYNCIFY_INITIALIZED = true;
|
|
97
|
+
},
|
|
98
|
+
generateCandles(data, candleSize) {
|
|
99
|
+
const _data = __liftString(data) || '[]';
|
|
100
|
+
const _candleSize = __liftString(candleSize) || '69m';
|
|
101
|
+
const candles = generateCandles(JSON.parse(_data), _candleSize);
|
|
102
|
+
return __lowerString(JSON.stringify(candles));
|
|
103
|
+
},
|
|
104
|
+
'console.log': (text) => {
|
|
105
|
+
console.log(__liftString(text));
|
|
106
|
+
},
|
|
107
|
+
ccxt_fetchOHLCV: (exchangeId, symbol, timeframe, limit, since) => {
|
|
108
|
+
// @ts-ignore
|
|
109
|
+
const currentState = WASM_EXPORTS.asyncify_get_state();
|
|
110
|
+
if (currentState === State.Rewinding) {
|
|
111
|
+
// @ts-ignore
|
|
112
|
+
WASM_EXPORTS.asyncify_stop_rewind();
|
|
113
|
+
// @ts-ignore
|
|
114
|
+
const ptr = __lowerStaticArray((pointer, value) => {
|
|
115
|
+
__setU32(pointer, __lowerStaticArray(__setF64, 7, 3, value, Float64Array));
|
|
116
|
+
}, 8, 2, detachedValue);
|
|
117
|
+
return ptr;
|
|
118
|
+
}
|
|
119
|
+
const _exchange = __liftString(exchangeId);
|
|
120
|
+
const _symbol = __liftString(symbol);
|
|
121
|
+
const _timeframe = __liftString(timeframe);
|
|
122
|
+
ccxtFn = async () => {
|
|
123
|
+
if (!_exchange || !_symbol || !_timeframe)
|
|
124
|
+
throw new Error('Exchange, Symbol, or Timeframe not provided when fetching OHCLV data.');
|
|
125
|
+
// @ts-ignore
|
|
126
|
+
const data = await new ccxt[_exchange]({
|
|
127
|
+
apiKey: '',
|
|
128
|
+
secret: '',
|
|
129
|
+
}).fetchOHLCV(_symbol, _timeframe, since, limit);
|
|
130
|
+
return data;
|
|
131
|
+
};
|
|
132
|
+
// @ts-ignore
|
|
133
|
+
WASM_EXPORTS.asyncify_start_unwind(ASYNCIFY_PTR);
|
|
134
|
+
},
|
|
135
|
+
},
|
|
136
|
+
'as-fetch': {
|
|
137
|
+
_initAsyncify(frame_ptr, stack_ptr) {
|
|
138
|
+
// @ts-ignore
|
|
139
|
+
if (!WASM_EXPORTS['asyncify_get_state'])
|
|
140
|
+
throw new Error('Asyncify initialized, but not enabled when run! Compile with the --runPasses asyncify flag or asyncify-shim transform!');
|
|
141
|
+
if (ASYNCIFY_INITIALIZED)
|
|
142
|
+
return;
|
|
143
|
+
ASYNCIFY_PTR = frame_ptr;
|
|
144
|
+
ASYNCIFY_MEM[ASYNCIFY_PTR >> 2] = ASYNCIFY_PTR + 8;
|
|
145
|
+
// I don"t know if I need to reserve all this memory...
|
|
146
|
+
ASYNCIFY_MEM[(ASYNCIFY_PTR + 4) >> 2] = stack_ptr;
|
|
147
|
+
ASYNCIFY_INITIALIZED = true;
|
|
148
|
+
},
|
|
149
|
+
_fetchPOSTSync(url, mode, headers, body) {
|
|
150
|
+
// @ts-ignore
|
|
151
|
+
const currentState = WASM_EXPORTS.asyncify_get_state();
|
|
152
|
+
if (currentState === State.Rewinding) {
|
|
153
|
+
// @ts-ignore
|
|
154
|
+
WASM_EXPORTS.asyncify_stop_rewind();
|
|
155
|
+
const ptr = __lowerBuffer(detachedValue);
|
|
156
|
+
detachedValue = null;
|
|
157
|
+
return ptr;
|
|
158
|
+
}
|
|
159
|
+
fetchFn = async () => {
|
|
160
|
+
const res = await fetchImpl(__liftString(url) || '', {
|
|
161
|
+
method: 'POST',
|
|
162
|
+
mode: modeToString(mode) || 'cors',
|
|
163
|
+
headers: __liftArray((pointer) => __liftArray((pointer) => __liftString(__getU32(pointer)), 2, __getU32(pointer)), 2, headers) || [],
|
|
164
|
+
body: __liftBuffer(body),
|
|
165
|
+
});
|
|
166
|
+
const value = await res.arrayBuffer();
|
|
167
|
+
return value;
|
|
168
|
+
};
|
|
169
|
+
// @ts-ignore
|
|
170
|
+
WASM_EXPORTS.asyncify_start_unwind(ASYNCIFY_PTR);
|
|
171
|
+
},
|
|
172
|
+
_fetchGETSync(url, mode, headers) {
|
|
173
|
+
// @ts-ignore
|
|
174
|
+
const currentState = WASM_EXPORTS.asyncify_get_state();
|
|
175
|
+
if (currentState === State.Rewinding) {
|
|
176
|
+
// @ts-ignore
|
|
177
|
+
WASM_EXPORTS.asyncify_stop_rewind();
|
|
178
|
+
const ptr = __lowerBuffer(detachedValue);
|
|
179
|
+
detachedValue = null;
|
|
180
|
+
return ptr;
|
|
181
|
+
}
|
|
182
|
+
fetchFn = async () => {
|
|
183
|
+
const res = await fetchImpl(__liftString(url) || '', {
|
|
184
|
+
method: 'GET',
|
|
185
|
+
mode: modeToString(mode) || 'cors',
|
|
186
|
+
headers: __liftArray((pointer) => __liftArray((pointer) => __liftString(__getU32(pointer)), 2, __getU32(pointer)), 2, headers) || [],
|
|
187
|
+
});
|
|
188
|
+
const value = await res.arrayBuffer();
|
|
189
|
+
return value;
|
|
190
|
+
};
|
|
191
|
+
// @ts-ignore
|
|
192
|
+
WASM_EXPORTS.asyncify_start_unwind(ASYNCIFY_PTR);
|
|
193
|
+
},
|
|
194
|
+
_fetchGET(url, mode, headers, callbackID) {
|
|
195
|
+
fetchImpl(__liftString(url) || '', {
|
|
196
|
+
method: 'GET',
|
|
197
|
+
mode: modeToString(mode) || 'cors',
|
|
198
|
+
headers: __liftArray((pointer) => __liftArray((pointer) => __liftString(__getU32(pointer)), 2, __getU32(pointer)), 2, headers) || [],
|
|
199
|
+
}).then(async (res) => {
|
|
200
|
+
const body = await res.arrayBuffer();
|
|
201
|
+
WASM_EXPORTS.responseHandler(body, res.status, res.redirected ? 1 : 0, callbackID);
|
|
202
|
+
});
|
|
203
|
+
},
|
|
204
|
+
_fetchPOST(url, mode, headers, body, callbackID) {
|
|
205
|
+
fetchImpl(__liftString(url) || '', {
|
|
206
|
+
method: 'POST',
|
|
207
|
+
mode: modeToString(mode) || 'cors',
|
|
208
|
+
body: body,
|
|
209
|
+
headers: __liftArray((pointer) => __liftArray((pointer) => __liftString(__getU32(pointer)), 2, __getU32(pointer)), 2, headers) || [],
|
|
210
|
+
}).then(async (res) => {
|
|
211
|
+
const body = await res.arrayBuffer();
|
|
212
|
+
WASM_EXPORTS.responseHandler(body, res.status, res.redirected ? 1 : 0, callbackID);
|
|
213
|
+
});
|
|
214
|
+
},
|
|
215
|
+
},
|
|
216
|
+
}, imports);
|
|
217
|
+
const mod = new WebAssembly.Instance(module, adaptedImports);
|
|
218
|
+
WASM_EXPORTS = mod.exports;
|
|
219
|
+
// @ts-ignore
|
|
220
|
+
WASM_MEMORY = WASM_EXPORTS.memory || adaptedImports.env.memory;
|
|
221
|
+
ASYNCIFY_MEM = new Uint32Array(WASM_MEMORY.buffer);
|
|
222
|
+
const handledExports = Object.setPrototypeOf({
|
|
223
|
+
responseHandler(body, statusCode, redirected, callbackID) {
|
|
224
|
+
if (!WASM_EXPORTS['responseHandler'])
|
|
225
|
+
throw new Error('Unable to call .responseHandler on wasm module. Add the line export { responseHandler } from "as-fetch/assembly" to your entry file.');
|
|
226
|
+
// @ts-ignore
|
|
227
|
+
WASM_EXPORTS.responseHandler(__lowerBuffer(body), statusCode, redirected ? 1 : 0, callbackID);
|
|
228
|
+
},
|
|
229
|
+
initialize(config) {
|
|
230
|
+
if (!WASM_EXPORTS['initialize'])
|
|
231
|
+
throw new Error('Unable to call .initialize on wasm module. Are you sure this is a data connector?');
|
|
232
|
+
try {
|
|
233
|
+
// @ts-ignore
|
|
234
|
+
WASM_EXPORTS.initialize(__lowerString(config));
|
|
235
|
+
return true;
|
|
236
|
+
}
|
|
237
|
+
catch (e) {
|
|
238
|
+
console.error(e);
|
|
239
|
+
return false;
|
|
240
|
+
}
|
|
241
|
+
},
|
|
242
|
+
async execute(...params) {
|
|
243
|
+
if (!WASM_EXPORTS['execute'])
|
|
244
|
+
throw new Error('Unable to call .execute on wasm module. Are you sure this is a data connector?');
|
|
245
|
+
const loweredArgs = new Array(params.length);
|
|
246
|
+
for (let i = 0; i < params.length; i++) {
|
|
247
|
+
loweredArgs[i] = __lower(params[i]);
|
|
248
|
+
}
|
|
249
|
+
let result = WASM_EXPORTS.execute(...loweredArgs);
|
|
250
|
+
if (ASYNCIFY_INITIALIZED) {
|
|
251
|
+
// @ts-ignore
|
|
252
|
+
while (WASM_EXPORTS.asyncify_get_state() === State.Unwinding) {
|
|
253
|
+
// @ts-ignore
|
|
254
|
+
WASM_EXPORTS.asyncify_stop_unwind();
|
|
255
|
+
if (fetchFn)
|
|
256
|
+
detachedValue = await fetchFn();
|
|
257
|
+
if (ccxtFn)
|
|
258
|
+
detachedValue = await ccxtFn();
|
|
259
|
+
// @ts-ignore
|
|
260
|
+
WASM_EXPORTS.asyncify_start_rewind(ASYNCIFY_PTR);
|
|
261
|
+
result = WASM_EXPORTS.execute();
|
|
262
|
+
}
|
|
263
|
+
}
|
|
264
|
+
if (fetchFn)
|
|
265
|
+
fetchFn = null;
|
|
266
|
+
if (ccxtFn)
|
|
267
|
+
ccxtFn = null;
|
|
268
|
+
// @ts-ignore
|
|
269
|
+
return __liftString(result);
|
|
270
|
+
},
|
|
271
|
+
config() {
|
|
272
|
+
if (!WASM_EXPORTS['config'])
|
|
273
|
+
throw new Error('Unable to call .config on wasm module. Are you sure this is a data connector?');
|
|
274
|
+
return __liftString(WASM_EXPORTS.config());
|
|
275
|
+
},
|
|
276
|
+
transform() {
|
|
277
|
+
if (!WASM_EXPORTS['transform'])
|
|
278
|
+
throw new Error('Unable to call .transform on wasm module. Are you sure this is a data connector?');
|
|
279
|
+
return __liftString(WASM_EXPORTS.transform());
|
|
280
|
+
},
|
|
281
|
+
reset() {
|
|
282
|
+
if (WASM_EXPORTS['reset'])
|
|
283
|
+
WASM_EXPORTS.reset();
|
|
284
|
+
},
|
|
285
|
+
}, WASM_EXPORTS);
|
|
286
|
+
WASM_DV = new DataView(WASM_MEMORY.buffer);
|
|
287
|
+
function __lower(val) {
|
|
288
|
+
if (typeof val === 'number') {
|
|
289
|
+
return val;
|
|
290
|
+
}
|
|
291
|
+
else if (typeof val === 'string') {
|
|
292
|
+
return __lowerString(val);
|
|
293
|
+
}
|
|
294
|
+
else if (val instanceof ArrayBuffer) {
|
|
295
|
+
return __lowerBuffer(val);
|
|
296
|
+
}
|
|
297
|
+
else {
|
|
298
|
+
return 0;
|
|
299
|
+
}
|
|
300
|
+
}
|
|
301
|
+
function __liftString(ptr) {
|
|
302
|
+
if (!ptr)
|
|
303
|
+
return null;
|
|
304
|
+
const end = (ptr + new Uint32Array(WASM_MEMORY.buffer)[(ptr - 4) >>> 2]) >>> 1;
|
|
305
|
+
const memoryU16 = new Uint16Array(WASM_MEMORY.buffer);
|
|
306
|
+
let start = ptr >>> 1;
|
|
307
|
+
let string = '';
|
|
308
|
+
while (end - start > 1024)
|
|
309
|
+
string += String.fromCharCode(...memoryU16.subarray(start, (start += 1024)));
|
|
310
|
+
return string + String.fromCharCode(...memoryU16.subarray(start, end));
|
|
311
|
+
}
|
|
312
|
+
function __lowerString(value) {
|
|
313
|
+
if (value == null)
|
|
314
|
+
return 0;
|
|
315
|
+
const length = value.length;
|
|
316
|
+
const ptr = WASM_EXPORTS.__pin(WASM_EXPORTS.__new(length << 1, 2) >>> 0);
|
|
317
|
+
const memoryU16 = new Uint16Array(WASM_MEMORY.buffer);
|
|
318
|
+
for (let i = 0; i < length; ++i)
|
|
319
|
+
memoryU16[(ptr >>> 1) + i] = value.charCodeAt(i);
|
|
320
|
+
return ptr;
|
|
321
|
+
}
|
|
322
|
+
function __liftBuffer(ptr) {
|
|
323
|
+
if (!ptr)
|
|
324
|
+
return null;
|
|
325
|
+
return WASM_MEMORY.buffer.slice(ptr, ptr + new Uint32Array(WASM_MEMORY.buffer)[(ptr - 4) >>> 2]);
|
|
326
|
+
}
|
|
327
|
+
function __lowerBuffer(value) {
|
|
328
|
+
if (value == null)
|
|
329
|
+
return 0;
|
|
330
|
+
const ptr = WASM_EXPORTS.__pin(WASM_EXPORTS.__new(value.byteLength, 1) >>> 0);
|
|
331
|
+
new Uint8Array(WASM_MEMORY.buffer).set(new Uint8Array(value), ptr);
|
|
332
|
+
return ptr;
|
|
333
|
+
}
|
|
334
|
+
function __liftArray(liftElement, align, ptr) {
|
|
335
|
+
if (!ptr)
|
|
336
|
+
return null;
|
|
337
|
+
const dataStart = __getU32(ptr + 4);
|
|
338
|
+
const length = WASM_DV.getUint32(ptr + 12, true);
|
|
339
|
+
const values = new Array(length);
|
|
340
|
+
for (let i = 0; i < length; ++i)
|
|
341
|
+
values[i] = liftElement(dataStart + ((i << align) >>> 0));
|
|
342
|
+
return values;
|
|
343
|
+
}
|
|
344
|
+
function __lowerStaticArray(lowerElement, id, align, values, typedConstructor = null) {
|
|
345
|
+
if (values == null)
|
|
346
|
+
return 0;
|
|
347
|
+
const length = values.length;
|
|
348
|
+
const buffer = WASM_EXPORTS.__pin(WASM_EXPORTS.__new(length << align, id)) >>> 0;
|
|
349
|
+
if (typedConstructor) {
|
|
350
|
+
new typedConstructor(WASM_MEMORY.buffer, buffer, length).set(values);
|
|
351
|
+
}
|
|
352
|
+
else {
|
|
353
|
+
for (let i = 0; i < length; i++)
|
|
354
|
+
lowerElement(buffer + ((i << align) >>> 0), values[i]);
|
|
355
|
+
}
|
|
356
|
+
return buffer;
|
|
357
|
+
}
|
|
358
|
+
function __setU32(ptr, value) {
|
|
359
|
+
try {
|
|
360
|
+
WASM_DV.setUint32(ptr, value, true);
|
|
361
|
+
}
|
|
362
|
+
catch {
|
|
363
|
+
WASM_DV = new DataView(WASM_MEMORY.buffer);
|
|
364
|
+
WASM_DV.setUint32(ptr, value, true);
|
|
365
|
+
}
|
|
366
|
+
}
|
|
367
|
+
function __setF64(ptr, value) {
|
|
368
|
+
try {
|
|
369
|
+
WASM_DV.setFloat64(ptr, value, true);
|
|
370
|
+
}
|
|
371
|
+
catch {
|
|
372
|
+
WASM_DV = new DataView(WASM_MEMORY.buffer);
|
|
373
|
+
WASM_DV.setFloat64(ptr, value, true);
|
|
374
|
+
}
|
|
375
|
+
}
|
|
376
|
+
function __getU32(ptr) {
|
|
377
|
+
try {
|
|
378
|
+
return WASM_DV.getUint32(ptr, true);
|
|
379
|
+
}
|
|
380
|
+
catch {
|
|
381
|
+
WASM_DV = new DataView(WASM_MEMORY.buffer);
|
|
382
|
+
return WASM_DV.getUint32(ptr, true);
|
|
383
|
+
}
|
|
384
|
+
}
|
|
385
|
+
return handledExports;
|
|
386
|
+
}
|
|
387
|
+
function modeToString(mode) {
|
|
388
|
+
if (mode == 1)
|
|
389
|
+
return 'cors';
|
|
390
|
+
if (mode == 2)
|
|
391
|
+
return 'no-cors';
|
|
392
|
+
if (mode == 3)
|
|
393
|
+
return 'same-origin';
|
|
394
|
+
if (mode == 4)
|
|
395
|
+
return 'navigate';
|
|
396
|
+
return null;
|
|
397
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"type": "module"}
|
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
|
@@ -42,7 +42,7 @@ let isNode = process || null;
|
|
|
42
42
|
let fetchImpl = null;
|
|
43
43
|
let fsImpl = null;
|
|
44
44
|
let ccxt = null;
|
|
45
|
-
if (globalThis[
|
|
45
|
+
if (globalThis['fetch'])
|
|
46
46
|
fetchImpl = fetch;
|
|
47
47
|
var State;
|
|
48
48
|
(function (State) {
|
|
@@ -69,14 +69,14 @@ exports.loadWasmSync = loadWasmSync;
|
|
|
69
69
|
function loadWasm(input, imports = {}) {
|
|
70
70
|
return __awaiter(this, void 0, void 0, function* () {
|
|
71
71
|
const mod = instantiate(yield (() => __awaiter(this, void 0, void 0, function* () {
|
|
72
|
-
if (typeof input ===
|
|
72
|
+
if (typeof input === 'string') {
|
|
73
73
|
if (isNode) {
|
|
74
74
|
if (!fetchImpl)
|
|
75
|
-
fetchImpl = (yield Promise.resolve().then(() => __importStar(require(
|
|
75
|
+
fetchImpl = (yield Promise.resolve().then(() => __importStar(require('undici')))).fetch;
|
|
76
76
|
if (!fsImpl)
|
|
77
|
-
fsImpl = yield Promise.resolve().then(() => __importStar(require(
|
|
77
|
+
fsImpl = yield Promise.resolve().then(() => __importStar(require('fs/promises')));
|
|
78
78
|
if (!ccxt)
|
|
79
|
-
ccxt = (yield Promise.resolve().then(() => __importStar(require(
|
|
79
|
+
ccxt = (yield Promise.resolve().then(() => __importStar(require('ccxt')))).default;
|
|
80
80
|
return WebAssembly.compile(yield fsImpl.readFile(input));
|
|
81
81
|
}
|
|
82
82
|
return yield WebAssembly.compileStreaming(globalThis.fetch(input));
|
|
@@ -115,7 +115,7 @@ function instantiate(module, imports = {}) {
|
|
|
115
115
|
const buf = __liftBuffer(buf_ptr);
|
|
116
116
|
const hash = ethers_1.ethers.keccak256(new Uint8Array(buf));
|
|
117
117
|
return __lowerString(hash);
|
|
118
|
-
}
|
|
118
|
+
},
|
|
119
119
|
},
|
|
120
120
|
// @ts-ignore
|
|
121
121
|
env: {
|
|
@@ -126,8 +126,8 @@ function instantiate(module, imports = {}) {
|
|
|
126
126
|
},
|
|
127
127
|
_initAsyncify(frame_ptr, stack_ptr) {
|
|
128
128
|
// @ts-ignore
|
|
129
|
-
if (!WASM_EXPORTS[
|
|
130
|
-
throw new Error(
|
|
129
|
+
if (!WASM_EXPORTS['asyncify_get_state'])
|
|
130
|
+
throw new Error('Asyncify initialized, but not enabled when run! Compile with the --runPasses asyncify flag or asyncify-shim transform!');
|
|
131
131
|
if (ASYNCIFY_INITIALIZED)
|
|
132
132
|
return;
|
|
133
133
|
ASYNCIFY_PTR = frame_ptr;
|
|
@@ -136,12 +136,12 @@ function instantiate(module, imports = {}) {
|
|
|
136
136
|
ASYNCIFY_INITIALIZED = true;
|
|
137
137
|
},
|
|
138
138
|
generateCandles(data, candleSize) {
|
|
139
|
-
const _data = __liftString(data) ||
|
|
140
|
-
const _candleSize = __liftString(candleSize) ||
|
|
139
|
+
const _data = __liftString(data) || '[]';
|
|
140
|
+
const _candleSize = __liftString(candleSize) || '69m';
|
|
141
141
|
const candles = (0, Candle_1.generateCandles)(JSON.parse(_data), _candleSize);
|
|
142
142
|
return __lowerString(JSON.stringify(candles));
|
|
143
143
|
},
|
|
144
|
-
|
|
144
|
+
'console.log': (text) => {
|
|
145
145
|
console.log(__liftString(text));
|
|
146
146
|
},
|
|
147
147
|
ccxt_fetchOHLCV: (exchangeId, symbol, timeframe, limit, since) => {
|
|
@@ -159,25 +159,25 @@ function instantiate(module, imports = {}) {
|
|
|
159
159
|
const _exchange = __liftString(exchangeId);
|
|
160
160
|
const _symbol = __liftString(symbol);
|
|
161
161
|
const _timeframe = __liftString(timeframe);
|
|
162
|
-
ccxtFn = (
|
|
162
|
+
ccxtFn = () => __awaiter(this, void 0, void 0, function* () {
|
|
163
163
|
if (!_exchange || !_symbol || !_timeframe)
|
|
164
|
-
throw new Error(
|
|
164
|
+
throw new Error('Exchange, Symbol, or Timeframe not provided when fetching OHCLV data.');
|
|
165
165
|
// @ts-ignore
|
|
166
166
|
const data = yield new ccxt[_exchange]({
|
|
167
|
-
apiKey:
|
|
168
|
-
secret:
|
|
167
|
+
apiKey: '',
|
|
168
|
+
secret: '',
|
|
169
169
|
}).fetchOHLCV(_symbol, _timeframe, since, limit);
|
|
170
170
|
return data;
|
|
171
|
-
})
|
|
171
|
+
});
|
|
172
172
|
// @ts-ignore
|
|
173
173
|
WASM_EXPORTS.asyncify_start_unwind(ASYNCIFY_PTR);
|
|
174
|
-
}
|
|
174
|
+
},
|
|
175
175
|
},
|
|
176
|
-
|
|
176
|
+
'as-fetch': {
|
|
177
177
|
_initAsyncify(frame_ptr, stack_ptr) {
|
|
178
178
|
// @ts-ignore
|
|
179
|
-
if (!WASM_EXPORTS[
|
|
180
|
-
throw new Error(
|
|
179
|
+
if (!WASM_EXPORTS['asyncify_get_state'])
|
|
180
|
+
throw new Error('Asyncify initialized, but not enabled when run! Compile with the --runPasses asyncify flag or asyncify-shim transform!');
|
|
181
181
|
if (ASYNCIFY_INITIALIZED)
|
|
182
182
|
return;
|
|
183
183
|
ASYNCIFY_PTR = frame_ptr;
|
|
@@ -196,16 +196,16 @@ function instantiate(module, imports = {}) {
|
|
|
196
196
|
detachedValue = null;
|
|
197
197
|
return ptr;
|
|
198
198
|
}
|
|
199
|
-
fetchFn = (
|
|
200
|
-
const res = yield fetchImpl(__liftString(url) ||
|
|
201
|
-
method:
|
|
202
|
-
mode: modeToString(mode) ||
|
|
199
|
+
fetchFn = () => __awaiter(this, void 0, void 0, function* () {
|
|
200
|
+
const res = yield fetchImpl(__liftString(url) || '', {
|
|
201
|
+
method: 'POST',
|
|
202
|
+
mode: modeToString(mode) || 'cors',
|
|
203
203
|
headers: __liftArray((pointer) => __liftArray((pointer) => __liftString(__getU32(pointer)), 2, __getU32(pointer)), 2, headers) || [],
|
|
204
|
-
body: __liftBuffer(body)
|
|
204
|
+
body: __liftBuffer(body),
|
|
205
205
|
});
|
|
206
206
|
const value = yield res.arrayBuffer();
|
|
207
207
|
return value;
|
|
208
|
-
})
|
|
208
|
+
});
|
|
209
209
|
// @ts-ignore
|
|
210
210
|
WASM_EXPORTS.asyncify_start_unwind(ASYNCIFY_PTR);
|
|
211
211
|
},
|
|
@@ -219,22 +219,22 @@ function instantiate(module, imports = {}) {
|
|
|
219
219
|
detachedValue = null;
|
|
220
220
|
return ptr;
|
|
221
221
|
}
|
|
222
|
-
fetchFn = (
|
|
223
|
-
const res = yield fetchImpl(__liftString(url) ||
|
|
224
|
-
method:
|
|
225
|
-
mode: modeToString(mode) ||
|
|
222
|
+
fetchFn = () => __awaiter(this, void 0, void 0, function* () {
|
|
223
|
+
const res = yield fetchImpl(__liftString(url) || '', {
|
|
224
|
+
method: 'GET',
|
|
225
|
+
mode: modeToString(mode) || 'cors',
|
|
226
226
|
headers: __liftArray((pointer) => __liftArray((pointer) => __liftString(__getU32(pointer)), 2, __getU32(pointer)), 2, headers) || [],
|
|
227
227
|
});
|
|
228
228
|
const value = yield res.arrayBuffer();
|
|
229
229
|
return value;
|
|
230
|
-
})
|
|
230
|
+
});
|
|
231
231
|
// @ts-ignore
|
|
232
232
|
WASM_EXPORTS.asyncify_start_unwind(ASYNCIFY_PTR);
|
|
233
233
|
},
|
|
234
234
|
_fetchGET(url, mode, headers, callbackID) {
|
|
235
|
-
fetchImpl(__liftString(url) ||
|
|
236
|
-
method:
|
|
237
|
-
mode: modeToString(mode) ||
|
|
235
|
+
fetchImpl(__liftString(url) || '', {
|
|
236
|
+
method: 'GET',
|
|
237
|
+
mode: modeToString(mode) || 'cors',
|
|
238
238
|
headers: __liftArray((pointer) => __liftArray((pointer) => __liftString(__getU32(pointer)), 2, __getU32(pointer)), 2, headers) || [],
|
|
239
239
|
}).then((res) => __awaiter(this, void 0, void 0, function* () {
|
|
240
240
|
const body = yield res.arrayBuffer();
|
|
@@ -242,9 +242,9 @@ function instantiate(module, imports = {}) {
|
|
|
242
242
|
}));
|
|
243
243
|
},
|
|
244
244
|
_fetchPOST(url, mode, headers, body, callbackID) {
|
|
245
|
-
fetchImpl(__liftString(url) ||
|
|
246
|
-
method:
|
|
247
|
-
mode: modeToString(mode) ||
|
|
245
|
+
fetchImpl(__liftString(url) || '', {
|
|
246
|
+
method: 'POST',
|
|
247
|
+
mode: modeToString(mode) || 'cors',
|
|
248
248
|
body: body,
|
|
249
249
|
headers: __liftArray((pointer) => __liftArray((pointer) => __liftString(__getU32(pointer)), 2, __getU32(pointer)), 2, headers) || [],
|
|
250
250
|
}).then((res) => __awaiter(this, void 0, void 0, function* () {
|
|
@@ -261,14 +261,14 @@ function instantiate(module, imports = {}) {
|
|
|
261
261
|
ASYNCIFY_MEM = new Uint32Array(WASM_MEMORY.buffer);
|
|
262
262
|
const handledExports = Object.setPrototypeOf({
|
|
263
263
|
responseHandler(body, statusCode, redirected, callbackID) {
|
|
264
|
-
if (!WASM_EXPORTS[
|
|
265
|
-
throw new Error(
|
|
264
|
+
if (!WASM_EXPORTS['responseHandler'])
|
|
265
|
+
throw new Error('Unable to call .responseHandler on wasm module. Add the line export { responseHandler } from "as-fetch/assembly" to your entry file.');
|
|
266
266
|
// @ts-ignore
|
|
267
267
|
WASM_EXPORTS.responseHandler(__lowerBuffer(body), statusCode, redirected ? 1 : 0, callbackID);
|
|
268
268
|
},
|
|
269
269
|
initialize(config) {
|
|
270
|
-
if (!WASM_EXPORTS[
|
|
271
|
-
throw new Error(
|
|
270
|
+
if (!WASM_EXPORTS['initialize'])
|
|
271
|
+
throw new Error('Unable to call .initialize on wasm module. Are you sure this is a data connector?');
|
|
272
272
|
try {
|
|
273
273
|
// @ts-ignore
|
|
274
274
|
WASM_EXPORTS.initialize(__lowerString(config));
|
|
@@ -281,8 +281,8 @@ function instantiate(module, imports = {}) {
|
|
|
281
281
|
},
|
|
282
282
|
execute(...params) {
|
|
283
283
|
return __awaiter(this, void 0, void 0, function* () {
|
|
284
|
-
if (!WASM_EXPORTS[
|
|
285
|
-
throw new Error(
|
|
284
|
+
if (!WASM_EXPORTS['execute'])
|
|
285
|
+
throw new Error('Unable to call .execute on wasm module. Are you sure this is a data connector?');
|
|
286
286
|
const loweredArgs = new Array(params.length);
|
|
287
287
|
for (let i = 0; i < params.length; i++) {
|
|
288
288
|
loweredArgs[i] = __lower(params[i]);
|
|
@@ -311,26 +311,26 @@ function instantiate(module, imports = {}) {
|
|
|
311
311
|
});
|
|
312
312
|
},
|
|
313
313
|
config() {
|
|
314
|
-
if (!WASM_EXPORTS[
|
|
315
|
-
throw new Error(
|
|
314
|
+
if (!WASM_EXPORTS['config'])
|
|
315
|
+
throw new Error('Unable to call .config on wasm module. Are you sure this is a data connector?');
|
|
316
316
|
return __liftString(WASM_EXPORTS.config());
|
|
317
317
|
},
|
|
318
318
|
transform() {
|
|
319
|
-
if (!WASM_EXPORTS[
|
|
320
|
-
throw new Error(
|
|
319
|
+
if (!WASM_EXPORTS['transform'])
|
|
320
|
+
throw new Error('Unable to call .transform on wasm module. Are you sure this is a data connector?');
|
|
321
321
|
return __liftString(WASM_EXPORTS.transform());
|
|
322
322
|
},
|
|
323
323
|
reset() {
|
|
324
|
-
if (WASM_EXPORTS[
|
|
324
|
+
if (WASM_EXPORTS['reset'])
|
|
325
325
|
WASM_EXPORTS.reset();
|
|
326
|
-
}
|
|
326
|
+
},
|
|
327
327
|
}, WASM_EXPORTS);
|
|
328
328
|
WASM_DV = new DataView(WASM_MEMORY.buffer);
|
|
329
329
|
function __lower(val) {
|
|
330
|
-
if (typeof val ===
|
|
330
|
+
if (typeof val === 'number') {
|
|
331
331
|
return val;
|
|
332
332
|
}
|
|
333
|
-
else if (typeof val ===
|
|
333
|
+
else if (typeof val === 'string') {
|
|
334
334
|
return __lowerString(val);
|
|
335
335
|
}
|
|
336
336
|
else if (val instanceof ArrayBuffer) {
|
|
@@ -343,12 +343,12 @@ function instantiate(module, imports = {}) {
|
|
|
343
343
|
function __liftString(ptr) {
|
|
344
344
|
if (!ptr)
|
|
345
345
|
return null;
|
|
346
|
-
const end = ptr + new Uint32Array(WASM_MEMORY.buffer)[ptr - 4 >>> 2] >>> 1;
|
|
346
|
+
const end = (ptr + new Uint32Array(WASM_MEMORY.buffer)[(ptr - 4) >>> 2]) >>> 1;
|
|
347
347
|
const memoryU16 = new Uint16Array(WASM_MEMORY.buffer);
|
|
348
348
|
let start = ptr >>> 1;
|
|
349
|
-
let string =
|
|
349
|
+
let string = '';
|
|
350
350
|
while (end - start > 1024)
|
|
351
|
-
string += String.fromCharCode(...memoryU16.subarray(start, start += 1024));
|
|
351
|
+
string += String.fromCharCode(...memoryU16.subarray(start, (start += 1024)));
|
|
352
352
|
return string + String.fromCharCode(...memoryU16.subarray(start, end));
|
|
353
353
|
}
|
|
354
354
|
function __lowerString(value) {
|
|
@@ -364,7 +364,7 @@ function instantiate(module, imports = {}) {
|
|
|
364
364
|
function __liftBuffer(ptr) {
|
|
365
365
|
if (!ptr)
|
|
366
366
|
return null;
|
|
367
|
-
return WASM_MEMORY.buffer.slice(ptr, ptr + new Uint32Array(WASM_MEMORY.buffer)[ptr - 4 >>> 2]);
|
|
367
|
+
return WASM_MEMORY.buffer.slice(ptr, ptr + new Uint32Array(WASM_MEMORY.buffer)[(ptr - 4) >>> 2]);
|
|
368
368
|
}
|
|
369
369
|
function __lowerBuffer(value) {
|
|
370
370
|
if (value == null)
|
|
@@ -380,7 +380,7 @@ function instantiate(module, imports = {}) {
|
|
|
380
380
|
const length = WASM_DV.getUint32(ptr + 12, true);
|
|
381
381
|
const values = new Array(length);
|
|
382
382
|
for (let i = 0; i < length; ++i)
|
|
383
|
-
values[i] = liftElement(dataStart + (i << align >>> 0));
|
|
383
|
+
values[i] = liftElement(dataStart + ((i << align) >>> 0));
|
|
384
384
|
return values;
|
|
385
385
|
}
|
|
386
386
|
function __lowerStaticArray(lowerElement, id, align, values, typedConstructor = null) {
|
|
@@ -393,7 +393,7 @@ function instantiate(module, imports = {}) {
|
|
|
393
393
|
}
|
|
394
394
|
else {
|
|
395
395
|
for (let i = 0; i < length; i++)
|
|
396
|
-
lowerElement(buffer + (i << align >>> 0), values[i]);
|
|
396
|
+
lowerElement(buffer + ((i << align) >>> 0), values[i]);
|
|
397
397
|
}
|
|
398
398
|
return buffer;
|
|
399
399
|
}
|
|
@@ -428,12 +428,12 @@ function instantiate(module, imports = {}) {
|
|
|
428
428
|
}
|
|
429
429
|
function modeToString(mode) {
|
|
430
430
|
if (mode == 1)
|
|
431
|
-
return
|
|
431
|
+
return 'cors';
|
|
432
432
|
if (mode == 2)
|
|
433
|
-
return
|
|
433
|
+
return 'no-cors';
|
|
434
434
|
if (mode == 3)
|
|
435
|
-
return
|
|
435
|
+
return 'same-origin';
|
|
436
436
|
if (mode == 4)
|
|
437
|
-
return
|
|
437
|
+
return 'navigate';
|
|
438
438
|
return null;
|
|
439
439
|
}
|
package/package.json
CHANGED
|
@@ -1,11 +1,26 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@steerprotocol/app-loader",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "2.0.0",
|
|
4
4
|
"description": "App Loader for Steer Protocol",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
|
+
"module": "lib/esm/index.js",
|
|
6
7
|
"types": "lib/index.d.ts",
|
|
8
|
+
"exports": {
|
|
9
|
+
".": {
|
|
10
|
+
"types": "./lib/index.d.ts",
|
|
11
|
+
"import": "./lib/esm/index.js",
|
|
12
|
+
"require": "./lib/index.js"
|
|
13
|
+
},
|
|
14
|
+
"./*": "./lib/*"
|
|
15
|
+
},
|
|
16
|
+
"publishConfig": {
|
|
17
|
+
"access": "public"
|
|
18
|
+
},
|
|
7
19
|
"scripts": {
|
|
8
|
-
"build": "
|
|
20
|
+
"build": "rm -rf lib && npm run build:cjs && npm run build:esm && npm run build:post",
|
|
21
|
+
"build:cjs": "tsc",
|
|
22
|
+
"build:esm": "tsc -p tsconfig.esm.json",
|
|
23
|
+
"build:post": "echo '{\"type\": \"module\"}' > lib/esm/package.json",
|
|
9
24
|
"format": "prettier --write \"src/**/*.(js|ts)\"",
|
|
10
25
|
"lint": "eslint src --ext .js,.ts",
|
|
11
26
|
"lint:fix": "eslint src --fix --ext .js,.ts",
|
|
@@ -18,7 +33,7 @@
|
|
|
18
33
|
},
|
|
19
34
|
"repository": {
|
|
20
35
|
"type": "git",
|
|
21
|
-
"url": "git+https://github.com/
|
|
36
|
+
"url": "git+https://github.com/SteerProtocol/app-loader.git"
|
|
22
37
|
},
|
|
23
38
|
"keywords": [
|
|
24
39
|
"boilerplate",
|
|
@@ -26,11 +41,20 @@
|
|
|
26
41
|
],
|
|
27
42
|
"author": "Hebert Cisco",
|
|
28
43
|
"license": "MIT",
|
|
44
|
+
"release": {
|
|
45
|
+
"branches": [
|
|
46
|
+
"main"
|
|
47
|
+
]
|
|
48
|
+
},
|
|
29
49
|
"bugs": {
|
|
30
|
-
"url": "https://github.com/
|
|
50
|
+
"url": "https://github.com/SteerProtocol/app-loader/issues"
|
|
31
51
|
},
|
|
32
|
-
"homepage": "https://github.com/
|
|
52
|
+
"homepage": "https://github.com/SteerProtocol/app-loader#readme",
|
|
33
53
|
"devDependencies": {
|
|
54
|
+
"@semantic-release/commit-analyzer": "^13.0.1",
|
|
55
|
+
"@semantic-release/github": "^12.0.2",
|
|
56
|
+
"@semantic-release/npm": "^13.1.3",
|
|
57
|
+
"@semantic-release/release-notes-generator": "^14.1.0",
|
|
34
58
|
"@types/jest": "29.5.6",
|
|
35
59
|
"@types/timestring": "^6.0.4",
|
|
36
60
|
"@typescript-eslint/eslint-plugin": "6.8.0",
|
|
@@ -39,6 +63,7 @@
|
|
|
39
63
|
"eslint-plugin-jest": "27.4.2",
|
|
40
64
|
"jest": "29.7.0",
|
|
41
65
|
"prettier": "3.0.3",
|
|
66
|
+
"semantic-release": "^24.2.9",
|
|
42
67
|
"ts-jest": "29.1.1",
|
|
43
68
|
"typescript": "5.2.2"
|
|
44
69
|
},
|