@capsule-run/sdk 0.7.1 → 0.8.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 (62) hide show
  1. package/README.md +5 -1
  2. package/dist/app.d.ts +7 -0
  3. package/dist/app.d.ts.map +1 -1
  4. package/dist/app.js +7 -0
  5. package/dist/app.js.map +1 -1
  6. package/dist/index.d.ts +1 -2
  7. package/dist/index.d.ts.map +1 -1
  8. package/dist/index.js +1 -2
  9. package/dist/index.js.map +1 -1
  10. package/dist/polyfills/fs.d.ts +148 -10
  11. package/dist/polyfills/fs.d.ts.map +1 -1
  12. package/dist/polyfills/fs.js +497 -17
  13. package/dist/polyfills/fs.js.map +1 -1
  14. package/dist/polyfills/process.d.ts +7 -2
  15. package/dist/polyfills/process.d.ts.map +1 -1
  16. package/dist/polyfills/process.js +78 -6
  17. package/dist/polyfills/process.js.map +1 -1
  18. package/dist/run.d.ts +4 -0
  19. package/dist/run.d.ts.map +1 -1
  20. package/dist/run.js +3 -2
  21. package/dist/run.js.map +1 -1
  22. package/dist/task.d.ts +11 -2
  23. package/dist/task.d.ts.map +1 -1
  24. package/dist/task.js +6 -3
  25. package/dist/task.js.map +1 -1
  26. package/package.json +4 -10
  27. package/src/app.ts +8 -0
  28. package/src/index.ts +1 -2
  29. package/src/polyfills/fs.ts +572 -20
  30. package/src/polyfills/process.ts +80 -6
  31. package/src/run.ts +7 -2
  32. package/src/task.ts +32 -14
  33. package/dist/polyfills/buffer.d.ts +0 -8
  34. package/dist/polyfills/buffer.d.ts.map +0 -1
  35. package/dist/polyfills/buffer.js +0 -9
  36. package/dist/polyfills/buffer.js.map +0 -1
  37. package/dist/polyfills/events.d.ts +0 -8
  38. package/dist/polyfills/events.d.ts.map +0 -1
  39. package/dist/polyfills/events.js +0 -9
  40. package/dist/polyfills/events.js.map +0 -1
  41. package/dist/polyfills/path.d.ts +0 -8
  42. package/dist/polyfills/path.d.ts.map +0 -1
  43. package/dist/polyfills/path.js +0 -8
  44. package/dist/polyfills/path.js.map +0 -1
  45. package/dist/polyfills/stream-web.d.ts +0 -74
  46. package/dist/polyfills/stream-web.d.ts.map +0 -1
  47. package/dist/polyfills/stream-web.js +0 -23
  48. package/dist/polyfills/stream-web.js.map +0 -1
  49. package/dist/polyfills/stream.d.ts +0 -16
  50. package/dist/polyfills/stream.d.ts.map +0 -1
  51. package/dist/polyfills/stream.js +0 -16
  52. package/dist/polyfills/stream.js.map +0 -1
  53. package/dist/polyfills/url.d.ts +0 -47
  54. package/dist/polyfills/url.d.ts.map +0 -1
  55. package/dist/polyfills/url.js +0 -68
  56. package/dist/polyfills/url.js.map +0 -1
  57. package/src/polyfills/buffer.ts +0 -11
  58. package/src/polyfills/events.ts +0 -11
  59. package/src/polyfills/path.ts +0 -21
  60. package/src/polyfills/stream-web.ts +0 -24
  61. package/src/polyfills/stream.ts +0 -28
  62. package/src/polyfills/url.ts +0 -73
@@ -9,6 +9,16 @@ declare const globalThis: {
9
9
  getArguments(): string[];
10
10
  initialCwd(): string | null;
11
11
  };
12
+ 'wasi:cli/stdin': {
13
+ getStdin(): {
14
+ blockingRead(len: bigint): [Uint8Array, boolean];
15
+ };
16
+ };
17
+ 'wasi:cli/stdout': {
18
+ getStdout(): {
19
+ blockingWriteAndFlush(buf: Uint8Array): void;
20
+ };
21
+ };
12
22
  };
13
23
 
14
24
  /**
@@ -178,24 +188,88 @@ const process = {
178
188
  },
179
189
 
180
190
  /**
181
- * Standard streams (not fully implemented)
191
+ * Standard input backed by wasi:cli/stdin@0.2.0.
192
+ * Exposes a minimal EventEmitter-compatible Readable so that
193
+ * MCP's StdioServerTransport can call stdin.on('data', ...).
182
194
  */
