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.
Files changed (253) hide show
  1. package/README.md +1 -1
  2. package/UPGRADING.md +7 -0
  3. package/dist/{api-types/cli.d.ts → api-types-cli.d.ts} +1 -0
  4. package/dist/api-types-cli.js +4 -3
  5. package/dist/api-types-cli.js.map +1 -1
  6. package/dist/{api-types/generate.d.ts → api-types.d.ts} +3 -3
  7. package/dist/api-types.js +3 -1
  8. package/dist/{button-KGJI6jQr.js → button-CYXjU-fs.js} +8 -5
  9. package/dist/button-CYXjU-fs.js.map +1 -0
  10. package/dist/{cursor-DDGBPiTJ.js → cursor-Cwyvgwsw.js} +9 -7
  11. package/dist/cursor-Cwyvgwsw.js.map +1 -0
  12. package/dist/{errors-BUvY1Z4d.js → errors-CmuwcWlb.js} +6 -6
  13. package/dist/{errors-BUvY1Z4d.js.map → errors-CmuwcWlb.js.map} +1 -1
  14. package/dist/{field-BjeE_FeB.js → field-DBCsFIng.js} +27 -23
  15. package/dist/field-DBCsFIng.js.map +1 -0
  16. package/dist/follow-CXQsL86O.js +16 -0
  17. package/dist/follow-CXQsL86O.js.map +1 -0
  18. package/dist/{generate-CjTHKJ39.js → generate-BkWhh4k4.js} +8 -6
  19. package/dist/generate-BkWhh4k4.js.map +1 -0
  20. package/dist/{lib/geo.d.ts → geo-DfKa9JtK.d.ts} +35 -33
  21. package/dist/{hls/index.d.ts → hls.d.ts} +13 -12
  22. package/dist/hls.js +5 -4
  23. package/dist/hls.js.map +1 -1
  24. package/dist/index.d.ts +5300 -140
  25. package/dist/index.js +363 -224
  26. package/dist/index.js.map +1 -1
  27. package/dist/map.d.ts +184 -0
  28. package/dist/map.js +21 -17
  29. package/dist/map.js.map +1 -1
  30. package/dist/media-player-BETa3P7K.d.ts +758 -0
  31. package/dist/{microphone-Bo3WaXgD.js → microphone-76skMt6i.js} +41 -30
  32. package/dist/microphone-76skMt6i.js.map +1 -0
  33. package/dist/microphone-DDOnQHxf.d.ts +237 -0
  34. package/dist/{migrate/cli.d.ts → migrate-cli.d.ts} +1 -0
  35. package/dist/migrate-cli.js +8 -6
  36. package/dist/migrate-cli.js.map +1 -1
  37. package/dist/panorama.d.ts +102 -0
  38. package/dist/panorama.js +54 -109
  39. package/dist/panorama.js.map +1 -1
  40. package/dist/{run-BT2WKzMz.js → run-D_Ic1jE7.js} +23 -16
  41. package/dist/run-D_Ic1jE7.js.map +1 -0
  42. package/dist/scene.d.ts +147 -0
  43. package/dist/scene.js +74 -77
  44. package/dist/scene.js.map +1 -1
  45. package/dist/testing.d.ts +468 -0
  46. package/dist/testing.js +11 -3
  47. package/dist/testing.js.map +1 -1
  48. package/dist/{theme-CxYZkUNk.js → theme-1oOSMj_D.js} +19 -17
  49. package/dist/theme-1oOSMj_D.js.map +1 -0
  50. package/dist/{tooltip-DhqrDtyu.js → tooltip-BosfsWYh.js} +9 -6
  51. package/dist/tooltip-BosfsWYh.js.map +1 -0
  52. package/dist/types-B3TsF0Ey.d.ts +241 -0
  53. package/dist/{value-controls-Dm_EYfZW.js → value-controls-5u7sD_wG.js} +22 -17
  54. package/dist/value-controls-5u7sD_wG.js.map +1 -0
  55. package/dist/viewer-input-3Qa-o35k.js +108 -0
  56. package/dist/viewer-input-3Qa-o35k.js.map +1 -0
  57. package/dist/{visual/cli.d.ts → visual-cli.d.ts} +2 -1
  58. package/dist/visual-cli.js +5 -4
  59. package/dist/visual-cli.js.map +1 -1
  60. package/dist/visual.d.ts +105 -0
  61. package/dist/visual.js +4 -3
  62. package/dist/visual.js.map +1 -1
  63. package/package.json +24 -19
  64. package/dist/api-types/index.d.ts +0 -1
  65. package/dist/button-KGJI6jQr.js.map +0 -1
  66. package/dist/components/active-list.d.ts +0 -46
  67. package/dist/components/alert.d.ts +0 -17
  68. package/dist/components/app-shell.d.ts +0 -32
  69. package/dist/components/async-button.d.ts +0 -48
  70. package/dist/components/auto-recorder.d.ts +0 -67
  71. package/dist/components/book-viewer.d.ts +0 -50
  72. package/dist/components/box-overlay.d.ts +0 -44
  73. package/dist/components/boxed-picture.d.ts +0 -34
  74. package/dist/components/button.d.ts +0 -45
  75. package/dist/components/byte-view.d.ts +0 -32
  76. package/dist/components/checkbox.d.ts +0 -39
  77. package/dist/components/choice-grid.d.ts +0 -42
  78. package/dist/components/commands.d.ts +0 -104
  79. package/dist/components/compare-audio.d.ts +0 -30
  80. package/dist/components/compare-grid.d.ts +0 -24
  81. package/dist/components/compare-parts.d.ts +0 -90
  82. package/dist/components/compare-regions.d.ts +0 -37
  83. package/dist/components/compare-text.d.ts +0 -32
  84. package/dist/components/compare-video-grid.d.ts +0 -52
  85. package/dist/components/compare-video.d.ts +0 -61
  86. package/dist/components/compare.d.ts +0 -90
  87. package/dist/components/composition.d.ts +0 -44
  88. package/dist/components/console.d.ts +0 -34
  89. package/dist/components/conversation.d.ts +0 -83
  90. package/dist/components/cursor.d.ts +0 -44
  91. package/dist/components/data-table.d.ts +0 -89
  92. package/dist/components/data-view.d.ts +0 -66
  93. package/dist/components/density.d.ts +0 -16
  94. package/dist/components/dialog.d.ts +0 -45
  95. package/dist/components/difference.d.ts +0 -19
  96. package/dist/components/disclosure.d.ts +0 -49
  97. package/dist/components/done.d.ts +0 -14
  98. package/dist/components/drag-source.d.ts +0 -29
  99. package/dist/components/field.d.ts +0 -79
  100. package/dist/components/file-intake.d.ts +0 -60
  101. package/dist/components/film-strip.d.ts +0 -35
  102. package/dist/components/folder-picker.d.ts +0 -59
  103. package/dist/components/fullscreen-frame.d.ts +0 -18
  104. package/dist/components/history.d.ts +0 -61
  105. package/dist/components/hotkeys.d.ts +0 -44
  106. package/dist/components/infinite-list.d.ts +0 -77
  107. package/dist/components/inspector.d.ts +0 -66
  108. package/dist/components/job-action.d.ts +0 -30
  109. package/dist/components/job-status.d.ts +0 -55
  110. package/dist/components/jobs-table.d.ts +0 -35
  111. package/dist/components/key-glyphs.d.ts +0 -5
  112. package/dist/components/key-owner.d.ts +0 -11
  113. package/dist/components/lightbox.d.ts +0 -61
  114. package/dist/components/line-chart.d.ts +0 -169
  115. package/dist/components/link-card.d.ts +0 -32
  116. package/dist/components/link.d.ts +0 -54
  117. package/dist/components/markable-text.d.ts +0 -60
  118. package/dist/components/media-contents.d.ts +0 -28
  119. package/dist/components/media-group.d.ts +0 -32
  120. package/dist/components/media-player.d.ts +0 -251
  121. package/dist/components/media-progress.d.ts +0 -17
  122. package/dist/components/media-skip.d.ts +0 -31
  123. package/dist/components/media-spans.d.ts +0 -93
  124. package/dist/components/media.d.ts +0 -133
  125. package/dist/components/meter.d.ts +0 -32
  126. package/dist/components/metric.d.ts +0 -17
  127. package/dist/components/outbox-status.d.ts +0 -10
  128. package/dist/components/page-header.d.ts +0 -14
  129. package/dist/components/pair-vote.d.ts +0 -70
  130. package/dist/components/pause-button.d.ts +0 -7
  131. package/dist/components/pixel-image.d.ts +0 -29
  132. package/dist/components/place-board.d.ts +0 -39
  133. package/dist/components/player-warning.d.ts +0 -24
  134. package/dist/components/popover.d.ts +0 -20
  135. package/dist/components/recorder.d.ts +0 -73
  136. package/dist/components/region-editor.d.ts +0 -67
  137. package/dist/components/save.d.ts +0 -46
  138. package/dist/components/say-again.d.ts +0 -13
  139. package/dist/components/schedule-table.d.ts +0 -24
  140. package/dist/components/secret-field.d.ts +0 -34
  141. package/dist/components/selectable-grid.d.ts +0 -57
  142. package/dist/components/selection.d.ts +0 -104
  143. package/dist/components/sequence-timeline.d.ts +0 -50
  144. package/dist/components/shortcut-editor.d.ts +0 -44
  145. package/dist/components/sortable-list.d.ts +0 -39
  146. package/dist/components/status.d.ts +0 -9
  147. package/dist/components/switch.d.ts +0 -15
  148. package/dist/components/system-panel.d.ts +0 -58
  149. package/dist/components/tabs.d.ts +0 -16
  150. package/dist/components/theme.d.ts +0 -106
  151. package/dist/components/thumbnail.d.ts +0 -50
  152. package/dist/components/tile-grid.d.ts +0 -67
  153. package/dist/components/timeline-player.d.ts +0 -18
  154. package/dist/components/timeline.d.ts +0 -115
  155. package/dist/components/toast.d.ts +0 -36
  156. package/dist/components/toggle.d.ts +0 -51
  157. package/dist/components/toolbar.d.ts +0 -15
  158. package/dist/components/tooltip.d.ts +0 -19
  159. package/dist/components/transcript-view.d.ts +0 -63
  160. package/dist/components/tree.d.ts +0 -74
  161. package/dist/components/undo.d.ts +0 -63
  162. package/dist/components/use-timeline.d.ts +0 -44
  163. package/dist/components/value-controls.d.ts +0 -91
  164. package/dist/components/video-clock.d.ts +0 -68
  165. package/dist/components/view-options.d.ts +0 -105
  166. package/dist/components/viewport.d.ts +0 -85
  167. package/dist/components/virtual-list.d.ts +0 -19
  168. package/dist/components/waveform.d.ts +0 -71
  169. package/dist/components/workflow-steps.d.ts +0 -71
  170. package/dist/components/workspace.d.ts +0 -83
  171. package/dist/cursor-DDGBPiTJ.js.map +0 -1
  172. package/dist/field-BjeE_FeB.js.map +0 -1
  173. package/dist/generate-CjTHKJ39.js.map +0 -1
  174. package/dist/lib/base.d.ts +0 -10
  175. package/dist/lib/book.d.ts +0 -25
  176. package/dist/lib/boxes.d.ts +0 -55
  177. package/dist/lib/breakpoint.d.ts +0 -4
  178. package/dist/lib/choice.d.ts +0 -29
  179. package/dist/lib/chords.d.ts +0 -20
  180. package/dist/lib/client-work.d.ts +0 -24
  181. package/dist/lib/control.d.ts +0 -4
  182. package/dist/lib/dev.d.ts +0 -2
  183. package/dist/lib/errors.d.ts +0 -43
  184. package/dist/lib/file-intake.d.ts +0 -60
  185. package/dist/lib/format.d.ts +0 -243
  186. package/dist/lib/grouped-grid-layout.d.ts +0 -44
  187. package/dist/lib/icon.d.ts +0 -6
  188. package/dist/lib/image-diff.d.ts +0 -30
  189. package/dist/lib/in-view.d.ts +0 -21
  190. package/dist/lib/loudness.d.ts +0 -18
  191. package/dist/lib/marks.d.ts +0 -6
  192. package/dist/lib/microphone.d.ts +0 -24
  193. package/dist/lib/number-input.d.ts +0 -4
  194. package/dist/lib/object-url.d.ts +0 -2
  195. package/dist/lib/overlay.d.ts +0 -1
  196. package/dist/lib/recording.d.ts +0 -16
  197. package/dist/lib/region.d.ts +0 -64
  198. package/dist/lib/rich-text.d.ts +0 -44
  199. package/dist/lib/search-param.d.ts +0 -16
  200. package/dist/lib/segmenter.d.ts +0 -40
  201. package/dist/lib/sequence.d.ts +0 -34
  202. package/dist/lib/speech.d.ts +0 -53
  203. package/dist/lib/text-diff.d.ts +0 -16
  204. package/dist/lib/timeline.d.ts +0 -14
  205. package/dist/lib/transcript.d.ts +0 -53
  206. package/dist/lib/utils.d.ts +0 -4
  207. package/dist/lib/viewport.d.ts +0 -55
  208. package/dist/lib/waveform.d.ts +0 -46
  209. package/dist/map/fan.d.ts +0 -15
  210. package/dist/map/index.d.ts +0 -3
  211. package/dist/map/map-styles.d.ts +0 -2
  212. package/dist/map/markers.d.ts +0 -60
  213. package/dist/map/route-map.d.ts +0 -146
  214. package/dist/microphone-Bo3WaXgD.js.map +0 -1
  215. package/dist/migrate/stock-classes.d.ts +0 -11
  216. package/dist/panorama/gl.d.ts +0 -16
  217. package/dist/panorama/index.d.ts +0 -2
  218. package/dist/panorama/panorama-viewer.d.ts +0 -56
  219. package/dist/panorama/projection.d.ts +0 -45
  220. package/dist/query/api.d.ts +0 -23
  221. package/dist/query/clips.d.ts +0 -48
  222. package/dist/query/index.d.ts +0 -55
  223. package/dist/query/infinite.d.ts +0 -60
  224. package/dist/query/job.d.ts +0 -26
  225. package/dist/query/outbox.d.ts +0 -85
  226. package/dist/query/poll.d.ts +0 -24
  227. package/dist/query/reserve.d.ts +0 -33
  228. package/dist/query/typed-api.d.ts +0 -84
  229. package/dist/query/workflow.d.ts +0 -17
  230. package/dist/run-BT2WKzMz.js.map +0 -1
  231. package/dist/scene/camera.d.ts +0 -74
  232. package/dist/scene/index.d.ts +0 -2
  233. package/dist/scene/scene-viewport.d.ts +0 -48
  234. package/dist/testing/buttons.d.ts +0 -7
  235. package/dist/testing/index.d.ts +0 -161
  236. package/dist/testing/intersection-observer.d.ts +0 -34
  237. package/dist/testing/layout.d.ts +0 -13
  238. package/dist/testing/microphone.d.ts +0 -35
  239. package/dist/testing/setup.d.ts +0 -14
  240. package/dist/testing/speech.d.ts +0 -38
  241. package/dist/testing/storage.d.ts +0 -7
  242. package/dist/theme-CxYZkUNk.js.map +0 -1
  243. package/dist/tooltip-DhqrDtyu.js.map +0 -1
  244. package/dist/value-controls-Dm_EYfZW.js.map +0 -1
  245. package/dist/visual/capture.d.ts +0 -37
  246. package/dist/visual/compare.d.ts +0 -46
  247. package/dist/visual/drop.d.ts +0 -19
  248. package/dist/visual/fonts.d.ts +0 -18
  249. package/dist/visual/index.d.ts +0 -19
  250. package/dist/visual/run.d.ts +0 -22
  251. package/dist/visual/serve.d.ts +0 -13
  252. package/dist/visual/targets.d.ts +0 -17
  253. package/dist/visual/types.d.ts +0 -188
