dirvi-lib 0.2.0 → 0.4.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 (58) hide show
  1. package/dist/application/intent-to-effect-no-state.test.d.ts +2 -0
  2. package/dist/application/intent-to-effect-no-state.test.d.ts.map +1 -0
  3. package/dist/application/intent-to-effect-no-state.test.js +178 -0
  4. package/dist/application/intent-to-effect.d.ts +8 -0
  5. package/dist/application/intent-to-effect.d.ts.map +1 -0
  6. package/dist/application/intent-to-effect.js +142 -0
  7. package/dist/application/intent-to-effect.test-no-state.d.ts +2 -0
  8. package/dist/application/intent-to-effect.test-no-state.d.ts.map +1 -0
  9. package/dist/application/intent-to-effect.test-no-state.js +178 -0
  10. package/dist/application/user-input-to-intent.d.ts +8 -0
  11. package/dist/application/user-input-to-intent.d.ts.map +1 -0
  12. package/dist/application/user-input-to-intent.js +98 -0
  13. package/dist/application/user-input-to-intent.test.d.ts +2 -0
  14. package/dist/application/user-input-to-intent.test.d.ts.map +1 -0
  15. package/dist/application/user-input-to-intent.test.js +125 -0
  16. package/dist/domain/cursor.d.ts +19 -0
  17. package/dist/domain/cursor.d.ts.map +1 -0
  18. package/dist/domain/cursor.js +46 -0
  19. package/dist/domain/display-row.d.ts +31 -24
  20. package/dist/domain/display-row.d.ts.map +1 -1
  21. package/dist/domain/display-row.js +22 -16
  22. package/dist/domain/effect.d.ts +48 -0
  23. package/dist/domain/effect.d.ts.map +1 -0
  24. package/dist/domain/effect.js +1 -0
  25. package/dist/domain/fold-node.d.ts +25 -0
  26. package/dist/domain/fold-node.d.ts.map +1 -0
  27. package/dist/domain/fold-node.js +93 -0
  28. package/dist/domain/input-state.d.ts +10 -0
  29. package/dist/domain/input-state.d.ts.map +1 -0
  30. package/dist/domain/input-state.js +1 -0
  31. package/dist/domain/intent.d.ts +34 -0
  32. package/dist/domain/intent.d.ts.map +1 -0
  33. package/dist/domain/intent.js +1 -0
  34. package/dist/domain/navigation-node.d.ts +58 -0
  35. package/dist/domain/navigation-node.d.ts.map +1 -0
  36. package/dist/domain/navigation-node.js +210 -0
  37. package/dist/domain/state.d.ts +12 -0
  38. package/dist/domain/state.d.ts.map +1 -0
  39. package/dist/domain/state.js +12 -0
  40. package/dist/domain/unix-entry.d.ts +39 -13
  41. package/dist/domain/unix-entry.d.ts.map +1 -1
  42. package/dist/domain/unix-entry.js +101 -8
  43. package/dist/domain/unix-path.d.ts +1 -1
  44. package/dist/domain/unix-path.js +9 -6
  45. package/dist/domain/user-input.d.ts +27 -0
  46. package/dist/domain/user-input.d.ts.map +1 -0
  47. package/dist/domain/user-input.js +1 -0
  48. package/dist/index.d.ts +10 -2
  49. package/dist/index.d.ts.map +1 -1
  50. package/dist/index.js +9 -1
  51. package/dist/infrastructure/get-cwd.d.ts +1 -1
  52. package/dist/infrastructure/get-cwd.js +12 -10
  53. package/dist/infrastructure/get-dir-lazy-entries.d.ts +4 -2
  54. package/dist/infrastructure/get-dir-lazy-entries.js +34 -28
  55. package/package.json +4 -2
  56. package/dist/domain/view.d.ts +0 -17
  57. package/dist/domain/view.d.ts.map +0 -1
  58. package/dist/domain/view.js +0 -6
