dsh-vscode-mode 0.5.3 → 0.7.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 (77) hide show
  1. package/README.md +72 -2
  2. package/lib/client.js +12082 -6420
  3. package/lib/client.js.map +1 -1
  4. package/lib/index.js +2750 -147
  5. package/lib/index.js.map +1 -1
  6. package/package.json +1 -1
  7. package/src/client/copyText.ts +28 -0
  8. package/src/client/dap/BpWidget.ts +262 -0
  9. package/src/client/dap/bpMenu.ts +91 -0
  10. package/src/client/dap/bpRowMenu.ts +53 -0
  11. package/src/client/dap/breakpoints.ts +222 -0
  12. package/src/client/dap/decorate.ts +128 -0
  13. package/src/client/dap/hintLine.ts +29 -0
  14. package/src/client/dap/hover.ts +166 -0
  15. package/src/client/dap/hoverMode.ts +159 -0
  16. package/src/client/dap/hoverTree.ts +722 -0
  17. package/src/client/dap/launchInsert.ts +229 -0
  18. package/src/client/dap/launchSnippetProvider.ts +206 -0
  19. package/src/client/dap/modelPath.ts +23 -0
  20. package/src/client/dap/panelSplit.ts +105 -0
  21. package/src/client/dap/pidPick.ts +24 -0
  22. package/src/client/dap/store.ts +571 -0
  23. package/src/client/dap/toolbarDrag.ts +51 -0
  24. package/src/client/dap/trace.ts +22 -0
  25. package/src/client/dap/variableTree.ts +62 -0
  26. package/src/client/fileClipboard.ts +46 -0
  27. package/src/client/index.ts +12 -3
  28. package/src/client/monaco/lsp/index.ts +15 -0
  29. package/src/client/monaco/lsp/providers.ts +2 -0
  30. package/src/client/monaco/theme.ts +15 -0
  31. package/src/client/openWithDialog.ts +66 -0
  32. package/src/client/searchSeed.ts +36 -0
  33. package/src/client/sidebar/contextMenu.ts +51 -10
  34. package/src/client/sidebar/menuItems.ts +473 -50
  35. package/src/client/sidebar/panels/DebugPanel.ts +613 -0
  36. package/src/client/sidebar/panels/SearchPanel.ts +24 -3
  37. package/src/client/sidebar/panels/SvnPanel.ts +167 -23
  38. package/src/client/sidebar/panels/index.ts +19 -0
  39. package/src/client/sidebar/types.ts +8 -0
  40. package/src/client/styles/editor.css +176 -0
  41. package/src/client/svnActions.ts +18 -1
  42. package/src/client/svnLog.ts +3 -3
  43. package/src/client/svnStatus.ts +140 -2
  44. package/src/client/tabActions.ts +22 -10
  45. package/src/client/ui/EditorView.ts +625 -23
  46. package/src/client/ui/OfficialSideTab.ts +1 -0
  47. package/src/client/ui/PromptDialog.ts +63 -0
  48. package/src/client/ui/SideBySideDiff.tsx +214 -29
  49. package/src/client/ui/SideEditorTab.ts +1 -0
  50. package/src/client/ui/SvnDiffPanel.ts +21 -8
  51. package/src/client/ui/SvnLogDialog.ts +44 -2
  52. package/src/client/ui/SvnPatchDialog.ts +63 -0
  53. package/src/client/ui/SvnSumDialog.ts +77 -0
  54. package/src/client/ui/commandCatalog.ts +63 -0
  55. package/src/client/ui/svnExport.ts +71 -0
  56. package/src/dap/configSnippets.ts +269 -0
  57. package/src/dap/discovery.ts +198 -0
  58. package/src/dap/launchConfig.ts +127 -0
  59. package/src/dap/manager.ts +588 -0
  60. package/src/dap/processList.ts +76 -0
  61. package/src/dap/protocol.ts +80 -0
  62. package/src/dap/provider.ts +49 -0
  63. package/src/dap/rpc.ts +192 -0
  64. package/src/dap/sourcePath.ts +82 -0
  65. package/src/index.ts +7 -3
  66. package/src/lsp/providers.ts +3 -2
  67. package/src/reveal.ts +31 -20
  68. package/src/rpc.ts +209 -5
  69. package/src/search/ripgrep.ts +127 -11
  70. package/src/shared/dap.ts +262 -0
  71. package/src/shared/fsNames.ts +115 -0
  72. package/src/shared/keybindings.ts +9 -0
  73. package/src/shared/rpc.ts +52 -2
  74. package/src/shared/svn.ts +147 -0
  75. package/src/shared/svnActions.ts +20 -0
  76. package/src/svn.ts +320 -11
  77. package/src/workspace.ts +0 -75
