@gadgetinc/substrate 0.1.0-rc.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/dist/assets/kernel.wasm +0 -0
- package/dist/assets/manifest.json +32 -0
- package/dist/assets/network-driver.js +2 -0
- package/dist/assets/network-driver.js.map +1 -0
- package/dist/assets/runtime.js +264 -0
- package/dist/assets/runtime.js.map +1 -0
- package/dist/binaries.d.ts +58 -0
- package/dist/binaries.d.ts.map +1 -0
- package/dist/boot/index.d.ts +318 -0
- package/dist/boot/index.d.ts.map +1 -0
- package/dist/index.d.ts +8 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +4589 -0
- package/dist/index.js.map +1 -0
- package/dist/kernel/bridge.d.ts +64 -0
- package/dist/kernel/bridge.d.ts.map +1 -0
- package/dist/kernel/types.d.ts +518 -0
- package/dist/kernel/types.d.ts.map +1 -0
- package/dist/kernel/wasm.d.ts +20 -0
- package/dist/kernel/wasm.d.ts.map +1 -0
- package/dist/node/assert.d.ts +99 -0
- package/dist/node/assert.d.ts.map +1 -0
- package/dist/node/async_hooks.d.ts +88 -0
- package/dist/node/async_hooks.d.ts.map +1 -0
- package/dist/node/buffer.d.ts +62 -0
- package/dist/node/buffer.d.ts.map +1 -0
- package/dist/node/child_process.d.ts +300 -0
- package/dist/node/child_process.d.ts.map +1 -0
- package/dist/node/cluster.d.ts +37 -0
- package/dist/node/cluster.d.ts.map +1 -0
- package/dist/node/constants.d.ts +306 -0
- package/dist/node/constants.d.ts.map +1 -0
- package/dist/node/crypto.d.ts +176 -0
- package/dist/node/crypto.d.ts.map +1 -0
- package/dist/node/dgram.d.ts +44 -0
- package/dist/node/dgram.d.ts.map +1 -0
- package/dist/node/diagnostics_channel.d.ts +57 -0
- package/dist/node/diagnostics_channel.d.ts.map +1 -0
- package/dist/node/dns.d.ts +278 -0
- package/dist/node/dns.d.ts.map +1 -0
- package/dist/node/domain.d.ts +21 -0
- package/dist/node/domain.d.ts.map +1 -0
- package/dist/node/events.d.ts +54 -0
- package/dist/node/events.d.ts.map +1 -0
- package/dist/node/fs/promises.d.ts +116 -0
- package/dist/node/fs/promises.d.ts.map +1 -0
- package/dist/node/fs.d.ts +536 -0
- package/dist/node/fs.d.ts.map +1 -0
- package/dist/node/http.d.ts +471 -0
- package/dist/node/http.d.ts.map +1 -0
- package/dist/node/http2.d.ts +508 -0
- package/dist/node/http2.d.ts.map +1 -0
- package/dist/node/https.d.ts +42 -0
- package/dist/node/https.d.ts.map +1 -0
- package/dist/node/inspector.d.ts +25 -0
- package/dist/node/inspector.d.ts.map +1 -0
- package/dist/node/net.d.ts +231 -0
- package/dist/node/net.d.ts.map +1 -0
- package/dist/node/os.d.ts +318 -0
- package/dist/node/os.d.ts.map +1 -0
- package/dist/node/path.d.ts +144 -0
- package/dist/node/path.d.ts.map +1 -0
- package/dist/node/process.d.ts +105 -0
- package/dist/node/process.d.ts.map +1 -0
- package/dist/node/punycode.d.ts +34 -0
- package/dist/node/punycode.d.ts.map +1 -0
- package/dist/node/querystring.d.ts +49 -0
- package/dist/node/querystring.d.ts.map +1 -0
- package/dist/node/readline.d.ts +99 -0
- package/dist/node/readline.d.ts.map +1 -0
- package/dist/node/stream.d.ts +409 -0
- package/dist/node/stream.d.ts.map +1 -0
- package/dist/node/string_decoder.d.ts +46 -0
- package/dist/node/string_decoder.d.ts.map +1 -0
- package/dist/node/timers.d.ts +79 -0
- package/dist/node/timers.d.ts.map +1 -0
- package/dist/node/tls.d.ts +159 -0
- package/dist/node/tls.d.ts.map +1 -0
- package/dist/node/trace_events.d.ts +18 -0
- package/dist/node/trace_events.d.ts.map +1 -0
- package/dist/node/tty.d.ts +67 -0
- package/dist/node/tty.d.ts.map +1 -0
- package/dist/node/url.d.ts +85 -0
- package/dist/node/url.d.ts.map +1 -0
- package/dist/node/util.d.ts +252 -0
- package/dist/node/util.d.ts.map +1 -0
- package/dist/node/v8.d.ts +134 -0
- package/dist/node/v8.d.ts.map +1 -0
- package/dist/node/vm.d.ts +89 -0
- package/dist/node/vm.d.ts.map +1 -0
- package/dist/node/wasi.d.ts +25 -0
- package/dist/node/wasi.d.ts.map +1 -0
- package/dist/node/worker_threads.d.ts +206 -0
- package/dist/node/worker_threads.d.ts.map +1 -0
- package/dist/node/ws.d.ts +110 -0
- package/dist/node/ws.d.ts.map +1 -0
- package/dist/node/zlib.d.ts +328 -0
- package/dist/node/zlib.d.ts.map +1 -0
- package/dist/persistence/opfs-store.d.ts +93 -0
- package/dist/persistence/opfs-store.d.ts.map +1 -0
- package/dist/runtime/async-function-shim.d.ts +27 -0
- package/dist/runtime/async-function-shim.d.ts.map +1 -0
- package/dist/runtime/fs-interface.d.ts +60 -0
- package/dist/runtime/fs-interface.d.ts.map +1 -0
- package/dist/runtime/index.d.ts +113 -0
- package/dist/runtime/index.d.ts.map +1 -0
- package/dist/runtime/loader.d.ts +50 -0
- package/dist/runtime/loader.d.ts.map +1 -0
- package/dist/runtime/loaders/async-transform.d.ts +40 -0
- package/dist/runtime/loaders/async-transform.d.ts.map +1 -0
- package/dist/runtime/loaders/cjs.d.ts +37 -0
- package/dist/runtime/loaders/cjs.d.ts.map +1 -0
- package/dist/runtime/loaders/detect-module-type.d.ts +21 -0
- package/dist/runtime/loaders/detect-module-type.d.ts.map +1 -0
- package/dist/runtime/loaders/esm.d.ts +140 -0
- package/dist/runtime/loaders/esm.d.ts.map +1 -0
- package/dist/runtime/loaders/source-map-registry.d.ts +43 -0
- package/dist/runtime/loaders/source-map-registry.d.ts.map +1 -0
- package/dist/runtime/loaders/source-map.d.ts +50 -0
- package/dist/runtime/loaders/source-map.d.ts.map +1 -0
- package/dist/runtime/loaders/utils.d.ts +6 -0
- package/dist/runtime/loaders/utils.d.ts.map +1 -0
- package/dist/runtime/native-globals.d.ts +24 -0
- package/dist/runtime/native-globals.d.ts.map +1 -0
- package/dist/runtime/network-driver.d.ts +78 -0
- package/dist/runtime/network-driver.d.ts.map +1 -0
- package/dist/runtime/process-context.d.ts +96 -0
- package/dist/runtime/process-context.d.ts.map +1 -0
- package/dist/runtime/process-event-loop.d.ts +356 -0
- package/dist/runtime/process-event-loop.d.ts.map +1 -0
- package/dist/runtime/process-handler.d.ts +71 -0
- package/dist/runtime/process-handler.d.ts.map +1 -0
- package/dist/runtime/process-handlers/node.d.ts +22 -0
- package/dist/runtime/process-handlers/node.d.ts.map +1 -0
- package/dist/runtime/process-handlers/npm.d.ts +20 -0
- package/dist/runtime/process-handlers/npm.d.ts.map +1 -0
- package/dist/runtime/process-handlers/npx.d.ts +11 -0
- package/dist/runtime/process-handlers/npx.d.ts.map +1 -0
- package/dist/runtime/process-handlers/pnpm.d.ts +12 -0
- package/dist/runtime/process-handlers/pnpm.d.ts.map +1 -0
- package/dist/runtime/process-handlers/shell.d.ts +24 -0
- package/dist/runtime/process-handlers/shell.d.ts.map +1 -0
- package/dist/runtime/process-handlers/yarn.d.ts +12 -0
- package/dist/runtime/process-handlers/yarn.d.ts.map +1 -0
- package/dist/runtime/process-helpers.d.ts +17 -0
- package/dist/runtime/process-helpers.d.ts.map +1 -0
- package/dist/runtime/process-manager.d.ts +87 -0
- package/dist/runtime/process-manager.d.ts.map +1 -0
- package/dist/runtime/process-scheduler.d.ts +123 -0
- package/dist/runtime/process-scheduler.d.ts.map +1 -0
- package/dist/runtime/process-waker.d.ts +24 -0
- package/dist/runtime/process-waker.d.ts.map +1 -0
- package/dist/runtime/promise.d.ts +44 -0
- package/dist/runtime/promise.d.ts.map +1 -0
- package/dist/runtime/stack-trace.d.ts +52 -0
- package/dist/runtime/stack-trace.d.ts.map +1 -0
- package/dist/runtime/wasm-package-interceptor.d.ts +141 -0
- package/dist/runtime/wasm-package-interceptor.d.ts.map +1 -0
- package/dist/runtime/web-streams.d.ts +57 -0
- package/dist/runtime/web-streams.d.ts.map +1 -0
- package/dist/runtime/websocket.d.ts +102 -0
- package/dist/runtime/websocket.d.ts.map +1 -0
- package/dist/shim/websocket-shim-inline.d.ts +9 -0
- package/dist/shim/websocket-shim-inline.d.ts.map +1 -0
- package/dist/shim/websocket-shim.d.ts +15 -0
- package/dist/shim/websocket-shim.d.ts.map +1 -0
- package/dist/sw/index.d.ts +53 -0
- package/dist/sw/index.d.ts.map +1 -0
- package/dist/utils/debug.d.ts +75 -0
- package/dist/utils/debug.d.ts.map +1 -0
- package/dist/utils/path.d.ts +20 -0
- package/dist/utils/path.d.ts.map +1 -0
- package/dist/utils/tarball.d.ts +37 -0
- package/dist/utils/tarball.d.ts.map +1 -0
- package/dist/utils/websocket-protocol.d.ts +102 -0
- package/dist/utils/websocket-protocol.d.ts.map +1 -0
- package/dist/worker/host.d.ts +14 -0
- package/dist/worker/host.d.ts.map +1 -0
- package/dist/worker/types.d.ts +209 -0
- package/dist/worker/types.d.ts.map +1 -0
- package/package.json +53 -0
|
@@ -0,0 +1,328 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Node.js zlib module implementation for Substrate
|
|
3
|
+
*
|
|
4
|
+
* Uses fflate for compression/decompression with proper streaming support.
|
|
5
|
+
*
|
|
6
|
+
* Key insight: Node.js zlib streams process data incrementally via Transform
|
|
7
|
+
* streams. fflate provides streaming classes (Gunzip, Inflate, etc.) with
|
|
8
|
+
* push(chunk, final) that handle incremental data properly.
|
|
9
|
+
*/
|
|
10
|
+
import { Buffer } from "./buffer.js";
|
|
11
|
+
import { Transform } from "./stream.js";
|
|
12
|
+
export declare const constants: {
|
|
13
|
+
Z_NO_FLUSH: number;
|
|
14
|
+
Z_PARTIAL_FLUSH: number;
|
|
15
|
+
Z_SYNC_FLUSH: number;
|
|
16
|
+
Z_FULL_FLUSH: number;
|
|
17
|
+
Z_FINISH: number;
|
|
18
|
+
Z_BLOCK: number;
|
|
19
|
+
Z_TREES: number;
|
|
20
|
+
Z_OK: number;
|
|
21
|
+
Z_STREAM_END: number;
|
|
22
|
+
Z_NEED_DICT: number;
|
|
23
|
+
Z_ERRNO: number;
|
|
24
|
+
Z_STREAM_ERROR: number;
|
|
25
|
+
Z_DATA_ERROR: number;
|
|
26
|
+
Z_MEM_ERROR: number;
|
|
27
|
+
Z_BUF_ERROR: number;
|
|
28
|
+
Z_VERSION_ERROR: number;
|
|
29
|
+
Z_NO_COMPRESSION: number;
|
|
30
|
+
Z_BEST_SPEED: number;
|
|
31
|
+
Z_BEST_COMPRESSION: number;
|
|
32
|
+
Z_DEFAULT_COMPRESSION: number;
|
|
33
|
+
Z_FILTERED: number;
|
|
34
|
+
Z_HUFFMAN_ONLY: number;
|
|
35
|
+
Z_RLE: number;
|
|
36
|
+
Z_FIXED: number;
|
|
37
|
+
Z_DEFAULT_STRATEGY: number;
|
|
38
|
+
DEFLATE: number;
|
|
39
|
+
INFLATE: number;
|
|
40
|
+
GZIP: number;
|
|
41
|
+
GUNZIP: number;
|
|
42
|
+
DEFLATERAW: number;
|
|
43
|
+
INFLATERAW: number;
|
|
44
|
+
UNZIP: number;
|
|
45
|
+
BROTLI_DECODE: number;
|
|
46
|
+
BROTLI_ENCODE: number;
|
|
47
|
+
Z_MIN_WINDOWBITS: number;
|
|
48
|
+
Z_MAX_WINDOWBITS: number;
|
|
49
|
+
Z_DEFAULT_WINDOWBITS: number;
|
|
50
|
+
Z_MIN_CHUNK: number;
|
|
51
|
+
Z_MAX_CHUNK: number;
|
|
52
|
+
Z_DEFAULT_CHUNK: number;
|
|
53
|
+
Z_MIN_MEMLEVEL: number;
|
|
54
|
+
Z_MAX_MEMLEVEL: number;
|
|
55
|
+
Z_DEFAULT_MEMLEVEL: number;
|
|
56
|
+
Z_MIN_LEVEL: number;
|
|
57
|
+
Z_MAX_LEVEL: number;
|
|
58
|
+
Z_DEFAULT_LEVEL: number;
|
|
59
|
+
};
|
|
60
|
+
export interface ZlibOptions {
|
|
61
|
+
level?: number;
|
|
62
|
+
windowBits?: number;
|
|
63
|
+
memLevel?: number;
|
|
64
|
+
strategy?: number;
|
|
65
|
+
dictionary?: Buffer | Uint8Array;
|
|
66
|
+
flush?: number;
|
|
67
|
+
finishFlush?: number;
|
|
68
|
+
chunkSize?: number;
|
|
69
|
+
info?: boolean;
|
|
70
|
+
}
|
|
71
|
+
export declare function deflateSync(buf: Buffer | Uint8Array | string, options?: ZlibOptions): Buffer;
|
|
72
|
+
export declare function inflateSync(buf: Buffer | Uint8Array, _options?: ZlibOptions): Buffer;
|
|
73
|
+
export declare function gzipSync(buf: Buffer | Uint8Array | string, options?: ZlibOptions): Buffer;
|
|
74
|
+
export declare function gunzipSync(buf: Buffer | Uint8Array, _options?: ZlibOptions): Buffer;
|
|
75
|
+
export declare function deflateRawSync(buf: Buffer | Uint8Array | string, options?: ZlibOptions): Buffer;
|
|
76
|
+
export declare function inflateRawSync(buf: Buffer | Uint8Array, _options?: ZlibOptions): Buffer;
|
|
77
|
+
export declare function unzipSync(buf: Buffer | Uint8Array, _options?: ZlibOptions): Buffer;
|
|
78
|
+
type ZlibCallback = (error: Error | null, result?: Buffer) => void;
|
|
79
|
+
export declare function deflate(buf: Buffer | Uint8Array | string, optionsOrCallback: ZlibOptions | ZlibCallback, callback?: ZlibCallback): void;
|
|
80
|
+
export declare function inflate(buf: Buffer | Uint8Array, optionsOrCallback: ZlibOptions | ZlibCallback, callback?: ZlibCallback): void;
|
|
81
|
+
export declare function gzip(buf: Buffer | Uint8Array | string, optionsOrCallback: ZlibOptions | ZlibCallback, callback?: ZlibCallback): void;
|
|
82
|
+
export declare function gunzip(buf: Buffer | Uint8Array, optionsOrCallback: ZlibOptions | ZlibCallback, callback?: ZlibCallback): void;
|
|
83
|
+
export declare function deflateRaw(buf: Buffer | Uint8Array | string, optionsOrCallback: ZlibOptions | ZlibCallback, callback?: ZlibCallback): void;
|
|
84
|
+
export declare function inflateRaw(buf: Buffer | Uint8Array, optionsOrCallback: ZlibOptions | ZlibCallback, callback?: ZlibCallback): void;
|
|
85
|
+
export declare function unzip(buf: Buffer | Uint8Array, optionsOrCallback: ZlibOptions | ZlibCallback, callback?: ZlibCallback): void;
|
|
86
|
+
export declare function brotliCompressSync(): Buffer;
|
|
87
|
+
export declare function brotliDecompressSync(): Buffer;
|
|
88
|
+
export declare function brotliCompress(): void;
|
|
89
|
+
export declare function brotliDecompress(): void;
|
|
90
|
+
/**
|
|
91
|
+
* Mock native handle that minizlib expects.
|
|
92
|
+
* minizlib accesses this._handle and calls methods on it.
|
|
93
|
+
*
|
|
94
|
+
* Key method: _processChunk(chunk, flushFlag) - minizlib calls this directly
|
|
95
|
+
* to perform synchronous compression/decompression.
|
|
96
|
+
*/
|
|
97
|
+
declare class NativeZlibHandle {
|
|
98
|
+
private _parent;
|
|
99
|
+
private _closed;
|
|
100
|
+
constructor(parent: ZlibTransform);
|
|
101
|
+
close(): void;
|
|
102
|
+
reset(): void;
|
|
103
|
+
/**
|
|
104
|
+
* Process a chunk synchronously - this is what minizlib calls directly.
|
|
105
|
+
* Returns an array of result buffers (can be multiple chunks).
|
|
106
|
+
*/
|
|
107
|
+
_processChunk(chunk: Buffer | Uint8Array, flushFlag: number): Buffer[] | undefined;
|
|
108
|
+
}
|
|
109
|
+
interface FflateStreamingCompressor {
|
|
110
|
+
push(chunk: Uint8Array, final?: boolean): void;
|
|
111
|
+
flush?(): void;
|
|
112
|
+
ondata: (data: Uint8Array, final: boolean) => void;
|
|
113
|
+
}
|
|
114
|
+
interface FflateStreamingDecompressor {
|
|
115
|
+
push(chunk: Uint8Array, final?: boolean): void;
|
|
116
|
+
ondata: (data: Uint8Array, final: boolean) => void;
|
|
117
|
+
}
|
|
118
|
+
/**
|
|
119
|
+
* Base class for zlib transform streams using fflate's streaming API.
|
|
120
|
+
*
|
|
121
|
+
* This properly handles incremental data by using fflate's streaming classes
|
|
122
|
+
* (Gunzip, Inflate, etc.) which have a push(chunk, final) method and ondata callback.
|
|
123
|
+
*/
|
|
124
|
+
declare abstract class ZlibTransform extends Transform {
|
|
125
|
+
protected _zlibOptions: ZlibOptions;
|
|
126
|
+
protected _closed: boolean;
|
|
127
|
+
protected _finished: boolean;
|
|
128
|
+
protected _errorEmitted: boolean;
|
|
129
|
+
_handle: NativeZlibHandle;
|
|
130
|
+
_outBuffer: Buffer;
|
|
131
|
+
protected _fflateStream: FflateStreamingCompressor | FflateStreamingDecompressor | null;
|
|
132
|
+
constructor(options?: ZlibOptions);
|
|
133
|
+
/**
|
|
134
|
+
* Initialize the fflate streaming instance. Override in subclasses.
|
|
135
|
+
*/
|
|
136
|
+
protected abstract _initFflateStream(): void;
|
|
137
|
+
_transform(chunk: Buffer | Uint8Array, _encoding: string, callback: (error?: Error | null, data?: Buffer) => void): void;
|
|
138
|
+
_flush(callback: (error?: Error | null, data?: Buffer) => void): void;
|
|
139
|
+
protected _emitError(err: Error, callback?: (error: Error) => void): void;
|
|
140
|
+
/**
|
|
141
|
+
* Collected output chunks from fflate (used by _processChunkInternal)
|
|
142
|
+
*/
|
|
143
|
+
protected _pendingOutput: Buffer[];
|
|
144
|
+
/**
|
|
145
|
+
* Handle data from fflate ondata callback
|
|
146
|
+
*/
|
|
147
|
+
protected _onFflateData: (data: Uint8Array<ArrayBufferLike>, _final: boolean) => void;
|
|
148
|
+
/**
|
|
149
|
+
* Process a chunk synchronously - minizlib calls this directly on the stream.
|
|
150
|
+
* This is THE key method that minizlib uses for synchronous processing.
|
|
151
|
+
*
|
|
152
|
+
* minizlib does: result = this.#handle._processChunk(chunk, flushFlag)
|
|
153
|
+
* where this.#handle is the zlib stream instance itself.
|
|
154
|
+
*/
|
|
155
|
+
_processChunk(chunk: Buffer | Uint8Array, flushFlag: number): Buffer[] | undefined;
|
|
156
|
+
/**
|
|
157
|
+
* Internal implementation of chunk processing.
|
|
158
|
+
*/
|
|
159
|
+
_processChunkInternal(chunk: Buffer | Uint8Array, flushFlag: number): Buffer[] | undefined;
|
|
160
|
+
write(chunk: unknown, encodingOrFlush?: BufferEncoding | number | ((error: Error | null | undefined) => void), callback?: (error: Error | null | undefined) => void): boolean;
|
|
161
|
+
close(callback?: () => void): void;
|
|
162
|
+
params(_level: number, _strategy: number, callback?: () => void): void;
|
|
163
|
+
reset(): void;
|
|
164
|
+
flush(kind?: number | (() => void), callback?: () => void): void;
|
|
165
|
+
}
|
|
166
|
+
declare class DeflateImpl extends ZlibTransform {
|
|
167
|
+
protected _initFflateStream(): void;
|
|
168
|
+
}
|
|
169
|
+
declare class InflateImpl extends ZlibTransform {
|
|
170
|
+
protected _initFflateStream(): void;
|
|
171
|
+
}
|
|
172
|
+
declare class GzipImpl extends ZlibTransform {
|
|
173
|
+
protected _initFflateStream(): void;
|
|
174
|
+
}
|
|
175
|
+
declare class GunzipImpl extends ZlibTransform {
|
|
176
|
+
protected _initFflateStream(): void;
|
|
177
|
+
}
|
|
178
|
+
declare class DeflateRawImpl extends ZlibTransform {
|
|
179
|
+
protected _initFflateStream(): void;
|
|
180
|
+
}
|
|
181
|
+
declare class InflateRawImpl extends ZlibTransform {
|
|
182
|
+
protected _initFflateStream(): void;
|
|
183
|
+
}
|
|
184
|
+
/**
|
|
185
|
+
* Unzip auto-detects gzip vs zlib format.
|
|
186
|
+
* We check the first bytes to determine which decompressor to use.
|
|
187
|
+
*/
|
|
188
|
+
declare class UnzipImpl extends ZlibTransform {
|
|
189
|
+
private _headerBytes;
|
|
190
|
+
private _detectedFormat;
|
|
191
|
+
protected _initFflateStream(): void;
|
|
192
|
+
private _detectAndInit;
|
|
193
|
+
_transform(chunk: Buffer | Uint8Array, _encoding: string, callback: (error?: Error | null, data?: Buffer) => void): void;
|
|
194
|
+
_flush(callback: (error?: Error | null, data?: Buffer) => void): void;
|
|
195
|
+
/**
|
|
196
|
+
* Override _processChunkInternal for Unzip to handle format detection
|
|
197
|
+
*/
|
|
198
|
+
_processChunkInternal(chunk: Buffer | Uint8Array, flushFlag: number): Buffer[] | undefined;
|
|
199
|
+
write(chunk: unknown, encodingOrFlush?: BufferEncoding | number | ((error: Error | null | undefined) => void), callback?: (error: Error | null | undefined) => void): boolean;
|
|
200
|
+
}
|
|
201
|
+
declare class BrotliCompressImpl extends ZlibTransform {
|
|
202
|
+
protected _initFflateStream(): void;
|
|
203
|
+
_transform(_chunk: Buffer | Uint8Array, _encoding: string, callback: (error?: Error | null) => void): void;
|
|
204
|
+
}
|
|
205
|
+
declare class BrotliDecompressImpl extends ZlibTransform {
|
|
206
|
+
protected _initFflateStream(): void;
|
|
207
|
+
_transform(_chunk: Buffer | Uint8Array, _encoding: string, callback: (error?: Error | null) => void): void;
|
|
208
|
+
}
|
|
209
|
+
type ZlibClass<T extends ZlibTransform> = {
|
|
210
|
+
new (options?: ZlibOptions): T;
|
|
211
|
+
(options?: ZlibOptions): T;
|
|
212
|
+
prototype: T;
|
|
213
|
+
};
|
|
214
|
+
export declare const Deflate: ZlibClass<DeflateImpl>;
|
|
215
|
+
export declare const Inflate: ZlibClass<InflateImpl>;
|
|
216
|
+
export declare const Gzip: ZlibClass<GzipImpl>;
|
|
217
|
+
export declare const Gunzip: ZlibClass<GunzipImpl>;
|
|
218
|
+
export declare const DeflateRaw: ZlibClass<DeflateRawImpl>;
|
|
219
|
+
export declare const InflateRaw: ZlibClass<InflateRawImpl>;
|
|
220
|
+
export declare const Unzip: ZlibClass<UnzipImpl>;
|
|
221
|
+
export declare const BrotliCompress: ZlibClass<BrotliCompressImpl>;
|
|
222
|
+
export declare const BrotliDecompress: ZlibClass<BrotliDecompressImpl>;
|
|
223
|
+
export type Deflate = DeflateImpl;
|
|
224
|
+
export type Inflate = InflateImpl;
|
|
225
|
+
export type Gzip = GzipImpl;
|
|
226
|
+
export type Gunzip = GunzipImpl;
|
|
227
|
+
export type DeflateRaw = DeflateRawImpl;
|
|
228
|
+
export type InflateRaw = InflateRawImpl;
|
|
229
|
+
export type Unzip = UnzipImpl;
|
|
230
|
+
export type BrotliCompress = BrotliCompressImpl;
|
|
231
|
+
export type BrotliDecompress = BrotliDecompressImpl;
|
|
232
|
+
export declare function createDeflate(options?: ZlibOptions): Deflate;
|
|
233
|
+
export declare function createInflate(options?: ZlibOptions): Inflate;
|
|
234
|
+
export declare function createGzip(options?: ZlibOptions): Gzip;
|
|
235
|
+
export declare function createGunzip(options?: ZlibOptions): Gunzip;
|
|
236
|
+
export declare function createDeflateRaw(options?: ZlibOptions): DeflateRaw;
|
|
237
|
+
export declare function createInflateRaw(options?: ZlibOptions): InflateRaw;
|
|
238
|
+
export declare function createUnzip(options?: ZlibOptions): Unzip;
|
|
239
|
+
export declare function createBrotliCompress(): BrotliCompress;
|
|
240
|
+
export declare function createBrotliDecompress(): BrotliDecompress;
|
|
241
|
+
declare const _default: {
|
|
242
|
+
constants: {
|
|
243
|
+
Z_NO_FLUSH: number;
|
|
244
|
+
Z_PARTIAL_FLUSH: number;
|
|
245
|
+
Z_SYNC_FLUSH: number;
|
|
246
|
+
Z_FULL_FLUSH: number;
|
|
247
|
+
Z_FINISH: number;
|
|
248
|
+
Z_BLOCK: number;
|
|
249
|
+
Z_TREES: number;
|
|
250
|
+
Z_OK: number;
|
|
251
|
+
Z_STREAM_END: number;
|
|
252
|
+
Z_NEED_DICT: number;
|
|
253
|
+
Z_ERRNO: number;
|
|
254
|
+
Z_STREAM_ERROR: number;
|
|
255
|
+
Z_DATA_ERROR: number;
|
|
256
|
+
Z_MEM_ERROR: number;
|
|
257
|
+
Z_BUF_ERROR: number;
|
|
258
|
+
Z_VERSION_ERROR: number;
|
|
259
|
+
Z_NO_COMPRESSION: number;
|
|
260
|
+
Z_BEST_SPEED: number;
|
|
261
|
+
Z_BEST_COMPRESSION: number;
|
|
262
|
+
Z_DEFAULT_COMPRESSION: number;
|
|
263
|
+
Z_FILTERED: number;
|
|
264
|
+
Z_HUFFMAN_ONLY: number;
|
|
265
|
+
Z_RLE: number;
|
|
266
|
+
Z_FIXED: number;
|
|
267
|
+
Z_DEFAULT_STRATEGY: number;
|
|
268
|
+
DEFLATE: number;
|
|
269
|
+
INFLATE: number;
|
|
270
|
+
GZIP: number;
|
|
271
|
+
GUNZIP: number;
|
|
272
|
+
DEFLATERAW: number;
|
|
273
|
+
INFLATERAW: number;
|
|
274
|
+
UNZIP: number;
|
|
275
|
+
BROTLI_DECODE: number;
|
|
276
|
+
BROTLI_ENCODE: number;
|
|
277
|
+
Z_MIN_WINDOWBITS: number;
|
|
278
|
+
Z_MAX_WINDOWBITS: number;
|
|
279
|
+
Z_DEFAULT_WINDOWBITS: number;
|
|
280
|
+
Z_MIN_CHUNK: number;
|
|
281
|
+
Z_MAX_CHUNK: number;
|
|
282
|
+
Z_DEFAULT_CHUNK: number;
|
|
283
|
+
Z_MIN_MEMLEVEL: number;
|
|
284
|
+
Z_MAX_MEMLEVEL: number;
|
|
285
|
+
Z_DEFAULT_MEMLEVEL: number;
|
|
286
|
+
Z_MIN_LEVEL: number;
|
|
287
|
+
Z_MAX_LEVEL: number;
|
|
288
|
+
Z_DEFAULT_LEVEL: number;
|
|
289
|
+
};
|
|
290
|
+
deflate: typeof deflate;
|
|
291
|
+
deflateSync: typeof deflateSync;
|
|
292
|
+
inflate: typeof inflate;
|
|
293
|
+
inflateSync: typeof inflateSync;
|
|
294
|
+
gzip: typeof gzip;
|
|
295
|
+
gzipSync: typeof gzipSync;
|
|
296
|
+
gunzip: typeof gunzip;
|
|
297
|
+
gunzipSync: typeof gunzipSync;
|
|
298
|
+
deflateRaw: typeof deflateRaw;
|
|
299
|
+
deflateRawSync: typeof deflateRawSync;
|
|
300
|
+
inflateRaw: typeof inflateRaw;
|
|
301
|
+
inflateRawSync: typeof inflateRawSync;
|
|
302
|
+
unzip: typeof unzip;
|
|
303
|
+
unzipSync: typeof unzipSync;
|
|
304
|
+
brotliCompress: typeof brotliCompress;
|
|
305
|
+
brotliCompressSync: typeof brotliCompressSync;
|
|
306
|
+
brotliDecompress: typeof brotliDecompress;
|
|
307
|
+
brotliDecompressSync: typeof brotliDecompressSync;
|
|
308
|
+
Deflate: ZlibClass<DeflateImpl>;
|
|
309
|
+
Inflate: ZlibClass<InflateImpl>;
|
|
310
|
+
Gzip: ZlibClass<GzipImpl>;
|
|
311
|
+
Gunzip: ZlibClass<GunzipImpl>;
|
|
312
|
+
DeflateRaw: ZlibClass<DeflateRawImpl>;
|
|
313
|
+
InflateRaw: ZlibClass<InflateRawImpl>;
|
|
314
|
+
Unzip: ZlibClass<UnzipImpl>;
|
|
315
|
+
BrotliCompress: ZlibClass<BrotliCompressImpl>;
|
|
316
|
+
BrotliDecompress: ZlibClass<BrotliDecompressImpl>;
|
|
317
|
+
createDeflate: typeof createDeflate;
|
|
318
|
+
createInflate: typeof createInflate;
|
|
319
|
+
createGzip: typeof createGzip;
|
|
320
|
+
createGunzip: typeof createGunzip;
|
|
321
|
+
createDeflateRaw: typeof createDeflateRaw;
|
|
322
|
+
createInflateRaw: typeof createInflateRaw;
|
|
323
|
+
createUnzip: typeof createUnzip;
|
|
324
|
+
createBrotliCompress: typeof createBrotliCompress;
|
|
325
|
+
createBrotliDecompress: typeof createBrotliDecompress;
|
|
326
|
+
};
|
|
327
|
+
export default _default;
|
|
328
|
+
//# sourceMappingURL=zlib.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"zlib.d.ts","sourceRoot":"","sources":["../../src/node/zlib.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAkBH,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AACrC,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAexC,eAAO,MAAM,SAAS;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA+CrB,CAAC;AAEF,MAAM,WAAW,WAAW;IAC1B,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,UAAU,CAAC,EAAE,MAAM,GAAG,UAAU,CAAC;IACjC,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,IAAI,CAAC,EAAE,OAA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AS,CAAC;AAC9B,MAAM,MAAM,cAAc,GAAG,kBAAkB,CAAC;AAChD,MAAM,MAAM,gBAAgB,GAAG,oBAAoB,CAAC;AAMpD,wBAAgB,aAAa,CAAC,OAAO,CAAC,EAAE,WAAW,GAAG,OAAO,CAE5D;AAED,wBAAgB,aAAa,CAAC,OAAO,CAAC,EAAE,WAAW,GAAG,OAAO,CAE5D;AAED,wBAAgB,UAAU,CAAC,OAAO,CAAC,EAAE,WAAW,GAAG,IAAI,CAEtD;AAED,wBAAgB,YAAY,CAAC,OAAO,CAAC,EAAE,WAAW,GAAG,MAAM,CAE1D;AAED,wBAAgB,gBAAgB,CAAC,OAAO,CAAC,EAAE,WAAW,GAAG,UAAU,CAElE;AAED,wBAAgB,gBAAgB,CAAC,OAAO,CAAC,EAAE,WAAW,GAAG,UAAU,CAElE;AAED,wBAAgB,WAAW,CAAC,OAAO,CAAC,EAAE,WAAW,GAAG,KAAK,CAExD;AAED,wBAAgB,oBAAoB,IAAI,cAAc,CAErD;AAED,wBAAgB,sBAAsB,IAAI,gBAAgB,CAEzD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAMD,wBAsCE"}
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* OPFS Persistence Store
|
|
3
|
+
*
|
|
4
|
+
* Primary storage for all file data. The WASM kernel never stores file bytes
|
|
5
|
+
* in linear memory — every read/write goes through host imports backed by this store.
|
|
6
|
+
*
|
|
7
|
+
* Uses FileSystemSyncAccessHandle for synchronous I/O in Workers.
|
|
8
|
+
* New inodes are buffered in JS memory until flushPending() creates OPFS handles.
|
|
9
|
+
*
|
|
10
|
+
* OPFS layout:
|
|
11
|
+
* opfs-root/substrate-stores/{name}/
|
|
12
|
+
* .meta — msgpack VFS metadata snapshot
|
|
13
|
+
* inodes/
|
|
14
|
+
* 1, 2, … — one file per inode
|
|
15
|
+
*/
|
|
16
|
+
export declare class OpfsStore {
|
|
17
|
+
private rootDir;
|
|
18
|
+
private inodesDir;
|
|
19
|
+
private metaHandle;
|
|
20
|
+
private inodeHandles;
|
|
21
|
+
private pendingInodes;
|
|
22
|
+
private pendingDeletes;
|
|
23
|
+
private getMemory;
|
|
24
|
+
private constructor();
|
|
25
|
+
/**
|
|
26
|
+
* Open or create an OPFS store. Pre-opens sync access handles for all existing
|
|
27
|
+
* inode files and the metadata file.
|
|
28
|
+
*
|
|
29
|
+
* @param name - Store name (used as OPFS directory name)
|
|
30
|
+
* @param getMemory - Lazy getter for the WASM Memory object (must be valid at call time, not capture time)
|
|
31
|
+
*/
|
|
32
|
+
static create(name: string, getMemory: () => WebAssembly.Memory): Promise<OpfsStore>;
|
|
33
|
+
/**
|
|
34
|
+
* Read `count` bytes from inode at `offset` into WASM memory at `bufPtr`.
|
|
35
|
+
* @returns bytes read (>= 0), or -1 if inode not found
|
|
36
|
+
*/
|
|
37
|
+
readFile(inode: number, offset: number, bufPtr: number, count: number): number;
|
|
38
|
+
/**
|
|
39
|
+
* Write `count` bytes from WASM memory at `bufPtr` to inode at `offset`.
|
|
40
|
+
* @returns bytes written (>= 0), or -1 if inode not found
|
|
41
|
+
*/
|
|
42
|
+
writeFile(inode: number, offset: number, bufPtr: number, count: number): number;
|
|
43
|
+
/**
|
|
44
|
+
* Set file size. If smaller, truncates. If larger, extends with zeros.
|
|
45
|
+
* @returns 0 on success, -1 if inode not found
|
|
46
|
+
*/
|
|
47
|
+
truncateFile(inode: number, size: number): number;
|
|
48
|
+
/**
|
|
49
|
+
* Get file size in bytes.
|
|
50
|
+
* @returns size (>= 0), or -1 if inode not found
|
|
51
|
+
*/
|
|
52
|
+
fileSize(inode: number): number;
|
|
53
|
+
/**
|
|
54
|
+
* Create a new file backing for an inode.
|
|
55
|
+
* Buffered in memory until flushPending() creates the OPFS handle.
|
|
56
|
+
* @returns 0 on success
|
|
57
|
+
*/
|
|
58
|
+
createFile(inode: number): number;
|
|
59
|
+
/**
|
|
60
|
+
* Delete file backing for an inode.
|
|
61
|
+
* Closes the sync handle and queues for async removal.
|
|
62
|
+
* @returns 0 on success
|
|
63
|
+
*/
|
|
64
|
+
deleteFile(inode: number): number;
|
|
65
|
+
/**
|
|
66
|
+
* Read VFS metadata snapshot into WASM memory at bufPtr.
|
|
67
|
+
* @returns bytes read, or -1 if no metadata exists (empty store)
|
|
68
|
+
*/
|
|
69
|
+
readMetadata(bufPtr: number, bufCap: number): number;
|
|
70
|
+
/**
|
|
71
|
+
* Write VFS metadata snapshot from WASM memory at bufPtr.
|
|
72
|
+
* @returns 0 on success
|
|
73
|
+
*/
|
|
74
|
+
writeMetadata(bufPtr: number, bufLen: number): number;
|
|
75
|
+
/**
|
|
76
|
+
* Materialize pending inodes to OPFS and process pending deletes.
|
|
77
|
+
* Creates OPFS file handles for new inodes that were buffered in memory.
|
|
78
|
+
*/
|
|
79
|
+
flushPending(): Promise<void>;
|
|
80
|
+
/**
|
|
81
|
+
* Close all sync access handles. Call on shutdown.
|
|
82
|
+
*/
|
|
83
|
+
close(): Promise<void>;
|
|
84
|
+
/**
|
|
85
|
+
* List all available store names.
|
|
86
|
+
*/
|
|
87
|
+
static list(): Promise<string[]>;
|
|
88
|
+
/**
|
|
89
|
+
* Delete a store and all its data.
|
|
90
|
+
*/
|
|
91
|
+
static delete(name: string): Promise<void>;
|
|
92
|
+
}
|
|
93
|
+
//# sourceMappingURL=opfs-store.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"opfs-store.d.ts","sourceRoot":"","sources":["../../src/persistence/opfs-store.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAoBH,qBAAa,SAAS;IACpB,OAAO,CAAC,OAAO,CAA4B;IAC3C,OAAO,CAAC,SAAS,CAA4B;IAC7C,OAAO,CAAC,UAAU,CAA6B;IAC/C,OAAO,CAAC,YAAY,CAA0C;IAC9D,OAAO,CAAC,aAAa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MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAK/C;CACF"}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* AsyncFunction Shim
|
|
3
|
+
*
|
|
4
|
+
* Creates a patched Function constructor that supports `await` in dynamically
|
|
5
|
+
* created function bodies. This is needed because Substrate's async transform
|
|
6
|
+
* converts `async function(){}` to generator wrappers, which means:
|
|
7
|
+
*
|
|
8
|
+
* const AsyncFunction = async function(){}.constructor;
|
|
9
|
+
*
|
|
10
|
+
* ...yields `Function` instead of `AsyncFunction`. Code like Vite's module
|
|
11
|
+
* runner that does `new AsyncFunction(code_with_await)` would fail with
|
|
12
|
+
* "await is only valid in async functions".
|
|
13
|
+
*
|
|
14
|
+
* The patched Function is installed as a process global (via _globals in
|
|
15
|
+
* ProcessEventLoop), so it only applies inside guest code running through
|
|
16
|
+
* runWithGlobals — not on the browser's global scope.
|
|
17
|
+
*/
|
|
18
|
+
/**
|
|
19
|
+
* Create a patched Function constructor that handles `await` in the body.
|
|
20
|
+
*
|
|
21
|
+
* When code contains `await` (which would always fail in a regular Function),
|
|
22
|
+
* we apply the async transform to make it work through SubstratePromise.
|
|
23
|
+
*
|
|
24
|
+
* Returns the patched Function to be installed as a process global.
|
|
25
|
+
*/
|
|
26
|
+
export declare function createPatchedFunction(): typeof Function;
|
|
27
|
+
//# sourceMappingURL=async-function-shim.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"async-function-shim.d.ts","sourceRoot":"","sources":["../../src/runtime/async-function-shim.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAmCH;;;;;;;GAOG;AACH,wBAAgB,qBAAqB,IAAI,OAAO,QAAQ,CAkCvD"}
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import type { DirEntry, StatResult } from "../kernel/types.js";
|
|
2
|
+
/**
|
|
3
|
+
* Hook called when a file is written that might be a native binding package.
|
|
4
|
+
* Set by the WASM package interceptor to enable detection.
|
|
5
|
+
*/
|
|
6
|
+
type NativeBindingHook = (path: string) => void;
|
|
7
|
+
/**
|
|
8
|
+
* Set the hook for detecting native binding writes.
|
|
9
|
+
* Called by the WASM package interceptor during initialization.
|
|
10
|
+
*/
|
|
11
|
+
export declare function setNativeBindingWriteHook(hook: NativeBindingHook | null): void;
|
|
12
|
+
/** Enable VFS tracking (call this from within the worker) */
|
|
13
|
+
export declare function enableVfsTracking(): void;
|
|
14
|
+
/** Disable VFS tracking */
|
|
15
|
+
export declare function disableVfsTracking(): void;
|
|
16
|
+
/** Track a VFS write and log if tracking is enabled */
|
|
17
|
+
export declare function trackVfsWrite(path: string, size: number): void;
|
|
18
|
+
/** Get VFS tracking stats */
|
|
19
|
+
export declare function getVfsStats(): {
|
|
20
|
+
totalBytesWritten: number;
|
|
21
|
+
largeFiles: Array<{
|
|
22
|
+
path: string;
|
|
23
|
+
size: number;
|
|
24
|
+
}>;
|
|
25
|
+
};
|
|
26
|
+
/** Reset VFS tracking stats */
|
|
27
|
+
export declare function resetVfsStats(): void;
|
|
28
|
+
export declare function readFile(path: string): Uint8Array;
|
|
29
|
+
export declare function writeFile(path: string, bytes: Uint8Array, mode?: number): void;
|
|
30
|
+
export declare function writeAt(path: string, bytes: Uint8Array, offset: number): number;
|
|
31
|
+
export declare function appendFile(path: string, bytes: Uint8Array): number;
|
|
32
|
+
export declare function stat(path: string): StatResult;
|
|
33
|
+
export declare function lstat(path: string): StatResult;
|
|
34
|
+
export declare function exists(path: string): boolean;
|
|
35
|
+
export declare function access(path: string, mode?: number): void;
|
|
36
|
+
export declare function readdir(path: string): DirEntry[];
|
|
37
|
+
export declare function mkdir(path: string, recursive: boolean, mode?: number): void;
|
|
38
|
+
export declare function chmod(path: string, mode: number): void;
|
|
39
|
+
export declare function fchmod(pid: number, fd: number, mode: number): void;
|
|
40
|
+
export declare function unlink(path: string): void;
|
|
41
|
+
export declare function rename(oldPath: string, newPath: string): void;
|
|
42
|
+
export declare function link(existingPath: string, newPath: string): void;
|
|
43
|
+
export declare function symlink(target: string, path: string): void;
|
|
44
|
+
export declare function readlink(path: string): string;
|
|
45
|
+
export declare function realpath(path: string): string;
|
|
46
|
+
export declare function open(pid: number, path: string, flags: string, mode?: number): number;
|
|
47
|
+
export declare function close(pid: number, fd: number): void;
|
|
48
|
+
export declare function read(pid: number, fd: number, length: number, position: number | null): {
|
|
49
|
+
bytes: Uint8Array;
|
|
50
|
+
bytes_read: number;
|
|
51
|
+
eof?: boolean;
|
|
52
|
+
};
|
|
53
|
+
export declare function write(pid: number, fd: number, bytes: Uint8Array, position: number | null): number;
|
|
54
|
+
export declare function truncate(pid: number, fd: number, size: number): void;
|
|
55
|
+
export declare function fstat(pid: number, fd: number): StatResult;
|
|
56
|
+
export declare function watch(path: string, recursive: boolean, eqId?: number): number;
|
|
57
|
+
export declare function unwatch(pid: number, watchId: number): void;
|
|
58
|
+
export declare function fsync(pid: number, fd: number): void;
|
|
59
|
+
export {};
|
|
60
|
+
//# sourceMappingURL=fs-interface.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fs-interface.d.ts","sourceRoot":"","sources":["../../src/runtime/fs-interface.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,QAAQ,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAS/D;;;GAGG;AACH,KAAK,iBAAiB,GAAG,CAAC,IAAI,EAAE,MAAM,KAAK,IAAI,CAAC;AAGhD;;;GAGG;AACH,wBAAgB,yBAAyB,CAAC,IAAI,EAAE,iBAAiB,GAAG,IAAI,GAAG,IAAI,CAG9E;AAoDD,6DAA6D;AAC7D,wBAAgB,iBAAiB,IAAI,IAAI,CAExC;AAED,2BAA2B;AAC3B,wBAAgB,kBAAkB,IAAI,IAAI,CAEzC;AAED,uDAAuD;AACvD,wBAAgB,aAAa,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,IAAI,CA4C9D;AAED,6B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EpE;AAED,wBAAgB,KAAK,CAAC,GAAG,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,GAAG,UAAU,CAIzD;AAED,wBAAgB,KAAK,CAAC,IAAI,EAAE,MAAM,EAAE,SAAS,EAAE,OAAO,EAAE,IAAI,CAAC,EAAE,MAAM,GAAG,MAAM,CAI7E;AAED,wBAAgB,OAAO,CAAC,GAAG,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,IAAI,CAG1D;AAED,wBAAgB,KAAK,CAAC,GAAG,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,GAAG,IAAI,CAGnD"}
|
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Substrate Runtime
|
|
3
|
+
*
|
|
4
|
+
* Orchestrates kernel initialization and Node compatibility setup.
|
|
5
|
+
*/
|
|
6
|
+
import type { KernelBridge, KernelResponse, KernelResponseFor, SyscallArgs, SyscallOp, KernelConfig } from "../kernel/types.js";
|
|
7
|
+
import { ProcessManager } from "./process-manager.js";
|
|
8
|
+
import type { ProcessContext } from "./process-context.js";
|
|
9
|
+
import type { BinaryName, BinarySpec } from "../binaries.js";
|
|
10
|
+
import { type WasmPackageMapping } from "./wasm-package-interceptor.js";
|
|
11
|
+
/**
|
|
12
|
+
* Interface for the kernel WASM glue exports.
|
|
13
|
+
*/
|
|
14
|
+
interface KernelWasmExports {
|
|
15
|
+
kernel_init(config_bytes: Uint8Array): Uint8Array;
|
|
16
|
+
kernel_syscall(req_bytes: Uint8Array): Uint8Array;
|
|
17
|
+
kernel_deliver(msg_bytes: Uint8Array): Uint8Array;
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Get the current WASM memory usage in bytes.
|
|
21
|
+
* Returns null if WASM is not initialized.
|
|
22
|
+
*/
|
|
23
|
+
export declare function getWasmMemorySize(): number | null;
|
|
24
|
+
/**
|
|
25
|
+
* Get formatted WASM memory usage string.
|
|
26
|
+
*/
|
|
27
|
+
export declare function getWasmMemoryInfo(): string;
|
|
28
|
+
/**
|
|
29
|
+
* Wraps the kernel WASM and provides a MessagePack-based interface.
|
|
30
|
+
*/
|
|
31
|
+
export declare class SubstrateKernel implements KernelBridge {
|
|
32
|
+
private exports;
|
|
33
|
+
constructor(exports: KernelWasmExports);
|
|
34
|
+
/**
|
|
35
|
+
* Initialize the kernel with configuration.
|
|
36
|
+
*/
|
|
37
|
+
init(config?: KernelConfig): KernelResponse<{
|
|
38
|
+
initialized: boolean;
|
|
39
|
+
}>;
|
|
40
|
+
syscall<Op extends SyscallOp>(op: Op, args?: SyscallArgs<Op>): KernelResponseFor<Op>;
|
|
41
|
+
deliver(msg: Record<string, unknown>): KernelResponse<{
|
|
42
|
+
delivered: boolean;
|
|
43
|
+
}>;
|
|
44
|
+
private parseResponse;
|
|
45
|
+
}
|
|
46
|
+
export interface SubstrateOptions {
|
|
47
|
+
/** URL to fetch the kernel WASM from */
|
|
48
|
+
kernel: string;
|
|
49
|
+
/** Initial working directory */
|
|
50
|
+
cwd?: string;
|
|
51
|
+
/** Environment variables */
|
|
52
|
+
env?: Record<string, string>;
|
|
53
|
+
/** Command-line arguments */
|
|
54
|
+
argv?: string[];
|
|
55
|
+
/** Kernel configuration */
|
|
56
|
+
config?: KernelConfig;
|
|
57
|
+
/** Install Node globals on globalThis (default: true) */
|
|
58
|
+
installGlobals?: boolean;
|
|
59
|
+
/** Binaries to install */
|
|
60
|
+
binaries?: Partial<Record<BinaryName, BinarySpec>>;
|
|
61
|
+
/** Custom WASM package mappings */
|
|
62
|
+
wasmPackages?: WasmPackageMapping[];
|
|
63
|
+
}
|
|
64
|
+
export interface SubstrateRuntime {
|
|
65
|
+
/** The kernel bridge */
|
|
66
|
+
kernel: SubstrateKernel;
|
|
67
|
+
/** Process manager - owns all process contexts */
|
|
68
|
+
processManager: ProcessManager;
|
|
69
|
+
/** Root process context (PID 1) */
|
|
70
|
+
rootProcess: ProcessContext;
|
|
71
|
+
/** Deliver a message to the kernel */
|
|
72
|
+
deliver(msg: Record<string, unknown>): boolean;
|
|
73
|
+
/** Shutdown the runtime */
|
|
74
|
+
shutdown(): void;
|
|
75
|
+
}
|
|
76
|
+
/**
|
|
77
|
+
* Create and initialize a Substrate runtime.
|
|
78
|
+
*
|
|
79
|
+
* @example
|
|
80
|
+
* ```ts
|
|
81
|
+
* import { createSubstrate, fs } from "@gadgetinc/substrate";
|
|
82
|
+
*
|
|
83
|
+
* // In production - load from CDN
|
|
84
|
+
* const runtime = await createSubstrate({
|
|
85
|
+
* kernel: "https://assets.gadget.dev/kernel.wasm?v=0.1.0",
|
|
86
|
+
* cwd: "/home/user",
|
|
87
|
+
* env: { NODE_ENV: "production" },
|
|
88
|
+
* });
|
|
89
|
+
*
|
|
90
|
+
* // In development - load from local dev server
|
|
91
|
+
* const runtime = await createSubstrate({
|
|
92
|
+
* kernel: "/kernel.wasm",
|
|
93
|
+
* cwd: "/home/user",
|
|
94
|
+
* });
|
|
95
|
+
*
|
|
96
|
+
* fs.writeFileSync("/test.txt", "hello");
|
|
97
|
+
* ```
|
|
98
|
+
*/
|
|
99
|
+
export declare function createSubstrate(options: SubstrateOptions): Promise<SubstrateRuntime>;
|
|
100
|
+
/**
|
|
101
|
+
* Ensure the es-module-lexer WASM is initialized.
|
|
102
|
+
* Can be called multiple times safely - will only initialize once.
|
|
103
|
+
*/
|
|
104
|
+
export declare function ensureLexerInit(): Promise<void>;
|
|
105
|
+
/**
|
|
106
|
+
* Register all Node.js builtin modules and WASM package interceptor.
|
|
107
|
+
* Exported for use by test helpers.
|
|
108
|
+
*/
|
|
109
|
+
export declare function registerBuiltins(wasmPackages?: WasmPackageMapping[]): void;
|
|
110
|
+
export { ProcessManager } from "./process-manager.js";
|
|
111
|
+
export type { ProcessContext, ProcessCreateOptions } from "./process-context.js";
|
|
112
|
+
export type { EventHandler as ProcessEventHandler, EventType as ProcessEventType, } from "./process-event-loop.js";
|
|
113
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
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