@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
|
@@ -2,6 +2,27 @@ import {
|
|
|
2
2
|
getPibblEventDefinition
|
|
3
3
|
} from "./event-definitions.js";
|
|
4
4
|
const states = /* @__PURE__ */ new WeakMap();
|
|
5
|
+
function borrowDispatchResource(event, key, create) {
|
|
6
|
+
const state = requiredState(event);
|
|
7
|
+
if (state.dispatchFinished) throw new Error("Inspection dispatch has expired.");
|
|
8
|
+
const resources = state.resources ??= /* @__PURE__ */ new Map();
|
|
9
|
+
let resource = resources.get(key);
|
|
10
|
+
if (!resource) {
|
|
11
|
+
resource = create();
|
|
12
|
+
resources.set(key, resource);
|
|
13
|
+
}
|
|
14
|
+
return resource.value;
|
|
15
|
+
}
|
|
16
|
+
function finishEventDispatch(event) {
|
|
17
|
+
const state = requiredState(event);
|
|
18
|
+
state.dispatchFinished = true;
|
|
19
|
+
const resources = state.resources;
|
|
20
|
+
if (resources) {
|
|
21
|
+
for (const resource of resources.values()) resource.dispose();
|
|
22
|
+
resources.clear();
|
|
23
|
+
state.resources = void 0;
|
|
24
|
+
}
|
|
25
|
+
}
|
|
5
26
|
function createPibblEvent(input) {
|
|
6
27
|
const definition = requiredDefinition(input.type);
|
|
7
28
|
const originalEvent = input.originalEvent;
|
|
@@ -180,7 +201,9 @@ function pick(value, keys) {
|
|
|
180
201
|
return result;
|
|
181
202
|
}
|
|
182
203
|
export {
|
|
204
|
+
borrowDispatchResource,
|
|
183
205
|
createPibblEvent,
|
|
206
|
+
finishEventDispatch,
|
|
184
207
|
isPibblImmediatePropagationStopped,
|
|
185
208
|
isPibblPropagationStopped,
|
|
186
209
|
setPibblEventInvocation
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/lib/events/event-facade.ts"],
|
|
4
|
-
"sourcesContent": ["import {\n getPibblEventDefinition,\n type PibblEventDefinition,\n} from './event-definitions.js';\nimport type { PibblEventNode } from './registrations.js';\nimport type {\n PibblEvent,\n PibblEventMap,\n PibblEventPhase,\n PibblEventTarget,\n PibblEventType,\n} from './types.js';\n\nexport type PibblOriginalEvent<K extends PibblEventType> =\n PibblEventMap[K] extends PibblEvent<infer TOriginal> ? TOriginal : Event;\n\nexport interface CreatePibblEventInput<K extends PibblEventType> {\n readonly type: K;\n readonly target: PibblEventNode;\n readonly path: readonly PibblEventNode[];\n readonly relatedTarget?: PibblEventNode | null;\n readonly originalEvent: PibblOriginalEvent<K>;\n readonly sourceEvent?: Event;\n /** Root-logical coordinate supplied by the family adapter. */\n readonly x?: number;\n /** Root-logical coordinate supplied by the family adapter. */\n readonly y?: number;\n}\n\ninterface PibblEventFacadeState {\n currentTarget: PibblEventTarget;\n eventPhase: PibblEventPhase;\n defaultPrevented: boolean;\n propagationStopped: boolean;\n immediatePropagationStopped: boolean;\n}\n\nconst states = new WeakMap<object, PibblEventFacadeState>();\n\nexport function createPibblEvent<K extends PibblEventType>(\n input: CreatePibblEventInput<K>,\n): PibblEventMap[K] {\n const definition = requiredDefinition(input.type);\n const originalEvent = input.originalEvent;\n const cancelable = definition.cancelable && originalEvent.cancelable;\n const publicPath = Object.freeze(\n input.path.map(node => node.publicTarget),\n );\n const state: PibblEventFacadeState = {\n currentTarget: input.target.publicTarget,\n eventPhase: 2,\n defaultPrevented: cancelable && originalEvent.defaultPrevented,\n propagationStopped: false,\n immediatePropagationStopped: false,\n };\n const facade = {\n type: input.type,\n target: input.target.publicTarget,\n relatedTarget: input.relatedTarget?.publicTarget ?? null,\n bubbles: definition.bubbles,\n cancelable,\n timeStamp: originalEvent.timeStamp,\n originalEvent,\n sourceEvent: input.sourceEvent,\n get currentTarget() {\n return state.currentTarget;\n },\n get eventPhase() {\n return state.eventPhase;\n },\n get defaultPrevented() {\n return state.defaultPrevented;\n },\n composedPath() {\n return publicPath;\n },\n preventDefault() {\n if (!cancelable) return;\n state.defaultPrevented = true;\n originalEvent.preventDefault();\n },\n stopPropagation() {\n state.propagationStopped = true;\n originalEvent.stopPropagation();\n },\n stopImmediatePropagation() {\n state.propagationStopped = true;\n state.immediatePropagationStopped = true;\n originalEvent.stopImmediatePropagation();\n },\n } as PibblEvent & Record<string, unknown>;\n states.set(facade, state);\n projectFamilyFields(facade, definition, input);\n return facade as unknown as PibblEventMap[K];\n}\n\nexport function setPibblEventInvocation(\n event: PibblEvent,\n currentTarget: PibblEventTarget,\n eventPhase: PibblEventPhase,\n): void {\n const state = requiredState(event);\n state.currentTarget = currentTarget;\n state.eventPhase = eventPhase;\n}\n\nexport function isPibblPropagationStopped(event: PibblEvent): boolean {\n return requiredState(event).propagationStopped;\n}\n\nexport function isPibblImmediatePropagationStopped(event: PibblEvent): boolean {\n return requiredState(event).immediatePropagationStopped;\n}\n\nfunction requiredState(event: PibblEvent): PibblEventFacadeState {\n const state = states.get(event);\n if (!state) throw new Error('Pibbl event facade state is unavailable.');\n return state;\n}\n\nfunction requiredDefinition(type: PibblEventType): PibblEventDefinition {\n const definition = getPibblEventDefinition(type);\n if (!definition) throw new Error(`Unsupported Pibbl event type: ${type}`);\n return definition;\n}\n\nfunction projectFamilyFields<K extends PibblEventType>(\n facade: PibblEvent & Record<string, unknown>,\n definition: PibblEventDefinition,\n input: CreatePibblEventInput<K>,\n): void {\n const original: unknown = input.originalEvent;\n if (definition.coordinate) {\n Object.assign(facade, { x: input.x ?? 0, y: input.y ?? 0 });\n }\n\n switch (definition.family) {\n case 'pointer':\n projectMouseFields(facade, original as PointerEvent);\n Object.assign(facade, pick(original as PointerEvent, [\n 'pointerId',\n 'width',\n 'height',\n 'pressure',\n 'tangentialPressure',\n 'tiltX',\n 'tiltY',\n 'twist',\n 'pointerType',\n 'isPrimary',\n ]));\n break;\n case 'mouse':\n projectMouseFields(facade, original as MouseEvent);\n break;\n case 'touch':\n projectModifierFields(facade, original as TouchEvent);\n Object.assign(facade, pick(original as TouchEvent, [\n 'touches',\n 'targetTouches',\n 'changedTouches',\n ]));\n break;\n case 'wheel':\n projectMouseFields(facade, original as WheelEvent);\n Object.assign(facade, pick(original as WheelEvent, [\n 'deltaX',\n 'deltaY',\n 'deltaZ',\n 'deltaMode',\n ]));\n break;\n case 'keyboard':\n projectModifierFields(facade, original as KeyboardEvent);\n Object.assign(facade, pick(original as KeyboardEvent, [\n 'key',\n 'code',\n 'location',\n 'repeat',\n 'isComposing',\n ]));\n break;\n case 'input':\n if (definition.type === 'beforeinput' || definition.type === 'input') {\n Object.assign(facade, pick(original as InputEvent, [\n 'data',\n 'dataTransfer',\n 'inputType',\n 'isComposing',\n ]));\n }\n break;\n case 'composition':\n Object.assign(facade, pick(original as CompositionEvent, ['data']));\n break;\n case 'clipboard':\n Object.assign(facade, pick(original as ClipboardEvent, ['clipboardData']));\n break;\n case 'drag':\n projectMouseFields(facade, original as DragEvent);\n Object.assign(facade, pick(original as DragEvent, ['dataTransfer']));\n break;\n case 'focus':\n break;\n }\n}\n\nfunction projectMouseFields(\n facade: PibblEvent & Record<string, unknown>,\n original: MouseEvent,\n): void {\n projectModifierFields(facade, original);\n Object.assign(facade, pick(original, [\n 'clientX',\n 'clientY',\n 'screenX',\n 'screenY',\n 'movementX',\n 'movementY',\n 'button',\n 'buttons',\n 'detail',\n ]));\n}\n\nfunction projectModifierFields(\n facade: PibblEvent & Record<string, unknown>,\n original: MouseEvent | TouchEvent | KeyboardEvent,\n): void {\n Object.assign(facade, pick(original, [\n 'altKey',\n 'ctrlKey',\n 'metaKey',\n 'shiftKey',\n ]));\n}\n\nfunction pick<T extends object, K extends keyof T>(\n value: T,\n keys: readonly K[],\n): Pick<T, K> {\n const result = {} as Pick<T, K>;\n for (const key of keys) result[key] = value[key];\n return result;\n}\n"],
|
|
5
|
-
"mappings": "AAAA;AAAA,EACE;AAAA,OAEK;
|
|
4
|
+
"sourcesContent": ["import {\n getPibblEventDefinition,\n type PibblEventDefinition,\n} from './event-definitions.js';\nimport type { PibblEventNode } from './registrations.js';\nimport type {\n PibblEvent,\n PibblEventMap,\n PibblEventPhase,\n PibblEventTarget,\n PibblEventType,\n} from './types.js';\n\nexport type PibblOriginalEvent<K extends PibblEventType> =\n PibblEventMap[K] extends PibblEvent<infer TOriginal> ? TOriginal : Event;\n\nexport interface CreatePibblEventInput<K extends PibblEventType> {\n readonly type: K;\n readonly target: PibblEventNode;\n readonly path: readonly PibblEventNode[];\n readonly relatedTarget?: PibblEventNode | null;\n readonly originalEvent: PibblOriginalEvent<K>;\n readonly sourceEvent?: Event;\n /** Root-logical coordinate supplied by the family adapter. */\n readonly x?: number;\n /** Root-logical coordinate supplied by the family adapter. */\n readonly y?: number;\n}\n\ninterface PibblEventFacadeState {\n dispatchFinished?: boolean;\n resources?: Map<object, { value: unknown; dispose: () => void }>;\n currentTarget: PibblEventTarget;\n eventPhase: PibblEventPhase;\n defaultPrevented: boolean;\n propagationStopped: boolean;\n immediatePropagationStopped: boolean;\n}\n\nconst states = new WeakMap<object, PibblEventFacadeState>();\n\n/** Private opt-in dispatch ownership; ordinary events allocate no resource map.\n * @param event - The currently dispatched logical event.\n * @param key - Identity of this optional integration resource.\n * @param create - Lazy initializer with an exact dispatch-end disposer.\n * @returns Shared resource for this logical dispatch.\n * @see {@link PibblEvent}\n */\nexport function borrowDispatchResource<T>(event: PibblEvent, key: object, create: () => {value:T;dispose:()=>void}): T {\n const state = requiredState(event);\n if (state.dispatchFinished) throw new Error('Inspection dispatch has expired.');\n const resources = state.resources ??= new Map();\n let resource = resources.get(key);\n if (!resource) { resource = create(); resources.set(key,resource); }\n return resource.value as T;\n}\n\n/** Releases optional synchronous resources even when a handler fails. */\nexport function finishEventDispatch(event: PibblEvent): void {\n const state = requiredState(event);\n state.dispatchFinished = true;\n const resources = state.resources;\n if (resources) {\n for (const resource of resources.values()) resource.dispose();\n resources.clear();\n state.resources = undefined;\n }\n}\n\nexport function createPibblEvent<K extends PibblEventType>(\n input: CreatePibblEventInput<K>,\n): PibblEventMap[K] {\n const definition = requiredDefinition(input.type);\n const originalEvent = input.originalEvent;\n const cancelable = definition.cancelable && originalEvent.cancelable;\n const publicPath = Object.freeze(\n input.path.map(node => node.publicTarget),\n );\n const state: PibblEventFacadeState = {\n currentTarget: input.target.publicTarget,\n eventPhase: 2,\n defaultPrevented: cancelable && originalEvent.defaultPrevented,\n propagationStopped: false,\n immediatePropagationStopped: false,\n };\n const facade = {\n type: input.type,\n target: input.target.publicTarget,\n relatedTarget: input.relatedTarget?.publicTarget ?? null,\n bubbles: definition.bubbles,\n cancelable,\n timeStamp: originalEvent.timeStamp,\n originalEvent,\n sourceEvent: input.sourceEvent,\n get currentTarget() {\n return state.currentTarget;\n },\n get eventPhase() {\n return state.eventPhase;\n },\n get defaultPrevented() {\n return state.defaultPrevented;\n },\n composedPath() {\n return publicPath;\n },\n preventDefault() {\n if (!cancelable) return;\n state.defaultPrevented = true;\n originalEvent.preventDefault();\n },\n stopPropagation() {\n state.propagationStopped = true;\n originalEvent.stopPropagation();\n },\n stopImmediatePropagation() {\n state.propagationStopped = true;\n state.immediatePropagationStopped = true;\n originalEvent.stopImmediatePropagation();\n },\n } as PibblEvent & Record<string, unknown>;\n states.set(facade, state);\n projectFamilyFields(facade, definition, input);\n return facade as unknown as PibblEventMap[K];\n}\n\nexport function setPibblEventInvocation(\n event: PibblEvent,\n currentTarget: PibblEventTarget,\n eventPhase: PibblEventPhase,\n): void {\n const state = requiredState(event);\n state.currentTarget = currentTarget;\n state.eventPhase = eventPhase;\n}\n\nexport function isPibblPropagationStopped(event: PibblEvent): boolean {\n return requiredState(event).propagationStopped;\n}\n\nexport function isPibblImmediatePropagationStopped(event: PibblEvent): boolean {\n return requiredState(event).immediatePropagationStopped;\n}\n\nfunction requiredState(event: PibblEvent): PibblEventFacadeState {\n const state = states.get(event);\n if (!state) throw new Error('Pibbl event facade state is unavailable.');\n return state;\n}\n\nfunction requiredDefinition(type: PibblEventType): PibblEventDefinition {\n const definition = getPibblEventDefinition(type);\n if (!definition) throw new Error(`Unsupported Pibbl event type: ${type}`);\n return definition;\n}\n\nfunction projectFamilyFields<K extends PibblEventType>(\n facade: PibblEvent & Record<string, unknown>,\n definition: PibblEventDefinition,\n input: CreatePibblEventInput<K>,\n): void {\n const original: unknown = input.originalEvent;\n if (definition.coordinate) {\n Object.assign(facade, { x: input.x ?? 0, y: input.y ?? 0 });\n }\n\n switch (definition.family) {\n case 'pointer':\n projectMouseFields(facade, original as PointerEvent);\n Object.assign(facade, pick(original as PointerEvent, [\n 'pointerId',\n 'width',\n 'height',\n 'pressure',\n 'tangentialPressure',\n 'tiltX',\n 'tiltY',\n 'twist',\n 'pointerType',\n 'isPrimary',\n ]));\n break;\n case 'mouse':\n projectMouseFields(facade, original as MouseEvent);\n break;\n case 'touch':\n projectModifierFields(facade, original as TouchEvent);\n Object.assign(facade, pick(original as TouchEvent, [\n 'touches',\n 'targetTouches',\n 'changedTouches',\n ]));\n break;\n case 'wheel':\n projectMouseFields(facade, original as WheelEvent);\n Object.assign(facade, pick(original as WheelEvent, [\n 'deltaX',\n 'deltaY',\n 'deltaZ',\n 'deltaMode',\n ]));\n break;\n case 'keyboard':\n projectModifierFields(facade, original as KeyboardEvent);\n Object.assign(facade, pick(original as KeyboardEvent, [\n 'key',\n 'code',\n 'location',\n 'repeat',\n 'isComposing',\n ]));\n break;\n case 'input':\n if (definition.type === 'beforeinput' || definition.type === 'input') {\n Object.assign(facade, pick(original as InputEvent, [\n 'data',\n 'dataTransfer',\n 'inputType',\n 'isComposing',\n ]));\n }\n break;\n case 'composition':\n Object.assign(facade, pick(original as CompositionEvent, ['data']));\n break;\n case 'clipboard':\n Object.assign(facade, pick(original as ClipboardEvent, ['clipboardData']));\n break;\n case 'drag':\n projectMouseFields(facade, original as DragEvent);\n Object.assign(facade, pick(original as DragEvent, ['dataTransfer']));\n break;\n case 'focus':\n break;\n }\n}\n\nfunction projectMouseFields(\n facade: PibblEvent & Record<string, unknown>,\n original: MouseEvent,\n): void {\n projectModifierFields(facade, original);\n Object.assign(facade, pick(original, [\n 'clientX',\n 'clientY',\n 'screenX',\n 'screenY',\n 'movementX',\n 'movementY',\n 'button',\n 'buttons',\n 'detail',\n ]));\n}\n\nfunction projectModifierFields(\n facade: PibblEvent & Record<string, unknown>,\n original: MouseEvent | TouchEvent | KeyboardEvent,\n): void {\n Object.assign(facade, pick(original, [\n 'altKey',\n 'ctrlKey',\n 'metaKey',\n 'shiftKey',\n ]));\n}\n\nfunction pick<T extends object, K extends keyof T>(\n value: T,\n keys: readonly K[],\n): Pick<T, K> {\n const result = {} as Pick<T, K>;\n for (const key of keys) result[key] = value[key];\n return result;\n}\n"],
|
|
5
|
+
"mappings": "AAAA;AAAA,EACE;AAAA,OAEK;AAoCP,MAAM,SAAS,oBAAI,QAAuC;AASnD,SAAS,uBAA0B,OAAmB,KAAa,QAA6C;AACrH,QAAM,QAAQ,cAAc,KAAK;AACjC,MAAI,MAAM,iBAAkB,OAAM,IAAI,MAAM,kCAAkC;AAC9E,QAAM,YAAY,MAAM,cAAc,oBAAI,IAAI;AAC9C,MAAI,WAAW,UAAU,IAAI,GAAG;AAChC,MAAI,CAAC,UAAU;AAAE,eAAW,OAAO;AAAG,cAAU,IAAI,KAAI,QAAQ;AAAA,EAAG;AACnE,SAAO,SAAS;AAClB;AAGO,SAAS,oBAAoB,OAAyB;AAC3D,QAAM,QAAQ,cAAc,KAAK;AACjC,QAAM,mBAAmB;AACzB,QAAM,YAAY,MAAM;AACxB,MAAI,WAAW;AACb,eAAW,YAAY,UAAU,OAAO,EAAG,UAAS,QAAQ;AAC5D,cAAU,MAAM;AAChB,UAAM,YAAY;AAAA,EACpB;AACF;AAEO,SAAS,iBACd,OACkB;AAClB,QAAM,aAAa,mBAAmB,MAAM,IAAI;AAChD,QAAM,gBAAgB,MAAM;AAC5B,QAAM,aAAa,WAAW,cAAc,cAAc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IACF,KAAK;AACH,UAAI,WAAW,SAAS,iBAAiB,WAAW,SAAS,SAAS;AACpE,eAAO,OAAO,QAAQ,KAAK,UAAwB;AAAA,UACjD;AAAA,UACA;AAAA,UACA;AAAA,UACA;AAAA,QACF,CAAC,CAAC;AAAA,MACJ;AACA;AAAA,IACF,KAAK;AACH,aAAO,OAAO,QAAQ,KAAK,UAA8B,CAAC,MAAM,CAAC,CAAC;AAClE;AAAA,IACF,KAAK;AACH,aAAO,OAAO,QAAQ,KAAK,UAA4B,CAAC,eAAe,CAAC,CAAC;AACzE;AAAA,IACF,KAAK;AACH,yBAAmB,QAAQ,QAAqB;AAChD,aAAO,OAAO,QAAQ,KAAK,UAAuB,CAAC,cAAc,CAAC,CAAC;AACnE;AAAA,IACF,KAAK;AACH;AAAA,EACJ;AACF;AAEA,SAAS,mBACP,QACA,UACM;AACN,wBAAsB,QAAQ,QAAQ;AACtC,SAAO,OAAO,QAAQ,KAAK,UAAU;AAAA,IACnC;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACF,CAAC,CAAC;AACJ;AAEA,SAAS,sBACP,QACA,UACM;AACN,SAAO,OAAO,QAAQ,KAAK,UAAU;AAAA,IACnC;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACF,CAAC,CAAC;AACJ;AAEA,SAAS,KACP,OACA,MACY;AACZ,QAAM,SAAS,CAAC;AAChB,aAAW,OAAO,KAAM,QAAO,GAAG,IAAI,MAAM,GAAG;AAC/C,SAAO;AACT;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { getPibblEventDefinition } from "./event-definitions.js";
|
|
2
2
|
import {
|
|
3
3
|
createPibblEvent,
|
|
4
|
+
finishEventDispatch,
|
|
4
5
|
isPibblImmediatePropagationStopped,
|
|
5
6
|
isPibblPropagationStopped,
|
|
6
7
|
setPibblEventInvocation
|
|
@@ -14,23 +15,27 @@ function dispatchEventPath(input) {
|
|
|
14
15
|
const path = buildEventPath(input.target);
|
|
15
16
|
const event = createPibblEvent({ ...input, path });
|
|
16
17
|
const targetIndex = path.length - 1;
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
invoke(path[index], input.type, true, 1, event);
|
|
20
|
-
}
|
|
21
|
-
if (!isPibblPropagationStopped(event) && input.target.live) {
|
|
22
|
-
invoke(input.target, input.type, true, 2, event);
|
|
23
|
-
if (!isPibblImmediatePropagationStopped(event)) {
|
|
24
|
-
invoke(input.target, input.type, false, 2, event);
|
|
25
|
-
}
|
|
26
|
-
}
|
|
27
|
-
if (definition.bubbles && !isPibblPropagationStopped(event)) {
|
|
28
|
-
for (let index = targetIndex - 1; index >= 0; index--) {
|
|
18
|
+
try {
|
|
19
|
+
for (let index = 0; index < targetIndex; index++) {
|
|
29
20
|
if (isPibblPropagationStopped(event)) break;
|
|
30
|
-
invoke(path[index], input.type,
|
|
21
|
+
invoke(path[index], input.type, true, 1, event);
|
|
22
|
+
}
|
|
23
|
+
if (!isPibblPropagationStopped(event) && input.target.live) {
|
|
24
|
+
invoke(input.target, input.type, true, 2, event);
|
|
25
|
+
if (!isPibblImmediatePropagationStopped(event)) {
|
|
26
|
+
invoke(input.target, input.type, false, 2, event);
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
if (definition.bubbles && !isPibblPropagationStopped(event)) {
|
|
30
|
+
for (let index = targetIndex - 1; index >= 0; index--) {
|
|
31
|
+
if (isPibblPropagationStopped(event)) break;
|
|
32
|
+
invoke(path[index], input.type, false, 3, event);
|
|
33
|
+
}
|
|
31
34
|
}
|
|
35
|
+
return event;
|
|
36
|
+
} finally {
|
|
37
|
+
finishEventDispatch(event);
|
|
32
38
|
}
|
|
33
|
-
return event;
|
|
34
39
|
}
|
|
35
40
|
function invoke(node, type, capture, phase, event) {
|
|
36
41
|
if (!node.live) return;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/lib/events/propagation.ts"],
|
|
4
|
-
"sourcesContent": ["import { getPibblEventDefinition } from './event-definitions.js';\nimport {\n createPibblEvent,\n isPibblImmediatePropagationStopped,\n isPibblPropagationStopped,\n setPibblEventInvocation,\n type CreatePibblEventInput,\n} from './event-facade.js';\nimport { buildEventPath } from './event-path.js';\nimport type {\n PibblEventNode,\n PibblNormalizedHandlers,\n} from './registrations.js';\nimport type {\n PibblEvent,\n PibblEventMap,\n PibblEventPhase,\n PibblEventType,\n} from './types.js';\n\nexport interface DispatchEventPathInput<K extends PibblEventType>\n extends Omit<CreatePibblEventInput<K>, 'path'> {\n readonly target: PibblEventNode;\n}\n\ntype PibblNormalizedCaptureKey = `${PibblEventType}Capture`;\n\nexport function dispatchEventPath<K extends PibblEventType>(\n input: DispatchEventPathInput<K>,\n): PibblEventMap[K] {\n const definition = getPibblEventDefinition(input.type);\n if (!definition) {\n throw new Error(`Unsupported Pibbl event type: ${input.type}`);\n }\n const path = buildEventPath(input.target);\n const event = createPibblEvent({ ...input, path });\n const targetIndex = path.length - 1;\n\n for (let index = 0; index < targetIndex; index++) {\n if (isPibblPropagationStopped(event)) break;\n invoke(path[index], input.type, true, 1, event);\n }\n\n if (!isPibblPropagationStopped(event) && input.target.live) {\n invoke(input.target, input.type, true, 2, event);\n if (!isPibblImmediatePropagationStopped(event)) {\n invoke(input.target, input.type, false, 2, event);\n }\n }\n\n if (definition.bubbles && !isPibblPropagationStopped(event)) {\n for (let index = targetIndex - 1; index >= 0; index--) {\n if (isPibblPropagationStopped(event)) break;\n invoke(path[index], input.type, false, 3, event);\n }\n }\n\n return event;\n}\n\nfunction invoke(\n node: PibblEventNode,\n type: PibblEventType,\n capture: boolean,\n phase: PibblEventPhase,\n event: PibblEvent,\n): void {\n if (!node.live) return;\n const key = capture ? `${type}Capture` as PibblNormalizedCaptureKey : type;\n const handler = node.handlers[key as keyof PibblNormalizedHandlers];\n if (!handler) return;\n setPibblEventInvocation(event, node.publicTarget, phase);\n try {\n (handler as (event: PibblEvent) => void)(event);\n } catch (error) {\n reportDispatchError(error);\n }\n}\n\nfunction reportDispatchError(error: unknown): void {\n try {\n globalThis.reportError(error);\n } catch {\n // Reporting cannot suppress unrelated handlers in this logical dispatch.\n }\n}\n"],
|
|
5
|
-
"mappings": "AAAA,SAAS,+BAA+B;AACxC;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OAEK;AACP,SAAS,sBAAsB;AAmBxB,SAAS,kBACd,OACkB;AAClB,QAAM,aAAa,wBAAwB,MAAM,IAAI;AACrD,MAAI,CAAC,YAAY;AACf,UAAM,IAAI,MAAM,iCAAiC,MAAM,IAAI,EAAE;AAAA,EAC/D;AACA,QAAM,OAAO,eAAe,MAAM,MAAM;AACxC,QAAM,QAAQ,iBAAiB,EAAE,GAAG,OAAO,KAAK,CAAC;AACjD,QAAM,cAAc,KAAK,SAAS;
|
|
4
|
+
"sourcesContent": ["import { getPibblEventDefinition } from './event-definitions.js';\nimport {\n createPibblEvent,\n finishEventDispatch,\n isPibblImmediatePropagationStopped,\n isPibblPropagationStopped,\n setPibblEventInvocation,\n type CreatePibblEventInput,\n} from './event-facade.js';\nimport { buildEventPath } from './event-path.js';\nimport type {\n PibblEventNode,\n PibblNormalizedHandlers,\n} from './registrations.js';\nimport type {\n PibblEvent,\n PibblEventMap,\n PibblEventPhase,\n PibblEventType,\n} from './types.js';\n\nexport interface DispatchEventPathInput<K extends PibblEventType>\n extends Omit<CreatePibblEventInput<K>, 'path'> {\n readonly target: PibblEventNode;\n}\n\ntype PibblNormalizedCaptureKey = `${PibblEventType}Capture`;\n\nexport function dispatchEventPath<K extends PibblEventType>(\n input: DispatchEventPathInput<K>,\n): PibblEventMap[K] {\n const definition = getPibblEventDefinition(input.type);\n if (!definition) {\n throw new Error(`Unsupported Pibbl event type: ${input.type}`);\n }\n const path = buildEventPath(input.target);\n const event = createPibblEvent({ ...input, path });\n const targetIndex = path.length - 1;\n try {\n for (let index = 0; index < targetIndex; index++) {\n if (isPibblPropagationStopped(event)) break;\n invoke(path[index], input.type, true, 1, event);\n }\n\n if (!isPibblPropagationStopped(event) && input.target.live) {\n invoke(input.target, input.type, true, 2, event);\n if (!isPibblImmediatePropagationStopped(event)) {\n invoke(input.target, input.type, false, 2, event);\n }\n }\n\n if (definition.bubbles && !isPibblPropagationStopped(event)) {\n for (let index = targetIndex - 1; index >= 0; index--) {\n if (isPibblPropagationStopped(event)) break;\n invoke(path[index], input.type, false, 3, event);\n }\n }\n\n return event;\n } finally { finishEventDispatch(event); }\n}\n\nfunction invoke(\n node: PibblEventNode,\n type: PibblEventType,\n capture: boolean,\n phase: PibblEventPhase,\n event: PibblEvent,\n): void {\n if (!node.live) return;\n const key = capture ? `${type}Capture` as PibblNormalizedCaptureKey : type;\n const handler = node.handlers[key as keyof PibblNormalizedHandlers];\n if (!handler) return;\n setPibblEventInvocation(event, node.publicTarget, phase);\n try {\n (handler as (event: PibblEvent) => void)(event);\n } catch (error) {\n reportDispatchError(error);\n }\n}\n\nfunction reportDispatchError(error: unknown): void {\n try {\n globalThis.reportError(error);\n } catch {\n // Reporting cannot suppress unrelated handlers in this logical dispatch.\n }\n}\n"],
|
|
5
|
+
"mappings": "AAAA,SAAS,+BAA+B;AACxC;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OAEK;AACP,SAAS,sBAAsB;AAmBxB,SAAS,kBACd,OACkB;AAClB,QAAM,aAAa,wBAAwB,MAAM,IAAI;AACrD,MAAI,CAAC,YAAY;AACf,UAAM,IAAI,MAAM,iCAAiC,MAAM,IAAI,EAAE;AAAA,EAC/D;AACA,QAAM,OAAO,eAAe,MAAM,MAAM;AACxC,QAAM,QAAQ,iBAAiB,EAAE,GAAG,OAAO,KAAK,CAAC;AACjD,QAAM,cAAc,KAAK,SAAS;AAClC,MAAI;AACJ,aAAS,QAAQ,GAAG,QAAQ,aAAa,SAAS;AAChD,UAAI,0BAA0B,KAAK,EAAG;AACtC,aAAO,KAAK,KAAK,GAAG,MAAM,MAAM,MAAM,GAAG,KAAK;AAAA,IAChD;AAEA,QAAI,CAAC,0BAA0B,KAAK,KAAK,MAAM,OAAO,MAAM;AAC1D,aAAO,MAAM,QAAQ,MAAM,MAAM,MAAM,GAAG,KAAK;AAC/C,UAAI,CAAC,mCAAmC,KAAK,GAAG;AAC9C,eAAO,MAAM,QAAQ,MAAM,MAAM,OAAO,GAAG,KAAK;AAAA,MAClD;AAAA,IACF;AAEA,QAAI,WAAW,WAAW,CAAC,0BAA0B,KAAK,GAAG;AAC3D,eAAS,QAAQ,cAAc,GAAG,SAAS,GAAG,SAAS;AACrD,YAAI,0BAA0B,KAAK,EAAG;AACtC,eAAO,KAAK,KAAK,GAAG,MAAM,MAAM,OAAO,GAAG,KAAK;AAAA,MACjD;AAAA,IACF;AAEA,WAAO;AAAA,EACP,UAAE;AAAU,wBAAoB,KAAK;AAAA,EAAG;AAC1C;AAEA,SAAS,OACP,MACA,MACA,SACA,OACA,OACM;AACN,MAAI,CAAC,KAAK,KAAM;AAChB,QAAM,MAAM,UAAU,GAAG,IAAI,YAAyC;AACtE,QAAM,UAAU,KAAK,SAAS,GAAoC;AAClE,MAAI,CAAC,QAAS;AACd,0BAAwB,OAAO,KAAK,cAAc,KAAK;AACvD,MAAI;AACF,IAAC,QAAwC,KAAK;AAAA,EAChD,SAAS,OAAO;AACd,wBAAoB,KAAK;AAAA,EAC3B;AACF;AAEA,SAAS,oBAAoB,OAAsB;AACjD,MAAI;AACF,eAAW,YAAY,KAAK;AAAA,EAC9B,QAAQ;AAAA,EAER;AACF;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -114,6 +114,19 @@ function executeRender(canvas, renderTimestamp, updatedRoot, _updateParents = fa
|
|
|
114
114
|
percentageBasis: pibblInstance.rootLayoutBox
|
|
115
115
|
}];
|
|
116
116
|
const renderGeneration = ++pibblInstance.renderGeneration;
|
|
117
|
+
if (!pibblInstance.parent) {
|
|
118
|
+
renderTransaction.onFinish((success) => {
|
|
119
|
+
if (success) pibblInstance.committedRenderGeneration = renderGeneration;
|
|
120
|
+
});
|
|
121
|
+
if (pibblInstance.rootFrameObservers?.size) {
|
|
122
|
+
renderTransaction.onAfterFinish?.((success) => {
|
|
123
|
+
const observers = pibblInstance.rootFrameObservers;
|
|
124
|
+
if (!observers) return;
|
|
125
|
+
for (const observer of observers)
|
|
126
|
+
observer(success, renderGeneration);
|
|
127
|
+
});
|
|
128
|
+
}
|
|
129
|
+
}
|
|
117
130
|
renderSeenIds = pibblInstance.renderSeenIds;
|
|
118
131
|
renderSeenKeys = pibblInstance.renderSeenKeys;
|
|
119
132
|
renderSeenIds.clear();
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/lib/execute-render.ts"],
|
|
4
|
-
"sourcesContent": ["import { RootRenderTransaction } from './render-transaction.js';\nimport {\n clearTempState,\n GLOBAL_STATE,\n NO_PENDING_ROOT,\n} from './global-state.js';\nimport { render } from './render.js';\nimport { initializeCurrentWorldTransformAnchor } from './render-target.js';\nimport {\n Canvas,\n type PibblNode,\n} from './types.js';\nimport type {\n PibblBackendFrame,\n} from './backend/types.js';\nimport type { PibblFrameSnapshot } from './scheduler/types.js';\nimport { withSignalWriteForbidden } from './signals/graph.js';\n\n/**\n * Gets the root element for a canvas and renders it. This is the\n * entry point for rendering the entire tree.\n * @param canvas The canvas to render on\n */\nexport function executeRender(\n canvas: Canvas,\n renderTimestamp: number,\n updatedRoot?: PibblNode | typeof NO_PENDING_ROOT,\n _updateParents = false,\n frameSnapshot?: PibblFrameSnapshot,\n): void {\n if (!canvas) {\n throw new Error('No canvas element provided');\n }\n\n const pibblInstance = GLOBAL_STATE.pibblInstances.get(canvas);\n\n if (!pibblInstance) {\n throw new Error('Pibbl is not mounted on this element');\n }\n\n if (pibblInstance.mainTeardowns.closed) return;\n\n const inheritedTransaction = pibblInstance.eventRoot.renderTransaction;\n const renderTransaction = inheritedTransaction ?? new RootRenderTransaction();\n const ownsRenderTransaction = !inheritedTransaction;\n if (ownsRenderTransaction) {\n pibblInstance.eventRoot.renderTransaction = renderTransaction;\n }\n let transactionFinished = false;\n const finishTransaction = (success: boolean) => {\n if (!ownsRenderTransaction || transactionFinished) return;\n transactionFinished = true;\n (renderTransaction as RootRenderTransaction).finish(success);\n };\n\n const prevCurrentPibblInstance = GLOBAL_STATE.currentPibblInstance;\n const prevCanvas = GLOBAL_STATE.canvas;\n const prevRenderContext = GLOBAL_STATE.renderContext;\n const prevRenderTarget = GLOBAL_STATE.renderTarget;\n const prevWorldBaseTransform = GLOBAL_STATE.worldBaseTransform;\n const prevWorldExactTransform = GLOBAL_STATE.worldExactTransform;\n const prevWorldPaintAnchorTransform = GLOBAL_STATE.worldPaintAnchorTransform;\n const prevPresentationTransformLineage = GLOBAL_STATE.presentationTransformLineage;\n const prevPresentationTransformLineageTrackingDepth =\n GLOBAL_STATE.presentationTransformLineageTrackingDepth;\n const prevRenderTransaction = GLOBAL_STATE.renderTransaction;\n const prevFrameSnapshot = GLOBAL_STATE.frameSnapshot;\n const prevPrimitiveReceiverToken = GLOBAL_STATE.primitiveReceiverToken;\n const prevSeenIds = GLOBAL_STATE.seenIds;\n const prevSeenKeys = GLOBAL_STATE.seenKeys;\n const prevComponentRefs = GLOBAL_STATE.componentRefs;\n const prevComponentHookIndex = GLOBAL_STATE.componentHookIndex;\n const prevComponentIsMounting = GLOBAL_STATE.componentIsMounting;\n const prevClippingStack = GLOBAL_STATE.clippingStack;\n const prevLayoutStack = GLOBAL_STATE.layoutStack;\n const prevBackendDriver = GLOBAL_STATE.backendDriver;\n const prevBackendFrame = GLOBAL_STATE.backendFrame;\n const prevBackendEnvironment = GLOBAL_STATE.backendEnvironment;\n let frame: PibblBackendFrame<unknown> | undefined;\n let frameSuccess = false;\n let renderSeenIds: Set<string> | undefined;\n let renderSeenKeys: Set<string> | undefined;\n try {\n const activeFrameSnapshot = frameSnapshot ?? (\n prevFrameSnapshot?.logicalTime === renderTimestamp ?\n prevFrameSnapshot :\n Object.freeze({\n frameId: prevFrameSnapshot?.frameId ?? 0,\n hostTime: prevFrameSnapshot?.hostTime ?? renderTimestamp,\n logicalTime: renderTimestamp,\n })\n );\n GLOBAL_STATE.frameSnapshot = activeFrameSnapshot;\n GLOBAL_STATE.currentPibblInstance = pibblInstance;\n for (const service of pibblInstance.optionalServices.values()) service.beginRender?.();\n GLOBAL_STATE.renderTransaction = renderTransaction;\n GLOBAL_STATE.currentPibblInstance.renderTimestamp = activeFrameSnapshot.logicalTime;\n GLOBAL_STATE.canvas = canvas;\n const rootNode = arguments.length >= 3 && updatedRoot !== NO_PENDING_ROOT ?\n updatedRoot :\n GLOBAL_STATE.currentPibblInstance.root;\n GLOBAL_STATE.currentPibblInstance.root = rootNode;\n const driver = pibblInstance.backendDriver;\n GLOBAL_STATE.backendDriver = driver;\n frame = driver.beginFrame({\n canvas,\n logicalWidth: pibblInstance.rootLayoutBox.width,\n logicalHeight: pibblInstance.rootLayoutBox.height,\n backingWidth: canvas.width,\n backingHeight: canvas.height,\n renderTimestamp: activeFrameSnapshot.logicalTime,\n });\n if (!frame) {\n pibblInstance.eventRoot.html?.suspend(pibblInstance);\n finishTransaction(true);\n return;\n }\n pibblInstance.eventRoot.html?.beginRender(pibblInstance);\n GLOBAL_STATE.backendFrame = frame;\n GLOBAL_STATE.backendEnvironment = frame.environment;\n GLOBAL_STATE.renderContext = frame.context2D;\n GLOBAL_STATE.renderTarget = frame.renderTarget;\n GLOBAL_STATE.worldBaseTransform = frame.worldBaseTransform;\n GLOBAL_STATE.worldExactTransform = undefined;\n GLOBAL_STATE.worldPaintAnchorTransform = undefined;\n GLOBAL_STATE.presentationTransformLineage = undefined;\n GLOBAL_STATE.presentationTransformLineageTrackingDepth = 0;\n if (\n frame.context2D !== undefined &&\n frame.renderTarget !== undefined &&\n frame.worldBaseTransform !== undefined\n ) {\n initializeCurrentWorldTransformAnchor(frame.worldBaseTransform);\n }\n GLOBAL_STATE.clippingStack = [];\n const surface = pibblInstance.surface.snapshot;\n const logicalWidth = surface?.logicalWidth ?? pibblInstance.rootLayoutBox.width;\n const logicalHeight = surface?.logicalHeight ?? pibblInstance.rootLayoutBox.height;\n const previousRootBox = pibblInstance.rootLayoutBox;\n if (\n previousRootBox.width !== logicalWidth ||\n previousRootBox.height !== logicalHeight\n ) {\n pibblInstance.rootLayoutBox = Object.freeze({\n x: 0,\n y: 0,\n width: logicalWidth,\n height: logicalHeight,\n });\n }\n GLOBAL_STATE.layoutStack = [{\n allocation: pibblInstance.rootLayoutBox,\n percentageBasis: pibblInstance.rootLayoutBox,\n }];\n\n const renderGeneration = ++pibblInstance.renderGeneration;\n renderSeenIds = pibblInstance.renderSeenIds;\n renderSeenKeys = pibblInstance.renderSeenKeys;\n renderSeenIds.clear();\n renderSeenKeys.clear();\n GLOBAL_STATE.seenIds = renderSeenIds;\n GLOBAL_STATE.seenKeys = renderSeenKeys;\n const id = 'root';\n renderSeenIds.add(id);\n withSignalWriteForbidden(\n 'Pibbl render',\n () => render(rootNode, id, undefined),\n );\n\n for (const [id, componentRefs] of pibblInstance.refs) {\n if (componentRefs.renderGeneration === renderGeneration) continue;\n componentRefs.teardowns.execute();\n pibblInstance.refs.delete(id);\n }\n frameSuccess = true;\n for (const service of pibblInstance.optionalServices.values()) service.endRender?.(true);\n driver.finishFrame(frame, true);\n finishTransaction(true);\n } catch (error) {\n for (const service of pibblInstance.optionalServices.values()) service.endRender?.(false);\n finishTransaction(false);\n for (const refs of pibblInstance.refs.values()) {\n refs.teardowns.execute();\n }\n pibblInstance.refs.clear();\n throw error;\n } finally {\n try {\n if (frame && !frameSuccess) {\n pibblInstance.backendDriver.finishFrame(frame, false);\n }\n } finally {\n try {\n clearTempState();\n GLOBAL_STATE.clippingStack = prevClippingStack;\n GLOBAL_STATE.layoutStack = prevLayoutStack;\n if (ownsRenderTransaction) {\n try {\n finishTransaction(false);\n } finally {\n if (pibblInstance.eventRoot.renderTransaction === renderTransaction) {\n pibblInstance.eventRoot.renderTransaction = undefined;\n }\n }\n }\n } finally {\n renderSeenIds?.clear();\n renderSeenKeys?.clear();\n GLOBAL_STATE.currentPibblInstance = prevCurrentPibblInstance;\n GLOBAL_STATE.canvas = prevCanvas;\n GLOBAL_STATE.renderContext = prevRenderContext;\n GLOBAL_STATE.renderTarget = prevRenderTarget;\n GLOBAL_STATE.worldBaseTransform = prevWorldBaseTransform;\n GLOBAL_STATE.worldExactTransform = prevWorldExactTransform;\n GLOBAL_STATE.worldPaintAnchorTransform = prevWorldPaintAnchorTransform;\n GLOBAL_STATE.presentationTransformLineage = prevPresentationTransformLineage;\n GLOBAL_STATE.presentationTransformLineageTrackingDepth =\n prevPresentationTransformLineageTrackingDepth;\n GLOBAL_STATE.renderTransaction = prevRenderTransaction;\n GLOBAL_STATE.frameSnapshot = prevFrameSnapshot;\n GLOBAL_STATE.primitiveReceiverToken = prevPrimitiveReceiverToken;\n GLOBAL_STATE.seenIds = prevSeenIds;\n GLOBAL_STATE.seenKeys = prevSeenKeys;\n GLOBAL_STATE.componentRefs = prevComponentRefs;\n GLOBAL_STATE.componentHookIndex = prevComponentHookIndex;\n GLOBAL_STATE.componentIsMounting = prevComponentIsMounting;\n GLOBAL_STATE.backendDriver = prevBackendDriver;\n GLOBAL_STATE.backendFrame = prevBackendFrame;\n GLOBAL_STATE.backendEnvironment = prevBackendEnvironment;\n }\n }\n }\n}\n"],
|
|
5
|
-
"mappings": "AAAA,SAAS,6BAA6B;AACtC;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,OACK;AACP,SAAS,cAAc;AACvB,SAAS,6CAA6C;AAStD,SAAS,gCAAgC;AAOlC,SAAS,cACd,QACA,iBACA,aACA,iBAAiB,OACjB,eACM;AACN,MAAI,CAAC,QAAQ;AACX,UAAM,IAAI,MAAM,4BAA4B;AAAA,EAC9C;AAEA,QAAM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,cAAI;AACF,8BAAkB,KAAK;AAAA,UACzB,UAAE;AACA,gBAAI,cAAc,UAAU,sBAAsB,mBAAmB;AACnE,4BAAc,UAAU,oBAAoB;AAAA,YAC9C;AAAA,UACF;AAAA,QACF;AAAA,MACF,UAAE;AACA,uBAAe,MAAM;AACrB,wBAAgB,MAAM;AACtB,qBAAa,uBAAuB;AACpC,qBAAa,SAAS;AACtB,qBAAa,gBAAgB;AAC7B,qBAAa,eAAe;AAC5B,qBAAa,qBAAqB;AAClC,qBAAa,sBAAsB;AACnC,qBAAa,4BAA4B;AACzC,qBAAa,+BAA+B;AAC5C,qBAAa,4CACX;AACF,qBAAa,oBAAoB;AACjC,qBAAa,gBAAgB;AAC7B,qBAAa,yBAAyB;AACtC,qBAAa,UAAU;AACvB,qBAAa,WAAW;AACxB,qBAAa,gBAAgB;AAC7B,qBAAa,qBAAqB;AAClC,qBAAa,sBAAsB;AACnC,qBAAa,gBAAgB;AAC7B,qBAAa,eAAe;AAC5B,qBAAa,qBAAqB;AAAA,MACpC;AAAA,IACF;AAAA,EACF;AACF;",
|
|
4
|
+
"sourcesContent": ["import { RootRenderTransaction } from './render-transaction.js';\nimport {\n clearTempState,\n GLOBAL_STATE,\n NO_PENDING_ROOT,\n} from './global-state.js';\nimport { render } from './render.js';\nimport { initializeCurrentWorldTransformAnchor } from './render-target.js';\nimport {\n Canvas,\n type PibblNode,\n} from './types.js';\nimport type {\n PibblBackendFrame,\n} from './backend/types.js';\nimport type { PibblFrameSnapshot } from './scheduler/types.js';\nimport { withSignalWriteForbidden } from './signals/graph.js';\n\n/**\n * Gets the root element for a canvas and renders it. This is the\n * entry point for rendering the entire tree.\n * @param canvas The canvas to render on\n */\nexport function executeRender(\n canvas: Canvas,\n renderTimestamp: number,\n updatedRoot?: PibblNode | typeof NO_PENDING_ROOT,\n _updateParents = false,\n frameSnapshot?: PibblFrameSnapshot,\n): void {\n if (!canvas) {\n throw new Error('No canvas element provided');\n }\n\n const pibblInstance = GLOBAL_STATE.pibblInstances.get(canvas);\n\n if (!pibblInstance) {\n throw new Error('Pibbl is not mounted on this element');\n }\n\n if (pibblInstance.mainTeardowns.closed) return;\n\n const inheritedTransaction = pibblInstance.eventRoot.renderTransaction;\n const renderTransaction = inheritedTransaction ?? new RootRenderTransaction();\n const ownsRenderTransaction = !inheritedTransaction;\n if (ownsRenderTransaction) {\n pibblInstance.eventRoot.renderTransaction = renderTransaction;\n }\n let transactionFinished = false;\n const finishTransaction = (success: boolean) => {\n if (!ownsRenderTransaction || transactionFinished) return;\n transactionFinished = true;\n (renderTransaction as RootRenderTransaction).finish(success);\n };\n\n const prevCurrentPibblInstance = GLOBAL_STATE.currentPibblInstance;\n const prevCanvas = GLOBAL_STATE.canvas;\n const prevRenderContext = GLOBAL_STATE.renderContext;\n const prevRenderTarget = GLOBAL_STATE.renderTarget;\n const prevWorldBaseTransform = GLOBAL_STATE.worldBaseTransform;\n const prevWorldExactTransform = GLOBAL_STATE.worldExactTransform;\n const prevWorldPaintAnchorTransform = GLOBAL_STATE.worldPaintAnchorTransform;\n const prevPresentationTransformLineage = GLOBAL_STATE.presentationTransformLineage;\n const prevPresentationTransformLineageTrackingDepth =\n GLOBAL_STATE.presentationTransformLineageTrackingDepth;\n const prevRenderTransaction = GLOBAL_STATE.renderTransaction;\n const prevFrameSnapshot = GLOBAL_STATE.frameSnapshot;\n const prevPrimitiveReceiverToken = GLOBAL_STATE.primitiveReceiverToken;\n const prevSeenIds = GLOBAL_STATE.seenIds;\n const prevSeenKeys = GLOBAL_STATE.seenKeys;\n const prevComponentRefs = GLOBAL_STATE.componentRefs;\n const prevComponentHookIndex = GLOBAL_STATE.componentHookIndex;\n const prevComponentIsMounting = GLOBAL_STATE.componentIsMounting;\n const prevClippingStack = GLOBAL_STATE.clippingStack;\n const prevLayoutStack = GLOBAL_STATE.layoutStack;\n const prevBackendDriver = GLOBAL_STATE.backendDriver;\n const prevBackendFrame = GLOBAL_STATE.backendFrame;\n const prevBackendEnvironment = GLOBAL_STATE.backendEnvironment;\n let frame: PibblBackendFrame<unknown> | undefined;\n let frameSuccess = false;\n let renderSeenIds: Set<string> | undefined;\n let renderSeenKeys: Set<string> | undefined;\n try {\n const activeFrameSnapshot = frameSnapshot ?? (\n prevFrameSnapshot?.logicalTime === renderTimestamp ?\n prevFrameSnapshot :\n Object.freeze({\n frameId: prevFrameSnapshot?.frameId ?? 0,\n hostTime: prevFrameSnapshot?.hostTime ?? renderTimestamp,\n logicalTime: renderTimestamp,\n })\n );\n GLOBAL_STATE.frameSnapshot = activeFrameSnapshot;\n GLOBAL_STATE.currentPibblInstance = pibblInstance;\n for (const service of pibblInstance.optionalServices.values()) service.beginRender?.();\n GLOBAL_STATE.renderTransaction = renderTransaction;\n GLOBAL_STATE.currentPibblInstance.renderTimestamp = activeFrameSnapshot.logicalTime;\n GLOBAL_STATE.canvas = canvas;\n const rootNode = arguments.length >= 3 && updatedRoot !== NO_PENDING_ROOT ?\n updatedRoot :\n GLOBAL_STATE.currentPibblInstance.root;\n GLOBAL_STATE.currentPibblInstance.root = rootNode;\n const driver = pibblInstance.backendDriver;\n GLOBAL_STATE.backendDriver = driver;\n frame = driver.beginFrame({\n canvas,\n logicalWidth: pibblInstance.rootLayoutBox.width,\n logicalHeight: pibblInstance.rootLayoutBox.height,\n backingWidth: canvas.width,\n backingHeight: canvas.height,\n renderTimestamp: activeFrameSnapshot.logicalTime,\n });\n if (!frame) {\n pibblInstance.eventRoot.html?.suspend(pibblInstance);\n finishTransaction(true);\n return;\n }\n pibblInstance.eventRoot.html?.beginRender(pibblInstance);\n GLOBAL_STATE.backendFrame = frame;\n GLOBAL_STATE.backendEnvironment = frame.environment;\n GLOBAL_STATE.renderContext = frame.context2D;\n GLOBAL_STATE.renderTarget = frame.renderTarget;\n GLOBAL_STATE.worldBaseTransform = frame.worldBaseTransform;\n GLOBAL_STATE.worldExactTransform = undefined;\n GLOBAL_STATE.worldPaintAnchorTransform = undefined;\n GLOBAL_STATE.presentationTransformLineage = undefined;\n GLOBAL_STATE.presentationTransformLineageTrackingDepth = 0;\n if (\n frame.context2D !== undefined &&\n frame.renderTarget !== undefined &&\n frame.worldBaseTransform !== undefined\n ) {\n initializeCurrentWorldTransformAnchor(frame.worldBaseTransform);\n }\n GLOBAL_STATE.clippingStack = [];\n const surface = pibblInstance.surface.snapshot;\n const logicalWidth = surface?.logicalWidth ?? pibblInstance.rootLayoutBox.width;\n const logicalHeight = surface?.logicalHeight ?? pibblInstance.rootLayoutBox.height;\n const previousRootBox = pibblInstance.rootLayoutBox;\n if (\n previousRootBox.width !== logicalWidth ||\n previousRootBox.height !== logicalHeight\n ) {\n pibblInstance.rootLayoutBox = Object.freeze({\n x: 0,\n y: 0,\n width: logicalWidth,\n height: logicalHeight,\n });\n }\n GLOBAL_STATE.layoutStack = [{\n allocation: pibblInstance.rootLayoutBox,\n percentageBasis: pibblInstance.rootLayoutBox,\n }];\n\n const renderGeneration = ++pibblInstance.renderGeneration;\n if (!pibblInstance.parent) {\n renderTransaction.onFinish((success) => {\n if (success) pibblInstance.committedRenderGeneration = renderGeneration;\n });\n if (pibblInstance.rootFrameObservers?.size) {\n renderTransaction.onAfterFinish?.((success) => {\n const observers = pibblInstance.rootFrameObservers;\n if (!observers) return;\n for (const observer of observers)\n observer(success, renderGeneration);\n });\n }\n }\n renderSeenIds = pibblInstance.renderSeenIds;\n renderSeenKeys = pibblInstance.renderSeenKeys;\n renderSeenIds.clear();\n renderSeenKeys.clear();\n GLOBAL_STATE.seenIds = renderSeenIds;\n GLOBAL_STATE.seenKeys = renderSeenKeys;\n const id = 'root';\n renderSeenIds.add(id);\n withSignalWriteForbidden(\n 'Pibbl render',\n () => render(rootNode, id, undefined),\n );\n\n for (const [id, componentRefs] of pibblInstance.refs) {\n if (componentRefs.renderGeneration === renderGeneration) continue;\n componentRefs.teardowns.execute();\n pibblInstance.refs.delete(id);\n }\n frameSuccess = true;\n for (const service of pibblInstance.optionalServices.values()) service.endRender?.(true);\n driver.finishFrame(frame, true);\n finishTransaction(true);\n } catch (error) {\n for (const service of pibblInstance.optionalServices.values()) service.endRender?.(false);\n finishTransaction(false);\n for (const refs of pibblInstance.refs.values()) {\n refs.teardowns.execute();\n }\n pibblInstance.refs.clear();\n throw error;\n } finally {\n try {\n if (frame && !frameSuccess) {\n pibblInstance.backendDriver.finishFrame(frame, false);\n }\n } finally {\n try {\n clearTempState();\n GLOBAL_STATE.clippingStack = prevClippingStack;\n GLOBAL_STATE.layoutStack = prevLayoutStack;\n if (ownsRenderTransaction) {\n try {\n finishTransaction(false);\n } finally {\n if (pibblInstance.eventRoot.renderTransaction === renderTransaction) {\n pibblInstance.eventRoot.renderTransaction = undefined;\n }\n }\n }\n } finally {\n renderSeenIds?.clear();\n renderSeenKeys?.clear();\n GLOBAL_STATE.currentPibblInstance = prevCurrentPibblInstance;\n GLOBAL_STATE.canvas = prevCanvas;\n GLOBAL_STATE.renderContext = prevRenderContext;\n GLOBAL_STATE.renderTarget = prevRenderTarget;\n GLOBAL_STATE.worldBaseTransform = prevWorldBaseTransform;\n GLOBAL_STATE.worldExactTransform = prevWorldExactTransform;\n GLOBAL_STATE.worldPaintAnchorTransform = prevWorldPaintAnchorTransform;\n GLOBAL_STATE.presentationTransformLineage = prevPresentationTransformLineage;\n GLOBAL_STATE.presentationTransformLineageTrackingDepth =\n prevPresentationTransformLineageTrackingDepth;\n GLOBAL_STATE.renderTransaction = prevRenderTransaction;\n GLOBAL_STATE.frameSnapshot = prevFrameSnapshot;\n GLOBAL_STATE.primitiveReceiverToken = prevPrimitiveReceiverToken;\n GLOBAL_STATE.seenIds = prevSeenIds;\n GLOBAL_STATE.seenKeys = prevSeenKeys;\n GLOBAL_STATE.componentRefs = prevComponentRefs;\n GLOBAL_STATE.componentHookIndex = prevComponentHookIndex;\n GLOBAL_STATE.componentIsMounting = prevComponentIsMounting;\n GLOBAL_STATE.backendDriver = prevBackendDriver;\n GLOBAL_STATE.backendFrame = prevBackendFrame;\n GLOBAL_STATE.backendEnvironment =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AAe;AAC5B,qBAAa,qBAAqB;AAAA,MACpC;AAAA,IACF;AAAA,EACF;AACF;",
|
|
6
6
|
"names": ["id"]
|
|
7
7
|
}
|
|
@@ -1,24 +1,14 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { PibblAnimatedValueOptions } from '../animation/types.js';
|
|
2
2
|
import type { Signal, SignalValue } from '../signals/types.js';
|
|
3
|
+
type AnimatedValueInputs<T> = {
|
|
4
|
+
readonly [K in keyof PibblAnimatedValueOptions<T>]: SignalValue<PibblAnimatedValueOptions<T>[K]>;
|
|
5
|
+
};
|
|
3
6
|
/**
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
* @param
|
|
7
|
-
*
|
|
8
|
-
*
|
|
9
|
-
* @returns A readonly signal containing the animated value. See {@link Signal}.
|
|
7
|
+
* Presents a target through an immutable animation definition or a pure animation factory.
|
|
8
|
+
* @param targetInput - Target value or signal. See {@link SignalValue}.
|
|
9
|
+
* @param optionsInput - Animation definition, initial value, equality, and diagnostic settings;
|
|
10
|
+
* fields and the options object may be signals. See {@link PibblAnimatedValueOptions}.
|
|
11
|
+
* @returns One stable readonly animated signal. See {@link Signal}.
|
|
10
12
|
*/
|
|
11
|
-
export declare function useAnimatedValue(
|
|
12
|
-
|
|
13
|
-
}>): Signal<number>;
|
|
14
|
-
/**
|
|
15
|
-
* Animates a target using a tween and optional custom interpolation. See
|
|
16
|
-
* {@link PibblTweenAnimatedValueOptions} and {@link Signal}.
|
|
17
|
-
* @param target - Target value or signal whose changes start transitions. See {@link SignalValue}.
|
|
18
|
-
* @param options - Spring or tween configuration, including signal-backed fields. See
|
|
19
|
-
* {@link SignalValue} , {@link PibblTweenAnimatedValueOptions} .
|
|
20
|
-
* @returns A readonly signal containing the animated value. See {@link Signal}.
|
|
21
|
-
*/
|
|
22
|
-
export declare function useAnimatedValue<T>(target: SignalValue<T>, options: SignalValue<{
|
|
23
|
-
readonly [K in keyof PibblTweenAnimatedValueOptions<T>]: SignalValue<PibblTweenAnimatedValueOptions<T>[K]>;
|
|
24
|
-
}>): Signal<T>;
|
|
13
|
+
export declare function useAnimatedValue<T>(targetInput: SignalValue<T>, optionsInput: SignalValue<AnimatedValueInputs<NoInfer<T>>>): Signal<T>;
|
|
14
|
+
export {};
|
|
@@ -1,8 +1,9 @@
|
|
|
1
|
+
import { bindAnimationTarget } from "../animation/definition.js";
|
|
2
|
+
import { drive } from "../animation/program.js";
|
|
3
|
+
import { withSignalWriteForbidden } from "../signals/graph.js";
|
|
1
4
|
import {
|
|
2
5
|
createAnimationPlaybackController
|
|
3
6
|
} from "../animation/playback.js";
|
|
4
|
-
import { spring, tween } from "../animation/definition.js";
|
|
5
|
-
import { drive } from "../animation/program.js";
|
|
6
7
|
import { GLOBAL_STATE } from "../global-state.js";
|
|
7
8
|
import {
|
|
8
9
|
isSignal,
|
|
@@ -11,45 +12,16 @@ import {
|
|
|
11
12
|
untracked
|
|
12
13
|
} from "../signals/graph.js";
|
|
13
14
|
import { resolveSignalValue } from "../signals/resolve-signal-value.js";
|
|
14
|
-
import { requireHookContext, useHookSlot } from "./hook-slot.js";
|
|
15
|
-
function hasOwn(value, key) {
|
|
16
|
-
return Object.prototype.hasOwnProperty.call(value, key);
|
|
17
|
-
}
|
|
15
|
+
import { requireHookContext, useHookSlot, withHooksForbidden } from "./hook-slot.js";
|
|
18
16
|
function normalizeCandidate(target, options) {
|
|
19
17
|
if (typeof options !== "object" || options === null) {
|
|
20
|
-
throw new TypeError("
|
|
21
|
-
}
|
|
22
|
-
if (options.type !== "tween" && options.type !== "spring") {
|
|
23
|
-
throw new TypeError('Pibbl transition type must be "tween" or "spring".');
|
|
18
|
+
throw new TypeError("useAnimatedValue options must be an object.");
|
|
24
19
|
}
|
|
25
20
|
if (options.equals !== void 0 && typeof options.equals !== "function") {
|
|
26
21
|
throw new TypeError("Pibbl transition equals must be a function.");
|
|
27
22
|
}
|
|
28
23
|
const snapshot = Object.freeze({ ...options });
|
|
29
|
-
|
|
30
|
-
spring({
|
|
31
|
-
from: target,
|
|
32
|
-
to: target,
|
|
33
|
-
mass: snapshot.mass,
|
|
34
|
-
stiffness: snapshot.stiffness,
|
|
35
|
-
damping: snapshot.damping,
|
|
36
|
-
initialVelocity: snapshot.initialVelocity,
|
|
37
|
-
restSpeed: snapshot.restSpeed,
|
|
38
|
-
restDelta: snapshot.restDelta,
|
|
39
|
-
maxDuration: snapshot.maxDuration,
|
|
40
|
-
debugName: snapshot.debugName
|
|
41
|
-
});
|
|
42
|
-
} else {
|
|
43
|
-
tween({
|
|
44
|
-
from: target,
|
|
45
|
-
to: target,
|
|
46
|
-
duration: snapshot.duration,
|
|
47
|
-
easing: snapshot.easing,
|
|
48
|
-
interpolate: snapshot.interpolate,
|
|
49
|
-
debugName: snapshot.debugName
|
|
50
|
-
});
|
|
51
|
-
}
|
|
52
|
-
const hasInitial = hasOwn(options, "initial");
|
|
24
|
+
const hasInitial = Object.prototype.hasOwnProperty.call(options, "initial");
|
|
53
25
|
return Object.freeze({
|
|
54
26
|
options: snapshot,
|
|
55
27
|
equals: snapshot.equals ?? Object.is,
|
|
@@ -58,31 +30,6 @@ function normalizeCandidate(target, options) {
|
|
|
58
30
|
target
|
|
59
31
|
});
|
|
60
32
|
}
|
|
61
|
-
function programFor(output, from, candidate, springVelocity) {
|
|
62
|
-
const options = candidate.options;
|
|
63
|
-
if (options.type === "spring") {
|
|
64
|
-
return drive(output, spring({
|
|
65
|
-
from,
|
|
66
|
-
to: candidate.target,
|
|
67
|
-
mass: options.mass,
|
|
68
|
-
stiffness: options.stiffness,
|
|
69
|
-
damping: options.damping,
|
|
70
|
-
initialVelocity: springVelocity ?? options.initialVelocity,
|
|
71
|
-
restSpeed: options.restSpeed,
|
|
72
|
-
restDelta: options.restDelta,
|
|
73
|
-
maxDuration: options.maxDuration,
|
|
74
|
-
debugName: options.debugName
|
|
75
|
-
}));
|
|
76
|
-
}
|
|
77
|
-
return drive(output, tween({
|
|
78
|
-
from,
|
|
79
|
-
to: candidate.target,
|
|
80
|
-
duration: options.duration,
|
|
81
|
-
easing: options.easing,
|
|
82
|
-
interpolate: options.interpolate,
|
|
83
|
-
debugName: options.debugName
|
|
84
|
-
}));
|
|
85
|
-
}
|
|
86
33
|
function isCurrentSlot(slot) {
|
|
87
34
|
return !slot.componentRefs.teardowns.closed && !slot.pibblInstance.mainTeardowns.closed && GLOBAL_STATE.pibblInstances.get(slot.pibblInstance.canvas) === slot.pibblInstance && slot.pibblInstance.refs.get(slot.componentRefs.id) === slot.componentRefs;
|
|
88
35
|
}
|
|
@@ -91,13 +38,14 @@ function useAnimatedValue(targetInput, optionsInput) {
|
|
|
91
38
|
const target = resolveSignalValue(targetInput);
|
|
92
39
|
const options = resolveTransitionOptions(optionsInput);
|
|
93
40
|
const candidate = normalizeCandidate(target, options);
|
|
94
|
-
const slot = useHookSlot("
|
|
41
|
+
const slot = useHookSlot("animatedValue", (teardowns) => {
|
|
95
42
|
const output = signal(candidate.initial);
|
|
96
|
-
const
|
|
97
|
-
const controller = createAnimationPlaybackController(
|
|
43
|
+
const program2 = programFor(output, candidate.initial, candidate);
|
|
44
|
+
const controller = createAnimationPlaybackController(program2, {
|
|
98
45
|
conflict: "replace",
|
|
99
46
|
debugName: candidate.options.debugName
|
|
100
47
|
});
|
|
48
|
+
controller.setDeferredStatusCommandOwner(pibblInstance.mainTeardowns);
|
|
101
49
|
const value = {
|
|
102
50
|
componentRefs,
|
|
103
51
|
controller,
|
|
@@ -111,6 +59,12 @@ function useAnimatedValue(targetInput, optionsInput) {
|
|
|
111
59
|
teardowns.add(() => controller.dispose());
|
|
112
60
|
return value;
|
|
113
61
|
}).value;
|
|
62
|
+
const program = programFor(
|
|
63
|
+
slot.output,
|
|
64
|
+
slot.settled ? untracked(() => slot.output.get()) : candidate.initial,
|
|
65
|
+
candidate,
|
|
66
|
+
slot.settled ? slot.controller.committedSpringSnapshot()?.velocity : void 0
|
|
67
|
+
);
|
|
114
68
|
const shouldEnter = !slot.settled && candidate.hasInitial && !candidate.equals(candidate.initial, candidate.target);
|
|
115
69
|
const shouldRetarget = slot.settled && !candidate.equals(slot.target, candidate.target);
|
|
116
70
|
const previousProvisionalValue = untracked(() => slot.output.get());
|
|
@@ -130,7 +84,7 @@ function useAnimatedValue(targetInput, optionsInput) {
|
|
|
130
84
|
slot.target = candidate.target;
|
|
131
85
|
if (!shouldEnter && !shouldRetarget) {
|
|
132
86
|
slot.controller.adopt(
|
|
133
|
-
|
|
87
|
+
program,
|
|
134
88
|
{
|
|
135
89
|
conflict: "replace",
|
|
136
90
|
debugName: candidate.options.debugName
|
|
@@ -138,13 +92,6 @@ function useAnimatedValue(targetInput, optionsInput) {
|
|
|
138
92
|
);
|
|
139
93
|
return;
|
|
140
94
|
}
|
|
141
|
-
const springVelocity = candidate.options.type === "spring" ? slot.controller.committedSpringSnapshot()?.velocity : void 0;
|
|
142
|
-
const program = programFor(
|
|
143
|
-
slot.output,
|
|
144
|
-
slot.output.get(),
|
|
145
|
-
candidate,
|
|
146
|
-
springVelocity
|
|
147
|
-
);
|
|
148
95
|
slot.controller.retarget(program, {
|
|
149
96
|
conflict: "replace",
|
|
150
97
|
debugName: candidate.options.debugName
|
|
@@ -163,6 +110,12 @@ function resolveTransitionOptions(input) {
|
|
|
163
110
|
}
|
|
164
111
|
return resolved ?? source;
|
|
165
112
|
}
|
|
113
|
+
function programFor(output, from, candidate, velocity) {
|
|
114
|
+
const context = Object.freeze({ from, to: candidate.target, velocity });
|
|
115
|
+
const animation = candidate.options.animation;
|
|
116
|
+
const definition = typeof animation === "function" ? withHooksForbidden("Animation factories cannot call hooks.", () => withSignalWriteForbidden("Animation factories cannot write to signals.", () => animation(context))) : animation;
|
|
117
|
+
return drive(output, bindAnimationTarget(definition, context));
|
|
118
|
+
}
|
|
166
119
|
export {
|
|
167
120
|
useAnimatedValue
|
|
168
121
|
};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/lib/hooks/use-animated-value.ts"],
|
|
4
|
-
"sourcesContent": ["import {\n createAnimationPlaybackController,\n type AnimationPlaybackController,\n} from '../animation/playback.js';\nimport { spring, tween } from '../animation/definition.js';\nimport { drive } from '../animation/program.js';\nimport type {\n PibblAnimationProgram,\n PibblSpringAnimatedValueOptions,\n PibblTweenAnimatedValueOptions,\n} from '../animation/types.js';\nimport { GLOBAL_STATE } from '../global-state.js';\nimport {\n isSignal,\n provisionSignalValueForRender,\n signal,\n untracked,\n} from '../signals/graph.js';\nimport { resolveSignalValue } from '../signals/resolve-signal-value.js';\nimport type {\n Signal,\n SignalEquals,\n SignalValue,\n WritableSignal,\n} from '../signals/types.js';\nimport type { PibblComponentRefs, PibblInstance } from '../types.js';\nimport { requireHookContext, useHookSlot } from './hook-slot.js';\n\ntype PibblTransitionOptions<T> =\n | PibblTweenAnimatedValueOptions<T>\n | PibblSpringAnimatedValueOptions;\n\ntype PibblTransitionOptionsInput<T> =\n | {\n readonly [K in keyof PibblTweenAnimatedValueOptions<T>]:\n SignalValue<PibblTweenAnimatedValueOptions<T>[K]>;\n }\n | {\n readonly [K in keyof PibblSpringAnimatedValueOptions]:\n SignalValue<PibblSpringAnimatedValueOptions[K]>;\n };\n\ninterface PibblTransitionCandidate<T> {\n readonly options: PibblTransitionOptions<T>;\n readonly equals: SignalEquals<T>;\n readonly hasInitial: boolean;\n readonly initial: T;\n readonly target: T;\n}\n\ninterface PibblTransitionHookSlot<T> {\n readonly componentRefs: PibblComponentRefs<any>;\n readonly controller: AnimationPlaybackController;\n readonly pibblInstance: PibblInstance;\n readonly output: WritableSignal<T>;\n readonly readonlyOutput: Signal<T>;\n renderRevision: number;\n settled: boolean;\n target: T;\n}\n\nfunction hasOwn(value: object, key: PropertyKey): boolean {\n return Object.prototype.hasOwnProperty.call(value, key);\n}\n\nfunction normalizeCandidate<T>(\n target: T,\n options: PibblTransitionOptions<T>,\n): PibblTransitionCandidate<T> {\n if (typeof options !== 'object' || options === null) {\n throw new TypeError('Pibbl transition options must be an object.');\n }\n if (options.type !== 'tween' && options.type !== 'spring') {\n throw new TypeError('Pibbl transition type must be \"tween\" or \"spring\".');\n }\n if (options.equals !== undefined && typeof options.equals !== 'function') {\n throw new TypeError('Pibbl transition equals must be a function.');\n }\n const snapshot = Object.freeze({ ...options }) as PibblTransitionOptions<T>;\n if (snapshot.type === 'spring') {\n spring({\n from: target as number,\n to: target as number,\n mass: snapshot.mass,\n stiffness: snapshot.stiffness,\n damping: snapshot.damping,\n initialVelocity: snapshot.initialVelocity,\n restSpeed: snapshot.restSpeed,\n restDelta: snapshot.restDelta,\n maxDuration: snapshot.maxDuration,\n debugName: snapshot.debugName,\n });\n } else {\n tween({\n from: target,\n to: target,\n duration: snapshot.duration,\n easing: snapshot.easing,\n interpolate: snapshot.interpolate,\n debugName: snapshot.debugName,\n });\n }\n const hasInitial = hasOwn(options, 'initial');\n return Object.freeze({\n options: snapshot,\n equals: (snapshot.equals ?? Object.is) as SignalEquals<T>,\n hasInitial,\n initial: (hasInitial ? snapshot.initial : target) as T,\n target,\n });\n}\n\nfunction programFor<T>(\n output: WritableSignal<T>,\n from: T,\n candidate: PibblTransitionCandidate<T>,\n springVelocity?: number,\n): PibblAnimationProgram {\n const options = candidate.options;\n if (options.type === 'spring') {\n return drive(output as unknown as WritableSignal<number>, spring({\n from: from as number,\n to: candidate.target as number,\n mass: options.mass,\n stiffness: options.stiffness,\n damping: options.damping,\n initialVelocity: springVelocity ?? options.initialVelocity,\n restSpeed: options.restSpeed,\n restDelta: options.restDelta,\n maxDuration: options.maxDuration,\n debugName: options.debugName,\n }));\n }\n return drive(output, tween({\n from,\n to: candidate.target,\n duration: options.duration,\n easing: options.easing,\n interpolate: options.interpolate,\n debugName: options.debugName,\n }));\n}\n\nfunction isCurrentSlot<T>(slot: PibblTransitionHookSlot<T>): boolean {\n return !slot.componentRefs.teardowns.closed &&\n !slot.pibblInstance.mainTeardowns.closed &&\n GLOBAL_STATE.pibblInstances.get(slot.pibblInstance.canvas) === slot.pibblInstance &&\n slot.pibblInstance.refs.get(slot.componentRefs.id) === slot.componentRefs;\n}\n\n/**\n * Animates a numeric target using an analytic spring. See {@link PibblSpringAnimatedValueOptions}\n * and {@link Signal}.\n * @param target - Target value or signal whose changes start transitions. See {@link SignalValue}.\n * @param options - Spring or tween configuration, including signal-backed fields. See\n * {@link SignalValue} , {@link PibblSpringAnimatedValueOptions} .\n * @returns A readonly signal containing the animated value. See {@link Signal}.\n */\nexport function useAnimatedValue(\n target: SignalValue<number>,\n options: SignalValue<{\n readonly [K in keyof PibblSpringAnimatedValueOptions]:\n SignalValue<PibblSpringAnimatedValueOptions[K]>;\n }>,\n): Signal<number>;\n/**\n * Animates a target using a tween and optional custom interpolation. See\n * {@link PibblTweenAnimatedValueOptions} and {@link Signal}.\n * @param target - Target value or signal whose changes start transitions. See {@link SignalValue}.\n * @param options - Spring or tween configuration, including signal-backed fields. See\n * {@link SignalValue} , {@link PibblTweenAnimatedValueOptions} .\n * @returns A readonly signal containing the animated value. See {@link Signal}.\n */\nexport function useAnimatedValue<T>(\n target: SignalValue<T>,\n options: SignalValue<{\n readonly [K in keyof PibblTweenAnimatedValueOptions<T>]:\n SignalValue<PibblTweenAnimatedValueOptions<T>[K]>;\n }>,\n): Signal<T>;\n/**\n * Returns a mount-owned signal that animates toward the current target using the supplied\n * transition options.\n *\n * @param targetInput - Target value or signal whose changes start transitions. See\n * {@link SignalValue} .\n * @param optionsInput - Spring or tween configuration, including signal-backed fields. See\n * {@link SignalValue} , {@link PibblTransitionOptionsInput} .\n * @returns A readonly signal containing the animated value. See {@link Signal}.\n *\n * @see {@link SignalValue}\n * @see {@link Signal}\n */\nexport function useAnimatedValue<T>(\n targetInput: SignalValue<T>,\n optionsInput: SignalValue<PibblTransitionOptionsInput<T>>,\n): Signal<T> {\n const { componentRefs, pibblInstance } = requireHookContext();\n const target = resolveSignalValue(targetInput);\n const options = resolveTransitionOptions(optionsInput);\n const candidate = normalizeCandidate(target, options);\n const slot = useHookSlot<PibblTransitionHookSlot<T>>('transition', teardowns => {\n const output = signal(candidate.initial);\n const program = programFor(output, candidate.initial, candidate);\n const controller = createAnimationPlaybackController(program, {\n conflict: 'replace',\n debugName: candidate.options.debugName,\n });\n const value: PibblTransitionHookSlot<T> = {\n componentRefs,\n controller,\n pibblInstance,\n output,\n readonlyOutput: output.asReadonly(),\n renderRevision: 0,\n settled: false,\n target: candidate.target,\n };\n teardowns.add(() => controller.dispose());\n return value;\n }).value;\n\n const shouldEnter = !slot.settled && candidate.hasInitial &&\n !candidate.equals(candidate.initial, candidate.target);\n const shouldRetarget = slot.settled &&\n !candidate.equals(slot.target, candidate.target);\n const previousProvisionalValue = untracked(() => slot.output.get());\n const hasProvisionalValue = !slot.settled &&\n !Object.is(previousProvisionalValue, candidate.initial);\n const transaction = GLOBAL_STATE.renderTransaction;\n if (!transaction) {\n throw new Error('useAnimatedValue requires an active Pibbl render transaction.');\n }\n if (hasProvisionalValue) {\n provisionSignalValueForRender(slot.output, candidate.initial, transaction);\n }\n const revision = ++slot.renderRevision;\n transaction.onFinish(success => {\n if (!success) return;\n if (revision !== slot.renderRevision || !isCurrentSlot(slot)) return;\n slot.settled = true;\n slot.target = candidate.target;\n if (!shouldEnter && !shouldRetarget) {\n slot.controller.adopt(\n programFor(slot.output, slot.output.get(), candidate),\n {\n conflict: 'replace',\n debugName: candidate.options.debugName,\n },\n );\n return;\n }\n const springVelocity = candidate.options.type === 'spring' ?\n slot.controller.committedSpringSnapshot()?.velocity : undefined;\n const program = programFor(\n slot.output,\n slot.output.get(),\n candidate,\n springVelocity,\n );\n slot.controller.retarget(program, {\n conflict: 'replace',\n debugName: candidate.options.debugName,\n });\n });\n return slot.readonlyOutput;\n}\n\nfunction resolveTransitionOptions<T>(\n input: SignalValue<PibblTransitionOptionsInput<T>>,\n): PibblTransitionOptions<T> {\n const source = resolveSignalValue(input);\n let resolved: Record<PropertyKey, unknown> | undefined;\n for (const key in source) {\n const value = source[key as keyof typeof source];\n if (!isSignal(value)) continue;\n resolved ??= { ...source };\n resolved[key] = resolveSignalValue(value as SignalValue<unknown>);\n }\n return (resolved ?? source) as PibblTransitionOptions<T>;\n}\n"],
|
|
5
|
-
"mappings": "AAAA
|
|
6
|
-
"names": []
|
|
4
|
+
"sourcesContent": ["import { bindAnimationTarget } from '../animation/definition.js';\nimport { drive } from '../animation/program.js';\nimport { withSignalWriteForbidden } from '../signals/graph.js';\nimport {\n createAnimationPlaybackController,\n type AnimationPlaybackController,\n} from '../animation/playback.js';\nimport type {\n PibblAnimatedValueOptions,\n} from '../animation/types.js';\nimport { GLOBAL_STATE } from '../global-state.js';\nimport {\n isSignal,\n provisionSignalValueForRender,\n signal,\n untracked,\n} from '../signals/graph.js';\nimport { resolveSignalValue } from '../signals/resolve-signal-value.js';\nimport type {\n Signal,\n SignalEquals,\n SignalValue,\n WritableSignal,\n} from '../signals/types.js';\nimport type { PibblComponentRefs, PibblInstance } from '../types.js';\nimport { requireHookContext, useHookSlot, withHooksForbidden } from './hook-slot.js';\n\ntype AnimatedValueInputs<T> = {\n readonly [K in keyof PibblAnimatedValueOptions<T>]: SignalValue<PibblAnimatedValueOptions<T>[K]>;\n};\n\ninterface PibblTransitionCandidate<T> {\n readonly options: PibblAnimatedValueOptions<T>;\n readonly equals: SignalEquals<T>;\n readonly hasInitial: boolean;\n readonly initial: T;\n readonly target: T;\n}\n\ninterface PibblTransitionHookSlot<T> {\n readonly componentRefs: PibblComponentRefs<any>;\n readonly controller: AnimationPlaybackController;\n readonly pibblInstance: PibblInstance;\n readonly output: WritableSignal<T>;\n readonly readonlyOutput: Signal<T>;\n renderRevision: number;\n settled: boolean;\n target: T;\n}\n\nfunction normalizeCandidate<T>(\n target: T,\n options: PibblAnimatedValueOptions<T>,\n): PibblTransitionCandidate<T> {\n if (typeof options !== 'object' || options === null) {\n throw new TypeError('useAnimatedValue options must be an object.');\n }\n if (options.equals !== undefined && typeof options.equals !== 'function') {\n throw new TypeError('Pibbl transition equals must be a function.');\n }\n const snapshot = Object.freeze({ ...options });\n const hasInitial = Object.prototype.hasOwnProperty.call(options, 'initial');\n return Object.freeze({\n options: snapshot,\n equals: snapshot.equals ?? Object.is,\n hasInitial,\n initial: (hasInitial ? snapshot.initial : target) as T,\n target,\n });\n}\n\nfunction isCurrentSlot<T>(slot: PibblTransitionHookSlot<T>): boolean {\n return !slot.componentRefs.teardowns.closed &&\n !slot.pibblInstance.mainTeardowns.closed &&\n GLOBAL_STATE.pibblInstances.get(slot.pibblInstance.canvas) === slot.pibblInstance &&\n slot.pibblInstance.refs.get(slot.componentRefs.id) === slot.componentRefs;\n}\n\n/**\n * Presents a target through an immutable animation definition or a pure animation factory.\n * @param targetInput - Target value or signal. See {@link SignalValue}.\n * @param optionsInput - Animation definition, initial value, equality, and diagnostic settings;\n * fields and the options object may be signals. See {@link PibblAnimatedValueOptions}.\n * @returns One stable readonly animated signal. See {@link Signal}.\n */\nexport function useAnimatedValue<T>(\n targetInput: SignalValue<T>,\n optionsInput: SignalValue<AnimatedValueInputs<NoInfer<T>>>,\n): Signal<T> {\n const { componentRefs, pibblInstance } = requireHookContext();\n const target = resolveSignalValue(targetInput);\n const options = resolveTransitionOptions<T>(optionsInput);\n const candidate = normalizeCandidate(target, options);\n const slot = useHookSlot<PibblTransitionHookSlot<T>>('animatedValue', teardowns => {\n const output = signal(candidate.initial);\n const program = programFor(output, candidate.initial, candidate);\n const controller = createAnimationPlaybackController(program, {\n conflict: 'replace',\n debugName: candidate.options.debugName,\n });\n controller.setDeferredStatusCommandOwner(pibblInstance.mainTeardowns);\n const value: PibblTransitionHookSlot<T> = {\n componentRefs,\n controller,\n pibblInstance,\n output,\n readonlyOutput: output.asReadonly(),\n renderRevision: 0,\n settled: false,\n target: candidate.target,\n };\n teardowns.add(() => controller.dispose());\n return value;\n }).value;\n\n // Prepare user-defined work while Render can still fail transactionally. No factory runs\n // in onFinish, where a late exception could otherwise adopt only part of the update.\n const program = programFor(slot.output,\n slot.settled ? untracked(() => slot.output.get()) : candidate.initial,\n candidate, slot.settled ? slot.controller.committedSpringSnapshot()?.velocity : undefined);\n\n const shouldEnter = !slot.settled && candidate.hasInitial &&\n !candidate.equals(candidate.initial, candidate.target);\n const shouldRetarget = slot.settled &&\n !candidate.equals(slot.target, candidate.target);\n const previousProvisionalValue = untracked(() => slot.output.get());\n const hasProvisionalValue = !slot.settled &&\n !Object.is(previousProvisionalValue, candidate.initial);\n const transaction = GLOBAL_STATE.renderTransaction;\n if (!transaction) {\n throw new Error('useAnimatedValue requires an active Pibbl render transaction.');\n }\n if (hasProvisionalValue) {\n provisionSignalValueForRender(slot.output, candidate.initial, transaction);\n }\n const revision = ++slot.renderRevision;\n transaction.onFinish(success => {\n if (!success) return;\n if (revision !== slot.renderRevision || !isCurrentSlot(slot)) return;\n slot.settled = true;\n slot.target = candidate.target;\n if (!shouldEnter && !shouldRetarget) {\n slot.controller.adopt(\n program,\n {\n conflict: 'replace',\n debugName: candidate.options.debugName,\n },\n );\n return;\n }\n slot.controller.retarget(program, {\n conflict: 'replace',\n debugName: candidate.options.debugName,\n });\n });\n return slot.readonlyOutput;\n}\n\nfunction resolveTransitionOptions<T>(\n input: SignalValue<AnimatedValueInputs<T>>,\n): PibblAnimatedValueOptions<T> {\n const source = resolveSignalValue(input);\n let resolved: Record<PropertyKey, unknown> | undefined;\n for (const key in source) {\n const value = source[key as keyof typeof source];\n if (!isSignal(value)) continue;\n resolved ??= { ...source };\n resolved[key] = resolveSignalValue(value as SignalValue<unknown>);\n }\n return (resolved ?? source) as PibblAnimatedValueOptions<T>;\n}\n\nfunction programFor<T>(\n output: WritableSignal<T>, from: T, candidate: PibblTransitionCandidate<T>, velocity?: number,\n) {\n const context = Object.freeze({ from, to: candidate.target, velocity });\n const animation = candidate.options.animation;\n const definition = typeof animation === 'function'\n ? withHooksForbidden('Animation factories cannot call hooks.', () =>\n withSignalWriteForbidden('Animation factories cannot write to signals.', () => animation(context)))\n : animation;\n return drive(output, bindAnimationTarget(definition, context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ACf,SAAK,SAAS,UAAU;AACxB,QAAI,CAAC,eAAe,CAAC,gBAAgB;AACnC,WAAK,WAAW;AAAA,QACd;AAAA,QACA;AAAA,UACE,UAAU;AAAA,UACV,WAAW,UAAU,QAAQ;AAAA,QAC/B;AAAA,MACF;AACA;AAAA,IACF;AACA,SAAK,WAAW,SAAS,SAAS;AAAA,MAChC,UAAU;AAAA,MACV,WAAW,UAAU,QAAQ;AAAA,IAC/B,CAAC;AAAA,EACH,CAAC;AACD,SAAO,KAAK;AACd;AAEA,SAAS,yBACP,OAC8B;AAC9B,QAAM,SAAS,mBAAmB,KAAK;AACvC,MAAI;AACJ,aAAW,OAAO,QAAQ;AACxB,UAAM,QAAQ,OAAO,GAA0B;AAC/C,QAAI,CAAC,SAAS,KAAK,EAAG;AACtB,iBAAa,EAAE,GAAG,OAAO;AACzB,aAAS,GAAG,IAAI,mBAAmB,KAA6B;AAAA,EAClE;AACA,SAAQ,YAAY;AACtB;AAEA,SAAS,WACP,QAA2B,MAAS,WAAwC,UAC5E;AACA,QAAM,UAAU,OAAO,OAAO,EAAE,MAAM,IAAI,UAAU,QAAQ,SAAS,CAAC;AACtE,QAAM,YAAY,UAAU,QAAQ;AACpC,QAAM,aAAa,OAAO,cAAc,aACpC,mBAAmB,0CAA0C,MAC7D,yBAAyB,gDAAgD,MAAM,UAAU,OAAO,CAAC,CAAC,IAClG;AACJ,SAAO,MAAM,QAAQ,oBAAoB,YAAY,OAAO,CAAC;AAC/D;",
|
|
6
|
+
"names": ["program"]
|
|
7
7
|
}
|
|
@@ -28,6 +28,7 @@ function usePlayback(programInput, optionsInput = {}) {
|
|
|
28
28
|
candidate.program,
|
|
29
29
|
candidateOptions
|
|
30
30
|
);
|
|
31
|
+
controller.setDeferredStatusCommandOwner(pibblInstance.mainTeardowns);
|
|
31
32
|
const onEvent = (event) => {
|
|
32
33
|
if (isCurrentSlot(value)) value.latestOptions.onEvent?.(event);
|
|
33
34
|
};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/lib/hooks/use-playback.ts"],
|
|
4
|
-
"sourcesContent": ["import {\n createAnimationPlaybackController,\n normalizeAnimationPlaybackCandidate,\n type AnimationPlaybackController,\n} from '../animation/playback.js';\nimport type {\n PibblAnimationProgram,\n PibblPlayback,\n PibblPlaybackEvent,\n PibblPlaybackOptions,\n} from '../animation/types.js';\nimport { GLOBAL_STATE } from '../global-state.js';\nimport { isSignal } from '../signals/graph.js';\nimport { resolveSignalValue } from '../signals/resolve-signal-value.js';\nimport type { SignalValue } from '../signals/types.js';\nimport type { PibblComponentRefs, PibblInstance } from '../types.js';\nimport { requireHookContext, useHookSlot } from './hook-slot.js';\n\ntype PibblPlaybackOptionsInput = {\n readonly [K in keyof PibblPlaybackOptions]: SignalValue<PibblPlaybackOptions[K]>;\n};\n\ninterface PibblPlaybackHookSlot {\n readonly controller: AnimationPlaybackController;\n readonly componentRefs: PibblComponentRefs<any>;\n readonly pibblInstance: PibblInstance;\n latestOptions: PibblPlaybackOptions;\n mountSettled: boolean;\n readonly onError: (error: unknown) => void;\n readonly onEvent: (event: PibblPlaybackEvent) => void;\n renderRevision: number;\n}\n\nfunction isCurrentSlot(slot: PibblPlaybackHookSlot): boolean {\n return !slot.componentRefs.teardowns.closed &&\n !slot.pibblInstance.mainTeardowns.closed &&\n GLOBAL_STATE.pibblInstances.get(slot.pibblInstance.canvas) === slot.pibblInstance &&\n slot.pibblInstance.refs.get(slot.componentRefs.id) === slot.componentRefs;\n}\n\nfunction controllerOptions(\n candidate: PibblPlaybackOptions,\n onEvent: (event: PibblPlaybackEvent) => void,\n onError: (error: unknown) => void,\n): PibblPlaybackOptions {\n return {\n ...candidate,\n onEvent: typeof candidate.onEvent === 'function' ?\n onEvent : candidate.onEvent,\n onError: typeof candidate.onError === 'function' ?\n onError : candidate.onError,\n };\n}\n\n/**\n * Creates one component-owned animation playback handle for a hook slot.\n *\n * @param programInput - Animation program, optionally supplied by a signal. See\n * {@link SignalValue} , {@link PibblAnimationProgram} .\n * @param optionsInput - Playback configuration, optionally supplied by a signal. See\n * {@link SignalValue} , {@link PibblPlaybackOptionsInput} .\n * @returns Stable mount-owned playback controls and reactive status/time values. See\n * {@link PibblPlayback} .\n *\n * @see {@link SignalValue}\n * @see {@link PibblAnimationProgram}\n * @see {@link PibblPlayback}\n */\nexport function usePlayback(\n programInput: SignalValue<PibblAnimationProgram>,\n optionsInput: SignalValue<PibblPlaybackOptionsInput> = {},\n): PibblPlayback {\n const { componentRefs, pibblInstance } = requireHookContext();\n const program = resolveSignalValue(programInput);\n const options = resolvePlaybackOptions(optionsInput);\n const candidate = normalizeAnimationPlaybackCandidate(program, options);\n const candidateOptions = candidate.options;\n const slot = useHookSlot<PibblPlaybackHookSlot>('playback', teardowns => {\n let value!: PibblPlaybackHookSlot;\n const controller = createAnimationPlaybackController(\n candidate.program,\n candidateOptions,\n );\n const onEvent = (event: PibblPlaybackEvent): void => {\n if (isCurrentSlot(value)) value.latestOptions.onEvent?.(event);\n };\n const onError = (error: unknown): void => {\n if (isCurrentSlot(value)) value.latestOptions.onError?.(error);\n };\n value = {\n controller,\n componentRefs,\n pibblInstance,\n latestOptions: {},\n mountSettled: false,\n onError,\n onEvent,\n renderRevision: 0,\n };\n controller.adopt(\n candidate.program,\n controllerOptions(candidateOptions, onEvent, onError),\n );\n teardowns.add(() => controller.dispose());\n return value;\n }).value;\n const revision = ++slot.renderRevision;\n const transaction = GLOBAL_STATE.renderTransaction;\n if (!transaction) {\n throw new Error('usePlayback requires an active Pibbl render transaction.');\n }\n transaction.onFinish(success => {\n if (!success || revision !== slot.renderRevision || !isCurrentSlot(slot)) return;\n slot.controller.adopt(\n candidate.program,\n controllerOptions(candidateOptions, slot.onEvent, slot.onError),\n );\n slot.latestOptions = candidateOptions;\n if (!slot.mountSettled) {\n slot.mountSettled = true;\n if (candidateOptions.autoplay === true) slot.controller.handle.play();\n }\n });\n return slot.controller.handle;\n}\n\nfunction resolvePlaybackOptions(\n input: SignalValue<PibblPlaybackOptionsInput>,\n): PibblPlaybackOptions {\n const source = resolveSignalValue(input);\n let resolved: Record<PropertyKey, unknown> | undefined;\n for (const key in source) {\n const value = source[key as keyof PibblPlaybackOptionsInput];\n if (!isSignal(value)) continue;\n resolved ??= { ...source };\n resolved[key] = resolveSignalValue(value as SignalValue<unknown>);\n }\n return (resolved ?? source) as PibblPlaybackOptions;\n}\n"],
|
|
5
|
-
"mappings": "AAAA;AAAA,EACE;AAAA,EACA;AAAA,OAEK;AAOP,SAAS,oBAAoB;AAC7B,SAAS,gBAAgB;AACzB,SAAS,0BAA0B;AAGnC,SAAS,oBAAoB,mBAAmB;AAiBhD,SAAS,cAAc,MAAsC;AAC3D,SAAO,CAAC,KAAK,cAAc,UAAU,UACnC,CAAC,KAAK,cAAc,cAAc,UAClC,aAAa,eAAe,IAAI,KAAK,cAAc,MAAM,MAAM,KAAK,iBACpE,KAAK,cAAc,KAAK,IAAI,KAAK,cAAc,EAAE,MAAM,KAAK;AAChE;AAEA,SAAS,kBACP,WACA,SACA,SACsB;AACtB,SAAO;AAAA,IACL,GAAG;AAAA,IACH,SAAS,OAAO,UAAU,YAAY,aACpC,UAAU,UAAU;AAAA,IACtB,SAAS,OAAO,UAAU,YAAY,aACpC,UAAU,UAAU;AAAA,EACxB;AACF;AAgBO,SAAS,YACd,cACA,eAAuD,CAAC,GACzC;AACf,QAAM,EAAE,eAAe,cAAc,IAAI,mBAAmB;AAC5D,QAAM,UAAU,mBAAmB,YAAY;AAC/C,QAAM,UAAU,uBAAuB,YAAY;AACnD,QAAM,YAAY,oCAAoC,SAAS,OAAO;AACtE,QAAM,mBAAmB,UAAU;AACnC,QAAM,OAAO,YAAmC,YAAY,eAAa;AACvE,QAAI;AACJ,UAAM,aAAa;AAAA,MACjB,UAAU;AAAA,MACV;AAAA,IACF;AACA,UAAM,UAAU,CAAC,UAAoC;AACnD,UAAI,cAAc,KAAK,EAAG,OAAM,cAA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,\n normalizeAnimationPlaybackCandidate,\n type AnimationPlaybackController,\n} from '../animation/playback.js';\nimport type {\n PibblAnimationProgram,\n PibblPlayback,\n PibblPlaybackEvent,\n PibblPlaybackOptions,\n} from '../animation/types.js';\nimport { GLOBAL_STATE } from '../global-state.js';\nimport { isSignal } from '../signals/graph.js';\nimport { resolveSignalValue } from '../signals/resolve-signal-value.js';\nimport type { SignalValue } from '../signals/types.js';\nimport type { PibblComponentRefs, PibblInstance } from '../types.js';\nimport { requireHookContext, useHookSlot } from './hook-slot.js';\n\ntype PibblPlaybackOptionsInput = {\n readonly [K in keyof PibblPlaybackOptions]: SignalValue<PibblPlaybackOptions[K]>;\n};\n\ninterface PibblPlaybackHookSlot {\n readonly controller: AnimationPlaybackController;\n readonly componentRefs: PibblComponentRefs<any>;\n readonly pibblInstance: PibblInstance;\n latestOptions: PibblPlaybackOptions;\n mountSettled: boolean;\n readonly onError: (error: unknown) => void;\n readonly onEvent: (event: PibblPlaybackEvent) => void;\n renderRevision: number;\n}\n\nfunction isCurrentSlot(slot: PibblPlaybackHookSlot): boolean {\n return !slot.componentRefs.teardowns.closed &&\n !slot.pibblInstance.mainTeardowns.closed &&\n GLOBAL_STATE.pibblInstances.get(slot.pibblInstance.canvas) === slot.pibblInstance &&\n slot.pibblInstance.refs.get(slot.componentRefs.id) === slot.componentRefs;\n}\n\nfunction controllerOptions(\n candidate: PibblPlaybackOptions,\n onEvent: (event: PibblPlaybackEvent) => void,\n onError: (error: unknown) => void,\n): PibblPlaybackOptions {\n return {\n ...candidate,\n onEvent: typeof candidate.onEvent === 'function' ?\n onEvent : candidate.onEvent,\n onError: typeof candidate.onError === 'function' ?\n onError : candidate.onError,\n };\n}\n\n/**\n * Creates one component-owned animation playback handle for a hook slot.\n *\n * @param programInput - Animation program, optionally supplied by a signal. See\n * {@link SignalValue} , {@link PibblAnimationProgram} .\n * @param optionsInput - Playback configuration, optionally supplied by a signal. See\n * {@link SignalValue} , {@link PibblPlaybackOptionsInput} .\n * @returns Stable mount-owned playback controls and reactive status/time values. See\n * {@link PibblPlayback} .\n *\n * @see {@link SignalValue}\n * @see {@link PibblAnimationProgram}\n * @see {@link PibblPlayback}\n */\nexport function usePlayback(\n programInput: SignalValue<PibblAnimationProgram>,\n optionsInput: SignalValue<PibblPlaybackOptionsInput> = {},\n): PibblPlayback {\n const { componentRefs, pibblInstance } = requireHookContext();\n const program = resolveSignalValue(programInput);\n const options = resolvePlaybackOptions(optionsInput);\n const candidate = normalizeAnimationPlaybackCandidate(program, options);\n const candidateOptions = candidate.options;\n const slot = useHookSlot<PibblPlaybackHookSlot>('playback', teardowns => {\n let value!: PibblPlaybackHookSlot;\n const controller = createAnimationPlaybackController(\n candidate.program,\n candidateOptions,\n );\n controller.setDeferredStatusCommandOwner(pibblInstance.mainTeardowns);\n const onEvent = (event: PibblPlaybackEvent): void => {\n if (isCurrentSlot(value)) value.latestOptions.onEvent?.(event);\n };\n const onError = (error: unknown): void => {\n if (isCurrentSlot(value)) value.latestOptions.onError?.(error);\n };\n value = {\n controller,\n componentRefs,\n pibblInstance,\n latestOptions: {},\n mountSettled: false,\n onError,\n onEvent,\n renderRevision: 0,\n };\n controller.adopt(\n candidate.program,\n controllerOptions(candidateOptions, onEvent, onError),\n );\n teardowns.add(() => controller.dispose());\n return value;\n }).value;\n const revision = ++slot.renderRevision;\n const transaction = GLOBAL_STATE.renderTransaction;\n if (!transaction) {\n throw new Error('usePlayback requires an active Pibbl render transaction.');\n }\n transaction.onFinish(success => {\n if (!success || revision !== slot.renderRevision || !isCurrentSlot(slot)) return;\n slot.controller.adopt(\n candidate.program,\n controllerOptions(candidateOptions, slot.onEvent, slot.onError),\n );\n slot.latestOptions = candidateOptions;\n if (!slot.mountSettled) {\n slot.mountSettled = true;\n if (candidateOptions.autoplay === true) slot.controller.handle.play();\n }\n });\n return slot.controller.handle;\n}\n\nfunction resolvePlaybackOptions(\n input: SignalValue<PibblPlaybackOptionsInput>,\n): PibblPlaybackOptions {\n const source = resolveSignalValue(input);\n let resolved: Record<PropertyKey, unknown> | undefined;\n for (const key in source) {\n const value = source[key as keyof PibblPlaybackOptionsInput];\n if (!isSignal(value)) continue;\n resolved ??= { ...source };\n resolved[key] = resolveSignalValue(value as SignalValue<unknown>);\n }\n return (resolved ?? source) as PibblPlaybackOptions;\n}\n"],
|
|
5
|
+
"mappings": "AAAA;AAAA,EACE;AAAA,EACA;AAAA,OAEK;AAOP,SAAS,oBAAoB;AAC7B,SAAS,gBAAgB;AACzB,SAAS,0BAA0B;AAGnC,SAAS,oBAAoB,mBAAmB;AAiBhD,SAAS,cAAc,MAAsC;AAC3D,SAAO,CAAC,KAAK,cAAc,UAAU,UACnC,CAAC,KAAK,cAAc,cAAc,UAClC,aAAa,eAAe,IAAI,KAAK,cAAc,MAAM,MAAM,KAAK,iBACpE,KAAK,cAAc,KAAK,IAAI,KAAK,cAAc,EAAE,MAAM,KAAK;AAChE;AAEA,SAAS,kBACP,WACA,SACA,SACsB;AACtB,SAAO;AAAA,IACL,GAAG;AAAA,IACH,SAAS,OAAO,UAAU,YAAY,aACpC,UAAU,UAAU;AAAA,IACtB,SAAS,OAAO,UAAU,YAAY,aACpC,UAAU,UAAU;AAAA,EACxB;AACF;AAgBO,SAAS,YACd,cACA,eAAuD,CAAC,GACzC;AACf,QAAM,EAAE,eAAe,cAAc,IAAI,mBAAmB;AAC5D,QAAM,UAAU,mBAAmB,YAAY;AAC/C,QAAM,UAAU,uBAAuB,YAAY;AACnD,QAAM,YAAY,oCAAoC,SAAS,OAAO;AACtE,QAAM,mBAAmB,UAAU;AACnC,QAAM,OAAO,YAAmC,YAAY,eAAa;AACvE,QAAI;AACJ,UAAM,aAAa;AAAA,MACjB,UAAU;AAAA,MACV;AAAA,IACF;AACA,eAAW,8BAA8B,cAAc,aAAa;AACpE,UAAM,UAAU,CAAC,UAAoC;AACnD,UAAI,cAAc,KAAK,EAAG,OAAM,cAAc,UAAU,KAAK;AAAA,IAC/D;AACA,UAAM,UAAU,CAAC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