@effect-vfs/core 0.8.0 → 0.9.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 +9 -0
- package/dist/Caller.d.ts +2 -0
- package/dist/Caller.d.ts.map +1 -1
- package/dist/Caller.js +3 -1
- package/dist/LiveVolume.d.ts +69 -1
- package/dist/LiveVolume.d.ts.map +1 -1
- package/dist/LiveVolume.js +80 -3
- package/dist/Search.d.ts.map +1 -1
- package/dist/Search.js +12 -4
- package/dist/VfsError.d.ts +3 -1
- package/dist/VfsError.d.ts.map +1 -1
- package/dist/VfsError.js +3 -1
- package/dist/VirtualFileSystem.d.ts +25 -1
- package/dist/VirtualFileSystem.d.ts.map +1 -1
- package/dist/VirtualFileSystem.js +10 -4
- package/dist/Watch.d.ts +18 -0
- package/dist/Watch.d.ts.map +1 -1
- package/dist/Watch.js +12 -0
- package/dist/internal/callerWatch.d.ts +32 -0
- package/dist/internal/callerWatch.d.ts.map +1 -0
- package/dist/internal/callerWatch.js +184 -0
- package/dist/internal/confinement.d.ts +16 -0
- package/dist/internal/confinement.d.ts.map +1 -0
- package/dist/internal/confinement.js +79 -0
- package/dist/internal/directoryEntries.d.ts +6 -0
- package/dist/internal/directoryEntries.d.ts.map +1 -0
- package/dist/internal/directoryEntries.js +79 -0
- package/dist/internal/fixture.js +1 -1
- package/dist/internal/path.js +2 -2
- package/dist/internal/resolution.d.ts +8 -4
- package/dist/internal/resolution.d.ts.map +1 -1
- package/dist/internal/resolution.js +68 -13
- package/dist/internal/tokenRegistry.d.ts +6 -0
- package/dist/internal/tokenRegistry.d.ts.map +1 -1
- package/dist/internal/tokenRegistry.js +21 -3
- package/dist/internal/virtualFileSystem.d.ts.map +1 -1
- package/dist/internal/virtualFileSystem.js +245 -80
- package/dist/internal/watchHub.d.ts +6 -2
- package/dist/internal/watchHub.d.ts.map +1 -1
- package/dist/internal/watchHub.js +31 -6
- package/package.json +5 -3
|
@@ -10,15 +10,19 @@ export interface Coordinator {
|
|
|
10
10
|
*
|
|
11
11
|
* @internal
|
|
12
12
|
*/
|
|
13
|
-
export interface Selection<A, C> {
|
|
13
|
+
export interface Selection<A, C, E = never> {
|
|
14
14
|
readonly includes: (event: A, context: C) => boolean;
|
|
15
|
+
readonly prepare?: (context: C) => void;
|
|
16
|
+
readonly project?: (event: A, context: C) => A | undefined;
|
|
17
|
+
readonly failure?: (context: C) => E | undefined;
|
|
18
|
+
readonly boundedTerminal?: boolean;
|
|
15
19
|
readonly rescan: (context: C) => A;
|
|
16
20
|
readonly settle?: (context: C) => Iterable<A> | undefined;
|
|
17
21
|
}
|
|
18
22
|
/** @internal */
|
|
19
23
|
export interface WatchHub<A, C, E = never> {
|
|
20
24
|
readonly publishUnsafe: (events: () => Iterable<A>, context: C) => void;
|
|
21
|
-
readonly subscribe: (select: Effect.Effect<Selection<A, C>, E>, afterSubscribe: Effect.Effect<void>) => Effect.Effect<Stream.Stream<A>, E, Scope.Scope>;
|
|
25
|
+
readonly subscribe: <F extends E = never>(select: Effect.Effect<Selection<A, C, F>, E>, afterSubscribe: Effect.Effect<void>) => Effect.Effect<Stream.Stream<A, F>, E, Scope.Scope>;
|
|
22
26
|
}
|
|
23
27
|
/** @internal */
|
|
24
28
|
export declare const make: <A, C, E = never>(coordinate: Coordinator, capacity: number) => Effect.Effect<WatchHub<A, C, E>, never, never>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"watchHub.d.ts","sourceRoot":"","sources":["../../src/internal/watchHub.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,MAAM,MAAM,eAAe,CAAA;AAGvC,OAAO,KAAK,KAAK,MAAM,cAAc,CAAA;AACrC,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,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C,EAAE,CAAC,OAAO,EAAE,CAAC,KAAK,QAAQ,CAAC,CAAC,CAAC,GAAG,SAAS,CAAA;CAC1D;AAED,gBAAgB;AAChB,MAAM,WAAW,QAAQ,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,GAAG,KAAK;IACvC,QAAQ,CAAC,aAAa,EAAE,CAAC,MAAM,EAAE,MAAM,QAAQ,CAAC,CAAC,CAAC,EAAE,OAAO,EAAE,CAAC,KAAK,IAAI,CAAA;IACvE,QAAQ,CAAC,SAAS,EAAE,CAAC,CAAC,SAAS,CAAC,GAAG,KAAK,EACtC,MAAM,EAAE,MAAM,CAAC,MAAM,CAAC,SAAS,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,EAAE,CAAC,CAAC,EAC5C,cAAc,EAAE,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,KAChC,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,CAAC,EAAE,KAAK,CAAC,KAAK,CAAC,CAAA;CACxD;AAQD,gBAAgB;AAChB,eAAO,MAAM,IAAI,GAA+B,CAAC,EAAE,CAAC,EAAE,CAAC,sGAoHrD,CAAA"}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import * as Cause from "effect/Cause";
|
|
1
2
|
import * as Effect from "effect/Effect";
|
|
2
3
|
import * as Predicate from "effect/Predicate";
|
|
3
4
|
import * as Queue from "effect/Queue";
|
|
@@ -17,20 +18,43 @@ export const make = Effect.fnUntraced(function* (coordinate, capacity) {
|
|
|
17
18
|
const publishUnsafe = (events, context) => {
|
|
18
19
|
if (subscribers.size === 0)
|
|
19
20
|
return;
|
|
21
|
+
for (const subscriber of subscribers)
|
|
22
|
+
subscriber.selection.prepare?.(context);
|
|
20
23
|
for (const event of events()) {
|
|
21
24
|
for (const subscriber of subscribers) {
|
|
22
|
-
if (subscriber.selection.includes(event, context))
|
|
23
|
-
|
|
25
|
+
if (subscriber.selection.includes(event, context)) {
|
|
26
|
+
const projected = subscriber.selection.project === undefined
|
|
27
|
+
? event
|
|
28
|
+
: subscriber.selection.project(event, context);
|
|
29
|
+
if (projected !== undefined)
|
|
30
|
+
offer(subscriber, projected, context);
|
|
31
|
+
}
|
|
24
32
|
}
|
|
25
33
|
}
|
|
26
34
|
for (const subscriber of subscribers) {
|
|
27
35
|
const last = subscriber.selection.settle?.(context);
|
|
28
|
-
|
|
36
|
+
const failure = subscriber.selection.failure?.(context);
|
|
37
|
+
if (last === undefined && failure === undefined)
|
|
29
38
|
continue;
|
|
30
|
-
|
|
31
|
-
|
|
39
|
+
if (last !== undefined) {
|
|
40
|
+
if (subscriber.selection.boundedTerminal) {
|
|
41
|
+
for (const event of last)
|
|
42
|
+
offer(subscriber, event, context);
|
|
43
|
+
if (subscriber.overflowed) {
|
|
44
|
+
while (Queue.takeUnsafe(subscriber.queue) !== undefined) { /* Drain before replacing with Rescan. */ }
|
|
45
|
+
Queue.offerUnsafe(subscriber.queue, subscriber.selection.rescan(context));
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
else {
|
|
49
|
+
for (const event of last)
|
|
50
|
+
Queue.offerUnsafe(subscriber.queue, event);
|
|
51
|
+
}
|
|
52
|
+
}
|
|
32
53
|
subscribers.delete(subscriber);
|
|
33
|
-
|
|
54
|
+
if (failure === undefined)
|
|
55
|
+
Queue.endUnsafe(subscriber.queue);
|
|
56
|
+
else
|
|
57
|
+
Queue.failCauseUnsafe(subscriber.queue, Cause.fail(failure));
|
|
34
58
|
}
|
|
35
59
|
};
|
|
36
60
|
// Register cleanup before waiting for the volume, including when the scope closes during registration.
|
|
@@ -62,6 +86,7 @@ export const make = Effect.fnUntraced(function* (coordinate, capacity) {
|
|
|
62
86
|
registered = created;
|
|
63
87
|
return created;
|
|
64
88
|
}));
|
|
89
|
+
// SAFETY: A subscription queue only receives failures from its own Selection<F>.
|
|
65
90
|
return subscriber === undefined ? Stream.empty : Stream.fromEffectRepeat(Queue.take(subscriber.queue));
|
|
66
91
|
});
|
|
67
92
|
return { publishUnsafe, subscribe };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@effect-vfs/core",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.9.0",
|
|
4
4
|
"description": "A runtime-neutral virtual filesystem core for Effect.",
|
|
5
5
|
"homepage": "https://github.com/lloydrichards/effect-virtual-fs#readme",
|
|
6
6
|
"bugs": {
|
|
@@ -22,7 +22,8 @@
|
|
|
22
22
|
"build": "tsc --project tsconfig.build.json && tsc --project compatibility/node-next/tsconfig.json",
|
|
23
23
|
"clean": "git clean -xdf .cache .turbo dist docs node_modules tsconfig.tsbuildinfo",
|
|
24
24
|
"test": "bun --bun run vitest run --config ../../vitest.config.ts --project core",
|
|
25
|
-
"type-check": "tsc --noEmit && tsc --project contracts/tsconfig.json"
|
|
25
|
+
"type-check": "tsc --noEmit && tsc --project contracts/tsconfig.json && tsc --project tsconfig.benchmarks.json",
|
|
26
|
+
"benchmark": "bun --bun run vitest bench --run --config ../../vitest.config.ts --project 'core (bench)'"
|
|
26
27
|
},
|
|
27
28
|
"peerDependencies": {
|
|
28
29
|
"effect": "^4.0.0"
|
|
@@ -32,7 +33,8 @@
|
|
|
32
33
|
"@effect/platform-node-shared": "4.0.0",
|
|
33
34
|
"@effect/vitest": "4.0.0",
|
|
34
35
|
"@repo/config-typescript": "workspace:*",
|
|
35
|
-
"effect": "4.0.0"
|
|
36
|
+
"effect": "4.0.0",
|
|
37
|
+
"@types/node": "26.6.3"
|
|
36
38
|
},
|
|
37
39
|
"exports": {
|
|
38
40
|
".": {
|