dsh-deepseek-style-theme 1.43.10 → 1.43.12

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 (2) hide show
  1. package/lib/client.js +2046 -26
  2. package/package.json +1 -1
package/lib/client.js CHANGED
@@ -1,6 +1,22 @@
1
+ // The loader requires this bundle to register itself under the id the host asked
2
+ // for, and that id is the package NAME of whichever copy is installed -- which is
3
+ // not one value during a rename. The package moved from
4
+ // @dsh-external/dsh-deepseek-style-theme to the unscoped dsh-deepseek-style-theme
5
+ // in 1.43.1, so a profile installed before the rename asks for the old id and one
6
+ // installed after asks for the new one. A single hard-coded literal therefore
7
+ // breaks whichever half it does not match, and BOTH directions were hit for real,
8
+ // one machine each:
9
+ //
10
+ // literal old, install new -> "loaded without registering \"dsh-deepseek-style-theme\""
11
+ // literal new, install old -> "loaded without registering \"@dsh-external/...\""
12
+ //
13
+ // So register under BOTH ids with the same factory: the loader finds the one it
14
+ // wants and the other entry is simply never asked for. The registrations are
15
+ // guarded individually because a loader might reject an id it did not request,
16
+ // and that must not take the working one down with it.
1
17
  const dshDeepseekStyleThemeFactory = (require) => {
2
- var module = { exports: {} };
3
- var exports = module.exports;
18
+ var module = { exports: {} };
19
+ var exports = module.exports;
4
20
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
5
21
  const React = require("react");
6
22
 
@@ -26,6 +42,952 @@ const dshDeepseekStyleThemeFactory = (require) => {
26
42
  // interpolated value there would be DOM XSS.
27
43
  const PLUGIN_ID = "dsh-deepseek-style-theme";
28
44
 
45
+ // ─── fluid background + liquid-glass refraction ───────────────────────
46
+ // Ported from dsh-theme-mineradio v2.3.8 (MIT, Copyright (c) 2026 John Wu).
47
+ // See the licence header on the block below; the notice must be preserved.
48
+ // ─────────────────────────────────────────────────────────────────────────────
49
+ // deepseek-style-theme — fluid shader + glass dispersion port
50
+ //
51
+ // The fluid shader (GLSL programs, the WebGL2 ping-pong fluid solver, the
52
+ // pointer/click interaction feeds) and the glass chromatic-dispersion filter
53
+ // plus the specular-highlight cursor parallax below are ported from
54
+ // `dsh-theme-mineradio` v2.3.8 — MIT, Copyright (c) 2026 John Wu.
55
+ // The upstream MIT licence notice MUST be preserved wherever this code ships.
56
+ //
57
+ // Only naming and external dependencies were adapted; the three GLSL shader
58
+ // sources (VERTEX_SHADER / FLOW_SHADER / DISPLAY_SHADER) are byte-for-byte
59
+ // copies of upstream, including `#version 300 es`, every precision qualifier
60
+ // and every in-shader comment.
61
+ //
62
+ // External dependencies found in the upstream module and what was done:
63
+ //
64
+ // INLINED VERBATIM (they sit outside the ported ranges upstream and are
65
+ // small pure helpers the ported code cannot run without):
66
+ // • `uv(canvas, clientX, clientY)` — upstream fluid-interactions.ts
67
+ // line 916, used by
68
+ // attachFluidInteractions.
69
+ // • `hslToRgb01(h, s, l)` — upstream glass-dispersion.ts
70
+ // line 2409, used by tintMatrix.
71
+ // • `filterMarkup(id, refractId, tintId, map)` — upstream glass-dispersion.ts
72
+ // line 2443, used by
73
+ // startGlassDispersion to build
74
+ // the SVG <filter> pair.
75
+ // • `closestSpot(target)`, `visualRect(spot)`,
76
+ // `inside(visual, clientX, clientY)` — upstream spot-core.ts
77
+ // lines 1711-1732, used by
78
+ // startSpecularParallax.
79
+ //
80
+ // CONSTANTS TAKEN FROM ADJACENT UPSTREAM DECLARATIONS (needed to make the
81
+ // requested subset self-contained; upstream declares them beside it):
82
+ // • TINT_ID / REFRACT_ID / TALL_FILTER_ID / TALL_TINT_ID /
83
+ // TALL_REFRACT_ID / DEFAULT_REF_SCALE / EDGE_DX / TINT_SAT / TINT_LIGHT
84
+ // — values unchanged, only FILTER_ID's value renamed.
85
+ // • SPOT_ATTR / SPOT_SELECTOR (upstream spot-core.ts lines 1707-1710)
86
+ // — renamed to the `dshome-` prefix.
87
+ //
88
+ // RENAMED (no longer refers to the upstream plugin):
89
+ // • FILTER_ID "mineradio-glass-dispersion" → "dshome-glass-dispersion"
90
+ // • every other SVG filter/tint/refract id → "dshome-glass-dispersion-*"
91
+ // • ATTR "data-dsh-dispersion" → "data-dshome-dispersion"
92
+ // • SPOT_ATTR "data-dsh-aqua-spot" → "data-dshome-spot"
93
+ // • SPEC_X / SPEC_Y --dsh-aqua-spec-x/y → --dshome-spec-x/y
94
+ // • console tags "ui-aqua fluid shader" / "ui-aqua fluid link" →
95
+ // "deepseek-style-theme fluid shader" /
96
+ // "deepseek-style-theme fluid link"
97
+ //
98
+ // DELIBERATELY NOT PORTED (upstream settings/theme-store/React layer). Each
99
+ // was replaced by a parameter or a local default:
100
+ // • `this.settings.dispersionHue` (dispersionTintHue()) — upstream read the
101
+ // user's hue knob and an extracted-wallpaper hue. REPLACED by the `hue`
102
+ // argument of startGlassDispersion({ hue }), defaulting to the upstream
103
+ // default DEFAULT_TINT_HUE = 44. The caller owns the hue source.
104
+ // • `this.settings.dispersionRefract` — upstream called
105
+ // handle.setRefraction(n) on every settings change. The caller now calls
106
+ // the returned handle's setRefraction(n) itself.
107
+ // • `this.settings.fluidHue` / `fluidDepth` / `rainbow` / `stationOffset`
108
+ // and the helper `fluidToneColors()` (upstream line 125) plus
109
+ // `HUE_BASE` — NONE of these are ported. attachFluidShader takes a
110
+ // complete params object; SITE_FLUID_PARAMS is exported as the upstream
111
+ // default (its own three palette colours), so the caller supplies its
112
+ // own palette by spreading SITE_FLUID_PARAMS and overriding color1..3.
113
+ // • `this.settings.audioReact` / the mic analyser (createAudioReactivity)
114
+ // — not ported. The audio coupling survives as the ported handle method
115
+ // `setAudioLow(level)`; the caller feeds it, or ignores it.
116
+ // • upstream's React component and the `[data-dsh-aqua-fluid-canvas]` /
117
+ // `[data-dsh-aqua-ambient]` mount lookups — the caller passes the canvas
118
+ // element and the { main, mainCanvas } handle explicitly.
119
+ //
120
+ // DOM hooks the ported code still reads (product/platform markup, intentionally
121
+ // NOT renamed): `[data-composer-card]` and `[data-dsh-stats]` inside
122
+ // visualRect(), and the `button` closest-match in attachFluidInteractions.
123
+ //
124
+ // Indentation note: this fragment is tab-indented at a base of 2 tabs to match
125
+ // the target factory body. Line indentation INSIDE the three GLSL template
126
+ // literals is string data and was left exactly as upstream, per the verbatim
127
+ // requirement; tab-indenting those lines would have altered the shipped shader
128
+ // text.
129
+ // ─────────────────────────────────────────────────────────────────────────────
130
+
131
+ var SITE_FLUID_PARAMS = {
132
+ mouseRadius: 0.22,
133
+ mouseStrength: 1.1,
134
+ decay: 0.96,
135
+ distortBoost: 1.35,
136
+ noiseBoost: 0,
137
+ swirlBoost: 0.45,
138
+ speed: 14,
139
+ distortion: 20,
140
+ swirl: 12,
141
+ swirlIterations: 8,
142
+ scale: 0.5,
143
+ rotation: -5,
144
+ proportion: 50,
145
+ softness: 100,
146
+ shapeScale: 10,
147
+ offsetX: 0,
148
+ offsetY: 65,
149
+ color1: "#8AA3D6",
150
+ color2: "#FFFFFF",
151
+ color3: "#FFFFFF"
152
+ };
153
+ var VERTEX_SHADER = `#version 300 es
154
+ in vec4 a_position;
155
+ out vec2 vUv;
156
+ void main() {
157
+ vUv = a_position.xy * 0.5 + 0.5;
158
+ gl_Position = a_position;
159
+ }
160
+ `;
161
+ var FLOW_SHADER = `#version 300 es
162
+ precision mediump float;
163
+ in vec2 vUv;
164
+ uniform sampler2D u_prev;
165
+ uniform vec2 u_mouse;
166
+ uniform vec2 u_velocity;
167
+ uniform float u_brushRadius;
168
+ uniform float u_brushStrength;
169
+ uniform float u_decay;
170
+ out vec4 fragColor;
171
+
172
+ void main() {
173
+ vec4 prev = texture(u_prev, vUv);
174
+
175
+ prev.r *= u_decay;
176
+ prev.gb = mix(vec2(0.5), prev.gb, u_decay);
177
+
178
+ float dist = distance(vUv, u_mouse);
179
+
180
+ float influence = exp(-dist * dist / (u_brushRadius * u_brushRadius * 0.5));
181
+ influence = max(0.0, influence - 0.01);
182
+
183
+ float speed = length(u_velocity);
184
+ float presenceStrength = u_brushStrength * 0.3;
185
+ float velBonus = min(speed * 3.0, 0.7) * u_brushStrength;
186
+ float totalStrength = presenceStrength + velBonus;
187
+
188
+ prev.r = max(prev.r, influence * totalStrength);
189
+ float blendAmt = influence * min(totalStrength, 0.4) * 0.3;
190
+ prev.g = mix(prev.g, clamp(u_velocity.x * 2.0 + 0.5, 0.0, 1.0), blendAmt);
191
+ prev.b = mix(prev.b, clamp(u_velocity.y * 2.0 + 0.5, 0.0, 1.0), blendAmt);
192
+
193
+ fragColor = prev;
194
+ }
195
+ `;
196
+ var DISPLAY_SHADER = `#version 300 es
197
+ precision mediump float;
198
+ in vec2 vUv;
199
+ uniform float u_time;
200
+ uniform float u_pixelRatio;
201
+ uniform vec2 u_resolution;
202
+ uniform float u_scale;
203
+ uniform float u_rotation;
204
+ uniform vec4 u_color1, u_color2, u_color3;
205
+ uniform float u_colorCount;
206
+ uniform float u_proportion;
207
+ uniform float u_softness;
208
+ uniform float u_shape;
209
+ uniform float u_shapeScale;
210
+ uniform float u_distortion;
211
+ uniform float u_swirl;
212
+ uniform float u_swirlIterations;
213
+ uniform vec2 u_offset;
214
+ uniform sampler2D u_flowmap;
215
+ uniform float u_distortBoost;
216
+ uniform float u_noiseBoost;
217
+ uniform float u_swirlBoost;
218
+ out vec4 fragColor;
219
+
220
+ #define TWO_PI 6.28318530718
221
+ #define PI 3.14159265358979323846
222
+
223
+ vec2 rotate(vec2 uv, float th) { return mat2(cos(th), sin(th), -sin(th), cos(th)) * uv; }
224
+ float random(vec2 st) { return fract(sin(dot(st.xy, vec2(12.9898, 78.233))) * 43758.5453123); }
225
+ float noise(vec2 st) {
226
+ vec2 i = floor(st); vec2 f = fract(st);
227
+ float a = random(i), b = random(i + vec2(1,0)), c = random(i + vec2(0,1)), d = random(i + vec2(1,1));
228
+ vec2 u = f*f*(3.0-2.0*f);
229
+ return mix(mix(a,b,u.x), mix(c,d,u.x), u.y);
230
+ }
231
+
232
+ vec3 blend_multi(float mixer, float softness) {
233
+ float edge = 1.0 - softness;
234
+ vec3 col = u_color1.rgb;
235
+ if (u_colorCount > 1.5) { col = mix(col, u_color2.rgb, smoothstep(0.0 + 0.35*edge, 0.7 - 0.35*edge, mixer)); }
236
+ if (u_colorCount > 2.5) { col = mix(col, u_color3.rgb, smoothstep(0.3 + 0.35*edge, 1.0 - 0.35*edge, mixer)); }
237
+ return col;
238
+ }
239
+
240
+ void main() {
241
+ vec2 uv = gl_FragCoord.xy / u_resolution.xy;
242
+ float t = .5 * u_time;
243
+ float ns = .0005 + .006 * u_scale;
244
+ uv -= .5; uv *= (ns * u_resolution); uv = rotate(uv, u_rotation * .5 * PI);
245
+ uv /= u_pixelRatio; uv += .5; uv += u_offset;
246
+
247
+ vec2 fragUV = gl_FragCoord.xy / u_resolution.xy;
248
+ vec4 flow = texture(u_flowmap, fragUV);
249
+ float influence = flow.r;
250
+ vec2 flowDir = (flow.gb - 0.5) * 2.0;
251
+
252
+ float n1 = noise(uv + t), n2 = noise(uv*2. - t);
253
+ float angle = n1 * TWO_PI;
254
+
255
+ float totalDistortion = u_distortion + influence * u_distortBoost;
256
+ uv.x += 4. * totalDistortion * n2 * cos(angle);
257
+ uv.y += 4. * totalDistortion * n2 * sin(angle);
258
+
259
+ uv += flowDir * influence * 0.15;
260
+
261
+ if (influence > 0.001) {
262
+ float localNoise = noise(uv * 2.0 + t * 1.5);
263
+ uv += influence * u_noiseBoost * vec2(cos(localNoise * TWO_PI), sin(localNoise * TWO_PI));
264
+ }
265
+
266
+ float iters = ceil(clamp(u_swirlIterations, 1., 30.));
267
+ float swirlAmt = clamp(u_swirl, 0., 2.) + influence * u_swirlBoost;
268
+ for (float i = 1.; i <= 30.0; i++) {
269
+ if (i > iters) break;
270
+ uv.x += swirlAmt / i * cos(t + i*1.5*uv.y);
271
+ uv.y += swirlAmt / i * cos(t + i*1.*uv.x);
272
+ }
273
+
274
+ float proportion = clamp(u_proportion, 0., 1.);
275
+ vec2 cuv = uv * (.5 + 3.5 * u_shapeScale);
276
+ float shape = .5 + .5 * sin(cuv.x) * cos(cuv.y);
277
+ float mixer = shape + .48 * sign(proportion - .5) * pow(abs(proportion - .5), .5);
278
+ vec3 col = blend_multi(mixer, clamp(u_softness, 0., 1.));
279
+ fragColor = vec4(col, 1.0);
280
+ }
281
+ `;
282
+ function hexToRgb(value) {
283
+ const hex = value.replace("#", "");
284
+ return [
285
+ parseInt(hex.slice(0, 2), 16) / 255,
286
+ parseInt(hex.slice(2, 4), 16) / 255,
287
+ parseInt(hex.slice(4, 6), 16) / 255
288
+ ];
289
+ }
290
+ function attachFluidShader(canvas, params) {
291
+ const gl = canvas.getContext("webgl2", {
292
+ alpha: true,
293
+ premultipliedAlpha: false,
294
+ powerPreference: "low-power"
295
+ });
296
+ if (gl === null) {
297
+ return {
298
+ setParams: () => {
299
+ },
300
+ stir: () => {
301
+ },
302
+ setAudioLow: () => {
303
+ },
304
+ setRunning: () => {
305
+ },
306
+ dispose: () => {
307
+ }
308
+ };
309
+ }
310
+ const compile = (type, source) => {
311
+ const shader = gl.createShader(type);
312
+ if (shader === null) return null;
313
+ gl.shaderSource(shader, source);
314
+ gl.compileShader(shader);
315
+ if (!gl.getShaderParameter(shader, gl.COMPILE_STATUS)) {
316
+ console.error("deepseek-style-theme fluid shader:", gl.getShaderInfoLog(shader));
317
+ return null;
318
+ }
319
+ return shader;
320
+ };
321
+ const link = (fragment) => {
322
+ const vertex = compile(gl.VERTEX_SHADER, VERTEX_SHADER);
323
+ const frag = compile(gl.FRAGMENT_SHADER, fragment);
324
+ if (vertex === null || frag === null) return null;
325
+ const program = gl.createProgram();
326
+ if (program === null) return null;
327
+ gl.attachShader(program, vertex);
328
+ gl.attachShader(program, frag);
329
+ gl.linkProgram(program);
330
+ if (!gl.getProgramParameter(program, gl.LINK_STATUS)) {
331
+ console.error("deepseek-style-theme fluid link:", gl.getProgramInfoLog(program));
332
+ return null;
333
+ }
334
+ return program;
335
+ };
336
+ const flowProgram = link(FLOW_SHADER);
337
+ const displayProgram = link(DISPLAY_SHADER);
338
+ if (flowProgram === null || displayProgram === null) {
339
+ return {
340
+ setParams: () => {
341
+ },
342
+ stir: () => {
343
+ },
344
+ setAudioLow: () => {
345
+ },
346
+ setRunning: () => {
347
+ },
348
+ dispose: () => {
349
+ }
350
+ };
351
+ }
352
+ const flow = {
353
+ prev: gl.getUniformLocation(flowProgram, "u_prev"),
354
+ mouse: gl.getUniformLocation(flowProgram, "u_mouse"),
355
+ velocity: gl.getUniformLocation(flowProgram, "u_velocity"),
356
+ brushRadius: gl.getUniformLocation(flowProgram, "u_brushRadius"),
357
+ brushStrength: gl.getUniformLocation(flowProgram, "u_brushStrength"),
358
+ decay: gl.getUniformLocation(flowProgram, "u_decay")
359
+ };
360
+ const display = {
361
+ time: gl.getUniformLocation(displayProgram, "u_time"),
362
+ pixelRatio: gl.getUniformLocation(displayProgram, "u_pixelRatio"),
363
+ resolution: gl.getUniformLocation(displayProgram, "u_resolution"),
364
+ scale: gl.getUniformLocation(displayProgram, "u_scale"),
365
+ rotation: gl.getUniformLocation(displayProgram, "u_rotation"),
366
+ offset: gl.getUniformLocation(displayProgram, "u_offset"),
367
+ color1: gl.getUniformLocation(displayProgram, "u_color1"),
368
+ color2: gl.getUniformLocation(displayProgram, "u_color2"),
369
+ color3: gl.getUniformLocation(displayProgram, "u_color3"),
370
+ colorCount: gl.getUniformLocation(displayProgram, "u_colorCount"),
371
+ proportion: gl.getUniformLocation(displayProgram, "u_proportion"),
372
+ softness: gl.getUniformLocation(displayProgram, "u_softness"),
373
+ shape: gl.getUniformLocation(displayProgram, "u_shape"),
374
+ shapeScale: gl.getUniformLocation(displayProgram, "u_shapeScale"),
375
+ distortion: gl.getUniformLocation(displayProgram, "u_distortion"),
376
+ swirl: gl.getUniformLocation(displayProgram, "u_swirl"),
377
+ swirlIterations: gl.getUniformLocation(displayProgram, "u_swirlIterations"),
378
+ flowmap: gl.getUniformLocation(displayProgram, "u_flowmap"),
379
+ distortBoost: gl.getUniformLocation(displayProgram, "u_distortBoost"),
380
+ noiseBoost: gl.getUniformLocation(displayProgram, "u_noiseBoost"),
381
+ swirlBoost: gl.getUniformLocation(displayProgram, "u_swirlBoost")
382
+ };
383
+ const quadBuffer = gl.createBuffer();
384
+ gl.bindBuffer(gl.ARRAY_BUFFER, quadBuffer);
385
+ gl.bufferData(gl.ARRAY_BUFFER, new Float32Array([-1, -1, 1, -1, -1, 1, 1, 1]), gl.STATIC_DRAW);
386
+ const bindQuad = (program) => {
387
+ const position = gl.getAttribLocation(program, "a_position");
388
+ gl.bindBuffer(gl.ARRAY_BUFFER, quadBuffer);
389
+ gl.enableVertexAttribArray(position);
390
+ gl.vertexAttribPointer(position, 2, gl.FLOAT, false, 0, 0);
391
+ };
392
+ const makeTarget = (width2, height2, initial2) => {
393
+ const tex = gl.createTexture();
394
+ if (tex === null) throw new Error("deepseek-style-theme fluid: texture allocation failed");
395
+ gl.bindTexture(gl.TEXTURE_2D, tex);
396
+ if (initial2 !== void 0) {
397
+ gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, width2, height2, 0, gl.RGBA, gl.UNSIGNED_BYTE, initial2);
398
+ } else {
399
+ gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, width2, height2, 0, gl.RGBA, gl.UNSIGNED_BYTE, null);
400
+ }
401
+ gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.LINEAR);
402
+ gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, gl.LINEAR);
403
+ gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE);
404
+ gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE);
405
+ const fbo = gl.createFramebuffer();
406
+ gl.bindFramebuffer(gl.FRAMEBUFFER, fbo);
407
+ gl.framebufferTexture2D(gl.FRAMEBUFFER, gl.COLOR_ATTACHMENT0, gl.TEXTURE_2D, tex, 0);
408
+ gl.bindFramebuffer(gl.FRAMEBUFFER, null);
409
+ return { fbo, tex };
410
+ };
411
+ let width = 0;
412
+ let height = 0;
413
+ let flowWidth = 0;
414
+ let flowHeight = 0;
415
+ let flip = false;
416
+ let current = { ...params };
417
+ let audioLow = 0;
418
+ const pointer = { x: 0.5, y: 0.5, smoothX: 0.5, smoothY: 0.5, vx: 0, vy: 0, svx: 0, svy: 0 };
419
+ const dprCap = Math.min(window.devicePixelRatio || 1, 1.5);
420
+ width = Math.round(canvas.clientWidth * dprCap);
421
+ height = Math.round(canvas.clientHeight * dprCap);
422
+ canvas.width = width;
423
+ canvas.height = height;
424
+ flowWidth = Math.round(width / 4);
425
+ flowHeight = Math.round(height / 4);
426
+ const initial = new Uint8Array(flowWidth * flowHeight * 4);
427
+ for (let i = 0; i < flowWidth * flowHeight; i += 1) {
428
+ initial[4 * i] = 0;
429
+ initial[4 * i + 1] = 128;
430
+ initial[4 * i + 2] = 128;
431
+ initial[4 * i + 3] = 255;
432
+ }
433
+ let targetA = makeTarget(flowWidth, flowHeight, initial);
434
+ let targetB = makeTarget(flowWidth, flowHeight, initial);
435
+ const coarse = window.matchMedia("(hover: none), (pointer: coarse)").matches;
436
+ const ua = navigator;
437
+ const windows = ua.userAgentData ? ua.userAgentData.platform === "Windows" : navigator.userAgent.includes("Windows");
438
+ const onMouseMove = (event) => {
439
+ const rect = canvas.getBoundingClientRect();
440
+ pointer.x = (event.clientX - rect.left) / rect.width;
441
+ pointer.y = 1 - (event.clientY - rect.top) / rect.height;
442
+ };
443
+ // Local adaptation: upstream always feeds the cursor into the flow field
444
+ // (except on touch and Windows). DSTT gates it behind its own
445
+ // `fluidBrush` setting, which ships OFF — the brush is the most
446
+ // expensive part of the simulation and leaves a visible wake trailing
447
+ // the pointer across the whole background.
448
+ if (!coarse && !windows && params.mouseFeed !== false) window.addEventListener("mousemove", onMouseMove);
449
+ const start = performance.now();
450
+ let raf = 0;
451
+ let running = false;
452
+ let previous = 0;
453
+ const step = 1e3 / 30;
454
+ const frame = (now) => {
455
+ raf = requestAnimationFrame(frame);
456
+ if (now - previous < step) return;
457
+ previous = now - (now - previous) % step;
458
+ const ratio = Math.min(window.devicePixelRatio || 1, 1.5);
459
+ const nextWidth = Math.round(canvas.clientWidth * ratio);
460
+ const nextHeight = Math.round(canvas.clientHeight * ratio);
461
+ if (nextWidth > 0 && nextHeight > 0 && (nextWidth !== width || nextHeight !== height)) {
462
+ width = nextWidth;
463
+ height = nextHeight;
464
+ canvas.width = width;
465
+ canvas.height = height;
466
+ }
467
+ const p = current;
468
+ const s = pointer;
469
+ s.svx *= 0.94;
470
+ s.svy *= 0.94;
471
+ s.smoothX += (s.x - s.smoothX) * 0.12;
472
+ s.smoothY += (s.y - s.smoothY) * 0.12;
473
+ s.svx += ((s.x - s.smoothX) * 0.5 - s.svx) * 0.15;
474
+ s.svy += ((s.y - s.smoothY) * 0.5 - s.svy) * 0.15;
475
+ const read = flip ? targetA : targetB;
476
+ const write = flip ? targetB : targetA;
477
+ flip = !flip;
478
+ gl.bindFramebuffer(gl.FRAMEBUFFER, write.fbo);
479
+ gl.viewport(0, 0, flowWidth, flowHeight);
480
+ gl.useProgram(flowProgram);
481
+ bindQuad(flowProgram);
482
+ gl.activeTexture(gl.TEXTURE0);
483
+ gl.bindTexture(gl.TEXTURE_2D, read.tex);
484
+ gl.uniform1i(flow.prev, 0);
485
+ gl.uniform2f(flow.mouse, s.smoothX, s.smoothY);
486
+ gl.uniform2f(flow.velocity, s.svx, s.svy);
487
+ gl.uniform1f(flow.brushRadius, p.mouseRadius);
488
+ gl.uniform1f(flow.brushStrength, p.mouseStrength);
489
+ gl.uniform1f(flow.decay, p.decay);
490
+ gl.drawArrays(gl.TRIANGLE_STRIP, 0, 4);
491
+ gl.bindFramebuffer(gl.FRAMEBUFFER, null);
492
+ gl.viewport(0, 0, width, height);
493
+ gl.useProgram(displayProgram);
494
+ bindQuad(displayProgram);
495
+ gl.activeTexture(gl.TEXTURE0);
496
+ gl.bindTexture(gl.TEXTURE_2D, write.tex);
497
+ gl.uniform1i(display.flowmap, 0);
498
+ const time = (performance.now() - start) * 1e-3 * (p.speed * (1 + audioLow * 1.3) / 100);
499
+ gl.uniform1f(display.time, time);
500
+ gl.uniform1f(display.pixelRatio, window.devicePixelRatio || 1);
501
+ gl.uniform2f(display.resolution, width, height);
502
+ gl.uniform1f(display.scale, p.scale);
503
+ gl.uniform1f(display.rotation, p.rotation / 90);
504
+ gl.uniform2f(display.offset, p.offsetX / 100, p.offsetY / 100);
505
+ const c1 = hexToRgb(p.color1 || "#2E58A4");
506
+ const c2 = hexToRgb(p.color2 || "#D2E2EE");
507
+ const c3 = hexToRgb(p.color3 || "#FFFFFF");
508
+ gl.uniform4f(display.color1, c1[0], c1[1], c1[2], 1);
509
+ gl.uniform4f(display.color2, c2[0], c2[1], c2[2], 1);
510
+ gl.uniform4f(display.color3, c3[0], c3[1], c3[2], 1);
511
+ gl.uniform1f(display.colorCount, 3);
512
+ gl.uniform1f(display.proportion, p.proportion / 100);
513
+ gl.uniform1f(display.softness, p.softness / 100);
514
+ gl.uniform1f(display.shape, 0);
515
+ gl.uniform1f(display.shapeScale, p.shapeScale / 100);
516
+ gl.uniform1f(display.distortion, p.distortion / 100);
517
+ gl.uniform1f(display.swirl, p.swirl / 50);
518
+ gl.uniform1f(display.swirlIterations, p.swirlIterations);
519
+ gl.uniform1f(display.distortBoost, p.distortBoost * (1 + audioLow * 0.85));
520
+ gl.uniform1f(display.noiseBoost, p.noiseBoost);
521
+ gl.uniform1f(display.swirlBoost, p.swirlBoost * (1 + audioLow * 0.6));
522
+ gl.drawArrays(gl.TRIANGLE_STRIP, 0, 4);
523
+ };
524
+ const handle = {
525
+ setParams: (next) => {
526
+ current = { ...next };
527
+ if (!running) {
528
+ frame(performance.now());
529
+ cancelAnimationFrame(raf);
530
+ }
531
+ },
532
+ stir: (x, y, vx, vy) => {
533
+ pointer.x += (x - pointer.x) * 0.35;
534
+ pointer.y += (y - pointer.y) * 0.35;
535
+ pointer.svx += (vx - pointer.svx) * 0.3;
536
+ pointer.svy += (vy - pointer.svy) * 0.3;
537
+ },
538
+ setAudioLow: (level) => {
539
+ audioLow = Math.max(0, Math.min(1, level));
540
+ },
541
+ setRunning: (on) => {
542
+ if (on) {
543
+ if (running) return;
544
+ running = true;
545
+ previous = 0;
546
+ raf = requestAnimationFrame(frame);
547
+ return;
548
+ }
549
+ if (!running) return;
550
+ running = false;
551
+ cancelAnimationFrame(raf);
552
+ },
553
+ dispose: () => {
554
+ cancelAnimationFrame(raf);
555
+ window.removeEventListener("mousemove", onMouseMove);
556
+ }
557
+ };
558
+ if (window.matchMedia("(prefers-reduced-motion: reduce)").matches) {
559
+ frame(performance.now());
560
+ cancelAnimationFrame(raf);
561
+ return handle;
562
+ }
563
+ running = true;
564
+ raf = requestAnimationFrame(frame);
565
+ return handle;
566
+ }
567
+
568
+ // Inlined from upstream `src/client/fluid-interactions.ts` (line 916):
569
+ // canvas-relative pointer position, flipped to GL bottom-left origin.
570
+ function uv(canvas, clientX, clientY) {
571
+ const rect = canvas.getBoundingClientRect();
572
+ return {
573
+ x: rect.width <= 0 ? 0.5 : (clientX - rect.left) / rect.width,
574
+ y: rect.height <= 0 ? 0.5 : 1 - (clientY - rect.top) / rect.height
575
+ };
576
+ }
577
+ function attachFluidInteractions(targets) {
578
+ const { main, mainCanvas } = targets;
579
+ const lastStir = /* @__PURE__ */ new WeakMap();
580
+ const ripples = /* @__PURE__ */ new Set();
581
+ const stirButton = (button, strength) => {
582
+ const now = performance.now();
583
+ const previous = lastStir.get(button) ?? 0;
584
+ if (now - previous < 160) return;
585
+ lastStir.set(button, now);
586
+ const rect = button.getBoundingClientRect();
587
+ const point = uv(mainCanvas, rect.left + rect.width / 2, rect.top + rect.height / 2);
588
+ main.stir(point.x, point.y, 0, -strength);
589
+ };
590
+ const ripple = (cx, cy) => {
591
+ const rect = mainCanvas.getBoundingClientRect();
592
+ if (rect.width <= 0 || rect.height <= 0) return;
593
+ const ux = (cx - rect.left) / rect.width;
594
+ const uy = 1 - (cy - rect.top) / rect.height;
595
+ const start = performance.now();
596
+ const duration = 1500;
597
+ const maxRadius = 120;
598
+ const count = 8;
599
+ const step = () => {
600
+ const t = performance.now() - start;
601
+ if (t > duration) return;
602
+ const k = t / duration;
603
+ const radius = maxRadius * k * k;
604
+ const strength = 0.05 * (1 - k);
605
+ const spin = 0.4 * k;
606
+ for (let i = 0; i < count; i += 1) {
607
+ const angle = i / count * Math.PI * 2 + spin;
608
+ const px = ux + radius * Math.cos(angle) / rect.width;
609
+ const py = uy + radius * Math.sin(angle) / rect.height;
610
+ main.stir(px, py, Math.cos(angle) * strength, -Math.sin(angle) * strength);
611
+ }
612
+ const id2 = requestAnimationFrame(step);
613
+ ripples.add(id2);
614
+ };
615
+ const id = requestAnimationFrame(step);
616
+ ripples.add(id);
617
+ };
618
+ const onPointerOver = (event) => {
619
+ const button = event.target?.closest?.("button");
620
+ if (button !== void 0 && button !== null) stirButton(button, 0.04);
621
+ };
622
+ const onClick = (event) => {
623
+ const button = event.target?.closest?.("button");
624
+ if (button === void 0 || button === null) return;
625
+ const now = performance.now();
626
+ const previous = lastStir.get(button) ?? 0;
627
+ if (now - previous < 500) return;
628
+ lastStir.set(button, now);
629
+ const rect = button.getBoundingClientRect();
630
+ ripple(rect.left + rect.width / 2, rect.top + rect.height / 2);
631
+ };
632
+ document.addEventListener("pointerover", onPointerOver, { capture: true });
633
+ document.addEventListener("click", onClick, { capture: true });
634
+ return () => {
635
+ for (const id of ripples) cancelAnimationFrame(id);
636
+ ripples.clear();
637
+ document.removeEventListener("pointerover", onPointerOver, { capture: true });
638
+ document.removeEventListener("click", onClick, { capture: true });
639
+ };
640
+ }
641
+
642
+ // ── glass chromatic dispersion ───────────────────────────────────────
643
+ var FILTER_ID = "dshome-glass-dispersion";
644
+ var TINT_ID = "dshome-glass-dispersion-tint";
645
+ var REFRACT_ID = "dshome-glass-dispersion-refract";
646
+ var TALL_FILTER_ID = "dshome-glass-dispersion-tall";
647
+ var TALL_TINT_ID = "dshome-glass-dispersion-tall-tint";
648
+ var TALL_REFRACT_ID = "dshome-glass-dispersion-tall-refract";
649
+ // Two composer filters: `narrow` (an 8px band) and `wide` (16px).
650
+ //
651
+ // The band is sized by what the user can actually SEE, which is the top and
652
+ // bottom edges: the card's top abuts the 任务 bar and its bottom abuts the
653
+ // status line, so displacing the backdrop across those hard edges shows,
654
+ // while left and right sit over a continuous background where the same
655
+ // displacement changes nothing. The user accepted that asymmetry ("允许左右
656
+ // 无反射"), so these maps are tuned for the VERTICAL band and the horizontal
657
+ // one is left wherever it lands.
658
+ //
659
+ // Vertical band on screen = (edge + softness) / mapHeight * 1.56 * cardHeight
660
+ // -- the filter region is 156% of the surface's height (see filterMarkup) --
661
+ // so at the upstream 400x92 aspect and a 112px-tall card that is 1.90x the
662
+ // map inset: 1.7 + 2.5 gives 8px, 3.4 + 5 gives 16px.
663
+ var COMPOSER_FILTER_ID = "dshome-glass-dispersion-composer";
664
+ var COMPOSER_TINT_ID = "dshome-glass-dispersion-composer-tint";
665
+ var COMPOSER_REFRACT_ID = "dshome-glass-dispersion-composer-refract";
666
+ var WIDE_FILTER_ID = "dshome-glass-dispersion-composer-wide";
667
+ var WIDE_TINT_ID = "dshome-glass-dispersion-composer-wide-tint";
668
+ var WIDE_REFRACT_ID = "dshome-glass-dispersion-composer-wide-refract";
669
+ var COMPOSER_MAP_W = 400;
670
+ var COMPOSER_MAP_H = 92;
671
+ var COMPOSER_MAP_RADIUS = 50;
672
+ var COMPOSER_MAP_EDGE = 1.7;
673
+ var COMPOSER_MAP_SOFTNESS = 2.5;
674
+ var COMPOSER_WIDE_EDGE = 3.4;
675
+ var COMPOSER_WIDE_SOFTNESS = 5;
676
+ // Chromatic aberration, composer filters only. 0.18 splits the base
677
+ // displacement into three: red at 118%, blue at 82%, green in the middle,
678
+ // which is what makes a lens edge fringe instead of merely tinting. Kept to
679
+ // the two composer filters because it triples the displacement passes, and
680
+ // because the shared filters have to keep upstream's exact shape for the
681
+ // frosted recipe.
682
+ var COMPOSER_ABERRATION = 0.18;
683
+ var DEFAULT_REF_SCALE = 60;
684
+ // The liquid recipe drives the same feDisplacementMap harder: at 60 the
685
+ // bend is there but only just legible once the blur sits on top of it, and
686
+ // "you can see the edge refract" is the whole point of that recipe. Kept as
687
+ // a separate constant so the frosted recipe keeps receiving 60.
688
+ var LIQUID_REF_SCALE = 104;
689
+ var EDGE_DX = -14;
690
+ var TINT_OPACITY = 0.45;
691
+ var TINT_SAT = 0.85;
692
+ var TINT_LIGHT = 0.6;
693
+ var DEFAULT_TINT_HUE = 44;
694
+ // Upstream derives the inset from the map's SHORT side (7% of it, halved),
695
+ // which is only uniform if the map is square. The composer passes `edge`
696
+ // instead: one absolute inset for both axes, which comes out uniform as
697
+ // long as the map's aspect matches the filter region's (see COMPOSER_MAP_*).
698
+ // Defaults reproduce upstream's numbers exactly, so the frosted recipe's
699
+ // map stays byte for byte what it was.
700
+ function buildDisplacementMapDataUrl(width = 400, height = 92, radius = 50, edge = null, softness = 11) {
701
+ const w = Math.max(240, Math.round(width));
702
+ const h = Math.max(48, Math.round(height));
703
+ const r = Math.max(12, Math.round(radius));
704
+ const inset = edge === null ? Math.min(w, h) * 0.035 : Math.max(0, edge);
705
+ const innerW = Math.max(1, w - inset * 2);
706
+ const innerH = Math.max(1, h - inset * 2);
707
+ const svg2 = `<svg viewBox="0 0 ${w} ${h}" xmlns="http://www.w3.org/2000/svg"><defs><linearGradient id="glass-x" x1="0%" y1="0%" x2="100%" y2="0%"><stop offset="0%" stop-color="#000"/><stop offset="100%" stop-color="#f00"/></linearGradient><linearGradient id="glass-y" x1="0%" y1="0%" x2="0%" y2="100%"><stop offset="0%" stop-color="#000"/><stop offset="100%" stop-color="#00f"/></linearGradient></defs><rect x="0" y="0" width="${w}" height="${h}" fill="#000"/><rect x="0" y="0" width="${w}" height="${h}" rx="${r}" fill="url(#glass-x)"/><rect x="0" y="0" width="${w}" height="${h}" rx="${r}" fill="url(#glass-y)" style="mix-blend-mode:screen"/><rect x="${inset.toFixed(2)}" y="${inset.toFixed(2)}" width="${innerW.toFixed(2)}" height="${innerH.toFixed(2)}" rx="${r}" fill="hsl(0 0% 50% / 1)" style="filter:blur(${softness})"/></svg>`;
708
+ return `data:image/svg+xml,${encodeURIComponent(svg2)}`;
709
+ }
710
+ // Inlined from upstream `src/client/glass-dispersion.ts` (line 2409) —
711
+ // required by tintMatrix below.
712
+ function hslToRgb01(h, s, l) {
713
+ const hue = (h % 360 + 360) % 360 / 360;
714
+ if (s === 0) return [l, l, l];
715
+ const q = l < 0.5 ? l * (1 + s) : l + s - l * s;
716
+ const p = 2 * l - q;
717
+ const channel = (t) => {
718
+ let tt = t;
719
+ if (tt < 0) tt += 1;
720
+ if (tt > 1) tt -= 1;
721
+ if (tt < 1 / 6) return p + (q - p) * 6 * tt;
722
+ if (tt < 1 / 2) return q;
723
+ if (tt < 2 / 3) return p + (q - p) * (2 / 3 - tt) * 6;
724
+ return p;
725
+ };
726
+ return [channel(hue + 1 / 3), channel(hue), channel(hue - 1 / 3)];
727
+ }
728
+ function tintMatrix(hue, opacity) {
729
+ const [r, g, b] = hslToRgb01(hue, TINT_SAT, TINT_LIGHT);
730
+ const lr = (0.2126 * opacity).toFixed(4);
731
+ const lg = (0.7152 * opacity).toFixed(4);
732
+ const lb = (0.0722 * opacity).toFixed(4);
733
+ return `0 0 0 0 ${r.toFixed(4)} 0 0 0 0 ${g.toFixed(4)} 0 0 0 0 ${b.toFixed(4)} ${lr} ${lg} ${lb} 0 0`;
734
+ }
735
+ function supportsSvgBackdropFilter() {
736
+ try {
737
+ const ua = navigator.userAgent || "";
738
+ if (/Safari/.test(ua) && !/Chrome/.test(ua) || /Firefox/.test(ua)) return false;
739
+ const div = document.createElement("div");
740
+ div.style.backdropFilter = `url(#${FILTER_ID})`;
741
+ return div.style.backdropFilter !== "";
742
+ } catch {
743
+ return false;
744
+ }
745
+ }
746
+ // Inlined from upstream `src/client/glass-dispersion.ts` (line 2443) —
747
+ // builds the wide/tall SVG <filter> pair startGlassDispersion injects.
748
+ //
749
+ // `aberration` (0 = off, upstream's shape byte for byte) adds true
750
+ // chromatic aberration: the backdrop is displaced TWICE MORE at slightly
751
+ // different scales, and the result is assembled channel by channel -- R
752
+ // from the stronger displacement, B from the weaker, G from the base. That
753
+ // is what puts a red/blue fringe on a real lens edge; the tinted
754
+ // difference-blend below is only a colour wash and does not separate
755
+ // channels at all.
756
+ //
757
+ // The two extra maps carry a data-aberration factor so setRefraction() can
758
+ // rescale them in step with the base one instead of flattening all three
759
+ // to the same value.
760
+ function filterMarkup(id, refractId, tintId, map, aberration = 0) {
761
+ const chromatic = aberration <= 0 ? '' :
762
+ `<feDisplacementMap data-aberration="${(1 + aberration).toFixed(3)}" in="SourceGraphic" in2="map" scale="${DEFAULT_REF_SCALE}" xChannelSelector="R" yChannelSelector="B" result="refractR"></feDisplacementMap>` +
763
+ `<feDisplacementMap data-aberration="${(1 - aberration).toFixed(3)}" in="SourceGraphic" in2="map" scale="${DEFAULT_REF_SCALE}" xChannelSelector="R" yChannelSelector="B" result="refractB"></feDisplacementMap>` +
764
+ `<feColorMatrix in="refracted" type="matrix" values="0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 1 0" result="onlyG"></feColorMatrix>` +
765
+ `<feColorMatrix in="refractR" type="matrix" values="1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0" result="onlyR"></feColorMatrix>` +
766
+ `<feColorMatrix in="refractB" type="matrix" values="0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 1 0" result="onlyB"></feColorMatrix>` +
767
+ `<feBlend in="onlyG" in2="onlyR" mode="screen" result="rgMerge"></feBlend>` +
768
+ `<feBlend in="rgMerge" in2="onlyB" mode="screen" result="aberrated"></feBlend>`;
769
+ const merged = chromatic === '' ? 'refracted' : 'aberrated';
770
+ return `<filter id="${id}" color-interpolation-filters="sRGB" x="-12%" y="-28%" width="124%" height="156%"><feImage href="${map}" x="0" y="0" width="100%" height="100%" preserveAspectRatio="none" result="map"></feImage><feDisplacementMap id="${refractId}" in="SourceGraphic" in2="map" scale="${DEFAULT_REF_SCALE}" xChannelSelector="R" yChannelSelector="B" result="refracted"></feDisplacementMap>${chromatic}<feOffset in="${merged}" dx="${EDGE_DX}" dy="0" result="shifted"></feOffset><feBlend in="shifted" in2="${merged}" mode="difference" result="edgeDiff"></feBlend><feColorMatrix id="${tintId}" in="edgeDiff" type="matrix" values="${tintMatrix(DEFAULT_TINT_HUE, TINT_OPACITY)}" result="edgeTint"></feColorMatrix><feBlend in="${merged}" in2="edgeTint" mode="screen" result="output"></feBlend><feGaussianBlur in="output" stdDeviation="0.5"></feGaussianBlur></filter>`;
771
+ }
772
+ /**
773
+ * Mount the two SVG backdrop filters and set `ATTR` on <html> so the
774
+ * stylesheet can opt surfaces into the dispersion. Returns a handle whose
775
+ * `setTint(hue)` / `setRefraction(scale)` accept values from the caller
776
+ * (upstream read them from its own settings store).
777
+ * @param {{ hue?: number, refraction?: number }} [options]
778
+ * @returns {{ setTint: (hue: number) => void, setRefraction: (scale: number) => void, dispose: () => void }}
779
+ */
780
+ function startGlassDispersion(options) {
781
+ const hue = options !== undefined && typeof options.hue === "number" ? options.hue : DEFAULT_TINT_HUE;
782
+ const root = document.documentElement;
783
+ if (root.hasAttribute(ATTR) || document.getElementById(FILTER_ID) !== null) {
784
+ return { setTint() {
785
+ }, setRefraction() {
786
+ }, dispose() {
787
+ } };
788
+ }
789
+ if (!supportsSvgBackdropFilter()) {
790
+ return { setTint() {
791
+ }, setRefraction() {
792
+ }, dispose() {
793
+ } };
794
+ }
795
+ const mapWide = buildDisplacementMapDataUrl(400, 92, 50);
796
+ const mapTall = buildDisplacementMapDataUrl(92, 400, 50);
797
+ const mapComposer = buildDisplacementMapDataUrl(COMPOSER_MAP_W, COMPOSER_MAP_H, COMPOSER_MAP_RADIUS, COMPOSER_MAP_EDGE, COMPOSER_MAP_SOFTNESS);
798
+ const mapComposerWide = buildDisplacementMapDataUrl(COMPOSER_MAP_W, COMPOSER_MAP_H, COMPOSER_MAP_RADIUS, COMPOSER_WIDE_EDGE, COMPOSER_WIDE_SOFTNESS);
799
+ const markup = `<svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" width="0" height="0" style="position:absolute;overflow:hidden"><defs>` + filterMarkup(FILTER_ID, REFRACT_ID, TINT_ID, mapWide) + filterMarkup(TALL_FILTER_ID, TALL_REFRACT_ID, TALL_TINT_ID, mapTall) + filterMarkup(COMPOSER_FILTER_ID, COMPOSER_REFRACT_ID, COMPOSER_TINT_ID, mapComposer, COMPOSER_ABERRATION) + filterMarkup(WIDE_FILTER_ID, WIDE_REFRACT_ID, WIDE_TINT_ID, mapComposerWide, COMPOSER_ABERRATION) + `</defs></svg>`;
800
+ const container = document.createElement("div");
801
+ container.setAttribute("aria-hidden", "true");
802
+ container.style.cssText = "position:absolute;width:0;height:0;overflow:hidden;";
803
+ container.innerHTML = markup;
804
+ document.body.appendChild(container);
805
+ const tint = container.querySelectorAll("feColorMatrix");
806
+ const refract = container.querySelectorAll("feDisplacementMap");
807
+ root.setAttribute(ATTR, "");
808
+ const handle = {
809
+ setTint(nextHue) {
810
+ const values = tintMatrix(nextHue, TINT_OPACITY);
811
+ tint.forEach((node) => node.setAttribute("values", values));
812
+ },
813
+ setRefraction(scale) {
814
+ // The aberration maps are the same displacement at a slightly
815
+ // different scale, so they carry a factor and are rescaled in step;
816
+ // flattening them all to one value would erase the fringing.
817
+ const base = Math.max(0, Math.min(140, Number(scale) || 0));
818
+ refract.forEach((node) => {
819
+ const factor = Number(node.getAttribute("data-aberration"));
820
+ const value = Number.isFinite(factor) && factor > 0 ? base * factor : base;
821
+ node.setAttribute("scale", String(Math.max(0, Math.min(140, value))));
822
+ });
823
+ },
824
+ dispose() {
825
+ root.removeAttribute(ATTR);
826
+ container.remove();
827
+ }
828
+ };
829
+ if (options !== undefined && typeof options.refraction === "number") handle.setRefraction(options.refraction);
830
+ handle.setTint(hue);
831
+ return handle;
832
+ }
833
+
834
+ // ── specular-highlight cursor parallax ───────────────────────────────
835
+ // SPOT_ATTR / SPEC_X / SPEC_Y/ SPOT_SELECTOR renamed to the `dshome-`
836
+ // prefix. The caller decides which elements carry `data-dshome-spot`;
837
+ // declare them as `data-dshome-spot` in the stylesheet/DOM layer.
838
+ var SPOT_ATTR = "data-dshome-spot";
839
+ var SPOT_SELECTOR = `[${SPOT_ATTR}]`;
840
+ var SPEC_X = "--dshome-spec-x";
841
+ var SPEC_Y = "--dshome-spec-y";
842
+ // Inlined from upstream `src/client/spot-core.ts` (lines 1711-1713).
843
+ function closestSpot(target) {
844
+ return target instanceof Element ? target.closest(SPOT_SELECTOR) : null;
845
+ }
846
+ // Inlined from upstream `src/client/spot-core.ts` (lines 1717-1729). The
847
+ // `[data-composer-card]` / `[data-dsh-stats]` selectors are product markup
848
+ // and are deliberately left unrenamed; a mount that lacks them simply
849
+ // falls back to the spot's own border box.
850
+ function visualRect(spot) {
851
+ if (spot.querySelector("[data-composer-card]") !== null) {
852
+ const card = spot.querySelector("[data-composer-card]");
853
+ const r0 = card.getBoundingClientRect();
854
+ const stats = spot.querySelector("[data-dsh-stats]");
855
+ if (stats === null) return r0;
856
+ const r1 = stats.getBoundingClientRect();
857
+ const left = Math.min(r0.left, r1.left);
858
+ const top = Math.min(r0.top, r1.top);
859
+ return new DOMRect(left, top, Math.max(r0.right, r1.right) - left, Math.max(r0.bottom, r1.bottom) - top);
860
+ }
861
+ return spot.getBoundingClientRect();
862
+ }
863
+ // Inlined from upstream `src/client/spot-core.ts` (lines 1730-1732).
864
+ function inside(visual, clientX, clientY) {
865
+ return clientX >= visual.left && clientX <= visual.right && clientY >= visual.top && clientY <= visual.bottom;
866
+ }
867
+ /**
868
+ * Write normalised cursor coordinates into `--dshome-spec-x` /
869
+ * `--dshome-spec-y` on the hovered `[data-dshome-spot]` element.
870
+ * @returns {() => void} disposer that detaches every listener and clears vars.
871
+ */
872
+ function startSpecularParallax() {
873
+ let current = null;
874
+ let visual = null;
875
+ let raf = 0;
876
+ const clear = () => {
877
+ if (current === null) return;
878
+ current.style.removeProperty(SPEC_X);
879
+ current.style.removeProperty(SPEC_Y);
880
+ current = null;
881
+ visual = null;
882
+ };
883
+ const paint = (clientX, clientY) => {
884
+ if (raf !== 0) return;
885
+ raf = requestAnimationFrame(() => {
886
+ raf = 0;
887
+ if (current === null || visual === null) return;
888
+ if (!inside(visual, clientX, clientY)) {
889
+ clear();
890
+ return;
891
+ }
892
+ const sx = Math.min(1, Math.max(-1, (clientX - visual.left) / visual.width * 2 - 1));
893
+ const sy = Math.min(1, Math.max(-1, (clientY - visual.top) / visual.height * 2 - 1));
894
+ current.style.setProperty(SPEC_X, sx.toFixed(4));
895
+ current.style.setProperty(SPEC_Y, sy.toFixed(4));
896
+ });
897
+ };
898
+ const onMove = (event) => {
899
+ const spot = closestSpot(event.target);
900
+ if (spot === null || spot !== current) return;
901
+ paint(event.clientX, event.clientY);
902
+ };
903
+ const onOver = (event) => {
904
+ const spot = closestSpot(event.target);
905
+ if (spot === null) return;
906
+ const rect = visualRect(spot);
907
+ if (!inside(rect, event.clientX, event.clientY)) return;
908
+ current = spot;
909
+ visual = rect;
910
+ paint(event.clientX, event.clientY);
911
+ };
912
+ const onOut = (event) => {
913
+ const spot = closestSpot(event.target);
914
+ if (spot === null || spot !== current) return;
915
+ if (visual !== null && inside(visual, event.clientX, event.clientY)) return;
916
+ clear();
917
+ };
918
+ document.addEventListener("pointermove", onMove, { passive: true });
919
+ document.addEventListener("pointerover", onOver, { passive: true });
920
+ document.addEventListener("pointerout", onOut, { passive: true });
921
+ return () => {
922
+ document.removeEventListener("pointermove", onMove);
923
+ document.removeEventListener("pointerover", onOver);
924
+ document.removeEventListener("pointerout", onOut);
925
+ if (raf !== 0) cancelAnimationFrame(raf);
926
+ clear();
927
+ };
928
+ }
929
+
930
+ // ─────────────────────────────────────────────────────────────────────────────
931
+ // PUBLIC API exposed by this fragment (all declarations are inert until called;
932
+ // nothing here runs at load time):
933
+ //
934
+ // SITE_FLUID_PARAMS : object
935
+ // Upstream's default fluid parameter set (mouse radius/strength, decay,
936
+ // distortion, swirl, scale, offsets and three palette colours). Spread it
937
+ // and override `color1`/`color2`/`color3` (and any knob) to theme the
938
+ // fluid: `{ ...SITE_FLUID_PARAMS, color1: '#8AA3D6' }`.
939
+ //
940
+ // attachFluidShader(canvas, params) -> handle
941
+ // canvas: HTMLCanvasElement in the DOM and sized by CSS. params: a full
942
+ // parameter object (see SITE_FLUID_PARAMS). Returns:
943
+ // setParams(next) -> void swap params; repaints once if paused
944
+ // stir(x, y, vx, vy) -> void inject a velocity impulse at uv (0..1)
945
+ // setAudioLow(level) -> void 0..1 audio boost for speed/boost knobs
946
+ // setRunning(on) -> void start/stop the rAF loop
947
+ // dispose() -> void cancel rAF + drop the mousemove listener
948
+ // Degrades to no-op methods when WebGL2 is unavailable or a shader fails to
949
+ // compile/link. Never throws for that reason.
950
+ //
951
+ // attachFluidInteractions({ main, mainCanvas }) -> dispose
952
+ // Wires document-level pointerover/click capture so hovering a <button>
953
+ // nudges the fluid and clicking one emits a ripple. `main` is the handle
954
+ // from attachFluidShader; `mainCanvas` is the same canvas element passed
955
+ // there. Returns a () => void that cancels in-flight ripples and detaches
956
+ // both listeners.
957
+ //
958
+ // startGlassDispersion(options?) -> { setTint(hue), setRefraction(scale), dispose() }
959
+ // options: { hue?: number, refraction?: number } — both optional.
960
+ // `hue` (default 44) tints the dispersion edge; `refraction` (default 60,
961
+ // clamped 0..140) is the displacement scale. Injects one hidden <svg> with
962
+ // a wide and a tall filter and sets `data-dshome-dispersion` on <html> so
963
+ // CSS can apply `backdrop-filter: url(#dshome-glass-dispersion)`. Returns
964
+ // no-op methods (idempotent, safe to call twice) when the document already
965
+ // has one or the engine does not support SVG backdrop filters.
966
+ //
967
+ // startSpecularParallax() -> dispose
968
+ // Tracks the cursor over any element carrying `data-dshome-spot` and
969
+ // writes normalised -1..1 coordinates to `--dshome-spec-x` /
970
+ // `--dshome-spec-y` on that element each animation frame. Requires the
971
+ // caller to mark spot elements with `data-dshome-spot` (SPOT_ATTR) and to
972
+ // consume the two custom properties in CSS. Returns a () => void that
973
+ // detaches all three document listeners, cancels the pending frame and
974
+ // clears both properties.
975
+ //
976
+ // hexToRgb(value) -> [r, g, b] (0..1) — internal helper, exported for reuse.
977
+ // buildDisplacementMapDataUrl(w?, h?, r?) -> string — SVG data URL.
978
+ // tintMatrix(hue, opacity) -> string — feColorMatrix values string.
979
+ // supportsSvgBackdropFilter() -> boolean — engine capability probe.
980
+ // FILTER_ID / TALL_FILTER_ID / ATTR / SPOT_ATTR / SPEC_X / SPEC_Y — the
981
+ // ids and attribute/var names the shipped CSS must match.
982
+ //
983
+ // Typical mount:
984
+ // const fluid = attachFluidShader(canvas, { ...SITE_FLUID_PARAMS, color1: c1 });
985
+ // const stopInteractions = attachFluidInteractions({ main: fluid, mainCanvas: canvas });
986
+ // const dispersion = startGlassDispersion({ hue: 44, refraction: 60 });
987
+ // const stopParallax = startSpecularParallax();
988
+ // Typical dispose: stopParallax(); dispersion.dispose(); stopInteractions(); fluid.dispose();
989
+ // ─────────────────────────────────────────────────────────────────────────────
990
+
29
991
  // CORE_CSS: ours only (`:root` tokens, `html/body`, keyframes, stable
