@scelar/nodepod 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (134) hide show
  1. package/LICENSE +43 -0
  2. package/README.md +240 -0
  3. package/dist/child_process-BJOMsZje.js +8233 -0
  4. package/dist/child_process-BJOMsZje.js.map +1 -0
  5. package/dist/child_process-Cj8vOcuc.cjs +7434 -0
  6. package/dist/child_process-Cj8vOcuc.cjs.map +1 -0
  7. package/dist/index-Cb1Cgdnd.js +35308 -0
  8. package/dist/index-Cb1Cgdnd.js.map +1 -0
  9. package/dist/index-DsMGS-xc.cjs +37195 -0
  10. package/dist/index-DsMGS-xc.cjs.map +1 -0
  11. package/dist/index.cjs +65 -0
  12. package/dist/index.cjs.map +1 -0
  13. package/dist/index.mjs +59 -0
  14. package/dist/index.mjs.map +1 -0
  15. package/package.json +95 -0
  16. package/src/__tests__/smoke.test.ts +11 -0
  17. package/src/constants/cdn-urls.ts +18 -0
  18. package/src/constants/config.ts +236 -0
  19. package/src/cross-origin.ts +26 -0
  20. package/src/engine-factory.ts +176 -0
  21. package/src/engine-types.ts +56 -0
  22. package/src/helpers/byte-encoding.ts +39 -0
  23. package/src/helpers/digest.ts +9 -0
  24. package/src/helpers/event-loop.ts +96 -0
  25. package/src/helpers/wasm-cache.ts +133 -0
  26. package/src/iframe-sandbox.ts +141 -0
  27. package/src/index.ts +192 -0
  28. package/src/isolation-helpers.ts +148 -0
  29. package/src/memory-volume.ts +941 -0
  30. package/src/module-transformer.ts +368 -0
  31. package/src/packages/archive-extractor.ts +248 -0
  32. package/src/packages/browser-bundler.ts +284 -0
  33. package/src/packages/installer.ts +396 -0
  34. package/src/packages/registry-client.ts +131 -0
  35. package/src/packages/version-resolver.ts +411 -0
  36. package/src/polyfills/assert.ts +384 -0
  37. package/src/polyfills/async_hooks.ts +144 -0
  38. package/src/polyfills/buffer.ts +628 -0
  39. package/src/polyfills/child_process.ts +2288 -0
  40. package/src/polyfills/chokidar.ts +336 -0
  41. package/src/polyfills/cluster.ts +106 -0
  42. package/src/polyfills/console.ts +136 -0
  43. package/src/polyfills/constants.ts +123 -0
  44. package/src/polyfills/crypto.ts +885 -0
  45. package/src/polyfills/dgram.ts +87 -0
  46. package/src/polyfills/diagnostics_channel.ts +76 -0
  47. package/src/polyfills/dns.ts +134 -0
  48. package/src/polyfills/domain.ts +68 -0
  49. package/src/polyfills/esbuild.ts +854 -0
  50. package/src/polyfills/events.ts +276 -0
  51. package/src/polyfills/fs.ts +2888 -0
  52. package/src/polyfills/fsevents.ts +79 -0
  53. package/src/polyfills/http.ts +1449 -0
  54. package/src/polyfills/http2.ts +199 -0
  55. package/src/polyfills/https.ts +76 -0
  56. package/src/polyfills/inspector.ts +62 -0
  57. package/src/polyfills/lightningcss.ts +105 -0
  58. package/src/polyfills/module.ts +191 -0
  59. package/src/polyfills/net.ts +353 -0
  60. package/src/polyfills/os.ts +238 -0
  61. package/src/polyfills/path.ts +206 -0
  62. package/src/polyfills/perf_hooks.ts +102 -0
  63. package/src/polyfills/process.ts +690 -0
  64. package/src/polyfills/punycode.ts +159 -0
  65. package/src/polyfills/querystring.ts +93 -0
  66. package/src/polyfills/quic.ts +118 -0
  67. package/src/polyfills/readdirp.ts +229 -0
  68. package/src/polyfills/readline.ts +692 -0
  69. package/src/polyfills/repl.ts +134 -0
  70. package/src/polyfills/rollup.ts +119 -0
  71. package/src/polyfills/sea.ts +33 -0
  72. package/src/polyfills/sqlite.ts +78 -0
  73. package/src/polyfills/stream.ts +1620 -0
  74. package/src/polyfills/string_decoder.ts +25 -0
  75. package/src/polyfills/tailwindcss-oxide.ts +309 -0
  76. package/src/polyfills/test.ts +197 -0
  77. package/src/polyfills/timers.ts +32 -0
  78. package/src/polyfills/tls.ts +105 -0
  79. package/src/polyfills/trace_events.ts +50 -0
  80. package/src/polyfills/tty.ts +71 -0
  81. package/src/polyfills/url.ts +174 -0
  82. package/src/polyfills/util.ts +559 -0
  83. package/src/polyfills/v8.ts +126 -0
  84. package/src/polyfills/vm.ts +132 -0
  85. package/src/polyfills/volume-registry.ts +15 -0
  86. package/src/polyfills/wasi.ts +44 -0
  87. package/src/polyfills/worker_threads.ts +326 -0
  88. package/src/polyfills/ws.ts +595 -0
  89. package/src/polyfills/zlib.ts +881 -0
  90. package/src/request-proxy.ts +716 -0
  91. package/src/script-engine.ts +3375 -0
  92. package/src/sdk/nodepod-fs.ts +93 -0
  93. package/src/sdk/nodepod-process.ts +86 -0
  94. package/src/sdk/nodepod-terminal.ts +350 -0
  95. package/src/sdk/nodepod.ts +509 -0
  96. package/src/sdk/types.ts +70 -0
  97. package/src/shell/commands/bun.ts +121 -0
  98. package/src/shell/commands/directory.ts +297 -0
  99. package/src/shell/commands/file-ops.ts +525 -0
  100. package/src/shell/commands/git.ts +2142 -0
  101. package/src/shell/commands/node.ts +80 -0
  102. package/src/shell/commands/npm.ts +198 -0
  103. package/src/shell/commands/pm-types.ts +45 -0
  104. package/src/shell/commands/pnpm.ts +82 -0
  105. package/src/shell/commands/search.ts +264 -0
  106. package/src/shell/commands/shell-env.ts +352 -0
  107. package/src/shell/commands/text-processing.ts +1152 -0
  108. package/src/shell/commands/yarn.ts +84 -0
  109. package/src/shell/shell-builtins.ts +19 -0
  110. package/src/shell/shell-helpers.ts +250 -0
  111. package/src/shell/shell-interpreter.ts +514 -0
  112. package/src/shell/shell-parser.ts +429 -0
  113. package/src/shell/shell-types.ts +85 -0
  114. package/src/syntax-transforms.ts +561 -0
  115. package/src/threading/engine-worker.ts +64 -0
  116. package/src/threading/inline-worker.ts +372 -0
  117. package/src/threading/offload-types.ts +112 -0
  118. package/src/threading/offload-worker.ts +383 -0
  119. package/src/threading/offload.ts +271 -0
  120. package/src/threading/process-context.ts +92 -0
  121. package/src/threading/process-handle.ts +275 -0
  122. package/src/threading/process-manager.ts +956 -0
  123. package/src/threading/process-worker-entry.ts +854 -0
  124. package/src/threading/shared-vfs.ts +352 -0
  125. package/src/threading/sync-channel.ts +135 -0
  126. package/src/threading/task-queue.ts +177 -0
  127. package/src/threading/vfs-bridge.ts +231 -0
  128. package/src/threading/worker-pool.ts +233 -0
  129. package/src/threading/worker-protocol.ts +358 -0
  130. package/src/threading/worker-vfs.ts +218 -0
  131. package/src/types/externals.d.ts +38 -0
  132. package/src/types/fs-streams.ts +142 -0
  133. package/src/types/manifest.ts +17 -0
  134. package/src/worker-sandbox.ts +90 -0