@@ -0,0 +1,210 @@
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:
36
+ entry.entries === undefined
37
+ ? undefined
38
+ : NavigationNode.from(entry.entries, childFoldNode),
39
+ };
40
+ break;
41
+ }
42
+ }
43
+ if (foldedNames.has(entry.name)) {
44
+ foldedEntries.push(navigationEntry);
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(
61
+ (candidate) => candidate.name === currentName,
62
+ );
63
+ if (entry === undefined || entry.kind !== 'directory') {
64
+ return undefined;
65
+ }
66
+ // The directory has not been loaded/opened.
67
+ if (entry.node === undefined) {
68
+ return undefined;
69
+ }
70
+ return NavigationNode.getNodeAtPath(entry.node, remainingPath);
71
+ },
72
+ getEntryAtPath(navigation, path) {
73
+ const [currentName, ...remainingPath] = path;
74
+ if (currentName === undefined) {
75
+ return undefined;
76
+ }
77
+ const entry = [...navigation.entries, ...navigation.foldedEntries].find(
78
+ (candidate) => candidate.name === currentName,
79
+ );
80
+ if (entry === undefined) {
81
+ return undefined;
82
+ }
83
+ if (remainingPath.length === 0) {
84
+ return entry;
85
+ }
86
+ if (entry.kind !== 'directory' || entry.node === undefined) {
87
+ return undefined;
88
+ }
89
+ return NavigationNode.getEntryAtPath(entry.node, remainingPath);
90
+ },
91
+ nextCursor(rootNode, cursor) {
92
+ const cursors = cursorsInNode(rootNode, []);
93
+ const currentIndex = cursors.findIndex((candidate) =>
94
+ Cursor.equal(candidate, cursor),
95
+ );
96
+ if (currentIndex === -1 || currentIndex === cursors.length - 1) {
97
+ return undefined;
98
+ }
99
+ return cursors[currentIndex + 1];
100
+ },
101
+ previousCursor(rootNode, cursor) {
102
+ const cursors = cursorsInNode(rootNode, []);
103
+ const currentIndex = cursors.findIndex((candidate) =>
104
+ Cursor.equal(candidate, cursor),
105
+ );
106
+ if (currentIndex <= 0) {
107
+ return undefined;
108
+ }
109
+ return cursors[currentIndex - 1];
110
+ },
111
+ cursorAfterFold(rootNode, cursor) {
112
+ if (cursor.kind === 'fold') {
113
+ return undefined;
114
+ }
115
+ const cursors = cursorsInNode(rootNode, []);
116
+ const currentIndex = cursors.findIndex((candidate) =>
117
+ Cursor.equal(candidate, cursor),
118
+ );
119
+ if (currentIndex === -1) {
120
+ return undefined;
121
+ }
122
+ const foldedPath = [...cursor.parentPath, cursor.entryName];
123
+ for (let index = currentIndex + 1; index < cursors.length; index += 1) {
124
+ const candidate = cursors[index];
125
+ if (candidate === undefined) {
126
+ continue;
127
+ }
128
+ if (cursorBelongsToSubtree(candidate, foldedPath)) {
129
+ continue;
130
+ }
131
+ return candidate;
132
+ }
133
+ // The fold row will be created at the end of this directory.
134
+ return {
135
+ kind: 'fold',
136
+ parentPath: cursor.parentPath,
137
+ };
138
+ },
139
+ parentCursor(navigation, cursor) {
140
+ const parentPath = cursor.parentPath;
141
+ // The cursor is already in the root directory.
142
+ if (parentPath.length === 0) {
143
+ return undefined;
144
+ }
145
+ const entryName = parentPath.at(-1);
146
+ if (entryName === undefined) {
147
+ return undefined;
148
+ }
149
+ const containingPath = parentPath.slice(0, -1);
150
+ const entry = NavigationNode.getEntryAtPath(navigation, parentPath);
151
+ if (entry === undefined || entry.kind !== 'directory') {
152
+ return undefined;
153
+ }
154
+ return {
155
+ kind: 'entry',
156
+ parentPath: containingPath,
157
+ entryName,
158
+ };
159
+ },
160
+ visibleFilesPaths(navigation, parentPath = []) {
161
+ const paths = [];
162
+ for (const entry of navigation.entries) {
163
+ const entryPath = [...parentPath, entry.name];
164
+ switch (entry.kind) {
165
+ case 'file':
166
+ paths.push(entryPath);
167
+ break;
168
+ case 'symlink':
169
+ // Do not recurse through symlinks.
170
+ break;
171
+ case 'directory':
172
+ if (entry.node !== undefined) {
173
+ paths.push(
174
+ ...NavigationNode.visibleFilesPaths(entry.node, entryPath),
175
+ );
176
+ }
177
+ break;
178
+ }
179
+ }
180
+ return paths;
181
+ },
182
+ };
183
+ function cursorsInNode(node, parentPath) {
184
+ const cursors = [];
185
+ for (const entry of node.entries) {
186
+ cursors.push({
187
+ kind: 'entry',
188
+ parentPath,
189
+ entryName: entry.name,
190
+ });
191
+ if (entry.kind !== 'directory' || entry.node === undefined) {
192
+ continue;
193
+ }
194
+ cursors.push(...cursorsInNode(entry.node, [...parentPath, entry.name]));
195
+ }
196
+ if (node.foldedEntries.length > 0) {
197
+ cursors.push({
198
+ kind: 'fold',
199
+ parentPath,
200
+ });
201
+ }
202
+ return cursors;
203
+ }
204
+ function cursorBelongsToSubtree(cursor, entryPath) {
205
+ if (cursor.kind === 'fold') {
206
+ return UnixEntryPath.isStrictPathPrefix(entryPath, cursor.parentPath);
207
+ }
208
+ const cursorPath = [...cursor.parentPath, cursor.entryName];
209
+ return UnixEntryPath.isStrictPathPrefix(entryPath, cursorPath);
210
+ }
@@ -0,0 +1,12 @@
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
@@ -0,0 +1 @@
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,CAAC"}
@@ -0,0 +1,12 @@
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
+ };
@@ -2,17 +2,43 @@ import { z } from 'zod';
2
2
  import { UnixPath } from './unix-path.js';
