@lemoncat7/dsh-knowledge 1.1.4 → 1.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -2
- package/docs/architecture.md +3 -3
- package/lib/api.d.ts +2 -0
- package/lib/api.d.ts.map +1 -1
- package/lib/api.js +41 -12
- package/lib/api.js.map +1 -1
- package/lib/atomic-file.d.ts +16 -0
- package/lib/atomic-file.d.ts.map +1 -0
- package/lib/atomic-file.js +93 -0
- package/lib/atomic-file.js.map +1 -0
- package/lib/client.js +101 -104
- package/lib/client.js.map +4 -4
- package/lib/config.d.ts.map +1 -1
- package/lib/config.js +2 -5
- package/lib/config.js.map +1 -1
- package/lib/connection.d.ts.map +1 -1
- package/lib/connection.js +5 -15
- package/lib/connection.js.map +1 -1
- package/lib/documents/projection-queue.d.ts +10 -0
- package/lib/documents/projection-queue.d.ts.map +1 -0
- package/lib/documents/projection-queue.js +21 -0
- package/lib/documents/projection-queue.js.map +1 -0
- package/lib/documents/store.d.ts +4 -2
- package/lib/documents/store.d.ts.map +1 -1
- package/lib/documents/store.js +54 -73
- package/lib/documents/store.js.map +1 -1
- package/lib/extraction.d.ts.map +1 -1
- package/lib/extraction.js +10 -2
- package/lib/extraction.js.map +1 -1
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +85 -31
- package/lib/index.js.map +1 -1
- package/lib/knowledge-merge.d.ts +8 -0
- package/lib/knowledge-merge.d.ts.map +1 -0
- package/lib/knowledge-merge.js +19 -0
- package/lib/knowledge-merge.js.map +1 -0
- package/lib/local-provider.d.ts +2 -0
- package/lib/local-provider.d.ts.map +1 -1
- package/lib/local-provider.js +100 -61
- package/lib/local-provider.js.map +1 -1
- package/lib/remote-provider.d.ts.map +1 -1
- package/lib/remote-provider.js +34 -2
- package/lib/remote-provider.js.map +1 -1
- package/lib/remote-url.d.ts +2 -0
- package/lib/remote-url.d.ts.map +1 -0
- package/lib/remote-url.js +14 -0
- package/lib/remote-url.js.map +1 -0
- package/lib/service-settings.d.ts.map +1 -1
- package/lib/service-settings.js +3 -10
- package/lib/service-settings.js.map +1 -1
- package/lib/tools.js +44 -1
- package/lib/tools.js.map +1 -1
- package/lib/web-change-review.d.ts +34 -0
- package/lib/web-change-review.d.ts.map +1 -0
- package/lib/web-change-review.js +147 -0
- package/lib/web-change-review.js.map +1 -0
- package/lib/web.d.ts.map +1 -1
- package/lib/web.js +1 -0
- package/lib/web.js.map +1 -1
- package/lib/workspace-ownership.d.ts +5 -0
- package/lib/workspace-ownership.d.ts.map +1 -0
- package/lib/workspace-ownership.js +18 -0
- package/lib/workspace-ownership.js.map +1 -0
- package/package.json +1 -2
- package/web/app.js +287 -81
- package/web/change-review.js +5 -0
- package/web/index.html +1 -0
- package/web/styles.css +100 -23
package/lib/client.js
CHANGED
|
@@ -25,25 +25,22 @@ __export(client_exports, {
|
|
|
25
25
|
inject: () => inject
|
|
26
26
|
});
|
|
27
27
|
module.exports = __toCommonJS(client_exports);
|
|
28
|
-
var import_react2 = require("react");
|
|
29
|
-
|
|
30
|
-
// node_modules/@lemoncat7/dsh-plugin-ui/lib/index.js
|
|
31
|
-
var import_jsx_runtime = require("react/jsx-runtime");
|
|
32
28
|
var import_react = require("react");
|
|
33
|
-
|
|
29
|
+
|
|
30
|
+
// src/workspace-ownership.ts
|
|
31
|
+
var WORKSPACE_ACTIVATE_EVENT = "@lemoncat7/dsh-plugin-ui/workspace-activate";
|
|
34
32
|
function activatePluginWorkspace(pluginId) {
|
|
35
|
-
window.dispatchEvent(new CustomEvent(
|
|
33
|
+
window.dispatchEvent(new CustomEvent(WORKSPACE_ACTIVATE_EVENT, {
|
|
36
34
|
detail: { pluginId }
|
|
37
35
|
}));
|
|
38
36
|
}
|
|
39
37
|
function observePluginWorkspace(pluginId, close) {
|
|
40
38
|
const onActivate = (event) => {
|
|
41
39
|
const detail = event.detail;
|
|
42
|
-
if (detail?.pluginId !== pluginId)
|
|
43
|
-
close();
|
|
40
|
+
if (detail?.pluginId !== pluginId) close();
|
|
44
41
|
};
|
|
45
|
-
window.addEventListener(
|
|
46
|
-
return () => window.removeEventListener(
|
|
42
|
+
window.addEventListener(WORKSPACE_ACTIVATE_EVENT, onActivate);
|
|
43
|
+
return () => window.removeEventListener(WORKSPACE_ACTIVATE_EVENT, onActivate);
|
|
47
44
|
}
|
|
48
45
|
|
|
49
46
|
// src/client.tsx
|
|
@@ -154,7 +151,7 @@ function firstDefinedToken(computed, snapshotTokens, sources) {
|
|
|
154
151
|
}
|
|
155
152
|
|
|
156
153
|
// src/client.tsx
|
|
157
|
-
var
|
|
154
|
+
var import_jsx_runtime = require("react/jsx-runtime");
|
|
158
155
|
var PLUGIN_ID = "@lemoncat7/dsh-knowledge";
|
|
159
156
|
var STYLE_ID = `${PLUGIN_ID}/client`;
|
|
160
157
|
var CONNECTION_CONTROL_PATH = "/knowledge-control/v1/connection";
|
|
@@ -170,7 +167,7 @@ function apply(ctx) {
|
|
|
170
167
|
name: "sidebar.footer.action",
|
|
171
168
|
id: "knowledge",
|
|
172
169
|
order: -10
|
|
173
|
-
}, (props) => /* @__PURE__ */ (0,
|
|
170
|
+
}, (props) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(KnowledgeLauncher, { ...props, workspace })));
|
|
174
171
|
ctx.slots.inject("settings.plugin.item", () => ctx.slots.register({
|
|
175
172
|
name: "settings.plugin.item",
|
|
176
173
|
key: KNOWLEDGE_SETTINGS_NAMESPACE
|
|
@@ -178,15 +175,15 @@ function apply(ctx) {
|
|
|
178
175
|
ctx.slots.inject("conversation.chat.turnTail", () => ctx.slots.register({
|
|
179
176
|
name: "conversation.chat.turnTail",
|
|
180
177
|
select: (owner) => ({ turn: owner.turn.turn })
|
|
181
|
-
}, (props) => /* @__PURE__ */ (0,
|
|
178
|
+
}, (props) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(KnowledgeWritebackStatus, { sessionId: String(props.sessionId), turn: props.matched.turn })));
|
|
182
179
|
}
|
|
183
180
|
function KnowledgeWritebackStatus({ sessionId, turn }) {
|
|
184
|
-
const [state, setState] = (0,
|
|
185
|
-
const [retrying, setRetrying] = (0,
|
|
186
|
-
(0,
|
|
181
|
+
const [state, setState] = (0, import_react.useState)();
|
|
182
|
+
const [retrying, setRetrying] = (0, import_react.useState)(false);
|
|
183
|
+
(0, import_react.useEffect)(() => {
|
|
187
184
|
const controller = new AbortController();
|
|
188
185
|
void fetch(`/knowledge-control/v1/writeback-status?sessionId=${encodeURIComponent(sessionId)}&turn=${turn}`, {
|
|
189
|
-
headers: { accept: "application/json" },
|
|
186
|
+
headers: { accept: "application/json", "x-dsh-knowledge-client": "conversation-web" },
|
|
190
187
|
signal: controller.signal
|
|
191
188
|
}).then(async (response) => response.ok ? response.json() : void 0).then((value) => {
|
|
192
189
|
if (value?.summary) setState(value);
|
|
@@ -216,11 +213,11 @@ function KnowledgeWritebackStatus({ sessionId, turn }) {
|
|
|
216
213
|
setRetrying(false);
|
|
217
214
|
}
|
|
218
215
|
};
|
|
219
|
-
return /* @__PURE__ */ (0,
|
|
220
|
-
/* @__PURE__ */ (0,
|
|
221
|
-
/* @__PURE__ */ (0,
|
|
222
|
-
/* @__PURE__ */ (0,
|
|
223
|
-
state.status === "failed" && state.retryable && /* @__PURE__ */ (0,
|
|
216
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "dsh-knowledge-writeback-status", children: [
|
|
217
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { children: "\u4E0A\u4E0B\u6587\u6CE8\u5165" }),
|
|
218
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("strong", { children: "dsh-knowledge" }),
|
|
219
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { title: state.error, children: state.summary }),
|
|
220
|
+
state.status === "failed" && state.retryable && /* @__PURE__ */ (0, import_jsx_runtime.jsx)("button", { type: "button", disabled: retrying, onClick: () => {
|
|
224
221
|
void retry();
|
|
225
222
|
}, children: retrying ? "\u91CD\u8BD5\u4E2D\u2026" : "\u91CD\u8BD5" })
|
|
226
223
|
] });
|
|
@@ -243,7 +240,7 @@ function createKnowledgeWorkspaceController(client) {
|
|
|
243
240
|
toggle: () => {
|
|
244
241
|
if (disposeWorkspace !== void 0) return close();
|
|
245
242
|
activatePluginWorkspace(PLUGIN_ID);
|
|
246
|
-
const dispose = client.slots.register({ name: "conversation", priority: -1 }, (props) => /* @__PURE__ */ (0,
|
|
243
|
+
const dispose = client.slots.register({ name: "conversation", priority: -1 }, (props) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(KnowledgeWorkspace, { ...props, client, workspace: controller }));
|
|
247
244
|
disposeWorkspace = dispose;
|
|
248
245
|
notify();
|
|
249
246
|
},
|
|
@@ -258,18 +255,18 @@ function createKnowledgeWorkspaceController(client) {
|
|
|
258
255
|
return controller;
|
|
259
256
|
}
|
|
260
257
|
function KnowledgeConnectionCard() {
|
|
261
|
-
const [current, setCurrent] = (0,
|
|
262
|
-
const [loadState, setLoadState] = (0,
|
|
263
|
-
const [loadError, setLoadError] = (0,
|
|
264
|
-
const [open, setOpen] = (0,
|
|
265
|
-
const [backend, setBackend] = (0,
|
|
266
|
-
const [remoteUrl, setRemoteUrl] = (0,
|
|
267
|
-
const [remoteToken, setRemoteToken] = (0,
|
|
268
|
-
const [timeout, setTimeoutValue] = (0,
|
|
269
|
-
const [dirty, setDirty] = (0,
|
|
270
|
-
const [saving, setSaving] = (0,
|
|
271
|
-
const [message, setMessage] = (0,
|
|
272
|
-
const load = (0,
|
|
258
|
+
const [current, setCurrent] = (0, import_react.useState)();
|
|
259
|
+
const [loadState, setLoadState] = (0, import_react.useState)("loading");
|
|
260
|
+
const [loadError, setLoadError] = (0, import_react.useState)("");
|
|
261
|
+
const [open, setOpen] = (0, import_react.useState)(false);
|
|
262
|
+
const [backend, setBackend] = (0, import_react.useState)("local");
|
|
263
|
+
const [remoteUrl, setRemoteUrl] = (0, import_react.useState)("");
|
|
264
|
+
const [remoteToken, setRemoteToken] = (0, import_react.useState)("");
|
|
265
|
+
const [timeout, setTimeoutValue] = (0, import_react.useState)("10000");
|
|
266
|
+
const [dirty, setDirty] = (0, import_react.useState)(false);
|
|
267
|
+
const [saving, setSaving] = (0, import_react.useState)(false);
|
|
268
|
+
const [message, setMessage] = (0, import_react.useState)();
|
|
269
|
+
const load = (0, import_react.useCallback)(async (signal) => {
|
|
273
270
|
setLoadState("loading");
|
|
274
271
|
setLoadError("");
|
|
275
272
|
try {
|
|
@@ -282,14 +279,14 @@ function KnowledgeConnectionCard() {
|
|
|
282
279
|
setLoadState("error");
|
|
283
280
|
}
|
|
284
281
|
}, []);
|
|
285
|
-
(0,
|
|
282
|
+
(0, import_react.useEffect)(() => {
|
|
286
283
|
const controller = new AbortController();
|
|
287
284
|
void load(controller.signal);
|
|
288
285
|
return () => {
|
|
289
286
|
controller.abort();
|
|
290
287
|
};
|
|
291
288
|
}, [load]);
|
|
292
|
-
(0,
|
|
289
|
+
(0, import_react.useEffect)(() => {
|
|
293
290
|
if (dirty || current === void 0) return;
|
|
294
291
|
setBackend(current.backend);
|
|
295
292
|
setRemoteUrl(current.remoteUrl ?? "");
|
|
@@ -337,75 +334,75 @@ function KnowledgeConnectionCard() {
|
|
|
337
334
|
setSaving(false);
|
|
338
335
|
}
|
|
339
336
|
};
|
|
340
|
-
return /* @__PURE__ */ (0,
|
|
341
|
-
/* @__PURE__ */ (0,
|
|
337
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("li", { className: `dsh-knowledge-settings-card${open ? " dsh-knowledge-settings-card--open" : ""}`, children: [
|
|
338
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("button", { type: "button", className: "dsh-knowledge-settings-header", "aria-expanded": open, onClick: () => {
|
|
342
339
|
setOpen((value) => !value);
|
|
343
340
|
}, children: [
|
|
344
|
-
/* @__PURE__ */ (0,
|
|
345
|
-
/* @__PURE__ */ (0,
|
|
346
|
-
/* @__PURE__ */ (0,
|
|
341
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("span", { children: [
|
|
342
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("strong", { children: "\u77E5\u8BC6\u5E93\u8FDE\u63A5" }),
|
|
343
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("small", { children: "\u9009\u62E9\u672C\u673A\u77E5\u8BC6\u5E93\uFF0C\u6216\u8FDE\u63A5\u4E00\u53F0\u4E2D\u592E DSH \u77E5\u8BC6\u5E93" })
|
|
347
344
|
] }),
|
|
348
|
-
/* @__PURE__ */ (0,
|
|
345
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("span", { className: "dsh-knowledge-settings-summary", children: [
|
|
349
346
|
loadState === "loading" ? "\u8BFB\u53D6\u4E2D" : loadState === "error" ? "\u8FDE\u63A5\u5165\u53E3" : current?.backend === "remote" ? "\u8FDC\u7A0B" : "\u672C\u5730",
|
|
350
|
-
/* @__PURE__ */ (0,
|
|
347
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("i", { "aria-hidden": "true" })
|
|
351
348
|
] })
|
|
352
349
|
] }),
|
|
353
|
-
open && /* @__PURE__ */ (0,
|
|
354
|
-
/* @__PURE__ */ (0,
|
|
355
|
-
/* @__PURE__ */ (0,
|
|
350
|
+
open && /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "dsh-knowledge-settings-body", children: loadState === "loading" ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)("p", { className: "dsh-knowledge-settings-note", role: "status", children: "\u6B63\u5728\u8BFB\u53D6\u8FDE\u63A5\u914D\u7F6E\u2026" }) : loadState === "error" ? /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "dsh-knowledge-settings-load-error", role: "alert", children: [
|
|
351
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("p", { children: loadError }),
|
|
352
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("button", { type: "button", onClick: () => {
|
|
356
353
|
void load();
|
|
357
354
|
}, children: "\u91CD\u65B0\u8BFB\u53D6" })
|
|
358
|
-
] }) : /* @__PURE__ */ (0,
|
|
359
|
-
/* @__PURE__ */ (0,
|
|
360
|
-
/* @__PURE__ */ (0,
|
|
361
|
-
/* @__PURE__ */ (0,
|
|
362
|
-
/* @__PURE__ */ (0,
|
|
355
|
+
] }) : /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, { children: [
|
|
356
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("fieldset", { className: "dsh-knowledge-source-picker", children: [
|
|
357
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("legend", { children: "\u77E5\u8BC6\u5E93\u6765\u6E90" }),
|
|
358
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("label", { className: backend === "local" ? "is-selected" : "", children: [
|
|
359
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("input", { type: "radio", name: "dsh-knowledge-backend", checked: backend === "local", onChange: () => edit(() => {
|
|
363
360
|
setBackend("local");
|
|
364
361
|
}) }),
|
|
365
|
-
/* @__PURE__ */ (0,
|
|
366
|
-
/* @__PURE__ */ (0,
|
|
367
|
-
/* @__PURE__ */ (0,
|
|
362
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("span", { children: [
|
|
363
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("strong", { children: "\u672C\u5730" }),
|
|
364
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("small", { children: "\u6570\u636E\u4FDD\u5B58\u5728\u5F53\u524D DSH \u7684 SQLite \u4E2D" })
|
|
368
365
|
] })
|
|
369
366
|
] }),
|
|
370
|
-
/* @__PURE__ */ (0,
|
|
371
|
-
/* @__PURE__ */ (0,
|
|
367
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("label", { className: `${backend === "remote" ? "is-selected" : ""}${!current?.canSwitchRemote ? " is-disabled" : ""}`, children: [
|
|
368
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("input", { type: "radio", name: "dsh-knowledge-backend", checked: backend === "remote", disabled: !current?.canSwitchRemote, onChange: () => edit(() => {
|
|
372
369
|
setBackend("remote");
|
|
373
370
|
}) }),
|
|
374
|
-
/* @__PURE__ */ (0,
|
|
375
|
-
/* @__PURE__ */ (0,
|
|
376
|
-
/* @__PURE__ */ (0,
|
|
371
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("span", { children: [
|
|
372
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("strong", { children: "\u8FDC\u7A0B" }),
|
|
373
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("small", { children: "\u53EC\u56DE\u548C\u56DE\u5199\u7EDF\u4E00\u4F7F\u7528\u4E2D\u592E\u77E5\u8BC6\u5E93" })
|
|
377
374
|
] })
|
|
378
375
|
] })
|
|
379
376
|
] }),
|
|
380
|
-
!current?.canSwitchRemote && /* @__PURE__ */ (0,
|
|
381
|
-
backend === "remote" && /* @__PURE__ */ (0,
|
|
382
|
-
/* @__PURE__ */ (0,
|
|
377
|
+
!current?.canSwitchRemote && /* @__PURE__ */ (0, import_jsx_runtime.jsx)("p", { className: "dsh-knowledge-settings-note", children: "\u5F53\u524D\u5B9E\u4F8B\u662F\u4E2D\u592E\u77E5\u8BC6\u5E93\u670D\u52A1\uFF0C\u4E0D\u80FD\u518D\u5207\u6362\u5230\u53E6\u4E00\u53F0\u8FDC\u7A0B\u670D\u52A1\u3002" }),
|
|
378
|
+
backend === "remote" && /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "dsh-knowledge-remote-fields", children: [
|
|
379
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("label", { htmlFor: "dsh-knowledge-remote-url", children: [
|
|
383
380
|
"\u670D\u52A1\u5668\u5730\u5740",
|
|
384
|
-
/* @__PURE__ */ (0,
|
|
381
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("input", { id: "dsh-knowledge-remote-url", type: "url", value: remoteUrl, placeholder: "https://example.com/knowledge-api/v1", autoComplete: "url", onChange: (event) => edit(() => {
|
|
385
382
|
setRemoteUrl(event.target.value);
|
|
386
383
|
}), "aria-invalid": urlError !== void 0, "aria-describedby": urlError ? "dsh-knowledge-url-error" : void 0 }),
|
|
387
|
-
urlError && /* @__PURE__ */ (0,
|
|
384
|
+
urlError && /* @__PURE__ */ (0, import_jsx_runtime.jsx)("small", { id: "dsh-knowledge-url-error", className: "dsh-knowledge-field-error", children: urlError })
|
|
388
385
|
] }),
|
|
389
|
-
/* @__PURE__ */ (0,
|
|
386
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("label", { htmlFor: "dsh-knowledge-remote-token", children: [
|
|
390
387
|
"\u5BA2\u6237\u7AEF\u4EE4\u724C",
|
|
391
|
-
/* @__PURE__ */ (0,
|
|
388
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("input", { id: "dsh-knowledge-remote-token", type: "password", value: remoteToken, placeholder: current?.tokenConfigured ? "\u5DF2\u4FDD\u5B58\uFF1B\u7559\u7A7A\u5219\u4FDD\u6301\u4E0D\u53D8" : "\u7C98\u8D34\u5BA2\u6237\u7AEF\u4EE4\u724C", autoComplete: "new-password", onChange: (event) => edit(() => {
|
|
392
389
|
setRemoteToken(event.target.value);
|
|
393
390
|
}), "aria-invalid": tokenError !== void 0, "aria-describedby": "dsh-knowledge-token-help" }),
|
|
394
|
-
/* @__PURE__ */ (0,
|
|
391
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("small", { id: "dsh-knowledge-token-help", className: tokenError ? "dsh-knowledge-field-error" : void 0, children: tokenError ?? (current?.tokenConfigured ? "\u4EE4\u724C\u5DF2\u5B89\u5168\u4FDD\u5B58\uFF0C\u9875\u9762\u65E0\u6CD5\u8BFB\u53D6\uFF1B\u8F93\u5165\u65B0\u4EE4\u724C\u53EF\u8986\u76D6\u3002" : "\u4EE4\u724C\u4FDD\u5B58\u540E\u4E0D\u53EF\u8BFB\u53D6\uFF0C\u53EA\u80FD\u8986\u76D6\u3002") })
|
|
395
392
|
] })
|
|
396
393
|
] }),
|
|
397
|
-
/* @__PURE__ */ (0,
|
|
394
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("label", { className: "dsh-knowledge-timeout-field", htmlFor: "dsh-knowledge-timeout", children: [
|
|
398
395
|
"\u8BF7\u6C42\u8D85\u65F6\uFF08\u6BEB\u79D2\uFF09",
|
|
399
|
-
/* @__PURE__ */ (0,
|
|
396
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("input", { id: "dsh-knowledge-timeout", type: "number", min: "100", max: "120000", step: "100", value: timeout, onChange: (event) => edit(() => {
|
|
400
397
|
setTimeoutValue(event.target.value);
|
|
401
398
|
}), "aria-invalid": timeoutError !== void 0 }),
|
|
402
|
-
timeoutError && /* @__PURE__ */ (0,
|
|
399
|
+
timeoutError && /* @__PURE__ */ (0, import_jsx_runtime.jsx)("small", { className: "dsh-knowledge-field-error", children: timeoutError })
|
|
403
400
|
] }),
|
|
404
|
-
!current?.writable && /* @__PURE__ */ (0,
|
|
405
|
-
message && /* @__PURE__ */ (0,
|
|
406
|
-
/* @__PURE__ */ (0,
|
|
407
|
-
/* @__PURE__ */ (0,
|
|
408
|
-
/* @__PURE__ */ (0,
|
|
401
|
+
!current?.writable && /* @__PURE__ */ (0, import_jsx_runtime.jsx)("p", { className: "dsh-knowledge-settings-note", children: "\u5F53\u524D\u63D2\u4EF6\u6CA1\u6709\u914D\u7F6E\u6301\u4E45\u5316\u8DEF\u5F84\uFF0C\u65E0\u6CD5\u4FDD\u5B58\u8FDE\u63A5\u3002" }),
|
|
402
|
+
message && /* @__PURE__ */ (0, import_jsx_runtime.jsx)("p", { className: `dsh-knowledge-settings-message is-${message.kind}`, role: message.kind === "error" ? "alert" : "status", "aria-live": "polite", children: message.text }),
|
|
403
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "dsh-knowledge-settings-actions", children: [
|
|
404
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("button", { type: "button", onClick: reset, disabled: !dirty || saving, children: "\u653E\u5F03\u66F4\u6539" }),
|
|
405
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("button", { type: "button", className: "is-primary", onClick: () => {
|
|
409
406
|
void save();
|
|
410
407
|
}, disabled: !dirty || invalid || saving || !current?.writable, children: saving ? "\u6B63\u5728\u9A8C\u8BC1\u2026" : "\u9A8C\u8BC1\u5E76\u8FDE\u63A5" })
|
|
411
408
|
] })
|
|
@@ -451,11 +448,11 @@ function isManagementPath(value) {
|
|
|
451
448
|
return typeof value === "string" && value.startsWith("/") && !value.startsWith("//");
|
|
452
449
|
}
|
|
453
450
|
function KnowledgeLauncher({ wide, workspace }) {
|
|
454
|
-
const [open, setOpen] = (0,
|
|
455
|
-
(0,
|
|
451
|
+
const [open, setOpen] = (0, import_react.useState)(workspace.isOpen());
|
|
452
|
+
(0, import_react.useEffect)(() => workspace.subscribe(() => {
|
|
456
453
|
setOpen(workspace.isOpen());
|
|
457
454
|
}), [workspace]);
|
|
458
|
-
return /* @__PURE__ */ (0,
|
|
455
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
|
|
459
456
|
"button",
|
|
460
457
|
{
|
|
461
458
|
type: "button",
|
|
@@ -467,8 +464,8 @@ function KnowledgeLauncher({ wide, workspace }) {
|
|
|
467
464
|
workspace.toggle();
|
|
468
465
|
},
|
|
469
466
|
children: [
|
|
470
|
-
/* @__PURE__ */ (0,
|
|
471
|
-
wide && /* @__PURE__ */ (0,
|
|
467
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_dsh_client_ui_primitives.IconDataOutline16, { size: wide ? 16 : 18 }),
|
|
468
|
+
wide && /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { children: open ? "\u8FD4\u56DE\u5BF9\u8BDD" : "\u77E5\u8BC6\u5E93" })
|
|
472
469
|
]
|
|
473
470
|
}
|
|
474
471
|
);
|
|
@@ -479,14 +476,14 @@ function KnowledgeWorkspace({
|
|
|
479
476
|
client,
|
|
480
477
|
workspace
|
|
481
478
|
}) {
|
|
482
|
-
const [panelState, setPanelState] = (0,
|
|
483
|
-
const [managementPath, setManagementPath] = (0,
|
|
484
|
-
const [panelError, setPanelError] = (0,
|
|
479
|
+
const [panelState, setPanelState] = (0, import_react.useState)("loading");
|
|
480
|
+
const [managementPath, setManagementPath] = (0, import_react.useState)();
|
|
481
|
+
const [panelError, setPanelError] = (0, import_react.useState)("");
|
|
485
482
|
const projectId = useSessions((state) => sessionId === void 0 ? void 0 : state.byId[sessionId]?.cwd);
|
|
486
483
|
const knowledgeUrl = managementPath === void 0 ? void 0 : knowledgePanelUrl(managementPath, sessionId, projectId);
|
|
487
|
-
const frame = (0,
|
|
488
|
-
const themeFrame = (0,
|
|
489
|
-
const loadManagement = (0,
|
|
484
|
+
const frame = (0, import_react.useRef)(null);
|
|
485
|
+
const themeFrame = (0, import_react.useRef)(0);
|
|
486
|
+
const loadManagement = (0, import_react.useCallback)(async () => {
|
|
490
487
|
setPanelState("loading");
|
|
491
488
|
setPanelError("");
|
|
492
489
|
try {
|
|
@@ -504,10 +501,10 @@ function KnowledgeWorkspace({
|
|
|
504
501
|
setPanelState("error");
|
|
505
502
|
}
|
|
506
503
|
}, []);
|
|
507
|
-
(0,
|
|
504
|
+
(0, import_react.useEffect)(() => {
|
|
508
505
|
void loadManagement();
|
|
509
506
|
}, [loadManagement]);
|
|
510
|
-
const sendTheme = (0,
|
|
507
|
+
const sendTheme = (0, import_react.useCallback)(() => {
|
|
511
508
|
const currentFrame = frame.current;
|
|
512
509
|
if (currentFrame === null) return;
|
|
513
510
|
const target = currentFrame.contentWindow;
|
|
@@ -518,14 +515,14 @@ function KnowledgeWorkspace({
|
|
|
518
515
|
frameOrigin(currentFrame) ?? "*"
|
|
519
516
|
);
|
|
520
517
|
}, [client]);
|
|
521
|
-
const scheduleTheme = (0,
|
|
518
|
+
const scheduleTheme = (0, import_react.useCallback)(() => {
|
|
522
519
|
if (themeFrame.current !== 0) window.cancelAnimationFrame(themeFrame.current);
|
|
523
520
|
themeFrame.current = window.requestAnimationFrame(() => {
|
|
524
521
|
themeFrame.current = 0;
|
|
525
522
|
sendTheme();
|
|
526
523
|
});
|
|
527
524
|
}, [sendTheme]);
|
|
528
|
-
(0,
|
|
525
|
+
(0, import_react.useEffect)(() => {
|
|
529
526
|
const off = client.on("theme/change", scheduleTheme);
|
|
530
527
|
const onMessage = (event) => {
|
|
531
528
|
const currentFrame = frame.current;
|
|
@@ -543,21 +540,21 @@ function KnowledgeWorkspace({
|
|
|
543
540
|
if (themeFrame.current !== 0) window.cancelAnimationFrame(themeFrame.current);
|
|
544
541
|
};
|
|
545
542
|
}, [client, scheduleTheme, sendTheme]);
|
|
546
|
-
return /* @__PURE__ */ (0,
|
|
547
|
-
/* @__PURE__ */ (0,
|
|
548
|
-
/* @__PURE__ */ (0,
|
|
549
|
-
/* @__PURE__ */ (0,
|
|
550
|
-
/* @__PURE__ */ (0,
|
|
551
|
-
/* @__PURE__ */ (0,
|
|
552
|
-
/* @__PURE__ */ (0,
|
|
543
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("section", { className: "dsh-knowledge-workspace", "data-xiaohei-surface": "plugin-workspace", "aria-labelledby": "dsh-knowledge-workspace-title", children: [
|
|
544
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("header", { className: "dsh-knowledge-workspace-header", children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { children: [
|
|
545
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("button", { type: "button", "data-xiaohei-workspace-close": true, onClick: workspace.close, "aria-label": "\u8FD4\u56DE\u4F1A\u8BDD", title: "\u8FD4\u56DE\u4F1A\u8BDD", children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_dsh_client_ui_primitives.IconChevronLeftOutline14, { size: 15 }) }),
|
|
546
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_dsh_client_ui_primitives.IconDataOutline16, { size: 18 }),
|
|
547
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("span", { children: [
|
|
548
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("h2", { id: "dsh-knowledge-workspace-title", children: "\u77E5\u8BC6\u5E93" }),
|
|
549
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("p", { children: "\u6587\u6863\u3001\u5BA1\u6838\u3001\u6302\u8F7D\u4E0E\u8BBF\u95EE\u7BA1\u7406" })
|
|
553
550
|
] })
|
|
554
551
|
] }) }),
|
|
555
|
-
panelState === "ready" && knowledgeUrl !== void 0 ? /* @__PURE__ */ (0,
|
|
556
|
-
/* @__PURE__ */ (0,
|
|
557
|
-
/* @__PURE__ */ (0,
|
|
558
|
-
/* @__PURE__ */ (0,
|
|
559
|
-
/* @__PURE__ */ (0,
|
|
560
|
-
panelState === "error" && /* @__PURE__ */ (0,
|
|
552
|
+
panelState === "ready" && knowledgeUrl !== void 0 ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)("iframe", { ref: frame, className: "dsh-knowledge-frame", src: knowledgeUrl, title: "\u77E5\u8BC6\u5E93\u7BA1\u7406\u53F0", onLoad: sendTheme }) : /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "dsh-knowledge-panel-state", role: panelState === "error" ? "alert" : "status", "aria-live": "polite", children: [
|
|
553
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: "dsh-knowledge-panel-state-icon", "aria-hidden": "true", children: panelState === "loading" ? "\xB7\xB7\xB7" : panelState === "error" ? "!" : "\u2014" }),
|
|
554
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { children: [
|
|
555
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("h3", { children: panelState === "loading" ? "\u6B63\u5728\u6253\u5F00\u77E5\u8BC6\u5E93\u2026" : panelState === "error" ? "\u6682\u65F6\u65E0\u6CD5\u6253\u5F00\u77E5\u8BC6\u5E93" : "\u8FD9\u53F0 DSH \u672A\u542F\u7528\u77E5\u8BC6\u5E93\u7BA1\u7406\u53F0" }),
|
|
556
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("p", { children: panelState === "loading" ? "\u6B63\u5728\u786E\u8BA4\u5F53\u524D\u5B9E\u4F8B\u662F\u5426\u63D0\u4F9B\u7BA1\u7406\u9875\u9762\u3002" : panelState === "error" ? panelError : "\u672C\u5730\u53EC\u56DE\u548C\u56DE\u5199\u4ECD\u53EF\u4F7F\u7528\u3002\u5F53\u524D profile \u5DF2\u663E\u5F0F\u5173\u95ED exposeWeb\uFF1B\u91CD\u65B0\u542F\u7528\u540E\u5373\u53EF\u5728\u8FD9\u91CC\u7BA1\u7406\u3002\u4F7F\u7528\u8FDC\u7A0B\u77E5\u8BC6\u5E93\u65F6\uFF0C\u8BF7\u524D\u5F80\u4E2D\u592E DSH \u7684\u77E5\u8BC6\u5E93\u7BA1\u7406\u53F0\u3002" }),
|
|
557
|
+
panelState === "error" && /* @__PURE__ */ (0, import_jsx_runtime.jsx)("button", { type: "button", onClick: () => {
|
|
561
558
|
void loadManagement();
|
|
562
559
|
}, children: "\u91CD\u8BD5" })
|
|
563
560
|
] })
|