dsh-fish-ui 0.3.1 → 0.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +0 -1
- package/README.md +29 -6
- package/THIRD-PARTY-NOTICES +24 -0
- package/dist/client.js +3823 -0
- package/dist/index.js +20 -0
- package/icon.png +0 -0
- package/icon.svg +15 -9
- package/locale/en.json +1 -1
- package/locale/zh.json +1 -1
- package/package.json +18 -7
- package/client.js +0 -3344
- package/index.js +0 -16
package/client.js
DELETED
|
@@ -1,3344 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Deep Fish UI — the blank New Session surface.
|
|
3
|
-
*
|
|
4
|
-
* The blank home becomes a dotted composition: a dot-matrix portrait on the
|
|
5
|
-
* right and the deepseek / harness wordmark on the left, both driven by one
|
|
6
|
-
* canvas layer registered into `conversation.hero.frame` (the HOC slot that
|
|
7
|
-
* wraps the Conversation scroll body and reports whether the blank home shows).
|
|
8
|
-
* The layer renders the wrapped `children` unchanged and paints below the
|
|
9
|
-
* content (`z-index: -1`, `pointer-events: none`).
|
|
10
|
-
*
|
|
11
|
-
* It also hides the stock home chrome it replaces: the headline, the brand mark,
|
|
12
|
-
* and the official pixel-whale canvas. A faint `dsh-fish-ui` signature sits in
|
|
13
|
-
* the page corner while the home is showing.
|
|
14
|
-
*
|
|
15
|
-
* The stylesheet below also carries the accent half in the same bundle:
|
|
16
|
-
* whale-blue bold runs in chat prose, the whale-blue composer focus ring, and the
|
|
17
|
-
* re-inked diff plates. One install, one stylesheet, one place to tune.
|
|
18
|
-
*/
|
|
19
|
-
window.__ModuleLoader__.load({
|
|
20
|
-
id: 'dsh-fish-ui',
|
|
21
|
-
factory(require) {
|
|
22
|
-
const React = require('react')
|
|
23
|
-
const h = React.createElement
|
|
24
|
-
|
|
25
|
-
/* ------------------------------------------------------------ hero mascot */
|
|
26
|
-
|
|
27
|
-
/** Dot grid sampled from the mascot artwork: one hex digit per cell. */
|
|
28
|
-
const GIRL_COLUMNS = 104
|
|
29
|
-
const GIRL_ROWS = 73
|
|
30
|
-
const GIRL_GRID = '00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000121100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000013133112320000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000163116400000264223200000000000000000000000000000000000000000000000000000000000000000000000000000000000326000001000000a800134000000000000000000000000000000000000000000000000000000000000000000000000000000002500000001200020000000014000000000000000000000000000000000000000000000000000000000000000000000000000000353000310023201320020000050000000000000000000000000000000000000000000000000000000000000000000000000000003000003310000000001300001b33300000000000000000000000000000000000000000000000000000000000000000000000000100010110035457764200000022002400000000000000000000000000000000000000000000000000000000000000000000000030000300006aba999accb820022000003000000000000000000000000000000000000000000000000000000000000000000000031000000224abbaa976778bca300200008900000000000000000000000000000000000000000000000000000000000000000000a1031005789787777898777679c8000000055000000000000000000000000000000000000000000000000000000000000000000b800220a98b96777777788777777ab30001008100000000000000000000000000000000000000000000000000000000000000007f00002b97b97777777777777777768c402100460000000000000000000000000000000000000000000000000000000000000000ef4000a9699777777777777778777677b600000a2000000000000000000000000000000000000000000000000000000000000000820107a68978777777777777778766788b30000c220000000000000000000000000000000000000000000000000000000000000300003b77887877777777877777787677889220af30300000000000000000000000000000000000000000000000000000000000130000897787787777777797754778877779960025d002000000000000000000000000000000000000000000000000000000000040000297777778777875878a777677977777981000870300000000000000000000000000000000000000000000000000000000003101069878778777865578779777778977778a70105a0300000000000000000000000000000000000000000000000000000000000c60288778778877744778855977777987777994004b0401000000000000000000000000000000000000000000000000000000008d00596788777777757878880497777897777888009a059800000000000000000000000000000000000000000000000000000002e00077578878668777777899203987779777778931ea57780000000000000000000000000000000000000000000000000000000aa004956788784587777777894246988789787788648688681000000000000000000000000000000000000000000000000000000ec00784679878439877777868710049888a74778877667da30000000000000000000000000000000000000000000000000000002fe20964779878408877777856800005878836877877749dd800000000000000000000000000000000000000000000000000000003c01857679879305977777762910000327985487876a7bbad90000000000000000000000000000000000000000000000000000000e00778679878433887877782610001620864877786aecbaad700000000000000000000000000000000000000000000000000002dda47786798787005868867755205cffde4587778887bbbaaad7000000000000000000000000000000000000000000000000004dccdb677778979300076788777604fc5d48fa77778868aaaaaaad50000000000000000000000000000000000000000000000003c2bcc9677778976300046677777704cb7ca0b96777796bbaaaaaaad400000000000000000000000000000000000000000000000a91ebb8777777974300002477776460abe8a02387877889acbaaaaabc2000000000000000000000000000000000000000000000009edba77777779812039a7038678400687660058787689703accbaaabc1000000000000000000000000000000000000000000000004ba977777778900dffab603624520073430087886599c00037bccbabc000000000000000000000000000000000000000000000000ba878787778908c9c89b001100000121104789756a9a900000369ccdb0000000000000000000000000000000000000000000000aca88969777893f26bbe91000111111111347a8649a98b8100000015afc000000000000000000000000000000000000000000006caa8996a877786f01a6562011111111222237a669aa888cb7414600000aa0000000000000000000000000000000000000000002daaa89b6a96777b9502742111111000111110586999998799047558778698000000000000000000000000000000000000000000bbaabaa969a77778600022011110012201100177aa7999777a400000210210000000000000000000000000000000000000000009caaadc6078b877779501112111036666010028aaa76a9a777880000000000000000000000000000000000000000000000000006daabda144a7aa778777401211105a434201000bb996699a86778400000000000000000000000000000000000000000000000005daaca4002aa7898789777532111014343101009d987769aa9677781000000000000000000000000000000000000000000000003dbcc700006c99788977a8473001110011001009db877768a9976767700000000000000000000000000000000000000000000000ddc8200005c9998789a868acb20000000011004cbb777667a9a8676786000000000000000000000000000000000000000000000bb600008867aa88977899967abc8310000000235baa7774678a99666759600000000000000000000000000000000000000000000d6269893007b9787778a788779aabcba52213425cb898536889997667509700000000000000000000000000000000000000000000562020000b97788889a967898989bb65444433278aa7647798998666810780000000000000000000000000000000000000000000000000007b7777225bca7768b989b802333331015c977677a889966777004830000000000000000000000000000000000000000000000000b7778410007c8676898ac502122222203c9877669a88a97878400096000000000000000000000000000000000000000000000006878861220003957889984001019491111ba986569a99aa447781000991000000000000000000000000000000000000000000006878785022000047576608100107e1e6000069a5458bb82000777600008a300000000000000000000000000000000000000000498787787113a00017454607a8bbac969b676067264478200000576840000995000000000000000000000000000000000000005996888788620aa0100835b607edbbdb687bdcccc6295362000000576682000198520000000000000000000000000000000000587204876892004b00214834a904fcbba9677bcbacb07a844500000098666700006965300000000000000000000000000000005740001977799000ad000077446b00cdcbada09caaae702977662001009a7666600029706200000000000000000000000000000970000088768a8102ce200085448d101cbabd706eaabb002d967885300005966665101881060000000000000000000000000001a70000078777999206cda0028435c6002babcc201dcbb7002bea6889940006a8766662588303500000000000000000000000000990000079776898a609bce005634ac006fbabbb010bbbac7002de22878a810398875555779200710000000000000000000000007a50000797777989911bbbc006348f9003bdcac60e57cabcf6008d80877984607988755545700073000000000000000000000003995003897776987a503daae81659df6000047dc30005dbbb81002dd27777906259888854545510850000000000000000000000078894688777679789006caad9593aed0001100c901001cd2000000af8677771b429888885455566740000000000000000000000098777787777787789308cab97820df4001000021000008400011004c7778726d60398888974454566400000000000000000000019665687777678778787aab768300eb00010001011200100120000158857a20cf702987876985445768740000000000000000003666668777777877767bcab8679002f40001000100013500001000000af752005f706a7789008a53450488500000000000000038867667877787787777bbab9776bb02e00000000000009e000010000002fa00009d6099877930099634303783000000000000189402766787789778778baaaa89769fa2d000000000000000000000000000dc0006dc6059877870079973530486000000000005a4000766687889777777baaaaa8b757e52d000000000000100100000000000ad003fbc606787778008889745106700000000008a1000676568888877787abaaaaa9aa77901f3000000000001001000000000008c000acba3777877900977896550070000000008b00001756568888877787baaaaaaa9baba00f8002210000000000000000000009b000cbab967678785787788966305000000007a4000046466588888777769cbaaaaaaaabd10be1123232100106a001000000000c800ccaaaa767677788777a258556400000004980000065466579888777765acbbaaaaabbcc04f9012222321107c011011122005f200dbaaab96776777777880086561000000078700001654465688887775665bbbbaaaaabcd009f702222223221012233323321ec02bcbaaaab86776777788000475620'
|
|
31
|
-
const GIRL_LINES = '000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001221000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000050551247200000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e601e8000001b624620000000000000000000000000000000000000000000000000000000000000000000000000000000000061f000000000000ff00068000000000000000000000000000000000000000000000000000000000000000000000000000000004b000000004000300000000090000000000000000000000000000000000000000000000000000000000000000000000000000006c5000600015100520030000080000000000000000000000000000000000000000000000000000000000000000000000000000005000005700000000000400000f55700000000000000000000000000000000000000000000000000000000000000000000000000100020000012125521100000021002800000000000000000000000000000000000000000000000000000000000000000000000070000600003fea779dfff910011000005000000000000000000000000000000000000000000000000000000000000000000000050000000112deb98422225efe10010000ff00000000000000000000000000000000000000000000000000000000000000000000f006000259b233233353322239fb000000099000000000000000000000000000000000000000000000000000000000000000000fd00110f95f52223222233323323cf1000000f000000000000000000000000000000000000000000000000000000000000000007f00001f82a43333333332333333324f2010005c0000000000000000000000000000000000000000000000000000000000000000ff1000f9254333333333333333333223f400000f1000000000000000000000000000000000000000000000000000000000000000f10008e23433333333333333323322333f10000f110000000000000000000000000000000000000000000000000000000000000300001f3333333333333332322234223335d110ff10400000000000000000000000000000000000000000000000000000000000060000983333333333333353222323422326920012f0010000000000000000000000000000000000000000000000000000000000700001d33333333334223239232232632323990000da0300000000000000000000000000000000000000000000000000000000004000059333333333322223337333323523324b70002f0100000000000000000000000000000000000000000000000000000000000f901b5333323333212233322b333326323336c1001f010000000000000000000000000000000000000000000000000000000000cf002b22333332332224343601a333236233237800bf02ee00000000000000000000000000000000000000000000000000000001f00085233324224333332369101a43326323334910fb246d0000000000000000000000000000000000000000000000000000000ff002c22333262273333333492116b733342333452152332b0000000000000000000000000000000000000000000000000000000ff00791234337119333333327a0002c533a31233332223f810000000000000000000000000000000000000000000000000000001ff10d22234338108633332422d00002735612433323313cf300000000000000000000000000000000000000000000000000000001f00a22235339102933322321f0000011287223333273743f80000000000000000000000000000000000000000000000000000000f005242343381118533222618000002104213333324f8433f400000000000000000000000000000000000000000000000000001ff813332243288004825322522102fffff1253323333654344f2000000000000000000000000000000000000000000000000001fc9d823332342b100082453224601fd2f13f9333233234333344f20000000000000000000000000000000000000000000000001f16683233323634100013233324901f72c90f82333342894333335f100000000000000000000000000000000000000000000000f90f453233323751100001163242270bdf3c011423323347e9433336f100000000000000000000000000000000000000000000000dfd4432333326801018d201b46b200572260025333233201afc84349f0000000000000000000000000000000000000000000000001a4323333334900fff7c2017129100b1110083432243f00013dfd97bf000000000000000000000000000000000000000000000000b5333233233806f3a36f000100000010002547322739900000128ffff0000000000000000000000000000000000000000000000cb533325322361f12ccfb0000000000000124b3225733e7000000002bff000000000000000000000000000000000000000000002f4433327322342f00e2251000000000111116b22584333ff9204a00000ff0000000000000000000000000000000000000000001f54433a2642323c9201a1100000000000001023243333325b03d86fced4fe000000000000000000000000000000000000000000f943548724822224200011000000001100000043662334223d100000100100000000000000000000000000000000000000000008e444ff2023932322b20000100002babe00001896932434322780000000000000000000000000000000000000000000000000002f548fa0119276333225100110009f214200000ea33224353222a200000000000000000000000000000000000000000000000002f66eb1001b72343235325211000005343000008f3332234432224a0000000000000000000000000000000000000000000000001fbdf300002e333333239322100000000000000af932222363422226a00000000000000000000000000000000000000000000000fff5100002f434333383238ff10000000000001f8722322353532223b8000000000000000000000000000000000000000000000ff20000ff45b5333323433228bf5100000000112e73232123343422222e900000000000000000000000000000000000000000000f515fef1003a3233223533322389dfff41102612fa33321233335222420fb00000000000000000000000000000000000000000000591010000f622557477323343333be36255411134662222343333222800cf0000000000000000000000000000000000000000000000000005f2236112ff922238333c601111111002f4332227333522246003f10000000000000000000000000000000000000000000000000f3337100006f52323437f201011111101f43322245338836491000fb000000000000000000000000000000000000000000000005623440110001d2253675100000c1f0000fa542224767ef1175b0000ff0000000000000000000000000000000000000000000004734352011000015242207000004f1f2000027d2125df9100065780000ff1000000000000000000000000000000000000000002e9343376001f00009121203b3dd8f324d222022121169100000272a10000ff3000000000000000000000000000000000000006ff2633269710ff0000c12f303fc66e72338eceef21c21410000002622b10001fa6100000000000000000000000000000000009fc1026323a1001f00102c11da02f744332237754ce03f6214000000e9222900005d46200000000000000000000000000000009f50000b3228a000cf0000b7112f00fc444d803a444f30172225100000fe222470001c70a100000000000000000000000000000fc00000b522398001ff1000d2126f000c444f302f444c001f6236a2100002922246000bc00d0000000000000000000000000000fc000008822246a102efb001d112f20018447f100f8463001ff9256ab20003c42224712ab102900000000000000000000000000ff000008b322354b20899f005511af005f9446c000b644d2001ff11536fc001c542222257e100f00000000000000000000000009f200009b3223536a10d46d006113f8001ffa4e20f22c45df7007f303328815056353222129000e3000000000000000000000001d92001aa3222433a201f44f30325ff2000013ff10002faafa0001ff12322904129334422222400d500000000000000000000000995a12a7222234338002e44f62c18ff0000000fd00000ff1000000cf3233440f2195334421223659100000000000000000000000c6322452222243337103a4632910ff100000001000000d200012001f2337712f2018333493112123610000000000000000000000c222242222233333232558325100ff00010000000400000010000025322f10ff201933432ca211287dc200000000000000000017322243222323333229a463228001f10001000000002700000000000df321002f202b323900ae212201cd60000000000000002fd6622243223323332375443222cf01f0000100010000ff000010000001fb00006f20b8322b100ab212101be10000000000000ff3016223322352333237444434225fb1f000000001000000000010000000ff0002fe20284228600598212101f8000000000007f500083223333432333364443439222f21f000000001000000000000000000ef001f9c20235324b008538313009d0000000000ef0000772223333332233554443434422500f1000000000000000000000000009f00089641323422a009234922400e000000000df00001922224333322233a44344443448900f900140000000000000000000000df000d547522233252242246a24109000000009f1000056242253333222323c4433444444f00ff001324200000cf000000000000fa00fc4446222223255222c12b229300000001eb000008312223433322232249444444445cf01fb00111241000df000000133002f100f64446322222322228900c32900000000ab80000082112224333223222244444444448f007f701111224110001246323310ff01fd44444832222322248000172810'
|
|
32
|
-
|
|
33
|
-
/** Grid aspect (width / height), used to keep the portrait undistorted. */
|
|
34
|
-
const GIRL_ASPECT = GIRL_COLUMNS / GIRL_ROWS
|
|
35
|
-
|
|
36
|
-
/** Wordmark set in dots on the left: two lines, sampled from live text. */
|
|
37
|
-
const LOCKUP_LINES = ['deepseek', 'harness']
|
|
38
|
-
const LOCKUP_COLUMNS = 140
|
|
39
|
-
const LOCKUP_ROWS = 58
|
|
40
|
-
|
|
41
|
-
/** Alpha buckets drawn per frame, so the twinkle costs one fill per level. */
|
|
42
|
-
const LEVELS = 12
|
|
43
|
-
const TAU = Math.PI * 2
|
|
44
|
-
|
|
45
|
-
/**
|
|
46
|
-
* Twinkle refresh rate. The field is dense, so the frame budget is kept
|
|
47
|
-
* loose: slow alpha breathing reads the same at 16 fps, and the canvas is
|
|
48
|
-
* only alive while the blank home is on screen.
|
|
49
|
-
*/
|
|
50
|
-
const FRAME_MS = 1000 / 30
|
|
51
|
-
|
|
52
|
-
/** One dot's cell in CSS pixels: fixed, so dots never scale with the window. */
|
|
53
|
-
const DOT_PITCH = 9
|
|
54
|
-
|
|
55
|
-
/** Smallest dot pitch the wordmark may use before it is dropped. */
|
|
56
|
-
const TEXT_MIN_PITCH = 3.6
|
|
57
|
-
|
|
58
|
-
/** Wordmark assembly: dots reveal left to right over this long. */
|
|
59
|
-
const ASSEMBLY_MS = 1300
|
|
60
|
-
|
|
61
|
-
/** Each line's slice of the assembly, in timeline fractions: line 1 starts
|
|
62
|
-
* while line 0 is still finishing, so the two never pop at once. */
|
|
63
|
-
const ASSEMBLY_SECOND_LINE = 0.42
|
|
64
|
-
const ASSEMBLY_LINE_SPAN = 0.58
|
|
65
|
-
|
|
66
|
-
/** Temporary on-canvas readout used to diagnose layout mismatches. */
|
|
67
|
-
const DEBUG = false
|
|
68
|
-
|
|
69
|
-
/** Dot model of the portrait for the light canvas (ink-weighted). */
|
|
70
|
-
let dotModel
|
|
71
|
-
|
|
72
|
-
/** Dot model of the portrait for the dark canvas (line-art weighted). */
|
|
73
|
-
let lineModel
|
|
74
|
-
|
|
75
|
-
/** Dot model of the wordmark, built once by rasterising live text. */
|
|
76
|
-
let lockupModel
|
|
77
|
-
|
|
78
|
-
/**
|
|
79
|
-
* Decode one hex grid into dots: one dot per non-empty cell, weight from the
|
|
80
|
-
* digit, each with its own twinkle phase and speed so the field never blinks
|
|
81
|
-
* in unison.
|
|
82
|
-
* @param cells - one hex digit per grid cell, row-major.
|
|
83
|
-
* @returns dots in normalised space (`u`/`v` 0..1, `a` weight 0..1).
|
|
84
|
-
*/
|
|
85
|
-
function decodeGrid(cells) {
|
|
86
|
-
const dots = []
|
|
87
|
-
for (let index = 0; index < cells.length; index += 1) {
|
|
88
|
-
const weight = Number.parseInt(cells[index], 16)
|
|
89
|
-
if (!(weight > 0)) continue
|
|
90
|
-
const row = Math.floor(index / GIRL_COLUMNS)
|
|
91
|
-
const column = index % GIRL_COLUMNS
|
|
92
|
-
dots.push({
|
|
93
|
-
u: (column + 0.5) / GIRL_COLUMNS,
|
|
94
|
-
v: (row + 0.5) / GIRL_ROWS,
|
|
95
|
-
a: weight / 15,
|
|
96
|
-
phase: Math.random() * TAU,
|
|
97
|
-
speed: 0.5 + Math.random() * 0.8,
|
|
98
|
-
})
|
|
99
|
-
}
|
|
100
|
-
return dots
|
|
101
|
-
}
|
|
102
|
-
|
|
103
|
-
/**
|
|
104
|
-
* Light canvas: the artwork's ink drives dot weight, so dark hair and the
|
|
105
|
-
* dark dress read dark on the pale canvas.
|
|
106
|
-
* @returns dots in normalised space.
|
|
107
|
-
*/
|
|
108
|
-
function mascotDots() {
|
|
109
|
-
if (dotModel === undefined) dotModel = decodeGrid(GIRL_GRID)
|
|
110
|
-
return dotModel
|
|
111
|
-
}
|
|
112
|
-
|
|
113
|
-
/**
|
|
114
|
-
* Dark canvas: the dots are light, so the artwork's ink is inverted — skin
|
|
115
|
-
* and the white apron become dense bright dots while ink-heavy hair and the
|
|
116
|
-
* dress fade back into the canvas. Cells with no ink but enclosed by the
|
|
117
|
-
* figure count as full weight, which is what keeps the face from turning
|
|
118
|
-
* into an empty hole.
|
|
119
|
-
* @returns dots in normalised space.
|
|
120
|
-
*/
|
|
121
|
-
function invertedDots() {
|
|
122
|
-
if (lineModel !== undefined) return lineModel
|
|
123
|
-
const total = GIRL_COLUMNS * GIRL_ROWS
|
|
124
|
-
const occupied = new Uint8Array(total)
|
|
125
|
-
const weight = new Float32Array(total)
|
|
126
|
-
for (let index = 0; index < GIRL_GRID.length && index < total; index += 1) {
|
|
127
|
-
const value = Number.parseInt(GIRL_GRID[index], 16)
|
|
128
|
-
if (!(value > 0)) continue
|
|
129
|
-
occupied[index] = 1
|
|
130
|
-
weight[index] = value / 15
|
|
131
|
-
}
|
|
132
|
-
const rowFirst = new Int32Array(GIRL_ROWS).fill(-1)
|
|
133
|
-
const rowLast = new Int32Array(GIRL_ROWS).fill(-1)
|
|
134
|
-
const columnFirst = new Int32Array(GIRL_COLUMNS).fill(-1)
|
|
135
|
-
const columnLast = new Int32Array(GIRL_COLUMNS).fill(-1)
|
|
136
|
-
for (let row = 0; row < GIRL_ROWS; row += 1) {
|
|
137
|
-
for (let column = 0; column < GIRL_COLUMNS; column += 1) {
|
|
138
|
-
if (occupied[row * GIRL_COLUMNS + column] === 0) continue
|
|
139
|
-
if (rowFirst[row] < 0) rowFirst[row] = column
|
|
140
|
-
rowLast[row] = column
|
|
141
|
-
if (columnFirst[column] < 0) columnFirst[column] = row
|
|
142
|
-
columnLast[column] = row
|
|
143
|
-
}
|
|
144
|
-
}
|
|
145
|
-
const dots = []
|
|
146
|
-
for (let row = 0; row < GIRL_ROWS; row += 1) {
|
|
147
|
-
for (let column = 0; column < GIRL_COLUMNS; column += 1) {
|
|
148
|
-
if (row < columnFirst[column] || row > columnLast[column]) continue
|
|
149
|
-
if (column < rowFirst[row] || column > rowLast[row]) continue
|
|
150
|
-
const index = row * GIRL_COLUMNS + column
|
|
151
|
-
const alpha = occupied[index] === 1 ? 1 - weight[index] : 1
|
|
152
|
-
if (alpha < 0.45) continue
|
|
153
|
-
dots.push({
|
|
154
|
-
u: (column + 0.5) / GIRL_COLUMNS,
|
|
155
|
-
v: (row + 0.5) / GIRL_ROWS,
|
|
156
|
-
a: alpha,
|
|
157
|
-
phase: Math.random() * TAU,
|
|
158
|
-
speed: 0.5 + Math.random() * 0.8,
|
|
159
|
-
})
|
|
160
|
-
}
|
|
161
|
-
}
|
|
162
|
-
lineModel = dots
|
|
163
|
-
return dots
|
|
164
|
-
}
|
|
165
|
-
|
|
166
|
-
/**
|
|
167
|
-
* Rasterise the two wordmark lines with the UI font and reduce them to the
|
|
168
|
-
* same dotted grid the portrait uses.
|
|
169
|
-
* @returns dots in normalised block space (`u`/`v` 0..1, `a` weight 0..1).
|
|
170
|
-
*/
|
|
171
|
-
function lockupDots() {
|
|
172
|
-
if (lockupModel !== undefined) return lockupModel
|
|
173
|
-
const supersample = 4
|
|
174
|
-
const family = '"Segoe UI", system-ui, sans-serif'
|
|
175
|
-
// Display treatment: heavy italic with wide tracking, filled solid. Each
|
|
176
|
-
// line is rasterised on its own canvas, so a descender that crosses the
|
|
177
|
-
// other line's band still belongs to its own colour.
|
|
178
|
-
const style = 'italic 700'
|
|
179
|
-
const probe = document.createElement('canvas').getContext('2d')
|
|
180
|
-
probe.font = `${style} 100px ${family}`
|
|
181
|
-
if ('letterSpacing' in probe) probe.letterSpacing = '6px'
|
|
182
|
-
const width = LOCKUP_COLUMNS * supersample
|
|
183
|
-
const height = LOCKUP_ROWS * supersample
|
|
184
|
-
const widest = Math.max(...LOCKUP_LINES.map(line => probe.measureText(line).width), 1)
|
|
185
|
-
const size = ((width * 0.94) / widest) * 100
|
|
186
|
-
const model = LOCKUP_LINES.map((line, lineIndex) => {
|
|
187
|
-
const big = document.createElement('canvas')
|
|
188
|
-
big.width = width
|
|
189
|
-
big.height = height
|
|
190
|
-
const bigContext = big.getContext('2d')
|
|
191
|
-
bigContext.textAlign = 'left'
|
|
192
|
-
bigContext.textBaseline = 'middle'
|
|
193
|
-
if ('letterSpacing' in bigContext) bigContext.letterSpacing = '6px'
|
|
194
|
-
bigContext.font = `${style} ${size.toFixed(1)}px ${family}`
|
|
195
|
-
bigContext.fillStyle = 'rgba(255, 255, 255, 0.92)'
|
|
196
|
-
bigContext.fillText(line, width * 0.02, height * (0.34 + 0.4 * lineIndex))
|
|
197
|
-
|
|
198
|
-
const small = document.createElement('canvas')
|
|
199
|
-
small.width = LOCKUP_COLUMNS
|
|
200
|
-
small.height = LOCKUP_ROWS
|
|
201
|
-
const smallContext = small.getContext('2d')
|
|
202
|
-
smallContext.drawImage(big, 0, 0, LOCKUP_COLUMNS, LOCKUP_ROWS)
|
|
203
|
-
const pixels = smallContext.getImageData(0, 0, LOCKUP_COLUMNS, LOCKUP_ROWS).data
|
|
204
|
-
const dots = []
|
|
205
|
-
for (let index = 0; index < LOCKUP_COLUMNS * LOCKUP_ROWS; index += 1) {
|
|
206
|
-
const alpha = pixels[index * 4 + 3] / 255
|
|
207
|
-
if (alpha < 0.08) continue
|
|
208
|
-
dots.push({
|
|
209
|
-
u: ((index % LOCKUP_COLUMNS) + 0.5) / LOCKUP_COLUMNS,
|
|
210
|
-
v: (Math.floor(index / LOCKUP_COLUMNS) + 0.5) / LOCKUP_ROWS,
|
|
211
|
-
a: Math.min(1, alpha * 1.25),
|
|
212
|
-
phase: Math.random() * TAU,
|
|
213
|
-
speed: 0.5 + Math.random() * 0.8,
|
|
214
|
-
})
|
|
215
|
-
}
|
|
216
|
-
return dots
|
|
217
|
-
})
|
|
218
|
-
lockupModel = model
|
|
219
|
-
return model
|
|
220
|
-
}
|
|
221
|
-
|
|
222
|
-
/**
|
|
223
|
-
* Paint the dot mascot and wordmark into a canvas, twinkling in place.
|
|
224
|
-
* @param canvas - the frame canvas sized to the conversation area.
|
|
225
|
-
* @returns disposer that cancels the animation and observers.
|
|
226
|
-
*/
|
|
227
|
-
function attachMascot(canvas) {
|
|
228
|
-
const context = canvas.getContext('2d')
|
|
229
|
-
if (context === null) return () => {}
|
|
230
|
-
const portraitLight = mascotDots()
|
|
231
|
-
const portraitDark = invertedDots()
|
|
232
|
-
const wordmark = lockupDots()
|
|
233
|
-
const motion = window.matchMedia('(prefers-reduced-motion: reduce)')
|
|
234
|
-
let reduced = motion.matches
|
|
235
|
-
const started = performance.now()
|
|
236
|
-
// The reveal clock starts on the first paint that actually has a canvas to draw
|
|
237
|
-
// into, otherwise the animation can finish while the element is still sizing.
|
|
238
|
-
let revealStarted = 0
|
|
239
|
-
let width = 1
|
|
240
|
-
let height = 1
|
|
241
|
-
let dpr = 1
|
|
242
|
-
let frame = 0
|
|
243
|
-
let drawnAt = 0
|
|
244
|
-
let disposed = false
|
|
245
|
-
/** Composer card geometry in canvas coordinates; the composition's bound. */
|
|
246
|
-
let composerLeft = 0
|
|
247
|
-
let composerWidth = 0
|
|
248
|
-
let composerTop = 0
|
|
249
|
-
let composerNode = null
|
|
250
|
-
const composerObserver = new ResizeObserver(() => { readComposer() })
|
|
251
|
-
|
|
252
|
-
/** Re-read the composer card (it mounts with the hero and resizes with it). */
|
|
253
|
-
const readComposer = () => {
|
|
254
|
-
const canvasRect = canvas.getBoundingClientRect()
|
|
255
|
-
// Pick the composer card that actually overlaps this conversation area:
|
|
256
|
-
// hidden or off-screen cards (other panels, mounted shells) must not
|
|
257
|
-
// become the layout bound.
|
|
258
|
-
let node = null
|
|
259
|
-
let rect = null
|
|
260
|
-
for (const candidate of document.querySelectorAll('[data-composer-card]')) {
|
|
261
|
-
const box = candidate.getBoundingClientRect()
|
|
262
|
-
if (box.width < 80 || box.height < 20) continue
|
|
263
|
-
if (box.right <= canvasRect.left || box.left >= canvasRect.right) continue
|
|
264
|
-
if (rect === null || box.width > rect.width) {
|
|
265
|
-
node = candidate
|
|
266
|
-
rect = box
|
|
267
|
-
}
|
|
268
|
-
}
|
|
269
|
-
if (node !== composerNode) {
|
|
270
|
-
composerObserver.disconnect()
|
|
271
|
-
composerNode = node
|
|
272
|
-
if (node !== null) composerObserver.observe(node)
|
|
273
|
-
}
|
|
274
|
-
if (node === null || rect === null) {
|
|
275
|
-
composerLeft = 0
|
|
276
|
-
composerWidth = 0
|
|
277
|
-
composerTop = 0
|
|
278
|
-
return
|
|
279
|
-
}
|
|
280
|
-
composerLeft = rect.left - canvasRect.left
|
|
281
|
-
composerWidth = rect.width
|
|
282
|
-
composerTop = rect.top - canvasRect.top
|
|
283
|
-
}
|
|
284
|
-
|
|
285
|
-
/** Last canvas box in viewport coordinates, for pointer hit-testing. */
|
|
286
|
-
let boxLeft = 0
|
|
287
|
-
let boxTop = 0
|
|
288
|
-
let boxWidth = 0
|
|
289
|
-
let boxHeight = 0
|
|
290
|
-
/** Pointer position in canvas coordinates; inactive while outside. */
|
|
291
|
-
let pointerX = -1e6
|
|
292
|
-
let pointerY = -1e6
|
|
293
|
-
let pointerActive = false
|
|
294
|
-
const onPointerMove = (event) => {
|
|
295
|
-
pointerX = event.clientX - boxLeft
|
|
296
|
-
pointerY = event.clientY - boxTop
|
|
297
|
-
pointerActive = pointerX >= 0 && pointerY >= 0 && pointerX <= boxWidth && pointerY <= boxHeight
|
|
298
|
-
if (pointerActive) {
|
|
299
|
-
trail.push({ x: pointerX, y: pointerY, at: performance.now() })
|
|
300
|
-
if (trail.length > 8) trail.shift()
|
|
301
|
-
spawnRipple()
|
|
302
|
-
}
|
|
303
|
-
if (reduced) paint(performance.now())
|
|
304
|
-
}
|
|
305
|
-
const onPointerLeave = () => { pointerActive = false }
|
|
306
|
-
/** Moving the pointer over the field band leaves a light ripple behind. */
|
|
307
|
-
const spawnRipple = () => {
|
|
308
|
-
const cfg = dcSettings
|
|
309
|
-
if (cfg !== undefined && cfg.ripple === false) return
|
|
310
|
-
const nowMs = performance.now()
|
|
311
|
-
if (nowMs - lastRippleAt < 90) return
|
|
312
|
-
const bandTop = boxHeight - Math.min(440, Math.max(230, boxHeight * 0.4))
|
|
313
|
-
if (pointerY < bandTop) return
|
|
314
|
-
lastRippleAt = nowMs
|
|
315
|
-
fieldRipples.push({ x: pointerX, y: pointerY, at: nowMs })
|
|
316
|
-
if (fieldRipples.length > 8) fieldRipples.shift()
|
|
317
|
-
}
|
|
318
|
-
/** Recent pointer samples so the light leaves a short, fading trail. */
|
|
319
|
-
const trail = []
|
|
320
|
-
/** Click ripples: origin plus start time, oldest first. */
|
|
321
|
-
const ripples = []
|
|
322
|
-
const onPointerDown = (event) => {
|
|
323
|
-
const x = event.clientX - boxLeft
|
|
324
|
-
const y = event.clientY - boxTop
|
|
325
|
-
if (x < 0 || y < 0 || x > boxWidth || y > boxHeight) return
|
|
326
|
-
ripples.push({ x, y, at: performance.now() })
|
|
327
|
-
if (ripples.length > 5) ripples.shift()
|
|
328
|
-
}
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
const measure = () => {
|
|
332
|
-
const rect = canvas.getBoundingClientRect()
|
|
333
|
-
dpr = Math.min(window.devicePixelRatio || 1, 2)
|
|
334
|
-
width = Math.max(1, rect.width)
|
|
335
|
-
height = Math.max(1, rect.height)
|
|
336
|
-
canvas.width = Math.round(width * dpr)
|
|
337
|
-
canvas.height = Math.round(height * dpr)
|
|
338
|
-
boxLeft = rect.left
|
|
339
|
-
boxTop = rect.top
|
|
340
|
-
boxWidth = width
|
|
341
|
-
boxHeight = height
|
|
342
|
-
readComposer()
|
|
343
|
-
}
|
|
344
|
-
|
|
345
|
-
/**
|
|
346
|
-
* Draw one frame: both groups hold still and only their alpha breathes.
|
|
347
|
-
* @param now - frame timestamp.
|
|
348
|
-
*/
|
|
349
|
-
let bgLayer = null
|
|
350
|
-
let bgGlow = null
|
|
351
|
-
let fieldDots = null
|
|
352
|
-
const fieldRipples = []
|
|
353
|
-
let lastRippleAt = 0
|
|
354
|
-
let fieldKeyCache = ''
|
|
355
|
-
let composerFocused = false
|
|
356
|
-
let focusAmount = 0
|
|
357
|
-
let bgKey = ''
|
|
358
|
-
|
|
359
|
-
const paint = (now) => {
|
|
360
|
-
frame = 0
|
|
361
|
-
if (disposed || document.hidden) return
|
|
362
|
-
const cfg = dcSettings
|
|
363
|
-
if (cfg !== undefined && cfg.hero === false) {
|
|
364
|
-
context.setTransform(dpr, 0, 0, dpr, 0, 0)
|
|
365
|
-
context.clearRect(0, 0, width, height)
|
|
366
|
-
frame = requestAnimationFrame(paint)
|
|
367
|
-
return
|
|
368
|
-
}
|
|
369
|
-
if (revealStarted === 0 && width > 200 && height > 200) revealStarted = now
|
|
370
|
-
// The assembly is a short, fast reveal: give it a smoother frame rate
|
|
371
|
-
// than the slow twinkle, then fall back to the cheap cadence.
|
|
372
|
-
const assembling = now - revealStarted < ASSEMBLY_MS + 80
|
|
373
|
-
const interval = (assembling ? 1000 / 60 : FRAME_MS) - 1
|
|
374
|
-
if (!reduced && now - drawnAt < interval) {
|
|
375
|
-
frame = requestAnimationFrame(paint)
|
|
376
|
-
return
|
|
377
|
-
}
|
|
378
|
-
drawnAt = now
|
|
379
|
-
const time = reduced ? 0 : (now - started) / 1000
|
|
380
|
-
const dark = document.body.hasAttribute('data-ds-dark-theme')
|
|
381
|
-
const ink = dark ? '236, 238, 242' : '102, 108, 120'
|
|
382
|
-
// The composer card is the layout's bound: the pair is centred on it and
|
|
383
|
-
// can never be wider than the input box.
|
|
384
|
-
const limit = composerWidth > 160 ? composerWidth : width * 0.94
|
|
385
|
-
const originX = composerWidth > 160 ? composerLeft : (width - limit) / 2
|
|
386
|
-
|
|
387
|
-
// One pitch drives both groups: the wordmark and the portrait always share
|
|
388
|
-
// the same dot size, and that pitch scales with the space available. Two
|
|
389
|
-
// hard bounds: the composer width (the pair never exceeds the input box)
|
|
390
|
-
// and the space above the composer (the pair hangs above it instead of
|
|
391
|
-
// being covered by it).
|
|
392
|
-
const availW = limit * 0.94
|
|
393
|
-
const pairCells = LOCKUP_COLUMNS + GIRL_COLUMNS - 30
|
|
394
|
-
const bandTop = composerTop > 140 ? composerTop : height * 0.86
|
|
395
|
-
const heightPitch = Math.max(1, bandTop - 8) / GIRL_ROWS
|
|
396
|
-
let pitch = Math.min(DOT_PITCH, availW / pairCells, heightPitch)
|
|
397
|
-
let showText = true
|
|
398
|
-
if (pitch < TEXT_MIN_PITCH) {
|
|
399
|
-
// Only when the type would fall below the readable floor: drop the
|
|
400
|
-
// wordmark and keep the portrait as large as it can be.
|
|
401
|
-
showText = false
|
|
402
|
-
pitch = Math.min(DOT_PITCH, availW / GIRL_COLUMNS, heightPitch)
|
|
403
|
-
}
|
|
404
|
-
if (pitch < 2.2) {
|
|
405
|
-
context.setTransform(dpr, 0, 0, dpr, 0, 0)
|
|
406
|
-
context.clearRect(0, 0, width, height)
|
|
407
|
-
return
|
|
408
|
-
}
|
|
409
|
-
const blockW = LOCKUP_COLUMNS * pitch
|
|
410
|
-
const blockH = LOCKUP_ROWS * pitch
|
|
411
|
-
const portraitW = GIRL_COLUMNS * pitch
|
|
412
|
-
const portraitH = GIRL_ROWS * pitch
|
|
413
|
-
const overlap = Math.max(8, pitch * 30)
|
|
414
|
-
const pairW = blockW + portraitW - overlap
|
|
415
|
-
|
|
416
|
-
// Hang the pair off the composer: the portrait's bottom edge sits on the
|
|
417
|
-
// composer's top edge, and the dot pitch above guaranteed it fits there.
|
|
418
|
-
const portraitY = Math.min(
|
|
419
|
-
Math.max(bandTop - portraitH / 2, 6 + portraitH / 2),
|
|
420
|
-
Math.max(6 + portraitH / 2, height - portraitH / 2 - 6),
|
|
421
|
-
)
|
|
422
|
-
let portraitX
|
|
423
|
-
let blockX = 0
|
|
424
|
-
if (showText) {
|
|
425
|
-
blockX = originX + Math.max(0, (limit - pairW) / 2)
|
|
426
|
-
portraitX = blockX + blockW - overlap + portraitW / 2
|
|
427
|
-
} else {
|
|
428
|
-
portraitX = originX + limit / 2
|
|
429
|
-
}
|
|
430
|
-
// Keep the pair inside the canvas even if the composer rect was odd.
|
|
431
|
-
const minX = portraitW / 2 + 6
|
|
432
|
-
const maxX = Math.max(minX, width - portraitW / 2 - 6)
|
|
433
|
-
portraitX = Math.min(Math.max(portraitX, minX), maxX)
|
|
434
|
-
const blockY = portraitY - blockH / 2
|
|
435
|
-
// The portrait and the wordmark are centred on each other, which leaves their
|
|
436
|
-
// cell rows half a cell apart; nudge the portrait so every dot in the scene
|
|
437
|
-
// (artwork and printed field alike) lands on one single lattice.
|
|
438
|
-
const portraitYAligned = portraitY + pitch / 2
|
|
439
|
-
const portraitRadius = Math.max(0.8, pitch * 0.28)
|
|
440
|
-
const lockupRadius = Math.max(0.8, pitch * 0.34)
|
|
441
|
-
|
|
442
|
-
// A faint dot field under everything, built on the artwork's own pitch and
|
|
443
|
-
// ink so the background reads as part of the same printed sheet.
|
|
444
|
-
// Phase the background lattice onto the artwork's own grid: the wordmark and the
|
|
445
|
-
// portrait already sit on one lattice (their origins differ by a whole number
|
|
446
|
-
// of cells), so matching that phase makes the field read as the same printed
|
|
447
|
-
// sheet instead of a second, offset grid.
|
|
448
|
-
// Artwork dots sit at the CENTRES of their cells (blockX + (col + 0.5) * pitch),
|
|
449
|
-
// so the field has to be phased half a cell further: its dots land exactly on
|
|
450
|
-
// the artwork's dots, like stones on intersections, not inside the squares.
|
|
451
|
-
const phaseX = (((blockX + pitch / 2) % pitch) + pitch) % pitch
|
|
452
|
-
const phaseY = (((blockY + pitch / 2) % pitch) + pitch) % pitch
|
|
453
|
-
const buildKey = pitch.toFixed(3) + '|' + ink + '|' + phaseX.toFixed(3) + '|'
|
|
454
|
-
+ phaseY.toFixed(3) + '|' + width + '|' + height + '|' + dpr
|
|
455
|
-
if (buildKey !== bgKey) {
|
|
456
|
-
bgKey = buildKey
|
|
457
|
-
bgLayer = document.createElement('canvas')
|
|
458
|
-
bgLayer.width = Math.max(1, Math.round(width * dpr))
|
|
459
|
-
bgLayer.height = Math.max(1, Math.round(height * dpr))
|
|
460
|
-
const layerContext = bgLayer.getContext('2d')
|
|
461
|
-
if (layerContext === null) {
|
|
462
|
-
bgLayer = null
|
|
463
|
-
} else {
|
|
464
|
-
layerContext.setTransform(dpr, 0, 0, dpr, 0, 0)
|
|
465
|
-
const fieldRadius = Math.max(0.45, pitch * 0.11)
|
|
466
|
-
|
|
467
|
-
// The resting field.
|
|
468
|
-
layerContext.fillStyle = 'rgba(' + ink + ', 0.1)'
|
|
469
|
-
for (let y = phaseY; y < height + pitch; y += pitch) {
|
|
470
|
-
for (let x = phaseX; x < width + pitch; x += pitch) {
|
|
471
|
-
layerContext.beginPath()
|
|
472
|
-
layerContext.arc(x, y, fieldRadius, 0, TAU)
|
|
473
|
-
layerContext.fill()
|
|
474
|
-
}
|
|
475
|
-
}
|
|
476
|
-
|
|
477
|
-
// The focused field: the same lattice, but brighter close to the
|
|
478
|
-
// composer card and fading out with distance, so the click lights the
|
|
479
|
-
// dots around the input rather than the whole page.
|
|
480
|
-
bgGlow = document.createElement('canvas')
|
|
481
|
-
bgGlow.width = bgLayer.width
|
|
482
|
-
bgGlow.height = bgLayer.height
|
|
483
|
-
const glowContext = bgGlow.getContext('2d')
|
|
484
|
-
if (glowContext === null) {
|
|
485
|
-
bgGlow = null
|
|
486
|
-
} else {
|
|
487
|
-
glowContext.setTransform(dpr, 0, 0, dpr, 0, 0)
|
|
488
|
-
const cardLeft = composerWidth > 160 ? composerLeft : (width - limit) / 2
|
|
489
|
-
const cardWidthForGlow = composerWidth > 160 ? composerWidth : limit
|
|
490
|
-
const glowRadiusX = Math.max(160, cardWidthForGlow * 0.55)
|
|
491
|
-
const glowRadiusY = Math.max(150, Math.min(height * 0.3, 260))
|
|
492
|
-
const centerX = cardLeft + cardWidthForGlow / 2
|
|
493
|
-
const centerY = composerTop + 8
|
|
494
|
-
for (let y = phaseY; y < height + pitch; y += pitch) {
|
|
495
|
-
for (let x = phaseX; x < width + pitch; x += pitch) {
|
|
496
|
-
const dx = (x - centerX) / glowRadiusX
|
|
497
|
-
const dy = (y - centerY) / glowRadiusY
|
|
498
|
-
const falloff = Math.exp(-(dx * dx + dy * dy) * 2.1)
|
|
499
|
-
if (falloff < 0.03) continue
|
|
500
|
-
glowContext.fillStyle = 'rgba(' + ink + ', ' + (0.3 * falloff).toFixed(3) + ')'
|
|
501
|
-
glowContext.beginPath()
|
|
502
|
-
glowContext.arc(x, y, fieldRadius, 0, TAU)
|
|
503
|
-
glowContext.fill()
|
|
504
|
-
}
|
|
505
|
-
}
|
|
506
|
-
}
|
|
507
|
-
}
|
|
508
|
-
}
|
|
509
|
-
|
|
510
|
-
// The portrait runs one opacity notch brighter than the wordmark, so the
|
|
511
|
-
// two groups keep separate alpha ladders.
|
|
512
|
-
const portraitPaths = []
|
|
513
|
-
const wordmarkPaths = [[], []]
|
|
514
|
-
for (let level = 0; level < LEVELS; level += 1) {
|
|
515
|
-
portraitPaths.push(new Path2D())
|
|
516
|
-
wordmarkPaths[0].push(new Path2D())
|
|
517
|
-
wordmarkPaths[1].push(new Path2D())
|
|
518
|
-
}
|
|
519
|
-
|
|
520
|
-
// Wordmark assembly: dots light up left to right, with a bright front.
|
|
521
|
-
const assembly = reduced ? 1 : Math.min(1, (now - revealStarted) / ASSEMBLY_MS)
|
|
522
|
-
// The portrait follows the wordmark: a soft vertical wipe grows it downward
|
|
523
|
-
// about a tenth of a second later.
|
|
524
|
-
const portraitProgress = reduced
|
|
525
|
-
? 1
|
|
526
|
-
: Math.max(0, Math.min(1, ((now - revealStarted) - 140) / 1100))
|
|
527
|
-
while (ripples.length > 0 && now - ripples[0].at > 760) ripples.shift()
|
|
528
|
-
const trailNow = trail.filter(sample => now - sample.at < 420)
|
|
529
|
-
const rippleBoost = (x, y) => {
|
|
530
|
-
let best = 0
|
|
531
|
-
for (const ripple of ripples) {
|
|
532
|
-
const age = (now - ripple.at) / 760
|
|
533
|
-
const radius = age * 640
|
|
534
|
-
const dx = x - ripple.x
|
|
535
|
-
const dy = y - ripple.y
|
|
536
|
-
if (dx * dx + dy * dy > (radius + 200) * (radius + 200)) continue
|
|
537
|
-
const distance = Math.sqrt(dx * dx + dy * dy)
|
|
538
|
-
if (Math.abs(distance - radius) > 160) continue
|
|
539
|
-
const band = Math.exp(-Math.pow((distance - radius) / 44, 2))
|
|
540
|
-
best = Math.max(best, band * (1 - age))
|
|
541
|
-
}
|
|
542
|
-
return 1 + 1.25 * best
|
|
543
|
-
}
|
|
544
|
-
const trailBoost = (x, y) => {
|
|
545
|
-
let best = 0
|
|
546
|
-
for (const sample of trailNow) {
|
|
547
|
-
const age = Math.max(0, (now - sample.at) / 420)
|
|
548
|
-
const dx = x - sample.x
|
|
549
|
-
const dy = y - sample.y
|
|
550
|
-
if (Math.abs(dx) > 260 || Math.abs(dy) > 260) continue
|
|
551
|
-
best = Math.max(best, Math.exp(-(dx * dx + dy * dy) / (2 * 95 * 95)) * (1 - age))
|
|
552
|
-
}
|
|
553
|
-
return 1 + 0.95 * best
|
|
554
|
-
}
|
|
555
|
-
const place = (target, dot, x, y, radius, kind, line) => {
|
|
556
|
-
// The portrait holds a steady level; only the wordmark breathes.
|
|
557
|
-
const breathe = reduced ? 0.6 : 0.5 + 0.5 * Math.sin(time * dot.speed + dot.phase)
|
|
558
|
-
// Ease the wave so the low and high ends linger instead of sweeping
|
|
559
|
-
// through the extremes linearly, which reads as a softer pulse.
|
|
560
|
-
const eased = breathe * breathe * (3 - 2 * breathe)
|
|
561
|
-
let tone = kind === 'portrait' ? dot.a : dot.a * (0.35 + 0.65 * eased)
|
|
562
|
-
if (kind === 'portrait' && portraitProgress < 1) {
|
|
563
|
-
const local = Math.max(0, Math.min(1, (portraitProgress - dot.v * 0.45) / 0.55))
|
|
564
|
-
const wipe = local * local * (3 - 2 * local)
|
|
565
|
-
if (wipe <= 0.004) return
|
|
566
|
-
tone *= wipe
|
|
567
|
-
}
|
|
568
|
-
if (kind === 'wordmark') {
|
|
569
|
-
if (assembly < 1) {
|
|
570
|
-
// Whole-word fade: the line rises as one piece, no left-to-right sweep.
|
|
571
|
-
const offset = line === 1 ? ASSEMBLY_SECOND_LINE : 0
|
|
572
|
-
const progress = Math.max(0, Math.min(1, (assembly - offset) / ASSEMBLY_LINE_SPAN))
|
|
573
|
-
const smooth = progress * progress * (3 - 2 * progress)
|
|
574
|
-
if (smooth <= 0.02) return
|
|
575
|
-
tone *= smooth
|
|
576
|
-
}
|
|
577
|
-
if (pointerActive) tone *= trailBoost(x, y)
|
|
578
|
-
}
|
|
579
|
-
// Ripples are a wordmark effect; the portrait stays untouched.
|
|
580
|
-
if (kind === 'wordmark') tone = Math.min(1, tone * rippleBoost(x, y))
|
|
581
|
-
const level = Math.min(LEVELS - 1, Math.max(0, Math.round(tone * (LEVELS - 1))))
|
|
582
|
-
// Halftone weighting: heavier cells draw slightly larger dots, so the
|
|
583
|
-
// field reads as printed ink rather than a uniform grid.
|
|
584
|
-
const size = radius * (0.82 + 0.36 * dot.a)
|
|
585
|
-
target[level].moveTo(x + size, y)
|
|
586
|
-
target[level].arc(x, y, size, 0, TAU)
|
|
587
|
-
}
|
|
588
|
-
const portrait = dark ? portraitDark : portraitLight
|
|
589
|
-
for (const dot of portrait) {
|
|
590
|
-
place(
|
|
591
|
-
portraitPaths,
|
|
592
|
-
dot,
|
|
593
|
-
portraitX + (dot.u - 0.5) * portraitW,
|
|
594
|
-
portraitYAligned + (dot.v - 0.5) * portraitH,
|
|
595
|
-
portraitRadius,
|
|
596
|
-
'portrait',
|
|
597
|
-
)
|
|
598
|
-
}
|
|
599
|
-
if (showText) {
|
|
600
|
-
wordmark.forEach((dots, index) => {
|
|
601
|
-
for (const dot of dots) {
|
|
602
|
-
place(
|
|
603
|
-
wordmarkPaths[index],
|
|
604
|
-
dot,
|
|
605
|
-
blockX + dot.u * blockW,
|
|
606
|
-
blockY + dot.v * blockH,
|
|
607
|
-
lockupRadius,
|
|
608
|
-
'wordmark',
|
|
609
|
-
index,
|
|
610
|
-
)
|
|
611
|
-
}
|
|
612
|
-
})
|
|
613
|
-
}
|
|
614
|
-
|
|
615
|
-
context.setTransform(dpr, 0, 0, dpr, 0, 0)
|
|
616
|
-
context.clearRect(0, 0, width, height)
|
|
617
|
-
// The field is painted after the clear so it survives the frame.
|
|
618
|
-
if (bgLayer !== null && (cfg === undefined || cfg.field !== false)) {
|
|
619
|
-
context.drawImage(bgLayer, 0, 0, width, height)
|
|
620
|
-
}
|
|
621
|
-
const focusTarget = composerFocused ? 1 : 0
|
|
622
|
-
focusAmount += (focusTarget - focusAmount) * 0.14
|
|
623
|
-
if (focusAmount > 0.005 && bgGlow !== null) {
|
|
624
|
-
context.save()
|
|
625
|
-
context.globalAlpha = Math.min(1, focusAmount)
|
|
626
|
-
context.drawImage(bgGlow, 0, 0, width, height)
|
|
627
|
-
context.restore()
|
|
628
|
-
}
|
|
629
|
-
|
|
630
|
-
// The wave field lives on the lattice: the light pattern is pure brightness,
|
|
631
|
-
// and the pointer can nudge dots aside. Nothing follows the cursor and every
|
|
632
|
-
// displaced dot springs straight back to its own cell.
|
|
633
|
-
const fieldKey = width + '|' + height + '|' + pitch.toFixed(3) + '|'
|
|
634
|
-
+ phaseX.toFixed(2) + '|' + phaseY.toFixed(2)
|
|
635
|
-
if (fieldKey !== fieldKeyCache) {
|
|
636
|
-
fieldKeyCache = fieldKey
|
|
637
|
-
fieldDots = []
|
|
638
|
-
const bandHeight = Math.min(440, Math.max(230, height * 0.4))
|
|
639
|
-
const bandTop = height - bandHeight
|
|
640
|
-
for (let y = phaseY; y < height + pitch; y += pitch) {
|
|
641
|
-
if (y < bandTop) continue
|
|
642
|
-
const depth = Math.min(1, (y - bandTop) / bandHeight)
|
|
643
|
-
const vertical = depth * depth * (3 - 2 * depth)
|
|
644
|
-
for (let x = phaseX; x < width + pitch; x += pitch) {
|
|
645
|
-
fieldDots.push({ x: x, y: y, vertical: vertical, ox: 0, oy: 0, vx: 0, vy: 0 })
|
|
646
|
-
}
|
|
647
|
-
}
|
|
648
|
-
}
|
|
649
|
-
|
|
650
|
-
if (!reduced && fieldDots !== null && (cfg === undefined || cfg.wave !== false)) {
|
|
651
|
-
const dt = 1 / 30
|
|
652
|
-
const unit = pitch / 8
|
|
653
|
-
const fieldRadius = Math.max(0.45, pitch * 0.11)
|
|
654
|
-
const breathe = 0.86 + 0.14 * Math.sin(time * 0.13)
|
|
655
|
-
const buckets = [[], [], [], [], [], []]
|
|
656
|
-
while (fieldRipples.length > 0 && now - fieldRipples[0].at > 1100) fieldRipples.shift()
|
|
657
|
-
for (const dot of fieldDots) {
|
|
658
|
-
|
|
659
|
-
const warpX = Math.sin(dot.y * 0.006 / unit + time * 0.23) * 30
|
|
660
|
-
+ Math.sin(dot.x * 0.003 / unit - time * 0.17) * 20
|
|
661
|
-
const warpY = Math.sin(dot.x * 0.0035 / unit + time * 0.29) * 26
|
|
662
|
-
const u = (dot.x + warpX) / unit
|
|
663
|
-
const v = (dot.y + warpY) / unit
|
|
664
|
-
const field = 0.5
|
|
665
|
-
+ 0.3 * Math.sin(u * 0.0035 - time * 0.55)
|
|
666
|
-
+ 0.22 * Math.sin(u * 0.0061 + time * 0.37 + v * 0.01)
|
|
667
|
-
+ 0.18 * Math.sin(u * 0.0107 - time * 0.29 + v * 0.021)
|
|
668
|
-
+ 0.12 * Math.sin(u * 0.0173 + time * 0.83 - v * 0.033)
|
|
669
|
-
let light = Math.max(0, Math.min(1, field)) ** 1.6
|
|
670
|
-
// A touch only adds light: rings race outward and fade, the dots stay put.
|
|
671
|
-
for (const ripple of fieldRipples) {
|
|
672
|
-
const age = (now - ripple.at) / 1100
|
|
673
|
-
const rdx = dot.x - ripple.x
|
|
674
|
-
const rdy = dot.y - ripple.y
|
|
675
|
-
const distance = Math.sqrt(rdx * rdx + rdy * rdy)
|
|
676
|
-
const ring = Math.exp(-Math.pow((distance - age * 420) / 42, 2)) * (1 - age)
|
|
677
|
-
if (ring > 0.001) light += ring * 0.8
|
|
678
|
-
}
|
|
679
|
-
const alpha = dot.vertical * (0.05 + Math.min(1, light) * 0.85) * breathe * (dark ? 1 : 1.2)
|
|
680
|
-
const level = Math.min(5, Math.floor(alpha * 7))
|
|
681
|
-
buckets[level].push(dot.x, dot.y)
|
|
682
|
-
}
|
|
683
|
-
for (let level = 0; level < buckets.length; level += 1) {
|
|
684
|
-
const bucket = buckets[level]
|
|
685
|
-
if (bucket.length === 0) continue
|
|
686
|
-
const alpha = 0.03 + level * 0.105
|
|
687
|
-
context.fillStyle = 'rgba(' + ink + ', ' + alpha.toFixed(3) + ')'
|
|
688
|
-
context.beginPath()
|
|
689
|
-
for (let index = 0; index < bucket.length; index += 2) {
|
|
690
|
-
context.moveTo(bucket[index] + fieldRadius, bucket[index + 1])
|
|
691
|
-
context.arc(bucket[index], bucket[index + 1], fieldRadius, 0, TAU)
|
|
692
|
-
}
|
|
693
|
-
context.fill()
|
|
694
|
-
}
|
|
695
|
-
}
|
|
696
|
-
|
|
697
|
-
const paintGroup = (paths, boost, color) => {
|
|
698
|
-
for (let level = 0; level < LEVELS; level += 1) {
|
|
699
|
-
const alpha = Math.min(1, (0.05 + (level / (LEVELS - 1)) * 0.5) * boost).toFixed(3)
|
|
700
|
-
context.fillStyle = `rgba(${color}, ${alpha})`
|
|
701
|
-
context.fill(paths[level])
|
|
702
|
-
}
|
|
703
|
-
}
|
|
704
|
-
// The portrait's opacity nudge flips with the palette: +10% on the light
|
|
705
|
-
// canvas, and its inverse trim on the dark one, where light dots already
|
|
706
|
-
// read brighter against the canvas.
|
|
707
|
-
paintGroup(portraitPaths, dark ? 1.15 : 1.8, ink)
|
|
708
|
-
if (showText) {
|
|
709
|
-
paintGroup(wordmarkPaths[0], dark ? 1 : 1.2, ink)
|
|
710
|
-
paintGroup(wordmarkPaths[1], dark ? 1 : 1.2, '122, 170, 255')
|
|
711
|
-
}
|
|
712
|
-
if (DEBUG) {
|
|
713
|
-
context.fillStyle = '#ff5555'
|
|
714
|
-
context.font = '12px monospace'
|
|
715
|
-
const readout = [
|
|
716
|
-
'pitch=' + pitch.toFixed(2) + ' limit=' + limit.toFixed(0) + ' composerTop=' + composerTop.toFixed(0),
|
|
717
|
-
'canvas=' + width.toFixed(0) + 'x' + height.toFixed(0) + ' dpr=' + dpr + ' showText=' + showText,
|
|
718
|
-
'portrait=' + portraitW.toFixed(0) + 'x' + portraitH.toFixed(0)
|
|
719
|
-
+ ' @ ' + portraitX.toFixed(0) + ',' + portraitY.toFixed(0),
|
|
720
|
-
'block=' + blockW.toFixed(0) + 'x' + blockH.toFixed(0)
|
|
721
|
-
+ ' @ ' + blockX.toFixed(0) + ',' + blockY.toFixed(0),
|
|
722
|
-
]
|
|
723
|
-
readout.forEach((line, index) => context.fillText(line, 12, 20 + index * 16))
|
|
724
|
-
context.strokeStyle = '#ff5555'
|
|
725
|
-
context.strokeRect(portraitX - portraitW / 2, portraitY - portraitH / 2, portraitW, portraitH)
|
|
726
|
-
context.strokeStyle = '#5599ff'
|
|
727
|
-
context.strokeRect(blockX, blockY, blockW, blockH)
|
|
728
|
-
}
|
|
729
|
-
if (!reduced) frame = requestAnimationFrame(paint)
|
|
730
|
-
}
|
|
731
|
-
|
|
732
|
-
const observer = new ResizeObserver(() => {
|
|
733
|
-
measure()
|
|
734
|
-
if (reduced) paint(performance.now())
|
|
735
|
-
})
|
|
736
|
-
observer.observe(canvas)
|
|
737
|
-
/** Focus inside the composer card lights the field around it. */
|
|
738
|
-
const onFocusChange = () => {
|
|
739
|
-
const active = document.activeElement
|
|
740
|
-
composerFocused = active !== null && active !== document.body
|
|
741
|
-
&& typeof active.closest === 'function'
|
|
742
|
-
&& active.closest('[data-composer-card]') !== null
|
|
743
|
-
}
|
|
744
|
-
window.addEventListener('focusin', onFocusChange, { passive: true })
|
|
745
|
-
window.addEventListener('focusout', onFocusChange, { passive: true })
|
|
746
|
-
window.addEventListener('pointermove', onPointerMove, { passive: true })
|
|
747
|
-
window.addEventListener('pointerleave', onPointerLeave, { passive: true })
|
|
748
|
-
window.addEventListener('pointerdown', onPointerDown, { passive: true })
|
|
749
|
-
const refresh = () => {
|
|
750
|
-
if (disposed) return
|
|
751
|
-
cancelAnimationFrame(frame)
|
|
752
|
-
frame = 0
|
|
753
|
-
if (!document.hidden) frame = requestAnimationFrame(paint)
|
|
754
|
-
}
|
|
755
|
-
const onMotion = () => { reduced = motion.matches; refresh() }
|
|
756
|
-
const themeObserver = new MutationObserver(refresh)
|
|
757
|
-
themeObserver.observe(document.body, { attributes: true, attributeFilter: ['data-ds-dark-theme'] })
|
|
758
|
-
const unsubscribeSettings = dcSubscribeSettings(refresh)
|
|
759
|
-
motion.addEventListener('change', onMotion)
|
|
760
|
-
document.addEventListener('visibilitychange', refresh)
|
|
761
|
-
measure()
|
|
762
|
-
refresh()
|
|
763
|
-
|
|
764
|
-
return () => {
|
|
765
|
-
disposed = true
|
|
766
|
-
unsubscribeSettings()
|
|
767
|
-
themeObserver.disconnect()
|
|
768
|
-
motion.removeEventListener('change', onMotion)
|
|
769
|
-
document.removeEventListener('visibilitychange', refresh)
|
|
770
|
-
cancelAnimationFrame(frame)
|
|
771
|
-
observer.disconnect()
|
|
772
|
-
composerObserver.disconnect()
|
|
773
|
-
window.removeEventListener('focusin', onFocusChange)
|
|
774
|
-
window.removeEventListener('focusout', onFocusChange)
|
|
775
|
-
window.removeEventListener('pointermove', onPointerMove)
|
|
776
|
-
window.removeEventListener('pointerleave', onPointerLeave)
|
|
777
|
-
window.removeEventListener('pointerdown', onPointerDown)
|
|
778
|
-
}
|
|
779
|
-
}
|
|
780
|
-
|
|
781
|
-
/**
|
|
782
|
-
* Frame layer for the blank home: paint the dot mascot below the content and
|
|
783
|
-
* pass the wrapped scroll body through untouched.
|
|
784
|
-
* @param props - the home flag and the wrapped Conversation body.
|
|
785
|
-
* @returns the layout-neutral frame.
|
|
786
|
-
*/
|
|
787
|
-
function HeroFrame({ hero, children }) {
|
|
788
|
-
const { values } = useDcSettings()
|
|
789
|
-
const show = hero === true && values.hero
|
|
790
|
-
const canvasRef = React.useRef(null)
|
|
791
|
-
React.useEffect(() => {
|
|
792
|
-
const canvas = canvasRef.current
|
|
793
|
-
if (!show || canvas === null) return undefined
|
|
794
|
-
return attachMascot(canvas)
|
|
795
|
-
}, [show])
|
|
796
|
-
return h('div', { className: 'dwe-frame' },
|
|
797
|
-
show ? h('div', { key: 'sign', className: 'dwe-sign' }, 'dsh-fish-ui') : null,
|
|
798
|
-
show ? h('canvas', { key: 'mascot', ref: canvasRef, className: 'dwe-whale', 'aria-hidden': 'true' }) : null,
|
|
799
|
-
children)
|
|
800
|
-
}
|
|
801
|
-
|
|
802
|
-
|
|
803
|
-
/* ---------------------------------------------------------------- styles */
|
|
804
|
-
|
|
805
|
-
const CSS = `
|
|
806
|
-
/* Hero frame layer: layout-neutral wrapper (display: contents keeps the wrapped
|
|
807
|
-
scroll body a direct flex item) plus one canvas that sits above the
|
|
808
|
-
Conversation background and below its content. */
|
|
809
|
-
.dwe-frame {
|
|
810
|
-
display: contents;
|
|
811
|
-
}
|
|
812
|
-
.dwe-whale {
|
|
813
|
-
position: absolute;
|
|
814
|
-
inset: 0;
|
|
815
|
-
z-index: -1;
|
|
816
|
-
width: 100%;
|
|
817
|
-
height: 100%;
|
|
818
|
-
display: block;
|
|
819
|
-
pointer-events: none;
|
|
820
|
-
}
|
|
821
|
-
|
|
822
|
-
/* One whale on the blank home: the official pixel whale would otherwise sit
|
|
823
|
-
behind this dot field, so its canvas is hidden. It keeps its slot layer and
|
|
824
|
-
still renders the wrapped content; only its artwork is suppressed. */
|
|
825
|
-
:root:has(canvas.dwe-whale) [data-home-whale] {
|
|
826
|
-
display: none !important;
|
|
827
|
-
}
|
|
828
|
-
|
|
829
|
-
/* Blank-home headline: drop the headline copy and the brand mark
|
|
830
|
-
beside it, leaving the dot portrait alone above the composer. The title group
|
|
831
|
-
is a CSS-module class (matched by its local name inside the hash, scoped by
|
|
832
|
-
the headline ancestor); the mark is the hero's own brand slot, matched by its
|
|
833
|
-
public slot key. If upstream renames either hook the rule simply stops
|
|
834
|
-
applying. */
|
|
835
|
-
:root:has(canvas.dwe-whale) [class*="headline"] [class*="titleGroup"],
|
|
836
|
-
:root:has(canvas.dwe-whale) [data-slot="conversation.hero.brand.mark"] {
|
|
837
|
-
display: none !important;
|
|
838
|
-
}
|
|
839
|
-
|
|
840
|
-
|
|
841
|
-
/* Product signature: only while the blank home is on screen, because the
|
|
842
|
-
element lives inside the hero frame layer. */
|
|
843
|
-
.dwe-sign {
|
|
844
|
-
position: fixed;
|
|
845
|
-
right: 14px;
|
|
846
|
-
bottom: 10px;
|
|
847
|
-
z-index: 2147483000;
|
|
848
|
-
font-size: 11px;
|
|
849
|
-
letter-spacing: 0.08em;
|
|
850
|
-
color: var(--dsw-alias-label-tertiary);
|
|
851
|
-
opacity: 0.28;
|
|
852
|
-
pointer-events: none;
|
|
853
|
-
user-select: none;
|
|
854
|
-
}
|
|
855
|
-
|
|
856
|
-
/* ------------------------------------------------------------------ accents */
|
|
857
|
-
|
|
858
|
-
/* Composer focus: the shipped 0.5px hairline turns whale blue and an inset ring
|
|
859
|
-
thickens the edge. The inset shadow follows the card radius and costs no
|
|
860
|
-
layout, and a focused draft editor is the only trigger — toolbar buttons
|
|
861
|
-
inside the card keep the resting look. */
|
|
862
|
-
/* Frosted composer, but only where something interesting runs behind it: while a
|
|
863
|
-
Session is open the messages scroll under the card, so glass reads as glass. On
|
|
864
|
-
the blank home the card sits on flat dotted paper, where translucency only muddies
|
|
865
|
-
the surface — there it keeps the shipped solid background. */
|
|
866
|
-
/* On the blank home the card must be fully opaque: the shipped menu surface is
|
|
867
|
-
slightly translucent, so the wave field behind it would show through the card as
|
|
868
|
-
moving light bands. */
|
|
869
|
-
/* The blank home keeps the card solid only when frosting is switched off. */
|
|
870
|
-
:root.dc-off-glass body:has(canvas.dwe-whale) [data-composer-card] {
|
|
871
|
-
background: var(--dsw-specific-input-major, var(--dsw-alias-bg-layer-1));
|
|
872
|
-
}
|
|
873
|
-
|
|
874
|
-
:root:not(.dc-off-glass) [data-composer-card] {
|
|
875
|
-
/* Much more translucent than the host surface, with a stronger blur and a touch of
|
|
876
|
-
saturation: the frosted look only reads if the backdrop is actually visible. */
|
|
877
|
-
background:
|
|
878
|
-
linear-gradient(
|
|
879
|
-
180deg,
|
|
880
|
-
color-mix(in srgb, var(--dsw-alias-label-primary) 7%, transparent),
|
|
881
|
-
color-mix(in srgb, var(--dsw-alias-label-primary) 2%, transparent) 42%,
|
|
882
|
-
transparent
|
|
883
|
-
),
|
|
884
|
-
color-mix(in srgb, var(--dsw-specific-input-major, var(--dsw-alias-bg-layer-1)) 54%, transparent);
|
|
885
|
-
-webkit-backdrop-filter: blur(26px) saturate(1.25);
|
|
886
|
-
backdrop-filter: blur(26px) saturate(1.25);
|
|
887
|
-
}
|
|
888
|
-
|
|
889
|
-
/* Composer focus: a soft whale-blue ring fades in under the card's own hairline
|
|
890
|
-
instead of recolouring it (a rebinding token switches instantly and reads as a
|
|
891
|
-
pop). Both states declare the same shadow layers so the transition interpolates
|
|
892
|
-
every layer, and the easing starts quickly and settles slowly. */
|
|
893
|
-
/* Focus ring in light grey: the composer is a text surface, so the highlight stays
|
|
894
|
-
neutral and the accent colour is reserved for content. */
|
|
895
|
-
:root {
|
|
896
|
-
--dc-focus-ink: 124, 128, 136;
|
|
897
|
-
}
|
|
898
|
-
|
|
899
|
-
body[data-ds-dark-theme] {
|
|
900
|
-
--dc-focus-ink: 224, 226, 232;
|
|
901
|
-
}
|
|
902
|
-
|
|
903
|
-
:root:not(.dc-off-focusring) [data-composer-card] {
|
|
904
|
-
box-shadow:
|
|
905
|
-
var(--dsw-elevation-soft),
|
|
906
|
-
inset 0 0 0 1px rgba(var(--dc-focus-ink), 0),
|
|
907
|
-
0 0 0 0 rgba(var(--dc-focus-ink), 0),
|
|
908
|
-
0 0 12px 0 rgba(var(--dc-focus-ink), 0),
|
|
909
|
-
0 0 32px 2px rgba(var(--dc-focus-ink), 0);
|
|
910
|
-
transition: box-shadow 240ms cubic-bezier(0.22, 1, 0.36, 1);
|
|
911
|
-
}
|
|
912
|
-
|
|
913
|
-
:root:not(.dc-off-focusring) [data-composer-card]:has(:is([contenteditable="true"], [role="textbox"], textarea):focus) {
|
|
914
|
-
box-shadow:
|
|
915
|
-
var(--dsw-elevation-soft),
|
|
916
|
-
inset 0 0 0 1.2px rgba(var(--dc-focus-ink), 0.92),
|
|
917
|
-
0 0 0 3px rgba(var(--dc-focus-ink), 0.12),
|
|
918
|
-
0 0 14px 1px rgba(var(--dc-focus-ink), 0.22),
|
|
919
|
-
0 0 40px 6px rgba(var(--dc-focus-ink), 0.1);
|
|
920
|
-
}
|
|
921
|
-
|
|
922
|
-
/* --------------------------------------------------- frame-wide ambient layer */
|
|
923
|
-
.dc-overlay {
|
|
924
|
-
position: fixed;
|
|
925
|
-
inset: 0;
|
|
926
|
-
width: 100vw;
|
|
927
|
-
height: 100vh;
|
|
928
|
-
display: block;
|
|
929
|
-
pointer-events: none;
|
|
930
|
-
}
|
|
931
|
-
|
|
932
|
-
/* ------------------------------------------- composer stats in the button row */
|
|
933
|
-
.dc-stats {
|
|
934
|
-
display: inline-flex;
|
|
935
|
-
align-items: center;
|
|
936
|
-
gap: 8px;
|
|
937
|
-
margin-right: 2px;
|
|
938
|
-
color: var(--dsw-alias-label-tertiary);
|
|
939
|
-
font-size: var(--dsh-content-font-size-secondary, 12px);
|
|
940
|
-
font-variant-numeric: tabular-nums;
|
|
941
|
-
line-height: 20px;
|
|
942
|
-
white-space: nowrap;
|
|
943
|
-
user-select: none;
|
|
944
|
-
}
|
|
945
|
-
|
|
946
|
-
.dc-stats-item {
|
|
947
|
-
opacity: 0.85;
|
|
948
|
-
}
|
|
949
|
-
|
|
950
|
-
|
|
951
|
-
/* ---------------------------------------------- reasoning effort celebration */
|
|
952
|
-
body[data-ds-dark-theme] {
|
|
953
|
-
--dc-effort-field: rgba(255, 255, 255, 0.8);
|
|
954
|
-
--dc-effort-ink: rgba(255, 255, 255, 0.95);
|
|
955
|
-
--dc-effort-glow: rgba(255, 255, 255, 0.6);
|
|
956
|
-
}
|
|
957
|
-
|
|
958
|
-
body:not([data-ds-dark-theme]) {
|
|
959
|
-
--dc-effort-field: rgba(58, 62, 72, 0.55);
|
|
960
|
-
--dc-effort-ink: rgba(22, 24, 28, 0.92);
|
|
961
|
-
--dc-effort-glow: rgba(40, 44, 52, 0.4);
|
|
962
|
-
}
|
|
963
|
-
|
|
964
|
-
[data-composer-card] {
|
|
965
|
-
position: relative;
|
|
966
|
-
/* Own stacking context so the field can paint above the card surface but below its
|
|
967
|
-
content without touching the host's children. */
|
|
968
|
-
isolation: isolate;
|
|
969
|
-
}
|
|
970
|
-
|
|
971
|
-
[data-composer-card].dc-effort-on::before {
|
|
972
|
-
content: '';
|
|
973
|
-
position: absolute;
|
|
974
|
-
left: 13%;
|
|
975
|
-
right: 13%;
|
|
976
|
-
bottom: 1px;
|
|
977
|
-
height: 40px;
|
|
978
|
-
z-index: -1;
|
|
979
|
-
pointer-events: none;
|
|
980
|
-
border-radius: 10px;
|
|
981
|
-
opacity: 0.42;
|
|
982
|
-
/* Two vertical highlight bars travel from the middle outwards while the model
|
|
983
|
-
thinks; the third layer is the dot print itself. */
|
|
984
|
-
background-image: linear-gradient(
|
|
985
|
-
90deg,
|
|
986
|
-
transparent 0%,
|
|
987
|
-
var(--dc-effort-glow) 50%,
|
|
988
|
-
transparent 100%
|
|
989
|
-
),
|
|
990
|
-
linear-gradient(
|
|
991
|
-
90deg,
|
|
992
|
-
transparent 0%,
|
|
993
|
-
var(--dc-effort-glow) 50%,
|
|
994
|
-
transparent 100%
|
|
995
|
-
),
|
|
996
|
-
radial-gradient(
|
|
997
|
-
circle at 1px 1px,
|
|
998
|
-
var(--dc-effort-field) 0.9px,
|
|
999
|
-
transparent 1.15px
|
|
1000
|
-
);
|
|
1001
|
-
background-size: 0% 100%, 0% 100%, 4px 4px;
|
|
1002
|
-
background-repeat: no-repeat, no-repeat, repeat;
|
|
1003
|
-
background-position: 50% 50%, 50% 50%, 0 0;
|
|
1004
|
-
/* Fade the field out towards both edges so it reads as depth, not a band. */
|
|
1005
|
-
-webkit-mask-image: linear-gradient(90deg, transparent 0%, #000 26%, #000 74%, transparent 100%);
|
|
1006
|
-
mask-image: linear-gradient(90deg, transparent 0%, #000 26%, #000 74%, transparent 100%);
|
|
1007
|
-
clip-path: inset(0 50% 0 50%);
|
|
1008
|
-
animation: dc-effort-open 800ms cubic-bezier(0.22, 1, 0.36, 1) forwards;
|
|
1009
|
-
}
|
|
1010
|
-
|
|
1011
|
-
[data-composer-card].dc-effort-on::after {
|
|
1012
|
-
content: attr(data-dc-effort);
|
|
1013
|
-
position: absolute;
|
|
1014
|
-
left: 0;
|
|
1015
|
-
right: 0;
|
|
1016
|
-
bottom: 3px;
|
|
1017
|
-
height: 40px;
|
|
1018
|
-
z-index: 2;
|
|
1019
|
-
pointer-events: none;
|
|
1020
|
-
text-align: center;
|
|
1021
|
-
font: italic 900 30px / 40px "Segoe UI", system-ui, sans-serif;
|
|
1022
|
-
letter-spacing: 0.08em;
|
|
1023
|
-
background-image: radial-gradient(
|
|
1024
|
-
circle at 1px 1px,
|
|
1025
|
-
var(--dc-effort-ink) 0.95px,
|
|
1026
|
-
transparent 1.15px
|
|
1027
|
-
);
|
|
1028
|
-
background-size: 3px 3px;
|
|
1029
|
-
-webkit-background-clip: text;
|
|
1030
|
-
background-clip: text;
|
|
1031
|
-
color: transparent;
|
|
1032
|
-
opacity: 0;
|
|
1033
|
-
/* The shadow follows the dot alpha, so the word carries a soft halo. */
|
|
1034
|
-
filter:
|
|
1035
|
-
drop-shadow(0 0 5px rgba(255, 255, 255, 0.4))
|
|
1036
|
-
drop-shadow(0 0 16px rgba(255, 255, 255, 0.2));
|
|
1037
|
-
animation: dc-effort-word 620ms 740ms cubic-bezier(0.22, 1, 0.36, 1) forwards;
|
|
1038
|
-
}
|
|
1039
|
-
|
|
1040
|
-
[data-composer-card].dc-effort-max::after {
|
|
1041
|
-
background-image: radial-gradient(
|
|
1042
|
-
circle at 1px 1px,
|
|
1043
|
-
var(--dc-accent) 0.95px,
|
|
1044
|
-
transparent 1.15px
|
|
1045
|
-
);
|
|
1046
|
-
filter:
|
|
1047
|
-
drop-shadow(0 0 6px rgba(122, 170, 255, 0.75))
|
|
1048
|
-
drop-shadow(0 0 20px rgba(122, 170, 255, 0.45));
|
|
1049
|
-
}
|
|
1050
|
-
|
|
1051
|
-
body:has([data-chat-running]) [data-composer-card].dc-effort-on::before {
|
|
1052
|
-
animation:
|
|
1053
|
-
dc-effort-open 800ms cubic-bezier(0.22, 1, 0.36, 1) forwards,
|
|
1054
|
-
dc-effort-spread 2.2s 900ms ease-out infinite;
|
|
1055
|
-
}
|
|
1056
|
-
|
|
1057
|
-
@keyframes dc-effort-open {
|
|
1058
|
-
from { clip-path: inset(0 50% 0 50%); }
|
|
1059
|
-
to { clip-path: inset(0 0 0 0); }
|
|
1060
|
-
}
|
|
1061
|
-
|
|
1062
|
-
@keyframes dc-effort-word {
|
|
1063
|
-
from { opacity: 0; }
|
|
1064
|
-
to { opacity: 1; }
|
|
1065
|
-
}
|
|
1066
|
-
|
|
1067
|
-
@keyframes dc-effort-spread {
|
|
1068
|
-
0% {
|
|
1069
|
-
background-size: 12% 100%, 12% 100%, 4px 4px;
|
|
1070
|
-
background-position: 50% 50%, 50% 50%, 0 0;
|
|
1071
|
-
}
|
|
1072
|
-
100% {
|
|
1073
|
-
background-size: 12% 100%, 12% 100%, 4px 4px;
|
|
1074
|
-
background-position: 0% 50%, 100% 50%, 0 0;
|
|
1075
|
-
}
|
|
1076
|
-
}
|
|
1077
|
-
|
|
1078
|
-
@media (prefers-reduced-motion: reduce) {
|
|
1079
|
-
[data-composer-card].dc-effort-on::before,
|
|
1080
|
-
[data-composer-card].dc-effort-on::after,
|
|
1081
|
-
body:has([data-chat-running]) [data-composer-card].dc-effort-on::before {
|
|
1082
|
-
animation: none;
|
|
1083
|
-
clip-path: inset(0 0 0 0);
|
|
1084
|
-
opacity: 1;
|
|
1085
|
-
}
|
|
1086
|
-
}
|
|
1087
|
-
|
|
1088
|
-
|
|
1089
|
-
|
|
1090
|
-
|
|
1091
|
-
/* ------------------------------------------------------------- startup splash */
|
|
1092
|
-
.dc-splash {
|
|
1093
|
-
position: fixed;
|
|
1094
|
-
inset: 0;
|
|
1095
|
-
z-index: 2147483600;
|
|
1096
|
-
display: flex;
|
|
1097
|
-
align-items: center;
|
|
1098
|
-
justify-content: center;
|
|
1099
|
-
background: #050507;
|
|
1100
|
-
pointer-events: none;
|
|
1101
|
-
animation: dc-splash-out 460ms 1860ms cubic-bezier(0.4, 0, 1, 1) forwards;
|
|
1102
|
-
contain: strict;
|
|
1103
|
-
}
|
|
1104
|
-
|
|
1105
|
-
/* Compositor-only animation: every property below is opacity or transform. */
|
|
1106
|
-
.dc-splash-grid {
|
|
1107
|
-
position: absolute;
|
|
1108
|
-
inset: -2px;
|
|
1109
|
-
background-image: radial-gradient(circle at 1px 1px, rgba(186, 196, 214, 0.5) 0.9px, transparent 1.15px);
|
|
1110
|
-
background-size: 18px 18px;
|
|
1111
|
-
opacity: 0;
|
|
1112
|
-
will-change: opacity;
|
|
1113
|
-
animation: dc-splash-grid-in 620ms 60ms cubic-bezier(0.22, 1, 0.36, 1) forwards;
|
|
1114
|
-
}
|
|
1115
|
-
|
|
1116
|
-
.dc-splash-ring {
|
|
1117
|
-
position: absolute;
|
|
1118
|
-
width: 108vmax;
|
|
1119
|
-
height: 108vmax;
|
|
1120
|
-
border: 1px solid rgba(176, 196, 232, 0.55);
|
|
1121
|
-
border-radius: 50%;
|
|
1122
|
-
opacity: 0;
|
|
1123
|
-
transform: scale(0.08);
|
|
1124
|
-
will-change: transform, opacity;
|
|
1125
|
-
animation: dc-splash-ring 900ms 60ms cubic-bezier(0.16, 0.84, 0.36, 1) forwards;
|
|
1126
|
-
}
|
|
1127
|
-
|
|
1128
|
-
.dc-splash-mark {
|
|
1129
|
-
position: relative;
|
|
1130
|
-
display: flex;
|
|
1131
|
-
flex-direction: column;
|
|
1132
|
-
align-items: center;
|
|
1133
|
-
gap: 0.08em;
|
|
1134
|
-
overflow: hidden;
|
|
1135
|
-
}
|
|
1136
|
-
|
|
1137
|
-
.dc-splash-line {
|
|
1138
|
-
display: block;
|
|
1139
|
-
font: 800 clamp(38px, 7.8vw, 108px) / 1.14 "Segoe UI", system-ui, sans-serif;
|
|
1140
|
-
letter-spacing: 0.09em;
|
|
1141
|
-
color: transparent;
|
|
1142
|
-
background-size: 5px 5px;
|
|
1143
|
-
-webkit-background-clip: text;
|
|
1144
|
-
background-clip: text;
|
|
1145
|
-
opacity: 0;
|
|
1146
|
-
transform: translate3d(0, 14px, 0) scale(0.985);
|
|
1147
|
-
will-change: transform, opacity;
|
|
1148
|
-
animation: dc-splash-line 760ms cubic-bezier(0.22, 1, 0.36, 1) forwards;
|
|
1149
|
-
}
|
|
1150
|
-
|
|
1151
|
-
.dc-splash-deepseek {
|
|
1152
|
-
background-image: radial-gradient(circle at 1px 1px, #eef0f4 1.1px, transparent 1.35px);
|
|
1153
|
-
}
|
|
1154
|
-
|
|
1155
|
-
.dc-splash-harness {
|
|
1156
|
-
background-image: radial-gradient(circle at 1px 1px, #7aaaff 1.1px, transparent 1.35px);
|
|
1157
|
-
animation-delay: 170ms;
|
|
1158
|
-
}
|
|
1159
|
-
|
|
1160
|
-
.dc-splash-sheen {
|
|
1161
|
-
position: absolute;
|
|
1162
|
-
top: -10%;
|
|
1163
|
-
bottom: -10%;
|
|
1164
|
-
left: 0;
|
|
1165
|
-
width: 34%;
|
|
1166
|
-
background: linear-gradient(
|
|
1167
|
-
90deg,
|
|
1168
|
-
rgba(255, 255, 255, 0) 0%,
|
|
1169
|
-
rgba(255, 255, 255, 0.42) 50%,
|
|
1170
|
-
rgba(255, 255, 255, 0) 100%
|
|
1171
|
-
);
|
|
1172
|
-
opacity: 0;
|
|
1173
|
-
transform: translate3d(-120%, 0, 0);
|
|
1174
|
-
will-change: transform, opacity;
|
|
1175
|
-
animation: dc-splash-sheen 820ms 1080ms cubic-bezier(0.4, 0, 0.6, 1) forwards;
|
|
1176
|
-
}
|
|
1177
|
-
|
|
1178
|
-
.dc-splash-veil {
|
|
1179
|
-
position: absolute;
|
|
1180
|
-
inset: 0;
|
|
1181
|
-
background:
|
|
1182
|
-
radial-gradient(circle at 50% 46%, rgba(0, 0, 0, 0) 38%, rgba(0, 0, 0, 0.62) 100%),
|
|
1183
|
-
linear-gradient(180deg, rgba(0, 0, 0, 0.5) 0%, rgba(0, 0, 0, 0) 26%);
|
|
1184
|
-
}
|
|
1185
|
-
|
|
1186
|
-
@keyframes dc-splash-grid-in {
|
|
1187
|
-
to { opacity: 0.55; }
|
|
1188
|
-
}
|
|
1189
|
-
|
|
1190
|
-
@keyframes dc-splash-ring {
|
|
1191
|
-
0% { opacity: 0; transform: scale(0.08); }
|
|
1192
|
-
30% { opacity: 0.5; }
|
|
1193
|
-
100% { opacity: 0; transform: scale(1.15); }
|
|
1194
|
-
}
|
|
1195
|
-
|
|
1196
|
-
@keyframes dc-splash-line {
|
|
1197
|
-
to { opacity: 1; transform: translate3d(0, 0, 0) scale(1); }
|
|
1198
|
-
}
|
|
1199
|
-
|
|
1200
|
-
@keyframes dc-splash-sheen {
|
|
1201
|
-
0% { opacity: 0; transform: translate3d(-120%, 0, 0); }
|
|
1202
|
-
20% { opacity: 0.9; }
|
|
1203
|
-
100% { opacity: 0; transform: translate3d(300%, 0, 0); }
|
|
1204
|
-
}
|
|
1205
|
-
|
|
1206
|
-
@keyframes dc-splash-out {
|
|
1207
|
-
to { opacity: 0; visibility: hidden; }
|
|
1208
|
-
}
|
|
1209
|
-
|
|
1210
|
-
@media (prefers-reduced-motion: reduce) {
|
|
1211
|
-
.dc-splash,
|
|
1212
|
-
.dc-splash-grid,
|
|
1213
|
-
.dc-splash-ring,
|
|
1214
|
-
.dc-splash-line,
|
|
1215
|
-
.dc-splash-sheen {
|
|
1216
|
-
animation: none;
|
|
1217
|
-
opacity: 1;
|
|
1218
|
-
transform: none;
|
|
1219
|
-
}
|
|
1220
|
-
}
|
|
1221
|
-
|
|
1222
|
-
/* ------------------------------------------------------------ settings page */
|
|
1223
|
-
.dc-set {
|
|
1224
|
-
max-width: 720px;
|
|
1225
|
-
padding: 4px 2px 24px;
|
|
1226
|
-
color: var(--dsw-alias-label-primary);
|
|
1227
|
-
font-synthesis: none;
|
|
1228
|
-
}
|
|
1229
|
-
|
|
1230
|
-
.dc-set-group {
|
|
1231
|
-
margin: 0 0 22px;
|
|
1232
|
-
padding: 0 0 6px;
|
|
1233
|
-
border-bottom: 1px solid var(--dsw-alias-border-l1);
|
|
1234
|
-
}
|
|
1235
|
-
|
|
1236
|
-
.dc-set-group:last-of-type {
|
|
1237
|
-
border-bottom: 0;
|
|
1238
|
-
}
|
|
1239
|
-
|
|
1240
|
-
.dc-set-group-title {
|
|
1241
|
-
margin: 0 0 6px;
|
|
1242
|
-
color: var(--dsw-alias-label-tertiary);
|
|
1243
|
-
font-size: 11px;
|
|
1244
|
-
font-weight: 600;
|
|
1245
|
-
letter-spacing: 0.08em;
|
|
1246
|
-
text-transform: uppercase;
|
|
1247
|
-
}
|
|
1248
|
-
|
|
1249
|
-
.dc-set-row {
|
|
1250
|
-
display: flex;
|
|
1251
|
-
align-items: center;
|
|
1252
|
-
gap: 16px;
|
|
1253
|
-
padding: 10px 0;
|
|
1254
|
-
}
|
|
1255
|
-
|
|
1256
|
-
.dc-set-text {
|
|
1257
|
-
display: flex;
|
|
1258
|
-
flex-direction: column;
|
|
1259
|
-
gap: 2px;
|
|
1260
|
-
min-width: 0;
|
|
1261
|
-
flex: 1 1 auto;
|
|
1262
|
-
}
|
|
1263
|
-
|
|
1264
|
-
.dc-set-label {
|
|
1265
|
-
font-size: 14px;
|
|
1266
|
-
line-height: 1.4;
|
|
1267
|
-
}
|
|
1268
|
-
|
|
1269
|
-
.dc-set-desc {
|
|
1270
|
-
color: var(--dsw-alias-label-tertiary);
|
|
1271
|
-
font-size: 12px;
|
|
1272
|
-
line-height: 1.45;
|
|
1273
|
-
}
|
|
1274
|
-
|
|
1275
|
-
/* The control is an SVG capsule with a drawn circle knob, so the track ends are
|
|
1276
|
-
exact semicircles and the knob is an exact circle at any zoom. */
|
|
1277
|
-
.dc-switch {
|
|
1278
|
-
flex: none;
|
|
1279
|
-
display: inline-flex;
|
|
1280
|
-
padding: 0;
|
|
1281
|
-
border: 0;
|
|
1282
|
-
border-radius: 14px;
|
|
1283
|
-
background: transparent;
|
|
1284
|
-
cursor: pointer;
|
|
1285
|
-
}
|
|
1286
|
-
|
|
1287
|
-
.dc-switch:focus-visible {
|
|
1288
|
-
outline: 2px solid var(--dsw-focus-ring-color, #7aaaff);
|
|
1289
|
-
outline-offset: 2px;
|
|
1290
|
-
}
|
|
1291
|
-
|
|
1292
|
-
@media (prefers-reduced-motion: reduce) {
|
|
1293
|
-
.dc-switch svg rect,
|
|
1294
|
-
.dc-switch svg g,
|
|
1295
|
-
.dc-switch svg circle {
|
|
1296
|
-
transition: none !important;
|
|
1297
|
-
}
|
|
1298
|
-
}
|
|
1299
|
-
|
|
1300
|
-
.dc-set-footer {
|
|
1301
|
-
display: flex;
|
|
1302
|
-
align-items: center;
|
|
1303
|
-
justify-content: space-between;
|
|
1304
|
-
gap: 12px;
|
|
1305
|
-
padding-top: 8px;
|
|
1306
|
-
}
|
|
1307
|
-
|
|
1308
|
-
.dc-set-reset {
|
|
1309
|
-
padding: 7px 14px;
|
|
1310
|
-
border: 1px solid var(--dsw-alias-border-l2);
|
|
1311
|
-
border-radius: var(--dsw-radius-sm, 6px);
|
|
1312
|
-
background: transparent;
|
|
1313
|
-
color: var(--dsw-alias-label-primary);
|
|
1314
|
-
font: inherit;
|
|
1315
|
-
font-size: 13px;
|
|
1316
|
-
cursor: pointer;
|
|
1317
|
-
}
|
|
1318
|
-
|
|
1319
|
-
.dc-set-reset:hover {
|
|
1320
|
-
background: var(--dsw-alias-interactive-bg-hover, rgba(127, 127, 127, 0.1));
|
|
1321
|
-
}
|
|
1322
|
-
|
|
1323
|
-
.dc-set-note {
|
|
1324
|
-
color: var(--dsw-alias-label-tertiary);
|
|
1325
|
-
font-size: 12px;
|
|
1326
|
-
font-variant-numeric: tabular-nums;
|
|
1327
|
-
}
|
|
1328
|
-
|
|
1329
|
-
/* -------------------------------------------------------- sidebar entry + sheet */
|
|
1330
|
-
.dc-foot {
|
|
1331
|
-
display: flex;
|
|
1332
|
-
flex-direction: column;
|
|
1333
|
-
gap: 2px;
|
|
1334
|
-
min-width: 0;
|
|
1335
|
-
}
|
|
1336
|
-
|
|
1337
|
-
.dc-foot-button {
|
|
1338
|
-
position: relative;
|
|
1339
|
-
overflow: hidden;
|
|
1340
|
-
display: flex;
|
|
1341
|
-
align-items: center;
|
|
1342
|
-
gap: 10px;
|
|
1343
|
-
width: 100%;
|
|
1344
|
-
padding: 7px 10px;
|
|
1345
|
-
border: 0;
|
|
1346
|
-
border-radius: var(--dsw-radius-sm, 6px);
|
|
1347
|
-
background: transparent;
|
|
1348
|
-
color: var(--dsw-alias-label-secondary);
|
|
1349
|
-
font: inherit;
|
|
1350
|
-
font-size: 13px;
|
|
1351
|
-
line-height: 20px;
|
|
1352
|
-
text-align: left;
|
|
1353
|
-
cursor: pointer;
|
|
1354
|
-
white-space: nowrap;
|
|
1355
|
-
overflow: hidden;
|
|
1356
|
-
}
|
|
1357
|
-
|
|
1358
|
-
.dc-foot-dots {
|
|
1359
|
-
position: absolute;
|
|
1360
|
-
inset: 0;
|
|
1361
|
-
width: 100%;
|
|
1362
|
-
height: 100%;
|
|
1363
|
-
display: block;
|
|
1364
|
-
pointer-events: none;
|
|
1365
|
-
}
|
|
1366
|
-
|
|
1367
|
-
.dc-foot-button > :not(.dc-foot-dots) {
|
|
1368
|
-
position: relative;
|
|
1369
|
-
z-index: 1;
|
|
1370
|
-
}
|
|
1371
|
-
|
|
1372
|
-
.dc-foot-button:hover {
|
|
1373
|
-
background: var(--dsw-alias-interactive-bg-hover, rgba(127, 127, 127, 0.1));
|
|
1374
|
-
color: var(--dsw-alias-label-primary);
|
|
1375
|
-
}
|
|
1376
|
-
|
|
1377
|
-
.dc-foot-button:focus-visible {
|
|
1378
|
-
outline: 2px solid var(--dsw-focus-ring-color, #7aaaff);
|
|
1379
|
-
outline-offset: 1px;
|
|
1380
|
-
}
|
|
1381
|
-
|
|
1382
|
-
.dc-foot-label {
|
|
1383
|
-
overflow: hidden;
|
|
1384
|
-
text-overflow: ellipsis;
|
|
1385
|
-
}
|
|
1386
|
-
|
|
1387
|
-
.dc-sheet-root {
|
|
1388
|
-
position: fixed;
|
|
1389
|
-
inset: 0;
|
|
1390
|
-
z-index: 2147483001;
|
|
1391
|
-
}
|
|
1392
|
-
|
|
1393
|
-
.dc-sheet-scrim {
|
|
1394
|
-
position: absolute;
|
|
1395
|
-
inset: 0;
|
|
1396
|
-
background: rgba(0, 0, 0, 0.28);
|
|
1397
|
-
}
|
|
1398
|
-
|
|
1399
|
-
.dc-sheet-panel {
|
|
1400
|
-
position: absolute;
|
|
1401
|
-
left: 14px;
|
|
1402
|
-
bottom: 78px;
|
|
1403
|
-
width: min(420px, calc(100vw - 28px));
|
|
1404
|
-
max-height: min(72vh, 640px);
|
|
1405
|
-
display: flex;
|
|
1406
|
-
flex-direction: column;
|
|
1407
|
-
border: 0;
|
|
1408
|
-
border-radius: 20px;
|
|
1409
|
-
/* Opaque on purpose: a raised surface layered over the base colour, so the panel is
|
|
1410
|
-
always solid and always uses the app's own palette instead of a hand-picked grey. */
|
|
1411
|
-
background-color: var(--dsw-alias-bg-base, #f6f6f8);
|
|
1412
|
-
background-image: linear-gradient(
|
|
1413
|
-
var(--dsw-alias-bg-layer-1, transparent),
|
|
1414
|
-
var(--dsw-alias-bg-layer-1, transparent)
|
|
1415
|
-
);
|
|
1416
|
-
box-shadow: var(--dsw-elevation-panel, 0 18px 48px rgba(0, 0, 0, 0.42));
|
|
1417
|
-
overflow: hidden;
|
|
1418
|
-
animation: dc-sheet-in 200ms cubic-bezier(0.22, 1, 0.36, 1);
|
|
1419
|
-
}
|
|
1420
|
-
|
|
1421
|
-
@keyframes dc-sheet-in {
|
|
1422
|
-
from { opacity: 0; transform: translateY(8px); }
|
|
1423
|
-
to { opacity: 1; transform: translateY(0); }
|
|
1424
|
-
}
|
|
1425
|
-
|
|
1426
|
-
.dc-sheet-head {
|
|
1427
|
-
display: flex;
|
|
1428
|
-
align-items: center;
|
|
1429
|
-
justify-content: space-between;
|
|
1430
|
-
gap: 12px;
|
|
1431
|
-
padding: 14px 16px 12px;
|
|
1432
|
-
border-bottom: 1px solid var(--dsw-alias-border-l1);
|
|
1433
|
-
}
|
|
1434
|
-
|
|
1435
|
-
.dc-sheet-title {
|
|
1436
|
-
font-size: 14px;
|
|
1437
|
-
font-weight: 600;
|
|
1438
|
-
color: var(--dsw-alias-label-primary);
|
|
1439
|
-
}
|
|
1440
|
-
|
|
1441
|
-
.dc-sheet-close {
|
|
1442
|
-
border: 0;
|
|
1443
|
-
background: transparent;
|
|
1444
|
-
color: var(--dsw-alias-label-tertiary);
|
|
1445
|
-
font-size: 18px;
|
|
1446
|
-
line-height: 1;
|
|
1447
|
-
padding: 2px 6px;
|
|
1448
|
-
border-radius: 6px;
|
|
1449
|
-
cursor: pointer;
|
|
1450
|
-
}
|
|
1451
|
-
|
|
1452
|
-
.dc-sheet-close:hover {
|
|
1453
|
-
background: var(--dsw-alias-interactive-bg-hover, rgba(127, 127, 127, 0.1));
|
|
1454
|
-
color: var(--dsw-alias-label-primary);
|
|
1455
|
-
}
|
|
1456
|
-
|
|
1457
|
-
.dc-sheet-body {
|
|
1458
|
-
padding: 4px 16px 8px;
|
|
1459
|
-
overflow-y: auto;
|
|
1460
|
-
}
|
|
1461
|
-
|
|
1462
|
-
@media (prefers-reduced-motion: reduce) {
|
|
1463
|
-
.dc-sheet-panel { animation: none; }
|
|
1464
|
-
}
|
|
1465
|
-
/* fish reading:start */
|
|
1466
|
-
/* Deep Fish reading: semantic hooks only; never animate streamed text. */
|
|
1467
|
-
body {
|
|
1468
|
-
--dc-accent: var(--dsw-alias-link);
|
|
1469
|
-
--dc-focus: color-mix(in srgb, var(--dc-accent) 18%, transparent);
|
|
1470
|
-
}
|
|
1471
|
-
|
|
1472
|
-
:root:not(.dc-off-reading) [data-chat-flow-kind="assistant-step"]:not([data-chat-group-part="reasoning"]) :is(p, li) {
|
|
1473
|
-
line-height: 1.85;
|
|
1474
|
-
text-wrap: pretty;
|
|
1475
|
-
}
|
|
1476
|
-
:root:not(.dc-off-reading) [data-chat-flow-kind="assistant-step"] :is(h1, h2, h3, h4) {
|
|
1477
|
-
color: var(--dsw-alias-label-primary);
|
|
1478
|
-
letter-spacing: -0.015em;
|
|
1479
|
-
line-height: 1.45;
|
|
1480
|
-
text-wrap: balance;
|
|
1481
|
-
}
|
|
1482
|
-
:root:not(.dc-off-reading) [data-chat-flow-kind="assistant-step"] :is(h2, h3) {
|
|
1483
|
-
padding-block-start: 0.25em;
|
|
1484
|
-
}
|
|
1485
|
-
:root:not(.dc-off-reading) [data-chat-flow-kind="assistant-step"] blockquote {
|
|
1486
|
-
border-inline-start: 2px solid color-mix(in srgb, var(--dc-accent) 38%, transparent);
|
|
1487
|
-
padding-inline-start: 1em;
|
|
1488
|
-
color: var(--dsw-alias-label-secondary);
|
|
1489
|
-
}
|
|
1490
|
-
:root:not(.dc-off-reading) [data-chat-flow-kind="assistant-step"] :is(p, li) > code {
|
|
1491
|
-
color: var(--dsw-alias-label-primary);
|
|
1492
|
-
background: var(--dsw-alias-interactive-bg-hover);
|
|
1493
|
-
border-radius: 4px;
|
|
1494
|
-
padding: 0.12em 0.35em;
|
|
1495
|
-
}
|
|
1496
|
-
:root:not(.dc-off-code) [data-chat-flow-kind="assistant-step"] pre {
|
|
1497
|
-
font-variant-ligatures: none;
|
|
1498
|
-
tab-size: 2;
|
|
1499
|
-
}
|
|
1500
|
-
/* Sidebar brand: the whale mark and the product name carry a quiet halo so they read as
|
|
1501
|
-
part of the same light as the accent. */
|
|
1502
|
-
[data-slot="sidebar.brand.mark"] {
|
|
1503
|
-
filter:
|
|
1504
|
-
drop-shadow(0 0 5px color-mix(in srgb, var(--dc-accent) 50%, transparent))
|
|
1505
|
-
drop-shadow(0 0 16px color-mix(in srgb, var(--dc-accent) 26%, transparent));
|
|
1506
|
-
}
|
|
1507
|
-
|
|
1508
|
-
[data-slot="sidebar.brand.name"] {
|
|
1509
|
-
text-shadow:
|
|
1510
|
-
0 0 1px color-mix(in srgb, var(--dc-accent) 42%, transparent),
|
|
1511
|
-
0 0 9px color-mix(in srgb, var(--dc-accent) 34%, transparent),
|
|
1512
|
-
0 0 22px color-mix(in srgb, var(--dc-accent) 18%, transparent);
|
|
1513
|
-
}
|
|
1514
|
-
|
|
1515
|
-
/* User messages carry a whale-blue halo: a hairline ring plus two soft halos. */
|
|
1516
|
-
[data-message-bubble] {
|
|
1517
|
-
box-shadow:
|
|
1518
|
-
0 0 0 1px color-mix(in srgb, var(--dc-accent) 52%, transparent),
|
|
1519
|
-
0 0 14px 1px color-mix(in srgb, var(--dc-accent) 22%, transparent),
|
|
1520
|
-
0 0 38px 8px color-mix(in srgb, var(--dc-accent) 10%, transparent);
|
|
1521
|
-
}
|
|
1522
|
-
|
|
1523
|
-
/* Selected conversation: a flat black plate in dark theme instead of the host's
|
|
1524
|
-
translucent hover fill. */
|
|
1525
|
-
body[data-ds-dark-theme] [class*="_sessionRow"][class*="_selected"] {
|
|
1526
|
-
background-color: #0d0d10;
|
|
1527
|
-
}
|
|
1528
|
-
|
|
1529
|
-
body:not([data-ds-dark-theme]) [class*="_sessionRow"][class*="_selected"] {
|
|
1530
|
-
background-color: #e9e9ec;
|
|
1531
|
-
}
|
|
1532
|
-
|
|
1533
|
-
:root:not(.dc-off-bold) [data-chat-flow-kind="assistant-step"] :is(p, li, td, blockquote) :is(strong, b) {
|
|
1534
|
-
color: var(--dc-accent);
|
|
1535
|
-
/* A soft halo so the accent reads as light rather than paint. */
|
|
1536
|
-
text-shadow:
|
|
1537
|
-
0 0 1px color-mix(in srgb, var(--dc-accent) 55%, transparent),
|
|
1538
|
-
0 0 8px color-mix(in srgb, var(--dc-accent) 42%, transparent),
|
|
1539
|
-
0 0 20px color-mix(in srgb, var(--dc-accent) 22%, transparent);
|
|
1540
|
-
}
|
|
1541
|
-
:root:not(.dc-off-thinkinglabel) [data-chat-running] [class*="_runningText"] {
|
|
1542
|
-
opacity: 0;
|
|
1543
|
-
}
|
|
1544
|
-
:root:not(.dc-off-thinkingsphere) [data-chat-running] [class*="_runningIcon"] {
|
|
1545
|
-
display: none;
|
|
1546
|
-
}
|
|
1547
|
-
|
|
1548
|
-
/* Compact figures leave submit reachable in a narrow composer. */
|
|
1549
|
-
.dc-stats {
|
|
1550
|
-
gap: 10px;
|
|
1551
|
-
font-size: 11px;
|
|
1552
|
-
letter-spacing: 0.015em;
|
|
1553
|
-
font-variant-numeric: tabular-nums;
|
|
1554
|
-
}
|
|
1555
|
-
.dc-stats-label {
|
|
1556
|
-
margin-inline-end: 4px;
|
|
1557
|
-
color: var(--dsw-alias-label-tertiary);
|
|
1558
|
-
font-size: 9px;
|
|
1559
|
-
letter-spacing: 0.06em;
|
|
1560
|
-
}
|
|
1561
|
-
.dc-stats-item { color: var(--dsw-alias-label-secondary); }
|
|
1562
|
-
@media (max-width: 640px) {
|
|
1563
|
-
.dc-stats-label { display: none; }
|
|
1564
|
-
.dc-stats { gap: 6px; }
|
|
1565
|
-
}
|
|
1566
|
-
@media (max-width: 420px) {
|
|
1567
|
-
.dc-stats-output { display: none; }
|
|
1568
|
-
}
|
|
1569
|
-
.dc-switch:disabled { cursor: default; opacity: 0.48; }
|
|
1570
|
-
.dc-set-reset:disabled { cursor: default; opacity: 0.48; }
|
|
1571
|
-
.dc-settings-status {
|
|
1572
|
-
margin: 0 0 16px;
|
|
1573
|
-
font-size: 12px;
|
|
1574
|
-
color: var(--dsw-alias-label-secondary);
|
|
1575
|
-
}
|
|
1576
|
-
.dc-settings-status[role="alert"] { color: var(--dsw-alias-state-error-primary); }
|
|
1577
|
-
@media (prefers-reduced-motion: reduce) {
|
|
1578
|
-
.dc-sheet-panel, .dc-sheet-scrim { animation: none; }
|
|
1579
|
-
[data-composer-card] { transition: none !important; }
|
|
1580
|
-
}
|
|
1581
|
-
|
|
1582
|
-
/* fish reading:end */
|
|
1583
|
-
`
|
|
1584
|
-
|
|
1585
|
-
/* fish indicator:start */
|
|
1586
|
-
/**
|
|
1587
|
-
* Dot sphere and English status label.
|
|
1588
|
-
*
|
|
1589
|
-
* The host text keeps the real clock, so we read the elapsed seconds out of it and
|
|
1590
|
-
* redraw both the words and a sweeping highlight on our own overlay canvas. The host
|
|
1591
|
-
* label is hidden by `reading.css` while this is on; turning it off restores the host
|
|
1592
|
-
* row untouched and only parks the sphere to the left of the visible text.
|
|
1593
|
-
*/
|
|
1594
|
-
function DcOverlay() {
|
|
1595
|
-
const canvasRef = React.useRef(null)
|
|
1596
|
-
const settings = useDcSettings()
|
|
1597
|
-
const sphereOn = settings.values.thinkingSphere !== false
|
|
1598
|
-
const labelOn = settings.values.thinkingLabel !== false
|
|
1599
|
-
React.useEffect(() => {
|
|
1600
|
-
const canvas = canvasRef.current
|
|
1601
|
-
if (!canvas) return
|
|
1602
|
-
const context = canvas.getContext('2d')
|
|
1603
|
-
if (!context) return
|
|
1604
|
-
const motion = matchMedia('(prefers-reduced-motion: reduce)')
|
|
1605
|
-
// Wall clock anchor. The host may remount its row on every tick, so an element
|
|
1606
|
-
// keyed start time resets constantly; a single anchor survives those remounts
|
|
1607
|
-
// and is dropped as soon as the row leaves the document.
|
|
1608
|
-
const clock = { since: 0 }
|
|
1609
|
-
let frame = 0
|
|
1610
|
-
let stopped = false
|
|
1611
|
-
const clear = () => context.clearRect(0, 0, canvas.width, canvas.height)
|
|
1612
|
-
|
|
1613
|
-
// The hidden host text cannot be trusted for the clock (its digits are not the
|
|
1614
|
-
// elapsed value), so the label counts wall time from when the running row first
|
|
1615
|
-
// appeared and restarts whenever the row leaves the document.
|
|
1616
|
-
const elapsedOf = (now) => {
|
|
1617
|
-
if (clock.since === 0) clock.since = now
|
|
1618
|
-
return Math.max(0, Math.round((now - clock.since) / 1000))
|
|
1619
|
-
}
|
|
1620
|
-
|
|
1621
|
-
const drawSphere = (cx, cy, spin, ink) => {
|
|
1622
|
-
// Two batched passes: a soft halo under a crisp core, so the sphere reads as
|
|
1623
|
-
// light instead of loose dots. Only 42 dots, so buckets are cheap.
|
|
1624
|
-
const points = []
|
|
1625
|
-
for (let index = 0; index < 42; index += 1) {
|
|
1626
|
-
const v = 1 - (2 * (index + 0.5)) / 42
|
|
1627
|
-
const ring = Math.sqrt(1 - v * v)
|
|
1628
|
-
const angle = index * 2.39996323 + spin
|
|
1629
|
-
const depth = Math.sin(angle) * ring
|
|
1630
|
-
points.push({
|
|
1631
|
-
x: cx + Math.cos(angle) * ring * 8,
|
|
1632
|
-
y: cy + v * 8,
|
|
1633
|
-
alpha: 0.25 + (depth + 1) * 0.32,
|
|
1634
|
-
radius: 0.8 + (depth + 1) * 0.35,
|
|
1635
|
-
})
|
|
1636
|
-
}
|
|
1637
|
-
context.fillStyle = ink
|
|
1638
|
-
const passes = [
|
|
1639
|
-
{ grow: 2.1, scale: 0.28 },
|
|
1640
|
-
{ grow: 1, scale: 1 },
|
|
1641
|
-
]
|
|
1642
|
-
for (const pass of passes) {
|
|
1643
|
-
const buckets = new Map()
|
|
1644
|
-
for (const point of points) {
|
|
1645
|
-
const alpha = point.alpha * pass.scale
|
|
1646
|
-
if (alpha < 0.02) continue
|
|
1647
|
-
const level = Math.min(10, Math.max(1, Math.round(alpha * 10)))
|
|
1648
|
-
let bucket = buckets.get(level)
|
|
1649
|
-
if (bucket === undefined) {
|
|
1650
|
-
bucket = new Path2D()
|
|
1651
|
-
buckets.set(level, bucket)
|
|
1652
|
-
}
|
|
1653
|
-
const radius = point.radius * pass.grow
|
|
1654
|
-
bucket.moveTo(point.x + radius, point.y)
|
|
1655
|
-
bucket.arc(point.x, point.y, radius, 0, Math.PI * 2)
|
|
1656
|
-
}
|
|
1657
|
-
for (const [level, path] of buckets) {
|
|
1658
|
-
context.globalAlpha = level / 10
|
|
1659
|
-
context.fill(path)
|
|
1660
|
-
}
|
|
1661
|
-
}
|
|
1662
|
-
context.globalAlpha = 1
|
|
1663
|
-
}
|
|
1664
|
-
|
|
1665
|
-
const drawLabel = (row, label, x, cy, seconds, now, ink) => {
|
|
1666
|
-
const style = getComputedStyle(label)
|
|
1667
|
-
const font = style.fontWeight + ' ' + style.fontSize + ' ' + style.fontFamily
|
|
1668
|
-
context.font = font
|
|
1669
|
-
context.textBaseline = 'middle'
|
|
1670
|
-
const text = 'Deep thinking for ' + seconds + 's. . .'
|
|
1671
|
-
const width = context.measureText(text).width
|
|
1672
|
-
const accent = (getComputedStyle(row).getPropertyValue('--dc-accent') || '').trim() || '#7aaaff'
|
|
1673
|
-
const band = motion.matches ? -1e4 : ((now % 2600) / 2600) * (width + 140) - 70
|
|
1674
|
-
context.save()
|
|
1675
|
-
context.beginPath()
|
|
1676
|
-
context.rect(x - 2, cy - 20, width + 4, 40)
|
|
1677
|
-
context.clip()
|
|
1678
|
-
context.fillStyle = ink
|
|
1679
|
-
context.globalAlpha = 0.92
|
|
1680
|
-
context.fillText(text, x, cy)
|
|
1681
|
-
context.globalAlpha = 1
|
|
1682
|
-
const gradient = context.createLinearGradient(x + band - 70, 0, x + band + 70, 0)
|
|
1683
|
-
gradient.addColorStop(0, 'rgba(122, 170, 255, 0)')
|
|
1684
|
-
gradient.addColorStop(0.5, accent)
|
|
1685
|
-
gradient.addColorStop(1, 'rgba(122, 170, 255, 0)')
|
|
1686
|
-
context.fillStyle = gradient
|
|
1687
|
-
context.fillText(text, x, cy)
|
|
1688
|
-
context.restore()
|
|
1689
|
-
}
|
|
1690
|
-
|
|
1691
|
-
const paint = now => {
|
|
1692
|
-
frame = 0
|
|
1693
|
-
if (stopped || document.hidden) return
|
|
1694
|
-
const dpr = Math.min(2, devicePixelRatio || 1)
|
|
1695
|
-
const width = innerWidth
|
|
1696
|
-
const height = innerHeight
|
|
1697
|
-
if (canvas.width !== Math.round(width * dpr) || canvas.height !== Math.round(height * dpr)) {
|
|
1698
|
-
canvas.width = Math.round(width * dpr)
|
|
1699
|
-
canvas.height = Math.round(height * dpr)
|
|
1700
|
-
}
|
|
1701
|
-
clear()
|
|
1702
|
-
context.setTransform(dpr, 0, 0, dpr, 0, 0)
|
|
1703
|
-
const card = document.querySelector('[data-composer-card]')
|
|
1704
|
-
const cardTop = card === null ? height : card.getBoundingClientRect().top
|
|
1705
|
-
const spin = motion.matches ? 0.35 : now / 1800
|
|
1706
|
-
const running = document.querySelectorAll('[data-chat-running]')
|
|
1707
|
-
if (running.length === 0) clock.since = 0
|
|
1708
|
-
let visible = false
|
|
1709
|
-
for (const row of document.querySelectorAll('[data-chat-running]:not([data-holding])')) {
|
|
1710
|
-
const bounds = row.getBoundingClientRect()
|
|
1711
|
-
if (bounds.height === 0 || bounds.top < 0 || bounds.bottom > height) continue
|
|
1712
|
-
// The overlay paints above every column: never let the sphere or the label
|
|
1713
|
-
// sit over the composer card.
|
|
1714
|
-
if (bounds.bottom + 2 > cardTop) continue
|
|
1715
|
-
const label = row.querySelector('[class*="_runningText"]')
|
|
1716
|
-
if (label === null) continue
|
|
1717
|
-
const labelRect = label.getBoundingClientRect()
|
|
1718
|
-
const ink = getComputedStyle(label).color || 'rgb(200, 205, 215)'
|
|
1719
|
-
const size = 24
|
|
1720
|
-
let cx
|
|
1721
|
-
let cy
|
|
1722
|
-
if (labelOn) {
|
|
1723
|
-
cx = bounds.left + 2 + size / 2
|
|
1724
|
-
cy = bounds.top + Math.min(bounds.height, 30) / 2
|
|
1725
|
-
} else {
|
|
1726
|
-
if (labelRect.width === 0) continue
|
|
1727
|
-
// Keep clear of the host words: park the sphere in the gutter to their left.
|
|
1728
|
-
cx = Math.max(size / 2 + 6, labelRect.left - size / 2 - 8)
|
|
1729
|
-
cy = labelRect.top + labelRect.height / 2
|
|
1730
|
-
}
|
|
1731
|
-
visible = true
|
|
1732
|
-
if (sphereOn) drawSphere(cx, cy, spin, ink)
|
|
1733
|
-
if (labelOn) {
|
|
1734
|
-
const seconds = elapsedOf(now)
|
|
1735
|
-
const x = bounds.left + 2 + (sphereOn ? size + 8 : 0)
|
|
1736
|
-
drawLabel(row, label, x, cy, seconds, now, ink)
|
|
1737
|
-
}
|
|
1738
|
-
}
|
|
1739
|
-
if (visible && !motion.matches) frame = requestAnimationFrame(paint)
|
|
1740
|
-
}
|
|
1741
|
-
|
|
1742
|
-
const refresh = () => {
|
|
1743
|
-
if (frame) cancelAnimationFrame(frame)
|
|
1744
|
-
frame = 0
|
|
1745
|
-
if (document.hidden) clear()
|
|
1746
|
-
else frame = requestAnimationFrame(paint)
|
|
1747
|
-
}
|
|
1748
|
-
const observer = new MutationObserver(refresh)
|
|
1749
|
-
observer.observe(document.body, {
|
|
1750
|
-
childList: true,
|
|
1751
|
-
subtree: true,
|
|
1752
|
-
characterData: true,
|
|
1753
|
-
attributes: true,
|
|
1754
|
-
attributeFilter: ['data-holding', 'data-ds-dark-theme'],
|
|
1755
|
-
})
|
|
1756
|
-
window.addEventListener('resize', refresh)
|
|
1757
|
-
document.addEventListener('scroll', refresh, true)
|
|
1758
|
-
document.addEventListener('visibilitychange', refresh)
|
|
1759
|
-
motion.addEventListener('change', refresh)
|
|
1760
|
-
refresh()
|
|
1761
|
-
return () => {
|
|
1762
|
-
stopped = true
|
|
1763
|
-
cancelAnimationFrame(frame)
|
|
1764
|
-
observer.disconnect()
|
|
1765
|
-
window.removeEventListener('resize', refresh)
|
|
1766
|
-
document.removeEventListener('scroll', refresh, true)
|
|
1767
|
-
document.removeEventListener('visibilitychange', refresh)
|
|
1768
|
-
motion.removeEventListener('change', refresh)
|
|
1769
|
-
}
|
|
1770
|
-
}, [sphereOn, labelOn])
|
|
1771
|
-
return sphereOn || labelOn
|
|
1772
|
-
? h('canvas', { ref: canvasRef, className: 'dc-overlay', 'aria-hidden': 'true' })
|
|
1773
|
-
: null
|
|
1774
|
-
}
|
|
1775
|
-
|
|
1776
|
-
/* fish indicator:end */
|
|
1777
|
-
|
|
1778
|
-
/** Compact session stats for the composer button row. */
|
|
1779
|
-
function DcStats(props) {
|
|
1780
|
-
const { values } = useDcSettings()
|
|
1781
|
-
const usage = props.useProjection('tokenUsage')
|
|
1782
|
-
const pressure = props.useProjection('contextPressure')
|
|
1783
|
-
if (!values.stats) return null
|
|
1784
|
-
const billed = usage === undefined || usage === null
|
|
1785
|
-
? 0
|
|
1786
|
-
: (usage.uncachedInputTokens || 0) + (usage.cacheReadTokens || 0)
|
|
1787
|
-
+ (usage.cacheWriteTokens || 0) + (usage.outputTokens || 0)
|
|
1788
|
-
const used = pressure === undefined || pressure === null
|
|
1789
|
-
? undefined
|
|
1790
|
-
: (pressure.projectedTokens !== undefined ? pressure.projectedTokens : pressure.pressureTokens)
|
|
1791
|
-
const windowSize = pressure === undefined || pressure === null ? undefined : pressure.contextWindow
|
|
1792
|
-
const percent = used === undefined || windowSize === undefined || windowSize === 0
|
|
1793
|
-
? null
|
|
1794
|
-
: Math.max(0, Math.min(100, Math.round((used / windowSize) * 100)))
|
|
1795
|
-
if (billed === 0 && percent === null) return null
|
|
1796
|
-
const tokens = billed >= 1e6
|
|
1797
|
-
? (billed / 1e6).toFixed(1) + 'm'
|
|
1798
|
-
: billed >= 1e3
|
|
1799
|
-
? (billed / 1e3).toFixed(1) + 'k'
|
|
1800
|
-
: String(billed)
|
|
1801
|
-
return h('span', { className: 'dc-stats' }, [
|
|
1802
|
-
percent === null
|
|
1803
|
-
? null
|
|
1804
|
-
: h('span', { key: 'ctx', className: 'dc-stats-item', title: dcUsesChinese() ? '上下文占用' : 'Context usage' }, [h('span', { key: 'label', className: 'dc-stats-label' }, 'CTX'), percent + '%']),
|
|
1805
|
-
billed === 0
|
|
1806
|
-
? null
|
|
1807
|
-
: h('span', { key: 'tok', className: 'dc-stats-item dc-stats-output', title: dcUsesChinese() ? '累计 Token 用量' : 'Cumulative token usage' }, [h('span', { key: 'label', className: 'dc-stats-label' }, 'TOK'), tokens]),
|
|
1808
|
-
])
|
|
1809
|
-
}
|
|
1810
|
-
|
|
1811
|
-
/**
|
|
1812
|
-
* Hover dot field for every rows in the sidebar.
|
|
1813
|
-
*
|
|
1814
|
-
* No nodes are injected into host buttons: a single fixed canvas tracks the pointer,
|
|
1815
|
-
* finds the sidebar button under it, and prints a dot field clipped to that button.
|
|
1816
|
-
*/
|
|
1817
|
-
function DcSidebarDots() {
|
|
1818
|
-
const canvasRef = React.useRef(null)
|
|
1819
|
-
const { values } = useDcSettings()
|
|
1820
|
-
const showDots = values.sidebarDots !== false
|
|
1821
|
-
const showRail = values.sidebarRail !== false
|
|
1822
|
-
React.useEffect(() => {
|
|
1823
|
-
const canvas = canvasRef.current
|
|
1824
|
-
if (canvas === null) return
|
|
1825
|
-
const context = canvas.getContext('2d')
|
|
1826
|
-
if (context === null) return
|
|
1827
|
-
const motion = matchMedia('(prefers-reduced-motion: reduce)')
|
|
1828
|
-
const state = {
|
|
1829
|
-
row: null,
|
|
1830
|
-
x: 0,
|
|
1831
|
-
y: 0,
|
|
1832
|
-
inside: false,
|
|
1833
|
-
rail: false,
|
|
1834
|
-
alpha: 0,
|
|
1835
|
-
frame: 0,
|
|
1836
|
-
live: false,
|
|
1837
|
-
dirty: false,
|
|
1838
|
-
}
|
|
1839
|
-
let stopped = false
|
|
1840
|
-
let dpr = Math.min(2, devicePixelRatio || 1)
|
|
1841
|
-
let rootCache = null
|
|
1842
|
-
|
|
1843
|
-
// The sidebar column itself is the scope: walk up from our footer button to the
|
|
1844
|
-
// column landmark, once, and only light controls inside it. A lowest-common-ancestor
|
|
1845
|
-
// guess leaked into the chat column and put rails on every button in the app.
|
|
1846
|
-
const sidebarScope = () => {
|
|
1847
|
-
if (rootCache !== null && rootCache.isConnected) return rootCache
|
|
1848
|
-
const foot = document.querySelector('.dc-foot-button')
|
|
1849
|
-
if (foot === null) return null
|
|
1850
|
-
let node = foot
|
|
1851
|
-
for (let depth = 0; depth < 10; depth += 1) {
|
|
1852
|
-
node = node.parentElement
|
|
1853
|
-
if (node === null) break
|
|
1854
|
-
if (node.matches('aside, [data-slot="sidebar"], [data-sidebar], [role="navigation"]')) {
|
|
1855
|
-
rootCache = node
|
|
1856
|
-
return node
|
|
1857
|
-
}
|
|
1858
|
-
}
|
|
1859
|
-
// No landmark: take the column wrapper a few levels up as a best effort.
|
|
1860
|
-
let fallback = foot
|
|
1861
|
-
for (let depth = 0; depth < 5 && fallback.parentElement !== null; depth += 1) {
|
|
1862
|
-
fallback = fallback.parentElement
|
|
1863
|
-
}
|
|
1864
|
-
rootCache = fallback
|
|
1865
|
-
return fallback
|
|
1866
|
-
}
|
|
1867
|
-
|
|
1868
|
-
const paint = () => {
|
|
1869
|
-
state.frame = 0
|
|
1870
|
-
if (stopped) return
|
|
1871
|
-
const width = innerWidth
|
|
1872
|
-
const height = innerHeight
|
|
1873
|
-
if (canvas.width !== Math.round(width * dpr) || canvas.height !== Math.round(height * dpr)) {
|
|
1874
|
-
canvas.width = Math.round(width * dpr)
|
|
1875
|
-
canvas.height = Math.round(height * dpr)
|
|
1876
|
-
}
|
|
1877
|
-
const target = state.inside ? 1 : 0
|
|
1878
|
-
state.alpha = motion.matches ? target : state.alpha + (target - state.alpha) * 0.22
|
|
1879
|
-
context.setTransform(dpr, 0, 0, dpr, 0, 0)
|
|
1880
|
-
context.clearRect(0, 0, width, height)
|
|
1881
|
-
if (!state.inside && state.alpha < 0.02) {
|
|
1882
|
-
state.alpha = 0
|
|
1883
|
-
state.live = false
|
|
1884
|
-
return
|
|
1885
|
-
}
|
|
1886
|
-
if (state.row === null || !state.row.isConnected) {
|
|
1887
|
-
state.inside = false
|
|
1888
|
-
state.live = false
|
|
1889
|
-
return
|
|
1890
|
-
}
|
|
1891
|
-
const rect = state.row.getBoundingClientRect()
|
|
1892
|
-
if (rect.width < 8 || rect.height < 8 || rect.bottom < 0 || rect.top > height) {
|
|
1893
|
-
state.live = false
|
|
1894
|
-
return
|
|
1895
|
-
}
|
|
1896
|
-
const style = getComputedStyle(state.row)
|
|
1897
|
-
const radius = parseFloat(style.borderTopLeftRadius) || 8
|
|
1898
|
-
const accent = (style.getPropertyValue('--dc-accent') || '').trim() || '#7aa4ff'
|
|
1899
|
-
const reach = 74
|
|
1900
|
-
context.save()
|
|
1901
|
-
context.beginPath()
|
|
1902
|
-
if (typeof context.roundRect === 'function') {
|
|
1903
|
-
context.roundRect(rect.left, rect.top, rect.width, rect.height, radius)
|
|
1904
|
-
} else {
|
|
1905
|
-
context.rect(rect.left, rect.top, rect.width, rect.height)
|
|
1906
|
-
}
|
|
1907
|
-
context.clip()
|
|
1908
|
-
context.fillStyle = accent
|
|
1909
|
-
if (showDots) {
|
|
1910
|
-
const startX = Math.floor(rect.left / 4) * 4 + 2
|
|
1911
|
-
const startY = Math.floor(rect.top / 4) * 4 + 2
|
|
1912
|
-
for (let y = startY; y < rect.bottom; y += 4) {
|
|
1913
|
-
for (let x = startX; x < rect.right; x += 4) {
|
|
1914
|
-
const dx = x - state.x
|
|
1915
|
-
const dy = y - state.y
|
|
1916
|
-
const distance = Math.sqrt(dx * dx + dy * dy)
|
|
1917
|
-
if (distance > reach) continue
|
|
1918
|
-
const alpha = Math.pow(1 - distance / reach, 1.35) * state.alpha * 0.72
|
|
1919
|
-
if (alpha < 0.02) continue
|
|
1920
|
-
context.globalAlpha = Math.min(1, alpha)
|
|
1921
|
-
context.beginPath()
|
|
1922
|
-
context.arc(x, y, 0.85, 0, Math.PI * 2)
|
|
1923
|
-
context.fill()
|
|
1924
|
-
}
|
|
1925
|
-
}
|
|
1926
|
-
}
|
|
1927
|
-
// A short whale-blue rail marks the hovered control — buttons only.
|
|
1928
|
-
if (state.rail && showRail) {
|
|
1929
|
-
const railWidth = 3
|
|
1930
|
-
const railInset = 5
|
|
1931
|
-
const railHeight = Math.max(6, rect.height - railInset * 2)
|
|
1932
|
-
const railTop = rect.top + (rect.height - railHeight) / 2
|
|
1933
|
-
context.globalAlpha = Math.min(1, state.alpha * 0.9)
|
|
1934
|
-
context.beginPath()
|
|
1935
|
-
if (typeof context.roundRect === 'function') {
|
|
1936
|
-
context.roundRect(rect.left + 2, railTop, railWidth, railHeight, 1.5)
|
|
1937
|
-
} else {
|
|
1938
|
-
context.rect(rect.left + 2, railTop, railWidth, railHeight)
|
|
1939
|
-
}
|
|
1940
|
-
context.fill()
|
|
1941
|
-
}
|
|
1942
|
-
context.restore()
|
|
1943
|
-
context.globalAlpha = 1
|
|
1944
|
-
const moving = state.dirty
|
|
1945
|
-
state.dirty = false
|
|
1946
|
-
if (motion.matches) {
|
|
1947
|
-
if (!state.inside) {
|
|
1948
|
-
context.clearRect(0, 0, width, height)
|
|
1949
|
-
state.alpha = 0
|
|
1950
|
-
}
|
|
1951
|
-
state.live = false
|
|
1952
|
-
return
|
|
1953
|
-
}
|
|
1954
|
-
if (state.inside && state.alpha >= 0.98 && !moving) {
|
|
1955
|
-
state.live = false
|
|
1956
|
-
return
|
|
1957
|
-
}
|
|
1958
|
-
if (state.inside || state.alpha >= 0.02) {
|
|
1959
|
-
state.frame = requestAnimationFrame(paint)
|
|
1960
|
-
} else {
|
|
1961
|
-
state.live = false
|
|
1962
|
-
}
|
|
1963
|
-
}
|
|
1964
|
-
|
|
1965
|
-
const wake = () => {
|
|
1966
|
-
if (stopped || state.live) return
|
|
1967
|
-
state.live = true
|
|
1968
|
-
if (state.frame === 0) state.frame = requestAnimationFrame(paint)
|
|
1969
|
-
}
|
|
1970
|
-
|
|
1971
|
-
const onMove = event => {
|
|
1972
|
-
const target = event.target instanceof Element
|
|
1973
|
-
? event.target.closest('button, a, [role="button"]')
|
|
1974
|
-
: null
|
|
1975
|
-
const scope = sidebarScope()
|
|
1976
|
-
const insideSidebar = target !== null
|
|
1977
|
-
&& scope !== null
|
|
1978
|
-
&& scope.contains(target)
|
|
1979
|
-
&& !target.closest('.dc-foot')
|
|
1980
|
-
if (!insideSidebar) {
|
|
1981
|
-
if (state.inside) {
|
|
1982
|
-
state.inside = false
|
|
1983
|
-
state.row = null
|
|
1984
|
-
wake()
|
|
1985
|
-
}
|
|
1986
|
-
return
|
|
1987
|
-
}
|
|
1988
|
-
state.row = target
|
|
1989
|
-
state.rail = target.matches('button')
|
|
1990
|
-
state.x = event.clientX
|
|
1991
|
-
state.y = event.clientY
|
|
1992
|
-
state.inside = true
|
|
1993
|
-
state.dirty = true
|
|
1994
|
-
wake()
|
|
1995
|
-
}
|
|
1996
|
-
|
|
1997
|
-
const onLeave = () => {
|
|
1998
|
-
if (!state.inside) return
|
|
1999
|
-
state.inside = false
|
|
2000
|
-
state.row = null
|
|
2001
|
-
wake()
|
|
2002
|
-
}
|
|
2003
|
-
|
|
2004
|
-
document.addEventListener('pointermove', onMove, { passive: true })
|
|
2005
|
-
document.addEventListener('pointerleave', onLeave)
|
|
2006
|
-
window.addEventListener('blur', onLeave)
|
|
2007
|
-
window.addEventListener('resize', wake)
|
|
2008
|
-
return () => {
|
|
2009
|
-
stopped = true
|
|
2010
|
-
document.removeEventListener('pointermove', onMove)
|
|
2011
|
-
document.removeEventListener('pointerleave', onLeave)
|
|
2012
|
-
window.removeEventListener('blur', onLeave)
|
|
2013
|
-
window.removeEventListener('resize', wake)
|
|
2014
|
-
if (state.frame !== 0) cancelAnimationFrame(state.frame)
|
|
2015
|
-
state.frame = 0
|
|
2016
|
-
state.live = false
|
|
2017
|
-
}
|
|
2018
|
-
}, [showDots, showRail])
|
|
2019
|
-
return showDots || showRail
|
|
2020
|
-
? h('canvas', { ref: canvasRef, className: 'dc-overlay', 'aria-hidden': 'true' })
|
|
2021
|
-
: null
|
|
2022
|
-
}
|
|
2023
|
-
|
|
2024
|
-
/**
|
|
2025
|
-
* Dot trail behind the composer caret.
|
|
2026
|
-
*
|
|
2027
|
-
* The caret itself is host-owned, so we only read its position (collapsed selection
|
|
2028
|
-
* range inside the active composer) and print a fading line of dots behind it on our
|
|
2029
|
-
* overlay canvas, clipped to the composer card. Dots never move once printed; they only
|
|
2030
|
-
* fade.
|
|
2031
|
-
*/
|
|
2032
|
-
function DcCaretTrail() {
|
|
2033
|
-
const canvasRef = React.useRef(null)
|
|
2034
|
-
React.useEffect(() => {
|
|
2035
|
-
const canvas = canvasRef.current
|
|
2036
|
-
if (canvas === null) return
|
|
2037
|
-
const context = canvas.getContext('2d')
|
|
2038
|
-
if (context === null) return
|
|
2039
|
-
const motion = matchMedia('(prefers-reduced-motion: reduce)')
|
|
2040
|
-
if (motion.matches) return undefined
|
|
2041
|
-
const trail = []
|
|
2042
|
-
const LIFE = 650
|
|
2043
|
-
const STEP = 3
|
|
2044
|
-
let stopped = false
|
|
2045
|
-
let frame = 0
|
|
2046
|
-
let last = null
|
|
2047
|
-
let trailCard = null
|
|
2048
|
-
let dpr = Math.min(2, devicePixelRatio || 1)
|
|
2049
|
-
|
|
2050
|
-
// A caret (or an IME composition) has no reliable box of its own, so every
|
|
2051
|
-
// measurement falls back to the text or element next to the insertion point.
|
|
2052
|
-
const rectAt = (container, offset) => {
|
|
2053
|
-
if (container === null) return null
|
|
2054
|
-
const range = document.createRange()
|
|
2055
|
-
try {
|
|
2056
|
-
range.setStart(container, offset)
|
|
2057
|
-
range.collapse(true)
|
|
2058
|
-
} catch (error) {
|
|
2059
|
-
return null
|
|
2060
|
-
}
|
|
2061
|
-
const collapsed = range.getBoundingClientRect()
|
|
2062
|
-
if (collapsed.height > 0 && (collapsed.left > 0 || collapsed.top > 0)) {
|
|
2063
|
-
return { left: collapsed.left, top: collapsed.top, height: collapsed.height }
|
|
2064
|
-
}
|
|
2065
|
-
const measure = (node, side) => {
|
|
2066
|
-
if (node === null) return null
|
|
2067
|
-
const inner = document.createRange()
|
|
2068
|
-
inner.selectNodeContents(node)
|
|
2069
|
-
const box = inner.getBoundingClientRect()
|
|
2070
|
-
if (box.height === 0) return null
|
|
2071
|
-
return { left: side === 'end' ? box.right : box.left, top: box.top, height: box.height }
|
|
2072
|
-
}
|
|
2073
|
-
if (container.nodeType === 3) {
|
|
2074
|
-
const text = container.textContent || ''
|
|
2075
|
-
if (offset > 0) {
|
|
2076
|
-
const inner = document.createRange()
|
|
2077
|
-
inner.setStart(container, offset - 1)
|
|
2078
|
-
inner.setEnd(container, offset)
|
|
2079
|
-
const box = inner.getBoundingClientRect()
|
|
2080
|
-
if (box.height > 0) return { left: box.right, top: box.top, height: box.height }
|
|
2081
|
-
}
|
|
2082
|
-
if (text.length > 0) {
|
|
2083
|
-
const inner = document.createRange()
|
|
2084
|
-
inner.setStart(container, 0)
|
|
2085
|
-
inner.setEnd(container, 1)
|
|
2086
|
-
const box = inner.getBoundingClientRect()
|
|
2087
|
-
if (box.height > 0) return { left: box.left, top: box.top, height: box.height }
|
|
2088
|
-
}
|
|
2089
|
-
return null
|
|
2090
|
-
}
|
|
2091
|
-
if (container.nodeType === 1) {
|
|
2092
|
-
const children = container.childNodes
|
|
2093
|
-
return measure(offset > 0 ? children[offset - 1] : null, 'end')
|
|
2094
|
-
|| measure(offset < children.length ? children[offset] : null, 'start')
|
|
2095
|
-
}
|
|
2096
|
-
return null
|
|
2097
|
-
}
|
|
2098
|
-
|
|
2099
|
-
const caretOf = () => {
|
|
2100
|
-
const active = document.activeElement
|
|
2101
|
-
if (active === null || typeof active.closest !== 'function') return null
|
|
2102
|
-
const card = active.closest('[data-composer-card]')
|
|
2103
|
-
if (card === null) return null
|
|
2104
|
-
const editable = active.isContentEditable
|
|
2105
|
-
? active
|
|
2106
|
-
: active.closest('[contenteditable], [role="textbox"], textarea')
|
|
2107
|
-
if (editable === null || !card.contains(editable)) return null
|
|
2108
|
-
const selection = window.getSelection()
|
|
2109
|
-
if (selection === null || selection.rangeCount === 0) return null
|
|
2110
|
-
// While an IME composes, the selection covers the composition text; the caret
|
|
2111
|
-
// sits at its focus end, so measure there instead of bailing out.
|
|
2112
|
-
const container = selection.isCollapsed ? selection.anchorNode : selection.focusNode
|
|
2113
|
-
const offset = selection.isCollapsed ? selection.anchorOffset : selection.focusOffset
|
|
2114
|
-
if (container === null) return null
|
|
2115
|
-
if (container !== active && !active.contains(container)) return null
|
|
2116
|
-
const rect = rectAt(container, offset)
|
|
2117
|
-
if (rect === null || rect.height === 0) return null
|
|
2118
|
-
return { x: rect.left, y: rect.top, height: rect.height, card }
|
|
2119
|
-
}
|
|
2120
|
-
|
|
2121
|
-
const push = (from, to, now) => {
|
|
2122
|
-
const deviceX = to.x - from.x
|
|
2123
|
-
const deviceY = to.y - from.y
|
|
2124
|
-
const distance = Math.sqrt(deviceX * deviceX + deviceY * deviceY)
|
|
2125
|
-
if (distance < 1.5) return
|
|
2126
|
-
// A line wrap or a jump to another spot is not a trail; only same-line motion is.
|
|
2127
|
-
if (distance > 90 || Math.abs(deviceY) > 6) return
|
|
2128
|
-
const topFrom = from.y
|
|
2129
|
-
const topTo = to.y
|
|
2130
|
-
const steps = Math.max(1, Math.min(40, Math.round(distance / STEP)))
|
|
2131
|
-
for (let index = 1; index <= steps; index += 1) {
|
|
2132
|
-
const t = index / steps
|
|
2133
|
-
trail.push({
|
|
2134
|
-
x: from.x + deviceX * t,
|
|
2135
|
-
y: topFrom + (topTo - topFrom) * t,
|
|
2136
|
-
height: to.height || 18,
|
|
2137
|
-
born: now - (steps - index) * 6,
|
|
2138
|
-
})
|
|
2139
|
-
}
|
|
2140
|
-
while (trail.length > 220) trail.shift()
|
|
2141
|
-
}
|
|
2142
|
-
|
|
2143
|
-
const sample = () => {
|
|
2144
|
-
const caret = caretOf()
|
|
2145
|
-
if (caret === null) {
|
|
2146
|
-
last = null
|
|
2147
|
-
trailCard = null
|
|
2148
|
-
return
|
|
2149
|
-
}
|
|
2150
|
-
trailCard = caret.card
|
|
2151
|
-
const now = performance.now()
|
|
2152
|
-
if (last !== null) {
|
|
2153
|
-
const sameCard = last.card === caret.card
|
|
2154
|
-
if (sameCard) push({ x: last.x, y: last.y, height: last.height }, caret, now)
|
|
2155
|
-
}
|
|
2156
|
-
last = { x: caret.x, y: caret.y, height: caret.height, card: caret.card }
|
|
2157
|
-
wake()
|
|
2158
|
-
}
|
|
2159
|
-
|
|
2160
|
-
const paint = () => {
|
|
2161
|
-
frame = 0
|
|
2162
|
-
if (stopped) return
|
|
2163
|
-
const width = innerWidth
|
|
2164
|
-
const height = innerHeight
|
|
2165
|
-
if (canvas.width !== Math.round(width * dpr) || canvas.height !== Math.round(height * dpr)) {
|
|
2166
|
-
canvas.width = Math.round(width * dpr)
|
|
2167
|
-
canvas.height = Math.round(height * dpr)
|
|
2168
|
-
}
|
|
2169
|
-
context.setTransform(dpr, 0, 0, dpr, 0, 0)
|
|
2170
|
-
context.clearRect(0, 0, width, height)
|
|
2171
|
-
const now = performance.now()
|
|
2172
|
-
while (trail.length > 0 && now - trail[0].born > LIFE) trail.shift()
|
|
2173
|
-
if (trail.length === 0) {
|
|
2174
|
-
trailCard = null
|
|
2175
|
-
return
|
|
2176
|
-
}
|
|
2177
|
-
const card = trailCard
|
|
2178
|
-
let clip = null
|
|
2179
|
-
let radius = 12
|
|
2180
|
-
if (card !== null && card.isConnected) {
|
|
2181
|
-
clip = card.getBoundingClientRect()
|
|
2182
|
-
const style = getComputedStyle(card)
|
|
2183
|
-
radius = parseFloat(style.borderTopLeftRadius) || 12
|
|
2184
|
-
}
|
|
2185
|
-
const accent = (getComputedStyle(document.body).getPropertyValue('--dc-accent') || '').trim() || '#7aa4ff'
|
|
2186
|
-
context.save()
|
|
2187
|
-
if (clip !== null) {
|
|
2188
|
-
context.beginPath()
|
|
2189
|
-
if (typeof context.roundRect === 'function') {
|
|
2190
|
-
context.roundRect(clip.left, clip.top, clip.width, clip.height, radius)
|
|
2191
|
-
} else {
|
|
2192
|
-
context.rect(clip.left, clip.top, clip.width, clip.height)
|
|
2193
|
-
}
|
|
2194
|
-
context.clip()
|
|
2195
|
-
}
|
|
2196
|
-
// Collect every dot once, then paint a soft halo pass and a crisp pass in
|
|
2197
|
-
// batches: per-dot fills with shadows would crawl.
|
|
2198
|
-
const dots = []
|
|
2199
|
-
for (const point of trail) {
|
|
2200
|
-
const age = (now - point.born) / LIFE
|
|
2201
|
-
if (age >= 1) continue
|
|
2202
|
-
const alpha = Math.pow(1 - age, 1.4) * 0.85
|
|
2203
|
-
if (alpha < 0.02) continue
|
|
2204
|
-
for (let offset = 1; offset < point.height - 0.5; offset += 3) {
|
|
2205
|
-
dots.push(point.x, point.y + offset, alpha)
|
|
2206
|
-
}
|
|
2207
|
-
}
|
|
2208
|
-
context.fillStyle = accent
|
|
2209
|
-
const passes = [
|
|
2210
|
-
{ radius: 2.4, scale: 0.3 },
|
|
2211
|
-
{ radius: 1.05, scale: 1 },
|
|
2212
|
-
]
|
|
2213
|
-
for (const pass of passes) {
|
|
2214
|
-
const buckets = new Map()
|
|
2215
|
-
for (let index = 0; index < dots.length; index += 3) {
|
|
2216
|
-
const alpha = dots[index + 2] * pass.scale
|
|
2217
|
-
if (alpha < 0.02) continue
|
|
2218
|
-
const level = Math.min(10, Math.max(1, Math.round(alpha * 10)))
|
|
2219
|
-
let bucket = buckets.get(level)
|
|
2220
|
-
if (bucket === undefined) {
|
|
2221
|
-
bucket = new Path2D()
|
|
2222
|
-
buckets.set(level, bucket)
|
|
2223
|
-
}
|
|
2224
|
-
bucket.moveTo(dots[index] + pass.radius, dots[index + 1])
|
|
2225
|
-
bucket.arc(dots[index], dots[index + 1], pass.radius, 0, Math.PI * 2)
|
|
2226
|
-
}
|
|
2227
|
-
for (const [level, path] of buckets) {
|
|
2228
|
-
context.globalAlpha = level / 10
|
|
2229
|
-
context.fill(path)
|
|
2230
|
-
}
|
|
2231
|
-
}
|
|
2232
|
-
context.restore()
|
|
2233
|
-
context.globalAlpha = 1
|
|
2234
|
-
frame = requestAnimationFrame(paint)
|
|
2235
|
-
}
|
|
2236
|
-
|
|
2237
|
-
const wake = () => {
|
|
2238
|
-
if (stopped || frame !== 0) return
|
|
2239
|
-
frame = requestAnimationFrame(paint)
|
|
2240
|
-
}
|
|
2241
|
-
|
|
2242
|
-
window.__dcCaretProbe = () => {
|
|
2243
|
-
const caret = caretOf()
|
|
2244
|
-
return caret === null
|
|
2245
|
-
? { ok: false, active: document.activeElement ? document.activeElement.tagName : null }
|
|
2246
|
-
: { ok: true, x: Math.round(caret.x), y: Math.round(caret.y), height: Math.round(caret.height) }
|
|
2247
|
-
}
|
|
2248
|
-
const onActivity = () => sample()
|
|
2249
|
-
document.addEventListener('selectionchange', onActivity)
|
|
2250
|
-
document.addEventListener('input', onActivity, true)
|
|
2251
|
-
document.addEventListener('beforeinput', onActivity, true)
|
|
2252
|
-
document.addEventListener('compositionupdate', onActivity, true)
|
|
2253
|
-
document.addEventListener('keyup', onActivity, true)
|
|
2254
|
-
document.addEventListener('click', onActivity, true)
|
|
2255
|
-
document.addEventListener('pointerup', onActivity, true)
|
|
2256
|
-
window.addEventListener('resize', wake)
|
|
2257
|
-
return () => {
|
|
2258
|
-
stopped = true
|
|
2259
|
-
document.removeEventListener('selectionchange', onActivity)
|
|
2260
|
-
document.removeEventListener('input', onActivity, true)
|
|
2261
|
-
document.removeEventListener('beforeinput', onActivity, true)
|
|
2262
|
-
document.removeEventListener('compositionupdate', onActivity, true)
|
|
2263
|
-
document.removeEventListener('keyup', onActivity, true)
|
|
2264
|
-
document.removeEventListener('click', onActivity, true)
|
|
2265
|
-
document.removeEventListener('pointerup', onActivity, true)
|
|
2266
|
-
window.removeEventListener('resize', wake)
|
|
2267
|
-
if (frame !== 0) cancelAnimationFrame(frame)
|
|
2268
|
-
frame = 0
|
|
2269
|
-
trail.length = 0
|
|
2270
|
-
}
|
|
2271
|
-
}, [])
|
|
2272
|
-
return h('canvas', {
|
|
2273
|
-
ref: canvasRef,
|
|
2274
|
-
className: 'dc-overlay dc-caret-layer',
|
|
2275
|
-
'aria-hidden': 'true',
|
|
2276
|
-
style: { zIndex: 2147483000 },
|
|
2277
|
-
})
|
|
2278
|
-
}
|
|
2279
|
-
|
|
2280
|
-
/**
|
|
2281
|
-
* Reasoning effort badge, done entirely in CSS.
|
|
2282
|
-
*
|
|
2283
|
-
* We only read the effort label and stamp two attributes on the composer card; the
|
|
2284
|
-
* unfolding dot field and the dot-printed level name are pseudo-elements, so there is no
|
|
2285
|
-
* canvas geometry to measure and nothing to drift when the layout changes.
|
|
2286
|
-
*/
|
|
2287
|
-
const DC_EFFORT_OFF = /^(off|none|disabled?|无|关闭)$/i
|
|
2288
|
-
|
|
2289
|
-
function dcEffortLabel() {
|
|
2290
|
-
const card = document.querySelector('[data-composer-card]')
|
|
2291
|
-
if (card === null) return null
|
|
2292
|
-
const node = card.querySelector('[class*="_triggerEffort"]')
|
|
2293
|
-
if (node === null) return null
|
|
2294
|
-
const text = (node.textContent || '').trim()
|
|
2295
|
-
return text === '' ? null : text
|
|
2296
|
-
}
|
|
2297
|
-
|
|
2298
|
-
function dcPaintEffort(label) {
|
|
2299
|
-
const card = document.querySelector('[data-composer-card]')
|
|
2300
|
-
if (card === null) return
|
|
2301
|
-
if (label === null) {
|
|
2302
|
-
card.removeAttribute('data-dc-effort')
|
|
2303
|
-
card.classList.remove('dc-effort-on', 'dc-effort-max')
|
|
2304
|
-
return
|
|
2305
|
-
}
|
|
2306
|
-
const word = label.toUpperCase()
|
|
2307
|
-
const changed = card.getAttribute('data-dc-effort') !== word
|
|
2308
|
-
card.setAttribute('data-dc-effort', word)
|
|
2309
|
-
card.classList.toggle('dc-effort-max', word === 'MAX')
|
|
2310
|
-
if (changed) {
|
|
2311
|
-
// Toggle the class off and on so the CSS animation replays for the new word.
|
|
2312
|
-
card.classList.remove('dc-effort-on')
|
|
2313
|
-
void card.offsetWidth
|
|
2314
|
-
card.classList.add('dc-effort-on')
|
|
2315
|
-
} else if (!card.classList.contains('dc-effort-on')) {
|
|
2316
|
-
card.classList.add('dc-effort-on')
|
|
2317
|
-
}
|
|
2318
|
-
}
|
|
2319
|
-
|
|
2320
|
-
/**
|
|
2321
|
-
* Startup splash: the dot wordmark over the boot screen.
|
|
2322
|
-
*
|
|
2323
|
-
* The whole animation is CSS transform/opacity so the compositor drives it: no canvas,
|
|
2324
|
-
* no per-frame JavaScript while the app is still booting.
|
|
2325
|
-
*/
|
|
2326
|
-
function dcPlaySplash() {
|
|
2327
|
-
if (window.__dcSplashPlayed === true) return
|
|
2328
|
-
window.__dcSplashPlayed = true
|
|
2329
|
-
try {
|
|
2330
|
-
if (typeof document === 'undefined' || document.body === null) return
|
|
2331
|
-
if (matchMedia('(prefers-reduced-motion: reduce)').matches) return
|
|
2332
|
-
const layer = document.createElement('div')
|
|
2333
|
-
layer.className = 'dc-splash'
|
|
2334
|
-
layer.setAttribute('aria-hidden', 'true')
|
|
2335
|
-
const grid = document.createElement('div')
|
|
2336
|
-
grid.className = 'dc-splash-grid'
|
|
2337
|
-
const ring = document.createElement('div')
|
|
2338
|
-
ring.className = 'dc-splash-ring'
|
|
2339
|
-
const mark = document.createElement('div')
|
|
2340
|
-
mark.className = 'dc-splash-mark'
|
|
2341
|
-
const deepseek = document.createElement('span')
|
|
2342
|
-
deepseek.className = 'dc-splash-line dc-splash-deepseek'
|
|
2343
|
-
deepseek.textContent = 'deepseek'
|
|
2344
|
-
const harness = document.createElement('span')
|
|
2345
|
-
harness.className = 'dc-splash-line dc-splash-harness'
|
|
2346
|
-
harness.textContent = 'harness'
|
|
2347
|
-
const sheen = document.createElement('div')
|
|
2348
|
-
sheen.className = 'dc-splash-sheen'
|
|
2349
|
-
mark.append(deepseek, harness, sheen)
|
|
2350
|
-
const veil = document.createElement('div')
|
|
2351
|
-
veil.className = 'dc-splash-veil'
|
|
2352
|
-
layer.append(grid, ring, mark, veil)
|
|
2353
|
-
document.body.appendChild(layer)
|
|
2354
|
-
const remove = () => {
|
|
2355
|
-
if (layer.isConnected) layer.remove()
|
|
2356
|
-
}
|
|
2357
|
-
layer.addEventListener('animationend', event => {
|
|
2358
|
-
if (event.animationName === 'dc-splash-out') remove()
|
|
2359
|
-
})
|
|
2360
|
-
setTimeout(remove, 3200)
|
|
2361
|
-
} catch (error) {
|
|
2362
|
-
console.warn('[dsh-fish-ui] splash failed', error)
|
|
2363
|
-
}
|
|
2364
|
-
}
|
|
2365
|
-
|
|
2366
|
-
/* fish runtime:start */
|
|
2367
|
-
// Profile settings and token layers; embedded into client.js by build-runtime.mjs.
|
|
2368
|
-
const DC_SETTINGS_KEY = 'dsh-fish-ui:settings'
|
|
2369
|
-
const DC_DEFAULT_SETTINGS = Object.freeze(Object.fromEntries([
|
|
2370
|
-
'hero', 'field', 'wave', 'ripple', 'thinkingSphere', 'thinkingLabel',
|
|
2371
|
-
'glass', 'effortBadge', 'sidebarDots', 'sidebarRail', 'bold', 'focusRing', 'diff',
|
|
2372
|
-
'reading', 'code', 'fishFont', 'fishGlow', 'fishMotion', 'fishCode',
|
|
2373
|
-
'catppuccin', 'aurora', 'cursor', 'textMotion',
|
|
2374
|
-
].map(key => [key, true])))
|
|
2375
|
-
const DC_OFF_CLASS = Object.freeze(Object.fromEntries(Object.keys(DC_DEFAULT_SETTINGS)
|
|
2376
|
-
.map(key => [key, 'dc-off-' + key.toLowerCase()])))
|
|
2377
|
-
const dcSettingsListeners = new Set()
|
|
2378
|
-
let dcSettings = DC_DEFAULT_SETTINGS
|
|
2379
|
-
let dcSnapshot = { values: dcSettings, status: 'loading', writable: false, pending: false, error: '' }
|
|
2380
|
-
let dcWrite = null
|
|
2381
|
-
let dcSettingsOwner = null
|
|
2382
|
-
let dcTheme = null
|
|
2383
|
-
let dcThemeLayers = new Map()
|
|
2384
|
-
let dcMounted = false
|
|
2385
|
-
|
|
2386
|
-
const dcReadLegacy = () => {
|
|
2387
|
-
try {
|
|
2388
|
-
const parsed = JSON.parse(window.localStorage.getItem(DC_SETTINGS_KEY))
|
|
2389
|
-
if (parsed === null || typeof parsed !== 'object' || Array.isArray(parsed)) return null
|
|
2390
|
-
const values = Object.fromEntries(Object.keys(DC_DEFAULT_SETTINGS)
|
|
2391
|
-
.filter(key => typeof parsed[key] === 'boolean').map(key => [key, parsed[key]]))
|
|
2392
|
-
return Object.keys(values).length ? values : null
|
|
2393
|
-
} catch { return null }
|
|
2394
|
-
}
|
|
2395
|
-
const dcLegacy = dcReadLegacy()
|
|
2396
|
-
dcSettings = Object.freeze({ ...DC_DEFAULT_SETTINGS, ...dcLegacy })
|
|
2397
|
-
dcSnapshot = { ...dcSnapshot, values: dcSettings }
|
|
2398
|
-
const dcSubscribeSettings = listener => {
|
|
2399
|
-
dcSettingsListeners.add(listener)
|
|
2400
|
-
return () => dcSettingsListeners.delete(listener)
|
|
2401
|
-
}
|
|
2402
|
-
const dcGetSnapshot = () => dcSnapshot
|
|
2403
|
-
const useDcSettings = () => React.useSyncExternalStore(dcSubscribeSettings, dcGetSnapshot, dcGetSnapshot)
|
|
2404
|
-
const dcModes = (light, dark) => ({ light, dark })
|
|
2405
|
-
const DC_CODE = {
|
|
2406
|
-
'--shiki-token-constant': dcModes('#2562A5', '#92BEF4'),
|
|
2407
|
-
'--shiki-token-string': dcModes('#326B55', '#A5CCB8'),
|
|
2408
|
-
'--shiki-token-comment': dcModes('#657287', '#8E9BAF'),
|
|
2409
|
-
'--shiki-token-keyword': dcModes('#765795', '#C0ACD8'),
|
|
2410
|
-
'--shiki-token-parameter': dcModes('#956032', '#D8B18A'),
|
|
2411
|
-
'--shiki-token-function': dcModes('#406A9D', '#A7C8F2'),
|
|
2412
|
-
'--shiki-token-string-expression': dcModes('#326B55', '#A5CCB8'),
|
|
2413
|
-
'--shiki-token-punctuation': dcModes('#546377', '#A6B2C4'),
|
|
2414
|
-
'--shiki-token-link': dcModes('#3269B7', '#8AB6FA'),
|
|
2415
|
-
}
|
|
2416
|
-
const DC_DIFF = {
|
|
2417
|
-
'--dsw-alias-file-diff-added-bg': dcModes('rgb(58 117 196 / 9%)', 'rgb(122 170 255 / 12%)'),
|
|
2418
|
-
'--dsw-alias-file-diff-added-gutter': dcModes('rgb(58 117 196 / 6%)', 'rgb(122 170 255 / 7%)'),
|
|
2419
|
-
'--dsw-alias-file-diff-added-marker': dcModes('#3269B7', '#8AB6FA'),
|
|
2420
|
-
'--dsw-alias-file-diff-deleted-bg': dcModes('rgb(164 97 83 / 9%)', 'rgb(213 156 139 / 10%)'),
|
|
2421
|
-
'--dsw-alias-file-diff-deleted-gutter': dcModes('rgb(164 97 83 / 6%)', 'rgb(213 156 139 / 6%)'),
|
|
2422
|
-
'--dsw-alias-file-diff-deleted-marker': dcModes('#995C50', '#D4A18F'),
|
|
2423
|
-
'--dsw-alias-code-diff-added': dcModes('rgb(58 117 196 / 10%)', 'rgb(122 170 255 / 13%)'),
|
|
2424
|
-
'--dsw-alias-code-diff-deleted': dcModes('rgb(164 97 83 / 10%)', 'rgb(213 156 139 / 11%)'),
|
|
2425
|
-
}
|
|
2426
|
-
const DC_IDENTITY = {
|
|
2427
|
-
'--dc-accent': dcModes('#3269B7', '#8AB6FA'),
|
|
2428
|
-
'--dc-focus': dcModes('rgb(50 105 183 / 18%)', 'rgb(138 182 250 / 18%)'),
|
|
2429
|
-
}
|
|
2430
|
-
const DC_CAT = {
|
|
2431
|
-
'--dsw-alias-bg-base': dcModes('#eff1f5', '#1e1e2e'),
|
|
2432
|
-
'--dsw-alias-bg-layer-1': dcModes('#e6e9ef', '#181825'),
|
|
2433
|
-
'--dsw-alias-bg-layer-2': dcModes('#dce0e8', '#11111b'),
|
|
2434
|
-
'--dsw-alias-bg-overlay': dcModes('#eff1f5', '#181825'),
|
|
2435
|
-
'--dsw-alias-border-l1': dcModes('#bcc0cc', '#313244'),
|
|
2436
|
-
'--dsw-alias-border-l2': dcModes('#acb0be', '#45475a'),
|
|
2437
|
-
'--dsw-alias-label-primary': dcModes('#4c4f69', '#cdd6f4'),
|
|
2438
|
-
'--dsw-alias-label-secondary': dcModes('#6c6f85', '#a6adc8'),
|
|
2439
|
-
'--dsw-specific-sidebar-fill': dcModes('#e6e9ef', '#181825'),
|
|
2440
|
-
'--dsw-alias-brand-primary': dcModes('#1e66f5', '#89b4fa'),
|
|
2441
|
-
'--dsw-alias-state-success-primary': dcModes('#40a02b', '#a6e3a1'),
|
|
2442
|
-
'--dsw-alias-state-warn-primary': dcModes('#df8e1d', '#f9e2af'),
|
|
2443
|
-
'--dsw-alias-state-error-primary': dcModes('#d20f39', '#f38ba8'),
|
|
2444
|
-
'--dsw-alias-state-idle-primary': dcModes('#8c8fa1', '#7f849c'),
|
|
2445
|
-
'--dc-accent': dcModes('#8839ef', '#cba6f7'),
|
|
2446
|
-
'--dc-focus': dcModes('rgb(136 57 239 / 18%)', 'rgb(203 166 247 / 18%)'),
|
|
2447
|
-
}
|
|
2448
|
-
function dcSyncTheme() {
|
|
2449
|
-
if (dcTheme === null) return
|
|
2450
|
-
for (const [name, enabled, tokens] of [
|
|
2451
|
-
['identity', true, DC_IDENTITY],
|
|
2452
|
-
['catppuccin', dcSettings.catppuccin, DC_CAT],
|
|
2453
|
-
['code', dcSettings.code, DC_CODE], ['diff', dcSettings.diff, DC_DIFF],
|
|
2454
|
-
]) {
|
|
2455
|
-
if (enabled && !dcThemeLayers.has(name)) {
|
|
2456
|
-
dcThemeLayers.set(name, dcTheme.overrideTokens('dsh-fish-ui:' + name, tokens))
|
|
2457
|
-
} else if (!enabled && dcThemeLayers.has(name)) {
|
|
2458
|
-
dcThemeLayers.get(name)()
|
|
2459
|
-
dcThemeLayers.delete(name)
|
|
2460
|
-
}
|
|
2461
|
-
}
|
|
2462
|
-
}
|
|
2463
|
-
function dcApplySettings() {
|
|
2464
|
-
if (!dcMounted) return
|
|
2465
|
-
for (const [key, className] of Object.entries(DC_OFF_CLASS)) {
|
|
2466
|
-
document.documentElement.classList.toggle(className, dcSettings[key] === false)
|
|
2467
|
-
}
|
|
2468
|
-
dcSyncTheme()
|
|
2469
|
-
}
|
|
2470
|
-
function dcPublish(patch) {
|
|
2471
|
-
dcSnapshot = Object.freeze({ ...dcSnapshot, ...patch })
|
|
2472
|
-
dcSettings = dcSnapshot.values
|
|
2473
|
-
dcApplySettings()
|
|
2474
|
-
dcSettingsListeners.forEach(listener => listener())
|
|
2475
|
-
}
|
|
2476
|
-
function dcConnectSettings(scope) {
|
|
2477
|
-
// This is the Host patch entry id; the bundle-config key below is the package name.
|
|
2478
|
-
const form = scope.configForms.get('dsh-fish-ui')
|
|
2479
|
-
let active = true
|
|
2480
|
-
let migrating = false
|
|
2481
|
-
let migrationTried = false
|
|
2482
|
-
const adopt = () => {
|
|
2483
|
-
if (!active) return
|
|
2484
|
-
const snapshot = form.getSnapshot()
|
|
2485
|
-
if (snapshot.status !== 'ready' || snapshot.value === undefined) {
|
|
2486
|
-
dcPublish({ status: snapshot.status, writable: false })
|
|
2487
|
-
return
|
|
2488
|
-
}
|
|
2489
|
-
const ownsValues = Object.keys(DC_DEFAULT_SETTINGS).some(key =>
|
|
2490
|
-
snapshot.user !== null && typeof snapshot.user === 'object' && Object.hasOwn(snapshot.user, key))
|
|
2491
|
-
const legacyKeys = dcLegacy === null ? []
|
|
2492
|
-
: Object.keys(dcLegacy).filter(key => Object.hasOwn(DC_DEFAULT_SETTINGS, key))
|
|
2493
|
-
if (!migrationTried && legacyKeys.length > 0 && !ownsValues && !snapshot.value.settingsMigrated && snapshot.writable) {
|
|
2494
|
-
migrationTried = true
|
|
2495
|
-
migrating = true
|
|
2496
|
-
dcPublish({ status: 'ready', writable: true, pending: true, error: '' })
|
|
2497
|
-
// Only carry keys the current schema still owns: a legacy blob may mention
|
|
2498
|
-
// preferences that were removed, and one unknown path rejects the whole write.
|
|
2499
|
-
const ops = Object.entries(dcLegacy)
|
|
2500
|
-
.filter(([key]) => Object.hasOwn(DC_DEFAULT_SETTINGS, key))
|
|
2501
|
-
.map(([key, value]) => ({ op: 'set', path: [key], value }))
|
|
2502
|
-
ops.push({ op: 'set', path: ['settingsMigrated'], value: true })
|
|
2503
|
-
// Fence the exact snapshot that established the namespace was empty.
|
|
2504
|
-
const migrate = async () => form.mutate(ops, snapshot.revision)
|
|
2505
|
-
migrate().then(ok => {
|
|
2506
|
-
if (!active) return
|
|
2507
|
-
migrating = false
|
|
2508
|
-
dcPublish({ pending: false, error: ok ? '' : 'conflict' })
|
|
2509
|
-
adopt()
|
|
2510
|
-
}, () => {
|
|
2511
|
-
if (!active) return
|
|
2512
|
-
migrating = false
|
|
2513
|
-
dcPublish({ pending: false, error: 'save' })
|
|
2514
|
-
adopt()
|
|
2515
|
-
})
|
|
2516
|
-
// Keep the legacy key read-only: other profiles may share this origin.
|
|
2517
|
-
return
|
|
2518
|
-
}
|
|
2519
|
-
if (migrating) return
|
|
2520
|
-
const values = Object.freeze(Object.fromEntries(Object.entries(DC_DEFAULT_SETTINGS)
|
|
2521
|
-
.map(([key, fallback]) => [key, typeof snapshot.value[key] === 'boolean' ? snapshot.value[key] : fallback])))
|
|
2522
|
-
dcPublish({ values, status: 'ready', writable: snapshot.writable })
|
|
2523
|
-
}
|
|
2524
|
-
const write = async values => {
|
|
2525
|
-
if (!active || dcSnapshot.pending || dcSnapshot.status !== 'ready' || !dcSnapshot.writable) return
|
|
2526
|
-
dcPublish({ pending: true, error: '' })
|
|
2527
|
-
try {
|
|
2528
|
-
const ops = Object.entries(values).filter(([key, value]) => Object.hasOwn(DC_DEFAULT_SETTINGS, key) && typeof value === 'boolean')
|
|
2529
|
-
.map(([key, value]) => ({ op: 'set', path: [key], value }))
|
|
2530
|
-
ops.push({ op: 'set', path: ['settingsMigrated'], value: true })
|
|
2531
|
-
const ok = await form.mutate(ops, form.getSnapshot().revision)
|
|
2532
|
-
if (active) dcPublish({ error: ok ? '' : 'conflict' })
|
|
2533
|
-
} catch {
|
|
2534
|
-
if (active) dcPublish({ error: 'save' })
|
|
2535
|
-
} finally {
|
|
2536
|
-
if (active) { dcPublish({ pending: false }); adopt() }
|
|
2537
|
-
}
|
|
2538
|
-
}
|
|
2539
|
-
scope.effect(() => {
|
|
2540
|
-
dcWrite = write
|
|
2541
|
-
dcSettingsOwner = write
|
|
2542
|
-
const unsubscribe = form.subscribe(adopt)
|
|
2543
|
-
adopt()
|
|
2544
|
-
return () => {
|
|
2545
|
-
active = false
|
|
2546
|
-
unsubscribe()
|
|
2547
|
-
if (dcWrite === write) dcWrite = null
|
|
2548
|
-
if (dcSettingsOwner === write) {
|
|
2549
|
-
dcSettingsOwner = null
|
|
2550
|
-
dcPublish({ status: 'unavailable', writable: false, pending: false })
|
|
2551
|
-
}
|
|
2552
|
-
}
|
|
2553
|
-
}, 'dsh-fish-ui: Host preferences')
|
|
2554
|
-
}
|
|
2555
|
-
const dcSetSetting = (key, value) => dcWrite?.({ [key]: value })
|
|
2556
|
-
|
|
2557
|
-
class DcBoundary extends React.Component {
|
|
2558
|
-
state = { failed: false }
|
|
2559
|
-
static getDerivedStateFromError() { return { failed: true } }
|
|
2560
|
-
componentDidCatch(error) { console.error('[dsh-fish-ui] enhancement failed', error) }
|
|
2561
|
-
render() { return this.state.failed ? (this.props.fallback ?? null) : this.props.children }
|
|
2562
|
-
}
|
|
2563
|
-
const dcSafe = Component => function DeepFishSafeSlot(props) {
|
|
2564
|
-
return h(DcBoundary, { fallback: props.children }, h(Component, props))
|
|
2565
|
-
}
|
|
2566
|
-
|
|
2567
|
-
/* fish runtime:end */
|
|
2568
|
-
|
|
2569
|
-
/** Settings copy follows the app language (Chinese unless the UI is English). */
|
|
2570
|
-
const dcUsesChinese = () => {
|
|
2571
|
-
const lang = (document.documentElement.lang || navigator.language || '').toLowerCase()
|
|
2572
|
-
return lang.startsWith('zh')
|
|
2573
|
-
}
|
|
2574
|
-
const DC_COPY = {
|
|
2575
|
-
zh: {
|
|
2576
|
-
lead: '\u8fd9\u91cc\u7684\u5f00\u5173\u7acb\u5373\u751f\u6548\uff0c\u5e76\u6309\u914d\u7f6e\u6587\u4ef6\u8bb0\u4f4f\u3002',
|
|
2577
|
-
groups: {
|
|
2578
|
-
hero: '\u6b22\u8fce\u9875',
|
|
2579
|
-
thinking: '\u601d\u8003\u4e2d',
|
|
2580
|
-
composer: '\u8f93\u5165\u6846',
|
|
2581
|
-
accents: '\u5f3a\u8c03\u8272',
|
|
2582
|
-
sidebar: '侧边栏',
|
|
2583
|
-
},
|
|
2584
|
-
items: {
|
|
2585
|
-
hero: ['\u70b9\u9635\u4eba\u50cf\u4e0e\u5b57\u6807', '\u7a7a\u767d\u6b22\u8fce\u9875\u4e0a\u7684\u7acb\u7ed8\u548c\u5b57\u6807'],
|
|
2586
|
-
field: ['\u80cc\u666f\u70b9\u9635', '\u94fa\u6ee1\u6574\u9875\u7684\u6de1\u70b9\u9635'],
|
|
2587
|
-
wave: ['\u5e95\u90e8\u6ce2\u6d6a', '\u9875\u9762\u5e95\u90e8\u7f13\u6162\u6d41\u52a8\u7684\u660e\u6697\u6ce2'],
|
|
2588
|
-
ripple: ['\u6307\u9488\u6d9f\u6f2a', '\u9f20\u6807\u5212\u8fc7\u70b9\u9635\u65f6\u8361\u5f00\u7684\u5149\u73af'],
|
|
2589
|
-
thinkingSphere: ['\u70b9\u9635\u7403', '\u601d\u8003\u65f6\u65cb\u8f6c\u7684\u5c0f\u7403'],
|
|
2590
|
-
thinkingLabel: ['英文思考文案', '把状态行换成 “Deep thinking for 12s. . .”'],
|
|
2591
|
-
glass: ['\u78e8\u7802\u73bb\u7483', '\u4f1a\u8bdd\u9875\u8f93\u5165\u6846\u7684\u534a\u900f\u660e\u6548\u679c'],
|
|
2592
|
-
stats: ['\u7528\u91cf\u8bfb\u6570', '\u5728\u53d1\u9001\u6309\u94ae\u6392\u663e\u793a\u4e0a\u4e0b\u6587\u4e0e Token \u7528\u91cf'],
|
|
2593
|
-
bold: ['\u9cb8\u9c7c\u84dd\u52a0\u7c97', '\u804a\u5929\u91cc\u7684\u52a0\u7c97\u6587\u5b57\u53d8\u6210\u9cb8\u9c7c\u84dd'],
|
|
2594
|
-
focusRing: ['\u805a\u7126\u63cf\u8fb9', '\u8f93\u5165\u6846\u805a\u7126\u65f6\u7684\u67d4\u5149\u63cf\u8fb9'],
|
|
2595
|
-
diff: ['diff \u6362\u84dd', '\u65b0\u589e / \u5220\u9664\u884c\u6539\u6210\u84dd\u8272\u65cf'],
|
|
2596
|
-
},
|
|
2597
|
-
reset: '\u6062\u590d\u9ed8\u8ba4',
|
|
2598
|
-
close: '\u5173\u95ed',
|
|
2599
|
-
dialog: 'Deep Fish UI \u8bbe\u7f6e',
|
|
2600
|
-
button: 'Deep Fish UI \u8bbe\u7f6e',
|
|
2601
|
-
},
|
|
2602
|
-
en: {
|
|
2603
|
-
lead: 'Everything here applies immediately and is remembered per profile.',
|
|
2604
|
-
groups: { hero: 'Welcome page', thinking: 'Thinking', composer: 'Composer', accents: 'Accents', sidebar: 'Sidebar' },
|
|
2605
|
-
items: {
|
|
2606
|
-
hero: ['Dot artwork', 'The portrait and the wordmark on the blank home'],
|
|
2607
|
-
field: ['Dot field', 'The faint lattice behind everything'],
|
|
2608
|
-
wave: ['Bottom wave', 'The slow brightness wave along the bottom edge'],
|
|
2609
|
-
ripple: ['Pointer ripples', 'Light rings where the pointer crosses the field'],
|
|
2610
|
-
thinkingSphere: ['Dot sphere', 'The rotating point-sphere beside the live status'],
|
|
2611
|
-
thinkingLabel: ['English status label', 'Replace the status row with “Deep thinking for 12s. . .”'],
|
|
2612
|
-
glass: ['Frosted glass', 'Translucent input card on session pages'],
|
|
2613
|
-
bold: ['Whale-blue bold', 'Bold runs in chat prose take the accent colour'],
|
|
2614
|
-
focusRing: ['Focus ring', 'The soft ring while the composer has focus'],
|
|
2615
|
-
diff: ['Re-inked diffs', 'Added and removed lines in the blue family'],
|
|
2616
|
-
},
|
|
2617
|
-
reset: 'Reset to defaults',
|
|
2618
|
-
close: 'Close',
|
|
2619
|
-
dialog: 'Deep Fish UI settings',
|
|
2620
|
-
button: 'Deep Fish UI settings',
|
|
2621
|
-
},
|
|
2622
|
-
}
|
|
2623
|
-
|
|
2624
|
-
Object.assign(DC_COPY.zh.items, {
|
|
2625
|
-
reading: ['阅读排版', '舒展段落、标题与引用,保留你的字号'],
|
|
2626
|
-
code: ['代码配色', '低饱和语法颜色,保持代码层次'],
|
|
2627
|
-
effortBadge: ['推理等级动画', '输入框里用点阵显示当前推理等级'],
|
|
2628
|
-
sidebarDots: ['悬停点阵', '鼠标悬停在侧边栏按钮上时亮起点阵'],
|
|
2629
|
-
sidebarRail: ['蓝色竖线', '在悬停按钮左侧显示鲸鱼蓝竖线'],
|
|
2630
|
-
thinkingLabel: ['英文思考文案', '把状态行换成 “Deep thinking for 12s. . .”'],
|
|
2631
|
-
diff: ['差异配色', '新增用蓝色,删除用暖色,保留语法高亮'],
|
|
2632
|
-
})
|
|
2633
|
-
Object.assign(DC_COPY.en.items, {
|
|
2634
|
-
reading: ['Reading layout', 'Clear paragraphs, headings and quotes at your chosen font size'],
|
|
2635
|
-
code: ['Code palette', 'Muted, distinct syntax colours'],
|
|
2636
|
-
effortBadge: ['Effort badge', 'Print the reasoning level in dots inside the composer'],
|
|
2637
|
-
sidebarDots: ['Hover dot field', 'Light the dot field around the pointer on sidebar buttons'],
|
|
2638
|
-
sidebarRail: ['Blue rail', 'Show a whale-blue rail on the left of the hovered button'],
|
|
2639
|
-
thinkingLabel: ['English status label', 'Replace the status row with “Deep thinking for 12s. . .”'],
|
|
2640
|
-
diff: ['Diff palette', 'Blue additions and warm deletions, with syntax highlighting intact'],
|
|
2641
|
-
})
|
|
2642
|
-
|
|
2643
|
-
Object.assign(DC_COPY.zh.items, {
|
|
2644
|
-
fishFont: ['Maple Mono 字体', '全站换成 Maple Mono NF CN,正文与代码统一字体'],
|
|
2645
|
-
fishGlow: ['输入框柔光', '16px 圆角,聚焦时带主题色光晕'],
|
|
2646
|
-
fishMotion: ['轻动效', '按钮悬停上浮,界面过渡更柔和'],
|
|
2647
|
-
fishCode: ['代码块质感', '圆角描边与行内代码小药丸'],
|
|
2648
|
-
})
|
|
2649
|
-
Object.assign(DC_COPY.en.items, {
|
|
2650
|
-
fishFont: ['Maple Mono type', 'Use Maple Mono NF CN everywhere, including code'],
|
|
2651
|
-
fishGlow: ['Composer glow', '16px radius plus an accent glow on focus'],
|
|
2652
|
-
fishMotion: ['Soft motion', 'Buttons lift on hover and surfaces ease between states'],
|
|
2653
|
-
fishCode: ['Code surface', 'Rounded code blocks and tinted inline-code pills'],
|
|
2654
|
-
})
|
|
2655
|
-
Object.assign(DC_COPY.zh.items, {
|
|
2656
|
-
catppuccin: ['Catppuccin 配色', 'Latte / Mocha 全套背景、文字、边框与强调色'],
|
|
2657
|
-
aurora: ['极光背景', '缓慢流动的渐变光晕,随主题色呼吸'],
|
|
2658
|
-
cursor: ['指针物理', '跟随指针的柔光、输入框微倾斜'],
|
|
2659
|
-
textMotion: ['思考与文字动效', '回复浮入、思考块微光、流式文字呼吸感'],
|
|
2660
|
-
})
|
|
2661
|
-
Object.assign(DC_COPY.en.items, {
|
|
2662
|
-
catppuccin: ['Catppuccin palette', 'Latte / Mocha backgrounds, text, borders and accents'],
|
|
2663
|
-
aurora: ['Aurora field', 'Slow drifting gradient light that breathes with the accent'],
|
|
2664
|
-
cursor: ['Pointer physics', 'A cursor-following glow and a subtle composer tilt'],
|
|
2665
|
-
textMotion: ['Thinking & text motion', 'Replies rise in, reasoning shimmers, streaming text breathes'],
|
|
2666
|
-
})
|
|
2667
|
-
/** Switch drawn as SVG so the capsule ends and the knob are exact shapes. */
|
|
2668
|
-
function DcSwitchSvg({ value }) {
|
|
2669
|
-
const on = value === true
|
|
2670
|
-
return h('svg', {
|
|
2671
|
-
width: 42,
|
|
2672
|
-
height: 24,
|
|
2673
|
-
viewBox: '0 0 42 24',
|
|
2674
|
-
'aria-hidden': 'true',
|
|
2675
|
-
style: { display: 'block', overflow: 'visible' },
|
|
2676
|
-
}, [
|
|
2677
|
-
h('rect', {
|
|
2678
|
-
key: 'track',
|
|
2679
|
-
x: 0.5,
|
|
2680
|
-
y: 0.5,
|
|
2681
|
-
width: 41,
|
|
2682
|
-
height: 23,
|
|
2683
|
-
rx: 11.5,
|
|
2684
|
-
ry: 11.5,
|
|
2685
|
-
style: {
|
|
2686
|
-
fill: on
|
|
2687
|
-
? 'color-mix(in srgb, var(--dsw-alias-label-primary) 94%, transparent)'
|
|
2688
|
-
: 'color-mix(in srgb, var(--dsw-alias-label-tertiary) 44%, transparent)',
|
|
2689
|
-
// Only the enabled state carries an outline; keep the SVG geometry fixed.
|
|
2690
|
-
stroke: on
|
|
2691
|
-
? 'color-mix(in srgb, var(--dsw-alias-label-primary) 94%, transparent)'
|
|
2692
|
-
: 'none',
|
|
2693
|
-
strokeWidth: 1,
|
|
2694
|
-
transition: 'fill 200ms cubic-bezier(0.22, 1, 0.36, 1), stroke 200ms cubic-bezier(0.22, 1, 0.36, 1)',
|
|
2695
|
-
},
|
|
2696
|
-
}),
|
|
2697
|
-
h('g', {
|
|
2698
|
-
key: 'knob',
|
|
2699
|
-
style: {
|
|
2700
|
-
transform: on ? 'translateX(18px)' : 'translateX(0px)',
|
|
2701
|
-
transition: 'transform 220ms cubic-bezier(0.22, 1, 0.36, 1)',
|
|
2702
|
-
},
|
|
2703
|
-
}, h('circle', {
|
|
2704
|
-
cx: 12,
|
|
2705
|
-
cy: 12,
|
|
2706
|
-
r: 9,
|
|
2707
|
-
style: {
|
|
2708
|
-
fill: on ? 'var(--dsw-alias-bg-base, #17171a)' : 'color-mix(in srgb, var(--dsw-alias-label-primary) 82%, transparent)',
|
|
2709
|
-
transition: 'fill 200ms cubic-bezier(0.22, 1, 0.36, 1)',
|
|
2710
|
-
},
|
|
2711
|
-
})),
|
|
2712
|
-
])
|
|
2713
|
-
}
|
|
2714
|
-
|
|
2715
|
-
/** One settings row: a label on the left and a switch on the right. */
|
|
2716
|
-
function DcSwitch({ label, description, value, disabled, onChange }) {
|
|
2717
|
-
return h('div', { className: 'dc-set-row' }, [
|
|
2718
|
-
h('div', { key: 'text', className: 'dc-set-text' }, [
|
|
2719
|
-
h('span', { key: 'label', className: 'dc-set-label' }, label),
|
|
2720
|
-
description === undefined
|
|
2721
|
-
? null
|
|
2722
|
-
: h('span', { key: 'desc', className: 'dc-set-desc' }, description),
|
|
2723
|
-
]),
|
|
2724
|
-
h('button', {
|
|
2725
|
-
key: 'switch',
|
|
2726
|
-
type: 'button',
|
|
2727
|
-
role: 'switch',
|
|
2728
|
-
disabled,
|
|
2729
|
-
'aria-checked': value ? 'true' : 'false',
|
|
2730
|
-
'aria-label': label,
|
|
2731
|
-
className: 'dc-switch',
|
|
2732
|
-
'data-on': value ? 'true' : undefined,
|
|
2733
|
-
onClick: () => onChange(!value),
|
|
2734
|
-
}, h(DcSwitchSvg, { key: 'glyph', value: value === true })),
|
|
2735
|
-
])
|
|
2736
|
-
}
|
|
2737
|
-
|
|
2738
|
-
/** The switch list shown inside the sidebar sheet. */
|
|
2739
|
-
const FISH_CSS = `
|
|
2740
|
-
:root {
|
|
2741
|
-
--fish-font: "Maple Mono NF CN", "Maple Mono", ui-monospace, SFMono-Regular, Menlo, monospace;
|
|
2742
|
-
--fish-ink: var(--dc-accent, #7cc8ff);
|
|
2743
|
-
}
|
|
2744
|
-
:root:not(.dc-off-fishfont) body {
|
|
2745
|
-
font-family: var(--fish-font) !important;
|
|
2746
|
-
font-feature-settings: "ss01" 1, "cv01" 1, "liga" 1;
|
|
2747
|
-
-webkit-font-smoothing: antialiased;
|
|
2748
|
-
text-rendering: optimizeLegibility;
|
|
2749
|
-
}
|
|
2750
|
-
:root:not(.dc-off-fishfont) button,
|
|
2751
|
-
:root:not(.dc-off-fishfont) input,
|
|
2752
|
-
:root:not(.dc-off-fishfont) textarea,
|
|
2753
|
-
:root:not(.dc-off-fishfont) select,
|
|
2754
|
-
:root:not(.dc-off-fishfont) [contenteditable="true"] {
|
|
2755
|
-
font-family: inherit !important;
|
|
2756
|
-
}
|
|
2757
|
-
:root:not(.dc-off-fishfont) code,
|
|
2758
|
-
:root:not(.dc-off-fishfont) pre,
|
|
2759
|
-
:root:not(.dc-off-fishfont) kbd,
|
|
2760
|
-
:root:not(.dc-off-fishfont) samp {
|
|
2761
|
-
font-family: var(--fish-font) !important;
|
|
2762
|
-
}
|
|
2763
|
-
:root:not(.dc-off-fishfont) p,
|
|
2764
|
-
:root:not(.dc-off-fishfont) li,
|
|
2765
|
-
:root:not(.dc-off-fishfont) blockquote {
|
|
2766
|
-
line-height: 1.75;
|
|
2767
|
-
}
|
|
2768
|
-
:root:not(.dc-off-fishglow) [data-composer-card] {
|
|
2769
|
-
border-radius: 16px !important;
|
|
2770
|
-
transition: box-shadow .25s ease, border-color .25s ease;
|
|
2771
|
-
}
|
|
2772
|
-
:root:not(.dc-off-fishglow) [data-composer-card]:focus-within {
|
|
2773
|
-
box-shadow: 0 0 0 1px var(--fish-ink),
|
|
2774
|
-
0 18px 50px -28px var(--fish-ink) !important;
|
|
2775
|
-
}
|
|
2776
|
-
:root:not(.dc-off-fishcode) pre {
|
|
2777
|
-
border-radius: 12px;
|
|
2778
|
-
border: 1px solid color-mix(in srgb, var(--dsw-alias-border-l1, #333) 70%, transparent);
|
|
2779
|
-
}
|
|
2780
|
-
:root:not(.dc-off-fishcode) :not(pre) > code {
|
|
2781
|
-
background: color-mix(in srgb, var(--dsw-alias-bg-layer-2, #222) 78%, transparent);
|
|
2782
|
-
padding: .12em .38em;
|
|
2783
|
-
border-radius: 5px;
|
|
2784
|
-
}
|
|
2785
|
-
:root:not(.dc-off-fishmotion) button {
|
|
2786
|
-
transition: transform .16s ease, box-shadow .16s ease;
|
|
2787
|
-
}
|
|
2788
|
-
:root:not(.dc-off-fishmotion) button:hover {
|
|
2789
|
-
transform: translateY(-1px);
|
|
2790
|
-
}
|
|
2791
|
-
::selection {
|
|
2792
|
-
background: color-mix(in srgb, var(--fish-ink) 32%, transparent);
|
|
2793
|
-
}
|
|
2794
|
-
::-webkit-scrollbar {
|
|
2795
|
-
width: 9px;
|
|
2796
|
-
height: 9px;
|
|
2797
|
-
}
|
|
2798
|
-
::-webkit-scrollbar-thumb {
|
|
2799
|
-
background: color-mix(in srgb, var(--dsw-alias-border-l2, #555) 60%, transparent);
|
|
2800
|
-
border-radius: 999px;
|
|
2801
|
-
}
|
|
2802
|
-
::-webkit-scrollbar-thumb:hover {
|
|
2803
|
-
background: var(--fish-ink);
|
|
2804
|
-
}
|
|
2805
|
-
@media (prefers-reduced-motion: reduce) {
|
|
2806
|
-
* { animation: none !important; transition: none !important; }
|
|
2807
|
-
}
|
|
2808
|
-
`
|
|
2809
|
-
|
|
2810
|
-
const FISH_FX_CSS = `
|
|
2811
|
-
:root:not(.dc-off-catppuccin) {
|
|
2812
|
-
--fish-ink: var(--dc-accent, #cba6f7);
|
|
2813
|
-
}
|
|
2814
|
-
:root:not(.dc-off-aurora) body {
|
|
2815
|
-
background-image:
|
|
2816
|
-
radial-gradient(55% 45% at 12% 8%, color-mix(in srgb, var(--dc-accent) 14%, transparent), transparent 70%),
|
|
2817
|
-
radial-gradient(50% 42% at 88% 16%, color-mix(in srgb, #89b4fa 12%, transparent), transparent 70%),
|
|
2818
|
-
radial-gradient(45% 38% at 50% 96%, color-mix(in srgb, #cba6f7 10%, transparent), transparent 72%) !important;
|
|
2819
|
-
background-size: 220% 220%, 220% 220%, 220% 220% !important;
|
|
2820
|
-
background-repeat: no-repeat !important;
|
|
2821
|
-
animation: fish-aurora 26s ease-in-out infinite alternate;
|
|
2822
|
-
}
|
|
2823
|
-
@keyframes fish-aurora {
|
|
2824
|
-
0% { background-position: 0% 0%, 100% 0%, 50% 100%; }
|
|
2825
|
-
100% { background-position: 18% 12%, 82% 20%, 42% 78%; }
|
|
2826
|
-
}
|
|
2827
|
-
.fish-cursor-glow {
|
|
2828
|
-
position: fixed;
|
|
2829
|
-
left: 0;
|
|
2830
|
-
top: 0;
|
|
2831
|
-
width: 360px;
|
|
2832
|
-
height: 360px;
|
|
2833
|
-
margin: -180px 0 0 -180px;
|
|
2834
|
-
border-radius: 50%;
|
|
2835
|
-
pointer-events: none;
|
|
2836
|
-
z-index: 1;
|
|
2837
|
-
opacity: 0;
|
|
2838
|
-
transition: opacity .35s ease;
|
|
2839
|
-
background: radial-gradient(circle, color-mix(in srgb, var(--dc-accent, #cba6f7) 18%, transparent), transparent 66%);
|
|
2840
|
-
will-change: transform;
|
|
2841
|
-
}
|
|
2842
|
-
:root:not(.dc-off-cursor) .fish-cursor-glow { opacity: .55; }
|
|
2843
|
-
:root:not(.dc-off-cursor) [data-composer-card] {
|
|
2844
|
-
transition: transform .2s ease, box-shadow .25s ease;
|
|
2845
|
-
will-change: transform;
|
|
2846
|
-
}
|
|
2847
|
-
:root:not(.dc-off-textmotion) [data-chat-flow-kind="assistant-step"] {
|
|
2848
|
-
animation: fish-rise .4s cubic-bezier(.16,1,.3,1) both;
|
|
2849
|
-
}
|
|
2850
|
-
@keyframes fish-rise {
|
|
2851
|
-
from { opacity: 0; transform: translateY(7px); }
|
|
2852
|
-
to { opacity: 1; transform: none; }
|
|
2853
|
-
}
|
|
2854
|
-
:root:not(.dc-off-textmotion) [data-chat-group-part="reasoning"] {
|
|
2855
|
-
border-left: 2px solid color-mix(in srgb, var(--dc-accent, #cba6f7) 45%, transparent);
|
|
2856
|
-
padding-left: 10px;
|
|
2857
|
-
animation: fish-breathe 4.5s ease-in-out infinite;
|
|
2858
|
-
}
|
|
2859
|
-
@keyframes fish-breathe {
|
|
2860
|
-
0%, 100% { opacity: .72; }
|
|
2861
|
-
50% { opacity: 1; }
|
|
2862
|
-
}
|
|
2863
|
-
@media (prefers-reduced-motion: reduce) {
|
|
2864
|
-
.fish-cursor-glow { display: none; }
|
|
2865
|
-
:root body { animation: none !important; }
|
|
2866
|
-
}
|
|
2867
|
-
`
|
|
2868
|
-
|
|
2869
|
-
function DcSettingsPage() {
|
|
2870
|
-
const copy = dcUsesChinese() ? DC_COPY.zh : DC_COPY.en
|
|
2871
|
-
const settings = useDcSettings()
|
|
2872
|
-
const state = settings.values
|
|
2873
|
-
const disabled = settings.status !== 'ready' || !settings.writable || settings.pending
|
|
2874
|
-
const update = key => value => dcSetSetting(key, value)
|
|
2875
|
-
const reset = () => dcWrite?.(DC_DEFAULT_SETTINGS)
|
|
2876
|
-
const group = (title, children) => h('section', { key: title, className: 'dc-set-group' }, [
|
|
2877
|
-
h('h3', { key: 'title', className: 'dc-set-group-title' }, title),
|
|
2878
|
-
...children,
|
|
2879
|
-
])
|
|
2880
|
-
const item = (key) => {
|
|
2881
|
-
const row = copy.items[key]
|
|
2882
|
-
return h(DcSwitch, {
|
|
2883
|
-
key: key,
|
|
2884
|
-
label: row[0],
|
|
2885
|
-
description: row[1],
|
|
2886
|
-
value: state[key],
|
|
2887
|
-
disabled,
|
|
2888
|
-
onChange: update(key),
|
|
2889
|
-
})
|
|
2890
|
-
}
|
|
2891
|
-
const zh = dcUsesChinese()
|
|
2892
|
-
const status = settings.error
|
|
2893
|
-
? (zh ? '保存未完成。如果刚更新过插件,请完整退出 DSH 重启后再试。' : 'Could not save. If you just updated the plugin, quit and reopen DSH, then try again.')
|
|
2894
|
-
: settings.status === 'loading' ? (zh ? '正在读取主题设置…' : 'Loading theme preferences…')
|
|
2895
|
-
: settings.status !== 'ready' ? (zh ? '此宿主暂未提供主题设置。' : 'Theme preferences are unavailable on this host.')
|
|
2896
|
-
: !settings.writable ? (zh ? '此配置只读。' : 'These preferences are read-only.')
|
|
2897
|
-
: settings.pending ? (zh ? '正在保存…' : 'Saving…') : ''
|
|
2898
|
-
return h('div', { className: 'dc-set' }, [
|
|
2899
|
-
h('p', { key: 'autosave', className: 'dc-settings-status' }, zh ? '更改立即生效并自动保存。' : 'Changes apply immediately and save automatically.'),
|
|
2900
|
-
status ? h('p', { key: 'status', className: 'dc-settings-status', role: settings.error ? 'alert' : 'status' }, status) : null,
|
|
2901
|
-
group(zh ? '界面与阅读' : 'Interface & reading', [item('reading'), item('code')]),
|
|
2902
|
-
group(copy.groups.hero, [
|
|
2903
|
-
item('hero'), item('field'), item('wave'), item('ripple'),
|
|
2904
|
-
]),
|
|
2905
|
-
group(copy.groups.thinking, [
|
|
2906
|
-
item('thinkingSphere'), item('thinkingLabel'),
|
|
2907
|
-
]),
|
|
2908
|
-
group(copy.groups.composer, [
|
|
2909
|
-
item('glass'), item('effortBadge'),
|
|
2910
|
-
]),
|
|
2911
|
-
group(copy.groups.sidebar, [
|
|
2912
|
-
item('sidebarDots'), item('sidebarRail'),
|
|
2913
|
-
]),
|
|
2914
|
-
group(copy.groups.accents, [
|
|
2915
|
-
item('bold'), item('focusRing'), item('diff'),
|
|
2916
|
-
]),
|
|
2917
|
-
group(zh ? 'Fish 字体与质感' : 'Fish finish', [
|
|
2918
|
-
item('fishFont'), item('fishGlow'), item('fishMotion'), item('fishCode'),
|
|
2919
|
-
]),
|
|
2920
|
-
group(zh ? 'Catppuccin 与动效' : 'Catppuccin & motion', [
|
|
2921
|
-
item('catppuccin'), item('aurora'), item('cursor'), item('textMotion'),
|
|
2922
|
-
]),
|
|
2923
|
-
h('div', { key: 'footer', className: 'dc-set-footer' }, [
|
|
2924
|
-
h('button', { key: 'reset', type: 'button', className: 'dc-set-reset', disabled, onClick: reset }, copy.reset),
|
|
2925
|
-
h('span', { key: 'note', className: 'dc-set-note' }, 'Deep Fish UI · 0.2.0'),
|
|
2926
|
-
]),
|
|
2927
|
-
])
|
|
2928
|
-
}
|
|
2929
|
-
|
|
2930
|
-
// ----------------------------------------------------------- sidebar entry
|
|
2931
|
-
/** Sheet state shared by the sidebar button and the panel itself. */
|
|
2932
|
-
let dcSheetOpen = false
|
|
2933
|
-
const dcSheetListeners = new Set()
|
|
2934
|
-
function dcSetSheetOpen(next) {
|
|
2935
|
-
dcSheetOpen = next
|
|
2936
|
-
dcSheetListeners.forEach((listener) => listener())
|
|
2937
|
-
}
|
|
2938
|
-
function useDcSheet() {
|
|
2939
|
-
const [open, setOpen] = React.useState(dcSheetOpen)
|
|
2940
|
-
React.useEffect(() => {
|
|
2941
|
-
const listener = () => setOpen(dcSheetOpen)
|
|
2942
|
-
dcSheetListeners.add(listener)
|
|
2943
|
-
return () => { dcSheetListeners.delete(listener) }
|
|
2944
|
-
}, [])
|
|
2945
|
-
return open
|
|
2946
|
-
}
|
|
2947
|
-
let dcReactDOM = null
|
|
2948
|
-
try {
|
|
2949
|
-
dcReactDOM = require('react-dom')
|
|
2950
|
-
} catch (error) {
|
|
2951
|
-
dcReactDOM = null
|
|
2952
|
-
}
|
|
2953
|
-
|
|
2954
|
-
/** The floating settings sheet, portalled to the body when react-dom is around. */
|
|
2955
|
-
function DcSheet() {
|
|
2956
|
-
const open = useDcSheet()
|
|
2957
|
-
const panelRef = React.useRef(null)
|
|
2958
|
-
React.useEffect(() => {
|
|
2959
|
-
if (!open) return undefined
|
|
2960
|
-
const previousFocus = document.activeElement
|
|
2961
|
-
const panel = panelRef.current
|
|
2962
|
-
const focusable = () => panel === null ? [] : [...panel.querySelectorAll('button:not(:disabled), [href], [tabindex="0"]')]
|
|
2963
|
-
;(focusable()[0] || panel)?.focus()
|
|
2964
|
-
const onKeyDown = event => {
|
|
2965
|
-
if (event.key === 'Escape') { event.preventDefault(); event.stopPropagation(); dcSetSheetOpen(false) }
|
|
2966
|
-
if (event.key !== 'Tab') return
|
|
2967
|
-
const items = focusable()
|
|
2968
|
-
const first = items[0] || panel
|
|
2969
|
-
const last = items[items.length - 1] || panel
|
|
2970
|
-
if (event.shiftKey && (document.activeElement === first || document.activeElement === panel)) {
|
|
2971
|
-
event.preventDefault(); last?.focus()
|
|
2972
|
-
} else if (!event.shiftKey && (document.activeElement === last || document.activeElement === panel)) {
|
|
2973
|
-
event.preventDefault(); first?.focus()
|
|
2974
|
-
}
|
|
2975
|
-
}
|
|
2976
|
-
document.addEventListener('keydown', onKeyDown, true)
|
|
2977
|
-
return () => {
|
|
2978
|
-
document.removeEventListener('keydown', onKeyDown, true)
|
|
2979
|
-
if (previousFocus instanceof HTMLElement && previousFocus.isConnected) previousFocus.focus()
|
|
2980
|
-
}
|
|
2981
|
-
}, [open])
|
|
2982
|
-
if (!open) return null
|
|
2983
|
-
const panel = h('div', { key: 'panel', className: 'dc-sheet-panel', ref: panelRef, role: 'dialog', 'aria-modal': 'true', tabIndex: -1, 'aria-label': dcUsesChinese() ? DC_COPY.zh.dialog : DC_COPY.en.dialog }, [
|
|
2984
|
-
h('div', { key: 'head', className: 'dc-sheet-head' }, [
|
|
2985
|
-
h('span', { key: 'title', className: 'dc-sheet-title' }, 'Deep Fish UI'),
|
|
2986
|
-
h('button', {
|
|
2987
|
-
key: 'close',
|
|
2988
|
-
type: 'button',
|
|
2989
|
-
className: 'dc-sheet-close',
|
|
2990
|
-
'aria-label': dcUsesChinese() ? DC_COPY.zh.close : DC_COPY.en.close,
|
|
2991
|
-
onClick: () => dcSetSheetOpen(false),
|
|
2992
|
-
}, '\u00d7'),
|
|
2993
|
-
]),
|
|
2994
|
-
h('div', { key: 'body', className: 'dc-sheet-body' }, h(DcSettingsPage)),
|
|
2995
|
-
])
|
|
2996
|
-
const scrim = h('div', {
|
|
2997
|
-
key: 'scrim',
|
|
2998
|
-
className: 'dc-sheet-scrim',
|
|
2999
|
-
onClick: () => dcSetSheetOpen(false),
|
|
3000
|
-
})
|
|
3001
|
-
const both = h('div', { className: 'dc-sheet-root' }, [scrim, panel])
|
|
3002
|
-
if (dcReactDOM !== null && typeof dcReactDOM.createPortal === 'function') {
|
|
3003
|
-
return dcReactDOM.createPortal(both, document.body)
|
|
3004
|
-
}
|
|
3005
|
-
return both
|
|
3006
|
-
}
|
|
3007
|
-
|
|
3008
|
-
/** Nine-dot glyph used by the sidebar button and its active state. */
|
|
3009
|
-
function DcSettingsIcon({ size = 16, active }) {
|
|
3010
|
-
const unit = size / 16
|
|
3011
|
-
const points = [
|
|
3012
|
-
[3, 3], [8, 3], [13, 3],
|
|
3013
|
-
[3, 8], [8, 8], [13, 8],
|
|
3014
|
-
[3, 13], [8, 13], [13, 13],
|
|
3015
|
-
]
|
|
3016
|
-
return h('svg', {
|
|
3017
|
-
viewBox: '0 0 16 16',
|
|
3018
|
-
width: size,
|
|
3019
|
-
height: size,
|
|
3020
|
-
'aria-hidden': 'true',
|
|
3021
|
-
style: { display: 'block' },
|
|
3022
|
-
}, points.map((point, index) => h('circle', {
|
|
3023
|
-
key: index,
|
|
3024
|
-
cx: point[0],
|
|
3025
|
-
cy: point[1],
|
|
3026
|
-
r: 1.35 * unit,
|
|
3027
|
-
fill: active ? 'var(--dc-accent)' : 'currentColor',
|
|
3028
|
-
})))
|
|
3029
|
-
}
|
|
3030
|
-
|
|
3031
|
-
/**
|
|
3032
|
-
* Sidebar footer button that opens the sheet.
|
|
3033
|
-
*
|
|
3034
|
-
* The button carries its own dot field: completely unlit at rest, it surfaces only in a
|
|
3035
|
-
* soft pool around the pointer, clipped to the button, and fades away when the pointer
|
|
3036
|
-
* leaves. Dots never move; only their brightness changes.
|
|
3037
|
-
*/
|
|
3038
|
-
function DcSidebarAction({ wide }) {
|
|
3039
|
-
const open = useDcSheet()
|
|
3040
|
-
const { values } = useDcSettings()
|
|
3041
|
-
const showDots = values.sidebarDots !== false
|
|
3042
|
-
const showRail = values.sidebarRail !== false
|
|
3043
|
-
const canvasRef = React.useRef(null)
|
|
3044
|
-
React.useEffect(() => {
|
|
3045
|
-
if (!showDots && !showRail) return
|
|
3046
|
-
const canvas = canvasRef.current
|
|
3047
|
-
if (canvas === null) return
|
|
3048
|
-
const context = canvas.getContext('2d')
|
|
3049
|
-
if (context === null) return
|
|
3050
|
-
const button = canvas.parentElement
|
|
3051
|
-
if (button === null) return
|
|
3052
|
-
const motion = matchMedia('(prefers-reduced-motion: reduce)')
|
|
3053
|
-
const state = { x: -999, y: -999, inside: false, alpha: 0, frame: 0, live: false, dirty: false }
|
|
3054
|
-
let stopped = false
|
|
3055
|
-
let dpr = Math.min(2, devicePixelRatio || 1)
|
|
3056
|
-
|
|
3057
|
-
const measure = () => {
|
|
3058
|
-
const rect = canvas.getBoundingClientRect()
|
|
3059
|
-
dpr = Math.min(2, devicePixelRatio || 1)
|
|
3060
|
-
const width = Math.max(1, Math.round(rect.width * dpr))
|
|
3061
|
-
const height = Math.max(1, Math.round(rect.height * dpr))
|
|
3062
|
-
if (canvas.width !== width || canvas.height !== height) {
|
|
3063
|
-
canvas.width = width
|
|
3064
|
-
canvas.height = height
|
|
3065
|
-
}
|
|
3066
|
-
}
|
|
3067
|
-
|
|
3068
|
-
const paint = () => {
|
|
3069
|
-
state.frame = 0
|
|
3070
|
-
if (stopped) return
|
|
3071
|
-
const rect = canvas.getBoundingClientRect()
|
|
3072
|
-
const width = rect.width
|
|
3073
|
-
const height = rect.height
|
|
3074
|
-
const target = state.inside ? 1 : 0
|
|
3075
|
-
state.alpha = motion.matches ? target : state.alpha + (target - state.alpha) * 0.22
|
|
3076
|
-
context.setTransform(dpr, 0, 0, dpr, 0, 0)
|
|
3077
|
-
context.clearRect(0, 0, width, height)
|
|
3078
|
-
if (!state.inside && state.alpha < 0.02) {
|
|
3079
|
-
state.alpha = 0
|
|
3080
|
-
state.live = false
|
|
3081
|
-
return
|
|
3082
|
-
}
|
|
3083
|
-
const radius = 64
|
|
3084
|
-
const accent = (getComputedStyle(button).getPropertyValue('--dc-accent') || '').trim() || '#7aa4ff'
|
|
3085
|
-
context.fillStyle = accent
|
|
3086
|
-
if (showDots) for (let y = 3; y < height; y += 4) {
|
|
3087
|
-
for (let x = 3; x < width; x += 4) {
|
|
3088
|
-
const dx = x - state.x
|
|
3089
|
-
const dy = y - state.y
|
|
3090
|
-
const distance = Math.sqrt(dx * dx + dy * dy)
|
|
3091
|
-
if (distance > radius) continue
|
|
3092
|
-
const alpha = Math.pow(1 - distance / radius, 1.35) * state.alpha
|
|
3093
|
-
if (alpha < 0.02) continue
|
|
3094
|
-
context.globalAlpha = Math.min(1, alpha)
|
|
3095
|
-
context.beginPath()
|
|
3096
|
-
context.arc(x, y, 0.85, 0, Math.PI * 2)
|
|
3097
|
-
context.fill()
|
|
3098
|
-
}
|
|
3099
|
-
}
|
|
3100
|
-
if (showRail) {
|
|
3101
|
-
const railHeight = Math.max(6, height - 10)
|
|
3102
|
-
const railTop = (height - railHeight) / 2
|
|
3103
|
-
context.globalAlpha = Math.min(1, state.alpha * 0.9)
|
|
3104
|
-
context.beginPath()
|
|
3105
|
-
if (typeof context.roundRect === 'function') {
|
|
3106
|
-
context.roundRect(2, railTop, 3, railHeight, 1.5)
|
|
3107
|
-
} else {
|
|
3108
|
-
context.rect(2, railTop, 3, railHeight)
|
|
3109
|
-
}
|
|
3110
|
-
context.fill()
|
|
3111
|
-
context.globalAlpha = 1
|
|
3112
|
-
}
|
|
3113
|
-
const moving = state.dirty
|
|
3114
|
-
state.dirty = false
|
|
3115
|
-
if (motion.matches) {
|
|
3116
|
-
if (!state.inside) {
|
|
3117
|
-
context.clearRect(0, 0, width, height)
|
|
3118
|
-
state.alpha = 0
|
|
3119
|
-
}
|
|
3120
|
-
state.live = false
|
|
3121
|
-
return
|
|
3122
|
-
}
|
|
3123
|
-
// Idle inside the button: stop the loop until the pointer moves again.
|
|
3124
|
-
if (state.inside && state.alpha >= 0.98 && !moving) {
|
|
3125
|
-
state.live = false
|
|
3126
|
-
return
|
|
3127
|
-
}
|
|
3128
|
-
if (state.inside || state.alpha >= 0.02) {
|
|
3129
|
-
state.frame = requestAnimationFrame(paint)
|
|
3130
|
-
} else {
|
|
3131
|
-
state.live = false
|
|
3132
|
-
}
|
|
3133
|
-
}
|
|
3134
|
-
|
|
3135
|
-
const wake = () => {
|
|
3136
|
-
if (stopped || state.live) return
|
|
3137
|
-
state.live = true
|
|
3138
|
-
if (state.frame === 0) state.frame = requestAnimationFrame(paint)
|
|
3139
|
-
}
|
|
3140
|
-
|
|
3141
|
-
const track = event => {
|
|
3142
|
-
const rect = canvas.getBoundingClientRect()
|
|
3143
|
-
state.x = event.clientX - rect.left
|
|
3144
|
-
state.y = event.clientY - rect.top
|
|
3145
|
-
state.inside = true
|
|
3146
|
-
state.dirty = true
|
|
3147
|
-
wake()
|
|
3148
|
-
}
|
|
3149
|
-
const leave = () => {
|
|
3150
|
-
state.inside = false
|
|
3151
|
-
wake()
|
|
3152
|
-
}
|
|
3153
|
-
|
|
3154
|
-
const resizeObserver = new ResizeObserver(() => {
|
|
3155
|
-
measure()
|
|
3156
|
-
if (state.inside || state.alpha > 0.02) wake()
|
|
3157
|
-
})
|
|
3158
|
-
resizeObserver.observe(canvas)
|
|
3159
|
-
button.addEventListener('pointerenter', track)
|
|
3160
|
-
button.addEventListener('pointermove', track)
|
|
3161
|
-
button.addEventListener('pointerleave', leave)
|
|
3162
|
-
measure()
|
|
3163
|
-
return () => {
|
|
3164
|
-
stopped = true
|
|
3165
|
-
resizeObserver.disconnect()
|
|
3166
|
-
button.removeEventListener('pointerenter', track)
|
|
3167
|
-
button.removeEventListener('pointermove', track)
|
|
3168
|
-
button.removeEventListener('pointerleave', leave)
|
|
3169
|
-
if (state.frame !== 0) cancelAnimationFrame(state.frame)
|
|
3170
|
-
state.frame = 0
|
|
3171
|
-
state.live = false
|
|
3172
|
-
}
|
|
3173
|
-
}, [showDots, showRail])
|
|
3174
|
-
return h('div', { className: 'dc-foot' }, [
|
|
3175
|
-
h('button', {
|
|
3176
|
-
key: 'button',
|
|
3177
|
-
type: 'button',
|
|
3178
|
-
className: 'dc-foot-button',
|
|
3179
|
-
title: 'Deep Fish UI',
|
|
3180
|
-
'aria-label': dcUsesChinese() ? DC_COPY.zh.button : DC_COPY.en.button,
|
|
3181
|
-
onClick: () => dcSetSheetOpen(!dcSheetOpen),
|
|
3182
|
-
}, [
|
|
3183
|
-
showDots || showRail
|
|
3184
|
-
? h('canvas', { key: 'dots', ref: canvasRef, className: 'dc-foot-dots', 'aria-hidden': 'true' })
|
|
3185
|
-
: null,
|
|
3186
|
-
h(DcSettingsIcon, { key: 'icon', size: 16, active: open }),
|
|
3187
|
-
wide ? h('span', { key: 'label', className: 'dc-foot-label' }, 'Deep Fish UI') : null,
|
|
3188
|
-
]),
|
|
3189
|
-
h(DcSheet, { key: 'sheet' }),
|
|
3190
|
-
])
|
|
3191
|
-
}
|
|
3192
|
-
|
|
3193
|
-
|
|
3194
|
-
return {
|
|
3195
|
-
inject: ['slots'],
|
|
3196
|
-
apply(ctx) {
|
|
3197
|
-
dcPlaySplash()
|
|
3198
|
-
ctx.effect(() => {
|
|
3199
|
-
dcMounted = true
|
|
3200
|
-
dcApplySettings()
|
|
3201
|
-
return () => {
|
|
3202
|
-
dcMounted = false
|
|
3203
|
-
dcWrite = null
|
|
3204
|
-
dcSetSheetOpen(false)
|
|
3205
|
-
for (const className of Object.values(DC_OFF_CLASS)) document.documentElement.classList.remove(className)
|
|
3206
|
-
for (const dispose of dcThemeLayers.values()) dispose()
|
|
3207
|
-
dcThemeLayers.clear()
|
|
3208
|
-
dcTheme = null
|
|
3209
|
-
}
|
|
3210
|
-
}, 'dsh-fish-ui: lifecycle')
|
|
3211
|
-
ctx.effect(() => {
|
|
3212
|
-
const style = document.createElement('style')
|
|
3213
|
-
style.dataset.dshPlugin = 'dsh-fish-ui'
|
|
3214
|
-
style.textContent = CSS
|
|
3215
|
-
document.head.append(style)
|
|
3216
|
-
return () => style.remove()
|
|
3217
|
-
}, 'dsh-fish-ui: styles')
|
|
3218
|
-
ctx.effect(() => {
|
|
3219
|
-
const style = document.createElement('style')
|
|
3220
|
-
style.dataset.dshPlugin = 'dsh-fish-ui:finish'
|
|
3221
|
-
style.textContent = FISH_CSS
|
|
3222
|
-
document.head.append(style)
|
|
3223
|
-
return () => style.remove()
|
|
3224
|
-
}, 'dsh-fish-ui: finish styles')
|
|
3225
|
-
ctx.effect(() => {
|
|
3226
|
-
const style = document.createElement('style')
|
|
3227
|
-
style.dataset.dshPlugin = 'dsh-fish-ui: fx'
|
|
3228
|
-
style.textContent = FISH_FX_CSS
|
|
3229
|
-
document.head.append(style)
|
|
3230
|
-
return () => style.remove()
|
|
3231
|
-
}, 'dsh-fish-ui: fx styles')
|
|
3232
|
-
ctx.effect(() => {
|
|
3233
|
-
if (window.matchMedia && window.matchMedia('(prefers-reduced-motion: reduce)').matches) return
|
|
3234
|
-
const glow = document.createElement('div')
|
|
3235
|
-
glow.className = 'fish-cursor-glow'
|
|
3236
|
-
document.body.append(glow)
|
|
3237
|
-
let tx = window.innerWidth / 2
|
|
3238
|
-
let ty = window.innerHeight / 2
|
|
3239
|
-
let x = tx
|
|
3240
|
-
let y = ty
|
|
3241
|
-
let raf = 0
|
|
3242
|
-
const move = event => { tx = event.clientX; ty = event.clientY }
|
|
3243
|
-
const loop = () => {
|
|
3244
|
-
x += (tx - x) * 0.12
|
|
3245
|
-
y += (ty - y) * 0.12
|
|
3246
|
-
glow.style.transform = 'translate3d(' + x.toFixed(1) + 'px,' + y.toFixed(1) + 'px,0)'
|
|
3247
|
-
raf = window.requestAnimationFrame(loop)
|
|
3248
|
-
}
|
|
3249
|
-
window.addEventListener('pointermove', move, { passive: true })
|
|
3250
|
-
raf = window.requestAnimationFrame(loop)
|
|
3251
|
-
|
|
3252
|
-
const tilt = event => {
|
|
3253
|
-
const card = event.currentTarget
|
|
3254
|
-
const rect = card.getBoundingClientRect()
|
|
3255
|
-
const dx = (event.clientX - rect.left) / rect.width - 0.5
|
|
3256
|
-
const dy = (event.clientY - rect.top) / rect.height - 0.5
|
|
3257
|
-
card.style.transform = 'perspective(900px) rotateX(' + (-dy * 1.6).toFixed(2) + 'deg) rotateY(' + (dx * 1.6).toFixed(2) + 'deg)'
|
|
3258
|
-
}
|
|
3259
|
-
const reset = event => { event.currentTarget.style.transform = '' }
|
|
3260
|
-
const cards = new Set()
|
|
3261
|
-
const bind = event => {
|
|
3262
|
-
const card = event.target.closest && event.target.closest('[data-composer-card]')
|
|
3263
|
-
if (!card || cards.has(card)) return
|
|
3264
|
-
cards.add(card)
|
|
3265
|
-
card.addEventListener('pointermove', tilt)
|
|
3266
|
-
card.addEventListener('pointerleave', reset)
|
|
3267
|
-
}
|
|
3268
|
-
document.addEventListener('pointerover', bind, { passive: true })
|
|
3269
|
-
return () => {
|
|
3270
|
-
window.cancelAnimationFrame(raf)
|
|
3271
|
-
window.removeEventListener('pointermove', move)
|
|
3272
|
-
document.removeEventListener('pointerover', bind)
|
|
3273
|
-
for (const card of cards) {
|
|
3274
|
-
card.removeEventListener('pointermove', tilt)
|
|
3275
|
-
card.removeEventListener('pointerleave', reset)
|
|
3276
|
-
card.style.transform = ''
|
|
3277
|
-
}
|
|
3278
|
-
glow.remove()
|
|
3279
|
-
}
|
|
3280
|
-
}, 'dsh-fish-ui: pointer physics')
|
|
3281
|
-
ctx.inject(['theme'], scope => {
|
|
3282
|
-
scope.effect(() => {
|
|
3283
|
-
dcTheme = scope.theme
|
|
3284
|
-
dcSyncTheme()
|
|
3285
|
-
return () => {
|
|
3286
|
-
for (const dispose of dcThemeLayers.values()) dispose()
|
|
3287
|
-
dcThemeLayers.clear()
|
|
3288
|
-
dcTheme = null
|
|
3289
|
-
}
|
|
3290
|
-
}, 'dsh-fish-ui: token layers')
|
|
3291
|
-
})
|
|
3292
|
-
ctx.effect(() => {
|
|
3293
|
-
const sync = () => {
|
|
3294
|
-
const enabled = dcGetSnapshot().values.effortBadge !== false
|
|
3295
|
-
const label = enabled ? dcEffortLabel() : null
|
|
3296
|
-
dcPaintEffort(label !== null && !DC_EFFORT_OFF.test(label) ? label : null)
|
|
3297
|
-
}
|
|
3298
|
-
sync()
|
|
3299
|
-
const timer = setInterval(sync, 500)
|
|
3300
|
-
return () => {
|
|
3301
|
-
clearInterval(timer)
|
|
3302
|
-
const card = document.querySelector('[data-composer-card]')
|
|
3303
|
-
if (card !== null) {
|
|
3304
|
-
card.removeAttribute('data-dc-effort')
|
|
3305
|
-
card.classList.remove('dc-effort-on', 'dc-effort-max')
|
|
3306
|
-
}
|
|
3307
|
-
}
|
|
3308
|
-
}, 'dsh-fish-ui: effort badge')
|
|
3309
|
-
// Fresh conversation on every launch. The service may not be reachable the first
|
|
3310
|
-
// moment the shell is up, so retry for a few seconds and leave a manual trigger.
|
|
3311
|
-
ctx.inject(['uiWorkspace'], scope => {
|
|
3312
|
-
const open = tries => {
|
|
3313
|
-
try {
|
|
3314
|
-
if (typeof scope.uiWorkspace.startSession === 'function') {
|
|
3315
|
-
scope.uiWorkspace.startSession()
|
|
3316
|
-
console.info('[dsh-fish-ui] opened a new session on launch')
|
|
3317
|
-
return
|
|
3318
|
-
}
|
|
3319
|
-
} catch (error) {
|
|
3320
|
-
console.warn('[dsh-fish-ui] new session failed', error)
|
|
3321
|
-
return
|
|
3322
|
-
}
|
|
3323
|
-
if (tries < 30) window.setTimeout(() => open(tries + 1), 400)
|
|
3324
|
-
}
|
|
3325
|
-
window.__dcNewSession = () => open(0)
|
|
3326
|
-
scope.effect(() => {
|
|
3327
|
-
const timer = window.setTimeout(() => open(0), 2500)
|
|
3328
|
-
return () => window.clearTimeout(timer)
|
|
3329
|
-
}, 'dsh-fish-ui: new session on launch')
|
|
3330
|
-
})
|
|
3331
|
-
ctx.inject(['configForms'], dcConnectSettings)
|
|
3332
|
-
const add = (name, options, Component) => ctx.slots.inject(name,
|
|
3333
|
-
() => ctx.slots.register({ name, ...options }, dcSafe(Component)))
|
|
3334
|
-
add('conversation.hero.frame', { id: 'dot-whale', order: 20 }, HeroFrame)
|
|
3335
|
-
add('sidebar.footer.action', { id: 'dsh-fish-ui', order: 5, label: () => 'Deep Fish UI' }, DcSidebarAction)
|
|
3336
|
-
add('shell.overlay', { id: 'dc-ambient', order: 5 }, DcOverlay)
|
|
3337
|
-
add('shell.overlay', { id: 'dc-sidebar-dots', order: 6 }, DcSidebarDots)
|
|
3338
|
-
add('shell.overlay', { id: 'dc-caret-trail', order: 4 }, DcCaretTrail)
|
|
3339
|
-
// Package name, distinct from the Host entry id even though both currently match.
|
|
3340
|
-
add('plugins.bundle.config', { key: 'dsh-fish-ui' }, DcSettingsPage)
|
|
3341
|
-
},
|
|
3342
|
-
}
|
|
3343
|
-
},
|
|
3344
|
-
})
|