@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.
- package/dist/application/effect-to-action.d.ts +4 -3
- package/dist/application/effect-to-action.d.ts.map +1 -1
- package/dist/application/effect-to-action.js +75 -71
- package/dist/application/reducer-action.d.ts +15 -11
- package/dist/application/reducer-action.d.ts.map +1 -1
- package/dist/application/reducer.d.ts +3 -2
- package/dist/application/reducer.d.ts.map +1 -1
- package/dist/application/reducer.js +66 -29
- 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 +6 -6
- package/dist/domain/event-message.d.ts.map +1 -1
- package/dist/index.js +13 -10
- 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 +4 -0
- package/dist/infrastructure/ink-input-to-user-input.d.ts.map +1 -0
- package/dist/infrastructure/{user-input.js → ink-input-to-user-input.js} +10 -0
- 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 +14 -8
- package/dist/ui/App.d.ts.map +1 -1
- package/dist/ui/App.js +68 -31
- package/dist/ui/AppShell.d.ts +4 -9
- package/dist/ui/AppShell.d.ts.map +1 -1
- package/dist/ui/AppShell.js +21 -7
- 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 +8 -0
- package/dist/ui/components/StatusBar.d.ts.map +1 -0
- package/dist/ui/components/StatusBar.js +7 -0
- package/dist/ui/components/ViewRowComponent.js +2 -2
- package/dist/ui/hooks/useView.d.ts +3 -2
- package/dist/ui/hooks/useView.d.ts.map +1 -1
- package/dist/ui/hooks/useView.js +5 -6
- package/dist/ui/view.d.ts +5 -4
- package/dist/ui/view.d.ts.map +1 -1
- package/dist/ui/view.js +55 -31
- package/package.json +3 -2
- package/dist/application/action.d.ts +0 -19
- 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 -3
- 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 -4
- package/dist/application/display-rows.d.ts.map +0 -1
- package/dist/application/display-rows.js +0 -50
- package/dist/application/fold-helpers.d.ts +0 -8
- package/dist/application/fold-helpers.d.ts.map +0 -1
- package/dist/application/fold-helpers.js +0 -43
- package/dist/application/intent-to-effect.d.ts +0 -39
- package/dist/application/intent-to-effect.d.ts.map +0 -1
- package/dist/application/intent-to-effect.js +0 -118
- package/dist/application/user-input-to-intent.d.ts +0 -15
- package/dist/application/user-input-to-intent.d.ts.map +0 -1
- package/dist/application/user-input-to-intent.js +0 -56
- package/dist/domain/print-message.d.ts +0 -9
- 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 -7
- 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 -29
- package/dist/infrastructure/user-input.d.ts +0 -17
- package/dist/infrastructure/user-input.d.ts.map +0 -1
- package/dist/ui/App2.d.ts +0 -11
- package/dist/ui/App2.d.ts.map +0 -1
- package/dist/ui/App2.js +0 -96
- package/dist/ui/components/DirEntries.d.ts +0 -8
- package/dist/ui/components/DirEntries.d.ts.map +0 -1
- package/dist/ui/components/DirEntries.js +0 -39
- package/dist/ui/components/UnixEntry.d.ts +0 -6
- package/dist/ui/components/UnixEntry.d.ts.map +0 -1
- package/dist/ui/components/UnixEntry.js +0 -12
- package/dist/ui/components/UnixEntryComponent.d.ts +0 -6
- package/dist/ui/components/UnixEntryComponent.d.ts.map +0 -1
- package/dist/ui/components/UnixEntryComponent.js +0 -12
package/dist/ui/App2.js
DELETED
|
@@ -1,96 +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(input, key, state, pendingInput.current);
|
|
26
|
-
if (result === undefined) {
|
|
27
|
-
return;
|
|
28
|
-
}
|
|
29
|
-
if (result === 'z') {
|
|
30
|
-
pendingInput.current = result;
|
|
31
|
-
return;
|
|
32
|
-
}
|
|
33
|
-
pendingInput.current = undefined;
|
|
34
|
-
const action = result;
|
|
35
|
-
// Contents of `updateDir` change meaning at this boundary:
|
|
36
|
-
if (action.kind === 'updateDir') {
|
|
37
|
-
// If the entry at the path is directory with no entries loaded:
|
|
38
|
-
if (action.entries === undefined) {
|
|
39
|
-
const path = Cursor.getPath(state.cursor);
|
|
40
|
-
if (path === undefined) {
|
|
41
|
-
return undefined;
|
|
42
|
-
}
|
|
43
|
-
const address = join(cwdAddress, ...path);
|
|
44
|
-
void getDirLazyEntries(address)
|
|
45
|
-
.then((entries) => {
|
|
46
|
-
dispatch({
|
|
47
|
-
kind: 'updateDir',
|
|
48
|
-
path: path,
|
|
49
|
-
entries,
|
|
50
|
-
});
|
|
51
|
-
})
|
|
52
|
-
.catch((error) => {
|
|
53
|
-
const appError = error instanceof Error ? error : new Error(String(error));
|
|
54
|
-
onError?.(appError);
|
|
55
|
-
setExitStatus(`Unable to open directory: ${appError.message}`);
|
|
56
|
-
});
|
|
57
|
-
}
|
|
58
|
-
else {
|
|
59
|
-
// Otherwise need to wipe the entries:
|
|
60
|
-
dispatch({
|
|
61
|
-
kind: 'updateDir',
|
|
62
|
-
path: action.path,
|
|
63
|
-
entries: undefined,
|
|
64
|
-
});
|
|
65
|
-
}
|
|
66
|
-
return;
|
|
67
|
-
}
|
|
68
|
-
if (action.kind === 'printFile') {
|
|
69
|
-
print?.({
|
|
70
|
-
type: 'file',
|
|
71
|
-
path: action.path,
|
|
72
|
-
});
|
|
73
|
-
return;
|
|
74
|
-
}
|
|
75
|
-
if (action.kind === 'exit') {
|
|
76
|
-
setExitStatus(action.exitMessage);
|
|
77
|
-
}
|
|
78
|
-
dispatch(action);
|
|
79
|
-
});
|
|
80
|
-
// --- Exit Logic ---
|
|
81
|
-
const { exit } = useApp();
|
|
82
|
-
useEffect(() => {
|
|
83
|
-
if (exitStatus === undefined) {
|
|
84
|
-
return;
|
|
85
|
-
}
|
|
86
|
-
if (exitStatus !== '') {
|
|
87
|
-
onError?.(new Error(exitStatus));
|
|
88
|
-
}
|
|
89
|
-
exit();
|
|
90
|
-
}, [exitStatus, exit, onError]);
|
|
91
|
-
if (exitStatus !== undefined) {
|
|
92
|
-
return null;
|
|
93
|
-
}
|
|
94
|
-
// --- JSX ---
|
|
95
|
-
return (_jsx(Box, { flexDirection: "column", children: view.rows.length === 0 ? (_jsx(Text, { dimColor: true, children: "Directory is empty." })) : (view.rows.map((row) => (_jsx(ViewRowComponent, { row: row }, row.id)))) }));
|
|
96
|
-
}
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import { Cursor } from 'dirvi-lib';
|
|
2
|
-
import { DisplayRow } from 'dirvi-lib';
|
|
3
|
-
declare function DirEntries({ rows, cursor }: {
|
|
4
|
-
rows: DisplayRow[];
|
|
5
|
-
cursor: Cursor;
|
|
6
|
-
}): import("react").JSX.Element;
|
|
7
|
-
export default DirEntries;
|
|
8
|
-
//# 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,39 +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) => Cursor.matchesDisplayRow(cursor, row));
|
|
11
|
-
const viewportHeight = Math.max(1, terminalRows);
|
|
12
|
-
const maximumViewportStart = Math.max(0, rows.length - viewportHeight);
|
|
13
|
-
let viewportStart = viewportStartRef.current;
|
|
14
|
-
if (cursorIndex >= 0) {
|
|
15
|
-
const firstVisibleCursorIndex = viewportStart + scrollMargin;
|
|
16
|
-
const lastVisibleCursorIndex = viewportStart + viewportHeight - 1 - scrollMargin;
|
|
17
|
-
if (cursorIndex < firstVisibleCursorIndex) {
|
|
18
|
-
// Cursor moved above the visible area.
|
|
19
|
-
viewportStart = cursorIndex - scrollMargin;
|
|
20
|
-
}
|
|
21
|
-
else if (cursorIndex > lastVisibleCursorIndex) {
|
|
22
|
-
// Cursor moved below the visible area.
|
|
23
|
-
viewportStart = cursorIndex - viewportHeight + 1 + scrollMargin;
|
|
24
|
-
}
|
|
25
|
-
}
|
|
26
|
-
viewportStart = Math.max(0, Math.min(viewportStart, maximumViewportStart));
|
|
27
|
-
viewportStartRef.current = viewportStart;
|
|
28
|
-
const visibleRows = rows.slice(viewportStart, viewportStart + viewportHeight);
|
|
29
|
-
return (_jsx(_Fragment, { children: visibleRows.map((row) => {
|
|
30
|
-
const selected = Cursor.matchesDisplayRow(cursor, row);
|
|
31
|
-
const indent = row.parentPath.length;
|
|
32
|
-
if (row.kind === 'fold') {
|
|
33
|
-
const key = `fold-${row.parentPath.join('/')}-${row.entryNames[0]}`;
|
|
34
|
-
return (_jsx(Box, { paddingLeft: indent * 2, children: _jsx(Text, { inverse: selected, dimColor: !selected, children: "..." }) }, key));
|
|
35
|
-
}
|
|
36
|
-
return (_jsx(Box, { paddingLeft: indent * 2, children: _jsx(UnixEntryComponent, { entry: row.entry, selected: selected }) }, [...row.parentPath, row.entry.name].join('/')));
|
|
37
|
-
}) }));
|
|
38
|
-
}
|
|
39
|
-
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,12 +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, { inverse: selected, children: [entry.name, " -> ", entry.target] }));
|
|
9
|
-
case 'directory':
|
|
10
|
-
return (_jsxs(Text, { inverse: selected, color: "blue", children: [entry.name, "/"] }));
|
|
11
|
-
}
|
|
12
|
-
}
|
|
@@ -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,12 +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, { inverse: selected, children: [entry.name, " -> ", entry.target] }));
|
|
9
|
-
case 'directory':
|
|
10
|
-
return (_jsxs(Text, { inverse: selected, color: "blue", children: [entry.name, "/"] }));
|
|
11
|
-
}
|
|
12
|
-
}
|