@linxin666/dsh-liangshen 0.3.23 → 0.3.24
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 +45 -38
- package/README.zh.md +44 -37
- package/lib/client.js +1058 -11
- package/lib/client.js.map +1 -1
- package/lib/index.js +105 -22
- package/lib/types/client/LiangShenSettingsCard.d.ts +61 -0
- package/lib/types/client/PluginSettingsCard.d.ts +133 -0
- package/lib/types/client/index.d.ts +34 -0
- package/lib/types/client/locales.d.ts +27 -1
- package/lib/types/client/plugin-card-seat.d.ts +96 -0
- package/lib/types/client/settings-form.d.ts +197 -0
- package/lib/types/core/lever.d.ts +6 -3
- package/lib/types/index.d.ts +23 -11
- package/lib/types/sync.d.ts +29 -2
- package/package.json +6 -2
- package/presets/liangshen/NOTICE +4 -4
- package/presets/liangshen/agent.cordis.yml +130 -119
- package/presets/liangshen/minimal-prompt.mjs +71 -36
- package/presets/liangshen/paging.mjs +232 -0
- package/presets/liangshen/tool-activate.mjs +176 -0
- package/presets/liangshen/tool-catalog.mjs +610 -218
- package/presets/liangshen/working-context.mjs +214 -0
- package/src/client/LiangShenLever.tsx +4 -1
- package/src/client/LiangShenSettingsCard.tsx +149 -0
- package/src/client/PluginSettingsCard.tsx +550 -0
- package/src/client/index.ts +60 -1
- package/src/client/locales.ts +53 -1
- package/src/client/plugin-card-seat.ts +185 -0
- package/src/client/settings-card.module.css +418 -0
- package/src/client/settings-form.ts +439 -0
- package/src/core/lever.ts +7 -4
- package/src/index.ts +35 -14
- package/src/sync.test.ts +86 -7
- package/src/sync.ts +108 -6
- package/tools/benchmark-live-run.mjs +24 -33
- package/presets/liangshen/custom-bash.mjs +0 -213
package/lib/client.js
CHANGED
|
@@ -7,13 +7,13 @@ window.__ModuleLoader__.load({
|
|
|
7
7
|
let react = require("react");
|
|
8
8
|
let react_jsx_runtime = require("react/jsx-runtime");
|
|
9
9
|
//#region \0dsh-css:packages/dsh-liangshen/src/client/LiangShenLever.module.css.mjs
|
|
10
|
-
const css = ".hYkIZq_lever{align-items:center;font-size:12px;line-height:1;display:inline-flex;position:relative}.hYkIZq_control{color:var(--dsw-alias-label-secondary,inherit);font:inherit;cursor:pointer;touch-action:none;background:0 0;border:none;border-radius:999px;align-items:center;gap:6px;margin:0;padding:2px 8px 2px 4px;transition:background-color .16s,color .16s;display:inline-flex}.hYkIZq_control:hover:not(:disabled){background:var(--dsw-alias-interactive-bg-hover,#0000000f)}.hYkIZq_control:focus-visible{outline:2px solid var(--dsw-alias-brand-primary,currentColor);outline-offset:2px}.hYkIZq_control:disabled{cursor:default;opacity:.55}.hYkIZq_track{background:linear-gradient(#2b2f36,#14161a);border-radius:8px;justify-content:center;align-items:flex-end;width:24px;height:28px;display:inline-flex;position:relative;overflow:hidden;box-shadow:inset 0 0 0 1px #ffffff24,inset 0 6px 10px #0000008c}.hYkIZq_track:after{content:\"\";background:#ffffff38;border-radius:2px;height:3px;position:absolute;bottom:2px;left:3px;right:3px}.hYkIZq_arm{transform-origin:50% 24px;width:16px;height:26px;margin-left:-8px;transition:transform .34s cubic-bezier(.2,1.7,.32,1);position:absolute;bottom:2px;left:50%;transform:rotate(-24deg)}.hYkIZq_lever[data-state=on] .hYkIZq_arm{transform:rotate(24deg)}.hYkIZq_rod{fill:#c9ced6;transition:fill .2s}.hYkIZq_knob{fill:#e04a33;stroke:#00000059;stroke-width:.6px;transition:fill .2s}.hYkIZq_lever[data-state=on] .hYkIZq_rod{fill:#ffd76a}.hYkIZq_lever[data-state=on] .hYkIZq_knob{fill:#f7c637}.hYkIZq_lever[data-state=on] .hYkIZq_track{box-shadow:inset 0 0 0 1px var(--dsw-alias-border-l3,#0000001f), 0 0 10px #f7c6378c}.hYkIZq_lever[data-busy=true] .hYkIZq_arm{animation:.42s ease-in-out infinite hYkIZq_lever-jitter}.hYkIZq_readout{white-space:nowrap;letter-spacing:.02em;min-width:4.4em}.hYkIZq_lever[data-state=on] .hYkIZq_readout{color:var(--dsw-alias-label-primary,inherit);font-weight:600}.hYkIZq_error{background:var(--dsw-alias-bg-layer-3,#0000000f);max-width:22ch;color:var(--dsw-alias-state-error-primary,#c0392b);text-overflow:ellipsis;white-space:nowrap;border-radius:6px;margin-left:4px;padding:2px 6px;overflow:hidden}.hYkIZq_burst{z-index:60;pointer-events:none;place-items:center;display:grid;position:fixed;inset:0;overflow:hidden}.hYkIZq_flash{background:radial-gradient(circle at 50% 62%,#fff6c8eb,#ffd04a73 38%,#ffa00000 72%);animation:.72s ease-out both hYkIZq_burst-flash;position:absolute;inset:0}.hYkIZq_ring{border:6px solid #ffd65ad9;border-radius:50%;width:220px;height:220px;animation:1.1s cubic-bezier(.16,.9,.3,1) both hYkIZq_burst-ring;position:absolute}.hYkIZq_ring:nth-of-type(2){animation-delay:.12s}.hYkIZq_ring:nth-of-type(3){animation-delay:.24s}.hYkIZq_banner{color:#ffe9a8;text-align:center;background:linear-gradient(160deg,#181004f0,#402604eb);border-radius:22px;flex-direction:column;align-items:center;gap:6px;padding:22px 40px;animation:.6s cubic-bezier(.16,1.5,.3,1) both hYkIZq_banner-slam,.5s ease-in-out .6s 2 hYkIZq_banner-shake;display:flex;position:relative;box-shadow:0 0 0 2px #ffd65abf,0 24px 70px #00000073}.hYkIZq_bannerName{letter-spacing:.16em;background:linear-gradient(#fff6d0,#ffc93c 55%,#b8730a);color:#0000;text-shadow:0 0 24px #ffc93ca6;-webkit-background-clip:text;background-clip:text;font-size:44px;font-weight:800}.hYkIZq_line{letter-spacing:.08em;font-size:15px}.hYkIZq_code{font-family:var(--dsw-font-mono,ui-monospace, SFMono-Regular, Menlo, monospace);letter-spacing:.06em;opacity:.82;font-size:11px;animation:.5s steps(2,end) 6 hYkIZq_code-blink}.hYkIZq_sparks{place-items:center;display:grid;position:absolute;inset:0}.hYkIZq_spark{transform-origin:50%;background:linear-gradient(#ffeca0f2,#ffaa1400);border-radius:3px;grid-area:1/1;width:3px;height:30px;animation:.95s ease-out both hYkIZq_spark-fly}@keyframes hYkIZq_lever-jitter{0%,to{transform:rotate(-22deg)}50%{transform:rotate(-8deg)}}@keyframes hYkIZq_burst-flash{0%{opacity:0;transform:scale(.6)}18%{opacity:1}to{opacity:0;transform:scale(1.5)}}@keyframes hYkIZq_burst-ring{0%{opacity:.9;transform:scale(.2)}to{opacity:0;transform:scale(3.4)}}@keyframes hYkIZq_banner-slam{0%{opacity:0;transform:scale(3.6)rotate(-9deg)}55%{opacity:1;transform:scale(.94)rotate(1.5deg)}75%{transform:scale(1.06)rotate(-1deg)}to{opacity:1;transform:scale(1)rotate(0)}}@keyframes hYkIZq_banner-shake{0%,to{transform:translate(0)}25%{transform:translate(-9px)rotate(-.6deg)}75%{transform:translate(9px)rotate(.6deg)}}@keyframes hYkIZq_spark-fly{0%{opacity:0;transform:translateY(-40px)scaleY(.3)}18%{opacity:1}to{opacity:0;transform:translateY(-300px)scaleY(1.15)}}@keyframes hYkIZq_code-blink{0%,to{opacity:.35}50%{opacity:1}}@media (prefers-reduced-motion:reduce){.hYkIZq_arm,.hYkIZq_control,.hYkIZq_rod,.hYkIZq_knob{transition:none}.hYkIZq_lever[data-busy=true] .hYkIZq_arm,.hYkIZq_flash,.hYkIZq_ring,.hYkIZq_banner,.hYkIZq_code,.hYkIZq_spark{animation:none}.hYkIZq_burst{animation:.3s ease-out both hYkIZq_burst-flash}.hYkIZq_spark{display:none}}";
|
|
11
|
-
const tagId = "@linxin666/dsh-liangshen/packages/dsh-liangshen/src/client/LiangShenLever.module.css";
|
|
12
|
-
if (typeof document !== "undefined" && document.querySelector("style[data-plugin-css=" + JSON.stringify(tagId) + "]") === null) {
|
|
10
|
+
const css$1 = ".hYkIZq_lever{align-items:center;font-size:12px;line-height:1;display:inline-flex;position:relative}.hYkIZq_control{color:var(--dsw-alias-label-secondary,inherit);font:inherit;cursor:pointer;touch-action:none;background:0 0;border:none;border-radius:999px;align-items:center;gap:6px;margin:0;padding:2px 8px 2px 4px;transition:background-color .16s,color .16s;display:inline-flex}.hYkIZq_control:hover:not(:disabled){background:var(--dsw-alias-interactive-bg-hover,#0000000f)}.hYkIZq_control:focus-visible{outline:2px solid var(--dsw-alias-brand-primary,currentColor);outline-offset:2px}.hYkIZq_control:disabled{cursor:default;opacity:.55}.hYkIZq_track{background:linear-gradient(#2b2f36,#14161a);border-radius:8px;justify-content:center;align-items:flex-end;width:24px;height:28px;display:inline-flex;position:relative;overflow:hidden;box-shadow:inset 0 0 0 1px #ffffff24,inset 0 6px 10px #0000008c}.hYkIZq_track:after{content:\"\";background:#ffffff38;border-radius:2px;height:3px;position:absolute;bottom:2px;left:3px;right:3px}.hYkIZq_arm{transform-origin:50% 24px;width:16px;height:26px;margin-left:-8px;transition:transform .34s cubic-bezier(.2,1.7,.32,1);position:absolute;bottom:2px;left:50%;transform:rotate(-24deg)}.hYkIZq_lever[data-state=on] .hYkIZq_arm{transform:rotate(24deg)}.hYkIZq_rod{fill:#c9ced6;transition:fill .2s}.hYkIZq_knob{fill:#e04a33;stroke:#00000059;stroke-width:.6px;transition:fill .2s}.hYkIZq_lever[data-state=on] .hYkIZq_rod{fill:#ffd76a}.hYkIZq_lever[data-state=on] .hYkIZq_knob{fill:#f7c637}.hYkIZq_lever[data-state=on] .hYkIZq_track{box-shadow:inset 0 0 0 1px var(--dsw-alias-border-l3,#0000001f), 0 0 10px #f7c6378c}.hYkIZq_lever[data-busy=true] .hYkIZq_arm{animation:.42s ease-in-out infinite hYkIZq_lever-jitter}.hYkIZq_readout{white-space:nowrap;letter-spacing:.02em;min-width:4.4em}.hYkIZq_lever[data-state=on] .hYkIZq_readout{color:var(--dsw-alias-label-primary,inherit);font-weight:600}.hYkIZq_error{background:var(--dsw-alias-bg-layer-3,#0000000f);max-width:22ch;color:var(--dsw-alias-state-error-primary,#c0392b);text-overflow:ellipsis;white-space:nowrap;border-radius:6px;margin-left:4px;padding:2px 6px;overflow:hidden}.hYkIZq_burst{z-index:60;pointer-events:none;place-items:center;display:grid;position:fixed;inset:0;overflow:hidden}.hYkIZq_flash{background:radial-gradient(circle at 50% 62%,#fff6c8eb,#ffd04a73 38%,#ffa00000 72%);animation:.72s ease-out both hYkIZq_burst-flash;position:absolute;inset:0}.hYkIZq_ring{border:6px solid #ffd65ad9;border-radius:50%;width:220px;height:220px;animation:1.1s cubic-bezier(.16,.9,.3,1) both hYkIZq_burst-ring;position:absolute}.hYkIZq_ring:nth-of-type(2){animation-delay:.12s}.hYkIZq_ring:nth-of-type(3){animation-delay:.24s}.hYkIZq_banner{color:#ffe9a8;text-align:center;background:linear-gradient(160deg,#181004f0,#402604eb);border-radius:22px;flex-direction:column;align-items:center;gap:6px;padding:22px 40px;animation:.6s cubic-bezier(.16,1.5,.3,1) both hYkIZq_banner-slam,.5s ease-in-out .6s 2 hYkIZq_banner-shake;display:flex;position:relative;box-shadow:0 0 0 2px #ffd65abf,0 24px 70px #00000073}.hYkIZq_bannerName{letter-spacing:.16em;background:linear-gradient(#fff6d0,#ffc93c 55%,#b8730a);color:#0000;text-shadow:0 0 24px #ffc93ca6;-webkit-background-clip:text;background-clip:text;font-size:44px;font-weight:800}.hYkIZq_line{letter-spacing:.08em;font-size:15px}.hYkIZq_code{font-family:var(--dsw-font-mono,ui-monospace, SFMono-Regular, Menlo, monospace);letter-spacing:.06em;opacity:.82;font-size:11px;animation:.5s steps(2,end) 6 hYkIZq_code-blink}.hYkIZq_sparks{place-items:center;display:grid;position:absolute;inset:0}.hYkIZq_spark{transform-origin:50%;background:linear-gradient(#ffeca0f2,#ffaa1400);border-radius:3px;grid-area:1/1;width:3px;height:30px;animation:.95s ease-out both hYkIZq_spark-fly}@keyframes hYkIZq_lever-jitter{0%,to{transform:rotate(-22deg)}50%{transform:rotate(-8deg)}}@keyframes hYkIZq_burst-flash{0%{opacity:0;transform:scale(.6)}18%{opacity:1}to{opacity:0;transform:scale(1.5)}}@keyframes hYkIZq_burst-ring{0%{opacity:.9;transform:scale(.2)}to{opacity:0;transform:scale(3.4)}}@keyframes hYkIZq_banner-slam{0%{opacity:0;transform:scale(3.6)rotate(-9deg)}55%{opacity:1;transform:scale(.94)rotate(1.5deg)}75%{transform:scale(1.06)rotate(-1deg)}to{opacity:1;transform:scale(1)rotate(0)}}@keyframes hYkIZq_banner-shake{0%,to{transform:translate(0)}25%{transform:translate(-9px)rotate(-.6deg)}75%{transform:translate(9px)rotate(.6deg)}}@keyframes hYkIZq_spark-fly{0%{opacity:0;transform:translateY(-40px)scaleY(.3)}18%{opacity:1}to{opacity:0;transform:translateY(-300px)scaleY(1.15)}}@keyframes hYkIZq_code-blink{0%,to{opacity:.35}50%{opacity:1}}@media (prefers-reduced-motion:reduce){.hYkIZq_arm,.hYkIZq_control,.hYkIZq_rod,.hYkIZq_knob{transition:none}.hYkIZq_lever[data-busy=true] .hYkIZq_arm,.hYkIZq_flash,.hYkIZq_ring,.hYkIZq_banner,.hYkIZq_code,.hYkIZq_spark{animation:none}.hYkIZq_burst{animation:.3s ease-out both hYkIZq_burst-flash}.hYkIZq_spark{display:none}}";
|
|
11
|
+
const tagId$1 = "@linxin666/dsh-liangshen/packages/dsh-liangshen/src/client/LiangShenLever.module.css";
|
|
12
|
+
if (typeof document !== "undefined" && document.querySelector("style[data-plugin-css=" + JSON.stringify(tagId$1) + "]") === null) {
|
|
13
13
|
const tag = document.createElement("style");
|
|
14
14
|
tag.dataset.plugin = "@linxin666/dsh-liangshen";
|
|
15
|
-
tag.dataset.pluginCss = tagId;
|
|
16
|
-
tag.textContent = css;
|
|
15
|
+
tag.dataset.pluginCss = tagId$1;
|
|
16
|
+
tag.textContent = css$1;
|
|
17
17
|
document.head.appendChild(tag);
|
|
18
18
|
}
|
|
19
19
|
var LiangShenLever_module_css_default = {
|
|
@@ -88,7 +88,7 @@ window.__ModuleLoader__.load({
|
|
|
88
88
|
clearTimeout(timer);
|
|
89
89
|
};
|
|
90
90
|
}, [burstKey]);
|
|
91
|
-
if (state === "locked" || state === "missing") return null;
|
|
91
|
+
if (state === "locked" || state === "missing" || state === "on" && restoreLabel === "") return null;
|
|
92
92
|
const toggle = () => {
|
|
93
93
|
if (!actionable) return;
|
|
94
94
|
if (on) face.push();
|
|
@@ -274,15 +274,19 @@ window.__ModuleLoader__.load({
|
|
|
274
274
|
}
|
|
275
275
|
/**
|
|
276
276
|
* The preset a push-up restores: the preset the user was on before pulling the
|
|
277
|
-
* lever, else the deployment default
|
|
278
|
-
* LiangShen preset
|
|
279
|
-
* no
|
|
277
|
+
* lever, else the deployment default, else the first usable roster row that is
|
|
278
|
+
* not the LiangShen preset. A candidate is skipped when it is the LiangShen
|
|
279
|
+
* preset itself (restoring it would be a no-op) or when the roster no longer
|
|
280
|
+
* supplies it. That last resort is what keeps the push direction alive when the
|
|
281
|
+
* deployment default IS LiangShen mode: `fallback` is skipped then, and after a
|
|
282
|
+
* reload `previous` is gone, so without it the gesture would have no target.
|
|
280
283
|
*/
|
|
281
284
|
function restoreTarget(facts) {
|
|
282
285
|
for (const candidate of [facts.previous, facts.fallback]) {
|
|
283
286
|
if (candidate === void 0 || candidate === "liangshen") continue;
|
|
284
287
|
if (facts.available.includes(candidate)) return candidate;
|
|
285
288
|
}
|
|
289
|
+
return facts.available.find((candidate) => candidate !== LIANGSHEN_PRESET_ID);
|
|
286
290
|
}
|
|
287
291
|
/** Whether the lever can act at all in its current state. */
|
|
288
292
|
function isActionable(state) {
|
|
@@ -528,6 +532,856 @@ window.__ModuleLoader__.load({
|
|
|
528
532
|
return error instanceof Error ? error.message : String(error);
|
|
529
533
|
}
|
|
530
534
|
//#endregion
|
|
535
|
+
//#region \0dsh-css:packages/dsh-liangshen/src/client/settings-card.module.css.mjs
|
|
536
|
+
const css = "._9t79wq_card{border:1px solid var(--dsw-alias-border-l2);background:var(--dsw-alias-bg-layer-3);border-radius:12px;list-style:none;transition:border-color .16s,background .16s}._9t79wq_card:hover{border-color:var(--dsw-alias-label-dimmed)}._9t79wq_cardOpen{background:var(--dsw-alias-bg-layer-2);border-color:var(--dsw-alias-label-dimmed)}._9t79wq_header{appearance:none;box-sizing:border-box;width:100%;font:inherit;color:inherit;text-align:left;cursor:pointer;background:0 0;border:0;border-radius:12px;align-items:center;gap:12px;padding:14px 16px;display:flex}._9t79wq_header:focus-visible{outline:2px solid var(--dsw-alias-brand-primary);outline-offset:-2px}._9t79wq_headerStatic{box-sizing:border-box;border-radius:12px;align-items:center;gap:12px;width:100%;padding:14px 16px;display:flex}._9t79wq_headText{flex-direction:column;flex:1;gap:4px;min-width:0;display:flex}._9t79wq_name{color:var(--dsw-alias-label-primary);font-size:15px;font-weight:600;line-height:1.4}._9t79wq_description{color:var(--dsw-alias-label-secondary);font-size:13px;line-height:1.5}._9t79wq_pending{white-space:nowrap;background:var(--dsw-alias-bg-module-platform);color:var(--dsw-alias-label-secondary);border-radius:999px;flex:none;padding:1px 8px;font-size:11px;font-weight:500;line-height:17px}._9t79wq_chevron{color:var(--dsw-alias-label-tertiary);flex:none;transition:transform .16s}._9t79wq_chevronOpen{transform:rotate(180deg)}._9t79wq_body{border-top:1px solid var(--dsw-alias-border-l2);margin:0 16px;padding-bottom:8px}._9t79wq_readOnly{color:var(--dsw-alias-label-secondary);margin:12px 0 0;font-size:12px;line-height:1.5}._9t79wq_notExposed{color:var(--dsw-alias-state-warn-primary);margin:12px 0 0;font-size:12px;line-height:1.5}._9t79wq_footer{border-top:1px solid var(--dsw-alias-border-l2);justify-content:flex-end;align-items:center;gap:8px;padding:12px 0 4px;display:flex}._9t79wq_failed{min-width:0;color:var(--dsw-alias-state-error-primary,#b42318);text-overflow:ellipsis;white-space:nowrap;flex:1;margin:0;font-size:12px;line-height:1.5;overflow:hidden}._9t79wq_discard,._9t79wq_save{appearance:none;font:inherit;cursor:pointer;border:1px solid #0000;border-radius:8px;padding:5px 14px;font-size:13px;line-height:1.5}._9t79wq_discard{border-color:var(--dsw-alias-border-l2);color:var(--dsw-alias-label-secondary);background:0 0}._9t79wq_discard:hover:not(:disabled){color:var(--dsw-alias-label-primary);border-color:var(--dsw-alias-label-dimmed)}._9t79wq_save{background:var(--dsw-alias-label-primary);color:var(--dsw-alias-bg-layer-3)}._9t79wq_discard:disabled,._9t79wq_save:disabled{opacity:.4;cursor:default}._9t79wq_discard:focus-visible,._9t79wq_save:focus-visible{outline:2px solid var(--dsw-alias-brand-primary);outline-offset:1px}._9t79wq_field{flex-direction:column;gap:6px;padding:12px 0;display:flex}._9t79wq_field+._9t79wq_field{border-top:1px solid var(--dsw-alias-border-l2)}._9t79wq_head{align-items:center;gap:8px;display:flex}._9t79wq_label{min-width:0;color:var(--dsw-alias-label-primary);flex:1;font-size:13px;font-weight:500;line-height:1.5}._9t79wq_badges{align-items:center;gap:8px;display:inline-flex}._9t79wq_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}._9t79wq_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}._9t79wq_reset:hover:not(:disabled){color:var(--dsw-alias-label-primary)}._9t79wq_reset:disabled{cursor:default}._9t79wq_reset:focus-visible{outline:2px solid var(--dsw-alias-brand-primary);outline-offset:2px;outline:2px solid var(--dsw-alias-brand-primary);outline-offset:2px}._9t79wq_input,._9t79wq_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}._9t79wq_input:focus-visible,._9t79wq_select:focus-visible{border-color:var(--dsw-alias-brand-primary);outline:none}._9t79wq_input:disabled,._9t79wq_select:disabled{color:var(--dsw-alias-label-tertiary);cursor:default}._9t79wq_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}._9t79wq_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)}._9t79wq_selectWrap{position:relative}._9t79wq_selectButton{appearance:none;text-align:left;cursor:pointer;justify-content:space-between;align-items:center;gap:8px;width:100%;display:flex}._9t79wq_selectLabel{text-overflow:ellipsis;white-space:nowrap;min-width:0;overflow:hidden}._9t79wq_selectChevron{color:var(--dsw-alias-label-tertiary);flex:none;transition:transform .16s}._9t79wq_selectChevronOpen{transform:rotate(180deg)}._9t79wq_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)}._9t79wq_selectPopupOpen{opacity:1;transform:none}._9t79wq_selectPopupClose{opacity:0;pointer-events:none;transform:translateY(-4px)}._9t79wq_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}._9t79wq_selectOption:hover,._9t79wq_selectOptionActive{background:var(--dsw-alias-interactive-bg-hover)}._9t79wq_selectOptionSelected{color:var(--dsw-alias-brand-primary);background:color-mix(in srgb, var(--dsw-alias-brand-primary-new-colorprimary-new-color) 10%, transparent);font-weight:500}._9t79wq_invalid{color:var(--dsw-alias-state-error-primary,#b42318);margin:0;font-size:12px;line-height:1.5}._9t79wq_hint{color:var(--dsw-alias-label-secondary);margin:0;font-size:12px;line-height:1.5}@media (prefers-reduced-motion:reduce){._9t79wq_card,._9t79wq_header,._9t79wq_chevron,._9t79wq_chevronOpen,._9t79wq_discard,._9t79wq_save,._9t79wq_selectChevron,._9t79wq_selectChevronOpen,._9t79wq_selectPopup{transition:none}}";
|
|
537
|
+
const tagId = "@linxin666/dsh-liangshen/packages/dsh-liangshen/src/client/settings-card.module.css";
|
|
538
|
+
if (typeof document !== "undefined" && document.querySelector("style[data-plugin-css=" + JSON.stringify(tagId) + "]") === null) {
|
|
539
|
+
const tag = document.createElement("style");
|
|
540
|
+
tag.dataset.plugin = "@linxin666/dsh-liangshen";
|
|
541
|
+
tag.dataset.pluginCss = tagId;
|
|
542
|
+
tag.textContent = css;
|
|
543
|
+
document.head.appendChild(tag);
|
|
544
|
+
}
|
|
545
|
+
var settings_card_module_css_default = {
|
|
546
|
+
"badge": "_9t79wq_badge",
|
|
547
|
+
"badges": "_9t79wq_badges",
|
|
548
|
+
"body": "_9t79wq_body",
|
|
549
|
+
"card": "_9t79wq_card",
|
|
550
|
+
"cardOpen": "_9t79wq_cardOpen",
|
|
551
|
+
"chevron": "_9t79wq_chevron",
|
|
552
|
+
"chevronOpen": "_9t79wq_chevronOpen",
|
|
553
|
+
"description": "_9t79wq_description",
|
|
554
|
+
"discard": "_9t79wq_discard",
|
|
555
|
+
"failed": "_9t79wq_failed",
|
|
556
|
+
"field": "_9t79wq_field",
|
|
557
|
+
"footer": "_9t79wq_footer",
|
|
558
|
+
"head": "_9t79wq_head",
|
|
559
|
+
"headText": "_9t79wq_headText",
|
|
560
|
+
"header": "_9t79wq_header",
|
|
561
|
+
"headerStatic": "_9t79wq_headerStatic",
|
|
562
|
+
"hint": "_9t79wq_hint",
|
|
563
|
+
"input": "_9t79wq_input",
|
|
564
|
+
"inputInvalid": "_9t79wq_inputInvalid",
|
|
565
|
+
"invalid": "_9t79wq_invalid",
|
|
566
|
+
"label": "_9t79wq_label",
|
|
567
|
+
"name": "_9t79wq_name",
|
|
568
|
+
"notExposed": "_9t79wq_notExposed",
|
|
569
|
+
"pending": "_9t79wq_pending",
|
|
570
|
+
"readOnly": "_9t79wq_readOnly",
|
|
571
|
+
"reset": "_9t79wq_reset",
|
|
572
|
+
"save": "_9t79wq_save",
|
|
573
|
+
"select": "_9t79wq_select",
|
|
574
|
+
"selectButton": "_9t79wq_selectButton",
|
|
575
|
+
"selectChevron": "_9t79wq_selectChevron",
|
|
576
|
+
"selectChevronOpen": "_9t79wq_selectChevronOpen",
|
|
577
|
+
"selectLabel": "_9t79wq_selectLabel",
|
|
578
|
+
"selectOption": "_9t79wq_selectOption",
|
|
579
|
+
"selectOptionActive": "_9t79wq_selectOptionActive",
|
|
580
|
+
"selectOptionSelected": "_9t79wq_selectOptionSelected",
|
|
581
|
+
"selectPopup": "_9t79wq_selectPopup",
|
|
582
|
+
"selectPopupClose": "_9t79wq_selectPopupClose",
|
|
583
|
+
"selectPopupOpen": "_9t79wq_selectPopupOpen",
|
|
584
|
+
"selectWrap": "_9t79wq_selectWrap"
|
|
585
|
+
};
|
|
586
|
+
//#endregion
|
|
587
|
+
//#region src/client/PluginSettingsCard.tsx
|
|
588
|
+
/**
|
|
589
|
+
* Family-shared chrome for plugin settings cards: a disclosure header naming
|
|
590
|
+
* the plugin and what its settings govern, the controls inside, and the save
|
|
591
|
+
* that writes them. Renders nothing while the namespace is unavailable — a
|
|
592
|
+
* deployment that does not compose the owning plugin should show no trace of
|
|
593
|
+
* it. Inlined into each consumer's client bundle; mirrors the official
|
|
594
|
+
* ui-plugin-config PluginCard in a self-contained slice.
|
|
595
|
+
*/
|
|
596
|
+
/**
|
|
597
|
+
* Render one plugin settings card.
|
|
598
|
+
* @param props - the plugin's copy keys, its form state, and its controls.
|
|
599
|
+
* @returns the card, or nothing while the namespace is still loading.
|
|
600
|
+
*/
|
|
601
|
+
function PluginSettingsCard(props) {
|
|
602
|
+
const [open, setOpen] = (0, react.useState)(props.defaultOpen ?? true);
|
|
603
|
+
const { state, alwaysOpen } = props;
|
|
604
|
+
if (!state.available) return null;
|
|
605
|
+
const title = props.t(props.titleKey);
|
|
606
|
+
const description = props.t(props.descriptionKey);
|
|
607
|
+
const blocked = !state.dirty || state.invalid || state.saving;
|
|
608
|
+
const expanded = alwaysOpen === true || open;
|
|
609
|
+
const cardClass = expanded ? `${settings_card_module_css_default.cardOpen} ${settings_card_module_css_default.card}` : settings_card_module_css_default.card;
|
|
610
|
+
const header = alwaysOpen === true ? /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
611
|
+
className: settings_card_module_css_default.headerStatic,
|
|
612
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("span", {
|
|
613
|
+
className: settings_card_module_css_default.headText,
|
|
614
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
615
|
+
className: settings_card_module_css_default.name,
|
|
616
|
+
title,
|
|
617
|
+
children: title
|
|
618
|
+
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
619
|
+
className: settings_card_module_css_default.description,
|
|
620
|
+
title: description,
|
|
621
|
+
children: props.descriptionNode ?? description
|
|
622
|
+
})]
|
|
623
|
+
}), state.dirty ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
624
|
+
className: settings_card_module_css_default.pending,
|
|
625
|
+
title: props.t("settings.unsaved"),
|
|
626
|
+
children: props.t("settings.unsaved")
|
|
627
|
+
}) : null]
|
|
628
|
+
}) : /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("button", {
|
|
629
|
+
type: "button",
|
|
630
|
+
className: settings_card_module_css_default.header,
|
|
631
|
+
"aria-expanded": open,
|
|
632
|
+
"aria-label": `${props.t(open ? "settings.collapse" : "settings.expand")}: ${title}`,
|
|
633
|
+
onClick: () => {
|
|
634
|
+
setOpen(!open);
|
|
635
|
+
},
|
|
636
|
+
children: [
|
|
637
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("span", {
|
|
638
|
+
className: settings_card_module_css_default.headText,
|
|
639
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
640
|
+
className: settings_card_module_css_default.name,
|
|
641
|
+
title,
|
|
642
|
+
children: title
|
|
643
|
+
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
644
|
+
className: settings_card_module_css_default.description,
|
|
645
|
+
title: description,
|
|
646
|
+
children: props.descriptionNode ?? description
|
|
647
|
+
})]
|
|
648
|
+
}),
|
|
649
|
+
state.dirty ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
650
|
+
className: settings_card_module_css_default.pending,
|
|
651
|
+
title: props.t("settings.unsaved"),
|
|
652
|
+
children: props.t("settings.unsaved")
|
|
653
|
+
}) : null,
|
|
654
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("svg", {
|
|
655
|
+
width: "14",
|
|
656
|
+
height: "14",
|
|
657
|
+
viewBox: "0 0 14 14",
|
|
658
|
+
fill: "none",
|
|
659
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
660
|
+
className: open ? `${settings_card_module_css_default.chevron} ${settings_card_module_css_default.chevronOpen}` : settings_card_module_css_default.chevron,
|
|
661
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("path", {
|
|
662
|
+
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",
|
|
663
|
+
fill: "currentColor"
|
|
664
|
+
})
|
|
665
|
+
})
|
|
666
|
+
]
|
|
667
|
+
});
|
|
668
|
+
if (!state.exposed) return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("li", {
|
|
669
|
+
className: cardClass,
|
|
670
|
+
children: [header, expanded ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
671
|
+
className: settings_card_module_css_default.body,
|
|
672
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
|
|
673
|
+
className: settings_card_module_css_default.notExposed,
|
|
674
|
+
role: "status",
|
|
675
|
+
children: props.t("settings.notExposed")
|
|
676
|
+
})
|
|
677
|
+
}) : null]
|
|
678
|
+
});
|
|
679
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("li", {
|
|
680
|
+
className: cardClass,
|
|
681
|
+
children: [header, expanded ? /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
682
|
+
className: settings_card_module_css_default.body,
|
|
683
|
+
children: [
|
|
684
|
+
!state.writable ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
|
|
685
|
+
className: settings_card_module_css_default.readOnly,
|
|
686
|
+
role: "status",
|
|
687
|
+
children: props.t("settings.readOnly")
|
|
688
|
+
}) : null,
|
|
689
|
+
props.children,
|
|
690
|
+
props.hideFooter === true ? null : /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
691
|
+
className: settings_card_module_css_default.footer,
|
|
692
|
+
children: [
|
|
693
|
+
state.failed ? /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("p", {
|
|
694
|
+
className: settings_card_module_css_default.failed,
|
|
695
|
+
role: "status",
|
|
696
|
+
children: [props.t("settings.saveFailed"), state.failedReason ? " - " + state.failedReason : ""]
|
|
697
|
+
}) : null,
|
|
698
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
|
|
699
|
+
type: "button",
|
|
700
|
+
className: settings_card_module_css_default.discard,
|
|
701
|
+
disabled: !state.dirty || state.saving,
|
|
702
|
+
onClick: props.onDiscard,
|
|
703
|
+
children: props.t("settings.discard")
|
|
704
|
+
}),
|
|
705
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
|
|
706
|
+
type: "button",
|
|
707
|
+
className: settings_card_module_css_default.save,
|
|
708
|
+
disabled: blocked,
|
|
709
|
+
onClick: props.onSave,
|
|
710
|
+
children: props.t(!state.saving ? "settings.save" : "settings.saving")
|
|
711
|
+
})
|
|
712
|
+
]
|
|
713
|
+
})
|
|
714
|
+
]
|
|
715
|
+
}) : null]
|
|
716
|
+
});
|
|
717
|
+
}
|
|
718
|
+
const NON_SKIN_BODY_MARKERS = /* @__PURE__ */ new Set(["dshSkinCenter", "dshSidebarCollapsed"]);
|
|
719
|
+
function isSkinActive() {
|
|
720
|
+
return Object.keys(document.body.dataset).some((key) => key.startsWith("dsh") && !NON_SKIN_BODY_MARKERS.has(key));
|
|
721
|
+
}
|
|
722
|
+
const SELECT_CLOSE_MS = 100;
|
|
723
|
+
/**
|
|
724
|
+
* The shared dual-mode select control. While an appearance skin is active it
|
|
725
|
+
* renders the legacy native `<select>` untouched, so element-level skin
|
|
726
|
+
* selectors keep working; under the default appearance it renders a
|
|
727
|
+
* self-drawn `role="listbox"` popup whose open/close is transition-animated.
|
|
728
|
+
* Staged cards reach it through BooleanField/ChoiceField; immediate-apply
|
|
729
|
+
* editors (the side-card prefs) bind it directly through onEdit.
|
|
730
|
+
* 双模式下拉框:皮肤激活时用原生 select,默认外观用自绘动画弹层。
|
|
731
|
+
*/
|
|
732
|
+
function SelectField(props) {
|
|
733
|
+
const { id, options, value } = props;
|
|
734
|
+
const [open, setOpen] = (0, react.useState)(false);
|
|
735
|
+
const [closing, setClosing] = (0, react.useState)(false);
|
|
736
|
+
const [phase, setPhase] = (0, react.useState)("initial");
|
|
737
|
+
const [activeIndex, setActiveIndex] = (0, react.useState)(0);
|
|
738
|
+
const closeTimer = (0, react.useRef)(void 0);
|
|
739
|
+
const wrapRef = (0, react.useRef)(null);
|
|
740
|
+
const popupRef = (0, react.useRef)(null);
|
|
741
|
+
const currentIndex = () => {
|
|
742
|
+
const index = options.findIndex((option) => option.value === value);
|
|
743
|
+
return index >= 0 ? index : 0;
|
|
744
|
+
};
|
|
745
|
+
const close = (0, react.useCallback)(() => {
|
|
746
|
+
if (closeTimer.current !== void 0) clearTimeout(closeTimer.current);
|
|
747
|
+
setClosing(true);
|
|
748
|
+
closeTimer.current = setTimeout(() => {
|
|
749
|
+
setClosing(false);
|
|
750
|
+
setOpen(false);
|
|
751
|
+
}, SELECT_CLOSE_MS);
|
|
752
|
+
}, []);
|
|
753
|
+
const openPopup = () => {
|
|
754
|
+
if (closeTimer.current !== void 0) clearTimeout(closeTimer.current);
|
|
755
|
+
setActiveIndex(currentIndex());
|
|
756
|
+
setPhase("initial");
|
|
757
|
+
setClosing(false);
|
|
758
|
+
setOpen(true);
|
|
759
|
+
};
|
|
760
|
+
const commit = (index) => {
|
|
761
|
+
const option = options[index];
|
|
762
|
+
if (option) props.onEdit(option.value);
|
|
763
|
+
close();
|
|
764
|
+
};
|
|
765
|
+
const onTriggerClick = () => {
|
|
766
|
+
if (props.disabled) return;
|
|
767
|
+
if (open && !closing) close();
|
|
768
|
+
else openPopup();
|
|
769
|
+
};
|
|
770
|
+
const onKeyDown = (event) => {
|
|
771
|
+
if (props.disabled) return;
|
|
772
|
+
const count = options.length;
|
|
773
|
+
switch (event.key) {
|
|
774
|
+
case "ArrowDown":
|
|
775
|
+
case "ArrowUp":
|
|
776
|
+
case "Enter":
|
|
777
|
+
case " ":
|
|
778
|
+
event.preventDefault();
|
|
779
|
+
if (!open) openPopup();
|
|
780
|
+
else if (!closing) if (event.key === "ArrowDown") setActiveIndex((index) => (index + 1) % count);
|
|
781
|
+
else if (event.key === "ArrowUp") setActiveIndex((index) => (index - 1 + count) % count);
|
|
782
|
+
else commit(activeIndex);
|
|
783
|
+
break;
|
|
784
|
+
case "Escape":
|
|
785
|
+
if (open) {
|
|
786
|
+
event.preventDefault();
|
|
787
|
+
event.stopPropagation();
|
|
788
|
+
close();
|
|
789
|
+
}
|
|
790
|
+
break;
|
|
791
|
+
case "Tab":
|
|
792
|
+
if (open) close();
|
|
793
|
+
break;
|
|
794
|
+
}
|
|
795
|
+
};
|
|
796
|
+
(0, react.useEffect)(() => () => {
|
|
797
|
+
if (closeTimer.current !== void 0) clearTimeout(closeTimer.current);
|
|
798
|
+
}, []);
|
|
799
|
+
(0, react.useLayoutEffect)(() => {
|
|
800
|
+
if (open && !closing && phase === "initial") {
|
|
801
|
+
popupRef.current?.offsetHeight;
|
|
802
|
+
setPhase("open");
|
|
803
|
+
}
|
|
804
|
+
}, [
|
|
805
|
+
open,
|
|
806
|
+
closing,
|
|
807
|
+
phase
|
|
808
|
+
]);
|
|
809
|
+
(0, react.useEffect)(() => {
|
|
810
|
+
if (!open) return;
|
|
811
|
+
const onPointerDown = (event) => {
|
|
812
|
+
const target = event.target;
|
|
813
|
+
if (target instanceof Node && !wrapRef.current?.contains(target)) close();
|
|
814
|
+
};
|
|
815
|
+
document.addEventListener("pointerdown", onPointerDown);
|
|
816
|
+
return () => document.removeEventListener("pointerdown", onPointerDown);
|
|
817
|
+
}, [open, close]);
|
|
818
|
+
(0, react.useEffect)(() => {
|
|
819
|
+
if (props.disabled && open) close();
|
|
820
|
+
}, [
|
|
821
|
+
props.disabled,
|
|
822
|
+
open,
|
|
823
|
+
close
|
|
824
|
+
]);
|
|
825
|
+
if (isSkinActive()) return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("select", {
|
|
826
|
+
id,
|
|
827
|
+
className: settings_card_module_css_default.select,
|
|
828
|
+
value,
|
|
829
|
+
disabled: props.disabled,
|
|
830
|
+
onChange: (event) => {
|
|
831
|
+
props.onEdit(event.target.value);
|
|
832
|
+
},
|
|
833
|
+
children: options.map((option) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)("option", {
|
|
834
|
+
value: option.value,
|
|
835
|
+
children: option.label
|
|
836
|
+
}, option.value))
|
|
837
|
+
});
|
|
838
|
+
const label = options.find((option) => option.value === value)?.label ?? "";
|
|
839
|
+
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;
|
|
840
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
841
|
+
className: settings_card_module_css_default.selectWrap,
|
|
842
|
+
ref: wrapRef,
|
|
843
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("button", {
|
|
844
|
+
type: "button",
|
|
845
|
+
id,
|
|
846
|
+
className: `${settings_card_module_css_default.select} ${settings_card_module_css_default.selectButton}`,
|
|
847
|
+
disabled: props.disabled,
|
|
848
|
+
"aria-haspopup": "listbox",
|
|
849
|
+
"aria-expanded": open,
|
|
850
|
+
"aria-activedescendant": open ? `${id}-o${activeIndex}` : void 0,
|
|
851
|
+
"aria-invalid": props.invalid || void 0,
|
|
852
|
+
onClick: onTriggerClick,
|
|
853
|
+
onKeyDown,
|
|
854
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
855
|
+
className: settings_card_module_css_default.selectLabel,
|
|
856
|
+
children: label
|
|
857
|
+
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("svg", {
|
|
858
|
+
width: "14",
|
|
859
|
+
height: "14",
|
|
860
|
+
viewBox: "0 0 14 14",
|
|
861
|
+
fill: "none",
|
|
862
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
863
|
+
className: open ? `${settings_card_module_css_default.selectChevron} ${settings_card_module_css_default.selectChevronOpen}` : settings_card_module_css_default.selectChevron,
|
|
864
|
+
"aria-hidden": "true",
|
|
865
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("path", {
|
|
866
|
+
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",
|
|
867
|
+
fill: "currentColor"
|
|
868
|
+
})
|
|
869
|
+
})]
|
|
870
|
+
}), open ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
871
|
+
className: popupClass,
|
|
872
|
+
role: "listbox",
|
|
873
|
+
ref: popupRef,
|
|
874
|
+
children: options.map((option, index) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
875
|
+
id: `${id}-o${index}`,
|
|
876
|
+
role: "option",
|
|
877
|
+
"aria-selected": option.value === value,
|
|
878
|
+
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}` : ""}`,
|
|
879
|
+
onClick: () => {
|
|
880
|
+
commit(index);
|
|
881
|
+
},
|
|
882
|
+
children: option.label
|
|
883
|
+
}, option.value))
|
|
884
|
+
}) : null]
|
|
885
|
+
});
|
|
886
|
+
}
|
|
887
|
+
/** A staged boolean field: 继承 / 开 / 关. */
|
|
888
|
+
function BooleanField(props) {
|
|
889
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
890
|
+
className: settings_card_module_css_default.field,
|
|
891
|
+
children: [
|
|
892
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
893
|
+
className: settings_card_module_css_default.head,
|
|
894
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("label", {
|
|
895
|
+
className: settings_card_module_css_default.label,
|
|
896
|
+
htmlFor: props.id,
|
|
897
|
+
children: props.label
|
|
898
|
+
}), props.overridden ? /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("span", {
|
|
899
|
+
className: settings_card_module_css_default.badges,
|
|
900
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
901
|
+
className: settings_card_module_css_default.badge,
|
|
902
|
+
children: props.overriddenLabel
|
|
903
|
+
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
|
|
904
|
+
type: "button",
|
|
905
|
+
className: settings_card_module_css_default.reset,
|
|
906
|
+
disabled: props.disabled,
|
|
907
|
+
onClick: props.onReset,
|
|
908
|
+
children: props.resetLabel
|
|
909
|
+
})]
|
|
910
|
+
}) : null]
|
|
911
|
+
}),
|
|
912
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)(SelectField, {
|
|
913
|
+
id: props.id,
|
|
914
|
+
options: [
|
|
915
|
+
{
|
|
916
|
+
value: "",
|
|
917
|
+
label: props.inheritLabel
|
|
918
|
+
},
|
|
919
|
+
{
|
|
920
|
+
value: "true",
|
|
921
|
+
label: props.onLabel
|
|
922
|
+
},
|
|
923
|
+
{
|
|
924
|
+
value: "false",
|
|
925
|
+
label: props.offLabel
|
|
926
|
+
}
|
|
927
|
+
],
|
|
928
|
+
value: props.text,
|
|
929
|
+
disabled: props.disabled,
|
|
930
|
+
invalid: props.invalid,
|
|
931
|
+
onEdit: props.onEdit
|
|
932
|
+
}),
|
|
933
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
|
|
934
|
+
className: settings_card_module_css_default.hint,
|
|
935
|
+
children: props.hint
|
|
936
|
+
})
|
|
937
|
+
]
|
|
938
|
+
});
|
|
939
|
+
}
|
|
940
|
+
/** A staged enumerated field rendered as a select. */
|
|
941
|
+
function ChoiceField(props) {
|
|
942
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
943
|
+
className: settings_card_module_css_default.field,
|
|
944
|
+
children: [
|
|
945
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
946
|
+
className: settings_card_module_css_default.head,
|
|
947
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("label", {
|
|
948
|
+
className: settings_card_module_css_default.label,
|
|
949
|
+
htmlFor: props.id,
|
|
950
|
+
children: props.label
|
|
951
|
+
}), props.overridden ? /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("span", {
|
|
952
|
+
className: settings_card_module_css_default.badges,
|
|
953
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
954
|
+
className: settings_card_module_css_default.badge,
|
|
955
|
+
children: props.overriddenLabel
|
|
956
|
+
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
|
|
957
|
+
type: "button",
|
|
958
|
+
className: settings_card_module_css_default.reset,
|
|
959
|
+
disabled: props.disabled,
|
|
960
|
+
onClick: props.onReset,
|
|
961
|
+
children: props.resetLabel
|
|
962
|
+
})]
|
|
963
|
+
}) : null]
|
|
964
|
+
}),
|
|
965
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)(SelectField, {
|
|
966
|
+
id: props.id,
|
|
967
|
+
options: [{
|
|
968
|
+
value: "",
|
|
969
|
+
label: props.inheritLabel
|
|
970
|
+
}, ...props.choices],
|
|
971
|
+
value: props.text,
|
|
972
|
+
disabled: props.disabled,
|
|
973
|
+
invalid: props.invalid,
|
|
974
|
+
onEdit: props.onEdit
|
|
975
|
+
}),
|
|
976
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
|
|
977
|
+
className: props.invalid ? settings_card_module_css_default.invalid : settings_card_module_css_default.hint,
|
|
978
|
+
children: props.invalid ? props.invalidLabel : props.hint
|
|
979
|
+
})
|
|
980
|
+
]
|
|
981
|
+
});
|
|
982
|
+
}
|
|
983
|
+
//#endregion
|
|
984
|
+
//#region src/client/settings-form.ts
|
|
985
|
+
/** A boolean field, edited through true/false draft text. */
|
|
986
|
+
function booleanField(field) {
|
|
987
|
+
return {
|
|
988
|
+
field,
|
|
989
|
+
format: (value) => typeof value === "boolean" ? String(value) : "",
|
|
990
|
+
parse: (text) => {
|
|
991
|
+
const trimmed = text.trim();
|
|
992
|
+
if (trimmed === "") return { kind: "clear" };
|
|
993
|
+
if (trimmed === "true") return {
|
|
994
|
+
kind: "set",
|
|
995
|
+
value: true
|
|
996
|
+
};
|
|
997
|
+
if (trimmed === "false") return {
|
|
998
|
+
kind: "set",
|
|
999
|
+
value: false
|
|
1000
|
+
};
|
|
1001
|
+
}
|
|
1002
|
+
};
|
|
1003
|
+
}
|
|
1004
|
+
/** An enumerated string field; only the listed choices are accepted. An empty draft clears the field. */
|
|
1005
|
+
function choiceField(field, choices) {
|
|
1006
|
+
return {
|
|
1007
|
+
field,
|
|
1008
|
+
format: (value) => typeof value === "string" && choices.includes(value) ? value : "",
|
|
1009
|
+
parse: (text) => {
|
|
1010
|
+
if (text === "") return { kind: "clear" };
|
|
1011
|
+
return choices.includes(text) ? {
|
|
1012
|
+
kind: "set",
|
|
1013
|
+
value: text
|
|
1014
|
+
} : void 0;
|
|
1015
|
+
}
|
|
1016
|
+
};
|
|
1017
|
+
}
|
|
1018
|
+
/**
|
|
1019
|
+
* Stages one card's edits over one settings namespace and writes them on save.
|
|
1020
|
+
*
|
|
1021
|
+
* The Host is the only authority on whether a value was accepted — its
|
|
1022
|
+
* validators own the constraints no schema can express — so the outcome is
|
|
1023
|
+
* read back from the section rather than predicted here. A save that did not
|
|
1024
|
+
* land keeps its drafts, so the user can correct them instead of retyping.
|
|
1025
|
+
*/
|
|
1026
|
+
var CardForm = class {
|
|
1027
|
+
scope;
|
|
1028
|
+
specs;
|
|
1029
|
+
staged = /* @__PURE__ */ new Map();
|
|
1030
|
+
listeners = /* @__PURE__ */ new Set();
|
|
1031
|
+
/** The scope subscription installed in the constructor; released by dispose(). */
|
|
1032
|
+
disposeScope;
|
|
1033
|
+
disposed = false;
|
|
1034
|
+
saving = false;
|
|
1035
|
+
failed = false;
|
|
1036
|
+
failedReason;
|
|
1037
|
+
/** @param scope - the bound settings scope for this card's namespace. */
|
|
1038
|
+
constructor(scope, specs) {
|
|
1039
|
+
this.scope = scope;
|
|
1040
|
+
this.specs = new Map(specs.map((spec) => [spec.field, spec]));
|
|
1041
|
+
this.disposeScope = scope.subscribe(() => {
|
|
1042
|
+
this.publish();
|
|
1043
|
+
});
|
|
1044
|
+
}
|
|
1045
|
+
/**
|
|
1046
|
+
* Release the scope subscription and every bound store listener. The card
|
|
1047
|
+
* must call this on teardown; later calls are no-ops.
|
|
1048
|
+
*/
|
|
1049
|
+
dispose() {
|
|
1050
|
+
if (this.disposed) return;
|
|
1051
|
+
this.disposed = true;
|
|
1052
|
+
this.disposeScope();
|
|
1053
|
+
this.listeners.clear();
|
|
1054
|
+
}
|
|
1055
|
+
/** Publish a projection of this form, rebuilt whenever the scope or a draft changes. */
|
|
1056
|
+
bind(project) {
|
|
1057
|
+
const store = createSnapshotStore(project());
|
|
1058
|
+
this.listeners.add(() => {
|
|
1059
|
+
store.set(project());
|
|
1060
|
+
});
|
|
1061
|
+
return store;
|
|
1062
|
+
}
|
|
1063
|
+
/** Read the card-level state: what the Host serves, and what a save would do. */
|
|
1064
|
+
shell() {
|
|
1065
|
+
const snapshot = this.scope.getSnapshot();
|
|
1066
|
+
const plan = this.plan();
|
|
1067
|
+
return {
|
|
1068
|
+
available: snapshot.status !== "loading",
|
|
1069
|
+
exposed: snapshot.status === "ready",
|
|
1070
|
+
writable: snapshot.writable,
|
|
1071
|
+
dirty: plan.length > 0,
|
|
1072
|
+
invalid: plan.some((item) => item.judge === void 0),
|
|
1073
|
+
saving: this.saving,
|
|
1074
|
+
failed: this.failed,
|
|
1075
|
+
...this.failedReason === void 0 ? {} : { failedReason: this.failedReason }
|
|
1076
|
+
};
|
|
1077
|
+
}
|
|
1078
|
+
/** Read one field's state from the effective section and its staged draft. */
|
|
1079
|
+
field(field) {
|
|
1080
|
+
const spec = this.specOf(field);
|
|
1081
|
+
const staged = this.staged.get(field);
|
|
1082
|
+
if (staged === void 0) return {
|
|
1083
|
+
text: spec.format(this.sectionValue(field)),
|
|
1084
|
+
overridden: this.stored(field),
|
|
1085
|
+
invalid: false
|
|
1086
|
+
};
|
|
1087
|
+
const write = staged.clear ? { kind: "clear" } : spec.parse(staged.text);
|
|
1088
|
+
return {
|
|
1089
|
+
text: staged.text,
|
|
1090
|
+
overridden: write?.kind === "set",
|
|
1091
|
+
invalid: write === void 0
|
|
1092
|
+
};
|
|
1093
|
+
}
|
|
1094
|
+
/** The actions the card's slot registration injects. */
|
|
1095
|
+
actions() {
|
|
1096
|
+
return {
|
|
1097
|
+
edit: (field, text) => {
|
|
1098
|
+
this.stage(field, {
|
|
1099
|
+
text,
|
|
1100
|
+
clear: false
|
|
1101
|
+
});
|
|
1102
|
+
},
|
|
1103
|
+
resetField: (field) => {
|
|
1104
|
+
this.stage(field, {
|
|
1105
|
+
text: this.specOf(field).format(this.baseValue(field)),
|
|
1106
|
+
clear: true
|
|
1107
|
+
});
|
|
1108
|
+
},
|
|
1109
|
+
save: () => {
|
|
1110
|
+
this.save();
|
|
1111
|
+
},
|
|
1112
|
+
discard: () => {
|
|
1113
|
+
if (this.staged.size === 0 && !this.failed) return;
|
|
1114
|
+
this.staged.clear();
|
|
1115
|
+
this.failed = false;
|
|
1116
|
+
this.failedReason = void 0;
|
|
1117
|
+
this.publish();
|
|
1118
|
+
}
|
|
1119
|
+
};
|
|
1120
|
+
}
|
|
1121
|
+
/**
|
|
1122
|
+
* Write every staged edit in one atomic scope mutation, then re-seed from
|
|
1123
|
+
* what the Host accepted.
|
|
1124
|
+
*
|
|
1125
|
+
* The whole batch rides one mutate, so cross-field validate hooks
|
|
1126
|
+
* (baseURL+model) judge it as a unit: the Host either applies every write
|
|
1127
|
+
* or refuses the batch. The 0.1.2 scope contract never rejects a refused
|
|
1128
|
+
* mutation — the scope recovers with a fresh Host view and resolves — so
|
|
1129
|
+
* resolution alone proves nothing: the outcome is judged by reading the
|
|
1130
|
+
* settled snapshot back, one planned write at a time, and one missed write
|
|
1131
|
+
* fails the whole save. A scope that still rejects on refusal (the dsh-web
|
|
1132
|
+
* bridge scope) reports through the same failure path with its rejection
|
|
1133
|
+
* message. A save that did not land keeps its drafts, so the user can
|
|
1134
|
+
* correct them instead of retyping.
|
|
1135
|
+
* @returns settlement after the mutation and the read-back.
|
|
1136
|
+
*/
|
|
1137
|
+
async save() {
|
|
1138
|
+
const plan = this.plan();
|
|
1139
|
+
const valid = plan.filter((item) => item.judge !== void 0);
|
|
1140
|
+
if (plan.length === 0 || this.saving || valid.length !== plan.length) return;
|
|
1141
|
+
const pending = /* @__PURE__ */ new Map();
|
|
1142
|
+
for (const item of plan) pending.set(item.field, this.staged.get(item.field));
|
|
1143
|
+
this.saving = true;
|
|
1144
|
+
this.failed = false;
|
|
1145
|
+
this.failedReason = void 0;
|
|
1146
|
+
this.publish();
|
|
1147
|
+
const ops = valid.map((item) => item.op.op === "set" ? {
|
|
1148
|
+
op: "set",
|
|
1149
|
+
path: [item.field],
|
|
1150
|
+
value: item.op.value
|
|
1151
|
+
} : {
|
|
1152
|
+
op: "unset",
|
|
1153
|
+
path: [item.field]
|
|
1154
|
+
});
|
|
1155
|
+
let failedReason;
|
|
1156
|
+
try {
|
|
1157
|
+
await this.scope.mutate(ops);
|
|
1158
|
+
} catch (error) {
|
|
1159
|
+
failedReason = error instanceof Error ? error.message : String(error);
|
|
1160
|
+
}
|
|
1161
|
+
const landed = failedReason === void 0 && valid.every((item) => item.judge());
|
|
1162
|
+
for (const [field, before] of pending) if (landed && this.staged.get(field) === before) this.staged.delete(field);
|
|
1163
|
+
this.saving = false;
|
|
1164
|
+
this.failed = !landed;
|
|
1165
|
+
this.failedReason = failedReason;
|
|
1166
|
+
this.publish();
|
|
1167
|
+
}
|
|
1168
|
+
/**
|
|
1169
|
+
* Every staged edit a save would write. An entry whose draft is not a value
|
|
1170
|
+
* its field accepts carries no write: the form is still dirty, and the save
|
|
1171
|
+
* refuses rather than dropping the edit. A staged edit that matches the
|
|
1172
|
+
* effective section is not a write at all.
|
|
1173
|
+
* @returns the planned writes, in the order the fields were staged.
|
|
1174
|
+
*/
|
|
1175
|
+
plan() {
|
|
1176
|
+
const plan = [];
|
|
1177
|
+
for (const [field, staged] of this.staged) {
|
|
1178
|
+
const spec = this.specOf(field);
|
|
1179
|
+
if (staged.clear) {
|
|
1180
|
+
if (this.stored(field)) plan.push({
|
|
1181
|
+
field,
|
|
1182
|
+
op: {
|
|
1183
|
+
field,
|
|
1184
|
+
op: "unset"
|
|
1185
|
+
},
|
|
1186
|
+
judge: () => this.landedUnset(field)
|
|
1187
|
+
});
|
|
1188
|
+
continue;
|
|
1189
|
+
}
|
|
1190
|
+
if (staged.text === spec.format(this.sectionValue(field))) continue;
|
|
1191
|
+
const write = spec.parse(staged.text);
|
|
1192
|
+
if (write === void 0) plan.push({
|
|
1193
|
+
field,
|
|
1194
|
+
op: {
|
|
1195
|
+
field,
|
|
1196
|
+
op: "unset"
|
|
1197
|
+
},
|
|
1198
|
+
judge: void 0
|
|
1199
|
+
});
|
|
1200
|
+
else if (write.kind === "clear") plan.push({
|
|
1201
|
+
field,
|
|
1202
|
+
op: {
|
|
1203
|
+
field,
|
|
1204
|
+
op: "unset"
|
|
1205
|
+
},
|
|
1206
|
+
judge: () => this.landedUnset(field)
|
|
1207
|
+
});
|
|
1208
|
+
else plan.push({
|
|
1209
|
+
field,
|
|
1210
|
+
op: {
|
|
1211
|
+
field,
|
|
1212
|
+
op: "set",
|
|
1213
|
+
value: write.value
|
|
1214
|
+
},
|
|
1215
|
+
judge: () => this.landedSet(field, write.value)
|
|
1216
|
+
});
|
|
1217
|
+
}
|
|
1218
|
+
return plan;
|
|
1219
|
+
}
|
|
1220
|
+
/**
|
|
1221
|
+
* Read-back judgment for a planned set: the user layer must hold the
|
|
1222
|
+
* intended value once the mutation has settled.
|
|
1223
|
+
*/
|
|
1224
|
+
landedSet(field, value) {
|
|
1225
|
+
if (this.specOf(field).secret) return true;
|
|
1226
|
+
return this.userLayer()?.[field] === value;
|
|
1227
|
+
}
|
|
1228
|
+
/**
|
|
1229
|
+
* Read-back judgment for a planned unset: the field must be gone from the
|
|
1230
|
+
* user layer once the mutation has settled.
|
|
1231
|
+
*/
|
|
1232
|
+
landedUnset(field) {
|
|
1233
|
+
return !this.stored(field);
|
|
1234
|
+
}
|
|
1235
|
+
stage(field, edit) {
|
|
1236
|
+
this.staged.set(field, edit);
|
|
1237
|
+
this.failed = false;
|
|
1238
|
+
this.failedReason = void 0;
|
|
1239
|
+
this.publish();
|
|
1240
|
+
}
|
|
1241
|
+
specOf(field) {
|
|
1242
|
+
const spec = this.specs.get(field);
|
|
1243
|
+
if (spec === void 0) throw new Error(`settings card has no field ${field}`);
|
|
1244
|
+
return spec;
|
|
1245
|
+
}
|
|
1246
|
+
snapshotOf() {
|
|
1247
|
+
return this.scope.getSnapshot();
|
|
1248
|
+
}
|
|
1249
|
+
sectionValue(field) {
|
|
1250
|
+
return this.snapshotOf().value?.[field];
|
|
1251
|
+
}
|
|
1252
|
+
baseValue(field) {
|
|
1253
|
+
return this.snapshotOf().base?.[field];
|
|
1254
|
+
}
|
|
1255
|
+
userLayer() {
|
|
1256
|
+
return this.snapshotOf().user;
|
|
1257
|
+
}
|
|
1258
|
+
stored(field) {
|
|
1259
|
+
const user = this.userLayer();
|
|
1260
|
+
return user !== void 0 && Object.hasOwn(user, field);
|
|
1261
|
+
}
|
|
1262
|
+
publish() {
|
|
1263
|
+
for (const listener of this.listeners) listener();
|
|
1264
|
+
}
|
|
1265
|
+
};
|
|
1266
|
+
//#endregion
|
|
1267
|
+
//#region src/client/LiangShenSettingsCard.tsx
|
|
1268
|
+
/** Wire presentations the tool catalog accepts (mirrors the Host schema). */
|
|
1269
|
+
const PRESENTATION_CHOICES = [
|
|
1270
|
+
"ptc",
|
|
1271
|
+
"native",
|
|
1272
|
+
"both"
|
|
1273
|
+
];
|
|
1274
|
+
/** Bridges the `dsh-liangshen` scope onto the card's staged form. */
|
|
1275
|
+
var LiangShenSettingsCardController = class {
|
|
1276
|
+
form;
|
|
1277
|
+
store;
|
|
1278
|
+
/** @param scope - the bound settings scope for the `dsh-liangshen` namespace. */
|
|
1279
|
+
constructor(scope) {
|
|
1280
|
+
this.form = new CardForm(scope, [
|
|
1281
|
+
booleanField("enabled"),
|
|
1282
|
+
booleanField("announceToAgent"),
|
|
1283
|
+
choiceField("presentation", PRESENTATION_CHOICES)
|
|
1284
|
+
]);
|
|
1285
|
+
this.store = this.form.bind(() => this.projection());
|
|
1286
|
+
}
|
|
1287
|
+
projection() {
|
|
1288
|
+
return {
|
|
1289
|
+
...this.form.shell(),
|
|
1290
|
+
enabled: this.form.field("enabled"),
|
|
1291
|
+
announceToAgent: this.form.field("announceToAgent"),
|
|
1292
|
+
presentation: this.form.field("presentation")
|
|
1293
|
+
};
|
|
1294
|
+
}
|
|
1295
|
+
/**
|
|
1296
|
+
* Build the face the card's slot registration injects.
|
|
1297
|
+
* @returns the card's snapshot and its form actions.
|
|
1298
|
+
*/
|
|
1299
|
+
inject() {
|
|
1300
|
+
return {
|
|
1301
|
+
hooks: { liangShenSettingsCard: this.store },
|
|
1302
|
+
...this.form.actions()
|
|
1303
|
+
};
|
|
1304
|
+
}
|
|
1305
|
+
/** Release the card's scope subscription and bound stores. */
|
|
1306
|
+
dispose() {
|
|
1307
|
+
this.form.dispose();
|
|
1308
|
+
}
|
|
1309
|
+
};
|
|
1310
|
+
/**
|
|
1311
|
+
* Render the LiangShen card.
|
|
1312
|
+
* @param props - locale copy, the card snapshot, and its form actions.
|
|
1313
|
+
* @returns the card.
|
|
1314
|
+
*/
|
|
1315
|
+
function LiangShenSettingsCard(props) {
|
|
1316
|
+
const { t } = props;
|
|
1317
|
+
const state = props.useLiangShenSettingsCard((snapshot) => snapshot);
|
|
1318
|
+
const fieldProps = {
|
|
1319
|
+
overriddenLabel: t("settings.overridden"),
|
|
1320
|
+
resetLabel: t("settings.reset"),
|
|
1321
|
+
invalidLabel: t("settings.invalidValue"),
|
|
1322
|
+
disabled: !state.writable,
|
|
1323
|
+
inheritLabel: t("settings.inherit")
|
|
1324
|
+
};
|
|
1325
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(PluginSettingsCard, {
|
|
1326
|
+
t,
|
|
1327
|
+
titleKey: "settings.title",
|
|
1328
|
+
descriptionKey: "settings.description",
|
|
1329
|
+
defaultOpen: false,
|
|
1330
|
+
state,
|
|
1331
|
+
onSave: props.save,
|
|
1332
|
+
onDiscard: props.discard,
|
|
1333
|
+
children: [
|
|
1334
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)(BooleanField, {
|
|
1335
|
+
id: "settings-liangshen-enabled",
|
|
1336
|
+
label: t("settings.enabled"),
|
|
1337
|
+
hint: t("settings.enabledHint"),
|
|
1338
|
+
onLabel: t("settings.on"),
|
|
1339
|
+
offLabel: t("settings.off"),
|
|
1340
|
+
...fieldProps,
|
|
1341
|
+
...state.enabled,
|
|
1342
|
+
onEdit: (text) => {
|
|
1343
|
+
props.edit("enabled", text);
|
|
1344
|
+
},
|
|
1345
|
+
onReset: () => {
|
|
1346
|
+
props.resetField("enabled");
|
|
1347
|
+
}
|
|
1348
|
+
}),
|
|
1349
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)(BooleanField, {
|
|
1350
|
+
id: "settings-liangshen-announce",
|
|
1351
|
+
label: t("settings.announceToAgent"),
|
|
1352
|
+
hint: t("settings.announceToAgentHint"),
|
|
1353
|
+
onLabel: t("settings.on"),
|
|
1354
|
+
offLabel: t("settings.off"),
|
|
1355
|
+
...fieldProps,
|
|
1356
|
+
...state.announceToAgent,
|
|
1357
|
+
onEdit: (text) => {
|
|
1358
|
+
props.edit("announceToAgent", text);
|
|
1359
|
+
},
|
|
1360
|
+
onReset: () => {
|
|
1361
|
+
props.resetField("announceToAgent");
|
|
1362
|
+
}
|
|
1363
|
+
}),
|
|
1364
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)(ChoiceField, {
|
|
1365
|
+
id: "settings-liangshen-presentation",
|
|
1366
|
+
label: t("settings.presentation"),
|
|
1367
|
+
hint: t("settings.presentationHint"),
|
|
1368
|
+
choices: PRESENTATION_CHOICES.map((choice) => ({
|
|
1369
|
+
value: choice,
|
|
1370
|
+
label: t(`presentation.${choice}`)
|
|
1371
|
+
})),
|
|
1372
|
+
...fieldProps,
|
|
1373
|
+
...state.presentation,
|
|
1374
|
+
onEdit: (text) => {
|
|
1375
|
+
props.edit("presentation", text);
|
|
1376
|
+
},
|
|
1377
|
+
onReset: () => {
|
|
1378
|
+
props.resetField("presentation");
|
|
1379
|
+
}
|
|
1380
|
+
})
|
|
1381
|
+
]
|
|
1382
|
+
});
|
|
1383
|
+
}
|
|
1384
|
+
//#endregion
|
|
531
1385
|
//#region src/client/locales.ts
|
|
532
1386
|
/**
|
|
533
1387
|
* Lever copy: zh-first dictionary with an English counterpart. The zh side is
|
|
@@ -550,7 +1404,33 @@ window.__ModuleLoader__.load({
|
|
|
550
1404
|
"lever.failed.timeout": "切换超时,请重试",
|
|
551
1405
|
"lever.failed.failed": "切换失败:{reason}",
|
|
552
1406
|
"burst.line1": "三秒,三辈子的代码",
|
|
553
|
-
"burst.line2": "文言文 · 二进制 · 摩斯电码"
|
|
1407
|
+
"burst.line2": "文言文 · 二进制 · 摩斯电码",
|
|
1408
|
+
"settings.title": "梁神模式",
|
|
1409
|
+
"settings.description": "控制本插件与工具面呈现方式。",
|
|
1410
|
+
"settings.enabled": "启用梁神模式",
|
|
1411
|
+
"settings.enabledHint": "关闭后预设同步与 agent 公告都不执行。",
|
|
1412
|
+
"settings.announceToAgent": "向 agent 公告本插件",
|
|
1413
|
+
"settings.announceToAgentHint": "开启后向每一轮 agent 系统提示注入本插件公告;默认关闭以保持提示词干净。",
|
|
1414
|
+
"settings.presentation": "工具面呈现方式",
|
|
1415
|
+
"settings.presentationHint": "写入同步后的预设:ptc 把 wire 收拢为 run_code;native 保持原生工具清单;both 让两者同驻。改动需重启 DSH 生效。",
|
|
1416
|
+
"settings.on": "开",
|
|
1417
|
+
"settings.off": "关",
|
|
1418
|
+
"settings.inherit": "继承(跟随部署默认)",
|
|
1419
|
+
"settings.overridden": "已覆盖",
|
|
1420
|
+
"settings.reset": "重置",
|
|
1421
|
+
"settings.notExposed": "当前 DSH 版本未向设置页暴露本插件的配置命名空间,表单不可用。可编辑 ~/.dsh/settings.yaml 直接配置,或将本命名空间加入 Host 设置白名单后重启。",
|
|
1422
|
+
"settings.readOnly": "当前部署的设置只读。",
|
|
1423
|
+
"settings.expand": "展开设置",
|
|
1424
|
+
"settings.collapse": "收起设置",
|
|
1425
|
+
"settings.save": "保存",
|
|
1426
|
+
"settings.saving": "保存中…",
|
|
1427
|
+
"settings.discard": "放弃",
|
|
1428
|
+
"settings.unsaved": "未保存",
|
|
1429
|
+
"settings.saveFailed": "部署未接受这些值,已保留供你修改。",
|
|
1430
|
+
"settings.invalidValue": "该取值不被接受",
|
|
1431
|
+
"presentation.ptc": "ptc(仅 run_code)",
|
|
1432
|
+
"presentation.native": "native(原生工具清单)",
|
|
1433
|
+
"presentation.both": "both(两者同驻)"
|
|
554
1434
|
};
|
|
555
1435
|
/** English counterpart; the key set mirrors {@link zh} exactly. */
|
|
556
1436
|
const en = {
|
|
@@ -568,12 +1448,163 @@ window.__ModuleLoader__.load({
|
|
|
568
1448
|
"lever.failed.timeout": "The switch timed out; try again",
|
|
569
1449
|
"lever.failed.failed": "Switch failed: {reason}",
|
|
570
1450
|
"burst.line1": "Three seconds, three lifetimes of code",
|
|
571
|
-
"burst.line2": "Classical Chinese · Binary · Morse code"
|
|
1451
|
+
"burst.line2": "Classical Chinese · Binary · Morse code",
|
|
1452
|
+
"settings.title": "LiangShen mode",
|
|
1453
|
+
"settings.description": "Controls this plugin and the wire presentation.",
|
|
1454
|
+
"settings.enabled": "Enable LiangShen mode",
|
|
1455
|
+
"settings.enabledHint": "When off, neither preset sync nor the agent announcement runs.",
|
|
1456
|
+
"settings.announceToAgent": "Announce this plugin to agents",
|
|
1457
|
+
"settings.announceToAgentHint": "Adds this plugin announcement to every agent system prompt; off by default so prompts stay clean.",
|
|
1458
|
+
"settings.presentation": "Wire presentation",
|
|
1459
|
+
"settings.presentationHint": "Written into the synced preset: ptc collapses the wire to run_code; native keeps the native roster; both keeps them co-resident. Restart DSH for a change to take effect.",
|
|
1460
|
+
"settings.on": "On",
|
|
1461
|
+
"settings.off": "Off",
|
|
1462
|
+
"settings.inherit": "Inherit (deployment default)",
|
|
1463
|
+
"settings.overridden": "Overridden",
|
|
1464
|
+
"settings.reset": "Reset",
|
|
1465
|
+
"settings.notExposed": "This DSH version does not expose this plugin's settings namespace to the configuration page, so the form is unavailable. Edit ~/.dsh/settings.yaml directly, or add the namespace to the Host settings allowlist and restart.",
|
|
1466
|
+
"settings.readOnly": "This deployment serves settings read-only.",
|
|
1467
|
+
"settings.expand": "Show settings",
|
|
1468
|
+
"settings.collapse": "Hide settings",
|
|
1469
|
+
"settings.save": "Save",
|
|
1470
|
+
"settings.saving": "Saving…",
|
|
1471
|
+
"settings.discard": "Discard",
|
|
1472
|
+
"settings.unsaved": "Unsaved",
|
|
1473
|
+
"settings.saveFailed": "The deployment did not accept these values; they were left for you to correct.",
|
|
1474
|
+
"settings.invalidValue": "The value is not accepted",
|
|
1475
|
+
"presentation.ptc": "ptc (run_code only)",
|
|
1476
|
+
"presentation.native": "native (native tool roster)",
|
|
1477
|
+
"presentation.both": "both (both co-resident)"
|
|
572
1478
|
};
|
|
573
1479
|
//#endregion
|
|
1480
|
+
//#region src/client/plugin-card-seat.ts
|
|
1481
|
+
/**
|
|
1482
|
+
* Family plugin-card seat.
|
|
1483
|
+
*
|
|
1484
|
+
* A family plugin contributes its settings card to whichever plugin-card seat
|
|
1485
|
+
* the running host actually renders:
|
|
1486
|
+
*
|
|
1487
|
+
* - `web-ui.plugin.item` — the list seat declared by the dsh-web-settings
|
|
1488
|
+
* group section (this family's own first-level "Web UI plugins" section);
|
|
1489
|
+
* - `settings.plugin.item` — the official keyed seat of the harness's
|
|
1490
|
+
* `ui-settings-plugins` tab, keyed by the settings namespace the card edits.
|
|
1491
|
+
*
|
|
1492
|
+
* SEAT SELECTION IS NOT A DECLARATION PROBE. The official `ui-settings-plugins`
|
|
1493
|
+
* row belongs to the harness bundle and its `configurable` tab always declares
|
|
1494
|
+
* `settings.plugin.item` before any external plugin's `apply()` runs, so
|
|
1495
|
+
* "is the official seat declared?" answers yes even in the deployment whose
|
|
1496
|
+
* whole point is the family group. Choosing on that probe sends every family
|
|
1497
|
+
* card to the official Plugins tab and leaves the group's own section
|
|
1498
|
+
* permanently empty — the family of reports where the section renders its
|
|
1499
|
+
* heading and zero cards.
|
|
1500
|
+
*
|
|
1501
|
+
* The signal that actually distinguishes the two deployments is whether
|
|
1502
|
+
* dsh-web-settings is loaded: it is the package that owns the group section and
|
|
1503
|
+
* it publishes the `webUiSettings` service during `apply()`, which every
|
|
1504
|
+
* family plugin already reads for its settings scope. Group loaded -> the family
|
|
1505
|
+
* seat; group absent -> the official seat.
|
|
1506
|
+
*
|
|
1507
|
+
* The decision is re-evaluated on every `slots/changed` because the group may
|
|
1508
|
+
* apply after this plugin (the family aggregate orders it first, a profile that
|
|
1509
|
+
* installs the group separately need not): the initial contribution goes to the
|
|
1510
|
+
* official seat, then moves to the family seat the moment the group's section
|
|
1511
|
+
* registers. The entry is disposed before the replacement is registered, so a
|
|
1512
|
+
* card is never in two seats at once.
|
|
1513
|
+
*
|
|
1514
|
+
* The shared tree has no client-SDK dependency, so this module reads its
|
|
1515
|
+
* context through the structural shape below; callers pass the plugin's own
|
|
1516
|
+
* `ctx`.
|
|
1517
|
+
*/
|
|
1518
|
+
/** The family list seat key. */
|
|
1519
|
+
const FAMILY_PLUGIN_CARD_SEAT = "web-ui.plugin.item";
|
|
1520
|
+
/** The official keyed plugin-card seat key. */
|
|
1521
|
+
const OFFICIAL_PLUGIN_CARD_SEAT = "settings.plugin.item";
|
|
1522
|
+
/** The service dsh-web-settings publishes while it is loaded. */
|
|
1523
|
+
const FAMILY_GROUP_SERVICE = "webUiSettings";
|
|
1524
|
+
/**
|
|
1525
|
+
* Whether the family group (dsh-web-settings) is loaded in this page. The
|
|
1526
|
+
* service is the group package's own contract, so the probe cannot be fooled
|
|
1527
|
+
* by a harness release that starts declaring the official seat differently.
|
|
1528
|
+
*/
|
|
1529
|
+
function familyGroupLoaded(ctx) {
|
|
1530
|
+
const get = ctx.get;
|
|
1531
|
+
if (typeof get !== "function") return false;
|
|
1532
|
+
try {
|
|
1533
|
+
return get.call(ctx, FAMILY_GROUP_SERVICE) !== void 0;
|
|
1534
|
+
} catch {
|
|
1535
|
+
return false;
|
|
1536
|
+
}
|
|
1537
|
+
}
|
|
1538
|
+
/** Report a refused registration instead of leaving the user with no card. */
|
|
1539
|
+
function warnRefusedSeat(seat, error) {
|
|
1540
|
+
try {
|
|
1541
|
+
console.warn(`[dsh-web] plugin card registration into "${seat}" was refused; the card will not render`, error);
|
|
1542
|
+
} catch {}
|
|
1543
|
+
}
|
|
1544
|
+
/**
|
|
1545
|
+
* Contribute one family plugin card to the seat this host renders, following
|
|
1546
|
+
* the group if it loads later. The entry is disposed and re-registered on a
|
|
1547
|
+
* seat change, never duplicated.
|
|
1548
|
+
* @param ctx - client context (its slot registry decides the seat).
|
|
1549
|
+
* @param seat - the card contribution.
|
|
1550
|
+
*/
|
|
1551
|
+
function installPluginCard(ctx, seat) {
|
|
1552
|
+
const slots = ctx.slots;
|
|
1553
|
+
const component = seat.component;
|
|
1554
|
+
const inject = seat.inject;
|
|
1555
|
+
let dispose;
|
|
1556
|
+
let current;
|
|
1557
|
+
/**
|
|
1558
|
+
* Re-entrancy latch. The registry emits a change event synchronously from
|
|
1559
|
+
* inside both `register` and the previous entry's disposer, so an unguarded
|
|
1560
|
+
* reconcile would re-enter itself mid-move and register the card twice into
|
|
1561
|
+
* the seat it is leaving ("already has an entry for key ...").
|
|
1562
|
+
*/
|
|
1563
|
+
let reconciling = false;
|
|
1564
|
+
/** Reconcile the contribution with the currently live seat (no-op when unchanged). */
|
|
1565
|
+
const reconcile = () => {
|
|
1566
|
+
if (reconciling) return;
|
|
1567
|
+
const target = familyGroupLoaded(ctx) ? FAMILY_PLUGIN_CARD_SEAT : OFFICIAL_PLUGIN_CARD_SEAT;
|
|
1568
|
+
if (current === target) return;
|
|
1569
|
+
reconciling = true;
|
|
1570
|
+
const previous = dispose;
|
|
1571
|
+
dispose = void 0;
|
|
1572
|
+
current = void 0;
|
|
1573
|
+
previous?.();
|
|
1574
|
+
try {
|
|
1575
|
+
dispose = slots.register(target === "web-ui.plugin.item" ? {
|
|
1576
|
+
name: FAMILY_PLUGIN_CARD_SEAT,
|
|
1577
|
+
id: seat.id,
|
|
1578
|
+
...seat.order === void 0 ? {} : { order: seat.order },
|
|
1579
|
+
...seat.label === void 0 ? {} : { label: seat.label },
|
|
1580
|
+
locale: seat.locale,
|
|
1581
|
+
...seat.inject === void 0 ? {} : { inject }
|
|
1582
|
+
} : {
|
|
1583
|
+
name: OFFICIAL_PLUGIN_CARD_SEAT,
|
|
1584
|
+
key: seat.namespace,
|
|
1585
|
+
locale: seat.locale,
|
|
1586
|
+
...seat.inject === void 0 ? {} : { inject }
|
|
1587
|
+
}, component);
|
|
1588
|
+
current = target;
|
|
1589
|
+
} catch (error) {
|
|
1590
|
+
warnRefusedSeat(target, error);
|
|
1591
|
+
} finally {
|
|
1592
|
+
reconciling = false;
|
|
1593
|
+
}
|
|
1594
|
+
};
|
|
1595
|
+
if (typeof ctx.on === "function") try {
|
|
1596
|
+
ctx.on("slots/changed", () => {
|
|
1597
|
+
reconcile();
|
|
1598
|
+
});
|
|
1599
|
+
} catch {}
|
|
1600
|
+
reconcile();
|
|
1601
|
+
}
|
|
1602
|
+
//#endregion
|
|
574
1603
|
//#region src/client/index.ts
|
|
575
1604
|
/** Locale namespace this half owns. */
|
|
576
1605
|
const NS = "liangshen";
|
|
1606
|
+
/** Settings namespace the settings card edits (the Host plugin registers it). */
|
|
1607
|
+
const SETTINGS_NAMESPACE = "dsh-liangshen";
|
|
577
1608
|
/**
|
|
578
1609
|
* Required client services: the slot registry, locale, sessions, and the roster
|
|
579
1610
|
* Remote. Both `remote` and `remote.agentPresets` are declared: the context
|
|
@@ -584,6 +1615,7 @@ window.__ModuleLoader__.load({
|
|
|
584
1615
|
"slots",
|
|
585
1616
|
"locale",
|
|
586
1617
|
"sessions",
|
|
1618
|
+
"settingsScope",
|
|
587
1619
|
"remote",
|
|
588
1620
|
"remote.agentPresets"
|
|
589
1621
|
];
|
|
@@ -608,6 +1640,20 @@ window.__ModuleLoader__.load({
|
|
|
608
1640
|
try {
|
|
609
1641
|
controller.start();
|
|
610
1642
|
} catch {}
|
|
1643
|
+
try {
|
|
1644
|
+
const settingsCard = new LiangShenSettingsCardController((ctx.get("webUiSettings") ?? ctx.settingsScope).bind({ namespace: SETTINGS_NAMESPACE }));
|
|
1645
|
+
installPluginCard(ctx, {
|
|
1646
|
+
namespace: SETTINGS_NAMESPACE,
|
|
1647
|
+
id: "liangshen",
|
|
1648
|
+
order: 120,
|
|
1649
|
+
locale: NS,
|
|
1650
|
+
inject: () => settingsCard.inject(),
|
|
1651
|
+
component: LiangShenSettingsCard
|
|
1652
|
+
});
|
|
1653
|
+
ctx.effect(() => () => {
|
|
1654
|
+
settingsCard.dispose();
|
|
1655
|
+
}, "liangshen: settings card");
|
|
1656
|
+
} catch {}
|
|
611
1657
|
ctx.slots.inject("conversation.input.right", () => {
|
|
612
1658
|
try {
|
|
613
1659
|
const unregister = ctx.slots.register({
|
|
@@ -629,6 +1675,7 @@ window.__ModuleLoader__.load({
|
|
|
629
1675
|
exports.LeverController = LeverController;
|
|
630
1676
|
exports.LiangShenLever = LiangShenLever;
|
|
631
1677
|
exports.NS = NS;
|
|
1678
|
+
exports.SETTINGS_NAMESPACE = SETTINGS_NAMESPACE;
|
|
632
1679
|
exports.apply = apply;
|
|
633
1680
|
exports.inject = inject;
|
|
634
1681
|
exports.leverState = leverState;
|