@webpodjs/sdk 0.0.0-stage → 0.1.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 +223 -2
- package/dist/agent/backend.d.ts +58 -0
- package/dist/agent/backend.js +405 -0
- package/dist/agent/backend.js.map +1 -0
- package/dist/agent/fs.d.ts +39 -0
- package/dist/agent/fs.js +148 -0
- package/dist/agent/fs.js.map +1 -0
- package/dist/agent/protocol.d.ts +227 -0
- package/dist/agent/protocol.js +360 -0
- package/dist/agent/protocol.js.map +1 -0
- package/dist/coi-serviceworker.d.ts +0 -0
- package/dist/coi-serviceworker.js +33 -0
- package/dist/coi-serviceworker.js.map +1 -0
- package/dist/coi.d.ts +19 -0
- package/dist/coi.js +54 -0
- package/dist/coi.js.map +1 -0
- package/dist/errors.d.ts +5 -0
- package/dist/errors.js +9 -0
- package/dist/errors.js.map +1 -0
- package/dist/features.d.ts +37 -0
- package/dist/features.js +125 -0
- package/dist/features.js.map +1 -0
- package/dist/fs/tar.d.ts +20 -0
- package/dist/fs/tar.js +329 -0
- package/dist/fs/tar.js.map +1 -0
- package/dist/fs/workspace.d.ts +14 -0
- package/dist/fs/workspace.js +170 -0
- package/dist/fs/workspace.js.map +1 -0
- package/dist/fs-router.d.ts +7 -0
- package/dist/fs-router.js +46 -0
- package/dist/fs-router.js.map +1 -0
- package/dist/host/backend.d.ts +115 -0
- package/dist/host/backend.js +419 -0
- package/dist/host/backend.js.map +1 -0
- package/dist/host/binding.d.ts +33 -0
- package/dist/host/binding.js +72 -0
- package/dist/host/binding.js.map +1 -0
- package/dist/host/channel.d.ts +37 -0
- package/dist/host/channel.js +150 -0
- package/dist/host/channel.js.map +1 -0
- package/dist/host/controller.d.ts +254 -0
- package/dist/host/controller.js +471 -0
- package/dist/host/controller.js.map +1 -0
- package/dist/host/devices.d.ts +128 -0
- package/dist/host/devices.js +315 -0
- package/dist/host/devices.js.map +1 -0
- package/dist/host/pump-worker.d.ts +1 -0
- package/dist/host/pump-worker.js +95 -0
- package/dist/host/pump-worker.js.map +1 -0
- package/dist/host/qmp.d.ts +8 -0
- package/dist/host/qmp.js +78 -0
- package/dist/host/qmp.js.map +1 -0
- package/dist/host/ring.d.ts +79 -0
- package/dist/host/ring.js +317 -0
- package/dist/host/ring.js.map +1 -0
- package/dist/index.d.ts +33 -0
- package/dist/index.js +19 -0
- package/dist/index.js.map +1 -0
- package/dist/net/client.d.ts +19 -0
- package/dist/net/client.js +230 -0
- package/dist/net/client.js.map +1 -0
- package/dist/net/options.d.ts +65 -0
- package/dist/net/options.js +8 -0
- package/dist/net/options.js.map +1 -0
- package/dist/net/preview.d.ts +15 -0
- package/dist/net/preview.js +69 -0
- package/dist/net/preview.js.map +1 -0
- package/dist/net/protocol.d.ts +65 -0
- package/dist/net/protocol.js +13 -0
- package/dist/net/protocol.js.map +1 -0
- package/dist/pod.d.ts +43 -0
- package/dist/pod.js +205 -0
- package/dist/pod.js.map +1 -0
- package/dist/preview-serviceworker.d.ts +0 -0
- package/dist/preview-serviceworker.js +399 -0
- package/dist/preview-serviceworker.js.map +1 -0
- package/dist/streams.d.ts +14 -0
- package/dist/streams.js +58 -0
- package/dist/streams.js.map +1 -0
- package/dist/testing/index.d.ts +14 -0
- package/dist/testing/index.js +353 -0
- package/dist/testing/index.js.map +1 -0
- package/dist/timers.d.ts +18 -0
- package/dist/timers.js +68 -0
- package/dist/timers.js.map +1 -0
- package/dist/types.d.ts +152 -0
- package/dist/types.js +14 -0
- package/dist/types.js.map +1 -0
- package/dist/units.d.ts +2 -0
- package/dist/units.js +31 -0
- package/dist/units.js.map +1 -0
- package/package.json +50 -4
|
@@ -0,0 +1,353 @@
|
|
|
1
|
+
import { WebPodError } from "../errors.js";
|
|
2
|
+
function parentPath(path) {
|
|
3
|
+
return `/${split(path).slice(0, -1).join("/")}`;
|
|
4
|
+
}
|
|
5
|
+
function split(path) {
|
|
6
|
+
if (!path.startsWith("/"))
|
|
7
|
+
throw new WebPodError("EINVAL", `path must be absolute: ${path}`);
|
|
8
|
+
const parts = [];
|
|
9
|
+
for (const part of path.split("/")) {
|
|
10
|
+
if (part === "" || part === ".")
|
|
11
|
+
continue;
|
|
12
|
+
if (part === "..")
|
|
13
|
+
parts.pop();
|
|
14
|
+
else
|
|
15
|
+
parts.push(part);
|
|
16
|
+
}
|
|
17
|
+
return parts;
|
|
18
|
+
}
|
|
19
|
+
function joinPath(cwd, path) {
|
|
20
|
+
return path.startsWith("/") ? path : `${cwd.replace(/\/$/, "")}/${path}`;
|
|
21
|
+
}
|
|
22
|
+
class MemoryFs {
|
|
23
|
+
root = { type: "dir", children: new Map(), mode: 0o755, mtime: Date.now() };
|
|
24
|
+
#watchers = new Set();
|
|
25
|
+
#emit(type, path) {
|
|
26
|
+
const norm = `/${split(path).join("/")}`;
|
|
27
|
+
for (const w of this.#watchers) {
|
|
28
|
+
const inside = norm === w.prefix || norm.startsWith(w.prefix === "/" ? "/" : `${w.prefix}/`);
|
|
29
|
+
const direct = parentPath(norm) === w.prefix || norm === w.prefix;
|
|
30
|
+
if (inside && (w.recursive || direct))
|
|
31
|
+
queueMicrotask(() => w.listener([{ type, path: norm }]));
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
/** Follows a final symlink (one level is enough for tests). */
|
|
35
|
+
#follow(path) {
|
|
36
|
+
const node = this.lookup(path);
|
|
37
|
+
if (node.type !== "symlink")
|
|
38
|
+
return node;
|
|
39
|
+
const target = node.target.startsWith("/") ? node.target : `${parentPath(path)}/${node.target}`;
|
|
40
|
+
return this.lookup(target);
|
|
41
|
+
}
|
|
42
|
+
lookup(path) {
|
|
43
|
+
let node = this.root;
|
|
44
|
+
for (const part of split(path)) {
|
|
45
|
+
if (node.type !== "dir")
|
|
46
|
+
throw new WebPodError("ENOTDIR", path);
|
|
47
|
+
const next = node.children.get(part);
|
|
48
|
+
if (!next)
|
|
49
|
+
throw new WebPodError("ENOENT", path);
|
|
50
|
+
node = next;
|
|
51
|
+
}
|
|
52
|
+
return node;
|
|
53
|
+
}
|
|
54
|
+
#parent(path) {
|
|
55
|
+
const parts = split(path);
|
|
56
|
+
const name = parts.pop();
|
|
57
|
+
if (name === undefined)
|
|
58
|
+
throw new WebPodError("EINVAL", `not allowed on /: ${path}`);
|
|
59
|
+
const dir = this.lookup(`/${parts.join("/")}`);
|
|
60
|
+
if (dir.type !== "dir")
|
|
61
|
+
throw new WebPodError("ENOTDIR", path);
|
|
62
|
+
return { dir, name };
|
|
63
|
+
}
|
|
64
|
+
async readFile(path, encoding) {
|
|
65
|
+
const node = this.#follow(path);
|
|
66
|
+
if (node.type !== "file")
|
|
67
|
+
throw new WebPodError("EISDIR", path);
|
|
68
|
+
return encoding === "utf8" ? new TextDecoder().decode(node.data) : node.data.slice();
|
|
69
|
+
}
|
|
70
|
+
createReadStream(path) {
|
|
71
|
+
return new ReadableStream({
|
|
72
|
+
start: async (controller) => {
|
|
73
|
+
try {
|
|
74
|
+
controller.enqueue(await this.readFile(path));
|
|
75
|
+
controller.close();
|
|
76
|
+
}
|
|
77
|
+
catch (e) {
|
|
78
|
+
controller.error(e);
|
|
79
|
+
}
|
|
80
|
+
},
|
|
81
|
+
});
|
|
82
|
+
}
|
|
83
|
+
async writeFile(path, data, options = {}) {
|
|
84
|
+
const { dir, name } = this.#parent(path);
|
|
85
|
+
const existing = dir.children.get(name);
|
|
86
|
+
if (existing?.type === "dir")
|
|
87
|
+
throw new WebPodError("EISDIR", path);
|
|
88
|
+
const bytes = typeof data === "string"
|
|
89
|
+
? new TextEncoder().encode(data)
|
|
90
|
+
: data instanceof Uint8Array
|
|
91
|
+
? data.slice()
|
|
92
|
+
: new Uint8Array(await new Response(data).arrayBuffer());
|
|
93
|
+
dir.children.set(name, { type: "file", data: bytes, mode: options.mode ?? existing?.mode ?? 0o644, mtime: Date.now() });
|
|
94
|
+
this.#emit(existing ? "modify" : "create", path);
|
|
95
|
+
}
|
|
96
|
+
async readdir(path) {
|
|
97
|
+
const node = this.lookup(path);
|
|
98
|
+
if (node.type !== "dir")
|
|
99
|
+
throw new WebPodError("ENOTDIR", path);
|
|
100
|
+
return [...node.children].map(([name, child]) => ({ name, type: child.type }));
|
|
101
|
+
}
|
|
102
|
+
async mkdir(path, options = {}) {
|
|
103
|
+
if (options.recursive) {
|
|
104
|
+
let node = this.root;
|
|
105
|
+
for (const part of split(path)) {
|
|
106
|
+
if (node.type !== "dir")
|
|
107
|
+
throw new WebPodError("ENOTDIR", path);
|
|
108
|
+
let next = node.children.get(part);
|
|
109
|
+
if (!next) {
|
|
110
|
+
next = { type: "dir", children: new Map(), mode: options.mode ?? 0o755, mtime: Date.now() };
|
|
111
|
+
node.children.set(part, next);
|
|
112
|
+
}
|
|
113
|
+
node = next;
|
|
114
|
+
}
|
|
115
|
+
if (node.type !== "dir")
|
|
116
|
+
throw new WebPodError("EEXIST", path);
|
|
117
|
+
return;
|
|
118
|
+
}
|
|
119
|
+
const { dir, name } = this.#parent(path);
|
|
120
|
+
if (dir.children.has(name))
|
|
121
|
+
throw new WebPodError("EEXIST", path);
|
|
122
|
+
dir.children.set(name, { type: "dir", children: new Map(), mode: options.mode ?? 0o755, mtime: Date.now() });
|
|
123
|
+
this.#emit("create", path);
|
|
124
|
+
}
|
|
125
|
+
async rm(path, options = {}) {
|
|
126
|
+
const { dir, name } = this.#parent(path);
|
|
127
|
+
const node = dir.children.get(name);
|
|
128
|
+
if (!node) {
|
|
129
|
+
if (options.force)
|
|
130
|
+
return;
|
|
131
|
+
throw new WebPodError("ENOENT", path);
|
|
132
|
+
}
|
|
133
|
+
if (node.type === "dir" && node.children.size > 0 && !options.recursive)
|
|
134
|
+
throw new WebPodError("ENOTEMPTY", path);
|
|
135
|
+
dir.children.delete(name);
|
|
136
|
+
this.#emit("delete", path);
|
|
137
|
+
}
|
|
138
|
+
#stat(node) {
|
|
139
|
+
const size = node.type === "file" ? node.data.length : node.type === "symlink" ? node.target.length : 0;
|
|
140
|
+
return { type: node.type, size, mode: node.mode, mtime: node.mtime };
|
|
141
|
+
}
|
|
142
|
+
async stat(path) {
|
|
143
|
+
return this.#stat(this.#follow(path));
|
|
144
|
+
}
|
|
145
|
+
async lstat(path) {
|
|
146
|
+
return this.#stat(this.lookup(path));
|
|
147
|
+
}
|
|
148
|
+
async rename(from, to) {
|
|
149
|
+
const src = this.#parent(from);
|
|
150
|
+
const node = src.dir.children.get(src.name);
|
|
151
|
+
if (!node)
|
|
152
|
+
throw new WebPodError("ENOENT", from);
|
|
153
|
+
const dst = this.#parent(to);
|
|
154
|
+
src.dir.children.delete(src.name);
|
|
155
|
+
dst.dir.children.set(dst.name, node);
|
|
156
|
+
this.#emit("delete", from);
|
|
157
|
+
this.#emit("create", to);
|
|
158
|
+
}
|
|
159
|
+
async chmod(path, mode) {
|
|
160
|
+
this.#follow(path).mode = mode & 0o7777;
|
|
161
|
+
this.#emit("modify", path);
|
|
162
|
+
}
|
|
163
|
+
async symlink(target, path) {
|
|
164
|
+
const { dir, name } = this.#parent(path);
|
|
165
|
+
if (dir.children.has(name))
|
|
166
|
+
throw new WebPodError("EEXIST", path);
|
|
167
|
+
dir.children.set(name, { type: "symlink", target, mode: 0o777, mtime: Date.now() });
|
|
168
|
+
this.#emit("create", path);
|
|
169
|
+
}
|
|
170
|
+
async readlink(path) {
|
|
171
|
+
const node = this.lookup(path);
|
|
172
|
+
if (node.type !== "symlink")
|
|
173
|
+
throw new WebPodError("EINVAL", `not a symlink: ${path}`);
|
|
174
|
+
return node.target;
|
|
175
|
+
}
|
|
176
|
+
async watch(path, listener, options = {}) {
|
|
177
|
+
this.lookup(path);
|
|
178
|
+
const entry = { prefix: `/${split(path).join("/")}`, recursive: options.recursive ?? true, listener };
|
|
179
|
+
this.#watchers.add(entry);
|
|
180
|
+
return { close: async () => void this.#watchers.delete(entry) };
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
const BUILTINS = {
|
|
184
|
+
true: async () => 0,
|
|
185
|
+
false: async () => 1,
|
|
186
|
+
exit: async ({ args }) => Number(args[0] ?? 0) & 255,
|
|
187
|
+
echo: async ({ args, out }) => {
|
|
188
|
+
out(`${args.join(" ")}\n`);
|
|
189
|
+
return 0;
|
|
190
|
+
},
|
|
191
|
+
pwd: async ({ cwd, out }) => {
|
|
192
|
+
out(`${cwd}\n`);
|
|
193
|
+
return 0;
|
|
194
|
+
},
|
|
195
|
+
env: async ({ env, out }) => {
|
|
196
|
+
out(Object.entries(env)
|
|
197
|
+
.map(([k, v]) => `${k}=${v}\n`)
|
|
198
|
+
.join(""));
|
|
199
|
+
return 0;
|
|
200
|
+
},
|
|
201
|
+
cat: async ({ args, cwd, fs, stdin, out, err }) => {
|
|
202
|
+
if (args.length === 0) {
|
|
203
|
+
for await (const chunk of stdin)
|
|
204
|
+
out(chunk);
|
|
205
|
+
return 0;
|
|
206
|
+
}
|
|
207
|
+
let code = 0;
|
|
208
|
+
for (const arg of args) {
|
|
209
|
+
try {
|
|
210
|
+
out(await fs.readFile(joinPath(cwd, arg)));
|
|
211
|
+
}
|
|
212
|
+
catch (e) {
|
|
213
|
+
err(`cat: ${arg}: ${e.code ?? e}\n`);
|
|
214
|
+
code = 1;
|
|
215
|
+
}
|
|
216
|
+
}
|
|
217
|
+
return code;
|
|
218
|
+
},
|
|
219
|
+
"wc-c": async ({ stdin, out }) => {
|
|
220
|
+
let n = 0;
|
|
221
|
+
for await (const chunk of stdin)
|
|
222
|
+
n += chunk.length;
|
|
223
|
+
out(`${n}\n`);
|
|
224
|
+
return 0;
|
|
225
|
+
},
|
|
226
|
+
sleep: async ({ args, killed }) => {
|
|
227
|
+
const ms = Number(args[0] ?? 0) * 1000;
|
|
228
|
+
let timer;
|
|
229
|
+
const done = new Promise((resolve) => (timer = setTimeout(() => resolve(0), ms)));
|
|
230
|
+
const result = await Promise.race([done, killed]);
|
|
231
|
+
clearTimeout(timer);
|
|
232
|
+
return result;
|
|
233
|
+
},
|
|
234
|
+
};
|
|
235
|
+
class Pipe {
|
|
236
|
+
#queue = [];
|
|
237
|
+
#closed = false;
|
|
238
|
+
#wake;
|
|
239
|
+
push(chunk) {
|
|
240
|
+
this.#queue.push(chunk);
|
|
241
|
+
this.#wake?.();
|
|
242
|
+
}
|
|
243
|
+
close() {
|
|
244
|
+
this.#closed = true;
|
|
245
|
+
this.#wake?.();
|
|
246
|
+
}
|
|
247
|
+
async *[Symbol.asyncIterator]() {
|
|
248
|
+
for (;;) {
|
|
249
|
+
const chunk = this.#queue.shift();
|
|
250
|
+
if (chunk)
|
|
251
|
+
yield chunk;
|
|
252
|
+
else if (this.#closed)
|
|
253
|
+
return;
|
|
254
|
+
else
|
|
255
|
+
await new Promise((resolve) => (this.#wake = resolve));
|
|
256
|
+
}
|
|
257
|
+
}
|
|
258
|
+
}
|
|
259
|
+
function output() {
|
|
260
|
+
let controller;
|
|
261
|
+
const stream = new ReadableStream({ start: (c) => void (controller = c) });
|
|
262
|
+
const encoder = new TextEncoder();
|
|
263
|
+
return {
|
|
264
|
+
stream,
|
|
265
|
+
write: (data) => {
|
|
266
|
+
const bytes = typeof data === "string" ? encoder.encode(data) : data;
|
|
267
|
+
if (bytes.length > 0)
|
|
268
|
+
controller.enqueue(bytes);
|
|
269
|
+
},
|
|
270
|
+
close: () => controller.close(),
|
|
271
|
+
};
|
|
272
|
+
}
|
|
273
|
+
let nextPid = 100;
|
|
274
|
+
class MemoryProcess {
|
|
275
|
+
pid;
|
|
276
|
+
stdin;
|
|
277
|
+
stdout;
|
|
278
|
+
stderr;
|
|
279
|
+
exit;
|
|
280
|
+
ptySizes = [];
|
|
281
|
+
#kill;
|
|
282
|
+
#exited = false;
|
|
283
|
+
constructor(fs, req, defaultEnv) {
|
|
284
|
+
this.pid = Promise.resolve(nextPid++);
|
|
285
|
+
if (req.pty)
|
|
286
|
+
this.ptySizes.push(req.pty);
|
|
287
|
+
const pipe = new Pipe();
|
|
288
|
+
this.stdin = new WritableStream({ write: (chunk) => pipe.push(chunk), close: () => pipe.close(), abort: () => pipe.close() });
|
|
289
|
+
const stdout = output();
|
|
290
|
+
const stderr = req.pty ? stdout : output();
|
|
291
|
+
this.stdout = stdout.stream;
|
|
292
|
+
this.stderr = req.pty ? new ReadableStream({ start: (c) => c.close() }) : stderr.stream;
|
|
293
|
+
const killed = new Promise((resolve) => (this.#kill = resolve));
|
|
294
|
+
const run = async () => {
|
|
295
|
+
const builtin = BUILTINS[req.command === "wc" && req.args[0] === "-c" ? "wc-c" : req.command];
|
|
296
|
+
const cwd = req.cwd ?? "/";
|
|
297
|
+
const node = fs.lookup(cwd);
|
|
298
|
+
if (node.type !== "dir")
|
|
299
|
+
throw new WebPodError("ENOTDIR", cwd);
|
|
300
|
+
let result;
|
|
301
|
+
if (!builtin) {
|
|
302
|
+
stderr.write(`${req.command}: command not found\n`);
|
|
303
|
+
result = 127;
|
|
304
|
+
}
|
|
305
|
+
else {
|
|
306
|
+
const args = req.command === "wc" ? req.args.slice(1) : req.args;
|
|
307
|
+
const env = { ...defaultEnv, ...req.env };
|
|
308
|
+
result = await Promise.race([builtin({ args, cwd, env, fs, stdin: pipe, out: stdout.write, err: stderr.write, killed }), killed]);
|
|
309
|
+
}
|
|
310
|
+
this.#exited = true;
|
|
311
|
+
stdout.close();
|
|
312
|
+
if (!req.pty)
|
|
313
|
+
stderr.close();
|
|
314
|
+
return typeof result === "number" ? { code: result, signal: null } : { code: null, signal: result };
|
|
315
|
+
};
|
|
316
|
+
this.exit = run();
|
|
317
|
+
}
|
|
318
|
+
async kill(signal = "SIGTERM") {
|
|
319
|
+
if (!this.#exited)
|
|
320
|
+
this.#kill(signal);
|
|
321
|
+
}
|
|
322
|
+
async resize(size) {
|
|
323
|
+
this.ptySizes.push(size);
|
|
324
|
+
}
|
|
325
|
+
}
|
|
326
|
+
/**
|
|
327
|
+
* In-memory backend for tests and E2E harness wiring: a JS file system and a handful of
|
|
328
|
+
* builtin commands (echo, cat, true, false, exit, pwd, env, sleep, `wc -c`). Not a Linux guest.
|
|
329
|
+
*/
|
|
330
|
+
export function createMemoryBackend(options = {}) {
|
|
331
|
+
const fs = new MemoryFs();
|
|
332
|
+
const env = { PATH: "/usr/local/bin:/usr/bin:/bin", HOME: "/root", ...options.env };
|
|
333
|
+
const procs = new Set();
|
|
334
|
+
let disposed = false;
|
|
335
|
+
return {
|
|
336
|
+
fs,
|
|
337
|
+
net: options.net,
|
|
338
|
+
get disposed() {
|
|
339
|
+
return disposed;
|
|
340
|
+
},
|
|
341
|
+
spawn(req) {
|
|
342
|
+
const proc = new MemoryProcess(fs, req, env);
|
|
343
|
+
procs.add(proc);
|
|
344
|
+
void proc.exit.finally(() => procs.delete(proc)).catch(() => { });
|
|
345
|
+
return proc;
|
|
346
|
+
},
|
|
347
|
+
async dispose() {
|
|
348
|
+
disposed = true;
|
|
349
|
+
await Promise.all([...procs].map((p) => p.kill("SIGKILL")));
|
|
350
|
+
},
|
|
351
|
+
};
|
|
352
|
+
}
|
|
353
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/testing/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAqB3C,SAAS,UAAU,CAAC,IAAY;IAC9B,OAAO,IAAI,KAAK,CAAC,IAAI,CAAC,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC;AAClD,CAAC;AAED,SAAS,KAAK,CAAC,IAAY;IACzB,IAAI,CAAC,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC;QAAE,MAAM,IAAI,WAAW,CAAC,QAAQ,EAAE,0BAA0B,IAAI,EAAE,CAAC,CAAC;IAC7F,MAAM,KAAK,GAAa,EAAE,CAAC;IAC3B,KAAK,MAAM,IAAI,IAAI,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,EAAE,CAAC;QACnC,IAAI,IAAI,KAAK,EAAE,IAAI,IAAI,KAAK,GAA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,GAAG;QAChB,IAAI,QAAQ;YACV,OAAO,QAAQ,CAAC;QAClB,CAAC;QACD,KAAK,CAAC,GAAG;YACP,MAAM,IAAI,GAAG,IAAI,aAAa,CAAC,EAAE,EAAE,GAAG,EAAE,GAAG,CAAC,CAAC;YAC7C,KAAK,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;YAChB,KAAK,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,GAAG,EAAE,CAAC,KAAK,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,KAAK,CAAC,GAAG,EAAE,GAAE,CAAC,CAAC,CAAC;YACjE,OAAO,IAAI,CAAC;QACd,CAAC;QACD,KAAK,CAAC,OAAO;YACX,QAAQ,GAAG,IAAI,CAAC;YAChB,MAAM,OAAO,CAAC,GAAG,CAAC,CAAC,GAAG,KAAK,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC;QAC9D,CAAC;KACF,CAAC;AACJ,CAAC"}
|
package/dist/timers.d.ts
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/** The part of `document` the timers watch (a fake one in tests). */
|
|
2
|
+
export interface VisibilitySource {
|
|
3
|
+
readonly visibilityState: string;
|
|
4
|
+
addEventListener(type: "visibilitychange", listener: () => void): void;
|
|
5
|
+
removeEventListener(type: "visibilitychange", listener: () => void): void;
|
|
6
|
+
}
|
|
7
|
+
/**
|
|
8
|
+
* Calls `onTimeout(hiddenMs)` once `ms` of visible time has passed and returns a cancel function.
|
|
9
|
+
* `hiddenMs` is how long the page was hidden during the wait (time that did not count).
|
|
10
|
+
*/
|
|
11
|
+
export declare function visibleTimeout(ms: number, onTimeout: (hiddenMs: number) => void, doc?: VisibilitySource | undefined): () => void;
|
|
12
|
+
/** Appended to timeout messages: says that (and how long) the page was hidden during the wait. */
|
|
13
|
+
export declare function hiddenNote(hiddenMs: number): string;
|
|
14
|
+
/** A promise rejected with `error(hiddenNote(...))` after `ms` of visible time; `cancel()` it once the wait is over. */
|
|
15
|
+
export declare function visibleDeadline(ms: number, error: (note: string) => Error): {
|
|
16
|
+
promise: Promise<never>;
|
|
17
|
+
cancel: () => void;
|
|
18
|
+
};
|
package/dist/timers.js
ADDED
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
// Timeouts for waits on the guest, the engine and device Workers that count only while the page is
|
|
2
|
+
// visible. Hidden pages get their timers throttled (Chromium, Firefox: about 1 Hz) or their whole
|
|
3
|
+
// JS frozen (Safari freezes a background tab after about 7 s), and a deadline that kept running
|
|
4
|
+
// meanwhile would fire as soon as the page comes back, for a wait that never got its time. Outside
|
|
5
|
+
// a document (Workers, Node) these are plain timers.
|
|
6
|
+
function pageDocument() {
|
|
7
|
+
const d = globalThis.document;
|
|
8
|
+
return d && typeof d.addEventListener === "function" && typeof d.visibilityState === "string" ? d : undefined;
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* Calls `onTimeout(hiddenMs)` once `ms` of visible time has passed and returns a cancel function.
|
|
12
|
+
* `hiddenMs` is how long the page was hidden during the wait (time that did not count).
|
|
13
|
+
*/
|
|
14
|
+
export function visibleTimeout(ms, onTimeout, doc = pageDocument()) {
|
|
15
|
+
if (!doc) {
|
|
16
|
+
const t = setTimeout(() => onTimeout(0), ms);
|
|
17
|
+
return () => clearTimeout(t);
|
|
18
|
+
}
|
|
19
|
+
let remaining = ms;
|
|
20
|
+
let since = 0;
|
|
21
|
+
let hiddenSince = 0;
|
|
22
|
+
let hiddenMs = 0;
|
|
23
|
+
let timer;
|
|
24
|
+
const run = () => {
|
|
25
|
+
since = performance.now();
|
|
26
|
+
timer = setTimeout(() => {
|
|
27
|
+
cancel();
|
|
28
|
+
onTimeout(hiddenMs);
|
|
29
|
+
}, Math.max(0, remaining));
|
|
30
|
+
};
|
|
31
|
+
const onChange = () => {
|
|
32
|
+
if (doc.visibilityState === "hidden") {
|
|
33
|
+
if (timer === undefined)
|
|
34
|
+
return;
|
|
35
|
+
clearTimeout(timer);
|
|
36
|
+
timer = undefined;
|
|
37
|
+
remaining -= performance.now() - since;
|
|
38
|
+
hiddenSince = performance.now();
|
|
39
|
+
}
|
|
40
|
+
else if (timer === undefined) {
|
|
41
|
+
hiddenMs += performance.now() - hiddenSince;
|
|
42
|
+
run();
|
|
43
|
+
}
|
|
44
|
+
};
|
|
45
|
+
const cancel = () => {
|
|
46
|
+
clearTimeout(timer);
|
|
47
|
+
doc.removeEventListener("visibilitychange", onChange);
|
|
48
|
+
};
|
|
49
|
+
doc.addEventListener("visibilitychange", onChange);
|
|
50
|
+
if (doc.visibilityState === "hidden")
|
|
51
|
+
hiddenSince = performance.now();
|
|
52
|
+
else
|
|
53
|
+
run();
|
|
54
|
+
return cancel;
|
|
55
|
+
}
|
|
56
|
+
/** Appended to timeout messages: says that (and how long) the page was hidden during the wait. */
|
|
57
|
+
export function hiddenNote(hiddenMs) {
|
|
58
|
+
return hiddenMs >= 1000 ? ` (page hidden for ${Math.round(hiddenMs / 1000)} s meanwhile, not counted)` : "";
|
|
59
|
+
}
|
|
60
|
+
/** A promise rejected with `error(hiddenNote(...))` after `ms` of visible time; `cancel()` it once the wait is over. */
|
|
61
|
+
export function visibleDeadline(ms, error) {
|
|
62
|
+
let cancel;
|
|
63
|
+
const promise = new Promise((_, reject) => {
|
|
64
|
+
cancel = visibleTimeout(ms, (hidden) => reject(error(hiddenNote(hidden))));
|
|
65
|
+
});
|
|
66
|
+
return { promise, cancel };
|
|
67
|
+
}
|
|
68
|
+
//# sourceMappingURL=timers.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"timers.js","sourceRoot":"","sources":["../src/timers.ts"],"names":[],"mappings":"AAAA,mGAAmG;AACnG,kGAAkG;AAClG,gGAAgG;AAChG,mGAAmG;AACnG,qDAAqD;AASrD,SAAS,YAAY;IACnB,MAAM,CAAC,GAAI,UAAuD,CAAC,QAAQ,CAAC;IAC5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
2
|
+
export type Signal = "SIGHUP" | "SIGINT" | "SIGQUIT" | "SIGKILL" | "SIGUSR1" | "SIGUSR2" | "SIGTERM" | "SIGCONT" | "SIGSTOP" | "SIGTSTP" | "SIGWINCH";
|
|
3
|
+
export declare const SIGNAL_NUMBERS: Record<Signal, number>;
|
|
4
|
+
export interface PtySize {
|
|
5
|
+
cols: number;
|
|
6
|
+
rows: number;
|
|
7
|
+
}
|
|
8
|
+
export interface SpawnOptions {
|
|
9
|
+
cwd?: string;
|
|
10
|
+
/** Merged over the image's default environment. */
|
|
11
|
+
env?: Record<string, string>;
|
|
12
|
+
/** Allocate a PTY. stderr is merged into stdout when set. */
|
|
13
|
+
pty?: boolean | PtySize;
|
|
14
|
+
/** `uid[:gid]` or `name[:group]`; defaults to the image's user. */
|
|
15
|
+
user?: string;
|
|
16
|
+
/** Data piped to the process; stdin is closed when it ends. Without it, `process.stdin` is writable. */
|
|
17
|
+
stdin?: ReadableStream<Uint8Array> | Uint8Array | string;
|
|
18
|
+
}
|
|
19
|
+
export interface ExitStatus {
|
|
20
|
+
/** Exit code, or null when killed by a signal. */
|
|
21
|
+
code: number | null;
|
|
22
|
+
signal: Signal | null;
|
|
23
|
+
}
|
|
24
|
+
export interface PodProcess {
|
|
25
|
+
readonly pid: Promise<number>;
|
|
26
|
+
readonly stdin: WritableStream<Uint8Array>;
|
|
27
|
+
readonly stdout: ReadableStream<Uint8Array>;
|
|
28
|
+
/** Empty stream when a PTY is allocated. */
|
|
29
|
+
readonly stderr: ReadableStream<Uint8Array>;
|
|
30
|
+
/** Resolves when the process exits; rejects when it could not be started. */
|
|
31
|
+
readonly exit: Promise<ExitStatus>;
|
|
32
|
+
kill(signal?: Signal): Promise<void>;
|
|
33
|
+
resize(size: PtySize): Promise<void>;
|
|
34
|
+
}
|
|
35
|
+
export interface ExecResult extends ExitStatus {
|
|
36
|
+
stdout: string;
|
|
37
|
+
stderr: string;
|
|
38
|
+
}
|
|
39
|
+
export type FileType = "file" | "dir" | "symlink" | "other";
|
|
40
|
+
export interface Stat {
|
|
41
|
+
type: FileType;
|
|
42
|
+
size: number;
|
|
43
|
+
mode: number;
|
|
44
|
+
/** Milliseconds since the epoch. */
|
|
45
|
+
mtime: number;
|
|
46
|
+
}
|
|
47
|
+
export interface DirEntry {
|
|
48
|
+
name: string;
|
|
49
|
+
type: FileType;
|
|
50
|
+
}
|
|
51
|
+
export type FsEventType = "create" | "modify" | "delete" | "overflow";
|
|
52
|
+
export interface FsEvent {
|
|
53
|
+
/** `overflow`: events were lost below `path`; rescan it. */
|
|
54
|
+
type: FsEventType;
|
|
55
|
+
path: string;
|
|
56
|
+
}
|
|
57
|
+
export interface FsWatcher {
|
|
58
|
+
close(): Promise<void>;
|
|
59
|
+
}
|
|
60
|
+
/** Guest file system. Paths are absolute guest paths. */
|
|
61
|
+
export interface PodFs {
|
|
62
|
+
readFile(path: string): Promise<Uint8Array>;
|
|
63
|
+
readFile(path: string, encoding: "utf8"): Promise<string>;
|
|
64
|
+
/** Streams a file in chunks, fetching the next chunk only as it is read. */
|
|
65
|
+
createReadStream(path: string): ReadableStream<Uint8Array>;
|
|
66
|
+
/** Creates or truncates. A stream is written chunk by chunk as it arrives. */
|
|
67
|
+
writeFile(path: string, data: Uint8Array | string | ReadableStream<Uint8Array>, options?: {
|
|
68
|
+
mode?: number;
|
|
69
|
+
}): Promise<void>;
|
|
70
|
+
readdir(path: string): Promise<DirEntry[]>;
|
|
71
|
+
mkdir(path: string, options?: {
|
|
72
|
+
recursive?: boolean;
|
|
73
|
+
mode?: number;
|
|
74
|
+
}): Promise<void>;
|
|
75
|
+
rm(path: string, options?: {
|
|
76
|
+
recursive?: boolean;
|
|
77
|
+
force?: boolean;
|
|
78
|
+
}): Promise<void>;
|
|
79
|
+
/** Follows symlinks. */
|
|
80
|
+
stat(path: string): Promise<Stat>;
|
|
81
|
+
lstat(path: string): Promise<Stat>;
|
|
82
|
+
rename(from: string, to: string): Promise<void>;
|
|
83
|
+
chmod(path: string, mode: number): Promise<void>;
|
|
84
|
+
symlink(target: string, path: string): Promise<void>;
|
|
85
|
+
readlink(path: string): Promise<string>;
|
|
86
|
+
/** Calls `listener` with batches of coalesced changes under `path`. */
|
|
87
|
+
watch(path: string, listener: (events: FsEvent[]) => void, options?: {
|
|
88
|
+
recursive?: boolean;
|
|
89
|
+
}): Promise<FsWatcher>;
|
|
90
|
+
}
|
|
91
|
+
export interface BackendSpawnRequest {
|
|
92
|
+
command: string;
|
|
93
|
+
args: string[];
|
|
94
|
+
cwd?: string;
|
|
95
|
+
env?: Record<string, string>;
|
|
96
|
+
pty?: PtySize;
|
|
97
|
+
user?: string;
|
|
98
|
+
}
|
|
99
|
+
/** Process handle returned by a backend; stdin is always writable. */
|
|
100
|
+
export interface BackendProcess extends Omit<PodProcess, "stdin"> {
|
|
101
|
+
readonly stdin: WritableStream<Uint8Array>;
|
|
102
|
+
}
|
|
103
|
+
/**
|
|
104
|
+
* What a Pod runs on. The default backend (QEMU-Wasm engine + guest agent) is wired in by
|
|
105
|
+
* webpod-host; tests and E2E harness setup can pass their own, e.g. `createMemoryBackend()`.
|
|
106
|
+
*/
|
|
107
|
+
export interface PodBackend {
|
|
108
|
+
readonly fs: PodFs;
|
|
109
|
+
/** Inbound networking (previews, pod.fetch, pod.net.connect): hands MessagePorts to the net Worker. */
|
|
110
|
+
readonly net?: import("./net/protocol.js").NetPortSink | null;
|
|
111
|
+
/** Guest console byte stream, when the backend has one. */
|
|
112
|
+
readonly console?: {
|
|
113
|
+
readable: ReadableStream<Uint8Array>;
|
|
114
|
+
writable: WritableStream<Uint8Array>;
|
|
115
|
+
};
|
|
116
|
+
spawn(request: BackendSpawnRequest): BackendProcess;
|
|
117
|
+
dispose(): Promise<void>;
|
|
118
|
+
}
|
|
119
|
+
export type IsolationMode = "iso" | "noiso";
|
|
120
|
+
export interface BootOptions {
|
|
121
|
+
/** Built-in image name or OCI reference. */
|
|
122
|
+
image?: string;
|
|
123
|
+
/** Guest RAM, e.g. `"256MiB"`, `"1GiB"` or bytes. Default 512MiB. */
|
|
124
|
+
memory?: string | number;
|
|
125
|
+
/** vCPUs. Values above 1 require cross-origin isolation. Default 1. */
|
|
126
|
+
cpus?: number;
|
|
127
|
+
/** Persistent volume name (OPFS). */
|
|
128
|
+
persist?: string;
|
|
129
|
+
/**
|
|
130
|
+
* `"auto"` (default) uses iso mode when the page is cross-origin isolated and noiso otherwise;
|
|
131
|
+
* `"require"` fails without isolation.
|
|
132
|
+
*/
|
|
133
|
+
isolation?: "auto" | "require";
|
|
134
|
+
/** Boot a real guest with this engine build (webpod-host). */
|
|
135
|
+
engine?: import("./host/backend.js").EngineOptions;
|
|
136
|
+
/** Guest networking (egress routes, CORS proxy, relay); needs `engine.net` (netWorker). */
|
|
137
|
+
network?: import("./net/options.js").NetworkOptions;
|
|
138
|
+
/** Custom backend; skips the engine. */
|
|
139
|
+
backend?: PodBackend | ((config: PodConfig) => PodBackend | Promise<PodBackend>);
|
|
140
|
+
}
|
|
141
|
+
export interface PodConfig {
|
|
142
|
+
image: string;
|
|
143
|
+
memoryBytes: number;
|
|
144
|
+
cpus: number;
|
|
145
|
+
persist: string | null;
|
|
146
|
+
mode: IsolationMode;
|
|
147
|
+
/** Values the caller left to their defaults (an engine boot snapshot may supply them). */
|
|
148
|
+
defaults?: {
|
|
149
|
+
memory?: boolean;
|
|
150
|
+
cpus?: boolean;
|
|
151
|
+
};
|
|
152
|
+
}
|
package/dist/types.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAGA,MAAM,CAAC,MAAM,cAAc,GAA2B;IACpD,MAAM,EAAE,CAAC;IACT,MAAM,EAAE,CAAC;IACT,OAAO,EAAE,CAAC;IACV,OAAO,EAAE,CAAC;IACV,OAAO,EAAE,EAAE;IACX,OAAO,EAAE,EAAE;IACX,OAAO,EAAE,EAAE;IACX,OAAO,EAAE,EAAE;IACX,OAAO,EAAE,EAAE;IACX,OAAO,EAAE,EAAE;IACX,QAAQ,EAAE,EAAE;CACb,CAAC"}
|
package/dist/units.d.ts
ADDED