@mak-98/dirvi-cli 0.3.2 → 0.4.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/action.d.ts +25 -18
- package/dist/application/dir-buffer-helpers.d.ts +5 -2
- package/dist/application/dir-buffer-helpers.js +17 -17
- package/dist/application/display-rows.d.ts +10 -3
- package/dist/application/display-rows.d.ts.map +1 -1
- package/dist/application/display-rows.js +54 -41
- package/dist/application/effect-to-action.d.ts +7 -4
- package/dist/application/effect-to-action.d.ts.map +1 -1
- package/dist/application/effect-to-action.js +84 -75
- package/dist/application/fold-helpers.d.ts +22 -6
- package/dist/application/fold-helpers.js +36 -32
- package/dist/application/intent-to-effect.d.ts +57 -37
- package/dist/application/intent-to-effect.d.ts.map +1 -1
- package/dist/application/intent-to-effect.js +116 -103
- package/dist/application/reducer-action.d.ts +22 -18
- package/dist/application/reducer.d.ts +1 -1
- package/dist/application/reducer.d.ts.map +1 -1
- package/dist/application/reducer.js +40 -28
- package/dist/application/user-input-to-intent.d.ts +38 -14
- package/dist/application/user-input-to-intent.d.ts.map +1 -1
- package/dist/application/user-input-to-intent.js +103 -49
- package/dist/domain/event-message.d.ts +14 -11
- package/dist/domain/print-message.d.ts +10 -8
- package/dist/index.d.ts +1 -1
- package/dist/index.js +35 -30
- package/dist/infrastructure/ink-input-to-user-input.d.ts +7 -0
- package/dist/infrastructure/ink-input-to-user-input.d.ts.map +1 -0
- package/dist/infrastructure/ink-input-to-user-input.js +45 -0
- package/dist/infrastructure/input.d.ts +7 -2
- package/dist/infrastructure/input.js +71 -71
- package/dist/infrastructure/load-initial-props.d.ts +1 -1
- package/dist/infrastructure/load-initial-props.d.ts.map +1 -1
- package/dist/infrastructure/load-initial-props.js +32 -25
- package/dist/infrastructure/user-input.d.ts +31 -16
- package/dist/infrastructure/user-input.d.ts.map +1 -1
- package/dist/infrastructure/user-input.js +42 -32
- package/dist/ui/App.d.ts +11 -6
- package/dist/ui/App.d.ts.map +1 -1
- package/dist/ui/App.js +127 -89
- package/dist/ui/App2.d.ts +11 -6
- package/dist/ui/App2.js +95 -84
- package/dist/ui/AppShell.d.ts +12 -7
- package/dist/ui/AppShell.js +11 -6
- package/dist/ui/components/DirEntries.d.ts +8 -5
- package/dist/ui/components/DirEntries.js +56 -31
- package/dist/ui/components/StatusBar.d.ts +10 -0
- package/dist/ui/components/StatusBar.d.ts.map +1 -0
- package/dist/ui/components/StatusBar.js +32 -0
- package/dist/ui/components/UnixEntry.d.ts +8 -5
- package/dist/ui/components/UnixEntry.js +17 -10
- package/dist/ui/components/UnixEntryComponent.d.ts +8 -5
- package/dist/ui/components/UnixEntryComponent.js +17 -10
- package/dist/ui/components/ViewRowComponent.d.ts +6 -4
- package/dist/ui/components/ViewRowComponent.js +30 -10
- package/dist/ui/hooks/useView.d.ts +6 -2
- package/dist/ui/hooks/useView.d.ts.map +1 -1
- package/dist/ui/hooks/useView.js +30 -22
- package/dist/ui/view.d.ts +15 -10
- package/dist/ui/view.d.ts.map +1 -1
- package/dist/ui/view.js +63 -59
- package/package.json +3 -2
package/dist/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import { jsx as _jsx } from
|
|
2
|
+
import { jsx as _jsx } from 'react/jsx-runtime';
|
|
3
3
|
import { Command } from 'commander';
|
|
4
4
|
import { render } from 'ink';
|
|
5
5
|
import { AppShell } from './ui/AppShell.js';
|
|
@@ -15,57 +15,62 @@ const uiOutput = process.stderr;
|
|
|
15
15
|
// Note: if you pipe output you'll need to use FORCE_COLOR=3
|
|
16
16
|
// to keep interactive screen colored.
|
|
17
17
|
const emitEventMsg = (message) => {
|
|
18
|
-
|
|
18
|
+
process.stdout.write(`${JSON.stringify(message)}\n`);
|
|
19
19
|
};
|
|
20
20
|
const enterAlternateScreen = '\u001b[?1049h\u001b[2J\u001b[H\u001b[?25l';
|
|
21
21
|
const leaveAlternateScreen = '\u001b[?25h\u001b[?1049l';
|
|
22
22
|
// Idempotent terminal restoration
|
|
23
23
|
let alternateScreenActive = false;
|
|
24
24
|
const restoreTerminal = () => {
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
25
|
+
if (!alternateScreenActive) {
|
|
26
|
+
return;
|
|
27
|
+
}
|
|
28
|
+
uiOutput.write(leaveAlternateScreen);
|
|
29
|
+
alternateScreenActive = false;
|
|
30
30
|
};
|
|
31
31
|
// Node exit last resort
|
|
32
32
|
process.on('exit', restoreTerminal);
|
|
33
33
|
// ---*--- COMPOSITION ---*---
|
|
34
34
|
program
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
35
|
+
.name('direx')
|
|
36
|
+
.description('View and manage directories.')
|
|
37
|
+
.version('0.3.2')
|
|
38
|
+
.helpOption('--help')
|
|
39
|
+
.action(async () => {
|
|
40
40
|
const initialProps = await loadInitialProps();
|
|
41
41
|
let appError;
|
|
42
42
|
const useAlternateScreen = uiOutput.isTTY === true;
|
|
43
43
|
if (useAlternateScreen) {
|
|
44
|
-
|
|
45
|
-
|
|
44
|
+
uiOutput.write(enterAlternateScreen);
|
|
45
|
+
alternateScreenActive = true;
|
|
46
46
|
}
|
|
47
47
|
try {
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
48
|
+
const app = render(
|
|
49
|
+
_jsx(AppShell, {
|
|
50
|
+
...initialProps,
|
|
51
|
+
print: process.stdout.isTTY ? undefined : emitEventMsg,
|
|
52
|
+
onError: (error) => {
|
|
53
|
+
appError = error;
|
|
54
|
+
},
|
|
55
|
+
}),
|
|
56
|
+
{ stdout: uiOutput },
|
|
57
|
+
);
|
|
58
|
+
// Errors thrown while leaving this await still execute the finally block.
|
|
59
|
+
await app.waitUntilExit();
|
|
60
|
+
} finally {
|
|
61
|
+
restoreTerminal(); // Always restore terminal regardless of error
|
|
56
62
|
}
|
|
57
63
|
// Re-throw an error reported by AppShell after the terminal
|
|
58
64
|
// has been restored, so the outer catch can format it.
|
|
59
65
|
if (appError !== undefined) {
|
|
60
|
-
|
|
66
|
+
throw appError;
|
|
61
67
|
}
|
|
62
|
-
});
|
|
68
|
+
});
|
|
63
69
|
// ---*--- RUN AND HANDLE ERROR ---*---
|
|
64
70
|
try {
|
|
65
|
-
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
process.exitCode = 1;
|
|
71
|
+
await program.parseAsync(process.argv);
|
|
72
|
+
} catch (error) {
|
|
73
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
74
|
+
process.stderr.write(`direx: ${message}\n`);
|
|
75
|
+
process.exitCode = 1;
|
|
71
76
|
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ink-input-to-user-input.d.ts","sourceRoot":"","sources":["../../src/infrastructure/ink-input-to-user-input.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,KAAK,CAAC;AAC/B,OAAO,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AAGtC,wBAAgB,mBAAmB,CACjC,KAAK,EAAE,MAAM,EACb,GAAG,EAAE,GAAG,GACP,SAAS,GAAG,SAAS,CAmDvB"}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
// Interprets raw user input to typed UserInput.
|
|
2
|
+
export function inkInputToUserInput(input, key) {
|
|
3
|
+
if (key.escape) {
|
|
4
|
+
return {
|
|
5
|
+
userInputType: 'esc',
|
|
6
|
+
};
|
|
7
|
+
}
|
|
8
|
+
if (key.return) {
|
|
9
|
+
return {
|
|
10
|
+
userInputType: 'enter',
|
|
11
|
+
};
|
|
12
|
+
}
|
|
13
|
+
if (key.backspace) {
|
|
14
|
+
return {
|
|
15
|
+
userInputType: 'backspace',
|
|
16
|
+
};
|
|
17
|
+
}
|
|
18
|
+
if (key.rightArrow) {
|
|
19
|
+
return {
|
|
20
|
+
userInputType: 'rightArrow',
|
|
21
|
+
};
|
|
22
|
+
}
|
|
23
|
+
if (key.leftArrow) {
|
|
24
|
+
return {
|
|
25
|
+
userInputType: 'leftArrow',
|
|
26
|
+
};
|
|
27
|
+
}
|
|
28
|
+
if (key.upArrow) {
|
|
29
|
+
return {
|
|
30
|
+
userInputType: 'upArrow',
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
if (key.downArrow) {
|
|
34
|
+
return {
|
|
35
|
+
userInputType: 'downArrow',
|
|
36
|
+
};
|
|
37
|
+
}
|
|
38
|
+
if (input !== '') {
|
|
39
|
+
return {
|
|
40
|
+
userInputType: 'character',
|
|
41
|
+
string: input,
|
|
42
|
+
};
|
|
43
|
+
}
|
|
44
|
+
return undefined;
|
|
45
|
+
}
|
|
@@ -3,5 +3,10 @@ import { State } from 'dirvi-lib';
|
|
|
3
3
|
import { Action } from '../application/action.js';
|
|
4
4
|
export type PendingInput = 'z';
|
|
5
5
|
export type InputResult = Action | PendingInput | undefined;
|
|
6
|
-
export declare function userInputToInputResult(
|
|
7
|
-
|
|
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,81 +1,81 @@
|
|
|
1
1
|
import { Cursor, View } from 'dirvi-lib';
|
|
2
2
|
export function userInputToInputResult(input, key, view, pendingInput) {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
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
|
+
};
|
|
6
13
|
}
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
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;
|
|
14
|
+
if (input === 'c') {
|
|
15
|
+
return {
|
|
16
|
+
kind: 'fold',
|
|
17
|
+
};
|
|
55
18
|
}
|
|
56
|
-
if (input === '
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
return {
|
|
61
|
-
kind: 'outDir',
|
|
62
|
-
};
|
|
19
|
+
if (input === 'o') {
|
|
20
|
+
return {
|
|
21
|
+
kind: 'unfold',
|
|
22
|
+
};
|
|
63
23
|
}
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
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;
|
|
68
32
|
}
|
|
69
|
-
if (
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
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
|
+
};
|
|
73
43
|
}
|
|
74
|
-
if (
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
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
|
+
};
|
|
79
53
|
}
|
|
80
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
81
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"load-initial-props.d.ts","sourceRoot":"","sources":["../../src/infrastructure/load-initial-props.ts"],"names":[],"mappings":"
|
|
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,29 +1,36 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import {
|
|
2
|
+
getCwdAbsPath,
|
|
3
|
+
getDirLazyEntries,
|
|
4
|
+
FoldNode,
|
|
5
|
+
DisplayEntry,
|
|
6
|
+
} from 'dirvi-lib';
|
|
2
7
|
export async function loadInitialProps() {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
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
|
-
}
|
|
8
|
+
const cwdAddress = getCwdAbsPath();
|
|
9
|
+
const lazyEntries = await getDirLazyEntries(cwdAddress);
|
|
10
|
+
if (lazyEntries.length === 0) {
|
|
17
11
|
return {
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
kind: 'entry',
|
|
23
|
-
parentPath: [],
|
|
24
|
-
entryName: DisplayEntry.fromUnixEntry(firstEntry).name,
|
|
25
|
-
},
|
|
26
|
-
folds: FoldNode.createEmpty(),
|
|
27
|
-
},
|
|
12
|
+
cwdAddress,
|
|
13
|
+
initialState: {
|
|
14
|
+
cursor: undefined,
|
|
15
|
+
},
|
|
28
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
|
+
};
|
|
29
36
|
}
|
|
@@ -1,17 +1,32 @@
|
|
|
1
1
|
import type { Key } from 'ink';
|
|
2
|
-
export type UserInput =
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
|
|
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 +1 @@
|
|
|
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,
|
|
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"}
|
|
@@ -1,35 +1,45 @@
|
|
|
1
1
|
// Interprets raw user input to typed UserInput.
|
|
2
2
|
export function inkInputToUserInput(input, key) {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
return
|
|
3
|
+
if (key.escape) {
|
|
4
|
+
return {
|
|
5
|
+
userInputType: 'esc',
|
|
6
|
+
};
|
|
7
|
+
}
|
|
8
|
+
if (key.return) {
|
|
9
|
+
return {
|
|
10
|
+
userInputType: 'enter',
|
|
11
|
+
};
|
|
12
|
+
}
|
|
13
|
+
if (key.backspace) {
|
|
14
|
+
return {
|
|
15
|
+
userInputType: 'backspace',
|
|
16
|
+
};
|
|
17
|
+
}
|
|
18
|
+
if (key.rightArrow) {
|
|
19
|
+
return {
|
|
20
|
+
userInputType: 'rightArrow',
|
|
21
|
+
};
|
|
22
|
+
}
|
|
23
|
+
if (key.leftArrow) {
|
|
24
|
+
return {
|
|
25
|
+
userInputType: 'leftArrow',
|
|
26
|
+
};
|
|
27
|
+
}
|
|
28
|
+
if (key.upArrow) {
|
|
29
|
+
return {
|
|
30
|
+
userInputType: 'upArrow',
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
if (key.downArrow) {
|
|
34
|
+
return {
|
|
35
|
+
userInputType: 'downArrow',
|
|
36
|
+
};
|
|
37
|
+
}
|
|
38
|
+
if (input !== '') {
|
|
39
|
+
return {
|
|
40
|
+
userInputType: 'character',
|
|
41
|
+
string: input,
|
|
42
|
+
};
|
|
43
|
+
}
|
|
44
|
+
return undefined;
|
|
35
45
|
}
|
package/dist/ui/App.d.ts
CHANGED
|
@@ -2,10 +2,15 @@ import { State } from 'dirvi-lib';
|
|
|
2
2
|
import type { UnixAbsolutePath } from 'dirvi-lib';
|
|
3
3
|
import { EventMessage } from '../domain/event-message.js';
|
|
4
4
|
export type AppProps = {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
5
|
+
cwdAddress: UnixAbsolutePath;
|
|
6
|
+
initialState: State;
|
|
7
|
+
print?: (message: EventMessage) => void;
|
|
8
|
+
onError?: (error: Error) => void;
|
|
9
9
|
};
|
|
10
|
-
export declare function App({
|
|
11
|
-
|
|
10
|
+
export declare function App({
|
|
11
|
+
cwdAddress,
|
|
12
|
+
initialState,
|
|
13
|
+
print,
|
|
14
|
+
onError,
|
|
15
|
+
}: AppProps): import('react').JSX.Element | null;
|
|
16
|
+
//# sourceMappingURL=App.d.ts.map
|
package/dist/ui/App.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"App.d.ts","sourceRoot":"","sources":["../../src/ui/App.tsx"],"names":[],"mappings":"AAIA,OAAO,
|
|
1
|
+
{"version":3,"file":"App.d.ts","sourceRoot":"","sources":["../../src/ui/App.tsx"],"names":[],"mappings":"AAIA,OAAO,EAML,KAAK,EAEN,MAAM,WAAW,CAAC;AACnB,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,WAAW,CAAC;AAIlD,OAAO,EAAE,YAAY,EAAE,MAAM,4BAA4B,CAAC;AAM1D,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,GAAG,CAAC,EAAE,UAAU,EAAE,YAAY,EAAE,KAAK,EAAE,OAAO,EAAE,EAAE,QAAQ,sCA2IzE"}
|