@capsule-run/sdk 0.7.2 → 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.
- package/README.md +5 -1
- package/dist/app.d.ts +7 -0
- package/dist/app.d.ts.map +1 -1
- package/dist/app.js +7 -0
- package/dist/app.js.map +1 -1
- package/dist/index.d.ts +1 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -2
- package/dist/index.js.map +1 -1
- package/dist/polyfills/fs.d.ts +94 -11
- package/dist/polyfills/fs.d.ts.map +1 -1
- package/dist/polyfills/fs.js +289 -10
- package/dist/polyfills/fs.js.map +1 -1
- package/dist/polyfills/process.d.ts +7 -2
- package/dist/polyfills/process.d.ts.map +1 -1
- package/dist/polyfills/process.js +78 -6
- package/dist/polyfills/process.js.map +1 -1
- package/dist/run.d.ts +3 -0
- package/dist/run.d.ts.map +1 -1
- package/dist/run.js.map +1 -1
- package/dist/task.d.ts +11 -2
- package/dist/task.d.ts.map +1 -1
- package/dist/task.js +6 -3
- package/dist/task.js.map +1 -1
- package/package.json +4 -10
- package/src/app.ts +8 -0
- package/src/index.ts +1 -2
- package/src/polyfills/fs.ts +317 -11
- package/src/polyfills/process.ts +80 -6
- package/src/run.ts +3 -0
- package/src/task.ts +32 -14
- package/dist/polyfills/buffer.d.ts +0 -8
- package/dist/polyfills/buffer.d.ts.map +0 -1
- package/dist/polyfills/buffer.js +0 -9
- package/dist/polyfills/buffer.js.map +0 -1
- package/dist/polyfills/events.d.ts +0 -8
- package/dist/polyfills/events.d.ts.map +0 -1
- package/dist/polyfills/events.js +0 -9
- package/dist/polyfills/events.js.map +0 -1
- package/dist/polyfills/path.d.ts +0 -8
- package/dist/polyfills/path.d.ts.map +0 -1
- package/dist/polyfills/path.js +0 -8
- package/dist/polyfills/path.js.map +0 -1
- package/dist/polyfills/stream-web.d.ts +0 -74
- package/dist/polyfills/stream-web.d.ts.map +0 -1
- package/dist/polyfills/stream-web.js +0 -23
- package/dist/polyfills/stream-web.js.map +0 -1
- package/dist/polyfills/stream.d.ts +0 -16
- package/dist/polyfills/stream.d.ts.map +0 -1
- package/dist/polyfills/stream.js +0 -16
- package/dist/polyfills/stream.js.map +0 -1
- package/dist/polyfills/url.d.ts +0 -47
- package/dist/polyfills/url.d.ts.map +0 -1
- package/dist/polyfills/url.js +0 -68
- package/dist/polyfills/url.js.map +0 -1
- package/src/polyfills/buffer.ts +0 -11
- package/src/polyfills/events.ts +0 -11
- package/src/polyfills/path.ts +0 -21
- package/src/polyfills/stream-web.ts +0 -24
- package/src/polyfills/stream.ts +0 -28
- package/src/polyfills/url.ts +0 -73
package/README.md
CHANGED
|
@@ -147,7 +147,9 @@ Every task returns a structured JSON envelope containing both the result and exe
|
|
|
147
147
|
"task_name": "data_processor",
|
|
148
148
|
"duration_ms": 1523,
|
|
149
149
|
"retries": 0,
|
|
150
|
-
"fuel_consumed": 45000
|
|
150
|
+
"fuel_consumed": 45000,
|
|
151
|
+
"ram_used": 1200000,
|
|
152
|
+
"host_requests": [{...}]
|
|
151
153
|
}
|
|
152
154
|
}
|
|
153
155
|
```
|
|
@@ -161,6 +163,8 @@ Every task returns a structured JSON envelope containing both the result and exe
|
|
|
161
163
|
- `duration_ms` — Execution time in milliseconds
|
|
162
164
|
- `retries` — Number of retry attempts that occurred
|
|
163
165
|
- `fuel_consumed` — CPU resources used (see [Compute Levels](#compute-levels))
|
|
166
|
+
- `ram_used` — Peak memory used in bytes
|
|
167
|
+
- `host_requests` — List of host requests made by the task
|
|
164
168
|
|
|
165
169
|
## Documentation
|
|
166
170
|
|
package/dist/app.d.ts
CHANGED
|
@@ -45,4 +45,11 @@ export declare class TaskRunner {
|
|
|
45
45
|
run(argsJson: string): Promise<string>;
|
|
46
46
|
}
|
|
47
47
|
export declare const exports: TaskRunner;
|
|
48
|
+
/**
|
|
49
|
+
* Implementation of wasi:http/incoming-handler@0.2.0.
|
|
50
|
+
* Required for some edge use cases.
|
|
51
|
+
*/
|
|
52
|
+
export declare const incomingHandler: {
|
|
53
|
+
handle(_req: unknown, _responseOut: unknown): void;
|
|
54
|
+
};
|
|
48
55
|
//# sourceMappingURL=app.d.ts.map
|
package/dist/app.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"app.d.ts","sourceRoot":"","sources":["../src/app.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,MAAM,WAAW,QAAQ,CAAC,CAAC,SAAS,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,GAAG;IACzD,IAAI,EAAE,CAAC,CAAC;IACR,MAAM,EAAE,UAAU,CAAC;CACpB;AAED,MAAM,WAAW,UAAU;IACzB,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,YAAY,CAAC,EAAE,MAAM,EAAE,CAAC;IACxB,YAAY,CAAC,EAAE,MAAM,EAAE,CAAC;IACxB,YAAY,CAAC,EAAE,MAAM,EAAE,CAAC;CACzB;AAID;;GAEG;AACH,wBAAgB,YAAY,CAAC,CAAC,SAAS,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,GAAG,EAC5D,IAAI,EAAE,MAAM,EACZ,IAAI,EAAE,CAAC,EACP,MAAM,EAAE,UAAU,GACjB,IAAI,CAEN;AAED;;GAEG;AACH,wBAAgB,OAAO,CAAC,IAAI,EAAE,MAAM,GAAG,CAAC,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,GAAG,CAAC,GAAG,SAAS,CAE3E;AAED;;GAEG;AACH,wBAAgB,aAAa,CAAC,IAAI,EAAE,MAAM,GAAG,UAAU,GAAG,SAAS,CAElE;AAED;;GAEG;AACH,wBAAgB,YAAY,IAAI,MAAM,EAAE,CAEvC;AAQD;;;;;GAKG;AACH,qBAAa,UAAU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C,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;CAuC7C;AAED,eAAO,MAAM,OAAO,YAAmB,CAAC;AAExC;;;GAGG;AACH,eAAO,MAAM,eAAe;iBACb,OAAO,gBAAgB,OAAO,GAAG,IAAI;CACnD,CAAC"}
|
package/dist/app.js
CHANGED
|
@@ -72,4 +72,11 @@ export class TaskRunner {
|
|
|
72
72
|
}
|
|
73
73
|
}
|
|
74
74
|
export const exports = new TaskRunner();
|
|
75
|
+
/**
|
|
76
|
+
* Implementation of wasi:http/incoming-handler@0.2.0.
|
|
77
|
+
* Required for some edge use cases.
|
|
78
|
+
*/
|
|
79
|
+
export const incomingHandler = {
|
|
80
|
+
handle(_req, _responseOut) { },
|
|
81
|
+
};
|
|
75
82
|
//# sourceMappingURL=app.js.map
|
package/dist/app.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"app.js","sourceRoot":"","sources":["../src/app.ts"],"names":[],"mappings":"AAAA;;GAEG;AAkBH,MAAM,KAAK,GAA+B,IAAI,GAAG,EAAE,CAAC;AAEpD;;GAEG;AACH,MAAM,UAAU,YAAY,CAC1B,IAAY,EACZ,IAAO,EACP,MAAkB;IAElB,KAAK,CAAC,GAAG,CAAC,IAAI,EAAE,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC,CAAC;AACpC,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,OAAO,CAAC,IAAY;IAClC,OAAO,KAAK,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,IAAI,CAAC;AAC/B,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,aAAa,CAAC,IAAY;IACxC,OAAO,KAAK,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,MAAM,CAAC;AACjC,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,YAAY;IAC1B,OAAO,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,EAAE,CAAC,CAAC;AAClC,CAAC;AAQD;;;;;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,CAAC,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC;aACpD,CAAC,CAAC;QACL,CAAC;IACH,CAAC;CACF;AAED,MAAM,CAAC,MAAM,OAAO,GAAG,IAAI,UAAU,EAAE,CAAC;AAExC;;;GAGG;AACH,MAAM,CAAC,MAAM,eAAe,GAAG;IAC7B,MAAM,CAAC,IAAa,EAAE,YAAqB,IAAS,CAAC;CACtD,CAAC"}
|
package/dist/index.d.ts
CHANGED
|
@@ -15,9 +15,8 @@
|
|
|
15
15
|
*/
|
|
16
16
|
export { task, type TaskOptions } from "./task.js";
|
|
17
17
|
export { TaskRunner, exports, type TaskConfig } from "./app.js";
|
|
18
|
-
export { default as fs } from "./polyfills/fs.js";
|
|
18
|
+
export { default as fs, promises as fsPromises } from "./polyfills/fs.js";
|
|
19
19
|
export { isWasmMode } from "./hostApi.js";
|
|
20
|
-
export { default as path } from "./polyfills/path.js";
|
|
21
20
|
export { default as os } from "./polyfills/os.js";
|
|
22
21
|
export { default as process } from "./polyfills/process.js";
|
|
23
22
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,EAAE,IAAI,EAAE,KAAK,WAAW,EAAE,MAAM,WAAW,CAAC;AACnD,OAAO,EAAE,UAAU,EAAE,OAAO,EAAE,KAAK,UAAU,EAAE,MAAM,UAAU,CAAC;AAChE,OAAO,EAAE,OAAO,IAAI,EAAE,EAAE,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,EAAE,IAAI,EAAE,KAAK,WAAW,EAAE,MAAM,WAAW,CAAC;AACnD,OAAO,EAAE,UAAU,EAAE,OAAO,EAAE,KAAK,UAAU,EAAE,MAAM,UAAU,CAAC;AAChE,OAAO,EAAE,OAAO,IAAI,EAAE,EAAE,QAAQ,IAAI,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAC1E,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAC1C,OAAO,EAAE,OAAO,IAAI,EAAE,EAAE,MAAM,mBAAmB,CAAC;AAClD,OAAO,EAAE,OAAO,IAAI,OAAO,EAAE,MAAM,wBAAwB,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -15,9 +15,8 @@
|
|
|
15
15
|
*/
|
|
16
16
|
export { task } from "./task.js";
|
|
17
17
|
export { TaskRunner, exports } from "./app.js";
|
|
18
|
-
export { default as fs } from "./polyfills/fs.js";
|
|
18
|
+
export { default as fs, promises as fsPromises } from "./polyfills/fs.js";
|
|
19
19
|
export { isWasmMode } from "./hostApi.js";
|
|
20
|
-
export { default as path } from "./polyfills/path.js";
|
|
21
20
|
export { default as os } from "./polyfills/os.js";
|
|
22
21
|
export { default as process } from "./polyfills/process.js";
|
|
23
22
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,EAAE,IAAI,EAAoB,MAAM,WAAW,CAAC;AACnD,OAAO,EAAE,UAAU,EAAE,OAAO,EAAmB,MAAM,UAAU,CAAC;AAChE,OAAO,EAAE,OAAO,IAAI,EAAE,EAAE,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,EAAE,IAAI,EAAoB,MAAM,WAAW,CAAC;AACnD,OAAO,EAAE,UAAU,EAAE,OAAO,EAAmB,MAAM,UAAU,CAAC;AAChE,OAAO,EAAE,OAAO,IAAI,EAAE,EAAE,QAAQ,IAAI,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAC1E,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAC1C,OAAO,EAAE,OAAO,IAAI,EAAE,EAAE,MAAM,mBAAmB,CAAC;AAClD,OAAO,EAAE,OAAO,IAAI,OAAO,EAAE,MAAM,wBAAwB,CAAC"}
|
package/dist/polyfills/fs.d.ts
CHANGED
|
@@ -46,9 +46,85 @@ export declare function writeFile(path: string, data: string | Uint8Array, optio
|
|
|
46
46
|
*/
|
|
47
47
|
export declare function readdir(path: string, optionsOrCallback: any | ((err: Error | null, files?: string[]) => void), callback?: (err: Error | null, files?: string[]) => void): void;
|
|
48
48
|
/**
|
|
49
|
-
*
|
|
49
|
+
* Read file contents synchronously.
|
|
50
|
+
* Backed by wasi:filesystem/types@0.2.0 — fully synchronous.
|
|
50
51
|
*/
|
|
51
|
-
export declare function
|
|
52
|
+
export declare function readFileSync(path: string, options?: ReadFileOptions | Encoding): string | Uint8Array;
|
|
53
|
+
/**
|
|
54
|
+
* Write data to a file synchronously.
|
|
55
|
+
* Backed by wasi:filesystem/types@0.2.0 — fully synchronous.
|
|
56
|
+
*/
|
|
57
|
+
export declare function writeFileSync(path: string, data: string | Uint8Array, _options?: WriteFileOptions | Encoding): void;
|
|
58
|
+
/**
|
|
59
|
+
* Append data to a file synchronously, creating it if it doesn't exist.
|
|
60
|
+
* Backed by wasi:filesystem/types@0.2.0 — fully synchronous.
|
|
61
|
+
*/
|
|
62
|
+
export declare function appendFileSync(path: string, data: string | Uint8Array, _options?: WriteFileOptions | Encoding): void;
|
|
63
|
+
/**
|
|
64
|
+
* Read directory contents synchronously.
|
|
65
|
+
* Backed by wasi:filesystem/types@0.2.0 — fully synchronous.
|
|
66
|
+
*/
|
|
67
|
+
export declare function readdirSync(path: string, _options?: any): string[];
|
|
68
|
+
export interface StatResult {
|
|
69
|
+
isFile: () => boolean;
|
|
70
|
+
isDirectory: () => boolean;
|
|
71
|
+
isSymbolicLink: () => boolean;
|
|
72
|
+
size: number;
|
|
73
|
+
mtimeMs: number;
|
|
74
|
+
atimeMs: number;
|
|
75
|
+
ctimeMs: number;
|
|
76
|
+
mode: number;
|
|
77
|
+
}
|
|
78
|
+
/**
|
|
79
|
+
* Get file stats synchronously.
|
|
80
|
+
* Backed by wasi:filesystem/types@0.2.0 — fully synchronous.
|
|
81
|
+
*/
|
|
82
|
+
export declare function statSync(path: string): StatResult;
|
|
83
|
+
/**
|
|
84
|
+
* Get file stats synchronously (no symlink follow — same as stat in WASI 0.2).
|
|
85
|
+
*/
|
|
86
|
+
export declare function lstatSync(path: string): StatResult;
|
|
87
|
+
/**
|
|
88
|
+
* Create a directory synchronously.
|
|
89
|
+
* Backed by wasi:filesystem/types@0.2.0 — fully synchronous.
|
|
90
|
+
*/
|
|
91
|
+
export declare function mkdirSync(path: string, options?: MkdirOptions): void;
|
|
92
|
+
/**
|
|
93
|
+
* Remove a directory synchronously.
|
|
94
|
+
* Backed by wasi:filesystem/types@0.2.0 — fully synchronous.
|
|
95
|
+
*/
|
|
96
|
+
export declare function rmdirSync(path: string, _options?: RmdirOptions): void;
|
|
97
|
+
/**
|
|
98
|
+
* Remove a file or directory synchronously.
|
|
99
|
+
* Backed by wasi:filesystem/types@0.2.0 — fully synchronous.
|
|
100
|
+
*/
|
|
101
|
+
export declare function rmSync(path: string, options?: RmOptions): void;
|
|
102
|
+
/**
|
|
103
|
+
* Remove a file synchronously.
|
|
104
|
+
* Backed by wasi:filesystem/types@0.2.0 — fully synchronous.
|
|
105
|
+
*/
|
|
106
|
+
export declare function unlinkSync(path: string): void;
|
|
107
|
+
/**
|
|
108
|
+
* Copy a file synchronously.
|
|
109
|
+
* Backed by wasi:filesystem/types@0.2.0 — fully synchronous.
|
|
110
|
+
*/
|
|
111
|
+
export declare function copyFileSync(src: string, dest: string): void;
|
|
112
|
+
/**
|
|
113
|
+
* Rename a file or directory synchronously.
|
|
114
|
+
* Falls back to copy+delete since wasi:filesystem/types@0.2.0
|
|
115
|
+
* does not expose a rename/link-at in the current WIT binding.
|
|
116
|
+
*/
|
|
117
|
+
export declare function renameSync(oldPath: string, newPath: string): void;
|
|
118
|
+
/**
|
|
119
|
+
* Check file accessibility synchronously.
|
|
120
|
+
* Throws if the path does not exist.
|
|
121
|
+
*/
|
|
122
|
+
export declare function accessSync(path: string, _mode?: number): void;
|
|
123
|
+
/**
|
|
124
|
+
* Check if a path exists synchronously.
|
|
125
|
+
* Backed by wasi:filesystem/types@0.2.0 — fully synchronous.
|
|
126
|
+
*/
|
|
127
|
+
export declare function existsSync(path: string): boolean;
|
|
52
128
|
/**
|
|
53
129
|
* Delete a file.
|
|
54
130
|
*/
|
|
@@ -95,10 +171,7 @@ export declare const promises: {
|
|
|
95
171
|
readdir(path: string): Promise<string[]>;
|
|
96
172
|
access(path: string): Promise<void>;
|
|
97
173
|
unlink(path: string): Promise<void>;
|
|
98
|
-
stat(path: string): Promise<
|
|
99
|
-
isFile: () => boolean;
|
|
100
|
-
isDirectory: () => boolean;
|
|
101
|
-
}>;
|
|
174
|
+
stat(path: string): Promise<StatResult>;
|
|
102
175
|
rmdir(path: string, options?: RmdirOptions): Promise<void>;
|
|
103
176
|
rm(path: string, options?: RmOptions): Promise<void>;
|
|
104
177
|
mkdir(path: string, options?: MkdirOptions): Promise<void>;
|
|
@@ -109,23 +182,33 @@ declare const fs: {
|
|
|
109
182
|
readFile: typeof readFile;
|
|
110
183
|
writeFile: typeof writeFile;
|
|
111
184
|
readdir: typeof readdir;
|
|
112
|
-
existsSync: typeof existsSync;
|
|
113
185
|
unlink: typeof unlink;
|
|
114
186
|
rmdir: typeof rmdir;
|
|
115
187
|
rm: typeof rm;
|
|
116
188
|
mkdir: typeof mkdir;
|
|
117
189
|
copyFile: typeof copyFile;
|
|
118
190
|
cp: typeof cp;
|
|
191
|
+
readFileSync: typeof readFileSync;
|
|
192
|
+
writeFileSync: typeof writeFileSync;
|
|
193
|
+
appendFileSync: typeof appendFileSync;
|
|
194
|
+
readdirSync: typeof readdirSync;
|
|
195
|
+
statSync: typeof statSync;
|
|
196
|
+
lstatSync: typeof lstatSync;
|
|
197
|
+
mkdirSync: typeof mkdirSync;
|
|
198
|
+
rmdirSync: typeof rmdirSync;
|
|
199
|
+
rmSync: typeof rmSync;
|
|
200
|
+
unlinkSync: typeof unlinkSync;
|
|
201
|
+
copyFileSync: typeof copyFileSync;
|
|
202
|
+
renameSync: typeof renameSync;
|
|
203
|
+
accessSync: typeof accessSync;
|
|
204
|
+
existsSync: typeof existsSync;
|
|
119
205
|
promises: {
|
|
120
206
|
readFile(path: string, options?: ReadFileOptions | Encoding): Promise<string | Uint8Array>;
|
|
121
207
|
writeFile(path: string, data: string | Uint8Array): Promise<void>;
|
|
122
208
|
readdir(path: string): Promise<string[]>;
|
|
123
209
|
access(path: string): Promise<void>;
|
|
124
210
|
unlink(path: string): Promise<void>;
|
|
125
|
-
stat(path: string): Promise<
|
|
126
|
-
isFile: () => boolean;
|
|
127
|
-
isDirectory: () => boolean;
|
|
128
|
-
}>;
|
|
211
|
+
stat(path: string): Promise<StatResult>;
|
|
129
212
|
rmdir(path: string, options?: RmdirOptions): Promise<void>;
|
|
130
213
|
rm(path: string, options?: RmOptions): Promise<void>;
|
|
131
214
|
mkdir(path: string, options?: MkdirOptions): Promise<void>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fs.d.ts","sourceRoot":"","sources":["../../src/polyfills/fs.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAwGH;;GAEG;AACH,wBAAsB,QAAQ,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAG5D;AAED;;GAEG;AACH,wBAAsB,SAAS,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,UAAU,CAAC,CAkBjE;AAED;;GAEG;AACH,wBAAsB,SAAS,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,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OAAO,CAAC,IAAI,CAAC;oBAIxC,MAAM,YAAY,YAAY,GAAG,OAAO,CAAC,IAAI,CAAC;sBAI5C,MAAM,QAAQ,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;gBAI1C,MAAM,QAAQ,MAAM,YAAY,SAAS,GAAG,OAAO,CAAC,IAAI,CAAC;;CAgC1E,CAAC;AAEF,eAAe,EAAE,CAAC"}
|
package/dist/polyfills/fs.js
CHANGED
|
@@ -205,12 +205,279 @@ export function readdir(path, optionsOrCallback, callback) {
|
|
|
205
205
|
.then((files) => cb?.(null, files))
|
|
206
206
|
.catch((err) => cb?.(err instanceof Error ? err : new Error(String(err))));
|
|
207
207
|
}
|
|
208
|
+
// ---------------------------------------------------------------------------
|
|
209
|
+
// Sync implementations
|
|
210
|
+
// wasi:filesystem/types@0.2.0 descriptor methods (openAt, read, write, stat,
|
|
211
|
+
// readDirectory, etc.) are direct component-model imports — they are
|
|
212
|
+
// synchronous from JS's perspective. No asyncify, no event-loop blocking.
|
|
213
|
+
// ---------------------------------------------------------------------------
|
|
214
|
+
function enoent(path) {
|
|
215
|
+
return Object.assign(new Error(`ENOENT: no such file or directory, open '${path}'`), { code: 'ENOENT' });
|
|
216
|
+
}
|
|
217
|
+
/**
|
|
218
|
+
* Read file contents synchronously.
|
|
219
|
+
* Backed by wasi:filesystem/types@0.2.0 — fully synchronous.
|
|
220
|
+
*/
|
|
221
|
+
export function readFileSync(path, options) {
|
|
222
|
+
const resolved = resolvePath(path);
|
|
223
|
+
if (!resolved)
|
|
224
|
+
throw enoent(path);
|
|
225
|
+
try {
|
|
226
|
+
const fd = resolved.dir.openAt({ symlinkFollow: false }, resolved.relativePath, {}, { read: true });
|
|
227
|
+
const stat = fd.stat();
|
|
228
|
+
const [data] = fd.read(stat.size, BigInt(0));
|
|
229
|
+
const encoding = typeof options === 'string' ? options : options?.encoding;
|
|
230
|
+
return (encoding === 'utf8' || encoding === 'utf-8') ? new TextDecoder().decode(data) : data;
|
|
231
|
+
}
|
|
232
|
+
catch (e) {
|
|
233
|
+
if (e instanceof Error && e.code)
|
|
234
|
+
throw e;
|
|
235
|
+
throw Object.assign(new Error(`ENOENT: no such file or directory, open '${path}'`), { code: 'ENOENT' });
|
|
236
|
+
}
|
|
237
|
+
}
|
|
238
|
+
/**
|
|
239
|
+
* Write data to a file synchronously.
|
|
240
|
+
* Backed by wasi:filesystem/types@0.2.0 — fully synchronous.
|
|
241
|
+
*/
|
|
242
|
+
export function writeFileSync(path, data, _options) {
|
|
243
|
+
const resolved = resolvePath(path);
|
|
244
|
+
if (!resolved)
|
|
245
|
+
throw enoent(path);
|
|
246
|
+
const bytes = typeof data === 'string' ? new TextEncoder().encode(data) : data;
|
|
247
|
+
try {
|
|
248
|
+
const fd = resolved.dir.openAt({ symlinkFollow: false }, resolved.relativePath, { create: true, truncate: true }, { write: true, mutateDirectory: true });
|
|
249
|
+
fd.write(bytes, BigInt(0));
|
|
250
|
+
}
|
|
251
|
+
catch (e) {
|
|
252
|
+
throw new Error(`ENOENT: no such file or directory, open '${path}'`);
|
|
253
|
+
}
|
|
254
|
+
}
|
|
255
|
+
/**
|
|
256
|
+
* Append data to a file synchronously, creating it if it doesn't exist.
|
|
257
|
+
* Backed by wasi:filesystem/types@0.2.0 — fully synchronous.
|
|
258
|
+
*/
|
|
259
|
+
export function appendFileSync(path, data, _options) {
|
|
260
|
+
const resolved = resolvePath(path);
|
|
261
|
+
if (!resolved)
|
|
262
|
+
throw enoent(path);
|
|
263
|
+
const bytes = typeof data === 'string' ? new TextEncoder().encode(data) : data;
|
|
264
|
+
try {
|
|
265
|
+
const fd = resolved.dir.openAt({ symlinkFollow: false }, resolved.relativePath, { create: true }, { write: true, mutateDirectory: true });
|
|
266
|
+
const stat = fd.stat();
|
|
267
|
+
fd.write(bytes, stat.size);
|
|
268
|
+
}
|
|
269
|
+
catch (e) {
|
|
270
|
+
throw new Error(`Failed to append to file '${path}': ${e}`);
|
|
271
|
+
}
|
|
272
|
+
}
|
|
273
|
+
/**
|
|
274
|
+
* Read directory contents synchronously.
|
|
275
|
+
* Backed by wasi:filesystem/types@0.2.0 — fully synchronous.
|
|
276
|
+
*/
|
|
277
|
+
export function readdirSync(path, _options) {
|
|
278
|
+
const resolved = resolvePath(path);
|
|
279
|
+
if (!resolved)
|
|
280
|
+
throw enoent(path);
|
|
281
|
+
try {
|
|
282
|
+
let targetDir = resolved.dir;
|
|
283
|
+
if (resolved.relativePath !== '.') {
|
|
284
|
+
targetDir = resolved.dir.openAt({ symlinkFollow: false }, resolved.relativePath, { directory: true }, { read: true });
|
|
285
|
+
}
|
|
286
|
+
const stream = targetDir.readDirectory();
|
|
287
|
+
const entries = [];
|
|
288
|
+
let entry;
|
|
289
|
+
while ((entry = stream.readDirectoryEntry()) && entry) {
|
|
290
|
+
if (entry.name)
|
|
291
|
+
entries.push(entry.name);
|
|
292
|
+
}
|
|
293
|
+
return entries;
|
|
294
|
+
}
|
|
295
|
+
catch (e) {
|
|
296
|
+
throw Object.assign(new Error(`ENOENT: no such file or directory, scandir '${path}'`), { code: 'ENOENT' });
|
|
297
|
+
}
|
|
298
|
+
}
|
|
299
|
+
function makeStatResult(type, size = BigInt(0)) {
|
|
300
|
+
return {
|
|
301
|
+
isFile: () => type === 'file',
|
|
302
|
+
isDirectory: () => type === 'directory',
|
|
303
|
+
isSymbolicLink: () => false,
|
|
304
|
+
size: Number(size),
|
|
305
|
+
mtimeMs: 0,
|
|
306
|
+
atimeMs: 0,
|
|
307
|
+
ctimeMs: 0,
|
|
308
|
+
mode: type === 'directory' ? 0o40755 : 0o100644,
|
|
309
|
+
};
|
|
310
|
+
}
|
|
208
311
|
/**
|
|
209
|
-
*
|
|
312
|
+
* Get file stats synchronously.
|
|
313
|
+
* Backed by wasi:filesystem/types@0.2.0 — fully synchronous.
|
|
210
314
|
*/
|
|
211
|
-
export function
|
|
212
|
-
|
|
213
|
-
|
|
315
|
+
export function statSync(path) {
|
|
316
|
+
const resolved = resolvePath(path);
|
|
317
|
+
if (!resolved)
|
|
318
|
+
throw enoent(path);
|
|
319
|
+
try {
|
|
320
|
+
const fd = resolved.dir.openAt({ symlinkFollow: false }, resolved.relativePath, {}, { read: true });
|
|
321
|
+
const s = fd.stat();
|
|
322
|
+
const type = s.type === 'directory' ? 'directory' : 'file';
|
|
323
|
+
return makeStatResult(type, s.size);
|
|
324
|
+
}
|
|
325
|
+
catch (e) {
|
|
326
|
+
throw Object.assign(new Error(`ENOENT: no such file or directory, stat '${path}'`), { code: 'ENOENT' });
|
|
327
|
+
}
|
|
328
|
+
}
|
|
329
|
+
/**
|
|
330
|
+
* Get file stats synchronously (no symlink follow — same as stat in WASI 0.2).
|
|
331
|
+
*/
|
|
332
|
+
export function lstatSync(path) {
|
|
333
|
+
return statSync(path);
|
|
334
|
+
}
|
|
335
|
+
/**
|
|
336
|
+
* Create a directory synchronously.
|
|
337
|
+
* Backed by wasi:filesystem/types@0.2.0 — fully synchronous.
|
|
338
|
+
*/
|
|
339
|
+
export function mkdirSync(path, options) {
|
|
340
|
+
if (options?.recursive) {
|
|
341
|
+
const normalized = normalizePath(path);
|
|
342
|
+
const parts = normalized.split('/').filter(Boolean);
|
|
343
|
+
for (let i = 1; i <= parts.length; i++) {
|
|
344
|
+
const partial = parts.slice(0, i).join('/');
|
|
345
|
+
const resolved = resolvePath(partial);
|
|
346
|
+
if (!resolved)
|
|
347
|
+
continue;
|
|
348
|
+
try {
|
|
349
|
+
resolved.dir.createDirectoryAt(resolved.relativePath);
|
|
350
|
+
}
|
|
351
|
+
catch { /* already exists */ }
|
|
352
|
+
}
|
|
353
|
+
}
|
|
354
|
+
else {
|
|
355
|
+
const resolved = resolvePath(path);
|
|
356
|
+
if (!resolved)
|
|
357
|
+
throw enoent(path);
|
|
358
|
+
try {
|
|
359
|
+
resolved.dir.createDirectoryAt(resolved.relativePath);
|
|
360
|
+
}
|
|
361
|
+
catch (e) {
|
|
362
|
+
throw Object.assign(new Error(`EEXIST: file already exists, mkdir '${path}'`), { code: 'EEXIST' });
|
|
363
|
+
}
|
|
364
|
+
}
|
|
365
|
+
}
|
|
366
|
+
/**
|
|
367
|
+
* Remove a directory synchronously.
|
|
368
|
+
* Backed by wasi:filesystem/types@0.2.0 — fully synchronous.
|
|
369
|
+
*/
|
|
370
|
+
export function rmdirSync(path, _options) {
|
|
371
|
+
const resolved = resolvePath(path);
|
|
372
|
+
if (!resolved)
|
|
373
|
+
throw enoent(path);
|
|
374
|
+
try {
|
|
375
|
+
resolved.dir.removeDirectoryAt(resolved.relativePath);
|
|
376
|
+
}
|
|
377
|
+
catch (e) {
|
|
378
|
+
throw Object.assign(new Error(`ENOENT: no such file or directory, rmdir '${path}'`), { code: 'ENOENT' });
|
|
379
|
+
}
|
|
380
|
+
}
|
|
381
|
+
/**
|
|
382
|
+
* Remove a file or directory synchronously.
|
|
383
|
+
* Backed by wasi:filesystem/types@0.2.0 — fully synchronous.
|
|
384
|
+
*/
|
|
385
|
+
export function rmSync(path, options) {
|
|
386
|
+
const resolved = resolvePath(path);
|
|
387
|
+
if (!resolved) {
|
|
388
|
+
if (options?.force)
|
|
389
|
+
return;
|
|
390
|
+
throw enoent(path);
|
|
391
|
+
}
|
|
392
|
+
try {
|
|
393
|
+
const fd = resolved.dir.openAt({ symlinkFollow: false }, resolved.relativePath, {}, { read: true });
|
|
394
|
+
const s = fd.stat();
|
|
395
|
+
if (s.type === 'directory') {
|
|
396
|
+
if (!options?.recursive) {
|
|
397
|
+
throw Object.assign(new Error(`EISDIR: illegal operation on a directory, rm '${path}'`), { code: 'EISDIR' });
|
|
398
|
+
}
|
|
399
|
+
resolved.dir.removeDirectoryAt(resolved.relativePath);
|
|
400
|
+
}
|
|
401
|
+
else {
|
|
402
|
+
resolved.dir.unlinkFileAt(resolved.relativePath);
|
|
403
|
+
}
|
|
404
|
+
}
|
|
405
|
+
catch (e) {
|
|
406
|
+
if (options?.force)
|
|
407
|
+
return;
|
|
408
|
+
if (e instanceof Error && e.code)
|
|
409
|
+
throw e;
|
|
410
|
+
throw enoent(path);
|
|
411
|
+
}
|
|
412
|
+
}
|
|
413
|
+
/**
|
|
414
|
+
* Remove a file synchronously.
|
|
415
|
+
* Backed by wasi:filesystem/types@0.2.0 — fully synchronous.
|
|
416
|
+
*/
|
|
417
|
+
export function unlinkSync(path) {
|
|
418
|
+
const resolved = resolvePath(path);
|
|
419
|
+
if (!resolved)
|
|
420
|
+
throw enoent(path);
|
|
421
|
+
try {
|
|
422
|
+
resolved.dir.unlinkFileAt(resolved.relativePath);
|
|
423
|
+
}
|
|
424
|
+
catch (e) {
|
|
425
|
+
throw Object.assign(new Error(`ENOENT: no such file or directory, unlink '${path}'`), { code: 'ENOENT' });
|
|
426
|
+
}
|
|
427
|
+
}
|
|
428
|
+
/**
|
|
429
|
+
* Copy a file synchronously.
|
|
430
|
+
* Backed by wasi:filesystem/types@0.2.0 — fully synchronous.
|
|
431
|
+
*/
|
|
432
|
+
export function copyFileSync(src, dest) {
|
|
433
|
+
const data = readFileSync(src);
|
|
434
|
+
writeFileSync(dest, data);
|
|
435
|
+
}
|
|
436
|
+
/**
|
|
437
|
+
* Rename a file or directory synchronously.
|
|
438
|
+
* Falls back to copy+delete since wasi:filesystem/types@0.2.0
|
|
439
|
+
* does not expose a rename/link-at in the current WIT binding.
|
|
440
|
+
*/
|
|
441
|
+
export function renameSync(oldPath, newPath) {
|
|
442
|
+
try {
|
|
443
|
+
const data = readFileSync(oldPath);
|
|
444
|
+
writeFileSync(newPath, data);
|
|
445
|
+
unlinkSync(oldPath);
|
|
446
|
+
}
|
|
447
|
+
catch (e) {
|
|
448
|
+
throw Object.assign(new Error(`ENOENT: no such file or directory, rename '${oldPath}' -> '${newPath}'`), { code: 'ENOENT' });
|
|
449
|
+
}
|
|
450
|
+
}
|
|
451
|
+
/**
|
|
452
|
+
* Check file accessibility synchronously.
|
|
453
|
+
* Throws if the path does not exist.
|
|
454
|
+
*/
|
|
455
|
+
export function accessSync(path, _mode) {
|
|
456
|
+
const resolved = resolvePath(path);
|
|
457
|
+
if (!resolved)
|
|
458
|
+
throw enoent(path);
|
|
459
|
+
try {
|
|
460
|
+
resolved.dir.openAt({ symlinkFollow: false }, resolved.relativePath, {}, { read: true });
|
|
461
|
+
}
|
|
462
|
+
catch (e) {
|
|
463
|
+
throw Object.assign(new Error(`ENOENT: no such file or directory, access '${path}'`), { code: 'ENOENT' });
|
|
464
|
+
}
|
|
465
|
+
}
|
|
466
|
+
/**
|
|
467
|
+
* Check if a path exists synchronously.
|
|
468
|
+
* Backed by wasi:filesystem/types@0.2.0 — fully synchronous.
|
|
469
|
+
*/
|
|
470
|
+
export function existsSync(path) {
|
|
471
|
+
const resolved = resolvePath(path);
|
|
472
|
+
if (!resolved)
|
|
473
|
+
return false;
|
|
474
|
+
try {
|
|
475
|
+
resolved.dir.openAt({ symlinkFollow: false }, resolved.relativePath, {}, { read: true });
|
|
476
|
+
return true;
|
|
477
|
+
}
|
|
478
|
+
catch {
|
|
479
|
+
return false;
|
|
480
|
+
}
|
|
214
481
|
}
|
|
215
482
|
/**
|
|
216
483
|
* Delete a file.
|
|
@@ -418,12 +685,9 @@ export const promises = {
|
|
|
418
685
|
async stat(path) {
|
|
419
686
|
const kind = await statPath(path);
|
|
420
687
|
if (kind === 'notfound') {
|
|
421
|
-
throw new Error(`ENOENT: no such file or directory, stat '${path}'`);
|
|
688
|
+
throw Object.assign(new Error(`ENOENT: no such file or directory, stat '${path}'`), { code: 'ENOENT' });
|
|
422
689
|
}
|
|
423
|
-
return
|
|
424
|
-
isFile: () => kind === 'file',
|
|
425
|
-
isDirectory: () => kind === 'directory',
|
|
426
|
-
};
|
|
690
|
+
return makeStatResult(kind);
|
|
427
691
|
},
|
|
428
692
|
async rmdir(path, options) {
|
|
429
693
|
await rmdir(path, options);
|
|
@@ -442,16 +706,31 @@ export const promises = {
|
|
|
442
706
|
},
|
|
443
707
|
};
|
|
444
708
|
const fs = {
|
|
709
|
+
// Async / callback
|
|
445
710
|
readFile,
|
|
446
711
|
writeFile,
|
|
447
712
|
readdir,
|
|
448
|
-
existsSync,
|
|
449
713
|
unlink,
|
|
450
714
|
rmdir,
|
|
451
715
|
rm,
|
|
452
716
|
mkdir,
|
|
453
717
|
copyFile,
|
|
454
718
|
cp,
|
|
719
|
+
readFileSync,
|
|
720
|
+
writeFileSync,
|
|
721
|
+
appendFileSync,
|
|
722
|
+
readdirSync,
|
|
723
|
+
statSync,
|
|
724
|
+
lstatSync,
|
|
725
|
+
mkdirSync,
|
|
726
|
+
rmdirSync,
|
|
727
|
+
rmSync,
|
|
728
|
+
unlinkSync,
|
|
729
|
+
copyFileSync,
|
|
730
|
+
renameSync,
|
|
731
|
+
accessSync,
|
|
732
|
+
existsSync,
|
|
733
|
+
// Promises API
|
|
455
734
|
promises,
|
|
456
735
|
};
|
|
457
736
|
export default fs;
|