@jayyuen66/dsh-zvec-grep 0.1.13 → 0.1.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/CHANGELOG.md +8 -0
- package/README.md +1 -1
- package/README.zh-CN.md +1 -1
- package/client.js +605 -28
- package/cordis.patch.yml +0 -3
- package/package.json +2 -5
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,14 @@
|
|
|
2
2
|
|
|
3
3
|
The format follows [Keep a Changelog](https://keepachangelog.com/en/1.1.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). The deviations below are deliberate: version headings carry no release date (publish times are recorded by the registry — `npm view <package> time`), and a release may add sections beyond the standard six, such as `Not changed, deliberately` and `Earlier`.
|
|
4
4
|
|
|
5
|
+
## 0.1.14
|
|
6
|
+
|
|
7
|
+
修复 0.1.13 引入的 web 启动隐患:卡片组件收回 `client.js` 内联,移除对 `@jayyuen66/dsh-plugin-shared/client` 的模块表外置与 `cordis.patch.yml` 里的 shared 供应行。zg 命令面与 MCP 传输层不变。
|
|
8
|
+
|
|
9
|
+
### Fixed
|
|
10
|
+
|
|
11
|
+
- **卡片组件内联进 `client.js`,产物自足**:0.1.13 把 `@jayyuen66/dsh-plugin-shared/client` 外置给宿主模块表,靠 `cordis.patch.yml` 插入的一条**不写 id** 的 shared 组件行把 shared 装载成供应方。这份供应链在 shared 只作为传递依赖装进 profile 时(`dsh plugin add` 的正常结果)没有保证——宿主侧可以既不报错也不把 shared 的 client 产物排进启动图,页面启动时 `require("@jayyuen66/dsh-plugin-shared/client")` 落进 `missed the module table`,整窗「应用无法启动或已意外停止」(dsh-ocr-review 仓 issue #2,宿主 0.2.2-rc.1 dsh desktop 实报)。`build-client.mjs` 的外置清单收回 react / zod 两族(宿主 `PLATFORM_MODULES` 供给,内联反而会产生第二份身份),卡片组件全部内联;`package.json` 的 `dsh.bundle.client.external` 与 patch 里的 shared 供应行随之移除,`cordis.patch.yml` 回到只声明本包一行。`test/build-client.test.ts` 的工厂替身对未知请求的抛出把外置回流挡在装配层。
|
|
12
|
+
|
|
5
13
|
## 0.1.13
|
|
6
14
|
|
|
7
15
|
适配 zg 0.3.0(上游 Rust 重写,CLI 形态破坏性变更),新增守护进程 MCP 传输层与传输三档设置卡开关,并把 0.3.0 的功能面对齐进三件工具。**不兼容旧 zg**:`MINIMUM_ZG_VERSION` 抬到 `0.3.0`,0.2.x 的 Node 版 zg 会在版本门槛处被拦下并给出升级指引。
|
package/README.md
CHANGED
|
@@ -105,7 +105,7 @@ If your profile pins `@jayyuen66/dsh-plugin-shared` with a pnpm `overrides` entr
|
|
|
105
105
|
|
|
106
106
|
## <img src="https://api.iconify.design/lucide/plug.svg?color=%23658EFF&height=22" height="22" width="22" align="absmiddle" alt="" /> Enabling it in dsh
|
|
107
107
|
|
|
108
|
-
- `dsh.bundle.patch` points at `cordis.patch.yml`, whose `insert:` block carries
|
|
108
|
+
- `dsh.bundle.patch` points at `cordis.patch.yml`, whose `insert:` block carries a single `- id: zvec-grep` entry with `name: "@jayyuen66/dsh-zvec-grep"` - the **bare package name** is what makes the host scan the client half. The card components are bundled into `client.js` (only `react` / `zod` stay external to the host's module table), so the card does not depend on a second package being loaded. Bundle installation goes through pnpm (>= 12.3.0).
|
|
109
109
|
- A missing injected surface keeps cordis from activating the entry (startup diagnostic: `pending (waiting for service: …)`); a malformed ctx throws `required services … missing` from apply.
|
|
110
110
|
- The card is registered in the `plugins.bundle.config` slot keyed by the **bundle package name**; the settings namespace and `configForms` reads stay the bare entry id `zvec-grep` (implicit registration by entry id).
|
|
111
111
|
- The rebuild read surface is installed on the apply fiber - no `webServer` dependency, no child fiber. On a TUI host the service still registers; the card simply has nowhere to render.
|
package/README.zh-CN.md
CHANGED
|
@@ -106,7 +106,7 @@ dsh plugin --profile web add @jayyuen66/dsh-zvec-grep
|
|
|
106
106
|
|
|
107
107
|
## <img src="https://api.iconify.design/lucide/plug.svg?color=%23658EFF&height=22" height="22" width="22" align="absmiddle" alt="" /> 在 dsh 里启用
|
|
108
108
|
|
|
109
|
-
- `dsh.bundle.patch` 指向 `cordis.patch.yml`,其 `insert:`
|
|
109
|
+
- `dsh.bundle.patch` 指向 `cordis.patch.yml`,其 `insert:` 块只有一条 `- id: zvec-grep`、`name: "@jayyuen66/dsh-zvec-grep"`——让宿主扫描 client 半的是**不带子路径的包名**。卡片组件直接打进 `client.js`(只有 `react` / `zod` 外置给宿主模块表),卡片不依赖第二份包被装载。bundle 安装走 pnpm(>= 12.3.0)。
|
|
110
110
|
- 缺任一注入宿主服务,cordis 就不激活本条目(启动诊断点名 `pending (waiting for service: …)`);ctx 形状不对时 apply 抛 `required services … missing`。
|
|
111
111
|
- 卡片注册在 `plugins.bundle.config` 槽的 **bundle 包名**键下;设置命名空间与 `configForms` 的读仍走裸条目 id `zvec-grep`(按条目 id 隐式注册)。
|
|
112
112
|
- 重建读取接口注册在 apply fiber 上——不声明 `webServer`、没有子 fiber。TUI 宿主上服务照常注册,只是卡片没有地方渲染。
|
package/client.js
CHANGED
|
@@ -8,7 +8,6 @@ window.__ModuleLoader__.load({
|
|
|
8
8
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
9
9
|
let react = require("react");
|
|
10
10
|
let zod = require("zod");
|
|
11
|
-
let _jayyuen66_dsh_plugin_shared_client = require("@jayyuen66/dsh-plugin-shared/client");
|
|
12
11
|
// lib/embedding-catalog.ts
|
|
13
12
|
/** 默认模型:本地最强(1024 维 / 8192 上下文 / 中英通用),约 640MB 一次性下载。 */
|
|
14
13
|
const DEFAULT_EMBEDDING = "local/qwen3-embedding-0.6b";
|
|
@@ -89,6 +88,584 @@ const REMOTE_EMBEDDING_CATALOG = Object.freeze([
|
|
|
89
88
|
dimension: 1024
|
|
90
89
|
}
|
|
91
90
|
].map((entry) => Object.freeze(entry)));
|
|
91
|
+
// node_modules/@jayyuen66/dsh-plugin-shared/dist/card-ui-C1lrHILm.js
|
|
92
|
+
const c = `
|
|
93
|
+
.dsu-form{display:flex;flex-direction:column}
|
|
94
|
+
.dsu-section{margin-top:24px;padding-top:24px;border-top:.5px solid var(--dsw-alias-border-l1)}
|
|
95
|
+
.dsu-form>.dsu-section:first-child{margin-top:0;padding-top:0;border-top:0}
|
|
96
|
+
.dsu-sectionTitle{margin:0;font-size:15px;font-weight:600;line-height:1.4;color:var(--dsw-alias-label-primary)}
|
|
97
|
+
.dsu-sectionHint{margin:4px 0 0;font-size:12px;line-height:1.5;color:var(--dsw-alias-label-tertiary)}
|
|
98
|
+
.dsu-statusbar{display:flex;flex-wrap:wrap;gap:4px 8px;margin-top:8px;font-size:12px;line-height:1.5;color:var(--dsw-alias-label-tertiary)}
|
|
99
|
+
.dsu-field{display:grid;grid-template-columns:minmax(0,1fr) minmax(240px,360px);column-gap:32px;align-items:center;padding:12px 0;border-top:.5px solid var(--dsw-alias-border-l2)}
|
|
100
|
+
.dsu-fieldMeta{display:flex;flex-direction:column;gap:4px;min-width:0}
|
|
101
|
+
.dsu-labelRow{display:flex;align-items:center;gap:6px;min-width:0}
|
|
102
|
+
.dsu-label{font-size:13px;font-weight:500;line-height:1.5;color:var(--dsw-alias-label-primary)}
|
|
103
|
+
.dsu-labelMono{font-family:ui-monospace,SFMono-Regular,Menlo,Consolas,monospace;font-size:12px}
|
|
104
|
+
.dsu-hint{margin:0;font-size:12px;line-height:1.5;color:var(--dsw-alias-label-tertiary)}
|
|
105
|
+
.dsu-control{min-width:0;display:flex;align-items:center;gap:8px}
|
|
106
|
+
.dsu-fieldWide{grid-template-columns:minmax(0,1fr);align-items:start}
|
|
107
|
+
.dsu-fieldWide .dsu-control{width:100%;max-width:720px;margin-top:2px}
|
|
108
|
+
.dsu-help{display:inline-flex;align-items:center;gap:6px;min-width:0}
|
|
109
|
+
.dsu-helpBtn{appearance:none;border:0;background:transparent;padding:0;width:16px;height:16px;display:inline-flex;align-items:center;justify-content:center;color:var(--dsw-alias-label-tertiary);cursor:help;border-radius:50%;flex:none}
|
|
110
|
+
.dsu-help:hover .dsu-helpBtn,.dsu-helpBtn:focus-visible{color:var(--dsw-alias-label-primary)}
|
|
111
|
+
.dsu-helpBtn:focus-visible{outline:2px solid var(--dsw-alias-state-business-primary);outline-offset:1px}
|
|
112
|
+
.dsu-tip{position:fixed;z-index:60;box-sizing:border-box;max-width:min(340px,calc(100vw - 16px));max-height:calc(100vh - 16px);overflow:auto;overflow-wrap:anywhere;padding:10px 12px;border-radius:10px;background:var(--dsw-alias-bg-layer-2);border:.5px solid var(--dsw-alias-border-l3);box-shadow:0 12px 32px rgb(0 0 0 / 45%);font-size:12px;line-height:1.6;font-weight:400;color:var(--dsw-alias-label-secondary)}
|
|
113
|
+
.dsu-input{width:100%;height:34px;padding:0 12px;border:.5px solid var(--dsw-alias-border-l4);border-radius:var(--dsw-radius-md);background:var(--dsw-alias-bg-layer-3);color:var(--dsw-alias-label-primary);font:inherit;font-size:13px}
|
|
114
|
+
.dsu-input:focus-visible{outline:none;border-color:var(--dsw-alias-state-business-primary)}
|
|
115
|
+
.dsu-input[aria-invalid="true"]{border-color:var(--dsw-alias-state-error-primary)}
|
|
116
|
+
.dsu-input:disabled{color:var(--dsw-alias-label-tertiary);cursor:default}
|
|
117
|
+
.dsu-input::placeholder{color:var(--dsw-alias-label-tertiary)}
|
|
118
|
+
.dsu-textarea{height:auto;min-height:96px;padding:8px 12px;line-height:1.6;resize:vertical}
|
|
119
|
+
.dsu-mono{font-family:ui-monospace,SFMono-Regular,Menlo,Consolas,monospace}
|
|
120
|
+
.dsu-numberWrap{display:flex;flex-direction:column;gap:4px;width:100%;min-width:0}
|
|
121
|
+
.dsu-number{display:flex;align-items:center;gap:8px;min-width:0}
|
|
122
|
+
.dsu-number .dsu-input{min-width:0}
|
|
123
|
+
.dsu-unit{flex:none;font-size:12px;color:var(--dsw-alias-label-tertiary)}
|
|
124
|
+
.dsu-error{margin:0;font-size:12px;line-height:1.5;color:var(--dsw-alias-state-error-primary)}
|
|
125
|
+
.dsu-switch{appearance:none;width:36px;height:20px;border-radius:999px;border:0;padding:2px;background:var(--dsw-alias-border-l3);display:flex;align-items:center;cursor:pointer;flex:none;transition:background-color .16s}
|
|
126
|
+
.dsu-knob{width:16px;height:16px;border-radius:50%;background:var(--dsw-alias-label-primary);transition:transform .16s,background-color .16s}
|
|
127
|
+
.dsu-switch[aria-checked="true"]{background:var(--dsw-alias-label-primary)}
|
|
128
|
+
.dsu-switch[aria-checked="true"] .dsu-knob{transform:translateX(16px);background:var(--dsw-alias-label-primary-foreground)}
|
|
129
|
+
.dsu-switch:disabled{opacity:.4;cursor:not-allowed}
|
|
130
|
+
.dsu-switch:focus-visible{outline:2px solid var(--dsw-alias-state-business-primary);outline-offset:2px}
|
|
131
|
+
.dsu-selectWrap{position:relative;width:100%;min-width:0}
|
|
132
|
+
.dsu-select{display:flex;align-items:center;justify-content:space-between;gap:8px;text-align:left;cursor:pointer}
|
|
133
|
+
.dsu-select[aria-expanded="true"]{border-color:var(--dsw-alias-state-business-primary)}
|
|
134
|
+
.dsu-selectValue{overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
|
|
135
|
+
.dsu-chevron{flex:none;color:var(--dsw-alias-label-tertiary);transition:transform .16s}
|
|
136
|
+
.dsu-select[aria-expanded="true"] .dsu-chevron{transform:rotate(180deg)}
|
|
137
|
+
.dsu-menu{position:fixed;z-index:70;padding:4px;background:var(--dsw-alias-bg-layer-2);border:.5px solid var(--dsw-alias-border-l3);border-radius:12px;box-shadow:0 12px 32px rgb(0 0 0 / 50%);max-height:280px;overflow:auto}
|
|
138
|
+
.dsu-option{appearance:none;border:0;background:transparent;color:var(--dsw-alias-label-primary);font:inherit;font-size:13px;line-height:1.4;width:100%;display:flex;align-items:center;justify-content:space-between;gap:12px;padding:8px 10px;border-radius:8px;cursor:pointer;text-align:left}
|
|
139
|
+
.dsu-option:hover,.dsu-option[data-active="true"]{background:var(--dsw-alias-bg-layer-3)}
|
|
140
|
+
.dsu-option:disabled{color:var(--dsw-alias-label-tertiary);cursor:not-allowed}
|
|
141
|
+
.dsu-option:focus-visible{outline:2px solid var(--dsw-alias-state-business-primary);outline-offset:-2px}
|
|
142
|
+
.dsu-optionGroup{padding:6px 10px 2px;font-size:11px;font-weight:600;color:var(--dsw-alias-label-tertiary)}
|
|
143
|
+
.dsu-check{opacity:0;flex:none}
|
|
144
|
+
.dsu-option[aria-selected="true"] .dsu-check{opacity:1}
|
|
145
|
+
.dsu-savebar{display:flex;align-items:center;gap:8px;padding:12px 0;margin-top:24px;border-top:.5px solid var(--dsw-alias-border-l2);background:var(--dsw-alias-bg-base)}
|
|
146
|
+
.dsu-savebar[data-dirty="true"]{position:sticky;bottom:0;z-index:2;box-shadow:0 -12px 24px rgb(0 0 0 / 35%)}
|
|
147
|
+
.dsu-btn{appearance:none;border:.5px solid var(--dsw-alias-border-l2);background:transparent;color:var(--dsw-alias-label-primary);font:inherit;font-size:13px;line-height:1.5;border-radius:var(--dsw-radius-md);padding:5px 14px;cursor:pointer;transition:background-color .12s,border-color .12s,color .12s,filter .12s}
|
|
148
|
+
.dsu-btn:hover:not(:disabled){background:var(--dsw-alias-bg-layer-2);border-color:var(--dsw-alias-border-l3)}
|
|
149
|
+
.dsu-btn:active:not(:disabled){background:var(--dsw-alias-bg-layer-1)}
|
|
150
|
+
.dsu-btn:focus-visible{outline:2px solid var(--dsw-alias-state-business-primary);outline-offset:1px}
|
|
151
|
+
.dsu-btn:disabled{opacity:.4;cursor:not-allowed}
|
|
152
|
+
.dsu-btnPrimary{background:var(--dsw-alias-label-primary);border-color:var(--dsw-alias-label-primary);color:var(--dsw-alias-bg-layer-3)}
|
|
153
|
+
.dsu-btnPrimary:hover:not(:disabled){background:var(--dsw-alias-label-primary);border-color:var(--dsw-alias-label-primary);filter:brightness(.9)}
|
|
154
|
+
.dsu-btnPrimary:active:not(:disabled){background:var(--dsw-alias-label-primary);border-color:var(--dsw-alias-label-primary);filter:brightness(.84)}
|
|
155
|
+
.dsu-btnDanger{color:var(--dsw-alias-state-error-primary)}
|
|
156
|
+
.dsu-btnDanger:hover:not(:disabled){color:var(--dsw-alias-state-error-primary);border-color:var(--dsw-alias-state-error-primary);background:var(--dsw-alias-bg-layer-2)}
|
|
157
|
+
.dsu-status{margin-left:auto;font-size:12px;color:var(--dsw-alias-label-tertiary)}
|
|
158
|
+
.dsu-statusError{color:var(--dsw-alias-state-error-primary)}
|
|
159
|
+
.dsu-grid{display:grid;grid-template-columns:repeat(auto-fit,minmax(min(200px,100%),1fr));gap:0 24px}
|
|
160
|
+
.dsu-grid>.dsu-field{display:flex;flex-direction:column;align-items:stretch;gap:6px;padding:10px 0;border-top:.5px solid var(--dsw-alias-border-l1)}
|
|
161
|
+
.dsu-grid>.dsu-field .dsu-control{width:100%}
|
|
162
|
+
@media (max-width:640px){
|
|
163
|
+
.dsu-field{grid-template-columns:minmax(0,1fr);align-items:start}
|
|
164
|
+
.dsu-control{width:100%;max-width:720px}
|
|
165
|
+
.dsu-section{margin-top:20px;padding-top:20px}
|
|
166
|
+
}
|
|
167
|
+
@media (prefers-reduced-motion:reduce){
|
|
168
|
+
.dsu-switch,.dsu-knob,.dsu-chevron,.dsu-btn{transition:none}
|
|
169
|
+
}
|
|
170
|
+
`;
|
|
171
|
+
function l(e, t = 30) {
|
|
172
|
+
return e.length <= t ? { hint: e } : { detail: e };
|
|
173
|
+
}
|
|
174
|
+
function u(t) {
|
|
175
|
+
return (0, react.createElement)(`div`, { className: `dsu-form` }, t.children);
|
|
176
|
+
}
|
|
177
|
+
function d(t) {
|
|
178
|
+
return (0, react.createElement)(`section`, { className: `dsu-section` }, (0, react.createElement)(`h2`, { className: `dsu-sectionTitle` }, t.title), t.hint === void 0 ? null : (0, react.createElement)(`p`, { className: `dsu-sectionHint` }, t.hint), t.children);
|
|
179
|
+
}
|
|
180
|
+
function m(a) {
|
|
181
|
+
let c = (0, react.useId)(), [l, u] = (0, react.useState)(!1), [d, f] = (0, react.useState)(!1), p = (0, react.useRef)(!1), m = (0, react.useRef)(!1), h = (0, react.useRef)(!1), g = (0, react.useRef)(null), _ = (0, react.useRef)(null), v = (0, react.useRef)(null), y = (0, react.useCallback)(() => {
|
|
182
|
+
v.current !== null && (clearTimeout(v.current), v.current = null);
|
|
183
|
+
}, []), b = (0, react.useCallback)(() => {
|
|
184
|
+
let e = g.current, t = _.current;
|
|
185
|
+
/* v8 ignore next 3 -- place 只在 open 的 layout effect 与挂载期监听器里调用;refs 为空只可能是卸载竞态 */
|
|
186
|
+
if (e === null || t === null) return;
|
|
187
|
+
let n = e.getBoundingClientRect(), r = t.offsetWidth, i = t.offsetHeight, { left: a } = n, o = n.bottom + 8;
|
|
188
|
+
o + i > window.innerHeight - 8 && (o = n.top - i - 8), a + r > window.innerWidth - 8 && (a = window.innerWidth - r - 8);
|
|
189
|
+
let s = Math.max(8, window.innerWidth - r - 8), c = Math.max(8, window.innerHeight - i - 8);
|
|
190
|
+
t.style.left = `${Math.min(Math.max(8, a), s)}px`, t.style.top = `${Math.min(Math.max(8, o), c)}px`;
|
|
191
|
+
}, []), x = (0, react.useCallback)(() => {
|
|
192
|
+
y(), h.current = !1, f(!1), u(!1);
|
|
193
|
+
}, [y]), S = (0, react.useCallback)(() => {
|
|
194
|
+
y(), u(!0);
|
|
195
|
+
}, [y]), C = (0, react.useCallback)(() => {
|
|
196
|
+
y(), p.current || m.current || h.current || (v.current = setTimeout(() => {
|
|
197
|
+
/* v8 ignore next 3 -- 任何重新进入/钉住都会 cancelHide;这次复查只防未来的异步路径 */
|
|
198
|
+
v.current = null, p.current || m.current || h.current || u(!1);
|
|
199
|
+
}, 120));
|
|
200
|
+
}, [y]), w = (0, react.useCallback)((e) => {
|
|
201
|
+
h.current = e, f(e);
|
|
202
|
+
}, []);
|
|
203
|
+
(0, react.useLayoutEffect)(() => {
|
|
204
|
+
if (!l) return () => {};
|
|
205
|
+
b();
|
|
206
|
+
let e = (e) => {
|
|
207
|
+
let { target: t } = e;
|
|
208
|
+
t instanceof Node && _.current?.contains(t) === !0 || (h.current ? b() : x());
|
|
209
|
+
}, t = () => {
|
|
210
|
+
b();
|
|
211
|
+
};
|
|
212
|
+
return window.addEventListener(`scroll`, e, !0), window.addEventListener(`resize`, t), () => {
|
|
213
|
+
window.removeEventListener(`scroll`, e, !0), window.removeEventListener(`resize`, t);
|
|
214
|
+
};
|
|
215
|
+
}, [
|
|
216
|
+
l,
|
|
217
|
+
a.detail,
|
|
218
|
+
b,
|
|
219
|
+
x
|
|
220
|
+
]), (0, react.useEffect)(() => {
|
|
221
|
+
if (!l) return () => {};
|
|
222
|
+
let e = (e) => {
|
|
223
|
+
e.key === `Escape` && x();
|
|
224
|
+
};
|
|
225
|
+
return document.addEventListener(`keydown`, e), () => {
|
|
226
|
+
document.removeEventListener(`keydown`, e);
|
|
227
|
+
};
|
|
228
|
+
}, [l, x]), (0, react.useEffect)(() => y, [y]);
|
|
229
|
+
let T = (0, react.createElement)(`button`, {
|
|
230
|
+
ref: g,
|
|
231
|
+
type: `button`,
|
|
232
|
+
className: `dsu-helpBtn`,
|
|
233
|
+
"aria-label": `${a.label} 说明`,
|
|
234
|
+
"aria-describedby": c,
|
|
235
|
+
"aria-pressed": d,
|
|
236
|
+
onClick: () => {
|
|
237
|
+
h.current ? x() : (w(!0), S());
|
|
238
|
+
}
|
|
239
|
+
}, (0, react.createElement)(`svg`, {
|
|
240
|
+
width: 12,
|
|
241
|
+
height: 12,
|
|
242
|
+
viewBox: `0 0 14 14`,
|
|
243
|
+
"aria-hidden": !0
|
|
244
|
+
}, (0, react.createElement)(`circle`, {
|
|
245
|
+
cx: 7,
|
|
246
|
+
cy: 7,
|
|
247
|
+
r: 6,
|
|
248
|
+
fill: `none`,
|
|
249
|
+
stroke: `currentColor`,
|
|
250
|
+
strokeWidth: 1.2
|
|
251
|
+
}), (0, react.createElement)(`path`, {
|
|
252
|
+
d: `M7 6.2v4`,
|
|
253
|
+
stroke: `currentColor`,
|
|
254
|
+
strokeWidth: 1.3,
|
|
255
|
+
strokeLinecap: `round`
|
|
256
|
+
}), (0, react.createElement)(`circle`, {
|
|
257
|
+
cx: 7,
|
|
258
|
+
cy: 4.3,
|
|
259
|
+
r: .8,
|
|
260
|
+
fill: `currentColor`
|
|
261
|
+
}))), E = (0, react.createElement)(`div`, {
|
|
262
|
+
ref: _,
|
|
263
|
+
id: c,
|
|
264
|
+
role: `tooltip`,
|
|
265
|
+
className: `dsu-tip`,
|
|
266
|
+
hidden: !l
|
|
267
|
+
}, a.detail), D = a.showLabel === !1 ? null : (0, react.createElement)(`span`, { className: `dsu-label${a.compact === !0 ? ` dsu-labelMono` : ``}` }, a.label);
|
|
268
|
+
return (0, react.createElement)(`span`, {
|
|
269
|
+
className: `dsu-help`,
|
|
270
|
+
onMouseEnter: () => {
|
|
271
|
+
p.current = !0, S();
|
|
272
|
+
},
|
|
273
|
+
onMouseLeave: () => {
|
|
274
|
+
p.current = !1, C();
|
|
275
|
+
},
|
|
276
|
+
onFocus: () => {
|
|
277
|
+
m.current = !0, S();
|
|
278
|
+
},
|
|
279
|
+
onBlur: (e) => {
|
|
280
|
+
let t = e.relatedTarget;
|
|
281
|
+
t instanceof Node && e.currentTarget.contains(t) || (m.current = !1, C());
|
|
282
|
+
}
|
|
283
|
+
}, D, T, E);
|
|
284
|
+
}
|
|
285
|
+
function h(t) {
|
|
286
|
+
let n = `dsu-label${t.compact === !0 ? ` dsu-labelMono` : ``}`, r = t.controlId === void 0 ? (0, react.createElement)(`span`, { className: n }, t.label) : (0, react.createElement)(`label`, {
|
|
287
|
+
className: n,
|
|
288
|
+
htmlFor: t.controlId
|
|
289
|
+
}, t.label);
|
|
290
|
+
return (0, react.createElement)(`div`, { className: `dsu-labelRow` }, r, t.detail === void 0 ? null : (0, react.createElement)(m, {
|
|
291
|
+
label: t.label,
|
|
292
|
+
detail: t.detail,
|
|
293
|
+
showLabel: !1
|
|
294
|
+
}));
|
|
295
|
+
}
|
|
296
|
+
function g(t) {
|
|
297
|
+
let n = t.controlId === void 0 ? void 0 : `${t.controlId}-hint`;
|
|
298
|
+
return (0, react.createElement)(`div`, { className: `dsu-field${t.wide === !0 ? ` dsu-fieldWide` : ``}` }, (0, react.createElement)(`div`, { className: `dsu-fieldMeta` }, (0, react.createElement)(h, {
|
|
299
|
+
label: t.label,
|
|
300
|
+
detail: t.detail,
|
|
301
|
+
compact: t.compact,
|
|
302
|
+
controlId: t.controlId
|
|
303
|
+
}), t.hint === void 0 ? null : (0, react.createElement)(`p`, {
|
|
304
|
+
className: `dsu-hint`,
|
|
305
|
+
id: n
|
|
306
|
+
}, t.hint)), (0, react.createElement)(`div`, { className: `dsu-control` }, t.children));
|
|
307
|
+
}
|
|
308
|
+
function _(t) {
|
|
309
|
+
let n = (0, react.useId)(), i = t.hint === void 0 ? void 0 : `${n}-hint`;
|
|
310
|
+
return (0, react.createElement)(g, {
|
|
311
|
+
...t,
|
|
312
|
+
controlId: n
|
|
313
|
+
}, (0, react.createElement)(`button`, {
|
|
314
|
+
type: `button`,
|
|
315
|
+
role: `switch`,
|
|
316
|
+
id: n,
|
|
317
|
+
className: `dsu-switch`,
|
|
318
|
+
"aria-checked": t.checked,
|
|
319
|
+
"aria-describedby": i,
|
|
320
|
+
"data-field": t.field,
|
|
321
|
+
disabled: t.disabled === !0,
|
|
322
|
+
onClick: () => {
|
|
323
|
+
t.onChange(!t.checked);
|
|
324
|
+
}
|
|
325
|
+
}, (0, react.createElement)(`span`, { className: `dsu-knob` })));
|
|
326
|
+
}
|
|
327
|
+
function v(t) {
|
|
328
|
+
let i = typeof t.value == `number` && Number.isFinite(t.value) ? String(t.value) : ``, [a, c] = (0, react.useState)(i), [l, u] = (0, react.useState)(!1), d = (0, react.useRef)(void 0), f = (0, react.useId)(), p = (0, react.useId)(), m = [t.hint === void 0 ? void 0 : `${f}-hint`, l ? p : void 0].filter((e) => e !== void 0), h = m.length === 0 ? void 0 : m.join(` `);
|
|
329
|
+
(0, react.useEffect)(() => {
|
|
330
|
+
t.value !== d.current && (d.current = t.value, c(i), u(!1));
|
|
331
|
+
}, [t.value, i]);
|
|
332
|
+
let _ = (e) => {
|
|
333
|
+
let n = t.min ?? -1 / 0, r = t.max ?? 1 / 0;
|
|
334
|
+
if (!Number.isFinite(e) || e < n || e > r) return !1;
|
|
335
|
+
let { step: i } = t;
|
|
336
|
+
if (i === void 0 || i <= 0) return !0;
|
|
337
|
+
let a = (e - (t.min ?? 0)) / i;
|
|
338
|
+
return Math.abs(a - Math.round(a)) < 1e-9;
|
|
339
|
+
}, v = (e) => {
|
|
340
|
+
if (c(e), e === ``) {
|
|
341
|
+
u(!1), d.current = void 0, t.onChange(void 0);
|
|
342
|
+
return;
|
|
343
|
+
}
|
|
344
|
+
let n = Number(e);
|
|
345
|
+
_(n) ? (u(!1), d.current = n, t.onChange(n)) : u(!0);
|
|
346
|
+
}, y = () => {
|
|
347
|
+
a === `` || l || c(String(Number(a)));
|
|
348
|
+
};
|
|
349
|
+
return (0, react.createElement)(g, {
|
|
350
|
+
...t,
|
|
351
|
+
controlId: f
|
|
352
|
+
}, (0, react.createElement)(`div`, { className: `dsu-numberWrap` }, (0, react.createElement)(`div`, { className: `dsu-number` }, (0, react.createElement)(`input`, {
|
|
353
|
+
className: `dsu-input`,
|
|
354
|
+
type: `number`,
|
|
355
|
+
inputMode: `numeric`,
|
|
356
|
+
id: f,
|
|
357
|
+
value: a,
|
|
358
|
+
min: t.min,
|
|
359
|
+
max: t.max,
|
|
360
|
+
step: t.step,
|
|
361
|
+
placeholder: t.placeholder,
|
|
362
|
+
"aria-invalid": l || void 0,
|
|
363
|
+
"aria-describedby": h,
|
|
364
|
+
"data-field": t.field,
|
|
365
|
+
disabled: t.disabled === !0,
|
|
366
|
+
onChange: (e) => {
|
|
367
|
+
v(e.target.value);
|
|
368
|
+
},
|
|
369
|
+
onBlur: y
|
|
370
|
+
}), t.unit === void 0 ? null : (0, react.createElement)(`span`, { className: `dsu-unit` }, t.unit)), l ? (0, react.createElement)(`p`, {
|
|
371
|
+
className: `dsu-error`,
|
|
372
|
+
id: p
|
|
373
|
+
}, t.invalidHint) : null));
|
|
374
|
+
}
|
|
375
|
+
function y(t) {
|
|
376
|
+
let [i, a] = (0, react.useState)(t.value), [o, c] = (0, react.useState)(!1), l = (0, react.useId)(), u = t.hint === void 0 ? void 0 : `${l}-hint`;
|
|
377
|
+
(0, react.useEffect)(() => {
|
|
378
|
+
o || a(t.value);
|
|
379
|
+
}, [t.value, o]);
|
|
380
|
+
let d = {
|
|
381
|
+
id: l,
|
|
382
|
+
className: `dsu-input${t.multiline === !0 ? ` dsu-textarea` : ``}${t.monospace === !0 ? ` dsu-mono` : ``}`,
|
|
383
|
+
value: i,
|
|
384
|
+
placeholder: t.placeholder,
|
|
385
|
+
"aria-describedby": u,
|
|
386
|
+
"data-field": t.field,
|
|
387
|
+
disabled: t.disabled === !0,
|
|
388
|
+
onFocus: () => {
|
|
389
|
+
c(!0);
|
|
390
|
+
},
|
|
391
|
+
onBlur: () => {
|
|
392
|
+
c(!1);
|
|
393
|
+
},
|
|
394
|
+
onChange: (e) => {
|
|
395
|
+
a(e.target.value), t.onChange(e.target.value);
|
|
396
|
+
}
|
|
397
|
+
};
|
|
398
|
+
return (0, react.createElement)(g, {
|
|
399
|
+
...t,
|
|
400
|
+
controlId: l
|
|
401
|
+
}, t.multiline === !0 ? (0, react.createElement)(`textarea`, d) : (0, react.createElement)(`input`, d));
|
|
402
|
+
}
|
|
403
|
+
function x(c) {
|
|
404
|
+
let [l, u] = (0, react.useState)(!1), [d, f] = (0, react.useState)(0), p = (0, react.useRef)(null), m = (0, react.useRef)(null), h = (0, react.useId)(), _ = (0, react.useId)(), v = c.hint === void 0 ? void 0 : `${_}-hint`, { disabled: y, value: b, options: x, onChange: S } = c, C = (0, react.useMemo)(() => x.map((e, t) => ({
|
|
405
|
+
option: e,
|
|
406
|
+
index: t
|
|
407
|
+
})).filter((e) => e.option.disabled !== !0), [x]), w = x.find((e) => e.value === b)?.label ?? b, T = x[d], E = T !== void 0 && T.disabled !== !0, D = (0, react.useCallback)(() => {
|
|
408
|
+
let e = p.current, t = m.current;
|
|
409
|
+
/* v8 ignore next 3 -- place 只在 open 的 layout effect 里调用;refs 为空只可能是卸载竞态 */
|
|
410
|
+
if (e === null || t === null) return;
|
|
411
|
+
let n = e.getBoundingClientRect(), r = Math.min(n.width, window.innerWidth - 16), { left: i } = n;
|
|
412
|
+
i + r > window.innerWidth - 8 && (i = window.innerWidth - r - 8);
|
|
413
|
+
let a = t.offsetHeight, o = n.bottom + 6;
|
|
414
|
+
o + a > window.innerHeight - 8 && (o = n.top - a - 6);
|
|
415
|
+
let s = Math.max(8, window.innerWidth - r - 8), c = Math.max(8, window.innerHeight - a - 8);
|
|
416
|
+
t.style.width = `${r}px`, t.style.left = `${Math.min(Math.max(8, i), s)}px`, t.style.top = `${Math.min(Math.max(8, o), c)}px`;
|
|
417
|
+
}, []), O = (0, react.useCallback)(() => {
|
|
418
|
+
u(!1);
|
|
419
|
+
}, []), k = (0, react.useCallback)(() => {
|
|
420
|
+
if (y === !0) return;
|
|
421
|
+
let e = C.find((e) => e.option.value === b) ?? C.at(0);
|
|
422
|
+
e !== void 0 && (f(e.index), u(!0));
|
|
423
|
+
}, [
|
|
424
|
+
y,
|
|
425
|
+
b,
|
|
426
|
+
C
|
|
427
|
+
]), A = (0, react.useCallback)((e) => {
|
|
428
|
+
/* v8 ignore next 3 -- 浮层只能经由 openMenu 打开;组件禁用时打不开 */
|
|
429
|
+
if (y === !0) return;
|
|
430
|
+
let t = x[e];
|
|
431
|
+
/* v8 ignore next 3 -- disabled 选项在浏览器里不派发 click;越界下标由调用面保证 */
|
|
432
|
+
t !== void 0 && t.disabled !== !0 && (S(t.value), O(), p.current?.focus());
|
|
433
|
+
}, [
|
|
434
|
+
y,
|
|
435
|
+
x,
|
|
436
|
+
S,
|
|
437
|
+
O
|
|
438
|
+
]), j = (0, react.useCallback)((e) => {
|
|
439
|
+
let t = C.findIndex((e) => e.index === d);
|
|
440
|
+
/* v8 ignore next 5 -- open 时归一 effect 已保证 enabled 非空且 active 落在可用项上 */
|
|
441
|
+
if (t === -1 || C.length === 0) return;
|
|
442
|
+
let n = (t + e + C.length) % C.length, r = C[n];
|
|
443
|
+
/* v8 ignore next 3 -- next 由取模保证在界内 */
|
|
444
|
+
r !== void 0 && f(r.index);
|
|
445
|
+
}, [d, C]);
|
|
446
|
+
(0, react.useLayoutEffect)(() => {
|
|
447
|
+
if (!l) return () => {};
|
|
448
|
+
D();
|
|
449
|
+
let e = (e) => {
|
|
450
|
+
let t = e.target;
|
|
451
|
+
m.current?.contains(t) !== !0 && p.current?.contains(t) !== !0 && O();
|
|
452
|
+
}, t = (e) => {
|
|
453
|
+
let { target: t } = e;
|
|
454
|
+
t instanceof Node && m.current?.contains(t) === !0 || O();
|
|
455
|
+
}, n = () => {
|
|
456
|
+
D();
|
|
457
|
+
};
|
|
458
|
+
return document.addEventListener(`pointerdown`, e, !0), window.addEventListener(`scroll`, t, !0), window.addEventListener(`resize`, n), () => {
|
|
459
|
+
document.removeEventListener(`pointerdown`, e, !0), window.removeEventListener(`scroll`, t, !0), window.removeEventListener(`resize`, n);
|
|
460
|
+
};
|
|
461
|
+
}, [
|
|
462
|
+
l,
|
|
463
|
+
c.options,
|
|
464
|
+
D,
|
|
465
|
+
O
|
|
466
|
+
]), (0, react.useEffect)(() => {
|
|
467
|
+
if (!l) return;
|
|
468
|
+
if (y === !0 || C.length === 0) {
|
|
469
|
+
O();
|
|
470
|
+
return;
|
|
471
|
+
}
|
|
472
|
+
if (C.some((e) => e.index === d)) return;
|
|
473
|
+
let e = C.find((e) => e.option.value === b) ?? C.at(0);
|
|
474
|
+
/* v8 ignore next 3 -- enabled 非空在上一分支已保证 */
|
|
475
|
+
e !== void 0 && f(e.index);
|
|
476
|
+
}, [
|
|
477
|
+
l,
|
|
478
|
+
y,
|
|
479
|
+
b,
|
|
480
|
+
x,
|
|
481
|
+
d,
|
|
482
|
+
O,
|
|
483
|
+
C
|
|
484
|
+
]), (0, react.useLayoutEffect)(() => {
|
|
485
|
+
if (!l) return;
|
|
486
|
+
let e = m.current;
|
|
487
|
+
/* v8 ignore next 2 -- 同上,menu 在 open 的 commit 之后必然已挂上 */
|
|
488
|
+
if (e === null) return;
|
|
489
|
+
let t = e.querySelector(`[data-active="true"]`);
|
|
490
|
+
/* v8 ignore next 2 -- active 已由归一 effect 保证落在可用项上 */
|
|
491
|
+
t !== null && (t.offsetTop < e.scrollTop ? e.scrollTop = t.offsetTop : t.offsetTop + t.offsetHeight > e.scrollTop + e.clientHeight && (e.scrollTop = t.offsetTop + t.offsetHeight - e.clientHeight));
|
|
492
|
+
}, [
|
|
493
|
+
l,
|
|
494
|
+
d,
|
|
495
|
+
x
|
|
496
|
+
]);
|
|
497
|
+
let M = (e) => {
|
|
498
|
+
if (e.key === `ArrowDown` || e.key === `ArrowUp`) {
|
|
499
|
+
if (e.preventDefault(), !l) {
|
|
500
|
+
k();
|
|
501
|
+
return;
|
|
502
|
+
}
|
|
503
|
+
j(e.key === `ArrowDown` ? 1 : -1);
|
|
504
|
+
} else if (e.key === `Home` || e.key === `End`) {
|
|
505
|
+
if (e.preventDefault(), l || k(), C.length === 0) return;
|
|
506
|
+
let t = e.key === `Home` ? C.at(0) : C.at(-1);
|
|
507
|
+
/* v8 ignore next 3 -- enabled 为空已在上一条返回 */
|
|
508
|
+
if (t === void 0) return;
|
|
509
|
+
f(t.index);
|
|
510
|
+
} else if (e.key === `Enter` || e.key === ` `) {
|
|
511
|
+
if (e.preventDefault(), !l) {
|
|
512
|
+
k();
|
|
513
|
+
return;
|
|
514
|
+
}
|
|
515
|
+
A(d);
|
|
516
|
+
} else (e.key === `Tab` || e.key === `Escape`) && O();
|
|
517
|
+
}, N = [], P;
|
|
518
|
+
for (let [t, n] of x.entries()) n.group !== P && (n.group !== void 0 && N.push((0, react.createElement)(`div`, {
|
|
519
|
+
key: `group-${t}-${n.group}`,
|
|
520
|
+
className: `dsu-optionGroup`,
|
|
521
|
+
role: `presentation`
|
|
522
|
+
}, n.group)), P = n.group), N.push((0, react.createElement)(`button`, {
|
|
523
|
+
key: `option-${n.value}`,
|
|
524
|
+
type: `button`,
|
|
525
|
+
role: `option`,
|
|
526
|
+
id: `${h}-${t}`,
|
|
527
|
+
className: `dsu-option`,
|
|
528
|
+
tabIndex: -1,
|
|
529
|
+
"aria-selected": n.value === c.value,
|
|
530
|
+
"data-active": t === d,
|
|
531
|
+
disabled: n.disabled === !0,
|
|
532
|
+
onMouseDown: (e) => {
|
|
533
|
+
e.preventDefault();
|
|
534
|
+
},
|
|
535
|
+
onClick: () => {
|
|
536
|
+
A(t);
|
|
537
|
+
},
|
|
538
|
+
onMouseEnter: () => {
|
|
539
|
+
/* v8 ignore next -- happy-dom 对 disabled 元素不派发 mouse 事件;浏览器实现各有差异,保留禁用检查 */
|
|
540
|
+
n.disabled !== !0 && f(t);
|
|
541
|
+
}
|
|
542
|
+
}, (0, react.createElement)(`span`, null, n.label), (0, react.createElement)(`svg`, {
|
|
543
|
+
className: `dsu-check`,
|
|
544
|
+
width: 14,
|
|
545
|
+
height: 14,
|
|
546
|
+
viewBox: `0 0 14 14`,
|
|
547
|
+
"aria-hidden": !0
|
|
548
|
+
}, (0, react.createElement)(`path`, {
|
|
549
|
+
d: `M2.5 7.5l3 3 6-7`,
|
|
550
|
+
fill: `none`,
|
|
551
|
+
stroke: `currentColor`,
|
|
552
|
+
strokeWidth: 1.5,
|
|
553
|
+
strokeLinecap: `round`,
|
|
554
|
+
strokeLinejoin: `round`
|
|
555
|
+
}))));
|
|
556
|
+
return (0, react.createElement)(g, {
|
|
557
|
+
...c,
|
|
558
|
+
controlId: _
|
|
559
|
+
}, (0, react.createElement)(`div`, {
|
|
560
|
+
className: `dsu-selectWrap`,
|
|
561
|
+
onBlur: (e) => {
|
|
562
|
+
let t = e.relatedTarget;
|
|
563
|
+
t instanceof Node && e.currentTarget.contains(t) || O();
|
|
564
|
+
}
|
|
565
|
+
}, (0, react.createElement)(`button`, {
|
|
566
|
+
ref: p,
|
|
567
|
+
type: `button`,
|
|
568
|
+
id: _,
|
|
569
|
+
className: `dsu-select dsu-input`,
|
|
570
|
+
role: `combobox`,
|
|
571
|
+
"aria-haspopup": `listbox`,
|
|
572
|
+
"aria-expanded": l,
|
|
573
|
+
"aria-controls": `${h}-list`,
|
|
574
|
+
"aria-activedescendant": l && E ? `${h}-${d}` : void 0,
|
|
575
|
+
"aria-describedby": v,
|
|
576
|
+
"data-field": c.field,
|
|
577
|
+
disabled: y === !0 || x.length === 0,
|
|
578
|
+
onClick: () => {
|
|
579
|
+
l ? O() : k();
|
|
580
|
+
},
|
|
581
|
+
onKeyDown: M
|
|
582
|
+
}, (0, react.createElement)(`span`, { className: `dsu-selectValue` }, w), (0, react.createElement)(`svg`, {
|
|
583
|
+
className: `dsu-chevron`,
|
|
584
|
+
width: 14,
|
|
585
|
+
height: 14,
|
|
586
|
+
viewBox: `0 0 14 14`,
|
|
587
|
+
"aria-hidden": !0
|
|
588
|
+
}, (0, react.createElement)(`path`, {
|
|
589
|
+
d: `M3 5l4 4 4-4`,
|
|
590
|
+
fill: `none`,
|
|
591
|
+
stroke: `currentColor`,
|
|
592
|
+
strokeWidth: 1.5,
|
|
593
|
+
strokeLinecap: `round`,
|
|
594
|
+
strokeLinejoin: `round`
|
|
595
|
+
}))), (0, react.createElement)(`div`, {
|
|
596
|
+
ref: m,
|
|
597
|
+
id: `${h}-list`,
|
|
598
|
+
role: `listbox`,
|
|
599
|
+
className: `dsu-menu`,
|
|
600
|
+
"aria-label": c.label,
|
|
601
|
+
hidden: !l
|
|
602
|
+
}, ...N)));
|
|
603
|
+
}
|
|
604
|
+
function S(t) {
|
|
605
|
+
let n = !t.writable || t.busy || !t.dirty, r;
|
|
606
|
+
return r = t.error === null ? t.writable ? t.dirty ? t.dirtyLabel : t.cleanLabel : t.readOnlyLabel : t.error, (0, react.createElement)(`div`, {
|
|
607
|
+
className: `dsu-savebar`,
|
|
608
|
+
"data-dirty": t.dirty
|
|
609
|
+
}, (0, react.createElement)(`button`, {
|
|
610
|
+
type: `button`,
|
|
611
|
+
className: `dsu-btn dsu-btnPrimary`,
|
|
612
|
+
"data-field": `save`,
|
|
613
|
+
disabled: n,
|
|
614
|
+
onClick: t.onSave
|
|
615
|
+
}, t.busy ? t.savingLabel : t.saveLabel), (0, react.createElement)(`button`, {
|
|
616
|
+
type: `button`,
|
|
617
|
+
className: `dsu-btn`,
|
|
618
|
+
"data-field": `discard`,
|
|
619
|
+
disabled: n,
|
|
620
|
+
onClick: t.onDiscard
|
|
621
|
+
}, t.revertLabel), (0, react.createElement)(`span`, { className: t.error === null ? `dsu-status` : `dsu-status dsu-statusError` }, r));
|
|
622
|
+
}
|
|
623
|
+
// node_modules/@jayyuen66/dsh-plugin-shared/dist/card-diff.js
|
|
624
|
+
function e$1(t, n, r) {
|
|
625
|
+
if (t == null || n == null) return (t ?? null) === (n ?? null);
|
|
626
|
+
if (Object.is(t, n)) return !0;
|
|
627
|
+
if (typeof t != `object` || typeof n != `object`) return !1;
|
|
628
|
+
if (r.get(t) === n) return !0;
|
|
629
|
+
if (r.set(t, n), Array.isArray(t) || Array.isArray(n)) return !Array.isArray(t) || !Array.isArray(n) || t.length !== n.length ? !1 : t.every((t, i) => e$1(t, n[i], r));
|
|
630
|
+
let i = Object.keys(t), a = Object.keys(n);
|
|
631
|
+
return i.length === a.length && i.every((i) => Object.hasOwn(n, i) && e$1(Reflect.get(t, i), Reflect.get(n, i), r));
|
|
632
|
+
}
|
|
633
|
+
function t$1(t, n) {
|
|
634
|
+
let r = [];
|
|
635
|
+
for (let i of Object.keys(t)) e$1(t[i], n[i], /* @__PURE__ */ new WeakMap()) || r.push(i);
|
|
636
|
+
return r;
|
|
637
|
+
}
|
|
638
|
+
// node_modules/@jayyuen66/dsh-plugin-shared/dist/record.js
|
|
639
|
+
function e(e) {
|
|
640
|
+
return typeof e == `object` && !!e && !Array.isArray(e);
|
|
641
|
+
}
|
|
642
|
+
// node_modules/@jayyuen66/dsh-plugin-shared/dist/errors.js
|
|
643
|
+
function t(e) {
|
|
644
|
+
let t = Object.getOwnPropertyDescriptor(e, `message`);
|
|
645
|
+
return t !== void 0 && `value` in t && typeof t.value == `string` ? t.value : void 0;
|
|
646
|
+
}
|
|
647
|
+
function n(e, r) {
|
|
648
|
+
if (r.has(e)) return `<circular cause>`;
|
|
649
|
+
r.add(e);
|
|
650
|
+
try {
|
|
651
|
+
if (!(e instanceof Error)) {
|
|
652
|
+
if (typeof e == `object` && e) {
|
|
653
|
+
let n = t(e);
|
|
654
|
+
if (n !== void 0 && n !== ``) return n;
|
|
655
|
+
}
|
|
656
|
+
return String(e);
|
|
657
|
+
}
|
|
658
|
+
let i = e.message === `` ? e.name : e.message, a = typeof globalThis.AggregateError == `function` && e instanceof AggregateError && e.errors.length > 0 ? ` [${e.errors.map((e) => n(e, r)).join(`; `)}]` : ``, o = e.cause === void 0 || e.cause === null ? `` : n(e.cause, r);
|
|
659
|
+
return `${i}${a}${o === `` || o === i ? `` : `: ${o}`}`;
|
|
660
|
+
} catch {
|
|
661
|
+
return `<unrenderable value>`;
|
|
662
|
+
} finally {
|
|
663
|
+
r.delete(e);
|
|
664
|
+
}
|
|
665
|
+
}
|
|
666
|
+
function r(e) {
|
|
667
|
+
return n(e, /* @__PURE__ */ new Set());
|
|
668
|
+
}
|
|
92
669
|
// lib/card-draft.ts
|
|
93
670
|
/** 草稿优先取值:touched 有该键(哪怕值是 undefined=待清空)即用草稿。
|
|
94
671
|
* 两层都只判**自有**属性:本函数收任意字段名,`in`/裸下标会沿原型链命中 `toString` /
|
|
@@ -317,9 +894,9 @@ const REBUILD_DESCRIPTORS = [
|
|
|
317
894
|
}
|
|
318
895
|
];
|
|
319
896
|
/** 这个值能当远程通道用吗(只核我们要调的那一位;服务来自别的实现或版本时保守当作没有)。 */
|
|
320
|
-
const isRemoteMounter = (value) => (
|
|
897
|
+
const isRemoteMounter = (value) => e(value) && typeof value["$mount"] === "function";
|
|
321
898
|
/** 同上:命名空间服务(挂载之后才有,缺它说明网关没认这枚贡献)。 */
|
|
322
|
-
const isRebuildNamespace = (value) => (
|
|
899
|
+
const isRebuildNamespace = (value) => e(value) && typeof value["roots"] === "function" && typeof value["rebuild"] === "function" && typeof value["status"] === "function";
|
|
323
900
|
/**
|
|
324
901
|
* 线上拒绝(result.ok=false)翻成异常:code 与 message 都来自网关的错误对象。
|
|
325
902
|
* 三个方法同构,收成一个入口——同一份判据,不抄三份。
|
|
@@ -612,9 +1189,9 @@ function numberDisplay(display, schema) {
|
|
|
612
1189
|
/** 检索模型小节:embedding 下拉(按本地后端分组)+ 每组结果数。 */
|
|
613
1190
|
function buildModelSection(deps) {
|
|
614
1191
|
const { editable, fields, setField, t } = deps;
|
|
615
|
-
const embedding = (0, react.createElement)(
|
|
1192
|
+
const embedding = (0, react.createElement)(x, {
|
|
616
1193
|
label: t("embeddingLabel"),
|
|
617
|
-
...(
|
|
1194
|
+
...l(t("embeddingHint")),
|
|
618
1195
|
field: "defaultEmbedding",
|
|
619
1196
|
value: fields.embedding,
|
|
620
1197
|
options: embeddingOptions(t),
|
|
@@ -623,7 +1200,7 @@ function buildModelSection(deps) {
|
|
|
623
1200
|
setField("defaultEmbedding", next);
|
|
624
1201
|
}
|
|
625
1202
|
});
|
|
626
|
-
const limit = (0, react.createElement)(
|
|
1203
|
+
const limit = (0, react.createElement)(v, {
|
|
627
1204
|
label: t("limitLabel"),
|
|
628
1205
|
hint: t("limitInvalid", {
|
|
629
1206
|
min: 1,
|
|
@@ -641,7 +1218,7 @@ function buildModelSection(deps) {
|
|
|
641
1218
|
setField("defaultLimit", next);
|
|
642
1219
|
}
|
|
643
1220
|
});
|
|
644
|
-
return (0, react.createElement)(
|
|
1221
|
+
return (0, react.createElement)(d, { title: t("modelSection") }, embedding, limit);
|
|
645
1222
|
}
|
|
646
1223
|
/** 重建行:root 输入(白名单候选进 <datalist>)+ 触发按钮(在跑时禁用)。 */
|
|
647
1224
|
function buildRebuildField(deps) {
|
|
@@ -667,9 +1244,9 @@ function buildRebuildField(deps) {
|
|
|
667
1244
|
disabled: rebuild.phase === "running",
|
|
668
1245
|
onClick: deps.onRebuild
|
|
669
1246
|
}, rebuild.phase === "running" ? t("rebuildRunning") : t("rebuildButton"));
|
|
670
|
-
return (0, react.createElement)(
|
|
1247
|
+
return (0, react.createElement)(g, {
|
|
671
1248
|
label: t("rebuildLabel"),
|
|
672
|
-
...(
|
|
1249
|
+
...l(rebuildHintText(t, fields.embedding, roots.length > 0)),
|
|
673
1250
|
wide: true
|
|
674
1251
|
}, rootDatalist, rebuildInput, rebuildButton);
|
|
675
1252
|
}
|
|
@@ -700,9 +1277,9 @@ function buildRebuildStatusRow(deps) {
|
|
|
700
1277
|
/** 网络与索引小节:传输三档、镜像地址、search-first 开关、配额与时效、工作区重建与守护进程状态。 */
|
|
701
1278
|
function buildIndexSection(deps) {
|
|
702
1279
|
const { editable, fields, setField, t } = deps;
|
|
703
|
-
const transport = (0, react.createElement)(
|
|
1280
|
+
const transport = (0, react.createElement)(x, {
|
|
704
1281
|
label: t("transportLabel"),
|
|
705
|
-
...(
|
|
1282
|
+
...l(t("transportHint")),
|
|
706
1283
|
field: "transport",
|
|
707
1284
|
value: fields.transport,
|
|
708
1285
|
options: transportOptions(t),
|
|
@@ -711,9 +1288,9 @@ function buildIndexSection(deps) {
|
|
|
711
1288
|
setField("transport", next);
|
|
712
1289
|
}
|
|
713
1290
|
});
|
|
714
|
-
const endpoint = (0, react.createElement)(
|
|
1291
|
+
const endpoint = (0, react.createElement)(y, {
|
|
715
1292
|
label: t("endpointLabel"),
|
|
716
|
-
...(
|
|
1293
|
+
...l(t("endpointHint")),
|
|
717
1294
|
field: "hfEndpoint",
|
|
718
1295
|
value: fields.hfEndpoint,
|
|
719
1296
|
placeholder: EMBEDDING_MIRROR_URL,
|
|
@@ -723,9 +1300,9 @@ function buildIndexSection(deps) {
|
|
|
723
1300
|
setField("hfEndpoint", next.trim() === "" ? void 0 : next.trim());
|
|
724
1301
|
}
|
|
725
1302
|
});
|
|
726
|
-
const enforce = (0, react.createElement)(
|
|
1303
|
+
const enforce = (0, react.createElement)(_, {
|
|
727
1304
|
label: t("enforceLabel"),
|
|
728
|
-
...(
|
|
1305
|
+
...l(t("enforceHint")),
|
|
729
1306
|
field: "enforceSearchFirst",
|
|
730
1307
|
checked: fields.enforceSearchFirst,
|
|
731
1308
|
disabled: !editable,
|
|
@@ -733,9 +1310,9 @@ function buildIndexSection(deps) {
|
|
|
733
1310
|
setField("enforceSearchFirst", next);
|
|
734
1311
|
}
|
|
735
1312
|
});
|
|
736
|
-
const budget = (0, react.createElement)(
|
|
1313
|
+
const budget = (0, react.createElement)(v, {
|
|
737
1314
|
label: t("budgetLabel"),
|
|
738
|
-
...(
|
|
1315
|
+
...l(t("budgetHint", { default: 3 })),
|
|
739
1316
|
field: "grepBudgetPerSearch",
|
|
740
1317
|
value: numberDisplay(fields.grepBudget, BUDGET_SCHEMA),
|
|
741
1318
|
min: BUDGET_SCHEMA.minValue ?? 1,
|
|
@@ -748,9 +1325,9 @@ function buildIndexSection(deps) {
|
|
|
748
1325
|
setField("grepBudgetPerSearch", next);
|
|
749
1326
|
}
|
|
750
1327
|
});
|
|
751
|
-
const window = (0, react.createElement)(
|
|
1328
|
+
const window = (0, react.createElement)(v, {
|
|
752
1329
|
label: t("windowLabel"),
|
|
753
|
-
...(
|
|
1330
|
+
...l(t("windowHint", { default: 10 })),
|
|
754
1331
|
field: "unlockWindowMin",
|
|
755
1332
|
value: numberDisplay(fields.unlockWindow, WINDOW_SCHEMA),
|
|
756
1333
|
min: WINDOW_SCHEMA.minValue ?? 1,
|
|
@@ -763,12 +1340,12 @@ function buildIndexSection(deps) {
|
|
|
763
1340
|
setField("unlockWindowMin", next);
|
|
764
1341
|
}
|
|
765
1342
|
});
|
|
766
|
-
return (0, react.createElement)(
|
|
1343
|
+
return (0, react.createElement)(d, { title: t("indexSection") }, transport, endpoint, enforce, budget, window, buildDaemonNote(deps), buildRebuildField(deps), buildRebuildStatusRow(deps));
|
|
767
1344
|
}
|
|
768
1345
|
/** 卡片主体:检索模型 / 网络与索引两节 + 保存条。 */
|
|
769
1346
|
function buildCardBody(deps) {
|
|
770
1347
|
const { t } = deps;
|
|
771
|
-
const saveBar = (0, react.createElement)(
|
|
1348
|
+
const saveBar = (0, react.createElement)(S, {
|
|
772
1349
|
dirty: deps.dirty,
|
|
773
1350
|
busy: deps.busy,
|
|
774
1351
|
writable: deps.writable,
|
|
@@ -782,7 +1359,7 @@ function buildCardBody(deps) {
|
|
|
782
1359
|
onSave: deps.onSave,
|
|
783
1360
|
onDiscard: deps.onDiscard
|
|
784
1361
|
});
|
|
785
|
-
return (0, react.createElement)(
|
|
1362
|
+
return (0, react.createElement)(u, null, buildModelSection(deps), buildIndexSection(deps), saveBar);
|
|
786
1363
|
}
|
|
787
1364
|
/** 显式字段写入(schema-coverage 门禁按 set('字段名') 字面量识别绑定)。 */
|
|
788
1365
|
function pushFieldWrite(ops, key, draft, set) {
|
|
@@ -872,7 +1449,7 @@ function useRebuild(t, reader) {
|
|
|
872
1449
|
stopPolling();
|
|
873
1450
|
setRebuild({
|
|
874
1451
|
phase: "error",
|
|
875
|
-
output: (
|
|
1452
|
+
output: r(error)
|
|
876
1453
|
});
|
|
877
1454
|
} finally {
|
|
878
1455
|
pollingRef.current = false;
|
|
@@ -909,7 +1486,7 @@ function useRebuild(t, reader) {
|
|
|
909
1486
|
stopPolling();
|
|
910
1487
|
setRebuild({
|
|
911
1488
|
phase: "error",
|
|
912
|
-
output: (
|
|
1489
|
+
output: r(error)
|
|
913
1490
|
});
|
|
914
1491
|
}
|
|
915
1492
|
}
|
|
@@ -933,7 +1510,7 @@ function ZgCard(props) {
|
|
|
933
1510
|
const [saveError, setSaveError] = (0, react.useState)(null);
|
|
934
1511
|
const rebuildView = useRebuild(t, props.rebuildRemote);
|
|
935
1512
|
const fields = draftFields(touched, value);
|
|
936
|
-
const dirtyCount = (
|
|
1513
|
+
const dirtyCount = t$1(touched, value).length;
|
|
937
1514
|
const dirty = dirtyCount > 0;
|
|
938
1515
|
const setField = (field, draft) => {
|
|
939
1516
|
setTouched((prev) => ({
|
|
@@ -942,7 +1519,7 @@ function ZgCard(props) {
|
|
|
942
1519
|
}));
|
|
943
1520
|
};
|
|
944
1521
|
const save = async () => {
|
|
945
|
-
const keys = (
|
|
1522
|
+
const keys = t$1(touched, value);
|
|
946
1523
|
if (keys.length === 0) return;
|
|
947
1524
|
setBusy(true);
|
|
948
1525
|
setSaveError(null);
|
|
@@ -960,7 +1537,7 @@ function ZgCard(props) {
|
|
|
960
1537
|
}
|
|
961
1538
|
} catch (error) {
|
|
962
1539
|
setBusy(false);
|
|
963
|
-
setSaveError(t("saveFailed", { reason: (
|
|
1540
|
+
setSaveError(t("saveFailed", { reason: r(error) }));
|
|
964
1541
|
return;
|
|
965
1542
|
}
|
|
966
1543
|
const savedKeys = new Set(keys);
|
|
@@ -1005,7 +1582,7 @@ function apply(ctx) {
|
|
|
1005
1582
|
ctx.effect(() => {
|
|
1006
1583
|
const tag = document.createElement("style");
|
|
1007
1584
|
tag.id = "zvec-grep-card-css";
|
|
1008
|
-
tag.textContent = `${CARD_CSS}\n${
|
|
1585
|
+
tag.textContent = `${CARD_CSS}\n${c}`;
|
|
1009
1586
|
document.head.append(tag);
|
|
1010
1587
|
return () => {
|
|
1011
1588
|
tag.remove();
|
package/cordis.patch.yml
CHANGED
|
@@ -12,8 +12,5 @@
|
|
|
12
12
|
# 行按裸包名引用本包(client-modules 只扫描裸包名条目的 dsh.client 声明)。
|
|
13
13
|
# 注意 pnpm ≥12.3.0:12.0.0 的 add 本地目录有 #14437 bug。
|
|
14
14
|
- insert:
|
|
15
|
-
# 故意不写 id:shared 是本包 patch 启用的内部组件行,不是用户可停用的独立组件;
|
|
16
|
-
# 写 id 会让插件页出现一个可关闭的组件,关闭后本包设置卡会失去组件供应。
|
|
17
|
-
- name: "@jayyuen66/dsh-plugin-shared"
|
|
18
15
|
- id: zvec-grep
|
|
19
16
|
name: "@jayyuen66/dsh-zvec-grep"
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@jayyuen66/dsh-zvec-grep",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.14",
|
|
4
4
|
"description": "dsh 工作区语义检索插件(zg):zg_search / zg_index / zg_status + 本地 embedding 设置卡片 + systemPrompt 路由规则 + guard 安全兜底。",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"cordis",
|
|
@@ -131,10 +131,7 @@
|
|
|
131
131
|
},
|
|
132
132
|
"client": {
|
|
133
133
|
"platform": "web",
|
|
134
|
-
"immediately": true
|
|
135
|
-
"external": [
|
|
136
|
-
"@jayyuen66/dsh-plugin-shared/client"
|
|
137
|
-
]
|
|
134
|
+
"immediately": true
|
|
138
135
|
}
|
|
139
136
|
},
|
|
140
137
|
"scripts": {
|