dsh-remote-vs 0.24.0 → 0.26.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.
Files changed (125) hide show
  1. package/README.en.md +50 -16
  2. package/README.md +40 -15
  3. package/THIRD-PARTY-NOTICES.md +188 -0
  4. package/lib/client.js +6512 -77887
  5. package/lib/index.js +1461 -1024
  6. package/lib/p2-router-fs.js +1 -1
  7. package/lib/types/client/CodeEditor.d.ts +25 -0
  8. package/lib/types/client/EditorPane.d.ts +16 -5
  9. package/lib/types/client/FloatingPlaceholder.d.ts +16 -5
  10. package/lib/types/client/RemoteEditorView.d.ts +13 -10
  11. package/lib/types/client/RemoteExplorer.d.ts +53 -0
  12. package/lib/types/client/RemoteRoot.d.ts +5 -5
  13. package/lib/types/client/TerminalSnippets.d.ts +36 -0
  14. package/lib/types/client/TerminalView.d.ts +1 -1
  15. package/lib/types/client/XTerm.d.ts +33 -0
  16. package/lib/types/client/api.d.ts +37 -2
  17. package/lib/types/client/changes/review-state.d.ts +19 -0
  18. package/lib/types/client/connection.d.ts +16 -0
  19. package/lib/types/client/editor-capability.d.ts +27 -0
  20. package/lib/types/client/i18n.d.ts +1 -1
  21. package/lib/types/client/request-gate.d.ts +110 -0
  22. package/lib/types/client/scm/DiffView.d.ts +45 -7
  23. package/lib/types/client/scm/actions.d.ts +31 -3
  24. package/lib/types/client/store.d.ts +112 -4
  25. package/lib/types/client/terminal-input.d.ts +23 -0
  26. package/lib/types/client/terminal-snippets.d.ts +86 -0
  27. package/lib/types/client/vsc/FindWidget.d.ts +6 -0
  28. package/lib/types/client/vsc/breadcrumb.d.ts +30 -0
  29. package/lib/types/client/vsc/change-marks.d.ts +16 -6
  30. package/lib/types/client/vsc/editor-caret.d.ts +32 -0
  31. package/lib/types/client/vsc/editor-keymap.d.ts +35 -1
  32. package/lib/types/client/vsc/editor-langs.d.ts +9 -0
  33. package/lib/types/client/vsc/editor-settings.d.ts +55 -0
  34. package/lib/types/client/vsc/image-preview.d.ts +36 -0
  35. package/lib/types/client/vsc/kit.d.ts +13 -0
  36. package/lib/types/client/vsc/save-shortcut.d.ts +21 -0
  37. package/lib/types/client/vsc/terminal-clipboard.d.ts +15 -0
  38. package/lib/types/client/vsc/terminal-line.d.ts +25 -0
  39. package/lib/types/client/vsc/terminal-links.d.ts +62 -0
  40. package/lib/types/client/vsc/terminal-theme.d.ts +48 -0
  41. package/lib/types/client/vsc/terminal-writer.d.ts +52 -0
  42. package/lib/types/forward.d.ts +12 -0
  43. package/lib/types/fs-ops.d.ts +42 -0
  44. package/lib/types/http.d.ts +2 -0
  45. package/lib/types/keygen.d.ts +9 -0
  46. package/lib/types/monitor.d.ts +8 -0
  47. package/lib/types/notices.d.ts +16 -1
  48. package/lib/types/p2/helper-rpc.d.ts +45 -0
  49. package/lib/types/pool.d.ts +25 -0
  50. package/lib/types/routes.d.ts +2 -0
  51. package/lib/types/store.d.ts +7 -0
  52. package/lib/types/terminal.d.ts +33 -1
  53. package/lib/types/view-settings.d.ts +5 -0
  54. package/lib/{worlds-B7gEDBzC.js → worlds-RG8K5eom.js} +113 -15
  55. package/package.json +2 -1
  56. package/src/client/CodeEditor.tsx +205 -10
  57. package/src/client/DirectoryFlow.tsx +16 -0
  58. package/src/client/DoctorPanel.tsx +70 -7
  59. package/src/client/EditorPane.tsx +545 -118
  60. package/src/client/FloatingPlaceholder.tsx +34 -5
  61. package/src/client/HostsView.tsx +12 -3
  62. package/src/client/RemoteDirectoryPicker.tsx +12 -0
  63. package/src/client/RemoteEditorView.tsx +14 -11
  64. package/src/client/RemoteExplorer.tsx +929 -40
  65. package/src/client/RemoteRoot.tsx +167 -147
  66. package/src/client/SearchView.tsx +8 -0
  67. package/src/client/TerminalSnippets.tsx +432 -0
  68. package/src/client/TerminalView.tsx +50 -1
  69. package/src/client/XTerm.tsx +228 -58
  70. package/src/client/api.ts +106 -13
  71. package/src/client/auto-open-remote.ts +11 -9
  72. package/src/client/changes/ChangesDock.tsx +188 -6
  73. package/src/client/changes/changes.css +10 -3
  74. package/src/client/changes/review-state.ts +34 -0
  75. package/src/client/connection.ts +29 -0
  76. package/src/client/downloads.ts +49 -4
  77. package/src/client/editor-capability.ts +42 -0
  78. package/src/client/i18n.ts +228 -12
  79. package/src/client/index.tsx +22 -6
  80. package/src/client/request-gate.ts +221 -0
  81. package/src/client/scm/CommitPane.tsx +20 -2
  82. package/src/client/scm/DiffView.tsx +343 -117
  83. package/src/client/scm/HistoryPanel.tsx +23 -2
  84. package/src/client/scm/RepoPicker.tsx +1 -1
  85. package/src/client/scm/ScmPanel.tsx +391 -87
  86. package/src/client/scm/actions.ts +95 -12
  87. package/src/client/store.tsx +537 -22
  88. package/src/client/terminal-input.ts +44 -0
  89. package/src/client/terminal-snippets.ts +216 -0
  90. package/src/client/ui.tsx +4 -0
  91. package/src/client/vsc/FindWidget.tsx +24 -9
  92. package/src/client/vsc/breadcrumb.tsx +339 -0
  93. package/src/client/vsc/change-marks.ts +93 -44
  94. package/src/client/vsc/editor-caret.ts +30 -0
  95. package/src/client/vsc/editor-keymap.ts +59 -1
  96. package/src/client/vsc/editor-langs.ts +20 -0
  97. package/src/client/vsc/editor-settings.ts +146 -0
  98. package/src/client/vsc/editor-theme.ts +4 -5
  99. package/src/client/vsc/file-icons.tsx +17 -3
  100. package/src/client/vsc/image-preview.tsx +110 -0
  101. package/src/client/vsc/kit.tsx +46 -10
  102. package/src/client/vsc/save-shortcut.ts +47 -1
  103. package/src/client/vsc/terminal-clipboard.ts +19 -0
  104. package/src/client/vsc/terminal-line.ts +101 -0
  105. package/src/client/vsc/terminal-links.ts +166 -0
  106. package/src/client/vsc/terminal-theme.ts +97 -0
  107. package/src/client/vsc/terminal-writer.ts +112 -0
  108. package/src/client/vsc/vsc.css +1078 -181
  109. package/src/forward.ts +47 -9
  110. package/src/fs-ops.ts +124 -4
  111. package/src/git-ops.ts +20 -3
  112. package/src/http.ts +35 -4
  113. package/src/keygen.ts +55 -4
  114. package/src/monitor.ts +13 -0
  115. package/src/notices.ts +23 -1
  116. package/src/p2/helper-rpc.ts +113 -7
  117. package/src/p2/worlds.ts +14 -1
  118. package/src/pool.ts +99 -27
  119. package/src/routes.ts +212 -43
  120. package/src/sftp.ts +51 -14
  121. package/src/store.ts +10 -0
  122. package/src/terminal.ts +225 -24
  123. package/src/view-settings.ts +50 -10
  124. package/lib/types/client/Dialog.d.ts +0 -14
  125. package/src/client/Dialog.tsx +0 -76
