attraverso 0.0.1 → 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (71) hide show
  1. package/README.txt +9 -0
  2. package/assets/migrations/0000_burly_firestar.sql +76 -0
  3. package/assets/migrations/0001_sleepy_gorilla_man.sql +27 -0
  4. package/assets/migrations/0002_smart_ikaris.sql +14 -0
  5. package/assets/migrations/0003_pink_zodiak.sql +17 -0
  6. package/assets/migrations/0004_loose_hitman.sql +14 -0
  7. package/assets/migrations/0005_glamorous_typhoid_mary.sql +5 -0
  8. package/assets/migrations/0006_slow_deadpool.sql +1 -0
  9. package/assets/migrations/0007_jittery_tag.sql +8 -0
  10. package/assets/migrations/0008_daily_firestar.sql +1 -0
  11. package/assets/migrations/0009_cute_marvex.sql +13 -0
  12. package/assets/migrations/0010_acoustic_pixie.sql +10 -0
  13. package/assets/migrations/0011_orange_rawhide_kid.sql +1 -0
  14. package/assets/migrations/0012_smiling_butterfly.sql +23 -0
  15. package/assets/migrations/0013_kind_bloodscream.sql +9 -0
  16. package/assets/migrations/meta/0000_snapshot.json +629 -0
  17. package/assets/migrations/meta/0001_snapshot.json +852 -0
  18. package/assets/migrations/meta/0002_snapshot.json +972 -0
  19. package/assets/migrations/meta/0003_snapshot.json +1130 -0
  20. package/assets/migrations/meta/0004_snapshot.json +1244 -0
  21. package/assets/migrations/meta/0005_snapshot.json +1275 -0
  22. package/assets/migrations/meta/0006_snapshot.json +1276 -0
  23. package/assets/migrations/meta/0007_snapshot.json +1376 -0
  24. package/assets/migrations/meta/0008_snapshot.json +1241 -0
  25. package/assets/migrations/meta/0009_snapshot.json +1241 -0
  26. package/assets/migrations/meta/0010_snapshot.json +1329 -0
  27. package/assets/migrations/meta/0011_snapshot.json +1322 -0
  28. package/assets/migrations/meta/0012_snapshot.json +1516 -0
  29. package/assets/migrations/meta/0013_snapshot.json +1576 -0
  30. package/assets/migrations/meta/_journal.json +104 -0
  31. package/assets/nodefs-BbnD6x79.js +33 -0
  32. package/assets/opfs-ahp-CFnUNF4E.js +308 -0
  33. package/assets/postgres-X5RxLyOz.js +5438 -0
  34. package/initdb.wasm +0 -0
  35. package/migrations/0000_burly_firestar.sql +76 -0
  36. package/migrations/0001_sleepy_gorilla_man.sql +27 -0
  37. package/migrations/0002_smart_ikaris.sql +14 -0
  38. package/migrations/0003_pink_zodiak.sql +17 -0
  39. package/migrations/0004_loose_hitman.sql +14 -0
  40. package/migrations/0005_glamorous_typhoid_mary.sql +5 -0
  41. package/migrations/0006_slow_deadpool.sql +1 -0
  42. package/migrations/0007_jittery_tag.sql +8 -0
  43. package/migrations/0008_daily_firestar.sql +1 -0
  44. package/migrations/0009_cute_marvex.sql +13 -0
  45. package/migrations/0010_acoustic_pixie.sql +10 -0
  46. package/migrations/0011_orange_rawhide_kid.sql +1 -0
  47. package/migrations/0012_smiling_butterfly.sql +23 -0
  48. package/migrations/0013_kind_bloodscream.sql +9 -0
  49. package/migrations/meta/0000_snapshot.json +629 -0
  50. package/migrations/meta/0001_snapshot.json +852 -0
  51. package/migrations/meta/0002_snapshot.json +972 -0
  52. package/migrations/meta/0003_snapshot.json +1130 -0
  53. package/migrations/meta/0004_snapshot.json +1244 -0
  54. package/migrations/meta/0005_snapshot.json +1275 -0
  55. package/migrations/meta/0006_snapshot.json +1276 -0
  56. package/migrations/meta/0007_snapshot.json +1376 -0
  57. package/migrations/meta/0008_snapshot.json +1241 -0
  58. package/migrations/meta/0009_snapshot.json +1241 -0
  59. package/migrations/meta/0010_snapshot.json +1329 -0
  60. package/migrations/meta/0011_snapshot.json +1322 -0
  61. package/migrations/meta/0012_snapshot.json +1516 -0
  62. package/migrations/meta/0013_snapshot.json +1576 -0
  63. package/migrations/meta/_journal.json +104 -0
  64. package/package.json +28 -4
  65. package/pglite.data +37667 -8
  66. package/pglite.wasm +0 -0
  67. package/server.js +47451 -0
  68. package/viewer/assets/index-BW6lgiAa.css +1 -0
  69. package/viewer/assets/index-CBMcK_jK.js +90 -0
  70. package/viewer/index.html +13 -0
  71. package/README.md +0 -19
