@restregular/dsh-powerup 0.6.1 → 0.8.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/README.md +87 -6
- package/client.js +1337 -5
- package/index.js +22 -1
- package/lib/step-reference.js +484 -0
- package/lib/step-tool.js +71 -0
- package/locale/en.json +1 -1
- package/locale/zh.json +1 -1
- package/package.json +23 -4
package/client.js
CHANGED
|
@@ -69,9 +69,11 @@
|
|
|
69
69
|
|
|
70
70
|
const NS = 'dsh-powerup';
|
|
71
71
|
const SETTINGS_KEY = 'dsh-powerup:settings:v1';
|
|
72
|
-
const VERSION = '0.
|
|
72
|
+
const VERSION = '0.8.0';
|
|
73
73
|
const MENU_GAP = 8;
|
|
74
74
|
const MENU_WIDTH = 248;
|
|
75
|
+
/** Reference scheme understood by the Host's `powerup_step_read` tool. */
|
|
76
|
+
const STEP_REF_PREFIX = 'dsh-step:';
|
|
75
77
|
/** How long a one-click update's completion panel stays open when nothing restarts. */
|
|
76
78
|
const ONE_CLICK_AUTO_CLOSE_MS = 4000;
|
|
77
79
|
|
|
@@ -84,7 +86,7 @@
|
|
|
84
86
|
'page.title': 'Power-Up',
|
|
85
87
|
'page.subtitle': '给 DeepSeek Harness 加一点助推。',
|
|
86
88
|
'page.featureTitle': '轨迹右键菜单',
|
|
87
|
-
'page.featureDesc': '
|
|
89
|
+
'page.featureDesc': '在轨迹页面右键任意记录,快速复制、引用、查看详情、复制步骤引用,或从该记录 Fork 出一个新会话。',
|
|
88
90
|
'page.enabled': '已启用',
|
|
89
91
|
'page.disabled': '已停用',
|
|
90
92
|
'page.actions': '可用操作',
|
|
@@ -104,6 +106,15 @@
|
|
|
104
106
|
'page.jobStopTitle': '后台任务停止原因',
|
|
105
107
|
'page.jobStopDesc': '在会话顶部的后台任务面板里点停止按钮时,可以顺手填写停止原因;原因会附加在任务结束后注入会话的提示里。',
|
|
106
108
|
'page.jobStopHow': '打开任意会话,点顶部的「后台任务」面板,在运行中的任务右侧点停止,填写原因(可留空)后确认。',
|
|
109
|
+
'page.launcherTitle': '侧边栏启动器',
|
|
110
|
+
'page.launcherDesc': '把左侧边栏的面板按钮变成自适应图标网格:列数跟着侧边栏宽度走,图标在上、文字在下;拖动图标可以排序,把一个图标拖到另一个图标的中间就会合成一个分组(像 Windows 开始菜单的文件夹),点分组会以浮层弹出里面的图标。',
|
|
111
|
+
'page.launcherToggle': '启用图标网格',
|
|
112
|
+
'page.launcherToggleHint': '关闭后侧边栏恢复宿主原本的列表样式;排序与分组仍会保留。',
|
|
113
|
+
'launcher.groupDefault': '分组',
|
|
114
|
+
'launcher.count': '{count} 个面板',
|
|
115
|
+
'launcher.renameHint': '点击重命名',
|
|
116
|
+
'launcher.dissolve': '解散分组',
|
|
117
|
+
'launcher.removeItem': '移出分组',
|
|
107
118
|
'page.footer': 'Power-Up {version} · 设置在浏览器本地保存',
|
|
108
119
|
'page.localOnly': '仅影响当前浏览器',
|
|
109
120
|
'action.copy': '复制内容',
|
|
@@ -116,6 +127,8 @@
|
|
|
116
127
|
'action.inspectHint': '打开宿主自带的记录检查器',
|
|
117
128
|
'action.fork': '从此处 Fork 会话',
|
|
118
129
|
'action.forkHint': '带着这条记录及其之前的内容分支',
|
|
130
|
+
'action.stepRef': '复制步骤引用',
|
|
131
|
+
'action.stepRefHint': '复制「会话 ID + 步骤 ID」,Agent 用 powerup_step_read 即可取回该步骤的完整数据',
|
|
119
132
|
'action.export': '导出轨迹 JSON',
|
|
120
133
|
'action.exportHint': '把当前轨迹快照保存为 JSON 文件',
|
|
121
134
|
'action.session': '复制会话 ID',
|
|
@@ -130,6 +143,8 @@
|
|
|
130
143
|
'menu.inspect': '查看记录详情',
|
|
131
144
|
'menu.fork': '从此处 Fork 会话',
|
|
132
145
|
'menu.forkHint': '含此条',
|
|
146
|
+
'menu.stepRef': '复制步骤引用',
|
|
147
|
+
'menu.noStepRef': '这条记录没有可引用的步骤 ID',
|
|
133
148
|
'menu.export': '导出轨迹 JSON',
|
|
134
149
|
'menu.session': '复制会话 ID',
|
|
135
150
|
'menu.panel': '打开 Power-Up 页面',
|
|
@@ -146,6 +161,7 @@
|
|
|
146
161
|
'toast.empty': '这条记录没有可复制的文本',
|
|
147
162
|
'toast.actionFailed': '操作失败:{message}',
|
|
148
163
|
'toast.sessionCopied': '会话 ID 已复制',
|
|
164
|
+
'toast.stepRefCopied': '步骤引用已复制',
|
|
149
165
|
'toast.forkUnavailable': '当前宿主没有提供 Fork 接口',
|
|
150
166
|
'toast.noSession': '还没有打开会话',
|
|
151
167
|
'jobStop.title': '停止后台任务',
|
|
@@ -256,7 +272,7 @@
|
|
|
256
272
|
'page.title': 'Power-Up',
|
|
257
273
|
'page.subtitle': 'A little boost for DeepSeek Harness.',
|
|
258
274
|
'page.featureTitle': 'Trajectory context menu',
|
|
259
|
-
'page.featureDesc': 'Right-click any trajectory record to copy it, quote it, open its inspector, or fork the session at that point.',
|
|
275
|
+
'page.featureDesc': 'Right-click any trajectory record to copy it, quote it, open its inspector, copy a step reference, or fork the session at that point.',
|
|
260
276
|
'page.enabled': 'Enabled',
|
|
261
277
|
'page.disabled': 'Disabled',
|
|
262
278
|
'page.actions': 'What you can do',
|
|
@@ -276,6 +292,15 @@
|
|
|
276
292
|
'page.jobStopTitle': 'Background job stop reason',
|
|
277
293
|
'page.jobStopDesc': 'When you stop a running job from the background jobs panel in the session header, you can leave a reason; the reason is appended to the notice injected into the session when the job settles.',
|
|
278
294
|
'page.jobStopHow': 'Open a session, expand the background jobs panel, press stop on a running job, type a reason (optional), then confirm.',
|
|
295
|
+
'page.launcherTitle': 'Sidebar launcher',
|
|
296
|
+
'page.launcherDesc': 'Turns the left sidebar panel buttons into an adaptive icon grid: the column count follows the sidebar width, icons sit above their labels, icons can be dragged to reorder, dropping one icon onto the middle of another forms a folder (like a Windows Start menu folder), and clicking a folder opens its contents in a flyout.',
|
|
297
|
+
'page.launcherToggle': 'Enable the icon grid',
|
|
298
|
+
'page.launcherToggleHint': 'When off, the sidebar keeps the host list; order and folders are remembered.',
|
|
299
|
+
'launcher.groupDefault': 'Group',
|
|
300
|
+
'launcher.count': '{count} panels',
|
|
301
|
+
'launcher.renameHint': 'Click to rename',
|
|
302
|
+
'launcher.dissolve': 'Ungroup',
|
|
303
|
+
'launcher.removeItem': 'Remove from group',
|
|
279
304
|
'page.footer': 'Power-Up {version} · Settings are stored in this browser',
|
|
280
305
|
'page.localOnly': 'This browser only',
|
|
281
306
|
'action.copy': 'Copy content',
|
|
@@ -288,6 +313,8 @@
|
|
|
288
313
|
'action.inspectHint': 'Open the host record inspector',
|
|
289
314
|
'action.fork': 'Fork from here',
|
|
290
315
|
'action.forkHint': 'Branch with this record and everything before it',
|
|
316
|
+
'action.stepRef': 'Copy step reference',
|
|
317
|
+
'action.stepRefHint': 'Copy "session ID + step ID"; the agent can read the full step data with powerup_step_read',
|
|
291
318
|
'action.export': 'Export trajectory JSON',
|
|
292
319
|
'action.exportHint': 'Save the current trajectory snapshot as JSON',
|
|
293
320
|
'action.session': 'Copy session ID',
|
|
@@ -302,6 +329,8 @@
|
|
|
302
329
|
'menu.inspect': 'Open record details',
|
|
303
330
|
'menu.fork': 'Fork from here',
|
|
304
331
|
'menu.forkHint': 'inclusive',
|
|
332
|
+
'menu.stepRef': 'Copy step reference',
|
|
333
|
+
'menu.noStepRef': 'This record has no referenceable step ID',
|
|
305
334
|
'menu.export': 'Export trajectory JSON',
|
|
306
335
|
'menu.session': 'Copy session ID',
|
|
307
336
|
'menu.panel': 'Open the Power-Up page',
|
|
@@ -318,6 +347,7 @@
|
|
|
318
347
|
'toast.empty': 'This record has no text to copy',
|
|
319
348
|
'toast.actionFailed': 'Action failed: {message}',
|
|
320
349
|
'toast.sessionCopied': 'Session ID copied',
|
|
350
|
+
'toast.stepRefCopied': 'Step reference copied',
|
|
321
351
|
'toast.forkUnavailable': 'This host does not expose the fork API',
|
|
322
352
|
'toast.noSession': 'No session is open',
|
|
323
353
|
'jobStop.title': 'Stop background job',
|
|
@@ -452,7 +482,7 @@
|
|
|
452
482
|
// Settings store (localStorage, per browser)
|
|
453
483
|
// ------------------------------------------------------------------
|
|
454
484
|
/** One-click update defaults: enable and restart unless the user turned one off. */
|
|
455
|
-
const DEFAULT_SETTINGS = { enabled: true, oneClickEnable: true, oneClickRestart: true };
|
|
485
|
+
const DEFAULT_SETTINGS = { enabled: true, oneClickEnable: true, oneClickRestart: true, launcher: true };
|
|
456
486
|
|
|
457
487
|
function readSettings() {
|
|
458
488
|
try {
|
|
@@ -462,6 +492,7 @@
|
|
|
462
492
|
enabled: parsed.enabled !== false,
|
|
463
493
|
oneClickEnable: parsed.oneClickEnable !== false,
|
|
464
494
|
oneClickRestart: parsed.oneClickRestart !== false,
|
|
495
|
+
launcher: parsed.launcher !== false,
|
|
465
496
|
};
|
|
466
497
|
}
|
|
467
498
|
} catch {
|
|
@@ -504,6 +535,1130 @@
|
|
|
504
535
|
return value;
|
|
505
536
|
}
|
|
506
537
|
|
|
538
|
+
// ------------------------------------------------------------------
|
|
539
|
+
// Sidebar launcher: the panel list as an adaptive icon grid
|
|
540
|
+
// ------------------------------------------------------------------
|
|
541
|
+
/** localStorage key holding the launcher's order and folders. */
|
|
542
|
+
const LAUNCHER_STORAGE_KEY = 'dsh-powerup:launcher:v1';
|
|
543
|
+
/** Prefix that marks a top-level entry as a folder instead of a panel. */
|
|
544
|
+
const LAUNCHER_GROUP_PREFIX = 'group:';
|
|
545
|
+
/** Pixel distance before a press turns into a drag. */
|
|
546
|
+
const LAUNCHER_DRAG_THRESHOLD = 6;
|
|
547
|
+
|
|
548
|
+
function launcherGroupEntry(groupId) {
|
|
549
|
+
return LAUNCHER_GROUP_PREFIX + groupId;
|
|
550
|
+
}
|
|
551
|
+
|
|
552
|
+
function launcherEntryGroupId(entry) {
|
|
553
|
+
return typeof entry === 'string' && entry.startsWith(LAUNCHER_GROUP_PREFIX)
|
|
554
|
+
? entry.slice(LAUNCHER_GROUP_PREFIX.length)
|
|
555
|
+
: null;
|
|
556
|
+
}
|
|
557
|
+
|
|
558
|
+
function makeLauncherGroupId() {
|
|
559
|
+
return 'g' + Date.now().toString(36) + Math.random().toString(36).slice(2, 6);
|
|
560
|
+
}
|
|
561
|
+
|
|
562
|
+
/**
|
|
563
|
+
* Reconcile the saved launcher state with the panels that exist right now.
|
|
564
|
+
* Unknown panel keys (unregistered, unpinned) are dropped; panels without
|
|
565
|
+
* a saved position are appended in host order; folders left empty vanish.
|
|
566
|
+
* Pure so the smoke test can cover the merge rules without a DOM.
|
|
567
|
+
* @param {unknown} raw stored value (already parsed)
|
|
568
|
+
* @param {string[]} panelKeys panel keys in host registration order
|
|
569
|
+
* @returns {{order: string[], groups: Record<string, {id: string, name: string, items: string[]}>}}
|
|
570
|
+
*/
|
|
571
|
+
function normalizeLauncherState(raw, panelKeys) {
|
|
572
|
+
const known = new Set(Array.isArray(panelKeys) ? panelKeys : []);
|
|
573
|
+
if (raw === null || typeof raw !== 'object') return { order: [...known], groups: {} };
|
|
574
|
+
const groups = {};
|
|
575
|
+
const assigned = new Set();
|
|
576
|
+
const rawGroups = raw.groups !== null && typeof raw.groups === 'object' ? raw.groups : {};
|
|
577
|
+
for (const [groupId, value] of Object.entries(rawGroups)) {
|
|
578
|
+
if (value === null || typeof value !== 'object' || typeof groupId !== 'string' || groupId === '') continue;
|
|
579
|
+
const items = [];
|
|
580
|
+
const list = Array.isArray(value.items) ? value.items : [];
|
|
581
|
+
for (const key of list) {
|
|
582
|
+
if (typeof key !== 'string' || !known.has(key) || assigned.has(key)) continue;
|
|
583
|
+
assigned.add(key);
|
|
584
|
+
items.push(key);
|
|
585
|
+
}
|
|
586
|
+
if (items.length === 0) continue;
|
|
587
|
+
groups[groupId] = {
|
|
588
|
+
id: groupId,
|
|
589
|
+
name: typeof value.name === 'string' ? value.name : '',
|
|
590
|
+
items,
|
|
591
|
+
};
|
|
592
|
+
}
|
|
593
|
+
const order = [];
|
|
594
|
+
const seen = new Set();
|
|
595
|
+
const rawOrder = Array.isArray(raw.order) ? raw.order : [];
|
|
596
|
+
for (const entry of rawOrder) {
|
|
597
|
+
if (typeof entry !== 'string' || seen.has(entry)) continue;
|
|
598
|
+
const groupId = launcherEntryGroupId(entry);
|
|
599
|
+
if (groupId !== null) {
|
|
600
|
+
if (Object.prototype.hasOwnProperty.call(groups, groupId)) {
|
|
601
|
+
order.push(entry);
|
|
602
|
+
seen.add(entry);
|
|
603
|
+
}
|
|
604
|
+
continue;
|
|
605
|
+
}
|
|
606
|
+
if (!known.has(entry) || assigned.has(entry)) continue;
|
|
607
|
+
order.push(entry);
|
|
608
|
+
seen.add(entry);
|
|
609
|
+
}
|
|
610
|
+
for (const key of known) {
|
|
611
|
+
if (assigned.has(key) || seen.has(key)) continue;
|
|
612
|
+
order.push(key);
|
|
613
|
+
seen.add(key);
|
|
614
|
+
}
|
|
615
|
+
for (const groupId of Object.keys(groups)) {
|
|
616
|
+
const entry = launcherGroupEntry(groupId);
|
|
617
|
+
if (seen.has(entry)) continue;
|
|
618
|
+
order.push(entry);
|
|
619
|
+
seen.add(entry);
|
|
620
|
+
}
|
|
621
|
+
return { order, groups };
|
|
622
|
+
}
|
|
623
|
+
|
|
624
|
+
/**
|
|
625
|
+
* DOM-driven controller for the sidebar launcher.
|
|
626
|
+
*
|
|
627
|
+
* It works on the host's own `<nav>` panel list: it adds a marker class,
|
|
628
|
+
* turns the list into an `auto-fill` grid, injects synthetic folder tiles,
|
|
629
|
+
* hides the host rows that moved into a folder, and drives drag sorting
|
|
630
|
+
* and the folder flyout with plain DOM (React owns the rows, so every
|
|
631
|
+
* change here is idempotent and re-applied after the host re-renders).
|
|
632
|
+
*
|
|
633
|
+
* Everything it needs from the plugin arrives through `deps`, which keeps
|
|
634
|
+
* this region self-contained and testable.
|
|
635
|
+
* @param {{t?: Function, format?: Function, isEnabled?: Function, read?: Function, write?: Function, listPanels?: Function}} deps
|
|
636
|
+
*/
|
|
637
|
+
function createLauncherCore(deps) {
|
|
638
|
+
const options = deps ?? {};
|
|
639
|
+
const t = typeof options.t === 'function' ? options.t : (key) => key;
|
|
640
|
+
const formatText = typeof options.format === 'function'
|
|
641
|
+
? options.format
|
|
642
|
+
: (template, params) => String(template).replace(/\{(\w+)\}/g, (match, key) =>
|
|
643
|
+
params !== undefined && params !== null && key in params ? String(params[key]) : match);
|
|
644
|
+
const isEnabled = typeof options.isEnabled === 'function' ? options.isEnabled : () => true;
|
|
645
|
+
const readRaw = typeof options.read === 'function' ? options.read : () => null;
|
|
646
|
+
const writeRaw = typeof options.write === 'function' ? options.write : () => {};
|
|
647
|
+
const listPanels = typeof options.listPanels === 'function' ? options.listPanels : () => [];
|
|
648
|
+
|
|
649
|
+
let nav = null;
|
|
650
|
+
let docObserver = null;
|
|
651
|
+
let navObserver = null;
|
|
652
|
+
let healthTimer = null;
|
|
653
|
+
let queued = 0;
|
|
654
|
+
let syncing = false;
|
|
655
|
+
let started = false;
|
|
656
|
+
let state = { order: [], groups: {} };
|
|
657
|
+
let pendingLoad = true;
|
|
658
|
+
let hostTiles = [];
|
|
659
|
+
let folderButtons = new Map();
|
|
660
|
+
let dropLine = null;
|
|
661
|
+
let drag = null;
|
|
662
|
+
let popup = null;
|
|
663
|
+
|
|
664
|
+
function warn(message, error) {
|
|
665
|
+
try {
|
|
666
|
+
console.warn('[dsh-powerup] ' + message, error?.message ?? error);
|
|
667
|
+
} catch {
|
|
668
|
+
/* Console output must never break the launcher. */
|
|
669
|
+
}
|
|
670
|
+
}
|
|
671
|
+
|
|
672
|
+
function hasDocument() {
|
|
673
|
+
return typeof document !== 'undefined'
|
|
674
|
+
&& document !== null
|
|
675
|
+
&& typeof document.querySelector === 'function'
|
|
676
|
+
&& document.body !== null
|
|
677
|
+
&& document.body !== undefined;
|
|
678
|
+
}
|
|
679
|
+
|
|
680
|
+
function scheduleSync() {
|
|
681
|
+
if (queued !== 0 || !started) return;
|
|
682
|
+
if (typeof requestAnimationFrame === 'function') {
|
|
683
|
+
queued = requestAnimationFrame(() => {
|
|
684
|
+
queued = 0;
|
|
685
|
+
sync();
|
|
686
|
+
});
|
|
687
|
+
return;
|
|
688
|
+
}
|
|
689
|
+
if (typeof window !== 'undefined' && window !== null && typeof window.setTimeout === 'function') {
|
|
690
|
+
queued = window.setTimeout(() => {
|
|
691
|
+
queued = 0;
|
|
692
|
+
sync();
|
|
693
|
+
}, 0);
|
|
694
|
+
}
|
|
695
|
+
}
|
|
696
|
+
|
|
697
|
+
function navLooksLikePanelList(candidate) {
|
|
698
|
+
if (candidate === null || candidate === undefined) return false;
|
|
699
|
+
if (typeof candidate.children !== 'object' || candidate.children === null) return false;
|
|
700
|
+
for (const child of [...candidate.children]) {
|
|
701
|
+
if (child.tagName === 'BUTTON') return true;
|
|
702
|
+
if (child.tagName === 'DIV' && typeof child.querySelector === 'function' && child.querySelector(':scope > button') !== null) return true;
|
|
703
|
+
}
|
|
704
|
+
return false;
|
|
705
|
+
}
|
|
706
|
+
|
|
707
|
+
function queryNav() {
|
|
708
|
+
if (!hasDocument()) return null;
|
|
709
|
+
const marked = document.querySelector('nav[class*="panelList"], nav.dsh-powerup-launcher');
|
|
710
|
+
if (marked !== null && marked !== undefined) return marked;
|
|
711
|
+
const candidates = typeof document.querySelectorAll === 'function' ? document.querySelectorAll('nav') : [];
|
|
712
|
+
for (const candidate of candidates) {
|
|
713
|
+
if (navLooksLikePanelList(candidate)) return candidate;
|
|
714
|
+
}
|
|
715
|
+
return null;
|
|
716
|
+
}
|
|
717
|
+
|
|
718
|
+
function observeDocument() {
|
|
719
|
+
if (docObserver !== null || typeof MutationObserver !== 'function' || !hasDocument()) return;
|
|
720
|
+
const root = document.body ?? document.documentElement;
|
|
721
|
+
if (root === null || root === undefined) return;
|
|
722
|
+
docObserver = new MutationObserver(() => {
|
|
723
|
+
const next = queryNav();
|
|
724
|
+
if (next === null) return;
|
|
725
|
+
if (docObserver !== null) {
|
|
726
|
+
docObserver.disconnect();
|
|
727
|
+
docObserver = null;
|
|
728
|
+
}
|
|
729
|
+
attachNav(next);
|
|
730
|
+
});
|
|
731
|
+
docObserver.observe(root, { childList: true, subtree: true });
|
|
732
|
+
}
|
|
733
|
+
|
|
734
|
+
function attachNav(element) {
|
|
735
|
+
nav = element;
|
|
736
|
+
element.classList.add('dsh-powerup-launcher');
|
|
737
|
+
if (navObserver !== null) navObserver.disconnect();
|
|
738
|
+
if (typeof MutationObserver === 'function') {
|
|
739
|
+
navObserver = new MutationObserver(() => {
|
|
740
|
+
if (!syncing) scheduleSync();
|
|
741
|
+
});
|
|
742
|
+
navObserver.observe(element, { childList: true, subtree: true, attributes: true, attributeFilter: ['aria-current'] });
|
|
743
|
+
}
|
|
744
|
+
sync();
|
|
745
|
+
}
|
|
746
|
+
|
|
747
|
+
/** Resolve the host panel rows (and the "more" launcher) into tile records. */
|
|
748
|
+
function collectHostTiles(container) {
|
|
749
|
+
const byLabel = new Map();
|
|
750
|
+
let panels = [];
|
|
751
|
+
try {
|
|
752
|
+
panels = listPanels() ?? [];
|
|
753
|
+
} catch {
|
|
754
|
+
panels = [];
|
|
755
|
+
}
|
|
756
|
+
if (Array.isArray(panels)) {
|
|
757
|
+
for (const panel of panels) {
|
|
758
|
+
if (panel === null || typeof panel !== 'object') continue;
|
|
759
|
+
if (typeof panel.id !== 'string' || typeof panel.label !== 'string') continue;
|
|
760
|
+
if (!byLabel.has(panel.label)) byLabel.set(panel.label, panel.id);
|
|
761
|
+
}
|
|
762
|
+
}
|
|
763
|
+
const tiles = [];
|
|
764
|
+
const usedKeys = new Set();
|
|
765
|
+
for (const child of [...container.children]) {
|
|
766
|
+
if (child.hasAttribute('data-powerup-folder')) continue;
|
|
767
|
+
if (typeof child.classList === 'object' && child.classList !== null && child.classList.contains('dsh-powerup-drop-line')) continue;
|
|
768
|
+
let gridEl = child;
|
|
769
|
+
let buttonEl = null;
|
|
770
|
+
if (child.tagName === 'BUTTON') buttonEl = child;
|
|
771
|
+
else if (child.tagName === 'DIV') {
|
|
772
|
+
buttonEl = typeof child.querySelector === 'function' ? child.querySelector(':scope > button') : null;
|
|
773
|
+
if (buttonEl === null) continue;
|
|
774
|
+
} else continue;
|
|
775
|
+
const label = buttonEl.getAttribute('aria-label') ?? '';
|
|
776
|
+
if (label === '') continue;
|
|
777
|
+
const isMore = child.tagName === 'DIV' || buttonEl.getAttribute('aria-haspopup') === 'menu';
|
|
778
|
+
let key = isMore ? '__more' : (byLabel.get(label) ?? 'label:' + label);
|
|
779
|
+
if (key !== '__more' && usedKeys.has(key)) {
|
|
780
|
+
let suffix = 2;
|
|
781
|
+
while (usedKeys.has(key + '~' + suffix)) suffix += 1;
|
|
782
|
+
key = key + '~' + suffix;
|
|
783
|
+
}
|
|
784
|
+
usedKeys.add(key);
|
|
785
|
+
gridEl.setAttribute('data-powerup-grid', key);
|
|
786
|
+
if (isMore) gridEl.setAttribute('data-powerup-more', '');
|
|
787
|
+
else gridEl.removeAttribute('data-powerup-more');
|
|
788
|
+
const glyph = typeof gridEl.querySelector === 'function'
|
|
789
|
+
? gridEl.querySelector('[class*="panelGlyph"], span[aria-hidden="true"]')
|
|
790
|
+
: null;
|
|
791
|
+
tiles.push({
|
|
792
|
+
key,
|
|
793
|
+
label,
|
|
794
|
+
gridEl,
|
|
795
|
+
buttonEl,
|
|
796
|
+
isMore,
|
|
797
|
+
glyphHtml: glyph === null ? '' : glyph.innerHTML,
|
|
798
|
+
active: false,
|
|
799
|
+
});
|
|
800
|
+
}
|
|
801
|
+
return tiles;
|
|
802
|
+
}
|
|
803
|
+
|
|
804
|
+
function detectWide(tiles) {
|
|
805
|
+
for (const tile of tiles) {
|
|
806
|
+
if (tile.isMore) continue;
|
|
807
|
+
if (typeof tile.buttonEl.querySelector === 'function' && tile.buttonEl.querySelector('[class*="panelTitle"]') !== null) return true;
|
|
808
|
+
if (tile.buttonEl.children.length >= 2) return true;
|
|
809
|
+
}
|
|
810
|
+
return false;
|
|
811
|
+
}
|
|
812
|
+
|
|
813
|
+
function tileByKeyMap() {
|
|
814
|
+
const map = new Map();
|
|
815
|
+
for (const tile of hostTiles) map.set(tile.key, tile);
|
|
816
|
+
return map;
|
|
817
|
+
}
|
|
818
|
+
|
|
819
|
+
function buildFolderTile(groupId, group, tiles) {
|
|
820
|
+
let button = folderButtons.get(groupId);
|
|
821
|
+
if (button === undefined || button.isConnected !== true) {
|
|
822
|
+
button = document.createElement('button');
|
|
823
|
+
button.type = 'button';
|
|
824
|
+
button.className = 'dsh-powerup-folder';
|
|
825
|
+
button.setAttribute('data-powerup-folder', groupId);
|
|
826
|
+
button.addEventListener('click', (event) => {
|
|
827
|
+
event.preventDefault();
|
|
828
|
+
event.stopPropagation();
|
|
829
|
+
if (drag !== null && drag.active) return;
|
|
830
|
+
toggleFolder(groupId, button);
|
|
831
|
+
});
|
|
832
|
+
nav.appendChild(button);
|
|
833
|
+
folderButtons.set(groupId, button);
|
|
834
|
+
}
|
|
835
|
+
button.setAttribute('data-powerup-folder', groupId);
|
|
836
|
+
button.setAttribute('aria-label', group.name === '' ? t('launcher.groupDefault') : group.name);
|
|
837
|
+
button.setAttribute('title', group.name === '' ? t('launcher.groupDefault') : group.name);
|
|
838
|
+
const signature = group.name + '\u0000' + group.items.join('\u0000');
|
|
839
|
+
if (button.getAttribute('data-powerup-signature') !== signature) {
|
|
840
|
+
button.setAttribute('data-powerup-signature', signature);
|
|
841
|
+
button.textContent = '';
|
|
842
|
+
const stack = document.createElement('span');
|
|
843
|
+
stack.className = 'dsh-powerup-folder-stack';
|
|
844
|
+
for (const key of group.items.slice(0, 4)) {
|
|
845
|
+
const tile = tiles.get(key);
|
|
846
|
+
const mini = document.createElement('span');
|
|
847
|
+
mini.className = 'dsh-powerup-folder-mini';
|
|
848
|
+
mini.innerHTML = tile === undefined ? '' : tile.glyphHtml;
|
|
849
|
+
stack.appendChild(mini);
|
|
850
|
+
}
|
|
851
|
+
if (group.items.length === 1) stack.classList.add('is-single');
|
|
852
|
+
const name = document.createElement('span');
|
|
853
|
+
name.className = 'dsh-powerup-folder-name';
|
|
854
|
+
name.textContent = group.name === '' ? t('launcher.groupDefault') : group.name;
|
|
855
|
+
button.append(stack, name);
|
|
856
|
+
}
|
|
857
|
+
return button;
|
|
858
|
+
}
|
|
859
|
+
|
|
860
|
+
function hideDropLine() {
|
|
861
|
+
if (dropLine !== null) dropLine.style.display = 'none';
|
|
862
|
+
if (nav !== null && typeof nav.querySelectorAll === 'function') {
|
|
863
|
+
for (const element of nav.querySelectorAll('.dsh-powerup-merge-target')) element.classList.remove('dsh-powerup-merge-target');
|
|
864
|
+
}
|
|
865
|
+
}
|
|
866
|
+
|
|
867
|
+
function clearVisuals() {
|
|
868
|
+
closePopup();
|
|
869
|
+
endDrag();
|
|
870
|
+
hideDropLine();
|
|
871
|
+
folderButtons.forEach((button) => button.remove());
|
|
872
|
+
folderButtons = new Map();
|
|
873
|
+
if (dropLine !== null) {
|
|
874
|
+
dropLine.remove();
|
|
875
|
+
dropLine = null;
|
|
876
|
+
}
|
|
877
|
+
if (nav !== null) {
|
|
878
|
+
nav.classList.remove('dsh-powerup-launcher', 'dsh-powerup-launcher-wide');
|
|
879
|
+
for (const tile of hostTiles) {
|
|
880
|
+
tile.gridEl.classList.remove('dsh-powerup-dragging', 'dsh-powerup-merge-target');
|
|
881
|
+
tile.gridEl.style.order = '';
|
|
882
|
+
tile.gridEl.style.display = '';
|
|
883
|
+
}
|
|
884
|
+
}
|
|
885
|
+
hostTiles = [];
|
|
886
|
+
}
|
|
887
|
+
|
|
888
|
+
function readPersisted() {
|
|
889
|
+
try {
|
|
890
|
+
const text = readRaw();
|
|
891
|
+
if (typeof text !== 'string' || text === '') return null;
|
|
892
|
+
return JSON.parse(text);
|
|
893
|
+
} catch {
|
|
894
|
+
return null;
|
|
895
|
+
}
|
|
896
|
+
}
|
|
897
|
+
|
|
898
|
+
function sync() {
|
|
899
|
+
if (!started || syncing || !hasDocument()) return;
|
|
900
|
+
if (nav === null || nav.isConnected !== true) {
|
|
901
|
+
const next = queryNav();
|
|
902
|
+
if (next === null) {
|
|
903
|
+
if (docObserver === null) observeDocument();
|
|
904
|
+
return;
|
|
905
|
+
}
|
|
906
|
+
attachNav(next);
|
|
907
|
+
return;
|
|
908
|
+
}
|
|
909
|
+
syncing = true;
|
|
910
|
+
try {
|
|
911
|
+
if (isEnabled() !== true) {
|
|
912
|
+
clearVisuals();
|
|
913
|
+
return;
|
|
914
|
+
}
|
|
915
|
+
nav.classList.add('dsh-powerup-launcher');
|
|
916
|
+
hostTiles = collectHostTiles(nav);
|
|
917
|
+
const wide = detectWide(hostTiles);
|
|
918
|
+
nav.classList.toggle('dsh-powerup-launcher-wide', wide);
|
|
919
|
+
const panelKeys = hostTiles.filter((tile) => !tile.isMore).map((tile) => tile.key);
|
|
920
|
+
if (pendingLoad) {
|
|
921
|
+
pendingLoad = false;
|
|
922
|
+
state = normalizeLauncherState(readPersisted(), panelKeys);
|
|
923
|
+
} else {
|
|
924
|
+
state = normalizeLauncherState(state, panelKeys);
|
|
925
|
+
}
|
|
926
|
+
const tiles = tileByKeyMap();
|
|
927
|
+
const memberOf = new Map();
|
|
928
|
+
for (const group of Object.values(state.groups)) {
|
|
929
|
+
for (const key of group.items) memberOf.set(key, group.id);
|
|
930
|
+
}
|
|
931
|
+
const orderIndex = new Map(state.order.map((entry, index) => [entry, index]));
|
|
932
|
+
for (const tile of hostTiles) {
|
|
933
|
+
tile.active = tile.buttonEl.getAttribute('aria-current') === 'page';
|
|
934
|
+
const hidden = wide && memberOf.has(tile.key);
|
|
935
|
+
/* Inline display (not a class): React rewrites className when the
|
|
936
|
+
active panel changes and would drop an added class. */
|
|
937
|
+
tile.gridEl.style.display = hidden ? 'none' : '';
|
|
938
|
+
if (tile.isMore) tile.gridEl.style.order = String(state.order.length + 4);
|
|
939
|
+
else {
|
|
940
|
+
const position = orderIndex.get(tile.key);
|
|
941
|
+
tile.gridEl.style.order = position === undefined ? '' : String(position);
|
|
942
|
+
}
|
|
943
|
+
}
|
|
944
|
+
const live = new Set();
|
|
945
|
+
for (const [groupId, group] of Object.entries(state.groups)) {
|
|
946
|
+
live.add(groupId);
|
|
947
|
+
const button = buildFolderTile(groupId, group, tiles);
|
|
948
|
+
button.style.display = wide ? '' : 'none';
|
|
949
|
+
const position = orderIndex.get(launcherGroupEntry(groupId));
|
|
950
|
+
button.style.order = position === undefined ? String(state.order.length + 2) : String(position);
|
|
951
|
+
const active = group.items.some((key) => tiles.get(key)?.active === true);
|
|
952
|
+
button.classList.toggle('is-active', active);
|
|
953
|
+
}
|
|
954
|
+
for (const [groupId, button] of [...folderButtons]) {
|
|
955
|
+
if (live.has(groupId)) continue;
|
|
956
|
+
button.remove();
|
|
957
|
+
folderButtons.delete(groupId);
|
|
958
|
+
}
|
|
959
|
+
if (popup !== null) {
|
|
960
|
+
if (state.groups[popup.groupId] === undefined) closePopup();
|
|
961
|
+
else renderPopup();
|
|
962
|
+
}
|
|
963
|
+
} catch (error) {
|
|
964
|
+
warn('launcher sync failed:', error);
|
|
965
|
+
} finally {
|
|
966
|
+
syncing = false;
|
|
967
|
+
}
|
|
968
|
+
}
|
|
969
|
+
|
|
970
|
+
function save() {
|
|
971
|
+
try {
|
|
972
|
+
writeRaw(JSON.stringify(state));
|
|
973
|
+
} catch (error) {
|
|
974
|
+
warn('launcher state could not be saved:', error);
|
|
975
|
+
}
|
|
976
|
+
}
|
|
977
|
+
|
|
978
|
+
// ----------------------------------------------------------------
|
|
979
|
+
// Folder flyout
|
|
980
|
+
// ----------------------------------------------------------------
|
|
981
|
+
function toggleFolder(groupId, anchor) {
|
|
982
|
+
if (popup !== null && popup.groupId === groupId) {
|
|
983
|
+
closePopup();
|
|
984
|
+
return;
|
|
985
|
+
}
|
|
986
|
+
openFolder(groupId, anchor);
|
|
987
|
+
}
|
|
988
|
+
|
|
989
|
+
function openFolder(groupId, anchor) {
|
|
990
|
+
if (!hasDocument() || state.groups[groupId] === undefined) return;
|
|
991
|
+
closePopup();
|
|
992
|
+
const element = document.createElement('div');
|
|
993
|
+
element.className = 'dsh-powerup-folder-pop';
|
|
994
|
+
element.setAttribute('role', 'dialog');
|
|
995
|
+
element.setAttribute('aria-label', state.groups[groupId].name === '' ? t('launcher.groupDefault') : state.groups[groupId].name);
|
|
996
|
+
element.setAttribute('data-powerup-folder-pop', groupId);
|
|
997
|
+
document.body.appendChild(element);
|
|
998
|
+
popup = { element, groupId, anchor };
|
|
999
|
+
renderPopup();
|
|
1000
|
+
positionPopup();
|
|
1001
|
+
const reveal = () => {
|
|
1002
|
+
if (popup !== null && popup.element === element) element.classList.add('is-open');
|
|
1003
|
+
};
|
|
1004
|
+
if (typeof requestAnimationFrame === 'function') requestAnimationFrame(reveal);
|
|
1005
|
+
else reveal();
|
|
1006
|
+
document.addEventListener('pointerdown', onPopupOutside, true);
|
|
1007
|
+
document.addEventListener('keydown', onPopupKey, true);
|
|
1008
|
+
if (typeof window !== 'undefined' && window !== null && typeof window.addEventListener === 'function') {
|
|
1009
|
+
window.addEventListener('resize', closePopup, true);
|
|
1010
|
+
window.addEventListener('scroll', onPopupScroll, true);
|
|
1011
|
+
}
|
|
1012
|
+
}
|
|
1013
|
+
|
|
1014
|
+
function closePopup() {
|
|
1015
|
+
if (popup === null) return;
|
|
1016
|
+
const element = popup.element;
|
|
1017
|
+
popup = null;
|
|
1018
|
+
document.removeEventListener('pointerdown', onPopupOutside, true);
|
|
1019
|
+
document.removeEventListener('keydown', onPopupKey, true);
|
|
1020
|
+
if (typeof window !== 'undefined' && window !== null && typeof window.removeEventListener === 'function') {
|
|
1021
|
+
window.removeEventListener('resize', closePopup, true);
|
|
1022
|
+
window.removeEventListener('scroll', onPopupScroll, true);
|
|
1023
|
+
}
|
|
1024
|
+
element.classList.remove('is-open');
|
|
1025
|
+
const remove = () => {
|
|
1026
|
+
if (element.parentNode !== null) element.remove();
|
|
1027
|
+
};
|
|
1028
|
+
if (typeof window !== 'undefined' && window !== null && typeof window.setTimeout === 'function') {
|
|
1029
|
+
window.setTimeout(remove, 170);
|
|
1030
|
+
} else {
|
|
1031
|
+
remove();
|
|
1032
|
+
}
|
|
1033
|
+
}
|
|
1034
|
+
|
|
1035
|
+
function onPopupOutside(event) {
|
|
1036
|
+
if (popup === null) return;
|
|
1037
|
+
const target = event.target;
|
|
1038
|
+
if (target === null || target === undefined) return;
|
|
1039
|
+
if (typeof popup.element.contains === 'function' && popup.element.contains(target)) return;
|
|
1040
|
+
if (popup.anchor !== null && popup.anchor !== undefined && typeof popup.anchor.contains === 'function' && popup.anchor.contains(target)) return;
|
|
1041
|
+
closePopup();
|
|
1042
|
+
}
|
|
1043
|
+
|
|
1044
|
+
function onPopupKey(event) {
|
|
1045
|
+
if (popup === null || event.key !== 'Escape') return;
|
|
1046
|
+
const target = event.target;
|
|
1047
|
+
const tag = target !== null && target !== undefined && typeof target.tagName === 'string' ? target.tagName : '';
|
|
1048
|
+
if (tag === 'INPUT' && typeof popup.element.contains === 'function' && popup.element.contains(target)) return;
|
|
1049
|
+
closePopup();
|
|
1050
|
+
}
|
|
1051
|
+
|
|
1052
|
+
function onPopupScroll(event) {
|
|
1053
|
+
if (popup === null) return;
|
|
1054
|
+
if (typeof popup.element.contains === 'function' && popup.element.contains(event.target)) return;
|
|
1055
|
+
closePopup();
|
|
1056
|
+
}
|
|
1057
|
+
|
|
1058
|
+
function positionPopup() {
|
|
1059
|
+
if (popup === null) return;
|
|
1060
|
+
const anchor = popup.anchor;
|
|
1061
|
+
const element = popup.element;
|
|
1062
|
+
if (anchor === null || anchor === undefined || typeof anchor.getBoundingClientRect !== 'function') return;
|
|
1063
|
+
const rect = anchor.getBoundingClientRect();
|
|
1064
|
+
if (rect.width === 0 && rect.height === 0) return;
|
|
1065
|
+
const width = element.offsetWidth || 0;
|
|
1066
|
+
const height = element.offsetHeight || 0;
|
|
1067
|
+
const viewWidth = (typeof window !== 'undefined' && window !== null && window.innerWidth) || 1280;
|
|
1068
|
+
const viewHeight = (typeof window !== 'undefined' && window !== null && window.innerHeight) || 900;
|
|
1069
|
+
const gap = 8;
|
|
1070
|
+
const margin = 10;
|
|
1071
|
+
let left = rect.right + gap;
|
|
1072
|
+
let originX = 'left';
|
|
1073
|
+
if (left + width > viewWidth - margin) {
|
|
1074
|
+
const alternate = rect.left - gap - width;
|
|
1075
|
+
if (alternate >= margin) {
|
|
1076
|
+
left = alternate;
|
|
1077
|
+
originX = 'right';
|
|
1078
|
+
} else {
|
|
1079
|
+
left = Math.max(margin, viewWidth - width - margin);
|
|
1080
|
+
}
|
|
1081
|
+
}
|
|
1082
|
+
const top = Math.max(margin, Math.min(rect.top - 6, viewHeight - height - margin));
|
|
1083
|
+
element.style.left = Math.round(left) + 'px';
|
|
1084
|
+
element.style.top = Math.round(top) + 'px';
|
|
1085
|
+
element.style.transformOrigin = originX + ' 22%';
|
|
1086
|
+
}
|
|
1087
|
+
|
|
1088
|
+
function renderPopup() {
|
|
1089
|
+
if (popup === null) return;
|
|
1090
|
+
const group = state.groups[popup.groupId];
|
|
1091
|
+
if (group === undefined) {
|
|
1092
|
+
closePopup();
|
|
1093
|
+
return;
|
|
1094
|
+
}
|
|
1095
|
+
const element = popup.element;
|
|
1096
|
+
element.textContent = '';
|
|
1097
|
+
const head = document.createElement('div');
|
|
1098
|
+
head.className = 'dsh-powerup-folder-pop-head';
|
|
1099
|
+
const title = document.createElement('button');
|
|
1100
|
+
title.type = 'button';
|
|
1101
|
+
title.className = 'dsh-powerup-folder-pop-title';
|
|
1102
|
+
title.textContent = group.name === '' ? t('launcher.groupDefault') : group.name;
|
|
1103
|
+
title.setAttribute('title', t('launcher.renameHint'));
|
|
1104
|
+
title.addEventListener('click', beginRename);
|
|
1105
|
+
const count = document.createElement('span');
|
|
1106
|
+
count.className = 'dsh-powerup-folder-pop-count';
|
|
1107
|
+
count.textContent = formatText(t('launcher.count'), { count: group.items.length });
|
|
1108
|
+
const dissolve = document.createElement('button');
|
|
1109
|
+
dissolve.type = 'button';
|
|
1110
|
+
dissolve.className = 'dsh-powerup-folder-pop-action';
|
|
1111
|
+
dissolve.textContent = t('launcher.dissolve');
|
|
1112
|
+
dissolve.addEventListener('click', () => dissolveGroup(popup === null ? null : popup.groupId));
|
|
1113
|
+
head.append(title, count, dissolve);
|
|
1114
|
+
const grid = document.createElement('div');
|
|
1115
|
+
grid.className = 'dsh-powerup-folder-grid';
|
|
1116
|
+
const tiles = tileByKeyMap();
|
|
1117
|
+
for (const key of group.items) {
|
|
1118
|
+
const tile = tiles.get(key);
|
|
1119
|
+
if (tile === undefined) continue;
|
|
1120
|
+
const item = document.createElement('div');
|
|
1121
|
+
item.className = 'dsh-powerup-folder-item';
|
|
1122
|
+
item.setAttribute('role', 'button');
|
|
1123
|
+
item.setAttribute('tabindex', '0');
|
|
1124
|
+
item.setAttribute('aria-label', tile.label);
|
|
1125
|
+
const glyph = document.createElement('span');
|
|
1126
|
+
glyph.className = 'dsh-powerup-folder-item-glyph';
|
|
1127
|
+
glyph.innerHTML = tile.glyphHtml;
|
|
1128
|
+
const label = document.createElement('span');
|
|
1129
|
+
label.className = 'dsh-powerup-folder-item-label';
|
|
1130
|
+
label.textContent = tile.label;
|
|
1131
|
+
const remove = document.createElement('span');
|
|
1132
|
+
remove.className = 'dsh-powerup-folder-item-remove';
|
|
1133
|
+
remove.setAttribute('role', 'button');
|
|
1134
|
+
remove.setAttribute('tabindex', '0');
|
|
1135
|
+
remove.setAttribute('aria-label', t('launcher.removeItem'));
|
|
1136
|
+
remove.setAttribute('title', t('launcher.removeItem'));
|
|
1137
|
+
remove.textContent = '\u00d7';
|
|
1138
|
+
remove.addEventListener('click', (event) => {
|
|
1139
|
+
event.preventDefault();
|
|
1140
|
+
event.stopPropagation();
|
|
1141
|
+
removeFromGroup(popup === null ? null : popup.groupId, key);
|
|
1142
|
+
});
|
|
1143
|
+
remove.addEventListener('keydown', (event) => {
|
|
1144
|
+
if (event.key !== 'Enter' && event.key !== ' ') return;
|
|
1145
|
+
event.preventDefault();
|
|
1146
|
+
event.stopPropagation();
|
|
1147
|
+
removeFromGroup(popup === null ? null : popup.groupId, key);
|
|
1148
|
+
});
|
|
1149
|
+
item.append(glyph, label, remove);
|
|
1150
|
+
item.addEventListener('click', () => selectPanel(tile));
|
|
1151
|
+
item.addEventListener('keydown', (event) => {
|
|
1152
|
+
if (event.key !== 'Enter' && event.key !== ' ') return;
|
|
1153
|
+
event.preventDefault();
|
|
1154
|
+
selectPanel(tile);
|
|
1155
|
+
});
|
|
1156
|
+
grid.appendChild(item);
|
|
1157
|
+
}
|
|
1158
|
+
element.append(head, grid);
|
|
1159
|
+
positionPopup();
|
|
1160
|
+
}
|
|
1161
|
+
|
|
1162
|
+
function beginRename() {
|
|
1163
|
+
if (popup === null) return;
|
|
1164
|
+
const group = state.groups[popup.groupId];
|
|
1165
|
+
if (group === undefined) return;
|
|
1166
|
+
const current = popup.element.querySelector('.dsh-powerup-folder-pop-title');
|
|
1167
|
+
if (current === null) return;
|
|
1168
|
+
const input = document.createElement('input');
|
|
1169
|
+
input.type = 'text';
|
|
1170
|
+
input.className = 'dsh-powerup-folder-pop-input';
|
|
1171
|
+
input.value = group.name;
|
|
1172
|
+
input.placeholder = t('launcher.groupDefault');
|
|
1173
|
+
input.setAttribute('maxlength', '24');
|
|
1174
|
+
const commit = () => {
|
|
1175
|
+
if (popup === null) return;
|
|
1176
|
+
const target = state.groups[popup.groupId];
|
|
1177
|
+
if (target === undefined) return;
|
|
1178
|
+
const name = input.value.trim().slice(0, 24);
|
|
1179
|
+
if (name === target.name) {
|
|
1180
|
+
renderPopup();
|
|
1181
|
+
return;
|
|
1182
|
+
}
|
|
1183
|
+
state = { order: state.order, groups: { ...state.groups, [popup.groupId]: { ...target, name } } };
|
|
1184
|
+
save();
|
|
1185
|
+
sync();
|
|
1186
|
+
};
|
|
1187
|
+
input.addEventListener('keydown', (event) => {
|
|
1188
|
+
if (event.key === 'Enter') {
|
|
1189
|
+
event.preventDefault();
|
|
1190
|
+
commit();
|
|
1191
|
+
} else if (event.key === 'Escape') {
|
|
1192
|
+
event.preventDefault();
|
|
1193
|
+
event.stopPropagation();
|
|
1194
|
+
renderPopup();
|
|
1195
|
+
}
|
|
1196
|
+
});
|
|
1197
|
+
input.addEventListener('blur', commit);
|
|
1198
|
+
current.replaceWith(input);
|
|
1199
|
+
if (typeof input.focus === 'function') {
|
|
1200
|
+
input.focus();
|
|
1201
|
+
if (typeof input.select === 'function') input.select();
|
|
1202
|
+
}
|
|
1203
|
+
}
|
|
1204
|
+
|
|
1205
|
+
function selectPanel(tile) {
|
|
1206
|
+
try {
|
|
1207
|
+
tile.buttonEl.click();
|
|
1208
|
+
} catch (error) {
|
|
1209
|
+
warn('panel could not be selected:', error);
|
|
1210
|
+
}
|
|
1211
|
+
closePopup();
|
|
1212
|
+
}
|
|
1213
|
+
|
|
1214
|
+
function removeFromGroup(groupId, key) {
|
|
1215
|
+
if (groupId === null || typeof groupId !== 'string' || typeof key !== 'string') return;
|
|
1216
|
+
const group = state.groups[groupId];
|
|
1217
|
+
if (group === undefined) return;
|
|
1218
|
+
const items = group.items.filter((entry) => entry !== key);
|
|
1219
|
+
const order = state.order.filter((entry) => entry !== key);
|
|
1220
|
+
const groups = { ...state.groups };
|
|
1221
|
+
if (items.length === 0) {
|
|
1222
|
+
delete groups[groupId];
|
|
1223
|
+
state = { order: order.filter((entry) => entry !== launcherGroupEntry(groupId)), groups };
|
|
1224
|
+
} else {
|
|
1225
|
+
groups[groupId] = { ...group, items };
|
|
1226
|
+
order.push(key);
|
|
1227
|
+
state = { order, groups };
|
|
1228
|
+
}
|
|
1229
|
+
save();
|
|
1230
|
+
sync();
|
|
1231
|
+
}
|
|
1232
|
+
|
|
1233
|
+
function dissolveGroup(groupId) {
|
|
1234
|
+
if (groupId === null || typeof groupId !== 'string') return;
|
|
1235
|
+
const group = state.groups[groupId];
|
|
1236
|
+
if (group === undefined) return;
|
|
1237
|
+
const groups = { ...state.groups };
|
|
1238
|
+
delete groups[groupId];
|
|
1239
|
+
const order = state.order
|
|
1240
|
+
.filter((entry) => entry !== launcherGroupEntry(groupId))
|
|
1241
|
+
.concat(group.items.filter((key) => !state.order.includes(key)));
|
|
1242
|
+
state = { order, groups };
|
|
1243
|
+
save();
|
|
1244
|
+
closePopup();
|
|
1245
|
+
sync();
|
|
1246
|
+
}
|
|
1247
|
+
|
|
1248
|
+
// ----------------------------------------------------------------
|
|
1249
|
+
// Drag sorting and folder merging
|
|
1250
|
+
// ----------------------------------------------------------------
|
|
1251
|
+
function topLevelCandidates(excludeKey) {
|
|
1252
|
+
const candidates = [];
|
|
1253
|
+
for (const entry of state.order) {
|
|
1254
|
+
if (entry === excludeKey) continue;
|
|
1255
|
+
const groupId = launcherEntryGroupId(entry);
|
|
1256
|
+
if (groupId !== null) {
|
|
1257
|
+
const button = folderButtons.get(groupId);
|
|
1258
|
+
if (button !== undefined && button.isConnected === true) candidates.push({ key: entry, el: button, kind: 'folder' });
|
|
1259
|
+
continue;
|
|
1260
|
+
}
|
|
1261
|
+
const tile = hostTiles.find((candidate) => candidate.key === entry);
|
|
1262
|
+
if (tile === undefined) continue;
|
|
1263
|
+
if (tile.gridEl.style.display === 'none') continue;
|
|
1264
|
+
candidates.push({ key: entry, el: tile.gridEl, kind: 'panel' });
|
|
1265
|
+
}
|
|
1266
|
+
return candidates;
|
|
1267
|
+
}
|
|
1268
|
+
|
|
1269
|
+
function describeTile(target) {
|
|
1270
|
+
if (target === null || target === undefined || typeof target.closest !== 'function') return null;
|
|
1271
|
+
const button = target.closest('button');
|
|
1272
|
+
if (button === null || nav === null || !nav.contains(button)) return null;
|
|
1273
|
+
const folderId = button.getAttribute('data-powerup-folder');
|
|
1274
|
+
if (folderId !== null) {
|
|
1275
|
+
const group = state.groups[folderId];
|
|
1276
|
+
if (group === undefined) return null;
|
|
1277
|
+
return { kind: 'folder', key: launcherGroupEntry(folderId), gridEl: button, label: group.name };
|
|
1278
|
+
}
|
|
1279
|
+
const tile = hostTiles.find((candidate) => candidate.buttonEl === button);
|
|
1280
|
+
if (tile === undefined || tile.isMore) return null;
|
|
1281
|
+
return { kind: 'panel', key: tile.key, gridEl: tile.gridEl, label: tile.label };
|
|
1282
|
+
}
|
|
1283
|
+
|
|
1284
|
+
function onPointerDown(event) {
|
|
1285
|
+
if (!started || event.button !== undefined && event.button !== 0) return;
|
|
1286
|
+
if (nav === null || !nav.classList.contains('dsh-powerup-launcher-wide')) return;
|
|
1287
|
+
if (popup !== null && typeof popup.element.contains === 'function' && popup.element.contains(event.target)) return;
|
|
1288
|
+
const descriptor = describeTile(event.target);
|
|
1289
|
+
if (descriptor === null) return;
|
|
1290
|
+
drag = {
|
|
1291
|
+
descriptor,
|
|
1292
|
+
startX: event.clientX,
|
|
1293
|
+
startY: event.clientY,
|
|
1294
|
+
active: false,
|
|
1295
|
+
ghost: null,
|
|
1296
|
+
offsetX: 0,
|
|
1297
|
+
offsetY: 0,
|
|
1298
|
+
drop: null,
|
|
1299
|
+
};
|
|
1300
|
+
document.addEventListener('pointermove', onPointerMove, { capture: true, passive: false });
|
|
1301
|
+
document.addEventListener('pointerup', onPointerUp, true);
|
|
1302
|
+
document.addEventListener('pointercancel', onPointerUp, true);
|
|
1303
|
+
document.addEventListener('keydown', onDragKey, true);
|
|
1304
|
+
}
|
|
1305
|
+
|
|
1306
|
+
function onDragKey(event) {
|
|
1307
|
+
if (event.key !== 'Escape') return;
|
|
1308
|
+
endDrag();
|
|
1309
|
+
}
|
|
1310
|
+
|
|
1311
|
+
function beginDrag() {
|
|
1312
|
+
if (drag === null) return;
|
|
1313
|
+
drag.active = true;
|
|
1314
|
+
closePopup();
|
|
1315
|
+
const gridEl = drag.descriptor.gridEl;
|
|
1316
|
+
const rect = gridEl.getBoundingClientRect();
|
|
1317
|
+
const ghost = gridEl.cloneNode(true);
|
|
1318
|
+
ghost.className = 'dsh-powerup-drag-ghost';
|
|
1319
|
+
ghost.removeAttribute('data-powerup-grid');
|
|
1320
|
+
ghost.removeAttribute('data-powerup-more');
|
|
1321
|
+
ghost.removeAttribute('data-powerup-host');
|
|
1322
|
+
ghost.removeAttribute('aria-label');
|
|
1323
|
+
ghost.style.width = rect.width + 'px';
|
|
1324
|
+
ghost.style.height = rect.height + 'px';
|
|
1325
|
+
ghost.style.left = rect.left + 'px';
|
|
1326
|
+
ghost.style.top = rect.top + 'px';
|
|
1327
|
+
ghost.style.order = '';
|
|
1328
|
+
document.body.appendChild(ghost);
|
|
1329
|
+
drag.ghost = ghost;
|
|
1330
|
+
drag.offsetX = drag.startX - rect.left;
|
|
1331
|
+
drag.offsetY = drag.startY - rect.top;
|
|
1332
|
+
gridEl.classList.add('dsh-powerup-dragging');
|
|
1333
|
+
hideDropLine();
|
|
1334
|
+
}
|
|
1335
|
+
|
|
1336
|
+
function moveGhost(x, y) {
|
|
1337
|
+
if (drag === null || drag.ghost === null) return;
|
|
1338
|
+
drag.ghost.style.left = Math.round(x - drag.offsetX) + 'px';
|
|
1339
|
+
drag.ghost.style.top = Math.round(y - drag.offsetY) + 'px';
|
|
1340
|
+
}
|
|
1341
|
+
|
|
1342
|
+
function onPointerMove(event) {
|
|
1343
|
+
if (drag === null) return;
|
|
1344
|
+
if (!drag.active) {
|
|
1345
|
+
const dx = event.clientX - drag.startX;
|
|
1346
|
+
const dy = event.clientY - drag.startY;
|
|
1347
|
+
if (Math.sqrt(dx * dx + dy * dy) < LAUNCHER_DRAG_THRESHOLD) return;
|
|
1348
|
+
beginDrag();
|
|
1349
|
+
}
|
|
1350
|
+
if (typeof event.preventDefault === 'function') event.preventDefault();
|
|
1351
|
+
moveGhost(event.clientX, event.clientY);
|
|
1352
|
+
updateDrop(event.clientX, event.clientY);
|
|
1353
|
+
}
|
|
1354
|
+
|
|
1355
|
+
function updateDrop(x, y) {
|
|
1356
|
+
if (drag === null || !drag.active) return;
|
|
1357
|
+
const candidates = topLevelCandidates(drag.descriptor.key);
|
|
1358
|
+
let drop = null;
|
|
1359
|
+
for (const candidate of candidates) {
|
|
1360
|
+
if (candidate.el === undefined || typeof candidate.el.getBoundingClientRect !== 'function') continue;
|
|
1361
|
+
const rect = candidate.el.getBoundingClientRect();
|
|
1362
|
+
if (rect.width === 0 && rect.height === 0) continue;
|
|
1363
|
+
if (x < rect.left || x > rect.right || y < rect.top || y > rect.bottom) continue;
|
|
1364
|
+
const centerX = rect.left + rect.width / 2;
|
|
1365
|
+
const centerY = rect.top + rect.height / 2;
|
|
1366
|
+
const nearCenter = Math.abs(x - centerX) <= rect.width * 0.28 && Math.abs(y - centerY) <= rect.height * 0.32;
|
|
1367
|
+
if (nearCenter) {
|
|
1368
|
+
drop = { kind: 'merge', target: candidate };
|
|
1369
|
+
} else {
|
|
1370
|
+
drop = { kind: 'insert', index: candidates.indexOf(candidate) + (x < centerX ? 0 : 1), anchor: rect, after: x >= centerX };
|
|
1371
|
+
}
|
|
1372
|
+
break;
|
|
1373
|
+
}
|
|
1374
|
+
if (drop === null) {
|
|
1375
|
+
let index = candidates.length;
|
|
1376
|
+
for (let cursor = 0; cursor < candidates.length; cursor += 1) {
|
|
1377
|
+
const rect = candidates[cursor].el.getBoundingClientRect();
|
|
1378
|
+
if (y < rect.top) {
|
|
1379
|
+
index = cursor;
|
|
1380
|
+
break;
|
|
1381
|
+
}
|
|
1382
|
+
if (y <= rect.bottom && x < rect.left + rect.width / 2) {
|
|
1383
|
+
index = cursor;
|
|
1384
|
+
break;
|
|
1385
|
+
}
|
|
1386
|
+
}
|
|
1387
|
+
const anchor = index < candidates.length && candidates[index] !== undefined
|
|
1388
|
+
? candidates[index].el.getBoundingClientRect()
|
|
1389
|
+
: (candidates.length > 0 ? candidates[candidates.length - 1].el.getBoundingClientRect() : null);
|
|
1390
|
+
drop = { kind: 'insert', index, anchor, after: index >= candidates.length };
|
|
1391
|
+
}
|
|
1392
|
+
drag.drop = drop;
|
|
1393
|
+
paintDrop(drop, candidates);
|
|
1394
|
+
}
|
|
1395
|
+
|
|
1396
|
+
function paintDrop(drop, candidates) {
|
|
1397
|
+
if (nav === null) return;
|
|
1398
|
+
for (const candidate of candidates) candidate.el.classList.remove('dsh-powerup-merge-target');
|
|
1399
|
+
if (drop.kind === 'merge') {
|
|
1400
|
+
hideDropLine();
|
|
1401
|
+
if (drop.target !== undefined && drop.target.el !== undefined) drop.target.el.classList.add('dsh-powerup-merge-target');
|
|
1402
|
+
return;
|
|
1403
|
+
}
|
|
1404
|
+
let rect = drop.anchor;
|
|
1405
|
+
let after = drop.after === true;
|
|
1406
|
+
if (rect === null || rect === undefined) {
|
|
1407
|
+
if (drop.index < candidates.length && candidates[drop.index] !== undefined) rect = candidates[drop.index].el.getBoundingClientRect();
|
|
1408
|
+
else if (candidates.length > 0) {
|
|
1409
|
+
rect = candidates[candidates.length - 1].el.getBoundingClientRect();
|
|
1410
|
+
after = true;
|
|
1411
|
+
}
|
|
1412
|
+
}
|
|
1413
|
+
if (rect === null || rect === undefined) {
|
|
1414
|
+
hideDropLine();
|
|
1415
|
+
return;
|
|
1416
|
+
}
|
|
1417
|
+
if (dropLine === null) {
|
|
1418
|
+
dropLine = document.createElement('div');
|
|
1419
|
+
dropLine.className = 'dsh-powerup-drop-line';
|
|
1420
|
+
dropLine.setAttribute('aria-hidden', 'true');
|
|
1421
|
+
nav.appendChild(dropLine);
|
|
1422
|
+
}
|
|
1423
|
+
const navRect = nav.getBoundingClientRect();
|
|
1424
|
+
dropLine.style.left = Math.round((after ? rect.right + 1 : rect.left - 1) - navRect.left) + 'px';
|
|
1425
|
+
dropLine.style.top = Math.round(rect.top - navRect.top) + 'px';
|
|
1426
|
+
dropLine.style.height = Math.round(rect.height) + 'px';
|
|
1427
|
+
dropLine.style.display = 'block';
|
|
1428
|
+
}
|
|
1429
|
+
|
|
1430
|
+
function endDrag() {
|
|
1431
|
+
document.removeEventListener('pointermove', onPointerMove, { capture: true, passive: false });
|
|
1432
|
+
document.removeEventListener('pointerup', onPointerUp, true);
|
|
1433
|
+
document.removeEventListener('pointercancel', onPointerUp, true);
|
|
1434
|
+
document.removeEventListener('keydown', onDragKey, true);
|
|
1435
|
+
if (drag !== null) {
|
|
1436
|
+
if (drag.ghost !== null) drag.ghost.remove();
|
|
1437
|
+
if (drag.descriptor !== undefined && drag.descriptor.gridEl !== undefined) drag.descriptor.gridEl.classList.remove('dsh-powerup-dragging');
|
|
1438
|
+
}
|
|
1439
|
+
hideDropLine();
|
|
1440
|
+
drag = null;
|
|
1441
|
+
}
|
|
1442
|
+
|
|
1443
|
+
function suppressNextClick() {
|
|
1444
|
+
const swallow = (event) => {
|
|
1445
|
+
if (typeof event.preventDefault === 'function') event.preventDefault();
|
|
1446
|
+
if (typeof event.stopPropagation === 'function') event.stopPropagation();
|
|
1447
|
+
};
|
|
1448
|
+
document.addEventListener('click', swallow, true);
|
|
1449
|
+
if (typeof window !== 'undefined' && window !== null && typeof window.setTimeout === 'function') {
|
|
1450
|
+
window.setTimeout(() => document.removeEventListener('click', swallow, true), 80);
|
|
1451
|
+
} else {
|
|
1452
|
+
document.removeEventListener('click', swallow, true);
|
|
1453
|
+
}
|
|
1454
|
+
}
|
|
1455
|
+
|
|
1456
|
+
function onPointerUp() {
|
|
1457
|
+
if (drag === null) return;
|
|
1458
|
+
const active = drag.active;
|
|
1459
|
+
const descriptor = drag.descriptor;
|
|
1460
|
+
const drop = drag.drop;
|
|
1461
|
+
endDrag();
|
|
1462
|
+
if (!active) return;
|
|
1463
|
+
suppressNextClick();
|
|
1464
|
+
if (drop !== null && drop.kind === 'merge' && drop.target !== undefined) {
|
|
1465
|
+
performMerge(descriptor.key, drop.target.key);
|
|
1466
|
+
} else if (drop !== null && drop.kind === 'insert') {
|
|
1467
|
+
performReorder(descriptor.key, drop.index);
|
|
1468
|
+
} else {
|
|
1469
|
+
sync();
|
|
1470
|
+
}
|
|
1471
|
+
}
|
|
1472
|
+
|
|
1473
|
+
function performReorder(key, index) {
|
|
1474
|
+
const order = state.order.filter((entry) => entry !== key);
|
|
1475
|
+
const clamped = Math.max(0, Math.min(index, order.length));
|
|
1476
|
+
order.splice(clamped, 0, key);
|
|
1477
|
+
state = { order: dedupeEntries(order), groups: state.groups };
|
|
1478
|
+
save();
|
|
1479
|
+
sync();
|
|
1480
|
+
}
|
|
1481
|
+
|
|
1482
|
+
function dedupeEntries(entries) {
|
|
1483
|
+
const seen = new Set();
|
|
1484
|
+
const result = [];
|
|
1485
|
+
for (const entry of entries) {
|
|
1486
|
+
if (typeof entry !== 'string' || seen.has(entry)) continue;
|
|
1487
|
+
seen.add(entry);
|
|
1488
|
+
result.push(entry);
|
|
1489
|
+
}
|
|
1490
|
+
return result;
|
|
1491
|
+
}
|
|
1492
|
+
|
|
1493
|
+
function performMerge(sourceKey, targetKey) {
|
|
1494
|
+
if (sourceKey === targetKey) return;
|
|
1495
|
+
const sourceGroupId = launcherEntryGroupId(sourceKey);
|
|
1496
|
+
const targetGroupId = launcherEntryGroupId(targetKey);
|
|
1497
|
+
if (sourceGroupId !== null && sourceGroupId === targetGroupId) return;
|
|
1498
|
+
const groups = { ...state.groups };
|
|
1499
|
+
let order = [...state.order];
|
|
1500
|
+
let sourceItems = [];
|
|
1501
|
+
let sourceName = '';
|
|
1502
|
+
if (sourceGroupId !== null) {
|
|
1503
|
+
const source = groups[sourceGroupId];
|
|
1504
|
+
if (source === undefined) return;
|
|
1505
|
+
sourceItems = [...source.items];
|
|
1506
|
+
sourceName = source.name;
|
|
1507
|
+
delete groups[sourceGroupId];
|
|
1508
|
+
} else {
|
|
1509
|
+
sourceItems = [sourceKey];
|
|
1510
|
+
}
|
|
1511
|
+
order = order.filter((entry) => entry !== sourceKey);
|
|
1512
|
+
if (targetGroupId !== null) {
|
|
1513
|
+
const target = groups[targetGroupId];
|
|
1514
|
+
if (target === undefined) return;
|
|
1515
|
+
const items = [...target.items];
|
|
1516
|
+
for (const key of sourceItems) if (!items.includes(key)) items.push(key);
|
|
1517
|
+
groups[targetGroupId] = { ...target, items, name: target.name !== '' ? target.name : sourceName };
|
|
1518
|
+
} else {
|
|
1519
|
+
const groupId = sourceGroupId !== null ? sourceGroupId : makeLauncherGroupId();
|
|
1520
|
+
const items = [];
|
|
1521
|
+
for (const key of sourceItems) if (!items.includes(key)) items.push(key);
|
|
1522
|
+
if (!items.includes(targetKey)) items.push(targetKey);
|
|
1523
|
+
groups[groupId] = { id: groupId, name: sourceName, items };
|
|
1524
|
+
const position = order.indexOf(targetKey);
|
|
1525
|
+
if (position >= 0) order[position] = launcherGroupEntry(groupId);
|
|
1526
|
+
else order.push(launcherGroupEntry(groupId));
|
|
1527
|
+
}
|
|
1528
|
+
state = { order: dedupeEntries(order), groups };
|
|
1529
|
+
save();
|
|
1530
|
+
sync();
|
|
1531
|
+
}
|
|
1532
|
+
|
|
1533
|
+
function start() {
|
|
1534
|
+
if (started || !hasDocument()) return;
|
|
1535
|
+
started = true;
|
|
1536
|
+
document.addEventListener('pointerdown', onPointerDown, true);
|
|
1537
|
+
const element = queryNav();
|
|
1538
|
+
if (element !== null) attachNav(element);
|
|
1539
|
+
else observeDocument();
|
|
1540
|
+
if (typeof window !== 'undefined' && window !== null && typeof window.setInterval === 'function') {
|
|
1541
|
+
healthTimer = window.setInterval(() => {
|
|
1542
|
+
if (!started) return;
|
|
1543
|
+
if (nav !== null && nav.isConnected === true) return;
|
|
1544
|
+
const next = queryNav();
|
|
1545
|
+
if (next !== null) attachNav(next);
|
|
1546
|
+
else if (docObserver === null) observeDocument();
|
|
1547
|
+
}, 2000);
|
|
1548
|
+
}
|
|
1549
|
+
sync();
|
|
1550
|
+
}
|
|
1551
|
+
|
|
1552
|
+
function stop() {
|
|
1553
|
+
started = false;
|
|
1554
|
+
if (queued !== 0) {
|
|
1555
|
+
try {
|
|
1556
|
+
if (typeof cancelAnimationFrame === 'function') cancelAnimationFrame(queued);
|
|
1557
|
+
else if (typeof window !== 'undefined' && window !== null && typeof window.clearTimeout === 'function') window.clearTimeout(queued);
|
|
1558
|
+
} catch {
|
|
1559
|
+
/* A cancelled frame is already gone. */
|
|
1560
|
+
}
|
|
1561
|
+
queued = 0;
|
|
1562
|
+
}
|
|
1563
|
+
if (healthTimer !== null) {
|
|
1564
|
+
try {
|
|
1565
|
+
if (typeof window.clearInterval === 'function') window.clearInterval(healthTimer);
|
|
1566
|
+
} catch {
|
|
1567
|
+
/* Nothing else to clear. */
|
|
1568
|
+
}
|
|
1569
|
+
healthTimer = null;
|
|
1570
|
+
}
|
|
1571
|
+
if (navObserver !== null) {
|
|
1572
|
+
navObserver.disconnect();
|
|
1573
|
+
navObserver = null;
|
|
1574
|
+
}
|
|
1575
|
+
if (docObserver !== null) {
|
|
1576
|
+
docObserver.disconnect();
|
|
1577
|
+
docObserver = null;
|
|
1578
|
+
}
|
|
1579
|
+
if (typeof document !== 'undefined' && document !== null && typeof document.removeEventListener === 'function') {
|
|
1580
|
+
document.removeEventListener('pointerdown', onPointerDown, true);
|
|
1581
|
+
}
|
|
1582
|
+
clearVisuals();
|
|
1583
|
+
state = { order: [], groups: {} };
|
|
1584
|
+
pendingLoad = true;
|
|
1585
|
+
nav = null;
|
|
1586
|
+
}
|
|
1587
|
+
|
|
1588
|
+
return {
|
|
1589
|
+
start,
|
|
1590
|
+
stop,
|
|
1591
|
+
sync,
|
|
1592
|
+
// Exposed for the smoke test only; the plugin never calls these.
|
|
1593
|
+
__debug: {
|
|
1594
|
+
getState: () => state,
|
|
1595
|
+
setState: (next) => {
|
|
1596
|
+
state = normalizeLauncherState(next, hostTiles.filter((tile) => !tile.isMore).map((tile) => tile.key));
|
|
1597
|
+
},
|
|
1598
|
+
getNav: () => nav,
|
|
1599
|
+
},
|
|
1600
|
+
};
|
|
1601
|
+
}
|
|
1602
|
+
|
|
1603
|
+
/**
|
|
1604
|
+
* Start the sidebar launcher upgrade. The core owns all DOM work; this
|
|
1605
|
+
* adapter supplies translations, the settings flag, storage, and the
|
|
1606
|
+
* registered panel ids that key the saved order and folders.
|
|
1607
|
+
* @param {object} ctx client plugin context
|
|
1608
|
+
* @returns {object | null} the core, or null when the host has no DOM
|
|
1609
|
+
*/
|
|
1610
|
+
function installLauncher(ctx) {
|
|
1611
|
+
const listPanels = () => {
|
|
1612
|
+
try {
|
|
1613
|
+
const slots = ctx.get('slots');
|
|
1614
|
+
if (slots === undefined || slots === null || typeof slots.entriesOfSlot !== 'function') return [];
|
|
1615
|
+
const entries = slots.entriesOfSlot('sidebar.panellist');
|
|
1616
|
+
if (!Array.isArray(entries)) return [];
|
|
1617
|
+
return entries.map((entry) => {
|
|
1618
|
+
const options = entry?.options ?? {};
|
|
1619
|
+
let label;
|
|
1620
|
+
try {
|
|
1621
|
+
label = typeof options.label === 'function' ? options.label() : options.label;
|
|
1622
|
+
} catch {
|
|
1623
|
+
label = undefined;
|
|
1624
|
+
}
|
|
1625
|
+
return { id: options.id, label };
|
|
1626
|
+
});
|
|
1627
|
+
} catch {
|
|
1628
|
+
return [];
|
|
1629
|
+
}
|
|
1630
|
+
};
|
|
1631
|
+
const core = createLauncherCore({
|
|
1632
|
+
t: (key, params) => translateCurrent(key, params),
|
|
1633
|
+
format,
|
|
1634
|
+
isEnabled: () => getSettings().launcher !== false,
|
|
1635
|
+
read: () => {
|
|
1636
|
+
try {
|
|
1637
|
+
return localStorage.getItem(LAUNCHER_STORAGE_KEY);
|
|
1638
|
+
} catch {
|
|
1639
|
+
return null;
|
|
1640
|
+
}
|
|
1641
|
+
},
|
|
1642
|
+
write: (value) => {
|
|
1643
|
+
try {
|
|
1644
|
+
localStorage.setItem(LAUNCHER_STORAGE_KEY, value);
|
|
1645
|
+
} catch {
|
|
1646
|
+
/* The in-memory order still works for this page. */
|
|
1647
|
+
}
|
|
1648
|
+
},
|
|
1649
|
+
listPanels,
|
|
1650
|
+
});
|
|
1651
|
+
ctx.effect(() => {
|
|
1652
|
+
core.start();
|
|
1653
|
+
const off = subscribeSettings(() => core.sync());
|
|
1654
|
+
return () => {
|
|
1655
|
+
off();
|
|
1656
|
+
core.stop();
|
|
1657
|
+
};
|
|
1658
|
+
}, 'dsh-powerup: sidebar launcher');
|
|
1659
|
+
return core;
|
|
1660
|
+
}
|
|
1661
|
+
|
|
507
1662
|
// ------------------------------------------------------------------
|
|
508
1663
|
// Session-scoped bridge
|
|
509
1664
|
// ------------------------------------------------------------------
|
|
@@ -555,6 +1710,27 @@
|
|
|
555
1710
|
}, children);
|
|
556
1711
|
}
|
|
557
1712
|
|
|
1713
|
+
function LauncherIcon({ size = 16 }) {
|
|
1714
|
+
return h(Icon, { size },
|
|
1715
|
+
h('rect', {
|
|
1716
|
+
x: '2.6', y: '2.6', width: '4.6', height: '4.6', rx: '1.3',
|
|
1717
|
+
stroke: 'currentColor', strokeWidth: '1.2',
|
|
1718
|
+
}),
|
|
1719
|
+
h('rect', {
|
|
1720
|
+
x: '8.8', y: '2.6', width: '4.6', height: '4.6', rx: '1.3',
|
|
1721
|
+
stroke: 'currentColor', strokeWidth: '1.2',
|
|
1722
|
+
}),
|
|
1723
|
+
h('rect', {
|
|
1724
|
+
x: '2.6', y: '8.8', width: '4.6', height: '4.6', rx: '1.3',
|
|
1725
|
+
stroke: 'currentColor', strokeWidth: '1.2',
|
|
1726
|
+
}),
|
|
1727
|
+
h('path', {
|
|
1728
|
+
d: 'M9.4 11.1h3.4M11.1 9.4v3.4',
|
|
1729
|
+
stroke: 'currentColor', strokeWidth: '1.2', strokeLinecap: 'round',
|
|
1730
|
+
}),
|
|
1731
|
+
);
|
|
1732
|
+
}
|
|
1733
|
+
|
|
558
1734
|
function PowerUpLineIcon({ size = 16 }) {
|
|
559
1735
|
return h(Icon, { size },
|
|
560
1736
|
h('path', {
|
|
@@ -688,6 +1864,16 @@
|
|
|
688
1864
|
);
|
|
689
1865
|
}
|
|
690
1866
|
|
|
1867
|
+
function TagIcon({ size = 16 }) {
|
|
1868
|
+
return h(Icon, { size },
|
|
1869
|
+
h('path', {
|
|
1870
|
+
d: 'M2.9 7.2V3.6a.7.7 0 0 1 .7-.7h3.6a.7.7 0 0 1 .5.2l5.4 5.4a.9.9 0 0 1 0 1.3l-2.9 2.9a.9.9 0 0 1-1.3 0L3.1 7.7a.7.7 0 0 1-.2-.5Z',
|
|
1871
|
+
stroke: 'currentColor', strokeWidth: '1.25', strokeLinejoin: 'round',
|
|
1872
|
+
}),
|
|
1873
|
+
h('circle', { cx: '5.5', cy: '5.5', r: '.85', fill: 'currentColor' }),
|
|
1874
|
+
);
|
|
1875
|
+
}
|
|
1876
|
+
|
|
691
1877
|
function LayoutIcon({ size = 16 }) {
|
|
692
1878
|
return h(Icon, { size },
|
|
693
1879
|
h('rect', {
|
|
@@ -775,6 +1961,64 @@
|
|
|
775
1961
|
// ------------------------------------------------------------------
|
|
776
1962
|
// CSS — host tokens only (except the brand SVG artwork)
|
|
777
1963
|
// ------------------------------------------------------------------
|
|
1964
|
+
/**
|
|
1965
|
+
* Sidebar launcher styles. Every rule is scoped under the marker class we
|
|
1966
|
+
* add to the host panel list, so the untouched host rules still describe
|
|
1967
|
+
* the collapsed 56px rail (we remove `.dsh-powerup-launcher-wide` there).
|
|
1968
|
+
* The grid uses `auto-fill` + `minmax`, so the column count follows the
|
|
1969
|
+
* sidebar width instead of a fixed number.
|
|
1970
|
+
*/
|
|
1971
|
+
const LAUNCHER_CSS = `
|
|
1972
|
+
nav.dsh-powerup-launcher.dsh-powerup-launcher-wide{position:relative;display:grid!important;grid-template-columns:repeat(auto-fill,minmax(58px,1fr));grid-auto-rows:min-content;gap:2px;align-content:start;align-items:stretch;margin:0 0 10px;padding:2px 0}
|
|
1973
|
+
nav.dsh-powerup-launcher.dsh-powerup-launcher-wide>button,nav.dsh-powerup-launcher.dsh-powerup-launcher-wide>[data-powerup-more]>button,.dsh-powerup-folder{box-sizing:border-box;display:flex;flex-direction:column;align-items:center;justify-content:center;gap:3px;width:auto;min-width:0;height:auto;min-height:52px;margin:0;padding:6px 2px 5px;border:0;border-radius:var(--dsw-radius-md,8px);background:transparent;color:var(--dsw-alias-label-primary);font:inherit;font-size:11px;line-height:14px;text-align:center;cursor:pointer;user-select:none;-webkit-user-select:none;transition:background .12s ease,color .12s ease,transform .12s ease}
|
|
1974
|
+
nav.dsh-powerup-launcher.dsh-powerup-launcher-wide>button:hover,nav.dsh-powerup-launcher.dsh-powerup-launcher-wide>[data-powerup-more]>button:hover,.dsh-powerup-folder:hover{background:var(--dsw-alias-interactive-bg-hover)}
|
|
1975
|
+
nav.dsh-powerup-launcher.dsh-powerup-launcher-wide>button:active,nav.dsh-powerup-launcher.dsh-powerup-launcher-wide>[data-powerup-more]>button:active,.dsh-powerup-folder:active{transform:scale(.96)}
|
|
1976
|
+
nav.dsh-powerup-launcher.dsh-powerup-launcher-wide>button[class*="panelActive"],nav.dsh-powerup-launcher.dsh-powerup-launcher-wide>[data-powerup-more]>button[aria-expanded=true]{background:var(--dsw-alias-interactive-bg-hover)}
|
|
1977
|
+
nav.dsh-powerup-launcher.dsh-powerup-launcher-wide>[data-powerup-more]{display:flex!important;flex-direction:column;min-width:0;margin:0}
|
|
1978
|
+
nav.dsh-powerup-launcher.dsh-powerup-launcher-wide [class*="panelGlyph"]{display:inline-flex;align-items:center;justify-content:center;width:24px;height:24px;flex:none}
|
|
1979
|
+
nav.dsh-powerup-launcher.dsh-powerup-launcher-wide [class*="panelGlyph"] svg{width:20px;height:20px}
|
|
1980
|
+
nav.dsh-powerup-launcher.dsh-powerup-launcher-wide [class*="panelTitle"]{display:block;width:100%;max-width:100%;color:var(--dsw-alias-label-secondary);font-size:11px;line-height:14px;font-weight:400;text-align:center;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
|
|
1981
|
+
nav.dsh-powerup-launcher.dsh-powerup-launcher-wide>button:hover [class*="panelTitle"]{color:var(--dsw-alias-label-primary)}
|
|
1982
|
+
.dsh-powerup-folder{position:relative;list-style:none;flex:none}
|
|
1983
|
+
.dsh-powerup-folder-stack{display:grid;grid-template-columns:repeat(2,1fr);grid-template-rows:repeat(2,1fr);gap:1px;width:24px;height:24px;padding:2px;box-sizing:border-box;border-radius:6px;background:color-mix(in srgb,var(--dsw-alias-label-primary) 9%,transparent);flex:none}
|
|
1984
|
+
.dsh-powerup-folder-mini{display:inline-flex;align-items:center;justify-content:center;min-width:0;min-height:0;overflow:hidden;color:var(--dsw-alias-label-primary);opacity:.85}
|
|
1985
|
+
.dsh-powerup-folder-mini svg{width:9px;height:9px}
|
|
1986
|
+
.dsh-powerup-folder-stack.is-single{grid-template-columns:1fr;grid-template-rows:1fr}
|
|
1987
|
+
.dsh-powerup-folder-stack.is-single .dsh-powerup-folder-mini svg{width:14px;height:14px}
|
|
1988
|
+
.dsh-powerup-folder-name{display:block;width:100%;max-width:100%;color:var(--dsw-alias-label-secondary);font-size:11px;line-height:14px;text-align:center;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
|
|
1989
|
+
.dsh-powerup-folder.is-active .dsh-powerup-folder-name{color:var(--dsw-alias-label-primary)}
|
|
1990
|
+
.dsh-powerup-folder.is-active .dsh-powerup-folder-stack{background:color-mix(in srgb,var(--dsw-alias-state-business-primary) 22%,transparent)}
|
|
1991
|
+
.dsh-powerup-dragging{opacity:.32}
|
|
1992
|
+
.dsh-powerup-merge-target{background:color-mix(in srgb,var(--dsw-alias-state-business-primary) 17%,transparent)!important;box-shadow:inset 0 0 0 1px var(--dsw-alias-state-business-primary)}
|
|
1993
|
+
.dsh-powerup-drop-line{position:absolute;z-index:6;display:none;width:2px;border-radius:999px;background:var(--dsw-alias-state-business-primary);box-shadow:0 0 0 1px color-mix(in srgb,var(--dsw-alias-state-business-primary) 26%,transparent);pointer-events:none}
|
|
1994
|
+
.dsh-powerup-drag-ghost{position:fixed;z-index:1800;box-sizing:border-box;display:flex;flex-direction:column;align-items:center;justify-content:center;gap:3px;padding:6px 2px 5px;border-radius:var(--dsw-radius-md,8px);background:var(--dsw-alias-bg-layer-2);box-shadow:var(--dsw-elevation-prominent);color:var(--dsw-alias-label-primary);font-size:11px;line-height:14px;pointer-events:none;opacity:.96;transform:scale(1.05);transition:opacity .1s ease}
|
|
1995
|
+
.dsh-powerup-drag-ghost [class*="panelGlyph"]{display:inline-flex;align-items:center;justify-content:center;width:24px;height:24px;flex:none}
|
|
1996
|
+
.dsh-powerup-drag-ghost [class*="panelGlyph"] svg{width:20px;height:20px}
|
|
1997
|
+
.dsh-powerup-drag-ghost [class*="panelTitle"]{display:block;width:100%;max-width:100%;color:var(--dsw-alias-label-secondary);font-size:11px;line-height:14px;text-align:center;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
|
|
1998
|
+
.dsh-powerup-folder-pop{position:fixed;z-index:1800;box-sizing:border-box;display:flex;flex-direction:column;gap:6px;width:max-content;min-width:196px;max-width:min(440px,calc(100vw - 24px));max-height:min(72vh,440px);padding:8px;border:.5px solid var(--dsw-alias-border-l2);border-radius:var(--dsw-radius-lg,10px);background:var(--dsw-alias-bg-layer-2);box-shadow:var(--dsw-elevation-prominent);color:var(--dsw-alias-label-primary);font-size:12px;line-height:16px;opacity:0;transform:scale(.92);transition:opacity .13s ease,transform .17s cubic-bezier(.22,.9,.3,1.06)}
|
|
1999
|
+
.dsh-powerup-folder-pop.is-open{opacity:1;transform:scale(1)}
|
|
2000
|
+
.dsh-powerup-folder-pop-head{display:flex;align-items:center;gap:6px;min-width:0;padding:0 2px}
|
|
2001
|
+
.dsh-powerup-folder-pop-title{flex:1 1 auto;min-width:0;padding:2px 5px;border:0;border-radius:var(--dsw-radius-sm,6px);background:transparent;color:var(--dsw-alias-label-primary);font:inherit;font-size:12px;line-height:16px;font-weight:500;text-align:left;cursor:text;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
|
|
2002
|
+
.dsh-powerup-folder-pop-title:hover{background:var(--dsw-alias-interactive-bg-hover)}
|
|
2003
|
+
.dsh-powerup-folder-pop-input{flex:1 1 auto;min-width:0;height:22px;padding:0 5px;border:.5px solid var(--dsw-alias-state-business-primary);border-radius:var(--dsw-radius-sm,6px);background:var(--dsw-alias-bg-layer-3);color:var(--dsw-alias-label-primary);font:inherit;font-size:12px;line-height:20px;outline:none}
|
|
2004
|
+
.dsh-powerup-folder-pop-count{flex:none;color:var(--dsw-alias-label-tertiary);font-size:11px;white-space:nowrap}
|
|
2005
|
+
.dsh-powerup-folder-pop-action{flex:none;padding:2px 6px;border:0;border-radius:var(--dsw-radius-sm,6px);background:transparent;color:var(--dsw-alias-label-tertiary);font:inherit;font-size:11px;line-height:16px;cursor:pointer;white-space:nowrap}
|
|
2006
|
+
.dsh-powerup-folder-pop-action:hover{background:var(--dsw-alias-interactive-bg-hover);color:var(--dsw-alias-label-primary)}
|
|
2007
|
+
.dsh-powerup-folder-grid{display:grid;grid-template-columns:repeat(auto-fill,minmax(76px,1fr));gap:2px;align-content:start;max-height:min(60vh,340px);overflow:auto;padding:2px}
|
|
2008
|
+
.dsh-powerup-folder-item{position:relative;box-sizing:border-box;display:flex;flex-direction:column;align-items:center;justify-content:center;gap:3px;min-width:0;min-height:54px;padding:6px 2px 5px;border:0;border-radius:var(--dsw-radius-md,8px);background:transparent;color:var(--dsw-alias-label-primary);font:inherit;font-size:11px;line-height:14px;cursor:pointer;transition:background .12s ease}
|
|
2009
|
+
.dsh-powerup-folder-item:hover{background:var(--dsw-alias-interactive-bg-hover)}
|
|
2010
|
+
.dsh-powerup-folder-item:focus{outline:none}
|
|
2011
|
+
.dsh-powerup-folder-item:focus-visible{outline:var(--dsw-focus-ring-width,2px) solid var(--dsw-focus-ring-color,var(--dsw-alias-state-business-primary));outline-offset:-1px}
|
|
2012
|
+
.dsh-powerup-folder-item-glyph{display:inline-flex;align-items:center;justify-content:center;width:24px;height:24px;flex:none;color:var(--dsw-alias-label-secondary)}
|
|
2013
|
+
.dsh-powerup-folder-item-glyph svg{width:20px;height:20px}
|
|
2014
|
+
.dsh-powerup-folder-item-label{display:block;width:100%;max-width:100%;color:var(--dsw-alias-label-secondary);text-align:center;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
|
|
2015
|
+
.dsh-powerup-folder-item:hover .dsh-powerup-folder-item-label{color:var(--dsw-alias-label-primary)}
|
|
2016
|
+
.dsh-powerup-folder-item-remove{position:absolute;top:1px;right:2px;display:inline-flex;align-items:center;justify-content:center;width:15px;height:15px;padding:0;border:0;border-radius:50%;background:var(--dsw-alias-bg-layer-2);color:var(--dsw-alias-label-tertiary);font:inherit;font-size:11px;line-height:15px;cursor:pointer;opacity:0;transition:opacity .12s ease}
|
|
2017
|
+
.dsh-powerup-folder-item:hover .dsh-powerup-folder-item-remove,.dsh-powerup-folder-item-remove:focus-visible{opacity:1}
|
|
2018
|
+
.dsh-powerup-folder-item-remove:hover{color:var(--dsw-alias-label-primary)}
|
|
2019
|
+
@media (prefers-reduced-motion:reduce){nav.dsh-powerup-launcher.dsh-powerup-launcher-wide>button,nav.dsh-powerup-launcher.dsh-powerup-launcher-wide>[data-powerup-more]>button,.dsh-powerup-folder,.dsh-powerup-folder-pop,.dsh-powerup-drag-ghost,.dsh-powerup-drop-line{transition:none}}
|
|
2020
|
+
`;
|
|
2021
|
+
|
|
778
2022
|
const CSS = `
|
|
779
2023
|
.dsh-powerup-page{box-sizing:border-box;height:100%;overflow-y:auto;padding:28px 24px 52px;color:var(--dsw-alias-label-primary);font-size:13px;line-height:1.55;--pu-accent:var(--dsw-alias-brand-primary)}
|
|
780
2024
|
.dsh-powerup-page *{box-sizing:border-box}
|
|
@@ -976,7 +2220,7 @@
|
|
|
976
2220
|
try {
|
|
977
2221
|
const style = document.createElement('style');
|
|
978
2222
|
style.setAttribute('data-dsh-powerup', '');
|
|
979
|
-
style.textContent = CSS;
|
|
2223
|
+
style.textContent = CSS + '\n' + LAUNCHER_CSS;
|
|
980
2224
|
document.head.appendChild(style);
|
|
981
2225
|
ctx.effect(() => () => style.remove(), 'dsh-powerup: styles');
|
|
982
2226
|
} catch (error) {
|
|
@@ -1029,6 +2273,54 @@
|
|
|
1029
2273
|
}
|
|
1030
2274
|
}
|
|
1031
2275
|
|
|
2276
|
+
/**
|
|
2277
|
+
* The trajectory record id behind a ledger row. The DOM attribute is the
|
|
2278
|
+
* URI-encoded record id; a folded summary row appends a raw
|
|
2279
|
+
* `\0summary\0<kind>` suffix that is not part of the record identity.
|
|
2280
|
+
*/
|
|
2281
|
+
function rowRecordId(row) {
|
|
2282
|
+
const raw = row.getAttribute('data-trajectory-row-key');
|
|
2283
|
+
if (typeof raw !== 'string' || raw === '') return '';
|
|
2284
|
+
let decoded = raw;
|
|
2285
|
+
try {
|
|
2286
|
+
decoded = decodeURIComponent(raw);
|
|
2287
|
+
} catch {
|
|
2288
|
+
/* Keep the literal attribute. */
|
|
2289
|
+
}
|
|
2290
|
+
const summaryCut = decoded.indexOf('\u0000summary\u0000');
|
|
2291
|
+
return summaryCut === -1 ? decoded : decoded.slice(0, summaryCut);
|
|
2292
|
+
}
|
|
2293
|
+
|
|
2294
|
+
/**
|
|
2295
|
+
* The step id a step reference carries: assistant rows resolve to their
|
|
2296
|
+
* turn/step, tool rows to their call id, raw-event rows to their seq.
|
|
2297
|
+
* Synthetic index rows have no stable identity and yield `''`.
|
|
2298
|
+
*/
|
|
2299
|
+
function rowStepId(row) {
|
|
2300
|
+
const recordId = rowRecordId(row);
|
|
2301
|
+
if (recordId === '') return '';
|
|
2302
|
+
const parts = recordId.split('\u0000');
|
|
2303
|
+
if (parts.length < 3) return '';
|
|
2304
|
+
if (parts[0] === 'assistant') {
|
|
2305
|
+
// `assistant\0T\0S` today; `assistant\0turn\0T\0step\0S` in older logs.
|
|
2306
|
+
const turn = Number(parts[1] === 'turn' ? parts[2] : parts[1]);
|
|
2307
|
+
const step = Number(parts[1] === 'turn' ? parts[4] : parts[2]);
|
|
2308
|
+
if (Number.isInteger(turn) && Number.isInteger(step) && turn >= 0 && step >= 0) {
|
|
2309
|
+
return `turn.${turn}.step.${step}`;
|
|
2310
|
+
}
|
|
2311
|
+
return '';
|
|
2312
|
+
}
|
|
2313
|
+
if (parts[1] === 'call' && parts[2] !== '') return `call.${encodeURIComponent(parts[2])}`;
|
|
2314
|
+
if (parts[1] === 'seq' && Number.isInteger(Number(parts[2]))) return `seq.${Number(parts[2])}`;
|
|
2315
|
+
return '';
|
|
2316
|
+
}
|
|
2317
|
+
|
|
2318
|
+
/** The reference the Host step reader resolves: session id + step id. */
|
|
2319
|
+
function rowStepReference(sessionId, stepId) {
|
|
2320
|
+
if (typeof sessionId !== 'string' || sessionId === '' || stepId === '') return '';
|
|
2321
|
+
return `${STEP_REF_PREFIX}${sessionId}/${stepId}`;
|
|
2322
|
+
}
|
|
2323
|
+
|
|
1032
2324
|
/** The full visible content of one ledger row. */
|
|
1033
2325
|
function rowText(row) {
|
|
1034
2326
|
const cell = row.querySelector('td:nth-child(2)');
|
|
@@ -3615,6 +4907,8 @@
|
|
|
3615
4907
|
const quote = markdownQuote(row, t);
|
|
3616
4908
|
const hasText = text !== '';
|
|
3617
4909
|
const hasSession = typeof sessionId === 'string' && sessionId !== '';
|
|
4910
|
+
const stepId = rowStepId(row);
|
|
4911
|
+
const stepReference = rowStepReference(hasSession ? sessionId : '', stepId);
|
|
3618
4912
|
return [
|
|
3619
4913
|
{
|
|
3620
4914
|
id: 'copy',
|
|
@@ -3690,6 +4984,21 @@
|
|
|
3690
4984
|
await forkAt(ctx, forkSeq, sessionId, notify, t);
|
|
3691
4985
|
},
|
|
3692
4986
|
},
|
|
4987
|
+
{
|
|
4988
|
+
id: 'stepref',
|
|
4989
|
+
label: t('menu.stepRef'),
|
|
4990
|
+
icon: h(TagIcon, { size: 15 }),
|
|
4991
|
+
disabled: stepReference === '',
|
|
4992
|
+
title: stepReference === '' ? t('menu.noStepRef') : undefined,
|
|
4993
|
+
run: async () => {
|
|
4994
|
+
if (stepReference === '') {
|
|
4995
|
+
notify(t('menu.noStepRef'));
|
|
4996
|
+
return;
|
|
4997
|
+
}
|
|
4998
|
+
await copyText(stepReference);
|
|
4999
|
+
notify(t('toast.stepRefCopied'));
|
|
5000
|
+
},
|
|
5001
|
+
},
|
|
3693
5002
|
{
|
|
3694
5003
|
id: 'session',
|
|
3695
5004
|
label: t('menu.session'),
|
|
@@ -3793,6 +5102,7 @@
|
|
|
3793
5102
|
{ id: 'insert', icon: ComposerIcon, name: t('action.insert'), hint: t('action.insertHint') },
|
|
3794
5103
|
{ id: 'inspect', icon: InspectIcon, name: t('action.inspect'), hint: t('action.inspectHint') },
|
|
3795
5104
|
{ id: 'fork', icon: ForkIcon, name: t('action.fork'), hint: t('action.forkHint') },
|
|
5105
|
+
{ id: 'stepref', icon: TagIcon, name: t('action.stepRef'), hint: t('action.stepRefHint') },
|
|
3796
5106
|
{ id: 'export', icon: ExportIcon, name: t('action.export'), hint: t('action.exportHint') },
|
|
3797
5107
|
];
|
|
3798
5108
|
/** One label/description row with a host-styled switch. */
|
|
@@ -3858,6 +5168,18 @@
|
|
|
3858
5168
|
),
|
|
3859
5169
|
),
|
|
3860
5170
|
),
|
|
5171
|
+
h('section', { className: 'dsh-powerup-card' },
|
|
5172
|
+
h('div', { className: 'dsh-powerup-card-head' },
|
|
5173
|
+
h('div', { className: 'dsh-powerup-card-icon' }, h(LauncherIcon, { size: 18 })),
|
|
5174
|
+
h('div', { className: 'dsh-powerup-card-copy' },
|
|
5175
|
+
h('h2', null, t('page.launcherTitle')),
|
|
5176
|
+
h('p', null, t('page.launcherDesc')),
|
|
5177
|
+
),
|
|
5178
|
+
),
|
|
5179
|
+
h('div', { className: 'dsh-powerup-settings' },
|
|
5180
|
+
settingRow('launcher', settings.launcher !== false, t('page.launcherToggle'), t('page.launcherToggleHint')),
|
|
5181
|
+
),
|
|
5182
|
+
),
|
|
3861
5183
|
h('section', { className: 'dsh-powerup-card' },
|
|
3862
5184
|
h('div', { className: 'dsh-powerup-card-head' },
|
|
3863
5185
|
h('div', { className: 'dsh-powerup-card-icon' }, h(QuickIcon, { size: 18 })),
|
|
@@ -3947,6 +5269,7 @@
|
|
|
3947
5269
|
function apply(ctx) {
|
|
3948
5270
|
bindLocale(ctx);
|
|
3949
5271
|
installStyles(ctx);
|
|
5272
|
+
installLauncher(ctx);
|
|
3950
5273
|
|
|
3951
5274
|
const slots = ctx.get('slots');
|
|
3952
5275
|
if (slots === undefined || typeof slots.inject !== 'function' || typeof slots.register !== 'function') {
|
|
@@ -4038,7 +5361,13 @@
|
|
|
4038
5361
|
__test: {
|
|
4039
5362
|
DICT,
|
|
4040
5363
|
CSS,
|
|
5364
|
+
LAUNCHER_CSS,
|
|
5365
|
+
LAUNCHER_STORAGE_KEY,
|
|
5366
|
+
normalizeLauncherState,
|
|
5367
|
+
createLauncherCore,
|
|
5368
|
+
installLauncher,
|
|
4041
5369
|
PowerUpLineIcon,
|
|
5370
|
+
LauncherIcon,
|
|
4042
5371
|
UpdateIcon,
|
|
4043
5372
|
QuickIcon,
|
|
4044
5373
|
PowerUpBridge,
|
|
@@ -4054,6 +5383,9 @@
|
|
|
4054
5383
|
updateButtonLabel,
|
|
4055
5384
|
popoverPlacement,
|
|
4056
5385
|
rowKeyParts,
|
|
5386
|
+
rowRecordId,
|
|
5387
|
+
rowStepId,
|
|
5388
|
+
rowStepReference,
|
|
4057
5389
|
resolveForkSeq,
|
|
4058
5390
|
markdownQuote,
|
|
4059
5391
|
jsonSafe,
|