dsh-vscode-mode 0.29.2 → 0.31.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.md +120 -11
- package/lib/client.js +178 -51
- package/lib/client.js.map +1 -1
- package/lib/index.js +4860 -1576
- package/lib/index.js.map +1 -1
- package/package.json +1 -1
- package/skills/dsh-vscodemode-html-plan/LICENSE +202 -0
- package/skills/dsh-vscodemode-html-plan/SKILL.md +147 -0
- package/skills/dsh-vscodemode-html-plan/examples/scheduled-send.html +298 -0
- package/skills/dsh-vscodemode-html-plan/references/blocks.md +227 -0
- package/skills/dsh-vscodemode-html-plan/references/subagent-brief.md +17 -0
- package/skills/dsh-vscodemode-html-plan/references/upstream-SKILL.md +174 -0
- package/skills/dsh-vscodemode-html-plan/runtime/htmlplan.css +564 -0
- package/skills/dsh-vscodemode-html-plan/runtime/htmlplan.js +1299 -0
- package/skills/dsh-vscodemode-html-plan/runtime/pack.mjs +300 -0
- package/src/ai/llmTask.ts +178 -0
- package/src/ai/llmTypes.ts +6 -0
- package/src/ai/svnCommitMsg.ts +107 -0
- package/src/ai/svnTriage.ts +34 -85
- package/src/client/aiCommit.ts +57 -0
- package/src/client/compatSummary.ts +15 -0
- package/src/client/editorFlush.ts +55 -0
- package/src/client/featurePrefs.ts +63 -0
- package/src/client/htmlPlan/HtmlPlanPanel.ts +261 -0
- package/src/client/htmlPlan/planActions.ts +347 -0
- package/src/client/htmlPlan/planPage.ts +333 -0
- package/src/client/htmlPreview.ts +218 -0
- package/src/client/index.ts +43 -0
- package/src/client/monaco/loader.ts +71 -9
- package/src/client/monaco/templateLanguages.ts +300 -0
- package/src/client/officialSidebar.ts +16 -4
- package/src/client/openPathRouter.ts +7 -0
- package/src/client/planState.ts +8 -2
- package/src/client/refCopy.ts +70 -0
- package/src/client/refIntake.ts +215 -0
- package/src/client/sidebar/menuItems.ts +11 -0
- package/src/client/sidebar/panels/FileExplorer.ts +11 -0
- package/src/client/sidebar/panels/SearchPanel.ts +214 -4
- package/src/client/sidebar/panels/SvnPanel.ts +17 -0
- package/src/client/sidebar/types.ts +2 -0
- package/src/client/styles/editor.css +112 -0
- package/src/client/svnActions.ts +7 -0
- package/src/client/svnCommit.ts +109 -0
- package/src/client/svnNotice.ts +1 -1
- package/src/client/svnStatus.ts +5 -2
- package/src/client/ui/DiffLauncher.ts +3 -1
- package/src/client/ui/EditorView.ts +221 -14
- package/src/client/ui/McpSettings.ts +108 -1
- package/src/client/ui/SvnAiPlanDialog.ts +24 -4
- package/src/client/ui/SvnCommitDialog.ts +458 -0
- package/src/client/ui/commandCatalog.ts +11 -0
- package/src/client/ui/svnCommitModel.ts +204 -0
- package/src/client/univer/UniverCacheSettings.ts +75 -0
- package/src/client/univer/UniverHost.ts +177 -0
- package/src/client/univer/api.ts +30 -0
- package/src/client/univer/routing.ts +32 -0
- package/src/client/univer/store.ts +111 -0
- package/src/fileOpenSettings.ts +118 -6
- package/src/htmlPlanCommand.ts +176 -0
- package/src/index.ts +4 -0
- package/src/paths.ts +5 -0
- package/src/refPointer.ts +193 -0
- package/src/rpc.ts +51 -0
- package/src/search/replacePlan.ts +144 -0
- package/src/search/replaceRun.ts +289 -0
- package/src/shared/keybindings.ts +11 -0
- package/src/shared/refSyntax.ts +106 -0
- package/src/shared/rpc.ts +28 -4
- package/src/shared/snippets.ts +17 -0
- package/src/shared/svn.ts +191 -10
- package/src/shared/svnActions.ts +16 -0
- package/src/shared/univer.ts +90 -0
- package/src/svn.ts +205 -47
- package/src/svnCommit.ts +348 -0
- package/src/svnCore.ts +254 -0
- package/src/svnToolJson.ts +73 -0
- package/src/svnTools.ts +566 -0
- package/src/univerBridge.ts +83 -0
- package/src/univerCache.ts +205 -0
- package/src/univerRpc.ts +144 -0
|
@@ -0,0 +1,333 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* dsh-vscode-mode client — HTML 计划页的纯逻辑(标记解析、路径归位、打包检测、状态推导、审批答案)。
|
|
3
|
+
*
|
|
4
|
+
* 页面格式来自上游 html-plan(MIT);本模块不碰 DOM/React,便于 node 单测。
|
|
5
|
+
* 约定:exit_plan_mode 的 plan 正文里写一行「HTML 计划页:<path>」,
|
|
6
|
+
* 插件据此把计划页签切成 HTML 模式;缺行或文件不可读时回落 Markdown 计划预览。
|
|
7
|
+
* @author ddj 2026年11月21号
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
/** plan 投影的最小结构面。 */
|
|
11
|
+
export interface PlanProjectionLike {
|
|
12
|
+
active?: unknown
|
|
13
|
+
pending?: unknown
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
/** 计划页签的状态模式。 */
|
|
17
|
+
export type PlanUiMode = 'unknown' | 'off' | 'planning' | 'reviewing' | 'approved' | 'revising' | 'exited'
|
|
18
|
+
|
|
19
|
+
/** 计划页签状态(徽标文案 + 原始布尔)。 */
|
|
20
|
+
export interface PlanUiState {
|
|
21
|
+
mode: PlanUiMode
|
|
22
|
+
label: string
|
|
23
|
+
active: boolean
|
|
24
|
+
pending: boolean
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
/** 待审批的 plan-review 问题(从 userQuestions 投影快照解析)。 */
|
|
28
|
+
export interface PendingReview {
|
|
29
|
+
callId: string
|
|
30
|
+
questionId: string
|
|
31
|
+
approveLabel: string
|
|
32
|
+
keepLabel: string | null
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
/** 插件桥接脚本标记(重复注入的幂等判据)。 */
|
|
36
|
+
const BRIDGE_MARK = 'data-edrv-htmlplan-bridge'
|
|
37
|
+
|
|
38
|
+
/** 计划页标记行:HTML 计划页:<path>(中英文冒号都接受)。 */
|
|
39
|
+
const PAGE_LINE = /^[ \t]*HTML[ \t]*计划页[ \t]*[::][ \t]*(.+?)[ \t]*$/im
|
|
40
|
+
|
|
41
|
+
/** 相对未打包页面的运行时引用(存在即说明还没 pack)。 */
|
|
42
|
+
const RUNTIME_REF = /(?:href|src)\s*=\s*["']([^"']*htmlplan\.(?:css|js))(?:[?#][^"']*)?["']/gi
|
|
43
|
+
|
|
44
|
+
/** 桥接脚本:拦截 iframe 内剪贴板写入并转发给父级;失败不影响页面。 */
|
|
45
|
+
const BRIDGE_SCRIPT = [
|
|
46
|
+
'<script ' + BRIDGE_MARK + '>',
|
|
47
|
+
'(() => {',
|
|
48
|
+
' try {',
|
|
49
|
+
' const send = (text) => {',
|
|
50
|
+
' try { parent.postMessage({ source: "edrv-htmlplan", type: "copy", text: String(text ?? "") }, "*") } catch (error) { /* 父级不可达 */ }',
|
|
51
|
+
' }',
|
|
52
|
+
' const clipboard = navigator.clipboard',
|
|
53
|
+
' const original = clipboard && clipboard.writeText',
|
|
54
|
+
' if (clipboard && typeof original === "function") {',
|
|
55
|
+
' clipboard.writeText = function writeText(text) { send(text); return original.apply(this, arguments) }',
|
|
56
|
+
' }',
|
|
57
|
+
' const exec = document.execCommand && document.execCommand.bind(document)',
|
|
58
|
+
' if (exec) {',
|
|
59
|
+
' document.execCommand = function execCommand(command) {',
|
|
60
|
+
' try { if (String(command).toLowerCase() === "copy" && window.getSelection) send(window.getSelection().toString()) } catch (error) { /* 忽略 */ }',
|
|
61
|
+
' return exec.apply(document, arguments)',
|
|
62
|
+
' }',
|
|
63
|
+
' }',
|
|
64
|
+
' document.addEventListener("click", (event) => {',
|
|
65
|
+
' const node = event.target && event.target.nodeType === 3 ? event.target.parentElement : event.target',
|
|
66
|
+
' const button = node && node.closest ? node.closest("button") : null',
|
|
67
|
+
' const label = button ? String(button.textContent || "").trim() : ""',
|
|
68
|
+
' if (!/copy response|复制答复/i.test(label)) return',
|
|
69
|
+
' const texts = Array.from(document.querySelectorAll("pre, textarea, [data-htmlplan-response]")).map((el) => String(el.value ?? el.textContent ?? ""))',
|
|
70
|
+
' texts.sort((left, right) => right.length - left.length)',
|
|
71
|
+
' if (texts[0]) send(texts[0])',
|
|
72
|
+
' }, true)',
|
|
73
|
+
' let reviewPending = false',
|
|
74
|
+
' const hookSheet = () => {',
|
|
75
|
+
' const sheets = document.querySelectorAll(".nw-sheet")',
|
|
76
|
+
' for (const sheet of sheets) {',
|
|
77
|
+
' if (sheet.dataset.edrvReply) continue',
|
|
78
|
+
' const title = sheet.querySelector("header h3")',
|
|
79
|
+
' if (!title || !/your response|你的回复/i.test(title.textContent || "")) continue',
|
|
80
|
+
' const pre = sheet.querySelector("pre")',
|
|
81
|
+
' const footer = sheet.querySelector("footer")',
|
|
82
|
+
' if (!pre || !footer) continue',
|
|
83
|
+
' sheet.dataset.edrvReply = "1"',
|
|
84
|
+
' const reply = document.createElement("button")',
|
|
85
|
+
' reply.type = "button"',
|
|
86
|
+
' reply.className = "nw-btn primary"',
|
|
87
|
+
' reply.textContent = reviewPending ? "回复并执行" : "回复"',
|
|
88
|
+
' reply.title = "直接把这份答复发送给 DSH agent"',
|
|
89
|
+
' reply.addEventListener("click", (event) => {',
|
|
90
|
+
' event.preventDefault()',
|
|
91
|
+
' reply.disabled = true',
|
|
92
|
+
' reply.textContent = "发送中…"',
|
|
93
|
+
' try { parent.postMessage({ source: "edrv-htmlplan", type: "respond", text: String(pre.textContent || "") }, "*") } catch (error) { /* 父级不可达 */ }',
|
|
94
|
+
' }, true)',
|
|
95
|
+
' const copy = Array.from(footer.querySelectorAll("button")).find((btn) => /copy response|复制答复/i.test(btn.textContent || ""))',
|
|
96
|
+
' footer.insertBefore(reply, copy || footer.firstChild)',
|
|
97
|
+
' const hint = sheet.querySelector("p.hint")',
|
|
98
|
+
' if (hint) hint.textContent = reviewPending ? "点「回复并执行」= 同意计划并把答复发给 agent;要修改请先在页签点「继续规划」。" : "点「回复」直接发送给 agent;也可以复制后手动粘贴。"',
|
|
99
|
+
' }',
|
|
100
|
+
' }',
|
|
101
|
+
' try { new MutationObserver(() => { try { hookSheet() } catch (error) { /* 忽略 */ } }).observe(document.body || document.documentElement, { childList: true, subtree: true }) } catch (error) { /* 无 MutationObserver */ }',
|
|
102
|
+
' try { hookSheet() } catch (error) { /* 忽略 */ }',
|
|
103
|
+
' window.addEventListener("message", (event) => {',
|
|
104
|
+
' const data = event.data',
|
|
105
|
+
' if (!data || data.source !== "edrv-plan-host") return',
|
|
106
|
+
' if (data.type === "state") {',
|
|
107
|
+
' reviewPending = data.reviewPending === true',
|
|
108
|
+
' for (const sheet of document.querySelectorAll(".nw-sheet")) {',
|
|
109
|
+
' const reply = Array.from(sheet.querySelectorAll("footer button")).find((btn) => /回复|发送中|已发送|发送失败/.test(btn.textContent || ""))',
|
|
110
|
+
' if (reply && !reply.disabled) reply.textContent = reviewPending ? "回复并执行" : "回复"',
|
|
111
|
+
' const hint = sheet.querySelector("p.hint")',
|
|
112
|
+
' if (hint && !/发送失败/.test(hint.textContent || "")) hint.textContent = reviewPending ? "点「回复并执行」= 同意计划并把答复发给 agent;要修改请先在页签点「继续规划」。" : "点「回复」直接发送给 agent;也可以复制后手动粘贴。"',
|
|
113
|
+
' }',
|
|
114
|
+
' return',
|
|
115
|
+
' }',
|
|
116
|
+
' if (data.type !== "respond-result") return',
|
|
117
|
+
' for (const sheet of document.querySelectorAll(".nw-sheet")) {',
|
|
118
|
+
' const reply = Array.from(sheet.querySelectorAll("footer button")).find((btn) => /回复|发送中|已发送|发送失败/.test(btn.textContent || ""))',
|
|
119
|
+
' if (!reply) continue',
|
|
120
|
+
' if (data.ok === true) {',
|
|
121
|
+
' reply.textContent = "已发送"',
|
|
122
|
+
' setTimeout(() => { try { sheet.querySelector("header button")?.click() } catch (error) { /* 忽略 */ } }, 500)',
|
|
123
|
+
' } else {',
|
|
124
|
+
' reply.disabled = false',
|
|
125
|
+
' reply.textContent = "回复"',
|
|
126
|
+
' const hint = sheet.querySelector("p.hint")',
|
|
127
|
+
' if (hint) hint.textContent = "发送失败:" + String(data.message || "未知原因") + "。可复制后手动粘贴。"',
|
|
128
|
+
' }',
|
|
129
|
+
' }',
|
|
130
|
+
' })',
|
|
131
|
+
' try { parent.postMessage({ source: "edrv-htmlplan", type: "ready" }, "*") } catch (error) { /* 忽略 */ }',
|
|
132
|
+
' } catch (error) { /* 桥接失败不影响页面 */ }',
|
|
133
|
+
'})();',
|
|
134
|
+
'</script>',
|
|
135
|
+
].join('\n')
|
|
136
|
+
|
|
137
|
+
/**
|
|
138
|
+
* 从计划正文里取 HTML 计划页路径(去掉包裹的反引号/引号)。
|
|
139
|
+
* @author ddj 2026年11月21号
|
|
140
|
+
* @param markdown 计划正文
|
|
141
|
+
* @returns 相对或绝对路径,未声明时 null
|
|
142
|
+
*/
|
|
143
|
+
export function planPagePathOf(markdown: unknown): string | null {
|
|
144
|
+
const text = typeof markdown === 'string' ? markdown : ''
|
|
145
|
+
const match = PAGE_LINE.exec(text)
|
|
146
|
+
if (!match) return null
|
|
147
|
+
const raw = match[1].trim().replace(/^["'\`]+|["'\`]+$/g, '').trim()
|
|
148
|
+
return raw ? raw.replace(/\\/g, '/') : null
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
/**
|
|
152
|
+
* 把计划页路径归位到工作区绝对路径(相对路径按 cwd 拼接)。
|
|
153
|
+
* @author ddj 2026年11月21号
|
|
154
|
+
* @param cwd 工作区目录
|
|
155
|
+
* @param pagePath 计划声明里的路径
|
|
156
|
+
* @returns 归一化路径(/ 分隔);空输入返回空串
|
|
157
|
+
*/
|
|
158
|
+
export function resolvePlanPagePath(cwd: unknown, pagePath: string): string {
|
|
159
|
+
const raw = String(pagePath ?? '').trim()
|
|
160
|
+
if (!raw) return ''
|
|
161
|
+
const normalized = raw.replace(/\\/g, '/')
|
|
162
|
+
if (/^(?:[a-zA-Z]:\/|\/)/.test(normalized)) return normalized
|
|
163
|
+
const base = String(cwd ?? '').replace(/\\/g, '/').replace(/\/+$/, '')
|
|
164
|
+
return base ? base + '/' + normalized.replace(/^\.\//, '') : normalized
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
/**
|
|
168
|
+
* 检测仍未内联的运行时引用(未执行 pack 的页面)。
|
|
169
|
+
* @author ddj 2026年11月21号
|
|
170
|
+
* @param html 页面文本
|
|
171
|
+
* @returns 引用串(去重,最多 8 条)
|
|
172
|
+
*/
|
|
173
|
+
export function unresolvedRuntimeRefs(html: unknown): string[] {
|
|
174
|
+
const text = typeof html === 'string' ? html : ''
|
|
175
|
+
const seen = new Set<string>()
|
|
176
|
+
for (const match of text.matchAll(RUNTIME_REF)) {
|
|
177
|
+
const ref = String(match[1] ?? '').trim()
|
|
178
|
+
if (ref) seen.add(ref)
|
|
179
|
+
if (seen.size >= 8) break
|
|
180
|
+
}
|
|
181
|
+
return [...seen]
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
/**
|
|
185
|
+
* 组装 iframe 的 srcdoc:注入剪贴板桥接脚本(已注入则原样返回)。
|
|
186
|
+
* @author ddj 2026年11月21号
|
|
187
|
+
* @param html 打包后的页面文本
|
|
188
|
+
* @returns 可安全交给 sandbox iframe 的 srcdoc
|
|
189
|
+
*/
|
|
190
|
+
export function buildPlanSrcDoc(html: unknown): string {
|
|
191
|
+
const text = typeof html === 'string' ? html : ''
|
|
192
|
+
if (!text.trim()) return ''
|
|
193
|
+
if (text.includes(BRIDGE_MARK)) return text
|
|
194
|
+
if (/<\/body\s*>/i.test(text)) return text.replace(/<\/body\s*>/i, BRIDGE_SCRIPT + '\n</body>')
|
|
195
|
+
return text + '\n' + BRIDGE_SCRIPT
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
/**
|
|
199
|
+
* 由 plan 投影 + 待审批状态 + 本地动作结果推导页签状态文案。
|
|
200
|
+
* @author ddj 2026年11月21号
|
|
201
|
+
* @param projection plan 投影快照(未知形状按不可用处理)
|
|
202
|
+
* @param reviewPending 是否存在 pending 的 plan-review 问题
|
|
203
|
+
* @param acted 本地刚完成的动作(approved / revising)
|
|
204
|
+
* @returns 页签状态
|
|
205
|
+
*/
|
|
206
|
+
export function derivePlanUiState(
|
|
207
|
+
projection: unknown,
|
|
208
|
+
reviewPending: boolean,
|
|
209
|
+
acted?: 'approved' | 'revising' | 'exited' | null,
|
|
210
|
+
): PlanUiState {
|
|
211
|
+
if (projection === null || typeof projection !== 'object') {
|
|
212
|
+
return { mode: 'unknown', label: '计划状态不可用', active: false, pending: false }
|
|
213
|
+
}
|
|
214
|
+
const row = projection as PlanProjectionLike
|
|
215
|
+
const active = row.active === true
|
|
216
|
+
const pending = row.pending === true
|
|
217
|
+
if (pending) return { mode: 'planning', label: '计划状态切换中', active, pending }
|
|
218
|
+
if (acted === 'approved') {
|
|
219
|
+
return { mode: 'approved', label: active ? '已批准 · 等待退出计划模式' : '已批准 · 已退出计划模式', active, pending }
|
|
220
|
+
}
|
|
221
|
+
if (acted === 'exited' && !active) return { mode: 'exited', label: '已退出计划模式', active, pending }
|
|
222
|
+
if (acted === 'revising' && active) return { mode: 'revising', label: '继续规划中', active, pending }
|
|
223
|
+
if (active && reviewPending) return { mode: 'reviewing', label: '待审批', active, pending }
|
|
224
|
+
if (active) return { mode: 'planning', label: '计划中', active, pending }
|
|
225
|
+
return { mode: 'off', label: '计划模式未开启', active, pending }
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
/** 选项标签归一:字符串或 { label } 数组。 */
|
|
229
|
+
function labelsOf(options: unknown): string[] {
|
|
230
|
+
if (!Array.isArray(options)) return []
|
|
231
|
+
const out: string[] = []
|
|
232
|
+
for (const option of options) {
|
|
233
|
+
if (typeof option === 'string') out.push(option.trim())
|
|
234
|
+
else if (option !== null && typeof option === 'object') {
|
|
235
|
+
const label = (option as { label?: unknown }).label
|
|
236
|
+
if (typeof label === 'string' && label.trim()) out.push(label.trim())
|
|
237
|
+
}
|
|
238
|
+
}
|
|
239
|
+
return out
|
|
240
|
+
}
|
|
241
|
+
|
|
242
|
+
/** 按正则挑标签(大小写不敏感)。 */
|
|
243
|
+
function pickLabel(labels: string[], pattern: RegExp): string | null {
|
|
244
|
+
for (const label of labels) if (pattern.test(label)) return label
|
|
245
|
+
return null
|
|
246
|
+
}
|
|
247
|
+
|
|
248
|
+
/**
|
|
249
|
+
* 从一个 question 里提取 plan-review 的标签(批准 / 继续规划)。
|
|
250
|
+
* 官方内存请求带 intent 对象(approve 才是准);投影会丢 intent,只剩选项标签。
|
|
251
|
+
* @author ddj 2026年11月21号
|
|
252
|
+
* @param raw question 形状
|
|
253
|
+
* @returns 标签集合;不是 plan-review 或没有批准标签时 null
|
|
254
|
+
*/
|
|
255
|
+
export function reviewLabelsOf(raw: unknown): { questionId: string; approveLabel: string; keepLabel: string | null } | null {
|
|
256
|
+
if (raw === null || typeof raw !== 'object') return null
|
|
257
|
+
const question = raw as Record<string, unknown>
|
|
258
|
+
const intent = question.intent !== null && typeof question.intent === 'object'
|
|
259
|
+
? question.intent as Record<string, unknown>
|
|
260
|
+
: undefined
|
|
261
|
+
const labels = labelsOf(question.options)
|
|
262
|
+
const fromIntent = typeof intent?.approve === 'string' && intent.approve.trim() ? intent.approve.trim() : null
|
|
263
|
+
const questionId = typeof question.id === 'string' && question.id ? question.id : ''
|
|
264
|
+
const declaredReview = intent?.kind === 'plan-review' || questionId === 'plan-review'
|
|
265
|
+
const approveLabel = fromIntent ?? pickLabel(labels, /^(?:approve|approve plan|同意执行|同意)$/i) ?? pickLabel(labels, /approve|同意/i)
|
|
266
|
+
if (approveLabel === null) return null
|
|
267
|
+
if (!declaredReview && !labels.includes(approveLabel)) return null
|
|
268
|
+
const keepLabel = pickLabel(labels.filter(label => label !== approveLabel), /keep planning|继续规划|要求修改/i)
|
|
269
|
+
return { questionId: questionId || 'plan-review', approveLabel, keepLabel }
|
|
270
|
+
}
|
|
271
|
+
|
|
272
|
+
/** 从一行待审批记录里取 questions 数组。 */
|
|
273
|
+
function questionsOf(row: Record<string, unknown>): unknown[] {
|
|
274
|
+
const pending = row.pending !== null && typeof row.pending === 'object' ? row.pending as Record<string, unknown> : undefined
|
|
275
|
+
const request = row.request !== null && typeof row.request === 'object' ? row.request as Record<string, unknown> : undefined
|
|
276
|
+
const candidates = [pending?.questions, row.questions, request?.questions]
|
|
277
|
+
for (const value of candidates) if (Array.isArray(value)) return value
|
|
278
|
+
return []
|
|
279
|
+
}
|
|
280
|
+
|
|
281
|
+
/** 取该记录的调用 id(官方问答按 callId 结算)。 */
|
|
282
|
+
function callIdOf(row: Record<string, unknown>): string | null {
|
|
283
|
+
const pending = row.pending !== null && typeof row.pending === 'object' ? row.pending as Record<string, unknown> : undefined
|
|
284
|
+
const key = row.key !== null && typeof row.key === 'object' ? row.key as Record<string, unknown> : undefined
|
|
285
|
+
const wait = pending?.wait !== null && typeof pending?.wait === 'object' ? pending.wait as Record<string, unknown> : undefined
|
|
286
|
+
const values = [row.callId, pending?.callId, wait?.callId, (row.wait as Record<string, unknown> | undefined)?.callId, key?.callId, row.id]
|
|
287
|
+
for (const value of values) if (typeof value === 'string' && value) return value
|
|
288
|
+
return null
|
|
289
|
+
}
|
|
290
|
+
|
|
291
|
+
/**
|
|
292
|
+
* 在 userQuestions 投影快照里找待审批的 plan-review 问题。
|
|
293
|
+
* 形状容错:数组或 { items } 包裹;questions 可能在 row/questions/pending 三层。
|
|
294
|
+
* @author ddj 2026年11月21号
|
|
295
|
+
* @param snapshot 投影快照
|
|
296
|
+
* @returns 待审批描述,或 null
|
|
297
|
+
*/
|
|
298
|
+
export function findPendingReview(snapshot: unknown): PendingReview | null {
|
|
299
|
+
const rows: unknown[] = Array.isArray(snapshot)
|
|
300
|
+
? snapshot
|
|
301
|
+
: (snapshot !== null && typeof snapshot === 'object' && Array.isArray((snapshot as { items?: unknown }).items)
|
|
302
|
+
? (snapshot as { items: unknown[] }).items
|
|
303
|
+
: [])
|
|
304
|
+
for (const entry of rows) {
|
|
305
|
+
if (entry === null || typeof entry !== 'object') continue
|
|
306
|
+
const row = entry as Record<string, unknown>
|
|
307
|
+
const callId = callIdOf(row)
|
|
308
|
+
if (!callId) continue
|
|
309
|
+
for (const raw of questionsOf(row)) {
|
|
310
|
+
const labels = reviewLabelsOf(raw)
|
|
311
|
+
if (!labels) continue
|
|
312
|
+
return { callId, questionId: labels.questionId, approveLabel: labels.approveLabel, keepLabel: labels.keepLabel }
|
|
313
|
+
}
|
|
314
|
+
}
|
|
315
|
+
return null
|
|
316
|
+
}
|
|
317
|
+
|
|
318
|
+
/**
|
|
319
|
+
* 构造官方 ask_user_question 答案(批准 = 选批准标签;否则选继续规划标签)。
|
|
320
|
+
* @author ddj 2026年11月21号
|
|
321
|
+
* @param review 待审批描述
|
|
322
|
+
* @param approve 是否批准
|
|
323
|
+
* @returns 答案批次;不批准且没有问题级备选时 null
|
|
324
|
+
*/
|
|
325
|
+
export function reviewAnswerOf(
|
|
326
|
+
review: PendingReview | null,
|
|
327
|
+
approve: boolean,
|
|
328
|
+
): { answers: Array<{ id: string; selected: string[]; custom: string }> } | null {
|
|
329
|
+
if (!review) return null
|
|
330
|
+
const label = approve ? review.approveLabel : review.keepLabel
|
|
331
|
+
if (!label) return null
|
|
332
|
+
return { answers: [{ id: review.questionId, selected: [label], custom: '' }] }
|
|
333
|
+
}
|
|
@@ -0,0 +1,218 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* dsh-vscode-mode client — HTML 文件判定与官方 HTML 渲染器探测。
|
|
3
|
+
*
|
|
4
|
+
* 背景:.html/.htm 的网页渲染交给官方 documentpreviews 的内置 html body;
|
|
5
|
+
* 本模块只回答两个问题:一是该路径是否 HTML,二是当前 DSH 是否真的注册了
|
|
6
|
+
* HTML 渲染器。探针必须有界、可卸载、异常不抛:旧版 DSH 没有 documentPreviews
|
|
7
|
+
* 服务时,调用方据此回退到本插件文本编辑,而不是把文件送进官方纯文本查看器。
|
|
8
|
+
* 纯函数 + 模块级探针态,无 DOM 依赖,可在 node 环境单测。
|
|
9
|
+
* @author ddj 2026年11月21号
|
|
10
|
+
*/
|
|
11
|
+
|
|
12
|
+
/** 可进入官方 HTML 预览的扩展名(小写、无点)。 */
|
|
13
|
+
const HTML_EXT_SET: Set<string> = new Set(['html', 'htm'])
|
|
14
|
+
|
|
15
|
+
/** 官方 documentpreviews 服务名(官方以 ctx.reflect.provide('documentPreviews') 暴露)。 */
|
|
16
|
+
export const DOCUMENT_PREVIEWS_SERVICE = 'documentPreviews'
|
|
17
|
+
|
|
18
|
+
/** 探针默认重试次数(与既有可选服务探测的 15×2s 同节奏)。 */
|
|
19
|
+
const PROBE_ATTEMPTS = 15
|
|
20
|
+
|
|
21
|
+
/** 探针默认重试间隔(毫秒)。 */
|
|
22
|
+
const PROBE_INTERVAL_MS = 2000
|
|
23
|
+
|
|
24
|
+
/** 官方 body 定义的最小结构面。 */
|
|
25
|
+
interface PreviewDefinition {
|
|
26
|
+
extensions?: unknown
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
/** 官方 documentpreviews 服务的最小结构面。 */
|
|
30
|
+
export interface DocumentPreviewsLike {
|
|
31
|
+
getSnapshot?: () => unknown
|
|
32
|
+
subscribe?: (listener: () => void) => unknown
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
/** 探针安装选项(schedule 可注入,便于单测)。 */
|
|
36
|
+
export interface HtmlPreviewProbeOptions {
|
|
37
|
+
/** 延时调度器(缺省 setTimeout);注入后单测可同步推进。 */
|
|
38
|
+
schedule?: (fn: () => void, ms: number) => void
|
|
39
|
+
/** 尝试次数(含首次;缺省 15)。 */
|
|
40
|
+
attempts?: number
|
|
41
|
+
/** 尝试间隔毫秒(缺省 2000)。 */
|
|
42
|
+
intervalMs?: number
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
/** 模块级探针态:true = 官方 HTML 渲染器可用。 */
|
|
46
|
+
let officialAvailable = false
|
|
47
|
+
|
|
48
|
+
/**
|
|
49
|
+
* 判断路径是否为可进入官方预览的 HTML 文件(取 basename 后缀,大小写不敏感)。
|
|
50
|
+
* @author ddj 2026年11月21号
|
|
51
|
+
* @param path 文件路径(/ 或 \ 分隔均可)
|
|
52
|
+
* @returns 是否 HTML 文件
|
|
53
|
+
*/
|
|
54
|
+
export function isHtmlPath(path: unknown): boolean {
|
|
55
|
+
const base = String(path ?? '').replace(/\\/g, '/').split('/').pop() ?? ''
|
|
56
|
+
const dot = base.lastIndexOf('.')
|
|
57
|
+
if (dot <= 0) return false
|
|
58
|
+
return HTML_EXT_SET.has(base.slice(dot + 1).toLowerCase())
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
/**
|
|
62
|
+
* 判断官方 documentpreviews 快照里是否声明了 html/htm 渲染器。
|
|
63
|
+
* 容忍带点、大小写、null/异常行;任何畸形输入一律按「没有」处理。
|
|
64
|
+
* @author ddj 2026年11月21号
|
|
65
|
+
* @param snapshot getSnapshot() 的返回值
|
|
66
|
+
* @returns 是否命中 HTML body
|
|
67
|
+
*/
|
|
68
|
+
export function hasHtmlPreviewBody(snapshot: unknown): boolean {
|
|
69
|
+
if (!Array.isArray(snapshot)) return false
|
|
70
|
+
for (const row of snapshot) {
|
|
71
|
+
if (row === null || typeof row !== 'object') continue
|
|
72
|
+
const extensions = (row as PreviewDefinition).extensions
|
|
73
|
+
if (!Array.isArray(extensions)) continue
|
|
74
|
+
for (const raw of extensions) {
|
|
75
|
+
if (typeof raw !== 'string') continue
|
|
76
|
+
if (HTML_EXT_SET.has(raw.trim().replace(/^\./, '').toLowerCase())) return true
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
return false
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
/**
|
|
83
|
+
* 当前是否可用官方 HTML 渲染器。
|
|
84
|
+
* @author ddj 2026年11月21号
|
|
85
|
+
* @returns 探针结论
|
|
86
|
+
*/
|
|
87
|
+
export function hasOfficialHtmlPreview(): boolean {
|
|
88
|
+
return officialAvailable
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
/**
|
|
92
|
+
* 直接写入探针结论(测试注入与运行时校正用)。
|
|
93
|
+
* @author ddj 2026年11月21号
|
|
94
|
+
* @param available 是否可用
|
|
95
|
+
*/
|
|
96
|
+
export function setOfficialHtmlPreview(available: boolean): void {
|
|
97
|
+
officialAvailable = available === true
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
/**
|
|
101
|
+
* 复位探针结论(卸载/测试隔离用)。
|
|
102
|
+
* @author ddj 2026年11月21号
|
|
103
|
+
*/
|
|
104
|
+
export function resetHtmlPreviewProbe(): void {
|
|
105
|
+
officialAvailable = false
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
/**
|
|
109
|
+
* 缺省调度器:setTimeout,并在可能时 unref,避免长驻进程被探针拖住。
|
|
110
|
+
* @author ddj 2026年11月21号
|
|
111
|
+
* @param fn 回调
|
|
112
|
+
* @param ms 延时毫秒
|
|
113
|
+
*/
|
|
114
|
+
function defaultSchedule(fn: () => void, ms: number): void {
|
|
115
|
+
const timer = setTimeout(fn, ms) as unknown as { unref?: () => void }
|
|
116
|
+
try {
|
|
117
|
+
timer.unref?.()
|
|
118
|
+
} catch {
|
|
119
|
+
/* 无 unref 的运行环境忽略 */
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
/**
|
|
124
|
+
* 安装官方 HTML 渲染器探针:命中即置真并订阅后续变化;未命中按间隔有界重试。
|
|
125
|
+
* 服务缺失、快照畸形、订阅抛错都只影响探针结论,不影响插件装配。
|
|
126
|
+
* @author ddj 2026年11月21号
|
|
127
|
+
* @param ctx 客户端上下文(只需 get)
|
|
128
|
+
* @param options 调度与重试参数
|
|
129
|
+
* @returns 幂等卸载器(同时复位结论)
|
|
130
|
+
*/
|
|
131
|
+
export function installHtmlPreviewProbe(
|
|
132
|
+
ctx: { get: (name: string) => unknown },
|
|
133
|
+
options: HtmlPreviewProbeOptions = {},
|
|
134
|
+
): () => void {
|
|
135
|
+
const schedule = typeof options.schedule === 'function' ? options.schedule : defaultSchedule
|
|
136
|
+
const attempts = Number.isFinite(options.attempts) ? Math.max(1, Number(options.attempts)) : PROBE_ATTEMPTS
|
|
137
|
+
const intervalMs = Number.isFinite(options.intervalMs) ? Math.max(0, Number(options.intervalMs)) : PROBE_INTERVAL_MS
|
|
138
|
+
|
|
139
|
+
let disposed = false
|
|
140
|
+
let remaining = attempts
|
|
141
|
+
let offSubscribe: (() => void) | null = null
|
|
142
|
+
let subscribing = false
|
|
143
|
+
|
|
144
|
+
/** @private @author ddj 2026年11月21号 @returns Optional previews service. */
|
|
145
|
+
function serviceOf(): DocumentPreviewsLike | undefined {
|
|
146
|
+
try {
|
|
147
|
+
return ctx.get(DOCUMENT_PREVIEWS_SERVICE) as DocumentPreviewsLike | undefined
|
|
148
|
+
} catch {
|
|
149
|
+
return undefined
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
/**
|
|
154
|
+
* 订阅服务变化(只订一次;回调自身异常不扩散)。
|
|
155
|
+
* @author ddj 2026年11月21号
|
|
156
|
+
* @param service 已命中的服务
|
|
157
|
+
*/
|
|
158
|
+
function attach(service: DocumentPreviewsLike): void {
|
|
159
|
+
if (offSubscribe !== null || subscribing || typeof service.subscribe !== 'function') return
|
|
160
|
+
subscribing = true
|
|
161
|
+
try {
|
|
162
|
+
const off = service.subscribe(() => {
|
|
163
|
+
refresh()
|
|
164
|
+
})
|
|
165
|
+
offSubscribe = typeof off === 'function' ? (off as () => void) : null
|
|
166
|
+
} catch {
|
|
167
|
+
offSubscribe = null
|
|
168
|
+
} finally {
|
|
169
|
+
subscribing = false
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
/**
|
|
174
|
+
* 读取一次快照并更新结论;命中时补订阅。
|
|
175
|
+
* @author ddj 2026年11月21号
|
|
176
|
+
* @returns 本次是否命中
|
|
177
|
+
*/
|
|
178
|
+
function refresh(): boolean {
|
|
179
|
+
if (disposed) return false
|
|
180
|
+
const service = serviceOf()
|
|
181
|
+
if (!service || typeof service.getSnapshot !== 'function') return false
|
|
182
|
+
let present = false
|
|
183
|
+
try {
|
|
184
|
+
present = hasHtmlPreviewBody(service.getSnapshot())
|
|
185
|
+
} catch {
|
|
186
|
+
present = false
|
|
187
|
+
}
|
|
188
|
+
officialAvailable = present
|
|
189
|
+
// 服务已就绪就订阅:官方 html body 可能晚于服务注册(客户端插件加载顺序不定),
|
|
190
|
+
// 只在命中时订阅会漏掉「先有服务、后注册 html body」的时序。
|
|
191
|
+
attach(service)
|
|
192
|
+
return present
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
/**
|
|
196
|
+
* 一轮探测:命中即停,否则按剩余次数继续调度。
|
|
197
|
+
* @author ddj 2026年11月21号
|
|
198
|
+
*/
|
|
199
|
+
function tick(): void {
|
|
200
|
+
if (disposed) return
|
|
201
|
+
if (refresh()) return
|
|
202
|
+
remaining -= 1
|
|
203
|
+
if (remaining > 0) schedule(tick, intervalMs)
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
tick()
|
|
207
|
+
return () => {
|
|
208
|
+
disposed = true
|
|
209
|
+
officialAvailable = false
|
|
210
|
+
const off = offSubscribe
|
|
211
|
+
offSubscribe = null
|
|
212
|
+
try {
|
|
213
|
+
off?.()
|
|
214
|
+
} catch {
|
|
215
|
+
/* 卸载异常不影响调用方 */
|
|
216
|
+
}
|
|
217
|
+
}
|
|
218
|
+
}
|
package/src/client/index.ts
CHANGED
|
@@ -43,6 +43,9 @@ import { clientSummary } from './compatSummary.js'
|
|
|
43
43
|
import { detectSidebarService, hasSideRoute, installSideEditor, routeSideEditor, setEnsureSideEditor, SIDEBAR_INSTALL_CMD } from './sidebarBridge.js'
|
|
44
44
|
import { detectOfficial, installOfficial, registerOfficialFileClaim, OFFICIAL_TAB_KIND, OFFICIAL_TAB_TITLE, isEditorTabActive, markEditorActive, restoreEditorTab, buildFileAddress, readSavedTab, setEditorTabScope } from './officialSidebar.js'
|
|
45
45
|
import { setNativeCsv, setNativeOpenHandler, resetNativeOpen } from './nativeOpenStore.js'
|
|
46
|
+
import { hasOfficialHtmlPreview, installHtmlPreviewProbe, isHtmlPath } from './htmlPreview.js'
|
|
47
|
+
import { installHtmlPlanActions } from './htmlPlan/planActions.js'
|
|
48
|
+
import { setFeaturePrefs } from './featurePrefs.js'
|
|
46
49
|
import { SideEditorTab } from './ui/SideEditorTab.js'
|
|
47
50
|
import { OfficialSideTab } from './ui/OfficialSideTab.js'
|
|
48
51
|
import { createClaimRouter } from './ui/ClaimRouter.js'
|
|
@@ -92,6 +95,7 @@ import { dbg } from './rpc.js'
|
|
|
92
95
|
import { BP_MODE, MODES, fieldOfMode } from './dap/BpWidget.js'
|
|
93
96
|
import { ContextMenu } from './ui/ContextMenu.js'
|
|
94
97
|
import { editExcel, exportExcel, notifyExcel } from './excel/controller.js'
|
|
98
|
+
import { activateUniver, refreshUniver } from './univer/store.js'
|
|
95
99
|
|
|
96
100
|
/** Root-owned live objects shared with independent panel chunks; no copied stores or transport state. */
|
|
97
101
|
export const __lazyShared = { rpc, dbg, dapStore, BP_MODE, MODES, fieldOfMode, ContextMenu, editExcel, exportExcel, notifyExcel, openOriginal }
|
|
@@ -107,6 +111,21 @@ export const inject = ['slots', 'timer', 'locale', 'connection', 'remote', 'work
|
|
|
107
111
|
/** 指令桥单例(同一 document 重复 apply 只装配一次;HMR 重挂不重复注册)。 */
|
|
108
112
|
let commandsBridge: CommandBridge | null = null
|
|
109
113
|
|
|
114
|
+
/**
|
|
115
|
+
* 模板语言是否已注册进当前 Monaco(兼容性报告探针)。
|
|
116
|
+
* @author ddj 2026年11月15号
|
|
117
|
+
* @returns true = Monaco 语言目录里已含本插件注册的模板语言 id
|
|
118
|
+
*/
|
|
119
|
+
function templatesReady(): boolean {
|
|
120
|
+
try {
|
|
121
|
+
const languages = (window as unknown as { monaco?: { languages?: { getLanguages?: () => Array<{ id?: string }> } } }).monaco?.languages?.getLanguages?.()
|
|
122
|
+
if (!Array.isArray(languages)) return false
|
|
123
|
+
return languages.some((item) => item?.id === 'ejs' || item?.id === 'jinja')
|
|
124
|
+
} catch (error) {
|
|
125
|
+
return false
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
|
|
110
129
|
/**
|
|
111
130
|
* 装配指令注册表(指令桥 + 命令栏)。
|
|
112
131
|
* 指令桥不依赖已挂载编辑器(run 只派发窗口事件),故可在启动期装配;
|
|
@@ -256,12 +275,24 @@ export async function apply(ctx: any): Promise<void> {
|
|
|
256
275
|
const scope = readSessionScope(ctx)
|
|
257
276
|
// 传 undefined = 清除绑定(保留原 LSP 同步语义:无当前会话时不残留旧归属)
|
|
258
277
|
setSession(scope.sessionId)
|
|
278
|
+
activateUniver(scope.sessionId ?? '')
|
|
279
|
+
if (scope.sessionId) void refreshUniver(scope.sessionId)
|
|
259
280
|
if (!scope.sessionId || scope.sessionId === preloadedFor) return
|
|
260
281
|
preloadedFor = scope.sessionId
|
|
261
282
|
schedulePreload()
|
|
262
283
|
}
|
|
263
284
|
ctx.effect(() => subscribeScope(ctx, onScopeChange), 'vscode-mode: monaco session trigger')
|
|
264
285
|
onScopeChange()
|
|
286
|
+
ctx.effect(() => {
|
|
287
|
+
/** @private @author ddj 2026年11月12号 @sideEffects Rechecks optional service/policy without starting Gateway; no background-window polling. */
|
|
288
|
+
function refreshOffice() {
|
|
289
|
+
if (document.visibilityState === 'hidden') return
|
|
290
|
+
const scope = readSessionScope(ctx)
|
|
291
|
+
if (scope.sessionId) void refreshUniver(scope.sessionId)
|
|
292
|
+
}
|
|
293
|
+
const timer = window.setInterval(refreshOffice, 10000)
|
|
294
|
+
return () => { window.clearInterval(timer); activateUniver('') }
|
|
295
|
+
}, 'vscode-mode: optional Univer capability')
|
|
265
296
|
}
|
|
266
297
|
// 会话切换 → 编辑 Tab 跨会话自动恢复:上一会话编辑区激活时,新会话自动展开并激活
|
|
267
298
|
//(官方停靠面按会话隔离,新会话默认收起;先试 openTabIn 直写新会话面,未 adopt 走有界重试)。
|
|
@@ -297,6 +328,10 @@ export async function apply(ctx: any): Promise<void> {
|
|
|
297
328
|
let claimDisposer: (() => void) | null = null
|
|
298
329
|
/** 「添加到对话」动作集:编辑区/Tab 右键菜单注入文件引用与代码块(conversation 服务缺失时各动作安全降级)。 */
|
|
299
330
|
const addToConversation = createAddToConversation(ctx)
|
|
331
|
+
// 官方 HTML 渲染器探针:可选服务,缺失/旧版一律回退文本编辑,不阻断装配。
|
|
332
|
+
ctx.effect(() => installHtmlPreviewProbe(ctx, { schedule }), 'vscode-mode: html preview probe')
|
|
333
|
+
// HTML 计划页动作桥:状态读取 / 官方审批作答 / /plan off / 回填输入框(全部可选服务)。
|
|
334
|
+
ctx.effect(() => installHtmlPlanActions(ctx), 'vscode-mode: html plan actions')
|
|
300
335
|
|
|
301
336
|
/**
|
|
302
337
|
* 读取规则列表(rules.list;失败抛错,由快捷菜单按「未校验」降级)。
|
|
@@ -449,6 +484,10 @@ export async function apply(ctx: any): Promise<void> {
|
|
|
449
484
|
legacySidebar: sideService !== undefined, officialSidebar: officialService !== undefined,
|
|
450
485
|
fileClaim: claimDisposer !== null, claimWanted: shouldClaimFiles(selected), selected,
|
|
451
486
|
officialMenus: Boolean(ctx.get('contextMenus')), forge: forge.available(),
|
|
487
|
+
// 交互特性探针:模板语言注册、composer 座位、搜索替换(v0.30.0)
|
|
488
|
+
templateLanguages: templatesReady(),
|
|
489
|
+
composerSeat: typeof document !== 'undefined' && document.querySelector('[data-composer-seat]') !== null,
|
|
490
|
+
searchReplace: true,
|
|
452
491
|
}, version)
|
|
453
492
|
|
|
454
493
|
ctx.provide('fileOpeners', registry)
|
|
@@ -556,6 +595,8 @@ export async function apply(ctx: any): Promise<void> {
|
|
|
556
595
|
window.dispatchEvent(new CustomEvent('edrv:max-open-editors', { detail: { value: limit } }))
|
|
557
596
|
// 原生打开范围同拍推送(nativeOpenStore 解析缓存;旧版无该字段 → 保持默认集)
|
|
558
597
|
setNativeCsv(snapshot.value?.nativeOpenExts)
|
|
598
|
+
// 交互特性开关(引用接入 / 搜索替换):模块级缓存 + 事件,输入事件热路径直接读
|
|
599
|
+
setFeaturePrefs(snapshot.value ?? {})
|
|
559
600
|
}
|
|
560
601
|
sync()
|
|
561
602
|
return scope.subscribe(sync)
|
|
@@ -737,6 +778,8 @@ export async function apply(ctx: any): Promise<void> {
|
|
|
737
778
|
//(claim 的 canOpen 同步让位该范围,否则地址又被认领转发回本插件);形态撤下时解绑
|
|
738
779
|
ctx.effect(() => {
|
|
739
780
|
setNativeOpenHandler((path) => {
|
|
781
|
+
// 旧版/无官方 HTML 渲染器:不调 openResource,回退本插件文本编辑。
|
|
782
|
+
if (isHtmlPath(path) && !hasOfficialHtmlPreview()) return false
|
|
740
783
|
const scope = readSessionScope(ctx)
|
|
741
784
|
if (!scope.sessionId) return false
|
|
742
785
|
official.service.openResource?.(buildFileAddress(path, scope.sessionId))
|