attraverso 0.3.0 → 0.4.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 +17 -7
- package/assets/memfs2opfs-B4SpaLa4.js +399 -0
- package/assets/migrations/0015_stormy_blindfold.sql +9 -0
- package/assets/migrations/meta/0015_snapshot.json +1668 -0
- package/assets/migrations/meta/_journal.json +7 -0
- package/assets/nodefs-DEelVsw6.js +23 -0
- package/assets/opfs-ahp-CDfgZf23.js +394 -0
- package/assets/postgres-DCJiA8An.js +4649 -0
- package/initdb.wasm +0 -0
- package/lib/index.js +2214 -1301
- package/migrations/0015_stormy_blindfold.sql +9 -0
- package/migrations/meta/0015_snapshot.json +1668 -0
- package/migrations/meta/_journal.json +7 -0
- package/package.json +2 -2
- package/pglite.data +1141 -1165
- package/pglite.wasm +0 -0
- package/server.js +54196 -46987
- package/viewer/assets/favicon-BUxCK25s.svg +13 -0
- package/viewer/assets/index-B4AZhw2f.js +45 -0
- package/viewer/assets/index-BuEyBnDM.css +1 -0
- package/viewer/index.html +3 -2
- package/assets/nodefs-MM0Ke5-7.js +0 -33
- package/assets/opfs-ahp-D4b2E8uR.js +0 -308
- package/assets/postgres-Dl17RzHj.js +0 -5466
- package/viewer/assets/index--Q2Bqrsm.css +0 -1
- package/viewer/assets/index-Dk0TlY7z.js +0 -90
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { l as u, n as I, t as Ce } from "../server.js";
|
|
2
|
+
import * as o from "fs";
|
|
3
|
+
import * as r from "path";
|
|
4
|
+
// node_modules/@electric-sql/pglite/dist/fs/nodefs.js
|
|
5
|
+
u();
|
|
6
|
+
var m = class extends Ce {
|
|
7
|
+
constructor(t) {
|
|
8
|
+
super(t), this.rootDir = r.resolve(t), o.existsSync(r.join(this.rootDir)) || o.mkdirSync(this.rootDir);
|
|
9
|
+
}
|
|
10
|
+
async init(t, e) {
|
|
11
|
+
return this.pg = t, { emscriptenOpts: {
|
|
12
|
+
...e,
|
|
13
|
+
preRun: [...e.preRun || [], (s) => {
|
|
14
|
+
let c = s.NODEFS;
|
|
15
|
+
s.FS.mkdirTree(I), s.FS.mount(c, { root: this.rootDir }, I);
|
|
16
|
+
}]
|
|
17
|
+
} };
|
|
18
|
+
}
|
|
19
|
+
async closeFs() {
|
|
20
|
+
this.pg.Module.FS.quit();
|
|
21
|
+
}
|
|
22
|
+
};
|
|
23
|
+
export { m as NodeFS };
|
|
@@ -0,0 +1,394 @@
|
|
|
1
|
+
import { a as R, c as h, i as xe, l as u, o as T$1, r as Ie, s as U$1, u as x$1 } from "../server.js";
|
|
2
|
+
// node_modules/@electric-sql/pglite/dist/fs/opfs-ahp.js
|
|
3
|
+
u();
|
|
4
|
+
var U = "state.txt";
|
|
5
|
+
var $ = "data";
|
|
6
|
+
var M = {
|
|
7
|
+
DIR: 16384,
|
|
8
|
+
FILE: 32768
|
|
9
|
+
};
|
|
10
|
+
var I;
|
|
11
|
+
var k;
|
|
12
|
+
var N;
|
|
13
|
+
var H;
|
|
14
|
+
var y;
|
|
15
|
+
var f;
|
|
16
|
+
var x;
|
|
17
|
+
var F;
|
|
18
|
+
var P;
|
|
19
|
+
var S;
|
|
20
|
+
var r;
|
|
21
|
+
var L;
|
|
22
|
+
var D;
|
|
23
|
+
var E;
|
|
24
|
+
var w;
|
|
25
|
+
var m;
|
|
26
|
+
var A;
|
|
27
|
+
var C;
|
|
28
|
+
var T;
|
|
29
|
+
var z = class extends Ie {
|
|
30
|
+
constructor(e, { initialPoolSize: t = 1e3, maintainedPoolSize: s = 100, debug: i = !1 } = {}) {
|
|
31
|
+
super(e, { debug: i });
|
|
32
|
+
R(this, r);
|
|
33
|
+
R(this, I);
|
|
34
|
+
R(this, k);
|
|
35
|
+
R(this, N);
|
|
36
|
+
R(this, H);
|
|
37
|
+
R(this, y);
|
|
38
|
+
R(this, f, /* @__PURE__ */ new Map());
|
|
39
|
+
R(this, x, 0);
|
|
40
|
+
R(this, F, /* @__PURE__ */ new Map());
|
|
41
|
+
R(this, P, /* @__PURE__ */ new Map());
|
|
42
|
+
this.lastCheckpoint = 0;
|
|
43
|
+
this.checkpointInterval = 6e4;
|
|
44
|
+
this.poolCounter = 0;
|
|
45
|
+
R(this, S, /* @__PURE__ */ new Set());
|
|
46
|
+
this.initialPoolSize = t, this.maintainedPoolSize = s;
|
|
47
|
+
}
|
|
48
|
+
async init(e, t) {
|
|
49
|
+
return await T$1(this, r, L).call(this), super.init(e, t);
|
|
50
|
+
}
|
|
51
|
+
async syncToFs(e = !1) {
|
|
52
|
+
await this.maybeCheckpointState(), await this.maintainPool(), e || this.flush();
|
|
53
|
+
}
|
|
54
|
+
async closeFs() {
|
|
55
|
+
for (let e of h(this, f).values()) e.sh.close();
|
|
56
|
+
h(this, y).flush(), h(this, y).close(), this.pg.Module.FS.quit();
|
|
57
|
+
}
|
|
58
|
+
async maintainPool(e) {
|
|
59
|
+
e = e || this.maintainedPoolSize;
|
|
60
|
+
let t = e - this.state.pool.length, s = [];
|
|
61
|
+
for (let i = 0; i < t; i++) s.push(new Promise(async (a) => {
|
|
62
|
+
++this.poolCounter;
|
|
63
|
+
let c = `${(Date.now() - 1704063600).toString(16).padStart(8, "0")}-${this.poolCounter.toString(16).padStart(8, "0")}`, h$1 = await h(this, N).getFileHandle(c, { create: !0 }), p = await h$1.createSyncAccessHandle();
|
|
64
|
+
h(this, f).set(c, {
|
|
65
|
+
fh: h$1,
|
|
66
|
+
sh: p
|
|
67
|
+
}), T$1(this, r, E).call(this, {
|
|
68
|
+
opp: "createPoolFile",
|
|
69
|
+
args: [c]
|
|
70
|
+
}), this.state.pool.push(c), a();
|
|
71
|
+
}));
|
|
72
|
+
for (let i = 0; i > t; i--) s.push(new Promise(async (a) => {
|
|
73
|
+
let c = this.state.pool.pop();
|
|
74
|
+
T$1(this, r, E).call(this, {
|
|
75
|
+
opp: "deletePoolFile",
|
|
76
|
+
args: [c]
|
|
77
|
+
});
|
|
78
|
+
let h$2 = h(this, f).get(c);
|
|
79
|
+
h$2?.sh?.close(), await h(this, N).removeEntry(h$2.fh.name), h(this, f).delete(c), a();
|
|
80
|
+
}));
|
|
81
|
+
await Promise.all(s);
|
|
82
|
+
}
|
|
83
|
+
_createPoolFileState(e) {
|
|
84
|
+
this.state.pool.push(e);
|
|
85
|
+
}
|
|
86
|
+
_deletePoolFileState(e) {
|
|
87
|
+
let t = this.state.pool.indexOf(e);
|
|
88
|
+
t > -1 && this.state.pool.splice(t, 1);
|
|
89
|
+
}
|
|
90
|
+
async maybeCheckpointState() {
|
|
91
|
+
Date.now() - this.lastCheckpoint > this.checkpointInterval && await this.checkpointState();
|
|
92
|
+
}
|
|
93
|
+
async checkpointState() {
|
|
94
|
+
let e = new TextEncoder().encode(JSON.stringify(this.state));
|
|
95
|
+
h(this, y).truncate(0), h(this, y).write(e, { at: 0 }), h(this, y).flush(), this.lastCheckpoint = Date.now();
|
|
96
|
+
}
|
|
97
|
+
flush() {
|
|
98
|
+
for (let e of h(this, S)) try {
|
|
99
|
+
e.flush();
|
|
100
|
+
} catch {}
|
|
101
|
+
h(this, S).clear();
|
|
102
|
+
}
|
|
103
|
+
chmod(e, t) {
|
|
104
|
+
T$1(this, r, D).call(this, {
|
|
105
|
+
opp: "chmod",
|
|
106
|
+
args: [e, t]
|
|
107
|
+
}, () => {
|
|
108
|
+
this._chmodState(e, t);
|
|
109
|
+
});
|
|
110
|
+
}
|
|
111
|
+
_chmodState(e, t) {
|
|
112
|
+
let s = T$1(this, r, m).call(this, e);
|
|
113
|
+
s.mode = t;
|
|
114
|
+
}
|
|
115
|
+
close(e) {
|
|
116
|
+
let t = T$1(this, r, A).call(this, e);
|
|
117
|
+
h(this, F).delete(e), h(this, P).delete(t);
|
|
118
|
+
}
|
|
119
|
+
fstat(e) {
|
|
120
|
+
let t = T$1(this, r, A).call(this, e);
|
|
121
|
+
return this.lstat(t);
|
|
122
|
+
}
|
|
123
|
+
lstat(e) {
|
|
124
|
+
let t = T$1(this, r, m).call(this, e), s = t.type === "file" ? h(this, f).get(t.backingFilename).sh.getSize() : 0, i = 4096;
|
|
125
|
+
return {
|
|
126
|
+
dev: 0,
|
|
127
|
+
ino: 0,
|
|
128
|
+
mode: t.mode,
|
|
129
|
+
nlink: 1,
|
|
130
|
+
uid: 0,
|
|
131
|
+
gid: 0,
|
|
132
|
+
rdev: 0,
|
|
133
|
+
size: s,
|
|
134
|
+
blksize: i,
|
|
135
|
+
blocks: Math.ceil(s / i),
|
|
136
|
+
atime: t.lastModified,
|
|
137
|
+
mtime: t.lastModified,
|
|
138
|
+
ctime: t.lastModified
|
|
139
|
+
};
|
|
140
|
+
}
|
|
141
|
+
mkdir(e, t) {
|
|
142
|
+
T$1(this, r, D).call(this, {
|
|
143
|
+
opp: "mkdir",
|
|
144
|
+
args: [e, t]
|
|
145
|
+
}, () => {
|
|
146
|
+
this._mkdirState(e, t);
|
|
147
|
+
});
|
|
148
|
+
}
|
|
149
|
+
_mkdirState(e, t) {
|
|
150
|
+
let s = T$1(this, r, w).call(this, e), i = s.pop(), a = [], c = this.state.root;
|
|
151
|
+
for (let p of s) {
|
|
152
|
+
if (a.push(e), !Object.prototype.hasOwnProperty.call(c.children, p)) if (t?.recursive) this.mkdir(a.join("/"));
|
|
153
|
+
else throw new d("ENOENT", "No such file or directory");
|
|
154
|
+
if (c.children[p].type !== "directory") throw new d("ENOTDIR", "Not a directory");
|
|
155
|
+
c = c.children[p];
|
|
156
|
+
}
|
|
157
|
+
if (Object.prototype.hasOwnProperty.call(c.children, i)) throw new d("EEXIST", "File exists");
|
|
158
|
+
let h = {
|
|
159
|
+
type: "directory",
|
|
160
|
+
lastModified: Date.now(),
|
|
161
|
+
mode: t?.mode || M.DIR,
|
|
162
|
+
children: {}
|
|
163
|
+
};
|
|
164
|
+
c.children[i] = h;
|
|
165
|
+
}
|
|
166
|
+
open(e, t, s) {
|
|
167
|
+
if (T$1(this, r, m).call(this, e).type !== "file") throw new d("EISDIR", "Is a directory");
|
|
168
|
+
let a = T$1(this, r, C).call(this);
|
|
169
|
+
return h(this, F).set(a, e), h(this, P).set(e, a), a;
|
|
170
|
+
}
|
|
171
|
+
readdir(e) {
|
|
172
|
+
let t = T$1(this, r, m).call(this, e);
|
|
173
|
+
if (t.type !== "directory") throw new d("ENOTDIR", "Not a directory");
|
|
174
|
+
return Object.keys(t.children);
|
|
175
|
+
}
|
|
176
|
+
read(e, t, s, i, a) {
|
|
177
|
+
let c = T$1(this, r, A).call(this, e), h$3 = T$1(this, r, m).call(this, c);
|
|
178
|
+
if (h$3.type !== "file") throw new d("EISDIR", "Is a directory");
|
|
179
|
+
return h(this, f).get(h$3.backingFilename).sh.read(new Uint8Array(t.buffer, s, i), { at: a });
|
|
180
|
+
}
|
|
181
|
+
rename(e, t) {
|
|
182
|
+
T$1(this, r, D).call(this, {
|
|
183
|
+
opp: "rename",
|
|
184
|
+
args: [e, t]
|
|
185
|
+
}, () => {
|
|
186
|
+
this._renameState(e, t, !0);
|
|
187
|
+
});
|
|
188
|
+
}
|
|
189
|
+
_renameState(e, t, s = !1) {
|
|
190
|
+
let i = T$1(this, r, w).call(this, e), a = i.pop(), c = T$1(this, r, m).call(this, i.join("/"));
|
|
191
|
+
if (!Object.prototype.hasOwnProperty.call(c.children, a)) throw new d("ENOENT", "No such file or directory");
|
|
192
|
+
let h$4 = T$1(this, r, w).call(this, t), p = h$4.pop(), l = T$1(this, r, m).call(this, h$4.join("/"));
|
|
193
|
+
if (s && Object.prototype.hasOwnProperty.call(l.children, p)) {
|
|
194
|
+
let u = l.children[p];
|
|
195
|
+
h(this, f).get(u.backingFilename).sh.truncate(0), this.state.pool.push(u.backingFilename);
|
|
196
|
+
}
|
|
197
|
+
l.children[p] = c.children[a], delete c.children[a];
|
|
198
|
+
}
|
|
199
|
+
rmdir(e) {
|
|
200
|
+
T$1(this, r, D).call(this, {
|
|
201
|
+
opp: "rmdir",
|
|
202
|
+
args: [e]
|
|
203
|
+
}, () => {
|
|
204
|
+
this._rmdirState(e);
|
|
205
|
+
});
|
|
206
|
+
}
|
|
207
|
+
_rmdirState(e) {
|
|
208
|
+
let t = T$1(this, r, w).call(this, e), s = t.pop(), i = T$1(this, r, m).call(this, t.join("/"));
|
|
209
|
+
if (!Object.prototype.hasOwnProperty.call(i.children, s)) throw new d("ENOENT", "No such file or directory");
|
|
210
|
+
let a = i.children[s];
|
|
211
|
+
if (a.type !== "directory") throw new d("ENOTDIR", "Not a directory");
|
|
212
|
+
if (Object.keys(a.children).length > 0) throw new d("ENOTEMPTY", "Directory not empty");
|
|
213
|
+
delete i.children[s];
|
|
214
|
+
}
|
|
215
|
+
truncate(e, t = 0) {
|
|
216
|
+
let s = T$1(this, r, m).call(this, e);
|
|
217
|
+
if (s.type !== "file") throw new d("EISDIR", "Is a directory");
|
|
218
|
+
let i = h(this, f).get(s.backingFilename)?.sh;
|
|
219
|
+
if (!i) throw new d("ENOENT", "No such file or directory");
|
|
220
|
+
i.truncate(t), h(this, S).add(i);
|
|
221
|
+
}
|
|
222
|
+
unlink(e) {
|
|
223
|
+
T$1(this, r, D).call(this, {
|
|
224
|
+
opp: "unlink",
|
|
225
|
+
args: [e]
|
|
226
|
+
}, () => {
|
|
227
|
+
this._unlinkState(e, !0);
|
|
228
|
+
});
|
|
229
|
+
}
|
|
230
|
+
_unlinkState(e, t = !1) {
|
|
231
|
+
let s = T$1(this, r, w).call(this, e), i = s.pop(), a = T$1(this, r, m).call(this, s.join("/"));
|
|
232
|
+
if (!Object.prototype.hasOwnProperty.call(a.children, i)) throw new d("ENOENT", "No such file or directory");
|
|
233
|
+
let c = a.children[i];
|
|
234
|
+
if (c.type !== "file") throw new d("EISDIR", "Is a directory");
|
|
235
|
+
if (delete a.children[i], t) {
|
|
236
|
+
let h$5 = h(this, f).get(c.backingFilename).sh;
|
|
237
|
+
h$5?.truncate(0), h(this, S).add(h$5), h(this, P).has(e) && (h(this, F).delete(h(this, P).get(e)), h(this, P).delete(e));
|
|
238
|
+
}
|
|
239
|
+
this.state.pool.push(c.backingFilename);
|
|
240
|
+
}
|
|
241
|
+
utimes(e, t, s) {
|
|
242
|
+
T$1(this, r, D).call(this, {
|
|
243
|
+
opp: "utimes",
|
|
244
|
+
args: [
|
|
245
|
+
e,
|
|
246
|
+
t,
|
|
247
|
+
s
|
|
248
|
+
]
|
|
249
|
+
}, () => {
|
|
250
|
+
this._utimesState(e, t, s);
|
|
251
|
+
});
|
|
252
|
+
}
|
|
253
|
+
_utimesState(e, t, s) {
|
|
254
|
+
let i = T$1(this, r, m).call(this, e);
|
|
255
|
+
i.lastModified = s;
|
|
256
|
+
}
|
|
257
|
+
writeFile(e, t, s) {
|
|
258
|
+
let i = T$1(this, r, w).call(this, e), a = i.pop(), c = T$1(this, r, m).call(this, i.join("/"));
|
|
259
|
+
if (Object.prototype.hasOwnProperty.call(c.children, a)) {
|
|
260
|
+
let l = c.children[a];
|
|
261
|
+
l.lastModified = Date.now(), T$1(this, r, E).call(this, {
|
|
262
|
+
opp: "setLastModified",
|
|
263
|
+
args: [e, l.lastModified]
|
|
264
|
+
});
|
|
265
|
+
} else {
|
|
266
|
+
if (this.state.pool.length === 0) throw new Error("No more file handles available in the pool");
|
|
267
|
+
let l = {
|
|
268
|
+
type: "file",
|
|
269
|
+
lastModified: Date.now(),
|
|
270
|
+
mode: s?.mode || M.FILE,
|
|
271
|
+
backingFilename: this.state.pool.pop()
|
|
272
|
+
};
|
|
273
|
+
c.children[a] = l, T$1(this, r, E).call(this, {
|
|
274
|
+
opp: "createFileNode",
|
|
275
|
+
args: [e, l]
|
|
276
|
+
});
|
|
277
|
+
}
|
|
278
|
+
let h$6 = c.children[a], p = h(this, f).get(h$6.backingFilename).sh;
|
|
279
|
+
t.length > 0 && (p.write(typeof t == "string" ? new TextEncoder().encode(t) : new Uint8Array(t), { at: 0 }), e.startsWith("/pg_wal") && h(this, S).add(p));
|
|
280
|
+
}
|
|
281
|
+
_createFileNodeState(e, t) {
|
|
282
|
+
let s = T$1(this, r, w).call(this, e), i = s.pop(), a = T$1(this, r, m).call(this, s.join("/"));
|
|
283
|
+
a.children[i] = t;
|
|
284
|
+
let c = this.state.pool.indexOf(t.backingFilename);
|
|
285
|
+
return c > -1 && this.state.pool.splice(c, 1), t;
|
|
286
|
+
}
|
|
287
|
+
_setLastModifiedState(e, t) {
|
|
288
|
+
let s = T$1(this, r, m).call(this, e);
|
|
289
|
+
s.lastModified = t;
|
|
290
|
+
}
|
|
291
|
+
write(e, t, s, i, a) {
|
|
292
|
+
let c = T$1(this, r, A).call(this, e), h$7 = T$1(this, r, m).call(this, c);
|
|
293
|
+
if (h$7.type !== "file") throw new d("EISDIR", "Is a directory");
|
|
294
|
+
let p = h(this, f).get(h$7.backingFilename)?.sh;
|
|
295
|
+
if (!p) throw new d("EBADF", "Bad file descriptor");
|
|
296
|
+
let l = p.write(new Uint8Array(t, s, i), { at: a });
|
|
297
|
+
return c.startsWith("/pg_wal") && h(this, S).add(p), l;
|
|
298
|
+
}
|
|
299
|
+
};
|
|
300
|
+
I = /* @__PURE__ */ new WeakMap(), k = /* @__PURE__ */ new WeakMap(), N = /* @__PURE__ */ new WeakMap(), H = /* @__PURE__ */ new WeakMap(), y = /* @__PURE__ */ new WeakMap(), f = /* @__PURE__ */ new WeakMap(), x = /* @__PURE__ */ new WeakMap(), F = /* @__PURE__ */ new WeakMap(), P = /* @__PURE__ */ new WeakMap(), S = /* @__PURE__ */ new WeakMap(), r = /* @__PURE__ */ new WeakSet(), L = async function() {
|
|
301
|
+
x$1(this, I, await navigator.storage.getDirectory()), x$1(this, k, await T$1(this, r, T).call(this, this.dataDir, { create: !0 })), x$1(this, N, await T$1(this, r, T).call(this, $, {
|
|
302
|
+
from: h(this, k),
|
|
303
|
+
create: !0
|
|
304
|
+
})), x$1(this, H, await h(this, k).getFileHandle(U, { create: !0 })), x$1(this, y, await h(this, H).createSyncAccessHandle());
|
|
305
|
+
let e = new ArrayBuffer(h(this, y).getSize());
|
|
306
|
+
h(this, y).read(e, { at: 0 });
|
|
307
|
+
let t, s = new TextDecoder().decode(e).split(`
|
|
308
|
+
`), i = !1;
|
|
309
|
+
try {
|
|
310
|
+
t = JSON.parse(s[0]);
|
|
311
|
+
} catch {
|
|
312
|
+
t = {
|
|
313
|
+
root: {
|
|
314
|
+
type: "directory",
|
|
315
|
+
lastModified: Date.now(),
|
|
316
|
+
mode: M.DIR,
|
|
317
|
+
children: {}
|
|
318
|
+
},
|
|
319
|
+
pool: []
|
|
320
|
+
}, h(this, y).truncate(0), h(this, y).write(new TextEncoder().encode(JSON.stringify(t)), { at: 0 }), i = !0;
|
|
321
|
+
}
|
|
322
|
+
this.state = t;
|
|
323
|
+
let a = s.slice(1).filter(Boolean).map((l) => JSON.parse(l));
|
|
324
|
+
for (let l of a) {
|
|
325
|
+
let u = `_${l.opp}State`;
|
|
326
|
+
if (typeof this[u] == "function") try {
|
|
327
|
+
this[u].bind(this)(...l.args);
|
|
328
|
+
} catch (b) {
|
|
329
|
+
console.warn("Error applying OPFS AHP WAL entry", l, b);
|
|
330
|
+
}
|
|
331
|
+
}
|
|
332
|
+
let c = [], h$8 = async (l) => {
|
|
333
|
+
if (l.type === "file") try {
|
|
334
|
+
let u = await h(this, N).getFileHandle(l.backingFilename), b = await u.createSyncAccessHandle();
|
|
335
|
+
h(this, f).set(l.backingFilename, {
|
|
336
|
+
sh: b,
|
|
337
|
+
fh: u
|
|
338
|
+
});
|
|
339
|
+
} catch (u) {
|
|
340
|
+
console.error("Error opening file handle for node", l, u);
|
|
341
|
+
}
|
|
342
|
+
else for (let u of Object.values(l.children)) c.push(h$8(u));
|
|
343
|
+
};
|
|
344
|
+
await h$8(this.state.root);
|
|
345
|
+
let p = [];
|
|
346
|
+
for (let l of this.state.pool) p.push(new Promise(async (u) => {
|
|
347
|
+
h(this, f).has(l) && console.warn("File handle already exists for pool file", l);
|
|
348
|
+
let b = await h(this, N).getFileHandle(l), J = await b.createSyncAccessHandle();
|
|
349
|
+
h(this, f).set(l, {
|
|
350
|
+
fh: b,
|
|
351
|
+
sh: J
|
|
352
|
+
}), u();
|
|
353
|
+
}));
|
|
354
|
+
await Promise.all([...c, ...p]), await this.maintainPool(i ? this.initialPoolSize : this.maintainedPoolSize);
|
|
355
|
+
}, D = function(e, t) {
|
|
356
|
+
let s = T$1(this, r, E).call(this, e);
|
|
357
|
+
try {
|
|
358
|
+
t();
|
|
359
|
+
} catch (i) {
|
|
360
|
+
throw h(this, y).truncate(s), i;
|
|
361
|
+
}
|
|
362
|
+
}, E = function(e) {
|
|
363
|
+
let t = JSON.stringify(e), s = new TextEncoder().encode(`
|
|
364
|
+
${t}`), i = h(this, y).getSize();
|
|
365
|
+
return h(this, y).write(s, { at: i }), h(this, S).add(h(this, y)), i;
|
|
366
|
+
}, w = function(e) {
|
|
367
|
+
return e.split("/").filter(Boolean);
|
|
368
|
+
}, m = function(e, t) {
|
|
369
|
+
let s = T$1(this, r, w).call(this, e), i = t || this.state.root;
|
|
370
|
+
for (let a of s) {
|
|
371
|
+
if (i.type !== "directory") throw new d("ENOTDIR", "Not a directory");
|
|
372
|
+
if (!Object.prototype.hasOwnProperty.call(i.children, a)) throw new d("ENOENT", "No such file or directory");
|
|
373
|
+
i = i.children[a];
|
|
374
|
+
}
|
|
375
|
+
return i;
|
|
376
|
+
}, A = function(e) {
|
|
377
|
+
let t = h(this, F).get(e);
|
|
378
|
+
if (!t) throw new d("EBADF", "Bad file descriptor");
|
|
379
|
+
return t;
|
|
380
|
+
}, C = function() {
|
|
381
|
+
let e = ++U$1(this, x)._;
|
|
382
|
+
for (; h(this, F).has(e);) U$1(this, x)._++;
|
|
383
|
+
return e;
|
|
384
|
+
}, T = async function(e, t) {
|
|
385
|
+
let s = T$1(this, r, w).call(this, e), i = t?.from || h(this, I);
|
|
386
|
+
for (let a of s) i = await i.getDirectoryHandle(a, { create: t?.create });
|
|
387
|
+
return i;
|
|
388
|
+
};
|
|
389
|
+
var d = class extends Error {
|
|
390
|
+
constructor(v, e) {
|
|
391
|
+
super(e), typeof v == "number" ? this.code = v : typeof v == "string" && (this.code = xe[v]);
|
|
392
|
+
}
|
|
393
|
+
};
|
|
394
|
+
export { z as OpfsAhpFS };
|