@steerprotocol/app-loader 2.1.1 → 3.0.1
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/README.md +141 -1
- package/lib/WasmModule-D9evRq1D.d.mts +74 -0
- package/lib/WasmModule-D9evRq1D.d.ts +74 -0
- package/lib/browser.mjs +757 -0
- package/lib/browser.mjs.map +1 -0
- package/lib/index.cjs +821 -0
- package/lib/index.cjs.map +1 -0
- package/lib/index.d.mts +24 -0
- package/lib/index.d.ts +14 -8
- package/lib/index.mjs +798 -0
- package/lib/index.mjs.map +1 -0
- package/lib/node.cjs +805 -0
- package/lib/node.cjs.map +1 -0
- package/lib/node.d.mts +23 -0
- package/lib/node.d.ts +23 -0
- package/lib/node.mjs +765 -0
- package/lib/node.mjs.map +1 -0
- package/package.json +27 -13
- package/lib/Candle.d.ts +0 -14
- package/lib/Candle.js +0 -79
- package/lib/RawTradeData.d.ts +0 -6
- package/lib/RawTradeData.js +0 -11
- package/lib/WasmModule.d.ts +0 -24
- package/lib/WasmModule.js +0 -2
- package/lib/esm/Candle.d.ts +0 -14
- package/lib/esm/Candle.js +0 -75
- package/lib/esm/RawTradeData.d.ts +0 -6
- package/lib/esm/RawTradeData.js +0 -10
- package/lib/esm/WasmModule.d.ts +0 -24
- package/lib/esm/WasmModule.js +0 -1
- package/lib/esm/index.d.ts +0 -18
- package/lib/esm/index.js +0 -397
- package/lib/esm/package.json +0 -1
- package/lib/esm/timestring.d.ts +0 -9
- package/lib/esm/timestring.js +0 -83
- package/lib/index.js +0 -439
- package/lib/timestring.d.ts +0 -9
- package/lib/timestring.js +0 -86
package/README.md
CHANGED
|
@@ -1 +1,141 @@
|
|
|
1
|
-
# Steer Protocol App Loader
|
|
1
|
+
# Steer Protocol App Loader
|
|
2
|
+
|
|
3
|
+
Load and execute Steer wasm bundles in Node.js and browser environments.
|
|
4
|
+
|
|
5
|
+
Node 18+ is required.
|
|
6
|
+
|
|
7
|
+
## Install
|
|
8
|
+
|
|
9
|
+
```bash
|
|
10
|
+
npm install @steerprotocol/app-loader
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
## Runtime Support
|
|
14
|
+
|
|
15
|
+
- Root import `@steerprotocol/app-loader`
|
|
16
|
+
- Node: resolves to the Node entrypoint
|
|
17
|
+
- Browser bundlers: resolves to the browser entrypoint through the `browser` export condition
|
|
18
|
+
- Explicit browser import: `@steerprotocol/app-loader/browser`
|
|
19
|
+
- Explicit Node import: `@steerprotocol/app-loader/node`
|
|
20
|
+
|
|
21
|
+
## Usage
|
|
22
|
+
|
|
23
|
+
### Node
|
|
24
|
+
|
|
25
|
+
Use the root import for typical Node usage.
|
|
26
|
+
|
|
27
|
+
```ts
|
|
28
|
+
import { loadWasm } from '@steerprotocol/app-loader';
|
|
29
|
+
|
|
30
|
+
const bundle = await loadWasm('/absolute/path/to/bundle.wasm');
|
|
31
|
+
bundle.initialize('{"example":true}');
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
Node supports:
|
|
35
|
+
|
|
36
|
+
- filesystem paths
|
|
37
|
+
- `ArrayBuffer`
|
|
38
|
+
- remote URLs
|
|
39
|
+
|
|
40
|
+
Node runtime note:
|
|
41
|
+
|
|
42
|
+
- native `fetch` is required
|
|
43
|
+
- Node 18+ is the supported baseline
|
|
44
|
+
|
|
45
|
+
If you want an explicit Node-only import:
|
|
46
|
+
|
|
47
|
+
```ts
|
|
48
|
+
import { loadWasm } from '@steerprotocol/app-loader/node';
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
### Browser
|
|
52
|
+
|
|
53
|
+
The browser entry supports `ArrayBuffer` and remote URL loading.
|
|
54
|
+
|
|
55
|
+
```ts
|
|
56
|
+
import { loadWasm } from '@steerprotocol/app-loader';
|
|
57
|
+
|
|
58
|
+
const response = await fetch('/bundle.wasm');
|
|
59
|
+
const bundle = await loadWasm(await response.arrayBuffer());
|
|
60
|
+
bundle.initialize('{"example":true}');
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
If you want to pin the browser-specific entrypoint:
|
|
64
|
+
|
|
65
|
+
```ts
|
|
66
|
+
import { loadWasm } from '@steerprotocol/app-loader/browser';
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
### Browser `ccxt`
|
|
70
|
+
|
|
71
|
+
In browsers, `ccxt` is expected on `globalThis.ccxt`.
|
|
72
|
+
|
|
73
|
+
If you load `ccxt` from a CDN or hosted bundle, make sure it is available before executing wasm that depends on it.
|
|
74
|
+
|
|
75
|
+
```html
|
|
76
|
+
<script src="https://unpkg.com/ccxt@4.5.46/dist/ccxt.browser.min.js"></script>
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
The hosted browser build is covered by the default test suite with a live network smoke test against the same unpkg URL.
|
|
80
|
+
|
|
81
|
+
### Node `ccxt`
|
|
82
|
+
|
|
83
|
+
In Node, `ccxt` is loaded from the installed module automatically.
|
|
84
|
+
|
|
85
|
+
## API
|
|
86
|
+
|
|
87
|
+
Main exports:
|
|
88
|
+
|
|
89
|
+
- `loadWasm(input, imports?)`
|
|
90
|
+
- `loadWasmSync(input, imports?)`
|
|
91
|
+
- `Candle`
|
|
92
|
+
- `RawTradeData`
|
|
93
|
+
|
|
94
|
+
The returned wasm wrapper exposes the module surface when available, including:
|
|
95
|
+
|
|
96
|
+
- `initialize(config)`
|
|
97
|
+
- `execute(...args)`
|
|
98
|
+
- `config()`
|
|
99
|
+
- `transform()`
|
|
100
|
+
- `reset()`
|
|
101
|
+
|
|
102
|
+
## Development
|
|
103
|
+
|
|
104
|
+
### Build
|
|
105
|
+
|
|
106
|
+
```bash
|
|
107
|
+
npm run build
|
|
108
|
+
```
|
|
109
|
+
|
|
110
|
+
### Unit And Integration Tests
|
|
111
|
+
|
|
112
|
+
```bash
|
|
113
|
+
npm test
|
|
114
|
+
```
|
|
115
|
+
|
|
116
|
+
An env-gated live repro for the deprecated Sushi Polygon v2 connector is enabled when
|
|
117
|
+
`STEER_SUBGRAPH_STUDIO_KEY` is set (or `STEER_SUBGRAPH_GATEWAY_KEY` for local debugging). This connector is kept as historical evidence of a
|
|
118
|
+
known-broken path and is not part of the supported execution contract.
|
|
119
|
+
|
|
120
|
+
### Packed Consumer Smoke Tests
|
|
121
|
+
|
|
122
|
+
These tests validate the packed artifact in real consumer fixtures for:
|
|
123
|
+
|
|
124
|
+
- Node ESM
|
|
125
|
+
- Node CJS
|
|
126
|
+
- Vite browser builds
|
|
127
|
+
|
|
128
|
+
```bash
|
|
129
|
+
npm run test:consumers
|
|
130
|
+
```
|
|
131
|
+
|
|
132
|
+
This command builds the package, packs it, installs the tarball into fixture apps, and runs each fixture check.
|
|
133
|
+
|
|
134
|
+
## Migration Notes
|
|
135
|
+
|
|
136
|
+
Version 2 changes the package runtime contract.
|
|
137
|
+
|
|
138
|
+
- Browser consumers should rely on the root import only when their bundler honors the `browser` export condition.
|
|
139
|
+
- Browser `ccxt` integration now expects the hosted browser build on `globalThis.ccxt`.
|
|
140
|
+
- Node consumers should use the root import or `@steerprotocol/app-loader/node`.
|
|
141
|
+
- Browser consumers can use `@steerprotocol/app-loader/browser` to pin the browser-safe entrypoint explicitly.
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Trade point model used as candle-generation input.
|
|
3
|
+
*/
|
|
4
|
+
declare class RawTradeData {
|
|
5
|
+
timestamp: number;
|
|
6
|
+
price: number;
|
|
7
|
+
volume: number;
|
|
8
|
+
/**
|
|
9
|
+
* Creates a raw trade data point.
|
|
10
|
+
* @param timestamp - Trade timestamp.
|
|
11
|
+
* @param price - Trade price.
|
|
12
|
+
* @param volume - Trade volume.
|
|
13
|
+
*/
|
|
14
|
+
constructor(timestamp: number, price: number, volume: number);
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* OHLCV candle model.
|
|
19
|
+
*/
|
|
20
|
+
declare class Candle {
|
|
21
|
+
timestamp: number;
|
|
22
|
+
high: number;
|
|
23
|
+
low: number;
|
|
24
|
+
open: number;
|
|
25
|
+
close: number;
|
|
26
|
+
volume: number;
|
|
27
|
+
/**
|
|
28
|
+
* Creates a candle instance.
|
|
29
|
+
* @param timestamp - Candle open timestamp in milliseconds.
|
|
30
|
+
* @param high - Highest traded price.
|
|
31
|
+
* @param low - Lowest traded price.
|
|
32
|
+
* @param open - Opening price.
|
|
33
|
+
* @param close - Closing price.
|
|
34
|
+
* @param volume - Total traded volume.
|
|
35
|
+
*/
|
|
36
|
+
constructor(timestamp: number, high: number, low: number, open: number, close: number, volume: number);
|
|
37
|
+
/**
|
|
38
|
+
* Serializes the candle as JSON.
|
|
39
|
+
* @returns The candle as a JSON string.
|
|
40
|
+
*/
|
|
41
|
+
toString(): string;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
/**
|
|
45
|
+
* Type declarations for the wasm exports surfaced by this package.
|
|
46
|
+
*/
|
|
47
|
+
declare function responseHandler(body: ArrayBuffer, statusCode: number, redirected: number, callbackID: number): void;
|
|
48
|
+
declare function initialize(config: string): boolean;
|
|
49
|
+
declare function config(): string;
|
|
50
|
+
declare function version(): number;
|
|
51
|
+
declare function transform(): string;
|
|
52
|
+
declare function execute(...params: Array<number | string | ArrayBuffer | null>): Promise<string | null>;
|
|
53
|
+
declare function __new(size: number, id: number): number;
|
|
54
|
+
declare function __pin(ptr: number): number;
|
|
55
|
+
declare function __unpin(ptr: number): number;
|
|
56
|
+
declare function reset(): void;
|
|
57
|
+
/**
|
|
58
|
+
* Public shape of the wrapped wasm exports.
|
|
59
|
+
*/
|
|
60
|
+
type WasmModule = {
|
|
61
|
+
responseHandler: typeof responseHandler;
|
|
62
|
+
initialize: typeof initialize;
|
|
63
|
+
execute: typeof execute;
|
|
64
|
+
config: typeof config;
|
|
65
|
+
version: typeof version;
|
|
66
|
+
transform: typeof transform;
|
|
67
|
+
memory: WebAssembly.Memory;
|
|
68
|
+
__new: typeof __new;
|
|
69
|
+
__pin: typeof __pin;
|
|
70
|
+
__unpin: typeof __unpin;
|
|
71
|
+
reset: typeof reset;
|
|
72
|
+
};
|
|
73
|
+
|
|
74
|
+
export { Candle as C, RawTradeData as R, type WasmModule as W };
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Trade point model used as candle-generation input.
|
|
3
|
+
*/
|
|
4
|
+
declare class RawTradeData {
|
|
5
|
+
timestamp: number;
|
|
6
|
+
price: number;
|
|
7
|
+
volume: number;
|
|
8
|
+
/**
|
|
9
|
+
* Creates a raw trade data point.
|
|
10
|
+
* @param timestamp - Trade timestamp.
|
|
11
|
+
* @param price - Trade price.
|
|
12
|
+
* @param volume - Trade volume.
|
|
13
|
+
*/
|
|
14
|
+
constructor(timestamp: number, price: number, volume: number);
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* OHLCV candle model.
|
|
19
|
+
*/
|
|
20
|
+
declare class Candle {
|
|
21
|
+
timestamp: number;
|
|
22
|
+
high: number;
|
|
23
|
+
low: number;
|
|
24
|
+
open: number;
|
|
25
|
+
close: number;
|
|
26
|
+
volume: number;
|
|
27
|
+
/**
|
|
28
|
+
* Creates a candle instance.
|
|
29
|
+
* @param timestamp - Candle open timestamp in milliseconds.
|
|
30
|
+
* @param high - Highest traded price.
|
|
31
|
+
* @param low - Lowest traded price.
|
|
32
|
+
* @param open - Opening price.
|
|
33
|
+
* @param close - Closing price.
|
|
34
|
+
* @param volume - Total traded volume.
|
|
35
|
+
*/
|
|
36
|
+
constructor(timestamp: number, high: number, low: number, open: number, close: number, volume: number);
|
|
37
|
+
/**
|
|
38
|
+
* Serializes the candle as JSON.
|
|
39
|
+
* @returns The candle as a JSON string.
|
|
40
|
+
*/
|
|
41
|
+
toString(): string;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
/**
|
|
45
|
+
* Type declarations for the wasm exports surfaced by this package.
|
|
46
|
+
*/
|
|
47
|
+
declare function responseHandler(body: ArrayBuffer, statusCode: number, redirected: number, callbackID: number): void;
|
|
48
|
+
declare function initialize(config: string): boolean;
|
|
49
|
+
declare function config(): string;
|
|
50
|
+
declare function version(): number;
|
|
51
|
+
declare function transform(): string;
|
|
52
|
+
declare function execute(...params: Array<number | string | ArrayBuffer | null>): Promise<string | null>;
|
|
53
|
+
declare function __new(size: number, id: number): number;
|
|
54
|
+
declare function __pin(ptr: number): number;
|
|
55
|
+
declare function __unpin(ptr: number): number;
|
|
56
|
+
declare function reset(): void;
|
|
57
|
+
/**
|
|
58
|
+
* Public shape of the wrapped wasm exports.
|
|
59
|
+
*/
|
|
60
|
+
type WasmModule = {
|
|
61
|
+
responseHandler: typeof responseHandler;
|
|
62
|
+
initialize: typeof initialize;
|
|
63
|
+
execute: typeof execute;
|
|
64
|
+
config: typeof config;
|
|
65
|
+
version: typeof version;
|
|
66
|
+
transform: typeof transform;
|
|
67
|
+
memory: WebAssembly.Memory;
|
|
68
|
+
__new: typeof __new;
|
|
69
|
+
__pin: typeof __pin;
|
|
70
|
+
__unpin: typeof __unpin;
|
|
71
|
+
reset: typeof reset;
|
|
72
|
+
};
|
|
73
|
+
|
|
74
|
+
export { Candle as C, RawTradeData as R, type WasmModule as W };
|