dsh-client-ui-skin-tianlight 2.0.4 → 2.0.5

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/README.md CHANGED
@@ -6,6 +6,10 @@
6
6
  >
7
7
  > npm 包名 `dsh-client-ui-skin-tianlight`(v2.0.2 起;旧链接安装包名 `@dsh-external/dsh-client-ui-skin-tianlight`)· 布线行 `ui-skin-tianlight` · body 属性 `data-dsh-tianlight`
8
8
 
9
+ ## v2.0.5 · 天气兜底版
10
+
11
+ 有些网络会把浏览器(Chromium/OpenSSL)到 `api.open-meteo.com` 的 **TLS 握手**丢掉——同一域名走明文 HTTP、或走系统 TLS 栈(curl/PowerShell)却正常。桌面端页面是 `dsh-app://` 安全源,渲染层不能自己降级,于是天气卡一直停在 `获取失败:请求超时(静默重试)`。这一版给宿主加了只读的 `_weather` 兜底路由:客户端直连失败后请宿主代取(宿主先试 HTTPS,失败才用同一域名的明文 HTTP),拿到数据后照旧走原来的天气模型与配额;直连正常时完全不会走到它。详见 [RELEASE-NOTES-v2.0.5.md](RELEASE-NOTES-v2.0.5.md)。
12
+
9
13
  ## v2.0.4 · 安全修复版(建议升级)
10
14
 
11
15
  修复了 v2.0.3 验收中发现的问题,其中最重要的一条:Wallpaper Engine 网页壁纸的页面以前会以 DSH 源的身份运行,现在一律沙箱化。2.0.2 和 2.0.3 都受影响,请升级:先完全退出 DSH,再运行 `npx dsh-client-ui-skin-tianlight@latest`。另外 `npx` 不再顺带下载整套 DSH 依赖,安装快很多。详见 [RELEASE-NOTES-v2.0.4.md](RELEASE-NOTES-v2.0.4.md)。
package/build-info.json CHANGED
@@ -1,8 +1,8 @@
1
1
  {
2
2
  "schema": 1,
3
3
  "product": "dsh-client-ui-skin-tianlight",
4
- "version": "2.0.4",
5
- "commit": "37c4db1b350a47b6794262bbe246a259710177db",
6
- "builtAt": "2026-11-13T17:10:57+08:00",
4
+ "version": "2.0.5",
5
+ "commit": "73c8d1f23eb0752a3607fa7e4853242e2a69545e",
6
+ "builtAt": "2026-11-14T17:30:25+08:00",
7
7
  "source": "pack"
8
8
  }
