@mak-98/dirvi-cli 0.3.2 → 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 (90) hide show
  1. package/dist/application/effect-to-action.d.ts +4 -3
  2. package/dist/application/effect-to-action.d.ts.map +1 -1
  3. package/dist/application/effect-to-action.js +75 -71
  4. package/dist/application/reducer-action.d.ts +15 -11
  5. package/dist/application/reducer-action.d.ts.map +1 -1
  6. package/dist/application/reducer.d.ts +3 -2
  7. package/dist/application/reducer.d.ts.map +1 -1
  8. package/dist/application/reducer.js +66 -29
  9. package/dist/domain/app-api.d.ts +47 -0
  10. package/dist/domain/app-api.d.ts.map +1 -0
  11. package/dist/domain/app-api.js +21 -0
  12. package/dist/domain/event-message.d.ts +6 -6
  13. package/dist/domain/event-message.d.ts.map +1 -1
  14. package/dist/index.js +13 -10
  15. package/dist/infrastructure/get-dir-entries.d.ts +3 -0
  16. package/dist/infrastructure/get-dir-entries.d.ts.map +1 -0
  17. package/dist/infrastructure/get-dir-entries.js +33 -0
  18. package/dist/infrastructure/get-dir-lazy-entries.d.ts +3 -0
  19. package/dist/infrastructure/get-dir-lazy-entries.d.ts.map +1 -0
  20. package/dist/infrastructure/get-dir-lazy-entries.js +33 -0
  21. package/dist/infrastructure/get-unix-abs-path.d.ts +3 -0
  22. package/dist/infrastructure/get-unix-abs-path.d.ts.map +1 -0
  23. package/dist/infrastructure/get-unix-abs-path.js +14 -0
  24. package/dist/infrastructure/ink-input-to-user-input.d.ts +4 -0
  25. package/dist/infrastructure/ink-input-to-user-input.d.ts.map +1 -0
  26. package/dist/infrastructure/{user-input.js → ink-input-to-user-input.js} +10 -0
  27. package/dist/infrastructure/load-posix-app-api.d.ts +4 -0
  28. package/dist/infrastructure/load-posix-app-api.d.ts.map +1 -0
  29. package/dist/infrastructure/load-posix-app-api.js +82 -0
  30. package/dist/ui/App.d.ts +14 -8
  31. package/dist/ui/App.d.ts.map +1 -1
  32. package/dist/ui/App.js +68 -31
  33. package/dist/ui/AppShell.d.ts +4 -9
  34. package/dist/ui/AppShell.d.ts.map +1 -1
  35. package/dist/ui/AppShell.js +21 -7
  36. package/dist/ui/LoadingApp.d.ts +11 -0
  37. package/dist/ui/LoadingApp.d.ts.map +1 -0
  38. package/dist/ui/LoadingApp.js +67 -0
  39. package/dist/ui/components/StatusBar.d.ts +8 -0
  40. package/dist/ui/components/StatusBar.d.ts.map +1 -0
  41. package/dist/ui/components/StatusBar.js +7 -0
  42. package/dist/ui/components/ViewRowComponent.js +2 -2
  43. package/dist/ui/hooks/useView.d.ts +3 -2
  44. package/dist/ui/hooks/useView.d.ts.map +1 -1
  45. package/dist/ui/hooks/useView.js +5 -6
  46. package/dist/ui/view.d.ts +5 -4
  47. package/dist/ui/view.d.ts.map +1 -1
  48. package/dist/ui/view.js +55 -31
  49. package/package.json +3 -2
  50. package/dist/application/action.d.ts +0 -19
  51. package/dist/application/action.d.ts.map +0 -1
  52. package/dist/application/action.js +0 -1
  53. package/dist/application/dir-buffer-helpers.d.ts +0 -3
  54. package/dist/application/dir-buffer-helpers.d.ts.map +0 -1
  55. package/dist/application/dir-buffer-helpers.js +0 -21
  56. package/dist/application/display-rows.d.ts +0 -4
  57. package/dist/application/display-rows.d.ts.map +0 -1
  58. package/dist/application/display-rows.js +0 -50
  59. package/dist/application/fold-helpers.d.ts +0 -8
  60. package/dist/application/fold-helpers.d.ts.map +0 -1
  61. package/dist/application/fold-helpers.js +0 -43
  62. package/dist/application/intent-to-effect.d.ts +0 -39
  63. package/dist/application/intent-to-effect.d.ts.map +0 -1
  64. package/dist/application/intent-to-effect.js +0 -118
  65. package/dist/application/user-input-to-intent.d.ts +0 -15
  66. package/dist/application/user-input-to-intent.d.ts.map +0 -1
  67. package/dist/application/user-input-to-intent.js +0 -56
  68. package/dist/domain/print-message.d.ts +0 -9
  69. package/dist/domain/print-message.d.ts.map +0 -1
  70. package/dist/domain/print-message.js +0 -1
  71. package/dist/infrastructure/input.d.ts +0 -7
  72. package/dist/infrastructure/input.d.ts.map +0 -1
  73. package/dist/infrastructure/input.js +0 -81
  74. package/dist/infrastructure/load-initial-props.d.ts +0 -3
  75. package/dist/infrastructure/load-initial-props.d.ts.map +0 -1
  76. package/dist/infrastructure/load-initial-props.js +0 -29
  77. package/dist/infrastructure/user-input.d.ts +0 -17
  78. package/dist/infrastructure/user-input.d.ts.map +0 -1
  79. package/dist/ui/App2.d.ts +0 -11
  80. package/dist/ui/App2.d.ts.map +0 -1
  81. package/dist/ui/App2.js +0 -96
  82. package/dist/ui/components/DirEntries.d.ts +0 -8
  83. package/dist/ui/components/DirEntries.d.ts.map +0 -1
  84. package/dist/ui/components/DirEntries.js +0 -39
  85. package/dist/ui/components/UnixEntry.d.ts +0 -6
  86. package/dist/ui/components/UnixEntry.d.ts.map +0 -1
  87. package/dist/ui/components/UnixEntry.js +0 -12
  88. package/dist/ui/components/UnixEntryComponent.d.ts +0 -6
  89. package/dist/ui/components/UnixEntryComponent.d.ts.map +0 -1
  90. package/dist/ui/components/UnixEntryComponent.js +0 -12
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mak-98/dirvi-cli",
3
- "version": "0.3.2",
3
+ "version": "0.5.0",
4
4
  "description": "A Vim-inspired TUI for browsing directories.",
