@minnowdb/core 0.6.9 → 0.7.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.
- package/dist/block-format/block.js +254 -325
- package/dist/block-format/checksum.js +30 -52
- package/dist/block-format/codecs.js +112 -125
- package/dist/block-format/column.js +187 -205
- package/dist/block-format/index.js +5 -1
- package/dist/block-format/physical.js +371 -387
- package/dist/block-format/types.js +4 -1
- package/dist/block-format/unicode.js +30 -39
- package/dist/date-value.d.ts +5 -0
- package/dist/date-value.js +71 -41
- package/dist/engine/artifact-cache.js +106 -116
- package/dist/engine/batch.js +36 -44
- package/dist/engine/buffered-writer.js +156 -158
- package/dist/engine/byte-estimates.js +20 -22
- package/dist/engine/cache-limits.js +24 -25
- package/dist/engine/cancellation.js +5 -3
- package/dist/engine/catalog.js +64 -73
- package/dist/engine/client.js +715 -780
- package/dist/engine/database.js +15952 -18465
- package/dist/engine/defaults.js +104 -111
- package/dist/engine/errors.js +113 -128
- package/dist/engine/fts.js +233 -280
- package/dist/engine/group-index.js +287 -321
- package/dist/engine/index.js +23 -12
- package/dist/engine/join-index.js +177 -186
- package/dist/engine/keyed-live.js +168 -173
- package/dist/engine/live-api.js +0 -1
- package/dist/engine/live-equal.js +32 -37
- package/dist/engine/live.js +603 -647
- package/dist/engine/memory.js +109 -111
- package/dist/engine/optimizer.d.ts +19 -1
- package/dist/engine/optimizer.js +2642 -2515
- package/dist/engine/point-read.d.ts +4 -2
- package/dist/engine/point-read.js +121 -171
- package/dist/engine/query-api.js +12 -3
- package/dist/engine/query-cache.js +61 -69
- package/dist/engine/query.d.ts +45 -0
- package/dist/engine/query.js +8506 -9375
- package/dist/engine/result-wire.js +221 -252
- package/dist/engine/schema-wire.js +97 -112
- package/dist/engine/schema.js +1099 -1254
- package/dist/engine/sort-keys.js +315 -389
- package/dist/engine/sql-domains.d.ts +7 -1
- package/dist/engine/sql-domains.js +648 -734
- package/dist/engine/sql-driver.js +0 -1
- package/dist/engine/sql-functions.d.ts +11 -0
- package/dist/engine/sql-functions.js +1092 -0
- package/dist/engine/sql-json.js +199 -218
- package/dist/engine/sql-semantics.d.ts +25 -4
- package/dist/engine/sql-semantics.js +579 -513
- package/dist/engine/typed-live.js +271 -293
- package/dist/engine/vector.d.ts +7 -1
- package/dist/engine/vector.js +4513 -4580
- package/dist/engine/worker-host.d.ts +8 -63
- package/dist/engine/worker-host.js +28 -1130
- package/dist/engine/worker-indexeddb.d.ts +1 -0
- package/dist/engine/worker-indexeddb.js +3 -0
- package/dist/engine/worker-memory.d.ts +1 -0
- package/dist/engine/worker-memory.js +3 -0
- package/dist/engine/worker-opfs.d.ts +1 -0
- package/dist/engine/worker-opfs.js +3 -0
- package/dist/engine/worker-server.d.ts +93 -0
- package/dist/engine/worker-server.js +999 -0
- package/dist/engine/worker-store-indexeddb.d.ts +2 -0
- package/dist/engine/worker-store-indexeddb.js +11 -0
- package/dist/engine/worker-store-memory.d.ts +2 -0
- package/dist/engine/worker-store-memory.js +6 -0
- package/dist/engine/worker-store-opfs.d.ts +2 -0
- package/dist/engine/worker-store-opfs.js +9 -0
- package/dist/engine/worker.js +0 -12
- package/dist/engine/write-block-planner.js +93 -100
- package/dist/plan/index.js +15 -16
- package/dist/plan/model.d.ts +9 -1
- package/dist/plan/model.js +20 -27
- package/dist/storage/index.js +0 -12
- package/dist/storage/indexeddb.js +11776 -13171
- package/dist/storage/memory.js +1198 -1241
- package/dist/storage/opfs/files.js +238 -295
- package/dist/storage/opfs/index.js +9 -3
- package/dist/storage/opfs/leader.js +4386 -4856
- package/dist/storage/opfs/rpc.js +223 -259
- package/dist/storage/opfs/snapshot-ledger.js +219 -260
- package/dist/storage/opfs/store.js +884 -1003
- package/dist/storage/persistence.js +59 -74
- package/dist/storage/snapshot-stream.js +788 -826
- package/dist/storage/snapshot.js +36 -37
- package/dist/storage/toolkit/extents.js +444 -520
- package/dist/storage/toolkit/index.js +28 -29
- package/dist/storage/toolkit/record-core.js +5792 -6377
- package/dist/storage/toolkit/sync-file.js +34 -42
- package/dist/storage/toolkit/wal.js +92 -127
- package/dist/storage/toolkit/wire.js +232 -256
- package/dist/storage/types.js +2952 -3228
- package/dist/testing/block-store-conformance.js +1556 -1629
- package/dist/testing/index.js +310 -291
- package/dist/testing/opfs-shim.js +280 -312
- package/dist/testing/simulator.js +496 -534
- package/dist/testing/sqllogictest.js +425 -365
- package/dist/transactions/index.js +1464 -1712
- package/dist/worker-protocol/index.js +70 -69
- package/package.json +20 -2
- package/postgres-feature-profile.json +15 -5
- package/sql-feature-matrix.json +252 -2
|
@@ -1,329 +1,297 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
directory.children.set(name, {
|
|
83
|
-
kind: "file",
|
|
84
|
-
name,
|
|
85
|
-
bytes: bytes.slice(),
|
|
86
|
-
lockHolder: existing?.lockHolder ?? null,
|
|
87
|
-
});
|
|
88
|
-
}
|
|
89
|
-
/** Test-side in-place corruption: existing sync handles observe the changed byte. */
|
|
90
|
-
corruptFileByte(path, offset) {
|
|
91
|
-
const node = this.#find(path);
|
|
92
|
-
if (node?.kind !== "file")
|
|
93
|
-
throw new Error(`Not a file: ${path}`);
|
|
94
|
-
if (!Number.isSafeInteger(offset) || offset < 0 || offset >= node.bytes.byteLength) {
|
|
95
|
-
throw new RangeError(`Invalid corruption offset ${String(offset)} for ${path}`);
|
|
96
|
-
}
|
|
97
|
-
node.bytes[offset] = (node.bytes[offset] ?? 0) ^ 0xff;
|
|
98
|
-
}
|
|
99
|
-
#find(path) {
|
|
100
|
-
let node = this.#rootNode;
|
|
101
|
-
for (const segment of path.split("/").filter((segment) => segment.length > 0)) {
|
|
102
|
-
if (node.kind !== "directory")
|
|
103
|
-
return undefined;
|
|
104
|
-
const child = node.children.get(segment);
|
|
105
|
-
if (child === undefined)
|
|
106
|
-
return undefined;
|
|
107
|
-
node = child;
|
|
108
|
-
}
|
|
109
|
-
return node;
|
|
110
|
-
}
|
|
1
|
+
class MemoryOpfs {
|
|
2
|
+
#rootNode = { kind: "directory", name: "", children: /* @__PURE__ */ new Map() };
|
|
3
|
+
#writeFault = null;
|
|
4
|
+
#deleteFault = null;
|
|
5
|
+
#transferLimit = null;
|
|
6
|
+
get root() {
|
|
7
|
+
return new ShimDirectoryHandle(this, this.#rootNode, "");
|
|
8
|
+
}
|
|
9
|
+
setWriteFault(fault) {
|
|
10
|
+
this.#writeFault = fault;
|
|
11
|
+
}
|
|
12
|
+
setDeleteFault(fault) {
|
|
13
|
+
this.#deleteFault = fault;
|
|
14
|
+
}
|
|
15
|
+
setTransferLimit(limit) {
|
|
16
|
+
this.#transferLimit = limit;
|
|
17
|
+
}
|
|
18
|
+
maybeFault(path, phase) {
|
|
19
|
+
this.#writeFault?.(path, phase);
|
|
20
|
+
}
|
|
21
|
+
maybeDeleteFault(path) {
|
|
22
|
+
this.#deleteFault?.(path);
|
|
23
|
+
}
|
|
24
|
+
limitTransfer(path, operation, requestedBytes, at) {
|
|
25
|
+
const limited = this.#transferLimit?.(path, operation, requestedBytes, at) ?? requestedBytes;
|
|
26
|
+
if (!Number.isSafeInteger(limited) || limited < 0 || limited > requestedBytes) {
|
|
27
|
+
throw new RangeError(`Invalid test transfer limit ${String(limited)} for ${String(requestedBytes)} requested bytes`);
|
|
28
|
+
}
|
|
29
|
+
return limited;
|
|
30
|
+
}
|
|
31
|
+
readFileBytes(path) {
|
|
32
|
+
const node = this.#find(path);
|
|
33
|
+
return node?.kind === "file" ? node.bytes.slice() : void 0;
|
|
34
|
+
}
|
|
35
|
+
writeFileBytes(path, bytes) {
|
|
36
|
+
const segments = path.split("/").filter((segment) => segment.length > 0);
|
|
37
|
+
const name = segments.pop();
|
|
38
|
+
if (name === void 0)
|
|
39
|
+
throw new Error("A file path cannot be empty");
|
|
40
|
+
let directory = this.#rootNode;
|
|
41
|
+
for (const segment of segments) {
|
|
42
|
+
let child = directory.children.get(segment);
|
|
43
|
+
if (child === void 0) {
|
|
44
|
+
child = { kind: "directory", name: segment, children: /* @__PURE__ */ new Map() };
|
|
45
|
+
directory.children.set(segment, child);
|
|
46
|
+
}
|
|
47
|
+
if (child.kind !== "directory")
|
|
48
|
+
throw new Error(`Not a directory: ${segment}`);
|
|
49
|
+
directory = child;
|
|
50
|
+
}
|
|
51
|
+
const existing = directory.children.get(name);
|
|
52
|
+
if (existing?.kind === "directory")
|
|
53
|
+
throw new Error(`Not a file: ${path}`);
|
|
54
|
+
directory.children.set(name, {
|
|
55
|
+
kind: "file",
|
|
56
|
+
name,
|
|
57
|
+
bytes: bytes.slice(),
|
|
58
|
+
lockHolder: existing?.lockHolder ?? null
|
|
59
|
+
});
|
|
60
|
+
}
|
|
61
|
+
corruptFileByte(path, offset) {
|
|
62
|
+
const node = this.#find(path);
|
|
63
|
+
if (node?.kind !== "file")
|
|
64
|
+
throw new Error(`Not a file: ${path}`);
|
|
65
|
+
if (!Number.isSafeInteger(offset) || offset < 0 || offset >= node.bytes.byteLength) {
|
|
66
|
+
throw new RangeError(`Invalid corruption offset ${String(offset)} for ${path}`);
|
|
67
|
+
}
|
|
68
|
+
node.bytes[offset] = (node.bytes[offset] ?? 0) ^ 255;
|
|
69
|
+
}
|
|
70
|
+
#find(path) {
|
|
71
|
+
let node = this.#rootNode;
|
|
72
|
+
for (const segment of path.split("/").filter((segment2) => segment2.length > 0)) {
|
|
73
|
+
if (node.kind !== "directory")
|
|
74
|
+
return void 0;
|
|
75
|
+
const child = node.children.get(segment);
|
|
76
|
+
if (child === void 0)
|
|
77
|
+
return void 0;
|
|
78
|
+
node = child;
|
|
79
|
+
}
|
|
80
|
+
return node;
|
|
81
|
+
}
|
|
111
82
|
}
|
|
112
83
|
function notFound(name) {
|
|
113
|
-
|
|
84
|
+
return new DOMException(`A requested file or directory could not be found: ${name}`, "NotFoundError");
|
|
114
85
|
}
|
|
115
86
|
function typeMismatch(name) {
|
|
116
|
-
|
|
87
|
+
return new DOMException(`The path is not of the requested type: ${name}`, "TypeMismatchError");
|
|
117
88
|
}
|
|
118
89
|
function locked(name) {
|
|
119
|
-
|
|
90
|
+
return new DOMException(`Access handles cannot be created if there is another open access handle: ${name}`, "NoModificationAllowedError");
|
|
120
91
|
}
|
|
121
92
|
class ShimDirectoryHandle {
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
yield handle;
|
|
213
|
-
}
|
|
214
|
-
[Symbol.asyncIterator]() {
|
|
215
|
-
return this.entries();
|
|
216
|
-
}
|
|
93
|
+
kind = "directory";
|
|
94
|
+
#shim;
|
|
95
|
+
#node;
|
|
96
|
+
#path;
|
|
97
|
+
constructor(shim, node, path) {
|
|
98
|
+
this.#shim = shim;
|
|
99
|
+
this.#node = node;
|
|
100
|
+
this.#path = path;
|
|
101
|
+
}
|
|
102
|
+
get name() {
|
|
103
|
+
return this.#node.name;
|
|
104
|
+
}
|
|
105
|
+
#childPath(name) {
|
|
106
|
+
return this.#path.length === 0 ? name : `${this.#path}/${name}`;
|
|
107
|
+
}
|
|
108
|
+
async getFileHandle(name, options) {
|
|
109
|
+
validateEntryName(name);
|
|
110
|
+
const existing = this.#node.children.get(name);
|
|
111
|
+
if (existing === void 0) {
|
|
112
|
+
if (options?.create !== true)
|
|
113
|
+
throw notFound(name);
|
|
114
|
+
this.#shim.maybeFault(this.#childPath(name), "create");
|
|
115
|
+
const node = { kind: "file", name, bytes: new Uint8Array(0), lockHolder: null };
|
|
116
|
+
this.#node.children.set(name, node);
|
|
117
|
+
return new ShimFileHandle(this.#shim, node, this.#childPath(name));
|
|
118
|
+
}
|
|
119
|
+
if (existing.kind !== "file")
|
|
120
|
+
throw typeMismatch(name);
|
|
121
|
+
return new ShimFileHandle(this.#shim, existing, this.#childPath(name));
|
|
122
|
+
}
|
|
123
|
+
async getDirectoryHandle(name, options) {
|
|
124
|
+
validateEntryName(name);
|
|
125
|
+
const existing = this.#node.children.get(name);
|
|
126
|
+
if (existing === void 0) {
|
|
127
|
+
if (options?.create !== true)
|
|
128
|
+
throw notFound(name);
|
|
129
|
+
this.#shim.maybeFault(this.#childPath(name), "create");
|
|
130
|
+
const node = { kind: "directory", name, children: /* @__PURE__ */ new Map() };
|
|
131
|
+
this.#node.children.set(name, node);
|
|
132
|
+
return new ShimDirectoryHandle(this.#shim, node, this.#childPath(name));
|
|
133
|
+
}
|
|
134
|
+
if (existing.kind !== "directory")
|
|
135
|
+
throw typeMismatch(name);
|
|
136
|
+
return new ShimDirectoryHandle(this.#shim, existing, this.#childPath(name));
|
|
137
|
+
}
|
|
138
|
+
async removeEntry(name, options) {
|
|
139
|
+
validateEntryName(name);
|
|
140
|
+
const existing = this.#node.children.get(name);
|
|
141
|
+
if (existing === void 0)
|
|
142
|
+
throw notFound(name);
|
|
143
|
+
this.#shim.maybeDeleteFault(this.#childPath(name));
|
|
144
|
+
if (existing.kind === "file") {
|
|
145
|
+
if (existing.lockHolder !== null)
|
|
146
|
+
throw locked(name);
|
|
147
|
+
} else if (options?.recursive !== true) {
|
|
148
|
+
if (existing.children.size > 0) {
|
|
149
|
+
throw new DOMException(`The directory is not empty: ${name}`, "InvalidModificationError");
|
|
150
|
+
}
|
|
151
|
+
} else {
|
|
152
|
+
assertSubtreeUnlocked(existing, name);
|
|
153
|
+
}
|
|
154
|
+
this.#node.children.delete(name);
|
|
155
|
+
}
|
|
156
|
+
async isSameEntry(other) {
|
|
157
|
+
return other instanceof ShimDirectoryHandle && other.#node === this.#node;
|
|
158
|
+
}
|
|
159
|
+
async resolve() {
|
|
160
|
+
return null;
|
|
161
|
+
}
|
|
162
|
+
async *entries() {
|
|
163
|
+
for (const [name, node] of [...this.#node.children.entries()]) {
|
|
164
|
+
if (this.#node.children.get(name) !== node)
|
|
165
|
+
continue;
|
|
166
|
+
yield [
|
|
167
|
+
name,
|
|
168
|
+
node.kind === "file" ? new ShimFileHandle(this.#shim, node, this.#childPath(name)) : new ShimDirectoryHandle(this.#shim, node, this.#childPath(name))
|
|
169
|
+
];
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
async *keys() {
|
|
173
|
+
for await (const [name] of this.entries())
|
|
174
|
+
yield name;
|
|
175
|
+
}
|
|
176
|
+
async *values() {
|
|
177
|
+
for await (const [, handle] of this.entries())
|
|
178
|
+
yield handle;
|
|
179
|
+
}
|
|
180
|
+
[Symbol.asyncIterator]() {
|
|
181
|
+
return this.entries();
|
|
182
|
+
}
|
|
217
183
|
}
|
|
218
184
|
function assertSubtreeUnlocked(node, name) {
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
}
|
|
185
|
+
for (const child of node.children.values()) {
|
|
186
|
+
if (child.kind === "file") {
|
|
187
|
+
if (child.lockHolder !== null)
|
|
188
|
+
throw locked(`${name}/${child.name}`);
|
|
189
|
+
} else {
|
|
190
|
+
assertSubtreeUnlocked(child, `${name}/${child.name}`);
|
|
191
|
+
}
|
|
192
|
+
}
|
|
228
193
|
}
|
|
229
194
|
function validateEntryName(name) {
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
195
|
+
if (name.length === 0 || name === "." || name === ".." || name.includes("/")) {
|
|
196
|
+
throw new TypeError(`Entry name is invalid: ${name}`);
|
|
197
|
+
}
|
|
233
198
|
}
|
|
234
199
|
class ShimFileHandle {
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
200
|
+
kind = "file";
|
|
201
|
+
#shim;
|
|
202
|
+
#node;
|
|
203
|
+
#path;
|
|
204
|
+
constructor(shim, node, path) {
|
|
205
|
+
this.#shim = shim;
|
|
206
|
+
this.#node = node;
|
|
207
|
+
this.#path = path;
|
|
208
|
+
}
|
|
209
|
+
get name() {
|
|
210
|
+
return this.#node.name;
|
|
211
|
+
}
|
|
212
|
+
async getFile() {
|
|
213
|
+
if (this.#node.lockHolder !== null)
|
|
214
|
+
throw locked(this.#node.name);
|
|
215
|
+
return new File([this.#node.bytes.slice()], this.#node.name);
|
|
216
|
+
}
|
|
217
|
+
async createSyncAccessHandle() {
|
|
218
|
+
if (this.#node.lockHolder !== null)
|
|
219
|
+
throw locked(this.#node.name);
|
|
220
|
+
const handle = new ShimSyncAccessHandle(this.#shim, this.#node, this.#path);
|
|
221
|
+
this.#node.lockHolder = handle;
|
|
222
|
+
return handle;
|
|
223
|
+
}
|
|
224
|
+
async isSameEntry(other) {
|
|
225
|
+
return other instanceof ShimFileHandle && other.#node === this.#node;
|
|
226
|
+
}
|
|
262
227
|
}
|
|
263
228
|
class ShimSyncAccessHandle {
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
229
|
+
#shim;
|
|
230
|
+
#node;
|
|
231
|
+
#path;
|
|
232
|
+
#closed = false;
|
|
233
|
+
constructor(shim, node, path) {
|
|
234
|
+
this.#shim = shim;
|
|
235
|
+
this.#node = node;
|
|
236
|
+
this.#path = path;
|
|
237
|
+
}
|
|
238
|
+
#assertOpen() {
|
|
239
|
+
if (this.#closed) {
|
|
240
|
+
throw new DOMException("The access handle is closed", "InvalidStateError");
|
|
241
|
+
}
|
|
242
|
+
}
|
|
243
|
+
getSize() {
|
|
244
|
+
this.#assertOpen();
|
|
245
|
+
return this.#node.bytes.byteLength;
|
|
246
|
+
}
|
|
247
|
+
read(buffer, options) {
|
|
248
|
+
this.#assertOpen();
|
|
249
|
+
const at = options?.at ?? 0;
|
|
250
|
+
const target = new Uint8Array(buffer.buffer, buffer.byteOffset, buffer.byteLength);
|
|
251
|
+
const limit = this.#shim.limitTransfer(this.#path, "read", target.byteLength, at);
|
|
252
|
+
const source = this.#node.bytes.subarray(at, at + limit);
|
|
253
|
+
target.set(source);
|
|
254
|
+
return source.byteLength;
|
|
255
|
+
}
|
|
256
|
+
write(buffer, options) {
|
|
257
|
+
this.#assertOpen();
|
|
258
|
+
this.#shim.maybeFault(this.#path, "write");
|
|
259
|
+
const at = options?.at ?? 0;
|
|
260
|
+
const requested = new Uint8Array(buffer.buffer, buffer.byteOffset, buffer.byteLength);
|
|
261
|
+
const limit = this.#shim.limitTransfer(this.#path, "write", requested.byteLength, at);
|
|
262
|
+
const source = requested.subarray(0, limit);
|
|
263
|
+
const end = at + source.byteLength;
|
|
264
|
+
if (source.byteLength > 0 && end > this.#node.bytes.byteLength) {
|
|
265
|
+
const grown = new Uint8Array(end);
|
|
266
|
+
grown.set(this.#node.bytes);
|
|
267
|
+
this.#node.bytes = grown;
|
|
268
|
+
}
|
|
269
|
+
this.#node.bytes.set(source, at);
|
|
270
|
+
return source.byteLength;
|
|
271
|
+
}
|
|
272
|
+
truncate(size) {
|
|
273
|
+
this.#assertOpen();
|
|
274
|
+
this.#shim.maybeFault(this.#path, "write");
|
|
275
|
+
if (size <= this.#node.bytes.byteLength) {
|
|
276
|
+
this.#node.bytes = this.#node.bytes.slice(0, size);
|
|
277
|
+
return;
|
|
278
|
+
}
|
|
279
|
+
const grown = new Uint8Array(size);
|
|
280
|
+
grown.set(this.#node.bytes);
|
|
281
|
+
this.#node.bytes = grown;
|
|
282
|
+
}
|
|
283
|
+
flush() {
|
|
284
|
+
this.#assertOpen();
|
|
285
|
+
this.#shim.maybeFault(this.#path, "flush");
|
|
286
|
+
}
|
|
287
|
+
close() {
|
|
288
|
+
if (this.#closed)
|
|
289
|
+
return;
|
|
290
|
+
this.#closed = true;
|
|
291
|
+
if (this.#node.lockHolder === this)
|
|
292
|
+
this.#node.lockHolder = null;
|
|
293
|
+
}
|
|
329
294
|
}
|
|
295
|
+
export {
|
|
296
|
+
MemoryOpfs
|
|
297
|
+
};
|