@mak-98/dirvi-cli 0.3.1 → 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
|
@@ -1,19 +1,26 @@
|
|
|
1
1
|
import { UnixEntry, UnixEntryPath } from 'dirvi-lib';
|
|
2
|
-
export type Action =
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
2
|
+
export type Action =
|
|
3
|
+
| {
|
|
4
|
+
kind: 'nextEntry';
|
|
5
|
+
}
|
|
6
|
+
| {
|
|
7
|
+
kind: 'prevEntry';
|
|
8
|
+
}
|
|
9
|
+
| {
|
|
10
|
+
kind: 'updateDir';
|
|
11
|
+
path: UnixEntryPath;
|
|
12
|
+
entries: UnixEntry[] | undefined;
|
|
13
|
+
}
|
|
14
|
+
| {
|
|
15
|
+
kind: 'outDir';
|
|
16
|
+
}
|
|
17
|
+
| {
|
|
18
|
+
kind: 'toggleFold';
|
|
19
|
+
}
|
|
20
|
+
| {
|
|
21
|
+
kind: 'fold';
|
|
22
|
+
}
|
|
23
|
+
| {
|
|
24
|
+
kind: 'unfold';
|
|
25
|
+
};
|
|
26
|
+
//# sourceMappingURL=action.d.ts.map
|
|
@@ -1,3 +1,6 @@
|
|
|
1
1
|
import type { UnixEntry, DirectoryBuffer, EntryPath } from 'dirvi-lib';
|
|
2
|
-
export declare function entryAtPath(
|
|
3
|
-
|
|
2
|
+
export declare function entryAtPath(
|
|
3
|
+
buffer: DirectoryBuffer,
|
|
4
|
+
path: EntryPath,
|
|
5
|
+
): UnixEntry | undefined;
|
|
6
|
+
//# sourceMappingURL=dir-buffer-helpers.d.ts.map
|
|
@@ -1,21 +1,21 @@
|
|
|
1
1
|
export function entryAtPath(buffer, path) {
|
|
2
|
-
|
|
3
|
-
|
|
2
|
+
if (path.length === 0) {
|
|
3
|
+
return undefined;
|
|
4
|
+
}
|
|
5
|
+
let entries = buffer.entries;
|
|
6
|
+
let entry;
|
|
7
|
+
for (const [index, name] of path.entries()) {
|
|
8
|
+
entry = entries.find((candidate) => candidate.name === name);
|
|
9
|
+
if (entry === undefined) {
|
|
10
|
+
return undefined;
|
|
4
11
|
}
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
for (const [index, name] of path.entries()) {
|
|
8
|
-
entry = entries.find((candidate) => candidate.name === name);
|
|
9
|
-
if (entry === undefined) {
|
|
10
|
-
return undefined;
|
|
11
|
-
}
|
|
12
|
-
if (index === path.length - 1) {
|
|
13
|
-
return entry;
|
|
14
|
-
}
|
|
15
|
-
if (entry.kind !== 'directory' || entry.entries === undefined) {
|
|
16
|
-
return undefined;
|
|
17
|
-
}
|
|
18
|
-
entries = entry.entries;
|
|
12
|
+
if (index === path.length - 1) {
|
|
13
|
+
return entry;
|
|
19
14
|
}
|
|
20
|
-
|
|
15
|
+
if (entry.kind !== 'directory' || entry.entries === undefined) {
|
|
16
|
+
return undefined;
|
|
17
|
+
}
|
|
18
|
+
entries = entry.entries;
|
|
19
|
+
}
|
|
20
|
+
return undefined;
|
|
21
21
|
}
|
|
@@ -1,4 +1,11 @@
|
|
|
1
1
|
import { DisplayRow, UnixEntryPath, FoldNode, UnixEntry } from 'dirvi-lib';
|
|
2
|
-
export declare function createDisplayRows(
|
|
3
|
-
|
|
4
|
-
|
|
2
|
+
export declare function createDisplayRows(
|
|
3
|
+
buffer: UnixEntry[],
|
|
4
|
+
folds: FoldNode,
|
|
5
|
+
): DisplayRow[];
|
|
6
|
+
export declare function displayRowAtPath(
|
|
7
|
+
buffer: UnixEntry[],
|
|
8
|
+
folds: FoldNode,
|
|
9
|
+
path: UnixEntryPath,
|
|
10
|
+
): DisplayRow | undefined;
|
|
11
|
+
//# sourceMappingURL=display-rows.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"display-rows.d.ts","sourceRoot":"","sources":["../../src/application/display-rows.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,UAAU,EACV,aAAa,
|
|
1
|
+
{"version":3,"file":"display-rows.d.ts","sourceRoot":"","sources":["../../src/application/display-rows.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,UAAU,EACV,aAAa,EACb,QAAQ,EACR,SAAS,EAEV,MAAM,WAAW,CAAC;AAuDnB,wBAAgB,iBAAiB,CAC/B,MAAM,EAAE,SAAS,EAAE,EACnB,KAAK,EAAE,QAAQ,GACd,UAAU,EAAE,CAEd;AAED,wBAAgB,gBAAgB,CAC9B,MAAM,EAAE,SAAS,EAAE,EACnB,KAAK,EAAE,QAAQ,EACf,IAAI,EAAE,aAAa,GAClB,UAAU,GAAG,SAAS,CAsBxB"}
|
|
@@ -1,50 +1,63 @@
|
|
|
1
|
-
import { UnixEntryPath, FoldNode
|
|
1
|
+
import { UnixEntryPath, FoldNode } from 'dirvi-lib';
|
|
2
2
|
function displayRowsAtPath(entries, path, foldNode) {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
rows.push({
|
|
15
|
-
kind: 'fold',
|
|
16
|
-
parentPath: path,
|
|
17
|
-
entryNames,
|
|
18
|
-
});
|
|
19
|
-
continue;
|
|
20
|
-
}
|
|
21
|
-
rows.push({
|
|
22
|
-
kind: 'entry',
|
|
23
|
-
parentPath: path,
|
|
24
|
-
entry,
|
|
25
|
-
});
|
|
26
|
-
if (entry.kind === 'directory' && entry.entries !== undefined) {
|
|
27
|
-
rows.push(...displayRowsAtPath(entry.entries, [...path, entry.name], foldNode?.children[entry.name]));
|
|
28
|
-
}
|
|
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);
|
|
29
14
|
index += 1;
|
|
15
|
+
}
|
|
16
|
+
rows.push({
|
|
17
|
+
kind: 'fold',
|
|
18
|
+
parentPath: path,
|
|
19
|
+
entryNames,
|
|
20
|
+
});
|
|
21
|
+
continue;
|
|
30
22
|
}
|
|
31
|
-
|
|
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;
|
|
32
40
|
}
|
|
33
41
|
export function createDisplayRows(buffer, folds) {
|
|
34
|
-
|
|
42
|
+
return displayRowsAtPath(buffer, [], folds);
|
|
35
43
|
}
|
|
36
44
|
export function displayRowAtPath(buffer, folds, path) {
|
|
37
|
-
|
|
38
|
-
|
|
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
|
+
);
|
|
39
57
|
}
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
return (row.entry.name === entryName && UnixEntryPath.equal(row.parentPath, parentPath));
|
|
46
|
-
}
|
|
47
|
-
return (UnixEntryPath.equal(row.parentPath, parentPath) &&
|
|
48
|
-
row.entryNames.includes(entryName));
|
|
49
|
-
});
|
|
58
|
+
return (
|
|
59
|
+
UnixEntryPath.equal(row.parentPath, parentPath) &&
|
|
60
|
+
row.entryNames.includes(entryName)
|
|
61
|
+
);
|
|
62
|
+
});
|
|
50
63
|
}
|
|
@@ -1,5 +1,8 @@
|
|
|
1
|
-
import { NavigationNode, State } from 'dirvi-lib';
|
|
1
|
+
import { NavigationNode, State, EffectAction } from 'dirvi-lib';
|
|
2
2
|
import type { ReducerAction } from './reducer-action.js';
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
3
|
+
export declare function effectToAction(
|
|
4
|
+
effectAction: EffectAction,
|
|
5
|
+
navigation: NavigationNode,
|
|
6
|
+
state: State,
|
|
7
|
+
): ReducerAction | undefined;
|
|
8
|
+
//# sourceMappingURL=effect-to-action.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"effect-to-action.d.ts","sourceRoot":"","sources":["../../src/application/effect-to-action.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,KAAK,EAAE,MAAM,WAAW,CAAC;
|
|
1
|
+
{"version":3,"file":"effect-to-action.d.ts","sourceRoot":"","sources":["../../src/application/effect-to-action.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,KAAK,EAAE,YAAY,EAAE,MAAM,WAAW,CAAC;AAEhE,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AAEzD,wBAAgB,cAAc,CAC5B,YAAY,EAAE,YAAY,EAC1B,UAAU,EAAE,cAAc,EAC1B,KAAK,EAAE,KAAK,GACX,aAAa,GAAG,SAAS,CAwG3B"}
|
|
@@ -1,79 +1,88 @@
|
|
|
1
1
|
import { NavigationNode } from 'dirvi-lib';
|
|
2
2
|
export function effectToAction(effectAction, navigation, state) {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
}
|
|
13
|
-
case 'prevEntry': {
|
|
14
|
-
const cursor = NavigationNode.previousCursor(navigation, state.cursor);
|
|
15
|
-
return cursor === undefined
|
|
16
|
-
? undefined
|
|
17
|
-
: {
|
|
18
|
-
kind: 'changeCursor',
|
|
19
|
-
cursor,
|
|
20
|
-
};
|
|
21
|
-
}
|
|
22
|
-
case 'updateDir':
|
|
23
|
-
return {
|
|
24
|
-
kind: 'updateDir',
|
|
25
|
-
path: effectAction.path,
|
|
26
|
-
entries: effectAction.entries,
|
|
27
|
-
};
|
|
28
|
-
case 'outDir': {
|
|
29
|
-
const cursor = NavigationNode.parentCursor(navigation, state.cursor);
|
|
30
|
-
return cursor === undefined
|
|
31
|
-
? undefined
|
|
32
|
-
: {
|
|
33
|
-
kind: 'changeCursor',
|
|
34
|
-
cursor,
|
|
35
|
-
};
|
|
36
|
-
}
|
|
37
|
-
case 'fold': {
|
|
38
|
-
if (state.cursor.kind === 'fold') {
|
|
39
|
-
return undefined;
|
|
40
|
-
}
|
|
41
|
-
const path = [...state.cursor.parentPath, state.cursor.entryName];
|
|
42
|
-
const entry = NavigationNode.getEntryAtPath(navigation, path);
|
|
43
|
-
if (entry === undefined) {
|
|
44
|
-
return undefined;
|
|
45
|
-
}
|
|
46
|
-
const cursor = NavigationNode.cursorAfterFold(navigation, state.cursor);
|
|
47
|
-
if (cursor === undefined) {
|
|
48
|
-
return undefined;
|
|
49
|
-
}
|
|
50
|
-
return {
|
|
51
|
-
kind: 'fold',
|
|
52
|
-
parentPath: state.cursor.parentPath,
|
|
53
|
-
entry,
|
|
54
|
-
cursor,
|
|
55
|
-
};
|
|
56
|
-
}
|
|
57
|
-
case 'unfold': {
|
|
58
|
-
if (state.cursor.kind !== 'fold') {
|
|
59
|
-
return undefined;
|
|
60
|
-
}
|
|
61
|
-
const node = NavigationNode.getNodeAtPath(navigation, state.cursor.parentPath);
|
|
62
|
-
if (node === undefined || node.foldedEntries.length === 0) {
|
|
63
|
-
return undefined;
|
|
64
|
-
}
|
|
65
|
-
const firstFoldedEntry = node.foldedEntries[0];
|
|
66
|
-
return {
|
|
67
|
-
kind: 'unfold',
|
|
68
|
-
parentPath: state.cursor.parentPath,
|
|
69
|
-
cursor: {
|
|
70
|
-
kind: 'entry',
|
|
71
|
-
parentPath: state.cursor.parentPath,
|
|
72
|
-
entryName: firstFoldedEntry.name,
|
|
73
|
-
},
|
|
74
|
-
};
|
|
75
|
-
}
|
|
76
|
-
case 'toggleFold':
|
|
77
|
-
return effectToAction(state.cursor.kind === 'fold' ? { kind: 'unfold' } : { kind: 'fold' }, navigation, state);
|
|
3
|
+
switch (effectAction.effectActionType) {
|
|
4
|
+
case 'nextEntry': {
|
|
5
|
+
const cursor = NavigationNode.nextCursor(navigation, state.cursor);
|
|
6
|
+
return cursor === undefined
|
|
7
|
+
? undefined
|
|
8
|
+
: {
|
|
9
|
+
kind: 'changeCursor',
|
|
10
|
+
cursor,
|
|
11
|
+
};
|
|
78
12
|
}
|
|
13
|
+
case 'prevEntry': {
|
|
14
|
+
const cursor = NavigationNode.previousCursor(navigation, state.cursor);
|
|
15
|
+
return cursor === undefined
|
|
16
|
+
? undefined
|
|
17
|
+
: {
|
|
18
|
+
kind: 'changeCursor',
|
|
19
|
+
cursor,
|
|
20
|
+
};
|
|
21
|
+
}
|
|
22
|
+
case 'updateDir':
|
|
23
|
+
return {
|
|
24
|
+
kind: 'updateDir',
|
|
25
|
+
path: effectAction.path,
|
|
26
|
+
entries: effectAction.entries,
|
|
27
|
+
};
|
|
28
|
+
case 'outDir': {
|
|
29
|
+
const cursor = NavigationNode.parentCursor(navigation, state.cursor);
|
|
30
|
+
return cursor === undefined
|
|
31
|
+
? undefined
|
|
32
|
+
: {
|
|
33
|
+
kind: 'changeCursor',
|
|
34
|
+
cursor,
|
|
35
|
+
};
|
|
36
|
+
}
|
|
37
|
+
case 'fold': {
|
|
38
|
+
if (state.cursor.kind === 'fold') {
|
|
39
|
+
return undefined;
|
|
40
|
+
}
|
|
41
|
+
const path = [...state.cursor.parentPath, state.cursor.entryName];
|
|
42
|
+
const entry = NavigationNode.getEntryAtPath(navigation, path);
|
|
43
|
+
if (entry === undefined) {
|
|
44
|
+
return undefined;
|
|
45
|
+
}
|
|
46
|
+
const cursor = NavigationNode.cursorAfterFold(navigation, state.cursor);
|
|
47
|
+
if (cursor === undefined) {
|
|
48
|
+
return undefined;
|
|
49
|
+
}
|
|
50
|
+
return {
|
|
51
|
+
kind: 'fold',
|
|
52
|
+
parentPath: state.cursor.parentPath,
|
|
53
|
+
entry,
|
|
54
|
+
cursor,
|
|
55
|
+
};
|
|
56
|
+
}
|
|
57
|
+
case 'unfold': {
|
|
58
|
+
if (state.cursor.kind !== 'fold') {
|
|
59
|
+
return undefined;
|
|
60
|
+
}
|
|
61
|
+
const node = NavigationNode.getNodeAtPath(
|
|
62
|
+
navigation,
|
|
63
|
+
state.cursor.parentPath,
|
|
64
|
+
);
|
|
65
|
+
if (node === undefined || node.foldedEntries.length === 0) {
|
|
66
|
+
return undefined;
|
|
67
|
+
}
|
|
68
|
+
const firstFoldedEntry = node.foldedEntries[0];
|
|
69
|
+
return {
|
|
70
|
+
kind: 'unfold',
|
|
71
|
+
parentPath: state.cursor.parentPath,
|
|
72
|
+
cursor: {
|
|
73
|
+
kind: 'entry',
|
|
74
|
+
parentPath: state.cursor.parentPath,
|
|
75
|
+
entryName: firstFoldedEntry.name,
|
|
76
|
+
},
|
|
77
|
+
};
|
|
78
|
+
}
|
|
79
|
+
case 'toggleFold':
|
|
80
|
+
return effectToAction(
|
|
81
|
+
state.cursor.kind === 'fold'
|
|
82
|
+
? { effectActionType: 'unfold' }
|
|
83
|
+
: { effectActionType: 'fold' },
|
|
84
|
+
navigation,
|
|
85
|
+
state,
|
|
86
|
+
);
|
|
87
|
+
}
|
|
79
88
|
}
|
|
@@ -1,8 +1,24 @@
|
|
|
1
1
|
import type { UnixEntry, UnixEntryName } from 'dirvi-lib';
|
|
2
2
|
import { FoldNode } from 'dirvi-lib';
|
|
3
|
-
export declare function hasFold(
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
export declare function
|
|
8
|
-
|
|
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,43 +1,47 @@
|
|
|
1
1
|
export function hasFold(node, entryName) {
|
|
2
|
-
|
|
2
|
+
return node.folds.includes(entryName);
|
|
3
3
|
}
|
|
4
4
|
export function entryIsFolded(node, entry) {
|
|
5
|
-
|
|
5
|
+
return node !== undefined && hasFold(node, entry.name);
|
|
6
6
|
}
|
|
7
7
|
// Replaces all folds at a node
|
|
8
8
|
export function setFolds(node, entries) {
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
9
|
+
const entryNames = entries.map((entry) => entry.name);
|
|
10
|
+
return {
|
|
11
|
+
...node,
|
|
12
|
+
folds: entryNames,
|
|
13
|
+
};
|
|
14
14
|
}
|
|
15
15
|
export function addFold(node, entryName) {
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
16
|
+
if (hasFold(node, entryName)) {
|
|
17
|
+
return node;
|
|
18
|
+
}
|
|
19
|
+
return {
|
|
20
|
+
...node,
|
|
21
|
+
folds: [...node.folds, entryName],
|
|
22
|
+
};
|
|
23
23
|
}
|
|
24
24
|
export function unfoldFoldSequence(node, entries, entryName) {
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
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
|
+
};
|
|
43
47
|
}
|
|
@@ -1,39 +1,59 @@
|
|
|
1
1
|
import { State } from 'dirvi-lib';
|
|
2
|
-
import {
|
|
2
|
+
import {
|
|
3
|
+
InputMode,
|
|
4
|
+
Intent,
|
|
5
|
+
} from '../../../dirvi-lib/src/application/user-input-to-intent.js';
|
|
3
6
|
import { UnixEntry, UnixEntryPath } from 'dirvi-lib';
|
|
4
|
-
export type EffectAction =
|
|
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
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
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 +1 @@
|
|
|
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,MAAM,EAAE,MAAM,
|
|
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"}
|