30
992
  // `[role=menu]`, `.dshome-*`). No product class names — always injected.
31
993
  // Color model: `data-dshome-color` ∈ {green(base), red(鲜红 peak), blue}
@@ -33,6 +995,20 @@ const dshDeepseekStyleThemeFactory = (require) => {
33
995
  const CORE_CSS = `
34
996
  :root{--ds-brand:#059669;--ds-brand-deep:#047857;--ds-brand-mid:#10B981;--ds-brand-light:#34D399;--ds-glass-blur:24px}
35
997
  html,body{background-color:transparent!important}
998
+ /* THE LABEL TOKENS ARE NOT PINNED HERE, AND MUST NOT BE AGAIN.
999
+ A previous attempt at the invisible-text bug declared
1000
+ body{--dsw-alias-label-primary:...!important} under our own scheme marker,
1001
+ so that background and text could never end up on opposite sides. It did fix
1002
+ that, and it broke something worse: those !important declarations outrank the
1003
+ PRODUCT's tokens, so when the user switched appearance the product changed its
1004
+ own tokens and this stylesheet kept painting the old ones. The UI looked like
1005
+ the switch was dead.
1006
+ Measured on the real page: with the theme's style tags removed the switch
1007
+ works, with them present it does not, and reverting the header z-index changes
1008
+ nothing -- i.e. it is this sheet, and it is these declarations.
1009
+ The invisible-text hazard stays open on purpose. A stuck appearance switch is
1010
+ a broken control; near-white text on a near-white page at least still reads
1011
+ once the marker agrees. Do not re-add these two rules. */
36
1012
  body{background:radial-gradient(1200px 700px at 12% -10%,color-mix(in srgb,var(--ds-brand) 14%,transparent),transparent 60%),radial-gradient(1000px 600px at 105% 12%,color-mix(in srgb,var(--ds-brand-light) 16%,transparent),transparent 55%),radial-gradient(900px 700px at 50% 115%,color-mix(in srgb,var(--ds-brand) 10%,transparent),transparent 60%),linear-gradient(180deg,#fbfbfd 0%,#f5f6fa 100%);background-attachment:fixed}
37
1013
  body[data-dshome-color=red]{--ds-brand:#F5222D;--ds-brand-deep:#CF1322;--ds-brand-mid:#FF4D4F;--ds-brand-light:#FF7875}
38
1014
  body[data-dshome-color=blue]{--ds-brand:#4D6BFE;--ds-brand-deep:#3A65C2;--ds-brand-mid:#4176E6;--ds-brand-light:#73A3D2}
@@ -204,7 +1180,12 @@ body[data-dshome-dark] .YDXeBa_sessionRow.YDXeBa_selected{background:linear-grad
204
1180
  .wSkVaW_scrollBody{padding-top:56px}
205
1181
  .wSkVaW_viewArea{padding:0 18px}
206
1182
  .wSkVaW_viewArea{animation:dshome-view-enter .45s ease}
207
- .wSkVaW_header{position:absolute;top:8px;left:24px;right:24px;z-index:5;min-height:36px;padding:4px 12px;display:flex;flex-direction:row;align-items:center;gap:8px;justify-content:flex-start;border:0!important;border-radius:0;background:transparent!important;transition:border-radius .3s ease}
1183
+ /* Header z-index: the product's column-resize grips (.wSkVaW_widthHandle) are
1184
+ 40px-wide full-height strips at z-index 8, while this bar sat at 5 — so the
1185
+ cursor anywhere inside the title bar's own box turned into col-resize and the
1186
+ bar's controls were unreachable. 9 puts the bar above the grips; the grips
1187
+ stay grabbable everywhere the bar is not (above y=8, below y=46). */
1188
+ .wSkVaW_header{position:absolute;top:8px;left:24px;right:24px;z-index:9;min-height:36px;padding:4px 12px;display:flex;flex-direction:row;align-items:center;gap:8px;justify-content:flex-start;border:0!important;border-radius:0;background:transparent!important;transition:border-radius .3s ease}
208
1189
  .wSkVaW_header::before{content:"";position:absolute;inset:0;z-index:-1;background:transparent;border:1px solid transparent;border-radius:inherit;-webkit-backdrop-filter:none;backdrop-filter:none;transition:background .3s ease,border-color .3s ease,box-shadow .3s ease}
209
1190
  .wSkVaW_header:hover{border-radius:999px}
210
1191
  .wSkVaW_titleRow{display:contents}
@@ -311,6 +1292,101 @@ body[data-dshome-dark] .VOzbGW_panel{background:rgba(13,30,60,.96)!important}
311
1292
  ` }