3
3
  export declare const UnixEntryNameSchema: z.ZodString;
4
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[];
5
+ export declare function entryNamesEqual(
6
+ left: UnixEntryName[],
7
+ right: UnixEntryName[],
8
+ ): boolean;
9
+ export type UnixEntry =
10
+ | {
11
+ kind: 'file';
12
+ name: UnixEntryName;
13
+ }
14
+ | {
15
+ kind: 'symlink';
16
+ name: UnixEntryName;
17
+ target: UnixPath;
18
+ }
19
+ | {
20
+ kind: 'directory';
21
+ name: UnixEntryName;
22
+ entries?: UnixEntry[];
23
+ };
24
+ export declare const UnixEntry: {
25
+ getEntryAtPath(
26
+ entries: UnixEntry[],
27
+ path: UnixEntryPath,
28
+ ): UnixEntry | undefined;
29
+ getEntriesAtPath(
30
+ entries: UnixEntry[],
31
+ path: UnixEntryPath,
32
+ ): UnixEntry[] | undefined;
33
+ setEntriesAtPath(
34
+ entries: UnixEntry[],
35
+ path: UnixEntryPath,
36
+ newEntries: UnixEntry[] | undefined,
37
+ ): UnixEntry[];
17
38
  };
18
- //# sourceMappingURL=unix-entry.d.ts.map
39
+ export type UnixEntryPath = UnixEntryName[];
40
+ export declare const UnixEntryPath: {
41
+ equal(left: UnixEntryPath, right: UnixEntryPath): boolean;
42
+ isStrictPathPrefix(prefix: UnixEntryPath, path: UnixEntryPath): boolean;
43
+ };
44
+ //# sourceMappingURL=unix-entry.d.ts.map
@@ -1 +1 @@
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;AAG1C,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"}
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;AAG1C,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;+BAI9B,aAAa,QAAQ,aAAa,GAAG,OAAO;CAOxE,CAAC"}
@@ -1,15 +1,108 @@
1
1
  import { z } from 'zod';
2
2
  // UNIX ENTRY
3
3
  export const UnixEntryNameSchema = z