@@ -0,0 +1 @@
1
+ {"version":3,"file":"field-DBCsFIng.js","names":["Input"],"sources":["../src/lib/format.ts","../src/lib/search-param.ts","../src/lib/control.ts","../src/components/field.tsx"],"sourcesContent":["// Every number and date on screen goes through Intl, once, here. Units are joined with a\n// non-breaking space so \"212 °C\" never wraps between figure and unit. A product that is not\n// en-GB calls createFormat with its locale once and exports the result from its own lib.\n//\n// The number formatters are callable (`format.integer(n)`) because that is the form people reach\n// for (strata-react issue #12), and they keep Intl's methods (`format.integer.format(n)`,\n// `formatToParts`, `resolvedOptions`) so existing calls and Intl knowledge still work.\n//\n// Dates follow the same shape. Every date formatter is callable with a Date, an ISO string or\n// epoch milliseconds (`format.dateTime(row.at)`), because rows arrive from an API as ISO strings\n// and an app that has to wrap each one in `new Date(...)` soon builds its own Intl.DateTimeFormat\n// beside it instead (strata-react issue #31, from the Bright Horizons History screen). An invalid\n// date throws a RangeError naming the input rather than printing \"Invalid Date\" into a row.\n// `date` and `dateTime` use Intl's medium/short styles, so the locale decides the order\n// (\"8 Nov 2026, 06:05\" in en-GB, \"Nov 8, 2026, 6:05 AM\" in en-US) and nobody hand-writes a\n// pattern. `timeZone` is optional: left out, times are the viewer's; a product that shows a place's\n// times (a kiln in one room, a shop's opening hours) passes that place's zone once.\n//\n// Tests: the non-breaking space is a real character in the DOM. Testing Library's text matchers\n// (`getByText`, `toHaveTextContent`) collapse whitespace and match \"6 pieces\", but accessible-name\n// matching (`getByRole(\"heading\", { name: \"6 pieces\" })`) compares the name exactly and does not.\n// Build the expected string with the same formatter (`{ name: format.count(6, \"piece\") }`), or\n// use a regex with `\\s` (`/6\\spieces/`), which matches U+00A0.\n//\n// A value that is not known (`null` or `undefined`: a count the source does not give, a date for\n// something never synced) prints as the placeholder, an en dash unless `createFormat`'s `missing`\n// says otherwise, from every number and date formatter (strata-react issue #47). Each screen used\n// to pick its own (\"–\", \"Never\", blank), so tables and cards disagreed. An invalid date still\n// throws: that is a bug, not a missing value.\n//\n// Three formatters came from the Tubes viewer, which wrote its own (strata-react issue #52): `ago`\n// (\"3 weeks ago\", from Intl.RelativeTimeFormat, with `now` passed in by tests), `compact` (\"1.2k\"\n// in en-GB, and `count`'s `{ compact: true }` for \"1.2k views\") and `runningTime` (\"4:05\", \"1:02:09\"), the\n// m:ss of a media player, which Intl.DurationFormat's long form is not. `share` is `percent` for a\n// part of a whole (strata-react issue #43): a part that is there never prints as \"0%\", nor a part\n// short of the whole as \"100%\".\n//\n// Four more came from a status page (strata-react issue #341, jburnhams/homepage), each written by\n// hand there because `format` had no equivalent: `bytes` in binary units (`{ binary: true }`:\n// memory is read in KiB, MiB, GiB, and `free -h` shows them, so a decimal GB reads 7% high);\n// `duration` (\"16 min\", \"3.5 h\", \"2 days\" to say how long, or `style: \"parts\"` for an uptime,\n// \"1d 1h 0m\"), which `runningTime`'s clock cannot say; `measure` (a reading and its unit, \"12.3 GB\",\n// \"41%\"); and `agoTick` (\"now\", \"−30 s\", \"−2 min\") for the axis of a history chart.\n\nexport const NBSP = \" \";\n\n/** The placeholder printed for a value that is not known: an en dash. */\nexport const MISSING = \"–\";\n\n/** The decimal byte units `format.bytes` writes. */\nexport type ByteUnit = \"B\" | \"kB\" | \"MB\" | \"GB\" | \"TB\" | \"PB\";\nconst BYTE_UNITS: readonly ByteUnit[] = [\"B\", \"kB\", \"MB\", \"GB\", \"TB\", \"PB\"];\nconst BYTE_SIZE = Object.fromEntries(BYTE_UNITS.map((u, i) => [u, 1000 ** i])) as Record<ByteUnit, number>;\n\n/** The binary byte units `format.bytes` writes with `{ binary: true }`. */\nexport type BinaryByteUnit = \"B\" | \"KiB\" | \"MiB\" | \"GiB\" | \"TiB\" | \"PiB\";\nconst BINARY_UNITS: readonly BinaryByteUnit[] = [\"B\", \"KiB\", \"MiB\", \"GiB\", \"TiB\", \"PiB\"];\nconst BINARY_SIZE = Object.fromEntries(BINARY_UNITS.map((u, i) => [u, 1024 ** i])) as Record<BinaryByteUnit, number>;\nconst SIZE: Record<ByteUnit | BinaryByteUnit, number> = { ...BYTE_SIZE, ...BINARY_SIZE };\n\n/** What `format.bytes` and `format.byteUnit` take beyond the value: `{ binary: true }` for KiB, MiB, GiB (powers of 1024), or a unit to fix. A binary unit implies binary. */\nexport type BytesOptions = { binary?: boolean; unit?: ByteUnit | BinaryByteUnit };\n\nfunction chooseByteUnit(value: number, binary: boolean): ByteUnit | BinaryByteUnit {\n const units: readonly (ByteUnit | BinaryByteUnit)[] = binary ? BINARY_UNITS : BYTE_UNITS;\n return [...units].reverse().find((u) => Math.abs(value) >= SIZE[u]) ?? \"B\";\n}\n\n/** An `Intl.NumberFormat` that can also be called directly: `f(n)` is `f.format(n)`. `null` or `undefined` prints the placeholder. */\nexport type NumberFormatter = ((value: number | bigint | Intl.StringNumericLiteral | null | undefined) => string) & {\n format: (value: number | bigint | Intl.StringNumericLiteral | null | undefined) => string;\n} & Pick<Intl.NumberFormat, \"formatToParts\" | \"resolvedOptions\">;\n\n/** What a date formatter accepts: a Date, an ISO 8601 string, or epoch milliseconds. */\nexport type DateInput = Date | string | number;\n\n/** An `Intl.DateTimeFormat` that can also be called directly, with a Date, an ISO string or epoch milliseconds. */\nexport type DateFormatter = ((value: DateInput | null | undefined) => string) & {\n format: (value: DateInput | null | undefined) => string;\n formatToParts: (value: DateInput) => Intl.DateTimeFormatPart[];\n formatRange: (start: DateInput, end: DateInput) => string;\n} & Pick<Intl.DateTimeFormat, \"resolvedOptions\">;\n\n/** Options shared by every date formatter one `createFormat` call makes. */\nexport interface FormatOptions {\n /** An IANA zone (\"Europe/London\", \"UTC\") to show times in. Left out, times are the viewer's own. */\n timeZone?: string;\n /** What a missing value (`null`, `undefined`) prints as. Default an en dash (`MISSING`). */\n missing?: string;\n}\n\n/** Options for `format.count`. */\nexport interface CountOptions {\n /** Write the figure compactly: \"1.2k views\". The noun still agrees with the exact count. */\n compact?: boolean;\n}\n\n/** A Date from a Date, an ISO string or epoch milliseconds; throws a RangeError naming the input when it is not a date. */\nexport function toDate(value: DateInput): Date {\n const date = value instanceof Date ? value : new Date(value);\n if (Number.isNaN(date.getTime())) throw new RangeError(`Not a date: ${JSON.stringify(String(value))}`);\n return date;\n}\n\nfunction callableDate(df: Intl.DateTimeFormat, missing: string): DateFormatter {\n const format = (value: DateInput | null | undefined) => (value == null ? missing : df.format(toDate(value)));\n return Object.assign(format, {\n format,\n formatToParts: (value: DateInput) => df.formatToParts(toDate(value)),\n formatRange: (start: DateInput, end: DateInput) => df.formatRange(toDate(start), toDate(end)),\n resolvedOptions: () => df.resolvedOptions(),\n });\n}\n\nfunction callable(nf: Intl.NumberFormat, missing: string): NumberFormatter {\n const format = (value: number | bigint | Intl.StringNumericLiteral | null | undefined) =>\n value == null ? missing : nf.format(value);\n return Object.assign(format, {\n format,\n formatToParts: (value: number | bigint) => nf.formatToParts(value),\n resolvedOptions: () => nf.resolvedOptions(),\n });\n}\n\n// Largest first: `ago` says a span in the largest unit it fills at least once, rounded down, so\n// 13 days is \"last week\" and 20 days \"2 weeks ago\", never \"3 weeks\" too early.\nconst DAY = 86_400_000;\nconst AGO_STEPS: readonly [Intl.RelativeTimeFormatUnit, number][] = [\n [\"year\", 365 * DAY],\n [\"month\", 30 * DAY],\n [\"week\", 7 * DAY],\n [\"day\", DAY],\n [\"hour\", 3_600_000],\n [\"minute\", 60_000],\n];\n\n/** Intl formatters for one locale (and optionally one time zone): integers, decimals, percent, dates, times, units with a non-breaking space, byte sizes, and counted nouns. */\nexport function createFormat(locale: string, options: FormatOptions = {}) {\n const { timeZone, missing = MISSING } = options;\n const dates = (opts: Intl.DateTimeFormatOptions) =>\n callableDate(new Intl.DateTimeFormat(locale, { ...opts, timeZone }), missing);\n const integer = callable(new Intl.NumberFormat(locale, { maximumFractionDigits: 0 }), missing);\n const decimal = callable(new Intl.NumberFormat(locale, { maximumFractionDigits: 1 }), missing);\n const percent = callable(new Intl.NumberFormat(locale, { style: \"percent\", maximumFractionDigits: 0 }), missing);\n const compact = callable(new Intl.NumberFormat(locale, { notation: \"compact\", maximumFractionDigits: 1 }), missing);\n const relative = new Intl.RelativeTimeFormat(locale, { numeric: \"auto\" });\n const plurals = new Intl.PluralRules(locale);\n const clock = dates({ hour: \"2-digit\", minute: \"2-digit\" });\n const day = dates({ weekday: \"long\", day: \"numeric\", month: \"long\" });\n const shortDay = dates({ weekday: \"short\", hour: \"2-digit\", minute: \"2-digit\" });\n const date = dates({ dateStyle: \"medium\" });\n const dateTime = dates({ dateStyle: \"medium\", timeStyle: \"short\" });\n const withUnit = (value: number, unit: string, fmt: Pick<Intl.NumberFormat, \"format\"> = integer) =>\n `${fmt.format(value)}${NBSP}${unit}`;\n return {\n locale,\n /** The zone times are shown in, or `undefined` for the viewer's own. */\n timeZone,\n /** Whole numbers with grouping: `format.integer(1222)` is \"1,222\". */\n integer,\n /** One decimal place at most: `format.decimal(3.14)` is \"3.1\". */\n decimal,\n /** A ratio as a whole percent: `format.percent(0.42)` is \"42%\". */\n percent,\n /**\n * A part's share of a whole, as `percent` but never misleading at the ends: a part above 0 that\n * rounds to 0 is \"<1%\", and one short of the whole that rounds to 100 is \">99%\".\n * `format.share(2.4 / 512)` is \"<1%\".\n */\n share: (value: number | null | undefined) => {\n if (value == null || Number.isNaN(value)) return missing;\n if (value > 0 && value < 0.005) return `<${percent.format(0.01)}`;\n if (value >= 0.995 && value < 1) return `>${percent.format(0.99)}`;\n return percent.format(value);\n },\n /** A figure in short form for counts that run to thousands: `format.compact(1234)` is \"1.2k\" in en-GB, \"1.2K\" in en-US. */\n compact,\n /**\n * How long ago (or how far ahead) a time is, in the largest unit it reaches:\n * \"3 weeks ago\", \"yesterday\", \"in 2 hours\", \"now\" under a minute. Pass `now` in tests.\n */\n ago: (value: DateInput | null | undefined, now: DateInput = new Date()) => {\n if (value == null) return missing;\n const diff = toDate(value).getTime() - toDate(now).getTime();\n const span = Math.abs(diff);\n for (const [unit, size] of AGO_STEPS) {\n if (span >= size) return relative.format(Math.sign(diff) * Math.floor(span / size), unit);\n }\n return relative.format(0, \"second\");\n },\n /**\n * A media running time from seconds, as a player shows it: \"4:05\", \"1:02:09\". Unknown\n * (null, negative, not finite) prints the placeholder. Set it in `tabular-nums`.\n */\n runningTime: (seconds: number | null | undefined) => {\n if (seconds == null || !Number.isFinite(seconds) || seconds < 0) return missing;\n const s = Math.floor(seconds);\n const two = (n: number) => String(n).padStart(2, \"0\");\n const [h, m] = [Math.floor(s / 3600), Math.floor((s % 3600) / 60)];\n return h > 0 ? `${h}:${two(m)}:${two(s % 60)}` : `${m}:${two(s % 60)}`;\n },\n /**\n * A position in media as an editor shows it, to a chosen precision: \"4:05\" (seconds), \"4:05.250\"\n * (`\"ms\"`), or \"0:04:05:07\" (`\"frames\"` at `fps`, the last part the frame). Hours appear only\n * from one hour, except in frames. Frames are always four parts, hours included, as SMPTE\n * timecode is (non-drop frame, with colons): a three-part \"1:05:00\" reads as one hour five, so\n * a frame count must never be three. Editors write the same four parts (strata-react issue\n * #122). Floors, never rounds up, so a time never reads ahead of the picture. Unknown (null,\n * negative, not finite) prints the placeholder. Set it in `tabular-nums`.\n */\n timecode: (\n seconds: number | null | undefined,\n { precision = \"seconds\", fps = 30 }: { precision?: \"seconds\" | \"ms\" | \"frames\"; fps?: number } = {},\n ) => {\n if (seconds == null || !Number.isFinite(seconds) || seconds < 0) return missing;\n const whole = Math.floor(seconds);\n const two = (n: number) => String(n).padStart(2, \"0\");\n const [h, m] = [Math.floor(whole / 3600), Math.floor((whole % 3600) / 60)];\n const base = h > 0 ? `${h}:${two(m)}:${two(whole % 60)}` : `${m}:${two(whole % 60)}`;\n if (precision === \"ms\")\n return `${base}.${String(Math.min(Math.floor((seconds - whole) * 1000 + 1e-6), 999)).padStart(3, \"0\")}`;\n if (precision === \"frames\")\n return `${h}:${two(m)}:${two(whole % 60)}:${two(Math.min(Math.floor((seconds - whole) * fps + 1e-6), Math.ceil(fps) - 1))}`;\n return base;\n },\n /** What a missing value prints as: an en dash unless `createFormat`'s `missing` says otherwise. */\n missing,\n /** A time of day: `format.clock(at)` is \"06:05\". */\n clock,\n /** A day without its year, for this week's things: `format.day(at)` is \"Sunday 8 November\". */\n day,\n /** A weekday and time, for chart axes and recent rows: `format.shortDay(at)` is \"Sun 06:05\". */\n shortDay,\n /** A date with its year, for a record or a deadline: `format.date(at)` is \"8 Nov 2026\". */\n date,\n /** A date and time, for a log or history row: `format.dateTime(at)` is \"8 Nov 2026, 06:05\". */\n dateTime,\n /** A figure and its unit joined by a non-breaking space (`NBSP`), so they never wrap apart. */\n withUnit,\n /** A temperature in °C, joined by a non-breaking space. */\n celsius: (value: number) => withUnit(value, \"°C\"),\n /**\n * A size in bytes in the largest decimal unit it reaches (kB, MB, GB, TB, as disks and\n * networks are sold): one decimal below 10 (\"5.2 GB\"), whole above (\"431 GB\"). Pass `unit`\n * to fix the unit, so figures compared side by side (\"431 of 466 GB\") share one. Memory is\n * read in binary units: `{ binary: true }` writes KiB, MiB, GiB (\"7.6 GiB\"), and a binary\n * unit (\"GiB\") picks that too. The second argument is a unit or `{ binary, unit }`.\n */\n bytes: (value: number, unitOrOptions?: ByteUnit | BinaryByteUnit | BytesOptions) => {\n const { binary = false, unit } =\n typeof unitOrOptions === \"string\" ? { unit: unitOrOptions } : (unitOrOptions ?? {});\n const chosen = unit ?? chooseByteUnit(value, binary);\n const scaled = value / SIZE[chosen];\n return withUnit(scaled, chosen, Math.abs(scaled) < 10 && chosen !== \"B\" ? decimal : integer);\n },\n /**\n * A length of time in words, the unit chosen by size: \"45 s\", \"16 min\", \"3.5 h\", \"2 days\". Unknown\n * (null, negative, not finite) prints the placeholder. `style: \"parts\"` is an uptime, the two\n * largest units written out: \"1d 1h 0m\", \"2h 5m\", \"5m 3s\". Not `runningTime`, which is a media clock.\n */\n duration: (seconds: number | null | undefined, { style = \"approx\" }: { style?: \"approx\" | \"parts\" } = {}) => {\n if (seconds == null || !Number.isFinite(seconds) || seconds < 0) return missing;\n if (style === \"parts\") {\n const s = Math.floor(seconds);\n const [d, h, m] = [Math.floor(s / 86400), Math.floor((s % 86400) / 3600), Math.floor((s % 3600) / 60)];\n if (d > 0) return `${d}d${NBSP}${h}h${NBSP}${m}m`;\n if (h > 0) return `${h}h${NBSP}${m}m`;\n if (m > 0) return `${m}m${NBSP}${s % 60}s`;\n return `${s}s`;\n }\n if (seconds < 60) return withUnit(Math.floor(seconds), \"s\");\n if (seconds < 3600) return withUnit(Math.floor(seconds / 60), \"min\");\n if (seconds < 86400) return withUnit(seconds / 3600, \"h\", decimal);\n const days = seconds / 86400;\n return withUnit(days, plurals.select(Math.round(days * 10) / 10) === \"one\" ? \"day\" : \"days\", decimal);\n },\n /**\n * A reading and its unit: `format.measure(12.34, \"GB\")` is \"12.3 GB\" (one decimal at most, a\n * non-breaking space). `\"%\"` takes the figure as percent points and goes through `percent`, so\n * the locale decides the spacing: `format.measure(41, \"%\")` is \"41%\". Unknown prints the placeholder.\n */\n measure: (value: number | null | undefined, unit: string) =>\n value == null ? missing : unit === \"%\" ? percent.format(value / 100) : withUnit(value, unit, decimal),\n /**\n * A tick for the axis of a chart of the past, from seconds before now: \"now\", \"−30 s\", \"−2 min\",\n * \"−6 h\", \"−3 d\" (a true minus sign). Pass it as `LineChart`'s `formatX` after turning x into seconds ago.\n */\n agoTick: (secondsAgo: number | null | undefined) => {\n if (secondsAgo == null || !Number.isFinite(secondsAgo)) return missing;\n const s = Math.abs(secondsAgo);\n if (s < 1) return \"now\";\n const [n, unit] = s < 60 ? [s, \"s\"] : s < 3600 ? [s / 60, \"min\"] : s < 86400 ? [s / 3600, \"h\"] : [s / 86400, \"d\"];\n return `−${integer.format(n)}${NBSP}${unit}`;\n },\n /**\n * A distance in metres as a person says it: metres under a kilometre (\"850 m\"), then\n * kilometres, one decimal below 100 (\"12.4 km\"), whole above; `\"imperial\"` is feet under a\n * tenth of a mile (\"320 ft\"), then miles (\"7.7 mi\").\n */\n distance: (metres: number, system: \"metric\" | \"imperial\" = \"metric\") => {\n if (system === \"imperial\") {\n const miles = metres / 1609.344;\n return miles < 0.1 ? withUnit(metres * 3.28084, \"ft\") : withUnit(miles, \"mi\", miles < 100 ? decimal : integer);\n }\n return Math.abs(metres) < 1000\n ? withUnit(metres, \"m\")\n : withUnit(metres / 1000, \"km\", Math.abs(metres) < 100_000 ? decimal : integer);\n },\n /** The unit `bytes` would choose for a value, to share it across a set of figures. */\n byteUnit: (value: number, { binary = false }: { binary?: boolean } = {}) => chooseByteUnit(value, binary),\n /**\n * \"1 piece\", \"6 pieces\": the count and its noun, so copy never reads \"1 pieces\". They are\n * joined by a non-breaking space (`NBSP`), not a plain one: in a test, match with the same\n * call or a `\\s` regex, not a typed \"6 pieces\" string in a role's `name`.\n */\n count: (\n value: number | null | undefined,\n one: string,\n many = `${one}s`,\n { compact: short = false }: CountOptions = {},\n ) =>\n value == null\n ? missing\n : `${(short ? compact : integer).format(value)}${NBSP}${plurals.select(value) === \"one\" ? one : many}`,\n };\n}\n\nexport type Format = ReturnType<typeof createFormat>;\n\n/** The en-GB formatters. */\nexport const format = createFormat(\"en-GB\");\n","import * as React from \"react\";\nimport { useSearchParams } from \"react-router\";\n\n// \"Anything a person would link or reload into (tab, sort, filter, page, open item) is in the URL.\"\n// Tabs (`param=`), DataTable (`sortParam`) and `useExpanded({ param })` already do; a plain filter or\n// choice did not, so each app wrote the same `setParams(p => { new URLSearchParams(p) … })` (#297).\n// Rules fixed here once: the default is never written (the plain URL stays plain, as `Tabs` does),\n// a value that does not parse reads as the default (a stale or hand-edited link must not break the\n// screen), other params are kept, and a filter replaces the history entry (Back leaves the screen,\n// it does not walk through every filter change; `replace: false` for a choice worth a Back step).\n\n/** Options of `useSearchParam`. */\nexport type SearchParamOptions<T extends string> = {\n /** Read when the param is missing or invalid; setting it removes the param. */\n default: T;\n /** Says whether a raw value is allowed: a type guard (`isMode`), or a function that returns the typed value or `undefined`. */\n parse?: (raw: string) => T | boolean | undefined;\n /** Replace the history entry instead of adding one. Default `true`, since most params are filters. */\n replace?: boolean;\n};\n\n/** What `useSearchParam` returns: the value, and a setter that takes the next value or `null` for the default. */\nexport type SearchParam<T extends string> = readonly [T, (next: T | null) => void];\n\n/**\n * One value held in a URL search parameter (React Router): `const [mode, setMode] = useSearchParam(\"mode\", { default: \"all\", parse: isMode })`.\n * Reads and validates it, drops the param when set to the default or `null`, keeps the others, and replaces the history entry by default.\n */\nexport function useSearchParam<T extends string = string>(\n key: string,\n { default: fallback, parse, replace = true }: SearchParamOptions<T>,\n): SearchParam<T> {\n const [params, setParams] = useSearchParams();\n const raw = params.get(key);\n let value = fallback;\n if (raw !== null) {\n const parsed = parse ? parse(raw) : (raw as T);\n if (parsed === true) value = raw as T;\n else if (typeof parsed === \"string\") value = parsed;\n }\n const set = React.useCallback(\n (next: T | null) =>\n setParams(\n (p) => {\n const out = new URLSearchParams(p);\n if (next === null || next === fallback) out.delete(key);\n else out.set(key, next);\n return out;\n },\n { replace },\n ),\n [key, fallback, replace, setParams],\n );\n return [value, set];\n}\n","// Control sizes, one set for everything that sits in a toolbar or a property row: `default` is\n// --control-h and `sm` is --control-h-sm, so two controls of the same size name are the same height\n// in every density (issue #117). Button, IconButton, Toggle, ToggleGroup, Input, NativeSelect and\n// NumberField all take it as `size`.\n\n/** The size names a control takes: `default` (--control-h) or `sm` (--control-h-sm). */\nexport type ControlSize = \"default\" | \"sm\";\n\n/** The height class of each control size. */\nexport const controlHeight: Record<ControlSize, string> = {\n default: \"h-(--control-h)\",\n sm: \"h-(--control-h-sm)\",\n};\n","import * as React from \"react\";\nimport { CircleAlert } from \"lucide-react\";\nimport { Label, Radio, RadioGroup } from \"react-aria-components\";\nimport { cn } from \"../lib/utils\";\nimport { useSearchParam } from \"../lib/search-param\";\nimport { controlHeight, type ControlSize } from \"../lib/control\";\n\n// Field owns the wiring a generated form usually forgets: the label's htmlFor, aria-describedby\n// pointing at the hint and the error, and aria-invalid. Controls read it from context, so a control\n// inside a Field cannot end up unlabelled or silently invalid.\n//\n// A one-field form (\"paste a link, Add\", a search box, \"invite by email\") puts its button on the\n// control's row, not beside the whole field (strata-react issue #46, from the Tubes Library\n// screen): in a plain flex row the button lines up with label, hint and error together and drifts\n// off the input whenever one shows. `action` is drawn on the control's row, both at --control-h,\n// with the hint and the error under both across the full width. It wraps under the control only\n// when the row cannot keep the control 10rem wide beside it (a 250px inspector body keeps a Reset beside its slider, issue #116): on a phone a short \"Add\" stays on the\n// row, as a search box's button does, and a long label or a narrow column wraps. The error and hint stay the input's description; the\n// button is not described by them. Field messages for a form come from `useAsyncAction`'s\n// `fieldErrors` (its `validate`, or the server's 422), so no `problem` state is kept by hand.\n\ntype FieldState = {\n id: string;\n label: string;\n describedBy?: string;\n invalid: boolean;\n report: (message: string | undefined) => void;\n};\nconst FieldContext = React.createContext<FieldState | null>(null);\n\n// A control that checks what was typed (a number field, a colour field) reports its own message to\n// the Field it sits in, which draws it as the field's error, so a value outside the limits is\n// explained in the same place and way as a server's 422, with nothing for the screen to wire.\n// `error` from the screen wins over the control's own. Outside a Field `report` does nothing and\n// the control marks itself invalid without a message.\n/** @internal The surrounding Field, and where a control reports its own message. */\nexport function useFieldControl() {\n const field = React.useContext(FieldContext);\n return { field, report: field?.report ?? noReport };\n}\n\nfunction useField(id?: string) {\n const field = React.useContext(FieldContext);\n return {\n // Inside a Field the Field's id wins, so the label always points at the control. To choose the\n // id yourself, pass it to Field.\n id: field?.id ?? id,\n \"aria-describedby\": field?.describedBy,\n \"aria-invalid\": field?.invalid || undefined,\n };\n}\n\nconst noReport = () => {};\n\nexport type FieldProps = {\n label: string;\n /** The control's id, when the page needs a known one (an anchor, a test). Generated otherwise. */\n id?: string;\n /** What the person needs to know before typing, such as limits or units. */\n hint?: React.ReactNode;\n /** What went wrong and how to fix it, in one sentence. Shown under the control, never in a toast. */\n error?: string;\n /** A button on the control's row, for a one-field form (an `AsyncButton` \"Add\"). The hint and error run under both; on a narrow screen it wraps under the control. */\n action?: React.ReactNode;\n children: React.ReactNode;\n className?: string;\n};\n\n/** A labelled form field: wires the label, hint, error, `aria-describedby` and `aria-invalid` into the one control it wraps. */\nexport function Field({ label, id: idProp, hint, error, action, children, className }: FieldProps) {\n const generated = React.useId();\n const id = idProp ?? generated;\n const hintId = hint ? `${id}-hint` : undefined;\n const [reported, report] = React.useState<string>();\n const shown = error ?? reported;\n const errorId = shown ? `${id}-error` : undefined;\n const describedBy = [errorId, hintId].filter(Boolean).join(\" \") || undefined;\n\n return (\n <FieldContext.Provider value={{ id, label, describedBy, invalid: Boolean(shown), report }}>\n <div className={cn(\"grid min-w-0 content-start gap-1.5\", className)}>\n <label htmlFor={id} className=\"type-label text-foreground\">\n {label}\n </label>\n {action ? (\n <div className=\"flex flex-wrap items-start gap-2\">\n <div className=\"min-w-40 flex-1\">{children}</div>\n <div className=\"flex shrink-0 items-center\">{action}</div>\n </div>\n ) : (\n children\n )}\n {shown && (\n <p id={errorId} className=\"flex items-start gap-1.5 type-body-sm text-danger\">\n <CircleAlert aria-hidden className=\"mt-0.5 size-4 shrink-0\" />\n {shown}\n </p>\n )}\n {hint && (\n <p id={hintId} className=\"type-body-sm text-muted-foreground\">\n {hint}\n </p>\n )}\n </div>\n </FieldContext.Provider>\n );\n}\n\nconst control =\n \"w-full min-w-0 rounded-control border border-input bg-background px-3 type-body text-foreground transition-state placeholder:text-muted-foreground disabled:cursor-not-allowed disabled:bg-muted disabled:opacity-70 aria-invalid:border-danger\";\n\n/** A text input that picks up its id and descriptions from the surrounding `Field`. `size=\"sm\"` is --control-h-sm; the native `size` (a width in characters) is not passed on. */\nexport function Input({\n className,\n id,\n size = \"default\",\n ...props\n}: Omit<React.ComponentProps<\"input\">, \"size\"> & { size?: ControlSize }) {\n return <input {...useField(id)} className={cn(control, controlHeight[size], className)} {...props} />;\n}\n\n/** A multi-line input that picks up its id and descriptions from the surrounding `Field`. */\nexport function Textarea({ className, id, ...props }: React.ComponentProps<\"textarea\">) {\n return <textarea {...useField(id)} className={cn(control, \"min-h-24 py-2\", className)} {...props} />;\n}\n\n// A native select, styled. For short option lists on a touch screen it beats a custom listbox:\n// the platform picker, typeahead and form autofill all work with no code.\n/** The platform select, styled. The default for short lists, especially on touch screens. `size=\"sm\"` is --control-h-sm. */\nexport function NativeSelect(props: NativeSelectProps) {\n // `param` is a different component so a select outside a router (no `param`) never calls router hooks.\n return props.param === undefined ? <PlainSelect {...(props as PlainSelectProps)} /> : <ParamSelect {...props} />;\n}\n\ntype PlainSelectProps = Omit<React.ComponentProps<\"select\">, \"size\"> & { size?: ControlSize };\n\n/** Props of `NativeSelect`: a native select's own, or (with `param`) a choice held in the URL. */\nexport type NativeSelectProps =\n | (PlainSelectProps & { param?: undefined; paramDefault?: undefined })\n | (Omit<PlainSelectProps, \"value\" | \"defaultValue\" | \"onChange\"> & {\n /** The search parameter that holds the choice (`?mode=…`), so it can be linked and survives a reload. */\n param: string;\n /** The option that is chosen when the URL says nothing; choosing it removes the param. */\n paramDefault: string;\n /** Called after the URL changes. */\n onChange?: (value: string) => void;\n });\n\nfunction PlainSelect({ className, id, size = \"default\", ...props }: PlainSelectProps) {\n return <select {...useField(id)} className={cn(control, controlHeight[size], \"pr-8\", className)} {...props} />;\n}\n\n/** The values of every `<option>`, looking inside `<optgroup>`s and fragments. */\nfunction optionValues(children: React.ReactNode): string[] {\n return React.Children.toArray(children).flatMap((c) => {\n if (!React.isValidElement<{ value?: string; children?: React.ReactNode }>(c)) return [];\n if (c.type === \"option\") return [c.props.value ?? String(c.props.children)];\n return optionValues(c.props.children);\n });\n}\n\nfunction ParamSelect({\n param,\n paramDefault,\n onChange,\n children,\n ...props\n}: Extract<NativeSelectProps, { param: string }>) {\n // An unknown value in the URL reads as the default: the select shows an option that exists.\n const options = optionValues(children);\n const [value, setValue] = useSearchParam(param, {\n default: paramDefault,\n parse: (raw) => options.length === 0 || options.includes(raw),\n });\n return (\n <PlainSelect\n {...props}\n value={value}\n onChange={(e) => {\n setValue(e.target.value);\n onChange?.(e.target.value);\n }}\n >\n {children}\n </PlainSelect>\n );\n}\n\n// Radio choices: React Aria's RadioGroup (a group named by its label, arrow-key movement, one tab\n// stop), and each row wraps its control so the whole row is one hit target. The dot is drawn from\n// tokens, not the platform's accent-color radio.\n/** One option of a `ChoiceGroup`: its value, its words, and optionally a decorative `leading` mark (a swatch) before the words, which a screen reader skips, so the label must say it all. */\nexport type Choice = { value: string; label: string; detail?: string; leading?: React.ReactNode };\n\n/** Radio choices in a fieldset with a legend; each whole row is the hit target. For 2 to 5 options that each need a sentence. */\nexport function ChoiceGroup(props: ChoiceGroupProps) {\n return props.param === undefined ? <ChoiceGroupView {...props} /> : <ParamChoiceGroup {...props} />;\n}\n\n/** Props of `ChoiceGroup`: the value and `onChange` are the caller's, or (with `param`) the URL's, the first choice being the default. */\nexport type ChoiceGroupProps = {\n legend: string;\n name: string;\n choices: Choice[];\n error?: string;\n} & (\n | { value: string; onChange: (value: string) => void; param?: undefined }\n | {\n /** The search parameter that holds the choice, so it can be linked and survives a reload. The first choice is the default and is not written. */\n param: string;\n value?: undefined;\n /** Called after the URL changes. */\n onChange?: (value: string) => void;\n }\n);\n\nfunction ParamChoiceGroup({ param, choices, onChange, ...props }: Extract<ChoiceGroupProps, { param: string }>) {\n const [value, setValue] = useSearchParam(param, {\n default: choices[0]?.value ?? \"\",\n parse: (raw) => choices.some((c) => c.value === raw),\n });\n return (\n <ChoiceGroupView\n {...props}\n choices={choices}\n value={value}\n onChange={(next) => {\n setValue(next);\n onChange?.(next);\n }}\n />\n );\n}\n\nfunction ChoiceGroupView({\n legend,\n name,\n choices,\n value,\n onChange,\n error,\n}: {\n legend: string;\n name: string;\n choices: Choice[];\n value: string;\n onChange: (value: string) => void;\n error?: string;\n}) {\n const errorId = React.useId();\n return (\n <RadioGroup\n name={name}\n value={value}\n onChange={onChange}\n aria-describedby={error ? errorId : undefined}\n className=\"grid gap-2\"\n >\n <Label className=\"mb-1.5 type-label text-foreground\">{legend}</Label>\n {choices.map((c) => (\n <Radio\n key={c.value}\n value={c.value}\n className=\"group flex min-h-(--control-h-sm) cursor-pointer items-start gap-3 py-1\"\n >\n <span\n aria-hidden\n className=\"mt-1 grid size-4 shrink-0 place-items-center rounded-pill border border-input bg-background transition-state group-selected:border-primary group-focus-visible:outline-2 group-focus-visible:outline-offset-2 group-focus-visible:outline-ring\"\n >\n <span className=\"size-2 rounded-pill bg-primary opacity-0 group-selected:opacity-100\" />\n </span>\n {c.leading && <span className=\"mt-0.5 shrink-0\">{c.leading}</span>}\n <span className=\"grid\">\n <span className=\"type-body\">{c.label}</span>\n {c.detail && <span className=\"type-body-sm text-muted-foreground\">{c.detail}</span>}\n </span>\n </Radio>\n ))}\n {error && (\n <p id={errorId} className=\"flex items-start gap-1.5 type-body-sm text-danger\">\n <CircleAlert aria-hidden className=\"mt-0.5 size-4 shrink-0\" />\n {error}\n </p>\n )}\n </RadioGroup>\n );\n}\n"],"mappings":";;;;;;;;AA4CA,MAAa,OAAO;;AAGpB,MAAa,UAAU;AAIvB,MAAM,aAAkC;CAAC;CAAK;CAAM;CAAM;CAAM;CAAM;AAAI;AAC1E,MAAM,YAAY,OAAO,YAAY,WAAW,KAAK,GAAG,MAAM,CAAC,GAAG,OAAQ,CAAC,CAA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M,WAAU;iBAAsC,EAAE;MAAa,EAC9E;;IACD;MAfA,EAAE,KAeF,CACR;GACA,SACC,qBAAC,KAAD;IAAG,IAAI;IAAS,WAAU;cAA1B,CACE,oBAAC,aAAD;KAAa;KAAY,WAAU;IAA0B,IAC5D,KACA;;EAEK;;AAEhB"}
@@ -0,0 +1,16 @@
1
+ // src/lib/follow.ts
2
+ /**
3
+ * Where a viewer looks when it follows something that moves (a player in a replay, a camera operator): the heading the app
4
+ * supplies, with the person's own look added on top, so panning during playback still works and "through the player's eyes" is just
5
+ * `follow` mode. Degrees, positive yaw to the right and positive pitch up, the same in `PanoramaViewer` and `SceneViewport`.
6
+ * Yaw wraps to -180 to 180 and pitch is held to `maxPitch` (default 89), where "up" stops meaning anything.
7
+ */
8
+ function followAim({ heading, pitch = 0, look, maxPitch = 89 }) {
9
+ return {
10
+ yaw: ((heading + (look?.yaw ?? 0) + 180) % 360 + 360) % 360 - 180,
11
+ pitch: Math.min(Math.max(pitch + (look?.pitch ?? 0), -maxPitch), maxPitch)
12
+ };
13
+ }
14
+
15
+ export { followAim as t };
16
+ //# sourceMappingURL=follow-CXQsL86O.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"follow-CXQsL86O.js","names":[],"sources":["../src/lib/follow.ts"],"sourcesContent":["// Pure, so the camera maths (no GL, no React) can use it. See `followAim`.\n\n/**\n * Where a viewer looks when it follows something that moves (a player in a replay, a camera operator): the heading the app\n * supplies, with the person's own look added on top, so panning during playback still works and \"through the player's eyes\" is just\n * `follow` mode. Degrees, positive yaw to the right and positive pitch up, the same in `PanoramaViewer` and `SceneViewport`.\n * Yaw wraps to -180 to 180 and pitch is held to `maxPitch` (default 89), where \"up\" stops meaning anything.\n */\nexport function followAim({\n heading,\n pitch = 0,\n look,\n maxPitch = 89,\n}: {\n heading: number;\n pitch?: number;\n look?: { yaw?: number; pitch?: number };\n maxPitch?: number;\n}): { yaw: number; pitch: number } {\n const yaw = ((((heading + (look?.yaw ?? 0) + 180) % 360) + 360) % 360) - 180;\n return { yaw, pitch: Math.min(Math.max(pitch + (look?.pitch ?? 0), -maxPitch), maxPitch) };\n}\n"],"mappings":";;;;;;;AAQA,SAAgB,UAAU,EACxB,SACA,QAAQ,GACR,MACA,WAAW,MAMsB;CAEjC,OAAO;EAAE,OADO,WAAW,MAAM,OAAO,KAAK,OAAO,MAAO,OAAO,MAAO;EAC3D,OAAO,KAAK,IAAI,KAAK,IAAI,SAAS,MAAM,SAAS,IAAI,CAAC,QAAQ,GAAG,QAAQ;CAAE;AAC3F"}
@@ -1,7 +1,8 @@
1
+ import { createRequire } from "node:module";
1
2
  import { resolve } from "node:path";
