dirvi-lib 0.3.0 → 0.5.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.
Files changed (103) hide show
  1. package/dist/domain/posix-node.d.ts +29 -0
  2. package/dist/domain/posix-node.d.ts.map +1 -0
  3. package/dist/domain/posix-node.js +20 -0
  4. package/dist/index.d.ts +8 -8
  5. package/dist/index.d.ts.map +1 -1
  6. package/dist/index.js +8 -8
  7. package/dist/tree-surfer/cursor.d.ts +24 -0
  8. package/dist/tree-surfer/cursor.d.ts.map +1 -0
  9. package/dist/tree-surfer/cursor.js +65 -0
  10. package/dist/tree-surfer/fold-node/fold-node.impl.d.ts +5 -0
  11. package/dist/tree-surfer/fold-node/fold-node.impl.d.ts.map +1 -0
  12. package/dist/tree-surfer/fold-node/fold-node.impl.js +143 -0
  13. package/dist/tree-surfer/fold-node/fold-node.types.d.ts +70 -0
  14. package/dist/tree-surfer/fold-node/fold-node.types.d.ts.map +1 -0
  15. package/dist/tree-surfer/fold-node/fold-node.types.js +1 -0
  16. package/dist/tree-surfer/index.d.ts +9 -0
  17. package/dist/tree-surfer/index.d.ts.map +1 -0
  18. package/dist/tree-surfer/index.js +8 -0
  19. package/dist/tree-surfer/nav-node/nav-node.impl.d.ts +6 -0
  20. package/dist/tree-surfer/nav-node/nav-node.impl.d.ts.map +1 -0
  21. package/dist/tree-surfer/nav-node/nav-node.impl.js +191 -0
  22. package/dist/tree-surfer/nav-node/nav-node.types.d.ts +42 -0
  23. package/dist/tree-surfer/nav-node/nav-node.types.d.ts.map +1 -0
  24. package/dist/tree-surfer/nav-node/nav-node.types.js +3 -0
  25. package/dist/tree-surfer/state.d.ts +19 -0
  26. package/dist/tree-surfer/state.d.ts.map +1 -0
  27. package/dist/tree-surfer/state.js +109 -0
  28. package/dist/tree-surfer/tree-node/tree-node.arb.d.ts +31 -0
  29. package/dist/tree-surfer/tree-node/tree-node.arb.d.ts.map +1 -0
  30. package/dist/tree-surfer/tree-node/tree-node.arb.js +80 -0
  31. package/dist/tree-surfer/tree-node/tree-node.impl.d.ts +13 -0
  32. package/dist/tree-surfer/tree-node/tree-node.impl.d.ts.map +1 -0
  33. package/dist/tree-surfer/tree-node/tree-node.impl.js +87 -0
  34. package/dist/tree-surfer/tree-node/tree-node.test.d.ts +2 -0
  35. package/dist/tree-surfer/tree-node/tree-node.test.d.ts.map +1 -0
  36. package/dist/tree-surfer/tree-node/tree-node.test.js +117 -0
  37. package/dist/tree-surfer/tree-node/tree-node.types.d.ts +184 -0
  38. package/dist/tree-surfer/tree-node/tree-node.types.d.ts.map +1 -0
  39. package/dist/tree-surfer/tree-node/tree-node.types.js +12 -0
  40. package/dist/tree-surfer-ui/application/index.d.ts +3 -0
  41. package/dist/tree-surfer-ui/application/index.d.ts.map +1 -0
  42. package/dist/tree-surfer-ui/application/index.js +2 -0
  43. package/dist/tree-surfer-ui/application/intent-to-effect-no-state.test.d.ts +2 -0
  44. package/dist/tree-surfer-ui/application/intent-to-effect-no-state.test.d.ts.map +1 -0
  45. package/dist/tree-surfer-ui/application/intent-to-effect-no-state.test.js +192 -0
  46. package/dist/tree-surfer-ui/application/intent-to-effect.d.ts +6 -0
  47. package/dist/tree-surfer-ui/application/intent-to-effect.d.ts.map +1 -0
  48. package/dist/tree-surfer-ui/application/intent-to-effect.js +137 -0
  49. package/dist/tree-surfer-ui/application/user-input-to-intent.d.ts +3 -0
  50. package/dist/tree-surfer-ui/application/user-input-to-intent.d.ts.map +1 -0
  51. package/dist/tree-surfer-ui/application/user-input-to-intent.js +98 -0
  52. package/dist/tree-surfer-ui/application/user-input-to-intent.test.d.ts +2 -0
  53. package/dist/tree-surfer-ui/application/user-input-to-intent.test.d.ts.map +1 -0
  54. package/dist/tree-surfer-ui/application/user-input-to-intent.test.js +118 -0
  55. package/dist/tree-surfer-ui/domain/effect.d.ts +36 -0
  56. package/dist/tree-surfer-ui/domain/effect.d.ts.map +1 -0
  57. package/dist/tree-surfer-ui/domain/effect.js +1 -0
  58. package/dist/tree-surfer-ui/domain/index.d.ts +5 -0
  59. package/dist/tree-surfer-ui/domain/index.d.ts.map +1 -0
  60. package/dist/tree-surfer-ui/domain/index.js +4 -0
  61. package/dist/tree-surfer-ui/domain/input-state.d.ts +8 -0
  62. package/dist/tree-surfer-ui/domain/input-state.d.ts.map +1 -0
  63. package/dist/tree-surfer-ui/domain/input-state.js +1 -0
  64. package/dist/tree-surfer-ui/domain/intent.d.ts +25 -0
  65. package/dist/tree-surfer-ui/domain/intent.d.ts.map +1 -0
  66. package/dist/tree-surfer-ui/domain/intent.js +1 -0
  67. package/dist/tree-surfer-ui/domain/user-input.d.ts +19 -0
  68. package/dist/tree-surfer-ui/domain/user-input.d.ts.map +1 -0
  69. package/dist/tree-surfer-ui/domain/user-input.js +1 -0
  70. package/package.json +6 -3
  71. package/dist/domain/cursor.d.ts +0 -17
  72. package/dist/domain/cursor.d.ts.map +0 -1
  73. package/dist/domain/cursor.js +0 -44
  74. package/dist/domain/display-row.d.ts +0 -29
  75. package/dist/domain/display-row.d.ts.map +0 -1
  76. package/dist/domain/display-row.js +0 -29
  77. package/dist/domain/fold-node.d.ts +0 -17
  78. package/dist/domain/fold-node.d.ts.map +0 -1
  79. package/dist/domain/fold-node.js +0 -81
  80. package/dist/domain/fold.d.ts +0 -10
  81. package/dist/domain/fold.d.ts.map +0 -1
  82. package/dist/domain/fold.js +0 -24
  83. package/dist/domain/navigation-entry.d.ts +0 -23
  84. package/dist/domain/navigation-entry.d.ts.map +0 -1
  85. package/dist/domain/navigation-entry.js +0 -52
  86. package/dist/domain/navigation-node.d.ts +0 -43
  87. package/dist/domain/navigation-node.d.ts.map +0 -1
  88. package/dist/domain/navigation-node.js +0 -198
  89. package/dist/domain/state.d.ts +0 -12
  90. package/dist/domain/state.d.ts.map +0 -1
  91. package/dist/domain/state.js +0 -12
  92. package/dist/domain/unix-entry.d.ts +0 -28
  93. package/dist/domain/unix-entry.d.ts.map +0 -1
  94. package/dist/domain/unix-entry.js +0 -96
  95. package/dist/domain/view.d.ts +0 -15
  96. package/dist/domain/view.d.ts.map +0 -1
  97. package/dist/domain/view.js +0 -12
  98. package/dist/infrastructure/get-cwd.d.ts +0 -3
  99. package/dist/infrastructure/get-cwd.d.ts.map +0 -1
  100. package/dist/infrastructure/get-cwd.js +0 -13
  101. package/dist/infrastructure/get-dir-lazy-entries.d.ts +0 -4
  102. package/dist/infrastructure/get-dir-lazy-entries.d.ts.map +0 -1
  103. package/dist/infrastructure/get-dir-lazy-entries.js +0 -34
