@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,171 @@
|
|
|
1
|
+
import type { LineAccessor } from "./types.js";
|
|
2
|
+
/**
|
|
3
|
+
* Shared inputs for source-aligned closing-price oscillators.
|
|
4
|
+
*
|
|
5
|
+
* @see {@link RelativeStrengthIndexPoint}
|
|
6
|
+
* @see {@link MovingAverageConvergenceDivergencePoint}
|
|
7
|
+
*/
|
|
8
|
+
export interface OscillatorOptions<D> {
|
|
9
|
+
/**
|
|
10
|
+
* Numeric property or callback that supplies each closing observation.
|
|
11
|
+
*
|
|
12
|
+
* @see {@link LineAccessor}
|
|
13
|
+
*/
|
|
14
|
+
readonly value: LineAccessor<D>;
|
|
15
|
+
/**
|
|
16
|
+
* Excludes a row before its accessor runs and resets the current warmup.
|
|
17
|
+
*
|
|
18
|
+
* @param datum - Source observation under consideration.
|
|
19
|
+
* @param index - Zero-based source index.
|
|
20
|
+
* @param data - Complete caller-supplied source data.
|
|
21
|
+
* @returns Whether the observation participates in the consecutive calculation.
|
|
22
|
+
* @see {@link LineAccessor}
|
|
23
|
+
*/
|
|
24
|
+
readonly defined?: (datum: D, index: number, data: readonly D[]) => boolean;
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Inputs for Wilder's relative strength index.
|
|
28
|
+
*
|
|
29
|
+
* @see {@link OscillatorOptions}
|
|
30
|
+
* @see {@link RelativeStrengthIndexPoint}
|
|
31
|
+
*/
|
|
32
|
+
export interface RelativeStrengthIndexOptions<D> extends OscillatorOptions<D> {
|
|
33
|
+
/**
|
|
34
|
+
* Positive safe number of consecutive price changes used by Wilder smoothing.
|
|
35
|
+
*
|
|
36
|
+
* @see {@link relativeStrengthIndex}
|
|
37
|
+
*/
|
|
38
|
+
readonly period: number;
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* Inputs for moving average convergence/divergence.
|
|
42
|
+
*
|
|
43
|
+
* @see {@link OscillatorOptions}
|
|
44
|
+
* @see {@link MovingAverageConvergenceDivergencePoint}
|
|
45
|
+
*/
|
|
46
|
+
export interface MovingAverageConvergenceDivergenceOptions<D> extends OscillatorOptions<D> {
|
|
47
|
+
/** Positive safe EMA period shorter than slowPeriod. */
|
|
48
|
+
readonly fastPeriod: number;
|
|
49
|
+
/** Positive safe EMA period longer than fastPeriod. */
|
|
50
|
+
readonly slowPeriod: number;
|
|
51
|
+
/** Positive safe EMA period used to smooth available MACD observations. */
|
|
52
|
+
readonly signalPeriod: number;
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* Inputs for the rolling stochastic oscillator.
|
|
56
|
+
*
|
|
57
|
+
* @see {@link StochasticOscillatorPoint}
|
|
58
|
+
* @see {@link LineAccessor}
|
|
59
|
+
*/
|
|
60
|
+
export interface StochasticOscillatorOptions<D> {
|
|
61
|
+
/** Numeric property or callback that supplies each high. See {@link LineAccessor}. */
|
|
62
|
+
readonly high: LineAccessor<D>;
|
|
63
|
+
/** Numeric property or callback that supplies each low. See {@link LineAccessor}. */
|
|
64
|
+
readonly low: LineAccessor<D>;
|
|
65
|
+
/** Numeric property or callback that supplies each close. See {@link LineAccessor}. */
|
|
66
|
+
readonly close: LineAccessor<D>;
|
|
67
|
+
/** Positive safe count of consecutive OHLC rows in the raw %K range. */
|
|
68
|
+
readonly lookbackPeriod: number;
|
|
69
|
+
/** Positive safe count of raw %K values in the smoothed %K average. */
|
|
70
|
+
readonly kPeriod: number;
|
|
71
|
+
/** Positive safe count of smoothed %K values in the %D average. */
|
|
72
|
+
readonly dPeriod: number;
|
|
73
|
+
/**
|
|
74
|
+
* Excludes a row before its accessors run and resets all oscillator warmup.
|
|
75
|
+
*
|
|
76
|
+
* @param datum - Source observation under consideration.
|
|
77
|
+
* @param index - Zero-based source index.
|
|
78
|
+
* @param data - Complete caller-supplied source data.
|
|
79
|
+
* @returns Whether the observation participates in consecutive windows.
|
|
80
|
+
* @see {@link LineAccessor}
|
|
81
|
+
*/
|
|
82
|
+
readonly defined?: (datum: D, index: number, data: readonly D[]) => boolean;
|
|
83
|
+
}
|
|
84
|
+
/**
|
|
85
|
+
* One source-aligned relative strength index observation.
|
|
86
|
+
*
|
|
87
|
+
* @see {@link RelativeStrengthIndexOptions}
|
|
88
|
+
*/
|
|
89
|
+
export interface RelativeStrengthIndexPoint<D> {
|
|
90
|
+
/** Caller-owned original observation. */
|
|
91
|
+
readonly datum: D;
|
|
92
|
+
/** Original source index, including rows that become gaps. */
|
|
93
|
+
readonly sourceIndex: number;
|
|
94
|
+
/** Wilder RSI from zero through 100, or null during warmup and gaps. */
|
|
95
|
+
readonly rsi: number | null;
|
|
96
|
+
}
|
|
97
|
+
/**
|
|
98
|
+
* One source-aligned moving average convergence/divergence observation.
|
|
99
|
+
*
|
|
100
|
+
* @see {@link MovingAverageConvergenceDivergenceOptions}
|
|
101
|
+
*/
|
|
102
|
+
export interface MovingAverageConvergenceDivergencePoint<D> {
|
|
103
|
+
/** Caller-owned original observation. */
|
|
104
|
+
readonly datum: D;
|
|
105
|
+
/** Original source index, including rows that become gaps. */
|
|
106
|
+
readonly sourceIndex: number;
|
|
107
|
+
/** Fast EMA minus slow EMA, or null before both are seeded. */
|
|
108
|
+
readonly macd: number | null;
|
|
109
|
+
/** EMA of available MACD values, or null during signal warmup. */
|
|
110
|
+
readonly signal: number | null;
|
|
111
|
+
/** MACD minus its signal, or null before the signal is available. */
|
|
112
|
+
readonly histogram: number | null;
|
|
113
|
+
}
|
|
114
|
+
/**
|
|
115
|
+
* One source-aligned stochastic oscillator observation.
|
|
116
|
+
*
|
|
117
|
+
* @see {@link StochasticOscillatorOptions}
|
|
118
|
+
*/
|
|
119
|
+
export interface StochasticOscillatorPoint<D> {
|
|
120
|
+
/** Caller-owned original observation. */
|
|
121
|
+
readonly datum: D;
|
|
122
|
+
/** Original source index, including rows that become gaps. */
|
|
123
|
+
readonly sourceIndex: number;
|
|
124
|
+
/** Unsmoothed %K from zero through 100, or null during warmup/a zero range. */
|
|
125
|
+
readonly rawK: number | null;
|
|
126
|
+
/** SMA-smoothed %K, or null during warmup/a zero range. */
|
|
127
|
+
readonly k: number | null;
|
|
128
|
+
/** SMA of smoothed %K, or null during warmup/a zero range. */
|
|
129
|
+
readonly d: number | null;
|
|
130
|
+
}
|
|
131
|
+
/**
|
|
132
|
+
* Derives source-aligned Wilder relative strength index observations.
|
|
133
|
+
*
|
|
134
|
+
* The first RSI follows a full `period` of consecutive price changes, requiring `period + 1`
|
|
135
|
+
* consecutive prices. Flat average gain/loss yields 50; gain-only yields 100 and loss-only yields
|
|
136
|
+
* 0. Missing, nonfinite, and excluded rows produce null and reset the seed.
|
|
137
|
+
*
|
|
138
|
+
* @param data - Source observations, retained in their original order.
|
|
139
|
+
* @param options - Closing value accessor, Wilder period, and optional participation callback.
|
|
140
|
+
* @returns Frozen source-aligned RSI observations.
|
|
141
|
+
* @see {@link RelativeStrengthIndexOptions}
|
|
142
|
+
* @see {@link RelativeStrengthIndexPoint}
|
|
143
|
+
*/
|
|
144
|
+
export declare function relativeStrengthIndex<D>(data: readonly D[], options: RelativeStrengthIndexOptions<D>): readonly RelativeStrengthIndexPoint<D>[];
|
|
145
|
+
/**
|
|
146
|
+
* Derives source-aligned MACD, signal, and histogram observations from SMA-seeded EMAs.
|
|
147
|
+
*
|
|
148
|
+
* Missing, nonfinite, and excluded rows produce null fields and reset all EMA warmup. The MACD
|
|
149
|
+
* value appears once both price EMAs are seeded; signal and histogram wait for their own EMA seed.
|
|
150
|
+
*
|
|
151
|
+
* @param data - Source observations, retained in their original order.
|
|
152
|
+
* @param options - Closing value accessor, ordered EMA periods, and participation callback.
|
|
153
|
+
* @returns Frozen source-aligned MACD observations.
|
|
154
|
+
* @see {@link MovingAverageConvergenceDivergenceOptions}
|
|
155
|
+
* @see {@link MovingAverageConvergenceDivergencePoint}
|
|
156
|
+
*/
|
|
157
|
+
export declare function movingAverageConvergenceDivergence<D>(data: readonly D[], options: MovingAverageConvergenceDivergenceOptions<D>): readonly MovingAverageConvergenceDivergencePoint<D>[];
|
|
158
|
+
/**
|
|
159
|
+
* Derives source-aligned rolling stochastic %K, smoothed %K, and %D observations.
|
|
160
|
+
*
|
|
161
|
+
* %K uses the trailing high/low range. A zero range yields null raw %K and resets only the %K/%D
|
|
162
|
+
* smoothing warmup, while its complete OHLC row remains in the rolling range. Missing, nonfinite,
|
|
163
|
+
* and excluded rows reset every window; malformed finite candles reject.
|
|
164
|
+
*
|
|
165
|
+
* @param data - Source OHLC observations, retained in their original order.
|
|
166
|
+
* @param options - OHLC accessors, rolling periods, and optional participation callback.
|
|
167
|
+
* @returns Frozen source-aligned stochastic oscillator observations.
|
|
168
|
+
* @see {@link StochasticOscillatorOptions}
|
|
169
|
+
* @see {@link StochasticOscillatorPoint}
|
|
170
|
+
*/
|
|
171
|
+
export declare function stochasticOscillator<D>(data: readonly D[], options: StochasticOscillatorOptions<D>): readonly StochasticOscillatorPoint<D>[];
|
|
@@ -0,0 +1,265 @@
|
|
|
1
|
+
import { finiteCoordinate, pointAccessor, pointData } from "./point-data.js";
|
|
2
|
+
function positivePeriod(period, name) {
|
|
3
|
+
if (!Number.isSafeInteger(period) || period <= 0)
|
|
4
|
+
throw new RangeError(`${name} must be a positive safe integer.`);
|
|
5
|
+
}
|
|
6
|
+
function mean(values) {
|
|
7
|
+
let scale = 0;
|
|
8
|
+
for (const value of values) scale = Math.max(scale, Math.abs(value));
|
|
9
|
+
if (scale === 0) return 0;
|
|
10
|
+
let sum = 0;
|
|
11
|
+
for (const value of values) sum += value / scale;
|
|
12
|
+
const result = sum / values.length * scale;
|
|
13
|
+
if (!Number.isFinite(result))
|
|
14
|
+
throw new RangeError("oscillator derived value must be finite.");
|
|
15
|
+
return result;
|
|
16
|
+
}
|
|
17
|
+
function weighted(previous, next, alpha) {
|
|
18
|
+
const scale = Math.max(Math.abs(previous), Math.abs(next));
|
|
19
|
+
if (scale === 0) return 0;
|
|
20
|
+
const result = (previous / scale * (1 - alpha) + next / scale * alpha) * scale;
|
|
21
|
+
if (!Number.isFinite(result))
|
|
22
|
+
throw new RangeError("oscillator derived value must be finite.");
|
|
23
|
+
return result;
|
|
24
|
+
}
|
|
25
|
+
function rollingPush(values, value, period) {
|
|
26
|
+
values.push(value);
|
|
27
|
+
if (values.length > period) values.shift();
|
|
28
|
+
}
|
|
29
|
+
function oscillatorValues(data, options) {
|
|
30
|
+
const rows = pointData(data, "oscillator");
|
|
31
|
+
const value = pointAccessor(options.value);
|
|
32
|
+
return Object.freeze(
|
|
33
|
+
rows.map((datum, index) => {
|
|
34
|
+
if (!(options.defined?.(datum, index, rows) ?? true)) return null;
|
|
35
|
+
const observed = value(datum, index, rows);
|
|
36
|
+
return finiteCoordinate(observed) ? observed : null;
|
|
37
|
+
})
|
|
38
|
+
);
|
|
39
|
+
}
|
|
40
|
+
function relativeStrengthIndex(data, options) {
|
|
41
|
+
positivePeriod(options.period, "RSI period");
|
|
42
|
+
const values = oscillatorValues(data, options);
|
|
43
|
+
const gains = [], losses = [];
|
|
44
|
+
let previous;
|
|
45
|
+
let averageGain, averageLoss;
|
|
46
|
+
return Object.freeze(
|
|
47
|
+
data.map((datum, sourceIndex) => {
|
|
48
|
+
const value = values[sourceIndex];
|
|
49
|
+
if (value === null) {
|
|
50
|
+
gains.length = 0;
|
|
51
|
+
losses.length = 0;
|
|
52
|
+
previous = void 0;
|
|
53
|
+
averageGain = void 0;
|
|
54
|
+
averageLoss = void 0;
|
|
55
|
+
return Object.freeze({ datum, sourceIndex, rsi: null });
|
|
56
|
+
}
|
|
57
|
+
if (previous === void 0) {
|
|
58
|
+
previous = value;
|
|
59
|
+
return Object.freeze({ datum, sourceIndex, rsi: null });
|
|
60
|
+
}
|
|
61
|
+
const change = value - previous;
|
|
62
|
+
if (!Number.isFinite(change))
|
|
63
|
+
throw new RangeError("RSI change must be finite.");
|
|
64
|
+
previous = value;
|
|
65
|
+
const gain = Math.max(change, 0), loss = Math.max(-change, 0);
|
|
66
|
+
if (averageGain === void 0 || averageLoss === void 0) {
|
|
67
|
+
gains.push(gain);
|
|
68
|
+
losses.push(loss);
|
|
69
|
+
if (gains.length < options.period)
|
|
70
|
+
return Object.freeze({ datum, sourceIndex, rsi: null });
|
|
71
|
+
averageGain = mean(gains);
|
|
72
|
+
averageLoss = mean(losses);
|
|
73
|
+
} else {
|
|
74
|
+
averageGain = weighted(averageGain, gain, 1 / options.period);
|
|
75
|
+
averageLoss = weighted(averageLoss, loss, 1 / options.period);
|
|
76
|
+
}
|
|
77
|
+
const rsi = averageGain === 0 && averageLoss === 0 ? 50 : averageLoss === 0 ? 100 : averageGain === 0 ? 0 : 100 - 100 / (1 + averageGain / averageLoss);
|
|
78
|
+
if (!Number.isFinite(rsi))
|
|
79
|
+
throw new RangeError("RSI derived value must be finite.");
|
|
80
|
+
return Object.freeze({ datum, sourceIndex, rsi });
|
|
81
|
+
})
|
|
82
|
+
);
|
|
83
|
+
}
|
|
84
|
+
function movingAverageConvergenceDivergence(data, options) {
|
|
85
|
+
positivePeriod(options.fastPeriod, "MACD fastPeriod");
|
|
86
|
+
positivePeriod(options.slowPeriod, "MACD slowPeriod");
|
|
87
|
+
positivePeriod(options.signalPeriod, "MACD signalPeriod");
|
|
88
|
+
if (options.fastPeriod >= options.slowPeriod)
|
|
89
|
+
throw new RangeError("MACD fastPeriod must be less than slowPeriod.");
|
|
90
|
+
const values = oscillatorValues(data, options);
|
|
91
|
+
const fastSeed = [], slowSeed = [], signalSeed = [];
|
|
92
|
+
const fastAlpha = 2 / (options.fastPeriod + 1), slowAlpha = 2 / (options.slowPeriod + 1);
|
|
93
|
+
const signalAlpha = 2 / (options.signalPeriod + 1);
|
|
94
|
+
let fast, slow, signal;
|
|
95
|
+
const reset = () => {
|
|
96
|
+
fastSeed.length = 0;
|
|
97
|
+
slowSeed.length = 0;
|
|
98
|
+
signalSeed.length = 0;
|
|
99
|
+
fast = void 0;
|
|
100
|
+
slow = void 0;
|
|
101
|
+
signal = void 0;
|
|
102
|
+
};
|
|
103
|
+
return Object.freeze(
|
|
104
|
+
data.map((datum, sourceIndex) => {
|
|
105
|
+
const value = values[sourceIndex];
|
|
106
|
+
if (value === null) {
|
|
107
|
+
reset();
|
|
108
|
+
return Object.freeze({
|
|
109
|
+
datum,
|
|
110
|
+
sourceIndex,
|
|
111
|
+
macd: null,
|
|
112
|
+
signal: null,
|
|
113
|
+
histogram: null
|
|
114
|
+
});
|
|
115
|
+
}
|
|
116
|
+
if (fast === void 0) {
|
|
117
|
+
fastSeed.push(value);
|
|
118
|
+
if (fastSeed.length === options.fastPeriod) fast = mean(fastSeed);
|
|
119
|
+
} else fast = weighted(fast, value, fastAlpha);
|
|
120
|
+
if (slow === void 0) {
|
|
121
|
+
slowSeed.push(value);
|
|
122
|
+
if (slowSeed.length === options.slowPeriod) slow = mean(slowSeed);
|
|
123
|
+
} else slow = weighted(slow, value, slowAlpha);
|
|
124
|
+
if (fast === void 0 || slow === void 0)
|
|
125
|
+
return Object.freeze({
|
|
126
|
+
datum,
|
|
127
|
+
sourceIndex,
|
|
128
|
+
macd: null,
|
|
129
|
+
signal: null,
|
|
130
|
+
histogram: null
|
|
131
|
+
});
|
|
132
|
+
const macd = fast - slow;
|
|
133
|
+
if (!Number.isFinite(macd))
|
|
134
|
+
throw new RangeError("MACD derived value must be finite.");
|
|
135
|
+
if (signal === void 0) {
|
|
136
|
+
signalSeed.push(macd);
|
|
137
|
+
if (signalSeed.length === options.signalPeriod)
|
|
138
|
+
signal = mean(signalSeed);
|
|
139
|
+
} else signal = weighted(signal, macd, signalAlpha);
|
|
140
|
+
const histogram = signal === void 0 ? null : macd - signal;
|
|
141
|
+
if (histogram !== null && !Number.isFinite(histogram))
|
|
142
|
+
throw new RangeError("MACD histogram must be finite.");
|
|
143
|
+
return Object.freeze({
|
|
144
|
+
datum,
|
|
145
|
+
sourceIndex,
|
|
146
|
+
macd,
|
|
147
|
+
signal: signal ?? null,
|
|
148
|
+
histogram
|
|
149
|
+
});
|
|
150
|
+
})
|
|
151
|
+
);
|
|
152
|
+
}
|
|
153
|
+
function stochasticValues(data, options) {
|
|
154
|
+
const rows = pointData(data, "stochastic oscillator");
|
|
155
|
+
const high = pointAccessor(options.high), low = pointAccessor(options.low), close = pointAccessor(options.close);
|
|
156
|
+
return Object.freeze(
|
|
157
|
+
rows.map((datum, index) => {
|
|
158
|
+
if (!(options.defined?.(datum, index, rows) ?? true)) return null;
|
|
159
|
+
const highValue = high(datum, index, rows);
|
|
160
|
+
const lowValue = low(datum, index, rows);
|
|
161
|
+
const closeValue = close(datum, index, rows);
|
|
162
|
+
if (!finiteCoordinate(highValue) || !finiteCoordinate(lowValue) || !finiteCoordinate(closeValue))
|
|
163
|
+
return null;
|
|
164
|
+
const values = {
|
|
165
|
+
high: highValue,
|
|
166
|
+
low: lowValue,
|
|
167
|
+
close: closeValue
|
|
168
|
+
};
|
|
169
|
+
if (values.low > values.high || values.close < values.low || values.close > values.high)
|
|
170
|
+
throw new RangeError(
|
|
171
|
+
"stochastic oscillator requires low <= close <= high."
|
|
172
|
+
);
|
|
173
|
+
return Object.freeze(values);
|
|
174
|
+
})
|
|
175
|
+
);
|
|
176
|
+
}
|
|
177
|
+
function stochasticOscillator(data, options) {
|
|
178
|
+
positivePeriod(options.lookbackPeriod, "stochastic lookbackPeriod");
|
|
179
|
+
positivePeriod(options.kPeriod, "stochastic kPeriod");
|
|
180
|
+
positivePeriod(options.dPeriod, "stochastic dPeriod");
|
|
181
|
+
const values = stochasticValues(data, options);
|
|
182
|
+
const window = [], kValues = [], dValues = [];
|
|
183
|
+
const reset = () => {
|
|
184
|
+
window.length = 0;
|
|
185
|
+
kValues.length = 0;
|
|
186
|
+
dValues.length = 0;
|
|
187
|
+
};
|
|
188
|
+
const resetSmoothing = () => {
|
|
189
|
+
kValues.length = 0;
|
|
190
|
+
dValues.length = 0;
|
|
191
|
+
};
|
|
192
|
+
return Object.freeze(
|
|
193
|
+
data.map((datum, sourceIndex) => {
|
|
194
|
+
const value = values[sourceIndex];
|
|
195
|
+
if (value === null) {
|
|
196
|
+
reset();
|
|
197
|
+
return Object.freeze({
|
|
198
|
+
datum,
|
|
199
|
+
sourceIndex,
|
|
200
|
+
rawK: null,
|
|
201
|
+
k: null,
|
|
202
|
+
d: null
|
|
203
|
+
});
|
|
204
|
+
}
|
|
205
|
+
window.push(value);
|
|
206
|
+
if (window.length > options.lookbackPeriod) window.shift();
|
|
207
|
+
if (window.length < options.lookbackPeriod)
|
|
208
|
+
return Object.freeze({
|
|
209
|
+
datum,
|
|
210
|
+
sourceIndex,
|
|
211
|
+
rawK: null,
|
|
212
|
+
k: null,
|
|
213
|
+
d: null
|
|
214
|
+
});
|
|
215
|
+
let high = -Infinity, low = Infinity;
|
|
216
|
+
for (const row of window) {
|
|
217
|
+
high = Math.max(high, row.high);
|
|
218
|
+
low = Math.min(low, row.low);
|
|
219
|
+
}
|
|
220
|
+
const scale = Math.max(
|
|
221
|
+
Math.abs(high),
|
|
222
|
+
Math.abs(low),
|
|
223
|
+
Math.abs(value.close)
|
|
224
|
+
);
|
|
225
|
+
if (scale === 0) {
|
|
226
|
+
resetSmoothing();
|
|
227
|
+
return Object.freeze({
|
|
228
|
+
datum,
|
|
229
|
+
sourceIndex,
|
|
230
|
+
rawK: null,
|
|
231
|
+
k: null,
|
|
232
|
+
d: null
|
|
233
|
+
});
|
|
234
|
+
}
|
|
235
|
+
const scaledLow = low / scale;
|
|
236
|
+
const scaledRange = high / scale - scaledLow;
|
|
237
|
+
if (scaledRange === 0) {
|
|
238
|
+
resetSmoothing();
|
|
239
|
+
return Object.freeze({
|
|
240
|
+
datum,
|
|
241
|
+
sourceIndex,
|
|
242
|
+
rawK: null,
|
|
243
|
+
k: null,
|
|
244
|
+
d: null
|
|
245
|
+
});
|
|
246
|
+
}
|
|
247
|
+
const rawK = (value.close / scale - scaledLow) / scaledRange * 100;
|
|
248
|
+
if (!Number.isFinite(rawK))
|
|
249
|
+
throw new RangeError("stochastic %K must be finite.");
|
|
250
|
+
rollingPush(kValues, rawK, options.kPeriod);
|
|
251
|
+
const k = kValues.length === options.kPeriod ? mean(kValues) : null;
|
|
252
|
+
if (k === null)
|
|
253
|
+
return Object.freeze({ datum, sourceIndex, rawK, k: null, d: null });
|
|
254
|
+
rollingPush(dValues, k, options.dPeriod);
|
|
255
|
+
const d = dValues.length === options.dPeriod ? mean(dValues) : null;
|
|
256
|
+
return Object.freeze({ datum, sourceIndex, rawK, k, d });
|
|
257
|
+
})
|
|
258
|
+
);
|
|
259
|
+
}
|
|
260
|
+
export {
|
|
261
|
+
movingAverageConvergenceDivergence,
|
|
262
|
+
relativeStrengthIndex,
|
|
263
|
+
stochasticOscillator
|
|
264
|
+
};
|
|
265
|
+
//# sourceMappingURL=financial-oscillators.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../../src/features/viz/lib/financial-oscillators.ts"],
|
|
4
|
+
"sourcesContent": ["import type { LineAccessor } from \"./types.js\";\nimport { finiteCoordinate, pointAccessor, pointData } from \"./point-data.js\";\n\n/**\n * Shared inputs for source-aligned closing-price oscillators.\n *\n * @see {@link RelativeStrengthIndexPoint}\n * @see {@link MovingAverageConvergenceDivergencePoint}\n */\nexport interface OscillatorOptions<D> {\n /**\n * Numeric property or callback that supplies each closing observation.\n *\n * @see {@link LineAccessor}\n */\n readonly value: LineAccessor<D>;\n /**\n * Excludes a row before its accessor runs and resets the current warmup.\n *\n * @param datum - Source observation under consideration.\n * @param index - Zero-based source index.\n * @param data - Complete caller-supplied source data.\n * @returns Whether the observation participates in the consecutive calculation.\n * @see {@link LineAccessor}\n */\n readonly defined?: (datum: D, index: number, data: readonly D[]) => boolean;\n}\n\n/**\n * Inputs for Wilder's relative strength index.\n *\n * @see {@link OscillatorOptions}\n * @see {@link RelativeStrengthIndexPoint}\n */\nexport interface RelativeStrengthIndexOptions<D> extends OscillatorOptions<D> {\n /**\n * Positive safe number of consecutive price changes used by Wilder smoothing.\n *\n * @see {@link relativeStrengthIndex}\n */\n readonly period: number;\n}\n\n/**\n * Inputs for moving average convergence/divergence.\n *\n * @see {@link OscillatorOptions}\n * @see {@link MovingAverageConvergenceDivergencePoint}\n */\nexport interface MovingAverageConvergenceDivergenceOptions<\n D,\n> extends OscillatorOptions<D> {\n /** Positive safe EMA period shorter than slowPeriod. */\n readonly fastPeriod: number;\n /** Positive safe EMA period longer than fastPeriod. */\n readonly slowPeriod: number;\n /** Positive safe EMA period used to smooth available MACD observations. */\n readonly signalPeriod: number;\n}\n\n/**\n * Inputs for the rolling stochastic oscillator.\n *\n * @see {@link StochasticOscillatorPoint}\n * @see {@link LineAccessor}\n */\nexport interface StochasticOscillatorOptions<D> {\n /** Numeric property or callback that supplies each high. See {@link LineAccessor}. */\n readonly high: LineAccessor<D>;\n /** Numeric property or callback that supplies each low. See {@link LineAccessor}. */\n readonly low: LineAccessor<D>;\n /** Numeric property or callback that supplies each close. See {@link LineAccessor}. */\n readonly close: LineAccessor<D>;\n /** Positive safe count of consecutive OHLC rows in the raw %K range. */\n readonly lookbackPeriod: number;\n /** Positive safe count of raw %K values in the smoothed %K average. */\n readonly kPeriod: number;\n /** Positive safe count of smoothed %K values in the %D average. */\n readonly dPeriod: number;\n /**\n * Excludes a row before its accessors run and resets all oscillator warmup.\n *\n * @param datum - Source observation under consideration.\n * @param index - Zero-based source index.\n * @param data - Complete caller-supplied source data.\n * @returns Whether the observation participates in consecutive windows.\n * @see {@link LineAccessor}\n */\n readonly defined?: (datum: D, index: number, data: readonly D[]) => boolean;\n}\n\n/**\n * One source-aligned relative strength index observation.\n *\n * @see {@link RelativeStrengthIndexOptions}\n */\nexport interface RelativeStrengthIndexPoint<D> {\n /** Caller-owned original observation. */\n readonly datum: D;\n /** Original source index, including rows that become gaps. */\n readonly sourceIndex: number;\n /** Wilder RSI from zero through 100, or null during warmup and gaps. */\n readonly rsi: number | null;\n}\n\n/**\n * One source-aligned moving average convergence/divergence observation.\n *\n * @see {@link MovingAverageConvergenceDivergenceOptions}\n */\nexport interface MovingAverageConvergenceDivergencePoint<D> {\n /** Caller-owned original observation. */\n readonly datum: D;\n /** Original source index, including rows that become gaps. */\n readonly sourceIndex: number;\n /** Fast EMA minus slow EMA, or null before both are seeded. */\n readonly macd: number | null;\n /** EMA of available MACD values, or null during signal warmup. */\n readonly signal: number | null;\n /** MACD minus its signal, or null before the signal is available. */\n readonly histogram: number | null;\n}\n\n/**\n * One source-aligned stochastic oscillator observation.\n *\n * @see {@link StochasticOscillatorOptions}\n */\nexport interface StochasticOscillatorPoint<D> {\n /** Caller-owned original observation. */\n readonly datum: D;\n /** Original source index, including rows that become gaps. */\n readonly sourceIndex: number;\n /** Unsmoothed %K from zero through 100, or null during warmup/a zero range. */\n readonly rawK: number | null;\n /** SMA-smoothed %K, or null during warmup/a zero range. */\n readonly k: number | null;\n /** SMA of smoothed %K, or null during warmup/a zero range. */\n readonly d: number | null;\n}\n\nfunction positivePeriod(period: number, name: string): void {\n if (!Number.isSafeInteger(period) || period <= 0)\n throw new RangeError(`${name} must be a positive safe integer.`);\n}\n\nfunction mean(values: readonly number[]): number {\n let scale = 0;\n for (const value of values) scale = Math.max(scale, Math.abs(value));\n if (scale === 0) return 0;\n let sum = 0;\n for (const value of values) sum += value / scale;\n const result = (sum / values.length) * scale;\n if (!Number.isFinite(result))\n throw new RangeError(\"oscillator derived value must be finite.\");\n return result;\n}\n\nfunction weighted(previous: number, next: number, alpha: number): number {\n const scale = Math.max(Math.abs(previous), Math.abs(next));\n if (scale === 0) return 0;\n const result =\n ((previous / scale) * (1 - alpha) + (next / scale) * alpha) * scale;\n if (!Number.isFinite(result))\n throw new RangeError(\"oscillator derived value must be finite.\");\n return result;\n}\n\nfunction rollingPush(values: number[], value: number, period: number): void {\n values.push(value);\n if (values.length > period) values.shift();\n}\n\nfunction oscillatorValues<D>(\n data: readonly D[],\n options: OscillatorOptions<D>,\n): readonly (number | null)[] {\n const rows = pointData(data, \"oscillator\");\n const value = pointAccessor(options.value);\n return Object.freeze(\n rows.map((datum, index) => {\n if (!(options.defined?.(datum, index, rows) ?? true)) return null;\n const observed = value(datum, index, rows);\n return finiteCoordinate(observed) ? observed : null;\n }),\n );\n}\n\n/**\n * Derives source-aligned Wilder relative strength index observations.\n *\n * The first RSI follows a full `period` of consecutive price changes, requiring `period + 1`\n * consecutive prices. Flat average gain/loss yields 50; gain-only yields 100 and loss-only yields\n * 0. Missing, nonfinite, and excluded rows produce null and reset the seed.\n *\n * @param data - Source observations, retained in their original order.\n * @param options - Closing value accessor, Wilder period, and optional participation callback.\n * @returns Frozen source-aligned RSI observations.\n * @see {@link RelativeStrengthIndexOptions}\n * @see {@link RelativeStrengthIndexPoint}\n */\nexport function relativeStrengthIndex<D>(\n data: readonly D[],\n options: RelativeStrengthIndexOptions<D>,\n): readonly RelativeStrengthIndexPoint<D>[] {\n positivePeriod(options.period, \"RSI period\");\n const values = oscillatorValues(data, options);\n const gains: number[] = [],\n losses: number[] = [];\n let previous: number | undefined;\n let averageGain: number | undefined, averageLoss: number | undefined;\n return Object.freeze(\n data.map((datum, sourceIndex) => {\n const value = values[sourceIndex];\n if (value === null) {\n gains.length = 0;\n losses.length = 0;\n previous = undefined;\n averageGain = undefined;\n averageLoss = undefined;\n return Object.freeze({ datum, sourceIndex, rsi: null });\n }\n if (previous === undefined) {\n previous = value;\n return Object.freeze({ datum, sourceIndex, rsi: null });\n }\n const change = value - previous;\n if (!Number.isFinite(change))\n throw new RangeError(\"RSI change must be finite.\");\n previous = value;\n const gain = Math.max(change, 0),\n loss = Math.max(-change, 0);\n if (averageGain === undefined || averageLoss === undefined) {\n gains.push(gain);\n losses.push(loss);\n if (gains.length < options.period)\n return Object.freeze({ datum, sourceIndex, rsi: null });\n averageGain = mean(gains);\n averageLoss = mean(losses);\n } else {\n averageGain = weighted(averageGain, gain, 1 / options.period);\n averageLoss = weighted(averageLoss, loss, 1 / options.period);\n }\n const rsi =\n averageGain === 0 && averageLoss === 0\n ? 50\n : averageLoss === 0\n ? 100\n : averageGain === 0\n ? 0\n : 100 - 100 / (1 + averageGain / averageLoss);\n if (!Number.isFinite(rsi))\n throw new RangeError(\"RSI derived value must be finite.\");\n return Object.freeze({ datum, sourceIndex, rsi });\n }),\n );\n}\n\n/**\n * Derives source-aligned MACD, signal, and histogram observations from SMA-seeded EMAs.\n *\n * Missing, nonfinite, and excluded rows produce null fields and reset all EMA warmup. The MACD\n * value appears once both price EMAs are seeded; signal and histogram wait for their own EMA seed.\n *\n * @param data - Source observations, retained in their original order.\n * @param options - Closing value accessor, ordered EMA periods, and participation callback.\n * @returns Frozen source-aligned MACD observations.\n * @see {@link MovingAverageConvergenceDivergenceOptions}\n * @see {@link MovingAverageConvergenceDivergencePoint}\n */\nexport function movingAverageConvergenceDivergence<D>(\n data: readonly D[],\n options: MovingAverageConvergenceDivergenceOptions<D>,\n): readonly MovingAverageConvergenceDivergencePoint<D>[] {\n positivePeriod(options.fastPeriod, \"MACD fastPeriod\");\n positivePeriod(options.slowPeriod, \"MACD slowPeriod\");\n positivePeriod(options.signalPeriod, \"MACD signalPeriod\");\n if (options.fastPeriod >= options.slowPeriod)\n throw new RangeError(\"MACD fastPeriod must be less than slowPeriod.\");\n const values = oscillatorValues(data, options);\n const fastSeed: number[] = [],\n slowSeed: number[] = [],\n signalSeed: number[] = [];\n const fastAlpha = 2 / (options.fastPeriod + 1),\n slowAlpha = 2 / (options.slowPeriod + 1);\n const signalAlpha = 2 / (options.signalPeriod + 1);\n let fast: number | undefined,\n slow: number | undefined,\n signal: number | undefined;\n const reset = () => {\n fastSeed.length = 0;\n slowSeed.length = 0;\n signalSeed.length = 0;\n fast = undefined;\n slow = undefined;\n signal = undefined;\n };\n return Object.freeze(\n data.map((datum, sourceIndex) => {\n const value = values[sourceIndex];\n if (value === null) {\n reset();\n return Object.freeze({\n datum,\n sourceIndex,\n macd: null,\n signal: null,\n histogram: null,\n });\n }\n if (fast === undefined) {\n fastSeed.push(value);\n if (fastSeed.length === options.fastPeriod) fast = mean(fastSeed);\n } else fast = weighted(fast, value, fastAlpha);\n if (slow === undefined) {\n slowSeed.push(value);\n if (slowSeed.length === options.slowPeriod) slow = mean(slowSeed);\n } else slow = weighted(slow, value, slowAlpha);\n if (fast === undefined || slow === undefined)\n return Object.freeze({\n datum,\n sourceIndex,\n macd: null,\n signal: null,\n histogram: null,\n });\n const macd = fast - slow;\n if (!Number.isFinite(macd))\n throw new RangeError(\"MACD derived value must be finite.\");\n if (signal === undefined) {\n signalSeed.push(macd);\n if (signalSeed.length === options.signalPeriod)\n signal = mean(signalSeed);\n } else signal = weighted(signal, macd, signalAlpha);\n const histogram = signal === undefined ? null : macd - signal;\n if (histogram !== null && !Number.isFinite(histogram))\n throw new RangeError(\"MACD histogram must be finite.\");\n return Object.freeze({\n datum,\n sourceIndex,\n macd,\n signal: signal ?? null,\n histogram,\n });\n }),\n );\n}\n\ninterface OhlcValue {\n readonly high: number;\n readonly low: number;\n readonly close: number;\n}\n\nfunction stochasticValues<D>(\n data: readonly D[],\n options: StochasticOscillatorOptions<D>,\n): readonly (OhlcValue | null)[] {\n const rows = pointData(data, \"stochastic oscillator\");\n const high = pointAccessor(options.high),\n low = pointAccessor(options.low),\n close = pointAccessor(options.close);\n return Object.freeze(\n rows.map((datum, index) => {\n if (!(options.defined?.(datum, index, rows) ?? true)) return null;\n const highValue = high(datum, index, rows);\n const lowValue = low(datum, index, rows);\n const closeValue = close(datum, index, rows);\n if (\n !finiteCoordinate(highValue) ||\n !finiteCoordinate(lowValue) ||\n !finiteCoordinate(closeValue)\n )\n return null;\n const values: OhlcValue = {\n high: highValue,\n low: lowValue,\n close: closeValue,\n };\n if (\n values.low > values.high ||\n values.close < values.low ||\n values.close > values.high\n )\n throw new RangeError(\n \"stochastic oscillator requires low <= close <= high.\",\n );\n return Object.freeze(values);\n }),\n );\n}\n\n/**\n * Derives source-aligned rolling stochastic %K, smoothed %K, and %D observations.\n *\n * %K uses the trailing high/low range. A zero range yields null raw %K and resets only the %K/%D\n * smoothing warmup, while its complete OHLC row remains in the rolling range. Missing, nonfinite,\n * and excluded rows reset every window; malformed finite candles reject.\n *\n * @param data - Source OHLC observations, retained in their original order.\n * @param options - OHLC accessors, rolling periods, and optional participation callback.\n * @returns Frozen source-aligned stochastic oscillator observations.\n * @see {@link StochasticOscillatorOptions}\n * @see {@link StochasticOscillatorPoint}\n */\nexport function stochasticOscillator<D>(\n data: readonly D[],\n options: StochasticOscillatorOptions<D>,\n): readonly StochasticOscillatorPoint<D>[] {\n positivePeriod(options.lookbackPeriod, \"stochastic lookbackPeriod\");\n positivePeriod(options.kPeriod, \"stochastic kPeriod\");\n positivePeriod(options.dPeriod, \"stochastic dPeriod\");\n const values = stochasticValues(data, options);\n const window: OhlcValue[] = [],\n kValues: number[] = [],\n dValues: number[] = [];\n const reset = () => {\n window.length = 0;\n kValues.length = 0;\n dValues.length = 0;\n };\n const resetSmoothing = () => {\n kValues.length = 0;\n dValues.length = 0;\n };\n return Object.freeze(\n data.map((datum, sourceIndex) => {\n const value = values[sourceIndex];\n if (value === null) {\n reset();\n return Object.freeze({\n datum,\n sourceIndex,\n rawK: null,\n k: null,\n d: null,\n });\n }\n window.push(value);\n if (window.length > options.lookbackPeriod) window.shift();\n if (window.length < options.lookbackPeriod)\n return Object.freeze({\n datum,\n sourceIndex,\n rawK: null,\n k: null,\n d: null,\n });\n let high = -Infinity,\n low = Infinity;\n for (const row of window) {\n high = Math.max(high, row.high);\n low = Math.min(low, row.low);\n }\n const scale = Math.max(\n Math.abs(high),\n Math.abs(low),\n Math.abs(value.close),\n );\n if (scale === 0) {\n resetSmoothing();\n return Object.freeze({\n datum,\n sourceIndex,\n rawK: null,\n k: null,\n d: null,\n });\n }\n const scaledLow = low / scale;\n const scaledRange = high / scale - scaledLow;\n if (scaledRange === 0) {\n resetSmoothing();\n return Object.freeze({\n datum,\n sourceIndex,\n rawK: null,\n k: null,\n d: null,\n });\n }\n const rawK = ((value.close / scale - scaledLow) / scaledRange) * 100;\n if (!Number.isFinite(rawK))\n throw new RangeError(\"stochastic %K must be finite.\");\n rollingPush(kValues, rawK, options.kPeriod);\n const k = kValues.length === options.kPeriod ? mean(kValues) : null;\n if (k === null)\n return Object.freeze({ datum, sourceIndex, rawK, k: null, d: null });\n rollingPush(dValues, k, options.dPeriod);\n const d = dValues.length === options.dPeriod ? mean(dValues) : null;\n return Object.freeze({ datum, sourceIndex, rawK, k, d });\n }),\n );\n}\n"],
|
|
5
|
+
"mappings": "AACA,SAAS,kBAAkB,eAAe,iBAAiB;AA4I3D,SAAS,eAAe,QAAgB,MAAoB;AAC1D,MAAI,CAAC,OAAO,cAAc,MAAM,KAAK,UAAU;AAC7C,UAAM,IAAI,WAAW,GAAG,IAAI,mCAAmC;AACnE;AAEA,SAAS,KAAK,QAAmC;AAC/C,MAAI,QAAQ;AACZ,aAAW,SAAS,OAAQ,SAAQ,KAAK,IAAI,OAAO,KAAK,IAAI,KAAK,CAAC;AACnE,MAAI,UAAU,EAAG,QAAO;AACxB,MAAI,MAAM;AACV,aAAW,SAAS,OAAQ,QAAO,QAAQ;AAC3C,QAAM,SAAU,MAAM,OAAO,SAAU;AACvC,MAAI,CAAC,OAAO,SAAS,MAAM;AACzB,UAAM,IAAI,WAAW,0CAA0C;AACjE,SAAO;AACT;AAEA,SAAS,SAAS,UAAkB,MAAc,OAAuB;AACvE,QAAM,QAAQ,KAAK,IAAI,KAAK,IAAI,QAAQ,GAAG,KAAK,IAAI,IAAI,CAAC;AACzD,MAAI,UAAU,EAAG,QAAO;AACxB,QAAM,UACF,WAAW,SAAU,IAAI,SAAU,OAAO,QAAS,SAAS;AAChE,MAAI,CAAC,OAAO,SAAS,MAAM;AACzB,UAAM,IAAI,WAAW,0CAA0C;AACjE,SAAO;AACT;AAEA,SAAS,YAAY,QAAkB,OAAe,QA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AI,MAAM;AACR,eAAO,OAAO,OAAO,EAAE,OAAO,aAAa,MAAM,GAAG,MAAM,GAAG,KAAK,CAAC;AACrE,kBAAY,SAAS,GAAG,QAAQ,OAAO;AACvC,YAAM,IAAI,QAAQ,WAAW,QAAQ,UAAU,KAAK,OAAO,IAAI;AAC/D,aAAO,OAAO,OAAO,EAAE,OAAO,aAAa,MAAM,GAAG,EAAE,CAAC;AAAA,IACzD,CAAC;AAAA,EACH;AACF;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -9,4 +9,4 @@ import type { HoverDataProps } from "./hover-types.js";
|
|
|
9
9
|
* @see {@link HoverDataProps}
|
|
10
10
|
* @see {@link PibblNode}
|
|
11
11
|
*/
|
|
12
|
-
export declare function HoverData<T>({ query, children }: HoverDataProps<T>): PibblNode;
|
|
12
|
+
export declare function HoverData<T>({ query, children, }: HoverDataProps<T>): PibblNode;
|
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
import { withHooksForbidden } from "@pibbl/core/internal";
|
|
2
2
|
import { readScale } from "./scale-context.js";
|
|
3
|
-
function HoverData({
|
|
3
|
+
function HoverData({
|
|
4
|
+
query,
|
|
5
|
+
children
|
|
6
|
+
}) {
|
|
4
7
|
if (typeof query !== "function" || typeof children !== "function")
|
|
5
8
|
throw new TypeError("HoverData requires query and children functions.");
|
|
6
9
|
const snapshots = /* @__PURE__ */ new Map();
|
|
@@ -16,9 +19,9 @@ function HoverData({ query, children }) {
|
|
|
16
19
|
const value = readScale(id, "HoverData");
|
|
17
20
|
if (!value) throw new TypeError("HoverData requires a scale ID.");
|
|
18
21
|
const resolved = value.get();
|
|
19
|
-
if (resolved.type
|
|
22
|
+
if (resolved.type === "band" || resolved.type === "point" || resolved.type === "trading-time")
|
|
20
23
|
throw new TypeError(
|
|
21
|
-
"HoverData numeric queries require
|
|
24
|
+
"HoverData numeric queries require continuous scales."
|
|
22
25
|
);
|
|
23
26
|
snapshot = resolved;
|
|
24
27
|
snapshots.set(id, snapshot);
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../src/features/viz/lib/hover-data.tsx"],
|
|
4
|
-
"sourcesContent": ["import type { PibblNode } from \"@pibbl/core\";\nimport { withHooksForbidden } from \"@pibbl/core/internal\";\nimport type { HoverDataProps, HoverQueryContext } from \"./hover-types.js\";\nimport type {
|
|
5
|
-
"mappings": "AACA,SAAS,0BAA0B;AAGnC,SAAS,iBAAiB;AAUnB,SAAS,UAAa,
|
|
4
|
+
"sourcesContent": ["import type { PibblNode } from \"@pibbl/core\";\nimport { withHooksForbidden } from \"@pibbl/core/internal\";\nimport type { HoverDataProps, HoverQueryContext } from \"./hover-types.js\";\nimport type { ResolvedContinuousScale, ScaleId } from \"./types.js\";\nimport { readScale } from \"./scale-context.js\";\n/**\n * Evaluates an ordinary synchronous query under the current scale scope.\n *\n * @param props - Hover query and child renderer receiving its result. See {@link HoverDataProps}.\n * @returns Content rendered from the current hover query result. See {@link PibblNode}.\n *\n * @see {@link HoverDataProps}\n * @see {@link PibblNode}\n */\nexport function HoverData<T>({\n query,\n children,\n}: HoverDataProps<T>): PibblNode {\n if (typeof query !== \"function\" || typeof children !== \"function\")\n throw new TypeError(\"HoverData requires query and children functions.\");\n const snapshots = new Map<ScaleId, ResolvedContinuousScale>();\n let active = true;\n const context: HoverQueryContext = {\n scale(id) {\n if (!active)\n throw new Error(\n \"HoverData query context cannot be retained outside its invocation.\",\n );\n let snapshot = snapshots.get(id);\n if (!snapshot) {\n const value = readScale(id, \"HoverData\");\n if (!value) throw new TypeError(\"HoverData requires a scale ID.\");\n const resolved = value.get();\n if (\n resolved.type === \"band\" ||\n resolved.type === \"point\" ||\n resolved.type === \"trading-time\"\n )\n throw new TypeError(\n \"HoverData numeric queries require continuous scales.\",\n );\n snapshot = resolved;\n snapshots.set(id, snapshot);\n }\n return snapshot;\n },\n };\n let result: T | undefined;\n try {\n result = withHooksForbidden(\n \"Pibbl hooks cannot be called inside a HoverData query.\",\n () => query(context),\n );\n if (\n result != null &&\n (typeof result === \"object\" || typeof result === \"function\") &&\n typeof (result as { then?: unknown }).then === \"function\"\n )\n throw new TypeError(\n \"HoverData query must be synchronous; promises are unsupported.\",\n );\n } finally {\n active = false;\n }\n return withHooksForbidden(\n \"Pibbl hooks cannot be called inside a HoverData render callback; return a component instead.\",\n () => children(result),\n );\n}\n"],
|
|
5
|
+
"mappings": "AACA,SAAS,0BAA0B;AAGnC,SAAS,iBAAiB;AAUnB,SAAS,UAAa;AAAA,EAC3B;AAAA,EACA;AACF,GAAiC;AAC/B,MAAI,OAAO,UAAU,cAAc,OAAO,aAAa;AACrD,UAAM,IAAI,UAAU,kDAAkD;AACxE,QAAM,YAAY,oBAAI,IAAsC;AAC5D,MAAI,SAAS;AACb,QAAM,UAA6B;AAAA,IACjC,MAAM,IAAI;AACR,UAAI,CAAC;AACH,cAAM,IAAI;AAAA,UACR;AAAA,QACF;AACF,UAAI,WAAW,UAAU,IAAI,EAAE;AAC/B,UAAI,CAAC,UAAU;AACb,cAAM,QAAQ,UAAU,IAAI,WAAW;AACvC,YAAI,CAAC,MAAO,OAAM,IAAI,UAAU,gCAAgC;AAChE,cAAM,WAAW,MAAM,IAAI;AAC3B,YACE,SAAS,SAAS,UAClB,SAAS,SAAS,WAClB,SAAS,SAAS;AAElB,gBAAM,IAAI;AAAA,YACR;AAAA,UACF;AACF,mBAAW;AACX,kBAAU,IAAI,IAAI,QAAQ;AAAA,MAC5B;AACA,aAAO;AAAA,IACT;AAAA,EACF;AACA,MAAI;AACJ,MAAI;AACF,aAAS;AAAA,MACP;AAAA,MACA,MAAM,MAAM,OAAO;AAAA,IACrB;AACA,QACE,UAAU,SACT,OAAO,WAAW,YAAY,OAAO,WAAW,eACjD,OAAQ,OAA8B,SAAS;AAE/C,YAAM,IAAI;AAAA,QACR;AAAA,MACF;AAAA,EACJ,UAAE;AACA,aAAS;AAAA,EACX;AACA,SAAO;AAAA,IACL;AAAA,IACA,MAAM,SAAS,MAAM;AAAA,EACvB;AACF;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -2,21 +2,21 @@ import type { closestPoint, closestX, interpolateX, linearInterpolation } from "
|
|
|
2
2
|
import type { HoverData } from "./hover-data.js";
|
|
3
3
|
import type { PibblNode, SignalValue } from "@pibbl/core";
|
|
4
4
|
import type { PointAccessor } from "./point-types.js";
|
|
5
|
-
import type {
|
|
5
|
+
import type { ResolvedContinuousScale, ScaleId } from "./types.js";
|
|
6
6
|
/**
|
|
7
7
|
* Scale lookup context supplied when evaluating a hover query.
|
|
8
8
|
*
|
|
9
9
|
* @see {@link ScaleId}
|
|
10
|
-
* @see {@link
|
|
10
|
+
* @see {@link ResolvedContinuousScale}
|
|
11
11
|
* @see {@link HoverQuery}
|
|
12
12
|
*/
|
|
13
13
|
export interface HoverQueryContext {
|
|
14
14
|
/**
|
|
15
|
-
* Looks up a resolved
|
|
15
|
+
* Looks up a resolved continuous scale by its identifier. See {@link ResolvedContinuousScale}.
|
|
16
16
|
* @param id - Identity of the scale needed by the query. See {@link ScaleId}.
|
|
17
|
-
* @returns The resolved
|
|
17
|
+
* @returns The resolved continuous scale. See {@link ResolvedContinuousScale}.
|
|
18
18
|
*/
|
|
19
|
-
scale(id: ScaleId):
|
|
19
|
+
scale(id: ScaleId): ResolvedContinuousScale;
|
|
20
20
|
}
|
|
21
21
|
/**
|
|
22
22
|
* A query that resolves reactive hover input into a hit or no result.
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import type { Path } from "@pibbl/core";
|
|
2
|
+
import type { PibblEventHandlers, PibblEventParticipationOptions, SignalValue } from "@pibbl/core";
|
|
3
|
+
import type { SignalStyle } from "@pibbl/core/internal";
|
|
4
|
+
import type { AreaSeriesStyle } from "./area-series.js";
|
|
5
|
+
import type { LineAccessor, LineSeriesProps } from "./types.js";
|
|
6
|
+
/**
|
|
7
|
+
* Authored inputs for {@link IntervalBandSeries}.
|
|
8
|
+
*
|
|
9
|
+
* The data, horizontal coordinate, scales, and defined predicate use the same contract as
|
|
10
|
+
* {@link LineSeriesProps}. Each contiguous run of at least two observations draws its upper
|
|
11
|
+
* boundary forward and lower boundary backward.
|
|
12
|
+
*
|
|
13
|
+
* @see {@link AreaSeriesStyle}
|
|
14
|
+
* @see {@link LineSeriesProps}
|
|
15
|
+
*/
|
|
16
|
+
export interface IntervalBandSeriesProps<D> extends PibblEventHandlers, PibblEventParticipationOptions {
|
|
17
|
+
/** Application data supplied directly or through a signal. */
|
|
18
|
+
readonly data: LineSeriesProps<D>["data"];
|
|
19
|
+
/** Property key or callback extracting the horizontal coordinate. */
|
|
20
|
+
readonly x: LineAccessor<D>;
|
|
21
|
+
/** Property key or callback extracting the lower bound. */
|
|
22
|
+
readonly lower: LineAccessor<D>;
|
|
23
|
+
/** Property key or callback extracting the upper bound. */
|
|
24
|
+
readonly upper: LineAccessor<D>;
|
|
25
|
+
/** Continuous scale used to map horizontal data coordinates. */
|
|
26
|
+
readonly xScale: LineSeriesProps<D>["xScale"];
|
|
27
|
+
/** Continuous scale used to map both data bounds. */
|
|
28
|
+
readonly yScale: LineSeriesProps<D>["yScale"];
|
|
29
|
+
/** Selects records that participate in a matching-bounds run. */
|
|
30
|
+
readonly defined?: LineSeriesProps<D>["defined"];
|
|
31
|
+
/** Curve used to connect successive matching bounds. */
|
|
32
|
+
readonly curve?: LineSeriesProps<D>["curve"];
|
|
33
|
+
/** Shared band presentation. Individual datum styling is not supported. */
|
|
34
|
+
readonly style?: SignalValue<SignalStyle<AreaSeriesStyle>>;
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* Draws a filled band between matching lower and upper observations.
|
|
38
|
+
*
|
|
39
|
+
* Missing, non-finite, and excluded coordinates split runs. A lower value above its upper
|
|
40
|
+
* value rejects the datum; equal bounds produce zero-area geometry. The component owns one
|
|
41
|
+
* ordinary {@link Path} target, so event participation follows standard Path defaults.
|
|
42
|
+
*
|
|
43
|
+
* @param props - Data, coordinate accessors, continuous scales, and presentation.
|
|
44
|
+
* @returns A Pibbl path node containing all drawable interval-band runs.
|
|
45
|
+
* @throws When data, presentation, or bounds are invalid.
|
|
46
|
+
*
|
|
47
|
+
* @see {@link IntervalBandSeriesProps}
|
|
48
|
+
*/
|
|
49
|
+
export declare function IntervalBandSeries<D>({ data: dataInput, x: xInput, lower: lowerInput, upper: upperInput, xScale: xId, yScale: yId, defined, curve, style: styleInput, ...eventProps }: IntervalBandSeriesProps<D>): import("../../../jsx-runtime.js").JSX.Element;
|