312
1293
  ];
313
1294
 
1295
+ // LIQUID GLASS — the "wet glass" recipe, imitated from
1296
+ // deepseek-harness-background (MIT, Copyright (c) 2026 HaoyueQin): a
1297
+ // translucent fill, a vertical sheen gradient that is brightest along the
1298
+ // top edge and gone by ~38%, one shared backdrop chain
1299
+ // (blur + saturate + brightness + contrast), an inset top highlight and a
1300
+ // hairline ring, with hover only brightening the fill. Every knob is a
1301
+ // --dshome-glass-* property so the theme stays one recipe.
1302
+ //
1303
+ // The specular highlight is composed as an EXTRA background layer rather
1304
+ // than a pseudo-element: `--dshome-spec-x/y` (centre-relative, -1..1) are
1305
+ // written by startSpecular() on the hovered surface and
1306
+ // `--dshome-glass-spec` fades it, so a surface that already spends its
1307
+ // ::after on backdrop blur still gets a moving highlight.
1308
+ //
1309
+ // Refraction is a deliberately narrower layer: `backdrop-filter: url(#…)`
1310
+ // with the feDisplacementMap filter from dsh-theme-mineradio bends the
1311
+ // backdrop at the edges of the few LARGE surfaces only. Chromium is the
1312
+ // only engine that supports an SVG filter inside backdrop-filter and it
1313
+ // costs a filter pass per element, so the rule is gated on the
1314
+ // `data-dshome-dispersion` attribute that startGlassDispersion() stamps on
1315
+ // <html> only where it really mounted — every other browser silently keeps
1316
+ // the plain chain.
1317
+ const GLASS_CSS = `
1318
+ :root{
1319
+ --dshome-glass-blur:16px;
1320
+ --dshome-glass-saturate:1.42;
1321
+ --dshome-glass-brightness:1;
1322
+ --dshome-glass-contrast:1.01;
1323
+ --dshome-glass-sheen:.14;
1324
+ --dshome-glass-sheen-mid:.05;
1325
+ --dshome-glass-edge:rgba(255,255,255,.62);
1326
+ --dshome-glass-edge-low:rgba(255,255,255,.14);
1327
+ --dshome-glass-ring:rgba(255,255,255,.34);
1328
+ --dshome-glass-shadow:0 12px 40px rgba(0,0,0,.12);
1329
+ --dshome-glass-spec:0;
1330
+ }
1331
+ body[data-dshome-dark]{
1332
+ --dshome-glass-sheen:.16;
1333
+ --dshome-glass-sheen-mid:.06;
1334
+ --dshome-glass-edge:rgba(255,255,255,.30);
1335
+ --dshome-glass-edge-low:rgba(255,255,255,.07);
1336
+ --dshome-glass-ring:rgba(255,255,255,.18);
1337
+ --dshome-glass-shadow:0 14px 44px rgba(0,0,0,.45);
1338
+ }
1339
+ html .hHd-Xa_root::before,
1340
+ html .uV2eYG_card::after,
1341
+ html .gdEzaW_bubble,
1342
+ html .fV0t5q_root,
1343
+ html [data-composer-card],
1344
+ html .VOzbGW_panel,
1345
+ html .dshome-sa,
1346
+ html .dshome-file-menu{
1347
+ background-image:
1348
+ radial-gradient(340px circle at calc(50% + var(--dshome-spec-x,0) * 50%) calc(50% + var(--dshome-spec-y,0) * 50%), rgb(255 255 255 / calc(var(--dshome-glass-spec) * .30)), transparent 62%),
1349
+ linear-gradient(180deg, rgba(255,255,255,var(--dshome-glass-sheen)), rgba(255,255,255,var(--dshome-glass-sheen-mid)) 38%, rgba(255,255,255,.01))!important;
1350
+ -webkit-backdrop-filter:blur(var(--dshome-glass-blur)) saturate(var(--dshome-glass-saturate)) brightness(var(--dshome-glass-brightness)) contrast(var(--dshome-glass-contrast))!important;
1351
+ backdrop-filter:blur(var(--dshome-glass-blur)) saturate(var(--dshome-glass-saturate)) brightness(var(--dshome-glass-brightness)) contrast(var(--dshome-glass-contrast))!important;
1352
+ box-shadow:inset 0 1px 0 var(--dshome-glass-edge),inset 0 -1px 0 var(--dshome-glass-edge-low),inset 0 0 0 .5px var(--dshome-glass-ring),var(--dshome-glass-shadow);
1353
+ transition:background-color .18s ease,box-shadow .18s ease;
1354
+ }
1355
+ /* The specular layer is multiplied by --dshome-glass-spec, so it has to be
1356
+ switched on: while the cursor is over a spot surface the highlight follows
1357
+ --dshome-spec-x/y (written per element by startSpecularParallax). */
1358
+ html [data-dshome-spot]:hover{--dshome-glass-spec:1;}
1359
+ html [data-composer-card]:hover{--dshome-glass-spec:1;--dshome-glass-sheen:.12;}
1360
+ html .gdEzaW_bubble:hover,html .dshome-sa:hover,html .dshome-file-menu:hover{
1361
+ background-color:rgb(255 255 255 / calc(var(--dshome-glass-sheen) + .16))!important;
1362
+ }
1363
+ body[data-dshome-dark] .gdEzaW_bubble:hover,
1364
+ body[data-dshome-dark] .dshome-sa:hover,
1365
+ body[data-dshome-dark] .dshome-file-menu:hover{
1366
+ background-color:rgb(255 255 255 / calc(var(--dshome-glass-sheen) + .06))!important;
1367
+ }
1368
+ html[data-dshome-dispersion] .hHd-Xa_root::before,
1369
+ html[data-dshome-dispersion] .gdEzaW_bubble,
1370
+ html[data-dshome-dispersion] .VOzbGW_panel{
1371
+ -webkit-backdrop-filter:url(#dshome-glass-dispersion) blur(var(--dshome-glass-blur)) saturate(var(--dshome-glass-saturate))!important;
1372
+ backdrop-filter:url(#dshome-glass-dispersion) blur(var(--dshome-glass-blur)) saturate(var(--dshome-glass-saturate))!important;
1373
+ }
1374
+ @supports not ((backdrop-filter:blur(1px)) or (-webkit-backdrop-filter:blur(1px))){
1375
+ html .hHd-Xa_root::before,html .uV2eYG_card::after,html .gdEzaW_bubble,html [data-composer-card],html .VOzbGW_panel,html .dshome-sa,html .dshome-file-menu{
1376
+ background-color:rgba(255,255,255,.86)!important;
1377
+ }
1378
+ body[data-dshome-dark] .hHd-Xa_root::before,
1379
+ body[data-dshome-dark] .uV2eYG_card::after,
1380
+ body[data-dshome-dark] .gdEzaW_bubble,
1381
+ body[data-dshome-dark] [data-composer-card],
1382
+ body[data-dshome-dark] .VOzbGW_panel,
1383
+ body[data-dshome-dark] .dshome-sa,
1384
+ body[data-dshome-dark] .dshome-file-menu{
1385
+ background-color:rgba(13,30,60,.92)!important;
1386
+ }
1387
+ }
1388
+ `;
1389
+
314
1390
  /** Append a style tag; returns a disposer that removes it. */
