@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.
- package/dist/application/effect-to-action.d.ts +5 -7
- package/dist/application/effect-to-action.d.ts.map +1 -1
- package/dist/application/effect-to-action.js +81 -86
- package/dist/application/reducer-action.d.ts +23 -23
- package/dist/application/reducer-action.d.ts.map +1 -1
- package/dist/application/reducer.d.ts +4 -3
- package/dist/application/reducer.d.ts.map +1 -1
- package/dist/application/reducer.js +67 -42
- package/dist/domain/app-api.d.ts +47 -0
- package/dist/domain/app-api.d.ts.map +1 -0
- package/dist/domain/app-api.js +21 -0
- package/dist/domain/event-message.d.ts +12 -15
- package/dist/domain/event-message.d.ts.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +40 -42
- package/dist/infrastructure/get-dir-entries.d.ts +3 -0
- package/dist/infrastructure/get-dir-entries.d.ts.map +1 -0
- package/dist/infrastructure/get-dir-entries.js +33 -0
- package/dist/infrastructure/get-dir-lazy-entries.d.ts +3 -0
- package/dist/infrastructure/get-dir-lazy-entries.d.ts.map +1 -0
- package/dist/infrastructure/get-dir-lazy-entries.js +33 -0
- package/dist/infrastructure/get-unix-abs-path.d.ts +3 -0
- package/dist/infrastructure/get-unix-abs-path.d.ts.map +1 -0
- package/dist/infrastructure/get-unix-abs-path.js +14 -0
- package/dist/infrastructure/ink-input-to-user-input.d.ts +2 -5
- package/dist/infrastructure/ink-input-to-user-input.js +42 -42
- package/dist/infrastructure/load-posix-app-api.d.ts +4 -0
- package/dist/infrastructure/load-posix-app-api.d.ts.map +1 -0
- package/dist/infrastructure/load-posix-app-api.js +82 -0
- package/dist/ui/App.d.ts +16 -15
- package/dist/ui/App.d.ts.map +1 -1
- package/dist/ui/App.js +127 -128
- package/dist/ui/AppShell.d.ts +6 -16
- package/dist/ui/AppShell.d.ts.map +1 -1
- package/dist/ui/AppShell.js +22 -13
- package/dist/ui/LoadingApp.d.ts +11 -0
- package/dist/ui/LoadingApp.d.ts.map +1 -0
- package/dist/ui/LoadingApp.js +67 -0
- package/dist/ui/components/StatusBar.d.ts +3 -5
- package/dist/ui/components/StatusBar.d.ts.map +1 -1
- package/dist/ui/components/StatusBar.js +3 -28
- package/dist/ui/components/ViewRowComponent.d.ts +4 -6
- package/dist/ui/components/ViewRowComponent.js +10 -30
- package/dist/ui/hooks/useView.d.ts +4 -7
- package/dist/ui/hooks/useView.d.ts.map +1 -1
- package/dist/ui/hooks/useView.js +20 -29
- package/dist/ui/view.d.ts +13 -17
- package/dist/ui/view.d.ts.map +1 -1
- package/dist/ui/view.js +84 -64
- package/package.json +2 -2
- package/dist/application/action.d.ts +0 -26
- package/dist/application/action.d.ts.map +0 -1
- package/dist/application/action.js +0 -1
- package/dist/application/dir-buffer-helpers.d.ts +0 -6
- package/dist/application/dir-buffer-helpers.d.ts.map +0 -1
- package/dist/application/dir-buffer-helpers.js +0 -21
- package/dist/application/display-rows.d.ts +0 -11
- package/dist/application/display-rows.d.ts.map +0 -1
- package/dist/application/display-rows.js +0 -63
- package/dist/application/fold-helpers.d.ts +0 -24
- package/dist/application/fold-helpers.d.ts.map +0 -1
- package/dist/application/fold-helpers.js +0 -47
- package/dist/application/intent-to-effect.d.ts +0 -59
- package/dist/application/intent-to-effect.d.ts.map +0 -1
- package/dist/application/intent-to-effect.js +0 -131
- package/dist/application/user-input-to-intent.d.ts +0 -39
- package/dist/application/user-input-to-intent.d.ts.map +0 -1
- package/dist/application/user-input-to-intent.js +0 -110
- package/dist/domain/print-message.d.ts +0 -11
- package/dist/domain/print-message.d.ts.map +0 -1
- package/dist/domain/print-message.js +0 -1
- package/dist/infrastructure/input.d.ts +0 -12
- package/dist/infrastructure/input.d.ts.map +0 -1
- package/dist/infrastructure/input.js +0 -81
- package/dist/infrastructure/load-initial-props.d.ts +0 -3
- package/dist/infrastructure/load-initial-props.d.ts.map +0 -1
- package/dist/infrastructure/load-initial-props.js +0 -36
- package/dist/infrastructure/user-input.d.ts +0 -32
- package/dist/infrastructure/user-input.d.ts.map +0 -1
- package/dist/infrastructure/user-input.js +0 -45
- package/dist/ui/App2.d.ts +0 -16
- package/dist/ui/App2.d.ts.map +0 -1
- package/dist/ui/App2.js +0 -107
- package/dist/ui/components/DirEntries.d.ts +0 -11
- package/dist/ui/components/DirEntries.d.ts.map +0 -1
- package/dist/ui/components/DirEntries.js +0 -64
- package/dist/ui/components/UnixEntry.d.ts +0 -9
- package/dist/ui/components/UnixEntry.d.ts.map +0 -1
- package/dist/ui/components/UnixEntry.js +0 -19
- package/dist/ui/components/UnixEntryComponent.d.ts +0 -9
- package/dist/ui/components/UnixEntryComponent.d.ts.map +0 -1
- package/dist/ui/components/UnixEntryComponent.js +0 -19
package/dist/ui/App2.d.ts.map
DELETED
|
@@ -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 +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 +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
|
-
}
|