@steerprotocol/app-loader 3.0.0 → 3.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -26,8 +26,9 @@ Use the root import for typical Node usage.
26
26
 
27
27
  ```ts
28
28
  import { loadWasm } from '@steerprotocol/app-loader';
29
+ import type { WasmModule } from '@steerprotocol/app-loader';
29
30
 
30
- const bundle = await loadWasm('/absolute/path/to/bundle.wasm');
31
+ const bundle: WasmModule = await loadWasm('/absolute/path/to/bundle.wasm');
31
32
  bundle.initialize('{"example":true}');
32
33
  ```
33
34
 
@@ -46,6 +47,9 @@ If you want an explicit Node-only import:
46
47
 
47
48
  ```ts
48
49
  import { loadWasm } from '@steerprotocol/app-loader/node';
50
+ import type { WasmModule } from '@steerprotocol/app-loader/node';
51
+
52
+ const bundle: WasmModule = await loadWasm('/absolute/path/to/bundle.wasm');
49
53
  ```
50
54
 
51
55
  ### Browser
@@ -54,9 +58,10 @@ The browser entry supports `ArrayBuffer` and remote URL loading.
54
58
 
55
59
  ```ts
56
60
  import { loadWasm } from '@steerprotocol/app-loader';
61
+ import type { WasmModule } from '@steerprotocol/app-loader';
57
62
 
58
63
  const response = await fetch('/bundle.wasm');
59
- const bundle = await loadWasm(await response.arrayBuffer());
64
+ const bundle: WasmModule = await loadWasm(await response.arrayBuffer());
60
65
  bundle.initialize('{"example":true}');
61
66
  ```
62
67
 
@@ -64,6 +69,10 @@ If you want to pin the browser-specific entrypoint:
64
69
 
65
70
  ```ts
66
71
  import { loadWasm } from '@steerprotocol/app-loader/browser';
72
+ import type { WasmModule } from '@steerprotocol/app-loader/browser';
73
+
74
+ const response = await fetch('/bundle.wasm');
75
+ const bundle: WasmModule = await loadWasm(await response.arrayBuffer());
67
76
  ```
68
77
 
69
78
  ### Browser `ccxt`
@@ -88,9 +97,27 @@ Main exports:
88
97
 
89
98
  - `loadWasm(input, imports?)`
90
99
  - `loadWasmSync(input, imports?)`
100
+ - `WasmModule` (type-only export)
91
101
  - `Candle`
92
102
  - `RawTradeData`
93
103
 
104
+ `WasmModule` is a type-only export. Strict TypeScript consumers, including projects using
105
+ `moduleResolution: "NodeNext"`, `module: "NodeNext"`, and `verbatimModuleSyntax: true`, must import it with
106
+ `import type`:
107
+
108
+ ```ts
109
+ import { loadWasm } from '@steerprotocol/app-loader';
110
+ import type { WasmModule } from '@steerprotocol/app-loader';
111
+ ```
112
+
113
+ The same rule applies to `@steerprotocol/app-loader/node` and `@steerprotocol/app-loader/browser`.
114
+
115
+ The non-type-only form is not the supported pattern for strict TS consumers:
116
+
117
+ ```ts
118
+ import { WasmModule, loadWasm } from '@steerprotocol/app-loader';
119
+ ```
120
+
94
121
  The returned wasm wrapper exposes the module surface when available, including:
95
122
 
96
123
  - `initialize(config)`
@@ -113,19 +140,26 @@ npm run build
113
140
  npm test
114
141
  ```
115
142
 
116
- ### Packed Consumer Smoke Tests
143
+ An env-gated live repro for the deprecated Sushi Polygon v2 connector is enabled when
144
+ `STEER_SUBGRAPH_STUDIO_KEY` is set (or `STEER_SUBGRAPH_GATEWAY_KEY` for local debugging). This connector is kept as historical evidence of a
145
+ known-broken path and is not part of the supported execution contract.
146
+
147
+ ### Packed Consumer Checks
117
148
 
118
- These tests validate the packed artifact in real consumer fixtures for:
149
+ These checks validate the packed artifact in consumer fixtures for:
119
150
 
120
151
  - Node ESM
121
152
  - Node CJS
122
- - Vite browser builds
153
+ - Strict TypeScript NodeNext consumers
154
+ - Vite browser bundler builds
155
+ - Next.js browser bundler builds
123
156
 
124
157
  ```bash
125
158
  npm run test:consumers
