dsh-remote-vs 0.23.0 → 0.25.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.en.md +49 -15
- package/README.md +40 -14
- package/lib/client.js +45978 -43338
- package/lib/index.js +388 -90
- package/lib/p2-router-fs.js +1 -1
- package/lib/types/client/CodeEditor.d.ts +17 -0
- package/lib/types/client/EditorPane.d.ts +16 -5
- package/lib/types/client/FloatingPlaceholder.d.ts +16 -5
- package/lib/types/client/RemoteEditorView.d.ts +13 -10
- package/lib/types/client/RemoteRoot.d.ts +5 -5
- package/lib/types/client/SettingsHosts.d.ts +3 -0
- package/lib/types/client/TerminalSnippets.d.ts +36 -0
- package/lib/types/client/TerminalView.d.ts +1 -1
- package/lib/types/client/XTerm.d.ts +33 -0
- package/lib/types/client/api.d.ts +4 -1
- package/lib/types/client/auto-open-remote.d.ts +41 -0
- package/lib/types/client/editor-capability.d.ts +27 -0
- package/lib/types/client/i18n.d.ts +1 -1
- package/lib/types/client/store.d.ts +59 -4
- package/lib/types/client/terminal-input.d.ts +23 -0
- package/lib/types/client/terminal-snippets.d.ts +86 -0
- package/lib/types/client/use-remote-chat-target.d.ts +2 -0
- package/lib/types/client/view-settings.d.ts +40 -0
- package/lib/types/client/vsc/breadcrumb.d.ts +30 -0
- package/lib/types/client/vsc/editor-caret.d.ts +32 -0
- package/lib/types/client/vsc/editor-langs.d.ts +9 -0
- package/lib/types/client/vsc/editor-settings.d.ts +55 -0
- package/lib/types/client/vsc/image-preview.d.ts +36 -0
- package/lib/types/client/vsc/kit.d.ts +2 -0
- package/lib/types/client/vsc/terminal-clipboard.d.ts +15 -0
- package/lib/types/client/vsc/terminal-line.d.ts +25 -0
- package/lib/types/client/vsc/terminal-links.d.ts +62 -0
- package/lib/types/client/vsc/terminal-theme.d.ts +22 -0
- package/lib/types/client/vsc/terminal-writer.d.ts +52 -0
- package/lib/types/paths.d.ts +9 -0
- package/lib/types/pool.d.ts +25 -0
- package/lib/types/protocol.d.ts +35 -0
- package/lib/types/routes.d.ts +7 -0
- package/lib/types/terminal.d.ts +25 -1
- package/lib/types/view-settings.d.ts +26 -0
- package/lib/{worlds-DXdP4SMn.js → worlds-B7gEDBzC.js} +13 -1
- package/package.json +36 -36
- package/src/client/CodeEditor.tsx +54 -2
- package/src/client/EditorPane.tsx +485 -107
- package/src/client/FloatingPlaceholder.tsx +34 -5
- package/src/client/RemoteEditorView.tsx +14 -11
- package/src/client/RemoteRoot.tsx +20 -125
- package/src/client/SettingsHosts.tsx +81 -3
- package/src/client/TerminalSnippets.tsx +357 -0
- package/src/client/TerminalView.tsx +50 -1
- package/src/client/XTerm.tsx +228 -58
- package/src/client/api.ts +7 -0
- package/src/client/auto-open-remote.ts +439 -0
- package/src/client/editor-capability.ts +42 -0
- package/src/client/i18n.ts +158 -6
- package/src/client/index.tsx +30 -6
- package/src/client/store.tsx +165 -13
- package/src/client/terminal-input.ts +44 -0
- package/src/client/terminal-snippets.ts +216 -0
- package/src/client/use-remote-chat-target.ts +1 -1
- package/src/client/view-settings.ts +99 -0
- package/src/client/vsc/breadcrumb.tsx +251 -0
- package/src/client/vsc/editor-caret.ts +30 -0
- package/src/client/vsc/editor-langs.ts +20 -0
- package/src/client/vsc/editor-settings.ts +146 -0
- package/src/client/vsc/editor-theme.ts +4 -5
- package/src/client/vsc/image-preview.tsx +110 -0
- package/src/client/vsc/kit.tsx +20 -1
- package/src/client/vsc/terminal-clipboard.ts +19 -0
- package/src/client/vsc/terminal-line.ts +101 -0
- package/src/client/vsc/terminal-links.ts +166 -0
- package/src/client/vsc/terminal-theme.ts +71 -0
- package/src/client/vsc/terminal-writer.ts +112 -0
- package/src/client/vsc/vsc.css +687 -48
- package/src/index.ts +6 -0
- package/src/paths.ts +13 -0
- package/src/pool.ts +99 -27
- package/src/protocol.ts +45 -0
- package/src/routes.ts +47 -0
- package/src/terminal.ts +160 -6
- package/src/view-settings.ts +133 -0
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Terminal OUTPUT writer: an ordered, coalescing buffer between the WebSocket
|
|
3
|
+
* frames and `term.write`.
|
|
4
|
+
*
|
|
5
|
+
* Why this is not just `term.write(frame.d)` per frame, and NOT a chain of
|
|
6
|
+
* `write(..., callback)`:
|
|
7
|
+
*
|
|
8
|
+
* - xterm parses writes in slices of a few milliseconds; handing it one string
|
|
9
|
+
* per frame costs per-call overhead on a busy stream (`cat`, `dmesg`).
|
|
10
|
+
* - chaining on the write CALLBACK couples our queue to xterm's parse/render
|
|
11
|
+
* completion. A callback is delivered after the data is parsed AND rendered,
|
|
12
|
+
* and rendering is driven by the browser's frames — a throttled window, an
|
|
13
|
+
* occluded tab or a very large previous chunk delays it, and while it is
|
|
14
|
+
* delayed this queue refuses to hand xterm anything new. That is exactly the
|
|
15
|
+
* "typing sometimes has no echo for a while, then it catches up" symptom:
|
|
16
|
+
* the echo was sitting in our queue behind a callback that had not fired yet.
|
|
17
|
+
*
|
|
18
|
+
* So: order is preserved by APPENDING to one buffer and flushing it on a timer
|
|
19
|
+
* (or immediately when the buffer is large). Nothing here waits for a write to
|
|
20
|
+
* finish — xterm's own queue already serialises the chunks we hand it.
|
|
21
|
+
*
|
|
22
|
+
* Pure for the gate (`scripts/check-terminal-writer.mjs`): the scheduler and the
|
|
23
|
+
* write sink are injected, no DOM, no timers at import time.
|
|
24
|
+
*/
|
|
25
|
+
|
|
26
|
+
/** Dependencies of {@link createTerminalWriter}. */
|
|
27
|
+
export interface TerminalWriterDeps {
|
|
28
|
+
/** Hand one chunk to the terminal (xterm's `write`). Must not throw. */
|
|
29
|
+
write: (text: string) => void
|
|
30
|
+
/** Schedule one flush; the default is `setTimeout(run, 0)`. */
|
|
31
|
+
schedule?: (run: () => void) => unknown
|
|
32
|
+
/**
|
|
33
|
+
* Largest string handed to `write` in one call.
|
|
34
|
+
*
|
|
35
|
+
* Joining a multi-megabyte backlog into ONE string would itself block the main
|
|
36
|
+
* thread (and the join is O(total) on every flush), so a big queue is written
|
|
37
|
+
* in pieces and the rest is scheduled immediately.
|
|
38
|
+
*/
|
|
39
|
+
maxChunkChars?: number
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
/** Handle returned by {@link createTerminalWriter}. */
|
|
43
|
+
export interface TerminalWriter {
|
|
44
|
+
/** Append output; the returned value is ignored (kept for symmetry/tests). */
|
|
45
|
+
push: (text: string) => void
|
|
46
|
+
/** Flush everything right now (tab closing, exit frame). */
|
|
47
|
+
flush: () => void
|
|
48
|
+
/** Characters still waiting (diagnostics/tests). */
|
|
49
|
+
pendingChars: () => number
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
/** Default cap for one `write` call (256 Ki UTF-16 units). */
|
|
53
|
+
export const WRITER_MAX_CHUNK_CHARS = 256 * 1024
|
|
54
|
+
|
|
55
|
+
/** Create one ordered, coalescing writer. */
|
|
56
|
+
export function createTerminalWriter(deps: TerminalWriterDeps): TerminalWriter {
|
|
57
|
+
const schedule = deps.schedule ?? ((run: () => void) => setTimeout(run, 0))
|
|
58
|
+
const maxChunk = deps.maxChunkChars ?? WRITER_MAX_CHUNK_CHARS
|
|
59
|
+
/** Queued chunks, in arrival order (joined only at flush time). */
|
|
60
|
+
let queue: string[] = []
|
|
61
|
+
let queuedChars = 0
|
|
62
|
+
let scheduled = false
|
|
63
|
+
|
|
64
|
+
const take = (limit: number): string => {
|
|
65
|
+
// Walk whole CHUNKS until the limit would be exceeded, so a normal burst
|
|
66
|
+
// (small frames) costs one join and a huge backlog is split without slicing
|
|
67
|
+
// a surrogate pair in half.
|
|
68
|
+
let taken = ''
|
|
69
|
+
while (queue.length > 0) {
|
|
70
|
+
const head = queue[0] as string
|
|
71
|
+
if (taken !== '' && taken.length + head.length > limit) break
|
|
72
|
+
queue.shift()
|
|
73
|
+
queuedChars -= head.length
|
|
74
|
+
taken += head
|
|
75
|
+
if (taken.length >= limit) break
|
|
76
|
+
}
|
|
77
|
+
return taken
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
const flush = (): void => {
|
|
81
|
+
scheduled = false
|
|
82
|
+
if (queue.length === 0) return
|
|
83
|
+
const chunk = take(maxChunk)
|
|
84
|
+
if (chunk === '') return
|
|
85
|
+
deps.write(chunk)
|
|
86
|
+
// More to send: keep the ORDER and get back to the event loop first, so a
|
|
87
|
+
// long backlog cannot starve input handling (keystrokes are separate tasks).
|
|
88
|
+
if (queue.length > 0) scheduleFlush()
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
const scheduleFlush = (): void => {
|
|
92
|
+
if (scheduled) return
|
|
93
|
+
scheduled = true
|
|
94
|
+
schedule(flush)
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
return {
|
|
98
|
+
push: (text: string): void => {
|
|
99
|
+
if (text === '') return
|
|
100
|
+
queue.push(text)
|
|
101
|
+
queuedChars += text.length
|
|
102
|
+
// A large buffer is flushed at once (the timer would only add latency);
|
|
103
|
+
// a small one waits one tick so a burst of frames becomes one write.
|
|
104
|
+
if (queuedChars >= maxChunk) flush()
|
|
105
|
+
else scheduleFlush()
|
|
106
|
+
},
|
|
107
|
+
flush: (): void => {
|
|
108
|
+
flush()
|
|
109
|
+
},
|
|
110
|
+
pendingChars: (): number => queuedChars,
|
|
111
|
+
}
|
|
112
|
+
}
|