183
- get stdout(): any {
195
+ get stdin(): any {
196
+ const listeners: Array<(chunk: Uint8Array | string) => void> = [];
197
+ let reading = false;
198
+
199
+ function startReading() {
200
+ if (reading) return;
201
+ reading = true;
202
+ (async () => {
203
+ try {
204
+ const api = globalThis['wasi:cli/stdin'];
205
+ if (!api) return;
206
+ const stream = api.getStdin();
207
+ while (true) {
208
+ const [chunk, done] = stream.blockingRead(BigInt(4096));
209
+ if (chunk && chunk.length > 0) {
210
+ const buf = chunk;
211
+ listeners.forEach(fn => fn(buf));
212
+ }
213
+ if (done) {
214
+ endListeners.forEach(fn => fn());
215
+ break;
216
+ }
217
+ }
218
+ } catch { /* stdin not available */ }
219
+ })();
220
+ }
221
+
222
+ const endListeners: Array<() => void> = [];
223
+
184
224
  return {
185
- write: (data: string) => console.log(data),
186
225
  isTTY: false,
226
+ readable: true,
227
+ on(event: string, fn: (...args: any[]) => void) {
228
+ if (event === 'data') { listeners.push(fn); startReading(); }
229
+ if (event === 'end') { endListeners.push(fn); }
230
+ return this;
231
+ },
232
+ once(event: string, fn: (...args: any[]) => void) {
233
+ return this.on(event, fn);
234
+ },
235
+ pause() { return this; },
236
+ resume() { startReading(); return this; },
237
+ pipe(dest: any) { return dest; },
238
+ setEncoding(_enc: string) { return this; },
187
239
  };
188
240
  },
189
241
 
190
- get stderr(): any {
242
+ /**
243
+ * Standard output — backed by wasi:cli/stdout@0.2.0.
244
+ */
245
+ get stdout(): any {
191
246
  return {
192
- write: (data: string) => console.error(data),
193
247
  isTTY: false,
248
+ write(data: string | Uint8Array, _enc?: string, cb?: () => void): boolean {
249
+ try {
250
+ const api = globalThis['wasi:cli/stdout'];
251
+ if (api) {
252
+ const bytes = typeof data === 'string' ? new TextEncoder().encode(data) : data;
253
+ api.getStdout().blockingWriteAndFlush(bytes);
254
+ } else {
255
+ console.log(typeof data === 'string' ? data : new TextDecoder().decode(data));
256
+ }
257
+ } catch {
258
+ console.log(typeof data === 'string' ? data : new TextDecoder().decode(data));
259
+ }
260
+ cb?.();
261
+ return true;
262
+ },
263
+ end(data?: string | Uint8Array, cb?: () => void): void {
264
+ if (data) this.write(data);
265
+ cb?.();
266
+ },
194
267
  };
195
268
  },
196
269
 
197
- get stdin(): any {
270
+ get stderr(): any {
198
271
  return {
272
+ write: (data: string) => console.error(data),
199
273
  isTTY: false,
200
274
  };
201
275
  },
package/src/run.ts CHANGED
@@ -8,10 +8,12 @@
8
8
  import { execFile } from 'child_process';
9
9
  import { resolve, extname } from 'path';
10
10
  import { existsSync } from 'fs';
11
+ import { HostRequest } from './task';
11
12
 
12
13
  export interface RunnerOptions {
13
14
  file: string;
14
15
  args?: string[];
16
+ mounts?: string[];
15
17
  cwd?: string;
16
18
  capsulePath?: string;
17
19
  }
@@ -25,6 +27,8 @@ export interface RunnerResult {
25
27
  duration_ms: number;
26
28
  retries: number;
27
29
  fuel_consumed: number;
30
+ ram_used: number;
31
+ host_requests: HostRequest[];
28
32
  };
29
33
  }
30
34
 
@@ -47,7 +51,7 @@ function getCapsuleCommand(capsulePath: string): string {
47
51
  * @returns Promise with the runner result
48
52
  */
49
53
  export function run(options: RunnerOptions): Promise<RunnerResult> {
50
- const { file, args = [], cwd, capsulePath = 'capsule' } = options;
54
+ const { file, args = [], mounts = [], cwd, capsulePath = 'capsule' } = options;
51
55
  const command = getCapsuleCommand(capsulePath);
52
56
 
53
57
  const resolvedFile = resolve(cwd || process.cwd(), file);
@@ -64,7 +68,8 @@ export function run(options: RunnerOptions): Promise<RunnerResult> {
64
68
  const subcommand = isWasm ? 'exec' : 'run';
65
69
 
66
70
  return new Promise((resolve, reject) => {
67
- const cmdArgs = [subcommand, resolvedFile, '--json', ...args];
71
+ const mountFlags = mounts.flatMap(m => ['--mount', m]);
72
+ const cmdArgs = [subcommand, resolvedFile, '--json', ...mountFlags, ...args];
68
73
 
69
74
  let executable = command;
70
75
  let executionArgs = cmdArgs;
package/src/task.ts CHANGED
@@ -50,13 +50,18 @@ interface TaskExecution {
50
50
  duration_ms: number;
51
51
  retries: number;
52
52
  fuel_consumed: number;
53
+ ram_used: number;
54
+ host_requests: HostRequest[];
53
55
  }
54
56
 
55
- type Awaited<T> = T extends Promise<infer U> ? U : T;
57
+ export interface HostRequest {
58
+ method: string;
59
+ url: string;
60
+ headers?: string[] | null;
61
+ body?: string | null;
62
+ status: number;
63
+ }
56
64
 
57
- type TaskReturnType<T> = T extends Promise<infer U>
58
- ? Promise<TaskResult<U>>
59
- : TaskResult<T>;
60
65
 
61
66
  /**
62
67
  * Define a Capsule task with configuration.
@@ -121,10 +126,20 @@ function normalizeAllowedFile(entry: string | AllowedFile): string {
121
126
  }
122
127
  }
123
128
 
124
- export function task<TArgs extends any[], TReturn>(
129
+ export function task<TArgs extends unknown[], TReturn>(
130
+ options: TaskOptions,
131
+ fn: (...args: TArgs) => Promise<TReturn>
132
+ ): (...args: TArgs) => Promise<TaskResult<TReturn>>;
133
+
134
+ export function task<TArgs extends unknown[], TReturn>(
125
135
  options: TaskOptions,
126
136
  fn: (...args: TArgs) => TReturn
127
- ): (...args: TArgs) => TaskReturnType<TReturn> {
137
+ ): (...args: TArgs) => TaskResult<TReturn>;
138
+
139
+ export function task<TArgs extends unknown[], TReturn>(
140
+ options: TaskOptions,
141
+ fn: (...args: TArgs) => TReturn | Promise<TReturn>
142
+ ): (...args: TArgs) => TaskResult<TReturn> | Promise<TaskResult<TReturn>> {
128
143
  const taskName = options.name;
129
144
  let compute = options.compute?.toString().toUpperCase() ?? "MEDIUM";
130
145
  let allowedHosts = options.allowedHosts ?? [];
@@ -140,45 +155,48 @@ export function task<TArgs extends any[], TReturn>(
140
155
  envVariables: options.envVariables,
141
156
  };
142
157
 
143
- const wrapper = (...args: TArgs): TaskReturnType<TReturn> => {
158
+ const wrapper = (...args: TArgs): TaskResult<TReturn> | Promise<TaskResult<TReturn>> => {
144
159
  if (!isWasmMode()) {
145
160
  const result = fn(...args);
146
161
 
147
162
  if (result instanceof Promise) {
148
163
  return result.then((value) => ({
149
164
  success: true,
150
- result: value,
165
+ result: value as TReturn,
151
166
  error: null,
152
167
  execution: {
153
168
  task_name: taskName,
154
169
  duration_ms: 0,
155
170
  retries: 0,
156
171
  fuel_consumed: 0,
172
+ ram_used: 0,
173
+ host_requests: [],
157
174
  },
158
- })) as TaskReturnType<TReturn>;
175
+ }));
159
176
  }
160
177
 
161
178
  return {
162
179
  success: true,
163
- result,
180
+ result: result as TReturn,
164
181
  error: null,
165
182
  execution: {
166
183
  task_name: taskName,
167
184
  duration_ms: 0,
168
185
  retries: 0,
169
186
  fuel_consumed: 0,
187
+ ram_used: 0,
188
+ host_requests: [],
170
189
  },
171
- } as TaskReturnType<TReturn>;
190
+ };
172
191
  }
173
192
 
174
193
  const resultJson = callHost(taskName, args, taskConfig);
175
194
 
176
195
  try {
177
- const result: TaskResult<Awaited<TReturn>> = JSON.parse(resultJson);
178
- return result as TaskReturnType<TReturn>;
196
+ return JSON.parse(resultJson) as TaskResult<TReturn>;
179
197
  } catch (e) {
180
198
  if (e instanceof SyntaxError) {
181
- return resultJson as unknown as TaskReturnType<TReturn>;
199
+ return resultJson as unknown as TaskResult<TReturn>;
182
200
  }
183
201
  throw e;
184
202
  }
@@ -1,8 +0,0 @@
1
- /**
2
- * Buffer polyfill for WASI environment
3
- * Provides Node.js-compatible Buffer class using the buffer package
4
- */
5
- import { Buffer as BufferPolyfill } from 'buffer';
6
- export declare const Buffer: BufferConstructor;
7
- export default BufferPolyfill;
8
- //# sourceMappingURL=buffer.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"buffer.d.ts","sourceRoot":"","sources":["../../src/polyfills/buffer.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,MAAM,IAAI,cAAc,EAAE,MAAM,QAAQ,CAAC;AAIlD,eAAO,MAAM,MAAM,mBAAiB,CAAC;AACrC,eAAe,cAAc,CAAC"}
@@ -1,9 +0,0 @@
1
- /**
2
- * Buffer polyfill for WASI environment
3
- * Provides Node.js-compatible Buffer class using the buffer package
4
- */
5
- import { Buffer as BufferPolyfill } from 'buffer';
6
- globalThis.Buffer = BufferPolyfill;
7
- export const Buffer = BufferPolyfill;
8
- export default BufferPolyfill;
9
- //# sourceMappingURL=buffer.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"buffer.js","sourceRoot":"","sources":["../../src/polyfills/buffer.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,MAAM,IAAI,cAAc,EAAE,MAAM,QAAQ,CAAC;AAEjD,UAAkB,CAAC,MAAM,GAAG,cAAc,CAAC;AAE5C,MAAM,CAAC,MAAM,MAAM,GAAG,cAAc,CAAC;AACrC,eAAe,cAAc,CAAC"}
@@ -1,8 +0,0 @@
1
- /**
2
- * Events polyfill for WASI environment
3
- * Provides Node.js-compatible EventEmitter using the events package
4
- */
5
- import EventEmitter from 'events';
6
- export { EventEmitter };
7
- export default EventEmitter;
8
- //# sourceMappingURL=events.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"events.d.ts","sourceRoot":"","sources":["../../src/polyfills/events.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,YAAY,MAAM,QAAQ,CAAC;AAIlC,OAAO,EAAE,YAAY,EAAE,CAAC;AACxB,eAAe,YAAY,CAAC"}
@@ -1,9 +0,0 @@
1
- /**
2
- * Events polyfill for WASI environment
3
- * Provides Node.js-compatible EventEmitter using the events package
4
- */
5
- import EventEmitter from 'events';
6
- globalThis.EventEmitter = EventEmitter;
7
- export { EventEmitter };
8
- export default EventEmitter;
9
- //# sourceMappingURL=events.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"events.js","sourceRoot":"","sources":["../../src/polyfills/events.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,YAAY,MAAM,QAAQ,CAAC;AAEjC,UAAkB,CAAC,YAAY,GAAG,YAAY,CAAC;AAEhD,OAAO,EAAE,YAAY,EAAE,CAAC;AACxB,eAAe,YAAY,CAAC"}
@@ -1,8 +0,0 @@
1
- /**
2
- * Path polyfill
3
- * Provides Node.js-compatible path object
4
- */
5
- import path from 'path-browserify';
6
- export default path;
7
- export declare const resolve: (this: void, ...pathSegments: string[]) => string, join: (this: void, ...paths: string[]) => string, dirname: (this: void, path: string) => string, basename: (this: void, path: string, ext?: string) => string, extname: (this: void, path: string) => string, format: (this: void, pathObject: Partial<path.PathObject>) => string, parse: (this: void, path: string) => path.PathObject, sep: string, delimiter: string, posix: path.Path, win32: null;
8
- //# sourceMappingURL=path.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"path.d.ts","sourceRoot":"","sources":["../../src/polyfills/path.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,IAAI,MAAM,iBAAiB,CAAC;AAEnC,eAAe,IAAI,CAAC;AACpB,eAAO,MACH,OAAO,qDACP,IAAI,8CACJ,OAAO,wCACP,QAAQ,sDACR,OAAO,wCACP,MAAM,gEACN,KAAK,iDACL,GAAG,UACH,SAAS,UACT,KAAK,aACL,KAAK,MACD,CAAC"}
@@ -1,8 +0,0 @@
1
- /**
2
- * Path polyfill
3
- * Provides Node.js-compatible path object
4
- */
5
- import path from 'path-browserify';
6
- export default path;
7
- export const { resolve, join, dirname, basename, extname, format, parse, sep, delimiter, posix, win32 } = path;
8
- //# sourceMappingURL=path.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"path.js","sourceRoot":"","sources":["../../src/polyfills/path.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,IAAI,MAAM,iBAAiB,CAAC;AAEnC,eAAe,IAAI,CAAC;AACpB,MAAM,CAAC,MAAM,EACT,OAAO,EACP,IAAI,EACJ,OAAO,EACP,QAAQ,EACR,OAAO,EACP,MAAM,EACN,KAAK,EACL,GAAG,EACH,SAAS,EACT,KAAK,EACL,KAAK,EACR,GAAG,IAAI,CAAC"}
@@ -1,74 +0,0 @@
1
- /**
2
- * stream/web polyfill for WASI environment
3
- * Exports the native Web Streams API which is built into StarlingMonkey
4
- */
5
- export declare const ReadableStream: {
6
- new (underlyingSource: UnderlyingByteSource, strategy?: {
7
- highWaterMark?: number;
8
- }): ReadableStream<Uint8Array<ArrayBuffer>>;
9
- new <R = any>(underlyingSource: UnderlyingDefaultSource<R>, strategy?: QueuingStrategy<R>): ReadableStream<R>;
10
- new <R = any>(underlyingSource?: UnderlyingSource<R>, strategy?: QueuingStrategy<R>): ReadableStream<R>;
11
- prototype: ReadableStream;
12
- };
13
- export declare const WritableStream: {
14
- new <W = any>(underlyingSink?: UnderlyingSink<W>, strategy?: QueuingStrategy<W>): WritableStream<W>;
15
- prototype: WritableStream;
16
- };
17
- export declare const TransformStream: {
18
- new <I = any, O = any>(transformer?: Transformer<I, O>, writableStrategy?: QueuingStrategy<I>, readableStrategy?: QueuingStrategy<O>): TransformStream<I, O>;
19
- prototype: TransformStream;
20
- };
21
- export declare const ReadableStreamDefaultReader: {
22
- new <R = any>(stream: ReadableStream<R>): ReadableStreamDefaultReader<R>;
23
- prototype: ReadableStreamDefaultReader;
24
- };
25
- export declare const ReadableStreamBYOBReader: any;
26
- export declare const WritableStreamDefaultWriter: {
27
- new <W = any>(stream: WritableStream<W>): WritableStreamDefaultWriter<W>;
28
- prototype: WritableStreamDefaultWriter;
29
- };
30
- export declare const ByteLengthQueuingStrategy: {
31
- new (init: QueuingStrategyInit): ByteLengthQueuingStrategy;
32
- prototype: ByteLengthQueuingStrategy;
33
- };
34
- export declare const CountQueuingStrategy: {
35
- new (init: QueuingStrategyInit): CountQueuingStrategy;
36
- prototype: CountQueuingStrategy;
37
- };
38
- declare const _default: {
39
- ReadableStream: {
40
- new (underlyingSource: UnderlyingByteSource, strategy?: {
41
- highWaterMark?: number;
42
- }): ReadableStream<Uint8Array<ArrayBuffer>>;
43
- new <R = any>(underlyingSource: UnderlyingDefaultSource<R>, strategy?: QueuingStrategy<R>): ReadableStream<R>;
44
- new <R = any>(underlyingSource?: UnderlyingSource<R>, strategy?: QueuingStrategy<R>): ReadableStream<R>;
45
- prototype: ReadableStream;
46
- };
47
- WritableStream: {
48
- new <W = any>(underlyingSink?: UnderlyingSink<W>, strategy?: QueuingStrategy<W>): WritableStream<W>;
49
- prototype: WritableStream;
50
- };
51
- TransformStream: {
52
- new <I = any, O = any>(transformer?: Transformer<I, O>, writableStrategy?: QueuingStrategy<I>, readableStrategy?: QueuingStrategy<O>): TransformStream<I, O>;
53
- prototype: TransformStream;
54
- };
55
- ReadableStreamDefaultReader: {
56
- new <R = any>(stream: ReadableStream<R>): ReadableStreamDefaultReader<R>;
57
- prototype: ReadableStreamDefaultReader;
58
- };
59
- ReadableStreamBYOBReader: any;
60
- WritableStreamDefaultWriter: {
61
- new <W = any>(stream: WritableStream<W>): WritableStreamDefaultWriter<W>;
62
- prototype: WritableStreamDefaultWriter;
63
- };
64
- ByteLengthQueuingStrategy: {
65
- new (init: QueuingStrategyInit): ByteLengthQueuingStrategy;
66
- prototype: ByteLengthQueuingStrategy;
67
- };
68
- CountQueuingStrategy: {
69
- new (init: QueuingStrategyInit): CountQueuingStrategy;
70
- prototype: CountQueuingStrategy;
71
- };
72
- };
73
- export default _default;
74
- //# sourceMappingURL=stream-web.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"stream-web.d.ts","sourceRoot":"","sources":["../../src/polyfills/stream-web.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,eAAO,MAAM,cAAc;;qBAmBq43oC,CAAC;;;;;CAnB123oC,CAAC;AACxD,eAAO,MAAM,cAAc;;;CAA4B,CAAC;AACxD,eAAO,MAAM,eAAe;;;CAA6B,CAAC;AAC1D,eAAO,MAAM,2BAA2B;;;CAAyC,CAAC;AAClF,eAAO,MAAM,wBAAwB,KAA+C,CAAC;AACrF,eAAO,MAAM,2BAA2B;;;CAAyC,CAAC;AAClF,eAAO,MAAM,yBAAyB;;;CAAuC,CAAC;AAC9E,eAAO,MAAM,oBAAoB;;;CAAkC,CAAC;;;;yBAY413oC,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAVj63oC,wBASE"}
@@ -1,23 +0,0 @@
1
- /**
2
- * stream/web polyfill for WASI environment
3
- * Exports the native Web Streams API which is built into StarlingMonkey
4
- */
5
- export const ReadableStream = globalThis.ReadableStream;
6
- export const WritableStream = globalThis.WritableStream;
7
- export const TransformStream = globalThis.TransformStream;
8
- export const ReadableStreamDefaultReader = globalThis.ReadableStreamDefaultReader;
9
- export const ReadableStreamBYOBReader = globalThis.ReadableStreamBYOBReader;
10
- export const WritableStreamDefaultWriter = globalThis.WritableStreamDefaultWriter;
11
- export const ByteLengthQueuingStrategy = globalThis.ByteLengthQueuingStrategy;
12
- export const CountQueuingStrategy = globalThis.CountQueuingStrategy;
13
- export default {
14
- ReadableStream,
15
- WritableStream,
16
- TransformStream,
17
- ReadableStreamDefaultReader,
18
- ReadableStreamBYOBReader,
19
- WritableStreamDefaultWriter,
20
- ByteLengthQueuingStrategy,
21
- CountQueuingStrategy,
22
- };
23
- //# sourceMappingURL=stream-web.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"stream-web.js","sourceRoot":"","sources":["../../src/polyfills/stream-web.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,MAAM,CAAC,MAAM,cAAc,GAAG,UAAU,CAAC,cAAc,CAAC;AACxD,MAAM,CAAC,MAAM,cAAc,GAAG,UAAU,CAAC,cAAc,CAAC;AACxD,MAAM,CAAC,MAAM,eAAe,GAAG,UAAU,CAAC,eAAe,CAAC;AAC1D,MAAM,CAAC,MAAM,2BAA2B,GAAG,UAAU,CAAC,2BAA2B,CAAC;AAClF,MAAM,CAAC,MAAM,wBAAwB,GAAI,UAAkB,CAAC,wBAAwB,CAAC;AACrF,MAAM,CAAC,MAAM,2BAA2B,GAAG,UAAU,CAAC,2BAA2B,CAAC;AAClF,MAAM,CAAC,MAAM,yBAAyB,GAAG,UAAU,CAAC,yBAAyB,CAAC;AAC9E,MAAM,CAAC,MAAM,oBAAoB,GAAG,UAAU,CAAC,oBAAoB,CAAC;AAEpE,eAAe;IACX,cAAc;IACd,cAAc;IACd,eAAe;IACf,2BAA2B;IAC3B,wBAAwB;IACxB,2BAA2B;IAC3B,yBAAyB;IACzB,oBAAoB;CACvB,CAAC"}
@@ -1,16 +0,0 @@
1
- /**
2
- * Stream polyfill for WASI environment
3
- * Provides Node.js-compatible streams using the readable-stream package
4
- */
5
- export { Readable, Writable, Duplex, Transform, PassThrough, Stream, pipeline, finished, } from 'readable-stream';
6
- import { Readable, Writable, Duplex, Transform, PassThrough, Stream } from 'readable-stream';
7
- declare const stream: {
8
- Readable: typeof Readable;
9
- Writable: typeof Writable;
10
- Duplex: typeof Duplex;
11
- Transform: typeof Transform;
12
- PassThrough: typeof PassThrough;
13
- Stream: typeof Stream;
14
- };
15
- export default stream;
16
- //# sourceMappingURL=stream.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"stream.d.ts","sourceRoot":"","sources":["../../src/polyfills/stream.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EACH,QAAQ,EACR,QAAQ,EACR,MAAM,EACN,SAAS,EACT,WAAW,EACX,MAAM,EACN,QAAQ,EACR,QAAQ,GACX,MAAM,iBAAiB,CAAC;AAEzB,OAAO,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,EAAE,SAAS,EAAE,WAAW,EAAE,MAAM,EAAE,MAAM,iBAAiB,CAAC;AAE7F,QAAA,MAAM,MAAM;;;;;;;CAOX,CAAC;AAEF,eAAe,MAAM,CAAC"}
@@ -1,16 +0,0 @@
1
- /**
2
- * Stream polyfill for WASI environment
3
- * Provides Node.js-compatible streams using the readable-stream package
4
- */
5
- export { Readable, Writable, Duplex, Transform, PassThrough, Stream, pipeline, finished, } from 'readable-stream';
6
- import { Readable, Writable, Duplex, Transform, PassThrough, Stream } from 'readable-stream';
7
- const stream = {
8
- Readable,
9
- Writable,
10
- Duplex,
11
- Transform,
12
- PassThrough,
13
- Stream,
14
- };
15
- export default stream;
16
- //# sourceMappingURL=stream.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"stream.js","sourceRoot":"","sources":["../../src/polyfills/stream.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EACH,QAAQ,EACR,QAAQ,EACR,MAAM,EACN,SAAS,EACT,WAAW,EACX,MAAM,EACN,QAAQ,EACR,QAAQ,GACX,MAAM,iBAAiB,CAAC;AAEzB,OAAO,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,EAAE,SAAS,EAAE,WAAW,EAAE,MAAM,EAAE,MAAM,iBAAiB,CAAC;AAE7F,MAAM,MAAM,GAAG;IACX,QAAQ;IACR,QAAQ;IACR,MAAM;IACN,SAAS;IACT,WAAW;IACX,MAAM;CACT,CAAC;AAEF,eAAe,MAAM,CAAC"}
@@ -1,47 +0,0 @@
1
- /**
2
- * URL polyfill for WASI environment
3
- * Aliases Node.js 'url' module to native Web URL APIs
4
- */
5
- export declare const URL: {
6
- new (url: string | URL, base?: string | URL): URL;
7
- prototype: URL;
8
- canParse(url: string | URL, base?: string | URL): boolean;
9
- createObjectURL(obj: Blob | MediaSource): string;
10
- parse(url: string | URL, base?: string | URL): URL | null;
11
- revokeObjectURL(url: string): void;
12
- };
13
- export declare const URLSearchParams: {
14
- new (init?: string[][] | Record<string, string> | string | URLSearchParams): URLSearchParams;
15
- prototype: URLSearchParams;
16
- };
17
- /**
18
- * Legacy Node.js url.parse()
19
- */
20
- export declare function parse(urlString: string, parseQueryString?: boolean): any;
21
- /**
22
- * Legacy Node.js url.format()
23
- */
24
- export declare function format(urlObject: any): string;
25
- /**
26
- * Legacy Node.js url.resolve()
27
- */
28
- export declare function resolve(from: string, to: string): string;
29
- declare const url: {
30
- URL: {
31
- new (url: string | URL, base?: string | URL): URL;
32
- prototype: URL;
33
- canParse(url: string | URL, base?: string | URL): boolean;
34
- createObjectURL(obj: Blob | MediaSource): string;
35
- parse(url: string | URL, base?: string | URL): URL | null;
36
- revokeObjectURL(url: string): void;
37
- };
38
- URLSearchParams: {
39
- new (init?: string[][] | Record<string, string> | string | URLSearchParams): URLSearchParams;
40
- prototype: URLSearchParams;
41
- };
42
- parse: typeof parse;
43
- format: typeof format;
44
- resolve: typeof resolve;
45
- };
46
- export default url;
47
- //# sourceMappingURL=url.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"url.d.ts","sourceRoot":"","sources":["../../src/polyfills/url.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,eAAO,MAAM,GAAG;;;;;;;CAAiB,CAAC;AAElC,eAAO,MAAM,eAAe;;;CAA6B,CAAC;AAE1D;;GAEG;AACH,wBAAgB,KAAK,CAAC,SAAS,EAAE,MAAM,EAAE,gBAAgB,CAAC,EAAE,OAAO,GAAG,GAAG,CAiBxE;AAED;;GAEG;AACH,wBAAgB,MAAM,CAAC,SAAS,EAAE,GAAG,GAAG,MAAM,CAiB7C;AAED;;GAEG;AACH,wBAAgB,OAAO,CAAC,IAAI,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,GAAG,MAAM,CAMxD;AAED,QAAA,MAAM,GAAG;;;;;;;;;;;;;;;;CAMR,CAAC;AAEF,eAAe,GAAG,CAAC"}
@@ -1,68 +0,0 @@
1
- /**
2
- * URL polyfill for WASI environment
3
- * Aliases Node.js 'url' module to native Web URL APIs
4
- */
5
- export const URL = globalThis.URL;
6
- export const URLSearchParams = globalThis.URLSearchParams;
7
- /**
8
- * Legacy Node.js url.parse()
9
- */
10
- export function parse(urlString, parseQueryString) {
11
- try {
12
- const url = new URL(urlString);
13
- return {
14
- href: url.href,
15
- protocol: url.protocol,
16
- host: url.host,
17
- hostname: url.hostname,
18
- port: url.port,
19
- pathname: url.pathname,
20
- search: url.search,
21
- hash: url.hash,
22
- query: parseQueryString ? Object.fromEntries(url.searchParams) : url.search.slice(1),
23
- };
24
- }
25
- catch (e) {
26
- return null;
27
- }
28
- }
29
- /**
30
- * Legacy Node.js url.format()
31
- */
32
- export function format(urlObject) {
33
- if (typeof urlObject === 'string') {
34
- return urlObject;
35
- }
36
- try {
37
- const protocol = urlObject.protocol || 'http:';
38
- const hostname = urlObject.hostname || urlObject.host || 'localhost';
39
- const port = urlObject.port ? `:${urlObject.port}` : '';
40
- const pathname = urlObject.pathname || '/';
41
- const search = urlObject.search || '';
42
- const hash = urlObject.hash || '';
43
- return `${protocol}//${hostname}${port}${pathname}${search}${hash}`;
44
- }
45
- catch (e) {
46
- return '';
47
- }
48
- }
49
- /**
50
- * Legacy Node.js url.resolve()
51
- */
52
- export function resolve(from, to) {
53
- try {
54
- return new URL(to, from).href;
55
- }
56
- catch (e) {
57
- return to;
58
- }
59
- }
60
- const url = {
61
- URL,
62
- URLSearchParams,
63
- parse,
64
- format,
65
- resolve,
66
- };
67
- export default url;
68
- //# sourceMappingURL=url.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"url.js","sourceRoot":"","sources":["../../src/polyfills/url.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,MAAM,CAAC,MAAM,GAAG,GAAG,UAAU,CAAC,GAAG,CAAC;AAElC,MAAM,CAAC,MAAM,eAAe,GAAG,UAAU,CAAC,eAAe,CAAC;AAE1D;;GAEG;AACH,MAAM,UAAU,KAAK,CAAC,SAAiB,EAAE,gBAA0B;IAC/D,IAAI,CAAC;QACD,MAAM,GAAG,GAAG,IAAI,GAAG,CAAC,SAAS,CAAC,CAAC;QAC/B,OAAO;YACH,IAAI,EAAE,GAAG,CAAC,IAAI;YACd,QAAQ,EAAE,GAAG,CAAC,QAAQ;YACtB,IAAI,EAAE,GAAG,CAAC,IAAI;YACd,QAAQ,EAAE,GAAG,CAAC,QAAQ;YACtB,IAAI,EAAE,GAAG,CAAC,IAAI;YACd,QAAQ,EAAE,GAAG,CAAC,QAAQ;YACtB,MAAM,EAAE,GAAG,CAAC,MAAM;YAClB,IAAI,EAAE,GAAG,CAAC,IAAI;YACd,KAAK,EAAE,gBAAgB,CAAC,CAAC,CAAC,MAAM,CAAC,WAAW,CAAC,GAAG,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC;SACvF,CAAC;IACN,CAAC;IAAC,OAAO,CAAC,EAAE,CAAC;QACT,OAAO,IAAI,CAAC;IAChB,CAAC;AACL,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,MAAM,CAAC,SAAc;IACjC,IAAI,OAAO,SAAS,KAAK,QAAQ,EAAE,CAAC;QAChC,OAAO,SAAS,CAAC;IACrB,CAAC;IAED,IAAI,CAAC;QACD,MAAM,QAAQ,GAAG,SAAS,CAAC,QAAQ,IAAI,OAAO,CAAC;QAC/C,MAAM,QAAQ,GAAG,SAAS,CAAC,QAAQ,IAAI,SAAS,CAAC,IAAI,IAAI,WAAW,CAAC;QACrE,MAAM,IAAI,GAAG,SAAS,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,SAAS,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;QACxD,MAAM,QAAQ,GAAG,SAAS,CAAC,QAAQ,IAAI,GAAG,CAAC;QAC3C,MAAM,MAAM,GAAG,SAAS,CAAC,MAAM,IAAI,EAAE,CAAC;QACtC,MAAM,IAAI,GAAG,SAAS,CAAC,IAAI,IAAI,EAAE,CAAC;QAElC,OAAO,GAAG,QAAQ,KAAK,QAAQ,GAAG,IAAI,GAAG,QAAQ,GAAG,MAAM,GAAG,IAAI,EAAE,CAAC;IACxE,CAAC;IAAC,OAAO,CAAC,EAAE,CAAC;QACT,OAAO,EAAE,CAAC;IACd,CAAC;AACL,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,OAAO,CAAC,IAAY,EAAE,EAAU;IAC5C,IAAI,CAAC;QACD,OAAO,IAAI,GAAG,CAAC,EAAE,EAAE,IAAI,CAAC,CAAC,IAAI,CAAC;IAClC,CAAC;IAAC,OAAO,CAAC,EAAE,CAAC;QACT,OAAO,EAAE,CAAC;IACd,CAAC;AACL,CAAC;AAED,MAAM,GAAG,GAAG;IACR,GAAG;IACH,eAAe;IACf,KAAK;IACL,MAAM;IACN,OAAO;CACV,CAAC;AAEF,eAAe,GAAG,CAAC"}
@@ -1,11 +0,0 @@
1
- /**
2
- * Buffer polyfill for WASI environment
3
- * Provides Node.js-compatible Buffer class using the buffer package
4
- */
5
-
6
- import { Buffer as BufferPolyfill } from 'buffer';
7
-
8
- (globalThis as any).Buffer = BufferPolyfill;
9
-
10
- export const Buffer = BufferPolyfill;
11
- export default BufferPolyfill;
@@ -1,11 +0,0 @@
1
- /**
2
- * Events polyfill for WASI environment
3
- * Provides Node.js-compatible EventEmitter using the events package
4
- */
5
-
6
- import EventEmitter from 'events';
7
-
8
- (globalThis as any).EventEmitter = EventEmitter;
9
-
10
- export { EventEmitter };
11
- export default EventEmitter;
@@ -1,21 +0,0 @@
1
- /**
2
- * Path polyfill
3
- * Provides Node.js-compatible path object
4
- */
5
-
6
- import path from 'path-browserify';
7
-
8
- export default path;
9
- export const {
10
- resolve,
11
- join,
12
- dirname,
13
- basename,
14
- extname,
15
- format,
16
- parse,
17
- sep,
18
- delimiter,
19
- posix,
20
- win32
21
- } = path;