@@ -0,0 +1,127 @@
1
+ /**
2
+ * dsh-vscode-mode host — 调试配置文件通用解析(JSONC 清洗 + 全量配置透传)。
3
+ * 纯函数,node 可测。读插件专属 `.dsh/launch.json`(格式与 VS Code launch.json 兼容;
4
+ * 与 `.vscode/launch.json` 互不干扰,旧共用文件仅作首读迁移源):
5
+ * - 不再限定 emmylua:所有带 name/type 的 configuration 都保留(类型可用性由 discovery 裁决);
6
+ * - 未识别字段原样进 raw(attach/launch 请求参数透传给适配器,对齐 VS Code 语义);
7
+ * - ${workspaceFolder}/${cwd} 按工作区根替换;${command:...} 是 VS Code 命令占位,
8
+ * 本插件无法解析——检出后由调用方明确报错(不做静默假解析)。
9
+ * 作者 ddj 2026年09月29号 / 2026年09月21号
10
+ */
11
+ import type { DapDebugConfig } from '../shared/dap.js'
12
+
13
+ /**
14
+ * 清洗 JSONC 为可 JSON.parse 文本:去 // 与 /* *\/ 注释、去尾逗号(字符串字面量感知)。
15
+ * @author ddj 2026年09月29号
16
+ * @param text 原始 launch.json 文本
17
+ * @returns 清洗后文本
18
+ */
19
+ export function stripJsonc(text: string): string {
20
+ let out = ''
21
+ let i = 0
22
+ const n = text.length
23
+ let state: 'code' | 'string' = 'code'
24
+ while (i < n) {
25
+ const ch = text[i]
26
+ const next = i + 1 < n ? text[i + 1] : ''
27
+ if (state === 'string') {
28
+ out += ch
29
+ if (ch === '\\') { out += next; i += 2; continue }
30
+ if (ch === '"') state = 'code'
31
+ i += 1
32
+ continue
33
+ }
34
+ if (ch === '"') { state = 'string'; out += ch; i += 1; continue }
35
+ if (ch === '/' && next === '/') { while (i < n && text[i] !== '\n') i += 1; continue }
36
+ if (ch === '/' && next === '*') { i += 2; while (i + 1 < n && !(text[i] === '*' && text[i + 1] === '/')) i += 1; i += 2; continue }
37
+ out += ch
38
+ i += 1
39
+ }
40
+ return out.replace(/,(\s*[}\]])/g, '$1')
41
+ }
42
+
43
+ /**
44
+ * 解析 launch.json 文本为全量调试配置列表(非法/缺 name/type 的条目跳过)。
45
+ * @author ddj 2026年09月29号 / 2026年09月21号
46
+ * @param text launch.json 文本(JSONC)
47
+ * @param workspacePath 工作区根(${workspaceFolder}/${cwd} 替换基准;空 = 不替换)
48
+ * @returns 全量配置(raw 原样透传)
49
+ */
50
+ export function parseLaunchConfigs(text: string, workspacePath = ''): DapDebugConfig[] {
51
+ let data: unknown
52
+ try { data = JSON.parse(stripJsonc(text)) } catch { return [] }
53
+ const list = (data as { configurations?: unknown })?.configurations
54
+ if (!Array.isArray(list)) return []
55
+ const out: DapDebugConfig[] = []
56
+ for (const item of list) {
57
+ if (!item || typeof item !== 'object' || Array.isArray(item)) continue
58
+ const cfg = item as Record<string, unknown>
59
+ const type = asString(cfg.type)
60
+ const name = asString(cfg.name)
61
+ if (!type || !name) continue
62
+ out.push({
63
+ name,
64
+ type,
65
+ request: asString(cfg.request),
66
+ processName: asString(cfg.processName),
67
+ pid: asPositive(cfg.pid),
68
+ processId: asPositive(cfg.processId),
69
+ host: asString(cfg.host),
70
+ port: asPositive(cfg.port),
71
+ sourcePaths: stringListOf(cfg.sourcePaths),
72
+ ext: stringListOf(cfg.ext),
73
+ captureLog: typeof cfg.captureLog === 'boolean' ? cfg.captureLog : undefined,
74
+ raw: expandRaw(cfg, workspacePath),
75
+ })
76
+ }
77
+ return out
78
+ }
79
+
80
+ /**
81
+ * 配置是否含 ${command:...} 占位(VS Code 命令,本插件无法解析,需用户改为具体值)。
82
+ * @author ddj 2026年09月21号
83
+ * @param config 调试配置
84
+ */
85
+ export function hasCmdPlaceholder(config: DapDebugConfig): boolean {
86
+ return JSON.stringify(config.raw ?? {}).includes('${command:')
87
+ }
88
+
89
+ /** ${workspaceFolder}/${cwd} → 工作区根(大小写不敏感;其余占位保持原样交适配器)。 */
90
+ function expandLaunchVars(text: string, workspacePath: string): string {
91
+ if (!workspacePath) return text
92
+ return text
93
+ .replace(/\$\{workspaceFolder\}/gi, workspacePath)
94
+ .replace(/\$\{cwd\}/gi, workspacePath)
95
+ }
96
+
97
+ /** raw 逐字段递归展开(字符串内占位替换;数组/嵌套对象同口径)。 */
98
+ function expandRaw(raw: Record<string, unknown>, workspacePath: string): Record<string, unknown> {
99
+ const out: Record<string, unknown> = {}
100
+ for (const [key, value] of Object.entries(raw)) out[key] = expandValue(value, workspacePath)
101
+ return out
102
+ }
103
+
104
+ /** 单值展开。 */
105
+ function expandValue(value: unknown, workspacePath: string): unknown {
106
+ if (typeof value === 'string') return expandLaunchVars(value, workspacePath)
107
+ if (Array.isArray(value)) return value.map((v) => expandValue(v, workspacePath))
108
+ if (value && typeof value === 'object') return expandRaw(value as Record<string, unknown>, workspacePath)
109
+ return value
110
+ }
111
+
112
+ /** unknown → 字符串(非字符串返回 undefined)。 */
113
+ function asString(value: unknown): string | undefined {
114
+ return typeof value === 'string' && value ? value : undefined
115
+ }
116
+
117
+ /** unknown → 正数(number 且 >0;其余 undefined)。 */
118
+ function asPositive(value: unknown): number | undefined {
119
+ return typeof value === 'number' && Number.isFinite(value) && value > 0 ? value : undefined
120
+ }
121
+
122
+ /** 字符串数组字段清洗(非字符串元素剔除;空数组返回 undefined)。 */
123
+ function stringListOf(raw: unknown): string[] | undefined {
124
+ if (!Array.isArray(raw)) return undefined
125
+ const items = raw.filter((v): v is string => typeof v === 'string' && v.length > 0)
126
+ return items.length ? items : undefined
127
+ }