@capsule-run/sdk 0.4.2 → 0.5.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (66) hide show
  1. package/README.md +13 -24
  2. package/dist/index.d.ts +4 -2
  3. package/dist/index.d.ts.map +1 -1
  4. package/dist/index.js +4 -2
  5. package/dist/index.js.map +1 -1
  6. package/dist/polyfills/buffer.d.ts +8 -0
  7. package/dist/polyfills/buffer.d.ts.map +1 -0
  8. package/dist/polyfills/buffer.js +9 -0
  9. package/dist/polyfills/buffer.js.map +1 -0
  10. package/dist/polyfills/events.d.ts +8 -0
  11. package/dist/polyfills/events.d.ts.map +1 -0
  12. package/dist/polyfills/events.js +9 -0
  13. package/dist/polyfills/events.js.map +1 -0
  14. package/dist/polyfills/fs-promises.d.ts +7 -0
  15. package/dist/polyfills/fs-promises.d.ts.map +1 -0
  16. package/dist/polyfills/fs-promises.js +7 -0
  17. package/dist/polyfills/fs-promises.js.map +1 -0
  18. package/dist/polyfills/fs.d.ts +82 -0
  19. package/dist/polyfills/fs.d.ts.map +1 -0
  20. package/dist/{files.js → polyfills/fs.js} +100 -20
  21. package/dist/polyfills/fs.js.map +1 -0
  22. package/dist/polyfills/os.d.ts +150 -0
  23. package/dist/polyfills/os.d.ts.map +1 -0
  24. package/dist/polyfills/os.js +151 -0
  25. package/dist/polyfills/os.js.map +1 -0
  26. package/dist/polyfills/path.d.ts +8 -0
  27. package/dist/polyfills/path.d.ts.map +1 -0
  28. package/dist/polyfills/path.js +8 -0
  29. package/dist/polyfills/path.js.map +1 -0
  30. package/dist/polyfills/process.d.ts +109 -0
  31. package/dist/polyfills/process.d.ts.map +1 -0
  32. package/dist/polyfills/process.js +224 -0
  33. package/dist/polyfills/process.js.map +1 -0
  34. package/dist/polyfills/stream-web.d.ts +74 -0
  35. package/dist/polyfills/stream-web.d.ts.map +1 -0
  36. package/dist/polyfills/stream-web.js +23 -0
  37. package/dist/polyfills/stream-web.js.map +1 -0
  38. package/dist/polyfills/stream.d.ts +16 -0
  39. package/dist/polyfills/stream.d.ts.map +1 -0
  40. package/dist/polyfills/stream.js +16 -0
  41. package/dist/polyfills/stream.js.map +1 -0
  42. package/dist/polyfills/url.d.ts +47 -0
  43. package/dist/polyfills/url.d.ts.map +1 -0
  44. package/dist/polyfills/url.js +68 -0
  45. package/dist/polyfills/url.js.map +1 -0
  46. package/package.json +18 -1
  47. package/src/index.ts +4 -2
  48. package/src/polyfills/buffer.ts +11 -0
  49. package/src/polyfills/events.ts +11 -0
  50. package/src/polyfills/fs-promises.ts +7 -0
  51. package/src/polyfills/fs.ts +336 -0
  52. package/src/polyfills/os.ts +222 -0
  53. package/src/polyfills/path.ts +21 -0
  54. package/src/polyfills/process.ts +286 -0
  55. package/src/polyfills/stream-web.ts +24 -0
  56. package/src/polyfills/stream.ts +28 -0
  57. package/src/polyfills/url.ts +73 -0
  58. package/dist/env.d.ts +0 -22
  59. package/dist/env.d.ts.map +0 -1
  60. package/dist/env.js +0 -61
  61. package/dist/env.js.map +0 -1
  62. package/dist/files.d.ts +0 -46
  63. package/dist/files.d.ts.map +0 -1
  64. package/dist/files.js.map +0 -1
  65. package/src/env.ts +0 -67
  66. package/src/files.ts +0 -217
