dsh-cookie-cleaner 0.6.4 → 0.7.2
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 +270 -242
- package/LICENSE +21 -21
- package/README.md +432 -432
- package/cordis.patch.yml +5 -5
- package/dsh.plugin.json +1 -1
- package/lib/client.js +336 -8
- package/lib/client.js.map +1 -1
- package/package.json +1 -1
- package/scripts/gen-locales.mjs +82 -82
- package/scripts/hosts.mjs +57 -57
- package/scripts/sync-hosts.mjs +80 -80
- package/src/api-routes.js +144 -138
- package/src/cli.js +281 -236
- package/src/client/card.tsx +315 -253
- package/src/client/index.ts +129 -129
- package/src/client/locales.ts +91 -84
- package/src/client/routes.ts +138 -118
- package/src/client/star-row-copy.ts +256 -0
- package/src/core.js +669 -531
- package/src/i18n.js +140 -140
- package/src/index.js +426 -394
- package/src/jar-live.js +365 -365
- package/src/legacy-injection.js +137 -0
- package/src/locales-advise-owner.js +39 -39
- package/src/locales-dict.js +220 -220
- package/src/locales-dict2.js +214 -214
- package/src/locales-patch.js +207 -207
- package/src/patch-guard.js +509 -416
- package/src/patch-model.js +271 -271
- package/src/patch-read.js +251 -199
- package/src/report.js +243 -243
- package/src/runtime-guard.js +14 -4
- package/src/settings-waist.js +37 -37
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dsh-cookie-cleaner",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.7.2",
|
|
4
4
|
"description": "Fixes the 'desktop welcome: Web authentication failed' (HTTP 431) launch failure caused by dsh-auth-* cookie pile-up in the desktop client's Chromium cookie store (random port per launch, ~70 entries overflow the 16KB header cap). Reports leftover entries with the estimated request-header occupancy and how much room is left before 431, and ships a standalone command that purges them once the client is fully closed (backup + atomic transaction, credentials/sessions/plugin config untouched); the settings panel audits your profile's cordis.patch.yml and one-click fixes connection.cookieMaxAgeDays (cookie lifetime, revertible). See README for usage.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|
package/scripts/gen-locales.mjs
CHANGED
|
@@ -1,82 +1,82 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* scripts/gen-locales.mjs — 生成 locale/<lang>.json(9 语包元数据)。
|
|
3
|
-
*
|
|
4
|
-
* 单一真源就是本文件的 TABLE;`--check` 模式只校验磁盘与表一致(prepack 门禁挂它),
|
|
5
|
-
* 避免「手改了 json 没同步表」或反之。宿主以 en.json 为锚,缺锚则整个 locale/ 被忽略。
|
|
6
|
-
*/
|
|
7
|
-
import fs from 'node:fs'
|
|
8
|
-
import path from 'node:path'
|
|
9
|
-
import { fileURLToPath } from 'node:url'
|
|
10
|
-
|
|
11
|
-
const ROOT = path.resolve(path.dirname(fileURLToPath(import.meta.url)), '..')
|
|
12
|
-
const OUT = path.join(ROOT, 'locale')
|
|
13
|
-
|
|
14
|
-
const TABLE = {
|
|
15
|
-
zh: {
|
|
16
|
-
title: 'Cookie 清理器',
|
|
17
|
-
description: '只读播报桌面客户端 cookie 库里残留的 dsh-auth-* 本地登录凭据,随包分发「客户端完全退出后」可执行的清理命令;并提供 profile patch 的结构化体检与一键修复面板。',
|
|
18
|
-
},
|
|
19
|
-
en: {
|
|
20
|
-
title: 'Cookie Cleaner',
|
|
21
|
-
description: "Reports leftover dsh-auth-* entries in the desktop client's cookie store, ships a command that purges them once the client is fully closed, and adds a panel that checks and repairs the profile patch structure.",
|
|
22
|
-
},
|
|
23
|
-
ja: {
|
|
24
|
-
title: 'Cookie クリーナー',
|
|
25
|
-
description: 'デスクトップクライアントの cookie ストアに残った dsh-auth-* を読み取り専用で報告し、クライアントを完全終了後に消去するコマンドを同梱。さらに profile patch の構造点検とワンクリック修復のパネルも提供します。',
|
|
26
|
-
},
|
|
27
|
-
ko: {
|
|
28
|
-
title: 'Cookie 정리 도구',
|
|
29
|
-
description: '데스크톱 클라이언트 cookie 저장소에 남은 dsh-auth-*를 읽기 전용으로 보고하고, 클라이언트를 완전히 종료한 뒤 지우는 명령을 함께 배포하며, profile patch 구조 점검·원클릭 복구 패널도 제공합니다.',
|
|
30
|
-
},
|
|
31
|
-
fr: {
|
|
32
|
-
title: 'Nettoyeur de cookies',
|
|
33
|
-
description: "Signale les entrées dsh-auth-* restantes dans la base de cookies du client desktop, fournit une commande qui les purge une fois le client entièrement fermé et ajoute un panneau qui contrôle et répare la structure du patch de profil.",
|
|
34
|
-
},
|
|
35
|
-
de: {
|
|
36
|
-
title: 'Cookie-Räumer',
|
|
37
|
-
description: 'Meldet übrig gebliebene dsh-auth-* Einträge im Cookie-Speicher des Desktop-Clients, liefert einen Befehl, der sie nach vollständigem Beenden räumt, und zeigt ein Panel zur Prüfung und Korrektur der Profil-Patch-Struktur.',
|
|
38
|
-
},
|
|
39
|
-
it: {
|
|
40
|
-
title: 'Pulitore di cookie',
|
|
41
|
-
description: "Segnala le voci dsh-auth-* residue nell'archivio cookie del client desktop, fornisce un comando che le elimina dopo aver chiuso completamente il client e aggiunge un pannello che controlla e corregge la struttura del patch del profilo.",
|
|
42
|
-
},
|
|
43
|
-
ru: {
|
|
44
|
-
title: 'Очистка cookie',
|
|
45
|
-
description: 'Отчитывается об остатках dsh-auth-* в хранилище cookie десктопного клиента, поставляет команду очистки после полного выхода из клиента и добавляет панель проверки и исправления структуры патча профиля.',
|
|
46
|
-
},
|
|
47
|
-
es: {
|
|
48
|
-
title: 'Limpiador de cookies',
|
|
49
|
-
description: 'Informa de las entradas dsh-auth-* residuales en el almacén de cookies del cliente de escritorio, ofrece un comando que las purga tras cerrar del todo el cliente y añade un panel que revisa y repara la estructura del patch de perfil.',
|
|
50
|
-
},
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
const langs = Object.keys(TABLE)
|
|
54
|
-
if (langs.length !== 9) throw new Error('locale 必须正好 9 语,当前 ' + langs.length)
|
|
55
|
-
if (!langs.includes('en')) throw new Error('缺 en 锚,宿主会忽略整个 locale/ 目录')
|
|
56
|
-
|
|
57
|
-
const check = process.argv.includes('--check')
|
|
58
|
-
const drift = []
|
|
59
|
-
fs.mkdirSync(OUT, { recursive: true })
|
|
60
|
-
|
|
61
|
-
for (const lang of langs) {
|
|
62
|
-
const expected = JSON.stringify({ meta: TABLE[lang] }, null, 2) + '\n'
|
|
63
|
-
const file = path.join(OUT, `${lang}.json`)
|
|
64
|
-
if (check) {
|
|
65
|
-
const actual = fs.existsSync(file) ? fs.readFileSync(file, 'utf8') : null
|
|
66
|
-
if (actual === null) drift.push(`${lang}.json 缺失`)
|
|
67
|
-
else if (actual !== expected) drift.push(`${lang}.json 与表不一致`)
|
|
68
|
-
} else {
|
|
69
|
-
fs.writeFileSync(file, expected, 'utf8')
|
|
70
|
-
}
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
if (check) {
|
|
74
|
-
if (drift.length > 0) {
|
|
75
|
-
process.stderr.write('locale 漂移:\n - ' + drift.join('\n - ') + '\n运行 `node scripts/gen-locales.mjs` 修复。\n')
|
|
76
|
-
process.exitCode = 1
|
|
77
|
-
} else {
|
|
78
|
-
process.stdout.write(`locale 9 语与表一致(锚 en 在位)\n`)
|
|
79
|
-
}
|
|
80
|
-
} else {
|
|
81
|
-
process.stdout.write(`已生成 ${langs.length} 份 locale/<lang>.json\n`)
|
|
82
|
-
}
|
|
1
|
+
/**
|
|
2
|
+
* scripts/gen-locales.mjs — 生成 locale/<lang>.json(9 语包元数据)。
|
|
3
|
+
*
|
|
4
|
+
* 单一真源就是本文件的 TABLE;`--check` 模式只校验磁盘与表一致(prepack 门禁挂它),
|
|
5
|
+
* 避免「手改了 json 没同步表」或反之。宿主以 en.json 为锚,缺锚则整个 locale/ 被忽略。
|
|
6
|
+
*/
|
|
7
|
+
import fs from 'node:fs'
|
|
8
|
+
import path from 'node:path'
|
|
9
|
+
import { fileURLToPath } from 'node:url'
|
|
10
|
+
|
|
11
|
+
const ROOT = path.resolve(path.dirname(fileURLToPath(import.meta.url)), '..')
|
|
12
|
+
const OUT = path.join(ROOT, 'locale')
|
|
13
|
+
|
|
14
|
+
const TABLE = {
|
|
15
|
+
zh: {
|
|
16
|
+
title: 'Cookie 清理器',
|
|
17
|
+
description: '只读播报桌面客户端 cookie 库里残留的 dsh-auth-* 本地登录凭据,随包分发「客户端完全退出后」可执行的清理命令;并提供 profile patch 的结构化体检与一键修复面板。',
|
|
18
|
+
},
|
|
19
|
+
en: {
|
|
20
|
+
title: 'Cookie Cleaner',
|
|
21
|
+
description: "Reports leftover dsh-auth-* entries in the desktop client's cookie store, ships a command that purges them once the client is fully closed, and adds a panel that checks and repairs the profile patch structure.",
|
|
22
|
+
},
|
|
23
|
+
ja: {
|
|
24
|
+
title: 'Cookie クリーナー',
|
|
25
|
+
description: 'デスクトップクライアントの cookie ストアに残った dsh-auth-* を読み取り専用で報告し、クライアントを完全終了後に消去するコマンドを同梱。さらに profile patch の構造点検とワンクリック修復のパネルも提供します。',
|
|
26
|
+
},
|
|
27
|
+
ko: {
|
|
28
|
+
title: 'Cookie 정리 도구',
|
|
29
|
+
description: '데스크톱 클라이언트 cookie 저장소에 남은 dsh-auth-*를 읽기 전용으로 보고하고, 클라이언트를 완전히 종료한 뒤 지우는 명령을 함께 배포하며, profile patch 구조 점검·원클릭 복구 패널도 제공합니다.',
|
|
30
|
+
},
|
|
31
|
+
fr: {
|
|
32
|
+
title: 'Nettoyeur de cookies',
|
|
33
|
+
description: "Signale les entrées dsh-auth-* restantes dans la base de cookies du client desktop, fournit une commande qui les purge une fois le client entièrement fermé et ajoute un panneau qui contrôle et répare la structure du patch de profil.",
|
|
34
|
+
},
|
|
35
|
+
de: {
|
|
36
|
+
title: 'Cookie-Räumer',
|
|
37
|
+
description: 'Meldet übrig gebliebene dsh-auth-* Einträge im Cookie-Speicher des Desktop-Clients, liefert einen Befehl, der sie nach vollständigem Beenden räumt, und zeigt ein Panel zur Prüfung und Korrektur der Profil-Patch-Struktur.',
|
|
38
|
+
},
|
|
39
|
+
it: {
|
|
40
|
+
title: 'Pulitore di cookie',
|
|
41
|
+
description: "Segnala le voci dsh-auth-* residue nell'archivio cookie del client desktop, fornisce un comando che le elimina dopo aver chiuso completamente il client e aggiunge un pannello che controlla e corregge la struttura del patch del profilo.",
|
|
42
|
+
},
|
|
43
|
+
ru: {
|
|
44
|
+
title: 'Очистка cookie',
|
|
45
|
+
description: 'Отчитывается об остатках dsh-auth-* в хранилище cookie десктопного клиента, поставляет команду очистки после полного выхода из клиента и добавляет панель проверки и исправления структуры патча профиля.',
|
|
46
|
+
},
|
|
47
|
+
es: {
|
|
48
|
+
title: 'Limpiador de cookies',
|
|
49
|
+
description: 'Informa de las entradas dsh-auth-* residuales en el almacén de cookies del cliente de escritorio, ofrece un comando que las purga tras cerrar del todo el cliente y añade un panel que revisa y repara la estructura del patch de perfil.',
|
|
50
|
+
},
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
const langs = Object.keys(TABLE)
|
|
54
|
+
if (langs.length !== 9) throw new Error('locale 必须正好 9 语,当前 ' + langs.length)
|
|
55
|
+
if (!langs.includes('en')) throw new Error('缺 en 锚,宿主会忽略整个 locale/ 目录')
|
|
56
|
+
|
|
57
|
+
const check = process.argv.includes('--check')
|
|
58
|
+
const drift = []
|
|
59
|
+
fs.mkdirSync(OUT, { recursive: true })
|
|
60
|
+
|
|
61
|
+
for (const lang of langs) {
|
|
62
|
+
const expected = JSON.stringify({ meta: TABLE[lang] }, null, 2) + '\n'
|
|
63
|
+
const file = path.join(OUT, `${lang}.json`)
|
|
64
|
+
if (check) {
|
|
65
|
+
const actual = fs.existsSync(file) ? fs.readFileSync(file, 'utf8') : null
|
|
66
|
+
if (actual === null) drift.push(`${lang}.json 缺失`)
|
|
67
|
+
else if (actual !== expected) drift.push(`${lang}.json 与表不一致`)
|
|
68
|
+
} else {
|
|
69
|
+
fs.writeFileSync(file, expected, 'utf8')
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
if (check) {
|
|
74
|
+
if (drift.length > 0) {
|
|
75
|
+
process.stderr.write('locale 漂移:\n - ' + drift.join('\n - ') + '\n运行 `node scripts/gen-locales.mjs` 修复。\n')
|
|
76
|
+
process.exitCode = 1
|
|
77
|
+
} else {
|
|
78
|
+
process.stdout.write(`locale 9 语与表一致(锚 en 在位)\n`)
|
|
79
|
+
}
|
|
80
|
+
} else {
|
|
81
|
+
process.stdout.write(`已生成 ${langs.length} 份 locale/<lang>.json\n`)
|
|
82
|
+
}
|
package/scripts/hosts.mjs
CHANGED
|
@@ -1,57 +1,57 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* dsh-cookie-cleaner — 宿主兼容清单(单一真源)。
|
|
3
|
-
*
|
|
4
|
-
* `scripts/sync-hosts.mjs` 把这份清单同步进三处:package.json 的 `engines.dsh`、
|
|
5
|
-
* package.json 的 `dsh.compatibility.dshReleases`、dsh.plugin.json 的 `engines.dsh`。
|
|
6
|
-
* 三处必须逐串相等(判定闸门只读 engines.dsh,compatibility 供插件管理器展示),
|
|
7
|
-
* 手工改其中一处而漏掉其余 = 假兼容/假拒绝的直接来源。
|
|
8
|
-
*/
|
|
9
|
-
|
|
10
|
-
/**
|
|
11
|
-
* 判定闸门声明面:`engines.dsh` 两处写点(package.json / dsh.plugin.json)与**全部**
|
|
12
|
-
* `@deepseek-ai/dsh-*` peer 共用下面这个区间(定义在 HOSTS 之后,下限由其起点推导)。
|
|
13
|
-
* HOSTS 枚举继续供 `dsh.compatibility.dshReleases` 展示(已实测细胞证据)。
|
|
14
|
-
*/
|
|
15
|
-
|
|
16
|
-
/** 已验证可装载的宿主线(逐 rc 单列,供 compatibility 展示与 peer range)。 */
|
|
17
|
-
export const HOSTS = [
|
|
18
|
-
'0.1.0-rc.2',
|
|
19
|
-
'0.1.0-rc.3',
|
|
20
|
-
'0.1.0-rc.6',
|
|
21
|
-
'0.1.0-rc.7',
|
|
22
|
-
'0.1.0-rc.8',
|
|
23
|
-
'0.1.1-rc.1',
|
|
24
|
-
'0.1.1-rc.2',
|
|
25
|
-
'0.1.2-rc.1',
|
|
26
|
-
'0.1.5-rc.1',
|
|
27
|
-
'0.1.5-rc.2',
|
|
28
|
-
'0.1.5-rc.3',
|
|
29
|
-
'0.1.7-rc.1',
|
|
30
|
-
'0.1.7-rc.2',
|
|
31
|
-
'0.2.0-rc.1',
|
|
32
|
-
'0.2.0-rc.2',
|
|
33
|
-
'0.2.1-rc.1',
|
|
34
|
-
'0.2.1-rc.2',
|
|
35
|
-
'0.2.1-rc.3',
|
|
36
|
-
'0.2.1-rc.4',
|
|
37
|
-
'0.2.1-rc.5',
|
|
38
|
-
// 0.2.2 line
|
|
39
|
-
'0.2.2-rc.1',
|
|
40
|
-
]
|
|
41
|
-
|
|
42
|
-
/**
|
|
43
|
-
* 唯一宿主声明串(2026-11-14 形状统一):engines.dsh 两处写点与全部 dsh-* peer 共用;
|
|
44
|
-
* 下限=HOSTS 起点,上限 `<0.3.0-0`(`-0` 堵住 0.3.0-rc.* 泄漏)。
|
|
45
|
-
*/
|
|
46
|
-
export const ENGINES_RANGE = `>=${HOSTS[0]} <0.3.0-0`
|
|
47
|
-
|
|
48
|
-
/** 每个宿主线的兼容判定。 */
|
|
49
|
-
export const STATUS = 'compatible'
|
|
50
|
-
|
|
51
|
-
/** npm 语法的逐串 or-range:`0.1.0-rc.2 || 0.1.0-rc.3 || ...`(仅作展示/证据)。 */
|
|
52
|
-
export function orRange(hosts = HOSTS) {
|
|
53
|
-
return hosts.join(' || ')
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
/** peer 下发用串:与 engines.dsh 同串(2026-11-14 起不再下发枚举)。 */
|
|
57
|
-
export const PEER_RANGE = ENGINES_RANGE
|
|
1
|
+
/**
|
|
2
|
+
* dsh-cookie-cleaner — 宿主兼容清单(单一真源)。
|
|
3
|
+
*
|
|
4
|
+
* `scripts/sync-hosts.mjs` 把这份清单同步进三处:package.json 的 `engines.dsh`、
|
|
5
|
+
* package.json 的 `dsh.compatibility.dshReleases`、dsh.plugin.json 的 `engines.dsh`。
|
|
6
|
+
* 三处必须逐串相等(判定闸门只读 engines.dsh,compatibility 供插件管理器展示),
|
|
7
|
+
* 手工改其中一处而漏掉其余 = 假兼容/假拒绝的直接来源。
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* 判定闸门声明面:`engines.dsh` 两处写点(package.json / dsh.plugin.json)与**全部**
|
|
12
|
+
* `@deepseek-ai/dsh-*` peer 共用下面这个区间(定义在 HOSTS 之后,下限由其起点推导)。
|
|
13
|
+
* HOSTS 枚举继续供 `dsh.compatibility.dshReleases` 展示(已实测细胞证据)。
|
|
14
|
+
*/
|
|
15
|
+
|
|
16
|
+
/** 已验证可装载的宿主线(逐 rc 单列,供 compatibility 展示与 peer range)。 */
|
|
17
|
+
export const HOSTS = [
|
|
18
|
+
'0.1.0-rc.2',
|
|
19
|
+
'0.1.0-rc.3',
|
|
20
|
+
'0.1.0-rc.6',
|
|
21
|
+
'0.1.0-rc.7',
|
|
22
|
+
'0.1.0-rc.8',
|
|
23
|
+
'0.1.1-rc.1',
|
|
24
|
+
'0.1.1-rc.2',
|
|
25
|
+
'0.1.2-rc.1',
|
|
26
|
+
'0.1.5-rc.1',
|
|
27
|
+
'0.1.5-rc.2',
|
|
28
|
+
'0.1.5-rc.3',
|
|
29
|
+
'0.1.7-rc.1',
|
|
30
|
+
'0.1.7-rc.2',
|
|
31
|
+
'0.2.0-rc.1',
|
|
32
|
+
'0.2.0-rc.2',
|
|
33
|
+
'0.2.1-rc.1',
|
|
34
|
+
'0.2.1-rc.2',
|
|
35
|
+
'0.2.1-rc.3',
|
|
36
|
+
'0.2.1-rc.4',
|
|
37
|
+
'0.2.1-rc.5',
|
|
38
|
+
// 0.2.2 line
|
|
39
|
+
'0.2.2-rc.1',
|
|
40
|
+
]
|
|
41
|
+
|
|
42
|
+
/**
|
|
43
|
+
* 唯一宿主声明串(2026-11-14 形状统一):engines.dsh 两处写点与全部 dsh-* peer 共用;
|
|
44
|
+
* 下限=HOSTS 起点,上限 `<0.3.0-0`(`-0` 堵住 0.3.0-rc.* 泄漏)。
|
|
45
|
+
*/
|
|
46
|
+
export const ENGINES_RANGE = `>=${HOSTS[0]} <0.3.0-0`
|
|
47
|
+
|
|
48
|
+
/** 每个宿主线的兼容判定。 */
|
|
49
|
+
export const STATUS = 'compatible'
|
|
50
|
+
|
|
51
|
+
/** npm 语法的逐串 or-range:`0.1.0-rc.2 || 0.1.0-rc.3 || ...`(仅作展示/证据)。 */
|
|
52
|
+
export function orRange(hosts = HOSTS) {
|
|
53
|
+
return hosts.join(' || ')
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
/** peer 下发用串:与 engines.dsh 同串(2026-11-14 起不再下发枚举)。 */
|
|
57
|
+
export const PEER_RANGE = ENGINES_RANGE
|
package/scripts/sync-hosts.mjs
CHANGED
|
@@ -1,80 +1,80 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* dsh-cookie-cleaner — 双清单同步 / 校验。
|
|
3
|
-
*
|
|
4
|
-
* node scripts/sync-hosts.mjs 写入(幂等)
|
|
5
|
-
* node scripts/sync-hosts.mjs --check 只校验,不一致即 exit 1(prepack 门禁)
|
|
6
|
-
*/
|
|
7
|
-
import fs from 'node:fs'
|
|
8
|
-
import path from 'node:path'
|
|
9
|
-
import { fileURLToPath } from 'node:url'
|
|
10
|
-
import { HOSTS, STATUS, ENGINES_RANGE, PEER_RANGE } from './hosts.mjs'
|
|
11
|
-
|
|
12
|
-
const ROOT = path.resolve(path.dirname(fileURLToPath(import.meta.url)), '..')
|
|
13
|
-
const check = process.argv.includes('--check')
|
|
14
|
-
const range = PEER_RANGE
|
|
15
|
-
const releases = Object.fromEntries(HOSTS.map((host) => [host, STATUS]))
|
|
16
|
-
const failures = []
|
|
17
|
-
|
|
18
|
-
const pkgPath = path.join(ROOT, 'package.json')
|
|
19
|
-
const manifestPath = path.join(ROOT, 'dsh.plugin.json')
|
|
20
|
-
const pkg = JSON.parse(fs.readFileSync(pkgPath, 'utf8'))
|
|
21
|
-
const manifest = JSON.parse(fs.readFileSync(manifestPath, 'utf8'))
|
|
22
|
-
|
|
23
|
-
/**
|
|
24
|
-
* client 半声明的包必须逐个有 optional peer 背书(包核验器 V3)。
|
|
25
|
-
* 单一真源就取 `dsh.client.inject`:inject 列表与 peer 清单同源于 hosts.mjs 的 range,
|
|
26
|
-
* 手写两处必然漂移;也没必要再给没引用的包占 peer(所以 renderer 自动退场)。
|
|
27
|
-
*/
|
|
28
|
-
const clientPeers = [...new Set((pkg.dsh?.client?.inject ?? []).filter((name) => typeof name === 'string' && name !== pkg.name))]
|
|
29
|
-
|
|
30
|
-
function compare(label, actual, expected) {
|
|
31
|
-
if (actual === expected) return
|
|
32
|
-
if (JSON.stringify(actual) === JSON.stringify(expected)) return
|
|
33
|
-
failures.push(`${label}: 与 scripts/hosts.mjs 不一致\n 期望 ${JSON.stringify(expected)}\n 实际 ${JSON.stringify(actual)}`)
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
compare('package.json#engines.dsh', pkg.engines?.dsh, ENGINES_RANGE)
|
|
37
|
-
compare('package.json#dsh.compatibility.dshReleases', pkg.dsh?.compatibility?.dshReleases, releases)
|
|
38
|
-
compare('dsh.plugin.json#engines.dsh', manifest.engines?.dsh, ENGINES_RANGE)
|
|
39
|
-
compare('dsh.plugin.json#version', manifest.version, pkg.version)
|
|
40
|
-
// 兼容性闸门只读 @deepseek-ai/dsh* 前缀的 peer range(不读 engines.dsh),
|
|
41
|
-
// 一个都不能漏:少了宿主换代时不会拒载,而是装载后运行期报错。
|
|
42
|
-
for (const name of clientPeers) {
|
|
43
|
-
compare(`package.json#peerDependencies[${name}]`, pkg.peerDependencies?.[name], range)
|
|
44
|
-
if (pkg.peerDependenciesMeta?.[name]?.optional !== true) {
|
|
45
|
-
failures.push(`package.json#peerDependenciesMeta[${name}].optional 应为 true(宿主提供,不是 npm 安装物)`)
|
|
46
|
-
}
|
|
47
|
-
}
|
|
48
|
-
if (!Object.keys(pkg.peerDependencies ?? {}).some((name) => name.startsWith('@deepseek-ai/dsh'))) {
|
|
49
|
-
failures.push('package.json#peerDependencies 缺 @deepseek-ai/dsh* 项:兼容性闸门将永远判兼容(假绿)')
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
if (check) {
|
|
53
|
-
if (failures.length > 0) {
|
|
54
|
-
process.stderr.write('双清单校验失败:\n' + failures.map((f) => ' - ' + f).join('\n') + '\n运行 `node scripts/sync-hosts.mjs` 修复。\n')
|
|
55
|
-
process.exitCode = 1
|
|
56
|
-
} else {
|
|
57
|
-
process.stdout.write(`双清单一致(${HOSTS.length} 条宿主线)\n`)
|
|
58
|
-
}
|
|
59
|
-
} else if (failures.length > 0) {
|
|
60
|
-
// 版本号以 package.json 为源,把同号刷进 dsh.plugin.json(不然改版本必遗漏一处,V1 闸抓不到)
|
|
61
|
-
pkg.engines = { ...pkg.engines, dsh: ENGINES_RANGE }
|
|
62
|
-
pkg.dsh = { ...pkg.dsh, compatibility: { ...pkg.dsh?.compatibility, dshReleases: releases } }
|
|
63
|
-
// peer 表重建:保留非 dsh-scope 的 peer(如 cordis),dsh* 项一律等于 client.inject 集合与同一 range
|
|
64
|
-
const kept = Object.fromEntries(Object.entries(pkg.peerDependencies ?? {}).filter(([name]) => !name.startsWith('@deepseek-ai/dsh')))
|
|
65
|
-
for (const name of clientPeers) kept[name] = range
|
|
66
|
-
pkg.peerDependencies = kept
|
|
67
|
-
const meta = Object.fromEntries(Object.entries(pkg.peerDependenciesMeta ?? {}).filter(([name]) => !name.startsWith('@deepseek-ai/dsh')))
|
|
68
|
-
for (const name of clientPeers) meta[name] = { ...meta[name], optional: true }
|
|
69
|
-
pkg.peerDependenciesMeta = meta
|
|
70
|
-
manifest.engines = { ...manifest.engines, dsh: ENGINES_RANGE }
|
|
71
|
-
if (manifest.version !== pkg.version) {
|
|
72
|
-
manifest.version = pkg.version
|
|
73
|
-
process.stdout.write(`dsh.plugin.json#version 同步为 ${pkg.version}\n`)
|
|
74
|
-
}
|
|
75
|
-
fs.writeFileSync(pkgPath, JSON.stringify(pkg, null, 2) + '\n', 'utf8')
|
|
76
|
-
fs.writeFileSync(manifestPath, JSON.stringify(manifest, null, 2) + '\n', 'utf8')
|
|
77
|
-
process.stdout.write(`已同步 ${HOSTS.length} 条宿主线到 package.json / dsh.plugin.json\n`)
|
|
78
|
-
} else {
|
|
79
|
-
process.stdout.write(`已是最新(${HOSTS.length} 条宿主线)\n`)
|
|
80
|
-
}
|
|
1
|
+
/**
|
|
2
|
+
* dsh-cookie-cleaner — 双清单同步 / 校验。
|
|
3
|
+
*
|
|
4
|
+
* node scripts/sync-hosts.mjs 写入(幂等)
|
|
5
|
+
* node scripts/sync-hosts.mjs --check 只校验,不一致即 exit 1(prepack 门禁)
|
|
6
|
+
*/
|
|
7
|
+
import fs from 'node:fs'
|
|
8
|
+
import path from 'node:path'
|
|
9
|
+
import { fileURLToPath } from 'node:url'
|
|
10
|
+
import { HOSTS, STATUS, ENGINES_RANGE, PEER_RANGE } from './hosts.mjs'
|
|
11
|
+
|
|
12
|
+
const ROOT = path.resolve(path.dirname(fileURLToPath(import.meta.url)), '..')
|
|
13
|
+
const check = process.argv.includes('--check')
|
|
14
|
+
const range = PEER_RANGE
|
|
15
|
+
const releases = Object.fromEntries(HOSTS.map((host) => [host, STATUS]))
|
|
16
|
+
const failures = []
|
|
17
|
+
|
|
18
|
+
const pkgPath = path.join(ROOT, 'package.json')
|
|
19
|
+
const manifestPath = path.join(ROOT, 'dsh.plugin.json')
|
|
20
|
+
const pkg = JSON.parse(fs.readFileSync(pkgPath, 'utf8'))
|
|
21
|
+
const manifest = JSON.parse(fs.readFileSync(manifestPath, 'utf8'))
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* client 半声明的包必须逐个有 optional peer 背书(包核验器 V3)。
|
|
25
|
+
* 单一真源就取 `dsh.client.inject`:inject 列表与 peer 清单同源于 hosts.mjs 的 range,
|
|
26
|
+
* 手写两处必然漂移;也没必要再给没引用的包占 peer(所以 renderer 自动退场)。
|
|
27
|
+
*/
|
|
28
|
+
const clientPeers = [...new Set((pkg.dsh?.client?.inject ?? []).filter((name) => typeof name === 'string' && name !== pkg.name))]
|
|
29
|
+
|
|
30
|
+
function compare(label, actual, expected) {
|
|
31
|
+
if (actual === expected) return
|
|
32
|
+
if (JSON.stringify(actual) === JSON.stringify(expected)) return
|
|
33
|
+
failures.push(`${label}: 与 scripts/hosts.mjs 不一致\n 期望 ${JSON.stringify(expected)}\n 实际 ${JSON.stringify(actual)}`)
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
compare('package.json#engines.dsh', pkg.engines?.dsh, ENGINES_RANGE)
|
|
37
|
+
compare('package.json#dsh.compatibility.dshReleases', pkg.dsh?.compatibility?.dshReleases, releases)
|
|
38
|
+
compare('dsh.plugin.json#engines.dsh', manifest.engines?.dsh, ENGINES_RANGE)
|
|
39
|
+
compare('dsh.plugin.json#version', manifest.version, pkg.version)
|
|
40
|
+
// 兼容性闸门只读 @deepseek-ai/dsh* 前缀的 peer range(不读 engines.dsh),
|
|
41
|
+
// 一个都不能漏:少了宿主换代时不会拒载,而是装载后运行期报错。
|
|
42
|
+
for (const name of clientPeers) {
|
|
43
|
+
compare(`package.json#peerDependencies[${name}]`, pkg.peerDependencies?.[name], range)
|
|
44
|
+
if (pkg.peerDependenciesMeta?.[name]?.optional !== true) {
|
|
45
|
+
failures.push(`package.json#peerDependenciesMeta[${name}].optional 应为 true(宿主提供,不是 npm 安装物)`)
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
if (!Object.keys(pkg.peerDependencies ?? {}).some((name) => name.startsWith('@deepseek-ai/dsh'))) {
|
|
49
|
+
failures.push('package.json#peerDependencies 缺 @deepseek-ai/dsh* 项:兼容性闸门将永远判兼容(假绿)')
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
if (check) {
|
|
53
|
+
if (failures.length > 0) {
|
|
54
|
+
process.stderr.write('双清单校验失败:\n' + failures.map((f) => ' - ' + f).join('\n') + '\n运行 `node scripts/sync-hosts.mjs` 修复。\n')
|
|
55
|
+
process.exitCode = 1
|
|
56
|
+
} else {
|
|
57
|
+
process.stdout.write(`双清单一致(${HOSTS.length} 条宿主线)\n`)
|
|
58
|
+
}
|
|
59
|
+
} else if (failures.length > 0) {
|
|
60
|
+
// 版本号以 package.json 为源,把同号刷进 dsh.plugin.json(不然改版本必遗漏一处,V1 闸抓不到)
|
|
61
|
+
pkg.engines = { ...pkg.engines, dsh: ENGINES_RANGE }
|
|
62
|
+
pkg.dsh = { ...pkg.dsh, compatibility: { ...pkg.dsh?.compatibility, dshReleases: releases } }
|
|
63
|
+
// peer 表重建:保留非 dsh-scope 的 peer(如 cordis),dsh* 项一律等于 client.inject 集合与同一 range
|
|
64
|
+
const kept = Object.fromEntries(Object.entries(pkg.peerDependencies ?? {}).filter(([name]) => !name.startsWith('@deepseek-ai/dsh')))
|
|
65
|
+
for (const name of clientPeers) kept[name] = range
|
|
66
|
+
pkg.peerDependencies = kept
|
|
67
|
+
const meta = Object.fromEntries(Object.entries(pkg.peerDependenciesMeta ?? {}).filter(([name]) => !name.startsWith('@deepseek-ai/dsh')))
|
|
68
|
+
for (const name of clientPeers) meta[name] = { ...meta[name], optional: true }
|
|
69
|
+
pkg.peerDependenciesMeta = meta
|
|
70
|
+
manifest.engines = { ...manifest.engines, dsh: ENGINES_RANGE }
|
|
71
|
+
if (manifest.version !== pkg.version) {
|
|
72
|
+
manifest.version = pkg.version
|
|
73
|
+
process.stdout.write(`dsh.plugin.json#version 同步为 ${pkg.version}\n`)
|
|
74
|
+
}
|
|
75
|
+
fs.writeFileSync(pkgPath, JSON.stringify(pkg, null, 2) + '\n', 'utf8')
|
|
76
|
+
fs.writeFileSync(manifestPath, JSON.stringify(manifest, null, 2) + '\n', 'utf8')
|
|
77
|
+
process.stdout.write(`已同步 ${HOSTS.length} 条宿主线到 package.json / dsh.plugin.json\n`)
|
|
78
|
+
} else {
|
|
79
|
+
process.stdout.write(`已是最新(${HOSTS.length} 条宿主线)\n`)
|
|
80
|
+
}
|