strata-react 1.3.24 → 1.3.26
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/UPGRADING.md +7 -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-CXQsL86O.js +16 -0
- 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 +5300 -140
- package/dist/index.js +363 -224
- 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 +54 -109
- 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 +74 -77
- 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-3Qa-o35k.js +108 -0
- package/dist/viewer-input-3Qa-o35k.js.map +1 -0
- 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/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/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/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 -74
- 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":"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"}
|
|
@@ -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,15 +1,17 @@
|
|
|
1
|
-
import { o as useInView } from "./button-
|
|
2
|
-
import { r as
|
|
3
|
-
import { r as
|
|
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";
|
|
4
5
|
import * as React from "react";
|
|
5
6
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
6
7
|
import { VisuallyHidden } from "react-aria";
|
|
8
|
+
|
|
7
9
|
// src/panorama/gl.ts
|
|
8
|
-
|
|
10
|
+
const VERTEX = `#version 300 es
|
|
9
11
|
in vec2 aPos;
|
|
10
12
|
out vec2 vNdc;
|
|
11
13
|
void main() { vNdc = aPos; gl_Position = vec4(aPos, 0.0, 1.0); }`;
|
|
12
|
-
|
|
14
|
+
const FRAGMENT = `#version 300 es
|
|
13
15
|
precision highp float;
|
|
14
16
|
in vec2 vNdc;
|
|
15
17
|
out vec4 outColor;
|
|
@@ -120,16 +122,17 @@ function createRenderer(canvas) {
|
|
|
120
122
|
}
|
|
121
123
|
};
|
|
122
124
|
}
|
|
125
|
+
|
|
123
126
|
// src/panorama/projection.ts
|
|
124
|
-
|
|
125
|
-
|
|
127
|
+
const RAD = Math.PI / 180;
|
|
128
|
+
const DEG = 180 / Math.PI;
|
|
126
129
|
/** Wraps a heading to (-180, 180]. */
|
|
127
130
|
function wrapYaw(yaw) {
|
|
128
131
|
const w = ((yaw + 180) % 360 + 360) % 360 - 180;
|
|
129
132
|
return w === -180 ? 180 : w;
|
|
130
133
|
}
|
|
131
134
|
/** The smallest signed turn from heading `from` to heading `to`, in (-180, 180]. Use it for a difference of headings, never `to - from`. */
|
|
132
|
-
|
|
135
|
+
const yawDelta = (from, to) => wrapYaw(to - from);
|
|
133
136
|
/** Keeps a view inside its limits: heading wrapped, pitch within +-`maxPitch`, field of view within `minFov` to `maxFov`. */
|
|
134
137
|
function clampView(view, { maxPitch = 85, minFov = 20, maxFov = 120 } = {}) {
|
|
135
138
|
return {
|
|
@@ -138,7 +141,7 @@ function clampView(view, { maxPitch = 85, minFov = 20, maxFov = 120 } = {}) {
|
|
|
138
141
|
fov: Math.min(Math.max(view.fov, minFov), maxFov)
|
|
139
142
|
};
|
|
140
143
|
}
|
|
141
|
-
|
|
144
|
+
const focal = (view, size) => size.width / 2 / Math.tan(view.fov * RAD / 2);
|
|
142
145
|
function basis(view) {
|
|
143
146
|
const y = view.yaw * RAD;
|
|
144
147
|
const p = view.pitch * RAD;
|
|
@@ -160,7 +163,7 @@ function basis(view) {
|
|
|
160
163
|
]
|
|
161
164
|
};
|
|
162
165
|
}
|
|
163
|
-
|
|
166
|
+
const dot = (a, b) => a[0] * b[0] + a[1] * b[1] + a[2] * b[2];
|
|
164
167
|
/** Where the direction (`yaw`, `pitch`) is drawn in the box for `view`, or null when it is behind the camera. */
|
|
165
168
|
function project(view, size, yaw, pitch) {
|
|
166
169
|
const { forward, right, up } = basis(view);
|
|
@@ -200,7 +203,7 @@ function unproject(view, size, x, y) {
|
|
|
200
203
|
};
|
|
201
204
|
}
|
|
202
205
|
/** Pixels to degrees at the middle of the box: how far a drag of `px` turns the view. */
|
|
203
|
-
|
|
206
|
+
const degreesPerPixel = (view, size) => Math.atan(1 / focal(view, size)) * DEG;
|
|
204
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. */
|
|
205
208
|
function projectFlat(view, size, yaw, pitch) {
|
|
206
209
|
const perPixel = view.fov / size.width;
|
|
@@ -227,13 +230,14 @@ function describeView(view) {
|
|
|
227
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);
|
|
228
231
|
return parts.length === 0 ? "Looking straight ahead" : `Looking ${parts.join(", ")}`;
|
|
229
232
|
}
|
|
233
|
+
|
|
230
234
|
// src/panorama/panorama-viewer.tsx
|
|
231
|
-
|
|
235
|
+
const HOME = {
|
|
232
236
|
yaw: 0,
|
|
233
237
|
pitch: 0,
|
|
234
238
|
fov: 90
|
|
235
239
|
};
|
|
236
|
-
|
|
240
|
+
const STILL_MS = 600;
|
|
237
241
|
/** A 360 picture or video as a window you pan and zoom, controlled from outside, with an overlay in the picture's coordinates. */
|
|
238
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 }) {
|
|
239
243
|
const limits = React.useMemo(() => ({
|
|
@@ -468,92 +472,42 @@ function PanoramaViewer({ label, image, video, view: controlled, defaultView = H
|
|
|
468
472
|
inView,
|
|
469
473
|
schedule
|
|
470
474
|
]);
|
|
471
|
-
const pointers = React.useRef(/* @__PURE__ */ new Map());
|
|
472
|
-
const gesture = React.useRef(null);
|
|
473
475
|
const hostRect = () => box.current.getBoundingClientRect();
|
|
474
|
-
const
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
x: e.clientX,
|
|
478
|
-
y: e.clientY
|
|
479
|
-
});
|
|
480
|
-
e.currentTarget.setPointerCapture?.(e.pointerId);
|
|
481
|
-
const [first, second] = [...pointers.current.values()];
|
|
482
|
-
const distance = second ? Math.hypot(first.x - second.x, first.y - second.y) : null;
|
|
483
|
-
gesture.current = {
|
|
484
|
-
moved: false,
|
|
485
|
-
pinch: distance,
|
|
486
|
-
start: {
|
|
487
|
-
x: e.clientX,
|
|
488
|
-
y: e.clientY
|
|
489
|
-
}
|
|
490
|
-
};
|
|
491
|
-
e.currentTarget.focus({ preventScroll: true });
|
|
492
|
-
};
|
|
493
|
-
const onPointerMove = (e) => {
|
|
494
|
-
const last = pointers.current.get(e.pointerId);
|
|
495
|
-
if (!last || !gesture.current) return;
|
|
496
|
-
const now = {
|
|
497
|
-
x: e.clientX,
|
|
498
|
-
y: e.clientY
|
|
499
|
-
};
|
|
500
|
-
pointers.current.set(e.pointerId, now);
|
|
501
|
-
const v = live.current.view;
|
|
502
|
-
const s = {
|
|
503
|
-
width: hostRect().width,
|
|
504
|
-
height: hostRect().height
|
|
505
|
-
};
|
|
506
|
-
if (pointers.current.size === 2) {
|
|
507
|
-
const [a, b] = [...pointers.current.values()];
|
|
508
|
-
const d = Math.hypot(a.x - b.x, a.y - b.y);
|
|
509
|
-
if (gesture.current.pinch && d > 0) change({
|
|
510
|
-
...v,
|
|
511
|
-
fov: v.fov * (gesture.current.pinch / d)
|
|
512
|
-
});
|
|
513
|
-
gesture.current.pinch = d;
|
|
514
|
-
gesture.current.moved = true;
|
|
515
|
-
return;
|
|
516
|
-
}
|
|
517
|
-
if (Math.hypot(now.x - gesture.current.start.x, now.y - gesture.current.start.y) > 4) gesture.current.moved = true;
|
|
518
|
-
if (!gesture.current.moved) return;
|
|
519
|
-
const per = degreesPerPixel(v, s);
|
|
520
|
-
change({
|
|
521
|
-
...v,
|
|
522
|
-
yaw: v.yaw - (now.x - last.x) * per,
|
|
523
|
-
pitch: v.pitch + (now.y - last.y) * per
|
|
524
|
-
});
|
|
525
|
-
};
|
|
526
|
-
const onPointerUp = (e) => {
|
|
527
|
-
const g = gesture.current;
|
|
528
|
-
pointers.current.delete(e.pointerId);
|
|
529
|
-
if (pointers.current.size === 0) {
|
|
530
|
-
gesture.current = null;
|
|
531
|
-
if (g && !g.moved && live.current.onPick) {
|
|
532
|
-
const r = hostRect();
|
|
533
|
-
const s = {
|
|
534
|
-
width: r.width,
|
|
535
|
-
height: r.height
|
|
536
|
-
};
|
|
537
|
-
const x = e.clientX - r.left;
|
|
538
|
-
const y = e.clientY - r.top;
|
|
539
|
-
live.current.onPick(current.current.flat ? unprojectFlat(live.current.view, s, x, y) : unproject(live.current.view, s, x, y));
|
|
540
|
-
}
|
|
541
|
-
} else if (g) g.pinch = null;
|
|
542
|
-
};
|
|
543
|
-
React.useEffect(() => {
|
|
544
|
-
const el = box.current;
|
|
545
|
-
if (!el || !wheelZoom) return;
|
|
546
|
-
const onWheel = (e) => {
|
|
547
|
-
e.preventDefault();
|
|
476
|
+
const pointers = useViewPointers({
|
|
477
|
+
ignore: (e) => e.button !== 0 && e.pointerType === "mouse",
|
|
478
|
+
onDrag: (dx, dy) => {
|
|
548
479
|
const v = live.current.view;
|
|
480
|
+
const r = hostRect();
|
|
481
|
+
const per = degreesPerPixel(v, {
|
|
482
|
+
width: r.width,
|
|
483
|
+
height: r.height
|
|
484
|
+
});
|
|
549
485
|
change({
|
|
550
486
|
...v,
|
|
551
|
-
|
|
487
|
+
yaw: v.yaw - dx * per,
|
|
488
|
+
pitch: v.pitch + dy * per
|
|
552
489
|
});
|
|
553
|
-
}
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
490
|
+
},
|
|
491
|
+
onPinch: (ratio) => change({
|
|
492
|
+
...live.current.view,
|
|
493
|
+
fov: live.current.view.fov * ratio
|
|
494
|
+
}),
|
|
495
|
+
onTap: (e) => {
|
|
496
|
+
if (!live.current.onPick) return;
|
|
497
|
+
const r = hostRect();
|
|
498
|
+
const s = {
|
|
499
|
+
width: r.width,
|
|
500
|
+
height: r.height
|
|
501
|
+
};
|
|
502
|
+
const x = e.clientX - r.left;
|
|
503
|
+
const y = e.clientY - r.top;
|
|
504
|
+
live.current.onPick(current.current.flat ? unprojectFlat(live.current.view, s, x, y) : unproject(live.current.view, s, x, y));
|
|
505
|
+
}
|
|
506
|
+
});
|
|
507
|
+
useWheelZoom(box, (factor) => change({
|
|
508
|
+
...live.current.view,
|
|
509
|
+
fov: live.current.view.fov * factor
|
|
510
|
+
}), { enabled: wheelZoom });
|
|
557
511
|
const onKeyDown = (e) => {
|
|
558
512
|
const v = live.current.view;
|
|
559
513
|
const turn = v.fov / 12 * (e.shiftKey ? 3 : 1);
|
|
@@ -586,16 +540,7 @@ function PanoramaViewer({ label, image, video, view: controlled, defaultView = H
|
|
|
586
540
|
e.preventDefault();
|
|
587
541
|
};
|
|
588
542
|
const direction = describeView(view);
|
|
589
|
-
const
|
|
590
|
-
const first = React.useRef(true);
|
|
591
|
-
React.useEffect(() => {
|
|
592
|
-
if (first.current) {
|
|
593
|
-
first.current = false;
|
|
594
|
-
return;
|
|
595
|
-
}
|
|
596
|
-
const t = setTimeout(() => setSaid(`${direction}, field of view ${Math.round(view.fov)}°`), STILL_MS);
|
|
597
|
-
return () => clearTimeout(t);
|
|
598
|
-
}, [direction, view.fov]);
|
|
543
|
+
const said = useSettledStatus(`${direction}, field of view ${Math.round(view.fov)}°`, STILL_MS);
|
|
599
544
|
const api = {
|
|
600
545
|
view,
|
|
601
546
|
size,
|
|
@@ -625,10 +570,10 @@ function PanoramaViewer({ label, image, video, view: controlled, defaultView = H
|
|
|
625
570
|
"aria-describedby": void 0,
|
|
626
571
|
tabIndex: 0,
|
|
627
572
|
onKeyDown,
|
|
628
|
-
onPointerDown,
|
|
629
|
-
onPointerMove,
|
|
630
|
-
onPointerUp,
|
|
631
|
-
onPointerCancel:
|
|
573
|
+
onPointerDown: pointers.onPointerDown,
|
|
574
|
+
onPointerMove: pointers.onPointerMove,
|
|
575
|
+
onPointerUp: pointers.onPointerUp,
|
|
576
|
+
onPointerCancel: pointers.onPointerCancel,
|
|
632
577
|
className: "relative w-full cursor-grab touch-none overflow-hidden rounded-surface bg-surface-sunken select-none active:cursor-grabbing",
|
|
633
578
|
style: { aspectRatio: aspect },
|
|
634
579
|
children: [/* @__PURE__ */ jsx("canvas", {
|
|
@@ -653,6 +598,6 @@ function PanoramaViewer({ label, image, video, view: controlled, defaultView = H
|
|
|
653
598
|
]
|
|
654
599
|
});
|
|
655
600
|
}
|
|
656
|
-
export { PanoramaViewer, clampView, degreesPerPixel, describeView, project, projectFlat, unproject, unprojectFlat, wrapYaw, yawDelta };
|
|
657
601
|
|
|
602
|
+
export { PanoramaViewer, clampView, degreesPerPixel, describeView, project, projectFlat, unproject, unprojectFlat, wrapYaw, yawDelta };
|
|
658
603
|
//# sourceMappingURL=panorama.js.map
|