@mak-98/dirvi-cli 0.4.0 → 0.6.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 (92) hide show
  1. package/dist/application/effect-to-action.d.ts +5 -7
  2. package/dist/application/effect-to-action.d.ts.map +1 -1
  3. package/dist/application/effect-to-action.js +83 -86
  4. package/dist/application/reducer-action.d.ts +23 -23
  5. package/dist/application/reducer-action.d.ts.map +1 -1
  6. package/dist/application/reducer.d.ts +4 -3
  7. package/dist/application/reducer.d.ts.map +1 -1
  8. package/dist/application/reducer.js +67 -42
  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 +12 -15
  13. package/dist/domain/event-message.d.ts.map +1 -1
  14. package/dist/index.d.ts +1 -1
  15. package/dist/index.js +56 -45
  16. package/dist/infrastructure/get-dir-entries.d.ts +3 -0
  17. package/dist/infrastructure/get-dir-entries.d.ts.map +1 -0
  18. package/dist/infrastructure/get-dir-entries.js +33 -0
  19. package/dist/infrastructure/get-dir-lazy-entries.d.ts +3 -0
  20. package/dist/infrastructure/get-dir-lazy-entries.d.ts.map +1 -0
  21. package/dist/infrastructure/get-dir-lazy-entries.js +33 -0
  22. package/dist/infrastructure/get-unix-abs-path.d.ts +3 -0
  23. package/dist/infrastructure/get-unix-abs-path.d.ts.map +1 -0
  24. package/dist/infrastructure/get-unix-abs-path.js +14 -0
  25. package/dist/infrastructure/ink-input-to-user-input.d.ts +2 -5
  26. package/dist/infrastructure/ink-input-to-user-input.js +42 -42
  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 +16 -15
  31. package/dist/ui/App.d.ts.map +1 -1
  32. package/dist/ui/App.js +124 -129
  33. package/dist/ui/AppShell.d.ts +6 -16
  34. package/dist/ui/AppShell.d.ts.map +1 -1
  35. package/dist/ui/AppShell.js +10 -13
  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 +3 -5
  40. package/dist/ui/components/StatusBar.d.ts.map +1 -1
  41. package/dist/ui/components/StatusBar.js +3 -28
  42. package/dist/ui/components/ViewRowComponent.d.ts +4 -6
  43. package/dist/ui/components/ViewRowComponent.js +10 -30
  44. package/dist/ui/hooks/useView.d.ts +4 -7
  45. package/dist/ui/hooks/useView.d.ts.map +1 -1
  46. package/dist/ui/hooks/useView.js +20 -29
  47. package/dist/ui/view.d.ts +13 -17
  48. package/dist/ui/view.d.ts.map +1 -1
  49. package/dist/ui/view.js +84 -64
  50. package/package.json +2 -2
  51. package/dist/application/action.d.ts +0 -26
  52. package/dist/application/action.d.ts.map +0 -1
  53. package/dist/application/action.js +0 -1
  54. package/dist/application/dir-buffer-helpers.d.ts +0 -6
  55. package/dist/application/dir-buffer-helpers.d.ts.map +0 -1
  56. package/dist/application/dir-buffer-helpers.js +0 -21
  57. package/dist/application/display-rows.d.ts +0 -11
  58. package/dist/application/display-rows.d.ts.map +0 -1
  59. package/dist/application/display-rows.js +0 -63
  60. package/dist/application/fold-helpers.d.ts +0 -24
  61. package/dist/application/fold-helpers.d.ts.map +0 -1
  62. package/dist/application/fold-helpers.js +0 -47
  63. package/dist/application/intent-to-effect.d.ts +0 -59
  64. package/dist/application/intent-to-effect.d.ts.map +0 -1
  65. package/dist/application/intent-to-effect.js +0 -131
  66. package/dist/application/user-input-to-intent.d.ts +0 -39
  67. package/dist/application/user-input-to-intent.d.ts.map +0 -1
  68. package/dist/application/user-input-to-intent.js +0 -110
  69. package/dist/domain/print-message.d.ts +0 -11
  70. package/dist/domain/print-message.d.ts.map +0 -1
  71. package/dist/domain/print-message.js +0 -1
  72. package/dist/infrastructure/input.d.ts +0 -12
  73. package/dist/infrastructure/input.d.ts.map +0 -1
  74. package/dist/infrastructure/input.js +0 -81
  75. package/dist/infrastructure/load-initial-props.d.ts +0 -3
  76. package/dist/infrastructure/load-initial-props.d.ts.map +0 -1
  77. package/dist/infrastructure/load-initial-props.js +0 -36
  78. package/dist/infrastructure/user-input.d.ts +0 -32
  79. package/dist/infrastructure/user-input.d.ts.map +0 -1
  80. package/dist/infrastructure/user-input.js +0 -45
  81. package/dist/ui/App2.d.ts +0 -16
  82. package/dist/ui/App2.d.ts.map +0 -1
  83. package/dist/ui/App2.js +0 -107
  84. package/dist/ui/components/DirEntries.d.ts +0 -11
  85. package/dist/ui/components/DirEntries.d.ts.map +0 -1
  86. package/dist/ui/components/DirEntries.js +0 -64
  87. package/dist/ui/components/UnixEntry.d.ts +0 -9
  88. package/dist/ui/components/UnixEntry.d.ts.map +0 -1
  89. package/dist/ui/components/UnixEntry.js +0 -19
  90. package/dist/ui/components/UnixEntryComponent.d.ts +0 -9
  91. package/dist/ui/components/UnixEntryComponent.d.ts.map +0 -1
  92. package/dist/ui/components/UnixEntryComponent.js +0 -19
