beauticode-dsh 1.0.30 → 1.0.32

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.
Files changed (50) hide show
  1. package/LICENSE +21 -21
  2. package/README.zh-CN.md +13 -12
  3. package/agent.mjs +10 -1
  4. package/atmosphere.js +11 -1
  5. package/bin/beauticode-dsh +1 -1
  6. package/browser-injection.mjs +166 -31
  7. package/build-manifest.json +73 -0
  8. package/cli.js +263 -173
  9. package/client.js +6 -0
  10. package/console.js +533 -105
  11. package/control-client.mjs +1 -2
  12. package/gallery-host.mjs +95 -74
  13. package/gallery.js +78 -20
  14. package/host-apply.mjs +1 -3
  15. package/index.mjs +34 -4
  16. package/package.json +4 -2
  17. package/presets.mjs +2 -5
  18. package/profile-patch.mjs +182 -0
  19. package/readability.js +679 -73
  20. package/themes/internal-beyond/NOTICE.md +2 -2
  21. package/themes/internal-beyond/bg-canvas-4k.webp +0 -0
  22. package/transport.js +83 -83
  23. package/ui-host.mjs +29 -2
  24. package/vendor/adapter-dsh/bridge.js +6 -0
  25. package/vendor/adapter-dsh/index.js +1 -1
  26. package/vendor/adapter-dsh/session.js +15 -3
  27. package/vendor/core/apply-transaction.js +7 -0
  28. package/vendor/core/background-change.js +40 -0
  29. package/vendor/core/background-store.js +22 -0
  30. package/vendor/core/bundled-gallery.js +4 -6
  31. package/vendor/core/error-message.js +1 -11
  32. package/vendor/core/file-lock.js +20 -3
  33. package/vendor/core/gallery-operations.js +42 -0
  34. package/vendor/core/http-boundary.js +49 -0
  35. package/vendor/core/index.js +15 -1
  36. package/vendor/core/linux-process.js +119 -0
  37. package/vendor/core/media-health.js +38 -0
  38. package/vendor/core/paths.js +86 -0
  39. package/vendor/core/process-liveness.js +7 -8
  40. package/vendor/core/serial-task.js +10 -0
  41. package/vendor/core/skin-catalog.js +326 -0
  42. package/vendor/core/star-invitation-renderer.js +266 -0
  43. package/vendor/core/star-invitation.js +31 -0
  44. package/vendor/core/star-project-browser.js +25 -0
  45. package/vendor/core/star-project.js +3 -0
  46. package/vendor/core/startup-repair-chain.js +63 -0
  47. package/vendor/core/wallpaper-library.js +118 -0
  48. package/vendor/core/wallpaper-project.js +102 -0
  49. package/themes/internal-beyond/bg-canvas-4k.png +0 -0
  50. package/themes/internal-beyond/bg-canvas.png +0 -0
package/LICENSE CHANGED
@@ -1,21 +1,21 @@
1
- MIT License
2
-
3
- Copyright (c) 2026 beautiCode contributors
4
-
5
- Permission is hereby granted, free of charge, to any person obtaining a copy
6
- of this software and associated documentation files (the "Software"), to deal
7
- in the Software without restriction, including without limitation the rights
8
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
- copies of the Software, and to permit persons to whom the Software is
10
- furnished to do so, subject to the following conditions:
11
-
12
- The above copyright notice and this permission notice shall be included in all
13
- copies or substantial portions of the Software.
14
-
15
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
- SOFTWARE.
1
+ MIT License
2
+
3
+ Copyright (c) 2026 beautiCode contributors
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.zh-CN.md CHANGED
@@ -16,11 +16,21 @@ dsh plugin --profile desktop add beauticode-dsh
16
16
 
17
17
  重新打开 Desktop,在「设置」中使用「背景」。Desktop 默认 Host 端口是 `19387`;如果还使用 beautiCode 托盘,将托盘的 `-DshUrl` 指向 `http://127.0.0.1:19387`(若 Desktop profile 改过 `webserver.config.port`,请使用实际端口)。Desktop 插件由 Desktop 自己管理;下方的 `npx beauticode-dsh` 安装器针对 Web profile。
18
18
 
19
- 「设置 → 背景」默认开启「功能面板不透明」,保证设置、弹层、菜单与消息编辑栏遮住后方内容。关闭后恢复原有透明效果;选择会保存在当前应用的本地偏好中,不受背景阴影、会话阶段或画窗模式影响。
20
-
21
19
  ## Web
22
20
 
