@vinena/knobs 0.6.0 → 0.6.2
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 +9 -0
- package/dist/edit/keep.d.ts +1 -1
- package/dist/{elementsview-fyc06wjt.js → elementsview-ffh56hbj.js} +77 -17
- package/dist/{elementsview-k6zvvcne.js → elementsview-nhm5k473.js} +77 -17
- package/dist/engine/fit.d.ts +16 -1
- package/dist/engine/mockdraw.d.ts +3 -1
- package/dist/{framekit-yx612r28.js → framekit-3bmkm34m.js} +88 -11
- package/dist/{framekit-622h6w1f.js → framekit-h0jrc5gs.js} +88 -11
- package/dist/{index-f60yax1j.js → index-1by1n6p4.js} +3 -3
- package/dist/{index-f67wctn3.js → index-44a62hfx.js} +2 -2
- package/dist/{index-x59vz1xx.js → index-ggf32ddy.js} +1 -1
- package/dist/{index-aynkv7qk.js → index-v67kqq9p.js} +2 -2
- package/dist/{index-kfdzsyyw.js → index-xeg2j4r8.js} +2 -2
- package/dist/index.global.js +172 -139
- package/dist/index.js +98 -12
- package/dist/{react-v8497a41.js → react-c98apxzz.js} +3 -3
- package/dist/{react-cs62p9qh.js → react-myz2rvvn.js} +1 -1
- package/dist/{react-6t4dbdzn.js → react-vtcq394z.js} +2 -2
- package/dist/react.js +98 -12
- package/dist/{storageview-pzn8yaad.js → storageview-cth4ysxw.js} +2 -2
- package/dist/{storageview-6xj7zb63.js → storageview-rs5drb7m.js} +2 -2
- package/dist/ui/elementsview.d.ts +3 -5
- package/dist/ui/settings.d.ts +20 -1
- package/package.json +1 -1
- package/skills/devknobs/SKILL.md +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,14 @@
|
|
|
1
1
|
# changelog
|
|
2
2
|
|
|
3
|
+
## 0.6.2
|
|
4
|
+
|
|
5
|
+
- no 1px light line at the top or bottom edge of a phone screen in the device frame, at any pixel ratio: the screen is drawn a whole number of device pixels tall and starts on a whole device pixel, and it is redrawn when the pixel ratio changes. devices without a body, and set zooms like 100%, look as before
|
|
6
|
+
|
|
7
|
+
## 0.6.1
|
|
8
|
+
|
|
9
|
+
- the `keep edits after reload` switch is in the settings now, with a short hint under it, and no longer at the top of the Elements view. as before, it is not there in fresh mode or in the copy of devknobs inside its own frame, which keeps nothing itself; the page's keeper still keeps edits made in the frame
|
|
10
|
+
- the line between the DOM tree and the styles is a full-width drag handle, also moved with ↑ ↓
|
|
11
|
+
|
|
3
12
|
## 0.6.0
|
|
4
13
|
|
|
5
14
|
- every edit field in inspect, the DOM tree's texts and attributes, the html editor and the styles' values, wraps its lines and grows down, so a long value or address never scrolls sideways, at any panel width and in the width knob's frame
|
package/dist/edit/keep.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Edits kept after a reload. With the
|
|
2
|
+
* Edits kept after a reload. With the settings' keep switch on, the edits
|
|
3
3
|
* in force are kept for the page, its address without the query, as plain
|
|
4
4
|
* json: each one's kind, target, property and values, no node of the page.
|
|
5
5
|
* As the page loads again and settles, the kept edits are made again in
|
|
@@ -92,14 +92,13 @@ import {
|
|
|
92
92
|
filterField,
|
|
93
93
|
sectionFold,
|
|
94
94
|
segments,
|
|
95
|
-
switchLine,
|
|
96
95
|
toolToggle,
|
|
97
96
|
toolbar
|
|
98
97
|
} from "./react-bxzn8vq5.js";
|
|
99
98
|
import {
|
|
100
99
|
getState,
|
|
101
100
|
subscribe
|
|
102
|
-
} from "./react-
|
|
101
|
+
} from "./react-myz2rvvn.js";
|
|
103
102
|
import {
|
|
104
103
|
isMac
|
|
105
104
|
} from "./react-ttj8f9qp.js";
|
|
@@ -3563,7 +3562,7 @@ function createStylesView(context, page = PAGE) {
|
|
|
3563
3562
|
|
|
3564
3563
|
// src/ui/elementsview.ts
|
|
3565
3564
|
var DOLLAR = "$0";
|
|
3566
|
-
var
|
|
3565
|
+
var TREE_MIN = 96;
|
|
3567
3566
|
function undoKey(event) {
|
|
3568
3567
|
if (!letterMatches(event, "z") || event.metaKey || event.ctrlKey || event.altKey)
|
|
3569
3568
|
return null;
|
|
@@ -3642,19 +3641,76 @@ function createElementsView(context, parts = {}) {
|
|
|
3642
3641
|
}, parts.page);
|
|
3643
3642
|
const keep = parts.keep === undefined ? keeper() : parts.keep;
|
|
3644
3643
|
const changes = createChanges(log, copy, undefined, keep, context.diff ?? null);
|
|
3645
|
-
const
|
|
3646
|
-
|
|
3647
|
-
|
|
3648
|
-
|
|
3644
|
+
const split = el("div", "dom-split");
|
|
3645
|
+
split.setAttribute("role", "separator");
|
|
3646
|
+
split.setAttribute("aria-orientation", "horizontal");
|
|
3647
|
+
split.setAttribute("aria-label", "drag to resize the DOM tree");
|
|
3648
|
+
split.setAttribute("aria-valuemin", String(TREE_MIN));
|
|
3649
|
+
split.tabIndex = 0;
|
|
3650
|
+
node.append(tree.node, split, styles.node, changes.node);
|
|
3651
|
+
function tallest() {
|
|
3652
|
+
const view = tree.node.ownerDocument?.defaultView ?? window;
|
|
3653
|
+
return Math.max(TREE_MIN, Math.round(view.innerHeight * 0.85));
|
|
3654
|
+
}
|
|
3655
|
+
function tell(most, now) {
|
|
3656
|
+
split.setAttribute("aria-valuemax", String(most));
|
|
3657
|
+
split.setAttribute("aria-valuenow", String(now));
|
|
3658
|
+
}
|
|
3659
|
+
function measure() {
|
|
3660
|
+
tell(tallest(), Math.round(tree.node.offsetHeight));
|
|
3661
|
+
}
|
|
3662
|
+
function size(height) {
|
|
3663
|
+
const most = tallest();
|
|
3664
|
+
const next = Math.round(Math.min(most, Math.max(TREE_MIN, height)));
|
|
3665
|
+
tree.node.style.height = `${next}px`;
|
|
3666
|
+
tell(most, next);
|
|
3667
|
+
}
|
|
3668
|
+
const frameView = tree.node.ownerDocument?.defaultView ?? window;
|
|
3669
|
+
const firstFrame = frameView.requestAnimationFrame?.(measure);
|
|
3670
|
+
let stopDrag = null;
|
|
3671
|
+
function onSplitDown(event) {
|
|
3672
|
+
if (event.button !== 0)
|
|
3649
3673
|
return;
|
|
3650
|
-
|
|
3651
|
-
|
|
3652
|
-
|
|
3653
|
-
|
|
3654
|
-
|
|
3655
|
-
|
|
3656
|
-
|
|
3657
|
-
|
|
3674
|
+
stopDrag?.();
|
|
3675
|
+
event.preventDefault();
|
|
3676
|
+
const id = event.pointerId;
|
|
3677
|
+
const from = event.clientY;
|
|
3678
|
+
const was = tree.node.offsetHeight;
|
|
3679
|
+
split.setPointerCapture?.(id);
|
|
3680
|
+
split.setAttribute("data-drag", "true");
|
|
3681
|
+
const move = (next) => {
|
|
3682
|
+
if (next.pointerId === id)
|
|
3683
|
+
size(was + next.clientY - from);
|
|
3684
|
+
};
|
|
3685
|
+
const end = (next) => {
|
|
3686
|
+
if (next.pointerId === id)
|
|
3687
|
+
up();
|
|
3688
|
+
};
|
|
3689
|
+
const up = () => {
|
|
3690
|
+
split.removeEventListener("pointermove", move);
|
|
3691
|
+
split.removeEventListener("pointerup", end);
|
|
3692
|
+
split.removeEventListener("pointercancel", end);
|
|
3693
|
+
split.removeEventListener("lostpointercapture", end);
|
|
3694
|
+
split.removeAttribute("data-drag");
|
|
3695
|
+
stopDrag = null;
|
|
3696
|
+
};
|
|
3697
|
+
stopDrag = up;
|
|
3698
|
+
split.addEventListener("pointermove", move);
|
|
3699
|
+
split.addEventListener("pointerup", end);
|
|
3700
|
+
split.addEventListener("pointercancel", end);
|
|
3701
|
+
split.addEventListener("lostpointercapture", end);
|
|
3702
|
+
}
|
|
3703
|
+
function onSplitKey(event) {
|
|
3704
|
+
if (event.key !== "ArrowUp" && event.key !== "ArrowDown")
|
|
3705
|
+
return;
|
|
3706
|
+
event.preventDefault();
|
|
3707
|
+
event.stopPropagation();
|
|
3708
|
+
const step = event.shiftKey ? 64 : 16;
|
|
3709
|
+
size(tree.node.offsetHeight + (event.key === "ArrowDown" ? step : -step));
|
|
3710
|
+
}
|
|
3711
|
+
split.addEventListener("pointerdown", onSplitDown);
|
|
3712
|
+
split.addEventListener("keydown", onSplitKey);
|
|
3713
|
+
split.addEventListener("focus", measure);
|
|
3658
3714
|
function onKeydown(event) {
|
|
3659
3715
|
const key = undoKey(event);
|
|
3660
3716
|
if (!key)
|
|
@@ -3684,8 +3740,13 @@ function createElementsView(context, parts = {}) {
|
|
|
3684
3740
|
focus: () => styles.focus(),
|
|
3685
3741
|
destroy() {
|
|
3686
3742
|
node.removeEventListener("keydown", onKeydown);
|
|
3743
|
+
stopDrag?.();
|
|
3744
|
+
split.removeEventListener("pointerdown", onSplitDown);
|
|
3745
|
+
split.removeEventListener("keydown", onSplitKey);
|
|
3746
|
+
split.removeEventListener("focus", measure);
|
|
3747
|
+
if (firstFrame !== undefined)
|
|
3748
|
+
frameView.cancelAnimationFrame?.(firstFrame);
|
|
3687
3749
|
stopFollow();
|
|
3688
|
-
stopKeep?.();
|
|
3689
3750
|
tree.destroy();
|
|
3690
3751
|
styles.destroy();
|
|
3691
3752
|
changes.destroy();
|
|
@@ -3697,6 +3758,5 @@ export {
|
|
|
3697
3758
|
undoKey,
|
|
3698
3759
|
createElementsView,
|
|
3699
3760
|
createDollar,
|
|
3700
|
-
KEEP_LABEL,
|
|
3701
3761
|
DOLLAR
|
|
3702
3762
|
};
|
|
@@ -91,14 +91,13 @@ import {
|
|
|
91
91
|
filterField,
|
|
92
92
|
sectionFold,
|
|
93
93
|
segments,
|
|
94
|
-
switchLine,
|
|
95
94
|
toolToggle,
|
|
96
95
|
toolbar
|
|
97
96
|
} from "./index-4a4x1bt2.js";
|
|
98
97
|
import {
|
|
99
98
|
getState,
|
|
100
99
|
subscribe
|
|
101
|
-
} from "./index-
|
|
100
|
+
} from "./index-ggf32ddy.js";
|
|
102
101
|
import {
|
|
103
102
|
isMac
|
|
104
103
|
} from "./index-7cb4x1vj.js";
|
|
@@ -3562,7 +3561,7 @@ function createStylesView(context, page = PAGE) {
|
|
|
3562
3561
|
|
|
3563
3562
|
// src/ui/elementsview.ts
|
|
3564
3563
|
var DOLLAR = "$0";
|
|
3565
|
-
var
|
|
3564
|
+
var TREE_MIN = 96;
|
|
3566
3565
|
function undoKey(event) {
|
|
3567
3566
|
if (!letterMatches(event, "z") || event.metaKey || event.ctrlKey || event.altKey)
|
|
3568
3567
|
return null;
|
|
@@ -3641,19 +3640,76 @@ function createElementsView(context, parts = {}) {
|
|
|
3641
3640
|
}, parts.page);
|
|
3642
3641
|
const keep = parts.keep === undefined ? keeper() : parts.keep;
|
|
3643
3642
|
const changes = createChanges(log, copy, undefined, keep, context.diff ?? null);
|
|
3644
|
-
const
|
|
3645
|
-
|
|
3646
|
-
|
|
3647
|
-
|
|
3643
|
+
const split = el("div", "dom-split");
|
|
3644
|
+
split.setAttribute("role", "separator");
|
|
3645
|
+
split.setAttribute("aria-orientation", "horizontal");
|
|
3646
|
+
split.setAttribute("aria-label", "drag to resize the DOM tree");
|
|
3647
|
+
split.setAttribute("aria-valuemin", String(TREE_MIN));
|
|
3648
|
+
split.tabIndex = 0;
|
|
3649
|
+
node.append(tree.node, split, styles.node, changes.node);
|
|
3650
|
+
function tallest() {
|
|
3651
|
+
const view = tree.node.ownerDocument?.defaultView ?? window;
|
|
3652
|
+
return Math.max(TREE_MIN, Math.round(view.innerHeight * 0.85));
|
|
3653
|
+
}
|
|
3654
|
+
function tell(most, now) {
|
|
3655
|
+
split.setAttribute("aria-valuemax", String(most));
|
|
3656
|
+
split.setAttribute("aria-valuenow", String(now));
|
|
3657
|
+
}
|
|
3658
|
+
function measure() {
|
|
3659
|
+
tell(tallest(), Math.round(tree.node.offsetHeight));
|
|
3660
|
+
}
|
|
3661
|
+
function size(height) {
|
|
3662
|
+
const most = tallest();
|
|
3663
|
+
const next = Math.round(Math.min(most, Math.max(TREE_MIN, height)));
|
|
3664
|
+
tree.node.style.height = `${next}px`;
|
|
3665
|
+
tell(most, next);
|
|
3666
|
+
}
|
|
3667
|
+
const frameView = tree.node.ownerDocument?.defaultView ?? window;
|
|
3668
|
+
const firstFrame = frameView.requestAnimationFrame?.(measure);
|
|
3669
|
+
let stopDrag = null;
|
|
3670
|
+
function onSplitDown(event) {
|
|
3671
|
+
if (event.button !== 0)
|
|
3648
3672
|
return;
|
|
3649
|
-
|
|
3650
|
-
|
|
3651
|
-
|
|
3652
|
-
|
|
3653
|
-
|
|
3654
|
-
|
|
3655
|
-
|
|
3656
|
-
|
|
3673
|
+
stopDrag?.();
|
|
3674
|
+
event.preventDefault();
|
|
3675
|
+
const id = event.pointerId;
|
|
3676
|
+
const from = event.clientY;
|
|
3677
|
+
const was = tree.node.offsetHeight;
|
|
3678
|
+
split.setPointerCapture?.(id);
|
|
3679
|
+
split.setAttribute("data-drag", "true");
|
|
3680
|
+
const move = (next) => {
|
|
3681
|
+
if (next.pointerId === id)
|
|
3682
|
+
size(was + next.clientY - from);
|
|
3683
|
+
};
|
|
3684
|
+
const end = (next) => {
|
|
3685
|
+
if (next.pointerId === id)
|
|
3686
|
+
up();
|
|
3687
|
+
};
|
|
3688
|
+
const up = () => {
|
|
3689
|
+
split.removeEventListener("pointermove", move);
|
|
3690
|
+
split.removeEventListener("pointerup", end);
|
|
3691
|
+
split.removeEventListener("pointercancel", end);
|
|
3692
|
+
split.removeEventListener("lostpointercapture", end);
|
|
3693
|
+
split.removeAttribute("data-drag");
|
|
3694
|
+
stopDrag = null;
|
|
3695
|
+
};
|
|
3696
|
+
stopDrag = up;
|
|
3697
|
+
split.addEventListener("pointermove", move);
|
|
3698
|
+
split.addEventListener("pointerup", end);
|
|
3699
|
+
split.addEventListener("pointercancel", end);
|
|
3700
|
+
split.addEventListener("lostpointercapture", end);
|
|
3701
|
+
}
|
|
3702
|
+
function onSplitKey(event) {
|
|
3703
|
+
if (event.key !== "ArrowUp" && event.key !== "ArrowDown")
|
|
3704
|
+
return;
|
|
3705
|
+
event.preventDefault();
|
|
3706
|
+
event.stopPropagation();
|
|
3707
|
+
const step = event.shiftKey ? 64 : 16;
|
|
3708
|
+
size(tree.node.offsetHeight + (event.key === "ArrowDown" ? step : -step));
|
|
3709
|
+
}
|
|
3710
|
+
split.addEventListener("pointerdown", onSplitDown);
|
|
3711
|
+
split.addEventListener("keydown", onSplitKey);
|
|
3712
|
+
split.addEventListener("focus", measure);
|
|
3657
3713
|
function onKeydown(event) {
|
|
3658
3714
|
const key = undoKey(event);
|
|
3659
3715
|
if (!key)
|
|
@@ -3683,8 +3739,13 @@ function createElementsView(context, parts = {}) {
|
|
|
3683
3739
|
focus: () => styles.focus(),
|
|
3684
3740
|
destroy() {
|
|
3685
3741
|
node.removeEventListener("keydown", onKeydown);
|
|
3742
|
+
stopDrag?.();
|
|
3743
|
+
split.removeEventListener("pointerdown", onSplitDown);
|
|
3744
|
+
split.removeEventListener("keydown", onSplitKey);
|
|
3745
|
+
split.removeEventListener("focus", measure);
|
|
3746
|
+
if (firstFrame !== undefined)
|
|
3747
|
+
frameView.cancelAnimationFrame?.(firstFrame);
|
|
3686
3748
|
stopFollow();
|
|
3687
|
-
stopKeep?.();
|
|
3688
3749
|
tree.destroy();
|
|
3689
3750
|
styles.destroy();
|
|
3690
3751
|
changes.destroy();
|
|
@@ -3696,6 +3757,5 @@ export {
|
|
|
3696
3757
|
undoKey,
|
|
3697
3758
|
createElementsView,
|
|
3698
3759
|
createDollar,
|
|
3699
|
-
KEEP_LABEL,
|
|
3700
3760
|
DOLLAR
|
|
3701
3761
|
};
|
package/dist/engine/fit.d.ts
CHANGED
|
@@ -43,7 +43,8 @@ export declare function hasStrip(knobs: Pick<DevknobsState, "width" | "height" |
|
|
|
43
43
|
* device pixel ratio's `zoom` on the frame keeps its css size too, and the
|
|
44
44
|
* wrapper takes it back out of the drawing. A device's mock takes `mock` px
|
|
45
45
|
* of the frame's on each side, drawn at the same scale, and the whole of it
|
|
46
|
-
* is fitted and centered.
|
|
46
|
+
* is fitted and centered. With a mock, a fit is drawn a hair smaller so the
|
|
47
|
+
* screen is a whole number of the `ratio`'s device pixels tall.
|
|
47
48
|
*/
|
|
48
49
|
export declare function fit(knobs: Pick<DevknobsState, "width" | "height" | "zoom">, size: {
|
|
49
50
|
width: number;
|
|
@@ -53,6 +54,7 @@ export declare function fit(knobs: Pick<DevknobsState, "width" | "height" | "zoo
|
|
|
53
54
|
aside?: number;
|
|
54
55
|
side?: SideValue;
|
|
55
56
|
mock?: Sides;
|
|
57
|
+
ratio?: number;
|
|
56
58
|
}): Fit;
|
|
57
59
|
/**
|
|
58
60
|
* Where the frame's top left sits in the scrolled content of a stage of
|
|
@@ -74,3 +76,16 @@ export declare function label(place: Fit, knobs: Pick<DevknobsState, "dpr" | "he
|
|
|
74
76
|
width: number;
|
|
75
77
|
height: number;
|
|
76
78
|
}): string;
|
|
79
|
+
/**
|
|
80
|
+
* `scale`, made at most a device pixel smaller so `length` css px drawn at it
|
|
81
|
+
* spans a whole number of device pixels at `ratio` device px per css px. A
|
|
82
|
+
* scale of 1 stays, so a frame drawn at its own size stays sharp.
|
|
83
|
+
*/
|
|
84
|
+
export declare function snapScale(scale: number, length: number, ratio: number): number;
|
|
85
|
+
/**
|
|
86
|
+
* How far to move an edge at `at` css px, under half a device pixel, so it
|
|
87
|
+
* lands on a whole device pixel at `ratio`. A rounded screen's clip on an
|
|
88
|
+
* edge between device pixels draws that row part way, blended with what is
|
|
89
|
+
* behind it.
|
|
90
|
+
*/
|
|
91
|
+
export declare function snapShift(at: number, ratio: number): number;
|
|
@@ -6,8 +6,10 @@ import type { Mock, Radius } from "./mock";
|
|
|
6
6
|
* mat would show through as a light line. The rim of the body there is black.
|
|
7
7
|
*/
|
|
8
8
|
export declare const UNDER = 2;
|
|
9
|
+
/** How many device pixels of the screen's edge go black with the body's rim. */
|
|
10
|
+
export declare const RING = 2;
|
|
9
11
|
/** A device's body over the frame, drawn by `drawMock`, in the letterbox's shadow root. */
|
|
10
|
-
export declare const MOCK_CSS = "\n/* Clips the frame to the screen's corners in a mock, in the body's color so\n no blue shows at the seam. */\n.glass.mocked {\n position: absolute;\n overflow: hidden;\n background: #111112;\n}\n/* Over the frame, and never in the way of a pointer. */\n.mock {\n position: absolute;\n top: 0;\n left: 0;\n overflow: visible;\n pointer-events: none;\n}\n.mock .band { fill: #48484a; fill-rule: evenodd; }\n.mock .body { fill: #111112; fill-rule: evenodd; }\n.mock .button { fill: #48484a; }\n.mock .sensor { fill: #000; }\n.mock .slot { fill: #2a2a2c; }\n.mock .lens { fill: #000; stroke: #2a2a2c; stroke-width: 1; }\n.mock .home { fill: #2a2a2c; }\n.mock .key { fill: #111112; }";
|
|
12
|
+
export declare const MOCK_CSS = "\n/* Clips the frame to the screen's corners in a mock, in the body's color so\n no blue shows at the seam. */\n.glass.mocked {\n position: absolute;\n overflow: hidden;\n background: #111112;\n}\n/* Black over the screen's edge, under the body, never in the way of a pointer. */\n.ring {\n position: absolute;\n box-sizing: border-box;\n pointer-events: none;\n}\n/* Over the frame, and never in the way of a pointer. */\n.mock {\n position: absolute;\n top: 0;\n left: 0;\n overflow: visible;\n pointer-events: none;\n}\n.mock .band { fill: #48484a; fill-rule: evenodd; }\n.mock .body { fill: #111112; fill-rule: evenodd; }\n.mock .button { fill: #48484a; }\n.mock .sensor { fill: #000; }\n.mock .slot { fill: #2a2a2c; }\n.mock .lens { fill: #000; stroke: #2a2a2c; stroke-width: 1; }\n.mock .home { fill: #2a2a2c; }\n.mock .key { fill: #111112; }";
|
|
11
13
|
/** The radius of each corner, from the top left round by the right, `by` added to each. */
|
|
12
14
|
export declare function corners(radius: Radius, by?: number): [number, number, number, number];
|
|
13
15
|
/**
|
|
@@ -5765,7 +5765,7 @@ function margin(size) {
|
|
|
5765
5765
|
return Math.min(MARGIN, size / 4);
|
|
5766
5766
|
}
|
|
5767
5767
|
function fit(knobs2, size, options = {}) {
|
|
5768
|
-
const { frameZoom = 1, aside = 0, side = "right", mock = BARE } = options;
|
|
5768
|
+
const { frameZoom = 1, aside = 0, side = "right", mock = BARE, ratio = 0 } = options;
|
|
5769
5769
|
const room = {
|
|
5770
5770
|
width: size.width,
|
|
5771
5771
|
height: Math.max(0, size.height - (hasStrip(knobs2) ? STRIP : 0))
|
|
@@ -5782,7 +5782,8 @@ function fit(knobs2, size, options = {}) {
|
|
|
5782
5782
|
const height = typeof knobs2.height === "number" ? knobs2.height : room.height / whole;
|
|
5783
5783
|
const outer = { width: width + sides.width, height: height + sides.height };
|
|
5784
5784
|
const covered = sized && aside > 0 && aside <= room.width / 2 && (room.width + outer.width * whole) / 2 + x > room.width - aside;
|
|
5785
|
-
const
|
|
5785
|
+
const loose = covered ? Math.min(whole, (room.width - aside - 2 * x) / outer.width) : whole;
|
|
5786
|
+
const fitted = mock === BARE ? loose : snapScale(loose, height, ratio);
|
|
5786
5787
|
const scale = knobs2.zoom === "fit" ? fitted : knobs2.zoom;
|
|
5787
5788
|
const beside = knobs2.zoom === "fit" && covered ? aside : 0;
|
|
5788
5789
|
const before = side === "left" ? beside : 0;
|
|
@@ -5813,6 +5814,17 @@ function label(place2, knobs2, page = place2) {
|
|
|
5813
5814
|
text += ` · ${knobs2.dpr}x`;
|
|
5814
5815
|
return text;
|
|
5815
5816
|
}
|
|
5817
|
+
function snapScale(scale, length, ratio) {
|
|
5818
|
+
if (!(ratio > 0) || !(scale > 0) || !(length > 0) || scale === 1)
|
|
5819
|
+
return scale;
|
|
5820
|
+
const pixels = Math.floor(length * scale * ratio + 0.000001);
|
|
5821
|
+
return pixels > 0 ? pixels / ratio / length : scale;
|
|
5822
|
+
}
|
|
5823
|
+
function snapShift(at, ratio) {
|
|
5824
|
+
if (!(ratio > 0))
|
|
5825
|
+
return 0;
|
|
5826
|
+
return Math.round(at * ratio) / ratio - at;
|
|
5827
|
+
}
|
|
5816
5828
|
|
|
5817
5829
|
// src/engine/mat.ts
|
|
5818
5830
|
function colorRules() {
|
|
@@ -6435,6 +6447,7 @@ var EDGE = "#48484a";
|
|
|
6435
6447
|
var RIM2 = "#2a2a2c";
|
|
6436
6448
|
var BAND = 2.5;
|
|
6437
6449
|
var UNDER = 2;
|
|
6450
|
+
var RING = 2;
|
|
6438
6451
|
var MOCK_CSS = `
|
|
6439
6452
|
/* Clips the frame to the screen's corners in a mock, in the body's color so
|
|
6440
6453
|
no blue shows at the seam. */
|
|
@@ -6443,6 +6456,12 @@ var MOCK_CSS = `
|
|
|
6443
6456
|
overflow: hidden;
|
|
6444
6457
|
background: ${BODY};
|
|
6445
6458
|
}
|
|
6459
|
+
/* Black over the screen's edge, under the body, never in the way of a pointer. */
|
|
6460
|
+
.ring {
|
|
6461
|
+
position: absolute;
|
|
6462
|
+
box-sizing: border-box;
|
|
6463
|
+
pointer-events: none;
|
|
6464
|
+
}
|
|
6446
6465
|
/* Over the frame, and never in the way of a pointer. */
|
|
6447
6466
|
.mock {
|
|
6448
6467
|
position: absolute;
|
|
@@ -8649,6 +8668,9 @@ var browser = null;
|
|
|
8649
8668
|
var touchDot = null;
|
|
8650
8669
|
var turnCover = null;
|
|
8651
8670
|
var mockDrawing = null;
|
|
8671
|
+
var ring2 = null;
|
|
8672
|
+
var density2 = null;
|
|
8673
|
+
var densityRatio = 0;
|
|
8652
8674
|
var mockKey = "";
|
|
8653
8675
|
var frame3 = null;
|
|
8654
8676
|
var readout = null;
|
|
@@ -9026,19 +9048,46 @@ function showMock(mock, place2) {
|
|
|
9026
9048
|
if (mockDrawing)
|
|
9027
9049
|
screen.append(mockDrawing);
|
|
9028
9050
|
glass.className = mock ? "glass mocked" : "glass";
|
|
9051
|
+
ring2?.remove();
|
|
9052
|
+
ring2 = mock ? document.createElement("div") : null;
|
|
9053
|
+
if (ring2) {
|
|
9054
|
+
ring2.className = "ring";
|
|
9055
|
+
glass.after(ring2);
|
|
9056
|
+
}
|
|
9029
9057
|
}
|
|
9030
9058
|
const zoom = place2.zoom;
|
|
9031
9059
|
glass.style.left = mock ? `${mock.inset.left * zoom}px` : "";
|
|
9032
9060
|
glass.style.top = mock ? `${mock.inset.top * zoom}px` : "";
|
|
9033
9061
|
const round4 = mock ? corners(mock.screenRadius).map((radius) => `${radius * zoom}px`) : [];
|
|
9034
9062
|
glass.style.borderRadius = round4.join(" ");
|
|
9035
|
-
|
|
9063
|
+
if (mock && ring2)
|
|
9064
|
+
showRing(mock, place2);
|
|
9036
9065
|
if (mock && mockDrawing) {
|
|
9037
9066
|
mockDrawing.style.width = `${mock.width * zoom}px`;
|
|
9038
9067
|
mockDrawing.style.height = `${mock.height * zoom}px`;
|
|
9039
9068
|
}
|
|
9040
9069
|
}
|
|
9041
|
-
function
|
|
9070
|
+
function showRing(mock, place2) {
|
|
9071
|
+
if (!ring2)
|
|
9072
|
+
return;
|
|
9073
|
+
const zoom = place2.zoom;
|
|
9074
|
+
const ratio = window.devicePixelRatio || 1;
|
|
9075
|
+
const width = UNDER * zoom + RING / (ratio * place2.transform);
|
|
9076
|
+
ring2.style.left = `${(mock.inset.left - UNDER) * zoom}px`;
|
|
9077
|
+
ring2.style.top = `${(mock.inset.top - UNDER) * zoom}px`;
|
|
9078
|
+
ring2.style.width = `${(place2.width + 2 * UNDER) * zoom}px`;
|
|
9079
|
+
ring2.style.height = `${(place2.height + 2 * UNDER) * zoom}px`;
|
|
9080
|
+
ring2.style.borderRadius = corners(mock.screenRadius, UNDER).map((radius) => `${radius * zoom}px`).join(" ");
|
|
9081
|
+
ring2.style.boxShadow = `inset 0 0 0 ${width}px #000`;
|
|
9082
|
+
}
|
|
9083
|
+
function pageInset(page, place2) {
|
|
9084
|
+
if (!page)
|
|
9085
|
+
return "0";
|
|
9086
|
+
const zoom = place2.zoom;
|
|
9087
|
+
const sides = [page.y, place2.width - page.x - page.width, place2.height - page.y - page.height, page.x];
|
|
9088
|
+
return sides.map((side) => `${-side * zoom}px`).join(" ");
|
|
9089
|
+
}
|
|
9090
|
+
function showBrowser(bars, page, place2, follow5, radii) {
|
|
9042
9091
|
if (!glass || !pageBox || !browser)
|
|
9043
9092
|
return;
|
|
9044
9093
|
const zoom = place2.zoom;
|
|
@@ -9051,6 +9100,7 @@ function showBrowser(bars, page, place2, follow5) {
|
|
|
9051
9100
|
box2.className = page ? "page placed" : "page";
|
|
9052
9101
|
box2.style.left = page ? `${page.x * zoom}px` : "";
|
|
9053
9102
|
box2.style.top = page ? `${page.y * zoom}px` : "";
|
|
9103
|
+
box2.style.clipPath = radii ? `inset(${pageInset(page, place2)} round ${radii})` : "";
|
|
9054
9104
|
};
|
|
9055
9105
|
glass.style.width = page ? `${place2.width * zoom}px` : "";
|
|
9056
9106
|
glass.style.height = page ? `${place2.height * zoom}px` : "";
|
|
@@ -9078,6 +9128,21 @@ function bodyFor(value) {
|
|
|
9078
9128
|
return body && over2 && openUpright(shapeOf(value)) ? flipMock(body) : body;
|
|
9079
9129
|
}
|
|
9080
9130
|
var over2 = false;
|
|
9131
|
+
function watchDensity() {
|
|
9132
|
+
const ratio = window.devicePixelRatio;
|
|
9133
|
+
if (ratio === densityRatio || typeof window.matchMedia !== "function")
|
|
9134
|
+
return;
|
|
9135
|
+
unwatchDensity();
|
|
9136
|
+
density2 = baseMatchMedia(`(resolution: ${ratio}dppx)`);
|
|
9137
|
+
density2.onchange = resize;
|
|
9138
|
+
densityRatio = ratio;
|
|
9139
|
+
}
|
|
9140
|
+
function unwatchDensity() {
|
|
9141
|
+
if (density2)
|
|
9142
|
+
density2.onchange = null;
|
|
9143
|
+
density2 = null;
|
|
9144
|
+
densityRatio = 0;
|
|
9145
|
+
}
|
|
9081
9146
|
function resize() {
|
|
9082
9147
|
if (!frame3 || !letterbox || !stage || !drawing || !screen || !readout || !caption)
|
|
9083
9148
|
return;
|
|
@@ -9093,7 +9158,8 @@ function resize() {
|
|
|
9093
9158
|
frameZoom: zoomFor(current.dpr),
|
|
9094
9159
|
aside,
|
|
9095
9160
|
side: current.panel.side,
|
|
9096
|
-
mock: mock?.inset
|
|
9161
|
+
mock: mock?.inset,
|
|
9162
|
+
ratio: window.devicePixelRatio
|
|
9097
9163
|
});
|
|
9098
9164
|
drawn = place2;
|
|
9099
9165
|
drawnAt(placeKey(origin(place2, size), place2.transform));
|
|
@@ -9110,12 +9176,17 @@ function resize() {
|
|
|
9110
9176
|
showMat(size);
|
|
9111
9177
|
stage.style.overflow = current.zoom === "fit" ? "hidden" : "";
|
|
9112
9178
|
frame3.style.zoom = place2.zoom === 1 ? "" : String(place2.zoom);
|
|
9113
|
-
|
|
9179
|
+
const radii = mock ? corners(mock.screenRadius).map((radius) => `${radius * place2.zoom}px`) : [];
|
|
9180
|
+
showBrowser(bars, page, place2, auto, radii.join(" "));
|
|
9114
9181
|
touchDot?.fit(place2, place2.zoom);
|
|
9115
9182
|
drawing.style.width = `${place2.box.width}px`;
|
|
9116
9183
|
drawing.style.height = `${place2.box.height}px`;
|
|
9117
|
-
|
|
9118
|
-
|
|
9184
|
+
const at = mock ? drawing.getBoundingClientRect() : null;
|
|
9185
|
+
const ratio = window.devicePixelRatio;
|
|
9186
|
+
const nudge = at ? { x: snapShift(at.left + place2.left, ratio), y: snapShift(at.top + place2.top, ratio) } : null;
|
|
9187
|
+
screen.style.left = `${place2.left - (mock?.inset.left ?? 0) * place2.scale + (nudge?.x ?? 0)}px`;
|
|
9188
|
+
screen.style.top = `${place2.top - (mock?.inset.top ?? 0) * place2.scale + (nudge?.y ?? 0)}px`;
|
|
9189
|
+
watchDensity();
|
|
9119
9190
|
showMock(mock, place2);
|
|
9120
9191
|
screen.style.transform = place2.transform === 1 ? "" : `scale(${place2.transform})`;
|
|
9121
9192
|
const native = current.scheme !== "system" && handsSchemeDown(frame3.getRootNode());
|
|
@@ -9224,16 +9295,20 @@ function screenFor(value) {
|
|
|
9224
9295
|
frameZoom: zoomFor(value.dpr),
|
|
9225
9296
|
aside: asideOf(value.panel),
|
|
9226
9297
|
side: value.panel.side,
|
|
9227
|
-
mock: mock?.inset
|
|
9298
|
+
mock: mock?.inset,
|
|
9299
|
+
ratio: window.devicePixelRatio
|
|
9228
9300
|
});
|
|
9229
9301
|
const room2 = { width: stage.clientWidth, height: stage.clientHeight };
|
|
9230
9302
|
const at = origin(place2, room2);
|
|
9231
9303
|
const box2 = letterbox.getBoundingClientRect();
|
|
9232
9304
|
const view = stage.getBoundingClientRect();
|
|
9233
9305
|
const scrolled = (scroll2, length, room3) => Math.min(scroll2, Math.max(0, length - room3));
|
|
9306
|
+
const left = view.left + at.x - scrolled(stage.scrollLeft, place2.box.width, room2.width);
|
|
9307
|
+
const top = view.top + at.y - scrolled(stage.scrollTop, place2.box.height, room2.height);
|
|
9308
|
+
const ratio = mock ? window.devicePixelRatio : 0;
|
|
9234
9309
|
return {
|
|
9235
|
-
x:
|
|
9236
|
-
y:
|
|
9310
|
+
x: left + snapShift(left, ratio) - box2.left,
|
|
9311
|
+
y: top + snapShift(top, ratio) - box2.top,
|
|
9237
9312
|
width: place2.width * place2.scale,
|
|
9238
9313
|
height: place2.height * place2.scale
|
|
9239
9314
|
};
|
|
@@ -9537,6 +9612,7 @@ function release(follow5) {
|
|
|
9537
9612
|
window.removeEventListener("message", onMessage);
|
|
9538
9613
|
window.removeEventListener("resize", resize);
|
|
9539
9614
|
window.removeEventListener("pagehide", keep2);
|
|
9615
|
+
unwatchDensity();
|
|
9540
9616
|
frame3?.removeEventListener("load", onLoad);
|
|
9541
9617
|
readyPage = null;
|
|
9542
9618
|
touchDot?.apply(false);
|
|
@@ -9571,6 +9647,7 @@ function teardown() {
|
|
|
9571
9647
|
touchDot = null;
|
|
9572
9648
|
turnCover = null;
|
|
9573
9649
|
mockDrawing = null;
|
|
9650
|
+
ring2 = null;
|
|
9574
9651
|
mockKey = "";
|
|
9575
9652
|
frame3 = null;
|
|
9576
9653
|
hideCover();
|