@lemoncat7/dsh-knowledge 0.7.2 → 1.0.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 +16 -15
- package/cordis.patch.yml +0 -1
- package/docs/architecture.md +37 -19
- package/docs/document-knowledge-design.zh-CN.md +2 -2
- package/docs/requirements.md +9 -5
- package/lib/api.js +5 -1
- package/lib/api.js.map +1 -1
- package/lib/client.d.ts +6 -0
- package/lib/client.d.ts.map +1 -0
- package/lib/client.js +210 -170
- package/lib/client.js.map +3 -3
- package/lib/config.d.ts +2 -0
- package/lib/config.d.ts.map +1 -1
- package/lib/config.js +5 -3
- package/lib/config.js.map +1 -1
- package/lib/constants.d.ts +3 -0
- package/lib/constants.d.ts.map +1 -0
- package/lib/constants.js +3 -0
- package/lib/constants.js.map +1 -0
- package/lib/documents/markdown.d.ts +33 -0
- package/lib/documents/markdown.d.ts.map +1 -0
- package/lib/documents/markdown.js +91 -0
- package/lib/documents/markdown.js.map +1 -0
- package/lib/documents/path.d.ts +4 -0
- package/lib/documents/path.d.ts.map +1 -0
- package/lib/documents/path.js +11 -0
- package/lib/documents/path.js.map +1 -0
- package/lib/documents/store.d.ts +32 -0
- package/lib/documents/store.d.ts.map +1 -0
- package/lib/documents/store.js +272 -0
- package/lib/documents/store.js.map +1 -0
- package/lib/domain.d.ts +2 -0
- package/lib/domain.d.ts.map +1 -1
- package/lib/domain.js +6 -0
- package/lib/domain.js.map +1 -1
- package/lib/extraction.d.ts.map +1 -1
- package/lib/extraction.js +210 -73
- package/lib/extraction.js.map +1 -1
- package/lib/index.d.ts +3 -2
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +9 -4
- package/lib/index.js.map +1 -1
- package/lib/local-provider.d.ts +2 -0
- package/lib/local-provider.d.ts.map +1 -1
- package/lib/local-provider.js +145 -79
- package/lib/local-provider.js.map +1 -1
- package/lib/recall.d.ts +7 -2
- package/lib/recall.d.ts.map +1 -1
- package/lib/recall.js +46 -30
- package/lib/recall.js.map +1 -1
- package/lib/retrieval.d.ts +14 -4
- package/lib/retrieval.d.ts.map +1 -1
- package/lib/retrieval.js +133 -25
- package/lib/retrieval.js.map +1 -1
- package/lib/runtime.d.ts +5 -0
- package/lib/runtime.d.ts.map +1 -1
- package/lib/runtime.js.map +1 -1
- package/lib/theme-bridge.d.ts +23 -0
- package/lib/theme-bridge.d.ts.map +1 -0
- package/lib/theme-bridge.js +72 -0
- package/lib/theme-bridge.js.map +1 -0
- package/lib/tools.d.ts.map +1 -1
- package/lib/tools.js +165 -7
- package/lib/tools.js.map +1 -1
- package/lib/web-markdown-preview.d.ts +3 -0
- package/lib/web-markdown-preview.d.ts.map +1 -0
- package/lib/web-markdown-preview.js +24 -0
- package/lib/web-markdown-preview.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/package.json +16 -3
- package/web/app.js +326 -359
- package/web/index.html +1 -0
- package/web/markdown-preview.js +72 -0
- package/web/styles.css +177 -200
package/lib/client.js
CHANGED
|
@@ -29,29 +29,161 @@ var import_react = require("react");
|
|
|
29
29
|
var import_dsh_client_ui_primitives = require("@deepseek-ai/dsh-client-ui-primitives");
|
|
30
30
|
|
|
31
31
|
// src/client.css
|
|
32
|
-
var client_default = ".dsh-knowledge-trigger {\n flex: none;\n display: flex;\n align-items: center;\n gap: 8px;\n width: calc(100% + 8px);\n height: 34px;\n margin: 4px -4px;\n padding: 6px 2px 6px 10px;\n box-sizing: border-box;\n border: 0;\n border-radius: 12px;\n overflow: hidden;\n background: transparent;\n color: var(--dsw-alias-label-primary);\n cursor: pointer;\n font: inherit;\n font-size: 14px;\n line-height: 22px;\n white-space: nowrap;\n}\n\n.dsh-knowledge-trigger:hover {\n background: var(--dsw-alias-interactive-bg-hover);\n}\n\n.dsh-knowledge-trigger--rail {\n width: 36px;\n height: 36px;\n margin: 8px 0 4px;\n padding: 0;\n justify-content: center;\n gap: 0;\n border-radius: 50%;\n}\n\n.dsh-knowledge-overlay {\n position: fixed;\n inset: 0;\n z-index: 1000;\n display: flex;\n align-items: center;\n justify-content: center;\n padding: 24px;\n box-sizing: border-box;\n}\n\n.dsh-knowledge-mask {\n position: absolute;\n inset: 0;\n background: var(--dsw-alias-bg-mask-1);\n backdrop-filter: var(--dsw-mask-blur);\n}\n\n.dsh-knowledge-panel {\n position: relative;\n z-index: 1;\n display: flex;\n flex-direction: column;\n width: min(1180px, calc(100vw - 48px));\n height: min(860px, calc(100vh - 48px));\n min-width: min(1040px, calc(100vw - 32px));\n min-height: 460px;\n max-width: calc(100vw - 32px);\n max-height: calc(100vh - 32px);\n border-radius: 24px;\n overflow: hidden;\n background: var(--dsw-alias-bg-layer-2);\n box-shadow: var(--dsw-shadow-lv3);\n resize: both;\n}\n\n.dsh-knowledge-panel--maximized {\n width: calc(100vw - 32px);\n height: calc(100vh - 32px);\n resize: none;\n}\n\n.dsh-knowledge-header {\n flex: none;\n display: flex;\n align-items: center;\n justify-content: space-between;\n gap: 16px;\n min-height: 68px;\n padding: 10px 16px 10px 24px;\n box-sizing: border-box;\n border-bottom: 1px solid var(--dsw-alias-divider-primary, rgba(128, 128, 128, .18));\n}\n\n.dsh-knowledge-window-actions {\n flex: none;\n display: flex;\n align-items: center;\n gap: 4px;\n}\n\n.dsh-knowledge-header h2,\n.dsh-knowledge-header p {\n margin: 0;\n}\n\n.dsh-knowledge-header h2 {\n color: var(--dsw-alias-label-primary);\n font-size: 17px;\n line-height: 26px;\n font-weight: 600;\n}\n\n.dsh-knowledge-header p {\n color: var(--dsw-alias-label-secondary);\n font-size: 12px;\n line-height: 18px;\n}\n\n.dsh-knowledge-window-button {\n flex: none;\n display: inline-flex;\n align-items: center;\n justify-content: center;\n width: 32px;\n height: 32px;\n padding: 0;\n border: 0;\n border-radius: 50%;\n background: transparent;\n color: var(--dsw-alias-label-primary);\n cursor: pointer;\n}\n\n.dsh-knowledge-window-button:hover {\n background: var(--dsw-alias-interactive-bg-hover);\n}\n\n.dsh-knowledge-window-button:focus-visible {\n outline: 2px solid var(--dsw-alias-interactive-primary, #335cff);\n outline-offset: 2px;\n}\n\n.dsh-knowledge-resize-grip {\n position: absolute;\n right: 3px;\n bottom: 3px;\n width: 20px;\n height: 20px;\n pointer-events: none;\n background: repeating-linear-gradient(135deg, transparent 0 4px, var(--dsw-alias-divider-primary, rgba(128, 128, 128, .42)) 4px 6px);\n clip-path: polygon(100% 0, 100% 100%, 0 100%);\n}\n\n.dsh-knowledge-frame {\n flex: 1;\n width: 100%;\n min-height: 0;\n border: 0;\n background: var(--dsw-alias-bg-layer-1, #fff);\n}\n\n.dsh-knowledge-panel-state {\n flex: 1;\n display: flex;\n align-items: center;\n justify-content: center;\n gap: 16px;\n min-height: 0;\n padding: 32px;\n box-sizing: border-box;\n background: var(--dsw-alias-bg-layer-1, #fff);\n color: var(--dsw-alias-label-primary, #171719);\n}\n\n.dsh-knowledge-panel-state-icon {\n flex: none;\n display: inline-flex;\n align-items: center;\n justify-content: center;\n width: 40px;\n height: 40px;\n border-radius: 12px;\n background: var(--dsw-alias-interactive-bg-hover, rgba(128, 128, 128, .1));\n color: var(--dsw-alias-label-secondary, #68686f);\n font-size: 18px;\n font-weight: 600;\n}\n\n.dsh-knowledge-panel-state > div { max-width: 560px; }\n.dsh-knowledge-panel-state h3 { margin: 0 0 6px; font-size: 17px; line-height: 24px; font-weight: 600; }\n.dsh-knowledge-panel-state p { margin: 0; color: var(--dsw-alias-label-secondary, #68686f); font-size: 13px; line-height: 20px; }\n.dsh-knowledge-panel-state button {\n min-width: 72px;\n min-height: 32px;\n margin-top: 16px;\n padding: 6px 14px;\n border: 0;\n border-radius: 10px;\n background: var(--dsw-alias-interactive-primary, #335cff);\n color: #fff;\n cursor: pointer;\n font: inherit;\n}\n.dsh-knowledge-panel-state button:focus-visible {\n outline: 2px solid var(--dsw-alias-interactive-primary, #335cff);\n outline-offset: 2px;\n}\n\n@media (max-width: 760px) {\n .dsh-knowledge-overlay {\n padding: 0;\n }\n\n .dsh-knowledge-panel {\n width: 100%;\n height: 100%;\n min-width: 0;\n min-height: 0;\n max-width: none;\n max-height: none;\n border-radius: 0;\n resize: none;\n }\n\n .dsh-knowledge-window-actions > :first-child,\n .dsh-knowledge-resize-grip { display: none; }\n}\n\n.dsh-knowledge-settings-card {\n list-style: none;\n overflow: hidden;\n border: 1px solid var(--dsw-alias-divider-primary, rgba(128, 128, 128, .18));\n border-radius: 18px;\n background: var(--dsw-alias-bg-layer-2, #fff);\n color: var(--dsw-alias-label-primary, #171719);\n}\n\n.dsh-knowledge-settings-card--open {\n box-shadow: 0 10px 32px rgba(0, 0, 0, .07);\n}\n\n.dsh-knowledge-settings-header {\n display: flex;\n width: 100%;\n align-items: center;\n justify-content: space-between;\n gap: 20px;\n padding: 18px 20px;\n border: 0;\n background: transparent;\n color: inherit;\n text-align: left;\n cursor: pointer;\n}\n\n.dsh-knowledge-settings-header:hover { background: var(--dsw-alias-interactive-bg-hover, rgba(128, 128, 128, .08)); }\n.dsh-knowledge-settings-header:focus-visible,\n.dsh-knowledge-settings-actions button:focus-visible,\n.dsh-knowledge-settings-load-error button:focus-visible {\n outline: 2px solid var(--dsw-alias-interactive-primary, #335cff);\n outline-offset: 2px;\n}\n.dsh-knowledge-settings-header > span:first-child { display: grid; gap: 3px; }\n.dsh-knowledge-settings-header strong { font-size: 15px; font-weight: 600; }\n.dsh-knowledge-settings-header small,\n.dsh-knowledge-source-picker small,\n.dsh-knowledge-remote-fields small { color: var(--dsw-alias-label-secondary, #68686f); font-size: 12px; }\n.dsh-knowledge-settings-summary { flex: none; color: var(--dsw-alias-label-secondary, #68686f); font-size: 12px; }\n\n.dsh-knowledge-settings-body {\n display: grid;\n gap: 18px;\n padding: 4px 20px 20px;\n border-top: 1px solid var(--dsw-alias-divider-primary, rgba(128, 128, 128, .14));\n}\n\n.dsh-knowledge-source-picker {\n display: grid;\n grid-template-columns: repeat(2, minmax(0, 1fr));\n gap: 10px;\n margin: 18px 0 0;\n padding: 0;\n border: 0;\n}\n\n.dsh-knowledge-source-picker legend { margin-bottom: 8px; font-size: 13px; font-weight: 600; }\n.dsh-knowledge-source-picker label {\n display: flex;\n gap: 10px;\n padding: 13px;\n border: 1px solid var(--dsw-alias-divider-primary, rgba(128, 128, 128, .2));\n border-radius: 14px;\n cursor: pointer;\n}\n.dsh-knowledge-source-picker label.is-selected {\n border-color: var(--dsw-alias-interactive-primary, #335cff);\n background: color-mix(in srgb, var(--dsw-alias-interactive-primary, #335cff) 7%, transparent);\n}\n.dsh-knowledge-source-picker label.is-disabled {\n cursor: default;\n opacity: .55;\n}\n.dsh-knowledge-source-picker label:focus-within {\n outline: 2px solid var(--dsw-alias-interactive-primary, #335cff);\n outline-offset: 2px;\n}\n.dsh-knowledge-source-picker input { margin-top: 2px; accent-color: var(--dsw-alias-interactive-primary, #335cff); }\n.dsh-knowledge-source-picker span { display: grid; gap: 3px; }\n\n.dsh-knowledge-remote-fields { display: grid; grid-template-columns: 1.25fr 1fr; gap: 12px; }\n.dsh-knowledge-remote-fields label,\n.dsh-knowledge-timeout-field { display: grid; gap: 6px; color: var(--dsw-alias-label-secondary, #68686f); font-size: 12px; }\n.dsh-knowledge-remote-fields input,\n.dsh-knowledge-timeout-field input {\n min-height: 38px;\n box-sizing: border-box;\n padding: 8px 11px;\n border: 1px solid var(--dsw-alias-divider-primary, rgba(128, 128, 128, .25));\n border-radius: 10px;\n outline: none;\n background: var(--dsw-alias-bg-layer-1, #fff);\n color: var(--dsw-alias-label-primary, #171719);\n font: inherit;\n}\n.dsh-knowledge-remote-fields input:focus,\n.dsh-knowledge-timeout-field input:focus { border-color: var(--dsw-alias-interactive-primary, #335cff); box-shadow: 0 0 0 3px rgba(51, 92, 255, .12); }\n.dsh-knowledge-timeout-field { max-width: 240px; }\n.dsh-knowledge-field-error { color: #c9362b !important; }\n\n.dsh-knowledge-settings-message,\n.dsh-knowledge-settings-note { margin: 0; color: var(--dsw-alias-label-secondary, #68686f); font-size: 12px; }\n.dsh-knowledge-settings-message.is-success { color: #15803d; }\n.dsh-knowledge-settings-message.is-error { color: #c9362b; }\n.dsh-knowledge-settings-load-error {\n display: flex;\n align-items: center;\n justify-content: space-between;\n gap: 12px;\n margin-top: 18px;\n padding: 12px 14px;\n border-radius: 12px;\n background: color-mix(in srgb, #c9362b 8%, transparent);\n color: #c9362b;\n font-size: 13px;\n}\n.dsh-knowledge-settings-load-error p { margin: 0; }\n.dsh-knowledge-settings-load-error button {\n flex: none;\n min-height: 30px;\n padding: 5px 10px;\n border: 0;\n border-radius: 9px;\n background: var(--dsw-alias-bg-layer-2, #fff);\n color: var(--dsw-alias-label-primary, #171719);\n cursor: pointer;\n font: inherit;\n}\n.dsh-knowledge-settings-actions { display: flex; justify-content: flex-end; gap: 8px; }\n.dsh-knowledge-settings-actions button {\n min-height: 34px;\n padding: 7px 13px;\n border: 0;\n border-radius: 10px;\n background: var(--dsw-alias-interactive-bg-hover, rgba(128, 128, 128, .1));\n color: var(--dsw-alias-label-primary, #171719);\n cursor: pointer;\n font: inherit;\n font-size: 13px;\n}\n.dsh-knowledge-settings-actions button.is-primary { background: var(--dsw-alias-interactive-primary, #335cff); color: #fff; }\n.dsh-knowledge-settings-actions button:disabled { cursor: default; opacity: .45; }\n\n@media (max-width: 720px) {\n .dsh-knowledge-source-picker,\n .dsh-knowledge-remote-fields { grid-template-columns: 1fr; }\n}\n";
|
|
32
|
+
var client_default = ".dsh-knowledge-trigger {\n flex: none;\n display: flex;\n align-items: center;\n gap: 8px;\n width: calc(100% + 8px);\n height: 34px;\n margin: 4px -4px;\n padding: 6px 2px 6px 10px;\n box-sizing: border-box;\n border: 0;\n border-radius: 12px;\n overflow: hidden;\n background: transparent;\n color: var(--dsw-alias-label-primary);\n cursor: pointer;\n font: inherit;\n font-size: 14px;\n line-height: 22px;\n white-space: nowrap;\n}\n\n.dsh-knowledge-trigger:hover {\n background: var(--dsw-alias-interactive-bg-hover);\n}\n\n.dsh-knowledge-trigger.is-active {\n background: var(--dsw-alias-interactive-bg-selected, var(--dsw-alias-interactive-bg-hover));\n color: var(--dsw-alias-interactive-primary, currentColor);\n}\n\n.dsh-knowledge-trigger--rail {\n width: 36px;\n height: 36px;\n margin: 8px 0 4px;\n padding: 0;\n justify-content: center;\n gap: 0;\n border-radius: 50%;\n}\n\n.dsh-knowledge-workspace {\n width: 100%;\n height: 100%;\n min-width: 0;\n min-height: 0;\n display: flex;\n flex-direction: column;\n overflow: hidden;\n background: var(--dsw-alias-bg-layer-1, #fff);\n}\n\n.dsh-knowledge-workspace-header {\n flex: none;\n display: flex;\n align-items: center;\n justify-content: space-between;\n gap: 16px;\n min-height: 56px;\n padding: 8px 16px 8px 20px;\n box-sizing: border-box;\n border-bottom: 1px solid var(--dsw-alias-divider-primary, rgba(128, 128, 128, .18));\n background: var(--dsw-alias-bg-layer-2, #fff);\n}\n\n.dsh-knowledge-workspace-header h2,\n.dsh-knowledge-workspace-header p {\n margin: 0;\n}\n\n.dsh-knowledge-workspace-header h2 {\n color: var(--dsw-alias-label-primary);\n font-size: 15px;\n line-height: 22px;\n font-weight: 600;\n}\n\n.dsh-knowledge-workspace-header p {\n color: var(--dsw-alias-label-secondary);\n font-size: 11px;\n line-height: 16px;\n}\n\n.dsh-knowledge-frame {\n flex: 1;\n width: 100%;\n min-height: 0;\n border: 0;\n background: var(--dsw-alias-bg-layer-1, #fff);\n}\n\n.dsh-knowledge-panel-state {\n flex: 1;\n display: flex;\n align-items: center;\n justify-content: center;\n gap: 16px;\n min-height: 0;\n padding: 32px;\n box-sizing: border-box;\n background: var(--dsw-alias-bg-layer-1, #fff);\n color: var(--dsw-alias-label-primary, #171719);\n}\n\n.dsh-knowledge-panel-state-icon {\n flex: none;\n display: inline-flex;\n align-items: center;\n justify-content: center;\n width: 40px;\n height: 40px;\n border-radius: 12px;\n background: var(--dsw-alias-interactive-bg-hover, rgba(128, 128, 128, .1));\n color: var(--dsw-alias-label-secondary, #68686f);\n font-size: 18px;\n font-weight: 600;\n}\n\n.dsh-knowledge-panel-state > div { max-width: 560px; }\n.dsh-knowledge-panel-state h3 { margin: 0 0 6px; font-size: 17px; line-height: 24px; font-weight: 600; }\n.dsh-knowledge-panel-state p { margin: 0; color: var(--dsw-alias-label-secondary, #68686f); font-size: 13px; line-height: 20px; }\n.dsh-knowledge-panel-state button {\n min-width: 72px;\n min-height: 32px;\n margin-top: 16px;\n padding: 6px 14px;\n border: 0;\n border-radius: 10px;\n background: var(--dsw-alias-interactive-primary, #335cff);\n color: #fff;\n cursor: pointer;\n font: inherit;\n}\n.dsh-knowledge-panel-state button:focus-visible {\n outline: 2px solid var(--dsw-alias-interactive-primary, #335cff);\n outline-offset: 2px;\n}\n\n.dsh-knowledge-settings-card {\n list-style: none;\n overflow: hidden;\n border: 1px solid var(--dsw-alias-divider-primary, rgba(128, 128, 128, .18));\n border-radius: 18px;\n background: var(--dsw-alias-bg-layer-2, #fff);\n color: var(--dsw-alias-label-primary, #171719);\n}\n\n.dsh-knowledge-settings-card--open {\n box-shadow: 0 10px 32px rgba(0, 0, 0, .07);\n}\n\n.dsh-knowledge-settings-header {\n display: flex;\n width: 100%;\n align-items: center;\n justify-content: space-between;\n gap: 20px;\n padding: 18px 20px;\n border: 0;\n background: transparent;\n color: inherit;\n text-align: left;\n cursor: pointer;\n}\n\n.dsh-knowledge-settings-header:hover { background: var(--dsw-alias-interactive-bg-hover, rgba(128, 128, 128, .08)); }\n.dsh-knowledge-settings-header:focus-visible,\n.dsh-knowledge-settings-actions button:focus-visible,\n.dsh-knowledge-settings-load-error button:focus-visible {\n outline: 2px solid var(--dsw-alias-interactive-primary, #335cff);\n outline-offset: 2px;\n}\n.dsh-knowledge-settings-header > span:first-child { display: grid; gap: 3px; }\n.dsh-knowledge-settings-header strong { font-size: 15px; font-weight: 600; }\n.dsh-knowledge-settings-header small,\n.dsh-knowledge-source-picker small,\n.dsh-knowledge-remote-fields small { color: var(--dsw-alias-label-secondary, #68686f); font-size: 12px; }\n.dsh-knowledge-settings-summary { flex: none; color: var(--dsw-alias-label-secondary, #68686f); font-size: 12px; }\n\n.dsh-knowledge-settings-body {\n display: grid;\n gap: 18px;\n padding: 4px 20px 20px;\n border-top: 1px solid var(--dsw-alias-divider-primary, rgba(128, 128, 128, .14));\n}\n\n.dsh-knowledge-source-picker {\n display: grid;\n grid-template-columns: repeat(2, minmax(0, 1fr));\n gap: 10px;\n margin: 18px 0 0;\n padding: 0;\n border: 0;\n}\n\n.dsh-knowledge-source-picker legend { margin-bottom: 8px; font-size: 13px; font-weight: 600; }\n.dsh-knowledge-source-picker label {\n display: flex;\n gap: 10px;\n padding: 13px;\n border: 1px solid var(--dsw-alias-divider-primary, rgba(128, 128, 128, .2));\n border-radius: 14px;\n cursor: pointer;\n}\n.dsh-knowledge-source-picker label.is-selected {\n border-color: var(--dsw-alias-interactive-primary, #335cff);\n background: color-mix(in srgb, var(--dsw-alias-interactive-primary, #335cff) 7%, transparent);\n}\n.dsh-knowledge-source-picker label.is-disabled {\n cursor: default;\n opacity: .55;\n}\n.dsh-knowledge-source-picker label:focus-within {\n outline: 2px solid var(--dsw-alias-interactive-primary, #335cff);\n outline-offset: 2px;\n}\n.dsh-knowledge-source-picker input { margin-top: 2px; accent-color: var(--dsw-alias-interactive-primary, #335cff); }\n.dsh-knowledge-source-picker span { display: grid; gap: 3px; }\n\n.dsh-knowledge-remote-fields { display: grid; grid-template-columns: 1.25fr 1fr; gap: 12px; }\n.dsh-knowledge-remote-fields label,\n.dsh-knowledge-timeout-field { display: grid; gap: 6px; color: var(--dsw-alias-label-secondary, #68686f); font-size: 12px; }\n.dsh-knowledge-remote-fields input,\n.dsh-knowledge-timeout-field input {\n min-height: 38px;\n box-sizing: border-box;\n padding: 8px 11px;\n border: 1px solid var(--dsw-alias-divider-primary, rgba(128, 128, 128, .25));\n border-radius: 10px;\n outline: none;\n background: var(--dsw-alias-bg-layer-1, #fff);\n color: var(--dsw-alias-label-primary, #171719);\n font: inherit;\n}\n.dsh-knowledge-remote-fields input:focus,\n.dsh-knowledge-timeout-field input:focus { border-color: var(--dsw-alias-interactive-primary, #335cff); box-shadow: 0 0 0 3px rgba(51, 92, 255, .12); }\n.dsh-knowledge-timeout-field { max-width: 240px; }\n.dsh-knowledge-field-error { color: #c9362b !important; }\n\n.dsh-knowledge-settings-message,\n.dsh-knowledge-settings-note { margin: 0; color: var(--dsw-alias-label-secondary, #68686f); font-size: 12px; }\n.dsh-knowledge-settings-message.is-success { color: #15803d; }\n.dsh-knowledge-settings-message.is-error { color: #c9362b; }\n.dsh-knowledge-settings-load-error {\n display: flex;\n align-items: center;\n justify-content: space-between;\n gap: 12px;\n margin-top: 18px;\n padding: 12px 14px;\n border-radius: 12px;\n background: color-mix(in srgb, #c9362b 8%, transparent);\n color: #c9362b;\n font-size: 13px;\n}\n.dsh-knowledge-settings-load-error p { margin: 0; }\n.dsh-knowledge-settings-load-error button {\n flex: none;\n min-height: 30px;\n padding: 5px 10px;\n border: 0;\n border-radius: 9px;\n background: var(--dsw-alias-bg-layer-2, #fff);\n color: var(--dsw-alias-label-primary, #171719);\n cursor: pointer;\n font: inherit;\n}\n.dsh-knowledge-settings-actions { display: flex; justify-content: flex-end; gap: 8px; }\n.dsh-knowledge-settings-actions button {\n min-height: 34px;\n padding: 7px 13px;\n border: 0;\n border-radius: 10px;\n background: var(--dsw-alias-interactive-bg-hover, rgba(128, 128, 128, .1));\n color: var(--dsw-alias-label-primary, #171719);\n cursor: pointer;\n font: inherit;\n font-size: 13px;\n}\n.dsh-knowledge-settings-actions button.is-primary { background: var(--dsw-alias-interactive-primary, #335cff); color: #fff; }\n.dsh-knowledge-settings-actions button:disabled { cursor: default; opacity: .45; }\n\n@media (max-width: 720px) {\n .dsh-knowledge-source-picker,\n .dsh-knowledge-remote-fields { grid-template-columns: 1fr; }\n}\n";
|
|
33
|
+
|
|
34
|
+
// src/constants.ts
|
|
35
|
+
var KNOWLEDGE_SETTINGS_NAMESPACE = "dsh-knowledge-connection";
|
|
36
|
+
|
|
37
|
+
// src/theme-bridge.ts
|
|
38
|
+
var KNOWLEDGE_THEME_MESSAGE = "@lemoncat7/dsh-knowledge/host-theme";
|
|
39
|
+
var KNOWLEDGE_THEME_READY_MESSAGE = "@lemoncat7/dsh-knowledge/host-theme-ready";
|
|
40
|
+
var KNOWLEDGE_THEME_PROTOCOL_VERSION = 1;
|
|
41
|
+
var TOKEN_SOURCES = {
|
|
42
|
+
"--bg": ["--dsw-alias-bg-layer-1", "--dsw-alias-bg-base"],
|
|
43
|
+
"--surface": ["--dsw-alias-bg-layer-2", "--dsw-alias-bg-layer-1"],
|
|
44
|
+
"--surface-raised": ["--dsw-alias-bg-layer-3", "--dsw-alias-bg-overlay", "--dsw-alias-bg-layer-2"],
|
|
45
|
+
"--surface-soft": ["--dsw-alias-bg-module-platform", "--dsw-alias-bg-layer-3", "--dsw-alias-bg-layer-2"],
|
|
46
|
+
"--surface-hover": ["--dsw-alias-interactive-bg-hover", "--dsw-alias-bg-layer-3"],
|
|
47
|
+
"--text": ["--dsw-alias-label-primary"],
|
|
48
|
+
"--text-secondary": ["--dsw-alias-label-secondary", "--dsw-alias-label-primary-dimmed"],
|
|
49
|
+
"--text-tertiary": ["--dsw-alias-label-tertiary", "--dsw-alias-label-caption"],
|
|
50
|
+
"--border": ["--dsw-alias-border-l2", "--dsw-alias-divider-primary", "--dsw-alias-border-l1"],
|
|
51
|
+
"--border-strong": ["--dsw-alias-border-l3", "--dsw-alias-border-l2"],
|
|
52
|
+
"--accent": ["--dsw-alias-button-primary-fill", "--dsw-alias-brand-primary"],
|
|
53
|
+
"--accent-hover": ["--dsw-alias-button-primary-hover", "--dsw-alias-brand-primary"],
|
|
54
|
+
"--accent-soft": ["--dsw-alias-interactive-bg-active", "--dsw-alias-interactive-bg-hover-accent"],
|
|
55
|
+
"--on-accent": ["--dsw-alias-label-primary-foreground", "--dsw-alias-brand-primary-invert"],
|
|
56
|
+
"--success": ["--dsw-alias-state-success-primary"],
|
|
57
|
+
"--success-soft": ["--dsw-alias-state-success-tertiary"],
|
|
58
|
+
"--warning": ["--dsw-alias-state-warn-primary", "--dsw-alias-state-warn-label"],
|
|
59
|
+
"--warning-soft": ["--dsw-alias-state-warn-tertiary"],
|
|
60
|
+
"--danger": ["--dsw-alias-state-error-primary"],
|
|
61
|
+
"--danger-soft": ["--dsw-alias-state-error-tertiary"],
|
|
62
|
+
"--shadow": ["--dsw-shadow-lv3", "--dsw-shadow-lv2"]
|
|
63
|
+
};
|
|
64
|
+
var FALLBACK_TOKENS = {
|
|
65
|
+
light: {
|
|
66
|
+
"--bg": "#f5f5f7",
|
|
67
|
+
"--surface": "#ffffff",
|
|
68
|
+
"--surface-raised": "#ffffff",
|
|
69
|
+
"--surface-soft": "#f0f0f3",
|
|
70
|
+
"--surface-hover": "#f5f5f8",
|
|
71
|
+
"--text": "#1d1d1f",
|
|
72
|
+
"--text-secondary": "#4c4c50",
|
|
73
|
+
"--text-tertiary": "#6e6e73",
|
|
74
|
+
"--border": "#dedee3",
|
|
75
|
+
"--border-strong": "#c7c7cc",
|
|
76
|
+
"--accent": "#086bd8",
|
|
77
|
+
"--accent-hover": "#005ab8",
|
|
78
|
+
"--accent-soft": "#e8f2ff",
|
|
79
|
+
"--on-accent": "#ffffff",
|
|
80
|
+
"--success": "#18794e",
|
|
81
|
+
"--success-soft": "#e8f5ee",
|
|
82
|
+
"--warning": "#986800",
|
|
83
|
+
"--warning-soft": "#fff4cf",
|
|
84
|
+
"--danger": "#c9343a",
|
|
85
|
+
"--danger-soft": "#fdebec",
|
|
86
|
+
"--shadow": "0 18px 48px rgb(30 45 70 / 10%)"
|
|
87
|
+
},
|
|
88
|
+
dark: {
|
|
89
|
+
"--bg": "#101012",
|
|
90
|
+
"--surface": "#1c1c1e",
|
|
91
|
+
"--surface-raised": "#242426",
|
|
92
|
+
"--surface-soft": "#2c2c2e",
|
|
93
|
+
"--surface-hover": "#303033",
|
|
94
|
+
"--text": "#f5f5f7",
|
|
95
|
+
"--text-secondary": "#c7c7cc",
|
|
96
|
+
"--text-tertiary": "#98989d",
|
|
97
|
+
"--border": "#353538",
|
|
98
|
+
"--border-strong": "#4a4a4f",
|
|
99
|
+
"--accent": "#64a8ff",
|
|
100
|
+
"--accent-hover": "#82b8ff",
|
|
101
|
+
"--accent-soft": "#17365d",
|
|
102
|
+
"--on-accent": "#0c1b2c",
|
|
103
|
+
"--success": "#62c596",
|
|
104
|
+
"--success-soft": "#163a2a",
|
|
105
|
+
"--warning": "#e7bc62",
|
|
106
|
+
"--warning-soft": "#423414",
|
|
107
|
+
"--danger": "#ff858a",
|
|
108
|
+
"--danger-soft": "#4b2227",
|
|
109
|
+
"--shadow": "0 16px 40px rgb(0 0 0 / 28%)"
|
|
110
|
+
}
|
|
111
|
+
};
|
|
112
|
+
function createKnowledgeHostTheme(computed, snapshot) {
|
|
113
|
+
const tokens = {};
|
|
114
|
+
for (const [target, sources] of Object.entries(TOKEN_SOURCES)) {
|
|
115
|
+
const value = firstDefinedToken(computed, snapshot.active.tokens, sources);
|
|
116
|
+
tokens[target] = value ?? FALLBACK_TOKENS[snapshot.active.colorScheme][target];
|
|
117
|
+
}
|
|
118
|
+
return {
|
|
119
|
+
type: KNOWLEDGE_THEME_MESSAGE,
|
|
120
|
+
version: KNOWLEDGE_THEME_PROTOCOL_VERSION,
|
|
121
|
+
colorScheme: snapshot.active.colorScheme,
|
|
122
|
+
tokens
|
|
123
|
+
};
|
|
124
|
+
}
|
|
125
|
+
function firstDefinedToken(computed, snapshotTokens, sources) {
|
|
126
|
+
for (const source of sources) {
|
|
127
|
+
const computedValue = computed.getPropertyValue(source).trim();
|
|
128
|
+
if (computedValue.length > 0) return computedValue;
|
|
129
|
+
const snapshotValue = snapshotTokens[source]?.trim();
|
|
130
|
+
if (snapshotValue !== void 0 && snapshotValue.length > 0) return snapshotValue;
|
|
131
|
+
}
|
|
132
|
+
return void 0;
|
|
133
|
+
}
|
|
33
134
|
|
|
34
135
|
// src/client.tsx
|
|
35
136
|
var import_jsx_runtime = require("react/jsx-runtime");
|
|
36
137
|
var PLUGIN_ID = "@lemoncat7/dsh-knowledge";
|
|
37
138
|
var STYLE_ID = `${PLUGIN_ID}/client`;
|
|
38
|
-
var PANEL_SIZE_KEY = `${PLUGIN_ID}/panel-size`;
|
|
39
139
|
var CONNECTION_CONTROL_PATH = "/knowledge-control/v1/connection";
|
|
40
|
-
var inject = ["slots"];
|
|
140
|
+
var inject = ["slots", "theme"];
|
|
41
141
|
function apply(ctx) {
|
|
42
142
|
ctx.effect(installStyles, "dsh-knowledge: client styles");
|
|
143
|
+
const workspace = createKnowledgeWorkspaceController(ctx);
|
|
144
|
+
ctx.effect(() => () => {
|
|
145
|
+
workspace.close();
|
|
146
|
+
}, "dsh-knowledge: workspace lifecycle");
|
|
43
147
|
ctx.slots.inject("sidebar.footer.action", () => ctx.slots.register({
|
|
44
148
|
name: "sidebar.footer.action",
|
|
45
149
|
id: "knowledge",
|
|
46
150
|
order: -10
|
|
47
|
-
}, KnowledgeLauncher));
|
|
151
|
+
}, (props) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(KnowledgeLauncher, { ...props, workspace })));
|
|
48
152
|
ctx.slots.inject("settings.plugin.item", () => ctx.slots.register({
|
|
49
153
|
name: "settings.plugin.item",
|
|
50
|
-
key:
|
|
51
|
-
id: "dsh-knowledge-connection",
|
|
52
|
-
order: 25
|
|
154
|
+
key: KNOWLEDGE_SETTINGS_NAMESPACE
|
|
53
155
|
}, KnowledgeConnectionCard));
|
|
54
156
|
}
|
|
157
|
+
function createKnowledgeWorkspaceController(client) {
|
|
158
|
+
const listeners = /* @__PURE__ */ new Set();
|
|
159
|
+
let disposeWorkspace;
|
|
160
|
+
const notify = () => {
|
|
161
|
+
for (const listener of listeners) listener();
|
|
162
|
+
};
|
|
163
|
+
const close = () => {
|
|
164
|
+
if (disposeWorkspace === void 0) return;
|
|
165
|
+
const dispose = disposeWorkspace;
|
|
166
|
+
disposeWorkspace = void 0;
|
|
167
|
+
dispose();
|
|
168
|
+
notify();
|
|
169
|
+
};
|
|
170
|
+
return {
|
|
171
|
+
isOpen: () => disposeWorkspace !== void 0,
|
|
172
|
+
toggle: () => {
|
|
173
|
+
if (disposeWorkspace !== void 0) return close();
|
|
174
|
+
const dispose = client.slots.register({ name: "conversation", priority: -1 }, (props) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(KnowledgeWorkspace, { ...props, client }));
|
|
175
|
+
disposeWorkspace = dispose;
|
|
176
|
+
notify();
|
|
177
|
+
},
|
|
178
|
+
close,
|
|
179
|
+
subscribe: (listener) => {
|
|
180
|
+
listeners.add(listener);
|
|
181
|
+
return () => {
|
|
182
|
+
listeners.delete(listener);
|
|
183
|
+
};
|
|
184
|
+
}
|
|
185
|
+
};
|
|
186
|
+
}
|
|
55
187
|
function KnowledgeConnectionCard() {
|
|
56
188
|
const [current, setCurrent] = (0, import_react.useState)();
|
|
57
189
|
const [loadState, setLoadState] = (0, import_react.useState)("loading");
|
|
@@ -246,18 +378,41 @@ function isConnectionView(value) {
|
|
|
246
378
|
function isManagementPath(value) {
|
|
247
379
|
return typeof value === "string" && value.startsWith("/") && !value.startsWith("//");
|
|
248
380
|
}
|
|
249
|
-
function KnowledgeLauncher({ wide,
|
|
250
|
-
const [open, setOpen] = (0, import_react.useState)(
|
|
251
|
-
|
|
381
|
+
function KnowledgeLauncher({ wide, workspace }) {
|
|
382
|
+
const [open, setOpen] = (0, import_react.useState)(workspace.isOpen());
|
|
383
|
+
(0, import_react.useEffect)(() => workspace.subscribe(() => {
|
|
384
|
+
setOpen(workspace.isOpen());
|
|
385
|
+
}), [workspace]);
|
|
386
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
|
|
387
|
+
"button",
|
|
388
|
+
{
|
|
389
|
+
type: "button",
|
|
390
|
+
className: `dsh-knowledge-trigger${wide ? "" : " dsh-knowledge-trigger--rail"}${open ? " is-active" : ""}`,
|
|
391
|
+
"aria-label": open ? "\u8FD4\u56DE\u5BF9\u8BDD" : "\u77E5\u8BC6\u5E93",
|
|
392
|
+
"aria-pressed": open,
|
|
393
|
+
title: wide ? void 0 : open ? "\u8FD4\u56DE\u5BF9\u8BDD" : "\u77E5\u8BC6\u5E93",
|
|
394
|
+
onClick: () => {
|
|
395
|
+
workspace.toggle();
|
|
396
|
+
},
|
|
397
|
+
children: [
|
|
398
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_dsh_client_ui_primitives.IconDataOutline16, { size: wide ? 16 : 18 }),
|
|
399
|
+
wide && /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { children: open ? "\u8FD4\u56DE\u5BF9\u8BDD" : "\u77E5\u8BC6\u5E93" })
|
|
400
|
+
]
|
|
401
|
+
}
|
|
402
|
+
);
|
|
403
|
+
}
|
|
404
|
+
function KnowledgeWorkspace({
|
|
405
|
+
sessionId,
|
|
406
|
+
useSessions,
|
|
407
|
+
client
|
|
408
|
+
}) {
|
|
252
409
|
const [panelState, setPanelState] = (0, import_react.useState)("loading");
|
|
253
410
|
const [managementPath, setManagementPath] = (0, import_react.useState)();
|
|
254
411
|
const [panelError, setPanelError] = (0, import_react.useState)("");
|
|
255
|
-
const close = (0, import_react.useCallback)(() => {
|
|
256
|
-
setOpen(false);
|
|
257
|
-
}, []);
|
|
258
|
-
const sessionId = useSessions((state) => state.current);
|
|
259
412
|
const projectId = useSessions((state) => sessionId === void 0 ? void 0 : state.byId[sessionId]?.cwd);
|
|
260
413
|
const knowledgeUrl = managementPath === void 0 ? void 0 : knowledgePanelUrl(managementPath, sessionId, projectId);
|
|
414
|
+
const frame = (0, import_react.useRef)(null);
|
|
415
|
+
const themeFrame = (0, import_react.useRef)(0);
|
|
261
416
|
const loadManagement = (0, import_react.useCallback)(async () => {
|
|
262
417
|
setPanelState("loading");
|
|
263
418
|
setPanelError("");
|
|
@@ -276,169 +431,54 @@ function KnowledgeLauncher({ wide, useSessions }) {
|
|
|
276
431
|
setPanelState("error");
|
|
277
432
|
}
|
|
278
433
|
}, []);
|
|
279
|
-
|
|
280
|
-
setOpen(true);
|
|
434
|
+
(0, import_react.useEffect)(() => {
|
|
281
435
|
void loadManagement();
|
|
282
|
-
};
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
wide && /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { children: "\u77E5\u8BC6\u5E93" })
|
|
297
|
-
]
|
|
298
|
-
}
|
|
299
|
-
),
|
|
300
|
-
open && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
301
|
-
KnowledgePanel,
|
|
302
|
-
{
|
|
303
|
-
src: knowledgeUrl,
|
|
304
|
-
state: panelState,
|
|
305
|
-
error: panelError,
|
|
306
|
-
onRetry: () => {
|
|
307
|
-
void loadManagement();
|
|
308
|
-
},
|
|
309
|
-
maximized,
|
|
310
|
-
onToggleMaximized: () => {
|
|
311
|
-
setMaximized((value) => !value);
|
|
312
|
-
},
|
|
313
|
-
onClose: close
|
|
314
|
-
}
|
|
315
|
-
)
|
|
316
|
-
] });
|
|
317
|
-
}
|
|
318
|
-
function KnowledgePanel({
|
|
319
|
-
src,
|
|
320
|
-
state,
|
|
321
|
-
error,
|
|
322
|
-
onRetry,
|
|
323
|
-
maximized,
|
|
324
|
-
onToggleMaximized,
|
|
325
|
-
onClose
|
|
326
|
-
}) {
|
|
327
|
-
const closeButton = (0, import_react.useRef)(null);
|
|
328
|
-
const panel = (0, import_react.useRef)(null);
|
|
329
|
-
const panelSize = (0, import_react.useRef)(readPanelSize());
|
|
436
|
+
}, [loadManagement]);
|
|
437
|
+
const sendTheme = (0, import_react.useCallback)(() => {
|
|
438
|
+
const target = frame.current?.contentWindow;
|
|
439
|
+
if (target === void 0 || target === null) return;
|
|
440
|
+
const computed = getComputedStyle(document.body);
|
|
441
|
+
target.postMessage(createKnowledgeHostTheme(computed, client.theme.getTheme()), window.location.origin);
|
|
442
|
+
}, [client]);
|
|
443
|
+
const scheduleTheme = (0, import_react.useCallback)(() => {
|
|
444
|
+
if (themeFrame.current !== 0) window.cancelAnimationFrame(themeFrame.current);
|
|
445
|
+
themeFrame.current = window.requestAnimationFrame(() => {
|
|
446
|
+
themeFrame.current = 0;
|
|
447
|
+
sendTheme();
|
|
448
|
+
});
|
|
449
|
+
}, [sendTheme]);
|
|
330
450
|
(0, import_react.useEffect)(() => {
|
|
331
|
-
const
|
|
332
|
-
|
|
451
|
+
const off = client.on("theme/change", scheduleTheme);
|
|
452
|
+
const onMessage = (event) => {
|
|
453
|
+
if (event.origin !== window.location.origin || event.source !== frame.current?.contentWindow) return;
|
|
454
|
+
const data = event.data;
|
|
455
|
+
if (data?.type === KNOWLEDGE_THEME_READY_MESSAGE && data.version === KNOWLEDGE_THEME_PROTOCOL_VERSION) sendTheme();
|
|
333
456
|
};
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
return () => {
|
|
337
|
-
document.removeEventListener("keydown", onKeyDown);
|
|
338
|
-
};
|
|
339
|
-
}, [onClose]);
|
|
340
|
-
(0, import_react.useEffect)(() => {
|
|
341
|
-
const target = panel.current;
|
|
342
|
-
if (target === null || typeof ResizeObserver === "undefined") return;
|
|
343
|
-
const minimumWidth = desktopPanelMinimumWidth();
|
|
344
|
-
const observer = new ResizeObserver((entries) => {
|
|
345
|
-
if (target.classList.contains("dsh-knowledge-panel--maximized") || window.innerWidth <= 760) return;
|
|
346
|
-
const rect = entries[0]?.contentRect;
|
|
347
|
-
if (rect === void 0 || rect.width < minimumWidth || rect.height < 460) return;
|
|
348
|
-
panelSize.current = { width: Math.round(rect.width), height: Math.round(rect.height) };
|
|
349
|
-
try {
|
|
350
|
-
localStorage.setItem(PANEL_SIZE_KEY, JSON.stringify(panelSize.current));
|
|
351
|
-
} catch {
|
|
352
|
-
}
|
|
353
|
-
});
|
|
354
|
-
observer.observe(target);
|
|
457
|
+
window.addEventListener("message", onMessage);
|
|
458
|
+
scheduleTheme();
|
|
355
459
|
return () => {
|
|
356
|
-
|
|
460
|
+
off();
|
|
461
|
+
window.removeEventListener("message", onMessage);
|
|
462
|
+
if (themeFrame.current !== 0) window.cancelAnimationFrame(themeFrame.current);
|
|
357
463
|
};
|
|
358
|
-
}, []);
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
"
|
|
370
|
-
|
|
371
|
-
children:
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
}, children: [
|
|
375
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { children: [
|
|
376
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("h2", { id: "dsh-knowledge-panel-title", children: "\u77E5\u8BC6\u5E93" }),
|
|
377
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("p", { children: "\u7BA1\u7406\u77E5\u8BC6\u3001AI \u5019\u9009\u548C\u5BA2\u6237\u7AEF\u8BBF\u95EE\u4EE4\u724C" })
|
|
378
|
-
] }),
|
|
379
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "dsh-knowledge-window-actions", children: [
|
|
380
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
381
|
-
"button",
|
|
382
|
-
{
|
|
383
|
-
type: "button",
|
|
384
|
-
className: "dsh-knowledge-window-button",
|
|
385
|
-
"aria-label": maximized ? "\u8FD8\u539F\u77E5\u8BC6\u5E93\u7A97\u53E3" : "\u6700\u5927\u5316\u77E5\u8BC6\u5E93\u7A97\u53E3",
|
|
386
|
-
title: maximized ? "\u8FD8\u539F" : "\u6700\u5927\u5316",
|
|
387
|
-
onClick: (event) => {
|
|
388
|
-
event.stopPropagation();
|
|
389
|
-
onToggleMaximized();
|
|
390
|
-
},
|
|
391
|
-
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { "aria-hidden": "true", children: maximized ? "\u2199" : "\u2197" })
|
|
392
|
-
}
|
|
393
|
-
),
|
|
394
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
395
|
-
"button",
|
|
396
|
-
{
|
|
397
|
-
ref: closeButton,
|
|
398
|
-
type: "button",
|
|
399
|
-
className: "dsh-knowledge-window-button",
|
|
400
|
-
"aria-label": "\u5173\u95ED\u77E5\u8BC6\u5E93",
|
|
401
|
-
onClick: onClose,
|
|
402
|
-
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_dsh_client_ui_primitives.IconCloseOutline16, { size: 16 })
|
|
403
|
-
}
|
|
404
|
-
)
|
|
405
|
-
] })
|
|
406
|
-
] }),
|
|
407
|
-
state === "ready" && src !== void 0 ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)("iframe", { className: "dsh-knowledge-frame", src, title: "\u77E5\u8BC6\u5E93\u7BA1\u7406\u53F0" }) : /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "dsh-knowledge-panel-state", role: state === "error" ? "alert" : "status", "aria-live": "polite", children: [
|
|
408
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: "dsh-knowledge-panel-state-icon", "aria-hidden": "true", children: state === "loading" ? "\xB7\xB7\xB7" : state === "error" ? "!" : "\u2014" }),
|
|
409
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { children: [
|
|
410
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("h3", { children: state === "loading" ? "\u6B63\u5728\u6253\u5F00\u77E5\u8BC6\u5E93\u2026" : state === "error" ? "\u6682\u65F6\u65E0\u6CD5\u6253\u5F00\u77E5\u8BC6\u5E93" : "\u8FD9\u53F0 DSH \u672A\u542F\u7528\u77E5\u8BC6\u5E93\u7BA1\u7406\u53F0" }),
|
|
411
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("p", { children: state === "loading" ? "\u6B63\u5728\u786E\u8BA4\u5F53\u524D\u5B9E\u4F8B\u662F\u5426\u63D0\u4F9B\u7BA1\u7406\u9875\u9762\u3002" : state === "error" ? error : "\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" }),
|
|
412
|
-
state === "error" && /* @__PURE__ */ (0, import_jsx_runtime.jsx)("button", { type: "button", onClick: onRetry, children: "\u91CD\u8BD5" })
|
|
413
|
-
] })
|
|
414
|
-
] }),
|
|
415
|
-
!maximized && /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: "dsh-knowledge-resize-grip", "aria-hidden": "true" })
|
|
416
|
-
]
|
|
417
|
-
}
|
|
418
|
-
)
|
|
464
|
+
}, [client, scheduleTheme, sendTheme]);
|
|
465
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("section", { className: "dsh-knowledge-workspace", "aria-labelledby": "dsh-knowledge-workspace-title", children: [
|
|
466
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("header", { className: "dsh-knowledge-workspace-header", children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { children: [
|
|
467
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("h2", { id: "dsh-knowledge-workspace-title", children: "\u77E5\u8BC6\u5E93" }),
|
|
468
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("p", { children: "\u6587\u6863\u3001\u5BA1\u6838\u3001\u6302\u8F7D\u4E0E\u8BBF\u95EE\u7BA1\u7406" })
|
|
469
|
+
] }) }),
|
|
470
|
+
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: [
|
|
471
|
+
/* @__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" }),
|
|
472
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { children: [
|
|
473
|
+
/* @__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" }),
|
|
474
|
+
/* @__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" }),
|
|
475
|
+
panelState === "error" && /* @__PURE__ */ (0, import_jsx_runtime.jsx)("button", { type: "button", onClick: () => {
|
|
476
|
+
void loadManagement();
|
|
477
|
+
}, children: "\u91CD\u8BD5" })
|
|
478
|
+
] })
|
|
479
|
+
] })
|
|
419
480
|
] });
|
|
420
481
|
}
|
|
421
|
-
function readPanelSize() {
|
|
422
|
-
const minimumWidth = desktopPanelMinimumWidth();
|
|
423
|
-
const fallback = {
|
|
424
|
-
width: Math.min(1180, Math.max(minimumWidth, window.innerWidth - 48)),
|
|
425
|
-
height: Math.min(860, Math.max(460, window.innerHeight - 48))
|
|
426
|
-
};
|
|
427
|
-
try {
|
|
428
|
-
const value = JSON.parse(localStorage.getItem(PANEL_SIZE_KEY) || "{}");
|
|
429
|
-
const width = Number(value.width);
|
|
430
|
-
const height = Number(value.height);
|
|
431
|
-
return {
|
|
432
|
-
width: Number.isFinite(width) ? Math.min(window.innerWidth - 32, Math.max(minimumWidth, width)) : fallback.width,
|
|
433
|
-
height: Number.isFinite(height) ? Math.min(window.innerHeight - 32, Math.max(460, height)) : fallback.height
|
|
434
|
-
};
|
|
435
|
-
} catch {
|
|
436
|
-
return fallback;
|
|
437
|
-
}
|
|
438
|
-
}
|
|
439
|
-
function desktopPanelMinimumWidth() {
|
|
440
|
-
return Math.min(1040, Math.max(320, window.innerWidth - 32));
|
|
441
|
-
}
|
|
442
482
|
function knowledgePanelUrl(managementPath, sessionId, projectId) {
|
|
443
483
|
const params = new URLSearchParams();
|
|
444
484
|
if (sessionId !== void 0) params.set("sessionId", sessionId);
|