@steerprotocol/app-loader 2.1.1 → 3.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/README.md +137 -1
- package/lib/{WasmModule.d.ts → WasmModule-MhaHnYBX.d.mts} +21 -2
- package/lib/{esm/WasmModule.d.ts → WasmModule-MhaHnYBX.d.ts} +21 -2
- package/lib/browser.mjs +559 -0
- package/lib/browser.mjs.map +1 -0
- package/lib/index.cjs +623 -0
- package/lib/index.cjs.map +1 -0
- package/lib/index.d.mts +20 -0
- package/lib/index.d.ts +10 -8
- package/lib/index.mjs +600 -0
- package/lib/index.mjs.map +1 -0
- package/lib/node.cjs +607 -0
- package/lib/node.cjs.map +1 -0
- package/lib/node.d.mts +19 -0
- package/lib/node.d.ts +19 -0
- package/lib/node.mjs +567 -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.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.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,137 @@
|
|
|
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
|
+
### Packed Consumer Smoke Tests
|
|
117
|
+
|
|
118
|
+
These tests validate the packed artifact in real consumer fixtures for:
|
|
119
|
+
|
|
120
|
+
- Node ESM
|
|
121
|
+
- Node CJS
|
|
122
|
+
- Vite browser builds
|
|
123
|
+
|
|
124
|
+
```bash
|
|
125
|
+
npm run test:consumers
|
|
126
|
+
```
|
|
127
|
+
|
|
128
|
+
This command builds the package, packs it, installs the tarball into fixture apps, and runs each fixture check.
|
|
129
|
+
|
|
130
|
+
## Migration Notes
|
|
131
|
+
|
|
132
|
+
Version 2 changes the package runtime contract.
|
|
133
|
+
|
|
134
|
+
- Browser consumers should rely on the root import only when their bundler honors the `browser` export condition.
|
|
135
|
+
- Browser `ccxt` integration now expects the hosted browser build on `globalThis.ccxt`.
|
|
136
|
+
- Node consumers should use the root import or `@steerprotocol/app-loader/node`.
|
|
137
|
+
- Browser consumers can use `@steerprotocol/app-loader/browser` to pin the browser-safe entrypoint explicitly.
|
|
@@ -1,3 +1,21 @@
|
|
|
1
|
+
declare class RawTradeData {
|
|
2
|
+
timestamp: number;
|
|
3
|
+
price: number;
|
|
4
|
+
volume: number;
|
|
5
|
+
constructor(timestamp: number, price: number, volume: number);
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
declare class Candle {
|
|
9
|
+
timestamp: number;
|
|
10
|
+
high: number;
|
|
11
|
+
low: number;
|
|
12
|
+
open: number;
|
|
13
|
+
close: number;
|
|
14
|
+
volume: number;
|
|
15
|
+
constructor(timestamp: number, high: number, low: number, open: number, close: number, volume: number);
|
|
16
|
+
toString(): string;
|
|
17
|
+
}
|
|
18
|
+
|
|
1
19
|
declare function responseHandler(body: ArrayBuffer, statusCode: number, redirected: number, callbackID: number): void;
|
|
2
20
|
declare function initialize(config: string): void;
|
|
3
21
|
declare function config(): string;
|
|
@@ -8,7 +26,7 @@ declare function __new(size: number, id: number): number;
|
|
|
8
26
|
declare function __pin(ptr: number): number;
|
|
9
27
|
declare function __unpin(ptr: number): number;
|
|
10
28
|
declare function reset(): void;
|
|
11
|
-
|
|
29
|
+
type WasmModule = {
|
|
12
30
|
responseHandler: typeof responseHandler;
|
|
13
31
|
initialize: typeof initialize;
|
|
14
32
|
execute: typeof execute;
|
|
@@ -21,4 +39,5 @@ export type WasmModule = {
|
|
|
21
39
|
__unpin: typeof __unpin;
|
|
22
40
|
reset: typeof reset;
|
|
23
41
|
};
|
|
24
|
-
|
|
42
|
+
|
|
43
|
+
export { Candle as C, RawTradeData as R, type WasmModule as W };
|
|
@@ -1,3 +1,21 @@
|
|
|
1
|
+
declare class RawTradeData {
|
|
2
|
+
timestamp: number;
|
|
3
|
+
price: number;
|
|
4
|
+
volume: number;
|
|
5
|
+
constructor(timestamp: number, price: number, volume: number);
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
declare class Candle {
|
|
9
|
+
timestamp: number;
|
|
10
|
+
high: number;
|
|
11
|
+
low: number;
|
|
12
|
+
open: number;
|
|
13
|
+
close: number;
|
|
14
|
+
volume: number;
|
|
15
|
+
constructor(timestamp: number, high: number, low: number, open: number, close: number, volume: number);
|
|
16
|
+
toString(): string;
|
|
17
|
+
}
|
|
18
|
+
|
|
1
19
|
declare function responseHandler(body: ArrayBuffer, statusCode: number, redirected: number, callbackID: number): void;
|
|
2
20
|
declare function initialize(config: string): void;
|
|
3
21
|
declare function config(): string;
|
|
@@ -8,7 +26,7 @@ declare function __new(size: number, id: number): number;
|
|
|
8
26
|
declare function __pin(ptr: number): number;
|
|
9
27
|
declare function __unpin(ptr: number): number;
|
|
10
28
|
declare function reset(): void;
|
|
11
|
-
|
|
29
|
+
type WasmModule = {
|
|
12
30
|
responseHandler: typeof responseHandler;
|
|
13
31
|
initialize: typeof initialize;
|
|
14
32
|
execute: typeof execute;
|
|
@@ -21,4 +39,5 @@ export type WasmModule = {
|
|
|
21
39
|
__unpin: typeof __unpin;
|
|
22
40
|
reset: typeof reset;
|
|
23
41
|
};
|
|
24
|
-
|
|
42
|
+
|
|
43
|
+
export { Candle as C, RawTradeData as R, type WasmModule as W };
|