dsh-vscode-mode 0.33.0 → 0.33.1
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 +12 -4
- package/lib/client.excel.js +22 -1
- package/lib/client.js +21 -0
- package/lib/client.js.map +1 -1
- package/lib/index.js +17 -9
- package/lib/index.js.map +1 -1
- package/package.json +1 -1
- package/src/httpGuard.ts +30 -8
- package/src/routes.ts +1 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dsh-vscode-mode",
|
|
3
|
-
"version": "0.33.
|
|
3
|
+
"version": "0.33.1",
|
|
4
4
|
"description": "DSH 上的类 VSCode 编码体验:Monaco 编辑器(文件页签/QuickOpen/状态栏,可驻 DSH 0.1.5+ 官方右侧 Sidebar 与对话同屏)+ 命令栏(Ctrl+Shift+P)与可扩展指令系统 + VS Code 兼容代码片段(.code-snippets 全局/项目,IntelliSense 展开)+ Agent 编辑差异审查(整文件差异/采纳/拒绝/归档/回滚)+ SVN 集成(侧栏变更面板/日志弹窗/并排差异)+ 语言服务器(LSP)智能(跳转定义/引用/hover/大纲 + VSIX 扩展市场安装),状态持久化到工作区旁车,界面状态(页签/光标/侧栏/编辑 Tab/导航历史)镜像到 DSH home 跨重启恢复",
|
|
5
5
|
"icon": "assets/icon.svg",
|
|
6
6
|
"keywords": [
|
package/src/httpGuard.ts
CHANGED
|
@@ -8,6 +8,16 @@ export const RPC_BODY_CAP = Math.max(READ_CAP * 6, Math.ceil(BINARY_READ_CAP / 3
|
|
|
8
8
|
export interface RpcInput { method: string; args: Record<string, unknown> }
|
|
9
9
|
type InputResult = { input: RpcInput } | { status: number; error: string }
|
|
10
10
|
|
|
11
|
+
/** Host 连接服务的旧版围栏(DSH 0.2.3 起已移除;存在时由插件自己调用)。 */
|
|
12
|
+
interface LegacyConnection {
|
|
13
|
+
/**
|
|
14
|
+
* 类方法:必须带服务实例作为 this 调用,方法体内部会读 this.admit()。
|
|
15
|
+
* @param request 原始 Node 请求(含认证头)。
|
|
16
|
+
* @returns 拒绝状态码;undefined 表示放行。
|
|
17
|
+
*/
|
|
18
|
+
requestRejection?: (request: IncomingMessage) => number | undefined
|
|
19
|
+
}
|
|
20
|
+
|
|
11
21
|
/**
|
|
12
22
|
* Send a JSON response without allowing credential-dependent results to be cached.
|
|
13
23
|
* @author ddj 2026年09月28号
|
|
@@ -22,6 +32,9 @@ export function replyJson(res: ServerResponse, status: number, value: unknown):
|
|
|
22
32
|
res.end(JSON.stringify(value))
|
|
23
33
|
}
|
|
24
34
|
|
|
35
|
+
/** 围栏异常只报一次:客户端会重试,逐次刷日志只会淹没真正的原因。 */
|
|
36
|
+
let fenceWarned = false
|
|
37
|
+
|
|
25
38
|
/**
|
|
26
39
|
* Resolve the legacy Host connection fence, or undefined when the host no longer has one.
|
|
27
40
|
* DSH 0.2.3 removed connection.requestRejection: the framework now authorizes a route
|
|
@@ -32,17 +45,25 @@ export function replyJson(res: ServerResponse, status: number, value: unknown):
|
|
|
32
45
|
* @param req Original Node request, including authentication headers.
|
|
33
46
|
* @returns The rejection status, or undefined when the host has no legacy fence.
|
|
34
47
|
*/
|
|
35
|
-
function legacyRejection(ctx: Ctx, req: IncomingMessage): number | undefined {
|
|
36
|
-
let
|
|
48
|
+
function legacyRejection(ctx: Ctx, req: IncomingMessage, warning?: (text: string) => void): number | undefined {
|
|
49
|
+
let connection: LegacyConnection | undefined
|
|
37
50
|
try {
|
|
38
|
-
|
|
51
|
+
connection = ctx.get('connection') as LegacyConnection | undefined
|
|
39
52
|
} catch {
|
|
40
|
-
|
|
53
|
+
connection = undefined
|
|
41
54
|
}
|
|
55
|
+
const reject = connection?.requestRejection
|
|
42
56
|
if (typeof reject !== 'function') return undefined
|
|
43
57
|
try {
|
|
44
|
-
|
|
45
|
-
|
|
58
|
+
// 必须以服务实例为接收者调用:requestRejection 是类方法,内部要走 this.admit()。
|
|
59
|
+
// 取出方法再裸调(v0.33.0 的写法)会在 0.2.3 之前的宿主上抛 TypeError → 503。
|
|
60
|
+
return reject.call(connection, req)
|
|
61
|
+
} catch (error) {
|
|
62
|
+
// 围栏本身坏掉时不再静默:把原因留给宿主日志,界面侧只看到 503。
|
|
63
|
+
if (!fenceWarned) {
|
|
64
|
+
fenceWarned = true
|
|
65
|
+
warning?.('兼容性:旧版 connection.requestRejection 调用失败(' + String(error) + ')')
|
|
66
|
+
}
|
|
46
67
|
return 503
|
|
47
68
|
}
|
|
48
69
|
}
|
|
@@ -69,10 +90,11 @@ export function routeAuthMode(ctx: Ctx): 'legacy' | 'framework' {
|
|
|
69
90
|
* @param req Original Node request, including authentication headers.
|
|
70
91
|
* @param res Response receiving a refusal when unavailable or unauthorized.
|
|
71
92
|
* @param methods Allowed HTTP methods for this route.
|
|
93
|
+
* @param warning Optional diagnostic sink for a broken legacy fence.
|
|
72
94
|
* @returns Whether the request may proceed.
|
|
73
95
|
*/
|
|
74
|
-
export function admitRoute(ctx: Ctx, req: IncomingMessage, res: ServerResponse, methods: string[]): boolean {
|
|
75
|
-
const rejection = legacyRejection(ctx, req)
|
|
96
|
+
export function admitRoute(ctx: Ctx, req: IncomingMessage, res: ServerResponse, methods: string[], warning?: (text: string) => void): boolean {
|
|
97
|
+
const rejection = legacyRejection(ctx, req, warning)
|
|
76
98
|
if (rejection !== undefined) {
|
|
77
99
|
const status = rejection === 401 || rejection === 403 ? rejection : 503
|
|
78
100
|
replyJson(res, status, { ok: false, error: status === 503 ? 'Host authentication service unavailable' : 'Host authentication rejected this request' })
|
package/src/routes.ts
CHANGED
|
@@ -143,7 +143,7 @@ function assetHandler(directory: string, prefix?: string, filename?: string): Ht
|
|
|
143
143
|
function mountRoute(ctx: Ctx, route: PluginRoute, warning?: (text: string) => void): void {
|
|
144
144
|
/** @author ddj 2026年09月28号 @param req Original HTTP request. @param res HTTP response. */
|
|
145
145
|
async function guarded(req: IncomingMessage, res: ServerResponse): Promise<void> {
|
|
146
|
-
if (!admitRoute(ctx, req, res, route.methods)) return
|
|
146
|
+
if (!admitRoute(ctx, req, res, route.methods, warning)) return
|
|
147
147
|
try { await route.handler(req, res) } catch {
|
|
148
148
|
if (!res.headersSent) replyJson(res, 500, { ok: false, error: 'Plugin request failed' })
|
|
149
149
|
else res.end()
|