@effect-vfs/core 0.7.1 → 0.8.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 +15 -238
- package/dist/LiveVolume.d.ts.map +1 -1
- package/dist/LiveVolume.js +9 -9
- package/dist/Search.d.ts +730 -0
- package/dist/Search.d.ts.map +1 -0
- package/dist/Search.js +568 -0
- package/dist/SnapshotDelta.d.ts +234 -0
- package/dist/SnapshotDelta.d.ts.map +1 -1
- package/dist/SnapshotDelta.js +107 -0
- package/dist/VirtualFileSystem.d.ts +53 -1
- package/dist/VirtualFileSystem.d.ts.map +1 -1
- package/dist/VirtualFileSystem.js +59 -1
- package/dist/index.d.ts +7 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +7 -0
- package/dist/internal/fixture.js +3 -3
- package/dist/internal/glob.d.ts +66 -0
- package/dist/internal/glob.d.ts.map +1 -0
- package/dist/internal/glob.js +248 -0
- package/dist/internal/image.d.ts +7 -1
- package/dist/internal/image.d.ts.map +1 -1
- package/dist/internal/image.js +9 -7
- package/dist/internal/liveImage.d.ts +1 -1
- package/dist/internal/liveImage.d.ts.map +1 -1
- package/dist/internal/liveImage.js +2 -10
- package/dist/internal/resolution.d.ts +135 -0
- package/dist/internal/resolution.d.ts.map +1 -0
- package/dist/internal/resolution.js +277 -0
- package/dist/internal/search.d.ts +24 -0
- package/dist/internal/search.d.ts.map +1 -0
- package/dist/internal/search.js +78 -0
- package/dist/internal/searchContent.d.ts +77 -0
- package/dist/internal/searchContent.d.ts.map +1 -0
- package/dist/internal/searchContent.js +223 -0
- package/dist/internal/searchModel.d.ts +83 -0
- package/dist/internal/searchModel.d.ts.map +1 -0
- package/dist/internal/searchModel.js +23 -0
- package/dist/internal/snapshotDelta.d.ts +470 -1
- package/dist/internal/snapshotDelta.d.ts.map +1 -1
- package/dist/internal/snapshotDelta.js +59 -25
- package/dist/internal/snapshotMerge.d.ts +54 -0
- package/dist/internal/snapshotMerge.d.ts.map +1 -0
- package/dist/internal/snapshotMerge.js +959 -0
- package/dist/internal/tokenRegistry.d.ts +77 -0
- package/dist/internal/tokenRegistry.d.ts.map +1 -0
- package/dist/internal/tokenRegistry.js +128 -0
- package/dist/internal/virtualFileSystem.d.ts +32 -17
- package/dist/internal/virtualFileSystem.d.ts.map +1 -1
- package/dist/internal/virtualFileSystem.js +263 -661
- package/dist/internal/volumeLimits.d.ts +53 -0
- package/dist/internal/volumeLimits.d.ts.map +1 -0
- package/dist/internal/volumeLimits.js +63 -0
- package/dist/internal/volumeState.d.ts +2 -0
- package/dist/internal/volumeState.d.ts.map +1 -1
- package/dist/internal/volumeState.js +9 -0
- package/package.json +5 -1
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
import * as Effect from "effect/Effect";
|
|
2
|
+
import * as Scope from "effect/Scope";
|
|
3
|
+
import type { FsFailure } from "../VfsError.js";
|
|
4
|
+
import type { DirectoryHandle, FileHandle, ObjectReference } from "../VirtualFileSystem.js";
|
|
5
|
+
import type { OpContext } from "./errors.js";
|
|
6
|
+
import type { Ino, Node } from "./volumeState.js";
|
|
7
|
+
/** @internal */
|
|
8
|
+
export type HandleLifecycle = {
|
|
9
|
+
readonly kind: "acquiring";
|
|
10
|
+
} | {
|
|
11
|
+
readonly kind: "open";
|
|
12
|
+
readonly ino: Ino;
|
|
13
|
+
} | {
|
|
14
|
+
readonly kind: "releasedPendingCommit";
|
|
15
|
+
readonly ino: Ino | undefined;
|
|
16
|
+
} | {
|
|
17
|
+
readonly kind: "closed";
|
|
18
|
+
};
|
|
19
|
+
/** @internal */
|
|
20
|
+
export interface HandleReference {
|
|
21
|
+
readonly volume: symbol;
|
|
22
|
+
lifecycle: HandleLifecycle;
|
|
23
|
+
scope: Scope.Closeable | undefined;
|
|
24
|
+
}
|
|
25
|
+
/** @internal */
|
|
26
|
+
export interface FileReference extends HandleReference {
|
|
27
|
+
offset: bigint;
|
|
28
|
+
readonly access: "read" | "write" | "readWrite";
|
|
29
|
+
readonly append: boolean;
|
|
30
|
+
}
|
|
31
|
+
/** @internal */
|
|
32
|
+
export type DirectoryReference = HandleReference;
|
|
33
|
+
/** @internal */
|
|
34
|
+
export type Token = ObjectReference | FileHandle | DirectoryHandle;
|
|
35
|
+
/** @internal */
|
|
36
|
+
export type Resolution = {
|
|
37
|
+
readonly kind: "unknown";
|
|
38
|
+
} | {
|
|
39
|
+
readonly kind: "foreign";
|
|
40
|
+
} | {
|
|
41
|
+
readonly kind: "stale";
|
|
42
|
+
} | {
|
|
43
|
+
readonly kind: "live";
|
|
44
|
+
readonly node: Node;
|
|
45
|
+
};
|
|
46
|
+
/** @internal */
|
|
47
|
+
export declare const inode: (reference: HandleReference) => Ino | undefined;
|
|
48
|
+
/** @internal */
|
|
49
|
+
export declare const isOpen: (reference: HandleReference) => boolean;
|
|
50
|
+
/** @internal */
|
|
51
|
+
export declare const publish: (reference: HandleReference, ino: Ino) => void;
|
|
52
|
+
/** @internal */
|
|
53
|
+
export declare const released: (reference: HandleReference) => void;
|
|
54
|
+
/** @internal */
|
|
55
|
+
export declare const release: <E, R>(reference: HandleReference, releaseInode: (ino: Ino) => Effect.Effect<void, E, R>, afterRelease: (action: () => void) => Effect.Effect<void, never, R>) => Effect.Effect<void, E, R>;
|
|
56
|
+
/** @internal */
|
|
57
|
+
export declare const closeReleasedScope: (reference: HandleReference) => Effect.Effect<void, never, never>;
|
|
58
|
+
/** @internal */
|
|
59
|
+
export declare const finalize: (reference: HandleReference, close: Effect.Effect<unknown, FsFailure>, fallback: Effect.Effect<void>) => Effect.Effect<void, never, never>;
|
|
60
|
+
/** @internal */
|
|
61
|
+
export declare const acquire: <A, E, R, ReleaseR, CoordinateR>(reference: HandleReference, coordinate: (acquire: Effect.Effect<A, E, R | ReleaseR>) => Effect.Effect<A, E | FsFailure, CoordinateR>, acquisition: Effect.Effect<A, E, R>, releaseAcquired: () => Effect.Effect<void, never, ReleaseR>, finalizer: Effect.Effect<void, never, never>) => Effect.Effect<A, E | FsFailure, CoordinateR | Scope.Scope>;
|
|
62
|
+
/** @internal */
|
|
63
|
+
export declare const nodeOrFail: (result: Resolution, addressing: "reference" | "handle", op: OpContext) => Effect.Effect<never, FsFailure, never> | Effect.Effect<Node, never, never>;
|
|
64
|
+
/** @internal */
|
|
65
|
+
export declare const make: (volume: symbol, get: (ino: Ino) => Effect.Effect<Node | undefined>) => {
|
|
66
|
+
resolve: (token: Token, addressing: "reference" | "handle" | "directory") => Effect.Effect<Resolution, never, never>;
|
|
67
|
+
resolveInode: (ino: Ino) => Effect.Effect<Resolution>;
|
|
68
|
+
referenceFor: (ino: Ino) => ObjectReference;
|
|
69
|
+
forget: (ino: Ino) => boolean;
|
|
70
|
+
file: (access: FileReference["access"], append: boolean) => FileReference;
|
|
71
|
+
directory: (ino?: Ino) => DirectoryReference;
|
|
72
|
+
registerFile: (handle: FileHandle, reference: FileReference) => WeakMap<object, FileReference>;
|
|
73
|
+
registerDirectory: (handle: DirectoryHandle, reference: DirectoryReference) => WeakMap<object, HandleReference>;
|
|
74
|
+
};
|
|
75
|
+
/** @internal */
|
|
76
|
+
export type TokenRegistry = ReturnType<typeof make>;
|
|
77
|
+
//# sourceMappingURL=tokenRegistry.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tokenRegistry.d.ts","sourceRoot":"","sources":["../../src/internal/tokenRegistry.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,MAAM,eAAe,CAAA;AAGvC,OAAO,KAAK,KAAK,MAAM,cAAc,CAAA;AAErC,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAA;AAC/C,OAAO,KAAK,EAAE,eAAe,EAAE,UAAU,EAAE,eAAe,EAAE,MAAM,yBAAyB,CAAA;AAC3F,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,aAAa,CAAA;AAC5C,OAAO,KAAK,EAAE,GAAG,EAAE,IAAI,EAAE,MAAM,kBAAkB,CAAA;AAEjD,gBAAg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AAO,CAAC,GAAG,EAAE,GAAG,KAAK,MAAM,CAAC,MAAM,CAAC,IAAI,GAAG,SAAS,CAAC;qBA0ClE,KAAK,cAAc,WAAW,GAAG,QAAQ,GAAG,WAAW;wBAvC/C,GAAG,KAAG,MAAM,CAAC,MAAM,CAAC,UAAU,CAAC;wBA0CpC,GAAG,KAAG,eAAe;kBAU3B,GAAG;mBACF,aAAa,CAAC,QAAQ,CAAC,UAAU,OAAO,KAAG,aAAa;sBAQrD,GAAG,KAAG,kBAAkB;2BAKnB,UAAU,aAAa,aAAa;gCAC/B,eAAe,aAAa,kBAAkB;CAE7E,CAAA;AAED,gBAAgB;AAChB,MAAM,MAAM,aAAa,GAAG,UAAU,CAAC,OAAO,IAAI,CAAC,CAAA"}
|
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
import * as Effect from "effect/Effect";
|
|
2
|
+
import * as Exit from "effect/Exit";
|
|
3
|
+
import * as Predicate from "effect/Predicate";
|
|
4
|
+
import * as Scope from "effect/Scope";
|
|
5
|
+
import { ObjectReferenceId } from "../Caller.js";
|
|
6
|
+
// Shared across volumes so a genuine token from another registry is distinguishable from a forgery.
|
|
7
|
+
const references = new WeakMap();
|
|
8
|
+
const files = new WeakMap();
|
|
9
|
+
const directories = new WeakMap();
|
|
10
|
+
/** @internal */
|
|
11
|
+
export const inode = (reference) => reference.lifecycle.kind === "open" || reference.lifecycle.kind === "releasedPendingCommit"
|
|
12
|
+
? reference.lifecycle.ino
|
|
13
|
+
: undefined;
|
|
14
|
+
/** @internal */
|
|
15
|
+
export const isOpen = (reference) => reference.lifecycle.kind === "open";
|
|
16
|
+
/** @internal */
|
|
17
|
+
export const publish = (reference, ino) => {
|
|
18
|
+
reference.lifecycle = reference.lifecycle.kind === "releasedPendingCommit" || reference.lifecycle.kind === "closed"
|
|
19
|
+
? { kind: "releasedPendingCommit", ino }
|
|
20
|
+
: { kind: "open", ino };
|
|
21
|
+
};
|
|
22
|
+
/** @internal */
|
|
23
|
+
export const released = (reference) => {
|
|
24
|
+
reference.lifecycle = reference.lifecycle.kind === "acquiring" ||
|
|
25
|
+
(reference.lifecycle.kind === "releasedPendingCommit" && reference.lifecycle.ino === undefined)
|
|
26
|
+
? { kind: "releasedPendingCommit", ino: undefined }
|
|
27
|
+
: { kind: "closed" };
|
|
28
|
+
};
|
|
29
|
+
// A release callback changes the engine's draft; publication may be immediate cleanup or after installation.
|
|
30
|
+
/** @internal */
|
|
31
|
+
export const release = Effect.fnUntraced(function* (reference, releaseInode, afterRelease) {
|
|
32
|
+
const ino = inode(reference);
|
|
33
|
+
yield* afterRelease(() => released(reference));
|
|
34
|
+
if (ino !== undefined)
|
|
35
|
+
yield* releaseInode(ino);
|
|
36
|
+
});
|
|
37
|
+
/** @internal */
|
|
38
|
+
export const closeReleasedScope = (reference) => Effect.suspend(() => isOpen(reference) || reference.scope === undefined ? Effect.void : Scope.close(reference.scope, Exit.void));
|
|
39
|
+
// The inode, rather than the open tag, decides whether a rerun must release a late publication.
|
|
40
|
+
/** @internal */
|
|
41
|
+
export const finalize = (reference, close, fallback) => Effect.uninterruptible(Effect.suspend(() => inode(reference) === undefined
|
|
42
|
+
? Effect.sync(() => released(reference))
|
|
43
|
+
: Effect.ignore(close).pipe(Effect.andThen(Effect.suspend(() => inode(reference) === undefined ? Effect.void : fallback)))));
|
|
44
|
+
// Register before waiting: a closed scope runs its finalizer immediately, and engine permits are not reentrant.
|
|
45
|
+
/** @internal */
|
|
46
|
+
export const acquire = Effect.fnUntraced(function* (reference, coordinate, acquisition, releaseAcquired, finalizer) {
|
|
47
|
+
const scope = yield* Scope.fork(yield* Effect.scope);
|
|
48
|
+
reference.scope = scope;
|
|
49
|
+
yield* Scope.addFinalizer(scope, finalizer);
|
|
50
|
+
const closed = () => Predicate.isTagged(scope.state, "Closed");
|
|
51
|
+
return yield* coordinate(Effect.suspend(() => closed() ? Effect.interrupt : acquisition).pipe(Effect.tap(() => Effect.suspend(() => closed() ? Effect.andThen(releaseAcquired(), Effect.interrupt) : Effect.void)))).pipe(Effect.tap(() => Effect.suspend(() => closed() ? Effect.interrupt : Effect.void)), Effect.onError(() => Effect.andThen(finalizer, Scope.close(scope, Exit.void))), Effect.onError(() => Effect.sync(() => {
|
|
52
|
+
if (reference.lifecycle.kind === "releasedPendingCommit" && reference.lifecycle.ino === undefined) {
|
|
53
|
+
reference.lifecycle = { kind: "closed" };
|
|
54
|
+
}
|
|
55
|
+
})));
|
|
56
|
+
});
|
|
57
|
+
/** @internal */
|
|
58
|
+
export const nodeOrFail = (result, addressing, op) => {
|
|
59
|
+
switch (result.kind) {
|
|
60
|
+
case "live":
|
|
61
|
+
return Effect.succeed(result.node);
|
|
62
|
+
case "unknown":
|
|
63
|
+
return Effect.fail(op.fail(addressing === "reference" ? "InvalidReference" : "InvalidHandle"));
|
|
64
|
+
case "foreign":
|
|
65
|
+
return Effect.fail(op.fail(addressing === "reference" ? "ForeignReference" : "ForeignHandle"));
|
|
66
|
+
case "stale":
|
|
67
|
+
return Effect.fail(op.fail(addressing === "reference" ? "StaleReference" : "InvalidHandle"));
|
|
68
|
+
}
|
|
69
|
+
};
|
|
70
|
+
/** @internal */
|
|
71
|
+
export const make = (volume, get) => {
|
|
72
|
+
const tokens = new Map();
|
|
73
|
+
const resolveInode = (ino) => Effect.map(get(ino), (node) => node === undefined || (node.kind === "directory" && node.metadata.nlink === 0)
|
|
74
|
+
? { kind: "stale" }
|
|
75
|
+
: { kind: "live", node });
|
|
76
|
+
const resolveReference = (token) => Effect.suspend(() => {
|
|
77
|
+
const known = Predicate.isObject(token) ? references.get(token) : undefined;
|
|
78
|
+
if (known === undefined)
|
|
79
|
+
return Effect.succeed({ kind: "unknown" });
|
|
80
|
+
if (known.volume !== volume)
|
|
81
|
+
return Effect.succeed({ kind: "foreign" });
|
|
82
|
+
return resolveInode(known.ino);
|
|
83
|
+
});
|
|
84
|
+
const resolveHandle = (token, directoryOnly = false) => Effect.suspend(() => {
|
|
85
|
+
const known = Predicate.isObject(token)
|
|
86
|
+
? directories.get(token) ?? (directoryOnly ? undefined : files.get(token))
|
|
87
|
+
: undefined;
|
|
88
|
+
if (known === undefined)
|
|
89
|
+
return Effect.succeed({ kind: "unknown" });
|
|
90
|
+
if (known.volume !== volume)
|
|
91
|
+
return Effect.succeed({ kind: "foreign" });
|
|
92
|
+
if (!isOpen(known))
|
|
93
|
+
return Effect.succeed({ kind: "stale" });
|
|
94
|
+
const ino = inode(known);
|
|
95
|
+
return ino === undefined
|
|
96
|
+
? Effect.succeed({ kind: "stale" })
|
|
97
|
+
: Effect.map(get(ino), (node) => node === undefined ? { kind: "stale" } : { kind: "live", node });
|
|
98
|
+
});
|
|
99
|
+
return {
|
|
100
|
+
resolve: (token, addressing) => addressing === "reference" ? resolveReference(token) : resolveHandle(token, addressing === "directory"),
|
|
101
|
+
resolveInode,
|
|
102
|
+
referenceFor: (ino) => {
|
|
103
|
+
const existing = tokens.get(ino);
|
|
104
|
+
if (existing !== undefined)
|
|
105
|
+
return existing;
|
|
106
|
+
const reference = Object.freeze({ [ObjectReferenceId]: true });
|
|
107
|
+
references.set(reference, { volume, ino });
|
|
108
|
+
tokens.set(ino, reference);
|
|
109
|
+
return reference;
|
|
110
|
+
},
|
|
111
|
+
forget: (ino) => tokens.delete(ino),
|
|
112
|
+
file: (access, append) => ({
|
|
113
|
+
volume,
|
|
114
|
+
lifecycle: { kind: "acquiring" },
|
|
115
|
+
scope: undefined,
|
|
116
|
+
offset: 0n,
|
|
117
|
+
access,
|
|
118
|
+
append
|
|
119
|
+
}),
|
|
120
|
+
directory: (ino) => ({
|
|
121
|
+
volume,
|
|
122
|
+
lifecycle: ino === undefined ? { kind: "acquiring" } : { kind: "open", ino },
|
|
123
|
+
scope: undefined
|
|
124
|
+
}),
|
|
125
|
+
registerFile: (handle, reference) => files.set(handle, reference),
|
|
126
|
+
registerDirectory: (handle, reference) => directories.set(handle, reference)
|
|
127
|
+
};
|
|
128
|
+
};
|
|
@@ -2,18 +2,24 @@ import * as ByteSize from "effect/ByteSize";
|
|
|
2
2
|
import * as Crypto from "effect/Crypto";
|
|
3
3
|
import * as Data from "effect/Data";
|
|
4
4
|
import * as Effect from "effect/Effect";
|
|
5
|
+
import type { CommitOutcome } from "../LiveVolume.js";
|
|
5
6
|
import type { Snapshot } from "../Snapshot.js";
|
|
6
|
-
import { type FsFailure
|
|
7
|
-
import type { OverlayVolume, Volume
|
|
7
|
+
import { type FsFailure } from "../VfsError.js";
|
|
8
|
+
import type { OverlayVolume, Volume } from "../VirtualFileSystem.js";
|
|
9
|
+
import { VfsError } from "./errors.js";
|
|
8
10
|
import * as LiveImage from "./liveImage.js";
|
|
9
11
|
import { type ObservationEntry } from "./overlayDiff.js";
|
|
10
12
|
import { type VolumeState } from "./volumeState.js";
|
|
11
|
-
|
|
12
|
-
interface CommitProvider<State> {
|
|
13
|
-
|
|
14
|
-
readonly
|
|
15
|
-
|
|
13
|
+
/** @internal */
|
|
14
|
+
export interface CommitProvider<State> {
|
|
15
|
+
readonly mode: "memory" | "durable";
|
|
16
|
+
readonly commit: (candidate: State) => Effect.Effect<CommitOutcome, FsFailure & {
|
|
17
|
+
readonly code: "StorageRejected";
|
|
18
|
+
}>;
|
|
19
|
+
readonly shutdown: Effect.Effect<void>;
|
|
16
20
|
}
|
|
21
|
+
/** @internal */
|
|
22
|
+
export declare const memoryCommitProvider: CommitProvider<VolumeState>;
|
|
17
23
|
type VolumeSource = {
|
|
18
24
|
readonly _tag: "Empty";
|
|
19
25
|
} | {
|
|
@@ -61,7 +67,7 @@ export declare const VolumeSource: {
|
|
|
61
67
|
}, "_tag">;
|
|
62
68
|
};
|
|
63
69
|
/** @internal */
|
|
64
|
-
export declare const makeVolume: (source: VolumeSource, options?: {
|
|
70
|
+
export declare const makeVolume: (source: VolumeSource, commitProvider: CommitProvider<VolumeState>, options?: {
|
|
65
71
|
readonly identity?: string & import("effect/Brand").Brand<"@effect-vfs/core/VolumeIdentity">;
|
|
66
72
|
readonly maxEntries?: number;
|
|
67
73
|
readonly maxPendingOperations?: number;
|
|
@@ -69,10 +75,9 @@ export declare const makeVolume: (source: VolumeSource, options?: {
|
|
|
69
75
|
readonly maxBytes?: ByteSize.ByteSize;
|
|
70
76
|
readonly maxFileBytes?: ByteSize.ByteSize;
|
|
71
77
|
readonly maxPathBytes?: ByteSize.ByteSize;
|
|
72
|
-
} | undefined,
|
|
78
|
+
} | undefined, durability?: "memory-only" | "survives-operating-system-crash" | "survives-power-loss" | "survives-process-crash" | undefined) => Effect.Effect<Readonly<{
|
|
73
79
|
volume: Volume;
|
|
74
|
-
shutdown: Effect.Effect<void, never, never
|
|
75
|
-
initialImage: Uint8Array<ArrayBufferLike> | undefined;
|
|
80
|
+
shutdown: Effect.Effect<void, never, never>;
|
|
76
81
|
observe: Readonly<{
|
|
77
82
|
changes: Effect.Effect<ObservationEntry[], FsFailure, never>;
|
|
78
83
|
capture: Effect.Effect<{
|
|
@@ -80,7 +85,7 @@ export declare const makeVolume: (source: VolumeSource, options?: {
|
|
|
80
85
|
observation: ObservationEntry[];
|
|
81
86
|
}, FsFailure, never>;
|
|
82
87
|
}>;
|
|
83
|
-
}>, import("../VfsError.js").ArgumentFailure | ImageFailure, Crypto.Crypto>;
|
|
88
|
+
}>, import("../VfsError.js").ArgumentFailure | import("../VfsError.js").ImageFailure, Crypto.Crypto>;
|
|
84
89
|
/** @internal */
|
|
85
90
|
export declare const make: (options?: {
|
|
86
91
|
readonly identity?: string & import("effect/Brand").Brand<"@effect-vfs/core/VolumeIdentity">;
|
|
@@ -100,12 +105,22 @@ export declare const prepareEmptyLiveImage: (options?: {
|
|
|
100
105
|
readonly maxBytes?: ByteSize.ByteSize;
|
|
101
106
|
readonly maxFileBytes?: ByteSize.ByteSize;
|
|
102
107
|
readonly maxPathBytes?: ByteSize.ByteSize;
|
|
103
|
-
} | undefined) => Effect.Effect<Uint8Array<ArrayBufferLike>, import("../VfsError.js").ArgumentFailure |
|
|
108
|
+
} | undefined) => Effect.Effect<Uint8Array<ArrayBufferLike>, import("../VfsError.js").ArgumentFailure | (VfsError & {
|
|
109
|
+
readonly code: import("../VfsError.js").ImageCode;
|
|
110
|
+
}), Crypto.Crypto>;
|
|
104
111
|
/** @internal */
|
|
105
|
-
export declare const openImageVolume: (image: Uint8Array<ArrayBufferLike>, maxImageBytes: ByteSize.ByteSize, commit: (image: Uint8Array) => Effect.Effect<
|
|
112
|
+
export declare const openImageVolume: (image: Uint8Array<ArrayBufferLike>, maxImageBytes: ByteSize.ByteSize, commit: (image: Uint8Array) => Effect.Effect<CommitOutcome>, durability?: "memory-only" | "survives-operating-system-crash" | "survives-power-loss" | "survives-process-crash" | undefined, options?: {
|
|
113
|
+
readonly identity?: string & import("effect/Brand").Brand<"@effect-vfs/core/VolumeIdentity">;
|
|
114
|
+
readonly maxEntries?: number;
|
|
115
|
+
readonly maxPendingOperations?: number;
|
|
116
|
+
readonly maxWatchEvents?: number;
|
|
117
|
+
readonly maxBytes?: ByteSize.ByteSize;
|
|
118
|
+
readonly maxFileBytes?: ByteSize.ByteSize;
|
|
119
|
+
readonly maxPathBytes?: ByteSize.ByteSize;
|
|
120
|
+
} | undefined) => Effect.Effect<Readonly<{
|
|
106
121
|
volume: Volume;
|
|
107
122
|
shutdown: Effect.Effect<void, never, never>;
|
|
108
|
-
}>, import("../VfsError.js").ArgumentFailure | ImageFailure, Crypto.Crypto>;
|
|
123
|
+
}>, import("../VfsError.js").ArgumentFailure | import("../VfsError.js").ImageFailure, Crypto.Crypto>;
|
|
109
124
|
/** @internal */
|
|
110
125
|
export declare const fromSnapshot: (snapshot: Snapshot, options?: {
|
|
111
126
|
readonly identity?: string & import("effect/Brand").Brand<"@effect-vfs/core/VolumeIdentity">;
|
|
@@ -115,7 +130,7 @@ export declare const fromSnapshot: (snapshot: Snapshot, options?: {
|
|
|
115
130
|
readonly maxBytes?: ByteSize.ByteSize;
|
|
116
131
|
readonly maxFileBytes?: ByteSize.ByteSize;
|
|
117
132
|
readonly maxPathBytes?: ByteSize.ByteSize;
|
|
118
|
-
} | undefined) => Effect.Effect<Volume, import("../VfsError.js").ArgumentFailure | ImageFailure, Crypto.Crypto>;
|
|
133
|
+
} | undefined) => Effect.Effect<Volume, import("../VfsError.js").ArgumentFailure | import("../VfsError.js").ImageFailure, Crypto.Crypto>;
|
|
119
134
|
/** @internal */
|
|
120
135
|
export declare const makeOverlay: (base: Snapshot, options?: {
|
|
121
136
|
readonly identity?: string & import("effect/Brand").Brand<"@effect-vfs/core/VolumeIdentity">;
|
|
@@ -125,6 +140,6 @@ export declare const makeOverlay: (base: Snapshot, options?: {
|
|
|
125
140
|
readonly maxBytes?: ByteSize.ByteSize;
|
|
126
141
|
readonly maxFileBytes?: ByteSize.ByteSize;
|
|
127
142
|
readonly maxPathBytes?: ByteSize.ByteSize;
|
|
128
|
-
} | undefined) => Effect.Effect<OverlayVolume, import("../VfsError.js").ArgumentFailure | ImageFailure, Crypto.Crypto>;
|
|
143
|
+
} | undefined) => Effect.Effect<OverlayVolume, import("../VfsError.js").ArgumentFailure | import("../VfsError.js").ImageFailure, Crypto.Crypto>;
|
|
129
144
|
export {};
|
|
130
145
|
//# sourceMappingURL=virtualFileSystem.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"virtualFileSystem.d.ts","sourceRoot":"","sources":["../../src/internal/virtualFileSystem.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,QAAQ,MAAM,iBAAiB,CAAA;
|
|
1
|
+
{"version":3,"file":"virtualFileSystem.d.ts","sourceRoot":"","sources":["../../src/internal/virtualFileSystem.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,QAAQ,MAAM,iBAAiB,CAAA;AAI3C,OAAO,KAAK,MAAM,MAAM,eAAe,CAAA;AACvC,OAAO,KAAK,IAAI,MAAM,aAAa,CAAA;AACnC,OAAO,KAAK,MAAM,MAAM,eAAe,CAAA;AA2BvC,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAA;AAErD,OAAO,KAAK,EA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