@mak-98/dirvi-cli 0.3.2 → 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 (61) hide show
  1. package/dist/application/action.d.ts +25 -18
  2. package/dist/application/dir-buffer-helpers.d.ts +5 -2
  3. package/dist/application/dir-buffer-helpers.js +17 -17
  4. package/dist/application/display-rows.d.ts +10 -3
  5. package/dist/application/display-rows.d.ts.map +1 -1
  6. package/dist/application/display-rows.js +54 -41
  7. package/dist/application/effect-to-action.d.ts +7 -4
  8. package/dist/application/effect-to-action.d.ts.map +1 -1
  9. package/dist/application/effect-to-action.js +84 -75
  10. package/dist/application/fold-helpers.d.ts +22 -6
  11. package/dist/application/fold-helpers.js +36 -32
  12. package/dist/application/intent-to-effect.d.ts +57 -37
  13. package/dist/application/intent-to-effect.d.ts.map +1 -1
  14. package/dist/application/intent-to-effect.js +116 -103
  15. package/dist/application/reducer-action.d.ts +22 -18
  16. package/dist/application/reducer.d.ts +1 -1
  17. package/dist/application/reducer.d.ts.map +1 -1
  18. package/dist/application/reducer.js +40 -28
  19. package/dist/application/user-input-to-intent.d.ts +38 -14
  20. package/dist/application/user-input-to-intent.d.ts.map +1 -1
  21. package/dist/application/user-input-to-intent.js +103 -49
  22. package/dist/domain/event-message.d.ts +14 -11
  23. package/dist/domain/print-message.d.ts +10 -8
  24. package/dist/index.d.ts +1 -1
  25. package/dist/index.js +35 -30
  26. package/dist/infrastructure/ink-input-to-user-input.d.ts +7 -0
  27. package/dist/infrastructure/ink-input-to-user-input.d.ts.map +1 -0
  28. package/dist/infrastructure/ink-input-to-user-input.js +45 -0
  29. package/dist/infrastructure/input.d.ts +7 -2
  30. package/dist/infrastructure/input.js +71 -71
  31. package/dist/infrastructure/load-initial-props.d.ts +1 -1
  32. package/dist/infrastructure/load-initial-props.d.ts.map +1 -1
  33. package/dist/infrastructure/load-initial-props.js +32 -25
  34. package/dist/infrastructure/user-input.d.ts +31 -16
  35. package/dist/infrastructure/user-input.d.ts.map +1 -1
  36. package/dist/infrastructure/user-input.js +42 -32
  37. package/dist/ui/App.d.ts +11 -6
  38. package/dist/ui/App.d.ts.map +1 -1
  39. package/dist/ui/App.js +127 -89
  40. package/dist/ui/App2.d.ts +11 -6
  41. package/dist/ui/App2.js +95 -84
  42. package/dist/ui/AppShell.d.ts +12 -7
  43. package/dist/ui/AppShell.js +11 -6
  44. package/dist/ui/components/DirEntries.d.ts +8 -5
  45. package/dist/ui/components/DirEntries.js +56 -31
  46. package/dist/ui/components/StatusBar.d.ts +10 -0
  47. package/dist/ui/components/StatusBar.d.ts.map +1 -0
  48. package/dist/ui/components/StatusBar.js +32 -0
  49. package/dist/ui/components/UnixEntry.d.ts +8 -5
  50. package/dist/ui/components/UnixEntry.js +17 -10
  51. package/dist/ui/components/UnixEntryComponent.d.ts +8 -5
  52. package/dist/ui/components/UnixEntryComponent.js +17 -10
  53. package/dist/ui/components/ViewRowComponent.d.ts +6 -4
  54. package/dist/ui/components/ViewRowComponent.js +30 -10
  55. package/dist/ui/hooks/useView.d.ts +6 -2
  56. package/dist/ui/hooks/useView.d.ts.map +1 -1
  57. package/dist/ui/hooks/useView.js +30 -22
  58. package/dist/ui/view.d.ts +15 -10
  59. package/dist/ui/view.d.ts.map +1 -1
  60. package/dist/ui/view.js +63 -59
  61. package/package.json +3 -2
