@mak-98/dirvi-cli 0.4.0 → 0.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (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 +81 -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 +40 -42
  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 +127 -128
  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 +22 -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 +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"}
package/dist/ui/App2.js DELETED
@@ -1,107 +0,0 @@
1
- import { jsx as _jsx } from 'react/jsx-runtime';
2
- import { join } from 'node:path';
3
- import { Box, Text, useApp, useInput } from 'ink';
4
- import { useEffect, useReducer, useRef, useState } from 'react';
5
- import { Cursor, getDirLazyEntries } from 'dirvi-lib';
6
- import { useView } from './hooks/useView.js';
7
- import { reducer } from '../application/reducer.js';
8
- import { userInputToInputResult } from '../infrastructure/input.js';
9
- import { ViewRowComponent } from './components/ViewRowComponent.js';
10
- export function App2({ cwdAddress, initialState, print, onError }) {
11
- const [state, dispatch] = useReducer(reducer, initialState);
12
- const view = useView(state);
13
- const pendingInput = useRef(undefined);
14
- const [exitStatus, setExitStatus] = useState();
15
- // Print view on changes
16
- useEffect(() => {
17
- print?.({ type: 'view', view: state });
18
- // print?.({
19
- // type: 'displayed-files-paths',
20
- // paths: displayedFilePaths(displayRows),
21
- // });
22
- }, [state, print]);
23
- // --- Input ---
24
- useInput((input, key) => {
25
- const result = userInputToInputResult(
26
- input,
27
- key,
28
- state,
29
- pendingInput.current,
30
- );
31
- if (result === undefined) {
32
- return;
33
- }
34
- if (result === 'z') {
35
- pendingInput.current = result;
36
- return;
37
- }
38
- pendingInput.current = undefined;
39
- const action = result;
40
- // Contents of `updateDir` change meaning at this boundary:
41
- if (action.kind === 'updateDir') {
42
- // If the entry at the path is directory with no entries loaded:
43
- if (action.entries === undefined) {
44
- const path = Cursor.getPath(state.cursor);
45
- if (path === undefined) {
46
- return undefined;
47
- }
48
- const address = join(cwdAddress, ...path);
49
- void getDirLazyEntries(address)
50
- .then((entries) => {
51
- dispatch({
52
- kind: 'updateDir',
53
- path: path,
54
- entries,
55
- });
56
- })
57
- .catch((error) => {
58
- const appError =
59
- error instanceof Error ? error : new Error(String(error));
60
- onError?.(appError);
61
- setExitStatus(`Unable to open directory: ${appError.message}`);
62
- });
63
- } else {
64
- // Otherwise need to wipe the entries:
65
- dispatch({
66
- kind: 'updateDir',
67
- path: action.path,
68
- entries: undefined,
69
- });
70
- }
71
- return;
72
- }
73
- if (action.kind === 'printFile') {
74
- print?.({
75
- type: 'file',
76
- path: action.path,
77
- });
78
- return;
79
- }
80
- if (action.kind === 'exit') {
81
- setExitStatus(action.exitMessage);
82
- }
83
- dispatch(action);
84
- });
85
- // --- Exit Logic ---
86
- const { exit } = useApp();
87
- useEffect(() => {
88
- if (exitStatus === undefined) {
89
- return;
90
- }
91
- if (exitStatus !== '') {
92
- onError?.(new Error(exitStatus));
93
- }
94
- exit();
95
- }, [exitStatus, exit, onError]);
96
- if (exitStatus !== undefined) {
97
- return null;
98
- }
99
- // --- JSX ---
100
- return _jsx(Box, {
101
- flexDirection: 'column',
102
- children:
103
- view.rows.length === 0
104
- ? _jsx(Text, { dimColor: true, children: 'Directory is empty.' })
105
- : view.rows.map((row) => _jsx(ViewRowComponent, { row: row }, row.id)),
106
- });
107
- }
@@ -1,11 +0,0 @@
1
- import { Cursor } from 'dirvi-lib';
2
- import { DisplayRow } from 'dirvi-lib';
3
- declare function DirEntries({
4
- rows,
5
- cursor,
6
- }: {
7
- rows: DisplayRow[];
8
- cursor: Cursor;
9
- }): import('react').JSX.Element;
10
- export default DirEntries;
11
- //# sourceMappingURL=DirEntries.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"DirEntries.d.ts","sourceRoot":"","sources":["../../../src/ui/components/DirEntries.tsx"],"names":[],"mappings":"AAEA,OAAO,EAAE,MAAM,EAAE,MAAM,WAAW,CAAC;AACnC,OAAO,EAAE,UAAU,EAAE,MAAM,WAAW,CAAC;AAKvC,iBAAS,UAAU,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,EAAE;IAAE,IAAI,EAAE,UAAU,EAAE,CAAC;IAAC,MAAM,EAAE,MAAM,CAAA;CAAE,+BA2D3E;AAED,eAAe,UAAU,CAAC"}
@@ -1,64 +0,0 @@
1
- import { jsx as _jsx, Fragment as _Fragment } from 'react/jsx-runtime';
2
- import { Box, Text, useWindowSize } from 'ink';
3
- import { Cursor } from 'dirvi-lib';
4
- import { UnixEntryComponent as UnixEntryComponent } from './UnixEntryComponent.js';
5
- import { useRef } from 'react';
6
- function DirEntries({ rows, cursor }) {
7
- const scrollMargin = 3;
8
- const { rows: terminalRows } = useWindowSize();
9
- const viewportStartRef = useRef(0);
10
- const cursorIndex = rows.findIndex((row) =>
11
- Cursor.matchesDisplayRow(cursor, row),
12
- );
13
- const viewportHeight = Math.max(1, terminalRows);
14
- const maximumViewportStart = Math.max(0, rows.length - viewportHeight);
15
- let viewportStart = viewportStartRef.current;
16
- if (cursorIndex >= 0) {
17
- const firstVisibleCursorIndex = viewportStart + scrollMargin;
18
- const lastVisibleCursorIndex =
19
- viewportStart + viewportHeight - 1 - scrollMargin;
20
- if (cursorIndex < firstVisibleCursorIndex) {
21
- // Cursor moved above the visible area.
22
- viewportStart = cursorIndex - scrollMargin;
23
- } else if (cursorIndex > lastVisibleCursorIndex) {
24
- // Cursor moved below the visible area.
25
- viewportStart = cursorIndex - viewportHeight + 1 + scrollMargin;
26
- }
27
- }
28
- viewportStart = Math.max(0, Math.min(viewportStart, maximumViewportStart));
29
- viewportStartRef.current = viewportStart;
30
- const visibleRows = rows.slice(viewportStart, viewportStart + viewportHeight);
31
- return _jsx(_Fragment, {
32
- children: visibleRows.map((row) => {
33
- const selected = Cursor.matchesDisplayRow(cursor, row);
34
- const indent = row.parentPath.length;
35
- if (row.kind === 'fold') {
36
- const key = `fold-${row.parentPath.join('/')}-${row.entryNames[0]}`;
37
- return _jsx(
38
- Box,
39
- {
40
- paddingLeft: indent * 2,
41
- children: _jsx(Text, {
42
- inverse: selected,
43
- dimColor: !selected,
44
- children: '...',
45
- }),
46
- },
47
- key,
48
- );
49
- }
50
- return _jsx(
51
- Box,
52
- {
53
- paddingLeft: indent * 2,
54
- children: _jsx(UnixEntryComponent, {
55
- entry: row.entry,
56
- selected: selected,
57
- }),
58
- },
59
- [...row.parentPath, row.entry.name].join('/'),
60
- );
61
- }),
62
- });
63
- }
64
- export default DirEntries;
@@ -1,9 +0,0 @@
1
- import { UnixEntry } from 'dirvi-lib';
2
- export declare function UnixEntry({
3
- entry,
4
- selected,
5
- }: {
6
- entry: UnixEntry;
7
- selected: boolean;
8
- }): import('react').JSX.Element;
9
- //# sourceMappingURL=UnixEntry.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"UnixEntry.d.ts","sourceRoot":"","sources":["../../../src/ui/components/UnixEntry.tsx"],"names":[],"mappings":"AACA,OAAO,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AAEtC,wBAAgB,SAAS,CAAC,EACxB,KAAK,EACL,QAAQ,GACT,EAAE;IACD,KAAK,EAAE,SAAS,CAAC;IACjB,QAAQ,EAAE,OAAO,CAAC;CACnB,+BAmBA"}
@@ -1,19 +0,0 @@
1
- import { jsx as _jsx, jsxs as _jsxs } from 'react/jsx-runtime';
2
- import { Text } from 'ink';
3
- export function UnixEntry({ entry, selected }) {
4
- switch (entry.kind) {
5
- case 'file':
6
- return _jsx(Text, { inverse: selected, children: entry.name });
7
- case 'symlink':
8
- return _jsxs(Text, {
9
- inverse: selected,
10
- children: [entry.name, ' -> ', entry.target],
11
- });
12
- case 'directory':
13
- return _jsxs(Text, {
14
- inverse: selected,
15
- color: 'blue',
16
- children: [entry.name, '/'],
17
- });
18
- }
19
- }
@@ -1,9 +0,0 @@
1
- import { UnixEntry } from 'dirvi-lib';
2
- export declare function UnixEntryComponent({
3
- entry,
4
- selected,
5
- }: {
6
- entry: UnixEntry;
7
- selected: boolean;
8
- }): import('react').JSX.Element;
9
- //# sourceMappingURL=UnixEntryComponent.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"UnixEntryComponent.d.ts","sourceRoot":"","sources":["../../../src/ui/components/UnixEntryComponent.tsx"],"names":[],"mappings":"AACA,OAAO,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AAEtC,wBAAgB,kBAAkB,CAAC,EACjC,KAAK,EACL,QAAQ,GACT,EAAE;IACD,KAAK,EAAE,SAAS,CAAC;IACjB,QAAQ,EAAE,OAAO,CAAC;CACnB,+BAmBA"}
@@ -1,19 +0,0 @@
1
- import { jsx as _jsx, jsxs as _jsxs } from 'react/jsx-runtime';
2
- import { Text } from 'ink';
3
- export function UnixEntryComponent({ entry, selected }) {
4
- switch (entry.kind) {
5
- case 'file':
6
- return _jsx(Text, { inverse: selected, children: entry.name });
7
- case 'symlink':
8
- return _jsxs(Text, {
9
- inverse: selected,
10
- children: [entry.name, ' -> ', entry.target],
11
- });
12
- case 'directory':
13
- return _jsxs(Text, {
14
- inverse: selected,
15
- color: 'blue',
16
- children: [entry.name, '/'],
17
- });
18
- }
19
- }