dsh-remote-vs 0.26.0 → 0.28.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 +112 -28
- package/README.md +84 -25
- package/THIRD-PARTY-NOTICES.md +7 -2
- package/lib/client.js +1237 -254
- package/lib/index.js +821 -17
- package/lib/types/changes/recorder.d.ts +119 -2
- package/lib/types/client/CodeEditor.d.ts +29 -0
- package/lib/types/client/OutlinePanel.d.ts +22 -0
- package/lib/types/client/ProcessesSection.d.ts +19 -0
- package/lib/types/client/api.d.ts +22 -2
- package/lib/types/client/blame-model.d.ts +77 -0
- package/lib/types/client/changes/apply-failure.d.ts +41 -0
- package/lib/types/client/changes/block-confirm.d.ts +97 -0
- package/lib/types/client/changes/diff-outcome.d.ts +56 -0
- package/lib/types/client/changes/freshness.d.ts +51 -0
- package/lib/types/client/changes/model.d.ts +19 -1
- package/lib/types/client/changes/session-diff.d.ts +100 -0
- package/lib/types/client/changes/staleness.d.ts +98 -0
- package/lib/types/client/changes/turn-reverted.d.ts +82 -0
- package/lib/types/client/changes/turn-view.d.ts +131 -0
- package/lib/types/client/changes/undo-affordance.d.ts +44 -10
- package/lib/types/client/changes/undo-target.d.ts +12 -0
- package/lib/types/client/i18n.d.ts +1 -1
- package/lib/types/client/outline-model.d.ts +59 -0
- package/lib/types/client/scm/actions.d.ts +12 -1
- package/lib/types/client/store.d.ts +109 -1
- package/lib/types/client/vsc/blame.d.ts +19 -0
- package/lib/types/client/vsc/change-marks.d.ts +21 -0
- package/lib/types/client/vsc/kit.d.ts +0 -2
- package/lib/types/client/vsc/preview-document.d.ts +46 -0
- package/lib/types/client/vsc/preview-model.d.ts +31 -0
- package/lib/types/client/vsc/preview-services.d.ts +24 -0
- package/lib/types/git-ops.d.ts +18 -0
- package/lib/types/processes.d.ts +43 -0
- package/lib/types/protocol.d.ts +133 -1
- package/package.json +2 -1
- package/src/changes/recorder.ts +851 -8
- package/src/client/CodeEditor.tsx +86 -4
- package/src/client/EditorPane.tsx +581 -41
- package/src/client/MonitorView.tsx +16 -5
- package/src/client/OutlinePanel.tsx +287 -0
- package/src/client/ProcessesSection.tsx +292 -0
- package/src/client/api.ts +38 -3
- package/src/client/blame-model.ts +242 -0
- package/src/client/changes/ChangesDock.tsx +539 -54
- package/src/client/changes/apply-failure.ts +73 -0
- package/src/client/changes/block-confirm.ts +180 -0
- package/src/client/changes/changes.css +45 -0
- package/src/client/changes/diff-outcome.ts +97 -0
- package/src/client/changes/freshness.ts +68 -0
- package/src/client/changes/model.ts +56 -1
- package/src/client/changes/session-diff.ts +187 -0
- package/src/client/changes/staleness.ts +148 -0
- package/src/client/changes/turn-reverted.ts +254 -0
- package/src/client/changes/turn-view.ts +195 -0
- package/src/client/changes/undo-affordance.ts +295 -63
- package/src/client/changes/undo-target.ts +12 -0
- package/src/client/i18n.ts +294 -2
- package/src/client/index.tsx +4 -0
- package/src/client/outline-model.ts +775 -0
- package/src/client/scm/DiffView.tsx +32 -13
- package/src/client/scm/HistoryPanel.tsx +38 -1
- package/src/client/scm/actions.ts +55 -2
- package/src/client/store.tsx +446 -21
- package/src/client/vsc/blame.ts +147 -0
- package/src/client/vsc/change-marks.ts +21 -0
- package/src/client/vsc/kit.tsx +3 -11
- package/src/client/vsc/preview-document.tsx +326 -0
- package/src/client/vsc/preview-model.ts +216 -0
- package/src/client/vsc/preview-services.ts +118 -0
- package/src/client/vsc/vsc.css +965 -39
- package/src/git-ops.ts +34 -0
- package/src/processes.ts +177 -0
- package/src/protocol.ts +138 -1
- package/src/routes.ts +138 -9
|
@@ -129,6 +129,9 @@ const wrapCompartment = new Compartment()
|
|
|
129
129
|
*/
|
|
130
130
|
const changeMarksCompartment = new Compartment()
|
|
131
131
|
|
|
132
|
+
/** Compartment holding the inline blame gutter; empty until the pane has data. */
|
|
133
|
+
const blameCompartment = new Compartment()
|
|
134
|
+
|
|
132
135
|
/** True while CodeMirror's own highlighter has produced token spans. */
|
|
133
136
|
function primaryColored(host: Element): boolean {
|
|
134
137
|
return host.querySelector('[class*="rvs-ck-"]') !== null
|
|
@@ -148,7 +151,15 @@ import {
|
|
|
148
151
|
type ChangeMark,
|
|
149
152
|
type ChangeSet,
|
|
150
153
|
} from './vsc/change-marks.ts'
|
|
151
|
-
import {
|
|
154
|
+
import { blameExtension, blameViewportReporter } from './vsc/blame.ts'
|
|
155
|
+
import type { BlameLine } from './blame-model.ts'
|
|
156
|
+
import {
|
|
157
|
+
DEFAULT_CONFIRM_LABEL,
|
|
158
|
+
DEFAULT_CONFIRMED_LABEL,
|
|
159
|
+
DEFAULT_TRIGGER_LABEL,
|
|
160
|
+
DEFAULT_UNDO_LABEL,
|
|
161
|
+
undoAffordance,
|
|
162
|
+
} from './changes/undo-affordance.ts'
|
|
152
163
|
|
|
153
164
|
/**
|
|
154
165
|
* The editor surface is OPAQUE and scrolls in the editor's own palette
|
|
@@ -200,6 +211,19 @@ export const CodeEditor = forwardRef<CodeEditorHandle, {
|
|
|
200
211
|
* 加入本功能之前完全一致。
|
|
201
212
|
*/
|
|
202
213
|
changeSet?: ChangeSet | null
|
|
214
|
+
/**
|
|
215
|
+
* Line→commit map for the inline blame gutter. `undefined`/empty removes the
|
|
216
|
+
* gutter entirely, so diff panes and files without blame data keep their old
|
|
217
|
+
* layout.
|
|
218
|
+
*/
|
|
219
|
+
blame?: ReadonlyMap<number, BlameLine> | null
|
|
220
|
+
/** Clicking a blame cell asks the pane to reveal that commit. */
|
|
221
|
+
onOpenBlame?: (entry: BlameLine) => void
|
|
222
|
+
/**
|
|
223
|
+
* Reports the visible 1-based line range. The pane uses it to fetch blame one
|
|
224
|
+
* window at a time; CodeMirror is the only code that knows the viewport.
|
|
225
|
+
*/
|
|
226
|
+
onViewport?: (first: number, last: number) => void
|
|
203
227
|
/**
|
|
204
228
|
* 用户在某一处改动上按下「撤销这处改动」时回调。
|
|
205
229
|
*
|
|
@@ -210,6 +234,21 @@ export const CodeEditor = forwardRef<CodeEditorHandle, {
|
|
|
210
234
|
onUndoChange?: (mark: ChangeMark) => void
|
|
211
235
|
/** 悬浮按钮的文案(由调用方按 `kind` 给出它的 i18n 说法)。 */
|
|
212
236
|
undoLabel?: (mark: ChangeMark) => string
|
|
237
|
+
/** 行尾那枚 `⋯` 的说明(title / aria-label,调用方传 i18n)。 */
|
|
238
|
+
undoTriggerLabel?: () => string
|
|
239
|
+
/**
|
|
240
|
+
* 悬浮栏的第二个动作:「确认保留」(块级本地笔记,见 `changes/block-confirm.ts`)。
|
|
241
|
+
*
|
|
242
|
+
* 不传 = 悬浮栏只有撤销一个动作(与没有这个功能时完全一致)。传了也只是把
|
|
243
|
+
* 读/切换交回去:存储、会话归属都在调用方那一侧,编辑器组件不持有这份状态,更
|
|
244
|
+
* 不会因为它写任何远端。
|
|
245
|
+
*/
|
|
246
|
+
blockConfirm?: {
|
|
247
|
+
isConfirmed: (mark: ChangeMark) => boolean
|
|
248
|
+
onToggle: (mark: ChangeMark) => void
|
|
249
|
+
label: (mark: ChangeMark) => string
|
|
250
|
+
pressedLabel?: (mark: ChangeMark) => string
|
|
251
|
+
}
|
|
213
252
|
/** 改动点跳转的目标行(1-based),配合 `revealHunkNonce` 重跳同一行。 */
|
|
214
253
|
revealHunkLine?: number
|
|
215
254
|
/** 改动点跳转的 nonce(同 `revealNonce` 的道理)。 */
|
|
@@ -394,6 +433,12 @@ export const CodeEditor = forwardRef<CodeEditorHandle, {
|
|
|
394
433
|
*/
|
|
395
434
|
const labelsRef = useRef(t)
|
|
396
435
|
const undoArmed = props.onUndoChange !== undefined
|
|
436
|
+
/**
|
|
437
|
+
* 「确认保留」是否可用也是**能力**的一部分:它随"这批标记有没有块标识"一起到达,
|
|
438
|
+
* 所以要进 `armed` 键 —— 否则先挂载、后拿到标记的编辑器永远不会重装扩展,第二个
|
|
439
|
+
* 按钮就再也不会出现。
|
|
440
|
+
*/
|
|
441
|
+
const confirmArmed = props.blockConfirm !== undefined
|
|
397
442
|
useEffect(() => {
|
|
398
443
|
const current = viewRef.current
|
|
399
444
|
if (current === undefined) return
|
|
@@ -403,7 +448,7 @@ export const CodeEditor = forwardRef<CodeEditorHandle, {
|
|
|
403
448
|
}
|
|
404
449
|
const set = props.changeSet
|
|
405
450
|
const marks = set !== undefined
|
|
406
|
-
const armed = `${marks ? 'm' : ''}${undoArmed ? 'u' : ''}`
|
|
451
|
+
const armed = `${marks ? 'm' : ''}${undoArmed ? 'u' : ''}${confirmArmed ? 'c' : ''}`
|
|
407
452
|
if (armed !== armedRef.current) {
|
|
408
453
|
armedRef.current = armed
|
|
409
454
|
// 重装扩展会重建字段,之前下发过的数据随之消失,必须再喂一次。
|
|
@@ -414,6 +459,19 @@ export const CodeEditor = forwardRef<CodeEditorHandle, {
|
|
|
414
459
|
? [undoAffordance({
|
|
415
460
|
onUndo: (mark) => { propsRef.current.onUndoChange?.(mark) },
|
|
416
461
|
label: (mark) => propsRef.current.undoLabel?.(mark) ?? DEFAULT_UNDO_LABEL,
|
|
462
|
+
triggerLabel: () => propsRef.current.undoTriggerLabel?.() ?? DEFAULT_TRIGGER_LABEL,
|
|
463
|
+
...(confirmArmed
|
|
464
|
+
? {
|
|
465
|
+
confirm: {
|
|
466
|
+
isConfirmed: (mark) => propsRef.current.blockConfirm?.isConfirmed(mark) === true,
|
|
467
|
+
onToggle: (mark) => { propsRef.current.blockConfirm?.onToggle(mark) },
|
|
468
|
+
label: (mark) => propsRef.current.blockConfirm?.label(mark) ?? DEFAULT_CONFIRM_LABEL,
|
|
469
|
+
pressedLabel: (mark) => propsRef.current.blockConfirm?.pressedLabel?.(mark)
|
|
470
|
+
?? propsRef.current.blockConfirm?.label(mark)
|
|
471
|
+
?? DEFAULT_CONFIRMED_LABEL,
|
|
472
|
+
},
|
|
473
|
+
}
|
|
474
|
+
: {}),
|
|
417
475
|
})]
|
|
418
476
|
: []),
|
|
419
477
|
]
|
|
@@ -431,7 +489,28 @@ export const CodeEditor = forwardRef<CodeEditorHandle, {
|
|
|
431
489
|
} catch {
|
|
432
490
|
// Disposed.
|
|
433
491
|
}
|
|
434
|
-
}, [props.changeSet, undoArmed, view, t])
|
|
492
|
+
}, [props.changeSet, undoArmed, confirmArmed, view, t])
|
|
493
|
+
|
|
494
|
+
/**
|
|
495
|
+
* Blame gutter: install/replace it when the pane hands over a new window.
|
|
496
|
+
*
|
|
497
|
+
* The map identity changes as viewport windows land, so comparing it is the
|
|
498
|
+
* only cheap "same data" test; the extension itself is small and rebuilding
|
|
499
|
+
* it costs one compartment transaction, not a document change.
|
|
500
|
+
*/
|
|
501
|
+
useEffect(() => {
|
|
502
|
+
const current = viewRef.current
|
|
503
|
+
if (current === undefined) return
|
|
504
|
+
const entries = props.blame
|
|
505
|
+
const extension = entries !== undefined && entries !== null && entries.size > 0
|
|
506
|
+
? blameExtension(entries, entry => { propsRef.current.onOpenBlame?.(entry) })
|
|
507
|
+
: []
|
|
508
|
+
try {
|
|
509
|
+
current.dispatch({ effects: blameCompartment.reconfigure(extension) })
|
|
510
|
+
} catch {
|
|
511
|
+
// Disposed.
|
|
512
|
+
}
|
|
513
|
+
}, [props.blame])
|
|
435
514
|
|
|
436
515
|
/**
|
|
437
516
|
* 跳到某个改动点。
|
|
@@ -625,7 +704,7 @@ export const CodeEditor = forwardRef<CodeEditorHandle, {
|
|
|
625
704
|
revealRange: (from, to) => {
|
|
626
705
|
const current = viewRef.current
|
|
627
706
|
if (current === undefined) return
|
|
628
|
-
revealRange(current, from, to)
|
|
707
|
+
revealRange(current, from, to, setLitPosition)
|
|
629
708
|
},
|
|
630
709
|
getChangeStale: () => viewRef.current?.state.field(changeStaleField, false) === true,
|
|
631
710
|
}), [])
|
|
@@ -824,6 +903,9 @@ export const CodeEditor = forwardRef<CodeEditorHandle, {
|
|
|
824
903
|
// Session-change marks, off until a `changeSet` prop arrives (see
|
|
825
904
|
// `changeMarksCompartment`).
|
|
826
905
|
changeMarksCompartment.of([]),
|
|
906
|
+
// Inline blame, off until the pane has fetched a window.
|
|
907
|
+
blameCompartment.of([]),
|
|
908
|
+
blameViewportReporter((first, last) => { propsRef.current.onViewport?.(first, last) }),
|
|
827
909
|
wrapCompartment.of(propsRef.current.wrap === false ? [] : EditorView.lineWrapping),
|
|
828
910
|
readOnlyCompartment.of(EditorState.readOnly.of(propsRef.current.readOnly === true)),
|
|
829
911
|
...langFor(propsRef.current.path),
|