4
- .string()
5
- .min(1)
6
- .refine((value) => !value.includes('/'), {
4
+ .string()
5
+ .min(1)
6
+ .refine((value) => !value.includes('/'), {
7
7
  message: "Entry name must not contain '/'",
8
- })
9
- .refine((value) => value !== '.' && value !== '..', {
8
+ })
9
+ .refine((value) => value !== '.' && value !== '..', {
10
10
  message: "Entry name cannot be '.' or '..'",
11
- });
11
+ });
12
12
  export function entryNamesEqual(left, right) {
13
- return (left.length === right.length &&
14
- left.every((name, index) => name === right[index]));
13
+ return (
14
+ left.length === right.length &&
15
+ left.every((name, index) => name === right[index])
16
+ );
15
17
  }
18
+ export const UnixEntry = {
19
+ // Query-Like
20
+ getEntryAtPath(entries, path) {
21
+ if (path.length === 0) {
22
+ return undefined;
23
+ }
24
+ let entry;
25
+ for (const [index, name] of path.entries()) {
26
+ entry = entries.find((candidate) => candidate.name === name);
27
+ if (entry === undefined) {
28
+ return undefined;
29
+ }
30
+ if (index === path.length - 1) {
31
+ return entry;
32
+ }
33
+ if (entry.kind !== 'directory' || entry.entries === undefined) {
34
+ return undefined;
35
+ }
36
+ entries = entry.entries;
37
+ }
38
+ return undefined;
39
+ },
40
+ getEntriesAtPath(entries, path) {
41
+ if (path.length === 0) {
42
+ return entries;
43
+ }
44
+ const entry = UnixEntry.getEntryAtPath(entries, path);
45
+ if (entry?.kind !== 'directory') {
46
+ return undefined;
47
+ }
48
+ return entry.entries;
49
+ },
50
+ // Command/Modifer-Like
51
+ setEntriesAtPath(entries, path, newEntries) {
52
+ const [currentName, ...remainingPath] = path;
53
+ if (currentName === undefined) {
54
+ throw new Error('Cannot update directory entries with an empty path');
55
+ }
56
+ let found = false;
57
+ const updatedEntries = entries.map((entry) => {
58
+ if (entry.name !== currentName) {
59
+ return entry;
60
+ }
61
+ found = true;
62
+ if (remainingPath.length === 0) {
63
+ if (entry.kind !== 'directory') {
64
+ throw new Error(
65
+ `Cannot update entries for non-directory entry "${entry.name}"`,
66
+ );
67
+ }
68
+ return {
69
+ ...entry,
70
+ entries: newEntries,
71
+ };
72
+ }
73
+ if (entry.kind !== 'directory') {
74
+ throw new Error(
75
+ `Cannot descend through non-directory entry "${entry.name}"`,
76
+ );
77
+ }
78
+ if (entry.entries === undefined) {
79
+ throw new Error(
80
+ `Cannot descend into unexpanded directory "${entry.name}"`,
81
+ );
82
+ }
83
+ return {
84
+ ...entry,
85
+ entries: UnixEntry.setEntriesAtPath(
86
+ entry.entries,
87
+ remainingPath,
88
+ newEntries,
89
+ ),
90
+ };
91
+ });
92
+ if (!found) {
93
+ throw new Error(`Directory path does not contain entry "${currentName}"`);
94
+ }
95
+ return updatedEntries;
96
+ },
97
+ };
98
+ export const UnixEntryPath = {
99
+ equal(left, right) {
100
+ return entryNamesEqual(left, right);
101
+ },
102
+ isStrictPathPrefix(prefix, path) {
103
+ if (path.length <= prefix.length) {
104
+ return false;
105
+ }
106
+ return prefix.every((name, index) => path[index] === name);
107
+ },
108
+ };
@@ -3,4 +3,4 @@ export declare const UnixPathSchema: z.ZodString;
3
3
  export type UnixPath = z.output<typeof UnixPathSchema>;
4
4
  export declare const UnixAbsolutePathSchema: z.ZodString;
5
5
  export type UnixAbsolutePath = z.output<typeof UnixAbsolutePathSchema>;
6
- //# sourceMappingURL=unix-path.d.ts.map
6
+ //# sourceMappingURL=unix-path.d.ts.map
@@ -1,11 +1,14 @@
1
1
  import { z } from 'zod';
2
2
  // UNIX PATHS
3
3
  export const UnixPathSchema = z
