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.
Files changed (53) hide show
  1. package/dist/index.d.ts +0 -2
  2. package/dist/index.d.ts.map +1 -1
  3. package/dist/index.js +0 -2
  4. package/dist/tree-surfer/cursor.d.ts +9 -0
  5. package/dist/tree-surfer/cursor.d.ts.map +1 -1
  6. package/dist/tree-surfer/cursor.js +15 -0
  7. package/dist/tree-surfer/fold-node/fold-node.schema.d.ts +8 -0
  8. package/dist/tree-surfer/fold-node/fold-node.schema.d.ts.map +1 -0
  9. package/dist/tree-surfer/fold-node/fold-node.schema.js +16 -0
  10. package/dist/tree-surfer/fold-node/fold-node.types.d.ts +7 -7
  11. package/dist/tree-surfer/fold-node/fold-node.types.d.ts.map +1 -1
  12. package/dist/tree-surfer/index.d.ts +5 -1
  13. package/dist/tree-surfer/index.d.ts.map +1 -1
  14. package/dist/tree-surfer/index.js +5 -1
  15. package/dist/tree-surfer/state/state.impl.d.ts +7 -0
  16. package/dist/tree-surfer/state/state.impl.d.ts.map +1 -0
  17. package/dist/tree-surfer/{state.js → state/state.impl.js} +13 -31
  18. package/dist/tree-surfer/state/state.schemas.d.ts +9 -0
  19. package/dist/tree-surfer/state/state.schemas.d.ts.map +1 -0
  20. package/dist/tree-surfer/state/state.schemas.js +8 -0
  21. package/dist/tree-surfer/state/state.types.d.ts +17 -0
  22. package/dist/tree-surfer/state/state.types.d.ts.map +1 -0
  23. package/dist/tree-surfer/state/state.types.js +1 -0
  24. package/dist/tree-surfer/tree-node/tree-node.arb.d.ts +82 -13
  25. package/dist/tree-surfer/tree-node/tree-node.arb.d.ts.map +1 -1
  26. package/dist/tree-surfer/tree-node/tree-node.arb.debug.d.ts +2 -0
  27. package/dist/tree-surfer/tree-node/tree-node.arb.debug.d.ts.map +1 -0
  28. package/dist/tree-surfer/tree-node/tree-node.arb.debug.js +34 -0
  29. package/dist/tree-surfer/tree-node/tree-node.arb.js +163 -50
  30. package/dist/tree-surfer/tree-node/tree-node.schemas.d.ts +32 -0
  31. package/dist/tree-surfer/tree-node/tree-node.schemas.d.ts.map +1 -0
  32. package/dist/tree-surfer/tree-node/tree-node.schemas.js +35 -0
  33. package/dist/tree-surfer/tree-node/tree-node.test.js +138 -65
  34. package/dist/tree-surfer/tree-node/tree-node.types.d.ts +91 -118
  35. package/dist/tree-surfer/tree-node/tree-node.types.d.ts.map +1 -1
  36. package/dist/tree-surfer/tree-node/tree-node.types.js +1 -12
  37. package/dist/tree-surfer-ui/application/intent-to-effect.d.ts +1 -1
  38. package/dist/tree-surfer-ui/application/intent-to-effect.d.ts.map +1 -1
  39. package/dist/tree-surfer-ui/application/intent-to-effect.js +9 -13
  40. package/dist/tree-surfer-ui/application/parse-command.d.ts +4 -0
  41. package/dist/tree-surfer-ui/application/parse-command.d.ts.map +1 -0
  42. package/dist/tree-surfer-ui/application/parse-command.js +48 -0
  43. package/dist/tree-surfer-ui/domain/effect.d.ts +10 -0
  44. package/dist/tree-surfer-ui/domain/effect.d.ts.map +1 -1
  45. package/package.json +3 -2
  46. package/dist/domain/posix-node.d.ts +0 -29
  47. package/dist/domain/posix-node.d.ts.map +0 -1
  48. package/dist/domain/posix-node.js +0 -20
  49. package/dist/domain/unix-path.d.ts +0 -6
  50. package/dist/domain/unix-path.d.ts.map +0 -1
  51. package/dist/domain/unix-path.js +0 -11
  52. package/dist/tree-surfer/state.d.ts +0 -19
  53. package/dist/tree-surfer/state.d.ts.map +0 -1
