dsh-folia 4.23.21 → 4.23.24

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.
@@ -24,9 +24,7 @@ import { existsSync, mkdirSync, readFileSync, readdirSync, realpathSync, renameS
24
24
  import { homedir } from 'node:os';
25
25
  import { join } from 'node:path';
26
26
  // 皮肤包的下载走与壁纸同一条队列(Range 续传 / 去重 / 并发上限),落地后再解压。
27
- import { getDownloadQueue } from './downloads.js';
28
- // 4.23.17:**期望值(url/bytes/sha256)只有一个来源** —— `resolveMediaExpectation(item, chosen)`。
29
- import { resolveMediaExpectation } from '../variant-pick.js';
27
+ import { getDownloadQueue, registerManifestSource } from './downloads.js';
30
28
  // 版本自检与升级入口:把"内核够不够"一并带给界面(见 lib/routes/kernel.js)。
31
29
  import { kernelInfo } from './kernel.js';
32
30
  import { siteRequestHeaders } from '../site-auth.js';
@@ -312,6 +310,18 @@ async function fetchSkinCenterCatalog(hostHeader, force) {
312
310
  const siteCache = { at: 0, items: [], error: null };
313
311
  const SITE_TTL_MS = 30000;
314
312
 
313
+ // 4.23.22:队列校验时现问**当前皮肤清单**(不再把入队那天的 sha 存在 job 上)。
314
+ // 皮肤条目带 bytes/sha256;`refresh` 强制绕过 30s 缓存(hash-mismatch 后的闭环)。
315
+ registerManifestSource('skin', {
316
+ snapshot: () => (siteCache.items.length ? { items: siteCache.items, base: siteBase() || '', at: siteCache.at } : null),
317
+ refresh: async () => {
318
+ const fresh = await fetchSiteSkins(true);
319
+ return fresh && fresh.items && fresh.items.length
320
+ ? { items: fresh.items, base: siteBase() || '', at: Date.now() }
321
+ : null;
322
+ },
323
+ });
324
+
315
325
  /**
316
326
  * 给"本机已装"逐条附上**皮肤中心是否收录**。
317
327
  *
@@ -798,21 +808,10 @@ export function registerSkinsRoutes(webServer, c) {
798
808
  // **high**:用户主动点了「安装」。同一 kind 内它排在后台预取(low)前面;
799
809
  // 又因为皮肤有自己的并发槽(见 lib/download-queue.js 的 KIND_LIMITS),
800
810
  // 它不会再被"正在播放的壁纸预取"占满槽而卡在「安装中…」。
801
- // 4.23.7:内容哈希优先取请求里带的,其次按 URL 去**已缓存的**站点清单里对一条
802
- // (**可能没有**)。⚠️ 这里只读 `siteCache` 的现状、**不**调 `fetchSiteSkins()`
803
- // 触发拉取:安装请求是同步等下载的(8 秒窗口),为了一条可选字段去等站点 20 秒超时
804
- // 会让"点安装没反应"重现。缓存是空的就不设防(前两层照样生效)。
805
- const wantSha = String((body && body.sha256) || '').trim()
806
- || (() => {
807
- try {
808
- const hit = (siteCache.items || []).find((x) => x.url === url.toString() || x.id === hinted);
809
- return hit && hit.sha256 ? String(hit.sha256) : '';
810
- } catch { return ''; }
811
- })();
812
- const exp = resolveMediaExpectation({ url: url.toString(), sha256: wantSha, bytes: 0 }, 'original');
811
+ // 4.23.22:入队只记 URL。sha/bytes **不在这里决定** —— 下载完成那一刻按
812
+ // registerManifestSource('skin') 的当前清单现问(站点换包后也不会拿旧 sha 误判)。
813
813
  const added = q.add({
814
- url: exp.url, dest: zipDest, kind: 'skin', priority: 'high',
815
- sha256: exp.sha256, expectBytes: exp.bytes, hashSource: exp.source,
814
+ url: url.toString(), dest: zipDest, kind: 'skin', priority: 'high',
816
815
  });
817
816
  const jobId = added && added.job ? added.job.id : null;
818
817
  // ⚠️ 4.23.4:**没有 jobId 就没有任何可识别状态** —— 客户端既轮询不到进度,
@@ -847,10 +846,7 @@ export function registerSkinsRoutes(webServer, c) {
847
846
  if (attempts < 1 && isTransient(state.error)) {
848
847
  attempts += 1;
849
848
  try {
850
- q.add({
851
- url: exp.url, dest: zipDest, kind: 'skin', priority: 'high',
852
- sha256: exp.sha256, expectBytes: exp.bytes, hashSource: exp.source,
853
- });
849
+ q.add({ url: url.toString(), dest: zipDest, kind: 'skin', priority: 'high' });
854
850
  } catch { /* ignore */ }
855
851
  await new Promise((resolve) => { setTimeout(resolve, 800); });
856
852
  continue;
@@ -37,12 +37,13 @@ export const SETTINGS_OWNERS = [
37
37
  {
38
38
  id: 'playback',
39
39
  name: '播放',
40
- why: '播放与轮换的时序:轮换间隔/过场、倍速、帧率上限、声音、暂停策略。',
41
- files: ['src/client-rotation.js', 'src/client-audio-playback.js', 'src/panel-tabs-advanced.js'],
40
+ why: '播放与轮换的时序:轮换间隔/过场、倍速、帧率上限、声音、暂停策略、站点壁纸的下载/播放策略。',
41
+ files: ['src/client-rotation.js', 'src/client-audio-playback.js', 'src/panel-tabs-advanced.js',
42
+ 'src/panel-tabs-effects.js', 'src/download-first.js'],
42
43
  keys: [
43
44
  'rotationEnabled', 'rotationInterval', 'rotationGroupId', 'rotationGroups', 'rotationSeeded',
44
45
  'switchTransition', 'switchTransitionDir', 'switchTransitionSpeed',
45
- 'playbackRate', 'fpsCap', 'videoVolume', 'videoAudioEnabled',
46
+ 'playbackRate', 'playbackPolicy', 'fpsCap', 'videoVolume', 'videoAudioEnabled',
46
47
  'pauseOnHidden', 'pauseOnBlur', 'pauseOnBattery', 'liveBootDelay',
47
48
  ],
48
49
  },
@@ -170,6 +170,15 @@ const SWITCH_SPEED_VALUES = ['fast', 'normal', 'slow'];
170
170
  // 适配目标(见 DEFAULTS.adapterTarget 的语义注释):auto = 自动检测,
171
171
  // 其余三个是手选覆盖,与宿主按请求观测出来的三档同名同字面量。
172
172
  const ADAPTER_TARGET_VALUES = ['auto', 'browser', 'desktop-community', 'desktop-official'];
173
+ /**
174
+ * 站点壁纸的播放策略(4.23.23):
175
+ * · `download-first`(默认):点未缓存的壁纸 ⇒ **先整份下到本地并校验通过,再从本地文件播**。
176
+ * 首帧要等一次下载,但播放全程不走 CDN 流(省流量、可续传、之后秒开)。
177
+ * · `stream-first`(旧行为,保留给回滚 / 愿意秒开的人):点击即用站点代理边下边播,
178
+ * 下载在后台继续,下完后再切到本地副本。
179
+ * 判据:test/verify-download-first.mjs(默认值 / 面板两档 / 不播站点流 / stream-first 回滚)。
180
+ */
181
+ const PLAYBACK_POLICY_VALUES = ['download-first', 'stream-first'];
173
182
  // 点击效果与拖尾效果(「扩展」页签的第二个模块):
174
183
  // 点击样式 —— ripple = 从落点扩散的圆环;spark = 向四周飞散的亮点;both = 两者一起。
175
184
  const FX_CLICK_STYLE_VALUES = ['ripple', 'spark', 'both'];
@@ -525,6 +534,9 @@ const DEFAULTS = {
525
534
  hiddenIds: [],
526
535
  // Video playback speed (0.5x–2x, applied via native playbackRate).
527
536
  playbackRate: 1,
537
+ // 站点壁纸播放策略(4.23.23):默认 `download-first` = 先完整下载 + 校验,再播本地文件;
538
+ // `stream-first` = 旧行为(CDN 边下边播)。切走时正在缓存的那条只降优先级、**不取消**。
539
+ playbackPolicy: "download-first",
528
540
  // 解码帧率上限(fps;0 = 无限制):对源帧率高于上限的视频壁纸,host 一次性
529
541
  // ffmpeg 重编码为上限帧率的"抽帧版"(4K120→4K60,时间线保持 1.0x 正常速度,
530
542
  // 解码占用随帧率线性下降)。与倍速完全解耦 —— 倍速照常叠加在抽帧版上。
@@ -1024,6 +1036,7 @@ const KINDS = {
1024
1036
  rotationSeeded: { kind: 'boolFalse' },
1025
1037
  hiddenIds: { kind: 'strArray' },
1026
1038
  playbackRate: { kind: 'num', min: 0.5, max: 2 },
1039
+ playbackPolicy: { kind: 'enum', values: PLAYBACK_POLICY_VALUES },
1027
1040
  videoVolume: { kind: 'num', min: 0, max: 1 },
1028
1041
  videoAudioEnabled: { kind: 'boolTrue' },
1029
1042
  fpsCap: { kind: 'enum', values: FPS_CAP_VALUES },
@@ -1323,7 +1336,7 @@ const RESET_TABS = {
1323
1336
  'scrim', 'wallpaperBlur', 'wallpaperOpacity',
1324
1337
  'backgroundBrightness', 'backgroundContrast', 'backgroundSaturate',
1325
1338
  'flip', 'objectFit', 'layerPositionX', 'layerPositionY', 'layerScale',
1326
- 'playbackRate', 'fpsCap', 'sceneLive', 'sceneLiveFps', 'liveBootDelay',
1339
+ 'playbackRate', 'playbackPolicy', 'fpsCap', 'sceneLive', 'sceneLiveFps', 'liveBootDelay',
1327
1340
  'videoVolume', 'videoAudioEnabled', 'audioSource',
1328
1341
  'mediaIntegration', 'mediaLyricsOnline',
1329
1342
  ],
@@ -1927,7 +1940,7 @@ const SETTINGS_NAMESPACES = {
1927
1940
  // 壁纸选择 + 播放 + 层位置(含 5 个"跨簇共用但唯一归属"的键:layerPositionX/Y/Scale、userProps、noticeSeen)
1928
1941
  core: [
1929
1942
  'id', 'hiddenIds', 'rotationEnabled', 'rotationGroupId', 'rotationGroups', 'rotationSeeded',
1930
- 'playbackRate', 'videoVolume', 'videoAudioEnabled', 'fpsCap', 'sceneLive', 'sceneLiveFps',
1943
+ 'playbackRate', 'playbackPolicy', 'videoVolume', 'videoAudioEnabled', 'fpsCap', 'sceneLive', 'sceneLiveFps',
1931
1944
  'liveBootDelay', 'sceneLiveFailures', 'pauseOnHidden', 'pauseOnBlur', 'pauseOnBattery',
1932
1945
  'flip', 'objectFit', 'contentRatingFilter', 'typeFilter', 'sourceFilter', 'pickerLayout', 'edgeCompat',
1933
1946
  'userProps', 'noticeSeen', 'layerPositionX', 'layerPositionY', 'layerScale',
@@ -2019,7 +2032,7 @@ export {
2019
2032
  // 导出(test/verify-settings-schema-exports.mjs 硬档)。
2020
2033
  sanitizeExtraGlassSelectors,
2021
2034
  systemFontNameOf, sanitizeFamilyKey, sanitizeFamilyValue,
2022
- FPS_CAP_VALUES, SCENE_LIVE_FPS_VALUES,
2035
+ FPS_CAP_VALUES, SCENE_LIVE_FPS_VALUES, PLAYBACK_POLICY_VALUES,
2023
2036
  SWITCH_TRANSITION_VALUES, SWITCH_DIRS, SWITCH_SPEED_VALUES,
2024
2037
  ROTATION_INTERVAL_MIN, ROTATION_INTERVAL_MAX,
2025
2038
  AVATAR_AI_REPEAT_MIN, AVATAR_AI_REPEAT_MAX,
@@ -460,14 +460,15 @@ export function resolveMediaExpectation(item, chosen) {
460
460
  }
461
461
 
462
462
  /**
463
- * **升级迁移**(4.23.18):清单条目 → 某条 job 的正确期望值(纯函数)。
463
+ * **当前清单 → 某条 URL 的期望值**(4.23.22 的唯一校验输入;纯函数)。
464
464
  *
465
- * 判据只有一条:job.url 必须**逐字**出现在清单里(原画 `media`/`url` 或某一档
466
- * `variants[].url`)。命中变体 ⇒ 期望值取**该变体自己的** sha256/bytes(`source='variant'`);
467
- * 命中原画 ⇒ 取原画的;找不到 ⇒ null(跳过;绝不拿"同一条壁纸"的原画哈希去套变体)。
465
+ * 判据只有一条:URL 必须**逐字**出现在清单里(原画 `media`/`url` 或某一档
466
+ * `variants[].url`)。命中变体 ⇒ 取**该变体自己的** sha256/bytes(`source='variant'`);
467
+ * 命中原画 ⇒ 取原画的;找不到 ⇒ null(退化为长度 + 结构校验;绝不拿原画哈希去套变体)。
468
468
  *
469
- * 本文件是期望值的唯一真相源,迁移也住这里;`lib/download-queue.js` 只通过注入的
470
- * `migrateExpectation` 回调消费它(队列不认识站点清单)。
469
+ * 4.23.22 起它**不再用于迁移**(没有迁移了):`lib/routes/downloads.js` 把它包成
470
+ * `resolveExpectation(job)` / `refreshExpectation(job)` 注入队列,校验发生在**下载完成那一刻**。
471
+ * 入队不再写 sha,job 上也不再有"期望值"可复用 —— 这是 4.23.21 hash-mismatch 的根因修复。
471
472
  *
472
473
  * @param {{ url?: string }} job
473
474
  * @param {any[]} items 站点清单(inventory 形状或原始 API 形状都吃)
@@ -487,21 +488,24 @@ export function resolveJobExpectationFromItems(job, items, base) {
487
488
  const origRaw = String(it.media || it.url || '');
488
489
  const originalUrl = /^https?:\/\//i.test(origRaw) ? origRaw : abs(origRaw);
489
490
  if (originalUrl === url) {
490
- return {
491
- url,
492
- sha256: normalizeSha(it.sha256 || it.manifestSha256),
493
- bytes: Number(it.bytes) || 0,
494
- source: 'original',
495
- };
491
+ // 原画档:仍然走唯一真相源(它同时守住 bytes/source 的口径)。
492
+ const exp = resolveMediaExpectation({
493
+ url: originalUrl, bytes: Number(it.bytes) || 0, sha256: it.sha256 || it.manifestSha256,
494
+ }, 'original');
495
+ return { url, sha256: exp.sha256, bytes: exp.bytes, source: exp.source };
496
496
  }
497
497
  for (const v of normalizeVariants(it.variants, base)) {
498
498
  if (v.url !== url) continue;
499
- return {
500
- url,
501
- sha256: normalizeSha(v.sha256),
502
- bytes: Number(v.bytes) || 0,
503
- source: 'variant',
504
- };
499
+ // 变体档:按**这个 URL** 命中那一档,结论同样由唯一真相源产出。
500
+ const exp = resolveMediaExpectation({
501
+ url: originalUrl,
502
+ bytes: Number(it.bytes) || 0,
503
+ sha256: it.sha256 || it.manifestSha256,
504
+ variants: it.variants,
505
+ base,
506
+ chosenUrl: url,
507
+ }, '1080p');
508
+ return { url, sha256: exp.sha256, bytes: exp.bytes, source: exp.source };
505
509
  }
506
510
  }
507
511
  return null;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dsh-folia",
3
- "version": "4.23.21",
3
+ "version": "4.23.24",
4
4
  "description": "Folia 壁纸引擎:把本机 Wallpaper Engine 壁纸搬进 DSH 界面(场景实时渲染 / 视频 / 网页),内置液态玻璃与 Folia 吉祥物,并可从自建站点拉取壁纸。单包形态(组件已合并)。",
5
5
  "type": "module",
6
6
  "engines": {
@@ -181,6 +181,33 @@
181
181
  }
182
182
  },
183
183
  "license": "MIT",
184
+ "scripts": {
185
+ "build": "node scripts/build-client.mjs",
186
+ "install:source": "node scripts/install-source.mjs",
187
+ "install:release": "node scripts/install-release.mjs",
188
+ "pack:release": "node scripts/pack-release.mjs",
189
+ "verify:deployment": "node test/verify-deployment.mjs",
190
+ "verify:pet-link": "node test/verify-pet-link.mjs",
191
+ "verify:pet-link:integration": "node test/verify-pet-hotplug-integration.mjs",
192
+ "verify:pet-link:browser": "node test/verify-pet-tuner-browser.mjs",
193
+ "verify": "node test/run-guards.mjs verify",
194
+ "verify:docs": "node test/run-guards.mjs docs",
195
+ "verify:bridge": "node test/verify-bridge-ci.mjs --provision",
196
+ "verify:bridge:strict": "node test/verify-media-bridge.mjs --provision",
197
+ "verify:e2e": "node test/e2e-web-media-origin.mjs",
198
+ "lint": "eslint .",
199
+ "typecheck": "tsc --noEmit -p tsconfig.json",
200
+ "verify:static": "node test/verify-static.mjs",
201
+ "smoke": "node test/run-guards.mjs smoke",
202
+ "verify:all": "node test/run-guards.mjs all",
203
+ "prepack": "node scripts/prepare.mjs",
204
+ "test:boot": "node test/boot-http.mjs",
205
+ "test:pets": "node test/pets-http.mjs",
206
+ "test:pets-layer": "node test/pets-layer.mjs",
207
+ "test:features": "node test/verify-features.mjs",
208
+ "audit": "node test/run-audit.mjs",
209
+ "gate": "node scripts/build-client.mjs && node test/run-guards.mjs smoke && node test/verify-features.mjs && node test/verify-route-registry.mjs && node test/verify-settings-ownership.mjs && node test/boot-http.mjs && node test/pets-http.mjs && node test/pets-layer.mjs"
210
+ },
184
211
  "peerDependencies": {
185
212
  "@deepseek-ai/cordis": "^4.0.4",
186
213
  "@deepseek-ai/dsh-client-runtime": ">=0.1.5-rc.1",
@@ -213,31 +240,5 @@
213
240
  "@types/node": "^26.6.5",
214
241
  "eslint": "^10.12.0",
215
242
  "typescript": "^7.0.2"
216
- },
217
- "scripts": {
218
- "build": "node scripts/build-client.mjs",
219
- "install:source": "node scripts/install-source.mjs",
220
- "install:release": "node scripts/install-release.mjs",
221
- "pack:release": "node scripts/pack-release.mjs",
222
- "verify:deployment": "node test/verify-deployment.mjs",
223
- "verify:pet-link": "node test/verify-pet-link.mjs",
224
- "verify:pet-link:integration": "node test/verify-pet-hotplug-integration.mjs",
225
- "verify:pet-link:browser": "node test/verify-pet-tuner-browser.mjs",
226
- "verify": "node test/run-guards.mjs verify",
227
- "verify:docs": "node test/run-guards.mjs docs",
228
- "verify:bridge": "node test/verify-bridge-ci.mjs --provision",
229
- "verify:bridge:strict": "node test/verify-media-bridge.mjs --provision",
230
- "verify:e2e": "node test/e2e-web-media-origin.mjs",
231
- "lint": "eslint .",
232
- "typecheck": "tsc --noEmit -p tsconfig.json",
233
- "verify:static": "node test/verify-static.mjs",
234
- "smoke": "node test/run-guards.mjs smoke",
235
- "verify:all": "node test/run-guards.mjs all",
236
- "test:boot": "node test/boot-http.mjs",
237
- "test:pets": "node test/pets-http.mjs",
238
- "test:pets-layer": "node test/pets-layer.mjs",
239
- "test:features": "node test/verify-features.mjs",
240
- "audit": "node test/run-audit.mjs",
241
- "gate": "node scripts/build-client.mjs && node test/run-guards.mjs smoke && node test/verify-features.mjs && node test/verify-route-registry.mjs && node test/verify-settings-ownership.mjs && node test/boot-http.mjs && node test/pets-http.mjs && node test/pets-layer.mjs"
242
243
  }
243
- }
244
+ }