@vinena/knobs 0.5.3 → 0.6.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 +32 -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-dm5v3z5a.js +3761 -0
- package/dist/elementsview-xm82cvs2.js +3762 -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 +438 -153
- package/dist/index.js +594 -486
- 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 +590 -486
- 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 +17 -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 +22 -1
- 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
package/dist/ui/keys.d.ts
CHANGED
|
@@ -16,7 +16,7 @@ export interface Combo {
|
|
|
16
16
|
key: string;
|
|
17
17
|
}
|
|
18
18
|
/** The shortcuts the panel can be told to use, and by whom. */
|
|
19
|
-
export type Binding = "panel" | "grab" | "inspect" | "replay" | "requests" | "storage" | "reset";
|
|
19
|
+
export type Binding = "panel" | "grab" | "inspect" | "replay" | "requests" | "storage" | "reset" | "elements" | "settings";
|
|
20
20
|
/** Each binding's key as the mount options and the defaults give it: every binding has one. */
|
|
21
21
|
export type BaseKeys = Record<Binding, Combo>;
|
|
22
22
|
/**
|
|
@@ -47,8 +47,9 @@ export declare function comboLabel(combo: Combo, mac: boolean): string;
|
|
|
47
47
|
export declare function comboSpoken(combo: Combo): string;
|
|
48
48
|
/**
|
|
49
49
|
* The panel's keys with none set: shift and the hotkey, shift g, shift c,
|
|
50
|
-
* shift r, shift n, shift s and shift
|
|
51
|
-
* panel or grab
|
|
50
|
+
* shift r, shift n, shift s, shift backspace, shift e and shift o. Where the
|
|
51
|
+
* mount gave the panel or grab one of inspect's, the elements view's or the
|
|
52
|
+
* settings' shift letters, that binding takes the next letter of its own.
|
|
52
53
|
*/
|
|
53
54
|
export declare function defaultKeys(options?: {
|
|
54
55
|
hotkey?: string;
|
|
@@ -59,6 +60,8 @@ export declare function defaultKeys(options?: {
|
|
|
59
60
|
* and not text. Its search is one: it finds in lower case anyway.
|
|
60
61
|
*/
|
|
61
62
|
export declare const KEYS_FIELD = "data-devknobs-keys";
|
|
63
|
+
/** Whether a key goes into any field, one of the panel's too, its search included. */
|
|
64
|
+
export declare function inField(event: Pick<KeyLike, "target" | "composedPath">): boolean;
|
|
62
65
|
/**
|
|
63
66
|
* Whether a key goes into a field: one of the page's, or one of the panel's
|
|
64
67
|
* other than those marked with `KEYS_FIELD`.
|
|
@@ -92,17 +95,18 @@ export declare function keyIs(event: {
|
|
|
92
95
|
export declare function comboMatches(event: KeyLike, combo: Combo): boolean;
|
|
93
96
|
/** The letter that with shift replays the page's animations. */
|
|
94
97
|
export declare const REPLAY_KEY = "r";
|
|
95
|
-
/** The letter that with shift shows the requests log, and
|
|
98
|
+
/** The letter that with shift shows the requests log, from a closed panel too, and leaves it. */
|
|
96
99
|
export declare const REQUESTS_KEY = "n";
|
|
97
100
|
/** The letter that with shift shows and leaves the storage view. */
|
|
98
101
|
export declare const STORAGE_KEY = "s";
|
|
99
102
|
/**
|
|
100
103
|
* What a keydown asks of the panel, if anything: escape closes, and the
|
|
101
|
-
* panel's, replay's, requests', reset's
|
|
102
|
-
* theirs, the panel's winning where they are
|
|
103
|
-
* giving way to all. In a field, `actsHere`
|
|
104
|
+
* panel's, replay's, requests', reset's, the elements view's, the settings'
|
|
105
|
+
* and the storage view's keys do theirs, the panel's winning where they are
|
|
106
|
+
* the same, and the storage view's giving way to all. In a field, `actsHere`
|
|
107
|
+
* says whether the key is its.
|
|
104
108
|
*/
|
|
105
|
-
export declare function keyAction(event: KeyLike, keys: Pick<Keys, "panel" | "replay" | "requests" | "reset"> & Partial<Pick<Keys, "storage">>): KeyAction | null;
|
|
109
|
+
export declare function keyAction(event: KeyLike, keys: Pick<Keys, "panel" | "replay" | "requests" | "reset"> & Partial<Pick<Keys, "storage" | "elements" | "settings">>): KeyAction | null;
|
|
106
110
|
/**
|
|
107
111
|
* Whether a keydown is the `/` that focuses the panel's search. Shift is fine,
|
|
108
112
|
* as some layouts need it for `/`, but no other modifier, and never in a field.
|
package/dist/ui/pane.d.ts
CHANGED
|
@@ -63,8 +63,6 @@ export interface PaneView {
|
|
|
63
63
|
}
|
|
64
64
|
/** Hears the id of the view that opened, or null when the view closed. */
|
|
65
65
|
export type PaneListener = (view: string | null) => void;
|
|
66
|
-
/** How wide the panel is while a view shows, until the user drags its edge, in px. */
|
|
67
|
-
export declare const PANE_WIDTH = 340;
|
|
68
66
|
/** What the view needs from the panel. */
|
|
69
67
|
export interface PaneContext {
|
|
70
68
|
/** The panel's shadow root, which knows where the focus is in it. */
|
package/dist/ui/panel.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { type EditLog } from "../edit/log";
|
|
1
2
|
import { type SystemMedia } from "../engine/system";
|
|
2
3
|
import type { GrabControl } from "../grab/control";
|
|
3
4
|
import type { InspectControl } from "../grab/inspect";
|
|
@@ -67,4 +68,6 @@ export declare const HOST_STYLE = "position:fixed;top:0;right:auto;bottom:auto;l
|
|
|
67
68
|
*/
|
|
68
69
|
/** The panel's styles with their prefers queries settled by what a host handed over. */
|
|
69
70
|
export declare function ownCss(media: SystemMedia): string;
|
|
71
|
+
/** What reset all does to the page: every edit of inspect's view undone, the states forced taken off, then every knob to its default. */
|
|
72
|
+
export declare function resetPage(log?: EditLog, reset?: () => void): void;
|
|
70
73
|
export declare function createPanel(options?: PanelOptions): Panel;
|
package/dist/ui/prefs.d.ts
CHANGED
|
@@ -1,30 +1,46 @@
|
|
|
1
|
-
import { type Showing } from "./size";
|
|
2
1
|
/**
|
|
3
2
|
* Where the panel's preferences the user set are kept, in `localStorage`, so
|
|
4
3
|
* they hold across reloads and in new tabs of the origin. Reset all leaves them.
|
|
5
4
|
*/
|
|
6
5
|
export declare const PREFS_KEY = "devknobs:prefs";
|
|
7
6
|
/** The version of the preferences `PREFS_KEY` keeps. Bump it with a new shape, see stored.ts. */
|
|
8
|
-
export declare const PREFS_VERSION =
|
|
7
|
+
export declare const PREFS_VERSION = 6;
|
|
9
8
|
/** How the styles view shows an element: what applies to it, or every rule in cascade order. */
|
|
10
9
|
export type StylesMode = "simple" | "advanced";
|
|
11
10
|
/** The mode the styles view starts in. */
|
|
12
11
|
export declare const STYLES_MODE: StylesMode;
|
|
13
12
|
/** Whether the styles view starts with the element's box folded out. */
|
|
14
13
|
export declare const STYLES_BOX = true;
|
|
14
|
+
/** Whether the changes of the Elements view start with their diff lines shown. */
|
|
15
|
+
export declare const CHANGES_DIFF = false;
|
|
16
|
+
/** How tall the box of the html editor starts, in px. */
|
|
17
|
+
export declare const HTML_HEIGHT = 200;
|
|
18
|
+
/** The least the editor's box is dragged to, in px. The most is as the panel allows. */
|
|
19
|
+
export declare const HTML_MIN = 64;
|
|
15
20
|
/**
|
|
16
21
|
* The panel's preferences: whether the handle shows while the panel is
|
|
17
|
-
* closed, how wide the panel is
|
|
18
|
-
*
|
|
19
|
-
*
|
|
20
|
-
*
|
|
22
|
+
* closed, how wide the panel is, in px, whatever it shows, the mode of the
|
|
23
|
+
* styles view, whether the box in it is folded out, whether the changes show
|
|
24
|
+
* their diff, and how tall the html editor is, in px, or whether it takes the
|
|
25
|
+
* panel's height. Version 1 kept the handle alone, version 2 had no mode,
|
|
26
|
+
* version 3 had no word on the box, and version 4 none on the diff and the
|
|
27
|
+
* html editor. Up to version 5 the panel had a width for the rows and the
|
|
28
|
+
* settings, `listWidth`, read as the one width, and another for a view,
|
|
29
|
+
* `viewWidth`, which is dropped.
|
|
21
30
|
*/
|
|
22
31
|
export interface Prefs {
|
|
23
32
|
handle: boolean;
|
|
24
|
-
|
|
25
|
-
viewWidth: number;
|
|
33
|
+
width: number;
|
|
26
34
|
stylesMode: StylesMode;
|
|
27
35
|
stylesBox: boolean;
|
|
36
|
+
changesDiff: boolean;
|
|
37
|
+
htmlHeight: number;
|
|
38
|
+
htmlFull: boolean;
|
|
39
|
+
}
|
|
40
|
+
/** How tall the html editor is: its height in px, and whether it takes the panel's height instead. */
|
|
41
|
+
export interface HtmlSize {
|
|
42
|
+
height: number;
|
|
43
|
+
full: boolean;
|
|
28
44
|
}
|
|
29
45
|
/** The preferences the user set, over the mount options. */
|
|
30
46
|
export type StoredPrefs = Partial<Prefs>;
|
|
@@ -37,12 +53,16 @@ export interface LivePrefs {
|
|
|
37
53
|
get(): Prefs;
|
|
38
54
|
/** Show or hide the handle of a closed panel. One the same as the mount's is not kept. */
|
|
39
55
|
setHandle(on: boolean): void;
|
|
40
|
-
/** Keep the width
|
|
41
|
-
setWidth(
|
|
56
|
+
/** Keep the panel's width. The one a panel starts with is not kept. */
|
|
57
|
+
setWidth(px: number): void;
|
|
42
58
|
/** Keep the mode of the styles view. The one it starts in is not kept. */
|
|
43
59
|
setStylesMode(mode: StylesMode): void;
|
|
44
60
|
/** Keep whether the box in the styles view is folded out. The way it starts is not kept. */
|
|
45
61
|
setStylesBox(open: boolean): void;
|
|
62
|
+
/** Keep whether the changes show their diff. The way they start is not kept. */
|
|
63
|
+
setChangesDiff(open: boolean): void;
|
|
64
|
+
/** Keep the html editor's height, in px, and whether it takes the panel's height. The size it starts at is not kept. */
|
|
65
|
+
setHtmlSize(size: HtmlSize): void;
|
|
46
66
|
/** Hear the preferences change. Returns the way to stop. */
|
|
47
67
|
subscribe(listener: () => void): () => void;
|
|
48
68
|
destroy(): void;
|
package/dist/ui/settings.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { Keeper } from "../edit/keep";
|
|
1
2
|
import type { GrabControl } from "../grab/control";
|
|
2
3
|
import { type PreferValue } from "../host";
|
|
3
4
|
import { type LiveKeys } from "./bindings";
|
|
@@ -7,7 +8,7 @@ import { type Tips } from "./tooltip";
|
|
|
7
8
|
/**
|
|
8
9
|
* The settings view, which slides in over the rows: whether the handle shows
|
|
9
10
|
* while the panel is closed, the host's switch for its native driver where it
|
|
10
|
-
* gives one, which copy runs the panel where a host gives the choice, whether the tab's icon has the dev ribbon, and each binding's
|
|
11
|
+
* gives one, which copy runs the panel where a host gives the choice, whether the page keeps its Elements edits after a reload, whether the tab's icon has the dev ribbon, and each binding's
|
|
11
12
|
* key, recorded from the next
|
|
12
13
|
* keys pressed. A key a binding cannot take is refused, and the chip says why.
|
|
13
14
|
*/
|
|
@@ -48,6 +49,8 @@ export interface SettingsContext {
|
|
|
48
49
|
realPhone: boolean;
|
|
49
50
|
/** The user turned real phone mode off or on. */
|
|
50
51
|
setRealPhone(on: boolean): void;
|
|
52
|
+
/** What keeps the page's edits after a reload, null with none. It starts after the panel, so it is asked again as the settings open. */
|
|
53
|
+
keep(): Keeper | null;
|
|
51
54
|
/** The words of the host's switch for its native driver, null with none. */
|
|
52
55
|
native: {
|
|
53
56
|
label: string;
|
|
@@ -85,9 +88,27 @@ export interface Settings {
|
|
|
85
88
|
/** Take a key for the binding that records, if one does, and say whether it did. */
|
|
86
89
|
recordingKey(event: KeyboardEvent): boolean;
|
|
87
90
|
stopRecording(): void;
|
|
91
|
+
/** Show the settings in place of the rows, as the footer's control does. */
|
|
92
|
+
openKeys(): void;
|
|
88
93
|
leaveKeys(): void;
|
|
89
94
|
destroy(): void;
|
|
90
95
|
}
|
|
91
96
|
/** What real phone mode costs, under its switch. */
|
|
92
97
|
export declare const REAL_PHONE_HINT = "sends the phone's user agent to sites, so they serve their mobile site. some sites may sign you out.";
|
|
98
|
+
/** The title of the switch that keeps the page's edits after a reload. */
|
|
99
|
+
export declare const KEEP_LABEL = "keep edits after reload";
|
|
100
|
+
/** What the keep switch does, under it. */
|
|
101
|
+
export declare const KEEP_HINT = "keeps your Elements edits on this page after a reload.";
|
|
102
|
+
export interface KeepRow {
|
|
103
|
+
/** The row, hidden while there is no keeper. */
|
|
104
|
+
node: HTMLElement;
|
|
105
|
+
/** Ask for the keeper again, and show it. */
|
|
106
|
+
sync(): void;
|
|
107
|
+
destroy(): void;
|
|
108
|
+
}
|
|
109
|
+
/**
|
|
110
|
+
* The switch that keeps the page's edits after a reload, as the keeper has
|
|
111
|
+
* it, and off to a click until the keeper knows what the page keeps.
|
|
112
|
+
*/
|
|
113
|
+
export declare function keepRow(resolve: () => Keeper | null): KeepRow;
|
|
93
114
|
export declare function createSettings(context: SettingsContext): Settings;
|
package/dist/ui/size.d.ts
CHANGED
|
@@ -2,20 +2,15 @@ import type { SideValue } from "../types";
|
|
|
2
2
|
import type { LivePrefs } from "./prefs";
|
|
3
3
|
/**
|
|
4
4
|
* How wide the panel is, and the strip on its page side that changes it, as
|
|
5
|
-
* the edge of a docked devtools does. The rows
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
* without changing what is kept. Pinned, the panel is a column the page gives
|
|
5
|
+
* the edge of a docked devtools does. The rows, the settings and every
|
|
6
|
+
* feature's view share one width, kept with the preferences, and a window too
|
|
7
|
+
* narrow for it shows the panel narrower without changing what is kept. Pinned, the panel is a column the page gives
|
|
9
8
|
* its room to, and the strip leaves the page the least it is laid out at.
|
|
10
9
|
*/
|
|
11
|
-
/** What the panel shows, as far as its width goes: the rows or the settings, or a feature's view. */
|
|
12
|
-
export type Showing = "list" | "view";
|
|
13
10
|
/** How wide the panel is until the user says otherwise, in px. */
|
|
14
|
-
export declare const
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
export declare const LIST_MIN = 240;
|
|
18
|
-
export declare const VIEW_MIN = 280;
|
|
11
|
+
export declare const PANEL_WIDTH = 320;
|
|
12
|
+
/** The narrowest the strip makes the panel, in px. */
|
|
13
|
+
export declare const WIDTH_MIN = 240;
|
|
19
14
|
/** The widest the strip makes the panel, and what it leaves the page of the window's width, in px. */
|
|
20
15
|
export declare const WIDTH_MAX = 720;
|
|
21
16
|
export declare const PAGE_ROOM = 96;
|
|
@@ -37,14 +32,13 @@ export interface Limits {
|
|
|
37
32
|
* The widths the strip can set in a window `view` wide, which leave the page
|
|
38
33
|
* `page` of it. With no room to spare, only the least.
|
|
39
34
|
*/
|
|
40
|
-
export declare function widthLimits(
|
|
35
|
+
export declare function widthLimits(view: number, page?: number): Limits;
|
|
41
36
|
/**
|
|
42
37
|
* The width the panel takes for the one that is wanted, in a window `view`
|
|
43
|
-
* wide that keeps `page` of it: held between the strip's limits,
|
|
44
|
-
*
|
|
45
|
-
* down to the rows' least, which a panel always had.
|
|
38
|
+
* wide that keeps `page` of it: held between the strip's limits, so never
|
|
39
|
+
* under the least, even in a window too narrow for it.
|
|
46
40
|
*/
|
|
47
|
-
export declare function widthIn(
|
|
41
|
+
export declare function widthIn(wanted: number, view: number, page?: number): number;
|
|
48
42
|
/**
|
|
49
43
|
* The width a drag of the strip asks for, from the width it started at and
|
|
50
44
|
* how far the pointer went across: away from the edge the panel is on is wider.
|
|
@@ -74,8 +68,6 @@ export interface SizerContext {
|
|
|
74
68
|
wrap: HTMLElement;
|
|
75
69
|
panel: HTMLElement;
|
|
76
70
|
prefs: LivePrefs;
|
|
77
|
-
/** What the panel shows now. */
|
|
78
|
-
showing(): Showing;
|
|
79
71
|
/** Whether the panel is open, the side of the window it is on, and whether it is pinned there. */
|
|
80
72
|
place(): {
|
|
81
73
|
open: boolean;
|
|
@@ -91,10 +83,10 @@ export interface Sizer {
|
|
|
91
83
|
/** The strip, which goes in the panel. */
|
|
92
84
|
strip: HTMLElement;
|
|
93
85
|
/**
|
|
94
|
-
* Give the panel
|
|
95
|
-
*
|
|
96
|
-
*
|
|
97
|
-
*
|
|
86
|
+
* Give the panel its width. `draw` draws what it shows, at the width the
|
|
87
|
+
* panel ends at, so what is measured there holds once it has glided. A
|
|
88
|
+
* closed panel keeps its width until it opens, as its handle would jump
|
|
89
|
+
* with it.
|
|
98
90
|
*/
|
|
99
91
|
size(draw?: () => void): void;
|
|
100
92
|
/** The window resized: the panel takes the width that leaves, at once. */
|
package/dist/ui/stylesview.d.ts
CHANGED
|
@@ -23,12 +23,21 @@
|
|
|
23
23
|
* element or an ancestor of it, the stylesheets in the head, the window's
|
|
24
24
|
* size and the knobs, and the box alone when the element's size does. The
|
|
25
25
|
* element may be one of the device frame's page.
|
|
26
|
+
*
|
|
27
|
+
* With a log to edit into, chips over the rules force a state on the element,
|
|
28
|
+
* `:hover` say: the page draws it so and the rules show as they apply then.
|
|
29
|
+
* That is no edit, and it ends when another element is shown or the view
|
|
30
|
+
* goes. A line under the element's rules adds a new rule, listed with them
|
|
31
|
+
* whether or not it matches the element.
|
|
26
32
|
*/
|
|
33
|
+
import type { EditLog } from "../edit/log";
|
|
34
|
+
import type { Locate } from "../edit/source";
|
|
27
35
|
import { inspect, invalidate } from "../styles";
|
|
36
|
+
import { type Forcing } from "../styles/force";
|
|
28
37
|
import type { BoxRing } from "../grab/boxmodel";
|
|
29
38
|
import type { DevknobsState } from "../types";
|
|
30
39
|
import { type BoxReading } from "./boxdiagram";
|
|
31
|
-
import type { StylesMode } from "./prefs";
|
|
40
|
+
import type { HtmlSize, StylesMode } from "./prefs";
|
|
32
41
|
import type { Tips } from "./tooltip";
|
|
33
42
|
/** How long the page is left to settle after a change before its styles are read again, in ms. */
|
|
34
43
|
export declare const SETTLE = 120;
|
|
@@ -40,6 +49,8 @@ export declare const PICK = "select an element to see its styles";
|
|
|
40
49
|
export declare const GONE_PICK = "the element left the page, select another";
|
|
41
50
|
export declare const NO_RULES = "no rule reaches this element";
|
|
42
51
|
export declare const NO_MATCH = "no declaration matches";
|
|
52
|
+
/** What a stylesheet the page may not read says, as none of its rules can be edited. */
|
|
53
|
+
export declare const READ_ONLY = "read only: the browser does not let a page read or edit a stylesheet from another origin, or its own default styles";
|
|
43
54
|
/** What the view needs from the panel. */
|
|
44
55
|
export interface StylesContext {
|
|
45
56
|
tips: Tips;
|
|
@@ -64,6 +75,16 @@ export interface StylesContext {
|
|
|
64
75
|
get(): boolean;
|
|
65
76
|
set(open: boolean): void;
|
|
66
77
|
};
|
|
78
|
+
/** Whether the Elements view's changes start with their diff shown, and where the way the user leaves them is kept. */
|
|
79
|
+
diff?: {
|
|
80
|
+
get(): boolean;
|
|
81
|
+
set(open: boolean): void;
|
|
82
|
+
};
|
|
83
|
+
/** How tall the Elements view's html editor starts, and where the size the user gives it is kept. */
|
|
84
|
+
htmlSize?: {
|
|
85
|
+
get(): HtmlSize;
|
|
86
|
+
set(size: HtmlSize): void;
|
|
87
|
+
};
|
|
67
88
|
/**
|
|
68
89
|
* The picking, for the select button the bar starts with, and for the
|
|
69
90
|
* empty line, which starts it with no element shown and the picking off.
|
|
@@ -81,6 +102,10 @@ export interface StylesContext {
|
|
|
81
102
|
/** Hear the picking go on or off, however it did. Returns the way to stop. */
|
|
82
103
|
watch(listener: () => void): () => void;
|
|
83
104
|
};
|
|
105
|
+
/** The log the view's edits go to. Without it the view is read only. */
|
|
106
|
+
edits?: EditLog;
|
|
107
|
+
/** Where an edited element is written, for its edit's target. Defaults to grab's lookup. */
|
|
108
|
+
locate?: Locate;
|
|
84
109
|
}
|
|
85
110
|
/** What the view reads the page through, so a test can stand in for each. */
|
|
86
111
|
export interface StylesPage {
|
|
@@ -94,6 +119,8 @@ export interface StylesPage {
|
|
|
94
119
|
box(element: Element): BoxReading | null;
|
|
95
120
|
/** What an element, or one of its pseudo-elements, sees for a custom property now. Empty for one not set. */
|
|
96
121
|
variable(element: Element, pseudo: string | null, name: string): string;
|
|
122
|
+
/** The states forced on the page's elements. Defaults to the page's own. */
|
|
123
|
+
force?: Forcing;
|
|
97
124
|
}
|
|
98
125
|
/**
|
|
99
126
|
* A custom property as the element's computed style has it: the computed
|
|
@@ -115,4 +142,6 @@ export interface StylesView {
|
|
|
115
142
|
focus(): void;
|
|
116
143
|
destroy(): void;
|
|
117
144
|
}
|
|
145
|
+
/** What the chips that force a state are called, as a group. */
|
|
146
|
+
export declare const FORCE_LABEL = "force a state";
|
|
118
147
|
export declare function createStylesView(context: StylesContext, page?: StylesPage): StylesView;
|
package/package.json
CHANGED
package/skills/devknobs/SKILL.md
CHANGED
|
@@ -168,6 +168,100 @@ is left or the elements give nothing.
|
|
|
168
168
|
After a fix, reload the page. The knobs stay set across reloads. Call
|
|
169
169
|
`await window.devknobs.ready()` and check again.
|
|
170
170
|
|
|
171
|
+
## Apply the user's edits
|
|
172
|
+
|
|
173
|
+
The user can edit styles and the html in inspect's view (`⇧C`) and ask you
|
|
174
|
+
to put them in the code. Read them:
|
|
175
|
+
|
|
176
|
+
```js
|
|
177
|
+
window.devknobs.edits();
|
|
178
|
+
```
|
|
179
|
+
|
|
180
|
+
Each edit is plain json: `kind` (`css-value`, `css-toggle`, `css-add` or
|
|
181
|
+
`css-rule` for styles, or one of the html kinds below),
|
|
182
|
+
`target.selector` (finds the element; see `grab` for `>>>` and `>>iframe>>` steps),
|
|
183
|
+
`target.source` (the file and line where the element is written, when grab
|
|
184
|
+
finds it), `target.rule` (`selectorText`, `sheet`, `owner`, `sheetId`, `path` and `context` of the rule,
|
|
185
|
+
`context` being the `@media`, `@layer` or outer rule it sits in, outermost
|
|
186
|
+
first; left out for the element's own `style`), `property`, and `before` and `after` (the
|
|
187
|
+
value, `!important` and all; null where it is not set, so `after: null` means
|
|
188
|
+
the declaration was turned off). `edits()` lists the edits in force, each as
|
|
189
|
+
it was made: an edit undone drops out, and undo all or the panel's reset
|
|
190
|
+
empties the list. Of those,
|
|
191
|
+
for several edits of one property in one rule, take the first `before` and
|
|
192
|
+
the last `after`. Put the changes where the project writes
|
|
193
|
+
its styles (Tailwind classes, CSS modules, a stylesheet), not as inline
|
|
194
|
+
styles, unless the edit was to the element's own style.
|
|
195
|
+
|
|
196
|
+
A `css-rule` is a rule the user made in the panel: `property` is `rule`,
|
|
197
|
+
`after` is its selector, `target.rule.sheet` is `new rule`, and the `css-add`
|
|
198
|
+
edits with the same `target.rule` are its declarations. It exists only on the
|
|
199
|
+
page: add it where the element's styles are written (in Tailwind, a variant
|
|
200
|
+
such as `hover:` on the element's classes).
|
|
201
|
+
|
|
202
|
+
The html edits have `kind` `text`, `attr`, `html`, `hide`, `delete` or
|
|
203
|
+
`move`, and no `target.rule`. `property` is `text` (`text 2` and on for an element's later
|
|
204
|
+
texts), the attribute's name, `html`, `hidden` or `node`; a `delete` of an
|
|
205
|
+
element has `node`, of a text `text` (or `text 2` and on), and of a comment
|
|
206
|
+
`comment`. `before` and `after` are the text, the attribute's value or the
|
|
207
|
+
markup (null where it is not set: an attribute added or taken out, a node
|
|
208
|
+
deleted). A `hide` with `after: "hidden"` asks to hide or remove the
|
|
209
|
+
element, and one with `before: "hidden"` and `after: null` means it was
|
|
210
|
+
shown again. A `move` has `property` `node`, `before` and `after` saying in
|
|
211
|
+
words where the element stood and stands, and `from` and `to` saying it as
|
|
212
|
+
selectors read before the move: `parent` (the element it is in) and `next`
|
|
213
|
+
(the element it stands before, null at the end); move it in the markup the
|
|
214
|
+
component renders. Make each one
|
|
215
|
+
in the component or template that renders the element, never by patching the
|
|
216
|
+
DOM from a script: they were made on the live DOM, and the framework's next
|
|
217
|
+
render may undo them. The edits live on the page: a reload drops them, unless
|
|
218
|
+
the user turned on `keep edits after reload` in the panel's settings,
|
|
219
|
+
which makes them again as the page loads where it still has their targets.
|
|
220
|
+
|
|
221
|
+
To try the edits again on a fresh load, before or after they are in the code,
|
|
222
|
+
save the list and make it again:
|
|
223
|
+
|
|
224
|
+
```js
|
|
225
|
+
// Read the list into your own context (the result of the evaluate call): a reload clears the page's variables.
|
|
226
|
+
JSON.stringify(window.devknobs.edits());
|
|
227
|
+
```
|
|
228
|
+
|
|
229
|
+
It comes back as a JSON string. Reload the page, then parse it and pass it back in:
|
|
230
|
+
|
|
231
|
+
```js
|
|
232
|
+
const { applied, skipped } = await window.devknobs.setEdits(JSON.parse(JSON_YOU_KEPT));
|
|
233
|
+
window.devknobs.undoEdit(); // undoes the last edit in force, returns it or null
|
|
234
|
+
```
|
|
235
|
+
|
|
236
|
+
`setEdits` makes each edit only where its element is found by its selector
|
|
237
|
+
and the page still has its `before` value, through the same log as the
|
|
238
|
+
panel's, so the user sees them and can undo them. `skipped` lists each one not
|
|
239
|
+
made as `{ edit, reason }`, and after a delete, move or html edit that was not
|
|
240
|
+
made, every later one is skipped too. A `css-rule` is always made anew, even
|
|
241
|
+
once the rule is in the code, so read its declarations instead. A value edit
|
|
242
|
+
already in the code is skipped with `the page has another value now`, and a
|
|
243
|
+
node deleted in the code with `not found on the page`, but those reasons have
|
|
244
|
+
other causes too: they say the edit may already be in the code, so check the
|
|
245
|
+
page itself before you count it done. An html or attribute edit that could run a script is never made.
|
|
246
|
+
With `keep edits after reload` on, html and attribute edits kept from before
|
|
247
|
+
wait for the user's click on `apply` in the panel.
|
|
248
|
+
|
|
249
|
+
## Check a hover or focus state
|
|
250
|
+
|
|
251
|
+
To see or screenshot a state the pointer or the keyboard would give, force it:
|
|
252
|
+
|
|
253
|
+
```js
|
|
254
|
+
window.devknobs.forceState(".cta", ["hover"]); // or "focus", "focus-visible", "active", "focus-within"
|
|
255
|
+
// screenshot, then:
|
|
256
|
+
window.devknobs.forceState(null);
|
|
257
|
+
```
|
|
258
|
+
|
|
259
|
+
It takes an element or a selector, returns the states forced, and is no edit.
|
|
260
|
+
`reset()` does not clear it: call `forceState(null)` before you go on to the
|
|
261
|
+
next condition and before `reset()` when you finish.
|
|
262
|
+
It is emulated: a stylesheet from another origin is not seen, and a page rule
|
|
263
|
+
with `:not(:hover)` still draws.
|
|
264
|
+
|
|
171
265
|
## Loop over conditions
|
|
172
266
|
|
|
173
267
|
```js
|
|
@@ -202,6 +296,7 @@ changes data values, such as numbers and names. That is not a bug.
|
|
|
202
296
|
Put the knobs back, and the panel as you noted it at the start:
|
|
203
297
|
|
|
204
298
|
```js
|
|
299
|
+
window.devknobs.forceState(null); // a state you forced; reset() leaves it
|
|
205
300
|
window.devknobs.reset();
|
|
206
301
|
window.devknobs.setState({ panel: NOTED_PANEL }); // the panel json you noted
|
|
207
302
|
await window.devknobs.ready();
|