@jingyi0605/codingns4dsh 0.1.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 +1114 -0
- package/assets/provider-icons/claude-code.png +0 -0
- package/assets/provider-icons/codex.png +0 -0
- package/assets/provider-icons/command-code.svg +5 -0
- package/assets/provider-icons/deepseek-harness.svg +9 -0
- package/assets/provider-icons/gemini.png +0 -0
- package/assets/provider-icons/grok.png +0 -0
- package/assets/provider-icons/kimi.png +0 -0
- package/assets/provider-icons/opencode.png +0 -0
- package/assets/provider-icons/pi.svg +7 -0
- package/data/build/dist/bootstrap/dsh-connection-adapter.d.ts +97 -0
- package/data/build/dist/bootstrap/dsh-connection-adapter.js +169 -0
- package/data/build/dist/bootstrap/index.d.ts +38 -0
- package/data/build/dist/bootstrap/index.js +44 -0
- package/data/build/dist/client/account-bar.d.ts +9 -0
- package/data/build/dist/client/account-bar.js +398 -0
- package/data/build/dist/client/bundle.js +26167 -0
- package/data/build/dist/client/cli-catalog.d.ts +24 -0
- package/data/build/dist/client/cli-catalog.js +108 -0
- package/data/build/dist/client/cli-slots.d.ts +38 -0
- package/data/build/dist/client/cli-slots.js +297 -0
- package/data/build/dist/client/debug/ui.d.ts +12 -0
- package/data/build/dist/client/debug/ui.js +451 -0
- package/data/build/dist/client/dsh-h5-bootstrap.d.ts +64 -0
- package/data/build/dist/client/dsh-h5-bootstrap.js +293 -0
- package/data/build/dist/client/dsh-runtime-version.d.ts +3 -0
- package/data/build/dist/client/dsh-runtime-version.js +11 -0
- package/data/build/dist/client/external-tool-stream.d.ts +24 -0
- package/data/build/dist/client/external-tool-stream.js +114 -0
- package/data/build/dist/client/features/cli-adapters.d.ts +7 -0
- package/data/build/dist/client/features/cli-adapters.js +215 -0
- package/data/build/dist/client/features/debug.d.ts +4 -0
- package/data/build/dist/client/features/debug.js +24 -0
- package/data/build/dist/client/features/index.d.ts +33 -0
- package/data/build/dist/client/features/index.js +44 -0
- package/data/build/dist/client/features/lan-access-panel.d.ts +5 -0
- package/data/build/dist/client/features/lan-access-panel.js +146 -0
- package/data/build/dist/client/features/lan-access.d.ts +9 -0
- package/data/build/dist/client/features/lan-access.js +30 -0
- package/data/build/dist/client/features/login-protection-panel.d.ts +5 -0
- package/data/build/dist/client/features/login-protection-panel.js +91 -0
- package/data/build/dist/client/features/login-protection-session.d.ts +6 -0
- package/data/build/dist/client/features/login-protection-session.js +25 -0
- package/data/build/dist/client/features/login-protection.d.ts +4 -0
- package/data/build/dist/client/features/login-protection.js +23 -0
- package/data/build/dist/client/features/reverse-proxy-panel.d.ts +9 -0
- package/data/build/dist/client/features/reverse-proxy-panel.js +159 -0
- package/data/build/dist/client/features/reverse-proxy.d.ts +12 -0
- package/data/build/dist/client/features/reverse-proxy.js +112 -0
- package/data/build/dist/client/features/terminal-enhancement-panel.d.ts +5 -0
- package/data/build/dist/client/features/terminal-enhancement-panel.js +160 -0
- package/data/build/dist/client/features/terminal-enhancement.d.ts +4 -0
- package/data/build/dist/client/features/terminal-enhancement.js +24 -0
- package/data/build/dist/client/features/types.d.ts +58 -0
- package/data/build/dist/client/features/types.js +2 -0
- package/data/build/dist/client/features/workspace-session-enhancement-panel.d.ts +5 -0
- package/data/build/dist/client/features/workspace-session-enhancement-panel.js +66 -0
- package/data/build/dist/client/features/workspace-session-enhancement.d.ts +4 -0
- package/data/build/dist/client/features/workspace-session-enhancement.js +101 -0
- package/data/build/dist/client/h5-bootstrap-entry.d.ts +2 -0
- package/data/build/dist/client/h5-bootstrap-entry.js +17 -0
- package/data/build/dist/client/index.d.ts +31 -0
- package/data/build/dist/client/index.js +98 -0
- package/data/build/dist/client/lan-access.d.ts +28 -0
- package/data/build/dist/client/lan-access.js +68 -0
- package/data/build/dist/client/locale.d.ts +20 -0
- package/data/build/dist/client/locale.js +393 -0
- package/data/build/dist/client/provider-icon-assets.d.ts +2 -0
- package/data/build/dist/client/provider-icon-assets.js +23 -0
- package/data/build/dist/client/provider-icons.d.ts +19 -0
- package/data/build/dist/client/provider-icons.js +39 -0
- package/data/build/dist/client/remote-web-context.d.ts +57 -0
- package/data/build/dist/client/remote-web-context.js +939 -0
- package/data/build/dist/client/session-adapter-cache.d.ts +18 -0
- package/data/build/dist/client/session-adapter-cache.js +84 -0
- package/data/build/dist/client/settings-bridge.d.ts +32 -0
- package/data/build/dist/client/settings-bridge.js +126 -0
- package/data/build/dist/client/settings-section.d.ts +30 -0
- package/data/build/dist/client/settings-section.js +93 -0
- package/data/build/dist/client/subscription-slot.d.ts +18 -0
- package/data/build/dist/client/subscription-slot.js +223 -0
- package/data/build/dist/client/terminal/index.d.ts +4 -0
- package/data/build/dist/client/terminal/index.js +3 -0
- package/data/build/dist/client/terminal/model.d.ts +116 -0
- package/data/build/dist/client/terminal/model.js +435 -0
- package/data/build/dist/client/terminal/styles.d.ts +21 -0
- package/data/build/dist/client/terminal/styles.js +51 -0
- package/data/build/dist/client/terminal/ui.d.ts +19 -0
- package/data/build/dist/client/terminal/ui.js +257 -0
- package/data/build/dist/client/terminal/xterm-view.d.ts +13 -0
- package/data/build/dist/client/terminal/xterm-view.js +213 -0
- package/data/build/dist/client/theme.d.ts +56 -0
- package/data/build/dist/client/theme.js +186 -0
- package/data/build/dist/client/workspace-session-archive-dom.d.ts +29 -0
- package/data/build/dist/client/workspace-session-archive-dom.js +525 -0
- package/data/build/dist/client/workspace-session-fiber.d.ts +3 -0
- package/data/build/dist/client/workspace-session-fiber.js +33 -0
- package/data/build/dist/client/workspace-session-logo-dom.d.ts +26 -0
- package/data/build/dist/client/workspace-session-logo-dom.js +128 -0
- package/data/build/dist/features/index.d.ts +3 -0
- package/data/build/dist/features/index.js +2 -0
- package/data/build/dist/features/registry.d.ts +74 -0
- package/data/build/dist/features/registry.js +382 -0
- package/data/build/dist/features/resource-scope/index.d.ts +39 -0
- package/data/build/dist/features/resource-scope/index.js +161 -0
- package/data/build/dist/host/auth-session.d.ts +42 -0
- package/data/build/dist/host/auth-session.js +186 -0
- package/data/build/dist/host/cli-adapters/claude-driver.d.ts +14 -0
- package/data/build/dist/host/cli-adapters/claude-driver.js +103 -0
- package/data/build/dist/host/cli-adapters/codex-driver.d.ts +45 -0
- package/data/build/dist/host/cli-adapters/codex-driver.js +534 -0
- package/data/build/dist/host/cli-adapters/command-code-driver.d.ts +38 -0
- package/data/build/dist/host/cli-adapters/command-code-driver.js +394 -0
- package/data/build/dist/host/cli-adapters/command-code-subscription.d.ts +19 -0
- package/data/build/dist/host/cli-adapters/command-code-subscription.js +126 -0
- package/data/build/dist/host/cli-adapters/driver.d.ts +41 -0
- package/data/build/dist/host/cli-adapters/driver.js +2 -0
- package/data/build/dist/host/cli-adapters/dsh-message-projector.d.ts +37 -0
- package/data/build/dist/host/cli-adapters/dsh-message-projector.js +180 -0
- package/data/build/dist/host/cli-adapters/dsh-tool-history.d.ts +48 -0
- package/data/build/dist/host/cli-adapters/dsh-tool-history.js +373 -0
- package/data/build/dist/host/cli-adapters/feature.d.ts +7 -0
- package/data/build/dist/host/cli-adapters/feature.js +335 -0
- package/data/build/dist/host/cli-adapters/gemini-driver.d.ts +24 -0
- package/data/build/dist/host/cli-adapters/gemini-driver.js +427 -0
- package/data/build/dist/host/cli-adapters/grok-driver.d.ts +38 -0
- package/data/build/dist/host/cli-adapters/grok-driver.js +372 -0
- package/data/build/dist/host/cli-adapters/http-sse-client.d.ts +22 -0
- package/data/build/dist/host/cli-adapters/http-sse-client.js +99 -0
- package/data/build/dist/host/cli-adapters/interaction-events.d.ts +11 -0
- package/data/build/dist/host/cli-adapters/interaction-events.js +80 -0
- package/data/build/dist/host/cli-adapters/json-rpc-process.d.ts +65 -0
- package/data/build/dist/host/cli-adapters/json-rpc-process.js +256 -0
- package/data/build/dist/host/cli-adapters/kimi-driver.d.ts +21 -0
- package/data/build/dist/host/cli-adapters/kimi-driver.js +382 -0
- package/data/build/dist/host/cli-adapters/model-catalog.d.ts +22 -0
- package/data/build/dist/host/cli-adapters/model-catalog.js +89 -0
- package/data/build/dist/host/cli-adapters/opencode-driver.d.ts +55 -0
- package/data/build/dist/host/cli-adapters/opencode-driver.js +728 -0
- package/data/build/dist/host/cli-adapters/pi-driver.d.ts +43 -0
- package/data/build/dist/host/cli-adapters/pi-driver.js +312 -0
- package/data/build/dist/host/cli-adapters/process-utils.d.ts +16 -0
- package/data/build/dist/host/cli-adapters/process-utils.js +27 -0
- package/data/build/dist/host/cli-adapters/provider-subscription.d.ts +82 -0
- package/data/build/dist/host/cli-adapters/provider-subscription.js +610 -0
- package/data/build/dist/host/cli-adapters/registry.d.ts +95 -0
- package/data/build/dist/host/cli-adapters/registry.js +659 -0
- package/data/build/dist/host/cli-adapters/rpc-driver-utils.d.ts +24 -0
- package/data/build/dist/host/cli-adapters/rpc-driver-utils.js +119 -0
- package/data/build/dist/host/cli-adapters/session-probe.d.ts +20 -0
- package/data/build/dist/host/cli-adapters/session-probe.js +139 -0
- package/data/build/dist/host/cli-adapters/session-store.d.ts +68 -0
- package/data/build/dist/host/cli-adapters/session-store.js +180 -0
- package/data/build/dist/host/cli-adapters/standard-stream-driver.d.ts +45 -0
- package/data/build/dist/host/cli-adapters/standard-stream-driver.js +205 -0
- package/data/build/dist/host/cli-adapters/stream-normalizer.d.ts +25 -0
- package/data/build/dist/host/cli-adapters/stream-normalizer.js +83 -0
- package/data/build/dist/host/cli-adapters/tool-observation.d.ts +9 -0
- package/data/build/dist/host/cli-adapters/tool-observation.js +39 -0
- package/data/build/dist/host/control-api-client.d.ts +84 -0
- package/data/build/dist/host/control-api-client.js +130 -0
- package/data/build/dist/host/credential-store.d.ts +54 -0
- package/data/build/dist/host/credential-store.js +114 -0
- package/data/build/dist/host/debug.d.ts +79 -0
- package/data/build/dist/host/debug.js +295 -0
- package/data/build/dist/host/dsh-device-runtime.d.ts +39 -0
- package/data/build/dist/host/dsh-device-runtime.js +118 -0
- package/data/build/dist/host/dsh-gateway-feature.d.ts +5 -0
- package/data/build/dist/host/dsh-gateway-feature.js +55 -0
- package/data/build/dist/host/dsh-runtime-version.d.ts +12 -0
- package/data/build/dist/host/dsh-runtime-version.js +69 -0
- package/data/build/dist/host/features/auth.d.ts +11 -0
- package/data/build/dist/host/features/auth.js +273 -0
- package/data/build/dist/host/features/debug.d.ts +5 -0
- package/data/build/dist/host/features/debug.js +90 -0
- package/data/build/dist/host/features/host-status.d.ts +12 -0
- package/data/build/dist/host/features/host-status.js +54 -0
- package/data/build/dist/host/features/index.d.ts +19 -0
- package/data/build/dist/host/features/index.js +29 -0
- package/data/build/dist/host/features/lan-access-dsh.d.ts +8 -0
- package/data/build/dist/host/features/lan-access-dsh.js +45 -0
- package/data/build/dist/host/features/terminal-process.d.ts +5 -0
- package/data/build/dist/host/features/terminal-process.js +110 -0
- package/data/build/dist/host/features/terminal-status.d.ts +18 -0
- package/data/build/dist/host/features/terminal-status.js +56 -0
- package/data/build/dist/host/features/types.d.ts +41 -0
- package/data/build/dist/host/features/types.js +2 -0
- package/data/build/dist/host/index.d.ts +43 -0
- package/data/build/dist/host/index.js +135 -0
- package/data/build/dist/host/lan-access-dsh.d.ts +83 -0
- package/data/build/dist/host/lan-access-dsh.js +831 -0
- package/data/build/dist/host/native-session-bridge.d.ts +130 -0
- package/data/build/dist/host/native-session-bridge.js +317 -0
- package/data/build/dist/host/relay-tunnel-runtime.d.ts +97 -0
- package/data/build/dist/host/relay-tunnel-runtime.js +361 -0
- package/data/build/dist/host/remote-web-runtime.d.ts +78 -0
- package/data/build/dist/host/remote-web-runtime.js +559 -0
- package/data/build/dist/host/rpc-table.d.ts +32 -0
- package/data/build/dist/host/rpc-table.js +47 -0
- package/data/build/dist/host/rpc.d.ts +18 -0
- package/data/build/dist/host/rpc.js +248 -0
- package/data/build/dist/host/settings.d.ts +19 -0
- package/data/build/dist/host/settings.js +80 -0
- package/data/build/dist/host/terminal/attachment-registry.d.ts +17 -0
- package/data/build/dist/host/terminal/attachment-registry.js +49 -0
- package/data/build/dist/host/terminal/backends/conpty-backend.d.ts +39 -0
- package/data/build/dist/host/terminal/backends/conpty-backend.js +160 -0
- package/data/build/dist/host/terminal/backends/local-pty-backend.d.ts +36 -0
- package/data/build/dist/host/terminal/backends/local-pty-backend.js +178 -0
- package/data/build/dist/host/terminal/backends/tmux-backend.d.ts +40 -0
- package/data/build/dist/host/terminal/backends/tmux-backend.js +191 -0
- package/data/build/dist/host/terminal/broker/conpty-broker-client.d.ts +27 -0
- package/data/build/dist/host/terminal/broker/conpty-broker-client.js +154 -0
- package/data/build/dist/host/terminal/broker/conpty-broker-process.d.ts +10 -0
- package/data/build/dist/host/terminal/broker/conpty-broker-process.js +147 -0
- package/data/build/dist/host/terminal/broker/conpty-broker-protocol.d.ts +92 -0
- package/data/build/dist/host/terminal/broker/conpty-broker-protocol.js +134 -0
- package/data/build/dist/host/terminal/controller-factory.d.ts +37 -0
- package/data/build/dist/host/terminal/controller-factory.js +82 -0
- package/data/build/dist/host/terminal/index.d.ts +17 -0
- package/data/build/dist/host/terminal/index.js +17 -0
- package/data/build/dist/host/terminal/runtime-adapter.d.ts +77 -0
- package/data/build/dist/host/terminal/runtime-adapter.js +18 -0
- package/data/build/dist/host/terminal/runtime-manager.d.ts +41 -0
- package/data/build/dist/host/terminal/runtime-manager.js +179 -0
- package/data/build/dist/host/terminal/shell-detection.d.ts +23 -0
- package/data/build/dist/host/terminal/shell-detection.js +105 -0
- package/data/build/dist/host/terminal/startup.d.ts +33 -0
- package/data/build/dist/host/terminal/startup.js +100 -0
- package/data/build/dist/host/terminal/terminal-controller.d.ts +78 -0
- package/data/build/dist/host/terminal/terminal-controller.js +324 -0
- package/data/build/dist/host/terminal/terminal-process-service.d.ts +30 -0
- package/data/build/dist/host/terminal/terminal-process-service.js +194 -0
- package/data/build/dist/host/terminal/terminal-process-store.d.ts +45 -0
- package/data/build/dist/host/terminal/terminal-process-store.js +183 -0
- package/data/build/dist/host/terminal/terminal-service.d.ts +87 -0
- package/data/build/dist/host/terminal/terminal-service.js +528 -0
- package/data/build/dist/host/terminal/terminal-store.d.ts +49 -0
- package/data/build/dist/host/terminal/terminal-store.js +242 -0
- package/data/build/dist/index.d.ts +37 -0
- package/data/build/dist/index.js +26 -0
- package/data/build/dist/shared/contracts/auth.d.ts +122 -0
- package/data/build/dist/shared/contracts/auth.js +8 -0
- package/data/build/dist/shared/contracts/cli-adapter.d.ts +192 -0
- package/data/build/dist/shared/contracts/cli-adapter.js +2 -0
- package/data/build/dist/shared/contracts/command-code.d.ts +5 -0
- package/data/build/dist/shared/contracts/command-code.js +2 -0
- package/data/build/dist/shared/contracts/config.d.ts +113 -0
- package/data/build/dist/shared/contracts/config.js +86 -0
- package/data/build/dist/shared/contracts/debug-config.d.ts +28 -0
- package/data/build/dist/shared/contracts/debug-config.js +78 -0
- package/data/build/dist/shared/contracts/debug.d.ts +75 -0
- package/data/build/dist/shared/contracts/debug.js +121 -0
- package/data/build/dist/shared/contracts/dsh-device.d.ts +72 -0
- package/data/build/dist/shared/contracts/dsh-device.js +2 -0
- package/data/build/dist/shared/contracts/errors.d.ts +33 -0
- package/data/build/dist/shared/contracts/errors.js +41 -0
- package/data/build/dist/shared/contracts/feature.d.ts +71 -0
- package/data/build/dist/shared/contracts/feature.js +2 -0
- package/data/build/dist/shared/contracts/host-status.d.ts +14 -0
- package/data/build/dist/shared/contracts/host-status.js +2 -0
- package/data/build/dist/shared/contracts/lan-access-dsh.d.ts +30 -0
- package/data/build/dist/shared/contracts/lan-access-dsh.js +2 -0
- package/data/build/dist/shared/contracts/peer-host.d.ts +37 -0
- package/data/build/dist/shared/contracts/peer-host.js +9 -0
- package/data/build/dist/shared/contracts/signaling.d.ts +67 -0
- package/data/build/dist/shared/contracts/signaling.js +2 -0
- package/data/build/dist/shared/contracts/subscription.d.ts +69 -0
- package/data/build/dist/shared/contracts/subscription.js +2 -0
- package/data/build/dist/shared/contracts/terminal-process.d.ts +65 -0
- package/data/build/dist/shared/contracts/terminal-process.js +2 -0
- package/data/build/dist/shared/contracts/terminal.d.ts +127 -0
- package/data/build/dist/shared/contracts/terminal.js +2 -0
- package/data/build/dist/shared/contracts/transport.d.ts +45 -0
- package/data/build/dist/shared/contracts/transport.js +3 -0
- package/data/build/dist/shared/contracts/version.d.ts +19 -0
- package/data/build/dist/shared/contracts/version.js +74 -0
- package/data/build/dist/shared/index.d.ts +22 -0
- package/data/build/dist/shared/index.js +9 -0
- package/data/build/dist/transport/carrier.d.ts +38 -0
- package/data/build/dist/transport/carrier.js +268 -0
- package/data/build/dist/transport/debug.d.ts +22 -0
- package/data/build/dist/transport/debug.js +57 -0
- package/data/build/dist/transport/dsh-envelope.d.ts +41 -0
- package/data/build/dist/transport/dsh-envelope.js +107 -0
- package/data/build/dist/transport/dsh-gateway.d.ts +64 -0
- package/data/build/dist/transport/dsh-gateway.js +254 -0
- package/data/build/dist/transport/dsh-session.d.ts +55 -0
- package/data/build/dist/transport/dsh-session.js +256 -0
- package/data/build/dist/transport/dsh-transport.d.ts +57 -0
- package/data/build/dist/transport/dsh-transport.js +125 -0
- package/data/build/dist/transport/frame.d.ts +132 -0
- package/data/build/dist/transport/frame.js +168 -0
- package/data/build/dist/transport/index.d.ts +11 -0
- package/data/build/dist/transport/index.js +11 -0
- package/data/build/dist/transport/multiplexer.d.ts +63 -0
- package/data/build/dist/transport/multiplexer.js +323 -0
- package/data/build/dist/transport/webrtc-client.d.ts +65 -0
- package/data/build/dist/transport/webrtc-client.js +255 -0
- package/data/build/dist/transport/webrtc-host.d.ts +58 -0
- package/data/build/dist/transport/webrtc-host.js +252 -0
- package/data/build/dist/typert.host.d.ts +25 -0
- package/data/build/dist/typert.host.js +150 -0
- package/dsh.bundle.patch +12 -0
- package/package.json +135 -0
- package/profile/README.md +27 -0
- package/profile/cordis.patch.yml +2 -0
- package/profile/package.json +20 -0
- package/profile/scripts/check-dsh-install.mjs +71 -0
- package/profile/version.json +5 -0
- package/scripts/check-dsh-install.mjs +88 -0
- package/version.json +6 -0
|
@@ -0,0 +1,257 @@
|
|
|
1
|
+
import { createElement, Fragment, useEffect, useLayoutEffect, useRef, useState, useSyncExternalStore, } from 'react';
|
|
2
|
+
import { Button, IconChevronDownOutline14, Menu, } from '@deepseek-ai/dsh-client-ui-primitives';
|
|
3
|
+
import { CodingNsWebTerminals } from './model.js';
|
|
4
|
+
import { installTerminalStyles, terminalClass } from './styles.js';
|
|
5
|
+
import { CodingNsXtermView } from './xterm-view.js';
|
|
6
|
+
import { codingNsTranslator, useCodingNsTranslator } from '../locale.js';
|
|
7
|
+
export const TERMINAL_PROVIDER_ID = 'codingns4dsh/terminal';
|
|
8
|
+
export const TERMINAL_KIND = 'terminal';
|
|
9
|
+
/** 注册终端类型及其所有公开 Sidebar Slot。 */
|
|
10
|
+
export function registerCodingNsTerminalUi(ctx, webTerminals, settings) {
|
|
11
|
+
const disposers = [];
|
|
12
|
+
const t = codingNsTranslator(ctx.locale);
|
|
13
|
+
const theme = {
|
|
14
|
+
getSnapshot: () => ctx.theme.getTheme().revision,
|
|
15
|
+
subscribe: (listener) => ctx.on('theme/change', listener),
|
|
16
|
+
};
|
|
17
|
+
const sidebarRight = ctx.sidebarRight;
|
|
18
|
+
const registerCloseHandler = sidebarRight.registerCloseHandler;
|
|
19
|
+
// alpha2 提供多 Tab 元数据和关闭 API;rc3 没有这些字段,不能直接调用。
|
|
20
|
+
const legacyCloseFallback = typeof registerCloseHandler !== 'function';
|
|
21
|
+
const supportsMultiple = typeof ctx.sidebarRight.openTabs !== 'undefined';
|
|
22
|
+
const guideEntrySlot = ctx.slots.specDynamic?.('sidebar.right.tab.guide.entry') !== undefined;
|
|
23
|
+
disposers.push(installTerminalStyles());
|
|
24
|
+
const tabDefinition = {
|
|
25
|
+
id: TERMINAL_PROVIDER_ID,
|
|
26
|
+
kind: TERMINAL_KIND,
|
|
27
|
+
...(supportsMultiple ? { multiple: true } : {}),
|
|
28
|
+
priority: 'extension',
|
|
29
|
+
title: () => t('terminal.title'),
|
|
30
|
+
guide: [{
|
|
31
|
+
id: 'new',
|
|
32
|
+
order: 20,
|
|
33
|
+
title: () => t('terminal.new'),
|
|
34
|
+
description: () => t('terminal.description'),
|
|
35
|
+
icon: TerminalGuideIcon,
|
|
36
|
+
}],
|
|
37
|
+
};
|
|
38
|
+
disposers.push(ctx.sidebarRightTabs.register(tabDefinition));
|
|
39
|
+
disposers.push(ctx.slots.inject('sidebar.right.pane.tab', () => ctx.slots.register({
|
|
40
|
+
name: 'sidebar.right.pane.tab', key: TERMINAL_PROVIDER_ID,
|
|
41
|
+
inject: () => ({ webTerminals, settings, theme, locale: ctx.locale, legacyCloseFallback }),
|
|
42
|
+
}, TerminalBody)));
|
|
43
|
+
disposers.push(ctx.slots.inject('sidebar.right.pane.tab.title', () => ctx.slots.register({
|
|
44
|
+
name: 'sidebar.right.pane.tab.title', key: TERMINAL_PROVIDER_ID,
|
|
45
|
+
inject: () => ({ webTerminals, locale: ctx.locale }),
|
|
46
|
+
}, TerminalTitle)));
|
|
47
|
+
if (guideEntrySlot)
|
|
48
|
+
disposers.push(ctx.slots.inject('sidebar.right.tab.guide.entry', () => ctx.slots.register({
|
|
49
|
+
name: 'sidebar.right.tab.guide.entry', key: TERMINAL_PROVIDER_ID,
|
|
50
|
+
inject: () => ({ webTerminals, locale: ctx.locale }),
|
|
51
|
+
}, TerminalGuide)));
|
|
52
|
+
disposers.push(ctx.slots.inject('shell.overlay', () => ctx.slots.register({
|
|
53
|
+
name: 'shell.overlay', id: 'codingns4dsh-terminal-cleanup', order: 1000,
|
|
54
|
+
inject: () => ({ webTerminals, locale: ctx.locale }),
|
|
55
|
+
}, TerminalCleanup)));
|
|
56
|
+
if (typeof registerCloseHandler === 'function')
|
|
57
|
+
disposers.push(registerCloseHandler.call(ctx.sidebarRight, TERMINAL_KIND, (sessionId, tab) => {
|
|
58
|
+
const params = navigationParams(tab);
|
|
59
|
+
webTerminals.close(String(sessionId), String(tab.id), tab.contentId, params.terminalId);
|
|
60
|
+
}));
|
|
61
|
+
return () => { for (const dispose of disposers.reverse())
|
|
62
|
+
dispose(); };
|
|
63
|
+
}
|
|
64
|
+
function TerminalBody({ sessionId, useTabInfo, webTerminals, settings, theme, legacyCloseFallback }) {
|
|
65
|
+
const info = useTabInfo();
|
|
66
|
+
const params = terminalParams(info);
|
|
67
|
+
const view = webTerminals.view(String(sessionId), String(info.tab.id), info.tab.contentId, params.terminalId, params.shellPath);
|
|
68
|
+
const themeRevision = useSyncExternalStore(theme.subscribe, theme.getSnapshot);
|
|
69
|
+
useEffect(() => info.tab.visible ? view.mount() : undefined, [info.tab.visible, view]);
|
|
70
|
+
useEffect(() => {
|
|
71
|
+
if (!legacyCloseFallback)
|
|
72
|
+
return;
|
|
73
|
+
// rc3 没有显式关闭回调,只能利用 Tab 被移除时的 signal 回收对应 Host 终端。
|
|
74
|
+
const close = () => {
|
|
75
|
+
const nextParams = navigationParams(info.tab);
|
|
76
|
+
webTerminals.close(String(sessionId), String(info.tab.id), info.tab.contentId, nextParams.terminalId);
|
|
77
|
+
};
|
|
78
|
+
if (info.tab.signal.aborted)
|
|
79
|
+
close();
|
|
80
|
+
else
|
|
81
|
+
info.tab.signal.addEventListener('abort', close, { once: true });
|
|
82
|
+
return () => info.tab.signal.removeEventListener('abort', close);
|
|
83
|
+
}, [legacyCloseFallback, info.tab, sessionId, webTerminals]);
|
|
84
|
+
return info.tab.visible ? createElement(CodingNsXtermView, {
|
|
85
|
+
view,
|
|
86
|
+
settings,
|
|
87
|
+
themeRevision,
|
|
88
|
+
onNewTerminal: () => info.tab.actions.openTab(TERMINAL_KIND, { replaceTab: true }),
|
|
89
|
+
}) : null;
|
|
90
|
+
}
|
|
91
|
+
function TerminalTitle({ sessionId, useTabInfo, webTerminals, locale }) {
|
|
92
|
+
const t = useCodingNsTranslator(locale);
|
|
93
|
+
const info = useTabInfo();
|
|
94
|
+
const params = terminalParams(info);
|
|
95
|
+
const view = webTerminals.view(String(sessionId), String(info.tab.id), info.tab.contentId, params.terminalId, params.shellPath);
|
|
96
|
+
const state = useSyncExternalStore(view.state.subscribe.bind(view.state), view.state.getSnapshot.bind(view.state));
|
|
97
|
+
const [editing, setEditing] = useState(false);
|
|
98
|
+
const [title, setTitle] = useState(state.title);
|
|
99
|
+
const input = useRef(null);
|
|
100
|
+
useEffect(() => { if (!editing)
|
|
101
|
+
setTitle(state.title); }, [editing, state.title]);
|
|
102
|
+
useLayoutEffect(() => {
|
|
103
|
+
if (!editing)
|
|
104
|
+
return;
|
|
105
|
+
input.current?.focus();
|
|
106
|
+
input.current?.select();
|
|
107
|
+
}, [editing]);
|
|
108
|
+
const beginEditing = (event) => {
|
|
109
|
+
event.stopPropagation();
|
|
110
|
+
if (event.detail === undefined || event.detail >= 2)
|
|
111
|
+
setEditing(true);
|
|
112
|
+
};
|
|
113
|
+
return createElement(Fragment, undefined, createElement(TerminalIcon), editing
|
|
114
|
+
? createElement('input', {
|
|
115
|
+
ref: input,
|
|
116
|
+
value: title,
|
|
117
|
+
maxLength: 120,
|
|
118
|
+
'aria-label': t('terminal.title'),
|
|
119
|
+
className: terminalClass.titleInput,
|
|
120
|
+
onPointerDown: stopPropagation,
|
|
121
|
+
onClick: stopPropagation,
|
|
122
|
+
onDoubleClick: stopPropagation,
|
|
123
|
+
onChange: (event) => setTitle(event.currentTarget.value),
|
|
124
|
+
onBlur: () => { setEditing(false); void view.rename(title); },
|
|
125
|
+
onKeyDown: (event) => {
|
|
126
|
+
event.stopPropagation();
|
|
127
|
+
if (event.key === 'Escape') {
|
|
128
|
+
setTitle(state.title);
|
|
129
|
+
event.currentTarget.blur();
|
|
130
|
+
}
|
|
131
|
+
else if (event.key === 'Enter')
|
|
132
|
+
event.currentTarget.blur();
|
|
133
|
+
},
|
|
134
|
+
})
|
|
135
|
+
: createElement('span', {
|
|
136
|
+
className: terminalClass.title,
|
|
137
|
+
onPointerDown: stopPropagation,
|
|
138
|
+
onMouseDown: stopPropagation,
|
|
139
|
+
onClick: beginEditing,
|
|
140
|
+
onDoubleClick: beginEditing,
|
|
141
|
+
title: t('terminal.rename'),
|
|
142
|
+
}, state.title));
|
|
143
|
+
}
|
|
144
|
+
function TerminalGuide({ sessionId, useTabInfo, webTerminals, title, description, locale }) {
|
|
145
|
+
const t = useCodingNsTranslator(locale);
|
|
146
|
+
const info = useTabInfo();
|
|
147
|
+
const [open, setOpen] = useState(false);
|
|
148
|
+
const [attempt, setAttempt] = useState(0);
|
|
149
|
+
const [state, setState] = useState({ phase: 'loading' });
|
|
150
|
+
useEffect(() => {
|
|
151
|
+
if (!open)
|
|
152
|
+
return;
|
|
153
|
+
const controller = new AbortController();
|
|
154
|
+
void webTerminals.launchShells(String(sessionId), controller.signal).then((result) => {
|
|
155
|
+
if (controller.signal.aborted)
|
|
156
|
+
return;
|
|
157
|
+
setState({
|
|
158
|
+
phase: 'ready',
|
|
159
|
+
shells: result.shells,
|
|
160
|
+
...(result.selectedShell === undefined ? {} : { selected: result.selectedShell }),
|
|
161
|
+
});
|
|
162
|
+
}).catch((cause) => {
|
|
163
|
+
if (!controller.signal.aborted)
|
|
164
|
+
setState({ phase: 'failed', message: messageOf(cause) });
|
|
165
|
+
});
|
|
166
|
+
return () => controller.abort();
|
|
167
|
+
}, [open, attempt, sessionId, webTerminals]);
|
|
168
|
+
return createElement('div', {
|
|
169
|
+
className: terminalClass.guideEntry,
|
|
170
|
+
'data-sidebar-right-guide-entry': TERMINAL_KIND,
|
|
171
|
+
}, createElement(Button, {
|
|
172
|
+
variant: 'ghost',
|
|
173
|
+
className: terminalClass.guideMain,
|
|
174
|
+
onClick: () => info.tab.actions.openTab(TERMINAL_KIND, { replaceTab: true }),
|
|
175
|
+
}, createElement(TerminalGuideIcon, { size: description === undefined ? 22 : 26, className: terminalClass.guideIcon }), createElement('span', { className: terminalClass.guideText }, createElement('span', { className: terminalClass.guideTitle }, title), description === undefined ? null : createElement('span', { className: terminalClass.guideDescription }, description))), createElement(Menu, {
|
|
176
|
+
open,
|
|
177
|
+
portal: true,
|
|
178
|
+
autoFocus: true,
|
|
179
|
+
align: 'end',
|
|
180
|
+
className: terminalClass.guideMenu,
|
|
181
|
+
items: shellMenuItems(state, t),
|
|
182
|
+
...(state.phase === 'ready' && state.selected !== undefined ? { selectedId: state.selected } : {}),
|
|
183
|
+
onClose: () => setOpen(false),
|
|
184
|
+
onSelect: (path) => {
|
|
185
|
+
if (state.phase === 'failed') {
|
|
186
|
+
setState({ phase: 'loading' });
|
|
187
|
+
setAttempt((value) => value + 1);
|
|
188
|
+
return;
|
|
189
|
+
}
|
|
190
|
+
if (state.phase !== 'ready')
|
|
191
|
+
return;
|
|
192
|
+
webTerminals.selectShell(path);
|
|
193
|
+
setOpen(false);
|
|
194
|
+
info.tab.actions.openTab(TERMINAL_KIND, { params: { shellPath: path }, replaceTab: true });
|
|
195
|
+
},
|
|
196
|
+
anchor: createElement(Button, {
|
|
197
|
+
variant: 'ghost',
|
|
198
|
+
className: terminalClass.guideTrigger,
|
|
199
|
+
'aria-label': t('terminal.selectShell'),
|
|
200
|
+
'aria-haspopup': 'menu',
|
|
201
|
+
'aria-expanded': open,
|
|
202
|
+
onClick: () => { setState({ phase: 'loading' }); setOpen((value) => !value); },
|
|
203
|
+
}, createElement(IconChevronDownOutline14)),
|
|
204
|
+
}));
|
|
205
|
+
}
|
|
206
|
+
function shellMenuItems(state, t) {
|
|
207
|
+
if (state.phase === 'loading')
|
|
208
|
+
return [{ id: 'loading', label: t('terminal.loadingShell'), disabled: true }];
|
|
209
|
+
if (state.phase === 'failed')
|
|
210
|
+
return [
|
|
211
|
+
{ id: 'error', label: `${t('terminal.error')}: ${state.message}`, disabled: true },
|
|
212
|
+
{ id: 'retry', label: t('terminal.retry') },
|
|
213
|
+
];
|
|
214
|
+
if (state.shells.length === 0)
|
|
215
|
+
return [{ id: 'empty', label: t('terminal.noShell'), disabled: true }];
|
|
216
|
+
return state.shells.map((shell) => ({ id: shell.path, label: shell.name }));
|
|
217
|
+
}
|
|
218
|
+
function TerminalCleanup({ webTerminals, locale }) {
|
|
219
|
+
const t = useCodingNsTranslator(locale);
|
|
220
|
+
const failures = useSyncExternalStore(webTerminals.closeFailures.subscribe.bind(webTerminals.closeFailures), webTerminals.closeFailures.getSnapshot.bind(webTerminals.closeFailures));
|
|
221
|
+
if (failures.length === 0)
|
|
222
|
+
return null;
|
|
223
|
+
return createElement('div', { className: terminalClass.cleanupStack }, ...failures.map((failure) => createElement('div', {
|
|
224
|
+
key: String(failure.id),
|
|
225
|
+
className: terminalClass.cleanupNotice,
|
|
226
|
+
role: 'alert',
|
|
227
|
+
}, createElement('span', undefined, t('terminal.cleanupFailed', { title: failure.title, message: failure.message })), createElement('button', { type: 'button', onClick: () => webTerminals.retryClose(failure.id) }, t('terminal.retry')))));
|
|
228
|
+
}
|
|
229
|
+
function terminalParams(info) {
|
|
230
|
+
const params = info.tab.navigation.params;
|
|
231
|
+
return typeof params === 'object' && params !== null ? params : {};
|
|
232
|
+
}
|
|
233
|
+
function navigationParams(tab) {
|
|
234
|
+
const params = tab.navigation?.params;
|
|
235
|
+
return typeof params === 'object' && params !== null ? params : {};
|
|
236
|
+
}
|
|
237
|
+
function messageOf(value) { return value instanceof Error ? value.message : String(value); }
|
|
238
|
+
function stopPropagation(event) { event.stopPropagation(); }
|
|
239
|
+
function TerminalIcon() {
|
|
240
|
+
return createElement('svg', { width: 16, height: 16, viewBox: '0 0 16 16', fill: 'none', 'aria-hidden': true }, createElement('path', {
|
|
241
|
+
d: 'm3 4 4 4-4 4M9 12h4',
|
|
242
|
+
stroke: 'currentColor',
|
|
243
|
+
strokeWidth: 1.5,
|
|
244
|
+
strokeLinecap: 'round',
|
|
245
|
+
strokeLinejoin: 'round',
|
|
246
|
+
}));
|
|
247
|
+
}
|
|
248
|
+
function TerminalGuideIcon({ size = 26, className }) {
|
|
249
|
+
return createElement('svg', { width: size, height: size, className, viewBox: '0 0 28 28', fill: 'none', 'aria-hidden': true }, createElement('rect', { x: 3, y: 5, width: 22, height: 19, rx: 3, fill: '#17191d' }), createElement('path', {
|
|
250
|
+
d: 'm8 10 4 4-4 4M15 18h5',
|
|
251
|
+
stroke: '#fff',
|
|
252
|
+
strokeWidth: 1.7,
|
|
253
|
+
strokeLinecap: 'round',
|
|
254
|
+
strokeLinejoin: 'round',
|
|
255
|
+
}));
|
|
256
|
+
}
|
|
257
|
+
//# sourceMappingURL=ui.js.map
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { ReactElement } from 'react';
|
|
2
|
+
import type { SettingsScope } from '@deepseek-ai/dsh-client-ui-settings/client';
|
|
3
|
+
import { type CodingNsSettings } from '../../shared/contracts/config.js';
|
|
4
|
+
import type { CodingNsTerminalView } from './model.js';
|
|
5
|
+
export interface CodingNsXtermViewProps {
|
|
6
|
+
readonly view: CodingNsTerminalView;
|
|
7
|
+
readonly settings: SettingsScope<CodingNsSettings>;
|
|
8
|
+
readonly themeRevision: number;
|
|
9
|
+
readonly onNewTerminal: () => void;
|
|
10
|
+
}
|
|
11
|
+
/** 使用与 DSH 内置终端相同的布局、状态条和 xterm 默认参数。 */
|
|
12
|
+
export declare function CodingNsXtermView({ view, settings, themeRevision, onNewTerminal, }: CodingNsXtermViewProps): ReactElement;
|
|
13
|
+
//# sourceMappingURL=xterm-view.d.ts.map
|
|
@@ -0,0 +1,213 @@
|
|
|
1
|
+
import { createElement, useEffect, useRef, useSyncExternalStore } from 'react';
|
|
2
|
+
import { Button, IconPlusOutline16 } from '@deepseek-ai/dsh-client-ui-primitives';
|
|
3
|
+
import { FitAddon } from '@xterm/addon-fit';
|
|
4
|
+
import { Terminal } from '@xterm/xterm';
|
|
5
|
+
import xtermCss from '@xterm/xterm/css/xterm.css';
|
|
6
|
+
import { DEFAULT_TERMINAL_ENHANCEMENT_SETTINGS, } from '../../shared/contracts/config.js';
|
|
7
|
+
import { terminalClass } from './styles.js';
|
|
8
|
+
/** 使用与 DSH 内置终端相同的布局、状态条和 xterm 默认参数。 */
|
|
9
|
+
export function CodingNsXtermView({ view, settings, themeRevision, onNewTerminal, }) {
|
|
10
|
+
const hostRef = useRef(null);
|
|
11
|
+
const terminalRef = useRef(null);
|
|
12
|
+
const fitRef = useRef(null);
|
|
13
|
+
const lastRevision = useRef(0);
|
|
14
|
+
const state = useSyncExternalStore(view.state.subscribe.bind(view.state), view.state.getSnapshot.bind(view.state));
|
|
15
|
+
const settingsSnapshot = useSyncExternalStore(settings.subscribe.bind(settings), settings.getSnapshot.bind(settings));
|
|
16
|
+
const appearance = settingsSnapshot.value?.terminalEnhancement.appearance
|
|
17
|
+
?? DEFAULT_TERMINAL_ENHANCEMENT_SETTINGS.appearance;
|
|
18
|
+
const hasTerminal = state.info !== undefined;
|
|
19
|
+
useEffect(() => {
|
|
20
|
+
const host = hostRef.current;
|
|
21
|
+
if (host === null || !hasTerminal)
|
|
22
|
+
return;
|
|
23
|
+
const root = host.shadowRoot ?? host.attachShadow({ mode: 'open' });
|
|
24
|
+
const style = document.createElement('style');
|
|
25
|
+
style.textContent = shadowCss;
|
|
26
|
+
const container = document.createElement('div');
|
|
27
|
+
container.className = 'codingns-xterm';
|
|
28
|
+
root.replaceChildren(style, container);
|
|
29
|
+
const terminal = new Terminal(terminalOptions(appearance, host, state.environment?.scrollback ?? 0, !state.writable));
|
|
30
|
+
const fit = new FitAddon();
|
|
31
|
+
terminal.loadAddon(fit);
|
|
32
|
+
terminal.open(container);
|
|
33
|
+
terminal.textarea?.setAttribute('aria-label', '终端');
|
|
34
|
+
terminalRef.current = terminal;
|
|
35
|
+
fitRef.current = fit;
|
|
36
|
+
lastRevision.current = 0;
|
|
37
|
+
const input = terminal.onData((data) => view.write(data));
|
|
38
|
+
// 调试终端由 Host 预设“配置名(终端类型)”标题;Shell 启动时通常会发一个 zsh 等默认标题,不能覆盖它。
|
|
39
|
+
const preserveHostTitle = state.info !== undefined && state.info.title !== state.info.shell.name;
|
|
40
|
+
const title = terminal.onTitleChange((value) => {
|
|
41
|
+
if (!preserveHostTitle)
|
|
42
|
+
void view.rename(value);
|
|
43
|
+
});
|
|
44
|
+
const measure = () => {
|
|
45
|
+
if (!state.writable || host.clientWidth === 0 || host.clientHeight === 0)
|
|
46
|
+
return;
|
|
47
|
+
fitTerminal(terminal, fit, view);
|
|
48
|
+
};
|
|
49
|
+
const resize = new ResizeObserver(measure);
|
|
50
|
+
resize.observe(host);
|
|
51
|
+
measure();
|
|
52
|
+
return () => {
|
|
53
|
+
resize.disconnect();
|
|
54
|
+
input.dispose();
|
|
55
|
+
title.dispose();
|
|
56
|
+
terminal.dispose();
|
|
57
|
+
terminalRef.current = null;
|
|
58
|
+
fitRef.current = null;
|
|
59
|
+
root.replaceChildren();
|
|
60
|
+
};
|
|
61
|
+
}, [hasTerminal, view]);
|
|
62
|
+
useEffect(() => {
|
|
63
|
+
const terminal = terminalRef.current;
|
|
64
|
+
const host = hostRef.current;
|
|
65
|
+
if (terminal === null || host === null)
|
|
66
|
+
return;
|
|
67
|
+
applyAppearance(terminal, appearance, host, state.environment?.scrollback ?? 0);
|
|
68
|
+
terminal.options.disableStdin = !state.writable;
|
|
69
|
+
if (state.writable && host.clientWidth > 0 && host.clientHeight > 0) {
|
|
70
|
+
fitTerminal(terminal, fitRef.current, view);
|
|
71
|
+
terminal.focus();
|
|
72
|
+
}
|
|
73
|
+
else if (state.info !== undefined) {
|
|
74
|
+
terminal.resize(state.info.cols, state.info.rows);
|
|
75
|
+
}
|
|
76
|
+
}, [
|
|
77
|
+
appearance,
|
|
78
|
+
state.environment?.scrollback,
|
|
79
|
+
state.info?.cols,
|
|
80
|
+
state.info?.rows,
|
|
81
|
+
state.writable,
|
|
82
|
+
themeRevision,
|
|
83
|
+
view,
|
|
84
|
+
]);
|
|
85
|
+
useEffect(() => {
|
|
86
|
+
const terminal = terminalRef.current;
|
|
87
|
+
const render = state.render;
|
|
88
|
+
if (terminal === null || render === undefined || render.revision <= lastRevision.current)
|
|
89
|
+
return;
|
|
90
|
+
lastRevision.current = render.revision;
|
|
91
|
+
if (render.frame.type === 'snapshot') {
|
|
92
|
+
terminal.reset();
|
|
93
|
+
terminal.resize(render.frame.info.cols, render.frame.info.rows);
|
|
94
|
+
}
|
|
95
|
+
const data = render.frame.type === 'snapshot' ? render.frame.screen : render.frame.data;
|
|
96
|
+
terminal.write(data, () => view.acknowledge(render.revision));
|
|
97
|
+
}, [state.render, view]);
|
|
98
|
+
return createElement('section', {
|
|
99
|
+
className: terminalClass.root,
|
|
100
|
+
'data-sidebar-terminal': true,
|
|
101
|
+
}, createElement(TerminalStatus, { state, view, onNewTerminal }), hasTerminal ? createElement('div', { className: terminalClass.screen }, createElement('div', { ref: hostRef, style: terminalHostStyle })) : null, state.error === undefined || state.phase === 'disconnected'
|
|
102
|
+
? null
|
|
103
|
+
: createElement('p', { className: terminalClass.error, role: 'alert' }, `终端错误:${state.error}`));
|
|
104
|
+
}
|
|
105
|
+
function TerminalStatus({ state, view, onNewTerminal, }) {
|
|
106
|
+
const status = statusText(state);
|
|
107
|
+
const ended = state.info?.state === 'exited' || state.phase === 'closed';
|
|
108
|
+
const retry = !ended && (state.phase === 'failed' || state.phase === 'disconnected');
|
|
109
|
+
const readOnly = state.phase === 'connected' && state.info?.state === 'running' && !state.writable;
|
|
110
|
+
if (status === undefined && !retry && !readOnly)
|
|
111
|
+
return null;
|
|
112
|
+
return createElement('div', { className: terminalClass.status, role: 'status' }, status, readOnly ? '此页面当前只读。' : null, retry ? createElement(Button, {
|
|
113
|
+
variant: 'outline',
|
|
114
|
+
size: 'sm',
|
|
115
|
+
onClick: () => { void view.refresh(); },
|
|
116
|
+
}, state.phase === 'disconnected' ? '重新连接' : '重试') : null, ended ? createElement(Button, {
|
|
117
|
+
variant: 'primary',
|
|
118
|
+
size: 'sm',
|
|
119
|
+
icon: createElement(IconPlusOutline16),
|
|
120
|
+
onClick: onNewTerminal,
|
|
121
|
+
}, '新建终端') : null);
|
|
122
|
+
}
|
|
123
|
+
function statusText(state) {
|
|
124
|
+
if (state.phase === 'idle' || state.phase === 'loading')
|
|
125
|
+
return '正在读取终端环境…';
|
|
126
|
+
if (state.phase === 'creating')
|
|
127
|
+
return '正在启动…';
|
|
128
|
+
if (state.phase === 'connecting')
|
|
129
|
+
return '正在连接…';
|
|
130
|
+
if (state.phase === 'disconnected')
|
|
131
|
+
return '连接已断开。';
|
|
132
|
+
if (state.info?.state === 'exited')
|
|
133
|
+
return `进程已退出(${state.info.exitCode ?? '—'})`;
|
|
134
|
+
if (state.info?.state === 'failed')
|
|
135
|
+
return '不可用';
|
|
136
|
+
if (state.phase === 'closed')
|
|
137
|
+
return '终端已关闭。';
|
|
138
|
+
return undefined;
|
|
139
|
+
}
|
|
140
|
+
function terminalOptions(appearance, host, scrollback, disableStdin) {
|
|
141
|
+
const computed = getComputedStyle(host);
|
|
142
|
+
return {
|
|
143
|
+
allowProposedApi: false,
|
|
144
|
+
convertEol: false,
|
|
145
|
+
disableStdin,
|
|
146
|
+
minimumContrastRatio: 4.5,
|
|
147
|
+
fontFamily: appearance.fontFamily ?? 'ui-monospace, SFMono-Regular, Menlo, Consolas, monospace',
|
|
148
|
+
fontSize: appearance.fontSize ?? 13,
|
|
149
|
+
lineHeight: appearance.lineHeight ?? 1,
|
|
150
|
+
cursorStyle: appearance.cursorStyle ?? 'block',
|
|
151
|
+
cursorBlink: appearance.cursorBlink ?? true,
|
|
152
|
+
scrollback: appearance.scrollback ?? scrollback,
|
|
153
|
+
theme: terminalTheme(appearance, computed),
|
|
154
|
+
};
|
|
155
|
+
}
|
|
156
|
+
function applyAppearance(terminal, appearance, host, scrollback) {
|
|
157
|
+
const next = terminalOptions(appearance, host, scrollback, terminal.options.disableStdin ?? false);
|
|
158
|
+
terminal.options.fontFamily = next.fontFamily;
|
|
159
|
+
terminal.options.fontSize = next.fontSize;
|
|
160
|
+
terminal.options.lineHeight = next.lineHeight;
|
|
161
|
+
terminal.options.cursorStyle = next.cursorStyle;
|
|
162
|
+
terminal.options.cursorBlink = next.cursorBlink;
|
|
163
|
+
terminal.options.scrollback = next.scrollback;
|
|
164
|
+
terminal.options.minimumContrastRatio = next.minimumContrastRatio;
|
|
165
|
+
terminal.options.theme = next.theme;
|
|
166
|
+
}
|
|
167
|
+
function terminalTheme(appearance, computed) {
|
|
168
|
+
const custom = appearance.theme === 'custom';
|
|
169
|
+
const background = custom
|
|
170
|
+
? appearance.background ?? '#111111'
|
|
171
|
+
: visibleColor(computed.backgroundColor, '#111111');
|
|
172
|
+
const foreground = custom
|
|
173
|
+
? appearance.foreground ?? '#f3f3f3'
|
|
174
|
+
: visibleColor(computed.color, '#f3f3f3');
|
|
175
|
+
const cursor = custom
|
|
176
|
+
? appearance.cursorColor ?? foreground
|
|
177
|
+
: foreground;
|
|
178
|
+
return {
|
|
179
|
+
background,
|
|
180
|
+
foreground,
|
|
181
|
+
cursor,
|
|
182
|
+
cursorAccent: background,
|
|
183
|
+
selectionBackground: foreground,
|
|
184
|
+
selectionForeground: background,
|
|
185
|
+
selectionInactiveBackground: foreground,
|
|
186
|
+
};
|
|
187
|
+
}
|
|
188
|
+
function fitTerminal(terminal, fit, view) {
|
|
189
|
+
const dimensions = fit?.proposeDimensions();
|
|
190
|
+
if (dimensions === undefined)
|
|
191
|
+
return;
|
|
192
|
+
terminal.resize(dimensions.cols, dimensions.rows);
|
|
193
|
+
view.resize(dimensions.cols, dimensions.rows);
|
|
194
|
+
}
|
|
195
|
+
function visibleColor(value, fallback) {
|
|
196
|
+
const normalized = value.trim();
|
|
197
|
+
return normalized === '' || normalized === 'rgba(0, 0, 0, 0)' ? fallback : normalized;
|
|
198
|
+
}
|
|
199
|
+
const terminalHostStyle = {
|
|
200
|
+
width: '100%',
|
|
201
|
+
height: '100%',
|
|
202
|
+
minWidth: 0,
|
|
203
|
+
minHeight: 0,
|
|
204
|
+
color: 'var(--dsw-alias-label-primary)',
|
|
205
|
+
background: 'var(--dsw-alias-bg-base)',
|
|
206
|
+
};
|
|
207
|
+
const shadowCss = `${xtermCss}
|
|
208
|
+
:host{display:block;width:100%;height:100%;min-width:0;min-height:0;color:inherit;background:inherit}
|
|
209
|
+
.codingns-xterm{width:100%;height:100%}
|
|
210
|
+
.xterm{height:100%}
|
|
211
|
+
.xterm-viewport{background:var(--dsw-alias-bg-base)}
|
|
212
|
+
`;
|
|
213
|
+
//# sourceMappingURL=xterm-view.js.map
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import type { CSSProperties } from 'react';
|
|
2
|
+
/**
|
|
3
|
+
* DSH 0.1.6 暴露的主题令牌。
|
|
4
|
+
*
|
|
5
|
+
* 回退值只服务于独立测试或宿主尚未加载主题的瞬间;正常运行时由 DSH 的明暗
|
|
6
|
+
* 主题覆盖。所有表单表面必须同时设置背景和前景,避免再次出现白底白字。
|
|
7
|
+
*/
|
|
8
|
+
export declare const dshThemeColor: {
|
|
9
|
+
readonly labelPrimary: "var(--dsw-alias-label-primary, CanvasText)";
|
|
10
|
+
readonly labelSecondary: "var(--dsw-alias-label-secondary, GrayText)";
|
|
11
|
+
readonly labelTertiary: "var(--dsw-alias-label-tertiary, GrayText)";
|
|
12
|
+
readonly labelCaption: "var(--dsw-alias-label-caption, GrayText)";
|
|
13
|
+
readonly border: "var(--dsw-alias-border-l2, #d9d9d9)";
|
|
14
|
+
readonly inputBackground: "var(--dsw-specific-input-major, Canvas)";
|
|
15
|
+
readonly surfaceSubtle: "var(--dsw-alias-bg-secondary, rgba(127, 127, 127, 0.06))";
|
|
16
|
+
readonly buttonBackground: "var(--dsw-alias-button-elevated-fill, transparent)";
|
|
17
|
+
readonly menuBackground: "var(--dsw-specific-menu, Canvas)";
|
|
18
|
+
readonly pageBackground: "var(--dsw-alias-bg-primary, Canvas)";
|
|
19
|
+
readonly overlay: "var(--dsw-alias-bg-mask-1, rgba(0, 0, 0, 0.45))";
|
|
20
|
+
readonly accent: "var(--dsw-alias-button-info-fill, #1677ff)";
|
|
21
|
+
readonly success: "var(--dsw-alias-state-success-primary, #16803c)";
|
|
22
|
+
readonly error: "var(--dsw-alias-state-error-primary, #b42318)";
|
|
23
|
+
readonly switchThumb: "var(--dsw-static-neutral-00, #fff)";
|
|
24
|
+
readonly prominentShadow: "var(--dsw-elevation-prominent, 0 12px 40px rgba(0, 0, 0, 0.25))";
|
|
25
|
+
readonly subtleShadow: "var(--dsw-elevation-l1, 0 1px 2px rgba(0, 0, 0, 0.06))";
|
|
26
|
+
};
|
|
27
|
+
/** 设置模块根节点显式接入 DSH 的主文字色。 */
|
|
28
|
+
export declare const dshFormRootStyle: CSSProperties;
|
|
29
|
+
/** input、select 和 textarea 共用的主题表面。 */
|
|
30
|
+
export declare const dshFieldStyle: CSSProperties;
|
|
31
|
+
/** 普通表单按钮共用的主题表面。 */
|
|
32
|
+
export declare const dshButtonStyle: CSSProperties;
|
|
33
|
+
/** Codingns4DSH 设置页共享外壳:保持紧凑宽度,避免挤压宿主设置导航。 */
|
|
34
|
+
export declare const dshSettingsPageStyle: CSSProperties;
|
|
35
|
+
/** 设置页标题区,使用宿主主题颜色而不是独立品牌色。 */
|
|
36
|
+
export declare const dshSettingsHeaderStyle: CSSProperties;
|
|
37
|
+
export declare const dshSettingsTitleStyle: CSSProperties;
|
|
38
|
+
export declare const dshSettingsSubtitleStyle: CSSProperties;
|
|
39
|
+
/** 模块卡片和标题栏共享的结构样式。 */
|
|
40
|
+
export declare const dshSettingsCardStyle: CSSProperties;
|
|
41
|
+
export declare const dshSettingsSummaryStyle: CSSProperties;
|
|
42
|
+
export declare const dshSettingsSummaryTextStyle: CSSProperties;
|
|
43
|
+
export declare const dshSettingsSummaryLabelStyle: CSSProperties;
|
|
44
|
+
export declare const dshSettingsSummaryDescriptionStyle: CSSProperties;
|
|
45
|
+
export declare const dshSettingsBodyStyle: CSSProperties;
|
|
46
|
+
export declare const dshSettingsFieldLabelStyle: CSSProperties;
|
|
47
|
+
export declare const dshSettingsFieldStyle: CSSProperties;
|
|
48
|
+
export declare const dshSettingsButtonStyle: CSSProperties;
|
|
49
|
+
export declare const dshSettingsPrimaryButtonStyle: CSSProperties;
|
|
50
|
+
export declare const dshSettingsRowStyle: CSSProperties;
|
|
51
|
+
export declare const dshSettingsListRowStyle: CSSProperties;
|
|
52
|
+
export declare const dshSettingsHelpStyle: CSSProperties;
|
|
53
|
+
export declare const dshSettingsNoteStyle: CSSProperties;
|
|
54
|
+
/** 模态框和弹出菜单必须成对设置前景色与背景色。 */
|
|
55
|
+
export declare const dshPopupSurfaceStyle: CSSProperties;
|
|
56
|
+
//# sourceMappingURL=theme.d.ts.map
|