315
1391
  function injectStyle(css, label) {
316
1392
  const tag = document.createElement('style');
@@ -321,6 +1397,287 @@ body[data-dshome-dark] .VOzbGW_panel{background:rgba(13,30,60,.96)!important}
321
1397
  return () => tag.remove();
322
1398
  }
323
1399
 
1400
+ // LIQUID GLASS — the second recipe, selected by the durable `glassStyle`
1401
+ // setting and gated entirely on `html[data-dshome-glass="liquid"]`. The
1402
+ // frosted block above is deliberately left byte-identical: switching the
1403
+ // setting back has to reproduce the look the user approved, so every rule
1404
+ // in here is additive and nothing above is edited.
1405
+ //
1406
+ // What makes it "liquid" rather than "frosted":
1407
+ // * the fill drops from a .42 white wash to a barely-there .10, and the
1408
+ // top sheen from .14 to .07, so the pane reads as glass over the fluid
1409
+ // rather than as a white card;
1410
+ // * the backdrop chain leans on saturation (1.75) instead of brightness,
1411
+ // which is what makes the colours behind the pane bloom;
1412
+ // * the shared feDisplacementMap runs at a much larger scale (see
1413
+ // LIQUID_REF_SCALE below), so the edge refraction is actually visible;
1414
+ // * a conic-gradient highlight sweeps the perimeter on its own, driven by
1415
+ // a registered <angle> property rather than by the pointer.
1416
+ //
1417
+ // Surfaces: exactly the four the user named — the sidebar shell, the
1418
+ // composer, the title bar and the user's own messages. Refraction is one
1419
+ // SVG filter pass per element in Chromium, so nothing else is added.
1420
+ //
1421
+ // The sweep lives on ::after because the product has already claimed
1422
+ // ::before on the sidebar and the title bar (measured, not assumed); the
1423
+ // composer claims both, which is why its edge highlight stays the
1424
+ // brand-tinted conic border the patch block already animates.
1425
+ // A user-authored message is not one flow kind but two: the message that
1426
+ // opens a turn is `data-chat-flow-kind="user"`, and a note typed while the
1427
+ // agent is already working is `"steering"`. Measured on the current build,
1428
+ // a transcript can contain ONLY steering bubbles — anchoring the selector
1429
+ // on "user" alone silently skipped every bubble on the page.
1430
+ //
1431
+ // The second half covers the gap the user hit: a message typed while the
1432
+ // agent is still working is painted in the transcript BEFORE it is picked
1433
+ // up, and at that moment it sits outside any flow-kind container, so the
1434
+ // two anchored selectors miss it and it renders unglazed until the turn
1435
+ // consumes it. Rather than enumerate the container it lands in, this side
1436
+ // takes any bubble that is NOT part of an assistant step — which is the
1437
+ // only place a bubble must not be glassed.
1438
+ const LIQUID_BUBBLE = ':is([data-chat-flow-kind="user"],[data-chat-flow-kind="steering"]) [class*="bubble" i],[class*="bubble" i]:not([data-chat-flow-kind="assistant-step"] *)';
1439
+ const LIQUID_CSS = `
1440
+ @property --dshome-liquid-sweep{syntax:"<angle>";inherits:false;initial-value:0deg}
1441
+ @keyframes dshome-liquid-sweep{from{--dshome-liquid-sweep:0deg}to{--dshome-liquid-sweep:360deg}}
1442
+ html[data-dshome-glass="liquid"]{
1443
+ --dshome-liquid-blur:11px;
1444
+ --dshome-liquid-saturate:1.75;
1445
+ --dshome-liquid-brightness:1.05;
1446
+ --dshome-liquid-contrast:1.02;
1447
+ --dshome-liquid-fill:rgb(255 255 255 / .14);
1448
+ /* The sidebar is the largest pane on screen, so a fill that reads as "barely
1449
+ there" on the composer leaves it washed out against the fluid; it carries a
1450
+ little more body of its own, and more of it again in light mode where the
1451
+ pane has to read as white glass rather than as tinted fluid. */
1452
+ --dshome-liquid-fill-sidebar:rgb(255 255 255 / .30);
1453
+ /* The sidebar is the boundary with the conversation pane, and it blurs harder
1454
+ than everything else on purpose: at the shared 11px the flow behind it stays
1455
+ legible and the pane never separates from the transcript. */
1456
+ --dshome-liquid-blur-sidebar:24px;
1457
+ /* The composer blurs less than the rest on purpose. Filters in a backdrop
1458
+ chain apply left to right, so url(refract) followed by blur(N) blurs the
1459
+ refraction AFTER it happens: a band narrower than about the blur radius is
1460
+ simply erased. At 11px the purpose-built ~4px band was invisible, which is
1461
+ exactly what was reported. 8px lets a ~10px band read while still frosting
1462
+ the backdrop. */
1463
+ --dshome-liquid-blur-composer:8px;
1464
+ /* One extra veil on top of the sidebar's glass. The pane sits over the fluid
1465
+ at roughly the same tone as the conversation it borders, so without this
1466
+ lift the two read as one surface. It is white in light mode. */
1467
+ --dshome-liquid-veil-sidebar:rgb(255 255 255 / .18);
1468
+ --dshome-liquid-sheen:.07;
1469
+ --dshome-liquid-edge:rgba(255,255,255,.60);
1470
+ --dshome-liquid-edge-low:rgba(255,255,255,.10);
1471
+ --dshome-liquid-ring:rgba(255,255,255,.26);
1472
+ --dshome-liquid-sweep-hi:rgba(255,255,255,.85);
1473
+ --dshome-liquid-sweep-lo:rgba(255,255,255,.28);
1474
+ --dshome-liquid-shadow:0 18px 54px rgba(9,20,44,.16);
1475
+ }
1476
+ body[data-dshome-dark]{
1477
+ --dshome-liquid-fill:rgb(255 255 255 / .07);
1478
+ /* Night mode goes the other way: the pane is a dark slab over a dark flow, so
1479
+ it is tinted towards the shell colour instead of towards white — dark
1480
+ enough to read as black glass, light enough to keep the flow visible. */
1481
+ --dshome-liquid-fill-sidebar:rgb(6 14 32 / .32);
1482
+ /* Night mode's veil is BLACK, the same idea inverted: a dark pane over a dark
1483
+ flow is lifted off it by deepening the pane, not by washing it grey. */
1484
+ --dshome-liquid-veil-sidebar:rgb(0 0 0 / .22);
1485
+ --dshome-liquid-sheen:.05;
1486
+ --dshome-liquid-edge:rgba(255,255,255,.34);
1487
+ --dshome-liquid-edge-low:rgba(255,255,255,.05);
1488
+ --dshome-liquid-ring:rgba(255,255,255,.14);
1489
+ --dshome-liquid-sweep-hi:rgba(255,255,255,.55);
1490
+ --dshome-liquid-sweep-lo:rgba(255,255,255,.16);
1491
+ --dshome-liquid-shadow:0 20px 60px rgba(0,0,0,.5);
1492
+ }
1493
+ /* The title bar is deliberately NOT always-on: the user's note on it is
1494
+ "rounded corners, and only once the mouse is over it" — the header becomes a
1495
+ pill on :hover (the patch block already sets border-radius:999px, and
1496
+ ::before inherits it), so the glass is scoped to that same hover state
1497
+ instead of turning the strip into a permanent bar. */
1498
+ /* The selectors carry an extra body step on purpose. The patch blocks are
1499
+ injected lazily when their anchor appears — later than this sheet — and their
1500
+ dark variants (body[data-dshome-dark] .uV2eYG_card) tie with a
1501
+ html[attr] .surface selector on specificity, at which point source order
1502
+ hands the pane back to the old fill. The extra type selector breaks the tie. */
1503
+ html[data-dshome-glass="liquid"] body .hHd-Xa_root::before,
1504
+ html[data-dshome-glass="liquid"] body [data-composer-card],
1505
+ html[data-dshome-glass="liquid"] body .wSkVaW_header:hover::before,
1506
+ html[data-dshome-glass="liquid"] body ${LIQUID_BUBBLE}{
1507
+ background-color:var(--dshome-liquid-fill)!important;
1508
+ background-image:
1509
+ radial-gradient(360px circle at calc(50% + var(--dshome-spec-x,0) * 50%) calc(50% + var(--dshome-spec-y,0) * 50%), rgb(255 255 255 / calc(var(--dshome-glass-spec) * .24)), transparent 60%),
1510
+ linear-gradient(180deg, rgba(255,255,255,var(--dshome-liquid-sheen)), rgba(255,255,255,.015) 34%, rgba(255,255,255,0))!important;
1511
+ -webkit-backdrop-filter:blur(var(--dshome-liquid-blur)) saturate(var(--dshome-liquid-saturate)) brightness(var(--dshome-liquid-brightness)) contrast(var(--dshome-liquid-contrast))!important;
1512
+ backdrop-filter:blur(var(--dshome-liquid-blur)) saturate(var(--dshome-liquid-saturate)) brightness(var(--dshome-liquid-brightness)) contrast(var(--dshome-liquid-contrast))!important;
1513
+ box-shadow:inset 0 1px 0 var(--dshome-liquid-edge),inset 0 -1px 0 var(--dshome-liquid-edge-low),inset 0 0 0 .5px var(--dshome-liquid-ring),var(--dshome-liquid-shadow)!important;
1514
+ }
1515
+ /* The composer is the one surface the old recipe paints TWICE: the patch block
1516
+ blurs .uV2eYG_card::after (and the frosted list paints it too), and the card
1517
+ itself is in both lists, so the backdrop was blurred twice over — which is what
1518
+ turned the pane into a smear. Under liquid the card element IS the glass, so
1519
+ the redundant layer is switched off rather than re-tuned. */
1520
+ html[data-dshome-glass="liquid"] [data-composer-card]::after{
1521
+ -webkit-backdrop-filter:none!important;
1522
+ backdrop-filter:none!important;
1523
+ background-image:none!important;
1524
+ box-shadow:none!important;
1525
+ }
1526
+ /* The frosted recipe gives the composer a brand-tinted conic ring, painted by
1527
+ the patch block at inset:-1px and spun by dsh-border-spin. Under liquid the
1528
+ user asked for it to go: it sits one pixel OUTSIDE the card's own 1.5px white
1529
+ border, so the pair reads as a coloured line with a white line outside it, and
1530
+ two competing edges is what liquid glass is not. content:none removes the
1531
+ pseudo-element outright rather than painting it transparent. */
1532
+ html[data-dshome-glass="liquid"] body [data-composer-card]::before{
1533
+ content:none!important;
1534
+ background:none!important;
1535
+ animation:none!important;
1536
+ }
1537
+ /* With the ring gone the card's own 1.5px white border is the only edge left,
1538
+ and on its own it reads as a flat white outline rather than as glass — which
1539
+ is what the user saw next. Liquid's edge is the inset hairline plus the
1540
+ refraction, so the border goes transparent. The WIDTH stays: removing it
1541
+ would resize the box and shift every control inside by 3px. */
1542
+ html[data-dshome-glass="liquid"] body [data-composer-card]{
1543
+ border-color:transparent!important;
1544
+ }
1545
+ /* The sidebar pane carries its own fill and its own shape: rounded only on the
1546
+ edge that faces the conversation, so it reads as a panel clipped to the
1547
+ window rather than as a full-bleed column. The hairline ring in the shared
1548
+ box-shadow above follows the radius. */
1549
+ html[data-dshome-glass="liquid"] body .hHd-Xa_root::before{
1550
+ background-color:var(--dshome-liquid-fill-sidebar)!important;
1551
+ border-radius:0 22px 22px 0;
1552
+ /* The veil rides on top of the two layers the shared rule sets, so the
1553
+ sidebar keeps its cursor-follow highlight and its sheen underneath. */
1554
+ background-image:
1555
+ linear-gradient(var(--dshome-liquid-veil-sidebar),var(--dshome-liquid-veil-sidebar)),
1556
+ radial-gradient(360px circle at calc(50% + var(--dshome-spec-x,0) * 50%) calc(50% + var(--dshome-spec-y,0) * 50%), rgb(255 255 255 / calc(var(--dshome-glass-spec) * .24)), transparent 60%),
1557
+ linear-gradient(180deg, rgba(255,255,255,var(--dshome-liquid-sheen)), rgba(255,255,255,.015) 34%, rgba(255,255,255,0))!important;
1558
+ }
1559
+ /* The message bubble is the one surface that is not already positioned. */
1560
+ html[data-dshome-glass="liquid"] ${LIQUID_BUBBLE}{
1561
+ position:relative;
1562
+ transition:background-color .18s ease,box-shadow .18s ease;
1563
+ }
1564
+ /* The composer leans under the cursor (see startComposerTilt). The transition
1565
+ is what turns the release into a settle rather than a snap: the ported
1566
+ routine writes the neutral transform back and only drops the inline
1567
+ properties 240ms later. */
1568
+ html[data-dshome-glass="liquid"] [data-composer-card]{
1569
+ transition:transform .24s cubic-bezier(.2,.8,.2,1),background-color .18s ease,box-shadow .18s ease!important;
1570
+ will-change:transform;
1571
+ }
1572
+ html[data-dshome-glass="liquid"] ${LIQUID_BUBBLE}:hover{
1573
+ background-color:rgb(255 255 255 / .18)!important;
1574
+ }
1575
+ body[data-dshome-dark] ${LIQUID_BUBBLE}:hover{
1576
+ background-color:rgb(255 255 255 / .10)!important;
1577
+ }
1578
+ html[data-dshome-glass="liquid"] body .hHd-Xa_root::after{
1579
+ border-radius:0 22px 22px 0;
1580
+ }
1581
+ /* The travelling edge highlight. mask-composite:exclude turns the filled
1582
+ conic gradient into a 1px perimeter band; padding:1px on the pseudo-element
1583
+ sets that band's width without touching the product's box model.
1584
+ It is drawn on the SIDEBAR ONLY. The user asked for it off the composer and
1585
+ off the message bubbles under liquid: on a small pill the band reads as a
1586
+ bright white outline rather than as light travelling a glass edge, and on the
1587
+ composer it doubled up with the card's own border. The bubbles and the
1588
+ composer keep liquid's other three marks — the translucent fill, the sheen
1589
+ and the refraction. */
1590
+ html[data-dshome-glass="liquid"] .hHd-Xa_root::after{
1591
+ content:"";position:absolute;inset:0;z-index:2;pointer-events:none;border-radius:inherit;
1592
+ padding:1px;
1593
+ background:conic-gradient(from var(--dshome-liquid-sweep),
1594
+ var(--dshome-liquid-sweep-lo) 0deg,var(--dshome-liquid-sweep-hi) 22deg,var(--dshome-liquid-sweep-lo) 64deg,
1595
+ rgba(255,255,255,.05) 140deg,var(--dshome-liquid-sweep-hi) 190deg,rgba(255,255,255,.05) 248deg,
1596
+ var(--dshome-liquid-sweep-lo) 360deg);
1597
+ -webkit-mask:linear-gradient(#000 0 0) content-box,linear-gradient(#000 0 0);
1598
+ -webkit-mask-composite:xor;
1599
+ mask:linear-gradient(#000 0 0) content-box,linear-gradient(#000 0 0);
1600
+ mask-composite:exclude;
1601
+ animation:dshome-liquid-sweep 6.5s linear infinite;
1602
+ }
1603
+ /* The composer's edge refraction. Three states, selected by the durable
1604
+ composerRefraction setting (see html[data-dshome-composer]):
1605
+ narrow (default) -- an 8px band top and bottom
1606
+ wide -- a 16px band top and bottom
1607
+ off -- no dispersion at all
1608
+ Left and right are left as they fall: the band is there, but over a
1609
+ continuous background a horizontal displacement has nothing to show, which
1610
+ the user accepted. */
1611
+ html[data-dshome-dispersion][data-dshome-glass="liquid"] body .wSkVaW_header:hover::before,
1612
+ html[data-dshome-dispersion][data-dshome-glass="liquid"] body ${LIQUID_BUBBLE}{
1613
+ -webkit-backdrop-filter:url(#dshome-glass-dispersion) blur(var(--dshome-liquid-blur)) saturate(var(--dshome-liquid-saturate))!important;
1614
+ backdrop-filter:url(#dshome-glass-dispersion) blur(var(--dshome-liquid-blur)) saturate(var(--dshome-liquid-saturate))!important;
1615
+ }
1616
+ html[data-dshome-dispersion][data-dshome-glass="liquid"][data-dshome-composer="narrow"] body [data-composer-card]{
1617
+ -webkit-backdrop-filter:url(#dshome-glass-dispersion-composer) blur(var(--dshome-liquid-blur-composer)) saturate(var(--dshome-liquid-saturate))!important;
1618
+ backdrop-filter:url(#dshome-glass-dispersion-composer) blur(var(--dshome-liquid-blur-composer)) saturate(var(--dshome-liquid-saturate))!important;
1619
+ }
1620
+ html[data-dshome-dispersion][data-dshome-glass="liquid"][data-dshome-composer="wide"] body [data-composer-card]{
1621
+ -webkit-backdrop-filter:url(#dshome-glass-dispersion-composer-wide) blur(var(--dshome-liquid-blur-composer)) saturate(var(--dshome-liquid-saturate))!important;
1622
+ backdrop-filter:url(#dshome-glass-dispersion-composer-wide) blur(var(--dshome-liquid-blur-composer)) saturate(var(--dshome-liquid-saturate))!important;
1623
+ }
1624
+ html[data-dshome-dispersion][data-dshome-glass="liquid"][data-dshome-composer="off"] body [data-composer-card]{
1625
+ -webkit-backdrop-filter:blur(var(--dshome-liquid-blur-composer)) saturate(var(--dshome-liquid-saturate))!important;
1626
+ backdrop-filter:blur(var(--dshome-liquid-blur-composer)) saturate(var(--dshome-liquid-saturate))!important;
1627
+ }
1628
+ /* The workspace list is faded out at its bottom by a gradient whose end stop is
1629
+ the sidebar-fill token — an OPAQUE colour matched to the product's own sidebar
1630
+ background. Over a translucent glass pane that stop no longer matches what is
1631
+ actually behind it, so the fade shows up as a lighter band above 设置 (the
1632
+ user's red box). The pane itself already separates the list from the
1633
+ conversation, so the fade is dropped. Scoped to the sidebar and to the
1634
+ product's own <hash>_fade naming so nothing else is touched. */
1635
+ html[data-dshome-glass="liquid"] body .hHd-Xa_root [class*="_fade" i]{
1636
+ background-image:none!important;
1637
+ }
1638
+ /* The sidebar's own, heavier blur. Written after the two rules above because it
1639
+ ties with the dispersion one on specificity and so has to come later. */
1640
+ html[data-dshome-glass="liquid"] body .hHd-Xa_root::before{
1641
+ -webkit-backdrop-filter:blur(var(--dshome-liquid-blur-sidebar)) saturate(var(--dshome-liquid-saturate)) brightness(var(--dshome-liquid-brightness)) contrast(var(--dshome-liquid-contrast))!important;
1642
+ backdrop-filter:blur(var(--dshome-liquid-blur-sidebar)) saturate(var(--dshome-liquid-saturate)) brightness(var(--dshome-liquid-brightness)) contrast(var(--dshome-liquid-contrast))!important;
1643
+ }
1644
+ html[data-dshome-dispersion][data-dshome-glass="liquid"] body .hHd-Xa_root::before{
1645
+ -webkit-backdrop-filter:url(#dshome-glass-dispersion) blur(var(--dshome-liquid-blur-sidebar)) saturate(var(--dshome-liquid-saturate))!important;
1646
+ backdrop-filter:url(#dshome-glass-dispersion) blur(var(--dshome-liquid-blur-sidebar)) saturate(var(--dshome-liquid-saturate))!important;
1647
+ }
1648
+ /* Backdrop blur, switched off by the durable backdropBlur setting. Each glass
1649
+ recipe reads its radius from a variable, so turning the frosting off is one
1650
+ 0px per variable -- the translucency, the sheen and the edge refraction all
1651
+ stay exactly as they were. Written with a body step so it also out-ranks the
1652
+ html[data-dshome-glass] block the liquid radii are declared in. */
1653
+ html[data-dshome-blur="off"],
1654
+ html[data-dshome-blur="off"] body{
1655
+ --dshome-glass-blur:0px;
1656
+ --dshome-liquid-blur:0px;
1657
+ --dshome-liquid-blur-sidebar:0px;
1658
+ --dshome-liquid-blur-composer:0px;
1659
+ }
1660
+ @media (prefers-reduced-motion:reduce){
1661
+ html[data-dshome-glass="liquid"] .hHd-Xa_root::after{
1662
+ animation:none;
1663
+ }
1664
+ }
1665
+ @supports not ((backdrop-filter:blur(1px)) or (-webkit-backdrop-filter:blur(1px))){
1666
+ html[data-dshome-glass="liquid"] body .hHd-Xa_root::before,
1667
+ html[data-dshome-glass="liquid"] body [data-composer-card],
1668
+ html[data-dshome-glass="liquid"] body .wSkVaW_header:hover::before,
1669
+ html[data-dshome-glass="liquid"] body ${LIQUID_BUBBLE}{
1670
+ background-color:rgba(255,255,255,.86)!important;
1671
+ }
1672
+ body[data-dshome-dark] .hHd-Xa_root::before,
1673
+ body[data-dshome-dark] [data-composer-card],
1674
+ body[data-dshome-dark] .wSkVaW_header:hover::before,
1675
+ body[data-dshome-dark] ${LIQUID_BUBBLE}{
1676
+ background-color:rgba(13,30,60,.92)!important;
1677
+ }
1678
+ }
1679
+ `;
1680
+
324
1681
  /**
325
1682
  * Inject `css` only while `anchor` matches the DOM. If the anchor is
326
1683
  * absent at call time, wait up to 30s for it (covers shells that render
@@ -371,8 +1728,32 @@ body[data-dshome-dark] .VOzbGW_panel{background:rgba(13,30,60,.96)!important}
371
1728
  * subscription is unavailable.
372
1729
  */
