@pgxsinkit/pgwasm 0.5.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/LICENSE +21 -0
- package/LICENSE-APACHE-2.0 +202 -0
- package/NOTICE +111 -0
- package/README.md +56 -0
- package/dist/build/index.d.ts +8 -0
- package/dist/build/index.d.ts.map +1 -0
- package/dist/build/index.js +21 -0
- package/dist/build/index.js.map +9 -0
- package/dist/build/seam.d.ts +174 -0
- package/dist/build/seam.d.ts.map +1 -0
- package/dist/chunk-0w227vw2.js +233 -0
- package/dist/chunk-0w227vw2.js.map +11 -0
- package/dist/chunk-74gcrk47.js +563 -0
- package/dist/chunk-74gcrk47.js.map +14 -0
- package/dist/chunk-at1py5s5.js +373 -0
- package/dist/chunk-at1py5s5.js.map +12 -0
- package/dist/chunk-cpsnmzrf.js +126 -0
- package/dist/chunk-cpsnmzrf.js.map +10 -0
- package/dist/chunk-d82gg1hx.js +306 -0
- package/dist/chunk-d82gg1hx.js.map +10 -0
- package/dist/chunk-gjf102c9.js +1005 -0
- package/dist/chunk-gjf102c9.js.map +16 -0
- package/dist/chunk-kb3rsr7n.js +19 -0
- package/dist/chunk-kb3rsr7n.js.map +9 -0
- package/dist/chunk-tdvrvgt5.js +83 -0
- package/dist/chunk-tdvrvgt5.js.map +11 -0
- package/dist/chunk-z0c40tja.js +50 -0
- package/dist/chunk-z0c40tja.js.map +10 -0
- package/dist/core/data-dir-archive.d.ts +17 -0
- package/dist/core/data-dir-archive.d.ts.map +1 -0
- package/dist/core/internals.d.ts +59 -0
- package/dist/core/internals.d.ts.map +1 -0
- package/dist/core/marker.d.ts +35 -0
- package/dist/core/marker.d.ts.map +1 -0
- package/dist/core/mutex.d.ts +9 -0
- package/dist/core/mutex.d.ts.map +1 -0
- package/dist/core/names.d.ts +11 -0
- package/dist/core/names.d.ts.map +1 -0
- package/dist/core/parse.d.ts +11 -0
- package/dist/core/parse.d.ts.map +1 -0
- package/dist/core/pgwasm.d.ts +53 -0
- package/dist/core/pgwasm.d.ts.map +1 -0
- package/dist/core/storage.d.ts +14 -0
- package/dist/core/storage.d.ts.map +1 -0
- package/dist/create.d.ts +10 -0
- package/dist/create.d.ts.map +1 -0
- package/dist/drizzle/codecs.d.ts +9 -0
- package/dist/drizzle/codecs.d.ts.map +1 -0
- package/dist/drizzle/driver.d.ts +50 -0
- package/dist/drizzle/driver.d.ts.map +1 -0
- package/dist/drizzle/index.d.ts +4 -0
- package/dist/drizzle/index.d.ts.map +1 -0
- package/dist/drizzle/index.js +261 -0
- package/dist/drizzle/index.js.map +12 -0
- package/dist/drizzle/session.d.ts +39 -0
- package/dist/drizzle/session.d.ts.map +1 -0
- package/dist/errors.d.ts +115 -0
- package/dist/errors.d.ts.map +1 -0
- package/dist/fs/base-filesystem.d.ts +118 -0
- package/dist/fs/base-filesystem.d.ts.map +1 -0
- package/dist/fs/index.d.ts +2 -0
- package/dist/fs/index.d.ts.map +1 -0
- package/dist/fs/index.js +11 -0
- package/dist/fs/index.js.map +9 -0
- package/dist/index.d.ts +8 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +53 -0
- package/dist/index.js.map +9 -0
- package/dist/interface.d.ts +165 -0
- package/dist/interface.d.ts.map +1 -0
- package/dist/live/debounce-mutex.d.ts +6 -0
- package/dist/live/debounce-mutex.d.ts.map +1 -0
- package/dist/live/format-query.d.ts +8 -0
- package/dist/live/format-query.d.ts.map +1 -0
- package/dist/live/index.d.ts +9 -0
- package/dist/live/index.d.ts.map +1 -0
- package/dist/live/index.js +601 -0
- package/dist/live/index.js.map +12 -0
- package/dist/live/interface.d.ts +86 -0
- package/dist/live/interface.d.ts.map +1 -0
- package/dist/opfs/broker/client.d.ts +163 -0
- package/dist/opfs/broker/client.d.ts.map +1 -0
- package/dist/opfs/broker/protocol.d.ts +326 -0
- package/dist/opfs/broker/protocol.d.ts.map +1 -0
- package/dist/opfs/broker/server.d.ts +84 -0
- package/dist/opfs/broker/server.d.ts.map +1 -0
- package/dist/opfs/core/checksum.d.ts +3 -0
- package/dist/opfs/core/checksum.d.ts.map +1 -0
- package/dist/opfs/core/codec.d.ts +73 -0
- package/dist/opfs/core/codec.d.ts.map +1 -0
- package/dist/opfs/core/errors.d.ts +80 -0
- package/dist/opfs/core/errors.d.ts.map +1 -0
- package/dist/opfs/core/limits.d.ts +35 -0
- package/dist/opfs/core/limits.d.ts.map +1 -0
- package/dist/opfs/core/memory-port.d.ts +51 -0
- package/dist/opfs/core/memory-port.d.ts.map +1 -0
- package/dist/opfs/core/metadata-store.d.ts +19 -0
- package/dist/opfs/core/metadata-store.d.ts.map +1 -0
- package/dist/opfs/core/mounted-vfs.d.ts +119 -0
- package/dist/opfs/core/mounted-vfs.d.ts.map +1 -0
- package/dist/opfs/core/path.d.ts +14 -0
- package/dist/opfs/core/path.d.ts.map +1 -0
- package/dist/opfs/core/port.d.ts +30 -0
- package/dist/opfs/core/port.d.ts.map +1 -0
- package/dist/opfs/core/repacked-vfs.d.ts +138 -0
- package/dist/opfs/core/repacked-vfs.d.ts.map +1 -0
- package/dist/opfs/core/state-machine.d.ts +296 -0
- package/dist/opfs/core/state-machine.d.ts.map +1 -0
- package/dist/opfs/create.d.ts +50 -0
- package/dist/opfs/create.d.ts.map +1 -0
- package/dist/opfs/file-port.d.ts +14 -0
- package/dist/opfs/file-port.d.ts.map +1 -0
- package/dist/opfs/index.d.ts +37 -0
- package/dist/opfs/index.d.ts.map +1 -0
- package/dist/opfs/index.js +6671 -0
- package/dist/opfs/index.js.map +28 -0
- package/dist/opfs/opfs-port.d.ts +34 -0
- package/dist/opfs/opfs-port.d.ts.map +1 -0
- package/dist/opfs/opfs-repacked-fs.d.ts +55 -0
- package/dist/opfs/opfs-repacked-fs.d.ts.map +1 -0
- package/dist/opfs/wasi/preview1.d.ts +228 -0
- package/dist/opfs/wasi/preview1.d.ts.map +1 -0
- package/dist/protocol/index.d.ts +15 -0
- package/dist/protocol/index.d.ts.map +1 -0
- package/dist/protocol/index.js +23 -0
- package/dist/protocol/index.js.map +10 -0
- package/dist/protocol/wire/buffer-reader.d.ts +13 -0
- package/dist/protocol/wire/buffer-reader.d.ts.map +1 -0
- package/dist/protocol/wire/buffer-writer.d.ts +12 -0
- package/dist/protocol/wire/buffer-writer.d.ts.map +1 -0
- package/dist/protocol/wire/index.d.ts +5 -0
- package/dist/protocol/wire/index.d.ts.map +1 -0
- package/dist/protocol/wire/messages.d.ts +194 -0
- package/dist/protocol/wire/messages.d.ts.map +1 -0
- package/dist/protocol/wire/parser.d.ts +12 -0
- package/dist/protocol/wire/parser.d.ts.map +1 -0
- package/dist/protocol/wire/serializer.d.ts +61 -0
- package/dist/protocol/wire/serializer.d.ts.map +1 -0
- package/dist/protocol/wire/string-utils.d.ts +6 -0
- package/dist/protocol/wire/string-utils.d.ts.map +1 -0
- package/dist/protocol/wire/types.d.ts +7 -0
- package/dist/protocol/wire/types.d.ts.map +1 -0
- package/dist/tar/gzip.d.ts +7 -0
- package/dist/tar/gzip.d.ts.map +1 -0
- package/dist/tar/tar.d.ts +39 -0
- package/dist/tar/tar.d.ts.map +1 -0
- package/dist/templating.d.ts +42 -0
- package/dist/templating.d.ts.map +1 -0
- package/dist/types.d.ts +76 -0
- package/dist/types.d.ts.map +1 -0
- package/package.json +69 -0
- package/skills/opfs/SKILL.md +138 -0
- package/src/build/index.ts +23 -0
- package/src/build/seam.ts +179 -0
- package/src/core/data-dir-archive.ts +68 -0
- package/src/core/internals.ts +87 -0
- package/src/core/marker.ts +94 -0
- package/src/core/mutex.ts +16 -0
- package/src/core/names.ts +26 -0
- package/src/core/parse.ts +79 -0
- package/src/core/pgwasm.ts +876 -0
- package/src/core/storage.ts +70 -0
- package/src/create.ts +134 -0
- package/src/drizzle/codecs.ts +114 -0
- package/src/drizzle/driver.ts +141 -0
- package/src/drizzle/index.ts +15 -0
- package/src/drizzle/session.ts +133 -0
- package/src/errors.ts +201 -0
- package/src/fs/base-filesystem.ts +149 -0
- package/src/fs/index.ts +7 -0
- package/src/index.ts +44 -0
- package/src/interface.ts +186 -0
- package/src/live/debounce-mutex.ts +45 -0
- package/src/live/format-query.ts +47 -0
- package/src/live/index.ts +707 -0
- package/src/live/interface.ts +109 -0
- package/src/opfs/broker/client.ts +482 -0
- package/src/opfs/broker/protocol.ts +624 -0
- package/src/opfs/broker/server.ts +522 -0
- package/src/opfs/core/checksum.ts +85 -0
- package/src/opfs/core/codec.ts +1051 -0
- package/src/opfs/core/errors.ts +134 -0
- package/src/opfs/core/limits.ts +68 -0
- package/src/opfs/core/memory-port.ts +459 -0
- package/src/opfs/core/metadata-store.ts +512 -0
- package/src/opfs/core/mounted-vfs.ts +407 -0
- package/src/opfs/core/path.ts +82 -0
- package/src/opfs/core/port.ts +114 -0
- package/src/opfs/core/repacked-vfs.ts +1464 -0
- package/src/opfs/core/state-machine.ts +1699 -0
- package/src/opfs/create.ts +125 -0
- package/src/opfs/file-port.ts +183 -0
- package/src/opfs/index.ts +113 -0
- package/src/opfs/opfs-port.ts +90 -0
- package/src/opfs/opfs-repacked-fs.ts +210 -0
- package/src/opfs/wasi/preview1.ts +1016 -0
- package/src/protocol/index.ts +24 -0
- package/src/protocol/wire/buffer-reader.ts +60 -0
- package/src/protocol/wire/buffer-writer.ts +93 -0
- package/src/protocol/wire/index.ts +15 -0
- package/src/protocol/wire/messages.ts +332 -0
- package/src/protocol/wire/parser.ts +373 -0
- package/src/protocol/wire/serializer.ts +233 -0
- package/src/protocol/wire/string-utils.ts +18 -0
- package/src/protocol/wire/types.ts +12 -0
- package/src/tar/gzip.ts +36 -0
- package/src/tar/tar.ts +253 -0
- package/src/templating.ts +103 -0
- package/src/types.ts +283 -0
|
@@ -0,0 +1,326 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The synchronous broker wire protocol.
|
|
3
|
+
*
|
|
4
|
+
* ## Why a wire protocol at all
|
|
5
|
+
*
|
|
6
|
+
* A repacked store is a single-owner object: it holds four exclusive file handles and one in-memory
|
|
7
|
+
* metadata generation, and it is not shareable across JavaScript agents. A multi-backend engine needs
|
|
8
|
+
* several worker threads to reach ONE store, and a worker running wasm parks in futexes, so it cannot
|
|
9
|
+
* await a promise to get a file answered. The store therefore lives alone in a coordinator worker and
|
|
10
|
+
* every other thread asks for file operations over a `SharedArrayBuffer`, blocking in `Atomics.wait`
|
|
11
|
+
* until the coordinator answers. Nothing here knows about PGlite, wasm, or OPFS.
|
|
12
|
+
*
|
|
13
|
+
* ## Topology
|
|
14
|
+
*
|
|
15
|
+
* One CHANNEL per client, plus one DOORBELL shared by every channel of one broker:
|
|
16
|
+
*
|
|
17
|
+
* client A ─ channel A ─┐
|
|
18
|
+
* client B ─ channel B ─┼─→ doorbell ─→ RepackedSyncBroker (owns the RepackedVfs)
|
|
19
|
+
* client C ─ channel C ─┘
|
|
20
|
+
*
|
|
21
|
+
* A client publishes its request into its own channel and then bumps the doorbell, so one blocking
|
|
22
|
+
* server loop can wait on a single word and still service any number of clients.
|
|
23
|
+
*
|
|
24
|
+
* ## Channel layout
|
|
25
|
+
*
|
|
26
|
+
* One `SharedArrayBuffer`, `CHANNEL_HEADER_BYTES` (64) of `Int32Array` header followed by a byte
|
|
27
|
+
* payload region (`DEFAULT_PAYLOAD_BYTES`, 64 KiB, chosen at channel creation):
|
|
28
|
+
*
|
|
29
|
+
* offset size as name
|
|
30
|
+
* ------ ---- -------- ------------------------------------------------------------------
|
|
31
|
+
* 0 4 int32 HEADER_STATE the word both sides `Atomics.wait` / `notify` on
|
|
32
|
+
* 4 4 int32 HEADER_OPCODE `OPCODE_*`, written by the client
|
|
33
|
+
* 8 4 int32 HEADER_REQUEST request bytes valid in the payload region
|
|
34
|
+
* 12 4 int32 HEADER_RESPONSE response bytes valid in the payload region
|
|
35
|
+
* 16 4 int32 HEADER_ERRNO 0, or the WASI preview1 errno of a file rejection
|
|
36
|
+
* 20 4 int32 HEADER_RESULT_LO low 32 bits of the unsigned 64-bit result
|
|
37
|
+
* 24 4 int32 HEADER_RESULT_HI high 32 bits of the unsigned 64-bit result
|
|
38
|
+
* 28 4 int32 HEADER_SEQUENCE the client's monotonic request number
|
|
39
|
+
* 32 4 int32 HEADER_FAULT `FAULT_*` — a transport/store failure, not a file one
|
|
40
|
+
* 36 4 int32 HEADER_PAYLOAD payload capacity in bytes (written once at creation)
|
|
41
|
+
* 40 24 int32[6] reserved, always zero
|
|
42
|
+
* 64 … bytes payload region
|
|
43
|
+
*
|
|
44
|
+
* `HEADER_STATE` is the whole handshake:
|
|
45
|
+
*
|
|
46
|
+
* STATE_IDLE (0) ──client publishes──→ STATE_REQUEST (1) ──server answers──→ STATE_RESPONSE (2)
|
|
47
|
+
* ↑ │ │
|
|
48
|
+
* └─────────────client consumes─────────┼─────────────────────────────────────┘
|
|
49
|
+
* └──server rejects the client──→ STATE_DETACHED (3)
|
|
50
|
+
*
|
|
51
|
+
* `STATE_DETACHED` is terminal: the server has closed the client's descriptors and dropped it, and
|
|
52
|
+
* every later client call throws instead of blocking forever.
|
|
53
|
+
*
|
|
54
|
+
* ## Doorbell layout
|
|
55
|
+
*
|
|
56
|
+
* A small separate `SharedArrayBuffer`, `DOORBELL_BYTES` (16) of `Int32Array`:
|
|
57
|
+
*
|
|
58
|
+
* index name meaning
|
|
59
|
+
* ----- ---------------- ----------------------------------------------------------------
|
|
60
|
+
* 0 DOORBELL_TICKET incremented by any client that publishes a request; the word the
|
|
61
|
+
* server's blocking loop waits on
|
|
62
|
+
* 1 DOORBELL_RUNNING 1 while the server should keep looping, 0 to ask it to return
|
|
63
|
+
* 2 reserved
|
|
64
|
+
* 3 reserved
|
|
65
|
+
*
|
|
66
|
+
* The server reads `DOORBELL_TICKET` BEFORE it scans the channels and waits on that observed value,
|
|
67
|
+
* so a request published during the scan makes the wait return `not-equal` immediately rather than
|
|
68
|
+
* being missed.
|
|
69
|
+
*
|
|
70
|
+
* ## Ordering
|
|
71
|
+
*
|
|
72
|
+
* Nothing in the payload region is atomic, and nothing needs to be. Each side writes its payload with
|
|
73
|
+
* ordinary stores and then publishes with `Atomics.store` on `HEADER_STATE`; the other side observes
|
|
74
|
+
* with `Atomics.load` on the same word before touching the payload. That store/load pair is the
|
|
75
|
+
* release/acquire edge, so every payload byte written before the publish is visible after the observe.
|
|
76
|
+
*
|
|
77
|
+
* ## Encoding
|
|
78
|
+
*
|
|
79
|
+
* Payloads are little-endian. Paths — and a symbolic link's TARGET, which is a path the store never
|
|
80
|
+
* walks — are `u32` byte length followed by UTF-8 bytes; sizes, offsets and
|
|
81
|
+
* timestamps are unsigned 64-bit (`bigint`) because a virtual file may exceed 2^53 in principle and
|
|
82
|
+
* the core store speaks `bigint` throughout. Byte counts that cannot exceed the payload region stay
|
|
83
|
+
* `u32`. The single numeric answer of an operation travels in the header's 64-bit result pair, not in
|
|
84
|
+
* the payload, so a read reply is nothing but its bytes.
|
|
85
|
+
*/
|
|
86
|
+
import type { FsErrorName } from "../core/errors";
|
|
87
|
+
/** Int32 slot indices of the channel header. */
|
|
88
|
+
export declare const HEADER_STATE = 0;
|
|
89
|
+
export declare const HEADER_OPCODE = 1;
|
|
90
|
+
export declare const HEADER_REQUEST = 2;
|
|
91
|
+
export declare const HEADER_RESPONSE = 3;
|
|
92
|
+
export declare const HEADER_ERRNO = 4;
|
|
93
|
+
export declare const HEADER_RESULT_LO = 5;
|
|
94
|
+
export declare const HEADER_RESULT_HI = 6;
|
|
95
|
+
export declare const HEADER_SEQUENCE = 7;
|
|
96
|
+
export declare const HEADER_FAULT = 8;
|
|
97
|
+
export declare const HEADER_PAYLOAD = 9;
|
|
98
|
+
export declare const CHANNEL_HEADER_SLOTS = 16;
|
|
99
|
+
export declare const CHANNEL_HEADER_BYTES: number;
|
|
100
|
+
/** `HEADER_STATE` values. */
|
|
101
|
+
export declare const STATE_IDLE = 0;
|
|
102
|
+
export declare const STATE_REQUEST = 1;
|
|
103
|
+
export declare const STATE_RESPONSE = 2;
|
|
104
|
+
export declare const STATE_DETACHED = 3;
|
|
105
|
+
/** Int32 slot indices of the doorbell. */
|
|
106
|
+
export declare const DOORBELL_TICKET = 0;
|
|
107
|
+
export declare const DOORBELL_RUNNING = 1;
|
|
108
|
+
export declare const DOORBELL_SLOTS = 4;
|
|
109
|
+
export declare const DOORBELL_BYTES: number;
|
|
110
|
+
/** The default payload region: large enough that a Postgres 8 KiB page round-trips in one request. */
|
|
111
|
+
export declare const DEFAULT_PAYLOAD_BYTES: number;
|
|
112
|
+
/** A payload region below this cannot hold the fixed part of every request. */
|
|
113
|
+
export declare const MIN_PAYLOAD_BYTES = 1024;
|
|
114
|
+
/**
|
|
115
|
+
* `HEADER_FAULT` values. A fault is NOT a file rejection: `HEADER_ERRNO` carries those and leaves the
|
|
116
|
+
* client working. A fault means the transport or the store itself failed.
|
|
117
|
+
*/
|
|
118
|
+
export declare const FAULT_NONE = 0;
|
|
119
|
+
/** The client violated the protocol (unknown opcode, impossible length, truncated payload). */
|
|
120
|
+
export declare const FAULT_PROTOCOL = 1;
|
|
121
|
+
/** The store threw something that is not an `FsError` — it is very likely poisoned. */
|
|
122
|
+
export declare const FAULT_STORE = 2;
|
|
123
|
+
/** The server rejected or dropped the client for a reason of its own (explicit `detach`). */
|
|
124
|
+
export declare const FAULT_DETACHED = 3;
|
|
125
|
+
/** Every operation the broker speaks. */
|
|
126
|
+
export declare const OPCODE_OPEN = 1;
|
|
127
|
+
export declare const OPCODE_CLOSE = 2;
|
|
128
|
+
export declare const OPCODE_READ = 3;
|
|
129
|
+
export declare const OPCODE_WRITE = 4;
|
|
130
|
+
export declare const OPCODE_FSYNC = 5;
|
|
131
|
+
export declare const OPCODE_FSTAT = 6;
|
|
132
|
+
export declare const OPCODE_STAT = 7;
|
|
133
|
+
export declare const OPCODE_LSTAT = 8;
|
|
134
|
+
export declare const OPCODE_READDIR = 9;
|
|
135
|
+
export declare const OPCODE_MKDIR = 10;
|
|
136
|
+
export declare const OPCODE_RMDIR = 11;
|
|
137
|
+
export declare const OPCODE_UNLINK = 12;
|
|
138
|
+
export declare const OPCODE_RENAME = 13;
|
|
139
|
+
export declare const OPCODE_TRUNCATE = 14;
|
|
140
|
+
export declare const OPCODE_SIZE = 15;
|
|
141
|
+
export declare const OPCODE_SYMLINK = 16;
|
|
142
|
+
export declare const OPCODE_READLINK = 17;
|
|
143
|
+
export declare function isKnownOpcode(opcode: number): boolean;
|
|
144
|
+
/**
|
|
145
|
+
* POSIX/WASI-shaped open bits. The wire carries these, never the core's node-style flag string: a WASI
|
|
146
|
+
* `path_open` maps its `oflags`/`fdflags`/`fs_rights_base` onto them directly, and the server is the
|
|
147
|
+
* only place that has to know the core's string vocabulary.
|
|
148
|
+
*/
|
|
149
|
+
export declare const O_RDONLY = 0;
|
|
150
|
+
export declare const O_WRONLY = 1;
|
|
151
|
+
export declare const O_RDWR = 2;
|
|
152
|
+
export declare const O_ACCMODE = 3;
|
|
153
|
+
export declare const O_CREAT = 64;
|
|
154
|
+
export declare const O_EXCL = 128;
|
|
155
|
+
export declare const O_TRUNC = 512;
|
|
156
|
+
export declare const O_APPEND = 1024;
|
|
157
|
+
/**
|
|
158
|
+
* Refuse to follow a symbolic link on the FINAL component. Linux's own bit value, and the wire form
|
|
159
|
+
* of a WASI `path_open` whose lookup flags omit `SYMLINK_FOLLOW`.
|
|
160
|
+
*/
|
|
161
|
+
export declare const O_NOFOLLOW = 131072;
|
|
162
|
+
/** The stat shape on the wire: `kind` + mode + size + the three timestamps. */
|
|
163
|
+
export declare const STAT_KIND_FILE = 0;
|
|
164
|
+
export declare const STAT_KIND_DIRECTORY = 1;
|
|
165
|
+
export declare const STAT_KIND_SYMLINK = 2;
|
|
166
|
+
export declare const STAT_BYTES: number;
|
|
167
|
+
/** A `readdir` reply that ran out of payload room reports the cursor to resume from; -1 means done. */
|
|
168
|
+
export declare const READDIR_DONE = -1;
|
|
169
|
+
/**
|
|
170
|
+
* How the server should satisfy one open request with the core's fixed flag-string vocabulary
|
|
171
|
+
* (`r`, `r+`, `w`, `w+`, `wx`, `wx+`, `a`, `a+`, `ax`, `ax+`).
|
|
172
|
+
*
|
|
173
|
+
* `readable`/`writable` are the access the CLIENT asked for, which is not always what `coreFlags`
|
|
174
|
+
* grants: the core has no "create without truncating and without appending" and no write-only
|
|
175
|
+
* non-truncating mode, so those requests open a wider core descriptor and the broker enforces the
|
|
176
|
+
* requested access itself on every later read/write.
|
|
177
|
+
*/
|
|
178
|
+
export interface OpenPlan {
|
|
179
|
+
/** The core flag string to try first. */
|
|
180
|
+
readonly coreFlags: string;
|
|
181
|
+
/** Used only when `coreFlags` fails with ENOENT — the create-without-truncate two-step. */
|
|
182
|
+
readonly fallbackFlags: string | undefined;
|
|
183
|
+
/** `O_TRUNC` without `O_CREAT`: truncate the existing path to zero before opening. */
|
|
184
|
+
readonly truncateFirst: boolean;
|
|
185
|
+
/** No `O_CREAT`, but `coreFlags` would create: the server must prove the path exists first. */
|
|
186
|
+
readonly requireExisting: boolean;
|
|
187
|
+
/** The access the client asked for, enforced by the broker on top of the core descriptor. */
|
|
188
|
+
readonly readable: boolean;
|
|
189
|
+
readonly writable: boolean;
|
|
190
|
+
/** `false` for `O_NOFOLLOW`: a final component that IS a symbolic link must answer `ELOOP`. */
|
|
191
|
+
readonly follow: boolean;
|
|
192
|
+
}
|
|
193
|
+
/**
|
|
194
|
+
* Translate POSIX open bits into the core's vocabulary, or reject the combination with `EINVAL`.
|
|
195
|
+
*
|
|
196
|
+
* Rejected because they are meaningless rather than merely unsupported: an unknown bit, `O_EXCL`
|
|
197
|
+
* without `O_CREAT`, `O_TRUNC` with `O_APPEND`, and a read-only request that also creates,
|
|
198
|
+
* truncates, or appends.
|
|
199
|
+
*/
|
|
200
|
+
export declare function planOpen(flags: number): OpenPlan;
|
|
201
|
+
/** Thrown when a payload cannot hold what a caller is trying to put in it. */
|
|
202
|
+
export declare class PayloadOverflowError extends Error {
|
|
203
|
+
constructor(needed: number, capacity: number);
|
|
204
|
+
}
|
|
205
|
+
/** Thrown when a payload does not decode — always a protocol violation by the peer that wrote it. */
|
|
206
|
+
export declare class PayloadDecodeError extends Error {
|
|
207
|
+
constructor(message: string);
|
|
208
|
+
}
|
|
209
|
+
/** Sequential little-endian writer over a channel's payload region. */
|
|
210
|
+
export declare class PayloadWriter {
|
|
211
|
+
#private;
|
|
212
|
+
constructor(payload: Uint8Array);
|
|
213
|
+
get length(): number;
|
|
214
|
+
get remaining(): number;
|
|
215
|
+
u8(value: number): void;
|
|
216
|
+
u32(value: number): void;
|
|
217
|
+
i32(value: number): void;
|
|
218
|
+
u64(value: bigint): void;
|
|
219
|
+
bytes(source: Uint8Array): void;
|
|
220
|
+
string(value: string): void;
|
|
221
|
+
/**
|
|
222
|
+
* Discard everything written after `to`, backing out a field that did not fit. A `string` reserves
|
|
223
|
+
* its length prefix before its bytes, so a name that overflows can leave four bytes behind.
|
|
224
|
+
*/
|
|
225
|
+
rewind(to: number): void;
|
|
226
|
+
/**
|
|
227
|
+
* A mutable view over `count` bytes already written at `at` — for a counter that has to be reserved
|
|
228
|
+
* before its value is known (a `readdir` page fills until the payload runs out).
|
|
229
|
+
*/
|
|
230
|
+
patch(at: number, count: number): DataView;
|
|
231
|
+
}
|
|
232
|
+
/** Sequential little-endian reader over a channel's payload region. */
|
|
233
|
+
export declare class PayloadReader {
|
|
234
|
+
#private;
|
|
235
|
+
constructor(payload: Uint8Array, length: number);
|
|
236
|
+
get remaining(): number;
|
|
237
|
+
u8(): number;
|
|
238
|
+
u32(): number;
|
|
239
|
+
i32(): number;
|
|
240
|
+
u64(): bigint;
|
|
241
|
+
bytes(count: number): Uint8Array;
|
|
242
|
+
string(): string;
|
|
243
|
+
}
|
|
244
|
+
/** Split an unsigned 64-bit result into the header's low/high `int32` pair. */
|
|
245
|
+
export declare function splitResult(value: bigint): {
|
|
246
|
+
readonly lo: number;
|
|
247
|
+
readonly hi: number;
|
|
248
|
+
};
|
|
249
|
+
/** Rejoin the header's low/high `int32` pair into an unsigned 64-bit result. */
|
|
250
|
+
export declare function joinResult(lo: number, hi: number): bigint;
|
|
251
|
+
/** The stat shape both sides exchange; `bigint` everywhere the core is `bigint`. */
|
|
252
|
+
export interface BrokerStat {
|
|
253
|
+
/** `symlink` only ever comes back from `lstat`; `size` is then the target's UTF-8 byte length. */
|
|
254
|
+
readonly kind: "directory" | "file" | "symlink";
|
|
255
|
+
readonly mode: number;
|
|
256
|
+
readonly size: bigint;
|
|
257
|
+
readonly atimeMs: bigint;
|
|
258
|
+
readonly mtimeMs: bigint;
|
|
259
|
+
readonly ctimeMs: bigint;
|
|
260
|
+
}
|
|
261
|
+
export declare function writeStat(writer: PayloadWriter, stat: BrokerStat): void;
|
|
262
|
+
export declare function readStat(reader: PayloadReader): BrokerStat;
|
|
263
|
+
/** A channel's two shared buffers, in the form that survives `postMessage`. */
|
|
264
|
+
export interface RepackedChannelTransfer {
|
|
265
|
+
readonly id: number;
|
|
266
|
+
readonly channel: SharedArrayBuffer;
|
|
267
|
+
readonly doorbell: SharedArrayBuffer;
|
|
268
|
+
}
|
|
269
|
+
/**
|
|
270
|
+
* The shared word one blocking server loop waits on. Both sides hold the same buffer; a client only
|
|
271
|
+
* ever rings it, and only the host that created it may ask the loop to stop.
|
|
272
|
+
*/
|
|
273
|
+
export declare class RepackedDoorbell {
|
|
274
|
+
#private;
|
|
275
|
+
readonly buffer: SharedArrayBuffer;
|
|
276
|
+
private constructor();
|
|
277
|
+
static create(): RepackedDoorbell;
|
|
278
|
+
/** Rebuild the doorbell around a buffer that arrived over `postMessage`. */
|
|
279
|
+
static attach(buffer: SharedArrayBuffer): RepackedDoorbell;
|
|
280
|
+
/** The value a server must observe BEFORE it scans, so a concurrent request cannot be missed. */
|
|
281
|
+
ticket(): number;
|
|
282
|
+
/** Announce that some channel now holds a request. */
|
|
283
|
+
ring(): void;
|
|
284
|
+
running(): boolean;
|
|
285
|
+
/**
|
|
286
|
+
* Ask a blocking `serveForever()` to return. This is the only way to stop it from another thread:
|
|
287
|
+
* once inside the loop the server never reaches its own event loop, so `postMessage` cannot reach it.
|
|
288
|
+
*/
|
|
289
|
+
requestStop(): void;
|
|
290
|
+
/** Undo a `requestStop()` so the same doorbell can drive another loop. */
|
|
291
|
+
resume(): void;
|
|
292
|
+
/** Block until the ticket leaves `observed`, or the timeout elapses. */
|
|
293
|
+
wait(observed: number, timeoutMs: number): "ok" | "not-equal" | "timed-out";
|
|
294
|
+
/** The non-blocking form, for a host that must not park its thread. */
|
|
295
|
+
waitAsync(observed: number, timeoutMs: number): Promise<"ok" | "not-equal" | "timed-out">;
|
|
296
|
+
}
|
|
297
|
+
/**
|
|
298
|
+
* One client's request/response channel. Both the client and the server hold an instance over the
|
|
299
|
+
* same `SharedArrayBuffer`; neither owns the memory, and nothing but the header words is atomic.
|
|
300
|
+
*/
|
|
301
|
+
export declare class RepackedChannel {
|
|
302
|
+
readonly id: number;
|
|
303
|
+
readonly buffer: SharedArrayBuffer;
|
|
304
|
+
readonly doorbell: RepackedDoorbell;
|
|
305
|
+
readonly header: Int32Array;
|
|
306
|
+
readonly payload: Uint8Array;
|
|
307
|
+
private constructor();
|
|
308
|
+
static create(options: {
|
|
309
|
+
id: number;
|
|
310
|
+
doorbell: RepackedDoorbell;
|
|
311
|
+
payloadBytes?: number;
|
|
312
|
+
}): RepackedChannel;
|
|
313
|
+
/** Rebuild a channel around buffers that arrived over `postMessage`. */
|
|
314
|
+
static attach(transfer: RepackedChannelTransfer): RepackedChannel;
|
|
315
|
+
/** The shape to hand to `postMessage`. */
|
|
316
|
+
transfer(): RepackedChannelTransfer;
|
|
317
|
+
get payloadBytes(): number;
|
|
318
|
+
state(): number;
|
|
319
|
+
}
|
|
320
|
+
/** The errno of a rejection, or `undefined` when it is not a plain file rejection. */
|
|
321
|
+
export declare function errnoOf(cause: unknown): number | undefined;
|
|
322
|
+
/** The core error name behind a wire errno, or `undefined` for a code the core never produces. */
|
|
323
|
+
export declare function fsErrorNameOf(code: number): FsErrorName | undefined;
|
|
324
|
+
/** Readable form of a wire errno, for a message. */
|
|
325
|
+
export declare function errnoName(code: number): string;
|
|
326
|
+
//# sour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,CAAC,MAAM,EAAE,iBAAiB,CAAC;IACnC,QAAQ,CAAC,QAAQ,EAAE,gBAAgB,CAAC;IACpC,QAAQ,CAAC,MAAM,EAAE,UAAU,CAAC;IAC5B,QAAQ,CAAC,OAAO,EAAE,UAAU,CAAC;IAE7B,OAAO,eAMN;IAED,MAAM,CAAC,MAAM,CAAC,OAAO,EAAE;QAAE,EAAE,EAAE,MAAM,CAAC;QAAC,QAAQ,EAAE,gBAAgB,CAAC;QAAC,YAAY,CAAC,EAAE,MAAM,CAAA;KAAE,GAAG,eAAe,CAgBzG;IAED,wEAAwE;IACxE,MAAM,CAAC,MAAM,CAAC,QAAQ,EAAE,uBAAuB,GAAG,eAAe,CAWhE;IAED,0CAA0C;IAC1C,QAAQ,IAAI,uBAAuB,CAElC;IAED,IAAI,YAAY,IAAI,MAAM,CAEzB;IAED,KAAK,IAAI,MAAM,CAEd;CACF;AAED,sFAAsF;AACtF,wBAAgB,OAAO,CAAC,KAAK,EAAE,OAAO,GAAG,MAAM,GAAG,SAAS,CAE1D;AAED,kGAAkG;AAClG,wBAAgB,aAAa,CAAC,IAAI,EAAE,MAAM,GAAG,WAAW,GAAG,SAAS,CAKnE;AAED,oDAAoD;AACpD,wBAAgB,SAAS,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAE9C"}
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `RepackedSyncBroker` — the single owner of one `RepackedVfs`, answering synchronous file requests
|
|
3
|
+
* that arrive over `SharedArrayBuffer` channels.
|
|
4
|
+
*
|
|
5
|
+
* The broker is meant to be the only thing on its thread. A backend running wasm parks in futexes and
|
|
6
|
+
* cannot await anything, so it publishes a request and blocks; the broker must therefore never block on
|
|
7
|
+
* a promise between reading a request and writing its answer. Every handler here is synchronous, and
|
|
8
|
+
* the store's own API is synchronous end to end.
|
|
9
|
+
*
|
|
10
|
+
* Three loop shapes are offered:
|
|
11
|
+
*
|
|
12
|
+
* - `serveForever()` parks the thread in `Atomics.wait` between requests. It is the shape for a
|
|
13
|
+
* dedicated coordinator worker, and while it runs the thread never reaches its event loop — so
|
|
14
|
+
* `postMessage` cannot reach it and every channel must be attached BEFORE entering it. Ask it to
|
|
15
|
+
* return with `doorbell.requestStop()` from any thread holding the doorbell.
|
|
16
|
+
* - `serve()` is the same loop built on `Atomics.waitAsync`, for a host that must keep its event loop
|
|
17
|
+
* alive. Channels may be attached and detached at any time.
|
|
18
|
+
* - `serveOnce()` scans every attached channel once and returns without waiting, for a host that
|
|
19
|
+
* drives its own loop.
|
|
20
|
+
*
|
|
21
|
+
* Failure separation is the point of the class. A file rejection (`FsError`) becomes an errno in the
|
|
22
|
+
* reply header and nothing else happens. A store failure becomes `FAULT_STORE` in the reply, and the
|
|
23
|
+
* loop keeps running because every later request will fail the same way and the client decides what to
|
|
24
|
+
* do. A protocol violation detaches only the offending client, with a logged reason.
|
|
25
|
+
*/
|
|
26
|
+
import type { RepackedFileSystem } from "../core/repacked-vfs";
|
|
27
|
+
import type { RepackedChannel, RepackedDoorbell } from "./protocol";
|
|
28
|
+
export interface RepackedSyncBrokerOptions {
|
|
29
|
+
/**
|
|
30
|
+
* The store this broker owns. Nothing else may hold it. A `RepackedVfs` is the one-store form; a
|
|
31
|
+
* `MountedRepackedVfs` serves several stores as one tree, and the broker cannot tell them apart.
|
|
32
|
+
*/
|
|
33
|
+
readonly vfs: RepackedFileSystem;
|
|
34
|
+
/** The shared doorbell every attached channel rings. */
|
|
35
|
+
readonly doorbell: RepackedDoorbell;
|
|
36
|
+
/** The timestamp the broker supplies to every core call. Defaults to the wall clock. */
|
|
37
|
+
readonly now?: () => bigint;
|
|
38
|
+
/** Where a detach reason goes. Defaults to `console.warn`. */
|
|
39
|
+
readonly log?: (message: string) => void;
|
|
40
|
+
/**
|
|
41
|
+
* How long one blocking iteration parks before re-scanning anyway. Defaults to 250 ms. The protocol
|
|
42
|
+
* has no missed-wakeup window — the server observes the doorbell ticket BEFORE it scans, so a
|
|
43
|
+
* request published during the scan makes the wait return `not-equal` at once — so this is purely a
|
|
44
|
+
* heartbeat: it costs four idle wakeups a second and turns any future slip into a latency blip
|
|
45
|
+
* instead of a permanently parked backend. `Infinity` makes the loop a pure park.
|
|
46
|
+
*/
|
|
47
|
+
readonly pollIntervalMs?: number;
|
|
48
|
+
}
|
|
49
|
+
export declare class RepackedSyncBroker {
|
|
50
|
+
#private;
|
|
51
|
+
readonly doorbell: RepackedDoorbell;
|
|
52
|
+
constructor(options: RepackedSyncBrokerOptions);
|
|
53
|
+
/** Channel ids the broker currently serves. */
|
|
54
|
+
attachedIds(): number[];
|
|
55
|
+
/** Descriptors the broker currently holds for one client — the leak check after a detach. */
|
|
56
|
+
openFdCount(channelId?: number): number;
|
|
57
|
+
attach(channel: RepackedChannel): void;
|
|
58
|
+
/**
|
|
59
|
+
* Drop a client and close every descriptor it still holds. A backend that dies mid-query never leaks
|
|
60
|
+
* a descriptor into the store, and the store's exclusive handles are released the moment the LAST
|
|
61
|
+
* owner goes away rather than whenever a stale fd happens to be noticed.
|
|
62
|
+
*/
|
|
63
|
+
detach(channel: RepackedChannel | number, reason?: string): void;
|
|
64
|
+
/** Detach every client, closing all descriptors. The store itself is NOT closed. */
|
|
65
|
+
detachAll(reason?: string): void;
|
|
66
|
+
/**
|
|
67
|
+
* Scan every attached channel once and answer whatever is pending. Never blocks, never throws for a
|
|
68
|
+
* file or store error. Returns how many requests were answered.
|
|
69
|
+
*/
|
|
70
|
+
serveOnce(): number;
|
|
71
|
+
/**
|
|
72
|
+
* The blocking coordinator loop. Parks the thread in `Atomics.wait` on the doorbell between
|
|
73
|
+
* requests, so this thread's event loop never runs: attach every channel before calling it, and stop
|
|
74
|
+
* it with `doorbell.requestStop()` from another thread.
|
|
75
|
+
*/
|
|
76
|
+
serveForever(): void;
|
|
77
|
+
/**
|
|
78
|
+
* The same loop on `Atomics.waitAsync`, for a host that must not park its thread — the tab's main
|
|
79
|
+
* thread, or a worker that also has to receive `postMessage`. Channels may be attached and detached
|
|
80
|
+
* while it runs. Resolves when `doorbell.requestStop()` is called.
|
|
81
|
+
*/
|
|
82
|
+
serve(): Promise<void>;
|
|
83
|
+
}
|
|
84
|
+
//# sourceMappingURL=server.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"server.d.ts","sourceRoot":"","sources":["../../../src/opfs/broker/server.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AAGH,OAAO,KAAK,EAAE,kBAAkB,EAAgB,MAAM,sBAAsB,CAAC;AA4C7E,OAAO,KAAK,EAAE,eAAe,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAC;AAqCpE,MAAM,WAAW,yBAAyB;IACxC;;;OAGG;IACH,QAAQ,CAAC,GAAG,EAAE,kBAAkB,CAAC;IACjC,wDAAwD;IACxD,QAAQ,CAAC,QAAQ,EAAE,gBAAgB,CAAC;IACpC,wFAAwF;IACxF,QAAQ,CAAC,GAAG,CAAC,EAAE,MAAM,MAAM,CAAC;IAC5B,8DAA8D;IAC9D,QAAQ,CAAC,GAAG,CAAC,EAAE,CAAC,OAAO,EAAE,MAAM,KAAK,IAAI,CAAC;IACzC;;;;;;OAMG;IACH,QAAQ,CAAC,cAAc,CAAC,EAAE,MAAM,CAAC;CAClC;AAED,qBAAa,kBAAkB;;IAC7B,QAAQ,CAAC,QAAQ,EAAE,gBAAgB,CAAC;IAQpC,YAAY,OAAO,EAAE,yBAAyB,EAM7C;IAED,+CAA+C;IAC/C,WAAW,IAAI,MAAM,EAAE,CAEtB;IAED,6FAA6F;IAC7F,WAAW,CAAC,SAAS,CAAC,EAAE,MAAM,GAAG,MAAM,CAOtC;IAED,MAAM,CAAC,OAAO,EAAE,eAAe,GAAG,IAAI,CAMrC;IAED;;;;OAIG;IACH,MAAM,CAAC,OAAO,EAAE,eAAe,GAAG,MAAM,EAAE,MAAM,SAAyB,GAAG,IAAI,CAE/E;IAgBD,oFAAoF;IACpF,SAAS,CAAC,MAAM,SAAyB,GAAG,IAAI,CAE/C;IAED;;;OAGG;IACH,SAAS,IAAI,MAAM,CAQlB;IAED;;;;OAIG;IACH,YAAY,IAAI,IAAI,CAWnB;IAED;;;;OAIG;IACG,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC,CAW3B;CAmRF"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"checksum.d.ts","sourceRoot":"","sources":["../../../src/opfs/core/checksum.ts"],"names":[],"mappings":"AAmEA,wBAAgB,KAAK,CAAC,KAAK,EAAE,UAAU,GAAG,MAAM,CAG/C;AAED,wBAAgB,oBAAoB,CAAC,KAAK,EAAE,UAAU,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,MAAM,CAY9F"}
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
import type { MetadataFile, TxnRecord, VfsState } from "./state-machine";
|
|
2
|
+
export declare const ARENA_HEADER_CHECKSUM_OFFSET = 24;
|
|
3
|
+
export declare const METADATA_HEADER_BYTES = 80;
|
|
4
|
+
export declare const TXN_FRAME_HEADER_BYTES = 48;
|
|
5
|
+
export declare const ACTIVATION_SLOT_BYTES = 128;
|
|
6
|
+
export declare const METADATA_HEADER_CHECKSUM_OFFSET = 64;
|
|
7
|
+
export declare const FRAME_CHECKSUM_OFFSET = 40;
|
|
8
|
+
export declare const ACTIVATION_CHECKSUM_OFFSET = 52;
|
|
9
|
+
export interface ArenaHeader {
|
|
10
|
+
extentSize: number;
|
|
11
|
+
limitsProfileVersion: number;
|
|
12
|
+
formatVersion: number;
|
|
13
|
+
}
|
|
14
|
+
export declare function encodeArenaHeader(options: {
|
|
15
|
+
extentSize: number;
|
|
16
|
+
}): Uint8Array;
|
|
17
|
+
export declare function decodeArenaHeader(bytes: Uint8Array, configuredExtentSize?: number): ArenaHeader;
|
|
18
|
+
export interface DecodedMetadataBase {
|
|
19
|
+
state: VfsState;
|
|
20
|
+
payloadBytes: number;
|
|
21
|
+
baseEnd: bigint;
|
|
22
|
+
baseDigest: number;
|
|
23
|
+
}
|
|
24
|
+
export interface MetadataBaseHeader {
|
|
25
|
+
formatVersion: number;
|
|
26
|
+
limitsProfileVersion: number;
|
|
27
|
+
generation: bigint;
|
|
28
|
+
extentSize: number;
|
|
29
|
+
metadataFileCode: number;
|
|
30
|
+
rootInodeId: bigint;
|
|
31
|
+
payloadLength: number;
|
|
32
|
+
availableCount: number;
|
|
33
|
+
quarantineCount: number;
|
|
34
|
+
baseEnd: bigint;
|
|
35
|
+
}
|
|
36
|
+
export declare function inspectMetadataBaseHeader(header: Uint8Array): MetadataBaseHeader;
|
|
37
|
+
export declare function encodeMetadataBase(state: VfsState): Uint8Array;
|
|
38
|
+
/** @internal The caller must have validated this exact state immediately before encoding it. */
|
|
39
|
+
export declare function encodeValidatedMetadataBase(state: VfsState): Uint8Array;
|
|
40
|
+
export declare function decodeMetadataBase(bytes: Uint8Array): DecodedMetadataBase;
|
|
41
|
+
export interface TxnFrame {
|
|
42
|
+
generation: bigint;
|
|
43
|
+
sequence: bigint;
|
|
44
|
+
record: TxnRecord;
|
|
45
|
+
}
|
|
46
|
+
export interface TxnFrameHeader {
|
|
47
|
+
generation: bigint;
|
|
48
|
+
sequence: bigint;
|
|
49
|
+
payloadLength: number;
|
|
50
|
+
frameBytes: number;
|
|
51
|
+
}
|
|
52
|
+
export declare function txnFrameBytes(record: TxnRecord): number;
|
|
53
|
+
export declare function inspectTxnFrameHeader(header: Uint8Array): TxnFrameHeader;
|
|
54
|
+
export declare function encodeTxnFrame(frame: TxnFrame): Uint8Array;
|
|
55
|
+
export declare function decodeTxnFrame(bytes: Uint8Array): TxnFrame;
|
|
56
|
+
export interface ActivationRecord {
|
|
57
|
+
sequence: bigint;
|
|
58
|
+
metadataFile: MetadataFile;
|
|
59
|
+
generation: bigint;
|
|
60
|
+
baseEnd: bigint;
|
|
61
|
+
baseDigest: number;
|
|
62
|
+
}
|
|
63
|
+
export declare function encodeActivationSlot(record: ActivationRecord): Uint8Array;
|
|
64
|
+
export declare function decodeActivationSlot(bytes: Uint8Array): ActivationRecord;
|
|
65
|
+
export declare function tryDecodeActivationSlot(bytes: Uint8Array): ActivationRecord | null;
|
|
66
|
+
export declare function selectActivation(leftBytes: Uint8Array, rightBytes: Uint8Array): ActivationRecord;
|
|
67
|
+
export interface ActivationPairSelection {
|
|
68
|
+
selected: ActivationRecord;
|
|
69
|
+
other: ActivationRecord | null;
|
|
70
|
+
}
|
|
71
|
+
export declare function selectActivationPair(leftBytes: Uint8Array, rightBytes: Uint8Array): ActivationPairSelection;
|
|
72
|
+
export declare function metadataBaseDigest(bytes: Uint8Array): number;
|
|
73
|
+
//# sourceMappingURL=codec.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"codec.d.ts","sourceRoot":"","sources":["../../../src/opfs/core/codec.ts"],"names":[],"mappings":"AAmBA,OAAO,KAAK,EAKV,YAAY,EAEZ,SAAS,EACT,QAAQ,EACT,MAAM,iBAAiB,CAAC;AAUzB,eAAO,MAAM,4BAA4B,KAAK,CAAC;AAC/C,eAAO,MAAM,qBAAqB,KAAK,CAAC;AACxC,eAAO,MAAM,sBAAsB,KAAK,CAAC;AACzC,eAAO,MAAM,qBAAqB,MAAM,CAAC;AAEzC,eAAO,MAAM,+BAA+B,KAAK,CAAC;AAClD,eAAO,MAAM,qBAAqB,KAAK,CAAC;AACxC,eAAO,MAAM,0BAA0B,KAAK,CAAC;AAwP7C,MAAM,WAAW,WAAW;IAC1B,UAAU,EAAE,MAAM,CAAC;IACnB,oBAAoB,EAAE,MAAM,CAAC;IAC7B,aAAa,EAAE,MAAM,CAAC;CACvB;AAED,wBAAgB,iBAAiB,CAAC,OAAO,EAAE;IAAE,UAAU,EAAE,MAAM,CAAA;CAAE,GAAG,UAAU,CAU7E;AAED,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,UAAU,EAAE,oBAAoB,CAAC,EAAE,MAAM,GAAG,WAAW,CAyB/F;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AG,UAAU,CAgB1D;AAED,wBAAgB,cAAc,CAAC,KAAK,EAAE,UAAU,GAAG,QAAQ,CAY1D;AAED,MAAM,WAAW,gBAAgB;IAC/B,QAAQ,EAAE,MAAM,CAAC;IACjB,YAAY,EAAE,YAAY,CAAC;IAC3B,UAAU,EAAE,MAAM,CAAC;IACnB,OAAO,EAAE,MAAM,CAAC;IAChB,UAAU,EAAE,MAAM,CAAC;CACpB;AAED,wBAAgB,oBAAoB,CAAC,MAAM,EAAE,gBAAgB,GAAG,UAAU,CAmBzE;AAED,wBAAgB,oBAAoB,CAAC,KAAK,EAAE,UAAU,GAAG,gBAAgB,CAuBxE;AAED,wBAAgB,uBAAuB,CAAC,KAAK,EAAE,UAAU,GAAG,gBAAgB,GAAG,IAAI,CAOlF;AAED,wBAAgB,gBAAgB,CAAC,SAAS,EAAE,UAAU,EAAE,UAAU,EAAE,UAAU,GAAG,gBAAgB,CAEhG;AAED,MAAM,WAAW,uBAAuB;IACtC,QAAQ,EAAE,gBAAgB,CAAC;IAC3B,KAAK,EAAE,gBAAgB,GAAG,IAAI,CAAC;CAChC;AAED,wBAAgB,oBAAoB,CAAC,SAAS,EAAE,UAAU,EAAE,UAAU,EAAE,UAAU,GAAG,uBAAuB,CAc3G;AAED,wBAAgB,kBAAkB,CAAC,KAAK,EAAE,UAAU,GAAG,MAAM,CAE5D"}
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
export declare const FS_ERRNO: {
|
|
2
|
+
readonly EBADF: 8;
|
|
3
|
+
readonly EEXIST: 20;
|
|
4
|
+
readonly EINVAL: 28;
|
|
5
|
+
/** The core reports this only as {@link StoreFailedError}'s `code`: the store failed, not the caller. */
|
|
6
|
+
readonly EIO: 29;
|
|
7
|
+
readonly EISDIR: 31;
|
|
8
|
+
readonly ELOOP: 32;
|
|
9
|
+
readonly ENOENT: 44;
|
|
10
|
+
readonly ENOTDIR: 54;
|
|
11
|
+
readonly ENOTEMPTY: 55;
|
|
12
|
+
readonly EXDEV: 75;
|
|
13
|
+
};
|
|
14
|
+
export type FsErrorName = keyof typeof FS_ERRNO;
|
|
15
|
+
/** A normal virtual-filesystem rejection. The live store remains usable. */
|
|
16
|
+
export declare class FsError extends Error {
|
|
17
|
+
readonly code: number;
|
|
18
|
+
readonly operation: string | undefined;
|
|
19
|
+
readonly path: string | undefined;
|
|
20
|
+
constructor(name: FsErrorName, message: string, options?: {
|
|
21
|
+
operation?: string;
|
|
22
|
+
path?: string;
|
|
23
|
+
cause?: unknown;
|
|
24
|
+
});
|
|
25
|
+
}
|
|
26
|
+
/** A configured or format hard limit was reached. */
|
|
27
|
+
export declare class StoreLimitError extends Error {
|
|
28
|
+
readonly storeCode = "STORE_LIMIT";
|
|
29
|
+
constructor(message: string, options?: ErrorOptions);
|
|
30
|
+
}
|
|
31
|
+
/** Activated bytes violate format integrity or semantic invariants. */
|
|
32
|
+
export declare class CorruptStoreError extends Error {
|
|
33
|
+
readonly storeCode = "CORRUPT_STORE";
|
|
34
|
+
constructor(message: string, options?: ErrorOptions);
|
|
35
|
+
}
|
|
36
|
+
/** The store identifies a different format and must be deleted in full. */
|
|
37
|
+
export declare class StoreRecreationRequiredError extends Error {
|
|
38
|
+
readonly storeCode = "STORE_RECREATION_REQUIRED";
|
|
39
|
+
constructor(message: string, options?: ErrorOptions);
|
|
40
|
+
}
|
|
41
|
+
/** A supplied creation extent size disagrees with the existing store identity. */
|
|
42
|
+
export declare class ExtentSizeMismatchError extends Error {
|
|
43
|
+
readonly storeCode = "EXTENT_SIZE_MISMATCH";
|
|
44
|
+
constructor(expected: number, actual: number);
|
|
45
|
+
}
|
|
46
|
+
/** Another live instance owns at least one required exclusive OPFS handle. */
|
|
47
|
+
export declare class StoreOwnedError extends Error {
|
|
48
|
+
readonly storeCode = "STORE_OWNED";
|
|
49
|
+
constructor(options?: ErrorOptions);
|
|
50
|
+
}
|
|
51
|
+
/** The dedicated store directory contains an entry outside the exact owned set. */
|
|
52
|
+
export declare class UnexpectedStoreEntryError extends Error {
|
|
53
|
+
readonly storeCode = "UNEXPECTED_STORE_ENTRY";
|
|
54
|
+
constructor(entryName: string);
|
|
55
|
+
}
|
|
56
|
+
/** The host attempted a non-awaited sync, proving the factory wiring was bypassed. */
|
|
57
|
+
export declare class DurabilityModeMismatchError extends Error {
|
|
58
|
+
readonly storeCode = "DURABILITY_MODE_MISMATCH";
|
|
59
|
+
constructor();
|
|
60
|
+
}
|
|
61
|
+
/** The adapter was used after all owned handles were closed. */
|
|
62
|
+
export declare class StoreClosedError extends Error {
|
|
63
|
+
readonly storeCode = "STORE_CLOSED";
|
|
64
|
+
constructor();
|
|
65
|
+
}
|
|
66
|
+
/**
|
|
67
|
+
* The live instance is poisoned and retains its first terminal cause.
|
|
68
|
+
*
|
|
69
|
+
* It carries a numeric `code` (`EIO`), as `FsError` does, so an engine's filesystem bridge that maps
|
|
70
|
+
* coded errors to errnos (PGlite's) reports an I/O error to the engine instead of letting an exception
|
|
71
|
+
* unwind through it. It is deliberately NOT an `FsError`: an `FsError` leaves the store usable, a
|
|
72
|
+
* `StoreFailedError` means every later call fails the same way until close.
|
|
73
|
+
*/
|
|
74
|
+
export declare class StoreFailedError extends Error {
|
|
75
|
+
readonly storeCode = "STORE_FAILED";
|
|
76
|
+
readonly code: number;
|
|
77
|
+
readonly cause: unknown;
|
|
78
|
+
constructor(cause: unknown);
|
|
79
|
+
}
|
|
80
|
+
//# sourceMappingURL=errors.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../../../src/opfs/core/errors.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,QAAQ;aACnB,KAAK,EAAE,CAAC;aACR,MAAM,EAAE,EAAE;aACV,MAAM,EAAE,EAAE;IACV,yGAAyG;aACzG,GAAG,EAAE,EAAE;aACP,MAAM,EAAE,EAAE;aACV,KAAK,EAAE,EAAE;aACT,MAAM,EAAE,EAAE;aACV,OAAO,EAAE,EAAE;aACX,SAAS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YAAY,EAGjC;CACF;AAED,mFAAmF;AACnF,qBAAa,yBAA0B,SAAQ,KAAK;IAClD,QAAQ,CAAC,SAAS,4BAA4B;IAE9C,YAAY,SAAS,EAAE,MAAM,EAG5B;CACF;AAED,sFAAsF;AACtF,qBAAa,2BAA4B,SAAQ,KAAK;IACpD,QAAQ,CAAC,SAAS,8BAA8B;IAEhD,cAGC;CACF;AAED,gEAAgE;AAChE,qBAAa,gBAAiB,SAAQ,KAAK;IACzC,QAAQ,CAAC,SAAS,kBAAkB;IAEpC,cAGC;CACF;AAED;;;;;;;GAOG;AACH,qBAAa,gBAAiB,SAAQ,KAAK;IACzC,QAAQ,CAAC,SAAS,kBAAkB;IACpC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAgB;IACrC,SAAkB,KAAK,EAAE,OAAO,CAAC;IAEjC,YAAY,KAAK,EAAE,OAAO,EAIzB;CACF"}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The on-disk format identity. Bumped to 2 by the symlink entry kind: a format-1 reader meets an
|
|
3
|
+
* inode kind and a transaction record it cannot decode, and the recreate-only version policy
|
|
4
|
+
* (ADR-0048 §3) is the store's ONLY evolution mechanism — one build reads and writes exactly one
|
|
5
|
+
* version, and a store identifying another one is rejected with `StoreRecreationRequiredError`
|
|
6
|
+
* before any content mutation. There is no migration and never will be.
|
|
7
|
+
*/
|
|
8
|
+
export declare const FORMAT_VERSION = 2;
|
|
9
|
+
export declare const LIMITS_PROFILE_VERSION = 1;
|
|
10
|
+
export declare const ARENA_HEADER_BYTES = 8192;
|
|
11
|
+
export declare const MIN_EXTENT_BYTES = 8192;
|
|
12
|
+
export declare const MAX_EXTENT_BYTES: number;
|
|
13
|
+
export declare const DEFAULT_EXTENT_BYTES: number;
|
|
14
|
+
export declare const MAX_COMPONENT_BYTES = 255;
|
|
15
|
+
export declare const MAX_PATH_BYTES = 1024;
|
|
16
|
+
export declare const MAX_PATH_DEPTH = 32;
|
|
17
|
+
/** How many symbolic links one path resolution may traverse before it reports `ELOOP`. */
|
|
18
|
+
export declare const MAX_SYMLINK_HOPS = 32;
|
|
19
|
+
export declare const MAX_INODES = 65536;
|
|
20
|
+
export declare const MAX_EXTENTS_PER_INODE: number;
|
|
21
|
+
export declare const MAX_TOTAL_EXTENTS: number;
|
|
22
|
+
export declare const MAX_METADATA_BASE_READER_BYTES: number;
|
|
23
|
+
export declare const MAX_METADATA_BASE_WRITER_BYTES: number;
|
|
24
|
+
export declare const MAX_FRAME_PAYLOAD_BYTES: number;
|
|
25
|
+
export declare const MAX_ACTIVE_LOG_BYTES: number;
|
|
26
|
+
export declare const SOFT_ACTIVE_LOG_BYTES: number;
|
|
27
|
+
export declare const MAX_ACTIVE_LOG_FRAMES = 32768;
|
|
28
|
+
export declare const SOFT_ACTIVE_LOG_FRAMES = 16384;
|
|
29
|
+
export declare const MAX_U64: bigint;
|
|
30
|
+
export declare function validateExtentSize(value: number): number;
|
|
31
|
+
export declare function checkedU64(value: bigint, label: string): bigint;
|
|
32
|
+
export declare function checkedSafeNumber(value: bigint, label: string): number;
|
|
33
|
+
export declare function checkedAdd(left: bigint, right: bigint, label: string): bigint;
|
|
34
|
+
export declare function checkedMultiply(left: bigint, right: bigint, label: string): bigint;
|
|
35
|
+
//# sourceMappingURL=limits.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"limits.d.ts","sourceRoot":"","sources":["../../../src/opfs/core/limits.ts"],"names":[],"mappings":"AAEA;;;;;;GAMG;AACH,eAAO,MAAM,cAAc,IAAI,CAAC;AAChC,eAAO,MAAM,sBAAsB,IAAI,CAAC;AACxC,eAAO,MAAM,kBAAkB,OAAO,CAAC;AACvC,eAAO,MAAM,gBAAgB,OAAO,CAAC;AACrC,eAAO,MAAM,gBAAgB,QAAmB,CAAC;AACjD,eAAO,MAAM,oBAAoB,QAAY,CAAC;AAC9C,eAAO,MAAM,mBAAmB,MAAM,CAAC;AACvC,eAAO,MAAM,cA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