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
@@ -1 +1 @@
1
- {"version":3,"file":"testing.js","names":[],"sources":["../src/testing/storage.ts","../src/testing/layout.ts","../src/testing/setup.ts","../src/testing/speech.ts","../src/testing/microphone.ts","../src/testing/buttons.ts","../src/testing/intersection-observer.ts","../src/testing/index.tsx"],"sourcesContent":["// Node 25 and later define a global `localStorage` that is undefined unless Node runs with\n// `--localstorage-file`, and it shadows jsdom's. In a Vitest jsdom project on Node 26 (Strata's floor)\n// `localStorage.getItem` then throws, so any app code that reads storage (a remembered choice, a\n// `ColorSchemeChoice` on a settings screen tested with storage on) fails in its tests. Strata's own\n// tests never hit it because `renderWithStrata` turns theme storage off. Every app would have copied\n// the same dozen lines (issue #298), so `installLayoutShims` installs this when, and only when, the\n// platform's storage is unusable; where it works nothing is replaced.\n\n/** An in-memory `Storage`, with the platform's behaviour (values are strings, `key` and `length` work). */\nexport function memoryStorage(): Storage {\n const data = new Map<string, string>();\n return {\n get length() {\n return data.size;\n },\n clear: () => data.clear(),\n getItem: (key) => data.get(String(key)) ?? null,\n key: (index) => [...data.keys()][index] ?? null,\n removeItem: (key) => void data.delete(String(key)),\n setItem: (key, value) => void data.set(String(key), String(value)),\n };\n}\n\nfunction usable(name: \"localStorage\" | \"sessionStorage\"): boolean {\n try {\n return typeof (globalThis as unknown as Record<string, Storage | undefined>)[name]?.getItem === \"function\";\n } catch {\n return false;\n }\n}\n\n/**\n * Replaces `localStorage` and `sessionStorage` with in-memory ones where the runtime's are missing or throw (Node 25+ under jsdom), and empties them after each test when the test runner has a global `afterEach`.\n * Does nothing where storage works. Returns a function that puts the originals back. Called by `installLayoutShims`.\n */\nexport function installStorageShim(): () => void {\n const restore: (() => void)[] = [];\n for (const name of [\"localStorage\", \"sessionStorage\"] as const) {\n if (usable(name)) continue;\n const storage = memoryStorage();\n const targets = [globalThis, typeof window !== \"undefined\" ? window : undefined].filter((t): t is typeof globalThis => t !== undefined);\n for (const target of new Set(targets)) {\n const before = Object.getOwnPropertyDescriptor(target, name);\n Object.defineProperty(target, name, { configurable: true, value: storage });\n restore.push(() => {\n if (before) Object.defineProperty(target, name, before);\n else delete (target as unknown as Record<string, unknown>)[name];\n });\n }\n const after = (globalThis as { afterEach?: (fn: () => void) => void }).afterEach;\n if (typeof after === \"function\") after(() => storage.clear());\n }\n return () => {\n for (const undo of restore.reverse()) undo();\n };\n}\n","// jsdom does no layout: every box is 0×0 and there is no ResizeObserver. Components that measure\n// (LineChart's width; React Aria's Virtualizer draws every row of a list in a test unless the box is mocked, which these shims do not make smaller. A virtualised table with detail rows, or a virtualised grid of tiles, measures each row by its scroll size, which jsdom reports as 0: a test of one gives `Element.prototype.scrollHeight` a value) then render nothing to\n// assert on, so an app testing a screen built from them hits the same wall Strata's own suite did.\n// These shims give every element one fixed box and a ResizeObserver that reports it once on\n// observe (and, on Node 25+, a working in-memory localStorage: see storage.ts). Real layout is checked by the visual suite in Chromium, never here.\n\nimport { installStorageShim } from \"./storage\";\n\n// jsdom has no DOMRect constructor in every version, so rects are plain objects of the same shape.\n/** A DOMRect-shaped object, for stand-ins that report geometry. */\nexport function box(x: number, y: number, width: number, height: number): DOMRect {\n return { x, y, width, height, top: y, left: x, right: x + width, bottom: y + height, toJSON() { return this; } } as DOMRect;\n}\n\n/** The box every element reports while the shims are installed. */\nexport interface LayoutBox {\n width: number;\n height: number;\n}\n\n/**\n * Give jsdom a fixed box for every element (`getBoundingClientRect`, `offset*`, `client*`) and a\n * ResizeObserver that reports it on observe, so measuring components render, and an in-memory `localStorage` and `sessionStorage` where the runtime's throw (Node 25+). Defaults to 640×280.\n * Call once in a Vitest setup file (or let `setupStrataTests` do it); does nothing, and returns a no-op, where there is no DOM (a node-environment test); returns a function that puts the originals back.\n */\nexport function installLayoutShims({ width = 640, height = 280 }: Partial<LayoutBox> = {}): () => void {\n // A setup file shared by jsdom tests and `// @vitest-environment node` ones runs this in both; with\n // no DOM there is nothing to measure and no component to render, so it does nothing (#363).\n if (typeof Element === \"undefined\" || typeof HTMLElement === \"undefined\") return () => {};\n const restore: (() => void)[] = [];\n const replace = (target: object, prop: string, descriptor: PropertyDescriptor) => {\n const before = Object.getOwnPropertyDescriptor(target, prop);\n Object.defineProperty(target, prop, { configurable: true, ...descriptor });\n restore.push(() => {\n if (before) Object.defineProperty(target, prop, before);\n else delete (target as Record<string, unknown>)[prop];\n });\n };\n\n class FixedResizeObserver implements ResizeObserver {\n constructor(private readonly callback: ResizeObserverCallback) {}\n observe(target: Element) {\n this.callback([{ target, contentRect: { width, height } } as unknown as ResizeObserverEntry], this);\n }\n unobserve() {}\n disconnect() {}\n }\n if (!globalThis.ResizeObserver) replace(globalThis, \"ResizeObserver\", { writable: true, value: FixedResizeObserver });\n\n replace(Element.prototype, \"getBoundingClientRect\", {\n writable: true,\n value: () => box(0, 0, width, height),\n });\n for (const [prop, value] of [[\"offsetWidth\", width], [\"offsetHeight\", height], [\"clientWidth\", width], [\"clientHeight\", height]] as const) {\n replace(HTMLElement.prototype, prop, { get: () => value });\n }\n\n restore.push(installStorageShim());\n\n return () => {\n for (const undo of restore.reverse()) undo();\n };\n}\n","import { cleanup } from \"@testing-library/react\";\nimport { toast } from \"../components/toast\";\nimport { forgetLoadedThumbnails } from \"../components/thumbnail\";\nimport { installLayoutShims, type LayoutBox } from \"./layout\";\n\n// What every Strata app's test setup file repeats (issue #363, from the Quake 2 explorer's suite):\n// unmount what each test rendered, give jsdom a layout, and forget module state between tests.\n// With Vitest's `globals` off (its default) Testing Library does not register its own\n// `afterEach(cleanup)`, so each `renderRoutes` stacked on the last (a second test found four\n// `treegrid`s with the same name). Strata's own `tests/utils/setup.ts` calls `cleanup()` itself,\n// which hid it from us.\n//\n// It takes the runner's `afterEach` rather than importing `vitest`: the runner is the app's, and\n// naming it here would make it a dependency of the package (the stack decision is Jonathan's).\n// MSW and jest-dom stay the app's, in the lines around this call.\n\n/** The options of `setupStrataTests`. */\nexport type StrataTestSetup = {\n /** The runner's `afterEach` (`import { afterEach } from \"vitest\"`). */\n afterEach: (hook: () => void | Promise<void>) => void;\n /** The box every element reports (`installLayoutShims`); `false` to skip the shims. */\n layout?: Partial<LayoutBox> | false;\n};\n\n/**\n * One call in a Vitest setup file: installs the layout shims (a no-op without a DOM), and after each\n * test unmounts what it rendered, clears the toast queue and forgets loaded thumbnails. Returns a\n * function that puts the layout back. Add jest-dom and MSW's `server` lifecycle beside it.\n */\nexport function setupStrataTests({ afterEach, layout = {} }: StrataTestSetup): () => void {\n const restore = layout === false ? () => {} : installLayoutShims(layout);\n afterEach(() => {\n cleanup(); // a no-op where nothing was rendered, so node-environment files can share the setup\n toast.clear();\n forgetLoadedThumbnails();\n });\n return restore;\n}\n","// jsdom has no `speechSynthesis`, and the device's voices are a true external, so a test of a screen\n// that speaks needs a stand-in that records what was said (strata-react issue #299). This is the one\n// stand-in an app would otherwise write: it has `speak`, `cancel`, `getVoices`, `speaking` and the\n// voiceschanged event, it ends an utterance when the test says so (`finish()`), and it never makes a sound.\n// It stands in for `Audio` too (issue #310): a recorded clip that plays is said with its `clip`, `finish()`\n// ends it (the next part starts) and `failClip()` makes it fail, as a missing file or a refused autoplay does.\n\n/** One thing said aloud. */\nexport type Spoken = {\n text: string;\n lang: string;\n rate: number;\n voice: string | null;\n cancelled: boolean;\n /** The recording that was played, or null when the browser's voice said it. */\n clip: string | null;\n};\n\n/** The recording stand-in `installFakeSpeech` puts on `window`. */\nexport type FakeSpeech = {\n /** Everything said so far, in order; an utterance cut off by a later one has `cancelled: true`. */\n said: Spoken[];\n /** The texts said so far that were not cancelled. */\n texts(): string[];\n /** The clips played so far, in order (cut-off ones included). */\n clips(): string[];\n /** Ends the utterance or clip being said, as the browser does when it has finished. */\n finish(): void;\n /** Makes the clip playing now fail (a missing file, a refused autoplay): the rest of the prompt goes to the browser's voice. */\n failClip(): void;\n /** Makes these voices the device's, and fires `voiceschanged` (the late arrival some browsers have). */\n setVoices(voices: { name: string; lang: string }[]): void;\n /** Puts the browser's own back (or none). */\n uninstall(): void;\n};\n\n/**\n * Installs a recording `speechSynthesis` and `SpeechSynthesisUtterance` on `window` and returns what was said.\n * `uninstall()` after each test. `const speech = installFakeSpeech(); … expect(speech.texts()).toEqual([\"Which one is the cat?\"])`.\n */\nexport function installFakeSpeech(voices: { name: string; lang: string }[] = []): FakeSpeech {\n const hadSynth = Object.getOwnPropertyDescriptor(window, \"speechSynthesis\");\n const hadUtterance = Object.getOwnPropertyDescriptor(globalThis, \"SpeechSynthesisUtterance\");\n const hadAudio = Object.getOwnPropertyDescriptor(window, \"Audio\");\n let clip: { entry: Spoken; audio: FakeAudio } | undefined;\n let current: { entry: Spoken; utterance: FakeUtterance } | undefined;\n let installed = voices.map((v) => ({ ...v, default: false, localService: true, voiceURI: v.name }) as SpeechSynthesisVoice);\n const listeners = new Set<EventListener>();\n const said: Spoken[] = [];\n\n class FakeUtterance {\n lang = \"\";\n rate = 1;\n voice: SpeechSynthesisVoice | null = null;\n onend: (() => void) | null = null;\n onerror: (() => void) | null = null;\n constructor(public text: string) {}\n }\n\n // Only what `speak` uses of an audio element: src, title (the words), play, pause and the two events.\n class FakeAudio {\n src = \"\";\n title = \"\";\n onended: (() => void) | null = null;\n onerror: (() => void) | null = null;\n play() {\n const entry: Spoken = { text: this.title, lang: \"\", rate: 1, voice: null, cancelled: false, clip: this.src };\n said.push(entry);\n clip = { entry, audio: this };\n return Promise.resolve();\n }\n pause() {\n if (clip?.audio !== this) return;\n clip.entry.cancelled = true;\n clip = undefined;\n }\n }\n\n const synth = {\n get speaking() {\n return current !== undefined;\n },\n speak(utterance: FakeUtterance) {\n const entry: Spoken = { text: utterance.text, lang: utterance.lang, rate: utterance.rate, voice: utterance.voice?.name ?? null, cancelled: false, clip: null };\n said.push(entry);\n current = { entry, utterance };\n },\n cancel() {\n if (!current) return;\n const { entry, utterance } = current;\n current = undefined;\n entry.cancelled = true;\n utterance.onerror?.();\n },\n getVoices: () => installed,\n addEventListener: (_: string, l: EventListener) => void listeners.add(l),\n removeEventListener: (_: string, l: EventListener) => void listeners.delete(l),\n };\n\n Object.defineProperty(window, \"speechSynthesis\", { configurable: true, value: synth });\n Object.defineProperty(globalThis, \"SpeechSynthesisUtterance\", { configurable: true, writable: true, value: FakeUtterance });\n Object.defineProperty(window, \"Audio\", { configurable: true, writable: true, value: FakeAudio });\n\n return {\n said,\n texts: () => said.filter((s) => !s.cancelled).map((s) => s.text),\n clips: () => said.flatMap((s) => (s.clip === null ? [] : [s.clip])),\n finish() {\n if (clip) {\n const done = clip;\n clip = undefined;\n done.audio.onended?.();\n return;\n }\n const done = current;\n current = undefined;\n done?.utterance.onend?.();\n },\n failClip() {\n const failed = clip;\n clip = undefined;\n failed?.audio.onerror?.();\n },\n setVoices(next) {\n installed = next.map((v) => ({ ...v, default: false, localService: true, voiceURI: v.name }) as SpeechSynthesisVoice);\n for (const l of listeners) l(new Event(\"voiceschanged\"));\n },\n uninstall() {\n if (hadSynth) Object.defineProperty(window, \"speechSynthesis\", hadSynth);\n else delete (window as unknown as Record<string, unknown>).speechSynthesis;\n if (hadUtterance) Object.defineProperty(globalThis, \"SpeechSynthesisUtterance\", hadUtterance);\n else delete (globalThis as unknown as Record<string, unknown>).SpeechSynthesisUtterance;\n if (hadAudio) Object.defineProperty(window, \"Audio\", hadAudio);\n else delete (window as unknown as Record<string, unknown>).Audio;\n },\n };\n}\n","import { MicrophoneError, type Microphone } from \"../lib/microphone\";\n\n// The microphone is hardware, the one true external a recording screen has, and jsdom, Storybook and\n// the visual suite have none. This stand-in sends a sine tone at a chosen level, `speed` times faster\n// than real time (ten by default, so a test of a two-second take waits a fifth of a second), or refuses\n// to open with a sentence as the browser's refusals become (`explainMicrophoneError`). Give it to the\n// screen through `MicrophoneContext`, or `renderWithStrata(ui, { microphone })`.\n// For a hands-free screen (`useAutoRecorder`), `script` plays stretches of tone and quiet in turn, as a\n// speaker reading prompts with gaps between them would, once (then quiet) or over and over (`loop`).\n\n/** `fakeMicrophone`'s options. */\nexport type FakeMicrophoneOptions = {\n /** Peak of the tone, 0 to 1. Default 0.3 (about -10 dBFS, a good level for speech). */\n amplitude?: number;\n /** Refuse to open with this sentence, as a `MicrophoneError` (what a screen shows). */\n refuse?: string;\n /** Throw something that is not a `MicrophoneError` (an audio graph that failed). */\n crash?: boolean;\n /** What the browser calls the device. Default \"Fake USB microphone\". */\n device?: string | null;\n /** Open but never send a sample: a take held in its first moment, for a screenshot. */\n silent?: boolean;\n /** Samples a second. Default 16 000. */\n sampleRate?: number;\n /** How many times faster than real time the samples arrive. Default 10. */\n speed?: number;\n /** Stretches of tone at their own `amplitude` (0 for quiet), played in order instead of one steady tone. */\n script?: readonly FakeSpeechStretch[];\n /** Play `script` again from the start when it ends, instead of falling quiet. */\n loop?: boolean;\n};\n\n/** One stretch of a fake microphone's `script`: so many seconds at a peak (0 is quiet). */\nexport type FakeSpeechStretch = { seconds: number; amplitude: number };\n\n/** A script of `takes` stretches of speech, each `speak` seconds after `gap` seconds of quiet, at `amplitude`. */\nexport function speechScript(takes: number, { speak = 1.5, gap = 1.5, amplitude = 0.3 }: { speak?: number; gap?: number; amplitude?: number } = {}): FakeSpeechStretch[] {\n return Array.from({ length: takes }, () => [\n { seconds: gap, amplitude: 0 },\n { seconds: speak, amplitude },\n ]).flat();\n}\n\n/** A microphone that sends a tone (or refuses), for tests and stories; hardware is never touched. */\nexport function fakeMicrophone({\n amplitude = 0.3,\n refuse,\n crash,\n device = \"Fake USB microphone\",\n silent,\n sampleRate = 16_000,\n speed = 10,\n script,\n loop,\n}: FakeMicrophoneOptions = {}): Microphone {\n // The amplitude at sample `t`: the script's stretch it falls in, or the steady tone's.\n const ends = (script ?? []).reduce<number[]>((acc, s) => [...acc, (acc.at(-1) ?? 0) + Math.round(s.seconds * sampleRate)], []);\n const total = ends.at(-1) ?? 0;\n const at = (t: number): number => {\n if (!script) return amplitude;\n if (total === 0) return 0;\n const n = loop ? t % total : t;\n if (n >= total) return 0;\n const i = ends.findIndex((end) => n < end);\n return script[i].amplitude;\n };\n return {\n open(onSamples) {\n if (crash) return Promise.reject(new TypeError(\"audio graph exploded\"));\n if (refuse) return Promise.reject(new MicrophoneError(refuse));\n let t = 0;\n // A tenth of a second of sound each tick, every 100 / speed ms of real time.\n const frames = Math.round(sampleRate / 10);\n const timer = silent\n ? undefined\n : setInterval(() => {\n const chunk = new Float32Array(frames);\n for (let i = 0; i < frames; i++) chunk[i] = at(t) * Math.sin((2 * Math.PI * 220 * t++) / sampleRate);\n onSamples(chunk);\n }, 100 / speed);\n return Promise.resolve({ sampleRate, device, close: () => clearInterval(timer) });\n },\n };\n}\n","import type { Phase } from \"../components/async-button\";\n\n// Assertions for the rules a screen keeps, read from what the components draw rather than from\n// their class names (strata-react issue #48, from the Tubes Library test, which matched\n// `bg-primary`). `Button` marks its variant (`data-variant`), so \"one filled button per view\"\n// (ux-research patterns.md §2, with the BulkBar hand-over: while rows are chosen the bulk action is\n// the filled one) is a check a screen test can make after every interaction. `AsyncButton` marks\n// its phase (`data-phase`), because it keeps every phase's label in the DOM to hold its width, so\n// its text reads \"AddAdding…AddedTry again\" and only the phase says which one shows.\n\n/** Whether an element is out of the view: hidden, inert or aria-hidden, itself or by an ancestor. */\nfunction outOfView(el: Element) {\n return Boolean(el.closest('[hidden], [inert], [aria-hidden=\"true\"]'));\n}\n\n/** An element's name as a person reads it: its `aria-label`, else its text without the parts hidden from screen readers. */\nfunction nameOf(el: Element): string {\n const label = el.getAttribute(\"aria-label\");\n if (label) return label;\n const walk = (node: Node): string =>\n node.nodeType === 3\n ? (node.textContent ?? \"\")\n : node instanceof Element && node.getAttribute(\"aria-hidden\") === \"true\"\n ? \"\"\n : [...node.childNodes].map(walk).join(\"\");\n return walk(el).replace(/\\s+/g, \" \").trim();\n}\n\n/** The filled (`variant=\"default\"`) buttons and links in `container` (default the whole document) that are in view. */\nexport function filledButtons(container: ParentNode = document.body): HTMLElement[] {\n return [...container.querySelectorAll<HTMLElement>('[data-variant=\"default\"]')].filter((el) => !outOfView(el));\n}\n\n/** Throws unless `container` (default the whole document) has exactly one filled button in view; the message names the ones found. */\nexport function expectOneFilledButton(container: ParentNode = document.body): HTMLElement {\n const found = filledButtons(container);\n if (found.length === 1) return found[0];\n const names = found.map((el) => `\"${nameOf(el)}\"`).join(\", \");\n throw new Error(`Expected one filled button in the view, found ${found.length}${names ? `: ${names}` : \"\"}.`);\n}\n\n/** The phase an `AsyncButton` is in (`idle`, `pending`, `done`, `error`), from the button or any element inside it. */\nexport function asyncButtonPhase(el: Element): Phase {\n const phase = el.closest(\"[data-phase]\")?.getAttribute(\"data-phase\");\n if (phase === \"idle\" || phase === \"pending\" || phase === \"done\" || phase === \"error\") return phase;\n throw new Error(`Not an AsyncButton: ${el.outerHTML.slice(0, 120)}`);\n}\n","// jsdom has no IntersectionObserver and does no layout, so nothing a component observes ever comes\n// into view in a unit test. Infinite lists load the next page when a sentinel at the end of the\n// list intersects, and before this helper every app wrote its own firable fake to test that\n// (strata-react issue #12, from strata-listory). This one stands in for the global, records what\n// each observer watches, and lets the test say when something scrolls into view: `scrollToEnd()`\n// for the common case, `intersect(el)` for one element. Entries are delivered inside `act` so the\n// state updates they cause are flushed before the next assertion, as a real scroll would be.\n\nimport { act } from \"@testing-library/react\";\nimport { box } from \"./layout\";\n\n/** One stand-in observer: its callback, options and the elements it currently watches. */\nexport interface FakeObserver {\n readonly callback: IntersectionObserverCallback;\n readonly options: IntersectionObserverInit;\n readonly targets: ReadonlySet<Element>;\n}\n\n/** The controls `installFakeIntersectionObserver` returns. */\nexport interface FakeIntersectionObserverControls {\n /** Every observer created since install, including disconnected ones (their target sets are empty). */\n readonly observers: readonly FakeObserver[];\n /** Report `el` to every observer watching it: in view by default, or out of view with `false`. Returns how many observers were told. */\n intersect(el: Element, isIntersecting?: boolean): number;\n /** Report every watched element as in view, as if the person scrolled to the end of the list. Returns how many elements were reported. */\n scrollToEnd(): number;\n /** Put back whatever `IntersectionObserver` was there before install. */\n uninstall(): void;\n}\n\nfunction entryFor(target: Element, isIntersecting: boolean): IntersectionObserverEntry {\n const rect = target.getBoundingClientRect();\n return {\n target,\n isIntersecting,\n intersectionRatio: isIntersecting ? 1 : 0,\n boundingClientRect: rect,\n intersectionRect: isIntersecting ? rect : box(0, 0, 0, 0),\n rootBounds: null,\n time: performance.now(),\n };\n}\n\n/**\n * Replace `globalThis.IntersectionObserver` with a stand-in the test fires by hand. Call it in\n * `beforeEach` and call `uninstall()` in `afterEach`.\n *\n * @example\n * let io: FakeIntersectionObserverControls;\n * beforeEach(() => { io = installFakeIntersectionObserver(); });\n * afterEach(() => io.uninstall());\n *\n * it(\"loads the next page at the end of the list\", async () => {\n * renderWithStrata(<Pieces />);\n * await screen.findByRole(\"list\", { name: \"Pieces\" });\n * io.scrollToEnd();\n * expect(await screen.findByText(\"Celadon bowl\")).toBeInTheDocument();\n * });\n */\nexport function installFakeIntersectionObserver(): FakeIntersectionObserverControls {\n const previous = Object.getOwnPropertyDescriptor(globalThis, \"IntersectionObserver\");\n const observers: (FakeObserver & { targets: Set<Element>; self: IntersectionObserver })[] = [];\n\n class FakeIntersectionObserver implements IntersectionObserver {\n readonly root: Element | Document | null;\n readonly rootMargin: string;\n readonly thresholds: readonly number[];\n readonly scrollMargin = \"0px\";\n private readonly record: (typeof observers)[number];\n\n constructor(callback: IntersectionObserverCallback, options: IntersectionObserverInit = {}) {\n this.root = options.root ?? null;\n this.rootMargin = options.rootMargin ?? \"0px\";\n const threshold = options.threshold ?? 0;\n this.thresholds = Array.isArray(threshold) ? threshold : [threshold];\n this.record = { callback, options, targets: new Set(), self: this };\n observers.push(this.record);\n }\n observe(target: Element) {\n this.record.targets.add(target);\n }\n unobserve(target: Element) {\n this.record.targets.delete(target);\n }\n disconnect() {\n this.record.targets.clear();\n }\n takeRecords(): IntersectionObserverEntry[] {\n return [];\n }\n }\n\n Object.defineProperty(globalThis, \"IntersectionObserver\", {\n configurable: true,\n writable: true,\n value: FakeIntersectionObserver,\n });\n\n const deliver = (observer: (typeof observers)[number], targets: readonly Element[], isIntersecting: boolean) => {\n act(() => observer.callback(targets.map((t) => entryFor(t, isIntersecting)), observer.self));\n };\n\n return {\n observers,\n intersect(el, isIntersecting = true) {\n const watching = observers.filter((o) => o.targets.has(el));\n for (const o of watching) deliver(o, [el], isIntersecting);\n return watching.length;\n },\n scrollToEnd() {\n // Snapshot every observer's targets before any callback runs: a callback that loads more\n // may observe a new sentinel, on this observer or another, which the person has not\n // scrolled to yet.\n const batches = observers.map((o) => [o, [...o.targets]] as const).filter(([, targets]) => targets.length > 0);\n for (const [o, targets] of batches) deliver(o, targets, true);\n return batches.reduce((n, [, targets]) => n + targets.length, 0);\n },\n uninstall() {\n if (previous) Object.defineProperty(globalThis, \"IntersectionObserver\", previous);\n else delete (globalThis as { IntersectionObserver?: unknown }).IntersectionObserver;\n },\n };\n}\n","/**\n * Test helpers: render a component, or a whole route tree, inside a router and a query client, as\n * a Strata app runs it,\n * and fill the gaps jsdom leaves (layout, ResizeObserver, IntersectionObserver). Use with MSW for\n * the network, never module mocks.\n *\n * @module strata-react/testing\n */\nimport * as React from \"react\";\nimport { act, render, type RenderOptions } from \"@testing-library/react\";\nimport { MemoryRouter, RouterProvider, createMemoryRouter, type RouteObject, type To } from \"react-router\";\nimport { QueryClient } from \"@tanstack/react-query\";\nimport { StrataQueryProvider, createQueryClient } from \"../query\";\nimport { ThemeProvider, type ColorSchemePreference } from \"../components/theme\";\nimport { StrataToastRegion, toast } from \"../components/toast\";\nimport { forgetLoadedThumbnails } from \"../components/thumbnail\";\nimport { MicrophoneContext, type Microphone } from \"../lib/microphone\";\n\nexport { installLayoutShims, type LayoutBox } from \"./layout\";\nexport { setupStrataTests, type StrataTestSetup } from \"./setup\";\nexport { installStorageShim, memoryStorage } from \"./storage\";\nexport { installFakeSpeech, type FakeSpeech, type Spoken } from \"./speech\";\nexport { fakeMicrophone, speechScript, type FakeMicrophoneOptions, type FakeSpeechStretch } from \"./microphone\";\nexport { filledButtons, expectOneFilledButton, asyncButtonPhase } from \"./buttons\";\nexport {\n installFakeIntersectionObserver,\n type FakeIntersectionObserverControls,\n type FakeObserver,\n} from \"./intersection-observer\";\n\n// Render a component the way a Strata app runs it: inside a router and a query client. Tests use\n// MSW for the network (see CLAUDE.md), never module mocks, so the real fetch/query/DataView path\n// runs. Each call gets a fresh QueryClient with retries off, so a test that serves a 500 sees the\n// error at once instead of after the retry delay. It also runs inside a ThemeProvider with\n// storage off, so `useColorScheme` works and a test can render the dark scheme with\n// `colorScheme: \"dark\"` without touching localStorage or leaking state into the next test.\n\n/** A query client for tests: no retries, and nothing goes stale or is collected mid-test. */\nexport function createTestQueryClient() {\n return createQueryClient({ defaultOptions: { queries: { retry: false, staleTime: Infinity, gcTime: Infinity } } });\n}\n\n/** The options `renderWithStrata` and `renderRoutes` share, beside Testing Library's own. */\nexport type StrataRenderOptions = Omit<RenderOptions, \"wrapper\"> & {\n /** The URL the test starts at, with its search and hash (`/bookings?sort=pieces.desc`). Defaults to `/`. */\n route?: string;\n /** The query client; a fresh `createTestQueryClient()` when left out. */\n client?: QueryClient;\n /** The colour scheme to render; `light` when left out. */\n colorScheme?: ColorSchemePreference;\n /** Render the one `StrataToastRegion`, so `toast.show(...)` has somewhere to appear and a test can find it. Default true; pass `false` when the app's own route tree renders the region (a root layout route), or a test would see every toast twice. The queue is cleared at the start of each render, so a toast never carries into the next test. */\n toasts?: boolean;\n /** The microphone a recording screen gets from `useMicrophone()`, such as `fakeMicrophone()`; the browser's when left out (which jsdom cannot open). */\n microphone?: Microphone;\n /** The mount point of an app served behind a proxy (`\"/_home/\"`): a `<base href>` is in the document while the render lasts and removed when it unmounts, so `withBase`, `createApi` and `useSystemInfo` read what they read in production and in `strata-visual`. None when left out. */\n base?: string;\n};\n\n// A <base href> for one render (#350): `appBase()` reads the page's <base>, which jsdom does not have.\n// It is installed before the render (and before `renderRoutes` creates its router, whose loaders run\n// at creation and may call `withBase`), first in <head> so it wins over one a setup file left. It is\n// made once per render call, outside React's render, so Strict Mode cannot leave a second one behind;\n// the provider removes it when the tree unmounts (Testing Library's cleanup does that after each\n// test) and puts it back if Strict Mode's rehearsal of the effect took it out.\nfunction installBase(base: string | undefined): HTMLBaseElement | null {\n if (base === undefined || typeof document === \"undefined\") return null;\n const el = document.createElement(\"base\");\n el.setAttribute(\"href\", base);\n document.head.prepend(el);\n return el;\n}\n\nfunction useBaseElement(element: HTMLBaseElement | null | undefined) {\n React.useEffect(() => {\n if (element && !element.isConnected) document.head.prepend(element);\n return () => element?.remove();\n }, [element]);\n}\n\n// The providers every Strata app has above its router, in the order an app nests them.\nfunction StrataProviders({\n client,\n colorScheme,\n toasts,\n microphone,\n base,\n children,\n}: {\n base?: HTMLBaseElement | null;\n client: QueryClient;\n colorScheme: ColorSchemePreference;\n toasts: boolean;\n microphone?: Microphone;\n children: React.ReactNode;\n}) {\n useBaseElement(base);\n const tree = (\n <ThemeProvider defaultPreference={colorScheme} storageKey={null}>\n <StrataQueryProvider client={client}>\n {children}\n {toasts && <StrataToastRegion />}\n </StrataQueryProvider>\n </ThemeProvider>\n );\n return microphone ? <MicrophoneContext.Provider value={microphone}>{tree}</MicrophoneContext.Provider> : tree;\n}\n\n/** Testing Library's `render` inside `StrataQueryProvider` and a `MemoryRouter` at `route`. */\nexport function renderWithStrata(\n ui: React.ReactElement,\n { route = \"/\", client = createTestQueryClient(), colorScheme = \"light\", toasts = true, microphone, base, ...options }: StrataRenderOptions = {},\n) {\n toast.clear(); // module state: a toast from the last test must not show in this one\n forgetLoadedThumbnails(); // likewise the pictures a Thumbnail has loaded: each test starts from skeletons\n const baseElement = installBase(base);\n const Wrapper = ({ children }: { children: React.ReactNode }) => (\n <StrataProviders client={client} colorScheme={colorScheme} toasts={toasts} microphone={microphone} base={baseElement}>\n <MemoryRouter initialEntries={[route]}>{children}</MemoryRouter>\n </StrataProviders>\n );\n return { client, ...render(ui, { wrapper: Wrapper, ...options }) };\n}\n\n// Render an app's own route tree: its layout routes and <Outlet />s, index routes, redirects\n// (<Navigate /> or a loader's redirect()), loaders, actions and error elements. Those only run in\n// a data router, which <MemoryRouter> is not, so renderWithStrata cannot show them; this builds\n// the memory twin of the app's createBrowserRouter from the same RouteObject[] the app exports,\n// so the test and the app cannot drift. The providers and options are renderWithStrata's.\n// `basename` is the app's own (the kiln app runs under /kiln), and `route` is the full URL,\n// basename included, as the browser would show it. The router is returned so a test can assert\n// where a redirect landed (`router.state.location`), and `navigate` moves it inside act().\n\n/** `renderRoutes`'s options: `renderWithStrata`'s, plus the app's `basename`. */\nexport type RenderRoutesOptions = StrataRenderOptions & {\n /** The base path the app is served under, as passed to `createBrowserRouter`. */\n basename?: string;\n};\n\n/** Testing Library's `render` of an app's route tree in a memory data router at `route`, with Strata's providers. */\nexport function renderRoutes(\n routes: RouteObject[],\n {\n route,\n basename,\n client = createTestQueryClient(),\n colorScheme = \"light\",\n toasts = true,\n microphone,\n base,\n ...options\n }: RenderRoutesOptions = {},\n) {\n toast.clear();\n forgetLoadedThumbnails();\n const baseElement = installBase(base);\n const router = createMemoryRouter(routes, { initialEntries: [route ?? basename ?? \"/\"], basename });\n const result = render(\n <StrataProviders client={client} colorScheme={colorScheme} toasts={toasts} microphone={microphone} base={baseElement}>\n <RouterProvider router={router} />\n </StrataProviders>,\n options,\n );\n const navigate = (to: To | number) =>\n act(async () => {\n await (typeof to === \"number\" ? router.navigate(to) : router.navigate(to));\n });\n return { client, router, navigate, ...result };\n}\n"],"mappings":";;;;;;;;AASA,SAAgB,gBAAyB;CACvC,MAAM,uBAAO,IAAI,IAAoB;CACrC,OAAO;EACL,IAAI,SAAS;GACX,OAAO,KAAK;EACd;EACA,aAAa,KAAK,MAAM;EACxB,UAAU,QAAQ,KAAK,IAAI,OAAO,GAAG,CAAC,KAAK;EAC3C,MAAM,UAAU,CAAC,GAAG,KAAK,KAAK,CAAC,CAAC,CAAC,UAAU;EAC3C,aAAa,QAAQ,KAAK,KAAK,OAAO,OAAO,GAAG,CAAC;EACjD,UAAU,KAAK,UAAU,KAAK,KAAK,IAAI,OAAO,GAAG,GAAG,OAAO,KAAK,CAAC;CACnE;AACF;AAEA,SAAS,OAAO,MAAkD;CAChE,IAAI;EACF,OAAO,OAAQ,WAA8D,KAAK,EAAE,YAAY;CAClG,QAAQ;EACN,OAAO;CACT;AACF;;;;;AAMA,SAAgB,qBAAiC;CAC/C,MAAM,UAA0B,CAAC;CACjC,KAAK,MAAM,QAAQ,CAAC,gBAAgB,gBAAgB,GAAY;EAC9D,IAAI,OAAO,IAAI,GAAG;EAClB,MAAM,UAAU,cAAc;EAC9B,MAAM,UAAU,CAAC,YAAY,OAAO,WAAW,cAAc,SAAS,KAAA,CAAS,CAAC,CAAC,QAAQ,MAA8B,MAAM,KAAA,CAAS;EACtI,KAAK,MAAM,UAAU,IAAI,IAAI,OAAO,GAAG;GACrC,MAAM,SAAS,OAAO,yBAAyB,QAAQ,IAAI;GAC3D,OAAO,eAAe,QAAQ,MAAM;IAAE,cAAc;IAAM,OAAO;GAAQ,CAAC;GAC1E,QAAQ,WAAW;IACjB,IAAI,QAAQ,OAAO,eAAe,QAAQ,MAAM,MAAM;SACjD,OAAQ,OAA8C;GAC7D,CAAC;EACH;EACA,MAAM,QAAS,WAAwD;E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S,mBAAmB,QAAQ;EAAE,gBAAgB,CAAC,SAAS,YAAY,GAAG;EAAG;CAAS,CAAC;CAClG,MAAM,SAAS,OACb,oBAAC,iBAAD;EAAyB;EAAqB;EAAqB;EAAoB;EAAY,MAAM;EACvG,UAAA,oBAAC,gBAAD,EAAwB,OAAS,CAAA;CAClB,CAAA,GACjB,OACF;CACA,MAAM,YAAY,OAChB,IAAI,YAAY;EACd,OAAO,OAAO,OAAO,WAAW,OAAO,SAAS,EAAE,IAAI,OAAO,SAAS,EAAE;CAC1E,CAAC;CACH,OAAO;EAAE;EAAQ;EAAQ;EAAU,GAAG;CAAO;AAC/C"}
1
+ {"version":3,"file":"testing.js","names":[],"sources":["../src/testing/storage.ts","../src/testing/layout.ts","../src/testing/setup.ts","../src/testing/speech.ts","../src/testing/microphone.ts","../src/testing/buttons.ts","../src/testing/intersection-observer.ts","../src/testing/index.tsx"],"sourcesContent":["// Node 25 and later define a global `localStorage` that is undefined unless Node runs with\n// `--localstorage-file`, and it shadows jsdom's. In a Vitest jsdom project on Node 26 (Strata's floor)\n// `localStorage.getItem` then throws, so any app code that reads storage (a remembered choice, a\n// `ColorSchemeChoice` on a settings screen tested with storage on) fails in its tests. Strata's own\n// tests never hit it because `renderWithStrata` turns theme storage off. Every app would have copied\n// the same dozen lines (issue #298), so `installLayoutShims` installs this when, and only when, the\n// platform's storage is unusable; where it works nothing is replaced.\n\n/** An in-memory `Storage`, with the platform's behaviour (values are strings, `key` and `length` work). */\nexport function memoryStorage(): Storage {\n const data = new Map<string, string>();\n return {\n get length() {\n return data.size;\n },\n clear: () => data.clear(),\n getItem: (key) => data.get(String(key)) ?? null,\n key: (index) => [...data.keys()][index] ?? null,\n removeItem: (key) => void data.delete(String(key)),\n setItem: (key, value) => void data.set(String(key), String(value)),\n };\n}\n\nfunction usable(name: \"localStorage\" | \"sessionStorage\"): boolean {\n try {\n return typeof (globalThis as unknown as Record<string, Storage | undefined>)[name]?.getItem === \"function\";\n } catch {\n return false;\n }\n}\n\n/**\n * Replaces `localStorage` and `sessionStorage` with in-memory ones where the runtime's are missing or throw (Node 25+ under jsdom), and empties them after each test when the test runner has a global `afterEach`.\n * Does nothing where storage works. Returns a function that puts the originals back. Called by `installLayoutShims`.\n */\nexport function installStorageShim(): () => void {\n const restore: (() => void)[] = [];\n for (const name of [\"localStorage\", \"sessionStorage\"] as const) {\n if (usable(name)) continue;\n const storage = memoryStorage();\n const targets = [globalThis, typeof window !== \"undefined\" ? window : undefined].filter(\n (t): t is typeof globalThis => t !== undefined,\n );\n for (const target of new Set(targets)) {\n const before = Object.getOwnPropertyDescriptor(target, name);\n Object.defineProperty(target, name, { configurable: true, value: storage });\n restore.push(() => {\n if (before) Object.defineProperty(target, name, before);\n else delete (target as unknown as Record<string, unknown>)[name];\n });\n }\n const after = (globalThis as { afterEach?: (fn: () => void) => void }).afterEach;\n if (typeof after === \"function\") after(() => storage.clear());\n }\n return () => {\n for (const undo of restore.reverse()) undo();\n };\n}\n","// jsdom does no layout: every box is 0×0 and there is no ResizeObserver. Components that measure\n// (LineChart's width; React Aria's Virtualizer draws every row of a list in a test unless the box is mocked, which these shims do not make smaller. A virtualised table with detail rows, or a virtualised grid of tiles, measures each row by its scroll size, which jsdom reports as 0: a test of one gives `Element.prototype.scrollHeight` a value) then render nothing to\n// assert on, so an app testing a screen built from them hits the same wall Strata's own suite did.\n// These shims give every element one fixed box and a ResizeObserver that reports it once on\n// observe (and, on Node 25+, a working in-memory localStorage: see storage.ts). Real layout is checked by the visual suite in Chromium, never here.\n\nimport { installStorageShim } from \"./storage\";\n\n// jsdom has no DOMRect constructor in every version, so rects are plain objects of the same shape.\n/** A DOMRect-shaped object, for stand-ins that report geometry. */\nexport function box(x: number, y: number, width: number, height: number): DOMRect {\n return {\n x,\n y,\n width,\n height,\n top: y,\n left: x,\n right: x + width,\n bottom: y + height,\n toJSON() {\n return this;\n },\n } as DOMRect;\n}\n\n/** The box every element reports while the shims are installed. */\nexport interface LayoutBox {\n width: number;\n height: number;\n}\n\n/**\n * Give jsdom a fixed box for every element (`getBoundingClientRect`, `offset*`, `client*`) and a\n * ResizeObserver that reports it on observe, so measuring components render, and an in-memory `localStorage` and `sessionStorage` where the runtime's throw (Node 25+). Defaults to 640×280.\n * Call once in a Vitest setup file (or let `setupStrataTests` do it); does nothing, and returns a no-op, where there is no DOM (a node-environment test); returns a function that puts the originals back.\n */\nexport function installLayoutShims({ width = 640, height = 280 }: Partial<LayoutBox> = {}): () => void {\n // A setup file shared by jsdom tests and `// @vitest-environment node` ones runs this in both; with\n // no DOM there is nothing to measure and no component to render, so it does nothing (#363).\n if (typeof Element === \"undefined\" || typeof HTMLElement === \"undefined\") return () => {};\n const restore: (() => void)[] = [];\n const replace = (target: object, prop: string, descriptor: PropertyDescriptor) => {\n const before = Object.getOwnPropertyDescriptor(target, prop);\n Object.defineProperty(target, prop, { configurable: true, ...descriptor });\n restore.push(() => {\n if (before) Object.defineProperty(target, prop, before);\n else delete (target as Record<string, unknown>)[prop];\n });\n };\n\n class FixedResizeObserver implements ResizeObserver {\n constructor(private readonly callback: ResizeObserverCallback) {}\n observe(target: Element) {\n this.callback([{ target, contentRect: { width, height } } as unknown as ResizeObserverEntry], this);\n }\n unobserve() {}\n disconnect() {}\n }\n if (!globalThis.ResizeObserver) replace(globalThis, \"ResizeObserver\", { writable: true, value: FixedResizeObserver });\n\n replace(Element.prototype, \"getBoundingClientRect\", {\n writable: true,\n value: () => box(0, 0, width, height),\n });\n for (const [prop, value] of [\n [\"offsetWidth\", width],\n [\"offsetHeight\", height],\n [\"clientWidth\", width],\n [\"clientHeight\", height],\n ] as const) {\n replace(HTMLElement.prototype, prop, { get: () => value });\n }\n\n restore.push(installStorageShim());\n\n return () => {\n for (const undo of restore.reverse()) undo();\n };\n}\n","import { cleanup } from \"@testing-library/react\";\nimport { toast } from \"../components/toast\";\nimport { forgetLoadedThumbnails } from \"../components/thumbnail\";\nimport { installLayoutShims, type LayoutBox } from \"./layout\";\n\n// What every Strata app's test setup file repeats (issue #363, from the Quake 2 explorer's suite):\n// unmount what each test rendered, give jsdom a layout, and forget module state between tests.\n// With Vitest's `globals` off (its default) Testing Library does not register its own\n// `afterEach(cleanup)`, so each `renderRoutes` stacked on the last (a second test found four\n// `treegrid`s with the same name). Strata's own `tests/utils/setup.ts` calls `cleanup()` itself,\n// which hid it from us.\n//\n// It takes the runner's `afterEach` rather than importing `vitest`: the runner is the app's, and\n// naming it here would make it a dependency of the package (the stack decision is Jonathan's).\n// MSW and jest-dom stay the app's, in the lines around this call.\n\n/** The options of `setupStrataTests`. */\nexport type StrataTestSetup = {\n /** The runner's `afterEach` (`import { afterEach } from \"vitest\"`). */\n afterEach: (hook: () => void | Promise<void>) => void;\n /** The box every element reports (`installLayoutShims`); `false` to skip the shims. */\n layout?: Partial<LayoutBox> | false;\n};\n\n/**\n * One call in a Vitest setup file: installs the layout shims (a no-op without a DOM), and after each\n * test unmounts what it rendered, clears the toast queue and forgets loaded thumbnails. Returns a\n * function that puts the layout back. Add jest-dom and MSW's `server` lifecycle beside it.\n */\nexport function setupStrataTests({ afterEach, layout = {} }: StrataTestSetup): () => void {\n const restore = layout === false ? () => {} : installLayoutShims(layout);\n afterEach(() => {\n cleanup(); // a no-op where nothing was rendered, so node-environment files can share the setup\n toast.clear();\n forgetLoadedThumbnails();\n });\n return restore;\n}\n","// jsdom has no `speechSynthesis`, and the device's voices are a true external, so a test of a screen\n// that speaks needs a stand-in that records what was said (strata-react issue #299). This is the one\n// stand-in an app would otherwise write: it has `speak`, `cancel`, `getVoices`, `speaking` and the\n// voiceschanged event, it ends an utterance when the test says so (`finish()`), and it never makes a sound.\n// It stands in for `Audio` too (issue #310): a recorded clip that plays is said with its `clip`, `finish()`\n// ends it (the next part starts) and `failClip()` makes it fail, as a missing file or a refused autoplay does.\n\n/** One thing said aloud. */\nexport type Spoken = {\n text: string;\n lang: string;\n rate: number;\n voice: string | null;\n cancelled: boolean;\n /** The recording that was played, or null when the browser's voice said it. */\n clip: string | null;\n};\n\n/** The recording stand-in `installFakeSpeech` puts on `window`. */\nexport type FakeSpeech = {\n /** Everything said so far, in order; an utterance cut off by a later one has `cancelled: true`. */\n said: Spoken[];\n /** The texts said so far that were not cancelled. */\n texts(): string[];\n /** The clips played so far, in order (cut-off ones included). */\n clips(): string[];\n /** Ends the utterance or clip being said, as the browser does when it has finished. */\n finish(): void;\n /** Makes the clip playing now fail (a missing file, a refused autoplay): the rest of the prompt goes to the browser's voice. */\n failClip(): void;\n /** Makes these voices the device's, and fires `voiceschanged` (the late arrival some browsers have). */\n setVoices(voices: { name: string; lang: string }[]): void;\n /** Puts the browser's own back (or none). */\n uninstall(): void;\n};\n\n/**\n * Installs a recording `speechSynthesis` and `SpeechSynthesisUtterance` on `window` and returns what was said.\n * `uninstall()` after each test. `const speech = installFakeSpeech(); … expect(speech.texts()).toEqual([\"Which one is the cat?\"])`.\n */\nexport function installFakeSpeech(voices: { name: string; lang: string }[] = []): FakeSpeech {\n const hadSynth = Object.getOwnPropertyDescriptor(window, \"speechSynthesis\");\n const hadUtterance = Object.getOwnPropertyDescriptor(globalThis, \"SpeechSynthesisUtterance\");\n const hadAudio = Object.getOwnPropertyDescriptor(window, \"Audio\");\n let clip: { entry: Spoken; audio: FakeAudio } | undefined;\n let current: { entry: Spoken; utterance: FakeUtterance } | undefined;\n let installed = voices.map(\n (v) => ({ ...v, default: false, localService: true, voiceURI: v.name }) as SpeechSynthesisVoice,\n );\n const listeners = new Set<EventListener>();\n const said: Spoken[] = [];\n\n class FakeUtterance {\n lang = \"\";\n rate = 1;\n voice: SpeechSynthesisVoice | null = null;\n onend: (() => void) | null = null;\n onerror: (() => void) | null = null;\n constructor(public text: string) {}\n }\n\n // Only what `speak` uses of an audio element: src, title (the words), play, pause and the two events.\n class FakeAudio {\n src = \"\";\n title = \"\";\n onended: (() => void) | null = null;\n onerror: (() => void) | null = null;\n play() {\n const entry: Spoken = { text: this.title, lang: \"\", rate: 1, voice: null, cancelled: false, clip: this.src };\n said.push(entry);\n clip = { entry, audio: this };\n return Promise.resolve();\n }\n pause() {\n if (clip?.audio !== this) return;\n clip.entry.cancelled = true;\n clip = undefined;\n }\n }\n\n const synth = {\n get speaking() {\n return current !== undefined;\n },\n speak(utterance: FakeUtterance) {\n const entry: Spoken = {\n text: utterance.text,\n lang: utterance.lang,\n rate: utterance.rate,\n voice: utterance.voice?.name ?? null,\n cancelled: false,\n clip: null,\n };\n said.push(entry);\n current = { entry, utterance };\n },\n cancel() {\n if (!current) return;\n const { entry, utterance } = current;\n current = undefined;\n entry.cancelled = true;\n utterance.onerror?.();\n },\n getVoices: () => installed,\n addEventListener: (_: string, l: EventListener) => void listeners.add(l),\n removeEventListener: (_: string, l: EventListener) => void listeners.delete(l),\n };\n\n Object.defineProperty(window, \"speechSynthesis\", { configurable: true, value: synth });\n Object.defineProperty(globalThis, \"SpeechSynthesisUtterance\", {\n configurable: true,\n writable: true,\n value: FakeUtterance,\n });\n Object.defineProperty(window, \"Audio\", { configurable: true, writable: true, value: FakeAudio });\n\n return {\n said,\n texts: () => said.filter((s) => !s.cancelled).map((s) => s.text),\n clips: () => said.flatMap((s) => (s.clip === null ? [] : [s.clip])),\n finish() {\n if (clip) {\n const done = clip;\n clip = undefined;\n done.audio.onended?.();\n return;\n }\n const done = current;\n current = undefined;\n done?.utterance.onend?.();\n },\n failClip() {\n const failed = clip;\n clip = undefined;\n failed?.audio.onerror?.();\n },\n setVoices(next) {\n installed = next.map(\n (v) => ({ ...v, default: false, localService: true, voiceURI: v.name }) as SpeechSynthesisVoice,\n );\n for (const l of listeners) l(new Event(\"voiceschanged\"));\n },\n uninstall() {\n if (hadSynth) Object.defineProperty(window, \"speechSynthesis\", hadSynth);\n else delete (window as unknown as Record<string, unknown>).speechSynthesis;\n if (hadUtterance) Object.defineProperty(globalThis, \"SpeechSynthesisUtterance\", hadUtterance);\n else delete (globalThis as unknown as Record<string, unknown>).SpeechSynthesisUtterance;\n if (hadAudio) Object.defineProperty(window, \"Audio\", hadAudio);\n else delete (window as unknown as Record<string, unknown>).Audio;\n },\n };\n}\n","import { MicrophoneError, type Microphone } from \"../lib/microphone\";\n\n// The microphone is hardware, the one true external a recording screen has, and jsdom, Storybook and\n// the visual suite have none. This stand-in sends a sine tone at a chosen level, `speed` times faster\n// than real time (ten by default, so a test of a two-second take waits a fifth of a second), or refuses\n// to open with a sentence as the browser's refusals become (`explainMicrophoneError`). Give it to the\n// screen through `MicrophoneContext`, or `renderWithStrata(ui, { microphone })`.\n// For a hands-free screen (`useAutoRecorder`), `script` plays stretches of tone and quiet in turn, as a\n// speaker reading prompts with gaps between them would, once (then quiet) or over and over (`loop`).\n\n/** `fakeMicrophone`'s options. */\nexport type FakeMicrophoneOptions = {\n /** Peak of the tone, 0 to 1. Default 0.3 (about -10 dBFS, a good level for speech). */\n amplitude?: number;\n /** Refuse to open with this sentence, as a `MicrophoneError` (what a screen shows). */\n refuse?: string;\n /** Throw something that is not a `MicrophoneError` (an audio graph that failed). */\n crash?: boolean;\n /** What the browser calls the device. Default \"Fake USB microphone\". */\n device?: string | null;\n /** Open but never send a sample: a take held in its first moment, for a screenshot. */\n silent?: boolean;\n /** Samples a second. Default 16 000. */\n sampleRate?: number;\n /** How many times faster than real time the samples arrive. Default 10. */\n speed?: number;\n /** Stretches of tone at their own `amplitude` (0 for quiet), played in order instead of one steady tone. */\n script?: readonly FakeSpeechStretch[];\n /** Play `script` again from the start when it ends, instead of falling quiet. */\n loop?: boolean;\n};\n\n/** One stretch of a fake microphone's `script`: so many seconds at a peak (0 is quiet). */\nexport type FakeSpeechStretch = { seconds: number; amplitude: number };\n\n/** A script of `takes` stretches of speech, each `speak` seconds after `gap` seconds of quiet, at `amplitude`. */\nexport function speechScript(\n takes: number,\n { speak = 1.5, gap = 1.5, amplitude = 0.3 }: { speak?: number; gap?: number; amplitude?: number } = {},\n): FakeSpeechStretch[] {\n return Array.from({ length: takes }, () => [\n { seconds: gap, amplitude: 0 },\n { seconds: speak, amplitude },\n ]).flat();\n}\n\n/** A microphone that sends a tone (or refuses), for tests and stories; hardware is never touched. */\nexport function fakeMicrophone({\n amplitude = 0.3,\n refuse,\n crash,\n device = \"Fake USB microphone\",\n silent,\n sampleRate = 16_000,\n speed = 10,\n script,\n loop,\n}: FakeMicrophoneOptions = {}): Microphone {\n // The amplitude at sample `t`: the script's stretch it falls in, or the steady tone's.\n const ends = (script ?? []).reduce<number[]>(\n (acc, s) => [...acc, (acc.at(-1) ?? 0) + Math.round(s.seconds * sampleRate)],\n [],\n );\n const total = ends.at(-1) ?? 0;\n const at = (t: number): number => {\n if (!script) return amplitude;\n if (total === 0) return 0;\n const n = loop ? t % total : t;\n if (n >= total) return 0;\n const i = ends.findIndex((end) => n < end);\n return script[i].amplitude;\n };\n return {\n open(onSamples) {\n if (crash) return Promise.reject(new TypeError(\"audio graph exploded\"));\n if (refuse) return Promise.reject(new MicrophoneError(refuse));\n let t = 0;\n // A tenth of a second of sound each tick, every 100 / speed ms of real time.\n const frames = Math.round(sampleRate / 10);\n const timer = silent\n ? undefined\n : setInterval(() => {\n const chunk = new Float32Array(frames);\n for (let i = 0; i < frames; i++) chunk[i] = at(t) * Math.sin((2 * Math.PI * 220 * t++) / sampleRate);\n onSamples(chunk);\n }, 100 / speed);\n return Promise.resolve({ sampleRate, device, close: () => clearInterval(timer) });\n },\n };\n}\n","import type { Phase } from \"../components/async-button\";\n\n// Assertions for the rules a screen keeps, read from what the components draw rather than from\n// their class names (strata-react issue #48, from the Tubes Library test, which matched\n// `bg-primary`). `Button` marks its variant (`data-variant`), so \"one filled button per view\"\n// (ux-research patterns.md §2, with the BulkBar hand-over: while rows are chosen the bulk action is\n// the filled one) is a check a screen test can make after every interaction. `AsyncButton` marks\n// its phase (`data-phase`), because it keeps every phase's label in the DOM to hold its width, so\n// its text reads \"AddAdding…AddedTry again\" and only the phase says which one shows.\n\n/** Whether an element is out of the view: hidden, inert or aria-hidden, itself or by an ancestor. */\nfunction outOfView(el: Element) {\n return Boolean(el.closest('[hidden], [inert], [aria-hidden=\"true\"]'));\n}\n\n/** An element's name as a person reads it: its `aria-label`, else its text without the parts hidden from screen readers. */\nfunction nameOf(el: Element): string {\n const label = el.getAttribute(\"aria-label\");\n if (label) return label;\n const walk = (node: Node): string =>\n node.nodeType === 3\n ? (node.textContent ?? \"\")\n : node instanceof Element && node.getAttribute(\"aria-hidden\") === \"true\"\n ? \"\"\n : [...node.childNodes].map(walk).join(\"\");\n return walk(el).replace(/\\s+/g, \" \").trim();\n}\n\n/** The filled (`variant=\"default\"`) buttons and links in `container` (default the whole document) that are in view. */\nexport function filledButtons(container: ParentNode = document.body): HTMLElement[] {\n return [...container.querySelectorAll<HTMLElement>('[data-variant=\"default\"]')].filter((el) => !outOfView(el));\n}\n\n/** Throws unless `container` (default the whole document) has exactly one filled button in view; the message names the ones found. */\nexport function expectOneFilledButton(container: ParentNode = document.body): HTMLElement {\n const found = filledButtons(container);\n if (found.length === 1) return found[0];\n const names = found.map((el) => `\"${nameOf(el)}\"`).join(\", \");\n throw new Error(`Expected one filled button in the view, found ${found.length}${names ? `: ${names}` : \"\"}.`);\n}\n\n/** The phase an `AsyncButton` is in (`idle`, `pending`, `done`, `error`), from the button or any element inside it. */\nexport function asyncButtonPhase(el: Element): Phase {\n const phase = el.closest(\"[data-phase]\")?.getAttribute(\"data-phase\");\n if (phase === \"idle\" || phase === \"pending\" || phase === \"done\" || phase === \"error\") return phase;\n throw new Error(`Not an AsyncButton: ${el.outerHTML.slice(0, 120)}`);\n}\n","// jsdom has no IntersectionObserver and does no layout, so nothing a component observes ever comes\n// into view in a unit test. Infinite lists load the next page when a sentinel at the end of the\n// list intersects, and before this helper every app wrote its own firable fake to test that\n// (strata-react issue #12, from strata-listory). This one stands in for the global, records what\n// each observer watches, and lets the test say when something scrolls into view: `scrollToEnd()`\n// for the common case, `intersect(el)` for one element. Entries are delivered inside `act` so the\n// state updates they cause are flushed before the next assertion, as a real scroll would be.\n\nimport { act } from \"@testing-library/react\";\nimport { box } from \"./layout\";\n\n/** One stand-in observer: its callback, options and the elements it currently watches. */\nexport interface FakeObserver {\n readonly callback: IntersectionObserverCallback;\n readonly options: IntersectionObserverInit;\n readonly targets: ReadonlySet<Element>;\n}\n\n/** The controls `installFakeIntersectionObserver` returns. */\nexport interface FakeIntersectionObserverControls {\n /** Every observer created since install, including disconnected ones (their target sets are empty). */\n readonly observers: readonly FakeObserver[];\n /** Report `el` to every observer watching it: in view by default, or out of view with `false`. Returns how many observers were told. */\n intersect(el: Element, isIntersecting?: boolean): number;\n /** Report every watched element as in view, as if the person scrolled to the end of the list. Returns how many elements were reported. */\n scrollToEnd(): number;\n /** Put back whatever `IntersectionObserver` was there before install. */\n uninstall(): void;\n}\n\nfunction entryFor(target: Element, isIntersecting: boolean): IntersectionObserverEntry {\n const rect = target.getBoundingClientRect();\n return {\n target,\n isIntersecting,\n intersectionRatio: isIntersecting ? 1 : 0,\n boundingClientRect: rect,\n intersectionRect: isIntersecting ? rect : box(0, 0, 0, 0),\n rootBounds: null,\n time: performance.now(),\n };\n}\n\n/**\n * Replace `globalThis.IntersectionObserver` with a stand-in the test fires by hand. Call it in\n * `beforeEach` and call `uninstall()` in `afterEach`.\n *\n * @example\n * let io: FakeIntersectionObserverControls;\n * beforeEach(() => { io = installFakeIntersectionObserver(); });\n * afterEach(() => io.uninstall());\n *\n * it(\"loads the next page at the end of the list\", async () => {\n * renderWithStrata(<Pieces />);\n * await screen.findByRole(\"list\", { name: \"Pieces\" });\n * io.scrollToEnd();\n * expect(await screen.findByText(\"Celadon bowl\")).toBeInTheDocument();\n * });\n */\nexport function installFakeIntersectionObserver(): FakeIntersectionObserverControls {\n const previous = Object.getOwnPropertyDescriptor(globalThis, \"IntersectionObserver\");\n const observers: (FakeObserver & { targets: Set<Element>; self: IntersectionObserver })[] = [];\n\n class FakeIntersectionObserver implements IntersectionObserver {\n readonly root: Element | Document | null;\n readonly rootMargin: string;\n readonly thresholds: readonly number[];\n readonly scrollMargin = \"0px\";\n private readonly record: (typeof observers)[number];\n\n constructor(callback: IntersectionObserverCallback, options: IntersectionObserverInit = {}) {\n this.root = options.root ?? null;\n this.rootMargin = options.rootMargin ?? \"0px\";\n const threshold = options.threshold ?? 0;\n this.thresholds = Array.isArray(threshold) ? threshold : [threshold];\n this.record = { callback, options, targets: new Set(), self: this };\n observers.push(this.record);\n }\n observe(target: Element) {\n this.record.targets.add(target);\n }\n unobserve(target: Element) {\n this.record.targets.delete(target);\n }\n disconnect() {\n this.record.targets.clear();\n }\n takeRecords(): IntersectionObserverEntry[] {\n return [];\n }\n }\n\n Object.defineProperty(globalThis, \"IntersectionObserver\", {\n configurable: true,\n writable: true,\n value: FakeIntersectionObserver,\n });\n\n const deliver = (observer: (typeof observers)[number], targets: readonly Element[], isIntersecting: boolean) => {\n act(() =>\n observer.callback(\n targets.map((t) => entryFor(t, isIntersecting)),\n observer.self,\n ),\n );\n };\n\n return {\n observers,\n intersect(el, isIntersecting = true) {\n const watching = observers.filter((o) => o.targets.has(el));\n for (const o of watching) deliver(o, [el], isIntersecting);\n return watching.length;\n },\n scrollToEnd() {\n // Snapshot every observer's targets before any callback runs: a callback that loads more\n // may observe a new sentinel, on this observer or another, which the person has not\n // scrolled to yet.\n const batches = observers.map((o) => [o, [...o.targets]] as const).filter(([, targets]) => targets.length > 0);\n for (const [o, targets] of batches) deliver(o, targets, true);\n return batches.reduce((n, [, targets]) => n + targets.length, 0);\n },\n uninstall() {\n if (previous) Object.defineProperty(globalThis, \"IntersectionObserver\", previous);\n else delete (globalThis as { IntersectionObserver?: unknown }).IntersectionObserver;\n },\n };\n}\n","/**\n * Test helpers: render a component, or a whole route tree, inside a router and a query client, as\n * a Strata app runs it,\n * and fill the gaps jsdom leaves (layout, ResizeObserver, IntersectionObserver). Use with MSW for\n * the network, never module mocks.\n *\n * @module strata-react/testing\n */\nimport * as React from \"react\";\nimport { act, render, type RenderOptions } from \"@testing-library/react\";\nimport { MemoryRouter, RouterProvider, createMemoryRouter, type RouteObject, type To } from \"react-router\";\nimport { QueryClient } from \"@tanstack/react-query\";\nimport { StrataQueryProvider, createQueryClient } from \"../query\";\nimport { ThemeProvider, type ColorSchemePreference } from \"../components/theme\";\nimport { StrataToastRegion, toast } from \"../components/toast\";\nimport { forgetLoadedThumbnails } from \"../components/thumbnail\";\nimport { MicrophoneContext, type Microphone } from \"../lib/microphone\";\n\nexport { installLayoutShims, type LayoutBox } from \"./layout\";\nexport { setupStrataTests, type StrataTestSetup } from \"./setup\";\nexport { installStorageShim, memoryStorage } from \"./storage\";\nexport { installFakeSpeech, type FakeSpeech, type Spoken } from \"./speech\";\nexport { fakeMicrophone, speechScript, type FakeMicrophoneOptions, type FakeSpeechStretch } from \"./microphone\";\nexport { filledButtons, expectOneFilledButton, asyncButtonPhase } from \"./buttons\";\nexport {\n installFakeIntersectionObserver,\n type FakeIntersectionObserverControls,\n type FakeObserver,\n} from \"./intersection-observer\";\n\n// Render a component the way a Strata app runs it: inside a router and a query client. Tests use\n// MSW for the network (see CLAUDE.md), never module mocks, so the real fetch/query/DataView path\n// runs. Each call gets a fresh QueryClient with retries off, so a test that serves a 500 sees the\n// error at once instead of after the retry delay. It also runs inside a ThemeProvider with\n// storage off, so `useColorScheme` works and a test can render the dark scheme with\n// `colorScheme: \"dark\"` without touching localStorage or leaking state into the next test.\n\n/** A query client for tests: no retries, and nothing goes stale or is collected mid-test. */\nexport function createTestQueryClient() {\n return createQueryClient({ defaultOptions: { queries: { retry: false, staleTime: Infinity, gcTime: Infinity } } });\n}\n\n/** The options `renderWithStrata` and `renderRoutes` share, beside Testing Library's own. */\nexport type StrataRenderOptions = Omit<RenderOptions, \"wrapper\"> & {\n /** The URL the test starts at, with its search and hash (`/bookings?sort=pieces.desc`). Defaults to `/`. */\n route?: string;\n /** The query client; a fresh `createTestQueryClient()` when left out. */\n client?: QueryClient;\n /** The colour scheme to render; `light` when left out. */\n colorScheme?: ColorSchemePreference;\n /** Render the one `StrataToastRegion`, so `toast.show(...)` has somewhere to appear and a test can find it. Default true; pass `false` when the app's own route tree renders the region (a root layout route), or a test would see every toast twice. The queue is cleared at the start of each render, so a toast never carries into the next test. */\n toasts?: boolean;\n /** The microphone a recording screen gets from `useMicrophone()`, such as `fakeMicrophone()`; the browser's when left out (which jsdom cannot open). */\n microphone?: Microphone;\n /** The mount point of an app served behind a proxy (`\"/_home/\"`): a `<base href>` is in the document while the render lasts and removed when it unmounts, so `withBase`, `createApi` and `useSystemInfo` read what they read in production and in `strata-visual`. None when left out. */\n base?: string;\n};\n\n// A <base href> for one render (#350): `appBase()` reads the page's <base>, which jsdom does not have.\n// It is installed before the render (and before `renderRoutes` creates its router, whose loaders run\n// at creation and may call `withBase`), first in <head> so it wins over one a setup file left. It is\n// made once per render call, outside React's render, so Strict Mode cannot leave a second one behind;\n// the provider removes it when the tree unmounts (Testing Library's cleanup does that after each\n// test) and puts it back if Strict Mode's rehearsal of the effect took it out.\nfunction installBase(base: string | undefined): HTMLBaseElement | null {\n if (base === undefined || typeof document === \"undefined\") return null;\n const el = document.createElement(\"base\");\n el.setAttribute(\"href\", base);\n document.head.prepend(el);\n return el;\n}\n\nfunction useBaseElement(element: HTMLBaseElement | null | undefined) {\n React.useEffect(() => {\n if (element && !element.isConnected) document.head.prepend(element);\n return () => element?.remove();\n }, [element]);\n}\n\n// The providers every Strata app has above its router, in the order an app nests them.\nfunction StrataProviders({\n client,\n colorScheme,\n toasts,\n microphone,\n base,\n children,\n}: {\n base?: HTMLBaseElement | null;\n client: QueryClient;\n colorScheme: ColorSchemePreference;\n toasts: boolean;\n microphone?: Microphone;\n children: React.ReactNode;\n}) {\n useBaseElement(base);\n const tree = (\n <ThemeProvider defaultPreference={colorScheme} storageKey={null}>\n <StrataQueryProvider client={client}>\n {children}\n {toasts && <StrataToastRegion />}\n </StrataQueryProvider>\n </ThemeProvider>\n );\n return microphone ? <MicrophoneContext.Provider value={microphone}>{tree}</MicrophoneContext.Provider> : tree;\n}\n\n/** Testing Library's `render` inside `StrataQueryProvider` and a `MemoryRouter` at `route`. */\nexport function renderWithStrata(\n ui: React.ReactElement,\n {\n route = \"/\",\n client = createTestQueryClient(),\n colorScheme = \"light\",\n toasts = true,\n microphone,\n base,\n ...options\n }: StrataRenderOptions = {},\n) {\n toast.clear(); // module state: a toast from the last test must not show in this one\n forgetLoadedThumbnails(); // likewise the pictures a Thumbnail has loaded: each test starts from skeletons\n const baseElement = installBase(base);\n const Wrapper = ({ children }: { children: React.ReactNode }) => (\n <StrataProviders\n client={client}\n colorScheme={colorScheme}\n toasts={toasts}\n microphone={microphone}\n base={baseElement}\n >\n <MemoryRouter initialEntries={[route]}>{children}</MemoryRouter>\n </StrataProviders>\n );\n return { client, ...render(ui, { wrapper: Wrapper, ...options }) };\n}\n\n// Render an app's own route tree: its layout routes and <Outlet />s, index routes, redirects\n// (<Navigate /> or a loader's redirect()), loaders, actions and error elements. Those only run in\n// a data router, which <MemoryRouter> is not, so renderWithStrata cannot show them; this builds\n// the memory twin of the app's createBrowserRouter from the same RouteObject[] the app exports,\n// so the test and the app cannot drift. The providers and options are renderWithStrata's.\n// `basename` is the app's own (the kiln app runs under /kiln), and `route` is the full URL,\n// basename included, as the browser would show it. The router is returned so a test can assert\n// where a redirect landed (`router.state.location`), and `navigate` moves it inside act().\n\n/** `renderRoutes`'s options: `renderWithStrata`'s, plus the app's `basename`. */\nexport type RenderRoutesOptions = StrataRenderOptions & {\n /** The base path the app is served under, as passed to `createBrowserRouter`. */\n basename?: string;\n};\n\n/** Testing Library's `render` of an app's route tree in a memory data router at `route`, with Strata's providers. */\nexport function renderRoutes(\n routes: RouteObject[],\n {\n route,\n basename,\n client = createTestQueryClient(),\n colorScheme = \"light\",\n toasts = true,\n microphone,\n base,\n ...options\n }: RenderRoutesOptions = {},\n) {\n toast.clear();\n forgetLoadedThumbnails();\n const baseElement = installBase(base);\n const router = createMemoryRouter(routes, { initialEntries: [route ?? basename ?? \"/\"], basename });\n const result = render(\n <StrataProviders\n client={client}\n colorScheme={colorScheme}\n toasts={toasts}\n microphone={microphone}\n base={baseElement}\n >\n <RouterProvider router={router} />\n </StrataProviders>,\n options,\n );\n const navigate = (to: To | number) =>\n act(async () => {\n await (typeof to === \"number\" ? router.navigate(to) : router.navigate(to));\n });\n return { client, router, navigate, ...result };\n}\n"],"mappings":";;;;;;;;;AASA,SAAgB,gBAAyB;CACvC,MAAM,uBAAO,IAAI,IAAoB;CACrC,OAAO;EACL,IAAI,SAAS;GACX,OAAO,KAAK;EACd;EACA,aAAa,KAAK,MAAM;EACxB,UAAU,QAAQ,KAAK,IAAI,OAAO,GAAG,CAAC,KAAK;EAC3C,MAAM,UAAU,CAAC,GAAG,KAAK,KAAK,CAAC,CAAC,CAAC,UAAU;EAC3C,aAAa,QAAQ,KAAK,KAAK,OAAO,OAAO,GAAG,CAAC;EACjD,UAAU,KAAK,UAAU,KAAK,KAAK,IAAI,OAAO,GAAG,GAAG,OAAO,KAAK,CAAC;CACnE;AACF;AAEA,SAAS,OAAO,MAAkD;CAChE,IAAI;EACF,OAAO,OAAQ,WAA8D,KAAK,EAAE,YAAY;CAClG,QAAQ;EACN,OAAO;CACT;AACF;;;;;AAMA,SAAgB,qBAAiC;CAC/C,MAAM,UAA0B,CAAC;CACjC,KAAK,MAAM,QAAQ,CAAC,gBAAgB,gBAAgB,GAAY;EAC9D,IAAI,OAAO,IAAI,GAAG;EAClB,MAAM,UAAU,cAAc;EAC9B,MAAM,UAAU,CAAC,YAAY,OAAO,WAAW,cAAc,SAAS,MAAS,CAAC,CAAC,QAC9E,MAA8B,MAAM,MACvC;EACA,KAAK,MAAM,UAAU,IAAI,IAAI,OAAO,GAAG;GACrC,MAAM,SAAS,OAAO,yBAAyB,QAAQ,IAAI;GAC3D,OAAO,eAAe,QAAQ,MAAM;IAAE,cAAc;IAAM,OAAO;GAAQ,CAAC;GAC1E,QAAQ,WAAW;IACjB,IAAI,QAAQ,OAAO,eAAe,QAAQ,MAAM,MAAM;SACjD,OAAQ,OAA8C;GAC7D,CAAC;EACH;EACA,MAAM,Q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EACI;EACZ,MAAM;YAEN,oBAAC,gBAAD,EAAwB,OAAS;CAClB,IACjB,OACF;CACA,MAAM,YAAY,OAChB,IAAI,YAAY;EACd,OAAO,OAAO,OAAO,WAAW,OAAO,SAAS,EAAE,IAAI,OAAO,SAAS,EAAE;CAC1E,CAAC;CACH,OAAO;EAAE;EAAQ;EAAQ;EAAU,GAAG;CAAO;AAC/C"}
@@ -1,9 +1,10 @@
1
- import { r as cn, t as Tooltip$1 } from "./tooltip-DhqrDtyu.js";
2
- import { t as ChoiceGroup } from "./field-BjeE_FeB.js";
1
+ import { r as cn, t as Tooltip$1 } from "./tooltip-BosfsWYh.js";
2
+ import { t as ChoiceGroup } from "./field-DBCsFIng.js";
3
3
  import * as React from "react";