23
- 装好插件并运行 `dsh web` 后,打开「设置」,左侧导航里会多出一项「背景」:在 Windows 上点击图片或视频会打开系统文件选择器,选好后在页面内命名,背景立即应用并进入已保存主题;也可以清除、开关声音、切换或删除主题,进入全屏把浏览器的标签页和地址栏收起来,以及打开「皮肤中心」安装已审核的社区皮肤。本地导入只在 Node 端保存绝对路径,并通过带 Range 支持的回环媒体服务读取原文件,不复制用户选择的图片或整段视频主文件。Windows 强制使用本地引用;原生选择器不可用时会明确报错,不会静默上传或复制媒体。非 Windows 环境保留兼容上传,并明确提示该模式会保存托管副本。网页控制台没有摸鱼;浅色/深色跟 DSH 自己的外观走。下次打开会恢复上次背景。设置 `BEAUTICODE_SKIN_CENTER` 或填写 `skin-center.json` 后,皮肤中心才会显示远程目录。
21
+ 「设置 → 背景」现在有两条独立材质通道。**页面透明度**默认 70%,在页面模式的 `[data-global-panel]`(插件页、技能页、自动化任务等)铺 30% 不透明度的灰幕。浅色界面使用浅灰,深色界面使用深灰。旧设置仍按灰幕不透明度保存,原来的 45% 显示为 55% 透明度。主会话没有该锚点。**页面模糊默认开启**:`html[data-bc-page-blur="true"]`、页面根 `position:relative`/`isolation:isolate`、`::before` `blur(2.4px)`;`getPageBlur()` 默认 true,`getBlur()` 默认 `{page:2.4, panel:3.69}`。**功能面板不透明**默认 **60%**(153/255),作用于 dialog / alertdialog / menu / listbox、消息编辑栏 `[data-composer-card]` 和提问/计划审核/授权确认卡片;已有 35 等保存值保留,重置写回 60。高级设置提供三个档位滑杆:材质档位间隔(透明度)默认 8%、材质档位间隔(模糊)默认 2px、最大模糊默认 8px;嵌套 alpha 固定递增(越上层越实),没有方向选项。旧 `beauticode-material-direction` 不读不写,旧值保留但忽略;`getMaterial()` 只返回 `{alphaStep,blurStep,maxBlur}`,`setMaterial({direction})` 静默忽略。面板根独立应用一次 `backdrop-filter`,默认页面下为 `blur(3.69px)`;嵌套层只按 alpha 档位变化、绝不加模糊;`[data-shell-overlay]`(`shell.overlay`)容器本身跳过,但其中标准 role 浮层仍按独立/嵌套处理;无标准 role 的第三方浮层不处理。
22
+
23
+ 页面根内的标准 role 分两类:**tooltip 不再材质化**——不是候选、不加 alpha/层,也不改写 `--dsw-alias-tooltip-bg`,保留宿主黑底白字、背景和定位;**menu / listbox / dialog / alertdialog** 按面板材质 60% 处理、`backdrop-filter:none`,不继承 page alpha。页面根内出现可见 tooltip/menu/listbox/dialog/alertdialog 时,页面模糊**暂停**:页面根加 `data-bc-page-blur-paused`,移除 `position`/`isolation`/`::before`,仅保留灰幕,`getBlur().page=0`,面板 blur 3.69 不变;关闭浮层后自动恢复 `relative/isolate` 与 `blur(2.4px)`。暂停是为了消除这些页内浮层在 V9/V10 下的现场漂移,**不是把 V9/V10 永久解决**:没有页内浮层时,页面根仍有 V9 absolute 包含块(探测 250)和 V10 层叠(default-outside)。
24
+
25
+ **为什么侧栏和主会话不在页面材质内**:左侧栏是 DSH chrome,位于 `[data-global-panel]` 之外,半透明由 `client.js` 的 `--bc-surface-mix`(默认 36%,会话 active/settling 86%)与 `--dsw-specific-sidebar-fill` 决定,不随页面/面板强度滑杆或页面模糊变化;背景阴影/壁纸磨砂只改变透出的壁纸,不是侧栏自身材质。主会话没有 `[data-global-panel]`,页面材质/页面模糊不铺,保持壁纸直出;若未来要统一页面,应新增独立可选项,不应默认扩到主会话。
26
+
27
+ 页面透明度 100% 时移除灰幕、页面模糊和插件页辅助;`beauticode-page-blur` 偏好保留,透明度调到 100% 以下后自动恢复模糊。面板 0% 只关闭面板材质。两者回到 `client.js` 发布的半透明宿主外观(不是未经 beautiCode 处理的 DSH 原生实色)。旧键 `beauticode-readable-surfaces`:缺失/`"true"` → 60、`"false"` → 0、数字原样保留(35 仍是 35)、无效 → 60;0 仍写 `"false"` 方便回滚。页面模糊键 `beauticode-page-blur` 仅字面 `"false"` 关闭。选择即时生效并跨同源窗口同步;清除背景后恢复宿主样式,偏好保留。需要回滚时把页面透明度调到 100% 或面板强度调到 0%,或恢复旧插件版本。
28
+
29
+ 需要知道的取舍与风险:30% 页面底色不是「任意壁纸都 ≥ 4.5:1」的保证;面板默认从 100% 降到 60%,会更明显地透出后景,设置页/添加插件弹窗在 35% 下已偏透,60% 是新的基线,用户可自行调高。**V3 fixed 已关闭**:页面内 fixed 开/关 `(60,60)`、portal `(40,40)`。**V9/V10 默认仍存在**:页面模糊开启且没有页内浮层时,absolute 250、页面内高 z-index `default-outside`;只有页内 tooltip/menu/listbox/dialog/alertdialog 可见触发暂停时才回到 absolute `(10,12)`、`high-inside`。**V11 仍开放**:页面列自身滚动时 absolute 背板底部一段失模糊(delta 1);暂停不解决。**V13 仍开放**:页面 `::before` 可能被宿主/第三方占用。**V14 开放**:关闭页面模糊时 30% alpha 只能把高对比后景文字从 21:1 降到约 10.68:1,不能消除后方文字透出;开启模糊也不宣称完全解决。**V15 已闭合**。**V16 开放(低-中)**:暂停选择器覆盖任意可见页内 listbox/dialog 等,常驻控件可能让页面模糊一直暂停,需现场复核。真实 DSH 当前运行上一版候选,尚未验证本轮 tooltip/暂停/面板 60/页面模糊默认开启;需重新安装/重启候选后现场确认,不能把自动化结果当作现场通过。
30
+
31
+ 自动化结果(Chromium/Edge fixture):t4(t6 修复后)/t7/t9/t11/t15/t19/t23 浏览器材质用例均为 **15/15 pass、0 skip**,全量 harness **150/150 pass、0 skip**,`readability.test.mjs` **21/21**,`console.test.mjs` **49/49**。完整命令、结果、跳过项与风险见[验证记录](../../docs/verification/2026-11-10-dsh-layered-material.md) §21(t23 方向移除/越上层越实复验)与 §24(t26 文档一致性修复/最终状态);§19 为 t19 现场修复复验,§20 为 t20 历史记录,§22/§23 为 t24 文档同步与 t25 提交前审计。设计冻结见 [ADR 0011](../../docs/adr/0011-dsh-layered-material.md)。三个 fixture 已随上一提交纳入版本控制,当前 `git status` 无未跟踪 fixture;交付时仍请确认提交包含 `test/fixtures/fake-dom.mjs`、`layered-material.mjs`、`backdrop-model.html`。
32
+
33
+ 装好插件并运行 `dsh web` 后,打开「设置」,左侧导航里会多出一项「背景」:在 Windows 上点击图片或视频会打开系统文件选择器,选好后在页面内命名,背景立即应用并进入已保存主题;也可以清除、开关声音、切换或删除主题,进入全屏把浏览器的标签页和地址栏收起来,以及打开「皮肤中心」安装 `https://hnnulwh.cn` 上已审核的社区皮肤。本地导入只在 Node 端保存绝对路径,并通过带 Range 支持的回环媒体服务读取原文件,不复制用户选择的图片或整段视频主文件。Windows 强制使用本地引用;原生选择器不可用时会明确报错,不会静默上传或复制媒体。非 Windows 环境保留兼容上传,并明确提示该模式会保存托管副本。网页控制台没有摸鱼;浅色/深色跟 DSH 自己的外观走。下次打开会恢复上次背景。皮肤中心来源固定,不使用 `BEAUTICODE_SKIN_CENTER` 或 `skin-center.json` 改写生产目录。
24
34
 
