@deepseek-ai/dsh-experimental-webworker-runtime 0.1.6-alpha.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/LICENSE +21 -0
- package/README.i18n.yaml +6 -0
- package/README.md +75 -0
- package/README.zh.md +75 -0
- package/lib/client.js +854 -0
- package/lib/index.js +3506 -0
- package/lib/types/client/apply-injections.d.ts +15 -0
- package/lib/types/client/client.d.ts +102 -0
- package/lib/types/client/index.d.ts +66 -0
- package/lib/types/client/source-chooser.d.ts +8 -0
- package/lib/types/compile/transform.d.ts +39 -0
- package/lib/types/fixture-manifest.d.ts +26 -0
- package/lib/types/image-layout.d.ts +43 -0
- package/lib/types/index.d.ts +23 -0
- package/lib/types/module-proxies.d.ts +25 -0
- package/lib/types/module-system/module-loader.d.ts +177 -0
- package/lib/types/module-system/posix-path.d.ts +98 -0
- package/lib/types/node/builtin_modules/implemented/abort-error.d.ts +11 -0
- package/lib/types/node/builtin_modules/implemented/async_hooks.d.ts +174 -0
- package/lib/types/node/builtin_modules/implemented/buffer.d.ts +28 -0
- package/lib/types/node/builtin_modules/implemented/child_process.d.ts +178 -0
- package/lib/types/node/builtin_modules/implemented/crypto.d.ts +53 -0
- package/lib/types/node/builtin_modules/implemented/events.d.ts +84 -0
- package/lib/types/node/builtin_modules/implemented/fs/promises.d.ts +39 -0
- package/lib/types/node/builtin_modules/implemented/fs-watch.d.ts +119 -0
- package/lib/types/node/builtin_modules/implemented/fs.d.ts +502 -0
- package/lib/types/node/builtin_modules/implemented/http.d.ts +113 -0
- package/lib/types/node/builtin_modules/implemented/module.d.ts +50 -0
- package/lib/types/node/builtin_modules/implemented/os.d.ts +115 -0
- package/lib/types/node/builtin_modules/implemented/path.d.ts +138 -0
- package/lib/types/node/builtin_modules/implemented/perf_hooks.d.ts +13 -0
- package/lib/types/node/builtin_modules/implemented/stream.d.ts +22 -0
- package/lib/types/node/builtin_modules/implemented/timers/promises.d.ts +36 -0
- package/lib/types/node/builtin_modules/implemented/tty.d.ts +18 -0
- package/lib/types/node/builtin_modules/implemented/url.d.ts +61 -0
- package/lib/types/node/builtin_modules/implemented/util/types.d.ts +12 -0
- package/lib/types/node/builtin_modules/implemented/util.d.ts +95 -0
- package/lib/types/node/builtin_modules/implemented/zlib.d.ts +65 -0
- package/lib/types/node/builtin_modules/mock/dns/promises.d.ts +10 -0
- package/lib/types/node/builtin_modules/mock/net.d.ts +61 -0
- package/lib/types/node/builtin_modules/mock/sqlite.d.ts +19 -0
- package/lib/types/node/builtin_modules/mock/vm.d.ts +25 -0
- package/lib/types/node/builtin_modules/mock/worker_threads.d.ts +34 -0
- package/lib/types/node/builtins.d.ts +13 -0
- package/lib/types/node/external_packages/koffi.d.ts +63 -0
- package/lib/types/node/external_packages/node-addon-system-flock.d.ts +19 -0
- package/lib/types/node/external_packages/node-pty.d.ts +13 -0
- package/lib/types/node/external_packages/pi-ai.d.ts +51 -0
- package/lib/types/node/external_packages/replaced-externals.d.ts +9 -0
- package/lib/types/node/external_packages/ripgrep.d.ts +16 -0
- package/lib/types/node/external_packages/sharp.d.ts +6 -0
- package/lib/types/node/external_packages/ws.d.ts +38 -0
- package/lib/types/node/globals/crypto.d.ts +3 -0
- package/lib/types/node/globals/process.d.ts +78 -0
- package/lib/types/node/globals/timers.d.ts +10 -0
- package/lib/types/node/notImplementedFail.d.ts +34 -0
- package/lib/types/node/process-table.d.ts +50 -0
- package/lib/types/polyfill/async-context/als-runtime.d.ts +45 -0
- package/lib/types/polyfill/async-context/async-context-hooks.d.ts +6 -0
- package/lib/types/shell/ast.d.ts +23 -0
- package/lib/types/shell/expand.d.ts +65 -0
- package/lib/types/shell/fs-access.d.ts +43 -0
- package/lib/types/shell/interpret.d.ts +54 -0
- package/lib/types/shell/process/child.d.ts +26 -0
- package/lib/types/shell/process/host.d.ts +58 -0
- package/lib/types/shell/process/landlock.d.ts +33 -0
- package/lib/types/shell/process/protocol.d.ts +74 -0
- package/lib/types/shell/process/virtual-executables.d.ts +49 -0
- package/lib/types/shell/programs/builtins.d.ts +9 -0
- package/lib/types/shell/programs/files.d.ts +11 -0
- package/lib/types/shell/programs/index.d.ts +14 -0
- package/lib/types/shell/programs/options.d.ts +40 -0
- package/lib/types/shell/programs/text.d.ts +9 -0
- package/lib/types/shell/types.d.ts +138 -0
- package/lib/types/storage/active.d.ts +18 -0
- package/lib/types/storage/image-gzip.d.ts +39 -0
- package/lib/types/storage/memory.d.ts +308 -0
- package/lib/types/storage/paths.d.ts +18 -0
- package/lib/types/storage/tar.d.ts +41 -0
- package/lib/types/storage/types.d.ts +279 -0
- package/lib/types/transport/frames.d.ts +108 -0
- package/lib/types/transport/synthetic-http.d.ts +50 -0
- package/lib/types/transport/tunnel.d.ts +132 -0
- package/lib/types/worker-host.d.ts +165 -0
- package/lib/types/worker.d.ts +2 -0
- package/lib/worker.js +21879 -0
- package/package.json +73 -0
|
@@ -0,0 +1,174 @@
|
|
|
1
|
+
/** Node's AsyncLocalStorage face, restricted to the members the host tree uses. */
|
|
2
|
+
export declare class AsyncLocalStorage<T> {
|
|
3
|
+
private readonly entries;
|
|
4
|
+
private overlay;
|
|
5
|
+
private readonly ambients;
|
|
6
|
+
private resumed;
|
|
7
|
+
constructor();
|
|
8
|
+
/**
|
|
9
|
+
* Run a callback with the store visible for the operation's whole lifetime:
|
|
10
|
+
* until it returns, or until the promise it returned settles.
|
|
11
|
+
* @param store - value {@link getStore} answers inside the boundary.
|
|
12
|
+
* @param callback - the operation.
|
|
13
|
+
* @param args - callback arguments.
|
|
14
|
+
* @returns the exact value the callback returned.
|
|
15
|
+
*/
|
|
16
|
+
run<R>(store: T | undefined, callback: (...args: never[]) => R, ...args: never[]): R;
|
|
17
|
+
/**
|
|
18
|
+
* Current store, resolved through the slot order this module documents: the
|
|
19
|
+
* hook-restored overlay, then the ambient context a resume installed (or a
|
|
20
|
+
* boundary owns), then the folding stack's innermost entry.
|
|
21
|
+
* @returns the store, or undefined outside every boundary.
|
|
22
|
+
*/
|
|
23
|
+
getStore(): T | undefined;
|
|
24
|
+
/**
|
|
25
|
+
* Run a callback with no store, folding over its lifetime like {@link run}.
|
|
26
|
+
* @param callback - the operation.
|
|
27
|
+
* @param args - callback arguments.
|
|
28
|
+
* @returns the exact value the callback returned.
|
|
29
|
+
*/
|
|
30
|
+
exit<R>(callback: (...args: never[]) => R, ...args: never[]): R;
|
|
31
|
+
/**
|
|
32
|
+
* Enter a boundary that lasts until {@link disable}, as Node's `enterWith` does
|
|
33
|
+
* for the remainder of the current chain.
|
|
34
|
+
* @param store - value {@link getStore} answers from now on.
|
|
35
|
+
*/
|
|
36
|
+
enterWith(store: T): void;
|
|
37
|
+
/** Drop every slot; teardown calls this unconditionally. */
|
|
38
|
+
disable(): void;
|
|
39
|
+
/**
|
|
40
|
+
* Copy every live instance's effective store, including the instances reading
|
|
41
|
+
* `undefined`: a resumed frame must see exactly what its pause point saw.
|
|
42
|
+
* @returns the ambient snapshot.
|
|
43
|
+
*/
|
|
44
|
+
static snapshotAll(): AmbientSnapshot;
|
|
45
|
+
/**
|
|
46
|
+
* Install a snapshot as the ambient context of every instance it names.
|
|
47
|
+
* @param snapshot - a copy from {@link snapshotAll}.
|
|
48
|
+
* @returns a disposer that restores the previous ambients, identity-checked.
|
|
49
|
+
*/
|
|
50
|
+
static restoreAll(snapshot: AmbientSnapshot): () => void;
|
|
51
|
+
/**
|
|
52
|
+
* Copy every live instance's current store. Not part of the Node face: this is
|
|
53
|
+
* the shim's own mechanism, kept in the class so the overlay stays private.
|
|
54
|
+
* @returns the snapshot, or undefined when no instance has a store.
|
|
55
|
+
*/
|
|
56
|
+
static captureContext(): AsyncContextSnapshot | undefined;
|
|
57
|
+
/**
|
|
58
|
+
* Run a callback with a captured context restored into the overlay slots.
|
|
59
|
+
* @param snapshot - context copy, or undefined to run unchanged.
|
|
60
|
+
* @param callback - the callback.
|
|
61
|
+
* @returns the callback's return value.
|
|
62
|
+
*/
|
|
63
|
+
static runWithContext<R>(snapshot: AsyncContextSnapshot | undefined, callback: () => R): R;
|
|
64
|
+
/**
|
|
65
|
+
* Every live instance, for {@link runAtAsyncContextRoot}.
|
|
66
|
+
* @returns The stores a snapshot must capture.
|
|
67
|
+
*/
|
|
68
|
+
static liveInstances(): readonly AsyncLocalStorage<unknown>[];
|
|
69
|
+
/**
|
|
70
|
+
* Bind a callback to the current context.
|
|
71
|
+
* @param callback - the callback to bind.
|
|
72
|
+
* @returns a callback that restores this context when invoked.
|
|
73
|
+
*/
|
|
74
|
+
static bind<F extends (...args: never[]) => unknown>(callback: F): F;
|
|
75
|
+
/**
|
|
76
|
+
* Snapshot helper matching Node's static: run a callback in the context
|
|
77
|
+
* captured now.
|
|
78
|
+
* @returns a function that runs its argument in the captured context.
|
|
79
|
+
*/
|
|
80
|
+
static snapshot(): <R>(callback: () => R) => R;
|
|
81
|
+
}
|
|
82
|
+
/** One instance's captured store. */
|
|
83
|
+
interface CapturedStore {
|
|
84
|
+
readonly instance: AsyncLocalStorage<unknown>;
|
|
85
|
+
readonly store: unknown;
|
|
86
|
+
}
|
|
87
|
+
/** Opaque context copy produced by {@link captureAsyncContext}. */
|
|
88
|
+
export type AsyncContextSnapshot = readonly CapturedStore[];
|
|
89
|
+
/** Opaque ambient copy produced by {@link __snapshotAll}; covers every live instance. */
|
|
90
|
+
export type AmbientSnapshot = readonly CapturedStore[];
|
|
91
|
+
/**
|
|
92
|
+
* Copy every live instance's current store.
|
|
93
|
+
* @returns the snapshot, or undefined when no instance has a store (the hook
|
|
94
|
+
* layer then wraps nothing and callbacks inherit the stack top).
|
|
95
|
+
*/
|
|
96
|
+
export declare function captureAsyncContext(): AsyncContextSnapshot | undefined;
|
|
97
|
+
/**
|
|
98
|
+
* Run a callback with a captured context restored into the overlay slots.
|
|
99
|
+
* @param snapshot - context copy, or undefined to run unchanged.
|
|
100
|
+
* @param callback - the callback.
|
|
101
|
+
* @returns the callback's return value.
|
|
102
|
+
*/
|
|
103
|
+
export declare function runWithAsyncContext<R>(snapshot: AsyncContextSnapshot | undefined, callback: () => R): R;
|
|
104
|
+
/**
|
|
105
|
+
* Capture the current context now and restore it around every later invocation.
|
|
106
|
+
* @param callback - the callback to bind.
|
|
107
|
+
* @returns the bound callback, or the original when no context is active.
|
|
108
|
+
*/
|
|
109
|
+
export declare function bindAsyncContext<F extends (...args: never[]) => unknown>(callback: F): F;
|
|
110
|
+
/**
|
|
111
|
+
* Run a callback at the root: every instance reads `undefined`, whatever was open
|
|
112
|
+
* before. The tunnel's message entry uses this so a queued request never inherits
|
|
113
|
+
* a boundary from unrelated work that happened to run first.
|
|
114
|
+
* @param callback - the callback.
|
|
115
|
+
* @returns the callback's return value.
|
|
116
|
+
*/
|
|
117
|
+
export declare function runAtAsyncContextRoot<R>(callback: () => R): R;
|
|
118
|
+
/**
|
|
119
|
+
* Pause point of the loader's `await` rewriting: copy the context every live
|
|
120
|
+
* instance currently reads.
|
|
121
|
+
*
|
|
122
|
+
* The transformed module reaches this through the module proxy table
|
|
123
|
+
* (`require('node:async_hooks').__snapshotAll()`), so the rewriter needs no
|
|
124
|
+
* additional plumbing.
|
|
125
|
+
* @returns the ambient snapshot to hand to {@link __restoreAll} after the await.
|
|
126
|
+
*/
|
|
127
|
+
export declare function __snapshotAll(): AmbientSnapshot;
|
|
128
|
+
/**
|
|
129
|
+
* Resume point of the loader's `await` rewriting: publish a paused context as the
|
|
130
|
+
* ambient one, so reads after the await answer what the frame saw before it —
|
|
131
|
+
* even while another chain interleaves.
|
|
132
|
+
* @param snapshot - the copy {@link __snapshotAll} produced at the pause point.
|
|
133
|
+
* @returns a disposer that restores the previous ambient context, identity-checked;
|
|
134
|
+
* a rewriter that wraps a whole function body calls it in that body's `finally`.
|
|
135
|
+
*/
|
|
136
|
+
export declare function __restoreAll(snapshot: AmbientSnapshot): () => void;
|
|
137
|
+
/**
|
|
138
|
+
* Snapshot face the module loader's `await` rewriting consumes (its `AlsCausality`):
|
|
139
|
+
* the same pair as {@link __snapshotAll}/{@link __restoreAll}, with `restore`
|
|
140
|
+
* narrowed to void because the rewritten code has no place to keep a disposer.
|
|
141
|
+
*/
|
|
142
|
+
export declare const alsCausality: {
|
|
143
|
+
snapshot: () => AmbientSnapshot;
|
|
144
|
+
restore: (snapshot: AmbientSnapshot) => void;
|
|
145
|
+
};
|
|
146
|
+
/**
|
|
147
|
+
* Async ids are not tracked; a stable id keeps callers that log it working.
|
|
148
|
+
* @returns Always 1.
|
|
149
|
+
*/
|
|
150
|
+
export declare function executionAsyncId(): number;
|
|
151
|
+
/**
|
|
152
|
+
* Trigger ids are not tracked either.
|
|
153
|
+
* @returns Always 0.
|
|
154
|
+
*/
|
|
155
|
+
export declare function triggerAsyncId(): number;
|
|
156
|
+
/**
|
|
157
|
+
* Async hooks cannot be created: no async resource tracking exists in the worker.
|
|
158
|
+
* @returns Never — it throws naming the unavailable member.
|
|
159
|
+
*/
|
|
160
|
+
export declare function createHook(): never;
|
|
161
|
+
/** Resource construction is likewise unavailable. */
|
|
162
|
+
export declare const AsyncResource: typeof import('node:async_hooks').AsyncResource;
|
|
163
|
+
/** CommonJS interop marker: the worker loader hands `default` to default imports (see ./builtins.ts). */
|
|
164
|
+
export declare const __esModule = true;
|
|
165
|
+
/** CommonJS default export: the members `require()` hands a caller of this module. */
|
|
166
|
+
declare const _default: {
|
|
167
|
+
AsyncLocalStorage: typeof AsyncLocalStorage;
|
|
168
|
+
AsyncResource: typeof import("async_hooks").AsyncResource;
|
|
169
|
+
executionAsyncId: typeof executionAsyncId;
|
|
170
|
+
triggerAsyncId: typeof triggerAsyncId;
|
|
171
|
+
createHook: typeof createHook;
|
|
172
|
+
};
|
|
173
|
+
export default _default;
|
|
174
|
+
//# sourceMappingURL=async_hooks.d.ts.map
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `node:buffer` for the worker, backed by the `buffer` npm package (feross), and
|
|
3
|
+
* the matching `globalThis.Buffer` install. Node code treats Buffer as ambient,
|
|
4
|
+
* so the global must exist before any host module evaluates.
|
|
5
|
+
*/
|
|
6
|
+
import { Buffer, kMaxLength } from 'buffer';
|
|
7
|
+
export { Buffer, kMaxLength };
|
|
8
|
+
/**
|
|
9
|
+
* Size limits, as `node:buffer` publishes them. The npm package exposes only
|
|
10
|
+
* `kMaxLength`, so the string bound is Node's own value for a 64-bit build.
|
|
11
|
+
*/
|
|
12
|
+
export declare const constants: {
|
|
13
|
+
MAX_LENGTH: number;
|
|
14
|
+
MAX_STRING_LENGTH: number;
|
|
15
|
+
};
|
|
16
|
+
/** CommonJS interop marker: the worker loader hands `default` to default imports (see ./builtins.ts). */
|
|
17
|
+
export declare const __esModule = true;
|
|
18
|
+
/** CommonJS default export: the members `require()` hands a caller of this module. */
|
|
19
|
+
declare const _default: {
|
|
20
|
+
Buffer: BufferConstructor;
|
|
21
|
+
constants: {
|
|
22
|
+
MAX_LENGTH: number;
|
|
23
|
+
MAX_STRING_LENGTH: number;
|
|
24
|
+
};
|
|
25
|
+
kMaxLength: number;
|
|
26
|
+
};
|
|
27
|
+
export default _default;
|
|
28
|
+
//# sourceMappingURL=buffer.d.ts.map
|
|
@@ -0,0 +1,178 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `node:child_process` over the worker's own shell.
|
|
3
|
+
*
|
|
4
|
+
* A browser worker cannot fork, so this module IS the machine's process layer:
|
|
5
|
+
* `spawn` starts the argv as a shell process (`src/shell/process/`) — its own
|
|
6
|
+
* Web Worker, off this thread — and reports it through the `ChildProcess`
|
|
7
|
+
* surface the subprocess service consumes: pipes, `exit`/`close`, pid, and
|
|
8
|
+
* signals, with `SIGKILL` terminating the worker for real. Worker-owned
|
|
9
|
+
* executable wrappers resolve before the shell's command table; anything in
|
|
10
|
+
* neither set fails with `ENOENT`, exactly as a missing binary does on a real
|
|
11
|
+
* host.
|
|
12
|
+
*
|
|
13
|
+
* What stays impossible is what needs a real process: synchronous execution
|
|
14
|
+
* (`execSync`, and `spawnSync` for a known program) and `fork`.
|
|
15
|
+
* @module @deepseek-ai/dsh-experimental-webworker-runtime/src/node/builtin_modules/implemented/child_process
|
|
16
|
+
*/
|
|
17
|
+
import { Buffer } from 'buffer';
|
|
18
|
+
import { EventEmitter } from './events.ts';
|
|
19
|
+
/** Per-stream disposition, as Node's `stdio` array spells it. */
|
|
20
|
+
type StdioSetting = 'pipe' | 'ignore' | 'inherit';
|
|
21
|
+
/** The spawn options this shim reads; Node accepts more, none of which apply here. */
|
|
22
|
+
export interface WorkerSpawnOptions {
|
|
23
|
+
cwd?: string | undefined;
|
|
24
|
+
env?: Record<string, string | undefined> | undefined;
|
|
25
|
+
stdio?: StdioSetting | readonly StdioSetting[] | undefined;
|
|
26
|
+
/** Accepted and ignored: process groups do not exist, so there is no group to detach into. */
|
|
27
|
+
detached?: boolean | undefined;
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* The readable half of a pipe: `data` events carrying Buffers, `end`, and a
|
|
31
|
+
* `destroy` that stops delivery.
|
|
32
|
+
*
|
|
33
|
+
* The stream-shaping members below are no-ops rather than omissions. A caller
|
|
34
|
+
* that configures the pipe before reading it (the browser launcher calls
|
|
35
|
+
* `setEncoding`) would otherwise die of a TypeError on the configuration line,
|
|
36
|
+
* hiding the real outcome — which for an unknown program is the `ENOENT` this
|
|
37
|
+
* shim is about to emit.
|
|
38
|
+
*/
|
|
39
|
+
declare class WorkerReadable extends EventEmitter {
|
|
40
|
+
private destroyed;
|
|
41
|
+
/**
|
|
42
|
+
* Accept an encoding (chunks are always UTF-8 text carried as Buffers).
|
|
43
|
+
* @returns this stream.
|
|
44
|
+
*/
|
|
45
|
+
setEncoding(): this;
|
|
46
|
+
/**
|
|
47
|
+
* Accept a flow-control request; delivery is driven by the command, which
|
|
48
|
+
* has already produced whatever it produced.
|
|
49
|
+
* @returns this stream.
|
|
50
|
+
*/
|
|
51
|
+
pause(): this;
|
|
52
|
+
/** @returns this stream; see {@link pause}. */
|
|
53
|
+
resume(): this;
|
|
54
|
+
/**
|
|
55
|
+
* Deliver one chunk to the `data` listeners.
|
|
56
|
+
* @param text - the text written by the command.
|
|
57
|
+
*/
|
|
58
|
+
push(text: string): void;
|
|
59
|
+
/** Signal end of stream. */
|
|
60
|
+
finish(): void;
|
|
61
|
+
/** Stop delivering; the collector calls this once the process settles. */
|
|
62
|
+
destroy(): void;
|
|
63
|
+
}
|
|
64
|
+
/** The writable half of stdin: the batch write the subprocess service performs. */
|
|
65
|
+
declare class WorkerWritable extends EventEmitter {
|
|
66
|
+
private text;
|
|
67
|
+
/**
|
|
68
|
+
* Buffer one write.
|
|
69
|
+
* @param chunk - text or bytes to add to standard input.
|
|
70
|
+
* @returns true, since nothing here applies backpressure.
|
|
71
|
+
*/
|
|
72
|
+
write(chunk: string | Uint8Array): boolean;
|
|
73
|
+
/**
|
|
74
|
+
* Finish standard input.
|
|
75
|
+
* @param chunk - optional final write.
|
|
76
|
+
*/
|
|
77
|
+
end(chunk?: string | Uint8Array): void;
|
|
78
|
+
/** @returns everything written so far. */
|
|
79
|
+
contents(): string;
|
|
80
|
+
}
|
|
81
|
+
/**
|
|
82
|
+
* One running command, wearing the parts of `ChildProcess` its consumers read.
|
|
83
|
+
*/
|
|
84
|
+
export declare class WorkerChildProcess extends EventEmitter {
|
|
85
|
+
/** The worker's own process id for this command, from the process table. */
|
|
86
|
+
readonly pid: number;
|
|
87
|
+
/** Standard input, when the caller asked for a pipe; null otherwise. */
|
|
88
|
+
readonly stdin: WorkerWritable | null;
|
|
89
|
+
/** Standard output, when the caller asked for a pipe; null otherwise. */
|
|
90
|
+
readonly stdout: WorkerReadable | null;
|
|
91
|
+
/** Standard error, when the caller asked for a pipe; null otherwise. */
|
|
92
|
+
readonly stderr: WorkerReadable | null;
|
|
93
|
+
/** Exit status once settled; null while running and after a signal. */
|
|
94
|
+
exitCode: number | null;
|
|
95
|
+
/** The signal that ended the command, or null when it exited on its own. */
|
|
96
|
+
signalCode: NodeJS.Signals | null;
|
|
97
|
+
constructor(pid: number, stdio: readonly StdioSetting[]);
|
|
98
|
+
/**
|
|
99
|
+
* Deliver a signal to this command.
|
|
100
|
+
* @param signal - signal name; every one of them terminates.
|
|
101
|
+
* @returns true when the command was still running.
|
|
102
|
+
*/
|
|
103
|
+
kill(signal?: NodeJS.Signals): boolean;
|
|
104
|
+
}
|
|
105
|
+
/**
|
|
106
|
+
* Run one command in the worker.
|
|
107
|
+
*
|
|
108
|
+
* The call returns immediately with a handle; the command runs in its own
|
|
109
|
+
* worker (or inline where no `Worker` exists) and reports back through the
|
|
110
|
+
* handle's pipes and events.
|
|
111
|
+
* @param program - the program name, as argv[0].
|
|
112
|
+
* @param args - its arguments.
|
|
113
|
+
* @param options - working directory, environment, and stdio dispositions.
|
|
114
|
+
* @returns the running command's handle.
|
|
115
|
+
*/
|
|
116
|
+
export declare function spawn(program: string, args?: readonly string[], options?: WorkerSpawnOptions): WorkerChildProcess;
|
|
117
|
+
/** The result shape `spawnSync` returns, holding only the members consumers read. */
|
|
118
|
+
export interface WorkerSpawnSyncResult {
|
|
119
|
+
pid: number;
|
|
120
|
+
status: number | null;
|
|
121
|
+
signal: NodeJS.Signals | null;
|
|
122
|
+
stdout: Buffer;
|
|
123
|
+
stderr: Buffer;
|
|
124
|
+
output: (Buffer | null)[];
|
|
125
|
+
/** Why the run did not happen; carries `code` for the callers that classify by it. */
|
|
126
|
+
error?: NodeJS.ErrnoException;
|
|
127
|
+
}
|
|
128
|
+
/**
|
|
129
|
+
* Report that a command cannot run synchronously.
|
|
130
|
+
*
|
|
131
|
+
* Callers use `spawnSync` to probe for a binary (the sandbox runner probes do)
|
|
132
|
+
* and Node answers a missing one with an `error` rather than a throw, so this
|
|
133
|
+
* answers in the same shape: absent programs report `ENOENT`, and a program
|
|
134
|
+
* this shell *does* have reports that only the asynchronous path can run it.
|
|
135
|
+
* @param program - the program name.
|
|
136
|
+
* @param args - arguments passed to the virtual launcher probe.
|
|
137
|
+
* @returns the Node-shaped synchronous result carrying the failure.
|
|
138
|
+
*/
|
|
139
|
+
export declare function spawnSync(program: string, args?: readonly string[]): WorkerSpawnSyncResult;
|
|
140
|
+
/** Callback `exec` and `execFile` report through. */
|
|
141
|
+
type ExecCallback = (error: Error | null, stdout: string, stderr: string) => void;
|
|
142
|
+
/**
|
|
143
|
+
* Run a command line and report its output through a callback.
|
|
144
|
+
* @param command - the shell source to run.
|
|
145
|
+
* @param options - working directory and environment, or the callback.
|
|
146
|
+
* @param callback - receives the failure (nonzero status included), stdout, and stderr.
|
|
147
|
+
* @returns the running command's handle.
|
|
148
|
+
*/
|
|
149
|
+
export declare function exec(command: string, options?: WorkerSpawnOptions | ExecCallback, callback?: ExecCallback): WorkerChildProcess;
|
|
150
|
+
/**
|
|
151
|
+
* Run one program with an explicit argv and report its output through a callback.
|
|
152
|
+
* @param program - the program name.
|
|
153
|
+
* @param args - its arguments, or the options, or the callback.
|
|
154
|
+
* @param options - working directory and environment, or the callback.
|
|
155
|
+
* @param callback - receives the failure (nonzero status included), stdout, and stderr.
|
|
156
|
+
* @returns the running command's handle.
|
|
157
|
+
*/
|
|
158
|
+
export declare function execFile(program: string, args?: readonly string[] | WorkerSpawnOptions | ExecCallback, options?: WorkerSpawnOptions | ExecCallback, callback?: ExecCallback): WorkerChildProcess;
|
|
159
|
+
/** Run a command line synchronously (unavailable: the interpreter is asynchronous). */
|
|
160
|
+
export declare const execSync: typeof import('node:child_process').execSync;
|
|
161
|
+
/** Run one program synchronously (unavailable: the interpreter is asynchronous). */
|
|
162
|
+
export declare const execFileSync: typeof import('node:child_process').execFileSync;
|
|
163
|
+
/** Start a Node child (unavailable: the worker cannot create another Node runtime). */
|
|
164
|
+
export declare const fork: typeof import('node:child_process').fork;
|
|
165
|
+
/** CommonJS interop marker: the worker loader hands `default` to default imports (see ../../builtins.ts). */
|
|
166
|
+
export declare const __esModule = true;
|
|
167
|
+
/** CommonJS default export: the members `require()` hands a caller of this module. */
|
|
168
|
+
declare const _default: {
|
|
169
|
+
spawn: typeof spawn;
|
|
170
|
+
spawnSync: typeof spawnSync;
|
|
171
|
+
exec: typeof exec;
|
|
172
|
+
execFile: typeof execFile;
|
|
173
|
+
execFileSync: typeof import("child_process").execFileSync;
|
|
174
|
+
execSync: typeof import("child_process").execSync;
|
|
175
|
+
fork: typeof import("child_process").fork;
|
|
176
|
+
};
|
|
177
|
+
export default _default;
|
|
178
|
+
//# sourceMappingURL=child_process.d.ts.map
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import { Buffer } from 'buffer';
|
|
2
|
+
/** Node's streaming Hash face, restricted to the update/digest pair in use. */
|
|
3
|
+
export interface Hash {
|
|
4
|
+
update(data: string | Uint8Array | ArrayBuffer, encoding?: string): Hash;
|
|
5
|
+
digest(): Buffer;
|
|
6
|
+
digest(encoding: 'hex' | 'base64'): string;
|
|
7
|
+
}
|
|
8
|
+
/**
|
|
9
|
+
* Create a synchronous hash object.
|
|
10
|
+
* @param algorithm - digest name; only the algorithms the host tree uses exist.
|
|
11
|
+
* @returns the streaming hash face.
|
|
12
|
+
*/
|
|
13
|
+
export declare function createHash(algorithm: string): Hash;
|
|
14
|
+
/**
|
|
15
|
+
* Random bytes.
|
|
16
|
+
* @param size - byte count.
|
|
17
|
+
* @returns a Buffer of cryptographically strong random bytes.
|
|
18
|
+
*/
|
|
19
|
+
export declare function randomBytes(size: number): Buffer<ArrayBuffer>;
|
|
20
|
+
/**
|
|
21
|
+
* Random v4 UUID. Delegated to the repository's own mint rather than to
|
|
22
|
+
* `crypto.randomUUID`, which browsers expose only in secure contexts — a
|
|
23
|
+
* preview served over plain HTTP on a LAN address has no `randomUUID`.
|
|
24
|
+
* @returns the UUID string.
|
|
25
|
+
*/
|
|
26
|
+
export declare function randomUUID(): import('node:crypto').UUID;
|
|
27
|
+
/**
|
|
28
|
+
* Fill a typed array with random bytes.
|
|
29
|
+
* @param target - the array to fill.
|
|
30
|
+
* @returns the same array.
|
|
31
|
+
*/
|
|
32
|
+
export declare function getRandomValues<T extends ArrayBufferView<ArrayBuffer>>(target: T): T;
|
|
33
|
+
/**
|
|
34
|
+
* Random integer in `[0, max)`.
|
|
35
|
+
* @param max - exclusive upper bound.
|
|
36
|
+
* @returns the integer.
|
|
37
|
+
*/
|
|
38
|
+
export declare function randomInt(max: number): number;
|
|
39
|
+
/** WebCrypto instance, as Node exposes it. */
|
|
40
|
+
export declare const webcrypto: Crypto;
|
|
41
|
+
/** CommonJS interop marker: the worker loader hands `default` to default imports (see ./builtins.ts). */
|
|
42
|
+
export declare const __esModule = true;
|
|
43
|
+
/** CommonJS default export: the members `require()` hands a caller of this module. */
|
|
44
|
+
declare const _default: {
|
|
45
|
+
createHash: typeof createHash;
|
|
46
|
+
randomBytes: typeof randomBytes;
|
|
47
|
+
randomUUID: typeof randomUUID;
|
|
48
|
+
getRandomValues: typeof getRandomValues;
|
|
49
|
+
randomInt: typeof randomInt;
|
|
50
|
+
webcrypto: Crypto;
|
|
51
|
+
};
|
|
52
|
+
export default _default;
|
|
53
|
+
//# sourceMappingURL=crypto.d.ts.map
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `node:events`: a minimal EventEmitter with the members harness code uses.
|
|
3
|
+
* Emission order and listener identity follow Node; anything beyond the basic
|
|
4
|
+
* on/once/off/emit set throws.
|
|
5
|
+
*/
|
|
6
|
+
type Listener = (...args: unknown[]) => void;
|
|
7
|
+
/** The `node:events` subset the harness registers on: add, remove, and emit. */
|
|
8
|
+
export declare class EventEmitter {
|
|
9
|
+
private readonly registry;
|
|
10
|
+
/**
|
|
11
|
+
* Register a listener.
|
|
12
|
+
* @param event - event name.
|
|
13
|
+
* @param listener - the listener.
|
|
14
|
+
* @returns this emitter.
|
|
15
|
+
*/
|
|
16
|
+
on(event: string, listener: Listener): this;
|
|
17
|
+
/**
|
|
18
|
+
* Register a listener removed after its first call.
|
|
19
|
+
* @param event - event name.
|
|
20
|
+
* @param listener - the listener.
|
|
21
|
+
* @returns this emitter.
|
|
22
|
+
*/
|
|
23
|
+
once(event: string, listener: Listener): this;
|
|
24
|
+
/**
|
|
25
|
+
* Register a listener ahead of the existing ones.
|
|
26
|
+
* @param event - event name.
|
|
27
|
+
* @param listener - the listener.
|
|
28
|
+
* @returns this emitter.
|
|
29
|
+
*/
|
|
30
|
+
prependListener(event: string, listener: Listener): this;
|
|
31
|
+
/**
|
|
32
|
+
* Remove a listener, by the function that was registered or by the one a
|
|
33
|
+
* `once` wrapper stands for.
|
|
34
|
+
* @param event - event name.
|
|
35
|
+
* @param listener - the listener.
|
|
36
|
+
* @returns this emitter.
|
|
37
|
+
*/
|
|
38
|
+
off(event: string, listener: Listener): this;
|
|
39
|
+
/**
|
|
40
|
+
* Alias of {@link off}.
|
|
41
|
+
* @param event - event name.
|
|
42
|
+
* @param listener - the listener.
|
|
43
|
+
* @returns this emitter.
|
|
44
|
+
*/
|
|
45
|
+
removeListener(event: string, listener: Listener): this;
|
|
46
|
+
/**
|
|
47
|
+
* Drop listeners for one event, or all of them.
|
|
48
|
+
* @param event - event name; omitted clears every event.
|
|
49
|
+
* @returns this emitter.
|
|
50
|
+
*/
|
|
51
|
+
removeAllListeners(event?: string): this;
|
|
52
|
+
/**
|
|
53
|
+
* Emit an event.
|
|
54
|
+
* @param event - event name.
|
|
55
|
+
* @param args - listener arguments.
|
|
56
|
+
* @returns whether any listener ran.
|
|
57
|
+
*/
|
|
58
|
+
emit(event: string, ...args: unknown[]): boolean;
|
|
59
|
+
/**
|
|
60
|
+
* Listeners of one event.
|
|
61
|
+
* @param event - event name.
|
|
62
|
+
* @returns a copy of the listener list.
|
|
63
|
+
*/
|
|
64
|
+
listeners(event: string): Listener[];
|
|
65
|
+
/**
|
|
66
|
+
* Listener count of one event.
|
|
67
|
+
* @param event - event name.
|
|
68
|
+
* @returns the count.
|
|
69
|
+
*/
|
|
70
|
+
listenerCount(event: string): number;
|
|
71
|
+
/**
|
|
72
|
+
* Node's max-listener knob has no effect here.
|
|
73
|
+
* @returns This emitter, for chaining.
|
|
74
|
+
*/
|
|
75
|
+
setMaxListeners(): this;
|
|
76
|
+
}
|
|
77
|
+
/** CommonJS interop marker: the worker loader hands `default` to default imports (see ./builtins.ts). */
|
|
78
|
+
export declare const __esModule = true;
|
|
79
|
+
/** CommonJS default export: the members `require()` hands a caller of this module. */
|
|
80
|
+
declare const _default: {
|
|
81
|
+
EventEmitter: typeof EventEmitter;
|
|
82
|
+
};
|
|
83
|
+
export default _default;
|
|
84
|
+
//# sourceMappingURL=events.d.ts.map
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `node:fs/promises` face: the promise members of the VFS bridge, re-exported as
|
|
3
|
+
* named bindings so `import { readFile } from 'node:fs/promises'` resolves. The
|
|
4
|
+
* member set is checked against Node where it is built, on `promises` in
|
|
5
|
+
* `../fs.ts`.
|
|
6
|
+
*/
|
|
7
|
+
import { Dirent, promises } from '../fs.ts';
|
|
8
|
+
/** The promise members of the VFS bridge, as `node:fs/promises` names them. */
|
|
9
|
+
export declare const readFile: (path: string | URL | Uint8Array<ArrayBufferLike>, options?: BufferEncoding | {
|
|
10
|
+
encoding?: BufferEncoding | null;
|
|
11
|
+
} | null | undefined) => Promise<Buffer | string>, writeFile: (path: string | URL | Uint8Array<ArrayBufferLike>, data: string | Uint8Array, options?: {
|
|
12
|
+
flag?: string;
|
|
13
|
+
mode?: number;
|
|
14
|
+
} | BufferEncoding | null) => Promise<void>, appendFile: (path: string | URL | Uint8Array<ArrayBufferLike>, data: string | Uint8Array) => Promise<void>, mkdir: (path: string | URL | Uint8Array<ArrayBufferLike>, options?: {
|
|
15
|
+
recursive?: boolean;
|
|
16
|
+
mode?: number;
|
|
17
|
+
}) => Promise<string | undefined>, mkdtemp: (prefix: string) => Promise<string>, readdir: (path: string | URL | Uint8Array<ArrayBufferLike>, options?: {
|
|
18
|
+
withFileTypes?: boolean;
|
|
19
|
+
} | BufferEncoding) => Promise<string[] | Dirent[]>, stat: (path: string | URL | Uint8Array<ArrayBufferLike>, options?: import("../../../../storage/types.ts").VfsStatOptions) => Promise<import("../../../../index.ts").VfsStats | import("../../../../storage/types.ts").VfsBigIntStats>, lstat: (path: string | URL | Uint8Array<ArrayBufferLike>, options?: import("../../../../storage/types.ts").VfsStatOptions) => Promise<import("../../../../index.ts").VfsStats | import("../../../../storage/types.ts").VfsBigIntStats>, realpath: (path: string | URL | Uint8Array<ArrayBufferLike>) => Promise<string>, rm: (path: string | URL | Uint8Array<ArrayBufferLike>, options?: {
|
|
20
|
+
recursive?: boolean;
|
|
21
|
+
force?: boolean;
|
|
22
|
+
}) => Promise<void>, unlink: (path: string | URL | Uint8Array<ArrayBufferLike>) => Promise<void>, rename: (from: string | URL | Uint8Array<ArrayBufferLike>, to: string | URL | Uint8Array<ArrayBufferLike>) => Promise<void>, access: (path: string | URL | Uint8Array<ArrayBufferLike>) => Promise<void>, chmod: (path: string | URL | Uint8Array<ArrayBufferLike>, mode: number | string) => Promise<void>, cp: (from: string | URL | Uint8Array<ArrayBufferLike>, to: string | URL | Uint8Array<ArrayBufferLike>) => Promise<void>, link: (from: string | URL | Uint8Array<ArrayBufferLike>, to: string | URL | Uint8Array<ArrayBufferLike>) => Promise<void>, open: (path: string | URL | Uint8Array<ArrayBufferLike>, flags?: string, mode?: number) => Promise<import("../fs.ts").FileHandle>, opendir: (path: string | URL | Uint8Array<ArrayBufferLike>) => Promise<import("../fs.ts").Dir>, truncate: (path: string | URL | Uint8Array<ArrayBufferLike>, length?: number) => Promise<void>, watch: typeof import("../fs-watch.ts").watchAsync, constants: {
|
|
23
|
+
F_OK: number;
|
|
24
|
+
R_OK: number;
|
|
25
|
+
W_OK: number;
|
|
26
|
+
X_OK: number;
|
|
27
|
+
COPYFILE_EXCL: number;
|
|
28
|
+
O_RDONLY: number;
|
|
29
|
+
O_WRONLY: number;
|
|
30
|
+
O_RDWR: number;
|
|
31
|
+
O_CREAT: number;
|
|
32
|
+
O_TRUNC: number;
|
|
33
|
+
O_APPEND: number;
|
|
34
|
+
};
|
|
35
|
+
export { Dirent };
|
|
36
|
+
/** CommonJS interop marker: the worker loader hands `default` to default imports (see ./builtins.ts). */
|
|
37
|
+
export declare const __esModule = true;
|
|
38
|
+
export default promises;
|
|
39
|
+
//# sourceMappingURL=promises.d.ts.map
|
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
/** Node filesystem watching over the active in-memory VFS. */
|
|
2
|
+
import { Buffer } from 'buffer';
|
|
3
|
+
import { EventEmitter } from './events.ts';
|
|
4
|
+
import type { VfsBigIntStats, VfsStats } from '../../../storage/types.ts';
|
|
5
|
+
type PathArg = string | URL | Uint8Array;
|
|
6
|
+
type WatchListener = (eventType: 'rename' | 'change', filename: string | Buffer | null) => void;
|
|
7
|
+
type WatchStats = VfsStats | VfsBigIntStats;
|
|
8
|
+
type StatListener = (current: WatchStats, previous: WatchStats) => void;
|
|
9
|
+
/** Options shared by the callback and promise watch faces. */
|
|
10
|
+
export interface WatchOptions {
|
|
11
|
+
persistent?: boolean;
|
|
12
|
+
recursive?: boolean;
|
|
13
|
+
encoding?: BufferEncoding | 'buffer';
|
|
14
|
+
signal?: AbortSignal;
|
|
15
|
+
}
|
|
16
|
+
/** Poll-style watch options. */
|
|
17
|
+
export interface WatchFileOptions {
|
|
18
|
+
persistent?: boolean;
|
|
19
|
+
interval?: number;
|
|
20
|
+
bigint?: boolean;
|
|
21
|
+
}
|
|
22
|
+
/** `fs.FSWatcher` over VFS mutations. */
|
|
23
|
+
export declare class FSWatcher extends EventEmitter {
|
|
24
|
+
private readonly target;
|
|
25
|
+
private readonly directory;
|
|
26
|
+
private readonly options;
|
|
27
|
+
private readonly disposeMutation;
|
|
28
|
+
private readonly signal;
|
|
29
|
+
private readonly onAbort;
|
|
30
|
+
private closed;
|
|
31
|
+
private referenced;
|
|
32
|
+
constructor(target: string, directory: boolean, options: WatchOptions, listener?: WatchListener);
|
|
33
|
+
private matches;
|
|
34
|
+
private filename;
|
|
35
|
+
/** Stop observing and publish `close` once. */
|
|
36
|
+
close(): void;
|
|
37
|
+
/**
|
|
38
|
+
* Mark this watcher as process-liveness-bearing.
|
|
39
|
+
* @returns This watcher.
|
|
40
|
+
*/
|
|
41
|
+
ref(): this;
|
|
42
|
+
/**
|
|
43
|
+
* Clear the process-liveness flag; dedicated Workers have no ref-counted event loop.
|
|
44
|
+
* @returns This watcher.
|
|
45
|
+
*/
|
|
46
|
+
unref(): this;
|
|
47
|
+
/**
|
|
48
|
+
* Read the retained process-liveness flag.
|
|
49
|
+
* @returns Whether this watcher is marked as keeping its owner alive.
|
|
50
|
+
*/
|
|
51
|
+
hasRef(): boolean;
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* Watch one path through the active VFS.
|
|
55
|
+
* @param path - File or directory path.
|
|
56
|
+
* @param optionsOrListener - Watch options, encoding, or the change listener.
|
|
57
|
+
* @param maybeListener - Change listener when the second argument carries options.
|
|
58
|
+
* @returns The closeable watcher.
|
|
59
|
+
*/
|
|
60
|
+
export declare function watch(path: PathArg, optionsOrListener?: WatchOptions | BufferEncoding | 'buffer' | WatchListener, maybeListener?: WatchListener): FSWatcher;
|
|
61
|
+
/** `fs.StatWatcher` returned from `watchFile`. */
|
|
62
|
+
export declare class StatWatcher extends EventEmitter {
|
|
63
|
+
readonly path: string;
|
|
64
|
+
private readonly disposeMutation;
|
|
65
|
+
private timer;
|
|
66
|
+
private previous;
|
|
67
|
+
private stopped;
|
|
68
|
+
private referenced;
|
|
69
|
+
private readonly context;
|
|
70
|
+
private readonly interval;
|
|
71
|
+
private readonly bigint;
|
|
72
|
+
constructor(path: string, options: WatchFileOptions);
|
|
73
|
+
private schedule;
|
|
74
|
+
/** Stop polling and release the VFS subscription. */
|
|
75
|
+
stop(): void;
|
|
76
|
+
/** Alias used by callers treating the watcher as a closeable handle. */
|
|
77
|
+
close(): void;
|
|
78
|
+
/**
|
|
79
|
+
* Mark this watcher as process-liveness-bearing.
|
|
80
|
+
* @returns This watcher.
|
|
81
|
+
*/
|
|
82
|
+
ref(): this;
|
|
83
|
+
/**
|
|
84
|
+
* Mark this watcher as not keeping its owner alive.
|
|
85
|
+
* @returns This watcher.
|
|
86
|
+
*/
|
|
87
|
+
unref(): this;
|
|
88
|
+
/**
|
|
89
|
+
* Read the retained process-liveness flag.
|
|
90
|
+
* @returns Whether this watcher is marked as keeping its owner alive.
|
|
91
|
+
*/
|
|
92
|
+
hasRef(): boolean;
|
|
93
|
+
}
|
|
94
|
+
/**
|
|
95
|
+
* Register a stat-poll watcher for one path.
|
|
96
|
+
* @param path - File or directory path, including a currently missing path.
|
|
97
|
+
* @param optionsOrListener - Polling options or the change listener.
|
|
98
|
+
* @param maybeListener - Change listener when the second argument carries options.
|
|
99
|
+
* @returns The path's shared stat watcher.
|
|
100
|
+
*/
|
|
101
|
+
export declare function watchFile(path: PathArg, optionsOrListener: WatchFileOptions | StatListener, maybeListener?: StatListener): StatWatcher;
|
|
102
|
+
/**
|
|
103
|
+
* Remove one listener or every listener for a path.
|
|
104
|
+
* @param path - Watched path.
|
|
105
|
+
* @param listener - Specific registration to remove; omission removes all registrations.
|
|
106
|
+
*/
|
|
107
|
+
export declare function unwatchFile(path: PathArg, listener?: StatListener): void;
|
|
108
|
+
/**
|
|
109
|
+
* Create the promise-based watch iterator over the callback watcher.
|
|
110
|
+
* @param path - File or directory path.
|
|
111
|
+
* @param options - Watch options and cancellation signal.
|
|
112
|
+
* @returns An iterator of change records that closes its watcher on return or failure.
|
|
113
|
+
*/
|
|
114
|
+
export declare function watchAsync(path: PathArg, options?: WatchOptions): AsyncIterableIterator<{
|
|
115
|
+
eventType: 'rename' | 'change';
|
|
116
|
+
filename: string | Buffer | null;
|
|
117
|
+
}>;
|
|
118
|
+
export {};
|
|
119
|
+
//# sourceMappingURL=fs-watch.d.ts.map
|