@@ -94,6 +94,20 @@ async function copyReport(text: string): Promise<boolean> {
94
94
  }
95
95
  }
96
96
 
97
+ /**
98
+ * Focusable controls inside this layer, in DOM order.
99
+ *
100
+ * Same rule as `vsc/kit.tsx`'s `focusables`, inlined instead of imported: this
101
+ * panel deliberately does not import the kit (its copy path must not use the
102
+ * silently-failing `copyText`), and `check-doctor.mjs` pins that.
103
+ */
104
+ const FOCUSABLE = 'button:not([disabled]), input:not([disabled]), select:not([disabled]), textarea:not([disabled]), [tabindex]:not([tabindex="-1"])'
105
+
106
+ function focusables(root: HTMLElement | null): HTMLElement[] {
107
+ if (root === null) return []
108
+ return Array.from(root.querySelectorAll<HTMLElement>(FOCUSABLE))
109
+ }
110
+
97
111
  export function DoctorPanel(props: {
98
112
  t: (key: string) => string
99
113
  alias: string
@@ -103,6 +117,10 @@ export function DoctorPanel(props: {
103
117
  /** `undefined` = the probe is still running. */
104
118
  const [items, setItems] = useState<DoctorItem[] | undefined>(undefined)
105
119
  const [copyState, setCopyState] = useState<'idle' | 'copied' | 'failed'>('idle')
120
+ /** The card, so the Tab trap below has one root to walk. */
121
+ const cardRef = useRef<HTMLDivElement>(null)
122
+ /** Where focus came from (the "环境自检" button); handed back on close. */
123
+ const openerRef = useRef<HTMLElement | null>(null)
106
124
  const alive = useRef(true)
107
125
  // Re-armed on every setup: a StrictMode/replay remount runs setup → cleanup →
108
126
  // setup, and a flag that only ever got set to false would freeze the panel on
@@ -124,14 +142,59 @@ export function DoctorPanel(props: {
124
142
  run()
125
143
  }, [run])
126
144
 
145
+ /**
146
+ * The layer takes the keyboard on open and gives it back on close.
147
+ *
148
+ * The panel declared `role="dialog" aria-modal="true"` but nothing moved the
149
+ * focus into it, so Tab walked straight out into the DSH Settings form behind
150
+ * the overlay while a screen reader had been told that form is inert. It lives
151
+ * INSIDE the host Settings dialog, hence both halves: keep the keyboard here,
152
+ * and give it back to the button that opened this layer.
153
+ */
154
+ useEffect(() => {
155
+ openerRef.current = typeof document === 'undefined' ? null : (document.activeElement as HTMLElement | null)
156
+ // First paint first: the copy button is still disabled while the probe runs,
157
+ // so this settles on the close button — a safe, always-present target.
158
+ const focusTimer = window.setTimeout(() => { focusables(cardRef.current)[0]?.focus() }, 0)
159
+ return () => {
160
+ window.clearTimeout(focusTimer)
161
+ const opener = openerRef.current
162
+ if (opener !== null && document.body.contains(opener)) opener.focus()
163
+ }
164
+ }, [])
165
+
127
166
  useEffect(() => {
128
167
  const onKey = (e: KeyboardEvent): void => {
129
- if (e.key !== 'Escape') return
130
- // CAPTURE phase + stop: the panel lives inside the DSH Settings dialog,
131
- // whose own Escape handler would otherwise close the whole dialog (and the
132
- // report) together with this layer.
133
- e.stopPropagation()
134
- props.onClose()
168
+ if (e.key === 'Escape') {
169
+ // CAPTURE phase + stop: the panel lives inside the DSH Settings dialog,
170
+ // whose own Escape handler would otherwise close the whole dialog (and the
171
+ // report) together with this layer.
172
+ e.stopPropagation()
173
+ props.onClose()
174
+ return
175
+ }
176
+ if (e.key !== 'Tab') return
177
+ // Tab trap, first <-> last (same shape as the kit's ModalCard).
178
+ const controls = focusables(cardRef.current)
179
+ if (controls.length === 0) return
180
+ const first = controls[0] as HTMLElement
181
+ const last = controls[controls.length - 1] as HTMLElement
182
+ const active = document.activeElement
183
+ const inside = cardRef.current?.contains(active) === true
184
+ // Focus outside the card: a plain Tab used to walk straight into the DSH
185
+ // Settings form behind the overlay (only Shift+Tab was pulled back, so the
186
+ // trap was not a closed loop). Both directions now return to the card.
187
+ if (!inside) {
188
+ e.preventDefault()
189
+ if (e.shiftKey) last.focus()
190
+ else first.focus()
191
+ } else if (e.shiftKey && active === first) {
192
+ e.preventDefault()
193
+ last.focus()
194
+ } else if (!e.shiftKey && active === last) {
195
+ e.preventDefault()
196
+ first.focus()
197
+ }
135
198
  }
136
199
  document.addEventListener('keydown', onKey, true)
137
200
  return () => document.removeEventListener('keydown', onKey, true)
@@ -160,7 +223,7 @@ export function DoctorPanel(props: {
160
223
  aria-label={title}
161
224
  onClick={props.onClose}
162
225
  >
163
- <div className="rvs-doctor-card" onClick={(e) => e.stopPropagation()}>
226
+ <div ref={cardRef} className="rvs-doctor-card" onClick={(e) => e.stopPropagation()}>
164
227
  <div className="rvs-doctor-head">
165
228
  <span className="rvs-doctor-title">{title}</span>
166
229
  <span style={{ flex: 1 }} />