dsh-panel-dock 1.0.42 → 1.0.43
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/client.js +31 -10
- package/package.json +1 -1
package/client.js
CHANGED
|
@@ -17,7 +17,7 @@ window.__ModuleLoader__.load({
|
|
|
17
17
|
// register a card here and the dock decides where it renders. It never adds a
|
|
18
18
|
// navigation entry, a button or a dialog -- the only affordances belong to the
|
|
19
19
|
// cards themselves.
|
|
20
|
-
const VERSION = '1.0.
|
|
20
|
+
const VERSION = '1.0.43'
|
|
21
21
|
const NS = 'panel-dock'
|
|
22
22
|
const STORE_KEY = 'dsh.panel-dock.v1'
|
|
23
23
|
const GAP = 6
|
|
@@ -191,21 +191,42 @@ window.__ModuleLoader__.load({
|
|
|
191
191
|
// one radius, one border, so three cards cannot end up in three different greys. The
|
|
192
192
|
// default stays off -- the dock must not repaint a card that draws itself.
|
|
193
193
|
// The host exposes no theme attribute and no surface tokens (verified: empty --dsw-* set,
|
|
194
|
-
// no data-theme, color-scheme:light), so the theme is read from what is
|
|
195
|
-
//
|
|
194
|
+
// no data-theme, color-scheme:light in both modes), so the theme is read from what is
|
|
195
|
+
// actually painted. Three signals, strongest first:
|
|
196
|
+
// 1. an explicit marker if the host ever adds one (data-ds-dark-theme / data-theme);
|
|
197
|
+
// 2. the painted background, body then <html> (body may be transparent);
|
|
198
|
+
// 3. prefers-color-scheme, only when nothing is painted.
|
|
199
|
+
// R3 closed: verified on invictus (light) and valentines (dark) after this change.
|
|
200
|
+
const paintLuma = (el) => {
|
|
201
|
+
try {
|
|
202
|
+
const bg = getComputedStyle(el).backgroundColor || ''
|
|
203
|
+
const m = bg.match(/rgba?\(([^)]+)\)/)
|
|
204
|
+
if (!m) return null
|
|
205
|
+
const p = m[1].split(',').map((v) => parseFloat(v))
|
|
206
|
+
const a = p.length > 3 ? p[3] : 1
|
|
207
|
+
if (a <= 0.1) return null
|
|
208
|
+
return (0.2126 * p[0] + 0.7152 * p[1] + 0.0722 * p[2]) / 255
|
|
209
|
+
} catch (e) { return null }
|
|
210
|
+
}
|
|
196
211
|
const darkCache = { at: 0, dark: false }
|
|
197
212
|
const hostIsDark = () => {
|
|
198
213
|
const now = Date.now()
|
|
199
214
|
if (now - darkCache.at < 500) return darkCache.dark
|
|
200
215
|
let dark = false
|
|
201
216
|
try {
|
|
202
|
-
const
|
|
203
|
-
const
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
217
|
+
const root = document.documentElement
|
|
218
|
+
const marker = (root.getAttribute('data-ds-dark-theme') !== null) ||
|
|
219
|
+
(root.getAttribute('data-theme') === 'dark') ||
|
|
220
|
+
(document.body && document.body.getAttribute
|
|
221
|
+
? (document.body.getAttribute('data-ds-dark-theme') !== null || document.body.getAttribute('data-theme') === 'dark')
|
|
222
|
+
: false)
|
|
223
|
+
if (marker) {
|
|
224
|
+
dark = true
|
|
225
|
+
} else {
|
|
226
|
+
const luma = paintLuma(document.body) ?? paintLuma(root)
|
|
227
|
+
dark = luma === null
|
|
228
|
+
? Boolean(window.matchMedia && window.matchMedia('(prefers-color-scheme: dark)').matches)
|
|
229
|
+
: luma < 0.45
|
|
209
230
|
}
|
|
210
231
|
} catch (e) {}
|
|
211
232
|
darkCache.at = now
|
package/package.json
CHANGED