@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.
Files changed (181) hide show
  1. package/dist/assets/kernel.wasm +0 -0
  2. package/dist/assets/manifest.json +32 -0
  3. package/dist/assets/network-driver.js +2 -0
  4. package/dist/assets/network-driver.js.map +1 -0
  5. package/dist/assets/runtime.js +264 -0
  6. package/dist/assets/runtime.js.map +1 -0
  7. package/dist/binaries.d.ts +58 -0
  8. package/dist/binaries.d.ts.map +1 -0
  9. package/dist/boot/index.d.ts +318 -0
  10. package/dist/boot/index.d.ts.map +1 -0
  11. package/dist/index.d.ts +8 -0
  12. package/dist/index.d.ts.map +1 -0
  13. package/dist/index.js +4589 -0
  14. package/dist/index.js.map +1 -0
  15. package/dist/kernel/bridge.d.ts +64 -0
  16. package/dist/kernel/bridge.d.ts.map +1 -0
  17. package/dist/kernel/types.d.ts +518 -0
  18. package/dist/kernel/types.d.ts.map +1 -0
  19. package/dist/kernel/wasm.d.ts +20 -0
  20. package/dist/kernel/wasm.d.ts.map +1 -0
  21. package/dist/node/assert.d.ts +99 -0
  22. package/dist/node/assert.d.ts.map +1 -0
  23. package/dist/node/async_hooks.d.ts +88 -0
  24. package/dist/node/async_hooks.d.ts.map +1 -0
  25. package/dist/node/buffer.d.ts +62 -0
  26. package/dist/node/buffer.d.ts.map +1 -0
  27. package/dist/node/child_process.d.ts +300 -0
  28. package/dist/node/child_process.d.ts.map +1 -0
  29. package/dist/node/cluster.d.ts +37 -0
  30. package/dist/node/cluster.d.ts.map +1 -0
  31. package/dist/node/constants.d.ts +306 -0
  32. package/dist/node/constants.d.ts.map +1 -0
  33. package/dist/node/crypto.d.ts +176 -0
  34. package/dist/node/crypto.d.ts.map +1 -0
  35. package/dist/node/dgram.d.ts +44 -0
  36. package/dist/node/dgram.d.ts.map +1 -0
  37. package/dist/node/diagnostics_channel.d.ts +57 -0
  38. package/dist/node/diagnostics_channel.d.ts.map +1 -0
  39. package/dist/node/dns.d.ts +278 -0
  40. package/dist/node/dns.d.ts.map +1 -0
  41. package/dist/node/domain.d.ts +21 -0
  42. package/dist/node/domain.d.ts.map +1 -0
  43. package/dist/node/events.d.ts +54 -0
  44. package/dist/node/events.d.ts.map +1 -0
  45. package/dist/node/fs/promises.d.ts +116 -0
  46. package/dist/node/fs/promises.d.ts.map +1 -0
  47. package/dist/node/fs.d.ts +536 -0
  48. package/dist/node/fs.d.ts.map +1 -0
  49. package/dist/node/http.d.ts +471 -0
  50. package/dist/node/http.d.ts.map +1 -0
  51. package/dist/node/http2.d.ts +508 -0
  52. package/dist/node/http2.d.ts.map +1 -0
  53. package/dist/node/https.d.ts +42 -0
  54. package/dist/node/https.d.ts.map +1 -0
  55. package/dist/node/inspector.d.ts +25 -0
  56. package/dist/node/inspector.d.ts.map +1 -0
  57. package/dist/node/net.d.ts +231 -0
  58. package/dist/node/net.d.ts.map +1 -0
  59. package/dist/node/os.d.ts +318 -0
  60. package/dist/node/os.d.ts.map +1 -0
  61. package/dist/node/path.d.ts +144 -0
  62. package/dist/node/path.d.ts.map +1 -0
  63. package/dist/node/process.d.ts +105 -0
  64. package/dist/node/process.d.ts.map +1 -0
  65. package/dist/node/punycode.d.ts +34 -0
  66. package/dist/node/punycode.d.ts.map +1 -0
  67. package/dist/node/querystring.d.ts +49 -0
  68. package/dist/node/querystring.d.ts.map +1 -0
  69. package/dist/node/readline.d.ts +99 -0
  70. package/dist/node/readline.d.ts.map +1 -0
  71. package/dist/node/stream.d.ts +409 -0
  72. package/dist/node/stream.d.ts.map +1 -0
  73. package/dist/node/string_decoder.d.ts +46 -0
  74. package/dist/node/string_decoder.d.ts.map +1 -0
  75. package/dist/node/timers.d.ts +79 -0
  76. package/dist/node/timers.d.ts.map +1 -0
  77. package/dist/node/tls.d.ts +159 -0
  78. package/dist/node/tls.d.ts.map +1 -0
  79. package/dist/node/trace_events.d.ts +18 -0
  80. package/dist/node/trace_events.d.ts.map +1 -0
  81. package/dist/node/tty.d.ts +67 -0
  82. package/dist/node/tty.d.ts.map +1 -0
  83. package/dist/node/url.d.ts +85 -0
  84. package/dist/node/url.d.ts.map +1 -0
  85. package/dist/node/util.d.ts +252 -0
  86. package/dist/node/util.d.ts.map +1 -0
  87. package/dist/node/v8.d.ts +134 -0
  88. package/dist/node/v8.d.ts.map +1 -0
  89. package/dist/node/vm.d.ts +89 -0
  90. package/dist/node/vm.d.ts.map +1 -0
  91. package/dist/node/wasi.d.ts +25 -0
  92. package/dist/node/wasi.d.ts.map +1 -0
  93. package/dist/node/worker_threads.d.ts +206 -0
  94. package/dist/node/worker_threads.d.ts.map +1 -0
  95. package/dist/node/ws.d.ts +110 -0
  96. package/dist/node/ws.d.ts.map +1 -0
  97. package/dist/node/zlib.d.ts +328 -0
  98. package/dist/node/zlib.d.ts.map +1 -0
  99. package/dist/persistence/opfs-store.d.ts +93 -0
  100. package/dist/persistence/opfs-store.d.ts.map +1 -0
  101. package/dist/runtime/async-function-shim.d.ts +27 -0
  102. package/dist/runtime/async-function-shim.d.ts.map +1 -0
  103. package/dist/runtime/fs-interface.d.ts +60 -0
  104. package/dist/runtime/fs-interface.d.ts.map +1 -0
  105. package/dist/runtime/index.d.ts +113 -0
  106. package/dist/runtime/index.d.ts.map +1 -0
  107. package/dist/runtime/loader.d.ts +50 -0
  108. package/dist/runtime/loader.d.ts.map +1 -0
  109. package/dist/runtime/loaders/async-transform.d.ts +40 -0
  110. package/dist/runtime/loaders/async-transform.d.ts.map +1 -0
  111. package/dist/runtime/loaders/cjs.d.ts +37 -0
  112. package/dist/runtime/loaders/cjs.d.ts.map +1 -0
  113. package/dist/runtime/loaders/detect-module-type.d.ts +21 -0
  114. package/dist/runtime/loaders/detect-module-type.d.ts.map +1 -0
  115. package/dist/runtime/loaders/esm.d.ts +140 -0
  116. package/dist/runtime/loaders/esm.d.ts.map +1 -0
  117. package/dist/runtime/loaders/source-map-registry.d.ts +43 -0
  118. package/dist/runtime/loaders/source-map-registry.d.ts.map +1 -0
  119. package/dist/runtime/loaders/source-map.d.ts +50 -0
  120. package/dist/runtime/loaders/source-map.d.ts.map +1 -0
  121. package/dist/runtime/loaders/utils.d.ts +6 -0
  122. package/dist/runtime/loaders/utils.d.ts.map +1 -0
  123. package/dist/runtime/native-globals.d.ts +24 -0
  124. package/dist/runtime/native-globals.d.ts.map +1 -0
  125. package/dist/runtime/network-driver.d.ts +78 -0
  126. package/dist/runtime/network-driver.d.ts.map +1 -0
  127. package/dist/runtime/process-context.d.ts +96 -0
  128. package/dist/runtime/process-context.d.ts.map +1 -0
  129. package/dist/runtime/process-event-loop.d.ts +356 -0
  130. package/dist/runtime/process-event-loop.d.ts.map +1 -0
  131. package/dist/runtime/process-handler.d.ts +71 -0
  132. package/dist/runtime/process-handler.d.ts.map +1 -0
  133. package/dist/runtime/process-handlers/node.d.ts +22 -0
  134. package/dist/runtime/process-handlers/node.d.ts.map +1 -0
  135. package/dist/runtime/process-handlers/npm.d.ts +20 -0
  136. package/dist/runtime/process-handlers/npm.d.ts.map +1 -0
  137. package/dist/runtime/process-handlers/npx.d.ts +11 -0
  138. package/dist/runtime/process-handlers/npx.d.ts.map +1 -0
  139. package/dist/runtime/process-handlers/pnpm.d.ts +12 -0
  140. package/dist/runtime/process-handlers/pnpm.d.ts.map +1 -0
  141. package/dist/runtime/process-handlers/shell.d.ts +24 -0
  142. package/dist/runtime/process-handlers/shell.d.ts.map +1 -0
  143. package/dist/runtime/process-handlers/yarn.d.ts +12 -0
  144. package/dist/runtime/process-handlers/yarn.d.ts.map +1 -0
  145. package/dist/runtime/process-helpers.d.ts +17 -0
  146. package/dist/runtime/process-helpers.d.ts.map +1 -0
  147. package/dist/runtime/process-manager.d.ts +87 -0
  148. package/dist/runtime/process-manager.d.ts.map +1 -0
  149. package/dist/runtime/process-scheduler.d.ts +123 -0
  150. package/dist/runtime/process-scheduler.d.ts.map +1 -0
  151. package/dist/runtime/process-waker.d.ts +24 -0
  152. package/dist/runtime/process-waker.d.ts.map +1 -0
  153. package/dist/runtime/promise.d.ts +44 -0
  154. package/dist/runtime/promise.d.ts.map +1 -0
  155. package/dist/runtime/stack-trace.d.ts +52 -0
  156. package/dist/runtime/stack-trace.d.ts.map +1 -0
  157. package/dist/runtime/wasm-package-interceptor.d.ts +141 -0
  158. package/dist/runtime/wasm-package-interceptor.d.ts.map +1 -0
  159. package/dist/runtime/web-streams.d.ts +57 -0
  160. package/dist/runtime/web-streams.d.ts.map +1 -0
  161. package/dist/runtime/websocket.d.ts +102 -0
  162. package/dist/runtime/websocket.d.ts.map +1 -0
  163. package/dist/shim/websocket-shim-inline.d.ts +9 -0
  164. package/dist/shim/websocket-shim-inline.d.ts.map +1 -0
  165. package/dist/shim/websocket-shim.d.ts +15 -0
  166. package/dist/shim/websocket-shim.d.ts.map +1 -0
  167. package/dist/sw/index.d.ts +53 -0
  168. package/dist/sw/index.d.ts.map +1 -0
  169. package/dist/utils/debug.d.ts +75 -0
  170. package/dist/utils/debug.d.ts.map +1 -0
  171. package/dist/utils/path.d.ts +20 -0
  172. package/dist/utils/path.d.ts.map +1 -0
  173. package/dist/utils/tarball.d.ts +37 -0
  174. package/dist/utils/tarball.d.ts.map +1 -0
  175. package/dist/utils/websocket-protocol.d.ts +102 -0
  176. package/dist/utils/websocket-protocol.d.ts.map +1 -0
  177. package/dist/worker/host.d.ts +14 -0
  178. package/dist/worker/host.d.ts.map +1 -0
  179. package/dist/worker/types.d.ts +209 -0
  180. package/dist/worker/types.d.ts.map +1 -0
  181. package/package.json +53 -0
