dirvi-lib 0.6.1 → 0.7.1
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/index.d.ts +0 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +0 -2
- package/dist/tree-surfer/cursor.d.ts +9 -0
- package/dist/tree-surfer/cursor.d.ts.map +1 -1
- package/dist/tree-surfer/cursor.js +15 -0
- package/dist/tree-surfer/fold-node/fold-node.schema.d.ts +8 -0
- package/dist/tree-surfer/fold-node/fold-node.schema.d.ts.map +1 -0
- package/dist/tree-surfer/fold-node/fold-node.schema.js +16 -0
- package/dist/tree-surfer/fold-node/fold-node.types.d.ts +7 -7
- package/dist/tree-surfer/fold-node/fold-node.types.d.ts.map +1 -1
- package/dist/tree-surfer/index.d.ts +5 -1
- package/dist/tree-surfer/index.d.ts.map +1 -1
- package/dist/tree-surfer/index.js +5 -1
- package/dist/tree-surfer/state/state.impl.d.ts +7 -0
- package/dist/tree-surfer/state/state.impl.d.ts.map +1 -0
- package/dist/tree-surfer/{state.js → state/state.impl.js} +13 -31
- package/dist/tree-surfer/state/state.schemas.d.ts +9 -0
- package/dist/tree-surfer/state/state.schemas.d.ts.map +1 -0
- package/dist/tree-surfer/state/state.schemas.js +8 -0
- package/dist/tree-surfer/state/state.types.d.ts +17 -0
- package/dist/tree-surfer/state/state.types.d.ts.map +1 -0
- package/dist/tree-surfer/state/state.types.js +1 -0
- package/dist/tree-surfer/tree-node/tree-node.arb.d.ts +82 -13
- package/dist/tree-surfer/tree-node/tree-node.arb.d.ts.map +1 -1
- package/dist/tree-surfer/tree-node/tree-node.arb.debug.d.ts +2 -0
- package/dist/tree-surfer/tree-node/tree-node.arb.debug.d.ts.map +1 -0
- package/dist/tree-surfer/tree-node/tree-node.arb.debug.js +34 -0
- package/dist/tree-surfer/tree-node/tree-node.arb.js +163 -50
- package/dist/tree-surfer/tree-node/tree-node.schemas.d.ts +32 -0
- package/dist/tree-surfer/tree-node/tree-node.schemas.d.ts.map +1 -0
- package/dist/tree-surfer/tree-node/tree-node.schemas.js +35 -0
- package/dist/tree-surfer/tree-node/tree-node.test.js +138 -65
- package/dist/tree-surfer/tree-node/tree-node.types.d.ts +91 -118
- package/dist/tree-surfer/tree-node/tree-node.types.d.ts.map +1 -1
- package/dist/tree-surfer/tree-node/tree-node.types.js +1 -12
- package/dist/tree-surfer-ui/application/intent-to-effect.d.ts +1 -1
- package/dist/tree-surfer-ui/application/intent-to-effect.d.ts.map +1 -1
- package/dist/tree-surfer-ui/application/intent-to-effect.js +9 -13
- package/dist/tree-surfer-ui/application/parse-command.d.ts +4 -0
- package/dist/tree-surfer-ui/application/parse-command.d.ts.map +1 -0
- package/dist/tree-surfer-ui/application/parse-command.js +48 -0
- package/dist/tree-surfer-ui/domain/effect.d.ts +10 -0
- package/dist/tree-surfer-ui/domain/effect.d.ts.map +1 -1
- package/package.json +3 -2
- package/dist/domain/posix-node.d.ts +0 -29
- package/dist/domain/posix-node.d.ts.map +0 -1
- package/dist/domain/posix-node.js +0 -20
- package/dist/domain/unix-path.d.ts +0 -6
- package/dist/domain/unix-path.d.ts.map +0 -1
- package/dist/domain/unix-path.js +0 -11
- package/dist/tree-surfer/state.d.ts +0 -19
- package/dist/tree-surfer/state.d.ts.map +0 -1
package/dist/index.d.ts
CHANGED
|
@@ -5,6 +5,4 @@ export * from './tree-surfer-ui/domain/input-state.js';
|
|
|
5
5
|
export * from './tree-surfer-ui/domain/intent.js';
|
|
6
6
|
export * from './tree-surfer-ui/domain/user-input.js';
|
|
7
7
|
export * from './tree-surfer/index.js';
|
|
8
|
-
export * from './domain/posix-node.js';
|
|
9
|
-
export * from './domain/unix-path.js';
|
|
10
8
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,sDAAsD,CAAC;AACrE,cAAc,kDAAkD,CAAC;AAEjE,cAAc,mCAAmC,CAAC;AAClD,cAAc,wCAAwC,CAAC;AACvD,cAAc,mCAAmC,CAAC;AAClD,cAAc,uCAAuC,CAAC;AAEtD,cAAc,wBAAwB,CAAC
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,sDAAsD,CAAC;AACrE,cAAc,kDAAkD,CAAC;AAEjE,cAAc,mCAAmC,CAAC;AAClD,cAAc,wCAAwC,CAAC;AACvD,cAAc,mCAAmC,CAAC;AAClD,cAAc,uCAAuC,CAAC;AAEtD,cAAc,wBAAwB,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -5,5 +5,3 @@ export * from './tree-surfer-ui/domain/input-state.js';
|
|
|
5
5
|
export * from './tree-surfer-ui/domain/intent.js';
|
|
6
6
|
export * from './tree-surfer-ui/domain/user-input.js';
|
|
7
7
|
export * from './tree-surfer/index.js';
|
|
8
|
-
export * from './domain/posix-node.js';
|
|
9
|
-
export * from './domain/unix-path.js';
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
1
2
|
export declare const CursorKind: {
|
|
2
3
|
readonly Entry: "entry";
|
|
3
4
|
readonly Fold: "fold";
|
|
@@ -13,6 +14,14 @@ export type CursorFold<Id> = {
|
|
|
13
14
|
parentPath: readonly Id[];
|
|
14
15
|
};
|
|
15
16
|
export type Cursor<Id> = CursorEntry<Id> | CursorFold<Id>;
|
|
17
|
+
export declare function createCursorSchema<IdSchema extends z.ZodTypeAny>(idSchema: IdSchema): z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
18
|
+
kind: z.ZodLiteral<"entry">;
|
|
19
|
+
parentPath: z.ZodArray<IdSchema>;
|
|
20
|
+
entryId: IdSchema;
|
|
21
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
22
|
+
kind: z.ZodLiteral<"fold">;
|
|
23
|
+
parentPath: z.ZodArray<IdSchema>;
|
|
24
|
+
}, z.core.$strip>], "kind">;
|
|
16
25
|
export type CursorApi<Id> = {
|
|
17
26
|
isEntry(cursor: Cursor<Id>): cursor is CursorEntry<Id>;
|
|
18
27
|
isFold(cursor: Cursor<Id>): cursor is CursorFold<Id>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cursor.d.ts","sourceRoot":"","sources":["../../src/tree-surfer/cursor.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,UAAU;;;CAGb,CAAC;AAEX,MAAM,MAAM,UAAU,GAAG,CAAC,OAAO,UAAU,CAAC,CAAC,MAAM,OAAO,UAAU,CAAC,CAAC;AAEtE,MAAM,MAAM,WAAW,CAAC,EAAE,IAAI;IAC5B,IAAI,EAAE,OAAO,UAAU,CAAC,KAAK,CAAC;IAC9B,UAAU,EAAE,SAAS,EAAE,EAAE,CAAC;IAC1B,OAAO,EAAE,EAAE,CAAC;CACb,CAAC;AAEF,MAAM,MAAM,UAAU,CAAC,EAAE,IAAI;IAC3B,IAAI,EAAE,OAAO,UAAU,CAAC,IAAI,CAAC;IAC7B,UAAU,EAAE,SAAS,EAAE,EAAE,CAAC;CAC3B,CAAC;AAEF,MAAM,MAAM,MAAM,CAAC,EAAE,IAAI,WAAW,CAAC,EAAE,CAAC,GAAG,UAAU,CAAC,EAAE,CAAC,CAAC;AAE1D,MAAM,MAAM,SAAS,CAAC,EAAE,IAAI;IAC1B,OAAO,CAAC,MAAM,EAAE,MAAM,CAAC,EAAE,CAAC,GAAG,MAAM,IAAI,WAAW,CAAC,EAAE,CAAC,CAAC;IAEvD,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,EAAE,CAAC,GAAG,MAAM,IAAI,UAAU,CAAC,EAAE,CAAC,CAAC;IAErD,KAAK,CAAC,IAAI,EAAE,MAAM,CAAC,EAAE,CAAC,EAAE,KAAK,EAAE,MAAM,CAAC,EAAE,CAAC,GAAG,OAAO,CAAC;IAEpD,OAAO,CAAC,MAAM,EAAE,MAAM,CAAC,EAAE,CAAC,GAAG,EAAE,EAAE,GAAG,SAAS,CAAC;IAE9C,sBAAsB,CAAC,MAAM,EAAE,MAAM,CAAC,EAAE,CAAC,EAAE,SAAS,EAAE,SAAS,EAAE,EAAE,GAAG,OAAO,CAAC;CAC/E,CAAC;AAEF,wBAAgB,eAAe,CAAC,EAAE,KAAK,SAAS,CAAC,EAAE,CAAC,CA0CnD"}
|
|
1
|
+
{"version":3,"file":"cursor.d.ts","sourceRoot":"","sources":["../../src/tree-surfer/cursor.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,eAAO,MAAM,UAAU;;;CAGb,CAAC;AAEX,MAAM,MAAM,UAAU,GAAG,CAAC,OAAO,UAAU,CAAC,CAAC,MAAM,OAAO,UAAU,CAAC,CAAC;AAEtE,MAAM,MAAM,WAAW,CAAC,EAAE,IAAI;IAC5B,IAAI,EAAE,OAAO,UAAU,CAAC,KAAK,CAAC;IAC9B,UAAU,EAAE,SAAS,EAAE,EAAE,CAAC;IAC1B,OAAO,EAAE,EAAE,CAAC;CACb,CAAC;AAEF,MAAM,MAAM,UAAU,CAAC,EAAE,IAAI;IAC3B,IAAI,EAAE,OAAO,UAAU,CAAC,IAAI,CAAC;IAC7B,UAAU,EAAE,SAAS,EAAE,EAAE,CAAC;CAC3B,CAAC;AAEF,MAAM,MAAM,MAAM,CAAC,EAAE,IAAI,WAAW,CAAC,EAAE,CAAC,GAAG,UAAU,CAAC,EAAE,CAAC,CAAC;AAE1D,wBAAgB,kBAAkB,CAAC,QAAQ,SAAS,CAAC,CAAC,UAAU,EAC9D,QAAQ,EAAE,QAAQ;;;;;;;4BAgBnB;AAED,MAAM,MAAM,SAAS,CAAC,EAAE,IAAI;IAC1B,OAAO,CAAC,MAAM,EAAE,MAAM,CAAC,EAAE,CAAC,GAAG,MAAM,IAAI,WAAW,CAAC,EAAE,CAAC,CAAC;IAEvD,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,EAAE,CAAC,GAAG,MAAM,IAAI,UAAU,CAAC,EAAE,CAAC,CAAC;IAErD,KAAK,CAAC,IAAI,EAAE,MAAM,CAAC,EAAE,CAAC,EAAE,KAAK,EAAE,MAAM,CAAC,EAAE,CAAC,GAAG,OAAO,CAAC;IAEpD,OAAO,CAAC,MAAM,EAAE,MAAM,CAAC,EAAE,CAAC,GAAG,EAAE,EAAE,GAAG,SAAS,CAAC;IAE9C,sBAAsB,CAAC,MAAM,EAAE,MAAM,CAAC,EAAE,CAAC,EAAE,SAAS,EAAE,SAAS,EAAE,EAAE,GAAG,OAAO,CAAC;CAC/E,CAAC;AAEF,wBAAgB,eAAe,CAAC,EAAE,KAAK,SAAS,CAAC,EAAE,CAAC,CA0CnD"}
|
|
@@ -1,7 +1,22 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
1
2
|
export const CursorKind = {
|
|
2
3
|
Entry: 'entry',
|
|
3
4
|
Fold: 'fold',
|
|
4
5
|
};
|
|
6
|
+
export function createCursorSchema(idSchema) {
|
|
7
|
+
const parentPathSchema = z.array(idSchema);
|
|
8
|
+
return z.discriminatedUnion('kind', [
|
|
9
|
+
z.object({
|
|
10
|
+
kind: z.literal(CursorKind.Entry),
|
|
11
|
+
parentPath: parentPathSchema,
|
|
12
|
+
entryId: idSchema,
|
|
13
|
+
}),
|
|
14
|
+
z.object({
|
|
15
|
+
kind: z.literal(CursorKind.Fold),
|
|
16
|
+
parentPath: parentPathSchema,
|
|
17
|
+
}),
|
|
18
|
+
]);
|
|
19
|
+
}
|
|
5
20
|
export function createCursorApi() {
|
|
6
21
|
const cursorApi = {
|
|
7
22
|
isEntry(cursor) {
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import type { FoldNode, FoldNodeRoot } from './fold-node.types.js';
|
|
3
|
+
import { SerializableKey } from '../tree-node/tree-node.types.js';
|
|
4
|
+
export declare function createFoldNodeSchemas<Id extends SerializableKey>(idSchema: z.ZodType<Id>): {
|
|
5
|
+
foldNodeSchema: z.ZodType<FoldNode<Id>, unknown, z.core.$ZodTypeInternals<FoldNode<Id>, unknown>>;
|
|
6
|
+
foldNodeRootSchema: z.ZodType<FoldNodeRoot<Id>, unknown, z.core.$ZodTypeInternals<FoldNodeRoot<Id>, unknown>>;
|
|
7
|
+
};
|
|
8
|
+
//# sourceMappingURL=fold-node.schema.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fold-node.schema.d.ts","sourceRoot":"","sources":["../../../src/tree-surfer/fold-node/fold-node.schema.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,OAAO,KAAK,EAAE,QAAQ,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AACnE,OAAO,EAAE,eAAe,EAAE,MAAM,iCAAiC,CAAC;AAElE,wBAAgB,qBAAqB,CAAC,EAAE,SAAS,eAAe,EAC9D,QAAQ,EAAE,CAAC,CAAC,OAAO,CAAC,EAAE,CAAC;;;EAsBxB"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
export function createFoldNodeSchemas(idSchema) {
|
|
3
|
+
const foldNodeSchema = z.lazy(() => z.object({
|
|
4
|
+
id: idSchema,
|
|
5
|
+
children: z.array(foldNodeSchema),
|
|
6
|
+
folds: z.array(idSchema).transform((ids) => new Set(ids)),
|
|
7
|
+
}));
|
|
8
|
+
const foldNodeRootSchema = z.object({
|
|
9
|
+
children: z.array(foldNodeSchema),
|
|
10
|
+
folds: z.array(idSchema).transform((ids) => new Set(ids)),
|
|
11
|
+
});
|
|
12
|
+
return {
|
|
13
|
+
foldNodeSchema,
|
|
14
|
+
foldNodeRootSchema,
|
|
15
|
+
};
|
|
16
|
+
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { SerializableKey } from '../tree-node/tree-node.types.js';
|
|
2
2
|
/**
|
|
3
3
|
* The whole fold state for a tree-node tree.
|
|
4
4
|
*
|
|
@@ -8,7 +8,7 @@ import { TreeNodeModifier, TreeNodeSelector } from '../tree-node/tree-node.types
|
|
|
8
8
|
* `folds` contains the IDs folded at this root. Fold order is not
|
|
9
9
|
* represented here; the buffer tree determines entry order.
|
|
10
10
|
*/
|
|
11
|
-
export type FoldNodeRoot<Id extends
|
|
11
|
+
export type FoldNodeRoot<Id extends SerializableKey> = {
|
|
12
12
|
children: FoldNode<Id>[];
|
|
13
13
|
folds: ReadonlySet<Id>;
|
|
14
14
|
};
|
|
@@ -25,7 +25,7 @@ export type FoldNodeRoot<Id extends PropertyKey> = {
|
|
|
25
25
|
* The type is structurally compatible with `TreeNode`, allowing the shared
|
|
26
26
|
* `TreeNodeApi` to be used for path traversal and immutable updates.
|
|
27
27
|
*/
|
|
28
|
-
export type FoldNode<Id extends
|
|
28
|
+
export type FoldNode<Id extends SerializableKey> = FoldNodeRoot<Id> & {
|
|
29
29
|
id: Id;
|
|
30
30
|
};
|
|
31
31
|
/**
|
|
@@ -36,7 +36,7 @@ export type FoldNode<Id extends PropertyKey> = FoldNodeRoot<Id> & {
|
|
|
36
36
|
* paths that already exist. Creation of missing fold paths belongs to
|
|
37
37
|
* `FoldNodeService`.
|
|
38
38
|
*/
|
|
39
|
-
export type FoldNodeApi<Id extends
|
|
39
|
+
export type FoldNodeApi<Id extends SerializableKey> = {
|
|
40
40
|
/**
|
|
41
41
|
* Returns the children of either the fold root or a fold node.
|
|
42
42
|
*/
|
|
@@ -48,11 +48,11 @@ export type FoldNodeApi<Id extends PropertyKey> = {
|
|
|
48
48
|
/**
|
|
49
49
|
* Selects a fold node at a path below the root.
|
|
50
50
|
*/
|
|
51
|
-
getAtPath<Result>(rootNode: FoldNodeRoot<Id>, path: Id[], selector:
|
|
51
|
+
getAtPath<Result>(rootNode: FoldNodeRoot<Id>, path: Id[], selector: (node: FoldNode<Id>) => Result): Result | undefined;
|
|
52
52
|
/**
|
|
53
53
|
* Immutably modifies a fold node at a path below the root.
|
|
54
54
|
*/
|
|
55
|
-
modifyAtPath(rootNode: FoldNodeRoot<Id>, path: Id[], modifier:
|
|
55
|
+
modifyAtPath(rootNode: FoldNodeRoot<Id>, path: Id[], modifier: (node: FoldNode<Id>) => FoldNode<Id> | undefined): FoldNodeRoot<Id> | undefined;
|
|
56
56
|
};
|
|
57
57
|
/**
|
|
58
58
|
* Semantic operations for managing folded buffer entries.
|
|
@@ -60,7 +60,7 @@ export type FoldNodeApi<Id extends PropertyKey> = {
|
|
|
60
60
|
* Unlike `FoldNodeApi`, the service may create missing fold paths when
|
|
61
61
|
* adding a fold. This allows an empty root to be populated lazily.
|
|
62
62
|
*/
|
|
63
|
-
export type FoldNodeService<Id extends
|
|
63
|
+
export type FoldNodeService<Id extends SerializableKey> = {
|
|
64
64
|
createEmptyRoot(): FoldNodeRoot<Id>;
|
|
65
65
|
getIfEntryFoldedAtPath(rootNode: FoldNodeRoot<Id>, path: Id[], entryId: Id): boolean;
|
|
66
66
|
addFoldedEntryAtPath(rootNode: FoldNodeRoot<Id>, path: Id[], entryId: Id): FoldNodeRoot<Id> | undefined;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fold-node.types.d.ts","sourceRoot":"","sources":["../../../src/tree-surfer/fold-node/fold-node.types.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"fold-node.types.d.ts","sourceRoot":"","sources":["../../../src/tree-surfer/fold-node/fold-node.types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,iCAAiC,CAAC;AAElE;;;;;;;;GAQG;AACH,MAAM,MAAM,YAAY,CAAC,EAAE,SAAS,eAAe,IAAI;IACrD,QAAQ,EAAE,QAAQ,CAAC,EAAE,CAAC,EAAE,CAAC;IACzB,KAAK,EAAE,WAAW,CAAC,EAAE,CAAC,CAAC;CACxB,CAAC;AAEF;;;;;;;;;;;;GAYG;AACH,MAAM,MAAM,QAAQ,CAAC,EAAE,SAAS,eAAe,IAAI,YAAY,CAAC,EAAE,CAAC,GAAG;IACpE,EAAE,EAAE,EAAE,CAAC;CACR,CAAC;AAEF;;;;;;;GAOG;AACH,MAAM,MAAM,WAAW,CAAC,EAAE,SAAS,eAAe,IAAI;IACpD;;OAEG;IACH,WAAW,CAAC,IAAI,EAAE,YAAY,CAAC,EAAE,CAAC,GAAG,QAAQ,CAAC,EAAE,CAAC,GAAG,QAAQ,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC,CAAC;IAE3E;;OAEG;IACH,YAAY,CACV,IAAI,EAAE,YAAY,CAAC,EAAE,CAAC,GAAG,QAAQ,CAAC,EAAE,CAAC,EACrC,EAAE,EAAE,EAAE,GACL,QAAQ,CAAC,EAAE,CAAC,GAAG,SAAS,CAAC;IAE5B;;OAEG;IACH,SAAS,CAAC,MAAM,EACd,QAAQ,EAAE,YAAY,CAAC,EAAE,CAAC,EAC1B,IAAI,EAAE,EAAE,EAAE,EACV,QAAQ,EAAE,CAAC,IAAI,EAAE,QAAQ,CAAC,EAAE,CAAC,KAAK,MAAM,GACvC,MAAM,GAAG,SAAS,CAAC;IAEtB;;OAEG;IACH,YAAY,CACV,QAAQ,EAAE,YAAY,CAAC,EAAE,CAAC,EAC1B,IAAI,EAAE,EAAE,EAAE,EACV,QAAQ,EAAE,CAAC,IAAI,EAAE,QAAQ,CAAC,EAAE,CAAC,KAAK,QAAQ,CAAC,EAAE,CAAC,GAAG,SAAS,GACzD,YAAY,CAAC,EAAE,CAAC,GAAG,SAAS,CAAC;CACjC,CAAC;AAEF;;;;;GAKG;AACH,MAAM,MAAM,eAAe,CAAC,EAAE,SAAS,eAAe,IAAI;IACxD,eAAe,IAAI,YAAY,CAAC,EAAE,CAAC,CAAC;IAEpC,sBAAsB,CACpB,QAAQ,EAAE,YAAY,CAAC,EAAE,CAAC,EAC1B,IAAI,EAAE,EAAE,EAAE,EACV,OAAO,EAAE,EAAE,GACV,OAAO,CAAC;IAEX,oBAAoB,CAClB,QAAQ,EAAE,YAAY,CAAC,EAAE,CAAC,EAC1B,IAAI,EAAE,EAAE,EAAE,EACV,OAAO,EAAE,EAAE,GACV,YAAY,CAAC,EAAE,CAAC,GAAG,SAAS,CAAC;IAEhC,uBAAuB,CACrB,QAAQ,EAAE,YAAY,CAAC,EAAE,CAAC,EAC1B,IAAI,EAAE,EAAE,EAAE,EACV,OAAO,EAAE,EAAE,GACV,YAAY,CAAC,EAAE,CAAC,GAAG,SAAS,CAAC;IAEhC,wBAAwB,CACtB,QAAQ,EAAE,YAAY,CAAC,EAAE,CAAC,EAC1B,IAAI,EAAE,EAAE,EAAE,GACT,YAAY,CAAC,EAAE,CAAC,GAAG,SAAS,CAAC;CACjC,CAAC"}
|
|
@@ -1,9 +1,13 @@
|
|
|
1
1
|
export * from './fold-node/fold-node.impl.js';
|
|
2
|
+
export * from './fold-node/fold-node.schema.js';
|
|
2
3
|
export * from './fold-node/fold-node.types.js';
|
|
3
4
|
export * from './nav-node/nav-node.impl.js';
|
|
4
5
|
export * from './nav-node/nav-node.types.js';
|
|
5
6
|
export * from './tree-node/tree-node.impl.js';
|
|
7
|
+
export * from './tree-node/tree-node.schemas.js';
|
|
6
8
|
export * from './tree-node/tree-node.types.js';
|
|
7
9
|
export * from './cursor.js';
|
|
8
|
-
export * from './state.js';
|
|
10
|
+
export * from './state/state.impl.js';
|
|
11
|
+
export * from './state/state.schemas.js';
|
|
12
|
+
export * from './state/state.types.js';
|
|
9
13
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/tree-surfer/index.ts"],"names":[],"mappings":"AAAA,cAAc,+BAA+B,CAAC;AAC9C,cAAc,gCAAgC,CAAC;AAE/C,cAAc,6BAA6B,CAAC;AAC5C,cAAc,8BAA8B,CAAC;AAE7C,cAAc,+BAA+B,CAAC;AAC9C,cAAc,gCAAgC,CAAC;AAE/C,cAAc,aAAa,CAAC;AAE5B,cAAc,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/tree-surfer/index.ts"],"names":[],"mappings":"AAAA,cAAc,+BAA+B,CAAC;AAC9C,cAAc,iCAAiC,CAAC;AAChD,cAAc,gCAAgC,CAAC;AAE/C,cAAc,6BAA6B,CAAC;AAC5C,cAAc,8BAA8B,CAAC;AAE7C,cAAc,+BAA+B,CAAC;AAC9C,cAAc,kCAAkC,CAAC;AACjD,cAAc,gCAAgC,CAAC;AAE/C,cAAc,aAAa,CAAC;AAE5B,cAAc,uBAAuB,CAAC;AACtC,cAAc,0BAA0B,CAAC;AACzC,cAAc,wBAAwB,CAAC"}
|
|
@@ -1,8 +1,12 @@
|
|
|
1
1
|
export * from './fold-node/fold-node.impl.js';
|
|
2
|
+
export * from './fold-node/fold-node.schema.js';
|
|
2
3
|
export * from './fold-node/fold-node.types.js';
|
|
3
4
|
export * from './nav-node/nav-node.impl.js';
|
|
4
5
|
export * from './nav-node/nav-node.types.js';
|
|
5
6
|
export * from './tree-node/tree-node.impl.js';
|
|
7
|
+
export * from './tree-node/tree-node.schemas.js';
|
|
6
8
|
export * from './tree-node/tree-node.types.js';
|
|
7
9
|
export * from './cursor.js';
|
|
8
|
-
export * from './state.js';
|
|
10
|
+
export * from './state/state.impl.js';
|
|
11
|
+
export * from './state/state.schemas.js';
|
|
12
|
+
export * from './state/state.types.js';
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { SerializableKey, TreeNode, TreeNodeApi } from '../tree-node/tree-node.types.js';
|
|
2
|
+
import { FoldNodeApi } from '../fold-node/fold-node.types.js';
|
|
3
|
+
import { CursorApi } from '../cursor.js';
|
|
4
|
+
import { NavNodeApi } from '../nav-node/nav-node.types.js';
|
|
5
|
+
import { StateApi } from './state.types.js';
|
|
6
|
+
export declare function createStateApi<Id extends SerializableKey, Node extends TreeNode<Id, Node>>(treeNodeApi: TreeNodeApi<Id, Node>, foldNodeApi: FoldNodeApi<Id>, cursorApi: CursorApi<Id>, navNodeApi: NavNodeApi<Id, Node>): StateApi<Id, Node>;
|
|
7
|
+
//# sourceMappingURL=state.impl.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"state.impl.d.ts","sourceRoot":"","sources":["../../../src/tree-surfer/state/state.impl.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,QAAQ,EAAE,WAAW,EAAE,MAAM,iCAAiC,CAAC;AACzF,OAAO,EAAY,WAAW,EAAgB,MAAM,iCAAiC,CAAC;AACtF,OAAO,EAAU,SAAS,EAAc,MAAM,cAAc,CAAC;AAC7D,OAAO,EAAE,UAAU,EAAE,MAAM,+BAA+B,CAAC;AAC3D,OAAO,EAAE,QAAQ,EAAS,MAAM,kBAAkB,CAAC;AAEnD,wBAAgB,cAAc,CAC5B,EAAE,SAAS,eAAe,EAC1B,IAAI,SAAS,QAAQ,CAAC,EAAE,EAAE,IAAI,CAAC,EAE/B,WAAW,EAAE,WAAW,CAAC,EAAE,EAAE,IAAI,CAAC,EAClC,WAAW,EAAE,WAAW,CAAC,EAAE,CAAC,EAC5B,SAAS,EAAE,SAAS,CAAC,EAAE,CAAC,EACxB,UAAU,EAAE,UAAU,CAAC,EAAE,EAAE,IAAI,CAAC,GAC/B,QAAQ,CAAC,EAAE,EAAE,IAAI,CAAC,CA6IpB"}
|
|
@@ -1,38 +1,20 @@
|
|
|
1
|
-
import { CursorKind } from '
|
|
1
|
+
import { CursorKind } from '../cursor.js';
|
|
2
2
|
export function createStateApi(treeNodeApi, foldNodeApi, cursorApi, navNodeApi) {
|
|
3
|
-
// Helpers
|
|
4
3
|
/**
|
|
5
|
-
* Create a new buffer and fold node at
|
|
4
|
+
* Create a new buffer and fold node at a level.
|
|
6
5
|
*
|
|
7
|
-
* Works on fold root and
|
|
6
|
+
* Works on fold root and descendant fold nodes using the generic.
|
|
8
7
|
*/
|
|
9
|
-
async function reload(oldBuffer, oldFoldNode,
|
|
10
|
-
|
|
11
|
-
let newBufferAtRoot = await loadBranches(parentPath);
|
|
8
|
+
async function reload(oldBuffer, oldFoldNode, parentPath, loadBranches) {
|
|
9
|
+
let newBuffer = await loadBranches(parentPath);
|
|
12
10
|
let newFoldNode = oldFoldNode; // Start with assumption of no changes
|
|
13
|
-
/**
|
|
14
|
-
* Reload descendants that were already loaded in the old buffer.
|
|
15
|
-
*
|
|
16
|
-
* Fold membership is represented by IDs in `folds`, so it remains
|
|
17
|
-
* valid across a reload without rebuilding an entry array.
|
|
18
|
-
*/
|
|
19
11
|
for (const oldEntry of oldBuffer) {
|
|
20
|
-
// If it wasn't an open branch, then there's no need to reload descendants.
|
|
21
|
-
// Either the new entry is a leaf or an unopen branch.
|
|
22
12
|
if (!treeNodeApi.isBranch(oldEntry) ||
|
|
23
13
|
!treeNodeApi.isOpenBranch(oldEntry)) {
|
|
24
14
|
continue;
|
|
25
15
|
}
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
// If it doesn't exist (an open branch was deleted) then move on
|
|
29
|
-
if (newEntry === undefined) {
|
|
30
|
-
continue;
|
|
31
|
-
}
|
|
32
|
-
// The old entry may have changed into a leaf.
|
|
33
|
-
// A newly loaded branch is normally closed here because loadBranches
|
|
34
|
-
// returns flat entries, and the descendants are to be attached below.
|
|
35
|
-
if (!treeNodeApi.isBranch(newEntry)) {
|
|
16
|
+
const newEntry = treeNodeApi.getAtPath(newBuffer, [oldEntry.id], (entry) => entry);
|
|
17
|
+
if (newEntry === undefined || !treeNodeApi.isBranch(newEntry)) {
|
|
36
18
|
continue;
|
|
37
19
|
}
|
|
38
20
|
const oldChildFoldNode = oldFoldNode === undefined
|
|
@@ -40,7 +22,7 @@ export function createStateApi(treeNodeApi, foldNodeApi, cursorApi, navNodeApi)
|
|
|
40
22
|
: foldNodeApi.getChildById(oldFoldNode, oldEntry.id);
|
|
41
23
|
const entryPath = [...parentPath, oldEntry.id];
|
|
42
24
|
const reloadedChild = await reload([...treeNodeApi.getChildren(oldEntry)], oldChildFoldNode, entryPath, loadBranches);
|
|
43
|
-
const updatedBuffer = treeNodeApi.modifyAtPath(
|
|
25
|
+
const updatedBuffer = treeNodeApi.modifyAtPath(newBuffer, [oldEntry.id], (entry) => {
|
|
44
26
|
// The entry may be closed: loadBranches normally returns branches
|
|
45
27
|
// with `branches: null`. We are turning it back into an open branch.
|
|
46
28
|
if (!treeNodeApi.isBranch(entry)) {
|
|
@@ -48,15 +30,15 @@ export function createStateApi(treeNodeApi, foldNodeApi, cursorApi, navNodeApi)
|
|
|
48
30
|
}
|
|
49
31
|
return {
|
|
50
32
|
...entry,
|
|
51
|
-
|
|
33
|
+
children: reloadedChild.buffer,
|
|
52
34
|
};
|
|
53
35
|
});
|
|
54
36
|
if (updatedBuffer !== undefined) {
|
|
55
|
-
|
|
37
|
+
newBuffer = updatedBuffer;
|
|
56
38
|
}
|
|
57
39
|
}
|
|
58
40
|
return {
|
|
59
|
-
buffer:
|
|
41
|
+
buffer: newBuffer,
|
|
60
42
|
foldNode: newFoldNode,
|
|
61
43
|
};
|
|
62
44
|
}
|
|
@@ -84,8 +66,8 @@ export function createStateApi(treeNodeApi, foldNodeApi, cursorApi, navNodeApi)
|
|
|
84
66
|
}
|
|
85
67
|
return treeNodeApi.getAtPath(state.buffer, path, (node) => node);
|
|
86
68
|
},
|
|
87
|
-
async resync(oldState,
|
|
88
|
-
const reloaded = await reload(oldState.buffer, oldState.foldNode, [],
|
|
69
|
+
async resync(oldState, loadChildren) {
|
|
70
|
+
const reloaded = await reload(oldState.buffer, oldState.foldNode, [], loadChildren);
|
|
89
71
|
/*
|
|
90
72
|
* `oldState.foldNode` is always present. At the root reload starts with
|
|
91
73
|
* that node, so `reloaded.foldNode` should also always be present.
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { SerializableKey, TreeNode } from '../tree-node/tree-node.types.js';
|
|
3
|
+
import { State } from './state.types.js';
|
|
4
|
+
export declare function createStateSchema<Id extends SerializableKey, Node extends TreeNode<Id, Node>>(bufferNodeSchema: z.ZodType<Node>, foldNodeRootSchema: z.ZodType<State<Id, Node>['foldNode']>, cursorSchema: z.ZodType<State<Id, Node>['cursor']>): z.ZodObject<{
|
|
5
|
+
buffer: z.ZodArray<z.ZodType<Node, unknown, z.core.$ZodTypeInternals<Node, unknown>>>;
|
|
6
|
+
foldNode: z.ZodType<import("../index.js").FoldNodeRoot<Id>, unknown, z.core.$ZodTypeInternals<import("../index.js").FoldNodeRoot<Id>, unknown>>;
|
|
7
|
+
cursor: z.ZodType<import("../cursor.js").Cursor<Id>, unknown, z.core.$ZodTypeInternals<import("../cursor.js").Cursor<Id>, unknown>>;
|
|
8
|
+
}, z.core.$strip>;
|
|
9
|
+
//# sourceMappingURL=state.schemas.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"state.schemas.d.ts","sourceRoot":"","sources":["../../../src/tree-surfer/state/state.schemas.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,eAAe,EAAE,QAAQ,EAAE,MAAM,iCAAiC,CAAC;AAC5E,OAAO,EAAE,KAAK,EAAE,MAAM,kBAAkB,CAAC;AAEzC,wBAAgB,iBAAiB,CAC/B,EAAE,SAAS,eAAe,EAC1B,IAAI,SAAS,QAAQ,CAAC,EAAE,EAAE,IAAI,CAAC,EAE/B,gBAAgB,EAAE,CAAC,CAAC,OAAO,CAAC,IAAI,CAAC,EACjC,kBAAkB,EAAE,CAAC,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE,EAAE,IAAI,CAAC,CAAC,UAAU,CAAC,CAAC,EAC1D,YAAY,EAAE,CAAC,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE,EAAE,IAAI,CAAC,CAAC,QAAQ,CAAC,CAAC;;;;kBAOnD"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { Cursor } from '../cursor.js';
|
|
2
|
+
import { SerializableKey, TreeNode } from '../tree-node/tree-node.types.js';
|
|
3
|
+
import { FoldNodeRoot } from '../fold-node/fold-node.types.js';
|
|
4
|
+
export type State<Id extends SerializableKey, Node extends TreeNode<Id, Node>> = {
|
|
5
|
+
buffer: Node[];
|
|
6
|
+
foldNode: FoldNodeRoot<Id>;
|
|
7
|
+
cursor: Cursor<Id>;
|
|
8
|
+
};
|
|
9
|
+
export type StateApi<Id extends SerializableKey, Node extends TreeNode<Id, Node>> = {
|
|
10
|
+
getNodeAtCursor(state: State<Id, Node>): Node | undefined;
|
|
11
|
+
/**
|
|
12
|
+
* Reloads the root and all descendant branches that were loaded in the
|
|
13
|
+
* previous state.
|
|
14
|
+
*/
|
|
15
|
+
resync(oldState: State<Id, Node>, loadBranches: (path: Id[]) => Promise<Node[]>): Promise<State<Id, Node>>;
|
|
16
|
+
};
|
|
17
|
+
//# sourceMappingURL=state.types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"state.types.d.ts","sourceRoot":"","sources":["../../../src/tree-surfer/state/state.types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,cAAc,CAAC;AACtC,OAAO,EACL,eAAe,EACf,QAAQ,EACT,MAAM,iCAAiC,CAAC;AACzC,OAAO,EACL,YAAY,EACb,MAAM,iCAAiC,CAAC;AAEzC,MAAM,MAAM,KAAK,CACf,EAAE,SAAS,eAAe,EAC1B,IAAI,SAAS,QAAQ,CAAC,EAAE,EAAE,IAAI,CAAC,IAC7B;IACF,MAAM,EAAE,IAAI,EAAE,CAAC;IACf,QAAQ,EAAE,YAAY,CAAC,EAAE,CAAC,CAAC;IAC3B,MAAM,EAAE,MAAM,CAAC,EAAE,CAAC,CAAC;CACpB,CAAC;AAEF,MAAM,MAAM,QAAQ,CAClB,EAAE,SAAS,eAAe,EAC1B,IAAI,SAAS,QAAQ,CAAC,EAAE,EAAE,IAAI,CAAC,IAC7B;IACF,eAAe,CAAC,KAAK,EAAE,KAAK,CAAC,EAAE,EAAE,IAAI,CAAC,GAAG,IAAI,GAAG,SAAS,CAAC;IAE1D;;;OAGG;IACH,MAAM,CACJ,QAAQ,EAAE,KAAK,CAAC,EAAE,EAAE,IAAI,CAAC,EACzB,YAAY,EAAE,CAAC,IAAI,EAAE,EAAE,EAAE,KAAK,OAAO,CAAC,IAAI,EAAE,CAAC,GAC5C,OAAO,CAAC,KAAK,CAAC,EAAE,EAAE,IAAI,CAAC,CAAC,CAAC;CAC7B,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -1,31 +1,100 @@
|
|
|
1
1
|
import * as fc from 'fast-check';
|
|
2
2
|
import type { TreeNode } from './tree-node.types.js';
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
3
|
+
/**
|
|
4
|
+
* The ID type used by the generated test trees.
|
|
5
|
+
*
|
|
6
|
+
* Short strings keep generated counterexamples readable.
|
|
7
|
+
*/
|
|
8
|
+
type TestNodeId = string;
|
|
9
|
+
/**
|
|
10
|
+
* Generates valid string IDs for test nodes. Note that the API just does
|
|
11
|
+
* comparisons on the IDs so we can safely restrict to any subset.
|
|
12
|
+
*/
|
|
13
|
+
export declare const testIdArb: fc.Arbitrary<string>;
|
|
14
|
+
/**
|
|
15
|
+
* Tree node whose IDs are strings, without additional domain properties.
|
|
16
|
+
*/
|
|
17
|
+
export type StringNode = TreeNode<TestNodeId, StringNode>;
|
|
18
|
+
type Path = TestNodeId[];
|
|
19
|
+
type NodeAtPath = {
|
|
20
|
+
path: Path;
|
|
6
21
|
node: StringNode;
|
|
7
22
|
};
|
|
8
|
-
|
|
23
|
+
type NodeWithReachableNodes = {
|
|
9
24
|
node: StringNode;
|
|
10
|
-
|
|
25
|
+
reachableNodes: NodeAtPath[];
|
|
11
26
|
};
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
export declare const
|
|
27
|
+
/**
|
|
28
|
+
* Generates a leaf node.
|
|
29
|
+
*/
|
|
30
|
+
export declare const generatedLeafNodeArb: fc.Arbitrary<NodeWithReachableNodes>;
|
|
31
|
+
/**
|
|
32
|
+
* Generates a closed branch.
|
|
33
|
+
*/
|
|
34
|
+
export declare const generatedClosedBranchNodeArb: fc.Arbitrary<NodeWithReachableNodes>;
|
|
35
|
+
/**
|
|
36
|
+
* Generates a leaf, an open branch, or a closed branch.
|
|
37
|
+
*
|
|
38
|
+
* Open branches have unique child IDs. Root IDs are made unique separately
|
|
39
|
+
* when generating a forest.
|
|
40
|
+
*
|
|
41
|
+
* The weighted choice gives recursive open branches a geometric dropoff.
|
|
42
|
+
*/
|
|
43
|
+
export declare const generatedNodeArb: fc.Arbitrary<NodeWithReachableNodes>;
|
|
44
|
+
/**
|
|
45
|
+
* Generates an array of generated nodes with unique IDs suitable for use as
|
|
46
|
+
* the root of a forest.
|
|
47
|
+
*
|
|
48
|
+
* Root IDs must be unique because paths begin by looking up an ID in this
|
|
49
|
+
* array.
|
|
50
|
+
*/
|
|
51
|
+
export declare const generatedNodesArrayArb: fc.Arbitrary<NodeWithReachableNodes[]>;
|
|
52
|
+
/**
|
|
53
|
+
* An array of root-level nodes and all paths that can be resolved through
|
|
54
|
+
* those nodes.
|
|
55
|
+
*
|
|
56
|
+
* Paths through closed branches stop at the closed branch because its
|
|
57
|
+
* descendants are not loaded.
|
|
58
|
+
*/
|
|
59
|
+
export declare const nodesArrayAndPathsArb: fc.Arbitrary<{
|
|
16
60
|
entries: any[];
|
|
17
|
-
pathEntries:
|
|
61
|
+
pathEntries: NodeAtPath[];
|
|
18
62
|
}>;
|
|
19
|
-
|
|
63
|
+
/**
|
|
64
|
+
* Generates root-level nodes and a path to one of their reachable nodes.
|
|
65
|
+
*
|
|
66
|
+
* Every generated path is valid for `getAtPath`; unreachable paths are not
|
|
67
|
+
* included.
|
|
68
|
+
*/
|
|
69
|
+
export declare const nodesArrayAndPathAndExpectedArb: fc.Arbitrary<{
|
|
20
70
|
entries: any[];
|
|
21
|
-
path:
|
|
71
|
+
path: Path;
|
|
22
72
|
expected: any;
|
|
23
73
|
}>;
|
|
74
|
+
/**
|
|
75
|
+
* Generates root-level nodes and a path to one of their branch nodes.
|
|
76
|
+
*
|
|
77
|
+
* Both open and closed branches are included. A path to a closed branch is
|
|
78
|
+
* valid, but a path through a closed branch cannot reach any descendants.
|
|
79
|
+
*/
|
|
24
80
|
export declare const nodesArrayAndBranchPathArb: fc.Arbitrary<{
|
|
25
81
|
entries: any[];
|
|
26
|
-
path:
|
|
82
|
+
path: Path;
|
|
27
83
|
expected: any;
|
|
28
84
|
}>;
|
|
85
|
+
/**
|
|
86
|
+
* Generates a new array of loaded child nodes.
|
|
87
|
+
*
|
|
88
|
+
* The generated nodes have unique IDs, making the result suitable for use as
|
|
89
|
+
* the children of an open branch.
|
|
90
|
+
*/
|
|
29
91
|
export declare const newBranchesArb: fc.Arbitrary<any[]>;
|
|
92
|
+
/**
|
|
93
|
+
* Generates either a new array of loaded child nodes or `null`.
|
|
94
|
+
*
|
|
95
|
+
* An array represents an open branch, including an open branch with no
|
|
96
|
+
* children. `null` represents a closed branch.
|
|
97
|
+
*/
|
|
30
98
|
export declare const newBranchesOrNullArb: fc.Arbitrary<any[] | null>;
|
|
99
|
+
export {};
|
|
31
100
|
//# sourceMappingURL=tree-node.arb.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tree-node.arb.d.ts","sourceRoot":"","sources":["../../../src/tree-surfer/tree-node/tree-node.arb.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,YAAY,CAAC;AAEjC,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAC;
|
|
1
|
+
{"version":3,"file":"tree-node.arb.d.ts","sourceRoot":"","sources":["../../../src/tree-surfer/tree-node/tree-node.arb.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,YAAY,CAAC;AAEjC,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAC;AAErD;;;;GAIG;AACH,KAAK,UAAU,GAAG,MAAM,CAAC;AASzB;;;GAGG;AACH,eAAO,MAAM,SAAS,sBAIpB,CAAC;AAEH;;GAEG;AAEH,MAAM,MAAM,UAAU,GAAG,QAAQ,CAAC,UAAU,EAAE,UAAU,CAAC,CAAC;AAC1D,KAAK,IAAI,GAAG,UAAU,EAAE,CAAC;AAEzB,KAAK,UAAU,GAAG;IAChB,IAAI,EAAE,IAAI,CAAC;IACX,IAAI,EAAE,UAAU,CAAC;CAClB,CAAC;AAEF,KAAK,sBAAsB,GAAG;IAC5B,IAAI,EAAE,UAAU,CAAC;IACjB,cAAc,EAAE,UAAU,EAAE,CAAC;CAC9B,CAAC;AAyEF;;GAEG;AACH,eAAO,MAAM,oBAAoB,sCAEhC,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,4BAA4B,sCAExC,CAAC;AAaF;;;;;;;GAOG;AACH,eAAO,MAAM,gBAAgB,EAAE,EAAE,CAAC,SAAS,CAAC,sBAAsB,CA0C5D,CAAC;AAEP;;;;;;GAMG;AACH,eAAO,MAAM,sBAAsB,wCAIjC,CAAC;AAEH;;;;;;GAMG;AACH,eAAO,MAAM,qBAAqB;;;EAOjC,CAAC;AAEF;;;;;GAKG;AACH,eAAO,MAAM,+BAA+B;;;;EAQzC,CAAC;AAEJ;;;;;GAKG;AACH,eAAO,MAAM,0BAA0B;;;;EAcpC,CAAC;AAEJ;;;;;GAKG;AACH,eAAO,MAAM,cAAc,qBAE1B,CAAC;AAEF;;;;;GAKG;AACH,eAAO,MAAM,oBAAoB,4BAGhC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tree-node.arb.debug.d.ts","sourceRoot":"","sources":["../../../src/tree-surfer/tree-node/tree-node.arb.debug.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { describe, it } from 'vitest';
|
|
2
|
+
import * as fc from 'fast-check';
|
|
3
|
+
import { generatedNodeArb, generatedNodesArrayArb, } from './tree-node.arb.js';
|
|
4
|
+
/**
|
|
5
|
+
* Used for looking at the tree distributions generated by the arbs.
|
|
6
|
+
*/
|
|
7
|
+
describe('print generated tree node arbitraries', () => {
|
|
8
|
+
it.only('generated nodes', () => {
|
|
9
|
+
const samples = fc.sample(generatedNodeArb, {
|
|
10
|
+
numRuns: 10,
|
|
11
|
+
seed: 12345,
|
|
12
|
+
});
|
|
13
|
+
for (const [index, generated] of samples.entries()) {
|
|
14
|
+
console.log(`\n--- node ${index + 1} ---`);
|
|
15
|
+
console.dir(generated.node, {
|
|
16
|
+
depth: Infinity,
|
|
17
|
+
colors: false,
|
|
18
|
+
});
|
|
19
|
+
}
|
|
20
|
+
});
|
|
21
|
+
it.only('generated root-level node arrays', () => {
|
|
22
|
+
const samples = fc.sample(generatedNodesArrayArb, {
|
|
23
|
+
numRuns: 5,
|
|
24
|
+
seed: 12345,
|
|
25
|
+
});
|
|
26
|
+
for (const [index, generatedNodes] of samples.entries()) {
|
|
27
|
+
console.log(`\n--- root array ${index + 1} ---`);
|
|
28
|
+
console.dir(generatedNodes.map(({ node }) => node), {
|
|
29
|
+
depth: Infinity,
|
|
30
|
+
colors: false,
|
|
31
|
+
});
|
|
32
|
+
}
|
|
33
|
+
});
|
|
34
|
+
});
|