@linxin666/dsh-client-ui-browser-view 0.4.12 → 0.4.14
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.i18n.yaml +2 -2
- package/README.md +53 -12
- package/README.zh.md +53 -12
- package/icon.svg +3 -0
- package/lib/client.js +1733 -17
- package/lib/client.js.map +1 -1
- package/lib/index.js +601 -66
- package/lib/types/client/BrowserViewSettingsCard.d.ts +40 -0
- package/lib/types/client/PluginSettingsCard.d.ts +255 -0
- package/lib/types/client/RangeBubble.d.ts +46 -0
- package/lib/types/client/SegmentGroup.d.ts +28 -0
- package/lib/types/client/config.d.ts +6 -0
- package/lib/types/client/index.d.ts +10 -0
- package/lib/types/client/locales.d.ts +26 -0
- package/lib/types/client/plugin-card-seat.d.ts +110 -0
- package/lib/types/client/settings-entry-form.d.ts +49 -0
- package/lib/types/client/settings-form.d.ts +235 -0
- package/lib/types/core/protocol.d.ts +7 -1
- package/lib/types/core/screenshot.d.ts +94 -0
- package/lib/types/core/tabs.d.ts +47 -3
- package/lib/types/host/cdp-endpoint.d.ts +27 -0
- package/lib/types/host/config.d.ts +26 -0
- package/lib/types/host/service.d.ts +43 -12
- package/lib/types/host/tools.d.ts +4 -4
- package/lib/types/index.d.ts +10 -1
- package/locale/en.json +6 -0
- package/locale/zh.json +6 -0
- package/package.json +14 -2
package/lib/client.js
CHANGED
|
@@ -7,6 +7,7 @@ window.__ModuleLoader__.load({
|
|
|
7
7
|
let react = require("react");
|
|
8
8
|
let _deepseek_ai_dsh_client_ui_primitives = require("@deepseek-ai/dsh-client-ui-primitives");
|
|
9
9
|
let react_jsx_runtime = require("react/jsx-runtime");
|
|
10
|
+
let _deepseek_ai_dsh_client_store = require("@deepseek-ai/dsh-client-store");
|
|
10
11
|
//#region src/client/live-title.ts
|
|
11
12
|
/**
|
|
12
13
|
* Create one store for the plugin's lifetime.
|
|
@@ -76,7 +77,33 @@ window.__ModuleLoader__.load({
|
|
|
76
77
|
"panel.trace.idle": "暂无工具动作",
|
|
77
78
|
"panel.status.connecting": "正在连接",
|
|
78
79
|
"panel.status.loading": "加载中",
|
|
79
|
-
"panel.status.live": "实时"
|
|
80
|
+
"panel.status.live": "实时",
|
|
81
|
+
"panel.mode.isolated": "隔离浏览器",
|
|
82
|
+
"panel.mode.real": "真实浏览器",
|
|
83
|
+
"config.summary": "真实浏览器 CDP 连接设置",
|
|
84
|
+
"config.realBrowserEnabled": "使用真实浏览器(CDP)",
|
|
85
|
+
"config.realBrowserEnabled.hint": "开启后,所有 DSH 会话都能操作此浏览器中的全部标签页。",
|
|
86
|
+
"config.cdpEndpoint": "CDP 地址",
|
|
87
|
+
"config.cdpEndpoint.hint": "仅支持本机 loopback;Chrome 136+ 默认 profile 不支持远程调试。",
|
|
88
|
+
"config.unavailable": "设置暂不可用",
|
|
89
|
+
"config.failed": "设置保存失败,请重试",
|
|
90
|
+
"settings.title": "真实浏览器",
|
|
91
|
+
"settings.description": "使用本机 Chrome / Edge 的登录状态与全部标签页。",
|
|
92
|
+
"settings.enabled": "启用 CDP 接管",
|
|
93
|
+
"settings.enabledHint": "开启后,所有 DSH 会话都能读取和操作此浏览器中的全部标签页。",
|
|
94
|
+
"settings.cdpEndpoint": "CDP 地址",
|
|
95
|
+
"settings.cdpEndpointHint": "仅限本机 loopback;Chrome 136+ 默认 profile 不支持远程调试。",
|
|
96
|
+
"settings.inherit": "继承",
|
|
97
|
+
"settings.on": "开启",
|
|
98
|
+
"settings.off": "关闭",
|
|
99
|
+
"settings.overridden": "已覆盖",
|
|
100
|
+
"settings.reset": "重置",
|
|
101
|
+
"settings.invalidValue": "取值无效",
|
|
102
|
+
"settings.collapse": "收起",
|
|
103
|
+
"settings.expand": "展开",
|
|
104
|
+
"settings.notExposed": "此部署未提供该插件设置。",
|
|
105
|
+
"settings.readOnly": "只读",
|
|
106
|
+
"settings.saveFailed": "保存失败"
|
|
80
107
|
};
|
|
81
108
|
/** English dictionary, key-for-key complete against zh. */
|
|
82
109
|
const en = {
|
|
@@ -93,7 +120,33 @@ window.__ModuleLoader__.load({
|
|
|
93
120
|
"panel.trace.idle": "No tool actions yet",
|
|
94
121
|
"panel.status.connecting": "Connecting",
|
|
95
122
|
"panel.status.loading": "Loading",
|
|
96
|
-
"panel.status.live": "Live"
|
|
123
|
+
"panel.status.live": "Live",
|
|
124
|
+
"panel.mode.isolated": "Isolated browser",
|
|
125
|
+
"panel.mode.real": "Real browser",
|
|
126
|
+
"config.summary": "Real-browser CDP connection settings",
|
|
127
|
+
"config.realBrowserEnabled": "Use a real browser (CDP)",
|
|
128
|
+
"config.realBrowserEnabled.hint": "When enabled, every DSH session can operate every tab in this browser.",
|
|
129
|
+
"config.cdpEndpoint": "CDP endpoint",
|
|
130
|
+
"config.cdpEndpoint.hint": "Loopback only. Chrome 136+ does not allow remote debugging on its default profile.",
|
|
131
|
+
"config.unavailable": "Settings are unavailable",
|
|
132
|
+
"config.failed": "Could not save settings. Try again.",
|
|
133
|
+
"settings.title": "Real browser",
|
|
134
|
+
"settings.description": "Use the sign-in state and every tab of this machine's Chrome or Edge.",
|
|
135
|
+
"settings.enabled": "Enable CDP takeover",
|
|
136
|
+
"settings.enabledHint": "When enabled, every DSH session can read and operate every tab in this browser.",
|
|
137
|
+
"settings.cdpEndpoint": "CDP endpoint",
|
|
138
|
+
"settings.cdpEndpointHint": "Loopback only. Chrome 136+ does not allow remote debugging on its default profile.",
|
|
139
|
+
"settings.inherit": "Inherit",
|
|
140
|
+
"settings.on": "On",
|
|
141
|
+
"settings.off": "Off",
|
|
142
|
+
"settings.overridden": "Overridden",
|
|
143
|
+
"settings.reset": "Reset",
|
|
144
|
+
"settings.invalidValue": "Invalid value",
|
|
145
|
+
"settings.collapse": "Collapse",
|
|
146
|
+
"settings.expand": "Expand",
|
|
147
|
+
"settings.notExposed": "This deployment does not expose the plugin settings.",
|
|
148
|
+
"settings.readOnly": "Read-only",
|
|
149
|
+
"settings.saveFailed": "Save failed"
|
|
97
150
|
};
|
|
98
151
|
//#endregion
|
|
99
152
|
//#region src/core/protocol.ts
|
|
@@ -198,7 +251,8 @@ window.__ModuleLoader__.load({
|
|
|
198
251
|
url: candidate.url,
|
|
199
252
|
title: candidate.title,
|
|
200
253
|
loading: candidate.loading,
|
|
201
|
-
...typeof candidate.sessionId === "string" ? { sessionId: candidate.sessionId } : {}
|
|
254
|
+
...typeof candidate.sessionId === "string" ? { sessionId: candidate.sessionId } : {},
|
|
255
|
+
...candidate.origin === "created" || candidate.origin === "adopted" ? { origin: candidate.origin } : {}
|
|
202
256
|
};
|
|
203
257
|
}
|
|
204
258
|
/** Narrow the panel state from the wire. */
|
|
@@ -218,6 +272,8 @@ window.__ModuleLoader__.load({
|
|
|
218
272
|
tabs,
|
|
219
273
|
activeTabId: candidate.activeTabId,
|
|
220
274
|
running: candidate.running,
|
|
275
|
+
...candidate.mode === "isolated" || candidate.mode === "cdp" ? { mode: candidate.mode } : {},
|
|
276
|
+
...typeof candidate.cdpEndpoint === "string" ? { cdpEndpoint: candidate.cdpEndpoint } : {},
|
|
221
277
|
...typeof candidate.message === "string" ? { message: candidate.message } : {}
|
|
222
278
|
};
|
|
223
279
|
}
|
|
@@ -453,13 +509,13 @@ window.__ModuleLoader__.load({
|
|
|
453
509
|
}
|
|
454
510
|
//#endregion
|
|
455
511
|
//#region \0dsh-css:packages/dsh-browser-view/src/client/panel.module.css.mjs
|
|
456
|
-
const css = ".mm_Yva_tabTitle{align-items:center;gap:5px;min-width:0;max-width:100%;display:inline-flex}.mm_Yva_tabTitleMark{flex:none;width:13px;height:13px}.mm_Yva_tabTitleText{white-space:nowrap;text-overflow:ellipsis;min-width:0;overflow:hidden}.mm_Yva_root{min-width:0;height:100%;min-height:0;color:var(--dsw-alias-label-primary);background:var(--dsw-alias-bg-base);flex-direction:column;flex:auto;display:flex;overflow:hidden}.mm_Yva_toolbar{box-sizing:border-box;border-bottom:.5px solid var(--dsw-alias-border-l3);flex:none;align-items:center;gap:4px;height:38px;padding:5px 6px;display:flex}.mm_Yva_tool{width:28px;height:28px;color:var(--dsw-alias-label-secondary);border-radius:var(--dsw-radius-sm);cursor:pointer;background:0 0;border:0;flex:none;justify-content:center;align-items:center;padding:0;display:inline-flex}@media (hover:hover){.mm_Yva_tool:hover:not(:disabled){color:var(--dsw-alias-label-primary);background:var(--dsw-alias-interactive-bg-hover)}}.mm_Yva_tool:disabled{color:var(--dsw-alias-label-quaternary);cursor:default}.mm_Yva_tool:focus-visible{box-shadow:0 0 0 2px var(--dsw-alias-bg-base), 0 0 0 4px var(--dsw-alias-brand-primary);outline:none}.mm_Yva_addressBox{flex:auto;min-width:0;position:relative}.mm_Yva_address{box-sizing:border-box;width:100%;height:28px;color:var(--dsw-alias-label-primary);font:var(--dsw-font-xxs-12);text-overflow:ellipsis;white-space:nowrap;background:var(--dsw-alias-bg-layer-1);border:.5px solid var(--dsw-alias-border-l2);border-radius:var(--dsw-radius-sm);padding:0 9px;overflow:hidden}.mm_Yva_address::placeholder{color:var(--dsw-alias-label-tertiary)}.mm_Yva_address:focus{outline:1px solid var(--dsw-alias-state-business-primary);outline-offset:-1px}.mm_Yva_status{color:var(--dsw-alias-label-tertiary);font:var(--dsw-font-xxxs-11);white-space:nowrap;flex:
|
|
457
|
-
const tagId = "@linxin666/dsh-client-ui-browser-view/packages/dsh-browser-view/src/client/panel.module.css";
|
|
458
|
-
if (typeof document !== "undefined" && document.querySelector("style[data-plugin-css=" + JSON.stringify(tagId) + "]") === null) {
|
|
512
|
+
const css$2 = ".mm_Yva_tabTitle{align-items:center;gap:5px;min-width:0;max-width:100%;display:inline-flex}.mm_Yva_tabTitleMark{flex:none;width:13px;height:13px}.mm_Yva_tabTitleText{white-space:nowrap;text-overflow:ellipsis;min-width:0;overflow:hidden}.mm_Yva_root{min-width:0;height:100%;min-height:0;color:var(--dsw-alias-label-primary);background:var(--dsw-alias-bg-base);flex-direction:column;flex:auto;display:flex;overflow:hidden}.mm_Yva_toolbar{box-sizing:border-box;border-bottom:.5px solid var(--dsw-alias-border-l3);flex:none;align-items:center;gap:4px;height:38px;padding:5px 6px;display:flex}.mm_Yva_tool{width:28px;height:28px;color:var(--dsw-alias-label-secondary);border-radius:var(--dsw-radius-sm);cursor:pointer;background:0 0;border:0;flex:none;justify-content:center;align-items:center;padding:0;display:inline-flex}@media (hover:hover){.mm_Yva_tool:hover:not(:disabled){color:var(--dsw-alias-label-primary);background:var(--dsw-alias-interactive-bg-hover)}}.mm_Yva_tool:disabled{color:var(--dsw-alias-label-quaternary);cursor:default}.mm_Yva_tool:focus-visible{box-shadow:0 0 0 2px var(--dsw-alias-bg-base), 0 0 0 4px var(--dsw-alias-brand-primary);outline:none}.mm_Yva_addressBox{flex:auto;min-width:0;position:relative}.mm_Yva_address{box-sizing:border-box;width:100%;height:28px;color:var(--dsw-alias-label-primary);font:var(--dsw-font-xxs-12);text-overflow:ellipsis;white-space:nowrap;background:var(--dsw-alias-bg-layer-1);border:.5px solid var(--dsw-alias-border-l2);border-radius:var(--dsw-radius-sm);padding:0 9px;overflow:hidden}.mm_Yva_address::placeholder{color:var(--dsw-alias-label-tertiary)}.mm_Yva_address:focus{outline:1px solid var(--dsw-alias-state-business-primary);outline-offset:-1px}.mm_Yva_status{min-width:0;color:var(--dsw-alias-label-tertiary);font:var(--dsw-font-xxxs-11);white-space:nowrap;flex:0 auto;align-items:center;gap:4px;line-height:16px;display:inline-flex}.mm_Yva_statusText{text-overflow:ellipsis;flex:none;max-width:72px;overflow:hidden}.mm_Yva_mode{color:var(--dsw-alias-label-secondary);flex:none}.mm_Yva_endpoint{text-overflow:ellipsis;max-width:160px;overflow:hidden}@media (width<=420px){.mm_Yva_endpoint{display:none}}.mm_Yva_tabs{border-bottom:.5px solid var(--dsw-alias-border-l3);scrollbar-width:none;flex:none;align-items:center;gap:4px;padding:4px 6px;display:flex;overflow-x:auto}.mm_Yva_tabs::-webkit-scrollbar{display:none}.mm_Yva_tab{max-width:150px;height:24px;color:var(--dsw-alias-label-secondary);font:var(--dsw-font-xxxs-11);white-space:nowrap;text-overflow:ellipsis;border-radius:var(--dsw-radius-sm);cursor:pointer;background:0 0;border:0;flex:none;padding:0 8px;transition:background-color .12s,color .12s;overflow:hidden}@media (hover:hover){.mm_Yva_tab:hover{color:var(--dsw-alias-label-primary);background:var(--dsw-alias-interactive-bg-hover)}}.mm_Yva_tabActive{color:var(--dsw-alias-label-primary);background:var(--dsw-alias-interactive-bg-active)}.mm_Yva_tab:focus-visible{box-shadow:0 0 0 2px var(--dsw-alias-bg-base), 0 0 0 4px var(--dsw-alias-brand-primary);outline:none}.mm_Yva_content{background:var(--dsw-alias-bg-base);flex:auto;min-width:0;min-height:0;display:flex;overflow:auto}.mm_Yva_frame{object-fit:contain;max-width:100%;height:auto;margin:auto;display:block}.mm_Yva_empty,.mm_Yva_error{text-align:center;flex-direction:column;align-items:center;gap:6px;margin:auto;padding:20px 16px;display:flex}.mm_Yva_emptyTitle,.mm_Yva_errorTitle{color:var(--dsw-alias-label-secondary);font-size:13px;font-weight:600;line-height:20px}.mm_Yva_emptyHint,.mm_Yva_errorBody{color:var(--dsw-alias-label-tertiary);font-size:12px;line-height:18px}.mm_Yva_errorTitle{color:var(--dsw-alias-state-error-primary)}.mm_Yva_errorCode{color:var(--dsw-alias-label-tertiary);font-family:var(--dsw-font-mono,ui-monospace, SFMono-Regular, Menlo, Consolas, monospace);font-size:11px;line-height:16px}.mm_Yva_trace{border-top:.5px solid var(--dsw-alias-border-l3);flex:none;align-items:center;gap:8px;max-height:84px;padding:6px 10px;display:flex;overflow:hidden}.mm_Yva_traceList{flex-direction:column;flex:1;gap:2px;min-width:0;display:flex;overflow:hidden}.mm_Yva_traceIdle{color:var(--dsw-alias-label-tertiary);font-size:12px;line-height:18px}.mm_Yva_traceRow{align-items:baseline;gap:6px;min-width:0;font-size:12px;line-height:18px;display:flex}.mm_Yva_traceTool{color:var(--dsw-alias-brand-primary);font-family:var(--dsw-font-mono,ui-monospace, SFMono-Regular, Menlo, Consolas, monospace);flex:none;font-size:11px}.mm_Yva_traceSummary{min-width:0;color:var(--dsw-alias-label-secondary);white-space:nowrap;text-overflow:ellipsis;overflow:hidden}";
|
|
513
|
+
const tagId$2 = "@linxin666/dsh-client-ui-browser-view/packages/dsh-browser-view/src/client/panel.module.css";
|
|
514
|
+
if (typeof document !== "undefined" && document.querySelector("style[data-plugin-css=" + JSON.stringify(tagId$2) + "]") === null) {
|
|
459
515
|
const tag = document.createElement("style");
|
|
460
516
|
tag.dataset.plugin = "@linxin666/dsh-client-ui-browser-view";
|
|
461
|
-
tag.dataset.pluginCss = tagId;
|
|
462
|
-
tag.textContent = css;
|
|
517
|
+
tag.dataset.pluginCss = tagId$2;
|
|
518
|
+
tag.textContent = css$2;
|
|
463
519
|
document.head.appendChild(tag);
|
|
464
520
|
}
|
|
465
521
|
var panel_module_css_default = {
|
|
@@ -469,11 +525,13 @@ window.__ModuleLoader__.load({
|
|
|
469
525
|
"empty": "mm_Yva_empty",
|
|
470
526
|
"emptyHint": "mm_Yva_emptyHint",
|
|
471
527
|
"emptyTitle": "mm_Yva_emptyTitle",
|
|
528
|
+
"endpoint": "mm_Yva_endpoint",
|
|
472
529
|
"error": "mm_Yva_error",
|
|
473
530
|
"errorBody": "mm_Yva_errorBody",
|
|
474
531
|
"errorCode": "mm_Yva_errorCode",
|
|
475
532
|
"errorTitle": "mm_Yva_errorTitle",
|
|
476
533
|
"frame": "mm_Yva_frame",
|
|
534
|
+
"mode": "mm_Yva_mode",
|
|
477
535
|
"root": "mm_Yva_root",
|
|
478
536
|
"status": "mm_Yva_status",
|
|
479
537
|
"statusText": "mm_Yva_statusText",
|
|
@@ -551,6 +609,8 @@ window.__ModuleLoader__.load({
|
|
|
551
609
|
const socketRef = (0, react.useRef)(null);
|
|
552
610
|
/** Last active tab seen in a state push; a tab switch invalidates the picture. */
|
|
553
611
|
const lastActiveTabRef = (0, react.useRef)(null);
|
|
612
|
+
/** Browser source seen in the last state push; a source switch invalidates it too. */
|
|
613
|
+
const lastSourceRef = (0, react.useRef)({});
|
|
554
614
|
const factory = (0, react.useMemo)(() => socketFactory ?? ((handlers) => connectBrowserViewSocket(handlers, {
|
|
555
615
|
location,
|
|
556
616
|
sessionId
|
|
@@ -565,7 +625,15 @@ window.__ModuleLoader__.load({
|
|
|
565
625
|
setStatus(next);
|
|
566
626
|
},
|
|
567
627
|
onState: (next) => {
|
|
568
|
-
if (
|
|
628
|
+
if (lastSourceRef.current.mode !== next.mode || lastSourceRef.current.cdpEndpoint !== next.cdpEndpoint) {
|
|
629
|
+
lastSourceRef.current = {
|
|
630
|
+
mode: next.mode,
|
|
631
|
+
cdpEndpoint: next.cdpEndpoint
|
|
632
|
+
};
|
|
633
|
+
lastActiveTabRef.current = next.activeTabId;
|
|
634
|
+
setFrame(null);
|
|
635
|
+
setError(null);
|
|
636
|
+
} else if (lastActiveTabRef.current !== next.activeTabId) {
|
|
569
637
|
lastActiveTabRef.current = next.activeTabId;
|
|
570
638
|
setFrame(null);
|
|
571
639
|
}
|
|
@@ -602,6 +670,7 @@ window.__ModuleLoader__.load({
|
|
|
602
670
|
const dataUrl = visibleFrame === null ? null : `data:image/jpeg;base64,${visibleFrame.data}`;
|
|
603
671
|
const statusLabel = status !== "open" ? t("panel.status.connecting") : loading ? t("panel.status.loading") : t("panel.status.live");
|
|
604
672
|
const dotState = status !== "open" ? "idle" : loading ? "ongoing" : "done";
|
|
673
|
+
const modeLabel = state.mode === "cdp" ? t("panel.mode.real") : t("panel.mode.isolated");
|
|
605
674
|
const pageTitle = activeTab === null || activeTab.title.length === 0 ? void 0 : activeTab.title;
|
|
606
675
|
const url = activeTab?.url ?? "";
|
|
607
676
|
(0, react.useEffect)(() => {
|
|
@@ -647,13 +716,25 @@ window.__ModuleLoader__.load({
|
|
|
647
716
|
className: panel_module_css_default.status,
|
|
648
717
|
"data-dsh-part": BROWSER_VIEW_PARTS.status,
|
|
649
718
|
"aria-live": "polite",
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
719
|
+
title: state.cdpEndpoint ?? modeLabel,
|
|
720
|
+
children: [
|
|
721
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)(_deepseek_ai_dsh_client_ui_primitives.StateDot, {
|
|
722
|
+
state: dotState,
|
|
723
|
+
size: 10
|
|
724
|
+
}),
|
|
725
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
726
|
+
className: panel_module_css_default.statusText,
|
|
727
|
+
children: statusLabel
|
|
728
|
+
}),
|
|
729
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
730
|
+
className: panel_module_css_default.mode,
|
|
731
|
+
children: modeLabel
|
|
732
|
+
}),
|
|
733
|
+
state.mode === "cdp" && state.cdpEndpoint !== void 0 && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
734
|
+
className: panel_module_css_default.endpoint,
|
|
735
|
+
children: state.cdpEndpoint
|
|
736
|
+
})
|
|
737
|
+
]
|
|
657
738
|
}),
|
|
658
739
|
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
|
|
659
740
|
type: "button",
|
|
@@ -896,6 +977,1614 @@ window.__ModuleLoader__.load({
|
|
|
896
977
|
});
|
|
897
978
|
}
|
|
898
979
|
//#endregion
|
|
980
|
+
//#region \0dsh-css:packages/dsh-browser-view/src/client/config.module.css.mjs
|
|
981
|
+
const css$1 = "._1_mPwq_root{color:var(--dsw-alias-label-primary);font:var(--dsw-font-xxs-12);flex-direction:column;gap:10px;display:flex}._1_mPwq_switchRow{align-items:center;gap:8px;font-weight:600;display:inline-flex}._1_mPwq_field{flex-direction:column;gap:6px;display:flex}._1_mPwq_field input{box-sizing:border-box;width:100%;height:30px;color:var(--dsw-alias-label-primary);font:var(--dsw-font-xxs-12);background:var(--dsw-alias-bg-layer-1);border:.5px solid var(--dsw-alias-border-l2);border-radius:var(--dsw-radius-sm);padding:0 9px}._1_mPwq_field input:focus{outline:1px solid var(--dsw-alias-state-business-primary);outline-offset:-1px}._1_mPwq_field input:disabled,._1_mPwq_switchRow input:disabled{color:var(--dsw-alias-label-quaternary);cursor:default}._1_mPwq_hint{color:var(--dsw-alias-label-tertiary);margin:0;line-height:18px}._1_mPwq_error{color:var(--dsw-alias-state-business-danger);margin:0;line-height:18px}";
|
|
982
|
+
const tagId$1 = "@linxin666/dsh-client-ui-browser-view/packages/dsh-browser-view/src/client/config.module.css";
|
|
983
|
+
if (typeof document !== "undefined" && document.querySelector("style[data-plugin-css=" + JSON.stringify(tagId$1) + "]") === null) {
|
|
984
|
+
const tag = document.createElement("style");
|
|
985
|
+
tag.dataset.plugin = "@linxin666/dsh-client-ui-browser-view";
|
|
986
|
+
tag.dataset.pluginCss = tagId$1;
|
|
987
|
+
tag.textContent = css$1;
|
|
988
|
+
document.head.appendChild(tag);
|
|
989
|
+
}
|
|
990
|
+
var config_module_css_default = {
|
|
991
|
+
"error": "_1_mPwq_error",
|
|
992
|
+
"field": "_1_mPwq_field",
|
|
993
|
+
"hint": "_1_mPwq_hint",
|
|
994
|
+
"root": "_1_mPwq_root",
|
|
995
|
+
"switchRow": "_1_mPwq_switchRow"
|
|
996
|
+
};
|
|
997
|
+
//#endregion
|
|
998
|
+
//#region src/client/config.tsx
|
|
999
|
+
/** Configuration-seat keys for standalone and aggregate bundle rows. */
|
|
1000
|
+
const BROWSER_VIEW_CONFIG_KEYS = ["@linxin666/dsh-client-ui-browser-view#ui-browser-view", "@linxin666/dsh-client-ui-browser-view#web-ui-browser-view"];
|
|
1001
|
+
/** The row configuration form backed by the Host's volatile settings namespace. */
|
|
1002
|
+
function BrowserViewConfig({ t, view, form }) {
|
|
1003
|
+
const values = form?.state.value;
|
|
1004
|
+
const enabled = values?.realBrowserEnabled === true;
|
|
1005
|
+
const endpoint = typeof values?.cdpEndpoint === "string" && values.cdpEndpoint.length > 0 ? values.cdpEndpoint : "http://127.0.0.1:9222";
|
|
1006
|
+
const [draft, setDraft] = (0, react.useState)(endpoint);
|
|
1007
|
+
const [pending, setPending] = (0, react.useState)(false);
|
|
1008
|
+
const [failed, setFailed] = (0, react.useState)(false);
|
|
1009
|
+
(0, react.useEffect)(() => {
|
|
1010
|
+
setDraft(endpoint);
|
|
1011
|
+
}, [endpoint]);
|
|
1012
|
+
if (view === "summary") return t("config.summary");
|
|
1013
|
+
if (form === void 0 || form.state.status !== "ready") return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
|
|
1014
|
+
className: config_module_css_default.hint,
|
|
1015
|
+
children: t("config.unavailable")
|
|
1016
|
+
});
|
|
1017
|
+
const disabled = pending || !form.state.writable;
|
|
1018
|
+
const mutate = async (ops) => {
|
|
1019
|
+
setPending(true);
|
|
1020
|
+
setFailed(false);
|
|
1021
|
+
try {
|
|
1022
|
+
if (!await form.mutate(ops, form.state.revision)) setFailed(true);
|
|
1023
|
+
} catch {
|
|
1024
|
+
setFailed(true);
|
|
1025
|
+
} finally {
|
|
1026
|
+
setPending(false);
|
|
1027
|
+
}
|
|
1028
|
+
};
|
|
1029
|
+
const commitEndpoint = async () => {
|
|
1030
|
+
const next = draft.trim();
|
|
1031
|
+
if (next === endpoint || next === "") return;
|
|
1032
|
+
await mutate([{
|
|
1033
|
+
op: "set",
|
|
1034
|
+
path: ["cdpEndpoint"],
|
|
1035
|
+
value: next
|
|
1036
|
+
}]);
|
|
1037
|
+
};
|
|
1038
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("section", {
|
|
1039
|
+
className: config_module_css_default.root,
|
|
1040
|
+
"data-dsh-plugin": BROWSER_VIEW_PLUGIN,
|
|
1041
|
+
"aria-busy": pending,
|
|
1042
|
+
children: [
|
|
1043
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("label", {
|
|
1044
|
+
className: config_module_css_default.switchRow,
|
|
1045
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("input", {
|
|
1046
|
+
type: "checkbox",
|
|
1047
|
+
role: "switch",
|
|
1048
|
+
checked: enabled,
|
|
1049
|
+
disabled,
|
|
1050
|
+
onChange: (event) => {
|
|
1051
|
+
mutate([{
|
|
1052
|
+
op: "set",
|
|
1053
|
+
path: ["realBrowserEnabled"],
|
|
1054
|
+
value: event.currentTarget.checked
|
|
1055
|
+
}]);
|
|
1056
|
+
}
|
|
1057
|
+
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", { children: t("config.realBrowserEnabled") })]
|
|
1058
|
+
}),
|
|
1059
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
|
|
1060
|
+
className: config_module_css_default.hint,
|
|
1061
|
+
children: t("config.realBrowserEnabled.hint")
|
|
1062
|
+
}),
|
|
1063
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("label", {
|
|
1064
|
+
className: config_module_css_default.field,
|
|
1065
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", { children: t("config.cdpEndpoint") }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("input", {
|
|
1066
|
+
type: "text",
|
|
1067
|
+
value: draft,
|
|
1068
|
+
disabled,
|
|
1069
|
+
spellCheck: false,
|
|
1070
|
+
onChange: (event) => {
|
|
1071
|
+
setDraft(event.currentTarget.value);
|
|
1072
|
+
},
|
|
1073
|
+
onBlur: () => {
|
|
1074
|
+
commitEndpoint();
|
|
1075
|
+
},
|
|
1076
|
+
onKeyDown: (event) => {
|
|
1077
|
+
if (event.key === "Enter") {
|
|
1078
|
+
event.preventDefault();
|
|
1079
|
+
event.currentTarget.blur();
|
|
1080
|
+
}
|
|
1081
|
+
}
|
|
1082
|
+
})]
|
|
1083
|
+
}),
|
|
1084
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
|
|
1085
|
+
className: config_module_css_default.hint,
|
|
1086
|
+
children: t("config.cdpEndpoint.hint")
|
|
1087
|
+
}),
|
|
1088
|
+
failed && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
|
|
1089
|
+
className: config_module_css_default.error,
|
|
1090
|
+
role: "alert",
|
|
1091
|
+
children: t("config.failed")
|
|
1092
|
+
})
|
|
1093
|
+
]
|
|
1094
|
+
});
|
|
1095
|
+
}
|
|
1096
|
+
//#endregion
|
|
1097
|
+
//#region \0dsh-css:packages/dsh-browser-view/src/client/settings-card.module.css.mjs
|
|
1098
|
+
const css = ".hZ1vmG_card{--settings-card-radius:12px;--settings-card-header-pad:16px;--settings-card-header-gap:13px;--settings-card-title-size:15px;--settings-card-description-size:13px;--settings-card-body-inset:16px;--settings-card-motion:.18s;border:1px solid var(--dsw-alias-border-l2);background:var(--dsw-alias-bg-layer-3);border-radius:var(--settings-card-radius);list-style:none;transition:border-color .16s,background .16s}.hZ1vmG_card:hover{border-color:var(--dsw-alias-label-dimmed)}.hZ1vmG_cardOpen{background:var(--dsw-alias-bg-layer-2);border-color:var(--dsw-alias-label-dimmed)}.hZ1vmG_cardNested{--settings-card-radius:10px;--settings-card-header-pad:10px 12px;--settings-card-header-gap:10px;--settings-card-title-size:13px;--settings-card-description-size:12px;--settings-card-body-inset:12px}.hZ1vmG_cardNested .hZ1vmG_description{white-space:nowrap;text-overflow:ellipsis;overflow:hidden}.hZ1vmG_header{appearance:none;box-sizing:border-box;width:100%;font:inherit;color:inherit;text-align:left;cursor:pointer;border-radius:var(--settings-card-radius);align-items:center;gap:var(--settings-card-header-gap);padding:var(--settings-card-header-pad);background:0 0;border:0;display:flex}.hZ1vmG_header:focus-visible{outline:2px solid var(--dsw-alias-brand-primary);outline-offset:-2px}.hZ1vmG_headerStatic{box-sizing:border-box;border-radius:var(--settings-card-radius);align-items:center;gap:var(--settings-card-header-gap);width:100%;padding:var(--settings-card-header-pad);display:flex}.hZ1vmG_headText{flex-direction:column;flex:1;gap:4px;min-width:0;display:flex}.hZ1vmG_mark{background:var(--dsw-alias-bg-module-platform);width:34px;height:34px;color:var(--dsw-alias-label-secondary);border-radius:10px;flex:none;place-items:center;transition:color .16s;display:grid}.hZ1vmG_header:hover .hZ1vmG_mark,.hZ1vmG_cardOpen .hZ1vmG_mark{color:var(--dsw-alias-label-primary)}.hZ1vmG_name{color:var(--dsw-alias-label-primary);font-size:var(--settings-card-title-size);font-weight:600;line-height:1.4}.hZ1vmG_description{color:var(--dsw-alias-label-secondary);font-size:12px;line-height:18px}.hZ1vmG_headerAction{flex:none;align-items:center;display:inline-flex}.hZ1vmG_chevron{color:var(--dsw-alias-label-tertiary);flex:none;width:16px;height:16px;transition:transform .16s,color .16s}.hZ1vmG_header:hover .hZ1vmG_chevron{color:var(--dsw-alias-label-secondary)}.hZ1vmG_chevronOpen{transform:rotate(180deg)}.hZ1vmG_disclosure{opacity:0;transition:grid-template-rows var(--settings-card-motion) ease, opacity var(--settings-card-motion) ease;grid-template-rows:0fr;display:grid}.hZ1vmG_disclosure[data-state=collapsed],.hZ1vmG_disclosure[data-state=entering],.hZ1vmG_disclosure[data-state=closing]{overflow:hidden}.hZ1vmG_disclosure[data-state=entering],.hZ1vmG_disclosure[data-state=shown]{opacity:1;grid-template-rows:1fr}.hZ1vmG_disclosure>.hZ1vmG_body{min-height:0}.hZ1vmG_body{border-top:1px solid var(--dsw-alias-border-l2);margin:0 var(--settings-card-body-inset);padding-bottom:8px;container:hZ1vmG_settings-card/inline-size}.hZ1vmG_readOnly{color:var(--dsw-alias-label-secondary);margin:12px 0 0;font-size:12px;line-height:1.5}.hZ1vmG_notExposed{color:var(--dsw-alias-state-warn-primary);margin:12px 0 0;font-size:12px;line-height:1.5}.hZ1vmG_failed{color:var(--dsw-alias-state-error-primary,#b42318);overflow-wrap:anywhere;margin:8px 0 4px;font-size:12px;line-height:18px}.hZ1vmG_field{grid-template-columns:minmax(0,1fr) fit-content(50%);grid-template-areas:\"hZ1vmG_head hZ1vmG_control\"\"hZ1vmG_hint hZ1vmG_control\";align-items:center;gap:4px 24px;padding:16px 0;display:grid}.hZ1vmG_field>.hZ1vmG_head{grid-area:hZ1vmG_head}.hZ1vmG_field>:is(.hZ1vmG_hint,.hZ1vmG_invalid){grid-area:hZ1vmG_hint}.hZ1vmG_field>:not(.hZ1vmG_head,.hZ1vmG_hint,.hZ1vmG_invalid){grid-area:hZ1vmG_control;justify-self:end;max-width:100%}.hZ1vmG_field+.hZ1vmG_field{border-top:1px solid var(--dsw-alias-border-l2)}.hZ1vmG_head{align-items:center;gap:8px;display:flex}.hZ1vmG_label{min-width:0;color:var(--dsw-alias-label-primary);flex:1;font-size:14px;font-weight:400;line-height:22px}.hZ1vmG_badges{align-items:center;gap:8px;display:inline-flex}.hZ1vmG_badge{white-space:nowrap;background:var(--dsw-alias-bg-module-platform);color:var(--dsw-alias-label-secondary);border-radius:999px;padding:1px 8px;font-size:11px;font-weight:500;line-height:17px}.hZ1vmG_reset{font:inherit;color:var(--dsw-alias-label-secondary);cursor:pointer;background:0 0;border:none;padding:0;font-size:12px;line-height:1.5}.hZ1vmG_reset:hover:not(:disabled){color:var(--dsw-alias-label-primary)}.hZ1vmG_reset:disabled{cursor:default}.hZ1vmG_reset:focus-visible{outline:2px solid var(--dsw-alias-brand-primary);outline-offset:2px}.hZ1vmG_segmentGroup{background:color-mix(in srgb, var(--dsw-alias-label-primary) 7%, transparent);box-shadow:inset 0 0 0 1px color-mix(in srgb, var(--dsw-alias-label-primary) 5%, transparent);border-radius:8px;flex-wrap:wrap;align-items:center;gap:2px;padding:2px;display:inline-flex;position:relative}.hZ1vmG_segment{appearance:none;color:var(--dsw-alias-label-secondary);font:inherit;white-space:nowrap;cursor:pointer;background:0 0;border:0;border-radius:7px;margin:0;padding:3px 12px;font-size:13px;font-weight:500;line-height:18px;transition:background-color .12s,color .12s}.hZ1vmG_segment:hover:not(:disabled):not([data-active]){color:var(--dsw-alias-label-primary)}.hZ1vmG_segmentGroup:not([data-pill])>.hZ1vmG_segment[data-active],.hZ1vmG_segmentGroup[data-pill]:before{background:var(--dsw-alias-bg-overlay,var(--dsw-alias-bg-layer-3));box-shadow:0 1px 2px #14141314}body[data-ds-dark-theme] .hZ1vmG_segmentGroup:not([data-pill])>.hZ1vmG_segment[data-active],body[data-ds-dark-theme] .hZ1vmG_segmentGroup[data-pill]:before{box-shadow:none;background:#ffffff24}.hZ1vmG_segment[data-active]{color:var(--dsw-alias-label-primary)}.hZ1vmG_segmentGroup[data-pill]:before{content:\"\";width:var(--segment-pill-w,0px);height:var(--segment-pill-h,0px);transform:translate(var(--segment-pill-x,0px), var(--segment-pill-y,0px));pointer-events:none;border-radius:7px;transition:transform .24s cubic-bezier(.22,.61,.36,1),width .24s cubic-bezier(.22,.61,.36,1),height .24s cubic-bezier(.22,.61,.36,1);position:absolute;top:0;left:0}.hZ1vmG_segmentGroup>*{z-index:1;position:relative}.hZ1vmG_segment:focus-visible{outline:2px solid var(--dsw-alias-brand-primary);outline-offset:1px}.hZ1vmG_segment:disabled{cursor:not-allowed;opacity:.45}.hZ1vmG_segmentGroup[data-pill]:has(>.hZ1vmG_segment:disabled):before{opacity:.45}.hZ1vmG_input,.hZ1vmG_select{border:1px solid var(--dsw-alias-border-l2);background:var(--dsw-alias-bg-layer-3);height:34px;font:inherit;color:var(--dsw-alias-label-primary);border-radius:8px;padding:0 12px;font-size:13px;line-height:1.5}.hZ1vmG_input:focus-visible,.hZ1vmG_select:focus-visible{border-color:var(--dsw-alias-brand-primary);outline:none}.hZ1vmG_input:disabled,.hZ1vmG_select:disabled{color:var(--dsw-alias-label-tertiary);cursor:default}.hZ1vmG_inputInvalid{border:1px solid var(--dsw-alias-state-error-primary,#b42318);background:var(--dsw-alias-bg-layer-3);height:34px;font:inherit;color:var(--dsw-alias-label-primary);border-radius:8px;padding:0 12px;font-size:13px;line-height:1.5}.hZ1vmG_inputInvalid:focus-visible{outline:2px solid var(--dsw-alias-state-error-primary,#b42318);outline-offset:1px;border-color:var(--dsw-alias-state-error-primary,#b42318)}.hZ1vmG_field>:is(.hZ1vmG_input,.hZ1vmG_inputInvalid,.hZ1vmG_select,.hZ1vmG_selectWrap,.hZ1vmG_rangeAnchor){box-sizing:border-box;width:220px}.hZ1vmG_rangeAnchor>:is(.hZ1vmG_input,.hZ1vmG_inputInvalid){box-sizing:border-box;width:100%}@container hZ1vmG_settings-card (width<=440px){.hZ1vmG_field{grid-template-columns:minmax(0,1fr);grid-template-areas:\"hZ1vmG_head\"\"hZ1vmG_hint\"\"hZ1vmG_control\";row-gap:8px}.hZ1vmG_field>:not(.hZ1vmG_head,.hZ1vmG_hint,.hZ1vmG_invalid){justify-self:start}.hZ1vmG_field>:is(.hZ1vmG_input,.hZ1vmG_inputInvalid,.hZ1vmG_select,.hZ1vmG_selectWrap,.hZ1vmG_rangeAnchor){justify-self:stretch;width:auto}}.hZ1vmG_selectWrap{position:relative}.hZ1vmG_selectButton{appearance:none;text-align:left;cursor:pointer;justify-content:space-between;align-items:center;gap:8px;width:100%;display:flex}.hZ1vmG_selectLabel{text-overflow:ellipsis;white-space:nowrap;min-width:0;overflow:hidden}.hZ1vmG_selectChevron{color:var(--dsw-alias-label-tertiary);flex:none;transition:transform .16s}.hZ1vmG_selectChevronOpen{transform:rotate(180deg)}.hZ1vmG_selectPopup{z-index:40;border:1px solid var(--dsw-alias-border-l2);background:var(--dsw-alias-bg-layer-3);max-height:240px;box-shadow:0 8px 24px var(--dsw-alias-bg-mask-2);opacity:0;border-radius:8px;flex-direction:column;padding:4px;transition:opacity .1s,transform .1s;display:flex;position:absolute;top:calc(100% + 4px);left:0;right:0;overflow-y:auto;transform:translateY(-4px)}.hZ1vmG_selectPopupOpen{opacity:1;transform:none}.hZ1vmG_selectPopupClose{opacity:0;pointer-events:none;transform:translateY(-4px)}.hZ1vmG_rangeAnchor{display:inline-flex;position:relative}.hZ1vmG_rangeBubble{z-index:40;box-sizing:border-box;border:1px solid var(--dsw-alias-border-l2);background:var(--dsw-alias-bg-layer-3);width:220px;box-shadow:0 8px 24px var(--dsw-alias-bg-mask-2);opacity:0;visibility:hidden;border-radius:10px;padding:10px 12px 6px;transition:opacity .12s,transform .12s,visibility 0s linear .12s;position:absolute;right:0}.hZ1vmG_rangeBubble[data-side=above]{bottom:calc(100% + 6px);transform:translateY(4px)}.hZ1vmG_rangeBubble[data-side=below]{top:calc(100% + 6px);transform:translateY(-4px)}.hZ1vmG_rangeBubble[data-open]{opacity:1;visibility:visible;transition:opacity .12s,transform .12s,visibility;transform:none}.hZ1vmG_rangeSlider{appearance:none;cursor:pointer;background:0 0;width:100%;height:18px;margin:0;display:block}.hZ1vmG_rangeSlider::-webkit-slider-runnable-track{background:linear-gradient(to right, var(--dsw-alias-brand-primary) var(--range-fill,0%), color-mix(in srgb, var(--dsw-alias-label-primary) 12%, transparent) var(--range-fill,0%));border-radius:999px;height:4px}.hZ1vmG_rangeSlider::-moz-range-track{background:color-mix(in srgb, var(--dsw-alias-label-primary) 12%, transparent);border-radius:999px;height:4px}.hZ1vmG_rangeSlider::-moz-range-progress{background:var(--dsw-alias-brand-primary);border-radius:999px;height:4px}.hZ1vmG_rangeSlider::-webkit-slider-thumb{appearance:none;background:#fff;border:0;border-radius:50%;width:14px;height:14px;margin-top:-5px;transition:transform .12s;box-shadow:0 0 0 1px #0000001f,0 1px 3px #00000040}.hZ1vmG_rangeSlider::-moz-range-thumb{background:#fff;border:0;border-radius:50%;width:14px;height:14px;box-shadow:0 0 0 1px #0000001f,0 1px 3px #00000040}.hZ1vmG_rangeSlider:active::-webkit-slider-thumb{transform:scale(1.15)}.hZ1vmG_rangeSlider:focus-visible{outline:none}.hZ1vmG_rangeSlider:focus-visible::-webkit-slider-thumb{box-shadow:0 0 0 2px var(--dsw-alias-brand-primary)}.hZ1vmG_rangeSlider:disabled{cursor:not-allowed}.hZ1vmG_rangeEnds{color:var(--dsw-alias-label-secondary);font-variant-numeric:tabular-nums;justify-content:space-between;margin-top:2px;font-size:11px;line-height:16px;display:flex}.hZ1vmG_selectOption{color:var(--dsw-alias-label-primary);cursor:pointer;white-space:nowrap;text-overflow:ellipsis;border-radius:6px;flex-shrink:0;padding:6px 10px;font-size:13px;line-height:1.5;overflow:hidden}.hZ1vmG_selectOption:hover,.hZ1vmG_selectOptionActive{background:var(--dsw-alias-interactive-bg-hover)}.hZ1vmG_selectOptionSelected{color:var(--dsw-alias-brand-primary);background:color-mix(in srgb, var(--dsw-alias-brand-primary) 10%, transparent);font-weight:500}.hZ1vmG_invalid{color:var(--dsw-alias-state-error-primary,#b42318);margin:0;font-size:12px;line-height:18px}.hZ1vmG_hint{color:var(--dsw-alias-label-secondary);margin:0;font-size:12px;line-height:18px}.hZ1vmG_toggle{appearance:none;cursor:pointer;font:inherit;background:0 0;border:0;border-radius:999px;align-items:center;margin:0;padding:0;display:inline-flex}.hZ1vmG_toggleTrack{background:var(--dsw-alias-label-dimmed);border-radius:999px;flex:none;width:36px;height:20px;transition:background-color .18s;position:relative}.hZ1vmG_toggleThumb{--toggle-travel:16px;--toggle-overshoot:1px;background:var(--dsw-alias-bg-layer-3);border-radius:50%;width:16px;height:16px;transition:translate .18s;position:absolute;top:2px;left:2px;translate:0;box-shadow:0 1px 2px #1414132e}.hZ1vmG_toggle[aria-checked=true] .hZ1vmG_toggleTrack{background:var(--dsw-alias-button-primary-fill,var(--dsw-alias-label-primary))}.hZ1vmG_toggle[aria-checked=true] .hZ1vmG_toggleThumb{translate:var(--toggle-travel) 0;background:var(--dsw-alias-label-primary-foreground,var(--dsw-alias-bg-layer-3))}.hZ1vmG_toggle[data-moved][aria-checked=true] .hZ1vmG_toggleThumb{animation:.35s cubic-bezier(.34,1.45,.64,1) both hZ1vmG_toggle-on}.hZ1vmG_toggle[data-moved][aria-checked=false] .hZ1vmG_toggleThumb{animation:.35s cubic-bezier(.34,1.45,.64,1) both hZ1vmG_toggle-off}@keyframes hZ1vmG_toggle-on{0%{translate:0}55%{translate:calc(var(--toggle-travel) + var(--toggle-overshoot)) 0}80%,to{translate:var(--toggle-travel) 0}}@keyframes hZ1vmG_toggle-off{0%{translate:var(--toggle-travel) 0}55%{translate:calc(0px - var(--toggle-overshoot)) 0}80%,to{translate:0}}.hZ1vmG_toggle:focus-visible{outline:2px solid var(--dsw-alias-brand-primary);outline-offset:2px}.hZ1vmG_toggle:disabled{opacity:.45;cursor:not-allowed}@media (prefers-reduced-motion:reduce){.hZ1vmG_card,.hZ1vmG_header,.hZ1vmG_mark,.hZ1vmG_chevron,.hZ1vmG_chevronOpen,.hZ1vmG_rangeBubble,.hZ1vmG_selectChevron,.hZ1vmG_selectChevronOpen,.hZ1vmG_selectPopup,.hZ1vmG_toggleTrack,.hZ1vmG_toggleThumb{transition:none}.hZ1vmG_toggle[data-moved] .hZ1vmG_toggleThumb{animation:none}.hZ1vmG_disclosure{transition-property:opacity}}";
|
|
1099
|
+
const tagId = "@linxin666/dsh-client-ui-browser-view/packages/dsh-browser-view/src/client/settings-card.module.css";
|
|
1100
|
+
if (typeof document !== "undefined" && document.querySelector("style[data-plugin-css=" + JSON.stringify(tagId) + "]") === null) {
|
|
1101
|
+
const tag = document.createElement("style");
|
|
1102
|
+
tag.dataset.plugin = "@linxin666/dsh-client-ui-browser-view";
|
|
1103
|
+
tag.dataset.pluginCss = tagId;
|
|
1104
|
+
tag.textContent = css;
|
|
1105
|
+
document.head.appendChild(tag);
|
|
1106
|
+
}
|
|
1107
|
+
var settings_card_module_css_default = {
|
|
1108
|
+
"badge": "hZ1vmG_badge",
|
|
1109
|
+
"badges": "hZ1vmG_badges",
|
|
1110
|
+
"body": "hZ1vmG_body",
|
|
1111
|
+
"card": "hZ1vmG_card",
|
|
1112
|
+
"cardNested": "hZ1vmG_cardNested",
|
|
1113
|
+
"cardOpen": "hZ1vmG_cardOpen",
|
|
1114
|
+
"chevron": "hZ1vmG_chevron",
|
|
1115
|
+
"chevronOpen": "hZ1vmG_chevronOpen",
|
|
1116
|
+
"control": "hZ1vmG_control",
|
|
1117
|
+
"description": "hZ1vmG_description",
|
|
1118
|
+
"disclosure": "hZ1vmG_disclosure",
|
|
1119
|
+
"failed": "hZ1vmG_failed",
|
|
1120
|
+
"field": "hZ1vmG_field",
|
|
1121
|
+
"head": "hZ1vmG_head",
|
|
1122
|
+
"headText": "hZ1vmG_headText",
|
|
1123
|
+
"header": "hZ1vmG_header",
|
|
1124
|
+
"headerAction": "hZ1vmG_headerAction",
|
|
1125
|
+
"headerStatic": "hZ1vmG_headerStatic",
|
|
1126
|
+
"hint": "hZ1vmG_hint",
|
|
1127
|
+
"input": "hZ1vmG_input",
|
|
1128
|
+
"inputInvalid": "hZ1vmG_inputInvalid",
|
|
1129
|
+
"invalid": "hZ1vmG_invalid",
|
|
1130
|
+
"label": "hZ1vmG_label",
|
|
1131
|
+
"mark": "hZ1vmG_mark",
|
|
1132
|
+
"name": "hZ1vmG_name",
|
|
1133
|
+
"notExposed": "hZ1vmG_notExposed",
|
|
1134
|
+
"rangeAnchor": "hZ1vmG_rangeAnchor",
|
|
1135
|
+
"rangeBubble": "hZ1vmG_rangeBubble",
|
|
1136
|
+
"rangeEnds": "hZ1vmG_rangeEnds",
|
|
1137
|
+
"rangeSlider": "hZ1vmG_rangeSlider",
|
|
1138
|
+
"readOnly": "hZ1vmG_readOnly",
|
|
1139
|
+
"reset": "hZ1vmG_reset",
|
|
1140
|
+
"segment": "hZ1vmG_segment",
|
|
1141
|
+
"segmentGroup": "hZ1vmG_segmentGroup",
|
|
1142
|
+
"select": "hZ1vmG_select",
|
|
1143
|
+
"selectButton": "hZ1vmG_selectButton",
|
|
1144
|
+
"selectChevron": "hZ1vmG_selectChevron",
|
|
1145
|
+
"selectChevronOpen": "hZ1vmG_selectChevronOpen",
|
|
1146
|
+
"selectLabel": "hZ1vmG_selectLabel",
|
|
1147
|
+
"selectOption": "hZ1vmG_selectOption",
|
|
1148
|
+
"selectOptionActive": "hZ1vmG_selectOptionActive",
|
|
1149
|
+
"selectOptionSelected": "hZ1vmG_selectOptionSelected",
|
|
1150
|
+
"selectPopup": "hZ1vmG_selectPopup",
|
|
1151
|
+
"selectPopupClose": "hZ1vmG_selectPopupClose",
|
|
1152
|
+
"selectPopupOpen": "hZ1vmG_selectPopupOpen",
|
|
1153
|
+
"selectWrap": "hZ1vmG_selectWrap",
|
|
1154
|
+
"settings-card": "hZ1vmG_settings-card",
|
|
1155
|
+
"toggle": "hZ1vmG_toggle",
|
|
1156
|
+
"toggle-off": "hZ1vmG_toggle-off",
|
|
1157
|
+
"toggle-on": "hZ1vmG_toggle-on",
|
|
1158
|
+
"toggleThumb": "hZ1vmG_toggleThumb",
|
|
1159
|
+
"toggleTrack": "hZ1vmG_toggleTrack"
|
|
1160
|
+
};
|
|
1161
|
+
//#endregion
|
|
1162
|
+
//#region src/client/RangeBubble.tsx
|
|
1163
|
+
/**
|
|
1164
|
+
* Coarse adjustment for a bounded number: resting the pointer on the control
|
|
1165
|
+
* (or moving focus into it) raises a small bubble holding a slider across the
|
|
1166
|
+
* field's whole range, so a large change is one drag instead of many presses
|
|
1167
|
+
* or a retyped value. The control itself stays the precise entry.
|
|
1168
|
+
*
|
|
1169
|
+
* The bubble belongs to the anchor's subtree, so moving from the control onto
|
|
1170
|
+
* the bubble never counts as leaving. It opens after a short rest and closes a
|
|
1171
|
+
* moment after the pointer and focus have both gone, so crossing the control
|
|
1172
|
+
* on the way elsewhere does not flash it. While a drag is in progress the
|
|
1173
|
+
* bubble stays put even if the pointer strays off it.
|
|
1174
|
+
*
|
|
1175
|
+
* Dragging reports each value through `onInput`, so the field shows it live;
|
|
1176
|
+
* releasing the thumb, or a key press on it, reports `onCommit` once. The
|
|
1177
|
+
* bubble opens on the side of the control that has room inside the nearest
|
|
1178
|
+
* scrolling ancestor, so a row near the top of a settings page does not hang
|
|
1179
|
+
* its bubble under the page edge.
|
|
1180
|
+
*/
|
|
1181
|
+
/** Rest on the control before the bubble opens. */
|
|
1182
|
+
const OPEN_DELAY_MS = 220;
|
|
1183
|
+
/** Grace after pointer and focus have left before the bubble closes. */
|
|
1184
|
+
const CLOSE_DELAY_MS = 200;
|
|
1185
|
+
/** Room the bubble needs between the control and the scroller's edge. */
|
|
1186
|
+
const BUBBLE_ROOM_PX = 64;
|
|
1187
|
+
/** The nearest ancestor that scrolls vertically, or the viewport's root. */
|
|
1188
|
+
function scroller(node) {
|
|
1189
|
+
for (let parent = node.parentElement; parent !== null; parent = parent.parentElement) {
|
|
1190
|
+
const overflow = getComputedStyle(parent).overflowY;
|
|
1191
|
+
if (overflow === "auto" || overflow === "scroll") return parent;
|
|
1192
|
+
}
|
|
1193
|
+
return node.ownerDocument.documentElement;
|
|
1194
|
+
}
|
|
1195
|
+
/**
|
|
1196
|
+
* Render the control with its coarse-adjustment bubble.
|
|
1197
|
+
* @param props - the range, the value and the two report callbacks.
|
|
1198
|
+
* @returns the anchor holding the control and the bubble.
|
|
1199
|
+
*/
|
|
1200
|
+
function RangeBubble(props) {
|
|
1201
|
+
const { min, max, step, disabled = false } = props;
|
|
1202
|
+
const [open, setOpen] = (0, react.useState)(false);
|
|
1203
|
+
const [side, setSide] = (0, react.useState)("above");
|
|
1204
|
+
const [live, setLive] = (0, react.useState)(null);
|
|
1205
|
+
const anchorRef = (0, react.useRef)(null);
|
|
1206
|
+
const timer = (0, react.useRef)(void 0);
|
|
1207
|
+
const hovered = (0, react.useRef)(false);
|
|
1208
|
+
const focused = (0, react.useRef)(false);
|
|
1209
|
+
const dragging = (0, react.useRef)(false);
|
|
1210
|
+
(0, react.useEffect)(() => () => {
|
|
1211
|
+
clearTimeout(timer.current);
|
|
1212
|
+
}, []);
|
|
1213
|
+
(0, react.useEffect)(() => {
|
|
1214
|
+
if (disabled) {
|
|
1215
|
+
clearTimeout(timer.current);
|
|
1216
|
+
setOpen(false);
|
|
1217
|
+
}
|
|
1218
|
+
}, [disabled]);
|
|
1219
|
+
const show = () => {
|
|
1220
|
+
const anchor = anchorRef.current;
|
|
1221
|
+
if (anchor !== null) {
|
|
1222
|
+
const room = anchor.getBoundingClientRect().top - scroller(anchor).getBoundingClientRect().top;
|
|
1223
|
+
setSide(room >= BUBBLE_ROOM_PX ? "above" : "below");
|
|
1224
|
+
}
|
|
1225
|
+
setOpen(true);
|
|
1226
|
+
};
|
|
1227
|
+
const schedule = () => {
|
|
1228
|
+
clearTimeout(timer.current);
|
|
1229
|
+
if (disabled) return;
|
|
1230
|
+
if (hovered.current || focused.current || dragging.current) {
|
|
1231
|
+
if (!open) timer.current = setTimeout(show, focused.current ? 0 : OPEN_DELAY_MS);
|
|
1232
|
+
return;
|
|
1233
|
+
}
|
|
1234
|
+
timer.current = setTimeout(() => {
|
|
1235
|
+
setOpen(false);
|
|
1236
|
+
}, CLOSE_DELAY_MS);
|
|
1237
|
+
};
|
|
1238
|
+
const commit = (value) => {
|
|
1239
|
+
dragging.current = false;
|
|
1240
|
+
setLive(null);
|
|
1241
|
+
props.onCommit(value);
|
|
1242
|
+
schedule();
|
|
1243
|
+
};
|
|
1244
|
+
const onChange = (event) => {
|
|
1245
|
+
const value = Number(event.target.value);
|
|
1246
|
+
setLive(value);
|
|
1247
|
+
props.onInput(value);
|
|
1248
|
+
};
|
|
1249
|
+
const onKeyUp = (event) => {
|
|
1250
|
+
if (live !== null) commit(live);
|
|
1251
|
+
if (event.key === "Escape") {
|
|
1252
|
+
clearTimeout(timer.current);
|
|
1253
|
+
setOpen(false);
|
|
1254
|
+
}
|
|
1255
|
+
};
|
|
1256
|
+
const shown = live ?? Math.min(max, Math.max(min, props.value));
|
|
1257
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
1258
|
+
ref: anchorRef,
|
|
1259
|
+
className: settings_card_module_css_default.rangeAnchor,
|
|
1260
|
+
onPointerEnter: () => {
|
|
1261
|
+
hovered.current = true;
|
|
1262
|
+
schedule();
|
|
1263
|
+
},
|
|
1264
|
+
onPointerLeave: () => {
|
|
1265
|
+
hovered.current = false;
|
|
1266
|
+
schedule();
|
|
1267
|
+
},
|
|
1268
|
+
onFocus: () => {
|
|
1269
|
+
focused.current = true;
|
|
1270
|
+
schedule();
|
|
1271
|
+
},
|
|
1272
|
+
onBlur: (event) => {
|
|
1273
|
+
if (event.currentTarget.contains(event.relatedTarget)) return;
|
|
1274
|
+
focused.current = false;
|
|
1275
|
+
if (live !== null) commit(live);
|
|
1276
|
+
else schedule();
|
|
1277
|
+
},
|
|
1278
|
+
children: [props.children, /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
1279
|
+
className: settings_card_module_css_default.rangeBubble,
|
|
1280
|
+
"data-open": open ? "" : void 0,
|
|
1281
|
+
"data-side": side,
|
|
1282
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("input", {
|
|
1283
|
+
type: "range",
|
|
1284
|
+
className: settings_card_module_css_default.rangeSlider,
|
|
1285
|
+
min,
|
|
1286
|
+
max,
|
|
1287
|
+
step,
|
|
1288
|
+
value: shown,
|
|
1289
|
+
"aria-label": props.label,
|
|
1290
|
+
tabIndex: open ? 0 : -1,
|
|
1291
|
+
disabled,
|
|
1292
|
+
style: { "--range-fill": `${(shown - min) / (max - min) * 100}%` },
|
|
1293
|
+
onPointerDown: () => {
|
|
1294
|
+
dragging.current = true;
|
|
1295
|
+
},
|
|
1296
|
+
onPointerUp: (event) => {
|
|
1297
|
+
commit(Number(event.currentTarget.value));
|
|
1298
|
+
},
|
|
1299
|
+
onPointerCancel: (event) => {
|
|
1300
|
+
commit(Number(event.currentTarget.value));
|
|
1301
|
+
},
|
|
1302
|
+
onChange,
|
|
1303
|
+
onKeyUp
|
|
1304
|
+
}), /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("span", {
|
|
1305
|
+
className: settings_card_module_css_default.rangeEnds,
|
|
1306
|
+
"aria-hidden": "true",
|
|
1307
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", { children: min }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", { children: max })]
|
|
1308
|
+
})]
|
|
1309
|
+
})]
|
|
1310
|
+
});
|
|
1311
|
+
}
|
|
1312
|
+
//#endregion
|
|
1313
|
+
//#region src/client/SegmentGroup.tsx
|
|
1314
|
+
/**
|
|
1315
|
+
* The family's segmented control: a quiet track whose options share one
|
|
1316
|
+
* highlight that slides to the pressed option, instead of each option fading
|
|
1317
|
+
* its own background out and the next one in. The settings fields' small
|
|
1318
|
+
* choices and the Web Extensions TAB strip both render through it, so the two
|
|
1319
|
+
* read as one control.
|
|
1320
|
+
*
|
|
1321
|
+
* The caller builds the option buttons and marks the pressed one with
|
|
1322
|
+
* `data-active`; the group measures that button after every render and writes
|
|
1323
|
+
* its box as four custom properties, and the stylesheet draws the highlight
|
|
1324
|
+
* there (`.segmentGroup[data-pill]::before`). Attribute and first placement
|
|
1325
|
+
* land in the same task, so the highlight appears in place and only later
|
|
1326
|
+
* changes slide. A ResizeObserver re-measures when the group or an option
|
|
1327
|
+
* changes size: a longer locale, a font arriving, a container growing, a
|
|
1328
|
+
* strip wrapping onto a second line.
|
|
1329
|
+
*/
|
|
1330
|
+
/** The attribute marking a group whose highlight has been placed. */
|
|
1331
|
+
const PILL_ATTR = "data-pill";
|
|
1332
|
+
/** The pressed option, relative to the group. */
|
|
1333
|
+
const ACTIVE_SELECTOR = ":scope > [data-active]";
|
|
1334
|
+
const PILL_PROPERTIES = [
|
|
1335
|
+
"--segment-pill-x",
|
|
1336
|
+
"--segment-pill-y",
|
|
1337
|
+
"--segment-pill-w",
|
|
1338
|
+
"--segment-pill-h"
|
|
1339
|
+
];
|
|
1340
|
+
/**
|
|
1341
|
+
* Write the highlight's box from the pressed option's box, or take the
|
|
1342
|
+
* highlight off when nothing is pressed or the group has no layout yet.
|
|
1343
|
+
* The two boxes are read in viewport pixels and turned back into the group's
|
|
1344
|
+
* own CSS pixels, so a dialog that opens through a scale transform still
|
|
1345
|
+
* lands the highlight on its option.
|
|
1346
|
+
*/
|
|
1347
|
+
function placePill(group) {
|
|
1348
|
+
const item = group.querySelector(ACTIVE_SELECTOR);
|
|
1349
|
+
const box = group.getBoundingClientRect();
|
|
1350
|
+
if (item === null || group.offsetWidth === 0 || box.width === 0) {
|
|
1351
|
+
group.removeAttribute(PILL_ATTR);
|
|
1352
|
+
for (const property of PILL_PROPERTIES) group.style.removeProperty(property);
|
|
1353
|
+
return;
|
|
1354
|
+
}
|
|
1355
|
+
const scale = box.width / group.offsetWidth;
|
|
1356
|
+
const itemBox = item.getBoundingClientRect();
|
|
1357
|
+
[
|
|
1358
|
+
(itemBox.left - box.left) / scale - group.clientLeft,
|
|
1359
|
+
(itemBox.top - box.top) / scale - group.clientTop,
|
|
1360
|
+
itemBox.width / scale,
|
|
1361
|
+
itemBox.height / scale
|
|
1362
|
+
].forEach((value, index) => {
|
|
1363
|
+
group.style.setProperty(PILL_PROPERTIES[index], `${Math.round(value * 100) / 100}px`);
|
|
1364
|
+
});
|
|
1365
|
+
if (!group.hasAttribute(PILL_ATTR)) group.setAttribute(PILL_ATTR, "");
|
|
1366
|
+
}
|
|
1367
|
+
/**
|
|
1368
|
+
* Render a segmented track around the caller's option buttons.
|
|
1369
|
+
* @param props - the track's attributes (role, accessible name, key handler) and its options.
|
|
1370
|
+
* @returns the track.
|
|
1371
|
+
*/
|
|
1372
|
+
function SegmentGroup(props) {
|
|
1373
|
+
const { children, className, ...rest } = props;
|
|
1374
|
+
const group = (0, react.useRef)(null);
|
|
1375
|
+
const count = react.Children.count(children);
|
|
1376
|
+
(0, react.useLayoutEffect)(() => {
|
|
1377
|
+
if (group.current !== null) placePill(group.current);
|
|
1378
|
+
});
|
|
1379
|
+
(0, react.useLayoutEffect)(() => {
|
|
1380
|
+
const element = group.current;
|
|
1381
|
+
if (element === null || typeof ResizeObserver === "undefined") return void 0;
|
|
1382
|
+
const observer = new ResizeObserver(() => {
|
|
1383
|
+
placePill(element);
|
|
1384
|
+
});
|
|
1385
|
+
observer.observe(element);
|
|
1386
|
+
for (const item of Array.from(element.children)) observer.observe(item);
|
|
1387
|
+
return () => {
|
|
1388
|
+
observer.disconnect();
|
|
1389
|
+
};
|
|
1390
|
+
}, [count]);
|
|
1391
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
1392
|
+
...rest,
|
|
1393
|
+
ref: group,
|
|
1394
|
+
className: className === void 0 ? settings_card_module_css_default.segmentGroup : `${settings_card_module_css_default.segmentGroup} ${className}`,
|
|
1395
|
+
children
|
|
1396
|
+
});
|
|
1397
|
+
}
|
|
1398
|
+
//#endregion
|
|
1399
|
+
//#region src/client/PluginSettingsCard.tsx
|
|
1400
|
+
/**
|
|
1401
|
+
* Family-shared chrome for plugin settings cards: a disclosure header naming
|
|
1402
|
+
* the plugin and what its settings govern, the controls inside, and the line
|
|
1403
|
+
* that reports a refused write. A pick is written the moment it is made and a
|
|
1404
|
+
* typed value after a pause, so the card has no save button and nothing waits
|
|
1405
|
+
* on the reader. Renders nothing while the namespace is unavailable — a
|
|
1406
|
+
* deployment that does not compose the owning plugin should show no trace of
|
|
1407
|
+
* it. Inlined into each consumer's client bundle; mirrors the official
|
|
1408
|
+
* ui-plugin-config PluginCard in a self-contained slice.
|
|
1409
|
+
*
|
|
1410
|
+
* Every field inside the body is one settings row: the label and its hint on
|
|
1411
|
+
* the left, the control on the right, a hairline between two rows; a narrow
|
|
1412
|
+
* card stacks the control under the text (settings-card.module.css).
|
|
1413
|
+
*/
|
|
1414
|
+
/**
|
|
1415
|
+
* What a text field inside a card reaches without its plugin wiring it: write
|
|
1416
|
+
* the pending draft now (Enter, leaving the field) or put it back (Escape).
|
|
1417
|
+
* Picks need neither; they are written the moment they are made.
|
|
1418
|
+
*/
|
|
1419
|
+
const CardApply = (0, react.createContext)(null);
|
|
1420
|
+
/** Length of the body's disclosure motion; it matches `--settings-card-motion` on the card root. */
|
|
1421
|
+
const BODY_MOTION_MS = 180;
|
|
1422
|
+
/**
|
|
1423
|
+
* Render one plugin settings card.
|
|
1424
|
+
* @param props - the plugin's copy keys, its form state, and its controls.
|
|
1425
|
+
* @returns the card, or nothing while the namespace is still loading.
|
|
1426
|
+
*/
|
|
1427
|
+
function PluginSettingsCard(props) {
|
|
1428
|
+
const [open, setOpen] = (0, react.useState)(props.defaultOpen ?? true);
|
|
1429
|
+
const { state, alwaysOpen } = props;
|
|
1430
|
+
const expanded = alwaysOpen === true || open;
|
|
1431
|
+
const [bodyPhase, setBodyPhase] = (0, react.useState)(expanded ? "shown" : "hidden");
|
|
1432
|
+
const bodyRef = (0, react.useRef)(null);
|
|
1433
|
+
(0, react.useLayoutEffect)(() => {
|
|
1434
|
+
if (expanded) {
|
|
1435
|
+
if (bodyPhase === "hidden") setBodyPhase("collapsed");
|
|
1436
|
+
else if (bodyPhase === "collapsed") {
|
|
1437
|
+
const node = bodyRef.current;
|
|
1438
|
+
if (node !== null) node.offsetHeight;
|
|
1439
|
+
setBodyPhase("entering");
|
|
1440
|
+
} else if (bodyPhase === "closing") setBodyPhase("entering");
|
|
1441
|
+
return;
|
|
1442
|
+
}
|
|
1443
|
+
if (bodyPhase === "collapsed") setBodyPhase("hidden");
|
|
1444
|
+
else if (bodyPhase === "entering" || bodyPhase === "shown") setBodyPhase("closing");
|
|
1445
|
+
}, [expanded, bodyPhase]);
|
|
1446
|
+
(0, react.useEffect)(() => {
|
|
1447
|
+
if (bodyPhase !== "entering" && bodyPhase !== "closing") return;
|
|
1448
|
+
const timer = setTimeout(() => {
|
|
1449
|
+
setBodyPhase(bodyPhase === "entering" ? "shown" : "hidden");
|
|
1450
|
+
}, BODY_MOTION_MS);
|
|
1451
|
+
return () => {
|
|
1452
|
+
clearTimeout(timer);
|
|
1453
|
+
};
|
|
1454
|
+
}, [bodyPhase]);
|
|
1455
|
+
if (!state.available) return null;
|
|
1456
|
+
const title = props.t(props.titleKey);
|
|
1457
|
+
const description = props.t(props.descriptionKey);
|
|
1458
|
+
const descriptionTitle = props.descriptionTitleKey === void 0 ? description : props.t(props.descriptionTitleKey);
|
|
1459
|
+
const baseClass = expanded ? `${settings_card_module_css_default.cardOpen} ${settings_card_module_css_default.card}` : settings_card_module_css_default.card;
|
|
1460
|
+
const cardClass = props.density === "nested" ? `${baseClass} ${settings_card_module_css_default.cardNested}` : baseClass;
|
|
1461
|
+
/** The body region both legs share; a hidden phase renders nothing at all. */
|
|
1462
|
+
const bodyRegion = (content) => bodyPhase === "hidden" ? null : /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
1463
|
+
className: settings_card_module_css_default.disclosure,
|
|
1464
|
+
"data-state": bodyPhase,
|
|
1465
|
+
ref: bodyRef,
|
|
1466
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
1467
|
+
className: settings_card_module_css_default.body,
|
|
1468
|
+
children: content
|
|
1469
|
+
})
|
|
1470
|
+
});
|
|
1471
|
+
const header = alwaysOpen === true ? /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
1472
|
+
className: settings_card_module_css_default.headerStatic,
|
|
1473
|
+
children: [
|
|
1474
|
+
props.icon !== void 0 ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
1475
|
+
className: settings_card_module_css_default.mark,
|
|
1476
|
+
"aria-hidden": "true",
|
|
1477
|
+
children: props.icon
|
|
1478
|
+
}) : null,
|
|
1479
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("span", {
|
|
1480
|
+
className: settings_card_module_css_default.headText,
|
|
1481
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
1482
|
+
className: settings_card_module_css_default.name,
|
|
1483
|
+
id: props.titleId,
|
|
1484
|
+
title,
|
|
1485
|
+
children: title
|
|
1486
|
+
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
1487
|
+
className: settings_card_module_css_default.description,
|
|
1488
|
+
title: descriptionTitle,
|
|
1489
|
+
children: props.descriptionNode ?? description
|
|
1490
|
+
})]
|
|
1491
|
+
}),
|
|
1492
|
+
props.headerAction !== void 0 ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
1493
|
+
className: settings_card_module_css_default.headerAction,
|
|
1494
|
+
children: props.headerAction
|
|
1495
|
+
}) : null
|
|
1496
|
+
]
|
|
1497
|
+
}) : /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("button", {
|
|
1498
|
+
type: "button",
|
|
1499
|
+
className: settings_card_module_css_default.header,
|
|
1500
|
+
"aria-expanded": open,
|
|
1501
|
+
"aria-label": `${props.t(open ? "settings.collapse" : "settings.expand")}: ${title}`,
|
|
1502
|
+
onClick: () => {
|
|
1503
|
+
setOpen(!open);
|
|
1504
|
+
},
|
|
1505
|
+
children: [
|
|
1506
|
+
props.icon !== void 0 ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
1507
|
+
className: settings_card_module_css_default.mark,
|
|
1508
|
+
"aria-hidden": "true",
|
|
1509
|
+
children: props.icon
|
|
1510
|
+
}) : null,
|
|
1511
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("span", {
|
|
1512
|
+
className: settings_card_module_css_default.headText,
|
|
1513
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
1514
|
+
className: settings_card_module_css_default.name,
|
|
1515
|
+
id: props.titleId,
|
|
1516
|
+
title,
|
|
1517
|
+
children: title
|
|
1518
|
+
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
1519
|
+
className: settings_card_module_css_default.description,
|
|
1520
|
+
title: descriptionTitle,
|
|
1521
|
+
children: props.descriptionNode ?? description
|
|
1522
|
+
})]
|
|
1523
|
+
}),
|
|
1524
|
+
props.headerAction !== void 0 ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
1525
|
+
className: settings_card_module_css_default.headerAction,
|
|
1526
|
+
children: props.headerAction
|
|
1527
|
+
}) : null,
|
|
1528
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("svg", {
|
|
1529
|
+
width: "14",
|
|
1530
|
+
height: "14",
|
|
1531
|
+
viewBox: "0 0 14 14",
|
|
1532
|
+
fill: "none",
|
|
1533
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
1534
|
+
className: open ? `${settings_card_module_css_default.chevron} ${settings_card_module_css_default.chevronOpen}` : settings_card_module_css_default.chevron,
|
|
1535
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("path", {
|
|
1536
|
+
d: "M11.8486 5.5L11.4238 5.92383L8.69727 8.65137C8.44157 8.90706 8.21562 9.13382 8.01172 9.29785C7.79912 9.46883 7.55595 9.61756 7.25 9.66602C7.08435 9.69222 6.91565 9.69222 6.75 9.66602C6.44405 9.61756 6.20088 9.46883 5.98828 9.29785C5.78438 9.13382 5.55843 8.90706 5.30273 8.65137L2.57617 5.92383L2.15137 5.5L3 4.65137L3.42383 5.07617L6.15137 7.80273C6.42595 8.07732 6.59876 8.24849 6.74023 8.3623C6.87291 8.46904 6.92272 8.47813 6.9375 8.48047C6.97895 8.48703 7.02105 8.48703 7.0625 8.48047C7.07728 8.47813 7.12709 8.46904 7.25977 8.3623C7.40124 8.24849 7.57405 8.07732 7.84863 7.80273L10.5762 5.07617L11 4.65137L11.8486 5.5Z",
|
|
1537
|
+
fill: "currentColor"
|
|
1538
|
+
})
|
|
1539
|
+
})
|
|
1540
|
+
]
|
|
1541
|
+
});
|
|
1542
|
+
const notExposedNotice = state.exposed || props.hideNotExposedNotice === true ? null : /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
|
|
1543
|
+
className: settings_card_module_css_default.notExposed,
|
|
1544
|
+
role: "status",
|
|
1545
|
+
children: props.t("settings.notExposed")
|
|
1546
|
+
});
|
|
1547
|
+
if (!state.exposed && props.renderChildrenWhenNotExposed !== true) return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("li", {
|
|
1548
|
+
className: cardClass,
|
|
1549
|
+
children: [header, bodyRegion(notExposedNotice)]
|
|
1550
|
+
});
|
|
1551
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("li", {
|
|
1552
|
+
className: cardClass,
|
|
1553
|
+
children: [header, props.headerOnly !== true ? bodyRegion(/* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_jsx_runtime.Fragment, { children: [
|
|
1554
|
+
notExposedNotice,
|
|
1555
|
+
!state.writable ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
|
|
1556
|
+
className: settings_card_module_css_default.readOnly,
|
|
1557
|
+
role: "status",
|
|
1558
|
+
children: props.t("settings.readOnly")
|
|
1559
|
+
}) : null,
|
|
1560
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)(CardApply.Provider, {
|
|
1561
|
+
value: {
|
|
1562
|
+
commit: props.onSave,
|
|
1563
|
+
revert: props.onDiscard
|
|
1564
|
+
},
|
|
1565
|
+
children: props.children
|
|
1566
|
+
}),
|
|
1567
|
+
props.hideFooter !== true && state.failed ? /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("p", {
|
|
1568
|
+
className: settings_card_module_css_default.failed,
|
|
1569
|
+
role: "status",
|
|
1570
|
+
children: [props.t("settings.saveFailed"), state.failedReason ? " - " + state.failedReason : ""]
|
|
1571
|
+
}) : null
|
|
1572
|
+
] })) : null]
|
|
1573
|
+
});
|
|
1574
|
+
}
|
|
1575
|
+
/**
|
|
1576
|
+
* A typed value field. Its draft is written after a pause in typing, at once on
|
|
1577
|
+
* Enter or when focus leaves, and Escape puts the stored value back. `numeric`
|
|
1578
|
+
* only hints the keypad: which drafts a field accepts is decided by its spec.
|
|
1579
|
+
* A field given a `range` also offers the coarse slider bubble: dragging fills
|
|
1580
|
+
* the draft live and releasing writes it.
|
|
1581
|
+
*/
|
|
1582
|
+
function ValueField(props) {
|
|
1583
|
+
const apply = (0, react.useContext)(CardApply);
|
|
1584
|
+
const settledByKey = (0, react.useRef)(false);
|
|
1585
|
+
const onKeyDown = (event) => {
|
|
1586
|
+
if (apply === null || event.key !== "Enter" && event.key !== "Escape") return;
|
|
1587
|
+
event.preventDefault();
|
|
1588
|
+
settledByKey.current = true;
|
|
1589
|
+
if (event.key === "Enter") apply.commit();
|
|
1590
|
+
else apply.revert();
|
|
1591
|
+
event.currentTarget.blur();
|
|
1592
|
+
};
|
|
1593
|
+
const input = /* @__PURE__ */ (0, react_jsx_runtime.jsx)("input", {
|
|
1594
|
+
id: props.id,
|
|
1595
|
+
className: props.invalid ? settings_card_module_css_default.inputInvalid : settings_card_module_css_default.input,
|
|
1596
|
+
type: "text",
|
|
1597
|
+
...props.numeric === true ? { inputMode: "numeric" } : {},
|
|
1598
|
+
...props.invalid ? { "aria-invalid": true } : {},
|
|
1599
|
+
value: props.text,
|
|
1600
|
+
placeholder: props.placeholder ?? "",
|
|
1601
|
+
disabled: props.disabled,
|
|
1602
|
+
onChange: (event) => {
|
|
1603
|
+
props.onEdit(event.target.value);
|
|
1604
|
+
},
|
|
1605
|
+
onKeyDown,
|
|
1606
|
+
onFocus: () => {
|
|
1607
|
+
settledByKey.current = false;
|
|
1608
|
+
},
|
|
1609
|
+
onBlur: () => {
|
|
1610
|
+
if (settledByKey.current) {
|
|
1611
|
+
settledByKey.current = false;
|
|
1612
|
+
return;
|
|
1613
|
+
}
|
|
1614
|
+
apply?.commit();
|
|
1615
|
+
}
|
|
1616
|
+
});
|
|
1617
|
+
const { range } = props;
|
|
1618
|
+
const typed = Number(props.text);
|
|
1619
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
1620
|
+
className: settings_card_module_css_default.field,
|
|
1621
|
+
children: [
|
|
1622
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
1623
|
+
className: settings_card_module_css_default.head,
|
|
1624
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("label", {
|
|
1625
|
+
className: settings_card_module_css_default.label,
|
|
1626
|
+
htmlFor: props.id,
|
|
1627
|
+
children: props.label
|
|
1628
|
+
}), props.overridden ? /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("span", {
|
|
1629
|
+
className: settings_card_module_css_default.badges,
|
|
1630
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
1631
|
+
className: settings_card_module_css_default.badge,
|
|
1632
|
+
children: props.overriddenLabel
|
|
1633
|
+
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
|
|
1634
|
+
type: "button",
|
|
1635
|
+
className: settings_card_module_css_default.reset,
|
|
1636
|
+
disabled: props.disabled,
|
|
1637
|
+
onClick: props.onReset,
|
|
1638
|
+
children: props.resetLabel
|
|
1639
|
+
})]
|
|
1640
|
+
}) : null]
|
|
1641
|
+
}),
|
|
1642
|
+
range === void 0 ? input : /* @__PURE__ */ (0, react_jsx_runtime.jsx)(RangeBubble, {
|
|
1643
|
+
min: range.min,
|
|
1644
|
+
max: range.max,
|
|
1645
|
+
step: range.step,
|
|
1646
|
+
value: props.text.trim() === "" || Number.isNaN(typed) ? range.min : typed,
|
|
1647
|
+
label: `${props.label} ${range.min}–${range.max}`,
|
|
1648
|
+
disabled: props.disabled,
|
|
1649
|
+
onInput: (value) => {
|
|
1650
|
+
props.onEdit(String(value));
|
|
1651
|
+
},
|
|
1652
|
+
onCommit: (value) => {
|
|
1653
|
+
props.onEdit(String(value));
|
|
1654
|
+
apply?.commit();
|
|
1655
|
+
},
|
|
1656
|
+
children: input
|
|
1657
|
+
}),
|
|
1658
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
|
|
1659
|
+
className: props.invalid ? settings_card_module_css_default.invalid : settings_card_module_css_default.hint,
|
|
1660
|
+
title: props.hintTitle,
|
|
1661
|
+
children: props.invalid ? props.invalidLabel : props.hint
|
|
1662
|
+
})
|
|
1663
|
+
]
|
|
1664
|
+
});
|
|
1665
|
+
}
|
|
1666
|
+
const NON_SKIN_BODY_MARKERS = /* @__PURE__ */ new Set(["dshSkinCenter", "dshSidebarCollapsed"]);
|
|
1667
|
+
function isSkinActive() {
|
|
1668
|
+
return Object.keys(document.body.dataset).some((key) => key.startsWith("dsh") && !NON_SKIN_BODY_MARKERS.has(key));
|
|
1669
|
+
}
|
|
1670
|
+
const SELECT_CLOSE_MS = 100;
|
|
1671
|
+
/**
|
|
1672
|
+
* The shared dual-mode select control. While an appearance skin is active it
|
|
1673
|
+
* renders the legacy native `<select>` untouched, so element-level skin
|
|
1674
|
+
* selectors keep working; under the default appearance it renders a
|
|
1675
|
+
* self-drawn `role="listbox"` popup whose open/close is transition-animated.
|
|
1676
|
+
* Cards reach it through BooleanField/ChoiceField; editors outside a card
|
|
1677
|
+
* (the side-card prefs) bind it directly through onEdit.
|
|
1678
|
+
* 双模式下拉框:皮肤激活时用原生 select,默认外观用自绘动画弹层。
|
|
1679
|
+
*/
|
|
1680
|
+
function SelectField(props) {
|
|
1681
|
+
const { id, options, value } = props;
|
|
1682
|
+
const [open, setOpen] = (0, react.useState)(false);
|
|
1683
|
+
const [closing, setClosing] = (0, react.useState)(false);
|
|
1684
|
+
const [phase, setPhase] = (0, react.useState)("initial");
|
|
1685
|
+
const [activeIndex, setActiveIndex] = (0, react.useState)(0);
|
|
1686
|
+
const closeTimer = (0, react.useRef)(void 0);
|
|
1687
|
+
const wrapRef = (0, react.useRef)(null);
|
|
1688
|
+
const popupRef = (0, react.useRef)(null);
|
|
1689
|
+
const currentIndex = () => {
|
|
1690
|
+
const index = options.findIndex((option) => option.value === value);
|
|
1691
|
+
return index >= 0 ? index : 0;
|
|
1692
|
+
};
|
|
1693
|
+
const close = (0, react.useCallback)(() => {
|
|
1694
|
+
if (closeTimer.current !== void 0) clearTimeout(closeTimer.current);
|
|
1695
|
+
setClosing(true);
|
|
1696
|
+
closeTimer.current = setTimeout(() => {
|
|
1697
|
+
setClosing(false);
|
|
1698
|
+
setOpen(false);
|
|
1699
|
+
}, SELECT_CLOSE_MS);
|
|
1700
|
+
}, []);
|
|
1701
|
+
const openPopup = () => {
|
|
1702
|
+
if (closeTimer.current !== void 0) clearTimeout(closeTimer.current);
|
|
1703
|
+
setActiveIndex(currentIndex());
|
|
1704
|
+
setPhase("initial");
|
|
1705
|
+
setClosing(false);
|
|
1706
|
+
setOpen(true);
|
|
1707
|
+
};
|
|
1708
|
+
const commit = (index) => {
|
|
1709
|
+
const option = options[index];
|
|
1710
|
+
if (option) props.onEdit(option.value);
|
|
1711
|
+
close();
|
|
1712
|
+
};
|
|
1713
|
+
const onTriggerClick = () => {
|
|
1714
|
+
if (props.disabled) return;
|
|
1715
|
+
if (open && !closing) close();
|
|
1716
|
+
else openPopup();
|
|
1717
|
+
};
|
|
1718
|
+
const onKeyDown = (event) => {
|
|
1719
|
+
if (props.disabled) return;
|
|
1720
|
+
const count = options.length;
|
|
1721
|
+
switch (event.key) {
|
|
1722
|
+
case "ArrowDown":
|
|
1723
|
+
case "ArrowUp":
|
|
1724
|
+
case "Enter":
|
|
1725
|
+
case " ":
|
|
1726
|
+
event.preventDefault();
|
|
1727
|
+
if (!open) openPopup();
|
|
1728
|
+
else if (!closing) if (event.key === "ArrowDown") setActiveIndex((index) => (index + 1) % count);
|
|
1729
|
+
else if (event.key === "ArrowUp") setActiveIndex((index) => (index - 1 + count) % count);
|
|
1730
|
+
else commit(activeIndex);
|
|
1731
|
+
break;
|
|
1732
|
+
case "Escape":
|
|
1733
|
+
if (open) {
|
|
1734
|
+
event.preventDefault();
|
|
1735
|
+
event.stopPropagation();
|
|
1736
|
+
close();
|
|
1737
|
+
}
|
|
1738
|
+
break;
|
|
1739
|
+
case "Tab":
|
|
1740
|
+
if (open) close();
|
|
1741
|
+
break;
|
|
1742
|
+
}
|
|
1743
|
+
};
|
|
1744
|
+
(0, react.useEffect)(() => () => {
|
|
1745
|
+
if (closeTimer.current !== void 0) clearTimeout(closeTimer.current);
|
|
1746
|
+
}, []);
|
|
1747
|
+
(0, react.useLayoutEffect)(() => {
|
|
1748
|
+
if (open && !closing && phase === "initial") {
|
|
1749
|
+
popupRef.current?.offsetHeight;
|
|
1750
|
+
setPhase("open");
|
|
1751
|
+
}
|
|
1752
|
+
}, [
|
|
1753
|
+
open,
|
|
1754
|
+
closing,
|
|
1755
|
+
phase
|
|
1756
|
+
]);
|
|
1757
|
+
(0, react.useEffect)(() => {
|
|
1758
|
+
if (!open) return;
|
|
1759
|
+
const onPointerDown = (event) => {
|
|
1760
|
+
const target = event.target;
|
|
1761
|
+
if (target instanceof Node && !wrapRef.current?.contains(target)) close();
|
|
1762
|
+
};
|
|
1763
|
+
document.addEventListener("pointerdown", onPointerDown);
|
|
1764
|
+
return () => document.removeEventListener("pointerdown", onPointerDown);
|
|
1765
|
+
}, [open, close]);
|
|
1766
|
+
(0, react.useEffect)(() => {
|
|
1767
|
+
if (props.disabled && open) close();
|
|
1768
|
+
}, [
|
|
1769
|
+
props.disabled,
|
|
1770
|
+
open,
|
|
1771
|
+
close
|
|
1772
|
+
]);
|
|
1773
|
+
if (isSkinActive()) return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("select", {
|
|
1774
|
+
id,
|
|
1775
|
+
className: settings_card_module_css_default.select,
|
|
1776
|
+
value,
|
|
1777
|
+
disabled: props.disabled,
|
|
1778
|
+
onChange: (event) => {
|
|
1779
|
+
props.onEdit(event.target.value);
|
|
1780
|
+
},
|
|
1781
|
+
children: options.map((option) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)("option", {
|
|
1782
|
+
value: option.value,
|
|
1783
|
+
children: option.label
|
|
1784
|
+
}, option.value))
|
|
1785
|
+
});
|
|
1786
|
+
const label = options.find((option) => option.value === value)?.label ?? "";
|
|
1787
|
+
const popupClass = closing ? `${settings_card_module_css_default.selectPopup} ${settings_card_module_css_default.selectPopupClose}` : phase === "open" ? `${settings_card_module_css_default.selectPopup} ${settings_card_module_css_default.selectPopupOpen}` : settings_card_module_css_default.selectPopup;
|
|
1788
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
1789
|
+
className: settings_card_module_css_default.selectWrap,
|
|
1790
|
+
ref: wrapRef,
|
|
1791
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("button", {
|
|
1792
|
+
type: "button",
|
|
1793
|
+
id,
|
|
1794
|
+
className: `${settings_card_module_css_default.select} ${settings_card_module_css_default.selectButton}`,
|
|
1795
|
+
disabled: props.disabled,
|
|
1796
|
+
"aria-haspopup": "listbox",
|
|
1797
|
+
"aria-expanded": open,
|
|
1798
|
+
"aria-activedescendant": open ? `${id}-o${activeIndex}` : void 0,
|
|
1799
|
+
"aria-invalid": props.invalid || void 0,
|
|
1800
|
+
onClick: onTriggerClick,
|
|
1801
|
+
onKeyDown,
|
|
1802
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
1803
|
+
className: settings_card_module_css_default.selectLabel,
|
|
1804
|
+
children: label
|
|
1805
|
+
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("svg", {
|
|
1806
|
+
width: "14",
|
|
1807
|
+
height: "14",
|
|
1808
|
+
viewBox: "0 0 14 14",
|
|
1809
|
+
fill: "none",
|
|
1810
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
1811
|
+
className: open ? `${settings_card_module_css_default.selectChevron} ${settings_card_module_css_default.selectChevronOpen}` : settings_card_module_css_default.selectChevron,
|
|
1812
|
+
"aria-hidden": "true",
|
|
1813
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("path", {
|
|
1814
|
+
d: "M11.8486 5.5L11.4238 5.92383L8.69727 8.65137C8.44157 8.90706 8.21562 9.13382 8.01172 9.29785C7.79912 9.46883 7.55595 9.61756 7.25 9.66602C7.08435 9.69222 6.91565 9.69222 6.75 9.66602C6.44405 9.61756 6.20088 9.46883 5.98828 9.29785C5.78438 9.13382 5.55843 8.90706 5.30273 8.65137L2.57617 5.92383L2.15137 5.5L3 4.65137L3.42383 5.07617L6.15137 7.80273C6.42595 8.07732 6.59876 8.24849 6.74023 8.3623C6.87291 8.46904 6.92272 8.47813 6.9375 8.48047C6.97895 8.48703 7.02105 8.48703 7.0625 8.48047C7.07728 8.47813 7.12709 8.46904 7.25977 8.3623C7.40124 8.24849 7.57405 8.07732 7.84863 7.80273L10.5762 5.07617L11 4.65137L11.8486 5.5Z",
|
|
1815
|
+
fill: "currentColor"
|
|
1816
|
+
})
|
|
1817
|
+
})]
|
|
1818
|
+
}), open ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
1819
|
+
className: popupClass,
|
|
1820
|
+
role: "listbox",
|
|
1821
|
+
ref: popupRef,
|
|
1822
|
+
children: options.map((option, index) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
1823
|
+
id: `${id}-o${index}`,
|
|
1824
|
+
role: "option",
|
|
1825
|
+
"aria-selected": option.value === value,
|
|
1826
|
+
className: `${settings_card_module_css_default.selectOption}${option.value === value ? ` ${settings_card_module_css_default.selectOptionSelected}` : ""}${index === activeIndex && !closing ? ` ${settings_card_module_css_default.selectOptionActive}` : ""}`,
|
|
1827
|
+
onClick: () => {
|
|
1828
|
+
commit(index);
|
|
1829
|
+
},
|
|
1830
|
+
children: option.label
|
|
1831
|
+
}, option.value))
|
|
1832
|
+
}) : null]
|
|
1833
|
+
});
|
|
1834
|
+
}
|
|
1835
|
+
/**
|
|
1836
|
+
* A visible segmented group for a small set of mutually exclusive values.
|
|
1837
|
+
* Every option stays on screen, so inherit/on/off and short enum fields take
|
|
1838
|
+
* one click without opening a popup. The pressed option carries the group's
|
|
1839
|
+
* sliding highlight and `aria-pressed`; the group takes the field label as its
|
|
1840
|
+
* accessible name.
|
|
1841
|
+
*/
|
|
1842
|
+
function SegmentField(props) {
|
|
1843
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(SegmentGroup, {
|
|
1844
|
+
id: props.id,
|
|
1845
|
+
role: "group",
|
|
1846
|
+
"aria-label": props.label,
|
|
1847
|
+
"aria-invalid": props.invalid || void 0,
|
|
1848
|
+
children: props.options.map((option, index) => {
|
|
1849
|
+
const active = option.value === props.value;
|
|
1850
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
|
|
1851
|
+
type: "button",
|
|
1852
|
+
className: settings_card_module_css_default.segment,
|
|
1853
|
+
"aria-pressed": active,
|
|
1854
|
+
disabled: props.disabled,
|
|
1855
|
+
"data-active": active ? "" : void 0,
|
|
1856
|
+
"data-segment-index": index,
|
|
1857
|
+
onClick: () => {
|
|
1858
|
+
if (!active) props.onEdit(option.value);
|
|
1859
|
+
},
|
|
1860
|
+
children: option.label
|
|
1861
|
+
}, option.value);
|
|
1862
|
+
})
|
|
1863
|
+
});
|
|
1864
|
+
}
|
|
1865
|
+
/** A boolean field: 继承 / 开 / 关. */
|
|
1866
|
+
function BooleanField(props) {
|
|
1867
|
+
const segmented = props.presentation !== "select";
|
|
1868
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
1869
|
+
className: settings_card_module_css_default.field,
|
|
1870
|
+
children: [
|
|
1871
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
1872
|
+
className: settings_card_module_css_default.head,
|
|
1873
|
+
children: [segmented ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
1874
|
+
className: settings_card_module_css_default.label,
|
|
1875
|
+
children: props.label
|
|
1876
|
+
}) : /* @__PURE__ */ (0, react_jsx_runtime.jsx)("label", {
|
|
1877
|
+
className: settings_card_module_css_default.label,
|
|
1878
|
+
htmlFor: props.id,
|
|
1879
|
+
children: props.label
|
|
1880
|
+
}), props.overridden ? /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("span", {
|
|
1881
|
+
className: settings_card_module_css_default.badges,
|
|
1882
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
1883
|
+
className: settings_card_module_css_default.badge,
|
|
1884
|
+
children: props.overriddenLabel
|
|
1885
|
+
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
|
|
1886
|
+
type: "button",
|
|
1887
|
+
className: settings_card_module_css_default.reset,
|
|
1888
|
+
disabled: props.disabled,
|
|
1889
|
+
onClick: props.onReset,
|
|
1890
|
+
children: props.resetLabel
|
|
1891
|
+
})]
|
|
1892
|
+
}) : null]
|
|
1893
|
+
}),
|
|
1894
|
+
segmented ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(SegmentField, {
|
|
1895
|
+
id: props.id,
|
|
1896
|
+
label: props.label,
|
|
1897
|
+
options: [
|
|
1898
|
+
{
|
|
1899
|
+
value: "",
|
|
1900
|
+
label: props.inheritLabel
|
|
1901
|
+
},
|
|
1902
|
+
{
|
|
1903
|
+
value: "true",
|
|
1904
|
+
label: props.onLabel
|
|
1905
|
+
},
|
|
1906
|
+
{
|
|
1907
|
+
value: "false",
|
|
1908
|
+
label: props.offLabel
|
|
1909
|
+
}
|
|
1910
|
+
],
|
|
1911
|
+
value: props.text,
|
|
1912
|
+
disabled: props.disabled,
|
|
1913
|
+
invalid: props.invalid,
|
|
1914
|
+
onEdit: props.onEdit
|
|
1915
|
+
}) : /* @__PURE__ */ (0, react_jsx_runtime.jsx)(SelectField, {
|
|
1916
|
+
id: props.id,
|
|
1917
|
+
options: [
|
|
1918
|
+
{
|
|
1919
|
+
value: "",
|
|
1920
|
+
label: props.inheritLabel
|
|
1921
|
+
},
|
|
1922
|
+
{
|
|
1923
|
+
value: "true",
|
|
1924
|
+
label: props.onLabel
|
|
1925
|
+
},
|
|
1926
|
+
{
|
|
1927
|
+
value: "false",
|
|
1928
|
+
label: props.offLabel
|
|
1929
|
+
}
|
|
1930
|
+
],
|
|
1931
|
+
value: props.text,
|
|
1932
|
+
disabled: props.disabled,
|
|
1933
|
+
invalid: props.invalid,
|
|
1934
|
+
onEdit: props.onEdit
|
|
1935
|
+
}),
|
|
1936
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
|
|
1937
|
+
className: settings_card_module_css_default.hint,
|
|
1938
|
+
title: props.hintTitle,
|
|
1939
|
+
children: props.hint
|
|
1940
|
+
})
|
|
1941
|
+
]
|
|
1942
|
+
});
|
|
1943
|
+
}
|
|
1944
|
+
/**
|
|
1945
|
+
* A free-text field. An empty draft clears the field. `entry` is `pick` when
|
|
1946
|
+
* the text arrives whole from a picker (a preset or a reasoning level).
|
|
1947
|
+
*/
|
|
1948
|
+
function textField(field, entry = "type") {
|
|
1949
|
+
return {
|
|
1950
|
+
field,
|
|
1951
|
+
entry,
|
|
1952
|
+
format: (value) => typeof value === "string" ? value : "",
|
|
1953
|
+
parse: (text) => {
|
|
1954
|
+
const trimmed = text.trim();
|
|
1955
|
+
return trimmed === "" ? { kind: "clear" } : {
|
|
1956
|
+
kind: "set",
|
|
1957
|
+
value: trimmed
|
|
1958
|
+
};
|
|
1959
|
+
}
|
|
1960
|
+
};
|
|
1961
|
+
}
|
|
1962
|
+
/** A boolean field, edited through true/false draft text. */
|
|
1963
|
+
function booleanField(field) {
|
|
1964
|
+
return {
|
|
1965
|
+
field,
|
|
1966
|
+
entry: "pick",
|
|
1967
|
+
format: (value) => typeof value === "boolean" ? String(value) : "",
|
|
1968
|
+
parse: (text) => {
|
|
1969
|
+
const trimmed = text.trim();
|
|
1970
|
+
if (trimmed === "") return { kind: "clear" };
|
|
1971
|
+
if (trimmed === "true") return {
|
|
1972
|
+
kind: "set",
|
|
1973
|
+
value: true
|
|
1974
|
+
};
|
|
1975
|
+
if (trimmed === "false") return {
|
|
1976
|
+
kind: "set",
|
|
1977
|
+
value: false
|
|
1978
|
+
};
|
|
1979
|
+
}
|
|
1980
|
+
};
|
|
1981
|
+
}
|
|
1982
|
+
/**
|
|
1983
|
+
* Applies one card's edits to one settings namespace as the reader makes them.
|
|
1984
|
+
*
|
|
1985
|
+
* The Host is the only authority on whether a value was accepted — its
|
|
1986
|
+
* validators own the constraints no schema can express — so the outcome is
|
|
1987
|
+
* read back from the section rather than predicted here. A write that did not
|
|
1988
|
+
* land puts each pick back to the stored value, the way a switch that could not
|
|
1989
|
+
* flip springs back, and keeps typed text so the reader can correct it instead
|
|
1990
|
+
* of retyping.
|
|
1991
|
+
*/
|
|
1992
|
+
var CardForm = class {
|
|
1993
|
+
scope;
|
|
1994
|
+
specs;
|
|
1995
|
+
staged = /* @__PURE__ */ new Map();
|
|
1996
|
+
listeners = /* @__PURE__ */ new Set();
|
|
1997
|
+
/** The form subscription installed in the constructor; released by dispose(). */
|
|
1998
|
+
disposeForm;
|
|
1999
|
+
disposed = false;
|
|
2000
|
+
/** The pending write of typed text, waiting for typing to pause. */
|
|
2001
|
+
typePause;
|
|
2002
|
+
saving = false;
|
|
2003
|
+
/** A save asked for while one was in flight; it runs once the first settles (#1754). */
|
|
2004
|
+
saveQueued = false;
|
|
2005
|
+
failed = false;
|
|
2006
|
+
failedReason;
|
|
2007
|
+
/** @param scope - the bound configuration form for this card's namespace. */
|
|
2008
|
+
constructor(scope, specs) {
|
|
2009
|
+
this.scope = scope;
|
|
2010
|
+
this.specs = new Map(specs.map((spec) => [spec.field, spec]));
|
|
2011
|
+
this.disposeForm = scope.subscribe(() => {
|
|
2012
|
+
this.publish();
|
|
2013
|
+
});
|
|
2014
|
+
}
|
|
2015
|
+
/**
|
|
2016
|
+
* Release the form subscription and every bound store listener. The card
|
|
2017
|
+
* must call this on teardown; later calls are no-ops.
|
|
2018
|
+
*/
|
|
2019
|
+
dispose() {
|
|
2020
|
+
if (this.disposed) return;
|
|
2021
|
+
this.disposed = true;
|
|
2022
|
+
clearTimeout(this.typePause);
|
|
2023
|
+
this.disposeForm();
|
|
2024
|
+
this.listeners.clear();
|
|
2025
|
+
}
|
|
2026
|
+
/** Publish a projection of this form, rebuilt whenever the form or a draft changes. */
|
|
2027
|
+
bind(project) {
|
|
2028
|
+
const store = (0, _deepseek_ai_dsh_client_store.createSnapshotStore)(project());
|
|
2029
|
+
this.listeners.add(() => {
|
|
2030
|
+
store.set(project());
|
|
2031
|
+
});
|
|
2032
|
+
return store;
|
|
2033
|
+
}
|
|
2034
|
+
/** Read the card-level state: what the Host serves, and what is still waiting to be written. */
|
|
2035
|
+
shell() {
|
|
2036
|
+
const snapshot = this.scope.getSnapshot();
|
|
2037
|
+
const plan = this.plan();
|
|
2038
|
+
return {
|
|
2039
|
+
available: snapshot.status !== "loading",
|
|
2040
|
+
exposed: snapshot.status === "ready",
|
|
2041
|
+
writable: snapshot.writable,
|
|
2042
|
+
dirty: plan.length > 0,
|
|
2043
|
+
invalid: plan.some((item) => item.judge === void 0),
|
|
2044
|
+
saving: this.saving,
|
|
2045
|
+
failed: this.failed,
|
|
2046
|
+
...this.failedReason === void 0 ? {} : { failedReason: this.failedReason }
|
|
2047
|
+
};
|
|
2048
|
+
}
|
|
2049
|
+
/** Read one field's state from the effective section and its staged draft. */
|
|
2050
|
+
field(field) {
|
|
2051
|
+
const spec = this.specOf(field);
|
|
2052
|
+
const staged = this.staged.get(field);
|
|
2053
|
+
if (staged === void 0) return {
|
|
2054
|
+
text: spec.format(this.sectionValue(field)),
|
|
2055
|
+
overridden: this.stored(field),
|
|
2056
|
+
invalid: false
|
|
2057
|
+
};
|
|
2058
|
+
const write = staged.clear ? { kind: "clear" } : spec.parse(staged.text);
|
|
2059
|
+
return {
|
|
2060
|
+
text: staged.text,
|
|
2061
|
+
overridden: write?.kind === "set",
|
|
2062
|
+
invalid: write === void 0
|
|
2063
|
+
};
|
|
2064
|
+
}
|
|
2065
|
+
/** The actions the card's slot registration injects. */
|
|
2066
|
+
actions() {
|
|
2067
|
+
return {
|
|
2068
|
+
edit: (field, text) => {
|
|
2069
|
+
this.stage(field, {
|
|
2070
|
+
text,
|
|
2071
|
+
clear: false
|
|
2072
|
+
});
|
|
2073
|
+
},
|
|
2074
|
+
resetField: (field) => {
|
|
2075
|
+
this.stage(field, {
|
|
2076
|
+
text: this.specOf(field).format(this.baseValue(field)),
|
|
2077
|
+
clear: true
|
|
2078
|
+
});
|
|
2079
|
+
},
|
|
2080
|
+
save: () => {
|
|
2081
|
+
this.applyNow();
|
|
2082
|
+
},
|
|
2083
|
+
discard: () => {
|
|
2084
|
+
clearTimeout(this.typePause);
|
|
2085
|
+
if (this.staged.size === 0 && !this.failed) return;
|
|
2086
|
+
this.staged.clear();
|
|
2087
|
+
this.failed = false;
|
|
2088
|
+
this.failedReason = void 0;
|
|
2089
|
+
this.publish();
|
|
2090
|
+
}
|
|
2091
|
+
};
|
|
2092
|
+
}
|
|
2093
|
+
/**
|
|
2094
|
+
* Run one write, and re-run it once if another was asked for while this one
|
|
2095
|
+
* was still in flight.
|
|
2096
|
+
*
|
|
2097
|
+
* A write is a Host round trip that also drives the profile reconcile, and
|
|
2098
|
+
* the Host runs it inside one exclusive transaction. Answering an edit that
|
|
2099
|
+
* arrives mid-flight by returning immediately dropped it with no explanation
|
|
2100
|
+
* (#1754). Serializing instead means an edit made while another write is
|
|
2101
|
+
* still settling is written against the settled state.
|
|
2102
|
+
* @returns settlement after the mutation and the read-back.
|
|
2103
|
+
*/
|
|
2104
|
+
async requestSave() {
|
|
2105
|
+
if (this.saving) {
|
|
2106
|
+
this.saveQueued = true;
|
|
2107
|
+
return;
|
|
2108
|
+
}
|
|
2109
|
+
await this.save();
|
|
2110
|
+
if (!this.saveQueued) return;
|
|
2111
|
+
this.saveQueued = false;
|
|
2112
|
+
await this.requestSave();
|
|
2113
|
+
}
|
|
2114
|
+
/**
|
|
2115
|
+
* Write every valid draft in one atomic form mutation, then re-seed from
|
|
2116
|
+
* what the Host accepted. A draft the field does not accept stays on screen,
|
|
2117
|
+
* unwritten, without holding the others back.
|
|
2118
|
+
*
|
|
2119
|
+
* The batch rides one mutate, so cross-field validate hooks (baseURL+model)
|
|
2120
|
+
* judge it as a unit: the Host either applies every write or refuses the
|
|
2121
|
+
* batch. The form contract answers a refusal or a skipped write with `false`
|
|
2122
|
+
* (it recovers with a fresh Host view instead of throwing), so the outcome is
|
|
2123
|
+
* judged twice: the answer itself, and then the settled snapshot read back
|
|
2124
|
+
* one planned write at a time. One missed write fails the whole batch. A
|
|
2125
|
+
* transport that rejects instead (the dsh-web bridge controller on a dead
|
|
2126
|
+
* connection) reports through the same failure path with its rejection
|
|
2127
|
+
* message. A batch that did not land puts its picks and clears back to the
|
|
2128
|
+
* stored value and keeps its typed text, so the reader can correct it.
|
|
2129
|
+
* @returns settlement after the mutation and the read-back.
|
|
2130
|
+
*/
|
|
2131
|
+
async save() {
|
|
2132
|
+
const valid = this.plan().filter((item) => item.judge !== void 0);
|
|
2133
|
+
if (valid.length === 0 || this.saving) return;
|
|
2134
|
+
const pending = /* @__PURE__ */ new Map();
|
|
2135
|
+
for (const item of valid) pending.set(item.field, this.staged.get(item.field));
|
|
2136
|
+
this.saving = true;
|
|
2137
|
+
this.failed = false;
|
|
2138
|
+
this.failedReason = void 0;
|
|
2139
|
+
this.publish();
|
|
2140
|
+
const ops = valid.map((item) => item.op.op === "set" ? {
|
|
2141
|
+
op: "set",
|
|
2142
|
+
path: [item.field],
|
|
2143
|
+
value: item.op.value
|
|
2144
|
+
} : {
|
|
2145
|
+
op: "unset",
|
|
2146
|
+
path: [item.field]
|
|
2147
|
+
});
|
|
2148
|
+
let failedReason;
|
|
2149
|
+
let accepted = false;
|
|
2150
|
+
try {
|
|
2151
|
+
accepted = await this.scope.mutate(ops);
|
|
2152
|
+
} catch (error) {
|
|
2153
|
+
failedReason = error instanceof Error ? error.message : String(error);
|
|
2154
|
+
}
|
|
2155
|
+
const landed = accepted && failedReason === void 0 && valid.every((item) => item.judge());
|
|
2156
|
+
for (const [field, before] of pending) {
|
|
2157
|
+
if (this.staged.get(field) !== before) continue;
|
|
2158
|
+
if (landed || before === void 0 || before.clear || this.specOf(field).entry === "pick") this.staged.delete(field);
|
|
2159
|
+
}
|
|
2160
|
+
this.saving = false;
|
|
2161
|
+
this.failed = !landed;
|
|
2162
|
+
this.failedReason = failedReason;
|
|
2163
|
+
this.publish();
|
|
2164
|
+
}
|
|
2165
|
+
/**
|
|
2166
|
+
* Every staged edit a write would carry. An entry whose draft is not a value
|
|
2167
|
+
* its field accepts carries no write: the form is still dirty, and the draft
|
|
2168
|
+
* stays on screen rather than being dropped. A staged edit that matches the
|
|
2169
|
+
* effective section is not a write at all.
|
|
2170
|
+
* @returns the planned writes, in the order the fields were staged.
|
|
2171
|
+
*/
|
|
2172
|
+
plan() {
|
|
2173
|
+
const plan = [];
|
|
2174
|
+
for (const [field, staged] of this.staged) {
|
|
2175
|
+
const spec = this.specOf(field);
|
|
2176
|
+
if (staged.clear) {
|
|
2177
|
+
if (this.stored(field)) plan.push({
|
|
2178
|
+
field,
|
|
2179
|
+
op: {
|
|
2180
|
+
field,
|
|
2181
|
+
op: "unset"
|
|
2182
|
+
},
|
|
2183
|
+
judge: () => this.landedUnset(field)
|
|
2184
|
+
});
|
|
2185
|
+
continue;
|
|
2186
|
+
}
|
|
2187
|
+
if (staged.text === spec.format(this.sectionValue(field))) continue;
|
|
2188
|
+
const write = spec.parse(staged.text);
|
|
2189
|
+
if (write === void 0) plan.push({
|
|
2190
|
+
field,
|
|
2191
|
+
op: {
|
|
2192
|
+
field,
|
|
2193
|
+
op: "unset"
|
|
2194
|
+
},
|
|
2195
|
+
judge: void 0
|
|
2196
|
+
});
|
|
2197
|
+
else if (write.kind === "clear") plan.push({
|
|
2198
|
+
field,
|
|
2199
|
+
op: {
|
|
2200
|
+
field,
|
|
2201
|
+
op: "unset"
|
|
2202
|
+
},
|
|
2203
|
+
judge: () => this.landedUnset(field)
|
|
2204
|
+
});
|
|
2205
|
+
else plan.push({
|
|
2206
|
+
field,
|
|
2207
|
+
op: {
|
|
2208
|
+
field,
|
|
2209
|
+
op: "set",
|
|
2210
|
+
value: write.value
|
|
2211
|
+
},
|
|
2212
|
+
judge: () => this.landedSet(field, write.value)
|
|
2213
|
+
});
|
|
2214
|
+
}
|
|
2215
|
+
return plan;
|
|
2216
|
+
}
|
|
2217
|
+
/**
|
|
2218
|
+
* Read-back judgment for a planned set: the user layer must hold the
|
|
2219
|
+
* intended value once the mutation has settled.
|
|
2220
|
+
*/
|
|
2221
|
+
landedSet(field, value) {
|
|
2222
|
+
if (this.specOf(field).secret) return true;
|
|
2223
|
+
return this.userLayer()?.[field] === value;
|
|
2224
|
+
}
|
|
2225
|
+
/**
|
|
2226
|
+
* Read-back judgment for a planned unset: the field must be gone from the
|
|
2227
|
+
* user layer once the mutation has settled.
|
|
2228
|
+
*/
|
|
2229
|
+
landedUnset(field) {
|
|
2230
|
+
return !this.stored(field);
|
|
2231
|
+
}
|
|
2232
|
+
/**
|
|
2233
|
+
* Take one edit and schedule its write: a pick or a clear is written now,
|
|
2234
|
+
* typed text once typing has rested for TYPE_PAUSE_MS.
|
|
2235
|
+
*/
|
|
2236
|
+
stage(field, edit) {
|
|
2237
|
+
this.staged.set(field, edit);
|
|
2238
|
+
this.failed = false;
|
|
2239
|
+
this.failedReason = void 0;
|
|
2240
|
+
this.publish();
|
|
2241
|
+
if (edit.clear || this.specOf(field).entry === "pick") {
|
|
2242
|
+
this.applyNow();
|
|
2243
|
+
return;
|
|
2244
|
+
}
|
|
2245
|
+
clearTimeout(this.typePause);
|
|
2246
|
+
this.typePause = setTimeout(() => {
|
|
2247
|
+
this.applyNow();
|
|
2248
|
+
}, 600);
|
|
2249
|
+
}
|
|
2250
|
+
/** Write every pending draft now, taking the place of a waiting pause. */
|
|
2251
|
+
applyNow() {
|
|
2252
|
+
clearTimeout(this.typePause);
|
|
2253
|
+
this.typePause = void 0;
|
|
2254
|
+
if (this.disposed) return;
|
|
2255
|
+
this.requestSave();
|
|
2256
|
+
}
|
|
2257
|
+
specOf(field) {
|
|
2258
|
+
const spec = this.specs.get(field);
|
|
2259
|
+
if (spec === void 0) throw new Error(`settings card has no field ${field}`);
|
|
2260
|
+
return spec;
|
|
2261
|
+
}
|
|
2262
|
+
snapshotOf() {
|
|
2263
|
+
return this.scope.getSnapshot();
|
|
2264
|
+
}
|
|
2265
|
+
sectionValue(field) {
|
|
2266
|
+
return this.snapshotOf().value?.[field];
|
|
2267
|
+
}
|
|
2268
|
+
baseValue(field) {
|
|
2269
|
+
return this.snapshotOf().base?.[field];
|
|
2270
|
+
}
|
|
2271
|
+
userLayer() {
|
|
2272
|
+
return this.snapshotOf().user;
|
|
2273
|
+
}
|
|
2274
|
+
stored(field) {
|
|
2275
|
+
const user = this.userLayer();
|
|
2276
|
+
return user !== void 0 && Object.hasOwn(user, field);
|
|
2277
|
+
}
|
|
2278
|
+
publish() {
|
|
2279
|
+
for (const listener of this.listeners) listener();
|
|
2280
|
+
}
|
|
2281
|
+
};
|
|
2282
|
+
//#endregion
|
|
2283
|
+
//#region src/client/settings-entry-form.ts
|
|
2284
|
+
/** The snapshot a form reports before the Host has answered with this entry. */
|
|
2285
|
+
function pendingSnapshot() {
|
|
2286
|
+
return {
|
|
2287
|
+
status: "loading",
|
|
2288
|
+
value: void 0,
|
|
2289
|
+
base: void 0,
|
|
2290
|
+
user: void 0,
|
|
2291
|
+
revision: void 0,
|
|
2292
|
+
writable: false
|
|
2293
|
+
};
|
|
2294
|
+
}
|
|
2295
|
+
/**
|
|
2296
|
+
* Create a settings form bound to the profile entry id this Host serves, and
|
|
2297
|
+
* rebound whenever the shared describe mirror names a different one of this
|
|
2298
|
+
* package's rows.
|
|
2299
|
+
* @param options - the shared forms service and this package's candidate row ids.
|
|
2300
|
+
* @returns a form delegating to the currently resolved entry's own form.
|
|
2301
|
+
*/
|
|
2302
|
+
function createServedEntryForm(options) {
|
|
2303
|
+
const { forms, entryIds } = options;
|
|
2304
|
+
const fallbackId = entryIds[0];
|
|
2305
|
+
const namespaceId = entryIds[entryIds.length - 1];
|
|
2306
|
+
const listeners = /* @__PURE__ */ new Set();
|
|
2307
|
+
let boundId;
|
|
2308
|
+
let bound;
|
|
2309
|
+
let offBound;
|
|
2310
|
+
let snapshot = pendingSnapshot();
|
|
2311
|
+
/** Republish: the delegated snapshot when one is bound, the pending one otherwise. */
|
|
2312
|
+
const publish = () => {
|
|
2313
|
+
if (bound !== void 0) snapshot = bound.getSnapshot();
|
|
2314
|
+
for (const listener of [...listeners]) listener();
|
|
2315
|
+
};
|
|
2316
|
+
/**
|
|
2317
|
+
* The entry id the mirror currently justifies. An unanswered or empty mirror
|
|
2318
|
+
* is not evidence of absence, so it keeps the first candidate; a mirror that
|
|
2319
|
+
* answers without any of this package's rows leaves the namespace itself.
|
|
2320
|
+
* @returns the entry id to bind.
|
|
2321
|
+
*/
|
|
2322
|
+
const resolve = () => {
|
|
2323
|
+
let served;
|
|
2324
|
+
try {
|
|
2325
|
+
served = forms.describe().getSnapshot().view?.namespaces.map((row) => row.ns);
|
|
2326
|
+
} catch {
|
|
2327
|
+
served = void 0;
|
|
2328
|
+
}
|
|
2329
|
+
if (served === void 0 || served.length === 0) return fallbackId;
|
|
2330
|
+
return entryIds.find((id) => served.includes(id)) ?? namespaceId;
|
|
2331
|
+
};
|
|
2332
|
+
/** Bind (or rebind) the resolved entry's form; a no-op while it is unchanged. */
|
|
2333
|
+
const bind = () => {
|
|
2334
|
+
const target = resolve();
|
|
2335
|
+
if (target === boundId) return;
|
|
2336
|
+
offBound?.();
|
|
2337
|
+
offBound = void 0;
|
|
2338
|
+
let form;
|
|
2339
|
+
try {
|
|
2340
|
+
form = forms.get(target);
|
|
2341
|
+
} catch {
|
|
2342
|
+
boundId = void 0;
|
|
2343
|
+
return;
|
|
2344
|
+
}
|
|
2345
|
+
boundId = target;
|
|
2346
|
+
bound = form;
|
|
2347
|
+
offBound = form.subscribe(() => {
|
|
2348
|
+
publish();
|
|
2349
|
+
});
|
|
2350
|
+
publish();
|
|
2351
|
+
};
|
|
2352
|
+
try {
|
|
2353
|
+
forms.describe().subscribe(() => {
|
|
2354
|
+
bind();
|
|
2355
|
+
});
|
|
2356
|
+
} catch {}
|
|
2357
|
+
bind();
|
|
2358
|
+
return {
|
|
2359
|
+
getSnapshot: () => snapshot,
|
|
2360
|
+
subscribe: (listener) => {
|
|
2361
|
+
listeners.add(listener);
|
|
2362
|
+
return () => {
|
|
2363
|
+
listeners.delete(listener);
|
|
2364
|
+
};
|
|
2365
|
+
},
|
|
2366
|
+
set: (field, value) => bound?.set(field, value) ?? Promise.resolve(false),
|
|
2367
|
+
unset: (field) => bound?.unset(field) ?? Promise.resolve(false),
|
|
2368
|
+
mutate: (ops, expectedRevision) => bound?.mutate(ops, expectedRevision) ?? Promise.resolve(false)
|
|
2369
|
+
};
|
|
2370
|
+
}
|
|
2371
|
+
//#endregion
|
|
2372
|
+
//#region src/client/BrowserViewSettingsCard.tsx
|
|
2373
|
+
/** Bind the existing browser-view namespace, never a second settings document. */
|
|
2374
|
+
function bindBrowserViewSettingsForm(ctx) {
|
|
2375
|
+
return createServedEntryForm({
|
|
2376
|
+
forms: ctx.configForms,
|
|
2377
|
+
entryIds: [
|
|
2378
|
+
"web-ui-browser-view",
|
|
2379
|
+
"ui-browser-view",
|
|
2380
|
+
"browser-view"
|
|
2381
|
+
]
|
|
2382
|
+
});
|
|
2383
|
+
}
|
|
2384
|
+
/** Bridge the native volatile form onto the shared staged card form. */
|
|
2385
|
+
var BrowserViewSettingsCardController = class {
|
|
2386
|
+
form;
|
|
2387
|
+
store;
|
|
2388
|
+
constructor(scope) {
|
|
2389
|
+
this.form = new CardForm(scope, [booleanField("realBrowserEnabled"), textField("cdpEndpoint")]);
|
|
2390
|
+
this.store = this.form.bind(() => this.projection());
|
|
2391
|
+
}
|
|
2392
|
+
projection() {
|
|
2393
|
+
return {
|
|
2394
|
+
...this.form.shell(),
|
|
2395
|
+
realBrowserEnabled: this.form.field("realBrowserEnabled"),
|
|
2396
|
+
cdpEndpoint: this.form.field("cdpEndpoint")
|
|
2397
|
+
};
|
|
2398
|
+
}
|
|
2399
|
+
inject() {
|
|
2400
|
+
return {
|
|
2401
|
+
hooks: { browserViewSettingsCard: this.store },
|
|
2402
|
+
...this.form.actions()
|
|
2403
|
+
};
|
|
2404
|
+
}
|
|
2405
|
+
dispose() {
|
|
2406
|
+
this.form.dispose();
|
|
2407
|
+
}
|
|
2408
|
+
};
|
|
2409
|
+
/** Render the real-browser card with the same chrome and field semantics as its siblings. */
|
|
2410
|
+
function BrowserViewSettingsCard(props) {
|
|
2411
|
+
const { t } = props;
|
|
2412
|
+
const state = props.useBrowserViewSettingsCard((snapshot) => snapshot);
|
|
2413
|
+
const shared = {
|
|
2414
|
+
overriddenLabel: t("settings.overridden"),
|
|
2415
|
+
resetLabel: t("settings.reset"),
|
|
2416
|
+
invalidLabel: t("settings.invalidValue"),
|
|
2417
|
+
disabled: !state.writable
|
|
2418
|
+
};
|
|
2419
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(PluginSettingsCard, {
|
|
2420
|
+
t,
|
|
2421
|
+
titleKey: "settings.title",
|
|
2422
|
+
descriptionKey: "settings.description",
|
|
2423
|
+
icon: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(BrowserViewGuideGlyph, { size: 18 }),
|
|
2424
|
+
defaultOpen: false,
|
|
2425
|
+
state,
|
|
2426
|
+
onSave: props.save,
|
|
2427
|
+
onDiscard: props.discard,
|
|
2428
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(BooleanField, {
|
|
2429
|
+
id: "settings-browser-view-real",
|
|
2430
|
+
label: t("settings.enabled"),
|
|
2431
|
+
hint: t("settings.enabledHint"),
|
|
2432
|
+
inheritLabel: t("settings.inherit"),
|
|
2433
|
+
onLabel: t("settings.on"),
|
|
2434
|
+
offLabel: t("settings.off"),
|
|
2435
|
+
...shared,
|
|
2436
|
+
...state.realBrowserEnabled,
|
|
2437
|
+
onEdit: (text) => {
|
|
2438
|
+
props.edit("realBrowserEnabled", text);
|
|
2439
|
+
},
|
|
2440
|
+
onReset: () => {
|
|
2441
|
+
props.resetField("realBrowserEnabled");
|
|
2442
|
+
}
|
|
2443
|
+
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(ValueField, {
|
|
2444
|
+
id: "settings-browser-view-endpoint",
|
|
2445
|
+
label: t("settings.cdpEndpoint"),
|
|
2446
|
+
hint: t("settings.cdpEndpointHint"),
|
|
2447
|
+
placeholder: "http://127.0.0.1:9222",
|
|
2448
|
+
...shared,
|
|
2449
|
+
...state.cdpEndpoint,
|
|
2450
|
+
onEdit: (text) => {
|
|
2451
|
+
props.edit("cdpEndpoint", text);
|
|
2452
|
+
},
|
|
2453
|
+
onReset: () => {
|
|
2454
|
+
props.resetField("cdpEndpoint");
|
|
2455
|
+
}
|
|
2456
|
+
})]
|
|
2457
|
+
});
|
|
2458
|
+
}
|
|
2459
|
+
//#endregion
|
|
2460
|
+
//#region src/client/plugin-card-seat.ts
|
|
2461
|
+
/**
|
|
2462
|
+
* Family plugin-card seat.
|
|
2463
|
+
*
|
|
2464
|
+
* A family plugin contributes its settings card to whichever plugin-card seat
|
|
2465
|
+
* the running host actually renders:
|
|
2466
|
+
*
|
|
2467
|
+
* - `web-ui.plugin.item` — the list seat declared by the dsh-web-settings
|
|
2468
|
+
* group section (this family's own first-level "Web UI plugins" section);
|
|
2469
|
+
* - `plugins.bundle.config` — the official keyed seat of the harness's plugin
|
|
2470
|
+
* manager page, keyed by the bundle's package name and rendered on that
|
|
2471
|
+
* bundle's page. alpha.2 removed the `settings.plugin.item` keyed seat of the
|
|
2472
|
+
* `ui-settings-plugins` tab that this helper used before, so a card keyed by
|
|
2473
|
+
* its settings namespace has no seat to land in any more.
|
|
2474
|
+
*
|
|
2475
|
+
* SEAT SELECTION IS NOT A DECLARATION PROBE. The official plugin surface
|
|
2476
|
+
* belongs to the harness bundle and declares its seats before any external
|
|
2477
|
+
* plugin's `apply()` runs, so "is the official seat declared?" answers yes even
|
|
2478
|
+
* in the deployment whose whole point is the family group. Choosing on that
|
|
2479
|
+
* probe sends every family card to the official page and leaves the group's own
|
|
2480
|
+
* section permanently empty — the family of reports where the section renders
|
|
2481
|
+
* its heading and zero cards.
|
|
2482
|
+
*
|
|
2483
|
+
* The signal that actually distinguishes the two deployments is whether
|
|
2484
|
+
* dsh-web-settings is loaded: it is the package that owns the group section and
|
|
2485
|
+
* it publishes the `webUiSettings` service during `apply()`, which every
|
|
2486
|
+
* family plugin already reads for its settings form. Group loaded -> the family
|
|
2487
|
+
* seat; group absent -> the official seat.
|
|
2488
|
+
*
|
|
2489
|
+
* The decision is re-evaluated on every `slots/changed` because the group may
|
|
2490
|
+
* apply after this plugin (the family aggregate orders it first, a profile that
|
|
2491
|
+
* installs the group separately need not): the initial contribution goes to the
|
|
2492
|
+
* official seat, then moves to the family seat the moment the group's section
|
|
2493
|
+
* registers. The entry is disposed before the replacement is registered, so a
|
|
2494
|
+
* card is never in two seats at once.
|
|
2495
|
+
*
|
|
2496
|
+
* The shared tree has no client-SDK dependency, so this module reads its
|
|
2497
|
+
* context through the structural shape below; callers pass the plugin's own
|
|
2498
|
+
* `ctx`.
|
|
2499
|
+
*/
|
|
2500
|
+
/** The family list seat key. */
|
|
2501
|
+
const FAMILY_PLUGIN_CARD_SEAT = "web-ui.plugin.item";
|
|
2502
|
+
/** The official keyed plugin-card seat key (the alpha.2 bundle-configuration seat). */
|
|
2503
|
+
const OFFICIAL_PLUGIN_CARD_SEAT = "plugins.bundle.config";
|
|
2504
|
+
/** The service dsh-web-settings publishes while it is loaded. */
|
|
2505
|
+
const FAMILY_GROUP_SERVICE = "webUiSettings";
|
|
2506
|
+
/**
|
|
2507
|
+
* Whether the family group (dsh-web-settings) is loaded in this page. The
|
|
2508
|
+
* service is the group package's own contract, so the probe cannot be fooled
|
|
2509
|
+
* by a harness release that starts declaring the official seat differently.
|
|
2510
|
+
*/
|
|
2511
|
+
function familyGroupLoaded(ctx) {
|
|
2512
|
+
const get = ctx.get;
|
|
2513
|
+
if (typeof get !== "function") return false;
|
|
2514
|
+
try {
|
|
2515
|
+
return get.call(ctx, FAMILY_GROUP_SERVICE) !== void 0;
|
|
2516
|
+
} catch {
|
|
2517
|
+
return false;
|
|
2518
|
+
}
|
|
2519
|
+
}
|
|
2520
|
+
/** Report a refused registration instead of leaving the user with no card. */
|
|
2521
|
+
function warnRefusedSeat(seat, error) {
|
|
2522
|
+
try {
|
|
2523
|
+
console.warn(`[dsh-web] plugin card registration into "${seat}" was refused; the card will not render`, error);
|
|
2524
|
+
} catch {}
|
|
2525
|
+
}
|
|
2526
|
+
/**
|
|
2527
|
+
* Contribute one family plugin card to the seat this host renders, following
|
|
2528
|
+
* the group if it loads later. The entry is disposed and re-registered on a
|
|
2529
|
+
* seat change, never duplicated.
|
|
2530
|
+
* @param ctx - client context (its slot registry decides the seat).
|
|
2531
|
+
* @param seat - the card contribution.
|
|
2532
|
+
*/
|
|
2533
|
+
function installPluginCard(ctx, seat) {
|
|
2534
|
+
const slots = ctx.slots;
|
|
2535
|
+
const component = seat.component;
|
|
2536
|
+
const inject = seat.inject;
|
|
2537
|
+
let dispose;
|
|
2538
|
+
let current;
|
|
2539
|
+
/**
|
|
2540
|
+
* Re-entrancy latch. The registry emits a change event synchronously from
|
|
2541
|
+
* inside both `register` and the previous entry's disposer, so an unguarded
|
|
2542
|
+
* reconcile would re-enter itself mid-move and register the card twice into
|
|
2543
|
+
* the seat it is leaving ("already has an entry for key ...").
|
|
2544
|
+
*/
|
|
2545
|
+
let reconciling = false;
|
|
2546
|
+
/** Reconcile the contribution with the currently live seat (no-op when unchanged). */
|
|
2547
|
+
const reconcile = () => {
|
|
2548
|
+
if (reconciling) return;
|
|
2549
|
+
const target = familyGroupLoaded(ctx) ? FAMILY_PLUGIN_CARD_SEAT : OFFICIAL_PLUGIN_CARD_SEAT;
|
|
2550
|
+
if (current === target) return;
|
|
2551
|
+
if (typeof slots.spec === "function" && slots.spec(target) === void 0) return;
|
|
2552
|
+
reconciling = true;
|
|
2553
|
+
const previous = dispose;
|
|
2554
|
+
dispose = void 0;
|
|
2555
|
+
current = void 0;
|
|
2556
|
+
previous?.();
|
|
2557
|
+
try {
|
|
2558
|
+
dispose = slots.register(target === "web-ui.plugin.item" ? {
|
|
2559
|
+
name: FAMILY_PLUGIN_CARD_SEAT,
|
|
2560
|
+
id: seat.id,
|
|
2561
|
+
...seat.order === void 0 ? {} : { order: seat.order },
|
|
2562
|
+
...seat.label === void 0 ? {} : { label: seat.label },
|
|
2563
|
+
locale: seat.locale,
|
|
2564
|
+
...seat.children === void 0 ? {} : { children: seat.children },
|
|
2565
|
+
...seat.inject === void 0 ? {} : { inject }
|
|
2566
|
+
} : {
|
|
2567
|
+
name: OFFICIAL_PLUGIN_CARD_SEAT,
|
|
2568
|
+
key: seat.bundle,
|
|
2569
|
+
locale: seat.locale,
|
|
2570
|
+
...seat.children === void 0 ? {} : { children: seat.children },
|
|
2571
|
+
...seat.inject === void 0 ? {} : { inject }
|
|
2572
|
+
}, component);
|
|
2573
|
+
current = target;
|
|
2574
|
+
} catch (error) {
|
|
2575
|
+
warnRefusedSeat(target, error);
|
|
2576
|
+
} finally {
|
|
2577
|
+
reconciling = false;
|
|
2578
|
+
}
|
|
2579
|
+
};
|
|
2580
|
+
if (typeof ctx.on === "function") try {
|
|
2581
|
+
ctx.on("slots/changed", () => {
|
|
2582
|
+
reconcile();
|
|
2583
|
+
});
|
|
2584
|
+
} catch {}
|
|
2585
|
+
reconcile();
|
|
2586
|
+
}
|
|
2587
|
+
//#endregion
|
|
899
2588
|
//#region src/client/index.ts
|
|
900
2589
|
/** Dictionary namespace owned by this plugin. */
|
|
901
2590
|
const NS = "browser-view";
|
|
@@ -903,7 +2592,9 @@ window.__ModuleLoader__.load({
|
|
|
903
2592
|
const inject = [
|
|
904
2593
|
"slots",
|
|
905
2594
|
"locale",
|
|
906
|
-
"sidebarRightTabs"
|
|
2595
|
+
"sidebarRightTabs",
|
|
2596
|
+
"configForms",
|
|
2597
|
+
"remote"
|
|
907
2598
|
];
|
|
908
2599
|
/**
|
|
909
2600
|
* Register the browser-view tab type and its surfaces.
|
|
@@ -963,6 +2654,31 @@ window.__ModuleLoader__.load({
|
|
|
963
2654
|
return () => {};
|
|
964
2655
|
}
|
|
965
2656
|
});
|
|
2657
|
+
ctx.slots.inject("plugins.row.config", () => {
|
|
2658
|
+
const disposers = [];
|
|
2659
|
+
for (const key of BROWSER_VIEW_CONFIG_KEYS) try {
|
|
2660
|
+
disposers.push(ctx.slots.register({
|
|
2661
|
+
name: "plugins.row.config",
|
|
2662
|
+
key,
|
|
2663
|
+
locale: NS
|
|
2664
|
+
}, BrowserViewConfig));
|
|
2665
|
+
} catch {}
|
|
2666
|
+
return () => {
|
|
2667
|
+
for (const dispose of disposers) dispose();
|
|
2668
|
+
};
|
|
2669
|
+
});
|
|
2670
|
+
const settingsCard = new BrowserViewSettingsCardController(bindBrowserViewSettingsForm(ctx));
|
|
2671
|
+
installPluginCard(ctx, {
|
|
2672
|
+
bundle: "@linxin666/dsh-client-ui-browser-view",
|
|
2673
|
+
id: "browser-view",
|
|
2674
|
+
order: 95,
|
|
2675
|
+
locale: NS,
|
|
2676
|
+
inject: () => settingsCard.inject(),
|
|
2677
|
+
component: BrowserViewSettingsCard
|
|
2678
|
+
});
|
|
2679
|
+
ctx.effect(() => () => {
|
|
2680
|
+
settingsCard.dispose();
|
|
2681
|
+
}, "browser-view: settings card");
|
|
966
2682
|
}
|
|
967
2683
|
//#endregion
|
|
968
2684
|
exports.apply = apply;
|