@@ -0,0 +1,356 @@
1
+ /**
2
+ * Per-Process Event Loop
3
+ *
4
+ * Each process gets its own event loop instance with isolated:
5
+ * - nextTick queue
6
+ * - Timer management (heap + single browser timer)
7
+ * - setImmediate (check) queue
8
+ * - Close callbacks queue
9
+ *
10
+ * The event loop implements Node.js phase ordering:
11
+ * 1. timers - setTimeout/setInterval callbacks
12
+ * 2. pending callbacks - I/O callbacks deferred to next loop
13
+ * 3. poll - retrieve new I/O events from kernel
14
+ * 4. check - setImmediate callbacks
15
+ * 5. close callbacks - socket.on('close', ...)
16
+ *
17
+ * Between each phase, nextTick queue is drained, then Promise microtasks run.
18
+ */
19
+ import type { KernelBridge, KernelEvent } from "../kernel/types.js";
20
+ import { type Waker } from "./process-waker.js";
21
+ /**
22
+ * Set the global pending work hook.
23
+ * Called by the WASM package interceptor to keep event loops alive during installation.
24
+ */
25
+ export declare function setGlobalPendingWorkHook(hook: (() => boolean) | null): void;
26
+ export declare class UnhandledEventLoopError extends Error {
27
+ constructor(message: string, cause: unknown);
28
+ }
29
+ type Callback = (...args: unknown[]) => void;
30
+ interface ImmediateEntry {
31
+ id: number;
32
+ callback: Callback;
33
+ args?: unknown[];
34
+ ref: boolean;
35
+ cleared: boolean;
36
+ }
37
+ /**
38
+ * Timer entry in the heap
39
+ */
40
+ interface TimerEntry {
41
+ id: number;
42
+ callback: Callback;
43
+ args?: unknown[];
44
+ expireAt: number;
45
+ delay: number;
46
+ refresh(): void;
47
+ interval: number | null;
48
+ ref: boolean;
49
+ cleared: boolean;
50
+ }
51
+ /**
52
+ * Timer handle returned to user code
53
+ */
54
+ export declare class Timeout {
55
+ private _id;
56
+ private _timer;
57
+ constructor(id: number, timer: TimerEntry);
58
+ ref(): this;
59
+ unref(): this;
60
+ hasRef(): boolean;
61
+ refresh(): this;
62
+ [Symbol.toPrimitive](): number;
63
+ [Symbol.dispose](): void;
64
+ }
65
+ /**
66
+ * Immediate handle returned to user code
67
+ */
68
+ export declare class Immediate {
69
+ private _id;
70
+ private _immediate;
71
+ constructor(id: number, immediate: ImmediateEntry);
72
+ ref(): this;
73
+ unref(): this;
74
+ hasRef(): boolean;
75
+ [Symbol.toPrimitive](): number;
76
+ [Symbol.dispose](): void;
77
+ }
78
+ export type TimerHandle = Timeout;
79
+ export type ImmediateHandle = Immediate;
80
+ /**
81
+ * Event handler callback type
82
+ */
83
+ export type EventHandler<T extends KernelEvent = KernelEvent> = (event: T) => void;
84
+ /**
85
+ * Typed event names matching kernel event types
86
+ */
87
+ export type EventType = "fs_watch_event" | "fs_read_complete" | "fs_read_error" | "fs_write_complete" | "fs_write_error" | "net_accept" | "net_readable" | "net_closed" | "proc_exit" | "pipe_readable" | "proc_stdout" | "proc_stderr" | "timer_fired" | "log";
88
+ export { type Waker, createWaker, registerWaker, unregisterWaker, wakeAllWakers, } from "./process-waker.js";
89
+ export declare const createProcessEventLoop: (pid: number, kernel: KernelBridge) => ProcessEventLoopImpl;
90
+ /**
91
+ * Get a process event loop, throwing an error if not found.
92
+ * NOTE TO LLMs: Do not right defensive code for this function.
93
+ * If the runtime needs an event loop and one doesn't exist, throw an error.
94
+ * It is a critical error if this function throws and we should know early.
95
+ */
96
+ export declare const getProcessEventLoop: (pid: number) => ProcessEventLoopImpl;
97
+ /**
98
+ * Reset all event loops (test helper).
99
+ */
100
+ export declare const resetEventLoops: () => void;
101
+ export type ProcessEventLoop = ProcessEventLoopImpl;
102
+ /**
103
+ * I/O handle callback type - called when kernel events are ready for this handle
104
+ */
105
+ type HandleCallback = (event: KernelEvent) => void;
106
+ /**
107
+ * Async context snapshot — maps AsyncLocalStorage instances to their stores.
108
+ * Used to propagate context across async boundaries (setTimeout, Promise.then, etc.)
109
+ */
110
+ export type AsyncContext = Map<object, unknown>;
111
+ /**
112
+ * Per-process event loop
113
+ *
114
+ * Each process gets its own isolated event loop with its own queues and timers.
115
+ */
116
+ declare class ProcessEventLoopImpl {
117
+ /** Process ID this event loop belongs to */
118
+ readonly pid: number;
119
+ /** Kernel bridge (shared across processes) */
120
+ private kernel;
121
+ /** Kernel event queue ID for this process */
122
+ private eqId;
123
+ /** Whether the event loop is running */
124
+ private running;
125
+ /**
126
+ * Set when process.exit() is called. Ensures the event loop exits even if
127
+ * user code catches the ProcessExitError. The stored code/signal are used
128
+ * to throw a new ProcessExitError after the loop breaks.
129
+ */
130
+ private _exitRequested;
131
+ /**
132
+ * The currently active async context for this process.
133
+ * Maps AsyncLocalStorage instances to their store values.
134
+ * null means no context is active (default state).
135
+ */
136
+ private _currentAsyncContext;
137
+ /** nextTick queue - drains synchronously, runs BEFORE Promise microtasks */
138
+ private nextTickQueue;
139
+ /**
140
+ * Node microtask queue - for Promise .then() callbacks and queueMicrotask()
141
+ * This runs AFTER nextTick but still within our controlled checkpoint.
142
+ * User code's Promise continuations go here instead of browser's microtask queue.
143
+ */
144
+ private nodeMicrotaskQueue;
145
+ /** Timer heap - ordered by expiration time */
146
+ private timerHeap;
147
+ private nextTimerId;
148
+ /** Immediate (check) queue */
149
+ private immediateQueue;
150
+ private nextImmediateId;
151
+ /** Close callbacks queue */
152
+ private closeQueue;
153
+ /** Pending I/O callbacks (from poll phase) */
154
+ private pendingCallbacks;
155
+ /**
156
+ * Registered I/O handles by ID.
157
+ * Key format: "server:{server_id}" or "conn:{conn_id}" or "watch:{watch_id}"
158
+ */
159
+ private handles;
160
+ private refCount;
161
+ /** Waker for signaling the event loop to wake up from poll */
162
+ wake: Waker;
163
+ private _globals;
164
+ private _builtinModules;
165
+ private _checkUnhandledRejections;
166
+ constructor(pid: number, kernel: KernelBridge);
167
+ /**
168
+ * Create a wrapped fetch function that returns SubstratePromise.
169
+ * This ensures that fetch() continuations run through our event loop's
170
+ * microtask queue instead of the browser's native microtask queue.
171
+ */
172
+ private createWrappedFetch;
173
+ /**
174
+ * Initialize the kernel event queue for this process
175
+ */
176
+ private initKernelEventQueue;
177
+ /**
178
+ * Get the kernel event queue ID for this process.
179
+ * Used when registering for kernel events (e.g., net_listen with eq_id).
180
+ */
181
+ getEventQueueId(): number | null;
182
+ /**
183
+ * Capture the current async context. Returns null if no context is active.
184
+ * Called when scheduling callbacks (setTimeout, nextTick, Promise.then, etc.)
185
+ * to snapshot the context at schedule time.
186
+ */
187
+ captureAsyncContext(): AsyncContext | null;
188
+ /**
189
+ * Run a function within a given async context.
190
+ * The previous context is saved and restored after the function completes.
191
+ */
192
+ runInAsyncContext<T>(context: AsyncContext | null, fn: () => T): T;
193
+ /**
194
+ * Replace the current async context entirely.
195
+ * Used by AsyncLocalStorage.enterWith() which permanently modifies
196
+ * the context for the remainder of the current execution.
197
+ */
198
+ setCurrentAsyncContext(context: AsyncContext | null): void;
199
+ /**
200
+ * Wrap a callback with the current async context so it is restored
201
+ * when the callback executes. This is the core mechanism for propagating
202
+ * AsyncLocalStorage stores across async boundaries.
203
+ */
204
+ private wrapWithContext;
205
+ /**
206
+ * Register a server handle. When NetAccept events arrive for this server,
207
+ * the callback will be queued as a pending I/O callback.
208
+ */
209
+ registerServer(serverId: number, callback: HandleCallback, ref?: boolean): void;
210
+ /**
211
+ * Unregister a server handle.
212
+ */
213
+ unregisterServer(serverId: number): void;
214
+ /**
215
+ * Register a connection handle. When events arrive for this connection,
216
+ * the callback will be queued as a pending I/O callback.
217
+ */
218
+ registerConnection(connId: number, callback: HandleCallback, ref?: boolean): void;
219
+ /**
220
+ * Register a filesystem watch handle. When FsWatch events arrive for this watch,
221
+ * the callback will be queued as a pending I/O callback.
222
+ */
223
+ registerFsWatch(watchId: number, callback: HandleCallback, ref?: boolean): void;
224
+ /**
225
+ * Register a pipe/fd handle. When PipeReadable events arrive for this fd,
226
+ * the callback will be queued as a pending I/O callback.
227
+ */
228
+ registerFdReadable(fd: number, callback: HandleCallback, ref?: boolean): void;
229
+ /**
230
+ * Unregister a connection handle.
231
+ */
232
+ unregisterConnection(connId: number): void;
233
+ /**
234
+ * Unregister a filesystem watch handle.
235
+ */
236
+ unregisterFsWatch(watchId: number): void;
237
+ /**
238
+ * Unregister a pipe/fd handle.
239
+ */
240
+ unregisterFdReadable(fd: number): void;
241
+ /**
242
+ * Queue a callback as a pending I/O callback.
243
+ * These run in the pending callbacks phase.
244
+ */
245
+ queuePendingCallback(callback: Callback): void;
246
+ setGlobal(key: string, value: unknown): void;
247
+ /**
248
+ * Report an unhandled promise rejection.
249
+ *
250
+ * Called by the SubstratePromise checkpoint after microtask queues drain.
251
+ * Mirrors Node.js semantics: if a process.on('unhandledRejection') handler
252
+ * exists, emit the event. Otherwise, print the error and exit with code 1.
253
+ */
254
+ reportUnhandledRejection(reason: unknown, promise: unknown): void;
255
+ isBuiltinModule(name: string): boolean;
256
+ runWithGlobals<T>(fn: () => T): T;
257
+ nextTick(callback: Callback, ...args: unknown[]): void;
258
+ queueMicrotask(callback: Callback): void;
259
+ setImmediate(callback: Callback, ...args: unknown[]): Immediate;
260
+ clearImmediate(immediate: Immediate | number | null | undefined): void;
261
+ queuePending(callback: Callback): void;
262
+ queueClose(callback: Callback): void;
263
+ setTimeout(callback: Callback, delayMs: number, ...args: unknown[]): Timeout;
264
+ setInterval(callback: Callback, intervalMs: number, ...args: unknown[]): Timeout;
265
+ clearTimeout(timeout: Timeout | number | null | undefined): void;
266
+ clearInterval(interval: Timeout | number | null | undefined): void;
267
+ /**
268
+ * Add a reference to keep the event loop alive.
269
+ * Used by servers, sockets, and other long-running handles.
270
+ */
271
+ ref(): void;
272
+ /**
273
+ * Remove a reference. When all references are removed and no other work
274
+ * is pending, the event loop will exit.
275
+ */
276
+ unref(): void;
277
+ /**
278
+ * Start the event loop
279
+ */
280
+ start(): Promise<void>;
281
+ /**
282
+ * Run a single event loop iteration (test helper).
283
+ */
284
+ runOnce(): Promise<void>;
285
+ /**
286
+ * Request the event loop to exit with the given code.
287
+ *
288
+ * Called by process.exit(). In real Node.js, process.exit() is uncatchable —
289
+ * it terminates the process immediately. In Substrate, process.exit() throws
290
+ * a ProcessExitError which CAN be caught by user code (e.g., pnpm wraps
291
+ * internal scripts in try/catch). This method ensures the event loop exits
292
+ * on the next iteration even if user code swallows the error. The stored
293
+ * code/signal are re-thrown as a ProcessExitError after the loop breaks.
294
+ */
295
+ requestExit(code: number, signal?: string | null): void;
296
+ /**
297
+ * Stop the event loop
298
+ */
299
+ stop(): void;
300
+ /**
301
+ * Check if the event loop is running
302
+ */
303
+ isRunning(): boolean;
304
+ /**
305
+ * Test helper for inspecting waker state.
306
+ */
307
+ __getWakerWaiterCount(): number;
308
+ private loopAlive;
309
+ /**
310
+ * Check if the process was signaled before the event loop started.
311
+ *
312
+ * This handles the race condition where:
313
+ * 1. Parent spawns child, gets pid
314
+ * 2. Parent calls child.kill() before child's event loop creates its event queue
315
+ * 3. Kernel emits ProcExit event, but eq_id is None so it's dropped
316
+ * 4. Child's event loop starts and never sees the signal
317
+ *
318
+ * By checking the process's signal state at startup, we can recover from this.
319
+ */
320
+ private checkPendingSignal;
321
+ private runIteration;
322
+ private poll;
323
+ /**
324
+ * Poll kernel event queue and dispatch events to listeners.
325
+ * Returns true if any events were processed.
326
+ */
327
+ private pollKernelEvents;
328
+ /**
329
+ * Dispatch a kernel event by looking up the handle and queuing its callback
330
+ * as a pending I/O callback.
331
+ */
332
+ private dispatchKernelEvent;
333
+ private computePollTimeout;
334
+ /**
335
+ * Find the next non-cleared, ref'd timer (for poll timeout calculation).
336
+ * Unlike peekNextActiveTimer(), this only returns ref'd timers.
337
+ */
338
+ private peekNextRefedTimer;
339
+ private drainPhaseQueue;
340
+ private callAndDrainNextTickAndMicrotaskQueues;
341
+ private callAndRethrow;
342
+ private drainNextTickAndMicrotaskQueues;
343
+ private drainQueue;
344
+ private hasImmediateWork;
345
+ private addTimer;
346
+ private runTimers;
347
+ private peekNextActiveTimer;
348
+ /**
349
+ * Check if there are any ref'd timers that would keep the loop alive.
350
+ * Unref'd timers don't keep the loop alive but will still fire if the loop
351
+ * is running for other reasons.
352
+ */
353
+ private hasActiveTimers;
354
+ private timersDueNow;
355
+ }
356
+ //# sourceMappingURL=process-event-loop.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"process-event-loop.d.ts","sourceRoot":"","sources":["../../src/runtime/process-event-loop.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AAEH,OAAO,KAAK,EAAE,YAAY,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AAUpE,OAAO,EAAE,KAAK,KAAK,EAA+C,MAAM,oBAAoB,CAAC;AAoG7F;;;GAGG;AACH,wBAAgB,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AI,OAAO,CAEnB;IAED;;OAEG;IACH,qBAAqB,IAAI,MAAM,CAE9B;IAED,OAAO,CAAC,SAAS;IAuCjB;;;;;;;;;;OAUG;IACH,OAAO,CAAC,kBAAkB;YAyBZ,YAAY;YAyCZ,IAAI;IAuClB;;;OAGG;IACH,OAAO,CAAC,gBAAgB;IA4BxB;;;OAGG;IACH,OAAO,CAAC,mBAAmB;IAiG3B,OAAO,CAAC,kBAAkB;IAuB1B;;;OAGG;IACH,OAAO,CAAC,kBAAkB;IAc1B,OAAO,CAAC,eAAe;IAsBvB,OAAO,CAAC,sCAAsC;IAK9C,OAAO,CAAC,cAAc;IAoDtB,OAAO,CAAC,+BAA+B;IAwBvC,OAAO,CAAC,UAAU;IAiBlB,OAAO,CAAC,gBAAgB;IAWxB,OAAO,CAAC,QAAQ;IAmChB,OAAO,CAAC,SAAS;IAyBjB,OAAO,CAAC,mBAAmB;IAa3B;;;;OAIG;IACH,OAAO,CAAC,eAAe;IAIvB,OAAO,CAAC,YAAY;CAKrB"}
@@ -0,0 +1,71 @@
1
+ import type { ProcessContext } from "./process-context.js";
2
+ import type { BinaryName, BinarySpec } from "../binaries.js";
3
+ /**
4
+ * Callback invoked when a process exits.
5
+ */
6
+ export type ProcessExitCallback = (exitCode: number, signal: string | null) => void;
7
+ /**
8
+ * Process Handler Interface
9
+ *
10
+ * Handlers are responsible for the full lifecycle of a process:
11
+ * - Parsing arguments
12
+ * - Setting up execution environment
13
+ * - Running the process (however that makes sense for this handler)
14
+ * - Calling onExit when complete
15
+ *
16
+ * For Node.js handlers, this means creating an event loop internally.
17
+ * Future handlers (WASM, etc.) may use different execution models.
18
+ */
19
+ export interface ProcessHandler {
20
+ /** List of commands this handler can execute */
21
+ commands: string[];
22
+ /**
23
+ * Install the binary for the process from a tar URL.
24
+ * Optional - only needed for handlers that require external installation.
25
+ */
26
+ install?(tarUrl: string): Promise<void>;
27
+ /**
28
+ * Start a process.
29
+ *
30
+ * The handler is responsible for:
31
+ * 1. Parsing arguments
32
+ * 2. Setting up the execution environment
33
+ * 3. Running the process (creating event loop, starting WASM, etc.)
34
+ * 4. Calling onExit(code, signal) when the process completes
35
+ *
36
+ * This method should return quickly - the actual execution happens
37
+ * asynchronously via the handler's internal scheduling mechanism.
38
+ *
39
+ * @param command - The command being executed
40
+ * @param args - Arguments passed to the command
41
+ * @param processContext - The ProcessContext for this execution
42
+ * @param onExit - Callback to invoke when the process exits
43
+ */
44
+ start(command: string, args: string[], processContext: ProcessContext, onExit: ProcessExitCallback): void;
45
+ }
46
+ /**
47
+ * Register a process handler.
48
+ *
49
+ * If a handler already exists for any of the commands, it will be replaced.
50
+ * This allows WASM packages to override handlers when detected.
51
+ */
52
+ export declare function registerHandler(handler: ProcessHandler): void;
53
+ /**
54
+ * Get a handler for a command.
55
+ */
56
+ export declare function getHandler(command: string): ProcessHandler;
57
+ /**
58
+ * Check if a handler exists for a command.
59
+ */
60
+ export declare function hasHandler(command: string): boolean;
61
+ /**
62
+ * Get all registered commands.
63
+ */
64
+ export declare function getRegisteredCommands(): string[];
65
+ /**
66
+ * Initialize process handlers for the specified binaries.
67
+ *
68
+ * This is called during Substrate boot to set up handlers that need installation.
69
+ */
70
+ export declare function initProcessHandlers(binaries: Partial<Record<BinaryName, BinarySpec>>): Promise<void>;
71
+ //# sourceMappingURL=process-handler.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"process-handler.d.ts","sourceRoot":"","sources":["../../src/runtime/process-handler.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AAE3D,OAAO,KAAK,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAU7D;;GAEG;AACH,MAAM,MAAM,mBAAmB,GAAG,CAAC,QAAQ,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,IAAI,KAAK,IAAI,CAAC;AAEpF;;;;;;;;;;;GAWG;AACH,MAAM,WAAW,cAAc;IAC7B,gDAAgD;IAChD,QAAQ,EAAE,MAAM,EAAE,CAAC;IAEnB;;;OAGG;IACH,OAAO,CAAC,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAExC;;;;;;;;;;;;;;;;OAgBG;IACH,KAAK,CACH,OAAO,EAAE,MAAM,EACf,IAAI,EAAE,MAAM,EAAE,EACd,cAAc,EAAE,cAAc,EAC9B,MAAM,EAAE,mBAAmB,GAC1B,IAAI,CAAC;CACT;AAKD;;;;;GAKG;AACH,wBAAgB,eAAe,CAAC,OAAO,EAAE,cAAc,GAAG,IAAI,CAY7D;AAED;;GAEG;AACH,wBAAgB,UAAU,CAAC,OAAO,EAAE,MAAM,GAAG,cAAc,CAM1D;AAED;;GAEG;AACH,wBAAgB,UAAU,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAEnD;AAED;;GAEG;AACH,wBAAgB,qBAAqB,IAAI,MAAM,EAAE,CAQhD;AAED;;;;GAIG;AACH,wBAAsB,mBAAmB,CACvC,QAAQ,EAAE,OAAO,CAAC,MAAM,CAAC,UAAU,EAAE,UAAU,CAAC,CAAC,GAChD,OAAO,CAAC,IAAI,CAAC,CA6Bf"}
@@ -0,0 +1,22 @@
1
+ /**
2
+ * Node.js Process Handler
3
+ *
4
+ * Handles `node` command by running scripts within an isolated ProcessContext.
5
+ * Each child process has its own event loop, module cache, and state.
6
+ */
7
+ import type { ProcessHandler } from "../process-handler.js";
8
+ /**
9
+ * Handler for `node` command
10
+ *
11
+ * Executes Node.js scripts in an isolated ProcessContext with its own event loop.
12
+ *
13
+ * Supports:
14
+ * - Running .js/.mjs/.cjs files
15
+ * - -e/--eval for inline code
16
+ * - -p/--print for eval + print
17
+ * - -c/--check for syntax checking
18
+ * - -r/--require for preloading modules
19
+ */
20
+ declare const NodeHandler: ProcessHandler;
21
+ export default NodeHandler;
22
+ //# sourceMappingURL=node.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"node.d.ts","sourceRoot":"","sources":["../../../src/runtime/process-handlers/node.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,cAAc,EAAuB,MAAM,uBAAuB,CAAC;AAcjF;;;;;;;;;;;GAWG;AACH,QAAA,MAAM,WAAW,EAAE,cA8DlB,CAAC;AAuPF,eAAe,WAAW,CAAC"}
@@ -0,0 +1,20 @@
1
+ /**
2
+ * npm Process Handler
3
+ *
4
+ * Delegates to real npm, auto-installing on first use if needed.
5
+ */
6
+ import type { ProcessHandler } from "../process-handler.js";
7
+ export declare const NPM_INSTALL_PATH = "/usr/lib/node_modules/npm";
8
+ export declare const NPM_BIN_PATH = "/usr/lib/node_modules/npm/bin/npm-cli.js";
9
+ /**
10
+ * Check if real npm is already installed
11
+ */
12
+ export declare function isNpmInstalled(): boolean;
13
+ /**
14
+ * Handler for `npm` command
15
+ *
16
+ * Auto-installs npm on first use, then delegates to real npm.
17
+ */
18
+ export declare const NpmHandler: ProcessHandler;
19
+ export default NpmHandler;
20
+ //# sourceMappingURL=npm.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"npm.d.ts","sourceRoot":"","sources":["../../../src/runtime/process-handlers/npm.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAIH,OAAO,KAAK,EAAE,cAAc,EAAuB,MAAM,uBAAuB,CAAC;AAMjF,eAAO,MAAM,gBAAgB,8BAA8B,CAAC;AAC5D,eAAO,MAAM,YAAY,6CAA6C,CAAC;AAEvE;;GAEG;AACH,wBAAgB,cAAc,IAAI,OAAO,CAMxC;AAMD;;;;GAIG;AACH,eAAO,MAAM,UAAU,EAAE,cAqDxB,CAAC;AAEF,eAAe,UAAU,CAAC"}
@@ -0,0 +1,11 @@
1
+ /**
2
+ * npx Process Handler
3
+ *
4
+ * Delegates to npx-cli.js which ships with the npm package.
5
+ * No separate installation needed — npx is available whenever npm is installed.
6
+ */
7
+ import type { ProcessHandler } from "../process-handler.js";
8
+ export declare const NPX_BIN_PATH = "/usr/lib/node_modules/npm/bin/npx-cli.js";
9
+ export declare const NpxHandler: ProcessHandler;
10
+ export default NpxHandler;
11
+ //# sourceMappingURL=npx.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"npx.d.ts","sourceRoot":"","sources":["../../../src/runtime/process-handlers/npx.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,cAAc,EAAuB,MAAM,uBAAuB,CAAC;AAIjF,eAAO,MAAM,YAAY,6CAA6C,CAAC;AAEvE,eAAO,MAAM,UAAU,EAAE,cAWxB,CAAC;AAEF,eAAe,UAAU,CAAC"}
@@ -0,0 +1,12 @@
1
+ /**
2
+ * pnpm Process Handler
3
+ *
4
+ * Delegates to real pnpm, auto-installing on first use if needed.
5
+ */
6
+ import type { ProcessHandler } from "../process-handler.js";
7
+ export declare const PNPM_INSTALL_PATH = "/usr/lib/node_modules/pnpm";
8
+ export declare const PNPM_BIN_PATH = "/usr/lib/node_modules/pnpm/bin/pnpm.cjs";
9
+ export declare function isPnpmInstalled(): boolean;
10
+ export declare const PnpmHandler: ProcessHandler;
11
+ export default PnpmHandler;
12
+ //# sourceMappingURL=pnpm.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"pnpm.d.ts","sourceRoot":"","sources":["../../../src/runtime/process-handlers/pnpm.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAIH,OAAO,KAAK,EAAE,cAAc,EAAuB,MAAM,uBAAuB,CAAC;AAKjF,eAAO,MAAM,iBAAiB,+BAA+B,CAAC;AAC9D,eAAO,MAAM,aAAa,4CAA4C,CAAC;AAEvE,wBAAgB,eAAe,IAAI,OAAO,CAMzC;AAED,eAAO,MAAM,WAAW,EAAE,cA+BzB,CAAC;AAEF,eAAe,WAAW,CAAC"}
@@ -0,0 +1,24 @@
1
+ /**
2
+ * Shell Handler
3
+ *
4
+ * Shims common shells (sh, bash) to support npm postinstall scripts and other
5
+ * shell-based commands. Parses simple commands and delegates to known handlers.
6
+ *
7
+ * Supports:
8
+ * - `sh -c "node install.js"` → delegates to node handler
9
+ * - `sh -c "npm run build"` → delegates to npm handler
10
+ * - `bash -c "command"` → same as sh
11
+ *
12
+ * Does NOT support:
13
+ * - Pipes: `cmd1 | cmd2`
14
+ * - Redirects: `cmd > file`
15
+ * - Shell builtins: `cd`, `export`, `echo` (most)
16
+ * - Complex quoting/escaping
17
+ */
18
+ import type { ProcessHandler } from "../process-handler.js";
19
+ /**
20
+ * Shell handler that intercepts sh/bash -c commands and delegates to known handlers.
21
+ */
22
+ export declare const ShellHandler: ProcessHandler;
23
+ export default ShellHandler;
24
+ //# sourceMappingURL=shell.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"shell.d.ts","sourceRoot":"","sources":["../../../src/runtime/process-handlers/shell.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAEH,OAAO,KAAK,EAAE,cAAc,EAAuB,MAAM,uBAAuB,CAAC;AAkDjF;;GAEG;AACH,eAAO,MAAM,YAAY,EAAE,cA+F1B,CAAC;AAEF,eAAe,YAAY,CAAC"}
@@ -0,0 +1,12 @@
1
+ /**
2
+ * Yarn Classic Process Handler
3
+ *
4
+ * Delegates to real Yarn Classic (v1.x), auto-installing on first use if needed.
5
+ */
6
+ import type { ProcessHandler } from "../process-handler.js";
7
+ export declare const YARN_INSTALL_PATH = "/usr/lib/node_modules/yarn";
8
+ export declare const YARN_BIN_PATH = "/usr/lib/node_modules/yarn/bin/yarn.js";
9
+ export declare function isYarnInstalled(): boolean;
10
+ export declare const YarnHandler: ProcessHandler;
11
+ export default YarnHandler;
12
+ //# sourceMappingURL=yarn.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"yarn.d.ts","sourceRoot":"","sources":["../../../src/runtime/process-handlers/yarn.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAIH,OAAO,KAAK,EAAE,cAAc,EAAuB,MAAM,uBAAuB,CAAC;AAKjF,eAAO,MAAM,iBAAiB,+BAA+B,CAAC;AAC9D,eAAO,MAAM,aAAa,2CAA2C,CAAC;AAEtE,wBAAgB,eAAe,IAAI,OAAO,CAMzC;AAED,eAAO,MAAM,WAAW,EAAE,cA+BzB,CAAC;AAEF,eAAe,WAAW,CAAC"}
@@ -0,0 +1,17 @@
1
+ /**
2
+ * Shared Process Helpers
3
+ *
4
+ * Utilities for creating per-process console and formatting values.
5
+ * Used by both NodeHandler and worker_threads.
6
+ */
7
+ import type { ProcessContext } from "./process-context.js";
8
+ /**
9
+ * Format a value for console output
10
+ */
11
+ export declare function formatValue(value: unknown): string;
12
+ /**
13
+ * Create a console object that writes to a process's stdout/stderr.
14
+ * This is injected into process contexts to shadow the global console.
15
+ */
16
+ export declare function createConsole(processContext: ProcessContext): Console;
17
+ //# sourceMappingURL=process-helpers.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"process-helpers.d.ts","sourceRoot":"","sources":["../../src/runtime/process-helpers.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AAG3D;;GAEG;AACH,wBAAgB,WAAW,CAAC,KAAK,EAAE,OAAO,GAAG,MAAM,CAiBlD;AAED;;;GAGG;AACH,wBAAgB,aAAa,CAAC,cAAc,EAAE,cAAc,GAAG,OAAO,CA4CrE"}