4
4
  import { Radio, RadioGroup } from "react-aria-components";
5
5
  import { Monitor, Moon, Sun } from "lucide-react";
6
6
  import { Fragment, jsx, jsxs } from "react/jsx-runtime";
7
+
7
8
  // src/components/density.tsx
8
9
  /** The density attribute's page-level setter, shared by `ThemeProvider`. @internal */
9
10
  function useDensityOn(value, target) {
@@ -29,17 +30,18 @@ function Density({ value, page = false, className, children }) {
29
30
  children
30
31
  });
31
32
  }
33
+
32
34
  // src/components/theme.tsx
33
35
  /** The localStorage key `ThemeProvider` uses unless given another. */
34
- var COLOR_SCHEME_STORAGE_KEY = "strata-color-scheme";
35
- var QUERY = "(prefers-color-scheme: dark)";
36
- var PREFERENCES = [
36
+ const COLOR_SCHEME_STORAGE_KEY = "strata-color-scheme";
37
+ const QUERY = "(prefers-color-scheme: dark)";
38
+ const PREFERENCES = [
37
39
  "system",
38
40
  "light",
39
41
  "dark"
40
42
  ];
41
43
  /** The palettes in `strata.css`: the default first, then four others. An app that adds its own in CSS passes its own list to `PaletteChoice`. */
42
- var palettes = [
44
+ const palettes = [
43
45
  {
44
46
  name: "petrol",
45
47
  label: "Petrol and marigold",
@@ -63,10 +65,10 @@ var palettes = [
63
65
  }
64
66
  ];
65
67
  /** The default palette: the plain `:root` look, with no override. */
66
- var DEFAULT_PALETTE = "petrol";
68
+ const DEFAULT_PALETTE = "petrol";
67
69
  /** The localStorage key `ThemeProvider` keeps the palette under unless given another. */
68
- var PALETTE_STORAGE_KEY = "strata-palette";
69
- var PALETTE_NAME = /^[a-z][a-z0-9-]{0,31}$/;
70
+ const PALETTE_STORAGE_KEY = "strata-palette";
71
+ const PALETTE_NAME = /^[a-z][a-z0-9-]{0,31}$/;
70
72
  function isPalette(value) {
71
73
  return typeof value === "string" && PALETTE_NAME.test(value);
72
74
  }
@@ -112,14 +114,14 @@ function subscribeSystem(onChange) {
112
114
  list.addEventListener("change", onChange);
113
115
  return () => list.removeEventListener("change", onChange);
114
116
  }
115
- var systemSnapshot = () => media()?.matches ? "dark" : "light";
116
- var serverSnapshot = () => "light";
117
+ const systemSnapshot = () => media()?.matches ? "dark" : "light";
118
+ const serverSnapshot = () => "light";
117
119
  /** The operating system's colour scheme, kept current as it changes. Light where it cannot be read (the server, jsdom). */
118
120
  function useSystemColorScheme() {
119
121
  return React.useSyncExternalStore(subscribeSystem, systemSnapshot, serverSnapshot);
120
122
  }
121
- var Context = React.createContext(null);
122
- var PaletteContext = React.createContext(null);
123
+ const Context = React.createContext(null);
124
+ const PaletteContext = React.createContext(null);
123
125
  /** Sets the `.dark` class strata.css keys on, from a system, light or dark preference that persists in localStorage when it can. */
124
126
  function ThemeProvider({ children, defaultPreference = "system", storageKey = COLOR_SCHEME_STORAGE_KEY, defaultPalette = DEFAULT_PALETTE, paletteStorageKey = PALETTE_STORAGE_KEY, target, density }) {
125
127
  const [preference, setState] = React.useState(defaultPreference);
@@ -212,7 +214,7 @@ function colorSchemeScript(storageKey = COLOR_SCHEME_STORAGE_KEY, defaultPrefere
212
214
  const key = JSON.stringify(storageKey);
213
215
  return `(function(){var p=${JSON.stringify(defaultPreference)};try{var s=localStorage.getItem(${key});if(s==="system"||s==="light"||s==="dark")p=s}catch(e){}var d=p==="dark"||(p==="system"&&window.matchMedia&&matchMedia(${JSON.stringify(QUERY)}).matches);document.documentElement.classList.toggle("dark",!!d)})()`;
214
216
  }
215
- var defaultLabels = {
217
+ const defaultLabels = {
216
218
  system: {
217
219
  label: "Match this device",
218
220
  detail: "Light or dark as your system setting changes"
@@ -220,7 +222,7 @@ var defaultLabels = {
220
222
  light: { label: "Light" },
221
223
  dark: { label: "Dark" }
222
224
  };
223
- var icons = {
225
+ const icons = {
224
226
  system: Monitor,
225
227
  light: Sun,
226
228
  dark: Moon
@@ -331,6 +333,6 @@ function PaletteChoice({ legend, options = palettes, compact = false, className
331
333
  }))
332
334
  });
333
335
  }
334
- export { PaletteChoice as a, paletteScript as c, usePalette as d, useSystemColorScheme as f, PALETTE_STORAGE_KEY as i, palettes as l, ColorSchemeChoice as n, ThemeProvider as o, Density as p, DEFAULT_PALETTE as r, colorSchemeScript as s, COLOR_SCHEME_STORAGE_KEY as t, useColorScheme as u };
335
336
 
336
- //# sourceMappingURL=theme-CxYZkUNk.js.map
337
+ export { PaletteChoice as a, paletteScript as c, usePalette as d, useSystemColorScheme as f, PALETTE_STORAGE_KEY as i, palettes as l, ColorSchemeChoice as n, ThemeProvider as o, Density as p, DEFAULT_PALETTE as r, colorSchemeScript as s, COLOR_SCHEME_STORAGE_KEY as t, useColorScheme as u };
338
+ //# sourceMappingURL=theme-1oOSMj_D.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"theme-1oOSMj_D.js","names":["Tooltip"],"sources":["../src/components/density.tsx","../src/components/theme.tsx"],"sourcesContent":["import * as React from \"react\";\nimport { cn } from \"../lib/utils\";\n\n// Density is how much a screen packs in: `default` for forms and pages, `compact` for a tool screen\n// worked for hours (an editor, an inspector, a timeline). strata.css moves --control-h and\n// --control-h-sm together on `[data-density]`; this is how an app says which (issue #117, from\n// strata-vid, whose export dialog came out at default density over a compact editor).\n//\n// There are two places it can live, and they are different on purpose:\n// - the page (`ThemeProvider density` or `<Density page>`): the attribute goes on the document's\n// root element, so everything Strata renders sees it, including `Dialog`, `Menu`, `ContextMenu`,\n// `Popover` and `CommandMenu`, which portal to <body> and so are never inside the app's own root.\n// An app chooses it once, here.\n// - a region (`<Density value=\"compact\">`): a wrapper element, for a dense inspector inside an\n// ordinary app. Its overlays portal out of it and stay at the page's density, which is right: a\n// confirm opened from a dense panel is still the app's confirm.\n//\n// `default` exists as a value so a region can step back inside a compact page. A coarse pointer\n// still gets 44px targets in every density (strata.css).\n\n/** How much a screen packs in: `default`, or `compact` for a tool screen. */\nexport type DensityName = \"default\" | \"compact\";\n\n/** The density attribute's page-level setter, shared by `ThemeProvider`. @internal */\nexport function useDensityOn(value: DensityName | undefined, target?: HTMLElement | null) {\n React.useLayoutEffect(() => {\n if (value === undefined) return;\n const element = target === undefined ? document.documentElement : target;\n if (!element) return;\n const before = element.getAttribute(\"data-density\");\n element.setAttribute(\"data-density\", value);\n return () => {\n if (before === null) element.removeAttribute(\"data-density\");\n else element.setAttribute(\"data-density\", before);\n };\n }, [value, target]);\n}\n\n/** Props for `Density`. */\nexport type DensityProps = {\n value: DensityName;\n /** Set it on the document's root element for the whole page, overlays included, instead of wrapping a region. Renders only its children. */\n page?: boolean;\n /** For the wrapper of a region: layout classes (the wrapper is a plain `div`; `contents` takes it out of layout). */\n className?: string;\n children?: React.ReactNode;\n};\n\n/** Sets the density of a region (a wrapper `div`), or of the whole page with `page`, where overlays are reached too. */\nexport function Density({ value, page = false, className, children }: DensityProps) {\n useDensityOn(page ? value : undefined);\n if (page) return <>{children}</>;\n return (\n <div data-density={value} className={cn(className)}>\n {children}\n </div>\n );\n}\n","import * as React from \"react\";\nimport { useDensityOn, type DensityName } from \"./density\";\nimport { Radio, RadioGroup } from \"react-aria-components\";\nimport { Tooltip } from \"./tooltip\";\nimport { Monitor, Moon, Sun } from \"lucide-react\";\nimport type { IconComponent } from \"../lib/icon\";\nimport { cn } from \"../lib/utils\";\nimport { ChoiceGroup } from \"./field\";\n\n// strata.css keys dark mode on a `.dark` ancestor (`@custom-variant dark (&:is(.dark *))`) and\n// gives `.dark` its `color-scheme`, but nothing in the library set the class, so every app wrote\n// the same matchMedia listener by hand (strata-listory did, in web/src/main.tsx). This is that\n// listener, once:\n// - Three choices, not two. \"system\" follows the operating system and keeps following it when it\n// changes at dusk; \"light\" and \"dark\" are a person's override. A toggle with only light and dark\n// loses the system setting the first time it is pressed.\n// - The choice persists in localStorage, read and written inside try/catch. Storage throws in\n// private windows, with blocked site data and in sandboxed frames; the theme then simply does\n// not persist, and the page still renders. A stored value that is not one of the three is\n// ignored.\n// - Another tab changing the choice changes this one too (the `storage` event).\n// - The first render uses the default preference, as a server render would, and the stored choice\n// is applied in a layout effect, so server-rendered markup hydrates cleanly and nothing paints\n// with the wrong scheme (found in review).\n// - The class is set in a layout effect, before paint. A page that must not flash light on first\n// load before React runs puts `colorSchemeScript()` in an inline script in its `<head>`.\n// - `ColorSchemeChoice` is the picker for a settings page: a `ChoiceGroup` of the three, with\n// \"Match this device\" first because it is the default and the one most people should keep. A\n// product that wants the choice elsewhere (a menu item, a header button) builds it from\n// `useColorScheme`. Changing theme is rare, so the picker has no motion and no icon flourish.\n// - `compact` is the same choice for an app with no settings page (a homepage, a single-page\n// tool), sized to sit in a header or footer: three segments with an icon each, named\n// \"Appearance\" (strata-react issue #25). They are still native radio buttons, so arrow keys move\n// the choice and a screen reader hears \"Match this device, radio button, 1 of 3, Appearance\".\n// Each segment is named by `aria-label` on its radio and shows the same words as a tooltip; the\n// icons are the familiar three (screen, sun, moon), and none of them is a toggle that loses the\n// system setting. The visible words are left out only because the icons are that well known.\n// - A palette is chosen independently of the scheme (2026-11-25, Jonathan: \"palettes as themes alongside\n// dark mode, each app an easy toggle\"). The provider sets `data-palette` on the same element as `.dark`;\n// strata.css has a light and a dark block per palette keyed on it (`src/styles/palettes.css`), and the\n// default palette is the plain :root, so no attribute and `\"petrol\"` are the same. The palette persists\n// under its own key like the scheme does, with the same safeguards (storage in try/catch, a stored\n// value that is not a palette name is ignored, other tabs follow). `PaletteChoice` is the picker: each\n// option carries a swatch drawn in its own palette by scoping `data-palette` on the swatch, so a person\n// sees the colours before choosing; a swatch is never the only name, the words are always there.\n// - Storybook's decorator and `renderWithStrata({ colorScheme })` run through this provider, so\n// stories and tests see the same class, in the same place, as an app.\n\n/** What a person chose: follow the operating system, or a fixed light or dark theme. */\nexport type ColorSchemePreference = \"system\" | \"light\" | \"dark\";\n/** The scheme in effect after \"system\" is resolved. */\nexport type ColorScheme = \"light\" | \"dark\";\n\n/** The localStorage key `ThemeProvider` uses unless given another. */\nexport const COLOR_SCHEME_STORAGE_KEY = \"strata-color-scheme\";\n\nconst QUERY = \"(prefers-color-scheme: dark)\";\nconst PREFERENCES: readonly ColorSchemePreference[] = [\"system\", \"light\", \"dark\"];\n\n/** A palette Strata ships: its name (the `data-palette` value) and the words `PaletteChoice` shows. */\nexport type PaletteOption = { name: string; label: string; detail?: string };\n\n/** The palettes in `strata.css`: the default first, then four others. An app that adds its own in CSS passes its own list to `PaletteChoice`. */\nexport const palettes: readonly PaletteOption[] = [\n { name: \"petrol\", label: \"Petrol and marigold\", detail: \"The default\" },\n { name: \"pine\", label: \"Pine and coral\" },\n { name: \"cobalt\", label: \"Cobalt and tangerine\" },\n { name: \"steel\", label: \"Steel and mint\" },\n { name: \"clay\", label: \"Clay and teal\" },\n];\n\n/** The default palette: the plain `:root` look, with no override. */\nexport const DEFAULT_PALETTE = \"petrol\";\n\n/** The localStorage key `ThemeProvider` keeps the palette under unless given another. */\nexport const PALETTE_STORAGE_KEY = \"strata-palette\";\n\nconst PALETTE_NAME = /^[a-z][a-z0-9-]{0,31}$/;\n\nfunction isPalette(value: unknown): value is string {\n return typeof value === \"string\" && PALETTE_NAME.test(value);\n}\n\nfunction readStoredPalette(key: string | null): string | null {\n if (key === null) return null;\n try {\n const value = window.localStorage.getItem(key);\n return isPalette(value) ? value : null;\n } catch {\n return null;\n }\n}\n\nfunction writeStoredPalette(key: string | null, value: string) {\n if (key === null) return;\n try {\n window.localStorage.setItem(key, value);\n } catch {\n // Storage unavailable: the palette lasts this visit only.\n }\n}\n\nfunction isPreference(value: unknown): value is ColorSchemePreference {\n return typeof value === \"string\" && (PREFERENCES as readonly string[]).includes(value);\n}\n\nfunction readStored(key: string | null): ColorSchemePreference | null {\n if (key === null) return null;\n try {\n const value = window.localStorage.getItem(key);\n return isPreference(value) ? value : null;\n } catch {\n return null;\n }\n}\n\nfunction writeStored(key: string | null, value: ColorSchemePreference) {\n if (key === null) return;\n try {\n window.localStorage.setItem(key, value);\n } catch {\n // Storage unavailable (private window, blocked site data): the choice lasts this visit only.\n }\n}\n\nfunction media(): MediaQueryList | null {\n return typeof window !== \"undefined\" && typeof window.matchMedia === \"function\" ? window.matchMedia(QUERY) : null;\n}\n\nfunction subscribeSystem(onChange: () => void) {\n const list = media();\n if (!list) return () => undefined;\n list.addEventListener(\"change\", onChange);\n return () => list.removeEventListener(\"change\", onChange);\n}\n\nconst systemSnapshot = (): ColorScheme => (media()?.matches ? \"dark\" : \"light\");\nconst serverSnapshot = (): ColorScheme => \"light\";\n\n/** The operating system's colour scheme, kept current as it changes. Light where it cannot be read (the server, jsdom). */\nexport function useSystemColorScheme(): ColorScheme {\n return React.useSyncExternalStore(subscribeSystem, systemSnapshot, serverSnapshot);\n}\n\n/** What `useColorScheme` returns: the chosen preference, the scheme in effect, and a setter that persists the choice. */\nexport type ColorSchemeState = {\n preference: ColorSchemePreference;\n scheme: ColorScheme;\n setPreference: (preference: ColorSchemePreference) => void;\n};\n\nconst Context = React.createContext<ColorSchemeState | null>(null);\n\n/** What `usePalette` returns: the palette name in effect and a setter that persists it. */\nexport type PaletteState = { palette: string; setPalette: (palette: string) => void };\n\nconst PaletteContext = React.createContext<PaletteState | null>(null);\n\n/** Sets the `.dark` class strata.css keys on, from a system, light or dark preference that persists in localStorage when it can. */\nexport function ThemeProvider({\n children,\n defaultPreference = \"system\",\n storageKey = COLOR_SCHEME_STORAGE_KEY,\n defaultPalette = DEFAULT_PALETTE,\n paletteStorageKey = PALETTE_STORAGE_KEY,\n target,\n density,\n}: {\n children: React.ReactNode;\n /** The preference before a person has chosen one. */\n defaultPreference?: ColorSchemePreference;\n /** Where the choice is kept in localStorage; `null` keeps it for this visit only. */\n storageKey?: string | null;\n /** The palette before a person has chosen one: a `data-palette` name from `palettes` (or the app's own). Left out, the default palette. */\n defaultPalette?: string;\n /** Where the palette is kept in localStorage; `null` keeps it for this visit only. */\n paletteStorageKey?: string | null;\n /**\n * The element that gets the `.dark` class; the document's root element when left out. A nested\n * target can turn a light page's panel dark, not the reverse: strata.css keys dark on any\n * `.dark` ancestor. Pass the element itself (keep it in state with a callback ref, since a\n * wrapping element's ref is not attached yet when this provider's effect first runs); `null`\n * means it has not mounted yet, and nothing is set until it has.\n */\n target?: HTMLElement | null;\n /**\n * How much the screen packs in, set on the same element as the colour scheme (the root, so\n * overlays are reached): `compact` for a tool screen. See `Density`. Left out, nothing is set.\n */\n density?: DensityName;\n}) {\n // The first render uses the default, as the server does, so a server-rendered tree hydrates\n // without a mismatch; the stored choice is read in a layout effect, which re-renders before the\n // browser paints, so a client-only app still never shows the default first.\n const [preference, setState] = React.useState<ColorSchemePreference>(defaultPreference);\n React.useLayoutEffect(() => {\n const stored = readStored(storageKey);\n if (stored) setState(stored);\n }, [storageKey]);\n const system = useSystemColorScheme();\n const scheme: ColorScheme = preference === \"system\" ? system : preference;\n\n const setPreference = React.useCallback(\n (next: ColorSchemePreference) => {\n setState(next);\n writeStored(storageKey, next);\n },\n [storageKey],\n );\n\n // Another tab changed the choice. A cleared key (`newValue` null) falls back to the default.\n React.useEffect(() => {\n if (storageKey === null) return;\n const onStorage = (event: StorageEvent) => {\n if (event.key !== storageKey && event.key !== null) return;\n const value = event.key === null ? null : event.newValue;\n setState(isPreference(value) ? value : defaultPreference);\n };\n window.addEventListener(\"storage\", onStorage);\n return () => window.removeEventListener(\"storage\", onStorage);\n }, [storageKey, defaultPreference]);\n\n React.useLayoutEffect(() => {\n const element = target === undefined ? document.documentElement : target;\n if (!element) return;\n element.classList.toggle(\"dark\", scheme === \"dark\");\n return () => element.classList.remove(\"dark\");\n }, [scheme, target]);\n\n // The palette follows the scheme's pattern: default first, the stored choice in a layout effect.\n const [palette, setPaletteState] = React.useState<string>(defaultPalette);\n React.useLayoutEffect(() => {\n const stored = readStoredPalette(paletteStorageKey);\n if (stored) setPaletteState(stored);\n }, [paletteStorageKey]);\n const setPalette = React.useCallback(\n (next: string) => {\n if (!isPalette(next)) return;\n setPaletteState(next);\n writeStoredPalette(paletteStorageKey, next);\n },\n [paletteStorageKey],\n );\n React.useEffect(() => {\n if (paletteStorageKey === null) return;\n const onStorage = (event: StorageEvent) => {\n if (event.key !== paletteStorageKey && event.key !== null) return;\n const value = event.key === null ? null : event.newValue;\n setPaletteState(isPalette(value) ? value : defaultPalette);\n };\n window.addEventListener(\"storage\", onStorage);\n return () => window.removeEventListener(\"storage\", onStorage);\n }, [paletteStorageKey, defaultPalette]);\n React.useLayoutEffect(() => {\n const element = target === undefined ? document.documentElement : target;\n if (!element) return;\n element.setAttribute(\"data-palette\", palette);\n return () => element.removeAttribute(\"data-palette\");\n }, [palette, target]);\n\n useDensityOn(density, target);\n\n const value = React.useMemo(() => ({ preference, scheme, setPreference }), [preference, scheme, setPreference]);\n const paletteValue = React.useMemo(() => ({ palette, setPalette }), [palette, setPalette]);\n return (\n <Context.Provider value={value}>\n <PaletteContext.Provider value={paletteValue}>{children}</PaletteContext.Provider>\n </Context.Provider>\n );\n}\n\n/** The person's colour-scheme preference, the scheme in effect, and a setter that persists it. Must be inside `ThemeProvider`. */\nexport function useColorScheme(): ColorSchemeState {\n const value = React.useContext(Context);\n if (!value) throw new Error(\"useColorScheme must be used inside a ThemeProvider.\");\n return value;\n}\n\n/**\n * The body of an inline `<script>` for the page's `<head>` that sets `.dark` before the first\n * paint, from the stored choice or the operating system, so a dark page does not flash light while\n * the bundle loads. Pass the same key and default as the `ThemeProvider`.\n */\nexport function colorSchemeScript(\n storageKey: string = COLOR_SCHEME_STORAGE_KEY,\n defaultPreference: ColorSchemePreference = \"system\",\n): string {\n const key = JSON.stringify(storageKey);\n const fallback = JSON.stringify(defaultPreference);\n return (\n `(function(){var p=${fallback};try{var s=localStorage.getItem(${key});` +\n `if(s===\"system\"||s===\"light\"||s===\"dark\")p=s}catch(e){}` +\n `var d=p===\"dark\"||(p===\"system\"&&window.matchMedia&&matchMedia(${JSON.stringify(QUERY)}).matches);` +\n `document.documentElement.classList.toggle(\"dark\",!!d)})()`\n );\n}\n\n/** The words `ColorSchemeChoice` shows for each preference. */\nexport type ColorSchemeLabels = Record<ColorSchemePreference, { label: string; detail?: string }>;\n\nconst defaultLabels: ColorSchemeLabels = {\n system: { label: \"Match this device\", detail: \"Light or dark as your system setting changes\" },\n light: { label: \"Light\" },\n dark: { label: \"Dark\" },\n};\n\nconst icons: Record<ColorSchemePreference, IconComponent> = { system: Monitor, light: Sun, dark: Moon };\n\n/** The three colour-scheme preferences as radio buttons, bound to the nearest `ThemeProvider`. A list for a settings page, or `compact` icon segments named \"Appearance\" for a header. */\nexport function ColorSchemeChoice({\n legend,\n labels = defaultLabels,\n compact = false,\n className,\n}: {\n /** The group's name, as the page words it. Defaults to \"Theme\", or \"Appearance\" when `compact`. */\n legend?: string;\n /** Overrides the words for each choice, in the product's voice. */\n labels?: Partial<ColorSchemeLabels>;\n /** Three icon segments for a header or footer, for an app with no settings page. */\n compact?: boolean;\n /** Layout at the call site (compact only). */\n className?: string;\n}) {\n const { preference, setPreference } = useColorScheme();\n const name = React.useId();\n const words = { ...defaultLabels, ...labels };\n if (compact) {\n return (\n <RadioGroup\n aria-label={legend ?? \"Appearance\"}\n orientation=\"horizontal\"\n name={name}\n value={preference}\n onChange={(value) => {\n if (isPreference(value)) setPreference(value);\n }}\n className={cn(\"inline-flex gap-0.5 rounded-surface border border-border bg-background p-0.5\", className)}\n >\n {PREFERENCES.map((value) => {\n const Icon = icons[value];\n return (\n <Tooltip key={value} label={words[value].label}>\n <Radio\n value={value}\n aria-label={words[value].label}\n className={cn(\n // Outer 6px less 2px padding: the segments are 4px, as optical nesting asks.\n \"grid size-(--control-h-sm) cursor-pointer place-items-center rounded-control text-muted-foreground transition-state\",\n \"hover:text-foreground selected:bg-muted selected:text-foreground\",\n \"focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-ring\",\n )}\n >\n <Icon aria-hidden className=\"size-4\" />\n </Radio>\n </Tooltip>\n );\n })}\n </RadioGroup>\n );\n }\n return (\n <ChoiceGroup\n legend={legend ?? \"Theme\"}\n name={name}\n value={preference}\n onChange={(value) => {\n if (isPreference(value)) setPreference(value);\n }}\n choices={PREFERENCES.map((value) => ({ value, ...words[value] }))}\n />\n );\n}\n\n/** The palette in effect and a setter that persists it. Must be inside `ThemeProvider`. */\nexport function usePalette(): PaletteState {\n const value = React.useContext(PaletteContext);\n if (!value) throw new Error(\"usePalette must be used inside a ThemeProvider.\");\n return value;\n}\n\n/**\n * The body of an inline `<script>` for the page's `<head>` that sets `data-palette` before the first paint\n * from the stored choice, so a page does not flash the default palette while the bundle loads. Pass the\n * same key and default as the `ThemeProvider`; put it beside `colorSchemeScript()`.\n */\nexport function paletteScript(\n storageKey: string = PALETTE_STORAGE_KEY,\n defaultPalette: string = DEFAULT_PALETTE,\n): string {\n const key = JSON.stringify(storageKey);\n const fallback = JSON.stringify(defaultPalette);\n return (\n `(function(){var p=${fallback};try{var s=localStorage.getItem(${key});` +\n `if(s&&/^[a-z][a-z0-9-]{0,31}$/.test(s))p=s}catch(e){}` +\n `document.documentElement.setAttribute(\"data-palette\",p)})()`\n );\n}\n\n/**\n * The palettes as radio buttons, bound to the nearest `ThemeProvider`, each with a swatch drawn in its own\n * palette (primary and the one warm accent) so the colours are seen before they are chosen. A list for a\n * settings page, or `compact` swatches named \"Palette\" for a header. The words are always present (the\n * list shows them, the compact form names each swatch and shows the same words as a tooltip).\n */\nexport function PaletteChoice({\n legend,\n options = palettes,\n compact = false,\n className,\n}: {\n /** The group's name, as the page words it. Defaults to \"Palette\". */\n legend?: string;\n /** The palettes offered: names that `strata.css` (or the app's own CSS) defines under `data-palette`, with their words. Defaults to `palettes`. */\n options?: readonly PaletteOption[];\n /** Swatches only, for a header or footer, for an app with no settings page. */\n compact?: boolean;\n /** Layout at the call site (compact only). */\n className?: string;\n}) {\n const { palette, setPalette } = usePalette();\n const name = React.useId();\n const swatch = (option: PaletteOption) => (\n // Scoping the palette on the swatch draws it in its own colours, in light and in a dark page.\n <span\n data-palette={option.name}\n aria-hidden\n className=\"inline-flex size-5 shrink-0 overflow-hidden rounded-pill border border-border\"\n >\n <span className=\"w-1/2 bg-primary\" />\n <span className=\"w-1/2 bg-secondary-9\" />\n </span>\n );\n if (compact) {\n return (\n <RadioGroup\n aria-label={legend ?? \"Palette\"}\n orientation=\"horizontal\"\n name={name}\n value={palette}\n onChange={setPalette}\n className={cn(\"inline-flex gap-0.5 rounded-surface border border-border bg-background p-0.5\", className)}\n >\n {options.map((option) => (\n <Tooltip key={option.name} label={option.label}>\n <Radio\n value={option.name}\n aria-label={option.label}\n className={cn(\n \"grid size-(--control-h-sm) cursor-pointer place-items-center rounded-control transition-state\",\n \"hover:bg-muted selected:bg-muted selected:ring-1 selected:ring-border\",\n \"focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-ring\",\n )}\n >\n {swatch(option)}\n </Radio>\n </Tooltip>\n ))}\n </RadioGroup>\n );\n }\n return (\n <ChoiceGroup\n legend={legend ?? \"Palette\"}\n name={name}\n value={palette}\n onChange={setPalette}\n choices={options.map((option) => ({\n value: option.name,\n label: option.label,\n detail: option.detail,\n leading: swatch(option),\n }))}\n />\n );\n}\n"],"mappings":";;;;;;;;;AAwBA,SAAgB,aAAa,OAAgC,QAA6B;CACxF,MAAM,sBAAsB;EAC1B,IAAI,UAAU,QAAW;EACzB,MAAM,UAAU,WAAW,SAAY,SAAS,kBAAkB;EAClE,IAAI,CAAC,SAAS;EACd,MAAM,SAAS,QAAQ,aAAa,cAAc;EAClD,QAAQ,aAAa,gBAAgB,KAAK;EA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;EACN,OAAO;EACP,UAAU;EACV,WAAW,GAAG,gFAAgF,SAAS;YAEtG,QAAQ,KAAK,WACZ,oBAACA,WAAD;GAA2B,OAAO,OAAO;aACvC,oBAAC,OAAD;IACE,OAAO,OAAO;IACd,cAAY,OAAO;IACnB,WAAW,GACT,iGACA,yEACA,mFACF;cAEC,OAAO,MAAM;GACT;EACA,GAZK,OAAO,IAYZ,CACV;CACS;CAGhB,OACE,oBAAC,aAAD;EACE,QAAQ,UAAU;EACZ;EACN,OAAO;EACP,UAAU;EACV,SAAS,QAAQ,KAAK,YAAY;GAChC,OAAO,OAAO;GACd,OAAO,OAAO;GACd,QAAQ,OAAO;GACf,SAAS,OAAO,MAAM;EACxB,EAAE;CACH;AAEL"}
@@ -4,8 +4,9 @@ import * as React from "react";
4
4
  import { Tooltip, TooltipTrigger } from "react-aria-components";
5
5
  import { ArrowBigUp, ArrowDown, ArrowLeft, ArrowRight, ArrowUp, ChevronUp, Command, Option } from "lucide-react";
6
6
  import { Fragment, jsx, jsxs } from "react/jsx-runtime";
7
+
7
8
  // src/lib/utils.ts
8
- var typeSteps = [
9
+ const typeSteps = [
9
10
  "caption",
10
11
  "label",
11
12
  "body-sm",
@@ -16,7 +17,7 @@ var typeSteps = [
16
17
  "display",
17
18
  "picture"
18
19
  ];
19
- var twMerge = extendTailwindMerge({ extend: {
20
+ const twMerge = extendTailwindMerge({ extend: {
20
21
  theme: { radius: [...[
21
22
  "control",
22
23
  "surface",
@@ -29,8 +30,9 @@ var twMerge = extendTailwindMerge({ extend: {
29
30
  function cn(...inputs) {
30
31
  return twMerge(clsx(inputs));
31
32
  }
33
+
32
34
  // src/components/key-glyphs.tsx
33
- var GLYPHS = {
35
+ const GLYPHS = {
34
36
  "←": {
35
37
  icon: ArrowLeft,
36
38
  name: "left arrow"
@@ -64,7 +66,7 @@ var GLYPHS = {
64
66
  name: "Shift"
65
67
  }
66
68
  };
67
- var PATTERN = new RegExp(`([${Object.keys(GLYPHS).join("")}])`);
69
+ const PATTERN = new RegExp(`([${Object.keys(GLYPHS).join("")}])`);
68
70
  /** Key text with its arrows and modifier symbols drawn as icons, each with its name for screen readers. Other text is left as it is. */
69
71
  function KeyText({ children }) {
70
72
  return /* @__PURE__ */ jsx(Fragment, { children: children.split(PATTERN).map((part, i) => {
@@ -80,6 +82,7 @@ function KeyText({ children }) {
80
82
  })] }, i);
81
83
  }) });
82
84
  }
85
+
83
86
  // src/components/tooltip.tsx
84
87
  /** A hover-and-focus tooltip for a control, portalled above everything. Words only; not the only home of information. */
85
88
  function Tooltip$1({ label, hint, children, side = "top", delay = 500, open, className }) {
@@ -98,6 +101,6 @@ function Tooltip$1({ label, hint, children, side = "top", delay = 500, open, cla
98
101
  })]
99
102
  });
100
103
  }
101
- export { typeSteps as i, KeyText as n, cn as r, Tooltip$1 as t };
102
104
 
103
- //# sourceMappingURL=tooltip-DhqrDtyu.js.map
105
+ export { typeSteps as i, KeyText as n, cn as r, Tooltip$1 as t };
106
+ //# sourceMappingURL=tooltip-BosfsWYh.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tooltip-BosfsWYh.js","names":["Tooltip","AriaTooltip"],"sources":["../src/lib/utils.ts","../src/components/key-glyphs.tsx","../src/components/tooltip.tsx"],"sourcesContent":["import { clsx, type ClassValue } from \"clsx\";\nimport { extendTailwindMerge } from \"tailwind-merge\";\n\n// Teach tailwind-merge that `type-*` utilities are font sizes. Without this, cn() cannot tell\n// `type-label` from a colour and may drop one of two classes that both survive in CSS; with stock\n// shadcn the same bug drops `text-muted-foreground` next to a custom `text-*` size.\nexport const typeSteps = [\n \"caption\",\n \"label\",\n \"body-sm\",\n \"body\",\n \"heading\",\n \"title\",\n \"figure\",\n \"display\",\n \"picture\",\n] as const;\n\n// The radius roles too, so `rounded-pill` at a call site (a round avatar Thumbnail) replaces a\n// component's `rounded-control` instead of both surviving and CSS order picking one.\nconst radiusRoles = [\"control\", \"surface\", \"overlay\", \"pill\"] as const;\n\nconst twMerge = extendTailwindMerge({\n extend: {\n theme: { radius: [...radiusRoles] },\n classGroups: {\n \"font-size\": [{ type: [...typeSteps] }],\n },\n },\n});\n\n/** clsx + tailwind-merge, taught that `type-*` utilities are font sizes and `rounded-control`, `-surface`, `-overlay`, `-pill` are radii. */\nexport function cn(...inputs: ClassValue[]) {\n return twMerge(clsx(inputs));\n}\n","import * as React from \"react\";\nimport {\n ArrowBigUp,\n ArrowDown,\n ArrowLeft,\n ArrowRight,\n ArrowUp,\n ChevronUp,\n Command,\n Option,\n type LucideIcon,\n} from \"lucide-react\";\n\n// Keys drawn as icons where a font cannot be trusted to have them (strata-react issue #136, from\n// strata-vid). The arrows (← → ↑ ↓) and the macOS modifiers (⌘ ⌃ ⌥ ⇧) are outside the latin subset of\n// the bundled variable fonts, so a legend drew them in whatever face the machine had: different on\n// every machine, and `strata-visual` fails a shot with text in a system font. Lucide's icons are\n// SVG, so they draw the same everywhere and take the text colour. Each is hidden from assistive\n// technology and followed by its name in screen-reader-only text (\"left arrow\", \"Command\"), so the\n// keycap reads as words rather than as a symbol each screen reader pronounces its own way.\n// Checked: React Aria has no keyboard-shortcut display beyond the `Keyboard` slot (which only\n// labels the text it is given), so this is the glyph mapping the slot's content needs.\n\nconst GLYPHS: Record<string, { icon: LucideIcon; name: string }> = {\n \"←\": { icon: ArrowLeft, name: \"left arrow\" },\n \"→\": { icon: ArrowRight, name: \"right arrow\" },\n \"↑\": { icon: ArrowUp, name: \"up arrow\" },\n \"↓\": { icon: ArrowDown, name: \"down arrow\" },\n \"⌘\": { icon: Command, name: \"Command\" },\n \"⌃\": { icon: ChevronUp, name: \"Control\" },\n \"⌥\": { icon: Option, name: \"Option\" },\n \"⇧\": { icon: ArrowBigUp, name: \"Shift\" },\n};\nconst PATTERN = new RegExp(`([${Object.keys(GLYPHS).join(\"\")}])`);\n\n/** Key text with its arrows and modifier symbols drawn as icons, each with its name for screen readers. Other text is left as it is. */\nexport function KeyText({ children }: { children: string }) {\n return (\n <>\n {children.split(PATTERN).map((part, i) => {\n const glyph = GLYPHS[part];\n if (!glyph) return part ? <React.Fragment key={i}>{part}</React.Fragment> : null;\n const Icon = glyph.icon;\n return (\n <React.Fragment key={i}>\n <Icon aria-hidden className=\"inline size-[1em] align-[-0.125em]\" />\n <span className=\"sr-only\">{glyph.name} </span>\n </React.Fragment>\n );\n })}\n </>\n );\n}\n","import { KeyText } from \"./key-glyphs\";\nimport * as React from \"react\";\nimport { Tooltip as AriaTooltip, TooltipTrigger } from \"react-aria-components\";\nimport { cn } from \"../lib/utils\";\n\n// A tooltip names or explains a control; it is never the only place information lives. React Aria\n// opens it on keyboard focus as well as hover (strata-vid's old hover-only tooltip hid it from\n// keyboard users), after a short delay so a pointer crossing a toolbar does not flash every tip,\n// and shares the delay between neighbouring tips. It holds only words: anything interactive is a\n// Popover. It is portalled to the body, so a parent's overflow cannot clip it, and sits on the\n// `layer-tip` layer above dialogs, since it can name a control inside one.\n//\n// `IconButton` uses it for its required `label`, so the name and the visible hint come from one\n// string and cannot drift.\n\n/** Props for `Tooltip`. */\nexport type TooltipProps = {\n /** The words: a control's name or one sentence about it. Not interactive. */\n label: React.ReactNode;\n /** A shortcut or other aside shown after the label, muted (\"Ctrl+Z\"). */\n hint?: React.ReactNode;\n /** The element that gets the tip. It must be a React Aria pressable or focusable (a Strata `Button` is). */\n children: React.ReactElement;\n /** Which side of the trigger it prefers; it flips when there is no room. Default `top`. */\n side?: \"top\" | \"right\" | \"bottom\" | \"left\";\n /** Milliseconds before it opens on hover. Focus opens it at once. Default 500. */\n delay?: number;\n /** A controlled open state, for a story or test that needs it shown. */\n open?: boolean;\n className?: string;\n};\n\n/** A hover-and-focus tooltip for a control, portalled above everything. Words only; not the only home of information. */\nexport function Tooltip({ label, hint, children, side = \"top\", delay = 500, open, className }: TooltipProps) {\n return (\n <TooltipTrigger delay={delay} closeDelay={0} isOpen={open}>\n {children}\n <AriaTooltip\n placement={side}\n offset={6}\n className={cn(\n \"layer-tip enter-overlay max-w-xs rounded-control bg-foreground px-2 py-1 type-caption text-background\",\n className,\n )}\n >\n {label}\n {hint != null && (\n <span className=\"ml-2 opacity-70\">{typeof hint === \"string\" ? <KeyText>{hint}</KeyText> : hint}</span>\n )}\n </AriaTooltip>\n </TooltipTrigger>\n );\n}\n"],"mappings":";;;;;;;;AAMA,MAAa,YAAY;CACvB;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;AACF;AAMA,MAAM,UAAU,oBAAoB,EAClC,QAAQ;CACN,OAAO,EAAE,QAAQ,CAAC,GAAG;EAJJ;EAAW;EAAW;EAAW;CAInB,CAAC,EAAE;CAClC,aAAa,EACX,aAAa,CAAC,EAAE,MAAM,CAAC,GAAG,SAAS,EAAE,CAAC,EACxC;AACF,EACF,CAAC;;AAGD,SAAgB,GAAG,GAAG,QAAsB;CAC1C,OAAO,QAAQ,KAAK,MAAM,CAAC;AAC7B;;;ACXA,MAAM,SAA6D;CACjE,KAAK;EAAE,MAAM;EAAW,MAAM;CAAa;CAC3C,KAAK;EAAE,MAAM;EAAY,MAAM;CAAc;CAC7C,KAAK;EAAE,MAAM;EAAS,MAAM;CAAW;CACvC,KAAK;EAAE,MAAM;EAAW,MAAM;CAAa;CAC3C,KAAK;EAAE,MAAM;EAAS,MAAM;CAAU;CACtC,KAAK;EAAE,MAAM;EAAW,MAAM;CAAU;CACxC,KAAK;EAAE,MAAM;EAAQ,MAAM;CAAS;CACpC,KAAK;EAAE,MAAM;EAAY,MAAM;CAAQ;AACzC;AACA,MAAM,UAAU,IAAI,OAAO,KAAK,OAAO,KAAK,MAAM,CAAC,CAAC,KAAK,EAAE,EAAE,GAAG;;AAGhE,SAAgB,QAAQ,EAAE,YAAkC;CAC1D,OACE,0CACG,SAAS,MAAM,OAAO,CAAC,CAAC,KAAK,MAAM,MAAM;EACxC,MAAM,QAAQ,OAAO;EACrB,IAAI,CAAC,OAAO,OAAO,OAAO,oBAAC,MAAM,UAAP,YAAyB,KAAqB,GAAzB,CAAyB,IAAI;EAC5E,MAAM,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