@effect-vfs/core 0.4.0 → 0.6.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 +39 -32
- package/dist/BytePath.d.ts +114 -4
- package/dist/BytePath.d.ts.map +1 -1
- package/dist/BytePath.js +155 -0
- package/dist/Caller.d.ts +391 -0
- package/dist/Caller.d.ts.map +1 -0
- package/dist/Caller.js +199 -0
- package/dist/FileHandle.d.ts +50 -0
- package/dist/FileHandle.d.ts.map +1 -0
- package/dist/FileHandle.js +28 -0
- package/dist/Fixture.d.ts +155 -0
- package/dist/Fixture.d.ts.map +1 -0
- package/dist/Fixture.js +65 -0
- package/dist/LiveVolume.d.ts +15 -22
- package/dist/LiveVolume.d.ts.map +1 -1
- package/dist/LiveVolume.js +19 -15
- package/dist/Metadata.d.ts +186 -0
- package/dist/Metadata.d.ts.map +1 -0
- package/dist/Metadata.js +125 -0
- package/dist/Snapshot.d.ts +31 -53
- package/dist/Snapshot.d.ts.map +1 -1
- package/dist/Snapshot.js +26 -49
- package/dist/SnapshotDelta.d.ts +24 -39
- package/dist/SnapshotDelta.d.ts.map +1 -1
- package/dist/SnapshotDelta.js +14 -35
- package/dist/Target.d.ts +225 -0
- package/dist/Target.d.ts.map +1 -0
- package/dist/Target.js +92 -0
- package/dist/Testing.d.ts +128 -0
- package/dist/Testing.d.ts.map +1 -0
- package/dist/Testing.js +111 -0
- package/dist/VfsError.d.ts +199 -0
- package/dist/VfsError.d.ts.map +1 -0
- package/dist/VfsError.js +164 -0
- package/dist/VirtualFileSystem.d.ts +628 -347
- package/dist/VirtualFileSystem.d.ts.map +1 -1
- package/dist/VirtualFileSystem.js +450 -117
- package/dist/Volume.d.ts +211 -0
- package/dist/Volume.d.ts.map +1 -0
- package/dist/Volume.js +172 -0
- package/dist/Watch.d.ts +68 -0
- package/dist/Watch.d.ts.map +1 -0
- package/dist/Watch.js +46 -0
- package/dist/index.d.ts +56 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +56 -1
- package/dist/internal/budget.d.ts +90 -0
- package/dist/internal/budget.d.ts.map +1 -0
- package/dist/internal/budget.js +70 -0
- package/dist/internal/bytePath.d.ts +2 -0
- package/dist/internal/bytePath.d.ts.map +1 -1
- package/dist/internal/bytePath.js +3 -2
- package/dist/internal/bytes.d.ts +3 -0
- package/dist/internal/bytes.d.ts.map +1 -1
- package/dist/internal/bytes.js +4 -2
- package/dist/internal/canonicalBase64.d.ts +1 -4
- package/dist/internal/canonicalBase64.d.ts.map +1 -1
- package/dist/internal/canonicalBase64.js +9 -13
- package/dist/internal/errors.d.ts +54 -0
- package/dist/internal/errors.d.ts.map +1 -0
- package/dist/internal/errors.js +91 -0
- package/dist/internal/{virtualFileSystem/fixture.d.ts → fixture.d.ts} +8 -8
- package/dist/internal/fixture.d.ts.map +1 -0
- package/dist/internal/fixture.js +133 -0
- package/dist/internal/hex128.d.ts +12 -0
- package/dist/internal/hex128.d.ts.map +1 -0
- package/dist/internal/hex128.js +7 -0
- package/dist/internal/hmac.d.ts +5 -0
- package/dist/internal/hmac.d.ts.map +1 -0
- package/dist/internal/hmac.js +150 -0
- package/dist/internal/image.d.ts +14 -117
- package/dist/internal/image.d.ts.map +1 -1
- package/dist/internal/image.js +137 -167
- package/dist/internal/inodeTable.d.ts +20 -0
- package/dist/internal/inodeTable.d.ts.map +1 -0
- package/dist/internal/inodeTable.js +48 -0
- package/dist/internal/lines.d.ts +36 -0
- package/dist/internal/lines.d.ts.map +1 -0
- package/dist/internal/lines.js +115 -0
- package/dist/internal/liveImage.d.ts +19 -278
- package/dist/internal/liveImage.d.ts.map +1 -1
- package/dist/internal/liveImage.js +75 -166
- package/dist/internal/merkle.d.ts +45 -0
- package/dist/internal/merkle.d.ts.map +1 -0
- package/dist/internal/merkle.js +179 -0
- package/dist/internal/metadata.d.ts +2 -13
- package/dist/internal/metadata.d.ts.map +1 -1
- package/dist/internal/metadata.js +5 -15
- package/dist/internal/{virtualFileSystem/overlayDiff.d.ts → overlayDiff.d.ts} +3 -3
- package/dist/internal/overlayDiff.d.ts.map +1 -0
- package/dist/internal/{virtualFileSystem/overlayDiff.js → overlayDiff.js} +1 -4
- package/dist/internal/{virtualFileSystem/path.d.ts → path.d.ts} +19 -7
- package/dist/internal/path.d.ts.map +1 -0
- package/dist/internal/{virtualFileSystem/path.js → path.js} +39 -25
- package/dist/internal/snapshotDelta.d.ts +61 -60
- package/dist/internal/snapshotDelta.d.ts.map +1 -1
- package/dist/internal/snapshotDelta.js +612 -504
- package/dist/internal/snapshotDeltaModel.d.ts.map +1 -1
- package/dist/internal/snapshotDeltaModel.js +0 -1
- package/dist/internal/stagedState.d.ts +18 -0
- package/dist/internal/stagedState.d.ts.map +1 -0
- package/dist/internal/stagedState.js +18 -0
- package/dist/internal/testSeams.d.ts +17 -0
- package/dist/internal/testSeams.d.ts.map +1 -0
- package/dist/internal/testSeams.js +20 -0
- package/dist/internal/tree.d.ts +225 -0
- package/dist/internal/tree.d.ts.map +1 -0
- package/dist/internal/tree.js +385 -0
- package/dist/internal/turnstile.d.ts +8 -0
- package/dist/internal/turnstile.d.ts.map +1 -0
- package/dist/internal/turnstile.js +43 -0
- package/dist/internal/virtualFileSystem.d.ts +41 -491
- package/dist/internal/virtualFileSystem.d.ts.map +1 -1
- package/dist/internal/virtualFileSystem.js +2118 -2471
- package/dist/internal/volumeState.d.ts +110 -0
- package/dist/internal/volumeState.d.ts.map +1 -0
- package/dist/internal/volumeState.js +204 -0
- package/dist/internal/watchHub.d.ts +25 -0
- package/dist/internal/watchHub.d.ts.map +1 -0
- package/dist/internal/watchHub.js +68 -0
- package/package.json +53 -9
- package/dist/VirtualFileSystemError.d.ts +0 -54
- package/dist/VirtualFileSystemError.d.ts.map +0 -1
- package/dist/VirtualFileSystemError.js +0 -49
- package/dist/internal/virtualFileSystem/errors.d.ts +0 -12
- package/dist/internal/virtualFileSystem/errors.d.ts.map +0 -1
- package/dist/internal/virtualFileSystem/errors.js +0 -47
- package/dist/internal/virtualFileSystem/fixture.d.ts.map +0 -1
- package/dist/internal/virtualFileSystem/fixture.js +0 -150
- package/dist/internal/virtualFileSystem/overlayContent.d.ts +0 -15
- package/dist/internal/virtualFileSystem/overlayContent.d.ts.map +0 -1
- package/dist/internal/virtualFileSystem/overlayContent.js +0 -29
- package/dist/internal/virtualFileSystem/overlayDiff.d.ts.map +0 -1
- package/dist/internal/virtualFileSystem/path.d.ts.map +0 -1
- package/dist/internal/virtualFileSystem/stagedState.d.ts +0 -22
- package/dist/internal/virtualFileSystem/stagedState.d.ts.map +0 -1
- package/dist/internal/virtualFileSystem/stagedState.js +0 -62
- package/dist/internal/virtualFileSystem/testHooks.d.ts +0 -20
- package/dist/internal/virtualFileSystem/testHooks.d.ts.map +0 -1
- package/dist/internal/virtualFileSystem/testHooks.js +0 -23
- package/dist/internal/virtualFileSystem/watchHub.d.ts +0 -16
- package/dist/internal/virtualFileSystem/watchHub.d.ts.map +0 -1
- package/dist/internal/virtualFileSystem/watchHub.js +0 -54
|
@@ -1,47 +0,0 @@
|
|
|
1
|
-
// Virtual filesystem failure schemas and identities shared by the runtime implementation.
|
|
2
|
-
import * as Predicate from "effect/Predicate";
|
|
3
|
-
import * as Result from "effect/Result";
|
|
4
|
-
import * as Schema from "effect/Schema";
|
|
5
|
-
import { ConfigurationError, FsError } from "../../VirtualFileSystemError.js";
|
|
6
|
-
/** @internal */
|
|
7
|
-
export { ConfigurationError, FsError };
|
|
8
|
-
/** @internal */
|
|
9
|
-
export const FsCode = Schema.Literals([
|
|
10
|
-
"NotFound",
|
|
11
|
-
"AlreadyExists",
|
|
12
|
-
"NotEmpty",
|
|
13
|
-
"NotDirectory",
|
|
14
|
-
"AccessDenied",
|
|
15
|
-
"InvalidHandle",
|
|
16
|
-
"ForeignHandle",
|
|
17
|
-
"InvalidReference",
|
|
18
|
-
"ForeignReference",
|
|
19
|
-
"StaleReference",
|
|
20
|
-
"ClosedCaller",
|
|
21
|
-
"InvalidArgument",
|
|
22
|
-
"InvalidPathEncoding",
|
|
23
|
-
"PathTooLong",
|
|
24
|
-
"NoSpace",
|
|
25
|
-
"IsDirectory",
|
|
26
|
-
"FileTooLarge",
|
|
27
|
-
"NoData",
|
|
28
|
-
"SymlinkLoop",
|
|
29
|
-
"UnrepresentableName",
|
|
30
|
-
// A durable provider knows the mutation was not committed.
|
|
31
|
-
"StorageRejected",
|
|
32
|
-
// A commit or publication failed after its outcome ceased to be knowable to the caller.
|
|
33
|
-
"OutcomeUnknown",
|
|
34
|
-
// The provider stopped serving operations until recovery establishes its state.
|
|
35
|
-
"VolumeUnavailable",
|
|
36
|
-
"VolumeBusy"
|
|
37
|
-
]);
|
|
38
|
-
// Names the offending option so the caller learns which key it got wrong, not just that decoding failed.
|
|
39
|
-
const configurationField = (issue) => {
|
|
40
|
-
if (Predicate.isTagged("Pointer")(issue))
|
|
41
|
-
return issue.path.map(String).join(".");
|
|
42
|
-
if (Predicate.isTagged("Composite")(issue))
|
|
43
|
-
return configurationField(issue.issues[0]);
|
|
44
|
-
return "options";
|
|
45
|
-
};
|
|
46
|
-
/** @internal */
|
|
47
|
-
export const decodeConfiguration = (schema, value) => Schema.decodeUnknownResult(schema, { onExcessProperty: "error" })(value).pipe(Result.mapError((error) => new ConfigurationError({ field: configurationField(error.issue) })));
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"fixture.d.ts","sourceRoot":"","sources":["../../../src/internal/virtualFileSystem/fixture.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,MAAM,MAAM,eAAe,CAAA;AAGvC,OAAO,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAA;AAoB9C,gBAAgB;AAChB,eAAO,MAAM,WAAW;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;kNAwLvB,CAAA"}
|
|
@@ -1,150 +0,0 @@
|
|
|
1
|
-
// Fixture image construction.
|
|
2
|
-
import * as Effect from "effect/Effect";
|
|
3
|
-
import * as Result from "effect/Result";
|
|
4
|
-
import * as Schema from "effect/Schema";
|
|
5
|
-
import { ImageError } from "../../Snapshot.js";
|
|
6
|
-
import { CanonicalBase64 } from "../canonicalBase64.js";
|
|
7
|
-
import * as Image from "../image.js";
|
|
8
|
-
import { Fixture as FixtureSchema, FixtureEntry, makeVolume, VolumeIdentity, VolumeOptions as VolumeOptionsSchema, VolumeSource } from "../virtualFileSystem.js";
|
|
9
|
-
import { decodeConfiguration, FsError } from "./errors.js";
|
|
10
|
-
import { inputBytes, isAttachedBytes, isDotComponent, nameBytes, preparePath } from "./path.js";
|
|
11
|
-
const DEFAULT_MODE = { directory: 0o755, file: 0o644, symlink: 0o777 };
|
|
12
|
-
const EPOCH_NS = 0n;
|
|
13
|
-
/** @internal */
|
|
14
|
-
export const fromFixture = Effect.fn("VirtualFileSystem.fromFixture")(function* (fixture, options) {
|
|
15
|
-
const config = decodeConfiguration(VolumeOptionsSchema, options ?? {});
|
|
16
|
-
if (Result.isFailure(config))
|
|
17
|
-
return yield* config.failure;
|
|
18
|
-
const decoded = Schema.decodeResult(FixtureSchema, { onExcessProperty: "error" })(fixture);
|
|
19
|
-
if (Result.isFailure(decoded))
|
|
20
|
-
return yield* new ImageError({ code: "InvalidStructure", field: "fixture" });
|
|
21
|
-
const source = decoded.success;
|
|
22
|
-
if (source.entries.some((entry) => FixtureEntry.match(entry, {
|
|
23
|
-
directory: () => false,
|
|
24
|
-
file: ({ bytes }) => !isAttachedBytes(bytes),
|
|
25
|
-
symlink: () => false,
|
|
26
|
-
hardLink: () => false
|
|
27
|
-
}))) {
|
|
28
|
-
return yield* new ImageError({ code: "InvalidEncoding", field: "bytes" });
|
|
29
|
-
}
|
|
30
|
-
const metadata = (kind, overrides) => ({
|
|
31
|
-
uid: overrides?.uid ?? 0,
|
|
32
|
-
gid: overrides?.gid ?? 0,
|
|
33
|
-
mode: overrides?.mode ?? DEFAULT_MODE[kind],
|
|
34
|
-
atimeNs: overrides?.atimeNs ?? EPOCH_NS,
|
|
35
|
-
mtimeNs: overrides?.mtimeNs ?? EPOCH_NS,
|
|
36
|
-
ctimeNs: overrides?.ctimeNs ?? EPOCH_NS,
|
|
37
|
-
birthtimeNs: overrides?.birthtimeNs ?? EPOCH_NS
|
|
38
|
-
});
|
|
39
|
-
const declarations = new Map();
|
|
40
|
-
const aliases = new Map();
|
|
41
|
-
const paths = new Map();
|
|
42
|
-
const root = Image.Record.cases.directory.make({
|
|
43
|
-
id: "root",
|
|
44
|
-
metadata: metadata("directory", source.rootMetadata),
|
|
45
|
-
entries: []
|
|
46
|
-
});
|
|
47
|
-
declarations.set("", root);
|
|
48
|
-
const fixturePath = (input) => preparePath(input, "fixture", config.success.maxPathBytes).pipe(Result.flatMap((path) => !path.absolute || path.components.length === 0 ||
|
|
49
|
-
path.components.some(isDotComponent)
|
|
50
|
-
? Result.fail(new FsError({ code: "InvalidArgument", operation: "fixture", path: input })) :
|
|
51
|
-
Result.succeed(path.components)));
|
|
52
|
-
// Encode caller-owned byte buffers now: nothing below yields until Image.capture, so a caller
|
|
53
|
-
// cannot mutate them first.
|
|
54
|
-
for (const entry of source.entries) {
|
|
55
|
-
const parsed = fixturePath(entry.path);
|
|
56
|
-
if (Result.isFailure(parsed)) {
|
|
57
|
-
return yield* new ImageError({ code: "InvalidStructure", field: "path" });
|
|
58
|
-
}
|
|
59
|
-
const components = parsed.success;
|
|
60
|
-
const key = components.join("/");
|
|
61
|
-
if (paths.has(key))
|
|
62
|
-
return yield* new ImageError({ code: "InvalidStructure", field: "duplicate" });
|
|
63
|
-
paths.set(key, components);
|
|
64
|
-
const error = FixtureEntry.match(entry, {
|
|
65
|
-
hardLink: ({ target }) => {
|
|
66
|
-
const parsedTarget = fixturePath(target);
|
|
67
|
-
if (Result.isFailure(parsedTarget))
|
|
68
|
-
return new ImageError({ code: "InvalidStructure", field: "target" });
|
|
69
|
-
aliases.set(key, parsedTarget.success.join("/"));
|
|
70
|
-
},
|
|
71
|
-
directory: (entry) => {
|
|
72
|
-
declarations.set(key, Image.Record.cases.directory.make({
|
|
73
|
-
id: String(paths.size),
|
|
74
|
-
metadata: metadata("directory", entry.metadata),
|
|
75
|
-
entries: []
|
|
76
|
-
}));
|
|
77
|
-
},
|
|
78
|
-
file: (entry) => {
|
|
79
|
-
declarations.set(key, Image.Record.cases.file.make({
|
|
80
|
-
id: String(paths.size),
|
|
81
|
-
metadata: metadata("file", entry.metadata),
|
|
82
|
-
data: CanonicalBase64.encode(entry.bytes)
|
|
83
|
-
}));
|
|
84
|
-
},
|
|
85
|
-
symlink: ({ metadata: overrides, target: input }) => {
|
|
86
|
-
const target = inputBytes(input);
|
|
87
|
-
if (Result.isFailure(target)) {
|
|
88
|
-
return new ImageError({
|
|
89
|
-
code: target.failure === "InvalidPathEncoding" ? "InvalidEncoding" : "InvalidStructure",
|
|
90
|
-
field: "target"
|
|
91
|
-
});
|
|
92
|
-
}
|
|
93
|
-
if (target.success.includes(0))
|
|
94
|
-
return new ImageError({ code: "InvalidStructure", field: "target" });
|
|
95
|
-
declarations.set(key, Image.Record.cases.symlink.make({
|
|
96
|
-
id: String(paths.size),
|
|
97
|
-
metadata: metadata("symlink", overrides),
|
|
98
|
-
target: CanonicalBase64.encode(target.success)
|
|
99
|
-
}));
|
|
100
|
-
}
|
|
101
|
-
});
|
|
102
|
-
if (error instanceof ImageError)
|
|
103
|
-
return yield* error;
|
|
104
|
-
}
|
|
105
|
-
for (const [key] of aliases) {
|
|
106
|
-
let target = key;
|
|
107
|
-
const seen = new Set();
|
|
108
|
-
while (!declarations.has(target)) {
|
|
109
|
-
if (seen.has(target))
|
|
110
|
-
return yield* new ImageError({ code: "InvalidStructure", field: "hardLink" });
|
|
111
|
-
seen.add(target);
|
|
112
|
-
const next = aliases.get(target);
|
|
113
|
-
if (next === undefined)
|
|
114
|
-
return yield* new ImageError({ code: "InvalidStructure", field: "hardLink" });
|
|
115
|
-
target = next;
|
|
116
|
-
}
|
|
117
|
-
const node = declarations.get(target);
|
|
118
|
-
if (node === undefined || Image.Record.guards.directory(node)) {
|
|
119
|
-
return yield* new ImageError({ code: "InvalidStructure", field: "hardLink" });
|
|
120
|
-
}
|
|
121
|
-
for (const alias of seen)
|
|
122
|
-
declarations.set(alias, node);
|
|
123
|
-
}
|
|
124
|
-
const children = new Map();
|
|
125
|
-
for (const [key, components] of paths) {
|
|
126
|
-
const parent = declarations.get(components.slice(0, -1).join("/"));
|
|
127
|
-
const child = declarations.get(key);
|
|
128
|
-
const name = components.at(-1);
|
|
129
|
-
if (parent?._tag !== "directory" || child === undefined || name === undefined) {
|
|
130
|
-
return yield* new ImageError({ code: "InvalidStructure", field: "parent" });
|
|
131
|
-
}
|
|
132
|
-
const entries = children.get(parent.id) ?? [];
|
|
133
|
-
entries.push({ name: CanonicalBase64.encode(nameBytes(name)), target: child.id });
|
|
134
|
-
children.set(parent.id, entries);
|
|
135
|
-
}
|
|
136
|
-
const records = [...new Set(declarations.values())].map((record) => Image.Record.match(record, {
|
|
137
|
-
directory: (record) => ({ ...record, entries: children.get(record.id) ?? [] }),
|
|
138
|
-
file: (record) => record,
|
|
139
|
-
symlink: (record) => record
|
|
140
|
-
}));
|
|
141
|
-
const snapshot = yield* Image.capture({ format: "effect-vfs", version: 1, root: "root", records }, undefined, true);
|
|
142
|
-
const image = yield* Image.inspect(snapshot);
|
|
143
|
-
const { identity, ...volumeOptions } = config.success;
|
|
144
|
-
if (identity === undefined)
|
|
145
|
-
return yield* makeVolume(VolumeSource.Snapshot({ image }), volumeOptions);
|
|
146
|
-
return yield* makeVolume(VolumeSource.Snapshot({ image }), {
|
|
147
|
-
...volumeOptions,
|
|
148
|
-
identity: VolumeIdentity.make(identity)
|
|
149
|
-
});
|
|
150
|
-
});
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import type { Snapshot } from "../../Snapshot.js";
|
|
2
|
-
import * as Image from "../image.js";
|
|
3
|
-
/** @internal */
|
|
4
|
-
export interface Content {
|
|
5
|
-
readonly bytes: Uint8Array;
|
|
6
|
-
}
|
|
7
|
-
/** @internal */
|
|
8
|
-
export declare const hasOverlayContents: (snapshot: Snapshot) => boolean;
|
|
9
|
-
/** @internal */
|
|
10
|
-
export declare const make: (bytes: Uint8Array) => Content;
|
|
11
|
-
/** @internal */
|
|
12
|
-
export declare const empty: () => Content;
|
|
13
|
-
/** @internal */
|
|
14
|
-
export declare const forOverlay: (snapshot: Snapshot, image: Image.Document) => ReadonlyMap<string, Content>;
|
|
15
|
-
//# sourceMappingURL=overlayContent.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"overlayContent.d.ts","sourceRoot":"","sources":["../../../src/internal/virtualFileSystem/overlayContent.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAA;AAEjD,OAAO,KAAK,KAAK,MAAM,aAAa,CAAA;AAEpC,gBAAgB;AAChB,MAAM,WAAW,OAAO;IACtB,QAAQ,CAAC,KAAK,EAAE,UAAU,CAAA;CAC3B;AAID,gBAAgB;AAChB,eAAO,MAAM,kBAAkB,aAAc,QAAQ,KAAG,OAAwC,CAAA;AAEhG,gBAAgB;AAChB,eAAO,MAAM,IAAI,UAAW,UAAU,KAAG,OAAsB,CAAA;AAE/D,gBAAgB;AAChB,eAAO,MAAM,KAAK,QAAO,OAAkC,CAAA;AAG3D,gBAAgB;AAChB,eAAO,MAAM,UAAU,aAAc,QAAQ,SAAS,KAAK,CAAC,QAAQ,KAAG,WAAW,CAAC,MAAM,EAAE,OAAO,CAiBjG,CAAA"}
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
// Immutable regular-file payloads shared by overlay workspaces.
|
|
2
|
-
import * as Result from "effect/Result";
|
|
3
|
-
import * as Schema from "effect/Schema";
|
|
4
|
-
import { CanonicalBase64 } from "../canonicalBase64.js";
|
|
5
|
-
import * as Image from "../image.js";
|
|
6
|
-
const overlayContents = new WeakMap();
|
|
7
|
-
/** @internal */
|
|
8
|
-
export const hasOverlayContents = (snapshot) => overlayContents.has(snapshot);
|
|
9
|
-
/** @internal */
|
|
10
|
-
export const make = (bytes) => ({ bytes });
|
|
11
|
-
/** @internal */
|
|
12
|
-
export const empty = () => make(new Uint8Array(0));
|
|
13
|
-
// The weak cache shares immutable payloads without extending the snapshot's lifetime.
|
|
14
|
-
/** @internal */
|
|
15
|
-
export const forOverlay = (snapshot, image) => {
|
|
16
|
-
const cached = overlayContents.get(snapshot);
|
|
17
|
-
if (cached !== undefined)
|
|
18
|
-
return cached;
|
|
19
|
-
const decoded = new Map();
|
|
20
|
-
for (const record of image.records) {
|
|
21
|
-
if (Image.Record.guards.file(record)) {
|
|
22
|
-
const bytes = Schema.decodeResult(CanonicalBase64.Bytes)(record.data);
|
|
23
|
-
if (Result.isSuccess(bytes))
|
|
24
|
-
decoded.set(record.id, make(bytes.success));
|
|
25
|
-
}
|
|
26
|
-
}
|
|
27
|
-
overlayContents.set(snapshot, decoded);
|
|
28
|
-
return decoded;
|
|
29
|
-
};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"overlayDiff.d.ts","sourceRoot":"","sources":["../../../src/internal/virtualFileSystem/overlayDiff.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAA;AAEpD,gBAAgB;AAChB,MAAM,WAAW,gBAAgB;IAC/B,QAAQ,CAAC,IAAI,EAAE,UAAU,CAAA;IACzB,QAAQ,CAAC,OAAO,EAAE,MAAM,GAAG,SAAS,CAAA;IACpC,QAAQ,CAAC,IAAI,EAAE,WAAW,GAAG,MAAM,GAAG,SAAS,CAAA;IAC/C,QAAQ,CAAC,OAAO,EAAE,UAAU,GAAG,SAAS,CAAA;IACxC,QAAQ,CAAC,QAAQ,EAAE,cAAc,CAAA;CAClC;AAED,gBAAgB;AAChB,MAAM,MAAM,iBAAiB,GAAG,SAAS,GAAG,MAAM,GAAG,KAAK,GAAG,KAAK,GAAG,SAAS,GAAG,SAAS,GAAG,SAAS,GAAG,aAAa,CAAA;AAEtH,gBAAgB;AAChB,MAAM,MAAM,gBAAgB,GACxB;IAAE,QAAQ,CAAC,IAAI,EAAE,OAAO,CAAC;IAAC,QAAQ,CAAC,IAAI,EAAE,UAAU,CAAC;IAAC,QAAQ,CAAC,IAAI,EAAE,gBAAgB,CAAC,MAAM,CAAC,CAAA;CAAE,GAC9F;IAAE,QAAQ,CAAC,IAAI,EAAE,SAAS,CAAC;IAAC,QAAQ,CAAC,IAAI,EAAE,UAAU,CAAC;IAAC,QAAQ,CAAC,IAAI,EAAE,gBAAgB,CAAC,MAAM,CAAC,CAAA;CAAE,GAChG;IACA,QAAQ,CAAC,IAAI,EAAE,UAAU,CAAA;IACzB,QAAQ,CAAC,IAAI,EAAE,UAAU,CAAA;IACzB,QAAQ,CAAC,UAAU,EAAE,gBAAgB,CAAC,MAAM,CAAC,CAAA;IAC7C,QAAQ,CAAC,SAAS,EAAE,gBAAgB,CAAC,MAAM,CAAC,CAAA;IAC5C,QAAQ,CAAC,WAAW,EAAE,aAAa,CAAC,iBAAiB,CAAC,CAAA;CACvD,GACC;IACA,QAAQ,CAAC,IAAI,EAAE,SAAS,CAAA;IACxB,QAAQ,CAAC,IAAI,EAAE,UAAU,CAAA;IACzB,QAAQ,CAAC,EAAE,EAAE,UAAU,CAAA;IACvB,QAAQ,CAAC,IAAI,EAAE,gBAAgB,CAAC,MAAM,CAAC,CAAA;IACvC,QAAQ,CAAC,WAAW,EAAE,aAAa,CAAC,iBAAiB,CAAC,CAAA;CACvD,GACC;IACA,QAAQ,CAAC,IAAI,EAAE,SAAS,CAAA;IACxB,QAAQ,CAAC,IAAI,EAAE,UAAU,CAAA;IACzB,QAAQ,CAAC,IAAI,EAAE,gBAAgB,CAAC,MAAM,CAAC,CAAA;IACvC,QAAQ,CAAC,WAAW,EAAE,aAAa,CAAC,iBAAiB,CAAC,CAAA;CACvD,CAAA;AA4DH,gBAAgB;AAChB,eAAO,MAAM,cAAc,SACnB,aAAa,CAAC,gBAAgB,CAAC,WAC5B,aAAa,CAAC,gBAAgB,CAAC,kCAEvC,aAAa,CAAC,gBAAgB,CAgFhC,CAAA"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"path.d.ts","sourceRoot":"","sources":["../../../src/internal/virtualFileSystem/path.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,QAAQ,MAAM,iBAAiB,CAAA;AAC3C,OAAO,KAAK,MAAM,MAAM,eAAe,CAAA;AAGvC,OAAO,KAAK,MAAM,MAAM,eAAe,CAAA;AACvC,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAA;AACjD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,4BAA4B,CAAA;AAE3D,OAAO,EAAE,OAAO,EAAE,MAAM,aAAa,CAAA;AAGrC,gBAAgB;AAChB,eAAO,MAAM,SAAS,OAAO,CAAA;AAE7B,gBAAgB;AAChB,eAAO,MAAM,OAAO,OAAO,CAAA;AAE3B,gBAAgB;AAChB,eAAO,MAAM,WAAW,SAAS,CAAA;AAEjC,gBAAgB;AAChB,eAAO,MAAM,UAAU,KAAK,CAAA;AAG5B,gBAAgB;AAChB,eAAO,MAAM,cAAc,MAAM,CAAA;AAKjC,gBAAgB;AAChB,eAAO,MAAM,cAAc,SAAU,MAAM,GAAG,SAAS,KAAG,IAAI,IAAI,SAAS,GAAG,OAAO,OAAO,GAAG,OAAO,WACtC,CAAA;AAEhE,gBAAgB;AAChB,eAAO,MAAM,SAAS,UAAW,UAAU,KAAG,QAA+B,CAAA;AAE7E,gBAAgB;AAChB,eAAO,MAAM,YAAY,UAAW,UAAU,aAAa,MAAM,0CAI7D,CAAA;AAEJ,gBAAgB;AAChB,eAAO,MAAM,SAAS,SAAU,MAAM,KAAG,UAAyD,CAAA;AAgBlG,gBAAgB;AAChB,eAAO,MAAM,eAAe,UAAW,UAAU,KAAG,OAC2C,CAAA;AAE/F,gBAAgB;AAChB,eAAO,MAAM,aAAa,iFASxB,CAAA;AAEF,gBAAgB;AAChB,eAAO,MAAM,WAAW,4EAMtB,CAAA;AAEF,gBAAgB;AAChB,MAAM,WAAW,YAAY;IAC3B,QAAQ,CAAC,KAAK,EAAE,SAAS,CAAA;IACzB,QAAQ,CAAC,QAAQ,EAAE,OAAO,CAAA;IAC1B,QAAQ,CAAC,aAAa,EAAE,OAAO,CAAA;IAC/B,QAAQ,CAAC,KAAK,EAAE,UAAU,CAAA;IAC1B,QAAQ,CAAC,QAAQ,EAAE,aAAa,CAAC,UAAU,CAAC,CAAA;IAC5C,QAAQ,CAAC,UAAU,EAAE,aAAa,CAAC,MAAM,CAAC,CAAA;CAC3C;AAoBD,gBAAgB;AAChB,eAAO,MAAM,UAAU,UAAW,SAAS,KAAG,MAAM,CAAC,MAAM,CAAC,UAAU,EAAE,qBAAqB,GAAG,iBAAiB,CAG5B,CAAA;AAErF,gBAAgB;AAChB,eAAO,MAAM,WAAW,UACf,SAAS,aACL,MAAM,gBACH,QAAQ,CAAC,QAAQ,GAAG,SAAS,KAC1C,MAAM,CAAC,MAAM,CAAC,YAAY,EAAE,OAAO,CAgDrC,CAAA"}
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
import * as Effect from "effect/Effect";
|
|
2
|
-
import { FsError } from "./errors.js";
|
|
3
|
-
/** @internal */
|
|
4
|
-
export type CommitOutcome = "committed" | "rejected" | "unknown";
|
|
5
|
-
/** @internal */
|
|
6
|
-
export interface CommitProvider<State> {
|
|
7
|
-
/** Provides a gate-coordinated shutdown effect once staging is ready. */
|
|
8
|
-
readonly onReady?: (shutdown: Effect.Effect<void>) => void;
|
|
9
|
-
/** Checks and encodes a candidate before the commit boundary. Failure leaves the volume available. */
|
|
10
|
-
readonly prepare?: (candidate: State) => Effect.Effect<void, FsError>;
|
|
11
|
-
/** Classifies a candidate as committed, definitely rejected, or uncertain. */
|
|
12
|
-
readonly commit: (candidate: State) => Effect.Effect<CommitOutcome>;
|
|
13
|
-
}
|
|
14
|
-
/** @internal */
|
|
15
|
-
export declare const makeStagedState: <State, Event = never>(initial: State, copy: (current: State) => Effect.Effect<State>, rawProvider: CommitProvider<State>, publish?: (candidate: State, events: ReadonlyArray<Event>) => void) => {
|
|
16
|
-
read: <A, E, R>(operation: string, inspect: (state: Readonly<State>) => Effect.Effect<A, E, R>) => Effect.Effect<A, E | FsError, R>;
|
|
17
|
-
mutate: <A, E, R>(operation: string, change: (candidate: State, emit: (event: Event) => void) => Effect.Effect<A, E, R>, onStorageFailure?: () => void) => Effect.Effect<A, E | FsError, R>;
|
|
18
|
-
coordinate: <A, E, R>(effect: Effect.Effect<A, E, R>) => Effect.Effect<A, E, R>;
|
|
19
|
-
checkAvailable: (operation: string) => Effect.Effect<void, FsError, never>;
|
|
20
|
-
shutdown: Effect.Effect<void, never, never>;
|
|
21
|
-
};
|
|
22
|
-
//# sourceMappingURL=stagedState.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"stagedState.d.ts","sourceRoot":"","sources":["../../../src/internal/virtualFileSystem/stagedState.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,MAAM,eAAe,CAAA;AAGvC,OAAO,EAAE,OAAO,EAAE,MAAM,aAAa,CAAA;AAErC,gBAAgB;AAChB,MAAM,MAAM,aAAa,GAAG,WAAW,GAAG,UAAU,GAAG,SAAS,CAAA;AAEhE,gBAAgB;AAChB,MAAM,WAAW,cAAc,CAAC,KAAK;IACnC,yEAAyE;IACzE,QAAQ,CAAC,OAAO,CAAC,EAAE,CAAC,QAAQ,EAAE,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,KAAK,IAAI,CAAA;IAC1D,sGAAsG;IACtG,QAAQ,CAAC,OAAO,CAAC,EAAE,CAAC,SAAS,EAAE,KAAK,KAAK,MAAM,CAAC,MAAM,CAAC,IAAI,EAAE,OAAO,CAAC,CAAA;IACrE,8EAA8E;IAC9E,QAAQ,CAAC,MAAM,EAAE,CAAC,SAAS,EAAE,KAAK,KAAK,MAAM,CAAC,MAAM,CAAC,aAAa,CAAC,CAAA;CACpE;AAED,gBAAgB;AAChB,eAAO,MAAM,eAAe,GAAI,KAAK,EAAE,KAAK,mBACjC,KAAK,QAER,CAAC,OAAO,EAAE,KAAK,KAAK,MAAM,CAAC,MAAM,CAAC,KAAK,CAAC,eACjC,cAAc,CAAC,KAAK,CAAC,YACxB,CAAC,SAAS,EAAE,KAAK,EAAE,MAAM,EAAE,aAAa,CAAC,KAAK,CAAC,KAAK,IAAI;WAyBpD,CAAC,EAAE,CAAC,EAAE,CAAC,aAAa,MAAM,WAAW,CAAC,KAAK,EAAE,QAAQ,CAAC,KAAK,CAAC,KAAK,MAAM,CAAC,MAAM,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC;aAOrF,CAAC,EAAE,CAAC,EAAE,CAAC,aACV,MAAM,UACT,CAAC,SAAS,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,KAAK,EAAE,KAAK,KAAK,IAAI,KAAK,MAAM,CAAC,MAAM,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,qBAC/D,MAAM,IAAI;iBAhBX,CAAC,EAAE,CAAC,EAAE,CAAC,UAAU,MAAM,CAAC,MAAM,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC;gCAPxB,MAAM;;CA0E1C,CAAA"}
|
|
@@ -1,62 +0,0 @@
|
|
|
1
|
-
import * as Effect from "effect/Effect";
|
|
2
|
-
import * as Exit from "effect/Exit";
|
|
3
|
-
import * as Semaphore from "effect/Semaphore";
|
|
4
|
-
import { FsError } from "./errors.js";
|
|
5
|
-
/** @internal */
|
|
6
|
-
export const makeStagedState = (initial,
|
|
7
|
-
// The copy must detach every mutable value that change can reach.
|
|
8
|
-
copy, rawProvider, publish) => {
|
|
9
|
-
const gate = Semaphore.makeUnsafe(1);
|
|
10
|
-
const provider = {
|
|
11
|
-
...rawProvider,
|
|
12
|
-
commit: (candidate) => Effect.suspend(() => rawProvider.commit(candidate))
|
|
13
|
-
};
|
|
14
|
-
let current = initial;
|
|
15
|
-
let available = true;
|
|
16
|
-
const checkAvailable = (operation) => Effect.suspend(() => available
|
|
17
|
-
? Effect.void
|
|
18
|
-
: Effect.fail(new FsError({ code: "VolumeUnavailable", operation })));
|
|
19
|
-
const coordinate = (effect) => gate.withPermit(effect);
|
|
20
|
-
const shutdown = coordinate(Effect.sync(() => {
|
|
21
|
-
available = false;
|
|
22
|
-
}));
|
|
23
|
-
const read = (operation, inspect) => coordinate(Effect.gen(function* () {
|
|
24
|
-
yield* checkAvailable(operation);
|
|
25
|
-
return yield* inspect(current);
|
|
26
|
-
}));
|
|
27
|
-
const mutate = (operation, change, onStorageFailure) => coordinate(Effect.uninterruptibleMask((restore) => Effect.gen(function* () {
|
|
28
|
-
yield* checkAvailable(operation);
|
|
29
|
-
const candidate = yield* restore(copy(current));
|
|
30
|
-
const events = [];
|
|
31
|
-
const value = yield* restore(change(candidate, (event) => events.push(event)));
|
|
32
|
-
if (provider.prepare !== undefined)
|
|
33
|
-
yield* restore(provider.prepare(candidate));
|
|
34
|
-
const committed = yield* Effect.exit(Effect.suspend(() => provider.commit(candidate)));
|
|
35
|
-
if (Exit.isFailure(committed)) {
|
|
36
|
-
available = false;
|
|
37
|
-
onStorageFailure?.();
|
|
38
|
-
return yield* new FsError({ code: "OutcomeUnknown", operation });
|
|
39
|
-
}
|
|
40
|
-
const outcome = committed.value;
|
|
41
|
-
if (outcome === "rejected") {
|
|
42
|
-
if (onStorageFailure !== undefined) {
|
|
43
|
-
available = false;
|
|
44
|
-
onStorageFailure();
|
|
45
|
-
}
|
|
46
|
-
return yield* new FsError({ code: "StorageRejected", operation });
|
|
47
|
-
}
|
|
48
|
-
if (outcome === "unknown") {
|
|
49
|
-
available = false;
|
|
50
|
-
onStorageFailure?.();
|
|
51
|
-
return yield* new FsError({ code: "OutcomeUnknown", operation });
|
|
52
|
-
}
|
|
53
|
-
current = candidate;
|
|
54
|
-
const published = yield* Effect.exit(Effect.sync(() => publish?.(candidate, events)));
|
|
55
|
-
if (Exit.isFailure(published)) {
|
|
56
|
-
available = false;
|
|
57
|
-
return yield* new FsError({ code: "OutcomeUnknown", operation });
|
|
58
|
-
}
|
|
59
|
-
return value;
|
|
60
|
-
})));
|
|
61
|
-
return { read, mutate, coordinate, checkAvailable, shutdown };
|
|
62
|
-
};
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
import type * as Effect from "effect/Effect";
|
|
2
|
-
import type { Snapshot } from "../../Snapshot.js";
|
|
3
|
-
import type { Volume } from "../../VirtualFileSystem.js";
|
|
4
|
-
/** @internal */
|
|
5
|
-
export interface ObservationHook {
|
|
6
|
-
readonly betweenSnapshotAndSummary: Effect.Effect<void>;
|
|
7
|
-
}
|
|
8
|
-
/** @internal */
|
|
9
|
-
export declare const getObservationHook: (snapshot: Snapshot) => ObservationHook | undefined;
|
|
10
|
-
/** @internal */
|
|
11
|
-
export declare const setObservationHook: (snapshot: Snapshot, hook: ObservationHook) => () => void;
|
|
12
|
-
/** @internal */
|
|
13
|
-
export interface RegistrationHook {
|
|
14
|
-
readonly afterSubscribe: Effect.Effect<void>;
|
|
15
|
-
}
|
|
16
|
-
/** @internal */
|
|
17
|
-
export declare const getRegistrationHook: (volume: Volume) => RegistrationHook | undefined;
|
|
18
|
-
/** @internal */
|
|
19
|
-
export declare const setRegistrationHook: (volume: Volume, hook: RegistrationHook) => () => void;
|
|
20
|
-
//# sourceMappingURL=testHooks.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"testHooks.d.ts","sourceRoot":"","sources":["../../../src/internal/virtualFileSystem/testHooks.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,KAAK,MAAM,MAAM,eAAe,CAAA;AAC5C,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAA;AACjD,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,4BAA4B,CAAA;AAExD,gBAAgB;AAChB,MAAM,WAAW,eAAe;IAC9B,QAAQ,CAAC,yBAAyB,EAAE,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,CAAA;CACxD;AAID,gBAAgB;AAChB,eAAO,MAAM,kBAAkB,aAAc,QAAQ,KAAG,eAAe,GAAG,SAA2C,CAAA;AAErH,gBAAgB;AAChB,eAAO,MAAM,kBAAkB,aAAc,QAAQ,QAAQ,eAAe,KAAG,MAAM,IAMpF,CAAA;AAED,gBAAgB;AAChB,MAAM,WAAW,gBAAgB;IAC/B,QAAQ,CAAC,cAAc,EAAE,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,CAAA;CAC7C;AAID,gBAAgB;AAChB,eAAO,MAAM,mBAAmB,WAAY,MAAM,KAAG,gBAAgB,GAAG,SAA0C,CAAA;AAElH,gBAAgB;AAChB,eAAO,MAAM,mBAAmB,WAAY,MAAM,QAAQ,gBAAgB,KAAG,MAAM,IAMlF,CAAA"}
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
// Package-internal synchronization hooks for deterministic volume tests.
|
|
2
|
-
const observationHooks = new WeakMap();
|
|
3
|
-
/** @internal */
|
|
4
|
-
export const getObservationHook = (snapshot) => observationHooks.get(snapshot);
|
|
5
|
-
/** @internal */
|
|
6
|
-
export const setObservationHook = (snapshot, hook) => {
|
|
7
|
-
observationHooks.set(snapshot, hook);
|
|
8
|
-
return () => {
|
|
9
|
-
if (observationHooks.get(snapshot) === hook)
|
|
10
|
-
observationHooks.delete(snapshot);
|
|
11
|
-
};
|
|
12
|
-
};
|
|
13
|
-
const registrationHooks = new WeakMap();
|
|
14
|
-
/** @internal */
|
|
15
|
-
export const getRegistrationHook = (volume) => registrationHooks.get(volume);
|
|
16
|
-
/** @internal */
|
|
17
|
-
export const setRegistrationHook = (volume, hook) => {
|
|
18
|
-
registrationHooks.set(volume, hook);
|
|
19
|
-
return () => {
|
|
20
|
-
if (registrationHooks.get(volume) === hook)
|
|
21
|
-
registrationHooks.delete(volume);
|
|
22
|
-
};
|
|
23
|
-
};
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import * as Effect from "effect/Effect";
|
|
2
|
-
import type * as Scope from "effect/Scope";
|
|
3
|
-
import * as Stream from "effect/Stream";
|
|
4
|
-
/** @internal */
|
|
5
|
-
export interface Coordinator {
|
|
6
|
-
<A, E, R>(effect: Effect.Effect<A, E, R>): Effect.Effect<A, E, R>;
|
|
7
|
-
}
|
|
8
|
-
/** @internal */
|
|
9
|
-
export interface WatchHub<A, E = never> {
|
|
10
|
-
readonly publishUnsafe: (event: () => A) => void;
|
|
11
|
-
readonly publishManyUnsafe: (events: () => Iterable<A>) => void;
|
|
12
|
-
readonly subscribe: (afterSubscribe?: Effect.Effect<void>) => Effect.Effect<Stream.Stream<A>, E, Scope.Scope>;
|
|
13
|
-
}
|
|
14
|
-
/** @internal */
|
|
15
|
-
export declare const make: <A, E = never>(coordinate: Coordinator, capacity: number, rescan: () => A, checkAvailable?: Effect.Effect<void, E, never> | undefined) => Effect.Effect<WatchHub<A, E>, never, never>;
|
|
16
|
-
//# sourceMappingURL=watchHub.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"watchHub.d.ts","sourceRoot":"","sources":["../../../src/internal/virtualFileSystem/watchHub.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,MAAM,eAAe,CAAA;AAEvC,OAAO,KAAK,KAAK,KAAK,MAAM,cAAc,CAAA;AAC1C,OAAO,KAAK,MAAM,MAAM,eAAe,CAAA;AAEvC,gBAAgB;AAChB,MAAM,WAAW,WAAW;IAC1B,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,MAAM,EAAE,MAAM,CAAC,MAAM,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,GAAG,MAAM,CAAC,MAAM,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,CAAA;CAClE;AAED,gBAAgB;AAChB,MAAM,WAAW,QAAQ,CAAC,CAAC,EAAE,CAAC,GAAG,KAAK;IACpC,QAAQ,CAAC,aAAa,EAAE,CAAC,KAAK,EAAE,MAAM,CAAC,KAAK,IAAI,CAAA;IAChD,QAAQ,CAAC,iBAAiB,EAAE,CAAC,MAAM,EAAE,MAAM,QAAQ,CAAC,CAAC,CAAC,KAAK,IAAI,CAAA;IAC/D,QAAQ,CAAC,SAAS,EAAE,CAAC,cAAc,CAAC,EAAE,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,KAAK,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,KAAK,CAAC,KAAK,CAAC,CAAA;CAC9G;AAQD,gBAAgB;AAChB,eAAO,MAAM,IAAI,GAA+B,CAAC,EAAE,CAAC,mEAGpC,CAAC,4GAiEf,CAAA"}
|
|
@@ -1,54 +0,0 @@
|
|
|
1
|
-
import * as Effect from "effect/Effect";
|
|
2
|
-
import * as Queue from "effect/Queue";
|
|
3
|
-
import * as Stream from "effect/Stream";
|
|
4
|
-
/** @internal */
|
|
5
|
-
export const make = Effect.fnUntraced(function* (coordinate, capacity, rescan, checkAvailable) {
|
|
6
|
-
const subscribers = new Set();
|
|
7
|
-
const publish = (event) => {
|
|
8
|
-
for (const subscriber of subscribers) {
|
|
9
|
-
if (subscriber.overflowed)
|
|
10
|
-
continue;
|
|
11
|
-
if (Queue.sizeUnsafe(subscriber.queue) < capacity - 1) {
|
|
12
|
-
Queue.offerUnsafe(subscriber.queue, event);
|
|
13
|
-
}
|
|
14
|
-
else {
|
|
15
|
-
subscriber.overflowed = true;
|
|
16
|
-
subscriber.marker = rescan();
|
|
17
|
-
Queue.offerUnsafe(subscriber.queue, subscriber.marker);
|
|
18
|
-
}
|
|
19
|
-
}
|
|
20
|
-
};
|
|
21
|
-
const publishUnsafe = (event) => {
|
|
22
|
-
if (subscribers.size > 0)
|
|
23
|
-
publish(event());
|
|
24
|
-
};
|
|
25
|
-
const publishManyUnsafe = (events) => {
|
|
26
|
-
if (subscribers.size > 0) {
|
|
27
|
-
for (const event of events())
|
|
28
|
-
publish(event);
|
|
29
|
-
}
|
|
30
|
-
};
|
|
31
|
-
const subscribe = (afterSubscribe) => Effect.acquireRelease(coordinate(Effect.gen(function* () {
|
|
32
|
-
if (checkAvailable !== undefined)
|
|
33
|
-
yield* checkAvailable;
|
|
34
|
-
const queue = yield* Queue.bounded(capacity);
|
|
35
|
-
const subscriber = {
|
|
36
|
-
queue,
|
|
37
|
-
overflowed: false,
|
|
38
|
-
marker: undefined
|
|
39
|
-
};
|
|
40
|
-
if (afterSubscribe !== undefined)
|
|
41
|
-
yield* afterSubscribe;
|
|
42
|
-
subscribers.add(subscriber);
|
|
43
|
-
return subscriber;
|
|
44
|
-
})), (subscriber) => coordinate(Effect.sync(() => {
|
|
45
|
-
subscribers.delete(subscriber);
|
|
46
|
-
})).pipe(Effect.andThen(Queue.shutdown(subscriber.queue))), { interruptible: true }).pipe(Effect.map((subscriber) => Stream.fromEffectRepeat(Queue.take(subscriber.queue)).pipe(Stream.map((event) => {
|
|
47
|
-
if (subscriber.overflowed && event === subscriber.marker) {
|
|
48
|
-
subscriber.overflowed = false;
|
|
49
|
-
subscriber.marker = undefined;
|
|
50
|
-
}
|
|
51
|
-
return event;
|
|
52
|
-
}))));
|
|
53
|
-
return { publishUnsafe, publishManyUnsafe, subscribe };
|
|
54
|
-
});
|