@@ -0,0 +1,151 @@
1
+ /**
2
+ * OS polyfill
3
+ * Provides Node.js-compatible os object
4
+ */
5
+ const os = {
6
+ /**
7
+ * Returns the operating system platform
8
+ * WASI is POSIX-like, so we return 'linux'
9
+ */
10
+ platform() {
11
+ return 'linux';
12
+ },
13
+ /**
14
+ * Returns the CPU architecture
15
+ * WASM runs on wasm32 architecture
16
+ */
17
+ arch() {
18
+ return 'wasm32';
19
+ },
20
+ /**
21
+ * Returns the operating system's default directory for temporary files
22
+ */
23
+ tmpdir() {
24
+ return '/tmp';
25
+ },
26
+ /**
27
+ * Returns the home directory of the current user
28
+ */
29
+ homedir() {
30
+ return '/home/capsule';
31
+ },
32
+ /**
33
+ * Returns the system uptime in seconds
34
+ * Not available in WASI, returns 0
35
+ */
36
+ uptime() {
37
+ return 0;
38
+ },
39
+ /**
40
+ * Returns the amount of free system memory in bytes
41
+ * Not available in WASI, returns 0
42
+ */
43
+ freemem() {
44
+ return 0;
45
+ },
46
+ /**
47
+ * Returns the total amount of system memory in bytes
48
+ * Not available in WASI, returns 0
49
+ */
50
+ totalmem() {
51
+ return 0;
52
+ },
53
+ /**
54
+ * Returns an array of objects containing information about each CPU/core
55
+ * Not available in WASI, returns empty array
56
+ */
57
+ cpus() {
58
+ return [];
59
+ },
60
+ /**
61
+ * Returns the hostname of the operating system
62
+ */
63
+ hostname() {
64
+ return 'capsule-wasm';
65
+ },
66
+ /**
67
+ * Returns the operating system release
68
+ */
69
+ release() {
70
+ return 'wasi';
71
+ },
72
+ /**
73
+ * Returns the operating system type
74
+ */
75
+ type() {
76
+ return 'WASI';
77
+ },
78
+ /**
79
+ * Returns the endianness of the CPU
80
+ * WASM is little-endian
81
+ */
82
+ endianness() {
83
+ return 'LE';
84
+ },
85
+ /**
86
+ * Returns an object containing network interfaces
87
+ * Not available in WASI, returns empty object
88
+ */
89
+ networkInterfaces() {
90
+ return {};
91
+ },
92
+ /**
93
+ * Returns the operating system's default directory for user data
94
+ */
95
+ userInfo(options) {
96
+ return {
97
+ username: 'capsule',
98
+ uid: 1000,
99
+ gid: 1000,
100
+ shell: null,
101
+ homedir: '/home/capsule',
102
+ };
103
+ },
104
+ /**
105
+ * Returns an array of objects containing information about the load average
106
+ * Not available in WASI, returns [0, 0, 0]
107
+ */
108
+ loadavg() {
109
+ return [0, 0, 0];
110
+ },
111
+ /**
112
+ * Returns the operating system's version
113
+ */
114
+ version() {
115
+ return 'WASI 0.2';
116
+ },
117
+ /**
118
+ * Returns the machine type
119
+ */
120
+ machine() {
121
+ return 'wasm32';
122
+ },
123
+ /**
124
+ * Platform-specific path segment separator
125
+ */
126
+ get EOL() {
127
+ return '\n';
128
+ },
129
+ /**
130
+ * Platform-specific constants
131
+ */
132
+ constants: {
133
+ signals: {},
134
+ errno: {},
135
+ priority: {},
136
+ },
137
+ /**
138
+ * Returns the number of logical CPU cores
139
+ * Not available in WASI, returns 1
140
+ */
141
+ availableParallelism() {
142
+ return 1;
143
+ },
144
+ /**
145
+ * Returns the string path of the current user's home directory
146
+ */
147
+ devNull: '/dev/null',
148
+ };
149
+ export default os;
150
+ export const { platform, arch, tmpdir, homedir, uptime, freemem, totalmem, cpus, hostname, release, type, endianness, networkInterfaces, userInfo, loadavg, version, machine, EOL, constants, availableParallelism, devNull, } = os;
151
+ //# sourceMappingURL=os.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"os.js","sourceRoot":"","sources":["../../src/polyfills/os.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAuBH,MAAM,EAAE,GAAG;IACP;;;OAGG;IACH,QAAQ;QACJ,OAAO,OAAO,CAAC;IACnB,CAAC;IAED;;;OAGG;IACH,IAAI;QACA,OAAO,QAAQ,CAAC;IACpB,CAAC;IAED;;OAEG;IACH,MAAM;QACF,OAAO,MAAM,CAAC;IAClB,CAAC;IAED;;OAEG;IACH,OAAO;QACH,OAAO,eAAe,CAAC;IAC3B,CAAC;IAED;;;OAGG;IACH,MAAM;QACF,OAAO,CAAC,CAAC;IACb,CAAC;IAED;;;OAGG;IACH,OAAO;QACH,OAAO,CAAC,CAAC;IACb,CAAC;IAED;;;OAGG;IACH,QAAQ;QACJ,OAAO,CAAC,CAAC;IACb,CAAC;IAED;;;OAGG;IACH,IAAI;QACA,OAAO,EAAE,CAAC;IACd,CAAC;IAED;;OAEG;IACH,QAAQ;QACJ,OAAO,cAAc,CAAC;IAC1B,CAAC;IAED;;OAEG;IACH,OAAO;QACH,OAAO,MAAM,CAAC;IAClB,CAAC;IAED;;OAEG;IACH,IAAI;QACA,OAAO,MAAM,CAAC;IAClB,CAAC;IAED;;;OAGG;IACH,UAAU;QACN,OAAO,IAAI,CAAC;IAChB,CAAC;IAED;;;OAGG;IACH,iBAAiB;QACb,OAAO,EAAE,CAAC;IACd,CAAC;IAED;;OAEG;IACH,QAAQ,CAAC,OAAgC;QAOrC,OAAO;YACH,QAAQ,EAAE,SAAS;YACnB,GAAG,EAAE,IAAI;YACT,GAAG,EAAE,IAAI;YACT,KAAK,EAAE,IAAI;YACX,OAAO,EAAE,eAAe;SAC3B,CAAC;IACN,CAAC;IAED;;;OAGG;IACH,OAAO;QACH,OAAO,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC;IACrB,CAAC;IAED;;OAEG;IACH,OAAO;QACH,OAAO,UAAU,CAAC;IACtB,CAAC;IAED;;OAEG;IACH,OAAO;QACH,OAAO,QAAQ,CAAC;IACpB,CAAC;IAED;;OAEG;IACH,IAAI,GAAG;QACH,OAAO,IAAI,CAAC;IAChB,CAAC;IAED;;OAEG;IACH,SAAS,EAAE;QACP,OAAO,EAAE,EAAE;QACX,KAAK,EAAE,EAAE;QACT,QAAQ,EAAE,EAAE;KACf;IAED;;;OAGG;IACH,oBAAoB;QAChB,OAAO,CAAC,CAAC;IACb,CAAC;IAED;;OAEG;IACH,OAAO,EAAE,WAAW;CACvB,CAAC;AAEF,eAAe,EAAE,CAAC;AAElB,MAAM,CAAC,MAAM,EACT,QAAQ,EACR,IAAI,EACJ,MAAM,EACN,OAAO,EACP,MAAM,EACN,OAAO,EACP,QAAQ,EACR,IAAI,EACJ,QAAQ,EACR,OAAO,EACP,IAAI,EACJ,UAAU,EACV,iBAAiB,EACjB,QAAQ,EACR,OAAO,EACP,OAAO,EACP,OAAO,EACP,GAAG,EACH,SAAS,EACT,oBAAoB,EACpB,OAAO,GACV,GAAG,EAAE,CAAC"}
@@ -0,0 +1,8 @@
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
@@ -0,0 +1 @@
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"}
@@ -0,0 +1,8 @@
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
@@ -0,0 +1 @@
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"}
@@ -0,0 +1,109 @@
1
+ /**
2
+ * Process polyfill for WASI environment
3
+ * Provides Node.js-compatible process object with WASI-backed values
4
+ */
5
+ declare const process: {
6
+ /**
7
+ * Environment variables
8
+ */
9
+ readonly env: Record<string, string>;
10
+ /**
11
+ * Command-line arguments
12
+ */
13
+ readonly argv: string[];
14
+ /**
15
+ * Returns the current working directory
16
+ */
17
+ cwd(): string;
18
+ /**
19
+ * Change directory (not supported in WASI)
20
+ */
21
+ chdir(directory: string): void;
22
+ /**
23
+ * Platform identifier
24
+ */
25
+ readonly platform: "linux";
26
+ /**
27
+ * Architecture identifier
28
+ */
29
+ readonly arch: "wasm32";
30
+ /**
31
+ * Process ID (not available in WASI)
32
+ */
33
+ readonly pid: number;
34
+ /**
35
+ * Parent process ID (not available in WASI)
36
+ */
37
+ readonly ppid: number;
38
+ /**
39
+ * Process uptime in seconds
40
+ */
41
+ uptime(): number;
42
+ /**
43
+ * Node.js version (WASI doesn't have Node.js)
44
+ */
45
+ readonly version: string;
46
+ /**
47
+ * Node.js versions object
48
+ */
49
+ readonly versions: Record<string, string>;
50
+ /**
51
+ * Exit the process (not fully supported in WASI)
52
+ */
53
+ exit(code?: number): never;
54
+ /**
55
+ * Abort the process
56
+ */
57
+ abort(): never;
58
+ /**
59
+ * Queue a microtask (uses native queueMicrotask)
60
+ */
61
+ nextTick(callback: (...args: any[]) => void, ...args: any[]): void;
62
+ /**
63
+ * Standard streams (not fully implemented)
64
+ */
65
+ readonly stdout: any;
66
+ readonly stderr: any;
67
+ readonly stdin: any;
68
+ /**
69
+ * Memory usage (not available in WASI)
70
+ */
71
+ memoryUsage(): {
72
+ rss: number;
73
+ heapTotal: number;
74
+ heapUsed: number;
75
+ external: number;
76
+ arrayBuffers: number;
77
+ };
78
+ /**
79
+ * CPU usage (not available in WASI)
80
+ */
81
+ cpuUsage(previousValue?: {
82
+ user: number;
83
+ system: number;
84
+ }): {
85
+ user: number;
86
+ system: number;
87
+ };
88
+ /**
89
+ * High-resolution time
90
+ */
91
+ hrtime: {
92
+ bigint(): bigint;
93
+ };
94
+ /**
95
+ * Execute path
96
+ */
97
+ readonly execPath: string;
98
+ /**
99
+ * Execution arguments
100
+ */
101
+ readonly execArgv: string[];
102
+ /**
103
+ * Title (not settable in WASI)
104
+ */
105
+ readonly title: string;
106
+ };
107
+ export default process;
108
+ export declare const env: Record<string, string>, argv: string[], cwd: () => string, platform: "linux", arch: "wasm32", pid: number, ppid: number, version: string, versions: Record<string, string>, exit: (code?: number) => never, nextTick: (callback: (...args: any[]) => void, ...args: any[]) => void, stdout: any, stderr: any, stdin: any;
109
+ //# sourceMappingURL=process.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"process.d.ts","sourceRoot":"","sources":["../../src/polyfills/process.ts"],"names":[],"mappings":"AAAA;;;GAGG;AA2EH,QAAA,MAAM,OAAO;IACT;;OAEG;kBACQ,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC;IAIjC;;OAEG;mBACS,MAAM,EAAE;IAIpB;;OAEG;WACI,MAAM;IAIb;;OAEG;qBACc,MAAM,GAAG,IAAI;IAI9B;;OAEG;uBACa,OAAO;IAIvB;;OAEG;mBACS,QAAQ;IAIpB;;OAEG;kBACQ,MAAM;IAIjB;;OAEG;mBACS,MAAM;IAIlB;;OAEG;cACO,MAAM;IAIhB;;OAEG;sBACY,MAAM;IAIrB;;OAEG;uBACa,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC;IAMtC;;OAEG;gBACS,MAAM,GAAG,KAAK;IAI1B;;OAEG;aACM,KAAK;IAId;;OAEG;uBACgB,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,IAAI,WAAW,GAAG,EAAE,GAAG,IAAI;IAIlE;;OAEG;qBACW,GAAG;qBAOH,GAAG;oBAOJ,GAAG;IAMhB;;OAEG;mBACY;QACX,GAAG,EAAE,MAAM,CAAC;QACZ,SAAS,EAAE,MAAM,CAAC;QAClB,QAAQ,EAAE,MAAM,CAAC;QACjB,QAAQ,EAAE,MAAM,CAAC;QACjB,YAAY,EAAE,MAAM,CAAC;KACxB;IAUD;;OAEG;6BACsB;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,MAAM,CAAA;KAAE,GAAG;QACxD,IAAI,EAAE,MAAM,CAAC;QACb,MAAM,EAAE,MAAM,CAAC;KAClB;IAOD;;OAEG;;kBAEW,MAAM;;IAKpB;;OAEG;uBACa,MAAM;IAItB;;OAEG;uBACa,MAAM,EAAE;IAIxB;;OAEG;oBACU,MAAM;CAItB,CAAC;AAEF,eAAe,OAAO,CAAC;AAEvB,eAAO,MACH,GAAG,0BACH,IAAI,YACJ,GAAG,QA/KI,MAAM,EAgLb,QAAQ,WACR,IAAI,YACJ,GAAG,UACH,IAAI,UACJ,OAAO,UACP,QAAQ,0BACR,IAAI,UArHQ,MAAM,KAAG,KAAK,EAsH1B,QAAQ,aAxGW,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,IAAI,WAAW,GAAG,EAAE,KAAG,IAAI,EAyGlE,MAAM,OACN,MAAM,OACN,KAAK,KACE,CAAC"}
@@ -0,0 +1,224 @@
1
+ /**
2
+ * Process polyfill for WASI environment
3
+ * Provides Node.js-compatible process object with WASI-backed values
4
+ */
5
+ /**
6
+ * Internal helper to safely get the WASI environment bindings.
7
+ */
8
+ function getEnvBindings() {
9
+ try {
10
+ const env = globalThis['wasi:cli/environment'];
11
+ if (env && typeof env.getEnvironment === 'function') {
12
+ return env;
13
+ }
14
+ }
15
+ catch { }
16
+ return null;
17
+ }
18
+ /**
19
+ * Lazy-loaded environment variables from WASI
20
+ */
21
+ function getEnv() {
22
+ const bindings = getEnvBindings();
23
+ if (!bindings) {
24
+ return {};
25
+ }
26
+ try {
27
+ const envPairs = bindings.getEnvironment();
28
+ return Object.fromEntries(envPairs);
29
+ }
30
+ catch (e) {
31
+ console.error("Failed to fetch environment variables:", e);
32
+ return {};
33
+ }
34
+ }
35
+ /**
36
+ * Lazy-loaded command-line arguments from WASI
37
+ */
38
+ function getArgv() {
39
+ const bindings = getEnvBindings();
40
+ if (!bindings || typeof bindings.getArguments !== 'function') {
41
+ return ['capsule'];
42
+ }
43
+ try {
44
+ return bindings.getArguments();
45
+ }
46
+ catch {
47
+ return ['capsule'];
48
+ }
49
+ }
50
+ /**
51
+ * Get current working directory from WASI
52
+ */
53
+ function getCwd() {
54
+ const bindings = getEnvBindings();
55
+ if (!bindings || typeof bindings.initialCwd !== 'function') {
56
+ return '/';
57
+ }
58
+ try {
59
+ const cwd = bindings.initialCwd();
60
+ return cwd || '/';
61
+ }
62
+ catch {
63
+ return '/';
64
+ }
65
+ }
66
+ const process = {
67
+ /**
68
+ * Environment variables
69
+ */
70
+ get env() {
71
+ return getEnv();
72
+ },
73
+ /**
74
+ * Command-line arguments
75
+ */
76
+ get argv() {
77
+ return getArgv();
78
+ },
79
+ /**
80
+ * Returns the current working directory
81
+ */
82
+ cwd() {
83
+ return getCwd();
84
+ },
85
+ /**
86
+ * Change directory (not supported in WASI)
87
+ */
88
+ chdir(directory) {
89
+ throw new Error('process.chdir() is not supported in WASI environment');
90
+ },
91
+ /**
92
+ * Platform identifier
93
+ */
94
+ get platform() {
95
+ return 'linux';
96
+ },
97
+ /**
98
+ * Architecture identifier
99
+ */
100
+ get arch() {
101
+ return 'wasm32';
102
+ },
103
+ /**
104
+ * Process ID (not available in WASI)
105
+ */
106
+ get pid() {
107
+ return 1;
108
+ },
109
+ /**
110
+ * Parent process ID (not available in WASI)
111
+ */
112
+ get ppid() {
113
+ return 0;
114
+ },
115
+ /**
116
+ * Process uptime in seconds
117
+ */
118
+ uptime() {
119
+ return 0;
120
+ },
121
+ /**
122
+ * Node.js version (WASI doesn't have Node.js)
123
+ */
124
+ get version() {
125
+ return 'v0.0.0-wasi';
126
+ },
127
+ /**
128
+ * Node.js versions object
129
+ */
130
+ get versions() {
131
+ return {
132
+ wasi: '0.2.0',
133
+ };
134
+ },
135
+ /**
136
+ * Exit the process (not fully supported in WASI)
137
+ */
138
+ exit(code) {
139
+ throw new Error(`Process exit requested with code ${code ?? 0}`);
140
+ },
141
+ /**
142
+ * Abort the process
143
+ */
144
+ abort() {
145
+ throw new Error('Process aborted');
146
+ },
147
+ /**
148
+ * Queue a microtask (uses native queueMicrotask)
149
+ */
150
+ nextTick(callback, ...args) {
151
+ queueMicrotask(() => callback(...args));
152
+ },
153
+ /**
154
+ * Standard streams (not fully implemented)
155
+ */
156
+ get stdout() {
157
+ return {
158
+ write: (data) => console.log(data),
159
+ isTTY: false,
160
+ };
161
+ },
162
+ get stderr() {
163
+ return {
164
+ write: (data) => console.error(data),
165
+ isTTY: false,
166
+ };
167
+ },
168
+ get stdin() {
169
+ return {
170
+ isTTY: false,
171
+ };
172
+ },
173
+ /**
174
+ * Memory usage (not available in WASI)
175
+ */
176
+ memoryUsage() {
177
+ return {
178
+ rss: 0,
179
+ heapTotal: 0,
180
+ heapUsed: 0,
181
+ external: 0,
182
+ arrayBuffers: 0,
183
+ };
184
+ },
185
+ /**
186
+ * CPU usage (not available in WASI)
187
+ */
188
+ cpuUsage(previousValue) {
189
+ return {
190
+ user: 0,
191
+ system: 0,
192
+ };
193
+ },
194
+ /**
195
+ * High-resolution time
196
+ */
197
+ hrtime: {
198
+ bigint() {
199
+ return BigInt(Date.now() * 1000000);
200
+ },
201
+ },
202
+ /**
203
+ * Execute path
204
+ */
205
+ get execPath() {
206
+ return '/usr/bin/capsule';
207
+ },
208
+ /**
209
+ * Execution arguments
210
+ */
211
+ get execArgv() {
212
+ return [];
213
+ },
214
+ /**
215
+ * Title (not settable in WASI)
216
+ */
217
+ get title() {
218
+ return 'capsule';
219
+ },
220
+ };
221
+ export default process;
222
+ export const { env, argv, cwd, platform, arch, pid, ppid, version, versions, exit, nextTick, stdout, stderr, stdin, } = process;
223
+ globalThis.process = process;
224
+ //# sourceMappingURL=process.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"process.js","sourceRoot":"","sources":["../../src/polyfills/process.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAUH;;GAEG;AACH,SAAS,cAAc;IACnB,IAAI,CAAC;QACD,MAAM,GAAG,GAAG,UAAU,CAAC,sBAAsB,CAAC,CAAC;QAE/C,IAAI,GAAG,IAAI,OAAO,GAAG,CAAC,cAAc,KAAK,UAAU,EAAE,CAAC;YAClD,OAAO,GAAG,CAAC;QACf,CAAC;IACL,CAAC;IAAC,MAAM,CAAC,CAAA,CAAC;I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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
@@ -0,0 +1 @@
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"}
@@ -0,0 +1,23 @@
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
@@ -0,0 +1 @@
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"}
@@ -0,0 +1,16 @@
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
@@ -0,0 +1 @@
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"}
@@ -0,0 +1,16 @@
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
@@ -0,0 +1 @@
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"}