@bakapiano/ccsm 0.22.3 → 0.22.5
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/CLAUDE.md +538 -538
- package/README.md +189 -189
- package/bin/ccsm.js +235 -235
- package/lib/cliActivity.js +139 -139
- package/lib/codexSeed.js +183 -183
- package/lib/config.js +274 -274
- package/lib/devices.js +229 -229
- package/lib/folders.js +124 -124
- package/lib/localCliSessions.js +519 -519
- package/lib/persistedSessions.js +129 -129
- package/lib/tunnel.js +621 -621
- package/lib/webTerminal.js +225 -225
- package/lib/workspace.js +233 -233
- package/package.json +57 -57
- package/public/css/base.css +99 -99
- package/public/css/cards.css +183 -183
- package/public/css/feedback.css +504 -504
- package/public/css/forms.css +453 -453
- package/public/css/layout.css +176 -176
- package/public/css/modal.css +190 -190
- package/public/css/responsive.css +176 -176
- package/public/css/sidebar.css +707 -707
- package/public/css/terminals.css +645 -543
- package/public/css/tokens.css +81 -81
- package/public/css/wco.css +196 -196
- package/public/css/widgets.css +2725 -2725
- package/public/index.html +152 -152
- package/public/js/api.js +371 -371
- package/public/js/backend.js +149 -149
- package/public/js/components/App.js +73 -73
- package/public/js/components/DirectoryPicker.js +203 -203
- package/public/js/components/EntityFormModal.js +153 -153
- package/public/js/components/Modal.js +57 -57
- package/public/js/components/OfflineBanner.js +67 -67
- package/public/js/components/PageTitleBar.js +13 -13
- package/public/js/components/PendingApprovalOverlay.js +128 -128
- package/public/js/components/Picker.js +179 -179
- package/public/js/components/Popover.js +55 -55
- package/public/js/components/RestartOverlay.js +36 -36
- package/public/js/components/Sidebar.js +380 -380
- package/public/js/components/TerminalInstance.js +159 -22
- package/public/js/components/TerminalResizeDebouncer.js +126 -0
- package/public/js/components/TerminalView.js +15 -2
- package/public/js/components/XtermTerminal.js +74 -15
- package/public/js/components/useDragSort.js +67 -67
- package/public/js/dialog.js +67 -67
- package/public/js/icons.js +212 -212
- package/public/js/main.js +296 -296
- package/public/js/pages/AboutPage.js +90 -90
- package/public/js/pages/ConfigurePage.js +713 -713
- package/public/js/pages/LaunchPage.js +421 -421
- package/public/js/pages/RemotePage.js +743 -743
- package/public/js/pages/SessionsPage.js +199 -80
- package/public/js/state.js +335 -335
- package/public/manifest.webmanifest +25 -0
- package/public/setup/index.html +567 -0
- package/scripts/dev.js +149 -149
- package/scripts/install.js +153 -153
- package/scripts/restart-helper.js +96 -96
- package/scripts/upgrade-helper.js +687 -687
- package/server.js +1807 -1807
|
@@ -1,203 +1,203 @@
|
|
|
1
|
-
// Directory browser used by Launch page. Windows-Explorer-style:
|
|
2
|
-
// ┌───────────────────────────────────────────────┐
|
|
3
|
-
// │ [←] [→] [↑] Home > Users > Admin > foo [✎] │ nav + breadcrumb
|
|
4
|
-
// ├──────────────┬────────────────────────────────┤
|
|
5
|
-
// │ Quick access │ folder rows (large, hoverable)│
|
|
6
|
-
// │ Home │ ⌃ .. │
|
|
7
|
-
// │ Work dir │ 📁 AppData │
|
|
8
|
-
// │ C:\ │ 📁 ccsm-workspaces │
|
|
9
|
-
// │ D:\ │ │
|
|
10
|
-
// └──────────────┴────────────────────────────────┘
|
|
11
|
-
//
|
|
12
|
-
// The picker streams the currently-selected path back to the parent via
|
|
13
|
-
// `onPick(path)` on every selection change. Confirm/cancel UI lives in
|
|
14
|
-
// the parent (the workdir modal's shared footer) so auto + cwd modes
|
|
15
|
-
// share one CTA.
|
|
16
|
-
//
|
|
17
|
-
// Props: { initialPath, onPick }
|
|
18
|
-
|
|
19
|
-
import { html } from '../html.js';
|
|
20
|
-
import { useEffect, useState } from 'preact/hooks';
|
|
21
|
-
import { api } from '../api.js';
|
|
22
|
-
import { setToast } from '../toast.js';
|
|
23
|
-
import { IconFolder, IconHome, IconChevronLeft, IconChevronRight, IconChevronUp, IconPencil } from '../icons.js';
|
|
24
|
-
|
|
25
|
-
export function DirectoryPicker({ initialPath, onPick }) {
|
|
26
|
-
const [data, setData] = useState(null);
|
|
27
|
-
const [path, setPath] = useState(initialPath || '');
|
|
28
|
-
const [history, setHistory] = useState({ stack: [], cursor: -1 }); // back/forward
|
|
29
|
-
const [editing, setEditing] = useState(false);
|
|
30
|
-
const [input, setInput] = useState('');
|
|
31
|
-
const [loading, setLoading] = useState(false);
|
|
32
|
-
|
|
33
|
-
// Push the current selection up on every change so the parent's
|
|
34
|
-
// shared "Use folder" CTA can act on it.
|
|
35
|
-
const select = (p) => { setPath(p); setInput(p); onPick?.(p); };
|
|
36
|
-
|
|
37
|
-
const browse = async (p, { pushHistory = true } = {}) => {
|
|
38
|
-
setLoading(true);
|
|
39
|
-
try {
|
|
40
|
-
const url = '/api/browse' + (p ? `?path=${encodeURIComponent(p)}` : '');
|
|
41
|
-
const r = await api('GET', url);
|
|
42
|
-
setData(r);
|
|
43
|
-
select(r.path);
|
|
44
|
-
if (pushHistory) {
|
|
45
|
-
setHistory((h) => {
|
|
46
|
-
const head = h.stack.slice(0, h.cursor + 1);
|
|
47
|
-
head.push(r.path);
|
|
48
|
-
return { stack: head, cursor: head.length - 1 };
|
|
49
|
-
});
|
|
50
|
-
}
|
|
51
|
-
} catch (e) { setToast(e.message, 'error'); }
|
|
52
|
-
finally { setLoading(false); }
|
|
53
|
-
};
|
|
54
|
-
|
|
55
|
-
useEffect(() => { browse(initialPath); }, []);
|
|
56
|
-
|
|
57
|
-
const canBack = history.cursor > 0;
|
|
58
|
-
const canForward = history.cursor >= 0 && history.cursor < history.stack.length - 1;
|
|
59
|
-
|
|
60
|
-
const goBack = () => {
|
|
61
|
-
if (!canBack) return;
|
|
62
|
-
const idx = history.cursor - 1;
|
|
63
|
-
setHistory({ ...history, cursor: idx });
|
|
64
|
-
browse(history.stack[idx], { pushHistory: false });
|
|
65
|
-
};
|
|
66
|
-
const goForward = () => {
|
|
67
|
-
if (!canForward) return;
|
|
68
|
-
const idx = history.cursor + 1;
|
|
69
|
-
setHistory({ ...history, cursor: idx });
|
|
70
|
-
browse(history.stack[idx], { pushHistory: false });
|
|
71
|
-
};
|
|
72
|
-
const goUp = () => {
|
|
73
|
-
if (!data?.parent) return;
|
|
74
|
-
browse(data.parent);
|
|
75
|
-
};
|
|
76
|
-
const onAddressSubmit = (ev) => {
|
|
77
|
-
ev?.preventDefault?.();
|
|
78
|
-
const p = (input || '').trim();
|
|
79
|
-
setEditing(false);
|
|
80
|
-
if (p && p !== path) browse(p);
|
|
81
|
-
};
|
|
82
|
-
|
|
83
|
-
if (!data) {
|
|
84
|
-
return html`<div class="filex"><div class="filex-loading">Loading…</div></div>`;
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
// Build breadcrumb segments. Windows-style: "C:\Users\Admin\foo" →
|
|
88
|
-
// [C:, Users, Admin, foo] with each segment clickable.
|
|
89
|
-
const segments = breadcrumbSegments(data.path);
|
|
90
|
-
|
|
91
|
-
return html`
|
|
92
|
-
<div class="filex">
|
|
93
|
-
<div class="filex-toolbar">
|
|
94
|
-
<div class="filex-navbtns">
|
|
95
|
-
<button class="filex-navbtn" title="Back" disabled=${!canBack} onClick=${goBack}>
|
|
96
|
-
<${IconChevronLeft} />
|
|
97
|
-
</button>
|
|
98
|
-
<button class="filex-navbtn" title="Forward" disabled=${!canForward} onClick=${goForward}>
|
|
99
|
-
<${IconChevronRight} />
|
|
100
|
-
</button>
|
|
101
|
-
<button class="filex-navbtn" title="Up" disabled=${!data.parent} onClick=${goUp}>
|
|
102
|
-
<${IconChevronUp} />
|
|
103
|
-
</button>
|
|
104
|
-
</div>
|
|
105
|
-
|
|
106
|
-
${editing ? html`
|
|
107
|
-
<form class="filex-address-edit" onSubmit=${onAddressSubmit}>
|
|
108
|
-
<input class="filex-address-input mono" value=${input}
|
|
109
|
-
autoFocus
|
|
110
|
-
onInput=${(e) => setInput(e.target.value)}
|
|
111
|
-
onBlur=${onAddressSubmit}
|
|
112
|
-
onKeyDown=${(e) => { if (e.key === 'Escape') { setInput(data.path); setEditing(false); } }}
|
|
113
|
-
spellcheck="false" />
|
|
114
|
-
</form>
|
|
115
|
-
` : html`
|
|
116
|
-
<div class="filex-breadcrumb"
|
|
117
|
-
onClick=${(e) => { if (e.target === e.currentTarget) { setInput(data.path); setEditing(true); } }}>
|
|
118
|
-
${segments.map((seg, i) => html`
|
|
119
|
-
<button key=${seg.path} class="filex-crumb"
|
|
120
|
-
title=${seg.path}
|
|
121
|
-
onClick=${() => browse(seg.path)}>
|
|
122
|
-
${i === 0 && seg.label.match(/^[a-z]:\\?$/i) ? null : null}
|
|
123
|
-
${seg.label}
|
|
124
|
-
</button>
|
|
125
|
-
${i < segments.length - 1
|
|
126
|
-
? html`<span class="filex-crumb-sep" aria-hidden="true">›</span>`
|
|
127
|
-
: null}
|
|
128
|
-
`)}
|
|
129
|
-
<button class="filex-address-edit-btn" title="Edit path"
|
|
130
|
-
onClick=${() => { setInput(data.path); setEditing(true); }}>
|
|
131
|
-
<${IconPencil} />
|
|
132
|
-
</button>
|
|
133
|
-
</div>
|
|
134
|
-
`}
|
|
135
|
-
</div>
|
|
136
|
-
|
|
137
|
-
<div class="filex-body">
|
|
138
|
-
<aside class="filex-side">
|
|
139
|
-
<div class="filex-side-label">Quick access</div>
|
|
140
|
-
${(data.starts || []).map((s) => html`
|
|
141
|
-
<button key=${s.path} class=${`filex-side-item${path === s.path ? ' is-active' : ''}`}
|
|
142
|
-
onClick=${() => browse(s.path)}
|
|
143
|
-
title=${s.path}>
|
|
144
|
-
<span class="filex-side-icon">
|
|
145
|
-
${s.label === 'Home' ? html`<${IconHome} />` : html`<${IconFolder} />`}
|
|
146
|
-
</span>
|
|
147
|
-
<span class="filex-side-name">${s.label}</span>
|
|
148
|
-
</button>`)}
|
|
149
|
-
</aside>
|
|
150
|
-
|
|
151
|
-
<div class="filex-main">
|
|
152
|
-
${!data.exists ? html`
|
|
153
|
-
<div class="filex-empty">Directory not found.</div>
|
|
154
|
-
` : html`
|
|
155
|
-
<div class="filex-list">
|
|
156
|
-
${data.entries.length === 0 ? html`
|
|
157
|
-
<div class="filex-empty">This folder is empty.</div>
|
|
158
|
-
` : data.entries.map((e) => html`
|
|
159
|
-
<button key=${e.path} class="filex-row"
|
|
160
|
-
onDblClick=${() => browse(e.path)}
|
|
161
|
-
onClick=${() => select(e.path)}
|
|
162
|
-
data-active=${path === e.path}>
|
|
163
|
-
<span class="filex-row-icon"><${IconFolder} /></span>
|
|
164
|
-
<span class="filex-row-name">${e.name}</span>
|
|
165
|
-
</button>`)}
|
|
166
|
-
</div>`}
|
|
167
|
-
</div>
|
|
168
|
-
</div>
|
|
169
|
-
|
|
170
|
-
<div class="filex-foot">
|
|
171
|
-
<span class="filex-foot-current mono" title=${path}>${path || ' '}</span>
|
|
172
|
-
</div>
|
|
173
|
-
</div>`;
|
|
174
|
-
}
|
|
175
|
-
|
|
176
|
-
// "C:\Users\Admin\foo" → [{label:'C:', path:'C:\\'}, {label:'Users', path:'C:\\Users'}, …]
|
|
177
|
-
// "/home/me/foo" → [{label:'/', path:'/'}, {label:'home', path:'/home'}, …]
|
|
178
|
-
function breadcrumbSegments(p) {
|
|
179
|
-
if (!p) return [];
|
|
180
|
-
// Windows: split on backslash. Posix: forward slash.
|
|
181
|
-
const isWin = /^[a-zA-Z]:[\\/]/.test(p);
|
|
182
|
-
const sep = isWin ? '\\' : '/';
|
|
183
|
-
const norm = p.replace(/[\\\/]+/g, sep);
|
|
184
|
-
const parts = norm.split(sep).filter(Boolean);
|
|
185
|
-
const segs = [];
|
|
186
|
-
if (isWin) {
|
|
187
|
-
// first part is drive like "C:"
|
|
188
|
-
let acc = parts[0] + sep;
|
|
189
|
-
segs.push({ label: parts[0], path: acc });
|
|
190
|
-
for (let i = 1; i < parts.length; i++) {
|
|
191
|
-
acc = (acc.endsWith(sep) ? acc.slice(0, -1) : acc) + sep + parts[i];
|
|
192
|
-
segs.push({ label: parts[i], path: acc });
|
|
193
|
-
}
|
|
194
|
-
} else {
|
|
195
|
-
let acc = '';
|
|
196
|
-
segs.push({ label: '/', path: '/' });
|
|
197
|
-
for (const part of parts) {
|
|
198
|
-
acc = acc + sep + part;
|
|
199
|
-
segs.push({ label: part, path: acc });
|
|
200
|
-
}
|
|
201
|
-
}
|
|
202
|
-
return segs;
|
|
203
|
-
}
|
|
1
|
+
// Directory browser used by Launch page. Windows-Explorer-style:
|
|
2
|
+
// ┌───────────────────────────────────────────────┐
|
|
3
|
+
// │ [←] [→] [↑] Home > Users > Admin > foo [✎] │ nav + breadcrumb
|
|
4
|
+
// ├──────────────┬────────────────────────────────┤
|
|
5
|
+
// │ Quick access │ folder rows (large, hoverable)│
|
|
6
|
+
// │ Home │ ⌃ .. │
|
|
7
|
+
// │ Work dir │ 📁 AppData │
|
|
8
|
+
// │ C:\ │ 📁 ccsm-workspaces │
|
|
9
|
+
// │ D:\ │ │
|
|
10
|
+
// └──────────────┴────────────────────────────────┘
|
|
11
|
+
//
|
|
12
|
+
// The picker streams the currently-selected path back to the parent via
|
|
13
|
+
// `onPick(path)` on every selection change. Confirm/cancel UI lives in
|
|
14
|
+
// the parent (the workdir modal's shared footer) so auto + cwd modes
|
|
15
|
+
// share one CTA.
|
|
16
|
+
//
|
|
17
|
+
// Props: { initialPath, onPick }
|
|
18
|
+
|
|
19
|
+
import { html } from '../html.js';
|
|
20
|
+
import { useEffect, useState } from 'preact/hooks';
|
|
21
|
+
import { api } from '../api.js';
|
|
22
|
+
import { setToast } from '../toast.js';
|
|
23
|
+
import { IconFolder, IconHome, IconChevronLeft, IconChevronRight, IconChevronUp, IconPencil } from '../icons.js';
|
|
24
|
+
|
|
25
|
+
export function DirectoryPicker({ initialPath, onPick }) {
|
|
26
|
+
const [data, setData] = useState(null);
|
|
27
|
+
const [path, setPath] = useState(initialPath || '');
|
|
28
|
+
const [history, setHistory] = useState({ stack: [], cursor: -1 }); // back/forward
|
|
29
|
+
const [editing, setEditing] = useState(false);
|
|
30
|
+
const [input, setInput] = useState('');
|
|
31
|
+
const [loading, setLoading] = useState(false);
|
|
32
|
+
|
|
33
|
+
// Push the current selection up on every change so the parent's
|
|
34
|
+
// shared "Use folder" CTA can act on it.
|
|
35
|
+
const select = (p) => { setPath(p); setInput(p); onPick?.(p); };
|
|
36
|
+
|
|
37
|
+
const browse = async (p, { pushHistory = true } = {}) => {
|
|
38
|
+
setLoading(true);
|
|
39
|
+
try {
|
|
40
|
+
const url = '/api/browse' + (p ? `?path=${encodeURIComponent(p)}` : '');
|
|
41
|
+
const r = await api('GET', url);
|
|
42
|
+
setData(r);
|
|
43
|
+
select(r.path);
|
|
44
|
+
if (pushHistory) {
|
|
45
|
+
setHistory((h) => {
|
|
46
|
+
const head = h.stack.slice(0, h.cursor + 1);
|
|
47
|
+
head.push(r.path);
|
|
48
|
+
return { stack: head, cursor: head.length - 1 };
|
|
49
|
+
});
|
|
50
|
+
}
|
|
51
|
+
} catch (e) { setToast(e.message, 'error'); }
|
|
52
|
+
finally { setLoading(false); }
|
|
53
|
+
};
|
|
54
|
+
|
|
55
|
+
useEffect(() => { browse(initialPath); }, []);
|
|
56
|
+
|
|
57
|
+
const canBack = history.cursor > 0;
|
|
58
|
+
const canForward = history.cursor >= 0 && history.cursor < history.stack.length - 1;
|
|
59
|
+
|
|
60
|
+
const goBack = () => {
|
|
61
|
+
if (!canBack) return;
|
|
62
|
+
const idx = history.cursor - 1;
|
|
63
|
+
setHistory({ ...history, cursor: idx });
|
|
64
|
+
browse(history.stack[idx], { pushHistory: false });
|
|
65
|
+
};
|
|
66
|
+
const goForward = () => {
|
|
67
|
+
if (!canForward) return;
|
|
68
|
+
const idx = history.cursor + 1;
|
|
69
|
+
setHistory({ ...history, cursor: idx });
|
|
70
|
+
browse(history.stack[idx], { pushHistory: false });
|
|
71
|
+
};
|
|
72
|
+
const goUp = () => {
|
|
73
|
+
if (!data?.parent) return;
|
|
74
|
+
browse(data.parent);
|
|
75
|
+
};
|
|
76
|
+
const onAddressSubmit = (ev) => {
|
|
77
|
+
ev?.preventDefault?.();
|
|
78
|
+
const p = (input || '').trim();
|
|
79
|
+
setEditing(false);
|
|
80
|
+
if (p && p !== path) browse(p);
|
|
81
|
+
};
|
|
82
|
+
|
|
83
|
+
if (!data) {
|
|
84
|
+
return html`<div class="filex"><div class="filex-loading">Loading…</div></div>`;
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
// Build breadcrumb segments. Windows-style: "C:\Users\Admin\foo" →
|
|
88
|
+
// [C:, Users, Admin, foo] with each segment clickable.
|
|
89
|
+
const segments = breadcrumbSegments(data.path);
|
|
90
|
+
|
|
91
|
+
return html`
|
|
92
|
+
<div class="filex">
|
|
93
|
+
<div class="filex-toolbar">
|
|
94
|
+
<div class="filex-navbtns">
|
|
95
|
+
<button class="filex-navbtn" title="Back" disabled=${!canBack} onClick=${goBack}>
|
|
96
|
+
<${IconChevronLeft} />
|
|
97
|
+
</button>
|
|
98
|
+
<button class="filex-navbtn" title="Forward" disabled=${!canForward} onClick=${goForward}>
|
|
99
|
+
<${IconChevronRight} />
|
|
100
|
+
</button>
|
|
101
|
+
<button class="filex-navbtn" title="Up" disabled=${!data.parent} onClick=${goUp}>
|
|
102
|
+
<${IconChevronUp} />
|
|
103
|
+
</button>
|
|
104
|
+
</div>
|
|
105
|
+
|
|
106
|
+
${editing ? html`
|
|
107
|
+
<form class="filex-address-edit" onSubmit=${onAddressSubmit}>
|
|
108
|
+
<input class="filex-address-input mono" value=${input}
|
|
109
|
+
autoFocus
|
|
110
|
+
onInput=${(e) => setInput(e.target.value)}
|
|
111
|
+
onBlur=${onAddressSubmit}
|
|
112
|
+
onKeyDown=${(e) => { if (e.key === 'Escape') { setInput(data.path); setEditing(false); } }}
|
|
113
|
+
spellcheck="false" />
|
|
114
|
+
</form>
|
|
115
|
+
` : html`
|
|
116
|
+
<div class="filex-breadcrumb"
|
|
117
|
+
onClick=${(e) => { if (e.target === e.currentTarget) { setInput(data.path); setEditing(true); } }}>
|
|
118
|
+
${segments.map((seg, i) => html`
|
|
119
|
+
<button key=${seg.path} class="filex-crumb"
|
|
120
|
+
title=${seg.path}
|
|
121
|
+
onClick=${() => browse(seg.path)}>
|
|
122
|
+
${i === 0 && seg.label.match(/^[a-z]:\\?$/i) ? null : null}
|
|
123
|
+
${seg.label}
|
|
124
|
+
</button>
|
|
125
|
+
${i < segments.length - 1
|
|
126
|
+
? html`<span class="filex-crumb-sep" aria-hidden="true">›</span>`
|
|
127
|
+
: null}
|
|
128
|
+
`)}
|
|
129
|
+
<button class="filex-address-edit-btn" title="Edit path"
|
|
130
|
+
onClick=${() => { setInput(data.path); setEditing(true); }}>
|
|
131
|
+
<${IconPencil} />
|
|
132
|
+
</button>
|
|
133
|
+
</div>
|
|
134
|
+
`}
|
|
135
|
+
</div>
|
|
136
|
+
|
|
137
|
+
<div class="filex-body">
|
|
138
|
+
<aside class="filex-side">
|
|
139
|
+
<div class="filex-side-label">Quick access</div>
|
|
140
|
+
${(data.starts || []).map((s) => html`
|
|
141
|
+
<button key=${s.path} class=${`filex-side-item${path === s.path ? ' is-active' : ''}`}
|
|
142
|
+
onClick=${() => browse(s.path)}
|
|
143
|
+
title=${s.path}>
|
|
144
|
+
<span class="filex-side-icon">
|
|
145
|
+
${s.label === 'Home' ? html`<${IconHome} />` : html`<${IconFolder} />`}
|
|
146
|
+
</span>
|
|
147
|
+
<span class="filex-side-name">${s.label}</span>
|
|
148
|
+
</button>`)}
|
|
149
|
+
</aside>
|
|
150
|
+
|
|
151
|
+
<div class="filex-main">
|
|
152
|
+
${!data.exists ? html`
|
|
153
|
+
<div class="filex-empty">Directory not found.</div>
|
|
154
|
+
` : html`
|
|
155
|
+
<div class="filex-list">
|
|
156
|
+
${data.entries.length === 0 ? html`
|
|
157
|
+
<div class="filex-empty">This folder is empty.</div>
|
|
158
|
+
` : data.entries.map((e) => html`
|
|
159
|
+
<button key=${e.path} class="filex-row"
|
|
160
|
+
onDblClick=${() => browse(e.path)}
|
|
161
|
+
onClick=${() => select(e.path)}
|
|
162
|
+
data-active=${path === e.path}>
|
|
163
|
+
<span class="filex-row-icon"><${IconFolder} /></span>
|
|
164
|
+
<span class="filex-row-name">${e.name}</span>
|
|
165
|
+
</button>`)}
|
|
166
|
+
</div>`}
|
|
167
|
+
</div>
|
|
168
|
+
</div>
|
|
169
|
+
|
|
170
|
+
<div class="filex-foot">
|
|
171
|
+
<span class="filex-foot-current mono" title=${path}>${path || ' '}</span>
|
|
172
|
+
</div>
|
|
173
|
+
</div>`;
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
// "C:\Users\Admin\foo" → [{label:'C:', path:'C:\\'}, {label:'Users', path:'C:\\Users'}, …]
|
|
177
|
+
// "/home/me/foo" → [{label:'/', path:'/'}, {label:'home', path:'/home'}, …]
|
|
178
|
+
function breadcrumbSegments(p) {
|
|
179
|
+
if (!p) return [];
|
|
180
|
+
// Windows: split on backslash. Posix: forward slash.
|
|
181
|
+
const isWin = /^[a-zA-Z]:[\\/]/.test(p);
|
|
182
|
+
const sep = isWin ? '\\' : '/';
|
|
183
|
+
const norm = p.replace(/[\\\/]+/g, sep);
|
|
184
|
+
const parts = norm.split(sep).filter(Boolean);
|
|
185
|
+
const segs = [];
|
|
186
|
+
if (isWin) {
|
|
187
|
+
// first part is drive like "C:"
|
|
188
|
+
let acc = parts[0] + sep;
|
|
189
|
+
segs.push({ label: parts[0], path: acc });
|
|
190
|
+
for (let i = 1; i < parts.length; i++) {
|
|
191
|
+
acc = (acc.endsWith(sep) ? acc.slice(0, -1) : acc) + sep + parts[i];
|
|
192
|
+
segs.push({ label: parts[i], path: acc });
|
|
193
|
+
}
|
|
194
|
+
} else {
|
|
195
|
+
let acc = '';
|
|
196
|
+
segs.push({ label: '/', path: '/' });
|
|
197
|
+
for (const part of parts) {
|
|
198
|
+
acc = acc + sep + part;
|
|
199
|
+
segs.push({ label: part, path: acc });
|
|
200
|
+
}
|
|
201
|
+
}
|
|
202
|
+
return segs;
|
|
203
|
+
}
|