@@ -1,63 +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 (
10
- index < entries.length &&
11
- FoldNode.getIfEntryFolded(foldNode, entries[index])
12
- ) {
13
- entryNames.push(entries[index].name);
14
- index += 1;
15
- }
16
- rows.push({
17
- kind: 'fold',
18
- parentPath: path,
19
- entryNames,
20
- });
21
- continue;
22
- }
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;
40
- }
41
- export function createDisplayRows(buffer, folds) {
42
- return displayRowsAtPath(buffer, [], folds);
43
- }
44
- export function displayRowAtPath(buffer, folds, path) {
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
- );
57
- }
58
- return (
59
- UnixEntryPath.equal(row.parentPath, parentPath) &&
60
- row.entryNames.includes(entryName)
61
- );
62
- });
63
- }
@@ -1,24 +0,0 @@
1
- import type { UnixEntry, UnixEntryName } from 'dirvi-lib';
2
- import { FoldNode } from 'dirvi-lib';
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 +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,47 +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 (
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
- };
47
- }
@@ -1,59 +0,0 @@
1
- import { State } from 'dirvi-lib';
2
- import {
3
- InputMode,
4
- Intent,
5
- } from '../../../dirvi-lib/src/application/user-input-to-intent.js';
6
- import { UnixEntry, UnixEntryPath } from 'dirvi-lib';
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 +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,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"}
@@ -1,131 +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
- } else {
24
- return dispatchAction({
25
- kind: 'updateDir',
26
- path,
27
- entries: undefined,
28
- });
29
- }
30
- }
31
- if (currentEntry.kind === 'file') {
32
- return {
33
- effectType: 'printFile',
34
- path,
35
- };
36
- }
37
- // TODO Later: Peeking on folds
38
- return undefined;
39
- }
40
- function interactLeftToEffect(state) {
41
- if (state.cursor.parentPath.length === 0) {
42
- return undefined;
43
- }
44
- return dispatchAction({
45
- kind: 'outDir',
46
- });
47
- }
48
- // Here if the updated command buffer reaches a recognized motion,
49
- // sends the effect.
50
- function commandBufferToEffectResult(updatedCommandBuffer) {
51
- switch (updatedCommandBuffer) {
52
- case 'q':
53
- return {
54
- effectType: 'exit',
55
- exitMessage: '',
56
- };
57
- case 'z':
58
- return {
59
- effectType: 'changeInput',
60
- inputMode: 'normal',
61
- commandBuffer: updatedCommandBuffer,
62
- commandLine: '',
63
- };
64
- case 'za':
65
- return dispatchAction({
66
- kind: 'toggleFold',
67
- });
68
- case 'zc':
69
- return dispatchAction({
70
- kind: 'fold',
71
- });
72
- case 'zo':
73
- return dispatchAction({
74
- kind: 'unfold',
75
- });
76
- default:
77
- return {
78
- effectType: 'changeInput',
79
- inputMode: 'normal',
80
- commandBuffer: '',
81
- commandLine: '',
82
- };
83
- }
84
- }
85
- // Effect derived from Intent and the state.
86
- export function intentToEffect(intent, state) {
87
- switch (intent.intentType) {
88
- case 'setNormalBuffer':
89
- return commandBufferToEffectResult(intent.commandBuffer);
90
- case 'interactRight':
91
- return interactRightToEffect(state);
92
- case 'interactLeft':
93
- return interactLeftToEffect(state);
94
- case 'interactDown':
95
- return dispatchAction({
96
- kind: 'nextEntry',
97
- });
98
- case 'interactUp':
99
- return dispatchAction({
100
- kind: 'prevEntry',
101
- });
102
- case 'enterCommandLineMode':
103
- return {
104
- effectType: 'changeInput',
105
- inputMode: 'command',
106
- commandBuffer: '',
107
- commandLine: ':',
108
- };
109
- case 'setCommandLine':
110
- return {
111
- effectType: 'changeInput',
112
- inputMode: 'command',
113
- commandBuffer: '',
114
- commandLine: intent.commandLine,
115
- };
116
- case 'exitCommandLineMode':
117
- return {
118
- effectType: 'changeInput',
119
- inputMode: 'normal',
120
- commandBuffer: '',
121
- commandLine: '',
122
- };
123
- case 'executeCommandLine':
124
- return {
125
- effectType: 'changeInput',
126
- inputMode: 'normal',
127
- commandBuffer: '',
128
- commandLine: '',
129
- };
130
- }
131
- }
@@ -1,39 +0,0 @@
1
- import { UserInput } from '../infrastructure/user-input.js';
2
- export type InputMode = 'normal' | 'command';
3
- export type Intent =
4
- | {
5
- intentType: 'interactRight';
6
- }
7
- | {
8
- intentType: 'interactLeft';
9
- }
10
- | {
11
- intentType: 'interactDown';
12
- }
13
- | {
14
- intentType: 'interactUp';
15
- }
16
- | {
17
- intentType: 'setNormalBuffer';
18
- commandBuffer: string;
19
- }
20
- | {
21
- intentType: 'enterCommandLineMode';
22
- }
23
- | {
24
- intentType: 'setCommandLine';
25
- commandLine: string;
26
- }
27
- | {
28
- intentType: 'executeCommandLine';
29
- }
30
- | {
31
- intentType: 'exitCommandLineMode';
32
- };
33
- export declare function userInputToIntent(
34
- userInput: UserInput,
35
- inputMode: InputMode,
36
- normalBuffer: string,
37
- commandLine: string,
38
- ): Intent | undefined;
39
- //# 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,SAAS,GAAG,QAAQ,GAAG,SAAS,CAAC;AAE7C,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,iBAAiB,CAAC;IAC9B,aAAa,EAAE,MAAM,CAAC;CACvB,GACD;IACE,UAAU,EAAE,sBAAsB,CAAC;CACpC,GACD;IACE,UAAU,EAAE,gBAAgB,CAAC;IAC7B,WAAW,EAAE,MAAM,CAAC;CACrB,GACD;IACE,UAAU,EAAE,oBAAoB,CAAC;CAClC,GACD;IACE,UAAU,EAAE,qBAAqB,CAAC;CACnC,CAAC;AAGN,wBAAgB,iBAAiB,CAC/B,SAAS,EAAE,SAAS,EACpB,SAAS,EAAE,SAAS,EACpB,YAAY,EAAE,MAAM,EACpB,WAAW,EAAE,MAAM,GAClB,MAAM,GAAG,SAAS,CAUpB"}
@@ -1,110 +0,0 @@
1
- // Derive the intent from the user input, the input mode, and the input buffers.
2
- export function userInputToIntent(
3
- userInput,
4
- inputMode,
5
- normalBuffer,
6
- commandLine,
7
- ) {
8
- if (inputMode === 'normal') {
9
- normalUserInputToIntent(userInput, normalBuffer);
10
- }
11
- if (inputMode === 'command') {
12
- commandUserInputToIntent(userInput, commandLine);
13
- }
14
- return undefined;
15
- }
16
- function normalUserInputToIntent(userInput, normalBuffer) {
17
- if (userInput.userInputType === 'esc') {
18
- return {
19
- intentType: 'setNormalBuffer',
20
- commandBuffer: '',
21
- };
22
- }
23
- if (userInput.userInputType === 'character') {
24
- return normalCharacterToIntent(userInput.string, normalBuffer);
25
- }
26
- switch (userInput.userInputType) {
27
- case 'rightArrow':
28
- return {
29
- intentType: 'interactRight',
30
- };
31
- case 'leftArrow':
32
- return {
33
- intentType: 'interactLeft',
34
- };
35
- case 'downArrow':
36
- return {
37
- intentType: 'interactDown',
38
- };
39
- case 'upArrow':
40
- return {
41
- intentType: 'interactUp',
42
- };
43
- }
44
- }
45
- function normalCharacterToIntent(character, commandBuffer) {
46
- if (commandBuffer === '') {
47
- switch (character) {
48
- case 'l':
49
- return {
50
- intentType: 'interactRight',
51
- };
52
- case 'h':
53
- return {
54
- intentType: 'interactLeft',
55
- };
56
- case 'j':
57
- return {
58
- intentType: 'interactDown',
59
- };
60
- case 'k':
61
- return {
62
- intentType: 'interactUp',
63
- };
64
- case ':':
65
- return {
66
- intentType: 'enterCommandLineMode',
67
- };
68
- }
69
- }
70
- return {
71
- intentType: 'setNormalBuffer',
72
- commandBuffer: commandBuffer + character,
73
- };
74
- }
75
- function commandUserInputToIntent(userInput, commandLine) {
76
- if (userInput.userInputType === 'esc') {
77
- return {
78
- intentType: 'exitCommandLineMode',
79
- };
80
- }
81
- if (userInput.userInputType === 'enter') {
82
- return {
83
- intentType: 'executeCommandLine',
84
- };
85
- }
86
- if (userInput.userInputType === 'character') {
87
- return {
88
- intentType: 'setCommandLine',
89
- commandLine: commandLine + userInput.string,
90
- };
91
- }
92
- switch (userInput.userInputType) {
93
- case 'rightArrow':
94
- return {
95
- intentType: 'interactRight',
96
- };
97
- case 'leftArrow':
98
- return {
99
- intentType: 'interactLeft',
100
- };
101
- case 'downArrow':
102
- return {
103
- intentType: 'interactDown',
104
- };
105
- case 'upArrow':
106
- return {
107
- intentType: 'interactUp',
108
- };
109
- }
110
- }
@@ -1,11 +0,0 @@
1
- import { EntryPath, View } from 'dirvi-lib';
2
- export type PrintMessage =
3
- | {
4
- type: 'view';
5
- view: View;
6
- }
7
- | {
8
- type: 'file';
9
- path: EntryPath;
10
- };
11
- //# 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,12 +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(
7
- input: string,
8
- key: Key,
9
- view: State,
10
- pendingInput?: PendingInput,
11
- ): InputResult;
12
- //# 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":"AAMA,OAAO,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AAElD,wBAAsB,gBAAgB,IAAI,OAAO,CAAC,aAAa,CAAC,CAiC/D"}
@@ -1,36 +0,0 @@
1
- import {
2
- getCwdAbsPath,
3
- getDirLazyEntries,
4
- FoldNode,
5
- DisplayEntry,
6
- } from 'dirvi-lib';
7
- export async function loadInitialProps() {
8
- const cwdAddress = getCwdAbsPath();
9
- const lazyEntries = await getDirLazyEntries(cwdAddress);
10
- if (lazyEntries.length === 0) {
11
- return {
12
- cwdAddress,
13
- initialState: {
14
- cursor: undefined,
15
- },
16
- };
17
- }
18
- const firstEntry = lazyEntries[0];
19
- if (firstEntry === undefined) {
20
- throw new Error(
21
- 'Expected a first entry after checking that the directory is non-empty',
22
- );
23
- }
24
- return {
25
- cwdAddress,
26
- initialState: {
27
- buffer: lazyEntries,
28
- cursor: {
29
- kind: 'entry',
30
- parentPath: [],
31
- entryName: DisplayEntry.fromUnixEntry(firstEntry).name,
32
- },
33
- folds: FoldNode.createEmpty(),
34
- },
35
- };
36
- }
@@ -1,32 +0,0 @@
1
- import type { Key } from 'ink';
2
- export type UserInput =
3
- | {
4
- userInputType: 'character';
5
- string: string;
6
- }
7
- | {
8
- userInputType: 'enter';
9
- }
10
- | {
11
- userInputType: 'backspace';
12
- }
13
- | {
14
- userInputType: 'esc';
15
- }
16
- | {
17
- userInputType: 'rightArrow';
18
- }
19
- | {
20
- userInputType: 'leftArrow';
21
- }
22
- | {
23
- userInputType: 'downArrow';
24
- }
25
- | {
26
- userInputType: 'upArrow';
27
- };
28
- export declare function inkInputToUserInput(
29
- input: string,
30
- key: Key,
31
- ): UserInput | undefined;
32
- //# 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,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;AAGN,wBAAgB,mBAAmB,CACjC,KAAK,EAAE,MAAM,EACb,GAAG,EAAE,GAAG,GACP,SAAS,GAAG,SAAS,CAmDvB"}