@pibbl/core 0.0.1 → 0.0.3-alpha.85.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 +1 -1
- package/THIRD_PARTY_NOTICES.txt +81 -0
- package/dist/features/machines/animation.d.ts +64 -0
- package/dist/features/machines/animation.js +55 -0
- package/dist/features/machines/animation.js.map +7 -0
- package/dist/features/machines/animation.mjs +1 -0
- package/dist/features/machines/assign.d.ts +16 -0
- package/dist/features/machines/assign.js +15 -0
- package/dist/features/machines/assign.js.map +7 -0
- package/dist/features/machines/callback.d.ts +9 -0
- package/dist/features/machines/callback.js +7 -0
- package/dist/features/machines/callback.js.map +7 -0
- package/dist/features/machines/hook.d.ts +30 -0
- package/dist/features/machines/hook.js +37 -0
- package/dist/features/machines/hook.js.map +7 -0
- package/dist/features/machines/index.d.ts +6 -0
- package/dist/features/machines/index.js +12 -0
- package/dist/features/machines/index.js.map +7 -0
- package/dist/features/machines/index.mjs +1 -0
- package/dist/features/machines/runtime.d.ts +18 -0
- package/dist/features/machines/runtime.js +363 -0
- package/dist/features/machines/runtime.js.map +7 -0
- package/dist/features/machines/types.d.ts +164 -0
- package/dist/features/physics/2d-geometry.d.ts +3 -3
- package/dist/features/physics/2d-geometry.js.map +1 -1
- package/dist/features/physics/2d.d.ts +115 -62
- package/dist/features/physics/2d.js +59 -28
- package/dist/features/physics/2d.js.map +2 -2
- package/dist/features/physics/lib/2d/query-types.d.ts +6 -0
- package/dist/features/physics/lib/2d/runtime/controller.d.ts +7 -6
- package/dist/features/physics/lib/2d/runtime/controller.js.map +2 -2
- package/dist/features/physics/lib/2d/types.d.ts +8 -30
- package/dist/features/physics/lib/2d/world/queries.d.ts +7 -6
- package/dist/features/physics/lib/2d/world/queries.js.map +2 -2
- package/dist/features/sprites/formats/aseprite.d.ts +5 -0
- package/dist/features/sprites/formats/texture-packer.d.ts +5 -0
- package/dist/features/sprites/index.d.ts +6 -0
- package/dist/features/sprites/loader.d.ts +25 -0
- package/dist/features/sprites/model.d.ts +75 -0
- package/dist/features/sprites/sprite.d.ts +22 -0
- package/dist/features/textures/index.d.ts +12 -2
- package/dist/features/textures/index.js +33 -1
- package/dist/features/textures/index.js.map +2 -2
- package/dist/features/textures/lib/chemical-field.d.ts +56 -0
- package/dist/features/textures/lib/chemical-field.js +154 -0
- package/dist/features/textures/lib/chemical-field.js.map +7 -0
- package/dist/features/textures/lib/chemical-recipes.d.ts +119 -0
- package/dist/features/textures/lib/chemical-recipes.js +275 -0
- package/dist/features/textures/lib/chemical-recipes.js.map +7 -0
- package/dist/features/textures/lib/definitions.d.ts +3 -18
- package/dist/features/textures/lib/definitions.js +15 -20
- package/dist/features/textures/lib/definitions.js.map +2 -2
- package/dist/features/textures/lib/geometric-patterns.d.ts +149 -0
- package/dist/features/textures/lib/geometric-patterns.js +305 -0
- package/dist/features/textures/lib/geometric-patterns.js.map +7 -0
- package/dist/features/textures/lib/gray-scott.d.ts +55 -0
- package/dist/features/textures/lib/gray-scott.js +39 -0
- package/dist/features/textures/lib/gray-scott.js.map +7 -0
- package/dist/features/textures/lib/patterns.d.ts +123 -0
- package/dist/features/textures/lib/patterns.js +344 -0
- package/dist/features/textures/lib/patterns.js.map +7 -0
- package/dist/features/textures/lib/reaction-diffusion.d.ts +3 -2
- package/dist/features/textures/lib/reaction-diffusion.js +9 -20
- package/dist/features/textures/lib/reaction-diffusion.js.map +2 -2
- package/dist/features/textures/lib/simulation.d.ts +10 -4
- package/dist/features/textures/lib/simulation.js +23 -13
- package/dist/features/textures/lib/simulation.js.map +2 -2
- package/dist/features/viz/index.d.ts +79 -5
- package/dist/features/viz/index.js +145 -4
- package/dist/features/viz/index.js.map +2 -2
- package/dist/features/viz/inspection/bar.d.ts +79 -0
- package/dist/features/viz/inspection/bar.js +49 -0
- package/dist/features/viz/inspection/bar.js.map +7 -0
- package/dist/features/viz/inspection/candle.d.ts +156 -0
- package/dist/features/viz/inspection/candle.js +120 -0
- package/dist/features/viz/inspection/candle.js.map +7 -0
- package/dist/features/viz/inspection/capture-types.d.ts +65 -0
- package/dist/features/viz/inspection/capture.d.ts +16 -0
- package/dist/features/viz/inspection/capture.js +49 -0
- package/dist/features/viz/inspection/capture.js.map +7 -0
- package/dist/features/viz/inspection/handler.d.ts +36 -0
- package/dist/features/viz/inspection/handler.js +91 -0
- package/dist/features/viz/inspection/handler.js.map +7 -0
- package/dist/features/viz/inspection/ohlc-bar.d.ts +132 -0
- package/dist/features/viz/inspection/ohlc-bar.js +118 -0
- package/dist/features/viz/inspection/ohlc-bar.js.map +7 -0
- package/dist/features/viz/inspection/owned-ref.d.ts +16 -0
- package/dist/features/viz/inspection/owned-ref.js +99 -0
- package/dist/features/viz/inspection/owned-ref.js.map +7 -0
- package/dist/features/viz/inspection/painted-point.d.ts +22 -0
- package/dist/features/viz/inspection/painted-point.js +29 -0
- package/dist/features/viz/inspection/painted-point.js.map +7 -0
- package/dist/features/viz/inspection/queries.d.ts +100 -0
- package/dist/features/viz/inspection/queries.js +192 -0
- package/dist/features/viz/inspection/queries.js.map +7 -0
- package/dist/features/viz/inspection/query-types.d.ts +177 -0
- package/dist/features/viz/inspection/volume.d.ts +104 -0
- package/dist/features/viz/inspection/volume.js +95 -0
- package/dist/features/viz/inspection/volume.js.map +7 -0
- package/dist/features/viz/inspection.d.ts +19 -0
- package/dist/features/viz/inspection.js +54 -0
- package/dist/features/viz/inspection.js.map +7 -0
- package/dist/features/viz/inspection.mjs +1 -0
- package/dist/features/viz/lib/area-series.d.ts +62 -0
- package/dist/features/viz/lib/area-series.js +120 -0
- package/dist/features/viz/lib/area-series.js.map +7 -0
- package/dist/features/viz/lib/axis-labels.d.ts +2 -0
- package/dist/features/viz/lib/axis-labels.js +41 -0
- package/dist/features/viz/lib/axis-labels.js.map +7 -0
- package/dist/features/viz/lib/axis-title.d.ts +23 -0
- package/dist/features/viz/lib/axis-title.js +23 -0
- package/dist/features/viz/lib/axis-title.js.map +7 -0
- package/dist/features/viz/lib/axis.d.ts +1 -1
- package/dist/features/viz/lib/axis.js +50 -50
- package/dist/features/viz/lib/axis.js.map +2 -2
- package/dist/features/viz/lib/bar-scale.d.ts +7 -0
- package/dist/features/viz/lib/bar-scale.js +34 -0
- package/dist/features/viz/lib/bar-scale.js.map +7 -0
- package/dist/features/viz/lib/bar-series.d.ts +3 -1
- package/dist/features/viz/lib/bar-series.js +21 -5
- package/dist/features/viz/lib/bar-series.js.map +2 -2
- package/dist/features/viz/lib/baseline-series.d.ts +55 -0
- package/dist/features/viz/lib/baseline-series.js +136 -0
- package/dist/features/viz/lib/baseline-series.js.map +7 -0
- package/dist/features/viz/lib/candlestick-series.d.ts +62 -0
- package/dist/features/viz/lib/candlestick-series.js +150 -0
- package/dist/features/viz/lib/candlestick-series.js.map +7 -0
- package/dist/features/viz/lib/censored-point-series.d.ts +71 -0
- package/dist/features/viz/lib/censored-point-series.js +129 -0
- package/dist/features/viz/lib/censored-point-series.js.map +7 -0
- package/dist/features/viz/lib/chart-lines.d.ts +41 -0
- package/dist/features/viz/lib/chart-lines.js +32 -0
- package/dist/features/viz/lib/chart-lines.js.map +7 -0
- package/dist/features/viz/lib/color-context.d.ts +4 -0
- package/dist/features/viz/lib/color-context.js +41 -0
- package/dist/features/viz/lib/color-context.js.map +7 -0
- package/dist/features/viz/lib/color-math.d.ts +4 -0
- package/dist/features/viz/lib/color-math.js +31 -0
- package/dist/features/viz/lib/color-math.js.map +7 -0
- package/dist/features/viz/lib/color-types.d.ts +53 -0
- package/dist/features/viz/lib/curve-definition.d.ts +49 -0
- package/dist/features/viz/lib/curve-definition.js +148 -0
- package/dist/features/viz/lib/curve-definition.js.map +7 -0
- package/dist/features/viz/lib/diverging-color-scale.d.ts +11 -0
- package/dist/features/viz/lib/diverging-color-scale.js +51 -0
- package/dist/features/viz/lib/diverging-color-scale.js.map +7 -0
- package/dist/features/viz/lib/domain-navigation.d.ts +40 -0
- package/dist/features/viz/lib/domain-navigation.js +77 -0
- package/dist/features/viz/lib/domain-navigation.js.map +7 -0
- package/dist/features/viz/lib/editable-chart-elements.d.ts +178 -0
- package/dist/features/viz/lib/editable-chart-elements.js +733 -0
- package/dist/features/viz/lib/editable-chart-elements.js.map +7 -0
- package/dist/features/viz/lib/financial-aggregation.d.ts +127 -0
- package/dist/features/viz/lib/financial-aggregation.js +116 -0
- package/dist/features/viz/lib/financial-aggregation.js.map +7 -0
- package/dist/features/viz/lib/financial-autoscale.d.ts +64 -0
- package/dist/features/viz/lib/financial-autoscale.js +61 -0
- package/dist/features/viz/lib/financial-autoscale.js.map +7 -0
- package/dist/features/viz/lib/financial-comparison.d.ts +62 -0
- package/dist/features/viz/lib/financial-comparison.js +98 -0
- package/dist/features/viz/lib/financial-comparison.js.map +7 -0
- package/dist/features/viz/lib/financial-geometry.d.ts +77 -0
- package/dist/features/viz/lib/financial-geometry.js +67 -0
- package/dist/features/viz/lib/financial-geometry.js.map +7 -0
- package/dist/features/viz/lib/financial-indicators.d.ts +114 -0
- package/dist/features/viz/lib/financial-indicators.js +135 -0
- package/dist/features/viz/lib/financial-indicators.js.map +7 -0
- package/dist/features/viz/lib/financial-oscillators.d.ts +171 -0
- package/dist/features/viz/lib/financial-oscillators.js +265 -0
- package/dist/features/viz/lib/financial-oscillators.js.map +7 -0
- package/dist/features/viz/lib/hover-data.d.ts +1 -1
- package/dist/features/viz/lib/hover-data.js +6 -3
- package/dist/features/viz/lib/hover-data.js.map +2 -2
- package/dist/features/viz/lib/hover-types.d.ts +5 -5
- package/dist/features/viz/lib/interval-band-series.d.ts +49 -0
- package/dist/features/viz/lib/interval-band-series.js +136 -0
- package/dist/features/viz/lib/interval-band-series.js.map +7 -0
- package/dist/features/viz/lib/interval-diamond-series.d.ts +43 -0
- package/dist/features/viz/lib/interval-diamond-series.js +124 -0
- package/dist/features/viz/lib/interval-diamond-series.js.map +7 -0
- package/dist/features/viz/lib/interval-series.d.ts +79 -0
- package/dist/features/viz/lib/interval-series.js +158 -0
- package/dist/features/viz/lib/interval-series.js.map +7 -0
- package/dist/features/viz/lib/line-series.d.ts +1 -1
- package/dist/features/viz/lib/line-series.js +47 -28
- package/dist/features/viz/lib/line-series.js.map +2 -2
- package/dist/features/viz/lib/linear-scale-component.d.ts +7 -0
- package/dist/features/viz/lib/linear-scale-component.js +18 -0
- package/dist/features/viz/lib/linear-scale-component.js.map +7 -0
- package/dist/features/viz/lib/linear-scale.js +1 -1
- package/dist/features/viz/lib/linear-scale.js.map +2 -2
- package/dist/features/viz/lib/log-scale-component.d.ts +7 -0
- package/dist/features/viz/lib/log-scale-component.js +19 -0
- package/dist/features/viz/lib/log-scale-component.js.map +7 -0
- package/dist/features/viz/lib/log-scale.d.ts +2 -0
- package/dist/features/viz/lib/log-scale.js +53 -0
- package/dist/features/viz/lib/log-scale.js.map +7 -0
- package/dist/features/viz/lib/monotone-curve.d.ts +11 -0
- package/dist/features/viz/lib/monotone-curve.js +63 -0
- package/dist/features/viz/lib/monotone-curve.js.map +7 -0
- package/dist/features/viz/lib/nearest.d.ts +9 -9
- package/dist/features/viz/lib/nearest.js.map +1 -1
- package/dist/features/viz/lib/numeric-range-interpolation.d.ts +15 -0
- package/dist/features/viz/lib/numeric-range-interpolation.js +36 -0
- package/dist/features/viz/lib/numeric-range-interpolation.js.map +7 -0
- package/dist/features/viz/lib/numeric-ticks.d.ts +38 -0
- package/dist/features/viz/lib/numeric-ticks.js +54 -0
- package/dist/features/viz/lib/numeric-ticks.js.map +7 -0
- package/dist/features/viz/lib/ohlc-bar-series.d.ts +55 -0
- package/dist/features/viz/lib/ohlc-bar-series.js +168 -0
- package/dist/features/viz/lib/ohlc-bar-series.js.map +7 -0
- package/dist/features/viz/lib/paired-series.d.ts +44 -0
- package/dist/features/viz/lib/paired-series.js +93 -0
- package/dist/features/viz/lib/paired-series.js.map +7 -0
- package/dist/features/viz/lib/plot-series.js +11 -6
- package/dist/features/viz/lib/plot-series.js.map +2 -2
- package/dist/features/viz/lib/plot-types.d.ts +4 -3
- package/dist/features/viz/lib/point-scale-component.d.ts +7 -0
- package/dist/features/viz/lib/point-scale-component.js +19 -0
- package/dist/features/viz/lib/point-scale-component.js.map +7 -0
- package/dist/features/viz/lib/point-scale.d.ts +2 -0
- package/dist/features/viz/lib/point-scale.js +45 -0
- package/dist/features/viz/lib/point-scale.js.map +7 -0
- package/dist/features/viz/lib/point-series.d.ts +1 -1
- package/dist/features/viz/lib/point-series.js +36 -9
- package/dist/features/viz/lib/point-series.js.map +2 -2
- package/dist/features/viz/lib/point-types.d.ts +5 -2
- package/dist/features/viz/lib/reference-band.d.ts +16 -0
- package/dist/features/viz/lib/reference-band.js +27 -0
- package/dist/features/viz/lib/reference-band.js.map +7 -0
- package/dist/features/viz/lib/scale-adjust.js +9 -4
- package/dist/features/viz/lib/scale-adjust.js.map +2 -2
- package/dist/features/viz/lib/scale-context.d.ts +5 -4
- package/dist/features/viz/lib/scale-context.js +15 -11
- package/dist/features/viz/lib/scale-context.js.map +2 -2
- package/dist/features/viz/lib/scale-provider.d.ts +2 -0
- package/dist/features/viz/lib/scale-provider.js +13 -0
- package/dist/features/viz/lib/scale-provider.js.map +7 -0
- package/dist/features/viz/lib/scale-ticks.d.ts +5 -0
- package/dist/features/viz/lib/scale-ticks.js +64 -0
- package/dist/features/viz/lib/scale-ticks.js.map +7 -0
- package/dist/features/viz/lib/scale-view.d.ts +4 -0
- package/dist/features/viz/lib/scale-view.js +21 -0
- package/dist/features/viz/lib/scale-view.js.map +7 -0
- package/dist/features/viz/lib/sequential-color-scale.d.ts +11 -0
- package/dist/features/viz/lib/sequential-color-scale.js +49 -0
- package/dist/features/viz/lib/sequential-color-scale.js.map +7 -0
- package/dist/features/viz/lib/series-position.d.ts +12 -0
- package/dist/features/viz/lib/series-position.js +44 -0
- package/dist/features/viz/lib/series-position.js.map +7 -0
- package/dist/features/viz/lib/step-curves.d.ts +19 -0
- package/dist/features/viz/lib/step-curves.js +53 -0
- package/dist/features/viz/lib/step-curves.js.map +7 -0
- package/dist/features/viz/lib/symlog-scale-component.d.ts +7 -0
- package/dist/features/viz/lib/symlog-scale-component.js +19 -0
- package/dist/features/viz/lib/symlog-scale-component.js.map +7 -0
- package/dist/features/viz/lib/symlog-scale.d.ts +2 -0
- package/dist/features/viz/lib/symlog-scale.js +38 -0
- package/dist/features/viz/lib/symlog-scale.js.map +7 -0
- package/dist/features/viz/lib/threshold-color-scale.d.ts +43 -0
- package/dist/features/viz/lib/threshold-color-scale.js +59 -0
- package/dist/features/viz/lib/threshold-color-scale.js.map +7 -0
- package/dist/features/viz/lib/trading-time-mapping.d.ts +32 -0
- package/dist/features/viz/lib/trading-time-mapping.js +89 -0
- package/dist/features/viz/lib/trading-time-mapping.js.map +7 -0
- package/dist/features/viz/lib/trading-time-scale.d.ts +83 -0
- package/dist/features/viz/lib/trading-time-scale.js +96 -0
- package/dist/features/viz/lib/trading-time-scale.js.map +7 -0
- package/dist/features/viz/lib/trajectory-series.d.ts +71 -0
- package/dist/features/viz/lib/trajectory-series.js +111 -0
- package/dist/features/viz/lib/trajectory-series.js.map +7 -0
- package/dist/features/viz/lib/types.d.ts +114 -21
- package/dist/features/viz/lib/use-bar-scale.d.ts +8 -0
- package/dist/features/viz/lib/use-bar-scale.js +9 -0
- package/dist/features/viz/lib/use-bar-scale.js.map +7 -0
- package/dist/features/viz/lib/use-continuous-scale.d.ts +8 -0
- package/dist/features/viz/lib/use-continuous-scale.js +14 -0
- package/dist/features/viz/lib/use-continuous-scale.js.map +7 -0
- package/dist/features/viz/lib/use-linear-scale.d.ts +8 -0
- package/dist/features/viz/lib/use-linear-scale.js +9 -0
- package/dist/features/viz/lib/use-linear-scale.js.map +7 -0
- package/dist/features/viz/lib/use-log-scale.d.ts +8 -0
- package/dist/features/viz/lib/use-log-scale.js +9 -0
- package/dist/features/viz/lib/use-log-scale.js.map +7 -0
- package/dist/features/viz/lib/use-point-scale.d.ts +8 -0
- package/dist/features/viz/lib/use-point-scale.js +9 -0
- package/dist/features/viz/lib/use-point-scale.js.map +7 -0
- package/dist/features/viz/lib/use-symlog-scale.d.ts +8 -0
- package/dist/features/viz/lib/use-symlog-scale.js +9 -0
- package/dist/features/viz/lib/use-symlog-scale.js.map +7 -0
- package/dist/features/viz/lib/use-utc-scale.d.ts +8 -0
- package/dist/features/viz/lib/use-utc-scale.js +9 -0
- package/dist/features/viz/lib/use-utc-scale.js.map +7 -0
- package/dist/features/viz/lib/utc-labels.d.ts +12 -0
- package/dist/features/viz/lib/utc-labels.js +27 -0
- package/dist/features/viz/lib/utc-labels.js.map +7 -0
- package/dist/features/viz/lib/utc-scale-component.d.ts +7 -0
- package/dist/features/viz/lib/utc-scale-component.js +18 -0
- package/dist/features/viz/lib/utc-scale-component.js.map +7 -0
- package/dist/features/viz/lib/utc-scale.d.ts +21 -0
- package/dist/features/viz/lib/utc-scale.js +123 -0
- package/dist/features/viz/lib/utc-scale.js.map +7 -0
- package/dist/features/viz/lib/volume-series.d.ts +59 -0
- package/dist/features/viz/lib/volume-series.js +117 -0
- package/dist/features/viz/lib/volume-series.js.map +7 -0
- package/dist/features/viz/lib/weighted-point-series.d.ts +71 -0
- package/dist/features/viz/lib/weighted-point-series.js +169 -0
- package/dist/features/viz/lib/weighted-point-series.js.map +7 -0
- package/dist/filters/emboss-gpu.d.ts +4 -0
- package/dist/filters/emboss-gpu.js +39 -0
- package/dist/filters/emboss-gpu.js.map +7 -0
- package/dist/filters/emboss.d.ts +32 -0
- package/dist/filters/emboss.js +106 -0
- package/dist/filters/emboss.js.map +7 -0
- package/dist/filters/reflection-gpu.d.ts +3 -1
- package/dist/filters/reflection-gpu.js +5 -2
- package/dist/filters/reflection-gpu.js.map +2 -2
- package/dist/filters/render-emboss-boundary.d.ts +13 -0
- package/dist/filters/render-emboss-boundary.js +131 -0
- package/dist/filters/render-emboss-boundary.js.map +7 -0
- package/dist/filters.d.ts +2 -0
- package/dist/filters.js +2 -0
- package/dist/filters.js.map +2 -2
- package/dist/index.d.ts +3 -1
- package/dist/index.js +3 -0
- package/dist/index.js.map +2 -2
- package/dist/internal.d.ts +2 -0
- package/dist/internal.js +4 -0
- package/dist/internal.js.map +2 -2
- package/dist/lib/animation/definition.d.ts +5 -3
- package/dist/lib/animation/definition.js +29 -4
- package/dist/lib/animation/definition.js.map +2 -2
- package/dist/lib/animation/playback.d.ts +8 -0
- package/dist/lib/animation/playback.js +33 -11
- package/dist/lib/animation/playback.js.map +2 -2
- package/dist/lib/animation/spring.d.ts +3 -1
- package/dist/lib/animation/spring.js.map +2 -2
- package/dist/lib/animation/types.d.ts +29 -73
- package/dist/lib/events/event-facade.d.ts +13 -0
- package/dist/lib/events/event-facade.js +23 -0
- package/dist/lib/events/event-facade.js.map +2 -2
- package/dist/lib/events/propagation.js +19 -14
- package/dist/lib/events/propagation.js.map +2 -2
- package/dist/lib/execute-render.js +13 -0
- package/dist/lib/execute-render.js.map +2 -2
- package/dist/lib/hooks/use-animated-value.d.ts +11 -21
- package/dist/lib/hooks/use-animated-value.js +23 -70
- package/dist/lib/hooks/use-animated-value.js.map +3 -3
- package/dist/lib/hooks/use-playback.js +1 -0
- package/dist/lib/hooks/use-playback.js.map +2 -2
- package/dist/lib/recording/recording.d.ts +43 -0
- package/dist/lib/recording/recording.js +555 -0
- package/dist/lib/recording/recording.js.map +7 -0
- package/dist/lib/recording/types.d.ts +118 -0
- package/dist/lib/recording/wasm-bytes.d.ts +1 -0
- package/dist/lib/recording/wasm-bytes.js +5 -0
- package/dist/lib/recording/wasm-bytes.js.map +7 -0
- package/dist/lib/recording/worker-source.d.ts +1 -0
- package/dist/lib/recording/worker-source.js +5 -0
- package/dist/lib/recording/worker-source.js.map +7 -0
- package/dist/lib/render-transaction.d.ts +5 -2
- package/dist/lib/render-transaction.js +23 -1
- package/dist/lib/render-transaction.js.map +2 -2
- package/dist/lib/series-inspection-frame.d.ts +18 -0
- package/dist/lib/series-inspection-frame.js +70 -0
- package/dist/lib/series-inspection-frame.js.map +7 -0
- package/dist/lib/types.d.ts +6 -0
- package/package.json +27 -5
- package/dist/features/viz/lib/scale.d.ts +0 -11
- package/dist/features/viz/lib/scale.js +0 -80
- package/dist/features/viz/lib/scale.js.map +0 -7
- package/dist/features/viz/lib/use-scale.d.ts +0 -20
- package/dist/features/viz/lib/use-scale.js +0 -10
- package/dist/features/viz/lib/use-scale.js.map +0 -7
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
import {
|
|
2
|
+
borrowDispatchResource,
|
|
3
|
+
withHooksForbidden
|
|
4
|
+
} from "@pibbl/core/internal";
|
|
5
|
+
const dispatchKey = {};
|
|
6
|
+
function copyArguments(value, depth = 0) {
|
|
7
|
+
if (value === null || typeof value !== "object") return value;
|
|
8
|
+
if (depth > 2 || Object.getPrototypeOf(value) !== Object.prototype)
|
|
9
|
+
throw new TypeError(
|
|
10
|
+
"Inspection arguments must contain plain scalar options and logical points."
|
|
11
|
+
);
|
|
12
|
+
return Object.fromEntries(
|
|
13
|
+
Object.entries(value).map(([key, item]) => [
|
|
14
|
+
key,
|
|
15
|
+
copyArguments(item, depth + 1)
|
|
16
|
+
])
|
|
17
|
+
);
|
|
18
|
+
}
|
|
19
|
+
function sameArguments(a, b) {
|
|
20
|
+
if (Object.is(a, b)) return true;
|
|
21
|
+
if (!a || !b || typeof a !== "object" || typeof b !== "object") return false;
|
|
22
|
+
const aa = a, bb = b;
|
|
23
|
+
const keys = Object.keys(aa);
|
|
24
|
+
return keys.length === Object.keys(bb).length && keys.every(
|
|
25
|
+
(key) => Object.hasOwn(bb, key) && sameArguments(aa[key], bb[key])
|
|
26
|
+
);
|
|
27
|
+
}
|
|
28
|
+
function withInspection(handler) {
|
|
29
|
+
return (event) => {
|
|
30
|
+
let live = true;
|
|
31
|
+
const borrow = () => {
|
|
32
|
+
if (!live)
|
|
33
|
+
throw new Error(
|
|
34
|
+
"Inspection context has expired; use it synchronously within dispatch."
|
|
35
|
+
);
|
|
36
|
+
return borrowDispatchResource(
|
|
37
|
+
event,
|
|
38
|
+
dispatchKey,
|
|
39
|
+
() => {
|
|
40
|
+
const value = {
|
|
41
|
+
live: true,
|
|
42
|
+
renders: /* @__PURE__ */ new Map(),
|
|
43
|
+
memo: []
|
|
44
|
+
};
|
|
45
|
+
return {
|
|
46
|
+
value,
|
|
47
|
+
dispose: () => {
|
|
48
|
+
value.live = false;
|
|
49
|
+
value.renders.clear();
|
|
50
|
+
value.memo.length = 0;
|
|
51
|
+
}
|
|
52
|
+
};
|
|
53
|
+
}
|
|
54
|
+
);
|
|
55
|
+
};
|
|
56
|
+
const context = Object.freeze({
|
|
57
|
+
rendered(ref) {
|
|
58
|
+
const state = borrow();
|
|
59
|
+
if (!state.renders.has(ref)) state.renders.set(ref, ref.rendered());
|
|
60
|
+
return state.renders.get(ref);
|
|
61
|
+
},
|
|
62
|
+
request(query, rendered, options) {
|
|
63
|
+
const state = borrow();
|
|
64
|
+
const args = copyArguments(options);
|
|
65
|
+
const cached = state.memo.find(
|
|
66
|
+
(memo) => memo.query === query && memo.rendered === rendered && sameArguments(memo.options, args)
|
|
67
|
+
);
|
|
68
|
+
if (cached) return cached.result;
|
|
69
|
+
const result = withHooksForbidden(
|
|
70
|
+
"Inspection queries must be pure synchronous functions.",
|
|
71
|
+
() => query(rendered, options)
|
|
72
|
+
);
|
|
73
|
+
if (result && typeof result.then === "function")
|
|
74
|
+
throw new TypeError("Inspection queries must be synchronous.");
|
|
75
|
+
state.memo.push({ query, rendered, options: args, result });
|
|
76
|
+
return result;
|
|
77
|
+
}
|
|
78
|
+
});
|
|
79
|
+
try {
|
|
80
|
+
const result = handler(event, context);
|
|
81
|
+
if (result && typeof result.then === "function")
|
|
82
|
+
throw new TypeError("Inspection handlers must be synchronous.");
|
|
83
|
+
} finally {
|
|
84
|
+
live = false;
|
|
85
|
+
}
|
|
86
|
+
};
|
|
87
|
+
}
|
|
88
|
+
export {
|
|
89
|
+
withInspection
|
|
90
|
+
};
|
|
91
|
+
//# sourceMappingURL=handler.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../../src/features/viz/inspection/handler.ts"],
|
|
4
|
+
"sourcesContent": ["import type { PibblEvent } from \"@pibbl/core\";\nimport {\n borrowDispatchResource,\n withHooksForbidden,\n} from \"@pibbl/core/internal\";\n\n/** A mount-owned source of borrowed committed render records.\n * @see {@link InspectionContext}\n */\nexport interface InspectionRef<S> {\n /** Returns the current committed record.\n * @returns Borrowed record or undefined before paint/after disposal.\n */\n rendered(): S | undefined;\n}\n\n/** Lazy synchronous inspection; expires when its handler returns.\n * @see {@link InspectionRef}\n */\nexport interface InspectionContext {\n /** Pins one receiver's committed generation for this logical dispatch.\n * @param ref - Explicit ref identifying the mounted receiver.\n * @returns Borrowed generation or undefined before paint/after disposal.\n */\n rendered<S>(ref: InspectionRef<S>): S | undefined;\n /**\n * Executes only on demand and memoizes equal requests, including no result.\n * Options contain plain scalar fields, function identities and logical points.\n * @param query - Pure synchronous query with a stable result contract.\n * @param rendered - Committed generation pinned for this request.\n * @param options - Named query parameters; functions compare by identity.\n * @returns Query result, including undefined, reused for equal requests in dispatch.\n */\n request<S, A, R>(\n query: (rendered: S, options: A) => R,\n rendered: S,\n options: A,\n ): R;\n}\n\nconst dispatchKey = {};\ninterface Memo {\n query: unknown;\n rendered: unknown;\n options: unknown;\n result: unknown;\n}\ninterface DispatchInspection {\n live: boolean;\n renders: Map<object, unknown>;\n memo: Memo[];\n}\n\nfunction copyArguments(value: unknown, depth = 0): unknown {\n if (value === null || typeof value !== \"object\") return value;\n if (depth > 2 || Object.getPrototypeOf(value) !== Object.prototype)\n throw new TypeError(\n \"Inspection arguments must contain plain scalar options and logical points.\",\n );\n return Object.fromEntries(\n Object.entries(value).map(([key, item]) => [\n key,\n copyArguments(item, depth + 1),\n ]),\n );\n}\nfunction sameArguments(a: unknown, b: unknown): boolean {\n if (Object.is(a, b)) return true;\n if (!a || !b || typeof a !== \"object\" || typeof b !== \"object\") return false;\n const aa = a as Record<string, unknown>,\n bb = b as Record<string, unknown>;\n const keys = Object.keys(aa);\n return (\n keys.length === Object.keys(bb).length &&\n keys.every(\n (key) => Object.hasOwn(bb, key) && sameArguments(aa[key], bb[key]),\n )\n );\n}\n\n/**\n * Adapts an ordinary handler to lazy typed inspection without changing its event.\n * @param handler - Synchronous callback receiving the unchanged event and an expiring context.\n * @returns An ordinary event handler. Searches occur only on request; memo state releases at dispatch end.\n * @see {@link InspectionContext}\n */\nexport function withInspection<E extends PibblEvent>(\n handler: (event: E, context: InspectionContext) => void,\n): (event: E) => void {\n return (event) => {\n let live = true;\n const borrow = () => {\n if (!live)\n throw new Error(\n \"Inspection context has expired; use it synchronously within dispatch.\",\n );\n return borrowDispatchResource<DispatchInspection>(\n event,\n dispatchKey,\n () => {\n const value: DispatchInspection = {\n live: true,\n renders: new Map(),\n memo: [],\n };\n return {\n value,\n dispose: () => {\n value.live = false;\n value.renders.clear();\n value.memo.length = 0;\n },\n };\n },\n );\n };\n const context: InspectionContext = Object.freeze({\n rendered<S>(ref: InspectionRef<S>): S | undefined {\n const state = borrow();\n if (!state.renders.has(ref)) state.renders.set(ref, ref.rendered());\n return state.renders.get(ref) as S | undefined;\n },\n request<S, A, R>(\n query: (rendered: S, options: A) => R,\n rendered: S,\n options: A,\n ): R {\n const state = borrow();\n const args = copyArguments(options);\n const cached = state.memo.find(\n (memo) =>\n memo.query === query &&\n memo.rendered === rendered &&\n sameArguments(memo.options, args),\n );\n if (cached) return cached.result as R;\n const result = withHooksForbidden(\n \"Inspection queries must be pure synchronous functions.\",\n () => query(rendered, options),\n );\n if (result && typeof (result as { then?: unknown }).then === \"function\")\n throw new TypeError(\"Inspection queries must be synchronous.\");\n state.memo.push({ query, rendered, options: args, result });\n return result;\n },\n });\n try {\n const result = handler(event, context) as unknown;\n if (result && typeof (result as { then?: unknown }).then === \"function\")\n throw new TypeError(\"Inspection handlers must be synchronous.\");\n } finally {\n live = false;\n }\n };\n}\n"],
|
|
5
|
+
"mappings": "AACA;AAAA,EACE;AAAA,EACA;AA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AAAA,MACF;AAAA,IACF;AACA,UAAM,UAA6B,OAAO,OAAO;AAAA,MAC/C,SAAY,KAAsC;AAChD,cAAM,QAAQ,OAAO;AACrB,YAAI,CAAC,MAAM,QAAQ,IAAI,GAAG,EAAG,OAAM,QAAQ,IAAI,KAAK,IAAI,SAAS,CAAC;AAClE,eAAO,MAAM,QAAQ,IAAI,GAAG;AAAA,MAC9B;AAAA,MACA,QACE,OACA,UACA,SACG;AACH,cAAM,QAAQ,OAAO;AACrB,cAAM,OAAO,cAAc,OAAO;AAClC,cAAM,SAAS,MAAM,KAAK;AAAA,UACxB,CAAC,SACC,KAAK,UAAU,SACf,KAAK,aAAa,YAClB,cAAc,KAAK,SAAS,IAAI;AAAA,QACpC;AACA,YAAI,OAAQ,QAAO,OAAO;AAC1B,cAAM,SAAS;AAAA,UACb;AAAA,UACA,MAAM,MAAM,UAAU,OAAO;AAAA,QAC/B;AACA,YAAI,UAAU,OAAQ,OAA8B,SAAS;AAC3D,gBAAM,IAAI,UAAU,yCAAyC;AAC/D,cAAM,KAAK,KAAK,EAAE,OAAO,UAAU,SAAS,MAAM,OAAO,CAAC;AAC1D,eAAO;AAAA,MACT;AAAA,IACF,CAAC;AACD,QAAI;AACF,YAAM,SAAS,QAAQ,OAAO,OAAO;AACrC,UAAI,UAAU,OAAQ,OAA8B,SAAS;AAC3D,cAAM,IAAI,UAAU,0CAA0C;AAAA,IAClE,UAAE;AACA,aAAO;AAAA,IACT;AAAA,EACF;AACF;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
import type { OhlcBarSeriesProps } from "../lib/ohlc-bar-series.js";
|
|
2
|
+
import { type NumericPositionScale } from "../lib/series-position.js";
|
|
3
|
+
import type { ResolvedContinuousScale } from "../lib/types.js";
|
|
4
|
+
import type { NumericRenderedSeries, RenderedSeriesPoint } from "./query-types.js";
|
|
5
|
+
/** One original OHLC record and its values and geometry as evaluated during paint.
|
|
6
|
+
* @see {@link OhlcBarRenderedSeries}
|
|
7
|
+
*/
|
|
8
|
+
export interface OhlcBarObservation<D> {
|
|
9
|
+
/** Caller-owned original record. */
|
|
10
|
+
readonly datum: D;
|
|
11
|
+
/** Original source index, including skipped rows. */
|
|
12
|
+
readonly sourceIndex: number;
|
|
13
|
+
/** Evaluated UTC-millisecond timestamp. */
|
|
14
|
+
readonly time: number;
|
|
15
|
+
/** Evaluated opening value. */
|
|
16
|
+
readonly open: number;
|
|
17
|
+
/** Evaluated high value. */
|
|
18
|
+
readonly high: number;
|
|
19
|
+
/** Evaluated low value. */
|
|
20
|
+
readonly low: number;
|
|
21
|
+
/** Evaluated closing value. */
|
|
22
|
+
readonly close: number;
|
|
23
|
+
/** Closing endpoint in series-local coordinates. */ readonly anchorLocal: Readonly<RenderedSeriesPoint>;
|
|
24
|
+
/** Closing endpoint in root-logical coordinates. */ readonly anchorRoot: Readonly<RenderedSeriesPoint>;
|
|
25
|
+
/** High/low segment before world transforms. */ readonly stemLocal: Readonly<{
|
|
26
|
+
/** Horizontal center. */ x: number;
|
|
27
|
+
/** Mapped high endpoint. */ highY: number;
|
|
28
|
+
/** Mapped low endpoint. */ lowY: number;
|
|
29
|
+
}>;
|
|
30
|
+
/** Left-facing opening segment before world transforms. */ readonly openTickLocal: Readonly<{
|
|
31
|
+
/** Left endpoint. */ x1: number;
|
|
32
|
+
/** Center endpoint. */ x2: number;
|
|
33
|
+
/** Mapped opening ordinate. */ y: number;
|
|
34
|
+
}>;
|
|
35
|
+
/** Right-facing closing segment before world transforms. */ readonly closeTickLocal: Readonly<{
|
|
36
|
+
/** Center endpoint. */ x1: number;
|
|
37
|
+
/** Right endpoint. */ x2: number;
|
|
38
|
+
/** Mapped closing ordinate. */ y: number;
|
|
39
|
+
}>;
|
|
40
|
+
}
|
|
41
|
+
/** A nearest-time OHLC candidate with committed clip eligibility.
|
|
42
|
+
* @see {@link nearestRecordedOhlcBarX}
|
|
43
|
+
*/
|
|
44
|
+
export interface OhlcBarInspectionCandidate<D> extends OhlcBarObservation<D> {
|
|
45
|
+
/** @returns Whether the close anchor lies inside every committed clip. */
|
|
46
|
+
anchorInsideClips(): boolean;
|
|
47
|
+
}
|
|
48
|
+
/** Original OHLC selected by nearest timestamp.
|
|
49
|
+
* @see {@link nearestRecordedOhlcBarX}
|
|
50
|
+
*/
|
|
51
|
+
export interface NearestOhlcBarHit<D> extends OhlcBarObservation<D> {
|
|
52
|
+
/** Absolute UTC-millisecond distance from the requested timestamp. */
|
|
53
|
+
readonly timeDelta: number;
|
|
54
|
+
}
|
|
55
|
+
/** An actual painted OHLC stroke segment covering a root-logical point.
|
|
56
|
+
* @see {@link paintedOhlcBarAt}
|
|
57
|
+
*/
|
|
58
|
+
export interface PaintedOhlcBarHit<D> extends OhlcBarObservation<D> {
|
|
59
|
+
/** Last painted matching segment. */
|
|
60
|
+
readonly part: "stem" | "openTick" | "closeTick";
|
|
61
|
+
}
|
|
62
|
+
/** @internal Local OHLC paint capture. */
|
|
63
|
+
export interface CapturedOhlcBarMark<D> extends Omit<OhlcBarObservation<D>, "anchorRoot"> {
|
|
64
|
+
readonly strokeWidthLocal: number;
|
|
65
|
+
}
|
|
66
|
+
/** Borrowed committed OHLC generation.
|
|
67
|
+
* @see {@link OhlcBarInspectionRef}
|
|
68
|
+
*/
|
|
69
|
+
export interface OhlcBarRenderedSeries<D> {
|
|
70
|
+
/** Captured original observations in source order. */
|
|
71
|
+
readonly observations: readonly OhlcBarObservation<D>[];
|
|
72
|
+
/** Throws after replacement or disposal. */
|
|
73
|
+
assertLive(): void;
|
|
74
|
+
/** Inverts a root-logical point to a timestamp.
|
|
75
|
+
* @param pointRoot - Root-logical point.
|
|
76
|
+
* @returns Timestamp, or undefined for a singular transform.
|
|
77
|
+
*/
|
|
78
|
+
timeAtRoot(pointRoot: Readonly<RenderedSeriesPoint>): number | undefined;
|
|
79
|
+
/** Tests a local point against every committed clip.
|
|
80
|
+
* @param pointLocal - Series-local point.
|
|
81
|
+
* @returns Whether every committed clip contains it.
|
|
82
|
+
*/
|
|
83
|
+
anchorInsideClips(pointLocal: Readonly<RenderedSeriesPoint>): boolean;
|
|
84
|
+
/** @internal */ readonly marks: readonly CapturedOhlcBarMark<D>[];
|
|
85
|
+
/** @internal */ readonly numeric: NumericRenderedSeries<D>;
|
|
86
|
+
/** @internal Converts a root-logical point to local geometry.
|
|
87
|
+
* @param point - Root-logical coordinate.
|
|
88
|
+
* @returns Local coordinate, or undefined for a singular transform.
|
|
89
|
+
*/ localAtRoot(point: Readonly<RenderedSeriesPoint>): Readonly<RenderedSeriesPoint> | undefined;
|
|
90
|
+
}
|
|
91
|
+
/** Mount-owned optional OHLC bar receiver.
|
|
92
|
+
* @see {@link useOhlcBarInspection}
|
|
93
|
+
*/
|
|
94
|
+
export interface OhlcBarInspectionRef<D> {
|
|
95
|
+
/** @returns Current borrowed generation, or undefined before paint and after disposal. */
|
|
96
|
+
rendered(): OhlcBarRenderedSeries<D> | undefined;
|
|
97
|
+
/** @internal Records completed local paint without querying.
|
|
98
|
+
* @param input - Captured marks and committed mappings.
|
|
99
|
+
*/ capture(input: {
|
|
100
|
+
/** Local marks in source order. */
|
|
101
|
+
marks: readonly CapturedOhlcBarMark<D>[];
|
|
102
|
+
/** Committed horizontal mapping. */
|
|
103
|
+
xScale: NumericPositionScale;
|
|
104
|
+
/** Committed price mapping. */
|
|
105
|
+
yScale: ResolvedContinuousScale;
|
|
106
|
+
}): void;
|
|
107
|
+
}
|
|
108
|
+
/** Creates a stable OHLC-bar inspection ref without reading data or subscribing.
|
|
109
|
+
* @param _inputs - Inputs retained only to infer the original datum type.
|
|
110
|
+
* @returns A ref for exactly one OhlcBarSeries inspection prop.
|
|
111
|
+
* @see {@link OhlcBarInspectionRef}
|
|
112
|
+
*/
|
|
113
|
+
export declare function useOhlcBarInspection<D>(_inputs: Pick<OhlcBarSeriesProps<D>, "data" | "time" | "open" | "high" | "low" | "close">): OhlcBarInspectionRef<D>;
|
|
114
|
+
/** Selects captured original OHLC by nearest timestamp, retaining source-order ties.
|
|
115
|
+
* @param rendered - Borrowed committed OHLC generation.
|
|
116
|
+
* @param options - Timestamp and optional pure candidate filter.
|
|
117
|
+
* @returns First source-order match on a tie, or undefined when none qualifies.
|
|
118
|
+
* @see {@link NearestOhlcBarHit}
|
|
119
|
+
*/
|
|
120
|
+
export declare function nearestRecordedOhlcBarX<D>(rendered: OhlcBarRenderedSeries<D>, options: {
|
|
121
|
+
time: number;
|
|
122
|
+
filter?: (observation: OhlcBarInspectionCandidate<D>) => boolean;
|
|
123
|
+
}): NearestOhlcBarHit<D> | undefined;
|
|
124
|
+
/** Finds the last-painted OHLC segment covering a root-logical point.
|
|
125
|
+
* @param rendered - Borrowed committed OHLC generation.
|
|
126
|
+
* @param options - Root-logical point; clips and singular transforms produce no result.
|
|
127
|
+
* @returns Captured OHLC record and painted segment, or undefined for gaps.
|
|
128
|
+
* @see {@link PaintedOhlcBarHit}
|
|
129
|
+
*/
|
|
130
|
+
export declare function paintedOhlcBarAt<D>(rendered: OhlcBarRenderedSeries<D>, options: {
|
|
131
|
+
rootPoint: Readonly<RenderedSeriesPoint>;
|
|
132
|
+
}): PaintedOhlcBarHit<D> | undefined;
|
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
import {
|
|
2
|
+
invertNumericPosition
|
|
3
|
+
} from "../lib/series-position.js";
|
|
4
|
+
import { useRenderedRef } from "./owned-ref.js";
|
|
5
|
+
import { nearestRecordedX } from "./queries.js";
|
|
6
|
+
function useOhlcBarInspection(_inputs) {
|
|
7
|
+
return useRenderedRef("ohlcBarInspection", (candidate, geometry) => {
|
|
8
|
+
const observations = Object.freeze(
|
|
9
|
+
candidate.marks.map(
|
|
10
|
+
(mark) => Object.freeze({
|
|
11
|
+
datum: mark.datum,
|
|
12
|
+
sourceIndex: mark.sourceIndex,
|
|
13
|
+
time: mark.time,
|
|
14
|
+
open: mark.open,
|
|
15
|
+
high: mark.high,
|
|
16
|
+
low: mark.low,
|
|
17
|
+
close: mark.close,
|
|
18
|
+
anchorLocal: mark.anchorLocal,
|
|
19
|
+
anchorRoot: geometry.rootAtLocal(mark.anchorLocal),
|
|
20
|
+
stemLocal: mark.stemLocal,
|
|
21
|
+
openTickLocal: mark.openTickLocal,
|
|
22
|
+
closeTickLocal: mark.closeTickLocal
|
|
23
|
+
})
|
|
24
|
+
)
|
|
25
|
+
);
|
|
26
|
+
const numeric = Object.freeze({
|
|
27
|
+
observations: Object.freeze(
|
|
28
|
+
observations.map(
|
|
29
|
+
(row) => Object.freeze({
|
|
30
|
+
...row,
|
|
31
|
+
domainX: row.time,
|
|
32
|
+
domainY: row.close,
|
|
33
|
+
run: 0
|
|
34
|
+
})
|
|
35
|
+
)
|
|
36
|
+
),
|
|
37
|
+
assertLive: geometry.assertLive,
|
|
38
|
+
domainXAtRoot(point) {
|
|
39
|
+
const local = geometry.localAtRoot(point);
|
|
40
|
+
return local ? invertNumericPosition(candidate.xScale, local.x) : void 0;
|
|
41
|
+
},
|
|
42
|
+
anchorInsideClips: geometry.anchorInsideClips,
|
|
43
|
+
anchorAtDomain(point) {
|
|
44
|
+
geometry.assertLive();
|
|
45
|
+
const anchorLocal = Object.freeze({
|
|
46
|
+
x: candidate.xScale.map(point.domainX),
|
|
47
|
+
y: candidate.yScale.map(point.domainY)
|
|
48
|
+
});
|
|
49
|
+
return Object.freeze({
|
|
50
|
+
anchorLocal,
|
|
51
|
+
anchorRoot: geometry.rootAtLocal(anchorLocal)
|
|
52
|
+
});
|
|
53
|
+
}
|
|
54
|
+
});
|
|
55
|
+
return Object.freeze({
|
|
56
|
+
observations,
|
|
57
|
+
marks: Object.freeze(candidate.marks.slice()),
|
|
58
|
+
numeric,
|
|
59
|
+
assertLive: geometry.assertLive,
|
|
60
|
+
localAtRoot: geometry.localAtRoot,
|
|
61
|
+
anchorInsideClips: geometry.anchorInsideClips,
|
|
62
|
+
timeAtRoot: numeric.domainXAtRoot
|
|
63
|
+
});
|
|
64
|
+
});
|
|
65
|
+
}
|
|
66
|
+
function nearestRecordedOhlcBarX(rendered, options) {
|
|
67
|
+
const hit = nearestRecordedX(rendered.numeric, {
|
|
68
|
+
domainX: options.time,
|
|
69
|
+
filter: options.filter ? (candidate) => options.filter(
|
|
70
|
+
candidate
|
|
71
|
+
) : void 0
|
|
72
|
+
});
|
|
73
|
+
if (!hit) return void 0;
|
|
74
|
+
const row = rendered.observations.find(
|
|
75
|
+
(observation) => observation.sourceIndex === hit.sourceIndex
|
|
76
|
+
);
|
|
77
|
+
return Object.freeze({ ...row, timeDelta: hit.domainDelta });
|
|
78
|
+
}
|
|
79
|
+
function segmentCovers(point, segment, strokeWidth) {
|
|
80
|
+
if (strokeWidth <= 0) return false;
|
|
81
|
+
const half = strokeWidth / 2;
|
|
82
|
+
return point.x >= Math.min(segment.x1, segment.x2) && point.x <= Math.max(segment.x1, segment.x2) && point.y >= segment.y - half && point.y <= segment.y + half;
|
|
83
|
+
}
|
|
84
|
+
function stemCovers(point, stem, strokeWidth) {
|
|
85
|
+
return segmentCovers(point, { x1: stem.x, x2: stem.x, y: 0 }, 0) || strokeWidth > 0 && point.x >= stem.x - strokeWidth / 2 && point.x <= stem.x + strokeWidth / 2 && point.y >= Math.min(stem.highY, stem.lowY) && point.y <= Math.max(stem.highY, stem.lowY);
|
|
86
|
+
}
|
|
87
|
+
function paintedOhlcBarAt(rendered, options) {
|
|
88
|
+
rendered.assertLive();
|
|
89
|
+
if (!Number.isFinite(options.rootPoint.x) || !Number.isFinite(options.rootPoint.y))
|
|
90
|
+
throw new RangeError("paintedOhlcBarAt rootPoint must be finite.");
|
|
91
|
+
const point = rendered.localAtRoot(options.rootPoint);
|
|
92
|
+
if (!point || !rendered.anchorInsideClips(point)) return void 0;
|
|
93
|
+
for (let index = rendered.marks.length - 1; index >= 0; index--) {
|
|
94
|
+
const mark = rendered.marks[index];
|
|
95
|
+
if (segmentCovers(point, mark.closeTickLocal, mark.strokeWidthLocal))
|
|
96
|
+
return Object.freeze({
|
|
97
|
+
...rendered.observations[index],
|
|
98
|
+
part: "closeTick"
|
|
99
|
+
});
|
|
100
|
+
if (segmentCovers(point, mark.openTickLocal, mark.strokeWidthLocal))
|
|
101
|
+
return Object.freeze({
|
|
102
|
+
...rendered.observations[index],
|
|
103
|
+
part: "openTick"
|
|
104
|
+
});
|
|
105
|
+
if (stemCovers(point, mark.stemLocal, mark.strokeWidthLocal))
|
|
106
|
+
return Object.freeze({
|
|
107
|
+
...rendered.observations[index],
|
|
108
|
+
part: "stem"
|
|
109
|
+
});
|
|
110
|
+
}
|
|
111
|
+
return void 0;
|
|
112
|
+
}
|
|
113
|
+
export {
|
|
114
|
+
nearestRecordedOhlcBarX,
|
|
115
|
+
paintedOhlcBarAt,
|
|
116
|
+
useOhlcBarInspection
|
|
117
|
+
};
|
|
118
|
+
//# sourceMappingURL=ohlc-bar.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../../src/features/viz/inspection/ohlc-bar.ts"],
|
|
4
|
+
"sourcesContent": ["import type { OhlcBarSeriesProps } from \"../lib/ohlc-bar-series.js\";\nimport {\n invertNumericPosition,\n type NumericPositionScale,\n} from \"../lib/series-position.js\";\nimport type { ResolvedContinuousScale } from \"../lib/types.js\";\nimport { useRenderedRef } from \"./owned-ref.js\";\nimport { nearestRecordedX } from \"./queries.js\";\nimport type {\n NumericRenderedSeries,\n RenderedSeriesPoint,\n} from \"./query-types.js\";\n\n/** One original OHLC record and its values and geometry as evaluated during paint.\n * @see {@link OhlcBarRenderedSeries}\n */\nexport interface OhlcBarObservation<D> {\n /** Caller-owned original record. */\n readonly datum: D;\n /** Original source index, including skipped rows. */\n readonly sourceIndex: number;\n /** Evaluated UTC-millisecond timestamp. */\n readonly time: number;\n /** Evaluated opening value. */\n readonly open: number;\n /** Evaluated high value. */\n readonly high: number;\n /** Evaluated low value. */\n readonly low: number;\n /** Evaluated closing value. */\n readonly close: number;\n /** Closing endpoint in series-local coordinates. */ readonly anchorLocal: Readonly<RenderedSeriesPoint>;\n /** Closing endpoint in root-logical coordinates. */ readonly anchorRoot: Readonly<RenderedSeriesPoint>;\n /** High/low segment before world transforms. */ readonly stemLocal: Readonly<{\n /** Horizontal center. */ x: number;\n /** Mapped high endpoint. */ highY: number;\n /** Mapped low endpoint. */ lowY: number;\n }>;\n /** Left-facing opening segment before world transforms. */ readonly openTickLocal: Readonly<{\n /** Left endpoint. */ x1: number;\n /** Center endpoint. */ x2: number;\n /** Mapped opening ordinate. */ y: number;\n }>;\n /** Right-facing closing segment before world transforms. */ readonly closeTickLocal: Readonly<{\n /** Center endpoint. */ x1: number;\n /** Right endpoint. */ x2: number;\n /** Mapped closing ordinate. */ y: number;\n }>;\n}\n/** A nearest-time OHLC candidate with committed clip eligibility.\n * @see {@link nearestRecordedOhlcBarX}\n */\nexport interface OhlcBarInspectionCandidate<D> extends OhlcBarObservation<D> {\n /** @returns Whether the close anchor lies inside every committed clip. */\n anchorInsideClips(): boolean;\n}\n/** Original OHLC selected by nearest timestamp.\n * @see {@link nearestRecordedOhlcBarX}\n */\nexport interface NearestOhlcBarHit<D> extends OhlcBarObservation<D> {\n /** Absolute UTC-millisecond distance from the requested timestamp. */\n readonly timeDelta: number;\n}\n/** An actual painted OHLC stroke segment covering a root-logical point.\n * @see {@link paintedOhlcBarAt}\n */\nexport interface PaintedOhlcBarHit<D> extends OhlcBarObservation<D> {\n /** Last painted matching segment. */\n readonly part: \"stem\" | \"openTick\" | \"closeTick\";\n}\n/** @internal Local OHLC paint capture. */\nexport interface CapturedOhlcBarMark<D> extends Omit<\n OhlcBarObservation<D>,\n \"anchorRoot\"\n> {\n readonly strokeWidthLocal: number;\n}\n/** Borrowed committed OHLC generation.\n * @see {@link OhlcBarInspectionRef}\n */\nexport interface OhlcBarRenderedSeries<D> {\n /** Captured original observations in source order. */\n readonly observations: readonly OhlcBarObservation<D>[];\n /** Throws after replacement or disposal. */\n assertLive(): void;\n /** Inverts a root-logical point to a timestamp.\n * @param pointRoot - Root-logical point.\n * @returns Timestamp, or undefined for a singular transform.\n */\n timeAtRoot(pointRoot: Readonly<RenderedSeriesPoint>): number | undefined;\n /** Tests a local point against every committed clip.\n * @param pointLocal - Series-local point.\n * @returns Whether every committed clip contains it.\n */\n anchorInsideClips(pointLocal: Readonly<RenderedSeriesPoint>): boolean;\n /** @internal */ readonly marks: readonly CapturedOhlcBarMark<D>[];\n /** @internal */ readonly numeric: NumericRenderedSeries<D>;\n /** @internal Converts a root-logical point to local geometry.\n * @param point - Root-logical coordinate.\n * @returns Local coordinate, or undefined for a singular transform.\n */ localAtRoot(\n point: Readonly<RenderedSeriesPoint>,\n ): Readonly<RenderedSeriesPoint> | undefined;\n}\n/** Mount-owned optional OHLC bar receiver.\n * @see {@link useOhlcBarInspection}\n */\nexport interface OhlcBarInspectionRef<D> {\n /** @returns Current borrowed generation, or undefined before paint and after disposal. */\n rendered(): OhlcBarRenderedSeries<D> | undefined;\n /** @internal Records completed local paint without querying.\n * @param input - Captured marks and committed mappings.\n */ capture(input: {\n /** Local marks in source order. */\n marks: readonly CapturedOhlcBarMark<D>[];\n /** Committed horizontal mapping. */\n xScale: NumericPositionScale;\n /** Committed price mapping. */\n yScale: ResolvedContinuousScale;\n }): void;\n}\n\n/** Creates a stable OHLC-bar inspection ref without reading data or subscribing.\n * @param _inputs - Inputs retained only to infer the original datum type.\n * @returns A ref for exactly one OhlcBarSeries inspection prop.\n * @see {@link OhlcBarInspectionRef}\n */\nexport function useOhlcBarInspection<D>(\n _inputs: Pick<\n OhlcBarSeriesProps<D>,\n \"data\" | \"time\" | \"open\" | \"high\" | \"low\" | \"close\"\n >,\n): OhlcBarInspectionRef<D> {\n return useRenderedRef<\n {\n marks: readonly CapturedOhlcBarMark<D>[];\n xScale: NumericPositionScale;\n yScale: ResolvedContinuousScale;\n },\n OhlcBarRenderedSeries<D>\n >(\"ohlcBarInspection\", (candidate, geometry) => {\n const observations = Object.freeze(\n candidate.marks.map((mark) =>\n Object.freeze({\n datum: mark.datum,\n sourceIndex: mark.sourceIndex,\n time: mark.time,\n open: mark.open,\n high: mark.high,\n low: mark.low,\n close: mark.close,\n anchorLocal: mark.anchorLocal,\n anchorRoot: geometry.rootAtLocal(mark.anchorLocal),\n stemLocal: mark.stemLocal,\n openTickLocal: mark.openTickLocal,\n closeTickLocal: mark.closeTickLocal,\n }),\n ),\n );\n const numeric: NumericRenderedSeries<D> = Object.freeze({\n observations: Object.freeze(\n observations.map((row) =>\n Object.freeze({\n ...row,\n domainX: row.time,\n domainY: row.close,\n run: 0,\n }),\n ),\n ),\n assertLive: geometry.assertLive,\n domainXAtRoot(point: Readonly<RenderedSeriesPoint>) {\n const local = geometry.localAtRoot(point);\n return local\n ? invertNumericPosition(candidate.xScale, local.x)\n : undefined;\n },\n anchorInsideClips: geometry.anchorInsideClips,\n anchorAtDomain(point: Readonly<{ domainX: number; domainY: number }>) {\n geometry.assertLive();\n const anchorLocal = Object.freeze({\n x: candidate.xScale.map(point.domainX),\n y: candidate.yScale.map(point.domainY),\n });\n return Object.freeze({\n anchorLocal,\n anchorRoot: geometry.rootAtLocal(anchorLocal),\n });\n },\n });\n return Object.freeze({\n observations,\n marks: Object.freeze(candidate.marks.slice()),\n numeric,\n assertLive: geometry.assertLive,\n localAtRoot: geometry.localAtRoot,\n anchorInsideClips: geometry.anchorInsideClips,\n timeAtRoot: numeric.domainXAtRoot,\n });\n });\n}\n\n/** Selects captured original OHLC by nearest timestamp, retaining source-order ties.\n * @param rendered - Borrowed committed OHLC generation.\n * @param options - Timestamp and optional pure candidate filter.\n * @returns First source-order match on a tie, or undefined when none qualifies.\n * @see {@link NearestOhlcBarHit}\n */\nexport function nearestRecordedOhlcBarX<D>(\n rendered: OhlcBarRenderedSeries<D>,\n options: {\n time: number;\n filter?: (observation: OhlcBarInspectionCandidate<D>) => boolean;\n },\n): NearestOhlcBarHit<D> | undefined {\n const hit = nearestRecordedX(rendered.numeric, {\n domainX: options.time,\n filter: options.filter\n ? (candidate) =>\n options.filter!(\n candidate as typeof candidate & OhlcBarInspectionCandidate<D>,\n )\n : undefined,\n });\n if (!hit) return undefined;\n const row = rendered.observations.find(\n (observation) => observation.sourceIndex === hit.sourceIndex,\n )!;\n return Object.freeze({ ...row, timeDelta: hit.domainDelta });\n}\n\nfunction segmentCovers(\n point: Readonly<RenderedSeriesPoint>,\n segment: Readonly<{ x1: number; x2: number; y: number }>,\n strokeWidth: number,\n): boolean {\n if (strokeWidth <= 0) return false;\n const half = strokeWidth / 2;\n return (\n point.x >= Math.min(segment.x1, segment.x2) &&\n point.x <= Math.max(segment.x1, segment.x2) &&\n point.y >= segment.y - half &&\n point.y <= segment.y + half\n );\n}\nfunction stemCovers(\n point: Readonly<RenderedSeriesPoint>,\n stem: Readonly<{ x: number; highY: number; lowY: number }>,\n strokeWidth: number,\n): boolean {\n return (\n segmentCovers(point, { x1: stem.x, x2: stem.x, y: 0 }, 0) ||\n (strokeWidth > 0 &&\n point.x >= stem.x - strokeWidth / 2 &&\n point.x <= stem.x + strokeWidth / 2 &&\n point.y >= Math.min(stem.highY, stem.lowY) &&\n point.y <= Math.max(stem.highY, stem.lowY))\n );\n}\n/** Finds the last-painted OHLC segment covering a root-logical point.\n * @param rendered - Borrowed committed OHLC generation.\n * @param options - Root-logical point; clips and singular transforms produce no result.\n * @returns Captured OHLC record and painted segment, or undefined for gaps.\n * @see {@link PaintedOhlcBarHit}\n */\nexport function paintedOhlcBarAt<D>(\n rendered: OhlcBarRenderedSeries<D>,\n options: { rootPoint: Readonly<RenderedSeriesPoint> },\n): PaintedOhlcBarHit<D> | undefined {\n rendered.assertLive();\n if (\n !Number.isFinite(options.rootPoint.x) ||\n !Number.isFinite(options.rootPoint.y)\n )\n throw new RangeError(\"paintedOhlcBarAt rootPoint must be finite.\");\n const point = rendered.localAtRoot(options.rootPoint);\n if (!point || !rendered.anchorInsideClips(point)) return undefined;\n for (let index = rendered.marks.length - 1; index >= 0; index--) {\n const mark = rendered.marks[index]!;\n if (segmentCovers(point, mark.closeTickLocal, mark.strokeWidthLocal))\n return Object.freeze({\n ...rendered.observations[index]!,\n part: \"closeTick\" as const,\n });\n if (segmentCovers(point, mark.openTickLocal, mark.strokeWidthLocal))\n return Object.freeze({\n ...rendered.observations[index]!,\n part: \"openTick\" as const,\n });\n if (stemCovers(point, mark.stemLocal, mark.strokeWidthLocal))\n return Object.freeze({\n ...rendered.observations[index]!,\n part: \"stem\" as const,\n });\n }\n return undefined;\n}\n"],
|
|
5
|
+
"mappings": "AACA;AAAA,EACE;AAAA,OAEK;AAEP,SAAS,sBAAsB;AAC/B,SAAS,wBAAwB;AAwH1B,SAAS,qBACd,SAIyB;AACzB,SAAO,eAOL,qBAAqB,CAAC,WAAW,aAAa;AAC9C,UAAM,eAAe,OAAO;AAAA,MAC1B,UAAU,MAAM;AAAA,QAAI,CAAC,SACnB,OAAO,OAAO;AAAA,UACZ,OAAO,KAAK;AAAA,UACZ,aAAa,KAAK;AAAA,UAClB,MAAM,KAAK;AAAA,UACX,MAAM,KAAK;AAAA,UACX,MAAM,KAAK;AAAA,UACX,KAAK,KAAK;AAAA,UACV,OAAO,KAAK;AAAA,UACZ,aAAa,KAAK;AAAA,UAClB,YAAY,SAAS,YAAY,KAAK,WAAW;AAAA,UACjD,WAAW,KAAK;AAAA,UAChB,eAAe,KAAK;AAAA,UACpB,gBAAgB,KAAK;AAAA,QACvB,CAAC;AAAA,MACH;AAAA,IACF;AACA,UAAM,UAAoC,OAAO,OAAO;AAAA,MACtD,cAAc,OAAO;AAAA,QACnB,aAAa;AAAA,UAAI,CAAC,QAChB,OAAO,OAAO;AAAA,YACZ,GAAG;AAAA,YACH,SAAS,IAAI;AAAA,YACb,SAAS,IAAI;AAAA,YACb,KAAK;AAAA,UACP,CAAC;AAAA,QACH;AAAA,MACF;AAAA,MACA,YAAY,SAAS;AAAA,MACrB,cAAc,OAAsC;AAClD,cAAM,QAAQ,SAAS,YAAY,KAAK;AACxC,eAAO,QACH,sBAAsB,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
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
type Point = Readonly<{
|
|
2
|
+
x: number;
|
|
3
|
+
y: number;
|
|
4
|
+
}>;
|
|
5
|
+
interface Geometry {
|
|
6
|
+
assertLive(): void;
|
|
7
|
+
localAtRoot(point: Point): Point | undefined;
|
|
8
|
+
rootAtLocal(point: Point): Point;
|
|
9
|
+
anchorInsideClips(point: Point): boolean;
|
|
10
|
+
}
|
|
11
|
+
/** Shared private mount/generation ownership; no signal reads or query algorithms. */
|
|
12
|
+
export declare function useRenderedRef<C, R>(kind: string, build: (candidate: C, geometry: Geometry) => R): Readonly<{
|
|
13
|
+
capture(input: C): void;
|
|
14
|
+
rendered(): R | undefined;
|
|
15
|
+
}>;
|
|
16
|
+
export {};
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
import {
|
|
2
|
+
captureSeriesInspectionFrame,
|
|
3
|
+
useInternalHookSlot
|
|
4
|
+
} from "@pibbl/core/internal";
|
|
5
|
+
function useRenderedRef(kind, build) {
|
|
6
|
+
return useInternalHookSlot(kind, (teardowns) => {
|
|
7
|
+
let closed = false, revision = 0, generation = -1;
|
|
8
|
+
let receiver, candidate, current;
|
|
9
|
+
let frame;
|
|
10
|
+
teardowns.add(() => {
|
|
11
|
+
closed = true;
|
|
12
|
+
candidate = void 0;
|
|
13
|
+
current = void 0;
|
|
14
|
+
frame = void 0;
|
|
15
|
+
receiver = void 0;
|
|
16
|
+
});
|
|
17
|
+
return Object.freeze({
|
|
18
|
+
capture(input) {
|
|
19
|
+
if (closed) throw new Error("Inspection ref has been disposed.");
|
|
20
|
+
const next = captureSeriesInspectionFrame();
|
|
21
|
+
next.onFinish((success) => {
|
|
22
|
+
if (!success || closed || !next.alive()) return;
|
|
23
|
+
if (receiver && receiver !== next.receiver)
|
|
24
|
+
throw new Error(
|
|
25
|
+
"One inspection ref can bind only one mounted series."
|
|
26
|
+
);
|
|
27
|
+
if (!receiver) {
|
|
28
|
+
receiver = next.receiver;
|
|
29
|
+
next.onDispose(() => {
|
|
30
|
+
if (receiver !== next.receiver) return;
|
|
31
|
+
candidate = void 0;
|
|
32
|
+
current = void 0;
|
|
33
|
+
frame = void 0;
|
|
34
|
+
receiver = void 0;
|
|
35
|
+
revision++;
|
|
36
|
+
});
|
|
37
|
+
}
|
|
38
|
+
candidate = input;
|
|
39
|
+
frame = next;
|
|
40
|
+
revision++;
|
|
41
|
+
current = void 0;
|
|
42
|
+
});
|
|
43
|
+
},
|
|
44
|
+
rendered() {
|
|
45
|
+
if (closed || candidate === void 0 || !frame?.alive())
|
|
46
|
+
return void 0;
|
|
47
|
+
if (current && generation === frame.generation()) return current;
|
|
48
|
+
const captured = frame.resolve();
|
|
49
|
+
if (!captured) return void 0;
|
|
50
|
+
if (current && generation === captured.generation) return current;
|
|
51
|
+
generation = captured.generation;
|
|
52
|
+
const stamp = revision, committedGeneration = generation;
|
|
53
|
+
const transform = captured.transform, inverse = transform.inverse();
|
|
54
|
+
const ctx = captured.canvas.getContext("2d");
|
|
55
|
+
const assertLive = () => {
|
|
56
|
+
if (closed || revision !== stamp || !frame?.alive() || frame.generation() !== committedGeneration)
|
|
57
|
+
throw new Error(
|
|
58
|
+
"Rendered series is stale or disposed; obtain the current generation with rendered()."
|
|
59
|
+
);
|
|
60
|
+
};
|
|
61
|
+
const rootAtLocal = (point) => {
|
|
62
|
+
const root = transform.transformPoint(new DOMPoint(point.x, point.y));
|
|
63
|
+
return Object.freeze({ x: root.x, y: root.y });
|
|
64
|
+
};
|
|
65
|
+
current = build(candidate, {
|
|
66
|
+
assertLive,
|
|
67
|
+
rootAtLocal,
|
|
68
|
+
localAtRoot(point) {
|
|
69
|
+
assertLive();
|
|
70
|
+
const local = inverse.transformPoint(
|
|
71
|
+
new DOMPoint(point.x, point.y)
|
|
72
|
+
);
|
|
73
|
+
return Number.isFinite(local.x) && Number.isFinite(local.y) ? Object.freeze({ x: local.x, y: local.y }) : void 0;
|
|
74
|
+
},
|
|
75
|
+
anchorInsideClips(point) {
|
|
76
|
+
assertLive();
|
|
77
|
+
const root = rootAtLocal(point);
|
|
78
|
+
ctx.save();
|
|
79
|
+
try {
|
|
80
|
+
for (const clip of captured.clips) {
|
|
81
|
+
ctx.setTransform(clip.transform);
|
|
82
|
+
if (!ctx.isPointInPath(clip.path, root.x, root.y, clip.fillRule))
|
|
83
|
+
return false;
|
|
84
|
+
}
|
|
85
|
+
return true;
|
|
86
|
+
} finally {
|
|
87
|
+
ctx.restore();
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
});
|
|
91
|
+
return current;
|
|
92
|
+
}
|
|
93
|
+
});
|
|
94
|
+
}).value;
|
|
95
|
+
}
|
|
96
|
+
export {
|
|
97
|
+
useRenderedRef
|
|
98
|
+
};
|
|
99
|
+
//# sourceMappingURL=owned-ref.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../../src/features/viz/inspection/owned-ref.ts"],
|
|
4
|
+
"sourcesContent": ["import {\n captureSeriesInspectionFrame,\n useInternalHookSlot,\n} from \"@pibbl/core/internal\";\ntype Point = Readonly<{ x: number; y: number }>;\ninterface Geometry {\n assertLive(): void;\n localAtRoot(point: Point): Point | undefined;\n rootAtLocal(point: Point): Point;\n anchorInsideClips(point: Point): boolean;\n}\n\n/** Shared private mount/generation ownership; no signal reads or query algorithms. */\nexport function useRenderedRef<C, R>(\n kind: string,\n build: (candidate: C, geometry: Geometry) => R,\n) {\n return useInternalHookSlot(kind, (teardowns) => {\n let closed = false,\n revision = 0,\n generation = -1;\n let receiver: object | undefined,\n candidate: C | undefined,\n current: R | undefined;\n let frame: ReturnType<typeof captureSeriesInspectionFrame> | undefined;\n teardowns.add(() => {\n closed = true;\n candidate = undefined;\n current = undefined;\n frame = undefined;\n receiver = undefined;\n });\n return Object.freeze({\n capture(input: C) {\n if (closed) throw new Error(\"Inspection ref has been disposed.\");\n const next = captureSeriesInspectionFrame();\n next.onFinish((success) => {\n if (!success || closed || !next.alive()) return;\n // Receiver removal is settled before successful render completion.\n // Check here so a keyed replacement can adopt the surviving hook.\n if (receiver && receiver !== next.receiver)\n throw new Error(\n \"One inspection ref can bind only one mounted series.\",\n );\n if (!receiver) {\n receiver = next.receiver;\n next.onDispose(() => {\n if (receiver !== next.receiver) return;\n candidate = undefined;\n current = undefined;\n frame = undefined;\n receiver = undefined;\n revision++;\n });\n }\n candidate = input;\n frame = next;\n revision++;\n current = undefined;\n });\n },\n rendered(): R | undefined {\n if (closed || candidate === undefined || !frame?.alive())\n return undefined;\n if (current && generation === frame.generation()) return current;\n const captured = frame.resolve();\n if (!captured) return undefined;\n if (current && generation === captured.generation) return current;\n generation = captured.generation;\n const stamp = revision,\n committedGeneration = generation;\n const transform = captured.transform,\n inverse = transform.inverse();\n const ctx = captured.canvas.getContext(\"2d\")!;\n const assertLive = () => {\n if (\n closed ||\n revision !== stamp ||\n !frame?.alive() ||\n frame.generation() !== committedGeneration\n )\n throw new Error(\n \"Rendered series is stale or disposed; obtain the current generation with rendered().\",\n );\n };\n const rootAtLocal = (point: Point): Point => {\n const root = transform.transformPoint(new DOMPoint(point.x, point.y));\n return Object.freeze({ x: root.x, y: root.y });\n };\n current = build(candidate, {\n assertLive,\n rootAtLocal,\n localAtRoot(point) {\n assertLive();\n const local = inverse.transformPoint(\n new DOMPoint(point.x, point.y),\n );\n return Number.isFinite(local.x) && Number.isFinite(local.y)\n ? Object.freeze({ x: local.x, y: local.y })\n : undefined;\n },\n anchorInsideClips(point) {\n assertLive();\n const root = rootAtLocal(point);\n ctx.save();\n try {\n for (const clip of captured.clips) {\n ctx.setTransform(clip.transform);\n if (\n !ctx.isPointInPath(clip.path, root.x, root.y, clip.fillRule)\n )\n return false;\n }\n return true;\n } finally {\n ctx.restore();\n }\n },\n });\n return current;\n },\n });\n }).value;\n}\n"],
|
|
5
|
+
"mappings": "AAAA;AAAA,EACE;AAAA,EACA;AAAA,OACK;AAUA,SAAS,eACd,MACA,O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,IAAI;AAAA,cACR;AAAA,YACF;AAAA,QACJ;AACA,cAAM,cAAc,CAAC,UAAwB;AAC3C,gBAAM,OAAO,UAAU,eAAe,IAAI,SAAS,MAAM,GAAG,MAAM,CAAC,CAAC;AACpE,iBAAO,OAAO,OAAO,EAAE,GAAG,KAAK,GAAG,GAAG,KAAK,EAAE,CAAC;AAAA,QAC/C;AACA,kBAAU,MAAM,WAAW;AAAA,UACzB;AAAA,UACA;AAAA,UACA,YAAY,OAAO;AACjB,uBAAW;AACX,kBAAM,QAAQ,QAAQ;AAAA,cACpB,IAAI,SAAS,MAAM,GAAG,MAAM,CAAC;AAAA,YAC/B;AACA,mBAAO,OAAO,SAAS,MAAM,CAAC,KAAK,OAAO,SAAS,MAAM,CAAC,IACtD,OAAO,OAAO,EAAE,GAAG,MAAM,GAAG,GAAG,MAAM,EAAE,CAAC,IACxC;AAAA,UACN;AAAA,UACA,kBAAkB,OAAO;AACvB,uBAAW;AACX,kBAAM,OAAO,YAAY,KAAK;AAC9B,gBAAI,KAAK;AACT,gBAAI;AACF,yBAAW,QAAQ,SAAS,OAAO;AACjC,oBAAI,aAAa,KAAK,SAAS;AAC/B,oBACE,CAAC,IAAI,cAAc,KAAK,MAAM,KAAK,GAAG,KAAK,GAAG,KAAK,QAAQ;AAE3D,yBAAO;AAAA,cACX;AACA,qBAAO;AAAA,YACT,UAAE;AACA,kBAAI,QAAQ;AAAA,YACd;AAAA,UACF;AAAA,QACF,CAAC;AACD,eAAO;AAAA,MACT;AAAA,IACF,CAAC;AAAA,EACH,CAAC,EAAE;AACL;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import type { PointRenderedSeries } from "./capture-types.js";
|
|
2
|
+
import type { RecordedNumericHit, RenderedSeriesPoint } from "./query-types.js";
|
|
3
|
+
/** The original record and local geometry of a discrete circle/ring covering a query point.
|
|
4
|
+
* @see {@link RecordedNumericHit}
|
|
5
|
+
*/
|
|
6
|
+
export interface PaintedPointHit<D> extends RecordedNumericHit<D> {
|
|
7
|
+
/** Circle radius before world transforms, in local logical units. */
|
|
8
|
+
readonly radiusLocal: number;
|
|
9
|
+
/** Painted stroke width before world transforms, in local logical units. */
|
|
10
|
+
readonly strokeWidthLocal: number;
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* Selects the last-painted circle/ring covering a root-logical position in this series.
|
|
14
|
+
* This is geometric fill/stroke coverage, not alpha readback or a Pibbl event target.
|
|
15
|
+
* @param rendered - Borrowed point geometry from the last successful paint.
|
|
16
|
+
* @param options - Explicit root-logical query point; CSS/device pixels are unsupported.
|
|
17
|
+
* @returns Original datum/index and captured geometry, or undefined for clips, holes, omissions or singular transforms.
|
|
18
|
+
* @see {@link PaintedPointHit}
|
|
19
|
+
*/
|
|
20
|
+
export declare function paintedPointAt<D>(rendered: PointRenderedSeries<D>, options: {
|
|
21
|
+
rootPoint: Readonly<RenderedSeriesPoint>;
|
|
22
|
+
}): PaintedPointHit<D> | undefined;
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
function paintedPointAt(rendered, options) {
|
|
2
|
+
rendered.assertLive();
|
|
3
|
+
const { x, y } = options.rootPoint;
|
|
4
|
+
if (!Number.isFinite(x) || !Number.isFinite(y))
|
|
5
|
+
throw new RangeError("paintedPointAt rootPoint must be finite.");
|
|
6
|
+
const local = rendered.localAtRoot(options.rootPoint);
|
|
7
|
+
if (!local || !rendered.anchorInsideClips(local)) return void 0;
|
|
8
|
+
for (let index = rendered.marks.length - 1; index >= 0; index--) {
|
|
9
|
+
const mark = rendered.marks[index];
|
|
10
|
+
const radius = mark.radiusLocal ?? 0, stroke = mark.strokeWidthLocal ?? 0;
|
|
11
|
+
if (radius === 0 || !mark.fill && stroke === 0) continue;
|
|
12
|
+
const distance = Math.hypot(
|
|
13
|
+
local.x - mark.anchorLocal.x,
|
|
14
|
+
local.y - mark.anchorLocal.y
|
|
15
|
+
);
|
|
16
|
+
if (distance > radius + stroke / 2 || !mark.fill && distance < Math.max(0, radius - stroke / 2))
|
|
17
|
+
continue;
|
|
18
|
+
return Object.freeze({
|
|
19
|
+
...rendered.observations[index],
|
|
20
|
+
radiusLocal: radius,
|
|
21
|
+
strokeWidthLocal: stroke
|
|
22
|
+
});
|
|
23
|
+
}
|
|
24
|
+
return void 0;
|
|
25
|
+
}
|
|
26
|
+
export {
|
|
27
|
+
paintedPointAt
|
|
28
|
+
};
|
|
29
|
+
//# sourceMappingURL=painted-point.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../../src/features/viz/inspection/painted-point.ts"],
|
|
4
|
+
"sourcesContent": ["import type { PointRenderedSeries } from \"./capture-types.js\";\nimport type { RecordedNumericHit, RenderedSeriesPoint } from \"./query-types.js\";\n\n/** The original record and local geometry of a discrete circle/ring covering a query point.\n * @see {@link RecordedNumericHit}\n */\nexport interface PaintedPointHit<D> extends RecordedNumericHit<D> {\n /** Circle radius before world transforms, in local logical units. */\n readonly radiusLocal: number;\n /** Painted stroke width before world transforms, in local logical units. */\n readonly strokeWidthLocal: number;\n}\n\n/**\n * Selects the last-painted circle/ring covering a root-logical position in this series.\n * This is geometric fill/stroke coverage, not alpha readback or a Pibbl event target.\n * @param rendered - Borrowed point geometry from the last successful paint.\n * @param options - Explicit root-logical query point; CSS/device pixels are unsupported.\n * @returns Original datum/index and captured geometry, or undefined for clips, holes, omissions or singular transforms.\n * @see {@link PaintedPointHit}\n */\nexport function paintedPointAt<D>(\n rendered: PointRenderedSeries<D>,\n options: { rootPoint: Readonly<RenderedSeriesPoint> },\n): PaintedPointHit<D> | undefined {\n rendered.assertLive();\n const { x, y } = options.rootPoint;\n if (!Number.isFinite(x) || !Number.isFinite(y))\n throw new RangeError(\"paintedPointAt rootPoint must be finite.\");\n const local = rendered.localAtRoot(options.rootPoint);\n if (!local || !rendered.anchorInsideClips(local)) return undefined;\n for (let index = rendered.marks.length - 1; index >= 0; index--) {\n const mark = rendered.marks[index];\n const radius = mark.radiusLocal ?? 0,\n stroke = mark.strokeWidthLocal ?? 0;\n if (radius === 0 || (!mark.fill && stroke === 0)) continue;\n const distance = Math.hypot(\n local.x - mark.anchorLocal.x,\n local.y - mark.anchorLocal.y,\n );\n if (\n distance > radius + stroke / 2 ||\n (!mark.fill && distance < Math.max(0, radius - stroke / 2))\n )\n continue;\n return Object.freeze({\n ...rendered.observations[index],\n radiusLocal: radius,\n strokeWidthLocal: stroke,\n });\n }\n return undefined;\n}\n"],
|
|
5
|
+
"mappings": "AAqBO,SAAS,eACd,UACA,SACgC;AAChC,WAAS,WAAW;AACpB,QAAM,EAAE,GAAG,EAAE,IAAI,QAAQ;AACzB,MAAI,CAAC,OAAO,SAAS,CAAC,KAAK,CAAC,OAAO,SAAS,CAAC;AAC3C,UAAM,IAAI,WAAW,0CAA0C;AACjE,QAAM,QAAQ,SAAS,YAAY,QAAQ,SAAS;AACpD,MAAI,CAAC,SAAS,CAAC,SAAS,kBAAkB,KAAK,EAAG,QAAO;AACzD,WAAS,QAAQ,SAAS,MAAM,SAAS,GAAG,SAAS,GAAG,SAAS;AAC/D,UAAM,OAAO,SAAS,MAAM,KAAK;AACjC,UAAM,SAAS,KAAK,eAAe,GACjC,SAAS,KAAK,oBAAoB;AACpC,QAAI,WAAW,KAAM,CAAC,KAAK,QAAQ,WAAW,EAAI;AAClD,UAAM,WAAW,KAAK;AAAA,MACpB,MAAM,IAAI,KAAK,YAAY;AAAA,MAC3B,MAAM,IAAI,KAAK,YAAY;AAAA,IAC7B;AACA,QACE,WAAW,SAAS,SAAS,KAC5B,CAAC,KAAK,QAAQ,WAAW,KAAK,IAAI,GAAG,SAAS,SAAS,CAAC;AAEzD;AACF,WAAO,OAAO,OAAO;AAAA,MACnB,GAAG,SAAS,aAAa,KAAK;AAAA,MAC9B,aAAa;AAAA,MACb,kBAAkB;AAAA,IACpB,CAAC;AAAA,EACH;AACA,SAAO;AACT;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|