4
- .string()
5
- .min(1)
6
- .refine((value) => !value.includes('\0'), {
4
+ .string()
5
+ .min(1)
6
+ .refine((value) => !value.includes('\0'), {
7
7
  message: 'Unix paths must not contain null bytes',
8
- });
9
- export const UnixAbsolutePathSchema = UnixPathSchema.refine((value) => value.startsWith('/'), {
8
+ });
9
+ export const UnixAbsolutePathSchema = UnixPathSchema.refine(
10
+ (value) => value.startsWith('/'),
11
+ {
10
12
  message: 'Path must be an absolute Unix path',
11
- });
13
+ },
14
+ );
@@ -0,0 +1,27 @@
1
+ export type UserInput =
2
+ | {
3
+ userInputType: 'character';
4
+ string: string;
5
+ }
6
+ | {
7
+ userInputType: 'enter';
8
+ }
9
+ | {
10
+ userInputType: 'backspace';
11
+ }
12
+ | {
13
+ userInputType: 'esc';
14
+ }
15
+ | {
16
+ userInputType: 'rightArrow';
17
+ }
18
+ | {
19
+ userInputType: 'leftArrow';
20
+ }
21
+ | {
22
+ userInputType: 'downArrow';
23
+ }
24
+ | {
25
+ userInputType: 'upArrow';
26
+ };
27
+ //# sourceMappingURL=user-input.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"user-input.d.ts","sourceRoot":"","sources":["../../src/domain/user-input.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,SAAS,GACjB;IACE,aAAa,EAAE,WAAW,CAAC;IAC3B,MAAM,EAAE,MAAM,CAAC;CAChB,GACD;IACE,aAAa,EAAE,OAAO,CAAC;CACxB,GACD;IACE,aAAa,EAAE,WAAW,CAAC;CAC5B,GACD;IACE,aAAa,EAAE,KAAK,CAAC;CACtB,GACD;IACE,aAAa,EAAE,YAAY,CAAC;CAC7B,GACD;IACE,aAAa,EAAE,WAAW,CAAC;CAC5B,GACD;IACE,aAAa,EAAE,WAAW,CAAC;CAC5B,GACD;IACE,aAAa,EAAE,SAAS,CAAC;CAC1B,CAAC"}
@@ -0,0 +1 @@
1
+ export {};
package/dist/index.d.ts CHANGED
@@ -1,7 +1,15 @@
1
+ export * from './application/user-input-to-intent.js';
2
+ export * from './application/intent-to-effect.js';
3
+ export * from './domain/cursor.js';
1
4
  export * from './domain/display-row.js';
5
+ export * from './domain/effect.js';
6
+ export * from './domain/fold-node.js';
7
+ export * from './domain/input-state.js';
8
+ export * from './domain/navigation-node.js';
9
+ export * from './domain/state.js';
2
10
  export * from './domain/unix-entry.js';
3
11
  export * from './domain/unix-path.js';
4
- export * from './domain/view.js';
12
+ export * from './domain/user-input.js';
5
13
  export * from './infrastructure/get-cwd.js';
6
14
  export * from './infrastructure/get-dir-lazy-entries.js';
7
- //# sourceMappingURL=index.d.ts.map
15
+ //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,yBAAyB,CAAC;AACxC,cAAc,wBAAwB,CAAC;AACvC,cAAc,uBAAuB,CAAC;AACtC,cAAc,kBAAkB,CAAC;AAEjC,cAAc,6BAA6B,CAAC;AAC5C,cAAc,0CAA0C,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,uCAAuC,CAAC;AACtD,cAAc,mCAAmC,CAAC;AAElD,cAAc,oBAAoB,CAAC;AACnC,cAAc,yBAAyB,CAAC;AACxC,cAAc,oBAAoB,CAAC;AACnC,cAAc,uBAAuB,CAAC;AACtC,cAAc,yBAAyB,CAAC;AACxC,cAAc,6BAA6B,CAAC;AAC5C,cAAc,mBAAmB,CAAC;AAClC,cAAc,wBAAwB,CAAC;AACvC,cAAc,uBAAuB,CAAC;AACtC,cAAc,wBAAwB,CAAC;AAEvC,cAAc,6BAA6B,CAAC;AAC5C,cAAc,0CAA0C,CAAC"}
package/dist/index.js CHANGED
@@ -1,6 +1,14 @@
1
+ export * from './application/user-input-to-intent.js';
2
+ export * from './application/intent-to-effect.js';
3
+ export * from './domain/cursor.js';
1
4
  export * from './domain/display-row.js';
