dsh-my-guardian 0.4.5 → 0.4.6
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/CHANGELOG.md +7 -0
- package/lib/api.js +7 -5
- package/lib/client.js +7 -1
- package/lib/index.js +1 -1
- package/lib/parts/util.js +7 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -6,6 +6,13 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
|
|
|
6
6
|
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
7
7
|
|
|
8
8
|
|
|
9
|
+
## [0.4.6] - 2026-10-17
|
|
10
|
+
|
|
11
|
+
### 变更
|
|
12
|
+
|
|
13
|
+
- fix(i18n): 插件文案优先跟随宿主 html lang
|
|
14
|
+
- fix(compat): 适配 DSH 0.2.1 移除 webRuntime 服务
|
|
15
|
+
|
|
9
16
|
## [0.4.5] - 2026-10-17
|
|
10
17
|
|
|
11
18
|
### 变更
|
package/lib/api.js
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
* appears), trust fence, method dispatch and the panel snapshot.
|
|
5
5
|
*/
|
|
6
6
|
import { readStagedFile, writeStagedFile } from './state.js';
|
|
7
|
-
import {
|
|
7
|
+
import { createTrustFence, readJsonBody, writeJson } from 'dsh-shared';
|
|
8
8
|
/** Bind the API entry points to one guardian instance's shared state. */
|
|
9
9
|
export function createApi(ctx, shared) {
|
|
10
10
|
return {
|
|
@@ -22,13 +22,15 @@ function ensureApi(ctx, shared) {
|
|
|
22
22
|
const webServer = ctx.get('webServer');
|
|
23
23
|
if (webServer === undefined)
|
|
24
24
|
return;
|
|
25
|
-
|
|
25
|
+
// 信任源迁移(DSH 0.2.1 移除 webRuntime):每次请求现读
|
|
26
|
+
// webStartup.trustedHosts + webServer.host,旧宿主回退 webRuntime(dsh-shared 内部兼容)。
|
|
27
|
+
const fence = createTrustFence(ctx);
|
|
26
28
|
shared.apiRegistered = true;
|
|
27
29
|
try {
|
|
28
30
|
ctx.effect(() => webServer.register({
|
|
29
31
|
kind: 'prefix',
|
|
30
32
|
path: '/guardian/api',
|
|
31
|
-
handler: (request, response) => handleApiRequest(ctx, shared,
|
|
33
|
+
handler: (request, response) => handleApiRequest(ctx, shared, fence, request, response),
|
|
32
34
|
}), 'dsh-my-guardian: /guardian/api routes');
|
|
33
35
|
}
|
|
34
36
|
catch (error) {
|
|
@@ -38,8 +40,8 @@ function ensureApi(ctx, shared) {
|
|
|
38
40
|
}
|
|
39
41
|
}
|
|
40
42
|
/** Unified route handler: fence → method dispatch → 404/error fallback. */
|
|
41
|
-
async function handleApiRequest(ctx, shared,
|
|
42
|
-
if (!
|
|
43
|
+
async function handleApiRequest(ctx, shared, fence, request, response) {
|
|
44
|
+
if (!fence(request)) {
|
|
43
45
|
writeJson(response, 403, { ok: false, error: { code: 'forbidden', message: 'forbidden' } });
|
|
44
46
|
return;
|
|
45
47
|
}
|
package/lib/client.js
CHANGED
|
@@ -237,8 +237,14 @@ const STYLES = `
|
|
|
237
237
|
|
|
238
238
|
'use strict'
|
|
239
239
|
// ── i18n ──────────────────────────────────────────────────────────────
|
|
240
|
-
/**
|
|
240
|
+
/** 当前界面语言是否为中文:宿主 <html lang> 优先,其次浏览器语言,再其次英文。 */
|
|
241
241
|
function isZh() {
|
|
242
|
+
try {
|
|
243
|
+
const host = (document.documentElement.lang || '').toLowerCase()
|
|
244
|
+
if (host !== '') return host.startsWith('zh')
|
|
245
|
+
} catch {
|
|
246
|
+
/* 非浏览器环境(node 渲染)无 document */
|
|
247
|
+
}
|
|
242
248
|
try {
|
|
243
249
|
return (navigator.language || 'en').toLowerCase().startsWith('zh')
|
|
244
250
|
} catch {
|
package/lib/index.js
CHANGED
|
@@ -22,7 +22,7 @@
|
|
|
22
22
|
* way to recover an environment a new plugin broke.
|
|
23
23
|
*
|
|
24
24
|
* Self-protection (watchdog): every async path is caught; only the loader
|
|
25
|
-
* service is a hard dependency; webServer
|
|
25
|
+
* service is a hard dependency; webServer is optional (a CLI
|
|
26
26
|
* profile without a web surface still gets staged loading, just no HTTP
|
|
27
27
|
* panel). The guardian never rewrites cordis.patch.yml; its own state lives
|
|
28
28
|
* at $DSH_HOME/guardian/state.json (atomic tmp+rename).
|
package/lib/parts/util.js
CHANGED
|
@@ -1,7 +1,13 @@
|
|
|
1
1
|
'use strict'
|
|
2
2
|
// ── i18n ──────────────────────────────────────────────────────────────
|
|
3
|
-
/**
|
|
3
|
+
/** 当前界面语言是否为中文:宿主 <html lang> 优先,其次浏览器语言,再其次英文。 */
|
|
4
4
|
function isZh() {
|
|
5
|
+
try {
|
|
6
|
+
const host = (document.documentElement.lang || '').toLowerCase()
|
|
7
|
+
if (host !== '') return host.startsWith('zh')
|
|
8
|
+
} catch {
|
|
9
|
+
/* 非浏览器环境(node 渲染)无 document */
|
|
10
|
+
}
|
|
5
11
|
try {
|
|
6
12
|
return (navigator.language || 'en').toLowerCase().startsWith('zh')
|
|
7
13
|
} catch {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dsh-my-guardian",
|
|
3
|
-
"version": "0.4.
|
|
3
|
+
"version": "0.4.6",
|
|
4
4
|
"description": "DSH 插件治理守护:新装/更新插件先进候选区,启动后热挂载——成功转正、失败自动禁用、连续失败冻结,一键安全模式,侧边栏诊断面板。DSH web plugin: staged plugin loading with auto-disable on failure, freeze, safe mode and a sidebar panel.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "lib/index.js",
|