373
1730
  function createDarkSync(ctx, theme) {
1731
+ /** Last value we wrote to the body; null until the first apply(). */
1732
+ let lastDark = null;
1733
+ /**
1734
+ * Scheme-change listeners. The dark marker is a marker only if someone
1735
+ * reads it: the stylesheet matches on it, and the ambient background reads
1736
+ * it for its palette (see startAmbient). A listener that throws must not
1737
+ * cost the others their update, so each call is boxed.
1738
+ */
1739
+ const darkListeners = new Set();
1740
+ const notifyDark = (dark) => {
1741
+ for (const fn of darkListeners) {
1742
+ try { fn(dark); } catch (error) {}
1743
+ }
1744
+ };
374
1745
  const apply = () => {
375
1746
  let dark = false;
1747
+ // Two signals, and BOTH of them lie in some state -- measured, not
1748
+ // assumed:
1749
+ // * the theme service reported `light` while the page was in dark
1750
+ // mode, so treating it as the only source painted a dark page light;
1751
+ // * `data-ds-dark-theme` was still on <body> after a switch back to
1752
+ // light, so treating IT as authoritative painted a light page dark.
1753
+ // This is the precedence that shipped through 1.43.1 and behaved in both
1754
+ // modes: ask the service first, and let the product's own attribute
1755
+ // override a "not dark" answer. Keep it, and sanity-check the signal
1756
+ // before touching it again.
376
1757
  if (theme !== undefined && theme !== null && typeof theme.getTheme === 'function') {
377
1758
  try {
378
1759
  const snap = theme.getTheme();
@@ -384,32 +1765,402 @@ body[data-dshome-dark] .VOzbGW_panel{background:rgba(13,30,60,.96)!important}
384
1765
  }
385
1766
  }
386
1767
  if (!dark) dark = document.body.hasAttribute('data-ds-dark-theme');
1768
+ // Remember what we actually put on the body, so a later apply() that
1769
+ // lands on the same answer does not wake the background up for
1770
+ // nothing. `lastDark` is null until the first write.
1771
+ const changed = lastDark !== dark;
1772
+ lastDark = dark;
387
1773
  if (dark) document.body.setAttribute('data-dshome-dark', '');
388
1774
  else document.body.removeAttribute('data-dshome-dark');
1775
+ // Publish the write. The marker is what EVERY dark rule and the fluid
1776
+ // palette read, so a light/dark switch that only set the attribute left
1777
+ // the background on the scheme it was mounted with -- reported as
1778
+ // "切到深色背景还是蓝白".
1779
+ if (changed) notifyDark(dark);
389
1780
  };
390
- apply();
391
1781
  let unsubscribe = null;
392
1782
  try {
393
1783
  unsubscribe = ctx.on('theme/change', apply);
394
1784
  } catch (error) {
395
1785
  unsubscribe = null;
396
1786
  }
1787
+ // Always mirror the product's attribute, not only when the theme service
1788
+ // is missing: this is the self-healing half. A missed `theme/change`
1789
+ // used to leave the marker stale until the next reload.
397
1790
  let mirror = null;
398
- if (unsubscribe === null || theme === undefined || theme === null || typeof theme.getTheme !== 'function') {
399
- try {
400
- mirror = new MutationObserver(apply);
401
- mirror.observe(document.body, { attributes: true, attributeFilter: ['data-ds-dark-theme'] });
402
- } catch (error) {
403
- mirror = null;
1791
+ try {
1792
+ mirror = new MutationObserver(apply);
1793
+ mirror.observe(document.body, { attributes: true, attributeFilter: ['data-ds-dark-theme'] });
1794
+ } catch (error) {
1795
+ mirror = null;
1796
+ }
1797
+ return {
1798
+ /**
1799
+ * Subscribe to light/dark *writes*. Nothing is replayed on subscribe:
1800
+ * a reader that needs the current value reads the attribute (or calls
1801
+ * dshomeDark()), which keeps one source of truth.
1802
+ */
1803
+ subscribe: (fn) => {
1804
+ darkListeners.add(fn);
1805
+ return () => darkListeners.delete(fn);
1806
+ },
1807
+ dispose: () => {
1808
+ darkListeners.clear();
1809
+ if (unsubscribe !== null) unsubscribe();
1810
+ if (mirror !== null) mirror.disconnect();
404
1811
  }
1812
+ };
1813
+ }
1814
+
1815
+ /**
1816
+ * Own the glass-recipe marker: mirror the durable `glassStyle` choice onto
1817
+ * <html data-dshome-glass>, which is the single switch the stylesheet gates
1818
+ * the liquid recipe on. The attribute is set before the first paint with the
1819
+ * default (`liquid`), so the only flicker is the one a user who picked
1820
+ * `frosted` sees during the initial loopback round trip.
1821
+ */
1822
+ function createGlassSync(ctx) {
1823
+ const root = document.documentElement;
1824
+ const apply = () => {
1825
+ root.setAttribute('data-dshome-glass', dsttGetGlass());
1826
+ root.setAttribute('data-dshome-composer', dsttGetComposer());
1827
+ root.setAttribute('data-dshome-blur', dsttGetBlur() ? 'on' : 'off');
1828
+ };
1829
+ apply();
1830
+ const unsubscribe = dsttSubscribe(apply);
1831
+ return () => {
1832
+ unsubscribe();
1833
+ root.removeAttribute('data-dshome-glass');
1834
+ root.removeAttribute('data-dshome-composer');
1835
+ root.removeAttribute('data-dshome-blur');
1836
+ };
1837
+ }
1838
+
1839
+ /**
1840
+ * Fluid palette per DSTT colour. The site ships `#8AA3D6` plus two pure
1841
+ * whites, which reads as one faint blue meander — legible on deepseek.com
1842
+ * but far too quiet to carry a colour token, so each entry here uses a
1843
+ * stronger lead and a genuinely different third tone: the display shader
1844
+ * blends all three across the noise field, so three near-identical colours
1845
+ * flatten the flow into a single wash.
1846
+ */
1847
+ // Two tones carry the hue, the third is white (light) or near-black (dark) --
1848
+ // the user's own rule: 白蓝 / 黑蓝, 白红 / 黑红, 白绿 / 黑绿. What changed is
1849
+ // that the two hue tones now carry real chroma: the previous set was
1850
+ // (hue + #FFFFFF + near-white), and the display shader averages all three
1851
+ // across the screen, so a pale lead plus two whites washed every mode into
1852
+ // the same blue-white (measured: canvas 235,240,252 with the token green).
1853
+ // Averaged now: blue 67,122,226 / red 219,78,87 / green 40,164,115, i.e. the
1854
+ // expected channel leads in every family, in both schemes.
1855
+ const FLUID_COLORS = {
1856
+ green: { light: ['#0FA76A', '#5FCB9E', '#0B7A52'], dark: ['#0A5C3A', '#0E7A4E', '#03130C'] },
1857
+ blue: { light: ['#1E6FE8', '#7FA8F5', '#2B57C9'], dark: ['#0B2E7A', '#123B8F', '#050A18'] },
1858
+ red: { light: ['#E23A44', '#F08A90', '#C02630'], dark: ['#8A1520', '#5E0F16', '#140507'] }
1859
+ };
1860
+ /** Edge-tint hue for the glass dispersion, following the DSTT colour. */
1861
+ const FLUID_HUES = { green: 152, blue: 221, red: 356 };
1862
+
1863
+ /** The active DSTT colour token. */
1864
+ function dshomeColor() {
1865
+ const value = document.body.getAttribute('data-dshome-color');
1866
+ return value === 'red' || value === 'blue' ? value : 'green';
1867
+ }
1868
+ function dshomeDark() {
1869
+ return document.body.hasAttribute('data-dshome-dark');
1870
+ }
1871
+ /** The whole fluid parameter set for the current DSTT colour and scheme. */
1872
+ function dshomeFluidParams() {
1873
+ const palette = FLUID_COLORS[dshomeColor()];
1874
+ const pick = dshomeDark() ? palette.dark : palette.light;
1875
+ // `mouseFeed` is ours, not upstream's: false keeps the cursor from
1876
+ // writing a wake into the flow field (see the DSTT `fluidBrush` setting).
1877
+ return { ...SITE_FLUID_PARAMS, color1: pick[0], color2: pick[1], color3: pick[2], mouseFeed: dsttBrush() };
1878
+ }
1879
+ /** The durable `fluidBrush` preference; off unless the host reports it on. */
1880
+ function dsttBrush() {
1881
+ try {
1882
+ return dsttState.fluidBrush === true;
1883
+ } catch (error) {
1884
+ return false;
1885
+ }
1886
+ }
1887
+ /** WebGL2 is probed on a throwaway canvas so the real one keeps its context. */
1888
+ function supportsWebgl2() {
1889
+ try {
1890
+ const probe = document.createElement('canvas');
1891
+ const gl = probe.getContext('webgl2');
1892
+ if (gl === null) return false;
1893
+ const lose = gl.getExtension('WEBGL_lose_context');
1894
+ if (lose !== null) lose.loseContext();
1895
+ return true;
1896
+ } catch (error) {
1897
+ return false;
405
1898
  }
1899
+ }
1900
+ /**
1901
+ * Mark glass surfaces as specular spots. The ported startSpecularParallax
1902
+ * only tracks elements carrying the spot attribute, and stamping it on
1903
+ * pointerover avoids writing attributes onto product elements that React
1904
+ * re-renders. Registered before the parallax listener so the stamp lands on
1905
+ * the same event the parallax handler then reads.
1906
+ */
1907
+ /**
1908
+ * Specular spot surfaces: the composer card, the sidebar shell and the
1909
+ * user's own messages. The transcript pane and the centre column are
1910
+ * deliberately NOT spots — a cursor-following highlight across that much
1911
+ * empty area reads as a large white patch sliding over the background.
1912
+ *
1913
+ * The message bubble is matched through the product's own
1914
+ * `data-chat-flow-kind="user"` marker rather than a class name: the hashed
1915
+ * `.gdEzaW_bubble` this list used to carry matches nothing on the current
1916
+ * build, which is how the old entry went dead without anyone noticing.
1917
+ */
1918
+ const SPOT_SURFACES = `${LIQUID_BUBBLE},.uV2eYG_card,.dshome-sa,.dshome-file-menu,.hHd-Xa_root,[data-composer-card]`;
1919
+ function startSpecularSpotter() {
1920
+ const onOver = (event) => {
1921
+ const target = event.target;
1922
+ if (target === null || typeof target.closest !== 'function') return;
1923
+ const surface = target.closest(SPOT_SURFACES);
1924
+ if (surface === null) return;
1925
+ if (surface.getAttribute(SPOT_ATTR) === null) surface.setAttribute(SPOT_ATTR, '');
1926
+ };
1927
+ document.addEventListener('pointerover', onOver, true);
1928
+ return () => document.removeEventListener('pointerover', onOver, true);
1929
+ }
1930
+
1931
+ // ── composer hover tilt ───────────────────────────────────────────────
1932
+ // Ported from dsh-theme-mineradio's `startSpotlight` tilt branch (MIT,
1933
+ // Copyright (c) 2026 John Wu), including its constants: the pane lifts by
1934
+ // scale(1.01) and leans up to TILT_MAX radians towards whichever side the
1935
+ // cursor is on, about its own centre, under an 800px perspective. The
1936
+ // cursor-relative offsets are the same half-range clamp, and the release
1937
+ // writes the neutral transform first and only drops the inline properties
1938
+ // SETTLE_MS later, so the stylesheet's transition animates the return
1939
+ // instead of snapping.
1940
+ //
1941
+ // Only the composer is tiltable here. mineradio tilts every spot it owns;
1942
+ // in this theme the other spots are the sidebar shell and the transcript's
1943
+ // message bubbles, where a whole-column lean reads as a bug rather than as
1944
+ // depth. It is also gated on the liquid recipe, because the frosted pane is
1945
+ // meant to stay observably identical to what shipped before.
1946
+ const TILT_SELECTOR = '[data-composer-card],.uV2eYG_card';
1947
+ const TILT_MAX = 0.0175;
1948
+ const TILT_PERSPECTIVE = 800;
1949
+ const TILT_SCALE = 1.01;
1950
+ const TILT_SETTLE_MS = 240;
1951
+ function startComposerTilt() {
1952
+ let current = null;
1953
+ let raf = 0;
1954
+ const tilted = new WeakSet();
1955
+ const settle = new Map();
1956
+ const reduced = typeof window.matchMedia === 'function' && window.matchMedia('(prefers-reduced-motion: reduce)').matches;
1957
+ if (reduced) return () => {};
1958
+ const release = (spot) => {
1959
+ const pending = settle.get(spot);
1960
+ if (pending !== undefined) {
1961
+ clearTimeout(pending);
1962
+ settle.delete(spot);
1963
+ }
1964
+ if (!tilted.has(spot)) return;
1965
+ tilted.delete(spot);
1966
+ spot.style.transform = 'perspective(' + TILT_PERSPECTIVE + 'px) rotateX(0rad) rotateY(0rad) scale(1)';
1967
+ const handle = window.setTimeout(() => {
1968
+ settle.delete(spot);
1969
+ spot.style.removeProperty('transform');
1970
+ spot.style.removeProperty('transform-origin');
1971
+ }, TILT_SETTLE_MS);
1972
+ settle.set(spot, handle);
1973
+ };
1974
+ const paint = (spot, rect, clientX, clientY) => {
1975
+ if (raf !== 0) return;
1976
+ raf = requestAnimationFrame(() => {
1977
+ raf = 0;
1978
+ if (current !== spot) return;
1979
+ if (dsttGetGlass() !== 'liquid') {
1980
+ release(spot);
1981
+ return;
1982
+ }
1983
+ if (clientX < rect.left || clientX > rect.right || clientY < rect.top || clientY > rect.bottom) return;
1984
+ const dx = Math.min(0.5, Math.max(-0.5, (clientX - rect.left) / rect.width - 0.5));
1985
+ const dy = Math.min(0.5, Math.max(-0.5, (clientY - rect.top) / rect.height - 0.5));
1986
+ spot.style.transformOrigin = (rect.width / 2) + 'px ' + (rect.height / 2) + 'px';
1987
+ spot.style.transform = 'perspective(' + TILT_PERSPECTIVE + 'px)'
1988
+ + ' rotateX(' + (TILT_MAX * -2 * dy).toFixed(5) + 'rad)'
1989
+ + ' rotateY(' + (TILT_MAX * 2 * dx).toFixed(5) + 'rad)'
1990
+ + ' scale(' + TILT_SCALE + ')';
1991
+ tilted.add(spot);
1992
+ });
1993
+ };
1994
+ const onOver = (event) => {
1995
+ if (dsttGetGlass() !== 'liquid') return;
1996
+ const target = event.target;
1997
+ if (target === null || typeof target.closest !== 'function') return;
1998
+ const spot = target.closest(TILT_SELECTOR);
1999
+ if (spot === null) return;
2000
+ const rect = spot.getBoundingClientRect();
2001
+ if (event.clientX < rect.left || event.clientX > rect.right || event.clientY < rect.top || event.clientY > rect.bottom) return;
2002
+ const pending = settle.get(spot);
2003
+ if (pending !== undefined) {
2004
+ clearTimeout(pending);
2005
+ settle.delete(spot);
2006
+ }
2007
+ current = spot;
2008
+ paint(spot, rect, event.clientX, event.clientY);
2009
+ };
2010
+ const onMove = (event) => {
2011
+ if (current === null) return;
2012
+ paint(current, current.getBoundingClientRect(), event.clientX, event.clientY);
2013
+ };
2014
+ const onOut = (event) => {
2015
+ if (current === null) return;
2016
+ const target = event.target;
2017
+ if (target !== null && typeof target.closest === 'function') {
2018
+ const spot = target.closest(TILT_SELECTOR);
2019
+ if (spot !== null && spot !== current) return;
2020
+ }
2021
+ const rect = current.getBoundingClientRect();
2022
+ if (event.clientX >= rect.left && event.clientX <= rect.right && event.clientY >= rect.top && event.clientY <= rect.bottom) return;
2023
+ release(current);
2024
+ current = null;
2025
+ };
2026
+ document.addEventListener('pointerover', onOver, { passive: true });
2027
+ document.addEventListener('pointermove', onMove, { passive: true });
2028
+ document.addEventListener('pointerout', onOut, { passive: true });
406
2029
  return () => {
407
- if (unsubscribe !== null) unsubscribe();
408
- if (mirror !== null) mirror.disconnect();
2030
+ document.removeEventListener('pointerover', onOver);
2031
+ document.removeEventListener('pointermove', onMove);
2032
+ document.removeEventListener('pointerout', onOut);
2033
+ if (raf !== 0) cancelAnimationFrame(raf);
2034
+ for (const id of settle.values()) clearTimeout(id);
2035
+ settle.clear();
2036
+ for (const spot of document.querySelectorAll(TILT_SELECTOR)) {
2037
+ spot.style.removeProperty('transform');
2038
+ spot.style.removeProperty('transform-origin');
2039
+ }
2040
+ current = null;
2041
+ };
2042
+ }
2043
+
2044
+ /**
2045
+ * Ambient background layer: the DSTT flow field, a WebGL2 two-pass fluid
2046
+ * simulation ported from dsh-theme-mineradio, replacing the particle field.
2047
+ * The particles stay the fallback — {@link startParticles} remains the whole
2048
+ * implementation for engines without WebGL2 — so a missing WebGL2 downgrades
2049
+ * the background instead of blanking it.
2050
+ *
2051
+ * Every colour knob follows the DSTT colour token, so a mode switch re-tints
2052
+ * the flow and the glass edge tint without a remount.
2053
+ */
2054
+ function startAmbient() {
2055
+ if (!supportsWebgl2()) return startParticles();
2056
+ // Which build is running, readable from the page (see README). One line in
2057
+ // the console answers "is the bundle I just installed actually live?".
2058
+ try { window.__dshomeBuild = '1.43.12 bold-hue'; } catch (error) {}
2059
+ const canvas = document.createElement('canvas');
2060
+ canvas.setAttribute('data-dsh-deepseek-canvas', '');
2061
+ const style = canvas.style;
2062
+ style.position = 'fixed';
2063
+ style.top = '0';
2064
+ style.left = '0';
2065
+ style.width = '100%';
2066
+ style.height = '100%';
2067
+ style.zIndex = '-1';
2068
+ style.pointerEvents = 'none';
2069
+ // The fluid paints an opaque full-screen wash; without this it HIDES the
2070
+ // body background, which is where the DSTT colour token actually lands.
2071
+ // Measured: canvas 235,240,252 over a body reading 233,242,241 with the
2072
+ // token green. Letting the page through is what makes a mode switch
2073
+ // visible on screen instead of only in the computed style.
2074
+ style.opacity = '0.55';
2075
+ document.body.appendChild(canvas);
2076
+
2077
+ const fluid = attachFluidShader(canvas, dshomeFluidParams());
2078
+ // ── palette follows the token, every frame ────────────────────────────
2079
+ // The mount above resolves the palette ONCE. Measured failure: with the
2080
+ // token green the body background computed green while the canvas kept
2081
+ // painting its mount palette -- six light/dark x blue/red/green
2082
+ // screenshots all sampled the same blue (159,187,238). Subscriptions and
2083
+ // a MutationObserver were not enough either (1.43.6 tried), because the
2084
+ // colour driver writes the token before this canvas exists. So the
2085
+ // palette is derived from the DOM and compared per frame: two
2086
+ // getAttribute calls when nothing changed, and it cannot miss a writer.
2087
+ let fluidKey = JSON.stringify(dshomeFluidParams());
2088
+ const fluidSync = setInterval(() => {
2089
+ let next;
2090
+ try { next = JSON.stringify(dshomeFluidParams()); } catch (error) { return; }
2091
+ if (next === fluidKey) return;
2092
+ fluidKey = next;
2093
+ try { fluid.setParams(JSON.parse(next)); } catch (error) {}
2094
+ }, 200);
2095
+ // The fluid is deliberately autonomous: no pointer feed (the `fluidBrush`
2096
+ // setting, off by default) and no button stir either. The ported
2097
+ // `attachFluidInteractions` is therefore NOT wired — it is kept in the
2098
+ // file, unmodified, because re-enabling button ripples is one call, but
2099
+ // nothing in this theme uses it today.
2100
+ const stopSpotter = startSpecularSpotter();
2101
+ const stopParallax = startSpecularParallax();
2102
+ const dispersion = startGlassDispersion({ hue: FLUID_HUES[dshomeColor()] });
2103
+ // Both recipes share one filter pair, so the recipe selects the scale:
2104
+ // 104 for liquid (visible edge refraction) and the untouched 60 for
2105
+ // frosted, which is what the pane has always used.
2106
+ const applyGlass = () => {
2107
+ dispersion.setRefraction(dsttGetGlass() === 'liquid' ? LIQUID_REF_SCALE : DEFAULT_REF_SCALE);
2108
+ };
2109
+ applyGlass();
2110
+ const unsubscribeGlass = dsttSubscribe(applyGlass);
2111
+ // ── palette reconciliation ────────────────────────────────────────────
2112
+ // One reader for BOTH inputs the palette depends on: the colour token on
2113
+ // <body> and the dark marker. Reported symptom: "切主题模式背景不变 /
2114
+ // 深色模式背景还是蓝白". The colour half of that was a real dead end --
2115
+ // `subscribeColor` only fires when the notified colour string CHANGES, so
2116
+ // the boot race (this canvas mounts, then the durable mode arrives over
2117
+ // the async bridge and re-resolves the colour) left the flow painted from
2118
+ // whatever the driver had guessed first, and a mode switch that resolved
2119
+ // to the same colour never notified at all. The scheme half had no
2120
+ // listener: a MutationObserver was watching the marker, but `darkSync`
2121
+ // pointedly does not set a *changed* value twice, and the marker itself
2122
+ // was the only thing written.
2123
+ // So: derive from the DOM on every signal instead of trusting the event to
2124
+ // carry it, and box every listener so one throw cannot cost the rest.
2125
+ let fluidParams = JSON.stringify(dshomeFluidParams());
2126
+ const syncFluid = () => {
2127
+ const next = dshomeFluidParams();
2128
+ const key = JSON.stringify(next);
2129
+ if (key === fluidParams) return;
2130
+ fluidParams = key;
2131
+ try { fluid.setParams(next); } catch (error) {}
2132
+ };
2133
+ const unsubscribeColor = subscribeColor((color) => {
2134
+ syncFluid();
2135
+ try { dispersion.setTint(FLUID_HUES[color] ?? FLUID_HUES.green); } catch (error) {}
2136
+ });
2137
+ const unsubscribeDark = darkSync === null ? null : darkSync.subscribe(syncFluid);
2138
+ // The colour driver writes the token as an attribute; watching it as well
2139
+ // keeps this correct no matter who wrote it (the peak-hour chain, a manual
2140
+ // mode pick, or a future caller that forgets to notify).
2141
+ let tokenMirror = null;
2142
+ try {
2143
+ tokenMirror = new MutationObserver(syncFluid);
2144
+ tokenMirror.observe(document.body, { attributes: true, attributeFilter: ['data-dshome-color'] });
2145
+ } catch (error) {
2146
+ tokenMirror = null;
2147
+ }
2148
+ return () => {
2149
+ unsubscribeColor();
2150
+ if (unsubscribeDark !== null) unsubscribeDark();
2151
+ unsubscribeGlass();
2152
+ if (tokenMirror !== null) tokenMirror.disconnect();
2153
+ dispersion.dispose();
2154
+ stopParallax();
2155
+ stopSpotter();
2156
+ clearInterval(fluidSync);
2157
+ fluid.dispose();
2158
+ canvas.remove();
409
2159
  };
410
2160
  }
411
2161
 
412
2162
  function startParticles() {
2163
+ try { window.__dshomeBuild = '1.43.12 bold-hue'; } catch (error) {}
413
2164
  const canvas = document.createElement('canvas');
414
2165
  canvas.setAttribute('data-dsh-deepseek-canvas', '');
415
2166
  const style = canvas.style;
@@ -522,7 +2273,20 @@ body[data-dshome-dark] .VOzbGW_panel{background:rgba(13,30,60,.96)!important}
522
2273
  const colors = palette();
523
2274
  for (const p of parts) p.c = colors[(Math.random() * colors.length) | 0];
524
2275
  };
2276
+ // Two inputs again: the colour token (notified) and the dark marker
2277
+ // (written by darkSync). The particle palette is per scheme, so a
2278
+ // light/dark switch has to re-roll the colours too -- otherwise the
2279
+ // fallback background keeps the scheme it was mounted with, exactly the
2280
+ // bug the fluid path had.
525
2281
  const unsubscribeColor = subscribeColor(refreshColors);
2282
+ const unsubscribeDark = darkSync === null ? null : darkSync.subscribe(refreshColors);
2283
+ let tokenMirror = null;
2284
+ try {
2285
+ tokenMirror = new MutationObserver(refreshColors);
2286
+ tokenMirror.observe(document.body, { attributes: true, attributeFilter: ['data-dshome-color'] });
2287
+ } catch (error) {
2288
+ tokenMirror = null;
2289
+ }
526
2290
 
527
2291
  window.addEventListener('resize', resize);
528
2292
  resize();
@@ -534,6 +2298,8 @@ body[data-dshome-dark] .VOzbGW_panel{background:rgba(13,30,60,.96)!important}
534
2298
  cancelAnimationFrame(rafId);
535
2299
  window.removeEventListener('resize', resize);
536
2300
  unsubscribeColor();
2301
+ if (unsubscribeDark !== null) unsubscribeDark();
2302
+ if (tokenMirror !== null) tokenMirror.disconnect();
537
2303
  canvas.remove();
538
2304
  };
539
2305
  }