5
+ export * from './domain/effect.js';
6
+ export * from './domain/fold-node.js';
7
+ export * from './domain/input-state.js';
8
+ export * from './domain/navigation-node.js';
9
+ export * from './domain/state.js';
2
10
  export * from './domain/unix-entry.js';
3
11
  export * from './domain/unix-path.js';
4
- export * from './domain/view.js';
12
+ export * from './domain/user-input.js';
5
13
  export * from './infrastructure/get-cwd.js';
6
14
  export * from './infrastructure/get-dir-lazy-entries.js';
@@ -1,3 +1,3 @@
1
1
  import type { UnixAbsolutePath } from '../domain/unix-path.js';
2
2
  export declare function getCwdAbsPath(): UnixAbsolutePath;
3
- //# sourceMappingURL=get-cwd.d.ts.map
3
+ //# sourceMappingURL=get-cwd.d.ts.map
@@ -1,13 +1,15 @@
1
1
  import { UnixAbsolutePathSchema } from '../domain/unix-path.js';
2
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;
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(
10
+ `Bad path for current working directory ` +
11
+ `"${currentWorkingDirectory}": ${details}`,
12
+ );
13
+ }
14
+ return result.data;
13
15
  }
@@ -1,4 +1,6 @@
1
1
  import type { UnixAbsolutePath } from '../domain/unix-path.js';
2
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
3
+ export declare function getDirLazyEntries(
4
+ address: UnixAbsolutePath,
5
+ ): Promise<UnixEntry[]>;
6
+ //# sourceMappingURL=get-dir-lazy-entries.d.ts.map
@@ -3,32 +3,38 @@ import { join } from 'node:path';
3
3
  import { UnixPathSchema } from '../domain/unix-path.js';
4
4
  import { UnixEntryNameSchema } from '../domain/unix-entry.js';
5
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
- }));
6
+ const directoryEntries = await readdir(address, {
7
+ withFileTypes: true,
8
+ });
9
+ return Promise.all(
10
+ directoryEntries.map(async (directoryEntry) => {
11
+ const name = UnixEntryNameSchema.parse(directoryEntry.name);
12
+ if (directoryEntry.isSymbolicLink()) {
13
+ const target = UnixPathSchema.parse(
14
+ await readlink(join(address, directoryEntry.name)),
15
+ );
16
+ return {
17
+ kind: 'symlink',
18
+ name,
19
+ target,
20
+ };
21
+ }
22
+ if (directoryEntry.isDirectory()) {
23
+ return {
24
+ kind: 'directory',
25
+ name,
26
+ // Deliberately omitted: this directory has not been expanded.
27
+ };
28
+ }
29
+ if (directoryEntry.isFile()) {
30
+ return {
31
+ kind: 'file',
32
+ name,
33
+ };
34
+ }
35
+ throw new Error(
36
+ `Unsupported filesystem entry "${join(address, directoryEntry.name)}"`,
37
+ );
38
+ }),
39
+ );
34
40
  }
package/package.json CHANGED
@@ -1,10 +1,11 @@
1
1
  {
2
2
  "name": "dirvi-lib",
3
- "version": "0.2.0",
3
+ "version": "0.4.0",
4
4
  "description": "Dependency for dirvi apps.",
5
5
  "license": "LGPL-3.0-or-later",
6
6
  "type": "module",
7
7
  "main": "dist/index.js",
8
+ "types": "dist/index.d.ts",
8
9
  "files": [
9
10
  "dist"
10
11
  ],
@@ -17,6 +18,7 @@
17
18
  },
18
19
  "scripts": {
19
20
  "build": "tsc",
20
- "typecheck": "tsc --noEmit"
21
+ "typecheck": "tsc --noEmit",
22
+ "format": "prettier . --write"
21
23
  }
22
24
  }