@mak-98/dirvi-app 0.11.0-beta.5 → 0.11.0-beta.7
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/create-app-api.d.ts +1 -1
- package/dist/application/create-app-api.d.ts.map +1 -1
- package/dist/application/create-app-api.js +41 -14
- package/dist/application/init-runtime.d.ts +26 -6
- package/dist/application/init-runtime.d.ts.map +1 -1
- package/dist/application/init-runtime.error.d.ts +53 -0
- package/dist/application/init-runtime.error.d.ts.map +1 -0
- package/dist/application/init-runtime.error.js +77 -0
- package/dist/application/init-runtime.js +123 -89
- package/dist/domain/app-input.d.ts +2 -0
- package/dist/domain/app-input.d.ts.map +1 -0
- package/dist/domain/app-input.js +1 -0
- package/dist/domain/ex-command.d.ts +5 -2
- package/dist/domain/ex-command.d.ts.map +1 -1
- package/dist/domain/initialization.d.ts +14 -11
- package/dist/domain/initialization.d.ts.map +1 -1
- package/dist/domain/node-presentation.d.ts +12 -0
- package/dist/domain/node-presentation.d.ts.map +1 -0
- package/dist/domain/node-presentation.js +1 -0
- package/dist/domain/public-init-api.d.ts +12 -7
- package/dist/domain/public-init-api.d.ts.map +1 -1
- package/dist/domain/shell-api.d.ts +1 -1
- package/dist/domain/shell-api.d.ts.map +1 -1
- package/dist/domain/theme.d.ts +2 -14
- package/dist/domain/theme.d.ts.map +1 -1
- package/dist/domain/theme.js +9 -15
- package/dist/index.d.ts +0 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/ui/App.d.ts +3 -5
- package/dist/ui/App.d.ts.map +1 -1
- package/dist/ui/App.js +36 -19
- package/dist/ui/AppSetup.d.ts +1 -1
- package/dist/ui/AppSetup.d.ts.map +1 -1
- package/dist/ui/AppSetup.js +30 -24
- package/dist/ui/Shell.js +6 -6
- package/dist/ui/color-resolver.d.ts +1 -1
- package/dist/ui/color-resolver.d.ts.map +1 -1
- package/dist/ui/hooks/useView.d.ts +2 -2
- package/dist/ui/hooks/useView.d.ts.map +1 -1
- package/dist/ui/hooks/useView.js +3 -3
- package/dist/ui/view.d.ts +7 -3
- package/dist/ui/view.d.ts.map +1 -1
- package/dist/ui/view.js +76 -19
- package/package.json +3 -3
package/dist/ui/view.js
CHANGED
|
@@ -1,17 +1,28 @@
|
|
|
1
|
+
function foldId(parentPath, firstId) {
|
|
2
|
+
return `fold:${JSON.stringify([...parentPath, firstId])}`;
|
|
3
|
+
}
|
|
1
4
|
export const View = {
|
|
2
|
-
createRows(rootNode, navNodeApi, cursor,
|
|
3
|
-
const rootCursor = [];
|
|
4
|
-
const
|
|
5
|
+
createRows(rootNode, navNodeApi, cursor, cursorMethods, presentNode) {
|
|
6
|
+
const rootCursor = { path: [] };
|
|
7
|
+
const inlineFoldIds = new Set();
|
|
8
|
+
if (rootNode.children !== null) {
|
|
9
|
+
for (const position of navNodeApi.cursors(rootNode.children)) {
|
|
10
|
+
if (cursorMethods.isFoldCursor(position)) {
|
|
11
|
+
inlineFoldIds.add(foldId(position.parentPath, position.firstId));
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
const rootRow = viewRowForEntry(rootNode, null, cursorMethods.equal(cursor, rootCursor), navNodeApi, presentNode, inlineFoldIds);
|
|
5
16
|
if (rootNode.children === null) {
|
|
6
17
|
return [rootRow];
|
|
7
18
|
}
|
|
8
19
|
return [
|
|
9
20
|
rootRow,
|
|
10
|
-
...viewRowsAtNode(rootNode.children, [], navNodeApi, cursor,
|
|
21
|
+
...viewRowsAtNode(rootNode.children, [], navNodeApi, cursor, cursorMethods, presentNode, inlineFoldIds),
|
|
11
22
|
];
|
|
12
23
|
},
|
|
13
|
-
create(rootNode, navNodeApi, cursor,
|
|
14
|
-
const rows = View.createRows(rootNode, navNodeApi, cursor,
|
|
24
|
+
create(rootNode, navNodeApi, cursor, cursorMethods, viewportHeight, viewportStart, presentNode) {
|
|
25
|
+
const rows = View.createRows(rootNode, navNodeApi, cursor, cursorMethods, presentNode);
|
|
15
26
|
return {
|
|
16
27
|
rows: rows.slice(viewportStart, viewportStart + viewportHeight),
|
|
17
28
|
};
|
|
@@ -20,52 +31,98 @@ export const View = {
|
|
|
20
31
|
/**
|
|
21
32
|
* Converts one NavNode and its descendants into display ViewRows.
|
|
22
33
|
*
|
|
23
|
-
* `node` is the directory currently being visited.
|
|
24
|
-
*
|
|
25
34
|
* `parentPath` is the path of that directory. For example:
|
|
26
35
|
*
|
|
27
36
|
* [] root directory
|
|
28
37
|
* ['src'] root/src
|
|
29
38
|
* ['src', 'lib'] root/src/lib
|
|
30
39
|
*/
|
|
31
|
-
function viewRowsAtNode(node, parentPath, navNodeApi, cursor,
|
|
40
|
+
function viewRowsAtNode(node, parentPath, navNodeApi, cursor, cursorMethods, presentNode, inlineFoldIds) {
|
|
32
41
|
const rows = [];
|
|
33
42
|
for (const entry of node.entries) {
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
43
|
+
if (navNodeApi.entryIsFold(entry)) {
|
|
44
|
+
const firstEntry = entry.folded[0];
|
|
45
|
+
// Match navigation's guard for empty or richer future fold contents.
|
|
46
|
+
if (firstEntry === undefined || navNodeApi.entryIsFold(firstEntry)) {
|
|
47
|
+
continue;
|
|
48
|
+
}
|
|
49
|
+
const id = foldId(parentPath, firstEntry.id);
|
|
50
|
+
// Unordered summaries belong to the parent, not separate rows.
|
|
51
|
+
if (!inlineFoldIds.has(id)) {
|
|
52
|
+
continue;
|
|
53
|
+
}
|
|
54
|
+
const entryCursor = {
|
|
55
|
+
parentPath: [...parentPath],
|
|
56
|
+
firstId: firstEntry.id,
|
|
57
|
+
};
|
|
58
|
+
// Reuse the first hidden entry's highlight until folds have a presenter.
|
|
59
|
+
const { highlight } = presentNode(firstEntry.id, navNodeApi.entryIsBranch(firstEntry));
|
|
60
|
+
rows.push({
|
|
61
|
+
id,
|
|
62
|
+
indent: parentPath.length + 1,
|
|
63
|
+
content: `… ${entry.folded.length} folded`,
|
|
64
|
+
cursor: cursorMethods.equal(cursor, entryCursor),
|
|
65
|
+
selected: false,
|
|
66
|
+
highlight,
|
|
67
|
+
type: 'fold',
|
|
68
|
+
foldedCount: entry.folded.length,
|
|
69
|
+
});
|
|
70
|
+
// Hidden descendants are never rendered separately.
|
|
71
|
+
continue;
|
|
72
|
+
}
|
|
73
|
+
const entryCursor = {
|
|
74
|
+
path: [...parentPath, entry.id],
|
|
75
|
+
};
|
|
76
|
+
const isCursor = cursorMethods.equal(cursor, entryCursor);
|
|
77
|
+
rows.push(viewRowForEntry(entry, parentPath, isCursor, navNodeApi, presentNode, inlineFoldIds));
|
|
37
78
|
// Case where there's no branches
|
|
38
79
|
if (!navNodeApi.entryIsBranch(entry) || entry.children === null) {
|
|
39
80
|
continue;
|
|
40
81
|
}
|
|
41
|
-
rows.push(...viewRowsAtNode(entry.children, [...parentPath, entry.id], navNodeApi, cursor,
|
|
82
|
+
rows.push(...viewRowsAtNode(entry.children, [...parentPath, entry.id], navNodeApi, cursor, cursorMethods, presentNode, inlineFoldIds));
|
|
42
83
|
}
|
|
43
84
|
return rows;
|
|
44
85
|
}
|
|
45
|
-
function viewRowForEntry(entry, parentPath, cursor, navNodeApi) {
|
|
86
|
+
function viewRowForEntry(entry, parentPath, cursor, navNodeApi, presentNode, inlineFoldIds) {
|
|
46
87
|
const id = entryId(parentPath ?? [], entry.id);
|
|
47
88
|
const indent = parentPath ? parentPath.length + 1 : 0;
|
|
48
89
|
const selected = false;
|
|
49
90
|
if (navNodeApi.entryIsBranch(entry)) {
|
|
50
|
-
const
|
|
51
|
-
|
|
52
|
-
|
|
91
|
+
const { content, highlight } = presentNode(entry.id, true);
|
|
92
|
+
const entryPath = parentPath === null ? [] : [...parentPath, entry.id];
|
|
93
|
+
const foldedCount = entry.children?.entries.reduce((count, entry) => {
|
|
94
|
+
if (!navNodeApi.entryIsFold(entry)) {
|
|
95
|
+
return count;
|
|
96
|
+
}
|
|
97
|
+
const firstEntry = entry.folded[0];
|
|
98
|
+
if (firstEntry === undefined || navNodeApi.entryIsFold(firstEntry)) {
|
|
99
|
+
return count;
|
|
100
|
+
}
|
|
101
|
+
// Ordered folds already have their own rows.
|
|
102
|
+
if (inlineFoldIds.has(foldId(entryPath, firstEntry.id))) {
|
|
103
|
+
return count;
|
|
104
|
+
}
|
|
105
|
+
return count + entry.folded.length;
|
|
106
|
+
}, 0) ?? 0;
|
|
53
107
|
return {
|
|
54
108
|
id,
|
|
55
109
|
indent,
|
|
56
110
|
selected,
|
|
57
111
|
cursor,
|
|
58
|
-
content:
|
|
112
|
+
content: content,
|
|
113
|
+
highlight,
|
|
59
114
|
type: 'branch',
|
|
60
115
|
foldedCount,
|
|
61
116
|
};
|
|
62
117
|
}
|
|
118
|
+
const { content, highlight } = presentNode(entry.id, false);
|
|
63
119
|
return {
|
|
64
120
|
id,
|
|
65
121
|
indent,
|
|
66
122
|
selected,
|
|
67
123
|
cursor,
|
|
68
|
-
content
|
|
124
|
+
content,
|
|
125
|
+
highlight,
|
|
69
126
|
type: 'leaf',
|
|
70
127
|
};
|
|
71
128
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mak-98/dirvi-app",
|
|
3
|
-
"version": "0.11.0-beta.
|
|
3
|
+
"version": "0.11.0-beta.7",
|
|
4
4
|
"description": "Shared React application logic for dirvi hosts.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "GPL-3.0-or-later",
|
|
@@ -16,8 +16,8 @@
|
|
|
16
16
|
"dist"
|
|
17
17
|
],
|
|
18
18
|
"dependencies": {
|
|
19
|
-
"dirvi-apis": "0.11.0-beta.
|
|
20
|
-
"dirvi-lib": "0.11.0-beta.
|
|
19
|
+
"dirvi-apis": "0.11.0-beta.7",
|
|
20
|
+
"dirvi-lib": "0.11.0-beta.7",
|
|
21
21
|
"zod": "^4.4.3"
|
|
22
22
|
},
|
|
23
23
|
"peerDependencies": {
|