strata-react 1.3.25 → 1.3.27
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -0
- package/UPGRADING.md +4 -0
- package/dist/{api-types/cli.d.ts → api-types-cli.d.ts} +1 -0
- package/dist/api-types-cli.js +4 -3
- package/dist/api-types-cli.js.map +1 -1
- package/dist/{api-types/generate.d.ts → api-types.d.ts} +3 -3
- package/dist/api-types.js +3 -1
- package/dist/{button-KGJI6jQr.js → button-CYXjU-fs.js} +8 -5
- package/dist/button-CYXjU-fs.js.map +1 -0
- package/dist/{cursor-DDGBPiTJ.js → cursor-Cwyvgwsw.js} +9 -7
- package/dist/cursor-Cwyvgwsw.js.map +1 -0
- package/dist/{errors-BUvY1Z4d.js → errors-CmuwcWlb.js} +6 -6
- package/dist/{errors-BUvY1Z4d.js.map → errors-CmuwcWlb.js.map} +1 -1
- package/dist/{field-BjeE_FeB.js → field-DBCsFIng.js} +27 -23
- package/dist/field-DBCsFIng.js.map +1 -0
- package/dist/{follow-BTPs49FP.js → follow-CXQsL86O.js} +2 -2
- package/dist/follow-CXQsL86O.js.map +1 -0
- package/dist/{generate-CjTHKJ39.js → generate-BkWhh4k4.js} +8 -6
- package/dist/generate-BkWhh4k4.js.map +1 -0
- package/dist/{lib/geo.d.ts → geo-DfKa9JtK.d.ts} +35 -33
- package/dist/{hls/index.d.ts → hls.d.ts} +13 -12
- package/dist/hls.js +5 -4
- package/dist/hls.js.map +1 -1
- package/dist/index.d.ts +5401 -142
- package/dist/index.js +1072 -227
- package/dist/index.js.map +1 -1
- package/dist/map.d.ts +184 -0
- package/dist/map.js +21 -17
- package/dist/map.js.map +1 -1
- package/dist/media-player-BETa3P7K.d.ts +758 -0
- package/dist/{microphone-Bo3WaXgD.js → microphone-76skMt6i.js} +41 -30
- package/dist/microphone-76skMt6i.js.map +1 -0
- package/dist/microphone-DDOnQHxf.d.ts +237 -0
- package/dist/{migrate/cli.d.ts → migrate-cli.d.ts} +1 -0
- package/dist/migrate-cli.js +8 -6
- package/dist/migrate-cli.js.map +1 -1
- package/dist/panorama.d.ts +102 -0
- package/dist/panorama.js +18 -15
- package/dist/panorama.js.map +1 -1
- package/dist/{run-BT2WKzMz.js → run-D_Ic1jE7.js} +23 -16
- package/dist/run-D_Ic1jE7.js.map +1 -0
- package/dist/scene.d.ts +147 -0
- package/dist/scene.js +15 -13
- package/dist/scene.js.map +1 -1
- package/dist/testing.d.ts +468 -0
- package/dist/testing.js +11 -3
- package/dist/testing.js.map +1 -1
- package/dist/{theme-CxYZkUNk.js → theme-1oOSMj_D.js} +19 -17
- package/dist/theme-1oOSMj_D.js.map +1 -0
- package/dist/{tooltip-DhqrDtyu.js → tooltip-BosfsWYh.js} +9 -6
- package/dist/tooltip-BosfsWYh.js.map +1 -0
- package/dist/types-B3TsF0Ey.d.ts +241 -0
- package/dist/{value-controls-Dm_EYfZW.js → value-controls-5u7sD_wG.js} +22 -17
- package/dist/value-controls-5u7sD_wG.js.map +1 -0
- package/dist/{viewer-input-CHU0Hx4A.js → viewer-input-3Qa-o35k.js} +3 -2
- package/dist/{viewer-input-CHU0Hx4A.js.map → viewer-input-3Qa-o35k.js.map} +1 -1
- package/dist/{visual/cli.d.ts → visual-cli.d.ts} +2 -1
- package/dist/visual-cli.js +5 -4
- package/dist/visual-cli.js.map +1 -1
- package/dist/visual.d.ts +105 -0
- package/dist/visual.js +4 -3
- package/dist/visual.js.map +1 -1
- package/package.json +24 -19
- package/dist/api-types/index.d.ts +0 -1
- package/dist/button-KGJI6jQr.js.map +0 -1
- package/dist/components/active-list.d.ts +0 -46
- package/dist/components/alert.d.ts +0 -17
- package/dist/components/app-shell.d.ts +0 -32
- package/dist/components/async-button.d.ts +0 -48
- package/dist/components/auto-recorder.d.ts +0 -67
- package/dist/components/book-viewer.d.ts +0 -50
- package/dist/components/box-overlay.d.ts +0 -44
- package/dist/components/boxed-picture.d.ts +0 -34
- package/dist/components/button.d.ts +0 -45
- package/dist/components/byte-view.d.ts +0 -32
- package/dist/components/checkbox.d.ts +0 -39
- package/dist/components/choice-grid.d.ts +0 -42
- package/dist/components/commands.d.ts +0 -104
- package/dist/components/compare-audio.d.ts +0 -30
- package/dist/components/compare-grid.d.ts +0 -24
- package/dist/components/compare-parts.d.ts +0 -90
- package/dist/components/compare-regions.d.ts +0 -37
- package/dist/components/compare-text.d.ts +0 -32
- package/dist/components/compare-video-grid.d.ts +0 -52
- package/dist/components/compare-video.d.ts +0 -61
- package/dist/components/compare.d.ts +0 -90
- package/dist/components/composition.d.ts +0 -44
- package/dist/components/console.d.ts +0 -34
- package/dist/components/conversation.d.ts +0 -83
- package/dist/components/cursor.d.ts +0 -44
- package/dist/components/data-table.d.ts +0 -89
- package/dist/components/data-view.d.ts +0 -66
- package/dist/components/density.d.ts +0 -16
- package/dist/components/dialog.d.ts +0 -45
- package/dist/components/difference.d.ts +0 -19
- package/dist/components/disclosure.d.ts +0 -49
- package/dist/components/done.d.ts +0 -14
- package/dist/components/drag-source.d.ts +0 -29
- package/dist/components/field.d.ts +0 -79
- package/dist/components/file-intake.d.ts +0 -60
- package/dist/components/film-strip.d.ts +0 -35
- package/dist/components/folder-picker.d.ts +0 -59
- package/dist/components/fullscreen-frame.d.ts +0 -18
- package/dist/components/history.d.ts +0 -61
- package/dist/components/hotkeys.d.ts +0 -44
- package/dist/components/infinite-list.d.ts +0 -77
- package/dist/components/inspector.d.ts +0 -66
- package/dist/components/job-action.d.ts +0 -30
- package/dist/components/job-status.d.ts +0 -55
- package/dist/components/jobs-table.d.ts +0 -35
- package/dist/components/key-glyphs.d.ts +0 -5
- package/dist/components/key-owner.d.ts +0 -11
- package/dist/components/lightbox.d.ts +0 -61
- package/dist/components/line-chart.d.ts +0 -169
- package/dist/components/link-card.d.ts +0 -32
- package/dist/components/link.d.ts +0 -54
- package/dist/components/markable-text.d.ts +0 -60
- package/dist/components/media-contents.d.ts +0 -28
- package/dist/components/media-group.d.ts +0 -32
- package/dist/components/media-player.d.ts +0 -251
- package/dist/components/media-progress.d.ts +0 -17
- package/dist/components/media-skip.d.ts +0 -31
- package/dist/components/media-spans.d.ts +0 -93
- package/dist/components/media.d.ts +0 -133
- package/dist/components/meter.d.ts +0 -32
- package/dist/components/metric.d.ts +0 -17
- package/dist/components/outbox-status.d.ts +0 -10
- package/dist/components/page-header.d.ts +0 -14
- package/dist/components/pair-vote.d.ts +0 -70
- package/dist/components/pause-button.d.ts +0 -7
- package/dist/components/pixel-image.d.ts +0 -29
- package/dist/components/place-board.d.ts +0 -39
- package/dist/components/player-warning.d.ts +0 -24
- package/dist/components/popover.d.ts +0 -20
- package/dist/components/recorder.d.ts +0 -73
- package/dist/components/region-editor.d.ts +0 -67
- package/dist/components/save.d.ts +0 -46
- package/dist/components/say-again.d.ts +0 -13
- package/dist/components/schedule-table.d.ts +0 -24
- package/dist/components/secret-field.d.ts +0 -34
- package/dist/components/selectable-grid.d.ts +0 -57
- package/dist/components/selection.d.ts +0 -104
- package/dist/components/sequence-timeline.d.ts +0 -50
- package/dist/components/shortcut-editor.d.ts +0 -44
- package/dist/components/sortable-list.d.ts +0 -39
- package/dist/components/status.d.ts +0 -9
- package/dist/components/switch.d.ts +0 -15
- package/dist/components/system-panel.d.ts +0 -58
- package/dist/components/tabs.d.ts +0 -16
- package/dist/components/theme.d.ts +0 -106
- package/dist/components/thumbnail.d.ts +0 -50
- package/dist/components/tile-grid.d.ts +0 -67
- package/dist/components/timeline-player.d.ts +0 -18
- package/dist/components/timeline.d.ts +0 -115
- package/dist/components/toast.d.ts +0 -36
- package/dist/components/toggle.d.ts +0 -51
- package/dist/components/toolbar.d.ts +0 -15
- package/dist/components/tooltip.d.ts +0 -19
- package/dist/components/transcript-view.d.ts +0 -63
- package/dist/components/tree.d.ts +0 -74
- package/dist/components/undo.d.ts +0 -63
- package/dist/components/use-timeline.d.ts +0 -44
- package/dist/components/value-controls.d.ts +0 -91
- package/dist/components/video-clock.d.ts +0 -68
- package/dist/components/view-options.d.ts +0 -105
- package/dist/components/viewport.d.ts +0 -85
- package/dist/components/virtual-list.d.ts +0 -19
- package/dist/components/waveform.d.ts +0 -71
- package/dist/components/workflow-steps.d.ts +0 -71
- package/dist/components/workspace.d.ts +0 -83
- package/dist/cursor-DDGBPiTJ.js.map +0 -1
- package/dist/field-BjeE_FeB.js.map +0 -1
- package/dist/follow-BTPs49FP.js.map +0 -1
- package/dist/generate-CjTHKJ39.js.map +0 -1
- package/dist/lib/base.d.ts +0 -10
- package/dist/lib/book.d.ts +0 -25
- package/dist/lib/boxes.d.ts +0 -55
- package/dist/lib/breakpoint.d.ts +0 -4
- package/dist/lib/choice.d.ts +0 -29
- package/dist/lib/chords.d.ts +0 -20
- package/dist/lib/client-work.d.ts +0 -24
- package/dist/lib/control.d.ts +0 -4
- package/dist/lib/dev.d.ts +0 -2
- package/dist/lib/errors.d.ts +0 -43
- package/dist/lib/file-intake.d.ts +0 -60
- package/dist/lib/follow.d.ts +0 -18
- package/dist/lib/format.d.ts +0 -243
- package/dist/lib/grouped-grid-layout.d.ts +0 -44
- package/dist/lib/icon.d.ts +0 -6
- package/dist/lib/image-diff.d.ts +0 -30
- package/dist/lib/in-view.d.ts +0 -21
- package/dist/lib/loudness.d.ts +0 -18
- package/dist/lib/marks.d.ts +0 -6
- package/dist/lib/microphone.d.ts +0 -24
- package/dist/lib/number-input.d.ts +0 -4
- package/dist/lib/object-url.d.ts +0 -2
- package/dist/lib/overlay.d.ts +0 -1
- package/dist/lib/recording.d.ts +0 -16
- package/dist/lib/region.d.ts +0 -64
- package/dist/lib/rich-text.d.ts +0 -44
- package/dist/lib/search-param.d.ts +0 -16
- package/dist/lib/segmenter.d.ts +0 -40
- package/dist/lib/sequence.d.ts +0 -34
- package/dist/lib/speech.d.ts +0 -53
- package/dist/lib/text-diff.d.ts +0 -16
- package/dist/lib/timeline.d.ts +0 -14
- package/dist/lib/transcript.d.ts +0 -53
- package/dist/lib/utils.d.ts +0 -4
- package/dist/lib/viewer-input.d.ts +0 -29
- package/dist/lib/viewport.d.ts +0 -55
- package/dist/lib/waveform.d.ts +0 -46
- package/dist/map/fan.d.ts +0 -15
- package/dist/map/index.d.ts +0 -3
- package/dist/map/map-styles.d.ts +0 -2
- package/dist/map/markers.d.ts +0 -60
- package/dist/map/route-map.d.ts +0 -146
- package/dist/microphone-Bo3WaXgD.js.map +0 -1
- package/dist/migrate/stock-classes.d.ts +0 -11
- package/dist/panorama/gl.d.ts +0 -16
- package/dist/panorama/index.d.ts +0 -2
- package/dist/panorama/panorama-viewer.d.ts +0 -56
- package/dist/panorama/projection.d.ts +0 -45
- package/dist/query/api.d.ts +0 -23
- package/dist/query/clips.d.ts +0 -48
- package/dist/query/index.d.ts +0 -55
- package/dist/query/infinite.d.ts +0 -60
- package/dist/query/job.d.ts +0 -26
- package/dist/query/outbox.d.ts +0 -85
- package/dist/query/poll.d.ts +0 -24
- package/dist/query/reserve.d.ts +0 -33
- package/dist/query/typed-api.d.ts +0 -84
- package/dist/query/workflow.d.ts +0 -17
- package/dist/run-BT2WKzMz.js.map +0 -1
- package/dist/scene/camera.d.ts +0 -99
- package/dist/scene/index.d.ts +0 -2
- package/dist/scene/scene-viewport.d.ts +0 -48
- package/dist/testing/buttons.d.ts +0 -7
- package/dist/testing/index.d.ts +0 -161
- package/dist/testing/intersection-observer.d.ts +0 -34
- package/dist/testing/layout.d.ts +0 -13
- package/dist/testing/microphone.d.ts +0 -35
- package/dist/testing/setup.d.ts +0 -14
- package/dist/testing/speech.d.ts +0 -38
- package/dist/testing/storage.d.ts +0 -7
- package/dist/theme-CxYZkUNk.js.map +0 -1
- package/dist/tooltip-DhqrDtyu.js.map +0 -1
- package/dist/value-controls-Dm_EYfZW.js.map +0 -1
- package/dist/visual/capture.d.ts +0 -37
- package/dist/visual/compare.d.ts +0 -46
- package/dist/visual/drop.d.ts +0 -19
- package/dist/visual/fonts.d.ts +0 -18
- package/dist/visual/index.d.ts +0 -19
- package/dist/visual/run.d.ts +0 -22
- package/dist/visual/serve.d.ts +0 -13
- package/dist/visual/targets.d.ts +0 -17
- package/dist/visual/types.d.ts +0 -188
package/dist/migrate-cli.js
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import { readFileSync, readdirSync, statSync } from "node:fs";
|
|
2
2
|
import { join, relative } from "node:path";
|
|
3
3
|
import { parseArgs } from "node:util";
|
|
4
|
+
|
|
4
5
|
// src/migrate/stock-classes.ts
|
|
5
|
-
|
|
6
|
+
const rules = [
|
|
6
7
|
{
|
|
7
8
|
kind: "colour",
|
|
8
9
|
test: new RegExp(`^(?:bg|text|border(?:-[xytblrse])?|ring|ring-offset|fill|stroke|from|via|to|divide|outline|accent|caret|decoration|placeholder|shadow|inset-shadow|inset-ring|text-shadow)-(?:(?:slate|gray|zinc|neutral|stone|red|orange|amber|yellow|lime|green|emerald|teal|cyan|sky|blue|indigo|violet|purple|fuchsia|pink|rose)-(?:50|100|200|300|400|500|600|700|800|900|950)|white|black)(?:/\\d+)?$`),
|
|
@@ -31,7 +32,7 @@ var rules = [
|
|
|
31
32
|
];
|
|
32
33
|
/** Stock classes in `source`, one entry per use. In a `.css` file only `@apply` lines are read. */
|
|
33
34
|
function findStockClasses(source, file = "") {
|
|
34
|
-
const css =
|
|
35
|
+
const css = file.endsWith(".css");
|
|
35
36
|
const found = [];
|
|
36
37
|
let applying = false;
|
|
37
38
|
source.split("\n").forEach((text, i) => {
|
|
@@ -52,8 +53,9 @@ function findStockClasses(source, file = "") {
|
|
|
52
53
|
});
|
|
53
54
|
return found;
|
|
54
55
|
}
|
|
56
|
+
|
|
55
57
|
// src/migrate/cli.ts
|
|
56
|
-
|
|
58
|
+
const usage = `Usage: strata-stock-classes [options] [folder or file ...]
|
|
57
59
|
|
|
58
60
|
Lists the stock Tailwind classes (colours such as bg-stone-100, text-sm, rounded-xl, shadow-lg, font-serif)
|
|
59
61
|
that strata.css would stop compiling, so an app on strata.migrate.css knows what is left to convert. Reads
|
|
@@ -62,8 +64,8 @@ that strata.css would stop compiling, so an app on strata.migrate.css knows what
|
|
|
62
64
|
--fail exit 1 when any are found (for a CI step that holds the line while migrating)
|
|
63
65
|
--help show this
|
|
64
66
|
`;
|
|
65
|
-
|
|
66
|
-
|
|
67
|
+
const readable = /\.(?:[cm]?[jt]sx?|html|mdx|vue|svelte|css)$/;
|
|
68
|
+
const skipped = /* @__PURE__ */ new Set([
|
|
67
69
|
"node_modules",
|
|
68
70
|
"dist",
|
|
69
71
|
".git",
|
|
@@ -123,6 +125,6 @@ async function main(argv, out = (t) => console.log(t)) {
|
|
|
123
125
|
for (const rule of new Set(all.flatMap((f) => f.found.map((x) => `${x.kind}: ${x.instead}`)))) out(` ${rule}`);
|
|
124
126
|
return values.fail ? 1 : 0;
|
|
125
127
|
}
|
|
126
|
-
export { main };
|
|
127
128
|
|
|
129
|
+
export { main };
|
|
128
130
|
//# sourceMappingURL=migrate-cli.js.map
|
package/dist/migrate-cli.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"migrate-cli.js","names":[],"sources":["../src/migrate/stock-classes.ts","../src/migrate/cli.ts"],"sourcesContent":["// Finds the stock Tailwind classes an app still uses, for an app moving onto Strata one screen at a time (issue #225).\n// `strata.css` clears Tailwind's colour, type-size, radius, shadow and font namespaces, so `bg-stone-100`, `text-sm`,\n// `rounded-xl` and `shadow-lg` stop compiling the moment it is imported. `strata.migrate.css` keeps them, and this lists\n// what is left to convert so the app knows when `strata.css` is one import away. It reads class names as text (no Tailwind\n// build, no dependency), so it is a list to work from, not a proof: a class built from parts (\"bg-\" + tone) is invisible\n// to it and to Tailwind's own scanner alike, and a word that only looks like a class in a string can be listed.\n\n/** What kind of stock class it is, named as the roles that replace it are. */\nexport type StockKind = \"colour\" | \"text size\" | \"radius\" | \"shadow\" | \"font\";\n\n/** One stock class found at a line of a file. */\nexport type StockClass = { line: number; className: string; kind: StockKind; instead: string };\n\nconst COLOURS
|
|
1
|
+
{"version":3,"file":"migrate-cli.js","names":[],"sources":["../src/migrate/stock-classes.ts","../src/migrate/cli.ts"],"sourcesContent":["// Finds the stock Tailwind classes an app still uses, for an app moving onto Strata one screen at a time (issue #225).\n// `strata.css` clears Tailwind's colour, type-size, radius, shadow and font namespaces, so `bg-stone-100`, `text-sm`,\n// `rounded-xl` and `shadow-lg` stop compiling the moment it is imported. `strata.migrate.css` keeps them, and this lists\n// what is left to convert so the app knows when `strata.css` is one import away. It reads class names as text (no Tailwind\n// build, no dependency), so it is a list to work from, not a proof: a class built from parts (\"bg-\" + tone) is invisible\n// to it and to Tailwind's own scanner alike, and a word that only looks like a class in a string can be listed.\n\n/** What kind of stock class it is, named as the roles that replace it are. */\nexport type StockKind = \"colour\" | \"text size\" | \"radius\" | \"shadow\" | \"font\";\n\n/** One stock class found at a line of a file. */\nexport type StockClass = { line: number; className: string; kind: StockKind; instead: string };\n\nconst COLOURS =\n \"slate|gray|zinc|neutral|stone|red|orange|amber|yellow|lime|green|emerald|teal|cyan|sky|blue|indigo|violet|purple|fuchsia|pink|rose\";\nconst COLOUR_UTILITIES =\n \"bg|text|border(?:-[xytblrse])?|ring|ring-offset|fill|stroke|from|via|to|divide|outline|accent|caret|decoration|placeholder|shadow|inset-shadow|inset-ring|text-shadow\";\nconst colour = new RegExp(\n `^(?:${COLOUR_UTILITIES})-(?:(?:${COLOURS})-(?:50|100|200|300|400|500|600|700|800|900|950)|white|black)(?:/\\\\d+)?$`,\n);\nconst textSize = /^text-(?:xs|sm|base|lg|xl|[2-9]xl)(?:\\/[\\w.[\\]-]+)?$/;\nconst radius = /^rounded(?:-(?:t|r|b|l|s|e|tl|tr|br|bl|ss|se|ee|es))?-(?:xs|sm|md|lg|xl|2xl|3xl|4xl)$/;\nconst shadow = /^(?:inset-)?shadow-(?:2xs|xs|sm|md|lg|xl|2xl|inner)$/;\nconst font = /^font-serif$/;\n\nconst rules: { kind: StockKind; test: RegExp; instead: string }[] = [\n {\n kind: \"colour\",\n test: colour,\n instead: \"a colour role: bg-primary, bg-muted, text-muted-foreground, border-border, bg-danger-subtle…\",\n },\n {\n kind: \"text size\",\n test: textSize,\n instead: \"a type step: type-caption, type-label, type-body-sm, type-body, type-heading, type-title\",\n },\n {\n kind: \"radius\",\n test: radius,\n instead: \"a radius role: rounded-control, rounded-surface, rounded-overlay or rounded-pill\",\n },\n { kind: \"shadow\", test: shadow, instead: \"shadow-overlay for what floats, a border for what sits on the page\" },\n { kind: \"font\", test: font, instead: \"font-display, or a face your theme names\" },\n];\n\n/** Stock classes in `source`, one entry per use. In a `.css` file only `@apply` lines are read. */\nexport function findStockClasses(source: string, file = \"\"): StockClass[] {\n const css = file.endsWith(\".css\");\n const found: StockClass[] = [];\n // In a stylesheet an `@apply` runs to its `;` (or the closing brace), however many lines it is written over.\n let applying = false;\n source.split(\"\\n\").forEach((text, i) => {\n if (css) {\n if (!applying && !text.includes(\"@apply\")) return;\n applying = !/[;}]/.test(text.slice(Math.max(0, text.indexOf(\"@apply\"))));\n }\n for (const token of text.match(/[^\\s\"'`<>{}()=,;]+/g) ?? []) {\n // The utility is what follows the last variant (`dark:hover:bg-stone-100`), without an important mark.\n const className = token.slice(token.lastIndexOf(\":\") + 1).replace(/^!|!$/g, \"\");\n const rule = rules.find((r) => r.test.test(className));\n if (rule) found.push({ line: i + 1, className: token.replace(/^!/, \"\"), kind: rule.kind, instead: rule.instead });\n }\n });\n return found;\n}\n","// The strata-stock-classes command: lists the stock Tailwind classes still in an app's source (see stock-classes.ts).\nimport { readdirSync, readFileSync, statSync } from \"node:fs\";\nimport { join, relative } from \"node:path\";\nimport { parseArgs } from \"node:util\";\nimport { findStockClasses, type StockClass } from \"./stock-classes\";\n\nconst usage = `Usage: strata-stock-classes [options] [folder or file ...]\n\nLists the stock Tailwind classes (colours such as bg-stone-100, text-sm, rounded-xl, shadow-lg, font-serif)\nthat strata.css would stop compiling, so an app on strata.migrate.css knows what is left to convert. Reads\n.ts .tsx .js .jsx .mjs .html .mdx .vue .svelte files, and the @apply lines of .css files. Default: ./src.\n\n --fail exit 1 when any are found (for a CI step that holds the line while migrating)\n --help show this\n`;\n\nconst readable = /\\.(?:[cm]?[jt]sx?|html|mdx|vue|svelte|css)$/;\nconst skipped = new Set([\"node_modules\", \"dist\", \".git\", \"storybook-static\", \"coverage\"]);\n\nfunction* walk(path: string): Generator<string> {\n if (statSync(path).isFile()) {\n if (readable.test(path)) yield path;\n return;\n }\n for (const name of readdirSync(path).sort()) if (!skipped.has(name)) yield* walk(join(path, name));\n}\n\n/** Runs the command; the exit code. */\nexport async function main(argv: string[], out: (text: string) => void = (t) => console.log(t)): Promise<number> {\n const { values, positionals } = parseArgs({\n args: argv,\n options: { fail: { type: \"boolean\" }, help: { type: \"boolean\" } },\n allowPositionals: true,\n });\n if (values.help) {\n out(usage);\n return 0;\n }\n const roots = positionals.length ? positionals : [\"src\"];\n const all: { file: string; found: StockClass[] }[] = [];\n for (const root of roots) {\n try {\n statSync(root);\n } catch {\n out(`strata-stock-classes: ${root} does not exist`);\n return 2;\n }\n for (const file of walk(root)) {\n const found = findStockClasses(readFileSync(file, \"utf8\"), file);\n if (found.length) all.push({ file: relative(process.cwd(), file), found });\n }\n }\n const total = all.reduce((n, f) => n + f.found.length, 0);\n if (!total) {\n out(\"No stock Tailwind classes left. Switch the import to strata-react/strata.css.\");\n return 0;\n }\n const byKind = new Map<string, number>();\n for (const { file, found } of all) {\n for (const f of found) {\n out(`${file}:${f.line} ${f.className} (${f.kind})`);\n byKind.set(f.kind, (byKind.get(f.kind) ?? 0) + 1);\n }\n }\n out(\"\");\n out(`${total} stock classes in ${all.length} files: ${[...byKind].map(([k, n]) => `${n} ${k}`).join(\", \")}.`);\n for (const rule of new Set(all.flatMap((f) => f.found.map((x) => `${x.kind}: ${x.instead}`)))) out(` ${rule}`);\n return values.fail ? 1 : 0;\n}\n"],"mappings":";;;;;AAyBA,MAAM,QAA8D;CAClE;EACE,MAAM;EACN,MAAM,IAXS,OACjB,6XAUa;EACX,SAAS;CACX;CACA;EACE,MAAM;EACN,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CAAC,GAAG,MAAM,CAAC,CAAC,KAAK,CAAC,GAAG,OAAO,GAAG,EAAE,GAAG,GAAG,CAAC,CAAC,KAAK,IAAI,EAAE,EAAE;CAC5G,KAAK,MAAM,QAAQ,IAAI,IAAI,IAAI,SAAS,MAAM,EAAE,MAAM,KAAK,MAAM,GAAG,EAAE,KAAK,IAAI,EAAE,SAAS,CAAC,CAAC,GAAG,IAAI,KAAK,MAAM;CAC9G,OAAO,OAAO,OAAO,IAAI;AAC3B"}
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
/** Where the window looks and how wide it sees, degrees. */
|
|
3
|
+
type PanoramaView = {
|
|
4
|
+
yaw: number;
|
|
5
|
+
pitch: number;
|
|
6
|
+
fov: number;
|
|
7
|
+
};
|
|
8
|
+
/** The size of the picture box in CSS pixels. */
|
|
9
|
+
type PanoramaSize = {
|
|
10
|
+
width: number;
|
|
11
|
+
height: number;
|
|
12
|
+
};
|
|
13
|
+
/** A place in the box. `inside` says it is within the box; a point behind the camera has none (`project` returns null). */
|
|
14
|
+
type PanoramaPoint = {
|
|
15
|
+
x: number;
|
|
16
|
+
y: number;
|
|
17
|
+
inside: boolean;
|
|
18
|
+
};
|
|
19
|
+
/** Wraps a heading to (-180, 180]. */
|
|
20
|
+
export declare function wrapYaw(yaw: number): number;
|
|
21
|
+
/** The smallest signed turn from heading `from` to heading `to`, in (-180, 180]. Use it for a difference of headings, never `to - from`. */
|
|
22
|
+
export declare const yawDelta: (from: number, to: number) => number;
|
|
23
|
+
/** Keeps a view inside its limits: heading wrapped, pitch within +-`maxPitch`, field of view within `minFov` to `maxFov`. */
|
|
24
|
+
export declare function clampView(view: PanoramaView, { maxPitch, minFov, maxFov }?: {
|
|
25
|
+
maxPitch?: number;
|
|
26
|
+
minFov?: number;
|
|
27
|
+
maxFov?: number;
|
|
28
|
+
}): PanoramaView;
|
|
29
|
+
/** Where the direction (`yaw`, `pitch`) is drawn in the box for `view`, or null when it is behind the camera. */
|
|
30
|
+
export declare function project(view: PanoramaView, size: PanoramaSize, yaw: number, pitch: number): PanoramaPoint | null;
|
|
31
|
+
/** The direction under a point of the box for `view`: the inverse of `project`. */
|
|
32
|
+
export declare function unproject(view: PanoramaView, size: PanoramaSize, x: number, y: number): {
|
|
33
|
+
yaw: number;
|
|
34
|
+
pitch: number;
|
|
35
|
+
};
|
|
36
|
+
/** Pixels to degrees at the middle of the box: how far a drag of `px` turns the view. */
|
|
37
|
+
export declare const degreesPerPixel: (view: PanoramaView, size: PanoramaSize) => number;
|
|
38
|
+
/** The flat picture's own mapping, for the fallback with no WebGL: longitude and latitude are straight across and down, the visible rectangle is `fov` wide and as tall as the box's shape makes it. */
|
|
39
|
+
export declare function projectFlat(view: PanoramaView, size: PanoramaSize, yaw: number, pitch: number): PanoramaPoint;
|
|
40
|
+
/** The inverse of `projectFlat`. */
|
|
41
|
+
export declare function unprojectFlat(view: PanoramaView, size: PanoramaSize, x: number, y: number): {
|
|
42
|
+
yaw: number;
|
|
43
|
+
pitch: number;
|
|
44
|
+
};
|
|
45
|
+
/** The direction in words: "Looking 40° right, 5° up", "Looking straight ahead". Whole degrees; nothing is said for less than half a degree. */
|
|
46
|
+
export declare function describeView(view: Pick<PanoramaView, "yaw" | "pitch">): string;
|
|
47
|
+
type PanoramaPictureSource = {
|
|
48
|
+
image: string;
|
|
49
|
+
video?: never;
|
|
50
|
+
} | {
|
|
51
|
+
video: React.RefObject<HTMLVideoElement | null>;
|
|
52
|
+
image?: never;
|
|
53
|
+
};
|
|
54
|
+
/** What an overlay is given. */
|
|
55
|
+
type PanoramaOverlayApi = {
|
|
56
|
+
view: PanoramaView;
|
|
57
|
+
size: PanoramaSize;
|
|
58
|
+
/** Where the direction is in the box, or null behind the camera. */
|
|
59
|
+
project: (yaw: number, pitch: number) => PanoramaPoint | null;
|
|
60
|
+
/** The direction under a place in the box. */
|
|
61
|
+
unproject: (x: number, y: number) => {
|
|
62
|
+
yaw: number;
|
|
63
|
+
pitch: number;
|
|
64
|
+
};
|
|
65
|
+
/** The flat picture is being drawn (no WebGL2). */
|
|
66
|
+
flat: boolean;
|
|
67
|
+
};
|
|
68
|
+
type PanoramaViewerProps = PanoramaPictureSource & {
|
|
69
|
+
/** Names the viewer: "360 view of the kitchen". Required; the current direction is added to it. */
|
|
70
|
+
label: string;
|
|
71
|
+
/** The view, when the app holds it. */
|
|
72
|
+
view?: PanoramaView;
|
|
73
|
+
/** The view the viewer starts with, when it holds its own. Default straight ahead at 90°. */
|
|
74
|
+
defaultView?: PanoramaView;
|
|
75
|
+
/** The view changed (a drag, a key, a wheel, the slider). Not called for a view the app set. */
|
|
76
|
+
onViewChange?: (view: PanoramaView) => void;
|
|
77
|
+
/** A click that did not drag: the direction under it. */
|
|
78
|
+
onPick?: (direction: {
|
|
79
|
+
yaw: number;
|
|
80
|
+
pitch: number;
|
|
81
|
+
}) => void;
|
|
82
|
+
/** Highest and lowest look, degrees from the horizon. Default 85. */
|
|
83
|
+
maxPitch?: number;
|
|
84
|
+
/** Narrowest and widest field of view, degrees. Default 20 and 120. */
|
|
85
|
+
minFov?: number;
|
|
86
|
+
maxFov?: number;
|
|
87
|
+
/** Zoom with the wheel. Default true. */
|
|
88
|
+
wheelZoom?: boolean;
|
|
89
|
+
/** Show a field-of-view slider under the picture. */
|
|
90
|
+
fovSlider?: boolean;
|
|
91
|
+
/** Markers and outlines drawn over the picture in its own coordinates. */
|
|
92
|
+
overlay?: (api: PanoramaOverlayApi) => React.ReactNode;
|
|
93
|
+
/** `"flat"` draws the flat picture even where WebGL2 is available (a low-power mode, or to see what a browser without it shows). Default `"auto"`. */
|
|
94
|
+
mode?: "auto" | "flat";
|
|
95
|
+
/** The shape of the box. Default 16/9. */
|
|
96
|
+
aspect?: number | `${number}/${number}`;
|
|
97
|
+
className?: string;
|
|
98
|
+
};
|
|
99
|
+
/** A 360 picture or video as a window you pan and zoom, controlled from outside, with an overlay in the picture's coordinates. */
|
|
100
|
+
export declare function PanoramaViewer({ label, image, video, view: controlled, defaultView, onViewChange, onPick, maxPitch, minFov, maxFov, wheelZoom, fovSlider, overlay, mode, aspect, className }: PanoramaViewerProps): React.JSX.Element;
|
|
101
|
+
export type { PanoramaOverlayApi, PanoramaPoint, PanoramaSize, PanoramaView, PanoramaViewerProps };
|
|
102
|
+
//# sourceMappingURL=panorama.d.ts.map
|
package/dist/panorama.js
CHANGED
|
@@ -1,16 +1,17 @@
|
|
|
1
|
-
import { o as useInView } from "./button-
|
|
2
|
-
import { n as useViewPointers, r as useWheelZoom, t as useSettledStatus } from "./viewer-input-
|
|
3
|
-
import { r as cn } from "./tooltip-
|
|
4
|
-
import { r as Slider } from "./value-controls-
|
|
1
|
+
import { o as useInView } from "./button-CYXjU-fs.js";
|
|
2
|
+
import { n as useViewPointers, r as useWheelZoom, t as useSettledStatus } from "./viewer-input-3Qa-o35k.js";
|
|
3
|
+
import { r as cn } from "./tooltip-BosfsWYh.js";
|
|
4
|
+
import { r as Slider } from "./value-controls-5u7sD_wG.js";
|
|
5
5
|
import * as React from "react";
|
|
6
6
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
7
7
|
import { VisuallyHidden } from "react-aria";
|
|
8
|
+
|
|
8
9
|
// src/panorama/gl.ts
|
|
9
|
-
|
|
10
|
+
const VERTEX = `#version 300 es
|
|
10
11
|
in vec2 aPos;
|
|
11
12
|
out vec2 vNdc;
|
|
12
13
|
void main() { vNdc = aPos; gl_Position = vec4(aPos, 0.0, 1.0); }`;
|
|
13
|
-
|
|
14
|
+
const FRAGMENT = `#version 300 es
|
|
14
15
|
precision highp float;
|
|
15
16
|
in vec2 vNdc;
|
|
16
17
|
out vec4 outColor;
|
|
@@ -121,16 +122,17 @@ function createRenderer(canvas) {
|
|
|
121
122
|
}
|
|
122
123
|
};
|
|
123
124
|
}
|
|
125
|
+
|
|
124
126
|
// src/panorama/projection.ts
|
|
125
|
-
|
|
126
|
-
|
|
127
|
+
const RAD = Math.PI / 180;
|
|
128
|
+
const DEG = 180 / Math.PI;
|
|
127
129
|
/** Wraps a heading to (-180, 180]. */
|
|
128
130
|
function wrapYaw(yaw) {
|
|
129
131
|
const w = ((yaw + 180) % 360 + 360) % 360 - 180;
|
|
130
132
|
return w === -180 ? 180 : w;
|
|
131
133
|
}
|
|
132
134
|
/** The smallest signed turn from heading `from` to heading `to`, in (-180, 180]. Use it for a difference of headings, never `to - from`. */
|
|
133
|
-
|
|
135
|
+
const yawDelta = (from, to) => wrapYaw(to - from);
|
|
134
136
|
/** Keeps a view inside its limits: heading wrapped, pitch within +-`maxPitch`, field of view within `minFov` to `maxFov`. */
|
|
135
137
|
function clampView(view, { maxPitch = 85, minFov = 20, maxFov = 120 } = {}) {
|
|
136
138
|
return {
|
|
@@ -139,7 +141,7 @@ function clampView(view, { maxPitch = 85, minFov = 20, maxFov = 120 } = {}) {
|
|
|
139
141
|
fov: Math.min(Math.max(view.fov, minFov), maxFov)
|
|
140
142
|
};
|
|
141
143
|
}
|
|
142
|
-
|
|
144
|
+
const focal = (view, size) => size.width / 2 / Math.tan(view.fov * RAD / 2);
|
|
143
145
|
function basis(view) {
|
|
144
146
|
const y = view.yaw * RAD;
|
|
145
147
|
const p = view.pitch * RAD;
|
|
@@ -161,7 +163,7 @@ function basis(view) {
|
|
|
161
163
|
]
|
|
162
164
|
};
|
|
163
165
|
}
|
|
164
|
-
|
|
166
|
+
const dot = (a, b) => a[0] * b[0] + a[1] * b[1] + a[2] * b[2];
|
|
165
167
|
/** Where the direction (`yaw`, `pitch`) is drawn in the box for `view`, or null when it is behind the camera. */
|
|
166
168
|
function project(view, size, yaw, pitch) {
|
|
167
169
|
const { forward, right, up } = basis(view);
|
|
@@ -201,7 +203,7 @@ function unproject(view, size, x, y) {
|
|
|
201
203
|
};
|
|
202
204
|
}
|
|
203
205
|
/** Pixels to degrees at the middle of the box: how far a drag of `px` turns the view. */
|
|
204
|
-
|
|
206
|
+
const degreesPerPixel = (view, size) => Math.atan(1 / focal(view, size)) * DEG;
|
|
205
207
|
/** The flat picture's own mapping, for the fallback with no WebGL: longitude and latitude are straight across and down, the visible rectangle is `fov` wide and as tall as the box's shape makes it. */
|
|
206
208
|
function projectFlat(view, size, yaw, pitch) {
|
|
207
209
|
const perPixel = view.fov / size.width;
|
|
@@ -228,13 +230,14 @@ function describeView(view) {
|
|
|
228
230
|
const parts = [yaw === 0 ? "" : yaw === 180 ? "directly behind" : `${Math.abs(yaw)}° ${yaw > 0 ? "right" : "left"}`, pitch === 0 ? "" : `${Math.abs(pitch)}° ${pitch > 0 ? "up" : "down"}`].filter(Boolean);
|
|
229
231
|
return parts.length === 0 ? "Looking straight ahead" : `Looking ${parts.join(", ")}`;
|
|
230
232
|
}
|
|
233
|
+
|
|
231
234
|
// src/panorama/panorama-viewer.tsx
|
|
232
|
-
|
|
235
|
+
const HOME = {
|
|
233
236
|
yaw: 0,
|
|
234
237
|
pitch: 0,
|
|
235
238
|
fov: 90
|
|
236
239
|
};
|
|
237
|
-
|
|
240
|
+
const STILL_MS = 600;
|
|
238
241
|
/** A 360 picture or video as a window you pan and zoom, controlled from outside, with an overlay in the picture's coordinates. */
|
|
239
242
|
function PanoramaViewer({ label, image, video, view: controlled, defaultView = HOME, onViewChange, onPick, maxPitch = 85, minFov = 20, maxFov = 120, wheelZoom = true, fovSlider = false, overlay, mode = "auto", aspect = "16/9", className }) {
|
|
240
243
|
const limits = React.useMemo(() => ({
|
|
@@ -595,6 +598,6 @@ function PanoramaViewer({ label, image, video, view: controlled, defaultView = H
|
|
|
595
598
|
]
|
|
596
599
|
});
|
|
597
600
|
}
|
|
598
|
-
export { PanoramaViewer, clampView, degreesPerPixel, describeView, project, projectFlat, unproject, unprojectFlat, wrapYaw, yawDelta };
|
|
599
601
|
|
|
602
|
+
export { PanoramaViewer, clampView, degreesPerPixel, describeView, project, projectFlat, unproject, unprojectFlat, wrapYaw, yawDelta };
|
|
600
603
|
//# sourceMappingURL=panorama.js.map
|
package/dist/panorama.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"panorama.js","names":[],"sources":["../src/panorama/gl.ts","../src/panorama/projection.ts","../src/panorama/panorama-viewer.tsx"],"sourcesContent":["import type { PanoramaView } from \"./projection\";\n\n// The WebGL2 side of `PanoramaViewer` (strata-react issue #178): one full-screen triangle, and a\n// fragment shader that does for every pixel what `project`/`unproject` do for one (projection.ts holds\n// the same formulas, and tests hold the two to each other): build the ray through the pixel from the\n// view's yaw, pitch and field of view, turn it into longitude and latitude, and read the equirectangular\n// texture there. The texture repeats across the seam (longitude) and clamps at the poles. No mipmaps:\n// the longitude wraps with an `atan`, whose jump at the seam would make a mipmapped lookup draw a line\n// one pixel wide down it; plain linear filtering draws none.\n//\n// Cost, as documented for apps: one texture upload per *drawn video frame* (`texImage2D` of the\n// `<video>`), none for a still picture (uploaded once), and a draw only when the view, the size or the\n// picture changed, never on a timer.\n\nconst VERTEX = `#version 300 es\nin vec2 aPos;\nout vec2 vNdc;\nvoid main() { vNdc = aPos; gl_Position = vec4(aPos, 0.0, 1.0); }`;\n\nconst FRAGMENT = `#version 300 es\nprecision highp float;\nin vec2 vNdc;\nout vec4 outColor;\nuniform sampler2D uPicture;\nuniform float uYaw;\nuniform float uPitch;\nuniform float uTanHalf;\nuniform float uAspect;\nconst float PI = 3.14159265358979;\nvoid main() {\n vec3 forward = vec3(cos(uPitch) * sin(uYaw), sin(uPitch), cos(uPitch) * cos(uYaw));\n vec3 right = vec3(cos(uYaw), 0.0, -sin(uYaw));\n vec3 up = vec3(-sin(uPitch) * sin(uYaw), cos(uPitch), -sin(uPitch) * cos(uYaw));\n vec3 ray = normalize(forward + vNdc.x * uTanHalf * right + vNdc.y * (uTanHalf / uAspect) * up);\n float lon = atan(ray.x, ray.z);\n float lat = asin(clamp(ray.y, -1.0, 1.0));\n outColor = texture(uPicture, vec2(lon / (2.0 * PI) + 0.5, 0.5 - lat / PI));\n}`;\n\n/** Anything WebGL can take as a texture: a decoded image or a playing video. */\nexport type PanoramaPicture = HTMLImageElement | HTMLVideoElement | ImageBitmap | HTMLCanvasElement;\n\n/** What draws the window. */\nexport type PanoramaRenderer = {\n /** Sends the picture to the GPU. Call when the picture is a new one (an image) or a new frame (a video). */\n upload: (picture: PanoramaPicture) => void;\n /** Draws the view into a canvas of `width` by `height` device pixels. */\n draw: (view: PanoramaView, width: number, height: number) => void;\n /** How many times `upload` has sent a picture (a video frame, an image), for the documented cost and for tests. */\n uploads: () => number;\n /** Frees the GPU objects. */\n dispose: () => void;\n};\n\n/** Makes a renderer on `canvas`, or null where WebGL2 is not available (the viewer then shows the flat picture). */\nexport function createRenderer(canvas: HTMLCanvasElement): PanoramaRenderer | null {\n const gl = canvas.getContext(\"webgl2\", { antialias: false, preserveDrawingBuffer: false, alpha: false }) as WebGL2RenderingContext | null;\n if (!gl) return null;\n const compile = (type: number, source: string) => {\n const shader = gl.createShader(type)!;\n gl.shaderSource(shader, source);\n gl.compileShader(shader);\n if (!gl.getShaderParameter(shader, gl.COMPILE_STATUS)) {\n const log = gl.getShaderInfoLog(shader);\n gl.deleteShader(shader);\n throw new Error(`Panorama shader: ${log}`);\n }\n return shader;\n };\n let program: WebGLProgram;\n try {\n program = gl.createProgram()!;\n gl.attachShader(program, compile(gl.VERTEX_SHADER, VERTEX));\n gl.attachShader(program, compile(gl.FRAGMENT_SHADER, FRAGMENT));\n gl.linkProgram(program);\n if (!gl.getProgramParameter(program, gl.LINK_STATUS)) throw new Error(`Panorama program: ${gl.getProgramInfoLog(program)}`);\n } catch {\n return null;\n }\n gl.useProgram(program);\n const buffer = gl.createBuffer();\n gl.bindBuffer(gl.ARRAY_BUFFER, buffer);\n // One triangle that covers the screen.\n gl.bufferData(gl.ARRAY_BUFFER, new Float32Array([-1, -1, 3, -1, -1, 3]), gl.STATIC_DRAW);\n const position = gl.getAttribLocation(program, \"aPos\");\n gl.enableVertexAttribArray(position);\n gl.vertexAttribPointer(position, 2, gl.FLOAT, false, 0, 0);\n const texture = gl.createTexture();\n gl.bindTexture(gl.TEXTURE_2D, texture);\n gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, gl.REPEAT);\n gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE);\n gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.LINEAR);\n gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, gl.LINEAR);\n const uniforms = {\n yaw: gl.getUniformLocation(program, \"uYaw\"),\n pitch: gl.getUniformLocation(program, \"uPitch\"),\n tanHalf: gl.getUniformLocation(program, \"uTanHalf\"),\n aspect: gl.getUniformLocation(program, \"uAspect\"),\n picture: gl.getUniformLocation(program, \"uPicture\"),\n };\n gl.uniform1i(uniforms.picture, 0);\n let uploaded = 0;\n let has = false;\n\n return {\n upload(picture) {\n gl.bindTexture(gl.TEXTURE_2D, texture);\n gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, gl.RGBA, gl.UNSIGNED_BYTE, picture);\n uploaded++;\n has = true;\n },\n draw(view, width, height) {\n if (canvas.width !== width || canvas.height !== height) {\n canvas.width = width;\n canvas.height = height;\n }\n gl.viewport(0, 0, width, height);\n if (!has) {\n gl.clearColor(0, 0, 0, 1);\n gl.clear(gl.COLOR_BUFFER_BIT);\n return;\n }\n const rad = Math.PI / 180;\n gl.uniform1f(uniforms.yaw, view.yaw * rad);\n gl.uniform1f(uniforms.pitch, view.pitch * rad);\n gl.uniform1f(uniforms.tanHalf, Math.tan((view.fov * rad) / 2));\n gl.uniform1f(uniforms.aspect, width / height);\n gl.drawArrays(gl.TRIANGLES, 0, 3);\n },\n uploads: () => uploaded,\n dispose() {\n gl.deleteTexture(texture);\n gl.deleteBuffer(buffer);\n gl.deleteProgram(program);\n },\n };\n}\n","// The geometry of `PanoramaViewer` (strata-react issue #178), with no DOM and no GL so every case\n// is tested on its own and the GL shader is held to the same numbers. A 360 picture is\n// *equirectangular*: longitude across, latitude down. The viewer shows a *rectilinear* window into the\n// sphere, as a camera does: straight lines stay straight, and the width of what is seen is the\n// horizontal field of view `fov`.\n//\n// Angles are degrees, because that is what an app and a person talk in. `yaw` is the heading: 0 is the\n// middle of the picture, positive to the right, wrapped to (-180, 180]. `pitch` is the elevation:\n// 0 is the horizon, positive up, limited to +-90 (the apps' own `maxPitch` is kept below that). A\n// direction in the world is a unit vector `(cos p sin y, sin p, cos p cos y)`; the camera's forward,\n// right and up are built from the view's yaw and pitch (no roll: upright footage). A point is drawn\n// where its direction crosses the image plane, `fpx = (width / 2) / tan(fov / 2)` pixels from the camera.\n\n/** Where the window looks and how wide it sees, degrees. */\nexport type PanoramaView = { yaw: number; pitch: number; fov: number };\n\n/** The size of the picture box in CSS pixels. */\nexport type PanoramaSize = { width: number; height: number };\n\n/** A place in the box. `inside` says it is within the box; a point behind the camera has none (`project` returns null). */\nexport type PanoramaPoint = { x: number; y: number; inside: boolean };\n\nconst RAD = Math.PI / 180;\nconst DEG = 180 / Math.PI;\n\n/** Wraps a heading to (-180, 180]. */\nexport function wrapYaw(yaw: number): number {\n const w = ((((yaw + 180) % 360) + 360) % 360) - 180;\n return w === -180 ? 180 : w;\n}\n\n/** The smallest signed turn from heading `from` to heading `to`, in (-180, 180]. Use it for a difference of headings, never `to - from`. */\nexport const yawDelta = (from: number, to: number) => wrapYaw(to - from);\n\n/** Keeps a view inside its limits: heading wrapped, pitch within +-`maxPitch`, field of view within `minFov` to `maxFov`. */\nexport function clampView(view: PanoramaView, { maxPitch = 85, minFov = 20, maxFov = 120 }: { maxPitch?: number; minFov?: number; maxFov?: number } = {}): PanoramaView {\n return { yaw: wrapYaw(view.yaw), pitch: Math.min(Math.max(view.pitch, -maxPitch), maxPitch), fov: Math.min(Math.max(view.fov, minFov), maxFov) };\n}\n\nconst focal = (view: PanoramaView, size: PanoramaSize) => size.width / 2 / Math.tan((view.fov * RAD) / 2);\n\nfunction basis(view: PanoramaView) {\n const y = view.yaw * RAD;\n const p = view.pitch * RAD;\n const forward = [Math.cos(p) * Math.sin(y), Math.sin(p), Math.cos(p) * Math.cos(y)] as const;\n const right = [Math.cos(y), 0, -Math.sin(y)] as const;\n const up = [-Math.sin(p) * Math.sin(y), Math.cos(p), -Math.sin(p) * Math.cos(y)] as const;\n return { forward, right, up };\n}\nconst dot = (a: readonly number[], b: readonly number[]) => a[0] * b[0] + a[1] * b[1] + a[2] * b[2];\n\n/** Where the direction (`yaw`, `pitch`) is drawn in the box for `view`, or null when it is behind the camera. */\nexport function project(view: PanoramaView, size: PanoramaSize, yaw: number, pitch: number): PanoramaPoint | null {\n const { forward, right, up } = basis(view);\n const p = pitch * RAD;\n const y = yaw * RAD;\n const d = [Math.cos(p) * Math.sin(y), Math.sin(p), Math.cos(p) * Math.cos(y)] as const;\n const z = dot(d, forward);\n if (z <= 1e-9) return null;\n const f = focal(view, size);\n const x = size.width / 2 + (f * dot(d, right)) / z;\n const yy = size.height / 2 - (f * dot(d, up)) / z;\n return { x, y: yy, inside: x >= 0 && x <= size.width && yy >= 0 && yy <= size.height };\n}\n\n/** The direction under a point of the box for `view`: the inverse of `project`. */\nexport function unproject(view: PanoramaView, size: PanoramaSize, x: number, y: number): { yaw: number; pitch: number } {\n const { forward, right, up } = basis(view);\n const f = focal(view, size);\n const a = (x - size.width / 2) / f;\n const b = -(y - size.height / 2) / f;\n const v = [forward[0] + a * right[0] + b * up[0], forward[1] + a * right[1] + b * up[1], forward[2] + a * right[2] + b * up[2]] as const;\n const length = Math.hypot(v[0], v[1], v[2]);\n return { yaw: wrapYaw(Math.atan2(v[0], v[2]) * DEG), pitch: Math.asin(Math.min(Math.max(v[1] / length, -1), 1)) * DEG };\n}\n\n/** Pixels to degrees at the middle of the box: how far a drag of `px` turns the view. */\nexport const degreesPerPixel = (view: PanoramaView, size: PanoramaSize) => (Math.atan(1 / focal(view, size)) * DEG);\n\n/** The flat picture's own mapping, for the fallback with no WebGL: longitude and latitude are straight across and down, the visible rectangle is `fov` wide and as tall as the box's shape makes it. */\nexport function projectFlat(view: PanoramaView, size: PanoramaSize, yaw: number, pitch: number): PanoramaPoint {\n const perPixel = view.fov / size.width;\n const x = size.width / 2 + yawDelta(view.yaw, yaw) / perPixel;\n const y = size.height / 2 - (pitch - view.pitch) / perPixel;\n return { x, y, inside: x >= 0 && x <= size.width && y >= 0 && y <= size.height };\n}\n\n/** The inverse of `projectFlat`. */\nexport function unprojectFlat(view: PanoramaView, size: PanoramaSize, x: number, y: number): { yaw: number; pitch: number } {\n const perPixel = view.fov / size.width;\n return { yaw: wrapYaw(view.yaw + (x - size.width / 2) * perPixel), pitch: Math.min(Math.max(view.pitch - (y - size.height / 2) * perPixel, -90), 90) };\n}\n\n/** The direction in words: \"Looking 40° right, 5° up\", \"Looking straight ahead\". Whole degrees; nothing is said for less than half a degree. */\nexport function describeView(view: Pick<PanoramaView, \"yaw\" | \"pitch\">): string {\n const yaw = Math.round(wrapYaw(view.yaw));\n const pitch = Math.round(view.pitch);\n const side = yaw === 0 ? \"\" : yaw === 180 ? \"directly behind\" : `${Math.abs(yaw)}° ${yaw > 0 ? \"right\" : \"left\"}`;\n const tilt = pitch === 0 ? \"\" : `${Math.abs(pitch)}° ${pitch > 0 ? \"up\" : \"down\"}`;\n const parts = [side, tilt].filter(Boolean);\n return parts.length === 0 ? \"Looking straight ahead\" : `Looking ${parts.join(\", \")}`;\n}\n","import * as React from \"react\";\nimport { VisuallyHidden } from \"react-aria\";\nimport { useInView } from \"../lib/in-view\";\nimport { useSettledStatus, useViewPointers, useWheelZoom } from \"../lib/viewer-input\";\nimport { cn } from \"../lib/utils\";\nimport { Slider } from \"../components/value-controls\";\nimport { createRenderer, type PanoramaPicture, type PanoramaRenderer } from \"./gl\";\nimport { clampView, degreesPerPixel, describeView, project, projectFlat, unproject, unprojectFlat, type PanoramaPoint, type PanoramaSize, type PanoramaView } from \"./projection\";\n\n// A 360 picture or video as a window you pan and zoom (strata-react issue #178, from strata-360, which\n// drew equirectangular footage with a hand-written WebGL2 shader and its own pointer, transport and\n// frame stepping). This is its own entry (`strata-react/panorama`) so an app that never shows 360 ships\n// no GL code. Nothing else in the package is as far from React Aria's world, so the choices:\n//\n// - **The picture is a canvas, the controls are keys and pointers on a group.** React Aria has no 360\n// view, so the viewer is ours; what it can give, it gives: the field-of-view slider is Strata's\n// `Slider` (React Aria's), and the pointer handling is plain pointer events (React Aria's `usePress`\n// is for a press, not a drag that turns a sphere; checked in its props: it reports a press and its\n// start and end, with no movement).\n// - **It does not own the video.** `video` is a ref to an element the app owns (`useMediaElement`,\n// `Transport`, `SeekBar` and `transportShortcuts` drive it as they drive any video, frame stepping\n// included). The viewer reads each new frame (`requestVideoFrameCallback`, else the element's events\n// and a frame loop while it plays) and uploads it: one texture upload per drawn frame, none for a\n// still picture, and no drawing at all while the viewer is off screen.\n// - **The view is controlled from outside** (`view`/`onViewChange`: yaw, pitch and field of view, in\n// degrees; `defaultView` to let it hold its own). It never animates: a view set from outside is\n// drawn at once, so an app's aim modes (follow a heading, a person, a point) are the app's own\n// function of time, and its pan on top is just another view.\n// - **From the keyboard and by touch, as well as the mouse**: arrow keys pan (Shift for more), `+` and\n// `-` zoom, `0` goes home; a drag pans (the picture follows the pointer), a wheel and a pinch zoom,\n// and a click that did not drag is `onPick` with the direction under it. A field-of-view slider is\n// an option. `maxPitch` stops the view short of the poles, where \"up\" stops meaning anything.\n// - **An overlay in the picture's coordinates**: `overlay` gets `project(yaw, pitch)` (the place in the\n// box, or null behind the camera), `unproject(x, y)` (the direction under a place) and the view, so\n// an app draws markers, aim dots and frame outlines in DOM, where they are text and buttons and take\n// focus. The same maths (projection.ts, with no GL) drives the shader.\n// - **Said in words.** The canvas is an image named by `label` and where it looks (\"Looking 40° right,\n// 5° up\"), always current; a polite status says it once the view has been still for a moment, never\n// per frame.\n// - **No WebGL2, no blank box**: the flat picture is drawn instead, cropped to the same window with the\n// same controls, and a line says so. `project` and `unproject` follow the flat drawing there, so\n// overlay markers still sit on what they mark.\n//\n// A GL context that is lost (a GPU reset, a tab in the background on a phone) is restored without the\n// app doing anything: the picture is sent again and the view redrawn.\n\nexport type PanoramaPictureSource = { image: string; video?: never } | { video: React.RefObject<HTMLVideoElement | null>; image?: never };\n\n/** What an overlay is given. */\nexport type PanoramaOverlayApi = {\n view: PanoramaView;\n size: PanoramaSize;\n /** Where the direction is in the box, or null behind the camera. */\n project: (yaw: number, pitch: number) => PanoramaPoint | null;\n /** The direction under a place in the box. */\n unproject: (x: number, y: number) => { yaw: number; pitch: number };\n /** The flat picture is being drawn (no WebGL2). */\n flat: boolean;\n};\n\nexport type PanoramaViewerProps = PanoramaPictureSource & {\n /** Names the viewer: \"360 view of the kitchen\". Required; the current direction is added to it. */\n label: string;\n /** The view, when the app holds it. */\n view?: PanoramaView;\n /** The view the viewer starts with, when it holds its own. Default straight ahead at 90°. */\n defaultView?: PanoramaView;\n /** The view changed (a drag, a key, a wheel, the slider). Not called for a view the app set. */\n onViewChange?: (view: PanoramaView) => void;\n /** A click that did not drag: the direction under it. */\n onPick?: (direction: { yaw: number; pitch: number }) => void;\n /** Highest and lowest look, degrees from the horizon. Default 85. */\n maxPitch?: number;\n /** Narrowest and widest field of view, degrees. Default 20 and 120. */\n minFov?: number;\n maxFov?: number;\n /** Zoom with the wheel. Default true. */\n wheelZoom?: boolean;\n /** Show a field-of-view slider under the picture. */\n fovSlider?: boolean;\n /** Markers and outlines drawn over the picture in its own coordinates. */\n overlay?: (api: PanoramaOverlayApi) => React.ReactNode;\n /** `\"flat\"` draws the flat picture even where WebGL2 is available (a low-power mode, or to see what a browser without it shows). Default `\"auto\"`. */\n mode?: \"auto\" | \"flat\";\n /** The shape of the box. Default 16/9. */\n aspect?: number | `${number}/${number}`;\n className?: string;\n};\n\nconst HOME: PanoramaView = { yaw: 0, pitch: 0, fov: 90 };\nconst STILL_MS = 600;\n\n/** A 360 picture or video as a window you pan and zoom, controlled from outside, with an overlay in the picture's coordinates. */\nexport function PanoramaViewer({ label, image, video, view: controlled, defaultView = HOME, onViewChange, onPick, maxPitch = 85, minFov = 20, maxFov = 120, wheelZoom = true, fovSlider = false, overlay, mode = \"auto\", aspect = \"16/9\", className }: PanoramaViewerProps) {\n const limits = React.useMemo(() => ({ maxPitch, minFov, maxFov }), [maxPitch, minFov, maxFov]);\n const [own, setOwn] = React.useState(() => clampView(defaultView, limits));\n const view = React.useMemo(() => clampView(controlled ?? own, limits), [controlled, own, limits]);\n const live = React.useRef({ view, controlled: controlled !== undefined, onViewChange, onPick, limits });\n live.current = { view, controlled: controlled !== undefined, onViewChange, onPick, limits };\n const change = React.useCallback((next: PanoramaView) => {\n const l = live.current;\n const clamped = clampView(next, l.limits);\n if (!l.controlled) setOwn(clamped);\n l.onViewChange?.(clamped);\n }, []);\n\n // The box, and the canvas in it.\n const box = React.useRef<HTMLDivElement>(null);\n const canvas = React.useRef<HTMLCanvasElement>(null);\n const [size, setSize] = React.useState<PanoramaSize>({ width: 0, height: 0 });\n React.useLayoutEffect(() => {\n const el = box.current;\n if (!el) return;\n const read = () => {\n const r = el.getBoundingClientRect();\n setSize((s) => (s.width === r.width && s.height === r.height ? s : { width: r.width, height: r.height }));\n };\n read();\n if (typeof ResizeObserver === \"undefined\") return;\n const ro = new ResizeObserver(read);\n ro.observe(el);\n return () => ro.disconnect();\n }, []);\n\n // The picture: a still is loaded once; a video is the app's element.\n const [still, setStill] = React.useState<HTMLImageElement | null>(null);\n React.useEffect(() => {\n if (image === undefined) {\n setStill(null);\n return;\n }\n const img = new Image();\n img.crossOrigin = \"anonymous\";\n let cancelled = false;\n img.onload = () => !cancelled && setStill(img);\n img.src = image;\n return () => {\n cancelled = true;\n img.onload = null;\n };\n }, [image]);\n\n // Drawing: only when something changed, and only while on screen.\n const { ref: visibleRef, inView } = useInView({ unsupported: true });\n // One stable callback: an inline one is called with null and the element on every render, and `useInView` would watch it come and go.\n const boxRef = React.useCallback(\n (el: HTMLDivElement | null) => {\n box.current = el;\n visibleRef(el);\n },\n [visibleRef],\n );\n const renderer = React.useRef<PanoramaRenderer | null>(null);\n const [flat, setFlat] = React.useState(false);\n const frame = React.useRef(0);\n const dirtyPicture = React.useRef(true);\n const current = React.useRef({ size, inView, flat });\n current.current = { size, inView, flat };\n\n const pictureNow = React.useCallback((): PanoramaPicture | null => {\n const v = video?.current;\n if (v) return v.readyState >= 2 && v.videoWidth > 0 ? v : null;\n return still;\n }, [video, still]);\n\n const paint = React.useCallback(() => {\n frame.current = 0;\n const c = canvas.current;\n const { size: s, inView: visible } = current.current;\n if (!c || !visible || s.width === 0 || s.height === 0) return;\n const picture = pictureNow();\n const dpr = Math.min(typeof devicePixelRatio === \"number\" ? devicePixelRatio : 1, 2);\n const w = Math.max(1, Math.round(s.width * dpr));\n const h = Math.max(1, Math.round(s.height * dpr));\n if (current.current.flat) {\n const ctx = c.getContext(\"2d\");\n if (!ctx) return;\n if (c.width !== w || c.height !== h) {\n c.width = w;\n c.height = h;\n }\n ctx.fillStyle = \"#000\";\n ctx.fillRect(0, 0, w, h);\n if (!picture) return;\n const sw = (picture as HTMLImageElement).naturalWidth || (picture as HTMLVideoElement).videoWidth || c.width;\n const sh = (picture as HTMLImageElement).naturalHeight || (picture as HTMLVideoElement).videoHeight || c.height;\n const v = live.current.view;\n const wide = (v.fov / 360) * sw;\n const tall = ((v.fov * (s.height / s.width)) / 180) * sh;\n const left = ((v.yaw - v.fov / 2 + 180) / 360) * sw;\n const top = ((90 - v.pitch) / 180) * sh - tall / 2;\n // Across the seam the window is two pieces of the picture side by side.\n for (const shift of [-sw, 0, sw]) {\n const a = Math.max(left + shift, 0);\n const b = Math.min(left + shift + wide, sw);\n if (b > a) ctx.drawImage(picture as CanvasImageSource, a, Math.max(top, 0), b - a, Math.min(tall, sh), ((a - (left + shift)) / wide) * w, 0, ((b - a) / wide) * w, h);\n }\n return;\n }\n const r = renderer.current;\n if (!r) return;\n if (picture && dirtyPicture.current) {\n r.upload(picture);\n dirtyPicture.current = false;\n }\n r.draw(live.current.view, w, h);\n }, [pictureNow]);\n const schedule = React.useCallback(() => {\n if (frame.current === 0) frame.current = requestAnimationFrame(paint);\n }, [paint]);\n\n // The renderer: made once, restored if the context is lost, and the flat picture if there is none.\n React.useEffect(() => {\n const c = canvas.current;\n if (!c) return;\n const make = () => {\n renderer.current?.dispose();\n renderer.current = mode === \"flat\" ? null : createRenderer(c);\n setFlat(renderer.current === null);\n dirtyPicture.current = true;\n schedule();\n };\n make();\n const lost = (e: Event) => {\n e.preventDefault();\n renderer.current = null;\n };\n c.addEventListener(\"webglcontextlost\", lost);\n c.addEventListener(\"webglcontextrestored\", make);\n return () => {\n c.removeEventListener(\"webglcontextlost\", lost);\n c.removeEventListener(\"webglcontextrestored\", make);\n renderer.current?.dispose();\n renderer.current = null;\n if (frame.current) cancelAnimationFrame(frame.current);\n frame.current = 0;\n };\n }, [schedule, mode]);\n\n // A new still, a new size, a new view, or coming into view: draw.\n React.useEffect(() => {\n dirtyPicture.current = true;\n }, [still]);\n React.useEffect(() => {\n schedule();\n }, [schedule, view.yaw, view.pitch, view.fov, size.width, size.height, still, inView, flat]);\n\n // A video: each new frame is one upload and one draw.\n React.useEffect(() => {\n const v = video?.current;\n if (!v || !inView) return;\n let stopped = false;\n let handle = 0;\n const onFrame = () => {\n if (stopped) return;\n dirtyPicture.current = true;\n schedule();\n handle = v.requestVideoFrameCallback(onFrame);\n };\n if (typeof v.requestVideoFrameCallback === \"function\") {\n handle = v.requestVideoFrameCallback(onFrame);\n return () => {\n stopped = true;\n v.cancelVideoFrameCallback?.(handle);\n };\n }\n // No frame callback: the element's own events, and a frame loop while it plays.\n const touch = () => {\n dirtyPicture.current = true;\n schedule();\n };\n const events = [\"loadeddata\", \"seeked\", \"timeupdate\", \"play\", \"pause\"] as const;\n for (const e of events) v.addEventListener(e, touch);\n let loop = 0;\n const tick = () => {\n if (!v.paused) touch();\n loop = requestAnimationFrame(tick);\n };\n loop = requestAnimationFrame(tick);\n return () => {\n for (const e of events) v.removeEventListener(e, touch);\n cancelAnimationFrame(loop);\n };\n }, [video, inView, schedule]);\n\n // Pointer: drag turns the view with the pointer, two pointers pinch, a click that did not drag picks (`useViewPointers`).\n const hostRect = () => box.current!.getBoundingClientRect();\n const pointers = useViewPointers({\n ignore: (e) => e.button !== 0 && e.pointerType === \"mouse\",\n onDrag: (dx, dy) => {\n const v = live.current.view;\n const r = hostRect();\n // The picture follows the pointer: dragging right turns the view left.\n const per = degreesPerPixel(v, { width: r.width, height: r.height });\n change({ ...v, yaw: v.yaw - dx * per, pitch: v.pitch + dy * per });\n },\n onPinch: (ratio) => change({ ...live.current.view, fov: live.current.view.fov * ratio }),\n onTap: (e) => {\n if (!live.current.onPick) return;\n const r = hostRect();\n const s = { width: r.width, height: r.height };\n const x = e.clientX - r.left;\n const y = e.clientY - r.top;\n live.current.onPick(current.current.flat ? unprojectFlat(live.current.view, s, x, y) : unproject(live.current.view, s, x, y));\n },\n });\n\n // The wheel zooms; native, because React's wheel listener is passive and the page must not scroll too.\n useWheelZoom(box, (factor) => change({ ...live.current.view, fov: live.current.view.fov * factor }), { enabled: wheelZoom });\n\n const onKeyDown = (e: React.KeyboardEvent) => {\n const v = live.current.view;\n const turn = (v.fov / 12) * (e.shiftKey ? 3 : 1);\n if (e.key === \"ArrowLeft\") change({ ...v, yaw: v.yaw - turn });\n else if (e.key === \"ArrowRight\") change({ ...v, yaw: v.yaw + turn });\n else if (e.key === \"ArrowUp\") change({ ...v, pitch: v.pitch + turn });\n else if (e.key === \"ArrowDown\") change({ ...v, pitch: v.pitch - turn });\n else if (e.key === \"+\" || e.key === \"=\") change({ ...v, fov: v.fov * 0.8 });\n else if (e.key === \"-\" || e.key === \"_\") change({ ...v, fov: v.fov * 1.25 });\n else if (e.key === \"0\") change(defaultView);\n else return;\n e.preventDefault();\n };\n\n // Said in words: always on the picture; politely once the view has been still for a moment.\n const direction = describeView(view);\n const said = useSettledStatus(`${direction}, field of view ${Math.round(view.fov)}°`, STILL_MS);\n\n const api: PanoramaOverlayApi = {\n view,\n size,\n flat,\n project: (yaw, pitch) => (flat ? projectFlat(view, size, yaw, pitch) : project(view, size, yaw, pitch)),\n unproject: (x, y) => (flat ? unprojectFlat(view, size, x, y) : unproject(view, size, x, y)),\n };\n const slider = fovSlider ? <Slider aria-label=\"Field of view\" value={Math.round(view.fov)} onChange={(fov) => change({ ...view, fov })} min={minFov} max={maxFov} step={1} unit=\"degree\" /> : null;\n\n return (\n <div className={cn(\"grid min-w-0 gap-2\", className)}>\n <div\n ref={boxRef}\n role=\"group\"\n aria-label={label}\n aria-describedby={undefined}\n tabIndex={0}\n onKeyDown={onKeyDown}\n onPointerDown={pointers.onPointerDown}\n onPointerMove={pointers.onPointerMove}\n onPointerUp={pointers.onPointerUp}\n onPointerCancel={pointers.onPointerCancel}\n className=\"relative w-full cursor-grab touch-none overflow-hidden rounded-surface bg-surface-sunken select-none active:cursor-grabbing\"\n style={{ aspectRatio: aspect }}\n >\n <canvas key={mode === \"flat\" ? \"2d\" : \"gl\"} ref={canvas} role=\"img\" aria-label={`${label}. ${direction}, field of view ${Math.round(view.fov)}°`} className=\"absolute inset-0 size-full\" />\n {overlay && size.width > 0 && <div className=\"pointer-events-none absolute inset-0\">{overlay(api)}</div>}\n </div>\n {flat && <p className=\"type-body-sm text-muted-foreground\">This browser cannot draw the 360 view, so the flat picture is shown. The controls work the same.</p>}\n {slider}\n <VisuallyHidden>\n <span role=\"status\">{said}</span>\n </VisuallyHidden>\n </div>\n );\n}\n"],"mappings":";;;;;;;;AAcA,IAAM,SAAS;;;;AAKf,IAAM,WAAW;;;;;;;;;;;;;;;;;;;;AAoCjB,SAAgB,eAAe,QAAoD;CACjF,MAAM,KAAK,OAAO,WAAW,UAAU;EAAE,WAAW;EAAO,uBAAuB;EAAO,OAAO;CAAM,CAAC;CACvG,IAAI,CAAC,IAAI,OAAO;CAChB,MAAM,WAAW,MAAc,WAAmB;EAChD,MAAM,SAAS,GAAG,aAAa,IAAI;EACnC,GAAG,aAAa,QAAQ,MAAM;EAC9B,GAAG,cAAc,MAAM;EACvB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rG,YAAY,GAAG,MAAO,OAAO,cAAc,MAAM,MAAM,GAAG,CAAC,IAAI,UAAU,MAAM,MAAM,GAAG,CAAC;CAC3F;CACA,MAAM,SAAS,YAAY,oBAAC,QAAD;EAAQ,cAAW;EAAgB,OAAO,KAAK,MAAM,KAAK,GAAG;EAAG,WAAW,QAAQ,OAAO;GAAE,GAAG;GAAM;EAAI,CAAC;EAAG,KAAK;EAAQ,KAAK;EAAQ,MAAM;EAAG,MAAK;CAAU,CAAA,IAAI;CAE9L,OACE,qBAAC,OAAD;EAAK,WAAW,GAAG,sBAAsB,SAAS;EAAlD,UAAA;GACE,qBAAC,OAAD;IACE,KAAK;IACL,MAAK;IACL,cAAY;IACZ,oBAAkB,KAAA;IAClB,UAAU;IACC;IACX,eAAe,SAAS;IACxB,eAAe,SAAS;IACxB,aAAa,SAAS;IACtB,iBAAiB,SAAS;IAC1B,WAAU;IACV,OAAO,EAAE,aAAa,OAAO;IAZ/B,UAAA,CAcE,oBAAC,UAAD;KAA4C,KAAK;KAAQ,MAAK;KAAM,cAAY,GAAG,MAAM,IAAI,UAAU,kBAAkB,KAAK,MAAM,KAAK,GAAG,EAAE;KAAI,WAAU;IAA8B,GAA7K,SAAS,SAAS,OAAO,IAAoJ,GACzL,WAAW,KAAK,QAAQ,KAAK,oBAAC,OAAD;KAAK,WAAU;KAAwC,UAAA,QAAQ,GAAG;IAAO,CAAA,CACpG;;GACJ,QAAQ,oBAAC,KAAD;IAAG,WAAU;IAAqC,UAAA;GAAmG,CAAA;GAC7J;GACD,oBAAC,gBAAD,EAAA,UACE,oBAAC,QAAD;IAAM,MAAK;IAAU,UAAA;GAAW,CAAA,EAClB,CAAA;EACb;;AAET"}
|
|
1
|
+
{"version":3,"file":"panorama.js","names":[],"sources":["../src/panorama/gl.ts","../src/panorama/projection.ts","../src/panorama/panorama-viewer.tsx"],"sourcesContent":["import type { PanoramaView } from \"./projection\";\n\n// The WebGL2 side of `PanoramaViewer` (strata-react issue #178): one full-screen triangle, and a\n// fragment shader that does for every pixel what `project`/`unproject` do for one (projection.ts holds\n// the same formulas, and tests hold the two to each other): build the ray through the pixel from the\n// view's yaw, pitch and field of view, turn it into longitude and latitude, and read the equirectangular\n// texture there. The texture repeats across the seam (longitude) and clamps at the poles. No mipmaps:\n// the longitude wraps with an `atan`, whose jump at the seam would make a mipmapped lookup draw a line\n// one pixel wide down it; plain linear filtering draws none.\n//\n// Cost, as documented for apps: one texture upload per *drawn video frame* (`texImage2D` of the\n// `<video>`), none for a still picture (uploaded once), and a draw only when the view, the size or the\n// picture changed, never on a timer.\n\nconst VERTEX = `#version 300 es\nin vec2 aPos;\nout vec2 vNdc;\nvoid main() { vNdc = aPos; gl_Position = vec4(aPos, 0.0, 1.0); }`;\n\nconst FRAGMENT = `#version 300 es\nprecision highp float;\nin vec2 vNdc;\nout vec4 outColor;\nuniform sampler2D uPicture;\nuniform float uYaw;\nuniform float uPitch;\nuniform float uTanHalf;\nuniform float uAspect;\nconst float PI = 3.14159265358979;\nvoid main() {\n vec3 forward = vec3(cos(uPitch) * sin(uYaw), sin(uPitch), cos(uPitch) * cos(uYaw));\n vec3 right = vec3(cos(uYaw), 0.0, -sin(uYaw));\n vec3 up = vec3(-sin(uPitch) * sin(uYaw), cos(uPitch), -sin(uPitch) * cos(uYaw));\n vec3 ray = normalize(forward + vNdc.x * uTanHalf * right + vNdc.y * (uTanHalf / uAspect) * up);\n float lon = atan(ray.x, ray.z);\n float lat = asin(clamp(ray.y, -1.0, 1.0));\n outColor = texture(uPicture, vec2(lon / (2.0 * PI) + 0.5, 0.5 - lat / PI));\n}`;\n\n/** Anything WebGL can take as a texture: a decoded image or a playing video. */\nexport type PanoramaPicture = HTMLImageElement | HTMLVideoElement | ImageBitmap | HTMLCanvasElement;\n\n/** What draws the window. */\nexport type PanoramaRenderer = {\n /** Sends the picture to the GPU. Call when the picture is a new one (an image) or a new frame (a video). */\n upload: (picture: PanoramaPicture) => void;\n /** Draws the view into a canvas of `width` by `height` device pixels. */\n draw: (view: PanoramaView, width: number, height: number) => void;\n /** How many times `upload` has sent a picture (a video frame, an image), for the documented cost and for tests. */\n uploads: () => number;\n /** Frees the GPU objects. */\n dispose: () => void;\n};\n\n/** Makes a renderer on `canvas`, or null where WebGL2 is not available (the viewer then shows the flat picture). */\nexport function createRenderer(canvas: HTMLCanvasElement): PanoramaRenderer | null {\n const gl = canvas.getContext(\"webgl2\", {\n antialias: false,\n preserveDrawingBuffer: false,\n alpha: false,\n }) as WebGL2RenderingContext | null;\n if (!gl) return null;\n const compile = (type: number, source: string) => {\n const shader = gl.createShader(type)!;\n gl.shaderSource(shader, source);\n gl.compileShader(shader);\n if (!gl.getShaderParameter(shader, gl.COMPILE_STATUS)) {\n const log = gl.getShaderInfoLog(shader);\n gl.deleteShader(shader);\n throw new Error(`Panorama shader: ${log}`);\n }\n return shader;\n };\n let program: WebGLProgram;\n try {\n program = gl.createProgram()!;\n gl.attachShader(program, compile(gl.VERTEX_SHADER, VERTEX));\n gl.attachShader(program, compile(gl.FRAGMENT_SHADER, FRAGMENT));\n gl.linkProgram(program);\n if (!gl.getProgramParameter(program, gl.LINK_STATUS))\n throw new Error(`Panorama program: ${gl.getProgramInfoLog(program)}`);\n } catch {\n return null;\n }\n gl.useProgram(program);\n const buffer = gl.createBuffer();\n gl.bindBuffer(gl.ARRAY_BUFFER, buffer);\n // One triangle that covers the screen.\n gl.bufferData(gl.ARRAY_BUFFER, new Float32Array([-1, -1, 3, -1, -1, 3]), gl.STATIC_DRAW);\n const position = gl.getAttribLocation(program, \"aPos\");\n gl.enableVertexAttribArray(position);\n gl.vertexAttribPointer(position, 2, gl.FLOAT, false, 0, 0);\n const texture = gl.createTexture();\n gl.bindTexture(gl.TEXTURE_2D, texture);\n gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, gl.REPEAT);\n gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE);\n gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.LINEAR);\n gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, gl.LINEAR);\n const uniforms = {\n yaw: gl.getUniformLocation(program, \"uYaw\"),\n pitch: gl.getUniformLocation(program, \"uPitch\"),\n tanHalf: gl.getUniformLocation(program, \"uTanHalf\"),\n aspect: gl.getUniformLocation(program, \"uAspect\"),\n picture: gl.getUniformLocation(program, \"uPicture\"),\n };\n gl.uniform1i(uniforms.picture, 0);\n let uploaded = 0;\n let has = false;\n\n return {\n upload(picture) {\n gl.bindTexture(gl.TEXTURE_2D, texture);\n gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, gl.RGBA, gl.UNSIGNED_BYTE, picture);\n uploaded++;\n has = true;\n },\n draw(view, width, height) {\n if (canvas.width !== width || canvas.height !== height) {\n canvas.width = width;\n canvas.height = height;\n }\n gl.viewport(0, 0, width, height);\n if (!has) {\n gl.clearColor(0, 0, 0, 1);\n gl.clear(gl.COLOR_BUFFER_BIT);\n return;\n }\n const rad = Math.PI / 180;\n gl.uniform1f(uniforms.yaw, view.yaw * rad);\n gl.uniform1f(uniforms.pitch, view.pitch * rad);\n gl.uniform1f(uniforms.tanHalf, Math.tan((view.fov * rad) / 2));\n gl.uniform1f(uniforms.aspect, width / height);\n gl.drawArrays(gl.TRIANGLES, 0, 3);\n },\n uploads: () => uploaded,\n dispose() {\n gl.deleteTexture(texture);\n gl.deleteBuffer(buffer);\n gl.deleteProgram(program);\n },\n };\n}\n","// The geometry of `PanoramaViewer` (strata-react issue #178), with no DOM and no GL so every case\n// is tested on its own and the GL shader is held to the same numbers. A 360 picture is\n// *equirectangular*: longitude across, latitude down. The viewer shows a *rectilinear* window into the\n// sphere, as a camera does: straight lines stay straight, and the width of what is seen is the\n// horizontal field of view `fov`.\n//\n// Angles are degrees, because that is what an app and a person talk in. `yaw` is the heading: 0 is the\n// middle of the picture, positive to the right, wrapped to (-180, 180]. `pitch` is the elevation:\n// 0 is the horizon, positive up, limited to +-90 (the apps' own `maxPitch` is kept below that). A\n// direction in the world is a unit vector `(cos p sin y, sin p, cos p cos y)`; the camera's forward,\n// right and up are built from the view's yaw and pitch (no roll: upright footage). A point is drawn\n// where its direction crosses the image plane, `fpx = (width / 2) / tan(fov / 2)` pixels from the camera.\n\n/** Where the window looks and how wide it sees, degrees. */\nexport type PanoramaView = { yaw: number; pitch: number; fov: number };\n\n/** The size of the picture box in CSS pixels. */\nexport type PanoramaSize = { width: number; height: number };\n\n/** A place in the box. `inside` says it is within the box; a point behind the camera has none (`project` returns null). */\nexport type PanoramaPoint = { x: number; y: number; inside: boolean };\n\nconst RAD = Math.PI / 180;\nconst DEG = 180 / Math.PI;\n\n/** Wraps a heading to (-180, 180]. */\nexport function wrapYaw(yaw: number): number {\n const w = ((((yaw + 180) % 360) + 360) % 360) - 180;\n return w === -180 ? 180 : w;\n}\n\n/** The smallest signed turn from heading `from` to heading `to`, in (-180, 180]. Use it for a difference of headings, never `to - from`. */\nexport const yawDelta = (from: number, to: number) => wrapYaw(to - from);\n\n/** Keeps a view inside its limits: heading wrapped, pitch within +-`maxPitch`, field of view within `minFov` to `maxFov`. */\nexport function clampView(\n view: PanoramaView,\n { maxPitch = 85, minFov = 20, maxFov = 120 }: { maxPitch?: number; minFov?: number; maxFov?: number } = {},\n): PanoramaView {\n return {\n yaw: wrapYaw(view.yaw),\n pitch: Math.min(Math.max(view.pitch, -maxPitch), maxPitch),\n fov: Math.min(Math.max(view.fov, minFov), maxFov),\n };\n}\n\nconst focal = (view: PanoramaView, size: PanoramaSize) => size.width / 2 / Math.tan((view.fov * RAD) / 2);\n\nfunction basis(view: PanoramaView) {\n const y = view.yaw * RAD;\n const p = view.pitch * RAD;\n const forward = [Math.cos(p) * Math.sin(y), Math.sin(p), Math.cos(p) * Math.cos(y)] as const;\n const right = [Math.cos(y), 0, -Math.sin(y)] as const;\n const up = [-Math.sin(p) * Math.sin(y), Math.cos(p), -Math.sin(p) * Math.cos(y)] as const;\n return { forward, right, up };\n}\nconst dot = (a: readonly number[], b: readonly number[]) => a[0] * b[0] + a[1] * b[1] + a[2] * b[2];\n\n/** Where the direction (`yaw`, `pitch`) is drawn in the box for `view`, or null when it is behind the camera. */\nexport function project(view: PanoramaView, size: PanoramaSize, yaw: number, pitch: number): PanoramaPoint | null {\n const { forward, right, up } = basis(view);\n const p = pitch * RAD;\n const y = yaw * RAD;\n const d = [Math.cos(p) * Math.sin(y), Math.sin(p), Math.cos(p) * Math.cos(y)] as const;\n const z = dot(d, forward);\n if (z <= 1e-9) return null;\n const f = focal(view, size);\n const x = size.width / 2 + (f * dot(d, right)) / z;\n const yy = size.height / 2 - (f * dot(d, up)) / z;\n return { x, y: yy, inside: x >= 0 && x <= size.width && yy >= 0 && yy <= size.height };\n}\n\n/** The direction under a point of the box for `view`: the inverse of `project`. */\nexport function unproject(\n view: PanoramaView,\n size: PanoramaSize,\n x: number,\n y: number,\n): { yaw: number; pitch: number } {\n const { forward, right, up } = basis(view);\n const f = focal(view, size);\n const a = (x - size.width / 2) / f;\n const b = -(y - size.height / 2) / f;\n const v = [\n forward[0] + a * right[0] + b * up[0],\n forward[1] + a * right[1] + b * up[1],\n forward[2] + a * right[2] + b * up[2],\n ] as const;\n const length = Math.hypot(v[0], v[1], v[2]);\n return {\n yaw: wrapYaw(Math.atan2(v[0], v[2]) * DEG),\n pitch: Math.asin(Math.min(Math.max(v[1] / length, -1), 1)) * DEG,\n };\n}\n\n/** Pixels to degrees at the middle of the box: how far a drag of `px` turns the view. */\nexport const degreesPerPixel = (view: PanoramaView, size: PanoramaSize) => Math.atan(1 / focal(view, size)) * DEG;\n\n/** The flat picture's own mapping, for the fallback with no WebGL: longitude and latitude are straight across and down, the visible rectangle is `fov` wide and as tall as the box's shape makes it. */\nexport function projectFlat(view: PanoramaView, size: PanoramaSize, yaw: number, pitch: number): PanoramaPoint {\n const perPixel = view.fov / size.width;\n const x = size.width / 2 + yawDelta(view.yaw, yaw) / perPixel;\n const y = size.height / 2 - (pitch - view.pitch) / perPixel;\n return { x, y, inside: x >= 0 && x <= size.width && y >= 0 && y <= size.height };\n}\n\n/** The inverse of `projectFlat`. */\nexport function unprojectFlat(\n view: PanoramaView,\n size: PanoramaSize,\n x: number,\n y: number,\n): { yaw: number; pitch: number } {\n const perPixel = view.fov / size.width;\n return {\n yaw: wrapYaw(view.yaw + (x - size.width / 2) * perPixel),\n pitch: Math.min(Math.max(view.pitch - (y - size.height / 2) * perPixel, -90), 90),\n };\n}\n\n/** The direction in words: \"Looking 40° right, 5° up\", \"Looking straight ahead\". Whole degrees; nothing is said for less than half a degree. */\nexport function describeView(view: Pick<PanoramaView, \"yaw\" | \"pitch\">): string {\n const yaw = Math.round(wrapYaw(view.yaw));\n const pitch = Math.round(view.pitch);\n const side = yaw === 0 ? \"\" : yaw === 180 ? \"directly behind\" : `${Math.abs(yaw)}° ${yaw > 0 ? \"right\" : \"left\"}`;\n const tilt = pitch === 0 ? \"\" : `${Math.abs(pitch)}° ${pitch > 0 ? \"up\" : \"down\"}`;\n const parts = [side, tilt].filter(Boolean);\n return parts.length === 0 ? \"Looking straight ahead\" : `Looking ${parts.join(\", \")}`;\n}\n","import * as React from \"react\";\nimport { VisuallyHidden } from \"react-aria\";\nimport { useInView } from \"../lib/in-view\";\nimport { useSettledStatus, useViewPointers, useWheelZoom } from \"../lib/viewer-input\";\nimport { cn } from \"../lib/utils\";\nimport { Slider } from \"../components/value-controls\";\nimport { createRenderer, type PanoramaPicture, type PanoramaRenderer } from \"./gl\";\nimport {\n clampView,\n degreesPerPixel,\n describeView,\n project,\n projectFlat,\n unproject,\n unprojectFlat,\n type PanoramaPoint,\n type PanoramaSize,\n type PanoramaView,\n} from \"./projection\";\n\n// A 360 picture or video as a window you pan and zoom (strata-react issue #178, from strata-360, which\n// drew equirectangular footage with a hand-written WebGL2 shader and its own pointer, transport and\n// frame stepping). This is its own entry (`strata-react/panorama`) so an app that never shows 360 ships\n// no GL code. Nothing else in the package is as far from React Aria's world, so the choices:\n//\n// - **The picture is a canvas, the controls are keys and pointers on a group.** React Aria has no 360\n// view, so the viewer is ours; what it can give, it gives: the field-of-view slider is Strata's\n// `Slider` (React Aria's), and the pointer handling is plain pointer events (React Aria's `usePress`\n// is for a press, not a drag that turns a sphere; checked in its props: it reports a press and its\n// start and end, with no movement).\n// - **It does not own the video.** `video` is a ref to an element the app owns (`useMediaElement`,\n// `Transport`, `SeekBar` and `transportShortcuts` drive it as they drive any video, frame stepping\n// included). The viewer reads each new frame (`requestVideoFrameCallback`, else the element's events\n// and a frame loop while it plays) and uploads it: one texture upload per drawn frame, none for a\n// still picture, and no drawing at all while the viewer is off screen.\n// - **The view is controlled from outside** (`view`/`onViewChange`: yaw, pitch and field of view, in\n// degrees; `defaultView` to let it hold its own). It never animates: a view set from outside is\n// drawn at once, so an app's aim modes (follow a heading, a person, a point) are the app's own\n// function of time, and its pan on top is just another view.\n// - **From the keyboard and by touch, as well as the mouse**: arrow keys pan (Shift for more), `+` and\n// `-` zoom, `0` goes home; a drag pans (the picture follows the pointer), a wheel and a pinch zoom,\n// and a click that did not drag is `onPick` with the direction under it. A field-of-view slider is\n// an option. `maxPitch` stops the view short of the poles, where \"up\" stops meaning anything.\n// - **An overlay in the picture's coordinates**: `overlay` gets `project(yaw, pitch)` (the place in the\n// box, or null behind the camera), `unproject(x, y)` (the direction under a place) and the view, so\n// an app draws markers, aim dots and frame outlines in DOM, where they are text and buttons and take\n// focus. The same maths (projection.ts, with no GL) drives the shader.\n// - **Said in words.** The canvas is an image named by `label` and where it looks (\"Looking 40° right,\n// 5° up\"), always current; a polite status says it once the view has been still for a moment, never\n// per frame.\n// - **No WebGL2, no blank box**: the flat picture is drawn instead, cropped to the same window with the\n// same controls, and a line says so. `project` and `unproject` follow the flat drawing there, so\n// overlay markers still sit on what they mark.\n//\n// A GL context that is lost (a GPU reset, a tab in the background on a phone) is restored without the\n// app doing anything: the picture is sent again and the view redrawn.\n\nexport type PanoramaPictureSource =\n | { image: string; video?: never }\n | { video: React.RefObject<HTMLVideoElement | null>; image?: never };\n\n/** What an overlay is given. */\nexport type PanoramaOverlayApi = {\n view: PanoramaView;\n size: PanoramaSize;\n /** Where the direction is in the box, or null behind the camera. */\n project: (yaw: number, pitch: number) => PanoramaPoint | null;\n /** The direction under a place in the box. */\n unproject: (x: number, y: number) => { yaw: number; pitch: number };\n /** The flat picture is being drawn (no WebGL2). */\n flat: boolean;\n};\n\nexport type PanoramaViewerProps = PanoramaPictureSource & {\n /** Names the viewer: \"360 view of the kitchen\". Required; the current direction is added to it. */\n label: string;\n /** The view, when the app holds it. */\n view?: PanoramaView;\n /** The view the viewer starts with, when it holds its own. Default straight ahead at 90°. */\n defaultView?: PanoramaView;\n /** The view changed (a drag, a key, a wheel, the slider). Not called for a view the app set. */\n onViewChange?: (view: PanoramaView) => void;\n /** A click that did not drag: the direction under it. */\n onPick?: (direction: { yaw: number; pitch: number }) => void;\n /** Highest and lowest look, degrees from the horizon. Default 85. */\n maxPitch?: number;\n /** Narrowest and widest field of view, degrees. Default 20 and 120. */\n minFov?: number;\n maxFov?: number;\n /** Zoom with the wheel. Default true. */\n wheelZoom?: boolean;\n /** Show a field-of-view slider under the picture. */\n fovSlider?: boolean;\n /** Markers and outlines drawn over the picture in its own coordinates. */\n overlay?: (api: PanoramaOverlayApi) => React.ReactNode;\n /** `\"flat\"` draws the flat picture even where WebGL2 is available (a low-power mode, or to see what a browser without it shows). Default `\"auto\"`. */\n mode?: \"auto\" | \"flat\";\n /** The shape of the box. Default 16/9. */\n aspect?: number | `${number}/${number}`;\n className?: string;\n};\n\nconst HOME: PanoramaView = { yaw: 0, pitch: 0, fov: 90 };\nconst STILL_MS = 600;\n\n/** A 360 picture or video as a window you pan and zoom, controlled from outside, with an overlay in the picture's coordinates. */\nexport function PanoramaViewer({\n label,\n image,\n video,\n view: controlled,\n defaultView = HOME,\n onViewChange,\n onPick,\n maxPitch = 85,\n minFov = 20,\n maxFov = 120,\n wheelZoom = true,\n fovSlider = false,\n overlay,\n mode = \"auto\",\n aspect = \"16/9\",\n className,\n}: PanoramaViewerProps) {\n const limits = React.useMemo(() => ({ maxPitch, minFov, maxFov }), [maxPitch, minFov, maxFov]);\n const [own, setOwn] = React.useState(() => clampView(defaultView, limits));\n const view = React.useMemo(() => clampView(controlled ?? own, limits), [controlled, own, limits]);\n const live = React.useRef({ view, controlled: controlled !== undefined, onViewChange, onPick, limits });\n live.current = { view, controlled: controlled !== undefined, onViewChange, onPick, limits };\n const change = React.useCallback((next: PanoramaView) => {\n const l = live.current;\n const clamped = clampView(next, l.limits);\n if (!l.controlled) setOwn(clamped);\n l.onViewChange?.(clamped);\n }, []);\n\n // The box, and the canvas in it.\n const box = React.useRef<HTMLDivElement>(null);\n const canvas = React.useRef<HTMLCanvasElement>(null);\n const [size, setSize] = React.useState<PanoramaSize>({ width: 0, height: 0 });\n React.useLayoutEffect(() => {\n const el = box.current;\n if (!el) return;\n const read = () => {\n const r = el.getBoundingClientRect();\n setSize((s) => (s.width === r.width && s.height === r.height ? s : { width: r.width, height: r.height }));\n };\n read();\n if (typeof ResizeObserver === \"undefined\") return;\n const ro = new ResizeObserver(read);\n ro.observe(el);\n return () => ro.disconnect();\n }, []);\n\n // The picture: a still is loaded once; a video is the app's element.\n const [still, setStill] = React.useState<HTMLImageElement | null>(null);\n React.useEffect(() => {\n if (image === undefined) {\n setStill(null);\n return;\n }\n const img = new Image();\n img.crossOrigin = \"anonymous\";\n let cancelled = false;\n img.onload = () => !cancelled && setStill(img);\n img.src = image;\n return () => {\n cancelled = true;\n img.onload = null;\n };\n }, [image]);\n\n // Drawing: only when something changed, and only while on screen.\n const { ref: visibleRef, inView } = useInView({ unsupported: true });\n // One stable callback: an inline one is called with null and the element on every render, and `useInView` would watch it come and go.\n const boxRef = React.useCallback(\n (el: HTMLDivElement | null) => {\n box.current = el;\n visibleRef(el);\n },\n [visibleRef],\n );\n const renderer = React.useRef<PanoramaRenderer | null>(null);\n const [flat, setFlat] = React.useState(false);\n const frame = React.useRef(0);\n const dirtyPicture = React.useRef(true);\n const current = React.useRef({ size, inView, flat });\n current.current = { size, inView, flat };\n\n const pictureNow = React.useCallback((): PanoramaPicture | null => {\n const v = video?.current;\n if (v) return v.readyState >= 2 && v.videoWidth > 0 ? v : null;\n return still;\n }, [video, still]);\n\n const paint = React.useCallback(() => {\n frame.current = 0;\n const c = canvas.current;\n const { size: s, inView: visible } = current.current;\n if (!c || !visible || s.width === 0 || s.height === 0) return;\n const picture = pictureNow();\n const dpr = Math.min(typeof devicePixelRatio === \"number\" ? devicePixelRatio : 1, 2);\n const w = Math.max(1, Math.round(s.width * dpr));\n const h = Math.max(1, Math.round(s.height * dpr));\n if (current.current.flat) {\n const ctx = c.getContext(\"2d\");\n if (!ctx) return;\n if (c.width !== w || c.height !== h) {\n c.width = w;\n c.height = h;\n }\n ctx.fillStyle = \"#000\";\n ctx.fillRect(0, 0, w, h);\n if (!picture) return;\n const sw = (picture as HTMLImageElement).naturalWidth || (picture as HTMLVideoElement).videoWidth || c.width;\n const sh = (picture as HTMLImageElement).naturalHeight || (picture as HTMLVideoElement).videoHeight || c.height;\n const v = live.current.view;\n const wide = (v.fov / 360) * sw;\n const tall = ((v.fov * (s.height / s.width)) / 180) * sh;\n const left = ((v.yaw - v.fov / 2 + 180) / 360) * sw;\n const top = ((90 - v.pitch) / 180) * sh - tall / 2;\n // Across the seam the window is two pieces of the picture side by side.\n for (const shift of [-sw, 0, sw]) {\n const a = Math.max(left + shift, 0);\n const b = Math.min(left + shift + wide, sw);\n if (b > a)\n ctx.drawImage(\n picture as CanvasImageSource,\n a,\n Math.max(top, 0),\n b - a,\n Math.min(tall, sh),\n ((a - (left + shift)) / wide) * w,\n 0,\n ((b - a) / wide) * w,\n h,\n );\n }\n return;\n }\n const r = renderer.current;\n if (!r) return;\n if (picture && dirtyPicture.current) {\n r.upload(picture);\n dirtyPicture.current = false;\n }\n r.draw(live.current.view, w, h);\n }, [pictureNow]);\n const schedule = React.useCallback(() => {\n if (frame.current === 0) frame.current = requestAnimationFrame(paint);\n }, [paint]);\n\n // The renderer: made once, restored if the context is lost, and the flat picture if there is none.\n React.useEffect(() => {\n const c = canvas.current;\n if (!c) return;\n const make = () => {\n renderer.current?.dispose();\n renderer.current = mode === \"flat\" ? null : createRenderer(c);\n setFlat(renderer.current === null);\n dirtyPicture.current = true;\n schedule();\n };\n make();\n const lost = (e: Event) => {\n e.preventDefault();\n renderer.current = null;\n };\n c.addEventListener(\"webglcontextlost\", lost);\n c.addEventListener(\"webglcontextrestored\", make);\n return () => {\n c.removeEventListener(\"webglcontextlost\", lost);\n c.removeEventListener(\"webglcontextrestored\", make);\n renderer.current?.dispose();\n renderer.current = null;\n if (frame.current) cancelAnimationFrame(frame.current);\n frame.current = 0;\n };\n }, [schedule, mode]);\n\n // A new still, a new size, a new view, or coming into view: draw.\n React.useEffect(() => {\n dirtyPicture.current = true;\n }, [still]);\n React.useEffect(() => {\n schedule();\n }, [schedule, view.yaw, view.pitch, view.fov, size.width, size.height, still, inView, flat]);\n\n // A video: each new frame is one upload and one draw.\n React.useEffect(() => {\n const v = video?.current;\n if (!v || !inView) return;\n let stopped = false;\n let handle = 0;\n const onFrame = () => {\n if (stopped) return;\n dirtyPicture.current = true;\n schedule();\n handle = v.requestVideoFrameCallback(onFrame);\n };\n if (typeof v.requestVideoFrameCallback === \"function\") {\n handle = v.requestVideoFrameCallback(onFrame);\n return () => {\n stopped = true;\n v.cancelVideoFrameCallback?.(handle);\n };\n }\n // No frame callback: the element's own events, and a frame loop while it plays.\n const touch = () => {\n dirtyPicture.current = true;\n schedule();\n };\n const events = [\"loadeddata\", \"seeked\", \"timeupdate\", \"play\", \"pause\"] as const;\n for (const e of events) v.addEventListener(e, touch);\n let loop = 0;\n const tick = () => {\n if (!v.paused) touch();\n loop = requestAnimationFrame(tick);\n };\n loop = requestAnimationFrame(tick);\n return () => {\n for (const e of events) v.removeEventListener(e, touch);\n cancelAnimationFrame(loop);\n };\n }, [video, inView, schedule]);\n\n // Pointer: drag turns the view with the pointer, two pointers pinch, a click that did not drag picks (`useViewPointers`).\n const hostRect = () => box.current!.getBoundingClientRect();\n const pointers = useViewPointers({\n ignore: (e) => e.button !== 0 && e.pointerType === \"mouse\",\n onDrag: (dx, dy) => {\n const v = live.current.view;\n const r = hostRect();\n // The picture follows the pointer: dragging right turns the view left.\n const per = degreesPerPixel(v, { width: r.width, height: r.height });\n change({ ...v, yaw: v.yaw - dx * per, pitch: v.pitch + dy * per });\n },\n onPinch: (ratio) => change({ ...live.current.view, fov: live.current.view.fov * ratio }),\n onTap: (e) => {\n if (!live.current.onPick) return;\n const r = hostRect();\n const s = { width: r.width, height: r.height };\n const x = e.clientX - r.left;\n const y = e.clientY - r.top;\n live.current.onPick(\n current.current.flat ? unprojectFlat(live.current.view, s, x, y) : unproject(live.current.view, s, x, y),\n );\n },\n });\n\n // The wheel zooms; native, because React's wheel listener is passive and the page must not scroll too.\n useWheelZoom(box, (factor) => change({ ...live.current.view, fov: live.current.view.fov * factor }), {\n enabled: wheelZoom,\n });\n\n const onKeyDown = (e: React.KeyboardEvent) => {\n const v = live.current.view;\n const turn = (v.fov / 12) * (e.shiftKey ? 3 : 1);\n if (e.key === \"ArrowLeft\") change({ ...v, yaw: v.yaw - turn });\n else if (e.key === \"ArrowRight\") change({ ...v, yaw: v.yaw + turn });\n else if (e.key === \"ArrowUp\") change({ ...v, pitch: v.pitch + turn });\n else if (e.key === \"ArrowDown\") change({ ...v, pitch: v.pitch - turn });\n else if (e.key === \"+\" || e.key === \"=\") change({ ...v, fov: v.fov * 0.8 });\n else if (e.key === \"-\" || e.key === \"_\") change({ ...v, fov: v.fov * 1.25 });\n else if (e.key === \"0\") change(defaultView);\n else return;\n e.preventDefault();\n };\n\n // Said in words: always on the picture; politely once the view has been still for a moment.\n const direction = describeView(view);\n const said = useSettledStatus(`${direction}, field of view ${Math.round(view.fov)}°`, STILL_MS);\n\n const api: PanoramaOverlayApi = {\n view,\n size,\n flat,\n project: (yaw, pitch) => (flat ? projectFlat(view, size, yaw, pitch) : project(view, size, yaw, pitch)),\n unproject: (x, y) => (flat ? unprojectFlat(view, size, x, y) : unproject(view, size, x, y)),\n };\n const slider = fovSlider ? (\n <Slider\n aria-label=\"Field of view\"\n value={Math.round(view.fov)}\n onChange={(fov) => change({ ...view, fov })}\n min={minFov}\n max={maxFov}\n step={1}\n unit=\"degree\"\n />\n ) : null;\n\n return (\n <div className={cn(\"grid min-w-0 gap-2\", className)}>\n <div\n ref={boxRef}\n role=\"group\"\n aria-label={label}\n aria-describedby={undefined}\n tabIndex={0}\n onKeyDown={onKeyDown}\n onPointerDown={pointers.onPointerDown}\n onPointerMove={pointers.onPointerMove}\n onPointerUp={pointers.onPointerUp}\n onPointerCancel={pointers.onPointerCancel}\n className=\"relative w-full cursor-grab touch-none overflow-hidden rounded-surface bg-surface-sunken select-none active:cursor-grabbing\"\n style={{ aspectRatio: aspect }}\n >\n <canvas\n key={mode === \"flat\" ? \"2d\" : \"gl\"}\n ref={canvas}\n role=\"img\"\n aria-label={`${label}. ${direction}, field of view ${Math.round(view.fov)}°`}\n className=\"absolute inset-0 size-full\"\n />\n {overlay && size.width > 0 && <div className=\"pointer-events-none absolute inset-0\">{overlay(api)}</div>}\n </div>\n {flat && (\n <p className=\"type-body-sm text-muted-foreground\">\n This browser cannot draw the 360 view, so the flat picture is shown. The controls work the same.\n </p>\n )}\n {slider}\n <VisuallyHidden>\n <span role=\"status\">{said}</span>\n </VisuallyHidden>\n </div>\n );\n}\n"],"mappings":";;;;;;;;;AAcA,MAAM,SAAS;;;;AAKf,MAAM,WAAW;;;;;;;;;;;;;;;;;;;;AAoCjB,SAAgB,eAAe,QAAoD;CACjF,MAAM,KAAK,OAAO,WAAW,UAAU;EACrC,WAAW;EACX,uBAAuB;EACvB,OAAO;CACT,CAAC;CACD,IAAI,CAAC,IAAI,OAAO;CAChB,MAAM,WAAW,MAAc,WAAmB;EAChD,MAAM,SAAS,GAAG,aAAa,IAAI;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