@@ -1,25 +1,14 @@
1
- import { z } from 'zod';
2
- /**
3
- * Runtime schema for IDs that can be safely represented as serializable
4
- * primitive values.
5
- *
6
- * Strings are accepted as-is. Numbers must be finite, so `NaN`, `Infinity`,
7
- * and `-Infinity` are rejected.
8
- *
9
- * Applications should derive a more specific schema when those constraints
10
- * are needed.
11
- */
12
- export declare const serializableKeySchema: z.ZodUnion<readonly [z.ZodString, z.ZodNumber]>;
13
1
  /**
14
2
  * A serializable primitive suitable for use as a stable tree ID.
15
3
  *
16
- * The runtime schema guarantees that numeric values are finite. TypeScript
17
- * cannot represent the exclusion of `NaN` and infinities from `number`, so
18
- * values from untrusted sources should be validated with
19
- * `serializableKeySchema` before being used as IDs.
4
+ * @remarks
5
+ *
6
+ * Numeric IDs must be finite. TypeScript cannot represent the exclusion of
7
+ * `NaN` and infinities from `number`, so values from untrusted sources should
8
+ * be validated with `serializableKeySchema`.
20
9
  *
21
10
  * For application-specific IDs, define a narrower branded schema and derive
22
- * its type with `z.output`.
11
+ * its type with `z.output`:
23
12
  *
24
13
  * @example
25
14
  *
@@ -39,61 +28,63 @@ export declare const serializableKeySchema: z.ZodUnion<readonly [z.ZodString, z.
39
28
  */
40
29
  export type SerializableKey = string | number;
41
30
  /**
42
- * A node with no children.
31
+ * A node in a tree.
32
+ *
33
+ * @remarks
34
+ *
35
+ * A node's `id` identifies it among its siblings and is used when resolving
36
+ * paths through the tree.
37
+ *
38
+ * Nodes are discriminated by the shape of their `children` property:
39
+ *
40
+ * - a leaf has no children and does not have a child collection;
41
+ * - an open branch has a loaded array of child nodes;
42
+ * - a closed branch has children that have not been loaded yet and uses
43
+ * `children: null`.
44
+ *
45
+ * `Node` is the concrete application-specific node type. It may contain
46
+ * additional properties, provided that it preserves the leaf-or-branch shape
47
+ * described by this type.
48
+ *
49
+ * The recursive `Node` parameter allows application-specific properties
50
+ * to be available on every descendant.
51
+ *
52
+ * @typeParam Id - The type of node IDs.
53
+ * @typeParam Node - The application-specific recursive node type.
54
+ *
55
+ * @example
56
+ *
57
+ * ```ts
58
+ * type DirectoryEntry = TreeNode<string, DirectoryEntry> & {
59
+ * kind: 'file' | 'directory';
60
+ * };
61
+ * ```
43
62
  */
63
+ export type TreeNode<Id extends SerializableKey, Node extends TreeNode<Id, Node>> = LeafTreeNode<Id> | BranchTreeNode<Id, Node>;
64
+ /** A node with no children. */
44
65
  export type LeafTreeNode<Id extends SerializableKey> = {
45
66
  id: Id;
46
67
  children?: never;
47
68
  };