@@ -1,19 +1,26 @@
1
1
  import { UnixEntry, UnixEntryPath } from 'dirvi-lib';
2
- export type Action = {
3
- kind: 'nextEntry';
4
- } | {
5
- kind: 'prevEntry';
6
- } | {
7
- kind: 'updateDir';
8
- path: UnixEntryPath;
9
- entries: UnixEntry[] | undefined;
10
- } | {
11
- kind: 'outDir';
12
- } | {
13
- kind: 'toggleFold';
14
- } | {
15
- kind: 'fold';
16
- } | {
17
- kind: 'unfold';
18
- };
19
- //# sourceMappingURL=action.d.ts.map
2
+ export type Action =
3
+ | {
4
+ kind: 'nextEntry';
5
+ }
6
+ | {
7
+ kind: 'prevEntry';
8
+ }
9
+ | {
10
+ kind: 'updateDir';
11
+ path: UnixEntryPath;
12
+ entries: UnixEntry[] | undefined;
13
+ }
14
+ | {
15
+ kind: 'outDir';
16
+ }
17
+ | {
18
+ kind: 'toggleFold';
19
+ }
20
+ | {
21
+ kind: 'fold';
22
+ }
23
+ | {
24
+ kind: 'unfold';
25
+ };
26
+ //# sourceMappingURL=action.d.ts.map
@@ -1,3 +1,6 @@
1
1
  import type { UnixEntry, DirectoryBuffer, EntryPath } from 'dirvi-lib';
