strata-react 1.3.24 → 1.3.26
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/UPGRADING.md +7 -0
- package/dist/{api-types/cli.d.ts → api-types-cli.d.ts} +1 -0
- package/dist/api-types-cli.js +4 -3
- package/dist/api-types-cli.js.map +1 -1
- package/dist/{api-types/generate.d.ts → api-types.d.ts} +3 -3
- package/dist/api-types.js +3 -1
- package/dist/{button-KGJI6jQr.js → button-CYXjU-fs.js} +8 -5
- package/dist/button-CYXjU-fs.js.map +1 -0
- package/dist/{cursor-DDGBPiTJ.js → cursor-Cwyvgwsw.js} +9 -7
- package/dist/cursor-Cwyvgwsw.js.map +1 -0
- package/dist/{errors-BUvY1Z4d.js → errors-CmuwcWlb.js} +6 -6
- package/dist/{errors-BUvY1Z4d.js.map → errors-CmuwcWlb.js.map} +1 -1
- package/dist/{field-BjeE_FeB.js → field-DBCsFIng.js} +27 -23
- package/dist/field-DBCsFIng.js.map +1 -0
- package/dist/follow-CXQsL86O.js +16 -0
- package/dist/follow-CXQsL86O.js.map +1 -0
- package/dist/{generate-CjTHKJ39.js → generate-BkWhh4k4.js} +8 -6
- package/dist/generate-BkWhh4k4.js.map +1 -0
- package/dist/{lib/geo.d.ts → geo-DfKa9JtK.d.ts} +35 -33
- package/dist/{hls/index.d.ts → hls.d.ts} +13 -12
- package/dist/hls.js +5 -4
- package/dist/hls.js.map +1 -1
- package/dist/index.d.ts +5300 -140
- package/dist/index.js +363 -224
- package/dist/index.js.map +1 -1
- package/dist/map.d.ts +184 -0
- package/dist/map.js +21 -17
- package/dist/map.js.map +1 -1
- package/dist/media-player-BETa3P7K.d.ts +758 -0
- package/dist/{microphone-Bo3WaXgD.js → microphone-76skMt6i.js} +41 -30
- package/dist/microphone-76skMt6i.js.map +1 -0
- package/dist/microphone-DDOnQHxf.d.ts +237 -0
- package/dist/{migrate/cli.d.ts → migrate-cli.d.ts} +1 -0
- package/dist/migrate-cli.js +8 -6
- package/dist/migrate-cli.js.map +1 -1
- package/dist/panorama.d.ts +102 -0
- package/dist/panorama.js +54 -109
- package/dist/panorama.js.map +1 -1
- package/dist/{run-BT2WKzMz.js → run-D_Ic1jE7.js} +23 -16
- package/dist/run-D_Ic1jE7.js.map +1 -0
- package/dist/scene.d.ts +147 -0
- package/dist/scene.js +74 -77
- package/dist/scene.js.map +1 -1
- package/dist/testing.d.ts +468 -0
- package/dist/testing.js +11 -3
- package/dist/testing.js.map +1 -1
- package/dist/{theme-CxYZkUNk.js → theme-1oOSMj_D.js} +19 -17
- package/dist/theme-1oOSMj_D.js.map +1 -0
- package/dist/{tooltip-DhqrDtyu.js → tooltip-BosfsWYh.js} +9 -6
- package/dist/tooltip-BosfsWYh.js.map +1 -0
- package/dist/types-B3TsF0Ey.d.ts +241 -0
- package/dist/{value-controls-Dm_EYfZW.js → value-controls-5u7sD_wG.js} +22 -17
- package/dist/value-controls-5u7sD_wG.js.map +1 -0
- package/dist/viewer-input-3Qa-o35k.js +108 -0
- package/dist/viewer-input-3Qa-o35k.js.map +1 -0
- package/dist/{visual/cli.d.ts → visual-cli.d.ts} +2 -1
- package/dist/visual-cli.js +5 -4
- package/dist/visual-cli.js.map +1 -1
- package/dist/visual.d.ts +105 -0
- package/dist/visual.js +4 -3
- package/dist/visual.js.map +1 -1
- package/package.json +24 -19
- package/dist/api-types/index.d.ts +0 -1
- package/dist/button-KGJI6jQr.js.map +0 -1
- package/dist/components/active-list.d.ts +0 -46
- package/dist/components/alert.d.ts +0 -17
- package/dist/components/app-shell.d.ts +0 -32
- package/dist/components/async-button.d.ts +0 -48
- package/dist/components/auto-recorder.d.ts +0 -67
- package/dist/components/book-viewer.d.ts +0 -50
- package/dist/components/box-overlay.d.ts +0 -44
- package/dist/components/boxed-picture.d.ts +0 -34
- package/dist/components/button.d.ts +0 -45
- package/dist/components/byte-view.d.ts +0 -32
- package/dist/components/checkbox.d.ts +0 -39
- package/dist/components/choice-grid.d.ts +0 -42
- package/dist/components/commands.d.ts +0 -104
- package/dist/components/compare-audio.d.ts +0 -30
- package/dist/components/compare-grid.d.ts +0 -24
- package/dist/components/compare-parts.d.ts +0 -90
- package/dist/components/compare-regions.d.ts +0 -37
- package/dist/components/compare-text.d.ts +0 -32
- package/dist/components/compare-video-grid.d.ts +0 -52
- package/dist/components/compare-video.d.ts +0 -61
- package/dist/components/compare.d.ts +0 -90
- package/dist/components/composition.d.ts +0 -44
- package/dist/components/console.d.ts +0 -34
- package/dist/components/conversation.d.ts +0 -83
- package/dist/components/cursor.d.ts +0 -44
- package/dist/components/data-table.d.ts +0 -89
- package/dist/components/data-view.d.ts +0 -66
- package/dist/components/density.d.ts +0 -16
- package/dist/components/dialog.d.ts +0 -45
- package/dist/components/difference.d.ts +0 -19
- package/dist/components/disclosure.d.ts +0 -49
- package/dist/components/done.d.ts +0 -14
- package/dist/components/drag-source.d.ts +0 -29
- package/dist/components/field.d.ts +0 -79
- package/dist/components/file-intake.d.ts +0 -60
- package/dist/components/film-strip.d.ts +0 -35
- package/dist/components/folder-picker.d.ts +0 -59
- package/dist/components/fullscreen-frame.d.ts +0 -18
- package/dist/components/history.d.ts +0 -61
- package/dist/components/hotkeys.d.ts +0 -44
- package/dist/components/infinite-list.d.ts +0 -77
- package/dist/components/inspector.d.ts +0 -66
- package/dist/components/job-action.d.ts +0 -30
- package/dist/components/job-status.d.ts +0 -55
- package/dist/components/jobs-table.d.ts +0 -35
- package/dist/components/key-glyphs.d.ts +0 -5
- package/dist/components/key-owner.d.ts +0 -11
- package/dist/components/lightbox.d.ts +0 -61
- package/dist/components/line-chart.d.ts +0 -169
- package/dist/components/link-card.d.ts +0 -32
- package/dist/components/link.d.ts +0 -54
- package/dist/components/markable-text.d.ts +0 -60
- package/dist/components/media-contents.d.ts +0 -28
- package/dist/components/media-group.d.ts +0 -32
- package/dist/components/media-player.d.ts +0 -251
- package/dist/components/media-progress.d.ts +0 -17
- package/dist/components/media-skip.d.ts +0 -31
- package/dist/components/media-spans.d.ts +0 -93
- package/dist/components/media.d.ts +0 -133
- package/dist/components/meter.d.ts +0 -32
- package/dist/components/metric.d.ts +0 -17
- package/dist/components/outbox-status.d.ts +0 -10
- package/dist/components/page-header.d.ts +0 -14
- package/dist/components/pair-vote.d.ts +0 -70
- package/dist/components/pause-button.d.ts +0 -7
- package/dist/components/pixel-image.d.ts +0 -29
- package/dist/components/place-board.d.ts +0 -39
- package/dist/components/player-warning.d.ts +0 -24
- package/dist/components/popover.d.ts +0 -20
- package/dist/components/recorder.d.ts +0 -73
- package/dist/components/region-editor.d.ts +0 -67
- package/dist/components/save.d.ts +0 -46
- package/dist/components/say-again.d.ts +0 -13
- package/dist/components/schedule-table.d.ts +0 -24
- package/dist/components/secret-field.d.ts +0 -34
- package/dist/components/selectable-grid.d.ts +0 -57
- package/dist/components/selection.d.ts +0 -104
- package/dist/components/sequence-timeline.d.ts +0 -50
- package/dist/components/shortcut-editor.d.ts +0 -44
- package/dist/components/sortable-list.d.ts +0 -39
- package/dist/components/status.d.ts +0 -9
- package/dist/components/switch.d.ts +0 -15
- package/dist/components/system-panel.d.ts +0 -58
- package/dist/components/tabs.d.ts +0 -16
- package/dist/components/theme.d.ts +0 -106
- package/dist/components/thumbnail.d.ts +0 -50
- package/dist/components/tile-grid.d.ts +0 -67
- package/dist/components/timeline-player.d.ts +0 -18
- package/dist/components/timeline.d.ts +0 -115
- package/dist/components/toast.d.ts +0 -36
- package/dist/components/toggle.d.ts +0 -51
- package/dist/components/toolbar.d.ts +0 -15
- package/dist/components/tooltip.d.ts +0 -19
- package/dist/components/transcript-view.d.ts +0 -63
- package/dist/components/tree.d.ts +0 -74
- package/dist/components/undo.d.ts +0 -63
- package/dist/components/use-timeline.d.ts +0 -44
- package/dist/components/value-controls.d.ts +0 -91
- package/dist/components/video-clock.d.ts +0 -68
- package/dist/components/view-options.d.ts +0 -105
- package/dist/components/viewport.d.ts +0 -85
- package/dist/components/virtual-list.d.ts +0 -19
- package/dist/components/waveform.d.ts +0 -71
- package/dist/components/workflow-steps.d.ts +0 -71
- package/dist/components/workspace.d.ts +0 -83
- package/dist/cursor-DDGBPiTJ.js.map +0 -1
- package/dist/field-BjeE_FeB.js.map +0 -1
- package/dist/generate-CjTHKJ39.js.map +0 -1
- package/dist/lib/base.d.ts +0 -10
- package/dist/lib/book.d.ts +0 -25
- package/dist/lib/boxes.d.ts +0 -55
- package/dist/lib/breakpoint.d.ts +0 -4
- package/dist/lib/choice.d.ts +0 -29
- package/dist/lib/chords.d.ts +0 -20
- package/dist/lib/client-work.d.ts +0 -24
- package/dist/lib/control.d.ts +0 -4
- package/dist/lib/dev.d.ts +0 -2
- package/dist/lib/errors.d.ts +0 -43
- package/dist/lib/file-intake.d.ts +0 -60
- package/dist/lib/format.d.ts +0 -243
- package/dist/lib/grouped-grid-layout.d.ts +0 -44
- package/dist/lib/icon.d.ts +0 -6
- package/dist/lib/image-diff.d.ts +0 -30
- package/dist/lib/in-view.d.ts +0 -21
- package/dist/lib/loudness.d.ts +0 -18
- package/dist/lib/marks.d.ts +0 -6
- package/dist/lib/microphone.d.ts +0 -24
- package/dist/lib/number-input.d.ts +0 -4
- package/dist/lib/object-url.d.ts +0 -2
- package/dist/lib/overlay.d.ts +0 -1
- package/dist/lib/recording.d.ts +0 -16
- package/dist/lib/region.d.ts +0 -64
- package/dist/lib/rich-text.d.ts +0 -44
- package/dist/lib/search-param.d.ts +0 -16
- package/dist/lib/segmenter.d.ts +0 -40
- package/dist/lib/sequence.d.ts +0 -34
- package/dist/lib/speech.d.ts +0 -53
- package/dist/lib/text-diff.d.ts +0 -16
- package/dist/lib/timeline.d.ts +0 -14
- package/dist/lib/transcript.d.ts +0 -53
- package/dist/lib/utils.d.ts +0 -4
- package/dist/lib/viewport.d.ts +0 -55
- package/dist/lib/waveform.d.ts +0 -46
- package/dist/map/fan.d.ts +0 -15
- package/dist/map/index.d.ts +0 -3
- package/dist/map/map-styles.d.ts +0 -2
- package/dist/map/markers.d.ts +0 -60
- package/dist/map/route-map.d.ts +0 -146
- package/dist/microphone-Bo3WaXgD.js.map +0 -1
- package/dist/migrate/stock-classes.d.ts +0 -11
- package/dist/panorama/gl.d.ts +0 -16
- package/dist/panorama/index.d.ts +0 -2
- package/dist/panorama/panorama-viewer.d.ts +0 -56
- package/dist/panorama/projection.d.ts +0 -45
- package/dist/query/api.d.ts +0 -23
- package/dist/query/clips.d.ts +0 -48
- package/dist/query/index.d.ts +0 -55
- package/dist/query/infinite.d.ts +0 -60
- package/dist/query/job.d.ts +0 -26
- package/dist/query/outbox.d.ts +0 -85
- package/dist/query/poll.d.ts +0 -24
- package/dist/query/reserve.d.ts +0 -33
- package/dist/query/typed-api.d.ts +0 -84
- package/dist/query/workflow.d.ts +0 -17
- package/dist/run-BT2WKzMz.js.map +0 -1
- package/dist/scene/camera.d.ts +0 -74
- package/dist/scene/index.d.ts +0 -2
- package/dist/scene/scene-viewport.d.ts +0 -48
- package/dist/testing/buttons.d.ts +0 -7
- package/dist/testing/index.d.ts +0 -161
- package/dist/testing/intersection-observer.d.ts +0 -34
- package/dist/testing/layout.d.ts +0 -13
- package/dist/testing/microphone.d.ts +0 -35
- package/dist/testing/setup.d.ts +0 -14
- package/dist/testing/speech.d.ts +0 -38
- package/dist/testing/storage.d.ts +0 -7
- package/dist/theme-CxYZkUNk.js.map +0 -1
- package/dist/tooltip-DhqrDtyu.js.map +0 -1
- package/dist/value-controls-Dm_EYfZW.js.map +0 -1
- package/dist/visual/capture.d.ts +0 -37
- package/dist/visual/compare.d.ts +0 -46
- package/dist/visual/drop.d.ts +0 -19
- package/dist/visual/fonts.d.ts +0 -18
- package/dist/visual/index.d.ts +0 -19
- package/dist/visual/run.d.ts +0 -22
- package/dist/visual/serve.d.ts +0 -13
- package/dist/visual/targets.d.ts +0 -17
- package/dist/visual/types.d.ts +0 -188
package/dist/panorama.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"panorama.js","names":[],"sources":["../src/panorama/gl.ts","../src/panorama/projection.ts","../src/panorama/panorama-viewer.tsx"],"sourcesContent":["import type { PanoramaView } from \"./projection\";\n\n// The WebGL2 side of `PanoramaViewer` (strata-react issue #178): one full-screen triangle, and a\n// fragment shader that does for every pixel what `project`/`unproject` do for one (projection.ts holds\n// the same formulas, and tests hold the two to each other): build the ray through the pixel from the\n// view's yaw, pitch and field of view, turn it into longitude and latitude, and read the equirectangular\n// texture there. The texture repeats across the seam (longitude) and clamps at the poles. No mipmaps:\n// the longitude wraps with an `atan`, whose jump at the seam would make a mipmapped lookup draw a line\n// one pixel wide down it; plain linear filtering draws none.\n//\n// Cost, as documented for apps: one texture upload per *drawn video frame* (`texImage2D` of the\n// `<video>`), none for a still picture (uploaded once), and a draw only when the view, the size or the\n// picture changed, never on a timer.\n\nconst VERTEX = `#version 300 es\nin vec2 aPos;\nout vec2 vNdc;\nvoid main() { vNdc = aPos; gl_Position = vec4(aPos, 0.0, 1.0); }`;\n\nconst FRAGMENT = `#version 300 es\nprecision highp float;\nin vec2 vNdc;\nout vec4 outColor;\nuniform sampler2D uPicture;\nuniform float uYaw;\nuniform float uPitch;\nuniform float uTanHalf;\nuniform float uAspect;\nconst float PI = 3.14159265358979;\nvoid main() {\n vec3 forward = vec3(cos(uPitch) * sin(uYaw), sin(uPitch), cos(uPitch) * cos(uYaw));\n vec3 right = vec3(cos(uYaw), 0.0, -sin(uYaw));\n vec3 up = vec3(-sin(uPitch) * sin(uYaw), cos(uPitch), -sin(uPitch) * cos(uYaw));\n vec3 ray = normalize(forward + vNdc.x * uTanHalf * right + vNdc.y * (uTanHalf / uAspect) * up);\n float lon = atan(ray.x, ray.z);\n float lat = asin(clamp(ray.y, -1.0, 1.0));\n outColor = texture(uPicture, vec2(lon / (2.0 * PI) + 0.5, 0.5 - lat / PI));\n}`;\n\n/** Anything WebGL can take as a texture: a decoded image or a playing video. */\nexport type PanoramaPicture = HTMLImageElement | HTMLVideoElement | ImageBitmap | HTMLCanvasElement;\n\n/** What draws the window. */\nexport type PanoramaRenderer = {\n /** Sends the picture to the GPU. Call when the picture is a new one (an image) or a new frame (a video). */\n upload: (picture: PanoramaPicture) => void;\n /** Draws the view into a canvas of `width` by `height` device pixels. */\n draw: (view: PanoramaView, width: number, height: number) => void;\n /** How many times `upload` has sent a picture (a video frame, an image), for the documented cost and for tests. */\n uploads: () => number;\n /** Frees the GPU objects. */\n dispose: () => void;\n};\n\n/** Makes a renderer on `canvas`, or null where WebGL2 is not available (the viewer then shows the flat picture). */\nexport function createRenderer(canvas: HTMLCanvasElement): PanoramaRenderer | null {\n const gl = canvas.getContext(\"webgl2\", { antialias: false, preserveDrawingBuffer: false, alpha: false }) as WebGL2RenderingContext | null;\n if (!gl) return null;\n const compile = (type: number, source: string) => {\n const shader = gl.createShader(type)!;\n gl.shaderSource(shader, source);\n gl.compileShader(shader);\n if (!gl.getShaderParameter(shader, gl.COMPILE_STATUS)) {\n const log = gl.getShaderInfoLog(shader);\n gl.deleteShader(shader);\n throw new Error(`Panorama shader: ${log}`);\n }\n return shader;\n };\n let program: WebGLProgram;\n try {\n program = gl.createProgram()!;\n gl.attachShader(program, compile(gl.VERTEX_SHADER, VERTEX));\n gl.attachShader(program, compile(gl.FRAGMENT_SHADER, FRAGMENT));\n gl.linkProgram(program);\n if (!gl.getProgramParameter(program, gl.LINK_STATUS)) throw new Error(`Panorama program: ${gl.getProgramInfoLog(program)}`);\n } catch {\n return null;\n }\n gl.useProgram(program);\n const buffer = gl.createBuffer();\n gl.bindBuffer(gl.ARRAY_BUFFER, buffer);\n // One triangle that covers the screen.\n gl.bufferData(gl.ARRAY_BUFFER, new Float32Array([-1, -1, 3, -1, -1, 3]), gl.STATIC_DRAW);\n const position = gl.getAttribLocation(program, \"aPos\");\n gl.enableVertexAttribArray(position);\n gl.vertexAttribPointer(position, 2, gl.FLOAT, false, 0, 0);\n const texture = gl.createTexture();\n gl.bindTexture(gl.TEXTURE_2D, texture);\n gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, gl.REPEAT);\n gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE);\n gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.LINEAR);\n gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, gl.LINEAR);\n const uniforms = {\n yaw: gl.getUniformLocation(program, \"uYaw\"),\n pitch: gl.getUniformLocation(program, \"uPitch\"),\n tanHalf: gl.getUniformLocation(program, \"uTanHalf\"),\n aspect: gl.getUniformLocation(program, \"uAspect\"),\n picture: gl.getUniformLocation(program, \"uPicture\"),\n };\n gl.uniform1i(uniforms.picture, 0);\n let uploaded = 0;\n let has = false;\n\n return {\n upload(picture) {\n gl.bindTexture(gl.TEXTURE_2D, texture);\n gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, gl.RGBA, gl.UNSIGNED_BYTE, picture);\n uploaded++;\n has = true;\n },\n draw(view, width, height) {\n if (canvas.width !== width || canvas.height !== height) {\n canvas.width = width;\n canvas.height = height;\n }\n gl.viewport(0, 0, width, height);\n if (!has) {\n gl.clearColor(0, 0, 0, 1);\n gl.clear(gl.COLOR_BUFFER_BIT);\n return;\n }\n const rad = Math.PI / 180;\n gl.uniform1f(uniforms.yaw, view.yaw * rad);\n gl.uniform1f(uniforms.pitch, view.pitch * rad);\n gl.uniform1f(uniforms.tanHalf, Math.tan((view.fov * rad) / 2));\n gl.uniform1f(uniforms.aspect, width / height);\n gl.drawArrays(gl.TRIANGLES, 0, 3);\n },\n uploads: () => uploaded,\n dispose() {\n gl.deleteTexture(texture);\n gl.deleteBuffer(buffer);\n gl.deleteProgram(program);\n },\n };\n}\n","// The geometry of `PanoramaViewer` (strata-react issue #178), with no DOM and no GL so every case\n// is tested on its own and the GL shader is held to the same numbers. A 360 picture is\n// *equirectangular*: longitude across, latitude down. The viewer shows a *rectilinear* window into the\n// sphere, as a camera does: straight lines stay straight, and the width of what is seen is the\n// horizontal field of view `fov`.\n//\n// Angles are degrees, because that is what an app and a person talk in. `yaw` is the heading: 0 is the\n// middle of the picture, positive to the right, wrapped to (-180, 180]. `pitch` is the elevation:\n// 0 is the horizon, positive up, limited to +-90 (the apps' own `maxPitch` is kept below that). A\n// direction in the world is a unit vector `(cos p sin y, sin p, cos p cos y)`; the camera's forward,\n// right and up are built from the view's yaw and pitch (no roll: upright footage). A point is drawn\n// where its direction crosses the image plane, `fpx = (width / 2) / tan(fov / 2)` pixels from the camera.\n\n/** Where the window looks and how wide it sees, degrees. */\nexport type PanoramaView = { yaw: number; pitch: number; fov: number };\n\n/** The size of the picture box in CSS pixels. */\nexport type PanoramaSize = { width: number; height: number };\n\n/** A place in the box. `inside` says it is within the box; a point behind the camera has none (`project` returns null). */\nexport type PanoramaPoint = { x: number; y: number; inside: boolean };\n\nconst RAD = Math.PI / 180;\nconst DEG = 180 / Math.PI;\n\n/** Wraps a heading to (-180, 180]. */\nexport function wrapYaw(yaw: number): number {\n const w = ((((yaw + 180) % 360) + 360) % 360) - 180;\n return w === -180 ? 180 : w;\n}\n\n/** The smallest signed turn from heading `from` to heading `to`, in (-180, 180]. Use it for a difference of headings, never `to - from`. */\nexport const yawDelta = (from: number, to: number) => wrapYaw(to - from);\n\n/** Keeps a view inside its limits: heading wrapped, pitch within +-`maxPitch`, field of view within `minFov` to `maxFov`. */\nexport function clampView(view: PanoramaView, { maxPitch = 85, minFov = 20, maxFov = 120 }: { maxPitch?: number; minFov?: number; maxFov?: number } = {}): PanoramaView {\n return { yaw: wrapYaw(view.yaw), pitch: Math.min(Math.max(view.pitch, -maxPitch), maxPitch), fov: Math.min(Math.max(view.fov, minFov), maxFov) };\n}\n\nconst focal = (view: PanoramaView, size: PanoramaSize) => size.width / 2 / Math.tan((view.fov * RAD) / 2);\n\nfunction basis(view: PanoramaView) {\n const y = view.yaw * RAD;\n const p = view.pitch * RAD;\n const forward = [Math.cos(p) * Math.sin(y), Math.sin(p), Math.cos(p) * Math.cos(y)] as const;\n const right = [Math.cos(y), 0, -Math.sin(y)] as const;\n const up = [-Math.sin(p) * Math.sin(y), Math.cos(p), -Math.sin(p) * Math.cos(y)] as const;\n return { forward, right, up };\n}\nconst dot = (a: readonly number[], b: readonly number[]) => a[0] * b[0] + a[1] * b[1] + a[2] * b[2];\n\n/** Where the direction (`yaw`, `pitch`) is drawn in the box for `view`, or null when it is behind the camera. */\nexport function project(view: PanoramaView, size: PanoramaSize, yaw: number, pitch: number): PanoramaPoint | null {\n const { forward, right, up } = basis(view);\n const p = pitch * RAD;\n const y = yaw * RAD;\n const d = [Math.cos(p) * Math.sin(y), Math.sin(p), Math.cos(p) * Math.cos(y)] as const;\n const z = dot(d, forward);\n if (z <= 1e-9) return null;\n const f = focal(view, size);\n const x = size.width / 2 + (f * dot(d, right)) / z;\n const yy = size.height / 2 - (f * dot(d, up)) / z;\n return { x, y: yy, inside: x >= 0 && x <= size.width && yy >= 0 && yy <= size.height };\n}\n\n/** The direction under a point of the box for `view`: the inverse of `project`. */\nexport function unproject(view: PanoramaView, size: PanoramaSize, x: number, y: number): { yaw: number; pitch: number } {\n const { forward, right, up } = basis(view);\n const f = focal(view, size);\n const a = (x - size.width / 2) / f;\n const b = -(y - size.height / 2) / f;\n const v = [forward[0] + a * right[0] + b * up[0], forward[1] + a * right[1] + b * up[1], forward[2] + a * right[2] + b * up[2]] as const;\n const length = Math.hypot(v[0], v[1], v[2]);\n return { yaw: wrapYaw(Math.atan2(v[0], v[2]) * DEG), pitch: Math.asin(Math.min(Math.max(v[1] / length, -1), 1)) * DEG };\n}\n\n/** Pixels to degrees at the middle of the box: how far a drag of `px` turns the view. */\nexport const degreesPerPixel = (view: PanoramaView, size: PanoramaSize) => (Math.atan(1 / focal(view, size)) * DEG);\n\n/** The flat picture's own mapping, for the fallback with no WebGL: longitude and latitude are straight across and down, the visible rectangle is `fov` wide and as tall as the box's shape makes it. */\nexport function projectFlat(view: PanoramaView, size: PanoramaSize, yaw: number, pitch: number): PanoramaPoint {\n const perPixel = view.fov / size.width;\n const x = size.width / 2 + yawDelta(view.yaw, yaw) / perPixel;\n const y = size.height / 2 - (pitch - view.pitch) / perPixel;\n return { x, y, inside: x >= 0 && x <= size.width && y >= 0 && y <= size.height };\n}\n\n/** The inverse of `projectFlat`. */\nexport function unprojectFlat(view: PanoramaView, size: PanoramaSize, x: number, y: number): { yaw: number; pitch: number } {\n const perPixel = view.fov / size.width;\n return { yaw: wrapYaw(view.yaw + (x - size.width / 2) * perPixel), pitch: Math.min(Math.max(view.pitch - (y - size.height / 2) * perPixel, -90), 90) };\n}\n\n/** The direction in words: \"Looking 40° right, 5° up\", \"Looking straight ahead\". Whole degrees; nothing is said for less than half a degree. */\nexport function describeView(view: Pick<PanoramaView, \"yaw\" | \"pitch\">): string {\n const yaw = Math.round(wrapYaw(view.yaw));\n const pitch = Math.round(view.pitch);\n const side = yaw === 0 ? \"\" : yaw === 180 ? \"directly behind\" : `${Math.abs(yaw)}° ${yaw > 0 ? \"right\" : \"left\"}`;\n const tilt = pitch === 0 ? \"\" : `${Math.abs(pitch)}° ${pitch > 0 ? \"up\" : \"down\"}`;\n const parts = [side, tilt].filter(Boolean);\n return parts.length === 0 ? \"Looking straight ahead\" : `Looking ${parts.join(\", \")}`;\n}\n","import * as React from \"react\";\nimport { VisuallyHidden } from \"react-aria\";\nimport { useInView } from \"../lib/in-view\";\nimport { cn } from \"../lib/utils\";\nimport { Slider } from \"../components/value-controls\";\nimport { createRenderer, type PanoramaPicture, type PanoramaRenderer } from \"./gl\";\nimport { clampView, degreesPerPixel, describeView, project, projectFlat, unproject, unprojectFlat, type PanoramaPoint, type PanoramaSize, type PanoramaView } from \"./projection\";\n\n// A 360 picture or video as a window you pan and zoom (strata-react issue #178, from strata-360, which\n// drew equirectangular footage with a hand-written WebGL2 shader and its own pointer, transport and\n// frame stepping). This is its own entry (`strata-react/panorama`) so an app that never shows 360 ships\n// no GL code. Nothing else in the package is as far from React Aria's world, so the choices:\n//\n// - **The picture is a canvas, the controls are keys and pointers on a group.** React Aria has no 360\n// view, so the viewer is ours; what it can give, it gives: the field-of-view slider is Strata's\n// `Slider` (React Aria's), and the pointer handling is plain pointer events (React Aria's `usePress`\n// is for a press, not a drag that turns a sphere; checked in its props: it reports a press and its\n// start and end, with no movement).\n// - **It does not own the video.** `video` is a ref to an element the app owns (`useMediaElement`,\n// `Transport`, `SeekBar` and `transportShortcuts` drive it as they drive any video, frame stepping\n// included). The viewer reads each new frame (`requestVideoFrameCallback`, else the element's events\n// and a frame loop while it plays) and uploads it: one texture upload per drawn frame, none for a\n// still picture, and no drawing at all while the viewer is off screen.\n// - **The view is controlled from outside** (`view`/`onViewChange`: yaw, pitch and field of view, in\n// degrees; `defaultView` to let it hold its own). It never animates: a view set from outside is\n// drawn at once, so an app's aim modes (follow a heading, a person, a point) are the app's own\n// function of time, and its pan on top is just another view.\n// - **From the keyboard and by touch, as well as the mouse**: arrow keys pan (Shift for more), `+` and\n// `-` zoom, `0` goes home; a drag pans (the picture follows the pointer), a wheel and a pinch zoom,\n// and a click that did not drag is `onPick` with the direction under it. A field-of-view slider is\n// an option. `maxPitch` stops the view short of the poles, where \"up\" stops meaning anything.\n// - **An overlay in the picture's coordinates**: `overlay` gets `project(yaw, pitch)` (the place in the\n// box, or null behind the camera), `unproject(x, y)` (the direction under a place) and the view, so\n// an app draws markers, aim dots and frame outlines in DOM, where they are text and buttons and take\n// focus. The same maths (projection.ts, with no GL) drives the shader.\n// - **Said in words.** The canvas is an image named by `label` and where it looks (\"Looking 40° right,\n// 5° up\"), always current; a polite status says it once the view has been still for a moment, never\n// per frame.\n// - **No WebGL2, no blank box**: the flat picture is drawn instead, cropped to the same window with the\n// same controls, and a line says so. `project` and `unproject` follow the flat drawing there, so\n// overlay markers still sit on what they mark.\n//\n// A GL context that is lost (a GPU reset, a tab in the background on a phone) is restored without the\n// app doing anything: the picture is sent again and the view redrawn.\n\nexport type PanoramaPictureSource = { image: string; video?: never } | { video: React.RefObject<HTMLVideoElement | null>; image?: never };\n\n/** What an overlay is given. */\nexport type PanoramaOverlayApi = {\n view: PanoramaView;\n size: PanoramaSize;\n /** Where the direction is in the box, or null behind the camera. */\n project: (yaw: number, pitch: number) => PanoramaPoint | null;\n /** The direction under a place in the box. */\n unproject: (x: number, y: number) => { yaw: number; pitch: number };\n /** The flat picture is being drawn (no WebGL2). */\n flat: boolean;\n};\n\nexport type PanoramaViewerProps = PanoramaPictureSource & {\n /** Names the viewer: \"360 view of the kitchen\". Required; the current direction is added to it. */\n label: string;\n /** The view, when the app holds it. */\n view?: PanoramaView;\n /** The view the viewer starts with, when it holds its own. Default straight ahead at 90°. */\n defaultView?: PanoramaView;\n /** The view changed (a drag, a key, a wheel, the slider). Not called for a view the app set. */\n onViewChange?: (view: PanoramaView) => void;\n /** A click that did not drag: the direction under it. */\n onPick?: (direction: { yaw: number; pitch: number }) => void;\n /** Highest and lowest look, degrees from the horizon. Default 85. */\n maxPitch?: number;\n /** Narrowest and widest field of view, degrees. Default 20 and 120. */\n minFov?: number;\n maxFov?: number;\n /** Zoom with the wheel. Default true. */\n wheelZoom?: boolean;\n /** Show a field-of-view slider under the picture. */\n fovSlider?: boolean;\n /** Markers and outlines drawn over the picture in its own coordinates. */\n overlay?: (api: PanoramaOverlayApi) => React.ReactNode;\n /** `\"flat\"` draws the flat picture even where WebGL2 is available (a low-power mode, or to see what a browser without it shows). Default `\"auto\"`. */\n mode?: \"auto\" | \"flat\";\n /** The shape of the box. Default 16/9. */\n aspect?: number | `${number}/${number}`;\n className?: string;\n};\n\nconst HOME: PanoramaView = { yaw: 0, pitch: 0, fov: 90 };\nconst STILL_MS = 600;\n\n/** A 360 picture or video as a window you pan and zoom, controlled from outside, with an overlay in the picture's coordinates. */\nexport function PanoramaViewer({ label, image, video, view: controlled, defaultView = HOME, onViewChange, onPick, maxPitch = 85, minFov = 20, maxFov = 120, wheelZoom = true, fovSlider = false, overlay, mode = \"auto\", aspect = \"16/9\", className }: PanoramaViewerProps) {\n const limits = React.useMemo(() => ({ maxPitch, minFov, maxFov }), [maxPitch, minFov, maxFov]);\n const [own, setOwn] = React.useState(() => clampView(defaultView, limits));\n const view = React.useMemo(() => clampView(controlled ?? own, limits), [controlled, own, limits]);\n const live = React.useRef({ view, controlled: controlled !== undefined, onViewChange, onPick, limits });\n live.current = { view, controlled: controlled !== undefined, onViewChange, onPick, limits };\n const change = React.useCallback((next: PanoramaView) => {\n const l = live.current;\n const clamped = clampView(next, l.limits);\n if (!l.controlled) setOwn(clamped);\n l.onViewChange?.(clamped);\n }, []);\n\n // The box, and the canvas in it.\n const box = React.useRef<HTMLDivElement>(null);\n const canvas = React.useRef<HTMLCanvasElement>(null);\n const [size, setSize] = React.useState<PanoramaSize>({ width: 0, height: 0 });\n React.useLayoutEffect(() => {\n const el = box.current;\n if (!el) return;\n const read = () => {\n const r = el.getBoundingClientRect();\n setSize((s) => (s.width === r.width && s.height === r.height ? s : { width: r.width, height: r.height }));\n };\n read();\n if (typeof ResizeObserver === \"undefined\") return;\n const ro = new ResizeObserver(read);\n ro.observe(el);\n return () => ro.disconnect();\n }, []);\n\n // The picture: a still is loaded once; a video is the app's element.\n const [still, setStill] = React.useState<HTMLImageElement | null>(null);\n React.useEffect(() => {\n if (image === undefined) {\n setStill(null);\n return;\n }\n const img = new Image();\n img.crossOrigin = \"anonymous\";\n let cancelled = false;\n img.onload = () => !cancelled && setStill(img);\n img.src = image;\n return () => {\n cancelled = true;\n img.onload = null;\n };\n }, [image]);\n\n // Drawing: only when something changed, and only while on screen.\n const { ref: visibleRef, inView } = useInView({ unsupported: true });\n // One stable callback: an inline one is called with null and the element on every render, and `useInView` would watch it come and go.\n const boxRef = React.useCallback(\n (el: HTMLDivElement | null) => {\n box.current = el;\n visibleRef(el);\n },\n [visibleRef],\n );\n const renderer = React.useRef<PanoramaRenderer | null>(null);\n const [flat, setFlat] = React.useState(false);\n const frame = React.useRef(0);\n const dirtyPicture = React.useRef(true);\n const current = React.useRef({ size, inView, flat });\n current.current = { size, inView, flat };\n\n const pictureNow = React.useCallback((): PanoramaPicture | null => {\n const v = video?.current;\n if (v) return v.readyState >= 2 && v.videoWidth > 0 ? v : null;\n return still;\n }, [video, still]);\n\n const paint = React.useCallback(() => {\n frame.current = 0;\n const c = canvas.current;\n const { size: s, inView: visible } = current.current;\n if (!c || !visible || s.width === 0 || s.height === 0) return;\n const picture = pictureNow();\n const dpr = Math.min(typeof devicePixelRatio === \"number\" ? devicePixelRatio : 1, 2);\n const w = Math.max(1, Math.round(s.width * dpr));\n const h = Math.max(1, Math.round(s.height * dpr));\n if (current.current.flat) {\n const ctx = c.getContext(\"2d\");\n if (!ctx) return;\n if (c.width !== w || c.height !== h) {\n c.width = w;\n c.height = h;\n }\n ctx.fillStyle = \"#000\";\n ctx.fillRect(0, 0, w, h);\n if (!picture) return;\n const sw = (picture as HTMLImageElement).naturalWidth || (picture as HTMLVideoElement).videoWidth || c.width;\n const sh = (picture as HTMLImageElement).naturalHeight || (picture as HTMLVideoElement).videoHeight || c.height;\n const v = live.current.view;\n const wide = (v.fov / 360) * sw;\n const tall = ((v.fov * (s.height / s.width)) / 180) * sh;\n const left = ((v.yaw - v.fov / 2 + 180) / 360) * sw;\n const top = ((90 - v.pitch) / 180) * sh - tall / 2;\n // Across the seam the window is two pieces of the picture side by side.\n for (const shift of [-sw, 0, sw]) {\n const a = Math.max(left + shift, 0);\n const b = Math.min(left + shift + wide, sw);\n if (b > a) ctx.drawImage(picture as CanvasImageSource, a, Math.max(top, 0), b - a, Math.min(tall, sh), ((a - (left + shift)) / wide) * w, 0, ((b - a) / wide) * w, h);\n }\n return;\n }\n const r = renderer.current;\n if (!r) return;\n if (picture && dirtyPicture.current) {\n r.upload(picture);\n dirtyPicture.current = false;\n }\n r.draw(live.current.view, w, h);\n }, [pictureNow]);\n const schedule = React.useCallback(() => {\n if (frame.current === 0) frame.current = requestAnimationFrame(paint);\n }, [paint]);\n\n // The renderer: made once, restored if the context is lost, and the flat picture if there is none.\n React.useEffect(() => {\n const c = canvas.current;\n if (!c) return;\n const make = () => {\n renderer.current?.dispose();\n renderer.current = mode === \"flat\" ? null : createRenderer(c);\n setFlat(renderer.current === null);\n dirtyPicture.current = true;\n schedule();\n };\n make();\n const lost = (e: Event) => {\n e.preventDefault();\n renderer.current = null;\n };\n c.addEventListener(\"webglcontextlost\", lost);\n c.addEventListener(\"webglcontextrestored\", make);\n return () => {\n c.removeEventListener(\"webglcontextlost\", lost);\n c.removeEventListener(\"webglcontextrestored\", make);\n renderer.current?.dispose();\n renderer.current = null;\n if (frame.current) cancelAnimationFrame(frame.current);\n frame.current = 0;\n };\n }, [schedule, mode]);\n\n // A new still, a new size, a new view, or coming into view: draw.\n React.useEffect(() => {\n dirtyPicture.current = true;\n }, [still]);\n React.useEffect(() => {\n schedule();\n }, [schedule, view.yaw, view.pitch, view.fov, size.width, size.height, still, inView, flat]);\n\n // A video: each new frame is one upload and one draw.\n React.useEffect(() => {\n const v = video?.current;\n if (!v || !inView) return;\n let stopped = false;\n let handle = 0;\n const onFrame = () => {\n if (stopped) return;\n dirtyPicture.current = true;\n schedule();\n handle = v.requestVideoFrameCallback(onFrame);\n };\n if (typeof v.requestVideoFrameCallback === \"function\") {\n handle = v.requestVideoFrameCallback(onFrame);\n return () => {\n stopped = true;\n v.cancelVideoFrameCallback?.(handle);\n };\n }\n // No frame callback: the element's own events, and a frame loop while it plays.\n const touch = () => {\n dirtyPicture.current = true;\n schedule();\n };\n const events = [\"loadeddata\", \"seeked\", \"timeupdate\", \"play\", \"pause\"] as const;\n for (const e of events) v.addEventListener(e, touch);\n let loop = 0;\n const tick = () => {\n if (!v.paused) touch();\n loop = requestAnimationFrame(tick);\n };\n loop = requestAnimationFrame(tick);\n return () => {\n for (const e of events) v.removeEventListener(e, touch);\n cancelAnimationFrame(loop);\n };\n }, [video, inView, schedule]);\n\n // Pointer: drag turns the view with the pointer, two pointers pinch, a click that did not drag picks.\n const pointers = React.useRef(new Map<number, { x: number; y: number }>());\n const gesture = React.useRef<{ moved: boolean; pinch: number | null; start: { x: number; y: number } } | null>(null);\n const hostRect = () => box.current!.getBoundingClientRect();\n const onPointerDown = (e: React.PointerEvent<HTMLDivElement>) => {\n if (e.button !== 0 && e.pointerType === \"mouse\") return;\n pointers.current.set(e.pointerId, { x: e.clientX, y: e.clientY });\n e.currentTarget.setPointerCapture?.(e.pointerId);\n const [first, second] = [...pointers.current.values()];\n const distance = second ? Math.hypot(first.x - second.x, first.y - second.y) : null;\n gesture.current = { moved: false, pinch: distance, start: { x: e.clientX, y: e.clientY } };\n e.currentTarget.focus({ preventScroll: true });\n };\n const onPointerMove = (e: React.PointerEvent<HTMLDivElement>) => {\n const last = pointers.current.get(e.pointerId);\n if (!last || !gesture.current) return;\n const now = { x: e.clientX, y: e.clientY };\n pointers.current.set(e.pointerId, now);\n const v = live.current.view;\n const s = { width: hostRect().width, height: hostRect().height };\n if (pointers.current.size === 2) {\n const [a, b] = [...pointers.current.values()];\n const d = Math.hypot(a.x - b.x, a.y - b.y);\n if (gesture.current.pinch && d > 0) change({ ...v, fov: v.fov * (gesture.current.pinch / d) });\n gesture.current.pinch = d;\n gesture.current.moved = true;\n return;\n }\n if (Math.hypot(now.x - gesture.current.start.x, now.y - gesture.current.start.y) > 4) gesture.current.moved = true;\n if (!gesture.current.moved) return;\n // The picture follows the pointer: dragging right turns the view left.\n const per = degreesPerPixel(v, s);\n change({ ...v, yaw: v.yaw - (now.x - last.x) * per, pitch: v.pitch + (now.y - last.y) * per });\n };\n const onPointerUp = (e: React.PointerEvent<HTMLDivElement>) => {\n const g = gesture.current;\n pointers.current.delete(e.pointerId);\n if (pointers.current.size === 0) {\n gesture.current = null;\n if (g && !g.moved && live.current.onPick) {\n const r = hostRect();\n const s = { width: r.width, height: r.height };\n const x = e.clientX - r.left;\n const y = e.clientY - r.top;\n live.current.onPick(current.current.flat ? unprojectFlat(live.current.view, s, x, y) : unproject(live.current.view, s, x, y));\n }\n } else if (g) g.pinch = null;\n };\n\n // The wheel zooms; native, because React's wheel listener is passive and the page must not scroll too.\n React.useEffect(() => {\n const el = box.current;\n if (!el || !wheelZoom) return;\n const onWheel = (e: WheelEvent) => {\n e.preventDefault();\n const v = live.current.view;\n change({ ...v, fov: v.fov * Math.exp(e.deltaY * 0.0015) });\n };\n el.addEventListener(\"wheel\", onWheel, { passive: false });\n return () => el.removeEventListener(\"wheel\", onWheel);\n }, [wheelZoom, change]);\n\n const onKeyDown = (e: React.KeyboardEvent) => {\n const v = live.current.view;\n const turn = (v.fov / 12) * (e.shiftKey ? 3 : 1);\n if (e.key === \"ArrowLeft\") change({ ...v, yaw: v.yaw - turn });\n else if (e.key === \"ArrowRight\") change({ ...v, yaw: v.yaw + turn });\n else if (e.key === \"ArrowUp\") change({ ...v, pitch: v.pitch + turn });\n else if (e.key === \"ArrowDown\") change({ ...v, pitch: v.pitch - turn });\n else if (e.key === \"+\" || e.key === \"=\") change({ ...v, fov: v.fov * 0.8 });\n else if (e.key === \"-\" || e.key === \"_\") change({ ...v, fov: v.fov * 1.25 });\n else if (e.key === \"0\") change(defaultView);\n else return;\n e.preventDefault();\n };\n\n // Said in words: always on the picture; politely once the view has been still for a moment.\n const direction = describeView(view);\n const [said, setSaid] = React.useState(\"\");\n const first = React.useRef(true);\n React.useEffect(() => {\n if (first.current) {\n first.current = false;\n return;\n }\n const t = setTimeout(() => setSaid(`${direction}, field of view ${Math.round(view.fov)}°`), STILL_MS);\n return () => clearTimeout(t);\n }, [direction, view.fov]);\n\n const api: PanoramaOverlayApi = {\n view,\n size,\n flat,\n project: (yaw, pitch) => (flat ? projectFlat(view, size, yaw, pitch) : project(view, size, yaw, pitch)),\n unproject: (x, y) => (flat ? unprojectFlat(view, size, x, y) : unproject(view, size, x, y)),\n };\n const slider = fovSlider ? <Slider aria-label=\"Field of view\" value={Math.round(view.fov)} onChange={(fov) => change({ ...view, fov })} min={minFov} max={maxFov} step={1} unit=\"degree\" /> : null;\n\n return (\n <div className={cn(\"grid min-w-0 gap-2\", className)}>\n <div\n ref={boxRef}\n role=\"group\"\n aria-label={label}\n aria-describedby={undefined}\n tabIndex={0}\n onKeyDown={onKeyDown}\n onPointerDown={onPointerDown}\n onPointerMove={onPointerMove}\n onPointerUp={onPointerUp}\n onPointerCancel={onPointerUp}\n className=\"relative w-full cursor-grab touch-none overflow-hidden rounded-surface bg-surface-sunken select-none active:cursor-grabbing\"\n style={{ aspectRatio: aspect }}\n >\n <canvas key={mode === \"flat\" ? \"2d\" : \"gl\"} ref={canvas} role=\"img\" aria-label={`${label}. ${direction}, field of view ${Math.round(view.fov)}°`} className=\"absolute inset-0 size-full\" />\n {overlay && size.width > 0 && <div className=\"pointer-events-none absolute inset-0\">{overlay(api)}</div>}\n </div>\n {flat && <p className=\"type-body-sm text-muted-foreground\">This browser cannot draw the 360 view, so the flat picture is shown. The controls work the same.</p>}\n {slider}\n <VisuallyHidden>\n <span role=\"status\">{said}</span>\n </VisuallyHidden>\n </div>\n );\n}\n"],"mappings":";;;;;;;AAcA,IAAM,SAAS;;;;AAKf,IAAM,WAAW;;;;;;;;;;;;;;;;;;;;AAoCjB,SAAgB,eAAe,QAAoD;CACjF,MAAM,KAAK,OAAO,WAAW,UAAU;EAAE,WAAW;EAAO,uBAAuB;EAAO,OAAO;CAAM,CAAC;CACvG,IAAI,CAAC,IAAI,OAAO;CAChB,MAAM,WAAW,MAAc,WAAmB;EAChD,MAAM,SAAS,GAAG,aAAa,IAAI;EACnC,GAAG,aAAa,QAAQ,MAAM;EAC9B,GAAG,cAAc,MAAM;EACvB,IAAI,CAAC,GAAG,mBAAmB,QAAQ,GAAG,cAAc,GAAG;GACrD,MAAM,MAAM,GAAG,iBAAiB,MAAM;GACtC,GAAG,aAAa,MAAM;GACtB,MAAM,IAAI,MAAM,oBAAoB,KAAK;EAC3C;EACA,OAAO;CACT;CACA,IAAI;CACJ,IAAI;EACF,UAAU,GAAG,cAAc;EAC3B,GAAG,aAAa,SAAS,QAAQ,GAAG,eAAe,MAAM,CAAC;EAC1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AAC,KAAD;IAAG,WAAU;IAAqC,UAAA;GAAmG,CAAA;GAC7J;GACD,oBAAC,gBAAD,EAAA,UACE,oBAAC,QAAD;IAAM,MAAK;IAAU,UAAA;GAAW,CAAA,EAClB,CAAA;EACb;;AAET"}
|
|
1
|
+
{"version":3,"file":"panorama.js","names":[],"sources":["../src/panorama/gl.ts","../src/panorama/projection.ts","../src/panorama/panorama-viewer.tsx"],"sourcesContent":["import type { PanoramaView } from \"./projection\";\n\n// The WebGL2 side of `PanoramaViewer` (strata-react issue #178): one full-screen triangle, and a\n// fragment shader that does for every pixel what `project`/`unproject` do for one (projection.ts holds\n// the same formulas, and tests hold the two to each other): build the ray through the pixel from the\n// view's yaw, pitch and field of view, turn it into longitude and latitude, and read the equirectangular\n// texture there. The texture repeats across the seam (longitude) and clamps at the poles. No mipmaps:\n// the longitude wraps with an `atan`, whose jump at the seam would make a mipmapped lookup draw a line\n// one pixel wide down it; plain linear filtering draws none.\n//\n// Cost, as documented for apps: one texture upload per *drawn video frame* (`texImage2D` of the\n// `<video>`), none for a still picture (uploaded once), and a draw only when the view, the size or the\n// picture changed, never on a timer.\n\nconst VERTEX = `#version 300 es\nin vec2 aPos;\nout vec2 vNdc;\nvoid main() { vNdc = aPos; gl_Position = vec4(aPos, 0.0, 1.0); }`;\n\nconst FRAGMENT = `#version 300 es\nprecision highp float;\nin vec2 vNdc;\nout vec4 outColor;\nuniform sampler2D uPicture;\nuniform float uYaw;\nuniform float uPitch;\nuniform float uTanHalf;\nuniform float uAspect;\nconst float PI = 3.14159265358979;\nvoid main() {\n vec3 forward = vec3(cos(uPitch) * sin(uYaw), sin(uPitch), cos(uPitch) * cos(uYaw));\n vec3 right = vec3(cos(uYaw), 0.0, -sin(uYaw));\n vec3 up = vec3(-sin(uPitch) * sin(uYaw), cos(uPitch), -sin(uPitch) * cos(uYaw));\n vec3 ray = normalize(forward + vNdc.x * uTanHalf * right + vNdc.y * (uTanHalf / uAspect) * up);\n float lon = atan(ray.x, ray.z);\n float lat = asin(clamp(ray.y, -1.0, 1.0));\n outColor = texture(uPicture, vec2(lon / (2.0 * PI) + 0.5, 0.5 - lat / PI));\n}`;\n\n/** Anything WebGL can take as a texture: a decoded image or a playing video. */\nexport type PanoramaPicture = HTMLImageElement | HTMLVideoElement | ImageBitmap | HTMLCanvasElement;\n\n/** What draws the window. */\nexport type PanoramaRenderer = {\n /** Sends the picture to the GPU. Call when the picture is a new one (an image) or a new frame (a video). */\n upload: (picture: PanoramaPicture) => void;\n /** Draws the view into a canvas of `width` by `height` device pixels. */\n draw: (view: PanoramaView, width: number, height: number) => void;\n /** How many times `upload` has sent a picture (a video frame, an image), for the documented cost and for tests. */\n uploads: () => number;\n /** Frees the GPU objects. */\n dispose: () => void;\n};\n\n/** Makes a renderer on `canvas`, or null where WebGL2 is not available (the viewer then shows the flat picture). */\nexport function createRenderer(canvas: HTMLCanvasElement): PanoramaRenderer | null {\n const gl = canvas.getContext(\"webgl2\", {\n antialias: false,\n preserveDrawingBuffer: false,\n alpha: false,\n }) as WebGL2RenderingContext | null;\n if (!gl) return null;\n const compile = (type: number, source: string) => {\n const shader = gl.createShader(type)!;\n gl.shaderSource(shader, source);\n gl.compileShader(shader);\n if (!gl.getShaderParameter(shader, gl.COMPILE_STATUS)) {\n const log = gl.getShaderInfoLog(shader);\n gl.deleteShader(shader);\n throw new Error(`Panorama shader: ${log}`);\n }\n return shader;\n };\n let program: WebGLProgram;\n try {\n program = gl.createProgram()!;\n gl.attachShader(program, compile(gl.VERTEX_SHADER, VERTEX));\n gl.attachShader(program, compile(gl.FRAGMENT_SHADER, FRAGMENT));\n gl.linkProgram(program);\n if (!gl.getProgramParameter(program, gl.LINK_STATUS))\n throw new Error(`Panorama program: ${gl.getProgramInfoLog(program)}`);\n } catch {\n return null;\n }\n gl.useProgram(program);\n const buffer = gl.createBuffer();\n gl.bindBuffer(gl.ARRAY_BUFFER, buffer);\n // One triangle that covers the screen.\n gl.bufferData(gl.ARRAY_BUFFER, new Float32Array([-1, -1, 3, -1, -1, 3]), gl.STATIC_DRAW);\n const position = gl.getAttribLocation(program, \"aPos\");\n gl.enableVertexAttribArray(position);\n gl.vertexAttribPointer(position, 2, gl.FLOAT, false, 0, 0);\n const texture = gl.createTexture();\n gl.bindTexture(gl.TEXTURE_2D, texture);\n gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, gl.REPEAT);\n gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE);\n gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.LINEAR);\n gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, gl.LINEAR);\n const uniforms = {\n yaw: gl.getUniformLocation(program, \"uYaw\"),\n pitch: gl.getUniformLocation(program, \"uPitch\"),\n tanHalf: gl.getUniformLocation(program, \"uTanHalf\"),\n aspect: gl.getUniformLocation(program, \"uAspect\"),\n picture: gl.getUniformLocation(program, \"uPicture\"),\n };\n gl.uniform1i(uniforms.picture, 0);\n let uploaded = 0;\n let has = false;\n\n return {\n upload(picture) {\n gl.bindTexture(gl.TEXTURE_2D, texture);\n gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, gl.RGBA, gl.UNSIGNED_BYTE, picture);\n uploaded++;\n has = true;\n },\n draw(view, width, height) {\n if (canvas.width !== width || canvas.height !== height) {\n canvas.width = width;\n canvas.height = height;\n }\n gl.viewport(0, 0, width, height);\n if (!has) {\n gl.clearColor(0, 0, 0, 1);\n gl.clear(gl.COLOR_BUFFER_BIT);\n return;\n }\n const rad = Math.PI / 180;\n gl.uniform1f(uniforms.yaw, view.yaw * rad);\n gl.uniform1f(uniforms.pitch, view.pitch * rad);\n gl.uniform1f(uniforms.tanHalf, Math.tan((view.fov * rad) / 2));\n gl.uniform1f(uniforms.aspect, width / height);\n gl.drawArrays(gl.TRIANGLES, 0, 3);\n },\n uploads: () => uploaded,\n dispose() {\n gl.deleteTexture(texture);\n gl.deleteBuffer(buffer);\n gl.deleteProgram(program);\n },\n };\n}\n","// The geometry of `PanoramaViewer` (strata-react issue #178), with no DOM and no GL so every case\n// is tested on its own and the GL shader is held to the same numbers. A 360 picture is\n// *equirectangular*: longitude across, latitude down. The viewer shows a *rectilinear* window into the\n// sphere, as a camera does: straight lines stay straight, and the width of what is seen is the\n// horizontal field of view `fov`.\n//\n// Angles are degrees, because that is what an app and a person talk in. `yaw` is the heading: 0 is the\n// middle of the picture, positive to the right, wrapped to (-180, 180]. `pitch` is the elevation:\n// 0 is the horizon, positive up, limited to +-90 (the apps' own `maxPitch` is kept below that). A\n// direction in the world is a unit vector `(cos p sin y, sin p, cos p cos y)`; the camera's forward,\n// right and up are built from the view's yaw and pitch (no roll: upright footage). A point is drawn\n// where its direction crosses the image plane, `fpx = (width / 2) / tan(fov / 2)` pixels from the camera.\n\n/** Where the window looks and how wide it sees, degrees. */\nexport type PanoramaView = { yaw: number; pitch: number; fov: number };\n\n/** The size of the picture box in CSS pixels. */\nexport type PanoramaSize = { width: number; height: number };\n\n/** A place in the box. `inside` says it is within the box; a point behind the camera has none (`project` returns null). */\nexport type PanoramaPoint = { x: number; y: number; inside: boolean };\n\nconst RAD = Math.PI / 180;\nconst DEG = 180 / Math.PI;\n\n/** Wraps a heading to (-180, 180]. */\nexport function wrapYaw(yaw: number): number {\n const w = ((((yaw + 180) % 360) + 360) % 360) - 180;\n return w === -180 ? 180 : w;\n}\n\n/** The smallest signed turn from heading `from` to heading `to`, in (-180, 180]. Use it for a difference of headings, never `to - from`. */\nexport const yawDelta = (from: number, to: number) => wrapYaw(to - from);\n\n/** Keeps a view inside its limits: heading wrapped, pitch within +-`maxPitch`, field of view within `minFov` to `maxFov`. */\nexport function clampView(\n view: PanoramaView,\n { maxPitch = 85, minFov = 20, maxFov = 120 }: { maxPitch?: number; minFov?: number; maxFov?: number } = {},\n): PanoramaView {\n return {\n yaw: wrapYaw(view.yaw),\n pitch: Math.min(Math.max(view.pitch, -maxPitch), maxPitch),\n fov: Math.min(Math.max(view.fov, minFov), maxFov),\n };\n}\n\nconst focal = (view: PanoramaView, size: PanoramaSize) => size.width / 2 / Math.tan((view.fov * RAD) / 2);\n\nfunction basis(view: PanoramaView) {\n const y = view.yaw * RAD;\n const p = view.pitch * RAD;\n const forward = [Math.cos(p) * Math.sin(y), Math.sin(p), Math.cos(p) * Math.cos(y)] as const;\n const right = [Math.cos(y), 0, -Math.sin(y)] as const;\n const up = [-Math.sin(p) * Math.sin(y), Math.cos(p), -Math.sin(p) * Math.cos(y)] as const;\n return { forward, right, up };\n}\nconst dot = (a: readonly number[], b: readonly number[]) => a[0] * b[0] + a[1] * b[1] + a[2] * b[2];\n\n/** Where the direction (`yaw`, `pitch`) is drawn in the box for `view`, or null when it is behind the camera. */\nexport function project(view: PanoramaView, size: PanoramaSize, yaw: number, pitch: number): PanoramaPoint | null {\n const { forward, right, up } = basis(view);\n const p = pitch * RAD;\n const y = yaw * RAD;\n const d = [Math.cos(p) * Math.sin(y), Math.sin(p), Math.cos(p) * Math.cos(y)] as const;\n const z = dot(d, forward);\n if (z <= 1e-9) return null;\n const f = focal(view, size);\n const x = size.width / 2 + (f * dot(d, right)) / z;\n const yy = size.height / 2 - (f * dot(d, up)) / z;\n return { x, y: yy, inside: x >= 0 && x <= size.width && yy >= 0 && yy <= size.height };\n}\n\n/** The direction under a point of the box for `view`: the inverse of `project`. */\nexport function unproject(\n view: PanoramaView,\n size: PanoramaSize,\n x: number,\n y: number,\n): { yaw: number; pitch: number } {\n const { forward, right, up } = basis(view);\n const f = focal(view, size);\n const a = (x - size.width / 2) / f;\n const b = -(y - size.height / 2) / f;\n const v = [\n forward[0] + a * right[0] + b * up[0],\n forward[1] + a * right[1] + b * up[1],\n forward[2] + a * right[2] + b * up[2],\n ] as const;\n const length = Math.hypot(v[0], v[1], v[2]);\n return {\n yaw: wrapYaw(Math.atan2(v[0], v[2]) * DEG),\n pitch: Math.asin(Math.min(Math.max(v[1] / length, -1), 1)) * DEG,\n };\n}\n\n/** Pixels to degrees at the middle of the box: how far a drag of `px` turns the view. */\nexport const degreesPerPixel = (view: PanoramaView, size: PanoramaSize) => Math.atan(1 / focal(view, size)) * DEG;\n\n/** The flat picture's own mapping, for the fallback with no WebGL: longitude and latitude are straight across and down, the visible rectangle is `fov` wide and as tall as the box's shape makes it. */\nexport function projectFlat(view: PanoramaView, size: PanoramaSize, yaw: number, pitch: number): PanoramaPoint {\n const perPixel = view.fov / size.width;\n const x = size.width / 2 + yawDelta(view.yaw, yaw) / perPixel;\n const y = size.height / 2 - (pitch - view.pitch) / perPixel;\n return { x, y, inside: x >= 0 && x <= size.width && y >= 0 && y <= size.height };\n}\n\n/** The inverse of `projectFlat`. */\nexport function unprojectFlat(\n view: PanoramaView,\n size: PanoramaSize,\n x: number,\n y: number,\n): { yaw: number; pitch: number } {\n const perPixel = view.fov / size.width;\n return {\n yaw: wrapYaw(view.yaw + (x - size.width / 2) * perPixel),\n pitch: Math.min(Math.max(view.pitch - (y - size.height / 2) * perPixel, -90), 90),\n };\n}\n\n/** The direction in words: \"Looking 40° right, 5° up\", \"Looking straight ahead\". Whole degrees; nothing is said for less than half a degree. */\nexport function describeView(view: Pick<PanoramaView, \"yaw\" | \"pitch\">): string {\n const yaw = Math.round(wrapYaw(view.yaw));\n const pitch = Math.round(view.pitch);\n const side = yaw === 0 ? \"\" : yaw === 180 ? \"directly behind\" : `${Math.abs(yaw)}° ${yaw > 0 ? \"right\" : \"left\"}`;\n const tilt = pitch === 0 ? \"\" : `${Math.abs(pitch)}° ${pitch > 0 ? \"up\" : \"down\"}`;\n const parts = [side, tilt].filter(Boolean);\n return parts.length === 0 ? \"Looking straight ahead\" : `Looking ${parts.join(\", \")}`;\n}\n","import * as React from \"react\";\nimport { VisuallyHidden } from \"react-aria\";\nimport { useInView } from \"../lib/in-view\";\nimport { useSettledStatus, useViewPointers, useWheelZoom } from \"../lib/viewer-input\";\nimport { cn } from \"../lib/utils\";\nimport { Slider } from \"../components/value-controls\";\nimport { createRenderer, type PanoramaPicture, type PanoramaRenderer } from \"./gl\";\nimport {\n clampView,\n degreesPerPixel,\n describeView,\n project,\n projectFlat,\n unproject,\n unprojectFlat,\n type PanoramaPoint,\n type PanoramaSize,\n type PanoramaView,\n} from \"./projection\";\n\n// A 360 picture or video as a window you pan and zoom (strata-react issue #178, from strata-360, which\n// drew equirectangular footage with a hand-written WebGL2 shader and its own pointer, transport and\n// frame stepping). This is its own entry (`strata-react/panorama`) so an app that never shows 360 ships\n// no GL code. Nothing else in the package is as far from React Aria's world, so the choices:\n//\n// - **The picture is a canvas, the controls are keys and pointers on a group.** React Aria has no 360\n// view, so the viewer is ours; what it can give, it gives: the field-of-view slider is Strata's\n// `Slider` (React Aria's), and the pointer handling is plain pointer events (React Aria's `usePress`\n// is for a press, not a drag that turns a sphere; checked in its props: it reports a press and its\n// start and end, with no movement).\n// - **It does not own the video.** `video` is a ref to an element the app owns (`useMediaElement`,\n// `Transport`, `SeekBar` and `transportShortcuts` drive it as they drive any video, frame stepping\n// included). The viewer reads each new frame (`requestVideoFrameCallback`, else the element's events\n// and a frame loop while it plays) and uploads it: one texture upload per drawn frame, none for a\n// still picture, and no drawing at all while the viewer is off screen.\n// - **The view is controlled from outside** (`view`/`onViewChange`: yaw, pitch and field of view, in\n// degrees; `defaultView` to let it hold its own). It never animates: a view set from outside is\n// drawn at once, so an app's aim modes (follow a heading, a person, a point) are the app's own\n// function of time, and its pan on top is just another view.\n// - **From the keyboard and by touch, as well as the mouse**: arrow keys pan (Shift for more), `+` and\n// `-` zoom, `0` goes home; a drag pans (the picture follows the pointer), a wheel and a pinch zoom,\n// and a click that did not drag is `onPick` with the direction under it. A field-of-view slider is\n// an option. `maxPitch` stops the view short of the poles, where \"up\" stops meaning anything.\n// - **An overlay in the picture's coordinates**: `overlay` gets `project(yaw, pitch)` (the place in the\n// box, or null behind the camera), `unproject(x, y)` (the direction under a place) and the view, so\n// an app draws markers, aim dots and frame outlines in DOM, where they are text and buttons and take\n// focus. The same maths (projection.ts, with no GL) drives the shader.\n// - **Said in words.** The canvas is an image named by `label` and where it looks (\"Looking 40° right,\n// 5° up\"), always current; a polite status says it once the view has been still for a moment, never\n// per frame.\n// - **No WebGL2, no blank box**: the flat picture is drawn instead, cropped to the same window with the\n// same controls, and a line says so. `project` and `unproject` follow the flat drawing there, so\n// overlay markers still sit on what they mark.\n//\n// A GL context that is lost (a GPU reset, a tab in the background on a phone) is restored without the\n// app doing anything: the picture is sent again and the view redrawn.\n\nexport type PanoramaPictureSource =\n | { image: string; video?: never }\n | { video: React.RefObject<HTMLVideoElement | null>; image?: never };\n\n/** What an overlay is given. */\nexport type PanoramaOverlayApi = {\n view: PanoramaView;\n size: PanoramaSize;\n /** Where the direction is in the box, or null behind the camera. */\n project: (yaw: number, pitch: number) => PanoramaPoint | null;\n /** The direction under a place in the box. */\n unproject: (x: number, y: number) => { yaw: number; pitch: number };\n /** The flat picture is being drawn (no WebGL2). */\n flat: boolean;\n};\n\nexport type PanoramaViewerProps = PanoramaPictureSource & {\n /** Names the viewer: \"360 view of the kitchen\". Required; the current direction is added to it. */\n label: string;\n /** The view, when the app holds it. */\n view?: PanoramaView;\n /** The view the viewer starts with, when it holds its own. Default straight ahead at 90°. */\n defaultView?: PanoramaView;\n /** The view changed (a drag, a key, a wheel, the slider). Not called for a view the app set. */\n onViewChange?: (view: PanoramaView) => void;\n /** A click that did not drag: the direction under it. */\n onPick?: (direction: { yaw: number; pitch: number }) => void;\n /** Highest and lowest look, degrees from the horizon. Default 85. */\n maxPitch?: number;\n /** Narrowest and widest field of view, degrees. Default 20 and 120. */\n minFov?: number;\n maxFov?: number;\n /** Zoom with the wheel. Default true. */\n wheelZoom?: boolean;\n /** Show a field-of-view slider under the picture. */\n fovSlider?: boolean;\n /** Markers and outlines drawn over the picture in its own coordinates. */\n overlay?: (api: PanoramaOverlayApi) => React.ReactNode;\n /** `\"flat\"` draws the flat picture even where WebGL2 is available (a low-power mode, or to see what a browser without it shows). Default `\"auto\"`. */\n mode?: \"auto\" | \"flat\";\n /** The shape of the box. Default 16/9. */\n aspect?: number | `${number}/${number}`;\n className?: string;\n};\n\nconst HOME: PanoramaView = { yaw: 0, pitch: 0, fov: 90 };\nconst STILL_MS = 600;\n\n/** A 360 picture or video as a window you pan and zoom, controlled from outside, with an overlay in the picture's coordinates. */\nexport function PanoramaViewer({\n label,\n image,\n video,\n view: controlled,\n defaultView = HOME,\n onViewChange,\n onPick,\n maxPitch = 85,\n minFov = 20,\n maxFov = 120,\n wheelZoom = true,\n fovSlider = false,\n overlay,\n mode = \"auto\",\n aspect = \"16/9\",\n className,\n}: PanoramaViewerProps) {\n const limits = React.useMemo(() => ({ maxPitch, minFov, maxFov }), [maxPitch, minFov, maxFov]);\n const [own, setOwn] = React.useState(() => clampView(defaultView, limits));\n const view = React.useMemo(() => clampView(controlled ?? own, limits), [controlled, own, limits]);\n const live = React.useRef({ view, controlled: controlled !== undefined, onViewChange, onPick, limits });\n live.current = { view, controlled: controlled !== undefined, onViewChange, onPick, limits };\n const change = React.useCallback((next: PanoramaView) => {\n const l = live.current;\n const clamped = clampView(next, l.limits);\n if (!l.controlled) setOwn(clamped);\n l.onViewChange?.(clamped);\n }, []);\n\n // The box, and the canvas in it.\n const box = React.useRef<HTMLDivElement>(null);\n const canvas = React.useRef<HTMLCanvasElement>(null);\n const [size, setSize] = React.useState<PanoramaSize>({ width: 0, height: 0 });\n React.useLayoutEffect(() => {\n const el = box.current;\n if (!el) return;\n const read = () => {\n const r = el.getBoundingClientRect();\n setSize((s) => (s.width === r.width && s.height === r.height ? s : { width: r.width, height: r.height }));\n };\n read();\n if (typeof ResizeObserver === \"undefined\") return;\n const ro = new ResizeObserver(read);\n ro.observe(el);\n return () => ro.disconnect();\n }, []);\n\n // The picture: a still is loaded once; a video is the app's element.\n const [still, setStill] = React.useState<HTMLImageElement | null>(null);\n React.useEffect(() => {\n if (image === undefined) {\n setStill(null);\n return;\n }\n const img = new Image();\n img.crossOrigin = \"anonymous\";\n let cancelled = false;\n img.onload = () => !cancelled && setStill(img);\n img.src = image;\n return () => {\n cancelled = true;\n img.onload = null;\n };\n }, [image]);\n\n // Drawing: only when something changed, and only while on screen.\n const { ref: visibleRef, inView } = useInView({ unsupported: true });\n // One stable callback: an inline one is called with null and the element on every render, and `useInView` would watch it come and go.\n const boxRef = React.useCallback(\n (el: HTMLDivElement | null) => {\n box.current = el;\n visibleRef(el);\n },\n [visibleRef],\n );\n const renderer = React.useRef<PanoramaRenderer | null>(null);\n const [flat, setFlat] = React.useState(false);\n const frame = React.useRef(0);\n const dirtyPicture = React.useRef(true);\n const current = React.useRef({ size, inView, flat });\n current.current = { size, inView, flat };\n\n const pictureNow = React.useCallback((): PanoramaPicture | null => {\n const v = video?.current;\n if (v) return v.readyState >= 2 && v.videoWidth > 0 ? v : null;\n return still;\n }, [video, still]);\n\n const paint = React.useCallback(() => {\n frame.current = 0;\n const c = canvas.current;\n const { size: s, inView: visible } = current.current;\n if (!c || !visible || s.width === 0 || s.height === 0) return;\n const picture = pictureNow();\n const dpr = Math.min(typeof devicePixelRatio === \"number\" ? devicePixelRatio : 1, 2);\n const w = Math.max(1, Math.round(s.width * dpr));\n const h = Math.max(1, Math.round(s.height * dpr));\n if (current.current.flat) {\n const ctx = c.getContext(\"2d\");\n if (!ctx) return;\n if (c.width !== w || c.height !== h) {\n c.width = w;\n c.height = h;\n }\n ctx.fillStyle = \"#000\";\n ctx.fillRect(0, 0, w, h);\n if (!picture) return;\n const sw = (picture as HTMLImageElement).naturalWidth || (picture as HTMLVideoElement).videoWidth || c.width;\n const sh = (picture as HTMLImageElement).naturalHeight || (picture as HTMLVideoElement).videoHeight || c.height;\n const v = live.current.view;\n const wide = (v.fov / 360) * sw;\n const tall = ((v.fov * (s.height / s.width)) / 180) * sh;\n const left = ((v.yaw - v.fov / 2 + 180) / 360) * sw;\n const top = ((90 - v.pitch) / 180) * sh - tall / 2;\n // Across the seam the window is two pieces of the picture side by side.\n for (const shift of [-sw, 0, sw]) {\n const a = Math.max(left + shift, 0);\n const b = Math.min(left + shift + wide, sw);\n if (b > a)\n ctx.drawImage(\n picture as CanvasImageSource,\n a,\n Math.max(top, 0),\n b - a,\n Math.min(tall, sh),\n ((a - (left + shift)) / wide) * w,\n 0,\n ((b - a) / wide) * w,\n h,\n );\n }\n return;\n }\n const r = renderer.current;\n if (!r) return;\n if (picture && dirtyPicture.current) {\n r.upload(picture);\n dirtyPicture.current = false;\n }\n r.draw(live.current.view, w, h);\n }, [pictureNow]);\n const schedule = React.useCallback(() => {\n if (frame.current === 0) frame.current = requestAnimationFrame(paint);\n }, [paint]);\n\n // The renderer: made once, restored if the context is lost, and the flat picture if there is none.\n React.useEffect(() => {\n const c = canvas.current;\n if (!c) return;\n const make = () => {\n renderer.current?.dispose();\n renderer.current = mode === \"flat\" ? null : createRenderer(c);\n setFlat(renderer.current === null);\n dirtyPicture.current = true;\n schedule();\n };\n make();\n const lost = (e: Event) => {\n e.preventDefault();\n renderer.current = null;\n };\n c.addEventListener(\"webglcontextlost\", lost);\n c.addEventListener(\"webglcontextrestored\", make);\n return () => {\n c.removeEventListener(\"webglcontextlost\", lost);\n c.removeEventListener(\"webglcontextrestored\", make);\n renderer.current?.dispose();\n renderer.current = null;\n if (frame.current) cancelAnimationFrame(frame.current);\n frame.current = 0;\n };\n }, [schedule, mode]);\n\n // A new still, a new size, a new view, or coming into view: draw.\n React.useEffect(() => {\n dirtyPicture.current = true;\n }, [still]);\n React.useEffect(() => {\n schedule();\n }, [schedule, view.yaw, view.pitch, view.fov, size.width, size.height, still, inView, flat]);\n\n // A video: each new frame is one upload and one draw.\n React.useEffect(() => {\n const v = video?.current;\n if (!v || !inView) return;\n let stopped = false;\n let handle = 0;\n const onFrame = () => {\n if (stopped) return;\n dirtyPicture.current = true;\n schedule();\n handle = v.requestVideoFrameCallback(onFrame);\n };\n if (typeof v.requestVideoFrameCallback === \"function\") {\n handle = v.requestVideoFrameCallback(onFrame);\n return () => {\n stopped = true;\n v.cancelVideoFrameCallback?.(handle);\n };\n }\n // No frame callback: the element's own events, and a frame loop while it plays.\n const touch = () => {\n dirtyPicture.current = true;\n schedule();\n };\n const events = [\"loadeddata\", \"seeked\", \"timeupdate\", \"play\", \"pause\"] as const;\n for (const e of events) v.addEventListener(e, touch);\n let loop = 0;\n const tick = () => {\n if (!v.paused) touch();\n loop = requestAnimationFrame(tick);\n };\n loop = requestAnimationFrame(tick);\n return () => {\n for (const e of events) v.removeEventListener(e, touch);\n cancelAnimationFrame(loop);\n };\n }, [video, inView, schedule]);\n\n // Pointer: drag turns the view with the pointer, two pointers pinch, a click that did not drag picks (`useViewPointers`).\n const hostRect = () => box.current!.getBoundingClientRect();\n const pointers = useViewPointers({\n ignore: (e) => e.button !== 0 && e.pointerType === \"mouse\",\n onDrag: (dx, dy) => {\n const v = live.current.view;\n const r = hostRect();\n // The picture follows the pointer: dragging right turns the view left.\n const per = degreesPerPixel(v, { width: r.width, height: r.height });\n change({ ...v, yaw: v.yaw - dx * per, pitch: v.pitch + dy * per });\n },\n onPinch: (ratio) => change({ ...live.current.view, fov: live.current.view.fov * ratio }),\n onTap: (e) => {\n if (!live.current.onPick) return;\n const r = hostRect();\n const s = { width: r.width, height: r.height };\n const x = e.clientX - r.left;\n const y = e.clientY - r.top;\n live.current.onPick(\n current.current.flat ? unprojectFlat(live.current.view, s, x, y) : unproject(live.current.view, s, x, y),\n );\n },\n });\n\n // The wheel zooms; native, because React's wheel listener is passive and the page must not scroll too.\n useWheelZoom(box, (factor) => change({ ...live.current.view, fov: live.current.view.fov * factor }), {\n enabled: wheelZoom,\n });\n\n const onKeyDown = (e: React.KeyboardEvent) => {\n const v = live.current.view;\n const turn = (v.fov / 12) * (e.shiftKey ? 3 : 1);\n if (e.key === \"ArrowLeft\") change({ ...v, yaw: v.yaw - turn });\n else if (e.key === \"ArrowRight\") change({ ...v, yaw: v.yaw + turn });\n else if (e.key === \"ArrowUp\") change({ ...v, pitch: v.pitch + turn });\n else if (e.key === \"ArrowDown\") change({ ...v, pitch: v.pitch - turn });\n else if (e.key === \"+\" || e.key === \"=\") change({ ...v, fov: v.fov * 0.8 });\n else if (e.key === \"-\" || e.key === \"_\") change({ ...v, fov: v.fov * 1.25 });\n else if (e.key === \"0\") change(defaultView);\n else return;\n e.preventDefault();\n };\n\n // Said in words: always on the picture; politely once the view has been still for a moment.\n const direction = describeView(view);\n const said = useSettledStatus(`${direction}, field of view ${Math.round(view.fov)}°`, STILL_MS);\n\n const api: PanoramaOverlayApi = {\n view,\n size,\n flat,\n project: (yaw, pitch) => (flat ? projectFlat(view, size, yaw, pitch) : project(view, size, yaw, pitch)),\n unproject: (x, y) => (flat ? unprojectFlat(view, size, x, y) : unproject(view, size, x, y)),\n };\n const slider = fovSlider ? (\n <Slider\n aria-label=\"Field of view\"\n value={Math.round(view.fov)}\n onChange={(fov) => change({ ...view, fov })}\n min={minFov}\n max={maxFov}\n step={1}\n unit=\"degree\"\n />\n ) : null;\n\n return (\n <div className={cn(\"grid min-w-0 gap-2\", className)}>\n <div\n ref={boxRef}\n role=\"group\"\n aria-label={label}\n aria-describedby={undefined}\n tabIndex={0}\n onKeyDown={onKeyDown}\n onPointerDown={pointers.onPointerDown}\n onPointerMove={pointers.onPointerMove}\n onPointerUp={pointers.onPointerUp}\n onPointerCancel={pointers.onPointerCancel}\n className=\"relative w-full cursor-grab touch-none overflow-hidden rounded-surface bg-surface-sunken select-none active:cursor-grabbing\"\n style={{ aspectRatio: aspect }}\n >\n <canvas\n key={mode === \"flat\" ? \"2d\" : \"gl\"}\n ref={canvas}\n role=\"img\"\n aria-label={`${label}. ${direction}, field of view ${Math.round(view.fov)}°`}\n className=\"absolute inset-0 size-full\"\n />\n {overlay && size.width > 0 && <div className=\"pointer-events-none absolute inset-0\">{overlay(api)}</div>}\n </div>\n {flat && (\n <p className=\"type-body-sm text-muted-foreground\">\n This browser cannot draw the 360 view, so the flat picture is shown. The controls work the same.\n </p>\n )}\n {slider}\n <VisuallyHidden>\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GAClB;EACb;;AAET"}
|
|
@@ -4,10 +4,11 @@ import { basename, extname, join, normalize, resolve, sep } from "node:path";
|
|
|
4
4
|
import { PNG } from "pngjs";
|
|
5
5
|
import { tmpdir } from "node:os";
|
|
6
6
|
import { createServer } from "node:http";
|
|
7
|
+
|
|
7
8
|
// src/visual/capture.ts
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
9
|
+
const COLOR_SCHEME_STORAGE_KEY = "strata-color-scheme";
|
|
10
|
+
const PICTURES_WAIT_MS = 15e3;
|
|
11
|
+
const freeze = `*, *::before, *::after { animation: none !important; transition: none !important; caret-color: transparent !important; }`;
|
|
11
12
|
/** Resolves a shot's path under the base URL, keeping the base's own path (`/app/` + `/review`). */
|
|
12
13
|
function resolveShotUrl(path, baseUrl) {
|
|
13
14
|
if (/^[a-z][a-z0-9+.-]*:/i.test(path)) return path;
|
|
@@ -348,13 +349,14 @@ function paintedBox({ root: selector, margin }) {
|
|
|
348
349
|
height: y1 - y0
|
|
349
350
|
};
|
|
350
351
|
}
|
|
352
|
+
|
|
351
353
|
// src/visual/compare.ts
|
|
352
354
|
/** Per-pixel colour distance pixelmatch treats as equal (0–1), measured after the blur. */
|
|
353
|
-
|
|
355
|
+
const THRESHOLD = .1;
|
|
354
356
|
/** Radius in pixels of the box blur applied to both images before comparing (1 is 3×3; 0 turns it off). */
|
|
355
|
-
|
|
357
|
+
const BLUR = 1;
|
|
356
358
|
/** Differing pixels (after the blur) tolerated before a screenshot counts as changed. */
|
|
357
|
-
|
|
359
|
+
const MAX_DIFF_PIXELS = 4;
|
|
358
360
|
/** Decodes a PNG file's bytes. */
|
|
359
361
|
function decode(buffer) {
|
|
360
362
|
return PNG.sync.read(Buffer.from(buffer));
|
|
@@ -454,8 +456,9 @@ function diffImage(expected, mask) {
|
|
|
454
456
|
}
|
|
455
457
|
return PNG.sync.write(png);
|
|
456
458
|
}
|
|
459
|
+
|
|
457
460
|
// src/visual/fonts.ts
|
|
458
|
-
|
|
461
|
+
const xml = (s) => s.replace(/[&<>"']/g, (c) => `&#${c.charCodeAt(0)};`);
|
|
459
462
|
/** Writes the fontconfig that pins `font` and returns what a launch needs. Throws when a file is missing. */
|
|
460
463
|
function pinSystemFont(font, cwd) {
|
|
461
464
|
if (!font.pin || !font.files.length) throw new Error("systemFonts.pin needs the family name and at least one font file");
|
|
@@ -492,8 +495,9 @@ function pinSystemFont(font, cwd) {
|
|
|
492
495
|
throw e;
|
|
493
496
|
}
|
|
494
497
|
}
|
|
498
|
+
|
|
495
499
|
// src/visual/serve.ts
|
|
496
|
-
|
|
500
|
+
const types = {
|
|
497
501
|
".html": "text/html",
|
|
498
502
|
".js": "text/javascript",
|
|
499
503
|
".mjs": "text/javascript",
|
|
@@ -567,13 +571,14 @@ async function serveStatic(dir, { spa = false, base = "/" } = {}) {
|
|
|
567
571
|
close: () => new Promise((r) => server.close(() => r()))
|
|
568
572
|
};
|
|
569
573
|
}
|
|
574
|
+
|
|
570
575
|
// src/visual/types.ts
|
|
571
576
|
/**
|
|
572
577
|
* Named viewports. `wide` and `phone` are what the Storybook tags `visual-wide` and
|
|
573
578
|
* `visual-phone` select; `default` is a laptop-sized screen for routes. (Untagged stories render
|
|
574
579
|
* 1024 wide and 200 tall and grow with the component, see {@link storybookShots}.)
|
|
575
580
|
*/
|
|
576
|
-
|
|
581
|
+
const viewports = {
|
|
577
582
|
default: {
|
|
578
583
|
width: 1024,
|
|
579
584
|
height: 768
|
|
@@ -587,10 +592,11 @@ var viewports = {
|
|
|
587
592
|
height: 844
|
|
588
593
|
}
|
|
589
594
|
};
|
|
595
|
+
|
|
590
596
|
// src/visual/targets.ts
|
|
591
597
|
/** The light and dark themes, the default for every target. */
|
|
592
|
-
|
|
593
|
-
|
|
598
|
+
const defaultThemes = ["light", "dark"];
|
|
599
|
+
const storyViewport = {
|
|
594
600
|
width: 1024,
|
|
595
601
|
height: 200
|
|
596
602
|
};
|
|
@@ -616,7 +622,7 @@ function storybookShots(target, themes = defaultThemes) {
|
|
|
616
622
|
}));
|
|
617
623
|
});
|
|
618
624
|
}
|
|
619
|
-
|
|
625
|
+
const slug = /^[a-z0-9]+(?:-[a-z0-9]+)*$/;
|
|
620
626
|
function viewportName(v) {
|
|
621
627
|
return typeof v === "string" ? v : `${v.width}x${v.height}`;
|
|
622
628
|
}
|
|
@@ -666,12 +672,13 @@ function routeShots(app, themes = defaultThemes) {
|
|
|
666
672
|
}
|
|
667
673
|
return shots;
|
|
668
674
|
}
|
|
675
|
+
|
|
669
676
|
// src/visual/run.ts
|
|
670
677
|
/** Returns the config unchanged; it exists so a config file is type-checked. */
|
|
671
678
|
function defineVisualConfig(config) {
|
|
672
679
|
return config;
|
|
673
680
|
}
|
|
674
|
-
|
|
681
|
+
const metaFile = ".strata-visual.json";
|
|
675
682
|
/** Screenshots every shot the config describes, compares with the baselines, and reports. */
|
|
676
683
|
async function runVisual(config, options = {}) {
|
|
677
684
|
const cwd = resolve(options.cwd ?? process.cwd());
|
|
@@ -875,7 +882,7 @@ function pinWarnings(cwd) {
|
|
|
875
882
|
};
|
|
876
883
|
return ["playwright", "@playwright/test"].filter((name) => deps[name] !== void 0 && !/^\d+\.\d+\.\d+$/.test(deps[name])).map((name) => `${name} is "${deps[name]}" in package.json: pin an exact version (npm install -D -E ${name}) so CI and the machine that wrote the baselines render with the same Chromium`);
|
|
877
884
|
}
|
|
878
|
-
|
|
885
|
+
const pixels = (line) => {
|
|
879
886
|
const m = /: (\d+) pixels differ[^,]*(?:, (\d+) without)?/.exec(line);
|
|
880
887
|
return Number(m?.[1] ?? 0) * 1e9 + Number(m?.[2] ?? 0);
|
|
881
888
|
};
|
|
@@ -894,6 +901,6 @@ function formatReport(report) {
|
|
|
894
901
|
if (report.failed) lines.push("", "Diffs are in the output folder (tests/visual/output by default). Look at them; if the change is intended, run with --update and commit the baselines.");
|
|
895
902
|
return lines.join("\n");
|
|
896
903
|
}
|
|
897
|
-
export { capture as _, defaultThemes as a, viewports as c, MAX_DIFF_PIXELS as d, THRESHOLD as f, encode as g, decode as h, runVisual as i, serveStatic as l, compare as m, formatReport as n, routeShots as o, boxBlur as p, pinWarnings as r, storybookShots as s, defineVisualConfig as t, BLUR as u, resolveShotUrl as v, toFetchRequest as y };
|
|
898
904
|
|
|
899
|
-
|
|
905
|
+
export { capture as _, defaultThemes as a, viewports as c, MAX_DIFF_PIXELS as d, THRESHOLD as f, encode as g, decode as h, runVisual as i, serveStatic as l, compare as m, formatReport as n, routeShots as o, boxBlur as p, pinWarnings as r, storybookShots as s, defineVisualConfig as t, BLUR as u, resolveShotUrl as v, toFetchRequest as y };
|
|
906
|
+
//# sourceMappingURL=run-D_Ic1jE7.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"run-D_Ic1jE7.js","names":[],"sources":["../src/visual/capture.ts","../src/visual/compare.ts","../src/visual/fonts.ts","../src/visual/serve.ts","../src/visual/types.ts","../src/visual/targets.ts","../src/visual/run.ts"],"sourcesContent":["// Taking one shot. Everything here is about determinism: a fresh browser context per shot so\n// shots cannot affect each other, reduced motion and frozen animations so the settled state is\n// what is captured, fonts awaited, the theme set both as the colour scheme and as the class the\n// app reads, the clock optionally frozen, and, for routes, every request the page makes answered\n// by MSW handlers in Node, so the screenshot depends on nothing outside the suite.\nimport type { Browser, BrowserContext, Page, Request as PlaywrightRequest, Route as PlaywrightRoute } from \"playwright\";\nimport type { RequestHandler } from \"msw\";\nimport type { Shot } from \"./types\";\n\n// Where ThemeProvider and colorSchemeScript() keep the preference (COLOR_SCHEME_STORAGE_KEY in components/theme.tsx; copied, not imported, so the runner loads no React).\nconst COLOR_SCHEME_STORAGE_KEY = \"strata-color-scheme\";\n\n// How long a whole-page shot waits for the pictures that have started loading (issue #331).\nconst PICTURES_WAIT_MS = 15_000;\n\n// Animations and transitions off, caret hidden: a screenshot is of the settled state.\nconst freeze = `*, *::before, *::after { animation: none !important; transition: none !important; caret-color: transparent !important; }`;\n\n/** Options shared by every shot of a run. */\nexport interface CaptureOptions {\n /** Where `shot.path` resolves, ending in `/`. */\n baseUrl: string;\n time?: string | number | Date;\n timezone?: string;\n locale?: string;\n /** Block service workers (an app's own MSW worker or PWA cache would bypass the handlers). */\n blockServiceWorkers?: boolean;\n onUnhandledRequest?: \"error\" | \"bypass\";\n /** Look up which faces drew the page's text and return the ones that are not web fonts. Default true. */\n checkFonts?: boolean;\n /** A family the runner pinned every system family to (`systemFonts: { pin }`): text drawn in it is deterministic, so it is not reported. */\n pinnedFamily?: string;\n /** Scroll a page taller than the window through before the shot, so pictures that wait until they are near the window have loaded (issue #273). Default true. */\n scrollThrough?: boolean;\n}\n\n/** What one shot produced. */\nexport interface Capture {\n png: Buffer;\n /** Page errors, console errors and unanswered requests. */\n problems: string[];\n /**\n * Text drawn in a font installed on this machine rather than one the page loaded, one line per\n * face with an example element, e.g. `\"DejaVu Sans\" in <kbd> \"⌘K\"`. Such text renders\n * differently on every machine, so the runner fails the shot (see {@link VisualConfig.systemFonts}).\n */\n systemFonts: string[];\n}\n\n/** Resolves a shot's path under the base URL, keeping the base's own path (`/app/` + `/review`). */\nexport function resolveShotUrl(path: string, baseUrl: string): string {\n if (/^[a-z][a-z0-9+.-]*:/i.test(path)) return path;\n return new URL(path.replace(/^\\/+/, \"\"), baseUrl).href;\n}\n\n/** Converts a request the page made into a Fetch `Request` MSW can match. */\nexport function toFetchRequest(\n request: Pick<PlaywrightRequest, \"url\" | \"method\" | \"headers\" | \"postDataBuffer\">,\n): Request {\n const method = request.method();\n const body = method === \"GET\" || method === \"HEAD\" ? undefined : (request.postDataBuffer() ?? undefined);\n return new Request(request.url(), {\n method,\n headers: request.headers(),\n body: body ? new Uint8Array(body) : undefined,\n });\n}\n\nasync function answerWithHandlers(\n context: BrowserContext,\n handlers: readonly RequestHandler[],\n baseUrl: string,\n unhandled: \"error\" | \"bypass\",\n problems: string[],\n) {\n const msw = await import(\"msw\").catch(() => {\n throw new Error(\"route shots with handlers need msw: npm install -D msw\");\n });\n const origin = new URL(baseUrl).origin;\n await context.route(\"**/*\", async (route: PlaywrightRoute) => {\n const request = route.request();\n const response = await msw.getResponse([...handlers], toFetchRequest(request), { baseUrl: origin, quiet: true });\n if (response && response.headers.get(\"x-msw-intention\") !== \"passthrough\") {\n const headers: Record<string, string> = {};\n response.headers.forEach((value, key) => (headers[key] = value));\n await route.fulfill({ status: response.status, headers, body: Buffer.from(await response.arrayBuffer()) });\n return;\n }\n if (\n !response &&\n unhandled === \"error\" &&\n [\"fetch\", \"xhr\", \"eventsource\", \"websocket\"].includes(request.resourceType())\n ) {\n const url = new URL(request.url());\n problems.push(\n `no handler for ${request.method()} ${url.origin === origin ? \"\" : url.origin}${url.pathname}${url.search}`,\n );\n }\n await route.continue();\n });\n}\n\n/** Takes one shot and returns its PNG, or throws with what went wrong. Page and console errors are returned as problems. */\nexport async function capture(browser: Browser, shot: Shot, options: CaptureOptions): Promise<Capture> {\n const context = await browser.newContext({\n viewport: shot.viewport,\n deviceScaleFactor: 1,\n reducedMotion: \"reduce\",\n colorScheme: shot.theme,\n timezoneId: options.timezone ?? \"UTC\",\n locale: options.locale ?? \"en-US\",\n serviceWorkers: options.blockServiceWorkers ? \"block\" : \"allow\",\n });\n const problems: string[] = [];\n try {\n if (options.time !== undefined) await context.clock.setFixedTime(options.time);\n // The theme the app's ThemeProvider reads before React runs (what `colorSchemeScript()` reads), so a shot's\n // theme reaches an app whose default preference is not \"system\" (issue #136). Failing storage is the app's no-op.\n await context.addInitScript(\n ({ key, theme }) => {\n try {\n localStorage.setItem(key, theme);\n } catch {}\n },\n { key: COLOR_SCHEME_STORAGE_KEY, theme: shot.theme },\n );\n if (shot.darkClass) {\n await context.addInitScript(\n ({ cls, dark }) => {\n const apply = () => document.documentElement?.classList.toggle(cls, dark);\n apply();\n document.addEventListener(\"DOMContentLoaded\", apply);\n },\n { cls: shot.darkClass, dark: shot.theme === \"dark\" },\n );\n }\n if (shot.handlers?.length || options.onUnhandledRequest === \"error\") {\n await answerWithHandlers(\n context,\n shot.handlers ?? [],\n options.baseUrl,\n options.onUnhandledRequest ?? \"bypass\",\n problems,\n );\n }\n const page = await context.newPage();\n page.on(\"pageerror\", (e) => problems.push(e.message));\n // A script or stylesheet that did not arrive makes a page that paints something else (an empty shell) and\n // still passes: it is a fault of the build or the server, so it fails the shot (issue #242).\n page.on(\"response\", (r) => {\n const type = r.request().resourceType();\n if (type !== \"script\" && type !== \"stylesheet\") return;\n const html = (r.headers()[\"content-type\"] ?? \"\").includes(\"text/html\");\n if (r.status() >= 400 || html)\n problems.push(\n `${type} ${new URL(r.url()).pathname} ${html ? \"came back as HTML (a fallback page)\" : `failed with ${r.status()}`}`,\n );\n });\n // Error responses a state serves on purpose (4xx/5xx) are logged by Chromium; not a fault.\n page.on(\"console\", (m) => {\n if (m.type() === \"error\" && !m.text().startsWith(\"Failed to load resource\")) problems.push(m.text());\n });\n await page.goto(resolveShotUrl(shot.path, options.baseUrl), { waitUntil: \"load\" });\n await page.addStyleTag({ content: freeze });\n await page\n .waitForFunction((root) => (document.querySelector(root)?.childElementCount ?? 0) > 0, shot.root, {\n timeout: 15_000,\n })\n .catch(() => {\n throw new Error(`${shot.root} stayed empty for 15s`);\n });\n if (shot.waitFor) await page.locator(shot.waitFor).first().waitFor({ state: \"visible\", timeout: 15_000 });\n await settle(page);\n // Only a whole-page shot: a component's shot is of its own box, and scrolling a story moved virtualised lists on (their shots got shorter).\n const lazy = options.scrollThrough !== false && shot.clip === \"page\";\n if (lazy) await scrollThrough(page, problems);\n if (shot.setup) {\n await shot.setup(page, shot);\n await settle(page);\n if (lazy) await scrollThrough(page, problems);\n }\n let png: Buffer;\n if (shot.clip === \"page\") {\n png = await stable(page, () => page.screenshot({ fullPage: true, animations: \"disabled\" }));\n } else {\n const clip = await page.evaluate(paintedBox, { root: shot.root, margin: 8 });\n if (!clip) throw new Error(\"rendered nothing visible\");\n png = await stable(page, () => page.screenshot({ fullPage: true, clip, animations: \"disabled\" }));\n }\n const systemFonts = options.checkFonts === false ? [] : await platformFonts(page, options.pinnedFamily);\n return { png, problems, systemFonts };\n } finally {\n await context.close();\n }\n}\n\n/**\n * A picture that two shots in a row agree on. The DOM being complete is not the picture being: with a\n * dozen shots running at once the compositor can present a frame before it has rasterised a layer, and\n * a map's pins (all in the DOM, visible, opacity 1) were missing from the PNG in about one run in ten\n * (the flaky RouteMap shots; a pixel read at each pin's centre gave the map's background). A second\n * shot a moment later has them. So a shot is taken again until two in a row are the same, at most\n * five times, with a longer wait each time and two animation frames before each (not reproduced again locally\n * in 5 runs at 12 pages under full CPU load, so this is the same mechanism made harder to miss, not a proven cure); a page that never stops changing gives the last one and the comparison decides.\n */\nasync function stable(page: Page, take: () => Promise<Buffer>): Promise<Buffer> {\n // Two frames through requestAnimationFrame make the compositor present what the DOM has before each shot; the wait\n // between shots doubles (100, 200, 400, 800 ms), so a compositor that lags more than the first gap still gets agreed on late.\n const frames = () =>\n page.evaluate(() => new Promise<void>((done) => requestAnimationFrame(() => requestAnimationFrame(() => done()))));\n await frames();\n let last = await take();\n for (let i = 0; i < 4; i++) {\n await new Promise((done) => setTimeout(done, 100 * 2 ** i));\n await frames();\n const next = await take();\n if (next.equals(last)) return next;\n last = next;\n }\n return last;\n}\n\n/**\n * A whole-page shot shows what a person would see after scrolling, so a picture that waits until it is near the\n * window (`Thumbnail`, `InfiniteList`'s next page) has to have been near it (issue #273). A page taller than the\n * window is shown to the page as a window as tall as itself (a few times over, in case what loads makes it taller),\n * the pictures that started loading are waited for, and the window goes back to its size. Not a scroll: scrolling\n * moved fixed elements (an undo bar) off where the shot has always drawn them, a window as tall as the page does not.\n *\n * The wait for the pictures is up to 15 s, not 3: on a loaded CI runner 18 small SVGs answered by MSW in Node took\n * longer than 3 s, the wait gave up without a word, and `stable()` then agreed with itself on two shots of\n * skeletons (their pulse is frozen, so nothing changed between them), which compared against a baseline of pictures\n * (issue #331). A wait that still runs out is now a problem on the shot, with the count and the first sources, so\n * the failure names its cause. A picture that is held open on purpose in a whole-page shot is reported the same way;\n * turn `scrollThrough` off for that run.\n */\nasync function scrollThrough(page: Page, problems: string[]) {\n const size = page.viewportSize();\n if (!size) return;\n let grew = false;\n for (let i = 0; i < 3; i++) {\n const height = await page.evaluate(() => document.documentElement.scrollHeight);\n if (height <= size.height + 1) break;\n grew = true;\n // Bounded: a page that grows as it is shown (an endless feed) is read to 20000 px and no further.\n await page.setViewportSize({ width: size.width, height: Math.min(height, 20_000) });\n await page.waitForTimeout(100);\n }\n // Also for a page that fits the window: the loop above never ran its wait, and settle()'s network-idle wait is shorter.\n await page\n .waitForFunction(() => [...document.images].every((img) => img.complete), undefined, { timeout: PICTURES_WAIT_MS })\n .catch(() => undefined);\n const late = await page.evaluate(() =>\n [...document.images].filter((img) => !img.complete).map((img) => img.currentSrc || img.src),\n );\n if (late.length) {\n const shown = late.slice(0, 3).map((src) => new URL(src, \"http://x\").pathname);\n problems.push(\n `${late.length} ${late.length === 1 ? \"picture\" : \"pictures\"} had not loaded after ${PICTURES_WAIT_MS / 1000}s (${shown.join(\", \")}${late.length > 3 ? \", …\" : \"\"})`,\n );\n }\n if (!grew) return;\n await page.setViewportSize(size);\n await settle(page);\n}\n\nasync function settle(page: Page) {\n // A state that is meant to stay loading keeps a request open, so networkidle may not come.\n await page.waitForLoadState(\"networkidle\", { timeout: 3_000 }).catch(() => undefined);\n await page.evaluate(() => document.fonts.ready.then(() => undefined));\n // A paused video shows its first frame once decoded; without this a shot is taken before or after, depending on the machine.\n await page\n .waitForFunction(\n () => [...document.querySelectorAll(\"video\")].every((v) => v.readyState >= 2 || v.error !== null),\n undefined,\n { timeout: 5_000 },\n )\n .catch(() => undefined);\n // Decoded is not painted: on a loaded runner Chromium can hold a decoded first frame back from the\n // compositor, and a shot then shows an empty cell for good (it stays empty for seconds; this was the\n // flaky CompareVideoGrid shots). A seek to the time a video is already at presents a fresh frame, and\n // its callback says when it was handed to the compositor, so each shot waits for that, per video.\n await page\n .evaluate(() =>\n Promise.all(\n [...document.querySelectorAll(\"video\")]\n .filter((v) => v.readyState >= 2 && !v.error && \"requestVideoFrameCallback\" in v)\n .map(\n (v) =>\n new Promise<void>((done) => {\n const stop = window.setTimeout(done, 2_000);\n v.requestVideoFrameCallback(() => {\n window.clearTimeout(stop);\n done();\n });\n // Seeking to the same time is what forces a frame to be painted; it is not a typo.\n // oxlint-disable-next-line eslint/no-self-assign\n v.currentTime = v.currentTime;\n }),\n ),\n ),\n )\n .catch(() => undefined);\n await page.waitForTimeout(250);\n}\n\n// Which faces drew the text. Chromium's DevTools protocol reports, per element, the font files\n// that actually painted its glyphs and whether each came from the page (@font-face) or from the\n// machine. A system face is the largest source of machine-to-machine difference left once the\n// browser is pinned: the same `ui-sans-serif` is Cantarell on one Linux, DejaVu on another and\n// San Francisco on a Mac, and a glyph missing from a web font (an arrow, ⌘) falls back to\n// whatever the machine has. So the shot reports it rather than tolerating it in the comparison.\nasync function platformFonts(page: Page, pinned?: string): Promise<string[]> {\n const cdp = await page.context().newCDPSession(page);\n try {\n await cdp.send(\"DOM.enable\");\n await cdp.send(\"CSS.enable\");\n const { root } = await cdp.send(\"DOM.getDocument\", { depth: -1, pierce: true });\n type DomNode = {\n nodeId: number;\n nodeType: number;\n nodeName: string;\n nodeValue: string;\n pseudoType?: string;\n children?: DomNode[];\n shadowRoots?: DomNode[];\n pseudoElements?: DomNode[];\n contentDocument?: DomNode;\n };\n const texts: { id: number; name: string; text: string }[] = [];\n const walk = (n: DomNode) => {\n if (n.nodeName === \"SCRIPT\" || n.nodeName === \"STYLE\" || n.nodeName === \"HEAD\") return;\n const own = n.children?.filter((c) => c.nodeType === 3 && c.nodeValue.trim()) ?? [];\n if (n.nodeType === 1 && own.length)\n texts.push({\n id: n.nodeId,\n name: n.nodeName.toLowerCase(),\n text: own.map((c) => c.nodeValue.trim()).join(\" \"),\n });\n // Generated content (`::before { content: \"⌘\" }`) draws text too; it has no text child.\n for (const p of n.pseudoElements ?? [])\n texts.push({ id: p.nodeId, name: `${n.nodeName.toLowerCase()}::${p.pseudoType ?? \"pseudo\"}`, text: \"\" });\n for (const c of [\n ...(n.children ?? []),\n ...(n.shadowRoots ?? []),\n ...(n.contentDocument ? [n.contentDocument] : []),\n ])\n walk(c);\n };\n walk(root as DomNode);\n const found = new Map<string, string>();\n for (const t of texts) {\n // A node that is not rendered (display: none) has no fonts and is skipped by Chromium.\n const { fonts } = await cdp.send(\"CSS.getPlatformFontsForNode\", { nodeId: t.id }).catch(() => ({ fonts: [] }));\n for (const f of fonts) {\n if (f.isCustomFont || f.familyName === pinned || found.has(f.familyName)) continue;\n const text = t.text.length > 30 ? `${t.text.slice(0, 29)}…` : t.text;\n // The CSS stack that fell through to the machine, so a `--font-mono` that names a face the app did not import is\n // recognisable as such (issue #136): the glyph or the whole stack was missing from the bundled faces.\n const { computedStyle } = await cdp\n .send(\"CSS.getComputedStyleForNode\", { nodeId: t.id })\n .catch(() => ({ computedStyle: [] }));\n const stack = computedStyle.find((p) => p.name === \"font-family\")?.value;\n found.set(\n f.familyName,\n `\"${f.familyName}\" in <${t.name}>${text ? ` \"${text}\"` : \"\"}${stack ? ` (font-family: ${stack})` : \"\"}`,\n );\n }\n }\n return [...found.values()];\n } finally {\n await cdp.detach().catch(() => undefined);\n }\n}\n\n// Runs in the page. The box around what the root actually paints: text, replaced and form\n// elements, SVGs, and any box with a background, border or shadow, each cut to the scroll\n// containers it sits in. So a row of buttons is cropped to the buttons, not the full-width div\n// holding them, and fixed elements (an undo bar) count wherever they are. Portalled overlays\n// (children of the body outside the root) count too, so an open dialog or popover is in its shot. The screenshot is\n// fullPage, so the box may extend past the viewport and a large component is captured whole.\nfunction paintedBox({ root: selector, margin }: { root: string; margin: number }) {\n const root = document.querySelector(selector);\n if (!root) return null;\n const replaced = new Set([\"IMG\", \"INPUT\", \"SELECT\", \"TEXTAREA\", \"CANVAS\", \"VIDEO\", \"svg\", \"HR\"]);\n const transparent = (c: string) => c === \"transparent\" || /rgba\\(.*,\\s*0\\)$/.test(c) || /\\/\\s*0\\)$/.test(c);\n const paints = (el: Element) => {\n const cs = getComputedStyle(el);\n if (replaced.has(el.tagName)) return true;\n if (!transparent(cs.backgroundColor) || cs.backgroundImage !== \"none\" || cs.boxShadow !== \"none\") return true;\n return ([\"Top\", \"Right\", \"Bottom\", \"Left\"] as const).some(\n (s) => parseFloat(cs[`border${s}Width`]) > 0 && cs[`border${s}Style`] !== \"none\",\n );\n };\n const clipTo = (r: DOMRect, el: Node) => {\n let { left, top, right, bottom } = r;\n for (let a = el.parentElement; a && a !== document.body; a = a.parentElement) {\n const cs = getComputedStyle(a);\n if (cs.overflowX !== \"visible\" || cs.overflowY !== \"visible\" || cs.clipPath !== \"none\" || cs.clip !== \"auto\") {\n const b = a.getBoundingClientRect();\n left = Math.max(left, b.left);\n top = Math.max(top, b.top);\n right = Math.min(right, b.right);\n bottom = Math.min(bottom, b.bottom);\n }\n if (cs.position === \"fixed\") break;\n }\n return right - left > 1 && bottom - top > 1 ? { left, top, right, bottom } : null;\n };\n const rects: { left: number; top: number; right: number; bottom: number }[] = [];\n // Overlays (dialogs, popovers, tooltips, menus) are portalled to the body, outside the root, so\n // the walk covers the root and every other element the body holds besides scripts and styles.\n const roots: Element[] = [\n root,\n ...[...document.body.children].filter(\n (c) => !c.contains(root) && ![\"SCRIPT\", \"STYLE\", \"LINK\", \"TEMPLATE\"].includes(c.tagName),\n ),\n ];\n const nodes: Node[] = [];\n for (const r of roots) {\n const walker = document.createTreeWalker(r, NodeFilter.SHOW_ELEMENT | NodeFilter.SHOW_TEXT);\n for (let n = walker.nextNode(); n; n = walker.nextNode()) nodes.push(n);\n }\n for (const n of nodes) {\n if (n.nodeType === Node.TEXT_NODE) {\n if (!n.textContent?.trim() || !n.parentElement) continue;\n const range = document.createRange();\n range.selectNodeContents(n);\n for (const r of range.getClientRects()) {\n // From the text node itself, so its own element's clip counts too (an sr-only span is a\n // 1px clipped box, and its text paints nothing).\n const c = clipTo(r, n);\n if (c) rects.push(c);\n }\n continue;\n }\n const el = n as Element;\n if (el.closest(\"svg\") && el.tagName !== \"svg\") continue;\n if (getComputedStyle(el).visibility === \"hidden\" || !paints(el)) continue;\n const c = clipTo(el.getBoundingClientRect(), el);\n if (c) rects.push(c);\n }\n if (!rects.length) return null;\n const x0 = Math.max(0, Math.floor(Math.min(...rects.map((r) => r.left)) + scrollX - margin));\n const y0 = Math.max(0, Math.floor(Math.min(...rects.map((r) => r.top)) + scrollY - margin));\n const x1 = Math.min(\n document.documentElement.scrollWidth,\n Math.ceil(Math.max(...rects.map((r) => r.right)) + scrollX + margin),\n );\n const y1 = Math.min(\n document.documentElement.scrollHeight,\n Math.ceil(Math.max(...rects.map((r) => r.bottom)) + scrollY + margin),\n );\n return { x: x0, y: y0, width: x1 - x0, height: y1 - y0 };\n}\n","// PNG decode and pixelmatch comparison, kept apart from the browser so it is unit tested without\n// one. The defaults are the ones every Strata suite uses, so a baseline means the same thing in\n// the library and in an app; a config can change them (`VisualConfig.compare`).\n//\n// Why blur first. Two machines running the same Chromium still rasterise edges a little\n// differently (GPU or CPU raster, SIMD paths, a newer Skia): the coverage of an edge pixel moves\n// to its neighbour, so plain pixelmatch sees a scatter of differing pixels along every edge and\n// glyph. Experiments on Strata's 218 shots (CHANGELOG, 2026-11-07) found that noise reached 159\n// pixels at threshold 0.1 under GPU raster, more than one changed letter makes (10 to 50 pixels),\n// so no pixel allowance could tell the two apart. Averaging each pixel with its 3×3 neighbours\n// before comparing keeps the ink an edge or glyph lays down and drops where exactly it fell: the\n// same noise then came to at most 1 pixel, while a changed letter, a weight step, a 1px shift or a\n// colour change still differed by tens to thousands. A size change is always a change (the layout\n// moved).\nimport pixelmatch from \"pixelmatch\";\nimport { PNG } from \"pngjs\";\n\n/** Per-pixel colour distance pixelmatch treats as equal (0–1), measured after the blur. */\nexport const THRESHOLD = 0.1;\n/** Radius in pixels of the box blur applied to both images before comparing (1 is 3×3; 0 turns it off). */\nexport const BLUR = 1;\n/** Differing pixels (after the blur) tolerated before a screenshot counts as changed. */\nexport const MAX_DIFF_PIXELS = 4;\n\n/** How two screenshots are compared. Every field has the default above. */\nexport interface CompareOptions {\n /** Per-pixel colour distance treated as equal, 0–1 (pixelmatch's `threshold`). Default {@link THRESHOLD}. */\n threshold?: number;\n /** Box blur radius in whole pixels applied to both images first, absorbing anti-aliasing differences (0 turns it off). Default {@link BLUR}. */\n blur?: number;\n /** Differing pixels tolerated. Default {@link MAX_DIFF_PIXELS}. */\n maxDiffPixels?: number;\n /** Count pixels pixelmatch judges to be anti-aliasing as differences too. Default false. */\n includeAA?: boolean;\n}\n\n/** A decoded RGBA image. */\nexport interface Image {\n width: number;\n height: number;\n data: Uint8Array;\n}\n\n/** The result of comparing a screenshot with its baseline. */\nexport interface CompareResult {\n /** Within tolerance: the screenshot matches. */\n same: boolean;\n /** Every pixel is identical, before any blur or threshold. */\n identical: boolean;\n /** Pixels that differ beyond the threshold after the blur (Infinity when the size changed). */\n diffPixels: number;\n /** The same count without the blur: how much anti-aliasing the blur absorbed. */\n unblurredDiffPixels: number;\n /** One line for a report: what changed. */\n reason: string;\n /** A PNG highlighting the differing pixels in red over the faded baseline, when the images differ in content. */\n diff?: Buffer;\n}\n\n/** Decodes a PNG file's bytes. */\nexport function decode(buffer: Buffer | Uint8Array): Image {\n return PNG.sync.read(Buffer.from(buffer));\n}\n\n/** Encodes an RGBA image as PNG bytes. */\nexport function encode({ width, height, data }: Image): Buffer {\n const png = new PNG({ width, height });\n png.data = Buffer.from(data);\n return PNG.sync.write(png);\n}\n\n/** Box-blurs an RGBA image with the given radius (separable, edges averaged over what exists). */\nexport function boxBlur({ width: w, height: h, data }: Image, radius: number): Uint8Array {\n if (!Number.isInteger(radius) || radius < 0)\n throw new Error(`blur must be a whole number of pixels, 0 or more (got ${radius})`);\n if (radius === 0) return data;\n const pass = (src: ArrayLike<number>, horizontal: boolean) => {\n const out = new Float32Array(src.length);\n const [outer, inner] = horizontal ? [h, w] : [w, h];\n for (let o = 0; o < outer; o++) {\n for (let c = 0; c < 4; c++) {\n const at = (i: number) => ((horizontal ? o * w + i : i * w + o) << 2) + c;\n // Running sum over the window, so the cost does not grow with the radius.\n let sum = 0;\n for (let i = 0; i <= Math.min(radius, inner - 1); i++) sum += src[at(i)];\n for (let i = 0; i < inner; i++) {\n const lo = Math.max(0, i - radius);\n const hi = Math.min(inner - 1, i + radius);\n out[at(i)] = sum / (hi - lo + 1);\n if (i + radius + 1 < inner) sum += src[at(i + radius + 1)];\n if (i - radius >= 0) sum -= src[at(i - radius)];\n }\n }\n }\n return out;\n };\n const blurred = pass(pass(data, true), false);\n const out = new Uint8Array(blurred.length);\n for (let i = 0; i < blurred.length; i++) out[i] = Math.round(blurred[i]);\n return out;\n}\n\nfunction sameBytes(a: Uint8Array, b: Uint8Array) {\n return (\n a.length === b.length &&\n Buffer.compare(\n Buffer.from(a.buffer, a.byteOffset, a.byteLength),\n Buffer.from(b.buffer, b.byteOffset, b.byteLength),\n ) === 0\n );\n}\n\n/** Compares two decoded PNGs with pixelmatch after a small blur. A size change is always a change. */\nexport function compare(expected: Image, actual: Image, options: CompareOptions = {}): CompareResult {\n const { threshold = THRESHOLD, blur = BLUR, maxDiffPixels = MAX_DIFF_PIXELS, includeAA = false } = options;\n if (expected.width !== actual.width || expected.height !== actual.height) {\n return {\n same: false,\n identical: false,\n diffPixels: Number.POSITIVE_INFINITY,\n unblurredDiffPixels: Number.POSITIVE_INFINITY,\n reason: `size ${expected.width}×${expected.height} → ${actual.width}×${actual.height}`,\n };\n }\n const { width, height } = expected;\n if (sameBytes(expected.data, actual.data))\n return { same: true, identical: true, diffPixels: 0, unblurredDiffPixels: 0, reason: \"identical\" };\n const mask = new Uint8Array(width * height * 4);\n const diffPixels = pixelmatch(boxBlur(expected, blur), boxBlur(actual, blur), mask, width, height, {\n threshold,\n includeAA,\n diffMask: true,\n });\n const unblurredDiffPixels =\n blur > 0 ? pixelmatch(expected.data, actual.data, null, width, height, { threshold, includeAA }) : diffPixels;\n const same = diffPixels <= maxDiffPixels;\n return {\n same,\n identical: false,\n diffPixels,\n unblurredDiffPixels,\n reason: `${diffPixels} pixels differ (${((diffPixels / (width * height)) * 100).toFixed(3)}%)${blur > 0 ? `, ${unblurredDiffPixels} without the blur` : \"\"}`,\n diff: same ? undefined : diffImage(expected, mask),\n };\n}\n\n// The baseline faded to grey, with the pixels that differ (pixelmatch's red mask) on top: the\n// mask was computed on blurred images, so it is drawn over the sharp baseline to stay readable.\nfunction diffImage(expected: Image, mask: Uint8Array): Buffer {\n const png = new PNG({ width: expected.width, height: expected.height });\n const d = expected.data;\n for (let i = 0; i < d.length; i += 4) {\n if (mask[i + 3] > 0 && mask[i] === 255 && mask[i + 1] === 0) {\n png.data[i] = 255;\n png.data[i + 1] = 0;\n png.data[i + 2] = 0;\n } else {\n const grey = 255 + ((0.299 * d[i] + 0.587 * d[i + 1] + 0.114 * d[i + 2] - 255) * 0.1 * d[i + 3]) / 255;\n png.data[i] = png.data[i + 1] = png.data[i + 2] = grey;\n }\n png.data[i + 3] = 255;\n }\n return PNG.sync.write(png);\n}\n","// Pinning the face a page's system fonts resolve to (issue #342). An app on a home server may\n// choose `system-ui` on purpose so a page never waits on a font download, and then `systemFonts:\n// \"allow\"` was the only way to take a baseline: it drew whichever face the machine resolved\n// `system-ui` to (DejaVu Sans on CI, Inter or Cantarell on a developer's machine), and every text\n// diff failed. The runner now gives Chromium a fontconfig file of its own, whose only font\n// directory holds the files the config names and which answers every family the page asks for\n// (`system-ui`, `sans-serif`, `ui-monospace`, a name nothing has) with the pinned family. Checked\n// against Chromium's own report of the faces that painted text: with and without the file,\n// `system-ui` was \"Inter\" and became \"DejaVu Sans\", `sans-serif` \"Liberation Sans\" → \"DejaVu Sans\",\n// `monospace` \"DejaVu Sans Mono\" → \"DejaVu Sans\". Nothing is shipped to users: the files are the\n// runner's, not the page's.\n//\n// Linux only: macOS and Windows resolve system-ui through the platform, not fontconfig. A run there\n// says so and reports system fonts as warnings; baselines are recorded where CI runs them.\nimport { copyFileSync, existsSync, mkdirSync, mkdtempSync, rmSync, writeFileSync } from \"node:fs\";\nimport { tmpdir } from \"node:os\";\nimport { basename, join, resolve } from \"node:path\";\n\n/** A system face to pin, from `VisualConfig.systemFonts`. */\nexport interface PinnedSystemFont {\n /** The family name inside the font files, e.g. `\"DejaVu Sans\"`. Every system family the page uses resolves to it. */\n pin: string;\n /** Font files (`.ttf`, `.otf`) holding that family, relative to the config file: the regular face and any bold or italic the page uses. */\n files: readonly string[];\n}\n\n/** A pinned face made ready for a launch. */\nexport interface PinnedFonts {\n /** Environment for Chromium: points fontconfig at the generated file. */\n env: Record<string, string>;\n /** The family that now stands for every system family; text drawn in it is not a system-font fault. */\n family: string;\n /** Removes the generated folder. */\n dispose(): void;\n}\n\nconst xml = (s: string) => s.replace(/[&<>\"']/g, (c) => `&#${c.charCodeAt(0)};`);\n\n/** Writes the fontconfig that pins `font` and returns what a launch needs. Throws when a file is missing. */\nexport function pinSystemFont(font: PinnedSystemFont, cwd: string): PinnedFonts {\n if (!font.pin || !font.files.length)\n throw new Error(\"systemFonts.pin needs the family name and at least one font file\");\n const dir = mkdtempSync(join(tmpdir(), \"strata-visual-fonts-\"));\n try {\n const fonts = join(dir, \"fonts\");\n mkdirSync(fonts);\n for (const file of font.files) {\n const from = resolve(cwd, file);\n if (!existsSync(from)) throw new Error(`systemFonts.pin: ${from} not found`);\n copyFileSync(from, join(fonts, basename(from)));\n }\n // The one `<dir>` is the copy, so nothing else on the machine is a candidate; the match rewrites\n // any family asked for to the pinned one, which is how the generic names reach it.\n writeFileSync(\n join(dir, \"fonts.conf\"),\n `<?xml version=\"1.0\"?>\n<!DOCTYPE fontconfig SYSTEM \"fonts.dtd\">\n<fontconfig>\n <dir>${xml(fonts)}</dir>\n <cachedir>${xml(join(dir, \"cache\"))}</cachedir>\n <match target=\"pattern\"><edit name=\"family\" mode=\"assign_replace\"><string>${xml(font.pin)}</string></edit></match>\n</fontconfig>\n`,\n );\n return {\n env: { FONTCONFIG_FILE: join(dir, \"fonts.conf\") },\n family: font.pin,\n dispose: () => rmSync(dir, { recursive: true, force: true }),\n };\n } catch (e) {\n rmSync(dir, { recursive: true, force: true });\n throw e;\n }\n}\n","// A static file server for a build folder, on a free local port. Storybook needs nothing more;\n// an app's build also needs history fallback (a request for /review that asks for HTML gets\n// index.html, as a host like Pages or Netlify would serve it) and its Vite `base`. Requests that\n// do not ask for HTML are never given index.html, so a missed API route fails loudly as a 404\n// instead of a JSON parse error.\n//\n// An app built with a relative Vite `base: './'` (python-app-template, for reverse proxies) gets a\n// `<base href>` back to its root from its own server in production. A plain file server does not,\n// so `/books/1` would ask for `/books/assets/index.js` and paint an empty page (issue #242). In\n// spa mode the index.html this server sends therefore gets `<base href=\"{prefix}\">` unless it\n// already has a base tag, which is what the app's server does for it.\nimport { createServer } from \"node:http\";\nimport { createReadStream, existsSync, readFileSync, statSync } from \"node:fs\";\nimport { basename, extname, join, normalize, resolve, sep } from \"node:path\";\n\nconst types: Record<string, string> = {\n \".html\": \"text/html\",\n \".js\": \"text/javascript\",\n \".mjs\": \"text/javascript\",\n \".css\": \"text/css\",\n \".json\": \"application/json\",\n \".map\": \"application/json\",\n \".webmanifest\": \"application/manifest+json\",\n \".svg\": \"image/svg+xml\",\n \".png\": \"image/png\",\n \".jpg\": \"image/jpeg\",\n \".jpeg\": \"image/jpeg\",\n \".webp\": \"image/webp\",\n \".avif\": \"image/avif\",\n \".gif\": \"image/gif\",\n \".ico\": \"image/x-icon\",\n \".woff2\": \"font/woff2\",\n \".woff\": \"font/woff\",\n \".ttf\": \"font/ttf\",\n \".txt\": \"text/plain\",\n \".wasm\": \"application/wasm\",\n};\n\n/** A running server: its origin plus base, and how to stop it. */\nexport interface StaticServer {\n /** e.g. `http://127.0.0.1:53121/app/` (always ends in `/`). */\n url: string;\n close(): Promise<void>;\n}\n\n/** The page with `<base href=\"{href}\">` first in its head, unless it already has a base tag. */\nexport function withBaseTag(html: string, href: string): string {\n if (/<base[\\s>]/i.test(html)) return html;\n const tag = `<base href=\"${href}\">`;\n return /<head[^>]*>/i.test(html) ? html.replace(/<head[^>]*>/i, (m) => `${m}${tag}`) : `${tag}${html}`;\n}\n\n/** Serves `dir` on 127.0.0.1 under `base`, with history fallback to `index.html` when `spa` is set. */\nexport async function serveStatic(\n dir: string,\n { spa = false, base = \"/\" }: { spa?: boolean; base?: string } = {},\n): Promise<StaticServer> {\n const root = resolve(dir);\n const prefix = `/${base.replace(/^\\/+|\\/+$/g, \"\")}/`.replace(/^\\/\\/$/, \"/\");\n const server = createServer((req, res) => {\n const pathname = decodeURIComponent(new URL(req.url ?? \"/\", \"http://x\").pathname);\n if (!pathname.startsWith(prefix) && `${pathname}/` !== prefix) {\n res.writeHead(404).end();\n return;\n }\n const rel = normalize(pathname.slice(prefix.length)).replace(/^([/\\\\])+/, \"\");\n let file = join(root, rel || \"index.html\");\n if (file !== root && !file.startsWith(root + sep)) {\n res.writeHead(404).end();\n return;\n }\n if (existsSync(file) && statSync(file).isDirectory()) file = join(file, \"index.html\");\n if (!existsSync(file)) {\n const wantsHtml = (req.headers.accept ?? \"\").includes(\"text/html\");\n if (!spa || !wantsHtml || !existsSync(join(root, \"index.html\"))) {\n res.writeHead(404).end();\n return;\n }\n file = join(root, \"index.html\");\n }\n if (spa && extname(file) === \".html\" && basename(file) === \"index.html\") {\n const html = withBaseTag(readFileSync(file, \"utf8\"), prefix);\n res.writeHead(200, { \"Content-Type\": \"text/html\", \"Service-Worker-Allowed\": \"/\" }).end(html);\n return;\n }\n res.writeHead(200, {\n \"Content-Type\": types[extname(file)] ?? \"application/octet-stream\",\n \"Service-Worker-Allowed\": \"/\",\n });\n createReadStream(file).pipe(res);\n });\n await new Promise<void>((r) => server.listen(0, \"127.0.0.1\", r));\n const address = server.address();\n const port = typeof address === \"object\" && address ? address.port : 0;\n return {\n url: `http://127.0.0.1:${port}${prefix}`,\n close: () => new Promise((r) => server.close(() => r())),\n };\n}\n","// The shapes a visual suite is written in. One Shot is one PNG: a URL, a theme, a viewport, how to\n// tell it has rendered, and what to cut out. Storybook stories and app routes are both turned into\n// shots, so capture, comparison and baselines are the same code for a component library and for\n// an app's screens (strata-react issue #13).\nimport type { PinnedSystemFont } from \"./fonts\";\nimport type { Page } from \"playwright\";\nimport type { RequestHandler } from \"msw\";\nimport type { CompareOptions } from \"./compare\";\n\n/** The two colour schemes every shot is taken in. */\nexport type Theme = \"light\" | \"dark\";\n\n/** A viewport in CSS pixels. Screenshots are taken at a device scale factor of 1. */\nexport interface Viewport {\n width: number;\n height: number;\n}\n\n/** A named viewport (see {@link viewports}) or an explicit size. */\nexport type ViewportChoice = keyof typeof viewports | Viewport;\n\n/**\n * Named viewports. `wide` and `phone` are what the Storybook tags `visual-wide` and\n * `visual-phone` select; `default` is a laptop-sized screen for routes. (Untagged stories render\n * 1024 wide and 200 tall and grow with the component, see {@link storybookShots}.)\n */\nexport const viewports = {\n default: { width: 1024, height: 768 },\n wide: { width: 1440, height: 900 },\n phone: { width: 390, height: 844 },\n} as const satisfies Record<string, Viewport>;\n\n/**\n * What a screenshot covers. `paint` is the union of what the root element paints (text,\n * controls, SVGs, and boxes with a background, border or shadow) plus 8px, so a component's\n * baseline shows the component and not the empty canvas. `page` is the whole page, for screens.\n */\nexport type Clip = \"paint\" | \"page\";\n\n/** A step run after a shot has rendered and before it is captured: open a menu, focus a field. */\nexport type Setup = (page: Page, shot: Shot) => Promise<void> | void;\n\n/** One screenshot: everything the runner needs to take it and to name its baseline. */\nexport interface Shot {\n /** The baseline's file name without `.png`, e.g. `review--empty--wide--dark`. */\n name: string;\n /** Path and query under the served base (`/review?tab=queue`), or an absolute URL. */\n path: string;\n theme: Theme;\n viewport: Viewport;\n /** Selector of the element the app renders into; the shot waits until it has children. */\n root: string;\n clip: Clip;\n /** A Playwright selector that must be visible before the shot is taken (see {@link RouteState.waitFor}). */\n waitFor?: string;\n /** MSW handlers answering the page's requests, first match wins. Route shots only. */\n handlers?: readonly RequestHandler[];\n /** Class put on `<html>` in the dark theme (Strata's `dark:` variant reads `.dark`). */\n darkClass?: string | false;\n setup?: Setup;\n}\n\n/** An app's built Storybook. */\nexport interface StorybookTarget {\n /** The `storybook build` output folder. Default `storybook-static`. */\n dir?: string;\n /** The Storybook global the preview reads the theme from. Default `theme`, as Strata's preview. */\n themeGlobal?: string;\n}\n\n/** One state of a route: the MSW handlers that put the server into it, and optional steps. */\nexport interface RouteState {\n /** Handlers tried before the target's base handlers (like `server.use(...)` in a test). */\n handlers?: readonly RequestHandler[];\n /** A different path for this state, e.g. the same screen with `?tab=sync`. */\n path?: string;\n /**\n * A Playwright selector that must be visible before the shot is taken, such as `role=alert` or\n * `text=Try again`. Needed when a state takes longer than the network to show: an error after\n * the query client's retry, a toast after a timer.\n */\n waitFor?: string;\n setup?: Setup;\n}\n\n/** A screen of the app, screenshotted in each of its states. */\nexport interface Route {\n /** Names the baselines: lower-case letters, digits and dashes. */\n name: string;\n /** Path and query under the app's base, e.g. `/review` or `/library?sort=-added`. */\n path: string;\n /**\n * The server states to capture, by name. A list of handlers is shorthand for `{ handlers }`.\n * Default: one state, `default`, served by the base handlers alone.\n */\n states?: Record<string, readonly RequestHandler[] | RouteState>;\n viewports?: readonly ViewportChoice[];\n clip?: Clip;\n root?: string;\n waitFor?: string;\n setup?: Setup;\n}\n\n/** An app served from its production build (or a running server), screenshotted route by route. */\nexport interface AppTarget {\n /** The build folder to serve, e.g. `dist`. Unknown paths that ask for HTML get `index.html`. */\n dir?: string;\n /** Or a server that is already running, e.g. `http://localhost:4173`. */\n url?: string;\n /** The app's base path (Vite's `base`). Default `/`. */\n base?: string;\n /** MSW handlers for every route: the healthy server, usually the app's `handlers.ts`. */\n handlers?: readonly RequestHandler[];\n /** Default `#root`. */\n root?: string;\n /** Default `[\"wide\"]`. Every route is taken at each. */\n viewports?: readonly ViewportChoice[];\n /** Default `page`. */\n clip?: Clip;\n /** Default `dark`; `false` to rely on `prefers-color-scheme` alone. */\n darkClass?: string | false;\n /**\n * A `fetch` or XHR request no handler answers: `error` (default) fails the shot, because a\n * screenshot that depends on a real server is not a baseline; `bypass` lets it through.\n */\n onUnhandledRequest?: \"error\" | \"bypass\";\n routes: readonly Route[];\n}\n\n/** A visual suite: where baselines live and what to screenshot. Paths are relative to the config file. */\nexport interface VisualConfig {\n /** Committed baselines. Default `tests/visual/baselines`. */\n baselines?: string;\n /** Actual, expected and diff PNGs of changed shots (uploaded by CI). Default `tests/visual/output`. */\n output?: string;\n /** Default `[\"light\", \"dark\"]`. */\n themes?: readonly Theme[];\n /** Freeze the page's clock at this time, so \"3 minutes ago\" and today's date stay put. */\n time?: string | number | Date;\n /** The page's time zone. Default `UTC`, so a date renders the same on every machine. */\n timezone?: string;\n /** The page's locale (`navigator.language`, `Intl` defaults). Default `en-US`. */\n locale?: string;\n /**\n * What to do with text drawn in a font installed on the machine rather than one the page\n * loaded (a theme whose `--font-*` falls through to `ui-sans-serif`, or a glyph the web font\n * lacks). `error` (default) fails the shot, because no comparison threshold makes Cantarell\n * match San Francisco; `warn` reports it; `allow` skips the check. Bundle every face with\n * `@fontsource` (or your own `@font-face`) and name it first in the theme's `--font-*`.\n *\n * An app that chooses `system-ui` on purpose (so a page never waits on a font download) pins it\n * instead: `{ pin: \"DejaVu Sans\", files: [\"tests/visual/fonts/DejaVuSans.ttf\"] }` makes every\n * system family mean that face in the runner's Chromium, on every machine (issue #342), through\n * a fontconfig file the runner generates. Linux only; elsewhere it warns and takes the machine's face.\n */\n systemFonts?: \"error\" | \"warn\" | \"allow\" | PinnedSystemFont;\n /**\n * Before a whole-page shot (a route's) of a page taller than the window, show it to the page in a window as tall as itself and wait for the\n * pictures that start loading, then go back to the window's size, so a `Thumbnail` or any other lazy picture below the fold is in the\n * baseline, not drawn as its loading box (issue #273). Default `true`; `false` takes the page as it loads.\n */\n scrollThrough?: boolean;\n /**\n * How a screenshot is compared with its baseline. The defaults (a 3×3 blur, then pixelmatch at\n * threshold 0.1 with 4 differing pixels allowed) absorb anti-aliasing differences between\n * machines and still fail on a changed letter; change them only with evidence from your own\n * screens.\n */\n compare?: CompareOptions;\n /** Pages captured at once. Default 4. */\n concurrency?: number;\n storybook?: StorybookTarget | string;\n app?: AppTarget;\n}\n\n/** What a run found. */\nexport interface VisualReport {\n /** Shots taken. */\n total: number;\n same: number;\n /** `name.png: reason` for each shot that matched without being pixel-identical (anti-aliasing absorbed). */\n tolerated: string[];\n /** `name.png: reason` for each shot that differs from its baseline. */\n changed: string[];\n /** Shots with no baseline yet (written, and copied to the output folder). */\n added: string[];\n /** Baselines no shot produced (removed when updating). */\n obsolete: string[];\n /** Shots that failed: page errors, console errors, unhandled requests, nothing rendered. */\n errors: string[];\n /** Things that make baselines less trustworthy, such as an unpinned Playwright. */\n warnings: string[];\n updated: boolean;\n /** Whether the run should fail (in CI a missing baseline fails too). */\n failed: boolean;\n}\n","// Turning what an app has into shots. A component library has stories; an app may have only\n// screens (strata-listory has Review, Library and Settings and no stories), so routes are a\n// first-class target: each route is taken in each server state, viewport and theme, with the\n// state set by MSW handlers, the same handlers its unit tests use. Names are stable and readable\n// (`review--empty--phone--dark.png`) because a person reviews baselines by file name in a diff.\nimport { readFileSync } from \"node:fs\";\nimport { join } from \"node:path\";\nimport {\n viewports,\n type AppTarget,\n type Route,\n type RouteState,\n type Shot,\n type StorybookTarget,\n type Theme,\n type Viewport,\n type ViewportChoice,\n} from \"./types\";\n\n/** The light and dark themes, the default for every target. */\nexport const defaultThemes: readonly Theme[] = [\"light\", \"dark\"];\n\n// Untagged stories lay out in a 1024-wide, 200-tall frame and the clip grows with the component,\n// so a short component's fixed elements (the undo bar) sit near it rather than 768px down.\nconst storyViewport: Viewport = { width: 1024, height: 200 };\n\ninterface IndexEntry {\n id: string;\n type: string;\n title?: string;\n name?: string;\n tags?: string[];\n}\n\n/**\n * Shots for every story in a built Storybook (its `index.json`), in each theme. Tags pick the\n * viewport: `visual-phone` 390×844, `visual-wide` 1440×900, otherwise 1024 wide; `no-visual`\n * skips the story. A story's own tag beats its file's, since Storybook merges both.\n */\nexport function storybookShots(\n target: StorybookTarget & { dir: string },\n themes: readonly Theme[] = defaultThemes,\n): Shot[] {\n const index = JSON.parse(readFileSync(join(target.dir, \"index.json\"), \"utf8\")) as {\n entries: Record<string, IndexEntry>;\n };\n const global = target.themeGlobal ?? \"theme\";\n return Object.values(index.entries)\n .filter((e) => e.type === \"story\" && !e.tags?.includes(\"no-visual\"))\n .flatMap((story) => {\n const tag = [\"visual-phone\", \"visual-wide\"].find((t) => story.tags?.includes(t));\n const viewport =\n tag === \"visual-phone\" ? viewports.phone : tag === \"visual-wide\" ? viewports.wide : storyViewport;\n return themes.map((theme) => ({\n name: `${story.id}--${theme}`,\n path: `iframe.html?id=${story.id}&viewMode=story&globals=${global}:${theme}`,\n theme,\n viewport: { ...viewport },\n root: \"#storybook-root\",\n clip: \"paint\" as const,\n darkClass: false as const,\n }));\n });\n}\n\nconst slug = /^[a-z0-9]+(?:-[a-z0-9]+)*$/;\n\nfunction viewportName(v: ViewportChoice): string {\n return typeof v === \"string\" ? v : `${v.width}x${v.height}`;\n}\n\nfunction viewportSize(v: ViewportChoice): Viewport {\n if (typeof v !== \"string\") return { width: v.width, height: v.height };\n const size = viewports[v];\n if (!size)\n throw new Error(`unknown viewport \"${String(v)}\": use ${Object.keys(viewports).join(\", \")} or { width, height }`);\n return { ...size };\n}\n\nfunction stateOf(value: readonly unknown[] | RouteState): RouteState {\n return Array.isArray(value) ? { handlers: value as RouteState[\"handlers\"] } : (value as RouteState);\n}\n\n/**\n * Shots for every route of an app in each state, viewport and theme, named\n * `route--state--viewport--theme`. A state's handlers come before the target's base handlers, as\n * `server.use(...)` would put them.\n */\nexport function routeShots(app: AppTarget, themes: readonly Theme[] = defaultThemes): Shot[] {\n const shots: Shot[] = [];\n for (const route of app.routes as readonly Route[]) {\n if (!slug.test(route.name))\n throw new Error(`route name \"${route.name}\" must be lower-case letters, digits and dashes`);\n const states = Object.entries(route.states ?? { default: [] });\n if (!states.length)\n throw new Error(`route \"${route.name}\" has an empty states object: leave it out for one default state`);\n const chosen = route.viewports ?? app.viewports ?? [\"wide\"];\n for (const [stateName, value] of states) {\n if (!slug.test(stateName))\n throw new Error(`state \"${stateName}\" of route \"${route.name}\" must be lower-case letters, digits and dashes`);\n const state = stateOf(value);\n const setups = [route.setup, state.setup].filter((s) => s !== undefined);\n for (const v of chosen) {\n for (const theme of themes) {\n shots.push({\n name: `${route.name}--${stateName}--${viewportName(v)}--${theme}`,\n path: state.path ?? route.path,\n theme,\n viewport: viewportSize(v),\n root: route.root ?? app.root ?? \"#root\",\n clip: route.clip ?? app.clip ?? \"page\",\n waitFor: state.waitFor ?? route.waitFor,\n handlers: [...(state.handlers ?? []), ...(app.handlers ?? [])],\n darkClass: app.darkClass ?? \"dark\",\n setup: setups.length\n ? async (page, shot) => {\n for (const s of setups) await s(page, shot);\n }\n : undefined,\n });\n }\n }\n }\n }\n return shots;\n}\n","// Running a suite: serve each target, take its shots a few at a time in one Chromium, compare\n// each with its committed baseline, and report. The rules are the library's own, so an app's\n// suite fails for the same reasons Strata's does: a changed screenshot, a page or console\n// error, an unanswered request, and in CI a shot with no baseline (it was added without one).\n//\n// Baselines are only comparable when written by the same Chromium on the same platform, which\n// is why Playwright is pinned to an exact version. A run records both next to the baselines\n// (`.strata-visual.json`) when it writes them, and says so when a later run differs.\nimport { existsSync, mkdirSync, readFileSync, readdirSync, rmSync, writeFileSync } from \"node:fs\";\nimport { join, resolve } from \"node:path\";\nimport type { Browser } from \"playwright\";\nimport { capture } from \"./capture\";\nimport { compare, decode } from \"./compare\";\nimport { pinSystemFont, type PinnedFonts } from \"./fonts\";\nimport { serveStatic, type StaticServer } from \"./serve\";\nimport { defaultThemes, routeShots, storybookShots } from \"./targets\";\nimport type { Shot, VisualConfig, VisualReport } from \"./types\";\n\n/** Returns the config unchanged; it exists so a config file is type-checked. */\nexport function defineVisualConfig(config: VisualConfig): VisualConfig {\n return config;\n}\n\n/** Options for one run, usually from the command line. */\nexport interface RunOptions {\n /** Folder the config's paths are relative to. Default `process.cwd()`. */\n cwd?: string;\n /** Write the screenshots as the baselines and remove obsolete ones, instead of comparing. */\n update?: boolean;\n /** Only shots whose name contains this text (obsolete baselines are then not reported). */\n filter?: string;\n /** Fail when a shot has no baseline. Default: when the `CI` environment variable is set. */\n ci?: boolean;\n /** Progress lines; default none. */\n log?: (line: string) => void;\n}\n\nconst metaFile = \".strata-visual.json\";\ninterface Meta {\n chromium: string;\n platform: string;\n}\n\ninterface Batch {\n shots: Shot[];\n server?: StaticServer;\n baseUrl: string;\n blockServiceWorkers: boolean;\n onUnhandledRequest?: \"error\" | \"bypass\";\n}\n\n/** Screenshots every shot the config describes, compares with the baselines, and reports. */\nexport async function runVisual(config: VisualConfig, options: RunOptions = {}): Promise<VisualReport> {\n const cwd = resolve(options.cwd ?? process.cwd());\n const baselineDir = resolve(cwd, config.baselines ?? \"tests/visual/baselines\");\n const outputDir = resolve(cwd, config.output ?? \"tests/visual/output\");\n const themes = config.themes ?? defaultThemes;\n const update = options.update ?? false;\n const ci = options.ci ?? Boolean(process.env.CI);\n const log = options.log ?? (() => undefined);\n const concurrency = config.concurrency ?? 4;\n // A worker count that is not a positive integer would start no workers and report an empty,\n // passing run, so it is refused up front.\n if (!Number.isInteger(concurrency) || concurrency < 1)\n throw new Error(`concurrency must be a whole number of pages, 1 or more (got ${String(config.concurrency)})`);\n const report: VisualReport = {\n total: 0,\n same: 0,\n tolerated: [],\n changed: [],\n added: [],\n obsolete: [],\n errors: [],\n warnings: pinWarnings(cwd),\n updated: update,\n failed: false,\n };\n\n const batches: Batch[] = [];\n let pinned: PinnedFonts | undefined;\n try {\n if (config.storybook !== undefined) {\n const target = typeof config.storybook === \"string\" ? { dir: config.storybook } : config.storybook;\n const dir = resolve(cwd, target.dir ?? \"storybook-static\");\n if (!existsSync(join(dir, \"index.json\")))\n throw new Error(`${join(dir, \"index.json\")} not found: build Storybook first (storybook build)`);\n // Shots first: if building them throws, no server is left running to hold the process open.\n const shots = storybookShots({ ...target, dir }, themes);\n const batch: Batch = { shots, baseUrl: \"\", blockServiceWorkers: false };\n batches.push(batch);\n batch.server = await serveStatic(dir);\n batch.baseUrl = batch.server.url;\n }\n if (config.app !== undefined) {\n const app = config.app;\n if (!app.dir === !app.url)\n throw new Error(\"app needs exactly one of dir (a build to serve) or url (a running server)\");\n const shots = routeShots(app, themes);\n const batch: Batch = {\n shots,\n baseUrl: \"\",\n blockServiceWorkers: true,\n onUnhandledRequest: app.onUnhandledRequest ?? \"error\",\n };\n batches.push(batch);\n if (app.dir) {\n const dir = resolve(cwd, app.dir);\n if (!existsSync(join(dir, \"index.html\")))\n throw new Error(`${join(dir, \"index.html\")} not found: build the app first`);\n batch.server = await serveStatic(dir, { spa: true, base: app.base });\n batch.baseUrl = batch.server.url;\n } else {\n batch.baseUrl = new URL(`${(app.base ?? \"/\").replace(/^\\/*/, \"/\").replace(/\\/*$/, \"/\")}`, app.url).href;\n }\n }\n if (!batches.length) throw new Error(\"nothing to screenshot: the config needs storybook or app\");\n\n const all = batches.flatMap((b) => b.shots);\n const names = new Set<string>();\n for (const s of all) {\n if (names.has(s.name)) throw new Error(`two shots are named ${s.name}: give routes and states distinct names`);\n names.add(s.name);\n }\n for (const b of batches) b.shots = b.shots.filter((s) => !options.filter || s.name.includes(options.filter));\n report.total = batches.reduce((n, b) => n + b.shots.length, 0);\n\n mkdirSync(baselineDir, { recursive: true });\n rmSync(outputDir, { recursive: true, force: true });\n mkdirSync(outputDir, { recursive: true });\n\n const { chromium } = await import(\"playwright\").catch(() => {\n throw new Error(\n \"strata-visual needs Playwright: npm install -D -E playwright, then npx playwright install chromium\",\n );\n });\n // Font hinting and LCD anti-aliasing off and an sRGB profile: the same pixels on every machine.\n // STRATA_VISUAL_CHROMIUM_ARGS adds flags, for experiments such as checking that the\n // comparison absorbs another rasteriser (the visual-portability workflow).\n const extraArgs = (process.env.STRATA_VISUAL_CHROMIUM_ARGS ?? \"\").split(/\\s+/).filter(Boolean);\n // A pinned system face (issue #342): on Linux a fontconfig file of the runner's own makes every system family that face.\n const pin = typeof config.systemFonts === \"object\" ? config.systemFonts : undefined;\n if (pin && process.platform !== \"linux\")\n report.warnings.push(\n `systemFonts.pin works through fontconfig and applies on Linux only; this run (${process.platform}) draws system text in the machine's own faces, so record baselines where CI does`,\n );\n pinned = pin && process.platform === \"linux\" ? pinSystemFont(pin, cwd) : undefined;\n const browser = await chromium.launch({\n args: [\"--font-render-hinting=none\", \"--disable-lcd-text\", \"--force-color-profile=srgb\", ...extraArgs],\n ...(pinned ? { env: { ...process.env, ...pinned.env } as Record<string, string> } : {}),\n });\n const meta: Meta = { chromium: browser.version(), platform: `${process.platform}-${process.arch}` };\n try {\n for (const batch of batches)\n await runBatch(browser, batch, {\n config,\n baselineDir,\n outputDir,\n update,\n report,\n log,\n pinnedFamily: pinned?.family,\n });\n } finally {\n await browser.close();\n }\n\n const pngs = readdirSync(baselineDir).filter((f) => f.endsWith(\".png\"));\n report.obsolete = options.filter ? [] : pngs.filter((f) => !names.has(f.slice(0, -4)));\n if (update) {\n for (const f of report.obsolete) rmSync(join(baselineDir, f));\n if (!options.filter) writeFileSync(join(baselineDir, metaFile), `${JSON.stringify(meta, null, 2)}\\n`);\n } else if (report.changed.length) {\n const written = readMeta(baselineDir);\n if (written && (written.chromium !== meta.chromium || written.platform !== meta.platform)) {\n report.warnings.push(\n `the baselines were written by Chromium ${written.chromium} on ${written.platform}; this run used Chromium ${meta.chromium} on ${meta.platform}, so some differences may be the browser, not the app`,\n );\n }\n }\n } finally {\n pinned?.dispose();\n for (const b of batches) await b.server?.close();\n }\n report.failed = Boolean(report.errors.length || report.changed.length || (ci && !update && report.added.length));\n return report;\n}\n\nasync function runBatch(\n browser: Browser,\n batch: Batch,\n ctx: {\n config: VisualConfig;\n baselineDir: string;\n outputDir: string;\n update: boolean;\n report: VisualReport;\n log: (l: string) => void;\n pinnedFamily?: string;\n },\n) {\n const { baselineDir, outputDir, update, report } = ctx;\n const shoot = async (shot: Shot) => {\n const file = `${shot.name}.png`;\n try {\n // A pin that cannot apply here (not Linux) was reported once, and its text is only a warning.\n const configured = ctx.config.systemFonts ?? \"error\";\n const fonts = typeof configured === \"object\" ? (ctx.pinnedFamily ? \"error\" : \"warn\") : configured;\n const { png, problems, systemFonts } = await capture(browser, shot, {\n baseUrl: batch.baseUrl,\n time: ctx.config.time,\n timezone: ctx.config.timezone,\n locale: ctx.config.locale,\n blockServiceWorkers: batch.blockServiceWorkers,\n onUnhandledRequest: batch.onUnhandledRequest,\n checkFonts: fonts !== \"allow\",\n pinnedFamily: ctx.pinnedFamily,\n scrollThrough: ctx.config.scrollThrough,\n });\n if (systemFonts.length) {\n const line = `${file}: text in a system font, which differs by machine (bundle the face with @fontsource and name it in the theme's --font-*): ${systemFonts.join(\", \")}`;\n if (fonts === \"error\") problems.push(line.slice(file.length + 2));\n else report.warnings.push(line);\n }\n if (problems.length) report.errors.push(`${file}: ${problems.join(\" | \")}`);\n const baselinePath = join(baselineDir, file);\n if (update || !existsSync(baselinePath)) {\n if (!update) report.added.push(file);\n writeFileSync(baselinePath, png);\n if (!update) writeFileSync(join(outputDir, file), png);\n return;\n }\n const expected = readFileSync(baselinePath);\n const result = compare(decode(expected), decode(png), ctx.config.compare);\n if (result.same) {\n report.same++;\n if (!result.identical) report.tolerated.push(`${file}: ${result.reason}`);\n return;\n }\n report.changed.push(`${file}: ${result.reason}`);\n writeFileSync(join(outputDir, `${shot.name}.actual.png`), png);\n writeFileSync(join(outputDir, `${shot.name}.expected.png`), expected);\n if (result.diff) writeFileSync(join(outputDir, `${shot.name}.diff.png`), result.diff);\n } catch (e) {\n report.errors.push(`${file}: ${(e instanceof Error ? e.message : String(e)).split(\"\\n\")[0]}`);\n } finally {\n ctx.log(file);\n }\n };\n // A few pages at once: each shot has its own context, so they cannot affect each other.\n const queue = [...batch.shots];\n await Promise.all(\n Array.from({ length: ctx.config.concurrency ?? 4 }, async () => {\n for (let shot = queue.shift(); shot; shot = queue.shift()) await shoot(shot);\n }),\n );\n}\n\nfunction readMeta(dir: string): Meta | undefined {\n try {\n return JSON.parse(readFileSync(join(dir, metaFile), \"utf8\")) as Meta;\n } catch {\n return undefined;\n }\n}\n\n/** A warning when the app's package.json lets Playwright float, since each version brings its own Chromium. */\nexport function pinWarnings(cwd: string): string[] {\n let pkg: { dependencies?: Record<string, string>; devDependencies?: Record<string, string> };\n try {\n pkg = JSON.parse(readFileSync(join(cwd, \"package.json\"), \"utf8\"));\n } catch {\n return [];\n }\n const deps = { ...pkg.dependencies, ...pkg.devDependencies };\n return [\"playwright\", \"@playwright/test\"]\n .filter((name) => deps[name] !== undefined && !/^\\d+\\.\\d+\\.\\d+$/.test(deps[name]))\n .map(\n (name) =>\n `${name} is \"${deps[name]}\" in package.json: pin an exact version (npm install -D -E ${name}) so CI and the machine that wrote the baselines render with the same Chromium`,\n );\n}\n\n// Sorts by the blurred count, then by the count without the blur.\nconst pixels = (line: string) => {\n const m = /: (\\d+) pixels differ[^,]*(?:, (\\d+) without)?/.exec(line);\n return Number(m?.[1] ?? 0) * 1e9 + Number(m?.[2] ?? 0);\n};\n\n/** The report as the lines the command prints. */\nexport function formatReport(report: VisualReport): string {\n const lines = [\n report.updated\n ? `Wrote ${report.total} baselines${report.obsolete.length ? `, removed ${report.obsolete.length} obsolete` : \"\"}.`\n : `${report.same} of ${report.total} screenshots match their baselines${report.tolerated.length ? ` (${report.same - report.tolerated.length} identical, ${report.tolerated.length} within tolerance)` : \"\"}.`,\n ...report.changed.map((l) => `changed ${l}`),\n // The most-differing few: enough to see how close to the allowance a machine runs.\n ...[...report.tolerated]\n .sort((a, b) => pixels(b) - pixels(a))\n .slice(0, 5)\n .map((l) => `within ${l}`),\n ...(report.tolerated.length > 5 ? [`within … and ${report.tolerated.length - 5} more`] : []),\n ...report.added.map((l) => `new ${l} (baseline written; commit it)`),\n ...report.obsolete.map((l) => `obsolete ${l}${report.updated ? \" (removed)\" : \" (run with --update to remove)\"}`),\n ...report.errors.map((l) => `error ${l}`),\n ...report.warnings.map((l) => `warning ${l}`),\n ];\n if (report.failed) {\n lines.push(\n \"\",\n \"Diffs are in the output folder (tests/visual/output by default). Look at them; if the change is intended, run with --update and commit the baselines.\",\n );\n }\n return lines.join(\"\\n\");\n}\n"],"mappings":";;;;;;;;AAUA,MAAM,2BAA2B;AAGjC,MAAM,mBAAmB;AAGzB,MAAM,SAAS;;AAkCf,SAAgB,eAAe,MAAc,SAAyB;CACpE,IAAI,uBAAuB,KAAK,IAAI,GAAG,OAAO;CAC9C,OAAO,IAAI,IAAI,KAAK,QAAQ,QAAQ,EAAE,GAAG,OAAO,CAAC,CAAC;AACpD;;AAGA,SAAgB,eACd,SACS;CACT,MAAM,SAAS,QAAQ,OAAO;CAC9B,MAAM,OAAO,WAAW,SAAS,WAAW,SAAS,SAAa,QAAQ,eAAe,KAAK;CAC9F,OAAO,IAAI,QAAQ,QAAQ,IAAI,GAAG;EAChC;EACA,SAAS,QAAQ,QAAQ;EACzB,MAAM,OAAO,IAAI,WAAW,IAAI,IAAI;CACtC,CAAC;AACH;AAEA,eAAe,mBACb,SACA,UACA,SACA,WACA,UACA;CACA,MAAM,MAAM,MAAM,OAAO,MAAM,CAAC,YAAY;EAC1C,MAAM,IAAI,MAAM,wDAAwD;CAC1E,CAAC;CACD,MAAM,SAAS,IAAI,IAAI,OAAO,CAAC,CAAC;CAChC,MAAM,QAAQ,MAAM,QAAQ,OAAO,UAA2B;EAC5D,MAAM,UAAU,MAAM,QAAQ;EAC9B,MAAM,WAAW,MAAM,IAAI,YAAY,CAAC,GAAG,QAAQ,GAAG,eAAe,OAAO,GAAG;GAAE,SAAS;GAAQ,OAAO;EAAK,CAAC;EAC/G,IAAI,YAAY,SAAS,QAAQ,IAAI,iBAAiB,MAAM,eAAe;GACzE,MAAM,UAAkC,CAAC;GACzC,SAAS,QAAQ,SAAS,OAAO,QAAS,QAAQ,OAAO,KAAM;GAC/D,MAAM,MAAM,QAAQ;IAAE,QAAQ,SAAS;IAAQ;IAAS,MAAM,OAAO,KAAK,MAAM,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