package/lib/client.js CHANGED
@@ -15742,6 +15742,8 @@ body[data-dsh-tianlight] [data-tl-group="context"] .tl-fx-hint {
15742
15742
  let weatherRetryTimer = 0;
15743
15743
  let weatherRetryUsed = false;
15744
15744
  let weatherRequestToken = 0;
15745
+ /** v2.0.5:直连被网络打断过一次、且宿主兜底能用时为 true(本页会话内有效)。 */
15746
+ let weatherDirectBlocked = false;
15745
15747
  let weatherScheduleKey = "";
15746
15748
  /** 最近一次天气请求的开始时间:切回可见时只按间隔决定是否补一次请求。 */
15747
15749
  let lastWeatherFetchAt = 0;
@@ -15870,6 +15872,55 @@ body[data-dsh-tianlight] [data-tl-group="context"] .tl-fx-hint {
15870
15872
  if (left === null || left === undefined || right === null || right === undefined) return false;
15871
15873
  return left.code === right.code && left.temperatureC === right.temperatureC && left.isDay === right.isDay;
15872
15874
  };
15875
+ /**
15876
+ * v2.0.5:直连失败时的宿主兜底。
15877
+ *
15878
+ * 有些网络会把 Chromium/OpenSSL 到 api.open-meteo.com 的 TLS 握手丢掉,
15879
+ * 而同一个域名走明文 HTTP、或走系统 TLS 栈(curl/PowerShell)却正常。
15880
+ * 桌面端页面是 `dsh-app://` 安全源,渲染层不能自己降级(mixed content 会拦),
15881
+ * 所以这里请宿主代取;宿主没这条路由(旧版本)时返回 null,错误照旧上报。
15882
+ */
15883
+ const weatherViaHost = async (state) => {
15884
+ try {
15885
+ const response = await fetch(
15886
+ ASSET_BASE +
15887
+ "/_weather?latitude=" +
15888
+ encodeURIComponent(String(state.latitude)) +
15889
+ "&longitude=" +
15890
+ encodeURIComponent(String(state.longitude)),
15891
+ { cache: "no-store" },
15892
+ );
15893
+ if (response === null || response === undefined || response.ok !== true) return null;
15894
+ const body = await response.json();
15895
+ if (body === null || body === undefined || body.ok !== true) return null;
15896
+ const payload = body.payload;
15897
+ return payload !== null && payload !== undefined && typeof payload === "object" ? payload : null;
15898
+ } catch {
15899
+ return null;
15900
+ }
15901
+ };
15902
+ /** 一次直连尝试:只返回结果、不写状态,由调用方决定要不要兜底。 */
15903
+ const fetchWeatherDirect = async (state) => {
15904
+ const token = (weatherRequestToken += 1);
15905
+ const request = weatherOpenRequest();
15906
+ try {
15907
+ const response = await fetch(weatherForecastUrl(state), { signal: request.controller.signal, cache: "no-store" });
15908
+ if (alive === false || token !== weatherRequestToken) return { ok: false, error: "aborted" };
15909
+ if (response === null || response === undefined || response.ok !== true) {
15910
+ return { ok: false, error: "network" };
15911
+ }
15912
+ const payload = await response.json();
15913
+ if (alive === false || token !== weatherRequestToken) return { ok: false, error: "aborted" };
15914
+ return { ok: true, payload };
15915
+ } catch (error) {
15916
+ if (alive === false || token !== weatherRequestToken) return { ok: false, error: "aborted" };
15917
+ const timedOut =
15918
+ request.timedOut === true || (error !== null && error !== undefined && error.name === "AbortError");
15919
+ return { ok: false, error: timedOut ? "timeout" : "network" };
15920
+ } finally {
15921
+ weatherCloseRequest(request);
15922
+ }
15923
+ };
15873
15924
  const fetchWeather = async (source) => {
15874
15925
  if (alive === false) return false;
15875
15926
  if (typeof AbortController !== "function") return false;
@@ -15877,20 +15928,33 @@ body[data-dsh-tianlight] [data-tl-group="context"] .tl-fx-hint {
15877
15928
  if (state.enabled !== true || weatherHasLocation() !== true) return false;
15878
15929
  if (source !== "retry") weatherRetryUsed = false;
15879
15930
  lastWeatherFetchAt = Date.now();
15880
- const token = (weatherRequestToken += 1);
15881
- const request = weatherOpenRequest();
15882
- try {
15883
- const response = await fetch(weatherForecastUrl(state), { signal: request.controller.signal, cache: "no-store" });
15884
- if (alive === false || token !== weatherRequestToken) return false;
15885
- if (response === null || response === undefined || response.ok !== true) {
15886
- setWeatherError("network");
15887
- scheduleWeatherRetry();
15888
- return false;
15931
+ let result;
15932
+ if (weatherDirectBlocked === false) {
15933
+ result = await fetchWeatherDirect(state);
15934
+ if (result.ok === false && result.error === "aborted") return false;
15935
+ if (result.ok === false) {
15936
+ // 直连栽在网络上:问一次宿主。只有宿主真的取到了,才记住“直连不可用”,
15937
+ // 这样网络恢复后下一次仍会先试直连(宿主失败时也会清掉这个捷径)。
15938
+ const payload = await weatherViaHost(state);
15939
+ if (payload !== null) {
15940
+ result = { ok: true, payload };
15941
+ weatherDirectBlocked = true;
15942
+ tl5Diag("context", { weatherFallback: "host" });
15943
+ }
15889
15944
  }
15890
- const payload = await response.json();
15891
- if (alive === false || token !== weatherRequestToken) return false;
15945
+ } else {
15946
+ const payload = await weatherViaHost(state);
15947
+ if (payload !== null) {
15948
+ result = { ok: true, payload };
15949
+ } else {
15950
+ weatherDirectBlocked = false;
15951
+ result = await fetchWeatherDirect(state);
15952
+ }
15953
+ }
15954
+ if (alive === false) return false;
15955
+ if (result.ok === true) {
15892
15956
  if (weatherController.state().enabled !== true) return false;
15893
- const last = normalizeWeatherForecast(payload);
15957
+ const last = normalizeWeatherForecast(result.payload);
15894
15958
  if (last === null) {
15895
15959
  setWeatherError("invalid");
15896
15960
  scheduleWeatherRetry();
@@ -15908,18 +15972,10 @@ body[data-dsh-tianlight] [data-tl-group="context"] .tl-fx-hint {
15908
15972
  weatherController.apply({ last, lastError: "" });
15909
15973
  applyWeatherAmbience(last.code, last.isDay);
15910
15974
  return true;
15911
- } catch (error) {
15912
- if (alive === false || token !== weatherRequestToken) return false;
15913
- const reason =
15914
- request.timedOut === true || (error !== null && error !== undefined && error.name === "AbortError")
15915
- ? "timeout"
15916
- : "network";
15917
- setWeatherError(reason);
15918
- scheduleWeatherRetry();
15919
- return false;
15920
- } finally {
15921
- weatherCloseRequest(request);
15922
15975
  }
15976
+ setWeatherError(result.error === "timeout" ? "timeout" : "network");
15977
+ scheduleWeatherRetry();
15978
+ return false;
15923
15979
  };
15924
15980
  const resolveWeatherCity = async (query) => {
15925
15981
  if (alive === false) return { ok: false, error: "aborted" };
package/lib/index.js CHANGED
@@ -29,6 +29,7 @@ import { frameCacheStatus, handleFrameCache, handleFrameCacheStatus } from './me
29
29
  import { derivedPath, ffmpegStatus, handleTranscode, handleTranscodeStatus, listDerived } from './transcode.js'
30
30
  import { handleWebProject, listWebProjects } from './web-project.js'
31
31
  import { buildFingerprint, formatFingerprintLine } from './fingerprint.js'
32
+ import { handleWeatherProxy } from './weather-proxy.js'
32
33
  import {
33
34
  PET_CHAT_CODES,
34
35
  computePetLlmCapability,
@@ -73,7 +74,7 @@ const HOST_API = '2'
73
74
  * manifest is stamped with it. The handshake no longer compares it, so a
74
75
  * browser-half-only update can run against an unchanged host process.
75
76
  */
76
- const BUILD = '2.0.4'
77
+ const BUILD = '2.0.5'
77
78
 
78
79
  function readRoots() {
79
80
  try {
@@ -472,6 +473,22 @@ function handle(ctx, req, res) {
472
473
  )
473
474
  return
474
475
  }
476
+ if (rest === '_weather') {
477
+ // v2.0.5: transport shim for networks where the renderer's TLS handshake to
478
+ // Open-Meteo is dropped. Read-only, no state, no caching.
479
+ if (req.method !== 'GET' && req.method !== 'HEAD') {
480
+ sendText(res, 405, 'method not allowed')
481
+ return
482
+ }
483
+ void handleWeatherProxy(url, res).catch(() => {
484
+ try {
485
+ sendJson(res, 502, { ok: false, error: 'network' })
486
+ } catch {
487
+ // response already gone
488
+ }
489
+ })
490
+ return
491
+ }
475
492
  if (rest === '_fingerprint') {
476
493
  // v2.0.1: exact installed-build identity for the hub's self-test / feedback panels.
477
494
  // Additive route; it carries versions, hashes and the install method only — never a
@@ -1,21 +1,21 @@
1
- MIT License
2
-
3
- Copyright (c) 2026 dsh-we-wallpaper 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 dsh-we-wallpaper 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.
@@ -0,0 +1,127 @@
1
+ // Weather fallback proxy (v2.0.5).
2
+ //
3
+ // The browser half fetches Open-Meteo directly. Some networks drop the TLS
4
+ // handshake to api.open-meteo.com for Chromium's TLS stack while the same host
5
+ // answers plain HTTP (and the OS TLS stack) normally. The desktop webview runs on
6
+ // the `dsh-app://` secure origin, so that half cannot downgrade the request itself
7
+ // — mixed content would be blocked. The host process has no such restriction, so
8
+ // the renderer asks this route and the host performs the request instead.
9
+ //
10
+ // Contract (read-only GET):
11
+ // /skin-tianlight/_weather?latitude=..&longitude=..
12
+ // 200 { ok: true, transport: "https" | "http", payload: <open-meteo json> }
13
+ // 400 { ok: false, error: "invalid" } missing / out-of-range coordinates
14
+ // 502 { ok: false, error: "network" | "timeout" }
15
+ //
16
+ // Only the two coordinates leave the machine. Nothing is cached, logged or written:
17
+ // the route is a transport shim, not a second weather model.
18
+ import http from 'node:http'
19
+ import https from 'node:https'
20
+ import { sendJson } from './http-media.js'
21
+
22
+ const FORECAST_HOST = 'api.open-meteo.com'
23
+ const FORECAST_PATH = '/v1/forecast'
24
+ /** Exactly what the browser half asks for; keep the two in step. */
25
+ const CURRENT_FIELDS = 'temperature_2m,weather_code,is_day'
26
+ /** Per-transport budget. HTTPS is tried first, so a dead handshake costs at most this. */
27
+ const TIMEOUT_MS = 3500
28
+ /** The current-conditions payload is ~600 bytes; anything near this is not weather. */
29
+ const MAX_BYTES = 64 * 1024
30
+
31
+ /** Trimmed, range-checked coordinate string, or null. */
32
+ function coordinate(value, limit) {
33
+ if (typeof value !== 'string' || value.trim() === '') return null
34
+ const number = Number(value)
35
+ if (Number.isFinite(number) === false || Math.abs(number) > limit) return null
36
+ return String(Math.round(number * 10000) / 10000)
37
+ }
38
+
39
+ /** One GET, resolved with the parsed JSON body. Errors carry a `code` for the caller. */
40
+ function requestJson(transport, path, timeoutMs) {
41
+ return new Promise((resolve, reject) => {
42
+ const secure = transport === 'https'
43
+ let settled = false
44
+ let deadline = null
45
+ const finish = (error, value) => {
46
+ if (settled) return
47
+ settled = true
48
+ if (deadline !== null) clearTimeout(deadline)
49
+ if (error === null) resolve(value)
50
+ else reject(error)
51
+ }
52
+ const request = (secure ? https : http).request(
53
+ {
54
+ host: FORECAST_HOST,
55
+ port: secure ? 443 : 80,
56
+ path,
57
+ method: 'GET',
58
+ headers: { accept: 'application/json', 'user-agent': 'tianlight-weather/2.0.5' },
59
+ },
60
+ (response) => {
61
+ if (response.statusCode !== 200) {
62
+ response.resume()
63
+ finish(Object.assign(new Error(`upstream status ${response.statusCode}`), { code: 'status' }))
64
+ return
65
+ }
66
+ const chunks = []
67
+ let size = 0
68
+ response.on('data', (chunk) => {
69
+ size += chunk.length
70
+ if (size > MAX_BYTES) {
71
+ request.destroy()
72
+ finish(Object.assign(new Error('upstream payload too large'), { code: 'oversize' }))
73
+ return
74
+ }
75
+ chunks.push(chunk)
76
+ })
77
+ response.on('end', () => {
78
+ try {
79
+ finish(null, JSON.parse(Buffer.concat(chunks).toString('utf8')))
80
+ } catch {
81
+ finish(Object.assign(new Error('upstream payload is not json'), { code: 'json' }))
82
+ }
83
+ })
84
+ response.on('error', (error) => finish(error))
85
+ },
86
+ )
87
+ // A hard wall-clock deadline: `request.setTimeout` only covers socket inactivity,
88
+ // and a handshake that stalls after connect can sit well past the budget.
89
+ deadline = setTimeout(() => {
90
+ request.destroy()
91
+ finish(Object.assign(new Error('upstream timeout'), { code: 'timeout' }))
92
+ }, timeoutMs)
93
+ request.on('error', (error) => finish(error))
94
+ request.end()
95
+ })
96
+ }
97
+
98
+ /** GET /skin-tianlight/_weather — HTTPS first, then the same host over plain HTTP. */
99
+ export async function handleWeatherProxy(url, res) {
100
+ const latitude = coordinate(url.searchParams.get('latitude'), 90)
101
+ const longitude = coordinate(url.searchParams.get('longitude'), 180)
102
+ if (latitude === null || longitude === null) {
103
+ sendJson(res, 400, { ok: false, error: 'invalid' })
104
+ return
105
+ }
106
+ const path =
107
+ FORECAST_PATH +
108
+ '?latitude=' +
109
+ encodeURIComponent(latitude) +
110
+ '&longitude=' +
111
+ encodeURIComponent(longitude) +
112
+ '&current=' +
113
+ encodeURIComponent(CURRENT_FIELDS) +
114
+ '&timezone=auto'
115
+ let timedOut = false
116
+ for (const transport of ['https', 'http']) {
117
+ try {
118
+ const payload = await requestJson(transport, path, TIMEOUT_MS)
119
+ if (payload === null || typeof payload !== 'object') continue
120
+ sendJson(res, 200, { ok: true, transport, payload })
121
+ return
122
+ } catch (error) {
123
+ if (error !== null && error !== undefined && error.code === 'timeout') timedOut = true
124
+ }
125
+ }
126
+ sendJson(res, 502, { ok: false, error: timedOut ? 'timeout' : 'network' })
127
+ }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "dsh-client-ui-skin-tianlight",
3
3
  "description": "Tianlight skin for the dsh web GUI: Makoto Shinkai daylight skies, a looping video wallpaper, a wallpaper library with upload/rotation, optional WebWallGL scene support, and a draggable Mint chibi-cat desktop companion",
4
- "version": "2.0.4",
4
+ "version": "2.0.5",
5
5
  "type": "module",
6
6
  "main": "lib/index.js",
7
7
  "bin": {
package/skin.json CHANGED
@@ -1,42 +1,42 @@
1
- {
2
- "id": "tianlight",
3
- "name": "天光",
4
- "nameEn": "TIANLIGHT",
5
- "version": "2.0.4",
6
- "author": "local",
7
- "tagline": "新海诚式天光 ・ 动态壁纸与可上传壁纸库 ・ 可选 WebWallGL 场景 ・ 薄荷小猫桌宠 ・ 职责通道(role pack → 桌宠气泡/选择) ・ 生活节奏与主动开口预算 ・ 可替换图片/≤32MiB 视频形象 ・ 液态玻璃三档 ・ AI 桌宠(严格权限) ・ 接入 DSH Agent(受控) ・ 桌宠即入口 ・ 兼容 DSH 0.2.0–0.2.2",
8
- "description": "以新海诚天光为基调的沉浸式皮肤:全屏循环视频壁纸置于内容之下,半透明天光玻璃面板;壁纸库支持上传、隐藏、轮播、画面滤镜与标签检索;可选的 WebWallGL 通道实时渲染 Wallpaper Engine 场景;可拖拽的薄荷 Q 版小猫桌宠会靠近回应、陪你互动。v0.5.0 加入了宿主配置同步与 schema 迁移、模块开关、渲染预算、特效与氛围层、时段/专注联动、系统音频与 Now Playing、网页壁纸、动态分辨率与预裁剪缓存、可选转码、导入导出包与配方分享链接、排版增强、可读性护栏、键盘无障碍与 zh/en 双语;v0.6.0 接入 Wallpaper Engine 壁纸库;v0.7.0 新增职责通道:外部角色包可在桌宠旁显示带按钮的职责气泡(审批/完成/喝水等),并把用户选择(等会儿/静音/休息时再说)回传给职责引擎。本版只改浏览器半,无需重启 DSH(Ctrl+F5 即可)。同一份构建适配 DSH 0.2.0 / 0.2.1 / 0.2.2(选择器桥按运行时钩子分层降级)。 v1.0.0 正式版:桌宠升级为有生活节奏的角色智能体——虚拟时钟/每日作息/主动开口预算/跨会话记忆,职责提醒可被静默与预算闸门延迟并在窗口期自动回放;形象可替换为本地图片或 ≤32 MiB 视频;新增可选液态玻璃(真实/柔和/磨砂,低电量自动降级);新增「角色 / 生活」设置页与专注计时;无宿主路由改动,Ctrl+F5 即可。 v1.1.0:角色中枢(侧栏入口 + 全屏面板,一屏管生活/形象/玻璃/记忆)、AI 桌宠(本地大脑 + 可选 LLM 适配器,严格能力白名单与硬上限、审计与暂停开关)、形象支持本地上传图片/视频(≤32MiB)。 v1.2.0:桌宠右键直达角色中枢;新增受控 DSH Agent 接入(agentChat 权限默认关闭、显式授权、无自动触发、每日≤10 次/≤500 字/60s,可连接现有会话或新建桌宠会话)。 v1.3.0:角色入口收进桌宠——去掉设置页「角色 / 生活」与侧栏「角色」按钮,右键桌宠(或桌宠菜单「角色中枢」)打开全部功能;生活节奏设置已并入角色中枢。 v1.4.0:权限模型调整——「驱动 DSH」仍强烈永久禁止;直接联网/读写文件/执行命令/代审批/代发消息/安装插件改为用户可显式授予的高风险权限(默认关闭、可撤销、全程审计;皮肤不内置实现,需你注册能力适配器才会被调用)。 v1.5.0:恢复默认桌宠形象、液态玻璃默认开启并加预览(实时可见)、角色中枢新增天气卡(启用/城市/定位/刷新,显示当前天气)、一键功能自检、应用内反馈面板(复制/预填 GitHub Issue/下载 JSON)+ GitHub issue 模板。 v1.6.0:安全上限整体上调(主动开口 12/50、本地 chat 20/分 1200/天、输入 1000 字、LLM 日 60/上限 120、分钟 6、输出 1200 字、20s 超时、Agent 日 30/上限 100、输入 1000 字/120s);液态玻璃在 depth!=off 时统一应用到全部界面(侧栏/设置/壁纸库/中枢/对话框/菜单/列表框/输入区/气泡/胶囊/提示等),无壁纸场景时自动补一层玻璃兜底,关闭档零变化、低电量自动降级。 v1.6.1:液态玻璃升级 v2(OriginOS 风更厚磨砂、多层 specular 高光、1px 亮暗边、外柔光、细噪点与柔和回弹);修复侧栏「新会话」按钮深色块并玻璃化;DSH 主界面右上新增常驻天气胶囊(点击打开角色中枢天气卡)。 v1.6.2:移除壁纸左上角固定的「晨光/太阳」装饰(旧版每张壁纸重建场景都会绘制一个 top-left dawn burst,看起来像常驻小太阳);场景层只保留 veil 天空光渐变,切换壁纸不再出现任何固定角标(仅视觉变化)。 v1.6.3:显示名精简为「天光」(skin id / 包名 / data 属性 / 设置键均不变,旧用户无迁移成本);完成 DSH 0.2.0-rc.2 / 0.2.1-rc.5 / 0.2.2-rc.1 三线兼容性实证(compat-matrix 三行全 COMPATIBLE、hook-scan 全桥接钩子在位、upgrade-check 升级假设全部成立)。 v1.6.4(公开 v1.0.3 正式版):桌宠新增「AI 对话」菜单(输入条 + 气泡回复,识别当前替换的图片/视频形象,视频上方空间不足自动翻转);每个自定义形象可编辑一套动作名与回复(按 mediaId 生效,未改动跟随默认);角色中枢形象文件名常显列表(文件名/类型/大小,点击切换);完成全代码审查修复(默认文案冻结、WE 宿主 stream error、低电量异步泄漏、bridge 节点清理、转码超时兜底、宿主同源栅栏收紧、聊天视口翻转)。 v1.6.5(公开 v1.0.4 正式版):修复桌宠「AI 对话」关不掉的问题——新增面板「×」关闭按钮、点空白关闭、全局 Esc 关闭、[hidden] 真正隐藏,并支持桌宠靠近屏幕底部时点桌宠直接退出(菜单被裁到视口外也能退出)。仅浏览器半,无宿主路由改动,Ctrl+F5 即可。 v1.6.6(公开 v1.0.5 正式版):修复 AI 对话面板在桌宠默认靠右位置时「×」关闭按钮被视口裁掉的问题(面板水平夹取进视口,拖拽/窗口缩放后重算),并把顶部翻转阈值改为按面板实际高度计算(新增按钮行后不再裁到顶部),略增大关闭按钮点击区域。仅浏览器半;版本常量变更,Ctrl+F5 + 重启 DSH 一次可消除宿主半 stale 提示。 v1.6.7(公开 v1.0.6 正式版):壁纸面板默认视图新增一等「URL 地址」「ShaderToy 代码」快捷来源(点击直达编辑器,并修复 URL/Shader 应用假成功与卡死);桌宠「AI 对话」收到回复即自动收起输入面板、只留气泡回复;新增「☰」对话历史(与 AI 对话相邻):可查看历史、开启新对话、编辑已发消息、删除对话,数据存本机 localStorage。仅浏览器半;版本常量变更,Ctrl+F5 + 重启 DSH 一次可消除宿主半 stale 提示。 v1.6.8(公开 v1.0.7 正式版):桌宠新增「自主思考」智能体——按间隔做内心独白、可自主开口(受既有主动开口预算约束),聊天回复融入最近对话/时段/记忆/当前想法更像人;角色中枢新增「自主思考」卡片(开关/间隔/自主开口/现在想一下/最近想法/清空)。不新增权限与网络通道,不驱动 DSH Agent;仅浏览器半,Ctrl+F5 即可;版本常量变更,重启 DSH 一次可消除宿主半 stale 提示。 v2.0.0:桌宠 AI 对话接入 DSH 自带 LLM(宿主路由 _pet-chat;默认跟随 DSH 默认模型,仍须在角色中枢两步授权 llm;不建会话、不调工具、60/日、6/分、1200 字、20s 超时;失败按稳定错误码提示);版本号统一为 2.0.0(仓库 / DSH 安装 / GitHub 发布同名同号);并入 v1.6.8 之后的体检修复批次(设置同步合并与冲突保护、宿主/桥接安全收口、统一浮层层序、壁纸切换与性能、可读性/低电量、导出导入一致性);默认演示素材精简为 bg-4k.mp4(H.264 4K)与 cat.png,bg-main.mp4 改为可选自备首选槽。本版改了宿主半:升级后必须重启 DSH 一次 + Ctrl+F5,之后纯浏览器半更新仍只需 Ctrl+F5。",
9
- "tags": [
10
- "shinkai",
11
- "sky",
12
- "video",
13
- "wallpaper-engine",
14
- "webwallgl",
15
- "anime",
16
- "mint",
17
- "pet",
18
- "role-pack",
19
- "duty",
20
- "life",
21
- "liquid-glass",
22
- "ai-pet",
23
- "permissions",
24
- "agent"
25
- ],
26
- "accent": "#3f8fe0",
27
- "bodyAttr": "data-dsh-tianlight",
28
- "dshCompatibility": "0.2.2rc1",
29
- "dshCompatibilityRange": ">=0.2.0-rc.1 <0.2.1-0 || >=0.2.1-0 <0.2.2-0 || >=0.2.2-0 <0.3.0-0",
30
- "dshCompatibilityTested": [
31
- "0.2.0-rc.2",
32
- "0.2.1-rc.3",
33
- "0.2.1-rc.5",
34
- "0.2.2-rc.1"
35
- ],
36
- "package": "dsh-client-ui-skin-tianlight",
37
- "wiring": {
38
- "id": "ui-skin-tianlight",
39
- "bundleWired": true
40
- },
41
- "order": 30
42
- }
1
+ {
2
+ "id": "tianlight",
3
+ "name": "天光",
4
+ "nameEn": "TIANLIGHT",
5
+ "version": "2.0.5",
6
+ "author": "local",
7
+ "tagline": "新海诚式天光 ・ 动态壁纸与可上传壁纸库 ・ 可选 WebWallGL 场景 ・ 薄荷小猫桌宠 ・ 职责通道(role pack → 桌宠气泡/选择) ・ 生活节奏与主动开口预算 ・ 可替换图片/≤32MiB 视频形象 ・ 液态玻璃三档 ・ AI 桌宠(严格权限) ・ 接入 DSH Agent(受控) ・ 桌宠即入口 ・ 兼容 DSH 0.2.0–0.2.2",
8
+ "description": "以新海诚天光为基调的沉浸式皮肤:全屏循环视频壁纸置于内容之下,半透明天光玻璃面板;壁纸库支持上传、隐藏、轮播、画面滤镜与标签检索;可选的 WebWallGL 通道实时渲染 Wallpaper Engine 场景;可拖拽的薄荷 Q 版小猫桌宠会靠近回应、陪你互动。v0.5.0 加入了宿主配置同步与 schema 迁移、模块开关、渲染预算、特效与氛围层、时段/专注联动、系统音频与 Now Playing、网页壁纸、动态分辨率与预裁剪缓存、可选转码、导入导出包与配方分享链接、排版增强、可读性护栏、键盘无障碍与 zh/en 双语;v0.6.0 接入 Wallpaper Engine 壁纸库;v0.7.0 新增职责通道:外部角色包可在桌宠旁显示带按钮的职责气泡(审批/完成/喝水等),并把用户选择(等会儿/静音/休息时再说)回传给职责引擎。本版只改浏览器半,无需重启 DSH(Ctrl+F5 即可)。同一份构建适配 DSH 0.2.0 / 0.2.1 / 0.2.2(选择器桥按运行时钩子分层降级)。 v1.0.0 正式版:桌宠升级为有生活节奏的角色智能体——虚拟时钟/每日作息/主动开口预算/跨会话记忆,职责提醒可被静默与预算闸门延迟并在窗口期自动回放;形象可替换为本地图片或 ≤32 MiB 视频;新增可选液态玻璃(真实/柔和/磨砂,低电量自动降级);新增「角色 / 生活」设置页与专注计时;无宿主路由改动,Ctrl+F5 即可。 v1.1.0:角色中枢(侧栏入口 + 全屏面板,一屏管生活/形象/玻璃/记忆)、AI 桌宠(本地大脑 + 可选 LLM 适配器,严格能力白名单与硬上限、审计与暂停开关)、形象支持本地上传图片/视频(≤32MiB)。 v1.2.0:桌宠右键直达角色中枢;新增受控 DSH Agent 接入(agentChat 权限默认关闭、显式授权、无自动触发、每日≤10 次/≤500 字/60s,可连接现有会话或新建桌宠会话)。 v1.3.0:角色入口收进桌宠——去掉设置页「角色 / 生活」与侧栏「角色」按钮,右键桌宠(或桌宠菜单「角色中枢」)打开全部功能;生活节奏设置已并入角色中枢。 v1.4.0:权限模型调整——「驱动 DSH」仍强烈永久禁止;直接联网/读写文件/执行命令/代审批/代发消息/安装插件改为用户可显式授予的高风险权限(默认关闭、可撤销、全程审计;皮肤不内置实现,需你注册能力适配器才会被调用)。 v1.5.0:恢复默认桌宠形象、液态玻璃默认开启并加预览(实时可见)、角色中枢新增天气卡(启用/城市/定位/刷新,显示当前天气)、一键功能自检、应用内反馈面板(复制/预填 GitHub Issue/下载 JSON)+ GitHub issue 模板。 v1.6.0:安全上限整体上调(主动开口 12/50、本地 chat 20/分 1200/天、输入 1000 字、LLM 日 60/上限 120、分钟 6、输出 1200 字、20s 超时、Agent 日 30/上限 100、输入 1000 字/120s);液态玻璃在 depth!=off 时统一应用到全部界面(侧栏/设置/壁纸库/中枢/对话框/菜单/列表框/输入区/气泡/胶囊/提示等),无壁纸场景时自动补一层玻璃兜底,关闭档零变化、低电量自动降级。 v1.6.1:液态玻璃升级 v2(OriginOS 风更厚磨砂、多层 specular 高光、1px 亮暗边、外柔光、细噪点与柔和回弹);修复侧栏「新会话」按钮深色块并玻璃化;DSH 主界面右上新增常驻天气胶囊(点击打开角色中枢天气卡)。 v1.6.2:移除壁纸左上角固定的「晨光/太阳」装饰(旧版每张壁纸重建场景都会绘制一个 top-left dawn burst,看起来像常驻小太阳);场景层只保留 veil 天空光渐变,切换壁纸不再出现任何固定角标(仅视觉变化)。 v1.6.3:显示名精简为「天光」(skin id / 包名 / data 属性 / 设置键均不变,旧用户无迁移成本);完成 DSH 0.2.0-rc.2 / 0.2.1-rc.5 / 0.2.2-rc.1 三线兼容性实证(compat-matrix 三行全 COMPATIBLE、hook-scan 全桥接钩子在位、upgrade-check 升级假设全部成立)。 v1.6.4(公开 v1.0.3 正式版):桌宠新增「AI 对话」菜单(输入条 + 气泡回复,识别当前替换的图片/视频形象,视频上方空间不足自动翻转);每个自定义形象可编辑一套动作名与回复(按 mediaId 生效,未改动跟随默认);角色中枢形象文件名常显列表(文件名/类型/大小,点击切换);完成全代码审查修复(默认文案冻结、WE 宿主 stream error、低电量异步泄漏、bridge 节点清理、转码超时兜底、宿主同源栅栏收紧、聊天视口翻转)。 v1.6.5(公开 v1.0.4 正式版):修复桌宠「AI 对话」关不掉的问题——新增面板「×」关闭按钮、点空白关闭、全局 Esc 关闭、[hidden] 真正隐藏,并支持桌宠靠近屏幕底部时点桌宠直接退出(菜单被裁到视口外也能退出)。仅浏览器半,无宿主路由改动,Ctrl+F5 即可。 v1.6.6(公开 v1.0.5 正式版):修复 AI 对话面板在桌宠默认靠右位置时「×」关闭按钮被视口裁掉的问题(面板水平夹取进视口,拖拽/窗口缩放后重算),并把顶部翻转阈值改为按面板实际高度计算(新增按钮行后不再裁到顶部),略增大关闭按钮点击区域。仅浏览器半;版本常量变更,Ctrl+F5 + 重启 DSH 一次可消除宿主半 stale 提示。 v1.6.7(公开 v1.0.6 正式版):壁纸面板默认视图新增一等「URL 地址」「ShaderToy 代码」快捷来源(点击直达编辑器,并修复 URL/Shader 应用假成功与卡死);桌宠「AI 对话」收到回复即自动收起输入面板、只留气泡回复;新增「☰」对话历史(与 AI 对话相邻):可查看历史、开启新对话、编辑已发消息、删除对话,数据存本机 localStorage。仅浏览器半;版本常量变更,Ctrl+F5 + 重启 DSH 一次可消除宿主半 stale 提示。 v1.6.8(公开 v1.0.7 正式版):桌宠新增「自主思考」智能体——按间隔做内心独白、可自主开口(受既有主动开口预算约束),聊天回复融入最近对话/时段/记忆/当前想法更像人;角色中枢新增「自主思考」卡片(开关/间隔/自主开口/现在想一下/最近想法/清空)。不新增权限与网络通道,不驱动 DSH Agent;仅浏览器半,Ctrl+F5 即可;版本常量变更,重启 DSH 一次可消除宿主半 stale 提示。 v2.0.0:桌宠 AI 对话接入 DSH 自带 LLM(宿主路由 _pet-chat;默认跟随 DSH 默认模型,仍须在角色中枢两步授权 llm;不建会话、不调工具、60/日、6/分、1200 字、20s 超时;失败按稳定错误码提示);版本号统一为 2.0.0(仓库 / DSH 安装 / GitHub 发布同名同号);并入 v1.6.8 之后的体检修复批次(设置同步合并与冲突保护、宿主/桥接安全收口、统一浮层层序、壁纸切换与性能、可读性/低电量、导出导入一致性);默认演示素材精简为 bg-4k.mp4(H.264 4K)与 cat.png,bg-main.mp4 改为可选自备首选槽。本版改了宿主半:升级后必须重启 DSH 一次 + Ctrl+F5,之后纯浏览器半更新仍只需 Ctrl+F5。",
9
+ "tags": [
10
+ "shinkai",
11
+ "sky",
12
+ "video",
13
+ "wallpaper-engine",
14
+ "webwallgl",
15
+ "anime",
16
+ "mint",
17
+ "pet",
18
+ "role-pack",
19
+ "duty",
20
+ "life",
21
+ "liquid-glass",
22
+ "ai-pet",
23
+ "permissions",
24
+ "agent"
25
+ ],
26
+ "accent": "#3f8fe0",
27
+ "bodyAttr": "data-dsh-tianlight",
28
+ "dshCompatibility": "0.2.2rc1",
29
+ "dshCompatibilityRange": ">=0.2.0-rc.1 <0.2.1-0 || >=0.2.1-0 <0.2.2-0 || >=0.2.2-0 <0.3.0-0",
30
+ "dshCompatibilityTested": [
31
+ "0.2.0-rc.2",
32
+ "0.2.1-rc.3",
33
+ "0.2.1-rc.5",
34
+ "0.2.2-rc.1"
35
+ ],
36
+ "package": "dsh-client-ui-skin-tianlight",
37
+ "wiring": {
38
+ "id": "ui-skin-tianlight",
39
+ "bundleWired": true
40
+ },
41
+ "order": 30
42
+ }
@@ -1,21 +1,21 @@
1
- This is free and unencumbered software released into the public domain.
2
-
3
- Anyone is free to copy, modify, publish, use, compile, sell, or distribute
4
- this software, either in source code form or as a compiled binary, for any
5
- purpose, commercial or non-commercial, and by any means.
6
-
7
- In jurisdictions that recognize copyright laws, the author or authors of
8
- this software dedicate any and all copyright interest in the software to the
9
- public domain. We make this dedication for the benefit of the public at large
10
- and to the detriment of our heirs and successors. We intend this dedication
11
- to be an overt act of relinquishment in perpetuity of all present and future
12
- rights to this software under copyright law.
13
-
14
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17
- AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
18
- ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
19
- WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
20
-
21
- For more information, please refer to <https://unlicense.org>.
1
+ This is free and unencumbered software released into the public domain.
2
+
3
+ Anyone is free to copy, modify, publish, use, compile, sell, or distribute
4
+ this software, either in source code form or as a compiled binary, for any
5
+ purpose, commercial or non-commercial, and by any means.
6
+
7
+ In jurisdictions that recognize copyright laws, the author or authors of
8
+ this software dedicate any and all copyright interest in the software to the
9
+ public domain. We make this dedication for the benefit of the public at large
10
+ and to the detriment of our heirs and successors. We intend this dedication
11
+ to be an overt act of relinquishment in perpetuity of all present and future
12
+ rights to this software under copyright law.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17
+ AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
18
+ ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
19
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
20
+
21
+ For more information, please refer to <https://unlicense.org>.
@@ -1,99 +1,99 @@
1
- param(
2
- [Parameter(Mandatory = $true)][ValidateSet('monitor', 'present', 'restore')][string]$Action,
3
- [string]$Title = 'DSH-WE-Record',
4
- [int]$Width = 0,
5
- [int]$Height = 0
6
- )
7
-
8
- # Desktop presentation for scene-video capture:
9
- # monitor - print the primary monitor's physical pixel size ("WxH")
10
- # present - hide taskbars, force the Wallpaper Engine record window
11
- # borderless-fullscreen topmost, move the cursor to its centre
12
- # (wcap captures the window under the cursor)
13
- # restore - bring the taskbars back
14
- # Everything is best-effort and reversible; a capture that fails midway must
15
- # still call 'restore' so the user's desktop returns to normal.
16
-
17
- $ErrorActionPreference = 'Stop'
18
-
19
- Add-Type -TypeDefinition @'
20
- using System;
21
- using System.Runtime.InteropServices;
22
- using System.Text;
23
-
24
- public static class SceneCaptureDesktop {
25
- [DllImport("user32.dll")] public static extern bool SetProcessDPIAware();
26
- [DllImport("user32.dll")] public static extern int GetSystemMetrics(int index);
27
- [DllImport("user32.dll", CharSet = CharSet.Unicode)] public static extern IntPtr FindWindow(string className, string windowName);
28
- [DllImport("user32.dll")] public static extern bool ShowWindow(IntPtr hWnd, int command);
29
- [DllImport("user32.dll")] public static extern bool SetWindowPos(IntPtr hWnd, IntPtr after, int x, int y, int width, int height, uint flags);
30
- [DllImport("user32.dll")] public static extern bool SetForegroundWindow(IntPtr hWnd);
31
- [DllImport("user32.dll")] public static extern bool SetCursorPos(int x, int y);
32
- [DllImport("user32.dll")] public static extern bool IsWindowVisible(IntPtr hWnd);
33
- [DllImport("user32.dll", CharSet = CharSet.Unicode)] public static extern int GetWindowText(IntPtr hWnd, StringBuilder text, int maxCount);
34
- [DllImport("user32.dll")] public static extern bool EnumWindows(EnumWindowsProc callback, IntPtr lParam);
35
- public delegate bool EnumWindowsProc(IntPtr hWnd, IntPtr lParam);
36
-
37
- public static readonly IntPtr TopMost = new IntPtr(-1);
38
- public const uint ShowWindowFlag = 0x0040;
39
- public const uint KeepPositionFlag = 0x0002;
40
- public const uint KeepSizeFlag = 0x0001;
41
- }
42
- '@
43
-
44
- [SceneCaptureDesktop]::SetProcessDPIAware() | Out-Null
45
-
46
- function Get-TaskbarHandles {
47
- $handles = @()
48
- foreach ($className in @('Shell_TrayWnd', 'Shell_SecondaryTrayWnd')) {
49
- $handle = [SceneCaptureDesktop]::FindWindow($className, $null)
50
- if ($handle -ne [IntPtr]::Zero) { $handles += $handle }
51
- }
52
- return $handles
53
- }
54
-
55
- function Find-RecordWindow([string]$titlePart) {
56
- $script:found = [IntPtr]::Zero
57
- $callback = [SceneCaptureDesktop+EnumWindowsProc]{
58
- param([IntPtr]$hWnd, [IntPtr]$lParam)
59
- if (-not [SceneCaptureDesktop]::IsWindowVisible($hWnd)) { return $true }
60
- $text = New-Object System.Text.StringBuilder 1024
61
- [void][SceneCaptureDesktop]::GetWindowText($hWnd, $text, 1024)
62
- if ($text.ToString().Contains($titlePart)) {
63
- $script:found = $hWnd
64
- return $false
65
- }
66
- return $true
67
- }
68
- [void][SceneCaptureDesktop]::EnumWindows($callback, [IntPtr]::Zero)
69
- return $script:found
70
- }
71
-
72
- switch ($Action) {
73
- 'monitor' {
74
- # 0 = SM_CXSCREEN, 1 = SM_CYSCREEN (primary monitor, physical pixels
75
- # because the process is DPI-aware)
76
- Write-Output ("{0}x{1}" -f [SceneCaptureDesktop]::GetSystemMetrics(0), [SceneCaptureDesktop]::GetSystemMetrics(1))
77
- }
78
- 'present' {
79
- foreach ($handle in (Get-TaskbarHandles)) { [void][SceneCaptureDesktop]::ShowWindow($handle, 0) }
80
- $window = Find-RecordWindow $Title
81
- if ($window -eq [IntPtr]::Zero) { Write-Output 'window-not-found'; exit 2 }
82
- if ($Width -gt 0 -and $Height -gt 0) {
83
- [void][SceneCaptureDesktop]::SetWindowPos($window, [SceneCaptureDesktop]::TopMost, 0, 0, $Width, $Height, [SceneCaptureDesktop]::ShowWindowFlag)
84
- }
85
- else {
86
- $flags = [SceneCaptureDesktop]::KeepPositionFlag -bor [SceneCaptureDesktop]::KeepSizeFlag -bor [SceneCaptureDesktop]::ShowWindowFlag
87
- [void][SceneCaptureDesktop]::SetWindowPos($window, [SceneCaptureDesktop]::TopMost, 0, 0, 0, 0, $flags)
88
- }
89
- [void][SceneCaptureDesktop]::SetForegroundWindow($window)
90
- if ($Width -gt 0 -and $Height -gt 0) {
91
- [void][SceneCaptureDesktop]::SetCursorPos([int]($Width / 2), [int]($Height / 2))
92
- }
93
- Write-Output 'ok'
94
- }
95
- 'restore' {
96
- foreach ($handle in (Get-TaskbarHandles)) { [void][SceneCaptureDesktop]::ShowWindow($handle, 5) }
97
- Write-Output 'ok'
98
- }
99
- }
1
+ param(
2
+ [Parameter(Mandatory = $true)][ValidateSet('monitor', 'present', 'restore')][string]$Action,
3
+ [string]$Title = 'DSH-WE-Record',
4
+ [int]$Width = 0,
5
+ [int]$Height = 0
6
+ )
7
+
8
+ # Desktop presentation for scene-video capture:
9
+ # monitor - print the primary monitor's physical pixel size ("WxH")
10
+ # present - hide taskbars, force the Wallpaper Engine record window
11
+ # borderless-fullscreen topmost, move the cursor to its centre
12
+ # (wcap captures the window under the cursor)
13
+ # restore - bring the taskbars back
14
+ # Everything is best-effort and reversible; a capture that fails midway must
15
+ # still call 'restore' so the user's desktop returns to normal.
16
+
17
+ $ErrorActionPreference = 'Stop'
18
+
19
+ Add-Type -TypeDefinition @'
20
+ using System;
21
+ using System.Runtime.InteropServices;
22
+ using System.Text;
23
+
24
+ public static class SceneCaptureDesktop {
25
+ [DllImport("user32.dll")] public static extern bool SetProcessDPIAware();
26
+ [DllImport("user32.dll")] public static extern int GetSystemMetrics(int index);
27
+ [DllImport("user32.dll", CharSet = CharSet.Unicode)] public static extern IntPtr FindWindow(string className, string windowName);
28
+ [DllImport("user32.dll")] public static extern bool ShowWindow(IntPtr hWnd, int command);
29
+ [DllImport("user32.dll")] public static extern bool SetWindowPos(IntPtr hWnd, IntPtr after, int x, int y, int width, int height, uint flags);
30
+ [DllImport("user32.dll")] public static extern bool SetForegroundWindow(IntPtr hWnd);
31
+ [DllImport("user32.dll")] public static extern bool SetCursorPos(int x, int y);
32
+ [DllImport("user32.dll")] public static extern bool IsWindowVisible(IntPtr hWnd);
33
+ [DllImport("user32.dll", CharSet = CharSet.Unicode)] public static extern int GetWindowText(IntPtr hWnd, StringBuilder text, int maxCount);
34
+ [DllImport("user32.dll")] public static extern bool EnumWindows(EnumWindowsProc callback, IntPtr lParam);
35
+ public delegate bool EnumWindowsProc(IntPtr hWnd, IntPtr lParam);
36
+
37
+ public static readonly IntPtr TopMost = new IntPtr(-1);
38
+ public const uint ShowWindowFlag = 0x0040;
39
+ public const uint KeepPositionFlag = 0x0002;
40
+ public const uint KeepSizeFlag = 0x0001;
41
+ }
42
+ '@
43
+
44
+ [SceneCaptureDesktop]::SetProcessDPIAware() | Out-Null
45
+
46
+ function Get-TaskbarHandles {
47
+ $handles = @()
48
+ foreach ($className in @('Shell_TrayWnd', 'Shell_SecondaryTrayWnd')) {
49
+ $handle = [SceneCaptureDesktop]::FindWindow($className, $null)
50
+ if ($handle -ne [IntPtr]::Zero) { $handles += $handle }
51
+ }
52
+ return $handles
53
+ }
54
+
55
+ function Find-RecordWindow([string]$titlePart) {
56
+ $script:found = [IntPtr]::Zero
57
+ $callback = [SceneCaptureDesktop+EnumWindowsProc]{
58
+ param([IntPtr]$hWnd, [IntPtr]$lParam)
59
+ if (-not [SceneCaptureDesktop]::IsWindowVisible($hWnd)) { return $true }
60
+ $text = New-Object System.Text.StringBuilder 1024
61
+ [void][SceneCaptureDesktop]::GetWindowText($hWnd, $text, 1024)
62
+ if ($text.ToString().Contains($titlePart)) {
63
+ $script:found = $hWnd
64
+ return $false
65
+ }
66
+ return $true
67
+ }
68
+ [void][SceneCaptureDesktop]::EnumWindows($callback, [IntPtr]::Zero)
69
+ return $script:found
70
+ }
71
+
72
+ switch ($Action) {
73
+ 'monitor' {
74
+ # 0 = SM_CXSCREEN, 1 = SM_CYSCREEN (primary monitor, physical pixels
75
+ # because the process is DPI-aware)
76
+ Write-Output ("{0}x{1}" -f [SceneCaptureDesktop]::GetSystemMetrics(0), [SceneCaptureDesktop]::GetSystemMetrics(1))
77
+ }
78
+ 'present' {
79
+ foreach ($handle in (Get-TaskbarHandles)) { [void][SceneCaptureDesktop]::ShowWindow($handle, 0) }
80
+ $window = Find-RecordWindow $Title
81
+ if ($window -eq [IntPtr]::Zero) { Write-Output 'window-not-found'; exit 2 }
82
+ if ($Width -gt 0 -and $Height -gt 0) {
83
+ [void][SceneCaptureDesktop]::SetWindowPos($window, [SceneCaptureDesktop]::TopMost, 0, 0, $Width, $Height, [SceneCaptureDesktop]::ShowWindowFlag)
84
+ }
85
+ else {
86
+ $flags = [SceneCaptureDesktop]::KeepPositionFlag -bor [SceneCaptureDesktop]::KeepSizeFlag -bor [SceneCaptureDesktop]::ShowWindowFlag
87
+ [void][SceneCaptureDesktop]::SetWindowPos($window, [SceneCaptureDesktop]::TopMost, 0, 0, 0, 0, $flags)
88
+ }
89
+ [void][SceneCaptureDesktop]::SetForegroundWindow($window)
90
+ if ($Width -gt 0 -and $Height -gt 0) {
91
+ [void][SceneCaptureDesktop]::SetCursorPos([int]($Width / 2), [int]($Height / 2))
92
+ }
93
+ Write-Output 'ok'
94
+ }
95
+ 'restore' {
96
+ foreach ($handle in (Get-TaskbarHandles)) { [void][SceneCaptureDesktop]::ShowWindow($handle, 5) }
97
+ Write-Output 'ok'
98
+ }
99
+ }
@@ -1,24 +1,24 @@
1
- Add-Type -TypeDefinition @'
2
- using System;
3
- using System.Runtime.InteropServices;
4
-
5
- public static class WcapHotkey {
6
- [DllImport("user32.dll")]
7
- private static extern void keybd_event(byte key, byte scan, uint flags, UIntPtr extraInfo);
8
-
9
- public static void Send() {
10
- const uint KeyUp = 0x0002;
11
- const byte Control = 0x11;
12
- const byte LeftWindows = 0x5B;
13
- const byte PrintScreen = 0x2C;
14
- keybd_event(Control, 0, 0, UIntPtr.Zero);
15
- keybd_event(LeftWindows, 0, 0, UIntPtr.Zero);
16
- keybd_event(PrintScreen, 0, 0, UIntPtr.Zero);
17
- keybd_event(PrintScreen, 0, KeyUp, UIntPtr.Zero);
18
- keybd_event(LeftWindows, 0, KeyUp, UIntPtr.Zero);
19
- keybd_event(Control, 0, KeyUp, UIntPtr.Zero);
20
- }
21
- }
22
- '@
23
-
24
- [WcapHotkey]::Send()
1
+ Add-Type -TypeDefinition @'
2
+ using System;
3
+ using System.Runtime.InteropServices;
4
+
5
+ public static class WcapHotkey {
6
+ [DllImport("user32.dll")]
7
+ private static extern void keybd_event(byte key, byte scan, uint flags, UIntPtr extraInfo);
8
+
9
+ public static void Send() {
10
+ const uint KeyUp = 0x0002;
11
+ const byte Control = 0x11;
12
+ const byte LeftWindows = 0x5B;
13
+ const byte PrintScreen = 0x2C;
14
+ keybd_event(Control, 0, 0, UIntPtr.Zero);
15
+ keybd_event(LeftWindows, 0, 0, UIntPtr.Zero);
16
+ keybd_event(PrintScreen, 0, 0, UIntPtr.Zero);
17
+ keybd_event(PrintScreen, 0, KeyUp, UIntPtr.Zero);
18
+ keybd_event(LeftWindows, 0, KeyUp, UIntPtr.Zero);
19
+ keybd_event(Control, 0, KeyUp, UIntPtr.Zero);
20
+ }
21
+ }
22
+ '@
23
+
24
+ [WcapHotkey]::Send()