@@ -0,0 +1,104 @@
1
+ {
2
+ "version": "7",
3
+ "dialect": "postgresql",
4
+ "entries": [
5
+ {
6
+ "idx": 0,
7
+ "version": "7",
8
+ "when": 1784899598232,
9
+ "tag": "0000_burly_firestar",
10
+ "breakpoints": true
11
+ },
12
+ {
13
+ "idx": 1,
14
+ "version": "7",
15
+ "when": 1784913815072,
16
+ "tag": "0001_sleepy_gorilla_man",
17
+ "breakpoints": true
18
+ },
19
+ {
20
+ "idx": 2,
21
+ "version": "7",
22
+ "when": 1785248894876,
23
+ "tag": "0002_smart_ikaris",
24
+ "breakpoints": true
25
+ },
26
+ {
27
+ "idx": 3,
28
+ "version": "7",
29
+ "when": 1785494222282,
30
+ "tag": "0003_pink_zodiak",
31
+ "breakpoints": true
32
+ },
33
+ {
34
+ "idx": 4,
35
+ "version": "7",
36
+ "when": 1788127474688,
37
+ "tag": "0004_loose_hitman",
38
+ "breakpoints": true
39
+ },
40
+ {
41
+ "idx": 5,
42
+ "version": "7",
43
+ "when": 1788191498092,
44
+ "tag": "0005_glamorous_typhoid_mary",
45
+ "breakpoints": true
46
+ },
47
+ {
48
+ "idx": 6,
49
+ "version": "7",
50
+ "when": 1788192487724,
51
+ "tag": "0006_slow_deadpool",
52
+ "breakpoints": true
53
+ },
54
+ {
55
+ "idx": 7,
56
+ "version": "7",
57
+ "when": 1788275809877,
58
+ "tag": "0007_jittery_tag",
59
+ "breakpoints": true
60
+ },
61
+ {
62
+ "idx": 8,
63
+ "version": "7",
64
+ "when": 1788298194195,
65
+ "tag": "0008_daily_firestar",
66
+ "breakpoints": true
67
+ },
68
+ {
69
+ "idx": 9,
70
+ "version": "7",
71
+ "when": 1788299093758,
72
+ "tag": "0009_cute_marvex",
73
+ "breakpoints": true
74
+ },
75
+ {
76
+ "idx": 10,
77
+ "version": "7",
78
+ "when": 1788375271316,
79
+ "tag": "0010_acoustic_pixie",
80
+ "breakpoints": true
81
+ },
82
+ {
83
+ "idx": 11,
84
+ "version": "7",
85
+ "when": 1788377979673,
86
+ "tag": "0011_orange_rawhide_kid",
87
+ "breakpoints": true
88
+ },
89
+ {
90
+ "idx": 12,
91
+ "version": "7",
92
+ "when": 1788381139129,
93
+ "tag": "0012_smiling_butterfly",
94
+ "breakpoints": true
95
+ },
96
+ {
97
+ "idx": 13,
98
+ "version": "7",
99
+ "when": 1790032589899,
100
+ "tag": "0013_kind_bloodscream",
101
+ "breakpoints": true
102
+ }
103
+ ]
104
+ }
@@ -0,0 +1,33 @@
1
+ import { W as We, B, u } from "../server.js";
2
+ import * as s from "fs";
3
+ import * as o from "path";
4
+ import "os";
5
+ import "crypto";
6
+ import "node:url";
7
+ import "node:path";
8
+ import "node:process";
9
+ import "node:crypto";
10
+ import "node:fs";
11
+ import "node:fs/promises";
12
+ import "node:os";
13
+ import "process";
14
+ import "buffer";
15
+ import "node:http";
16
+ u();
17
+ var m = class extends We {
18
+ constructor(t) {
19
+ super(t), this.rootDir = o.resolve(t), s.existsSync(o.join(this.rootDir)) || s.mkdirSync(this.rootDir);
20
+ }
21
+ async init(t, e) {
22
+ return this.pg = t, { emscriptenOpts: { ...e, preRun: [...e.preRun || [], (r) => {
23
+ let c = r.FS.filesystems.NODEFS;
24
+ r.FS.mkdir(B), r.FS.mount(c, { root: this.rootDir }, B);
25
+ }] } };
26
+ }
27
+ async closeFs() {
28
+ this.pg.Module.FS.quit();
29
+ }
30
+ };
31
+ export {
32
+ m as NodeFS
33
+ };
@@ -0,0 +1,308 @@
1
+ import { G as Ge, R as R$1, T as T$1, p as h, V as Ve, u, x as x$1, U } from "../server.js";
2
+ import "fs";
3
+ import "path";
4
+ import "os";
5
+ import "crypto";
6
+ import "node:url";
7
+ import "node:path";
8
+ import "node:process";
9
+ import "node:crypto";
10
+ import "node:fs";
11
+ import "node:fs/promises";
12
+ import "node:os";
13
+ import "process";
14
+ import "buffer";
15
+ import "node:http";
16
+ u();
17
+ var $ = "state.txt", G = "data", T = { DIR: 16384, FILE: 32768 }, H, v, F, M, y, b, m, x, P, D, S, n, C, O, k, w, f, I, W, j, L = class extends Ge {
18
+ constructor(e, { initialPoolSize: t = 1e3, maintainedPoolSize: o = 100, debug: i = false } = {}) {
19
+ super(e, { debug: i });
20
+ R$1(this, n);
21
+ R$1(this, H);
22
+ R$1(this, v);
23
+ R$1(this, F);
24
+ R$1(this, M);
25
+ R$1(this, y);
26
+ R$1(this, b, /* @__PURE__ */ new Map());
27
+ R$1(this, m, /* @__PURE__ */ new Map());
28
+ R$1(this, x, 0);
29
+ R$1(this, P, /* @__PURE__ */ new Map());
30
+ R$1(this, D, /* @__PURE__ */ new Map());
31
+ this.lastCheckpoint = 0;
32
+ this.checkpointInterval = 1e3 * 60;
33
+ this.poolCounter = 0;
34
+ R$1(this, S, /* @__PURE__ */ new Set());
35
+ this.initialPoolSize = t, this.maintainedPoolSize = o;
36
+ }
37
+ async init(e, t) {
38
+ return await T$1(this, n, C).call(this), super.init(e, t);
39
+ }
40
+ async syncToFs(e = false) {
41
+ await this.maybeCheckpointState(), await this.maintainPool(), e || this.flush();
42
+ }
43
+ async closeFs() {
44
+ for (let e of h(this, m).values()) e.close();
45
+ h(this, y).flush(), h(this, y).close(), this.pg.Module.FS.quit();
46
+ }
47
+ async maintainPool(e) {
48
+ e = e || this.maintainedPoolSize;
49
+ let t = e - this.state.pool.length, o = [];
50
+ for (let i = 0; i < t; i++) o.push(new Promise(async (c) => {
51
+ ++this.poolCounter;
52
+ let a = `${(Date.now() - 1704063600).toString(16).padStart(8, "0")}-${this.poolCounter.toString(16).padStart(8, "0")}`, h$1 = await h(this, F).getFileHandle(a, { create: true }), d = await h$1.createSyncAccessHandle();
53
+ h(this, b).set(a, h$1), h(this, m).set(a, d), T$1(this, n, k).call(this, { opp: "createPoolFile", args: [a] }), this.state.pool.push(a), c();
54
+ }));
55
+ for (let i = 0; i > t; i--) o.push(new Promise(async (c) => {
56
+ let a = this.state.pool.pop();
57
+ T$1(this, n, k).call(this, { opp: "deletePoolFile", args: [a] });
58
+ let h$1 = h(this, b).get(a);
59
+ h(this, m).get(a)?.close(), await h(this, F).removeEntry(h$1.name), h(this, b).delete(a), h(this, m).delete(a), c();
60
+ }));
61
+ await Promise.all(o);
62
+ }
63
+ _createPoolFileState(e) {
64
+ this.state.pool.push(e);
65
+ }
66
+ _deletePoolFileState(e) {
67
+ let t = this.state.pool.indexOf(e);
68
+ t > -1 && this.state.pool.splice(t, 1);
69
+ }
70
+ async maybeCheckpointState() {
71
+ Date.now() - this.lastCheckpoint > this.checkpointInterval && await this.checkpointState();
72
+ }
73
+ async checkpointState() {
74
+ let e = new TextEncoder().encode(JSON.stringify(this.state));
75
+ h(this, y).truncate(0), h(this, y).write(e, { at: 0 }), h(this, y).flush(), this.lastCheckpoint = Date.now();
76
+ }
77
+ flush() {
78
+ for (let e of h(this, S)) try {
79
+ e.flush();
80
+ } catch {
81
+ }
82
+ h(this, S).clear();
83
+ }
84
+ chmod(e, t) {
85
+ T$1(this, n, O).call(this, { opp: "chmod", args: [e, t] }, () => {
86
+ this._chmodState(e, t);
87
+ });
88
+ }
89
+ _chmodState(e, t) {
90
+ let o = T$1(this, n, f).call(this, e);
91
+ o.mode = t;
92
+ }
93
+ close(e) {
94
+ let t = T$1(this, n, I).call(this, e);
95
+ h(this, P).delete(e), h(this, D).delete(t);
96
+ }
97
+ fstat(e) {
98
+ let t = T$1(this, n, I).call(this, e);
99
+ return this.lstat(t);
100
+ }
101
+ lstat(e) {
102
+ let t = T$1(this, n, f).call(this, e), o = t.type === "file" ? h(this, m).get(t.backingFilename).getSize() : 0, i = 4096;
103
+ return { dev: 0, ino: 0, mode: t.mode, nlink: 1, uid: 0, gid: 0, rdev: 0, size: o, blksize: i, blocks: Math.ceil(o / i), atime: t.lastModified, mtime: t.lastModified, ctime: t.lastModified };
104
+ }
105
+ mkdir(e, t) {
106
+ T$1(this, n, O).call(this, { opp: "mkdir", args: [e, t] }, () => {
107
+ this._mkdirState(e, t);
108
+ });
109
+ }
110
+ _mkdirState(e, t) {
111
+ let o = T$1(this, n, w).call(this, e), i = o.pop(), c = [], a = this.state.root;
112
+ for (let d of o) {
113
+ if (c.push(e), !Object.prototype.hasOwnProperty.call(a.children, d)) if (t?.recursive) this.mkdir(c.join("/"));
114
+ else throw new p("ENOENT", "No such file or directory");
115
+ if (a.children[d].type !== "directory") throw new p("ENOTDIR", "Not a directory");
116
+ a = a.children[d];
117
+ }
118
+ if (Object.prototype.hasOwnProperty.call(a.children, i)) throw new p("EEXIST", "File exists");
119
+ let h2 = { type: "directory", lastModified: Date.now(), mode: t?.mode || T.DIR, children: {} };
120
+ a.children[i] = h2;
121
+ }
122
+ open(e, t, o) {
123
+ if (T$1(this, n, f).call(this, e).type !== "file") throw new p("EISDIR", "Is a directory");
124
+ let c = T$1(this, n, W).call(this);
125
+ return h(this, P).set(c, e), h(this, D).set(e, c), c;
126
+ }
127
+ readdir(e) {
128
+ let t = T$1(this, n, f).call(this, e);
129
+ if (t.type !== "directory") throw new p("ENOTDIR", "Not a directory");
130
+ return Object.keys(t.children);
131
+ }
132
+ read(e, t, o, i, c) {
133
+ let a = T$1(this, n, I).call(this, e), h$1 = T$1(this, n, f).call(this, a);
134
+ if (h$1.type !== "file") throw new p("EISDIR", "Is a directory");
135
+ return h(this, m).get(h$1.backingFilename).read(new Uint8Array(t.buffer, o, i), { at: c });
136
+ }
137
+ rename(e, t) {
138
+ T$1(this, n, O).call(this, { opp: "rename", args: [e, t] }, () => {
139
+ this._renameState(e, t, true);
140
+ });
141
+ }
142
+ _renameState(e, t, o = false) {
143
+ let i = T$1(this, n, w).call(this, e), c = i.pop(), a = T$1(this, n, f).call(this, i.join("/"));
144
+ if (!Object.prototype.hasOwnProperty.call(a.children, c)) throw new p("ENOENT", "No such file or directory");
145
+ let h$1 = T$1(this, n, w).call(this, t), d = h$1.pop(), l = T$1(this, n, f).call(this, h$1.join("/"));
146
+ if (o && Object.prototype.hasOwnProperty.call(l.children, d)) {
147
+ let u2 = l.children[d];
148
+ h(this, m).get(u2.backingFilename).truncate(0), this.state.pool.push(u2.backingFilename);
149
+ }
150
+ l.children[d] = a.children[c], delete a.children[c];
151
+ }
152
+ rmdir(e) {
153
+ T$1(this, n, O).call(this, { opp: "rmdir", args: [e] }, () => {
154
+ this._rmdirState(e);
155
+ });
156
+ }
157
+ _rmdirState(e) {
158
+ let t = T$1(this, n, w).call(this, e), o = t.pop(), i = T$1(this, n, f).call(this, t.join("/"));
159
+ if (!Object.prototype.hasOwnProperty.call(i.children, o)) throw new p("ENOENT", "No such file or directory");
160
+ let c = i.children[o];
161
+ if (c.type !== "directory") throw new p("ENOTDIR", "Not a directory");
162
+ if (Object.keys(c.children).length > 0) throw new p("ENOTEMPTY", "Directory not empty");
163
+ delete i.children[o];
164
+ }
165
+ truncate(e, t = 0) {
166
+ let o = T$1(this, n, f).call(this, e);
167
+ if (o.type !== "file") throw new p("EISDIR", "Is a directory");
168
+ let i = h(this, m).get(o.backingFilename);
169
+ if (!i) throw new p("ENOENT", "No such file or directory");
170
+ i.truncate(t), h(this, S).add(i);
171
+ }
172
+ unlink(e) {
173
+ T$1(this, n, O).call(this, { opp: "unlink", args: [e] }, () => {
174
+ this._unlinkState(e, true);
175
+ });
176
+ }
177
+ _unlinkState(e, t = false) {
178
+ let o = T$1(this, n, w).call(this, e), i = o.pop(), c = T$1(this, n, f).call(this, o.join("/"));
179
+ if (!Object.prototype.hasOwnProperty.call(c.children, i)) throw new p("ENOENT", "No such file or directory");
180
+ let a = c.children[i];
181
+ if (a.type !== "file") throw new p("EISDIR", "Is a directory");
182
+ if (delete c.children[i], t) {
183
+ let h$1 = h(this, m).get(a.backingFilename);
184
+ h$1?.truncate(0), h(this, S).add(h$1), h(this, D).has(e) && (h(this, P).delete(h(this, D).get(e)), h(this, D).delete(e));
185
+ }
186
+ this.state.pool.push(a.backingFilename);
187
+ }
188
+ utimes(e, t, o) {
189
+ T$1(this, n, O).call(this, { opp: "utimes", args: [e, t, o] }, () => {
190
+ this._utimesState(e, t, o);
191
+ });
192
+ }
193
+ _utimesState(e, t, o) {
194
+ let i = T$1(this, n, f).call(this, e);
195
+ i.lastModified = o;
196
+ }
197
+ writeFile(e, t, o) {
198
+ let i = T$1(this, n, w).call(this, e), c = i.pop(), a = T$1(this, n, f).call(this, i.join("/"));
199
+ if (Object.prototype.hasOwnProperty.call(a.children, c)) {
200
+ let l = a.children[c];
201
+ l.lastModified = Date.now(), T$1(this, n, k).call(this, { opp: "setLastModified", args: [e, l.lastModified] });
202
+ } else {
203
+ if (this.state.pool.length === 0) throw new Error("No more file handles available in the pool");
204
+ let l = { type: "file", lastModified: Date.now(), mode: o?.mode || T.FILE, backingFilename: this.state.pool.pop() };
205
+ a.children[c] = l, T$1(this, n, k).call(this, { opp: "createFileNode", args: [e, l] });
206
+ }
207
+ let h$1 = a.children[c], d = h(this, m).get(h$1.backingFilename);
208
+ t.length > 0 && (d.write(typeof t == "string" ? new TextEncoder().encode(t) : new Uint8Array(t), { at: 0 }), e.startsWith("/pg_wal") && h(this, S).add(d));
209
+ }
210
+ _createFileNodeState(e, t) {
211
+ let o = T$1(this, n, w).call(this, e), i = o.pop(), c = T$1(this, n, f).call(this, o.join("/"));
212
+ c.children[i] = t;
213
+ let a = this.state.pool.indexOf(t.backingFilename);
214
+ return a > -1 && this.state.pool.splice(a, 1), t;
215
+ }
216
+ _setLastModifiedState(e, t) {
217
+ let o = T$1(this, n, f).call(this, e);
218
+ o.lastModified = t;
219
+ }
220
+ write(e, t, o, i, c) {
221
+ let a = T$1(this, n, I).call(this, e), h$1 = T$1(this, n, f).call(this, a);
222
+ if (h$1.type !== "file") throw new p("EISDIR", "Is a directory");
223
+ let d = h(this, m).get(h$1.backingFilename);
224
+ if (!d) throw new p("EBADF", "Bad file descriptor");
225
+ let l = d.write(new Uint8Array(t, o, i), { at: c });
226
+ return a.startsWith("/pg_wal") && h(this, S).add(d), l;
227
+ }
228
+ };
229
+ H = /* @__PURE__ */ new WeakMap(), v = /* @__PURE__ */ new WeakMap(), F = /* @__PURE__ */ new WeakMap(), M = /* @__PURE__ */ new WeakMap(), y = /* @__PURE__ */ new WeakMap(), b = /* @__PURE__ */ new WeakMap(), m = /* @__PURE__ */ new WeakMap(), x = /* @__PURE__ */ new WeakMap(), P = /* @__PURE__ */ new WeakMap(), D = /* @__PURE__ */ new WeakMap(), S = /* @__PURE__ */ new WeakMap(), n = /* @__PURE__ */ new WeakSet(), C = async function() {
230
+ x$1(this, H, await navigator.storage.getDirectory()), x$1(this, v, await T$1(this, n, j).call(this, this.dataDir, { create: true })), x$1(this, F, await T$1(this, n, j).call(this, G, { from: h(this, v), create: true })), x$1(this, M, await h(this, v).getFileHandle($, { create: true })), x$1(this, y, await h(this, M).createSyncAccessHandle());
231
+ let e = new ArrayBuffer(h(this, y).getSize());
232
+ h(this, y).read(e, { at: 0 });
233
+ let t, o = new TextDecoder().decode(e).split(`
234
+ `), i = false;
235
+ try {
236
+ t = JSON.parse(o[0]);
237
+ } catch {
238
+ t = { root: { type: "directory", lastModified: Date.now(), mode: T.DIR, children: {} }, pool: [] }, h(this, y).truncate(0), h(this, y).write(new TextEncoder().encode(JSON.stringify(t)), { at: 0 }), i = true;
239
+ }
240
+ this.state = t;
241
+ let c = o.slice(1).filter(Boolean).map((l) => JSON.parse(l));
242
+ for (let l of c) {
243
+ let u2 = `_${l.opp}State`;
244
+ if (typeof this[u2] == "function") try {
245
+ this[u2].bind(this)(...l.args);
246
+ } catch (N) {
247
+ console.warn("Error applying OPFS AHP WAL entry", l, N);
248
+ }
249
+ }
250
+ let a = [], h$1 = async (l) => {
251
+ if (l.type === "file") try {
252
+ let u2 = await h(this, F).getFileHandle(l.backingFilename), N = await u2.createSyncAccessHandle();
253
+ h(this, b).set(l.backingFilename, u2), h(this, m).set(l.backingFilename, N);
254
+ } catch (u2) {
255
+ console.error("Error opening file handle for node", l, u2);
256
+ }
257
+ else for (let u2 of Object.values(l.children)) a.push(h$1(u2));
258
+ };
259
+ await h$1(this.state.root);
260
+ let d = [];
261
+ for (let l of this.state.pool) d.push(new Promise(async (u2) => {
262
+ h(this, b).has(l) && console.warn("File handle already exists for pool file", l);
263
+ let N = await h(this, F).getFileHandle(l), U2 = await N.createSyncAccessHandle();
264
+ h(this, b).set(l, N), h(this, m).set(l, U2), u2();
265
+ }));
266
+ await Promise.all([...a, ...d]), await this.maintainPool(i ? this.initialPoolSize : this.maintainedPoolSize);
267
+ }, O = function(e, t) {
268
+ let o = T$1(this, n, k).call(this, e);
269
+ try {
270
+ t();
271
+ } catch (i) {
272
+ throw h(this, y).truncate(o), i;
273
+ }
274
+ }, k = function(e) {
275
+ let t = JSON.stringify(e), o = new TextEncoder().encode(`
276
+ ${t}`), i = h(this, y).getSize();
277
+ return h(this, y).write(o, { at: i }), h(this, S).add(h(this, y)), i;
278
+ }, w = function(e) {
279
+ return e.split("/").filter(Boolean);
280
+ }, f = function(e, t) {
281
+ let o = T$1(this, n, w).call(this, e), i = t || this.state.root;
282
+ for (let c of o) {
283
+ if (i.type !== "directory") throw new p("ENOTDIR", "Not a directory");
284
+ if (!Object.prototype.hasOwnProperty.call(i.children, c)) throw new p("ENOENT", "No such file or directory");
285
+ i = i.children[c];
286
+ }
287
+ return i;
288
+ }, I = function(e) {
289
+ let t = h(this, P).get(e);
290
+ if (!t) throw new p("EBADF", "Bad file descriptor");
291
+ return t;
292
+ }, W = function() {
293
+ let e = ++U(this, x)._;
294
+ for (; h(this, P).has(e); ) U(this, x)._++;
295
+ return e;
296
+ }, j = async function(e, t) {
297
+ let o = T$1(this, n, w).call(this, e), i = t?.from || h(this, H);
298
+ for (let c of o) i = await i.getDirectoryHandle(c, { create: t?.create });
299
+ return i;
300
+ };
301
+ var p = class extends Error {
302
+ constructor(A, e) {
303
+ super(e), typeof A == "number" ? this.code = A : typeof A == "string" && (this.code = Ve[A]);
304
+ }
305
+ };
306
+ export {
307
+ L as OpfsAhpFS
308
+ };