@jayyuen66/dsh-zvec-grep 0.1.14 → 0.1.16
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 +23 -0
- package/README.md +26 -25
- package/README.zh-CN.md +4 -4
- package/client.js +195 -159
- package/host.js +227 -163
- package/package.json +45 -44
package/client.js
CHANGED
|
@@ -88,7 +88,7 @@ const REMOTE_EMBEDDING_CATALOG = Object.freeze([
|
|
|
88
88
|
dimension: 1024
|
|
89
89
|
}
|
|
90
90
|
].map((entry) => Object.freeze(entry)));
|
|
91
|
-
// node_modules/@jayyuen66/dsh-plugin-shared/dist/card-ui-
|
|
91
|
+
// node_modules/@jayyuen66/dsh-plugin-shared/dist/card-ui-yf56_khz.js
|
|
92
92
|
const c = `
|
|
93
93
|
.dsu-form{display:flex;flex-direction:column}
|
|
94
94
|
.dsu-section{margin-top:24px;padding-top:24px;border-top:.5px solid var(--dsw-alias-border-l1)}
|
|
@@ -109,11 +109,11 @@ const c = `
|
|
|
109
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
110
|
.dsu-help:hover .dsu-helpBtn,.dsu-helpBtn:focus-visible{color:var(--dsw-alias-label-primary)}
|
|
111
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)}
|
|
112
|
+
.dsu-tip{width:max-content;position:fixed;position-area:block-end span-inline-end;justify-self:start;margin-top:8px;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
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
114
|
.dsu-input:focus-visible{outline:none;border-color:var(--dsw-alias-state-business-primary)}
|
|
115
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:
|
|
116
|
+
.dsu-input:disabled{color:var(--dsw-alias-label-tertiary);cursor:not-allowed}
|
|
117
117
|
.dsu-input::placeholder{color:var(--dsw-alias-label-tertiary)}
|
|
118
118
|
.dsu-textarea{height:auto;min-height:96px;padding:8px 12px;line-height:1.6;resize:vertical}
|
|
119
119
|
.dsu-mono{font-family:ui-monospace,SFMono-Regular,Menlo,Consolas,monospace}
|
|
@@ -134,7 +134,7 @@ const c = `
|
|
|
134
134
|
.dsu-selectValue{overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
|
|
135
135
|
.dsu-chevron{flex:none;color:var(--dsw-alias-label-tertiary);transition:transform .16s}
|
|
136
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}
|
|
137
|
+
.dsu-menu{position:fixed;position-area:block-end span-inline-end;justify-self:start;margin-top:6px;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
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
139
|
.dsu-option:hover,.dsu-option[data-active="true"]{background:var(--dsw-alias-bg-layer-3)}
|
|
140
140
|
.dsu-option:disabled{color:var(--dsw-alias-label-tertiary);cursor:not-allowed}
|
|
@@ -177,64 +177,80 @@ function u(t) {
|
|
|
177
177
|
function d(t) {
|
|
178
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
179
|
}
|
|
180
|
-
function m(
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
180
|
+
function m() {
|
|
181
|
+
return `happyDOM` in globalThis ? !1 : typeof CSS < `u` && typeof CSS.supports == `function` && CSS.supports(`position-area: block-end`);
|
|
182
|
+
}
|
|
183
|
+
function h(e, t) {
|
|
184
|
+
let n = Math.abs(t.left - e.left) <= 2, r = Math.abs(t.right - e.right) <= 2;
|
|
185
|
+
if (!n && !r) return !0;
|
|
186
|
+
let i = t.top >= e.bottom - 2, a = t.bottom <= e.top + 2;
|
|
187
|
+
return !i && !a;
|
|
188
|
+
}
|
|
189
|
+
function g(a) {
|
|
190
|
+
let c = (0, react.useId)(), l = `--dsu-tip-${c.replaceAll(/[^a-zA-Z0-9]/gu, ``)}`, [u, d] = (0, react.useState)(!1), f = (0, react.useRef)(!1), p = (0, react.useRef)(!1), g = (0, react.useRef)(!1), _ = (0, react.useRef)(null), v = (0, react.useRef)(null), y = (0, react.useRef)(null), b = (0, react.useRef)(null), x = (0, react.useCallback)(() => {
|
|
191
|
+
b.current !== null && (clearTimeout(b.current), b.current = null);
|
|
192
|
+
}, []), S = (0, react.useCallback)(() => {
|
|
193
|
+
let e = v.current, t = y.current;
|
|
185
194
|
/* v8 ignore next 3 -- place 只在 open 的 layout effect 与挂载期监听器里调用;refs 为空只可能是卸载竞态 */
|
|
186
195
|
if (e === null || t === null) return;
|
|
187
|
-
let n =
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
196
|
+
let n = m() && t.style.positionArea !== `none`, r = e.getBoundingClientRect();
|
|
197
|
+
if (n && !h(r, t.getBoundingClientRect())) return;
|
|
198
|
+
n && (t.style.positionArea = `none`), t.style.marginTop = `0px`;
|
|
199
|
+
let i = t.offsetWidth, a = t.offsetHeight, { left: o } = r, s = r.bottom + 8;
|
|
200
|
+
s + a > window.innerHeight - 8 && (s = r.top - a - 8), o + i > window.innerWidth - 8 && (o = window.innerWidth - i - 8);
|
|
201
|
+
let c = Math.max(8, window.innerWidth - i - 8), l = Math.max(8, window.innerHeight - a - 8);
|
|
202
|
+
t.style.left = `${Math.min(Math.max(8, o), c)}px`, t.style.top = `${Math.min(Math.max(8, s), l)}px`;
|
|
203
|
+
}, []), C = (0, react.useCallback)(() => {
|
|
204
|
+
x(), g.current = !1, d(!1);
|
|
205
|
+
}, [x]), w = (0, react.useCallback)(() => {
|
|
206
|
+
x(), d(!0);
|
|
207
|
+
}, [x]), T = (0, react.useCallback)(() => {
|
|
208
|
+
x(), f.current || p.current || g.current || (b.current = setTimeout(() => {
|
|
197
209
|
/* v8 ignore next 3 -- 任何重新进入/钉住都会 cancelHide;这次复查只防未来的异步路径 */
|
|
198
|
-
|
|
210
|
+
b.current = null, f.current || p.current || g.current || d(!1);
|
|
199
211
|
}, 120));
|
|
200
|
-
}, [
|
|
201
|
-
|
|
212
|
+
}, [x]), E = (0, react.useCallback)((e) => {
|
|
213
|
+
g.current = e;
|
|
202
214
|
}, []);
|
|
203
215
|
(0, react.useLayoutEffect)(() => {
|
|
204
|
-
if (!
|
|
205
|
-
|
|
216
|
+
if (!u) return () => {};
|
|
217
|
+
S();
|
|
206
218
|
let e = (e) => {
|
|
207
219
|
let { target: t } = e;
|
|
208
|
-
t instanceof Node &&
|
|
220
|
+
t instanceof Node && y.current?.contains(t) === !0 || (g.current ? S() : C());
|
|
209
221
|
}, t = () => {
|
|
210
|
-
|
|
222
|
+
S();
|
|
223
|
+
}, n = (e) => {
|
|
224
|
+
let t = e.target;
|
|
225
|
+
_.current?.contains(t) !== !0 && C();
|
|
211
226
|
};
|
|
212
|
-
return window.addEventListener(`scroll`, e, !0), window.addEventListener(`resize`, t), () => {
|
|
213
|
-
window.removeEventListener(`scroll`, e, !0), window.removeEventListener(`resize`, t);
|
|
227
|
+
return document.addEventListener(`pointerdown`, n, !0), window.addEventListener(`scroll`, e, !0), window.addEventListener(`resize`, t), () => {
|
|
228
|
+
document.removeEventListener(`pointerdown`, n, !0), window.removeEventListener(`scroll`, e, !0), window.removeEventListener(`resize`, t);
|
|
214
229
|
};
|
|
215
230
|
}, [
|
|
216
|
-
|
|
231
|
+
u,
|
|
217
232
|
a.detail,
|
|
218
|
-
|
|
219
|
-
|
|
233
|
+
S,
|
|
234
|
+
C
|
|
220
235
|
]), (0, react.useEffect)(() => {
|
|
221
|
-
if (!
|
|
236
|
+
if (!u) return () => {};
|
|
222
237
|
let e = (e) => {
|
|
223
|
-
e.key === `Escape` &&
|
|
238
|
+
e.key === `Escape` && C();
|
|
224
239
|
};
|
|
225
240
|
return document.addEventListener(`keydown`, e), () => {
|
|
226
241
|
document.removeEventListener(`keydown`, e);
|
|
227
242
|
};
|
|
228
|
-
}, [
|
|
229
|
-
let
|
|
230
|
-
ref:
|
|
243
|
+
}, [u, C]), (0, react.useEffect)(() => x, [x]);
|
|
244
|
+
let D = (0, react.createElement)(`button`, {
|
|
245
|
+
ref: v,
|
|
231
246
|
type: `button`,
|
|
232
247
|
className: `dsu-helpBtn`,
|
|
248
|
+
style: { anchorName: l },
|
|
233
249
|
"aria-label": `${a.label} 说明`,
|
|
234
|
-
"aria-
|
|
235
|
-
"aria-
|
|
250
|
+
"aria-expanded": u,
|
|
251
|
+
"aria-controls": c,
|
|
236
252
|
onClick: () => {
|
|
237
|
-
|
|
253
|
+
g.current ? C() : (E(!0), w());
|
|
238
254
|
}
|
|
239
255
|
}, (0, react.createElement)(`svg`, {
|
|
240
256
|
width: 12,
|
|
@@ -258,44 +274,49 @@ function m(a) {
|
|
|
258
274
|
cy: 4.3,
|
|
259
275
|
r: .8,
|
|
260
276
|
fill: `currentColor`
|
|
261
|
-
}))),
|
|
262
|
-
ref:
|
|
277
|
+
}))), O = (0, react.createElement)(`div`, {
|
|
278
|
+
ref: y,
|
|
263
279
|
id: c,
|
|
264
280
|
role: `tooltip`,
|
|
265
281
|
className: `dsu-tip`,
|
|
266
|
-
|
|
267
|
-
|
|
282
|
+
style: {
|
|
283
|
+
positionAnchor: l,
|
|
284
|
+
positionTryFallbacks: `flip-block, flip-inline`
|
|
285
|
+
},
|
|
286
|
+
hidden: !u
|
|
287
|
+
}, a.detail), k = a.showLabel === !1 ? null : (0, react.createElement)(`span`, { className: `dsu-label${a.compact === !0 ? ` dsu-labelMono` : ``}` }, a.label);
|
|
268
288
|
return (0, react.createElement)(`span`, {
|
|
289
|
+
ref: _,
|
|
269
290
|
className: `dsu-help`,
|
|
270
291
|
onMouseEnter: () => {
|
|
271
|
-
|
|
292
|
+
f.current = !0, w();
|
|
272
293
|
},
|
|
273
294
|
onMouseLeave: () => {
|
|
274
|
-
|
|
295
|
+
f.current = !1, T();
|
|
275
296
|
},
|
|
276
297
|
onFocus: () => {
|
|
277
|
-
|
|
298
|
+
p.current = !0, w();
|
|
278
299
|
},
|
|
279
300
|
onBlur: (e) => {
|
|
280
301
|
let t = e.relatedTarget;
|
|
281
|
-
t instanceof Node && e.currentTarget.contains(t) || (
|
|
302
|
+
t instanceof Node && e.currentTarget.contains(t) || (p.current = !1, T());
|
|
282
303
|
}
|
|
283
|
-
},
|
|
304
|
+
}, k, D, O);
|
|
284
305
|
}
|
|
285
|
-
function
|
|
306
|
+
function _(t) {
|
|
286
307
|
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
308
|
className: n,
|
|
288
309
|
htmlFor: t.controlId
|
|
289
310
|
}, t.label);
|
|
290
|
-
return (0, react.createElement)(`div`, { className: `dsu-labelRow` }, r, t.detail === void 0 ? null : (0, react.createElement)(
|
|
311
|
+
return (0, react.createElement)(`div`, { className: `dsu-labelRow` }, r, t.detail === void 0 ? null : (0, react.createElement)(g, {
|
|
291
312
|
label: t.label,
|
|
292
313
|
detail: t.detail,
|
|
293
314
|
showLabel: !1
|
|
294
315
|
}));
|
|
295
316
|
}
|
|
296
|
-
function
|
|
317
|
+
function v(t) {
|
|
297
318
|
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)(
|
|
319
|
+
return (0, react.createElement)(`div`, { className: `dsu-field${t.wide === !0 ? ` dsu-fieldWide` : ``}` }, (0, react.createElement)(`div`, { className: `dsu-fieldMeta` }, (0, react.createElement)(_, {
|
|
299
320
|
label: t.label,
|
|
300
321
|
detail: t.detail,
|
|
301
322
|
compact: t.compact,
|
|
@@ -305,9 +326,9 @@ function g(t) {
|
|
|
305
326
|
id: n
|
|
306
327
|
}, t.hint)), (0, react.createElement)(`div`, { className: `dsu-control` }, t.children));
|
|
307
328
|
}
|
|
308
|
-
function
|
|
329
|
+
function y(t) {
|
|
309
330
|
let n = (0, react.useId)(), i = t.hint === void 0 ? void 0 : `${n}-hint`;
|
|
310
|
-
return (0, react.createElement)(
|
|
331
|
+
return (0, react.createElement)(v, {
|
|
311
332
|
...t,
|
|
312
333
|
controlId: n
|
|
313
334
|
}, (0, react.createElement)(`button`, {
|
|
@@ -324,55 +345,57 @@ function _(t) {
|
|
|
324
345
|
}
|
|
325
346
|
}, (0, react.createElement)(`span`, { className: `dsu-knob` })));
|
|
326
347
|
}
|
|
327
|
-
function
|
|
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),
|
|
348
|
+
function b(t) {
|
|
349
|
+
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, f] = (0, react.useState)(!1), p = (0, react.useRef)(void 0), m = (0, react.useId)(), h = (0, react.useId)(), g = t.hint === void 0 ? void 0 : `${m}-hint`, _ = l && d, y = [g, _ ? h : void 0].filter((e) => e !== void 0), b = y.length === 0 ? void 0 : y.join(` `);
|
|
329
350
|
(0, react.useEffect)(() => {
|
|
330
|
-
t.value !==
|
|
351
|
+
t.value !== p.current && (p.current = t.value, c(i), u(!1), f(!1));
|
|
331
352
|
}, [t.value, i]);
|
|
332
|
-
let
|
|
353
|
+
let x = (e) => {
|
|
333
354
|
let n = t.min ?? -1 / 0, r = t.max ?? 1 / 0;
|
|
334
355
|
if (!Number.isFinite(e) || e < n || e > r) return !1;
|
|
335
356
|
let { step: i } = t;
|
|
336
357
|
if (i === void 0 || i <= 0) return !0;
|
|
337
358
|
let a = (e - (t.min ?? 0)) / i;
|
|
338
359
|
return Math.abs(a - Math.round(a)) < 1e-9;
|
|
339
|
-
},
|
|
340
|
-
if (c(e), e === ``) {
|
|
341
|
-
u(!1),
|
|
360
|
+
}, S = (e) => {
|
|
361
|
+
if (f(!1), c(e), e === ``) {
|
|
362
|
+
u(!1), p.current = void 0, t.onChange(void 0);
|
|
342
363
|
return;
|
|
343
364
|
}
|
|
344
365
|
let n = Number(e);
|
|
345
|
-
|
|
346
|
-
},
|
|
366
|
+
x(n) ? (u(!1), p.current = n, t.onChange(n)) : u(!0);
|
|
367
|
+
}, C = () => {
|
|
347
368
|
a === `` || l || c(String(Number(a)));
|
|
369
|
+
}, w = () => {
|
|
370
|
+
f(l), C();
|
|
348
371
|
};
|
|
349
|
-
return (0, react.createElement)(
|
|
372
|
+
return (0, react.createElement)(v, {
|
|
350
373
|
...t,
|
|
351
|
-
controlId:
|
|
374
|
+
controlId: m
|
|
352
375
|
}, (0, react.createElement)(`div`, { className: `dsu-numberWrap` }, (0, react.createElement)(`div`, { className: `dsu-number` }, (0, react.createElement)(`input`, {
|
|
353
376
|
className: `dsu-input`,
|
|
354
377
|
type: `number`,
|
|
355
378
|
inputMode: `numeric`,
|
|
356
|
-
id:
|
|
379
|
+
id: m,
|
|
357
380
|
value: a,
|
|
358
381
|
min: t.min,
|
|
359
382
|
max: t.max,
|
|
360
383
|
step: t.step,
|
|
361
384
|
placeholder: t.placeholder,
|
|
362
|
-
"aria-invalid":
|
|
363
|
-
"aria-describedby":
|
|
385
|
+
"aria-invalid": _ || void 0,
|
|
386
|
+
"aria-describedby": b,
|
|
364
387
|
"data-field": t.field,
|
|
365
388
|
disabled: t.disabled === !0,
|
|
366
389
|
onChange: (e) => {
|
|
367
|
-
|
|
390
|
+
S(e.target.value);
|
|
368
391
|
},
|
|
369
|
-
onBlur:
|
|
370
|
-
}), t.unit === void 0 ? null : (0, react.createElement)(`span`, { className: `dsu-unit` }, t.unit)),
|
|
392
|
+
onBlur: w
|
|
393
|
+
}), t.unit === void 0 ? null : (0, react.createElement)(`span`, { className: `dsu-unit` }, t.unit)), _ ? (0, react.createElement)(`p`, {
|
|
371
394
|
className: `dsu-error`,
|
|
372
|
-
id:
|
|
395
|
+
id: h
|
|
373
396
|
}, t.invalidHint) : null));
|
|
374
397
|
}
|
|
375
|
-
function
|
|
398
|
+
function x(t) {
|
|
376
399
|
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
400
|
(0, react.useEffect)(() => {
|
|
378
401
|
o || a(t.value);
|
|
@@ -395,65 +418,70 @@ function y(t) {
|
|
|
395
418
|
a(e.target.value), t.onChange(e.target.value);
|
|
396
419
|
}
|
|
397
420
|
};
|
|
398
|
-
return (0, react.createElement)(
|
|
421
|
+
return (0, react.createElement)(v, {
|
|
399
422
|
...t,
|
|
400
423
|
controlId: l
|
|
401
424
|
}, t.multiline === !0 ? (0, react.createElement)(`textarea`, d) : (0, react.createElement)(`input`, d));
|
|
402
425
|
}
|
|
403
|
-
function
|
|
404
|
-
let [l, u] = (0, react.useState)(!1), [d, f] = (0, react.useState)(0), p = (0, react.useRef)(null),
|
|
426
|
+
function C(c) {
|
|
427
|
+
let [l, u] = (0, react.useState)(!1), [d, f] = (0, react.useState)(0), p = (0, react.useRef)(null), g = (0, react.useRef)(null), _ = (0, react.useId)(), y = (0, react.useId)(), b = `--dsu-${y.replaceAll(/[^a-zA-Z0-9]/gu, ``)}`, x = c.hint === void 0 ? void 0 : `${y}-hint`, { disabled: S, value: C, options: w, onChange: T } = c, E = (0, react.useMemo)(() => w.map((e, t) => ({
|
|
405
428
|
option: e,
|
|
406
429
|
index: t
|
|
407
|
-
})).filter((e) => e.option.disabled !== !0), [
|
|
408
|
-
let e = p.current, t =
|
|
430
|
+
})).filter((e) => e.option.disabled !== !0), [w]), D = w.find((e) => e.value === C)?.label ?? C, O = w[d], k = O !== void 0 && O.disabled !== !0, A = (0, react.useCallback)(() => {
|
|
431
|
+
let e = p.current, t = g.current;
|
|
409
432
|
/* v8 ignore next 3 -- place 只在 open 的 layout effect 里调用;refs 为空只可能是卸载竞态 */
|
|
410
433
|
if (e === null || t === null) return;
|
|
411
|
-
let n = e.getBoundingClientRect(), r = Math.min(n.width, window.innerWidth - 16)
|
|
412
|
-
|
|
413
|
-
let
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
434
|
+
let n = e.getBoundingClientRect(), r = Math.min(n.width, window.innerWidth - 16);
|
|
435
|
+
t.style.width = `${r}px`;
|
|
436
|
+
let i = m() && t.style.positionArea !== `none`;
|
|
437
|
+
if (i && !h(n, t.getBoundingClientRect())) return;
|
|
438
|
+
i && (t.style.positionArea = `none`), t.style.marginTop = `0px`;
|
|
439
|
+
let { left: a } = n;
|
|
440
|
+
a + r > window.innerWidth - 8 && (a = window.innerWidth - r - 8);
|
|
441
|
+
let o = t.offsetHeight, s = n.bottom + 6;
|
|
442
|
+
s + o > window.innerHeight - 8 && (s = n.top - o - 6);
|
|
443
|
+
let c = Math.max(8, window.innerWidth - r - 8), l = Math.max(8, window.innerHeight - o - 8);
|
|
444
|
+
t.style.left = `${Math.min(Math.max(8, a), c)}px`, t.style.top = `${Math.min(Math.max(8, s), l)}px`;
|
|
445
|
+
}, []), j = (0, react.useCallback)(() => {
|
|
418
446
|
u(!1);
|
|
419
|
-
}, []),
|
|
420
|
-
if (
|
|
421
|
-
let e =
|
|
447
|
+
}, []), M = (0, react.useCallback)(() => {
|
|
448
|
+
if (S === !0) return;
|
|
449
|
+
let e = E.find((e) => e.option.value === C) ?? E.at(0);
|
|
422
450
|
e !== void 0 && (f(e.index), u(!0));
|
|
423
451
|
}, [
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
]),
|
|
452
|
+
S,
|
|
453
|
+
C,
|
|
454
|
+
E
|
|
455
|
+
]), N = (0, react.useCallback)((e) => {
|
|
428
456
|
/* v8 ignore next 3 -- 浮层只能经由 openMenu 打开;组件禁用时打不开 */
|
|
429
|
-
if (
|
|
430
|
-
let t =
|
|
431
|
-
/* v8 ignore next 3 -- disabled 选项在浏览器里不派发 click
|
|
432
|
-
t !== void 0 && t.disabled !== !0 && (
|
|
457
|
+
if (S === !0) return;
|
|
458
|
+
let t = w[e];
|
|
459
|
+
/* v8 ignore next 3 -- disabled 选项在浏览器里不派发 click;越界下标由调用方保证 */
|
|
460
|
+
t !== void 0 && t.disabled !== !0 && (T(t.value), j(), p.current?.focus());
|
|
433
461
|
}, [
|
|
434
|
-
y,
|
|
435
|
-
x,
|
|
436
462
|
S,
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
463
|
+
w,
|
|
464
|
+
T,
|
|
465
|
+
j
|
|
466
|
+
]), P = (0, react.useCallback)((e) => {
|
|
467
|
+
let t = E.findIndex((e) => e.index === d);
|
|
440
468
|
/* v8 ignore next 5 -- open 时归一 effect 已保证 enabled 非空且 active 落在可用项上 */
|
|
441
|
-
if (t === -1 ||
|
|
442
|
-
let n = (t + e +
|
|
469
|
+
if (t === -1 || E.length === 0) return;
|
|
470
|
+
let n = (t + e + E.length) % E.length, r = E[n];
|
|
443
471
|
/* v8 ignore next 3 -- next 由取模保证在界内 */
|
|
444
472
|
r !== void 0 && f(r.index);
|
|
445
|
-
}, [d,
|
|
473
|
+
}, [d, E]);
|
|
446
474
|
(0, react.useLayoutEffect)(() => {
|
|
447
475
|
if (!l) return () => {};
|
|
448
|
-
|
|
476
|
+
A();
|
|
449
477
|
let e = (e) => {
|
|
450
478
|
let t = e.target;
|
|
451
|
-
|
|
479
|
+
g.current?.contains(t) !== !0 && p.current?.contains(t) !== !0 && j();
|
|
452
480
|
}, t = (e) => {
|
|
453
481
|
let { target: t } = e;
|
|
454
|
-
t instanceof Node &&
|
|
482
|
+
t instanceof Node && g.current?.contains(t) === !0 || j();
|
|
455
483
|
}, n = () => {
|
|
456
|
-
|
|
484
|
+
A();
|
|
457
485
|
};
|
|
458
486
|
return document.addEventListener(`pointerdown`, e, !0), window.addEventListener(`scroll`, t, !0), window.addEventListener(`resize`, n), () => {
|
|
459
487
|
document.removeEventListener(`pointerdown`, e, !0), window.removeEventListener(`scroll`, t, !0), window.removeEventListener(`resize`, n);
|
|
@@ -461,29 +489,29 @@ function x(c) {
|
|
|
461
489
|
}, [
|
|
462
490
|
l,
|
|
463
491
|
c.options,
|
|
464
|
-
|
|
465
|
-
|
|
492
|
+
A,
|
|
493
|
+
j
|
|
466
494
|
]), (0, react.useEffect)(() => {
|
|
467
495
|
if (!l) return;
|
|
468
|
-
if (
|
|
469
|
-
|
|
496
|
+
if (S === !0 || E.length === 0) {
|
|
497
|
+
j();
|
|
470
498
|
return;
|
|
471
499
|
}
|
|
472
|
-
if (
|
|
473
|
-
let e =
|
|
500
|
+
if (E.some((e) => e.index === d)) return;
|
|
501
|
+
let e = E.find((e) => e.option.value === C) ?? E.at(0);
|
|
474
502
|
/* v8 ignore next 3 -- enabled 非空在上一分支已保证 */
|
|
475
503
|
e !== void 0 && f(e.index);
|
|
476
504
|
}, [
|
|
477
505
|
l,
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
506
|
+
S,
|
|
507
|
+
C,
|
|
508
|
+
w,
|
|
481
509
|
d,
|
|
482
|
-
|
|
483
|
-
|
|
510
|
+
j,
|
|
511
|
+
E
|
|
484
512
|
]), (0, react.useLayoutEffect)(() => {
|
|
485
513
|
if (!l) return;
|
|
486
|
-
let e =
|
|
514
|
+
let e = g.current;
|
|
487
515
|
/* v8 ignore next 2 -- 同上,menu 在 open 的 commit 之后必然已挂上 */
|
|
488
516
|
if (e === null) return;
|
|
489
517
|
let t = e.querySelector(`[data-active="true"]`);
|
|
@@ -492,38 +520,38 @@ function x(c) {
|
|
|
492
520
|
}, [
|
|
493
521
|
l,
|
|
494
522
|
d,
|
|
495
|
-
|
|
523
|
+
w
|
|
496
524
|
]);
|
|
497
|
-
let
|
|
525
|
+
let F = (e) => {
|
|
498
526
|
if (e.key === `ArrowDown` || e.key === `ArrowUp`) {
|
|
499
527
|
if (e.preventDefault(), !l) {
|
|
500
|
-
|
|
528
|
+
M();
|
|
501
529
|
return;
|
|
502
530
|
}
|
|
503
|
-
|
|
531
|
+
P(e.key === `ArrowDown` ? 1 : -1);
|
|
504
532
|
} else if (e.key === `Home` || e.key === `End`) {
|
|
505
|
-
if (e.preventDefault(), l ||
|
|
506
|
-
let t = e.key === `Home` ?
|
|
533
|
+
if (e.preventDefault(), l || M(), E.length === 0) return;
|
|
534
|
+
let t = e.key === `Home` ? E.at(0) : E.at(-1);
|
|
507
535
|
/* v8 ignore next 3 -- enabled 为空已在上一条返回 */
|
|
508
536
|
if (t === void 0) return;
|
|
509
537
|
f(t.index);
|
|
510
538
|
} else if (e.key === `Enter` || e.key === ` `) {
|
|
511
539
|
if (e.preventDefault(), !l) {
|
|
512
|
-
|
|
540
|
+
M();
|
|
513
541
|
return;
|
|
514
542
|
}
|
|
515
|
-
|
|
516
|
-
} else (e.key === `Tab` || e.key === `Escape`) &&
|
|
517
|
-
},
|
|
518
|
-
for (let [t, n] of
|
|
543
|
+
N(d);
|
|
544
|
+
} else (e.key === `Tab` || e.key === `Escape`) && j();
|
|
545
|
+
}, I = [], L;
|
|
546
|
+
for (let [t, n] of w.entries()) n.group !== L && (n.group !== void 0 && I.push((0, react.createElement)(`div`, {
|
|
519
547
|
key: `group-${t}-${n.group}`,
|
|
520
548
|
className: `dsu-optionGroup`,
|
|
521
549
|
role: `presentation`
|
|
522
|
-
}, n.group)),
|
|
550
|
+
}, n.group)), L = n.group), I.push((0, react.createElement)(`button`, {
|
|
523
551
|
key: `option-${n.value}`,
|
|
524
552
|
type: `button`,
|
|
525
553
|
role: `option`,
|
|
526
|
-
id: `${
|
|
554
|
+
id: `${_}-${t}`,
|
|
527
555
|
className: `dsu-option`,
|
|
528
556
|
tabIndex: -1,
|
|
529
557
|
"aria-selected": n.value === c.value,
|
|
@@ -533,7 +561,7 @@ function x(c) {
|
|
|
533
561
|
e.preventDefault();
|
|
534
562
|
},
|
|
535
563
|
onClick: () => {
|
|
536
|
-
|
|
564
|
+
N(t);
|
|
537
565
|
},
|
|
538
566
|
onMouseEnter: () => {
|
|
539
567
|
/* v8 ignore next -- happy-dom 对 disabled 元素不派发 mouse 事件;浏览器实现各有差异,保留禁用检查 */
|
|
@@ -553,33 +581,34 @@ function x(c) {
|
|
|
553
581
|
strokeLinecap: `round`,
|
|
554
582
|
strokeLinejoin: `round`
|
|
555
583
|
}))));
|
|
556
|
-
return (0, react.createElement)(
|
|
584
|
+
return (0, react.createElement)(v, {
|
|
557
585
|
...c,
|
|
558
|
-
controlId:
|
|
586
|
+
controlId: y
|
|
559
587
|
}, (0, react.createElement)(`div`, {
|
|
560
588
|
className: `dsu-selectWrap`,
|
|
561
589
|
onBlur: (e) => {
|
|
562
590
|
let t = e.relatedTarget;
|
|
563
|
-
t instanceof Node && e.currentTarget.contains(t) ||
|
|
591
|
+
t instanceof Node && e.currentTarget.contains(t) || j();
|
|
564
592
|
}
|
|
565
593
|
}, (0, react.createElement)(`button`, {
|
|
566
594
|
ref: p,
|
|
567
595
|
type: `button`,
|
|
568
|
-
id:
|
|
596
|
+
id: y,
|
|
597
|
+
style: { anchorName: b },
|
|
569
598
|
className: `dsu-select dsu-input`,
|
|
570
599
|
role: `combobox`,
|
|
571
600
|
"aria-haspopup": `listbox`,
|
|
572
601
|
"aria-expanded": l,
|
|
573
|
-
"aria-controls": `${
|
|
574
|
-
"aria-activedescendant": l &&
|
|
575
|
-
"aria-describedby":
|
|
602
|
+
"aria-controls": `${_}-list`,
|
|
603
|
+
"aria-activedescendant": l && k ? `${_}-${d}` : void 0,
|
|
604
|
+
"aria-describedby": x,
|
|
576
605
|
"data-field": c.field,
|
|
577
|
-
disabled:
|
|
606
|
+
disabled: S === !0 || w.length === 0,
|
|
578
607
|
onClick: () => {
|
|
579
|
-
l ?
|
|
608
|
+
l ? j() : M();
|
|
580
609
|
},
|
|
581
|
-
onKeyDown:
|
|
582
|
-
}, (0, react.createElement)(`span`, { className: `dsu-selectValue` },
|
|
610
|
+
onKeyDown: F
|
|
611
|
+
}, (0, react.createElement)(`span`, { className: `dsu-selectValue` }, D), (0, react.createElement)(`svg`, {
|
|
583
612
|
className: `dsu-chevron`,
|
|
584
613
|
width: 14,
|
|
585
614
|
height: 14,
|
|
@@ -593,15 +622,19 @@ function x(c) {
|
|
|
593
622
|
strokeLinecap: `round`,
|
|
594
623
|
strokeLinejoin: `round`
|
|
595
624
|
}))), (0, react.createElement)(`div`, {
|
|
596
|
-
ref:
|
|
597
|
-
id: `${
|
|
625
|
+
ref: g,
|
|
626
|
+
id: `${_}-list`,
|
|
598
627
|
role: `listbox`,
|
|
599
628
|
className: `dsu-menu`,
|
|
629
|
+
style: {
|
|
630
|
+
positionAnchor: b,
|
|
631
|
+
positionTryFallbacks: `flip-block, flip-inline`
|
|
632
|
+
},
|
|
600
633
|
"aria-label": c.label,
|
|
601
634
|
hidden: !l
|
|
602
|
-
}, ...
|
|
635
|
+
}, ...I)));
|
|
603
636
|
}
|
|
604
|
-
function
|
|
637
|
+
function w(t) {
|
|
605
638
|
let n = !t.writable || t.busy || !t.dirty, r;
|
|
606
639
|
return r = t.error === null ? t.writable ? t.dirty ? t.dirtyLabel : t.cleanLabel : t.readOnlyLabel : t.error, (0, react.createElement)(`div`, {
|
|
607
640
|
className: `dsu-savebar`,
|
|
@@ -618,7 +651,10 @@ function S(t) {
|
|
|
618
651
|
"data-field": `discard`,
|
|
619
652
|
disabled: n,
|
|
620
653
|
onClick: t.onDiscard
|
|
621
|
-
}, t.revertLabel), (0, react.createElement)(`span`, {
|
|
654
|
+
}, t.revertLabel), (0, react.createElement)(`span`, {
|
|
655
|
+
role: `status`,
|
|
656
|
+
className: t.error === null ? `dsu-status` : `dsu-status dsu-statusError`
|
|
657
|
+
}, r));
|
|
622
658
|
}
|
|
623
659
|
// node_modules/@jayyuen66/dsh-plugin-shared/dist/card-diff.js
|
|
624
660
|
function e$1(t, n, r) {
|
|
@@ -1189,7 +1225,7 @@ function numberDisplay(display, schema) {
|
|
|
1189
1225
|
/** 检索模型小节:embedding 下拉(按本地后端分组)+ 每组结果数。 */
|
|
1190
1226
|
function buildModelSection(deps) {
|
|
1191
1227
|
const { editable, fields, setField, t } = deps;
|
|
1192
|
-
const embedding = (0, react.createElement)(
|
|
1228
|
+
const embedding = (0, react.createElement)(C, {
|
|
1193
1229
|
label: t("embeddingLabel"),
|
|
1194
1230
|
...l(t("embeddingHint")),
|
|
1195
1231
|
field: "defaultEmbedding",
|
|
@@ -1200,7 +1236,7 @@ function buildModelSection(deps) {
|
|
|
1200
1236
|
setField("defaultEmbedding", next);
|
|
1201
1237
|
}
|
|
1202
1238
|
});
|
|
1203
|
-
const limit = (0, react.createElement)(
|
|
1239
|
+
const limit = (0, react.createElement)(b, {
|
|
1204
1240
|
label: t("limitLabel"),
|
|
1205
1241
|
hint: t("limitInvalid", {
|
|
1206
1242
|
min: 1,
|
|
@@ -1244,7 +1280,7 @@ function buildRebuildField(deps) {
|
|
|
1244
1280
|
disabled: rebuild.phase === "running",
|
|
1245
1281
|
onClick: deps.onRebuild
|
|
1246
1282
|
}, rebuild.phase === "running" ? t("rebuildRunning") : t("rebuildButton"));
|
|
1247
|
-
return (0, react.createElement)(
|
|
1283
|
+
return (0, react.createElement)(v, {
|
|
1248
1284
|
label: t("rebuildLabel"),
|
|
1249
1285
|
...l(rebuildHintText(t, fields.embedding, roots.length > 0)),
|
|
1250
1286
|
wide: true
|
|
@@ -1277,7 +1313,7 @@ function buildRebuildStatusRow(deps) {
|
|
|
1277
1313
|
/** 网络与索引小节:传输三档、镜像地址、search-first 开关、配额与时效、工作区重建与守护进程状态。 */
|
|
1278
1314
|
function buildIndexSection(deps) {
|
|
1279
1315
|
const { editable, fields, setField, t } = deps;
|
|
1280
|
-
const transport = (0, react.createElement)(
|
|
1316
|
+
const transport = (0, react.createElement)(C, {
|
|
1281
1317
|
label: t("transportLabel"),
|
|
1282
1318
|
...l(t("transportHint")),
|
|
1283
1319
|
field: "transport",
|
|
@@ -1288,7 +1324,7 @@ function buildIndexSection(deps) {
|
|
|
1288
1324
|
setField("transport", next);
|
|
1289
1325
|
}
|
|
1290
1326
|
});
|
|
1291
|
-
const endpoint = (0, react.createElement)(
|
|
1327
|
+
const endpoint = (0, react.createElement)(x, {
|
|
1292
1328
|
label: t("endpointLabel"),
|
|
1293
1329
|
...l(t("endpointHint")),
|
|
1294
1330
|
field: "hfEndpoint",
|
|
@@ -1300,7 +1336,7 @@ function buildIndexSection(deps) {
|
|
|
1300
1336
|
setField("hfEndpoint", next.trim() === "" ? void 0 : next.trim());
|
|
1301
1337
|
}
|
|
1302
1338
|
});
|
|
1303
|
-
const enforce = (0, react.createElement)(
|
|
1339
|
+
const enforce = (0, react.createElement)(y, {
|
|
1304
1340
|
label: t("enforceLabel"),
|
|
1305
1341
|
...l(t("enforceHint")),
|
|
1306
1342
|
field: "enforceSearchFirst",
|
|
@@ -1310,7 +1346,7 @@ function buildIndexSection(deps) {
|
|
|
1310
1346
|
setField("enforceSearchFirst", next);
|
|
1311
1347
|
}
|
|
1312
1348
|
});
|
|
1313
|
-
const budget = (0, react.createElement)(
|
|
1349
|
+
const budget = (0, react.createElement)(b, {
|
|
1314
1350
|
label: t("budgetLabel"),
|
|
1315
1351
|
...l(t("budgetHint", { default: 3 })),
|
|
1316
1352
|
field: "grepBudgetPerSearch",
|
|
@@ -1325,7 +1361,7 @@ function buildIndexSection(deps) {
|
|
|
1325
1361
|
setField("grepBudgetPerSearch", next);
|
|
1326
1362
|
}
|
|
1327
1363
|
});
|
|
1328
|
-
const window = (0, react.createElement)(
|
|
1364
|
+
const window = (0, react.createElement)(b, {
|
|
1329
1365
|
label: t("windowLabel"),
|
|
1330
1366
|
...l(t("windowHint", { default: 10 })),
|
|
1331
1367
|
field: "unlockWindowMin",
|
|
@@ -1345,7 +1381,7 @@ function buildIndexSection(deps) {
|
|
|
1345
1381
|
/** 卡片主体:检索模型 / 网络与索引两节 + 保存条。 */
|
|
1346
1382
|
function buildCardBody(deps) {
|
|
1347
1383
|
const { t } = deps;
|
|
1348
|
-
const saveBar = (0, react.createElement)(
|
|
1384
|
+
const saveBar = (0, react.createElement)(w, {
|
|
1349
1385
|
dirty: deps.dirty,
|
|
1350
1386
|
busy: deps.busy,
|
|
1351
1387
|
writable: deps.writable,
|