2
- export declare function entryAtPath(buffer: DirectoryBuffer, path: EntryPath): UnixEntry | undefined;
3
- //# sourceMappingURL=dir-buffer-helpers.d.ts.map
2
+ export declare function entryAtPath(
3
+ buffer: DirectoryBuffer,
4
+ path: EntryPath,
5
+ ): UnixEntry | undefined;
6
+ //# sourceMappingURL=dir-buffer-helpers.d.ts.map
@@ -1,21 +1,21 @@
1
1
  export function entryAtPath(buffer, path) {
2
- if (path.length === 0) {
3
- return undefined;
2
+ if (path.length === 0) {
3
+ return undefined;
4
+ }
5
+ let entries = buffer.entries;
6
+ let entry;
7
+ for (const [index, name] of path.entries()) {
8
+ entry = entries.find((candidate) => candidate.name === name);
9
+ if (entry === undefined) {
10
+ return undefined;
4
11
  }
5
- let entries = buffer.entries;
6
- let entry;
7
- for (const [index, name] of path.entries()) {
8
- entry = entries.find((candidate) => candidate.name === name);
9
- if (entry === undefined) {
10
- return undefined;
11
- }
12
- if (index === path.length - 1) {
13
- return entry;
14
- }
15
- if (entry.kind !== 'directory' || entry.entries === undefined) {
16
- return undefined;
17
- }
18
- entries = entry.entries;
12
+ if (index === path.length - 1) {
13
+ return entry;
19
14
  }
20
- return undefined;
15
+ if (entry.kind !== 'directory' || entry.entries === undefined) {
16
+ return undefined;
17
+ }
18
+ entries = entry.entries;
19
+ }
20
+ return undefined;
21
21
  }
@@ -1,4 +1,11 @@
1
1
  import { DisplayRow, UnixEntryPath, FoldNode, UnixEntry } from 'dirvi-lib';
2
- export declare function createDisplayRows(buffer: UnixEntry[], folds: FoldNode): DisplayRow[];
3
- export declare function displayRowAtPath(buffer: UnixEntry[], folds: FoldNode, path: UnixEntryPath): DisplayRow | undefined;
4
- //# sourceMappingURL=display-rows.d.ts.map
2
+ export declare function createDisplayRows(
3
+ buffer: UnixEntry[],
4
+ folds: FoldNode,
5
+ ): DisplayRow[];
6
+ export declare function displayRowAtPath(
7
+ buffer: UnixEntry[],
8
+ folds: FoldNode,
9
+ path: UnixEntryPath,
10
+ ): DisplayRow | undefined;
11
+ //# sourceMappingURL=display-rows.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"display-rows.d.ts","sourceRoot":"","sources":["../../src/application/display-rows.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,UAAU,EACV,aAAa,EAAE,QAAQ,EACvB,SAAS,EAEV,MAAM,WAAW,CAAC;AAuDnB,wBAAgB,iBAAiB,CAC/B,MAAM,EAAE,SAAS,EAAE,EACnB,KAAK,EAAE,QAAQ,GACd,UAAU,EAAE,CAEd;AAED,wBAAgB,gBAAgB,CAC9B,MAAM,EAAE,SAAS,EAAE,EACnB,KAAK,EAAE,QAAQ,EACf,IAAI,EAAE,aAAa,GAClB,UAAU,GAAG,SAAS,CAqBxB"}
1
+ {"version":3,"file":"display-rows.d.ts","sourceRoot":"","sources":["../../src/application/display-rows.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,UAAU,EACV,aAAa,EACb,QAAQ,EACR,SAAS,EAEV,MAAM,WAAW,CAAC;AAuDnB,wBAAgB,iBAAiB,CAC/B,MAAM,EAAE,SAAS,EAAE,EACnB,KAAK,EAAE,QAAQ,GACd,UAAU,EAAE,CAEd;AAED,wBAAgB,gBAAgB,CAC9B,MAAM,EAAE,SAAS,EAAE,EACnB,KAAK,EAAE,QAAQ,EACf,IAAI,EAAE,aAAa,GAClB,UAAU,GAAG,SAAS,CAsBxB"}
@@ -1,50 +1,63 @@
1
- import { UnixEntryPath, FoldNode, } from 'dirvi-lib';
1
+ import { UnixEntryPath, FoldNode } from 'dirvi-lib';
2
2
  function displayRowsAtPath(entries, path, foldNode) {
3
- const rows = [];
4
- let index = 0;
5
- while (index < entries.length) {
6
- const entry = entries[index];
7
- if (foldNode !== undefined && FoldNode.getIfEntryFolded(foldNode, entry)) {
8
- const entryNames = [];
9
- while (index < entries.length &&
10
- FoldNode.getIfEntryFolded(foldNode, entries[index])) {
11
- entryNames.push(entries[index].name);
12
- index += 1;
13
- }
14
- rows.push({
15
- kind: 'fold',
16
- parentPath: path,
17
- entryNames,
18
- });
19
- continue;
20
- }
21
- rows.push({
22
- kind: 'entry',
23
- parentPath: path,
24
- entry,
25
- });
26
- if (entry.kind === 'directory' && entry.entries !== undefined) {
27
- rows.push(...displayRowsAtPath(entry.entries, [...path, entry.name], foldNode?.children[entry.name]));
28
- }
3
+ const rows = [];
4
+ let index = 0;
5
+ while (index < entries.length) {
6
+ const entry = entries[index];
7
+ if (foldNode !== undefined && FoldNode.getIfEntryFolded(foldNode, entry)) {
8
+ const entryNames = [];
9
+ while (
10
+ index < entries.length &&
11
+ FoldNode.getIfEntryFolded(foldNode, entries[index])
12
+ ) {
13
+ entryNames.push(entries[index].name);
29
14
  index += 1;
15
+ }
16
+ rows.push({
17
+ kind: 'fold',
18
+ parentPath: path,
19
+ entryNames,
20
+ });
21
+ continue;
30
22
  }
31
- return rows;
23
+ rows.push({
24
+ kind: 'entry',
25
+ parentPath: path,
26
+ entry,
27
+ });
28
+ if (entry.kind === 'directory' && entry.entries !== undefined) {
29
+ rows.push(
30
+ ...displayRowsAtPath(
31
+ entry.entries,
32
+ [...path, entry.name],
33
+ foldNode?.children[entry.name],
34
+ ),
35
+ );
36
+ }
37
+ index += 1;
38
+ }
39
+ return rows;
32
40
  }
33
41
  export function createDisplayRows(buffer, folds) {
34
- return displayRowsAtPath(buffer, [], folds);
42
+ return displayRowsAtPath(buffer, [], folds);
35
43
  }
36
44
  export function displayRowAtPath(buffer, folds, path) {
37
- if (path.length === 0) {
38
- return undefined;
45
+ if (path.length === 0) {
46
+ return undefined;
47
+ }
48
+ const rows = createDisplayRows(buffer, folds);
49
+ const parentPath = path.slice(0, -1);
50
+ const entryName = path[path.length - 1];
51
+ return rows.find((row) => {
52
+ if (row.kind === 'entry') {
53
+ return (
54
+ row.entry.name === entryName &&
55
+ UnixEntryPath.equal(row.parentPath, parentPath)
56
+ );
39
57
  }
40
- const rows = createDisplayRows(buffer, folds);
41
- const parentPath = path.slice(0, -1);
42
- const entryName = path[path.length - 1];
43
- return rows.find((row) => {
44
- if (row.kind === 'entry') {
45
- return (row.entry.name === entryName && UnixEntryPath.equal(row.parentPath, parentPath));
46
- }
47
- return (UnixEntryPath.equal(row.parentPath, parentPath) &&
48
- row.entryNames.includes(entryName));
49
- });
58
+ return (
59
+ UnixEntryPath.equal(row.parentPath, parentPath) &&
60
+ row.entryNames.includes(entryName)
61
+ );
62
+ });
50
63
  }
@@ -1,5 +1,8 @@
1
- import { NavigationNode, State } from 'dirvi-lib';
1
+ import { NavigationNode, State, EffectAction } from 'dirvi-lib';
2
2
  import type { ReducerAction } from './reducer-action.js';
3
- import { EffectAction } from './intent-to-effect.js';
4
- export declare function effectToAction(effectAction: EffectAction, navigation: NavigationNode, state: State): ReducerAction | undefined;
5
- //# sourceMappingURL=effect-to-action.d.ts.map
3
+ export declare function effectToAction(
4
+ effectAction: EffectAction,
5
+ navigation: NavigationNode,
6
+ state: State,
7
+ ): ReducerAction | undefined;
8
+ //# sourceMappingURL=effect-to-action.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"effect-to-action.d.ts","sourceRoot":"","sources":["../../src/application/effect-to-action.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,KAAK,EAAE,MAAM,WAAW,CAAC;AAElD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AACzD,OAAO,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAC;AAErD,wBAAgB,cAAc,CAC5B,YAAY,EAAE,YAAY,EAC1B,UAAU,EAAE,cAAc,EAC1B,KAAK,EAAE,KAAK,GACX,aAAa,GAAG,SAAS,CAsG3B"}
1
+ {"version":3,"file":"effect-to-action.d.ts","sourceRoot":"","sources":["../../src/application/effect-to-action.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,KAAK,EAAE,YAAY,EAAE,MAAM,WAAW,CAAC;AAEhE,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AAEzD,wBAAgB,cAAc,CAC5B,YAAY,EAAE,YAAY,EAC1B,UAAU,EAAE,cAAc,EAC1B,KAAK,EAAE,KAAK,GACX,aAAa,GAAG,SAAS,CAwG3B"}
@@ -1,79 +1,88 @@
1
1
  import { NavigationNode } from 'dirvi-lib';
2
2
  export function effectToAction(effectAction, navigation, state) {
3
- switch (effectAction.kind) {
4
- case 'nextEntry': {
5
- const cursor = NavigationNode.nextCursor(navigation, state.cursor);
6
- return cursor === undefined
7
- ? undefined
8
- : {
9
- kind: 'changeCursor',
10
- cursor,
11
- };
12
- }
13
- case 'prevEntry': {
14
- const cursor = NavigationNode.previousCursor(navigation, state.cursor);
15
- return cursor === undefined
16
- ? undefined
17
- : {
18
- kind: 'changeCursor',
19
- cursor,
20
- };
21
- }
22
- case 'updateDir':
23
- return {
24
- kind: 'updateDir',
25
- path: effectAction.path,
26
- entries: effectAction.entries,
27
- };
28
- case 'outDir': {
29
- const cursor = NavigationNode.parentCursor(navigation, state.cursor);
30
- return cursor === undefined
31
- ? undefined
32
- : {
33
- kind: 'changeCursor',
34
- cursor,
35
- };
36
- }
37
- case 'fold': {
38
- if (state.cursor.kind === 'fold') {
39
- return undefined;
40
- }
41
- const path = [...state.cursor.parentPath, state.cursor.entryName];
42
- const entry = NavigationNode.getEntryAtPath(navigation, path);
43
- if (entry === undefined) {
44
- return undefined;
45
- }
46
- const cursor = NavigationNode.cursorAfterFold(navigation, state.cursor);
47
- if (cursor === undefined) {
48
- return undefined;
49
- }
50
- return {
51
- kind: 'fold',
52
- parentPath: state.cursor.parentPath,
53
- entry,
54
- cursor,
55
- };
56
- }
57
- case 'unfold': {
58
- if (state.cursor.kind !== 'fold') {
59
- return undefined;
60
- }
61
- const node = NavigationNode.getNodeAtPath(navigation, state.cursor.parentPath);
62
- if (node === undefined || node.foldedEntries.length === 0) {
63
- return undefined;
64
- }
65
- const firstFoldedEntry = node.foldedEntries[0];
66
- return {
67
- kind: 'unfold',
68
- parentPath: state.cursor.parentPath,
69
- cursor: {
70
- kind: 'entry',
71
- parentPath: state.cursor.parentPath,
72
- entryName: firstFoldedEntry.name,
73
- },
74
- };
75
- }
76
- case 'toggleFold':
77
- return effectToAction(state.cursor.kind === 'fold' ? { kind: 'unfold' } : { kind: 'fold' }, navigation, state);
3
+ switch (effectAction.effectActionType) {
4
+ case 'nextEntry': {
5
+ const cursor = NavigationNode.nextCursor(navigation, state.cursor);
6
+ return cursor === undefined
7
+ ? undefined
8
+ : {
9
+ kind: 'changeCursor',
10
+ cursor,
11
+ };
78
12
  }
13
+ case 'prevEntry': {
14
+ const cursor = NavigationNode.previousCursor(navigation, state.cursor);
15
+ return cursor === undefined
16
+ ? undefined
17
+ : {
18
+ kind: 'changeCursor',
19
+ cursor,
20
+ };
21
+ }
22
+ case 'updateDir':
23
+ return {
24
+ kind: 'updateDir',
25
+ path: effectAction.path,
26
+ entries: effectAction.entries,
27
+ };
28
+ case 'outDir': {
29
+ const cursor = NavigationNode.parentCursor(navigation, state.cursor);
30
+ return cursor === undefined
31
+ ? undefined
32
+ : {
33
+ kind: 'changeCursor',
34
+ cursor,
35
+ };
36
+ }
37
+ case 'fold': {
38
+ if (state.cursor.kind === 'fold') {
39
+ return undefined;
40
+ }
41
+ const path = [...state.cursor.parentPath, state.cursor.entryName];
42
+ const entry = NavigationNode.getEntryAtPath(navigation, path);
43
+ if (entry === undefined) {
44
+ return undefined;
45
+ }
46
+ const cursor = NavigationNode.cursorAfterFold(navigation, state.cursor);
47
+ if (cursor === undefined) {
48
+ return undefined;
49
+ }
50
+ return {
51
+ kind: 'fold',
52
+ parentPath: state.cursor.parentPath,
53
+ entry,
54
+ cursor,
55
+ };
56
+ }
57
+ case 'unfold': {
58
+ if (state.cursor.kind !== 'fold') {
59
+ return undefined;
60
+ }
61
+ const node = NavigationNode.getNodeAtPath(
62
+ navigation,
63
+ state.cursor.parentPath,
64
+ );
65
+ if (node === undefined || node.foldedEntries.length === 0) {
66
+ return undefined;
67
+ }
68
+ const firstFoldedEntry = node.foldedEntries[0];
69
+ return {
70
+ kind: 'unfold',
71
+ parentPath: state.cursor.parentPath,
72
+ cursor: {
73
+ kind: 'entry',
74
+ parentPath: state.cursor.parentPath,
75
+ entryName: firstFoldedEntry.name,
76
+ },
77
+ };
78
+ }
79
+ case 'toggleFold':
80
+ return effectToAction(
81
+ state.cursor.kind === 'fold'
82
+ ? { effectActionType: 'unfold' }
83
+ : { effectActionType: 'fold' },
84
+ navigation,
85
+ state,
86
+ );
87
+ }
79
88
  }
@@ -1,8 +1,24 @@
1
1
  import type { UnixEntry, UnixEntryName } from 'dirvi-lib';
2
2
  import { FoldNode } from 'dirvi-lib';
3
- export declare function hasFold(node: FoldNode, entryName: UnixEntryName): boolean;
4
- export declare function entryIsFolded(node: FoldNode | undefined, entry: UnixEntry): boolean;
5
- export declare function setFolds(node: FoldNode, entries: UnixEntry[]): FoldNode;
6
- export declare function addFold(node: FoldNode, entryName: UnixEntryName): FoldNode;
7
- export declare function unfoldFoldSequence(node: FoldNode, entries: UnixEntry[], entryName: UnixEntryName): FoldNode;
8
- //# sourceMappingURL=fold-helpers.d.ts.map
3
+ export declare function hasFold(
4
+ node: FoldNode,
5
+ entryName: UnixEntryName,
6
+ ): boolean;
7
+ export declare function entryIsFolded(
8
+ node: FoldNode | undefined,
9
+ entry: UnixEntry,
10
+ ): boolean;
11
+ export declare function setFolds(
12
+ node: FoldNode,
13
+ entries: UnixEntry[],
14
+ ): FoldNode;
15
+ export declare function addFold(
16
+ node: FoldNode,
17
+ entryName: UnixEntryName,
18
+ ): FoldNode;
19
+ export declare function unfoldFoldSequence(
20
+ node: FoldNode,
21
+ entries: UnixEntry[],
22
+ entryName: UnixEntryName,
23
+ ): FoldNode;
24
+ //# sourceMappingURL=fold-helpers.d.ts.map
@@ -1,43 +1,47 @@
1
1
  export function hasFold(node, entryName) {
2
- return node.folds.includes(entryName);
2
+ return node.folds.includes(entryName);
3
3
  }
4
4
  export function entryIsFolded(node, entry) {
5
- return node !== undefined && hasFold(node, entry.name);
5
+ return node !== undefined && hasFold(node, entry.name);
6
6
  }
7
7
  // Replaces all folds at a node
8
8
  export function setFolds(node, entries) {
9
- const entryNames = entries.map((entry) => entry.name);
10
- return {
11
- ...node,
12
- folds: entryNames,
13
- };
9
+ const entryNames = entries.map((entry) => entry.name);
10
+ return {
11
+ ...node,
12
+ folds: entryNames,
13
+ };
14
14
  }
15
15
  export function addFold(node, entryName) {
16
- if (hasFold(node, entryName)) {
17
- return node;
18
- }
19
- return {
20
- ...node,
21
- folds: [...node.folds, entryName],
22
- };
16
+ if (hasFold(node, entryName)) {
17
+ return node;
18
+ }
19
+ return {
20
+ ...node,
21
+ folds: [...node.folds, entryName],
22
+ };
23
23
  }
24
24
  export function unfoldFoldSequence(node, entries, entryName) {
25
- const entryIndex = entries.findIndex((entry) => entry.name === entryName);
26
- if (entryIndex === -1 || !hasFold(node, entryName)) {
27
- return node;
28
- }
29
- let firstIndex = entryIndex;
30
- while (firstIndex > 0 && hasFold(node, entries[firstIndex - 1].name)) {
31
- firstIndex -= 1;
32
- }
33
- let lastIndex = entryIndex;
34
- while (lastIndex < entries.length - 1 &&
35
- hasFold(node, entries[lastIndex + 1].name)) {
36
- lastIndex += 1;
37
- }
38
- const unfoldedNames = new Set(entries.slice(firstIndex, lastIndex + 1).map((entry) => entry.name));
39
- return {
40
- ...node,
41
- folds: node.folds.filter((foldedName) => !unfoldedNames.has(foldedName)),
42
- };
25
+ const entryIndex = entries.findIndex((entry) => entry.name === entryName);
26
+ if (entryIndex === -1 || !hasFold(node, entryName)) {
27
+ return node;
28
+ }
29
+ let firstIndex = entryIndex;
30
+ while (firstIndex > 0 && hasFold(node, entries[firstIndex - 1].name)) {
31
+ firstIndex -= 1;
32
+ }
33
+ let lastIndex = entryIndex;
34
+ while (
35
+ lastIndex < entries.length - 1 &&
36
+ hasFold(node, entries[lastIndex + 1].name)
37
+ ) {
38
+ lastIndex += 1;
39
+ }
40
+ const unfoldedNames = new Set(
41
+ entries.slice(firstIndex, lastIndex + 1).map((entry) => entry.name),
42
+ );
43
+ return {
44
+ ...node,
45
+ folds: node.folds.filter((foldedName) => !unfoldedNames.has(foldedName)),
46
+ };
43
47
  }
@@ -1,39 +1,59 @@
1
1
  import { State } from 'dirvi-lib';
2
- import { Intent } from './user-input-to-intent.js';
2
+ import {
3
+ InputMode,
4
+ Intent,
5
+ } from '../../../dirvi-lib/src/application/user-input-to-intent.js';
3
6
  import { UnixEntry, UnixEntryPath } from 'dirvi-lib';
4
- export type EffectAction = {
5
- kind: 'nextEntry';
6
- } | {
7
- kind: 'prevEntry';
8
- } | {
9
- kind: 'updateDir';
10
- path: UnixEntryPath;
11
- entries: UnixEntry[] | undefined;
12
- } | {
13
- kind: 'outDir';
14
- } | {
15
- kind: 'fold';
16
- } | {
17
- kind: 'unfold';
18
- } | {
19
- kind: 'toggleFold';
20
- };
21
- export type Effect = {
22
- effectType: 'dispatchEffectAsAction';
23
- action: EffectAction;
24
- } | {
25
- effectType: 'loadDir';
26
- path: UnixEntryPath;
27
- } | {
28
- effectType: 'printFile';
29
- path: UnixEntryPath;
30
- } | {
31
- effectType: 'exit';
32
- exitMessage: string;
33
- };
34
- export type EffectResult = {
35
- commandBuffer: string;
36
- effect?: Effect;
37
- };
38
- export declare function intentToEffect(intent: Intent, state: State): EffectResult | undefined;
39
- //# sourceMappingURL=intent-to-effect.d.ts.map
7
+ export type EffectAction =
8
+ | {
9
+ kind: 'nextEntry';
10
+ }
11
+ | {
12
+ kind: 'prevEntry';
13
+ }
14
+ | {
15
+ kind: 'updateDir';
16
+ path: UnixEntryPath;
17
+ entries: UnixEntry[] | undefined;
18
+ }
19
+ | {
20
+ kind: 'outDir';
21
+ }
22
+ | {
23
+ kind: 'fold';
24
+ }
25
+ | {
26
+ kind: 'unfold';
27
+ }
28
+ | {
29
+ kind: 'toggleFold';
30
+ };
31
+ export type Effect =
32
+ | {
33
+ effectType: 'dispatchEffectAsAction';
34
+ action: EffectAction;
35
+ }
36
+ | {
37
+ effectType: 'loadDir';
38
+ path: UnixEntryPath;
39
+ }
40
+ | {
41
+ effectType: 'printFile';
42
+ path: UnixEntryPath;
43
+ }
44
+ | {
45
+ effectType: 'exit';
46
+ exitMessage: string;
47
+ }
48
+ | {
49
+ effectType: 'changeInput';
50
+ inputMode: InputMode;
51
+ commandBuffer: string;
52
+ commandLine: string;
53
+ };
54
+ export type EffectResult = Effect | undefined;
55
+ export declare function intentToEffect(
56
+ intent: Intent,
57
+ state: State,
58
+ ): EffectResult | undefined;
59
+ //# sourceMappingURL=intent-to-effect.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"intent-to-effect.d.ts","sourceRoot":"","sources":["../../src/application/intent-to-effect.ts"],"names":[],"mappings":"AAAA,OAAO,EAAU,KAAK,EAAQ,MAAM,WAAW,CAAC;AAChD,OAAO,EAAE,MAAM,EAAE,MAAM,2BAA2B,CAAC;AACnD,OAAO,EAAE,SAAS,EAAE,aAAa,EAAE,MAAM,WAAW,CAAC;AAGrD,MAAM,MAAM,YAAY,GACpB;IACE,IAAI,EAAE,WAAW,CAAC;CACnB,GACD;IACE,IAAI,EAAE,WAAW,CAAC;CACnB,GACD;IACE,IAAI,EAAE,WAAW,CAAC;IAClB,IAAI,EAAE,aAAa,CAAC;IACpB,OAAO,EAAE,SAAS,EAAE,GAAG,SAAS,CAAC;CAClC,GACD;IACE,IAAI,EAAE,QAAQ,CAAC;CAChB,GACD;IACE,IAAI,EAAE,MAAM,CAAC;CACd,GACD;IACE,IAAI,EAAE,QAAQ,CAAC;CAChB,GACD;IACE,IAAI,EAAE,YAAY,CAAC;CACpB,CAAC;AAEN,MAAM,MAAM,MAAM,GACd;IACE,UAAU,EAAE,wBAAwB,CAAC;IACrC,MAAM,EAAE,YAAY,CAAC;CACtB,GACD;IACE,UAAU,EAAE,SAAS,CAAC;IACtB,IAAI,EAAE,aAAa,CAAC;CACrB,GACD;IACE,UAAU,EAAE,WAAW,CAAC;IACxB,IAAI,EAAE,aAAa,CAAC;CACrB,GACD;IACE,UAAU,EAAE,MAAM,CAAC;IACnB,WAAW,EAAE,MAAM,CAAC;CACrB,CAAC;AAEN,MAAM,MAAM,YAAY,GAAG;IACzB,aAAa,EAAE,MAAM,CAAC;IACtB,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB,CAAC;AA0GF,wBAAgB,cAAc,CAC5B,MAAM,EAAE,MAAM,EACd,KAAK,EAAE,KAAK,GACX,YAAY,GAAG,SAAS,CAiC1B"}
1
+ {"version":3,"file":"intent-to-effect.d.ts","sourceRoot":"","sources":["../../src/application/intent-to-effect.ts"],"names":[],"mappings":"AAAA,OAAO,EAAU,KAAK,EAAQ,MAAM,WAAW,CAAC;AAChD,OAAO,EAAE,SAAS,EAAE,MAAM,EAAE,MAAM,4DAA4D,CAAC;AAC/F,OAAO,EAAE,SAAS,EAAE,aAAa,EAAE,MAAM,WAAW,CAAC;AAGrD,MAAM,MAAM,YAAY,GACpB;IACE,IAAI,EAAE,WAAW,CAAC;CACnB,GACD;IACE,IAAI,EAAE,WAAW,CAAC;CACnB,GACD;IACE,IAAI,EAAE,WAAW,CAAC;IAClB,IAAI,EAAE,aAAa,CAAC;IACpB,OAAO,EAAE,SAAS,EAAE,GAAG,SAAS,CAAC;CAClC,GACD;IACE,IAAI,EAAE,QAAQ,CAAC;CAChB,GACD;IACE,IAAI,EAAE,MAAM,CAAC;CACd,GACD;IACE,IAAI,EAAE,QAAQ,CAAC;CAChB,GACD;IACE,IAAI,EAAE,YAAY,CAAC;CACpB,CAAC;AAEN,MAAM,MAAM,MAAM,GACd;IACE,UAAU,EAAE,wBAAwB,CAAC;IACrC,MAAM,EAAE,YAAY,CAAC;CACtB,GACD;IACE,UAAU,EAAE,SAAS,CAAC;IACtB,IAAI,EAAE,aAAa,CAAC;CACrB,GACD;IACE,UAAU,EAAE,WAAW,CAAC;IACxB,IAAI,EAAE,aAAa,CAAC;CACrB,GACD;IACE,UAAU,EAAE,MAAM,CAAC;IACnB,WAAW,EAAE,MAAM,CAAC;CACrB,GACD;IACE,UAAU,EAAE,aAAa,CAAC;IAC1B,SAAS,EAAE,SAAS,CAAC;IACrB,aAAa,EAAE,MAAM,CAAC;IACtB,WAAW,EAAE,MAAM,CAAC;CACrB,CAAC;AAEN,MAAM,MAAM,YAAY,GAAG,MAAM,GAAG,SAAS,CAAC;AAyG9C,wBAAgB,cAAc,CAC5B,MAAM,EAAE,MAAM,EACd,KAAK,EAAE,KAAK,GACX,YAAY,GAAG,SAAS,CAqD1B"}