dsh-rss 0.7.1 → 0.9.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/lib/client.js CHANGED
@@ -1,126 +1,680 @@
1
- // This is the browser source. tsc does not rebuild it; check with node --check.
2
- window.__ModuleLoader__.load({ id: 'dsh-rss', factory: require => {
3
- const React = require('react');
4
- var __FR_KEY = "dsh-first-run:dsh-rss:v1";
5
- var __FR_TITLE = "RSS 订阅 · 首次使用(3 步)";
6
- var __FR_STEPS = [{"title":"先加一个源","body":"粘贴 RSS/Atom 地址,插件会先抓一次验证可用,再存进列表。"},{"title":"增量比全量好用","body":"抓取时选「增量」,只返回上次之后的新条目,适合定时巡检。"},{"title":"跨源搜索","body":"在对话里直接问关键词最近有没有更新,比逐个源翻快得多。","tryIt":"搜一下最近一周提到 DeepSeek 的订阅条目"}];
1
+ // Generated: shared optional update controls; edit the original client templates.
2
+ (function(){
3
+ /* DSH workbench UI v1. MIT. Canonical source: dsh-suite/ui/workbench-ui.js.
4
+ * Vendored into each plugin: no Suite or extra runtime dependency is required.
5
+ * Styles are scoped to .dshw and never replace the host chrome or theme.
6
+ */
7
+ function createWorkbenchUI(React) {
8
+ const h = React.createElement;
9
+ const { useEffect, useId, useRef } = React;
10
+ const cx = (...values) => values.filter(Boolean).join(' ');
11
+ const paths = {
12
+ book: ['M4 4h6a3 3 0 0 1 2 2v15a4 4 0 0 0-4-2H4z', 'M20 4h-6a3 3 0 0 0-2 2v15a4 4 0 0 1 4-2h4z'],
13
+ calendar: ['M5 5h14a2 2 0 0 1 2 2v13H3V7a2 2 0 0 1 2-2Z', 'M7 3v4M17 3v4M3 10h18'],
14
+ mail: ['M3 5h18v14H3z', 'm3 6 9 7 9-7'],
15
+ rss: ['M4 11a9 9 0 0 1 9 9M4 4a16 16 0 0 1 16 16', 'M4 19h.01'],
16
+ slides: ['M3 4h18v13H3z', 'M12 17v4M8 21h8'],
17
+ shield: ['m12 3 8 3v6c0 4-4 7-8 9-4-2-8-5-8-9V6z', 'm8 12 3 3 5-6'],
18
+ layers: ['M5 3h16v16H5z', 'M2 7v15h15'],
19
+ play: ['m9 6 9 6-9 6Z'],
20
+ video: ['M3 5h12v14H3z', 'm15 10 6-4v12l-6-4'],
21
+ search: ['M10.5 18a7.5 7.5 0 1 0 0-15 7.5 7.5 0 0 0 0 15Z', 'm16 16 5 5'],
22
+ plus: ['M12 5v14M5 12h14'],
23
+ refresh: ['M20 7a9 9 0 1 0 1 8', 'M20 2v5h-5'],
24
+ settings: ['m9 3-.7 2.4-2 .9L4 5.8 2.5 8.4l1.7 1.8v2.3L2.5 14 4 17l2.5-.4 1.9 1L9 20h3l.8-2.4 2-1 2.5.4 1.5-2.7-1.7-1.9v-2.2l1.7-1.8-1.5-2.6-2.5.4-2-1L12 3Z', 'M14 11.5a3.5 3.5 0 1 1-7 0 3.5 3.5 0 0 1 7 0Z'],
25
+ close: ['m6 6 12 12M18 6 6 18'],
26
+ left: ['m14 5-7 7 7 7'],
27
+ right: ['m10 5 7 7-7 7'],
28
+ down: ['m5 9 7 7 7-7'],
29
+ filter: ['M4 5h16M7 12h10M10 19h4'],
30
+ download: ['M12 3v12m-5-5 5 5 5-5', 'M4 16v5h16v-5'],
31
+ upload: ['M12 16V4m-5 5 5-5 5 5', 'M4 16v5h16v-5'],
32
+ copy: ['M8 8h13v13H8z', 'M16 8V3H3v13h5'],
33
+ external: ['M14 3h7v7m0-7L10 14', 'M10 3H3v18h18v-7'],
34
+ file: ['M4 3h10l6 6v12H4z', 'M14 3v6h6M8 13h8M8 17h6'],
35
+ folder: ['M3 5h7l2 3h9v12H3z'],
36
+ edit: ['m15 4 5 5-10 10-6 1 1-6Z', 'm13 6 5 5'],
37
+ trash: ['M3 6h18M9 6V3h6v3M5 6l1 15h12l1-15M10 10v7M14 10v7'],
38
+ more: ['M5 12h.01M12 12h.01M19 12h.01'],
39
+ info: ['M12 22a10 10 0 1 0 0-20 10 10 0 0 0 0 20Z', 'M12 11v6M12 7h.01'],
40
+ check: ['m5 12 4 4L19 6'],
41
+ quote: ['M4 12h6v7H3v-7c0-4 2-6 5-7M15 12h6v7h-7v-7c0-4 2-6 5-7'],
42
+ star: ['m12 3 2.8 5.7 6.2.9-4.5 4.4 1.1 6.2-5.6-3-5.6 3 1.1-6.2L3 9.6l6.2-.9Z'],
43
+ reply: ['m9 5-7 7 7 7v-5h6c3 0 5 2 6 5 0-8-4-11-12-11Z'],
44
+ link: ['m10 13 4-4M8 16l-2 2a4 4 0 0 1-6-6l4-4a4 4 0 0 1 6 0', 'm14 8 2-2a4 4 0 0 1 6 6l-4 4a4 4 0 0 1-6 0'],
45
+ };
46
+ function Icon({ name = 'file', size = 20, ...props }) {
47
+ return h('svg', { width: size, height: size, viewBox: '0 0 24 24', fill: 'none', stroke: 'currentColor', strokeWidth: 1.75, strokeLinecap: 'round', strokeLinejoin: 'round', 'aria-hidden': true, focusable: false, ...props },
48
+ (paths[name] || paths.file).map((d, index) => h('path', { key: index, d })));
49
+ }
50
+ function Button({ children, icon, variant, className, ...props }) {
51
+ return h('button', { type: 'button', ...props, className: cx('w-button', variant && 'w-' + variant, className) }, icon ? h(Icon, { name: icon, size: 18 }) : null, children);
52
+ }
53
+ function IconButton({ label, icon, ...props }) {
54
+ return h(Button, { ...props, icon, className: cx('w-icon-button', props.className), 'aria-label': label, title: label });
55
+ }
56
+ function Page({ title, subtitle, actions, children, workbench = false, className, rootRef, ...props }) {
57
+ return h('section', { ...props, ref: rootRef, className: cx('dshw', 'w-page', className), 'data-main': workbench ? 'true' : 'false' },
58
+ h('style', null, styles),
59
+ h('header', { className: 'w-page-header' }, h('div', { className: 'w-heading' }, h('h1', null, title), subtitle ? h('p', { className: 'w-subtitle' }, subtitle) : null), actions ? h('div', { className: 'w-header-actions' }, actions) : null),
60
+ h('div', { className: 'w-body' }, children));
61
+ }
62
+ function Tabs({ items, value, onChange, label, children }) {
63
+ const id = useId();
64
+ const active = items.some(item => item.id === value) ? value : items[0]?.id;
65
+ function keys(event, index) {
66
+ if (!['ArrowLeft', 'ArrowRight', 'Home', 'End'].includes(event.key)) return;
67
+ event.preventDefault();
68
+ const next = event.key === 'Home' ? 0 : event.key === 'End' ? items.length - 1 : (index + (event.key === 'ArrowRight' ? 1 : -1) + items.length) % items.length;
69
+ const node = event.currentTarget.parentElement?.querySelectorAll('[role=tab]')[next];
70
+ if (node) { onChange(items[next].id); node.focus(); }
71
+ }
72
+ return h('div', { className: 'w-tabs-layout' },
73
+ h('div', { className: 'w-tabs', role: 'tablist', 'aria-label': label }, items.map((item, index) => h('button', {
74
+ type: 'button', role: 'tab', key: item.id, id: id + '-' + item.id, 'aria-controls': id + '-panel', 'aria-selected': active === item.id, tabIndex: active === item.id ? 0 : -1,
75
+ onClick: () => onChange(item.id), onKeyDown: event => keys(event, index),
76
+ }, item.label, item.count !== undefined ? h('span', { className: 'w-count' }, item.count) : null))),
77
+ h('div', { className: 'w-tab-panel', id: id + '-panel', role: 'tabpanel', 'aria-labelledby': id + '-' + active }, children));
78
+ }
79
+ function Status({ children, tone = 'info', className }) {
80
+ if (!children) return null;
81
+ return h('div', { className: cx('w-status', 'w-status-' + tone, className), role: tone === 'error' ? 'alert' : 'status', 'aria-live': tone === 'error' ? 'assertive' : 'polite' }, h(Icon, { name: tone === 'success' ? 'check' : 'info', size: 18 }), h('div', null, children));
82
+ }
83
+ function Empty({ title, children, action, icon = 'file' }) {
84
+ return h('div', { className: 'w-empty' }, h(Icon, { name: icon, size: 32 }), h('h2', null, title), children ? h('div', { className: 'w-muted' }, children) : null, action ? h('div', { className: 'w-toolbar' }, action) : null);
85
+ }
86
+ function Split({ list, detail, selected, onBack, backLabel, className, listWidth = 360 }) {
87
+ const ref = useRef(null);
88
+ useEffect(() => {
89
+ if (!selected || !ref.current || ref.current.clientWidth > 760) return;
90
+ const heading = ref.current.querySelector('.w-detail h2');
91
+ if (heading) { heading.tabIndex = -1; heading.focus({ preventScroll: true }); }
92
+ }, [selected]);
93
+ return h('div', { ref, className: cx('w-split', className), 'data-selected': selected ? 'true' : 'false', style: { '--w-list-width': listWidth + 'px' } },
94
+ h('div', { className: 'w-master' }, list),
95
+ h('div', { className: 'w-detail' }, selected ? h(Button, { className: 'w-back', icon: 'left', variant: 'ghost', onClick: onBack }, backLabel) : null, detail));
96
+ }
97
+ function Row({ title, meta, description, active, onClick, children, status, className, disabled }) {
98
+ return h('div', { className: cx('w-row', active && 'w-selected', className) },
99
+ children ? h('div', { className: 'w-row-select' }, children) : null,
100
+ h('button', { type: 'button', className: 'w-row-button', onClick, disabled, 'aria-pressed': !!active },
101
+ h('span', { className: 'w-row-head' }, h('strong', null, title), status ? h('span', { className: 'w-tag' }, status) : null),
102
+ meta ? h('span', { className: 'w-row-meta' }, meta) : null,
103
+ description ? h('span', { className: 'w-row-description' }, description) : null));
104
+ }
105
+ function Search({ label, value, onChange, ...props }) {
106
+ const id = useId();
107
+ return h('div', { className: 'w-search' }, h(Icon, { name: 'search', size: 18 }), h('input', { type: 'search', id, 'aria-label': label, placeholder: label, value, onChange, ...props }));
108
+ }
109
+ function Switch({ label, checked, onChange, disabled }) {
110
+ return h('label', { className: 'w-switch-label' }, h('span', null, label), h('input', { type: 'checkbox', role: 'switch', checked, disabled, onChange, 'aria-label': label }), h('span', { className: 'w-switch-track', 'aria-hidden': true }));
111
+ }
112
+ function Dialog({ title, children, onClose, closeLabel, className, busy = false }) {
113
+ const id = useId(), panel = useRef(null);
114
+ useEffect(() => {
115
+ const previous = document.activeElement;
116
+ panel.current?.querySelector('button:not(:disabled), input:not(:disabled), select:not(:disabled), textarea:not(:disabled), [tabindex="0"]')?.focus();
117
+ return () => { if (previous?.isConnected) previous.focus({ preventScroll: true }); };
118
+ }, []);
119
+ function keydown(event) {
120
+ if (event.key === 'Escape' && !event.isComposing) { event.preventDefault(); event.stopPropagation(); if (!busy) onClose(); return; }
121
+ if (event.key !== 'Tab') return;
122
+ const controls = [...panel.current.querySelectorAll('button:not(:disabled), input:not(:disabled), select:not(:disabled), textarea:not(:disabled), a[href], [tabindex="0"]')].filter(node => node.getClientRects().length);
123
+ const first = controls[0], last = controls.at(-1);
124
+ if (!controls.length) { event.preventDefault(); panel.current.focus(); }
125
+ else if (event.shiftKey && document.activeElement === first) { event.preventDefault(); last.focus(); }
126
+ else if (!event.shiftKey && document.activeElement === last) { event.preventDefault(); first.focus(); }
127
+ }
128
+ return h('div', { className: 'w-overlay', onClick: event => { if (!busy && event.target === event.currentTarget) onClose(); } },
129
+ h('section', { ref: panel, className: cx('w-dialog', className), role: 'dialog', 'aria-modal': true, 'aria-labelledby': id, tabIndex: -1, onKeyDown: keydown },
130
+ h('header', { className: 'w-dialog-header' }, h('h2', { id }, title), h(IconButton, { icon: 'close', label: closeLabel, disabled: busy, onClick: onClose })), h('div', { className: 'w-dialog-body' }, children)));
131
+ }
132
+ function register(ctx, { id, label, icon, component, inject, order = 50 }) {
133
+ // The two slots are optional. Existing settings and manual tools still load
134
+ // in hosts without a workbench, while RC.3 owns navigation/pinning itself.
135
+ ctx.slots.inject('main', () => ctx.slots.register({ name: 'main', key: id, inject: () => ({ ...(inject?.() || {}), workbench: true }) }, component));
136
+ ctx.slots.inject('sidebar.panellist', () => ctx.slots.register({ name: 'sidebar.panellist', id, order, label }, function WorkbenchIcon({ size }) { return h(Icon, { name: icon, size }); }));
137
+ }
138
+ const styles = `
139
+ .dshw{--w-bg:var(--dsw-alias-bg-layer-1,#fff);--w-soft:var(--dsw-alias-bg-layer-2,#f7f8fa);--w-text:var(--dsw-alias-label-primary,#18202c);--w-muted:var(--dsw-alias-label-secondary,#667085);--w-border:var(--dsw-alias-border-l3,#e7e9ef);--w-accent:var(--dsh-plugin-workbench-accent,#4f6bdb);--w-selected:color-mix(in srgb,var(--w-accent) 10%,var(--w-bg));--w-primary:var(--w-text);--w-on-primary:var(--w-bg);container-type:inline-size;container-name:dsh-workbench;color:var(--w-text);background:var(--w-bg);font:14px/1.65 var(--dsh-font-family-content,system-ui,-apple-system,"Segoe UI","Microsoft YaHei",sans-serif);min-width:0;max-width:100%;box-sizing:border-box;text-align:start;color-scheme:inherit}
140
+ .dshw *,.dshw *:before,.dshw *:after{box-sizing:border-box}.dshw h1,.dshw h2,.dshw h3,.dshw h4,.dshw p{margin:0}.dshw h1{font-size:30px;line-height:1.25;letter-spacing:-.025em;font-weight:650}.dshw h2{font-size:24px;line-height:1.35;font-weight:650;letter-spacing:-.015em;overflow-wrap:anywhere}.dshw h3,.dshw h4{font-size:16px;line-height:1.4;font-weight:600}.dshw a{color:var(--w-accent);text-underline-offset:3px;overflow-wrap:anywhere}.dshw button,.dshw input,.dshw select,.dshw textarea{font:inherit;color:inherit;max-width:100%}.dshw input:not([type=checkbox]):not([type=radio]):not([type=file]),.dshw select,.dshw textarea{background:var(--w-bg);border:1px solid var(--w-border);border-radius:8px;padding:8px 11px;min-width:0;line-height:1.5}.dshw input:not([type=checkbox]):not([type=radio]):not([type=file]),.dshw select{min-height:38px}.dshw textarea{resize:vertical}.dshw input[type=checkbox],.dshw input[type=radio]{width:16px;height:16px;flex-shrink:0;accent-color:var(--w-accent)}.dshw :focus-visible{outline:2px solid var(--w-accent);outline-offset:3px}.dshw button:disabled,.dshw input:disabled,.dshw select:disabled,.dshw textarea:disabled{opacity:.5;cursor:not-allowed}.dshw label{font-size:13px}.dshw fieldset{min-width:0;border:1px solid var(--w-border);border-radius:8px}.dshw summary{cursor:pointer;font-weight:550;list-style:none;display:flex;align-items:center;gap:8px}.dshw summary::-webkit-details-marker{display:none}.dshw summary:after{content:'';display:block;margin-inline-start:auto;width:7px;height:7px;border-inline-end:1.75px solid currentColor;border-bottom:1.75px solid currentColor;transform:rotate(45deg);flex-shrink:0}.dshw details[open]>summary:after{transform:rotate(225deg)}.dshw details>summary+*{margin-top:12px}.dshw pre{white-space:pre-wrap;overflow-wrap:anywhere;font:12px/1.7 ui-monospace,SFMono-Regular,Consolas,monospace;max-width:100%;background:var(--w-soft);border-radius:6px;padding:14px}.dshw img,.dshw video,.dshw iframe{max-width:100%}
141
+ .w-page{display:flex;flex-direction:column;position:relative;padding:0;min-height:540px;gap:0}.w-page[data-main=true]{height:100%;min-height:0;padding:calc(24px + var(--dsh-frame-top-clearance,0px)) 28px 0 max(28px,var(--dsh-frame-leading-clearance,0px));overflow:auto}.w-page-header{display:flex;justify-content:space-between;gap:24px;align-items:flex-start;padding-bottom:22px;flex-shrink:0}.w-heading{min-width:0}.w-subtitle{margin-top:8px!important;font-size:14px;color:var(--w-muted);line-height:1.6}.w-header-actions,.w-toolbar,.w-actions{display:flex;align-items:center;flex-wrap:wrap;gap:8px;min-width:0}.w-header-actions{justify-content:flex-end}.w-body,.w-tabs-layout{display:flex;flex-direction:column;flex:1;min-height:0;min-width:0}.w-body{overflow:auto}.w-tab-panel{flex:1;min-width:0;min-height:0;display:flex;flex-direction:column;overflow:auto}.w-tabs{display:flex;align-items:stretch;gap:20px;border-bottom:1px solid var(--w-border);flex-shrink:0;overflow-x:auto;scrollbar-width:thin}.dshw .w-tabs>button{border:0;border-bottom:2px solid transparent;background:transparent;padding:11px 8px 13px;white-space:nowrap;font-size:14px;font-weight:550;cursor:pointer;color:var(--w-muted);display:flex;align-items:center;gap:7px}.dshw .w-tabs>button[aria-selected=true]{border-bottom-color:var(--w-accent);color:var(--w-accent)}.w-count,.w-tag{font-size:12px;line-height:1.5;display:inline-flex;align-items:center;flex-shrink:0;background:var(--w-soft);border-radius:5px;padding:1px 6px;color:var(--w-muted)}.w-tabs [aria-selected=true] .w-count,.w-selected .w-tag{color:var(--w-accent);background:var(--w-selected)}
142
+ .dshw .w-button{display:inline-flex;justify-content:center;align-items:center;gap:7px;background:var(--w-bg);border:1px solid var(--w-border);border-radius:8px;padding:8px 12px;min-height:36px;line-height:1.4;font-size:14px;font-weight:500;cursor:pointer;text-decoration:none;white-space:normal}.dshw .w-button:not(:disabled):hover{background:var(--w-soft)}.dshw .w-primary{background:var(--w-primary);border-color:var(--w-primary);color:var(--w-on-primary)}.dshw .w-primary:not(:disabled):hover{background:var(--w-primary);opacity:.9}.dshw .w-ghost{background:transparent;border-color:transparent}.dshw .w-danger{color:var(--dsw-alias-state-error-primary,#b43c3c)}.dshw .w-icon-button{width:36px;min-width:36px;padding:8px}.dshw .w-button svg{flex-shrink:0}.w-muted{color:var(--w-muted);font-size:12px;line-height:1.6}.w-section{padding:24px 0;border-bottom:1px solid var(--w-border);min-width:0}.w-section>h3{margin-bottom:12px}.w-section>p+p{margin-top:8px}.w-fields{display:grid;gap:16px;min-width:0}.w-field{display:grid;gap:6px;min-width:0}.w-field>input,.w-field>select,.w-field>textarea{width:100%}.w-status{display:flex;align-items:flex-start;gap:8px;padding:11px 13px;margin:12px 0;border:1px solid var(--w-border);border-radius:8px;background:var(--w-soft);font-size:13px;overflow-wrap:anywhere;flex-shrink:0}.w-status>svg{flex-shrink:0;margin-top:2px}.w-status-error{color:var(--dsw-alias-state-error-primary,#ad3636)}.w-status-success{color:var(--dsw-alias-state-success-primary,#24794a)}.w-empty{display:flex;flex-direction:column;align-items:center;justify-content:center;text-align:center;gap:14px;max-width:580px;padding:48px 24px;margin:auto;min-height:280px;overflow-wrap:anywhere}.w-empty>svg{color:var(--w-muted)}.w-empty h2{font-size:20px}.w-empty .w-muted{font-size:14px}.w-empty .w-toolbar{justify-content:center}
143
+ .w-split{display:grid;grid-template-columns:minmax(240px,var(--w-list-width)) minmax(0,1fr);min-height:460px;flex:1;min-width:0}.w-master{min-width:0;border-inline-end:1px solid var(--w-border);overflow:auto;padding-bottom:24px}.w-detail{min-width:0;padding:26px 28px;overflow:auto;overflow-wrap:anywhere;display:flex;flex-direction:column}.w-master-toolbar{display:flex;align-items:center;gap:8px;flex-wrap:wrap;padding:20px 16px}.w-search{display:flex;align-items:center;gap:8px;border:1px solid var(--w-border);border-radius:8px;padding:0 10px;min-width:0;flex:1;background:var(--w-bg)}.w-search>svg{color:var(--w-muted);flex-shrink:0}.dshw .w-search>input{border:0!important;background:transparent!important;padding:8px 0!important;width:100%;outline-offset:0}.w-row{display:flex;gap:0;min-width:0;position:relative;border-bottom:1px solid var(--w-border);border-inline-start:3px solid transparent}.w-row-select{display:flex;align-items:flex-start;padding:21px 0 0 14px}.dshw .w-row-button{display:flex;flex-direction:column;align-items:stretch;gap:7px;text-align:start;width:100%;padding:18px 18px 18px 16px;border:0;background:transparent;color:inherit;min-width:0;cursor:pointer;line-height:1.5}.dshw .w-row-button:hover{background:var(--w-soft)}.w-row-head{display:flex;align-items:flex-start;gap:10px;justify-content:space-between;min-width:0}.w-row-head>strong{font-size:14px;line-height:1.5;font-weight:600;overflow-wrap:anywhere}.w-row-meta,.w-row-description{color:var(--w-muted);font-size:12px;line-height:1.6;overflow-wrap:anywhere}.w-row-description{display:-webkit-box;-webkit-line-clamp:2;-webkit-box-orient:vertical;overflow:hidden}.w-selected{background:var(--w-selected);border-inline-start-color:var(--w-accent)}.w-back{display:none!important}.w-detail-title{margin-bottom:12px!important}.w-detail-meta{color:var(--w-muted);font-size:13px;display:flex;align-items:center;gap:8px;flex-wrap:wrap}.w-detail-footer{padding:24px 0;display:flex;align-items:center;gap:10px;flex-wrap:wrap;margin-top:auto;border-top:1px solid var(--w-border)}.w-detail-footer .w-muted{flex:1;min-width:160px}.w-definition{display:grid;grid-template-columns:minmax(80px,120px) minmax(0,1fr);gap:8px 16px;font-size:14px;margin:20px 0}.w-definition dt{color:var(--w-muted)}.w-definition dd{margin:0;min-width:0;overflow-wrap:anywhere}
144
+ .w-switch-label{display:inline-flex;align-items:center;gap:8px;font-size:13px;position:relative;cursor:pointer}.w-switch-label>input{position:absolute;opacity:0;inset-inline-end:0;width:36px!important;height:22px!important;margin:0;cursor:pointer}.w-switch-track{width:36px;height:22px;border-radius:12px;display:block;background:var(--w-border);border:1px solid var(--w-border);pointer-events:none;padding:2px;transition:background .15s}.w-switch-track:before{content:'';display:block;width:16px;height:16px;border-radius:50%;background:#fff;box-shadow:0 1px 2px #0002;transition:transform .15s}.w-switch-label>input:checked+.w-switch-track{background:var(--w-accent);border-color:var(--w-accent)}.w-switch-label>input:checked+.w-switch-track:before{transform:translateX(14px)}.w-switch-label>input:focus-visible+.w-switch-track{outline:2px solid var(--w-accent);outline-offset:3px}.w-switch-label:has(>input:disabled){opacity:.5;cursor:not-allowed}
145
+ .w-overlay{position:fixed;inset:0;background:#0005;display:flex;justify-content:flex-end;z-index:1000;padding:12px;overflow:auto}.w-dialog{width:min(620px,100%);max-height:100%;display:flex;flex-direction:column;min-height:0;background:var(--w-bg);color:var(--w-text);border:1px solid var(--w-border);border-radius:12px;box-shadow:0 18px 70px #0003}.w-dialog-header{display:flex;justify-content:space-between;align-items:center;gap:16px;padding:20px 24px;border-bottom:1px solid var(--w-border);flex-shrink:0}.w-dialog-header>h2{font-size:20px}.w-dialog-body{overflow:auto;padding:20px 24px;min-height:0}.w-editor-grid{display:grid;grid-template-columns:210px minmax(0,1fr) 300px;min-height:500px;flex:1}.w-editor-list{padding:20px 12px;border-inline-end:1px solid var(--w-border);min-width:0}.w-editor-canvas{background:var(--w-soft);padding:20px;min-width:0;display:flex;flex-direction:column;gap:14px}.w-editor-inspector{padding:24px;border-inline-start:1px solid var(--w-border);min-width:0;overflow:auto}.w-editor-inspector h3{margin-bottom:18px}.w-preview-empty{display:flex;flex-direction:column;justify-content:center;align-items:center;text-align:center;gap:12px;aspect-ratio:16/9;min-height:180px;background:var(--w-soft);border:1px solid var(--w-border);border-radius:8px;padding:24px;color:var(--w-muted)}.w-content-pad{padding:24px 0}.w-stack{display:flex;flex-direction:column;gap:16px;min-width:0}.w-scroll-x{overflow:auto;max-width:100%}
146
+ @container dsh-workbench (max-width:1000px){.w-editor-grid{grid-template-columns:160px minmax(0,1fr)}.w-editor-inspector{grid-column:1/-1;border-inline-start:0;border-top:1px solid var(--w-border)}.w-header-actions{max-width:60%}.w-split{grid-template-columns:minmax(240px,32%) minmax(0,1fr)}}
147
+ @container dsh-workbench (max-width:760px){.w-page-header{gap:14px;flex-wrap:wrap;padding-bottom:18px}.w-heading{flex:1;min-width:170px}.dshw h1{font-size:24px}.w-header-actions{max-width:100%;justify-content:flex-start}.w-subtitle{font-size:13px}.w-tabs{gap:12px}.dshw .w-tabs>button{padding:10px 4px 12px}.w-split{display:block;min-height:360px}.w-split[data-selected=false]>.w-detail{display:none}.w-split[data-selected=true]>.w-master{display:none}.w-master{border-inline-end:0}.w-detail{padding:20px 0}.w-back{display:inline-flex!important;align-self:flex-start;margin:0 0 16px!important}.w-detail h2{font-size:22px}.w-master-toolbar{padding:16px 0}.dshw .w-row-button{padding:16px 10px}.w-detail-footer{position:static}.w-detail-footer .w-muted{flex-basis:100%}.w-editor-grid{display:flex;flex-direction:column}.w-editor-list{border-inline-end:0;border-bottom:1px solid var(--w-border);padding:16px 0}.w-editor-canvas{padding:16px 0;background:var(--w-bg)}.w-editor-inspector{padding:20px 0}.w-dialog-header,.w-dialog-body{padding:16px}.w-button{min-height:40px}.w-definition{grid-template-columns:80px minmax(0,1fr)}}
148
+ @media(max-width:700px){.w-page[data-main=true]{padding:calc(16px + var(--dsh-frame-top-clearance,0px)) 16px 0 max(16px,var(--dsh-frame-leading-clearance,0px))}.w-overlay{padding:8px}.w-dialog{width:100%}}
149
+ @media(prefers-reduced-motion:reduce){.dshw *,.dshw *:before{scroll-behavior:auto!important;transition:none!important;animation:none!important}}
150
+ `;
151
+ return { Icon, Button, IconButton, Page, Tabs, Status, Empty, Split, Row, Search, Switch, Dialog, register, styles };
152
+ }
7
153
 
8
- // ---- first-run guide (shared snippet; keep in sync across plugins) ----
9
- var __FR_STYLE_ID = 'dsh-first-run-css';
10
- var __FR_CSS = [
11
- '.fr-card{border:1px solid var(--dsw-border,rgba(0,0,0,.10));border-radius:12px;padding:14px 16px;margin:0 0 14px;background:linear-gradient(180deg,rgba(59,130,246,.06),rgba(59,130,246,.02))}',
12
- '.fr-head{display:flex;align-items:center;gap:8px;margin-bottom:6px}',
13
- '.fr-dot{width:6px;height:6px;border-radius:50%;background:var(--dsw-accent,#3b82f6)}',
14
- '.fr-title{font-weight:650;font-size:13.5px}',
15
- '.fr-count{margin-left:auto;font-size:11px;color:var(--dsw-text-weak,#6b7280);font-variant-numeric:tabular-nums}',
16
- '.fr-step{font-weight:600;font-size:13px;margin:2px 0 4px}',
17
- '.fr-body{color:var(--dsw-text-weak,#4b5563);font-size:12.5px;line-height:1.65}',
18
- '.fr-try{margin-top:8px;padding:7px 9px;border-radius:8px;background:rgba(59,130,246,.09);font-size:12px;display:flex;gap:8px}',
19
- '.fr-try code{font-family:ui-monospace,monospace;white-space:pre-wrap;word-break:break-word}',
20
- '.fr-bar{display:flex;gap:8px;align-items:center;margin-top:12px}',
21
- '.fr-progress{display:flex;gap:4px;margin-right:auto}',
22
- '.fr-seg{width:16px;height:3px;border-radius:2px;background:var(--dsw-border,rgba(0,0,0,.12))}',
23
- '.fr-seg.on{background:var(--dsw-accent,#3b82f6)}',
24
- '.fr-btn{border:1px solid var(--dsw-border,rgba(0,0,0,.14));background:transparent;color:inherit;border-radius:8px;padding:4px 10px;font-size:12px;cursor:pointer}',
25
- '.fr-btn:hover{background:rgba(0,0,0,.04)}',
26
- '.fr-btn.primary{background:var(--dsw-accent,#3b82f6);border-color:transparent;color:#fff}',
27
- '.fr-btn.ghost{border-color:transparent;color:var(--dsw-text-weak,#6b7280)}',
28
- ].join('\n');
29
- function __frEnsureCss() {
30
- if (typeof document === 'undefined' || document.getElementById(__FR_STYLE_ID)) return;
31
- var el = document.createElement('style');
32
- el.id = __FR_STYLE_ID;
33
- el.textContent = __FR_CSS;
34
- document.head.appendChild(el);
154
+ /* One update control per plugin. Only transport, idle guards and installation
155
+ * coordination are shared; no global update page or update-all action exists. */
156
+ function __stardustUpdatesGuards() {
157
+ const key = Symbol.for('stardustlc.plugin-updates.guards.v1');
158
+ return globalThis[key] ||= { values: new Map(), listeners: new Set(), viewListeners: new Set(), clients: new Set() };
35
159
  }
36
- function __frRead() { try { return localStorage.getItem(__FR_KEY) === 'done'; } catch (e) { return false; } }
37
- function __frWrite() { try { localStorage.setItem(__FR_KEY, 'done'); } catch (e) {} }
38
- function __FirstRunCard() {
39
- var doneState = React.useState(__frRead);
40
- var done = doneState[0], setDone = doneState[1];
41
- var idxState = React.useState(0);
42
- var index = idxState[0], setIndex = idxState[1];
43
- React.useEffect(function () { __frEnsureCss(); }, []);
44
- if (done) return null;
45
- var step = __FR_STEPS[index];
46
- var last = index >= __FR_STEPS.length - 1;
47
- var close = function () { __frWrite(); setDone(true); };
48
- var kids = [
49
- React.createElement('div', { className: 'fr-head', key: 'h' },
50
- React.createElement('span', { className: 'fr-dot' }),
51
- React.createElement('span', { className: 'fr-title' }, __FR_TITLE),
52
- React.createElement('span', { className: 'fr-count' }, (index + 1) + ' / ' + __FR_STEPS.length)),
53
- React.createElement('div', { className: 'fr-step', key: 't' }, step.title),
54
- React.createElement('div', { className: 'fr-body', key: 'b' }, step.body),
55
- ];
56
- if (step.tryIt) kids.push(React.createElement('div', { className: 'fr-try', key: 'y' },
57
- React.createElement('span', null, '可以直接说'),
58
- React.createElement('code', null, '「' + step.tryIt + '」')));
59
- var buttons = [React.createElement('div', { className: 'fr-progress', key: 'p' }, __FR_STEPS.map(function (_, i) {
60
- return React.createElement('span', { key: i, className: 'fr-seg' + (i <= index ? ' on' : '') });
61
- }))];
62
- buttons.push(React.createElement('button', { className: 'fr-btn ghost', type: 'button', onClick: close, key: 's' }, '跳过'));
63
- if (index > 0) buttons.push(React.createElement('button', { className: 'fr-btn', type: 'button', key: 'prev', onClick: function () { setIndex(index - 1); } }, '上一步'));
64
- buttons.push(React.createElement('button', { className: 'fr-btn primary', type: 'button', key: 'next', onClick: function () { if (last) close(); else setIndex(index + 1); } }, last ? '开始使用' : '下一步'));
65
- kids.push(React.createElement('div', { className: 'fr-bar', key: 'bar' }, buttons));
66
- return React.createElement('div', { className: 'fr-card' }, kids);
160
+ function __stardustUpdatesGuard(React, name, { dirty = false, busy = false, retainOnClose = false } = {}) {
161
+ const token = React.useRef(null);
162
+ if (!token.current) token.current = {};
163
+ React.useLayoutEffect(() => {
164
+ const pool = __stardustUpdatesGuards();
165
+ if (!dirty && !busy) for (const [key, value] of pool.values) if (value.name === name && value.orphan) pool.values.delete(key);
166
+ pool.values.set(token.current, { name, dirty: !!dirty, busy: !!busy, retainOnClose, orphan: false });
167
+ for (const listener of pool.listeners) listener();
168
+ }, [name, !!dirty, !!busy, retainOnClose]);
169
+ React.useEffect(() => () => {
170
+ const pool = __stardustUpdatesGuards(), value = pool.values.get(token.current);
171
+ if (value?.retainOnClose && (value.dirty || value.busy)) value.orphan = true;
172
+ else pool.values.delete(token.current);
173
+ for (const listener of pool.listeners) listener();
174
+ }, []);
67
175
  }
68
- function __withFirstRun(Component) {
69
- return function FirstRunWrapped(props) {
70
- return React.createElement(React.Fragment, null, React.createElement(__FirstRunCard, null), React.createElement(Component, props));
71
- };
176
+ function __StardustPluginUpdateButton({ React, name }) {
177
+ const [, render] = React.useState(0), pool = __stardustUpdatesGuards();
178
+ React.useEffect(() => { const fn = () => render(value => value + 1); pool.viewListeners.add(fn); return () => pool.viewListeners.delete(fn); }, []);
179
+ const client = [...pool.clients].find(client => client.has(name));
180
+ if (!client) return null;
181
+ const available = client.row(name)?.available;
182
+ return React.createElement(client.Button, { icon: 'refresh', variant: available ? undefined : 'ghost', onClick: () => client.open(name), 'data-plugin-update': name }, available ? client.t('有更新', 'Update available') : client.t('插件更新', 'Update plugin'));
183
+ }
184
+ function __stardustUpdatesPage(React, props, name) {
185
+ return { ...props, actions: React.createElement(React.Fragment, null, props.actions, React.createElement(__StardustPluginUpdateButton, { React, name })) };
186
+ }
187
+ function __stardustUpdatesDisplayRows(next, known) {
188
+ for (const row of next.rows) known.set(row.name, row);
189
+ if (!['verifying', 'installing', 'cancelling', 'unknown', 'restore-failed'].includes(next.job?.state)) return next;
190
+ const rows = [...next.rows];
191
+ for (const row of known.values()) if ((row.name === next.job.name || row.bundledBy === next.job.name) && !rows.some(item => item.name === row.name)) rows.push({ ...row, updating: true });
192
+ return { ...next, rows };
193
+ }
194
+ function __stardustUpdatesWrap(definition, participant) {
195
+ return { ...definition, factory(require) {
196
+ const original = definition.factory(require);
197
+ if (!original || typeof original !== 'object') return original;
198
+ const React = require('react');
199
+ return { ...original, apply(ctx, ...args) {
200
+ const result = original.apply?.call(this, ctx, ...args);
201
+ if (typeof ctx.inject === 'function') ctx.inject(['slots', 'locale', 'remote', 'remote.pluginManager'], host => __stardustUpdatesJoin(host, React, require, participant));
202
+ return result;
203
+ } };
204
+ } };
205
+ }
206
+ function __stardustUpdatesJoin(host, React, require, participant) {
207
+ const key = Symbol.for('stardustlc.plugin-updates.client.v1'), pools = globalThis[key] ||= new WeakMap(), root = host.root || host;
208
+ if (typeof root.plugin !== 'function') return;
209
+ let record = pools.get(root);
210
+ if (!record) {
211
+ record = { refs: new Map(), timer: null, version: participant.version, alive: true, hold: false };
212
+ pools.set(root, record);
213
+ const shared = record;
214
+ record.fiber = root.plugin({ name: 'stardustlc-plugin-updates-client', inject: ['slots', 'locale', 'remote', 'remote.pluginManager'], apply(ctx) {
215
+ const client = __stardustUpdatesClient(ctx, React, require, shared);
216
+ ctx.effect(() => () => { shared.alive = false; client.dispose(); if (pools.get(root) === shared) pools.delete(root); });
217
+ } });
218
+ Promise.resolve(record.fiber).catch(() => { shared.alive = false; if (pools.get(root) === shared) pools.delete(root); });
219
+ }
220
+ clearTimeout(record.timer);
221
+ const ref = {}; record.refs.set(ref, participant);
222
+ host.effect(() => () => {
223
+ record.refs.delete(ref);
224
+ const stop = () => {
225
+ if (record.refs.size || !record.alive) return;
226
+ if (record.hold) { record.timer = setTimeout(stop, 1000); return; }
227
+ record.alive = false; Promise.resolve(record.fiber?.dispose?.()).catch(() => {});
228
+ };
229
+ if (!record.refs.size) record.timer = setTimeout(stop, 1000);
230
+ });
231
+ }
232
+ function __stardustUpdatesClient(ctx, React, require, shared) {
233
+ const h = React.createElement, W = createWorkbenchUI(React), route = new URL('api/stardustlc/plugin-updates', document.baseURI);
234
+ const { useState, useEffect } = React, id = crypto.randomUUID(), listeners = new Set(), pool = __stardustUpdatesGuards(), requests = new Set(), sections = new Map(), notified = new Set(), knownRows = new Map();
235
+ let alive = true, registered = false, state = null, lastInteraction = Date.now(), inPoll = false, activeName = null, manualOperation = false;
236
+ const language = () => String(ctx.locale?.getSnapshot?.().active || '').startsWith('en') ? 'en' : 'zh';
237
+ const t = (zh, en) => language() === 'en' ? en : zh;
238
+ const preferences = name => state?.preferences.packages[name] || { checkEnabled: true, autoInstall: false, deferredUntil: 0, ignoredVersion: null };
239
+ const originalRow = name => state?.rows.find(row => row.name === name);
240
+ const rowFor = name => { const row = originalRow(name); return row?.bundledBy ? originalRow(row.bundledBy) : row; };
241
+ const activeJob = () => ['verifying', 'installing', 'cancelling'].includes(state?.job?.state);
242
+ function notify() { shared.hold = manualOperation || activeJob(); for (const listener of listeners) listener(); for (const listener of pool.viewListeners) listener(); }
243
+ async function api(body = { action: 'state' }) {
244
+ const controller = new AbortController(); requests.add(controller);
245
+ const timeout = setTimeout(() => controller.abort(), body.action === 'check' ? 95000 : 45000);
246
+ try {
247
+ const response = await fetch(route, { method: 'POST', credentials: 'same-origin', cache: 'no-store', signal: controller.signal, headers: { 'content-type': 'application/json', 'x-stardustlc-updates': '1' }, body: JSON.stringify(body) });
248
+ let data; try { data = await response.json(); } catch { throw new Error('service-unavailable'); }
249
+ if (!response.ok || !data.ok) throw new Error(response.status === 403 ? 'owner-required' : data.code || 'service-unavailable');
250
+ return data.value;
251
+ } catch (error) { if (error?.name === 'AbortError') throw new Error('service-unavailable'); throw error; }
252
+ finally { clearTimeout(timeout); requests.delete(controller); }
253
+ }
254
+ function pageState(manual = manualOperation) {
255
+ const values = [...pool.values.values()];
256
+ const dialog = [...document.querySelectorAll('[role="dialog"],dialog[open]')].some(node => node.getClientRects().length && !(manual && (node.closest('.plugin-updates-page') || node.querySelector('.plugin-updates-page'))));
257
+ return { action: 'heartbeat', id, dirty: values.some(value => value.dirty), busy: values.some(value => value.busy) || dialog, idleForMs: Math.min(86400000, Math.max(0, Date.now() - lastInteraction)) };
258
+ }
259
+ const heartbeat = () => api(pageState());
260
+ function interaction() { lastInteraction = Date.now(); }
261
+ const guardChanged = () => { if (registered && alive) void heartbeat().catch(() => {}); };
262
+ for (const event of ['pointerdown', 'keydown', 'input']) document.addEventListener(event, interaction, { capture: true, passive: true });
263
+ pool.listeners.add(guardChanged);
264
+ const close = () => { void fetch(route, { method: 'POST', credentials: 'same-origin', keepalive: true, headers: { 'content-type': 'application/json', 'x-stardustlc-updates': '1' }, body: JSON.stringify({ action: 'client-close', id }) }).catch(() => {}); };
265
+ window.addEventListener('pagehide', close);
266
+ async function refresh() { const next = await api(); if (alive) { state = __stardustUpdatesDisplayRows(next, knownRows); notify(); } return next; }
267
+ function useSnapshot() {
268
+ const [, render] = useState(0);
269
+ useEffect(() => { const fn = () => render(value => value + 1); listeners.add(fn); const stop = ctx.locale?.subscribe?.(fn); return () => { listeners.delete(fn); stop?.(); }; }, []);
270
+ return state;
271
+ }
272
+ function message(code) {
273
+ return ({
274
+ 'page-dirty': t('有未保存的修改。请先保存或放弃修改,再更新。', 'Save or discard unsaved changes before updating.'),
275
+ 'page-busy': t('有页面操作或对话框尚未结束,请完成后再试。', 'Finish the active page operation or close its dialog, then retry.'),
276
+ 'page-not-ready': t('还有窗口状态未确认,或旧版插件尚未提供状态保护。请刷新相关窗口,必要时先手动更新旧版插件。', 'A window state is unknown or an older plugin lacks state protection. Refresh the affected windows and manually update legacy plugins if needed.'),
277
+ busy: t('DSH 正在执行任务或安装,请等操作结束。', 'DSH is running a task or installation. Wait for it to finish.'),
278
+ 'activity-unknown': t('无法确认任务是否空闲,已暂停安装。', 'Installation paused because task activity is unknown.'),
279
+ 'restart-required': t('更新服务需要重启后继续。请在方便时手动重启 DSH。', 'The updater needs a restart. Restart DSH manually when convenient.'),
280
+ 'operation-unconfirmed': t('上次安装未确认或恢复失败。请在官方插件管理中检查并修复,之后手动重启 DSH。', 'The last installation is unconfirmed or recovery failed. Check and repair it in native plugin management, then restart DSH manually.'),
281
+ 'check-first': t('检查结果已过期,请重新检查。', 'This check expired. Check again.'),
282
+ 'release-changed': t('发布信息已变化,本次未安装。请重新检查。', 'Release metadata changed. Nothing was installed; check again.'),
283
+ 'preferences-conflict': t('另一个窗口修改了偏好,已刷新,请重试。', 'Preferences changed in another window. They have been refreshed; retry.'),
284
+ 'preferences-unreadable': t('更新偏好文件无法读取,自动安装已关闭。请检查当前 profile 的 stardustlc-plugin-updates.json。', 'Preferences could not be read. Automatic installation is off. Check stardustlc-plugin-updates.json in this profile.'),
285
+ 'no-update': t('版本已变化或暂不兼容,请重新检查。', 'The version changed or is incompatible. Check again.'),
286
+ 'source-not-registry': t('本地源码、Git 等安装,请通过原安装方式更新。', 'Update local, Git and other external sources through their original installation method.'),
287
+ 'managed-by-suite': t('这个插件随 Suite 安装,通过 Suite 更新。', 'This plugin was installed through Suite and is updated through Suite.'),
288
+ 'owner-required': t('只有 profile 拥有者能管理更新。', 'Only the profile owner can manage updates.'),
289
+ })[code] || t('操作未完成,请刷新后重试。DSH 不会因此自动重启。', 'The operation could not be completed. Refresh and retry. DSH will not restart automatically.');
290
+ }
291
+ function jobLabel(job) {
292
+ return ({ verifying: t('正在核对版本', 'Verifying release'), installing: t('正在安装', 'Installing'), cancelling: t('正在请求取消', 'Requesting cancellation'), complete: t('已更新', 'Updated'), 'restart-required': t('已安装,等待你手动重启', 'Installed; manual restart needed'), restored: t('更新未成功,已恢复原版本', 'Update failed; previous version restored'), 'restore-failed': t('恢复未成功,请检查官方插件管理', 'Recovery failed; check native plugin management'), unknown: t('结果未确认,请检查官方插件管理', 'Result unconfirmed; check native plugin management'), cancelled: t('已取消', 'Cancelled'), failed: t('更新未成功', 'Update failed') })[job.state] || job.state;
293
+ }
294
+ function Panel({ name, compact = false }) {
295
+ const snapshot = useSnapshot(), [error, setError] = useState(''), [working, setWorking] = useState(false), [checking, setChecking] = useState(false), [dialog, setDialog] = useState(null), [notes, setNotes] = useState(null), [loadingNotes, setLoadingNotes] = useState(false);
296
+ const row = rowFor(name), original = originalRow(name), target = row?.name || name, prefs = preferences(target), job = snapshot?.job?.name === target ? snapshot.job : null;
297
+ async function perform(callback) { setError(''); setWorking(true); try { await callback(); await refresh(); } catch (error) { setError(error.message); await refresh().catch(() => {}); } finally { setWorking(false); } }
298
+ async function save(changes, consent) { await api({ action: 'preferences', name: target, revision: state.preferences.revision, changes, consent }); }
299
+ async function check() { setError(''); setChecking(true); try { await api({ action: 'check', name: target }); await refresh(); } catch (error) { setError(error.message); } finally { setChecking(false); } }
300
+ async function install() {
301
+ setDialog(null); manualOperation = true; notify();
302
+ await perform(async () => {
303
+ try {
304
+ await heartbeat();
305
+ const started = await api({ action: 'install', name: row.name, version: row.release.version, confirmation: 'update-installed-plugin' });
306
+ while (alive) {
307
+ await new Promise(resolve => setTimeout(resolve, 800)); await heartbeat(); await refresh();
308
+ if (state.job?.id !== started.id) throw new Error('operation-unconfirmed');
309
+ if (!activeJob()) break;
310
+ }
311
+ } finally { manualOperation = false; notify(); }
312
+ });
313
+ }
314
+ async function showNotes() {
315
+ setDialog('notes'); setNotes(null); setLoadingNotes(true); setError('');
316
+ try { setNotes(await api({ action: 'notes', name: target, version: row.release.version })); } catch (error) { setError(error.message); } finally { setLoadingNotes(false); }
317
+ }
318
+ if (!snapshot || !row) return h(W.Status, null, t('此插件尚未安装或已从当前 profile 移除。', 'This plugin is not installed in the current profile.'));
319
+ const title = language() === 'en' ? original.labelEn : original.label;
320
+ if (compact) return h('div', { className: 'dshw', style: { padding: 16 } }, h('style', null, W.styles), h('div', { className: 'w-stack' }, h('h3', null, title), h('p', { className: 'w-muted' }, original.name + ' · ' + original.version), h('p', null, t('这个插件的更新设置与安装入口。自动安装默认关闭。', 'Update settings and installation for this plugin. Automatic installation is off by default.')), h(W.Button, { icon: 'refresh', onClick: () => { activeName = name; notify(); } }, row.available ? t('查看可用更新', 'Review available update') : t('检查与更新', 'Check and update'))));
321
+ const unconfirmed = ['unknown', 'restore-failed'].includes(snapshot.job?.state), pageBusy = pageState(true).busy || (snapshot.pages.clients || []).some(client => client.id !== id && client.busy), installLocked = working || activeJob() || unconfirmed || snapshot.updaterRestart || snapshot.preferenceError || !snapshot.activity.known || snapshot.activity.busy || snapshot.pages.dirty || pageBusy || !snapshot.pages.known;
322
+ const checkingThis = checking || snapshot.checkingNames?.includes(target);
323
+ const status = row.sourceKind !== 'registry' ? t('本地 / 外部来源,保留原安装方式', 'Local / external source; keep original install method') : row.loadError ? t('加载异常,请先检查官方插件管理', 'Loading error; check native plugin management') : row.error ? t('检查失败,可以重试', 'Check failed; retry available') : row.release && !row.release.compatible ? t('新版本暂不兼容当前环境', 'Latest release is incompatible with this environment') : row.available ? (prefs.ignoredVersion === row.release.version ? t('已忽略提醒,仍可手动更新', 'Reminder ignored; manual update available') : t('有新版本', 'Update available')) : row.checkedAt ? t('当前已是最新稳定版', 'Latest stable version') : t('尚未检查', 'Not checked yet');
324
+ return h(W.Page, { title: title + t(' · 更新', ' · Updates'), subtitle: t('只管理这个插件。检查不会安装,也不会重启 DSH。', 'Manage this plugin. Checking does not install anything or restart DSH.'), className: 'plugin-updates-page', actions: h(W.Button, { icon: 'refresh', disabled: checkingThis || row.sourceKind !== 'registry', onClick: check }, checkingThis ? t('正在检查…', 'Checking…') : t('检查更新', 'Check for updates')) },
325
+ h('style', null, '.plugin-updates-page{min-height:0;padding:4px}.plugin-updates-page .updates-settings{display:grid;gap:24px;padding:20px 0}.plugin-updates-page .updates-note{margin-top:8px}.plugin-updates-page .updates-version{font:13px/1.7 ui-monospace,monospace;overflow-wrap:anywhere}.plugin-updates-page .w-overlay{z-index:1002}.plugin-updates-page .w-switch-label{max-width:100%}.plugin-updates-page .w-switch-track{flex-shrink:0}@media(max-width:700px){[data-shortcut-modal="settings"]:has(.plugin-updates-page){flex-direction:column!important;width:calc(100vw - 16px)!important;max-width:calc(100vw - 16px)!important}[data-shortcut-modal="settings"]:has(.plugin-updates-page)>nav{width:100%!important;flex-basis:auto!important;flex-shrink:0;max-height:180px;overflow:auto;border-right:0!important}[data-shortcut-modal="settings"]:has(.plugin-updates-page)>nav>div:has(>button){display:flex;flex-wrap:wrap;gap:4px}[data-shortcut-modal="settings"]:has(.plugin-updates-page)>div{min-width:0!important;width:100%!important}.plugin-updates-page .w-switch-label{display:flex;justify-content:space-between;align-items:flex-start;gap:16px}.plugin-updates-page .w-switch-label>span:first-child{min-width:0}.plugin-updates-page .w-switch-label>input{inset-inline-end:0}}'),
326
+ original.bundledBy && h(W.Status, null, t('此插件随 Suite 安装。以下设置与安装作用于 Suite 整包,以保持组件版本一致。单独安装的插件可以独立更新。', 'This plugin was installed through Suite. These controls update Suite as a package so its components stay consistent. Independently installed plugins update individually.')),
327
+ h('section', { className: 'w-section' }, h('p', { className: 'updates-version' }, target + ' · ' + row.version, row.release?.version && row.release.version !== row.version ? ' → ' + row.release.version : ''), h('p', { className: 'w-muted updates-note' }, status), !row.enabled && h('p', { className: 'w-muted' }, t('当前已停用,更新后仍保持停用。', 'Currently disabled; it will remain disabled after updating.')), row.checkedAt && h('p', { className: 'w-muted' }, t('上次检查:', 'Last checked: ') + new Date(row.checkedAt).toLocaleString(language() === 'en' ? 'en-US' : 'zh-CN')),
328
+ h('div', { className: 'w-toolbar', style: { marginTop: 16 } }, row.available && row.sourceKind === 'registry' && h(W.Button, { variant: 'primary', icon: 'download', disabled: installLocked || row.loadError, onClick: () => setDialog('install') }, t('更新此插件', 'Update this plugin')), row.release && h(W.Button, { variant: 'ghost', onClick: showNotes }, t('更新记录', 'Release notes')), row.available && h(W.Button, { variant: 'ghost', disabled: working, onClick: () => perform(() => api({ action: 'later', name: target, revision: state.preferences.revision })) }, t('明天再提醒', 'Remind me tomorrow')), row.available && prefs.ignoredVersion !== row.release.version && h(W.Button, { variant: 'ghost', disabled: working, onClick: () => perform(() => api({ action: 'ignore', name: target, revision: state.preferences.revision, version: row.release.version })) }, t('忽略此版本提醒', 'Ignore this reminder')))),
329
+ h('section', { className: 'updates-settings', 'aria-label': t('这个插件的更新偏好', 'Update preferences for this plugin') },
330
+ h('div', null, h(W.Switch, { label: t('自动检查这个插件的更新', 'Automatically check this plugin'), checked: prefs.checkEnabled, disabled: working || !!snapshot.preferenceError || row.sourceKind !== 'registry', onChange: event => perform(() => save({ checkEnabled: event.target.checked })) }), h('p', { className: 'w-muted updates-note' }, t('默认开启,每天最多一次。只影响这个插件,关闭后仍可手动检查。', 'On by default, at most once daily. This affects only this plugin; manual checks remain available.'))),
331
+ h('div', null, h(W.Switch, { label: t('空闲时自动安装这个插件的补丁', 'Install patches for this plugin while idle'), checked: prefs.autoInstall, disabled: working || !!snapshot.preferenceError || row.sourceKind !== 'registry', onChange: event => event.target.checked ? setDialog('automatic') : perform(() => save({ autoInstall: false })) }), h('p', { className: 'w-muted updates-note' }, t('默认关闭。明确开启后,仅空闲且没有未保存修改时安装兼容补丁。其他插件的开关不变。', 'Off by default. Explicitly enable compatible patches while idle with no unsaved changes. Other plugins’ settings stay unchanged.')))),
332
+ error && h(W.Status, { tone: 'error' }, message(error)), snapshot.preferenceError && h(W.Status, { tone: 'error' }, message('preferences-unreadable')),
333
+ snapshot.pendingRestart && h(W.Status, null, snapshot.updaterRestart ? message('restart-required') : t('已有更新等待手动重启后生效。你可以继续工作,自动安装已暂停。', 'Some updates need a manual restart. Continue your work; automatic installation is paused.')),
334
+ prefs.autoInstall && snapshot.autoReady === false && h(W.Status, null, message('page-not-ready')),
335
+ snapshot.pages.clients.some(client => !client.fresh) && h(W.Status, null, h('p', null, t('有窗口已断开,无法确认是否还有未保存修改。仍在使用的窗口请先保存并刷新;已关闭的窗口可以手动重新确认。', 'A disconnected window may contain unsaved changes. Save and refresh windows still in use. If they are closed, you can confirm that manually.')), h(W.Button, { onClick: () => setDialog('windows') }, t('重新确认已关闭的窗口', 'Confirm closed windows'))),
336
+ snapshot.pages.dirty && h(W.Status, null, message('page-dirty')), (snapshot.activity.busy || pageBusy) && h(W.Status, null, message(snapshot.activity.busy ? 'busy' : 'page-busy')),
337
+ prefs.deferredUntil > Date.now() && h(W.Status, null, t('此插件已推迟提醒和自动安装 24 小时,仍可手动更新。', 'Reminders and automatic installation for this plugin are deferred for 24 hours. Manual updates remain available.')),
338
+ unconfirmed && h(W.Status, { tone: 'error' }, message('operation-unconfirmed')),
339
+ job && h('section', { className: 'w-section', 'aria-label': t('这个插件的更新进度', 'Update progress for this plugin') }, h('h3', null, jobLabel(job)), h('p', { className: 'w-muted' }, job.from + ' → ' + job.to + (job.mode === 'automatic' ? t(' · 自动补丁更新', ' · Automatic patch') : '')), (job.reason || job.outcome?.result?.error?.code) && h(W.Status, { tone: 'error' }, message(job.reason || job.outcome.result.error.code)), activeJob() && h(W.Button, { disabled: job.state === 'cancelling', onClick: () => perform(() => api({ action: 'cancel', id: job.id })) }, t('取消更新', 'Cancel update')), h('p', { className: 'w-muted updates-note' }, t('安装开始后,取消由官方包管理器处理;已落盘的写入以实际结果或恢复状态为准。', 'After installation starts, the native package manager handles cancellation. Completed writes and recovery are reported as they occur.'))),
340
+ dialog && h(W.Dialog, { title: dialog === 'windows' ? t('断开的窗口都已关闭?', 'Are the disconnected windows closed?') : dialog === 'automatic' ? t('允许这个插件自动安装补丁?', 'Allow automatic patches for this plugin?') : dialog === 'notes' ? t('更新记录', 'Release notes') : t('确认更新此插件', 'Confirm this plugin update'), closeLabel: t('关闭', 'Close'), onClose: () => setDialog(null) },
341
+ dialog === 'windows' ? h('div', { className: 'w-stack' }, h('p', null, t('只清除超过 45 秒未回应的其他窗口记录。请先确认它们已经关闭;仍在使用的窗口请保存修改并刷新。当前或仍在回应的窗口保护会保留。', 'Only other windows silent for over 45 seconds are cleared. Confirm that they are closed; save and refresh windows still in use. Current and responsive windows remain protected.')), h('div', { className: 'w-toolbar' }, h(W.Button, { onClick: () => setDialog(null) }, t('取消', 'Cancel')), h(W.Button, { onClick: () => { setDialog(null); void perform(() => api({ ...pageState(true), action: 'reconfirm-windows', confirmation: 'other-stale-windows-are-closed' })); } }, t('已关闭,重新确认状态', 'They are closed; reconfirm')))) :
342
+ dialog === 'automatic' ? h('div', { className: 'w-stack' }, h('p', null, (language() === 'en' ? row.labelEn : row.label) + ' · ' + target), h('p', null, t('你正在主动启用这个插件的自动安装。只处理兼容的稳定补丁;有任务、未保存修改、未知窗口或等待重启时暂停。', 'You are explicitly enabling automatic installation for this plugin. Only compatible stable patches qualify; running tasks, unsaved changes, unknown windows or a pending restart pause it.')), h('p', null, t('不会自动重启 DSH,其他插件不会跟着开启。可随时关闭。', 'DSH will not restart automatically, and other plugins will not be enabled for automatic updates. Turn it off anytime.')), h('div', { className: 'w-toolbar' }, h(W.Button, { onClick: () => setDialog(null) }, t('保持关闭', 'Keep off')), h(W.Button, { variant: 'primary', onClick: () => { setDialog(null); void perform(() => save({ checkEnabled: true, autoInstall: true }, 'enable-idle-patch-updates')); } }, t('允许此插件自动安装补丁', 'Allow patches for this plugin')))) :
343
+ dialog === 'notes' ? h('div', { className: 'w-stack' }, h('p', null, target + ' · ' + row.release.version), loadingNotes ? h('p', null, t('正在读取…', 'Loading…')) : notes?.text ? h('pre', null, notes.text) : h('p', null, t('未找到此版本的独立更新记录。', 'No separate notes were found for this version.')), notes?.url && h('a', { href: notes.url, target: '_blank', rel: 'noreferrer noopener' }, t('查看仓库更新记录', 'View repository changelog'))) :
344
+ h('div', { className: 'w-stack' }, h('p', { className: 'updates-version' }, target + ': ' + row.version + ' → ' + row.release.version), h('p', null, t('通过 DSH 官方插件管理器安装。需要重启时,由你手动决定时间;停用状态会保留。', 'Install through DSH’s native plugin manager. Choose when to restart if needed; disabled status is preserved.')), h('p', { className: 'w-muted' }, t('来源:npm 官方 registry,网络不可达时回退 npmmirror。安装前再次核对版本与完整性。', 'Source: official npm registry, with npmmirror fallback if unreachable. Version and integrity are checked again before installation.')), h('div', { className: 'w-toolbar' }, h(W.Button, { onClick: () => setDialog(null) }, t('取消', 'Cancel')), h(W.Button, { variant: 'primary', onClick: install }, t('确认安装此版本', 'Install this version')))))
345
+ );
346
+ }
347
+ function Overlay() {
348
+ useSnapshot();
349
+ const row = activeName && originalRow(activeName);
350
+ if (!row) return null;
351
+ const content = h('div', { className: 'dshw' }, h('style', null, W.styles), h(W.Dialog, { title: (language() === 'en' ? row.labelEn : row.label) + t(' · 更新设置', ' · Update settings'), closeLabel: t('关闭更新设置', 'Close update settings'), onClose: () => { activeName = null; notify(); } }, h(Panel, { key: activeName, name: activeName })));
352
+ const settings = document.querySelector('[data-shortcut-modal="settings"]');
353
+ // Keep the dialog inside the native settings focus boundary when its
354
+ // per-plugin entry was opened there. The shared fiber survives HMR.
355
+ return settings ? require('react-dom').createPortal(content, settings) : content;
356
+ }
357
+ function Reminder() {
358
+ useSnapshot();
359
+ const row = state?.rows.find(row => { const prefs = preferences(row.name); return row.available && !row.updating && !row.bundledBy && prefs.checkEnabled && prefs.deferredUntil <= Date.now() && prefs.ignoredVersion !== row.release.version && !notified.has(row.name + '@' + row.release.version); });
360
+ if (!row) return null;
361
+ let Toast; try { Toast = require('@deepseek-ai/dsh-client-ui-primitives').Toast; } catch { return null; }
362
+ if (!Toast) return null;
363
+ const key = row.name + '@' + row.release.version;
364
+ return h(Toast, { key, text: (language() === 'en' ? row.labelEn : row.label) + t('有新版本,可在它的页面或设置中查看。', ' has an update. Review it on its page or in settings.'), icon: h(W.Icon, { name: 'refresh', size: 18 }), holdMs: 7000, onDone: () => { notified.add(key); notify(); } });
365
+ }
366
+ function register() {
367
+ if (!alive) return;
368
+ if (!registered) {
369
+ registered = true; pool.clients.add(client);
370
+ ctx.slots.inject('shell.overlay', () => ctx.slots.register({ name: 'shell.overlay', id: 'stardustlc.plugin-update-dialog' }, Overlay));
371
+ ctx.slots.inject('shell.overlay', () => ctx.slots.register({ name: 'shell.overlay', id: 'stardustlc.plugin-update-reminder' }, Reminder));
372
+ notify();
373
+ }
374
+ for (const row of state.rows) {
375
+ const hasWorkbench = [...shared.refs.values()].some(participant => participant.name === row.name && participant.hasWorkbench);
376
+ if (hasWorkbench) { if (sections.has(row.name)) { void sections.get(row.name).dispose(); sections.delete(row.name); } continue; }
377
+ if (sections.has(row.name)) continue;
378
+ const label = () => (language() === 'en' ? row.labelEn : row.label) + t(' · 更新', ' · Updates');
379
+ const fiber = ctx.plugin({ name: 'plugin-update-settings-' + row.name, inject: ['slots', 'locale'], apply(section) {
380
+ section.slots.inject('settings.section', () => section.slots.register({ name: 'settings.section', id: row.name + '.updates', label, order: 89 }, () => h(Panel, { name: row.name })));
381
+ } });
382
+ sections.set(row.name, fiber);
383
+ }
384
+ }
385
+ async function poll() {
386
+ if (inPoll || !alive || !shared.refs.size) return;
387
+ inPoll = true;
388
+ try { await refresh(); register(); await heartbeat(); }
389
+ catch { /* Owner-only controls stay absent for guests and unsupported hosts. */ }
390
+ finally { inPoll = false; }
391
+ }
392
+ const timer = setInterval(() => { void poll(); }, 15000), first = setTimeout(() => { void poll(); }, 100);
393
+ const client = { t, Button: W.Button, has: name => registered && !!originalRow(name), row: rowFor, open(name) { activeName = name; notify(); }, dispose() {
394
+ close(); alive = false; clearTimeout(first); clearInterval(timer); pool.clients.delete(client);
395
+ pool.listeners.delete(guardChanged); listeners.clear();
396
+ for (const event of ['pointerdown', 'keydown', 'input']) document.removeEventListener(event, interaction, true);
397
+ window.removeEventListener('pagehide', close);
398
+ for (const controller of requests) controller.abort();
399
+ for (const listener of pool.viewListeners) listener();
400
+ } };
401
+ return client;
72
402
  }
73
- // ---- end first-run guide ----
74
403
 
75
- const { useState, useEffect, useRef, useId } = React;
404
+ /* STARDUSTLC_UPDATE_CLIENT_BODY_START */
405
+ // Generated from templates/client.js, templates/panels/ and templates/workbench-ui.js. Edit the sources.
406
+ (function () {
407
+ /* DSH workbench UI v1. MIT. Canonical source: dsh-suite/ui/workbench-ui.js.
408
+ * Vendored into each plugin: no Suite or extra runtime dependency is required.
409
+ * Styles are scoped to .dshw and never replace the host chrome or theme.
410
+ */
411
+ function createWorkbenchUI(React) {
76
412
  const h = React.createElement;
77
- const ROUTE = '_dsh/dsh-rss/subscriptions';
78
- let language = 'zh';
79
- const listeners = new Set();
80
- const words = {
81
- title: ['RSS 订阅', 'RSS subscriptions'], intro: ['在这里管理订阅,也可以在对话里让 AI 读取和搜索文章。', 'Manage feeds here, then ask AI to read or search articles in a conversation.'],
82
- recommended: ['推荐订阅源', 'Recommended feeds'], manual: ['输入地址', 'Enter a URL'],
83
- catalogHint: ['先选感兴趣的分类,再预览或订阅。不会默认添加,也不会自动访问所有网站。', 'Choose a topic, then preview or subscribe. Feeds are not added by default and websites are not contacted automatically.'],
84
- networkHint: ['可用性取决于你当前的网络,国内外网站可能不同。预览失败可以重试,或改选其他来源。', 'Availability depends on your current network and can differ by website. Retry a failed preview or choose another source.'],
85
- sourceSearch: ['搜索来源或关键词', 'Search sources or keywords'], sourceLanguage: ['内容语言', 'Content language'], anyLanguage: ['全部语言', 'All languages'], chinese: ['中文', 'Chinese'], english: ['英文', 'English'],
86
- native: ['网站原生 RSS / Atom', 'Publisher RSS / Atom'], website: ['来源网站', 'Source website'], previewArticles: ['预览并检查', 'Preview and check'], subscribe: ['订阅', 'Subscribe'], subscribed: ['已订阅', 'Subscribed'],
87
- recentArticles: ['近期文章(最多 5 篇)', 'Recent articles (up to 5)'], noRecentArticles: ['订阅格式有效,但此时没有文章。有些来源只在发布日提供条目。', 'The feed is valid but currently empty. Some sources only include entries on publication days.'], noTitle: ['无标题', 'Untitled'],
88
- customCategory: ['可选现有分类,也可填写自定义分类。已有分类原样保留。', 'Choose an existing category or type your own. Existing categories are preserved.'],
89
- rsshubHint: ['其他网站:可在“输入地址”添加原生订阅,或粘贴你选择的 RSSHub 实例生成的地址。', 'For other sites, use “Enter a URL” with a native feed or a URL generated by your chosen RSSHub instance.'],
90
- add: ['添加订阅', 'Add feed'], import: ['导入 OPML', 'Import OPML'], export: ['导出 OPML', 'Export OPML'], refresh: ['刷新列表', 'Refresh list'],
91
- search: ['搜索名称或地址', 'Search name or URL'], category: ['分类', 'Category'], all: ['全部分类', 'All categories'], uncategorized: ['未分类', 'Uncategorized'],
92
- name: ['显示名称', 'Display name'], nameHint: ['留空时使用订阅源的标题', 'Leave blank to use the feed title'], url: ['订阅源地址', 'Feed URL'], categoryHint: ['例如:科技、阅读', 'For example: Tech, Reading'],
93
- save: ['保存订阅', 'Save feed'], saving: ['正在处理…', 'Working…'], cancel: ['取消', 'Cancel'], close: ['关闭', 'Close'], edit: ['编辑', 'Edit'], remove: ['移除', 'Remove'], check: ['检查可用性', 'Check feed'],
94
- empty: ['还没有订阅', 'No subscriptions yet'], emptyHint: ['从推荐目录选几个感兴趣的来源,也可以输入 RSS/Atom 地址或导入 OPML。', 'Choose sources from the recommended catalog, enter an RSS/Atom URL, or import OPML.'], noMatch: ['没有匹配项,试试清空筛选。', 'No matches. Try clearing the filters.'], clear: ['清空筛选', 'Clear filters'],
95
- readonly: ['当前配置为只读。你可以查看、检查和导出订阅。', 'These settings are read-only. You can view, check and export feeds.'],
96
- pending: ['本次运行尚未检查', 'Not checked during this run'], entries: ['篇文章', 'articles'], checked: ['检查通过', 'Check passed'], failed: ['检查失败', 'Check failed'],
97
- statusHint: ['检查记录仅保留在本次 DSH 运行中;导入不会自动抓取所有订阅。', 'Check history lasts for this DSH run. Import does not fetch every feed.'],
98
- deleteTitle: ['移除这个订阅?', 'Remove this feed?'], deleteHint: ['只移除订阅,不会删除原网站的文章。', 'This removes the subscription; the original articles remain on the website.'],
99
- opml: ['OPML 文本', 'OPML text'], file: ['选择 OPML 文件', 'Choose OPML file'], importHint: ['选择文件或粘贴内容,先预览,再确认导入。最多 1 MiB。', 'Choose a file or paste its content, preview, then confirm. Maximum 1 MiB.'],
100
- update: ['用导入文件的名称和分类更新重复订阅', 'Update duplicate names and categories from this file'], preserve: ['默认保留现有订阅的名称和分类。', 'Existing names and categories are preserved by default.'],
101
- preview: ['预览导入', 'Preview import'], confirm: ['确认导入', 'Confirm import'], new: ['新增', 'New'], duplicates: ['重复', 'Duplicates'], invalid: ['跳过无效项', 'Invalid items skipped'], previewEmpty: ['文件中没有可导入的订阅。请确认 outline 包含 xmlUrl。', 'No importable feeds. Check that outlines contain xmlUrl.'],
102
- keep: ['保留', 'Keep'], change: ['更新为', 'Change to'],
103
- previewLimit: ['预览最多显示前 20 项,确认会处理全部有效项。', 'Preview shows up to 20 items. Confirmation processes all valid items.'], saved: ['订阅已保存', 'Feed saved'], removed: ['订阅已移除', 'Feed removed'], imported: ['导入完成', 'Import complete'], downloaded: ['已下载 OPML 文件', 'OPML downloaded'],
104
- loading: ['正在读取订阅…', 'Loading subscriptions…'], retry: ['重新读取', 'Retry'], loadError: ['无法读取订阅。请确认 DSH 仍在运行,然后重试。', 'Cannot load feeds. Check that DSH is running, then retry.'],
105
- conflict: ['订阅列表已变化,请刷新列表,再保存或重新预览。输入已保留。', 'The list has changed. Refresh it, then save or preview again. Your input is preserved.'], duplicate: ['这个地址已经订阅,请编辑现有订阅。', 'This URL is already subscribed. Edit the existing feed.'],
106
- bodyLarge: ['文件超过 1 MiB,请拆分后导入。', 'File exceeds 1 MiB. Split it before importing.'], session: ['DSH 会话已失效,请重新打开 DSH 页面。', 'The DSH session has expired. Reopen the DSH page.'], fileError: ['无法读取文件,请重新选择或粘贴 OPML 文本。', 'Cannot read this file. Choose it again or paste OPML text.'],
413
+ const { useEffect, useId, useRef } = React;
414
+ const cx = (...values) => values.filter(Boolean).join(' ');
415
+ const paths = {
416
+ book: ['M4 4h6a3 3 0 0 1 2 2v15a4 4 0 0 0-4-2H4z', 'M20 4h-6a3 3 0 0 0-2 2v15a4 4 0 0 1 4-2h4z'],
417
+ calendar: ['M5 5h14a2 2 0 0 1 2 2v13H3V7a2 2 0 0 1 2-2Z', 'M7 3v4M17 3v4M3 10h18'],
418
+ mail: ['M3 5h18v14H3z', 'm3 6 9 7 9-7'],
419
+ rss: ['M4 11a9 9 0 0 1 9 9M4 4a16 16 0 0 1 16 16', 'M4 19h.01'],
420
+ slides: ['M3 4h18v13H3z', 'M12 17v4M8 21h8'],
421
+ shield: ['m12 3 8 3v6c0 4-4 7-8 9-4-2-8-5-8-9V6z', 'm8 12 3 3 5-6'],
422
+ layers: ['M5 3h16v16H5z', 'M2 7v15h15'],
423
+ play: ['m9 6 9 6-9 6Z'],
424
+ video: ['M3 5h12v14H3z', 'm15 10 6-4v12l-6-4'],
425
+ search: ['M10.5 18a7.5 7.5 0 1 0 0-15 7.5 7.5 0 0 0 0 15Z', 'm16 16 5 5'],
426
+ plus: ['M12 5v14M5 12h14'],
427
+ refresh: ['M20 7a9 9 0 1 0 1 8', 'M20 2v5h-5'],
428
+ settings: ['m9 3-.7 2.4-2 .9L4 5.8 2.5 8.4l1.7 1.8v2.3L2.5 14 4 17l2.5-.4 1.9 1L9 20h3l.8-2.4 2-1 2.5.4 1.5-2.7-1.7-1.9v-2.2l1.7-1.8-1.5-2.6-2.5.4-2-1L12 3Z', 'M14 11.5a3.5 3.5 0 1 1-7 0 3.5 3.5 0 0 1 7 0Z'],
429
+ close: ['m6 6 12 12M18 6 6 18'],
430
+ left: ['m14 5-7 7 7 7'],
431
+ right: ['m10 5 7 7-7 7'],
432
+ down: ['m5 9 7 7 7-7'],
433
+ filter: ['M4 5h16M7 12h10M10 19h4'],
434
+ download: ['M12 3v12m-5-5 5 5 5-5', 'M4 16v5h16v-5'],
435
+ upload: ['M12 16V4m-5 5 5-5 5 5', 'M4 16v5h16v-5'],
436
+ copy: ['M8 8h13v13H8z', 'M16 8V3H3v13h5'],
437
+ external: ['M14 3h7v7m0-7L10 14', 'M10 3H3v18h18v-7'],
438
+ file: ['M4 3h10l6 6v12H4z', 'M14 3v6h6M8 13h8M8 17h6'],
439
+ folder: ['M3 5h7l2 3h9v12H3z'],
440
+ edit: ['m15 4 5 5-10 10-6 1 1-6Z', 'm13 6 5 5'],
441
+ trash: ['M3 6h18M9 6V3h6v3M5 6l1 15h12l1-15M10 10v7M14 10v7'],
442
+ more: ['M5 12h.01M12 12h.01M19 12h.01'],
443
+ info: ['M12 22a10 10 0 1 0 0-20 10 10 0 0 0 0 20Z', 'M12 11v6M12 7h.01'],
444
+ check: ['m5 12 4 4L19 6'],
445
+ quote: ['M4 12h6v7H3v-7c0-4 2-6 5-7M15 12h6v7h-7v-7c0-4 2-6 5-7'],
446
+ star: ['m12 3 2.8 5.7 6.2.9-4.5 4.4 1.1 6.2-5.6-3-5.6 3 1.1-6.2L3 9.6l6.2-.9Z'],
447
+ reply: ['m9 5-7 7 7 7v-5h6c3 0 5 2 6 5 0-8-4-11-12-11Z'],
448
+ link: ['m10 13 4-4M8 16l-2 2a4 4 0 0 1-6-6l4-4a4 4 0 0 1 6 0', 'm14 8 2-2a4 4 0 0 1 6 6l-4 4a4 4 0 0 1-6 0'],
107
449
  };
108
- const t = key => (words[key] || [key, key])[language === 'en' ? 1 : 0];
109
- const localized = value => value?.[language === 'en' ? 1 : 0] || '';
110
-
111
- function feedError(message, code) {
112
- if (language !== 'en' || !/[\u3400-\u9fff]/.test(message || '')) return message;
113
- if (['conflict', 'duplicate', 'readonly', 'bodyLarge', 'session'].includes(code)) return t(code);
114
- if (/HTTP/.test(message)) return 'Feed request failed. Check the URL, connection and proxy settings, then retry.';
115
- if (/YAML|feedsYaml/.test(message)) return 'The feed configuration is invalid. Fix the feedsYaml list in settings before retrying.';
116
- if (/OPML|outline|xmlUrl/.test(message)) return 'The OPML content is invalid. Export it again with xmlUrl attributes on feed outlines.';
117
- if (/地址|URL|url|http|https|协议/.test(message)) return 'Enter a valid HTTP or HTTPS feed URL. Local and private-network addresses are not allowed.';
118
- if (/写入|只读/.test(message)) return 'Could not save the feed configuration. Check write access and reload the list before retrying; your input is preserved.';
119
- if (/未找到|找不到|没有找到/.test(message)) return 'No matching feed was found. Refresh the subscription list.';
120
- return 'The feed could not be read. Check the URL, network and proxy settings, then retry.';
450
+ function Icon({ name = 'file', size = 20, ...props }) {
451
+ return h('svg', { width: size, height: size, viewBox: '0 0 24 24', fill: 'none', stroke: 'currentColor', strokeWidth: 1.75, strokeLinecap: 'round', strokeLinejoin: 'round', 'aria-hidden': true, focusable: false, ...props },
452
+ (paths[name] || paths.file).map((d, index) => h('path', { key: index, d })));
121
453
  }
454
+ function Button({ children, icon, variant, className, ...props }) {
455
+ return h('button', { type: 'button', ...props, className: cx('w-button', variant && 'w-' + variant, className) }, icon ? h(Icon, { name: icon, size: 18 }) : null, children);
456
+ }
457
+ function IconButton({ label, icon, ...props }) {
458
+ return h(Button, { ...props, icon, className: cx('w-icon-button', props.className), 'aria-label': label, title: label });
459
+ }
460
+ function Page({ title, subtitle, actions, children, workbench = false, className, rootRef, ...props }) {
461
+ return h('section', { ...props, ref: rootRef, className: cx('dshw', 'w-page', className), 'data-main': workbench ? 'true' : 'false' },
462
+ h('style', null, styles),
463
+ h('header', { className: 'w-page-header' }, h('div', { className: 'w-heading' }, h('h1', null, title), subtitle ? h('p', { className: 'w-subtitle' }, subtitle) : null), actions ? h('div', { className: 'w-header-actions' }, actions) : null),
464
+ h('div', { className: 'w-body' }, children));
465
+ }
466
+ function Tabs({ items, value, onChange, label, children }) {
467
+ const id = useId();
468
+ const active = items.some(item => item.id === value) ? value : items[0]?.id;
469
+ function keys(event, index) {
470
+ if (!['ArrowLeft', 'ArrowRight', 'Home', 'End'].includes(event.key)) return;
471
+ event.preventDefault();
472
+ const next = event.key === 'Home' ? 0 : event.key === 'End' ? items.length - 1 : (index + (event.key === 'ArrowRight' ? 1 : -1) + items.length) % items.length;
473
+ const node = event.currentTarget.parentElement?.querySelectorAll('[role=tab]')[next];
474
+ if (node) { onChange(items[next].id); node.focus(); }
475
+ }
476
+ return h('div', { className: 'w-tabs-layout' },
477
+ h('div', { className: 'w-tabs', role: 'tablist', 'aria-label': label }, items.map((item, index) => h('button', {
478
+ type: 'button', role: 'tab', key: item.id, id: id + '-' + item.id, 'aria-controls': id + '-panel', 'aria-selected': active === item.id, tabIndex: active === item.id ? 0 : -1,
479
+ onClick: () => onChange(item.id), onKeyDown: event => keys(event, index),
480
+ }, item.label, item.count !== undefined ? h('span', { className: 'w-count' }, item.count) : null))),
481
+ h('div', { className: 'w-tab-panel', id: id + '-panel', role: 'tabpanel', 'aria-labelledby': id + '-' + active }, children));
482
+ }
483
+ function Status({ children, tone = 'info', className }) {
484
+ if (!children) return null;
485
+ return h('div', { className: cx('w-status', 'w-status-' + tone, className), role: tone === 'error' ? 'alert' : 'status', 'aria-live': tone === 'error' ? 'assertive' : 'polite' }, h(Icon, { name: tone === 'success' ? 'check' : 'info', size: 18 }), h('div', null, children));
486
+ }
487
+ function Empty({ title, children, action, icon = 'file' }) {
488
+ return h('div', { className: 'w-empty' }, h(Icon, { name: icon, size: 32 }), h('h2', null, title), children ? h('div', { className: 'w-muted' }, children) : null, action ? h('div', { className: 'w-toolbar' }, action) : null);
489
+ }
490
+ function Split({ list, detail, selected, onBack, backLabel, className, listWidth = 360 }) {
491
+ const ref = useRef(null);
492
+ useEffect(() => {
493
+ if (!selected || !ref.current || ref.current.clientWidth > 760) return;
494
+ const heading = ref.current.querySelector('.w-detail h2');
495
+ if (heading) { heading.tabIndex = -1; heading.focus({ preventScroll: true }); }
496
+ }, [selected]);
497
+ return h('div', { ref, className: cx('w-split', className), 'data-selected': selected ? 'true' : 'false', style: { '--w-list-width': listWidth + 'px' } },
498
+ h('div', { className: 'w-master' }, list),
499
+ h('div', { className: 'w-detail' }, selected ? h(Button, { className: 'w-back', icon: 'left', variant: 'ghost', onClick: onBack }, backLabel) : null, detail));
500
+ }
501
+ function Row({ title, meta, description, active, onClick, children, status, className, disabled }) {
502
+ return h('div', { className: cx('w-row', active && 'w-selected', className) },
503
+ children ? h('div', { className: 'w-row-select' }, children) : null,
504
+ h('button', { type: 'button', className: 'w-row-button', onClick, disabled, 'aria-pressed': !!active },
505
+ h('span', { className: 'w-row-head' }, h('strong', null, title), status ? h('span', { className: 'w-tag' }, status) : null),
506
+ meta ? h('span', { className: 'w-row-meta' }, meta) : null,
507
+ description ? h('span', { className: 'w-row-description' }, description) : null));
508
+ }
509
+ function Search({ label, value, onChange, ...props }) {
510
+ const id = useId();
511
+ return h('div', { className: 'w-search' }, h(Icon, { name: 'search', size: 18 }), h('input', { type: 'search', id, 'aria-label': label, placeholder: label, value, onChange, ...props }));
512
+ }
513
+ function Switch({ label, checked, onChange, disabled }) {
514
+ return h('label', { className: 'w-switch-label' }, h('span', null, label), h('input', { type: 'checkbox', role: 'switch', checked, disabled, onChange, 'aria-label': label }), h('span', { className: 'w-switch-track', 'aria-hidden': true }));
515
+ }
516
+ function Dialog({ title, children, onClose, closeLabel, className, busy = false }) {
517
+ const id = useId(), panel = useRef(null);
518
+ useEffect(() => {
519
+ const previous = document.activeElement;
520
+ panel.current?.querySelector('button:not(:disabled), input:not(:disabled), select:not(:disabled), textarea:not(:disabled), [tabindex="0"]')?.focus();
521
+ return () => { if (previous?.isConnected) previous.focus({ preventScroll: true }); };
522
+ }, []);
523
+ function keydown(event) {
524
+ if (event.key === 'Escape' && !event.isComposing) { event.preventDefault(); event.stopPropagation(); if (!busy) onClose(); return; }
525
+ if (event.key !== 'Tab') return;
526
+ const controls = [...panel.current.querySelectorAll('button:not(:disabled), input:not(:disabled), select:not(:disabled), textarea:not(:disabled), a[href], [tabindex="0"]')].filter(node => node.getClientRects().length);
527
+ const first = controls[0], last = controls.at(-1);
528
+ if (!controls.length) { event.preventDefault(); panel.current.focus(); }
529
+ else if (event.shiftKey && document.activeElement === first) { event.preventDefault(); last.focus(); }
530
+ else if (!event.shiftKey && document.activeElement === last) { event.preventDefault(); first.focus(); }
531
+ }
532
+ return h('div', { className: 'w-overlay', onClick: event => { if (!busy && event.target === event.currentTarget) onClose(); } },
533
+ h('section', { ref: panel, className: cx('w-dialog', className), role: 'dialog', 'aria-modal': true, 'aria-labelledby': id, tabIndex: -1, onKeyDown: keydown },
534
+ h('header', { className: 'w-dialog-header' }, h('h2', { id }, title), h(IconButton, { icon: 'close', label: closeLabel, disabled: busy, onClick: onClose })), h('div', { className: 'w-dialog-body' }, children)));
535
+ }
536
+ function register(ctx, { id, label, icon, component, inject, order = 50 }) {
537
+ // The two slots are optional. Existing settings and manual tools still load
538
+ // in hosts without a workbench, while RC.3 owns navigation/pinning itself.
539
+ ctx.slots.inject('main', () => ctx.slots.register({ name: 'main', key: id, inject: () => ({ ...(inject?.() || {}), workbench: true }) }, component));
540
+ ctx.slots.inject('sidebar.panellist', () => ctx.slots.register({ name: 'sidebar.panellist', id, order, label }, function WorkbenchIcon({ size }) { return h(Icon, { name: icon, size }); }));
541
+ }
542
+ const styles = `
543
+ .dshw{--w-bg:var(--dsw-alias-bg-layer-1,#fff);--w-soft:var(--dsw-alias-bg-layer-2,#f7f8fa);--w-text:var(--dsw-alias-label-primary,#18202c);--w-muted:var(--dsw-alias-label-secondary,#667085);--w-border:var(--dsw-alias-border-l3,#e7e9ef);--w-accent:var(--dsh-plugin-workbench-accent,#4f6bdb);--w-selected:color-mix(in srgb,var(--w-accent) 10%,var(--w-bg));--w-primary:var(--w-text);--w-on-primary:var(--w-bg);container-type:inline-size;container-name:dsh-workbench;color:var(--w-text);background:var(--w-bg);font:14px/1.65 var(--dsh-font-family-content,system-ui,-apple-system,"Segoe UI","Microsoft YaHei",sans-serif);min-width:0;max-width:100%;box-sizing:border-box;text-align:start;color-scheme:inherit}
544
+ .dshw *,.dshw *:before,.dshw *:after{box-sizing:border-box}.dshw h1,.dshw h2,.dshw h3,.dshw h4,.dshw p{margin:0}.dshw h1{font-size:30px;line-height:1.25;letter-spacing:-.025em;font-weight:650}.dshw h2{font-size:24px;line-height:1.35;font-weight:650;letter-spacing:-.015em;overflow-wrap:anywhere}.dshw h3,.dshw h4{font-size:16px;line-height:1.4;font-weight:600}.dshw a{color:var(--w-accent);text-underline-offset:3px;overflow-wrap:anywhere}.dshw button,.dshw input,.dshw select,.dshw textarea{font:inherit;color:inherit;max-width:100%}.dshw input:not([type=checkbox]):not([type=radio]):not([type=file]),.dshw select,.dshw textarea{background:var(--w-bg);border:1px solid var(--w-border);border-radius:8px;padding:8px 11px;min-width:0;line-height:1.5}.dshw input:not([type=checkbox]):not([type=radio]):not([type=file]),.dshw select{min-height:38px}.dshw textarea{resize:vertical}.dshw input[type=checkbox],.dshw input[type=radio]{width:16px;height:16px;flex-shrink:0;accent-color:var(--w-accent)}.dshw :focus-visible{outline:2px solid var(--w-accent);outline-offset:3px}.dshw button:disabled,.dshw input:disabled,.dshw select:disabled,.dshw textarea:disabled{opacity:.5;cursor:not-allowed}.dshw label{font-size:13px}.dshw fieldset{min-width:0;border:1px solid var(--w-border);border-radius:8px}.dshw summary{cursor:pointer;font-weight:550;list-style:none;display:flex;align-items:center;gap:8px}.dshw summary::-webkit-details-marker{display:none}.dshw summary:after{content:'';display:block;margin-inline-start:auto;width:7px;height:7px;border-inline-end:1.75px solid currentColor;border-bottom:1.75px solid currentColor;transform:rotate(45deg);flex-shrink:0}.dshw details[open]>summary:after{transform:rotate(225deg)}.dshw details>summary+*{margin-top:12px}.dshw pre{white-space:pre-wrap;overflow-wrap:anywhere;font:12px/1.7 ui-monospace,SFMono-Regular,Consolas,monospace;max-width:100%;background:var(--w-soft);border-radius:6px;padding:14px}.dshw img,.dshw video,.dshw iframe{max-width:100%}
545
+ .w-page{display:flex;flex-direction:column;position:relative;padding:0;min-height:540px;gap:0}.w-page[data-main=true]{height:100%;min-height:0;padding:calc(24px + var(--dsh-frame-top-clearance,0px)) 28px 0 max(28px,var(--dsh-frame-leading-clearance,0px));overflow:auto}.w-page-header{display:flex;justify-content:space-between;gap:24px;align-items:flex-start;padding-bottom:22px;flex-shrink:0}.w-heading{min-width:0}.w-subtitle{margin-top:8px!important;font-size:14px;color:var(--w-muted);line-height:1.6}.w-header-actions,.w-toolbar,.w-actions{display:flex;align-items:center;flex-wrap:wrap;gap:8px;min-width:0}.w-header-actions{justify-content:flex-end}.w-body,.w-tabs-layout{display:flex;flex-direction:column;flex:1;min-height:0;min-width:0}.w-body{overflow:auto}.w-tab-panel{flex:1;min-width:0;min-height:0;display:flex;flex-direction:column;overflow:auto}.w-tabs{display:flex;align-items:stretch;gap:20px;border-bottom:1px solid var(--w-border);flex-shrink:0;overflow-x:auto;scrollbar-width:thin}.dshw .w-tabs>button{border:0;border-bottom:2px solid transparent;background:transparent;padding:11px 8px 13px;white-space:nowrap;font-size:14px;font-weight:550;cursor:pointer;color:var(--w-muted);display:flex;align-items:center;gap:7px}.dshw .w-tabs>button[aria-selected=true]{border-bottom-color:var(--w-accent);color:var(--w-accent)}.w-count,.w-tag{font-size:12px;line-height:1.5;display:inline-flex;align-items:center;flex-shrink:0;background:var(--w-soft);border-radius:5px;padding:1px 6px;color:var(--w-muted)}.w-tabs [aria-selected=true] .w-count,.w-selected .w-tag{color:var(--w-accent);background:var(--w-selected)}
546
+ .dshw .w-button{display:inline-flex;justify-content:center;align-items:center;gap:7px;background:var(--w-bg);border:1px solid var(--w-border);border-radius:8px;padding:8px 12px;min-height:36px;line-height:1.4;font-size:14px;font-weight:500;cursor:pointer;text-decoration:none;white-space:normal}.dshw .w-button:not(:disabled):hover{background:var(--w-soft)}.dshw .w-primary{background:var(--w-primary);border-color:var(--w-primary);color:var(--w-on-primary)}.dshw .w-primary:not(:disabled):hover{background:var(--w-primary);opacity:.9}.dshw .w-ghost{background:transparent;border-color:transparent}.dshw .w-danger{color:var(--dsw-alias-state-error-primary,#b43c3c)}.dshw .w-icon-button{width:36px;min-width:36px;padding:8px}.dshw .w-button svg{flex-shrink:0}.w-muted{color:var(--w-muted);font-size:12px;line-height:1.6}.w-section{padding:24px 0;border-bottom:1px solid var(--w-border);min-width:0}.w-section>h3{margin-bottom:12px}.w-section>p+p{margin-top:8px}.w-fields{display:grid;gap:16px;min-width:0}.w-field{display:grid;gap:6px;min-width:0}.w-field>input,.w-field>select,.w-field>textarea{width:100%}.w-status{display:flex;align-items:flex-start;gap:8px;padding:11px 13px;margin:12px 0;border:1px solid var(--w-border);border-radius:8px;background:var(--w-soft);font-size:13px;overflow-wrap:anywhere;flex-shrink:0}.w-status>svg{flex-shrink:0;margin-top:2px}.w-status-error{color:var(--dsw-alias-state-error-primary,#ad3636)}.w-status-success{color:var(--dsw-alias-state-success-primary,#24794a)}.w-empty{display:flex;flex-direction:column;align-items:center;justify-content:center;text-align:center;gap:14px;max-width:580px;padding:48px 24px;margin:auto;min-height:280px;overflow-wrap:anywhere}.w-empty>svg{color:var(--w-muted)}.w-empty h2{font-size:20px}.w-empty .w-muted{font-size:14px}.w-empty .w-toolbar{justify-content:center}
547
+ .w-split{display:grid;grid-template-columns:minmax(240px,var(--w-list-width)) minmax(0,1fr);min-height:460px;flex:1;min-width:0}.w-master{min-width:0;border-inline-end:1px solid var(--w-border);overflow:auto;padding-bottom:24px}.w-detail{min-width:0;padding:26px 28px;overflow:auto;overflow-wrap:anywhere;display:flex;flex-direction:column}.w-master-toolbar{display:flex;align-items:center;gap:8px;flex-wrap:wrap;padding:20px 16px}.w-search{display:flex;align-items:center;gap:8px;border:1px solid var(--w-border);border-radius:8px;padding:0 10px;min-width:0;flex:1;background:var(--w-bg)}.w-search>svg{color:var(--w-muted);flex-shrink:0}.dshw .w-search>input{border:0!important;background:transparent!important;padding:8px 0!important;width:100%;outline-offset:0}.w-row{display:flex;gap:0;min-width:0;position:relative;border-bottom:1px solid var(--w-border);border-inline-start:3px solid transparent}.w-row-select{display:flex;align-items:flex-start;padding:21px 0 0 14px}.dshw .w-row-button{display:flex;flex-direction:column;align-items:stretch;gap:7px;text-align:start;width:100%;padding:18px 18px 18px 16px;border:0;background:transparent;color:inherit;min-width:0;cursor:pointer;line-height:1.5}.dshw .w-row-button:hover{background:var(--w-soft)}.w-row-head{display:flex;align-items:flex-start;gap:10px;justify-content:space-between;min-width:0}.w-row-head>strong{font-size:14px;line-height:1.5;font-weight:600;overflow-wrap:anywhere}.w-row-meta,.w-row-description{color:var(--w-muted);font-size:12px;line-height:1.6;overflow-wrap:anywhere}.w-row-description{display:-webkit-box;-webkit-line-clamp:2;-webkit-box-orient:vertical;overflow:hidden}.w-selected{background:var(--w-selected);border-inline-start-color:var(--w-accent)}.w-back{display:none!important}.w-detail-title{margin-bottom:12px!important}.w-detail-meta{color:var(--w-muted);font-size:13px;display:flex;align-items:center;gap:8px;flex-wrap:wrap}.w-detail-footer{padding:24px 0;display:flex;align-items:center;gap:10px;flex-wrap:wrap;margin-top:auto;border-top:1px solid var(--w-border)}.w-detail-footer .w-muted{flex:1;min-width:160px}.w-definition{display:grid;grid-template-columns:minmax(80px,120px) minmax(0,1fr);gap:8px 16px;font-size:14px;margin:20px 0}.w-definition dt{color:var(--w-muted)}.w-definition dd{margin:0;min-width:0;overflow-wrap:anywhere}
548
+ .w-switch-label{display:inline-flex;align-items:center;gap:8px;font-size:13px;position:relative;cursor:pointer}.w-switch-label>input{position:absolute;opacity:0;inset-inline-end:0;width:36px!important;height:22px!important;margin:0;cursor:pointer}.w-switch-track{width:36px;height:22px;border-radius:12px;display:block;background:var(--w-border);border:1px solid var(--w-border);pointer-events:none;padding:2px;transition:background .15s}.w-switch-track:before{content:'';display:block;width:16px;height:16px;border-radius:50%;background:#fff;box-shadow:0 1px 2px #0002;transition:transform .15s}.w-switch-label>input:checked+.w-switch-track{background:var(--w-accent);border-color:var(--w-accent)}.w-switch-label>input:checked+.w-switch-track:before{transform:translateX(14px)}.w-switch-label>input:focus-visible+.w-switch-track{outline:2px solid var(--w-accent);outline-offset:3px}.w-switch-label:has(>input:disabled){opacity:.5;cursor:not-allowed}
549
+ .w-overlay{position:fixed;inset:0;background:#0005;display:flex;justify-content:flex-end;z-index:1000;padding:12px;overflow:auto}.w-dialog{width:min(620px,100%);max-height:100%;display:flex;flex-direction:column;min-height:0;background:var(--w-bg);color:var(--w-text);border:1px solid var(--w-border);border-radius:12px;box-shadow:0 18px 70px #0003}.w-dialog-header{display:flex;justify-content:space-between;align-items:center;gap:16px;padding:20px 24px;border-bottom:1px solid var(--w-border);flex-shrink:0}.w-dialog-header>h2{font-size:20px}.w-dialog-body{overflow:auto;padding:20px 24px;min-height:0}.w-editor-grid{display:grid;grid-template-columns:210px minmax(0,1fr) 300px;min-height:500px;flex:1}.w-editor-list{padding:20px 12px;border-inline-end:1px solid var(--w-border);min-width:0}.w-editor-canvas{background:var(--w-soft);padding:20px;min-width:0;display:flex;flex-direction:column;gap:14px}.w-editor-inspector{padding:24px;border-inline-start:1px solid var(--w-border);min-width:0;overflow:auto}.w-editor-inspector h3{margin-bottom:18px}.w-preview-empty{display:flex;flex-direction:column;justify-content:center;align-items:center;text-align:center;gap:12px;aspect-ratio:16/9;min-height:180px;background:var(--w-soft);border:1px solid var(--w-border);border-radius:8px;padding:24px;color:var(--w-muted)}.w-content-pad{padding:24px 0}.w-stack{display:flex;flex-direction:column;gap:16px;min-width:0}.w-scroll-x{overflow:auto;max-width:100%}
550
+ @container dsh-workbench (max-width:1000px){.w-editor-grid{grid-template-columns:160px minmax(0,1fr)}.w-editor-inspector{grid-column:1/-1;border-inline-start:0;border-top:1px solid var(--w-border)}.w-header-actions{max-width:60%}.w-split{grid-template-columns:minmax(240px,32%) minmax(0,1fr)}}
551
+ @container dsh-workbench (max-width:760px){.w-page-header{gap:14px;flex-wrap:wrap;padding-bottom:18px}.w-heading{flex:1;min-width:170px}.dshw h1{font-size:24px}.w-header-actions{max-width:100%;justify-content:flex-start}.w-subtitle{font-size:13px}.w-tabs{gap:12px}.dshw .w-tabs>button{padding:10px 4px 12px}.w-split{display:block;min-height:360px}.w-split[data-selected=false]>.w-detail{display:none}.w-split[data-selected=true]>.w-master{display:none}.w-master{border-inline-end:0}.w-detail{padding:20px 0}.w-back{display:inline-flex!important;align-self:flex-start;margin:0 0 16px!important}.w-detail h2{font-size:22px}.w-master-toolbar{padding:16px 0}.dshw .w-row-button{padding:16px 10px}.w-detail-footer{position:static}.w-detail-footer .w-muted{flex-basis:100%}.w-editor-grid{display:flex;flex-direction:column}.w-editor-list{border-inline-end:0;border-bottom:1px solid var(--w-border);padding:16px 0}.w-editor-canvas{padding:16px 0;background:var(--w-bg)}.w-editor-inspector{padding:20px 0}.w-dialog-header,.w-dialog-body{padding:16px}.w-button{min-height:40px}.w-definition{grid-template-columns:80px minmax(0,1fr)}}
552
+ @media(max-width:700px){.w-page[data-main=true]{padding:calc(16px + var(--dsh-frame-top-clearance,0px)) 16px 0 max(16px,var(--dsh-frame-leading-clearance,0px))}.w-overlay{padding:8px}.w-dialog{width:100%}}
553
+ @media(prefers-reduced-motion:reduce){.dshw *,.dshw *:before{scroll-behavior:auto!important;transition:none!important;animation:none!important}}
554
+ `;
555
+ return { Icon, Button, IconButton, Page, Tabs, Status, Empty, Split, Row, Search, Switch, Dialog, register, styles };
556
+ }
557
+
558
+ // Editable browser entry. Build with node scripts/build-client.mjs.
559
+ window.__ModuleLoader__.load(__stardustUpdatesWrap({ id: 'dsh-rss', factory: require => {
560
+ const React = require('react');
561
+ const W = createWorkbenchUI(React);
562
+ function rssText(zh, en) { return language === 'en' ? en : zh; }
563
+
564
+ function RssArticlePreview({ value }) {
565
+ return h('section', { className: 'w-section rss-articles' },
566
+ h('h3', null, t('recentArticles')),
567
+ !value ? h('p', { className: 'w-muted' }, rssText('点击“检查并预览”后获取近期条目,不会因打开此页而访问来源。', 'Choose Check and preview to fetch recent entries. Opening this page does not contact the source.')) :
568
+ h(React.Fragment, null,
569
+ h('p', { className: 'w-muted' }, new Date(value.checkedAt).toLocaleString(language === 'en' ? 'en-US' : 'zh-CN')),
570
+ value.entries.length ? h('ul', { className: 'rss-article-list' }, value.entries.map((entry, index) => h('li', { key: index },
571
+ entry.link ? h('a', { href: entry.link, target: '_blank', rel: 'noopener noreferrer' }, entry.title || t('noTitle')) : h('strong', null, entry.title || t('noTitle')),
572
+ entry.pubDate && !Number.isNaN(Date.parse(entry.pubDate)) ? h('p', { className: 'w-muted' }, new Date(entry.pubDate).toLocaleDateString(language === 'en' ? 'en-US' : 'zh-CN')) : null))) : h('p', { className: 'w-muted' }, t('noRecentArticles'))));
573
+ }
122
574
 
123
- const CSS = `
575
+ function RssFeedBrowser({ feeds, filtered, categories, query, setQuery, category, setCategory, writable, busy, run, open }) {
576
+ const [activeId, setActiveId] = useState(null), [previews, setPreviews] = useState({});
577
+ const active = filtered.find(feed => feed.id === activeId) || filtered[0];
578
+ if (!feeds.length) return h(W.Empty, { title: t('empty'), icon: 'rss', action: h(W.Button, { onClick: event => open('feed', null, event), disabled: !writable || !!busy }, t('add')) }, t('emptyHint'));
579
+ return h(W.Split, { selected: activeId && filtered.some(feed => feed.id === activeId) ? activeId : null, onBack: () => setActiveId(null), backLabel: rssText('返回订阅列表', 'Back to feeds'), listWidth: 380,
580
+ list: h('div', null,
581
+ h('div', { className: 'w-master-toolbar' }, h(W.Search, { label: t('search'), value: query, onChange: event => { setQuery(event.target.value); setActiveId(null); } }), h(W.IconButton, { icon: 'refresh', label: t('refresh'), disabled: !!busy, onClick: () => run(null) })),
582
+ h('div', { className: 'rss-list-filter' }, h('select', { 'aria-label': t('category'), value: category, onChange: event => { setCategory(event.target.value); setActiveId(null); } }, h('option', { value: '*' }, t('all')), categories.map(value => h('option', { key: value, value }, value || t('uncategorized'))))),
583
+ filtered.map(feed => h(W.Row, { key: feed.id, title: feed.name || feed.url, active: feed.id === active?.id, meta: feed.url, description: feed.category || t('uncategorized'), status: feed.check ? t(feed.check.ok ? 'checked' : 'failed') : t('pending'), onClick: () => setActiveId(feed.id) })),
584
+ !filtered.length ? h(W.Empty, { title: t('noMatch'), action: h(W.Button, { onClick: () => { setQuery(''); setCategory('*'); } }, t('clear')) }) : null),
585
+ detail: active ? h('article', { className: 'rss-feed-detail' },
586
+ h('h2', { className: 'w-detail-title' }, active.name || active.url), h('p', { className: 'w-detail-meta rss-url' }, active.url),
587
+ h('div', { className: 'rss-detail-actions' }, h('span', { className: 'w-tag' }, active.category || t('uncategorized')), h('div', { className: 'w-toolbar' },
588
+ h(W.Button, { variant: 'primary', disabled: !!busy, onClick: () => run('previewFeed', { id: active.id }, value => setPreviews(old => ({ ...old, [active.id]: value.feedPreview }))) }, busy === 'previewFeed' ? t('saving') : rssText('检查并预览', 'Check and preview')),
589
+ h(W.Button, { icon: 'edit', variant: 'ghost', disabled: !writable || !!busy, onClick: event => open('feed', active, event) }, t('edit')),
590
+ h('details', { className: 'rss-more' }, h('summary', { 'aria-label': rssText('更多订阅操作', 'More feed actions') }, h(W.Icon, { name: 'more', size: 20 })), h(W.Button, { variant: 'danger', disabled: !writable || !!busy, onClick: event => open('remove', active, event) }, t('remove'))))),
591
+ h(RssArticlePreview, { value: previews[active.id] }),
592
+ h('details', { className: 'w-section' }, h('summary', null, rssText('来源检查', 'Source check')),
593
+ active.check ? h(React.Fragment, null, h('p', { className: 'w-muted' }, new Date(active.check.checkedAt).toLocaleString(language === 'en' ? 'en-US' : 'zh-CN')),
594
+ h(W.Status, { tone: active.check.ok ? 'success' : 'error' }, active.check.ok ? t('checked') + ' · ' + active.check.entryCount + ' ' + t('entries') : t('failed') + ' · ' + feedError(active.check.error))) : h('p', { className: 'w-muted' }, t('pending')),
595
+ h('p', { className: 'w-muted' }, t('statusHint')))) : h(W.Empty, { title: t('noMatch'), icon: 'rss' }) });
596
+ }
597
+
598
+ function RssCatalog({ catalog, sources, query, setQuery, category, setCategory, contentLanguage, setContentLanguage, busy, writable, state, run, previews, setPreviews, setNotice }) {
599
+ const [activeId, setActiveId] = useState(null);
600
+ const active = sources.find(source => source.id === activeId) || sources[0];
601
+ const categoryOf = source => localized(catalog.categories.find(category => category.id === source.category)?.name);
602
+ return h(W.Split, { selected: activeId && sources.some(source => source.id === activeId) ? activeId : null, onBack: () => setActiveId(null), backLabel: rssText('返回来源目录', 'Back to source catalog'), listWidth: 380,
603
+ list: h('div', null,
604
+ h('div', { className: 'w-master-toolbar' }, h(W.Search, { label: t('sourceSearch'), value: query, onChange: event => { setQuery(event.target.value); setActiveId(null); } })),
605
+ h('div', { className: 'rss-list-filter rss-catalog-filters' },
606
+ h('label', { className: 'w-field' }, t('category'), h('select', { value: category, onChange: event => { setCategory(event.target.value); setActiveId(null); } }, h('option', { value: '*' }, t('all')), catalog.categories.map(category => h('option', { key: category.id, value: category.id }, localized(category.name))))),
607
+ h('label', { className: 'w-field' }, t('sourceLanguage'), h('select', { value: contentLanguage, onChange: event => { setContentLanguage(event.target.value); setActiveId(null); } }, h('option', { value: '*' }, t('anyLanguage')), h('option', { value: 'zh' }, t('chinese')), h('option', { value: 'en' }, t('english'))))),
608
+ sources.map(source => h(W.Row, { key: source.id, title: source.name, active: source.id === active?.id, meta: categoryOf(source) + ' · ' + t(source.language === 'zh' ? 'chinese' : 'english'), description: localized(source.description), status: source.subscribed ? t('subscribed') : undefined, onClick: () => setActiveId(source.id) })),
609
+ !sources.length ? h(W.Empty, { title: t('noMatch') }) : null),
610
+ detail: active ? h('article', null,
611
+ h('h2', { className: 'w-detail-title' }, active.name), h('p', { className: 'w-detail-meta' }, categoryOf(active) + ' · ' + t(active.language === 'zh' ? 'chinese' : 'english')),
612
+ h('section', { className: 'w-section' }, h('p', null, localized(active.description)), h('p', { className: 'w-muted rss-url' }, active.url), h('a', { href: active.website, target: '_blank', rel: 'noopener noreferrer' }, t('website')),
613
+ h('div', { className: 'w-toolbar rss-catalog-actions' }, h(W.Button, { disabled: !!busy, onClick: () => run('previewSource', { sourceId: active.id }, value => setPreviews(old => ({ ...old, [active.id]: value.sourcePreview }))) }, busy === 'previewSource' ? t('saving') : t('previewArticles')),
614
+ h(W.Button, { variant: 'primary', disabled: !writable || !!busy || active.subscribed, onClick: () => run('add', { url: active.url, name: active.name, category: categoryOf(active), revision: state.revision }, () => setNotice(t('saved') + ' · ' + active.name)) }, active.subscribed ? t('subscribed') : t('subscribe')))),
615
+ h(RssArticlePreview, { value: previews[active.id] }), h('section', { className: 'w-section' }, h('p', { className: 'w-muted' }, t('catalogHint')), h('p', { className: 'w-muted' }, t('networkHint')), h('p', { className: 'w-muted' }, t('rsshubHint')))) : h(W.Empty, { title: t('noMatch'), icon: 'rss' }) });
616
+ }
617
+
618
+ const RSS_WORKBENCH_CSS = `
619
+ .rss-workbench .rss-list-filter{padding:0 16px 16px;display:grid;gap:12px}.rss-workbench .rss-list-filter select{width:100%}.rss-workbench .rss-catalog-filters{grid-template-columns:1fr 1fr}.rss-workbench .rss-url{overflow-wrap:anywhere}.rss-workbench .rss-detail-actions{display:flex;justify-content:space-between;align-items:center;gap:12px;flex-wrap:wrap;margin-top:18px}.rss-workbench .rss-more{position:relative;align-self:center}.rss-workbench .rss-more>summary{list-style:none;padding:8px;min-width:36px;min-height:36px;border-radius:6px}.rss-workbench .rss-more>summary:after{display:none}.rss-workbench .rss-more[open]>.w-button{position:absolute;inset-inline-end:0;top:100%;z-index:4;min-width:100px;box-shadow:0 6px 24px #0002}.rss-workbench .rss-articles>p{margin-top:12px}.rss-workbench .rss-article-list{padding:0;list-style:none;margin:12px 0 0}.rss-workbench .rss-article-list li{padding:18px 0;border-bottom:1px solid var(--w-border)}.rss-workbench .rss-article-list li:last-child{border:0}.rss-workbench .rss-article-list a{font-size:14px;font-weight:550;text-decoration:none}.rss-workbench .rss-article-list a:hover{text-decoration:underline}.rss-workbench .rss-article-list p{margin-top:6px}.rss-workbench .rss-catalog-actions{margin-top:20px}.rss-workbench .rss-transfer{width:min(740px,100%);padding:24px 0}.rss-workbench .rss-transfer form{display:grid;gap:16px}.rss-workbench .rss-transfer label{display:grid;gap:6px}.rss-workbench .rss-transfer textarea{min-height:150px}.rss-workbench .rss-transfer .dshr-checkbox{display:flex;align-items:flex-start;gap:8px}.rss-workbench .rss-transfer .dshr-checkbox input{margin-top:3px}.rss-workbench .rss-transfer .dshr-buttons{display:flex;gap:8px;flex-wrap:wrap}.rss-workbench .rss-transfer button,.rss-workbench .dshr-dialog button{min-height:36px;padding:8px 12px;border:1px solid var(--w-border);border-radius:8px;background:var(--w-bg);font-size:14px;cursor:pointer}.rss-workbench .rss-transfer button.primary,.rss-workbench .dshr-dialog button.primary{background:var(--w-primary);color:var(--w-on-primary);border-color:var(--w-primary)}.rss-workbench .dshr-dialog{background:var(--w-bg);color:var(--w-text);border:1px solid var(--w-border);box-shadow:0 18px 70px #0003;border-radius:12px;max-height:calc(100dvh - 32px);width:min(620px,calc(100vw - 32px));padding:24px}.rss-workbench .dshr-dialog label{display:grid;gap:6px;margin:16px 0}.rss-workbench .dshr-dialog input:not([type=checkbox]),.rss-workbench .dshr-dialog textarea{width:100%}.rss-workbench .dshr-dialog form{min-width:0}.rss-workbench .dshr-dialog .dshr-url{overflow-wrap:anywhere}.rss-workbench .dshr-preview{border:1px solid var(--w-border);border-radius:8px;background:var(--w-soft);padding:16px}.rss-workbench .dshr-dialog .dshr-buttons{margin-top:20px}.rss-workbench .dshr-dialog h3{font-size:20px}.rss-workbench.dshr{max-width:none;margin:0;font-size:14px}.rss-workbench .dshr-alert,.rss-workbench .dshr-notice{background:var(--w-soft);border:1px solid var(--w-border);color:inherit}.rss-workbench .dshr-muted{color:var(--w-muted)}
620
+ @container dsh-workbench (max-width:760px){.rss-workbench .rss-list-filter{padding-inline:0}.rss-workbench .rss-catalog-filters{grid-template-columns:1fr 1fr}.rss-workbench .rss-detail-actions>.w-toolbar{width:100%}}
621
+ `;
622
+
623
+ const { useState, useEffect, useRef, useId } = React;
624
+ const h = React.createElement;
625
+ const ROUTE = '_dsh/dsh-rss/subscriptions';
626
+ let language = 'zh';
627
+ const listeners = new Set();
628
+ const words = {
629
+ title: ['RSS 订阅', 'RSS subscriptions'], intro: ['在这里管理订阅,也可以在对话里让 AI 读取和搜索文章。', 'Manage feeds here, then ask AI to read or search articles in a conversation.'],
630
+ recommended: ['推荐订阅源', 'Recommended feeds'], manual: ['输入地址', 'Enter a URL'],
631
+ catalogHint: ['先选感兴趣的分类,再预览或订阅。不会默认添加,也不会自动访问所有网站。', 'Choose a topic, then preview or subscribe. Feeds are not added by default and websites are not contacted automatically.'],
632
+ networkHint: ['可用性取决于你当前的网络,国内外网站可能不同。预览失败可以重试,或改选其他来源。', 'Availability depends on your current network and can differ by website. Retry a failed preview or choose another source.'],
633
+ sourceSearch: ['搜索来源或关键词', 'Search sources or keywords'], sourceLanguage: ['内容语言', 'Content language'], anyLanguage: ['全部语言', 'All languages'], chinese: ['中文', 'Chinese'], english: ['英文', 'English'],
634
+ native: ['网站原生 RSS / Atom', 'Publisher RSS / Atom'], website: ['来源网站', 'Source website'], previewArticles: ['预览并检查', 'Preview and check'], subscribe: ['订阅', 'Subscribe'], subscribed: ['已订阅', 'Subscribed'],
635
+ recentArticles: ['近期文章(最多 5 篇)', 'Recent articles (up to 5)'], noRecentArticles: ['订阅格式有效,但此时没有文章。有些来源只在发布日提供条目。', 'The feed is valid but currently empty. Some sources only include entries on publication days.'], noTitle: ['无标题', 'Untitled'],
636
+ customCategory: ['可选现有分类,也可填写自定义分类。已有分类原样保留。', 'Choose an existing category or type your own. Existing categories are preserved.'],
637
+ rsshubHint: ['其他网站:可在“输入地址”添加原生订阅,或粘贴你选择的 RSSHub 实例生成的地址。', 'For other sites, use “Enter a URL” with a native feed or a URL generated by your chosen RSSHub instance.'],
638
+ add: ['添加订阅', 'Add feed'], import: ['导入 OPML', 'Import OPML'], export: ['导出 OPML', 'Export OPML'], refresh: ['刷新列表', 'Refresh list'],
639
+ search: ['搜索名称或地址', 'Search name or URL'], category: ['分类', 'Category'], all: ['全部分类', 'All categories'], uncategorized: ['未分类', 'Uncategorized'],
640
+ name: ['显示名称', 'Display name'], nameHint: ['留空时使用订阅源的标题', 'Leave blank to use the feed title'], url: ['订阅源地址', 'Feed URL'], categoryHint: ['例如:科技、阅读', 'For example: Tech, Reading'],
641
+ save: ['保存订阅', 'Save feed'], saving: ['正在处理…', 'Working…'], cancel: ['取消', 'Cancel'], close: ['关闭', 'Close'], edit: ['编辑', 'Edit'], remove: ['移除', 'Remove'], check: ['检查可用性', 'Check feed'],
642
+ empty: ['还没有订阅', 'No subscriptions yet'], emptyHint: ['从推荐目录选几个感兴趣的来源,也可以输入 RSS/Atom 地址或导入 OPML。', 'Choose sources from the recommended catalog, enter an RSS/Atom URL, or import OPML.'], noMatch: ['没有匹配项,试试清空筛选。', 'No matches. Try clearing the filters.'], clear: ['清空筛选', 'Clear filters'],
643
+ readonly: ['当前配置为只读。你可以查看、检查和导出订阅。', 'These settings are read-only. You can view, check and export feeds.'],
644
+ pending: ['本次运行尚未检查', 'Not checked during this run'], entries: ['篇文章', 'articles'], checked: ['检查通过', 'Check passed'], failed: ['检查失败', 'Check failed'],
645
+ statusHint: ['检查记录仅保留在本次 DSH 运行中;导入不会自动抓取所有订阅。', 'Check history lasts for this DSH run. Import does not fetch every feed.'],
646
+ deleteTitle: ['移除这个订阅?', 'Remove this feed?'], deleteHint: ['只移除订阅,不会删除原网站的文章。', 'This removes the subscription; the original articles remain on the website.'],
647
+ opml: ['OPML 文本', 'OPML text'], file: ['选择 OPML 文件', 'Choose OPML file'], importHint: ['选择文件或粘贴内容,先预览,再确认导入。最多 1 MiB。', 'Choose a file or paste its content, preview, then confirm. Maximum 1 MiB.'],
648
+ update: ['用导入文件的名称和分类更新重复订阅', 'Update duplicate names and categories from this file'], preserve: ['默认保留现有订阅的名称和分类。', 'Existing names and categories are preserved by default.'],
649
+ preview: ['预览导入', 'Preview import'], confirm: ['确认导入', 'Confirm import'], new: ['新增', 'New'], duplicates: ['重复', 'Duplicates'], invalid: ['跳过无效项', 'Invalid items skipped'], previewEmpty: ['文件中没有可导入的订阅。请确认 outline 包含 xmlUrl。', 'No importable feeds. Check that outlines contain xmlUrl.'],
650
+ keep: ['保留', 'Keep'], change: ['更新为', 'Change to'],
651
+ previewLimit: ['预览最多显示前 20 项,确认会处理全部有效项。', 'Preview shows up to 20 items. Confirmation processes all valid items.'], saved: ['订阅已保存', 'Feed saved'], removed: ['订阅已移除', 'Feed removed'], imported: ['导入完成', 'Import complete'], downloaded: ['已下载 OPML 文件', 'OPML downloaded'],
652
+ loading: ['正在读取订阅…', 'Loading subscriptions…'], retry: ['重新读取', 'Retry'], loadError: ['无法读取订阅。请确认 DSH 仍在运行,然后重试。', 'Cannot load feeds. Check that DSH is running, then retry.'],
653
+ conflict: ['订阅列表已变化,请刷新列表,再保存或重新预览。输入已保留。', 'The list has changed. Refresh it, then save or preview again. Your input is preserved.'], duplicate: ['这个地址已经订阅,请编辑现有订阅。', 'This URL is already subscribed. Edit the existing feed.'],
654
+ bodyLarge: ['文件超过 1 MiB,请拆分后导入。', 'File exceeds 1 MiB. Split it before importing.'], session: ['DSH 会话已失效,请重新打开 DSH 页面。', 'The DSH session has expired. Reopen the DSH page.'], fileError: ['无法读取文件,请重新选择或粘贴 OPML 文本。', 'Cannot read this file. Choose it again or paste OPML text.'],
655
+ };
656
+ const t = key => (words[key] || [key, key])[language === 'en' ? 1 : 0];
657
+ const localized = value => value?.[language === 'en' ? 1 : 0] || '';
658
+ function feedError(message, code) {
659
+ if (language !== 'en' || !/[\u3400-\u9fff]/.test(message || ''))
660
+ return message;
661
+ if (['conflict', 'duplicate', 'readonly', 'bodyLarge', 'session'].includes(code))
662
+ return t(code);
663
+ if (/HTTP/.test(message))
664
+ return 'Feed request failed. Check the URL, connection and proxy settings, then retry.';
665
+ if (/YAML|feedsYaml/.test(message))
666
+ return 'The feed configuration is invalid. Fix the feedsYaml list in settings before retrying.';
667
+ if (/OPML|outline|xmlUrl/.test(message))
668
+ return 'The OPML content is invalid. Export it again with xmlUrl attributes on feed outlines.';
669
+ if (/地址|URL|url|http|https|协议/.test(message))
670
+ return 'Enter a valid HTTP or HTTPS feed URL. Local and private-network addresses are not allowed.';
671
+ if (/写入|只读/.test(message))
672
+ return 'Could not save the feed configuration. Check write access and reload the list before retrying; your input is preserved.';
673
+ if (/未找到|找不到|没有找到/.test(message))
674
+ return 'No matching feed was found. Refresh the subscription list.';
675
+ return 'The feed could not be read. Check the URL, network and proxy settings, then retry.';
676
+ }
677
+ const CSS = `
124
678
  .dshr{color:var(--dsw-alias-label-primary,#202737);font-size:14px;line-height:1.55;max-width:920px;min-width:0;overflow-wrap:anywhere}
125
679
  .dshr *,.dshr-dialog *{box-sizing:border-box}.dshr h2{font-size:22px;margin:0 0 6px}.dshr p{margin:0 0 12px}
126
680
  .dshr-muted{color:var(--dsw-alias-label-tertiary,#657083);font-size:13px}.dshr-toolbar{display:flex;flex-wrap:wrap;gap:8px;margin:16px 0}
@@ -151,198 +705,205 @@ function __withFirstRun(Component) {
151
705
  [role=dialog]:has(.dshr)>nav>div:has(>button){display:flex;flex-direction:row!important;flex-wrap:wrap;gap:4px}
152
706
  }
153
707
  `;
154
- async function request(action, args, signal) {
155
- const response = await fetch(new URL(ROUTE, document.baseURI), action ? {
156
- method: 'POST', credentials: 'same-origin', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify({ action, ...args }), signal,
157
- } : { credentials: 'same-origin', signal });
158
- let value;
159
- try { value = await response.json(); } catch { throw new Error(response.status === 401 ? t('session') : t('loadError')); }
160
- if (!response.ok) {
161
- const error = new Error(['conflict', 'duplicate', 'readonly'].includes(value.code) ? t(value.code) : feedError(value.error, value.code) || t('loadError'));
162
- error.snapshot = value.snapshot;
163
- throw error;
164
- }
165
- return value;
166
- }
167
- function Dialog({ title, busy, onClose, children, wide }) {
168
- const ref = useRef(null);
169
- const id = useId();
170
- useEffect(() => { ref.current.showModal(); return () => ref.current?.close(); }, []);
171
- return h('dialog', { ref, className: 'dshr-dialog' + (wide ? ' catalog' : ''), 'aria-labelledby': id,
172
- onKeyDownCapture: event => {
173
- if (event.nativeEvent.isComposing) return;
174
- if (event.key === 'Escape') { event.preventDefault(); event.stopPropagation(); if (!busy) onClose(); }
175
- if (event.key === 'Tab') {
176
- event.stopPropagation();
177
- const targets = [...event.currentTarget.querySelectorAll('input:not([disabled]),textarea:not([disabled]),select:not([disabled]),button:not([disabled]),a[href],summary')].filter(node => node.getClientRects().length);
178
- const first = targets[0], last = targets[targets.length - 1];
179
- if (event.shiftKey && document.activeElement === first) { event.preventDefault(); last?.focus(); }
180
- else if (!event.shiftKey && document.activeElement === last) { event.preventDefault(); first?.focus(); }
708
+ async function request(action, args, signal) {
709
+ const response = await fetch(new URL(ROUTE, document.baseURI), action ? {
710
+ method: 'POST', credentials: 'same-origin', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify({ action, ...args }), signal,
711
+ } : { credentials: 'same-origin', signal });
712
+ let value;
713
+ try {
714
+ value = await response.json();
715
+ }
716
+ catch {
717
+ throw new Error(response.status === 401 ? t('session') : t('loadError'));
718
+ }
719
+ if (!response.ok) {
720
+ const error = new Error(['conflict', 'duplicate', 'readonly'].includes(value.code) ? t(value.code) : feedError(value.error, value.code) || t('loadError'));
721
+ error.snapshot = value.snapshot;
722
+ throw error;
723
+ }
724
+ return value;
181
725
  }
182
- },
183
- onCancel: event => { event.preventDefault(); event.stopPropagation(); if (!busy) onClose(); } },
184
- h('h3', { id }, title), children);
185
- }
186
- function Panel() {
187
- const [, setLanguage] = useState(language);
188
- const [state, setState] = useState(null), [loading, setLoading] = useState(true), [busy, setBusy] = useState('');
189
- const [error, setError] = useState(''), [notice, setNotice] = useState(''), [query, setQuery] = useState(''), [category, setCategory] = useState('*');
190
- const [modal, setModal] = useState(null), [draft, setDraft] = useState({ url: '', name: '', category: '' });
191
- const [opml, setOpml] = useState(''), [updateExisting, setUpdateExisting] = useState(false), [preview, setPreview] = useState(null);
192
- const [catalogQuery, setCatalogQuery] = useState(''), [catalogCategory, setCatalogCategory] = useState('*'), [catalogLanguage, setCatalogLanguage] = useState('*');
193
- const [sourcePreviews, setSourcePreviews] = useState({}), [selectedSource, setSelectedSource] = useState('');
194
- const categoryListId = useId();
195
- const controller = useRef(null), trigger = useRef(null);
196
- useEffect(() => { listeners.add(setLanguage); return () => listeners.delete(setLanguage); }, []);
197
- useEffect(() => { void run(null); return () => controller.current?.abort(); }, []);
198
- async function run(action, args = {}, onSuccess) {
199
- if (controller.current) return;
200
- const abort = new AbortController(); controller.current = abort;
201
- setBusy(action === 'check' && args.id ? args.id : action || 'load'); setError(''); setNotice('');
202
- try {
203
- const value = await request(action, args, abort.signal);
204
- if (value.snapshot) setState(value.snapshot);
205
- if (onSuccess) onSuccess(value);
206
- return value;
207
- } catch (failure) {
208
- if (!abort.signal.aborted) { if (failure.snapshot) setState(failure.snapshot); setError(failure.message || t('loadError')); }
209
- } finally { if (!abort.signal.aborted) { setBusy(''); setLoading(false); } controller.current = null; }
210
- }
211
- function close() { setModal(null); setError(''); setPreview(null); queueMicrotask(() => trigger.current?.focus()); }
212
- function open(type, feed, event) {
213
- trigger.current = event.currentTarget; setError(''); setNotice(''); setPreview(null);
214
- if (type === 'feed') setDraft(feed ? { url: feed.url, name: feed.name, category: feed.category } : { url: '', name: '', category: '' });
215
- if (type === 'import') { setOpml(''); setUpdateExisting(false); }
216
- if (type === 'catalog') { setCatalogQuery(''); setCatalogCategory('*'); setCatalogLanguage('*'); setSelectedSource(''); }
217
- setModal({ type, feed });
218
- }
219
- async function chooseFile(event) {
220
- const file = event.target.files?.[0];
221
- event.target.value = '';
222
- if (!file) return;
223
- if (file.size > 1024 * 1024) { setError(t('bodyLarge')); return; }
224
- try { setOpml(await file.text()); setPreview(null); setError(''); } catch { setError(t('fileError')); }
225
- }
226
- const field = (key, hint) => h('label', { key }, t(key), h('input', {
227
- name: key, type: key === 'url' ? 'url' : 'text', value: draft[key], placeholder: hint, required: key === 'url', disabled: !!busy,
228
- list: key === 'category' ? categoryListId : undefined,
229
- autoFocus: key === 'url', onChange: event => setDraft({ ...draft, [key]: event.target.value }),
230
- }));
231
- const buttons = submit => h('div', { className: 'dshr-buttons' },
232
- h('button', { type: 'button', disabled: !!busy, onClick: close }, t('cancel')), submit);
233
- const alert = error ? h('div', { role: 'alert', className: 'dshr-alert' }, error) : null;
234
- const feeds = state?.feeds || [], writable = state?.writable === true;
235
- const categories = [...new Set(feeds.map(feed => feed.category))].sort();
236
- const catalog = state?.catalog || { categories: [], sources: [] };
237
- const sourceCategory = source => localized(catalog.categories.find(category => category.id === source.category)?.name);
238
- const sourceOptions = catalog.sources.filter(source => (catalogCategory === '*' || source.category === catalogCategory) &&
239
- (catalogLanguage === '*' || source.language === catalogLanguage) &&
240
- (source.name + ' ' + source.url + ' ' + (source.description || []).join(' ')).toLowerCase().includes(catalogQuery.trim().toLowerCase()));
241
- const filtered = feeds.filter(feed => (category === '*' || feed.category === category) && (feed.name + ' ' + feed.url).toLowerCase().includes(query.trim().toLowerCase()));
242
- return h('section', { className: 'dshr', 'aria-label': t('title') },
243
- h('h2', null, t('title')), h('p', { className: 'dshr-muted' }, t('intro')),
244
- state && !writable ? h('p', { className: 'dshr-notice' }, t('readonly')) : null,
245
- h('div', { className: 'dshr-toolbar' },
246
- h('button', { className: 'primary', disabled: !state || !!busy, onClick: event => open('catalog', null, event) }, t('recommended')),
247
- h('button', { disabled: !writable || !!busy, onClick: event => open('feed', null, event) }, t('manual')),
248
- h('button', { disabled: !writable || !!busy, onClick: event => open('import', null, event) }, t('import')),
249
- h('button', { disabled: !state || !!busy, onClick: () => run('export', {}, value => {
250
- const url = URL.createObjectURL(new Blob([value.opml], { type: 'text/x-opml;charset=utf-8' }));
251
- const a = document.createElement('a'); a.href = url; a.download = 'rss-subscriptions.opml'; a.click();
252
- setTimeout(() => URL.revokeObjectURL(url), 10000); setNotice(t('downloaded'));
253
- }) }, t('export')),
254
- h('button', { disabled: !!busy, onClick: () => run(null) }, t('refresh'))),
255
- !modal ? alert : null, notice ? h('div', { role: 'status', className: 'dshr-notice' }, notice) : null,
256
- loading ? h('p', { role: 'status' }, t('loading')) : !state ? h('button', { disabled: !!busy, onClick: () => run(null) }, t('retry')) :
257
- h(React.Fragment, null,
258
- feeds.length ? h('div', { className: 'dshr-filters' },
259
- h('label', null, t('search'), h('input', { type: 'search', value: query, onChange: event => setQuery(event.target.value) })),
260
- h('label', null, t('category'), h('select', { value: category, onChange: event => setCategory(event.target.value) },
261
- h('option', { value: '*' }, t('all')), categories.map(value => h('option', { key: value, value }, value || t('uncategorized')))))) : null,
262
- !feeds.length ? h('div', { className: 'dshr-empty' }, h('strong', null, t('empty')), h('p', { className: 'dshr-muted' }, t('emptyHint'))) :
263
- !filtered.length ? h('div', { className: 'dshr-empty' }, h('p', null, t('noMatch')), h('button', { onClick: () => { setQuery(''); setCategory('*'); } }, t('clear'))) :
264
- h('ul', { className: 'dshr-list' }, filtered.map(feed => h('li', { key: feed.id, className: 'dshr-card', 'aria-label': feed.name || feed.url },
265
- h('div', { className: 'dshr-info' }, h('h3', null, feed.name || feed.url), h('div', { className: 'dshr-url' }, feed.url),
266
- h('span', { className: 'dshr-tag' }, feed.category || t('uncategorized')),
267
- h('div', { className: 'dshr-status' }, feed.check ? [
268
- new Date(feed.check.checkedAt).toLocaleString(language === 'en' ? 'en-US' : 'zh-CN'), ' · ',
269
- feed.check.ok ? feed.check.entryCount + ' ' + t('entries') + ' · ' + t('checked') : t('failed') + (language === 'en' ? ': ' : ':') + feedError(feed.check.error),
270
- ] : t('pending'))),
271
- h('div', { className: 'dshr-actions' },
272
- h('button', { disabled: !!busy, onClick: () => run('check', { id: feed.id }, value => setNotice(t('checked') + ' · ' + value.check.entryCount + ' ' + t('entries'))) }, busy === feed.id ? t('saving') : t('check')),
273
- h('button', { disabled: !writable || !!busy, onClick: event => open('feed', feed, event) }, t('edit')),
274
- h('button', { disabled: !writable || !!busy, onClick: event => open('remove', feed, event) }, t('remove')))))),
275
- feeds.length ? h('p', { className: 'dshr-muted', style: { marginTop: 12 } }, t('statusHint')) : null),
276
- modal ? h(Dialog, { title: modal.type === 'catalog' ? t('recommended') : modal.type === 'import' ? t('import') : modal.type === 'remove' ? t('deleteTitle') : modal.feed ? t('edit') : t('add'), wide: modal.type === 'catalog', busy: !!busy, onClose: close },
277
- alert,
278
- modal.type === 'catalog' ? h('div', null,
279
- h('p', { className: 'dshr-muted' }, t('catalogHint')), h('p', { className: 'dshr-muted' }, t('networkHint')),
280
- notice ? h('p', { role: 'status', className: 'dshr-notice' }, notice) : null,
281
- h('div', { className: 'dshr-filters' },
282
- h('label', null, t('sourceSearch'), h('input', { type: 'search', autoFocus: true, value: catalogQuery, disabled: !!busy, onChange: event => setCatalogQuery(event.target.value) })),
283
- h('label', null, t('category'), h('select', { value: catalogCategory, disabled: !!busy, onChange: event => setCatalogCategory(event.target.value) }, h('option', { value: '*' }, t('all')), catalog.categories.map(category => h('option', { key: category.id, value: category.id }, localized(category.name))))),
284
- h('label', null, t('sourceLanguage'), h('select', { value: catalogLanguage, disabled: !!busy, onChange: event => setCatalogLanguage(event.target.value) }, h('option', { value: '*' }, t('anyLanguage')), h('option', { value: 'zh' }, t('chinese')), h('option', { value: 'en' }, t('english'))))),
285
- !sourceOptions.length ? h('p', { role: 'status' }, t('noMatch')) : null,
286
- h('ul', { className: 'dshr-catalog' }, sourceOptions.map(source => {
287
- const recent = sourcePreviews[source.id];
288
- return h('li', { key: source.id, className: 'dshr-source' + (selectedSource === source.id ? ' is-selected' : ''), 'aria-label': source.name },
289
- h('h4', null, source.name), h('span', { className: 'dshr-tag' }, sourceCategory(source)), ' ', h('span', { className: 'dshr-tag' }, t(source.language === 'zh' ? 'chinese' : 'english')),
290
- h('p', null, localized(source.description)), h('a', { href: source.website, target: '_blank', rel: 'noopener noreferrer' }, t('website')),
291
- h('details', null, h('summary', null, t('url')), h('p', { className: 'dshr-url' }, source.url), h('p', { className: 'dshr-muted' }, t('native'))),
292
- source.check ? h('p', { className: 'dshr-status' }, source.check.ok ? t('checked') + ' · ' + source.check.entryCount + ' ' + t('entries') : t('failed') + ' · ' + feedError(source.check.error)) : null,
293
- h('div', { className: 'dshr-actions' },
294
- h('button', { type: 'button', disabled: !!busy, onClick: () => { setSelectedSource(source.id); void run('previewSource', { sourceId: source.id }, value => setSourcePreviews(old => ({ ...old, [source.id]: value.sourcePreview }))); } }, busy === 'previewSource' && selectedSource === source.id ? t('saving') : t('previewArticles')),
295
- h('button', { type: 'button', className: source.subscribed ? '' : 'primary', disabled: !writable || !!busy || source.subscribed, onClick: () => { setSelectedSource(source.id); void run('add', { url: source.url, name: source.name, category: sourceCategory(source), revision: state.revision }, () => setNotice(t('saved') + ' · ' + source.name)); } }, source.subscribed ? t('subscribed') : t('subscribe'))),
296
- recent ? h('div', { className: 'dshr-preview', role: 'status' }, h('strong', null, t('recentArticles')), h('p', { className: 'dshr-muted' }, new Date(recent.checkedAt).toLocaleString(language === 'en' ? 'en-US' : 'zh-CN')),
297
- !recent.entries.length ? h('p', null, t('noRecentArticles')) : h('ul', null, recent.entries.map((entry, index) => h('li', { key: index },
298
- entry.link ? h('a', { href: entry.link, target: '_blank', rel: 'noopener noreferrer' }, entry.title || t('noTitle')) : entry.title || t('noTitle'),
299
- entry.pubDate ? h('div', { className: 'dshr-muted' }, new Date(entry.pubDate).toLocaleDateString(language === 'en' ? 'en-US' : 'zh-CN')) : null)))) : null);
300
- })),
301
- h('p', { className: 'dshr-muted' }, t('rsshubHint')),
302
- h('div', { className: 'dshr-buttons' }, h('button', { type: 'button', disabled: !!busy, onClick: close }, t('close')))) :
303
- modal.type === 'feed' ? h('form', { onSubmit: event => { event.preventDefault(); void run(modal.feed ? 'edit' : 'add', { ...draft, id: modal.feed?.id, revision: state.revision }, () => { close(); setNotice(t('saved')); }); } },
304
- field('url', 'https://example.com/feed.xml'), field('name', t('nameHint')), field('category', t('categoryHint')),
305
- h('datalist', { id: categoryListId }, [...new Set([...categories, ...catalog.categories.map(category => localized(category.name))])].filter(Boolean).map(value => h('option', { key: value, value }))),
306
- h('p', { className: 'dshr-muted' }, t('customCategory')),
307
- error ? h('button', { type: 'button', disabled: !!busy, onClick: () => run(null) }, t('refresh')) : null,
308
- buttons(h('button', { type: 'submit', className: 'primary', disabled: !!busy }, t(busy ? 'saving' : 'save')))) :
309
- modal.type === 'remove' ? h('div', null, h('strong', null, modal.feed.name || modal.feed.url), h('p', { className: 'dshr-url' }, modal.feed.url), h('p', null, t('deleteHint')),
310
- buttons(h('button', { className: 'danger', disabled: !!busy, onClick: () => run('remove', { id: modal.feed.id, revision: state.revision }, () => { close(); setNotice(t('removed')); }) }, t(busy ? 'saving' : 'remove')))) :
311
- h('form', { onSubmit: event => { event.preventDefault(); void run('preview', { opml, updateExisting }, value => setPreview(value.preview)); } },
312
- h('p', { className: 'dshr-muted' }, t('importHint')), h('label', null, t('file'), h('input', { type: 'file', accept: '.opml,.xml,text/xml,application/xml,text/x-opml', disabled: !!busy, onChange: chooseFile })),
313
- h('label', null, t('opml'), h('textarea', { required: true, autoFocus: true, value: opml, disabled: !!busy, onChange: event => { setOpml(event.target.value); setPreview(null); } })),
314
- h('label', { className: 'dshr-checkbox' }, h('input', { type: 'checkbox', checked: updateExisting, disabled: !!busy, onChange: event => { setUpdateExisting(event.target.checked); setPreview(null); } }), t('update')),
315
- h('p', { className: 'dshr-muted' }, t('preserve')),
316
- preview ? h('div', { className: 'dshr-preview', role: 'status' },
317
- h('strong', null, `${t('new')} ${preview.addedCount} · ${t('duplicates')} ${preview.existedCount} · ${t('invalid')} ${preview.skippedCount}`),
318
- !preview.addedCount && !preview.existedCount ? h('p', null, t('previewEmpty')) : null,
319
- h('ul', null, preview.added.slice(0, 20).map(feed => h('li', { key: feed.url }, t('new'), ':', feed.name || feed.url, ' · ', feed.category || t('uncategorized'))),
320
- (preview.duplicates || []).slice(0, 20).map((item, index) => h('li', { key: 'duplicate-' + index },
321
- t('duplicates'), ':', item.before.name || item.url, ' · ', item.before.category || t('uncategorized'),
322
- updateExisting ? ' → ' + (item.after.name || item.url) + ' · ' + (item.after.category || t('uncategorized')) : ' · ' + t('keep'))),
323
- preview.skipped.slice(0, 20).map((item, index) => h('li', { key: index }, item.title, ' · ', item.url, language === 'en' ? ': ' : ':', feedError(item.reason)))),
324
- preview.added.length > 20 || preview.skipped.length > 20 || (preview.duplicates || []).length > 20 ? h('p', { className: 'dshr-muted' }, t('previewLimit')) : null) : null,
325
- h('div', { className: 'dshr-buttons' }, h('button', { type: 'button', disabled: !!busy, onClick: close }, t('cancel')),
326
- h('button', { type: 'submit', disabled: !!busy || !opml.trim() }, t(busy === 'preview' ? 'saving' : 'preview')),
327
- preview ? h('button', { type: 'button', className: 'primary', disabled: !!busy || !(preview.addedCount || updateExisting && preview.existedCount), onClick: () => run('import', { opml, updateExisting, revision: preview.revision, token: preview.token }, value => {
328
- close(); setNotice(`${t('imported')} · ${t('new')} ${value.result.addedCount} · ${t('duplicates')} ${value.result.existedCount} · ${t('invalid')} ${value.result.skippedCount}`);
329
- }) }, t(busy === 'import' ? 'saving' : 'confirm')) : null))) : null);
330
- }
331
- function apply(ctx) {
332
- ctx.effect(() => {
333
- const service = ctx.get ? ctx.get('locale') : ctx.locale;
334
- const update = () => { language = String(service?.getSnapshot?.().active || 'zh').startsWith('en') ? 'en' : 'zh'; for (const notify of listeners) notify(language); };
335
- update(); return service?.subscribe?.(update) || (() => {});
336
- }, 'dsh-rss: locale');
337
- ctx.effect(() => {
338
- const style = document.createElement('style'); style.dataset.pluginCss = 'dsh-rss/client'; style.textContent = CSS; document.head.appendChild(style);
339
- return () => style.remove();
340
- }, 'dsh-rss: styles');
341
- ctx.slots.inject('settings.section', () => ctx.slots.register({ name: 'settings.section', id: 'dsh-rss', order: 55, label: () => {
342
- let lang = language;
343
- try { const service = ctx.get ? ctx.get('locale') : ctx.locale; if (service?.getSnapshot) lang = String(service.getSnapshot().active || '').startsWith('en') ? 'en' : 'zh'; } catch {}
344
- return words.title[lang === 'en' ? 1 : 0];
345
- }, inject: () => ({}) }, __withFirstRun(Panel)));
346
- }
347
- return { apply, inject: ['slots', 'locale'] };
348
- } });
726
+ function Dialog({ title, busy, onClose, children, wide }) {
727
+ const ref = useRef(null);
728
+ const id = useId();
729
+ useEffect(() => { ref.current.showModal(); return () => ref.current?.close(); }, []);
730
+ return h('dialog', { ref, className: 'dshr-dialog' + (wide ? ' catalog' : ''), 'aria-labelledby': id,
731
+ onKeyDownCapture: event => {
732
+ if (event.nativeEvent.isComposing)
733
+ return;
734
+ if (event.key === 'Escape') {
735
+ event.preventDefault();
736
+ event.stopPropagation();
737
+ if (!busy)
738
+ onClose();
739
+ }
740
+ if (event.key === 'Tab') {
741
+ event.stopPropagation();
742
+ const targets = [...event.currentTarget.querySelectorAll('input:not([disabled]),textarea:not([disabled]),select:not([disabled]),button:not([disabled]),a[href],summary')].filter(node => node.getClientRects().length);
743
+ const first = targets[0], last = targets[targets.length - 1];
744
+ if (event.shiftKey && document.activeElement === first) {
745
+ event.preventDefault();
746
+ last?.focus();
747
+ }
748
+ else if (!event.shiftKey && document.activeElement === last) {
749
+ event.preventDefault();
750
+ first?.focus();
751
+ }
752
+ }
753
+ },
754
+ onCancel: event => { event.preventDefault(); event.stopPropagation(); if (!busy)
755
+ onClose(); } }, h('h3', { id }, title), children);
756
+ }
757
+ function Panel({workbench=false}={}) {
758
+ const [activeTab,setActiveTab] = useState('feeds');
759
+ function exportFeeds(){return run('export',{},value=>{const url=URL.createObjectURL(new Blob([value.opml],{type:'text/x-opml;charset=utf-8'}));const link=document.createElement('a');link.href=url;link.download='rss-subscriptions.opml';document.body.appendChild(link);link.click();link.remove();setTimeout(()=>URL.revokeObjectURL(url),10000);setNotice(t('downloaded'));});}
760
+ const [, setLanguage] = useState(language);
761
+ const [state, setState] = useState(null), [loading, setLoading] = useState(true), [busy, setBusy] = useState('');
762
+ const [error, setError] = useState(''), [notice, setNotice] = useState(''), [query, setQuery] = useState(''), [category, setCategory] = useState('*');
763
+ const [modal, setModal] = useState(null), [draft, setDraft] = useState({ url: '', name: '', category: '' });
764
+ const [opml, setOpml] = useState(''), [updateExisting, setUpdateExisting] = useState(false), [preview, setPreview] = useState(null);
765
+ const [catalogQuery, setCatalogQuery] = useState(''), [catalogCategory, setCatalogCategory] = useState('*'), [catalogLanguage, setCatalogLanguage] = useState('*');
766
+ const [sourcePreviews, setSourcePreviews] = useState({}), [selectedSource, setSelectedSource] = useState('');
767
+ const categoryListId = useId();
768
+ const controller = useRef(null), trigger = useRef(null);
769
+ // Update protection: dsh-rss
770
+ __stardustUpdatesGuard(React, "dsh-rss", { dirty: !!opml.trim(), busy: !!busy || !!modal });
771
+
772
+ useEffect(() => { listeners.add(setLanguage); return () => listeners.delete(setLanguage); }, []);
773
+ useEffect(() => { void run(null); return () => controller.current?.abort(); }, []);
774
+ async function run(action, args = {}, onSuccess) {
775
+ if (controller.current)
776
+ return;
777
+ const abort = new AbortController();
778
+ controller.current = abort;
779
+ setBusy(action === 'check' && args.id ? args.id : action || 'load');
780
+ setError('');
781
+ setNotice('');
782
+ try {
783
+ const value = await request(action, args, abort.signal);
784
+ abort.signal.throwIfAborted();
785
+ if (value.snapshot)
786
+ setState(value.snapshot);
787
+ if (onSuccess)
788
+ onSuccess(value);
789
+ return value;
790
+ }
791
+ catch (failure) {
792
+ if (!abort.signal.aborted) {
793
+ if (failure.snapshot)
794
+ setState(failure.snapshot);
795
+ setError(failure.message || t('loadError'));
796
+ }
797
+ }
798
+ finally {
799
+ if (!abort.signal.aborted) {
800
+ setBusy('');
801
+ setLoading(false);
802
+ }
803
+ controller.current = null;
804
+ }
805
+ }
806
+ function close() { if(!modal && activeTab === 'transfer') setActiveTab('feeds'); setModal(null); setError(''); setPreview(null); queueMicrotask(() => trigger.current?.focus()); }
807
+ function open(type, feed, event) {
808
+ trigger.current = event.currentTarget;
809
+ setError('');
810
+ setNotice('');
811
+ setPreview(null);
812
+ if (type === 'feed')
813
+ setDraft(feed ? { url: feed.url, name: feed.name, category: feed.category } : { url: '', name: '', category: '' });
814
+ if (type === 'import') {
815
+ setOpml('');
816
+ setUpdateExisting(false);
817
+ }
818
+ if (type === 'catalog') {
819
+ setCatalogQuery('');
820
+ setCatalogCategory('*');
821
+ setCatalogLanguage('*');
822
+ setSelectedSource('');
823
+ }
824
+ setModal({ type, feed });
825
+ }
826
+ async function chooseFile(event) {
827
+ const file = event.target.files?.[0];
828
+ event.target.value = '';
829
+ if (!file)
830
+ return;
831
+ if (file.size > 1024 * 1024) {
832
+ setError(t('bodyLarge'));
833
+ return;
834
+ }
835
+ try {
836
+ setOpml(await file.text());
837
+ setPreview(null);
838
+ setError('');
839
+ }
840
+ catch {
841
+ setError(t('fileError'));
842
+ }
843
+ }
844
+ const field = (key, hint) => h('label', { key }, t(key), h('input', {
845
+ name: key, type: key === 'url' ? 'url' : 'text', value: draft[key], placeholder: hint, required: key === 'url', disabled: !!busy,
846
+ list: key === 'category' ? categoryListId : undefined,
847
+ autoFocus: key === 'url', onChange: event => setDraft({ ...draft, [key]: event.target.value }),
848
+ }));
849
+ const buttons = submit => h('div', { className: 'dshr-buttons' }, h('button', { type: 'button', disabled: !!busy, onClick: close }, t('cancel')), submit);
850
+ const alert = error ? h('div', { role: 'alert', className: 'dshr-alert' }, error) : null;
851
+ const feeds = state?.feeds || [], writable = state?.writable === true;
852
+ const categories = [...new Set(feeds.map(feed => feed.category))].sort();
853
+ const catalog = state?.catalog || { categories: [], sources: [] };
854
+ const sourceCategory = source => localized(catalog.categories.find(category => category.id === source.category)?.name);
855
+ const sourceOptions = catalog.sources.filter(source => (catalogCategory === '*' || source.category === catalogCategory) &&
856
+ (catalogLanguage === '*' || source.language === catalogLanguage) &&
857
+ (source.name + ' ' + source.url + ' ' + (source.description || []).join(' ')).toLowerCase().includes(catalogQuery.trim().toLowerCase()));
858
+ const filtered = feeds.filter(feed => (category === '*' || feed.category === category) && (feed.name + ' ' + feed.url).toLowerCase().includes(query.trim().toLowerCase()));
859
+ return h(W.Page,__stardustUpdatesPage(React,{workbench,title:t('title'),subtitle:rssText('选择可信来源,先预览再订阅。','Choose trusted sources. Preview before subscribing.'),className:'dshr rss-workbench',actions:h(React.Fragment,null,
860
+ h(W.Button,{icon:'plus',variant:'primary',disabled:!writable || !!busy,onClick:event=>open('feed',null,event)},t('add')),
861
+ h(W.Button,{icon:'rss',disabled:!state || !!busy,onClick:()=>setActiveTab('catalog')},t('recommended')))},"dsh-rss"),
862
+ h('style',null,RSS_WORKBENCH_CSS),
863
+ state && !writable ? h(W.Status,null,t('readonly')) : null,
864
+ !modal ? h(W.Status,{tone:'error'},error) : null,h(W.Status,{tone:'success'},notice),
865
+ h(W.Tabs,{label:rssText('RSS 视图','RSS views'),value:activeTab,onChange:setActiveTab,items:[{id:'feeds',label:rssText('我的订阅','My feeds')},{id:'catalog',label:t('recommended')},{id:'transfer',label:rssText('导入与导出','Import and export')}]},
866
+ loading ? h(W.Empty,{title:t('loading'),icon:'rss'}) : !state ? h(W.Empty,{title:t('loadError'),action:h(W.Button,{disabled:!!busy,onClick:()=>run(null)},t('retry'))}) :
867
+ activeTab === 'feeds' ? h(RssFeedBrowser,{feeds,filtered,categories,query,setQuery,category,setCategory,writable,busy,run,open}) :
868
+ activeTab === 'catalog' ? h(RssCatalog,{catalog,sources:sourceOptions,query:catalogQuery,setQuery:setCatalogQuery,category:catalogCategory,setCategory:setCatalogCategory,contentLanguage:catalogLanguage,setContentLanguage:setCatalogLanguage,busy,writable,state,run,previews:sourcePreviews,setPreviews:setSourcePreviews,setNotice}) :
869
+ h('div',{className:'rss-transfer'},h('div',{className:'w-toolbar'},h('h3',null,rssText('订阅备份与迁移','Back up and move subscriptions')),h(W.Button,{icon:'download',disabled:!state || !!busy,onClick:exportFeeds},t('export'))),h('p',{className:'w-muted'},t('preserve')),h('form', { onSubmit: event => { event.preventDefault(); void run('preview', { opml, updateExisting }, value => setPreview(value.preview)); } }, h('p', { className: 'dshr-muted' }, t('importHint')), h('label', null, t('file'), h('input', { type: 'file', accept: '.opml,.xml,text/xml,application/xml,text/x-opml', disabled: !!busy, onChange: chooseFile })), h('label', null, t('opml'), h('textarea', { required: true, autoFocus: true, value: opml, disabled: !!busy, onChange: event => { setOpml(event.target.value); setPreview(null); } })), h('label', { className: 'dshr-checkbox' }, h('input', { type: 'checkbox', checked: updateExisting, disabled: !!busy, onChange: event => { setUpdateExisting(event.target.checked); setPreview(null); } }), t('update')), h('p', { className: 'dshr-muted' }, t('preserve')), preview ? h('div', { className: 'dshr-preview', role: 'status' }, h('strong', null, `${t('new')} ${preview.addedCount} · ${t('duplicates')} ${preview.existedCount} · ${t('invalid')} ${preview.skippedCount}`), !preview.addedCount && !preview.existedCount ? h('p', null, t('previewEmpty')) : null, h('ul', null, preview.added.slice(0, 20).map(feed => h('li', { key: feed.url }, t('new'), ':', feed.name || feed.url, ' · ', feed.category || t('uncategorized'))), (preview.duplicates || []).slice(0, 20).map((item, index) => h('li', { key: 'duplicate-' + index }, t('duplicates'), ':', item.before.name || item.url, ' · ', item.before.category || t('uncategorized'), updateExisting ? ' → ' + (item.after.name || item.url) + ' · ' + (item.after.category || t('uncategorized')) : ' · ' + t('keep'))), preview.skipped.slice(0, 20).map((item, index) => h('li', { key: index }, item.title, ' · ', item.url, language === 'en' ? ': ' : ':', feedError(item.reason)))), preview.added.length > 20 || preview.skipped.length > 20 || (preview.duplicates || []).length > 20 ? h('p', { className: 'dshr-muted' }, t('previewLimit')) : null) : null, h('div', { className: 'dshr-buttons' }, h('button', { type: 'button', disabled: !!busy, onClick: close }, t('cancel')), h('button', { type: 'submit', disabled: !!busy || !opml.trim() }, t(busy === 'preview' ? 'saving' : 'preview')), preview ? h('button', { type: 'button', className: 'primary', disabled: !!busy || !(preview.addedCount || updateExisting && preview.existedCount), onClick: () => run('import', { opml, updateExisting, revision: preview.revision, token: preview.token }, value => {
870
+ close();
871
+ setNotice(`${t('imported')} · ${t('new')} ${value.result.addedCount} · ${t('duplicates')} ${value.result.existedCount} · ${t('invalid')} ${value.result.skippedCount}`);
872
+ }) }, t(busy === 'import' ? 'saving' : 'confirm')) : null)))),
873
+ modal ? h(Dialog,{title:modal.type === 'remove' ? t('deleteTitle') : modal.feed ? t('edit') : t('add'),busy:!!busy,onClose:close},alert,modal.type === 'feed' ? h('form', { onSubmit: event => { event.preventDefault(); void run(modal.feed ? 'edit' : 'add', { ...draft, id: modal.feed?.id, revision: state.revision }, () => { close(); setNotice(t('saved')); }); } }, field('url', 'https://example.com/feed.xml'), field('name', t('nameHint')), field('category', t('categoryHint')), h('datalist', { id: categoryListId }, [...new Set([...categories, ...catalog.categories.map(category => localized(category.name))])].filter(Boolean).map(value => h('option', { key: value, value }))), h('p', { className: 'dshr-muted' }, t('customCategory')), error ? h('button', { type: 'button', disabled: !!busy, onClick: () => run(null) }, t('refresh')) : null, buttons(h('button', { type: 'submit', className: 'primary', disabled: !!busy }, t(busy ? 'saving' : 'save')))) : h('div', null, h('strong', null, modal.feed.name || modal.feed.url), h('p', { className: 'dshr-url' }, modal.feed.url), h('p', null, t('deleteHint')), buttons(h('button', { className: 'danger', disabled: !!busy, onClick: () => run('remove', { id: modal.feed.id, revision: state.revision }, () => { close(); setNotice(t('removed')); }) }, t(busy ? 'saving' : 'remove'))))) : null);
874
+ }
875
+ function apply(ctx) {
876
+ W.register(ctx,{id:'dsh-rss.workbench',label:()=>t('title'),icon:'rss',component:Panel,order:56});
877
+
878
+ ctx.effect(() => {
879
+ const service = ctx.get ? ctx.get('locale') : ctx.locale;
880
+ const update = () => { language = String(service?.getSnapshot?.().active || 'zh').startsWith('en') ? 'en' : 'zh'; for (const notify of listeners)
881
+ notify(language); };
882
+ update();
883
+ return service?.subscribe?.(update) || (() => { });
884
+ }, 'dsh-rss: locale');
885
+ ctx.effect(() => {
886
+ const style = document.createElement('style');
887
+ style.dataset.pluginCss = 'dsh-rss/client';
888
+ style.textContent = CSS;
889
+ document.head.appendChild(style);
890
+ return () => style.remove();
891
+ }, 'dsh-rss: styles');
892
+ ctx.slots.inject('settings.section', () => ctx.slots.register({ name: 'settings.section', id: 'dsh-rss', order: 55, label: () => {
893
+ let lang = language;
894
+ try {
895
+ const service = ctx.get ? ctx.get('locale') : ctx.locale;
896
+ if (service?.getSnapshot)
897
+ lang = String(service.getSnapshot().active || '').startsWith('en') ? 'en' : 'zh';
898
+ }
899
+ catch { }
900
+ return words.title[lang === 'en' ? 1 : 0];
901
+ }, inject: () => ({}) }, Panel));
902
+ }
903
+ return { apply, inject: ['slots', 'locale'] };
904
+ } },{"name":"dsh-rss","version":"0.1.0","hasWorkbench":true}));
905
+
906
+ })();
907
+
908
+ /* STARDUSTLC_UPDATE_CLIENT_BODY_END */
909
+ })();