@@ -1,43 +0,0 @@
1
- import { UnixEntry, UnixEntryName, UnixEntryPath } from './unix-entry.js';
2
- import { UnixPath } from './unix-path.js';
3
- import { FoldNode } from './fold-node.js';
4
- import { Cursor } from './cursor.js';
5
- export type NavigationEntry = {
6
- kind: 'file';
7
- name: UnixEntryName;
8
- } | {
9
- kind: 'symlink';
10
- name: UnixEntryName;
11
- target: UnixPath;
12
- } | {
13
- /**
14
- * Undefined node means the directory has not been loaded.
15
- */
16
- kind: 'directory';
17
- name: UnixEntryName;
18
- node?: NavigationNode;
19
- };
20
- /**
21
- * A directory as navigated: list of visible entries and folded entries.
22
- */
23
- export type NavigationNode = {
24
- /**
25
- * Currently visible entries.
26
- */
27
- entries: NavigationEntry[];
28
- /**
29
- * Currently loaded entries hidden by this directory's fold.
30
- */
31
- foldedEntries: NavigationEntry[];
32
- };
33
- export declare const NavigationNode: {
34
- from(entries: UnixEntry[] | undefined, foldNode: FoldNode | undefined): NavigationNode;
35
- getNodeAtPath(navigation: NavigationNode, path: UnixEntryPath): NavigationNode | undefined;
36
- getEntryAtPath(navigation: NavigationNode, path: UnixEntryPath): NavigationEntry | undefined;
37
- nextCursor(rootNode: NavigationNode, cursor: Cursor): Cursor | undefined;
38
- previousCursor(rootNode: NavigationNode, cursor: Cursor): Cursor | undefined;
39
- cursorAfterFold(rootNode: NavigationNode, cursor: Cursor): Cursor | undefined;
40
- parentCursor(navigation: NavigationNode, cursor: Cursor): Cursor | undefined;
41
- visibleFilesPaths(navigation: NavigationNode, parentPath?: UnixEntryPath): UnixEntryPath[];
42
- };
43
- //# sourceMappingURL=navigation-node.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"navigation-node.d.ts","sourceRoot":"","sources":["../../src/domain/navigation-node.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,aAAa,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAC1E,OAAO,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAC1C,OAAO,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAC1C,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAErC,MAAM,MAAM,eAAe,GACvB;IACE,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,aAAa,CAAC;CACrB,GACD;IACE,IAAI,EAAE,SAAS,CAAC;IAChB,IAAI,EAAE,aAAa,CAAC;IACpB,MAAM,EAAE,QAAQ,CAAC;CAClB,GACD;IACE;;OAEG;IACH,IAAI,EAAE,WAAW,CAAC;IAClB,IAAI,EAAE,aAAa,CAAC;IACpB,IAAI,CAAC,EAAE,cAAc,CAAC;CACvB,CAAC;AAEN;;GAEG;AACH,MAAM,MAAM,cAAc,GAAG;IAC3B;;OAEG;IACH,OAAO,EAAE,eAAe,EAAE,CAAC;IAE3B;;OAEG;IACH,aAAa,EAAE,eAAe,EAAE,CAAC;CAClC,CAAC;AAEF,eAAO,MAAM,cAAc;kBAEd,SAAS,EAAE,GAAG,SAAS,YACtB,QAAQ,GAAG,SAAS,GAC7B,cAAc;8BA4DH,cAAc,QACpB,aAAa,GAClB,cAAc,GAAG,SAAS;+BAyBf,cAAc,QACpB,aAAa,GAClB,eAAe,GAAG,SAAS;yBA0BT,cAAc,UAAU,MAAM,GAAG,MAAM,GAAG,SAAS;6BAc/C,cAAc,UAAU,MAAM,GAAG,MAAM,GAAG,SAAS;8BAehE,cAAc,UAChB,MAAM,GACb,MAAM,GAAG,SAAS;6BAsCI,cAAc,UAAU,MAAM,GAAG,MAAM,GAAG,SAAS;kCA6B9D,cAAc,eACd,aAAa,GACxB,aAAa,EAAE;CA2BnB,CAAC"}
@@ -1,198 +0,0 @@
1
- import { UnixEntryPath } from './unix-entry.js';
2
- import { Cursor } from './cursor.js';
3
- export const NavigationNode = {
4
- from(entries, foldNode) {
5
- if (entries === undefined) {
6
- return {
7
- entries: [],
8
- foldedEntries: [],
9
- };
10
- }
11
- const foldedNames = new Set(foldNode?.folds ?? []);
12
- const visibleEntries = [];
13
- const foldedEntries = [];
14
- for (const entry of entries) {
15
- let navigationEntry;
16
- switch (entry.kind) {
17
- case 'file':
18
- navigationEntry = {
19
- kind: 'file',
20
- name: entry.name,
21
- };
22
- break;
23
- case 'symlink':
24
- navigationEntry = {
25
- kind: 'symlink',
26
- name: entry.name,
27
- target: entry.target,
28
- };
29
- break;
30
- case 'directory': {
31
- const childFoldNode = foldNode?.children[entry.name];
32
- navigationEntry = {
33
- kind: 'directory',
34
- name: entry.name,
35
- node: entry.entries === undefined
36
- ? undefined
37
- : NavigationNode.from(entry.entries, childFoldNode),
38
- };
39
- break;
40
- }
41
- }
42
- if (foldedNames.has(entry.name)) {
43
- foldedEntries.push(navigationEntry);
44
- }
45
- else {
46
- visibleEntries.push(navigationEntry);
47
- }
48
- }
49
- return {
50
- entries: visibleEntries,
51
- foldedEntries,
52
- };
53
- },
54
- getNodeAtPath(navigation, path) {
55
- const [currentName, ...remainingPath] = path;
56
- // An empty path identifies the current node.
57
- if (currentName === undefined) {
58
- return navigation;
59
- }
60
- const entry = [...navigation.entries, ...navigation.foldedEntries].find((candidate) => candidate.name === currentName);
61
- if (entry === undefined || entry.kind !== 'directory') {
62
- return undefined;
63
- }
64
- // The directory has not been loaded/opened.
65
- if (entry.node === undefined) {
66
- return undefined;
67
- }
68
- return NavigationNode.getNodeAtPath(entry.node, remainingPath);
69
- },
70
- getEntryAtPath(navigation, path) {
71
- const [currentName, ...remainingPath] = path;
72
- if (currentName === undefined) {
73
- return undefined;
74
- }
75
- const entry = [...navigation.entries, ...navigation.foldedEntries].find((candidate) => candidate.name === currentName);
76
- if (entry === undefined) {
77
- return undefined;
78
- }
79
- if (remainingPath.length === 0) {
80
- return entry;
81
- }
82
- if (entry.kind !== 'directory' || entry.node === undefined) {
83
- return undefined;
84
- }
85
- return NavigationNode.getEntryAtPath(entry.node, remainingPath);
86
- },
87
- nextCursor(rootNode, cursor) {
88
- const cursors = cursorsInNode(rootNode, []);
89
- const currentIndex = cursors.findIndex((candidate) => Cursor.equal(candidate, cursor));
90
- if (currentIndex === -1 || currentIndex === cursors.length - 1) {
91
- return undefined;
92
- }
93
- return cursors[currentIndex + 1];
94
- },
95
- previousCursor(rootNode, cursor) {
96
- const cursors = cursorsInNode(rootNode, []);
97
- const currentIndex = cursors.findIndex((candidate) => Cursor.equal(candidate, cursor));
98
- if (currentIndex <= 0) {
99
- return undefined;
100
- }
101
- return cursors[currentIndex - 1];
102
- },
103
- cursorAfterFold(rootNode, cursor) {
104
- if (cursor.kind === 'fold') {
105
- return undefined;
106
- }
107
- const cursors = cursorsInNode(rootNode, []);
108
- const currentIndex = cursors.findIndex((candidate) => Cursor.equal(candidate, cursor));
109
- if (currentIndex === -1) {
110
- return undefined;
111
- }
112
- const foldedPath = [...cursor.parentPath, cursor.entryName];
113
- for (let index = currentIndex + 1; index < cursors.length; index += 1) {
114
- const candidate = cursors[index];
115
- if (candidate === undefined) {
116
- continue;
117
- }
118
- if (cursorBelongsToSubtree(candidate, foldedPath)) {
119
- continue;
120
- }
121
- return candidate;
122
- }
123
- // The fold row will be created at the end of this directory.
124
- return {
125
- kind: 'fold',
126
- parentPath: cursor.parentPath,
127
- };
128
- },
129
- parentCursor(navigation, cursor) {
130
- const parentPath = cursor.parentPath;
131
- // The cursor is already in the root directory.
132
- if (parentPath.length === 0) {
133
- return undefined;
134
- }
135
- const entryName = parentPath.at(-1);
136
- if (entryName === undefined) {
137
- return undefined;
138
- }
139
- const containingPath = parentPath.slice(0, -1);
140
- const entry = NavigationNode.getEntryAtPath(navigation, parentPath);
141
- if (entry === undefined || entry.kind !== 'directory') {
142
- return undefined;
143
- }
144
- return {
145
- kind: 'entry',
146
- parentPath: containingPath,
147
- entryName,
148
- };
149
- },
150
- visibleFilesPaths(navigation, parentPath = []) {
151
- const paths = [];
152
- for (const entry of navigation.entries) {
153
- const entryPath = [...parentPath, entry.name];
154
- switch (entry.kind) {
155
- case 'file':
156
- paths.push(entryPath);
157
- break;
158
- case 'symlink':
159
- // Do not recurse through symlinks.
160
- break;
161
- case 'directory':
162
- if (entry.node !== undefined) {
163
- paths.push(...NavigationNode.visibleFilesPaths(entry.node, entryPath));
164
- }
165
- break;
166
- }
167
- }
168
- return paths;
169
- },
170
- };
171
- function cursorsInNode(node, parentPath) {
172
- const cursors = [];
173
- for (const entry of node.entries) {
174
- cursors.push({
175
- kind: 'entry',
176
- parentPath,
177
- entryName: entry.name,
178
- });
179
- if (entry.kind !== 'directory' || entry.node === undefined) {
180
- continue;
181
- }
182
- cursors.push(...cursorsInNode(entry.node, [...parentPath, entry.name]));
183
- }
184
- if (node.foldedEntries.length > 0) {
185
- cursors.push({
186
- kind: 'fold',
187
- parentPath,
188
- });
189
- }
190
- return cursors;
191
- }
192
- function cursorBelongsToSubtree(cursor, entryPath) {
193
- if (cursor.kind === 'fold') {
194
- return UnixEntryPath.isStrictPathPrefix(entryPath, cursor.parentPath);
195
- }
196
- const cursorPath = [...cursor.parentPath, cursor.entryName];
197
- return UnixEntryPath.isStrictPathPrefix(entryPath, cursorPath);
198
- }
@@ -1,12 +0,0 @@
1
- import { UnixEntry } from './unix-entry.js';
2
- import type { FoldNode } from './fold-node.js';
3
- import { Cursor } from './cursor.js';
4
- export type State = {
5
- buffer: UnixEntry[];
6
- folds: FoldNode;
7
- cursor: Cursor;
8
- };
9
- export declare const View: {
10
- getEntryAtCursor(view: State): UnixEntry | undefined;
11
- };
12
- //# sourceMappingURL=state.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"state.d.ts","sourceRoot":"","sources":["../../src/domain/state.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAC5C,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAC/C,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAErC,MAAM,MAAM,KAAK,GAAG;IAClB,MAAM,EAAE,SAAS,EAAE,CAAC;IACpB,KAAK,EAAE,QAAQ,CAAC;IAChB,MAAM,EAAE,MAAM,CAAC;CAChB,CAAC;AAEF,eAAO,MAAM,IAAI;2BACQ,KAAK,GAAG,SAAS,GAAG,SAAS;CAUrD,CAAA"}
@@ -1,12 +0,0 @@
1
- import { UnixEntry } from './unix-entry.js';
2
- import { Cursor } from './cursor.js';
3
- export const View = {
4
- getEntryAtCursor(view) {
5
- const path = Cursor.getPath(view.cursor);
6
- // Nothing on folds
7
- if (path === undefined) {
8
- return undefined;
9
- }
10
- return UnixEntry.getEntryAtPath(view.buffer, path);
11
- }
12
- };
@@ -1,28 +0,0 @@
1
- import { z } from 'zod';
2
- import { UnixPath } from './unix-path.js';
3
- export declare const UnixEntryNameSchema: z.ZodString;
4
- export type UnixEntryName = z.output<typeof UnixEntryNameSchema>;
5
- export declare function entryNamesEqual(left: UnixEntryName[], right: UnixEntryName[]): boolean;
6
- export type UnixEntry = {
7
- kind: 'file';
8
- name: UnixEntryName;
9
- } | {
10
- kind: 'symlink';
11
- name: UnixEntryName;
12
- target: UnixPath;
13
- } | {
14
- kind: 'directory';
15
- name: UnixEntryName;
16
- entries?: UnixEntry[];
17
- };
18
- export declare const UnixEntry: {
19
- getEntryAtPath(entries: UnixEntry[], path: UnixEntryPath): UnixEntry | undefined;
20
- getEntriesAtPath(entries: UnixEntry[], path: UnixEntryPath): UnixEntry[] | undefined;
21
- setEntriesAtPath(entries: UnixEntry[], path: UnixEntryPath, newEntries: UnixEntry[] | undefined): UnixEntry[];
22
- };
23
- export type UnixEntryPath = UnixEntryName[];
24
- export declare const UnixEntryPath: {
25
- equal(left: UnixEntryPath, right: UnixEntryPath): boolean;
26
- isStrictPathPrefix(prefix: UnixEntryPath, path: UnixEntryPath): boolean;
27
- };
28
- //# sourceMappingURL=unix-entry.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"unix-entry.d.ts","sourceRoot":"","sources":["../../src/domain/unix-entry.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAI1C,eAAO,MAAM,mBAAmB,aAQ5B,CAAC;AAEL,MAAM,MAAM,aAAa,GAAG,CAAC,CAAC,MAAM,CAAC,OAAO,mBAAmB,CAAC,CAAC;AAEjE,wBAAgB,eAAe,CAC7B,IAAI,EAAE,aAAa,EAAE,EACrB,KAAK,EAAE,aAAa,EAAE,GACrB,OAAO,CAKT;AAED,MAAM,MAAM,SAAS,GACjB;IACE,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,aAAa,CAAC;CACrB,GACD;IACE,IAAI,EAAE,SAAS,CAAC;IAChB,IAAI,EAAE,aAAa,CAAC;IACpB,MAAM,EAAE,QAAQ,CAAC;CAClB,GACD;IACE,IAAI,EAAE,WAAW,CAAC;IAClB,IAAI,EAAE,aAAa,CAAC;IAEpB,OAAO,CAAC,EAAE,SAAS,EAAE,CAAC;CACvB,CAAC;AAEN,eAAO,MAAM,SAAS;4BAGT,SAAS,EAAE,QACd,aAAa,GAClB,SAAS,GAAG,SAAS;8BA6Bb,SAAS,EAAE,QACd,aAAa,GAClB,SAAS,EAAE,GAAG,SAAS;8BAgBf,SAAS,EAAE,QACd,aAAa,cACP,SAAS,EAAE,GAAG,SAAS,GAClC,SAAS,EAAE;CAyDf,CAAC;AAEF,MAAM,MAAM,aAAa,GAAG,aAAa,EAAE,CAAC;AAE5C,eAAO,MAAM,aAAa;gBACZ,aAAa,SAAS,aAAa,GAAG,OAAO;+BAK/C,aAAa,QACf,aAAa,GAClB,OAAO;CAOX,CAAA"}
@@ -1,96 +0,0 @@
1
- import { z } from 'zod';
2
- // UNIX ENTRY
3
- export const UnixEntryNameSchema = z
4
- .string()
5
- .min(1)
6
- .refine((value) => !value.includes('/'), {
7
- message: "Entry name must not contain '/'",
8
- })
9
- .refine((value) => value !== '.' && value !== '..', {
10
- message: "Entry name cannot be '.' or '..'",
11
- });
12
- export function entryNamesEqual(left, right) {
13
- return (left.length === right.length &&
14
- left.every((name, index) => name === right[index]));
15
- }
16
- export const UnixEntry = {
17
- // Query-Like
18
- getEntryAtPath(entries, path) {
19
- if (path.length === 0) {
20
- return undefined;
21
- }
22
- let entry;
23
- for (const [index, name] of path.entries()) {
24
- entry = entries.find((candidate) => candidate.name === name);
25
- if (entry === undefined) {
26
- return undefined;
27
- }
28
- if (index === path.length - 1) {
29
- return entry;
30
- }
31
- if (entry.kind !== 'directory' || entry.entries === undefined) {
32
- return undefined;
33
- }
34
- entries = entry.entries;
35
- }
36
- return undefined;
37
- },
38
- getEntriesAtPath(entries, path) {
39
- if (path.length === 0) {
40
- return entries;
41
- }
42
- const entry = UnixEntry.getEntryAtPath(entries, path);
43
- if (entry?.kind !== 'directory') {
44
- return undefined;
45
- }
46
- return entry.entries;
47
- },
48
- // Command/Modifer-Like
49
- setEntriesAtPath(entries, path, newEntries) {
50
- const [currentName, ...remainingPath] = path;
51
- if (currentName === undefined) {
52
- throw new Error('Cannot update directory entries with an empty path');
53
- }
54
- let found = false;
55
- const updatedEntries = entries.map((entry) => {
56
- if (entry.name !== currentName) {
57
- return entry;
58
- }
59
- found = true;
60
- if (remainingPath.length === 0) {
61
- if (entry.kind !== 'directory') {
62
- throw new Error(`Cannot update entries for non-directory entry "${entry.name}"`);
63
- }
64
- return {
65
- ...entry,
66
- entries: newEntries,
67
- };
68
- }
69
- if (entry.kind !== 'directory') {
70
- throw new Error(`Cannot descend through non-directory entry "${entry.name}"`);
71
- }
72
- if (entry.entries === undefined) {
73
- throw new Error(`Cannot descend into unexpanded directory "${entry.name}"`);
74
- }
75
- return {
76
- ...entry,
77
- entries: UnixEntry.setEntriesAtPath(entry.entries, remainingPath, newEntries),
78
- };
79
- });
80
- if (!found) {
81
- throw new Error(`Directory path does not contain entry "${currentName}"`);
82
- }
83
- return updatedEntries;
84
- },
85
- };
86
- export const UnixEntryPath = {
87
- equal(left, right) {
88
- return entryNamesEqual(left, right);
89
- },
90
- isStrictPathPrefix(prefix, path) {
91
- if (path.length <= prefix.length) {
92
- return false;
93
- }
94
- return prefix.every((name, index) => path[index] === name);
95
- }
96
- };
@@ -1,15 +0,0 @@
1
- import { UnixEntry } from './unix-entry.js';
2
- import type { FoldNode } from './fold-node.js';
3
- import { Cursor } from './cursor.js';
4
- export type DirectoryBuffer = {
5
- entries: UnixEntry[];
6
- };
7
- export type View = {
8
- buffer: DirectoryBuffer;
9
- folds: FoldNode;
10
- cursor: Cursor;
11
- };
12
- export declare const View: {
13
- getEntryAtCursor(view: View): UnixEntry | undefined;
14
- };
15
- //# sourceMappingURL=view.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"view.d.ts","sourceRoot":"","sources":["../../src/domain/view.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAC5C,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAC/C,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAErC,MAAM,MAAM,eAAe,GAAG;IAC5B,OAAO,EAAE,SAAS,EAAE,CAAC;CACtB,CAAC;AAEF,MAAM,MAAM,IAAI,GAAG;IACjB,MAAM,EAAE,eAAe,CAAC;IACxB,KAAK,EAAE,QAAQ,CAAC;IAChB,MAAM,EAAE,MAAM,CAAC;CAChB,CAAC;AAEF,eAAO,MAAM,IAAI;2BACQ,IAAI,GAAG,SAAS,GAAG,SAAS;CAUpD,CAAA"}
@@ -1,12 +0,0 @@
1
- import { UnixEntry } from './unix-entry.js';
2
- import { Cursor } from './cursor.js';
3
- export const View = {
4
- getEntryAtCursor(view) {
5
- const path = Cursor.getPath(view.cursor);
6
- // Nothing on folds
7
- if (path === undefined) {
8
- return undefined;
9
- }
10
- return UnixEntry.getEntryAtPath(view.buffer.entries, path);
11
- }
12
- };
@@ -1,3 +0,0 @@
1
- import type { UnixAbsolutePath } from '../domain/unix-path.js';
2
- export declare function getCwdAbsPath(): UnixAbsolutePath;
3
- //# sourceMappingURL=get-cwd.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"get-cwd.d.ts","sourceRoot":"","sources":["../../src/infrastructure/get-cwd.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAG/D,wBAAgB,aAAa,IAAI,gBAAgB,CAgBhD"}
@@ -1,13 +0,0 @@
1
- import { UnixAbsolutePathSchema } from '../domain/unix-path.js';
2
- export function getCwdAbsPath() {
3
- const currentWorkingDirectory = process.cwd();
4
- const result = UnixAbsolutePathSchema.safeParse(currentWorkingDirectory);
5
- if (!result.success) {
6
- const details = result.error.issues
7
- .map((issue) => issue.message)
8
- .join('; ');
9
- throw new Error(`Bad path for current working directory ` +
10
- `"${currentWorkingDirectory}": ${details}`);
11
- }
12
- return result.data;
13
- }
@@ -1,4 +0,0 @@
1
- import type { UnixAbsolutePath } from '../domain/unix-path.js';
2
- import type { UnixEntry } from '../domain/unix-entry.js';
3
- export declare function getDirLazyEntries(address: UnixAbsolutePath): Promise<UnixEntry[]>;
4
- //# sourceMappingURL=get-dir-lazy-entries.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"get-dir-lazy-entries.d.ts","sourceRoot":"","sources":["../../src/infrastructure/get-dir-lazy-entries.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAE/D,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,yBAAyB,CAAC;AAGzD,wBAAsB,iBAAiB,CACrC,OAAO,EAAE,gBAAgB,GACxB,OAAO,CAAC,SAAS,EAAE,CAAC,CAyCtB"}
@@ -1,34 +0,0 @@
1
- import { readdir, readlink } from 'node:fs/promises';
2
- import { join } from 'node:path';
3
- import { UnixPathSchema } from '../domain/unix-path.js';
4
- import { UnixEntryNameSchema } from '../domain/unix-entry.js';
5
- export async function getDirLazyEntries(address) {
6
- const directoryEntries = await readdir(address, {
7
- withFileTypes: true,
8
- });
9
- return Promise.all(directoryEntries.map(async (directoryEntry) => {
10
- const name = UnixEntryNameSchema.parse(directoryEntry.name);
11
- if (directoryEntry.isSymbolicLink()) {
12
- const target = UnixPathSchema.parse(await readlink(join(address, directoryEntry.name)));
13
- return {
14
- kind: 'symlink',
15
- name,
16
- target,
17
- };
18
- }
19
- if (directoryEntry.isDirectory()) {
20
- return {
21
- kind: 'directory',
22
- name,
23
- // Deliberately omitted: this directory has not been expanded.
24
- };
25
- }
26
- if (directoryEntry.isFile()) {
27
- return {
28
- kind: 'file',
29
- name,
30
- };
31
- }
32
- throw new Error(`Unsupported filesystem entry "${join(address, directoryEntry.name)}"`);
33
- }));
34
- }