@linxin666/dsh-ssh 0.1.1
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 +75 -0
- package/cordis.patch.yml +12 -0
- package/lib/client.js +15638 -0
- package/lib/index.js +3297 -0
- package/lib/invariant.js +6 -0
- package/lib/types/client/api.d.ts +72 -0
- package/lib/types/client/index.d.ts +37 -0
- package/lib/types/client/locales.d.ts +137 -0
- package/lib/types/client/mount.d.ts +12 -0
- package/lib/types/client/panel/ClusterTab.d.ts +7 -0
- package/lib/types/client/panel/HostFormDialog.d.ts +12 -0
- package/lib/types/client/panel/HostsTab.d.ts +9 -0
- package/lib/types/client/panel/SshPanel.d.ts +13 -0
- package/lib/types/client/panel/TerminalTab.d.ts +11 -0
- package/lib/types/client/panel/TransferTab.d.ts +7 -0
- package/lib/types/client/panel/TunnelsTab.d.ts +7 -0
- package/lib/types/client/panel/controller.d.ts +22 -0
- package/lib/types/client/panel/helpers.d.ts +14 -0
- package/lib/types/client/panel/xterm.css.d.ts +2 -0
- package/lib/types/client/sidebar-entry.d.ts +24 -0
- package/lib/types/engine.d.ts +135 -0
- package/lib/types/index.d.ts +40 -0
- package/lib/types/invariant.d.ts +3 -0
- package/lib/types/protocol.d.ts +189 -0
- package/lib/types/routes.d.ts +29 -0
- package/lib/types/store.d.ts +54 -0
- package/lib/types/tools.d.ts +18 -0
- package/package.json +106 -0
- package/src/client/api.ts +363 -0
- package/src/client/css-modules.d.ts +5 -0
- package/src/client/index.ts +68 -0
- package/src/client/locales.ts +284 -0
- package/src/client/mount.tsx +83 -0
- package/src/client/panel/ClusterTab.tsx +123 -0
- package/src/client/panel/HostFormDialog.tsx +221 -0
- package/src/client/panel/HostsTab.tsx +166 -0
- package/src/client/panel/SshPanel.tsx +77 -0
- package/src/client/panel/TerminalTab.tsx +176 -0
- package/src/client/panel/TransferTab.tsx +232 -0
- package/src/client/panel/TunnelsTab.tsx +177 -0
- package/src/client/panel/controller.ts +48 -0
- package/src/client/panel/helpers.ts +26 -0
- package/src/client/panel/panel.module.css +833 -0
- package/src/client/panel/xterm.css.ts +2 -0
- package/src/client/sidebar-entry.ts +123 -0
- package/src/engine.ts +780 -0
- package/src/index.ts +155 -0
- package/src/invariant.ts +4 -0
- package/src/protocol.ts +188 -0
- package/src/routes.ts +540 -0
- package/src/store.ts +344 -0
- package/src/tools.ts +371 -0
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
/** xterm.css text embedded at build-authoring time (the ?raw suffix is not resolvable by the tsdown/rolldown pipeline). Generated file — see the package docs. */
|
|
2
|
+
export const XTERM_CSS: string = "/**\n * Copyright (c) 2014 The xterm.js authors. All rights reserved.\n * Copyright (c) 2012-2013, Christopher Jeffrey (MIT License)\n * https://github.com/chjj/term.js\n * @license MIT\n *\n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to deal\n * in the Software without restriction, including without limitation the rights\n * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n *\n * The above copyright notice and this permission notice shall be included in\n * all copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n * THE SOFTWARE.\n *\n * Originally forked from (with the author's permission):\n * Fabrice Bellard's javascript vt100 for jslinux:\n * http://bellard.org/jslinux/\n * Copyright (c) 2011 Fabrice Bellard\n * The original design remains. The terminal itself\n * has been extended to include xterm CSI codes, among\n * other features.\n */\n\n/**\n * Default styles for xterm.js\n */\n\n.xterm {\n cursor: text;\n position: relative;\n user-select: none;\n -ms-user-select: none;\n -webkit-user-select: none;\n}\n\n.xterm.focus,\n.xterm:focus {\n outline: none;\n}\n\n.xterm .xterm-helpers {\n position: absolute;\n top: 0;\n /**\n * The z-index of the helpers must be higher than the canvases in order for\n * IMEs to appear on top.\n */\n z-index: 5;\n}\n\n.xterm .xterm-helper-textarea {\n padding: 0;\n border: 0;\n margin: 0;\n /* Move textarea out of the screen to the far left, so that the cursor is not visible */\n position: absolute;\n opacity: 0;\n left: -9999em;\n top: 0;\n width: 0;\n height: 0;\n z-index: -5;\n /** Prevent wrapping so the IME appears against the textarea at the correct position */\n white-space: nowrap;\n overflow: hidden;\n resize: none;\n}\n\n.xterm .composition-view {\n /* TODO: Composition position got messed up somewhere */\n background: #000;\n color: #FFF;\n display: none;\n position: absolute;\n white-space: nowrap;\n z-index: 1;\n}\n\n.xterm .composition-view.active {\n display: block;\n}\n\n.xterm .xterm-viewport {\n /* On OS X this is required in order for the scroll bar to appear fully opaque */\n background-color: #000;\n overflow-y: scroll;\n cursor: default;\n position: absolute;\n right: 0;\n left: 0;\n top: 0;\n bottom: 0;\n}\n\n.xterm .xterm-screen {\n position: relative;\n}\n\n.xterm .xterm-screen canvas {\n position: absolute;\n left: 0;\n top: 0;\n}\n\n.xterm-char-measure-element {\n display: inline-block;\n visibility: hidden;\n position: absolute;\n top: 0;\n left: -9999em;\n line-height: normal;\n}\n\n.xterm.enable-mouse-events {\n /* When mouse events are enabled (eg. tmux), revert to the standard pointer cursor */\n cursor: default;\n}\n\n.xterm.xterm-cursor-pointer,\n.xterm .xterm-cursor-pointer {\n cursor: pointer;\n}\n\n.xterm.column-select.focus {\n /* Column selection mode */\n cursor: crosshair;\n}\n\n.xterm .xterm-accessibility:not(.debug),\n.xterm .xterm-message {\n position: absolute;\n left: 0;\n top: 0;\n bottom: 0;\n right: 0;\n z-index: 10;\n color: transparent;\n pointer-events: none;\n}\n\n.xterm .xterm-accessibility-tree:not(.debug) *::selection {\n color: transparent;\n}\n\n.xterm .xterm-accessibility-tree {\n font-family: monospace;\n user-select: text;\n white-space: pre;\n}\n\n.xterm .xterm-accessibility-tree > div {\n transform-origin: left;\n width: fit-content;\n}\n\n.xterm .live-region {\n position: absolute;\n left: -9999px;\n width: 1px;\n height: 1px;\n overflow: hidden;\n}\n\n.xterm-dim {\n /* Dim should not apply to background, so the opacity of the foreground color is applied\n * explicitly in the generated class and reset to 1 here */\n opacity: 1 !important;\n}\n\n.xterm-underline-1 { text-decoration: underline; }\n.xterm-underline-2 { text-decoration: double underline; }\n.xterm-underline-3 { text-decoration: wavy underline; }\n.xterm-underline-4 { text-decoration: dotted underline; }\n.xterm-underline-5 { text-decoration: dashed underline; }\n\n.xterm-overline {\n text-decoration: overline;\n}\n\n.xterm-overline.xterm-underline-1 { text-decoration: overline underline; }\n.xterm-overline.xterm-underline-2 { text-decoration: overline double underline; }\n.xterm-overline.xterm-underline-3 { text-decoration: overline wavy underline; }\n.xterm-overline.xterm-underline-4 { text-decoration: overline dotted underline; }\n.xterm-overline.xterm-underline-5 { text-decoration: overline dashed underline; }\n\n.xterm-strikethrough {\n text-decoration: line-through;\n}\n\n.xterm-screen .xterm-decoration-container .xterm-decoration {\n\tz-index: 6;\n\tposition: absolute;\n}\n\n.xterm-screen .xterm-decoration-container .xterm-decoration.xterm-decoration-top-layer {\n\tz-index: 7;\n}\n\n.xterm-decoration-overview-ruler {\n z-index: 8;\n position: absolute;\n top: 0;\n right: 0;\n pointer-events: none;\n}\n\n.xterm-decoration-top {\n z-index: 2;\n position: relative;\n}\n\n\n\n/* Derived from vs/base/browser/ui/scrollbar/media/scrollbar.css */\n\n/* xterm.js customization: Override xterm's cursor style */\n.xterm .xterm-scrollable-element > .scrollbar {\n cursor: default;\n}\n\n/* Arrows */\n.xterm .xterm-scrollable-element > .scrollbar > .scra {\n\tcursor: pointer;\n\tfont-size: 11px !important;\n}\n\n.xterm .xterm-scrollable-element > .visible {\n\topacity: 1;\n\n\t/* Background rule added for IE9 - to allow clicks on dom node */\n\tbackground:rgba(0,0,0,0);\n\n\ttransition: opacity 100ms linear;\n\t/* In front of peek view */\n\tz-index: 11;\n}\n.xterm .xterm-scrollable-element > .invisible {\n\topacity: 0;\n\tpointer-events: none;\n}\n.xterm .xterm-scrollable-element > .invisible.fade {\n\ttransition: opacity 800ms linear;\n}\n\n/* Scrollable Content Inset Shadow */\n.xterm .xterm-scrollable-element > .shadow {\n\tposition: absolute;\n\tdisplay: none;\n}\n.xterm .xterm-scrollable-element > .shadow.top {\n\tdisplay: block;\n\ttop: 0;\n\tleft: 3px;\n\theight: 3px;\n\twidth: 100%;\n\tbox-shadow: var(--vscode-scrollbar-shadow, #000) 0 6px 6px -6px inset;\n}\n.xterm .xterm-scrollable-element > .shadow.left {\n\tdisplay: block;\n\ttop: 3px;\n\tleft: 0;\n\theight: 100%;\n\twidth: 3px;\n\tbox-shadow: var(--vscode-scrollbar-shadow, #000) 6px 0 6px -6px inset;\n}\n.xterm .xterm-scrollable-element > .shadow.top-left-corner {\n\tdisplay: block;\n\ttop: 0;\n\tleft: 0;\n\theight: 3px;\n\twidth: 3px;\n}\n.xterm .xterm-scrollable-element > .shadow.top.left {\n\tbox-shadow: var(--vscode-scrollbar-shadow, #000) 6px 0 6px -6px inset;\n}\n"
|
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Sidebar entry injection.
|
|
3
|
+
*
|
|
4
|
+
* dsh's sidebar shell exposes no slot an external plugin can register into,
|
|
5
|
+
* so — following the task-board precedent of DOM-level extension — the entry
|
|
6
|
+
* row is injected between the shell's New Session button and the workspace
|
|
7
|
+
* browser. The injection self-heals: a MutationObserver watches the sidebar
|
|
8
|
+
* root and re-inserts the row whenever a React re-render displaces it
|
|
9
|
+
* (re-insertion happens in the same frame, before paint, so no flicker).
|
|
10
|
+
*
|
|
11
|
+
* The row is plain DOM (no React tree) so it can never disturb the shell's
|
|
12
|
+
* reconciliation; the panel view it toggles is a separate React root mounted
|
|
13
|
+
* in the center column (see mount.tsx).
|
|
14
|
+
*/
|
|
15
|
+
import type { PanelController } from './panel/controller.ts'
|
|
16
|
+
import { tt } from './panel/helpers.ts'
|
|
17
|
+
import css from './panel/panel.module.css'
|
|
18
|
+
|
|
19
|
+
/** Stable data attribute identifying the injected entry row. */
|
|
20
|
+
export const ENTRY_SELECTOR = '[data-dsh-ssh-entry]'
|
|
21
|
+
|
|
22
|
+
/** The sidebar column is the grid item AppFrame renders with this pane marker. */
|
|
23
|
+
const SIDEBAR_COLUMN_SELECTOR = '[data-pane="sidebar"]'
|
|
24
|
+
|
|
25
|
+
/** Inline icon (matches the shell's 16px nav-icon look): a terminal prompt glyph. */
|
|
26
|
+
const ICON = '<svg viewBox="0 0 16 16" width="14" height="14" fill="none" stroke="currentColor" stroke-width="1.3" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><rect x="2" y="2.5" width="12" height="11" rx="1.5"/><path d="M4.5 5.5l2.5 2.5-2.5 2.5"/><path d="M8.5 10.5h3"/></svg>'
|
|
27
|
+
|
|
28
|
+
/** Find the sidebar shell root element, or undefined while not yet mounted. */
|
|
29
|
+
function sidebarRoot(): HTMLElement | undefined {
|
|
30
|
+
const column = document.querySelector<HTMLElement>(SIDEBAR_COLUMN_SELECTOR)
|
|
31
|
+
const root = column?.firstElementChild as HTMLElement | undefined
|
|
32
|
+
return root ?? undefined
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
/** The New Session button: the shell's only direct-child button of the root. */
|
|
36
|
+
function newSessionButton(root: HTMLElement): HTMLButtonElement | undefined {
|
|
37
|
+
for (const child of root.children) {
|
|
38
|
+
if (child.tagName === 'BUTTON') return child as HTMLButtonElement
|
|
39
|
+
}
|
|
40
|
+
return undefined
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
/** Build the entry row (a detached button; insert once the shell is up). */
|
|
44
|
+
function createEntry(controller: PanelController): HTMLButtonElement {
|
|
45
|
+
const entry = document.createElement('button')
|
|
46
|
+
entry.type = 'button'
|
|
47
|
+
entry.dataset.dshSshEntry = ''
|
|
48
|
+
entry.className = css.entry
|
|
49
|
+
entry.setAttribute('aria-label', tt('entry.label'))
|
|
50
|
+
entry.setAttribute('title', tt('entry.tooltip'))
|
|
51
|
+
entry.innerHTML = '<span class="' + css.entryIcon + '">' + ICON + '</span><span class="' + css.entryLabel + '">' + tt('entry.label') + '</span>'
|
|
52
|
+
entry.addEventListener('click', () => { controller.toggle() })
|
|
53
|
+
return entry
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
/** Re-insert the entry after the New Session button (before the browser region). */
|
|
57
|
+
function placeEntry(root: HTMLElement, entry: HTMLButtonElement): boolean {
|
|
58
|
+
const button = newSessionButton(root)
|
|
59
|
+
if (button === undefined) return false
|
|
60
|
+
if (entry.parentElement !== root) {
|
|
61
|
+
// Insert after the button: React never manages this node, and the shell
|
|
62
|
+
// keeps its own child order intact around it.
|
|
63
|
+
root.insertBefore(entry, button.nextElementSibling)
|
|
64
|
+
}
|
|
65
|
+
return true
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
/**
|
|
69
|
+
* Mount the sidebar entry, waiting for the shell to render and self-healing
|
|
70
|
+
* on later React re-renders.
|
|
71
|
+
* @param controller - the panel controller the entry toggles.
|
|
72
|
+
* @returns disposer removing the entry and its observers.
|
|
73
|
+
*/
|
|
74
|
+
export function mountSidebarEntry(controller: PanelController): () => void {
|
|
75
|
+
const entry = createEntry(controller)
|
|
76
|
+
let root: HTMLElement | undefined
|
|
77
|
+
let placed = false
|
|
78
|
+
|
|
79
|
+
const tryPlace = (): void => {
|
|
80
|
+
if (placed) return
|
|
81
|
+
if (root !== undefined && !root.isConnected) {
|
|
82
|
+
// The shell re-created the sidebar pane; re-query from scratch.
|
|
83
|
+
rootObserver.disconnect()
|
|
84
|
+
root = undefined
|
|
85
|
+
}
|
|
86
|
+
root ??= sidebarRoot()
|
|
87
|
+
if (root === undefined) return
|
|
88
|
+
placed = placeEntry(root, entry)
|
|
89
|
+
if (placed) rootObserver.observe(root, { childList: true, subtree: true })
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
// The shell renders after boot settlement; watch for its arrival.
|
|
93
|
+
const waitObserver = new MutationObserver(() => { tryPlace() })
|
|
94
|
+
waitObserver.observe(document.body, { childList: true, subtree: true })
|
|
95
|
+
|
|
96
|
+
// Self-heal: if a React re-render displaces the row, re-insert it in the
|
|
97
|
+
// same frame (microtask before paint -> no visible flicker).
|
|
98
|
+
const rootObserver = new MutationObserver(() => {
|
|
99
|
+
if (root === undefined || !root.isConnected) {
|
|
100
|
+
placed = false
|
|
101
|
+
tryPlace()
|
|
102
|
+
return
|
|
103
|
+
}
|
|
104
|
+
if (!root.contains(entry)) {
|
|
105
|
+
placed = placeEntry(root, entry)
|
|
106
|
+
}
|
|
107
|
+
})
|
|
108
|
+
|
|
109
|
+
// Reflect the panel's open state on the row (active highlight).
|
|
110
|
+
const unsubscribe = controller.subscribe(() => {
|
|
111
|
+
entry.dataset.active = controller.getSnapshot().panelOpen ? 'true' : undefined
|
|
112
|
+
})
|
|
113
|
+
entry.dataset.active = controller.getSnapshot().panelOpen ? 'true' : undefined
|
|
114
|
+
|
|
115
|
+
tryPlace()
|
|
116
|
+
|
|
117
|
+
return () => {
|
|
118
|
+
waitObserver.disconnect()
|
|
119
|
+
rootObserver.disconnect()
|
|
120
|
+
unsubscribe()
|
|
121
|
+
entry.remove()
|
|
122
|
+
}
|
|
123
|
+
}
|