@pibbl/core 0.0.1 → 0.0.3-alpha.85.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/THIRD_PARTY_NOTICES.txt +81 -0
- package/dist/features/machines/animation.d.ts +64 -0
- package/dist/features/machines/animation.js +55 -0
- package/dist/features/machines/animation.js.map +7 -0
- package/dist/features/machines/animation.mjs +1 -0
- package/dist/features/machines/assign.d.ts +16 -0
- package/dist/features/machines/assign.js +15 -0
- package/dist/features/machines/assign.js.map +7 -0
- package/dist/features/machines/callback.d.ts +9 -0
- package/dist/features/machines/callback.js +7 -0
- package/dist/features/machines/callback.js.map +7 -0
- package/dist/features/machines/hook.d.ts +30 -0
- package/dist/features/machines/hook.js +37 -0
- package/dist/features/machines/hook.js.map +7 -0
- package/dist/features/machines/index.d.ts +6 -0
- package/dist/features/machines/index.js +12 -0
- package/dist/features/machines/index.js.map +7 -0
- package/dist/features/machines/index.mjs +1 -0
- package/dist/features/machines/runtime.d.ts +18 -0
- package/dist/features/machines/runtime.js +363 -0
- package/dist/features/machines/runtime.js.map +7 -0
- package/dist/features/machines/types.d.ts +164 -0
- package/dist/features/physics/2d-geometry.d.ts +3 -3
- package/dist/features/physics/2d-geometry.js.map +1 -1
- package/dist/features/physics/2d.d.ts +115 -62
- package/dist/features/physics/2d.js +59 -28
- package/dist/features/physics/2d.js.map +2 -2
- package/dist/features/physics/lib/2d/query-types.d.ts +6 -0
- package/dist/features/physics/lib/2d/runtime/controller.d.ts +7 -6
- package/dist/features/physics/lib/2d/runtime/controller.js.map +2 -2
- package/dist/features/physics/lib/2d/types.d.ts +8 -30
- package/dist/features/physics/lib/2d/world/queries.d.ts +7 -6
- package/dist/features/physics/lib/2d/world/queries.js.map +2 -2
- package/dist/features/sprites/formats/aseprite.d.ts +5 -0
- package/dist/features/sprites/formats/texture-packer.d.ts +5 -0
- package/dist/features/sprites/index.d.ts +6 -0
- package/dist/features/sprites/loader.d.ts +25 -0
- package/dist/features/sprites/model.d.ts +75 -0
- package/dist/features/sprites/sprite.d.ts +22 -0
- package/dist/features/textures/index.d.ts +12 -2
- package/dist/features/textures/index.js +33 -1
- package/dist/features/textures/index.js.map +2 -2
- package/dist/features/textures/lib/chemical-field.d.ts +56 -0
- package/dist/features/textures/lib/chemical-field.js +154 -0
- package/dist/features/textures/lib/chemical-field.js.map +7 -0
- package/dist/features/textures/lib/chemical-recipes.d.ts +119 -0
- package/dist/features/textures/lib/chemical-recipes.js +275 -0
- package/dist/features/textures/lib/chemical-recipes.js.map +7 -0
- package/dist/features/textures/lib/definitions.d.ts +3 -18
- package/dist/features/textures/lib/definitions.js +15 -20
- package/dist/features/textures/lib/definitions.js.map +2 -2
- package/dist/features/textures/lib/geometric-patterns.d.ts +149 -0
- package/dist/features/textures/lib/geometric-patterns.js +305 -0
- package/dist/features/textures/lib/geometric-patterns.js.map +7 -0
- package/dist/features/textures/lib/gray-scott.d.ts +55 -0
- package/dist/features/textures/lib/gray-scott.js +39 -0
- package/dist/features/textures/lib/gray-scott.js.map +7 -0
- package/dist/features/textures/lib/patterns.d.ts +123 -0
- package/dist/features/textures/lib/patterns.js +344 -0
- package/dist/features/textures/lib/patterns.js.map +7 -0
- package/dist/features/textures/lib/reaction-diffusion.d.ts +3 -2
- package/dist/features/textures/lib/reaction-diffusion.js +9 -20
- package/dist/features/textures/lib/reaction-diffusion.js.map +2 -2
- package/dist/features/textures/lib/simulation.d.ts +10 -4
- package/dist/features/textures/lib/simulation.js +23 -13
- package/dist/features/textures/lib/simulation.js.map +2 -2
- package/dist/features/viz/index.d.ts +79 -5
- package/dist/features/viz/index.js +145 -4
- package/dist/features/viz/index.js.map +2 -2
- package/dist/features/viz/inspection/bar.d.ts +79 -0
- package/dist/features/viz/inspection/bar.js +49 -0
- package/dist/features/viz/inspection/bar.js.map +7 -0
- package/dist/features/viz/inspection/candle.d.ts +156 -0
- package/dist/features/viz/inspection/candle.js +120 -0
- package/dist/features/viz/inspection/candle.js.map +7 -0
- package/dist/features/viz/inspection/capture-types.d.ts +65 -0
- package/dist/features/viz/inspection/capture.d.ts +16 -0
- package/dist/features/viz/inspection/capture.js +49 -0
- package/dist/features/viz/inspection/capture.js.map +7 -0
- package/dist/features/viz/inspection/handler.d.ts +36 -0
- package/dist/features/viz/inspection/handler.js +91 -0
- package/dist/features/viz/inspection/handler.js.map +7 -0
- package/dist/features/viz/inspection/ohlc-bar.d.ts +132 -0
- package/dist/features/viz/inspection/ohlc-bar.js +118 -0
- package/dist/features/viz/inspection/ohlc-bar.js.map +7 -0
- package/dist/features/viz/inspection/owned-ref.d.ts +16 -0
- package/dist/features/viz/inspection/owned-ref.js +99 -0
- package/dist/features/viz/inspection/owned-ref.js.map +7 -0
- package/dist/features/viz/inspection/painted-point.d.ts +22 -0
- package/dist/features/viz/inspection/painted-point.js +29 -0
- package/dist/features/viz/inspection/painted-point.js.map +7 -0
- package/dist/features/viz/inspection/queries.d.ts +100 -0
- package/dist/features/viz/inspection/queries.js +192 -0
- package/dist/features/viz/inspection/queries.js.map +7 -0
- package/dist/features/viz/inspection/query-types.d.ts +177 -0
- package/dist/features/viz/inspection/volume.d.ts +104 -0
- package/dist/features/viz/inspection/volume.js +95 -0
- package/dist/features/viz/inspection/volume.js.map +7 -0
- package/dist/features/viz/inspection.d.ts +19 -0
- package/dist/features/viz/inspection.js +54 -0
- package/dist/features/viz/inspection.js.map +7 -0
- package/dist/features/viz/inspection.mjs +1 -0
- package/dist/features/viz/lib/area-series.d.ts +62 -0
- package/dist/features/viz/lib/area-series.js +120 -0
- package/dist/features/viz/lib/area-series.js.map +7 -0
- package/dist/features/viz/lib/axis-labels.d.ts +2 -0
- package/dist/features/viz/lib/axis-labels.js +41 -0
- package/dist/features/viz/lib/axis-labels.js.map +7 -0
- package/dist/features/viz/lib/axis-title.d.ts +23 -0
- package/dist/features/viz/lib/axis-title.js +23 -0
- package/dist/features/viz/lib/axis-title.js.map +7 -0
- package/dist/features/viz/lib/axis.d.ts +1 -1
- package/dist/features/viz/lib/axis.js +50 -50
- package/dist/features/viz/lib/axis.js.map +2 -2
- package/dist/features/viz/lib/bar-scale.d.ts +7 -0
- package/dist/features/viz/lib/bar-scale.js +34 -0
- package/dist/features/viz/lib/bar-scale.js.map +7 -0
- package/dist/features/viz/lib/bar-series.d.ts +3 -1
- package/dist/features/viz/lib/bar-series.js +21 -5
- package/dist/features/viz/lib/bar-series.js.map +2 -2
- package/dist/features/viz/lib/baseline-series.d.ts +55 -0
- package/dist/features/viz/lib/baseline-series.js +136 -0
- package/dist/features/viz/lib/baseline-series.js.map +7 -0
- package/dist/features/viz/lib/candlestick-series.d.ts +62 -0
- package/dist/features/viz/lib/candlestick-series.js +150 -0
- package/dist/features/viz/lib/candlestick-series.js.map +7 -0
- package/dist/features/viz/lib/censored-point-series.d.ts +71 -0
- package/dist/features/viz/lib/censored-point-series.js +129 -0
- package/dist/features/viz/lib/censored-point-series.js.map +7 -0
- package/dist/features/viz/lib/chart-lines.d.ts +41 -0
- package/dist/features/viz/lib/chart-lines.js +32 -0
- package/dist/features/viz/lib/chart-lines.js.map +7 -0
- package/dist/features/viz/lib/color-context.d.ts +4 -0
- package/dist/features/viz/lib/color-context.js +41 -0
- package/dist/features/viz/lib/color-context.js.map +7 -0
- package/dist/features/viz/lib/color-math.d.ts +4 -0
- package/dist/features/viz/lib/color-math.js +31 -0
- package/dist/features/viz/lib/color-math.js.map +7 -0
- package/dist/features/viz/lib/color-types.d.ts +53 -0
- package/dist/features/viz/lib/curve-definition.d.ts +49 -0
- package/dist/features/viz/lib/curve-definition.js +148 -0
- package/dist/features/viz/lib/curve-definition.js.map +7 -0
- package/dist/features/viz/lib/diverging-color-scale.d.ts +11 -0
- package/dist/features/viz/lib/diverging-color-scale.js +51 -0
- package/dist/features/viz/lib/diverging-color-scale.js.map +7 -0
- package/dist/features/viz/lib/domain-navigation.d.ts +40 -0
- package/dist/features/viz/lib/domain-navigation.js +77 -0
- package/dist/features/viz/lib/domain-navigation.js.map +7 -0
- package/dist/features/viz/lib/editable-chart-elements.d.ts +178 -0
- package/dist/features/viz/lib/editable-chart-elements.js +733 -0
- package/dist/features/viz/lib/editable-chart-elements.js.map +7 -0
- package/dist/features/viz/lib/financial-aggregation.d.ts +127 -0
- package/dist/features/viz/lib/financial-aggregation.js +116 -0
- package/dist/features/viz/lib/financial-aggregation.js.map +7 -0
- package/dist/features/viz/lib/financial-autoscale.d.ts +64 -0
- package/dist/features/viz/lib/financial-autoscale.js +61 -0
- package/dist/features/viz/lib/financial-autoscale.js.map +7 -0
- package/dist/features/viz/lib/financial-comparison.d.ts +62 -0
- package/dist/features/viz/lib/financial-comparison.js +98 -0
- package/dist/features/viz/lib/financial-comparison.js.map +7 -0
- package/dist/features/viz/lib/financial-geometry.d.ts +77 -0
- package/dist/features/viz/lib/financial-geometry.js +67 -0
- package/dist/features/viz/lib/financial-geometry.js.map +7 -0
- package/dist/features/viz/lib/financial-indicators.d.ts +114 -0
- package/dist/features/viz/lib/financial-indicators.js +135 -0
- package/dist/features/viz/lib/financial-indicators.js.map +7 -0
- package/dist/features/viz/lib/financial-oscillators.d.ts +171 -0
- package/dist/features/viz/lib/financial-oscillators.js +265 -0
- package/dist/features/viz/lib/financial-oscillators.js.map +7 -0
- package/dist/features/viz/lib/hover-data.d.ts +1 -1
- package/dist/features/viz/lib/hover-data.js +6 -3
- package/dist/features/viz/lib/hover-data.js.map +2 -2
- package/dist/features/viz/lib/hover-types.d.ts +5 -5
- package/dist/features/viz/lib/interval-band-series.d.ts +49 -0
- package/dist/features/viz/lib/interval-band-series.js +136 -0
- package/dist/features/viz/lib/interval-band-series.js.map +7 -0
- package/dist/features/viz/lib/interval-diamond-series.d.ts +43 -0
- package/dist/features/viz/lib/interval-diamond-series.js +124 -0
- package/dist/features/viz/lib/interval-diamond-series.js.map +7 -0
- package/dist/features/viz/lib/interval-series.d.ts +79 -0
- package/dist/features/viz/lib/interval-series.js +158 -0
- package/dist/features/viz/lib/interval-series.js.map +7 -0
- package/dist/features/viz/lib/line-series.d.ts +1 -1
- package/dist/features/viz/lib/line-series.js +47 -28
- package/dist/features/viz/lib/line-series.js.map +2 -2
- package/dist/features/viz/lib/linear-scale-component.d.ts +7 -0
- package/dist/features/viz/lib/linear-scale-component.js +18 -0
- package/dist/features/viz/lib/linear-scale-component.js.map +7 -0
- package/dist/features/viz/lib/linear-scale.js +1 -1
- package/dist/features/viz/lib/linear-scale.js.map +2 -2
- package/dist/features/viz/lib/log-scale-component.d.ts +7 -0
- package/dist/features/viz/lib/log-scale-component.js +19 -0
- package/dist/features/viz/lib/log-scale-component.js.map +7 -0
- package/dist/features/viz/lib/log-scale.d.ts +2 -0
- package/dist/features/viz/lib/log-scale.js +53 -0
- package/dist/features/viz/lib/log-scale.js.map +7 -0
- package/dist/features/viz/lib/monotone-curve.d.ts +11 -0
- package/dist/features/viz/lib/monotone-curve.js +63 -0
- package/dist/features/viz/lib/monotone-curve.js.map +7 -0
- package/dist/features/viz/lib/nearest.d.ts +9 -9
- package/dist/features/viz/lib/nearest.js.map +1 -1
- package/dist/features/viz/lib/numeric-range-interpolation.d.ts +15 -0
- package/dist/features/viz/lib/numeric-range-interpolation.js +36 -0
- package/dist/features/viz/lib/numeric-range-interpolation.js.map +7 -0
- package/dist/features/viz/lib/numeric-ticks.d.ts +38 -0
- package/dist/features/viz/lib/numeric-ticks.js +54 -0
- package/dist/features/viz/lib/numeric-ticks.js.map +7 -0
- package/dist/features/viz/lib/ohlc-bar-series.d.ts +55 -0
- package/dist/features/viz/lib/ohlc-bar-series.js +168 -0
- package/dist/features/viz/lib/ohlc-bar-series.js.map +7 -0
- package/dist/features/viz/lib/paired-series.d.ts +44 -0
- package/dist/features/viz/lib/paired-series.js +93 -0
- package/dist/features/viz/lib/paired-series.js.map +7 -0
- package/dist/features/viz/lib/plot-series.js +11 -6
- package/dist/features/viz/lib/plot-series.js.map +2 -2
- package/dist/features/viz/lib/plot-types.d.ts +4 -3
- package/dist/features/viz/lib/point-scale-component.d.ts +7 -0
- package/dist/features/viz/lib/point-scale-component.js +19 -0
- package/dist/features/viz/lib/point-scale-component.js.map +7 -0
- package/dist/features/viz/lib/point-scale.d.ts +2 -0
- package/dist/features/viz/lib/point-scale.js +45 -0
- package/dist/features/viz/lib/point-scale.js.map +7 -0
- package/dist/features/viz/lib/point-series.d.ts +1 -1
- package/dist/features/viz/lib/point-series.js +36 -9
- package/dist/features/viz/lib/point-series.js.map +2 -2
- package/dist/features/viz/lib/point-types.d.ts +5 -2
- package/dist/features/viz/lib/reference-band.d.ts +16 -0
- package/dist/features/viz/lib/reference-band.js +27 -0
- package/dist/features/viz/lib/reference-band.js.map +7 -0
- package/dist/features/viz/lib/scale-adjust.js +9 -4
- package/dist/features/viz/lib/scale-adjust.js.map +2 -2
- package/dist/features/viz/lib/scale-context.d.ts +5 -4
- package/dist/features/viz/lib/scale-context.js +15 -11
- package/dist/features/viz/lib/scale-context.js.map +2 -2
- package/dist/features/viz/lib/scale-provider.d.ts +2 -0
- package/dist/features/viz/lib/scale-provider.js +13 -0
- package/dist/features/viz/lib/scale-provider.js.map +7 -0
- package/dist/features/viz/lib/scale-ticks.d.ts +5 -0
- package/dist/features/viz/lib/scale-ticks.js +64 -0
- package/dist/features/viz/lib/scale-ticks.js.map +7 -0
- package/dist/features/viz/lib/scale-view.d.ts +4 -0
- package/dist/features/viz/lib/scale-view.js +21 -0
- package/dist/features/viz/lib/scale-view.js.map +7 -0
- package/dist/features/viz/lib/sequential-color-scale.d.ts +11 -0
- package/dist/features/viz/lib/sequential-color-scale.js +49 -0
- package/dist/features/viz/lib/sequential-color-scale.js.map +7 -0
- package/dist/features/viz/lib/series-position.d.ts +12 -0
- package/dist/features/viz/lib/series-position.js +44 -0
- package/dist/features/viz/lib/series-position.js.map +7 -0
- package/dist/features/viz/lib/step-curves.d.ts +19 -0
- package/dist/features/viz/lib/step-curves.js +53 -0
- package/dist/features/viz/lib/step-curves.js.map +7 -0
- package/dist/features/viz/lib/symlog-scale-component.d.ts +7 -0
- package/dist/features/viz/lib/symlog-scale-component.js +19 -0
- package/dist/features/viz/lib/symlog-scale-component.js.map +7 -0
- package/dist/features/viz/lib/symlog-scale.d.ts +2 -0
- package/dist/features/viz/lib/symlog-scale.js +38 -0
- package/dist/features/viz/lib/symlog-scale.js.map +7 -0
- package/dist/features/viz/lib/threshold-color-scale.d.ts +43 -0
- package/dist/features/viz/lib/threshold-color-scale.js +59 -0
- package/dist/features/viz/lib/threshold-color-scale.js.map +7 -0
- package/dist/features/viz/lib/trading-time-mapping.d.ts +32 -0
- package/dist/features/viz/lib/trading-time-mapping.js +89 -0
- package/dist/features/viz/lib/trading-time-mapping.js.map +7 -0
- package/dist/features/viz/lib/trading-time-scale.d.ts +83 -0
- package/dist/features/viz/lib/trading-time-scale.js +96 -0
- package/dist/features/viz/lib/trading-time-scale.js.map +7 -0
- package/dist/features/viz/lib/trajectory-series.d.ts +71 -0
- package/dist/features/viz/lib/trajectory-series.js +111 -0
- package/dist/features/viz/lib/trajectory-series.js.map +7 -0
- package/dist/features/viz/lib/types.d.ts +114 -21
- package/dist/features/viz/lib/use-bar-scale.d.ts +8 -0
- package/dist/features/viz/lib/use-bar-scale.js +9 -0
- package/dist/features/viz/lib/use-bar-scale.js.map +7 -0
- package/dist/features/viz/lib/use-continuous-scale.d.ts +8 -0
- package/dist/features/viz/lib/use-continuous-scale.js +14 -0
- package/dist/features/viz/lib/use-continuous-scale.js.map +7 -0
- package/dist/features/viz/lib/use-linear-scale.d.ts +8 -0
- package/dist/features/viz/lib/use-linear-scale.js +9 -0
- package/dist/features/viz/lib/use-linear-scale.js.map +7 -0
- package/dist/features/viz/lib/use-log-scale.d.ts +8 -0
- package/dist/features/viz/lib/use-log-scale.js +9 -0
- package/dist/features/viz/lib/use-log-scale.js.map +7 -0
- package/dist/features/viz/lib/use-point-scale.d.ts +8 -0
- package/dist/features/viz/lib/use-point-scale.js +9 -0
- package/dist/features/viz/lib/use-point-scale.js.map +7 -0
- package/dist/features/viz/lib/use-symlog-scale.d.ts +8 -0
- package/dist/features/viz/lib/use-symlog-scale.js +9 -0
- package/dist/features/viz/lib/use-symlog-scale.js.map +7 -0
- package/dist/features/viz/lib/use-utc-scale.d.ts +8 -0
- package/dist/features/viz/lib/use-utc-scale.js +9 -0
- package/dist/features/viz/lib/use-utc-scale.js.map +7 -0
- package/dist/features/viz/lib/utc-labels.d.ts +12 -0
- package/dist/features/viz/lib/utc-labels.js +27 -0
- package/dist/features/viz/lib/utc-labels.js.map +7 -0
- package/dist/features/viz/lib/utc-scale-component.d.ts +7 -0
- package/dist/features/viz/lib/utc-scale-component.js +18 -0
- package/dist/features/viz/lib/utc-scale-component.js.map +7 -0
- package/dist/features/viz/lib/utc-scale.d.ts +21 -0
- package/dist/features/viz/lib/utc-scale.js +123 -0
- package/dist/features/viz/lib/utc-scale.js.map +7 -0
- package/dist/features/viz/lib/volume-series.d.ts +59 -0
- package/dist/features/viz/lib/volume-series.js +117 -0
- package/dist/features/viz/lib/volume-series.js.map +7 -0
- package/dist/features/viz/lib/weighted-point-series.d.ts +71 -0
- package/dist/features/viz/lib/weighted-point-series.js +169 -0
- package/dist/features/viz/lib/weighted-point-series.js.map +7 -0
- package/dist/filters/emboss-gpu.d.ts +4 -0
- package/dist/filters/emboss-gpu.js +39 -0
- package/dist/filters/emboss-gpu.js.map +7 -0
- package/dist/filters/emboss.d.ts +32 -0
- package/dist/filters/emboss.js +106 -0
- package/dist/filters/emboss.js.map +7 -0
- package/dist/filters/reflection-gpu.d.ts +3 -1
- package/dist/filters/reflection-gpu.js +5 -2
- package/dist/filters/reflection-gpu.js.map +2 -2
- package/dist/filters/render-emboss-boundary.d.ts +13 -0
- package/dist/filters/render-emboss-boundary.js +131 -0
- package/dist/filters/render-emboss-boundary.js.map +7 -0
- package/dist/filters.d.ts +2 -0
- package/dist/filters.js +2 -0
- package/dist/filters.js.map +2 -2
- package/dist/index.d.ts +3 -1
- package/dist/index.js +3 -0
- package/dist/index.js.map +2 -2
- package/dist/internal.d.ts +2 -0
- package/dist/internal.js +4 -0
- package/dist/internal.js.map +2 -2
- package/dist/lib/animation/definition.d.ts +5 -3
- package/dist/lib/animation/definition.js +29 -4
- package/dist/lib/animation/definition.js.map +2 -2
- package/dist/lib/animation/playback.d.ts +8 -0
- package/dist/lib/animation/playback.js +33 -11
- package/dist/lib/animation/playback.js.map +2 -2
- package/dist/lib/animation/spring.d.ts +3 -1
- package/dist/lib/animation/spring.js.map +2 -2
- package/dist/lib/animation/types.d.ts +29 -73
- package/dist/lib/events/event-facade.d.ts +13 -0
- package/dist/lib/events/event-facade.js +23 -0
- package/dist/lib/events/event-facade.js.map +2 -2
- package/dist/lib/events/propagation.js +19 -14
- package/dist/lib/events/propagation.js.map +2 -2
- package/dist/lib/execute-render.js +13 -0
- package/dist/lib/execute-render.js.map +2 -2
- package/dist/lib/hooks/use-animated-value.d.ts +11 -21
- package/dist/lib/hooks/use-animated-value.js +23 -70
- package/dist/lib/hooks/use-animated-value.js.map +3 -3
- package/dist/lib/hooks/use-playback.js +1 -0
- package/dist/lib/hooks/use-playback.js.map +2 -2
- package/dist/lib/recording/recording.d.ts +43 -0
- package/dist/lib/recording/recording.js +555 -0
- package/dist/lib/recording/recording.js.map +7 -0
- package/dist/lib/recording/types.d.ts +118 -0
- package/dist/lib/recording/wasm-bytes.d.ts +1 -0
- package/dist/lib/recording/wasm-bytes.js +5 -0
- package/dist/lib/recording/wasm-bytes.js.map +7 -0
- package/dist/lib/recording/worker-source.d.ts +1 -0
- package/dist/lib/recording/worker-source.js +5 -0
- package/dist/lib/recording/worker-source.js.map +7 -0
- package/dist/lib/render-transaction.d.ts +5 -2
- package/dist/lib/render-transaction.js +23 -1
- package/dist/lib/render-transaction.js.map +2 -2
- package/dist/lib/series-inspection-frame.d.ts +18 -0
- package/dist/lib/series-inspection-frame.js +70 -0
- package/dist/lib/series-inspection-frame.js.map +7 -0
- package/dist/lib/types.d.ts +6 -0
- package/package.json +27 -5
- package/dist/features/viz/lib/scale.d.ts +0 -11
- package/dist/features/viz/lib/scale.js +0 -80
- package/dist/features/viz/lib/scale.js.map +0 -7
- package/dist/features/viz/lib/use-scale.d.ts +0 -20
- package/dist/features/viz/lib/use-scale.js +0 -10
- package/dist/features/viz/lib/use-scale.js.map +0 -7
|
@@ -0,0 +1,363 @@
|
|
|
1
|
+
import { assertDirectSignalWriteAllowed, signal } from "../../lib/signals/graph.js";
|
|
2
|
+
import { assignmentOf } from "./assign.js";
|
|
3
|
+
const compiledMachines = /* @__PURE__ */ new WeakMap();
|
|
4
|
+
function defineMachine(definition) {
|
|
5
|
+
compile(definition);
|
|
6
|
+
return definition;
|
|
7
|
+
}
|
|
8
|
+
function createMachine(definition, options) {
|
|
9
|
+
const compiled = compile(definition);
|
|
10
|
+
const input = options.input;
|
|
11
|
+
const context = typeof definition.context === "function" ? definition.context({ input }) : definition.context;
|
|
12
|
+
let currentContext = context;
|
|
13
|
+
let value = definition.initial;
|
|
14
|
+
let status = "not-started";
|
|
15
|
+
let error;
|
|
16
|
+
let activeEntry;
|
|
17
|
+
let entryGeneration = 0;
|
|
18
|
+
const initial = snapshot(value, currentContext, status, error);
|
|
19
|
+
const writableSnapshot = signal(initial, { debugName: "machine.snapshot" });
|
|
20
|
+
const publicSnapshot = writableSnapshot.asReadonly();
|
|
21
|
+
const queue = [];
|
|
22
|
+
let queueHead = 0;
|
|
23
|
+
let processing = false;
|
|
24
|
+
const actor = {
|
|
25
|
+
snapshot: publicSnapshot,
|
|
26
|
+
start() {
|
|
27
|
+
if (status !== "not-started") return;
|
|
28
|
+
assertDirectSignalWriteAllowed(writableSnapshot);
|
|
29
|
+
status = "active";
|
|
30
|
+
processing = true;
|
|
31
|
+
try {
|
|
32
|
+
runActions(stateDefinition().entry, void 0);
|
|
33
|
+
if (status !== "active") return;
|
|
34
|
+
publish();
|
|
35
|
+
startInvocations(void 0);
|
|
36
|
+
} catch (cause) {
|
|
37
|
+
fail(cause);
|
|
38
|
+
} finally {
|
|
39
|
+
processing = false;
|
|
40
|
+
}
|
|
41
|
+
drain();
|
|
42
|
+
},
|
|
43
|
+
send(event) {
|
|
44
|
+
if (status !== "active") return;
|
|
45
|
+
assertDirectSignalWriteAllowed(writableSnapshot);
|
|
46
|
+
queue.push({ kind: "event", event });
|
|
47
|
+
if (!processing) drain();
|
|
48
|
+
},
|
|
49
|
+
stop() {
|
|
50
|
+
if (status === "stopped" || status === "error") return;
|
|
51
|
+
assertDirectSignalWriteAllowed(writableSnapshot);
|
|
52
|
+
status = "stopped";
|
|
53
|
+
try {
|
|
54
|
+
cancelEntry();
|
|
55
|
+
} finally {
|
|
56
|
+
releaseQueue();
|
|
57
|
+
publish();
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
};
|
|
61
|
+
return actor;
|
|
62
|
+
function stateDefinition() {
|
|
63
|
+
const state = compiled.states.get(value);
|
|
64
|
+
if (!state) throw new Error(`Machine entered unknown state ${JSON.stringify(value)}.`);
|
|
65
|
+
return state.definition;
|
|
66
|
+
}
|
|
67
|
+
function drain() {
|
|
68
|
+
if (processing || status !== "active") return;
|
|
69
|
+
processing = true;
|
|
70
|
+
try {
|
|
71
|
+
while (status === "active" && queueHead < queue.length) {
|
|
72
|
+
const item = queue[queueHead];
|
|
73
|
+
queue[queueHead++] = void 0;
|
|
74
|
+
if (item.kind === "event") processEvent(item.event);
|
|
75
|
+
else processInvocation(item);
|
|
76
|
+
}
|
|
77
|
+
} catch (cause) {
|
|
78
|
+
fail(cause);
|
|
79
|
+
} finally {
|
|
80
|
+
processing = false;
|
|
81
|
+
if (queueHead === queue.length) releaseQueue();
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
function processEvent(event) {
|
|
85
|
+
const compiledState = compiled.states.get(value);
|
|
86
|
+
const local = compiledState.on;
|
|
87
|
+
const source = local.has(event.type) ? local.get(event.type) : compiled.on.get(event.type);
|
|
88
|
+
if (source === void 0) return;
|
|
89
|
+
const selected = selectTransition(source, event);
|
|
90
|
+
if (selected !== void 0) applyTransition(selected, event);
|
|
91
|
+
}
|
|
92
|
+
function processInvocation(item) {
|
|
93
|
+
if (!item.entry.active || activeEntry !== item.entry || status !== "active") return;
|
|
94
|
+
const source = item.kind === "done" ? item.invocation.onDone : item.invocation.onError;
|
|
95
|
+
if (source === void 0) {
|
|
96
|
+
if (item.kind === "error") fail(item.error);
|
|
97
|
+
return;
|
|
98
|
+
}
|
|
99
|
+
const event = item.kind === "done" ? { type: "@pibbl/machine.done", output: item.output } : { type: "@pibbl/machine.error", error: item.error };
|
|
100
|
+
const selected = selectTransition(
|
|
101
|
+
source,
|
|
102
|
+
event
|
|
103
|
+
);
|
|
104
|
+
if (selected !== void 0) applyTransition(selected, event);
|
|
105
|
+
}
|
|
106
|
+
function selectTransition(source, event) {
|
|
107
|
+
if (typeof source === "string") return { target: source };
|
|
108
|
+
const candidates = Array.isArray(source) ? source : void 0;
|
|
109
|
+
if (!candidates) {
|
|
110
|
+
const candidate = source;
|
|
111
|
+
return !candidate.guard || candidate.guard(actionContext(event)) ? candidate : void 0;
|
|
112
|
+
}
|
|
113
|
+
for (const candidate of candidates) {
|
|
114
|
+
if (!candidate.guard || candidate.guard(actionContext(event))) return candidate;
|
|
115
|
+
}
|
|
116
|
+
return void 0;
|
|
117
|
+
}
|
|
118
|
+
function applyTransition(transition, event) {
|
|
119
|
+
const target = transition.target ?? value;
|
|
120
|
+
const changesState = target !== value || transition.reenter === true;
|
|
121
|
+
if (changesState) {
|
|
122
|
+
cancelEntry();
|
|
123
|
+
runActions(stateDefinition().exit, event);
|
|
124
|
+
if (status !== "active") return;
|
|
125
|
+
}
|
|
126
|
+
const contextChanged = runActions(transition.actions, event);
|
|
127
|
+
if (status !== "active") return;
|
|
128
|
+
if (changesState) {
|
|
129
|
+
value = target;
|
|
130
|
+
runActions(stateDefinition().entry, event);
|
|
131
|
+
}
|
|
132
|
+
if (changesState || contextChanged) publish();
|
|
133
|
+
if (changesState) startInvocations(event);
|
|
134
|
+
}
|
|
135
|
+
function actionContext(event) {
|
|
136
|
+
return {
|
|
137
|
+
get context() {
|
|
138
|
+
return currentContext;
|
|
139
|
+
},
|
|
140
|
+
event,
|
|
141
|
+
input,
|
|
142
|
+
send: actor.send
|
|
143
|
+
};
|
|
144
|
+
}
|
|
145
|
+
function runActions(actions, event) {
|
|
146
|
+
if (actions === void 0) return false;
|
|
147
|
+
const list = Array.isArray(actions) ? actions : [actions];
|
|
148
|
+
let changed = false;
|
|
149
|
+
for (const action of list) {
|
|
150
|
+
const contextForAction = actionContext(event);
|
|
151
|
+
const assignment = assignmentOf(action);
|
|
152
|
+
if (assignment) {
|
|
153
|
+
const patch = assignment(contextForAction);
|
|
154
|
+
if (patch === null || typeof patch !== "object") throw new TypeError("assign() must return a context object patch.");
|
|
155
|
+
if (patchChangesContext(currentContext, patch)) {
|
|
156
|
+
currentContext = Object.assign({}, currentContext, patch);
|
|
157
|
+
changed = true;
|
|
158
|
+
}
|
|
159
|
+
} else {
|
|
160
|
+
action(contextForAction);
|
|
161
|
+
}
|
|
162
|
+
if (status !== "active") return changed;
|
|
163
|
+
}
|
|
164
|
+
return changed;
|
|
165
|
+
}
|
|
166
|
+
function startInvocations(event) {
|
|
167
|
+
const definitions = stateDefinition().invoke;
|
|
168
|
+
if (!definitions) return;
|
|
169
|
+
const entry = {
|
|
170
|
+
active: true,
|
|
171
|
+
generation: ++entryGeneration,
|
|
172
|
+
controllers: []
|
|
173
|
+
};
|
|
174
|
+
activeEntry = entry;
|
|
175
|
+
const list = Array.isArray(definitions) ? definitions : [definitions];
|
|
176
|
+
for (const invocation of list) {
|
|
177
|
+
startInvocation(entry, invocation, event);
|
|
178
|
+
if (status !== "active" || !entry.active || activeEntry !== entry) break;
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
function startInvocation(entry, invocation, event) {
|
|
182
|
+
const controller = new AbortController();
|
|
183
|
+
const owned = { controller, invocation, cleanup: void 0 };
|
|
184
|
+
entry.controllers.push(owned);
|
|
185
|
+
let returned;
|
|
186
|
+
try {
|
|
187
|
+
returned = invocation.task({
|
|
188
|
+
context: currentContext,
|
|
189
|
+
event,
|
|
190
|
+
input,
|
|
191
|
+
signal: controller.signal,
|
|
192
|
+
send(queuedEvent) {
|
|
193
|
+
if (status !== "active" || !entry.active || activeEntry !== entry || controller.signal.aborted) return;
|
|
194
|
+
actor.send(queuedEvent);
|
|
195
|
+
}
|
|
196
|
+
});
|
|
197
|
+
} catch (cause) {
|
|
198
|
+
queueInvocation({ kind: "error", entry, invocation, error: cause });
|
|
199
|
+
return;
|
|
200
|
+
}
|
|
201
|
+
if (typeof returned === "function") {
|
|
202
|
+
owned.cleanup = returned;
|
|
203
|
+
} else if (returned && typeof returned.then === "function") {
|
|
204
|
+
Promise.resolve(returned).then(
|
|
205
|
+
(output) => queueInvocation({ kind: "done", entry, invocation, output }),
|
|
206
|
+
(cause) => queueInvocation({ kind: "error", entry, invocation, error: cause })
|
|
207
|
+
);
|
|
208
|
+
}
|
|
209
|
+
}
|
|
210
|
+
function queueInvocation(item) {
|
|
211
|
+
if (status !== "active" || !item.entry.active || activeEntry !== item.entry) return;
|
|
212
|
+
queue.push(item);
|
|
213
|
+
if (!processing) drain();
|
|
214
|
+
}
|
|
215
|
+
function cancelEntry() {
|
|
216
|
+
const entry = activeEntry;
|
|
217
|
+
activeEntry = void 0;
|
|
218
|
+
if (!entry) return;
|
|
219
|
+
entry.active = false;
|
|
220
|
+
const failures = [];
|
|
221
|
+
for (const owned of entry.controllers) {
|
|
222
|
+
try {
|
|
223
|
+
owned.controller.abort();
|
|
224
|
+
} catch (cause) {
|
|
225
|
+
failures.push(cause);
|
|
226
|
+
}
|
|
227
|
+
const cleanup = owned.cleanup;
|
|
228
|
+
owned.cleanup = void 0;
|
|
229
|
+
if (cleanup) {
|
|
230
|
+
try {
|
|
231
|
+
cleanup();
|
|
232
|
+
} catch (cause) {
|
|
233
|
+
failures.push(cause);
|
|
234
|
+
}
|
|
235
|
+
}
|
|
236
|
+
}
|
|
237
|
+
entry.controllers.length = 0;
|
|
238
|
+
if (failures.length === 1) throw failures[0];
|
|
239
|
+
if (failures.length > 1) throw new AggregateError(failures, "Machine state task cleanup failed.");
|
|
240
|
+
}
|
|
241
|
+
function fail(cause) {
|
|
242
|
+
if (status === "error" || status === "stopped") return;
|
|
243
|
+
status = "error";
|
|
244
|
+
error = cause;
|
|
245
|
+
try {
|
|
246
|
+
cancelEntry();
|
|
247
|
+
} catch (cleanupCause) {
|
|
248
|
+
error = new AggregateError([cause, cleanupCause], "Machine failed while cleaning up a state task.");
|
|
249
|
+
}
|
|
250
|
+
releaseQueue();
|
|
251
|
+
publish();
|
|
252
|
+
}
|
|
253
|
+
function releaseQueue() {
|
|
254
|
+
for (let index = queueHead; index < queue.length; index++) queue[index] = void 0;
|
|
255
|
+
queue.length = 0;
|
|
256
|
+
queueHead = 0;
|
|
257
|
+
}
|
|
258
|
+
function publish() {
|
|
259
|
+
writableSnapshot.set(snapshot(value, currentContext, status, error));
|
|
260
|
+
}
|
|
261
|
+
}
|
|
262
|
+
function snapshot(value, context, status, error) {
|
|
263
|
+
return Object.freeze({ value, context, status, error, matches: (candidate) => candidate === value });
|
|
264
|
+
}
|
|
265
|
+
function patchChangesContext(context, patch) {
|
|
266
|
+
if (context === null || typeof context !== "object") return true;
|
|
267
|
+
for (const key of Reflect.ownKeys(patch)) {
|
|
268
|
+
if (!Object.is(context[key], patch[key])) return true;
|
|
269
|
+
}
|
|
270
|
+
return false;
|
|
271
|
+
}
|
|
272
|
+
function compile(definition) {
|
|
273
|
+
const known = compiledMachines.get(definition);
|
|
274
|
+
if (known) return known;
|
|
275
|
+
if (!definition || typeof definition !== "object") throw new TypeError("Machine definition must be an object.");
|
|
276
|
+
if (!definition.states || typeof definition.states !== "object") throw new TypeError("Machine definition requires a states object.");
|
|
277
|
+
if (!Object.prototype.hasOwnProperty.call(definition.states, definition.initial)) throw new RangeError(`Machine initial state ${JSON.stringify(definition.initial)} is not declared.`);
|
|
278
|
+
const names = new Set(Object.keys(definition.states));
|
|
279
|
+
const states = /* @__PURE__ */ new Map();
|
|
280
|
+
for (const [name, rawValue] of Object.entries(definition.states)) {
|
|
281
|
+
const raw = rawValue;
|
|
282
|
+
if (!raw || typeof raw !== "object") throw new TypeError(`Machine state ${JSON.stringify(name)} must be an object.`);
|
|
283
|
+
validateHandlers(raw.on, names, `state ${JSON.stringify(name)}`);
|
|
284
|
+
validateInvocations(raw.invoke, names, `state ${JSON.stringify(name)}`);
|
|
285
|
+
const normalized = normalizeState(raw);
|
|
286
|
+
states.set(name, { definition: normalized, on: new Map(Object.entries(normalized.on ?? {})) });
|
|
287
|
+
}
|
|
288
|
+
validateHandlers(definition.on, names, "machine");
|
|
289
|
+
const compiled = { states, on: normalizeHandlers(definition.on) };
|
|
290
|
+
compiledMachines.set(definition, compiled);
|
|
291
|
+
return compiled;
|
|
292
|
+
}
|
|
293
|
+
function normalizeState(state) {
|
|
294
|
+
const invocations = state.invoke === void 0 ? void 0 : Array.isArray(state.invoke) ? state.invoke.map((invocation) => normalizeInvocation(invocation)) : normalizeInvocation(state.invoke);
|
|
295
|
+
return Object.freeze({
|
|
296
|
+
entry: normalizeActions(state.entry),
|
|
297
|
+
exit: normalizeActions(state.exit),
|
|
298
|
+
invoke: invocations === void 0 ? void 0 : Object.freeze(Array.isArray(invocations) ? invocations : [invocations]),
|
|
299
|
+
on: Object.freeze(Object.fromEntries(normalizeHandlers(state.on)))
|
|
300
|
+
});
|
|
301
|
+
}
|
|
302
|
+
function normalizeHandlers(handlers) {
|
|
303
|
+
if (!handlers) return /* @__PURE__ */ new Map();
|
|
304
|
+
return new Map(Object.entries(handlers).map(([type, transition]) => [type, normalizeTransition(transition)]));
|
|
305
|
+
}
|
|
306
|
+
function normalizeInvocation(invocation) {
|
|
307
|
+
const source = invocation;
|
|
308
|
+
return Object.freeze({
|
|
309
|
+
id: source.id,
|
|
310
|
+
task: source.task,
|
|
311
|
+
onDone: normalizeTransition(source.onDone),
|
|
312
|
+
onError: normalizeTransition(source.onError)
|
|
313
|
+
});
|
|
314
|
+
}
|
|
315
|
+
function normalizeTransition(transition) {
|
|
316
|
+
if (transition === void 0 || typeof transition === "string") return transition;
|
|
317
|
+
if (Array.isArray(transition)) return Object.freeze(transition.map((candidate) => normalizeTransition(candidate)));
|
|
318
|
+
const source = transition;
|
|
319
|
+
return Object.freeze({
|
|
320
|
+
target: source.target,
|
|
321
|
+
guard: source.guard,
|
|
322
|
+
actions: normalizeActions(source.actions),
|
|
323
|
+
reenter: source.reenter
|
|
324
|
+
});
|
|
325
|
+
}
|
|
326
|
+
function normalizeActions(actions) {
|
|
327
|
+
return Array.isArray(actions) ? Object.freeze([...actions]) : actions;
|
|
328
|
+
}
|
|
329
|
+
function validateHandlers(handlers, names, label) {
|
|
330
|
+
if (handlers === void 0) return;
|
|
331
|
+
if (!handlers || typeof handlers !== "object") throw new TypeError(`Handlers for ${label} must be an object.`);
|
|
332
|
+
for (const transition of Object.values(handlers)) validateTransition(transition, names, label);
|
|
333
|
+
}
|
|
334
|
+
function validateInvocations(invocations, names, label) {
|
|
335
|
+
if (invocations === void 0) return;
|
|
336
|
+
const list = Array.isArray(invocations) ? invocations : [invocations];
|
|
337
|
+
for (const invocation of list) {
|
|
338
|
+
if (!invocation || typeof invocation !== "object" || typeof invocation.task !== "function") throw new TypeError(`Each invocation in ${label} requires a task function.`);
|
|
339
|
+
const typed = invocation;
|
|
340
|
+
validateTransition(typed.onDone, names, label);
|
|
341
|
+
validateTransition(typed.onError, names, label);
|
|
342
|
+
}
|
|
343
|
+
}
|
|
344
|
+
function validateTransition(transition, names, label) {
|
|
345
|
+
if (transition === void 0) return;
|
|
346
|
+
const list = Array.isArray(transition) ? transition : [transition];
|
|
347
|
+
for (const candidate of list) {
|
|
348
|
+
if (typeof candidate === "string") {
|
|
349
|
+
if (!names.has(candidate)) throw new RangeError(`Transition in ${label} targets undeclared state ${JSON.stringify(candidate)}.`);
|
|
350
|
+
continue;
|
|
351
|
+
}
|
|
352
|
+
if (!candidate || typeof candidate !== "object") throw new TypeError(`Transition in ${label} must be a state name or object.`);
|
|
353
|
+
const config = candidate;
|
|
354
|
+
if (config.target !== void 0 && (typeof config.target !== "string" || !names.has(config.target))) throw new RangeError(`Transition in ${label} targets an undeclared state.`);
|
|
355
|
+
if (config.guard !== void 0 && typeof config.guard !== "function") throw new TypeError(`Transition guard in ${label} must be a function.`);
|
|
356
|
+
if (config.actions !== void 0 && typeof config.actions !== "function" && (!Array.isArray(config.actions) || config.actions.some((action) => typeof action !== "function"))) throw new TypeError(`Transition actions in ${label} must be functions.`);
|
|
357
|
+
}
|
|
358
|
+
}
|
|
359
|
+
export {
|
|
360
|
+
createMachine,
|
|
361
|
+
defineMachine
|
|
362
|
+
};
|
|
363
|
+
//# sourceMappingURL=runtime.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../src/features/machines/runtime.ts"],
|
|
4
|
+
"sourcesContent": ["import { assertDirectSignalWriteAllowed, signal } from '../../lib/signals/graph.js';\nimport { assignmentOf } from './assign.js';\nimport type {\n CreateMachineOptions,\n MachineAction,\n MachineActionContext,\n MachineActions,\n MachineActor,\n MachineDefinition,\n MachineEvent,\n MachineInvocation,\n MachineSnapshot,\n MachineState,\n MachineStatus,\n MachineTaskDoneEvent,\n MachineTaskErrorEvent,\n MachineTransition,\n MachineTransitionConfig,\n} from './types.js';\n\ninterface CompiledMachine {\n readonly states: ReadonlyMap<string, CompiledState>;\n readonly on: ReadonlyMap<string, unknown>;\n}\n\ninterface CompiledState {\n readonly definition: MachineState<object, MachineEvent, unknown, string>;\n readonly on: ReadonlyMap<string, unknown>;\n}\n\nconst compiledMachines = new WeakMap<object, CompiledMachine>();\n\n/**\n * Validates and records a reusable flat machine definition. Calling this function performs no\n * work and creates no actor; use {@link createMachine} or `useMachine` to execute it.\n * @param definition - Reusable machine behavior to validate and normalize.\n * @returns The supplied definition, suitable for actor creation.\n * @see {@link MachineDefinition}\n */\nexport function defineMachine<Context, Event extends MachineEvent, Input = undefined, State extends string = string>(\n definition: MachineDefinition<Context, Event, Input, State>,\n): MachineDefinition<Context, Event, Input, State> {\n compile(definition);\n return definition;\n}\n\n/**\n * Creates an explicitly owned, initially idle machine actor. Call `start()` when ownership begins\n * and `stop()` when it ends. The actor has no renderer, scheduler, or animation dependency.\n * @param definition - Reusable behavior previously authored with {@link defineMachine}.\n * @param options - Immutable input supplied to this actor.\n * @returns An idle actor that owns no task until it starts.\n * @see {@link MachineActor}\n */\nexport function createMachine<Context, Event extends MachineEvent, Input, State extends string = string>(\n definition: MachineDefinition<Context, Event, Input, State>,\n options: CreateMachineOptions<Input>,\n): MachineActor<Context, Event, Input, State> {\n const compiled = compile(definition);\n const input = options.input;\n const context = typeof definition.context === 'function'\n ? (definition.context as (value: Readonly<{ input: Input }>) => Context)({ input })\n : definition.context;\n let currentContext = context;\n let value = definition.initial;\n let status: MachineStatus = 'not-started';\n let error: unknown | undefined;\n let activeEntry: StateEntry<Context, Event, Input, State> | undefined;\n let entryGeneration = 0;\n const initial = snapshot(value, currentContext, status, error);\n const writableSnapshot = signal(initial, { debugName: 'machine.snapshot' });\n const publicSnapshot = writableSnapshot.asReadonly();\n const queue: QueueItem<Context, Event, Input, State>[] = [];\n let queueHead = 0;\n let processing = false;\n\n const actor: MachineActor<Context, Event, Input, State> = {\n snapshot: publicSnapshot,\n start(): void {\n if (status !== 'not-started') return;\n assertDirectSignalWriteAllowed(writableSnapshot);\n status = 'active';\n // Entry actions may send events. Keep those queued until the initial entry has published\n // and started its owned work, just like an ordinary transition.\n processing = true;\n try {\n runActions(stateDefinition().entry as unknown as MachineActions<Context, Event, Input>, undefined);\n if (status !== 'active') return;\n publish();\n startInvocations(undefined);\n } catch (cause) {\n fail(cause);\n } finally {\n processing = false;\n }\n drain();\n },\n send(event: Event): void {\n if (status !== 'active') return;\n assertDirectSignalWriteAllowed(writableSnapshot);\n queue.push({ kind: 'event', event });\n if (!processing) drain();\n },\n stop(): void {\n if (status === 'stopped' || status === 'error') return;\n assertDirectSignalWriteAllowed(writableSnapshot);\n status = 'stopped';\n try {\n cancelEntry();\n } finally {\n releaseQueue();\n publish();\n }\n },\n };\n\n return actor;\n\n function stateDefinition(): MachineState<Context, Event, Input, State> {\n const state = compiled.states.get(value);\n if (!state) throw new Error(`Machine entered unknown state ${JSON.stringify(value)}.`);\n return state.definition as unknown as MachineState<Context, Event, Input, State>;\n }\n\n function drain(): void {\n if (processing || status !== 'active') return;\n processing = true;\n try {\n while (status === 'active' && queueHead < queue.length) {\n const item = queue[queueHead];\n queue[queueHead++] = undefined as never;\n if (item.kind === 'event') processEvent(item.event);\n else processInvocation(item);\n }\n } catch (cause) {\n fail(cause);\n } finally {\n processing = false;\n if (queueHead === queue.length) releaseQueue();\n }\n }\n\n function processEvent(event: Event): void {\n const compiledState = compiled.states.get(value)!;\n const local = compiledState.on;\n // Local declaration intentionally shadows the machine fallback even if every guard rejects.\n const source = local.has(event.type) ? local.get(event.type) : compiled.on.get(event.type);\n if (source === undefined) return;\n const selected = selectTransition(source as MachineTransition<Context, Event, Input, State, Event>, event);\n if (selected !== undefined) applyTransition(selected, event);\n }\n\n function processInvocation(item: InvocationQueueItem<Context, Event, Input, State>): void {\n if (!item.entry.active || activeEntry !== item.entry || status !== 'active') return;\n const source = item.kind === 'done' ? item.invocation.onDone : item.invocation.onError;\n if (source === undefined) {\n if (item.kind === 'error') fail(item.error);\n return;\n }\n const event = item.kind === 'done'\n ? { type: '@pibbl/machine.done', output: item.output } as MachineTaskDoneEvent\n : { type: '@pibbl/machine.error', error: item.error } as MachineTaskErrorEvent;\n const selected = selectTransition<MachineEvent>(\n source as unknown as MachineTransition<Context, MachineEvent, Input, State, Event>,\n event,\n );\n if (selected !== undefined) applyTransition<MachineEvent>(selected, event);\n }\n\n function selectTransition<SelectedEvent extends MachineEvent>(\n source: MachineTransition<Context, SelectedEvent, Input, State, Event>,\n event: SelectedEvent,\n ): MachineTransitionConfig<Context, SelectedEvent, Input, State, Event> | undefined {\n if (typeof source === 'string') return { target: source };\n const candidates = Array.isArray(source as unknown) ? source as readonly MachineTransitionConfig<Context, SelectedEvent, Input, State, Event>[] : undefined;\n if (!candidates) {\n const candidate = source as MachineTransitionConfig<Context, SelectedEvent, Input, State, Event>;\n return !candidate.guard || candidate.guard(actionContext(event)) ? candidate : undefined;\n }\n for (const candidate of candidates) {\n if (!candidate.guard || candidate.guard(actionContext(event))) return candidate;\n }\n return undefined;\n }\n\n function applyTransition<SelectedEvent extends MachineEvent>(\n transition: MachineTransitionConfig<Context, SelectedEvent, Input, State, Event>,\n event: SelectedEvent,\n ): void {\n const target = transition.target ?? value;\n const changesState = target !== value || transition.reenter === true;\n if (changesState) {\n cancelEntry();\n runActions(stateDefinition().exit, event as unknown as Event);\n if (status !== 'active') return;\n }\n const contextChanged = runActions(transition.actions, event);\n if (status !== 'active') return;\n if (changesState) {\n value = target;\n runActions(stateDefinition().entry as unknown as MachineActions<Context, Event, Input>, event as unknown as Event);\n }\n // Empty handlers and no-op action handlers preserve snapshot identity.\n if (changesState || contextChanged) publish();\n if (changesState) startInvocations(event as unknown as Event);\n }\n\n function actionContext<SelectedEvent extends MachineEvent>(event: SelectedEvent | undefined): MachineActionContext<Context, SelectedEvent, Input, Event> {\n return {\n get context() { return currentContext; },\n event: event as SelectedEvent,\n input,\n send: actor.send,\n };\n }\n\n function runActions<SelectedEvent extends MachineEvent>(\n actions: MachineAction<Context, SelectedEvent, Input, Event> | readonly MachineAction<Context, SelectedEvent, Input, Event>[] | undefined,\n event: SelectedEvent | undefined,\n ): boolean {\n if (actions === undefined) return false;\n const list = Array.isArray(actions) ? actions : [actions];\n let changed = false;\n for (const action of list) {\n const contextForAction = actionContext(event);\n const assignment = assignmentOf(action);\n if (assignment) {\n const patch = assignment(contextForAction as unknown as MachineActionContext<object, MachineEvent, unknown>);\n if (patch === null || typeof patch !== 'object') throw new TypeError('assign() must return a context object patch.');\n if (patchChangesContext(currentContext, patch)) {\n currentContext = Object.assign({}, currentContext as object, patch) as Context;\n changed = true;\n }\n } else {\n action(contextForAction);\n }\n if (status !== 'active') return changed;\n }\n return changed;\n }\n\n function startInvocations(event: Event | undefined): void {\n const definitions = stateDefinition().invoke;\n if (!definitions) return;\n const entry: StateEntry<Context, Event, Input, State> = {\n active: true,\n generation: ++entryGeneration,\n controllers: [],\n };\n activeEntry = entry;\n const list = Array.isArray(definitions) ? definitions : [definitions];\n for (const invocation of list) {\n startInvocation(entry, invocation, event);\n if (status !== 'active' || !entry.active || activeEntry !== entry) break;\n }\n }\n\n function startInvocation(\n entry: StateEntry<Context, Event, Input, State>,\n invocation: MachineInvocation<Context, Event, Input, State>,\n event: Event | undefined,\n ): void {\n const controller = new AbortController();\n const owned: OwnedInvocation<Context, Event, Input, State> = { controller, invocation, cleanup: undefined };\n entry.controllers.push(owned);\n let returned: void | (() => void) | Promise<unknown>;\n try {\n returned = invocation.task({\n context: currentContext,\n event,\n input,\n signal: controller.signal,\n send(queuedEvent: Event): void {\n if (status !== 'active' || !entry.active || activeEntry !== entry || controller.signal.aborted) return;\n actor.send(queuedEvent);\n },\n });\n } catch (cause) {\n queueInvocation({ kind: 'error', entry, invocation, error: cause });\n return;\n }\n if (typeof returned === 'function') {\n owned.cleanup = returned;\n } else if (returned && typeof (returned as Promise<unknown>).then === 'function') {\n Promise.resolve(returned).then(\n output => queueInvocation({ kind: 'done', entry, invocation, output }),\n cause => queueInvocation({ kind: 'error', entry, invocation, error: cause }),\n );\n }\n }\n\n function queueInvocation(item: InvocationQueueItem<Context, Event, Input, State>): void {\n if (status !== 'active' || !item.entry.active || activeEntry !== item.entry) return;\n queue.push(item);\n if (!processing) drain();\n }\n\n function cancelEntry(): void {\n const entry = activeEntry;\n activeEntry = undefined;\n if (!entry) return;\n entry.active = false;\n const failures: unknown[] = [];\n for (const owned of entry.controllers) {\n try { owned.controller.abort(); } catch (cause) { failures.push(cause); }\n const cleanup = owned.cleanup;\n owned.cleanup = undefined;\n if (cleanup) {\n try { cleanup(); } catch (cause) { failures.push(cause); }\n }\n }\n entry.controllers.length = 0;\n if (failures.length === 1) throw failures[0];\n if (failures.length > 1) throw new AggregateError(failures, 'Machine state task cleanup failed.');\n }\n\n function fail(cause: unknown): void {\n if (status === 'error' || status === 'stopped') return;\n status = 'error';\n error = cause;\n try { cancelEntry(); } catch (cleanupCause) { error = new AggregateError([cause, cleanupCause], 'Machine failed while cleaning up a state task.'); }\n releaseQueue();\n publish();\n }\n\n function releaseQueue(): void {\n for (let index = queueHead; index < queue.length; index++) queue[index] = undefined as never;\n queue.length = 0;\n queueHead = 0;\n }\n\n function publish(): void {\n writableSnapshot.set(snapshot(value, currentContext, status, error));\n }\n}\n\nfunction snapshot<Context, State extends string>(\n value: State,\n context: Context,\n status: MachineStatus,\n error: unknown | undefined,\n): MachineSnapshot<Context, State> {\n return Object.freeze({ value, context, status, error, matches: (candidate: State) => candidate === value });\n}\n\n/** Avoid replacing context or publishing a snapshot for an assignment that changes no own key. */\nfunction patchChangesContext(context: unknown, patch: object): boolean {\n if (context === null || typeof context !== 'object') return true;\n for (const key of Reflect.ownKeys(patch)) {\n if (!Object.is((context as Record<PropertyKey, unknown>)[key], (patch as Record<PropertyKey, unknown>)[key])) return true;\n }\n return false;\n}\n\nfunction compile<Context, Event extends MachineEvent, Input, State extends string>(\n definition: MachineDefinition<Context, Event, Input, State>,\n): CompiledMachine {\n const known = compiledMachines.get(definition);\n if (known) return known;\n if (!definition || typeof definition !== 'object') throw new TypeError('Machine definition must be an object.');\n if (!definition.states || typeof definition.states !== 'object') throw new TypeError('Machine definition requires a states object.');\n if (!Object.prototype.hasOwnProperty.call(definition.states, definition.initial)) throw new RangeError(`Machine initial state ${JSON.stringify(definition.initial)} is not declared.`);\n const names = new Set(Object.keys(definition.states));\n const states = new Map<string, CompiledState>();\n for (const [name, rawValue] of Object.entries(definition.states)) {\n const raw = rawValue as MachineState<Context, Event, Input, State>;\n if (!raw || typeof raw !== 'object') throw new TypeError(`Machine state ${JSON.stringify(name)} must be an object.`);\n validateHandlers(raw.on, names, `state ${JSON.stringify(name)}`);\n validateInvocations(raw.invoke, names, `state ${JSON.stringify(name)}`);\n const normalized = normalizeState(raw);\n states.set(name, { definition: normalized as unknown as MachineState<object, MachineEvent, unknown, string>, on: new Map(Object.entries(normalized.on ?? {})) });\n }\n validateHandlers(definition.on, names, 'machine');\n const compiled: CompiledMachine = { states, on: normalizeHandlers(definition.on) };\n compiledMachines.set(definition, compiled);\n return compiled;\n}\n\nfunction normalizeState<Context, Event extends MachineEvent, Input, State extends string>(\n state: MachineState<Context, Event, Input, State>,\n): MachineState<Context, Event, Input, State> {\n const invocations = state.invoke === undefined ? undefined : (Array.isArray(state.invoke)\n ? state.invoke.map(invocation => normalizeInvocation(invocation))\n : normalizeInvocation(state.invoke));\n return Object.freeze({\n entry: normalizeActions(state.entry),\n exit: normalizeActions(state.exit),\n invoke: invocations === undefined ? undefined : Object.freeze(Array.isArray(invocations) ? invocations : [invocations]),\n on: Object.freeze(Object.fromEntries(normalizeHandlers(state.on))),\n }) as unknown as MachineState<Context, Event, Input, State>;\n}\n\nfunction normalizeHandlers(handlers: object | undefined): Map<string, unknown> {\n if (!handlers) return new Map();\n return new Map(Object.entries(handlers).map(([type, transition]) => [type, normalizeTransition(transition)]));\n}\n\nfunction normalizeInvocation(invocation: unknown): object {\n const source = invocation as { id?: string; task: unknown; onDone?: unknown; onError?: unknown };\n return Object.freeze({\n id: source.id,\n task: source.task,\n onDone: normalizeTransition(source.onDone),\n onError: normalizeTransition(source.onError),\n });\n}\n\nfunction normalizeTransition(transition: unknown): unknown {\n if (transition === undefined || typeof transition === 'string') return transition;\n if (Array.isArray(transition)) return Object.freeze(transition.map(candidate => normalizeTransition(candidate)));\n const source = transition as { target?: string; guard?: unknown; actions?: unknown; reenter?: boolean };\n return Object.freeze({\n target: source.target,\n guard: source.guard,\n actions: normalizeActions(source.actions),\n reenter: source.reenter,\n });\n}\n\nfunction normalizeActions(actions: unknown): unknown {\n return Array.isArray(actions) ? Object.freeze([...actions]) : actions;\n}\n\nfunction validateHandlers(handlers: object | undefined, names: ReadonlySet<string>, label: string): void {\n if (handlers === undefined) return;\n if (!handlers || typeof handlers !== 'object') throw new TypeError(`Handlers for ${label} must be an object.`);\n for (const transition of Object.values(handlers)) validateTransition(transition, names, label);\n}\n\nfunction validateInvocations(invocations: unknown, names: ReadonlySet<string>, label: string): void {\n if (invocations === undefined) return;\n const list = Array.isArray(invocations) ? invocations : [invocations];\n for (const invocation of list) {\n if (!invocation || typeof invocation !== 'object' || typeof (invocation as { task?: unknown }).task !== 'function') throw new TypeError(`Each invocation in ${label} requires a task function.`);\n const typed = invocation as { onDone?: unknown; onError?: unknown };\n validateTransition(typed.onDone, names, label);\n validateTransition(typed.onError, names, label);\n }\n}\n\nfunction validateTransition(transition: unknown, names: ReadonlySet<string>, label: string): void {\n if (transition === undefined) return;\n const list = Array.isArray(transition) ? transition : [transition];\n for (const candidate of list) {\n if (typeof candidate === 'string') {\n if (!names.has(candidate)) throw new RangeError(`Transition in ${label} targets undeclared state ${JSON.stringify(candidate)}.`);\n continue;\n }\n if (!candidate || typeof candidate !== 'object') throw new TypeError(`Transition in ${label} must be a state name or object.`);\n const config = candidate as { target?: unknown; guard?: unknown; actions?: unknown };\n if (config.target !== undefined && (typeof config.target !== 'string' || !names.has(config.target))) throw new RangeError(`Transition in ${label} targets an undeclared state.`);\n if (config.guard !== undefined && typeof config.guard !== 'function') throw new TypeError(`Transition guard in ${label} must be a function.`);\n if (config.actions !== undefined && typeof config.actions !== 'function' && (!Array.isArray(config.actions) || config.actions.some(action => typeof action !== 'function'))) throw new TypeError(`Transition actions in ${label} must be functions.`);\n }\n}\n\ninterface StateEntry<Context, Event extends MachineEvent, Input, State extends string> {\n active: boolean;\n readonly generation: number;\n readonly controllers: OwnedInvocation<Context, Event, Input, State>[];\n}\ninterface OwnedInvocation<Context, Event extends MachineEvent, Input, State extends string> {\n readonly controller: AbortController;\n readonly invocation: MachineInvocation<Context, Event, Input, State>;\n cleanup: (() => void) | undefined;\n}\ntype EventQueueItem<Event extends MachineEvent> = { readonly kind: 'event'; readonly event: Event };\ntype InvocationQueueItem<Context, Event extends MachineEvent, Input, State extends string> =\n | { readonly kind: 'done'; readonly entry: StateEntry<Context, Event, Input, State>; readonly invocation: MachineInvocation<Context, Event, Input, State>; readonly output: unknown }\n | { readonly kind: 'error'; readonly entry: StateEntry<Context, Event, Input, State>; readonly invocation: MachineInvocation<Context, Event, Input, State>; readonly error: unknown };\ntype QueueItem<Context, Event extends MachineEvent, Input, State extends string> = EventQueueItem<Event> | InvocationQueueItem<Context, Event, Input, State>;\n"],
|
|
5
|
+
"mappings": "AAAA,SAAS,gCAAgC,cAAc;AACvD,SAAS,oBAAoB;AA6B7B,MAAM,mBAAmB,oBAAI,QAAiC;AASvD,SAAS,cACd,YACiD;AACjD,UAAQ,UAAU;AAClB,SAAO;AACT;AAUO,SAAS,cACd,YACA,SAC4C;AAC5C,QAAM,WAAW,QAAQ,UAAU;AACnC,QAAM,QAAQ,QAAQ;AACtB,QAAM,UAAU,OAAO,WAAW,YAAY,aACzC,WAAW,QAA2D,EAAE,MAAM,CAAC,IAChF,WAAW;AACf,MAAI,iBAAiB;AACrB,MAAI,QAAQ,WAAW;AACvB,MAAI,SAAwB;AAC5B,MAAI;AACJ,MAAI;AACJ,MAAI,kBAAkB;AACtB,QAAM,UAAU,SAAS,OAAO,gBAAgB,QAAQ,KAAK;AAC7D,QAAM,mBAAmB,OAAO,SAAS,EAAE,WAAW,mBAAmB,CAAC;AAC1E,QAAM,iBAAiB,iBAAiB,WAAW;AACnD,QAAM,QAAmD,CAAC;AAC1D,MAAI,YAAY;AAChB,MAAI,aAAa;AAEjB,QAAM,QAAoD;AAAA,IACxD,UAAU;AAAA,IACV,QAAc;AACZ,UAAI,WAAW,cAAe;AAC9B,qCAA+B,gBAAgB;AAC/C,eAAS;AAGT,mBAAa;AACb,UAAI;A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OAAO,MAAM,GAAI,OAAM,IAAI,WAAW,iBAAiB,KAAK,+BAA+B;AAC/K,QAAI,OAAO,UAAU,UAAa,OAAO,OAAO,UAAU,WAAY,OAAM,IAAI,UAAU,uBAAuB,KAAK,sBAAsB;AAC5I,QAAI,OAAO,YAAY,UAAa,OAAO,OAAO,YAAY,eAAe,CAAC,MAAM,QAAQ,OAAO,OAAO,KAAK,OAAO,QAAQ,KAAK,YAAU,OAAO,WAAW,UAAU,GAAI,OAAM,IAAI,UAAU,yBAAyB,KAAK,qBAAqB;AAAA,EACtP;AACF;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1,164 @@
|
|
|
1
|
+
import type { Signal } from '../../lib/signals/types.js';
|
|
2
|
+
/** An event accepted by a machine. The `type` selects the active state's handler. @see {@link MachineDefinition} */
|
|
3
|
+
export interface MachineEvent {
|
|
4
|
+
/** Stable event discriminator. */
|
|
5
|
+
readonly type: string;
|
|
6
|
+
}
|
|
7
|
+
/**
|
|
8
|
+
* Maps each event discriminator to its narrowed event shape.
|
|
9
|
+
* @property type - Handler selected for each event discriminator.
|
|
10
|
+
* @see {@link MachineTransition}
|
|
11
|
+
*/
|
|
12
|
+
export type MachineEventRoutes<Context, Event extends MachineEvent, Input, State extends string> = {
|
|
13
|
+
[type in Event['type']]?: MachineTransition<Context, Extract<Event, {
|
|
14
|
+
readonly type: type;
|
|
15
|
+
}>, Input, State, Event>;
|
|
16
|
+
};
|
|
17
|
+
/** Lifecycle state of a machine actor. @see {@link MachineActor} */
|
|
18
|
+
export type MachineStatus = 'not-started' | 'active' | 'stopped' | 'error';
|
|
19
|
+
/** Immutable state published by a running machine actor. @see {@link MachineActor} */
|
|
20
|
+
export interface MachineSnapshot<Context, State extends string = string> {
|
|
21
|
+
/** Active flat state name. */
|
|
22
|
+
readonly value: State;
|
|
23
|
+
/** Application-owned immutable context for the active state. */
|
|
24
|
+
readonly context: Readonly<Context>;
|
|
25
|
+
/** Whether the actor may receive events. */
|
|
26
|
+
readonly status: MachineStatus;
|
|
27
|
+
/** Unexpected failure that stopped this actor, if any. */
|
|
28
|
+
readonly error: unknown | undefined;
|
|
29
|
+
/** Tests whether this flat machine currently occupies `state`.
|
|
30
|
+
* @param state - State name to compare with the active value.
|
|
31
|
+
* @returns True when this is the active state.
|
|
32
|
+
*/
|
|
33
|
+
matches(state: State): boolean;
|
|
34
|
+
}
|
|
35
|
+
/** Cleanup called when a callback task's owning state exits or its actor stops. @see {@link MachineTask} */
|
|
36
|
+
export type MachineTaskCleanup = () => void;
|
|
37
|
+
/** Values given to state actions. Context reflects all preceding `assign` actions. @see {@link MachineAction} */
|
|
38
|
+
export interface MachineActionContext<Context, Event extends MachineEvent | undefined, Input, SentEvent extends MachineEvent = MachineEvent> {
|
|
39
|
+
/** Context as it exists at this point in the transition. */
|
|
40
|
+
readonly context: Readonly<Context>;
|
|
41
|
+
/** Event which selected this transition. */
|
|
42
|
+
readonly event: Event;
|
|
43
|
+
/** Immutable actor input supplied at creation. */
|
|
44
|
+
readonly input: Input;
|
|
45
|
+
/** Queues an event after the current transition has completed.
|
|
46
|
+
* @param event - Event to process after the active transition.
|
|
47
|
+
*/
|
|
48
|
+
send(event: SentEvent): void;
|
|
49
|
+
}
|
|
50
|
+
/** A synchronous effect run during entry, exit, or a transition. @see {@link MachineActionContext} */
|
|
51
|
+
export type MachineAction<Context, Event extends MachineEvent | undefined, Input, SentEvent extends MachineEvent = MachineEvent> = {
|
|
52
|
+
/** Executes one synchronous effect.
|
|
53
|
+
* @param context - Current transition values.
|
|
54
|
+
*/
|
|
55
|
+
action(context: MachineActionContext<Context, Event, Input, SentEvent>): void;
|
|
56
|
+
}['action'];
|
|
57
|
+
/** One action or actions run in source order. @see {@link MachineAction} */
|
|
58
|
+
export type MachineActions<Context, Event extends MachineEvent | undefined, Input, SentEvent extends MachineEvent = MachineEvent> = MachineAction<Context, Event, Input, SentEvent> | readonly MachineAction<Context, Event, Input, SentEvent>[];
|
|
59
|
+
/** Values supplied to a state-owned task when that state is entered. @see {@link MachineTask} */
|
|
60
|
+
export interface MachineTaskContext<Context, Event extends MachineEvent, Input> {
|
|
61
|
+
/** Context captured when this particular task starts. */
|
|
62
|
+
readonly context: Readonly<Context>;
|
|
63
|
+
/** Event that entered this state, or undefined for the initial state. */
|
|
64
|
+
readonly event: Event | undefined;
|
|
65
|
+
/** Immutable actor input supplied at creation. */
|
|
66
|
+
readonly input: Input;
|
|
67
|
+
/** Aborted synchronously when the owning state exits. */
|
|
68
|
+
readonly signal: AbortSignal;
|
|
69
|
+
/** Queues an event after the current transition, without re-entering the actor.
|
|
70
|
+
* @param event - Event accepted by the owning actor.
|
|
71
|
+
*/
|
|
72
|
+
send(event: Event): void;
|
|
73
|
+
}
|
|
74
|
+
/**
|
|
75
|
+
* Cancelable work owned by a state entry. Return a cleanup for subscriptions or a promise for
|
|
76
|
+
* finite work. A task is never started until its entry snapshot has been published.
|
|
77
|
+
* @param context - State-entry values and cancellation signal.
|
|
78
|
+
* @returns Optional cleanup or a promise for finite work.
|
|
79
|
+
* @see {@link MachineInvocation}
|
|
80
|
+
*/
|
|
81
|
+
export type MachineTask<Context, Event extends MachineEvent, Input, Output = unknown> = (context: MachineTaskContext<Context, Event, Input>) => void | MachineTaskCleanup | Promise<Output>;
|
|
82
|
+
/** Completion data supplied to an invocation's `onDone` transition. @see {@link MachineInvocation} */
|
|
83
|
+
export interface MachineTaskDoneEvent<Output = unknown> extends MachineEvent {
|
|
84
|
+
/** Internal completion discriminator. */ readonly type: '@pibbl/machine.done';
|
|
85
|
+
/** Value resolved by the task promise. */ readonly output: Output;
|
|
86
|
+
}
|
|
87
|
+
/** Failure data supplied to an invocation's `onError` transition. @see {@link MachineInvocation} */
|
|
88
|
+
export interface MachineTaskErrorEvent extends MachineEvent {
|
|
89
|
+
/** Internal failure discriminator. */ readonly type: '@pibbl/machine.error';
|
|
90
|
+
/** Thrown or rejected task value. */ readonly error: unknown;
|
|
91
|
+
}
|
|
92
|
+
/** A transition selected by an invocation completion or failure. */
|
|
93
|
+
/** State-owned task and optional completion transitions. @see {@link MachineTask} */
|
|
94
|
+
export interface MachineInvocation<Context, Event extends MachineEvent, Input, State extends string> {
|
|
95
|
+
/** Optional diagnostic identity; IDs are local to one state entry. */
|
|
96
|
+
readonly id?: string;
|
|
97
|
+
/** Work started after this state's snapshot publishes. */
|
|
98
|
+
readonly task: MachineTask<Context, Event, Input>;
|
|
99
|
+
/** Transition selected if a promise resolves before cancellation. */
|
|
100
|
+
readonly onDone?: MachineTransition<Context, MachineTaskDoneEvent, Input, State, Event>;
|
|
101
|
+
/** Transition selected if a task throws or a promise rejects before cancellation. */
|
|
102
|
+
readonly onError?: MachineTransition<Context, MachineTaskErrorEvent, Input, State, Event>;
|
|
103
|
+
}
|
|
104
|
+
/** A conditional route considered in list order. @see {@link MachineTransition} */
|
|
105
|
+
export interface MachineTransitionConfig<Context, Event extends MachineEvent, Input, State extends string, SentEvent extends MachineEvent = Event> {
|
|
106
|
+
/** Destination state. Omit to run actions without leaving the current state. */
|
|
107
|
+
readonly target?: State;
|
|
108
|
+
/** Only select this route when it returns true.
|
|
109
|
+
* @param context - Current transition values.
|
|
110
|
+
* @returns Whether this route may be selected.
|
|
111
|
+
*/
|
|
112
|
+
readonly guard?: (context: MachineActionContext<Context, Event, Input, SentEvent>) => boolean;
|
|
113
|
+
/** Effects run after exit and before entry. */
|
|
114
|
+
readonly actions?: MachineActions<Context, Event, Input, SentEvent>;
|
|
115
|
+
/** Restarts entry work when targeting the already active state. */
|
|
116
|
+
readonly reenter?: boolean;
|
|
117
|
+
}
|
|
118
|
+
/** Shorthand state target, a configured route, or ordered guarded alternatives. @see {@link MachineTransitionConfig} */
|
|
119
|
+
export type MachineTransition<Context, Event extends MachineEvent, Input, State extends string, SentEvent extends MachineEvent = Event> = State | MachineTransitionConfig<Context, Event, Input, State, SentEvent> | readonly MachineTransitionConfig<Context, Event, Input, State, SentEvent>[];
|
|
120
|
+
/** One flat state definition. Local event handlers shadow machine-level handlers. @see {@link MachineDefinition} */
|
|
121
|
+
export interface MachineState<Context, Event extends MachineEvent, Input, State extends string> {
|
|
122
|
+
/** Effects run whenever this state is entered. The initial entry receives `undefined` as event. */
|
|
123
|
+
readonly entry?: MachineActions<Context, Event | undefined, Input, Event>;
|
|
124
|
+
/** Effects run whenever this state is exited. */
|
|
125
|
+
readonly exit?: MachineActions<Context, Event, Input, Event>;
|
|
126
|
+
/** State-owned work, canceled before exit effects. */
|
|
127
|
+
readonly invoke?: MachineInvocation<Context, Event, Input, State> | readonly MachineInvocation<Context, Event, Input, State>[];
|
|
128
|
+
/** Event routes local to this state. Declaring an event consumes machine-level handling. */
|
|
129
|
+
readonly on?: MachineEventRoutes<Context, Event, Input, State>;
|
|
130
|
+
}
|
|
131
|
+
/** Declarative, reusable machine definition. Definitions create no actor or scheduled work. @see {@link MachineActor} */
|
|
132
|
+
export interface MachineDefinition<Context, Event extends MachineEvent, Input = undefined, State extends string = string> {
|
|
133
|
+
/** State entered when an actor starts. */
|
|
134
|
+
readonly initial: State;
|
|
135
|
+
/** Initial context or a factory evaluated once for every actor.
|
|
136
|
+
* @param context - Input used to create this actor's context.
|
|
137
|
+
* @returns Initial context for the new actor.
|
|
138
|
+
*/
|
|
139
|
+
readonly context: Context | ((context: Readonly<{
|
|
140
|
+
input: Input;
|
|
141
|
+
}>) => Context);
|
|
142
|
+
/** State table. This initial implementation supports flat states only. */
|
|
143
|
+
readonly states: Readonly<Record<State, MachineState<Context, Event, Input, State>>>;
|
|
144
|
+
/** Fallback routes for events not declared by the active state. */
|
|
145
|
+
readonly on?: MachineEventRoutes<Context, Event, Input, State>;
|
|
146
|
+
}
|
|
147
|
+
/** Options used to create an explicitly owned actor. @see {@link MachineActor} */
|
|
148
|
+
export interface CreateMachineOptions<Input> {
|
|
149
|
+
/** Immutable application input available to context factories, actions, and tasks. */
|
|
150
|
+
readonly input: Input;
|
|
151
|
+
}
|
|
152
|
+
/** Explicitly owned machine execution. Call `start` before sending events and `stop` to release it. @see {@link MachineDefinition} */
|
|
153
|
+
export interface MachineActor<Context, Event extends MachineEvent, _Input, State extends string = string> {
|
|
154
|
+
/** Readonly, synchronous signal for the current state and context. */
|
|
155
|
+
readonly snapshot: Signal<MachineSnapshot<Context, State>>;
|
|
156
|
+
/** Starts the initial state once. Starting an active or stopped actor does nothing. */
|
|
157
|
+
start(): void;
|
|
158
|
+
/** Queues an event. Events sent during actions run after the current transition.
|
|
159
|
+
* @param event - Event accepted by this actor.
|
|
160
|
+
*/
|
|
161
|
+
send(event: Event): void;
|
|
162
|
+
/** Terminal, idempotent cleanup. Cancels every task owned by the active state. */
|
|
163
|
+
stop(): void;
|
|
164
|
+
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { boundsOfShape2D, massProperties2D, transformShape2D } from "./lib/2d/shapes.js";
|
|
2
|
-
import type {
|
|
2
|
+
import type { findAabbMatch2D, raycastClosest2D } from "./2d.js";
|
|
3
3
|
import type { raycastShape2D, shapeCastAgainstShape2D } from "./lib/2d/collision/casts.js";
|
|
4
4
|
import type { PibblPhysicsCollisionEvent2D, PibblPhysicsQueryHit2D } from "./lib/2d/types.js";
|
|
5
5
|
import type { PibblPhysicsContactInspection2D } from "./lib/2d/inspection-types.js";
|
|
@@ -36,7 +36,7 @@ export type PibblPhysicsTransform2D = PibblPhysicsPose2D;
|
|
|
36
36
|
*
|
|
37
37
|
* @see {@link PibblPhysicsVector2}
|
|
38
38
|
* @see {@link boundsOfShape2D}
|
|
39
|
-
* @see {@link
|
|
39
|
+
* @see {@link findAabbMatch2D}
|
|
40
40
|
*/
|
|
41
41
|
export interface PibblPhysicsAabb2D {
|
|
42
42
|
/** Lower bound of the coordinate or sampling interval. See {@link PibblPhysicsVector2}. */
|
|
@@ -49,7 +49,7 @@ export interface PibblPhysicsAabb2D {
|
|
|
49
49
|
*
|
|
50
50
|
* @see {@link PibblPhysicsVector2}
|
|
51
51
|
* @see {@link raycastShape2D}
|
|
52
|
-
* @see {@link
|
|
52
|
+
* @see {@link raycastClosest2D}
|
|
53
53
|
*/
|
|
54
54
|
export interface PibblPhysicsRay2D {
|
|
55
55
|
/** Origin of the transform or geometric query. See {@link PibblPhysicsVector2}. */
|