@weasel-js/labkit 1.6.1 → 1.7.1
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 +3 -3
- package/dist/_dts/{CanvasStackContext-Wo6OwIVM.d.ts → CanvasStackContext-Cjy6I-Iv.d.ts} +4 -1
- package/dist/_dts/{Stage-DWBBi8IU.d.ts → Stage-D6t7o0pF.d.ts} +59 -18
- package/dist/_dts/{index-CKyX0ME_.d.ts → index-BTmaRy6a.d.ts} +10 -6
- package/dist/_dts/{types-B7yBTTF9.d.ts → index-DCMA4Fy1.d.ts} +59 -113
- package/dist/_dts/{types-DTuViBvc.d.ts → types-BUBSIZuV.d.ts} +18 -8
- package/dist/_dts/{useTrialState-CMaV6UD4.d.ts → useTrialState-Bh8bzFgE.d.ts} +1 -1
- package/dist/canvas/index.d.ts +8 -6
- package/dist/canvas/index.js +6 -6
- package/dist/chrome/index.d.ts +6 -4
- package/dist/chrome/index.js +11 -10
- package/dist/chunk-2ES4W47N.js +8 -0
- package/dist/chunk-2ES4W47N.js.map +1 -0
- package/dist/{chunk-WPLAANH4.js → chunk-2N7UBSS2.js} +12 -12
- package/dist/chunk-2N7UBSS2.js.map +1 -0
- package/dist/chunk-4KSC7NXL.js +15491 -0
- package/dist/chunk-4KSC7NXL.js.map +1 -0
- package/dist/{chunk-SLAQPUI4.js → chunk-CEGFXTBD.js} +10 -63
- package/dist/chunk-CEGFXTBD.js.map +1 -0
- package/dist/chunk-CZZPXUOU.js +3 -0
- package/dist/{chunk-SBXNQW4G.js.map → chunk-CZZPXUOU.js.map} +1 -1
- package/dist/{chunk-QGMOA2YE.js → chunk-E23Q6A3Y.js} +296 -104
- package/dist/chunk-E23Q6A3Y.js.map +1 -0
- package/dist/{chunk-GHGO52SO.js → chunk-E6NARGU7.js} +5 -5
- package/dist/{chunk-GHGO52SO.js.map → chunk-E6NARGU7.js.map} +1 -1
- package/dist/{chunk-IJJUK4FU.js → chunk-EESJUSYR.js} +5 -6
- package/dist/chunk-EESJUSYR.js.map +1 -0
- package/dist/{chunk-HXXTULDN.js → chunk-EFXRM6XQ.js} +8 -11
- package/dist/chunk-EFXRM6XQ.js.map +1 -0
- package/dist/chunk-F4ACIK7Z.js +210 -0
- package/dist/chunk-F4ACIK7Z.js.map +1 -0
- package/dist/{chunk-6FLXL3I7.js → chunk-FB4MIZOO.js} +77 -45
- package/dist/chunk-FB4MIZOO.js.map +1 -0
- package/dist/{chunk-AWQG7FCC.js → chunk-FG3EXZDV.js} +3 -3
- package/dist/{chunk-AWQG7FCC.js.map → chunk-FG3EXZDV.js.map} +1 -1
- package/dist/{chunk-4TT3PNPR.js → chunk-GAHELLJT.js} +95 -95
- package/dist/chunk-GAHELLJT.js.map +1 -0
- package/dist/{chunk-HKV7LRHY.js → chunk-IBVRMHW5.js} +5 -5
- package/dist/{chunk-HKV7LRHY.js.map → chunk-IBVRMHW5.js.map} +1 -1
- package/dist/{chunk-ASOK76ZH.js → chunk-JFOJESJF.js} +72 -29
- package/dist/chunk-JFOJESJF.js.map +1 -0
- package/dist/{chunk-RWNDDKOH.js → chunk-PMLZP7RT.js} +18 -15
- package/dist/chunk-PMLZP7RT.js.map +1 -0
- package/dist/{chunk-TJ77A4A3.js → chunk-READTDQX.js} +5 -9
- package/dist/chunk-READTDQX.js.map +1 -0
- package/dist/{chunk-JVBYV6TL.js → chunk-ROGJWDQA.js} +3 -3
- package/dist/{chunk-JVBYV6TL.js.map → chunk-ROGJWDQA.js.map} +1 -1
- package/dist/{chunk-CGHF6RZV.js → chunk-T6DLGEJB.js} +18 -18
- package/dist/chunk-T6DLGEJB.js.map +1 -0
- package/dist/{chunk-24W5VEJW.js → chunk-ULYYNWGP.js} +2 -2
- package/dist/{chunk-24W5VEJW.js.map → chunk-ULYYNWGP.js.map} +1 -1
- package/dist/{chunk-DWMSB4CA.js → chunk-VYVGVBGY.js} +95 -32
- package/dist/chunk-VYVGVBGY.js.map +1 -0
- package/dist/{chunk-IRTGUQ5O.js → chunk-WLMDTI2Q.js} +16 -6
- package/dist/chunk-WLMDTI2Q.js.map +1 -0
- package/dist/{chunk-NEXR37YJ.js → chunk-XE5HJOPL.js} +6 -8
- package/dist/chunk-XE5HJOPL.js.map +1 -0
- package/dist/chunk-XVUKDSYV.js +38 -0
- package/dist/chunk-XVUKDSYV.js.map +1 -0
- package/dist/{chunk-O6FFFOHS.js → chunk-YCFKW5RX.js} +16 -8
- package/dist/chunk-YCFKW5RX.js.map +1 -0
- package/dist/{chunk-CQLQPQ4P.js → chunk-ZQIHJXP4.js} +2 -2
- package/dist/chunk-ZQIHJXP4.js.map +1 -0
- package/dist/config/index.d.ts +28 -13
- package/dist/config/index.js +4 -4
- package/dist/controls/index.d.ts +4 -7
- package/dist/controls/index.js +6 -5
- package/dist/dragdrop/index.d.ts +23 -3
- package/dist/dragdrop/index.js +4 -3
- package/dist/fonts/oswald-tabular-digits.woff2 +0 -0
- package/dist/index.d.ts +72 -487
- package/dist/index.js +603 -441
- package/dist/index.js.map +1 -1
- package/dist/job/index.d.ts +8 -0
- package/dist/job/index.js +1 -1
- package/dist/layers/index.d.ts +6 -5
- package/dist/layers/index.js +3 -2
- package/dist/loupe/index.d.ts +100 -30
- package/dist/loupe/index.js +585 -6
- package/dist/loupe/index.js.map +1 -1
- package/dist/overview/index.d.ts +4 -2
- package/dist/overview/index.js +20 -18
- package/dist/overview/index.js.map +1 -1
- package/dist/passthrough/weasel-canvas.d.ts +2 -0
- package/dist/passthrough/weasel-ui.d.ts +2 -2701
- package/dist/passthrough/weasel-ui.js +4 -3
- package/dist/primitives/index.d.ts +37 -2
- package/dist/primitives/index.js +9 -8
- package/dist/state/index.d.ts +7 -5
- package/dist/state/index.js +6 -6
- package/dist/styles.css +150 -126
- package/dist/surface/index.d.ts +10 -2
- package/dist/surface/index.js +1 -1
- package/dist/undo/index.d.ts +5 -3
- package/package.json +14 -13
- package/src/annotations/AnnotationOverlay.abandon.test.tsx +143 -0
- package/src/annotations/AnnotationOverlay.tsx +52 -33
- package/src/annotations/Annotations.less +0 -10
- package/src/annotations/Annotations.overlay.test.tsx +31 -0
- package/src/annotations/MarkList.tsx +4 -8
- package/src/annotations/capture.browser.test.ts +41 -0
- package/src/annotations/capture.ts +14 -7
- package/src/annotations/drawOne.ts +2 -2
- package/src/annotations/frac.test.ts +44 -1
- package/src/annotations/frac.ts +46 -18
- package/src/annotations/index.ts +1 -0
- package/src/annotations/paint.test.ts +76 -46
- package/src/annotations/paint.ts +65 -43
- package/src/annotations/store.test.ts +212 -2
- package/src/annotations/store.ts +130 -27
- package/src/annotations/svgNodes.test.ts +28 -19
- package/src/annotations/svgNodes.ts +6 -6
- package/src/annotations/types.ts +29 -10
- package/src/canvas/AGENTS.md +1 -0
- package/src/canvas/CameraInput.test.tsx +30 -0
- package/src/canvas/CameraInput.tsx +60 -48
- package/src/canvas/CanvasStack.tsx +11 -6
- package/src/canvas/CanvasStackContext.ts +4 -1
- package/src/canvas/LinkedCursor.less +1 -1
- package/src/canvas/Stage.test.tsx +33 -4
- package/src/canvas/Stage.tsx +9 -4
- package/src/canvas/cameraRegistry.test.ts +55 -0
- package/src/canvas/cameraRegistry.ts +87 -0
- package/src/canvas/cameraZoom.test.ts +46 -0
- package/src/canvas/cameraZoom.ts +24 -0
- package/src/canvas/index.ts +14 -2
- package/src/canvas/sharedScope.test.tsx +94 -0
- package/src/canvas/worldSpec.ts +3 -1
- package/src/chrome/ChromeRegions.stories.tsx +1 -0
- package/src/chrome/builtins.test.ts +7 -6
- package/src/chrome/builtins.tsx +5 -1
- package/src/chrome/index.ts +1 -1
- package/src/chrome/merge.test.ts +5 -0
- package/src/chrome/merge.ts +4 -2
- package/src/chrome/regions/PaletteRegion.less +0 -7
- package/src/chrome/regions/PaletteRegion.test.tsx +2 -3
- package/src/chrome/regions/PaletteRegion.tsx +3 -4
- package/src/chrome/regions/SidebarRegion.less +12 -2
- package/src/chrome/regions/ViewportRegion.browser.test.less +6 -0
- package/src/chrome/regions/ViewportRegion.browser.test.tsx +38 -0
- package/src/chrome/regions/ViewportRegion.less +6 -0
- package/src/chrome/regions/ViewportRegion.tsx +10 -4
- package/src/chrome/types.ts +4 -2
- package/src/config/auto.ts +1 -0
- package/src/config/builder.test.ts +2 -1
- package/src/config/builder.ts +18 -5
- package/src/config/fromConfigField.test.ts +14 -0
- package/src/config/fromConfigField.ts +18 -4
- package/src/config/path.ts +2 -5
- package/src/config/resolve.ts +4 -0
- package/src/config/types.ts +14 -9
- package/src/controls/ControlPanel.less +1 -1
- package/src/controls/ControlPanel.stories.tsx +3 -2
- package/src/controls/ControlPanel.test.tsx +98 -11
- package/src/controls/ControlPanel.tsx +61 -2
- package/src/dragdrop/DragDropRuntime.tsx +22 -13
- package/src/dragdrop/DragGhost.tsx +3 -0
- package/src/dragdrop/Palette.tsx +2 -0
- package/src/index.test.ts +5 -0
- package/src/index.ts +16 -2
- package/src/instrument/types.ts +0 -6
- package/src/job/useJob.ts +14 -9
- package/src/lab/Lab.tsx +88 -73
- package/src/lab/{LabFit.stories.less → LabFit.browser.test.less} +1 -1
- package/src/lab/{LabFit.stories.tsx → LabFit.browser.test.tsx} +41 -63
- package/src/lab/LabFullChrome.stories.tsx +1 -0
- package/src/lab/LabHeader.test.tsx +24 -14
- package/src/lab/LabHeader.tsx +11 -12
- package/src/lab/LabShell.less +9 -17
- package/src/lab/LabSwitcher.browser.test.tsx +27 -0
- package/src/lab/LabSwitcher.less +8 -6
- package/src/lab/LabZoom.test.tsx +223 -0
- package/src/lab/LabZoom.tsx +170 -0
- package/src/lab/Workspace.tsx +48 -52
- package/src/lab/index.ts +1 -0
- package/src/loupe/AGENTS.md +28 -15
- package/src/loupe/CanvasLoupe.tsx +2 -3
- package/src/loupe/DomLoupe.tsx +1 -7
- package/src/loupe/Loupe.less +16 -0
- package/src/loupe/LoupeGestures.tsx +1 -1
- package/src/loupe/TrialLoupe.tsx +120 -57
- package/src/loupe/index.ts +1 -6
- package/src/loupe/types.test.ts +3 -3
- package/src/loupe/types.ts +24 -27
- package/src/loupe/useLoupe.test.tsx +29 -4
- package/src/loupe/useLoupe.ts +20 -17
- package/src/overview/OverviewMarks.tsx +12 -4
- package/src/overview/TrialOverview.tsx +10 -8
- package/src/passthrough/weasel-ui.test.ts +2 -0
- package/src/passthrough/weasel-ui.ts +17 -5
- package/src/primitives/FloatingPanel.test.tsx +11 -0
- package/src/primitives/FloatingPanel.tsx +8 -7
- package/src/primitives/JobProgress.less +2 -1
- package/src/primitives/Legend.stories.tsx +1 -0
- package/src/primitives/Readout.browser.test.tsx +137 -0
- package/src/primitives/Readout.less +12 -0
- package/src/primitives/Readout.stories.tsx +58 -0
- package/src/primitives/Readout.test.tsx +93 -0
- package/src/primitives/Readout.tsx +56 -0
- package/src/primitives/Split.tsx +69 -41
- package/src/primitives/Toolbar.tsx +3 -3
- package/src/primitives/ZoomControl.less +1 -2
- package/src/primitives/index.ts +2 -0
- package/src/specimen/Specimen.stories.tsx +1 -0
- package/src/specimen/Specimen.tsx +2 -3
- package/src/state/Persistence.browser.test.tsx +47 -0
- package/src/state/store.test.ts +5 -1
- package/src/state/undock.ts +3 -0
- package/src/state/useOpenOnce.ts +20 -16
- package/src/state/usePersistedState.test.tsx +1 -1
- package/src/state/view.ts +1 -0
- package/src/styles.less +1 -0
- package/src/surface/index.ts +1 -1
- package/src/surface/useTiledSurface.test.tsx +14 -0
- package/src/surface/useTiledSurface.ts +11 -3
- package/src/theme/Interstellar.stories.tsx +3 -1
- package/src/theme/base.less +21 -47
- package/src/theme/interstellar.test.ts +1 -1
- package/src/theme/interstellar.theme.json +10 -3
- package/src/trial/Trial.annotations.test.tsx +73 -0
- package/src/trial/Trial.less +0 -29
- package/src/trial/Trial.loupe.test.tsx +28 -11
- package/src/trial/Trial.tsx +85 -67
- package/src/trial/TrialChrome.tsx +27 -6
- package/src/trial/index.ts +2 -0
- package/src/trial/loupeSwitch.ts +15 -0
- package/dist/_dts/LayerList.d-BoELAMsM.d.ts +0 -83
- package/dist/_dts/PrefsRow.d-DFpPIeIC.d.ts +0 -39
- package/dist/_dts/PropertyField.d-D0ndfIIt.d.ts +0 -404
- package/dist/_dts/Select.d-Cr8-zoup.d.ts +0 -569
- package/dist/chunk-4TT3PNPR.js.map +0 -1
- package/dist/chunk-6FLXL3I7.js.map +0 -1
- package/dist/chunk-ASOK76ZH.js.map +0 -1
- package/dist/chunk-CGHF6RZV.js.map +0 -1
- package/dist/chunk-CQLQPQ4P.js.map +0 -1
- package/dist/chunk-DWMSB4CA.js.map +0 -1
- package/dist/chunk-HXXTULDN.js.map +0 -1
- package/dist/chunk-IJJUK4FU.js.map +0 -1
- package/dist/chunk-IRTGUQ5O.js.map +0 -1
- package/dist/chunk-KHK5FGER.js +0 -145
- package/dist/chunk-KHK5FGER.js.map +0 -1
- package/dist/chunk-NEXR37YJ.js.map +0 -1
- package/dist/chunk-O6FFFOHS.js.map +0 -1
- package/dist/chunk-QGMOA2YE.js.map +0 -1
- package/dist/chunk-RWNDDKOH.js.map +0 -1
- package/dist/chunk-S4NCI32V.js +0 -549
- package/dist/chunk-S4NCI32V.js.map +0 -1
- package/dist/chunk-SBXNQW4G.js +0 -3
- package/dist/chunk-SLAQPUI4.js.map +0 -1
- package/dist/chunk-TJ77A4A3.js.map +0 -1
- package/dist/chunk-TYN6MLXX.js +0 -13864
- package/dist/chunk-TYN6MLXX.js.map +0 -1
- package/dist/chunk-WPLAANH4.js.map +0 -1
- package/src/primitives/useRovingTabIndex.test.ts +0 -48
- package/src/primitives/useRovingTabIndex.ts +0 -88
- package/src/state/Persistence.stories.tsx +0 -75
package/dist/loupe/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":[],"names":[],"mappings":"","file":"index.js"}
|
|
1
|
+
{"version":3,"sources":["../../src/loupe/canvasLens.ts","../../src/loupe/CanvasLoupe.tsx","../../src/loupe/DomLoupe.tsx","../../src/loupe/LoupeBubble.tsx","../../src/loupe/loupeActions.ts","../../src/loupe/LoupeGestures.tsx","../../src/loupe/types.ts","../../src/loupe/useHostSize.ts","../../../loupe/src/geometry.ts","../../../loupe/src/model.ts","../../src/loupe/useLoupe.ts","../../src/loupe/TrialLoupe.tsx"],"names":["jsx","useEffect","useRef","useLatest","useMemo","useContext"],"mappings":";;;;;;;;;;;AAqBO,SAAS,WACd,GAAA,EACA,KAAA,EACA,UAAA,EACA,MAAA,EACA,UACA,SAAA,EACY;AACZ,EAAA,MAAM,IAAA,GAAO,EAAE,KAAA,EAAO,QAAA,EAAU,QAAQ,QAAA,EAAS;AACjD,EAAA,MAAM,KAAA,GAAQ,YAAA,CAAa,SAAA,EAAW,IAAI,CAAA;AAC1C,EAAA,MAAM,KAAA,GAAQ,aAAA,CAAc,GAAA,EAAK,KAAA,EAAO,UAAU,CAAA;AAClD,EAAA,OAAO,EAAE,IAAA,EAAM,QAAA,CAAS,KAAA,EAAO,KAAA,CAAM,OAAO,MAAA,EAAQ,IAAA,EAAM,KAAK,CAAA,EAAG,KAAA,EAAM;AAC1E;AAcO,SAAS,cAAA,CACd,GAAA,EACA,MAAA,EACA,QAAA,EACA,GAAA,EACY;AACZ,EAAA,MAAM,OAAO,QAAA,GAAW,MAAA;AACxB,EAAA,OAAO;AAAA,IACL,EAAA,EAAA,CAAK,GAAA,CAAI,CAAA,GAAI,IAAA,GAAO,CAAA,IAAK,GAAA;AAAA,IACzB,EAAA,EAAA,CAAK,GAAA,CAAI,CAAA,GAAI,IAAA,GAAO,CAAA,IAAK,GAAA;AAAA,IACzB,IAAI,IAAA,GAAO,GAAA;AAAA,IACX,IAAI,IAAA,GAAO;AAAA,GACb;AACF;AAOO,SAAS,WAAA,CACd,MAAA,EACA,QAAA,EACA,CAAA,EACA,GAAA,EACe;AACf,EAAA,KAAA,IAAS,IAAI,MAAA,CAAO,MAAA,GAAS,CAAA,EAAG,CAAA,IAAK,GAAG,CAAA,EAAA,EAAK;AAC3C,IAAA,MAAM,KAAA,GAAQ,OAAO,CAAC,CAAA;AACtB,IAAA,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MACd,MAAM,KAAA,CAAM,IAAA;AAAA,MACZ,UAAU,OAAA,CAAQ,QAAA;AAAA,MAClB,OAAA;AAAA,MACA,MAAM,KAAA,CAAM,IAAA;AAAA,MACZ,OAAO,KAAA,CAAM,KAAA;AAAA,MACb,WAAW,OAAA,CAAQ;AAAA;AAAA,GACrB,GACE,MACN,CAAA,GACE,IAAA;AAEJ,EAAA,IAAI,KAAA,EAAO;AACT,IAAA,uBACE,IAAA,CAAC,KAAA,EAAA,EAAI,GAAA,EAAK,OAAA,EAAS,WAAU,eAAA,EAC1B,QAAA,EAAA;AAAA,MAAA,QAAA;AAAA,MACA,QAAA;AAAA,MACA;AAAA,KAAA,EACH,CAAA;AAAA,EAEJ;AACA,EAAA,uBACE,IAAA,CAAA,QAAA,EAAA,EACG,QAAA,EAAA;AAAA,IAAA,QAAA;AAAA,IACA,QAAA;AAAA,IACA;AAAA,GAAA,EACH,CAAA;AAEJ","file":"index.js","sourcesContent":["import type { LoupePoint } from '@weasel-js/loupe';\nimport { centerOn } from '../canvas/camera';\nimport { screenToWorld } from '../canvas/canvasCoords';\nimport type { CanvasLayerDescriptor } from '../canvas/useLayerScheduler';\nimport { DEFAULT_FRAME, resolveFrame, type WorldFrame, type WorldSpec } from '../canvas/worldSpec';\nimport type { ViewTransform } from '../instrument/types';\n\n/** The camera a round lens of `diameter` shows a magnified region through, and\n * the coordinate system it is read in — the instrument's own `WorldSpec`,\n * resolved against the lens rather than the stack. */\nexport interface LensCamera {\n view: ViewTransform;\n frame: WorldFrame;\n}\n\n/**\n * What a lens aimed at `aim` renders the stack's layers through.\n *\n * The lens is its own viewport, so the world spec resolves against its box: an\n * instrument centred on its viewport is centred in the lens too.\n */\nexport function lensCamera(\n aim: LoupePoint,\n outer: ViewTransform,\n outerFrame: WorldFrame,\n factor: number,\n diameter: number,\n worldSpec?: WorldSpec,\n): LensCamera {\n const size = { width: diameter, height: diameter };\n const frame = resolveFrame(worldSpec, size);\n const world = screenToWorld(aim, outer, outerFrame);\n return { view: centerOn(world, outer.zoom * factor, size, frame), frame };\n}\n\n/** A rectangle in a backing store's own device pixels. */\nexport interface SourceRect {\n sx: number;\n sy: number;\n sw: number;\n sh: number;\n}\n\n/**\n * The region a pixel-mode lens copies out of a presented canvas: the `diameter\n * / factor` CSS px around `aim`, in that canvas' backing-store pixels.\n */\nexport function lensSourceRect(\n aim: LoupePoint,\n factor: number,\n diameter: number,\n dpr: number,\n): SourceRect {\n const span = diameter / factor;\n return {\n sx: (aim.x - span / 2) * dpr,\n sy: (aim.y - span / 2) * dpr,\n sw: span * dpr,\n sh: span * dpr,\n };\n}\n\n/**\n * The color a stack presents at a point: the topmost visible layer with\n * anything opaque there, or `null` when every layer is transparent — which is\n * the honest answer for a point showing nothing but the workspace behind.\n */\nexport function sampleStack(\n layers: readonly CanvasLayerDescriptor[],\n canvases: Map<string, HTMLCanvasElement>,\n p: LoupePoint,\n dpr: number,\n): string | null {\n for (let i = layers.length - 1; i >= 0; i--) {\n const layer = layers[i];\n if (!layer.visible) continue;\n const canvas = canvases.get(layer.id);\n if (!canvas) continue;\n const ctx = canvas.getContext('2d', { willReadFrequently: true });\n if (!ctx) continue;\n const x = Math.floor(p.x * dpr);\n const y = Math.floor(p.y * dpr);\n if (x < 0 || y < 0 || x >= canvas.width || y >= canvas.height) continue;\n const [r, g, b, a] = ctx.getImageData(x, y, 1, 1).data;\n if (a === 0) continue;\n return `#${[r, g, b].map((c) => c.toString(16).padStart(2, '0')).join('')}`;\n }\n return null;\n}\n\n/** Redraw the stack into a lens' own canvas. `mode` decides whether the layers\n * are re-run at the lens camera or their presented pixels are enlarged. */\nexport function drawCanvasLens(\n ctx: CanvasRenderingContext2D,\n opts: {\n aim: LoupePoint;\n factor: number;\n diameter: number;\n dpr: number;\n mode: 'vector' | 'pixel';\n outer: ViewTransform;\n outerFrame?: WorldFrame;\n worldSpec?: WorldSpec;\n layers: readonly CanvasLayerDescriptor[];\n canvases: Map<string, HTMLCanvasElement>;\n },\n): void {\n const { aim, factor, diameter, dpr, mode, outer, layers, canvases } = opts;\n ctx.save();\n ctx.setTransform(dpr, 0, 0, dpr, 0, 0);\n ctx.clearRect(0, 0, diameter, diameter);\n\n if (mode === 'pixel') {\n const { sx, sy, sw, sh } = lensSourceRect(aim, factor, diameter, dpr);\n ctx.imageSmoothingEnabled = false;\n for (const layer of layers) {\n if (!layer.visible) continue;\n const canvas = canvases.get(layer.id);\n if (!canvas || canvas.width === 0 || canvas.height === 0) continue;\n ctx.drawImage(canvas, sx, sy, sw, sh, 0, 0, diameter, diameter);\n }\n ctx.restore();\n return;\n }\n\n const lens = lensCamera(\n aim,\n outer,\n opts.outerFrame ?? DEFAULT_FRAME,\n factor,\n diameter,\n opts.worldSpec,\n );\n for (const layer of layers) {\n if (!layer.visible) continue;\n ctx.save();\n layer.render(ctx, lens.view, lens.frame);\n ctx.restore();\n }\n ctx.restore();\n}\n","import { useLatest, useVisibleRaf } from '@weasel-js/core';\nimport type { LoupeMode, LoupePoint } from '@weasel-js/loupe';\nimport { useEffect, useRef } from 'react';\nimport type { CanvasStackSurface } from '../canvas/CanvasStackContext';\nimport type { WorldFrame, WorldSpec } from '../canvas/worldSpec';\nimport type { ViewTransform } from '../instrument/types';\nimport { drawCanvasLens } from './canvasLens';\n\n/** Props for `<CanvasLoupe>`. */\nexport interface CanvasLoupeProps {\n aim: LoupePoint;\n factor: number;\n mode: LoupeMode;\n diameter: number;\n /** The stack being magnified: its layers, its pixels, and its measured box. */\n surface: CanvasStackSurface;\n view: ViewTransform;\n frame: WorldFrame;\n worldSpec?: WorldSpec;\n}\n\n/**\n * Paints a lens over a `<CanvasStack>` by re-drawing the stack's layers through\n * a zoomed camera — so the magnified content is as sharp as the original, at\n * any factor. `pixel` mode enlarges what the stack presented instead.\n */\nexport function CanvasLoupe({\n aim,\n factor,\n mode,\n diameter,\n surface,\n view,\n frame,\n worldSpec,\n}: CanvasLoupeProps) {\n const canvasRef = useRef<HTMLCanvasElement | null>(null);\n const dpr = surface.size.dpr;\n\n // Whatever the stack redraws every frame, the lens has to redraw too — an\n // instrument that animates from its own loop never re-renders this component.\n const args = { aim, factor, mode, diameter, dpr, view, frame, worldSpec, surface };\n const argsRef = useLatest(args);\n\n const loop = useVisibleRaf(\n () => {\n loop.request();\n const canvas = canvasRef.current;\n const ctx = canvas?.getContext('2d');\n const canvases = argsRef.current.surface.canvases.current;\n if (!ctx || !canvases) return;\n const a = argsRef.current;\n drawCanvasLens(ctx, {\n aim: a.aim,\n factor: a.factor,\n diameter: a.diameter,\n dpr: a.dpr,\n mode: a.mode,\n outer: a.view,\n outerFrame: a.frame,\n worldSpec: a.worldSpec,\n layers: a.surface.layers,\n canvases,\n });\n },\n { target: canvasRef },\n );\n\n useEffect(() => {\n loop.request();\n return () => loop.cancel();\n }, [loop]);\n\n return (\n <canvas\n ref={canvasRef}\n className=\"lk-loupe__canvas\"\n width={Math.max(1, Math.round(diameter * dpr))}\n height={Math.max(1, Math.round(diameter * dpr))}\n />\n );\n}\n","import type { LoupeMode, LoupePoint } from '@weasel-js/loupe';\nimport type { CSSProperties } from 'react';\nimport { zoomAt } from '../canvas/camera';\nimport type { ViewportSize, WorldFrame } from '../canvas/worldSpec';\nimport type { ViewTransform } from '../instrument/types';\nimport type { LoupeRenderArgs } from './types';\n\n/** Props for `<DomLoupe>`. */\nexport interface DomLoupeProps {\n aim: LoupePoint;\n factor: number;\n mode: LoupeMode;\n diameter: number;\n /** The host the instrument draws into, which the stage reproduces. */\n size: ViewportSize;\n /** The trial's own camera. */\n view: ViewTransform;\n frame?: WorldFrame;\n render: (args: LoupeRenderArgs) => React.ReactNode;\n}\n\n/**\n * Paints a lens over DOM content by asking its `render` to draw it again\n * at a magnified camera.\n *\n * The stage is a full copy of the host, so the instrument's own layout still\n * holds; the camera is composed about the aimed point, which keeps that point\n * where it already was, and the stage is then slid by `diameter / 2 - aim` to\n * bring it to the middle of the lens.\n */\nexport function DomLoupe({\n aim,\n factor,\n mode,\n diameter,\n size,\n view,\n frame,\n render,\n}: DomLoupeProps) {\n const style: CSSProperties = {\n width: `${size.width}px`,\n height: `${size.height}px`,\n transform: `translate(${diameter / 2 - aim.x}px, ${diameter / 2 - aim.y}px)`,\n };\n return (\n <div className=\"lk-loupe__stage\" style={style}>\n {render({\n view: zoomAt(view, factor, aim, { frame }),\n factor,\n mode,\n size,\n })}\n </div>\n );\n}\n","import type { LoupePoint } from '@weasel-js/loupe';\nimport type { CSSProperties, ReactNode, RefObject } from 'react';\n\n/** Props for `<LoupeBubble>`. */\nexport interface LoupeBubbleProps {\n /** Where the lens is aimed, in its container's own pixels. */\n aim: LoupePoint;\n diameter: number;\n hostRef?: RefObject<HTMLDivElement | null>;\n children: ReactNode;\n}\n\n/**\n * The lens itself: a circle centred on the aimed point, clipping whatever a\n * painter draws into it.\n *\n * It takes no pointer events, so the pan, the wheel and anything underneath\n * keep working while it is up — and it is `aria-hidden`, since it magnifies\n * content already on the page rather than adding any.\n */\nexport function LoupeBubble({ aim, diameter, hostRef, children }: LoupeBubbleProps) {\n const style: CSSProperties = {\n width: `${diameter}px`,\n height: `${diameter}px`,\n transform: `translate(${aim.x - diameter / 2}px, ${aim.y - diameter / 2}px)`,\n };\n return (\n <div ref={hostRef} className=\"lk-loupe\" style={style} aria-hidden=\"true\">\n {children}\n </div>\n );\n}\n","/**\n * The loupe's two bindable interactions, as `Action` descriptors the gesture\n * dispatcher routes: hold a key to peek, and walk the magnification with the\n * wheel.\n *\n * Free of React so the routing can be tested without a DOM.\n */\nimport type { Action } from '@weasel-js/core';\n\n/** Canonical id of the hold-to-peek action. */\nexport const LOUPE_PEEK_ID = 'loupe.peek';\n/** Canonical id of the wheel-magnify action. */\nexport const LOUPE_MAGNIFY_ID = 'loupe.magnify';\n\n/** How fast the wheel walks the magnification. Gentler than the pan-zoom\n * wheel: the lens' whole range is one order of magnitude. */\nexport const WHEEL_RATE = 0.002;\n\n/** What the actions do to a live loupe. Every member is read through the\n * object on each invocation, so one stable instance serves the life of the\n * registration. */\nexport interface LoupeInputApi {\n /** Whether the lens is up. The wheel belongs to the loupe only while it is;\n * otherwise `loupe.magnify` declines and the dispatcher falls through to\n * the trial camera's zoom. */\n shown: () => boolean;\n /** Raise or drop the hold-to-peek flag. */\n setPeeking: (on: boolean) => void;\n /** Multiply the magnification by one wheel notch of `deltaY`. */\n magnifyBy: (deltaY: number) => void;\n}\n\n/**\n * Build the loupe's actions. `peekKey` is a `KeyboardEvent.key`; passing\n * `null` omits `loupe.peek` entirely rather than registering a binding no key\n * can match.\n */\nexport function createLoupeActions(\n input: LoupeInputApi,\n peekKey: string | null,\n): readonly Action[] {\n const magnify: Action = {\n id: LOUPE_MAGNIFY_ID,\n label: 'Magnify (loupe)',\n group: 'loupe',\n // Hotkey scope, so while the lens is up it outranks the trial camera's\n // wheel zoom on the same dispatcher; while it is down `enabled` declines\n // and the zoom runs.\n scope: 'hotkey',\n // Every modifier optional: the lens claims the wheel whenever it is up,\n // which is what the hand-rolled capture-phase listener did. A bare spec\n // would forbid modifiers and hand Cmd+wheel back to the lab mid-peek.\n defaultBinding: [\n {\n spec: {\n kind: 'wheel',\n mods: { alt: 'optional', ctrl: 'optional', meta: 'optional', shift: 'optional' },\n },\n opts: {},\n },\n ],\n enabled: () => (input.shown() ? true : 'not-applicable'),\n invoker: {\n timing: 'immediate',\n run(_deps, params) {\n input.magnifyBy((params?.deltaY as number | undefined) ?? 0);\n },\n },\n };\n\n if (peekKey === null) return [magnify];\n\n const peek: Action = {\n id: LOUPE_PEEK_ID,\n label: 'Peek (loupe)',\n group: 'loupe',\n // Hotkey scope: peeking must beat whatever the lab's active tool binds to\n // the same key, the way every other held-key trigger does.\n scope: 'hotkey',\n // Every modifier optional because the peek key may BE one: the keydown\n // that carries `Alt` — the default — also reports `altKey: true`, and the\n // matcher forbids any modifier a spec does not name.\n defaultBinding: [\n {\n spec: {\n kind: 'key-held',\n key: peekKey,\n mods: { alt: 'optional', ctrl: 'optional', meta: 'optional', shift: 'optional' },\n },\n opts: {},\n },\n ],\n invoker: {\n timing: 'ongoing',\n start() {\n input.setPeeking(true);\n return { onEnd: () => input.setPeeking(false) };\n },\n },\n };\n return [peek, magnify];\n}\n","/**\n * Registers the loupe's actions, and mounts the gesture dispatcher on the\n * loupe's host when no camera already has one there, so the peek key and the\n * wheel route the way every other weasel binding does.\n *\n * Three of the dispatcher's four element channels are off. Only `wheel` is\n * wanted here; `contextMenu` suppresses the native menu unconditionally and\n * `ingest` makes the host a file-drop target, neither of which a lab asked\n * for by turning a magnifier on.\n */\nimport {\n type ActionsRegistry,\n type Tool,\n useActionsRegistry,\n useGestureDispatcher,\n} from '@weasel-js/core';\nimport { type RefObject, useContext, useEffect, useMemo } from 'react';\nimport { CameraContext } from '../canvas/CameraInput';\nimport { createLoupeActions, type LoupeInputApi } from './loupeActions';\n\n/** Props for `<LoupeGestures>`. */\nexport interface LoupeGesturesProps {\n /** The element the dispatcher listens on — the same one the lens tracks. */\n hostRef: RefObject<HTMLElement | null>;\n input: LoupeInputApi;\n /** `KeyboardEvent.key` for hold-to-peek, or `null` for no peek binding. */\n peekKey: string | null;\n}\n\nconst NO_TOOLS: ReadonlyMap<string, Tool> = new Map();\n\nconst CHANNELS = { pointer: false, contextMenu: false, ingest: false } as const;\n\nfunction LoupeDispatch({\n hostRef,\n input,\n peekKey,\n registry,\n ownDispatcher,\n}: LoupeGesturesProps & { registry: ActionsRegistry; ownDispatcher: boolean }) {\n const actions = useMemo(() => createLoupeActions(input, peekKey), [input, peekKey]);\n\n useEffect(() => {\n const offs = actions.map((a) => registry.register(a));\n return () => {\n for (const off of offs) off();\n };\n }, [registry, actions]);\n\n useGestureDispatcher({\n canvasRef: hostRef,\n actions: registry,\n entriesById: NO_TOOLS,\n channels: CHANNELS,\n enabled: ownDispatcher,\n });\n\n return null;\n}\n\n/**\n * The loupe's input, routed. Inside a camera (`<CanvasStack>`, `<Stage>`) its\n * actions join the camera's dispatcher, which already listens on the host;\n * elsewhere it mounts a dispatcher of its own. With no registry in scope it\n * renders nothing rather than registering actions that could never fire.\n */\nexport function LoupeGestures(props: LoupeGesturesProps) {\n const registry = useActionsRegistry();\n const camera = useContext(CameraContext);\n if (!registry) return null;\n return <LoupeDispatch {...props} registry={registry} ownDispatcher={camera === null} />;\n}\n","import type { LoupeMode } from '@weasel-js/loupe';\nimport type { ReactNode } from 'react';\nimport type { ViewportSize } from '../canvas/worldSpec';\nimport type { ViewTransform } from '../instrument/types';\n\n/** What a DOM loupe's `render` is handed: the camera to draw the content\n * through again. */\nexport interface LoupeRenderArgs {\n /** The trial's own camera composed with the magnification, about the aimed\n * point — so drawing the same content through it magnifies in place. */\n view: ViewTransform;\n /** The magnification on its own, for whatever must not scale with the\n * camera. */\n factor: number;\n mode: LoupeMode;\n /** The size of the viewport `view` is written for: the trial's content well,\n * not the lens. The lens shows a circle cut out of it. */\n size: ViewportSize;\n}\n\n/**\n * How a lens magnifies.\n *\n * With no `render`, the lens re-draws the canvas stack's layers through a\n * zoomed camera, so it stays sharp at any factor. Over DOM content, `render`\n * draws it instead: given a camera, draw me again.\n */\nexport interface LoupeOptions {\n render?: (args: LoupeRenderArgs) => ReactNode;\n /** Opening magnification, clamped to the bounds below. Default 6. */\n factor?: number;\n /** What the wheel clamps to. Defaults 2 and 32. */\n minFactor?: number;\n maxFactor?: number;\n /** `'vector'` (default) re-renders the content magnified; `'pixel'` blows up\n * the pixels the instrument presented. A `render` loupe is always vector —\n * DOM has no framebuffer to enlarge. */\n mode?: LoupeMode;\n /** Lens diameter in CSS px. Default 200. */\n diameter?: number;\n /** Held for a momentary peek while the loupe is off. Default `'Alt'`; `null`\n * turns hold-to-peek off. Matched against `KeyboardEvent.key`. */\n peekKey?: string | null;\n /** Called with the color under the aim, wherever the surface can say. The\n * canvas painter reads it back; a DOM loupe has no pixels to sample. */\n onColorChange?: (hex: string) => void;\n}\n\n/** {@link LoupeOptions} with every default filled in. */\nexport interface ResolvedLoupe {\n render?: (args: LoupeRenderArgs) => ReactNode;\n onColorChange?: (hex: string) => void;\n factor: number;\n minFactor: number;\n maxFactor: number;\n mode: LoupeMode;\n diameter: number;\n peekKey: string | null;\n}\n\n/** What `resolveLoupe` fills in for anything a declaration leaves unset. */\nexport const LOUPE_DEFAULTS = {\n factor: 6,\n minFactor: 2,\n maxFactor: 32,\n mode: 'vector',\n diameter: 200,\n peekKey: 'Alt',\n} as const satisfies Omit<ResolvedLoupe, 'render' | 'onColorChange'>;\n\n/** `options` with every default filled in and `factor` clamped to\n * `[minFactor, maxFactor]`. A loupe with its own `render` is always `'vector'`. */\nexport function resolveLoupe(options: LoupeOptions = {}): ResolvedLoupe {\n const minFactor = options.minFactor ?? LOUPE_DEFAULTS.minFactor;\n const maxFactor = options.maxFactor ?? LOUPE_DEFAULTS.maxFactor;\n return {\n render: options.render,\n onColorChange: options.onColorChange,\n minFactor,\n maxFactor,\n factor: Math.min(maxFactor, Math.max(minFactor, options.factor ?? LOUPE_DEFAULTS.factor)),\n diameter: options.diameter ?? LOUPE_DEFAULTS.diameter,\n peekKey: options.peekKey === undefined ? LOUPE_DEFAULTS.peekKey : options.peekKey,\n // A DOM loupe has no framebuffer, so `pixel` would have nothing to enlarge.\n mode: options.render ? 'vector' : (options.mode ?? LOUPE_DEFAULTS.mode),\n };\n}\n","import { type RefObject, useEffect, useState } from 'react';\nimport type { ViewportSize } from '../canvas/worldSpec';\n\nconst ZERO: ViewportSize = { width: 0, height: 0 };\n\n/** An element's CSS-pixel box, kept current. `{0, 0}` until it is measured, and\n * wherever `ResizeObserver` is absent. */\nexport function useHostSize(ref: RefObject<HTMLElement | null>): ViewportSize {\n const [size, setSize] = useState<ViewportSize>(ZERO);\n\n useEffect(() => {\n const el = ref.current;\n if (!el) return;\n const update = (): void => {\n const rect = el.getBoundingClientRect();\n setSize((prev) =>\n prev.width === rect.width && prev.height === rect.height\n ? prev\n : { width: rect.width, height: rect.height },\n );\n };\n update();\n if (typeof ResizeObserver === 'undefined') return;\n const ro = new ResizeObserver(update);\n ro.observe(el);\n return () => ro.disconnect();\n }, [ref]);\n\n return size;\n}\n","import type { View } from '@weasel-js/core';\n\n/** A point on the magnified surface, in its own CSS pixels. */\nexport interface LoupePoint {\n x: number;\n y: number;\n}\n\n/** The lens' rectangle on that surface. */\nexport interface LoupeRect extends LoupePoint {\n w: number;\n h: number;\n}\n\n/**\n * The inner `View` a loupe renders its content through: the outer view's\n * magnification times `factor`, positioned so `target` sits at the center of\n * a viewport the size of `rect`.\n */\nexport function loupeInnerView(\n target: LoupePoint,\n outer: View,\n rect: LoupeRect,\n factor: number,\n): View {\n const scale = { x: outer.scale.x * factor, y: outer.scale.y * factor };\n return {\n x: target.x - rect.w / 2 / scale.x,\n y: target.y - rect.h / 2 / scale.y,\n scale,\n };\n}\n\n/**\n * Where on the outer surface a point inside the lens is looking, in\n * screen-space CSS px.\n *\n * The inverse of {@link loupeInnerView}: the lens centers `aim` in `rect` and\n * magnifies by `factor`, and the outer view's own scale cancels out of the\n * round trip — so this needs no `View`.\n */\nexport function loupeSourcePoint(\n p: LoupePoint,\n rect: LoupeRect,\n aim: LoupePoint,\n factor: number,\n): LoupePoint {\n return {\n x: aim.x + (p.x - (rect.x + rect.w / 2)) / factor,\n y: aim.y + (p.y - (rect.y + rect.h / 2)) / factor,\n };\n}\n","import { normalizeZoom } from '@weasel-js/core';\nimport { type LoupePoint, type LoupeRect, loupeSourcePoint } from './geometry';\n\n/** How a loupe magnifies. `'vector'` re-renders the source through a zoomed-in\n * view, so content stays sharp at any factor; `'pixel'` blows up the actual\n * pixels the surface presented. */\nexport type LoupeMode = 'vector' | 'pixel';\n\n/**\n * What a loupe needs from the surface it magnifies. A painter implements it,\n * and the model asks nothing about how the lens is drawn — only where it is,\n * what colour is under a point, and whether anyone can still see it.\n */\nexport interface LoupeSurface {\n /** The lens' rectangle, or `null` while it has none. */\n lens(): LoupeRect | null;\n /**\n * Does the lens itself cover this point? A stationary lens does over its own\n * frame, which is what the freeze rule below is for; a lens that follows the\n * pointer never covers it and answers `false`.\n */\n covers(p: LoupePoint): boolean;\n /** Hex colour at a surface point, or `null` when the surface cannot say. */\n sample(p: LoupePoint): string | null;\n /** Is the lens off screen? Aims are ignored while it is. */\n hidden(): boolean;\n /** Is the lens gone for good? The model tears itself down when it is. */\n gone(): boolean;\n /** Something the painter must redraw for has changed. */\n changed(): void;\n /**\n * Run `fn` after each frame the surface lands; returns an unsubscribe.\n * Implement it when `sample` reads pixels that only show an aim once a\n * frame has painted — a framebuffer read back. The model then samples the\n * aim on the next landed frame, so `color` settles a frame after the aim.\n * Omit it when `sample` can answer for a fresh aim right away.\n */\n subscribeFrame?(fn: () => void): () => void;\n}\n\n/** Options for {@link createLoupeModel}. */\nexport interface LoupeModelOptions {\n surface: LoupeSurface;\n mode?: LoupeMode;\n /** Magnification. Default 8. Always positive and finite: a factor that is\n * not becomes `ZOOM_FLOOR`, the same rule a view's zoom follows. */\n factor?: number;\n /** Bounds `setFactor` clamps to. Unset means bounded only by that rule. */\n minFactor?: number;\n maxFactor?: number;\n /** Called with the hex colour under the aim point whenever it changes. */\n onColorChange?: (hex: string) => void;\n /** Called when a pick lands — an eyedropper on the magnified surface. Where\n * the colour goes is the consumer's business. */\n onPick?: (hex: string) => void;\n /** Called when the model tears itself down because the surface reported the\n * lens gone, so the painter can drop what it was holding. */\n onDispose?: () => void;\n}\n\n/** Where a loupe is aimed, how far it magnifies, and what colour it is over. */\nexport interface LoupeModel {\n readonly mode: LoupeMode;\n readonly factor: number;\n /** Last aimed point, in the surface's CSS px. */\n readonly aim: LoupePoint;\n /** Hex colour under the aim point. `null` until something answers. */\n readonly color: string | null;\n setMode(mode: LoupeMode): void;\n setFactor(factor: number): void;\n /** Aim at a surface point. Ignored while the lens covers it, is hidden, or\n * the model is disposed. */\n aimAt(p: LoupePoint): void;\n /** Sample what the lens shows at `p`, a point inside it, and report that to\n * `onPick`. Omit `p` to pick at the aim point. Leaves the aim, and `color`,\n * alone. */\n pick(p?: LoupePoint): string | null;\n dispose(): void;\n}\n\n/**\n * Build the loupe's model over a surface. It holds the state a magnifier has —\n * aim, factor, mode, colour — and none of the drawing.\n */\nexport function createLoupeModel(opts: LoupeModelOptions): LoupeModel {\n const { surface } = opts;\n let mode: LoupeMode = opts.mode ?? 'vector';\n let factor = normalizeZoom(opts.factor ?? 8);\n let aim: LoupePoint = { x: 0, y: 0 };\n let color: string | null = null;\n let disposed = false;\n let aimUnsampled = false;\n\n const clamp = (n: number): number =>\n normalizeZoom(Math.min(opts.maxFactor ?? Number.POSITIVE_INFINITY,\n Math.max(opts.minFactor ?? Number.NEGATIVE_INFINITY, n)));\n\n const sampleColor = () => {\n const hex = surface.sample(aim);\n if (hex === null || hex === color) return;\n color = hex;\n opts.onColorChange?.(hex);\n };\n\n const unsubscribeFrame = surface.subscribeFrame?.(() => {\n if (!aimUnsampled) return;\n aimUnsampled = false;\n sampleColor();\n });\n\n const teardown = () => {\n if (disposed) return;\n disposed = true;\n unsubscribeFrame?.();\n opts.onDispose?.();\n };\n\n return {\n get mode() { return mode; },\n get factor() { return factor; },\n get aim() { return aim; },\n get color() { return color; },\n\n setMode(next) {\n if (disposed || next === mode) return;\n mode = next;\n surface.changed();\n },\n\n setFactor(next) {\n if (disposed) return;\n factor = clamp(next);\n surface.changed();\n },\n\n aimAt(p) {\n if (disposed) return;\n // A lens can be taken away by whatever owns it, without coming back\n // through `dispose`. Follow it down rather than keep sampling for a\n // magnifier nobody can see.\n if (surface.gone()) { teardown(); return; }\n if (surface.hidden()) return;\n if (surface.covers(p)) return;\n aim = p;\n if (unsubscribeFrame) aimUnsampled = true;\n else sampleColor();\n surface.changed();\n },\n\n pick(p) {\n if (disposed) return null;\n let at = aim;\n if (p) {\n const rect = surface.lens();\n if (!rect) return null;\n at = loupeSourcePoint(p, rect, aim, factor);\n // The lens is part of the picture the surface presents. A point near\n // its frame maps back underneath it, and sampling there reports the\n // lens' own chrome as artwork.\n if (surface.covers(at)) return null;\n }\n const hex = surface.sample(at);\n if (hex !== null) opts.onPick?.(hex);\n return hex;\n },\n\n dispose: teardown,\n };\n}\n","import { useLatest } from '@weasel-js/core';\nimport {\n createLoupeModel,\n type LoupeMode,\n type LoupeModel,\n type LoupePoint,\n} from '@weasel-js/loupe';\nimport { type RefObject, useCallback, useEffect, useReducer, useRef } from 'react';\nimport type { LoupeInputApi } from './loupeActions';\nimport { WHEEL_RATE } from './loupeActions';\nimport type { ResolvedLoupe } from './types';\n\n/** Options for {@link useLoupe}. */\nexport interface UseLoupeOptions {\n options: ResolvedLoupe;\n /** The element the lens tracks the pointer across. */\n hostRef: RefObject<HTMLElement | null>;\n /** Whether the loupe is turned on. Hold-to-peek shows it regardless. */\n enabled: boolean;\n /** Hex color at a host point. Omitted, the loupe reports no color — which\n * is the honest answer for a surface with no pixels to read. */\n sample?: (p: LoupePoint) => string | null;\n}\n\n/** A loupe as a React view reads it. */\nexport interface LoupeState {\n /** Whether the lens should be drawn. */\n visible: boolean;\n /** Where it is aimed, in the host's own pixels. */\n aim: LoupePoint;\n factor: number;\n mode: LoupeMode;\n color: string | null;\n setMode: (mode: LoupeMode) => void;\n setFactor: (factor: number) => void;\n /** Sample what the lens shows at a point inside it. */\n pick: (p?: LoupePoint) => string | null;\n /** What `<LoupeGestures>` drives the lens through. Stable for the life of\n * the hook, so registering the actions on it does not churn. */\n input: LoupeInputApi;\n}\n\n/** Whether the lens is up: the pointer is over the host, and the loupe is on or peeked. */\nfunction lensShown(over: boolean, enabled: boolean, peeking: boolean): boolean {\n return over && (enabled || peeking);\n}\n\n/**\n * Binds `@weasel-js/loupe`'s model to a host element and tracks the pointer\n * across it.\n *\n * The peek key and the wheel are not here: they are `loupe.peek` and\n * `loupe.magnify`, routed through the gesture dispatcher that\n * `<LoupeGestures>` mounts on the same host. Aiming stays a plain listener\n * because a hover is not a gesture the grammar names — `GESTURE_DESCRIPTORS`\n * has no continuous-motion entry, and inventing one to carry the lens' aim\n * would be an input taxonomy change, not a loupe change.\n */\nexport function useLoupe({ options, hostRef, enabled, sample }: UseLoupeOptions): LoupeState {\n const [, bump] = useReducer((n: number) => n + 1, 0);\n\n const overRef = useRef(false);\n const peekingRef = useRef(false);\n const enabledRef = useLatest(enabled);\n const sampleRef = useLatest(sample);\n const onColorChangeRef = useLatest(options.onColorChange);\n\n // Reads nothing but refs, so it is stable and an effect may depend on it.\n const shown = useCallback(\n (): boolean => lensShown(overRef.current, enabledRef.current, peekingRef.current),\n [enabledRef],\n );\n\n const modelRef = useRef<LoupeModel | null>(null);\n if (modelRef.current === null) {\n modelRef.current = createLoupeModel({\n mode: options.mode,\n factor: options.factor,\n minFactor: options.minFactor,\n maxFactor: options.maxFactor,\n onColorChange: (hex) => onColorChangeRef.current?.(hex),\n surface: {\n lens: () => {\n const d = diameterRef.current;\n const { x, y } = modelRef.current?.aim ?? { x: 0, y: 0 };\n return { x: x - d / 2, y: y - d / 2, w: d, h: d };\n },\n // The lens follows the pointer and is painted over the host rather than\n // into it, so it is never part of the picture being magnified.\n covers: () => false,\n sample: (p) => sampleRef.current?.(p) ?? null,\n hidden: () => !shown(),\n gone: () => goneRef.current,\n changed: bump,\n },\n });\n }\n const model = modelRef.current;\n\n const diameterRef = useLatest(options.diameter);\n const goneRef = useRef(false);\n\n // The model holds no resources, and `dispose` is one-way — so unmounting only\n // reports the lens gone. Disposing here instead leaves React's mount / unmount\n // / remount in StrictMode with a permanently dead model that silently ignores\n // every aim.\n useEffect(() => {\n goneRef.current = false;\n return () => {\n goneRef.current = true;\n };\n }, []);\n\n // Turning the loupe off with the pointer still inside must put the lens away,\n // and the model only reconsiders on an aim.\n useEffect(() => {\n if (!enabled && !peekingRef.current) bump();\n }, [enabled]);\n\n useEffect(() => {\n const host = hostRef.current;\n if (!host) return;\n\n const onPointerMove = (e: PointerEvent): void => {\n overRef.current = true;\n const rect = host.getBoundingClientRect();\n model.aimAt({ x: e.clientX - rect.left, y: e.clientY - rect.top });\n if (!shown()) return;\n bump();\n };\n const onPointerLeave = (): void => {\n overRef.current = false;\n bump();\n };\n\n host.addEventListener('pointermove', onPointerMove);\n host.addEventListener('pointerleave', onPointerLeave);\n return () => {\n host.removeEventListener('pointermove', onPointerMove);\n host.removeEventListener('pointerleave', onPointerLeave);\n };\n }, [hostRef, model, shown]);\n\n const inputRef = useRef<LoupeInputApi | null>(null);\n if (inputRef.current === null) {\n inputRef.current = {\n shown,\n setPeeking: (on) => {\n if (peekingRef.current === on) return;\n peekingRef.current = on;\n bump();\n },\n magnifyBy: (deltaY) => {\n const m = modelRef.current;\n if (m) m.setFactor(m.factor * Math.exp(-deltaY * WHEEL_RATE));\n },\n };\n }\n\n return {\n // This render's `enabled`: `enabledRef` holds the last committed one.\n visible: lensShown(overRef.current, enabled, peekingRef.current),\n aim: model.aim,\n factor: model.factor,\n mode: model.mode,\n color: model.color,\n setMode: model.setMode,\n setFactor: model.setFactor,\n pick: model.pick,\n input: inputRef.current,\n };\n}\n","import { type ReactNode, type RefObject, useContext, useEffect, useMemo, useRef } from 'react';\nimport { CameraContext, CameraScope } from '../canvas/CameraInput';\nimport { CanvasStackContext } from '../canvas/CanvasStackContext';\nimport { fromCameraView } from '../canvas/cameraView';\nimport type { ViewTransform } from '../instrument/types';\nimport { LoupeSwitchContext } from '../trial/loupeSwitch';\nimport { CanvasLoupe } from './CanvasLoupe';\nimport { sampleStack } from './canvasLens';\nimport { DomLoupe } from './DomLoupe';\nimport { LoupeBubble } from './LoupeBubble';\nimport { LoupeGestures } from './LoupeGestures';\nimport { type LoupeOptions, resolveLoupe } from './types';\nimport { useHostSize } from './useHostSize';\nimport { useLoupe } from './useLoupe';\n\n/** Props for `<TrialLoupe>`. */\nexport interface TrialLoupeProps extends LoupeOptions {\n /** Whether the lens is turned on. Omitted, it follows the trial's toolbar\n * toggle, which the trial offers while a lens like this is mounted — and is\n * off outside a trial. Hold-to-peek shows it either way. */\n enabled?: boolean;\n /** The camera a `render` lens composes its magnification onto. Defaults to\n * the camera around it, and to the identity outside one. */\n view?: ViewTransform;\n /** The element the lens tracks. Defaults to the canvas stack or stage around\n * it, and outside both to a box wrapped around `children`. */\n hostRef?: RefObject<HTMLElement | null>;\n /** Content for the lens to sit over. Wrapped in a box of the lens's own only\n * when nothing around it gives the lens an element to track. */\n children?: ReactNode;\n}\n\nconst IDENTITY: ViewTransform = { zoom: 1, pan: { x: 0, y: 0 } };\n\n/**\n * A trial's magnifier, mounted by the instrument wherever its content is: in\n * a canvas instrument's `render`, a stage's `overlay`, or around DOM content.\n *\n * With no `render` inside a `<CanvasStack>`, it re-draws the stack's own\n * layers through a zoomed camera. With `render`, it asks for the content again\n * at a magnified camera.\n */\nexport function TrialLoupe({\n enabled,\n view,\n hostRef,\n children,\n render,\n factor,\n minFactor,\n maxFactor,\n mode,\n diameter,\n peekKey,\n onColorChange,\n}: TrialLoupeProps) {\n const options = useMemo(\n () =>\n resolveLoupe({\n render,\n factor,\n minFactor,\n maxFactor,\n mode,\n diameter,\n peekKey,\n onColorChange,\n }),\n [render, factor, minFactor, maxFactor, mode, diameter, peekKey, onColorChange],\n );\n\n const stack = useContext(CanvasStackContext);\n const camera = useContext(CameraContext);\n const loupeSwitch = useContext(LoupeSwitchContext);\n const surface = options.render ? undefined : stack?.surface;\n\n const ownHost = useRef<HTMLDivElement | null>(null);\n const cameraHost = useMemo<RefObject<HTMLElement | null> | null>(\n () =>\n camera\n ? {\n get current() {\n return camera.element();\n },\n }\n : null,\n [camera],\n );\n const host = surface?.element ?? hostRef ?? cameraHost ?? ownHost;\n const wraps = host === ownHost;\n\n // A lens told whether it is on has no use for the trial's toggle.\n const mount = enabled === undefined ? loupeSwitch?.mount : undefined;\n useEffect(() => mount?.(), [mount]);\n\n const sample = useMemo(() => {\n if (!surface) return undefined;\n return (p: { x: number; y: number }): string | null => {\n const canvases = surface.canvases.current;\n return canvases ? sampleStack(surface.layers, canvases, p, surface.size.dpr) : null;\n };\n }, [surface]);\n\n const loupe = useLoupe({\n options,\n hostRef: host,\n enabled: enabled ?? loupeSwitch?.on ?? false,\n sample,\n });\n const measured = useHostSize(host);\n const size = surface?.size ?? measured;\n\n // The gestures mount outside the visibility gate: hold-to-peek is what\n // raises a lens that is down, so its binding has to be live while it is.\n // In a trial they join the trial's scope, and with it the camera's\n // dispatcher; outside one, `<CameraScope>` gives them an isolated scope.\n const gestures = (\n <CameraScope>\n <LoupeGestures hostRef={host} input={loupe.input} peekKey={options.peekKey ?? null} />\n </CameraScope>\n );\n\n const lens = loupe.visible ? (\n <LoupeBubble aim={loupe.aim} diameter={options.diameter}>\n {options.render ? (\n <DomLoupe\n aim={loupe.aim}\n factor={loupe.factor}\n mode={loupe.mode}\n diameter={options.diameter}\n size={size}\n view={\n view ??\n stack?.view ??\n (camera ? fromCameraView(camera.view.get(), camera.frame) : IDENTITY)\n }\n frame={stack?.frame ?? camera?.frame}\n render={options.render}\n />\n ) : surface && stack ? (\n <CanvasLoupe\n aim={loupe.aim}\n factor={loupe.factor}\n mode={loupe.mode}\n diameter={options.diameter}\n surface={surface}\n view={stack.view}\n frame={stack.frame}\n worldSpec={surface.worldSpec}\n />\n ) : null}\n </LoupeBubble>\n ) : null;\n\n if (wraps) {\n return (\n <div ref={ownHost} className=\"lk-loupe-host\">\n {children}\n {gestures}\n {lens}\n </div>\n );\n }\n return (\n <>\n {children}\n {gestures}\n {lens}\n </>\n );\n}\n"]}
|
package/dist/overview/index.d.ts
CHANGED
|
@@ -2,10 +2,12 @@ import * as react from 'react';
|
|
|
2
2
|
import { ReactNode } from 'react';
|
|
3
3
|
import { ViewportSize } from '../canvas/index.js';
|
|
4
4
|
import { FloatingPanelProps } from '../index.js';
|
|
5
|
+
import '@weasel-js/ui';
|
|
5
6
|
import '@weasel-js/core';
|
|
6
|
-
import '../_dts/PrefsRow.d-DFpPIeIC.js';
|
|
7
7
|
import '@weasel-js/theme';
|
|
8
|
-
import '../_dts/types-
|
|
8
|
+
import '../_dts/types-BUBSIZuV.js';
|
|
9
|
+
import '@weasel-js/quantity';
|
|
10
|
+
import '@weasel-js/geom';
|
|
9
11
|
import '../_dts/types-DJ79Tg5J.js';
|
|
10
12
|
import 'windease';
|
|
11
13
|
|
package/dist/overview/index.js
CHANGED
|
@@ -1,13 +1,14 @@
|
|
|
1
|
-
import { markSvgNodes } from '../chunk-
|
|
1
|
+
import { markSvgNodes } from '../chunk-F4ACIK7Z.js';
|
|
2
2
|
import { useAnnotationsOptional } from '../chunk-3RY6WL5T.js';
|
|
3
|
-
import { FloatingPanel } from '../chunk-
|
|
4
|
-
import '../chunk-
|
|
5
|
-
import { CameraContext, fromCameraView, pointerElsewhere, usePublishPointer } from '../chunk-
|
|
6
|
-
import '../chunk-
|
|
7
|
-
import { CanvasStackContext } from '../chunk-
|
|
3
|
+
import { FloatingPanel } from '../chunk-XE5HJOPL.js';
|
|
4
|
+
import '../chunk-PMLZP7RT.js';
|
|
5
|
+
import { CameraContext, fromCameraView, pointerElsewhere, usePublishPointer } from '../chunk-VYVGVBGY.js';
|
|
6
|
+
import '../chunk-ULYYNWGP.js';
|
|
7
|
+
import { CanvasStackContext } from '../chunk-ZQIHJXP4.js';
|
|
8
8
|
import '../chunk-2YILQ7Y5.js';
|
|
9
|
-
import { serializeSvg } from '../chunk-
|
|
10
|
-
import
|
|
9
|
+
import { serializeSvg } from '../chunk-E23Q6A3Y.js';
|
|
10
|
+
import '../chunk-XVUKDSYV.js';
|
|
11
|
+
import { usePointerPosition, crosshairRects, DepRegistryProvider, ActionsProvider, ActiveToolContextProvider, useActionsRegistry, useLatest, useDepSource, minimapCenterAction, minimapPanAction, useGestureDispatcher, MINIMAP_CENTER, MINIMAP_PAN } from '@weasel-js/core';
|
|
11
12
|
import { useContext, useMemo, useRef, useLayoutEffect, useEffect, useReducer } from 'react';
|
|
12
13
|
import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
|
|
13
14
|
|
|
@@ -27,10 +28,11 @@ function localRectOf(el, camera) {
|
|
|
27
28
|
function elementOf(target) {
|
|
28
29
|
return target.ref?.current ?? null;
|
|
29
30
|
}
|
|
30
|
-
function markupOf(api, target, content) {
|
|
31
|
+
function markupOf(api, target, content, shown) {
|
|
31
32
|
const painted = api.paintedMarks(target);
|
|
32
33
|
if (painted.length === 0) return "";
|
|
33
|
-
const
|
|
34
|
+
const k = Math.min(shown.w / content.w, shown.h / content.h) || 1;
|
|
35
|
+
const nodes = painted.flatMap(({ mark, style }) => markSvgNodes(mark, style, { x: k, y: k }));
|
|
34
36
|
return serializeSvg(nodes, { viewBox: { x: 0, y: 0, width: content.w, height: content.h } });
|
|
35
37
|
}
|
|
36
38
|
function OverviewMarks({ fit, camera }) {
|
|
@@ -42,7 +44,7 @@ function OverviewMarks({ fit, camera }) {
|
|
|
42
44
|
return /* @__PURE__ */ jsx(Fragment, { children: api.targets().map((t) => {
|
|
43
45
|
const el = elementOf(t);
|
|
44
46
|
const box = el ? localRectOf(el, camera) : null;
|
|
45
|
-
const markup = box ? markupOf(api, t.id, t.content) : "";
|
|
47
|
+
const markup = box ? markupOf(api, t.id, t.content, { w: box.w * s, h: box.h * s }) : "";
|
|
46
48
|
if (!box || !markup) return null;
|
|
47
49
|
const place = {
|
|
48
50
|
["--lk-overview-mx"]: `${(box.x - fit.x) * s}px`,
|
|
@@ -123,10 +125,11 @@ function Overview({
|
|
|
123
125
|
}) {
|
|
124
126
|
const size = useMemo(() => ({ width, height }), [width, height]);
|
|
125
127
|
const content = bounds ? toLocalRect(bounds, camera.frame) : camera.content;
|
|
126
|
-
const
|
|
128
|
+
const framed = content !== null && content !== void 0;
|
|
129
|
+
const { x = 0, y = 0, width: w = 0, height: h = 0 } = content ?? {};
|
|
127
130
|
const fit = useMemo(
|
|
128
|
-
() =>
|
|
129
|
-
[
|
|
131
|
+
() => framed ? fitRect({ x, y, width: w, height: h }, size) : { x: 0, y: 0, scale: { x: 1, y: 1 } },
|
|
132
|
+
[framed, x, y, w, h, size]
|
|
130
133
|
);
|
|
131
134
|
const boxRef = useRef(null);
|
|
132
135
|
return /* @__PURE__ */ jsxs(
|
|
@@ -230,8 +233,7 @@ function OverviewDispatch({
|
|
|
230
233
|
camera
|
|
231
234
|
}) {
|
|
232
235
|
const registry = useActionsRegistry();
|
|
233
|
-
const fitRef =
|
|
234
|
-
fitRef.current = fit;
|
|
236
|
+
const fitRef = useLatest(fit);
|
|
235
237
|
const root = camera.view;
|
|
236
238
|
useDepSource("rootView", () => root);
|
|
237
239
|
useEffect(() => {
|
|
@@ -250,13 +252,13 @@ function OverviewDispatch({
|
|
|
250
252
|
y: (cy - (r?.top ?? 0)) / f.scale.y + f.y
|
|
251
253
|
};
|
|
252
254
|
},
|
|
253
|
-
[boxRef]
|
|
255
|
+
[boxRef, fitRef]
|
|
254
256
|
);
|
|
255
257
|
useGestureDispatcher({
|
|
256
258
|
canvasRef: boxRef,
|
|
257
259
|
// Always present: `OverviewInput` mounts the provider directly above.
|
|
258
260
|
actions: registry,
|
|
259
|
-
|
|
261
|
+
entriesById: TOOLS_BY_ID,
|
|
260
262
|
clientToWorld: clientToLocal,
|
|
261
263
|
keyboard: false,
|
|
262
264
|
channels: CHANNELS
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/overview/OverviewMarks.tsx","../../src/overview/TrialOverview.tsx"],"names":["jsx","useEffect"],"mappings":";;;;;;;;;;;;;AAsBA,SAAS,WAAA,CAAY,IAAiB,MAAA,EAA8C;AAClF,EAAA,MAAM,IAAA,GAAO,OAAO,OAAA,EAAQ;AAC5B,EAAA,IAAI,CAAC,MAAM,OAAO,IAAA;AAClB,EAAA,MAAM,CAAA,GAAI,GAAG,qBAAA,EAAsB;AACnC,EAAA,MAAM,CAAA,GAAI,KAAK,qBAAA,EAAsB;AACrC,EAAA,MAAM,CAAA,GAAI,MAAA,CAAO,IAAA,CAAK,GAAA,EAAI;AAC1B,EAAA,OAAO;AAAA,IACL,CAAA,EAAA,CAAI,EAAE,IAAA,GAAO,CAAA,CAAE,QAAQ,CAAA,CAAE,KAAA,CAAM,IAAI,CAAA,CAAE,CAAA;AAAA,IACrC,CAAA,EAAA,CAAI,EAAE,GAAA,GAAM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;AAAA,MACA,WAAA;AAAA,MACA,OAAA;AAAA,MACA,OAAA;AAAA,MACA,UAAA;AAAA,MACA;AAAA,KACF;AACA,IAAA,KAAA,MAAW,CAAA,IAAK,KAAA,EAAO,EAAA,CAAG,gBAAA,CAAiB,GAAG,IAAI,CAAA;AAClD,IAAA,OAAO,MAAM;AACX,MAAA,KAAA,MAAW,CAAA,IAAK,KAAA,EAAO,EAAA,CAAG,mBAAA,CAAoB,GAAG,IAAI,CAAA;AAAA,IACvD,CAAA;AAAA,EACF,CAAA,EAAG,CAAC,MAAM,CAAC,CAAA;AAEX,EAAA,OAAO,IAAA;AACT","file":"index.js","sourcesContent":["/**\n * Every annotation target's marks, drawn read-only on the overview through the\n * export's own vector path: `markSvgNodes`, then `serializeSvg`.\n */\nimport type { View } from '@weasel-js/core';\nimport { serializeSvg } from '@weasel-js/svg';\nimport { type CSSProperties, type RefObject, useEffect, useReducer } from 'react';\nimport { useAnnotationsOptional } from '../annotations/AnnotationsContext';\nimport { markSvgNodes } from '../annotations/svgNodes';\nimport type { AnnotationsApi } from '../annotations/types';\nimport type { CameraContextValue } from '../canvas/CameraInput';\n\n/** A target's box, in the camera's frame-local units. */\ninterface LocalRect {\n x: number;\n y: number;\n w: number;\n h: number;\n}\n\n/** Where `el` sits in the camera's frame-local units: its screen rect,\n * measured against the camera's element, through the camera. */\nfunction localRectOf(el: HTMLElement, camera: CameraContextValue): LocalRect | null {\n const host = camera.element();\n if (!host) return null;\n const r = el.getBoundingClientRect();\n const h = host.getBoundingClientRect();\n const v = camera.view.get();\n return {\n x: (r.left - h.left) / v.scale.x + v.x,\n y: (r.top - h.top) / v.scale.y + v.y,\n w: r.width / v.scale.x,\n h: r.height / v.scale.y,\n };\n}\n\n/** The element a target's marks sit on. The capability's targets carry their\n * `ref`; the store's type names only the half it reads. */\nfunction elementOf(target: object): HTMLElement | null {\n return (target as { ref?: RefObject<HTMLElement | null> }).ref?.current ?? null;\n}\n\nfunction markupOf(api: AnnotationsApi, target: string, content: { w: number; h: number }): string {\n const painted = api.paintedMarks(target);\n if (painted.length === 0) return '';\n const nodes = painted.flatMap(({ mark, style }) => markSvgNodes(mark, content, style));\n return serializeSvg(nodes, { viewBox: { x: 0, y: 0, width: content.w, height: content.h } });\n}\n\n/** Props for `<OverviewMarks>`. */\nexport interface OverviewMarksProps {\n fit: View;\n camera: CameraContextValue;\n}\n\n/**\n * The marks of every target in the annotations store in scope, placed where\n * each target's element sits on the stage. Draws nothing outside an annotating\n * trial, and takes no input.\n */\nexport function OverviewMarks({ fit, camera }: OverviewMarksProps) {\n const api = useAnnotationsOptional();\n const [, redraw] = useReducer((n: number) => n + 1, 0);\n useEffect(() => api?.subscribe(redraw), [api]);\n if (!api) return null;\n const s = fit.scale.x;\n return (\n <>\n {api.targets().map((t) => {\n const el = elementOf(t);\n const box = el ? localRectOf(el, camera) : null;\n const markup = box ? markupOf(api, t.id, t.content) : '';\n if (!box || !markup) return null;\n const place = {\n ['--lk-overview-mx' as string]: `${(box.x - fit.x) * s}px`,\n ['--lk-overview-my' as string]: `${(box.y - fit.y) * s}px`,\n ['--lk-overview-mw' as string]: `${box.w * s}px`,\n ['--lk-overview-mh' as string]: `${box.h * s}px`,\n } as CSSProperties;\n return (\n <div\n key={t.id}\n className=\"lk-overview__marks\"\n style={place}\n data-target={t.id}\n // biome-ignore lint/security/noDangerouslySetInnerHtml: the export's SVG serializer is the one vector path marks have; re-deriving React nodes would be a second.\n dangerouslySetInnerHTML={{ __html: markup }}\n />\n );\n })}\n </>\n );\n}\n","/**\n * `<TrialOverview>` — the whole of a trial's content at a glance, in a panel\n * that floats over the stage: the visible rect, a crosshair where the pointer\n * is on the stage, and a press or drag that moves the stage's camera there.\n *\n * It is the labkit form of core's minimap contribution: the same\n * `minimap.center` / `minimap.pan` actions, run on a dispatcher of its own with\n * the trial's camera as `rootView`, and the same crosshair geometry.\n */\nimport {\n ActionsProvider,\n ActiveToolContextProvider,\n crosshairRects,\n DepRegistryProvider,\n MINIMAP_CENTER,\n MINIMAP_PAN,\n minimapCenterAction,\n minimapPanAction,\n type Tool,\n useActionsRegistry,\n useDepSource,\n useGestureDispatcher,\n usePointerPosition,\n type View,\n type ViewApi,\n} from '@weasel-js/core';\nimport {\n type CSSProperties,\n type ReactNode,\n type RefObject,\n useContext,\n useEffect,\n useLayoutEffect,\n useMemo,\n useRef,\n} from 'react';\nimport {\n CameraContext,\n type CameraContextValue,\n pointerElsewhere,\n usePublishPointer,\n} from '../canvas/CameraInput';\nimport { CanvasStackContext } from '../canvas/CanvasStackContext';\nimport { fromCameraView } from '../canvas/cameraView';\nimport type { ViewportSize, WorldFrame } from '../canvas/worldSpec';\nimport { FloatingPanel, type FloatingPanelProps } from '../primitives/FloatingPanel';\nimport { OverviewMarks } from './OverviewMarks';\n\n/** The view id the overview publishes its pointer under. */\nexport const OVERVIEW_VIEW_ID = 'overview';\n\n/** A rect in the instrument's world. */\nexport interface OverviewBounds {\n x: number;\n y: number;\n width: number;\n height: number;\n}\n\n/** What an overview's `render` is handed. */\nexport interface OverviewRenderArgs {\n /** The content's own size in CSS pixels, at zoom 1 — lay out at this size\n * and the overview scales it to fit. */\n size: ViewportSize;\n}\n\n/** Props for `<TrialOverview>`. */\nexport interface TrialOverviewProps {\n /** The overview box, in CSS pixels. */\n width: number;\n height: number;\n /**\n * DOM content for the overview, laid out at the content's own size — for a\n * `stage` instrument, typically a lighter copy of what its `render` draws.\n * Never the instrument's own `render`: its effects would run twice. A canvas\n * instrument omits it, and the overview redraws the canvas's layers.\n */\n render?: (args: OverviewRenderArgs) => ReactNode;\n /** What to frame, in the instrument's world. Defaults to a stage's content\n * rect; a canvas instrument, whose world has no edge, names one. */\n bounds?: OverviewBounds;\n /** Panel title. */\n title?: string;\n anchor?: FloatingPanelProps['anchor'];\n persist?: string;\n className?: string;\n}\n\nconst PADDING = 6;\nconst OVERVIEW_INPUT: Tool = {\n id: 'overview',\n eligibility: { always: true },\n bindings: [\n { spec: { kind: 'pointerDown' }, actionId: MINIMAP_CENTER },\n { spec: { kind: 'drag' }, actionId: MINIMAP_PAN },\n ],\n};\nconst TOOLS_BY_ID: ReadonlyMap<string, Tool> = new Map([[OVERVIEW_INPUT.id, OVERVIEW_INPUT]]);\nconst CHANNELS = { wheel: false, pinch: false, contextMenu: false, ingest: false } as const;\n\n/** A world rect as a frame-local one. */\nfunction toLocalRect(b: OverviewBounds, frame: WorldFrame): OverviewBounds {\n if (frame.yDir === 1) return b;\n return { x: b.x, y: -(b.y + b.height), width: b.width, height: b.height };\n}\n\n/** The camera that fits `rect` into `size`, `PADDING` in from every edge. */\nfunction fitRect(rect: OverviewBounds, size: ViewportSize): View {\n const s = Math.min(\n Math.max(1, size.width - 2 * PADDING) / Math.max(rect.width, 1e-9),\n Math.max(1, size.height - 2 * PADDING) / Math.max(rect.height, 1e-9),\n );\n return {\n x: rect.x + rect.width / 2 - size.width / (2 * s),\n y: rect.y + rect.height / 2 - size.height / (2 * s),\n scale: { x: s, y: s },\n };\n}\n\n/** A canvas's 2D context sized to `size` at the device pixel ratio. */\nfunction prepare(\n canvas: HTMLCanvasElement | null,\n size: ViewportSize,\n): CanvasRenderingContext2D | null {\n const ctx = canvas?.getContext('2d') ?? null;\n if (!canvas || !ctx) return null;\n const dpr = window.devicePixelRatio || 1;\n const w = Math.round(size.width * dpr);\n const h = Math.round(size.height * dpr);\n if (canvas.width !== w) canvas.width = w;\n if (canvas.height !== h) canvas.height = h;\n ctx.setTransform(dpr, 0, 0, dpr, 0, 0);\n ctx.clearRect(0, 0, size.width, size.height);\n return ctx;\n}\n\nfunction cssVar(el: Element | null, name: string, fallback: string): string {\n if (!el) return fallback;\n return getComputedStyle(el).getPropertyValue(name).trim() || fallback;\n}\n\n/**\n * A trial's overview. Mount it from an instrument's `render` (a canvas\n * instrument) or `stage.overlay` (a DOM stage) — anywhere inside the trial's\n * camera.\n */\nexport function TrialOverview(props: TrialOverviewProps) {\n const camera = useContext(CameraContext);\n if (!camera) return null;\n return <Overview {...props} camera={camera} />;\n}\n\nfunction Overview({\n width,\n height,\n render,\n bounds,\n title = 'Overview',\n anchor = 'bottom-left',\n persist,\n className,\n camera,\n}: TrialOverviewProps & { camera: CameraContextValue }) {\n const size = useMemo(() => ({ width, height }), [width, height]);\n const content = bounds ? toLocalRect(bounds, camera.frame) : camera.content;\n const contentKey = content ? `${content.x},${content.y},${content.width},${content.height}` : '';\n // biome-ignore lint/correctness/useExhaustiveDependencies: `content` is rebuilt every render; its numbers, in `contentKey`, are what the fit depends on.\n const fit = useMemo(\n () => (content ? fitRect(content, size) : { x: 0, y: 0, scale: { x: 1, y: 1 } }),\n [contentKey, size],\n );\n const boxRef = useRef<HTMLDivElement | null>(null);\n\n return (\n <FloatingPanel\n anchor={anchor}\n className={className ? `lk-overview ${className}` : 'lk-overview'}\n {...(persist ? { persist } : {})}\n >\n <div className=\"lk-overview__title\">{title}</div>\n <div ref={boxRef} className=\"lk-overview__box\" data-no-drag style={boxVars(size)}>\n {render && content ? (\n <div className=\"lk-overview__content\" style={contentVars(fit, content)}>\n {render({ size: { width: content.width, height: content.height } })}\n </div>\n ) : null}\n {render ? null : <LayersCanvas fit={fit} size={size} frame={camera.frame} />}\n <OverviewMarks fit={fit} camera={camera} />\n <ChromeCanvas fit={fit} size={size} camera={camera} />\n <OverviewInput boxRef={boxRef} fit={fit} camera={camera} />\n </div>\n </FloatingPanel>\n );\n}\n\n// The box's size and the content's camera change with props, and a transform\n// has nowhere to live but the element's own style: set as custom properties\n// the stylesheet reads, as `<Stage>` does.\nfunction boxVars(size: ViewportSize): CSSProperties {\n return {\n ['--lk-overview-w' as string]: `${size.width}px`,\n ['--lk-overview-h' as string]: `${size.height}px`,\n } as CSSProperties;\n}\n\nfunction contentVars(fit: View, content: OverviewBounds): CSSProperties {\n const s = fit.scale.x;\n return {\n ['--lk-overview-x' as string]: `${(content.x - fit.x) * s}px`,\n ['--lk-overview-y' as string]: `${(content.y - fit.y) * s}px`,\n ['--lk-overview-zoom' as string]: String(s),\n ['--lk-overview-cw' as string]: `${content.width}px`,\n ['--lk-overview-ch' as string]: `${content.height}px`,\n } as CSSProperties;\n}\n\n/** A canvas instrument's layers, redrawn through the fit camera. */\nfunction LayersCanvas({ fit, size, frame }: { fit: View; size: ViewportSize; frame: WorldFrame }) {\n const stack = useContext(CanvasStackContext);\n const ref = useRef<HTMLCanvasElement | null>(null);\n const layers = stack?.surface?.layers;\n useLayoutEffect(() => {\n const ctx = prepare(ref.current, size);\n if (!ctx || !layers) return;\n const local: WorldFrame = { originPx: { x: 0, y: 0 }, yDir: frame.yDir };\n const view = fromCameraView(fit, local);\n for (const layer of layers) {\n if (!layer.visible || layer.id.startsWith('__lk_')) continue;\n ctx.save();\n layer.render(ctx, view, local);\n ctx.restore();\n }\n }, [layers, fit, size, frame.yDir]);\n return <canvas ref={ref} className=\"lk-overview__canvas\" />;\n}\n\n/** The visible-rect indicator and the linked crosshair. */\nfunction ChromeCanvas({\n fit,\n size,\n camera,\n}: {\n fit: View;\n size: ViewportSize;\n camera: CameraContextValue;\n}) {\n const ref = useRef<HTMLCanvasElement | null>(null);\n const pointer = usePointerPosition();\n const root = camera.view.get();\n const host = camera.view.hostSize?.() ?? null;\n // No dependency list: this renders only when the pointer or the trial's\n // camera moved, and either one moves the chrome.\n useLayoutEffect(() => {\n const ctx = prepare(ref.current, size);\n if (!ctx) return;\n const s = fit.scale.x;\n const px = (x: number, y: number) => ({ x: (x - fit.x) * s, y: (y - fit.y) * s });\n if (host) {\n const a = px(root.x, root.y);\n ctx.strokeStyle = cssVar(ref.current, '--wzl-fg', '#ffffff');\n ctx.lineWidth = 1;\n ctx.setLineDash([2, 3]);\n ctx.strokeRect(\n a.x + 0.5,\n a.y + 0.5,\n (host.width / root.scale.x) * s,\n (host.height / root.scale.y) * s,\n );\n ctx.setLineDash([]);\n }\n const world = pointerElsewhere(pointer, OVERVIEW_VIEW_ID, camera.frame);\n if (world) {\n // Back to frame-local: the map is its own inverse.\n const at = px(world.x, world.y * camera.frame.yDir);\n const { halo, bars } = crosshairRects(at.x, at.y, 1);\n ctx.fillStyle = 'rgb(0 0 0 / 60%)';\n for (const r of halo) ctx.fillRect(r.x, r.y, r.w, r.h);\n ctx.fillStyle = cssVar(ref.current, '--wzl-accent', '#4c8dff');\n for (const r of bars) ctx.fillRect(r.x, r.y, r.w, r.h);\n }\n });\n return <canvas ref={ref} className=\"lk-overview__canvas lk-overview__chrome\" />;\n}\n\n/**\n * The overview's input, on a dispatcher of its own: its actions and deps are\n * isolated from the trial's, its pointer store is shared with it.\n */\nfunction OverviewInput(props: {\n boxRef: RefObject<HTMLDivElement | null>;\n fit: View;\n camera: CameraContextValue;\n}) {\n return (\n <DepRegistryProvider>\n <ActionsProvider>\n <ActiveToolContextProvider>\n <OverviewDispatch {...props} />\n </ActiveToolContextProvider>\n </ActionsProvider>\n </DepRegistryProvider>\n );\n}\n\nfunction OverviewDispatch({\n boxRef,\n fit,\n camera,\n}: {\n boxRef: RefObject<HTMLDivElement | null>;\n fit: View;\n camera: CameraContextValue;\n}) {\n const registry = useActionsRegistry();\n const fitRef = useRef(fit);\n fitRef.current = fit;\n const root = camera.view;\n useDepSource('rootView', () => root as ViewApi);\n\n useEffect(() => {\n if (!registry) return;\n const offs = [registry.register(minimapCenterAction()), registry.register(minimapPanAction())];\n return () => {\n for (const off of offs) off();\n };\n }, [registry]);\n\n const clientToLocal = useMemo(\n () => (cx: number, cy: number) => {\n const r = boxRef.current?.getBoundingClientRect();\n const f = fitRef.current;\n return {\n x: (cx - (r?.left ?? 0)) / f.scale.x + f.x,\n y: (cy - (r?.top ?? 0)) / f.scale.y + f.y,\n };\n },\n [boxRef],\n );\n\n useGestureDispatcher({\n canvasRef: boxRef,\n // Always present: `OverviewInput` mounts the provider directly above.\n actions: registry as NonNullable<typeof registry>,\n toolsById: TOOLS_BY_ID,\n clientToWorld: clientToLocal,\n keyboard: false,\n channels: CHANNELS,\n });\n\n usePublishPointer(boxRef, clientToLocal, camera.frame, OVERVIEW_VIEW_ID);\n\n // The box sits inside the stage's element, whose own dispatcher, loupe and\n // pointer publisher would otherwise take every event that bubbles out of it.\n useEffect(() => {\n const el = boxRef.current;\n if (!el) return;\n const stop = (e: Event): void => e.stopPropagation();\n const kinds = [\n 'pointerdown',\n 'pointermove',\n 'pointerup',\n 'click',\n 'wheel',\n 'dblclick',\n 'contextmenu',\n ];\n for (const k of kinds) el.addEventListener(k, stop);\n return () => {\n for (const k of kinds) el.removeEventListener(k, stop);\n };\n }, [boxRef]);\n\n return null;\n}\n"]}
|
|
1
|
+
{"version":3,"sources":["../../src/overview/OverviewMarks.tsx","../../src/overview/TrialOverview.tsx"],"names":["jsx","useEffect"],"mappings":";;;;;;;;;;;;;;AAuBA,SAAS,WAAA,CAAY,IAAiB,MAAA,EAA8C;AAClF,EAAA,MAAM,IAAA,GAAO,OAAO,OAAA,EAAQ;AAC5B,EAAA,IAAI,CAAC,MAAM,OAAO,IAAA;AAClB,EAAA,MAAM,CAAA,GAAI,GAAG,qBAAA,EAAsB;AACnC,EAAA,MAAM,CAAA,GAAI,KAAK,qBAAA,EAAsB;AACrC,EAAA,MAAM,CAAA,GAAI,MAAA,CAAO,IAAA,CAAK,GAAA,EAAI;AAC1B,EAAA,OAAO;AAAA,IACL,CAAA,EAAA,CAAI,EAAE,IAAA,GAAO,CAAA,CAAE,QAAQ,CAAA,CAAE,KAAA,CAAM,IAAI,CAAA,CAAE,CAAA;AAAA,IACrC,CAAA,EAAA,CAAI,EAAE,GAAA,GAAM,CAAA,CAAE,OAAO,CAAA,CAAE,KAAA,CAAM,IAAI,CAAA,CAAE,CAAA;AAAA,IACnC,CAAA,EAAG,CAAA,CAAE,KAAA,GAAQ,CAAA,CAAE,KAAA,CAAM,CAAA;AAAA,IACrB,CAAA,EAAG,CAAA,CAAE,MAAA,GAAS,CAAA,CAAE,KAAA,CAAM;AAAA,GACxB;AACF;AAIA,SAAS,UAAU,MAAA,EAAoC;AACrD,EAAA,OAAQ,MAAA,CAAmD,KAAK,OAAA,I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AA,KAAmB,CAAA,CAAE,eAAA,EAAgB;AACnD,IAAA,MAAM,KAAA,GAAQ;AAAA,MACZ,aAAA;AAAA,MACA,aAAA;AAAA,MACA,WAAA;AAAA,MACA,OAAA;AAAA,MACA,OAAA;AAAA,MACA,UAAA;AAAA,MACA;AAAA,KACF;AACA,IAAA,KAAA,MAAW,CAAA,IAAK,KAAA,EAAO,EAAA,CAAG,gBAAA,CAAiB,GAAG,IAAI,CAAA;AAClD,IAAA,OAAO,MAAM;AACX,MAAA,KAAA,MAAW,CAAA,IAAK,KAAA,EAAO,EAAA,CAAG,mBAAA,CAAoB,GAAG,IAAI,CAAA;AAAA,IACvD,CAAA;AAAA,EACF,CAAA,EAAG,CAAC,MAAM,CAAC,CAAA;AAEX,EAAA,OAAO,IAAA;AACT","file":"index.js","sourcesContent":["/**\n * Every annotation target's marks, drawn read-only on the overview through the\n * export's own vector path: `markSvgNodes`, then `serializeSvg` — synchronous\n * with no `warmSvg`, since marks export nothing that loads on demand.\n */\nimport type { View } from '@weasel-js/core';\nimport { serializeSvg } from '@weasel-js/svg';\nimport { type CSSProperties, type RefObject, useEffect, useReducer } from 'react';\nimport { useAnnotationsOptional } from '../annotations/AnnotationsContext';\nimport { markSvgNodes } from '../annotations/svgNodes';\nimport type { AnnotationsApi } from '../annotations/types';\nimport type { CameraContextValue } from '../canvas/CameraInput';\n\n/** A target's box, in the camera's frame-local units. */\ninterface LocalRect {\n x: number;\n y: number;\n w: number;\n h: number;\n}\n\n/** Where `el` sits in the camera's frame-local units: its screen rect,\n * measured against the camera's element, through the camera. */\nfunction localRectOf(el: HTMLElement, camera: CameraContextValue): LocalRect | null {\n const host = camera.element();\n if (!host) return null;\n const r = el.getBoundingClientRect();\n const h = host.getBoundingClientRect();\n const v = camera.view.get();\n return {\n x: (r.left - h.left) / v.scale.x + v.x,\n y: (r.top - h.top) / v.scale.y + v.y,\n w: r.width / v.scale.x,\n h: r.height / v.scale.y,\n };\n}\n\n/** The element a target's marks sit on. The capability's targets carry their\n * `ref`; the store's type names only the half it reads. */\nfunction elementOf(target: object): HTMLElement | null {\n return (target as { ref?: RefObject<HTMLElement | null> }).ref?.current ?? null;\n}\n\nfunction markupOf(\n api: AnnotationsApi,\n target: string,\n content: { w: number; h: number },\n shown: { w: number; h: number },\n): string {\n const painted = api.paintedMarks(target);\n if (painted.length === 0) return '';\n // The document is shown at `shown` px, fitted like any SVG viewBox.\n const k = Math.min(shown.w / content.w, shown.h / content.h) || 1;\n const nodes = painted.flatMap(({ mark, style }) => markSvgNodes(mark, style, { x: k, y: k }));\n return serializeSvg(nodes, { viewBox: { x: 0, y: 0, width: content.w, height: content.h } });\n}\n\n/** Props for `<OverviewMarks>`. */\nexport interface OverviewMarksProps {\n fit: View;\n camera: CameraContextValue;\n}\n\n/**\n * The marks of every target in the annotations store in scope, placed where\n * each target's element sits on the stage. Draws nothing outside an annotating\n * trial, and takes no input.\n */\nexport function OverviewMarks({ fit, camera }: OverviewMarksProps) {\n const api = useAnnotationsOptional();\n const [, redraw] = useReducer((n: number) => n + 1, 0);\n useEffect(() => api?.subscribe(redraw), [api]);\n if (!api) return null;\n const s = fit.scale.x;\n return (\n <>\n {api.targets().map((t) => {\n const el = elementOf(t);\n const box = el ? localRectOf(el, camera) : null;\n const markup = box ? markupOf(api, t.id, t.content, { w: box.w * s, h: box.h * s }) : '';\n if (!box || !markup) return null;\n const place = {\n ['--lk-overview-mx' as string]: `${(box.x - fit.x) * s}px`,\n ['--lk-overview-my' as string]: `${(box.y - fit.y) * s}px`,\n ['--lk-overview-mw' as string]: `${box.w * s}px`,\n ['--lk-overview-mh' as string]: `${box.h * s}px`,\n } as CSSProperties;\n return (\n <div\n key={t.id}\n className=\"lk-overview__marks\"\n style={place}\n data-target={t.id}\n // biome-ignore lint/security/noDangerouslySetInnerHtml: the export's SVG serializer is the one vector path marks have; re-deriving React nodes would be a second.\n dangerouslySetInnerHTML={{ __html: markup }}\n />\n );\n })}\n </>\n );\n}\n","/**\n * `<TrialOverview>` — the whole of a trial's content at a glance, in a panel\n * that floats over the stage: the visible rect, a crosshair where the pointer\n * is on the stage, and a press or drag that moves the stage's camera there.\n *\n * It is the labkit form of core's minimap contribution: the same\n * `minimap.center` / `minimap.pan` actions, run on a dispatcher of its own with\n * the trial's camera as `rootView`, and the same crosshair geometry.\n */\nimport {\n ActionsProvider,\n ActiveToolContextProvider,\n crosshairRects,\n DepRegistryProvider,\n MINIMAP_CENTER,\n MINIMAP_PAN,\n minimapCenterAction,\n minimapPanAction,\n type Tool,\n useActionsRegistry,\n useDepSource,\n useGestureDispatcher,\n useLatest,\n usePointerPosition,\n type View,\n type ViewApi,\n} from '@weasel-js/core';\nimport {\n type CSSProperties,\n type ReactNode,\n type RefObject,\n useContext,\n useEffect,\n useLayoutEffect,\n useMemo,\n useRef,\n} from 'react';\nimport {\n CameraContext,\n type CameraContextValue,\n pointerElsewhere,\n usePublishPointer,\n} from '../canvas/CameraInput';\nimport { CanvasStackContext } from '../canvas/CanvasStackContext';\nimport { fromCameraView } from '../canvas/cameraView';\nimport type { ViewportSize, WorldFrame } from '../canvas/worldSpec';\nimport { FloatingPanel, type FloatingPanelProps } from '../primitives/FloatingPanel';\nimport { OverviewMarks } from './OverviewMarks';\n\n/** The view id the overview publishes its pointer under. */\nexport const OVERVIEW_VIEW_ID = 'overview';\n\n/** A rect in the instrument's world. */\nexport interface OverviewBounds {\n x: number;\n y: number;\n width: number;\n height: number;\n}\n\n/** What an overview's `render` is handed. */\nexport interface OverviewRenderArgs {\n /** The content's own size in CSS pixels, at zoom 1 — lay out at this size\n * and the overview scales it to fit. */\n size: ViewportSize;\n}\n\n/** Props for `<TrialOverview>`. */\nexport interface TrialOverviewProps {\n /** The overview box, in CSS pixels. */\n width: number;\n height: number;\n /**\n * DOM content for the overview, laid out at the content's own size — for a\n * `stage` instrument, typically a lighter copy of what its `render` draws.\n * Never the instrument's own `render`: its effects would run twice. A canvas\n * instrument omits it, and the overview redraws the canvas's layers.\n */\n render?: (args: OverviewRenderArgs) => ReactNode;\n /** What to frame, in the instrument's world. Defaults to a stage's content\n * rect; a canvas instrument, whose world has no edge, names one. */\n bounds?: OverviewBounds;\n /** Panel title. */\n title?: string;\n anchor?: FloatingPanelProps['anchor'];\n persist?: string;\n className?: string;\n}\n\nconst PADDING = 6;\nconst OVERVIEW_INPUT: Tool = {\n id: 'overview',\n eligibility: { always: true },\n bindings: [\n { spec: { kind: 'pointerDown' }, actionId: MINIMAP_CENTER },\n { spec: { kind: 'drag' }, actionId: MINIMAP_PAN },\n ],\n};\nconst TOOLS_BY_ID: ReadonlyMap<string, Tool> = new Map([[OVERVIEW_INPUT.id, OVERVIEW_INPUT]]);\nconst CHANNELS = { wheel: false, pinch: false, contextMenu: false, ingest: false } as const;\n\n/** A world rect as a frame-local one. */\nfunction toLocalRect(b: OverviewBounds, frame: WorldFrame): OverviewBounds {\n if (frame.yDir === 1) return b;\n return { x: b.x, y: -(b.y + b.height), width: b.width, height: b.height };\n}\n\n/** The camera that fits `rect` into `size`, `PADDING` in from every edge. */\nfunction fitRect(rect: OverviewBounds, size: ViewportSize): View {\n const s = Math.min(\n Math.max(1, size.width - 2 * PADDING) / Math.max(rect.width, 1e-9),\n Math.max(1, size.height - 2 * PADDING) / Math.max(rect.height, 1e-9),\n );\n return {\n x: rect.x + rect.width / 2 - size.width / (2 * s),\n y: rect.y + rect.height / 2 - size.height / (2 * s),\n scale: { x: s, y: s },\n };\n}\n\n/** A canvas's 2D context sized to `size` at the device pixel ratio. */\nfunction prepare(\n canvas: HTMLCanvasElement | null,\n size: ViewportSize,\n): CanvasRenderingContext2D | null {\n const ctx = canvas?.getContext('2d') ?? null;\n if (!canvas || !ctx) return null;\n const dpr = window.devicePixelRatio || 1;\n const w = Math.round(size.width * dpr);\n const h = Math.round(size.height * dpr);\n if (canvas.width !== w) canvas.width = w;\n if (canvas.height !== h) canvas.height = h;\n ctx.setTransform(dpr, 0, 0, dpr, 0, 0);\n ctx.clearRect(0, 0, size.width, size.height);\n return ctx;\n}\n\nfunction cssVar(el: Element | null, name: string, fallback: string): string {\n if (!el) return fallback;\n return getComputedStyle(el).getPropertyValue(name).trim() || fallback;\n}\n\n/**\n * A trial's overview. Mount it from an instrument's `render` (a canvas\n * instrument) or `stage.overlay` (a DOM stage) — anywhere inside the trial's\n * camera.\n */\nexport function TrialOverview(props: TrialOverviewProps) {\n const camera = useContext(CameraContext);\n if (!camera) return null;\n return <Overview {...props} camera={camera} />;\n}\n\nfunction Overview({\n width,\n height,\n render,\n bounds,\n title = 'Overview',\n anchor = 'bottom-left',\n persist,\n className,\n camera,\n}: TrialOverviewProps & { camera: CameraContextValue }) {\n const size = useMemo(() => ({ width, height }), [width, height]);\n const content = bounds ? toLocalRect(bounds, camera.frame) : camera.content;\n // `content` is rebuilt every render, so the fit keys on its numbers.\n const framed = content !== null && content !== undefined;\n const { x = 0, y = 0, width: w = 0, height: h = 0 } = content ?? {};\n const fit = useMemo(\n () =>\n framed ? fitRect({ x, y, width: w, height: h }, size) : { x: 0, y: 0, scale: { x: 1, y: 1 } },\n [framed, x, y, w, h, size],\n );\n const boxRef = useRef<HTMLDivElement | null>(null);\n\n return (\n <FloatingPanel\n anchor={anchor}\n className={className ? `lk-overview ${className}` : 'lk-overview'}\n {...(persist ? { persist } : {})}\n >\n <div className=\"lk-overview__title\">{title}</div>\n <div ref={boxRef} className=\"lk-overview__box\" data-no-drag style={boxVars(size)}>\n {render && content ? (\n <div className=\"lk-overview__content\" style={contentVars(fit, content)}>\n {render({ size: { width: content.width, height: content.height } })}\n </div>\n ) : null}\n {render ? null : <LayersCanvas fit={fit} size={size} frame={camera.frame} />}\n <OverviewMarks fit={fit} camera={camera} />\n <ChromeCanvas fit={fit} size={size} camera={camera} />\n <OverviewInput boxRef={boxRef} fit={fit} camera={camera} />\n </div>\n </FloatingPanel>\n );\n}\n\n// The box's size and the content's camera change with props, and a transform\n// has nowhere to live but the element's own style: set as custom properties\n// the stylesheet reads, as `<Stage>` does.\nfunction boxVars(size: ViewportSize): CSSProperties {\n return {\n ['--lk-overview-w' as string]: `${size.width}px`,\n ['--lk-overview-h' as string]: `${size.height}px`,\n } as CSSProperties;\n}\n\nfunction contentVars(fit: View, content: OverviewBounds): CSSProperties {\n const s = fit.scale.x;\n return {\n ['--lk-overview-x' as string]: `${(content.x - fit.x) * s}px`,\n ['--lk-overview-y' as string]: `${(content.y - fit.y) * s}px`,\n ['--lk-overview-zoom' as string]: String(s),\n ['--lk-overview-cw' as string]: `${content.width}px`,\n ['--lk-overview-ch' as string]: `${content.height}px`,\n } as CSSProperties;\n}\n\n/** A canvas instrument's layers, redrawn through the fit camera. */\nfunction LayersCanvas({ fit, size, frame }: { fit: View; size: ViewportSize; frame: WorldFrame }) {\n const stack = useContext(CanvasStackContext);\n const ref = useRef<HTMLCanvasElement | null>(null);\n const layers = stack?.surface?.layers;\n useLayoutEffect(() => {\n const ctx = prepare(ref.current, size);\n if (!ctx || !layers) return;\n const local: WorldFrame = { originPx: { x: 0, y: 0 }, yDir: frame.yDir };\n const view = fromCameraView(fit, local);\n for (const layer of layers) {\n if (!layer.visible || layer.id.startsWith('__lk_')) continue;\n ctx.save();\n layer.render(ctx, view, local);\n ctx.restore();\n }\n }, [layers, fit, size, frame.yDir]);\n return <canvas ref={ref} className=\"lk-overview__canvas\" />;\n}\n\n/** The visible-rect indicator and the linked crosshair. */\nfunction ChromeCanvas({\n fit,\n size,\n camera,\n}: {\n fit: View;\n size: ViewportSize;\n camera: CameraContextValue;\n}) {\n const ref = useRef<HTMLCanvasElement | null>(null);\n const pointer = usePointerPosition();\n const root = camera.view.get();\n const host = camera.view.hostSize?.() ?? null;\n // No dependency list: this renders only when the pointer or the trial's\n // camera moved, and either one moves the chrome.\n useLayoutEffect(() => {\n const ctx = prepare(ref.current, size);\n if (!ctx) return;\n const s = fit.scale.x;\n const px = (x: number, y: number) => ({ x: (x - fit.x) * s, y: (y - fit.y) * s });\n if (host) {\n const a = px(root.x, root.y);\n ctx.strokeStyle = cssVar(ref.current, '--wzl-fg', '#ffffff');\n ctx.lineWidth = 1;\n ctx.setLineDash([2, 3]);\n ctx.strokeRect(\n a.x + 0.5,\n a.y + 0.5,\n (host.width / root.scale.x) * s,\n (host.height / root.scale.y) * s,\n );\n ctx.setLineDash([]);\n }\n const world = pointerElsewhere(pointer, OVERVIEW_VIEW_ID, camera.frame);\n if (world) {\n // Back to frame-local: the map is its own inverse.\n const at = px(world.x, world.y * camera.frame.yDir);\n const { halo, bars } = crosshairRects(at.x, at.y, 1);\n ctx.fillStyle = 'rgb(0 0 0 / 60%)';\n for (const r of halo) ctx.fillRect(r.x, r.y, r.w, r.h);\n ctx.fillStyle = cssVar(ref.current, '--wzl-accent', '#4c8dff');\n for (const r of bars) ctx.fillRect(r.x, r.y, r.w, r.h);\n }\n });\n return <canvas ref={ref} className=\"lk-overview__canvas lk-overview__chrome\" />;\n}\n\n/**\n * The overview's input, on a dispatcher of its own: its actions and deps are\n * isolated from the trial's, its pointer store is shared with it.\n */\nfunction OverviewInput(props: {\n boxRef: RefObject<HTMLDivElement | null>;\n fit: View;\n camera: CameraContextValue;\n}) {\n return (\n <DepRegistryProvider>\n <ActionsProvider>\n <ActiveToolContextProvider>\n <OverviewDispatch {...props} />\n </ActiveToolContextProvider>\n </ActionsProvider>\n </DepRegistryProvider>\n );\n}\n\nfunction OverviewDispatch({\n boxRef,\n fit,\n camera,\n}: {\n boxRef: RefObject<HTMLDivElement | null>;\n fit: View;\n camera: CameraContextValue;\n}) {\n const registry = useActionsRegistry();\n const fitRef = useLatest(fit);\n const root = camera.view;\n useDepSource('rootView', () => root as ViewApi);\n\n useEffect(() => {\n if (!registry) return;\n const offs = [registry.register(minimapCenterAction()), registry.register(minimapPanAction())];\n return () => {\n for (const off of offs) off();\n };\n }, [registry]);\n\n const clientToLocal = useMemo(\n () => (cx: number, cy: number) => {\n const r = boxRef.current?.getBoundingClientRect();\n const f = fitRef.current;\n return {\n x: (cx - (r?.left ?? 0)) / f.scale.x + f.x,\n y: (cy - (r?.top ?? 0)) / f.scale.y + f.y,\n };\n },\n [boxRef, fitRef],\n );\n\n useGestureDispatcher({\n canvasRef: boxRef,\n // Always present: `OverviewInput` mounts the provider directly above.\n actions: registry as NonNullable<typeof registry>,\n entriesById: TOOLS_BY_ID,\n clientToWorld: clientToLocal,\n keyboard: false,\n channels: CHANNELS,\n });\n\n usePublishPointer(boxRef, clientToLocal, camera.frame, OVERVIEW_VIEW_ID);\n\n // The box sits inside the stage's element, whose own dispatcher, loupe and\n // pointer publisher would otherwise take every event that bubbles out of it.\n useEffect(() => {\n const el = boxRef.current;\n if (!el) return;\n const stop = (e: Event): void => e.stopPropagation();\n const kinds = [\n 'pointerdown',\n 'pointermove',\n 'pointerup',\n 'click',\n 'wheel',\n 'dblclick',\n 'contextmenu',\n ];\n for (const k of kinds) el.addEventListener(k, stop);\n return () => {\n for (const k of kinds) el.removeEventListener(k, stop);\n };\n }, [boxRef]);\n\n return null;\n}\n"]}
|
|
@@ -1 +1,3 @@
|
|
|
1
1
|
export { ComputeFitViewOptions, FALLBACK_FIT_VIEW, IndicatorStyle, MinimapCanvas, MinimapCanvasProps, MinimapFit, SceneViewCanvas, SceneViewCanvasProps, SceneViewDrawOne, buildSceneViewCommands, computeFitView, computeIndicatorCommand, renderSceneToCanvas } from '@weasel-js/core';
|
|
2
|
+
import '@weasel-js/quantity';
|
|
3
|
+
import '@weasel-js/ui';
|