@webpodjs/fs-worker 0.0.0-stage → 0.1.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.
@@ -0,0 +1,376 @@
1
+ /* tslint:disable */
2
+ /* eslint-disable */
3
+
4
+ /**
5
+ * The pod's two block devices for the FS Worker: `webpod-root` (lazy read-only base image)
6
+ * and `webpod-data` (persistent writable disk), served from channel-mode block messages.
7
+ */
8
+ export class BlockVolumes {
9
+ private constructor();
10
+ free(): void;
11
+ [Symbol.dispose](): void;
12
+ /**
13
+ * Flushes the data disk, closes both and releases the pod lock.
14
+ */
15
+ close(): Promise<any>;
16
+ /**
17
+ * Flushes the data disk's writes to storage (the page is going away: `pagehide`), as a
18
+ * guest flush request does.
19
+ */
20
+ flush(): Promise<any>;
21
+ /**
22
+ * Handles a batch of block request messages for disk `serial`; resolves to the encoded
23
+ * completion messages, in request order.
24
+ */
25
+ handle(serial: string, msgs: Array<any>): Promise<any>;
26
+ /**
27
+ * `dataBackend`: `"auto" | "opfs" | "idb" | "memory"`; `onConflict`: `"fail" | "ephemeral"`.
28
+ * `manifestUrl` defaults to `imageUrl + ".wpim"` when empty. `packedUrl`: the image's
29
+ * packed form, read instead of the blob when it is there (null: never).
30
+ */
31
+ static open(pod_id: string, image_url: string, manifest_url: string, data_size: number, data_backend: string, on_conflict: string, packed_url?: string | null): Promise<BlockVolumes>;
32
+ /**
33
+ * Downloads root image chunks ahead of use (into memory and the chunk cache). Call with
34
+ * small batches so guest reads are not held up behind a long prefetch.
35
+ */
36
+ prefetch(chunks: Uint32Array | number[]): Promise<any>;
37
+ /**
38
+ * Replaces the data disk's contents by a snapshot (manifest bytes from `SnapshotStore`).
39
+ * Only before the engine attaches: the guest must not see the disk change under it.
40
+ */
41
+ restoreData(manifest: Uint8Array | number[]): Promise<any>;
42
+ /**
43
+ * Base image download counters (FS-010 / FS-011): resolves to `{fetchedBytes,
44
+ * transferredBytes, packed, packFallback?, fetchRequests, cacheHits, memoryHits}` (queued
45
+ * behind running requests and prefetches). `fetchedBytes` counts image bytes,
46
+ * `transferredBytes` what came over the network (less when reading the packed image).
47
+ */
48
+ rootStats(): Promise<any>;
49
+ /**
50
+ * The boot profile so far: resolves to `{ manifest, chunks }`, the root image's manifest
51
+ * id and the chunk indices in first-touch order (see `webpod-build prefetch`).
52
+ */
53
+ rootTrace(): Promise<any>;
54
+ /**
55
+ * The engine's memory (the `SharedArrayBuffer` its rings and guest RAM live in): enables
56
+ * indirect requests, whose data the FS Worker reads from and writes to it in place
57
+ * (`docs/design/blk-indirect.md`).
58
+ */
59
+ setEngineMemory(memory: any): void;
60
+ /**
61
+ * Sets the largest read one completion can carry for `serial` (ring payload limit - 12).
62
+ */
63
+ setMaxRead(serial: string, max_read_len: number): void;
64
+ /**
65
+ * Snapshots the data disk into the pod's snapshot store (`webpod-snapshots/<pod>`); resolves
66
+ * to the volume manifest bytes. Block requests wait meanwhile (crash-consistent). Only the
67
+ * chunks written since the previous snapshot or restore are reread.
68
+ */
69
+ snapshotData(): Promise<any>;
70
+ /**
71
+ * True when nothing was ever written to the data disk when it was opened: a new pod (a
72
+ * boot snapshot's data disk can be restored onto it without losing anything).
73
+ */
74
+ readonly dataFresh: boolean;
75
+ readonly dataSize: number;
76
+ /**
77
+ * True when the data disk is in memory (another tab holds the pod, or memory backend).
78
+ */
79
+ readonly ephemeral: boolean;
80
+ /**
81
+ * Manifest id of the root image (to match a prefetch list, and in snapshot bindings). Kept
82
+ * from `open`: the root's server is lent out while it serves a request (a prefetch too).
83
+ */
84
+ readonly rootManifestId: string;
85
+ readonly rootSize: number;
86
+ }
87
+
88
+ /**
89
+ * The pod's snapshots (`webpod-snapshots/<pod>` in OPFS): named sets of volume manifests.
90
+ */
91
+ export class SnapshotStore {
92
+ private constructor();
93
+ free(): void;
94
+ [Symbol.dispose](): void;
95
+ /**
96
+ * Mismatching binding keys between snapshot `name` and the machine described by
97
+ * `current` (`{engine, machine, cpus, ram, devices, kernel, cmdline, image}`); empty means
98
+ * the snapshot can resume on it.
99
+ */
100
+ checkBinding(name: string, current: any): Promise<any>;
101
+ /**
102
+ * Resolves to whether a snapshot was deleted (unreferenced chunks are freed).
103
+ */
104
+ delete(name: string): Promise<any>;
105
+ /**
106
+ * Forgets the RAM chunks `importBoot` kept unstored (its pod did not resume from them: a
107
+ * later import downloads what the store lacks).
108
+ */
109
+ discardUnpersisted(): void;
110
+ /**
111
+ * Writes snapshot `name` as one tar file and resolves to it: a `File` in OPFS
112
+ * (`exports/<name>.tar` in the store), or an in-memory `Blob` with the IndexedDB store. Either
113
+ * can be posted to the page and downloaded.
114
+ */
115
+ exportFile(name: string): Promise<any>;
116
+ /**
117
+ * Imports an exported snapshot from a `File`/`Blob` (worker only), optionally renamed.
118
+ */
119
+ importBlob(blob: Blob, rename?: string | null): Promise<any>;
120
+ /**
121
+ * Imports a published boot snapshot (`webpod-build snapshot` output under `base_url`,
122
+ * ending in `/`) as snapshot `name`: downloads the RAM and data disk chunks this store lacks
123
+ * over range requests and the device state, verifies everything, and records the binding
124
+ * metadata. Resolves to `{ info, fetchedBytes }`; a second import of the same snapshot
125
+ * downloads nothing but `boot.json` and the manifests.
126
+ */
127
+ importBoot(base_url: string, name: string): Promise<any>;
128
+ /**
129
+ * `[{name, created, volumes: {name: manifestId}, meta}]`.
130
+ */
131
+ list(): Promise<any>;
132
+ /**
133
+ * The manifest bytes of volume `volume` of snapshot `name`, for `restoreData` / `restore`.
134
+ */
135
+ manifest(name: string, volume: string): Promise<any>;
136
+ static open(pod_id: string): Promise<SnapshotStore>;
137
+ /**
138
+ * Stores the RAM chunks `importBoot` kept in memory, a few at a time with the Worker's other
139
+ * tasks in between (call it once the pod has resumed). Anything that reads RAM chunks from
140
+ * the store stores them first anyway.
141
+ */
142
+ persistRam(): Promise<any>;
143
+ /**
144
+ * Writes a RAM snapshot (manifest bytes) into `ram`; `fresh`: the RAM is all zeros (a
145
+ * just-started engine), zero chunks are skipped. Resolves to the bytes written.
146
+ * Reads a RAM volume's chunks ahead (decompressed, in this Worker's memory) so that the
147
+ * next `restoreRam` of the same manifest only copies; resolves to the non-zero bytes held.
148
+ */
149
+ prefetchRam(manifest: Uint8Array | number[]): Promise<any>;
150
+ /**
151
+ * Reads back bytes stored with `snapshotBytes`.
152
+ */
153
+ readBytes(manifest: Uint8Array | number[]): Promise<any>;
154
+ restoreRam(manifest: Uint8Array | number[], ram: Uint8Array, fresh: boolean): Promise<any>;
155
+ /**
156
+ * Records snapshot `name` from volume manifests (`{data: Uint8Array, workspace: ...}`,
157
+ * as returned by `snapshotData()` / `WorkspaceFs.snapshot()`) and string metadata.
158
+ */
159
+ save(name: string, created_ms: number, meta: any, volumes: any): Promise<any>;
160
+ /**
161
+ * Stores an opaque byte string (the engine's device state) as a volume; resolves to its
162
+ * manifest.
163
+ */
164
+ snapshotBytes(data: Uint8Array | number[]): Promise<any>;
165
+ /**
166
+ * Stores guest RAM (`ram`: a view of the engine's memory) and resolves to its manifest.
167
+ * Call with the guest stopped.
168
+ */
169
+ snapshotRam(ram: Uint8Array): Promise<any>;
170
+ }
171
+
172
+ /**
173
+ * The shared workspace, opened in the FS Worker.
174
+ */
175
+ export class WorkspaceFs {
176
+ private constructor();
177
+ free(): void;
178
+ [Symbol.dispose](): void;
179
+ chmod(path: string, mode: number): Promise<any>;
180
+ /**
181
+ * Syncs, closes OPFS handles and releases the workspace lock.
182
+ */
183
+ close(): Promise<any>;
184
+ /**
185
+ * The view serving another tab `client` (its page and its guest's 9P session); its changes
186
+ * are recorded as `"page:<client>"` and `"guest:<client>"`.
187
+ */
188
+ forClient(client: string): WorkspaceFs;
189
+ mkdir(path: string, recursive: boolean, mode: number): Promise<any>;
190
+ /**
191
+ * Opens the workspace of `podId` (OPFS, else in memory; see `ephemeral`). Files the page
192
+ * creates are owned by `uid`/`gid`; `msize` bounds 9P messages (ring payload limit).
193
+ */
194
+ static open(pod_id: string, mount_point: string, uid: number, gid: number, msize: number): Promise<WorkspaceFs>;
195
+ /**
196
+ * Goes on with `session` (another tab's, from `p9Session` of the workspace's previous
197
+ * holder) as this view's 9P session: the fids of what this workspace has go on working,
198
+ * open ones pinned again. Resolves to the number of fids dropped.
199
+ */
200
+ p9Adopt(session: Uint8Array | number[]): Promise<any>;
201
+ /**
202
+ * Ends the 9P session (guest reboot or disconnect): drops all fids. For another tab's view,
203
+ * also forgets the session (the tab is gone).
204
+ */
205
+ p9Reset(): Promise<any>;
206
+ /**
207
+ * The 9P session of this view (`P9Server::save_session`), for the tab it serves to go on
208
+ * with if it takes the workspace over; `undefined` before its guest speaks 9P.
209
+ */
210
+ p9Session(): Promise<any>;
211
+ /**
212
+ * Answers one 9P request message; resolves to the reply, or `undefined` for a message
213
+ * too short to answer.
214
+ */
215
+ p9(msg: Uint8Array | number[]): Promise<any>;
216
+ readAt(path: string, offset: number, len: number): Promise<any>;
217
+ readFile(path: string): Promise<any>;
218
+ /**
219
+ * `[{name, type}]`.
220
+ */
221
+ readdir(path: string): Promise<any>;
222
+ readlink(path: string): Promise<any>;
223
+ rename(from: string, to: string): Promise<any>;
224
+ /**
225
+ * Replaces the workspace by a dump (manifest bytes from `SnapshotStore`). Only before the
226
+ * engine attaches. Without `session` the 9P session is dropped (the guest mounts again);
227
+ * with the one saved by `snapshotWithSession` the resumed guest's fids go on working, open
228
+ * files unlinked before the snapshot included.
229
+ */
230
+ restore(manifest: Uint8Array | number[], session?: Uint8Array | number[] | null): Promise<any>;
231
+ rm(path: string, recursive: boolean, force: boolean): Promise<any>;
232
+ /**
233
+ * [`WorkspaceFs::snapshot`] and the 9P session at the same moment, for a memory snapshot
234
+ * (guest stopped): resolves to `{ workspace, p9 }`, the dump's manifest bytes and the
235
+ * session (`P9Server::save_session`), which `restore` takes back.
236
+ */
237
+ snapshotWithSession(): Promise<any>;
238
+ /**
239
+ * Dumps the whole workspace into the pod's snapshot store; resolves to the manifest bytes
240
+ * of the dump. Page and guest requests wait meanwhile.
241
+ */
242
+ snapshot(): Promise<any>;
243
+ /**
244
+ * `{type, size, mode, uid, gid, mtime (ms), ino}`; `follow` = stat, else lstat.
245
+ */
246
+ stat(path: string, follow: boolean): Promise<any>;
247
+ symlink(target: string, path: string): Promise<any>;
248
+ /**
249
+ * Flushes contents and metadata (call periodically and before closing).
250
+ */
251
+ sync(): Promise<any>;
252
+ /**
253
+ * Changes since the last call (through every view): `[{origin, type, path, dir?}]`, origin
254
+ * `"page"` or `"guest"` (this tab), `"page:<id>"` or `"guest:<id>"` (another, `forClient`);
255
+ * `dir: true` when the entry is a directory.
256
+ */
257
+ takeEvents(): Array<any>;
258
+ /**
259
+ * For a tab that another serves the workspace to: waits until that one releases the
260
+ * workspace lock (closes or ends), then opens it from OPFS and goes on with the 9P session
261
+ * `session()` returns then (a `Uint8Array`, the last one of this tab's guest the other sent,
262
+ * `p9Session`; or nothing), dropping the fids of what the other had not synced. Resolves to
263
+ * the opened workspace.
264
+ */
265
+ static takeOver(pod_id: string, mount_point: string, uid: number, gid: number, msize: number, session: Function): Promise<WorkspaceFs>;
266
+ /**
267
+ * Writes `data` at `offset`; `create` makes a missing file with `mode`, `truncate` empties
268
+ * it first. A whole-file write is `write(path, 0, data, true, true, mode)`.
269
+ */
270
+ write(path: string, offset: number, data: Uint8Array | number[], create: boolean, truncate: boolean, mode: number): Promise<any>;
271
+ /**
272
+ * `""` when persistent, else why not: `"no-opfs"` or `"locked"`.
273
+ */
274
+ readonly ephemeral: string;
275
+ }
276
+
277
+ export type InitInput = RequestInfo | URL | Response | BufferSource | WebAssembly.Module;
278
+
279
+ export interface InitOutput {
280
+ readonly memory: WebAssembly.Memory;
281
+ readonly __wbg_blockvolumes_free: (a: number, b: number) => void;
282
+ readonly __wbg_snapshotstore_free: (a: number, b: number) => void;
283
+ readonly __wbg_workspacefs_free: (a: number, b: number) => void;
284
+ readonly blockvolumes_close: (a: number) => any;
285
+ readonly blockvolumes_dataFresh: (a: number) => number;
286
+ readonly blockvolumes_dataSize: (a: number) => number;
287
+ readonly blockvolumes_ephemeral: (a: number) => number;
288
+ readonly blockvolumes_flush: (a: number) => any;
289
+ readonly blockvolumes_handle: (a: number, b: number, c: number, d: any) => any;
290
+ readonly blockvolumes_open: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number, i: number, j: number, k: number, l: number, m: number) => any;
291
+ readonly blockvolumes_prefetch: (a: number, b: number, c: number) => any;
292
+ readonly blockvolumes_restoreData: (a: number, b: number, c: number) => any;
293
+ readonly blockvolumes_rootManifestId: (a: number) => [number, number];
294
+ readonly blockvolumes_rootSize: (a: number) => number;
295
+ readonly blockvolumes_rootStats: (a: number) => any;
296
+ readonly blockvolumes_rootTrace: (a: number) => any;
297
+ readonly blockvolumes_setEngineMemory: (a: number, b: any) => void;
298
+ readonly blockvolumes_setMaxRead: (a: number, b: number, c: number, d: number) => void;
299
+ readonly blockvolumes_snapshotData: (a: number) => any;
300
+ readonly snapshotstore_checkBinding: (a: number, b: number, c: number, d: any) => any;
301
+ readonly snapshotstore_delete: (a: number, b: number, c: number) => any;
302
+ readonly snapshotstore_discardUnpersisted: (a: number) => void;
303
+ readonly snapshotstore_exportFile: (a: number, b: number, c: number) => any;
304
+ readonly snapshotstore_importBlob: (a: number, b: any, c: number, d: number) => any;
305
+ readonly snapshotstore_importBoot: (a: number, b: number, c: number, d: number, e: number) => any;
306
+ readonly snapshotstore_list: (a: number) => any;
307
+ readonly snapshotstore_manifest: (a: number, b: number, c: number, d: number, e: number) => any;
308
+ readonly snapshotstore_open: (a: number, b: number) => any;
309
+ readonly snapshotstore_persistRam: (a: number) => any;
310
+ readonly snapshotstore_prefetchRam: (a: number, b: number, c: number) => any;
311
+ readonly snapshotstore_readBytes: (a: number, b: number, c: number) => any;
312
+ readonly snapshotstore_restoreRam: (a: number, b: number, c: number, d: any, e: number) => any;
313
+ readonly snapshotstore_save: (a: number, b: number, c: number, d: number, e: any, f: any) => any;
314
+ readonly snapshotstore_snapshotBytes: (a: number, b: number, c: number) => any;
315
+ readonly snapshotstore_snapshotRam: (a: number, b: any) => any;
316
+ readonly workspacefs_chmod: (a: number, b: number, c: number, d: number) => any;
317
+ readonly workspacefs_close: (a: number) => any;
318
+ readonly workspacefs_ephemeral: (a: number) => [number, number];
319
+ readonly workspacefs_forClient: (a: number, b: number, c: number) => number;
320
+ readonly workspacefs_mkdir: (a: number, b: number, c: number, d: number, e: number) => any;
321
+ readonly workspacefs_open: (a: number, b: number, c: number, d: number, e: number, f: number, g: number) => any;
322
+ readonly workspacefs_p9: (a: number, b: number, c: number) => any;
323
+ readonly workspacefs_p9Adopt: (a: number, b: number, c: number) => any;
324
+ readonly workspacefs_p9Reset: (a: number) => any;
325
+ readonly workspacefs_p9Session: (a: number) => any;
326
+ readonly workspacefs_readAt: (a: number, b: number, c: number, d: number, e: number) => any;
327
+ readonly workspacefs_readFile: (a: number, b: number, c: number) => any;
328
+ readonly workspacefs_readdir: (a: number, b: number, c: number) => any;
329
+ readonly workspacefs_readlink: (a: number, b: number, c: number) => any;
330
+ readonly workspacefs_rename: (a: number, b: number, c: number, d: number, e: number) => any;
331
+ readonly workspacefs_restore: (a: number, b: number, c: number, d: number, e: number) => any;
332
+ readonly workspacefs_rm: (a: number, b: number, c: number, d: number, e: number) => any;
333
+ readonly workspacefs_snapshot: (a: number) => any;
334
+ readonly workspacefs_snapshotWithSession: (a: number) => any;
335
+ readonly workspacefs_stat: (a: number, b: number, c: number, d: number) => any;
336
+ readonly workspacefs_symlink: (a: number, b: number, c: number, d: number, e: number) => any;
337
+ readonly workspacefs_sync: (a: number) => any;
338
+ readonly workspacefs_takeEvents: (a: number) => any;
339
+ readonly workspacefs_takeOver: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: any) => any;
340
+ readonly workspacefs_write: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number, i: number) => any;
341
+ readonly wasm_bindgen_5a2380350bab5903___convert__closures_____invoke___js_sys_173b2b1834468215___Function_fn_wasm_bindgen_5a2380350bab5903___JsValue_____wasm_bindgen_5a2380350bab5903___sys__Undefined___js_sys_173b2b1834468215___Function_fn_wasm_bindgen_5a2380350bab5903___JsValue_____wasm_bindgen_5a2380350bab5903___sys__Undefined_______true_: (a: number, b: number, c: any, d: any) => void;
342
+ readonly wasm_bindgen_5a2380350bab5903___convert__closures_____invoke___wasm_bindgen_5a2380350bab5903___JsValue__core_6a51abefd5362b2___result__Result_____wasm_bindgen_5a2380350bab5903___JsError___true_: (a: number, b: number, c: any) => [number, number];
343
+ readonly wasm_bindgen_5a2380350bab5903___convert__closures_____invoke___wasm_bindgen_5a2380350bab5903___JsValue__wasm_bindgen_5a2380350bab5903___JsValue__true__1_: (a: number, b: number, c: any) => any;
344
+ readonly wasm_bindgen_5a2380350bab5903___convert__closures_____invoke_______true_: (a: number, b: number) => void;
345
+ readonly __wbindgen_malloc: (a: number, b: number) => number;
346
+ readonly __wbindgen_realloc: (a: number, b: number, c: number, d: number) => number;
347
+ readonly __wbindgen_free: (a: number, b: number, c: number) => void;
348
+ readonly __wbindgen_exn_store: (a: number) => void;
349
+ readonly __externref_table_alloc: () => number;
350
+ readonly __wbindgen_externrefs: WebAssembly.Table;
351
+ readonly __wbindgen_destroy_closure: (a: number, b: number) => void;
352
+ readonly __externref_table_dealloc: (a: number) => void;
353
+ readonly __wbindgen_start: () => void;
354
+ }
355
+
356
+ export type SyncInitInput = BufferSource | WebAssembly.Module;
357
+
358
+ /**
359
+ * Instantiates the given `module`, which can either be bytes or
360
+ * a precompiled `WebAssembly.Module`.
361
+ *
362
+ * @param {{ module: SyncInitInput }} module - Passing `SyncInitInput` directly is deprecated.
363
+ *
364
+ * @returns {InitOutput}
365
+ */
366
+ export function initSync(module: { module: SyncInitInput } | SyncInitInput): InitOutput;
367
+
368
+ /**
369
+ * If `module_or_path` is {RequestInfo} or {URL}, makes a request and
370
+ * for everything else, calls `WebAssembly.instantiate` directly.
371
+ *
372
+ * @param {{ module_or_path: InitInput | Promise<InitInput> }} module_or_path - Passing `InitInput` directly is deprecated.
373
+ *
374
+ * @returns {Promise<InitOutput>}
375
+ */
376
+ export default function __wbg_init (module_or_path?: { module_or_path: InitInput | Promise<InitInput> } | InitInput | Promise<InitInput>): Promise<InitOutput>;