126
159
  ```
127
160
 
128
- This command builds the package, packs it, installs the tarball into fixture apps, and runs each fixture check.
161
+ This command builds the package, packs it, installs the tarball into fixture apps, validates the packed export artifacts,
162
+ and runs each fixture check.
129
163
 
130
164
  ## Migration Notes
131
165
 
@@ -0,0 +1,46 @@
1
+ import { RawTradeData } from './RawTradeData';
2
+ /**
3
+ * OHLCV candle model.
4
+ */
5
+ export declare class Candle {
6
+ timestamp: number;
7
+ high: number;
8
+ low: number;
9
+ open: number;
10
+ close: number;
11
+ volume: number;
12
+ /**
13
+ * Creates a candle instance.
14
+ * @param timestamp - Candle open timestamp in milliseconds.
15
+ * @param high - Highest traded price.
16
+ * @param low - Lowest traded price.
17
+ * @param open - Opening price.
18
+ * @param close - Closing price.
19
+ * @param volume - Total traded volume.
20
+ */
21
+ constructor(timestamp: number, high: number, low: number, open: number, close: number, volume: number);
22
+ /**
23
+ * Serializes the candle as JSON.
24
+ * @returns The candle as a JSON string.
25
+ */
26
+ toString(): string;
27
+ }
28
+ /**
29
+ * Encodes a candle into a fixed-width integer buffer.
30
+ * @param candle - Candle to encode.
31
+ * @returns The encoded candle buffer.
32
+ */
33
+ export declare function encodeCandle(candle: Candle): Uint32Array;
34
+ /**
35
+ * Decodes a fixed-width integer buffer into a candle.
36
+ * @param buffer - Encoded candle buffer.
37
+ * @returns The decoded candle.
38
+ */
39
+ export declare function decodeCandle(buffer: Uint32Array): Candle;
40
+ /**
41
+ * Aggregates raw trades into OHLCV candles.
42
+ * @param data - Raw trades sorted by timestamp.
43
+ * @param candleSize - Candle width expressed as a timestring.
44
+ * @returns Generated candles.
45
+ */
46
+ export declare function generateCandles(data: RawTradeData[], candleSize: string): Candle[];
@@ -0,0 +1,15 @@
1
+ /**
2
+ * Trade point model used as candle-generation input.
3
+ */
4
+ export 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
+ }
@@ -1,32 +1,20 @@
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
+ /**
2
+ * Type declarations for the wasm exports surfaced by this package.
3
+ */
19
4
  declare function responseHandler(body: ArrayBuffer, statusCode: number, redirected: number, callbackID: number): void;
20
- declare function initialize(config: string): void;
5
+ declare function initialize(config: string): boolean;
21
6
  declare function config(): string;
22
7
  declare function version(): number;
23
8
  declare function transform(): string;
24
- declare function execute(...params: number[] | string[] | ArrayBuffer[] | null[]): string;
9
+ declare function execute(...params: Array<number | string | ArrayBuffer | null>): Promise<string | null>;
25
10
  declare function __new(size: number, id: number): number;
26
11
  declare function __pin(ptr: number): number;
27
12
  declare function __unpin(ptr: number): number;
28
13
  declare function reset(): void;
29
- type WasmModule = {
14
+ /**
15
+ * Public shape of the wrapped wasm exports.
16
+ */
17
+ export type WasmModule = {
30
18
  responseHandler: typeof responseHandler;
31
19
  initialize: typeof initialize;
32
20
  execute: typeof execute;
@@ -39,5 +27,4 @@ type WasmModule = {
39
27
  __unpin: typeof __unpin;
40
28
  reset: typeof reset;
41
29
  };
42
-
43
- export { Candle as C, RawTradeData as R, type WasmModule as W };
30
+ export {};
@@ -1,6 +1,8 @@
1
- import { W as WasmModule } from './WasmModule-MhaHnYBX.mjs';
2
- export { C as Candle, R as RawTradeData } from './WasmModule-MhaHnYBX.mjs';
3
-
1
+ /**
2
+ * Browser-only entrypoints for loading Steer wasm bundles.
3
+ */
4
+ import { Candle, RawTradeData } from './internal/instantiate';
5
+ import type { WasmModule } from './WasmModule';
4
6
  /**
5
7
  * Load a wasm bundle synchronously. Only accepts the actual binary data.
6
8
  * @param input - Wasm bundle data
@@ -9,11 +11,11 @@ export { C as Candle, R as RawTradeData } from './WasmModule-MhaHnYBX.mjs';
9
11
  */
10
12
  declare function loadWasmSync(input: ArrayBuffer, imports?: {}): WasmModule;
11
13
  /**
12
- * Load a wasm bundle asynchronously. Accepts the actual binary data or a file path/URL.
13
- * @param input - Wasm bundle data, file path, or URL
14
+ * Load a wasm bundle asynchronously. Accepts the actual binary data or URL.
15
+ * @param input - Wasm bundle data or URL
14
16
  * @param imports - Imports
15
17
  * @returns
16
18
  */
17
19
  declare function loadWasm(input: string | ArrayBuffer, imports?: {}): Promise<WasmModule>;
18
-
19
- export { WasmModule, loadWasm, loadWasmSync };
20
+ export type { WasmModule } from './WasmModule';
21
+ export { loadWasm, loadWasmSync, Candle, RawTradeData };