strata-react 1.0.31 → 1.0.33
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 +1 -0
- package/dist/components/compare-parts.d.ts +2 -0
- package/dist/components/compare-video-grid.d.ts +48 -0
- package/dist/components/compare-video.d.ts +2 -5
- package/dist/components/cursor.d.ts +44 -0
- package/dist/components/line-chart.d.ts +92 -3
- package/dist/components/media.d.ts +6 -1
- package/dist/components/video-clock.d.ts +60 -0
- package/dist/{geo-C0jcFp4q.js → cursor-DplHNzj3.js} +173 -3
- package/dist/cursor-DplHNzj3.js.map +1 -0
- package/dist/index.d.ts +3 -1
- package/dist/index.js +1056 -424
- package/dist/index.js.map +1 -1
- package/dist/lib/geo.d.ts +17 -1
- package/dist/map/fan.d.ts +15 -0
- package/dist/map/index.d.ts +3 -1
- package/dist/map/markers.d.ts +60 -0
- package/dist/map/route-map.d.ts +74 -3
- package/dist/map.js +712 -54
- package/dist/map.js.map +1 -1
- package/dist/{run-CKlcLpdN.js → run-BqZGKhW9.js} +10 -1
- package/dist/run-BqZGKhW9.js.map +1 -0
- package/dist/visual-cli.js +1 -1
- package/dist/visual.js +1 -1
- package/package.json +1 -1
- package/dist/geo-C0jcFp4q.js.map +0 -1
- package/dist/run-CKlcLpdN.js.map +0 -1
package/dist/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { _ as cn, a as useColorScheme, c as ChoiceGroup, d as NativeSelect, f as Textarea, g as KeyText, h as Tooltip, i as colorSchemeScript, l as Field, m as controlHeight, n as ColorSchemeChoice, o as useSystemColorScheme, p as useFieldControl, r as ThemeProvider, s as Density, t as COLOR_SCHEME_STORAGE_KEY, u as Input, v as typeSteps } from "./theme-BgTOESmN.js";
|
|
2
|
-
import { a as
|
|
2
|
+
import { a as NBSP, c as toDate, i as MISSING, n as useSharedCursor, o as createFormat, r as geo, s as format, t as CursorScope } from "./cursor-DplHNzj3.js";
|
|
3
3
|
import { _ as IconButton, a as toLoad, c as toast, d as describeActionError, f as describeHttpError, g as Button, h as overlaySurface, i as staleOf, l as toastTimeout, m as readErrorBody, n as createQueryClient, o as useLoad, p as fieldErrorsOf, r as fetchJson, s as StrataToastRegion, t as StrataQueryProvider, u as HttpError, v as RowAction, y as buttonVariants } from "./query-DgJMyXTT.js";
|
|
4
4
|
import * as React from "react";
|
|
5
5
|
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, I18nProvider, Input as Input$1, Keyboard, ListLayout, ListStateContext, Menu as Menu$1, MenuItem, MenuSection, MenuTrigger, Modal, ModalOverlay, NumberField as NumberField$1, Popover as Popover$1, Row, SearchField, Separator, Slider as Slider$1, SliderOutput, SliderThumb, SliderTrack, SubmenuTrigger, Switch as Switch$1, Tab, TabList, TabPanel, Table, TableBody, TableHeader, TableLayout, Tabs as Tabs$1, Text, ToggleButton, ToggleButtonGroup, Toolbar as Toolbar$1, Virtualizer, useDragAndDrop, useFilter } from "react-aria-components";
|
|
@@ -2671,13 +2671,33 @@ function TimeReadout({ time, duration, precision = "seconds", fps = 30, classNam
|
|
|
2671
2671
|
});
|
|
2672
2672
|
}
|
|
2673
2673
|
/** A seek bar: dragged, clicked and moved by keys (arrows `step`, Page keys `bigStep`, Home and End), with its time as the accessible value. */
|
|
2674
|
-
function SeekBar({ time, duration: known, onSeek, marks = [], onMarkPress, buffered, step = 5, bigStep = 30, label = "Seek", precision = "seconds", fps = 30, disabled: off, className }) {
|
|
2674
|
+
function SeekBar({ time, duration: known, onSeek, marks = [], onMarkPress, buffered, step = 5, bigStep = 30, label = "Seek", precision = "seconds", fps = 30, disabled: off, cursor: cursorProp, className }) {
|
|
2675
2675
|
const duration = known && Number.isFinite(known) && known > 0 ? known : 0;
|
|
2676
2676
|
const disabled = off || duration === 0;
|
|
2677
2677
|
const track = React.useRef(null);
|
|
2678
2678
|
const input = React.useRef(null);
|
|
2679
2679
|
const frac = duration > 0 ? clamp$2(time / duration, 0, 1) : 0;
|
|
2680
2680
|
const seekTo = (t) => onSeek(clamp$2(t, 0, duration));
|
|
2681
|
+
const shared = useSharedCursor();
|
|
2682
|
+
const joined = Boolean(cursorProp) && shared !== null;
|
|
2683
|
+
const mapping = typeof cursorProp === "object" ? cursorProp : void 0;
|
|
2684
|
+
const toCursor = mapping?.toCursor ?? ((t) => t);
|
|
2685
|
+
const setPlayback = shared?.setPlayback;
|
|
2686
|
+
const setPointer = shared?.setPointer;
|
|
2687
|
+
const playbackAt = joined && mapping?.playback !== false && duration > 0 ? toCursor(time) : null;
|
|
2688
|
+
React.useEffect(() => {
|
|
2689
|
+
if (!joined) return;
|
|
2690
|
+
setPlayback?.(playbackAt);
|
|
2691
|
+
}, [
|
|
2692
|
+
joined,
|
|
2693
|
+
setPlayback,
|
|
2694
|
+
playbackAt
|
|
2695
|
+
]);
|
|
2696
|
+
React.useEffect(() => () => {
|
|
2697
|
+
setPlayback?.(null);
|
|
2698
|
+
setPointer?.(null);
|
|
2699
|
+
}, [setPlayback, setPointer]);
|
|
2700
|
+
const otherTime = joined && shared.other !== null && duration > 0 ? (mapping?.fromCursor ?? ((c) => c))(shared.other) : null;
|
|
2681
2701
|
const timeText = React.useMemo(() => {
|
|
2682
2702
|
const say = (t) => timecode(t, {
|
|
2683
2703
|
precision,
|
|
@@ -2732,7 +2752,14 @@ function SeekBar({ time, duration: known, onSeek, marks = [], onMarkPress, buffe
|
|
|
2732
2752
|
...groupProps,
|
|
2733
2753
|
className: cn("relative flex h-(--control-h) min-w-0 flex-1 items-center", disabled && "cursor-not-allowed opacity-50", className),
|
|
2734
2754
|
children: /* @__PURE__ */ jsxs("div", {
|
|
2735
|
-
...trackProps,
|
|
2755
|
+
...mergeProps(trackProps, {
|
|
2756
|
+
onPointerMove: (e) => {
|
|
2757
|
+
if (!joined || duration === 0) return;
|
|
2758
|
+
const box = e.currentTarget.getBoundingClientRect();
|
|
2759
|
+
shared.setPointer(toCursor(clamp$2((e.clientX - box.left) / (box.width || 1) * duration, 0, duration)));
|
|
2760
|
+
},
|
|
2761
|
+
onPointerLeave: () => shared?.setPointer(null)
|
|
2762
|
+
}),
|
|
2736
2763
|
ref: track,
|
|
2737
2764
|
className: cn("relative flex h-full w-full cursor-pointer touch-none items-center", disabled && "cursor-not-allowed"),
|
|
2738
2765
|
children: [
|
|
@@ -2750,6 +2777,12 @@ function SeekBar({ time, duration: known, onSeek, marks = [], onMarkPress, buffe
|
|
|
2750
2777
|
className: "absolute left-0 h-1.5 rounded-pill bg-primary",
|
|
2751
2778
|
style: { width: `${frac * 100}%` }
|
|
2752
2779
|
}),
|
|
2780
|
+
otherTime !== null && otherTime >= 0 && otherTime <= duration && /* @__PURE__ */ jsx("span", {
|
|
2781
|
+
"aria-hidden": true,
|
|
2782
|
+
"data-cursor": "",
|
|
2783
|
+
className: "absolute top-1/2 h-4 w-px -translate-y-1/2 bg-foreground/60",
|
|
2784
|
+
style: { left: `${otherTime / duration * 100}%` }
|
|
2785
|
+
}),
|
|
2753
2786
|
duration > 0 && marks.map((m) => /* @__PURE__ */ jsx("button", {
|
|
2754
2787
|
type: "button",
|
|
2755
2788
|
tabIndex: -1,
|
|
@@ -5285,6 +5318,13 @@ function InfiniteList({ state, label, children, skeleton, empty, moreLabel, more
|
|
|
5285
5318
|
});
|
|
5286
5319
|
}
|
|
5287
5320
|
// src/components/line-chart.tsx
|
|
5321
|
+
var TONE_FILL = {
|
|
5322
|
+
neutral: "var(--muted)",
|
|
5323
|
+
info: "var(--info-subtle)",
|
|
5324
|
+
success: "var(--success-subtle)",
|
|
5325
|
+
warning: "var(--warning-subtle)",
|
|
5326
|
+
danger: "var(--danger-subtle)"
|
|
5327
|
+
};
|
|
5288
5328
|
function useWidth$1() {
|
|
5289
5329
|
const ref = React.useRef(null);
|
|
5290
5330
|
const [width, setWidth] = React.useState(0);
|
|
@@ -5352,6 +5392,66 @@ function yScale(values, pin = {}) {
|
|
|
5352
5392
|
].map((i) => min + (max - min) * i / 4)
|
|
5353
5393
|
};
|
|
5354
5394
|
}
|
|
5395
|
+
var linearScale = (values, pin) => {
|
|
5396
|
+
const y = yScale(values, pin);
|
|
5397
|
+
return {
|
|
5398
|
+
...y,
|
|
5399
|
+
at: (v) => (v - y.min) / (y.max - y.min),
|
|
5400
|
+
log: false
|
|
5401
|
+
};
|
|
5402
|
+
};
|
|
5403
|
+
/** The 1, 2, 5 × 10ⁿ values in `[lo, hi]`. */
|
|
5404
|
+
function decadeTicks(lo, hi, mantissas = [
|
|
5405
|
+
1,
|
|
5406
|
+
2,
|
|
5407
|
+
5
|
|
5408
|
+
]) {
|
|
5409
|
+
const out = [];
|
|
5410
|
+
for (let e = Math.floor(Math.log10(lo)) - 1; e <= Math.ceil(Math.log10(hi)) + 1; e++) for (const m of mantissas) out.push(Number((m * 10 ** e).toPrecision(12)));
|
|
5411
|
+
return out;
|
|
5412
|
+
}
|
|
5413
|
+
/**
|
|
5414
|
+
* A logarithmic y axis over the positive values: the ends are the nearest 1, 2, 5 steps outside the
|
|
5415
|
+
* data, the ticks are those steps, thinned to whole decades and then every k-th decade when there are
|
|
5416
|
+
* more than seven. Values at or below zero are ignored (the chart reports them). A pinned end is used as
|
|
5417
|
+
* given when it is positive and does not cut a reading off.
|
|
5418
|
+
*/
|
|
5419
|
+
function logScale(values, pin = {}) {
|
|
5420
|
+
const positive = values.filter((v) => Number.isFinite(v) && v > 0);
|
|
5421
|
+
const dMin = positive.length ? Math.min(...positive) : 1;
|
|
5422
|
+
const dMax = positive.length ? Math.max(...positive) : 10;
|
|
5423
|
+
const grid = decadeTicks(dMin, dMax);
|
|
5424
|
+
const pinMin = pin.min !== void 0 && pin.min > 0 && pin.min <= dMin ? pin.min : void 0;
|
|
5425
|
+
const pinMax = pin.max !== void 0 && pin.max > 0 && pin.max >= dMax ? pin.max : void 0;
|
|
5426
|
+
let min = pinMin ?? Math.max(...grid.filter((t) => t <= dMin * (1 + 1e-9)));
|
|
5427
|
+
let max = pinMax ?? Math.min(...grid.filter((t) => t >= dMax * (1 - 1e-9)));
|
|
5428
|
+
if (!(max > min)) max = min * 10;
|
|
5429
|
+
let ticks = decadeTicks(min, max).filter((t) => t >= min * (1 - 1e-9) && t <= max * (1 + 1e-9));
|
|
5430
|
+
if (ticks.length > 7) ticks = decadeTicks(min, max, [1]).filter((t) => t >= min * (1 - 1e-9) && t <= max * (1 + 1e-9));
|
|
5431
|
+
if (ticks.length > 7) {
|
|
5432
|
+
const k = Math.ceil(ticks.length / 6);
|
|
5433
|
+
ticks = ticks.filter((_, i) => i % k === 0);
|
|
5434
|
+
}
|
|
5435
|
+
const span = Math.log10(max) - Math.log10(min);
|
|
5436
|
+
return {
|
|
5437
|
+
min,
|
|
5438
|
+
max,
|
|
5439
|
+
ticks,
|
|
5440
|
+
at: (v) => (Math.log10(v) - Math.log10(min)) / span,
|
|
5441
|
+
log: true
|
|
5442
|
+
};
|
|
5443
|
+
}
|
|
5444
|
+
/** The value of a series at x, read between the two readings either side (flat beyond the ends). Series need not be sorted. */
|
|
5445
|
+
function valueAt(series, x) {
|
|
5446
|
+
const sorted = [...series].sort((p, q) => p.x - q.x);
|
|
5447
|
+
if (!sorted.length) return 0;
|
|
5448
|
+
if (x <= sorted[0].x) return sorted[0].y;
|
|
5449
|
+
for (let i = 1; i < sorted.length; i++) if (x <= sorted[i].x) {
|
|
5450
|
+
const [p0, p1] = [sorted[i - 1], sorted[i]];
|
|
5451
|
+
return p0.y + (p1.y - p0.y) * (x - p0.x) / (p1.x - p0.x || 1);
|
|
5452
|
+
}
|
|
5453
|
+
return sorted[sorted.length - 1].y;
|
|
5454
|
+
}
|
|
5355
5455
|
/** Roughly how wide a 12px caption label is, in px. jsdom cannot measure text, so the chart estimates. */
|
|
5356
5456
|
var labelWidth = (text) => text.length * 7;
|
|
5357
5457
|
/**
|
|
@@ -5368,42 +5468,74 @@ function fitTicks(ticks, scale, widthOf, gap = 12) {
|
|
|
5368
5468
|
return sorted.slice(0, 1);
|
|
5369
5469
|
}
|
|
5370
5470
|
/** One measured series, drawn in real pixels, with the peak and current readings labelled on the chart and every reading in a screen-reader table. Optional plan, threshold band and `colourScale`. */
|
|
5371
|
-
function LineChart({ label, series, seriesLabel, planned, plannedLabel, band, formatX, xLabel = "Time", formatY, xTicks, yMin, yMax, colour = "var(--chart-1)", colourScale, colourScaleLabel, current, end, formatCurrent, readout, onPick, area, height = 280, className }) {
|
|
5471
|
+
function LineChart({ label, series, seriesLabel, planned, plannedLabel, band, formatX, xLabel = "Time", formatY, xTicks, xDomain, xAxis = "labels", yScale: yMode = "linear", yInvert = false, spans, marks, onMarkSelect, renderMarkCard, cursor: cursorProp, yMin, yMax, colour = "var(--chart-1)", colourScale, colourScaleLabel, current, end, formatCurrent, readout, onPick, area, height = 280, className }) {
|
|
5372
5472
|
const [ref, width] = useWidth$1();
|
|
5473
|
+
const shared = useSharedCursor();
|
|
5474
|
+
const joined = Boolean(cursorProp) && shared !== null;
|
|
5475
|
+
const mapping = typeof cursorProp === "object" ? cursorProp : void 0;
|
|
5373
5476
|
const gradientId = `heat-${React.useId().replace(/[^\w-]/g, "")}`;
|
|
5374
5477
|
const all = [...series, ...planned ?? []];
|
|
5375
|
-
const xMin = Math.min(...all.map((p) => p.x));
|
|
5376
|
-
const xMax = Math.max(...all.map((p) => p.x));
|
|
5377
|
-
const
|
|
5478
|
+
const xMin = xDomain ? xDomain[0] : Math.min(...all.map((p) => p.x));
|
|
5479
|
+
const xMax = xDomain ? xDomain[1] : Math.max(...all.map((p) => p.x));
|
|
5480
|
+
const log = yMode === "log";
|
|
5481
|
+
const y = log ? logScale(all.map((p) => p.y), {
|
|
5482
|
+
min: yMin,
|
|
5483
|
+
max: yMax
|
|
5484
|
+
}) : linearScale(all.map((p) => p.y), {
|
|
5378
5485
|
min: yMin,
|
|
5379
5486
|
max: yMax
|
|
5380
5487
|
});
|
|
5488
|
+
const undrawn = log ? series.filter((p) => !(p.y > 0)).length : 0;
|
|
5381
5489
|
const pad = {
|
|
5382
5490
|
top: 16,
|
|
5383
5491
|
right: 16,
|
|
5384
|
-
bottom: 28,
|
|
5492
|
+
bottom: xAxis === "none" ? 8 : 28,
|
|
5385
5493
|
left: 56
|
|
5386
5494
|
};
|
|
5387
5495
|
const w = Math.max(0, width - pad.left - pad.right);
|
|
5388
5496
|
const h = height - pad.top - pad.bottom;
|
|
5389
5497
|
const sx = (x) => pad.left + (x - xMin) / (xMax - xMin || 1) * w;
|
|
5390
|
-
const sy = (v) =>
|
|
5498
|
+
const sy = (v) => {
|
|
5499
|
+
const f = y.at(v);
|
|
5500
|
+
return pad.top + (yInvert ? f : 1 - f) * h;
|
|
5501
|
+
};
|
|
5391
5502
|
const xLabelWidth = (t) => labelWidth(formatX(t));
|
|
5392
5503
|
const xLabelAt = (t) => {
|
|
5393
5504
|
const half = xLabelWidth(t) / 2;
|
|
5394
5505
|
return Math.min(Math.max(sx(t), half), Math.max(half, width - half));
|
|
5395
5506
|
};
|
|
5396
|
-
const
|
|
5507
|
+
const tickList = React.useMemo(() => typeof xTicks === "function" ? xTicks({
|
|
5508
|
+
min: xMin,
|
|
5509
|
+
max: xMax
|
|
5510
|
+
}) : xTicks, [
|
|
5397
5511
|
xTicks,
|
|
5512
|
+
xMin,
|
|
5513
|
+
xMax
|
|
5514
|
+
]);
|
|
5515
|
+
const shownXTicks = React.useMemo(() => xAxis === "none" ? [] : fitTicks(tickList, xLabelAt, xLabelWidth), [
|
|
5516
|
+
tickList,
|
|
5398
5517
|
width,
|
|
5399
5518
|
xMin,
|
|
5400
5519
|
xMax,
|
|
5401
|
-
formatX
|
|
5520
|
+
formatX,
|
|
5521
|
+
xAxis
|
|
5402
5522
|
]);
|
|
5403
|
-
const path = (pts) =>
|
|
5523
|
+
const path = (pts) => {
|
|
5524
|
+
let pen = false;
|
|
5525
|
+
return pts.map((p) => {
|
|
5526
|
+
if (log && !(p.y > 0)) {
|
|
5527
|
+
pen = false;
|
|
5528
|
+
return "";
|
|
5529
|
+
}
|
|
5530
|
+
const cmd = `${pen ? "L" : "M"}${sx(p.x).toFixed(1)},${sy(p.y).toFixed(1)}`;
|
|
5531
|
+
pen = true;
|
|
5532
|
+
return cmd;
|
|
5533
|
+
}).join("");
|
|
5534
|
+
};
|
|
5404
5535
|
const last = series[series.length - 1];
|
|
5405
5536
|
const showEnd = (end ?? (current === void 0 ? "now" : "none")) === "now";
|
|
5406
5537
|
const peak = series.reduce((a, b) => b.y > a.y ? b : a, series[0]);
|
|
5538
|
+
const peakShown = !log || peak.y > 0;
|
|
5407
5539
|
const stops = colourScale ? [...colourScale].sort((a, b) => a.at - b.at) : [];
|
|
5408
5540
|
/** The colour a value lands on: the highest stop at or below it. Used for the labelled points. */
|
|
5409
5541
|
const colourAt = (y) => stops.length ? [...stops].reverse().find((s) => s.at <= y)?.colour ?? stops[0].colour : colour;
|
|
@@ -5417,19 +5549,29 @@ function LineChart({ label, series, seriesLabel, planned, plannedLabel, band, fo
|
|
|
5417
5549
|
y1: sy(y.min),
|
|
5418
5550
|
y2: sy(y.max),
|
|
5419
5551
|
children: stops.map((s) => /* @__PURE__ */ jsx("stop", {
|
|
5420
|
-
offset: Math.min(1, Math.max(0,
|
|
5552
|
+
offset: Math.min(1, Math.max(0, s.at > 0 || !log ? y.at(s.at) : 0)),
|
|
5421
5553
|
stopColor: s.colour
|
|
5422
5554
|
}, s.at))
|
|
5423
5555
|
}) }),
|
|
5556
|
+
spans?.map((sp) => {
|
|
5557
|
+
const [a, b] = [Math.max(sx(Math.min(sp.from, sp.to)), pad.left), Math.min(sx(Math.max(sp.from, sp.to)), pad.left + w)];
|
|
5558
|
+
return b > a ? /* @__PURE__ */ jsx("rect", {
|
|
5559
|
+
x: a,
|
|
5560
|
+
y: pad.top,
|
|
5561
|
+
width: b - a,
|
|
5562
|
+
height: h,
|
|
5563
|
+
fill: TONE_FILL[sp.tone ?? "neutral"]
|
|
5564
|
+
}, `${sp.from}-${sp.to}-${sp.label}`) : null;
|
|
5565
|
+
}),
|
|
5424
5566
|
band && band.below > y.min && /* @__PURE__ */ jsxs("g", { children: [/* @__PURE__ */ jsx("rect", {
|
|
5425
5567
|
x: pad.left,
|
|
5426
|
-
y: sy(Math.min(band.below, y.max)),
|
|
5568
|
+
y: Math.min(sy(y.min), sy(Math.min(band.below, y.max))),
|
|
5427
5569
|
width: w,
|
|
5428
|
-
height: sy(y.min) - sy(Math.min(band.below, y.max)),
|
|
5570
|
+
height: Math.abs(sy(y.min) - sy(Math.min(band.below, y.max))),
|
|
5429
5571
|
fill: "var(--success-subtle)"
|
|
5430
5572
|
}), /* @__PURE__ */ jsx("text", {
|
|
5431
5573
|
x: pad.left + 8,
|
|
5432
|
-
y: sy(Math.min(band.below, y.max)) + 16,
|
|
5574
|
+
y: Math.min(sy(y.min), sy(Math.min(band.below, y.max))) + 16,
|
|
5433
5575
|
className: "fill-success type-caption",
|
|
5434
5576
|
children: band.label
|
|
5435
5577
|
})] }),
|
|
@@ -5476,19 +5618,18 @@ function LineChart({ label, series, seriesLabel, planned, plannedLabel, band, fo
|
|
|
5476
5618
|
strokeLinejoin: "round",
|
|
5477
5619
|
strokeLinecap: "round"
|
|
5478
5620
|
}),
|
|
5479
|
-
/* @__PURE__ */ jsx("circle", {
|
|
5621
|
+
peakShown && /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsx("circle", {
|
|
5480
5622
|
cx: sx(peak.x),
|
|
5481
5623
|
cy: sy(peak.y),
|
|
5482
5624
|
r: 3,
|
|
5483
5625
|
fill: colourAt(peak.y)
|
|
5484
|
-
}),
|
|
5485
|
-
/* @__PURE__ */ jsxs("text", {
|
|
5626
|
+
}), /* @__PURE__ */ jsxs("text", {
|
|
5486
5627
|
x: sx(peak.x) + 8,
|
|
5487
5628
|
y: sy(peak.y) - 8,
|
|
5488
5629
|
className: "fill-foreground type-caption tabular-nums",
|
|
5489
5630
|
children: [formatY(peak.y), " peak"]
|
|
5490
|
-
}),
|
|
5491
|
-
showEnd && /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
5631
|
+
})] }),
|
|
5632
|
+
showEnd && (!log || last.y > 0) && /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
5492
5633
|
/* @__PURE__ */ jsx("line", {
|
|
5493
5634
|
x1: sx(last.x),
|
|
5494
5635
|
x2: sx(last.x),
|
|
@@ -5517,7 +5658,13 @@ function LineChart({ label, series, seriesLabel, planned, plannedLabel, band, fo
|
|
|
5517
5658
|
series,
|
|
5518
5659
|
planned,
|
|
5519
5660
|
band,
|
|
5520
|
-
|
|
5661
|
+
tickList,
|
|
5662
|
+
xMin,
|
|
5663
|
+
xMax,
|
|
5664
|
+
yMode,
|
|
5665
|
+
yInvert,
|
|
5666
|
+
xAxis,
|
|
5667
|
+
spans,
|
|
5521
5668
|
yMin,
|
|
5522
5669
|
yMax,
|
|
5523
5670
|
colour,
|
|
@@ -5527,29 +5674,41 @@ function LineChart({ label, series, seriesLabel, planned, plannedLabel, band, fo
|
|
|
5527
5674
|
area,
|
|
5528
5675
|
showEnd
|
|
5529
5676
|
]);
|
|
5530
|
-
const tableEl = React.useMemo(() => /* @__PURE__ */
|
|
5677
|
+
const tableEl = React.useMemo(() => /* @__PURE__ */ jsxs("div", {
|
|
5531
5678
|
className: "sr-only",
|
|
5532
|
-
children:
|
|
5533
|
-
/* @__PURE__ */
|
|
5534
|
-
|
|
5535
|
-
|
|
5536
|
-
|
|
5537
|
-
|
|
5538
|
-
|
|
5539
|
-
|
|
5540
|
-
|
|
5541
|
-
|
|
5542
|
-
|
|
5679
|
+
children: [
|
|
5680
|
+
/* @__PURE__ */ jsxs("table", { children: [
|
|
5681
|
+
/* @__PURE__ */ jsx("caption", { children: label }),
|
|
5682
|
+
/* @__PURE__ */ jsx("thead", { children: /* @__PURE__ */ jsxs("tr", { children: [/* @__PURE__ */ jsx("th", {
|
|
5683
|
+
scope: "col",
|
|
5684
|
+
children: xLabel
|
|
5685
|
+
}), /* @__PURE__ */ jsx("th", {
|
|
5686
|
+
scope: "col",
|
|
5687
|
+
children: seriesLabel
|
|
5688
|
+
})] }) }),
|
|
5689
|
+
/* @__PURE__ */ jsx("tbody", { children: series.map((p) => /* @__PURE__ */ jsxs("tr", { children: [/* @__PURE__ */ jsx("td", { children: formatX(p.x) }), /* @__PURE__ */ jsx("td", { children: formatY(p.y) })] }, p.x)) })
|
|
5690
|
+
] }),
|
|
5691
|
+
spans && spans.length > 0 && /* @__PURE__ */ jsx("ul", {
|
|
5692
|
+
"aria-label": "Shaded stretches",
|
|
5693
|
+
children: spans.map((sp) => /* @__PURE__ */ jsx("li", { children: `${sp.label}: ${formatX(sp.from)} to ${formatX(sp.to)}` }, `${sp.from}-${sp.to}-${sp.label}`))
|
|
5694
|
+
}),
|
|
5695
|
+
marks && marks.length > 0 && /* @__PURE__ */ jsx("ul", {
|
|
5696
|
+
"aria-label": "Marks",
|
|
5697
|
+
children: marks.map((m) => /* @__PURE__ */ jsx("li", { children: `${m.label}: ${formatX(m.x)}${m.selected ? ", selected" : ""}` }, `${m.x}-${m.label}`))
|
|
5698
|
+
})
|
|
5699
|
+
]
|
|
5543
5700
|
}), [
|
|
5544
5701
|
label,
|
|
5545
5702
|
seriesLabel,
|
|
5546
5703
|
series,
|
|
5547
5704
|
formatX,
|
|
5548
5705
|
formatY,
|
|
5549
|
-
xLabel
|
|
5706
|
+
xLabel,
|
|
5707
|
+
spans,
|
|
5708
|
+
marks
|
|
5550
5709
|
]);
|
|
5551
5710
|
const sorted = React.useMemo(() => [...series].sort((p, q) => p.x - q.x), [series]);
|
|
5552
|
-
const interactive = Boolean(readout || onPick);
|
|
5711
|
+
const interactive = Boolean(readout || onPick || joined);
|
|
5553
5712
|
const [hover, setHover] = React.useState(null);
|
|
5554
5713
|
const [kbd, setKbd] = React.useState(null);
|
|
5555
5714
|
const [focused, setFocused] = React.useState(false);
|
|
@@ -5578,6 +5737,22 @@ function LineChart({ label, series, seriesLabel, planned, plannedLabel, band, fo
|
|
|
5578
5737
|
const heldIdx = kbd === null ? fallbackIdx : Math.min(kbd, Math.max(sorted.length - 1, 0));
|
|
5579
5738
|
const selectedIdx = hover === null ? heldIdx : Math.min(hover, Math.max(sorted.length - 1, 0));
|
|
5580
5739
|
const active = (hover !== null || focused) && sorted.length ? sorted[selectedIdx] : null;
|
|
5740
|
+
const setPointer = shared?.setPointer;
|
|
5741
|
+
const writeAt = active ? (mapping?.toCursor ?? ((x) => x))(active.x) : null;
|
|
5742
|
+
React.useEffect(() => {
|
|
5743
|
+
if (!joined || !setPointer) return;
|
|
5744
|
+
setPointer(writeAt);
|
|
5745
|
+
}, [
|
|
5746
|
+
joined,
|
|
5747
|
+
setPointer,
|
|
5748
|
+
writeAt
|
|
5749
|
+
]);
|
|
5750
|
+
React.useEffect(() => () => setPointer?.(null), [setPointer]);
|
|
5751
|
+
const otherX = joined && shared.other !== null ? (mapping?.fromCursor ?? ((c) => c))(shared.other) : null;
|
|
5752
|
+
const otherAt = otherX !== null && otherX >= xMin && otherX <= xMax ? {
|
|
5753
|
+
x: otherX,
|
|
5754
|
+
y: yAt(otherX)
|
|
5755
|
+
} : null;
|
|
5581
5756
|
const onKey = (e) => {
|
|
5582
5757
|
const at = selectedIdx;
|
|
5583
5758
|
let next = at;
|
|
@@ -5607,120 +5782,210 @@ function LineChart({ label, series, seriesLabel, planned, plannedLabel, band, fo
|
|
|
5607
5782
|
/* @__PURE__ */ jsxs("div", {
|
|
5608
5783
|
ref,
|
|
5609
5784
|
className: "relative min-w-0",
|
|
5610
|
-
children: [
|
|
5611
|
-
width,
|
|
5612
|
-
|
|
5613
|
-
|
|
5614
|
-
|
|
5615
|
-
|
|
5616
|
-
|
|
5617
|
-
|
|
5618
|
-
|
|
5619
|
-
"
|
|
5620
|
-
|
|
5621
|
-
|
|
5622
|
-
|
|
5623
|
-
|
|
5624
|
-
|
|
5625
|
-
|
|
5626
|
-
|
|
5627
|
-
|
|
5628
|
-
|
|
5629
|
-
|
|
5630
|
-
|
|
5631
|
-
|
|
5632
|
-
|
|
5633
|
-
|
|
5634
|
-
|
|
5635
|
-
|
|
5636
|
-
|
|
5637
|
-
|
|
5638
|
-
|
|
5639
|
-
|
|
5640
|
-
|
|
5641
|
-
|
|
5642
|
-
|
|
5643
|
-
|
|
5644
|
-
|
|
5645
|
-
|
|
5646
|
-
|
|
5647
|
-
|
|
5648
|
-
|
|
5785
|
+
children: [
|
|
5786
|
+
width > 0 && /* @__PURE__ */ jsxs("svg", {
|
|
5787
|
+
width,
|
|
5788
|
+
height,
|
|
5789
|
+
role: "img",
|
|
5790
|
+
"aria-label": label,
|
|
5791
|
+
className: "block overflow-visible",
|
|
5792
|
+
children: [
|
|
5793
|
+
plot,
|
|
5794
|
+
currentAt && /* @__PURE__ */ jsxs("g", {
|
|
5795
|
+
"aria-hidden": true,
|
|
5796
|
+
children: [
|
|
5797
|
+
/* @__PURE__ */ jsx("line", {
|
|
5798
|
+
x1: sx(currentAt.x),
|
|
5799
|
+
x2: sx(currentAt.x),
|
|
5800
|
+
y1: pad.top,
|
|
5801
|
+
y2: pad.top + h,
|
|
5802
|
+
stroke: "var(--primary)",
|
|
5803
|
+
strokeWidth: 1.5
|
|
5804
|
+
}),
|
|
5805
|
+
/* @__PURE__ */ jsx("circle", {
|
|
5806
|
+
cx: sx(currentAt.x),
|
|
5807
|
+
cy: sy(currentAt.y),
|
|
5808
|
+
r: 4,
|
|
5809
|
+
fill: "var(--background)",
|
|
5810
|
+
stroke: "var(--primary)",
|
|
5811
|
+
strokeWidth: 2
|
|
5812
|
+
}),
|
|
5813
|
+
(() => {
|
|
5814
|
+
const text = formatCurrent ? formatCurrent(currentAt) : `${formatX(currentAt.x)}: ${formatY(currentAt.y)}`;
|
|
5815
|
+
const at = flip(sx(currentAt.x), text);
|
|
5816
|
+
return /* @__PURE__ */ jsx("text", {
|
|
5817
|
+
x: at.x,
|
|
5818
|
+
y: pad.top + 12,
|
|
5819
|
+
textAnchor: at.anchor,
|
|
5820
|
+
className: "fill-foreground type-caption tabular-nums",
|
|
5821
|
+
children: text
|
|
5822
|
+
});
|
|
5823
|
+
})()
|
|
5824
|
+
]
|
|
5825
|
+
}),
|
|
5826
|
+
otherAt && (!log || otherAt.y > 0) && /* @__PURE__ */ jsxs("g", {
|
|
5827
|
+
"aria-hidden": true,
|
|
5828
|
+
children: [
|
|
5829
|
+
/* @__PURE__ */ jsx("line", {
|
|
5830
|
+
x1: sx(otherAt.x),
|
|
5831
|
+
x2: sx(otherAt.x),
|
|
5832
|
+
y1: pad.top,
|
|
5833
|
+
y2: pad.top + h,
|
|
5834
|
+
stroke: "var(--muted-foreground)",
|
|
5835
|
+
strokeWidth: 1,
|
|
5836
|
+
strokeDasharray: "2 3"
|
|
5837
|
+
}),
|
|
5838
|
+
/* @__PURE__ */ jsx("circle", {
|
|
5839
|
+
cx: sx(otherAt.x),
|
|
5840
|
+
cy: sy(otherAt.y),
|
|
5841
|
+
r: 4,
|
|
5842
|
+
fill: "var(--background)",
|
|
5843
|
+
stroke: "var(--foreground)",
|
|
5844
|
+
strokeWidth: 2
|
|
5845
|
+
}),
|
|
5846
|
+
(() => {
|
|
5847
|
+
const text = `${formatX(otherAt.x)}: ${formatY(otherAt.y)}`;
|
|
5848
|
+
const at = flip(sx(otherAt.x), text);
|
|
5849
|
+
return /* @__PURE__ */ jsx("text", {
|
|
5850
|
+
x: at.x,
|
|
5851
|
+
y: sy(otherAt.y) - 10,
|
|
5852
|
+
textAnchor: at.anchor,
|
|
5853
|
+
className: "fill-foreground type-caption tabular-nums",
|
|
5854
|
+
paintOrder: "stroke",
|
|
5855
|
+
stroke: "var(--background)",
|
|
5856
|
+
strokeWidth: 3,
|
|
5857
|
+
children: text
|
|
5858
|
+
});
|
|
5859
|
+
})()
|
|
5860
|
+
]
|
|
5861
|
+
}),
|
|
5862
|
+
active && /* @__PURE__ */ jsxs("g", {
|
|
5863
|
+
"aria-hidden": true,
|
|
5864
|
+
children: [
|
|
5865
|
+
/* @__PURE__ */ jsx("line", {
|
|
5866
|
+
x1: sx(active.x),
|
|
5867
|
+
x2: sx(active.x),
|
|
5868
|
+
y1: pad.top,
|
|
5869
|
+
y2: pad.top + h,
|
|
5870
|
+
stroke: "var(--muted-foreground)",
|
|
5871
|
+
strokeWidth: 1,
|
|
5872
|
+
strokeDasharray: "2 3"
|
|
5873
|
+
}),
|
|
5874
|
+
/* @__PURE__ */ jsx("circle", {
|
|
5875
|
+
cx: sx(active.x),
|
|
5876
|
+
cy: sy(active.y),
|
|
5877
|
+
r: 4,
|
|
5878
|
+
fill: "var(--foreground)"
|
|
5879
|
+
}),
|
|
5880
|
+
(() => {
|
|
5881
|
+
const text = readoutText(active);
|
|
5882
|
+
const at = flip(sx(active.x), text);
|
|
5883
|
+
return /* @__PURE__ */ jsx("text", {
|
|
5884
|
+
x: at.x,
|
|
5885
|
+
y: sy(active.y) - 10,
|
|
5886
|
+
textAnchor: at.anchor,
|
|
5887
|
+
className: "fill-foreground type-label tabular-nums",
|
|
5888
|
+
paintOrder: "stroke",
|
|
5889
|
+
stroke: "var(--background)",
|
|
5890
|
+
strokeWidth: 3,
|
|
5891
|
+
children: text
|
|
5892
|
+
});
|
|
5893
|
+
})()
|
|
5894
|
+
]
|
|
5895
|
+
})
|
|
5896
|
+
]
|
|
5897
|
+
}),
|
|
5898
|
+
width > 0 && interactive && sorted.length > 0 && /* @__PURE__ */ jsx(ReadingSlider, {
|
|
5899
|
+
label: `${label}: read values`,
|
|
5900
|
+
sorted,
|
|
5901
|
+
selected: selectedIdx,
|
|
5902
|
+
text: readoutText,
|
|
5903
|
+
onSelect: (i) => {
|
|
5904
|
+
setHover(null);
|
|
5905
|
+
setKbd(i);
|
|
5906
|
+
},
|
|
5907
|
+
onPick,
|
|
5908
|
+
onKeyDownCapture: onKey,
|
|
5909
|
+
onHover: (px) => setHover(px === null ? null : nearest(px)),
|
|
5910
|
+
onFocusChange: setFocused,
|
|
5911
|
+
domain: [xMin, xMax],
|
|
5912
|
+
box: {
|
|
5913
|
+
left: pad.left,
|
|
5914
|
+
top: pad.top,
|
|
5915
|
+
width: w,
|
|
5916
|
+
height: h
|
|
5917
|
+
}
|
|
5918
|
+
}),
|
|
5919
|
+
width > 0 && marks && marks.length > 0 && /* @__PURE__ */ jsx(MarkButtons, {
|
|
5920
|
+
marks: marks.filter((m) => m.x >= xMin && m.x <= xMax && (!log || yAt(m.x) > 0)),
|
|
5921
|
+
place: (m) => ({
|
|
5922
|
+
left: sx(m.x),
|
|
5923
|
+
top: sy(yAt(m.x))
|
|
5649
5924
|
}),
|
|
5650
|
-
|
|
5651
|
-
|
|
5652
|
-
|
|
5653
|
-
|
|
5654
|
-
|
|
5655
|
-
x2: sx(active.x),
|
|
5656
|
-
y1: pad.top,
|
|
5657
|
-
y2: pad.top + h,
|
|
5658
|
-
stroke: "var(--muted-foreground)",
|
|
5659
|
-
strokeWidth: 1,
|
|
5660
|
-
strokeDasharray: "2 3"
|
|
5661
|
-
}),
|
|
5662
|
-
/* @__PURE__ */ jsx("circle", {
|
|
5663
|
-
cx: sx(active.x),
|
|
5664
|
-
cy: sy(active.y),
|
|
5665
|
-
r: 4,
|
|
5666
|
-
fill: "var(--foreground)"
|
|
5667
|
-
}),
|
|
5668
|
-
(() => {
|
|
5669
|
-
const text = readoutText(active);
|
|
5670
|
-
const at = flip(sx(active.x), text);
|
|
5671
|
-
return /* @__PURE__ */ jsx("text", {
|
|
5672
|
-
x: at.x,
|
|
5673
|
-
y: sy(active.y) - 10,
|
|
5674
|
-
textAnchor: at.anchor,
|
|
5675
|
-
className: "fill-foreground type-label tabular-nums",
|
|
5676
|
-
paintOrder: "stroke",
|
|
5677
|
-
stroke: "var(--background)",
|
|
5678
|
-
strokeWidth: 3,
|
|
5679
|
-
children: text
|
|
5680
|
-
});
|
|
5681
|
-
})()
|
|
5682
|
-
]
|
|
5683
|
-
})
|
|
5684
|
-
]
|
|
5685
|
-
}), width > 0 && interactive && sorted.length > 0 && /* @__PURE__ */ jsx(ReadingSlider, {
|
|
5686
|
-
label: `${label}: read values`,
|
|
5687
|
-
sorted,
|
|
5688
|
-
selected: selectedIdx,
|
|
5689
|
-
text: readoutText,
|
|
5690
|
-
onSelect: (i) => {
|
|
5691
|
-
setHover(null);
|
|
5692
|
-
setKbd(i);
|
|
5693
|
-
},
|
|
5694
|
-
onPick,
|
|
5695
|
-
onKeyDownCapture: onKey,
|
|
5696
|
-
onHover: (px) => setHover(px === null ? null : nearest(px)),
|
|
5697
|
-
onFocusChange: setFocused,
|
|
5698
|
-
box: {
|
|
5699
|
-
left: pad.left,
|
|
5700
|
-
top: pad.top,
|
|
5701
|
-
width: w,
|
|
5702
|
-
height: h
|
|
5703
|
-
}
|
|
5704
|
-
})]
|
|
5925
|
+
formatX,
|
|
5926
|
+
onSelect: onMarkSelect,
|
|
5927
|
+
card: renderMarkCard
|
|
5928
|
+
})
|
|
5929
|
+
]
|
|
5705
5930
|
}),
|
|
5706
5931
|
/* @__PURE__ */ jsxs("figcaption", {
|
|
5707
5932
|
className: "flex flex-wrap gap-x-5 gap-y-1 type-caption text-muted-foreground",
|
|
5708
|
-
children: [
|
|
5709
|
-
|
|
5710
|
-
|
|
5711
|
-
|
|
5712
|
-
|
|
5713
|
-
|
|
5933
|
+
children: [
|
|
5934
|
+
/* @__PURE__ */ jsxs("span", {
|
|
5935
|
+
className: "inline-flex items-center gap-2",
|
|
5936
|
+
children: [
|
|
5937
|
+
stops.length ? /* @__PURE__ */ jsx("svg", {
|
|
5938
|
+
width: stops.length * 8,
|
|
5939
|
+
height: "3",
|
|
5940
|
+
"aria-hidden": true,
|
|
5941
|
+
children: stops.map((s, i) => /* @__PURE__ */ jsx("line", {
|
|
5942
|
+
x1: i * 8,
|
|
5943
|
+
x2: i * 8 + 8,
|
|
5944
|
+
y1: "1.5",
|
|
5945
|
+
y2: "1.5",
|
|
5946
|
+
stroke: s.colour,
|
|
5947
|
+
strokeWidth: 3
|
|
5948
|
+
}, s.at))
|
|
5949
|
+
}) : /* @__PURE__ */ jsx("svg", {
|
|
5950
|
+
width: "16",
|
|
5951
|
+
height: "2",
|
|
5952
|
+
"aria-hidden": true,
|
|
5953
|
+
children: /* @__PURE__ */ jsx("line", {
|
|
5954
|
+
x1: "0",
|
|
5955
|
+
x2: "16",
|
|
5956
|
+
y1: "1",
|
|
5957
|
+
y2: "1",
|
|
5958
|
+
stroke: colour,
|
|
5959
|
+
strokeWidth: 2
|
|
5960
|
+
})
|
|
5961
|
+
}),
|
|
5962
|
+
seriesLabel,
|
|
5963
|
+
stops.length > 0 && colourScaleLabel && /* @__PURE__ */ jsxs("span", { children: [
|
|
5964
|
+
"(",
|
|
5965
|
+
colourScaleLabel,
|
|
5966
|
+
")"
|
|
5967
|
+
] })
|
|
5968
|
+
]
|
|
5969
|
+
}),
|
|
5970
|
+
spans?.map((sp) => /* @__PURE__ */ jsxs("span", {
|
|
5971
|
+
className: "inline-flex items-center gap-2",
|
|
5972
|
+
children: [/* @__PURE__ */ jsx("svg", {
|
|
5973
|
+
width: "14",
|
|
5974
|
+
height: "10",
|
|
5714
5975
|
"aria-hidden": true,
|
|
5715
|
-
children:
|
|
5716
|
-
|
|
5717
|
-
|
|
5718
|
-
|
|
5719
|
-
|
|
5720
|
-
stroke:
|
|
5721
|
-
|
|
5722
|
-
|
|
5723
|
-
|
|
5976
|
+
children: /* @__PURE__ */ jsx("rect", {
|
|
5977
|
+
width: "14",
|
|
5978
|
+
height: "10",
|
|
5979
|
+
rx: "2",
|
|
5980
|
+
fill: TONE_FILL[sp.tone ?? "neutral"],
|
|
5981
|
+
stroke: "var(--border)"
|
|
5982
|
+
})
|
|
5983
|
+
}), sp.label]
|
|
5984
|
+
}, `${sp.from}-${sp.to}-${sp.label}`)),
|
|
5985
|
+
undrawn > 0 && /* @__PURE__ */ jsx("span", { children: undrawn === 1 ? "1 reading at or below zero is not drawn" : `${undrawn} readings at or below zero are not drawn` }),
|
|
5986
|
+
planned && plannedLabel && /* @__PURE__ */ jsxs("span", {
|
|
5987
|
+
className: "inline-flex items-center gap-2",
|
|
5988
|
+
children: [/* @__PURE__ */ jsx("svg", {
|
|
5724
5989
|
width: "16",
|
|
5725
5990
|
height: "2",
|
|
5726
5991
|
"aria-hidden": true,
|
|
@@ -5729,45 +5994,71 @@ function LineChart({ label, series, seriesLabel, planned, plannedLabel, band, fo
|
|
|
5729
5994
|
x2: "16",
|
|
5730
5995
|
y1: "1",
|
|
5731
5996
|
y2: "1",
|
|
5732
|
-
stroke:
|
|
5733
|
-
strokeWidth:
|
|
5997
|
+
stroke: "var(--muted-foreground)",
|
|
5998
|
+
strokeWidth: 1.5,
|
|
5999
|
+
strokeDasharray: "4 4"
|
|
5734
6000
|
})
|
|
5735
|
-
}),
|
|
5736
|
-
|
|
5737
|
-
|
|
5738
|
-
"(",
|
|
5739
|
-
colourScaleLabel,
|
|
5740
|
-
")"
|
|
5741
|
-
] })
|
|
5742
|
-
]
|
|
5743
|
-
}), planned && plannedLabel && /* @__PURE__ */ jsxs("span", {
|
|
5744
|
-
className: "inline-flex items-center gap-2",
|
|
5745
|
-
children: [/* @__PURE__ */ jsx("svg", {
|
|
5746
|
-
width: "16",
|
|
5747
|
-
height: "2",
|
|
5748
|
-
"aria-hidden": true,
|
|
5749
|
-
children: /* @__PURE__ */ jsx("line", {
|
|
5750
|
-
x1: "0",
|
|
5751
|
-
x2: "16",
|
|
5752
|
-
y1: "1",
|
|
5753
|
-
y2: "1",
|
|
5754
|
-
stroke: "var(--muted-foreground)",
|
|
5755
|
-
strokeWidth: 1.5,
|
|
5756
|
-
strokeDasharray: "4 4"
|
|
5757
|
-
})
|
|
5758
|
-
}), plannedLabel]
|
|
5759
|
-
})]
|
|
6001
|
+
}), plannedLabel]
|
|
6002
|
+
})
|
|
6003
|
+
]
|
|
5760
6004
|
}),
|
|
5761
6005
|
tableEl
|
|
5762
6006
|
]
|
|
5763
6007
|
});
|
|
5764
6008
|
}
|
|
6009
|
+
/** The marks as controls: one tab stop for the group, arrows, Home and End between them, each named by its label and x. */
|
|
6010
|
+
function MarkButtons({ marks, place, formatX, onSelect, card }) {
|
|
6011
|
+
const [active, setActive] = React.useState(0);
|
|
6012
|
+
const refs = React.useRef([]);
|
|
6013
|
+
const at = Math.min(active, marks.length - 1);
|
|
6014
|
+
const move = (i) => {
|
|
6015
|
+
const next = Math.max(0, Math.min(marks.length - 1, i));
|
|
6016
|
+
setActive(next);
|
|
6017
|
+
refs.current[next]?.focus();
|
|
6018
|
+
};
|
|
6019
|
+
return /* @__PURE__ */ jsx("div", {
|
|
6020
|
+
role: "group",
|
|
6021
|
+
"aria-label": "Marks",
|
|
6022
|
+
onKeyDown: (e) => {
|
|
6023
|
+
if (e.key === "ArrowRight" || e.key === "ArrowDown") move(at + 1);
|
|
6024
|
+
else if (e.key === "ArrowLeft" || e.key === "ArrowUp") move(at - 1);
|
|
6025
|
+
else if (e.key === "Home") move(0);
|
|
6026
|
+
else if (e.key === "End") move(marks.length - 1);
|
|
6027
|
+
else return;
|
|
6028
|
+
e.preventDefault();
|
|
6029
|
+
},
|
|
6030
|
+
children: marks.map((m, i) => {
|
|
6031
|
+
const pos = place(m);
|
|
6032
|
+
const name = `${m.label}, ${formatX(m.x)}`;
|
|
6033
|
+
return /* @__PURE__ */ jsx(Tooltip, {
|
|
6034
|
+
label: card ? card(m) : name,
|
|
6035
|
+
side: "top",
|
|
6036
|
+
children: /* @__PURE__ */ jsx(Button$1, {
|
|
6037
|
+
ref: (el) => {
|
|
6038
|
+
refs.current[i] = el;
|
|
6039
|
+
},
|
|
6040
|
+
"aria-label": name,
|
|
6041
|
+
"aria-pressed": m.selected ?? false,
|
|
6042
|
+
excludeFromTabOrder: i !== at,
|
|
6043
|
+
onFocus: () => setActive(i),
|
|
6044
|
+
onPress: () => onSelect?.(m),
|
|
6045
|
+
className: cn("absolute z-10 -translate-x-1/2 -translate-y-1/2 cursor-pointer rounded-pill border-2 border-background outline-offset-2 transition-state focus-visible:outline-2 focus-visible:outline-ring", m.selected ? "size-4 ring-2 ring-foreground" : "size-3"),
|
|
6046
|
+
style: {
|
|
6047
|
+
left: pos.left,
|
|
6048
|
+
top: pos.top,
|
|
6049
|
+
background: m.colour ?? "var(--foreground)"
|
|
6050
|
+
}
|
|
6051
|
+
})
|
|
6052
|
+
}, `${m.x}-${m.label}`);
|
|
6053
|
+
})
|
|
6054
|
+
});
|
|
6055
|
+
}
|
|
5765
6056
|
/** The slider over the plot: React Aria's hooks, snapped to the readings, with the reading as its spoken value. */
|
|
5766
|
-
function ReadingSlider({ label, sorted, selected, text, onSelect, onPick, onKeyDownCapture, onHover, onFocusChange, box }) {
|
|
6057
|
+
function ReadingSlider({ label, sorted, selected, text, onSelect, onPick, onKeyDownCapture, onHover, onFocusChange, domain, box }) {
|
|
5767
6058
|
const track = React.useRef(null);
|
|
5768
6059
|
const input = React.useRef(null);
|
|
5769
|
-
const lo =
|
|
5770
|
-
const hi = Math.max(
|
|
6060
|
+
const lo = domain[0];
|
|
6061
|
+
const hi = Math.max(domain[1], lo + 1e-9);
|
|
5771
6062
|
const indexAt = (x) => {
|
|
5772
6063
|
let best = 0;
|
|
5773
6064
|
for (let i = 1; i < sorted.length; i++) if (Math.abs(sorted[i].x - x) < Math.abs(sorted[best].x - x)) best = i;
|
|
@@ -5828,6 +6119,44 @@ function ReadingSlider({ label, sorted, selected, text, onSelect, onPick, onKeyD
|
|
|
5828
6119
|
})
|
|
5829
6120
|
});
|
|
5830
6121
|
}
|
|
6122
|
+
/**
|
|
6123
|
+
* Charts stacked on one x axis: one shared range, labels on the last chart only, and one cursor, so
|
|
6124
|
+
* hovering or arrowing in any chart puts a rule and that chart's own reading in all of them (read
|
|
6125
|
+
* together, and announced as one sentence, politely, at most once a second). Inside a `CursorScope`
|
|
6126
|
+
* already, it joins that scope (a map beside the charts moves with them); otherwise it makes its own.
|
|
6127
|
+
*/
|
|
6128
|
+
function LineChartGroup({ label, charts, formatX, xLabel, xTicks, spans, marks, onMarkSelect, renderMarkCard, current, onPick, className }) {
|
|
6129
|
+
const inScope = useSharedCursor() !== null;
|
|
6130
|
+
const xs = charts.flatMap((c) => [...c.series, ...c.planned ?? []].map((p) => p.x));
|
|
6131
|
+
const domain = [Math.min(...xs), Math.max(...xs)];
|
|
6132
|
+
const say = (x) => `${formatX(x)}: ${charts.map((c) => `${c.label ?? c.seriesLabel} ${c.formatY(valueAt(c.series, x))}`).join(", ")}`;
|
|
6133
|
+
const stack = /* @__PURE__ */ jsx("div", {
|
|
6134
|
+
role: "group",
|
|
6135
|
+
"aria-label": label,
|
|
6136
|
+
className: cn("grid min-w-0 gap-1", className),
|
|
6137
|
+
children: charts.map((c, i) => /* @__PURE__ */ jsx(LineChart, {
|
|
6138
|
+
spans,
|
|
6139
|
+
marks,
|
|
6140
|
+
onMarkSelect,
|
|
6141
|
+
renderMarkCard,
|
|
6142
|
+
...c,
|
|
6143
|
+
label: c.label ?? c.seriesLabel,
|
|
6144
|
+
formatX,
|
|
6145
|
+
xLabel,
|
|
6146
|
+
xTicks,
|
|
6147
|
+
xDomain: domain,
|
|
6148
|
+
xAxis: i === charts.length - 1 ? "labels" : "none",
|
|
6149
|
+
current,
|
|
6150
|
+
onPick,
|
|
6151
|
+
cursor: true,
|
|
6152
|
+
readout: true
|
|
6153
|
+
}, c.label ?? c.seriesLabel))
|
|
6154
|
+
});
|
|
6155
|
+
return inScope ? stack : /* @__PURE__ */ jsx(CursorScope, {
|
|
6156
|
+
format: say,
|
|
6157
|
+
children: stack
|
|
6158
|
+
});
|
|
6159
|
+
}
|
|
5831
6160
|
// src/components/page-header.tsx
|
|
5832
6161
|
/** The top of an Operate screen: a noun title, its scope, the main action, and the finding (the one fact in today's data that most needs attention). */
|
|
5833
6162
|
function PageHeader({ title, scope, actions, finding, as: Heading = "h1" }) {
|
|
@@ -6724,6 +7053,21 @@ function FullscreenButton({ full, setFull }) {
|
|
|
6724
7053
|
onPress: () => setFull(!full)
|
|
6725
7054
|
});
|
|
6726
7055
|
}
|
|
7056
|
+
/** The width of an element, kept current: for "is this shown larger than its own pixels". */
|
|
7057
|
+
function useWidth(ref) {
|
|
7058
|
+
const [width, setWidth] = React.useState(0);
|
|
7059
|
+
React.useLayoutEffect(() => {
|
|
7060
|
+
const el = ref.current;
|
|
7061
|
+
if (!el) return;
|
|
7062
|
+
const read = () => setWidth(el.getBoundingClientRect().width);
|
|
7063
|
+
read();
|
|
7064
|
+
if (typeof ResizeObserver === "undefined") return;
|
|
7065
|
+
const ro = new ResizeObserver(read);
|
|
7066
|
+
ro.observe(el);
|
|
7067
|
+
return () => ro.disconnect();
|
|
7068
|
+
});
|
|
7069
|
+
return width;
|
|
7070
|
+
}
|
|
6727
7071
|
// src/lib/image-diff.ts
|
|
6728
7072
|
/** The longest side, in pixels, a picture is compared at. */
|
|
6729
7073
|
var MAX_SIDE = 2048;
|
|
@@ -8065,19 +8409,8 @@ function CompareAudio({ label, a, b, blind, missing, levelMatch = true, align =
|
|
|
8065
8409
|
]
|
|
8066
8410
|
});
|
|
8067
8411
|
}
|
|
8068
|
-
// src/components/
|
|
8069
|
-
|
|
8070
|
-
"side",
|
|
8071
|
-
"swipe",
|
|
8072
|
-
"fade",
|
|
8073
|
-
"blink"
|
|
8074
|
-
];
|
|
8075
|
-
var MODE_LABEL = {
|
|
8076
|
-
side: "Side by side",
|
|
8077
|
-
swipe: "Swipe",
|
|
8078
|
-
fade: "Fade",
|
|
8079
|
-
blink: "Blink"
|
|
8080
|
-
};
|
|
8412
|
+
// src/components/video-clock.tsx
|
|
8413
|
+
/** Speeds offered by default: slow motion for sitting on a moment. */
|
|
8081
8414
|
var SLOW_RATES = [
|
|
8082
8415
|
.1,
|
|
8083
8416
|
.25,
|
|
@@ -8087,73 +8420,140 @@ var SLOW_RATES = [
|
|
|
8087
8420
|
1.5,
|
|
8088
8421
|
2
|
|
8089
8422
|
];
|
|
8090
|
-
|
|
8091
|
-
|
|
8092
|
-
React.
|
|
8093
|
-
|
|
8094
|
-
|
|
8095
|
-
|
|
8096
|
-
|
|
8097
|
-
|
|
8098
|
-
|
|
8099
|
-
|
|
8100
|
-
|
|
8101
|
-
|
|
8102
|
-
return width;
|
|
8103
|
-
}
|
|
8104
|
-
/** Two videos to judge by eye on one clock: side by side, swipe, fade or blink, zoomed together, with matched sound and full screen. */
|
|
8105
|
-
function CompareVideo({ label, a, b, blind, missing, mode, onModeChange, rates = SLOW_RATES, regions, moments = [], loop: loopProp, onLoopChange, audio = "a", pixelated = "zoomed", maxHeight, keys = true, extraShortcuts = [], footer, className }) {
|
|
8106
|
-
const refA = React.useRef(null);
|
|
8107
|
-
const refB = React.useRef(null);
|
|
8108
|
-
const sa = useMediaElement(refA);
|
|
8109
|
-
const sb = useMediaElement(refB);
|
|
8110
|
-
const { viewport, setViewport } = useViewport();
|
|
8111
|
-
const [full, setFull] = React.useState(false);
|
|
8112
|
-
const [divider, setDivider] = React.useState(50);
|
|
8113
|
-
const [blend, setBlend] = React.useState(50);
|
|
8114
|
-
const [showing, setShowing] = React.useState("a");
|
|
8423
|
+
/** Plays, pauses, seeks, steps and loops any number of videos together. */
|
|
8424
|
+
function useVideoClock({ fps, loop: loopProp, onLoopChange, audio }) {
|
|
8425
|
+
const els = React.useRef(/* @__PURE__ */ new Map());
|
|
8426
|
+
const leaderRef = React.useRef(null);
|
|
8427
|
+
const cleanups = React.useRef(/* @__PURE__ */ new Map());
|
|
8428
|
+
const attachers = React.useRef(/* @__PURE__ */ new Map());
|
|
8429
|
+
const hidden = React.useRef(/* @__PURE__ */ new Set());
|
|
8430
|
+
const [infos, setInfos] = React.useState({});
|
|
8431
|
+
const [wanted, setWanted] = React.useState(false);
|
|
8432
|
+
const wantedRef = React.useRef(false);
|
|
8433
|
+
wantedRef.current = wanted;
|
|
8434
|
+
const [started, setStarted] = React.useState(false);
|
|
8115
8435
|
const [volume, setVolume] = React.useState(100);
|
|
8116
8436
|
const [muted, setMuted] = React.useState(false);
|
|
8117
|
-
const [
|
|
8118
|
-
const
|
|
8119
|
-
const
|
|
8120
|
-
const
|
|
8121
|
-
const
|
|
8437
|
+
const [behind, setBehind] = React.useState(/* @__PURE__ */ new Set());
|
|
8438
|
+
const chosenRate = React.useRef(1);
|
|
8439
|
+
const holdRef = React.useRef(false);
|
|
8440
|
+
const lead = useMediaElement(leaderRef);
|
|
8441
|
+
const active = () => [...els.current.entries()].filter(([i]) => i === 0 || !hidden.current.has(i)).sort((a, b) => a[0] - b[0]).map(([, el]) => el);
|
|
8442
|
+
const start = (el) => {
|
|
8443
|
+
el.play().catch((e) => {
|
|
8444
|
+
if (e instanceof DOMException && e.name === "AbortError") return;
|
|
8445
|
+
setWanted(false);
|
|
8446
|
+
});
|
|
8447
|
+
};
|
|
8448
|
+
const pauseAll = () => {
|
|
8449
|
+
for (const el of els.current.values()) el.pause();
|
|
8450
|
+
};
|
|
8451
|
+
const [ownLoop, setOwnLoop] = React.useState({
|
|
8452
|
+
start: null,
|
|
8453
|
+
end: null
|
|
8454
|
+
});
|
|
8455
|
+
const loop = loopProp ?? ownLoop;
|
|
8456
|
+
const setLoop = (next) => {
|
|
8457
|
+
setOwnLoop(next);
|
|
8458
|
+
onLoopChange?.(next);
|
|
8459
|
+
};
|
|
8460
|
+
const loopRef = React.useRef(loop);
|
|
8461
|
+
loopRef.current = loop;
|
|
8462
|
+
const onEnded = () => {
|
|
8463
|
+
const { start, end } = loopRef.current;
|
|
8464
|
+
const list = active();
|
|
8465
|
+
if (wantedRef.current && start !== null && end !== null) {
|
|
8466
|
+
for (const el of list) el.currentTime = start;
|
|
8467
|
+
for (const el of list) startRef.current(el);
|
|
8468
|
+
return;
|
|
8469
|
+
}
|
|
8470
|
+
setWanted(false);
|
|
8471
|
+
pauseAll();
|
|
8472
|
+
};
|
|
8473
|
+
const startRef = React.useRef(start);
|
|
8474
|
+
startRef.current = start;
|
|
8475
|
+
const onEndedRef = React.useRef(onEnded);
|
|
8476
|
+
onEndedRef.current = onEnded;
|
|
8477
|
+
const refresh = () => {
|
|
8478
|
+
const first = [...els.current.keys()].sort((a, b) => a - b)[0];
|
|
8479
|
+
leaderRef.current = first === void 0 ? null : els.current.get(first) ?? null;
|
|
8480
|
+
};
|
|
8481
|
+
const attach = (index) => {
|
|
8482
|
+
let fn = attachers.current.get(index);
|
|
8483
|
+
if (fn) return fn;
|
|
8484
|
+
fn = (el) => {
|
|
8485
|
+
if (els.current.get(index) === el || !el && !els.current.has(index)) return;
|
|
8486
|
+
cleanups.current.get(index)?.();
|
|
8487
|
+
cleanups.current.delete(index);
|
|
8488
|
+
if (!el) {
|
|
8489
|
+
els.current.delete(index);
|
|
8490
|
+
refresh();
|
|
8491
|
+
setInfos((p) => {
|
|
8492
|
+
const { [index]: _gone, ...rest } = p;
|
|
8493
|
+
return rest;
|
|
8494
|
+
});
|
|
8495
|
+
return;
|
|
8496
|
+
}
|
|
8497
|
+
els.current.set(index, el);
|
|
8498
|
+
refresh();
|
|
8499
|
+
const read = () => setInfos((p) => ({
|
|
8500
|
+
...p,
|
|
8501
|
+
[index]: {
|
|
8502
|
+
duration: Number.isFinite(el.duration) && el.duration > 0 ? el.duration : null,
|
|
8503
|
+
error: !!el.error && el.error.code !== 1
|
|
8504
|
+
}
|
|
8505
|
+
}));
|
|
8506
|
+
const ended = () => onEndedRef.current();
|
|
8507
|
+
const types = [
|
|
8508
|
+
"loadedmetadata",
|
|
8509
|
+
"durationchange",
|
|
8510
|
+
"error",
|
|
8511
|
+
"emptied",
|
|
8512
|
+
"loadstart"
|
|
8513
|
+
];
|
|
8514
|
+
for (const t of types) el.addEventListener(t, read);
|
|
8515
|
+
el.addEventListener("ended", ended);
|
|
8516
|
+
cleanups.current.set(index, () => {
|
|
8517
|
+
for (const t of types) el.removeEventListener(t, read);
|
|
8518
|
+
el.removeEventListener("ended", ended);
|
|
8519
|
+
});
|
|
8520
|
+
read();
|
|
8521
|
+
};
|
|
8522
|
+
attachers.current.set(index, fn);
|
|
8523
|
+
return fn;
|
|
8524
|
+
};
|
|
8525
|
+
const known = Object.values(infos).map((i) => i.duration).filter((d) => d !== null);
|
|
8122
8526
|
const duration = known.length ? Math.min(...known) : null;
|
|
8123
|
-
const
|
|
8527
|
+
const count = Object.keys(infos).length;
|
|
8528
|
+
const loaded = count > 0 && known.length === count;
|
|
8529
|
+
const failed = lead.error !== null || Object.values(infos).some((i) => i.error);
|
|
8530
|
+
const now = () => leaderRef.current?.currentTime ?? lead.time;
|
|
8124
8531
|
const play = () => {
|
|
8125
8532
|
setWanted(true);
|
|
8126
|
-
|
|
8127
|
-
|
|
8533
|
+
setStarted(true);
|
|
8534
|
+
for (const el of active()) start(el);
|
|
8128
8535
|
};
|
|
8129
8536
|
const pause = () => {
|
|
8130
8537
|
setWanted(false);
|
|
8131
|
-
|
|
8132
|
-
sb.pause();
|
|
8538
|
+
pauseAll();
|
|
8133
8539
|
};
|
|
8134
8540
|
const toggle = () => wanted ? pause() : play();
|
|
8135
8541
|
const seek = (time) => {
|
|
8136
8542
|
const t = Math.max(0, duration === null ? time : Math.min(time, duration));
|
|
8137
|
-
|
|
8138
|
-
|
|
8543
|
+
lead.seek(t);
|
|
8544
|
+
for (const [i, el] of els.current) if (el !== leaderRef.current && !hidden.current.has(i)) el.currentTime = t;
|
|
8139
8545
|
};
|
|
8140
|
-
const now = () => refA.current?.currentTime ?? sa.time;
|
|
8141
8546
|
const step = (direction) => {
|
|
8142
8547
|
pause();
|
|
8143
|
-
|
|
8144
|
-
seek(Math.max(0, (frame + direction + .5) / fps));
|
|
8548
|
+
seek(Math.max(0, (Math.floor(now() * fps + 1e-6) + direction + .5) / fps));
|
|
8145
8549
|
};
|
|
8146
|
-
const
|
|
8147
|
-
|
|
8148
|
-
|
|
8149
|
-
|
|
8150
|
-
|
|
8151
|
-
|
|
8152
|
-
setOwnLoop(next);
|
|
8153
|
-
onLoopChange?.(next);
|
|
8550
|
+
const setRate = (rate) => {
|
|
8551
|
+
chosenRate.current = rate;
|
|
8552
|
+
for (const el of els.current.values()) {
|
|
8553
|
+
el.defaultPlaybackRate = rate;
|
|
8554
|
+
el.playbackRate = rate;
|
|
8555
|
+
}
|
|
8154
8556
|
};
|
|
8155
|
-
const loopRef = React.useRef(loop);
|
|
8156
|
-
loopRef.current = loop;
|
|
8157
8557
|
const setPoint = (point) => {
|
|
8158
8558
|
const t = now();
|
|
8159
8559
|
const other = point === "start" ? loop.end : loop.start;
|
|
@@ -8169,71 +8569,68 @@ function CompareVideo({ label, a, b, blind, missing, mode, onModeChange, rates =
|
|
|
8169
8569
|
start: null,
|
|
8170
8570
|
end: null
|
|
8171
8571
|
});
|
|
8172
|
-
const
|
|
8173
|
-
|
|
8174
|
-
|
|
8175
|
-
|
|
8176
|
-
|
|
8177
|
-
|
|
8178
|
-
};
|
|
8179
|
-
React.useEffect(() => {
|
|
8180
|
-
if (!(sa.ended || sb.ended)) return;
|
|
8181
|
-
const { start, end } = loopRef.current;
|
|
8182
|
-
const A = refA.current;
|
|
8183
|
-
const B = refB.current;
|
|
8184
|
-
if (wanted && start !== null && end !== null && A && B) {
|
|
8185
|
-
A.currentTime = start;
|
|
8186
|
-
B.currentTime = start;
|
|
8187
|
-
A.play();
|
|
8188
|
-
B.play();
|
|
8572
|
+
const setVisible = (index, visible) => {
|
|
8573
|
+
if (index === 0) return;
|
|
8574
|
+
const el = els.current.get(index);
|
|
8575
|
+
if (!visible) {
|
|
8576
|
+
hidden.current.add(index);
|
|
8577
|
+
el?.pause();
|
|
8189
8578
|
return;
|
|
8190
8579
|
}
|
|
8191
|
-
|
|
8192
|
-
|
|
8193
|
-
|
|
8194
|
-
|
|
8580
|
+
if (!hidden.current.delete(index) || !el) return;
|
|
8581
|
+
el.currentTime = now();
|
|
8582
|
+
el.playbackRate = chosenRate.current;
|
|
8583
|
+
if (wantedRef.current && !holdRef.current) start(el);
|
|
8584
|
+
};
|
|
8195
8585
|
React.useEffect(() => {
|
|
8196
8586
|
if (!wanted) return;
|
|
8197
8587
|
let held = false;
|
|
8198
8588
|
let frame = requestAnimationFrame(function tick() {
|
|
8199
|
-
const
|
|
8200
|
-
const
|
|
8201
|
-
if (
|
|
8202
|
-
if (!(
|
|
8203
|
-
|
|
8204
|
-
|
|
8205
|
-
|
|
8206
|
-
B.pause();
|
|
8207
|
-
}
|
|
8589
|
+
const list = active();
|
|
8590
|
+
const [L, ...followers] = list;
|
|
8591
|
+
if (L && list.every((el) => !el.ended)) {
|
|
8592
|
+
if (!list.every((el) => el.readyState >= 3)) {
|
|
8593
|
+
held = true;
|
|
8594
|
+
holdRef.current = true;
|
|
8595
|
+
for (const el of list) if (!el.paused) el.pause();
|
|
8208
8596
|
} else if (held) {
|
|
8209
8597
|
held = false;
|
|
8210
|
-
|
|
8211
|
-
|
|
8212
|
-
} else if (!
|
|
8598
|
+
holdRef.current = false;
|
|
8599
|
+
for (const el of list) startRef.current(el);
|
|
8600
|
+
} else if (!L.paused) {
|
|
8213
8601
|
const { start, end } = loopRef.current;
|
|
8214
|
-
if (start !== null && end !== null &&
|
|
8215
|
-
|
|
8216
|
-
|
|
8217
|
-
|
|
8218
|
-
|
|
8602
|
+
if (start !== null && end !== null && L.currentTime >= end) for (const el of list) el.currentTime = start;
|
|
8603
|
+
else {
|
|
8604
|
+
const one = 1 / fps;
|
|
8605
|
+
const slow = /* @__PURE__ */ new Set();
|
|
8606
|
+
const indexes = [...els.current.entries()].filter(([, el]) => followers.includes(el)).map(([i]) => i);
|
|
8607
|
+
followers.forEach((el, k) => {
|
|
8608
|
+
const drift = el.currentTime - L.currentTime;
|
|
8609
|
+
if (Math.abs(drift) > .3) el.currentTime = L.currentTime;
|
|
8610
|
+
else if (Math.abs(drift) > one) el.playbackRate = L.playbackRate * (drift > 0 ? .97 : 1.03);
|
|
8611
|
+
else if (Math.abs(drift) < one / 2 && el.playbackRate !== L.playbackRate) el.playbackRate = L.playbackRate;
|
|
8612
|
+
if (Math.abs(drift) > 2 * one) slow.add(indexes[k]);
|
|
8613
|
+
});
|
|
8614
|
+
setBehind((prev) => prev.size === slow.size && [...slow].every((i) => prev.has(i)) ? prev : slow);
|
|
8219
8615
|
}
|
|
8220
|
-
const drift = B.currentTime - A.currentTime;
|
|
8221
|
-
const one = 1 / fps;
|
|
8222
|
-
if (Math.abs(drift) > .3) B.currentTime = A.currentTime;
|
|
8223
|
-
else if (Math.abs(drift) > one) B.playbackRate = A.playbackRate * (drift > 0 ? .97 : 1.03);
|
|
8224
|
-
else if (Math.abs(drift) < one / 2 && B.playbackRate !== A.playbackRate) B.playbackRate = A.playbackRate;
|
|
8225
8616
|
}
|
|
8226
8617
|
}
|
|
8227
8618
|
frame = requestAnimationFrame(tick);
|
|
8228
8619
|
});
|
|
8229
|
-
return () =>
|
|
8620
|
+
return () => {
|
|
8621
|
+
cancelAnimationFrame(frame);
|
|
8622
|
+
holdRef.current = false;
|
|
8623
|
+
};
|
|
8230
8624
|
}, [wanted, fps]);
|
|
8625
|
+
React.useEffect(() => {
|
|
8626
|
+
if (!wanted) setBehind((prev) => prev.size ? /* @__PURE__ */ new Set() : prev);
|
|
8627
|
+
}, [wanted]);
|
|
8231
8628
|
const resume = React.useRef({
|
|
8232
8629
|
time: 0,
|
|
8233
8630
|
playing: false
|
|
8234
8631
|
});
|
|
8235
|
-
if (
|
|
8236
|
-
time:
|
|
8632
|
+
if (lead.duration !== null) resume.current = {
|
|
8633
|
+
time: lead.time,
|
|
8237
8634
|
playing: wanted
|
|
8238
8635
|
};
|
|
8239
8636
|
const restore = (e) => {
|
|
@@ -8241,74 +8638,16 @@ function CompareVideo({ label, a, b, blind, missing, mode, onModeChange, rates =
|
|
|
8241
8638
|
el.defaultPlaybackRate = chosenRate.current;
|
|
8242
8639
|
el.playbackRate = chosenRate.current;
|
|
8243
8640
|
if (resume.current.time > 0) el.currentTime = resume.current.time;
|
|
8244
|
-
|
|
8641
|
+
const index = [...els.current.entries()].find(([, e]) => e === el)?.[0];
|
|
8642
|
+
if (resume.current.playing && (index === void 0 || !hidden.current.has(index))) start(el);
|
|
8245
8643
|
};
|
|
8246
8644
|
React.useEffect(() => {
|
|
8247
|
-
[
|
|
8248
|
-
|
|
8249
|
-
el.muted = audio !== side || muted || volume === 0;
|
|
8645
|
+
for (const [i, el] of els.current) {
|
|
8646
|
+
el.muted = audio !== i || muted || volume === 0;
|
|
8250
8647
|
el.volume = volume / 100;
|
|
8251
|
-
}
|
|
8648
|
+
}
|
|
8252
8649
|
});
|
|
8253
|
-
const
|
|
8254
|
-
const natural = [a.media.width, a.media.height];
|
|
8255
|
-
const frameHeight = frameWidth / aspect;
|
|
8256
|
-
const sharpFor = (c) => {
|
|
8257
|
-
if (rg.active !== null) return true;
|
|
8258
|
-
if (pixelated !== "zoomed") return pixelated === "always";
|
|
8259
|
-
const drawn = Math.min(frameWidth, frameHeight * (c.media.width / c.media.height));
|
|
8260
|
-
return drawn > 0 && viewport.scale * drawn / c.media.width > 1;
|
|
8261
|
-
};
|
|
8262
|
-
const rg = useRegions({
|
|
8263
|
-
regions,
|
|
8264
|
-
viewport,
|
|
8265
|
-
setViewport,
|
|
8266
|
-
frame: frameRef,
|
|
8267
|
-
reset: `${a.media.src}|${b.media.src}`
|
|
8268
|
-
});
|
|
8269
|
-
const zoom = useZoom({
|
|
8270
|
-
viewport,
|
|
8271
|
-
setViewport: rg.setViewport,
|
|
8272
|
-
frame: frameRef,
|
|
8273
|
-
natural
|
|
8274
|
-
});
|
|
8275
|
-
const flip = () => setShowing((s) => s === "a" ? "b" : "a");
|
|
8276
|
-
const video = (c, ref) => /* @__PURE__ */ jsx("video", {
|
|
8277
|
-
ref,
|
|
8278
|
-
src: c.media.src,
|
|
8279
|
-
poster: c.media.poster,
|
|
8280
|
-
preload: "auto",
|
|
8281
|
-
playsInline: true,
|
|
8282
|
-
"aria-label": `Video ${c.label}`,
|
|
8283
|
-
onLoadedMetadata: restore,
|
|
8284
|
-
style: sharpFor(c) ? { imageRendering: "pixelated" } : void 0,
|
|
8285
|
-
className: "absolute inset-0 size-full object-contain"
|
|
8286
|
-
});
|
|
8287
|
-
const skeleton = !failed && (sa.duration === null || sb.duration === null) && /* @__PURE__ */ jsx(Skeleton, {
|
|
8288
|
-
"aria-hidden": true,
|
|
8289
|
-
className: "absolute inset-0 size-full rounded-none"
|
|
8290
|
-
});
|
|
8291
|
-
const frameProps = {
|
|
8292
|
-
viewport,
|
|
8293
|
-
setViewport: rg.setViewport,
|
|
8294
|
-
onBox: wanted ? void 0 : rg.add,
|
|
8295
|
-
outline: rg.peek,
|
|
8296
|
-
aspect,
|
|
8297
|
-
maxHeight: maxHeight === "viewport" ? VIEWPORT_HEIGHT : maxHeight
|
|
8298
|
-
};
|
|
8299
|
-
const shortcuts = [
|
|
8300
|
-
...extraShortcuts,
|
|
8301
|
-
...MODES.map((m, i) => ({
|
|
8302
|
-
keys: [String(i + 1)],
|
|
8303
|
-
label: MODE_LABEL[m],
|
|
8304
|
-
run: () => onModeChange(m)
|
|
8305
|
-
})),
|
|
8306
|
-
{
|
|
8307
|
-
keys: ["x"],
|
|
8308
|
-
label: `Flip ${a.label} and ${b.label}`,
|
|
8309
|
-
run: flip,
|
|
8310
|
-
disabled: mode !== "blink"
|
|
8311
|
-
},
|
|
8650
|
+
const shortcuts = () => [
|
|
8312
8651
|
{
|
|
8313
8652
|
keys: [" ", "k"],
|
|
8314
8653
|
label: "Play or pause",
|
|
@@ -8317,13 +8656,13 @@ function CompareVideo({ label, a, b, blind, missing, mode, onModeChange, rates =
|
|
|
8317
8656
|
{
|
|
8318
8657
|
keys: ["j"],
|
|
8319
8658
|
label: "Back 1 s",
|
|
8320
|
-
run: () => seek(
|
|
8659
|
+
run: () => seek(now() - 1),
|
|
8321
8660
|
repeat: true
|
|
8322
8661
|
},
|
|
8323
8662
|
{
|
|
8324
8663
|
keys: ["l"],
|
|
8325
8664
|
label: "Forward 1 s",
|
|
8326
|
-
run: () => seek(
|
|
8665
|
+
run: () => seek(now() + 1),
|
|
8327
8666
|
repeat: true
|
|
8328
8667
|
},
|
|
8329
8668
|
{
|
|
@@ -8354,15 +8693,46 @@ function CompareVideo({ label, a, b, blind, missing, mode, onModeChange, rates =
|
|
|
8354
8693
|
run: clearLoop,
|
|
8355
8694
|
disabled: loop.start === null && loop.end === null
|
|
8356
8695
|
},
|
|
8357
|
-
...audio ===
|
|
8696
|
+
...audio === null ? [] : [{
|
|
8358
8697
|
keys: ["m"],
|
|
8359
8698
|
label: "Mute",
|
|
8360
8699
|
run: () => setMuted((m) => !m)
|
|
8361
|
-
}]
|
|
8362
|
-
...rg.shortcuts,
|
|
8363
|
-
...zoomShortcuts(zoom, full, setFull)
|
|
8700
|
+
}]
|
|
8364
8701
|
];
|
|
8365
|
-
|
|
8702
|
+
return {
|
|
8703
|
+
attach,
|
|
8704
|
+
restore,
|
|
8705
|
+
wanted,
|
|
8706
|
+
started,
|
|
8707
|
+
play,
|
|
8708
|
+
pause,
|
|
8709
|
+
toggle,
|
|
8710
|
+
seek,
|
|
8711
|
+
step,
|
|
8712
|
+
setRate,
|
|
8713
|
+
time: lead.time,
|
|
8714
|
+
rate: lead.rate,
|
|
8715
|
+
buffered: lead.buffered,
|
|
8716
|
+
duration,
|
|
8717
|
+
loaded,
|
|
8718
|
+
failed,
|
|
8719
|
+
loop,
|
|
8720
|
+
looping: loop.start !== null && loop.end !== null,
|
|
8721
|
+
setPoint,
|
|
8722
|
+
clearLoop,
|
|
8723
|
+
volume,
|
|
8724
|
+
muted,
|
|
8725
|
+
setVolume: (v) => (setMuted(false), setVolume(v)),
|
|
8726
|
+
behind,
|
|
8727
|
+
setVisible,
|
|
8728
|
+
shortcuts,
|
|
8729
|
+
hasAudio: audio !== null,
|
|
8730
|
+
fps
|
|
8731
|
+
};
|
|
8732
|
+
}
|
|
8733
|
+
/** The transport row (play, step, time, seek bar with moments and the loop's ends, speed, volume) and the loop row, for a clock. */
|
|
8734
|
+
function VideoControls({ clock, rates = SLOW_RATES, moments = [] }) {
|
|
8735
|
+
const { loop, fps } = clock;
|
|
8366
8736
|
const at = (t) => t === null ? format.missing : format.timecode(t, {
|
|
8367
8737
|
precision: "frames",
|
|
8368
8738
|
fps
|
|
@@ -8378,10 +8748,331 @@ function CompareVideo({ label, a, b, blind, missing, mode, onModeChange, rates =
|
|
|
8378
8748
|
label: "Loop end"
|
|
8379
8749
|
}] : []
|
|
8380
8750
|
];
|
|
8751
|
+
return /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsxs(Transport, {
|
|
8752
|
+
playing: clock.wanted,
|
|
8753
|
+
onPlayPause: clock.toggle,
|
|
8754
|
+
onStepBack: () => clock.step(-1),
|
|
8755
|
+
onStepForward: () => clock.step(1),
|
|
8756
|
+
children: [
|
|
8757
|
+
/* @__PURE__ */ jsx(TimeReadout, {
|
|
8758
|
+
time: clock.time,
|
|
8759
|
+
duration: clock.duration,
|
|
8760
|
+
precision: "frames",
|
|
8761
|
+
fps
|
|
8762
|
+
}),
|
|
8763
|
+
/* @__PURE__ */ jsx(SeekBar, {
|
|
8764
|
+
time: clock.time,
|
|
8765
|
+
duration: clock.duration,
|
|
8766
|
+
onSeek: clock.seek,
|
|
8767
|
+
marks,
|
|
8768
|
+
onMarkPress: (m) => (clock.pause(), clock.seek(m.time)),
|
|
8769
|
+
buffered: clock.buffered,
|
|
8770
|
+
label: "Position",
|
|
8771
|
+
step: 1,
|
|
8772
|
+
precision: "frames",
|
|
8773
|
+
fps
|
|
8774
|
+
}),
|
|
8775
|
+
/* @__PURE__ */ jsx(RateChoice, {
|
|
8776
|
+
rate: clock.rate,
|
|
8777
|
+
onRateChange: clock.setRate,
|
|
8778
|
+
rates
|
|
8779
|
+
}),
|
|
8780
|
+
clock.hasAudio && /* @__PURE__ */ jsx(VolumeControl, {
|
|
8781
|
+
volume: clock.muted ? 0 : clock.volume,
|
|
8782
|
+
onVolumeChange: clock.setVolume
|
|
8783
|
+
})
|
|
8784
|
+
]
|
|
8785
|
+
}), /* @__PURE__ */ jsxs("div", {
|
|
8786
|
+
className: "flex flex-wrap items-center gap-2",
|
|
8787
|
+
children: [
|
|
8788
|
+
/* @__PURE__ */ jsx(Button, {
|
|
8789
|
+
size: "sm",
|
|
8790
|
+
onPress: () => clock.setPoint("start"),
|
|
8791
|
+
disabled: clock.duration === null,
|
|
8792
|
+
children: "Loop starts here"
|
|
8793
|
+
}),
|
|
8794
|
+
/* @__PURE__ */ jsx(Button, {
|
|
8795
|
+
size: "sm",
|
|
8796
|
+
onPress: () => clock.setPoint("end"),
|
|
8797
|
+
disabled: clock.duration === null,
|
|
8798
|
+
children: "Loop ends here"
|
|
8799
|
+
}),
|
|
8800
|
+
/* @__PURE__ */ jsx(Button, {
|
|
8801
|
+
size: "sm",
|
|
8802
|
+
variant: "ghost",
|
|
8803
|
+
onPress: clock.clearLoop,
|
|
8804
|
+
disabled: loop.start === null && loop.end === null,
|
|
8805
|
+
children: "Clear the loop"
|
|
8806
|
+
}),
|
|
8807
|
+
/* @__PURE__ */ jsx("span", {
|
|
8808
|
+
role: "status",
|
|
8809
|
+
className: "type-caption tabular-nums text-muted-foreground",
|
|
8810
|
+
children: clock.looping ? `Looping ${at(loop.start)} to ${at(loop.end)}` : loop.start !== null ? `Loop starts at ${at(loop.start)}` : loop.end !== null ? `Loop ends at ${at(loop.end)}` : "No loop"
|
|
8811
|
+
})
|
|
8812
|
+
]
|
|
8813
|
+
})] });
|
|
8814
|
+
}
|
|
8815
|
+
// src/components/compare-video-grid.tsx
|
|
8816
|
+
var COLUMNS$1 = {
|
|
8817
|
+
2: "sm:grid-cols-2",
|
|
8818
|
+
3: "sm:grid-cols-2 lg:grid-cols-3",
|
|
8819
|
+
4: "sm:grid-cols-2 lg:grid-cols-4"
|
|
8820
|
+
};
|
|
8821
|
+
function Cell$1({ c, index, clock, blind, isReference, children }) {
|
|
8822
|
+
const view = useInView({
|
|
8823
|
+
rootMargin: "200px",
|
|
8824
|
+
unsupported: true
|
|
8825
|
+
});
|
|
8826
|
+
const { setVisible } = clock;
|
|
8827
|
+
const latest = React.useRef(setVisible);
|
|
8828
|
+
latest.current = setVisible;
|
|
8829
|
+
React.useEffect(() => latest.current(index, view.inView), [index, view.inView]);
|
|
8830
|
+
return /* @__PURE__ */ jsxs("figure", {
|
|
8831
|
+
ref: view.ref,
|
|
8832
|
+
className: "grid content-start gap-1.5",
|
|
8833
|
+
children: [/* @__PURE__ */ jsx(Caption, {
|
|
8834
|
+
c,
|
|
8835
|
+
blind: blind && !isReference
|
|
8836
|
+
}), children(!clock.loaded)]
|
|
8837
|
+
});
|
|
8838
|
+
}
|
|
8839
|
+
/** Many videos in a grid on one clock, zoomed and panned together, with regions, a loop, stepping and full screen. */
|
|
8840
|
+
function CompareVideoGrid({ label, items, reference, blind, missing, catchingUp = "Catching up", actions, columns = 3, regions, rates = SLOW_RATES, moments = [], loop, onLoopChange, audio = null, pixelated = "zoomed", keys = true, extraShortcuts = [], footer, className }) {
|
|
8841
|
+
const cells = reference ? [reference, ...items] : [...items];
|
|
8842
|
+
const first = cells[0];
|
|
8843
|
+
const fps = first?.media.fps ?? 30;
|
|
8844
|
+
const audioIndex = audio === null ? null : cells.findIndex((c) => c.id === audio);
|
|
8845
|
+
const clock = useVideoClock({
|
|
8846
|
+
fps,
|
|
8847
|
+
loop,
|
|
8848
|
+
onLoopChange,
|
|
8849
|
+
audio: audioIndex === null || audioIndex < 0 ? null : audioIndex
|
|
8850
|
+
});
|
|
8851
|
+
const { viewport, setViewport } = useViewport();
|
|
8852
|
+
const [full, setFull] = React.useState(false);
|
|
8853
|
+
const frameRef = React.useRef(null);
|
|
8854
|
+
const frameWidth = useWidth(frameRef);
|
|
8855
|
+
const key = cells.map((c) => c.media.src).join("|");
|
|
8856
|
+
const aspect = first ? first.media.width / first.media.height : 4 / 3;
|
|
8857
|
+
const natural = first ? [first.media.width, first.media.height] : null;
|
|
8858
|
+
const rg = useRegions({
|
|
8859
|
+
regions,
|
|
8860
|
+
viewport,
|
|
8861
|
+
setViewport,
|
|
8862
|
+
frame: frameRef,
|
|
8863
|
+
reset: key
|
|
8864
|
+
});
|
|
8865
|
+
const zoom = useZoom({
|
|
8866
|
+
viewport,
|
|
8867
|
+
setViewport: rg.setViewport,
|
|
8868
|
+
frame: frameRef,
|
|
8869
|
+
natural
|
|
8870
|
+
});
|
|
8871
|
+
const shortcuts = [
|
|
8872
|
+
...extraShortcuts,
|
|
8873
|
+
...clock.shortcuts(),
|
|
8874
|
+
...rg.shortcuts,
|
|
8875
|
+
...zoomShortcuts(zoom, full, setFull)
|
|
8876
|
+
];
|
|
8877
|
+
useHotkeys(shortcuts, { enabled: keys });
|
|
8878
|
+
const frameHeight = frameWidth / aspect;
|
|
8879
|
+
const sharp = (c, isReference) => {
|
|
8880
|
+
if (isReference || rg.active !== null) return true;
|
|
8881
|
+
if (pixelated !== "zoomed") return pixelated === "always";
|
|
8882
|
+
const drawn = Math.min(frameWidth, frameHeight * (c.media.width / c.media.height));
|
|
8883
|
+
return drawn > 0 && viewport.scale * drawn / c.media.width > 1;
|
|
8884
|
+
};
|
|
8885
|
+
return /* @__PURE__ */ jsx(FullscreenFrame, {
|
|
8886
|
+
label,
|
|
8887
|
+
active: full,
|
|
8888
|
+
onActiveChange: setFull,
|
|
8889
|
+
className,
|
|
8890
|
+
children: /* @__PURE__ */ jsxs("section", {
|
|
8891
|
+
"aria-label": label,
|
|
8892
|
+
className: cn("grid gap-3", full && "min-h-0 flex-1 content-start overflow-auto"),
|
|
8893
|
+
children: [
|
|
8894
|
+
/* @__PURE__ */ jsxs(Toolbar, {
|
|
8895
|
+
label: "Zoom",
|
|
8896
|
+
className: "items-center gap-2",
|
|
8897
|
+
children: [
|
|
8898
|
+
/* @__PURE__ */ jsx(ZoomControls, {
|
|
8899
|
+
viewport,
|
|
8900
|
+
zoom,
|
|
8901
|
+
natural
|
|
8902
|
+
}),
|
|
8903
|
+
/* @__PURE__ */ jsx(ToolbarSeparator, {}),
|
|
8904
|
+
/* @__PURE__ */ jsx(FullscreenButton, {
|
|
8905
|
+
full,
|
|
8906
|
+
setFull
|
|
8907
|
+
})
|
|
8908
|
+
]
|
|
8909
|
+
}),
|
|
8910
|
+
/* @__PURE__ */ jsx(RegionChips, { state: rg }),
|
|
8911
|
+
clock.failed && /* @__PURE__ */ jsx("p", {
|
|
8912
|
+
role: "alert",
|
|
8913
|
+
className: "type-body-sm text-danger",
|
|
8914
|
+
children: missing
|
|
8915
|
+
}),
|
|
8916
|
+
/* @__PURE__ */ jsx("div", {
|
|
8917
|
+
className: cn("grid gap-3", COLUMNS$1[columns]),
|
|
8918
|
+
children: cells.map((c, i) => {
|
|
8919
|
+
const isReference = reference !== void 0 && i === 0;
|
|
8920
|
+
return /* @__PURE__ */ jsx(Cell$1, {
|
|
8921
|
+
c,
|
|
8922
|
+
index: i,
|
|
8923
|
+
clock,
|
|
8924
|
+
blind,
|
|
8925
|
+
isReference,
|
|
8926
|
+
children: (loading) => /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
8927
|
+
/* @__PURE__ */ jsxs(ViewportFrame, {
|
|
8928
|
+
viewport,
|
|
8929
|
+
setViewport: rg.setViewport,
|
|
8930
|
+
onBox: clock.wanted ? void 0 : rg.add,
|
|
8931
|
+
outline: rg.peek,
|
|
8932
|
+
aspect,
|
|
8933
|
+
maxHeight: VIEWPORT_HEIGHT,
|
|
8934
|
+
label: `Frame ${c.label}`,
|
|
8935
|
+
ref: i === 0 ? frameRef : void 0,
|
|
8936
|
+
children: [loading && /* @__PURE__ */ jsx(Skeleton, {
|
|
8937
|
+
"aria-hidden": true,
|
|
8938
|
+
className: "absolute inset-0 size-full rounded-none"
|
|
8939
|
+
}), /* @__PURE__ */ jsx("video", {
|
|
8940
|
+
ref: clock.attach(i),
|
|
8941
|
+
src: c.media.src,
|
|
8942
|
+
poster: c.media.poster,
|
|
8943
|
+
preload: clock.started ? "auto" : "metadata",
|
|
8944
|
+
playsInline: true,
|
|
8945
|
+
"aria-label": `Video ${c.label}`,
|
|
8946
|
+
onLoadedMetadata: (e) => {
|
|
8947
|
+
clock.restore(e);
|
|
8948
|
+
const v = e.currentTarget;
|
|
8949
|
+
if (v.currentTime === 0 && v.readyState < 2) v.currentTime = .001;
|
|
8950
|
+
},
|
|
8951
|
+
style: sharp(c, isReference) ? { imageRendering: "pixelated" } : void 0,
|
|
8952
|
+
className: "absolute inset-0 size-full object-contain"
|
|
8953
|
+
})]
|
|
8954
|
+
}),
|
|
8955
|
+
clock.behind.has(i) && /* @__PURE__ */ jsx("p", {
|
|
8956
|
+
role: "status",
|
|
8957
|
+
className: "type-caption text-muted-foreground",
|
|
8958
|
+
children: catchingUp
|
|
8959
|
+
}),
|
|
8960
|
+
actions && !isReference && /* @__PURE__ */ jsx("div", {
|
|
8961
|
+
className: "flex flex-wrap gap-2",
|
|
8962
|
+
children: actions(c)
|
|
8963
|
+
})
|
|
8964
|
+
] })
|
|
8965
|
+
}, c.id);
|
|
8966
|
+
})
|
|
8967
|
+
}),
|
|
8968
|
+
/* @__PURE__ */ jsx(VideoControls, {
|
|
8969
|
+
clock,
|
|
8970
|
+
rates,
|
|
8971
|
+
moments
|
|
8972
|
+
}),
|
|
8973
|
+
footer,
|
|
8974
|
+
keys && /* @__PURE__ */ jsx(KeysLegend, { shortcuts })
|
|
8975
|
+
]
|
|
8976
|
+
})
|
|
8977
|
+
});
|
|
8978
|
+
}
|
|
8979
|
+
// src/components/compare-video.tsx
|
|
8980
|
+
var MODES = [
|
|
8981
|
+
"side",
|
|
8982
|
+
"swipe",
|
|
8983
|
+
"fade",
|
|
8984
|
+
"blink"
|
|
8985
|
+
];
|
|
8986
|
+
var MODE_LABEL = {
|
|
8987
|
+
side: "Side by side",
|
|
8988
|
+
swipe: "Swipe",
|
|
8989
|
+
fade: "Fade",
|
|
8990
|
+
blink: "Blink"
|
|
8991
|
+
};
|
|
8992
|
+
/** Two videos to judge by eye on one clock: side by side, swipe, fade or blink, zoomed together, with matched sound and full screen. */
|
|
8993
|
+
function CompareVideo({ label, a, b, blind, missing, mode, onModeChange, rates = SLOW_RATES, regions, moments = [], loop: loopProp, onLoopChange, audio = "a", pixelated = "zoomed", maxHeight, keys = true, extraShortcuts = [], footer, className }) {
|
|
8994
|
+
const clock = useVideoClock({
|
|
8995
|
+
fps: a.media.fps ?? 30,
|
|
8996
|
+
loop: loopProp,
|
|
8997
|
+
onLoopChange,
|
|
8998
|
+
audio: audio === "none" ? null : audio === "a" ? 0 : 1
|
|
8999
|
+
});
|
|
9000
|
+
const { viewport, setViewport } = useViewport();
|
|
9001
|
+
const [full, setFull] = React.useState(false);
|
|
9002
|
+
const [divider, setDivider] = React.useState(50);
|
|
9003
|
+
const [blend, setBlend] = React.useState(50);
|
|
9004
|
+
const [showing, setShowing] = React.useState("a");
|
|
9005
|
+
const frameRef = React.useRef(null);
|
|
9006
|
+
const frameWidth = useWidth(frameRef);
|
|
9007
|
+
const { wanted, failed } = clock;
|
|
9008
|
+
const aspect = a.media.width / a.media.height;
|
|
9009
|
+
const natural = [a.media.width, a.media.height];
|
|
9010
|
+
const frameHeight = frameWidth / aspect;
|
|
9011
|
+
const sharpFor = (c) => {
|
|
9012
|
+
if (rg.active !== null) return true;
|
|
9013
|
+
if (pixelated !== "zoomed") return pixelated === "always";
|
|
9014
|
+
const drawn = Math.min(frameWidth, frameHeight * (c.media.width / c.media.height));
|
|
9015
|
+
return drawn > 0 && viewport.scale * drawn / c.media.width > 1;
|
|
9016
|
+
};
|
|
9017
|
+
const rg = useRegions({
|
|
9018
|
+
regions,
|
|
9019
|
+
viewport,
|
|
9020
|
+
setViewport,
|
|
9021
|
+
frame: frameRef,
|
|
9022
|
+
reset: `${a.media.src}|${b.media.src}`
|
|
9023
|
+
});
|
|
9024
|
+
const zoom = useZoom({
|
|
9025
|
+
viewport,
|
|
9026
|
+
setViewport: rg.setViewport,
|
|
9027
|
+
frame: frameRef,
|
|
9028
|
+
natural
|
|
9029
|
+
});
|
|
9030
|
+
const flip = () => setShowing((s) => s === "a" ? "b" : "a");
|
|
9031
|
+
const video = (c, index) => /* @__PURE__ */ jsx("video", {
|
|
9032
|
+
ref: clock.attach(index),
|
|
9033
|
+
src: c.media.src,
|
|
9034
|
+
poster: c.media.poster,
|
|
9035
|
+
preload: "auto",
|
|
9036
|
+
playsInline: true,
|
|
9037
|
+
"aria-label": `Video ${c.label}`,
|
|
9038
|
+
onLoadedMetadata: clock.restore,
|
|
9039
|
+
style: sharpFor(c) ? { imageRendering: "pixelated" } : void 0,
|
|
9040
|
+
className: "absolute inset-0 size-full object-contain"
|
|
9041
|
+
});
|
|
9042
|
+
const skeleton = !failed && !clock.loaded && /* @__PURE__ */ jsx(Skeleton, {
|
|
9043
|
+
"aria-hidden": true,
|
|
9044
|
+
className: "absolute inset-0 size-full rounded-none"
|
|
9045
|
+
});
|
|
9046
|
+
const frameProps = {
|
|
9047
|
+
viewport,
|
|
9048
|
+
setViewport: rg.setViewport,
|
|
9049
|
+
onBox: wanted ? void 0 : rg.add,
|
|
9050
|
+
outline: rg.peek,
|
|
9051
|
+
aspect,
|
|
9052
|
+
maxHeight: maxHeight === "viewport" ? VIEWPORT_HEIGHT : maxHeight
|
|
9053
|
+
};
|
|
9054
|
+
const shortcuts = [
|
|
9055
|
+
...extraShortcuts,
|
|
9056
|
+
...MODES.map((m, i) => ({
|
|
9057
|
+
keys: [String(i + 1)],
|
|
9058
|
+
label: MODE_LABEL[m],
|
|
9059
|
+
run: () => onModeChange(m)
|
|
9060
|
+
})),
|
|
9061
|
+
{
|
|
9062
|
+
keys: ["x"],
|
|
9063
|
+
label: `Flip ${a.label} and ${b.label}`,
|
|
9064
|
+
run: flip,
|
|
9065
|
+
disabled: mode !== "blink"
|
|
9066
|
+
},
|
|
9067
|
+
...clock.shortcuts(),
|
|
9068
|
+
...rg.shortcuts,
|
|
9069
|
+
...zoomShortcuts(zoom, full, setFull)
|
|
9070
|
+
];
|
|
9071
|
+
useHotkeys(shortcuts, { enabled: keys });
|
|
8381
9072
|
let body;
|
|
8382
9073
|
if (mode === "side") body = /* @__PURE__ */ jsx("div", {
|
|
8383
9074
|
className: "grid gap-3 sm:grid-cols-2",
|
|
8384
|
-
children: [
|
|
9075
|
+
children: [a, b].map((c, i) => /* @__PURE__ */ jsxs("figure", {
|
|
8385
9076
|
className: "grid gap-1.5",
|
|
8386
9077
|
children: [/* @__PURE__ */ jsx(Caption, {
|
|
8387
9078
|
c,
|
|
@@ -8390,7 +9081,7 @@ function CompareVideo({ label, a, b, blind, missing, mode, onModeChange, rates =
|
|
|
8390
9081
|
...frameProps,
|
|
8391
9082
|
label: `Frame ${c.label}`,
|
|
8392
9083
|
ref: i === 0 ? frameRef : void 0,
|
|
8393
|
-
children: [i === 0 && skeleton, video(c,
|
|
9084
|
+
children: [i === 0 && skeleton, video(c, i)]
|
|
8394
9085
|
})]
|
|
8395
9086
|
}, i))
|
|
8396
9087
|
});
|
|
@@ -8412,7 +9103,7 @@ function CompareVideo({ label, a, b, blind, missing, mode, onModeChange, rates =
|
|
|
8412
9103
|
...frameProps,
|
|
8413
9104
|
ref: frameRef,
|
|
8414
9105
|
cover: mode === "swipe" ? {
|
|
8415
|
-
content: video(a,
|
|
9106
|
+
content: video(a, 0),
|
|
8416
9107
|
shown: divider
|
|
8417
9108
|
} : void 0,
|
|
8418
9109
|
label: mode === "blink" ? `Frame ${(showing === "a" ? a : b).label}` : `${a.label} over ${b.label}`,
|
|
@@ -8441,11 +9132,11 @@ function CompareVideo({ label, a, b, blind, missing, mode, onModeChange, rates =
|
|
|
8441
9132
|
}),
|
|
8442
9133
|
children: [
|
|
8443
9134
|
skeleton,
|
|
8444
|
-
video(b,
|
|
9135
|
+
video(b, 1),
|
|
8445
9136
|
mode !== "swipe" && /* @__PURE__ */ jsx("div", {
|
|
8446
9137
|
className: "absolute inset-0",
|
|
8447
9138
|
style: mode === "fade" ? { opacity: 1 - blend / 100 } : mode === "blink" ? { opacity: showing === "a" ? 1 : 0 } : void 0,
|
|
8448
|
-
children: video(a,
|
|
9139
|
+
children: video(a, 0)
|
|
8449
9140
|
})
|
|
8450
9141
|
]
|
|
8451
9142
|
})]
|
|
@@ -8530,69 +9221,10 @@ function CompareVideo({ label, a, b, blind, missing, mode, onModeChange, rates =
|
|
|
8530
9221
|
children: missing
|
|
8531
9222
|
}),
|
|
8532
9223
|
body,
|
|
8533
|
-
/* @__PURE__ */
|
|
8534
|
-
|
|
8535
|
-
|
|
8536
|
-
|
|
8537
|
-
onStepForward: () => step(1),
|
|
8538
|
-
children: [
|
|
8539
|
-
/* @__PURE__ */ jsx(TimeReadout, {
|
|
8540
|
-
time: sa.time,
|
|
8541
|
-
duration,
|
|
8542
|
-
precision: "frames",
|
|
8543
|
-
fps
|
|
8544
|
-
}),
|
|
8545
|
-
/* @__PURE__ */ jsx(SeekBar, {
|
|
8546
|
-
time: sa.time,
|
|
8547
|
-
duration,
|
|
8548
|
-
onSeek: seek,
|
|
8549
|
-
marks,
|
|
8550
|
-
onMarkPress: (m) => (pause(), seek(m.time)),
|
|
8551
|
-
buffered: sa.buffered,
|
|
8552
|
-
label: "Position",
|
|
8553
|
-
step: 1,
|
|
8554
|
-
precision: "frames",
|
|
8555
|
-
fps
|
|
8556
|
-
}),
|
|
8557
|
-
/* @__PURE__ */ jsx(RateChoice, {
|
|
8558
|
-
rate: sa.rate,
|
|
8559
|
-
onRateChange: setRate,
|
|
8560
|
-
rates
|
|
8561
|
-
}),
|
|
8562
|
-
audio !== "none" && /* @__PURE__ */ jsx(VolumeControl, {
|
|
8563
|
-
volume: muted ? 0 : volume,
|
|
8564
|
-
onVolumeChange: (v) => (setMuted(false), setVolume(v))
|
|
8565
|
-
})
|
|
8566
|
-
]
|
|
8567
|
-
}),
|
|
8568
|
-
/* @__PURE__ */ jsxs("div", {
|
|
8569
|
-
className: "flex flex-wrap items-center gap-2",
|
|
8570
|
-
children: [
|
|
8571
|
-
/* @__PURE__ */ jsx(Button, {
|
|
8572
|
-
size: "sm",
|
|
8573
|
-
onPress: () => setPoint("start"),
|
|
8574
|
-
disabled: duration === null,
|
|
8575
|
-
children: "Loop starts here"
|
|
8576
|
-
}),
|
|
8577
|
-
/* @__PURE__ */ jsx(Button, {
|
|
8578
|
-
size: "sm",
|
|
8579
|
-
onPress: () => setPoint("end"),
|
|
8580
|
-
disabled: duration === null,
|
|
8581
|
-
children: "Loop ends here"
|
|
8582
|
-
}),
|
|
8583
|
-
/* @__PURE__ */ jsx(Button, {
|
|
8584
|
-
size: "sm",
|
|
8585
|
-
variant: "ghost",
|
|
8586
|
-
onPress: clearLoop,
|
|
8587
|
-
disabled: loop.start === null && loop.end === null,
|
|
8588
|
-
children: "Clear the loop"
|
|
8589
|
-
}),
|
|
8590
|
-
/* @__PURE__ */ jsx("span", {
|
|
8591
|
-
role: "status",
|
|
8592
|
-
className: "type-caption tabular-nums text-muted-foreground",
|
|
8593
|
-
children: looping ? `Looping ${at(loop.start)} to ${at(loop.end)}` : loop.start !== null ? `Loop starts at ${at(loop.start)}` : loop.end !== null ? `Loop ends at ${at(loop.end)}` : "No loop"
|
|
8594
|
-
})
|
|
8595
|
-
]
|
|
9224
|
+
/* @__PURE__ */ jsx(VideoControls, {
|
|
9225
|
+
clock,
|
|
9226
|
+
rates,
|
|
9227
|
+
moments
|
|
8596
9228
|
}),
|
|
8597
9229
|
footer,
|
|
8598
9230
|
keys && /* @__PURE__ */ jsx(KeysLegend, { shortcuts })
|
|
@@ -9525,6 +10157,6 @@ function SaveStatus({ state, onRetry, className }) {
|
|
|
9525
10157
|
]
|
|
9526
10158
|
});
|
|
9527
10159
|
}
|
|
9528
|
-
export { ActiveList, Alert, AlertDialog, AppShell, AsyncButton, Breadcrumb, BulkBar, Button, COLOR_SCHEME_STORAGE_KEY, Checkbox, ChoiceGroup, ColorField, ColorSchemeChoice, CommandLegend, CommandMenu, Compare, CompareAudio, CompareGrid, CompareText, CompareVideo, CompositionBar, ContextMenu, DEFAULT_TOLERANCE, DataTable, DataView, Density, Dialog, Disclosure, Done, EmptyState, FIT, Field, FileButton, FileDropZone, FileOutcomes, FullscreenFrame, HttpError, IconButton, InfiniteList, Input, Inspector, InspectorSection, JobStatus, KeysLegend, LineChart, LinkCard, LinkCardList, LoadError, LoadMore, MAX_SCALE, MAX_SIDE, MIN_SCALE, MISSING, MediaPlayer, MediaStage, Menu, Meter, Metric, MetricStrip, MissingFile, NBSP, NativeSelect, NumberField, PageHeader, PairJudge, PairVote, Pane, Popover, PropertyList, PropertyRow, RateChoice, RowAction, SPEECH_RATES, SaveStatus, SeekBar, SelectableGrid, SideNav, Skeleton, Slider, SortableList, Split, StageGuides, StaleNotice, Status, StrataQueryProvider, StrataToastRegion, Switch, TableSkeleton, Tabs, Textarea, ThemeProvider, Thumbnail, ThumbnailSkeleton, TimeReadout, Timeline, TimelineZoomControls, Toggle, ToggleGroup, Toolbar, ToolbarSeparator, Tooltip, Transport, UndoBar, ViewportFrame, VirtualList, VolumeControl, Workspace, actualPixelsScale, boxViewport, buttonVariants, canFullscreen, clampViewport, cn, colorSchemeScript, commandShortcut, createFormat, createQueryClient, crossedThreshold, describeActionError, describeHttpError, detectPlatform, diffWords, differences, fetchJson, fieldErrorsOf, format, formatChord, gainToVolume, geo, isReservedChord, isTypingTarget, labelOf, loudnessOf, matchGains, matchesAccept, matchesChord, measureLoudness, noOverlap, parseChord, parseSort, readErrorBody, readPixels, regionShares, resample, serialiseSort, staleOf, tickLabel, tickStep, ticksBetween, toDate, toLoad, toast, toastTimeout, transportShortcuts, typeSteps, useActiveItem, useAsyncAction, useAutoSave, useClientWork, useColorScheme, useCommands, useDifference, useExpanded, useFileIntake, useHistory, useHistoryState, useHotkeys, useInView, useInfiniteLoad, useJob, useLeaveGuard, useLoad, useMediaElement, useSelection, useSystemColorScheme, useTimelineZoom, useUndoable, useViewport, useWorkspaceState, zoomAt };
|
|
10160
|
+
export { ActiveList, Alert, AlertDialog, AppShell, AsyncButton, Breadcrumb, BulkBar, Button, COLOR_SCHEME_STORAGE_KEY, Checkbox, ChoiceGroup, ColorField, ColorSchemeChoice, CommandLegend, CommandMenu, Compare, CompareAudio, CompareGrid, CompareText, CompareVideo, CompareVideoGrid, CompositionBar, ContextMenu, CursorScope, DEFAULT_TOLERANCE, DataTable, DataView, Density, Dialog, Disclosure, Done, EmptyState, FIT, Field, FileButton, FileDropZone, FileOutcomes, FullscreenFrame, HttpError, IconButton, InfiniteList, Input, Inspector, InspectorSection, JobStatus, KeysLegend, LineChart, LineChartGroup, LinkCard, LinkCardList, LoadError, LoadMore, MAX_SCALE, MAX_SIDE, MIN_SCALE, MISSING, MediaPlayer, MediaStage, Menu, Meter, Metric, MetricStrip, MissingFile, NBSP, NativeSelect, NumberField, PageHeader, PairJudge, PairVote, Pane, Popover, PropertyList, PropertyRow, RateChoice, RowAction, SPEECH_RATES, SaveStatus, SeekBar, SelectableGrid, SideNav, Skeleton, Slider, SortableList, Split, StageGuides, StaleNotice, Status, StrataQueryProvider, StrataToastRegion, Switch, TableSkeleton, Tabs, Textarea, ThemeProvider, Thumbnail, ThumbnailSkeleton, TimeReadout, Timeline, TimelineZoomControls, Toggle, ToggleGroup, Toolbar, ToolbarSeparator, Tooltip, Transport, UndoBar, ViewportFrame, VirtualList, VolumeControl, Workspace, actualPixelsScale, boxViewport, buttonVariants, canFullscreen, clampViewport, cn, colorSchemeScript, commandShortcut, createFormat, createQueryClient, crossedThreshold, describeActionError, describeHttpError, detectPlatform, diffWords, differences, fetchJson, fieldErrorsOf, format, formatChord, gainToVolume, geo, isReservedChord, isTypingTarget, labelOf, logScale, loudnessOf, matchGains, matchesAccept, matchesChord, measureLoudness, noOverlap, parseChord, parseSort, readErrorBody, readPixels, regionShares, resample, serialiseSort, staleOf, tickLabel, tickStep, ticksBetween, toDate, toLoad, toast, toastTimeout, transportShortcuts, typeSteps, useActiveItem, useAsyncAction, useAutoSave, useClientWork, useColorScheme, useCommands, useDifference, useExpanded, useFileIntake, useHistory, useHistoryState, useHotkeys, useInView, useInfiniteLoad, useJob, useLeaveGuard, useLoad, useMediaElement, useSelection, useSharedCursor, useSystemColorScheme, useTimelineZoom, useUndoable, useViewport, useWorkspaceState, valueAt, zoomAt };
|
|
9529
10161
|
|
|
9530
10162
|
//# sourceMappingURL=index.js.map
|