@@ -1756,6 +3522,26 @@ body[data-dshome-dark] .${CLS}{background:rgba(14,30,60,.94);box-shadow:0 18px 4
1756
3522
  const DSTT_SET = "dstt.mode.set";
1757
3523
  /** Peak windows, [startHour, endHour), judged in Beijing time (UTC+8). */
1758
3524
  const PEAK_RANGES = [[9, 12], [14, 18]];
3525
+ // The two glass recipes the stylesheet gates on <html data-dshome-glass>.
3526
+ // `liquid` is the default; `frosted` is the pane this theme shipped before.
3527
+ const DSTT_GLASS_STYLES = ["liquid", "frosted"];
3528
+ const DSTT_GLASS_DEFAULT = "liquid";
3529
+ const DSTT_GLASS_LABELS = {
3530
+ liquid: { zh: "液态", en: "Liquid" },
3531
+ frosted: { zh: "白磨砂", en: "Frosted" }
3532
+ };
3533
+ // How wide the composer's edge refraction is under liquid, measured on the
3534
+ // top and bottom edges -- the only two where a displacement has anything to
3535
+ // show. The stylesheet gates the three states on <html data-dshome-composer>.
3536
+ // `origin` was this option's first id and is still accepted from a settings
3537
+ // file written before the rename; it reads back as `wide`.
3538
+ const DSTT_COMPOSER = ["narrow", "wide", "off"];
3539
+ const DSTT_COMPOSER_DEFAULT = "narrow";
3540
+ const DSTT_COMPOSER_LABELS = {
3541
+ narrow: { zh: "窄 8px", en: "Narrow 8px" },
3542
+ wide: { zh: "宽 16px", en: "Wide 16px" },
3543
+ off: { zh: "无", en: "Off" }
3544
+ };
1759
3545
 
1760
3546
  /**
1761
3547
  * Shared in-memory mirror of the durable DSTT mode. The settings domain's
@@ -1763,8 +3549,104 @@ body[data-dshome-dark] .${CLS}{background:rgba(14,30,60,.94);box-shadow:0 18px 4
1763
3549
  * plugin's own loopback channel instead; every reader (the color driver,
1764
3550
  * the settings tab) subscribes to this mirror.
1765
3551
  */
1766
- const dsttState = { mode: "peakvalley-redblue", listeners: new Set() };
3552
+ const dsttState = { mode: "peakvalley-redblue", fluidBrush: false, glassStyle: DSTT_GLASS_DEFAULT, composer: DSTT_COMPOSER_DEFAULT, blur: true, listeners: new Set() };
3553
+ // Fields the user has chosen in this session. A host half that predates a
3554
+ // field ignores it and answers without it -- or with its own default -- so
3555
+ // without this a fresh choice gets overwritten by the next sync and the
3556
+ // option appears to snap straight back to its default.
3557
+ const dsttTouched = new Set();
1767
3558
  const dsttGetMode = () => dsttState.mode;
3559
+ const dsttGetGlass = () => (DSTT_GLASS_STYLES.includes(dsttState.glassStyle) ? dsttState.glassStyle : DSTT_GLASS_DEFAULT);
3560
+ const dsttGetComposer = () => {
3561
+ if (dsttState.composer === "origin") return "wide";
3562
+ return DSTT_COMPOSER.includes(dsttState.composer) ? dsttState.composer : DSTT_COMPOSER_DEFAULT;
3563
+ };
3564
+ const dsttGetBlur = () => dsttState.blur !== false;
3565
+ /**
3566
+ * Turn the glass frosting on or off. Same shape as the other CSS-only
3567
+ * preferences: apply locally first, then let the host persist it, and treat
3568
+ * its answer as confirmation only.
3569
+ */
3570
+ async function dsttSetBlur(ctx, next) {
3571
+ dsttState.blur = next === true;
3572
+ dsttTouched.add("blur");
3573
+ dsttNotify();
3574
+ try {
3575
+ const result = await bridgeCall(DSTT_SET, { mode: dsttState.mode, backdropBlur: dsttState.blur });
3576
+ if (result !== undefined && result !== null && result.ok === true) {
3577
+ return result.value.backdropBlur === dsttState.blur;
3578
+ }
3579
+ } catch (error) {
3580
+ // Fall through: the local choice stands, it just was not stored.
3581
+ }
3582
+ return false;
3583
+ }
3584
+ /**
3585
+ * Persist the composer's refraction width through the bridge.
3586
+ *
3587
+ * Applied locally FIRST, before the round trip. Both this and glassStyle
3588
+ * only flip a CSS attribute, so the choice is fully usable the moment it is
3589
+ * made — and it has to be, because a running dsh keeps the host half it
3590
+ * booted with: until `dsh web` is restarted, `dstt.mode.set` ignores fields
3591
+ * it does not know and answers without them, which used to make a brand new
3592
+ * setting look broken. The cost of applying first is that a choice made
3593
+ * against a stale host is not persisted and reverts on reload, so the
3594
+ * return value still reports the truth.
3595
+ */
3596
+ async function dsttSetComposer(ctx, next) {
3597
+ if (!DSTT_COMPOSER.includes(next)) return false;
3598
+ dsttState.composer = next;
3599
+ dsttTouched.add("composer");
3600
+ dsttNotify();
3601
+ try {
3602
+ const result = await bridgeCall(DSTT_SET, { mode: dsttState.mode, composerRefraction: next });
3603
+ // The response is used ONLY to confirm. It must never be written back
3604
+ // into the mirror: a host that accepts the call but does not store the
3605
+ // field answers with its own value (the default, `narrow`), and copying
3606
+ // that in is what made the option snap straight back the moment the
3607
+ // round trip landed.
3608
+ if (result !== undefined && result !== null && result.ok === true && DSTT_COMPOSER.includes(result.value.composerRefraction)) {
3609
+ return result.value.composerRefraction === next;
3610
+ }
3611
+ } catch (error) {
3612
+ // Fall through: the local choice stands, it just was not stored.
3613
+ }
3614
+ return false;
3615
+ }
3616
+ /** Persist the glass recipe through the bridge; resolves with success.
3617
+ * Applied locally first for the same reason as dsttSetComposer above. */
3618
+ async function dsttSetGlass(ctx, next) {
3619
+ if (!DSTT_GLASS_STYLES.includes(next)) return false;
3620
+ dsttState.glassStyle = next;
3621
+ dsttTouched.add("glassStyle");
3622
+ dsttNotify();
3623
+ try {
3624
+ const result = await bridgeCall(DSTT_SET, { mode: dsttState.mode, glassStyle: next });
3625
+ // Confirmation only -- see dsttSetComposer for why the host's echo must
3626
+ // not be copied back into the mirror.
3627
+ if (result !== undefined && result !== null && result.ok === true && DSTT_GLASS_STYLES.includes(result.value.glassStyle)) {
3628
+ return result.value.glassStyle === next;
3629
+ }
3630
+ } catch (error) {
3631
+ // Fall through: the local choice stands, it just was not stored.
3632
+ }
3633
+ return false;
3634
+ }
3635
+ const dsttGetBrush = () => dsttState.fluidBrush === true;
3636
+ /** Persist the fluid-brush preference (off by default) through the bridge. */
3637
+ async function dsttSetBrush(ctx, next) {
3638
+ try {
3639
+ const result = await bridgeCall(DSTT_SET, { mode: dsttState.mode, fluidBrush: next === true });
3640
+ if (result !== undefined && result !== null && result.ok === true) {
3641
+ dsttState.fluidBrush = result.value.fluidBrush === true;
3642
+ dsttNotify();
3643
+ return true;
3644
+ }
3645
+ } catch (error) {
3646
+ // Fall through to the caller's failure handling.
3647
+ }
3648
+ return false;
3649
+ }
1768
3650
  const dsttSubscribe = (listener) => {
1769
3651
  dsttState.listeners.add(listener);
1770
3652
  return () => dsttState.listeners.delete(listener);
@@ -1794,12 +3676,24 @@ body[data-dshome-dark] .${CLS}{background:rgba(14,30,60,.94);box-shadow:0 18px 4
1794
3676
  return await response.json();
1795
3677
  }
1796
3678
 
3679
+ /** Fallback used when the host half is unavailable. */
3680
+ const dsttGetBlurFallback = () => dsttState.blur !== false;
3681
+
1797
3682
  /** Pull the durable mode from the host half once. */
1798
3683
  async function dsttSync(ctx) {
1799
3684
  try {
1800
3685
  const result = await bridgeCall(DSTT_GET, {});
1801
3686
  if (result !== undefined && result !== null && result.ok === true && DSTT_MODES.includes(result.value.mode)) {
1802
3687
  dsttState.mode = result.value.mode;
3688
+ dsttState.fluidBrush = result.value.fluidBrush === true;
3689
+ // An older host half answers without a glass recipe: keep the
3690
+ // default rather than clearing the attribute to nothing. And a
3691
+ // field the user has already chosen this session is never taken
3692
+ // back from the host -- a stale host answers with its own default,
3693
+ // which is what made a fresh choice look like it snapped back.
3694
+ if (!dsttTouched.has("glassStyle") && DSTT_GLASS_STYLES.includes(result.value.glassStyle)) dsttState.glassStyle = result.value.glassStyle;
3695
+ if (!dsttTouched.has("composer") && DSTT_COMPOSER.includes(result.value.composerRefraction)) dsttState.composer = result.value.composerRefraction;
3696
+ if (!dsttTouched.has("blur") && typeof result.value.backdropBlur === "boolean") dsttState.blur = result.value.backdropBlur;
1803
3697
  dsttNotify();
1804
3698
  }
1805
3699
  } catch (error) {}
@@ -1964,10 +3858,18 @@ body[data-dshome-dark] .${CLS}{background:rgba(14,30,60,.94);box-shadow:0 18px 4
1964
3858
 
1965
3859
  anchor();
1966
3860
 
3861
+ // The durable mode crosses an async bridge (dsttSync), so the anchor above
3862
+ // may have resolved the colour from the DEFAULT mode -- its 常态绿/常态蓝
3863
+ // token then never appears, and the background keeps the first guess. One
3864
+ // extra read after the sync has had its turn fixes the boot race, and it
3865
+ // is idempotent, so it cannot fight a later answer.
3866
+ const bootTimer = setTimeout(anchor, 0);
3867
+
1967
3868
  try { unsubscribe = dsttSubscribe(anchor); } catch (error) { unsubscribe = null; }
1968
3869
 
1969
3870
  return () => {
1970
3871
  stopped = true;
3872
+ clearTimeout(bootTimer);
1971
3873
  if (chainTimer !== 0) clearTimeout(chainTimer);
1972
3874
  if (unsubscribe !== null) unsubscribe();
1973
3875
  document.removeEventListener('visibilitychange', onVisibility);
@@ -2041,6 +3943,30 @@ body[data-dshome-dark] .${CLS}{background:rgba(14,30,60,.94);box-shadow:0 18px 4
2041
3943
  if (dstt === undefined || next === mode) return;
2042
3944
  dstt.set(next);
2043
3945
  };
3946
+ // The brush is a durable preference, not local state: flipping it asks the
3947
+ // host to persist it and the mirror re-renders this panel.
3948
+ const brushOn = dstt !== undefined && typeof dstt.brush === 'function' ? dstt.brush() === true : false;
3949
+ const toggleBrush = () => {
3950
+ if (dstt === undefined || typeof dstt.setBrush !== 'function') return;
3951
+ dstt.setBrush(!brushOn);
3952
+ };
3953
+ // The glass recipe is durable too, and the mirror re-renders this panel
3954
+ // when the host confirms the write.
3955
+ const glassNow = dstt !== undefined && typeof dstt.glass === 'function' ? dstt.glass() : DSTT_GLASS_DEFAULT;
3956
+ const pickGlass = (next) => {
3957
+ if (dstt === undefined || typeof dstt.setGlass !== 'function' || next === glassNow) return;
3958
+ dstt.setGlass(next);
3959
+ };
3960
+ const composerNow = dstt !== undefined && typeof dstt.composer === 'function' ? dstt.composer() : DSTT_COMPOSER_DEFAULT;
3961
+ const pickComposer = (next) => {
3962
+ if (dstt === undefined || typeof dstt.setComposer !== 'function' || next === composerNow) return;
3963
+ dstt.setComposer(next);
3964
+ };
3965
+ const blurOn = dstt !== undefined && typeof dstt.blur === 'function' ? dstt.blur() !== false : true;
3966
+ const toggleBlur = () => {
3967
+ if (dstt === undefined || typeof dstt.setBlur !== 'function') return;
3968
+ dstt.setBlur(!blurOn);
3969
+ };
2044
3970
 
2045
3971
  return React.createElement('div', { className: 'dshome-dstt' },
2046
3972
  React.createElement('h3', null,
@@ -2064,6 +3990,62 @@ body[data-dshome-dark] .${CLS}{background:rgba(14,30,60,.94);box-shadow:0 18px 4
2064
3990
  className: 'dshome-dstt-seg-btn' + (mode === m ? ' dshome-on' : ''),
2065
3991
  onClick: () => pickMode(m)
2066
3992
  }, isZh ? DSTT_LABELS[m].zh : DSTT_LABELS[m].en)))),
3993
+ React.createElement('div', { className: 'dshome-dstt-row' },
3994
+ React.createElement('div', { className: 'dshome-dstt-row-body' },
3995
+ React.createElement('div', { className: 'dshome-dstt-row-title' }, isZh ? '流体跟随笔刷' : 'Fluid follow brush'),
3996
+ React.createElement('div', { className: 'dshome-dstt-row-hint' }, isZh
3997
+ ? '开启后光标会把背景流场搅出一条跟随的尾迹。它是整个模拟里最贵的一部分,默认关闭;改完刷新页面生效。'
3998
+ : 'Lets the cursor stir a trail into the background flow. It is the most expensive part of the simulation, so it is off by default; reload after changing.')),
3999
+ React.createElement('button', {
4000
+ type: 'button',
4001
+ role: 'switch',
4002
+ 'aria-checked': brushOn,
4003
+ className: 'dshome-dstt-seg-btn' + (brushOn ? ' dshome-on' : ''),
4004
+ onClick: toggleBrush
4005
+ }, brushOn ? (isZh ? '已开启' : 'On') : (isZh ? '已关闭' : 'Off'))),
4006
+ React.createElement('div', { className: 'dshome-dstt-row' },
4007
+ React.createElement('div', { className: 'dshome-dstt-row-body' },
4008
+ React.createElement('div', { className: 'dshome-dstt-row-title' }, isZh ? '玻璃风格' : 'Glass style'),
4009
+ React.createElement('div', { className: 'dshome-dstt-row-hint' }, isZh
4010
+ ? '液态:透镜折射 + 会走圈的边缘高光,更通透(本次方向)。白磨砂:此前那套白磨砂 + 蓝变光边框,观感与从前完全一致。'
4011
+ : 'Liquid: lens refraction plus a highlight that travels the border, far more translucent (the current direction). Frosted: the white frosted pane with the blue shifting border, pixel-identical to what shipped before.')),
4012
+ React.createElement('div', { className: 'dshome-dstt-seg', role: 'radiogroup', 'aria-label': isZh ? '玻璃风格' : 'Glass style' },
4013
+ DSTT_GLASS_STYLES.map((style) => React.createElement('button', {
4014
+ key: style,
4015
+ type: 'button',
4016
+ role: 'radio',
4017
+ 'aria-checked': glassNow === style,
4018
+ className: 'dshome-dstt-seg-btn' + (glassNow === style ? ' dshome-on' : ''),
4019
+ onClick: () => pickGlass(style)
4020
+ }, isZh ? DSTT_GLASS_LABELS[style].zh : DSTT_GLASS_LABELS[style].en)))),
4021
+ React.createElement('div', { className: 'dshome-dstt-row' },
4022
+ React.createElement('div', { className: 'dshome-dstt-row-body' },
4023
+ React.createElement('div', { className: 'dshome-dstt-row-title' }, isZh ? '对话框边缘倒影' : 'Composer edge reflection'),
4024
+ React.createElement('div', { className: 'dshome-dstt-row-hint' }, isZh
4025
+ ? '液态下对话框边缘的折射带宽(按上下量——左右背后是连续背景,同样的位移看不出变化)。窄 8px(默认)/ 宽 16px / 无,三者都是专为这张卡片做的位移图。'
4026
+ : 'Width of the lens band at the composer edge under liquid, measured top and bottom — left and right sit over a continuous backdrop where the same displacement shows nothing. Narrow 8px (default) / Wide 16px / Off; each is a map built for this card.')),
4027
+ React.createElement('div', { className: 'dshome-dstt-seg', role: 'radiogroup', 'aria-label': isZh ? '对话框边缘倒影' : 'Composer edge reflection' },
4028
+ DSTT_COMPOSER.map((choice) => React.createElement('button', {
4029
+ key: choice,
4030
+ type: 'button',
4031
+ role: 'radio',
4032
+ 'aria-checked': composerNow === choice,
4033
+ className: 'dshome-dstt-seg-btn' + (composerNow === choice ? ' dshome-on' : ''),
4034
+ onClick: () => pickComposer(choice)
4035
+ }, isZh ? DSTT_COMPOSER_LABELS[choice].zh : DSTT_COMPOSER_LABELS[choice].en)))),
4036
+ React.createElement('div', { className: 'dshome-dstt-row' },
4037
+ React.createElement('div', { className: 'dshome-dstt-row-body' },
4038
+ React.createElement('div', { className: 'dshome-dstt-row-title' }, isZh ? '背景模糊(磨砂)' : 'Backdrop blur'),
4039
+ React.createElement('div', { className: 'dshome-dstt-row-hint' }, isZh
4040
+ ? '玻璃面板后面那层虚化。关闭后玻璃变成纯半透明:通透度、顶部光泽、边缘折射都保留,只是不再把背后的东西磨掉。'
4041
+ : 'The frosting behind every glass pane. Off leaves the translucency, the sheen and the edge refraction intact and only stops blurring what is behind the glass.')),
4042
+ React.createElement('button', {
4043
+ type: 'button',
4044
+ role: 'switch',
4045
+ 'aria-checked': blurOn,
4046
+ className: 'dshome-dstt-seg-btn' + (blurOn ? ' dshome-on' : ''),
4047
+ onClick: toggleBlur
4048
+ }, blurOn ? (isZh ? '已开启' : 'On') : (isZh ? '已关闭' : 'Off'))),
2067
4049
  React.createElement('div', { className: 'dshome-dstt-status', 'data-peak': timeSliced && peakNow },
2068
4050
  '当前:' + colorName + ' · ' + status));
2069
4051
  }
@@ -2091,8 +4073,22 @@ body[data-dshome-dark] .${CLS}{background:rgba(14,30,60,.94);box-shadow:0 18px 4
2091
4073
 
2092
4074
  // Dark marker: owned attribute driven by the theme service, never by
2093
4075
  // the product's attribute name. Must precede the patch blocks so the
2094
- // dark selectors match from the first paint.
2095
- ctx.effect(() => createDarkSync(ctx, theme), 'deepseek-style-theme: dark sync');
4076
+ // dark selectors match from the first paint. The handle is kept in scope
4077
+ // because the ambient background subscribes to its writes: the marker
4078
+ // alone was not enough, since nothing re-read it when the scheme changed.
4079
+ let darkSync = null;
4080
+ ctx.effect(() => {
4081
+ const handle = createDarkSync(ctx, theme);
4082
+ darkSync = handle;
4083
+ return () => {
4084
+ if (darkSync === handle) darkSync = null;
4085
+ handle.dispose();
4086
+ };
4087
+ }, 'deepseek-style-theme: dark sync');
4088
+
4089
+ // Glass-recipe marker: same idea, and it has to be on <html> before the
4090
+ // first paint of the glass surfaces or the pane flashes the other recipe.
4091
+ ctx.effect(() => createGlassSync(ctx), 'deepseek-style-theme: glass style sync');
2096
4092
 
2097
4093
  // Guarded product-surface patches: each block activates only while
2098
4094
  // its anchor class exists in the DOM.
@@ -2100,6 +4096,17 @@ body[data-dshome-dark] .${CLS}{background:rgba(14,30,60,.94);box-shadow:0 18px 4
2100
4096
  ctx.effect(() => installGuarded(block.anchor, block.css), 'deepseek-style-theme: patch ' + block.anchor);
2101
4097
  }
2102
4098
 
4099
+ // Liquid glass wins by SPECIFICITY, not by order: the patch blocks are
4100
+ // injected lazily when their anchor appears and set `background`
4101
+ // (shorthand) with !important, so every glass selector below is written
4102
+ // as `html .surface` — one type selector of extra weight — instead of
4103
+ // racing their insertion order.
4104
+ ctx.effect(() => injectStyle(GLASS_CSS, 'glass.css'), 'deepseek-style-theme: liquid glass');
4105
+ // The liquid recipe is a second sheet rather than an edit of the first:
4106
+ // every rule inside is gated on html[data-dshome-glass="liquid"], so the
4107
+ // frosted pane keeps rendering exactly what it rendered before.
4108
+ ctx.effect(() => injectStyle(LIQUID_CSS, 'liquid-glass.css'), 'deepseek-style-theme: apple liquid glass');
4109
+
2103
4110
  if (theme !== undefined) {
2104
4111
  const disposeTokens = theme.overrideTokens('deepseek-style-theme', {
2105
4112
  '--dsw-alias-bg-base': { light: '#f6f7fb', dark: '#0a1a3a' },
@@ -2120,8 +4127,14 @@ body[data-dshome-dark] .${CLS}{background:rgba(14,30,60,.94);box-shadow:0 18px 4
2120
4127
  }
2121
4128
 
2122
4129
  ctx.effect(() => {
2123
- try { return startParticles(); } catch (error) { return () => {}; }
2124
- });
4130
+ try { return startAmbient(); } catch (error) { return () => {}; }
4131
+ }, 'deepseek-style-theme: fluid background');
4132
+ // The composer's hover tilt is independent of the background: it must
4133
+ // survive a machine without WebGL2, where startAmbient() falls back to
4134
+ // the 2D particle field.
4135
+ ctx.effect(() => {
4136
+ try { return startComposerTilt(); } catch (error) { return () => {}; }
4137
+ }, 'deepseek-style-theme: composer hover tilt');
2125
4138
  ctx.effect(() => {
2126
4139
  try { return watchSettingsSection(); } catch (error) { return () => {}; }
2127
4140
  });
@@ -2156,6 +4169,14 @@ body[data-dshome-dark] .${CLS}{background:rgba(14,30,60,.94);box-shadow:0 18px 4
2156
4169
  dstt: {
2157
4170
  mode: dsttGetMode,
2158
4171
  set: (mode) => dsttSetMode(ctx, mode),
4172
+ brush: dsttGetBrush,
4173
+ setBrush: (next) => dsttSetBrush(ctx, next),
4174
+ glass: dsttGetGlass,
4175
+ setGlass: (next) => dsttSetGlass(ctx, next),
4176
+ composer: dsttGetComposer,
4177
+ setComposer: (next) => dsttSetComposer(ctx, next),
4178
+ blur: dsttGetBlur,
4179
+ setBlur: (next) => dsttSetBlur(ctx, next),
2159
4180
  subscribe: dsttSubscribe
2160
4181
  },
2161
4182
  locale: ctx.get('locale')
@@ -2169,12 +4190,11 @@ body[data-dshome-dark] .${CLS}{background:rgba(14,30,60,.94);box-shadow:0 18px 4
2169
4190
  return module.exports;
2170
4191
  };
2171
4192
 
2172
- // Both ids, same factory. The package moved from
2173
- // @dsh-external/dsh-deepseek-style-theme to the unscoped
2174
- // dsh-deepseek-style-theme, and the loader asks a bundle to register under
2175
- // whichever id the installed copy carries -- while this rolled-back file
2176
- // still carries the old literal internally. Registering both, each guarded,
2177
- // means either host finds the id it wants and the other entry is simply
2178
- // never requested.
2179
- try { window.__ModuleLoader__.load({ id: "dsh-deepseek-style-theme", factory: dshDeepseekStyleThemeFactory }); } catch (error) {}
2180
- try { window.__ModuleLoader__.load({ id: "@dsh-external/dsh-deepseek-style-theme", factory: dshDeepseekStyleThemeFactory }); } catch (error) {}
4193
+ // Both ids, same factory. See the note at the top of this file for why one
4194
+ // literal cannot work during the rename.
4195
+ try {
4196
+ window.__ModuleLoader__.load({ id: "dsh-deepseek-style-theme", factory: dshDeepseekStyleThemeFactory });
4197
+ } catch (error) {}
4198
+ try {
4199
+ window.__ModuleLoader__.load({ id: "@dsh-external/dsh-deepseek-style-theme", factory: dshDeepseekStyleThemeFactory });
4200
+ } catch (error) {}