dsh-plugin-wallpaper-engine-fonts 1.4.0 → 1.4.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.
@@ -5,11 +5,11 @@ window.__ModuleLoader__.load({
5
5
  var exports = module.exports;
6
6
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
7
7
  const host = require("dsh-plugin-wallpaper-engine");
8
- // ── 内联模块:packages/fonts/src/appearance-font-section.js —— 外观页签第六节「全局字体」的渲染器(原 src/panel-tabs-appearance.js:54-420,逐字搬来);入口的 registerPanelSection 把它的 render 登记进面板节注册表(构建期注入;勿手改本段)──
8
+ // ── 内联模块:packages/fonts/src/appearance-font-section.js —— 外观页签第六节「全局字体」的渲染器(ADR-0013/ADR-0014 子包出户);入口的 registerPanelSection 把它的 render 登记进面板节注册表(构建期注入;勿手改本段)──
9
9
  /**
10
10
  * appearance-font-section.js — 外观页签第六节「全局字体」的渲染器(P-C 搬出)。
11
11
  *
12
- * 原来住在 src/panel-tabs-appearance.js 的 54-420 行,**函数体逐字未改**,只是换了住处。
12
+ * 从 src/panel-tabs-appearance.js 按域拆出(ADR-0013/ADR-0014 子包出户);渲染逻辑与主包版本同源。
13
13
  *
14
14
  * 跨包形状(契约 §2.1 / §2.2):
15
15
  * · 本文件**只画界面**:稳定零件(React / weT / switchRow / ctlText / sectionHead /
@@ -392,10 +392,10 @@ window.__ModuleLoader__.load({
392
392
  }
393
393
 
394
394
  // 独立文件形态下必须有导出:本文件被内联进产物时这一行会被构建器剥掉
395
- // (scripts/build-client.mjs 的 EXPORT_BLOCK,同 packages/fonts/src/fontset-editor.js:205 的先例),
395
+ // (scripts/build-client.mjs 的 EXPORT_BLOCK,同 fontset-editor.js 的导出块先例),
396
396
  // 但渲染挂载台(test/verify-scene-live.mjs 等)是**按文件 import** 的,没有它就取不到渲染器。
397
397
 
398
- // ── 内联模块:packages/fonts/src/fontset-editor.js —— 「字体集」编辑器面板(原 src/fontset-editor.js,整文件逐字搬来):纯渲染 + 意图回调,由字体节的 renderFontSet(fontSet) 调用(构建期注入;勿手改本段)──
398
+ // ── 内联模块:packages/fonts/src/fontset-editor.js —— 「字体集」编辑器面板(ADR-0013/ADR-0014 子包出户):纯渲染 + 意图回调,由字体节的 renderFontSet(fontSet) 调用(构建期注入;勿手改本段)──
399
399
  /**
400
400
  * fontset-editor.js — 「字体集」编辑器面板:**纯渲染 + 意图回调**。
401
401
  *
@@ -560,7 +560,7 @@ window.__ModuleLoader__.load({
560
560
  ctlText(weT("字体集"), weT("一份集 = 整套字体外观(颜色角色 / 排版 / 字重 / 字族 / 组件)。改动只落到当前这一份、随时可以恢复原样;导入导出按整份文件走。")),
561
561
  ),
562
562
  loading ? React.createElement("div", { className: "we-picker__hint" }, weT("正在读取字体集…")) : null,
563
- // ⚠️ reason 必须再过一次 weT:它来自宿主回包(lib/routes/fontsets.js 里那批中文 error),
563
+ // ⚠️ reason 必须再过一次 weT:它来自宿主回包(packages/fonts/lib/routes/fontsets.js 里那批中文 error),
564
564
  // 原样塞进去会让英文界面露出中文,并让 i18n-copy.js 里为这些串备好的词条永远成为死词条。
565
565
  error ? React.createElement("div", { className: "we-picker__hint" }, weT("字体集不可用:{reason}", { reason: weT(error) })) : null,
566
566
  rows.length === 0 && !loading
package/lib/index.js CHANGED
@@ -4,9 +4,9 @@
4
4
  * 落点 = 字体子包的**宿主半边**(ADR-0014 S3.4):
5
5
  * · 搬进来的:字体系统的**两条宿主路由族** —— `fontsets`(字体集 /fontsets)与
6
6
  * `system-fonts`(本机字体清单 /system-fonts),见 ./routes/*.js。
7
- * · P-C(2026-10-16)之后**浏览器半边也随包走**:入口 `src/client.js` + 外观页签第六节
8
- * 「全局字体」渲染器 `src/appearance-font-section.js` + 字体集编辑器 `src/fontset-editor.js`,
9
- * 产物 `lib/client.fonts.js` ⇒ 本包**声明** `dsh.client` 且清单里有 `exports['./client']`
7
+ * · P-C之后**浏览器半边也随包走**:入口 `src/client.js` + 外观页签第六节
8
+ * 「全局字体」渲染器 `packages/fonts/src/appearance-font-section.js` + 字体集编辑器 `packages/fonts/src/fontset-editor.js`,
9
+ * 产物 `packages/fonts/lib/client.fonts.js` ⇒ 本包**声明** `dsh.client` 且清单里有 `exports['./client']`
10
10
  * (ADR-0014 S3.4 的两向判据)。
11
11
  * · **仍然不搬**:`src/fontset-store.js`、`src/system-fonts.js`、`src/font/apply.js`、
12
12
  * `src/font/typography.js`、`src/font/color-roles.js`、`src/font/components.js`
@@ -60,10 +60,10 @@ export const inject = ['webServer', 'wallpaperEngineHost'];
60
60
  * 宿主半边入口。`ctx` 是 cordis 的插件上下文(`new apply(ctx)` 形态),`config` 来自 patch 行的 config
61
61
  * (本包今天不使用:路由路径/键名都是定死的,要求行为零回归)。
62
62
  *
63
- * @returns {() => void} 拆卸函数(同时已交 `ctx.effect`;mock ctx 无 effect 时退回返回值,见 host-boot.js:188-197)。
63
+ * @returns {() => void} 拆卸函数(同时已交 `ctx.effect`;mock ctx 无 effect 时退回返回值,见 `lib/host-boot.js` 的 `handOffTeardown`)。
64
64
  */
65
65
  export function apply(ctx, _config) {
66
- const webServer = ctx && ctx.webServer;
66
+ let webServer = ctx && ctx.webServer;
67
67
  // provider 缺席(主包没起 / 没有 webServer):与 about-notice 同口径 —— 静默退回空拆卸,
68
68
  // 不抛异常炸掉整行(行级失败静默)。
69
69
  if (!webServer || typeof webServer.register !== 'function') return () => {};
@@ -75,8 +75,10 @@ export function apply(ctx, _config) {
75
75
  // host.http,由下方传给两条路由的 register。
76
76
  const keys = host.keys('fonts', ctx);
77
77
  assertFontsKeys(host.keyNames('fonts'), keys);
78
+ // issue #267:注册面容错(原地升级撞 1.3.3 残留路由时不整条抛错)。
79
+ webServer = keys.tolerantWebServer(webServer);
78
80
 
79
- // 拆卸句柄数组:照主包 lib/kernel/host-session.js:190/:257 的口径(一个数组、插入顺序、
81
+ // 拆卸句柄数组:照主包 lib/kernel/host-session.js 的口径(一个数组、插入顺序、
80
82
  // 逐条兜错),两条路由族的 register 都往它 push。
81
83
  const disposers = [];
82
84
  // 两个调用点各自给**自己那一族**的键集:`...keys` 是冻结表(唯一真源),`disposers` 是共用
@@ -90,7 +92,7 @@ export function apply(ctx, _config) {
90
92
  disposers,
91
93
  schema: host.schema,
92
94
  http: host.http,
93
- // 落盘缓存路径与主包同式(本文件 :94;出户前 = 主包 lib/index.js:383):pluginDataDir()/system-fonts.json。
95
+ // 落盘缓存路径与主包同式(本文件的 `cachePath` 实参;出户前是主包门面的同名入参):pluginDataDir()/system-fonts.json。
94
96
  cachePath: () => join(keys.pluginDataDir(), 'system-fonts.json'),
95
97
  });
96
98
  } catch (error) {
@@ -119,7 +121,7 @@ function assertFontsKeys(required, keys) {
119
121
  }
120
122
 
121
123
  /**
122
- * 逐条兜错的拆卸:**插入顺序**、单条抛错不影响其余(与 lib/kernel/host-session.js:257 逐字同口径)。
124
+ * 逐条兜错的拆卸:**插入顺序**、单条抛错不影响其余(与 lib/kernel/host-session.js 的 teardown 逐字同口径)。
123
125
  * `splice(0)` 让重复调用成 no-op(teardown 可能被 ctx.effect + 调用方各跑一次)。
124
126
  */
125
127
  function disposeAll(disposers) {
@@ -229,7 +229,7 @@ export function registerFontsetsRoutes(webServer, c) {
229
229
  c.lingerClose(req, res);
230
230
  };
231
231
  c.armBodyIdleTimeout(req, () => fail(408, { error: 'request timeout' }));
232
- // 字节计上限 + 收完**一次性**解码(不变量见 lib/routes/upload.js 文件头):
232
+ // 字节计上限 + 收完**一次性**解码(不变量见 packages/media-bridge/lib/routes/upload.js 文件头):
233
233
  // 逐块 `body += chunk` 会把跨 TCP 分片的多字节码点切成 U+FFFD,而字体集名 / 字体族
234
234
  // 正是会被这样静默写坏的用户可见字符串。
235
235
  const reader = c.http.bodyReader(req, {
@@ -77,7 +77,7 @@ const SYSTEM_FONTS_TTL_MS = 7 * 24 * 60 * 60 * 1000;
77
77
  * 没有版本号时,用户升级插件后最长一周里拿到的还是**老口径**的结果 —— 表现就是"改了没生效",
78
78
  * 而且看不出是缓存。**改动枚举口径(来源、过滤、解码)时必须 +1。**
79
79
  */
80
- const SYSTEM_FONTS_CACHE_VERSION = 2;
80
+ const SYSTEM_FONTS_CACHE_VERSION = 3;
81
81
  /** 单个子进程的超时:macOS 实测 ~10s,25s 给慢机器留余量;超时即 kill 并降级。 */
82
82
  const FONT_SCAN_TIMEOUT_MS = 25000;
83
83
  /** 子进程输出上限(macOS 的 JSON 实测 ~2MB):够用,又不让一次异常输出吃光内存。 */
@@ -128,7 +128,12 @@ function authoritativeSources(platform) {
128
128
  source: 'powershell-fonts',
129
129
  cmd: 'powershell.exe',
130
130
  args: ['-NoProfile', '-NonInteractive', '-Command',
131
- 'Add-Type -AssemblyName System.Drawing; '
131
+ // 钉死写往 **stdout 的编码**(#300):PS 5.1 在 stdout 被重定向成管道时按**控制台输出编码**
132
+ // 写(中文系统是 OEM CP936),本侧却按 UTF-8 解码 ⇒ 每个中文字体名都成 U+FFFD。
133
+ // `[Console]::OutputEncoding` 必须在任何输出之前设;`$OutputEncoding` 只影响"喂给别的程序"的输入,
134
+ // 不解决这条。UTF8Encoding 不带 BOM,首行不会多出 U+FEFF(即便有,normalizeFamilies 的 trim 也会吃掉)。
135
+ '[Console]::OutputEncoding = [System.Text.Encoding]::UTF8; '
136
+ + 'Add-Type -AssemblyName System.Drawing; '
132
137
  + '(New-Object System.Drawing.Text.InstalledFontCollection).Families | ForEach-Object { $_.Name }'],
133
138
  parse: parseLineFamilies,
134
139
  }];
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "dsh-plugin-wallpaper-engine-fonts",
3
- "version": "1.4.0",
4
- "description": "Font system for the DSH wallpaper engine: the appearance tab's font section and the font-set editor (browser half, packages/fonts/lib/client.fonts.js) plus the host routes /fontsets and /system-fonts. Config keys and state stay in the main bundle (ADR-0013 D20); the only cross-package channel is the main bundle's explicit host bridge(浏览器半边契约见 ADR-0014 S3.8/S3.9 与 .integration-notes/p-c-contract.md).",
3
+ "version": "1.4.1",
4
+ "description": "Font system for the DSH wallpaper engine: the appearance tab's font section and the font-set editor (browser half, packages/fonts/lib/client.fonts.js) plus the host routes /fontsets and /system-fonts. Config keys and state stay in the main bundle (ADR-0013 D20); the only cross-package channel is the main bundle's explicit host bridge(浏览器半边契约见 ADR-0014 S3.8/S3.9).",
5
5
  "icon": "./icon.png",
6
6
  "type": "module",
7
7
  "main": "./lib/index.js",
@@ -17,7 +17,7 @@
17
17
  "patch": "./cordis.patch.yml"
18
18
  },
19
19
  "client": {
20
- "inject": ["@deepseek-ai/dsh-client-runtime"],
20
+ "inject": ["@deepseek-ai/dsh-client-runtime", "dsh-plugin-wallpaper-engine"],
21
21
  "platform": "web",
22
22
  "immediately": true
23
23
  }