48
- /**
49
- * A branch whose children have not been loaded.
50
- */
51
- export type ClosedBranchTreeNode<Id extends SerializableKey> = {
69
+ /** A tree node that has children, either loaded or unloaded. */
70
+ export type BranchTreeNode<Id extends SerializableKey, Node extends TreeNode<Id, Node>> = OpenBranchTreeNode<Id, Node> | ClosedBranchTreeNode<Id>;
71
+ /** A branch whose direct children have been loaded. */
72
+ export type OpenBranchTreeNode<Id extends SerializableKey, Node extends TreeNode<Id, Node>> = {
52
73
  id: Id;
53
- children: null;
74
+ children: Node[];
54
75
  };
55
- /**
56
- * A branch whose children have been loaded.
57
- *
58
- * TODO Later: Add a dictionary by ID for faster lookup.
59
- * Then children will just be an array for keeping order.
60
- */
61
- export type OpenBranchTreeNode<Id extends SerializableKey, ChildNode extends TreeNode<Id, ChildNode>> = {
76
+ /** A branch whose direct children have not been loaded. */
77
+ export type ClosedBranchTreeNode<Id extends SerializableKey> = {
62
78
  id: Id;
63
- children: ChildNode[];
79
+ children: null;
64
80
  };
65
81
  /**
66
- * A tree node that has children, either loaded or unloaded.
67
- */
68
- export type BranchTreeNode<Id extends SerializableKey, ChildNode extends TreeNode<Id, ChildNode>> = OpenBranchTreeNode<Id, ChildNode> | ClosedBranchTreeNode<Id>;
69
- /**
70
- * A node in a tree.
71
- *
72
- * `ChildNode` is the concrete application-specific node type. It may contain
73
- * additional properties, provided that it has the shape of either a leaf or a
74
- * branch.
75
- */
76
- export type TreeNode<Id extends SerializableKey, ChildNode extends TreeNode<Id, ChildNode>> = LeafTreeNode<Id> | BranchTreeNode<Id, ChildNode>;
77
- /**
78
- * Selects a value from a node reached by a path.
79
- *
80
- * The selector is called only when the complete path exists and identifies
81
- * a node. Returning `undefined` from the selector is allowed, but is
82
- * indistinguishable from an unsuccessful lookup in the return value.
83
- */
84
- export type TreeNodeSelector<ChildNode, Result> = (node: ChildNode) => Result;
85
- /**
86
- * Produces a replacement for a node reached by a path.
82
+ * Operations for inspecting and immutably updating a tree node array.
87
83
  *
88
- * Returning `undefined` aborts the modification and causes `modifyAtPath`
89
- * to return `undefined`.
90
- */
91
- export type TreeNodeModifier<ChildNode> = (node: ChildNode) => ChildNode | undefined;
92
- /**
93
- * Fundamental operations for inspecting and immutably updating a tree forest.
84
+ * @remarks
94
85
  *
95
- * A forest is represented by an array of root-level nodes. A path is an array
96
- * of IDs beginning at a root node and continuing through its descendants.
86
+ * A path is an array of IDs beginning at a root node and continuing through
87
+ * its descendants.
97
88
  *
98
89
  * For example, given tree with IDs:
99
90
  *
@@ -102,83 +93,65 @@ export type TreeNodeModifier<ChildNode> = (node: ChildNode) => ChildNode | undef
102
93
  *
103
94
  * the path to `child` is `['root', 'child']`.
104
95
  *
105
- * Path traversal and child lookup are performed by this API so that callers
106
- * do not depend on the internal child-storage representation or need to
107
- * iterate over children themselves.
96
+ * Paths cannot pass through leaves or closed branches. A closed branch may be
97
+ * the final node in a path. An empty path does not identify a node and is
98
+ * invalid for both lookup and modification operations.
108
99
  *
109
- * An empty path does not identify a node and is invalid for both lookup and
110
- * modification operations.
100
+ * @typeParam Id - The type of node IDs.
101
+ * @typeParam Node - The application-specific recursive node type.
111
102
  */
112
- export type TreeNodeApi<Id extends SerializableKey, ChildNode extends TreeNode<Id, ChildNode>> = {
113
- isLeaf(node: ChildNode): node is ChildNode & LeafTreeNode<Id>;
114
- isBranch(node: ChildNode): node is ChildNode & BranchTreeNode<Id, ChildNode>;
115
- isClosedBranch(node: BranchTreeNode<Id, ChildNode>): node is ClosedBranchTreeNode<Id>;
116
- isOpenBranch(node: BranchTreeNode<Id, ChildNode>): node is OpenBranchTreeNode<Id, ChildNode>;
103
+ export type TreeNodeApi<Id extends SerializableKey, Node extends TreeNode<Id, Node>> = {
104
+ isLeaf(node: Node): node is Node & LeafTreeNode<Id>;
105
+ isBranch(node: Node): node is Node & BranchTreeNode<Id, Node>;
106
+ isClosedBranch(node: BranchTreeNode<Id, Node>): node is ClosedBranchTreeNode<Id>;
107
+ isOpenBranch(node: BranchTreeNode<Id, Node>): node is OpenBranchTreeNode<Id, Node>;
117
108
  /**
118
- * Returns the loaded children of an open branch.
109
+ * Returns the loaded direct children of an open branch.
119
110
  *
120
- * The returned iterable preserves the branch's sibling order. The method
121
- * can only be called after narrowing the branch with `isOpenBranch`.
111
+ * The children are returned in sibling order. The returned nodes are the
112
+ * existing nodes and are not cloned.
122
113
  *
123
- * The returned children are the existing child nodes; they are not cloned.
114
+ * @param node - An open branch.
115
+ * @returns The branch's loaded children.
124
116
  */
125
- getChildren(node: OpenBranchTreeNode<Id, ChildNode>): Iterable<ChildNode>;
117
+ getChildren(node: OpenBranchTreeNode<Id, Node>): Iterable<Node>;
126
118
  /**
127
- * Returns the child with the supplied ID.
119
+ * Finds a direct child by ID.
128
120
  *
129
- * Returns `undefined` when the branch has no child with that ID.
130
- * The returned child is the existing node; it is not cloned.
121
+ * @param node - An open branch.
122
+ * @param id - The ID of the child to find.
123
+ * @returns The existing child, or `undefined` when no matching child exists.
131
124
  */
132
- getChildById(node: OpenBranchTreeNode<Id, ChildNode>, id: Id): ChildNode | undefined;
125
+ getChildById(node: OpenBranchTreeNode<Id, Node>, id: Id): Node | undefined;
133
126
  /**
134
- * Applies `selector` to the node at `path`.
135
- *
136
- * The path must:
137
- *
138
- * - be non-empty;
139
- * - begin at one of the supplied forest entries;
140
- * - contain only IDs that identify existing entries;
141
- * - not traverse through a leaf; and
142
- * - not traverse through a closed branch.
143
- *
144
- * A branch at the end of the path is valid even when it is closed.
127
+ * Applies a selector to the node at a path.
145
128
  *
146
129
  * The selector is called only after the complete path has been resolved.
147
- * This method does not clone the tree or the selected node.
130
+ * The selected node is not cloned.
148
131
  *
149
- * Returns `undefined` when the path cannot be resolved, or when the
150
- * selector returns `undefined`.
132
+ * @param entries - The root-level nodes of the forest.
133
+ * @param path - A non-empty path beginning at a root node.
134
+ * @param selector - The function to apply to the resolved node.
135
+ * @returns The selector result, or `undefined` when the path cannot be
136
+ * resolved or the selector returns `undefined`.
151
137
  */
152
- getAtPath<Result>(entries: ChildNode[], path: Id[], selector: TreeNodeSelector<ChildNode, Result>): Result | undefined;
138
+ getAtPath<Result>(entries: Node[], path: Id[], selector: (node: Node) => Result): Result | undefined;
153
139
  /**
154
- * Immutably modifies the node at `path`.
140
+ * Immutably replaces the node at a path.
155
141
  *
156
142
  * The modifier is called only after the complete path has been resolved.
157
- * Its return value replaces the target node. Returning `undefined` aborts
158
- * the modification.
159
- *
160
- * The operation creates new arrays and ancestor nodes along the path.
161
- * Nodes and arrays unrelated to the path retain their original object
162
- * identity. The input forest and its nodes (as objects) are never modified.
163
- *
164
- * The path must:
165
- *
166
- * - be non-empty;
167
- * - begin at one of the supplied forest entries;
168
- * - contain only IDs that identify existing entries;
169
- * - not traverse through a leaf; and
170
- * - not traverse through a closed branch.
171
- *
172
- * A leaf or branch, including a closed branch, may be the final target.
143
+ * Returning `undefined` aborts the modification.
173
144
  *
174
- * Returns `undefined` when:
145
+ * New arrays and ancestor nodes are created along the modified path.
146
+ * Unrelated nodes and arrays retain their original object identity. The
147
+ * input array is never modified.
175
148
  *
176
- * - `path` is empty;
177
- * - the path does not exist;
178
- * - an intermediate node is a leaf;
179
- * - an intermediate branch is closed; or
180
- * - the modifier returns `undefined`.
149
+ * @param entries - The root-level nodes of the forest.
150
+ * @param path - A non-empty path beginning at a root node.
151
+ * @param modifier - Produces the replacement node.
152
+ * @returns A new forest, or `undefined` when the path cannot be resolved or
153
+ * the modifier returns `undefined`.
181
154
  */
182
- modifyAtPath(entries: ChildNode[], path: Id[], modifier: TreeNodeModifier<ChildNode>): ChildNode[] | undefined;
155
+ modifyAtPath(entries: Node[], path: Id[], modifier: (node: Node) => Node | undefined): Node[] | undefined;
183
156
  };
184
157
  //# sourceMappingURL=tree-node.types.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"tree-node.types.d.ts","sourceRoot":"","sources":["../../../src/tree-surfer/tree-node/tree-node.types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,K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AS,GACzC,IAAI,EAAE,GAAG,SAAS,CAAC;CACvB,CAAC"}
@@ -1,12 +1 @@
1
- import { z } from 'zod';
2
- /**
3
- * Runtime schema for IDs that can be safely represented as serializable
4
- * primitive values.
5
- *
6
- * Strings are accepted as-is. Numbers must be finite, so `NaN`, `Infinity`,
7
- * and `-Infinity` are rejected.
8
- *
9
- * Applications should derive a more specific schema when those constraints
10
- * are needed.
11
- */
12
- export const serializableKeySchema = z.union([z.string(), z.number().finite()]);
1
+ export {};
@@ -1,4 +1,4 @@
1
- import { SerializableKey, TreeNode, TreeNodeApi } from '../../tree-surfer/tree-node/tree-node.types.js';
1
+ import { SerializableKey, TreeNode, TreeNodeApi } from '../../tree-surfer/index.js';
2
2
  import { Effect, Intent } from '../domain/index.js';
3
3
  import { CursorApi, State, StateApi } from '../../tree-surfer/index.js';
4
4
  export type IntentToEffect<Id extends SerializableKey, BufferNode extends TreeNode<Id, BufferNode>> = (intent: Intent, state: State<Id, BufferNode>) => Effect<Id, BufferNode> | undefined;
@@ -1 +1 @@
1
- {"version":3,"file":"intent-to-effect.d.ts","sourceRoot":"","sources":["../../../src/tree-surfer-ui/application/intent-to-effect.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,eAAe,EACf,QAAQ,EACR,WAAW,EACZ,MAAM,gDAAgD,CAAC;AACxD,OAAO,EAAE,MAAM,EAAgB,MAAM,EAAE,MAAM,oBAAoB,CAAC;AAClE,OAAO,EAAE,SAAS,EAAE,KAAK,EAAE,QAAQ,EAAE,MAAM,4BAA4B,CAAC;AAGxE,MAAM,MAAM,cAAc,CACxB,EAAE,SAAS,eAAe,EAC1B,UAAU,SAAS,QAAQ,CAAC,EAAE,EAAE,UAAU,CAAC,IACzC,CACF,MAAM,EAAE,MAAM,EACd,KAAK,EAAE,KAAK,CAAC,EAAE,EAAE,UAAU,CAAC,KACzB,MAAM,CAAC,EAAE,EAAE,UAAU,CAAC,GAAG,SAAS,CAAC;AAGxC,wBAAgB,oBAAoB,CAClC,EAAE,SAAS,eAAe,EAC1B,UAAU,SAAS,QAAQ,CAAC,EAAE,EAAE,UAAU,CAAC,EAE3C,QAAQ,EAAE,QAAQ,CAAC,EAAE,EAAE,UAAU,CAAC,EAClC,SAAS,EAAE,SAAS,CAAC,EAAE,CAAC,EACxB,WAAW,EAAE,WAAW,CAAC,EAAE,EAAE,UAAU,CAAC,GACvC,cAAc,CAAC,EAAE,EAAE,UAAU,CAAC,CA6EhC"}
1
+ {"version":3,"file":"intent-to-effect.d.ts","sourceRoot":"","sources":["../../../src/tree-surfer-ui/application/intent-to-effect.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,eAAe,EACf,QAAQ,EACR,WAAW,EACZ,MAAM,4BAA4B,CAAC;AACpC,OAAO,EAAE,MAAM,EAAgB,MAAM,EAAE,MAAM,oBAAoB,CAAC;AAClE,OAAO,EAAE,SAAS,EAAE,KAAK,EAAE,QAAQ,EAAE,MAAM,4BAA4B,CAAC;AAIxE,MAAM,MAAM,cAAc,CACxB,EAAE,SAAS,eAAe,EAC1B,UAAU,SAAS,QAAQ,CAAC,EAAE,EAAE,UAAU,CAAC,IACzC,CACF,MAAM,EAAE,MAAM,EACd,KAAK,EAAE,KAAK,CAAC,EAAE,EAAE,UAAU,CAAC,KACzB,MAAM,CAAC,EAAE,EAAE,UAAU,CAAC,GAAG,SAAS,CAAC;AAGxC,wBAAgB,oBAAoB,CAClC,EAAE,SAAS,eAAe,EAC1B,UAAU,SAAS,QAAQ,CAAC,EAAE,EAAE,UAAU,CAAC,EAE3C,QAAQ,EAAE,QAAQ,CAAC,EAAE,EAAE,UAAU,CAAC,EAClC,SAAS,EAAE,SAAS,CAAC,EAAE,CAAC,EACxB,WAAW,EAAE,WAAW,CAAC,EAAE,EAAE,UAAU,CAAC,GACvC,cAAc,CAAC,EAAE,EAAE,UAAU,CAAC,CAkEhC"}
@@ -1,3 +1,4 @@
1
+ import { parseCommand } from './parse-command.js';
1
2
  // Factory method, since Apis are needed to derive intent
2
3
  export function createIntentToEffect(stateApi, cursorApi, treeNodeApi) {
3
4
  return (intent, state) => {
@@ -41,24 +42,13 @@ export function createIntentToEffect(stateApi, cursorApi, treeNodeApi) {
41
42
  },
42
43
  };
43
44
  case 'executeCommandLine':
44
- if (intent.commandLine === ':q') {
45
- return {
46
- effectType: 'quit',
47
- exitMessage: '',
48
- };
49
- }
50
- if (intent.commandLine === ':evlp') {
51
- return {
52
- effectType: 'emitVisibleLeavesPaths',
53
- };
54
- }
55
- return {
45
+ return (parseCommand(intent.commandLine) ?? {
56
46
  effectType: 'setInputState',
57
47
  inputState: {
58
48
  inputMode: 'normal',
59
49
  normalBuffer: '',
60
50
  },
61
- };
51
+ });
62
52
  }
63
53
  };
64
54
  }
@@ -108,6 +98,12 @@ function normalBufferToEffectResult(updatedNormalBuffer) {
108
98
  function normalInteractRightToEffect(state, stateApi, cursorApi, treeNodeApi) {
109
99
  const currentEntry = stateApi.getNodeAtCursor(state);
110
100
  if (currentEntry === undefined) {
101
+ if (state.cursor.kind === 'fold') {
102
+ return {
103
+ effectType: 'peekFold',
104
+ parentPath: state.cursor.parentPath
105
+ };
106
+ }
111
107
  return undefined;
112
108
  }
113
109
  const path = cursorApi.getPath(state.cursor);
@@ -0,0 +1,4 @@
1
+ import { SerializableKey, TreeNode } from '../../tree-surfer/index.js';
2
+ import { Effect } from '../domain/index.js';
3
+ export declare function parseCommand<Id extends SerializableKey, BufferNode extends TreeNode<Id, BufferNode>>(commandLine: string): Effect<Id, BufferNode> | undefined;
4
+ //# sourceMappingURL=parse-command.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"parse-command.d.ts","sourceRoot":"","sources":["../../../src/tree-surfer-ui/application/parse-command.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,QAAQ,EAAE,MAAM,4BAA4B,CAAC;AACvE,OAAO,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAC;AAI5C,wBAAgB,YAAY,CAC1B,EAAE,SAAS,eAAe,EAC1B,UAAU,SAAS,QAAQ,CAAC,EAAE,EAAE,UAAU,CAAC,EAC3C,WAAW,EAAE,MAAM,GAAG,MAAM,CAAC,EAAE,EAAE,UAAU,CAAC,GAAG,SAAS,CAqDzD"}
@@ -0,0 +1,48 @@
1
+ const DEFAULT_VIEW_NAME = 'default';
2
+ export function parseCommand(commandLine) {
3
+ const command = commandLine.trim();
4
+ switch (command) {
5
+ case ':q':
6
+ return {
7
+ effectType: 'quit',
8
+ exitMessage: '',
9
+ };
10
+ case ':evlp':
11
+ return {
12
+ effectType: 'emitVisibleLeavesPaths',
13
+ };
14
+ }
15
+ /*
16
+ * Vim-style view commands:
17
+ *
18
+ * :mkview!
19
+ * :mkview! project
20
+ * :loadview
21
+ * :loadview project
22
+ *
23
+ * The name may contain spaces, so capture the remainder of the command
24
+ * instead of splitting on whitespace.
25
+ *
26
+ * TODO Later: mkview that checks if same named view already saved
27
+ */
28
+ const viewCommand = command.match(/^:(mkview!|loadview)(?:\s+(.+?))?$/);
29
+ if (viewCommand === null) {
30
+ return undefined;
31
+ }
32
+ const commandName = viewCommand[1];
33
+ const suppliedName = viewCommand[2]?.trim();
34
+ const name = suppliedName || DEFAULT_VIEW_NAME;
35
+ switch (commandName) {
36
+ case 'mkview!':
37
+ return {
38
+ effectType: 'saveView',
39
+ name,
40
+ overwrite: true,
41
+ };
42
+ case 'loadview':
43
+ return {
44
+ effectType: 'loadView',
45
+ name,
46
+ };
47
+ }
48
+ }
@@ -6,6 +6,16 @@ export type Effect<Id extends SerializableKey, BufferNode extends TreeNode<Id, B
6
6
  } | {
7
7
  effectType: 'loadBranchEntries';
8
8
  path: Id[];
9
+ } | {
10
+ effectType: 'peekFold';
11
+ parentPath: readonly Id[];
12
+ } | {
13
+ effectType: 'saveView';
14
+ name: string;
15
+ overwrite: boolean;
16
+ } | {
17
+ effectType: 'loadView';
18
+ name: string;
9
19
  } | {
10
20
  effectType: 'emitVisibleLeavesPaths';
11
21
  } | {
@@ -1 +1 @@
1
- {"version":3,"file":"effect.d.ts","sourceRoot":"","sources":["../../../src/tree-surfer-ui/domain/effect.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AACnD,OAAO,EACL,eAAe,EACf,QAAQ,EACT,MAAM,4BAA4B,CAAC;AAGpC,MAAM,MAAM,MAAM,CAChB,EAAE,SAAS,eAAe,EAC1B,UAAU,SAAS,QAAQ,CAAC,EAAE,EAAE,UAAU,CAAC,IAEzC;IACE,UAAU,EAAE,sBAAsB,CAAC;IACnC,MAAM,EAAE,YAAY,CAAC,EAAE,EAAE,UAAU,CAAC,CAAC;CACtC,GACD;IACE,UAAU,EAAE,mBAAmB,CAAC;IAChC,IAAI,EAAE,EAAE,EAAE,CAAC;CACZ,GACD;IACE,UAAU,EAAE,wBAAwB,CAAC;CACtC,GACD;IACE,UAAU,EAAE,MAAM,CAAC;IACnB,WAAW,EAAE,MAAM,CAAC;CACrB,GACD;IACE,UAAU,EAAE,eAAe,CAAC;IAC5B,UAAU,EAAE,UAAU,CAAC;CACxB,CAAC;AAGN,MAAM,MAAM,YAAY,CACtB,EAAE,SAAS,eAAe,EAC1B,UAAU,SAAS,QAAQ,CAAC,EAAE,EAAE,UAAU,CAAC,IAEzC;IACE,gBAAgB,EAAE,WAAW,CAAC;CAC/B,GACD;IACE,gBAAgB,EAAE,WAAW,CAAC;CAC/B,GACD;IACE,gBAAgB,EAAE,kBAAkB,CAAC;IACrC,IAAI,EAAE,EAAE,EAAE,CAAC;IACX,OAAO,EAAE,UAAU,EAAE,GAAG,IAAI,CAAC;CAC9B,GACD;IACE,gBAAgB,EAAE,kBAAkB,CAAC;CACtC,GACD;IACE,gBAAgB,EAAE,MAAM,CAAC;CAC1B,GACD;IACE,gBAAgB,EAAE,QAAQ,CAAC;CAC5B,GACD;IACE,gBAAgB,EAAE,YAAY,CAAC;CAChC,CAAC"}
1
+ {"version":3,"file":"effect.d.ts","sourceRoot":"","sources":["../../../src/tree-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AkB,CAAC;CACtC,GACD;IACE,gBAAgB,EAAE,MAAM,CAAC;CAC1B,GACD;IACE,gBAAgB,EAAE,QAAQ,CAAC;CAC5B,GACD;IACE,gBAAgB,EAAE,YAAY,CAAC;CAChC,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dirvi-lib",
3
- "version": "0.6.1",
3
+ "version": "0.7.1",
4
4
  "description": "Dependency for dirvi apps.",
5
5
  "license": "LGPL-3.0-or-later",
6
6
  "type": "module",
@@ -20,6 +20,7 @@
20
20
  "clean": "rm -rf dist",
21
21
  "build": "pnpm clean && tsc",
22
22
  "typecheck": "tsc --noEmit",
23
- "format": "prettier . --write"
23
+ "format": "prettier . --write",
24
+ "docs": "typedoc"
24
25
  }
25
26
  }
@@ -1,29 +0,0 @@
1
- import { z } from 'zod';
2
- import { UnixPath } from './unix-path.js';
3
- import { Cursor, State } from '../tree-surfer/index.js';
4
- import { FoldNode } from '../tree-surfer/fold-node/fold-node.types.js';
5
- import { NavNode } from '../tree-surfer/nav-node/nav-node.types.js';
6
- export declare const PosixNameSchema: z.ZodString;
7
- export type PosixName = z.output<typeof PosixNameSchema>;
8
- export type PosixNode = {
9
- kind: 'file';
10
- id: PosixName;
11
- } | {
12
- kind: 'symlink';
13
- id: PosixName;
14
- target: UnixPath;
15
- } | {
16
- kind: 'directory';
17
- id: PosixName;
18
- children: PosixNode[] | null;
19
- };
20
- export declare const PosixNodeApi: import("../tree-surfer/index.js").TreeNodeApi<string, PosixNode>;
21
- export type PosixCursor = Cursor<PosixName>;
22
- export declare const PosixCursorApi: import("../tree-surfer/cursor.js").CursorApi<string>;
23
- export type PosixFoldNode = FoldNode<PosixName>;
24
- export declare const PosixFoldNodeApi: import("../tree-surfer/index.js").FoldNodeApi<string>;
25
- export type PosixNavNode = NavNode<PosixName, PosixNode>;
26
- export declare const PosixNavApi: import("../tree-surfer/index.js").NavNodeApi<string, PosixNode>;
27
- export type PosixState = State<PosixName, PosixNode>;
28
- export declare const PosixStateApi: import("../tree-surfer/state.js").StateApi<string, PosixNode>;
29
- //# sourceMappingURL=posix-node.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"posix-node.d.ts","sourceRoot":"","sources":["../../src/domain/posix-node.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,OAAO,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAE1C,OAAO,EAGL,MAAM,EACN,KAAK,EACN,MAAM,yBAAyB,CAAC;AACjC,OAAO,EAAE,QAAQ,EAAE,MAAM,6CAA6C,CAAC;AAEvE,OAAO,EAAE,OAAO,EAAE,MAAM,2CAA2C,CAAC;AAIpE,eAAO,MAAM,eAAe,aAQxB,CAAC;AAEL,MAAM,MAAM,SAAS,GAAG,CAAC,CAAC,MAAM,CAAC,OAAO,eAAe,CAAC,CAAC;AAGzD,MAAM,MAAM,SAAS,GACjB;IACE,IAAI,EAAE,MAAM,CAAC;IACb,EAAE,EAAE,SAAS,CAAC;CACf,GACD;IACE,IAAI,EAAE,SAAS,CAAC;IAChB,EAAE,EAAE,SAAS,CAAC;IACd,MAAM,EAAE,QAAQ,CAAC;CAClB,GACD;IACE,IAAI,EAAE,WAAW,CAAC;IAClB,EAAE,EAAE,SAAS,CAAC;IACd,QAAQ,EAAE,SAAS,EAAE,GAAG,IAAI,CAAC;CAC9B,CAAC;AAEN,eAAO,MAAM,YAAY,kEAA4C,CAAC;AAStE,MAAM,MAAM,WAAW,GAAG,MAAM,CAAC,SAAS,CAAC,CAAC;AAE5C,eAAO,MAAM,cAAc,sDAA+B,CAAC;AAG3D,MAAM,MAAM,aAAa,GAAG,QAAQ,CAAC,SAAS,CAAC,CAAC;AAEhD,eAAO,MAAM,gBAAgB,uDAAiC,CAAC;AAG/D,MAAM,MAAM,YAAY,GAAG,OAAO,CAAC,SAAS,EAAE,SAAS,CAAC,CAAC;AAEzD,eAAO,MAAM,WAAW,iEAIvB,CAAC;AAGF,MAAM,MAAM,UAAU,GAAG,KAAK,CAAC,SAAS,EAAE,SAAS,CAAC,CAAC;AAErD,eAAO,MAAM,aAAa,+DAKzB,CAAC"}
@@ -1,20 +0,0 @@
1
- import { z } from 'zod';
2
- import { createTreeNodeApi } from '../tree-surfer/tree-node/tree-node.impl.js';
3
- import { createCursorApi, createStateApi, } from '../tree-surfer/index.js';
4
- import { createFoldNodeApi } from '../tree-surfer/fold-node/fold-node.impl.js';
5
- import { createNavNodeApi } from '../tree-surfer/nav-node/nav-node.impl.js';
6
- // Name
7
- export const PosixNameSchema = z
8
- .string()
9
- .min(1)
10
- .refine((value) => !value.includes('/'), {
11
- message: "Entry name must not contain '/'",
12
- })
13
- .refine((value) => value !== '.' && value !== '..', {
14
- message: "Entry name cannot be '.' or '..'",
15
- });
16
- export const PosixNodeApi = createTreeNodeApi();
17
- export const PosixCursorApi = createCursorApi();
18
- export const PosixFoldNodeApi = createFoldNodeApi();
19
- export const PosixNavApi = createNavNodeApi(PosixNodeApi, PosixFoldNodeApi, PosixCursorApi);
20
- export const PosixStateApi = createStateApi(PosixNodeApi, PosixFoldNodeApi, PosixCursorApi, PosixNavApi);
@@ -1,6 +0,0 @@
1
- import { z } from 'zod';
2
- export declare const UnixPathSchema: z.ZodString;
3
- export type UnixPath = z.output<typeof UnixPathSchema>;
4
- export declare const UnixAbsolutePathSchema: z.ZodString;
5
- export type UnixAbsolutePath = z.output<typeof UnixAbsolutePathSchema>;
6
- //# sourceMappingURL=unix-path.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"unix-path.d.ts","sourceRoot":"","sources":["../../src/domain/unix-path.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAGxB,eAAO,MAAM,cAAc,aAKvB,CAAC;AAEL,MAAM,MAAM,QAAQ,GAAG,CAAC,CAAC,MAAM,CAAC,OAAO,cAAc,CAAC,CAAC;AAEvD,eAAO,MAAM,sBAAsB,aAKlC,CAAC;AAEF,MAAM,MAAM,gBAAgB,GAAG,CAAC,CAAC,MAAM,CAAC,OAAO,sBAAsB,CAAC,CAAC"}
@@ -1,11 +0,0 @@
1
- import { z } from 'zod';
2
- // UNIX PATHS
3
- export const UnixPathSchema = z
4
- .string()
5
- .min(1)
6
- .refine((value) => !value.includes('\0'), {
7
- message: 'Unix paths must not contain null bytes',
8
- });
9
- export const UnixAbsolutePathSchema = UnixPathSchema.refine((value) => value.startsWith('/'), {
10
- message: 'Path must be an absolute Unix path',
11
- });
@@ -1,19 +0,0 @@
1
- import { Cursor, CursorApi } from './cursor.js';
2
- import { SerializableKey, TreeNode, TreeNodeApi } from './tree-node/tree-node.types.js';
3
- import { FoldNodeApi, FoldNodeRoot } from './fold-node/fold-node.types.js';
4
- import { NavNodeApi } from './nav-node/nav-node.types.js';
5
- export type State<Id extends SerializableKey, BufferNode extends TreeNode<Id, BufferNode>> = {
6
- buffer: BufferNode[];
7
- foldNode: FoldNodeRoot<Id>;
8
- cursor: Cursor<Id>;
9
- };
10
- export type StateApi<Id extends SerializableKey, BufferNode extends TreeNode<Id, BufferNode>> = {
11
- getNodeAtCursor(state: State<Id, BufferNode>): BufferNode | undefined;
12
- /**
13
- * Reloads the root and all descendant branches that were loaded in the
14
- * previous state.
15
- */
16
- resync(oldState: State<Id, BufferNode>, loadBranches: (path: Id[]) => Promise<BufferNode[]>): Promise<State<Id, BufferNode>>;
17
- };
18
- export declare function createStateApi<Id extends SerializableKey, BufferNode extends TreeNode<Id, BufferNode>>(treeNodeApi: TreeNodeApi<Id, BufferNode>, foldNodeApi: FoldNodeApi<Id>, cursorApi: CursorApi<Id>, navNodeApi: NavNodeApi<Id, BufferNode>): StateApi<Id, BufferNode>;
19
- //# sourceMappingURL=state.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"state.d.ts","sourceRoot":"","sources":["../../src/tree-surfer/state.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,SAAS,EAAc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