@effect-vfs/core 0.2.0 → 0.3.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/dist/BytePath.d.ts +18 -5
- package/dist/BytePath.d.ts.map +1 -1
- package/dist/BytePath.js +9 -9
- package/dist/Snapshot.d.ts +3 -3
- package/dist/Snapshot.d.ts.map +1 -1
- package/dist/Snapshot.js +3 -4
- package/dist/SnapshotDelta.d.ts +97 -30
- package/dist/SnapshotDelta.d.ts.map +1 -1
- package/dist/SnapshotDelta.js +51 -24
- package/dist/VirtualFileSystem.d.ts +122 -344
- package/dist/VirtualFileSystem.d.ts.map +1 -1
- package/dist/VirtualFileSystem.js +53 -1773
- package/dist/internal/bytePath.d.ts +10 -0
- package/dist/internal/bytePath.d.ts.map +1 -0
- package/dist/internal/bytePath.js +46 -0
- package/dist/internal/canonicalBase64.d.ts +3 -3
- package/dist/internal/canonicalBase64.d.ts.map +1 -1
- package/dist/internal/canonicalBase64.js +3 -3
- package/dist/internal/image.d.ts +21 -26
- package/dist/internal/image.d.ts.map +1 -1
- package/dist/internal/image.js +4 -9
- package/dist/internal/snapshotDelta.d.ts +0 -1
- package/dist/internal/snapshotDelta.d.ts.map +1 -1
- package/dist/internal/snapshotDelta.js +15 -28
- package/dist/internal/snapshotDeltaModel.d.ts +10 -0
- package/dist/internal/snapshotDeltaModel.d.ts.map +1 -0
- package/dist/internal/snapshotDeltaModel.js +13 -0
- package/dist/internal/virtualFileSystem/errors.d.ts +26 -0
- package/dist/internal/virtualFileSystem/errors.d.ts.map +1 -0
- package/dist/internal/virtualFileSystem/errors.js +32 -0
- package/dist/internal/virtualFileSystem/fixture.d.ts +63 -0
- package/dist/internal/virtualFileSystem/fixture.d.ts.map +1 -0
- package/dist/internal/virtualFileSystem/fixture.js +144 -0
- package/dist/internal/{content.d.ts → virtualFileSystem/overlayContent.d.ts} +4 -14
- package/dist/internal/virtualFileSystem/overlayContent.d.ts.map +1 -0
- package/dist/internal/{content.js → virtualFileSystem/overlayContent.js} +3 -7
- package/dist/internal/{overlayChanges.d.ts → virtualFileSystem/overlayDiff.d.ts} +1 -1
- package/dist/internal/virtualFileSystem/overlayDiff.d.ts.map +1 -0
- package/dist/internal/virtualFileSystem/path.d.ts +43 -0
- package/dist/internal/virtualFileSystem/path.d.ts.map +1 -0
- package/dist/internal/virtualFileSystem/path.js +124 -0
- package/dist/internal/virtualFileSystem/testHooks.d.ts +20 -0
- package/dist/internal/virtualFileSystem/testHooks.d.ts.map +1 -0
- package/dist/internal/virtualFileSystem/testHooks.js +23 -0
- package/dist/internal/virtualFileSystem/watchHub.d.ts +16 -0
- package/dist/internal/virtualFileSystem/watchHub.d.ts.map +1 -0
- package/dist/internal/virtualFileSystem/watchHub.js +33 -0
- package/dist/internal/virtualFileSystem.d.ts +290 -0
- package/dist/internal/virtualFileSystem.d.ts.map +1 -0
- package/dist/internal/virtualFileSystem.js +1677 -0
- package/package.json +1 -1
- package/dist/internal/content.d.ts.map +0 -1
- package/dist/internal/overlayChanges.d.ts.map +0 -1
- package/dist/internal/overlayTesting.d.ts +0 -12
- package/dist/internal/overlayTesting.d.ts.map +0 -1
- package/dist/internal/overlayTesting.js +0 -12
- /package/dist/internal/{overlayChanges.js → virtualFileSystem/overlayDiff.js} +0 -0
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { BytePath } from "../BytePath.js";
|
|
2
|
+
/** @internal */
|
|
3
|
+
export declare const BytePathId: "@effect-vfs/core/BytePath";
|
|
4
|
+
/** @internal */
|
|
5
|
+
export declare const isBytePath: (value: unknown) => value is BytePath;
|
|
6
|
+
/** @internal */
|
|
7
|
+
export declare const make: (bytes: Uint8Array) => BytePath;
|
|
8
|
+
/** @internal */
|
|
9
|
+
export declare const getBytes: (path: BytePath) => Uint8Array | undefined;
|
|
10
|
+
//# sourceMappingURL=bytePath.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"bytePath.d.ts","sourceRoot":"","sources":["../../src/internal/bytePath.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAA;AAE9C,gBAAgB;AAChB,eAAO,MAAM,UAAU,EAAG,2BAAoC,CAAA;AAgC9D,gBAAgB;AAChB,eAAO,MAAM,UAAU,UAAW,OAAO,KAAG,KAAK,IAAI,QAC4B,CAAA;AAEjF,gBAAgB;AAChB,eAAO,MAAM,IAAI,UAAW,UAAU,KAAG,QAIxC,CAAA;AAED,gBAAgB;AAChB,eAAO,MAAM,QAAQ,SAAU,QAAQ,KAAG,UAAU,GAAG,SAAgC,CAAA"}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
// Opaque byte path representation and value protocols.
|
|
2
|
+
import * as Equal from "effect/Equal";
|
|
3
|
+
import * as Hash from "effect/Hash";
|
|
4
|
+
import { pipeArguments } from "effect/Pipeable";
|
|
5
|
+
/** @internal */
|
|
6
|
+
export const BytePathId = "@effect-vfs/core/BytePath";
|
|
7
|
+
const bytePaths = new WeakMap();
|
|
8
|
+
const hashBytes = (bytes) => {
|
|
9
|
+
let hash = Hash.string("@effect-vfs/core/BytePath");
|
|
10
|
+
for (const byte of bytes) {
|
|
11
|
+
hash = Hash.combine(Hash.number(byte))(hash);
|
|
12
|
+
}
|
|
13
|
+
return Hash.combine(Hash.number(bytes.length))(hash);
|
|
14
|
+
};
|
|
15
|
+
const BytePathProto = {
|
|
16
|
+
[BytePathId]: BytePathId,
|
|
17
|
+
[Equal.symbol](that) {
|
|
18
|
+
if (!isBytePath(that))
|
|
19
|
+
return false;
|
|
20
|
+
const selfBytes = bytePaths.get(this);
|
|
21
|
+
const thatBytes = bytePaths.get(that);
|
|
22
|
+
if (selfBytes.length !== thatBytes.length)
|
|
23
|
+
return false;
|
|
24
|
+
for (let index = 0; index < selfBytes.length; index++) {
|
|
25
|
+
if (selfBytes[index] !== thatBytes[index])
|
|
26
|
+
return false;
|
|
27
|
+
}
|
|
28
|
+
return true;
|
|
29
|
+
},
|
|
30
|
+
[Hash.symbol]() {
|
|
31
|
+
return hashBytes(bytePaths.get(this));
|
|
32
|
+
},
|
|
33
|
+
pipe() {
|
|
34
|
+
return pipeArguments(this, arguments);
|
|
35
|
+
}
|
|
36
|
+
};
|
|
37
|
+
/** @internal */
|
|
38
|
+
export const isBytePath = (value) => typeof value === "object" && value !== null && bytePaths.has(value);
|
|
39
|
+
/** @internal */
|
|
40
|
+
export const make = (bytes) => {
|
|
41
|
+
const path = Object.create(BytePathProto);
|
|
42
|
+
bytePaths.set(path, bytes);
|
|
43
|
+
return Object.freeze(path);
|
|
44
|
+
};
|
|
45
|
+
/** @internal */
|
|
46
|
+
export const getBytes = (path) => bytePaths.get(path);
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
/**
|
|
1
|
+
/** @internal */
|
|
2
2
|
export declare const isCanonical: (value: string) => boolean;
|
|
3
|
-
/**
|
|
3
|
+
/** @internal */
|
|
4
4
|
export declare const decodedLength: (value: string) => number;
|
|
5
|
-
/**
|
|
5
|
+
/** @internal */
|
|
6
6
|
export declare const decodeTrusted: (value: string) => Uint8Array;
|
|
7
7
|
//# sourceMappingURL=canonicalBase64.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"canonicalBase64.d.ts","sourceRoot":"","sources":["../../src/internal/canonicalBase64.ts"],"names":[],"mappings":"AAKA,
|
|
1
|
+
{"version":3,"file":"canonicalBase64.d.ts","sourceRoot":"","sources":["../../src/internal/canonicalBase64.ts"],"names":[],"mappings":"AAKA,gBAAgB;AAChB,eAAO,MAAM,WAAW,UAAW,MAAM,KAAG,OAGP,CAAA;AAErC,gBAAgB;AAChB,eAAO,MAAM,aAAa,UAAW,MAAM,KAAG,MACmC,CAAA;AAEjF,gBAAgB;AAChB,eAAO,MAAM,aAAa,UAAW,MAAM,KAAG,UAC4D,CAAA"}
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import * as Encoding from "effect/Encoding";
|
|
2
2
|
import * as Result from "effect/Result";
|
|
3
3
|
const canonicalTail = /^(?:[A-Za-z0-9+/]{4}|[A-Za-z0-9+/][AQgw]==|[A-Za-z0-9+/]{2}[AEIMQUYcgkosw048]=)?(?![\s\S])/;
|
|
4
|
-
/**
|
|
4
|
+
/** @internal */
|
|
5
5
|
export const isCanonical = (value) => value.length % 4 === 0 &&
|
|
6
6
|
!/[^A-Za-z0-9+/]/.test(value.slice(0, -4)) &&
|
|
7
7
|
canonicalTail.test(value.slice(-4));
|
|
8
|
-
/**
|
|
8
|
+
/** @internal */
|
|
9
9
|
export const decodedLength = (value) => value.length / 4 * 3 - (value.endsWith("==") ? 2 : value.endsWith("=") ? 1 : 0);
|
|
10
|
-
/**
|
|
10
|
+
/** @internal */
|
|
11
11
|
export const decodeTrusted = (value) => Result.getOrThrowWith(Encoding.decodeBase64(value), () => new Error("Invalid trusted canonical base64"));
|
package/dist/internal/image.d.ts
CHANGED
|
@@ -1,8 +1,3 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Snapshot validation and serialization used by `VirtualFileSystem`.
|
|
3
|
-
*
|
|
4
|
-
* @internal
|
|
5
|
-
*/
|
|
6
1
|
import * as ByteSize from "effect/ByteSize";
|
|
7
2
|
import * as Effect from "effect/Effect";
|
|
8
3
|
import * as Schema from "effect/Schema";
|
|
@@ -10,9 +5,9 @@ import { ImageError, type Snapshot } from "../Snapshot.js";
|
|
|
10
5
|
import * as CanonicalBase64 from "./canonicalBase64.js";
|
|
11
6
|
/** @internal */
|
|
12
7
|
export declare const StoredMetadata: Schema.Struct<{
|
|
13
|
-
readonly uid: Schema.
|
|
14
|
-
readonly gid: Schema.
|
|
15
|
-
readonly mode: Schema.
|
|
8
|
+
readonly uid: Schema.Natural;
|
|
9
|
+
readonly gid: Schema.Natural;
|
|
10
|
+
readonly mode: Schema.Natural;
|
|
16
11
|
readonly atimeNs: Schema.String;
|
|
17
12
|
readonly mtimeNs: Schema.String;
|
|
18
13
|
readonly ctimeNs: Schema.String;
|
|
@@ -25,9 +20,9 @@ export declare const Record: Schema.Union<readonly [Schema.Struct<{
|
|
|
25
20
|
readonly id: Schema.String;
|
|
26
21
|
readonly kind: Schema.Literal<"directory">;
|
|
27
22
|
readonly metadata: Schema.Struct<{
|
|
28
|
-
readonly uid: Schema.
|
|
29
|
-
readonly gid: Schema.
|
|
30
|
-
readonly mode: Schema.
|
|
23
|
+
readonly uid: Schema.Natural;
|
|
24
|
+
readonly gid: Schema.Natural;
|
|
25
|
+
readonly mode: Schema.Natural;
|
|
31
26
|
readonly atimeNs: Schema.String;
|
|
32
27
|
readonly mtimeNs: Schema.String;
|
|
33
28
|
readonly ctimeNs: Schema.String;
|
|
@@ -41,9 +36,9 @@ export declare const Record: Schema.Union<readonly [Schema.Struct<{
|
|
|
41
36
|
readonly id: Schema.String;
|
|
42
37
|
readonly kind: Schema.Literal<"file">;
|
|
43
38
|
readonly metadata: Schema.Struct<{
|
|
44
|
-
readonly uid: Schema.
|
|
45
|
-
readonly gid: Schema.
|
|
46
|
-
readonly mode: Schema.
|
|
39
|
+
readonly uid: Schema.Natural;
|
|
40
|
+
readonly gid: Schema.Natural;
|
|
41
|
+
readonly mode: Schema.Natural;
|
|
47
42
|
readonly atimeNs: Schema.String;
|
|
48
43
|
readonly mtimeNs: Schema.String;
|
|
49
44
|
readonly ctimeNs: Schema.String;
|
|
@@ -54,9 +49,9 @@ export declare const Record: Schema.Union<readonly [Schema.Struct<{
|
|
|
54
49
|
readonly id: Schema.String;
|
|
55
50
|
readonly kind: Schema.Literal<"symlink">;
|
|
56
51
|
readonly metadata: Schema.Struct<{
|
|
57
|
-
readonly uid: Schema.
|
|
58
|
-
readonly gid: Schema.
|
|
59
|
-
readonly mode: Schema.
|
|
52
|
+
readonly uid: Schema.Natural;
|
|
53
|
+
readonly gid: Schema.Natural;
|
|
54
|
+
readonly mode: Schema.Natural;
|
|
60
55
|
readonly atimeNs: Schema.String;
|
|
61
56
|
readonly mtimeNs: Schema.String;
|
|
62
57
|
readonly ctimeNs: Schema.String;
|
|
@@ -75,9 +70,9 @@ export declare const Document: Schema.Struct<{
|
|
|
75
70
|
readonly id: Schema.String;
|
|
76
71
|
readonly kind: Schema.Literal<"directory">;
|
|
77
72
|
readonly metadata: Schema.Struct<{
|
|
78
|
-
readonly uid: Schema.
|
|
79
|
-
readonly gid: Schema.
|
|
80
|
-
readonly mode: Schema.
|
|
73
|
+
readonly uid: Schema.Natural;
|
|
74
|
+
readonly gid: Schema.Natural;
|
|
75
|
+
readonly mode: Schema.Natural;
|
|
81
76
|
readonly atimeNs: Schema.String;
|
|
82
77
|
readonly mtimeNs: Schema.String;
|
|
83
78
|
readonly ctimeNs: Schema.String;
|
|
@@ -91,9 +86,9 @@ export declare const Document: Schema.Struct<{
|
|
|
91
86
|
readonly id: Schema.String;
|
|
92
87
|
readonly kind: Schema.Literal<"file">;
|
|
93
88
|
readonly metadata: Schema.Struct<{
|
|
94
|
-
readonly uid: Schema.
|
|
95
|
-
readonly gid: Schema.
|
|
96
|
-
readonly mode: Schema.
|
|
89
|
+
readonly uid: Schema.Natural;
|
|
90
|
+
readonly gid: Schema.Natural;
|
|
91
|
+
readonly mode: Schema.Natural;
|
|
97
92
|
readonly atimeNs: Schema.String;
|
|
98
93
|
readonly mtimeNs: Schema.String;
|
|
99
94
|
readonly ctimeNs: Schema.String;
|
|
@@ -104,9 +99,9 @@ export declare const Document: Schema.Struct<{
|
|
|
104
99
|
readonly id: Schema.String;
|
|
105
100
|
readonly kind: Schema.Literal<"symlink">;
|
|
106
101
|
readonly metadata: Schema.Struct<{
|
|
107
|
-
readonly uid: Schema.
|
|
108
|
-
readonly gid: Schema.
|
|
109
|
-
readonly mode: Schema.
|
|
102
|
+
readonly uid: Schema.Natural;
|
|
103
|
+
readonly gid: Schema.Natural;
|
|
104
|
+
readonly mode: Schema.Natural;
|
|
110
105
|
readonly atimeNs: Schema.String;
|
|
111
106
|
readonly mtimeNs: Schema.String;
|
|
112
107
|
readonly ctimeNs: Schema.String;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"image.d.ts","sourceRoot":"","sources":["../../src/internal/image.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"image.d.ts","sourceRoot":"","sources":["../../src/internal/image.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,EAAgB,UAAU,EAAE,KAAK,QAAQ,EAAkB,MAAM,gBAAgB,CAAA;AACxF,OAAO,KAAK,eAAe,MAAM,sBAAsB,CAAA;AAQvD,gBAAgB;AAChB,eAAO,MAAM,cAAc;;;;;;;;EAQzB,CAAA;AAEF,gBAAgB;AAChB,MAAM,MAAM,cAAc,GAAG,OAAO,cAAc,CAAC,IAAI,CAAA;AAIvD,gBAAgB;AAChB,eAAO,MAAM,MAAM;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;IASjB,CAAA;AAEF,gBAAgB;AAChB,MAAM,MAAM,MAAM,GAAG,OAAO,MAAM,CAAC,IAAI,CAAA;AAEvC,gBAAgB;AAChB,eAAO,MAAM,QAAQ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAKnB,CAAA;AAEF,gBAAgB;AAChB,MAAM,MAAM,QAAQ,GAAG,OAAO,QAAQ,CAAC,IAAI,CAAA;AAI3C,gBAAgB;AAChB,eAAO,MAAM,aAAa,sCAAgC,CAAA;AAE1D,gBAAgB;AAChB,eAAO,MAAM,MAAM,UAAW,UAAU,KAAG,MAU1C,CAAA;AAKD,gBAAgB;AAChB,eAAO,MAAM,KAAK,UAAW,MAAM,KAAG,UAErC,CAAA;AAED,gBAAgB;AAChB,eAAO,MAAM,OAAO,aAAc,QAAQ,KAAG,MAAM,CAAC,MAAM,CAAC,QAAQ,EAAE,UAAU,CAI3E,CAAA;AAEJ,gBAAgB;AAChB,eAAO,MAAM,OAAO;;;;;4DAwElB,CAAA;AAEF,gBAAgB;AAChB,eAAO,MAAM,cAAc,mFAKzB,CAAA;AAEF,gBAAgB;AAChB,eAAO,MAAM,cAAc;;;;;gDAqB1B,CAAA"}
|
package/dist/internal/image.js
CHANGED
|
@@ -1,8 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
* Snapshot validation and serialization used by `VirtualFileSystem`.
|
|
3
|
-
*
|
|
4
|
-
* @internal
|
|
5
|
-
*/
|
|
1
|
+
// Snapshot validation and serialization used by VirtualFileSystem.
|
|
6
2
|
import * as ByteSize from "effect/ByteSize";
|
|
7
3
|
import * as Effect from "effect/Effect";
|
|
8
4
|
import * as Encoding from "effect/Encoding";
|
|
@@ -10,16 +6,15 @@ import * as Result from "effect/Result";
|
|
|
10
6
|
import * as Schema from "effect/Schema";
|
|
11
7
|
import { DecodeLimits, ImageError, SnapshotTypeId } from "../Snapshot.js";
|
|
12
8
|
import * as CanonicalBase64 from "./canonicalBase64.js";
|
|
13
|
-
const natural = Schema.Finite.check(Schema.isInt(), Schema.isGreaterThanOrEqualTo(0), Schema.isLessThanOrEqualTo(Number.MAX_SAFE_INTEGER));
|
|
14
9
|
class SnapshotImpl {
|
|
15
10
|
[SnapshotTypeId] = SnapshotTypeId;
|
|
16
11
|
}
|
|
17
12
|
const integer = Schema.String.check(Schema.isPattern(/^(?:0|-?[1-9][0-9]{0,127})(?![\s\S])/));
|
|
18
13
|
/** @internal */
|
|
19
14
|
export const StoredMetadata = Schema.Struct({
|
|
20
|
-
uid:
|
|
21
|
-
gid:
|
|
22
|
-
mode:
|
|
15
|
+
uid: Schema.Natural,
|
|
16
|
+
gid: Schema.Natural,
|
|
17
|
+
mode: Schema.Natural.check(Schema.isLessThanOrEqualTo(0o7777)),
|
|
23
18
|
atimeNs: integer,
|
|
24
19
|
mtimeNs: integer,
|
|
25
20
|
ctimeNs: integer,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"snapshotDelta.d.ts","sourceRoot":"","sources":["../../src/internal/snapshotDelta.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"snapshotDelta.d.ts","sourceRoot":"","sources":["../../src/internal/snapshotDelta.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,QAAQ,MAAM,iBAAiB,CAAA;AAC3C,OAAO,KAAK,MAAM,MAAM,eAAe,CAAA;AACvC,OAAO,KAAK,MAAM,MAAM,eAAe,CAAA;AAKvC,OAAO,EAAE,UAAU,EAAE,KAAK,QAAQ,EAAE,MAAM,gBAAgB,CAAA;AAC1D,OAAO,EAGL,KAAK,aAAa,EAClB,kBAAkB,EAInB,MAAM,qBAAqB,CAAA;AA6e5B,gBAAgB;AAChB,eAAO,MAAM,aAAa;;;;;;;;;;;4GAgDzB,CAAA;AAyBD,gBAAgB;AAChB,eAAO,MAAM,oBAAoB;;;;;;;;;;;;;;;;;;;;;;;;;;;oGAgBhC,CAAA;AAED,gBAAgB;AAChB,eAAO,MAAM,mBAAmB;;;;;;;;;;;+DAS9B,CAAA;AAEF,gBAAgB;AAChB,eAAO,MAAM,mBAAmB;;;;;;;;;;;qDAkB9B,CAAA;AAEF,gBAAgB;AAChB,eAAO,MAAM,kBAAkB;;;;;;;;;;;4HAI9B,CAAA"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
// Exact snapshot delta construction, inspection, serialization, and application.
|
|
2
2
|
import * as ByteSize from "effect/ByteSize";
|
|
3
3
|
import * as Crypto from "effect/Crypto";
|
|
4
4
|
import * as Effect from "effect/Effect";
|
|
@@ -6,11 +6,12 @@ import * as Encoding from "effect/Encoding";
|
|
|
6
6
|
import * as Equal from "effect/Equal";
|
|
7
7
|
import * as Result from "effect/Result";
|
|
8
8
|
import * as Schema from "effect/Schema";
|
|
9
|
-
import { make as makeBytePath } from "../BytePath.js";
|
|
10
9
|
import { ImageError } from "../Snapshot.js";
|
|
11
|
-
import {
|
|
10
|
+
import { SnapshotDeltaError, SnapshotDifference, SnapshotNodeKind } from "../SnapshotDelta.js";
|
|
11
|
+
import { make as makeBytePath } from "./bytePath.js";
|
|
12
12
|
import * as CanonicalBase64 from "./canonicalBase64.js";
|
|
13
13
|
import * as Image from "./image.js";
|
|
14
|
+
import * as SnapshotDeltaModel from "./snapshotDeltaModel.js";
|
|
14
15
|
const Path = Schema.String;
|
|
15
16
|
const Payload = Schema.Union([
|
|
16
17
|
Schema.TaggedStruct("Inline", { bytes: Schema.String }),
|
|
@@ -31,28 +32,14 @@ const Record = Schema.Union([
|
|
|
31
32
|
payload: Payload
|
|
32
33
|
})
|
|
33
34
|
]);
|
|
34
|
-
const Kind = Schema.Literals(["directory", "file", "symlink"]);
|
|
35
|
-
const Difference = Schema.Literals([
|
|
36
|
-
"kind",
|
|
37
|
-
"content",
|
|
38
|
-
"target",
|
|
39
|
-
"hardLinks",
|
|
40
|
-
"mode",
|
|
41
|
-
"uid",
|
|
42
|
-
"gid",
|
|
43
|
-
"atimeNs",
|
|
44
|
-
"mtimeNs",
|
|
45
|
-
"ctimeNs",
|
|
46
|
-
"birthtimeNs"
|
|
47
|
-
]);
|
|
48
35
|
const Change = Schema.Union([
|
|
49
|
-
Schema.TaggedStruct("Added", { path: Path, kind:
|
|
50
|
-
Schema.TaggedStruct("Removed", { path: Path, kind:
|
|
36
|
+
Schema.TaggedStruct("Added", { path: Path, kind: SnapshotNodeKind }),
|
|
37
|
+
Schema.TaggedStruct("Removed", { path: Path, kind: SnapshotNodeKind }),
|
|
51
38
|
Schema.TaggedStruct("Updated", {
|
|
52
39
|
path: Path,
|
|
53
|
-
beforeKind:
|
|
54
|
-
afterKind:
|
|
55
|
-
differences: Schema.Array(
|
|
40
|
+
beforeKind: SnapshotNodeKind,
|
|
41
|
+
afterKind: SnapshotNodeKind,
|
|
42
|
+
differences: Schema.Array(SnapshotDifference).check(Schema.isMinLength(1))
|
|
56
43
|
})
|
|
57
44
|
]);
|
|
58
45
|
const Document = Schema.Struct({
|
|
@@ -325,7 +312,7 @@ const compare = (base, target) => {
|
|
|
325
312
|
return changes.map(({ change }) => change);
|
|
326
313
|
};
|
|
327
314
|
const getDocument = (delta) => Effect.suspend(() => {
|
|
328
|
-
const value =
|
|
315
|
+
const value = SnapshotDeltaModel.value(delta);
|
|
329
316
|
return value !== undefined && Schema.is(Document)(value)
|
|
330
317
|
? Effect.succeed(value)
|
|
331
318
|
: Effect.fail(failure("InvalidStructure", "delta"));
|
|
@@ -471,7 +458,7 @@ const validate = Effect.fnUntraced(function* (document, limits) {
|
|
|
471
458
|
yield* buildImage(document, undefined, limits);
|
|
472
459
|
});
|
|
473
460
|
/** @internal */
|
|
474
|
-
export const diffSnapshots = Effect.
|
|
461
|
+
export const diffSnapshots = Effect.fnUntraced(function* (base, target, limits) {
|
|
475
462
|
const before = yield* normalize(base, limits, "base");
|
|
476
463
|
const after = yield* normalize(target, limits, "target");
|
|
477
464
|
const changes = [...compare(before, after)];
|
|
@@ -518,7 +505,7 @@ export const diffSnapshots = Effect.fn("VirtualFileSystem.diffSnapshots")(functi
|
|
|
518
505
|
changes
|
|
519
506
|
};
|
|
520
507
|
yield* validate(document, limits);
|
|
521
|
-
return
|
|
508
|
+
return SnapshotDeltaModel.make(document);
|
|
522
509
|
});
|
|
523
510
|
/** @internal */
|
|
524
511
|
const verify = Effect.fnUntraced(function* (base, document, limits) {
|
|
@@ -536,7 +523,7 @@ const verify = Effect.fnUntraced(function* (base, document, limits) {
|
|
|
536
523
|
return { changes, target };
|
|
537
524
|
});
|
|
538
525
|
/** @internal */
|
|
539
|
-
export const inspectSnapshotDelta = Effect.
|
|
526
|
+
export const inspectSnapshotDelta = Effect.fnUntraced(function* (base, delta, options, limits) {
|
|
540
527
|
const output = [];
|
|
541
528
|
const { changes } = yield* verify(base, yield* getDocument(delta), limits);
|
|
542
529
|
for (const change of changes) {
|
|
@@ -581,9 +568,9 @@ export const decodeSnapshotDelta = Effect.fnUntraced(function* (input, limits) {
|
|
|
581
568
|
if (Result.isFailure(parsed))
|
|
582
569
|
return yield* failure("InvalidStructure");
|
|
583
570
|
yield* validate(parsed.success, limits);
|
|
584
|
-
return
|
|
571
|
+
return SnapshotDeltaModel.make(parsed.success);
|
|
585
572
|
});
|
|
586
573
|
/** @internal */
|
|
587
|
-
export const applySnapshotDelta = Effect.
|
|
574
|
+
export const applySnapshotDelta = Effect.fnUntraced(function* (base, delta, limits) {
|
|
588
575
|
return (yield* verify(base, yield* getDocument(delta), limits)).target;
|
|
589
576
|
});
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { SnapshotDelta } from "../SnapshotDelta.js";
|
|
2
|
+
/** @internal */
|
|
3
|
+
export declare const SnapshotDeltaTypeId: "@effect-vfs/core/SnapshotDelta";
|
|
4
|
+
/** @internal */
|
|
5
|
+
export declare const make: (value: object) => SnapshotDelta;
|
|
6
|
+
/** @internal */
|
|
7
|
+
export declare const value: (delta: SnapshotDelta) => object | undefined;
|
|
8
|
+
/** @internal */
|
|
9
|
+
export declare const isSnapshotDelta: (input: unknown) => input is SnapshotDelta;
|
|
10
|
+
//# sourceMappingURL=snapshotDeltaModel.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"snapshotDeltaModel.d.ts","sourceRoot":"","sources":["../../src/internal/snapshotDeltaModel.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAA;AAExD,gBAAgB;AAChB,eAAO,MAAM,mBAAmB,EAAG,gCAAyC,CAAA;AAI5E,gBAAgB;AAChB,eAAO,MAAM,IAAI,UAAW,MAAM,KAAG,aAIpC,CAAA;AAED,gBAAgB;AAChB,eAAO,MAAM,KAAK,UAAW,aAAa,KAAG,MAAM,GAAG,SAAsC,CAAA;AAE5F,gBAAgB;AAChB,eAAO,MAAM,eAAe,UAAW,OAAO,KAAG,KAAK,IAAI,aACiC,CAAA"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/** @internal */
|
|
2
|
+
export const SnapshotDeltaTypeId = "@effect-vfs/core/SnapshotDelta";
|
|
3
|
+
const snapshotDeltas = new WeakMap();
|
|
4
|
+
/** @internal */
|
|
5
|
+
export const make = (value) => {
|
|
6
|
+
const delta = Object.freeze({ [SnapshotDeltaTypeId]: SnapshotDeltaTypeId });
|
|
7
|
+
snapshotDeltas.set(delta, value);
|
|
8
|
+
return delta;
|
|
9
|
+
};
|
|
10
|
+
/** @internal */
|
|
11
|
+
export const value = (delta) => snapshotDeltas.get(delta);
|
|
12
|
+
/** @internal */
|
|
13
|
+
export const isSnapshotDelta = (input) => typeof input === "object" && input !== null && snapshotDeltas.has(input);
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import * as Schema from "effect/Schema";
|
|
2
|
+
import type { PathInput } from "../../VirtualFileSystem.js";
|
|
3
|
+
/** @internal */
|
|
4
|
+
export declare const FsCode: Schema.Literals<readonly ["NotFound", "AlreadyExists", "NotEmpty", "NotDirectory", "AccessDenied", "InvalidHandle", "ForeignHandle", "InvalidReference", "ForeignReference", "StaleReference", "ClosedCaller", "InvalidArgument", "InvalidPathEncoding", "PathTooLong", "NoSpace", "IsDirectory", "FileTooLarge", "NoData", "SymlinkLoop", "UnrepresentableName"]>;
|
|
5
|
+
/** @internal */
|
|
6
|
+
export type FsCode = typeof FsCode.Type;
|
|
7
|
+
declare const FsError_base: new <A extends Record<string, any> = {}>(args: import("effect/Types").VoidIfEmpty<{ readonly [P in keyof A as P extends "_tag" ? never : P]: A[P]; }>) => import("effect/Cause").YieldableError & {
|
|
8
|
+
readonly _tag: "FsError";
|
|
9
|
+
} & Readonly<A>;
|
|
10
|
+
/** @internal */
|
|
11
|
+
export declare class FsError extends FsError_base<{
|
|
12
|
+
readonly code: FsCode;
|
|
13
|
+
readonly operation: string;
|
|
14
|
+
readonly path?: PathInput;
|
|
15
|
+
}> {
|
|
16
|
+
}
|
|
17
|
+
declare const ConfigurationError_base: new <A extends Record<string, any> = {}>(args: import("effect/Types").VoidIfEmpty<{ readonly [P in keyof A as P extends "_tag" ? never : P]: A[P]; }>) => import("effect/Cause").YieldableError & {
|
|
18
|
+
readonly _tag: "ConfigurationError";
|
|
19
|
+
} & Readonly<A>;
|
|
20
|
+
/** @internal */
|
|
21
|
+
export declare class ConfigurationError extends ConfigurationError_base<{
|
|
22
|
+
readonly field: string;
|
|
23
|
+
}> {
|
|
24
|
+
}
|
|
25
|
+
export {};
|
|
26
|
+
//# sourceMappingURL=errors.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../../../src/internal/virtualFileSystem/errors.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,MAAM,MAAM,eAAe,CAAA;AACvC,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,4BAA4B,CAAA;AAE3D,gBAAgB;AAChB,eAAO,MAAM,MAAM,oWAqBjB,CAAA;AAEF,gBAAgB;AAChB,MAAM,MAAM,MAAM,GAAG,OAAO,MAAM,CAAC,IAAI,CAAA;;;;AAEvC,gBAAgB;AAChB,qBAAa,OAAQ,SAAQ,aAA4B;IACvD,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAA;IACrB,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAA;IAC1B,QAAQ,CAAC,IAAI,CAAC,EAAE,SAAS,CAAA;CAC1B,CAAC;CAAG;;;;AAEL,gBAAgB;AAChB,qBAAa,kBAAmB,SAAQ,wBAAuC;IAC7E,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAA;CACvB,CAAC;CAAG"}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
// Virtual filesystem failure schemas and identities shared by the runtime implementation.
|
|
2
|
+
import * as Data from "effect/Data";
|
|
3
|
+
import * as Schema from "effect/Schema";
|
|
4
|
+
/** @internal */
|
|
5
|
+
export const FsCode = Schema.Literals([
|
|
6
|
+
"NotFound",
|
|
7
|
+
"AlreadyExists",
|
|
8
|
+
"NotEmpty",
|
|
9
|
+
"NotDirectory",
|
|
10
|
+
"AccessDenied",
|
|
11
|
+
"InvalidHandle",
|
|
12
|
+
"ForeignHandle",
|
|
13
|
+
"InvalidReference",
|
|
14
|
+
"ForeignReference",
|
|
15
|
+
"StaleReference",
|
|
16
|
+
"ClosedCaller",
|
|
17
|
+
"InvalidArgument",
|
|
18
|
+
"InvalidPathEncoding",
|
|
19
|
+
"PathTooLong",
|
|
20
|
+
"NoSpace",
|
|
21
|
+
"IsDirectory",
|
|
22
|
+
"FileTooLarge",
|
|
23
|
+
"NoData",
|
|
24
|
+
"SymlinkLoop",
|
|
25
|
+
"UnrepresentableName"
|
|
26
|
+
]);
|
|
27
|
+
/** @internal */
|
|
28
|
+
export class FsError extends Data.TaggedError("FsError") {
|
|
29
|
+
}
|
|
30
|
+
/** @internal */
|
|
31
|
+
export class ConfigurationError extends Data.TaggedError("ConfigurationError") {
|
|
32
|
+
}
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import * as Effect from "effect/Effect";
|
|
2
|
+
import { ImageError } from "../../Snapshot.js";
|
|
3
|
+
/** @internal */
|
|
4
|
+
export declare const fromFixture: (fixture: {
|
|
5
|
+
readonly rootMetadata?: {
|
|
6
|
+
readonly uid?: number;
|
|
7
|
+
readonly gid?: number;
|
|
8
|
+
readonly mode?: number;
|
|
9
|
+
readonly atimeNs?: bigint;
|
|
10
|
+
readonly mtimeNs?: bigint;
|
|
11
|
+
readonly ctimeNs?: bigint;
|
|
12
|
+
readonly birthtimeNs?: bigint;
|
|
13
|
+
};
|
|
14
|
+
readonly entries: readonly ({
|
|
15
|
+
readonly kind: "directory";
|
|
16
|
+
readonly path: string | import("../../BytePath.js").BytePath;
|
|
17
|
+
readonly metadata?: {
|
|
18
|
+
readonly uid?: number;
|
|
19
|
+
readonly gid?: number;
|
|
20
|
+
readonly mode?: number;
|
|
21
|
+
readonly atimeNs?: bigint;
|
|
22
|
+
readonly mtimeNs?: bigint;
|
|
23
|
+
readonly ctimeNs?: bigint;
|
|
24
|
+
readonly birthtimeNs?: bigint;
|
|
25
|
+
};
|
|
26
|
+
} | {
|
|
27
|
+
readonly kind: "file";
|
|
28
|
+
readonly path: string | import("../../BytePath.js").BytePath;
|
|
29
|
+
readonly bytes: Uint8Array<ArrayBufferLike>;
|
|
30
|
+
readonly metadata?: {
|
|
31
|
+
readonly uid?: number;
|
|
32
|
+
readonly gid?: number;
|
|
33
|
+
readonly mode?: number;
|
|
34
|
+
readonly atimeNs?: bigint;
|
|
35
|
+
readonly mtimeNs?: bigint;
|
|
36
|
+
readonly ctimeNs?: bigint;
|
|
37
|
+
readonly birthtimeNs?: bigint;
|
|
38
|
+
};
|
|
39
|
+
} | {
|
|
40
|
+
readonly kind: "symlink";
|
|
41
|
+
readonly path: string | import("../../BytePath.js").BytePath;
|
|
42
|
+
readonly target: string | import("../../BytePath.js").BytePath;
|
|
43
|
+
readonly metadata?: {
|
|
44
|
+
readonly uid?: number;
|
|
45
|
+
readonly gid?: number;
|
|
46
|
+
readonly mode?: number;
|
|
47
|
+
readonly atimeNs?: bigint;
|
|
48
|
+
readonly mtimeNs?: bigint;
|
|
49
|
+
readonly ctimeNs?: bigint;
|
|
50
|
+
readonly birthtimeNs?: bigint;
|
|
51
|
+
};
|
|
52
|
+
} | {
|
|
53
|
+
readonly kind: "hardLink";
|
|
54
|
+
readonly path: string | import("../../BytePath.js").BytePath;
|
|
55
|
+
readonly target: string | import("../../BytePath.js").BytePath;
|
|
56
|
+
})[];
|
|
57
|
+
}, options?: {
|
|
58
|
+
readonly maxEntries?: number;
|
|
59
|
+
readonly maxBytes?: import("effect/ByteSize").ByteSize;
|
|
60
|
+
readonly maxFileBytes?: import("effect/ByteSize").ByteSize;
|
|
61
|
+
readonly maxPathBytes?: import("effect/ByteSize").ByteSize;
|
|
62
|
+
} | undefined) => Effect.Effect<import("../../VirtualFileSystem.js").Volume, import("./errors.js").ConfigurationError | ImageError, never>;
|
|
63
|
+
//# sourceMappingURL=fixture.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
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;AAY9C,gBAAgB;AAChB,eAAO,MAAM,WAAW;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;0IAuIvB,CAAA"}
|