@opfs-vfs/effect 0.3.1 → 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 +13 -5
- package/dist/errors.js +1 -2
- package/dist/index.js +256 -232
- package/dist/volume-DMrEmDUv.js +355 -0
- package/dist/volume.js +1 -2
- package/package.json +10 -10
- package/dist/volume-BIqpe5Vt.js +0 -357
package/dist/index.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import { d as e, f as t, l as n, t as r } from "./volume-
|
|
1
|
+
import { d as e, f as t, l as n, t as r } from "./volume-DMrEmDUv.js";
|
|
2
2
|
import { EncryptionError as i, MountError as a, RemoteErrorDetails as o, SubscriptionError as s, VolumeError as c, mountError as l, remoteDetails as u } from "./errors.js";
|
|
3
3
|
import { ByteSize as d, Cause as f, Context as p, Deferred as m, Effect as h, Exit as g, FileSystem as _, Layer as v, Option as y, PlatformError as b, Queue as x, Schema as S, Scope as C, Semaphore as w, Stream as T } from "effect";
|
|
4
4
|
import { OpenFlags as E } from "@opfs-vfs/opfs-vfs";
|
|
5
5
|
import { VfsCommandError as D } from "@opfs-vfs/opfs-vfs/worker";
|
|
6
6
|
import { subscribe as ee } from "@opfs-vfs/plugin-subscriptions/client";
|
|
7
|
-
|
|
7
|
+
// src/subscriptions-internal.ts
|
|
8
8
|
var te = 16, ne = Symbol("retry subscription on captured generation"), O = /* @__PURE__ */ new Set([
|
|
9
9
|
"SUBSCRIPTION_OVERFLOW",
|
|
10
10
|
"SUBSCRIPTION_INTERRUPTED",
|
|
@@ -81,12 +81,12 @@ var te = 16, ne = Symbol("retry subscription on captured generation"), O = /* @_
|
|
|
81
81
|
let e = Math.max(0, r.currentTimeMillisUnsafe() - l);
|
|
82
82
|
n.remaining = Math.max(0, n.remaining - e);
|
|
83
83
|
})), h.andThen(se(e, t, n, r, i)));
|
|
84
|
-
}),
|
|
84
|
+
}), ce = (e, t, n) => h.uninterruptibleMask((r) => h.gen(function* () {
|
|
85
85
|
let i = yield* h.scope;
|
|
86
86
|
if (i.state._tag === "Closed") return yield* h.fail(k(Object.assign(/* @__PURE__ */ Error("Subscription scope is closed"), { code: "EBADF" }), e.fileName, ""));
|
|
87
87
|
let a = yield* C.fork(i, "sequential"), o = typeof t?.path == "string" ? t.path : "", c = new AbortController(), l = !1, d = !1, f, p, _, v, y, b = yield* x.bounded(te), S = m.makeUnsafe(), w = (t) => {
|
|
88
88
|
f || (f = k(t, e.fileName, o), m.doneUnsafe(S, h.succeed(f)), x.shutdownUnsafe(b));
|
|
89
|
-
}, E, D, O,
|
|
89
|
+
}, E, D, O, ce = h.uninterruptibleMask(() => h.gen(function* () {
|
|
90
90
|
if (l = !0, c.abort(), _ && (_.state = "retiring"), y) {
|
|
91
91
|
let e = yield* h.tryPromise({
|
|
92
92
|
try: () => y,
|
|
@@ -96,7 +96,7 @@ var te = 16, ne = Symbol("retry subscription on captured generation"), O = /* @_
|
|
|
96
96
|
}
|
|
97
97
|
x.shutdownUnsafe(b), m.doneUnsafe(S, h.succeed(void 0));
|
|
98
98
|
}).pipe(h.ensuring(h.sync(() => e.files.delete(O))), h.orDie));
|
|
99
|
-
return E = yield* h.cached(
|
|
99
|
+
return E = yield* h.cached(ce), D = yield* h.cached(h.uninterruptible(C.close(a, g.void).pipe(h.andThen(E)))), O = () => D, e.files.add(O), yield* C.addFinalizer(a, E), a.state._tag === "Closed" || e.isClosed() ? (yield* O(), yield* h.fail(k(Object.assign(/* @__PURE__ */ Error("Subscription scope is closed"), { code: "EBADF" }), e.fileName, ""))) : yield* h.gen(function* () {
|
|
100
100
|
if (!e.subscriptionsAvailable) return yield* h.fail(k(ae(e.fileName), e.fileName, o));
|
|
101
101
|
if (typeof o != "string" || !o.startsWith("/")) return yield* h.fail(k(Object.assign(/* @__PURE__ */ Error("path must be absolute"), { code: "EINVAL" }), e.fileName, o));
|
|
102
102
|
if (e.isClosed()) return yield* h.fail(k(e.terminal(), e.fileName, o));
|
|
@@ -191,9 +191,7 @@ var te = 16, ne = Symbol("retry subscription on captured generation"), O = /* @_
|
|
|
191
191
|
if (te === ne) {
|
|
192
192
|
if ((yield* r(e.awaitReady(a, "subscribe").pipe(h.mapError((t) => k(t, e.fileName, o))))) !== g) return yield* h.fail(A(e, g, o) ?? k(Object.assign(/* @__PURE__ */ Error("Owner changed during subscription setup"), { code: "VFS_ATTACHMENT_LOST" }), e.fileName, o));
|
|
193
193
|
yield* r(se(e, g, a, i, o));
|
|
194
|
-
|
|
195
|
-
}
|
|
196
|
-
return yield* h.fail(k(te, e.fileName, o));
|
|
194
|
+
} else return yield* h.fail(k(te, e.fileName, o));
|
|
197
195
|
}
|
|
198
196
|
let D = p.closed.then((t) => (t.status === "released" && setTimeout(() => {
|
|
199
197
|
l || f || (x.endUnsafe(b), m.doneUnsafe(S, h.succeed(void 0)));
|
|
@@ -203,10 +201,10 @@ var te = 16, ne = Symbol("retry subscription on captured generation"), O = /* @_
|
|
|
203
201
|
retired: h.promise(() => D)
|
|
204
202
|
};
|
|
205
203
|
}).pipe(h.onExit((e) => g.isFailure(e) ? C.close(a, e) : h.void));
|
|
206
|
-
})),
|
|
207
|
-
Subscriptions: () =>
|
|
208
|
-
layer: () =>
|
|
209
|
-
}),
|
|
204
|
+
})), le = /* @__PURE__ */ t({
|
|
205
|
+
Subscriptions: () => ue,
|
|
206
|
+
layer: () => de
|
|
207
|
+
}), ue = class extends p.Service()("@opfs-vfs/effect/Subscriptions") {}, de = v.effect(ue, h.gen(function* () {
|
|
210
208
|
let t = yield* r, n = e(t);
|
|
211
209
|
return !n || !n.subscriptionsAvailable ? yield* h.fail(new c({
|
|
212
210
|
kind: "unsupported",
|
|
@@ -215,8 +213,8 @@ var te = 16, ne = Symbol("retry subscription on captured generation"), O = /* @_
|
|
|
215
213
|
code: "ENOTSUP",
|
|
216
214
|
outcome: "not-applied",
|
|
217
215
|
details: null
|
|
218
|
-
})) : { subscribe: (e) =>
|
|
219
|
-
})),
|
|
216
|
+
})) : { subscribe: (e) => ce(n, e) };
|
|
217
|
+
})), j = "FileSystem", fe = 16777216, pe = (e, t) => e instanceof D && e.dispatch === "refused" ? "not-applied" : e instanceof D && e.dispatch === "sent" && t ? "possibly-applied" : "unknown", me = (e, t, n) => l(e instanceof D ? e.cause : e, t, n, void 0, pe(e, !1)), M = (e, t, n, r) => new c({
|
|
220
218
|
kind: "lifecycle",
|
|
221
219
|
fileName: t,
|
|
222
220
|
operation: n,
|
|
@@ -224,28 +222,28 @@ var te = 16, ne = Symbol("retry subscription on captured generation"), O = /* @_
|
|
|
224
222
|
outcome: r,
|
|
225
223
|
details: e.details,
|
|
226
224
|
...e.cause === void 0 ? {} : { cause: e.cause }
|
|
227
|
-
}),
|
|
225
|
+
}), he = (e, t) => {
|
|
228
226
|
if (t instanceof c && t.kind === "lifecycle" && t.cause !== void 0) return "Unknown";
|
|
229
227
|
let n = e.code ?? "";
|
|
230
228
|
return n === "ENOENT" ? "NotFound" : n === "EEXIST" ? "AlreadyExists" : n === "EACCES" || n === "EPERM" ? "PermissionDenied" : n === "EISDIR" || n === "ENOTDIR" || n === "ELOOP" || n === "EBADF" ? "BadResource" : n === "EBUSY" ? "Busy" : n === "VFS_OWNER_READY_TIMEOUT" || n === "LEADER_RESPONSE_TIMEOUT" ? "TimedOut" : t instanceof c && t.kind === "corruption" || "reason" in t && (t.reason === "IntegrityFailure" || t.reason === "VaultCorrupt" || t.reason === "SidecarCorrupt") ? "InvalidData" : "Unknown";
|
|
231
|
-
},
|
|
229
|
+
}, N = (e, t, n, r = null, i = !1) => {
|
|
232
230
|
if (b.isPlatformError(e)) return e;
|
|
233
|
-
let a = (e instanceof D ? e : void 0)?.cause ?? e, o = u(a), s =
|
|
231
|
+
let a = (e instanceof D ? e : void 0)?.cause ?? e, o = u(a), s = pe(e, i), d = e instanceof c ? e : l(a, r, t, void 0, s);
|
|
234
232
|
return b.systemError({
|
|
235
|
-
_tag:
|
|
236
|
-
module:
|
|
233
|
+
_tag: he(o, d),
|
|
234
|
+
module: j,
|
|
237
235
|
method: t,
|
|
238
236
|
...n === void 0 ? {} : { pathOrDescriptor: n },
|
|
239
237
|
...o.message ? { description: o.message } : {},
|
|
240
238
|
cause: d
|
|
241
239
|
});
|
|
242
|
-
},
|
|
243
|
-
module:
|
|
240
|
+
}, P = (e, t) => typeof t != "string" || !t.startsWith("/") ? b.badArgument({
|
|
241
|
+
module: j,
|
|
244
242
|
method: e,
|
|
245
243
|
description: "path must be absolute"
|
|
246
|
-
}) : void 0,
|
|
244
|
+
}) : void 0, ge = (e, t, n = null) => b.systemError({
|
|
247
245
|
_tag: "Unknown",
|
|
248
|
-
module:
|
|
246
|
+
module: j,
|
|
249
247
|
method: e,
|
|
250
248
|
...t === void 0 ? {} : { pathOrDescriptor: t },
|
|
251
249
|
description: "Operation is not supported by this adapter slice",
|
|
@@ -258,7 +256,7 @@ var te = 16, ne = Symbol("retry subscription on captured generation"), O = /* @_
|
|
|
258
256
|
outcome: "not-applied",
|
|
259
257
|
details: null
|
|
260
258
|
})
|
|
261
|
-
}),
|
|
259
|
+
}), _e = (e, t, n) => {
|
|
262
260
|
let r = new s({
|
|
263
261
|
code: "SUBSCRIPTION_INTERRUPTED",
|
|
264
262
|
fileName: e.fileName,
|
|
@@ -268,70 +266,75 @@ var te = 16, ne = Symbol("retry subscription on captured generation"), O = /* @_
|
|
|
268
266
|
});
|
|
269
267
|
return b.systemError({
|
|
270
268
|
_tag: "Unknown",
|
|
271
|
-
module:
|
|
269
|
+
module: j,
|
|
272
270
|
method: "watch",
|
|
273
271
|
pathOrDescriptor: t,
|
|
274
272
|
cause: r
|
|
275
273
|
});
|
|
276
|
-
},
|
|
274
|
+
}, F = (e, t, n) => {
|
|
277
275
|
if (b.isPlatformError(n)) {
|
|
278
276
|
let r = n.reason.cause;
|
|
279
|
-
return S.is(c)(r) && r.code === "VFS_ATTACHMENT_LOST" ?
|
|
277
|
+
return S.is(c)(r) && r.code === "VFS_ATTACHMENT_LOST" ? _e(e, t, r) : n;
|
|
280
278
|
}
|
|
281
|
-
return S.is(s)(n) ? S.is(c)(n.cause) && n.cause.kind === "unsupported" ?
|
|
279
|
+
return S.is(s)(n) ? S.is(c)(n.cause) && n.cause.kind === "unsupported" ? N(n.cause, "watch", t, e.fileName) : n.code === "SUBSCRIPTION_INTERRUPTED" ? b.systemError({
|
|
282
280
|
_tag: "Unknown",
|
|
283
|
-
module:
|
|
281
|
+
module: j,
|
|
284
282
|
method: "watch",
|
|
285
283
|
pathOrDescriptor: t,
|
|
286
284
|
cause: n
|
|
287
|
-
}) : n.sourceCode === "VFS_ATTACHMENT_LOST" ?
|
|
285
|
+
}) : n.sourceCode === "VFS_ATTACHMENT_LOST" ? _e(e, t, n) : n.sourceCode === "VFS_OWNER_READY_TIMEOUT" || n.sourceCode === "VFS_SUBSCRIPTION_RETIREMENT_TIMEOUT" ? b.systemError({
|
|
288
286
|
_tag: "TimedOut",
|
|
289
|
-
module:
|
|
287
|
+
module: j,
|
|
290
288
|
method: "watch",
|
|
291
289
|
pathOrDescriptor: t,
|
|
292
290
|
cause: n
|
|
293
291
|
}) : b.systemError({
|
|
294
292
|
_tag: "Unknown",
|
|
295
|
-
module:
|
|
293
|
+
module: j,
|
|
296
294
|
method: "watch",
|
|
297
295
|
pathOrDescriptor: t,
|
|
298
296
|
cause: n
|
|
299
|
-
}) :
|
|
300
|
-
},
|
|
301
|
-
let d =
|
|
302
|
-
|
|
303
|
-
|
|
297
|
+
}) : N(n, "watch", t, e.fileName);
|
|
298
|
+
}, I = (e, t, n, r, i = !1, a = !0, o, s, l = !0) => {
|
|
299
|
+
let d = P(t, n);
|
|
300
|
+
if (d) return h.fail(d);
|
|
301
|
+
let p = (r) => {
|
|
302
|
+
let a = r instanceof D ? e.terminal() : void 0;
|
|
303
|
+
return N(a ? M(a, e.fileName, t, pe(r, i)) : r, t, n, e.fileName, i);
|
|
304
|
+
};
|
|
305
|
+
return h.gen(function* () {
|
|
306
|
+
let d = s ?? { remaining: e.readinessTimeout }, _ = 0, v, y;
|
|
304
307
|
for (;;) {
|
|
305
308
|
let s = yield* h.result(e.awaitReady(d, t));
|
|
306
|
-
if (s._tag === "Failure") return yield* h.fail(
|
|
307
|
-
let
|
|
308
|
-
if (o !== void 0 &&
|
|
309
|
-
if (
|
|
310
|
-
let
|
|
309
|
+
if (s._tag === "Failure") return yield* h.fail(N(v && u(s.failure).code === "VFS_OWNER_READY_TIMEOUT" ? v : e.terminal() ? M(s.failure, e.fileName, t, "not-applied") : s.failure, t, n, e.fileName, i));
|
|
310
|
+
let b = s.success;
|
|
311
|
+
if (o !== void 0 && b !== o) return yield* h.fail(N(ve(), t, n, e.fileName, i));
|
|
312
|
+
if (y === b) return yield* h.fail(N(v, t, n, e.fileName, i));
|
|
313
|
+
let x = () => h.scoped(h.gen(function* () {
|
|
311
314
|
if (i) {
|
|
312
|
-
let n = h.asVoid(h.raceFirst(h.acquireRelease(w.take(e.gate, 1), () => w.release(e.gate, 1), { interruptible: !0 }), m.await(e.terminalSignal).pipe(h.flatMap((n) => h.fail(
|
|
315
|
+
let n = h.asVoid(h.raceFirst(h.acquireRelease(w.take(e.gate, 1), () => w.release(e.gate, 1), { interruptible: !0 }), m.await(e.terminalSignal).pipe(h.flatMap((n) => h.fail(M(n, e.fileName, t, "not-applied"))))));
|
|
313
316
|
yield* l ? h.interruptible(n) : h.uninterruptible(n);
|
|
314
317
|
}
|
|
315
318
|
let n = e.terminal(), a = e.currentGeneration();
|
|
316
|
-
if (e.isClosed() || n) return yield* h.fail(n ?
|
|
319
|
+
if (e.isClosed() || n) return yield* h.fail(n ? M(n, e.fileName, t, "not-applied") : new c({
|
|
317
320
|
kind: "lifecycle",
|
|
318
321
|
fileName: e.fileName,
|
|
319
322
|
operation: t,
|
|
320
323
|
outcome: "not-applied",
|
|
321
324
|
details: null
|
|
322
325
|
}));
|
|
323
|
-
if (a !==
|
|
326
|
+
if (a !== b) return yield* h.succeed({ retry: !0 });
|
|
324
327
|
let o = e.continuity;
|
|
325
|
-
i && (o._tag === "lost" || o._tag === "pending" && o.generation !==
|
|
328
|
+
i && (o._tag === "lost" || o._tag === "pending" && o.generation !== b ? e.continuity = {
|
|
326
329
|
_tag: "lost",
|
|
327
330
|
generation: o.generation
|
|
328
331
|
} : o._tag === "clean" && (e.continuity = {
|
|
329
332
|
_tag: "pending",
|
|
330
|
-
generation:
|
|
333
|
+
generation: b
|
|
331
334
|
}));
|
|
332
335
|
let s = h.suspend(() => {
|
|
333
336
|
try {
|
|
334
|
-
let t = r(e.backend,
|
|
337
|
+
let t = r(e.backend, b, p);
|
|
335
338
|
return h.isEffect(t) ? t : h.tryPromise({
|
|
336
339
|
try: () => Promise.resolve(t),
|
|
337
340
|
catch: (e) => e
|
|
@@ -347,31 +350,48 @@ var te = 16, ne = Symbol("retry subscription on captured generation"), O = /* @_
|
|
|
347
350
|
let n = t.reasons.length === 1 && t.reasons[0]._tag === "Fail" ? t.reasons[0].error : void 0;
|
|
348
351
|
return n instanceof D && n.dispatch === "refused" && (e.continuity = o), h.failCause(t);
|
|
349
352
|
})) : s;
|
|
350
|
-
})),
|
|
351
|
-
if (g.isFailure(
|
|
352
|
-
let
|
|
353
|
-
if (a &&
|
|
354
|
-
|
|
353
|
+
})), S = i ? h.uninterruptibleMask(() => x()) : x(), C = yield* h.exit(S);
|
|
354
|
+
if (g.isFailure(C)) {
|
|
355
|
+
let t = C.cause.reasons.length === 1 && C.cause.reasons[0]._tag === "Fail" ? C.cause.reasons[0].error : void 0;
|
|
356
|
+
if (a && _ === 0 && e.canRecapture() && t instanceof D && t.dispatch === "refused" && u(t.cause).code === "VFS_ATTACHMENT_LOST" && e.currentGeneration() !== b && !e.terminal()) {
|
|
357
|
+
_++, v = t, y = b;
|
|
355
358
|
continue;
|
|
356
359
|
}
|
|
357
|
-
return yield* h.failCause(f.map(
|
|
358
|
-
let a = r instanceof D ? e.terminal() : void 0;
|
|
359
|
-
return P(a ? N(a, e.fileName, t, fe(r, i)) : r, t, n, e.fileName, i);
|
|
360
|
-
}));
|
|
361
|
-
}
|
|
362
|
-
let C = S.value;
|
|
363
|
-
if (C.retry) {
|
|
364
|
-
let r = _e();
|
|
365
|
-
if (o !== void 0 || !a || p++ >= 1 || !e.canRecapture() || e.terminal()) return yield* h.fail(P(r, t, n, e.fileName, i));
|
|
366
|
-
_ = r, v = void 0;
|
|
367
|
-
continue;
|
|
360
|
+
return yield* h.failCause(f.map(C.cause, p));
|
|
368
361
|
}
|
|
369
|
-
|
|
362
|
+
let T = C.value;
|
|
363
|
+
if (T.retry) {
|
|
364
|
+
let r = ve();
|
|
365
|
+
if (o !== void 0 || !a || _++ >= 1 || !e.canRecapture() || e.terminal()) return yield* h.fail(N(r, t, n, e.fileName, i));
|
|
366
|
+
v = r, y = void 0;
|
|
367
|
+
} else return T.result;
|
|
370
368
|
}
|
|
371
369
|
});
|
|
372
|
-
},
|
|
370
|
+
}, ve = () => new D(Object.assign(/* @__PURE__ */ Error("Owner changed before dispatch"), { code: "VFS_ATTACHMENT_LOST" }), "refused"), ye = (e, t) => {
|
|
371
|
+
let n = {
|
|
372
|
+
message: "Path is a directory",
|
|
373
|
+
code: "ERR_FS_EISDIR",
|
|
374
|
+
errno: 21
|
|
375
|
+
};
|
|
376
|
+
return b.systemError({
|
|
377
|
+
_tag: "Unknown",
|
|
378
|
+
module: j,
|
|
379
|
+
method: "remove",
|
|
380
|
+
pathOrDescriptor: t,
|
|
381
|
+
syscall: "rm",
|
|
382
|
+
cause: new c({
|
|
383
|
+
kind: "filesystem",
|
|
384
|
+
fileName: e.fileName,
|
|
385
|
+
operation: "remove",
|
|
386
|
+
path: t,
|
|
387
|
+
code: n.code,
|
|
388
|
+
outcome: "not-applied",
|
|
389
|
+
details: n
|
|
390
|
+
})
|
|
391
|
+
});
|
|
392
|
+
}, L = (e, t) => b.systemError({
|
|
373
393
|
_tag: "BadResource",
|
|
374
|
-
module:
|
|
394
|
+
module: j,
|
|
375
395
|
method: t,
|
|
376
396
|
cause: new c({
|
|
377
397
|
kind: "lifecycle",
|
|
@@ -381,13 +401,13 @@ var te = 16, ne = Symbol("retry subscription on captured generation"), O = /* @_
|
|
|
381
401
|
outcome: "not-applied",
|
|
382
402
|
details: null
|
|
383
403
|
})
|
|
384
|
-
}),
|
|
404
|
+
}), R = (e, t, n, r = !1) => N(Object.assign(/* @__PURE__ */ Error("Invalid result from VFS"), { code: "EIO" }), t, n, e.fileName, r), z = (e, t, n, r = !1, i = !1) => h.uninterruptibleMask((a) => h.gen(function* () {
|
|
385
405
|
let o = e.state, s = o.terminal();
|
|
386
|
-
return s ? yield* h.fail(
|
|
387
|
-
r && (yield* a(h.interruptible(h.asVoid(h.raceFirst(h.acquireRelease(w.take(o.gate, 1), () => w.release(o.gate, 1), { interruptible: !0 }), m.await(o.terminalSignal).pipe(h.flatMap((n) => h.fail(
|
|
406
|
+
return s ? yield* h.fail(N(s, t, e.path, o.fileName, r)) : e.closed || o.isClosed() || o.currentGeneration() !== e.generation ? yield* h.fail(L(o, t)) : yield* h.scoped(h.gen(function* () {
|
|
407
|
+
r && (yield* a(h.interruptible(h.asVoid(h.raceFirst(h.acquireRelease(w.take(o.gate, 1), () => w.release(o.gate, 1), { interruptible: !0 }), m.await(o.terminalSignal).pipe(h.flatMap((n) => h.fail(N(n, t, e.path, o.fileName, r)))))))));
|
|
388
408
|
let s = o.terminal();
|
|
389
|
-
if (s) return yield* h.fail(
|
|
390
|
-
if (e.closed || o.isClosed() || o.currentGeneration() !== e.generation) return yield* h.fail(
|
|
409
|
+
if (s) return yield* h.fail(N(s, t, e.path, o.fileName, r));
|
|
410
|
+
if (e.closed || o.isClosed() || o.currentGeneration() !== e.generation) return yield* h.fail(L(o, t));
|
|
391
411
|
let c = o.continuity;
|
|
392
412
|
r && !i && (c._tag === "lost" || c._tag === "pending" && c.generation !== e.generation ? o.continuity = {
|
|
393
413
|
_tag: "lost",
|
|
@@ -401,22 +421,22 @@ var te = 16, ne = Symbol("retry subscription on captured generation"), O = /* @_
|
|
|
401
421
|
catch: (e) => e
|
|
402
422
|
}).pipe(h.catchCause((n) => {
|
|
403
423
|
let a = n.reasons.length === 1 && n.reasons[0]._tag === "Fail" ? n.reasons[0].error : void 0;
|
|
404
|
-
return r && !i && a instanceof D && a.dispatch === "refused" && (o.continuity = c), h.failCause(f.map(n, (n) =>
|
|
424
|
+
return r && !i && a instanceof D && a.dispatch === "refused" && (o.continuity = c), h.failCause(f.map(n, (n) => N(n, t, e.path, o.fileName, r)));
|
|
405
425
|
}));
|
|
406
426
|
return i && o.continuity._tag === "pending" && o.continuity.generation === e.generation && (o.continuity = { _tag: "clean" }), l;
|
|
407
427
|
}));
|
|
408
|
-
})),
|
|
428
|
+
})), be = (e, t, n) => "forGeneration" in e ? e.forGeneration(t).stat(n) : e.statSync(n), xe = (e) => (e.closed = !0, e.closing ??= (async () => {
|
|
409
429
|
if (!e.openLaunched || (e.openingDone && await e.openingDone, e.fd === void 0)) return;
|
|
410
430
|
let t = e.state.backend;
|
|
411
431
|
"forGeneration" in t ? await t.forGeneration(e.generation).close(e.fd) : t.closeSync(e.fd);
|
|
412
432
|
})().finally(() => {
|
|
413
433
|
e.release && e.state.files.delete(e.release);
|
|
414
|
-
}), e.closing),
|
|
434
|
+
}), e.closing), Se = (e, t, n, r = !1, i = !1) => $(e, t, () => z(e, t, () => n(e.state.backend), r, i)), Ce = (e, t, n, r, i, a, o) => {
|
|
415
435
|
if (!Object.hasOwn(Y, n)) return h.fail(Z("open", "unsupported file flag"));
|
|
416
436
|
if (r !== void 0 && !X(r)) return h.fail(Z("open", "mode must be an unsigned 32-bit integer"));
|
|
417
437
|
let s = a ?? Y[n], c = (s & (E.O_CREAT | E.O_TRUNC)) !== 0;
|
|
418
438
|
return h.uninterruptibleMask((n) => h.gen(function* () {
|
|
419
|
-
let a =
|
|
439
|
+
let a = P("open", t);
|
|
420
440
|
if (a) return yield* h.fail(a);
|
|
421
441
|
let l = yield* h.scope, u = yield* C.fork(l, "sequential"), d, p = {
|
|
422
442
|
state: e,
|
|
@@ -429,15 +449,15 @@ var te = 16, ne = Symbol("retry subscription on captured generation"), O = /* @_
|
|
|
429
449
|
closed: !1
|
|
430
450
|
};
|
|
431
451
|
p.release = () => h.tryPromise({
|
|
432
|
-
try: () =>
|
|
433
|
-
catch: (t) =>
|
|
452
|
+
try: () => xe(p),
|
|
453
|
+
catch: (t) => me(t, e.fileName, "close")
|
|
434
454
|
}).pipe(h.orDie), e.files.add(p.release), yield* C.addFinalizer(u, p.release());
|
|
435
455
|
let m = () => p.closed || e.isClosed() || e.scope?.state._tag === "Closed" || l.state._tag === "Closed" || u.state._tag === "Closed", _ = () => new D(Object.assign(/* @__PURE__ */ Error("File scope is closed"), { code: "EBADF" }), "refused"), v = (e) => h.gen(function* () {
|
|
436
456
|
let t = yield* h.exit(p.release());
|
|
437
457
|
return yield* h.exit(C.close(u, e)), g.isFailure(t) ? yield* h.failCause(f.combine(e.cause, t.cause)) : yield* h.failCause(e.cause);
|
|
438
458
|
}), y = (e) => g.fail(e);
|
|
439
|
-
if (m()) return yield* v(y(
|
|
440
|
-
let x = "", S = yield* h.exit(n(
|
|
459
|
+
if (m()) return yield* v(y(L(e, "open")));
|
|
460
|
+
let x = "", S = yield* h.exit(n(I(e, "open", t, (e, n) => {
|
|
441
461
|
if (m()) return h.fail(_());
|
|
442
462
|
x = n, p.openLaunched = !0, p.openingDone = new Promise((e) => {
|
|
443
463
|
d = e;
|
|
@@ -450,32 +470,32 @@ var te = 16, ne = Symbol("retry subscription on captured generation"), O = /* @_
|
|
|
450
470
|
}, c, !1, i, o)));
|
|
451
471
|
return g.isSuccess(S) && (p.fd = S.value, p.generation = x), g.isFailure(S) ? yield* v(S) : m() ? yield* v(y(b.systemError({
|
|
452
472
|
_tag: "BadResource",
|
|
453
|
-
module:
|
|
473
|
+
module: j,
|
|
454
474
|
method: "open"
|
|
455
475
|
}))) : p;
|
|
456
476
|
}));
|
|
457
|
-
},
|
|
477
|
+
}, B = (e, t, n, r, i = !1, a, o, s) => h.flatMap(Ce(e, t, n, r, a, o, s), (n) => n.closed ? h.fail(b.systemError({
|
|
458
478
|
_tag: "BadResource",
|
|
459
|
-
module:
|
|
479
|
+
module: j,
|
|
460
480
|
method: "open"
|
|
461
481
|
})) : h.succeed({
|
|
462
482
|
[_.FileTypeId]: _.FileTypeId,
|
|
463
|
-
stat:
|
|
483
|
+
stat: Se(n, "fstat", (e) => "forGeneration" in n.state.backend ? n.state.backend.forGeneration(n.generation).fstat(n.fd).then(Q) : Q(n.state.backend.fstatSync(n.fd))),
|
|
464
484
|
seek: (e, t) => $(n, "seek", () => h.gen(function* () {
|
|
465
|
-
let r = BigInt(n.cursor), i =
|
|
485
|
+
let r = BigInt(n.cursor), i = We(t === "start" ? e : r + e, "seek");
|
|
466
486
|
return typeof i == "number" ? !Number.isSafeInteger(i) || i < 0 ? yield* h.fail(Z("seek", "seek position must be a non-negative safe integer")) : (n.cursor = i, BigInt(i)) : yield* h.fail(i);
|
|
467
487
|
})),
|
|
468
|
-
sync:
|
|
488
|
+
sync: Se(n, "fsync", (e) => "forGeneration" in n.state.backend ? n.state.backend.forGeneration(n.generation).fsync(n.fd) : n.state.backend.fsyncSync(n.fd), !0, !0),
|
|
469
489
|
read: (e) => e instanceof Uint8Array ? $(n, "read", () => h.gen(function* () {
|
|
470
|
-
let t = yield*
|
|
490
|
+
let t = yield* z(n, "read", () => {
|
|
471
491
|
let t = n.state.backend;
|
|
472
492
|
return "forGeneration" in t ? t.forGeneration(n.generation).read(n.fd, e.byteLength, n.cursor) : t.readSync(n.fd, e.byteLength, n.cursor);
|
|
473
493
|
});
|
|
474
|
-
return !Number.isSafeInteger(t.read) || t.read < 0 || t.read > e.byteLength || t.buffer.byteLength < t.read ? yield* h.fail(
|
|
494
|
+
return !Number.isSafeInteger(t.read) || t.read < 0 || t.read > e.byteLength || t.buffer.byteLength < t.read ? yield* h.fail(R(n.state, "read", n.path)) : (e.set(t.buffer.subarray(0, t.read)), n.cursor += t.read, t.read);
|
|
475
495
|
})) : h.fail(Z("read", "buffer must be a Uint8Array")),
|
|
476
|
-
readAlloc: (e) => !Number.isSafeInteger(e) || e < 0 ? h.fail(Z("readAlloc", "size must be a non-negative safe integer")) : e === 0 ? $(n, "readAlloc", () => h.succeed(y.none())) :
|
|
496
|
+
readAlloc: (e) => !Number.isSafeInteger(e) || e < 0 ? h.fail(Z("readAlloc", "size must be a non-negative safe integer")) : e === 0 ? $(n, "readAlloc", () => h.succeed(y.none())) : we(n, e),
|
|
477
497
|
truncate: (e = 0) => !Number.isSafeInteger(e) || e < 0 ? h.fail(Z("truncate", "length must be a non-negative safe integer")) : $(n, "ftruncate", () => h.gen(function* () {
|
|
478
|
-
yield*
|
|
498
|
+
yield* z(n, "ftruncate", () => {
|
|
479
499
|
let t = n.state.backend;
|
|
480
500
|
return "forGeneration" in t ? t.forGeneration(n.generation).ftruncate(n.fd, e) : t.ftruncateSync(n.fd, e);
|
|
481
501
|
}, !0), n.append || (n.cursor = Math.min(n.cursor, e));
|
|
@@ -483,11 +503,11 @@ var te = 16, ne = Symbol("retry subscription on captured generation"), O = /* @_
|
|
|
483
503
|
write: (r) => r instanceof Uint8Array ? h.suspend(() => {
|
|
484
504
|
let i = Uint8Array.from(r), a = i.byteLength;
|
|
485
505
|
return $(n, "write", () => h.gen(function* () {
|
|
486
|
-
let r = yield*
|
|
506
|
+
let r = yield* z(n, "write", () => {
|
|
487
507
|
let e = n.state.backend;
|
|
488
508
|
return "forGeneration" in e ? e.forGeneration(n.generation).write(n.fd, i, n.append ? void 0 : n.cursor) : e.writeSync(n.fd, i, n.append ? void 0 : n.cursor);
|
|
489
509
|
}, !0, !1);
|
|
490
|
-
return !Number.isSafeInteger(r) || r < 0 || r > a ? yield* h.fail(
|
|
510
|
+
return !Number.isSafeInteger(r) || r < 0 || r > a ? yield* h.fail(R(e, "write", t, !0)) : (n.append || (n.cursor += r), r);
|
|
491
511
|
}));
|
|
492
512
|
}) : h.fail(Z("write", "buffer must be a Uint8Array")),
|
|
493
513
|
writeAll: (r) => r instanceof Uint8Array ? h.suspend(() => {
|
|
@@ -496,28 +516,28 @@ var te = 16, ne = Symbol("retry subscription on captured generation"), O = /* @_
|
|
|
496
516
|
let r = 0;
|
|
497
517
|
return h.gen(function* () {
|
|
498
518
|
for (; r < a.byteLength;) {
|
|
499
|
-
let i = Uint8Array.from(a.subarray(r, r + 65536)), o = i.byteLength, s = yield*
|
|
519
|
+
let i = Uint8Array.from(a.subarray(r, r + 65536)), o = i.byteLength, s = yield* z(n, "write", () => {
|
|
500
520
|
let e = n.state.backend;
|
|
501
521
|
return "forGeneration" in e ? e.forGeneration(n.generation).write(n.fd, i, n.append ? void 0 : n.cursor) : e.writeSync(n.fd, i, n.append ? void 0 : n.cursor);
|
|
502
522
|
}, !0, !1);
|
|
503
|
-
if (!Number.isSafeInteger(s) || s < 0 || s > o) return yield* h.fail(
|
|
523
|
+
if (!Number.isSafeInteger(s) || s < 0 || s > o) return yield* h.fail(R(e, "writeAll", t, !0));
|
|
504
524
|
if (r += s, n.append || (n.cursor += s), s === 0) return yield* h.fail(b.systemError({
|
|
505
525
|
_tag: "WriteZero",
|
|
506
|
-
module:
|
|
526
|
+
module: j,
|
|
507
527
|
method: "writeAll",
|
|
508
528
|
pathOrDescriptor: t
|
|
509
529
|
}));
|
|
510
530
|
}
|
|
511
|
-
}).pipe(h.catchCause((n) => r > 0 || i ? h.failCause(f.map(n, (n) =>
|
|
531
|
+
}).pipe(h.catchCause((n) => r > 0 || i ? h.failCause(f.map(n, (n) => V(e, t, n))) : h.failCause(n)));
|
|
512
532
|
});
|
|
513
533
|
}) : h.fail(Z("writeAll", "buffer must be a Uint8Array"))
|
|
514
|
-
})),
|
|
515
|
-
let n = yield*
|
|
534
|
+
})), we = (e, t) => $(e, "readAlloc", () => h.gen(function* () {
|
|
535
|
+
let n = yield* z(e, "readAlloc", () => {
|
|
516
536
|
let n = e.state.backend;
|
|
517
537
|
return "forGeneration" in n ? n.forGeneration(e.generation).read(e.fd, t, e.cursor) : n.readSync(e.fd, t, e.cursor);
|
|
518
538
|
});
|
|
519
|
-
return !Number.isSafeInteger(n.read) || n.read < 0 || n.read > t || n.buffer.byteLength < n.read ? yield* h.fail(
|
|
520
|
-
})),
|
|
539
|
+
return !Number.isSafeInteger(n.read) || n.read < 0 || n.read > t || n.buffer.byteLength < n.read ? yield* h.fail(R(e.state, "readAlloc", e.path)) : n.read === 0 ? y.none() : (e.cursor += n.read, y.some(Uint8Array.from(n.buffer.subarray(0, n.read))));
|
|
540
|
+
})), V = (e, t, n, r = "writeAll") => {
|
|
521
541
|
let a = b.isPlatformError(n) ? n.reason.cause : void 0, o = S.is(c)(a) ? new c({
|
|
522
542
|
kind: a.kind,
|
|
523
543
|
fileName: a.fileName,
|
|
@@ -544,59 +564,66 @@ var te = 16, ne = Symbol("retry subscription on captured generation"), O = /* @_
|
|
|
544
564
|
outcome: "possibly-applied",
|
|
545
565
|
details: u(n),
|
|
546
566
|
cause: n
|
|
547
|
-
}), s = o.details ?? u(n), l = b.isPlatformError(n) && n.reason._tag !== "BadArgument" ? n.reason._tag :
|
|
567
|
+
}), s = o.details ?? u(n), l = b.isPlatformError(n) && n.reason._tag !== "BadArgument" ? n.reason._tag : he(s, o);
|
|
548
568
|
return b.systemError({
|
|
549
569
|
_tag: l,
|
|
550
|
-
module:
|
|
570
|
+
module: j,
|
|
551
571
|
method: r,
|
|
552
572
|
pathOrDescriptor: t,
|
|
553
573
|
...s.message ? { description: s.message } : {},
|
|
554
574
|
cause: o
|
|
555
575
|
});
|
|
556
|
-
},
|
|
576
|
+
}, H = (e, t) => e === "/" ? `/${t}` : `${e.replace(/\/$/, "")}/${t}`, U = (e) => {
|
|
557
577
|
let t = e.replace(/\/$/, ""), n = t.lastIndexOf("/");
|
|
558
578
|
return n <= 0 ? "/" : t.slice(0, n);
|
|
559
|
-
},
|
|
579
|
+
}, W = (e) => {
|
|
580
|
+
let t = e.replace(/\/$/, "");
|
|
581
|
+
return t.slice(t.lastIndexOf("/") + 1);
|
|
582
|
+
}, G = (e) => (e.mode & 61440) == 40960, K = (e, t, n, r, i, a = !1, o, s = !0) => I(e, n, r, (e) => i(e), a, !1, t, o, s), q = (e, t, n, r) => K(e, t, "lstat", n, (e) => "forGeneration" in e ? e.forGeneration(t).lstat(n) : e.lstatSync(n), !1, r), J = (e, t, n, r) => K(e, t, "realPath", n, (e) => "forGeneration" in e ? e.forGeneration(t).realpath(n) : e.realpathSync(n), !1, r), Te = (e, t, n, r) => K(e, t, "stat", n, (e) => "forGeneration" in e ? e.forGeneration(t).stat(n) : e.statSync(n), !1, r), Ee = (e, t, n, r) => K(e, t, "remove", n, (e) => "forGeneration" in e ? e.forGeneration(t).remove(n) : e.removeSync(n), !0, r, !1), De = (e, t, n, r) => h.result(q(e, t, n, r)).pipe(h.flatMap((e) => e._tag === "Success" ? h.succeed(y.some(e.success)) : e.failure.reason._tag === "NotFound" ? h.succeed(y.none()) : h.fail(e.failure))), Oe = (e) => e === "." || e === "..", ke = (e, t) => N(Object.assign(/* @__PURE__ */ Error("No such file or directory"), { code: "ENOENT" }), "copy", t, e.fileName), Ae = (e, t, n, r) => h.gen(function* () {
|
|
560
583
|
let i = n, a = [];
|
|
561
584
|
for (;;) {
|
|
562
|
-
let
|
|
563
|
-
if (y.isSome(
|
|
585
|
+
let o = yield* De(e, t, i, r);
|
|
586
|
+
if (y.isSome(o)) {
|
|
564
587
|
let n = yield* J(e, t, i, r);
|
|
565
|
-
return (yield*
|
|
588
|
+
return (yield* Te(e, t, n, r)).is_dir ? {
|
|
566
589
|
realPath: n,
|
|
567
590
|
missing: a.reverse()
|
|
568
591
|
} : yield* h.fail(Z("copy", "destination parent is not a directory"));
|
|
569
592
|
}
|
|
570
593
|
if (i === "/") return yield* h.fail(Z("copy", "destination parent does not exist"));
|
|
571
|
-
|
|
594
|
+
let s = W(i);
|
|
595
|
+
if (Oe(s)) return yield* h.fail(ke(e, n));
|
|
596
|
+
a.push(s), i = U(i);
|
|
572
597
|
}
|
|
573
|
-
}),
|
|
598
|
+
}), je = (e, t, n, r, i) => {
|
|
574
599
|
let a = !1;
|
|
575
600
|
return h.scoped(h.gen(function* () {
|
|
576
|
-
let o = yield*
|
|
601
|
+
let o = yield* B(e, n, "r", void 0, !1, t, void 0, i), s = yield* B(e, r, "w", void 0, !1, t, E.O_WRONLY | E.O_CREAT, i);
|
|
577
602
|
a = !0;
|
|
578
603
|
let [c, l] = yield* h.all([o.stat, s.stat]), u = c.ino._tag === "Some" ? c.ino.value : void 0, d = l.ino._tag === "Some" ? l.ino.value : void 0;
|
|
579
|
-
if (u === void 0 || d === void 0) return yield* h.fail(
|
|
604
|
+
if (u === void 0 || d === void 0) return yield* h.fail(R(e, "copyFile", n));
|
|
580
605
|
if (u === d) return a = !1, yield* h.fail(Z("copyFile", "source and destination refer to the same file"));
|
|
581
606
|
for (yield* s.truncate(0);;) {
|
|
582
607
|
let e = yield* o.readAlloc(65536);
|
|
583
608
|
if (y.isNone(e)) return;
|
|
584
609
|
yield* s.writeAll(e.value);
|
|
585
610
|
}
|
|
586
|
-
}).pipe(h.catchCause((t) => a ? h.failCause(f.map(t, (t) =>
|
|
587
|
-
},
|
|
611
|
+
}).pipe(h.catchCause((t) => a ? h.failCause(f.map(t, (t) => V(e, r, t, "copyFile"))) : h.failCause(t))));
|
|
612
|
+
}, Me = (e, t, n, r, i, a, o) => {
|
|
588
613
|
let s = !1;
|
|
589
614
|
return h.gen(function* () {
|
|
590
|
-
let c = yield* q(e, t, n, o), l = c.is_dir ? yield* J(e, t, n, o) :
|
|
615
|
+
let c = yield* q(e, t, n, o), l = c.is_dir ? yield* J(e, t, n, o) : H(yield* J(e, t, U(n), o), W(n)), u = yield* Ae(e, t, U(r), o), d = yield* De(e, t, r, o);
|
|
616
|
+
if (y.isNone(d) && Oe(W(r))) return yield* h.fail(ke(e, r));
|
|
617
|
+
let f = y.isSome(d) && d.value.is_dir && !G(d.value) ? yield* J(e, t, r, o) : H(u.missing.reduce(H, u.realPath), W(r));
|
|
591
618
|
if (f === l || c.is_dir && f.startsWith(`${l.replace(/\/$/, "")}/`)) return yield* h.fail(Z("copy", "destination is the source or is inside it"));
|
|
592
|
-
u.missing.length > 0 && (yield* K(e, t, "makeDirectory",
|
|
619
|
+
u.missing.length > 0 && (yield* K(e, t, "makeDirectory", U(r), (e) => "forGeneration" in e ? e.forGeneration(t).mkdir(U(r), { recursive: !0 }) : e.mkdirSync(U(r), { recursive: !0 }), !0, o), s = !0);
|
|
593
620
|
let p = (n, r) => {
|
|
594
621
|
if (!a) return h.void;
|
|
595
622
|
let i = n.atimeMs ?? n.timestampMs, c = n.mtimeMs ?? n.timestampMs;
|
|
596
623
|
return i === void 0 || c === void 0 ? h.void : K(e, t, "utimes", r, (e) => "forGeneration" in e ? e.forGeneration(t).utimes(r, i, c) : e.utimesSync(r, i, c), !0, o).pipe(h.tap(() => h.sync(() => s = !0)));
|
|
597
624
|
}, m = (n, r) => h.gen(function* () {
|
|
598
|
-
let a = yield* q(e, t, n, o), c = yield*
|
|
599
|
-
if (l && !d && u && !G(l)) return yield* h.fail(
|
|
625
|
+
let a = yield* q(e, t, n, o), c = yield* De(e, t, r, o), l = y.getOrUndefined(c), u = G(a), d = l !== void 0 && (a.is_dir && l.is_dir || a.is_file && (l.is_file || G(l)) || u && G(l));
|
|
626
|
+
if (l && !d && u && !G(l)) return yield* h.fail(N(Object.assign(/* @__PURE__ */ Error("Destination already exists"), { code: "EEXIST" }), "copy", r, e.fileName));
|
|
600
627
|
if (l && !d) return yield* h.fail(Z("copy", "source and destination have incompatible types"));
|
|
601
628
|
if (!l || i || a.is_dir) {
|
|
602
629
|
if (u) {
|
|
@@ -604,48 +631,42 @@ var te = 16, ne = Symbol("retry subscription on captured generation"), O = /* @_
|
|
|
604
631
|
let i = yield* K(e, t, "readLink", n, (e) => "forGeneration" in e ? e.forGeneration(t).readlink(n) : e.readlinkSync(n), !1, o);
|
|
605
632
|
yield* K(e, t, "symlink", r, (e) => "forGeneration" in e ? e.forGeneration(t).symlink(i, r) : e.symlinkSync(i, r), !0, o), s = !0;
|
|
606
633
|
}
|
|
607
|
-
|
|
608
|
-
}
|
|
609
|
-
if (a.is_dir) {
|
|
634
|
+
} else if (a.is_dir) {
|
|
610
635
|
l || (yield* K(e, t, "makeDirectory", r, (e) => "forGeneration" in e ? e.forGeneration(t).mkdir(r, { mode: a.mode & 4095 | 448 }) : e.mkdirSync(r, { mode: a.mode & 4095 | 448 }), !0, o)), l || (s = !0);
|
|
611
636
|
let c = yield* K(e, t, "readDirectory", n, (e) => "forGeneration" in e ? e.forGeneration(t).readdirEntries(n) : e.readdirEntriesSync(n), !1, o);
|
|
612
|
-
for (let e of [...c].sort((e, t) => e.name.localeCompare(t.name))) yield* m(
|
|
637
|
+
for (let e of [...c].sort((e, t) => e.name.localeCompare(t.name))) yield* m(H(n, e.name), H(r, e.name));
|
|
613
638
|
(!l || i) && (yield* K(e, t, "chmod", r, (e) => "forGeneration" in e ? e.forGeneration(t).chmod(r, a.mode & 4095) : e.chmodSync(r, a.mode & 4095), !0, o), s = !0, yield* p(a, r));
|
|
614
|
-
|
|
615
|
-
}
|
|
616
|
-
if (a.is_file) {
|
|
639
|
+
} else if (a.is_file) {
|
|
617
640
|
if (!l || i) {
|
|
618
641
|
if (l && l.is_file && a.ino === l.ino) return yield* h.fail(Z("copy", "source and destination refer to the same file"));
|
|
619
|
-
l && (yield* K(e, t, "remove", r, (e) => "forGeneration" in e ? e.forGeneration(t).unlink(r) : e.unlinkSync(r), !0, o), s = !0), yield*
|
|
642
|
+
l && (yield* K(e, t, "remove", r, (e) => "forGeneration" in e ? e.forGeneration(t).unlink(r) : e.unlinkSync(r), !0, o), s = !0), yield* je(e, t, n, r, o), s = !0, yield* K(e, t, "chmod", r, (e) => "forGeneration" in e ? e.forGeneration(t).chmod(r, a.mode & 4095) : e.chmodSync(r, a.mode & 4095), !0, o), s = !0, yield* p(a, r);
|
|
620
643
|
}
|
|
621
|
-
|
|
622
|
-
}
|
|
623
|
-
return yield* h.fail(Z("copy", "unsupported source entry type"));
|
|
644
|
+
} else return yield* h.fail(Z("copy", "unsupported source entry type"));
|
|
624
645
|
}
|
|
625
646
|
});
|
|
626
647
|
if (c.is_dir && y.isSome(d) && d.value.is_dir) {
|
|
627
|
-
for (let i of yield* K(e, t, "readDirectory", n, (e) => "forGeneration" in e ? e.forGeneration(t).readdirEntries(n) : e.readdirEntriesSync(n), !1, o)) yield* m(
|
|
648
|
+
for (let i of yield* K(e, t, "readDirectory", n, (e) => "forGeneration" in e ? e.forGeneration(t).readdirEntries(n) : e.readdirEntriesSync(n), !1, o)) yield* m(H(n, i.name), H(r, i.name));
|
|
628
649
|
i && (yield* K(e, t, "chmod", r, (e) => "forGeneration" in e ? e.forGeneration(t).chmod(r, c.mode & 4095) : e.chmodSync(r, c.mode & 4095), !0, o), s = !0, yield* p(c, r));
|
|
629
650
|
} else yield* m(n, r);
|
|
630
|
-
}).pipe(h.catchCause((t) => s ? h.failCause(f.map(t, (t) =>
|
|
631
|
-
},
|
|
651
|
+
}).pipe(h.catchCause((t) => s ? h.failCause(f.map(t, (t) => V(e, r, t, "copy"))) : h.failCause(t)));
|
|
652
|
+
}, Ne = (e) => typeof e == "string" && !e.includes("/") && !e.includes("\0"), Pe = () => {
|
|
632
653
|
let e = /* @__PURE__ */ new Uint8Array(8);
|
|
633
654
|
return globalThis.crypto.getRandomValues(e), Array.from(e, (e) => e.toString(16).padStart(2, "0")).join("");
|
|
634
|
-
},
|
|
635
|
-
if (n.state._tag === "Closed") return yield* h.fail(
|
|
655
|
+
}, Fe = (e) => e.reason._tag === "AlreadyExists", Ie = (e, t, n, r) => h.gen(function* () {
|
|
656
|
+
if (n.state._tag === "Closed") return yield* h.fail(L(e, "makeTemp"));
|
|
636
657
|
let i = yield* C.fork(n, "sequential"), a, o = new Promise((e) => {
|
|
637
658
|
a = e;
|
|
638
659
|
}), s, c, l, u = h.uninterruptibleMask(() => h.gen(function* () {
|
|
639
660
|
s.closing = !0, s.started && (yield* h.tryPromise({
|
|
640
661
|
try: () => o,
|
|
641
662
|
catch: (e) => e
|
|
642
|
-
})), s.created && s.root && !s.detached && (yield*
|
|
663
|
+
})), s.created && s.root && !s.detached && (yield* Ee(e, t, s.root, s.cleanupBudget ?? { remaining: e.readinessTimeout }));
|
|
643
664
|
}).pipe(h.ensuring(h.sync(() => {
|
|
644
665
|
e.files.delete(l);
|
|
645
666
|
})), h.orDie));
|
|
646
667
|
l = () => c, c = yield* h.cached(u);
|
|
647
668
|
let d = h.uninterruptible(h.gen(function* () {
|
|
648
|
-
if (i.state._tag === "Closed" || s.closing) return yield* h.fail(
|
|
669
|
+
if (i.state._tag === "Closed" || s.closing) return yield* h.fail(L(e, "makeTemp"));
|
|
649
670
|
s.detached = !0, s.created = !1, s.root = void 0;
|
|
650
671
|
let t = C.closeUnsafe(i, g.succeed(void 0));
|
|
651
672
|
t && (yield* t);
|
|
@@ -666,33 +687,33 @@ var te = 16, ne = Symbol("retry subscription on captured generation"), O = /* @_
|
|
|
666
687
|
finishAllocation: () => a(),
|
|
667
688
|
release: l,
|
|
668
689
|
detach: d
|
|
669
|
-
}, e.files.add(l), yield* C.addFinalizer(i, l()), i.state._tag === "Closed" ? yield* h.fail(
|
|
670
|
-
}),
|
|
671
|
-
let l = yield*
|
|
690
|
+
}, e.files.add(l), yield* C.addFinalizer(i, l()), i.state._tag === "Closed" ? yield* h.fail(L(e, "makeTemp")) : s;
|
|
691
|
+
}), Le = (e, t, n, r, i, a, o) => h.suspend(() => I(e, t, n, (s, c) => h.uninterruptibleMask((s) => h.gen(function* () {
|
|
692
|
+
let l = yield* Ie(e, c, r, a);
|
|
672
693
|
l.generation = c, l.started = !0;
|
|
673
694
|
let u = yield* h.exit(s(o(c, l)).pipe(h.ensuring(h.sync(l.finishAllocation))));
|
|
674
695
|
if (g.isFailure(u)) {
|
|
675
696
|
let r = yield* h.exit(l.release());
|
|
676
697
|
yield* h.exit(C.close(l.child, u));
|
|
677
|
-
let i = l.mutated ? f.map(u.cause, (r) =>
|
|
698
|
+
let i = l.mutated ? f.map(u.cause, (r) => V(e, l.root ?? n, r, t)) : u.cause;
|
|
678
699
|
return g.isFailure(r) ? yield* h.failCause(f.combine(i, r.cause)) : yield* h.failCause(i);
|
|
679
700
|
}
|
|
680
701
|
if (e.isClosed() || l.child.state._tag === "Closed" || l.closing) {
|
|
681
|
-
let r = f.fail(
|
|
702
|
+
let r = f.fail(L(e, t)), i = yield* h.exit(l.release());
|
|
682
703
|
yield* h.exit(C.close(l.child, g.failCause(r)));
|
|
683
|
-
let a = l.mutated ? f.map(r, (r) =>
|
|
704
|
+
let a = l.mutated ? f.map(r, (r) => V(e, l.root ?? n, r, t)) : r;
|
|
684
705
|
return g.isFailure(i) ? yield* h.failCause(f.combine(a, i.cause)) : yield* h.failCause(a);
|
|
685
706
|
}
|
|
686
707
|
return i ? l.cleanupBudget = void 0 : yield* l.detach, u.value;
|
|
687
|
-
})), !1, !1, void 0, a)),
|
|
688
|
-
let a = n?.directory ?? "/tmp", o = n?.prefix ?? "", s =
|
|
708
|
+
})), !1, !1, void 0, a)), Re = (e, t, n, r, i) => {
|
|
709
|
+
let a = n?.directory ?? "/tmp", o = n?.prefix ?? "", s = P(t, a) ?? (Ne(o) ? void 0 : Z(t, "prefix must be a single path component"));
|
|
689
710
|
return s ? h.fail(s) : h.suspend(() => {
|
|
690
711
|
let n = { remaining: e.readinessTimeout };
|
|
691
|
-
return
|
|
712
|
+
return Le(e, t, a, r, i, n, (r, i) => h.gen(function* () {
|
|
692
713
|
yield* K(e, r, "makeDirectory", a, (e) => "forGeneration" in e ? e.forGeneration(r).mkdir(a, { recursive: !0 }) : e.mkdirSync(a, { recursive: !0 }), !0, n), i.mutated = !0;
|
|
693
714
|
let s = yield* J(e, r, a, n), c;
|
|
694
715
|
for (let a = 0; a < 128; a++) {
|
|
695
|
-
let a =
|
|
716
|
+
let a = H(s, `${o}${Pe()}`), l = yield* h.result(K(e, r, t, a, (e) => {
|
|
696
717
|
if ("forGeneration" in e) return e.forGeneration(r).mkdir(a).then(() => {
|
|
697
718
|
i.root = a, i.created = !0;
|
|
698
719
|
});
|
|
@@ -704,31 +725,31 @@ var te = 16, ne = Symbol("retry subscription on captured generation"), O = /* @_
|
|
|
704
725
|
generation: r,
|
|
705
726
|
owner: i
|
|
706
727
|
};
|
|
707
|
-
if (c = l.failure, !
|
|
728
|
+
if (c = l.failure, !Fe(c)) return yield* h.fail(c);
|
|
708
729
|
}
|
|
709
730
|
return yield* h.fail(c);
|
|
710
731
|
}));
|
|
711
732
|
});
|
|
712
|
-
},
|
|
713
|
-
let a = n?.directory ?? "/tmp", o = n?.prefix ?? "", s = n?.suffix ?? "", c =
|
|
733
|
+
}, ze = (e, t, n, r, i) => {
|
|
734
|
+
let a = n?.directory ?? "/tmp", o = n?.prefix ?? "", s = n?.suffix ?? "", c = P(t, a) ?? (!Ne(o) || !Ne(s) ? Z(t, "prefix and suffix must be single path components") : void 0);
|
|
714
735
|
return c ? h.fail(c) : h.suspend(() => {
|
|
715
736
|
let n = { remaining: e.readinessTimeout };
|
|
716
|
-
return
|
|
737
|
+
return Le(e, t, a, r, i, n, (r, i) => h.gen(function* () {
|
|
717
738
|
yield* K(e, r, "makeDirectory", a, (e) => "forGeneration" in e ? e.forGeneration(r).mkdir(a, { recursive: !0 }) : e.mkdirSync(a, { recursive: !0 }), !0, n), i.mutated = !0;
|
|
718
739
|
let c = yield* J(e, r, a, n), l;
|
|
719
740
|
for (let a = 0; a < 128; a++) {
|
|
720
|
-
let a =
|
|
741
|
+
let a = H(c, `${o}${Pe()}`), u = yield* h.result(K(e, r, t, a, (e) => {
|
|
721
742
|
if ("forGeneration" in e) return e.forGeneration(r).mkdir(a).then(() => {
|
|
722
743
|
i.root = a, i.created = !0;
|
|
723
744
|
});
|
|
724
745
|
e.mkdirSync(a), i.root = a, i.created = !0;
|
|
725
746
|
}, !0, n));
|
|
726
747
|
if (u._tag === "Failure") {
|
|
727
|
-
if (l = u.failure,
|
|
748
|
+
if (l = u.failure, Fe(l)) continue;
|
|
728
749
|
return yield* h.fail(l);
|
|
729
750
|
}
|
|
730
751
|
i.root = a, i.created = !0, i.mutated = !0;
|
|
731
|
-
let d =
|
|
752
|
+
let d = H(a, `${Pe()}${s}`), p = yield* h.exit(h.scoped(h.asVoid(B(e, d, "wx", void 0, !1, r, E.O_WRONLY | E.O_CREAT | E.O_EXCL, n))));
|
|
732
753
|
if (g.isSuccess(p)) return {
|
|
733
754
|
path: d,
|
|
734
755
|
root: a,
|
|
@@ -736,24 +757,24 @@ var te = 16, ne = Symbol("retry subscription on captured generation"), O = /* @_
|
|
|
736
757
|
owner: i
|
|
737
758
|
};
|
|
738
759
|
let m = p.cause.reasons.length === 1 && p.cause.reasons[0]._tag === "Fail" ? p.cause.reasons[0].error : void 0;
|
|
739
|
-
if (!b.isPlatformError(m) || !
|
|
740
|
-
let _ = yield* h.exit(
|
|
760
|
+
if (!b.isPlatformError(m) || !Fe(m)) return yield* h.failCause(p.cause);
|
|
761
|
+
let _ = yield* h.exit(Ee(e, r, a, n));
|
|
741
762
|
if (g.isFailure(_)) return yield* h.failCause(f.combine(p.cause, _.cause));
|
|
742
763
|
i.root = void 0, i.created = !1, l = m;
|
|
743
764
|
}
|
|
744
765
|
return yield* h.fail(l);
|
|
745
766
|
}));
|
|
746
767
|
});
|
|
747
|
-
},
|
|
768
|
+
}, Be = (e, t, n, r, i) => h.scoped(h.gen(function* () {
|
|
748
769
|
let i = yield* h.acquireRelease(h.tryPromise({
|
|
749
770
|
try: async () => "forGeneration" in t ? await t.forGeneration(n).open(r, E.O_RDONLY) : t.openSync(r, E.O_RDONLY),
|
|
750
771
|
catch: (e) => e
|
|
751
772
|
}), (r) => ("forGeneration" in t ? h.tryPromise({
|
|
752
773
|
try: () => t.forGeneration(n).close(r),
|
|
753
|
-
catch: (t) =>
|
|
774
|
+
catch: (t) => me(t, e.fileName, "readFile")
|
|
754
775
|
}) : h.try({
|
|
755
776
|
try: () => t.closeSync(r),
|
|
756
|
-
catch: (t) =>
|
|
777
|
+
catch: (t) => me(t, e.fileName, "readFile")
|
|
757
778
|
})).pipe(h.orDie)), a = yield* h.tryPromise({
|
|
758
779
|
try: async () => "forGeneration" in t ? await t.forGeneration(n).fstat(i) : t.fstatSync(i),
|
|
759
780
|
catch: (e) => e
|
|
@@ -772,7 +793,7 @@ var te = 16, ne = Symbol("retry subscription on captured generation"), O = /* @_
|
|
|
772
793
|
o.set(a.buffer.subarray(0, a.read), s), s += a.read;
|
|
773
794
|
}
|
|
774
795
|
return o;
|
|
775
|
-
})), Y = {
|
|
796
|
+
}).pipe(h.mapError(i))), Y = {
|
|
776
797
|
r: E.O_RDONLY,
|
|
777
798
|
"r+": E.O_RDWR,
|
|
778
799
|
w: E.O_WRONLY | E.O_CREAT | E.O_TRUNC,
|
|
@@ -783,7 +804,7 @@ var te = 16, ne = Symbol("retry subscription on captured generation"), O = /* @_
|
|
|
783
804
|
ax: E.O_WRONLY | E.O_CREAT | E.O_APPEND | E.O_EXCL,
|
|
784
805
|
"a+": E.O_RDWR | E.O_CREAT | E.O_APPEND,
|
|
785
806
|
"ax+": E.O_RDWR | E.O_CREAT | E.O_APPEND | E.O_EXCL
|
|
786
|
-
}, X = (e) => typeof e == "number" && Number.isFinite(e) && Number.isInteger(e) && e >= 0 && e <= 4294967295,
|
|
807
|
+
}, X = (e) => typeof e == "number" && Number.isFinite(e) && Number.isInteger(e) && e >= 0 && e <= 4294967295, Ve = (e) => {
|
|
787
808
|
if (!(e instanceof Date) && typeof e != "number") return Z("utimes", "time must be a Date or number");
|
|
788
809
|
let t;
|
|
789
810
|
try {
|
|
@@ -792,66 +813,62 @@ var te = 16, ne = Symbol("retry subscription on captured generation"), O = /* @_
|
|
|
792
813
|
return Z("utimes", "time must be a valid Date or number");
|
|
793
814
|
}
|
|
794
815
|
return Number.isFinite(t) && Math.abs(t) <= 864e13 ? t : Z("utimes", "time must be a finite value within the supported date range");
|
|
795
|
-
},
|
|
796
|
-
module:
|
|
816
|
+
}, He = (e) => u(e instanceof D ? e.cause : e).code === "ENOENT", Z = (e, t) => b.badArgument({
|
|
817
|
+
module: j,
|
|
797
818
|
method: e,
|
|
798
819
|
description: t
|
|
799
|
-
}), Q = (e) => {
|
|
820
|
+
}), Ue = (e) => e.is_file ? "File" : e.is_dir ? "Directory" : (e.mode & 61440) == 40960 ? "SymbolicLink" : "Unknown", Q = (e) => {
|
|
800
821
|
if (!X(e.mode) || !Number.isSafeInteger(e.size) || e.size < 0) throw Z("stat", "file metadata is outside the supported range");
|
|
801
822
|
let t = (e) => e !== void 0 && Number.isSafeInteger(e) && e >= 0 ? y.some(e) : y.none(), n = (e) => {
|
|
802
823
|
let t = e === void 0 ? void 0 : new Date(e);
|
|
803
824
|
return t && Number.isFinite(t.getTime()) ? y.some(t) : y.none();
|
|
804
|
-
}, r = e
|
|
825
|
+
}, r = (e) => t(e).pipe(y.map(BigInt));
|
|
805
826
|
return {
|
|
806
|
-
type: e
|
|
827
|
+
type: Ue(e),
|
|
807
828
|
mtime: n(e.mtimeMs ?? e.timestampMs),
|
|
808
829
|
atime: n(e.atimeMs ?? e.timestampMs),
|
|
809
830
|
birthtime: y.none(),
|
|
810
|
-
dev:
|
|
811
|
-
ino:
|
|
831
|
+
dev: 0n,
|
|
832
|
+
ino: r(e.ino),
|
|
812
833
|
mode: e.mode,
|
|
813
|
-
nlink:
|
|
834
|
+
nlink: r(e.nlink),
|
|
814
835
|
uid: y.none(),
|
|
815
836
|
gid: y.none(),
|
|
816
837
|
rdev: y.none(),
|
|
817
838
|
size: d.bytes(BigInt(e.size)),
|
|
818
839
|
blksize: t(e.blksize).pipe(y.map(d.bytes)),
|
|
819
|
-
blocks:
|
|
840
|
+
blocks: r(e.blocks)
|
|
820
841
|
};
|
|
821
|
-
},
|
|
842
|
+
}, We = (e, t) => {
|
|
822
843
|
let n = Number(e);
|
|
823
844
|
return Number.isSafeInteger(n) && n >= 0 ? n : Z(t, "offset is outside the supported range");
|
|
824
|
-
},
|
|
845
|
+
}, Ge = (e) => e.state.isClosed(), $ = (e, t, n) => h.scoped(h.gen(function* () {
|
|
825
846
|
yield* h.acquireRelease(w.take(e.cursorGate, 1), () => w.release(e.cursorGate, 1), { interruptible: !0 });
|
|
826
847
|
let r = e.state.terminal();
|
|
827
|
-
return r ? yield* h.fail(
|
|
848
|
+
return r ? yield* h.fail(N(r, t, e.path, e.state.fileName)) : e.closed || Ge(e) || e.state.currentGeneration() !== e.generation ? yield* h.fail(b.systemError({
|
|
828
849
|
_tag: "BadResource",
|
|
829
|
-
module:
|
|
850
|
+
module: j,
|
|
830
851
|
method: t
|
|
831
852
|
})) : yield* n();
|
|
832
|
-
})),
|
|
853
|
+
})), Ke = (t) => {
|
|
833
854
|
let n = e(t);
|
|
834
855
|
if (!n) throw TypeError("Volume service was not created by this adapter");
|
|
835
856
|
return _.make({
|
|
836
|
-
access: (e, t) => t?.ok !== void 0 && typeof t.ok != "boolean" || t?.readable !== void 0 && typeof t.readable != "boolean" || t?.writable !== void 0 && typeof t.writable != "boolean" ? h.fail(Z("access", "ok, readable, and writable must be booleans")) :
|
|
837
|
-
let i = await
|
|
857
|
+
access: (e, t) => t?.ok !== void 0 && typeof t.ok != "boolean" || t?.readable !== void 0 && typeof t.readable != "boolean" || t?.writable !== void 0 && typeof t.writable != "boolean" ? h.fail(Z("access", "ok, readable, and writable must be booleans")) : I(n, "access", e, async (n, r) => {
|
|
858
|
+
let i = await be(n, r, e), a = !!(i.mode & 292), o = !!(i.mode & 146);
|
|
838
859
|
if (t?.readable && !a || t?.writable && !o) throw Object.assign(/* @__PURE__ */ Error("Permission denied"), { code: "EACCES" });
|
|
839
860
|
}),
|
|
840
|
-
chmod: (e, t) => X(t) ?
|
|
841
|
-
chown: (e) => h.fail(
|
|
842
|
-
glob: (e, t) => {
|
|
843
|
-
let r = t?.root === void 0 ? void 0 : F("glob", t.root);
|
|
844
|
-
return h.fail(r ?? he("glob", e, n.fileName));
|
|
845
|
-
},
|
|
861
|
+
chmod: (e, t) => X(t) ? I(n, "chmod", e, (n, r) => "forGeneration" in n ? n.forGeneration(r).chmod(e, t) : n.chmodSync(e, t), !0) : h.fail(Z("chmod", "mode must be an unsigned 32-bit integer")),
|
|
862
|
+
chown: (e) => h.fail(P("chown", e) ?? ge("chown", e, n.fileName)),
|
|
846
863
|
link: (e, t) => {
|
|
847
|
-
let r =
|
|
848
|
-
return r || i ? h.fail(r ?? i) :
|
|
864
|
+
let r = P("link", e), i = P("link", t);
|
|
865
|
+
return r || i ? h.fail(r ?? i) : I(n, "link", e, (n, r) => "forGeneration" in n ? n.forGeneration(r).link(e, t) : n.linkSync(e, t), !0);
|
|
849
866
|
},
|
|
850
867
|
makeDirectory: (e, t) => {
|
|
851
868
|
if (t?.recursive !== void 0 && typeof t.recursive != "boolean") return h.fail(Z("makeDirectory", "recursive must be a boolean"));
|
|
852
869
|
if (t?.mode !== void 0 && !X(t.mode)) return h.fail(Z("makeDirectory", "mode must be an unsigned 32-bit integer"));
|
|
853
870
|
let r = t?.mode, i = t?.recursive ?? !1;
|
|
854
|
-
return
|
|
871
|
+
return I(n, "makeDirectory", e, (t, n) => "forGeneration" in t ? t.forGeneration(n).mkdir(e, {
|
|
855
872
|
mode: r,
|
|
856
873
|
recursive: i
|
|
857
874
|
}) : t.mkdirSync(e, {
|
|
@@ -859,33 +876,33 @@ var te = 16, ne = Symbol("retry subscription on captured generation"), O = /* @_
|
|
|
859
876
|
recursive: i
|
|
860
877
|
}), !0);
|
|
861
878
|
},
|
|
862
|
-
makeTempDirectory: (e) => h.scoped(h.flatMap(h.scope, (t) => h.map(
|
|
863
|
-
makeTempDirectoryScoped: (e) => h.flatMap(h.scope, (t) => h.map(
|
|
864
|
-
makeTempFile: (e) => h.scoped(h.flatMap(h.scope, (t) => h.map(
|
|
865
|
-
makeTempFileScoped: (e) => h.flatMap(h.scope, (t) => h.map(
|
|
866
|
-
readFile: (e) =>
|
|
867
|
-
let
|
|
879
|
+
makeTempDirectory: (e) => h.scoped(h.flatMap(h.scope, (t) => h.map(Re(n, "makeTempDirectory", e, t, !1), (e) => e.path))),
|
|
880
|
+
makeTempDirectoryScoped: (e) => h.flatMap(h.scope, (t) => h.map(Re(n, "makeTempDirectoryScoped", e, t, !0), (e) => e.path)),
|
|
881
|
+
makeTempFile: (e) => h.scoped(h.flatMap(h.scope, (t) => h.map(ze(n, "makeTempFile", e, t, !1), (e) => e.path))),
|
|
882
|
+
makeTempFileScoped: (e) => h.flatMap(h.scope, (t) => h.map(ze(n, "makeTempFileScoped", e, t, !0), (e) => e.path)),
|
|
883
|
+
readFile: (e) => I(n, "readFile", e, (t, r, i) => {
|
|
884
|
+
let a = () => Be(n, t, r, e, i);
|
|
868
885
|
return "forGeneration" in t ? h.tryPromise({
|
|
869
|
-
try: () => t.forGeneration(r).readFileBuffer(e,
|
|
886
|
+
try: () => t.forGeneration(r).readFileBuffer(e, fe),
|
|
870
887
|
catch: (e) => e
|
|
871
|
-
}).pipe(h.catch((e) => u(e instanceof D ? e.cause : e).code === "EFBIG" ?
|
|
888
|
+
}).pipe(h.catch((e) => u(e instanceof D ? e.cause : e).code === "EFBIG" ? a() : h.fail(e))) : a();
|
|
872
889
|
}, !1, !1),
|
|
873
890
|
writeFile: (e, t, r) => {
|
|
874
|
-
let i =
|
|
891
|
+
let i = P("writeFile", e);
|
|
875
892
|
if (i) return h.fail(i);
|
|
876
893
|
if (!(t instanceof Uint8Array)) return h.fail(b.badArgument({
|
|
877
|
-
module:
|
|
894
|
+
module: j,
|
|
878
895
|
method: "writeFile",
|
|
879
896
|
description: "data must be a Uint8Array"
|
|
880
897
|
}));
|
|
881
898
|
let a = r?.flag ?? "w";
|
|
882
|
-
return Object.hasOwn(Y, a) ? r?.mode !== void 0 && !X(r.mode) ? h.fail(Z("writeFile", "mode must be an unsigned 32-bit integer")) : r?.mode !== void 0 || t.byteLength >
|
|
899
|
+
return Object.hasOwn(Y, a) ? r?.mode !== void 0 && !X(r.mode) ? h.fail(Z("writeFile", "mode must be an unsigned 32-bit integer")) : r?.mode !== void 0 || t.byteLength > fe || ![
|
|
883
900
|
"w",
|
|
884
901
|
"wx",
|
|
885
902
|
"ax"
|
|
886
903
|
].includes(a) ? h.scoped(h.gen(function* () {
|
|
887
|
-
yield* (yield*
|
|
888
|
-
})) :
|
|
904
|
+
yield* (yield* B(n, e, a, r?.mode, (Y[a] & (E.O_CREAT | E.O_TRUNC)) !== 0)).writeAll(t);
|
|
905
|
+
})) : I(n, "writeFile", e, (n, r) => {
|
|
889
906
|
let i = {
|
|
890
907
|
exclusive: a === "wx" || a === "ax",
|
|
891
908
|
append: a === "ax"
|
|
@@ -895,27 +912,27 @@ var te = 16, ne = Symbol("retry subscription on captured generation"), O = /* @_
|
|
|
895
912
|
}, !0) : h.fail(Z("writeFile", "unsupported file flag"));
|
|
896
913
|
},
|
|
897
914
|
copy: (e, t, r) => {
|
|
898
|
-
let i =
|
|
915
|
+
let i = P("copy", e), a = P("copy", t);
|
|
899
916
|
return i || a ? h.fail(i ?? a) : r?.overwrite !== void 0 && typeof r.overwrite != "boolean" ? h.fail(Z("copy", "overwrite must be a boolean")) : r?.preserveTimestamps !== void 0 && typeof r.preserveTimestamps != "boolean" ? h.fail(Z("copy", "preserveTimestamps must be a boolean")) : h.suspend(() => {
|
|
900
917
|
let i = { remaining: n.readinessTimeout };
|
|
901
|
-
return
|
|
918
|
+
return I(n, "copy", e, (a, o) => Me(n, o, e, t, r?.overwrite ?? !1, r?.preserveTimestamps ?? !1, i), !1, !1, void 0, i);
|
|
902
919
|
});
|
|
903
920
|
},
|
|
904
921
|
copyFile: (e, t) => {
|
|
905
|
-
let r =
|
|
922
|
+
let r = P("copyFile", e), i = P("copyFile", t);
|
|
906
923
|
return r || i ? h.fail(r ?? i) : h.suspend(() => {
|
|
907
924
|
let r = { remaining: n.readinessTimeout };
|
|
908
|
-
return
|
|
925
|
+
return I(n, "copyFile", e, (i, a) => je(n, a, e, t, r), !1, !1, void 0, r);
|
|
909
926
|
});
|
|
910
927
|
},
|
|
911
|
-
open: (e, t) =>
|
|
928
|
+
open: (e, t) => t?.noFollow ? h.fail(Z("open", "noFollow is not supported")) : B(n, e, t?.flag ?? "r", t?.mode),
|
|
912
929
|
readDirectory: (e, t) => {
|
|
913
930
|
if (t?.recursive !== void 0 && typeof t.recursive != "boolean") return h.fail(Z("readDirectory", "recursive must be a boolean"));
|
|
914
931
|
let r = t?.recursive ?? !1;
|
|
915
932
|
return h.suspend(() => {
|
|
916
933
|
let t = { remaining: n.readinessTimeout };
|
|
917
|
-
return
|
|
918
|
-
let o = (e) =>
|
|
934
|
+
return I(n, "readDirectory", e, (i, a) => {
|
|
935
|
+
let o = (e) => I(n, "readDirectory", e, (t, n) => "forGeneration" in t ? t.forGeneration(n).readdirEntries(e) : t.readdirEntriesSync(e), !1, !1, a, t), s = [], c = (e, t) => h.gen(function* () {
|
|
919
936
|
let n = [...yield* o(e)].sort((e, t) => e.name < t.name ? -1 : +(e.name > t.name));
|
|
920
937
|
for (let i of n) {
|
|
921
938
|
let n = t ? `${t}/${i.name}` : i.name;
|
|
@@ -928,45 +945,53 @@ var te = 16, ne = Symbol("retry subscription on captured generation"), O = /* @_
|
|
|
928
945
|
}, !1, !1, void 0, t);
|
|
929
946
|
});
|
|
930
947
|
},
|
|
931
|
-
|
|
932
|
-
|
|
948
|
+
lstat: (e) => I(n, "lstat", e, (t, n) => "forGeneration" in t ? t.forGeneration(n).lstat(e).then(Q) : Q(t.lstatSync(e))),
|
|
949
|
+
readDirectoryEntries: (e) => I(n, "readDirectoryEntries", e, (t, n) => "forGeneration" in t ? t.forGeneration(n).readdirEntries(e) : t.readdirEntriesSync(e)).pipe(h.map((e) => e.map((e) => ({
|
|
950
|
+
name: e.name,
|
|
951
|
+
type: Ue(e)
|
|
952
|
+
})))),
|
|
953
|
+
readLink: (e) => I(n, "readLink", e, (t, n) => "forGeneration" in t ? t.forGeneration(n).readlink(e) : t.readlinkSync(e)),
|
|
954
|
+
realPath: (e) => I(n, "realPath", e, (t, n) => "forGeneration" in t ? t.forGeneration(n).realpath(e) : t.realpathSync(e)),
|
|
933
955
|
remove: (e, t) => {
|
|
934
956
|
if (t?.recursive !== void 0 && typeof t.recursive != "boolean") return h.fail(Z("remove", "recursive must be a boolean"));
|
|
935
957
|
if (t?.force !== void 0 && typeof t.force != "boolean") return h.fail(Z("remove", "force must be a boolean"));
|
|
936
958
|
let r = t?.recursive ?? !1, i = t?.force ?? !1;
|
|
937
|
-
return r ?
|
|
959
|
+
return r ? I(n, "remove", e, (t, n) => "forGeneration" in t ? t.forGeneration(n).remove(e) : t.removeSync(e), !0).pipe(h.catchTag("PlatformError", (e) => i && e.reason._tag === "NotFound" ? h.void : h.fail(e))) : I(n, "remove", e, (t, r) => {
|
|
938
960
|
let a = () => "forGeneration" in t ? t.forGeneration(r).lstat(e) : t.lstatSync(e);
|
|
939
961
|
return h.gen(function* () {
|
|
940
962
|
let o = yield* h.tryPromise({
|
|
941
963
|
try: () => Promise.resolve(a()),
|
|
942
964
|
catch: (e) => e
|
|
943
|
-
}).pipe(h.catch((e) => i &&
|
|
944
|
-
|
|
965
|
+
}).pipe(h.catch((e) => i && He(e) ? h.succeed(void 0) : h.fail(e)));
|
|
966
|
+
if (o) {
|
|
967
|
+
if (o.is_dir) return yield* h.fail(ye(n, e));
|
|
968
|
+
yield* I(n, "remove", e, () => "forGeneration" in t ? t.forGeneration(r).unlink(e) : t.unlinkSync(e), !0, !1, r).pipe(h.catchTag("PlatformError", (e) => i && e.reason._tag === "NotFound" ? h.void : h.fail(e)));
|
|
969
|
+
}
|
|
945
970
|
});
|
|
946
971
|
}, !1, !1);
|
|
947
972
|
},
|
|
948
973
|
rename: (e, t) => {
|
|
949
|
-
let r =
|
|
950
|
-
return r || i ? h.fail(r ?? i) :
|
|
974
|
+
let r = P("rename", e), i = P("rename", t);
|
|
975
|
+
return r || i ? h.fail(r ?? i) : I(n, "rename", e, (n, r) => "forGeneration" in n ? n.forGeneration(r).rename(e, t) : n.renameSync(e, t), !0);
|
|
951
976
|
},
|
|
952
|
-
stat: (e) =>
|
|
977
|
+
stat: (e) => I(n, "stat", e, (t, n) => "forGeneration" in t ? t.forGeneration(n).stat(e).then(Q) : Q(t.statSync(e))),
|
|
953
978
|
symlink: (e, t) => {
|
|
954
|
-
let r =
|
|
955
|
-
return r ? h.fail(r) : typeof e == "string" ?
|
|
979
|
+
let r = P("symlink", t);
|
|
980
|
+
return r ? h.fail(r) : typeof e == "string" ? I(n, "symlink", t, (n, r) => "forGeneration" in n ? n.forGeneration(r).symlink(e, t) : n.symlinkSync(e, t), !0) : h.fail(Z("symlink", "target must be a string"));
|
|
956
981
|
},
|
|
957
|
-
truncate: (e, t = 0) => !Number.isSafeInteger(t) || t < 0 ? h.fail(Z("truncate", "length must be a non-negative safe integer")) :
|
|
982
|
+
truncate: (e, t = 0) => !Number.isSafeInteger(t) || t < 0 ? h.fail(Z("truncate", "length must be a non-negative safe integer")) : I(n, "truncate", e, (n, r) => "forGeneration" in n ? n.forGeneration(r).truncate(e, t) : n.truncateSync(e, t), !0),
|
|
958
983
|
utimes: (e, t, r) => {
|
|
959
|
-
let i =
|
|
960
|
-
return typeof i == "number" ? typeof a == "number" ?
|
|
984
|
+
let i = Ve(t), a = Ve(r);
|
|
985
|
+
return typeof i == "number" ? typeof a == "number" ? I(n, "utimes", e, (t, n) => "forGeneration" in t ? t.forGeneration(n).utimes(e, i, a) : t.utimesSync(e, i, a), !0) : h.fail(a) : h.fail(i);
|
|
961
986
|
},
|
|
962
987
|
watch: (e, t) => T.suspend(() => {
|
|
963
|
-
let r =
|
|
988
|
+
let r = P("watch", e);
|
|
964
989
|
if (r) return T.fail(r);
|
|
965
990
|
let i = h.gen(function* () {
|
|
966
|
-
let r = { remaining: n.readinessTimeout }, i = yield* n.awaitReady(r, "watch").pipe(h.mapError((t) =>
|
|
991
|
+
let r = { remaining: n.readinessTimeout }, i = yield* n.awaitReady(r, "watch").pipe(h.mapError((t) => F(n, e, t))), a = yield* q(n, i, e, r).pipe(h.mapError((t) => F(n, e, t)));
|
|
967
992
|
if (G(a)) return yield* h.fail(b.systemError({
|
|
968
993
|
_tag: "BadResource",
|
|
969
|
-
module:
|
|
994
|
+
module: j,
|
|
970
995
|
method: "watch",
|
|
971
996
|
pathOrDescriptor: e,
|
|
972
997
|
cause: new c({
|
|
@@ -981,7 +1006,7 @@ var te = 16, ne = Symbol("retry subscription on captured generation"), O = /* @_
|
|
|
981
1006
|
}));
|
|
982
1007
|
if (!a.is_dir && !a.is_file) return yield* h.fail(b.systemError({
|
|
983
1008
|
_tag: "BadResource",
|
|
984
|
-
module:
|
|
1009
|
+
module: j,
|
|
985
1010
|
method: "watch",
|
|
986
1011
|
pathOrDescriptor: e,
|
|
987
1012
|
cause: new c({
|
|
@@ -994,16 +1019,16 @@ var te = 16, ne = Symbol("retry subscription on captured generation"), O = /* @_
|
|
|
994
1019
|
details: u(Object.assign(/* @__PURE__ */ Error("Target is not a regular file or directory"), { code: "EINVAL" }))
|
|
995
1020
|
})
|
|
996
1021
|
}));
|
|
997
|
-
let o = {
|
|
1022
|
+
let o = a.is_dir ? yield* J(n, i, e, r) : H(yield* J(n, i, U(e), r), W(e)), s = {
|
|
998
1023
|
generation: i,
|
|
999
1024
|
budget: r
|
|
1000
|
-
}
|
|
1001
|
-
|
|
1002
|
-
path: e,
|
|
1025
|
+
}, l = yield* ce(n, {
|
|
1026
|
+
path: o,
|
|
1003
1027
|
scope: a.is_dir ? "directory" : "file",
|
|
1004
1028
|
recursive: a.is_dir && (t?.recursive ?? !1),
|
|
1005
1029
|
content: !1
|
|
1006
|
-
},
|
|
1030
|
+
}, s).pipe(h.catchCause((t) => h.failCause(f.map(t, (t) => F(n, e, t)))));
|
|
1031
|
+
return t?.onReady?.(), l.changes.pipe(T.catchCause((t) => T.failCause(f.map(t, (t) => F(n, e, t)))), T.map((e) => {
|
|
1007
1032
|
switch (e.type) {
|
|
1008
1033
|
case "create": return {
|
|
1009
1034
|
_tag: "Create",
|
|
@@ -1020,12 +1045,11 @@ var te = 16, ne = Symbol("retry subscription on captured generation"), O = /* @_
|
|
|
1020
1045
|
}
|
|
1021
1046
|
}));
|
|
1022
1047
|
});
|
|
1023
|
-
return T.scoped(T.unwrap(i.pipe(h.catchCause((t) => h.failCause(f.map(t, (t) =>
|
|
1048
|
+
return T.scoped(T.unwrap(i.pipe(h.catchCause((t) => h.failCause(f.map(t, (t) => F(n, e, t)))))));
|
|
1024
1049
|
})
|
|
1025
1050
|
});
|
|
1026
|
-
},
|
|
1027
|
-
make:
|
|
1028
|
-
layer: v.effect(_.FileSystem, h.map(r,
|
|
1051
|
+
}, qe = {
|
|
1052
|
+
make: Ke,
|
|
1053
|
+
layer: v.effect(_.FileSystem, h.map(r, Ke))
|
|
1029
1054
|
};
|
|
1030
|
-
|
|
1031
|
-
export { i as EncryptionError, a as MountError, Ue as OpfsFileSystem, o as RemoteErrorDetails, s as SubscriptionError, ce as Subscriptions, n as Volume, c as VolumeError };
|
|
1055
|
+
export { i as EncryptionError, a as MountError, qe as OpfsFileSystem, o as RemoteErrorDetails, s as SubscriptionError, le as Subscriptions, n as Volume, c as VolumeError };
|