strata-react 2.0.1 → 2.1.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/README.md +2 -2
- package/UPGRADING.md +9 -0
- package/dist/hls.d.ts +1 -1
- package/dist/index.d.ts +53 -8
- package/dist/index.js +518 -47
- package/dist/index.js.map +1 -1
- package/dist/{media-player-BETa3P7K.d.ts → media-player-Buvu2l7R.d.ts} +20 -6
- package/dist/{microphone-BI7HNGxj.d.ts → microphone-DDOnQHxf.d.ts} +2 -2
- package/dist/testing.d.ts +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -10,7 +10,7 @@ import { a as fieldErrorsOf, i as errorPayload, n as describeActionError, o as r
|
|
|
10
10
|
import { a as PaletteChoice, c as paletteScript, d as usePalette, f as useSystemColorScheme, i as PALETTE_STORAGE_KEY, l as palettes, n as ColorSchemeChoice, o as ThemeProvider, p as Density, r as DEFAULT_PALETTE, s as colorSchemeScript, t as COLOR_SCHEME_STORAGE_KEY, u as useColorScheme } from "./theme-1oOSMj_D.js";
|
|
11
11
|
import * as React from "react";
|
|
12
12
|
import { Autocomplete, Button as Button$1, Cell, Checkbox as Checkbox$1, Collection, Column, Dialog as Dialog$1, DialogTrigger, Disclosure as Disclosure$1, DisclosurePanel, DropIndicator, DropZone, FileTrigger, GridLayout, GridList, GridListItem, Header, Heading, Input as Input$1, Keyboard, Link, ListBox, ListBoxItem, ListLayout, ListStateContext, Menu as Menu$1, MenuItem, MenuSection, MenuTrigger, Modal, ModalOverlay, Popover as Popover$1, RouterProvider, Row, SearchField, Select, SelectValue, Separator, Slider as Slider$1, SliderThumb, SliderTrack, SubmenuTrigger, Switch as Switch$1, Tab, TabList, TabPanel, Table, TableBody, TableHeader, TableLayout, Tabs as Tabs$1, Text, ToggleButton, ToggleButtonGroup, Tree as Tree$1, TreeItem, TreeItemContent, Virtualizer, useDragAndDrop, useFilter } from "react-aria-components";
|
|
13
|
-
import { ArrowDown, ArrowUp, ArrowUpDown, ArrowUpRight, Ban, Check, ChevronDown, ChevronLeft, ChevronRight, CircleAlert, CircleCheck, CircleDashed, Clock, CloudOff, Columns2, Ellipsis, Eye, EyeOff, FastForward, FileQuestion, Flag, Folder, FolderOpen, FolderX, GripVertical, ImageOff, Info, KeyRound, LayoutGrid, List, Loader, LoaderCircle, Lock, Maximize, Maximize2, Minimize, Minus, PanelBottomClose, PanelBottomOpen, PanelLeftClose, PanelLeftOpen, PanelRightClose, PanelRightOpen, PanelTopClose, PanelTopOpen, Pause, Pencil, Play, Redo2, Rewind, RotateCcw, RotateCw, Scan, Search, Send, SkipBack, SkipForward, SlidersHorizontal, Square, StepBack, StepForward, Trash2, TriangleAlert, Undo2, Upload, Volume2, VolumeX, X, ZoomIn, ZoomOut } from "lucide-react";
|
|
13
|
+
import { ArrowDown, ArrowUp, ArrowUpDown, ArrowUpRight, Ban, Check, ChevronDown, ChevronLeft, ChevronRight, ChevronsUp, CircleAlert, CircleCheck, CircleDashed, Clock, CloudOff, Columns2, Ellipsis, Eye, EyeOff, FastForward, FileQuestion, Flag, Folder, FolderOpen, FolderX, GripVertical, ImageOff, Info, KeyRound, LayoutGrid, List, Loader, LoaderCircle, Lock, Maximize, Maximize2, Minimize, Minus, PanelBottomClose, PanelBottomOpen, PanelLeftClose, PanelLeftOpen, PanelRightClose, PanelRightOpen, PanelTopClose, PanelTopOpen, Pause, Pencil, Play, Redo2, Rewind, RotateCcw, RotateCw, Scan, Search, Send, SkipBack, SkipForward, SlidersHorizontal, Square, StepBack, StepForward, Trash2, TriangleAlert, Undo2, Upload, Volume2, VolumeX, X, ZoomIn, ZoomOut } from "lucide-react";
|
|
14
14
|
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
15
15
|
import { Link as Link$1, NavLink, useHref, useNavigate, useSearchParams } from "react-router";
|
|
16
16
|
import { hashKey, useInfiniteQuery, useQuery, useQueryClient } from "@tanstack/react-query";
|
|
@@ -4001,29 +4001,50 @@ function Transport({ playing, onPlayPause, onStop, onToStart, onToEnd, onStepBac
|
|
|
4001
4001
|
]
|
|
4002
4002
|
});
|
|
4003
4003
|
}
|
|
4004
|
-
/** A mute button and a volume slider with its value in percent. Muting sets the volume to 0 and remembers the level; unmuting puts it back. Moving the slider from 0 unmutes. */
|
|
4005
|
-
function VolumeControl({ volume, onVolumeChange, max = 100, disabled, className }) {
|
|
4004
|
+
/** A mute button and a volume slider with its value in percent. Muting sets the volume to 0 and remembers the level; unmuting puts it back. Moving the slider from 0 unmutes. With `boost`, a Louder toggle lets it past 100. */
|
|
4005
|
+
function VolumeControl({ volume, onVolumeChange, max = 100, boost, disabled, className }) {
|
|
4006
4006
|
const last = React.useRef(volume > 0 ? volume : 100);
|
|
4007
4007
|
if (volume > 0) last.current = volume;
|
|
4008
4008
|
const muted = volume === 0;
|
|
4009
|
+
const [louderAsked, setLouderAsked] = React.useState(false);
|
|
4010
|
+
const canBoost = boost !== void 0 && boost > 100;
|
|
4011
|
+
const louder = canBoost && (louderAsked || volume > 100 || last.current > 100);
|
|
4012
|
+
const top = canBoost ? louder ? boost : 100 : max;
|
|
4009
4013
|
return /* @__PURE__ */ jsxs("div", {
|
|
4010
4014
|
className: cn("flex min-w-0 items-center gap-2", className),
|
|
4011
|
-
children: [
|
|
4012
|
-
|
|
4013
|
-
|
|
4014
|
-
|
|
4015
|
-
|
|
4016
|
-
|
|
4017
|
-
|
|
4018
|
-
|
|
4019
|
-
|
|
4020
|
-
|
|
4021
|
-
|
|
4022
|
-
|
|
4023
|
-
|
|
4024
|
-
|
|
4025
|
-
|
|
4026
|
-
|
|
4015
|
+
children: [
|
|
4016
|
+
/* @__PURE__ */ jsx(IconButton, {
|
|
4017
|
+
icon: muted ? VolumeX : Volume2,
|
|
4018
|
+
label: muted ? "Unmute" : "Mute",
|
|
4019
|
+
hint: "M",
|
|
4020
|
+
disabled,
|
|
4021
|
+
onClick: () => onVolumeChange(muted ? last.current : 0)
|
|
4022
|
+
}),
|
|
4023
|
+
/* @__PURE__ */ jsx(Slider, {
|
|
4024
|
+
"aria-label": "Volume",
|
|
4025
|
+
value: Math.min(volume, top),
|
|
4026
|
+
onChange: onVolumeChange,
|
|
4027
|
+
min: 0,
|
|
4028
|
+
max: top,
|
|
4029
|
+
unit: "%",
|
|
4030
|
+
disabled,
|
|
4031
|
+
className: "w-40 min-w-24 shrink"
|
|
4032
|
+
}),
|
|
4033
|
+
canBoost && /* @__PURE__ */ jsx(Toggle, {
|
|
4034
|
+
label: `Louder, up to ${boost}%`,
|
|
4035
|
+
icon: ChevronsUp,
|
|
4036
|
+
iconOnly: true,
|
|
4037
|
+
pressed: louder,
|
|
4038
|
+
disabled,
|
|
4039
|
+
onChange: (on) => {
|
|
4040
|
+
setLouderAsked(on);
|
|
4041
|
+
if (!on && (volume > 100 || last.current > 100)) {
|
|
4042
|
+
last.current = 100;
|
|
4043
|
+
onVolumeChange(muted ? 0 : 100);
|
|
4044
|
+
}
|
|
4045
|
+
}
|
|
4046
|
+
})
|
|
4047
|
+
]
|
|
4027
4048
|
});
|
|
4028
4049
|
}
|
|
4029
4050
|
/** A choice of playback speed ("0.5×", "1×", "1.5×"), named "Playback speed": React Aria's Select. */
|
|
@@ -4571,6 +4592,121 @@ function createWatchedRanges() {
|
|
|
4571
4592
|
};
|
|
4572
4593
|
}
|
|
4573
4594
|
|
|
4595
|
+
// src/components/media-sound.ts
|
|
4596
|
+
/** The limiter's threshold, dB under full scale. */
|
|
4597
|
+
const LIMIT_DB = -1;
|
|
4598
|
+
const RATIO = 20;
|
|
4599
|
+
/** Seconds: how fast an app's level glides to a new value (a time constant; about three of them to arrive). */
|
|
4600
|
+
const GLIDE = .5;
|
|
4601
|
+
const FOLLOW = .02;
|
|
4602
|
+
/** The compressor's automatic make-up gain at the limiter's settings, as the Web Audio spec defines it. */
|
|
4603
|
+
function makeupGain(threshold = -1, ratio = RATIO) {
|
|
4604
|
+
const atFullScale = threshold + (0 - threshold) / ratio;
|
|
4605
|
+
return Math.pow(1 / Math.pow(10, atFullScale / 20), .6);
|
|
4606
|
+
}
|
|
4607
|
+
const graphs = /* @__PURE__ */ new WeakMap();
|
|
4608
|
+
/**
|
|
4609
|
+
* Whether this browser can play a level past the element's own (it has Web Audio), and, given an element, whether its
|
|
4610
|
+
* source may go through it: same-origin (or a `blob:` or `data:` URL, as a stream engine's Media Source is), or loaded
|
|
4611
|
+
* with `crossOrigin` set (then the server must answer with CORS). Any other file comes out of a graph as silence, so it
|
|
4612
|
+
* is never routed: it plays at its own level, with no gain and no boost.
|
|
4613
|
+
*/
|
|
4614
|
+
function canShapeSound(el) {
|
|
4615
|
+
if (typeof window === "undefined" || typeof window.AudioContext !== "function") return false;
|
|
4616
|
+
if (!el) return true;
|
|
4617
|
+
const src = el.currentSrc || el.getAttribute("src") || "";
|
|
4618
|
+
if (!src || el.crossOrigin !== null) return true;
|
|
4619
|
+
try {
|
|
4620
|
+
const url = new URL(src, window.location.href);
|
|
4621
|
+
return url.protocol === "blob:" || url.protocol === "data:" || url.origin === window.location.origin;
|
|
4622
|
+
} catch {
|
|
4623
|
+
return false;
|
|
4624
|
+
}
|
|
4625
|
+
}
|
|
4626
|
+
function graphFor(el) {
|
|
4627
|
+
const had = graphs.get(el);
|
|
4628
|
+
if (had) return had;
|
|
4629
|
+
if (!canShapeSound(el)) return null;
|
|
4630
|
+
const context = new AudioContext();
|
|
4631
|
+
const level = context.createGain();
|
|
4632
|
+
const boost = context.createGain();
|
|
4633
|
+
const limiter = context.createDynamicsCompressor();
|
|
4634
|
+
limiter.threshold.value = -1;
|
|
4635
|
+
limiter.knee.value = 0;
|
|
4636
|
+
limiter.ratio.value = RATIO;
|
|
4637
|
+
limiter.attack.value = .001;
|
|
4638
|
+
limiter.release.value = .1;
|
|
4639
|
+
const unlift = context.createGain();
|
|
4640
|
+
unlift.gain.value = 1 / makeupGain();
|
|
4641
|
+
level.connect(boost).connect(limiter).connect(unlift).connect(context.destination);
|
|
4642
|
+
const graph = {
|
|
4643
|
+
context,
|
|
4644
|
+
level,
|
|
4645
|
+
boost,
|
|
4646
|
+
routed: false,
|
|
4647
|
+
waiting: false,
|
|
4648
|
+
levelTarget: 1,
|
|
4649
|
+
boostTarget: 1
|
|
4650
|
+
};
|
|
4651
|
+
graphs.set(el, graph);
|
|
4652
|
+
return graph;
|
|
4653
|
+
}
|
|
4654
|
+
function route(el, graph) {
|
|
4655
|
+
if (graph.context.state !== "running") {
|
|
4656
|
+
graph.context.resume().catch(() => {});
|
|
4657
|
+
return;
|
|
4658
|
+
}
|
|
4659
|
+
if (graph.routed) return;
|
|
4660
|
+
if (!canShapeSound(el)) return;
|
|
4661
|
+
try {
|
|
4662
|
+
graph.context.createMediaElementSource(el).connect(graph.level);
|
|
4663
|
+
graph.routed = true;
|
|
4664
|
+
} catch {
|
|
4665
|
+
graph.routed = true;
|
|
4666
|
+
}
|
|
4667
|
+
}
|
|
4668
|
+
/**
|
|
4669
|
+
* Applies `gain` (the app's level, a factor) and `boost` (the person's, a factor of 1 or more) to an element's sound.
|
|
4670
|
+
* Makes nothing while both are 1 and no graph exists yet. Call again whenever either changes, and on `play` (the
|
|
4671
|
+
* gesture that lets the context start).
|
|
4672
|
+
*/
|
|
4673
|
+
function shapeSound(el, gain, boost, glide = true) {
|
|
4674
|
+
if (!graphs.has(el) && gain === 1 && boost === 1) return;
|
|
4675
|
+
const graph = graphFor(el);
|
|
4676
|
+
if (!graph) return;
|
|
4677
|
+
const now = graph.context.currentTime;
|
|
4678
|
+
const wanted = Math.max(0, gain);
|
|
4679
|
+
if (wanted !== graph.levelTarget) {
|
|
4680
|
+
graph.levelTarget = wanted;
|
|
4681
|
+
graph.level.gain.cancelScheduledValues(now);
|
|
4682
|
+
graph.level.gain.setTargetAtTime(wanted, now, graph.routed && glide ? GLIDE : FOLLOW);
|
|
4683
|
+
}
|
|
4684
|
+
if (boost !== graph.boostTarget) {
|
|
4685
|
+
graph.boostTarget = boost;
|
|
4686
|
+
graph.boost.gain.cancelScheduledValues(now);
|
|
4687
|
+
graph.boost.gain.setTargetAtTime(boost, now, FOLLOW);
|
|
4688
|
+
}
|
|
4689
|
+
if (!graph.routed && !graph.waiting && graph.context.state !== "running") {
|
|
4690
|
+
graph.waiting = true;
|
|
4691
|
+
graph.context.addEventListener("statechange", function started() {
|
|
4692
|
+
if (graph.context.state !== "running") return;
|
|
4693
|
+
graph.context.removeEventListener("statechange", started);
|
|
4694
|
+
graph.waiting = false;
|
|
4695
|
+
route(el, graph);
|
|
4696
|
+
});
|
|
4697
|
+
}
|
|
4698
|
+
route(el, graph);
|
|
4699
|
+
}
|
|
4700
|
+
/**
|
|
4701
|
+
* Lets go of an element's audio while its player is gone: suspends its context, which frees the audio thread. Not
|
|
4702
|
+
* closed, since an element can be given to a context only once: the same element mounted again (React's double mount in
|
|
4703
|
+
* development) resumes it on the next `shapeSound`.
|
|
4704
|
+
*/
|
|
4705
|
+
function releaseSound(el) {
|
|
4706
|
+
const graph = graphs.get(el);
|
|
4707
|
+
if (graph && graph.context.state === "running") graph.context.suspend().catch(() => {});
|
|
4708
|
+
}
|
|
4709
|
+
|
|
4574
4710
|
// src/components/link.tsx
|
|
4575
4711
|
function useTarget(target, newTab, state) {
|
|
4576
4712
|
const navigate = useNavigate();
|
|
@@ -4631,6 +4767,10 @@ function TextLink(all) {
|
|
|
4631
4767
|
}
|
|
4632
4768
|
|
|
4633
4769
|
// src/components/media-player.tsx
|
|
4770
|
+
/** The most the volume goes to: a boost where Web Audio can play it, else 100. */
|
|
4771
|
+
function maxVolumeOf(boost, el) {
|
|
4772
|
+
return boost && boost > 100 && canShapeSound(el) ? boost : 100;
|
|
4773
|
+
}
|
|
4634
4774
|
/** How far one notch of the wheel over a focused video moves the volume, in percent. */
|
|
4635
4775
|
const WHEEL_VOLUME_STEP = 5;
|
|
4636
4776
|
const idle = {
|
|
@@ -4642,6 +4782,7 @@ const idle = {
|
|
|
4642
4782
|
buffered: 0,
|
|
4643
4783
|
volume: 100,
|
|
4644
4784
|
muted: false,
|
|
4785
|
+
maxVolume: 100,
|
|
4645
4786
|
rate: 1,
|
|
4646
4787
|
ended: false,
|
|
4647
4788
|
loading: false,
|
|
@@ -4708,6 +4849,7 @@ function useMediaElement(ref, options = {}) {
|
|
|
4708
4849
|
const windowEnded = React.useRef(false);
|
|
4709
4850
|
const streamProblem = React.useRef(null);
|
|
4710
4851
|
const edgePause = React.useRef(false);
|
|
4852
|
+
const extra = React.useRef(1);
|
|
4711
4853
|
const contextGroup = useMediaGroupName();
|
|
4712
4854
|
const group = options.group ?? contextGroup;
|
|
4713
4855
|
const read = React.useCallback(() => {
|
|
@@ -4734,8 +4876,9 @@ function useMediaElement(ref, options = {}) {
|
|
|
4734
4876
|
time: Number.isFinite(el.currentTime) ? el.currentTime : 0,
|
|
4735
4877
|
duration: known,
|
|
4736
4878
|
buffered: bufferedAhead(el),
|
|
4737
|
-
volume: el.muted ? 0 : Math.round(el.volume * 100),
|
|
4879
|
+
volume: el.muted ? 0 : Math.round(el.volume * extra.current * 100),
|
|
4738
4880
|
muted: el.muted,
|
|
4881
|
+
maxVolume: maxVolumeOf(opts.current.boost, el),
|
|
4739
4882
|
rate: el.playbackRate,
|
|
4740
4883
|
ended: endedNow,
|
|
4741
4884
|
loading: !error && el.networkState === 2 && el.readyState < 3 && !el.paused,
|
|
@@ -4761,9 +4904,21 @@ function useMediaElement(ref, options = {}) {
|
|
|
4761
4904
|
el.currentTime = w.end;
|
|
4762
4905
|
opts.current.onWindowEnd?.();
|
|
4763
4906
|
}, []);
|
|
4907
|
+
const gain = options.gain ?? 1;
|
|
4908
|
+
React.useEffect(() => {
|
|
4909
|
+
const el = ref.current;
|
|
4910
|
+
if (el) shapeSound(el, gain, extra.current);
|
|
4911
|
+
}, [ref, gain]);
|
|
4912
|
+
React.useEffect(() => {
|
|
4913
|
+
const el = ref.current;
|
|
4914
|
+
return () => {
|
|
4915
|
+
if (el) releaseSound(el);
|
|
4916
|
+
};
|
|
4917
|
+
}, [ref]);
|
|
4764
4918
|
useElementListeners(ref, (el) => {
|
|
4765
4919
|
el.preservesPitch = true;
|
|
4766
4920
|
const on = (e) => {
|
|
4921
|
+
if (e.type === "play") shapeSound(el, opts.current.gain ?? 1, extra.current);
|
|
4767
4922
|
if (e.type === "play" || e.type === "playing") blocked.current = null;
|
|
4768
4923
|
if (e.type === "play") {
|
|
4769
4924
|
windowEnded.current = false;
|
|
@@ -4983,9 +5138,12 @@ function useMediaElement(ref, options = {}) {
|
|
|
4983
5138
|
setVolume: (volume) => {
|
|
4984
5139
|
const el = ref.current;
|
|
4985
5140
|
if (!el) return;
|
|
4986
|
-
const v = Math.min(Math.max(volume, 0),
|
|
5141
|
+
const v = Math.min(Math.max(volume, 0), maxVolumeOf(opts.current.boost, el));
|
|
4987
5142
|
el.muted = v === 0;
|
|
4988
|
-
if (v > 0) el.volume = v / 100;
|
|
5143
|
+
if (v > 0) el.volume = Math.min(v, 100) / 100;
|
|
5144
|
+
extra.current = v > 100 ? v / 100 : 1;
|
|
5145
|
+
shapeSound(el, opts.current.gain ?? 1, extra.current);
|
|
5146
|
+
read();
|
|
4989
5147
|
},
|
|
4990
5148
|
setRate: (rate) => {
|
|
4991
5149
|
const el = ref.current;
|
|
@@ -5096,7 +5254,7 @@ function useCoarsePointer() {
|
|
|
5096
5254
|
* a touch device), with the failure to load shown and retried. For an editor or a replay, use the
|
|
5097
5255
|
* parts and `useMediaElement` directly.
|
|
5098
5256
|
*/
|
|
5099
|
-
function MediaPlayer({ label, kind = "audio", src, sources, index: controlledIndex, onIndexChange, autoAdvance = true, controls = "auto", autoPlay, poster, session, rates, shortcuts = true, attach, growing, window: bound, loop, showFull, group, onTimeUpdate, onWindowEnd, onEnded, onTimeChange, spans, spanKinds, marks, onSpan, spanWords, start, resumeWords, onProgress, progressEvery, mediaRef, heading, overlay, status, warning, aspect, fullscreen = true, skip = {}, fps, float = false, className }) {
|
|
5257
|
+
function MediaPlayer({ label, kind = "audio", src, sources, index: controlledIndex, onIndexChange, autoAdvance = true, controls = "auto", autoPlay, poster, session, rates, shortcuts = true, attach, growing, window: bound, loop, showFull, group, onTimeUpdate, onWindowEnd, onEnded, onTimeChange, spans, spanKinds, marks, onSpan, spanWords, start, resumeWords, onProgress, progressEvery, mediaRef, heading, overlay, status, warning, gain, boost, crossOrigin, aspect, fullscreen = true, skip = {}, fps, float = false, className }) {
|
|
5100
5258
|
const list = React.useMemo(() => sources ?? (src ? [{
|
|
5101
5259
|
src,
|
|
5102
5260
|
title: label
|
|
@@ -5125,7 +5283,9 @@ function MediaPlayer({ label, kind = "audio", src, sources, index: controlledInd
|
|
|
5125
5283
|
onRetry: attach ? (t) => stream.current.reload(t) : void 0,
|
|
5126
5284
|
onProgress: onProgress ? progress : void 0,
|
|
5127
5285
|
progressEvery,
|
|
5128
|
-
progressKey: current?.src
|
|
5286
|
+
progressKey: current?.src,
|
|
5287
|
+
gain,
|
|
5288
|
+
boost
|
|
5129
5289
|
});
|
|
5130
5290
|
React.useEffect(() => void (sourceIndex.current = index), [index]);
|
|
5131
5291
|
stream.current = useAttachedSource(ref, current?.src, attach, media.reportProblem, growing !== void 0, start);
|
|
@@ -5378,7 +5538,8 @@ function MediaPlayer({ label, kind = "audio", src, sources, index: controlledInd
|
|
|
5378
5538
|
if (!el.contains(document.activeElement) || e.ctrlKey || !e.deltaY) return;
|
|
5379
5539
|
e.preventDefault();
|
|
5380
5540
|
const m = latest.current;
|
|
5381
|
-
|
|
5541
|
+
const top = m.volume > 100 ? m.maxVolume : 100;
|
|
5542
|
+
m.setVolume(Math.min(top, Math.max(0, m.volume + (e.deltaY < 0 ? WHEEL_VOLUME_STEP : -5))));
|
|
5382
5543
|
};
|
|
5383
5544
|
el.addEventListener("wheel", onWheel, { passive: false });
|
|
5384
5545
|
return () => el.removeEventListener("wheel", onWheel);
|
|
@@ -5501,6 +5662,7 @@ function MediaPlayer({ label, kind = "audio", src, sources, index: controlledInd
|
|
|
5501
5662
|
controls: native,
|
|
5502
5663
|
autoPlay,
|
|
5503
5664
|
preload: "metadata",
|
|
5665
|
+
crossOrigin,
|
|
5504
5666
|
"aria-label": `${label}, ${kind}`
|
|
5505
5667
|
};
|
|
5506
5668
|
const hasSpans = (spans?.length ?? 0) > 0;
|
|
@@ -5777,7 +5939,8 @@ function MediaPlayer({ label, kind = "audio", src, sources, index: controlledInd
|
|
|
5777
5939
|
}),
|
|
5778
5940
|
/* @__PURE__ */ jsx(VolumeControl, {
|
|
5779
5941
|
volume: media.volume,
|
|
5780
|
-
onVolumeChange: media.setVolume
|
|
5942
|
+
onVolumeChange: media.setVolume,
|
|
5943
|
+
boost: media.maxVolume > 100 ? media.maxVolume : void 0
|
|
5781
5944
|
}),
|
|
5782
5945
|
canFull && /* @__PURE__ */ jsx(IconButton, {
|
|
5783
5946
|
icon: full ? Minimize : Maximize,
|
|
@@ -11803,7 +11966,7 @@ const ViewportFrame = React.forwardRef(function ViewportFrame({ label, aspect, v
|
|
|
11803
11966
|
}),
|
|
11804
11967
|
cover && /* @__PURE__ */ jsx("div", {
|
|
11805
11968
|
className: "absolute inset-0",
|
|
11806
|
-
style: { clipPath: `inset(0 ${100 - cover.shown}% 0 0)` },
|
|
11969
|
+
style: { clipPath: cover.axis === "y" ? `inset(0 0 ${100 - cover.shown}% 0)` : `inset(0 ${100 - cover.shown}% 0 0)` },
|
|
11807
11970
|
children: /* @__PURE__ */ jsx("div", {
|
|
11808
11971
|
className: "absolute inset-0",
|
|
11809
11972
|
style: {
|
|
@@ -15419,10 +15582,116 @@ async function readPixels(src, maxSide = MAX_SIDE) {
|
|
|
15419
15582
|
height
|
|
15420
15583
|
};
|
|
15421
15584
|
}
|
|
15585
|
+
/** Where a pixel's brightness (0–255) is below `threshold`. */
|
|
15586
|
+
function inkOf(p, threshold) {
|
|
15587
|
+
const out = new Uint8Array(p.width * p.height);
|
|
15588
|
+
for (let i = 0, j = 0; j < out.length; i += 4, j++) {
|
|
15589
|
+
const luma = .2126 * p.data[i] + .7152 * p.data[i + 1] + .0722 * p.data[i + 2];
|
|
15590
|
+
out[j] = p.data[i + 3] > 127 && luma < threshold ? 1 : 0;
|
|
15591
|
+
}
|
|
15592
|
+
return out;
|
|
15593
|
+
}
|
|
15594
|
+
/** 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. */
|
|
15595
|
+
function dilate(mask, width, height, r) {
|
|
15596
|
+
if (r <= 0) return mask;
|
|
15597
|
+
const rows = new Uint8Array(mask.length);
|
|
15598
|
+
for (let y = 0; y < height; y++) {
|
|
15599
|
+
let n = 0;
|
|
15600
|
+
const o = y * width;
|
|
15601
|
+
for (let x = 0; x < Math.min(r, width); x++) n += mask[o + x];
|
|
15602
|
+
for (let x = 0; x < width; x++) {
|
|
15603
|
+
if (x + r < width) n += mask[o + x + r];
|
|
15604
|
+
if (x - r - 1 >= 0) n -= mask[o + x - r - 1];
|
|
15605
|
+
rows[o + x] = n > 0 ? 1 : 0;
|
|
15606
|
+
}
|
|
15607
|
+
}
|
|
15608
|
+
const out = new Uint8Array(mask.length);
|
|
15609
|
+
for (let x = 0; x < width; x++) {
|
|
15610
|
+
let n = 0;
|
|
15611
|
+
for (let y = 0; y < Math.min(r, height); y++) n += rows[y * width + x];
|
|
15612
|
+
for (let y = 0; y < height; y++) {
|
|
15613
|
+
if (y + r < height) n += rows[(y + r) * width + x];
|
|
15614
|
+
if (y - r - 1 >= 0) n -= rows[(y - r - 1) * width + x];
|
|
15615
|
+
out[y * width + x] = n > 0 ? 1 : 0;
|
|
15616
|
+
}
|
|
15617
|
+
}
|
|
15618
|
+
return out;
|
|
15619
|
+
}
|
|
15620
|
+
/** Default colours, used where the theme's cannot be read (no canvas): near-black for matched ink, a red and a blue. */
|
|
15621
|
+
const INK_COLOURS = {
|
|
15622
|
+
both: [
|
|
15623
|
+
40,
|
|
15624
|
+
40,
|
|
15625
|
+
40
|
|
15626
|
+
],
|
|
15627
|
+
onlyA: [
|
|
15628
|
+
200,
|
|
15629
|
+
40,
|
|
15630
|
+
40
|
|
15631
|
+
],
|
|
15632
|
+
onlyB: [
|
|
15633
|
+
40,
|
|
15634
|
+
90,
|
|
15635
|
+
210
|
|
15636
|
+
]
|
|
15637
|
+
};
|
|
15638
|
+
/**
|
|
15639
|
+
* 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;
|
|
15640
|
+
* `near` the pixels either way within which the other's ink counts as the same ink.
|
|
15641
|
+
*/
|
|
15642
|
+
function inkMatch(a, b, { threshold = 128, near = 1, colours = INK_COLOURS } = {}) {
|
|
15643
|
+
const { width, height } = a;
|
|
15644
|
+
const other = resample(b, width, height);
|
|
15645
|
+
const ia = inkOf(a, threshold);
|
|
15646
|
+
const ib = inkOf(other, threshold);
|
|
15647
|
+
const nearA = dilate(ia, width, height, near);
|
|
15648
|
+
const nearB = dilate(ib, width, height, near);
|
|
15649
|
+
const marks = new Uint8ClampedArray(width * height * 4);
|
|
15650
|
+
let inkA = 0, matchedA = 0, inkB = 0, matchedB = 0;
|
|
15651
|
+
const put = (j, c) => {
|
|
15652
|
+
marks[j * 4] = c[0];
|
|
15653
|
+
marks[j * 4 + 1] = c[1];
|
|
15654
|
+
marks[j * 4 + 2] = c[2];
|
|
15655
|
+
marks[j * 4 + 3] = 255;
|
|
15656
|
+
};
|
|
15657
|
+
for (let j = 0; j < ia.length; j++) {
|
|
15658
|
+
const hitA = ia[j] === 1 && nearB[j] === 1;
|
|
15659
|
+
const hitB = ib[j] === 1 && nearA[j] === 1;
|
|
15660
|
+
if (ia[j]) {
|
|
15661
|
+
inkA++;
|
|
15662
|
+
if (hitA) matchedA++;
|
|
15663
|
+
}
|
|
15664
|
+
if (ib[j]) {
|
|
15665
|
+
inkB++;
|
|
15666
|
+
if (hitB) matchedB++;
|
|
15667
|
+
}
|
|
15668
|
+
if (hitA || hitB) put(j, colours.both);
|
|
15669
|
+
else if (ia[j]) put(j, colours.onlyA);
|
|
15670
|
+
else if (ib[j]) put(j, colours.onlyB);
|
|
15671
|
+
}
|
|
15672
|
+
let agreement;
|
|
15673
|
+
if (!inkA && !inkB) agreement = 1;
|
|
15674
|
+
else if (!inkA || !inkB) agreement = 0;
|
|
15675
|
+
else {
|
|
15676
|
+
const p = matchedB / inkB;
|
|
15677
|
+
const r = matchedA / inkA;
|
|
15678
|
+
agreement = p + r ? 2 * p * r / (p + r) : 0;
|
|
15679
|
+
}
|
|
15680
|
+
return {
|
|
15681
|
+
marks,
|
|
15682
|
+
width,
|
|
15683
|
+
height,
|
|
15684
|
+
inkA,
|
|
15685
|
+
matchedA,
|
|
15686
|
+
inkB,
|
|
15687
|
+
matchedB,
|
|
15688
|
+
agreement
|
|
15689
|
+
};
|
|
15690
|
+
}
|
|
15422
15691
|
|
|
15423
15692
|
// src/components/difference.tsx
|
|
15424
|
-
/**
|
|
15425
|
-
function
|
|
15693
|
+
/** Both pictures' pixels, read once per pair and only while `enabled`. */
|
|
15694
|
+
function usePixelPair(a, b, enabled, read) {
|
|
15426
15695
|
const [loaded, setLoaded] = React.useState(null);
|
|
15427
15696
|
const key = `${a}|${b}`;
|
|
15428
15697
|
const reader = React.useRef(read);
|
|
@@ -15445,18 +15714,85 @@ function useDifference(a, b, tolerance, enabled, read = readPixels) {
|
|
|
15445
15714
|
key,
|
|
15446
15715
|
enabled
|
|
15447
15716
|
]);
|
|
15717
|
+
if (loaded === "failed") return "failed";
|
|
15718
|
+
return loaded && loaded.key === key ? loaded : null;
|
|
15719
|
+
}
|
|
15720
|
+
/** The pixels that differ between two pictures at a tolerance (0 to 1), read only while `enabled`. */
|
|
15721
|
+
function useDifference(a, b, tolerance, enabled, read = readPixels) {
|
|
15722
|
+
const pair = usePixelPair(a, b, enabled, read);
|
|
15448
15723
|
const deferred = React.useDeferredValue(tolerance);
|
|
15449
|
-
const difference = React.useMemo(() =>
|
|
15450
|
-
|
|
15451
|
-
key,
|
|
15452
|
-
deferred
|
|
15453
|
-
]);
|
|
15454
|
-
if (loaded === "failed") return { status: "failed" };
|
|
15724
|
+
const difference = React.useMemo(() => pair && pair !== "failed" ? differences(pair.a, pair.b, deferred) : null, [pair, deferred]);
|
|
15725
|
+
if (pair === "failed") return { status: "failed" };
|
|
15455
15726
|
return difference ? {
|
|
15456
15727
|
status: "ready",
|
|
15457
15728
|
difference
|
|
15458
15729
|
} : { status: "loading" };
|
|
15459
15730
|
}
|
|
15731
|
+
/** 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). */
|
|
15732
|
+
function roleColour(role, fallback) {
|
|
15733
|
+
if (typeof document === "undefined") return fallback;
|
|
15734
|
+
try {
|
|
15735
|
+
const value = getComputedStyle(document.documentElement).getPropertyValue(role).trim();
|
|
15736
|
+
const ctx = document.createElement("canvas").getContext("2d", { willReadFrequently: true });
|
|
15737
|
+
if (!value || !ctx) return fallback;
|
|
15738
|
+
ctx.fillStyle = value;
|
|
15739
|
+
ctx.fillRect(0, 0, 1, 1);
|
|
15740
|
+
const [r, g, b] = ctx.getImageData(0, 0, 1, 1).data;
|
|
15741
|
+
return [
|
|
15742
|
+
r,
|
|
15743
|
+
g,
|
|
15744
|
+
b
|
|
15745
|
+
];
|
|
15746
|
+
} catch {
|
|
15747
|
+
return fallback;
|
|
15748
|
+
}
|
|
15749
|
+
}
|
|
15750
|
+
/** 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). */
|
|
15751
|
+
function themeInkColours() {
|
|
15752
|
+
return {
|
|
15753
|
+
both: roleColour("--color-foreground", INK_COLOURS.both),
|
|
15754
|
+
onlyA: roleColour("--color-danger", INK_COLOURS.onlyA),
|
|
15755
|
+
onlyB: roleColour("--color-info", INK_COLOURS.onlyB)
|
|
15756
|
+
};
|
|
15757
|
+
}
|
|
15758
|
+
/** 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. */
|
|
15759
|
+
function useThemeChanges(enabled) {
|
|
15760
|
+
const [n, setN] = React.useState(0);
|
|
15761
|
+
React.useEffect(() => {
|
|
15762
|
+
if (!enabled || typeof MutationObserver === "undefined") return;
|
|
15763
|
+
const watch = new MutationObserver(() => setN((x) => x + 1));
|
|
15764
|
+
watch.observe(document.documentElement, {
|
|
15765
|
+
attributes: true,
|
|
15766
|
+
attributeFilter: [
|
|
15767
|
+
"class",
|
|
15768
|
+
"data-palette",
|
|
15769
|
+
"style"
|
|
15770
|
+
]
|
|
15771
|
+
});
|
|
15772
|
+
return () => watch.disconnect();
|
|
15773
|
+
}, [enabled]);
|
|
15774
|
+
return n;
|
|
15775
|
+
}
|
|
15776
|
+
/** Where two pictures' ink agrees, within `near` pixels, read only while `enabled`. */
|
|
15777
|
+
function useInkMatch(a, b, near, enabled, read = readPixels) {
|
|
15778
|
+
const pair = usePixelPair(a, b, enabled, read);
|
|
15779
|
+
const deferred = React.useDeferredValue(near);
|
|
15780
|
+
const theme = useThemeChanges(enabled);
|
|
15781
|
+
const colours = React.useMemo(() => pair && pair !== "failed" ? themeInkColours() : INK_COLOURS, [pair, theme]);
|
|
15782
|
+
const match = React.useMemo(() => pair && pair !== "failed" ? inkMatch(pair.a, pair.b, {
|
|
15783
|
+
near: deferred,
|
|
15784
|
+
colours
|
|
15785
|
+
}) : null, [
|
|
15786
|
+
pair,
|
|
15787
|
+
deferred,
|
|
15788
|
+
colours
|
|
15789
|
+
]);
|
|
15790
|
+
if (pair === "failed") return { status: "failed" };
|
|
15791
|
+
return match ? {
|
|
15792
|
+
status: "ready",
|
|
15793
|
+
match
|
|
15794
|
+
} : { status: "loading" };
|
|
15795
|
+
}
|
|
15460
15796
|
/** The marks of a difference drawn over the picture: a canvas that fits its frame the way the picture does (`object-contain`). */
|
|
15461
15797
|
function DifferenceMarks({ difference }) {
|
|
15462
15798
|
const ref = React.useRef(null);
|
|
@@ -15611,7 +15947,9 @@ const MODE_LABEL$1 = {
|
|
|
15611
15947
|
swipe: "Swipe",
|
|
15612
15948
|
fade: "Fade",
|
|
15613
15949
|
blink: "Blink",
|
|
15614
|
-
difference: "Difference"
|
|
15950
|
+
difference: "Difference",
|
|
15951
|
+
stack: "Above and below",
|
|
15952
|
+
match: "Ink match"
|
|
15615
15953
|
};
|
|
15616
15954
|
const ALL_MODES = [
|
|
15617
15955
|
"side",
|
|
@@ -15620,6 +15958,14 @@ const ALL_MODES = [
|
|
|
15620
15958
|
"blink",
|
|
15621
15959
|
"difference"
|
|
15622
15960
|
];
|
|
15961
|
+
/** The ink match in words: how much agrees, and how much of each side's ink the other lacks. */
|
|
15962
|
+
function inkWords(m, a, b) {
|
|
15963
|
+
if (!m.inkA && !m.inkB) return "Neither has any ink.";
|
|
15964
|
+
if (!m.inkA) return `${a} has no ink; ${b} has.`;
|
|
15965
|
+
if (!m.inkB) return `${b} has no ink; ${a} has.`;
|
|
15966
|
+
const only = (n, of) => n === of ? "none" : format.share((of - n) / of);
|
|
15967
|
+
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)}.`;
|
|
15968
|
+
}
|
|
15623
15969
|
/** Two pictures to judge, side by side or laid over each other, zoomed and panned together, and full screen. */
|
|
15624
15970
|
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 }) {
|
|
15625
15971
|
const { viewport, setViewport } = useViewport();
|
|
@@ -15633,6 +15979,10 @@ function Compare({ label, a, b, blind, missing, mode, onModeChange, modes = ALL_
|
|
|
15633
15979
|
const [style, setStyle] = React.useState(defaultDifference);
|
|
15634
15980
|
const [amplify, setAmplify] = React.useState(4);
|
|
15635
15981
|
const [tolerance, setTolerance] = React.useState(10);
|
|
15982
|
+
const [axis, setAxis] = React.useState("x");
|
|
15983
|
+
const [multiply, setMultiply] = React.useState(false);
|
|
15984
|
+
const [near, setNear] = React.useState(1);
|
|
15985
|
+
const ink = useInkMatch(a.media.src, b.media.src, near, mode === "match", readPixels);
|
|
15636
15986
|
const diff = useDifference(a.media.src, b.media.src, tolerance / 100, mode === "difference" && style === "pixels", readPixels);
|
|
15637
15987
|
const frameRef = React.useRef(null);
|
|
15638
15988
|
const imgRef = React.useRef(null);
|
|
@@ -15697,8 +16047,8 @@ function Compare({ label, a, b, blind, missing, mode, onModeChange, modes = ALL_
|
|
|
15697
16047
|
maxHeight: frameCap(maxHeight, fit, full)
|
|
15698
16048
|
};
|
|
15699
16049
|
let body;
|
|
15700
|
-
if (mode === "side") body = /* @__PURE__ */ jsx("div", {
|
|
15701
|
-
className: "grid gap-3 sm:grid-cols-2",
|
|
16050
|
+
if (mode === "side" || mode === "stack") body = /* @__PURE__ */ jsx("div", {
|
|
16051
|
+
className: cn("grid gap-3", mode === "side" && "sm:grid-cols-2"),
|
|
15702
16052
|
children: [a, b].map((c, i) => /* @__PURE__ */ jsxs("figure", {
|
|
15703
16053
|
className: "grid gap-1.5",
|
|
15704
16054
|
children: [/* @__PURE__ */ jsx(Caption, {
|
|
@@ -15763,6 +16113,47 @@ function Compare({ label, a, b, blind, missing, mode, onModeChange, modes = ALL_
|
|
|
15763
16113
|
] })
|
|
15764
16114
|
})]
|
|
15765
16115
|
});
|
|
16116
|
+
else if (mode === "match") body = /* @__PURE__ */ jsxs("figure", {
|
|
16117
|
+
className: "grid gap-1.5",
|
|
16118
|
+
children: [/* @__PURE__ */ jsxs("div", {
|
|
16119
|
+
className: "flex justify-between gap-4",
|
|
16120
|
+
children: [
|
|
16121
|
+
/* @__PURE__ */ jsx(Caption, {
|
|
16122
|
+
c: a,
|
|
16123
|
+
blind
|
|
16124
|
+
}),
|
|
16125
|
+
/* @__PURE__ */ jsx("span", {
|
|
16126
|
+
className: "type-caption text-muted-foreground",
|
|
16127
|
+
children: "against"
|
|
16128
|
+
}),
|
|
16129
|
+
/* @__PURE__ */ jsx(Caption, {
|
|
16130
|
+
c: b,
|
|
16131
|
+
blind
|
|
16132
|
+
})
|
|
16133
|
+
]
|
|
16134
|
+
}), /* @__PURE__ */ jsxs(ViewportFrame, {
|
|
16135
|
+
...frameProps,
|
|
16136
|
+
ref: frameRef,
|
|
16137
|
+
label: `Ink of ${a.label} matched against ${b.label}`,
|
|
16138
|
+
children: [
|
|
16139
|
+
/* @__PURE__ */ jsx("div", {
|
|
16140
|
+
className: "absolute inset-0 opacity-0",
|
|
16141
|
+
children: pane(a, imgRef, learn)
|
|
16142
|
+
}),
|
|
16143
|
+
/* @__PURE__ */ jsx("div", { className: "absolute inset-0 bg-background" }),
|
|
16144
|
+
ink.status === "ready" && /* @__PURE__ */ jsx(DifferenceMarks, { difference: ink.match }),
|
|
16145
|
+
ink.status === "loading" && /* @__PURE__ */ jsx(Skeleton, {
|
|
16146
|
+
"aria-hidden": true,
|
|
16147
|
+
className: "absolute inset-0 size-full rounded-none opacity-40"
|
|
16148
|
+
}),
|
|
16149
|
+
ink.status === "failed" && /* @__PURE__ */ jsx("p", {
|
|
16150
|
+
role: "alert",
|
|
16151
|
+
className: "absolute inset-x-0 bottom-0 bg-background/90 p-2 type-body-sm text-danger",
|
|
16152
|
+
children: cannotCompare
|
|
16153
|
+
})
|
|
16154
|
+
]
|
|
16155
|
+
})]
|
|
16156
|
+
});
|
|
15766
16157
|
else {
|
|
15767
16158
|
const top = mode === "blink" ? showing === "a" ? a : b : a;
|
|
15768
16159
|
const bottom = b;
|
|
@@ -15785,26 +16176,28 @@ function Compare({ label, a, b, blind, missing, mode, onModeChange, modes = ALL_
|
|
|
15785
16176
|
ref: frameRef,
|
|
15786
16177
|
cover: mode === "swipe" ? {
|
|
15787
16178
|
content: pane(a, imgRef, learn),
|
|
15788
|
-
shown: divider
|
|
16179
|
+
shown: divider,
|
|
16180
|
+
axis
|
|
15789
16181
|
} : void 0,
|
|
15790
|
-
pick: mode === "swipe" ? picker?.split(divider) : mode === "blink" ? picker?.one(showing) : void 0,
|
|
16182
|
+
pick: mode === "swipe" && axis === "x" ? picker?.split(divider) : mode === "blink" ? picker?.one(showing) : void 0,
|
|
15791
16183
|
label: mode === "blink" ? `Picture ${top.label}` : `${a.label} over ${b.label}`,
|
|
15792
16184
|
overlay: mode === "swipe" && /* @__PURE__ */ jsx(Slider$1, {
|
|
15793
16185
|
"aria-label": `Divider between ${a.label} and ${b.label}`,
|
|
15794
|
-
value: divider,
|
|
15795
|
-
onChange: (v) => setDivider(v),
|
|
16186
|
+
value: axis === "y" ? 100 - divider : divider,
|
|
16187
|
+
onChange: (v) => setDivider(axis === "y" ? 100 - v : v),
|
|
15796
16188
|
minValue: 0,
|
|
15797
16189
|
maxValue: 100,
|
|
15798
16190
|
step: 1,
|
|
16191
|
+
orientation: axis === "y" ? "vertical" : "horizontal",
|
|
15799
16192
|
className: "absolute inset-0",
|
|
15800
16193
|
children: /* @__PURE__ */ jsx(SliderTrack, {
|
|
15801
16194
|
className: "pointer-events-none h-full w-full",
|
|
15802
16195
|
children: /* @__PURE__ */ jsxs(SliderThumb, {
|
|
15803
|
-
className: "pointer-events-auto grid
|
|
15804
|
-
style: { top: "50%" },
|
|
16196
|
+
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"),
|
|
16197
|
+
style: axis === "y" ? { left: "50%" } : { top: "50%" },
|
|
15805
16198
|
children: [/* @__PURE__ */ jsx("span", {
|
|
15806
16199
|
"aria-hidden": true,
|
|
15807
|
-
className: "col-start-1 row-start-1 h-full w-1 border-x border-background
|
|
16200
|
+
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")
|
|
15808
16201
|
}), /* @__PURE__ */ jsx("span", {
|
|
15809
16202
|
"aria-hidden": true,
|
|
15810
16203
|
className: "col-start-1 row-start-1 size-6 rounded-pill border-2 border-foreground bg-background"
|
|
@@ -15813,7 +16206,7 @@ function Compare({ label, a, b, blind, missing, mode, onModeChange, modes = ALL_
|
|
|
15813
16206
|
})
|
|
15814
16207
|
}),
|
|
15815
16208
|
children: [pane(bottom), mode !== "swipe" && /* @__PURE__ */ jsx("div", {
|
|
15816
|
-
className: "absolute inset-0",
|
|
16209
|
+
className: cn("absolute inset-0", mode === "fade" && multiply && "mix-blend-multiply"),
|
|
15817
16210
|
style: mode === "fade" ? { opacity: 1 - blend / 100 } : void 0,
|
|
15818
16211
|
children: pane(top, imgRef, learn)
|
|
15819
16212
|
})]
|
|
@@ -15862,6 +16255,38 @@ function Compare({ label, a, b, blind, missing, mode, onModeChange, modes = ALL_
|
|
|
15862
16255
|
className: "type-caption text-muted-foreground",
|
|
15863
16256
|
children: picker.unavailable(MODE_LABEL$1[mode])
|
|
15864
16257
|
}),
|
|
16258
|
+
mode === "swipe" && /* @__PURE__ */ jsx(ToggleGroup, {
|
|
16259
|
+
label: "Swipe direction",
|
|
16260
|
+
options: [{
|
|
16261
|
+
value: "x",
|
|
16262
|
+
label: "Left and right"
|
|
16263
|
+
}, {
|
|
16264
|
+
value: "y",
|
|
16265
|
+
label: "Top and bottom"
|
|
16266
|
+
}],
|
|
16267
|
+
value: axis,
|
|
16268
|
+
onChange: (v) => setAxis(v),
|
|
16269
|
+
size: "sm",
|
|
16270
|
+
className: "justify-self-start"
|
|
16271
|
+
}),
|
|
16272
|
+
picker && mode === "swipe" && axis === "y" && /* @__PURE__ */ jsx("p", {
|
|
16273
|
+
className: "type-caption text-muted-foreground",
|
|
16274
|
+
children: picker.unavailable("Top and bottom")
|
|
16275
|
+
}),
|
|
16276
|
+
mode === "fade" && /* @__PURE__ */ jsx(ToggleGroup, {
|
|
16277
|
+
label: "Blend",
|
|
16278
|
+
options: [{
|
|
16279
|
+
value: "normal",
|
|
16280
|
+
label: "Normal"
|
|
16281
|
+
}, {
|
|
16282
|
+
value: "multiply",
|
|
16283
|
+
label: "Multiply"
|
|
16284
|
+
}],
|
|
16285
|
+
value: multiply ? "multiply" : "normal",
|
|
16286
|
+
onChange: (v) => setMultiply(v === "multiply"),
|
|
16287
|
+
size: "sm",
|
|
16288
|
+
className: "justify-self-start"
|
|
16289
|
+
}),
|
|
15865
16290
|
mode === "fade" && /* @__PURE__ */ jsxs("div", {
|
|
15866
16291
|
className: "flex items-center gap-3",
|
|
15867
16292
|
children: [
|
|
@@ -15949,6 +16374,52 @@ function Compare({ label, a, b, blind, missing, mode, onModeChange, modes = ALL_
|
|
|
15949
16374
|
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…" : ""
|
|
15950
16375
|
})] })]
|
|
15951
16376
|
}),
|
|
16377
|
+
mode === "match" && /* @__PURE__ */ jsxs("div", {
|
|
16378
|
+
className: "grid gap-2",
|
|
16379
|
+
children: [
|
|
16380
|
+
/* @__PURE__ */ jsxs("div", {
|
|
16381
|
+
className: "flex items-center gap-3",
|
|
16382
|
+
children: [
|
|
16383
|
+
/* @__PURE__ */ jsx("span", {
|
|
16384
|
+
className: "type-caption text-muted-foreground",
|
|
16385
|
+
children: "Near"
|
|
16386
|
+
}),
|
|
16387
|
+
/* @__PURE__ */ jsx(Slider, {
|
|
16388
|
+
"aria-label": "Pixels within which ink is the same ink",
|
|
16389
|
+
value: near,
|
|
16390
|
+
onChange: setNear,
|
|
16391
|
+
min: 0,
|
|
16392
|
+
max: 6,
|
|
16393
|
+
hideValue: true,
|
|
16394
|
+
className: "flex-1"
|
|
16395
|
+
}),
|
|
16396
|
+
/* @__PURE__ */ jsxs("span", {
|
|
16397
|
+
className: "w-10 type-caption tabular-nums text-muted-foreground",
|
|
16398
|
+
children: [near, "\xA0px"]
|
|
16399
|
+
})
|
|
16400
|
+
]
|
|
16401
|
+
}),
|
|
16402
|
+
/* @__PURE__ */ jsx("p", {
|
|
16403
|
+
className: "flex flex-wrap gap-x-4 type-caption text-muted-foreground",
|
|
16404
|
+
children: [
|
|
16405
|
+
["bg-foreground", "In both"],
|
|
16406
|
+
["bg-danger", `Only ${a.label}`],
|
|
16407
|
+
["bg-info", `Only ${b.label}`]
|
|
16408
|
+
].map(([swatch, words]) => /* @__PURE__ */ jsxs("span", {
|
|
16409
|
+
className: "inline-flex items-center gap-1.5",
|
|
16410
|
+
children: [/* @__PURE__ */ jsx("span", {
|
|
16411
|
+
"aria-hidden": true,
|
|
16412
|
+
className: cn("inline-block size-2.5 rounded-control", swatch)
|
|
16413
|
+
}), words]
|
|
16414
|
+
}, words))
|
|
16415
|
+
}),
|
|
16416
|
+
/* @__PURE__ */ jsx("p", {
|
|
16417
|
+
role: "status",
|
|
16418
|
+
className: "type-body-sm text-muted-foreground",
|
|
16419
|
+
children: ink.status === "ready" ? inkWords(ink.match, a.label, b.label) : ink.status === "loading" ? "Matching ink…" : ""
|
|
16420
|
+
})
|
|
16421
|
+
]
|
|
16422
|
+
}),
|
|
15952
16423
|
mode === "blink" && /* @__PURE__ */ jsx("div", { children: /* @__PURE__ */ jsx(ToggleGroup, {
|
|
15953
16424
|
label: "Showing",
|
|
15954
16425
|
options: [{
|
|
@@ -21070,5 +21541,5 @@ function FolderPicker({ label, useFolders: useListing, value, onChange, onChoose
|
|
|
21070
21541
|
});
|
|
21071
21542
|
}
|
|
21072
21543
|
|
|
21073
|
-
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 };
|
|
21544
|
+
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 };
|
|
21074
21545
|
//# sourceMappingURL=index.js.map
|