@@ -0,0 +1,372 @@
1
+ // Inline Worker Factory — creates offload workers from embedded source.
2
+ // Worker source is inlined as a string and spawned via Blob URL, so it works
3
+ // in any environment (no separate file to serve). Implements Comlink's wire
4
+ // protocol directly so the message listener is synchronous on boot — no race
5
+ // with the first init() call. Heavy deps (esbuild, pako) load from CDN lazily.
6
+
7
+ import { CDN_ESBUILD_ESM, CDN_ESBUILD_BINARY } from "../constants/cdn-urls";
8
+ import { CDN_PAKO } from "../constants/config";
9
+
10
+ const WORKER_SOURCE = /* js */ `
11
+ "use strict";
12
+
13
+ // CDN URLs (injected at build time)
14
+
15
+ const ESBUILD_ESM_URL = "${CDN_ESBUILD_ESM}";
16
+ const ESBUILD_WASM_URL = "${CDN_ESBUILD_BINARY}";
17
+ const PAKO_URL = "${CDN_PAKO}";
18
+
19
+ const cdnImport = new Function("url", "return import(url)");
20
+
21
+ let esbuildEngine = null;
22
+ let pakoModule = null;
23
+ let _initialized = false;
24
+
25
+ // Minimal Comlink-compatible expose() — implements the wire protocol
26
+ // that comlink.wrap() speaks on the main thread.
27
+
28
+ function miniExpose(obj) {
29
+ self.addEventListener("message", function handler(ev) {
30
+ if (!ev || !ev.data || !ev.data.id) return;
31
+ const { id, type, path } = { path: [], ...ev.data };
32
+
33
+ const args = (ev.data.argumentList || []).map(function(a) {
34
+ return (a && a.type === "RAW") ? a.value : a;
35
+ });
36
+
37
+ let returnValue;
38
+ try {
39
+ const parent = path.length > 1
40
+ ? path.slice(0, -1).reduce(function(o, p) { return o[p]; }, obj)
41
+ : obj;
42
+ const target = path.reduce(function(o, p) { return o[p]; }, obj);
43
+
44
+ switch (type) {
45
+ case "GET":
46
+ returnValue = target;
47
+ break;
48
+ case "SET":
49
+ parent[path[path.length - 1]] = (ev.data.value && ev.data.value.type === "RAW")
50
+ ? ev.data.value.value
51
+ : ev.data.value;
52
+ returnValue = true;
53
+ break;
54
+ case "APPLY":
55
+ returnValue = target.apply(parent, args);
56
+ break;
57
+ case "CONSTRUCT":
58
+ returnValue = new target(...args);
59
+ break;
60
+ case "RELEASE":
61
+ returnValue = undefined;
62
+ break;
63
+ default:
64
+ return;
65
+ }
66
+ } catch (err) {
67
+ self.postMessage({
68
+ id: id,
69
+ type: "HANDLER",
70
+ name: "throw",
71
+ value: {
72
+ isError: true,
73
+ value: { message: (err && err.message) || String(err), name: (err && err.name) || "Error", stack: (err && err.stack) || "" }
74
+ }
75
+ });
76
+ return;
77
+ }
78
+
79
+ Promise.resolve(returnValue)
80
+ .then(function(result) {
81
+ self.postMessage({ id: id, type: "RAW", value: result });
82
+ })
83
+ .catch(function(err) {
84
+ self.postMessage({
85
+ id: id,
86
+ type: "HANDLER",
87
+ name: "throw",
88
+ value: {
89
+ isError: true,
90
+ value: { message: (err && err.message) || String(err), name: (err && err.name) || "Error", stack: (err && err.stack) || "" }
91
+ }
92
+ });
93
+ });
94
+ });
95
+ }
96
+
97
+ // --- Base64 helper ---
98
+
99
+ const SEGMENT_SIZE = 8192;
100
+
101
+ function uint8ToBase64(data) {
102
+ const segments = [];
103
+ for (let offset = 0; offset < data.length; offset += SEGMENT_SIZE) {
104
+ segments.push(
105
+ String.fromCharCode.apply(
106
+ null,
107
+ Array.from(data.subarray(offset, offset + SEGMENT_SIZE))
108
+ )
109
+ );
110
+ }
111
+ return btoa(segments.join(""));
112
+ }
113
+
114
+ // --- Tar parser ---
115
+
116
+ function readNullTerminated(buf, start, len) {
117
+ const slice = buf.slice(start, start + len);
118
+ const zeroPos = slice.indexOf(0);
119
+ const trimmed = zeroPos >= 0 ? slice.slice(0, zeroPos) : slice;
120
+ return new TextDecoder().decode(trimmed);
121
+ }
122
+
123
+ function readOctalField(buf, start, len) {
124
+ const raw = readNullTerminated(buf, start, len).trim();
125
+ return parseInt(raw, 8) || 0;
126
+ }
127
+
128
+ function classifyTypeFlag(flag) {
129
+ switch (flag) {
130
+ case "0": case "\\0": case "": return "file";
131
+ case "5": return "directory";
132
+ case "1": case "2": return "link";
133
+ default: return "other";
134
+ }
135
+ }
136
+
137
+ function* parseTar(raw) {
138
+ const BLOCK = 512;
139
+ let cursor = 0;
140
+ while (cursor + BLOCK <= raw.length) {
141
+ const header = raw.slice(cursor, cursor + BLOCK);
142
+ cursor += BLOCK;
143
+ if (header.every(function(b) { return b === 0; })) break;
144
+ const nameField = readNullTerminated(header, 0, 100);
145
+ if (!nameField) continue;
146
+ const byteSize = readOctalField(header, 124, 12);
147
+ const typeChar = String.fromCharCode(header[156]);
148
+ const prefixField = readNullTerminated(header, 345, 155);
149
+ const filepath = prefixField ? prefixField + "/" + nameField : nameField;
150
+ const kind = classifyTypeFlag(typeChar);
151
+ let payload;
152
+ if (kind === "file") {
153
+ payload = byteSize > 0 ? raw.slice(cursor, cursor + byteSize) : new Uint8Array(0);
154
+ if (byteSize > 0) cursor += Math.ceil(byteSize / BLOCK) * BLOCK;
155
+ }
156
+ yield { filepath: filepath, kind: kind, byteSize: byteSize, payload: payload };
157
+ }
158
+ }
159
+
160
+ // --- JSX detection ---
161
+
162
+ function detectJsx(source) {
163
+ if (/<[A-Z][a-zA-Z0-9.]*[\\s/>]/.test(source)) return true;
164
+ if (/<\\/[a-zA-Z]/.test(source)) return true;
165
+ if (/\\/>/.test(source)) return true;
166
+ if (/<>|<\\/>/.test(source)) return true;
167
+ if (/React\\.createElement\\b/.test(source)) return true;
168
+ if (/jsx\\(|jsxs\\(|jsxDEV\\(/.test(source)) return true;
169
+ return false;
170
+ }
171
+
172
+ // --- Default define map ---
173
+
174
+ const DEFAULT_DEFINE = {
175
+ "import.meta.url": "import_meta.url",
176
+ "import.meta.dirname": "import_meta.dirname",
177
+ "import.meta.filename": "import_meta.filename",
178
+ "import.meta": "import_meta",
179
+ };
180
+
181
+ // --- Worker endpoint ---
182
+
183
+ const endpoint = {
184
+ async init() {
185
+ if (_initialized) return;
186
+
187
+ const pakoMod = await cdnImport(PAKO_URL);
188
+ pakoModule = pakoMod.default || pakoMod;
189
+
190
+ const esbuildMod = await cdnImport(ESBUILD_ESM_URL);
191
+ esbuildEngine = esbuildMod.default || esbuildMod;
192
+
193
+ try {
194
+ await esbuildEngine.initialize({ wasmURL: ESBUILD_WASM_URL });
195
+ } catch (err) {
196
+ if (!(err instanceof Error && err.message.includes('Cannot call "initialize" more than once'))) {
197
+ throw err;
198
+ }
199
+ }
200
+
201
+ _initialized = true;
202
+ },
203
+
204
+ async transform(task) {
205
+ if (!esbuildEngine) throw new Error("Worker not initialized");
206
+
207
+ const opts = task.options || {};
208
+ let loader = opts.loader || "js";
209
+ const format = opts.format || "cjs";
210
+ const define = opts.define || DEFAULT_DEFINE;
211
+
212
+ if (loader === "js" && detectJsx(task.source)) loader = "jsx";
213
+
214
+ const transformOpts = {
215
+ loader: loader,
216
+ format: format,
217
+ target: opts.target || "esnext",
218
+ platform: opts.platform || "neutral",
219
+ define: define,
220
+ };
221
+
222
+ try {
223
+ const output = await esbuildEngine.transform(task.source, transformOpts);
224
+ return {
225
+ type: "transform",
226
+ id: task.id,
227
+ code: output.code,
228
+ warnings: (output.warnings || []).map(function(w) { return w.text || String(w); }),
229
+ };
230
+ } catch (err) {
231
+ const fallbacks = loader === "js" ? ["jsx", "tsx", "ts"] : loader === "jsx" ? ["tsx"] : [];
232
+ for (let i = 0; i < fallbacks.length; i++) {
233
+ try {
234
+ const output = await esbuildEngine.transform(task.source, Object.assign({}, transformOpts, { loader: fallbacks[i] }));
235
+ return { type: "transform", id: task.id, code: output.code, warnings: [] };
236
+ } catch (e) { /* try next */ }
237
+ }
238
+ if (err && err.message && err.message.includes("Top-level await")) {
239
+ try {
240
+ const output = await esbuildEngine.transform(task.source, Object.assign({}, transformOpts, { format: "esm" }));
241
+ return { type: "transform", id: task.id, code: output.code, warnings: [] };
242
+ } catch (e) { /* fall through */ }
243
+ }
244
+ return { type: "transform", id: task.id, code: task.source, warnings: [(err && err.message) || "transform failed"] };
245
+ }
246
+ },
247
+
248
+ async extract(task) {
249
+ if (!pakoModule) throw new Error("Worker not initialized");
250
+
251
+ const response = await fetch(task.tarballUrl);
252
+ if (!response.ok) {
253
+ throw new Error("Archive download failed (HTTP " + response.status + "): " + task.tarballUrl);
254
+ }
255
+
256
+ const compressed = new Uint8Array(await response.arrayBuffer());
257
+ const tarBytes = pakoModule.inflate(compressed);
258
+
259
+ const files = [];
260
+ for (const entry of parseTar(tarBytes)) {
261
+ if (entry.kind !== "file" && entry.kind !== "directory") continue;
262
+ let relative = entry.filepath;
263
+ if (task.stripComponents > 0) {
264
+ const segments = relative.split("/").filter(Boolean);
265
+ if (segments.length <= task.stripComponents) continue;
266
+ relative = segments.slice(task.stripComponents).join("/");
267
+ }
268
+ if (entry.kind === "file" && entry.payload) {
269
+ let data;
270
+ let isBinary = false;
271
+ try {
272
+ data = new TextDecoder("utf-8", { fatal: true }).decode(entry.payload);
273
+ } catch (e) {
274
+ data = uint8ToBase64(entry.payload);
275
+ isBinary = true;
276
+ }
277
+ files.push({ path: relative, data: data, isBinary: isBinary });
278
+ }
279
+ }
280
+
281
+ return { type: "extract", id: task.id, files: files };
282
+ },
283
+
284
+ async build(task) {
285
+ if (!esbuildEngine) throw new Error("Worker not initialized");
286
+
287
+ const fileMap = new Map();
288
+ const entries = Object.entries(task.files);
289
+ for (let i = 0; i < entries.length; i++) {
290
+ fileMap.set(entries[i][0], entries[i][1]);
291
+ }
292
+
293
+ const volumePlugin = {
294
+ name: "offload-volume",
295
+ setup: function(build) {
296
+ build.onLoad({ filter: /.*/ }, function(args) {
297
+ const content = fileMap.get(args.path);
298
+ if (content === undefined) return null;
299
+ const ext = args.path.substring(args.path.lastIndexOf("."));
300
+ const loaderMap = { ".ts": "ts", ".tsx": "tsx", ".js": "js", ".mjs": "js", ".cjs": "js", ".jsx": "jsx", ".json": "json", ".css": "css" };
301
+ return { contents: content, loader: loaderMap[ext] || undefined };
302
+ });
303
+ },
304
+ };
305
+
306
+ try {
307
+ const result = await esbuildEngine.build({
308
+ entryPoints: task.entryPoints,
309
+ stdin: task.stdin,
310
+ bundle: task.bundle !== false,
311
+ format: task.format || "esm",
312
+ platform: task.platform || "browser",
313
+ target: task.target || "esnext",
314
+ minify: !!task.minify,
315
+ external: task.external,
316
+ write: false,
317
+ plugins: [volumePlugin],
318
+ absWorkingDir: task.absWorkingDir || "/",
319
+ });
320
+
321
+ return {
322
+ type: "build",
323
+ id: task.id,
324
+ outputFiles: (result.outputFiles || []).map(function(f) {
325
+ return { path: f.path, text: f.text || new TextDecoder().decode(f.contents) };
326
+ }),
327
+ errors: (result.errors || []).map(function(e) { return e.text || String(e); }),
328
+ warnings: (result.warnings || []).map(function(w) { return w.text || String(w); }),
329
+ };
330
+ } catch (err) {
331
+ return {
332
+ type: "build",
333
+ id: task.id,
334
+ outputFiles: [],
335
+ errors: [(err && err.message) || "build failed"],
336
+ warnings: [],
337
+ };
338
+ }
339
+ },
340
+
341
+ ping: function() {
342
+ return true;
343
+ },
344
+ };
345
+
346
+ miniExpose(endpoint);
347
+ `;
348
+
349
+ // --- Factory ---
350
+
351
+ let cachedBlobUrl: string | null = null;
352
+
353
+ // Creates a Worker from the inline source. Blob URL is cached and reused.
354
+ export function createInlineWorker(): Worker | null {
355
+ try {
356
+ if (!cachedBlobUrl) {
357
+ const blob = new Blob([WORKER_SOURCE], { type: "application/javascript" });
358
+ cachedBlobUrl = URL.createObjectURL(blob);
359
+ }
360
+ return new Worker(cachedBlobUrl);
361
+ } catch {
362
+ return null;
363
+ }
364
+ }
365
+
366
+ // Clean up the cached blob URL when the pool is permanently disposed.
367
+ export function revokeInlineWorkerUrl(): void {
368
+ if (cachedBlobUrl) {
369
+ URL.revokeObjectURL(cachedBlobUrl);
370
+ cachedBlobUrl = null;
371
+ }
372
+ }
@@ -0,0 +1,112 @@
1
+ // Type definitions for the worker offloading system.
2
+ // All types must be structured-clone compatible (postMessage-safe).
3
+
4
+ // --- Task priority ---
5
+
6
+ export enum TaskPriority {
7
+ HIGH = 0, // runtime transforms (user waiting)
8
+ NORMAL = 1, // install-time bulk transforms
9
+ LOW = 2, // background pre-bundling
10
+ }
11
+
12
+ // --- Transform task ---
13
+
14
+ export interface TransformTask {
15
+ type: "transform";
16
+ id: string;
17
+ source: string;
18
+ filePath: string;
19
+ options?: {
20
+ loader?: "js" | "jsx" | "ts" | "tsx";
21
+ format?: "cjs" | "esm";
22
+ target?: string;
23
+ platform?: string;
24
+ define?: Record<string, string>;
25
+ };
26
+ priority: TaskPriority;
27
+ }
28
+
29
+ export interface TransformResult {
30
+ type: "transform";
31
+ id: string;
32
+ code: string;
33
+ warnings: string[];
34
+ }
35
+
36
+ // --- Extract task ---
37
+
38
+ export interface ExtractTask {
39
+ type: "extract";
40
+ id: string;
41
+ tarballUrl: string;
42
+ stripComponents: number;
43
+ priority: TaskPriority;
44
+ }
45
+
46
+ export interface ExtractedFile {
47
+ path: string;
48
+ // UTF-8 text, or base64-encoded binary
49
+ data: string;
50
+ isBinary: boolean;
51
+ }
52
+
53
+ export interface ExtractResult {
54
+ type: "extract";
55
+ id: string;
56
+ files: ExtractedFile[];
57
+ }
58
+
59
+ // --- Build task ---
60
+
61
+ export interface BuildTask {
62
+ type: "build";
63
+ id: string;
64
+ files: Record<string, string>;
65
+ entryPoints?: string[];
66
+ stdin?: { contents: string; resolveDir?: string; loader?: string };
67
+ bundle?: boolean;
68
+ format?: "iife" | "cjs" | "esm";
69
+ platform?: "browser" | "node" | "neutral";
70
+ target?: string | string[];
71
+ minify?: boolean;
72
+ external?: string[];
73
+ absWorkingDir?: string;
74
+ priority: TaskPriority;
75
+ }
76
+
77
+ export interface BuildOutputFile {
78
+ path: string;
79
+ text: string;
80
+ }
81
+
82
+ export interface BuildResult {
83
+ type: "build";
84
+ id: string;
85
+ outputFiles: BuildOutputFile[];
86
+ errors: string[];
87
+ warnings: string[];
88
+ }
89
+
90
+ // --- Union types ---
91
+
92
+ export type OffloadTask = TransformTask | ExtractTask | BuildTask;
93
+ export type OffloadResult = TransformResult | ExtractResult | BuildResult;
94
+
95
+ // --- Worker endpoint (exposed via Comlink) ---
96
+
97
+ export interface OffloadWorkerEndpoint {
98
+ init(): Promise<void>;
99
+ transform(task: TransformTask): Promise<TransformResult>;
100
+ extract(task: ExtractTask): Promise<ExtractResult>;
101
+ build(task: BuildTask): Promise<BuildResult>;
102
+ ping(): boolean;
103
+ }
104
+
105
+ // --- Pool config ---
106
+
107
+ export interface PoolConfig {
108
+ minWorkers?: number;
109
+ maxWorkers?: number;
110
+ idleTimeoutMs?: number;
111
+ warmUpOnCreate?: boolean;
112
+ }