25
35
  插件也会注册对话工具(`beauticode_*`)和斜杠命令(`/bg`、`/bg-theme`、`/bg-clear`)。不需要托盘;托盘若已在跑则复用它。
26
36
 
@@ -64,12 +74,3 @@ npx @deepseek-ai/dsh web
64
74
  4. 打开页面后在「设置」里点「背景」,或输入 `/bg <本机绝对路径>`,或直接跟 AI 说把某个视频/图片设为背景。
65
75
 
66
76
  安全边界:DSH Web 必须绑定本机回环地址;控制端点需要随机令牌;媒体 URL 仅允许带令牌的回环 HTTP 地址;浏览器回执只接受同源请求。
67
-
68
- ## 1.0.29 背景修复
69
-
70
- 画窗现在响应背景磨砂和阴影滑块,并随 DSH 深浅色切换遮罩。背景模式保留宿主的渐隐滚动内容,修复长思考展开后的持续抖动(#86、#87)。
71
-
72
-
73
- ## 1.0.30:插件页可读性
74
-
75
- 基于本地正式包 1.0.29,加入 #92 的局部实色底板,并保留主分支已合并的问答、计划及审批面板保护。DSH Web 和官方 Desktop 共用同一脚本;插件标题、分组、卡片、详情、配置及加载/空/错误状态受保护,分组间隙保留壁纸。沿用「功能面板不透明」开关,关闭保护或清除背景即可恢复宿主效果;说明文字使用宿主 secondary 标签色。不改变偏好、鉴权和存储格式。回滚可恢复旧包,无需数据迁移。
package/agent.mjs CHANGED
@@ -375,9 +375,18 @@ export function createBeauticodeActions(dataRootOrOptions) {
375
375
  videoPath: input.videoPath.trim(),
376
376
  imagePath,
377
377
  source,
378
+ ...(input.effects ? { effects: input.effects } : {}),
378
379
  }
379
380
  : { type: "image", imagePath, source };
380
- if (!hasVideo && input.effects) themeInput.effects = input.effects;
381
+ if (input.provenance?.source === "hnnulwh" &&
382
+ /^skin-[a-z0-9]{8,40}$/.test(String(input.provenance.sourceSkinId)) &&
383
+ String(input.provenance.sourceVersion || "").trim()) {
384
+ themeInput.provenance = {
385
+ source: "hnnulwh",
386
+ sourceSkinId: String(input.provenance.sourceSkinId),
387
+ sourceVersion: String(input.provenance.sourceVersion).trim(),
388
+ };
389
+ }
381
390
  const resolved = await backend();
382
391
  // Gallery import applies-and-saves through the same atomic transaction as
383
392
  // the normal image/video flow. There is no separate import-only endpoint:
package/atmosphere.js CHANGED
@@ -242,6 +242,7 @@ html[data-bc-fish="true"] #root{opacity:0!important;visibility:hidden!important;
242
242
 
243
243
  function closeLayer() {
244
244
  stopLoop();
245
+ runtime.layer?.disposeMotion?.();
245
246
  runtime.layer?.water?.destroy();
246
247
  runtime.layer?.node.remove();
247
248
  runtime.layer = null;
@@ -277,15 +278,24 @@ html[data-bc-fish="true"] #root{opacity:0!important;visibility:hidden!important;
277
278
 
278
279
  const water = attachWater(canvas);
279
280
  runtime.layer = { node, water };
281
+ const motion = window.matchMedia?.("(prefers-reduced-motion: reduce)");
280
282
  const tick = (ts) => {
281
283
  if (!runtime.layer) return;
284
+ if (motion?.matches || document.hidden) { runtime.loop = 0; return; }
282
285
  if (ts - runtime.lastTick > 32) {
283
286
  runtime.lastTick = ts;
284
287
  water.render();
285
288
  }
286
289
  runtime.loop = requestAnimationFrame(tick);
287
290
  };
288
- runtime.loop = requestAnimationFrame(tick);
291
+ const resume = () => {
292
+ if (motion?.matches || document.hidden) { stopLoop(); return; }
293
+ if (runtime.layer && !runtime.loop) runtime.loop = requestAnimationFrame(tick);
294
+ };
295
+ motion?.addEventListener?.("change", resume);
296
+ document.addEventListener("visibilitychange", resume);
297
+ runtime.layer.disposeMotion = () => { motion?.removeEventListener?.("change", resume); document.removeEventListener("visibilitychange", resume); };
298
+ resume();
289
299
  }
290
300
 
291
301
  function setWindowMode(mode) {
@@ -1,4 +1,4 @@
1
- #!/usr/bin/env node
1
+ #!/usr/bin/env node
2
2
  import { runCli } from "../cli.js";
3
3
 
4
4
  runCli().catch((error) => {
@@ -1,31 +1,166 @@
1
- import crypto from "node:crypto";
2
-
3
- const SCRIPT_PATHS = [
4
- "/__beauticode/transport.js",
5
- "/__beauticode/atmosphere.js",
6
- "/__beauticode/client.js",
7
- "/__beauticode/console.js",
8
- "/__beauticode/gallery.js",
9
- ];
10
-
11
- /** The desktop shell forwards requests after removing browser Origin headers. */
12
- export function createBrowserInjection() {
13
- const desktopKey = crypto.randomBytes(32).toString("hex");
14
-
15
- return {
16
- contribute(table) {
17
- table.push({ kind: "global", name: "__BEAUTICODE_DESKTOP_KEY__", value: desktopKey });
18
- for (const src of SCRIPT_PATHS) {
19
- table.push({ kind: "script-src", placement: "body", src });
20
- }
21
- },
22
- isSameOrigin(req) {
23
- const origin = req.headers.origin;
24
- if (typeof origin === "string") return origin === `http://${req.headers.host}`;
25
- if (req.headers["sec-fetch-site"] === "same-origin") return true;
26
- const supplied = req.headers["x-beauticode-desktop-key"];
27
- if (typeof supplied !== "string" || !/^[a-f0-9]{64}$/.test(supplied)) return false;
28
- return crypto.timingSafeEqual(Buffer.from(supplied), Buffer.from(desktopKey));
29
- },
30
- };
31
- }
1
+ import crypto from "node:crypto";
2
+ import { loadAdapter } from "./host-apply.mjs";
3
+
4
+ const SCRIPT_PATHS = [
5
+ "/__beauticode/transport.js",
6
+ "/__beauticode/atmosphere.js",
7
+ "/__beauticode/client.js",
8
+ "/__beauticode/console.js",
9
+ "/__beauticode/gallery.js",
10
+ ];
11
+
12
+ function parseLoopbackAuthority(value) {
13
+ if (typeof value !== "string" || value.trim() !== value || /[\s,]/.test(value)) return null;
14
+ const bracketed = /^\[([^\]]+)\](?::([0-9]{1,5}))?$/.exec(value);
15
+ const plain = /^(127\.0\.0\.1|localhost)(?::([0-9]{1,5}))?$/i.exec(value);
16
+ const hostname = bracketed ? `[${bracketed[1].toLowerCase()}]` : plain?.[1]?.toLowerCase();
17
+ if (hostname !== "[::1]" && !/^(?:127\.0\.0\.1|localhost)$/i.test(hostname || "")) return null;
18
+ const port = Number(bracketed?.[2] ?? plain?.[2] ?? "80");
19
+ if (!Number.isInteger(port) || port < 1 || port > 65535) return null;
20
+ return { key: `${hostname}:${port}` };
21
+ }
22
+
23
+ function parseLoopbackOrigin(value) {
24
+ if (typeof value !== "string" || value === "null") return null;
25
+ try {
26
+ const url = new URL(value);
27
+ if (url.protocol !== "http:" || url.username || url.password || url.pathname !== "/" || url.search || url.hash) return null;
28
+ return parseLoopbackAuthority(url.host);
29
+ } catch {
30
+ return null;
31
+ }
32
+ }
33
+
34
+ export function isAllowedLoopbackHost(value) {
35
+ return Boolean(parseLoopbackAuthority(value));
36
+ }
37
+
38
+ function matchesToken(supplied, expected) {
39
+ return typeof supplied === "string" && /^[a-f0-9]{64}$/.test(supplied) &&
40
+ crypto.timingSafeEqual(Buffer.from(supplied), Buffer.from(expected));
41
+ }
42
+
43
+ export function starInvitationRoutes({
44
+ authorize,
45
+ browserInjection,
46
+ readJson,
47
+ sendJson,
48
+ findRenderedClient,
49
+ openStarProject = async () => {
50
+ const { openStarProjectInDefaultBrowser } = await loadAdapter();
51
+ await openStarProjectInDefaultBrowser();
52
+ },
53
+ }) {
54
+ let lastGeneration = null;
55
+ let pendingOpenToken = null;
56
+ let opening = false;
57
+ return [
58
+ {
59
+ kind: "exact",
60
+ path: "/__beauticode/star-invitation",
61
+ async handler(req, res) {
62
+ if (req.method !== "POST") return res.writeHead(405).end();
63
+ if (!(await authorize(req))) {
64
+ return sendJson(res, 401, { ok: false, error: "未授权的请求。" });
65
+ }
66
+ const { generation } = await readJson(req);
67
+ if (!Number.isSafeInteger(generation) || generation < 0) {
68
+ return sendJson(res, 400, { ok: false, error: "背景版本无效。" });
69
+ }
70
+ // The adapter signals after its transaction commits. The bridge also
71
+ // requires a live receipt because DSH can commit with no page open.
72
+ if (generation !== lastGeneration && findRenderedClient(generation)) {
73
+ lastGeneration = generation;
74
+ try {
75
+ const { recordConfirmedBackgroundSwitch } = await loadAdapter();
76
+ if (findRenderedClient(generation) && await recordConfirmedBackgroundSwitch()) {
77
+ const client = findRenderedClient(generation);
78
+ if (client) {
79
+ const invitation = { type: "star-invitation" };
80
+ // The desktop key is shared by the host's pages. Only the
81
+ // window receiving this invitation gets the browser-open token.
82
+ if (client.desktop) invitation.openToken = crypto.randomBytes(32).toString("hex");
83
+ client.response.write(`data: ${JSON.stringify(invitation)}\n\n`);
84
+ pendingOpenToken = invitation.openToken ?? null;
85
+ }
86
+ }
87
+ } catch {
88
+ return sendJson(res, 500, { ok: false, error: "无法记录背景切换邀请。" });
89
+ }
90
+ }
91
+ return sendJson(res, 200, { ok: true });
92
+ },
93
+ },
94
+ {
95
+ kind: "exact",
96
+ path: "/__beauticode/ui/star/open",
97
+ async handler(req, res) {
98
+ if (req.method !== "POST") return res.writeHead(405).end();
99
+ if (
100
+ !browserInjection.isSameOrigin(req) || !browserInjection.hasDesktopKey(req) ||
101
+ !pendingOpenToken || !matchesToken(req.headers["x-beauticode-star-open-token"], pendingOpenToken)
102
+ ) {
103
+ return res.writeHead(403).end();
104
+ }
105
+ if (opening) return res.writeHead(409).end();
106
+ opening = true;
107
+ try {
108
+ await openStarProject();
109
+ pendingOpenToken = null;
110
+ return res.writeHead(204, { "cache-control": "no-store" }).end();
111
+ } catch {
112
+ return sendJson(res, 503, { ok: false, error: "无法打开系统默认浏览器。" });
113
+ } finally {
114
+ opening = false;
115
+ }
116
+ },
117
+ },
118
+ {
119
+ kind: "exact",
120
+ path: "/__beauticode/star-invitation.js",
121
+ async handler(req, res) {
122
+ if (req.method !== "GET" && req.method !== "HEAD") return res.writeHead(405).end();
123
+ if (!isAllowedLoopbackHost(req.headers.host)) return res.writeHead(403).end();
124
+ try {
125
+ const { buildStarInvitationExpression } = await loadAdapter();
126
+ const script = buildStarInvitationExpression("dsh");
127
+ res.writeHead(200, {
128
+ "content-type": "text/javascript; charset=utf-8",
129
+ "cache-control": "no-store",
130
+ "content-length": Buffer.byteLength(script),
131
+ });
132
+ return res.end(req.method === "HEAD" ? undefined : script);
133
+ } catch {
134
+ return res.writeHead(503).end();
135
+ }
136
+ },
137
+ },
138
+ ];
139
+ }
140
+
141
+ /** The desktop shell forwards requests after removing browser Origin headers. */
142
+ export function createBrowserInjection() {
143
+ const desktopKey = crypto.randomBytes(32).toString("hex");
144
+ const hasDesktopKey = (req) => matchesToken(req.headers["x-beauticode-desktop-key"], desktopKey);
145
+
146
+ return {
147
+ contribute(table) {
148
+ table.push({ kind: "global", name: "__BEAUTICODE_DESKTOP_KEY__", value: desktopKey });
149
+ for (const src of SCRIPT_PATHS) {
150
+ table.push({ kind: "script-src", placement: "body", src });
151
+ }
152
+ },
153
+ hasDesktopKey,
154
+ isSameOrigin(req) {
155
+ const host = parseLoopbackAuthority(req?.headers?.host);
156
+ if (!host) return false;
157
+ const origin = req.headers.origin;
158
+ if (typeof origin === "string") {
159
+ const parsedOrigin = parseLoopbackOrigin(origin);
160
+ return Boolean(parsedOrigin && parsedOrigin.key === host.key);
161
+ }
162
+ if (req.headers["sec-fetch-site"] === "same-origin") return true;
163
+ return hasDesktopKey(req);
164
+ },
165
+ };
166
+ }
@@ -0,0 +1,73 @@
1
+ {
2
+ "schema": "beauticode.build/v1",
3
+ "packageName": "beauticode-dsh",
4
+ "packageVersion": "1.0.32",
5
+ "sourceCommit": "79fd88f27e9ccbbe3c1c27c47aba4cf2873e2e22",
6
+ "sourceDirty": true,
7
+ "nodeVersion": "v24.18.0",
8
+ "files": {
9
+ "agent.mjs": "a5e3f72cc944054ee8a07eec38df7b20a53c99171f38eb4799362bf9ed81506c",
10
+ "atmosphere.js": "cb4be11aaf2bad314186dd25aab9014afcde964c861ab1be48d5ecbaa4e9bcb2",
11
+ "bin/beauticode-dsh": "d3c40c54e36e5c1f813830a01522428f898508e71969ebf7e4ac89a2ab28517d",
12
+ "browser-injection.mjs": "902d122cd71a4a7363f8934c493a561cac08adad97dded68e93d6958769f1d79",
13
+ "cli.js": "6237c8f4cc16999bad3d085d44dffcb26b18b9fea9dfed410253f69590e5033a",
14
+ "client.js": "c71f3c33a8efc5c92730c138c88f6e64c5596bcdaebfee59a2276e688b2d5851",
15
+ "console.js": "a87daed28bdcee780af9ac1fc672ff35af39f09c87fe7aa0b27c455a06e509d8",
16
+ "control-client.mjs": "e9f2dfa45ede088758dc16ec03e4ecce032fe2d1b25d236e3276f7e799ad67e5",
17
+ "cordis.patch.yml": "789d336bfd2dfb2f9853c3bcecb109b66d78fc96d9d04d3714d5d0074b47733d",
18
+ "gallery-host.mjs": "717e795778fbf0e8cc2c69261698fe461bc85fb244e3a20ef00677d3d0f6beb2",
19
+ "gallery.js": "f027132d0fab62e321af7fd7d2099610f0b7657111b8e9e13d4aa90692dc37ca",
20
+ "host-apply.mjs": "fb5dcce4d29685f5a6c90b918feb7120c7f5dcfea9e71115994e4d25156d2278",
21
+ "index.mjs": "d4e14a69e982879bac6252df615683dcf504bcc7798e9cb3b6e40ac26c64cc7b",
22
+ "LICENSE": "2de6b1cfe1f50194f14bfde5cf78bc4c41a4a0d844cc4110414b030553e4214b",
23
+ "package.json": "37cc0a23f288ed7e716260a110ef17f7b86d66f0f0164e1e840f8dd75f861385",
24
+ "presets.mjs": "586a0650873ac638724ec0f046dd2a8682de8ac0ed4b98f3ba60c5ee57bb58c3",
25
+ "profile-patch.mjs": "dc34582d8bc5834dbce46cec4227d025bae17595be4cfd98e03aaf7804f341b6",
26
+ "readability.js": "2ee034a4a781e7749625b17b1f5484a62283d643bddbd6210377eb69496e449d",
27
+ "README.zh-CN.md": "e87ad5001e0654e46194f634ddd29749665103b612a175fffde3d45b9c177b49",
28
+ "skin-center.json": "1ecb404f8e664d18ee8775d196755bb18558fa540f757302f7f522353d4dcb1d",
29
+ "themes/internal-beyond/bg-canvas-4k.webp": "8651c9535d0c4fc9c9967b9cf2d1e726054298c534ea7e42533135787881ab2d",
30
+ "themes/internal-beyond/bg-infernal.jpg": "240315e3e74593d6b2c9163c7498bee985f0afabd6380af074c3ad5cc0141f17",
31
+ "themes/internal-beyond/bg-internal.jpg": "3309416dbdc1cfa185a66e9a9305339e125153d343bf119303b52266be1f2bb3",
32
+ "themes/internal-beyond/NOTICE.md": "1fcaa56f81ae2e835de3ad8c9d087b1c5810ad024b4f012156ddb24a763e2a58",
33
+ "transport.js": "3d4dfe32b35da8d436048a53739b643d7d2d8e274bb61f2d1d86db6e5c59bfea",
34
+ "ui-host.mjs": "4274a53b6b146f2306c6c06ac4ea81354ed1e2bb0bc1193ce588894fd776eef4",
35
+ "vendor/adapter-dsh/bridge.js": "99f2e229368676501063b24319ec88acdf441ba2d1645b5913ddb73b05882685",
36
+ "vendor/adapter-dsh/host-descriptor.js": "10141d09b8a9eadee6922e8d482bbb6801d1f2b28f96d699aa55db1d70782e4d",
37
+ "vendor/adapter-dsh/index.js": "d4536e3c9756d53445309873d8496a9116da9f9a371a7c08baa3fb5d5300de96",
38
+ "vendor/adapter-dsh/injector-lock.js": "c194c2a083b4d85f5d2584017b68cad5a06c92387dc63206321f0dfd32f72b74",
39
+ "vendor/adapter-dsh/package.json": "e7e161bc9e0de87d18b82d95b944a11afdaec38975da319b0d5dfe8305a7982c",
40
+ "vendor/adapter-dsh/session.js": "8c2c95cbcba37269cec8ad0d8754763ba3d1f38edb0080df7a277392562858e1",
41
+ "vendor/adapter-dsh/token.js": "d9ddbdfe3f92939727db85ea01afcafec71449d19f4067de146fb06e165141cd",
42
+ "vendor/adapter-dsh/tray-handoff.js": "b8b80fd1735d207a1c7f1157aa8035c6620cafa84e5065aa93c8adb43e2f0c8c",
43
+ "vendor/core/apply-transaction.js": "bb2d2e20f162d8869329eef1d5feb1f346521c3811a5aa72662622a2d60ff953",
44
+ "vendor/core/background-change.js": "3400eb1e7afee283749fd0066cbde3590cebc0e99eac7378ac408933d0a3bcd5",
45
+ "vendor/core/background-store.js": "4679ab02f03bd3da0bf4d6ef912416b00d40e556434b78270f6d20ad589a6208",
46
+ "vendor/core/bundled-gallery.js": "a8e8d46ed9db394ca64c54b5afbd4de5f72f1d5d8fde154506a12938cee063e2",
47
+ "vendor/core/constants.js": "9cb5dec3cdd2a5a9feff55a137b3e6d67dae90c66e2a3d4f99b1e25f4587baad",
48
+ "vendor/core/error-message.js": "dd2b4d1b2eec04c53f9cd675eab3ea9ce7ecad37c0d463e2c0a757d69fa5da79",
49
+ "vendor/core/file-lock.js": "10917c882ade59d4ebb2c88198f94b08800a350c3f6ae5cc211d2a4b6d16f21b",
50
+ "vendor/core/gallery-operations.js": "005931f912716bf13b405ba0bc48d16a14ebc08163c3cca0121265a4522ab41d",
51
+ "vendor/core/host-session.js": "76aade5833cd30fcb3885f0abb51ab396514bfc1a90c02f00e36d425b84a4496",
52
+ "vendor/core/http-boundary.js": "f76d0c45f62542838f6b1355569db5bbbf300f29cb5b5459eba77c3cb0c28b35",
53
+ "vendor/core/index.js": "5845e7cad3f12ab97ddfcd265ec8577576f9d0a25ea4d302b414fd0df5b65d67",
54
+ "vendor/core/linux-process.js": "2f9d07d743f6478a7b2e3cb77050209b889501949e2a5d27a31f740ca896fd75",
55
+ "vendor/core/media-health.js": "9b35f87d898638c002ff24e37df97ed1b0e17ec8246c74b5f4e4ea3d558f6438",
56
+ "vendor/core/media-server.js": "797cbc5246474db7d21ddf5b3e999a97b1fa4c42976a3ea17ef9a543c9f7c730",
57
+ "vendor/core/media-source.js": "11baa59d7ddc554e86f7e00df760e54c584e11837eff0ce65d185961ac285e19",
58
+ "vendor/core/media-validation.js": "996ae05f6f546c92dc1930ae6735381e4b780e3db84e98f6c60f30b981102f51",
59
+ "vendor/core/package.json": "245673d02497aa88bf7a316abb987c2bac3979a1f7a58f8f427f56952c119820",
60
+ "vendor/core/paths.js": "d91fba8f9320c032b19d8a55d09873d87d9c81c5de4e529ec12030d84029768b",
61
+ "vendor/core/process-liveness.js": "7584d21f0f51d1f3e9f6e1fb0726e90d3557d259f6055c7536a3a577de4a3119",
62
+ "vendor/core/serial-task.js": "6af2acc77a22aa093a9199520d858cc9cc3c05e70fbe3ea90ec01855feab0e0c",
63
+ "vendor/core/skin-catalog.js": "ba14e4201239e0c8072fc95c9d040ed890d2c815fc5092585244ea0d1c1dc9a1",
64
+ "vendor/core/star-invitation-renderer.js": "cf9acf2291c59486cb496c88bdf0975c2ae9357a24de43c8072d0fb1670a5890",
65
+ "vendor/core/star-invitation.js": "855631ea6d92439babed07c1146159522e3dfcaba3f48d712c46c5d2861e3db6",
66
+ "vendor/core/star-project-browser.js": "fc9b3751ed4541af21bbdd74bb4061382c2cacf1c156c02c21bf9536a16f0a83",
67
+ "vendor/core/star-project.js": "fc3672e8776929b9749e14f29df3c18bb4ed3950cfbb6cb452cd3bb451b10a1e",
68
+ "vendor/core/startup-repair-chain.js": "9082caccd5e07a8e79c155172529336b7a5bb14b02f7f46ffe27aa0cf4a76c4f",
69
+ "vendor/core/types.js": "ab174157581c04974a33d44b4ad9638882c90d328c20773f4dfba8520c784065",
70
+ "vendor/core/wallpaper-library.js": "adf9aec99a04e510671f75ed22f8af57d6a0705f3cb2825d7eb73b24f64aed63",
71
+ "vendor/core/wallpaper-project.js": "9eaf221091807c0b91f1496ff42caa90b913c1adfb126872bea78bc55360229f"
72
+ }
73
+ }