2
3
  import { pathToFileURL } from "node:url";
3
4
  import { readFile } from "node:fs/promises";
4
- import { createRequire } from "node:module";
5
+
5
6
  // src/api-types/generate.ts
6
7
  /** Reads an OpenAPI document from an `http(s)` URL (a running server) or a JSON file path. */
7
8
  async function loadSchema(source, fetcher = fetch) {
@@ -20,11 +21,11 @@ async function loadSchema(source, fetcher = fetch) {
20
21
  if (!parsed || typeof parsed !== "object" || !("openapi" in parsed)) throw new Error(`${source} is JSON but not an OpenAPI document (no "openapi" field).`);
21
22
  return parsed;
22
23
  }
23
- var header = `/* eslint-disable */
24
+ const header = `/* eslint-disable */
24
25
  // Generated by strata-api-types from the app's OpenAPI schema. Do not edit by hand:
25
26
  // regenerate with \`strata-api-types <schema> -o <this file>\`; CI runs it with --check.
26
27
  `;
27
- var footer = `
28
+ const footer = `
28
29
  /** A named schema of the API: \`Schema<"Task">\`. */
29
30
  export type Schema<K extends keyof components["schemas"]> = components["schemas"][K];
30
31
  `;
@@ -57,8 +58,9 @@ async function generateApiTypes(schema, source) {
57
58
  const { default: openapiTS, astToString } = await import("openapi-typescript").catch((cause) => {
58
59
  throw new Error(explainImportFailure(cause), { cause });
59
60
  });
60
- return `${header}\n${astToString(await openapiTS(schema, source ? { cwd: baseOf(source) } : void 0)).trimEnd()}\n${footer}`;
61
+ const ast = await openapiTS(schema, source ? { cwd: baseOf(source) } : void 0);
62
+ return `${header}\n${astToString(ast).trimEnd()}\n${footer}`;
61
63
  }
62
- export { loadSchema as n, generateApiTypes as t };
63
64
 
64
- //# sourceMappingURL=generate-CjTHKJ39.js.map
65
+ export { loadSchema as n, generateApiTypes as t };
66
+ //# sourceMappingURL=generate-BkWhh4k4.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"generate-BkWhh4k4.js","names":[],"sources":["../src/api-types/generate.ts"],"sourcesContent":["import { readFile } from \"node:fs/promises\";\nimport { resolve } from \"node:path\";\nimport { createRequire } from \"node:module\";\nimport { pathToFileURL } from \"node:url\";\n\n// The types behind `strata-api-types` (strata-react issue #263). A strata app's FastAPI server\n// publishes its routes, the shared contracts (`strata_python.contracts`: Health, Task, Page, ErrorBody…)\n// and its typed settings at `/api/openapi.json`; the TypeScript types follow that schema instead of\n// being written again by hand and drifting. The work of reading OpenAPI is `openapi-typescript`\n// (Jonathan, 2026-11-14: types only, nothing in the app's bundle); this file adds where the schema\n// comes from (a running server, or a file the server's own CLI wrote, so CI needs no server) and what\n// the committed file looks like. It lives behind its own entry (`strata-react/api-types`), like\n// `strata-react/visual`, and `openapi-typescript` is an optional peer, so an app that never runs the\n// command installs nothing and the main entry's peer contract is unchanged.\n//\n// The output is deterministic, so `--check` can compare it with the committed file and fail CI when\n// the Python side moved and the file did not. Nothing about the machine (the URL it was read from, a\n// date) goes into it, for the same reason.\n\n/** The OpenAPI document as the generator takes it: a parsed JSON object. */\nexport type OpenApiDocument = Record<string, unknown>;\n\n/** Reads an OpenAPI document from an `http(s)` URL (a running server) or a JSON file path. */\nexport async function loadSchema(source: string, fetcher: typeof fetch = fetch): Promise<OpenApiDocument> {\n let text: string;\n if (/^https?:\\/\\//i.test(source)) {\n const response = await fetcher(source, { headers: { accept: \"application/json\" } });\n if (!response.ok) throw new Error(`${source} answered ${response.status} ${response.statusText}`);\n text = await response.text();\n } else {\n text = await readFile(source, \"utf8\");\n }\n let parsed: unknown;\n try {\n parsed = JSON.parse(text);\n } catch {\n throw new Error(`${source} is not JSON. Give the OpenAPI document (/api/openapi.json), not the docs page.`);\n }\n if (!parsed || typeof parsed !== \"object\" || !(\"openapi\" in parsed))\n throw new Error(`${source} is JSON but not an OpenAPI document (no \"openapi\" field).`);\n return parsed as OpenApiDocument;\n}\n\nconst header = `/* eslint-disable */\n// Generated by strata-api-types from the app's OpenAPI schema. Do not edit by hand:\n// regenerate with \\`strata-api-types <schema> -o <this file>\\`; CI runs it with --check.\n`;\n\n// Short names for the schemas, so a screen writes \\`Schema<\"Task\">\\` and not the whole path.\nconst footer = `\n/** A named schema of the API: \\`Schema<\"Task\">\\`. */\nexport type Schema<K extends keyof components[\"schemas\"]> = components[\"schemas\"][K];\n`;\n\n/** The URL relative references resolve against: the document's own URL, or its file's location. */\nfunction baseOf(source: string): URL {\n return /^https?:\\/\\//i.test(source) ? new URL(source) : pathToFileURL(resolve(source));\n}\n\n/** The message for a failed `import(\"openapi-typescript\")`: absent, or present but unable to load (issue #293: a TypeScript 7 app was told to install what it had). */\nexport function explainImportFailure(\n cause: unknown,\n typescriptMajor: number | undefined = installedTypescriptMajor(),\n): string {\n const text = cause instanceof Error ? cause.message : String(cause);\n const code = (cause as { code?: string } | null)?.code;\n const notFound =\n (code === \"ERR_MODULE_NOT_FOUND\" || code === \"MODULE_NOT_FOUND\") &&\n /Cannot find (package|module) 'openapi-typescript'/.test(text);\n if (notFound) {\n return 'strata-api-types needs openapi-typescript: npm install --save-dev openapi-typescript (see \"API types from the server\" in the README for the TypeScript it wants).';\n }\n const hint =\n typescriptMajor !== undefined && typescriptMajor >= 7\n ? ` The \\`typescript\\` package installed here is version ${typescriptMajor}, which ships no JavaScript API, and openapi-typescript needs one. Install TypeScript 6's under the name \\`typescript\\` (\"typescript\": \"npm:@typescript/typescript6@~6.0.2\", with TypeScript 7 as another name such as \"typescript7\" for \\`tsc\\`) and keep the \\`overrides\\` entry; see \"API types from the server\" in the README.`\n : \" It is installed but did not load; the cause is above. It needs a `typescript` package with a JavaScript API (TypeScript 5 or 6).\";\n return `strata-api-types could not load openapi-typescript: ${text}.${hint}`;\n}\n\n/** The major version of the `typescript` package an app resolves, or `undefined` when none can be read. */\nfunction installedTypescriptMajor(): number | undefined {\n try {\n const { version } = createRequire(resolve(\"package.json\"))(\"typescript/package.json\") as { version?: string };\n const major = Number.parseInt(version ?? \"\", 10);\n return Number.isNaN(major) ? undefined : major;\n } catch {\n return undefined;\n }\n}\n\n/**\n * The TypeScript types for an OpenAPI document, as the text of the generated file. `source` is where the\n * document was read from (a URL or file path): relative `$ref`s to other files resolve against it.\n */\nexport async function generateApiTypes(schema: OpenApiDocument, source?: string): Promise<string> {\n const mod = await import(\"openapi-typescript\").catch((cause: unknown) => {\n throw new Error(explainImportFailure(cause), { cause });\n });\n const { default: openapiTS, astToString } = mod;\n const ast = await openapiTS(schema as never, source ? { cwd: baseOf(source) } : undefined);\n return `${header}\\n${astToString(ast).trimEnd()}\\n${footer}`;\n}\n"],"mappings":";;;;;;;AAuBA,eAAsB,WAAW,QAAgB,UAAwB,OAAiC;CACxG,IAAI;CACJ,IAAI,gBAAgB,KAAK,MAAM,GAAG;EAChC,MAAM,WAAW,MAAM,QAAQ,QAAQ,EAAE,SAAS,EAAE,QAAQ,mBAAmB,EAAE,CAAC;EAClF,IAAI,CAAC,SAAS,IAAI,MAAM,IAAI,MAAM,GAAG,OAAO,YAAY,SAAS,OAAO,GAAG,SAAS,YAAY;EAChG,OAAO,MAAM,SAAS,KAAK;CAC7B,OACE,OAAO,MAAM,SAAS,QAAQ,MAAM;CAEtC,IAAI;CACJ,IAAI;EACF,SAAS,KAAK,MAAM,IAAI;CAC1B,QAAQ;EACN,MAAM,IAAI,MAAM,GAAG,OAAO,gFAAgF;CAC5G;CACA,IAAI,CAAC,UAAU,OAAO,WAAW,YAAY,EAAE,aAAa,SAC1D,MAAM,IAAI,MAAM,GAAG,OAAO,2DAA2D;CACvF,OAAO;AACT;AAEA,MAAM,SAAS;;;;AAMf,MAAM,SAAS;;;;;AAMf,SAAS,OAAO,QAAqB;CACnC,OAAO,gBAAgB,KAAK,MAAM,IAAI,IAAI,IAAI,MAAM,IAAI,cAAc,QAAQ,MAAM,CAAC;AACvF;;AAGA,SAAgB,qBACd,OACA,kBAAsC,yBAAyB,GACvD;CACR,MAAM,OAAO,iBAAiB,QAAQ,MAAM,UAAU,OAAO,KAAK;CAClE,MAAM,OAAQ,OAAoC;CAIlD,KAFG,SAAS,0BAA0B,SAAS,uBAC7C,oDAAoD,KAAK,IAAI,GAE7D,OAAO;CAMT,OAAO,uDAAuD,KAAK,GAHjE,oBAAoB,UAAa,mBAAmB,IAChD,yDAAyD,gBAAgB,sUACzE;AAER;;AAGA,SAAS,2BAA+C;CACtD,IAAI;EACF,MAAM,EAAE,YAAY,cAAc,QAAQ,cAAc,CAAC,CAAC,CAAC,yBAAyB;EACpF,MAAM,QAAQ,OAAO,SAAS,WAAW,IAAI,EAAE;EAC/C,OAAO,OAAO,MAAM,KAAK,IAAI,SAAY;CAC3C,QAAQ;EACN;CACF;AACF;;;;;AAMA,eAAsB,iBAAiB,QAAyB,QAAkC;CAIhG,MAAM,EAAE,SAAS,WAAW,gBAAgB,MAH1B,OAAO,qBAAqB,CAAC,OAAO,UAAmB;EACvE,MAAM,IAAI,MAAM,qBAAqB,KAAK,GAAG,EAAE,MAAM,CAAC;CACxD,CAAC;CAED,MAAM,MAAM,MAAM,UAAU,QAAiB,SAAS,EAAE,KAAK,OAAO,MAAM,EAAE,IAAI,MAAS;CACzF,OAAO,GAAG,OAAO,IAAI,YAAY,GAAG,CAAC,CAAC,QAAQ,EAAE,IAAI;AACtD"}
@@ -1,60 +1,62 @@
1
1
  /** A position: `[latitude, longitude]` in degrees. */
2
- export type LatLng = readonly [lat: number, lng: number];
2
+ type LatLng = readonly [lat: number, lng: number];
3
3
  /** Great-circle distance between two positions, in metres. */
4
- export declare function distance([lat1, lng1]: LatLng, [lat2, lng2]: LatLng): number;
4
+ declare function distance([lat1, lng1]: LatLng, [lat2, lng2]: LatLng): number;
5
5
  /** The direction from `a` to `b` in degrees clockwise from north (0 to 360), for neighbouring points. */
6
- export declare function bearing([lat1, lng1]: LatLng, [lat2, lng2]: LatLng): number;
6
+ declare function bearing([lat1, lng1]: LatLng, [lat2, lng2]: LatLng): number;
7
7
  /** The running distance along a route at each point, in metres, starting at 0. */
8
- export declare function cumulative(points: readonly LatLng[]): number[];
8
+ declare function cumulative(points: readonly LatLng[]): number[];
9
9
  /** The length of a route in metres. */
10
- export declare function length(points: readonly LatLng[]): number;
10
+ declare function length(points: readonly LatLng[]): number;
11
11
  /** The south-west and north-east corners that hold every point, or null for none. */
12
- export declare function bounds(points: readonly LatLng[]): [LatLng, LatLng] | null;
12
+ declare function bounds(points: readonly LatLng[]): [LatLng, LatLng] | null;
13
13
  /** The position `metres` along a route (clamped to its ends), by linear interpolation, or null for no points. */
14
- export declare function pointAlong(points: readonly LatLng[], metres: number, along?: readonly number[]): LatLng | null;
14
+ declare function pointAlong(points: readonly LatLng[], metres: number, along?: readonly number[]): LatLng | null;
15
15
  /**
16
16
  * `count` positions evenly spaced by distance along a route (the ends skipped), each with the
17
17
  * direction of travel there. The direction is smoothed: the bearing from a point a fraction
18
18
  * (`window`) of the spacing before to one the same distance after, so GPS jitter and a tight bend
19
19
  * do not turn a chevron sideways.
20
20
  */
21
- export declare function arrows(points: readonly LatLng[], count?: number, window?: number): {
22
- position: LatLng;
23
- bearing: number;
21
+ declare function arrows(points: readonly LatLng[], count?: number, window?: number): {
22
+ position: LatLng;
23
+ bearing: number;
24
24
  }[];
25
25
  /** The first and last positions, and whether they are within `loopWithin` metres of each other (a loop), or null for no route. */
26
- export declare function ends(points: readonly LatLng[], loopWithin?: number): {
27
- start: LatLng;
28
- finish: LatLng;
29
- loop: boolean;
26
+ declare function ends(points: readonly LatLng[], loopWithin?: number): {
27
+ start: LatLng;
28
+ finish: LatLng;
29
+ loop: boolean;
30
30
  } | null;
31
31
  /** The index of the point nearest `position`, for "where on the route is this?". */
32
- export declare function nearest(points: readonly LatLng[], position: LatLng): number;
32
+ declare function nearest(points: readonly LatLng[], position: LatLng): number;
33
33
  /** The part of a route between two distances along it (metres, clamped, either order): the cut ends and every point between. Empty for no route. */
34
- export declare function slice(points: readonly LatLng[], from: number, to: number, along?: readonly number[]): LatLng[];
34
+ declare function slice(points: readonly LatLng[], from: number, to: number, along?: readonly number[]): LatLng[];
35
35
  /**
36
36
  * The nearest point on a route to `position`, not only its vertices: where it lies, how far along the
37
37
  * route that is, and how far `position` is from the route. The inverse of `pointAlong` (a cursor on a
38
38
  * map is a distance on a chart). Each leg is flattened around its own latitude, which is exact enough
39
39
  * for any leg a recording has; `index` is the leg's first point. Null for fewer than one point.
40
40
  */
41
- export declare function snap(points: readonly LatLng[], position: LatLng, along?: readonly number[]): {
42
- position: LatLng;
43
- metres: number;
44
- offset: number;
45
- index: number;
41
+ declare function snap(points: readonly LatLng[], position: LatLng, along?: readonly number[]): {
42
+ position: LatLng;
43
+ metres: number;
44
+ offset: number;
45
+ index: number;
46
46
  } | null;
47
47
  /** Route geometry helpers: `geo.distance`, `bearing`, `length`, `cumulative`, `bounds`, `pointAlong`, `snap` (its inverse), `slice`, `arrows`, `ends`, `nearest`. */
48
- export declare const geo: {
49
- distance: typeof distance;
50
- bearing: typeof bearing;
51
- cumulative: typeof cumulative;
52
- length: typeof length;
53
- bounds: typeof bounds;
54
- pointAlong: typeof pointAlong;
55
- snap: typeof snap;
56
- slice: typeof slice;
57
- arrows: typeof arrows;
58
- ends: typeof ends;
59
- nearest: typeof nearest;
48
+ declare const geo: {
49
+ distance: typeof distance;
50
+ bearing: typeof bearing;
51
+ cumulative: typeof cumulative;
52
+ length: typeof length;
53
+ bounds: typeof bounds;
54
+ pointAlong: typeof pointAlong;
55
+ snap: typeof snap;
56
+ slice: typeof slice;
57
+ arrows: typeof arrows;
58
+ ends: typeof ends;
59
+ nearest: typeof nearest;
60
60
  };
61
+ export { geo as n, LatLng as t };
62
+ //# sourceMappingURL=geo-DfKa9JtK.d.ts.map
@@ -1,23 +1,23 @@
1
- import { default as Hls, HlsConfig } from 'hls.js';
2
- import { SourceAttacher } from '../components/media-player';
1
+ import { f as SourceAttacher } from "./media-player-BETa3P7K.js";
2
+ import Hls, { HlsConfig } from "hls.js";
3
3
  /** The parts of hls.js this entry uses, so the engine can be handed in (a test's, or an app's own build). */
4
4
  export type HlsEngine = typeof Hls;
5
5
  declare const WORDS: {
6
- network: string;
7
- media: string;
8
- other: string;
9
- unsupported: string;
6
+ network: string;
7
+ media: string;
8
+ other: string;
9
+ unsupported: string;
10
10
  };
11
11
  /** The words an HLS attacher says for each way a stream fails. */
12
12
  export type HlsWords = Partial<Record<keyof typeof WORDS, string>>;
13
13
  /** Options of an HLS attacher. */
14
14
  export type HlsAttacherOptions = {
15
- /** Which to use where both would do: `"engine"` (default) is hls.js, `"native"` is the element's own HLS. Where only one is available that one is used. */
16
- prefer?: "engine" | "native";
17
- /** hls.js's own configuration. */
18
- config?: Partial<HlsConfig>;
19
- /** What each failure says in the product's words (the connection dropped, the stream could not be decoded, anything else, no support here). Defaults are plain English. */
20
- words?: HlsWords;
15
+ /** Which to use where both would do: `"engine"` (default) is hls.js, `"native"` is the element's own HLS. Where only one is available that one is used. */
16
+ prefer?: "engine" | "native";
17
+ /** hls.js's own configuration. */
18
+ config?: Partial<HlsConfig>;
19
+ /** What each failure says in the product's words (the connection dropped, the stream could not be decoded, anything else, no support here). Defaults are plain English. */
20
+ words?: HlsWords;
21
21
  };
22
22
  /** Makes a `SourceAttacher` around an hls.js engine: the engine where the browser has Media Source Extensions, otherwise the element's own HLS. */
23
23
  export declare function createHlsAttacher(Engine: HlsEngine, { prefer, config, words }?: HlsAttacherOptions): SourceAttacher;
@@ -28,3 +28,4 @@ export declare const hlsAttacher: (options: HlsAttacherOptions) => SourceAttache
28
28
  /** Whether this browser can play HLS at all, natively or through hls.js. */
29
29
  export declare function hlsSupported(): boolean;
30
30
  export {};
31
+ //# sourceMappingURL=hls.d.ts.map
package/dist/hls.js CHANGED
@@ -1,6 +1,7 @@
1
1
  import Hls from "hls.js";
2
+
2
3
  // src/hls/index.ts
3
- var WORDS = {
4
+ const WORDS = {
4
5
  network: "The connection to the stream dropped.",
5
6
  media: "The stream could not be decoded.",
6
7
  other: "The stream could not be played.",
@@ -75,14 +76,14 @@ function createHlsAttacher(Engine, { prefer = "engine", config = {}, words = {}
75
76
  };
76
77
  }
77
78
  /** HLS for `MediaPlayer attach` and `useAttachedSource`: hls.js where the browser has Media Source Extensions, the element's own HLS where it does not. */
78
- var attachHls = createHlsAttacher(Hls);
79
+ const attachHls = createHlsAttacher(Hls);
79
80
  /** An HLS attacher with options: `prefer: "native"`, or hls.js's own `config` (buffer sizes, headers). */
80
- var hlsAttacher = (options) => createHlsAttacher(Hls, options);
81
+ const hlsAttacher = (options) => createHlsAttacher(Hls, options);
81
82
  /** Whether this browser can play HLS at all, natively or through hls.js. */
82
83
  function hlsSupported() {
83
84
  if (typeof document === "undefined") return false;
84
85
  return document.createElement("video").canPlayType("application/vnd.apple.mpegurl") !== "" || Hls.isSupported();
85
86
  }
86
- export { attachHls, createHlsAttacher, hlsAttacher, hlsSupported };
87
87
 
88
+ export { attachHls, createHlsAttacher, hlsAttacher, hlsSupported };
88
89
  //# sourceMappingURL=hls.js.map
package/dist/hls.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"hls.js","names":[],"sources":["../src/hls/index.ts"],"sourcesContent":["import Hls, { type HlsConfig } from \"hls.js\";\nimport type { SourceAttacher, StreamAttachment, StreamContext } from \"../components/media-player\";\n\n// The HLS entry: `import { attachHls } from \"strata-react/hls\"` (strata-react issue #179, from\n// strata-360, whose film preview is an HLS stream that starts playing after a couple of seconds and\n// keeps growing while the rest is made). `hls.js` is an optional peer that only this entry imports, as\n// `leaflet` is for the map, so an app that never plays a stream never installs it, and the main entry\n// never reaches it (the peer-contract test walks the built chunks to keep that true).\n//\n// It is a `SourceAttacher`, the one shape the main entry knows: `<MediaPlayer attach={attachHls}\n// src=\"…/film.m3u8\" />`, or `useAttachedSource(ref, src, attachHls, media.reportProblem)` beside\n// `useMediaElement` for a plain `<video>` (the panorama viewer, the compare components). It does three\n// things the engine does not do for a player:\n//\n// - **The engine wherever it can run, the element's own HLS where it cannot.** The brief was \"native\n// where the browser plays it\", but Chromium now plays HLS natively and, checked in Chromium 158 here,\n// its native pipeline failed (`DEMUXER_ERROR_COULD_NOT_PARSE`) on a growing playlist that hls.js plays,\n// which is the case this exists for. So hls.js is used wherever Media Source Extensions exist, one\n// behaviour on every browser, and the element's `src` only where they do not (older iOS). `prefer:\n// \"native\"` turns that around for an app that wants the system's own player behaviour.\n// - **Recovers what can be recovered, and says what cannot.** hls.js reports a fatal error for a\n// dropped connection or a decoder hiccup that its own `startLoad()` or `recoverMediaError()` fixes;\n// up to three of those are tried quietly (the count resets once a segment loads), and only then does\n// the player's load error appear, in words, with Try again. Try again restarts the engine at the\n// time playback had reached.\n// - **Cleans up**: the engine is destroyed when the source changes, the attacher changes or the player\n// unmounts, so a source switch never leaves two engines on one element.\n//\n// What is *growing* is the player's business (`MediaPlayer growing`), not the engine's: hls.js plays a\n// playlist with no end-list as a live one and the element reports the end of what exists as its\n// seekable range.\n//\n// Checked: hls.js has `isSupported()` (false with no Media Source Extensions), `startPosition` for a\n// restart in place, `startLoad()` and `recoverMediaError()` for the two recoverable kinds of fatal\n// error, and `Events.FRAG_LOADED` to know it is working again.\n\n/** The parts of hls.js this entry uses, so the engine can be handed in (a test's, or an app's own build). */\nexport type HlsEngine = typeof Hls;\n\nconst WORDS = {\n network: \"The connection to the stream dropped.\",\n media: \"The stream could not be decoded.\",\n other: \"The stream could not be played.\",\n unsupported: \"This browser cannot play this kind of stream.\",\n};\n\n/** The words an HLS attacher says for each way a stream fails. */\nexport type HlsWords = Partial<Record<keyof typeof WORDS, string>>;\n\n/** Options of an HLS attacher. */\nexport type HlsAttacherOptions = {\n /** Which to use where both would do: `\"engine\"` (default) is hls.js, `\"native\"` is the element's own HLS. Where only one is available that one is used. */\n prefer?: \"engine\" | \"native\";\n /** hls.js's own configuration. */\n config?: Partial<HlsConfig>;\n /** What each failure says in the product's words (the connection dropped, the stream could not be decoded, anything else, no support here). Defaults are plain English. */\n words?: HlsWords;\n};\n\n/** Makes a `SourceAttacher` around an hls.js engine: the engine where the browser has Media Source Extensions, otherwise the element's own HLS. */\nexport function createHlsAttacher(Engine: HlsEngine, { prefer = \"engine\", config = {}, words = {} }: HlsAttacherOptions = {}): SourceAttacher {\n const say = { ...WORDS, ...words };\n return (el: HTMLMediaElement, src: string, context: StreamContext): StreamAttachment => {\n const canNative = el.canPlayType(\"application/vnd.apple.mpegurl\") !== \"\";\n const native = canNative && (prefer === \"native\" || !Engine.isSupported());\n let engine: Hls | null = null;\n let seekOnLoad: (() => void) | null = null;\n\n const stop = () => {\n engine?.destroy();\n engine = null;\n if (seekOnLoad) el.removeEventListener(\"loadedmetadata\", seekOnLoad);\n seekOnLoad = null;\n };\n\n const start = (at: number) => {\n stop();\n if (native) {\n el.src = src;\n if (at > 0) {\n seekOnLoad = () => {\n el.currentTime = at;\n seekOnLoad = null;\n };\n el.addEventListener(\"loadedmetadata\", seekOnLoad, { once: true });\n }\n return;\n }\n if (!Engine.isSupported()) {\n context.onProblem(say.unsupported);\n return;\n }\n // Where playback had reached, else the app's own start, else the beginning of a source still being made\n // (an EVENT playlist counts as live to hls.js, which with -1 would start at the newest part), else hls.js's choice.\n const hls = new Engine({ ...config, startPosition: at > 0 ? at : (config.startPosition ?? (context.growing ? 0 : -1)) });\n engine = hls;\n let recoveries = 0;\n hls.on(Engine.Events.FRAG_LOADED, () => {\n recoveries = 0;\n });\n hls.on(Engine.Events.ERROR, (_event, data) => {\n if (!data.fatal || engine !== hls) return;\n if (recoveries < 3 && data.type === Engine.ErrorTypes.NETWORK_ERROR) {\n recoveries++;\n hls.startLoad();\n } else if (recoveries < 3 && data.type === Engine.ErrorTypes.MEDIA_ERROR) {\n recoveries++;\n hls.recoverMediaError();\n } else {\n context.onProblem(data.type === Engine.ErrorTypes.NETWORK_ERROR ? say.network : data.type === Engine.ErrorTypes.MEDIA_ERROR ? say.media : say.other);\n stop();\n }\n });\n hls.loadSource(src);\n hls.attachMedia(el);\n };\n\n start(context.startAt);\n return {\n detach: () => {\n stop();\n if (native) el.removeAttribute(\"src\");\n },\n reload: start,\n };\n };\n}\n\n/** HLS for `MediaPlayer attach` and `useAttachedSource`: hls.js where the browser has Media Source Extensions, the element's own HLS where it does not. */\nexport const attachHls: SourceAttacher = createHlsAttacher(Hls);\n\n/** An HLS attacher with options: `prefer: \"native\"`, or hls.js's own `config` (buffer sizes, headers). */\nexport const hlsAttacher = (options: HlsAttacherOptions): SourceAttacher => createHlsAttacher(Hls, options);\n\n/** Whether this browser can play HLS at all, natively or through hls.js. */\nexport function hlsSupported(): boolean {\n if (typeof document === \"undefined\") return false;\n return document.createElement(\"video\").canPlayType(\"application/vnd.apple.mpegurl\") !== \"\" || Hls.isSupported();\n}\n"],"mappings":";;AAuCA,IAAM,QAAQ;CACZ,SAAS;CACT,OAAO;CACP,OAAO;CACP,aAAa;AACf;;AAgBA,SAAgB,kBAAkB,QAAmB,EAAE,SAAS,UAAU,SAAS,CAAC,GAAG,QAAQ,CAAC,MAA0B,CAAC,GAAmB;CAC5I,MAAM,MAAM;EAAE,GAAG;EAAO,GAAG;CAAM;CACjC,QAAQ,IAAsB,KAAa,YAA6C;EAEtF,MAAM,SADY,GAAG,YAAY,+BAA+B,MAAM,OACzC,WAAW,YAAY,CAAC,OAAO,YAAY;EACxE,IAAI,SAAqB;EACzB,IAAI,aAAkC;EAEtC,MAAM,aAAa;GACjB,QAAQ,QAAQ;GAChB,SAAS;GACT,IAAI,YAAY,GAAG,oBAAoB,kBAAkB,UAAU;GACnE,aAAa;EACf;EAEA,MAAM,SAAS,OAAe;GAC5B,KAAK;GACL,IAAI,QAAQ;IACV,GAAG,MAAM;IACT,IAAI,KAAK,GAAG;KACV,m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1
+ {"version":3,"file":"hls.js","names":[],"sources":["../src/hls/index.ts"],"sourcesContent":["import Hls, { type HlsConfig } from \"hls.js\";\nimport type { SourceAttacher, StreamAttachment, StreamContext } from \"../components/media-player\";\n\n// The HLS entry: `import { attachHls } from \"strata-react/hls\"` (strata-react issue #179, from\n// strata-360, whose film preview is an HLS stream that starts playing after a couple of seconds and\n// keeps growing while the rest is made). `hls.js` is an optional peer that only this entry imports, as\n// `leaflet` is for the map, so an app that never plays a stream never installs it, and the main entry\n// never reaches it (the peer-contract test walks the built chunks to keep that true).\n//\n// It is a `SourceAttacher`, the one shape the main entry knows: `<MediaPlayer attach={attachHls}\n// src=\"…/film.m3u8\" />`, or `useAttachedSource(ref, src, attachHls, media.reportProblem)` beside\n// `useMediaElement` for a plain `<video>` (the panorama viewer, the compare components). It does three\n// things the engine does not do for a player:\n//\n// - **The engine wherever it can run, the element's own HLS where it cannot.** The brief was \"native\n// where the browser plays it\", but Chromium now plays HLS natively and, checked in Chromium 158 here,\n// its native pipeline failed (`DEMUXER_ERROR_COULD_NOT_PARSE`) on a growing playlist that hls.js plays,\n// which is the case this exists for. So hls.js is used wherever Media Source Extensions exist, one\n// behaviour on every browser, and the element's `src` only where they do not (older iOS). `prefer:\n// \"native\"` turns that around for an app that wants the system's own player behaviour.\n// - **Recovers what can be recovered, and says what cannot.** hls.js reports a fatal error for a\n// dropped connection or a decoder hiccup that its own `startLoad()` or `recoverMediaError()` fixes;\n// up to three of those are tried quietly (the count resets once a segment loads), and only then does\n// the player's load error appear, in words, with Try again. Try again restarts the engine at the\n// time playback had reached.\n// - **Cleans up**: the engine is destroyed when the source changes, the attacher changes or the player\n// unmounts, so a source switch never leaves two engines on one element.\n//\n// What is *growing* is the player's business (`MediaPlayer growing`), not the engine's: hls.js plays a\n// playlist with no end-list as a live one and the element reports the end of what exists as its\n// seekable range.\n//\n// Checked: hls.js has `isSupported()` (false with no Media Source Extensions), `startPosition` for a\n// restart in place, `startLoad()` and `recoverMediaError()` for the two recoverable kinds of fatal\n// error, and `Events.FRAG_LOADED` to know it is working again.\n\n/** The parts of hls.js this entry uses, so the engine can be handed in (a test's, or an app's own build). */\nexport type HlsEngine = typeof Hls;\n\nconst WORDS = {\n network: \"The connection to the stream dropped.\",\n media: \"The stream could not be decoded.\",\n other: \"The stream could not be played.\",\n unsupported: \"This browser cannot play this kind of stream.\",\n};\n\n/** The words an HLS attacher says for each way a stream fails. */\nexport type HlsWords = Partial<Record<keyof typeof WORDS, string>>;\n\n/** Options of an HLS attacher. */\nexport type HlsAttacherOptions = {\n /** Which to use where both would do: `\"engine\"` (default) is hls.js, `\"native\"` is the element's own HLS. Where only one is available that one is used. */\n prefer?: \"engine\" | \"native\";\n /** hls.js's own configuration. */\n config?: Partial<HlsConfig>;\n /** What each failure says in the product's words (the connection dropped, the stream could not be decoded, anything else, no support here). Defaults are plain English. */\n words?: HlsWords;\n};\n\n/** Makes a `SourceAttacher` around an hls.js engine: the engine where the browser has Media Source Extensions, otherwise the element's own HLS. */\nexport function createHlsAttacher(\n Engine: HlsEngine,\n { prefer = \"engine\", config = {}, words = {} }: HlsAttacherOptions = {},\n): SourceAttacher {\n const say = { ...WORDS, ...words };\n return (el: HTMLMediaElement, src: string, context: StreamContext): StreamAttachment => {\n const canNative = el.canPlayType(\"application/vnd.apple.mpegurl\") !== \"\";\n const native = canNative && (prefer === \"native\" || !Engine.isSupported());\n let engine: Hls | null = null;\n let seekOnLoad: (() => void) | null = null;\n\n const stop = () => {\n engine?.destroy();\n engine = null;\n if (seekOnLoad) el.removeEventListener(\"loadedmetadata\", seekOnLoad);\n seekOnLoad = null;\n };\n\n const start = (at: number) => {\n stop();\n if (native) {\n el.src = src;\n if (at > 0) {\n seekOnLoad = () => {\n el.currentTime = at;\n seekOnLoad = null;\n };\n el.addEventListener(\"loadedmetadata\", seekOnLoad, { once: true });\n }\n return;\n }\n if (!Engine.isSupported()) {\n context.onProblem(say.unsupported);\n return;\n }\n // Where playback had reached, else the app's own start, else the beginning of a source still being made\n // (an EVENT playlist counts as live to hls.js, which with -1 would start at the newest part), else hls.js's choice.\n const hls = new Engine({\n ...config,\n startPosition: at > 0 ? at : (config.startPosition ?? (context.growing ? 0 : -1)),\n });\n engine = hls;\n let recoveries = 0;\n hls.on(Engine.Events.FRAG_LOADED, () => {\n recoveries = 0;\n });\n hls.on(Engine.Events.ERROR, (_event, data) => {\n if (!data.fatal || engine !== hls) return;\n if (recoveries < 3 && data.type === Engine.ErrorTypes.NETWORK_ERROR) {\n recoveries++;\n hls.startLoad();\n } else if (recoveries < 3 && data.type === Engine.ErrorTypes.MEDIA_ERROR) {\n recoveries++;\n hls.recoverMediaError();\n } else {\n context.onProblem(\n data.type === Engine.ErrorTypes.NETWORK_ERROR\n ? say.network\n : data.type === Engine.ErrorTypes.MEDIA_ERROR\n ? say.media\n : say.other,\n );\n stop();\n }\n });\n hls.loadSource(src);\n hls.attachMedia(el);\n };\n\n start(context.startAt);\n return {\n detach: () => {\n stop();\n if (native) el.removeAttribute(\"src\");\n },\n reload: start,\n };\n };\n}\n\n/** HLS for `MediaPlayer attach` and `useAttachedSource`: hls.js where the browser has Media Source Extensions, the element's own HLS where it does not. */\nexport const attachHls: SourceAttacher = createHlsAttacher(Hls);\n\n/** An HLS attacher with options: `prefer: \"native\"`, or hls.js's own `config` (buffer sizes, headers). */\nexport const hlsAttacher = (options: HlsAttacherOptions): SourceAttacher => createHlsAttacher(Hls, options);\n\n/** Whether this browser can play HLS at all, natively or through hls.js. */\nexport function hlsSupported(): boolean {\n if (typeof document === \"undefined\") return false;\n return document.createElement(\"video\").canPlayType(\"application/vnd.apple.mpegurl\") !== \"\" || Hls.isSupported();\n}\n"],"mappings":";;;AAuCA,MAAM,QAAQ;CACZ,SAAS;CACT,OAAO;CACP,OAAO;CACP,aAAa;AACf;;AAgBA,SAAgB,kBACd,QACA,EAAE,SAAS,UAAU,SAAS,CAAC,GAAG,QAAQ,CAAC,MAA0B,CAAC,GACtD;CAChB,MAAM,MAAM;E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