@vinena/knobs 0.5.3 → 0.6.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/CHANGELOG.md +27 -0
- package/README.md +7 -6
- package/dist/context-amfyasb5.js +23 -0
- package/dist/context-svtr7vwt.js +22 -0
- package/dist/early.global.js +5 -5
- package/dist/edit/css.d.ts +59 -0
- package/dist/edit/html.d.ts +91 -0
- package/dist/edit/keep.d.ts +175 -0
- package/dist/edit/log.d.ts +107 -0
- package/dist/edit/replay.d.ts +28 -0
- package/dist/edit/risk.d.ts +33 -0
- package/dist/edit/rule.d.ts +31 -0
- package/dist/edit/source.d.ts +12 -0
- package/dist/edit/text.d.ts +66 -0
- package/dist/elementsview-fyc06wjt.js +3702 -0
- package/dist/elementsview-k6zvvcne.js +3701 -0
- package/dist/engine/dock.d.ts +3 -4
- package/dist/engine/frame.d.ts +1 -1
- package/dist/engine/style.d.ts +15 -0
- package/dist/{framekit-cjz0e4y8.js → framekit-622h6w1f.js} +54 -47
- package/dist/{framekit-yk1jxjv7.js → framekit-yx612r28.js} +54 -47
- package/dist/index-0zp9py56.js +859 -0
- package/dist/{index-prjpx67p.js → index-1mstjadm.js} +126 -2167
- package/dist/{index-begsqdm0.js → index-4a4x1bt2.js} +1 -1
- package/dist/index-58jdczmj.js +44 -0
- package/dist/index-5tv6sr74.js +23 -0
- package/dist/index-6bc2ztfd.js +688 -0
- package/dist/index-7cb4x1vj.js +1885 -0
- package/dist/index-a974q3aa.js +34 -0
- package/dist/{index-q73py563.js → index-aymfvd8s.js} +1 -1
- package/dist/{index-zt3rheck.js → index-aynkv7qk.js} +11 -8
- package/dist/{index-p57fdttx.js → index-dzm8ywq0.js} +492 -2365
- package/dist/{index-9jhatmky.js → index-f60yax1j.js} +13 -8
- package/dist/index-f67wctn3.js +1858 -0
- package/dist/{index-vgfn2n1h.js → index-ftjdt358.js} +8 -171
- package/dist/{index-j1h13ahg.js → index-gm51cthv.js} +2 -45
- package/dist/index-kfdzsyyw.js +1859 -0
- package/dist/index-t4kssacm.js +208 -0
- package/dist/index-v0ht9q0g.js +1518 -0
- package/dist/{index-6wbgqkdz.js → index-x59vz1xx.js} +247 -905
- package/dist/index-xh39jtkq.js +32 -0
- package/dist/index-yb7fc59g.js +718 -0
- package/dist/index-zd6adby9.js +496 -0
- package/dist/index.d.ts +62 -0
- package/dist/index.global.js +410 -152
- package/dist/index.js +504 -482
- package/dist/react-0wepdf60.js +1519 -0
- package/dist/{react-gefkdkdz.js → react-1gqwa2yw.js} +1 -1
- package/dist/{index-sn2y6j09.js → react-3mfz1x2a.js} +126 -2167
- package/dist/react-4rbjw9af.js +33 -0
- package/dist/react-5rq7bnsy.js +210 -0
- package/dist/react-6bz05qk1.js +860 -0
- package/dist/{react-qgz9afa2.js → react-6fnxxs30.js} +8 -171
- package/dist/react-6q2cw2ya.js +689 -0
- package/dist/{react-7vjfsh40.js → react-6t4dbdzn.js} +11 -8
- package/dist/react-88es9b5q.js +719 -0
- package/dist/react-97b5b8j4.js +46 -0
- package/dist/{react-mmq2zya3.js → react-bxzn8vq5.js} +1 -1
- package/dist/{react-3rhdj2k1.js → react-cs62p9qh.js} +62 -720
- package/dist/react-ethftdxp.js +497 -0
- package/dist/react-fp73vhyd.js +36 -0
- package/dist/{react-qfpg79hs.js → react-me102s1a.js} +2 -45
- package/dist/react-t2qnewz2.js +24 -0
- package/dist/react-ttj8f9qp.js +1886 -0
- package/dist/{react-806qmkyz.js → react-v8497a41.js} +13 -8
- package/dist/{react-6tss0r9f.js → react-wqn4sx0n.js} +265 -2137
- package/dist/react.js +500 -482
- package/dist/replay-j18rw92k.js +258 -0
- package/dist/replay-vtg0vqj2.js +257 -0
- package/dist/{storageview-7cv0vpdm.js → storageview-6xj7zb63.js} +11 -7
- package/dist/{storageview-dyhpgt8f.js → storageview-pzn8yaad.js} +11 -7
- package/dist/styles/force.d.ts +66 -0
- package/dist/ui/bindings.d.ts +31 -5
- package/dist/ui/changes.d.ts +49 -0
- package/dist/ui/cssauto.d.ts +119 -0
- package/dist/ui/cssedit.d.ts +80 -0
- package/dist/ui/domedit.d.ts +99 -0
- package/dist/ui/domtree.d.ts +26 -1
- package/dist/ui/elementsview.d.ts +19 -2
- package/dist/ui/htmledit.d.ts +62 -0
- package/dist/ui/inspector.d.ts +6 -1
- package/dist/ui/keys.d.ts +12 -8
- package/dist/ui/pane.d.ts +0 -2
- package/dist/ui/panel.d.ts +3 -0
- package/dist/ui/prefs.d.ts +30 -10
- package/dist/ui/settings.d.ts +2 -0
- package/dist/ui/size.d.ts +14 -22
- package/dist/ui/stylesview.d.ts +30 -1
- package/package.json +1 -1
- package/skills/devknobs/SKILL.md +95 -0
- package/dist/elementsview-1wsxcdtj.js +0 -2874
- package/dist/elementsview-3kv34jfx.js +0 -2873
- package/dist/index-78r0f8pw.js +0 -27
- package/dist/react-adky72h9.js +0 -29
|
@@ -1,56 +1,106 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import {
|
|
3
|
-
GRAB_COLORS,
|
|
4
|
-
GRAB_COLOR_NAMES,
|
|
5
|
-
boxTint,
|
|
6
|
-
copyText,
|
|
7
|
-
grabColor,
|
|
8
|
-
isCLike,
|
|
9
|
-
isElement
|
|
10
|
-
} from "./react-806qmkyz.js";
|
|
11
2
|
import {
|
|
12
3
|
quietFetch
|
|
13
|
-
} from "./react-
|
|
14
|
-
import {
|
|
15
|
-
middle,
|
|
16
|
-
shorthand,
|
|
17
|
-
sizeText,
|
|
18
|
-
tidy
|
|
19
|
-
} from "./react-qgz9afa2.js";
|
|
20
|
-
import"./react-adky72h9.js";
|
|
4
|
+
} from "./react-1gqwa2yw.js";
|
|
21
5
|
import {
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
6
|
+
elementSelector,
|
|
7
|
+
nearestSemanticSelector,
|
|
8
|
+
selectorTarget
|
|
9
|
+
} from "./react-5rq7bnsy.js";
|
|
10
|
+
|
|
11
|
+
// src/grab/fiber.ts
|
|
12
|
+
var FORWARD_REF = Symbol.for("react.forward_ref");
|
|
13
|
+
var MEMO = Symbol.for("react.memo");
|
|
14
|
+
function isFiber(value) {
|
|
15
|
+
return typeof value === "object" && value !== null && "tag" in value && "stateNode" in value && "return" in value && "child" in value && "sibling" in value;
|
|
16
|
+
}
|
|
17
|
+
function isFiberKey(key) {
|
|
18
|
+
return key.startsWith("__reactFiber") || key.startsWith("__reactInternalInstance$");
|
|
19
|
+
}
|
|
20
|
+
function getFiber(element) {
|
|
21
|
+
for (const key of Object.keys(element)) {
|
|
22
|
+
if (!isFiberKey(key))
|
|
23
|
+
continue;
|
|
24
|
+
const fiber = Reflect.get(element, key);
|
|
25
|
+
if (isFiber(fiber))
|
|
26
|
+
return fiber;
|
|
27
|
+
}
|
|
28
|
+
return null;
|
|
29
|
+
}
|
|
30
|
+
function nearestFiberElement(element) {
|
|
31
|
+
let current = element;
|
|
32
|
+
while (current?.ownerDocument === element.ownerDocument) {
|
|
33
|
+
if (getFiber(current))
|
|
34
|
+
return current;
|
|
35
|
+
if (current.parentElement) {
|
|
36
|
+
current = current.parentElement;
|
|
37
|
+
continue;
|
|
38
|
+
}
|
|
39
|
+
const root = current.getRootNode();
|
|
40
|
+
current = "host" in root ? root.host : null;
|
|
41
|
+
}
|
|
42
|
+
return element;
|
|
43
|
+
}
|
|
44
|
+
function typeName(value) {
|
|
45
|
+
const displayName = Reflect.get(value, "displayName");
|
|
46
|
+
if (typeof displayName === "string" && displayName)
|
|
47
|
+
return displayName;
|
|
48
|
+
const name = Reflect.get(value, "name");
|
|
49
|
+
return typeof name === "string" && name ? name : null;
|
|
50
|
+
}
|
|
51
|
+
function displayName(type) {
|
|
52
|
+
if (typeof type === "string")
|
|
53
|
+
return type;
|
|
54
|
+
if (typeof type !== "function" && typeof type !== "object" || type === null)
|
|
55
|
+
return null;
|
|
56
|
+
const own = typeName(type);
|
|
57
|
+
if (own)
|
|
58
|
+
return own;
|
|
59
|
+
const seen = new Set;
|
|
60
|
+
let current = type;
|
|
61
|
+
while (typeof current === "object" && current !== null && !seen.has(current)) {
|
|
62
|
+
seen.add(current);
|
|
63
|
+
current = Reflect.get(current, "type") ?? Reflect.get(current, "render");
|
|
64
|
+
}
|
|
65
|
+
return typeof current === "function" ? typeName(current) : null;
|
|
66
|
+
}
|
|
67
|
+
function isComposite(fiber) {
|
|
68
|
+
const type = fiber.type;
|
|
69
|
+
if (typeof type === "function")
|
|
70
|
+
return true;
|
|
71
|
+
if (typeof type !== "object" || type === null)
|
|
72
|
+
return false;
|
|
73
|
+
const tag = Reflect.get(type, "$$typeof");
|
|
74
|
+
return tag === FORWARD_REF || tag === MEMO;
|
|
75
|
+
}
|
|
76
|
+
function hasKeyedSibling(fiber) {
|
|
77
|
+
for (let sibling = fiber.return?.child ?? null;sibling; sibling = sibling.sibling) {
|
|
78
|
+
if (sibling !== fiber && sibling.key !== null)
|
|
79
|
+
return true;
|
|
80
|
+
}
|
|
81
|
+
return false;
|
|
82
|
+
}
|
|
83
|
+
function listKey(fiber) {
|
|
84
|
+
let crossed = 0;
|
|
85
|
+
for (let current = fiber;current; current = current.return) {
|
|
86
|
+
if (current.key !== null && hasKeyedSibling(current))
|
|
87
|
+
return String(current.key);
|
|
88
|
+
if (isComposite(current) && ++crossed === 2)
|
|
89
|
+
break;
|
|
90
|
+
}
|
|
91
|
+
return null;
|
|
92
|
+
}
|
|
93
|
+
function componentNames(fiber, max, accept) {
|
|
94
|
+
const names = [];
|
|
95
|
+
for (let current = fiber;current && names.length < max; current = current.return) {
|
|
96
|
+
if (!isComposite(current))
|
|
97
|
+
continue;
|
|
98
|
+
const name = displayName(current.type);
|
|
99
|
+
if (name && accept(name))
|
|
100
|
+
names.push(name);
|
|
101
|
+
}
|
|
102
|
+
return names;
|
|
103
|
+
}
|
|
54
104
|
|
|
55
105
|
// src/grab/preview.ts
|
|
56
106
|
var ELEMENT_NODE = 1;
|
|
@@ -226,361 +276,32 @@ function htmlPreview(element) {
|
|
|
226
276
|
return text ? `<${tag}${attrs}>${text}</${tag}>` : `<${tag}${attrs} />`;
|
|
227
277
|
}
|
|
228
278
|
|
|
229
|
-
//
|
|
230
|
-
var
|
|
231
|
-
var
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
return {
|
|
242
|
-
"text/plain": payload.content,
|
|
243
|
-
"text/html": `<meta charset='utf-8'><pre><code>${escapeText(payload.content)}</code></pre>`,
|
|
244
|
-
[DEVKNOBS_TYPE]: JSON.stringify({ ...payload, timestamp: now }),
|
|
245
|
-
[REACT_GRAB_TYPE]: JSON.stringify({
|
|
246
|
-
version: "devknobs",
|
|
247
|
-
content: payload.content,
|
|
248
|
-
entries,
|
|
249
|
-
timestamp: now
|
|
250
|
-
})
|
|
251
|
-
};
|
|
252
|
-
}
|
|
253
|
-
function copyGrab(payload) {
|
|
254
|
-
return copyText(payload.content, clipboardData(payload));
|
|
255
|
-
}
|
|
256
|
-
|
|
257
|
-
// src/grab/fiber.ts
|
|
258
|
-
var FORWARD_REF = Symbol.for("react.forward_ref");
|
|
259
|
-
var MEMO = Symbol.for("react.memo");
|
|
260
|
-
function isFiber(value) {
|
|
261
|
-
return typeof value === "object" && value !== null && "tag" in value && "stateNode" in value && "return" in value && "child" in value && "sibling" in value;
|
|
262
|
-
}
|
|
263
|
-
function isFiberKey(key) {
|
|
264
|
-
return key.startsWith("__reactFiber") || key.startsWith("__reactInternalInstance$");
|
|
265
|
-
}
|
|
266
|
-
function getFiber(element) {
|
|
267
|
-
for (const key of Object.keys(element)) {
|
|
268
|
-
if (!isFiberKey(key))
|
|
269
|
-
continue;
|
|
270
|
-
const fiber = Reflect.get(element, key);
|
|
271
|
-
if (isFiber(fiber))
|
|
272
|
-
return fiber;
|
|
273
|
-
}
|
|
274
|
-
return null;
|
|
275
|
-
}
|
|
276
|
-
function nearestFiberElement(element) {
|
|
277
|
-
let current = element;
|
|
278
|
-
while (current?.ownerDocument === element.ownerDocument) {
|
|
279
|
-
if (getFiber(current))
|
|
280
|
-
return current;
|
|
281
|
-
if (current.parentElement) {
|
|
282
|
-
current = current.parentElement;
|
|
283
|
-
continue;
|
|
284
|
-
}
|
|
285
|
-
const root = current.getRootNode();
|
|
286
|
-
current = "host" in root ? root.host : null;
|
|
287
|
-
}
|
|
288
|
-
return element;
|
|
289
|
-
}
|
|
290
|
-
function typeName(value) {
|
|
291
|
-
const displayName = Reflect.get(value, "displayName");
|
|
292
|
-
if (typeof displayName === "string" && displayName)
|
|
293
|
-
return displayName;
|
|
294
|
-
const name = Reflect.get(value, "name");
|
|
295
|
-
return typeof name === "string" && name ? name : null;
|
|
296
|
-
}
|
|
297
|
-
function displayName(type) {
|
|
298
|
-
if (typeof type === "string")
|
|
299
|
-
return type;
|
|
300
|
-
if (typeof type !== "function" && typeof type !== "object" || type === null)
|
|
301
|
-
return null;
|
|
302
|
-
const own = typeName(type);
|
|
303
|
-
if (own)
|
|
304
|
-
return own;
|
|
305
|
-
const seen = new Set;
|
|
306
|
-
let current = type;
|
|
307
|
-
while (typeof current === "object" && current !== null && !seen.has(current)) {
|
|
308
|
-
seen.add(current);
|
|
309
|
-
current = Reflect.get(current, "type") ?? Reflect.get(current, "render");
|
|
310
|
-
}
|
|
311
|
-
return typeof current === "function" ? typeName(current) : null;
|
|
312
|
-
}
|
|
313
|
-
function isComposite(fiber) {
|
|
314
|
-
const type = fiber.type;
|
|
315
|
-
if (typeof type === "function")
|
|
316
|
-
return true;
|
|
317
|
-
if (typeof type !== "object" || type === null)
|
|
318
|
-
return false;
|
|
319
|
-
const tag = Reflect.get(type, "$$typeof");
|
|
320
|
-
return tag === FORWARD_REF || tag === MEMO;
|
|
321
|
-
}
|
|
322
|
-
function hasKeyedSibling(fiber) {
|
|
323
|
-
for (let sibling = fiber.return?.child ?? null;sibling; sibling = sibling.sibling) {
|
|
324
|
-
if (sibling !== fiber && sibling.key !== null)
|
|
325
|
-
return true;
|
|
326
|
-
}
|
|
327
|
-
return false;
|
|
328
|
-
}
|
|
329
|
-
function listKey(fiber) {
|
|
330
|
-
let crossed = 0;
|
|
331
|
-
for (let current = fiber;current; current = current.return) {
|
|
332
|
-
if (current.key !== null && hasKeyedSibling(current))
|
|
333
|
-
return String(current.key);
|
|
334
|
-
if (isComposite(current) && ++crossed === 2)
|
|
335
|
-
break;
|
|
336
|
-
}
|
|
337
|
-
return null;
|
|
338
|
-
}
|
|
339
|
-
function componentNames(fiber, max, accept) {
|
|
340
|
-
const names = [];
|
|
341
|
-
for (let current = fiber;current && names.length < max; current = current.return) {
|
|
342
|
-
if (!isComposite(current))
|
|
343
|
-
continue;
|
|
344
|
-
const name = displayName(current.type);
|
|
345
|
-
if (name && accept(name))
|
|
346
|
-
names.push(name);
|
|
347
|
-
}
|
|
348
|
-
return names;
|
|
349
|
-
}
|
|
350
|
-
|
|
351
|
-
// src/grab/selector.ts
|
|
352
|
-
var VALUE_MAX2 = 120;
|
|
353
|
-
var PREFERRED = [
|
|
354
|
-
"data-testid",
|
|
355
|
-
"data-test-id",
|
|
356
|
-
"data-test",
|
|
357
|
-
"data-cy",
|
|
358
|
-
"data-qa",
|
|
359
|
-
"aria-label",
|
|
360
|
-
"href",
|
|
361
|
-
"src",
|
|
362
|
-
"role",
|
|
363
|
-
"name",
|
|
364
|
-
"title",
|
|
365
|
-
"alt"
|
|
366
|
-
];
|
|
367
|
-
var ACTIONABLE_ROLES = new Set([
|
|
368
|
-
"button",
|
|
369
|
-
"link",
|
|
370
|
-
"checkbox",
|
|
371
|
-
"radio",
|
|
372
|
-
"switch",
|
|
373
|
-
"tab",
|
|
374
|
-
"menuitem",
|
|
375
|
-
"option",
|
|
376
|
-
"textbox",
|
|
377
|
-
"combobox",
|
|
378
|
-
"slider",
|
|
379
|
-
"spinbutton"
|
|
380
|
-
]);
|
|
381
|
-
var IDENTIFIER_QUERY = [
|
|
382
|
-
...PREFERRED.filter((name) => name !== "role").map((name) => `[${name}]`),
|
|
383
|
-
...[...ACTIONABLE_ROLES].map((role) => `[role~="${role}"]`)
|
|
384
|
-
].join(",");
|
|
385
|
-
var GENERIC_QUERY = "button,input,select,textarea";
|
|
386
|
-
var GENERATED_IDS = [
|
|
387
|
-
/^[0-9a-f]{8}(?:-[0-9a-f]{4}){3}-[0-9a-f]{12}$/i,
|
|
388
|
-
/:r[a-z0-9]+:/i,
|
|
389
|
-
/_r_[a-z0-9]+_(?:$|-)/i,
|
|
390
|
-
/«r[a-z0-9]+»/i,
|
|
391
|
-
/^(?:downshift-\d+(?:-|$)|headlessui-[a-z-]+-\d+(?:-|$)|mui-\d+(?:-|$)|radix-\d+(?:-|$)|react-aria-\d+(?:-|$)|react-select-\d+(?:-|$))/i,
|
|
392
|
-
/^ember\d+$/i,
|
|
393
|
-
/^\d+$/
|
|
394
|
-
];
|
|
395
|
-
function isStableId(id) {
|
|
396
|
-
return id.length > 0 && id.length <= VALUE_MAX2 && !GENERATED_IDS.some((pattern) => pattern.test(id));
|
|
397
|
-
}
|
|
398
|
-
function isShadowRoot(node) {
|
|
399
|
-
return "host" in node;
|
|
400
|
-
}
|
|
401
|
-
function escape(element, value) {
|
|
402
|
-
const css = element.ownerDocument.defaultView?.CSS ?? globalThis.CSS;
|
|
403
|
-
return css.escape(value);
|
|
404
|
-
}
|
|
405
|
-
function isPreferred(name, value) {
|
|
406
|
-
if (value.length === 0 || value.length > VALUE_MAX2)
|
|
407
|
-
return false;
|
|
408
|
-
return name !== "role" || value.split(/\s+/).some((role) => ACTIONABLE_ROLES.has(role));
|
|
409
|
-
}
|
|
410
|
-
function isUnique(element, selector) {
|
|
279
|
+
// ../../node_modules/.pnpm/bippy@0.7.3_@types+react@19.2.18_react@19.2.8/node_modules/bippy/dist/rdt-hook.js
|
|
280
|
+
var e = `0.7.3`;
|
|
281
|
+
var t = `bippy-${e}`;
|
|
282
|
+
var n = Object.defineProperty;
|
|
283
|
+
var r = () => {};
|
|
284
|
+
var i = (e2) => e2.__REACT_DEVTOOLS_GLOBAL_HOOK__;
|
|
285
|
+
var a = (e2) => Object.assign(e2, { [Symbol.dispose]: e2 });
|
|
286
|
+
var o = (e2) => {
|
|
287
|
+
let t2 = e2.current.memoizedState;
|
|
288
|
+
return t2 === null || t2 !== undefined && (t2.element === null || t2.element === undefined);
|
|
289
|
+
};
|
|
290
|
+
var s = (e2) => {
|
|
411
291
|
try {
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
} catch {
|
|
292
|
+
Function.prototype.toString.call(e2).indexOf(`^_^`) > -1 && setTimeout(() => {
|
|
293
|
+
throw Error(`React is running in production mode, but dead code elimination has not been applied. Read how to correctly configure React for production: https://react.dev/link/perf-use-production-build`);
|
|
294
|
+
});
|
|
295
|
+
} catch {}
|
|
296
|
+
};
|
|
297
|
+
var c = (e2 = globalThis.__REACT_DEVTOOLS_GLOBAL_HOOK__) => !!(e2 && (`getFiberRoots` in e2) && e2._isBippyHook !== true);
|
|
298
|
+
var l = (e2 = globalThis.__REACT_DEVTOOLS_GLOBAL_HOOK__) => {
|
|
299
|
+
if (!e2 || typeof e2.inject != `function` || c(e2))
|
|
416
300
|
return false;
|
|
417
|
-
}
|
|
418
|
-
}
|
|
419
|
-
function fastSelector(element) {
|
|
420
|
-
const id = element.getAttribute("id");
|
|
421
|
-
let fallback = null;
|
|
422
|
-
if (id) {
|
|
423
|
-
const selector = `#${escape(element, id)}`;
|
|
424
|
-
if (isUnique(element, selector)) {
|
|
425
|
-
if (isStableId(id))
|
|
426
|
-
return { selector, semantic: true };
|
|
427
|
-
fallback = selector;
|
|
428
|
-
}
|
|
429
|
-
}
|
|
430
|
-
for (const name of PREFERRED) {
|
|
431
|
-
const value = element.getAttribute(name);
|
|
432
|
-
if (!value || !isPreferred(name, value))
|
|
433
|
-
continue;
|
|
434
|
-
const attribute = `[${name}=${JSON.stringify(value)}]`;
|
|
435
|
-
if (isUnique(element, attribute))
|
|
436
|
-
return { selector: attribute, semantic: true };
|
|
437
|
-
const tagged = `${element.tagName.toLowerCase()}${attribute}`;
|
|
438
|
-
if (isUnique(element, tagged))
|
|
439
|
-
return { selector: tagged, semantic: true };
|
|
440
|
-
}
|
|
441
|
-
return fallback ? { selector: fallback, semantic: false } : null;
|
|
442
|
-
}
|
|
443
|
-
function nthChildSelector(element) {
|
|
444
|
-
const steps = [];
|
|
445
|
-
const rootNode = element.getRootNode();
|
|
446
|
-
const root = isShadowRoot(rootNode) ? rootNode : element.ownerDocument.body ?? element.ownerDocument.documentElement;
|
|
447
|
-
let current = element;
|
|
448
|
-
while (current) {
|
|
449
|
-
const id = current.getAttribute("id");
|
|
450
|
-
if (id) {
|
|
451
|
-
steps.unshift(`#${escape(current, id)}`);
|
|
452
|
-
break;
|
|
453
|
-
}
|
|
454
|
-
const parent = current.parentNode;
|
|
455
|
-
const tag = current.tagName.toLowerCase();
|
|
456
|
-
if (!parent) {
|
|
457
|
-
steps.unshift(tag);
|
|
458
|
-
break;
|
|
459
|
-
}
|
|
460
|
-
steps.unshift(`${tag}:nth-child(${Array.from(parent.children).indexOf(current) + 1})`);
|
|
461
|
-
if (parent === root) {
|
|
462
|
-
if ("tagName" in root)
|
|
463
|
-
steps.unshift(root.tagName.toLowerCase());
|
|
464
|
-
break;
|
|
465
|
-
}
|
|
466
|
-
current = "tagName" in parent ? parent : null;
|
|
467
|
-
}
|
|
468
|
-
return steps.join(" > ");
|
|
469
|
-
}
|
|
470
|
-
function frameOf(element) {
|
|
471
301
|
try {
|
|
472
|
-
|
|
473
|
-
return frame?.hasAttribute("data-devknobs-frame") ? null : frame;
|
|
302
|
+
return Function.prototype.toString.call(e2.inject).includes(`(injected)`);
|
|
474
303
|
} catch {
|
|
475
|
-
return
|
|
476
|
-
}
|
|
477
|
-
}
|
|
478
|
-
function elementSelector(element) {
|
|
479
|
-
const local = fastSelector(element) ?? { selector: nthChildSelector(element), semantic: false };
|
|
480
|
-
const root = element.getRootNode();
|
|
481
|
-
const outer = isShadowRoot(root) ? root.host : frameOf(element);
|
|
482
|
-
if (!outer)
|
|
483
|
-
return local;
|
|
484
|
-
const host = elementSelector(outer);
|
|
485
|
-
const join = isShadowRoot(root) ? ">>>" : ">>iframe>>";
|
|
486
|
-
return {
|
|
487
|
-
selector: `${host.selector} ${join} ${local.selector}`,
|
|
488
|
-
semantic: host.semantic && local.semantic
|
|
489
|
-
};
|
|
490
|
-
}
|
|
491
|
-
function semanticSelector(element) {
|
|
492
|
-
const local = fastSelector(element);
|
|
493
|
-
if (!local?.semantic)
|
|
494
|
-
return null;
|
|
495
|
-
const root = element.getRootNode();
|
|
496
|
-
const outer = isShadowRoot(root) ? root.host : frameOf(element);
|
|
497
|
-
if (!outer)
|
|
498
|
-
return local;
|
|
499
|
-
const host = semanticSelector(outer);
|
|
500
|
-
if (!host)
|
|
501
|
-
return null;
|
|
502
|
-
const join = isShadowRoot(root) ? ">>>" : ">>iframe>>";
|
|
503
|
-
return { selector: `${host.selector} ${join} ${local.selector}`, semantic: true };
|
|
504
|
-
}
|
|
505
|
-
function hasIdentifier(element) {
|
|
506
|
-
const id = element.getAttribute("id");
|
|
507
|
-
return Boolean(id && isStableId(id) || element.matches(IDENTIFIER_QUERY));
|
|
508
|
-
}
|
|
509
|
-
function isTarget(element) {
|
|
510
|
-
return hasIdentifier(element) || element.matches(GENERIC_QUERY);
|
|
511
|
-
}
|
|
512
|
-
function isBroad(element) {
|
|
513
|
-
const { body, documentElement } = element.ownerDocument;
|
|
514
|
-
if (element === body || element === documentElement)
|
|
515
|
-
return true;
|
|
516
|
-
if (!body)
|
|
517
|
-
return false;
|
|
518
|
-
const total = body.getElementsByTagName("*").length;
|
|
519
|
-
return total > 0 && element.getElementsByTagName("*").length / total >= 0.5;
|
|
520
|
-
}
|
|
521
|
-
function composedParent2(element) {
|
|
522
|
-
if (element.assignedSlot)
|
|
523
|
-
return element.assignedSlot;
|
|
524
|
-
if (element.parentElement)
|
|
525
|
-
return element.parentElement;
|
|
526
|
-
const root = element.getRootNode();
|
|
527
|
-
return isShadowRoot(root) ? root.host : frameOf(element);
|
|
528
|
-
}
|
|
529
|
-
function selectorTarget(element, accept) {
|
|
530
|
-
const root = element.getRootNode();
|
|
531
|
-
let current = element;
|
|
532
|
-
while (current) {
|
|
533
|
-
if (isTarget(current)) {
|
|
534
|
-
const broad = isBroad(current);
|
|
535
|
-
if (broad && current !== element)
|
|
536
|
-
return element;
|
|
537
|
-
if (!accept || accept(current))
|
|
538
|
-
return current;
|
|
539
|
-
if (broad)
|
|
540
|
-
return current;
|
|
541
|
-
if (!hasIdentifier(current) && current === element)
|
|
542
|
-
return current;
|
|
543
|
-
}
|
|
544
|
-
const parent = composedParent2(current);
|
|
545
|
-
current = parent?.getRootNode() === root ? parent : null;
|
|
546
|
-
}
|
|
547
|
-
return element;
|
|
548
|
-
}
|
|
549
|
-
function nearestSemanticSelector(element) {
|
|
550
|
-
let found = null;
|
|
551
|
-
selectorTarget(element, (candidate) => {
|
|
552
|
-
found = semanticSelector(candidate);
|
|
553
|
-
return found !== null;
|
|
554
|
-
});
|
|
555
|
-
return found;
|
|
556
|
-
}
|
|
557
|
-
|
|
558
|
-
// ../../node_modules/.pnpm/bippy@0.7.3_@types+react@19.2.18_react@19.2.8/node_modules/bippy/dist/rdt-hook.js
|
|
559
|
-
var e = `0.7.3`;
|
|
560
|
-
var t = `bippy-${e}`;
|
|
561
|
-
var n = Object.defineProperty;
|
|
562
|
-
var r = () => {};
|
|
563
|
-
var i = (e2) => e2.__REACT_DEVTOOLS_GLOBAL_HOOK__;
|
|
564
|
-
var a = (e2) => Object.assign(e2, { [Symbol.dispose]: e2 });
|
|
565
|
-
var o = (e2) => {
|
|
566
|
-
let t2 = e2.current.memoizedState;
|
|
567
|
-
return t2 === null || t2 !== undefined && (t2.element === null || t2.element === undefined);
|
|
568
|
-
};
|
|
569
|
-
var s = (e2) => {
|
|
570
|
-
try {
|
|
571
|
-
Function.prototype.toString.call(e2).indexOf(`^_^`) > -1 && setTimeout(() => {
|
|
572
|
-
throw Error(`React is running in production mode, but dead code elimination has not been applied. Read how to correctly configure React for production: https://react.dev/link/perf-use-production-build`);
|
|
573
|
-
});
|
|
574
|
-
} catch {}
|
|
575
|
-
};
|
|
576
|
-
var c = (e2 = globalThis.__REACT_DEVTOOLS_GLOBAL_HOOK__) => !!(e2 && (`getFiberRoots` in e2) && e2._isBippyHook !== true);
|
|
577
|
-
var l = (e2 = globalThis.__REACT_DEVTOOLS_GLOBAL_HOOK__) => {
|
|
578
|
-
if (!e2 || typeof e2.inject != `function` || c(e2))
|
|
579
|
-
return false;
|
|
580
|
-
try {
|
|
581
|
-
return Function.prototype.toString.call(e2.inject).includes(`(injected)`);
|
|
582
|
-
} catch {
|
|
583
|
-
return false;
|
|
304
|
+
return false;
|
|
584
305
|
}
|
|
585
306
|
};
|
|
586
307
|
var u = new Set;
|
|
@@ -2122,11 +1843,11 @@ function tagPlaces(content, tag) {
|
|
|
2122
1843
|
}
|
|
2123
1844
|
return places;
|
|
2124
1845
|
}
|
|
2125
|
-
function
|
|
1846
|
+
function escape(text) {
|
|
2126
1847
|
return text.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
2127
1848
|
}
|
|
2128
1849
|
function jsxCalls(code, tag, host) {
|
|
2129
|
-
const name = host ? `["']${
|
|
1850
|
+
const name = host ? `["']${escape(tag)}["']` : escape(tag);
|
|
2130
1851
|
const pattern = new RegExp(`(?<![\\w$.])[\\w$.]*(jsxs?(?:DEV)?|createElement)\\(\\s*${name}\\s*,`, "g");
|
|
2131
1852
|
return Array.from(code.matchAll(pattern), (match) => ({
|
|
2132
1853
|
start: match.index,
|
|
@@ -2169,12 +1890,12 @@ function calleeAt(code, call) {
|
|
|
2169
1890
|
return IDENTIFIER.test(name) && OPENS_CALL.test(code) ? name : null;
|
|
2170
1891
|
}
|
|
2171
1892
|
function callOffsets(code, name) {
|
|
2172
|
-
const pattern = new RegExp(`(?<![\\w$])(function\\s*\\*?\\s*)?${
|
|
1893
|
+
const pattern = new RegExp(`(?<![\\w$])(function\\s*\\*?\\s*)?${escape(name)}\\s*\\(`, "g");
|
|
2173
1894
|
return Array.from(code.matchAll(pattern)).filter((match) => match[1] === undefined).map((match) => match.index);
|
|
2174
1895
|
}
|
|
2175
1896
|
var BODY = /\s*(?::[^={}()]*)?(?:=>)?\s*[{(]/y;
|
|
2176
1897
|
function bodyOf(code, name) {
|
|
2177
|
-
const pattern = new RegExp(`(?<![\\w$])(?:function\\s*\\*?\\s*${
|
|
1898
|
+
const pattern = new RegExp(`(?<![\\w$])(?:function\\s*\\*?\\s*${escape(name)}\\s*|${escape(name)}\\s*=\\s*(?:async\\s*)?(?:function\\s*\\*?\\s*)?)\\(`, "g");
|
|
2178
1899
|
const found = Array.from(code.matchAll(pattern));
|
|
2179
1900
|
const [match] = found;
|
|
2180
1901
|
if (!match || found.length !== 1)
|
|
@@ -3048,1766 +2769,4 @@ async function grabContext(elements, options = {}) {
|
|
|
3048
2769
|
return { content: joinEntries(entries), entries };
|
|
3049
2770
|
}
|
|
3050
2771
|
|
|
3051
|
-
|
|
3052
|
-
var DWELL = 80;
|
|
3053
|
-
var SLOW = 0.3;
|
|
3054
|
-
function settles(hover) {
|
|
3055
|
-
return !hover.boxed || hover.speed < SLOW || hover.held >= DWELL;
|
|
3056
|
-
}
|
|
3057
|
-
function speedOf(from, to, elapsed) {
|
|
3058
|
-
return Math.hypot(to.x - from.x, to.y - from.y) / Math.max(elapsed, 1);
|
|
3059
|
-
}
|
|
3060
|
-
|
|
3061
|
-
// src/grab/navigate.ts
|
|
3062
|
-
var HISTORY = 50;
|
|
3063
|
-
function stepOf(event) {
|
|
3064
|
-
switch (event.key) {
|
|
3065
|
-
case "ArrowUp":
|
|
3066
|
-
return "up";
|
|
3067
|
-
case "ArrowDown":
|
|
3068
|
-
return "down";
|
|
3069
|
-
case "ArrowLeft":
|
|
3070
|
-
return "left";
|
|
3071
|
-
case "ArrowRight":
|
|
3072
|
-
return "right";
|
|
3073
|
-
case "Tab":
|
|
3074
|
-
return event.shiftKey ? "left" : "right";
|
|
3075
|
-
default:
|
|
3076
|
-
return null;
|
|
3077
|
-
}
|
|
3078
|
-
}
|
|
3079
|
-
function firstChild(element, accept) {
|
|
3080
|
-
const children = element.children.length > 0 ? element.children : element.shadowRoot?.children;
|
|
3081
|
-
for (const child of Array.from(children ?? []))
|
|
3082
|
-
if (accept(child))
|
|
3083
|
-
return child;
|
|
3084
|
-
return null;
|
|
3085
|
-
}
|
|
3086
|
-
function createNavigator(accept = isGrabbable) {
|
|
3087
|
-
let history = [];
|
|
3088
|
-
function up(current) {
|
|
3089
|
-
let parent = composedParent(current);
|
|
3090
|
-
while (parent && !accept(parent)) {
|
|
3091
|
-
const tag = parent.tagName.toLowerCase();
|
|
3092
|
-
if (tag === "body" || tag === "html")
|
|
3093
|
-
return null;
|
|
3094
|
-
parent = composedParent(parent);
|
|
3095
|
-
}
|
|
3096
|
-
if (!parent)
|
|
3097
|
-
return null;
|
|
3098
|
-
history.push(current);
|
|
3099
|
-
if (history.length > HISTORY)
|
|
3100
|
-
history = history.slice(-HISTORY);
|
|
3101
|
-
return parent;
|
|
3102
|
-
}
|
|
3103
|
-
function down(current) {
|
|
3104
|
-
const previous = history.pop();
|
|
3105
|
-
if (previous?.isConnected)
|
|
3106
|
-
return previous;
|
|
3107
|
-
history = [];
|
|
3108
|
-
return firstChild(current, accept);
|
|
3109
|
-
}
|
|
3110
|
-
function along(current, forward) {
|
|
3111
|
-
const sibling = (element) => forward ? element.nextElementSibling : element.previousElementSibling;
|
|
3112
|
-
for (let from = current;from; from = composedParent(from)) {
|
|
3113
|
-
const tag = from.tagName.toLowerCase();
|
|
3114
|
-
if (tag === "body" || tag === "html")
|
|
3115
|
-
return null;
|
|
3116
|
-
for (let next = sibling(from);next; next = sibling(next)) {
|
|
3117
|
-
if (!accept(next))
|
|
3118
|
-
continue;
|
|
3119
|
-
history = [];
|
|
3120
|
-
return next;
|
|
3121
|
-
}
|
|
3122
|
-
}
|
|
3123
|
-
return null;
|
|
3124
|
-
}
|
|
3125
|
-
return {
|
|
3126
|
-
next(step, current) {
|
|
3127
|
-
if (step === "up")
|
|
3128
|
-
return up(current);
|
|
3129
|
-
if (step === "down")
|
|
3130
|
-
return down(current);
|
|
3131
|
-
return along(current, step === "right");
|
|
3132
|
-
},
|
|
3133
|
-
clear() {
|
|
3134
|
-
history = [];
|
|
3135
|
-
}
|
|
3136
|
-
};
|
|
3137
|
-
}
|
|
3138
|
-
|
|
3139
|
-
// src/grab/colorvalue.ts
|
|
3140
|
-
var NAMED = {
|
|
3141
|
-
black: "#000000",
|
|
3142
|
-
silver: "#c0c0c0",
|
|
3143
|
-
gray: "#808080",
|
|
3144
|
-
grey: "#808080",
|
|
3145
|
-
white: "#ffffff",
|
|
3146
|
-
maroon: "#800000",
|
|
3147
|
-
red: "#ff0000",
|
|
3148
|
-
purple: "#800080",
|
|
3149
|
-
fuchsia: "#ff00ff",
|
|
3150
|
-
green: "#008000",
|
|
3151
|
-
lime: "#00ff00",
|
|
3152
|
-
olive: "#808000",
|
|
3153
|
-
yellow: "#ffff00",
|
|
3154
|
-
navy: "#000080",
|
|
3155
|
-
blue: "#0000ff",
|
|
3156
|
-
teal: "#008080",
|
|
3157
|
-
aqua: "#00ffff",
|
|
3158
|
-
orange: "#ffa500",
|
|
3159
|
-
rebeccapurple: "#663399"
|
|
3160
|
-
};
|
|
3161
|
-
var WHITE = { red: 255, green: 255, blue: 255, alpha: 1 };
|
|
3162
|
-
function hex(value) {
|
|
3163
|
-
const match = /^#([0-9a-f]{3,4}|[0-9a-f]{6}|[0-9a-f]{8})$/i.exec(value);
|
|
3164
|
-
if (!match?.[1])
|
|
3165
|
-
return null;
|
|
3166
|
-
const digits = match[1];
|
|
3167
|
-
const wide = digits.length <= 4 ? [...digits].map((digit) => digit + digit).join("") : digits;
|
|
3168
|
-
const channel = (at2) => Number.parseInt(wide.slice(at2, at2 + 2), 16);
|
|
3169
|
-
return {
|
|
3170
|
-
red: channel(0),
|
|
3171
|
-
green: channel(2),
|
|
3172
|
-
blue: channel(4),
|
|
3173
|
-
alpha: wide.length === 8 ? channel(6) / 255 : 1
|
|
3174
|
-
};
|
|
3175
|
-
}
|
|
3176
|
-
function degrees(value) {
|
|
3177
|
-
const number = Number.parseFloat(value);
|
|
3178
|
-
if (value.endsWith("turn"))
|
|
3179
|
-
return number * 360;
|
|
3180
|
-
if (value.endsWith("grad"))
|
|
3181
|
-
return number * 0.9;
|
|
3182
|
-
if (value.endsWith("rad"))
|
|
3183
|
-
return number * 180 / Math.PI;
|
|
3184
|
-
return number;
|
|
3185
|
-
}
|
|
3186
|
-
function hsl(value) {
|
|
3187
|
-
const match = /^hsla?\(([^)]+)\)$/i.exec(value);
|
|
3188
|
-
if (!match?.[1])
|
|
3189
|
-
return null;
|
|
3190
|
-
const parts = match[1].split(/[\s,/]+/).filter(Boolean);
|
|
3191
|
-
if (parts.length < 3 || parts.length > 4)
|
|
3192
|
-
return null;
|
|
3193
|
-
const [h4 = "", s3 = "", l3 = "", a2] = parts;
|
|
3194
|
-
const hue = (degrees(h4) % 360 + 360) % 360 / 30;
|
|
3195
|
-
const saturation = Math.min(Math.max(Number.parseFloat(s3) / 100, 0), 1);
|
|
3196
|
-
const lightness = Math.min(Math.max(Number.parseFloat(l3) / 100, 0), 1);
|
|
3197
|
-
const alpha = a2 === undefined ? 1 : a2.endsWith("%") ? Number.parseFloat(a2) / 100 : Number.parseFloat(a2);
|
|
3198
|
-
if (![hue, saturation, lightness, alpha].every(Number.isFinite))
|
|
3199
|
-
return null;
|
|
3200
|
-
const reach = saturation * Math.min(lightness, 1 - lightness);
|
|
3201
|
-
const channel = (n2) => {
|
|
3202
|
-
const k3 = (n2 + hue) % 12;
|
|
3203
|
-
return 255 * (lightness - reach * Math.max(-1, Math.min(k3 - 3, 9 - k3, 1)));
|
|
3204
|
-
};
|
|
3205
|
-
return { red: channel(0), green: channel(8), blue: channel(4), alpha };
|
|
3206
|
-
}
|
|
3207
|
-
function parseCss(value) {
|
|
3208
|
-
const text = value.trim().toLowerCase();
|
|
3209
|
-
if (text === "transparent")
|
|
3210
|
-
return { red: 0, green: 0, blue: 0, alpha: 0 };
|
|
3211
|
-
const named = Object.hasOwn(NAMED, text) ? NAMED[text] : undefined;
|
|
3212
|
-
return hex(named ?? text) ?? hsl(text) ?? parseColor(text);
|
|
3213
|
-
}
|
|
3214
|
-
function composite(top, under) {
|
|
3215
|
-
const alpha = top.alpha + under.alpha * (1 - top.alpha);
|
|
3216
|
-
if (alpha <= 0)
|
|
3217
|
-
return { red: 0, green: 0, blue: 0, alpha: 0 };
|
|
3218
|
-
const mix = (over, below) => (over * top.alpha + below * under.alpha * (1 - top.alpha)) / alpha;
|
|
3219
|
-
return {
|
|
3220
|
-
red: mix(top.red, under.red),
|
|
3221
|
-
green: mix(top.green, under.green),
|
|
3222
|
-
blue: mix(top.blue, under.blue),
|
|
3223
|
-
alpha
|
|
3224
|
-
};
|
|
3225
|
-
}
|
|
3226
|
-
function byte(channel) {
|
|
3227
|
-
return Math.min(255, Math.max(0, Math.round(channel)));
|
|
3228
|
-
}
|
|
3229
|
-
function shortColor(color) {
|
|
3230
|
-
const channels = [byte(color.red), byte(color.green), byte(color.blue)];
|
|
3231
|
-
const alpha = Math.round(color.alpha * 100) / 100;
|
|
3232
|
-
if (alpha <= 0)
|
|
3233
|
-
return "transparent";
|
|
3234
|
-
if (alpha >= 1)
|
|
3235
|
-
return `#${channels.map((one) => one.toString(16).padStart(2, "0")).join("")}`;
|
|
3236
|
-
return `rgb(${channels.join(" ")} / ${alpha})`;
|
|
3237
|
-
}
|
|
3238
|
-
var WALK_CAP = 20;
|
|
3239
|
-
function walkBackgrounds(start, read, parent, cap = WALK_CAP) {
|
|
3240
|
-
const found = [];
|
|
3241
|
-
let node = start;
|
|
3242
|
-
while (node !== null && found.length <= cap) {
|
|
3243
|
-
const color = read(node);
|
|
3244
|
-
found.push(color);
|
|
3245
|
-
if (color && color.alpha >= 1)
|
|
3246
|
-
break;
|
|
3247
|
-
node = parent(node);
|
|
3248
|
-
}
|
|
3249
|
-
return found;
|
|
3250
|
-
}
|
|
3251
|
-
function effectiveBackground(backgrounds) {
|
|
3252
|
-
let color = WHITE;
|
|
3253
|
-
for (let at2 = backgrounds.length - 1;at2 >= 0; at2 -= 1) {
|
|
3254
|
-
const layer = backgrounds[at2];
|
|
3255
|
-
if (layer && layer.alpha > 0)
|
|
3256
|
-
color = composite(layer, color);
|
|
3257
|
-
}
|
|
3258
|
-
return color;
|
|
3259
|
-
}
|
|
3260
|
-
function contrastRatio(a2, b4) {
|
|
3261
|
-
const first = luminance(a2.red, a2.green, a2.blue);
|
|
3262
|
-
const second = luminance(b4.red, b4.green, b4.blue);
|
|
3263
|
-
return (Math.max(first, second) + 0.05) / (Math.min(first, second) + 0.05);
|
|
3264
|
-
}
|
|
3265
|
-
var LARGE = 24;
|
|
3266
|
-
var LARGE_BOLD = 18.66;
|
|
3267
|
-
var BOLD = 700;
|
|
3268
|
-
function aaRatio(size, weight) {
|
|
3269
|
-
return size >= LARGE || size >= LARGE_BOLD && weight >= BOLD ? 3 : 4.5;
|
|
3270
|
-
}
|
|
3271
|
-
function passesAA(ratio, size, weight) {
|
|
3272
|
-
return ratio >= aaRatio(size, weight);
|
|
3273
|
-
}
|
|
3274
|
-
|
|
3275
|
-
// src/grab/card.ts
|
|
3276
|
-
var CARD_KEYS = [
|
|
3277
|
-
"color",
|
|
3278
|
-
"background",
|
|
3279
|
-
"font",
|
|
3280
|
-
"type",
|
|
3281
|
-
"contrast",
|
|
3282
|
-
"margin",
|
|
3283
|
-
"padding"
|
|
3284
|
-
];
|
|
3285
|
-
var CARD_LABELS = {
|
|
3286
|
-
color: "color",
|
|
3287
|
-
background: "background",
|
|
3288
|
-
font: "font",
|
|
3289
|
-
type: "",
|
|
3290
|
-
contrast: "contrast",
|
|
3291
|
-
margin: "margin",
|
|
3292
|
-
padding: "padding"
|
|
3293
|
-
};
|
|
3294
|
-
function colorRow(key, color, quiet = false) {
|
|
3295
|
-
const text = shortColor(color);
|
|
3296
|
-
return quiet ? { key, text, swatch: text, quiet } : { key, text, swatch: text };
|
|
3297
|
-
}
|
|
3298
|
-
function cardRows(facts) {
|
|
3299
|
-
const rows = [];
|
|
3300
|
-
const own = facts.backgrounds[0] ?? null;
|
|
3301
|
-
const behind = effectiveBackground(facts.backgrounds);
|
|
3302
|
-
if (facts.text && facts.color)
|
|
3303
|
-
rows.push(colorRow("color", facts.color));
|
|
3304
|
-
if (own && own.alpha > 0)
|
|
3305
|
-
rows.push(colorRow("background", own));
|
|
3306
|
-
else if (facts.text)
|
|
3307
|
-
rows.push(colorRow("background", behind, true));
|
|
3308
|
-
if (facts.text) {
|
|
3309
|
-
const parts = [`${tidy(facts.fontSize)} / ${tidy(facts.lineHeight)}`, facts.fontWeight];
|
|
3310
|
-
if (facts.letterSpacing !== "normal")
|
|
3311
|
-
parts.push(tidy(facts.letterSpacing));
|
|
3312
|
-
if (facts.family)
|
|
3313
|
-
rows.push({ key: "font", text: facts.family });
|
|
3314
|
-
rows.push({ key: facts.family ? "type" : "font", text: parts.join(" · ") });
|
|
3315
|
-
if (facts.color) {
|
|
3316
|
-
const ratio = contrastRatio(composite(facts.color, behind), behind);
|
|
3317
|
-
const size = pxOf(facts.fontSize) ?? 16;
|
|
3318
|
-
const weight = Number.parseFloat(facts.fontWeight) || 400;
|
|
3319
|
-
rows.push({ key: "contrast", text: ratio.toFixed(2), pass: passesAA(ratio, size, weight) });
|
|
3320
|
-
}
|
|
3321
|
-
}
|
|
3322
|
-
const margin = shorthand(facts.margin);
|
|
3323
|
-
if (margin)
|
|
3324
|
-
rows.push({ key: "margin", text: margin });
|
|
3325
|
-
const padding = shorthand(facts.padding);
|
|
3326
|
-
if (padding)
|
|
3327
|
-
rows.push({ key: "padding", text: padding });
|
|
3328
|
-
return rows;
|
|
3329
|
-
}
|
|
3330
|
-
|
|
3331
|
-
// src/grab/fontused.ts
|
|
3332
|
-
var GENERIC = new Set([
|
|
3333
|
-
"serif",
|
|
3334
|
-
"sans-serif",
|
|
3335
|
-
"monospace",
|
|
3336
|
-
"cursive",
|
|
3337
|
-
"fantasy",
|
|
3338
|
-
"system-ui",
|
|
3339
|
-
"ui-serif",
|
|
3340
|
-
"ui-sans-serif",
|
|
3341
|
-
"ui-monospace",
|
|
3342
|
-
"ui-rounded",
|
|
3343
|
-
"math",
|
|
3344
|
-
"emoji",
|
|
3345
|
-
"fangsong",
|
|
3346
|
-
"-apple-system",
|
|
3347
|
-
"blinkmacsystemfont"
|
|
3348
|
-
]);
|
|
3349
|
-
function families(stack) {
|
|
3350
|
-
const found = [];
|
|
3351
|
-
let name = "";
|
|
3352
|
-
let quote = "";
|
|
3353
|
-
for (const char of stack) {
|
|
3354
|
-
if (quote) {
|
|
3355
|
-
if (char === quote)
|
|
3356
|
-
quote = "";
|
|
3357
|
-
else
|
|
3358
|
-
name += char;
|
|
3359
|
-
} else if (char === '"' || char === "'")
|
|
3360
|
-
quote = char;
|
|
3361
|
-
else if (char === ",") {
|
|
3362
|
-
found.push(name.trim());
|
|
3363
|
-
name = "";
|
|
3364
|
-
} else
|
|
3365
|
-
name += char;
|
|
3366
|
-
}
|
|
3367
|
-
found.push(name.trim());
|
|
3368
|
-
return found.filter((family) => family !== "");
|
|
3369
|
-
}
|
|
3370
|
-
function isGeneric(family) {
|
|
3371
|
-
return GENERIC.has(family.toLowerCase());
|
|
3372
|
-
}
|
|
3373
|
-
function usedFamily(stack, available) {
|
|
3374
|
-
return families(stack).find((family) => isGeneric(family) || available(family)) ?? null;
|
|
3375
|
-
}
|
|
3376
|
-
function fontCheck(fonts) {
|
|
3377
|
-
return (family) => {
|
|
3378
|
-
if (!fonts)
|
|
3379
|
-
return false;
|
|
3380
|
-
try {
|
|
3381
|
-
return fonts.check(`16px "${family.replace(/["\\]/g, "\\$&")}"`);
|
|
3382
|
-
} catch {
|
|
3383
|
-
return false;
|
|
3384
|
-
}
|
|
3385
|
-
};
|
|
3386
|
-
}
|
|
3387
|
-
|
|
3388
|
-
// src/grab/cardread.ts
|
|
3389
|
-
var TEXT_CAP = 40;
|
|
3390
|
-
var TEXT_CONTROLS = new Set(["INPUT", "TEXTAREA", "SELECT"]);
|
|
3391
|
-
function parentOf(element) {
|
|
3392
|
-
if (element.parentElement)
|
|
3393
|
-
return element.parentElement;
|
|
3394
|
-
const root = element.getRootNode();
|
|
3395
|
-
return root instanceof ShadowRoot ? root.host : null;
|
|
3396
|
-
}
|
|
3397
|
-
function hasOwnText(element) {
|
|
3398
|
-
if (TEXT_CONTROLS.has(element.tagName))
|
|
3399
|
-
return true;
|
|
3400
|
-
const nodes = element.childNodes;
|
|
3401
|
-
for (let at2 = 0;at2 < nodes.length && at2 < TEXT_CAP; at2 += 1) {
|
|
3402
|
-
const node = nodes[at2];
|
|
3403
|
-
if (node?.nodeType === 3 && (node.textContent ?? "").trim() !== "")
|
|
3404
|
-
return true;
|
|
3405
|
-
}
|
|
3406
|
-
return false;
|
|
3407
|
-
}
|
|
3408
|
-
function readFacts(element, style, colorOf) {
|
|
3409
|
-
const text = hasOwnText(element);
|
|
3410
|
-
return {
|
|
3411
|
-
text,
|
|
3412
|
-
color: colorOf(style.color),
|
|
3413
|
-
backgrounds: walkBackgrounds(element, (node) => colorOf((node === element ? style : getComputedStyle(node)).backgroundColor), parentOf),
|
|
3414
|
-
family: text ? usedFamily(style.fontFamily, fontCheck(element.ownerDocument.fonts)) : null,
|
|
3415
|
-
fontSize: style.fontSize,
|
|
3416
|
-
lineHeight: style.lineHeight,
|
|
3417
|
-
fontWeight: style.fontWeight,
|
|
3418
|
-
letterSpacing: style.letterSpacing
|
|
3419
|
-
};
|
|
3420
|
-
}
|
|
3421
|
-
function quadsOf(element, bounds) {
|
|
3422
|
-
const read = Reflect.get(element, "getBoxQuads");
|
|
3423
|
-
if (typeof read !== "function")
|
|
3424
|
-
return null;
|
|
3425
|
-
const found = new Map;
|
|
3426
|
-
for (const ring of RINGS) {
|
|
3427
|
-
let answer = null;
|
|
3428
|
-
try {
|
|
3429
|
-
answer = Reflect.apply(read, element, [{ box: ring }]);
|
|
3430
|
-
} catch {
|
|
3431
|
-
return null;
|
|
3432
|
-
}
|
|
3433
|
-
const quad = oneQuad(answer);
|
|
3434
|
-
if (!quad)
|
|
3435
|
-
return null;
|
|
3436
|
-
found.set(ring, quad);
|
|
3437
|
-
}
|
|
3438
|
-
const [margin, border, padding, content] = RINGS.map((ring) => found.get(ring));
|
|
3439
|
-
if (!margin || !border || !padding || !content)
|
|
3440
|
-
return null;
|
|
3441
|
-
const laid = element instanceof HTMLElement ? { width: element.offsetWidth, height: element.offsetHeight } : null;
|
|
3442
|
-
if (isPlain(border, laid))
|
|
3443
|
-
return null;
|
|
3444
|
-
return alignQuads({ margin, border, padding, content }, { x: bounds.left, y: bounds.top });
|
|
3445
|
-
}
|
|
3446
|
-
function readBox(element, style) {
|
|
3447
|
-
const bounds = element.getBoundingClientRect();
|
|
3448
|
-
if (!hasBox(style.display, bounds))
|
|
3449
|
-
return null;
|
|
3450
|
-
return { model: boxModel(style), quads: quadsOf(element, bounds) };
|
|
3451
|
-
}
|
|
3452
|
-
|
|
3453
|
-
// src/grab/cardview.ts
|
|
3454
|
-
function span(className, text = "") {
|
|
3455
|
-
const node = document.createElement("span");
|
|
3456
|
-
node.className = className;
|
|
3457
|
-
if (text)
|
|
3458
|
-
node.textContent = text;
|
|
3459
|
-
return node;
|
|
3460
|
-
}
|
|
3461
|
-
function say(node, text) {
|
|
3462
|
-
if (node.textContent !== text)
|
|
3463
|
-
node.textContent = text;
|
|
3464
|
-
}
|
|
3465
|
-
function show(node, on2) {
|
|
3466
|
-
if (node.hidden === on2)
|
|
3467
|
-
node.hidden = !on2;
|
|
3468
|
-
}
|
|
3469
|
-
function mark(className, name) {
|
|
3470
|
-
const node = span(className);
|
|
3471
|
-
node.append(icon(name, 12));
|
|
3472
|
-
node.hidden = true;
|
|
3473
|
-
return node;
|
|
3474
|
-
}
|
|
3475
|
-
function createCardView() {
|
|
3476
|
-
const size = span("size");
|
|
3477
|
-
const rows = document.createElement("div");
|
|
3478
|
-
rows.className = "rows";
|
|
3479
|
-
rows.hidden = true;
|
|
3480
|
-
const nodes = new Map;
|
|
3481
|
-
for (const key of CARD_KEYS) {
|
|
3482
|
-
const node = document.createElement("div");
|
|
3483
|
-
node.className = "info";
|
|
3484
|
-
node.hidden = true;
|
|
3485
|
-
const value = span("val");
|
|
3486
|
-
const swatch = span("dot");
|
|
3487
|
-
swatch.hidden = true;
|
|
3488
|
-
const pass = mark("mark", "check");
|
|
3489
|
-
const fail = mark("mark fail", "x");
|
|
3490
|
-
const text = span("text");
|
|
3491
|
-
value.append(swatch, text, pass, fail);
|
|
3492
|
-
node.append(span("key", CARD_LABELS[key]), value);
|
|
3493
|
-
rows.append(node);
|
|
3494
|
-
nodes.set(key, { node, swatch, pass, fail, text });
|
|
3495
|
-
}
|
|
3496
|
-
function write(sized, next) {
|
|
3497
|
-
say(size, sized);
|
|
3498
|
-
const shown = [];
|
|
3499
|
-
for (const key of CARD_KEYS) {
|
|
3500
|
-
const parts = nodes.get(key);
|
|
3501
|
-
if (!parts)
|
|
3502
|
-
continue;
|
|
3503
|
-
const row = next.find((one) => one.key === key);
|
|
3504
|
-
show(parts.node, row !== undefined);
|
|
3505
|
-
if (!row)
|
|
3506
|
-
continue;
|
|
3507
|
-
shown.push(key);
|
|
3508
|
-
say(parts.text, row.text);
|
|
3509
|
-
const quiet = row.quiet ? "text quiet" : "text";
|
|
3510
|
-
if (parts.text.className !== quiet)
|
|
3511
|
-
parts.text.className = quiet;
|
|
3512
|
-
show(parts.swatch, row.swatch !== undefined);
|
|
3513
|
-
if (row.swatch !== undefined)
|
|
3514
|
-
parts.swatch.style.backgroundColor = row.swatch;
|
|
3515
|
-
show(parts.pass, row.pass === true);
|
|
3516
|
-
show(parts.fail, row.pass === false);
|
|
3517
|
-
}
|
|
3518
|
-
show(rows, shown.length > 0);
|
|
3519
|
-
return shown.join(" ");
|
|
3520
|
-
}
|
|
3521
|
-
return { size, rows, write };
|
|
3522
|
-
}
|
|
3523
|
-
|
|
3524
|
-
// src/grab/paint.ts
|
|
3525
|
-
function createColorReader() {
|
|
3526
|
-
const colors = new Map;
|
|
3527
|
-
let context;
|
|
3528
|
-
function paint(value) {
|
|
3529
|
-
if (!CSS.supports("color", value))
|
|
3530
|
-
return null;
|
|
3531
|
-
if (context === undefined) {
|
|
3532
|
-
const canvas = document.createElement("canvas");
|
|
3533
|
-
canvas.width = 1;
|
|
3534
|
-
canvas.height = 1;
|
|
3535
|
-
context = canvas.getContext("2d", { willReadFrequently: true });
|
|
3536
|
-
}
|
|
3537
|
-
if (!context)
|
|
3538
|
-
return null;
|
|
3539
|
-
context.clearRect(0, 0, 1, 1);
|
|
3540
|
-
context.fillStyle = value;
|
|
3541
|
-
context.fillRect(0, 0, 1, 1);
|
|
3542
|
-
const [red = 0, green = 0, blue = 0, alpha = 0] = context.getImageData(0, 0, 1, 1).data;
|
|
3543
|
-
return { red, green, blue, alpha: alpha / 255 };
|
|
3544
|
-
}
|
|
3545
|
-
return (value) => {
|
|
3546
|
-
let color = colors.get(value);
|
|
3547
|
-
if (color === undefined) {
|
|
3548
|
-
color = parseCss(value) ?? paint(value);
|
|
3549
|
-
colors.set(value, color);
|
|
3550
|
-
}
|
|
3551
|
-
return color;
|
|
3552
|
-
};
|
|
3553
|
-
}
|
|
3554
|
-
|
|
3555
|
-
// src/grab/theme.ts
|
|
3556
|
-
var DARK_BACKGROUND = 0.18;
|
|
3557
|
-
var LIGHT_TEXT = 0.6;
|
|
3558
|
-
var SOLID = 0.5;
|
|
3559
|
-
var THEME_ATTRIBUTES = [
|
|
3560
|
-
"data-theme",
|
|
3561
|
-
"data-mode",
|
|
3562
|
-
"data-color-scheme",
|
|
3563
|
-
"data-bs-theme",
|
|
3564
|
-
"data-mui-color-scheme",
|
|
3565
|
-
"data-mantine-color-scheme"
|
|
3566
|
-
];
|
|
3567
|
-
function backgroundTheme(color) {
|
|
3568
|
-
if (!color || color.alpha <= SOLID)
|
|
3569
|
-
return null;
|
|
3570
|
-
return luminance(color.red, color.green, color.blue) < DARK_BACKGROUND ? "dark" : "light";
|
|
3571
|
-
}
|
|
3572
|
-
function textTheme(color) {
|
|
3573
|
-
if (!color || color.alpha <= SOLID)
|
|
3574
|
-
return null;
|
|
3575
|
-
return luminance(color.red, color.green, color.blue) > LIGHT_TEXT ? "dark" : null;
|
|
3576
|
-
}
|
|
3577
|
-
function markerTheme(hasClass, attribute) {
|
|
3578
|
-
if (hasClass("dark"))
|
|
3579
|
-
return "dark";
|
|
3580
|
-
if (hasClass("light"))
|
|
3581
|
-
return "light";
|
|
3582
|
-
for (const name of THEME_ATTRIBUTES) {
|
|
3583
|
-
const value = attribute(name)?.toLowerCase();
|
|
3584
|
-
if (value === "dark" || value === "light")
|
|
3585
|
-
return value;
|
|
3586
|
-
}
|
|
3587
|
-
if (attribute("data-dark") !== null)
|
|
3588
|
-
return "dark";
|
|
3589
|
-
if (attribute("data-light") !== null)
|
|
3590
|
-
return "light";
|
|
3591
|
-
return null;
|
|
3592
|
-
}
|
|
3593
|
-
function schemeTheme(value) {
|
|
3594
|
-
const tokens = value.trim().toLowerCase().split(/\s+/);
|
|
3595
|
-
const dark = tokens.includes("dark");
|
|
3596
|
-
if (dark === tokens.includes("light"))
|
|
3597
|
-
return null;
|
|
3598
|
-
return dark ? "dark" : "light";
|
|
3599
|
-
}
|
|
3600
|
-
function decideTheme(signals) {
|
|
3601
|
-
return signals.surface ?? signals.marker ?? signals.scheme ?? signals.backdrop ?? signals.text ?? "light";
|
|
3602
|
-
}
|
|
3603
|
-
var BLUE_HUES = [190, 260];
|
|
3604
|
-
var BLUE_SATURATION = 0.35;
|
|
3605
|
-
var BLUE_LIGHTNESS = [0.15, 0.85];
|
|
3606
|
-
function toHsl(color) {
|
|
3607
|
-
const red = color.red / 255;
|
|
3608
|
-
const green = color.green / 255;
|
|
3609
|
-
const blue = color.blue / 255;
|
|
3610
|
-
const high = Math.max(red, green, blue);
|
|
3611
|
-
const low = Math.min(red, green, blue);
|
|
3612
|
-
const spread = high - low;
|
|
3613
|
-
const lightness = (high + low) / 2;
|
|
3614
|
-
if (spread === 0)
|
|
3615
|
-
return { hue: 0, saturation: 0, lightness };
|
|
3616
|
-
const saturation = spread / (1 - Math.abs(2 * lightness - 1));
|
|
3617
|
-
let hue;
|
|
3618
|
-
if (high === red)
|
|
3619
|
-
hue = (green - blue) / spread % 6;
|
|
3620
|
-
else if (high === green)
|
|
3621
|
-
hue = (blue - red) / spread + 2;
|
|
3622
|
-
else
|
|
3623
|
-
hue = (red - green) / spread + 4;
|
|
3624
|
-
return { hue: (hue * 60 + 360) % 360, saturation, lightness };
|
|
3625
|
-
}
|
|
3626
|
-
function isBlue(color) {
|
|
3627
|
-
if (!color || color.alpha <= SOLID)
|
|
3628
|
-
return false;
|
|
3629
|
-
const { hue, saturation, lightness } = toHsl(color);
|
|
3630
|
-
return hue >= BLUE_HUES[0] && hue <= BLUE_HUES[1] && saturation > BLUE_SATURATION && lightness >= BLUE_LIGHTNESS[0] && lightness <= BLUE_LIGHTNESS[1];
|
|
3631
|
-
}
|
|
3632
|
-
function decideGrab(signals) {
|
|
3633
|
-
if (isBlue(signals.surface))
|
|
3634
|
-
return "green";
|
|
3635
|
-
const clear = !signals.own || signals.own.alpha <= SOLID;
|
|
3636
|
-
if (clear && (isBlue(signals.border) || isBlue(signals.text)))
|
|
3637
|
-
return "green";
|
|
3638
|
-
return "blue";
|
|
3639
|
-
}
|
|
3640
|
-
function invertTheme(theme) {
|
|
3641
|
-
return theme === "dark" ? "light" : "dark";
|
|
3642
|
-
}
|
|
3643
|
-
function createThemeReader() {
|
|
3644
|
-
const surfaces = new WeakMap;
|
|
3645
|
-
const tones = new WeakMap;
|
|
3646
|
-
const colorOf = createColorReader();
|
|
3647
|
-
let page = null;
|
|
3648
|
-
function parentOf2(element) {
|
|
3649
|
-
if (element.parentElement)
|
|
3650
|
-
return element.parentElement;
|
|
3651
|
-
const root = element.getRootNode();
|
|
3652
|
-
return root instanceof ShadowRoot ? root.host : null;
|
|
3653
|
-
}
|
|
3654
|
-
function solid(color) {
|
|
3655
|
-
return color && color.alpha > SOLID ? color : null;
|
|
3656
|
-
}
|
|
3657
|
-
function surfaceOf(element) {
|
|
3658
|
-
const walked = [];
|
|
3659
|
-
let found = null;
|
|
3660
|
-
let node = element;
|
|
3661
|
-
while (node && node !== document.body && node !== document.documentElement) {
|
|
3662
|
-
const known = surfaces.get(node);
|
|
3663
|
-
if (known !== undefined) {
|
|
3664
|
-
found = known;
|
|
3665
|
-
break;
|
|
3666
|
-
}
|
|
3667
|
-
walked.push(node);
|
|
3668
|
-
found = solid(colorOf(getComputedStyle(node).backgroundColor));
|
|
3669
|
-
if (found)
|
|
3670
|
-
break;
|
|
3671
|
-
node = parentOf2(node);
|
|
3672
|
-
}
|
|
3673
|
-
for (const each of walked)
|
|
3674
|
-
surfaces.set(each, found);
|
|
3675
|
-
return found;
|
|
3676
|
-
}
|
|
3677
|
-
function first(roots, read) {
|
|
3678
|
-
for (const root of roots) {
|
|
3679
|
-
const value = root ? read(root) : null;
|
|
3680
|
-
if (value)
|
|
3681
|
-
return value;
|
|
3682
|
-
}
|
|
3683
|
-
return null;
|
|
3684
|
-
}
|
|
3685
|
-
function readPage() {
|
|
3686
|
-
const html = document.documentElement;
|
|
3687
|
-
const body = document.body;
|
|
3688
|
-
const meta = document.querySelector('meta[name="color-scheme"]')?.getAttribute("content");
|
|
3689
|
-
const backdrop = first([body, html], (root) => solid(colorOf(getComputedStyle(root).backgroundColor)));
|
|
3690
|
-
const signals = {
|
|
3691
|
-
marker: first([html, body], (root) => markerTheme((name) => root.classList.contains(name), (name) => root.getAttribute(name))),
|
|
3692
|
-
scheme: first([html, body], (root) => schemeTheme(root.style.colorScheme || getComputedStyle(root).colorScheme)) ?? schemeTheme(meta ?? ""),
|
|
3693
|
-
backdrop: backgroundTheme(backdrop),
|
|
3694
|
-
text: textTheme(colorOf(getComputedStyle(html).color))
|
|
3695
|
-
};
|
|
3696
|
-
return { signals, backdrop };
|
|
3697
|
-
}
|
|
3698
|
-
function toneOf(element, surface) {
|
|
3699
|
-
let tone = tones.get(element);
|
|
3700
|
-
if (tone === undefined) {
|
|
3701
|
-
const style = getComputedStyle(element);
|
|
3702
|
-
tone = decideGrab({
|
|
3703
|
-
surface,
|
|
3704
|
-
own: colorOf(style.backgroundColor),
|
|
3705
|
-
border: Number.parseFloat(style.borderTopWidth) > 0 ? colorOf(style.borderTopColor) : null,
|
|
3706
|
-
text: colorOf(style.color)
|
|
3707
|
-
});
|
|
3708
|
-
tones.set(element, tone);
|
|
3709
|
-
}
|
|
3710
|
-
return tone;
|
|
3711
|
-
}
|
|
3712
|
-
return (element) => {
|
|
3713
|
-
page ??= readPage();
|
|
3714
|
-
const near = element ? surfaceOf(element) : null;
|
|
3715
|
-
const surface = near ?? page.backdrop;
|
|
3716
|
-
return {
|
|
3717
|
-
theme: decideTheme({ surface: backgroundTheme(near), ...page.signals }),
|
|
3718
|
-
grab: element ? toneOf(element, surface) : decideGrab({ surface, own: null, border: null, text: null })
|
|
3719
|
-
};
|
|
3720
|
-
};
|
|
3721
|
-
}
|
|
3722
|
-
|
|
3723
|
-
// src/grab/overlay.ts
|
|
3724
|
-
var Z_INDEX = 2147483646;
|
|
3725
|
-
var HOST_CSS = `
|
|
3726
|
-
:host([popover]) {
|
|
3727
|
-
inset: 0 !important;
|
|
3728
|
-
width: auto !important;
|
|
3729
|
-
height: auto !important;
|
|
3730
|
-
pointer-events: none !important;
|
|
3731
|
-
}`;
|
|
3732
|
-
var GAP = 6;
|
|
3733
|
-
var MARGIN = 8;
|
|
3734
|
-
var MIN_RADIUS = 2;
|
|
3735
|
-
var LERP = 0.3;
|
|
3736
|
-
var FRAME = 1000 / 60;
|
|
3737
|
-
var SNAP = 0.5;
|
|
3738
|
-
var FADE = 125;
|
|
3739
|
-
var HIDE_WAIT = 100;
|
|
3740
|
-
var SYNC_EVERY = 100;
|
|
3741
|
-
var TOAST_TIME = 1500;
|
|
3742
|
-
var TOAST_FADE = 100;
|
|
3743
|
-
var MAX_WIDTH = 280;
|
|
3744
|
-
var CARD_WIDTH = 264;
|
|
3745
|
-
var CARD_HEIGHT = 180;
|
|
3746
|
-
var NAME_MAX = 26;
|
|
3747
|
-
function over(top, under) {
|
|
3748
|
-
return 100 - (100 - top) * (100 - under) / 100;
|
|
3749
|
-
}
|
|
3750
|
-
function colorRules(gamut) {
|
|
3751
|
-
return GRAB_COLOR_NAMES.map((name) => `.layer[data-grab="${name}"] { --grab: ${GRAB_COLORS[name][gamut]}; }`).join(`
|
|
3752
|
-
`);
|
|
3753
|
-
}
|
|
3754
|
-
var CSS2 = `
|
|
3755
|
-
.layer {
|
|
3756
|
-
all: initial;
|
|
3757
|
-
position: fixed;
|
|
3758
|
-
inset: 0;
|
|
3759
|
-
overflow: hidden;
|
|
3760
|
-
contain: strict;
|
|
3761
|
-
pointer-events: none;
|
|
3762
|
-
direction: ltr;
|
|
3763
|
-
--grab: ${GRAB_COLORS.blue.srgb};
|
|
3764
|
-
font-family: system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
|
|
3765
|
-
font-size: 13px;
|
|
3766
|
-
font-weight: 400;
|
|
3767
|
-
line-height: 16px;
|
|
3768
|
-
-webkit-font-smoothing: antialiased;
|
|
3769
|
-
}
|
|
3770
|
-
${colorRules("srgb")}
|
|
3771
|
-
@media (color-gamut: p3) {
|
|
3772
|
-
${colorRules("p3")}
|
|
3773
|
-
}
|
|
3774
|
-
.glow {
|
|
3775
|
-
position: absolute;
|
|
3776
|
-
inset: 0;
|
|
3777
|
-
opacity: 0;
|
|
3778
|
-
box-shadow: inset 0 0 50px color-mix(in srgb, var(--grab) 15%, transparent);
|
|
3779
|
-
transition: opacity ${FADE}ms ease-out, box-shadow ${FADE}ms ease-out;
|
|
3780
|
-
}
|
|
3781
|
-
.glow.on { opacity: 1; }
|
|
3782
|
-
.glide, .part {
|
|
3783
|
-
position: absolute;
|
|
3784
|
-
top: 0;
|
|
3785
|
-
left: 0;
|
|
3786
|
-
transform-origin: 0 0;
|
|
3787
|
-
will-change: transform;
|
|
3788
|
-
}
|
|
3789
|
-
.fills > .part, .lines > .part {
|
|
3790
|
-
width: var(--unit);
|
|
3791
|
-
height: var(--unit);
|
|
3792
|
-
background-color: currentColor;
|
|
3793
|
-
}
|
|
3794
|
-
.box {
|
|
3795
|
-
opacity: 0;
|
|
3796
|
-
will-change: opacity;
|
|
3797
|
-
--line: color-mix(in srgb, var(--grab) 50%, transparent);
|
|
3798
|
-
--fill: color-mix(in srgb, var(--grab) 8%, transparent);
|
|
3799
|
-
--edge: color-mix(in srgb, var(--grab) ${over(50, 8)}%, transparent);
|
|
3800
|
-
transition: opacity ${FADE}ms ease-out;
|
|
3801
|
-
}
|
|
3802
|
-
.box.on { opacity: 1; }
|
|
3803
|
-
.box.copied {
|
|
3804
|
-
--line: color-mix(in srgb, var(--grab) 60%, transparent);
|
|
3805
|
-
--fill: color-mix(in srgb, var(--grab) 20%, transparent);
|
|
3806
|
-
--edge: color-mix(in srgb, var(--grab) ${over(60, 20)}%, transparent);
|
|
3807
|
-
}
|
|
3808
|
-
.fills, .lines, .corners { transition: color ${FADE}ms ease-out; }
|
|
3809
|
-
.fills { color: var(--fill); }
|
|
3810
|
-
.lines { color: var(--edge); }
|
|
3811
|
-
.corners { color: var(--line); }
|
|
3812
|
-
.corner {
|
|
3813
|
-
box-sizing: border-box;
|
|
3814
|
-
width: var(--corner-width);
|
|
3815
|
-
height: var(--corner-height);
|
|
3816
|
-
border: 0 solid;
|
|
3817
|
-
background-color: var(--fill);
|
|
3818
|
-
transition: background-color ${FADE}ms ease-out;
|
|
3819
|
-
}
|
|
3820
|
-
.top > .corner { border-top-width: 1px; }
|
|
3821
|
-
.bottom > .corner { border-bottom-width: 1px; }
|
|
3822
|
-
.left > .corner { border-left-width: 1px; }
|
|
3823
|
-
.right > .corner { border-right-width: 1px; }
|
|
3824
|
-
.top.left > .corner { border-top-left-radius: var(--corner-radius); }
|
|
3825
|
-
.top.right > .corner { border-top-right-radius: var(--corner-radius); }
|
|
3826
|
-
.bottom.left > .corner { border-bottom-left-radius: var(--corner-radius); }
|
|
3827
|
-
.bottom.right > .corner { border-bottom-right-radius: var(--corner-radius); }
|
|
3828
|
-
.pick {
|
|
3829
|
-
position: absolute;
|
|
3830
|
-
top: 0;
|
|
3831
|
-
left: 0;
|
|
3832
|
-
box-sizing: border-box;
|
|
3833
|
-
will-change: transform;
|
|
3834
|
-
border: 1px solid color-mix(in srgb, var(--grab) 30%, transparent);
|
|
3835
|
-
border-radius: ${MIN_RADIUS}px;
|
|
3836
|
-
background: color-mix(in srgb, var(--grab) 5%, transparent);
|
|
3837
|
-
transition: border-color ${FADE}ms ease-out, background-color ${FADE}ms ease-out;
|
|
3838
|
-
}
|
|
3839
|
-
.tint {
|
|
3840
|
-
position: absolute;
|
|
3841
|
-
inset: 0;
|
|
3842
|
-
opacity: 0;
|
|
3843
|
-
transition: opacity ${FADE}ms ease-out;
|
|
3844
|
-
}
|
|
3845
|
-
.tint.on { opacity: 1; }
|
|
3846
|
-
${RINGS.map((ring) => `.tint.${ring} { background: ${boxTint(ring)}; }`).join(`
|
|
3847
|
-
`)}
|
|
3848
|
-
.tip {
|
|
3849
|
-
position: absolute;
|
|
3850
|
-
inset: 0;
|
|
3851
|
-
will-change: transform;
|
|
3852
|
-
}
|
|
3853
|
-
.pill {
|
|
3854
|
-
position: absolute;
|
|
3855
|
-
top: 0;
|
|
3856
|
-
left: 0;
|
|
3857
|
-
display: flex;
|
|
3858
|
-
align-items: center;
|
|
3859
|
-
gap: 6px;
|
|
3860
|
-
max-width: min(${MAX_WIDTH}px, calc(100% - ${2 * MARGIN}px));
|
|
3861
|
-
box-sizing: border-box;
|
|
3862
|
-
padding: 6px 8px;
|
|
3863
|
-
white-space: nowrap;
|
|
3864
|
-
opacity: 0;
|
|
3865
|
-
--bar: #161616;
|
|
3866
|
-
--quiet: #a7a7a7;
|
|
3867
|
-
color: #ffffff;
|
|
3868
|
-
background: var(--bar);
|
|
3869
|
-
border-radius: 6px;
|
|
3870
|
-
box-shadow: 0 0 0 1px rgb(255 255 255 / 12%), 0 2px 8px rgb(0 0 0 / 24%);
|
|
3871
|
-
transition: opacity ${FADE}ms ease-out;
|
|
3872
|
-
}
|
|
3873
|
-
.pill.on { opacity: 1; }
|
|
3874
|
-
.pill.toast.on { transition: opacity ${TOAST_FADE}ms ease-out; }
|
|
3875
|
-
.pill span {
|
|
3876
|
-
min-width: 0;
|
|
3877
|
-
overflow: hidden;
|
|
3878
|
-
text-overflow: ellipsis;
|
|
3879
|
-
}
|
|
3880
|
-
.check {
|
|
3881
|
-
flex: none;
|
|
3882
|
-
margin-right: -2px;
|
|
3883
|
-
opacity: 0.85;
|
|
3884
|
-
}
|
|
3885
|
-
.check circle { fill: currentColor; }
|
|
3886
|
-
.check path {
|
|
3887
|
-
fill: none;
|
|
3888
|
-
stroke: var(--bar);
|
|
3889
|
-
stroke-width: 1.5;
|
|
3890
|
-
stroke-linecap: round;
|
|
3891
|
-
stroke-linejoin: round;
|
|
3892
|
-
}
|
|
3893
|
-
.pill .tag { flex: none; color: #a7a7a7; }
|
|
3894
|
-
.pill[data-bar="light"] {
|
|
3895
|
-
--bar: #ffffff;
|
|
3896
|
-
--quiet: #737373;
|
|
3897
|
-
color: #171717;
|
|
3898
|
-
box-shadow: 0 0 0 1px rgb(0 0 0 / 10%), 0 2px 8px rgb(0 0 0 / 32%);
|
|
3899
|
-
}
|
|
3900
|
-
.pill[data-bar="light"] .tag { color: #737373; }
|
|
3901
|
-
/* Inspect's card: the label grown to a few rows, one width whatever it says. */
|
|
3902
|
-
.pill.card {
|
|
3903
|
-
display: block;
|
|
3904
|
-
width: ${CARD_WIDTH}px;
|
|
3905
|
-
max-height: ${CARD_HEIGHT}px;
|
|
3906
|
-
overflow: hidden;
|
|
3907
|
-
padding: 8px;
|
|
3908
|
-
border-radius: 8px;
|
|
3909
|
-
}
|
|
3910
|
-
.card .head { display: flex; align-items: center; gap: 6px; }
|
|
3911
|
-
.card .size, .card .val {
|
|
3912
|
-
font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
|
|
3913
|
-
font-size: 11px;
|
|
3914
|
-
font-variant-numeric: tabular-nums;
|
|
3915
|
-
}
|
|
3916
|
-
.card .size { flex: none; margin-left: auto; color: var(--quiet); }
|
|
3917
|
-
.card .rows { display: grid; gap: 2px; margin-top: 6px; }
|
|
3918
|
-
.card .info { display: flex; align-items: center; gap: 12px; }
|
|
3919
|
-
.card .key { flex: none; font-size: 11px; color: var(--quiet); }
|
|
3920
|
-
.card .val { display: flex; align-items: center; gap: 5px; min-width: 0; margin-left: auto; }
|
|
3921
|
-
.card .quiet { color: var(--quiet); }
|
|
3922
|
-
.card .dot {
|
|
3923
|
-
flex: none;
|
|
3924
|
-
width: 9px;
|
|
3925
|
-
height: 9px;
|
|
3926
|
-
border-radius: 2px;
|
|
3927
|
-
box-shadow: inset 0 0 0 1px rgb(128 128 128 / 45%);
|
|
3928
|
-
}
|
|
3929
|
-
.card .mark { flex: none; display: grid; overflow: visible; }
|
|
3930
|
-
.card .mark.fail { color: var(--quiet); }
|
|
3931
|
-
.layer [hidden] { display: none; }
|
|
3932
|
-
.layer[data-still] * { transition: none; }
|
|
3933
|
-
`;
|
|
3934
|
-
function clamp(value, low, high) {
|
|
3935
|
-
return Math.min(Math.max(value, low), Math.max(low, high));
|
|
3936
|
-
}
|
|
3937
|
-
function tweenStep(from, to, elapsed, reduce) {
|
|
3938
|
-
const share = reduce ? 1 : 1 - (1 - LERP) ** (Math.max(elapsed, 1) / FRAME);
|
|
3939
|
-
const values = to.map((end, index) => {
|
|
3940
|
-
const start = from[index] ?? end;
|
|
3941
|
-
return start + (end - start) * share;
|
|
3942
|
-
});
|
|
3943
|
-
const done = values.every((value, index) => Math.abs((to[index] ?? value) - value) < SNAP);
|
|
3944
|
-
return done ? { values: [...to], done } : { values, done };
|
|
3945
|
-
}
|
|
3946
|
-
function labelPlace(box, pill, view, pointerX) {
|
|
3947
|
-
const anchor = pointerX === null ? (box.left + box.right) / 2 : clamp(pointerX, box.left, box.right);
|
|
3948
|
-
const x3 = clamp(anchor - pill.width / 2, MARGIN, view.width - pill.width - MARGIN);
|
|
3949
|
-
let y4 = box.bottom + GAP;
|
|
3950
|
-
if (y4 + pill.height > view.height - MARGIN)
|
|
3951
|
-
y4 = box.top - pill.height - GAP;
|
|
3952
|
-
y4 = clamp(y4, MARGIN, view.height - pill.height - MARGIN);
|
|
3953
|
-
return { x: x3, y: y4 };
|
|
3954
|
-
}
|
|
3955
|
-
function cardPlace(box, card, view) {
|
|
3956
|
-
const { y: y4 } = labelPlace(box, card, view, null);
|
|
3957
|
-
return { x: clamp(box.left, MARGIN, view.width - card.width - MARGIN), y: y4 };
|
|
3958
|
-
}
|
|
3959
|
-
function parseRadius(value) {
|
|
3960
|
-
const match = /(\d*\.?\d+)px/.exec(value);
|
|
3961
|
-
return match ? Number(match[1]) : 0;
|
|
3962
|
-
}
|
|
3963
|
-
function boxRadius(radius, width, height) {
|
|
3964
|
-
return Math.max(MIN_RADIUS, Math.min(radius, Math.min(width, height) / 2));
|
|
3965
|
-
}
|
|
3966
|
-
var CORNERS = ["top right", "bottom left", "bottom right"];
|
|
3967
|
-
var LINES = ["top", "bottom", "left", "right"];
|
|
3968
|
-
var FILLS = ["middle", "west", "east"];
|
|
3969
|
-
function snap(value, ratio) {
|
|
3970
|
-
return Math.round(value * ratio) / ratio;
|
|
3971
|
-
}
|
|
3972
|
-
function onPixels(shape, ratio) {
|
|
3973
|
-
const [x3 = 0, y4 = 0, width = 0, height = 0] = shape;
|
|
3974
|
-
const left = snap(x3, ratio);
|
|
3975
|
-
const top = snap(y4, ratio);
|
|
3976
|
-
return [left, top, snap(x3 + width, ratio) - left, snap(y4 + height, ratio) - top];
|
|
3977
|
-
}
|
|
3978
|
-
function boxParts(shape, radius, ratio) {
|
|
3979
|
-
const [x3, y4, wide, tall] = onPixels(shape, ratio);
|
|
3980
|
-
const line = Math.max(1, Math.floor(ratio)) / ratio;
|
|
3981
|
-
const width = Math.max(wide, 2 * line);
|
|
3982
|
-
const height = Math.max(tall, 2 * line);
|
|
3983
|
-
const round = Math.min(radius, width / 2, height / 2);
|
|
3984
|
-
const reach = Math.max(Math.ceil(round * ratio - 0.000001) / ratio, line);
|
|
3985
|
-
const cornerWidth = Math.min(reach, Math.floor(width / 2 * ratio + 0.000001) / ratio);
|
|
3986
|
-
const cornerHeight = Math.min(reach, Math.floor(height / 2 * ratio + 0.000001) / ratio);
|
|
3987
|
-
const right = width - cornerWidth;
|
|
3988
|
-
const bottom = height - cornerHeight;
|
|
3989
|
-
const acrossBy = width - 2 * cornerWidth;
|
|
3990
|
-
const downBy = height - 2 * cornerHeight;
|
|
3991
|
-
const sideBy = cornerWidth - line;
|
|
3992
|
-
const whole = (length) => Math.round(length * ratio);
|
|
3993
|
-
const part = (left, top, across, down) => `translate(${left}px, ${top}px) scale(${whole(across)}, ${whole(down)})`;
|
|
3994
|
-
return {
|
|
3995
|
-
at: `translate(${x3}px, ${y4}px)`,
|
|
3996
|
-
unit: 1 / ratio,
|
|
3997
|
-
corner: { width: cornerWidth, height: cornerHeight, radius: round },
|
|
3998
|
-
pieces: {
|
|
3999
|
-
"top right": `translate(${right}px, 0px)`,
|
|
4000
|
-
"bottom left": `translate(0px, ${bottom}px)`,
|
|
4001
|
-
"bottom right": `translate(${right}px, ${bottom}px)`,
|
|
4002
|
-
top: part(cornerWidth, 0, acrossBy, line),
|
|
4003
|
-
bottom: part(cornerWidth, height - line, acrossBy, line),
|
|
4004
|
-
left: part(0, cornerHeight, line, downBy),
|
|
4005
|
-
right: part(width - line, cornerHeight, line, downBy),
|
|
4006
|
-
middle: part(cornerWidth, line, acrossBy, height - 2 * line),
|
|
4007
|
-
west: part(line, cornerHeight, sideBy, downBy),
|
|
4008
|
-
east: part(right, cornerHeight, sideBy, downBy)
|
|
4009
|
-
}
|
|
4010
|
-
};
|
|
4011
|
-
}
|
|
4012
|
-
var SVG = "http://www.w3.org/2000/svg";
|
|
4013
|
-
function checkIcon() {
|
|
4014
|
-
const icon2 = document.createElementNS(SVG, "svg");
|
|
4015
|
-
icon2.setAttribute("class", "check");
|
|
4016
|
-
icon2.setAttribute("width", "14");
|
|
4017
|
-
icon2.setAttribute("height", "14");
|
|
4018
|
-
icon2.setAttribute("viewBox", "0 0 14 14");
|
|
4019
|
-
icon2.setAttribute("aria-hidden", "true");
|
|
4020
|
-
const disc = document.createElementNS(SVG, "circle");
|
|
4021
|
-
disc.setAttribute("cx", "7");
|
|
4022
|
-
disc.setAttribute("cy", "7");
|
|
4023
|
-
disc.setAttribute("r", "6");
|
|
4024
|
-
const mark2 = document.createElementNS(SVG, "path");
|
|
4025
|
-
mark2.setAttribute("d", "M4.4 7.2 6.2 9l3.4-3.8");
|
|
4026
|
-
icon2.append(disc, mark2);
|
|
4027
|
-
return icon2;
|
|
4028
|
-
}
|
|
4029
|
-
var written = new WeakMap;
|
|
4030
|
-
function write(node, name, value) {
|
|
4031
|
-
let styles = written.get(node);
|
|
4032
|
-
if (!styles) {
|
|
4033
|
-
styles = new Map;
|
|
4034
|
-
written.set(node, styles);
|
|
4035
|
-
}
|
|
4036
|
-
if (styles.get(name) === value)
|
|
4037
|
-
return;
|
|
4038
|
-
styles.set(name, value);
|
|
4039
|
-
node.style.setProperty(name, value);
|
|
4040
|
-
}
|
|
4041
|
-
function place(node, shape, ratio) {
|
|
4042
|
-
const [x3, y4, width, height] = onPixels(shape, ratio);
|
|
4043
|
-
write(node, "transform", `translate(${x3}px, ${y4}px)`);
|
|
4044
|
-
write(node, "width", `${width}px`);
|
|
4045
|
-
write(node, "height", `${height}px`);
|
|
4046
|
-
write(node, "border-radius", `${shape[4] ?? 0}px`);
|
|
4047
|
-
}
|
|
4048
|
-
function createOverlay(quiet = false, model = false) {
|
|
4049
|
-
const host = document.createElement("div");
|
|
4050
|
-
host.setAttribute("data-devknobs", "grab");
|
|
4051
|
-
host.style.cssText = `position:fixed;inset:0;width:auto;height:auto;pointer-events:none;z-index:${Z_INDEX}`;
|
|
4052
|
-
const root = host.attachShadow({ mode: "open" });
|
|
4053
|
-
addStyle(root, HOST_RESET + HOST_CSS + CSS2);
|
|
4054
|
-
const layer = document.createElement("div");
|
|
4055
|
-
layer.className = "layer";
|
|
4056
|
-
const glow = document.createElement("div");
|
|
4057
|
-
glow.className = "glow";
|
|
4058
|
-
const glide = document.createElement("div");
|
|
4059
|
-
glide.className = "glide";
|
|
4060
|
-
const box = document.createElement("div");
|
|
4061
|
-
box.className = "box";
|
|
4062
|
-
glide.append(box);
|
|
4063
|
-
const pieces = [];
|
|
4064
|
-
function group(name2, names) {
|
|
4065
|
-
const parent = document.createElement("div");
|
|
4066
|
-
parent.className = name2;
|
|
4067
|
-
for (const piece of names) {
|
|
4068
|
-
const node = document.createElement("div");
|
|
4069
|
-
node.className = `part ${piece}`;
|
|
4070
|
-
if (name2 === "corners") {
|
|
4071
|
-
const corner = document.createElement("div");
|
|
4072
|
-
corner.className = "corner";
|
|
4073
|
-
node.append(corner);
|
|
4074
|
-
}
|
|
4075
|
-
parent.append(node);
|
|
4076
|
-
if (piece !== "top left")
|
|
4077
|
-
pieces.push({ piece, node });
|
|
4078
|
-
}
|
|
4079
|
-
box.append(parent);
|
|
4080
|
-
}
|
|
4081
|
-
group("fills", FILLS);
|
|
4082
|
-
group("lines", LINES);
|
|
4083
|
-
group("corners", ["top left", ...CORNERS]);
|
|
4084
|
-
const tip = document.createElement("div");
|
|
4085
|
-
tip.className = "tip";
|
|
4086
|
-
const label = document.createElement("div");
|
|
4087
|
-
label.className = "pill";
|
|
4088
|
-
tip.append(label);
|
|
4089
|
-
const check = checkIcon();
|
|
4090
|
-
const tag = document.createElement("span");
|
|
4091
|
-
tag.className = "tag";
|
|
4092
|
-
const name = document.createElement("span");
|
|
4093
|
-
const card = model && !quiet ? createCardView() : null;
|
|
4094
|
-
if (card) {
|
|
4095
|
-
const head = document.createElement("div");
|
|
4096
|
-
head.className = "head";
|
|
4097
|
-
head.append(check, tag, name, card.size);
|
|
4098
|
-
label.classList.add("card");
|
|
4099
|
-
label.append(head, card.rows);
|
|
4100
|
-
} else
|
|
4101
|
-
label.append(check, tag, name);
|
|
4102
|
-
const picks = [];
|
|
4103
|
-
const tints = (model ? RINGS : []).map((ring) => {
|
|
4104
|
-
const node = document.createElement("div");
|
|
4105
|
-
node.className = `tint ${ring}`;
|
|
4106
|
-
layer.append(node);
|
|
4107
|
-
return { ring, node };
|
|
4108
|
-
});
|
|
4109
|
-
layer.append(glow, glide, tip);
|
|
4110
|
-
root.append(layer);
|
|
4111
|
-
(document.body ?? document.documentElement).append(host);
|
|
4112
|
-
const hold = holdInTopLayer(host, LAYER.overlay);
|
|
4113
|
-
const reduce = baseMatchMedia("(prefers-reduced-motion: reduce)");
|
|
4114
|
-
let reduced = reduce.matches;
|
|
4115
|
-
const radii = new WeakMap;
|
|
4116
|
-
const read = createThemeReader();
|
|
4117
|
-
const sizes = new Map;
|
|
4118
|
-
let color = getState().grabColor;
|
|
4119
|
-
let tone = "blue";
|
|
4120
|
-
let bar = null;
|
|
4121
|
-
let element = null;
|
|
4122
|
-
let measured = null;
|
|
4123
|
-
let picked = [];
|
|
4124
|
-
let shapes = [];
|
|
4125
|
-
let at2 = null;
|
|
4126
|
-
let target = null;
|
|
4127
|
-
let labelAt = null;
|
|
4128
|
-
let shown = false;
|
|
4129
|
-
let stale = false;
|
|
4130
|
-
let pointerX = null;
|
|
4131
|
-
let text = { tag: "", name: null };
|
|
4132
|
-
let checked = false;
|
|
4133
|
-
let sized = null;
|
|
4134
|
-
let size = { width: 0, height: 0 };
|
|
4135
|
-
const styles = new WeakMap;
|
|
4136
|
-
const colorOf = createColorReader();
|
|
4137
|
-
let rings = null;
|
|
4138
|
-
let ringsAt = null;
|
|
4139
|
-
let only = null;
|
|
4140
|
-
let facts = null;
|
|
4141
|
-
let factsTimer = 0;
|
|
4142
|
-
let rows = [];
|
|
4143
|
-
let toasting = false;
|
|
4144
|
-
let closing = false;
|
|
4145
|
-
let removed = false;
|
|
4146
|
-
let frame = 0;
|
|
4147
|
-
let last = 0;
|
|
4148
|
-
let hideTimer = 0;
|
|
4149
|
-
let toastTimer = 0;
|
|
4150
|
-
let fadeTimer = 0;
|
|
4151
|
-
function fade() {
|
|
4152
|
-
return reduced ? 0 : FADE;
|
|
4153
|
-
}
|
|
4154
|
-
function still() {
|
|
4155
|
-
const own = systemMedia();
|
|
4156
|
-
reduced = own ? own.motion === "reduce" : reduce.matches;
|
|
4157
|
-
layer.toggleAttribute("data-still", reduced);
|
|
4158
|
-
}
|
|
4159
|
-
function paint() {
|
|
4160
|
-
const name2 = grabColor(color, tone);
|
|
4161
|
-
if (layer.dataset.grab !== name2) {
|
|
4162
|
-
layer.dataset.grab = name2;
|
|
4163
|
-
if (isCustomColor(name2))
|
|
4164
|
-
layer.style.setProperty("--grab", name2);
|
|
4165
|
-
else
|
|
4166
|
-
layer.style.removeProperty("--grab");
|
|
4167
|
-
}
|
|
4168
|
-
if (bar && label.dataset.bar !== bar)
|
|
4169
|
-
label.dataset.bar = bar;
|
|
4170
|
-
}
|
|
4171
|
-
function schedule() {
|
|
4172
|
-
if (!frame && !removed)
|
|
4173
|
-
frame = window.requestAnimationFrame(draw);
|
|
4174
|
-
}
|
|
4175
|
-
function sync() {
|
|
4176
|
-
if (!element && picked.length === 0)
|
|
4177
|
-
return;
|
|
4178
|
-
stale = true;
|
|
4179
|
-
schedule();
|
|
4180
|
-
}
|
|
4181
|
-
function radiusOf(of) {
|
|
4182
|
-
let radius = radii.get(of);
|
|
4183
|
-
if (radius === undefined) {
|
|
4184
|
-
radius = parseRadius(getComputedStyle(of).borderRadius);
|
|
4185
|
-
radii.set(of, radius);
|
|
4186
|
-
}
|
|
4187
|
-
return radius;
|
|
4188
|
-
}
|
|
4189
|
-
function shapeOf(of) {
|
|
4190
|
-
const rect = of.getBoundingClientRect();
|
|
4191
|
-
const radius = boxRadius(radiusOf(of), rect.width, rect.height);
|
|
4192
|
-
return [rect.left, rect.top, rect.width, rect.height, radius];
|
|
4193
|
-
}
|
|
4194
|
-
function drawPicks(ratio) {
|
|
4195
|
-
while (picks.length < shapes.length) {
|
|
4196
|
-
const node = document.createElement("div");
|
|
4197
|
-
node.className = "pick";
|
|
4198
|
-
layer.insertBefore(node, glide);
|
|
4199
|
-
picks.push(node);
|
|
4200
|
-
}
|
|
4201
|
-
picks.forEach((node, index) => {
|
|
4202
|
-
const shape = shapes[index] ?? null;
|
|
4203
|
-
if (node.hidden !== (shape === null))
|
|
4204
|
-
node.hidden = shape === null;
|
|
4205
|
-
if (shape)
|
|
4206
|
-
place(node, shape, ratio);
|
|
4207
|
-
});
|
|
4208
|
-
}
|
|
4209
|
-
function drawBox(parts) {
|
|
4210
|
-
write(glide, "transform", parts.at);
|
|
4211
|
-
write(box, "--unit", `${parts.unit}px`);
|
|
4212
|
-
write(box, "--corner-width", `${parts.corner.width}px`);
|
|
4213
|
-
write(box, "--corner-height", `${parts.corner.height}px`);
|
|
4214
|
-
write(box, "--corner-radius", `${parts.corner.radius}px`);
|
|
4215
|
-
for (const { piece, node } of pieces)
|
|
4216
|
-
write(node, "transform", parts.pieces[piece]);
|
|
4217
|
-
}
|
|
4218
|
-
function styleOf(of) {
|
|
4219
|
-
let style = styles.get(of);
|
|
4220
|
-
if (!style) {
|
|
4221
|
-
style = getComputedStyle(of);
|
|
4222
|
-
styles.set(of, style);
|
|
4223
|
-
}
|
|
4224
|
-
return style;
|
|
4225
|
-
}
|
|
4226
|
-
function measureBox() {
|
|
4227
|
-
const first = element ? -1 : picked.findIndex((pick) => pick.isConnected);
|
|
4228
|
-
const subject = element ?? picked[first] ?? null;
|
|
4229
|
-
rings = subject ? readBox(subject, styleOf(subject)) : null;
|
|
4230
|
-
ringsAt = shapes[first] ?? null;
|
|
4231
|
-
if (!card || !element || facts?.of !== element)
|
|
4232
|
-
return;
|
|
4233
|
-
rows = rings ? cardRows({ ...facts.read, margin: rings.model.margin, padding: rings.model.padding }) : [];
|
|
4234
|
-
}
|
|
4235
|
-
function readCard(of) {
|
|
4236
|
-
if (removed || of !== element || !of.isConnected)
|
|
4237
|
-
return;
|
|
4238
|
-
facts = { of, read: readFacts(of, styleOf(of), colorOf) };
|
|
4239
|
-
stale = true;
|
|
4240
|
-
schedule();
|
|
4241
|
-
}
|
|
4242
|
-
function drawTints(glide2) {
|
|
4243
|
-
const [x3, y4, width, height] = glide2 ?? ringsAt ?? [];
|
|
4244
|
-
const on2 = rings !== null && x3 !== undefined && y4 !== undefined;
|
|
4245
|
-
if (rings && on2) {
|
|
4246
|
-
const paths = ringPaths(rings.quads ?? ringQuads({ x: x3, y: y4, width: width ?? 0, height: height ?? 0 }, rings.model));
|
|
4247
|
-
for (const { ring, node } of tints)
|
|
4248
|
-
write(node, "clip-path", paths[ring]);
|
|
4249
|
-
}
|
|
4250
|
-
for (const { ring, node } of tints) {
|
|
4251
|
-
node.classList.toggle("on", on2 && (only === null || only === ring));
|
|
4252
|
-
}
|
|
4253
|
-
}
|
|
4254
|
-
function measure() {
|
|
4255
|
-
if (element && !element.isConnected)
|
|
4256
|
-
element = null;
|
|
4257
|
-
shapes = picked.map((pick) => pick.isConnected ? shapeOf(pick) : null);
|
|
4258
|
-
if (model)
|
|
4259
|
-
measureBox();
|
|
4260
|
-
if (element || toasting) {
|
|
4261
|
-
const { theme, grab } = read(element);
|
|
4262
|
-
bar = invertTheme(theme);
|
|
4263
|
-
tone = grab;
|
|
4264
|
-
}
|
|
4265
|
-
if (!element) {
|
|
4266
|
-
measured = null;
|
|
4267
|
-
target = null;
|
|
4268
|
-
return;
|
|
4269
|
-
}
|
|
4270
|
-
const next = shapeOf(element);
|
|
4271
|
-
if (!shown || !at2 || !target) {
|
|
4272
|
-
at2 = next;
|
|
4273
|
-
labelAt = null;
|
|
4274
|
-
} else if (measured === element) {
|
|
4275
|
-
const from = target;
|
|
4276
|
-
at2 = at2.map((value, index) => value + (next[index] ?? 0) - (from[index] ?? 0));
|
|
4277
|
-
if (labelAt) {
|
|
4278
|
-
labelAt = [(labelAt[0] ?? 0) + next[0] - from[0], (labelAt[1] ?? 0) + next[1] - from[1]];
|
|
4279
|
-
}
|
|
4280
|
-
}
|
|
4281
|
-
target = next;
|
|
4282
|
-
measured = element;
|
|
4283
|
-
}
|
|
4284
|
-
function writeLabel() {
|
|
4285
|
-
const said = card && target ? sizeText(target[2], target[3]) : "";
|
|
4286
|
-
const told = card ? `
|
|
4287
|
-
${said}
|
|
4288
|
-
${JSON.stringify(rows)}` : "";
|
|
4289
|
-
const key = `${checked}
|
|
4290
|
-
${text.tag}
|
|
4291
|
-
${text.name ?? ""}${told}`;
|
|
4292
|
-
if (key === sized)
|
|
4293
|
-
return;
|
|
4294
|
-
check.toggleAttribute("hidden", !checked);
|
|
4295
|
-
tag.textContent = text.tag;
|
|
4296
|
-
tag.hidden = !text.tag;
|
|
4297
|
-
name.textContent = card ? middle(text.name ?? "", NAME_MAX) : text.name ?? "";
|
|
4298
|
-
name.hidden = !text.name;
|
|
4299
|
-
const shape = card ? `card
|
|
4300
|
-
${card.write(said, rows)}` : key;
|
|
4301
|
-
let known = sizes.get(shape);
|
|
4302
|
-
if (!known) {
|
|
4303
|
-
known = { width: label.offsetWidth, height: label.offsetHeight };
|
|
4304
|
-
sizes.set(shape, known);
|
|
4305
|
-
}
|
|
4306
|
-
size = known;
|
|
4307
|
-
sized = key;
|
|
4308
|
-
}
|
|
4309
|
-
function resize() {
|
|
4310
|
-
sizes.clear();
|
|
4311
|
-
sync();
|
|
4312
|
-
}
|
|
4313
|
-
function draw(now) {
|
|
4314
|
-
frame = 0;
|
|
4315
|
-
if (removed)
|
|
4316
|
-
return;
|
|
4317
|
-
const fresh = stale;
|
|
4318
|
-
if (stale) {
|
|
4319
|
-
stale = false;
|
|
4320
|
-
measure();
|
|
4321
|
-
}
|
|
4322
|
-
const view = {
|
|
4323
|
-
width: document.documentElement.clientWidth,
|
|
4324
|
-
height: document.documentElement.clientHeight
|
|
4325
|
-
};
|
|
4326
|
-
const ratio = window.devicePixelRatio || 1;
|
|
4327
|
-
shown = at2 !== null && target !== null;
|
|
4328
|
-
if (shown || toasting)
|
|
4329
|
-
writeLabel();
|
|
4330
|
-
if (fresh) {
|
|
4331
|
-
paint();
|
|
4332
|
-
drawPicks(ratio);
|
|
4333
|
-
}
|
|
4334
|
-
box.classList.toggle("on", shown);
|
|
4335
|
-
label.classList.toggle("toast", toasting);
|
|
4336
|
-
label.classList.toggle("on", shown || toasting);
|
|
4337
|
-
if (!at2 || !target) {
|
|
4338
|
-
last = 0;
|
|
4339
|
-
labelAt = null;
|
|
4340
|
-
if (model)
|
|
4341
|
-
drawTints(null);
|
|
4342
|
-
if (!toasting)
|
|
4343
|
-
return;
|
|
4344
|
-
const x4 = Math.round((view.width - size.width) / 2);
|
|
4345
|
-
write(tip, "transform", `translate(${x4}px, ${MARGIN * 2}px)`);
|
|
4346
|
-
return;
|
|
4347
|
-
}
|
|
4348
|
-
const elapsed = last ? now - last : FRAME;
|
|
4349
|
-
const step = tweenStep(at2, target, elapsed, reduced);
|
|
4350
|
-
at2 = step.values;
|
|
4351
|
-
drawBox(boxParts(at2, target[4], ratio));
|
|
4352
|
-
if (model)
|
|
4353
|
-
drawTints(at2);
|
|
4354
|
-
const edges = {
|
|
4355
|
-
top: target[1],
|
|
4356
|
-
bottom: target[1] + target[3],
|
|
4357
|
-
left: target[0],
|
|
4358
|
-
right: target[0] + target[2]
|
|
4359
|
-
};
|
|
4360
|
-
const spot = card ? cardPlace(edges, size, view) : labelPlace(edges, size, view, pointerX);
|
|
4361
|
-
const goal = [Math.round(spot.x), Math.round(spot.y)];
|
|
4362
|
-
const move = tweenStep(labelAt ?? goal, goal, elapsed, reduced);
|
|
4363
|
-
labelAt = move.values;
|
|
4364
|
-
const [x3 = 0, y4 = 0] = labelAt;
|
|
4365
|
-
write(tip, "transform", `translate(${snap(x3, ratio)}px, ${snap(y4, ratio)}px)`);
|
|
4366
|
-
const done = step.done && move.done;
|
|
4367
|
-
last = done ? 0 : now;
|
|
4368
|
-
if (!done)
|
|
4369
|
-
schedule();
|
|
4370
|
-
}
|
|
4371
|
-
function hide() {
|
|
4372
|
-
hideTimer = 0;
|
|
4373
|
-
element = null;
|
|
4374
|
-
clearTimeout(factsTimer);
|
|
4375
|
-
facts = null;
|
|
4376
|
-
rows = [];
|
|
4377
|
-
box.classList.remove("on");
|
|
4378
|
-
label.classList.remove("on");
|
|
4379
|
-
stale = true;
|
|
4380
|
-
schedule();
|
|
4381
|
-
}
|
|
4382
|
-
function remove() {
|
|
4383
|
-
if (removed)
|
|
4384
|
-
return;
|
|
4385
|
-
removed = true;
|
|
4386
|
-
clearTimeout(hideTimer);
|
|
4387
|
-
clearTimeout(toastTimer);
|
|
4388
|
-
clearTimeout(fadeTimer);
|
|
4389
|
-
clearTimeout(factsTimer);
|
|
4390
|
-
clearInterval(ticker);
|
|
4391
|
-
if (frame)
|
|
4392
|
-
window.cancelAnimationFrame(frame);
|
|
4393
|
-
window.removeEventListener("scroll", sync, true);
|
|
4394
|
-
window.removeEventListener("resize", resize);
|
|
4395
|
-
reduce.removeEventListener("change", still);
|
|
4396
|
-
stopSystem();
|
|
4397
|
-
stopColor();
|
|
4398
|
-
hold.release();
|
|
4399
|
-
host.remove();
|
|
4400
|
-
}
|
|
4401
|
-
const stopSystem = watchSystemMedia(still);
|
|
4402
|
-
paint();
|
|
4403
|
-
const stopColor = subscribe((state) => {
|
|
4404
|
-
color = state.grabColor;
|
|
4405
|
-
paint();
|
|
4406
|
-
});
|
|
4407
|
-
reduce.addEventListener("change", still);
|
|
4408
|
-
window.addEventListener("scroll", sync, { capture: true, passive: true });
|
|
4409
|
-
window.addEventListener("resize", resize);
|
|
4410
|
-
const ticker = window.setInterval(sync, SYNC_EVERY);
|
|
4411
|
-
getComputedStyle(glow).opacity;
|
|
4412
|
-
if (!quiet)
|
|
4413
|
-
glow.classList.add("on");
|
|
4414
|
-
return {
|
|
4415
|
-
draw(current, next, gathered) {
|
|
4416
|
-
if (closing)
|
|
4417
|
-
return;
|
|
4418
|
-
picked = gathered;
|
|
4419
|
-
if (current) {
|
|
4420
|
-
clearTimeout(hideTimer);
|
|
4421
|
-
hideTimer = 0;
|
|
4422
|
-
if (card && current !== element) {
|
|
4423
|
-
clearTimeout(factsTimer);
|
|
4424
|
-
factsTimer = window.setTimeout(() => readCard(current), DWELL);
|
|
4425
|
-
}
|
|
4426
|
-
element = current;
|
|
4427
|
-
text = next;
|
|
4428
|
-
checked = false;
|
|
4429
|
-
} else if (element && !hideTimer) {
|
|
4430
|
-
hideTimer = window.setTimeout(hide, HIDE_WAIT);
|
|
4431
|
-
}
|
|
4432
|
-
stale = true;
|
|
4433
|
-
schedule();
|
|
4434
|
-
},
|
|
4435
|
-
point(x3) {
|
|
4436
|
-
if (closing || x3 === pointerX)
|
|
4437
|
-
return;
|
|
4438
|
-
pointerX = x3;
|
|
4439
|
-
if (element)
|
|
4440
|
-
schedule();
|
|
4441
|
-
},
|
|
4442
|
-
toast(message, near, mark2) {
|
|
4443
|
-
if (removed)
|
|
4444
|
-
return;
|
|
4445
|
-
clearTimeout(hideTimer);
|
|
4446
|
-
clearTimeout(toastTimer);
|
|
4447
|
-
clearTimeout(fadeTimer);
|
|
4448
|
-
hideTimer = 0;
|
|
4449
|
-
toasting = true;
|
|
4450
|
-
box.classList.toggle("copied", mark2);
|
|
4451
|
-
element = near?.isConnected ? near : null;
|
|
4452
|
-
text = { tag: "", name: message };
|
|
4453
|
-
checked = mark2;
|
|
4454
|
-
stale = true;
|
|
4455
|
-
schedule();
|
|
4456
|
-
toastTimer = window.setTimeout(() => {
|
|
4457
|
-
toasting = false;
|
|
4458
|
-
hide();
|
|
4459
|
-
if (!closing)
|
|
4460
|
-
box.classList.remove("copied");
|
|
4461
|
-
if (closing)
|
|
4462
|
-
fadeTimer = window.setTimeout(remove, fade());
|
|
4463
|
-
}, TOAST_TIME);
|
|
4464
|
-
},
|
|
4465
|
-
area(ring) {
|
|
4466
|
-
if (closing || ring === only)
|
|
4467
|
-
return;
|
|
4468
|
-
only = ring;
|
|
4469
|
-
schedule();
|
|
4470
|
-
},
|
|
4471
|
-
destroy() {
|
|
4472
|
-
if (closing)
|
|
4473
|
-
return;
|
|
4474
|
-
closing = true;
|
|
4475
|
-
clearTimeout(hideTimer);
|
|
4476
|
-
glow.classList.remove("on");
|
|
4477
|
-
picked = [];
|
|
4478
|
-
shapes = [];
|
|
4479
|
-
drawPicks(1);
|
|
4480
|
-
if (toasting)
|
|
4481
|
-
return;
|
|
4482
|
-
hide();
|
|
4483
|
-
fadeTimer = window.setTimeout(remove, fade());
|
|
4484
|
-
}
|
|
4485
|
-
};
|
|
4486
|
-
}
|
|
4487
|
-
|
|
4488
|
-
// src/grab/picks.ts
|
|
4489
|
-
function togglePick(picked, item) {
|
|
4490
|
-
return picked.includes(item) ? picked.filter((entry) => entry !== item) : [...picked, item];
|
|
4491
|
-
}
|
|
4492
|
-
function flushPicks(picked, clicked) {
|
|
4493
|
-
if (clicked === null || picked.includes(clicked))
|
|
4494
|
-
return [...picked];
|
|
4495
|
-
return [...picked, clicked];
|
|
4496
|
-
}
|
|
4497
|
-
function copiedText(count) {
|
|
4498
|
-
return count > 1 ? `Copied ${count}` : "Copied";
|
|
4499
|
-
}
|
|
4500
|
-
|
|
4501
|
-
// src/grab/mode.ts
|
|
4502
|
-
var PREPARE = 80;
|
|
4503
|
-
var HIT_EVERY = 32;
|
|
4504
|
-
var BLOCKED = [
|
|
4505
|
-
"pointerdown",
|
|
4506
|
-
"mousedown",
|
|
4507
|
-
"pointerup",
|
|
4508
|
-
"mouseup",
|
|
4509
|
-
"click",
|
|
4510
|
-
"dblclick",
|
|
4511
|
-
"auxclick",
|
|
4512
|
-
"pointerover",
|
|
4513
|
-
"pointerout",
|
|
4514
|
-
"mouseover",
|
|
4515
|
-
"mouseout"
|
|
4516
|
-
];
|
|
4517
|
-
var PAGE = {
|
|
4518
|
-
componentOf,
|
|
4519
|
-
copyGrab,
|
|
4520
|
-
createOverlay,
|
|
4521
|
-
grabEntry,
|
|
4522
|
-
grabTargetAt,
|
|
4523
|
-
quickEntry
|
|
4524
|
-
};
|
|
4525
|
-
function fromDevknobs(event) {
|
|
4526
|
-
const target = event.composedPath()[0];
|
|
4527
|
-
return target instanceof Element && isDevknobs(target);
|
|
4528
|
-
}
|
|
4529
|
-
function isTyping(event) {
|
|
4530
|
-
const target = event.composedPath()[0];
|
|
4531
|
-
if (!(target instanceof HTMLElement))
|
|
4532
|
-
return false;
|
|
4533
|
-
return target.tagName === "INPUT" || target.tagName === "TEXTAREA" || target.isContentEditable;
|
|
4534
|
-
}
|
|
4535
|
-
function onControl(event) {
|
|
4536
|
-
const target = event.composedPath()[0];
|
|
4537
|
-
return isTyping(event) || target instanceof HTMLElement && target.tagName === "BUTTON";
|
|
4538
|
-
}
|
|
4539
|
-
function startMode(options, page = PAGE) {
|
|
4540
|
-
const { purpose } = options;
|
|
4541
|
-
const overlay = page.createOverlay(false, purpose !== undefined);
|
|
4542
|
-
const navigator = createNavigator();
|
|
4543
|
-
const ready = new WeakMap;
|
|
4544
|
-
const warming = new WeakSet;
|
|
4545
|
-
const labels = new WeakMap;
|
|
4546
|
-
let current = null;
|
|
4547
|
-
let candidate = null;
|
|
4548
|
-
let since = 0;
|
|
4549
|
-
let leftAt = Number.NEGATIVE_INFINITY;
|
|
4550
|
-
let picked = [];
|
|
4551
|
-
let prepareTimer = 0;
|
|
4552
|
-
let point = null;
|
|
4553
|
-
let hitPoint = null;
|
|
4554
|
-
let hitAt = 0;
|
|
4555
|
-
let hitTimer = 0;
|
|
4556
|
-
let settleTimer = 0;
|
|
4557
|
-
let stopped = false;
|
|
4558
|
-
ensureStyle("grab-cursor").textContent = "*:not([data-devknobs]){cursor:crosshair!important}";
|
|
4559
|
-
pause(true);
|
|
4560
|
-
function warm(element) {
|
|
4561
|
-
if (purpose || ready.has(element) || warming.has(element))
|
|
4562
|
-
return;
|
|
4563
|
-
warming.add(element);
|
|
4564
|
-
page.grabEntry(element).then((entry) => ready.set(element, entry)).catch(() => {
|
|
4565
|
-
return;
|
|
4566
|
-
}).finally(() => warming.delete(element));
|
|
4567
|
-
}
|
|
4568
|
-
function labelOf(element) {
|
|
4569
|
-
if (purpose)
|
|
4570
|
-
return purpose.label(element);
|
|
4571
|
-
let name = labels.get(element);
|
|
4572
|
-
if (name === undefined) {
|
|
4573
|
-
name = page.componentOf(element);
|
|
4574
|
-
labels.set(element, name);
|
|
4575
|
-
}
|
|
4576
|
-
return { tag: element.tagName.toLowerCase(), name };
|
|
4577
|
-
}
|
|
4578
|
-
function draw() {
|
|
4579
|
-
if (stopped)
|
|
4580
|
-
return;
|
|
4581
|
-
if (current && !current.isConnected)
|
|
4582
|
-
current = null;
|
|
4583
|
-
picked = picked.filter((element) => element.isConnected);
|
|
4584
|
-
overlay.draw(current, current ? labelOf(current) : { tag: "", name: null }, picked);
|
|
4585
|
-
}
|
|
4586
|
-
function select(element) {
|
|
4587
|
-
if (element === current)
|
|
4588
|
-
return;
|
|
4589
|
-
current = element;
|
|
4590
|
-
if (!element)
|
|
4591
|
-
leftAt = performance.now();
|
|
4592
|
-
clearTimeout(prepareTimer);
|
|
4593
|
-
if (element)
|
|
4594
|
-
prepareTimer = window.setTimeout(() => warm(element), PREPARE);
|
|
4595
|
-
draw();
|
|
4596
|
-
}
|
|
4597
|
-
function copy(elements) {
|
|
4598
|
-
if (elements.length === 0)
|
|
4599
|
-
return;
|
|
4600
|
-
const entries = elements.map((element) => ready.get(element) ?? page.quickEntry(element));
|
|
4601
|
-
const anchor = elements[elements.length - 1] ?? null;
|
|
4602
|
-
overlay.toast(copiedText(elements.length), anchor, true);
|
|
4603
|
-
page.copyGrab({ content: joinEntries(entries), entries }).then((copied) => {
|
|
4604
|
-
if (!copied)
|
|
4605
|
-
overlay.toast("Copy failed", anchor, false);
|
|
4606
|
-
});
|
|
4607
|
-
for (const element of elements)
|
|
4608
|
-
warm(element);
|
|
4609
|
-
exit();
|
|
4610
|
-
}
|
|
4611
|
-
function drop() {
|
|
4612
|
-
clearTimeout(hitTimer);
|
|
4613
|
-
clearTimeout(settleTimer);
|
|
4614
|
-
hitTimer = 0;
|
|
4615
|
-
settleTimer = 0;
|
|
4616
|
-
}
|
|
4617
|
-
function hit(now = false) {
|
|
4618
|
-
drop();
|
|
4619
|
-
if (!point)
|
|
4620
|
-
return;
|
|
4621
|
-
const at2 = performance.now();
|
|
4622
|
-
const target = page.grabTargetAt(document, point.x, point.y);
|
|
4623
|
-
const speed = speedOf(hitPoint ?? point, point, at2 - hitAt);
|
|
4624
|
-
hitAt = at2;
|
|
4625
|
-
hitPoint = point;
|
|
4626
|
-
if (target !== candidate) {
|
|
4627
|
-
candidate = target;
|
|
4628
|
-
since = at2;
|
|
4629
|
-
}
|
|
4630
|
-
if (target === current)
|
|
4631
|
-
return;
|
|
4632
|
-
const held = at2 - since;
|
|
4633
|
-
const boxed = current !== null || at2 - leftAt < HIDE_WAIT;
|
|
4634
|
-
if (now || !target || settles({ boxed, held, speed })) {
|
|
4635
|
-
navigator.clear();
|
|
4636
|
-
select(target);
|
|
4637
|
-
return;
|
|
4638
|
-
}
|
|
4639
|
-
settleTimer = window.setTimeout(() => hit(), Math.min(HIT_EVERY, DWELL - held));
|
|
4640
|
-
}
|
|
4641
|
-
function resolve2(at2 = point) {
|
|
4642
|
-
if (!hitTimer && !settleTimer)
|
|
4643
|
-
return;
|
|
4644
|
-
point = at2;
|
|
4645
|
-
hit(true);
|
|
4646
|
-
}
|
|
4647
|
-
function onPointerMove(event) {
|
|
4648
|
-
if (!event.isPrimary)
|
|
4649
|
-
return;
|
|
4650
|
-
point = { x: event.clientX, y: event.clientY };
|
|
4651
|
-
overlay.point(point.x);
|
|
4652
|
-
const wait = HIT_EVERY - (performance.now() - hitAt);
|
|
4653
|
-
if (wait <= 0) {
|
|
4654
|
-
hit();
|
|
4655
|
-
} else if (!hitTimer) {
|
|
4656
|
-
hitTimer = window.setTimeout(() => hit(), wait);
|
|
4657
|
-
}
|
|
4658
|
-
}
|
|
4659
|
-
function onBlocked(event) {
|
|
4660
|
-
if (fromDevknobs(event))
|
|
4661
|
-
return;
|
|
4662
|
-
event.preventDefault();
|
|
4663
|
-
event.stopPropagation();
|
|
4664
|
-
if (event.type !== "click" || !(event instanceof MouseEvent))
|
|
4665
|
-
return;
|
|
4666
|
-
resolve2({ x: event.clientX, y: event.clientY });
|
|
4667
|
-
const target = page.grabTargetAt(document, event.clientX, event.clientY) ?? (current?.isConnected ? current : null);
|
|
4668
|
-
if (!target)
|
|
4669
|
-
return;
|
|
4670
|
-
if (purpose) {
|
|
4671
|
-
purpose.pick(target);
|
|
4672
|
-
exit();
|
|
4673
|
-
return;
|
|
4674
|
-
}
|
|
4675
|
-
if (event.shiftKey) {
|
|
4676
|
-
picked = togglePick(picked, target);
|
|
4677
|
-
warm(target);
|
|
4678
|
-
draw();
|
|
4679
|
-
return;
|
|
4680
|
-
}
|
|
4681
|
-
copy(flushPicks(picked, target));
|
|
4682
|
-
}
|
|
4683
|
-
function keydown(event) {
|
|
4684
|
-
if (event.key === "Escape") {
|
|
4685
|
-
event.preventDefault();
|
|
4686
|
-
event.stopImmediatePropagation();
|
|
4687
|
-
exit();
|
|
4688
|
-
return;
|
|
4689
|
-
}
|
|
4690
|
-
const step = stepOf(event);
|
|
4691
|
-
if (step) {
|
|
4692
|
-
if (isTyping(event) || event.metaKey || event.ctrlKey || event.altKey)
|
|
4693
|
-
return;
|
|
4694
|
-
if (purpose && (event.key === "Tab" || onControl(event)))
|
|
4695
|
-
return;
|
|
4696
|
-
event.preventDefault();
|
|
4697
|
-
event.stopImmediatePropagation();
|
|
4698
|
-
const next = current?.isConnected ? navigator.next(step, current) : null;
|
|
4699
|
-
if (next) {
|
|
4700
|
-
drop();
|
|
4701
|
-
overlay.point(null);
|
|
4702
|
-
select(next);
|
|
4703
|
-
}
|
|
4704
|
-
return;
|
|
4705
|
-
}
|
|
4706
|
-
if (event.repeat) {
|
|
4707
|
-
if (options.heldKey(event))
|
|
4708
|
-
event.preventDefault();
|
|
4709
|
-
return;
|
|
4710
|
-
}
|
|
4711
|
-
if (purpose) {
|
|
4712
|
-
if (event.key !== "Enter" || onControl(event))
|
|
4713
|
-
return;
|
|
4714
|
-
resolve2();
|
|
4715
|
-
if (!current?.isConnected)
|
|
4716
|
-
return;
|
|
4717
|
-
event.preventDefault();
|
|
4718
|
-
event.stopImmediatePropagation();
|
|
4719
|
-
purpose.pick(current);
|
|
4720
|
-
exit();
|
|
4721
|
-
return;
|
|
4722
|
-
}
|
|
4723
|
-
if (event.key !== "Enter" && !isCLike(event.key, event.code))
|
|
4724
|
-
return;
|
|
4725
|
-
resolve2();
|
|
4726
|
-
const elements = flushPicks(picked, current);
|
|
4727
|
-
if (elements.length === 0)
|
|
4728
|
-
return;
|
|
4729
|
-
event.preventDefault();
|
|
4730
|
-
event.stopImmediatePropagation();
|
|
4731
|
-
copy(elements);
|
|
4732
|
-
}
|
|
4733
|
-
function onKeyup(event) {
|
|
4734
|
-
if (event.key === "Shift" && picked.length > 0)
|
|
4735
|
-
copy(picked);
|
|
4736
|
-
}
|
|
4737
|
-
for (const type of BLOCKED)
|
|
4738
|
-
window.addEventListener(type, onBlocked, true);
|
|
4739
|
-
window.addEventListener("pointermove", onPointerMove, true);
|
|
4740
|
-
window.addEventListener("keyup", onKeyup, true);
|
|
4741
|
-
function stop() {
|
|
4742
|
-
if (stopped)
|
|
4743
|
-
return;
|
|
4744
|
-
stopped = true;
|
|
4745
|
-
clearTimeout(prepareTimer);
|
|
4746
|
-
drop();
|
|
4747
|
-
for (const type of BLOCKED)
|
|
4748
|
-
window.removeEventListener(type, onBlocked, true);
|
|
4749
|
-
window.removeEventListener("pointermove", onPointerMove, true);
|
|
4750
|
-
window.removeEventListener("keyup", onKeyup, true);
|
|
4751
|
-
removeStyle("grab-cursor");
|
|
4752
|
-
pause(false);
|
|
4753
|
-
overlay.destroy();
|
|
4754
|
-
}
|
|
4755
|
-
function exit() {
|
|
4756
|
-
stop();
|
|
4757
|
-
options.onExit();
|
|
4758
|
-
}
|
|
4759
|
-
if (options.pointer) {
|
|
4760
|
-
point = options.pointer;
|
|
4761
|
-
overlay.point(point.x);
|
|
4762
|
-
hit();
|
|
4763
|
-
}
|
|
4764
|
-
return { keydown, stop };
|
|
4765
|
-
}
|
|
4766
|
-
// src/grab/outline.ts
|
|
4767
|
-
var NO_LABEL = { tag: "", name: null };
|
|
4768
|
-
function createOutline(make = createOverlay) {
|
|
4769
|
-
let overlay = null;
|
|
4770
|
-
let only = null;
|
|
4771
|
-
function show2(element) {
|
|
4772
|
-
if (!element) {
|
|
4773
|
-
overlay?.destroy();
|
|
4774
|
-
overlay = null;
|
|
4775
|
-
return;
|
|
4776
|
-
}
|
|
4777
|
-
if (!overlay) {
|
|
4778
|
-
overlay = make(true, true);
|
|
4779
|
-
if (only)
|
|
4780
|
-
overlay.area(only);
|
|
4781
|
-
}
|
|
4782
|
-
overlay.draw(null, NO_LABEL, [element]);
|
|
4783
|
-
}
|
|
4784
|
-
function area(ring) {
|
|
4785
|
-
only = ring;
|
|
4786
|
-
overlay?.area(ring);
|
|
4787
|
-
}
|
|
4788
|
-
return { show: show2, area, destroy: () => show2(null) };
|
|
4789
|
-
}
|
|
4790
|
-
|
|
4791
|
-
// src/grab/index.ts
|
|
4792
|
-
function iterable(value) {
|
|
4793
|
-
return typeof value === "object" && value !== null && typeof Reflect.get(value, Symbol.iterator) === "function";
|
|
4794
|
-
}
|
|
4795
|
-
function listOf(elements) {
|
|
4796
|
-
if (isElement(elements))
|
|
4797
|
-
return [elements];
|
|
4798
|
-
return iterable(elements) ? Array.from(elements) : [];
|
|
4799
|
-
}
|
|
4800
|
-
async function grab(elements, options = {}) {
|
|
4801
|
-
const found = listOf(elements).filter(isElement);
|
|
4802
|
-
if (found.length === 0)
|
|
4803
|
-
return null;
|
|
4804
|
-
const payload = await grabContext(found, options);
|
|
4805
|
-
if (!payload.content.trim())
|
|
4806
|
-
return null;
|
|
4807
|
-
return { ...payload, copied: await copyGrab(payload) };
|
|
4808
|
-
}
|
|
4809
|
-
export {
|
|
4810
|
-
startMode,
|
|
4811
|
-
grab,
|
|
4812
|
-
createOutline
|
|
4813
|
-
};
|
|
2772
|
+
export { escapeText, buildTrace, formatEntry, joinEntries, grabEntry, quickEntry, componentOf, grabContext };
|