5
5
  "type": "module",
6
6
  "license": "GPL-3.0-or-later",
@@ -13,7 +13,7 @@
13
13
  ],
14
14
  "dependencies": {
15
15
  "commander": "^13.0.0",
16
- "dirvi-lib": "0.3.0",
16
+ "dirvi-lib": "0.5.0",
17
17
  "ink": "^7.1.1",
18
18
  "react": "^19.0.0"
19
19
  },
@@ -28,6 +28,7 @@
28
28
  "dev": "FORCE_COLOR=3 tsx src/index.tsx",
29
29
  "start": "node dist/index.js",
30
30
  "typecheck": "tsc --noEmit",
31
+ "format": "prettier . --write",
31
32
  "update-global": "npm install --global @mak-98/dirvi-cli@latest"
32
33
  }
33
34
  }
@@ -1,19 +0,0 @@
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
@@ -1 +0,0 @@
1
- {"version":3,"file":"action.d.ts","sourceRoot":"","sources":["../../src/application/action.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,aAAa,EAAE,MAAM,WAAW,CAAC;AAErD,MAAM,MAAM,MAAM,GACd;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,YAAY,CAAC;CACpB,GACD;IACE,IAAI,EAAE,MAAM,CAAC;CACd,GACD;IACE,IAAI,EAAE,QAAQ,CAAC;CAChB,CAAC"}
@@ -1 +0,0 @@
1
- export {};
@@ -1,3 +0,0 @@
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
@@ -1 +0,0 @@
1
- {"version":3,"file":"dir-buffer-helpers.d.ts","sourceRoot":"","sources":["../../src/application/dir-buffer-helpers.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,eAAe,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AAEvE,wBAAgB,WAAW,CACzB,MAAM,EAAE,eAAe,EACvB,IAAI,EAAE,SAAS,GACd,SAAS,GAAG,SAAS,CA2BvB"}
@@ -1,21 +0,0 @@
1
- export function entryAtPath(buffer, path) {
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;
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;
19
- }
20
- return undefined;
21
- }
@@ -1,4 +0,0 @@
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
@@ -1 +0,0 @@
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,50 +0,0 @@
1
- import { UnixEntryPath, FoldNode, } from 'dirvi-lib';
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
- }
29
- index += 1;
30
- }
31
- return rows;
32
- }
33
- export function createDisplayRows(buffer, folds) {
34
- return displayRowsAtPath(buffer, [], folds);
35
- }
36
- export function displayRowAtPath(buffer, folds, path) {
37
- if (path.length === 0) {
38
- return undefined;
39
- }
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
- });
50
- }
@@ -1,8 +0,0 @@
1
- import type { UnixEntry, UnixEntryName } from 'dirvi-lib';
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
@@ -1 +0,0 @@
1
- {"version":3,"file":"fold-helpers.d.ts","sourceRoot":"","sources":["../../src/application/fold-helpers.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,aAAa,EAAE,MAAM,WAAW,CAAC;AAC1D,OAAO,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAC;AAErC,wBAAgB,OAAO,CAAC,IAAI,EAAE,QAAQ,EAAE,SAAS,EAAE,aAAa,GAAG,OAAO,CAEzE;AAED,wBAAgB,aAAa,CAC3B,IAAI,EAAE,QAAQ,GAAG,SAAS,EAC1B,KAAK,EAAE,SAAS,GACf,OAAO,CAET;AAGD,wBAAgB,QAAQ,CAAC,IAAI,EAAE,QAAQ,EAAE,OAAO,EAAE,SAAS,EAAE,GAAG,QAAQ,CAOvE;AAED,wBAAgB,OAAO,CAAC,IAAI,EAAE,QAAQ,EAAE,SAAS,EAAE,aAAa,GAAG,QAAQ,CAS1E;AAED,wBAAgB,kBAAkB,CAChC,IAAI,EAAE,QAAQ,EACd,OAAO,EAAE,SAAS,EAAE,EACpB,SAAS,EAAE,aAAa,GACvB,QAAQ,CA8BV"}
@@ -1,43 +0,0 @@
1
- export function hasFold(node, entryName) {
2
- return node.folds.includes(entryName);
3
- }
4
- export function entryIsFolded(node, entry) {
5
- return node !== undefined && hasFold(node, entry.name);
6
- }
7
- // Replaces all folds at a node
8
- export function setFolds(node, entries) {
9
- const entryNames = entries.map((entry) => entry.name);
10
- return {
11
- ...node,
12
- folds: entryNames,
13
- };
14
- }
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
- };
23
- }
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
- };
43
- }
@@ -1,39 +0,0 @@
1
- import { State } from 'dirvi-lib';
2
- import { Intent } from './user-input-to-intent.js';
3
- 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
@@ -1 +0,0 @@
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,118 +0,0 @@
1
- import { Cursor, View } from 'dirvi-lib';
2
- function dispatchAction(action) {
3
- return {
4
- effectType: 'dispatchEffectAsAction',
5
- action,
6
- };
7
- }
8
- function interactRightToEffect(state) {
9
- const currentEntry = View.getEntryAtCursor(state);
10
- if (currentEntry === undefined) {
11
- return undefined;
12
- }
13
- const path = Cursor.getPath(state.cursor);
14
- if (path === undefined) {
15
- return undefined;
16
- }
17
- if (currentEntry.kind === 'directory') {
18
- if (currentEntry.entries === undefined) {
19
- return {
20
- effectType: 'loadDir',
21
- path,
22
- };
23
- }
24
- else {
25
- return dispatchAction({
26
- kind: 'updateDir',
27
- path,
28
- entries: undefined,
29
- });
30
- }
31
- }
32
- if (currentEntry.kind === 'file') {
33
- return {
34
- effectType: 'printFile',
35
- path,
36
- };
37
- }
38
- // TODO Later: Peeking on folds
39
- return undefined;
40
- }
41
- function interactLeftToEffect(state) {
42
- if (state.cursor.parentPath.length === 0) {
43
- return undefined;
44
- }
45
- return dispatchAction({
46
- kind: 'outDir',
47
- });
48
- }
49
- // Here if the updated command buffer reaches a recognized motion,
50
- // sends the effect.
51
- function commandBufferToEffectResult(updatedCommandBuffer) {
52
- switch (updatedCommandBuffer) {
53
- case 'q':
54
- return {
55
- commandBuffer: '',
56
- effect: {
57
- effectType: 'exit',
58
- exitMessage: '',
59
- },
60
- };
61
- case 'za':
62
- return {
63
- commandBuffer: '',
64
- effect: dispatchAction({
65
- kind: 'toggleFold',
66
- }),
67
- };
68
- case 'zc':
69
- return {
70
- commandBuffer: '',
71
- effect: dispatchAction({
72
- kind: 'fold',
73
- }),
74
- };
75
- case 'zo':
76
- return {
77
- commandBuffer: '',
78
- effect: dispatchAction({
79
- kind: 'unfold',
80
- }),
81
- };
82
- default:
83
- return {
84
- commandBuffer: updatedCommandBuffer,
85
- };
86
- }
87
- }
88
- // Effect derived from Intent and the state.
89
- export function intentToEffect(intent, state) {
90
- switch (intent.intentType) {
91
- case 'updateCommandBuffer':
92
- return commandBufferToEffectResult(intent.updatedCommandBuffer);
93
- case 'interactRight':
94
- return {
95
- commandBuffer: '',
96
- effect: interactRightToEffect(state),
97
- };
98
- case 'interactLeft':
99
- return {
100
- commandBuffer: '',
101
- effect: interactLeftToEffect(state),
102
- };
103
- case 'interactDown':
104
- return {
105
- commandBuffer: '',
106
- effect: dispatchAction({
107
- kind: 'nextEntry',
108
- }),
109
- };
110
- case 'interactUp':
111
- return {
112
- commandBuffer: '',
113
- effect: dispatchAction({
114
- kind: 'prevEntry',
115
- }),
116
- };
117
- }
118
- }
@@ -1,15 +0,0 @@
1
- import { UserInput } from '../infrastructure/user-input.js';
2
- export type Intent = {
3
- intentType: 'interactRight';
4
- } | {
5
- intentType: 'interactLeft';
6
- } | {
7
- intentType: 'interactDown';
8
- } | {
9
- intentType: 'interactUp';
10
- } | {
11
- intentType: 'updateCommandBuffer';
12
- updatedCommandBuffer: string;
13
- };
14
- export declare function userInputToIntent(userInput: UserInput, commandBuffer: string): Intent | undefined;
15
- //# sourceMappingURL=user-input-to-intent.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"user-input-to-intent.d.ts","sourceRoot":"","sources":["../../src/application/user-input-to-intent.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,iCAAiC,CAAC;AAE5D,MAAM,MAAM,MAAM,GACd;IACE,UAAU,EAAE,eAAe,CAAC;CAC7B,GACD;IACE,UAAU,EAAE,cAAc,CAAC;CAC5B,GACD;IACE,UAAU,EAAE,cAAc,CAAC;CAC5B,GACD;IACE,UAAU,EAAE,YAAY,CAAC;CAC1B,GACD;IACE,UAAU,EAAE,qBAAqB,CAAC;IAClC,oBAAoB,EAAE,MAAM,CAAC;CAC9B,CAAC;AAqCN,wBAAgB,iBAAiB,CAC/B,SAAS,EAAE,SAAS,EACpB,aAAa,EAAE,MAAM,GACpB,MAAM,GAAG,SAAS,CAiCpB"}
@@ -1,56 +0,0 @@
1
- function characterToIntent(character, commandBuffer) {
2
- if (commandBuffer === '') {
3
- switch (character) {
4
- case 'l':
5
- return {
6
- intentType: 'interactRight',
7
- };
8
- case 'h':
9
- return {
10
- intentType: 'interactLeft',
11
- };
12
- case 'j':
13
- return {
14
- intentType: 'interactDown',
15
- };
16
- case 'k':
17
- return {
18
- intentType: 'interactUp',
19
- };
20
- }
21
- }
22
- return {
23
- intentType: 'updateCommandBuffer',
24
- updatedCommandBuffer: commandBuffer + character,
25
- };
26
- }
27
- // Derive the intent from the user input and the commandBuffer.
28
- export function userInputToIntent(userInput, commandBuffer) {
29
- if (userInput.userInputType === 'esc') {
30
- return {
31
- intentType: 'updateCommandBuffer',
32
- updatedCommandBuffer: '',
33
- };
34
- }
35
- if (userInput.userInputType === 'character') {
36
- return characterToIntent(userInput.string, commandBuffer);
37
- }
38
- switch (userInput.userInputType) {
39
- case 'rightArrow':
40
- return {
41
- intentType: 'interactRight',
42
- };
43
- case 'leftArrow':
44
- return {
45
- intentType: 'interactLeft',
46
- };
47
- case 'downArrow':
48
- return {
49
- intentType: 'interactDown',
50
- };
51
- case 'upArrow':
52
- return {
53
- intentType: 'interactUp',
54
- };
55
- }
56
- }
@@ -1,9 +0,0 @@
1
- import { EntryPath, View } from 'dirvi-lib';
2
- export type PrintMessage = {
3
- type: 'view';
4
- view: View;
5
- } | {
6
- type: 'file';
7
- path: EntryPath;
8
- };
9
- //# sourceMappingURL=print-message.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"print-message.d.ts","sourceRoot":"","sources":["../../src/domain/print-message.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAE5C,MAAM,MAAM,YAAY,GACpB;IACE,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,IAAI,CAAC;CACZ,GACD;IACE,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,SAAS,CAAC;CACjB,CAAC"}
@@ -1 +0,0 @@
1
- export {};
@@ -1,7 +0,0 @@
1
- import type { Key } from 'ink';
2
- import { State } from 'dirvi-lib';
3
- import { Action } from '../application/action.js';
4
- export type PendingInput = 'z';
5
- export type InputResult = Action | PendingInput | undefined;
6
- export declare function userInputToInputResult(input: string, key: Key, view: State, pendingInput?: PendingInput): InputResult;
7
- //# sourceMappingURL=input.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"input.d.ts","sourceRoot":"","sources":["../../src/infrastructure/input.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,KAAK,CAAC;AAE/B,OAAO,EAAU,KAAK,EAAQ,MAAM,WAAW,CAAC;AAChD,OAAO,EAAE,MAAM,EAAE,MAAM,0BAA0B,CAAC;AAElD,MAAM,MAAM,YAAY,GAAG,GAAG,CAAC;AAC/B,MAAM,MAAM,WAAW,GAAG,MAAM,GAAG,YAAY,GAAG,SAAS,CAAC;AAE5D,wBAAgB,sBAAsB,CACpC,KAAK,EAAE,MAAM,EACb,GAAG,EAAE,GAAG,EACR,IAAI,EAAE,KAAK,EACX,YAAY,CAAC,EAAE,YAAY,GAC1B,WAAW,CA8Fb"}
@@ -1,81 +0,0 @@
1
- import { Cursor, View } from 'dirvi-lib';
2
- export function userInputToInputResult(input, key, view, pendingInput) {
3
- // Adding Pending Input
4
- if (pendingInput === undefined && input === 'z') {
5
- return 'z';
6
- }
7
- // z prefixed inputs
8
- if (pendingInput === 'z') {
9
- if (input === 'a') {
10
- return {
11
- kind: 'toggleFold',
12
- };
13
- }
14
- if (input === 'c') {
15
- return {
16
- kind: 'fold',
17
- };
18
- }
19
- if (input === 'o') {
20
- return {
21
- kind: 'unfold',
22
- };
23
- }
24
- // Unknown z command.
25
- return undefined;
26
- }
27
- // Not prefixed inputs
28
- if (input === 'l' || key.rightArrow) {
29
- const currentEntry = View.getEntryAtCursor(view);
30
- if (currentEntry === undefined) {
31
- return undefined;
32
- }
33
- if (currentEntry.kind === 'directory') {
34
- const path = Cursor.getPath(view.cursor);
35
- if (path === undefined) {
36
- return undefined;
37
- }
38
- return {
39
- kind: 'updateDir',
40
- path,
41
- entries: currentEntry.entries,
42
- };
43
- }
44
- if (currentEntry.kind === 'file') {
45
- const path = Cursor.getPath(view.cursor);
46
- if (path === undefined) {
47
- return undefined;
48
- }
49
- return {
50
- kind: 'printFile',
51
- path,
52
- };
53
- }
54
- return undefined;
55
- }
56
- if (input === 'h' || key.leftArrow) {
57
- if (view.cursor.parentPath.length === 0) {
58
- return undefined;
59
- }
60
- return {
61
- kind: 'outDir',
62
- };
63
- }
64
- if (input === 'k' || key.upArrow) {
65
- return {
66
- kind: 'prevEntry',
67
- };
68
- }
69
- if (input === 'j' || key.downArrow) {
70
- return {
71
- kind: 'nextEntry',
72
- };
73
- }
74
- if (input === 'q' || key.escape) {
75
- return {
76
- kind: 'exit',
77
- exitMessage: '',
78
- };
79
- }
80
- return undefined;
81
- }
@@ -1,3 +0,0 @@
1
- import { ShellAppProps } from '../ui/AppShell.js';
2
- export declare function loadInitialProps(): Promise<ShellAppProps>;
3
- //# sourceMappingURL=load-initial-props.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"load-initial-props.d.ts","sourceRoot":"","sources":["../../src/infrastructure/load-initial-props.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AAElD,wBAAsB,gBAAgB,IAAI,OAAO,CAAC,aAAa,CAAC,CAiC/D"}
@@ -1,29 +0,0 @@
1
- import { getCwdAbsPath, getDirLazyEntries, FoldNode, DisplayEntry, } from 'dirvi-lib';
2
- export async function loadInitialProps() {
3
- const cwdAddress = getCwdAbsPath();
4
- const lazyEntries = await getDirLazyEntries(cwdAddress);
5
- if (lazyEntries.length === 0) {
6
- return {
7
- cwdAddress,
8
- initialState: {
9
- cursor: undefined,
10
- },
11
- };
12
- }
13
- const firstEntry = lazyEntries[0];
14
- if (firstEntry === undefined) {
15
- throw new Error('Expected a first entry after checking that the directory is non-empty');
16
- }
17
- return {
18
- cwdAddress,
19
- initialState: {
20
- buffer: lazyEntries,
21
- cursor: {
22
- kind: 'entry',
23
- parentPath: [],
24
- entryName: DisplayEntry.fromUnixEntry(firstEntry).name,
25
- },
26
- folds: FoldNode.createEmpty(),
27
- },
28
- };
29
- }
@@ -1,17 +0,0 @@
1
- import type { Key } from 'ink';
2
- export type UserInput = {
3
- userInputType: 'character';
4
- string: string;
5
- } | {
6
- userInputType: 'esc';
7
- } | {
8
- userInputType: 'rightArrow';
9
- } | {
10
- userInputType: 'leftArrow';
11
- } | {
12
- userInputType: 'downArrow';
13
- } | {
14
- userInputType: 'upArrow';
15
- };
16
- export declare function inkInputToUserInput(input: string, key: Key): UserInput | undefined;
17
- //# sourceMappingURL=user-input.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"user-input.d.ts","sourceRoot":"","sources":["../../src/infrastructure/user-input.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,KAAK,CAAC;AAE/B,MAAM,MAAM,SAAS,GACjB;IACE,aAAa,EAAE,WAAW,CAAC;IAC3B,MAAM,EAAE,MAAM,CAAC;CAChB,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;AAGN,wBAAgB,mBAAmB,CAAC,KAAK,EAAE,MAAM,EAAE,GAAG,EAAE,GAAG,GAAG,SAAS,GAAG,SAAS,CAuClF"}
package/dist/ui/App2.d.ts DELETED
@@ -1,11 +0,0 @@
1
- import { State } from 'dirvi-lib';
2
- import type { UnixAbsolutePath } from 'dirvi-lib';
3
- import { EventMessage } from '../domain/event-message.js';
4
- export type AppProps = {
5
- cwdAddress: UnixAbsolutePath;
6
- initialState: State;
7
- print?: (message: EventMessage) => void;
8
- onError?: (error: Error) => void;
9
- };
10
- export declare function App2({ cwdAddress, initialState, print, onError }: AppProps): import("react").JSX.Element | null;
11
- //# sourceMappingURL=App2.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"App2.d.ts","sourceRoot":"","sources":["../../src/ui/App2.tsx"],"names":[],"mappings":"AAIA,OAAO,EAA6B,KAAK,EAAE,MAAM,WAAW,CAAC;AAC7D,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,WAAW,CAAC;AAQlD,OAAO,EAAE,YAAY,EAAE,MAAM,4BAA4B,CAAC;AAG1D,MAAM,MAAM,QAAQ,GAAG;IACrB,UAAU,EAAE,gBAAgB,CAAC;IAC7B,YAAY,EAAE,KAAK,CAAC;IACpB,KAAK,CAAC,EAAE,CAAC,OAAO,EAAE,YAAY,KAAK,IAAI,CAAC;IACxC,OAAO,CAAC,EAAE,CAAC,KAAK,EAAE,KAAK,KAAK,IAAI,CAAC;CAClC,CAAC;AAEF,wBAAgB,IAAI,CAAC,EAAE,UAAU,EAAE,YAAY,EAAE,KAAK,EAAE,OAAO,EAAE,EAAE,QAAQ,sCAsH1E"}