dirvi-lib 0.3.0 → 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/intent-to-effect-no-state.test.d.ts +2 -0
- package/dist/application/intent-to-effect-no-state.test.d.ts.map +1 -0
- package/dist/application/intent-to-effect-no-state.test.js +178 -0
- package/dist/application/intent-to-effect.d.ts +8 -0
- package/dist/application/intent-to-effect.d.ts.map +1 -0
- package/dist/application/intent-to-effect.js +142 -0
- package/dist/application/intent-to-effect.test-no-state.d.ts +2 -0
- package/dist/application/intent-to-effect.test-no-state.d.ts.map +1 -0
- package/dist/application/intent-to-effect.test-no-state.js +178 -0
- package/dist/application/user-input-to-intent.d.ts +8 -0
- package/dist/application/user-input-to-intent.d.ts.map +1 -0
- package/dist/application/user-input-to-intent.js +98 -0
- package/dist/application/user-input-to-intent.test.d.ts +2 -0
- package/dist/application/user-input-to-intent.test.d.ts.map +1 -0
- package/dist/application/user-input-to-intent.test.js +125 -0
- package/dist/domain/cursor.d.ts +15 -13
- package/dist/domain/cursor.js +43 -41
- package/dist/domain/display-row.d.ts +28 -23
- package/dist/domain/display-row.d.ts.map +1 -1
- package/dist/domain/display-row.js +26 -22
- package/dist/domain/effect.d.ts +48 -0
- package/dist/domain/effect.d.ts.map +1 -0
- package/dist/domain/effect.js +1 -0
- package/dist/domain/fold-node.d.ts +20 -12
- package/dist/domain/fold-node.js +82 -70
- package/dist/domain/input-state.d.ts +10 -0
- package/dist/domain/input-state.d.ts.map +1 -0
- package/dist/domain/input-state.js +1 -0
- package/dist/domain/intent.d.ts +34 -0
- package/dist/domain/intent.d.ts.map +1 -0
- package/dist/domain/intent.js +1 -0
- package/dist/domain/navigation-node.d.ts +47 -32
- package/dist/domain/navigation-node.js +201 -189
- package/dist/domain/state.d.ts +5 -5
- package/dist/domain/state.d.ts.map +1 -1
- package/dist/domain/state.js +7 -7
- package/dist/domain/unix-entry.d.ts +35 -19
- package/dist/domain/unix-entry.d.ts.map +1 -1
- package/dist/domain/unix-entry.js +94 -82
- package/dist/domain/unix-path.d.ts +1 -1
- package/dist/domain/unix-path.js +9 -6
- package/dist/domain/user-input.d.ts +27 -0
- package/dist/domain/user-input.d.ts.map +1 -0
- package/dist/domain/user-input.js +1 -0
- package/dist/index.d.ts +6 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +5 -0
- package/dist/infrastructure/get-cwd.d.ts +1 -1
- package/dist/infrastructure/get-cwd.js +12 -10
- package/dist/infrastructure/get-dir-lazy-entries.d.ts +4 -2
- package/dist/infrastructure/get-dir-lazy-entries.js +34 -28
- package/package.json +4 -2
- package/dist/domain/fold.d.ts +0 -10
- package/dist/domain/fold.d.ts.map +0 -1
- package/dist/domain/fold.js +0 -24
- package/dist/domain/navigation-entry.d.ts +0 -23
- package/dist/domain/navigation-entry.d.ts.map +0 -1
- package/dist/domain/navigation-entry.js +0 -52
- package/dist/domain/view.d.ts +0 -15
- package/dist/domain/view.d.ts.map +0 -1
- package/dist/domain/view.js +0 -12
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
export type Intent = NormalModeIntent | CommandLineIntent;
|
|
2
|
+
export type NormalModeIntent =
|
|
3
|
+
| {
|
|
4
|
+
intentType: 'normalRight';
|
|
5
|
+
}
|
|
6
|
+
| {
|
|
7
|
+
intentType: 'normalLeft';
|
|
8
|
+
}
|
|
9
|
+
| {
|
|
10
|
+
intentType: 'normalDown';
|
|
11
|
+
}
|
|
12
|
+
| {
|
|
13
|
+
intentType: 'normalUp';
|
|
14
|
+
}
|
|
15
|
+
| {
|
|
16
|
+
intentType: 'setNormalBuffer';
|
|
17
|
+
normalBuffer: string;
|
|
18
|
+
};
|
|
19
|
+
export type CommandLineIntent =
|
|
20
|
+
| {
|
|
21
|
+
intentType: 'enterCommandLineMode';
|
|
22
|
+
}
|
|
23
|
+
| {
|
|
24
|
+
intentType: 'setCommandLine';
|
|
25
|
+
commandLine: string;
|
|
26
|
+
}
|
|
27
|
+
| {
|
|
28
|
+
intentType: 'executeCommandLine';
|
|
29
|
+
commandLine: string;
|
|
30
|
+
}
|
|
31
|
+
| {
|
|
32
|
+
intentType: 'exitCommandLineMode';
|
|
33
|
+
};
|
|
34
|
+
//# sourceMappingURL=intent.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"intent.d.ts","sourceRoot":"","sources":["../../src/domain/intent.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,MAAM,GAAG,gBAAgB,GAAG,iBAAiB,CAAC;AAE1D,MAAM,MAAM,gBAAgB,GACxB;IACE,UAAU,EAAE,aAAa,CAAC;CAC3B,GACD;IACE,UAAU,EAAE,YAAY,CAAC;CAC1B,GACD;IACE,UAAU,EAAE,YAAY,CAAC;CAC1B,GACD;IACE,UAAU,EAAE,UAAU,CAAC;CACxB,GACD;IACE,UAAU,EAAE,iBAAiB,CAAC;IAC9B,YAAY,EAAE,MAAM,CAAC;CACtB,CAAC;AAEN,MAAM,MAAM,iBAAiB,GACzB;IACE,UAAU,EAAE,sBAAsB,CAAC;CACpC,GACD;IACE,UAAU,EAAE,gBAAgB,CAAC;IAC7B,WAAW,EAAE,MAAM,CAAC;CACrB,GACD;IACE,UAAU,EAAE,oBAAoB,CAAC;IACjC,WAAW,EAAE,MAAM,CAAC;CACrB,GACD;IACE,UAAU,EAAE,qBAAqB,CAAC;CACnC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -2,42 +2,57 @@ import { UnixEntry, UnixEntryName, UnixEntryPath } from './unix-entry.js';
|
|
|
2
2
|
import { UnixPath } from './unix-path.js';
|
|
3
3
|
import { FoldNode } from './fold-node.js';
|
|
4
4
|
import { Cursor } from './cursor.js';
|
|
5
|
-
export type NavigationEntry =
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
5
|
+
export type NavigationEntry =
|
|
6
|
+
| {
|
|
7
|
+
kind: 'file';
|
|
8
|
+
name: UnixEntryName;
|
|
9
|
+
}
|
|
10
|
+
| {
|
|
11
|
+
kind: 'symlink';
|
|
12
|
+
name: UnixEntryName;
|
|
13
|
+
target: UnixPath;
|
|
14
|
+
}
|
|
15
|
+
| {
|
|
16
|
+
/**
|
|
17
|
+
* Undefined node means the directory has not been loaded.
|
|
18
|
+
*/
|
|
19
|
+
kind: 'directory';
|
|
20
|
+
name: UnixEntryName;
|
|
21
|
+
node?: NavigationNode;
|
|
22
|
+
};
|
|
20
23
|
/**
|
|
21
24
|
* A directory as navigated: list of visible entries and folded entries.
|
|
22
25
|
*/
|
|
23
26
|
export type NavigationNode = {
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
27
|
+
/**
|
|
28
|
+
* Currently visible entries.
|
|
29
|
+
*/
|
|
30
|
+
entries: NavigationEntry[];
|
|
31
|
+
/**
|
|
32
|
+
* Currently loaded entries hidden by this directory's fold.
|
|
33
|
+
*/
|
|
34
|
+
foldedEntries: NavigationEntry[];
|
|
32
35
|
};
|
|
33
36
|
export declare const NavigationNode: {
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
37
|
+
from(
|
|
38
|
+
entries: UnixEntry[] | undefined,
|
|
39
|
+
foldNode: FoldNode | undefined,
|
|
40
|
+
): NavigationNode;
|
|
41
|
+
getNodeAtPath(
|
|
42
|
+
navigation: NavigationNode,
|
|
43
|
+
path: UnixEntryPath,
|
|
44
|
+
): NavigationNode | undefined;
|
|
45
|
+
getEntryAtPath(
|
|
46
|
+
navigation: NavigationNode,
|
|
47
|
+
path: UnixEntryPath,
|
|
48
|
+
): NavigationEntry | undefined;
|
|
49
|
+
nextCursor(rootNode: NavigationNode, cursor: Cursor): Cursor | undefined;
|
|
50
|
+
previousCursor(rootNode: NavigationNode, cursor: Cursor): Cursor | undefined;
|
|
51
|
+
cursorAfterFold(rootNode: NavigationNode, cursor: Cursor): Cursor | undefined;
|
|
52
|
+
parentCursor(navigation: NavigationNode, cursor: Cursor): Cursor | undefined;
|
|
53
|
+
visibleFilesPaths(
|
|
54
|
+
navigation: NavigationNode,
|
|
55
|
+
parentPath?: UnixEntryPath,
|
|
56
|
+
): UnixEntryPath[];
|
|
42
57
|
};
|
|
43
|
-
//# sourceMappingURL=navigation-node.d.ts.map
|
|
58
|
+
//# sourceMappingURL=navigation-node.d.ts.map
|
|
@@ -1,198 +1,210 @@
|
|
|
1
1
|
import { UnixEntryPath } from './unix-entry.js';
|
|
2
2
|
import { Cursor } from './cursor.js';
|
|
3
3
|
export const NavigationNode = {
|
|
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
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
4
|
+
from(entries, foldNode) {
|
|
5
|
+
if (entries === undefined) {
|
|
6
|
+
return {
|
|
7
|
+
entries: [],
|
|
8
|
+
foldedEntries: [],
|
|
9
|
+
};
|
|
10
|
+
}
|
|
11
|
+
const foldedNames = new Set(foldNode?.folds ?? []);
|
|
12
|
+
const visibleEntries = [];
|
|
13
|
+
const foldedEntries = [];
|
|
14
|
+
for (const entry of entries) {
|
|
15
|
+
let navigationEntry;
|
|
16
|
+
switch (entry.kind) {
|
|
17
|
+
case 'file':
|
|
18
|
+
navigationEntry = {
|
|
19
|
+
kind: 'file',
|
|
20
|
+
name: entry.name,
|
|
21
|
+
};
|
|
22
|
+
break;
|
|
23
|
+
case 'symlink':
|
|
24
|
+
navigationEntry = {
|
|
25
|
+
kind: 'symlink',
|
|
26
|
+
name: entry.name,
|
|
27
|
+
target: entry.target,
|
|
28
|
+
};
|
|
29
|
+
break;
|
|
30
|
+
case 'directory': {
|
|
31
|
+
const childFoldNode = foldNode?.children[entry.name];
|
|
32
|
+
navigationEntry = {
|
|
33
|
+
kind: 'directory',
|
|
34
|
+
name: entry.name,
|
|
35
|
+
node:
|
|
36
|
+
entry.entries === undefined
|
|
37
|
+
? undefined
|
|
38
|
+
: NavigationNode.from(entry.entries, childFoldNode),
|
|
39
|
+
};
|
|
40
|
+
break;
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
if (foldedNames.has(entry.name)) {
|
|
44
|
+
foldedEntries.push(navigationEntry);
|
|
45
|
+
} else {
|
|
46
|
+
visibleEntries.push(navigationEntry);
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
return {
|
|
50
|
+
entries: visibleEntries,
|
|
51
|
+
foldedEntries,
|
|
52
|
+
};
|
|
53
|
+
},
|
|
54
|
+
getNodeAtPath(navigation, path) {
|
|
55
|
+
const [currentName, ...remainingPath] = path;
|
|
56
|
+
// An empty path identifies the current node.
|
|
57
|
+
if (currentName === undefined) {
|
|
58
|
+
return navigation;
|
|
59
|
+
}
|
|
60
|
+
const entry = [...navigation.entries, ...navigation.foldedEntries].find(
|
|
61
|
+
(candidate) => candidate.name === currentName,
|
|
62
|
+
);
|
|
63
|
+
if (entry === undefined || entry.kind !== 'directory') {
|
|
64
|
+
return undefined;
|
|
65
|
+
}
|
|
66
|
+
// The directory has not been loaded/opened.
|
|
67
|
+
if (entry.node === undefined) {
|
|
68
|
+
return undefined;
|
|
69
|
+
}
|
|
70
|
+
return NavigationNode.getNodeAtPath(entry.node, remainingPath);
|
|
71
|
+
},
|
|
72
|
+
getEntryAtPath(navigation, path) {
|
|
73
|
+
const [currentName, ...remainingPath] = path;
|
|
74
|
+
if (currentName === undefined) {
|
|
75
|
+
return undefined;
|
|
76
|
+
}
|
|
77
|
+
const entry = [...navigation.entries, ...navigation.foldedEntries].find(
|
|
78
|
+
(candidate) => candidate.name === currentName,
|
|
79
|
+
);
|
|
80
|
+
if (entry === undefined) {
|
|
81
|
+
return undefined;
|
|
82
|
+
}
|
|
83
|
+
if (remainingPath.length === 0) {
|
|
84
|
+
return entry;
|
|
85
|
+
}
|
|
86
|
+
if (entry.kind !== 'directory' || entry.node === undefined) {
|
|
87
|
+
return undefined;
|
|
88
|
+
}
|
|
89
|
+
return NavigationNode.getEntryAtPath(entry.node, remainingPath);
|
|
90
|
+
},
|
|
91
|
+
nextCursor(rootNode, cursor) {
|
|
92
|
+
const cursors = cursorsInNode(rootNode, []);
|
|
93
|
+
const currentIndex = cursors.findIndex((candidate) =>
|
|
94
|
+
Cursor.equal(candidate, cursor),
|
|
95
|
+
);
|
|
96
|
+
if (currentIndex === -1 || currentIndex === cursors.length - 1) {
|
|
97
|
+
return undefined;
|
|
98
|
+
}
|
|
99
|
+
return cursors[currentIndex + 1];
|
|
100
|
+
},
|
|
101
|
+
previousCursor(rootNode, cursor) {
|
|
102
|
+
const cursors = cursorsInNode(rootNode, []);
|
|
103
|
+
const currentIndex = cursors.findIndex((candidate) =>
|
|
104
|
+
Cursor.equal(candidate, cursor),
|
|
105
|
+
);
|
|
106
|
+
if (currentIndex <= 0) {
|
|
107
|
+
return undefined;
|
|
108
|
+
}
|
|
109
|
+
return cursors[currentIndex - 1];
|
|
110
|
+
},
|
|
111
|
+
cursorAfterFold(rootNode, cursor) {
|
|
112
|
+
if (cursor.kind === 'fold') {
|
|
113
|
+
return undefined;
|
|
114
|
+
}
|
|
115
|
+
const cursors = cursorsInNode(rootNode, []);
|
|
116
|
+
const currentIndex = cursors.findIndex((candidate) =>
|
|
117
|
+
Cursor.equal(candidate, cursor),
|
|
118
|
+
);
|
|
119
|
+
if (currentIndex === -1) {
|
|
120
|
+
return undefined;
|
|
121
|
+
}
|
|
122
|
+
const foldedPath = [...cursor.parentPath, cursor.entryName];
|
|
123
|
+
for (let index = currentIndex + 1; index < cursors.length; index += 1) {
|
|
124
|
+
const candidate = cursors[index];
|
|
125
|
+
if (candidate === undefined) {
|
|
126
|
+
continue;
|
|
127
|
+
}
|
|
128
|
+
if (cursorBelongsToSubtree(candidate, foldedPath)) {
|
|
129
|
+
continue;
|
|
130
|
+
}
|
|
131
|
+
return candidate;
|
|
132
|
+
}
|
|
133
|
+
// The fold row will be created at the end of this directory.
|
|
134
|
+
return {
|
|
135
|
+
kind: 'fold',
|
|
136
|
+
parentPath: cursor.parentPath,
|
|
137
|
+
};
|
|
138
|
+
},
|
|
139
|
+
parentCursor(navigation, cursor) {
|
|
140
|
+
const parentPath = cursor.parentPath;
|
|
141
|
+
// The cursor is already in the root directory.
|
|
142
|
+
if (parentPath.length === 0) {
|
|
143
|
+
return undefined;
|
|
144
|
+
}
|
|
145
|
+
const entryName = parentPath.at(-1);
|
|
146
|
+
if (entryName === undefined) {
|
|
147
|
+
return undefined;
|
|
148
|
+
}
|
|
149
|
+
const containingPath = parentPath.slice(0, -1);
|
|
150
|
+
const entry = NavigationNode.getEntryAtPath(navigation, parentPath);
|
|
151
|
+
if (entry === undefined || entry.kind !== 'directory') {
|
|
152
|
+
return undefined;
|
|
153
|
+
}
|
|
154
|
+
return {
|
|
155
|
+
kind: 'entry',
|
|
156
|
+
parentPath: containingPath,
|
|
157
|
+
entryName,
|
|
158
|
+
};
|
|
159
|
+
},
|
|
160
|
+
visibleFilesPaths(navigation, parentPath = []) {
|
|
161
|
+
const paths = [];
|
|
162
|
+
for (const entry of navigation.entries) {
|
|
163
|
+
const entryPath = [...parentPath, entry.name];
|
|
164
|
+
switch (entry.kind) {
|
|
165
|
+
case 'file':
|
|
166
|
+
paths.push(entryPath);
|
|
167
|
+
break;
|
|
168
|
+
case 'symlink':
|
|
169
|
+
// Do not recurse through symlinks.
|
|
170
|
+
break;
|
|
171
|
+
case 'directory':
|
|
172
|
+
if (entry.node !== undefined) {
|
|
173
|
+
paths.push(
|
|
174
|
+
...NavigationNode.visibleFilesPaths(entry.node, entryPath),
|
|
175
|
+
);
|
|
176
|
+
}
|
|
177
|
+
break;
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
return paths;
|
|
181
|
+
},
|
|
170
182
|
};
|
|
171
183
|
function cursorsInNode(node, parentPath) {
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
}
|
|
182
|
-
cursors.push(...cursorsInNode(entry.node, [...parentPath, entry.name]));
|
|
183
|
-
}
|
|
184
|
-
if (node.foldedEntries.length > 0) {
|
|
185
|
-
cursors.push({
|
|
186
|
-
kind: 'fold',
|
|
187
|
-
parentPath,
|
|
188
|
-
});
|
|
184
|
+
const cursors = [];
|
|
185
|
+
for (const entry of node.entries) {
|
|
186
|
+
cursors.push({
|
|
187
|
+
kind: 'entry',
|
|
188
|
+
parentPath,
|
|
189
|
+
entryName: entry.name,
|
|
190
|
+
});
|
|
191
|
+
if (entry.kind !== 'directory' || entry.node === undefined) {
|
|
192
|
+
continue;
|
|
189
193
|
}
|
|
190
|
-
|
|
194
|
+
cursors.push(...cursorsInNode(entry.node, [...parentPath, entry.name]));
|
|
195
|
+
}
|
|
196
|
+
if (node.foldedEntries.length > 0) {
|
|
197
|
+
cursors.push({
|
|
198
|
+
kind: 'fold',
|
|
199
|
+
parentPath,
|
|
200
|
+
});
|
|
201
|
+
}
|
|
202
|
+
return cursors;
|
|
191
203
|
}
|
|
192
204
|
function cursorBelongsToSubtree(cursor, entryPath) {
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
205
|
+
if (cursor.kind === 'fold') {
|
|
206
|
+
return UnixEntryPath.isStrictPathPrefix(entryPath, cursor.parentPath);
|
|
207
|
+
}
|
|
208
|
+
const cursorPath = [...cursor.parentPath, cursor.entryName];
|
|
209
|
+
return UnixEntryPath.isStrictPathPrefix(entryPath, cursorPath);
|
|
198
210
|
}
|
package/dist/domain/state.d.ts
CHANGED
|
@@ -2,11 +2,11 @@ import { UnixEntry } from './unix-entry.js';
|
|
|
2
2
|
import type { FoldNode } from './fold-node.js';
|
|
3
3
|
import { Cursor } from './cursor.js';
|
|
4
4
|
export type State = {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
5
|
+
buffer: UnixEntry[];
|
|
6
|
+
folds: FoldNode;
|
|
7
|
+
cursor: Cursor;
|
|
8
8
|
};
|
|
9
9
|
export declare const View: {
|
|
10
|
-
|
|
10
|
+
getEntryAtCursor(view: State): UnixEntry | undefined;
|
|
11
11
|
};
|
|
12
|
-
//# sourceMappingURL=state.d.ts.map
|
|
12
|
+
//# sourceMappingURL=state.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"state.d.ts","sourceRoot":"","sources":["../../src/domain/state.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAC5C,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAC/C,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAErC,MAAM,MAAM,KAAK,GAAG;IAClB,MAAM,EAAE,SAAS,EAAE,CAAC;IACpB,KAAK,EAAE,QAAQ,CAAC;IAChB,MAAM,EAAE,MAAM,CAAC;CAChB,CAAC;AAEF,eAAO,MAAM,IAAI;2BACQ,KAAK,GAAG,SAAS,GAAG,SAAS;CAUrD,
|
|
1
|
+
{"version":3,"file":"state.d.ts","sourceRoot":"","sources":["../../src/domain/state.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAC5C,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAC/C,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAErC,MAAM,MAAM,KAAK,GAAG;IAClB,MAAM,EAAE,SAAS,EAAE,CAAC;IACpB,KAAK,EAAE,QAAQ,CAAC;IAChB,MAAM,EAAE,MAAM,CAAC;CAChB,CAAC;AAEF,eAAO,MAAM,IAAI;2BACQ,KAAK,GAAG,SAAS,GAAG,SAAS;CAUrD,CAAC"}
|
package/dist/domain/state.js
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { UnixEntry } from './unix-entry.js';
|
|
2
2
|
import { Cursor } from './cursor.js';
|
|
3
3
|
export const View = {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
}
|
|
10
|
-
return UnixEntry.getEntryAtPath(view.buffer, path);
|
|
4
|
+
getEntryAtCursor(view) {
|
|
5
|
+
const path = Cursor.getPath(view.cursor);
|
|
6
|
+
// Nothing on folds
|
|
7
|
+
if (path === undefined) {
|
|
8
|
+
return undefined;
|
|
11
9
|
}
|
|
10
|
+
return UnixEntry.getEntryAtPath(view.buffer, path);
|
|
11
|
+
},
|
|
12
12
|
};
|
|
@@ -2,27 +2,43 @@ import { z } from 'zod';
|
|
|
2
2
|
import { UnixPath } from './unix-path.js';
|
|
3
3
|
export declare const UnixEntryNameSchema: z.ZodString;
|
|
4
4
|
export type UnixEntryName = z.output<typeof UnixEntryNameSchema>;
|
|
5
|
-
export declare function entryNamesEqual(
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
5
|
+
export declare function entryNamesEqual(
|
|
6
|
+
left: UnixEntryName[],
|
|
7
|
+
right: UnixEntryName[],
|
|
8
|
+
): boolean;
|
|
9
|
+
export type UnixEntry =
|
|
10
|
+
| {
|
|
11
|
+
kind: 'file';
|
|
12
|
+
name: UnixEntryName;
|
|
13
|
+
}
|
|
14
|
+
| {
|
|
15
|
+
kind: 'symlink';
|
|
16
|
+
name: UnixEntryName;
|
|
17
|
+
target: UnixPath;
|
|
18
|
+
}
|
|
19
|
+
| {
|
|
20
|
+
kind: 'directory';
|
|
21
|
+
name: UnixEntryName;
|
|
22
|
+
entries?: UnixEntry[];
|
|
23
|
+
};
|
|
18
24
|
export declare const UnixEntry: {
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
25
|
+
getEntryAtPath(
|
|
26
|
+
entries: UnixEntry[],
|
|
27
|
+
path: UnixEntryPath,
|
|
28
|
+
): UnixEntry | undefined;
|
|
29
|
+
getEntriesAtPath(
|
|
30
|
+
entries: UnixEntry[],
|
|
31
|
+
path: UnixEntryPath,
|
|
32
|
+
): UnixEntry[] | undefined;
|
|
33
|
+
setEntriesAtPath(
|
|
34
|
+
entries: UnixEntry[],
|
|
35
|
+
path: UnixEntryPath,
|
|
36
|
+
newEntries: UnixEntry[] | undefined,
|
|
37
|
+
): UnixEntry[];
|
|
22
38
|
};
|
|
23
39
|
export type UnixEntryPath = UnixEntryName[];
|
|
24
40
|
export declare const UnixEntryPath: {
|
|
25
|
-
|
|
26
|
-
|
|
41
|
+
equal(left: UnixEntryPath, right: UnixEntryPath): boolean;
|
|
42
|
+
isStrictPathPrefix(prefix: UnixEntryPath, path: UnixEntryPath): boolean;
|
|
27
43
|
};
|
|
28
|
-
//# sourceMappingURL=unix-entry.d.ts.map
|
|
44
|
+
//# sourceMappingURL=unix-entry.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"unix-entry.d.ts","sourceRoot":"","sources":["../../src/domain/unix-entry.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;
|
|
1
|
+
{"version":3,"file":"unix-entry.d.ts","sourceRoot":"","sources":["../../src/domain/unix-entry.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAG1C,eAAO,MAAM,mBAAmB,aAQ5B,CAAC;AAEL,MAAM,MAAM,aAAa,GAAG,CAAC,CAAC,MAAM,CAAC,OAAO,mBAAmB,CAAC,CAAC;AAEjE,wBAAgB,eAAe,CAC7B,IAAI,EAAE,aAAa,EAAE,EACrB,KAAK,EAAE,aAAa,EAAE,GACrB,OAAO,CAKT;AAED,MAAM,MAAM,SAAS,GACjB;IACE,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,aAAa,CAAC;CACrB,GACD;IACE,IAAI,EAAE,SAAS,CAAC;IAChB,IAAI,EAAE,aAAa,CAAC;IACpB,MAAM,EAAE,QAAQ,CAAC;CAClB,GACD;IACE,IAAI,EAAE,WAAW,CAAC;IAClB,IAAI,EAAE,aAAa,CAAC;IAEpB,OAAO,CAAC,EAAE,SAAS,EAAE,CAAC;CACvB,CAAC;AAEN,eAAO,MAAM,SAAS;4BAGT,SAAS,EAAE,QACd,aAAa,GAClB,SAAS,GAAG,SAAS;8BA6Bb,SAAS,EAAE,QACd,aAAa,GAClB,SAAS,EAAE,GAAG,SAAS;8BAgBf,SAAS,EAAE,QACd,aAAa,cACP,SAAS,EAAE,GAAG,SAAS,GAClC,SAAS,EAAE;CAyDf,CAAC;AAEF,MAAM,MAAM,aAAa,GAAG,aAAa,EAAE,CAAC;AAE5C,eAAO,MAAM,aAAa;gBACZ,aAAa,SAAS,aAAa,GAAG,OAAO;+BAI9B,aAAa,QAAQ,aAAa,GAAG,OAAO;CAOxE,CAAC"}
|