@vinena/knobs 0.6.6 → 0.7.1
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 +26 -0
- package/README.md +13 -7
- package/THIRD_PARTY_NOTICES.md +3 -3
- package/dist/cli.d.ts +95 -0
- package/dist/cli.js +527 -0
- package/dist/{context-eawqn680.js → context-2r76ext7.js} +3 -3
- package/dist/{context-vd2xep5t.js → context-h1bdt8w3.js} +3 -3
- package/dist/early.global.js +7 -8
- package/dist/edit/html.d.ts +7 -3
- package/dist/edit/keep.d.ts +2 -2
- package/dist/{elementsview-n26sp8m7.js → elementsview-mcg6d5zp.js} +21 -19
- package/dist/{elementsview-dpm0xmb2.js → elementsview-mwr1s17z.js} +21 -19
- package/dist/engine/bezels.d.ts +2 -2
- package/dist/engine/check.d.ts +2 -2
- package/dist/engine/describe.d.ts +2 -2
- package/dist/engine/devices.d.ts +3 -3
- package/dist/engine/fit.d.ts +4 -4
- package/dist/engine/foldhand.d.ts +2 -2
- package/dist/engine/frame.d.ts +6 -6
- package/dist/engine/frames.d.ts +4 -4
- package/dist/engine/fresh.d.ts +12 -5
- package/dist/engine/header.d.ts +3 -1
- package/dist/engine/identity.d.ts +4 -4
- package/dist/engine/index.d.ts +7 -7
- package/dist/engine/locale.d.ts +2 -2
- package/dist/engine/morph.d.ts +2 -2
- package/dist/engine/native.d.ts +8 -8
- package/dist/engine/placeholder.d.ts +3 -3
- package/dist/engine/reload.d.ts +2 -2
- package/dist/engine/screen.d.ts +2 -2
- package/dist/engine/scrollkeep.d.ts +1 -1
- package/dist/engine/store.d.ts +11 -11
- package/dist/engine/storekeys.d.ts +34 -0
- package/dist/engine/style.d.ts +1 -1
- package/dist/engine/tabicon.d.ts +2 -2
- package/dist/engine/underneath.d.ts +1 -0
- package/dist/engine/width.d.ts +3 -3
- package/dist/{framekit-0as9t6a7.js → framekit-4v7nc3ea.js} +25 -20
- package/dist/{framekit-dknq662p.js → framekit-wyppj1se.js} +25 -20
- package/dist/grab/clipboard.d.ts +2 -0
- package/dist/{index-jfv7vavj.js → index-311fys81.js} +93 -29
- package/dist/index-3dcgysws.js +77 -0
- package/dist/{index-7vb2ct4s.js → index-3s4v7gw5.js} +11 -10
- package/dist/{index-ztnjefrh.js → index-585hs9tp.js} +5 -1
- package/dist/{index-za4ppxay.js → index-6t0w5s7p.js} +1 -1
- package/dist/{index-r1rdj05c.js → index-82y8x8vv.js} +14 -11
- package/dist/{index-dxga6h10.js → index-9targr2f.js} +26 -16
- package/dist/{index-x3sxssbs.js → index-a23nv5j4.js} +65 -45
- package/dist/{index-t4kssacm.js → index-abwqw8jh.js} +6 -1
- package/dist/{index-s6yzsvs4.js → index-bgzyc7rz.js} +22 -15
- package/dist/{index-t4wrs2a3.js → index-c1t6knbf.js} +20 -14
- package/dist/{index-7w0nm76e.js → index-cqymjce4.js} +20 -14
- package/dist/{index-69fvtkcm.js → index-dvtbh3c8.js} +24 -18
- package/dist/{index-ajs4na3f.js → index-k4w5v53q.js} +2 -2
- package/dist/{index-df35z48z.js → index-n31pn4ax.js} +20 -16
- package/dist/{index-ymqm185m.js → index-rps0bdq9.js} +1 -1
- package/dist/{index-a8ffw5ft.js → index-szd9bddn.js} +1 -1
- package/dist/{index-whehz74d.js → index-vhda420r.js} +32 -6
- package/dist/{index-xs29b55n.js → index-vmprrfwe.js} +5 -2
- package/dist/{index-20bc9yrj.js → index-vmz7htwn.js} +1 -1
- package/dist/index.d.ts +14 -8
- package/dist/index.global.js +176 -159
- package/dist/index.js +108 -43
- package/dist/instance.d.ts +7 -1
- package/dist/mark.d.ts +50 -0
- package/dist/{react-msn10fjb.js → react-4ezjf7mq.js} +24 -18
- package/dist/react-4qn9vsjw.js +78 -0
- package/dist/{react-73reavv4.js → react-4tcwpama.js} +1 -1
- package/dist/{react-k4pkm1p5.js → react-7eyps0cg.js} +2 -2
- package/dist/{react-10r2rczp.js → react-7tzwahsm.js} +14 -11
- package/dist/{react-yx3g9k55.js → react-amvrbng8.js} +5 -2
- package/dist/{react-5rq7bnsy.js → react-atw9y8ny.js} +5 -1
- package/dist/{react-4phtr2nd.js → react-dg4bjv3j.js} +1 -1
- package/dist/{react-vbk58f9m.js → react-hdneb4v3.js} +32 -6
- package/dist/{react-h9w04skh.js → react-j87bdhhe.js} +4 -1
- package/dist/{react-wtgvkf6g.js → react-mkafgzqf.js} +1 -1
- package/dist/{react-a1r0nr0g.js → react-ppyj3fg2.js} +65 -45
- package/dist/{react-0r5418av.js → react-rbmk30xk.js} +92 -29
- package/dist/{react-y9gr8yt2.js → react-rxw73n04.js} +1 -1
- package/dist/{react-5h7pxnax.js → react-tet7swk2.js} +22 -15
- package/dist/{react-5ekfj7g3.js → react-w94cfn87.js} +20 -16
- package/dist/{react-v08ywmtw.js → react-wzd3cfg8.js} +11 -10
- package/dist/{react-2b7725je.js → react-x209et38.js} +26 -16
- package/dist/react.d.ts +3 -1
- package/dist/react.js +111 -44
- package/dist/{replay-ehgxp9py.js → replay-3xqgt3xg.js} +8 -8
- package/dist/{replay-461gcdh1.js → replay-48gn27bj.js} +8 -8
- package/dist/storage/onload.d.ts +1 -1
- package/dist/{storageview-5p1y11b5.js → storageview-2rvwk0v7.js} +20 -17
- package/dist/{storageview-kxzpnfvr.js → storageview-6vq7nz02.js} +20 -17
- package/dist/styles/force.d.ts +3 -1
- package/dist/types.d.ts +4 -4
- package/dist/ui/actions.d.ts +3 -3
- package/dist/ui/bindings.d.ts +1 -1
- package/dist/ui/catalog.d.ts +14 -14
- package/dist/ui/changes.d.ts +1 -1
- package/dist/ui/colors.d.ts +1 -1
- package/dist/ui/deviceknobs.d.ts +2 -2
- package/dist/ui/editors.d.ts +3 -3
- package/dist/ui/foldslider.d.ts +2 -2
- package/dist/ui/icons.d.ts +5 -2
- package/dist/ui/keys.d.ts +1 -1
- package/dist/ui/list.d.ts +10 -10
- package/dist/ui/palette.d.ts +2 -2
- package/dist/ui/panel.d.ts +2 -0
- package/dist/ui/pin.d.ts +2 -2
- package/dist/ui/prefs.d.ts +1 -1
- package/dist/ui/rows.d.ts +3 -3
- package/dist/ui/settings.d.ts +11 -1
- package/dist/ui/storageview.d.ts +2 -2
- package/dist/ui/stylesview.d.ts +3 -3
- package/dist/ui/swatches.d.ts +2 -2
- package/package.json +5 -2
- package/skills/{devknobs → knobs}/SKILL.md +52 -51
- package/dist/index-5tv6sr74.js +0 -23
- package/dist/react-t2qnewz2.js +0 -24
|
@@ -10,16 +10,23 @@ import {
|
|
|
10
10
|
knobFrame,
|
|
11
11
|
newer,
|
|
12
12
|
parseHex,
|
|
13
|
+
readItem,
|
|
13
14
|
realNow,
|
|
15
|
+
removeItem,
|
|
14
16
|
removeStyle,
|
|
15
17
|
screenOf,
|
|
16
18
|
stamped,
|
|
17
19
|
turn,
|
|
18
|
-
webStorage
|
|
19
|
-
|
|
20
|
+
webStorage,
|
|
21
|
+
writeItem
|
|
22
|
+
} from "./react-rbmk30xk.js";
|
|
23
|
+
import {
|
|
24
|
+
findOwn,
|
|
25
|
+
ownSelector
|
|
26
|
+
} from "./react-4qn9vsjw.js";
|
|
20
27
|
|
|
21
28
|
// src/engine/scrollkeep.ts
|
|
22
|
-
var SCROLL_KEY = "
|
|
29
|
+
var SCROLL_KEY = "knobs:scroll";
|
|
23
30
|
var SCROLL_VERSION = 1;
|
|
24
31
|
var SCROLL_WINDOW = 1e4;
|
|
25
32
|
var HOLD = 2000;
|
|
@@ -148,11 +155,11 @@ function keep(view, role) {
|
|
|
148
155
|
const session = webStorage("session");
|
|
149
156
|
if (!session)
|
|
150
157
|
return;
|
|
151
|
-
const kept = keptWith(parseKept(session
|
|
158
|
+
const kept = keptWith(parseKept(readItem(session, SCROLL_KEY)), role, placeIn(view), realNow());
|
|
152
159
|
if (kept)
|
|
153
|
-
session
|
|
160
|
+
writeItem(session, SCROLL_KEY, JSON.stringify(stamped(kept, SCROLL_VERSION)));
|
|
154
161
|
else
|
|
155
|
-
|
|
162
|
+
removeItem(session, SCROLL_KEY);
|
|
156
163
|
} catch {}
|
|
157
164
|
}
|
|
158
165
|
function keepOwn() {
|
|
@@ -169,15 +176,15 @@ function resume() {
|
|
|
169
176
|
let target = null;
|
|
170
177
|
try {
|
|
171
178
|
const session = webStorage("session");
|
|
172
|
-
const text = session
|
|
179
|
+
const text = readItem(session, SCROLL_KEY);
|
|
173
180
|
if (!session || text === null)
|
|
174
181
|
return;
|
|
175
182
|
const role = isDevknobsFrame() ? "frame" : "page";
|
|
176
183
|
const { place, rest } = take(parseKept(text), role, window.location.pathname, realNow());
|
|
177
184
|
if (rest)
|
|
178
|
-
session
|
|
185
|
+
writeItem(session, SCROLL_KEY, JSON.stringify(stamped(rest, SCROLL_VERSION)));
|
|
179
186
|
else
|
|
180
|
-
|
|
187
|
+
removeItem(session, SCROLL_KEY);
|
|
181
188
|
target = place;
|
|
182
189
|
} catch {
|
|
183
190
|
return;
|
|
@@ -1532,7 +1539,7 @@ function putMat(node, mat) {
|
|
|
1532
1539
|
// src/engine/placeholder.ts
|
|
1533
1540
|
var Z_INDEX = 2147483645;
|
|
1534
1541
|
var EARLY = "early";
|
|
1535
|
-
var SNAPSHOT_KEY = "
|
|
1542
|
+
var SNAPSHOT_KEY = "knobs:snapshot";
|
|
1536
1543
|
var SNAPSHOT_VERSION = 1;
|
|
1537
1544
|
var EARLY_FRAMES = 60;
|
|
1538
1545
|
var earlyWait = 0;
|
|
@@ -1593,7 +1600,7 @@ function lookOf(value) {
|
|
|
1593
1600
|
}
|
|
1594
1601
|
function readSnapshot(knobs, view) {
|
|
1595
1602
|
try {
|
|
1596
|
-
const text = webStorage("session")
|
|
1603
|
+
const text = readItem(webStorage("session"), SNAPSHOT_KEY);
|
|
1597
1604
|
if (!text)
|
|
1598
1605
|
return null;
|
|
1599
1606
|
const data = JSON.parse(text);
|
|
@@ -1614,7 +1621,7 @@ function readSnapshot(knobs, view) {
|
|
|
1614
1621
|
}
|
|
1615
1622
|
function writeSnapshot(snapshot) {
|
|
1616
1623
|
try {
|
|
1617
|
-
webStorage("session")
|
|
1624
|
+
writeItem(webStorage("session"), SNAPSHOT_KEY, JSON.stringify(stamped(snapshot, SNAPSHOT_VERSION)));
|
|
1618
1625
|
} catch {
|
|
1619
1626
|
clearSnapshot();
|
|
1620
1627
|
}
|
|
@@ -1640,14 +1647,14 @@ function keepDrawing({ letterbox, zoom, key, css, look }) {
|
|
|
1640
1647
|
}
|
|
1641
1648
|
function clearSnapshot() {
|
|
1642
1649
|
try {
|
|
1643
|
-
webStorage("session")
|
|
1650
|
+
removeItem(webStorage("session"), SNAPSHOT_KEY);
|
|
1644
1651
|
} catch {}
|
|
1645
1652
|
}
|
|
1646
1653
|
function earlyHost() {
|
|
1647
|
-
return document
|
|
1654
|
+
return findOwn(document, EARLY, "div");
|
|
1648
1655
|
}
|
|
1649
1656
|
function dropEarly() {
|
|
1650
|
-
for (const node of Array.from(document.querySelectorAll(
|
|
1657
|
+
for (const node of Array.from(document.querySelectorAll(ownSelector(EARLY)))) {
|
|
1651
1658
|
node.remove();
|
|
1652
1659
|
}
|
|
1653
1660
|
removeStyle(EARLY);
|
|
@@ -1,13 +1,18 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import {
|
|
3
|
+
itemKeys,
|
|
3
4
|
newer,
|
|
5
|
+
readItem,
|
|
4
6
|
realNow,
|
|
7
|
+
removeItem,
|
|
8
|
+
sameItem,
|
|
5
9
|
stamped,
|
|
6
|
-
webStorage
|
|
7
|
-
|
|
10
|
+
webStorage,
|
|
11
|
+
writeItem
|
|
12
|
+
} from "./react-rbmk30xk.js";
|
|
8
13
|
import {
|
|
9
14
|
__require
|
|
10
|
-
} from "./react-
|
|
15
|
+
} from "./react-4qn9vsjw.js";
|
|
11
16
|
|
|
12
17
|
// src/edit/log.ts
|
|
13
18
|
function copy(edit) {
|
|
@@ -181,7 +186,7 @@ function riskyEdit(edit) {
|
|
|
181
186
|
}
|
|
182
187
|
|
|
183
188
|
// src/edit/keep.ts
|
|
184
|
-
var EDITS_KEY = "
|
|
189
|
+
var EDITS_KEY = "knobs:edits:";
|
|
185
190
|
var EDITS_VERSION = 1;
|
|
186
191
|
var MAX_EDITS = 200;
|
|
187
192
|
var MAX_BYTES = 256 * 1024;
|
|
@@ -189,7 +194,7 @@ var MAX_PAGES = 20;
|
|
|
189
194
|
var FIELD_MAX = 64 * 1024;
|
|
190
195
|
var KINDS = ["css-value", "css-toggle", "css-add", "css-rule", "text", "attr", "html", "hide", "delete", "move"];
|
|
191
196
|
var REASONS = {
|
|
192
|
-
invalid: "not an edit
|
|
197
|
+
invalid: "not an edit knobs reads",
|
|
193
198
|
missing: "not found on the page",
|
|
194
199
|
rule: "its rule is not on the page",
|
|
195
200
|
changed: "the page has another value now",
|
|
@@ -290,29 +295,28 @@ function writtenAt(text2) {
|
|
|
290
295
|
}
|
|
291
296
|
function otherPages(storage, kept) {
|
|
292
297
|
const pages = [];
|
|
293
|
-
for (
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
pages.push({ key, at: writtenAt(storage.getItem(key)) });
|
|
298
|
+
for (const key of itemKeys(storage, EDITS_KEY)) {
|
|
299
|
+
if (key !== kept)
|
|
300
|
+
pages.push({ key, at: writtenAt(readItem(storage, key)) });
|
|
297
301
|
}
|
|
298
302
|
return pages.sort((a, b) => b.at - a.at).map((page) => page.key);
|
|
299
303
|
}
|
|
300
304
|
function evict(storage, kept) {
|
|
301
305
|
for (const key of otherPages(storage, kept).slice(MAX_PAGES - 1))
|
|
302
|
-
|
|
306
|
+
removeItem(storage, key);
|
|
303
307
|
}
|
|
304
308
|
function write(storage, key, text2) {
|
|
305
309
|
let older = null;
|
|
306
310
|
for (;; ) {
|
|
307
311
|
try {
|
|
308
|
-
storage
|
|
312
|
+
writeItem(storage, key, text2);
|
|
309
313
|
return;
|
|
310
314
|
} catch (error) {
|
|
311
315
|
older ??= otherPages(storage, key);
|
|
312
316
|
const oldest = older.pop();
|
|
313
317
|
if (!oldest)
|
|
314
318
|
throw error;
|
|
315
|
-
|
|
319
|
+
removeItem(storage, oldest);
|
|
316
320
|
}
|
|
317
321
|
}
|
|
318
322
|
}
|
|
@@ -328,7 +332,7 @@ function localEditsStore(path = pathNow()) {
|
|
|
328
332
|
return {
|
|
329
333
|
load() {
|
|
330
334
|
try {
|
|
331
|
-
const kept = webStorage("local")
|
|
335
|
+
const kept = readItem(webStorage("local"), pageKey());
|
|
332
336
|
return kept ? JSON.parse(kept) : null;
|
|
333
337
|
} catch {
|
|
334
338
|
return null;
|
|
@@ -340,7 +344,7 @@ function localEditsStore(path = pathNow()) {
|
|
|
340
344
|
return;
|
|
341
345
|
try {
|
|
342
346
|
if (kept === null)
|
|
343
|
-
|
|
347
|
+
removeItem(storage, pageKey());
|
|
344
348
|
else {
|
|
345
349
|
write(storage, pageKey(), JSON.stringify({ ...kept, at: realNow() }));
|
|
346
350
|
evict(storage, pageKey());
|
|
@@ -349,7 +353,7 @@ function localEditsStore(path = pathNow()) {
|
|
|
349
353
|
},
|
|
350
354
|
subscribe(listener) {
|
|
351
355
|
const onStorage = (event) => {
|
|
352
|
-
if (event.key === null || event.key
|
|
356
|
+
if (event.key === null || sameItem(event.key, pageKey()))
|
|
353
357
|
listener();
|
|
354
358
|
};
|
|
355
359
|
window.addEventListener("storage", onStorage);
|
|
@@ -409,7 +413,7 @@ function settled(view, quiet = QUIET, longest = SETTLE_MAX) {
|
|
|
409
413
|
}
|
|
410
414
|
function createKeeper(options) {
|
|
411
415
|
const { log, store, view } = options;
|
|
412
|
-
const loadReplay = options.replay ?? (() => import("./replay-
|
|
416
|
+
const loadReplay = options.replay ?? (() => import("./replay-48gn27bj.js").then(({ replayEdits }) => replayEdits));
|
|
413
417
|
const wait = options.settled ?? (() => settled(view));
|
|
414
418
|
const frame = options.frame ?? (() => null);
|
|
415
419
|
const ours = new WeakMap;
|
|
@@ -1,18 +1,18 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import {
|
|
3
3
|
label
|
|
4
|
-
} from "./react-
|
|
4
|
+
} from "./react-dg4bjv3j.js";
|
|
5
5
|
import {
|
|
6
6
|
frameWindow,
|
|
7
7
|
subscribe
|
|
8
|
-
} from "./react-
|
|
8
|
+
} from "./react-ppyj3fg2.js";
|
|
9
9
|
import {
|
|
10
10
|
inField,
|
|
11
11
|
isFunctionKey,
|
|
12
12
|
keyIs,
|
|
13
13
|
typesInField,
|
|
14
14
|
withShift
|
|
15
|
-
} from "./react-
|
|
15
|
+
} from "./react-hdneb4v3.js";
|
|
16
16
|
import {
|
|
17
17
|
addStyle,
|
|
18
18
|
isDevknobsFrame,
|
|
@@ -20,10 +20,11 @@ import {
|
|
|
20
20
|
post,
|
|
21
21
|
readMessage,
|
|
22
22
|
systemMedia
|
|
23
|
-
} from "./react-
|
|
23
|
+
} from "./react-rbmk30xk.js";
|
|
24
24
|
import {
|
|
25
|
-
__require
|
|
26
|
-
|
|
25
|
+
__require,
|
|
26
|
+
markOwn
|
|
27
|
+
} from "./react-4qn9vsjw.js";
|
|
27
28
|
|
|
28
29
|
// src/grab/keys.ts
|
|
29
30
|
var HOLD = 100;
|
|
@@ -154,7 +155,7 @@ function systemScheme() {
|
|
|
154
155
|
if (own)
|
|
155
156
|
return own.scheme;
|
|
156
157
|
const host = document.createElement("div");
|
|
157
|
-
host
|
|
158
|
+
markOwn(host, "probe");
|
|
158
159
|
host.style.cssText = "position:fixed;width:0;height:0;overflow:hidden;pointer-events:none";
|
|
159
160
|
const root = host.attachShadow({ mode: "open" });
|
|
160
161
|
addStyle(root, "i{display:block;width:0}@media (prefers-color-scheme: dark){i{width:1px}}");
|
|
@@ -165,7 +166,7 @@ function systemScheme() {
|
|
|
165
166
|
host.remove();
|
|
166
167
|
return dark ? "dark" : "light";
|
|
167
168
|
}
|
|
168
|
-
function createGrab(options = {}, loadMode = () => import("./index-
|
|
169
|
+
function createGrab(options = {}, loadMode = () => import("./index-cqymjce4.js")) {
|
|
169
170
|
const keyNow = options.key ?? defaultGrabKey;
|
|
170
171
|
const { purpose } = options;
|
|
171
172
|
const channel = purpose?.channel ?? "grab";
|
|
@@ -374,7 +375,7 @@ function held(view) {
|
|
|
374
375
|
return null;
|
|
375
376
|
}
|
|
376
377
|
}
|
|
377
|
-
function createInspect(options = {}, load = () => import("./index-
|
|
378
|
+
function createInspect(options = {}, load = () => import("./index-cqymjce4.js"), frameOf = frameWindow) {
|
|
378
379
|
const inFrame = isDevknobsFrame();
|
|
379
380
|
const listeners = new Set;
|
|
380
381
|
let outliner = null;
|
|
@@ -482,7 +483,7 @@ async function copyText(text, data = { "text/plain": text }) {
|
|
|
482
483
|
};
|
|
483
484
|
const textarea = document.createElement("textarea");
|
|
484
485
|
textarea.value = text;
|
|
485
|
-
textarea
|
|
486
|
+
markOwn(textarea, "grab");
|
|
486
487
|
textarea.setAttribute("aria-hidden", "true");
|
|
487
488
|
textarea.style.cssText = "position:fixed;left:-9999px;top:0;opacity:0";
|
|
488
489
|
document.addEventListener("copy", onCopy);
|
|
@@ -6,31 +6,41 @@ import {
|
|
|
6
6
|
import {
|
|
7
7
|
resolveNesting,
|
|
8
8
|
splitList
|
|
9
|
-
} from "./react-
|
|
9
|
+
} from "./react-w94cfn87.js";
|
|
10
10
|
import {
|
|
11
11
|
flatParent,
|
|
12
12
|
isNewRuleSheet,
|
|
13
13
|
isShadowRoot,
|
|
14
14
|
scopeOf
|
|
15
|
-
} from "./react-
|
|
15
|
+
} from "./react-dg4bjv3j.js";
|
|
16
16
|
import {
|
|
17
17
|
isDevknobs
|
|
18
|
-
} from "./react-
|
|
18
|
+
} from "./react-hdneb4v3.js";
|
|
19
19
|
import {
|
|
20
20
|
addStyle,
|
|
21
21
|
ensureStyle,
|
|
22
22
|
fresh,
|
|
23
23
|
isOwnSheet,
|
|
24
24
|
newer,
|
|
25
|
+
readItem,
|
|
26
|
+
removeItem,
|
|
25
27
|
removeStyle,
|
|
28
|
+
sameItem,
|
|
26
29
|
stamped,
|
|
27
30
|
versionOf,
|
|
28
|
-
webStorage
|
|
29
|
-
|
|
31
|
+
webStorage,
|
|
32
|
+
writeItem
|
|
33
|
+
} from "./react-rbmk30xk.js";
|
|
34
|
+
import {
|
|
35
|
+
ATTRIBUTES,
|
|
36
|
+
getMark,
|
|
37
|
+
removeMark,
|
|
38
|
+
setMark
|
|
39
|
+
} from "./react-4qn9vsjw.js";
|
|
30
40
|
|
|
31
41
|
// src/styles/force.ts
|
|
32
42
|
var FORCED_STATES = ["hover", "focus", "focus-visible", "active", "focus-within"];
|
|
33
|
-
var FORCE_ATTRIBUTE =
|
|
43
|
+
var FORCE_ATTRIBUTE = ATTRIBUTES.force;
|
|
34
44
|
var SHEET = "force";
|
|
35
45
|
var UP = {
|
|
36
46
|
hover: "hover",
|
|
@@ -235,7 +245,7 @@ function syncForced() {
|
|
|
235
245
|
const wanted = new Set;
|
|
236
246
|
const scopes = new Set;
|
|
237
247
|
for (const { element } of forced.marked) {
|
|
238
|
-
for (const state of (element
|
|
248
|
+
for (const state of (getMark(element, FORCE_ATTRIBUTE) ?? "").split(" "))
|
|
239
249
|
if (isState(state))
|
|
240
250
|
wanted.add(state);
|
|
241
251
|
scopes.add(scopeOf(element));
|
|
@@ -258,9 +268,9 @@ function clearForced() {
|
|
|
258
268
|
for (const { element, before } of forced.marked) {
|
|
259
269
|
try {
|
|
260
270
|
if (before === null)
|
|
261
|
-
element
|
|
271
|
+
removeMark(element, FORCE_ATTRIBUTE);
|
|
262
272
|
else
|
|
263
|
-
element
|
|
273
|
+
setMark(element, FORCE_ATTRIBUTE, before);
|
|
264
274
|
} catch {}
|
|
265
275
|
}
|
|
266
276
|
for (const [scope, style] of forced.sheets) {
|
|
@@ -282,8 +292,8 @@ function forceState(element, states) {
|
|
|
282
292
|
for (const [one, own] of marks(element, chosen)) {
|
|
283
293
|
if (own.length === 0)
|
|
284
294
|
continue;
|
|
285
|
-
forced.marked.push({ element: one, before: one
|
|
286
|
-
one
|
|
295
|
+
forced.marked.push({ element: one, before: getMark(one, FORCE_ATTRIBUTE) });
|
|
296
|
+
setMark(one, FORCE_ATTRIBUTE, own.join(" "));
|
|
287
297
|
}
|
|
288
298
|
current = forced;
|
|
289
299
|
syncForced();
|
|
@@ -555,7 +565,7 @@ function createSizer(context) {
|
|
|
555
565
|
}
|
|
556
566
|
|
|
557
567
|
// src/ui/prefs.ts
|
|
558
|
-
var PREFS_KEY = "
|
|
568
|
+
var PREFS_KEY = "knobs:prefs";
|
|
559
569
|
var PREFS_VERSION = 6;
|
|
560
570
|
var STYLES_MODE = "simple";
|
|
561
571
|
var STYLES_BOX = true;
|
|
@@ -602,7 +612,7 @@ function resolvePrefs(base, stored) {
|
|
|
602
612
|
}
|
|
603
613
|
function loadPrefs() {
|
|
604
614
|
try {
|
|
605
|
-
return readPrefs(webStorage("local")
|
|
615
|
+
return readPrefs(readItem(webStorage("local"), PREFS_KEY));
|
|
606
616
|
} catch {
|
|
607
617
|
return {};
|
|
608
618
|
}
|
|
@@ -610,9 +620,9 @@ function loadPrefs() {
|
|
|
610
620
|
function keepPrefs(prefs) {
|
|
611
621
|
try {
|
|
612
622
|
if (Object.keys(prefs).length === 0)
|
|
613
|
-
webStorage("local")
|
|
623
|
+
removeItem(webStorage("local"), PREFS_KEY);
|
|
614
624
|
else
|
|
615
|
-
webStorage("local")
|
|
625
|
+
writeItem(webStorage("local"), PREFS_KEY, JSON.stringify(stamped(prefs, PREFS_VERSION)));
|
|
616
626
|
} catch {}
|
|
617
627
|
}
|
|
618
628
|
function createPrefs(options = {}) {
|
|
@@ -639,7 +649,7 @@ function createPrefs(options = {}) {
|
|
|
639
649
|
changed();
|
|
640
650
|
}
|
|
641
651
|
function onStorage(event) {
|
|
642
|
-
if (event.key !==
|
|
652
|
+
if (event.key !== null && !sameItem(event.key, PREFS_KEY))
|
|
643
653
|
return;
|
|
644
654
|
if (fresh())
|
|
645
655
|
return;
|
package/dist/react.d.ts
CHANGED
|
@@ -3,4 +3,6 @@ import { type MountOptions } from "./index";
|
|
|
3
3
|
* Mount the knobs from a React tree. Renders nothing, so drop it anywhere and
|
|
4
4
|
* render it in development only. Options are read once, on mount.
|
|
5
5
|
*/
|
|
6
|
-
export declare function
|
|
6
|
+
export declare function Knobs(props: MountOptions): null;
|
|
7
|
+
/** @deprecated use Knobs */
|
|
8
|
+
export declare const DevKnobs: typeof Knobs;
|