strata-react 2.0.0 → 2.1.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/README.md +1 -1
- package/UPGRADING.md +10 -0
- package/dist/index.d.ts +51 -6
- package/dist/index.js +344 -23
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -11803,7 +11803,7 @@ const ViewportFrame = React.forwardRef(function ViewportFrame({ label, aspect, v
|
|
|
11803
11803
|
}),
|
|
11804
11804
|
cover && /* @__PURE__ */ jsx("div", {
|
|
11805
11805
|
className: "absolute inset-0",
|
|
11806
|
-
style: { clipPath: `inset(0 ${100 - cover.shown}% 0 0)` },
|
|
11806
|
+
style: { clipPath: cover.axis === "y" ? `inset(0 0 ${100 - cover.shown}% 0)` : `inset(0 ${100 - cover.shown}% 0 0)` },
|
|
11807
11807
|
children: /* @__PURE__ */ jsx("div", {
|
|
11808
11808
|
className: "absolute inset-0",
|
|
11809
11809
|
style: {
|
|
@@ -12421,14 +12421,26 @@ function nextBeckon(open, last) {
|
|
|
12421
12421
|
return others[Math.floor(Math.random() * others.length)] ?? null;
|
|
12422
12422
|
}
|
|
12423
12423
|
const SEP$1 = "\0";
|
|
12424
|
-
|
|
12424
|
+
const REDUCE = "(prefers-reduced-motion: reduce)";
|
|
12425
|
+
const reduceQuery = () => typeof matchMedia === "function" ? matchMedia(REDUCE) : null;
|
|
12426
|
+
function subscribeReduce(change) {
|
|
12427
|
+
const q = reduceQuery();
|
|
12428
|
+
q?.addEventListener("change", change);
|
|
12429
|
+
return () => q?.removeEventListener("change", change);
|
|
12430
|
+
}
|
|
12431
|
+
/** Whether the person asked for reduced motion; false where there is no `matchMedia` (a server, plain jsdom). */
|
|
12432
|
+
function useReducedMotion() {
|
|
12433
|
+
return React.useSyncExternalStore(subscribeReduce, () => reduceQuery()?.matches ?? false, () => false);
|
|
12434
|
+
}
|
|
12435
|
+
/** Which of `open` pulses now, moving every `ms` while `on`; null when off, when none is open or under reduced motion. The class alternates
|
|
12425
12436
|
* between two names of the same pulse each beat: a CSS animation runs again only when its name changes, so the last
|
|
12426
12437
|
* open tile, lit beat after beat, still pulses each time (Codex on #400). */
|
|
12427
12438
|
function useBeckon(on, open, ms) {
|
|
12428
12439
|
const [lit, setLit] = React.useState(null);
|
|
12429
12440
|
const openKey = open.join(SEP$1);
|
|
12441
|
+
const still = useReducedMotion();
|
|
12430
12442
|
React.useEffect(() => {
|
|
12431
|
-
if (!on || openKey === "") return;
|
|
12443
|
+
if (!on || still || openKey === "") return;
|
|
12432
12444
|
const keys = openKey.split(SEP$1);
|
|
12433
12445
|
let last = null;
|
|
12434
12446
|
let beat = 0;
|
|
@@ -12446,6 +12458,7 @@ function useBeckon(on, open, ms) {
|
|
|
12446
12458
|
};
|
|
12447
12459
|
}, [
|
|
12448
12460
|
on,
|
|
12461
|
+
still,
|
|
12449
12462
|
openKey,
|
|
12450
12463
|
ms
|
|
12451
12464
|
]);
|
|
@@ -15406,10 +15419,116 @@ async function readPixels(src, maxSide = MAX_SIDE) {
|
|
|
15406
15419
|
height
|
|
15407
15420
|
};
|
|
15408
15421
|
}
|
|
15422
|
+
/** Where a pixel's brightness (0–255) is below `threshold`. */
|
|
15423
|
+
function inkOf(p, threshold) {
|
|
15424
|
+
const out = new Uint8Array(p.width * p.height);
|
|
15425
|
+
for (let i = 0, j = 0; j < out.length; i += 4, j++) {
|
|
15426
|
+
const luma = .2126 * p.data[i] + .7152 * p.data[i + 1] + .0722 * p.data[i + 2];
|
|
15427
|
+
out[j] = p.data[i + 3] > 127 && luma < threshold ? 1 : 0;
|
|
15428
|
+
}
|
|
15429
|
+
return out;
|
|
15430
|
+
}
|
|
15431
|
+
/** The mask grown by `r` pixels each way (a square), as two passes of a running count so it is linear in the pixels whatever `r` is. */
|
|
15432
|
+
function dilate(mask, width, height, r) {
|
|
15433
|
+
if (r <= 0) return mask;
|
|
15434
|
+
const rows = new Uint8Array(mask.length);
|
|
15435
|
+
for (let y = 0; y < height; y++) {
|
|
15436
|
+
let n = 0;
|
|
15437
|
+
const o = y * width;
|
|
15438
|
+
for (let x = 0; x < Math.min(r, width); x++) n += mask[o + x];
|
|
15439
|
+
for (let x = 0; x < width; x++) {
|
|
15440
|
+
if (x + r < width) n += mask[o + x + r];
|
|
15441
|
+
if (x - r - 1 >= 0) n -= mask[o + x - r - 1];
|
|
15442
|
+
rows[o + x] = n > 0 ? 1 : 0;
|
|
15443
|
+
}
|
|
15444
|
+
}
|
|
15445
|
+
const out = new Uint8Array(mask.length);
|
|
15446
|
+
for (let x = 0; x < width; x++) {
|
|
15447
|
+
let n = 0;
|
|
15448
|
+
for (let y = 0; y < Math.min(r, height); y++) n += rows[y * width + x];
|
|
15449
|
+
for (let y = 0; y < height; y++) {
|
|
15450
|
+
if (y + r < height) n += rows[(y + r) * width + x];
|
|
15451
|
+
if (y - r - 1 >= 0) n -= rows[(y - r - 1) * width + x];
|
|
15452
|
+
out[y * width + x] = n > 0 ? 1 : 0;
|
|
15453
|
+
}
|
|
15454
|
+
}
|
|
15455
|
+
return out;
|
|
15456
|
+
}
|
|
15457
|
+
/** Default colours, used where the theme's cannot be read (no canvas): near-black for matched ink, a red and a blue. */
|
|
15458
|
+
const INK_COLOURS = {
|
|
15459
|
+
both: [
|
|
15460
|
+
40,
|
|
15461
|
+
40,
|
|
15462
|
+
40
|
|
15463
|
+
],
|
|
15464
|
+
onlyA: [
|
|
15465
|
+
200,
|
|
15466
|
+
40,
|
|
15467
|
+
40
|
|
15468
|
+
],
|
|
15469
|
+
onlyB: [
|
|
15470
|
+
40,
|
|
15471
|
+
90,
|
|
15472
|
+
210
|
|
15473
|
+
]
|
|
15474
|
+
};
|
|
15475
|
+
/**
|
|
15476
|
+
* Where two pictures' ink agrees. `b` is resampled to `a`'s size first. `threshold` is the brightness (0–255) below which a pixel is ink;
|
|
15477
|
+
* `near` the pixels either way within which the other's ink counts as the same ink.
|
|
15478
|
+
*/
|
|
15479
|
+
function inkMatch(a, b, { threshold = 128, near = 1, colours = INK_COLOURS } = {}) {
|
|
15480
|
+
const { width, height } = a;
|
|
15481
|
+
const other = resample(b, width, height);
|
|
15482
|
+
const ia = inkOf(a, threshold);
|
|
15483
|
+
const ib = inkOf(other, threshold);
|
|
15484
|
+
const nearA = dilate(ia, width, height, near);
|
|
15485
|
+
const nearB = dilate(ib, width, height, near);
|
|
15486
|
+
const marks = new Uint8ClampedArray(width * height * 4);
|
|
15487
|
+
let inkA = 0, matchedA = 0, inkB = 0, matchedB = 0;
|
|
15488
|
+
const put = (j, c) => {
|
|
15489
|
+
marks[j * 4] = c[0];
|
|
15490
|
+
marks[j * 4 + 1] = c[1];
|
|
15491
|
+
marks[j * 4 + 2] = c[2];
|
|
15492
|
+
marks[j * 4 + 3] = 255;
|
|
15493
|
+
};
|
|
15494
|
+
for (let j = 0; j < ia.length; j++) {
|
|
15495
|
+
const hitA = ia[j] === 1 && nearB[j] === 1;
|
|
15496
|
+
const hitB = ib[j] === 1 && nearA[j] === 1;
|
|
15497
|
+
if (ia[j]) {
|
|
15498
|
+
inkA++;
|
|
15499
|
+
if (hitA) matchedA++;
|
|
15500
|
+
}
|
|
15501
|
+
if (ib[j]) {
|
|
15502
|
+
inkB++;
|
|
15503
|
+
if (hitB) matchedB++;
|
|
15504
|
+
}
|
|
15505
|
+
if (hitA || hitB) put(j, colours.both);
|
|
15506
|
+
else if (ia[j]) put(j, colours.onlyA);
|
|
15507
|
+
else if (ib[j]) put(j, colours.onlyB);
|
|
15508
|
+
}
|
|
15509
|
+
let agreement;
|
|
15510
|
+
if (!inkA && !inkB) agreement = 1;
|
|
15511
|
+
else if (!inkA || !inkB) agreement = 0;
|
|
15512
|
+
else {
|
|
15513
|
+
const p = matchedB / inkB;
|
|
15514
|
+
const r = matchedA / inkA;
|
|
15515
|
+
agreement = p + r ? 2 * p * r / (p + r) : 0;
|
|
15516
|
+
}
|
|
15517
|
+
return {
|
|
15518
|
+
marks,
|
|
15519
|
+
width,
|
|
15520
|
+
height,
|
|
15521
|
+
inkA,
|
|
15522
|
+
matchedA,
|
|
15523
|
+
inkB,
|
|
15524
|
+
matchedB,
|
|
15525
|
+
agreement
|
|
15526
|
+
};
|
|
15527
|
+
}
|
|
15409
15528
|
|
|
15410
15529
|
// src/components/difference.tsx
|
|
15411
|
-
/**
|
|
15412
|
-
function
|
|
15530
|
+
/** Both pictures' pixels, read once per pair and only while `enabled`. */
|
|
15531
|
+
function usePixelPair(a, b, enabled, read) {
|
|
15413
15532
|
const [loaded, setLoaded] = React.useState(null);
|
|
15414
15533
|
const key = `${a}|${b}`;
|
|
15415
15534
|
const reader = React.useRef(read);
|
|
@@ -15432,18 +15551,85 @@ function useDifference(a, b, tolerance, enabled, read = readPixels) {
|
|
|
15432
15551
|
key,
|
|
15433
15552
|
enabled
|
|
15434
15553
|
]);
|
|
15554
|
+
if (loaded === "failed") return "failed";
|
|
15555
|
+
return loaded && loaded.key === key ? loaded : null;
|
|
15556
|
+
}
|
|
15557
|
+
/** The pixels that differ between two pictures at a tolerance (0 to 1), read only while `enabled`. */
|
|
15558
|
+
function useDifference(a, b, tolerance, enabled, read = readPixels) {
|
|
15559
|
+
const pair = usePixelPair(a, b, enabled, read);
|
|
15435
15560
|
const deferred = React.useDeferredValue(tolerance);
|
|
15436
|
-
const difference = React.useMemo(() =>
|
|
15437
|
-
|
|
15438
|
-
key,
|
|
15439
|
-
deferred
|
|
15440
|
-
]);
|
|
15441
|
-
if (loaded === "failed") return { status: "failed" };
|
|
15561
|
+
const difference = React.useMemo(() => pair && pair !== "failed" ? differences(pair.a, pair.b, deferred) : null, [pair, deferred]);
|
|
15562
|
+
if (pair === "failed") return { status: "failed" };
|
|
15442
15563
|
return difference ? {
|
|
15443
15564
|
status: "ready",
|
|
15444
15565
|
difference
|
|
15445
15566
|
} : { status: "loading" };
|
|
15446
15567
|
}
|
|
15568
|
+
/** The theme's colour for a role (`--color-danger`) as [r, g, b], read by painting it on a 1×1 canvas, so an oklch or a palette's colour comes out right. `fallback` where the page has no canvas (jsdom). */
|
|
15569
|
+
function roleColour(role, fallback) {
|
|
15570
|
+
if (typeof document === "undefined") return fallback;
|
|
15571
|
+
try {
|
|
15572
|
+
const value = getComputedStyle(document.documentElement).getPropertyValue(role).trim();
|
|
15573
|
+
const ctx = document.createElement("canvas").getContext("2d", { willReadFrequently: true });
|
|
15574
|
+
if (!value || !ctx) return fallback;
|
|
15575
|
+
ctx.fillStyle = value;
|
|
15576
|
+
ctx.fillRect(0, 0, 1, 1);
|
|
15577
|
+
const [r, g, b] = ctx.getImageData(0, 0, 1, 1).data;
|
|
15578
|
+
return [
|
|
15579
|
+
r,
|
|
15580
|
+
g,
|
|
15581
|
+
b
|
|
15582
|
+
];
|
|
15583
|
+
} catch {
|
|
15584
|
+
return fallback;
|
|
15585
|
+
}
|
|
15586
|
+
}
|
|
15587
|
+
/** Matched ink in the foreground's colour, A's own in the danger role's and B's in the info role's, read from the theme each time the view opens (light, dark or a palette). */
|
|
15588
|
+
function themeInkColours() {
|
|
15589
|
+
return {
|
|
15590
|
+
both: roleColour("--color-foreground", INK_COLOURS.both),
|
|
15591
|
+
onlyA: roleColour("--color-danger", INK_COLOURS.onlyA),
|
|
15592
|
+
onlyB: roleColour("--color-info", INK_COLOURS.onlyB)
|
|
15593
|
+
};
|
|
15594
|
+
}
|
|
15595
|
+
/** A count that goes up whenever the page's scheme or palette changes (`ThemeProvider` sets the `class` and `data-palette` of the root element), so colours read from the theme can be read again. */
|
|
15596
|
+
function useThemeChanges(enabled) {
|
|
15597
|
+
const [n, setN] = React.useState(0);
|
|
15598
|
+
React.useEffect(() => {
|
|
15599
|
+
if (!enabled || typeof MutationObserver === "undefined") return;
|
|
15600
|
+
const watch = new MutationObserver(() => setN((x) => x + 1));
|
|
15601
|
+
watch.observe(document.documentElement, {
|
|
15602
|
+
attributes: true,
|
|
15603
|
+
attributeFilter: [
|
|
15604
|
+
"class",
|
|
15605
|
+
"data-palette",
|
|
15606
|
+
"style"
|
|
15607
|
+
]
|
|
15608
|
+
});
|
|
15609
|
+
return () => watch.disconnect();
|
|
15610
|
+
}, [enabled]);
|
|
15611
|
+
return n;
|
|
15612
|
+
}
|
|
15613
|
+
/** Where two pictures' ink agrees, within `near` pixels, read only while `enabled`. */
|
|
15614
|
+
function useInkMatch(a, b, near, enabled, read = readPixels) {
|
|
15615
|
+
const pair = usePixelPair(a, b, enabled, read);
|
|
15616
|
+
const deferred = React.useDeferredValue(near);
|
|
15617
|
+
const theme = useThemeChanges(enabled);
|
|
15618
|
+
const colours = React.useMemo(() => pair && pair !== "failed" ? themeInkColours() : INK_COLOURS, [pair, theme]);
|
|
15619
|
+
const match = React.useMemo(() => pair && pair !== "failed" ? inkMatch(pair.a, pair.b, {
|
|
15620
|
+
near: deferred,
|
|
15621
|
+
colours
|
|
15622
|
+
}) : null, [
|
|
15623
|
+
pair,
|
|
15624
|
+
deferred,
|
|
15625
|
+
colours
|
|
15626
|
+
]);
|
|
15627
|
+
if (pair === "failed") return { status: "failed" };
|
|
15628
|
+
return match ? {
|
|
15629
|
+
status: "ready",
|
|
15630
|
+
match
|
|
15631
|
+
} : { status: "loading" };
|
|
15632
|
+
}
|
|
15447
15633
|
/** The marks of a difference drawn over the picture: a canvas that fits its frame the way the picture does (`object-contain`). */
|
|
15448
15634
|
function DifferenceMarks({ difference }) {
|
|
15449
15635
|
const ref = React.useRef(null);
|
|
@@ -15598,7 +15784,9 @@ const MODE_LABEL$1 = {
|
|
|
15598
15784
|
swipe: "Swipe",
|
|
15599
15785
|
fade: "Fade",
|
|
15600
15786
|
blink: "Blink",
|
|
15601
|
-
difference: "Difference"
|
|
15787
|
+
difference: "Difference",
|
|
15788
|
+
stack: "Above and below",
|
|
15789
|
+
match: "Ink match"
|
|
15602
15790
|
};
|
|
15603
15791
|
const ALL_MODES = [
|
|
15604
15792
|
"side",
|
|
@@ -15607,6 +15795,14 @@ const ALL_MODES = [
|
|
|
15607
15795
|
"blink",
|
|
15608
15796
|
"difference"
|
|
15609
15797
|
];
|
|
15798
|
+
/** The ink match in words: how much agrees, and how much of each side's ink the other lacks. */
|
|
15799
|
+
function inkWords(m, a, b) {
|
|
15800
|
+
if (!m.inkA && !m.inkB) return "Neither has any ink.";
|
|
15801
|
+
if (!m.inkA) return `${a} has no ink; ${b} has.`;
|
|
15802
|
+
if (!m.inkB) return `${b} has no ink; ${a} has.`;
|
|
15803
|
+
const only = (n, of) => n === of ? "none" : format.share((of - n) / of);
|
|
15804
|
+
return `${format.share(m.agreement)} of the ink agrees. Ink only in ${a}: ${only(m.matchedA, m.inkA)} of its ink; only in ${b}: ${only(m.matchedB, m.inkB)}.`;
|
|
15805
|
+
}
|
|
15610
15806
|
/** Two pictures to judge, side by side or laid over each other, zoomed and panned together, and full screen. */
|
|
15611
15807
|
function Compare({ label, a, b, blind, missing, mode, onModeChange, modes = ALL_MODES, regions, onPick, pick = true, pickWords, keys = true, extraShortcuts = [], footer, maxHeight, reserve, cannotCompare = "Could not read these pictures to compare their pixels.", readPixels, defaultDifference = "brightness", className }) {
|
|
15612
15808
|
const { viewport, setViewport } = useViewport();
|
|
@@ -15620,6 +15816,10 @@ function Compare({ label, a, b, blind, missing, mode, onModeChange, modes = ALL_
|
|
|
15620
15816
|
const [style, setStyle] = React.useState(defaultDifference);
|
|
15621
15817
|
const [amplify, setAmplify] = React.useState(4);
|
|
15622
15818
|
const [tolerance, setTolerance] = React.useState(10);
|
|
15819
|
+
const [axis, setAxis] = React.useState("x");
|
|
15820
|
+
const [multiply, setMultiply] = React.useState(false);
|
|
15821
|
+
const [near, setNear] = React.useState(1);
|
|
15822
|
+
const ink = useInkMatch(a.media.src, b.media.src, near, mode === "match", readPixels);
|
|
15623
15823
|
const diff = useDifference(a.media.src, b.media.src, tolerance / 100, mode === "difference" && style === "pixels", readPixels);
|
|
15624
15824
|
const frameRef = React.useRef(null);
|
|
15625
15825
|
const imgRef = React.useRef(null);
|
|
@@ -15684,8 +15884,8 @@ function Compare({ label, a, b, blind, missing, mode, onModeChange, modes = ALL_
|
|
|
15684
15884
|
maxHeight: frameCap(maxHeight, fit, full)
|
|
15685
15885
|
};
|
|
15686
15886
|
let body;
|
|
15687
|
-
if (mode === "side") body = /* @__PURE__ */ jsx("div", {
|
|
15688
|
-
className: "grid gap-3 sm:grid-cols-2",
|
|
15887
|
+
if (mode === "side" || mode === "stack") body = /* @__PURE__ */ jsx("div", {
|
|
15888
|
+
className: cn("grid gap-3", mode === "side" && "sm:grid-cols-2"),
|
|
15689
15889
|
children: [a, b].map((c, i) => /* @__PURE__ */ jsxs("figure", {
|
|
15690
15890
|
className: "grid gap-1.5",
|
|
15691
15891
|
children: [/* @__PURE__ */ jsx(Caption, {
|
|
@@ -15750,6 +15950,47 @@ function Compare({ label, a, b, blind, missing, mode, onModeChange, modes = ALL_
|
|
|
15750
15950
|
] })
|
|
15751
15951
|
})]
|
|
15752
15952
|
});
|
|
15953
|
+
else if (mode === "match") body = /* @__PURE__ */ jsxs("figure", {
|
|
15954
|
+
className: "grid gap-1.5",
|
|
15955
|
+
children: [/* @__PURE__ */ jsxs("div", {
|
|
15956
|
+
className: "flex justify-between gap-4",
|
|
15957
|
+
children: [
|
|
15958
|
+
/* @__PURE__ */ jsx(Caption, {
|
|
15959
|
+
c: a,
|
|
15960
|
+
blind
|
|
15961
|
+
}),
|
|
15962
|
+
/* @__PURE__ */ jsx("span", {
|
|
15963
|
+
className: "type-caption text-muted-foreground",
|
|
15964
|
+
children: "against"
|
|
15965
|
+
}),
|
|
15966
|
+
/* @__PURE__ */ jsx(Caption, {
|
|
15967
|
+
c: b,
|
|
15968
|
+
blind
|
|
15969
|
+
})
|
|
15970
|
+
]
|
|
15971
|
+
}), /* @__PURE__ */ jsxs(ViewportFrame, {
|
|
15972
|
+
...frameProps,
|
|
15973
|
+
ref: frameRef,
|
|
15974
|
+
label: `Ink of ${a.label} matched against ${b.label}`,
|
|
15975
|
+
children: [
|
|
15976
|
+
/* @__PURE__ */ jsx("div", {
|
|
15977
|
+
className: "absolute inset-0 opacity-0",
|
|
15978
|
+
children: pane(a, imgRef, learn)
|
|
15979
|
+
}),
|
|
15980
|
+
/* @__PURE__ */ jsx("div", { className: "absolute inset-0 bg-background" }),
|
|
15981
|
+
ink.status === "ready" && /* @__PURE__ */ jsx(DifferenceMarks, { difference: ink.match }),
|
|
15982
|
+
ink.status === "loading" && /* @__PURE__ */ jsx(Skeleton, {
|
|
15983
|
+
"aria-hidden": true,
|
|
15984
|
+
className: "absolute inset-0 size-full rounded-none opacity-40"
|
|
15985
|
+
}),
|
|
15986
|
+
ink.status === "failed" && /* @__PURE__ */ jsx("p", {
|
|
15987
|
+
role: "alert",
|
|
15988
|
+
className: "absolute inset-x-0 bottom-0 bg-background/90 p-2 type-body-sm text-danger",
|
|
15989
|
+
children: cannotCompare
|
|
15990
|
+
})
|
|
15991
|
+
]
|
|
15992
|
+
})]
|
|
15993
|
+
});
|
|
15753
15994
|
else {
|
|
15754
15995
|
const top = mode === "blink" ? showing === "a" ? a : b : a;
|
|
15755
15996
|
const bottom = b;
|
|
@@ -15772,26 +16013,28 @@ function Compare({ label, a, b, blind, missing, mode, onModeChange, modes = ALL_
|
|
|
15772
16013
|
ref: frameRef,
|
|
15773
16014
|
cover: mode === "swipe" ? {
|
|
15774
16015
|
content: pane(a, imgRef, learn),
|
|
15775
|
-
shown: divider
|
|
16016
|
+
shown: divider,
|
|
16017
|
+
axis
|
|
15776
16018
|
} : void 0,
|
|
15777
|
-
pick: mode === "swipe" ? picker?.split(divider) : mode === "blink" ? picker?.one(showing) : void 0,
|
|
16019
|
+
pick: mode === "swipe" && axis === "x" ? picker?.split(divider) : mode === "blink" ? picker?.one(showing) : void 0,
|
|
15778
16020
|
label: mode === "blink" ? `Picture ${top.label}` : `${a.label} over ${b.label}`,
|
|
15779
16021
|
overlay: mode === "swipe" && /* @__PURE__ */ jsx(Slider$1, {
|
|
15780
16022
|
"aria-label": `Divider between ${a.label} and ${b.label}`,
|
|
15781
|
-
value: divider,
|
|
15782
|
-
onChange: (v) => setDivider(v),
|
|
16023
|
+
value: axis === "y" ? 100 - divider : divider,
|
|
16024
|
+
onChange: (v) => setDivider(axis === "y" ? 100 - v : v),
|
|
15783
16025
|
minValue: 0,
|
|
15784
16026
|
maxValue: 100,
|
|
15785
16027
|
step: 1,
|
|
16028
|
+
orientation: axis === "y" ? "vertical" : "horizontal",
|
|
15786
16029
|
className: "absolute inset-0",
|
|
15787
16030
|
children: /* @__PURE__ */ jsx(SliderTrack, {
|
|
15788
16031
|
className: "pointer-events-none h-full w-full",
|
|
15789
16032
|
children: /* @__PURE__ */ jsxs(SliderThumb, {
|
|
15790
|
-
className: "pointer-events-auto grid
|
|
15791
|
-
style: { top: "50%" },
|
|
16033
|
+
className: cn("pointer-events-auto grid place-items-center focus-visible:outline-2 focus-visible:outline-ring", axis === "y" ? "h-8 w-full cursor-ns-resize" : "h-full w-8 cursor-ew-resize"),
|
|
16034
|
+
style: axis === "y" ? { left: "50%" } : { top: "50%" },
|
|
15792
16035
|
children: [/* @__PURE__ */ jsx("span", {
|
|
15793
16036
|
"aria-hidden": true,
|
|
15794
|
-
className: "col-start-1 row-start-1 h-full w-1 border-x border-background
|
|
16037
|
+
className: cn("col-start-1 row-start-1 bg-foreground", axis === "y" ? "h-1 w-full border-y border-background" : "h-full w-1 border-x border-background")
|
|
15795
16038
|
}), /* @__PURE__ */ jsx("span", {
|
|
15796
16039
|
"aria-hidden": true,
|
|
15797
16040
|
className: "col-start-1 row-start-1 size-6 rounded-pill border-2 border-foreground bg-background"
|
|
@@ -15800,7 +16043,7 @@ function Compare({ label, a, b, blind, missing, mode, onModeChange, modes = ALL_
|
|
|
15800
16043
|
})
|
|
15801
16044
|
}),
|
|
15802
16045
|
children: [pane(bottom), mode !== "swipe" && /* @__PURE__ */ jsx("div", {
|
|
15803
|
-
className: "absolute inset-0",
|
|
16046
|
+
className: cn("absolute inset-0", mode === "fade" && multiply && "mix-blend-multiply"),
|
|
15804
16047
|
style: mode === "fade" ? { opacity: 1 - blend / 100 } : void 0,
|
|
15805
16048
|
children: pane(top, imgRef, learn)
|
|
15806
16049
|
})]
|
|
@@ -15849,6 +16092,38 @@ function Compare({ label, a, b, blind, missing, mode, onModeChange, modes = ALL_
|
|
|
15849
16092
|
className: "type-caption text-muted-foreground",
|
|
15850
16093
|
children: picker.unavailable(MODE_LABEL$1[mode])
|
|
15851
16094
|
}),
|
|
16095
|
+
mode === "swipe" && /* @__PURE__ */ jsx(ToggleGroup, {
|
|
16096
|
+
label: "Swipe direction",
|
|
16097
|
+
options: [{
|
|
16098
|
+
value: "x",
|
|
16099
|
+
label: "Left and right"
|
|
16100
|
+
}, {
|
|
16101
|
+
value: "y",
|
|
16102
|
+
label: "Top and bottom"
|
|
16103
|
+
}],
|
|
16104
|
+
value: axis,
|
|
16105
|
+
onChange: (v) => setAxis(v),
|
|
16106
|
+
size: "sm",
|
|
16107
|
+
className: "justify-self-start"
|
|
16108
|
+
}),
|
|
16109
|
+
picker && mode === "swipe" && axis === "y" && /* @__PURE__ */ jsx("p", {
|
|
16110
|
+
className: "type-caption text-muted-foreground",
|
|
16111
|
+
children: picker.unavailable("Top and bottom")
|
|
16112
|
+
}),
|
|
16113
|
+
mode === "fade" && /* @__PURE__ */ jsx(ToggleGroup, {
|
|
16114
|
+
label: "Blend",
|
|
16115
|
+
options: [{
|
|
16116
|
+
value: "normal",
|
|
16117
|
+
label: "Normal"
|
|
16118
|
+
}, {
|
|
16119
|
+
value: "multiply",
|
|
16120
|
+
label: "Multiply"
|
|
16121
|
+
}],
|
|
16122
|
+
value: multiply ? "multiply" : "normal",
|
|
16123
|
+
onChange: (v) => setMultiply(v === "multiply"),
|
|
16124
|
+
size: "sm",
|
|
16125
|
+
className: "justify-self-start"
|
|
16126
|
+
}),
|
|
15852
16127
|
mode === "fade" && /* @__PURE__ */ jsxs("div", {
|
|
15853
16128
|
className: "flex items-center gap-3",
|
|
15854
16129
|
children: [
|
|
@@ -15936,6 +16211,52 @@ function Compare({ label, a, b, blind, missing, mode, onModeChange, modes = ALL_
|
|
|
15936
16211
|
children: diff.status === "ready" ? diff.difference.differing === 0 ? "No pixels differ at this tolerance." : `${format.share(diff.difference.differing / diff.difference.total)} of pixels differ at this tolerance.` : diff.status === "loading" ? "Comparing pixels…" : ""
|
|
15937
16212
|
})] })]
|
|
15938
16213
|
}),
|
|
16214
|
+
mode === "match" && /* @__PURE__ */ jsxs("div", {
|
|
16215
|
+
className: "grid gap-2",
|
|
16216
|
+
children: [
|
|
16217
|
+
/* @__PURE__ */ jsxs("div", {
|
|
16218
|
+
className: "flex items-center gap-3",
|
|
16219
|
+
children: [
|
|
16220
|
+
/* @__PURE__ */ jsx("span", {
|
|
16221
|
+
className: "type-caption text-muted-foreground",
|
|
16222
|
+
children: "Near"
|
|
16223
|
+
}),
|
|
16224
|
+
/* @__PURE__ */ jsx(Slider, {
|
|
16225
|
+
"aria-label": "Pixels within which ink is the same ink",
|
|
16226
|
+
value: near,
|
|
16227
|
+
onChange: setNear,
|
|
16228
|
+
min: 0,
|
|
16229
|
+
max: 6,
|
|
16230
|
+
hideValue: true,
|
|
16231
|
+
className: "flex-1"
|
|
16232
|
+
}),
|
|
16233
|
+
/* @__PURE__ */ jsxs("span", {
|
|
16234
|
+
className: "w-10 type-caption tabular-nums text-muted-foreground",
|
|
16235
|
+
children: [near, "\xA0px"]
|
|
16236
|
+
})
|
|
16237
|
+
]
|
|
16238
|
+
}),
|
|
16239
|
+
/* @__PURE__ */ jsx("p", {
|
|
16240
|
+
className: "flex flex-wrap gap-x-4 type-caption text-muted-foreground",
|
|
16241
|
+
children: [
|
|
16242
|
+
["bg-foreground", "In both"],
|
|
16243
|
+
["bg-danger", `Only ${a.label}`],
|
|
16244
|
+
["bg-info", `Only ${b.label}`]
|
|
16245
|
+
].map(([swatch, words]) => /* @__PURE__ */ jsxs("span", {
|
|
16246
|
+
className: "inline-flex items-center gap-1.5",
|
|
16247
|
+
children: [/* @__PURE__ */ jsx("span", {
|
|
16248
|
+
"aria-hidden": true,
|
|
16249
|
+
className: cn("inline-block size-2.5 rounded-control", swatch)
|
|
16250
|
+
}), words]
|
|
16251
|
+
}, words))
|
|
16252
|
+
}),
|
|
16253
|
+
/* @__PURE__ */ jsx("p", {
|
|
16254
|
+
role: "status",
|
|
16255
|
+
className: "type-body-sm text-muted-foreground",
|
|
16256
|
+
children: ink.status === "ready" ? inkWords(ink.match, a.label, b.label) : ink.status === "loading" ? "Matching ink…" : ""
|
|
16257
|
+
})
|
|
16258
|
+
]
|
|
16259
|
+
}),
|
|
15939
16260
|
mode === "blink" && /* @__PURE__ */ jsx("div", { children: /* @__PURE__ */ jsx(ToggleGroup, {
|
|
15940
16261
|
label: "Showing",
|
|
15941
16262
|
options: [{
|
|
@@ -21057,5 +21378,5 @@ function FolderPicker({ label, useFolders: useListing, value, onChange, onChoose
|
|
|
21057
21378
|
});
|
|
21058
21379
|
}
|
|
21059
21380
|
|
|
21060
|
-
export { ActiveList, Alert, AlertDialog, AppShell, AsyncButton, BookViewer, BoxList, BoxOverlay, BoxedPicture, Breadcrumb, BulkBar, Button, ButtonLink, ByteView, COLOR_SCHEME_STORAGE_KEY, Checkbox, ChoiceGrid, ChoiceGridSkeleton, ChoiceGroup, ClipsProvider, ColorField, ColorSchemeChoice, CommandLegend, CommandMenu, Compare, CompareAudio, CompareGrid, CompareText, CompareVideo, CompareVideoGrid, Composer, CompositionBar, Console, ContextMenu, Conversation, CursorScope, DEFAULT_PALETTE, DEFAULT_TOLERANCE, DataTable, DataView$1 as DataView, Density, Dialog, Disclosure, Done, DragSource, EditListPlayer, EmptyState, FIT, Field, FileButton, FileDropOverlay, FileDropZone, FileOutcomes, FilmStrip, FolderPicker, FullscreenFrame, HttpError, IconButton, InfiniteList, Input, InputLevel, Inspector, InspectorSection, JobStatus, JobsTable, KeysLegend, LEVEL_FLOOR_DB, Lightbox, LineChart, LineChartGroup, LinkCard, LinkCardList, ListeningLevel, LoadError, LoadMore, MAX_SCALE, MAX_SIDE, MIN_SCALE, MISSING, Mark, MarkSummary, MarkableText, MediaContents, MediaGroup, MediaPlayer, MediaStage, Menu, Meter, Metric, MetricStrip, MicrophoneContext, MicrophoneError, MissingFile, NBSP, NativeSelect, NumberField, OutboxStatus, PALETTE_STORAGE_KEY, PageHeader, PairJudge, PairVote, PaletteChoice, Pane, PauseButton, PixelImage, PlaceBoard, PlayWindowButton, PlayerNotice, Popover, PropertyList, PropertyRow, RateChoice, RegionEditor, RichText, RowAction, SPEECH_RATES, STRATA_DRAG_TYPE, SaveStatus, SayAgain, ScheduleTable, SecretField, SeekBar, SelectableGrid, SelectableGridSkeleton, SequenceTimeline, ShortcutEditor, SideNav, Skeleton, Slider, SortableList, SpanActions, SpanStrip, Split, StageGuides, StaleNotice, Status, StrataQueryProvider, StrataToastRegion, Switch, SystemPanel, TableSkeleton, Tabs, TakeLevel, TextLink, Textarea, ThemeProvider, Thumbnail, ThumbnailSkeleton, TileGrid, TileGridSkeleton, TimeReadout, Timeline, TimelinePlayer, TimelineZoomControls, Toggle, ToggleGroup, Toolbar, ToolbarSeparator, Tooltip, TranscriptView, Transport, Tree, UndoBar, ViewOptions, ViewportFrame, VirtualList, VolumeControl, Waveform, WorkflowSteps, WorkflowSummary, Workspace, WorkspaceBar, actualPixelsScale, ancestorsOf, apiPage, appBase, boxViewport, browserMicrophone, buttonVariants, canFullscreen, canPlayClips, canSay, canSpeak, checkKey, clampToRoom, clampViewport, clipsQueryKey, cn, colorSchemeScript, commandShortcut, continues, countMarks, createApi, createFormat, createOutbox, createQueryClient, createReserve, createSegmenter, createTypedApi, crossedThreshold, currentItem, describeActionError, describeHttpError, describeRegion, describeWorkflowSummary, detectPlatform, diffWords, differences, diskThresholds, drawRect, ease, editTimeOf, editTimes, encodeWav, errorPayload, explainMicrophoneError, fetchJson, fieldErrorsOf, findPage, fitRect, followAim, format, formatChord, frameAt, gainToVolume, geo, gridPoints, gutterOf, inputLevelThresholds, isDoubtful, isRefusal, isReservedChord, isTaskRunning, isTypingTarget, isWorkflowRunning, jobProgressText, joinMediaGroup, joinRects, joinSamples, keyName, labelOf, lerpRect, locateInEdit, logScale, loudnessOf, marksFor, matchEntities, matchGains, matchesAccept, matchesChord, measureLoudness, moveGutter, moveRect, nextBreak, noOverlap, normaliseAngle, pageName, paletteScript, palettes, parentOf, parseChord, parseInline, parseRichText, parseSort, peakDb, peakGain, peaksFromAudio, phraseAt, phraseDoubtful, phraseOfWordId, pickEvenly, pickVoice, pixelZoom, plainText, rangeBetween, readErrorBody, readPixels, readingOrder, regionShares, regionStyle, resample, resamplePeaks, resizeRect, rgbaToBlob, rmsDb, safeHref, sayPosition, serialiseSort, settleCut, skipAction, snapToGrid, sortRows, speak, speechLevel, splitRect, staleOf, stepId, stepOnGrid, stopSpeaking, summariseWorkflow, textOf, tickLabel, tickStep, ticksBetween, toDate, toLoad, toPeakPair, toast, toastTimeout, transportShortcuts, turnRect, turnedSize, typeSteps, useActiveItem, useAsyncAction, useAttachedSource, useAutoRecorder, useAutoSave, useBookUrl, useBoxes, useChoices, useClientWork, useClips, useColorScheme, useCommands, useDifference, useEditList, useExpanded, useFileIntake, useHistory, useHistoryState, useHotkeys, useInView, useInfiniteLoad, useJob, useJobAction, useLeaveGuard, useLightboxUrl, useLoad, useMediaElement, useMediaSpans, useMicrophone, useObjectUrl, useOutbox, useOutboxStarted, usePalette, usePlayerWarnings, usePoll, useRebindableShortcuts, useRecorder, useReserve, useSayOnShow, useSearchParam, useSelection, useSettledStatus, useSharedCursor, useSpeech, useSystemColorScheme, useSystemInfo, useTimeline, useTimelineZoom, useUndoable, useViewOptions, useViewPointers, useViewport, useWheelZoom, useWorkflowRun, useWorkspaceState, valueAt, viewOf, viewsOf, withBase, wordAt, wordId, zoomAt, zoomToBox };
|
|
21381
|
+
export { ActiveList, Alert, AlertDialog, AppShell, AsyncButton, BookViewer, BoxList, BoxOverlay, BoxedPicture, Breadcrumb, BulkBar, Button, ButtonLink, ByteView, COLOR_SCHEME_STORAGE_KEY, Checkbox, ChoiceGrid, ChoiceGridSkeleton, ChoiceGroup, ClipsProvider, ColorField, ColorSchemeChoice, CommandLegend, CommandMenu, Compare, CompareAudio, CompareGrid, CompareText, CompareVideo, CompareVideoGrid, Composer, CompositionBar, Console, ContextMenu, Conversation, CursorScope, DEFAULT_PALETTE, DEFAULT_TOLERANCE, DataTable, DataView$1 as DataView, Density, Dialog, Disclosure, Done, DragSource, EditListPlayer, EmptyState, FIT, Field, FileButton, FileDropOverlay, FileDropZone, FileOutcomes, FilmStrip, FolderPicker, FullscreenFrame, HttpError, INK_COLOURS, IconButton, InfiniteList, Input, InputLevel, Inspector, InspectorSection, JobStatus, JobsTable, KeysLegend, LEVEL_FLOOR_DB, Lightbox, LineChart, LineChartGroup, LinkCard, LinkCardList, ListeningLevel, LoadError, LoadMore, MAX_SCALE, MAX_SIDE, MIN_SCALE, MISSING, Mark, MarkSummary, MarkableText, MediaContents, MediaGroup, MediaPlayer, MediaStage, Menu, Meter, Metric, MetricStrip, MicrophoneContext, MicrophoneError, MissingFile, NBSP, NativeSelect, NumberField, OutboxStatus, PALETTE_STORAGE_KEY, PageHeader, PairJudge, PairVote, PaletteChoice, Pane, PauseButton, PixelImage, PlaceBoard, PlayWindowButton, PlayerNotice, Popover, PropertyList, PropertyRow, RateChoice, RegionEditor, RichText, RowAction, SPEECH_RATES, STRATA_DRAG_TYPE, SaveStatus, SayAgain, ScheduleTable, SecretField, SeekBar, SelectableGrid, SelectableGridSkeleton, SequenceTimeline, ShortcutEditor, SideNav, Skeleton, Slider, SortableList, SpanActions, SpanStrip, Split, StageGuides, StaleNotice, Status, StrataQueryProvider, StrataToastRegion, Switch, SystemPanel, TableSkeleton, Tabs, TakeLevel, TextLink, Textarea, ThemeProvider, Thumbnail, ThumbnailSkeleton, TileGrid, TileGridSkeleton, TimeReadout, Timeline, TimelinePlayer, TimelineZoomControls, Toggle, ToggleGroup, Toolbar, ToolbarSeparator, Tooltip, TranscriptView, Transport, Tree, UndoBar, ViewOptions, ViewportFrame, VirtualList, VolumeControl, Waveform, WorkflowSteps, WorkflowSummary, Workspace, WorkspaceBar, actualPixelsScale, ancestorsOf, apiPage, appBase, boxViewport, browserMicrophone, buttonVariants, canFullscreen, canPlayClips, canSay, canSpeak, checkKey, clampToRoom, clampViewport, clipsQueryKey, cn, colorSchemeScript, commandShortcut, continues, countMarks, createApi, createFormat, createOutbox, createQueryClient, createReserve, createSegmenter, createTypedApi, crossedThreshold, currentItem, describeActionError, describeHttpError, describeRegion, describeWorkflowSummary, detectPlatform, diffWords, differences, diskThresholds, drawRect, ease, editTimeOf, editTimes, encodeWav, errorPayload, explainMicrophoneError, fetchJson, fieldErrorsOf, findPage, fitRect, followAim, format, formatChord, frameAt, gainToVolume, geo, gridPoints, gutterOf, inkMatch, inputLevelThresholds, isDoubtful, isRefusal, isReservedChord, isTaskRunning, isTypingTarget, isWorkflowRunning, jobProgressText, joinMediaGroup, joinRects, joinSamples, keyName, labelOf, lerpRect, locateInEdit, logScale, loudnessOf, marksFor, matchEntities, matchGains, matchesAccept, matchesChord, measureLoudness, moveGutter, moveRect, nextBreak, noOverlap, normaliseAngle, pageName, paletteScript, palettes, parentOf, parseChord, parseInline, parseRichText, parseSort, peakDb, peakGain, peaksFromAudio, phraseAt, phraseDoubtful, phraseOfWordId, pickEvenly, pickVoice, pixelZoom, plainText, rangeBetween, readErrorBody, readPixels, readingOrder, regionShares, regionStyle, resample, resamplePeaks, resizeRect, rgbaToBlob, rmsDb, safeHref, sayPosition, serialiseSort, settleCut, skipAction, snapToGrid, sortRows, speak, speechLevel, splitRect, staleOf, stepId, stepOnGrid, stopSpeaking, summariseWorkflow, textOf, tickLabel, tickStep, ticksBetween, toDate, toLoad, toPeakPair, toast, toastTimeout, transportShortcuts, turnRect, turnedSize, typeSteps, useActiveItem, useAsyncAction, useAttachedSource, useAutoRecorder, useAutoSave, useBookUrl, useBoxes, useChoices, useClientWork, useClips, useColorScheme, useCommands, useDifference, useEditList, useExpanded, useFileIntake, useHistory, useHistoryState, useHotkeys, useInView, useInfiniteLoad, useInkMatch, useJob, useJobAction, useLeaveGuard, useLightboxUrl, useLoad, useMediaElement, useMediaSpans, useMicrophone, useObjectUrl, useOutbox, useOutboxStarted, usePalette, usePlayerWarnings, usePoll, useRebindableShortcuts, useRecorder, useReserve, useSayOnShow, useSearchParam, useSelection, useSettledStatus, useSharedCursor, useSpeech, useSystemColorScheme, useSystemInfo, useTimeline, useTimelineZoom, useUndoable, useViewOptions, useViewPointers, useViewport, useWheelZoom, useWorkflowRun, useWorkspaceState, valueAt, viewOf, viewsOf, withBase, wordAt, wordId, zoomAt, zoomToBox };
|
|
21061
21382
|
//# sourceMappingURL=index.js.map
|