@pibbl/core 0.0.2 → 0.0.3-alpha.109.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/THIRD_PARTY_NOTICES.txt +81 -0
- package/dist/features/physics/2d-testing.d.ts +1 -1
- package/dist/features/physics/2d-testing.js +2 -2
- package/dist/features/physics/2d-testing.js.map +2 -2
- package/dist/features/physics/lib/2d/canvas/components.js +25 -21
- package/dist/features/physics/lib/2d/canvas/components.js.map +2 -2
- package/dist/features/physics/lib/2d/canvas/presentation.js +1 -2
- package/dist/features/physics/lib/2d/canvas/presentation.js.map +2 -2
- package/dist/features/physics/lib/2d/collision/casts.js +4 -2
- package/dist/features/physics/lib/2d/collision/casts.js.map +2 -2
- package/dist/features/physics/lib/2d/runtime/controller.js +1 -1
- package/dist/features/physics/lib/2d/runtime/controller.js.map +2 -2
- package/dist/features/physics/lib/2d/runtime/obstacles.js +9 -11
- package/dist/features/physics/lib/2d/runtime/obstacles.js.map +2 -2
- package/dist/features/physics/lib/2d/shapes.js +8 -9
- package/dist/features/physics/lib/2d/shapes.js.map +2 -2
- package/dist/features/physics/lib/2d/world/rapier.js +22 -26
- package/dist/features/physics/lib/2d/world/rapier.js.map +2 -2
- package/dist/features/sprites/loader.js +6 -3
- package/dist/features/sprites/loader.js.map +2 -2
- 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 +17 -24
- 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 +37 -0
- package/dist/features/textures/lib/gray-scott.js.map +7 -0
- package/dist/features/textures/lib/palette.js +1 -3
- package/dist/features/textures/lib/palette.js.map +2 -2
- 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/rain-drops.js +2 -1
- package/dist/features/textures/lib/rain-drops.js.map +2 -2
- 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/textures/lib/wasm/electric.js +8 -1
- package/dist/features/textures/lib/wasm/electric.js.map +2 -2
- package/dist/features/textures/lib/water-surface.js +1 -3
- package/dist/features/textures/lib/water-surface.js.map +2 -2
- package/dist/features/viz/index.d.ts +68 -6
- package/dist/features/viz/index.js +164 -2
- 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-title.js +2 -1
- package/dist/features/viz/lib/axis-title.js.map +2 -2
- package/dist/features/viz/lib/axis.js +1 -1
- package/dist/features/viz/lib/axis.js.map +2 -2
- package/dist/features/viz/lib/bar-series.d.ts +3 -1
- package/dist/features/viz/lib/bar-series.js +16 -1
- 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/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 +142 -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/graph/bipartite.d.ts +14 -0
- package/dist/features/viz/lib/graph/bipartite.js +250 -0
- package/dist/features/viz/lib/graph/bipartite.js.map +7 -0
- package/dist/features/viz/lib/graph/chord.d.ts +44 -0
- package/dist/features/viz/lib/graph/chord.js +348 -0
- package/dist/features/viz/lib/graph/chord.js.map +7 -0
- package/dist/features/viz/lib/graph/dependency.d.ts +26 -0
- package/dist/features/viz/lib/graph/dependency.js +140 -0
- package/dist/features/viz/lib/graph/dependency.js.map +7 -0
- package/dist/features/viz/lib/graph/force.d.ts +28 -0
- package/dist/features/viz/lib/graph/force.js +580 -0
- package/dist/features/viz/lib/graph/force.js.map +7 -0
- package/dist/features/viz/lib/graph/hierarchy.d.ts +21 -0
- package/dist/features/viz/lib/graph/hierarchy.js +112 -0
- package/dist/features/viz/lib/graph/hierarchy.js.map +7 -0
- package/dist/features/viz/lib/graph/icicle.d.ts +16 -0
- package/dist/features/viz/lib/graph/icicle.js +153 -0
- package/dist/features/viz/lib/graph/icicle.js.map +7 -0
- package/dist/features/viz/lib/graph/matrix.d.ts +30 -0
- package/dist/features/viz/lib/graph/matrix.js +243 -0
- package/dist/features/viz/lib/graph/matrix.js.map +7 -0
- package/dist/features/viz/lib/graph/neighborhood.d.ts +11 -0
- package/dist/features/viz/lib/graph/neighborhood.js +281 -0
- package/dist/features/viz/lib/graph/neighborhood.js.map +7 -0
- package/dist/features/viz/lib/graph/routes.d.ts +35 -0
- package/dist/features/viz/lib/graph/routes.js +101 -0
- package/dist/features/viz/lib/graph/routes.js.map +7 -0
- package/dist/features/viz/lib/graph/sankey.d.ts +44 -0
- package/dist/features/viz/lib/graph/sankey.js +341 -0
- package/dist/features/viz/lib/graph/sankey.js.map +7 -0
- package/dist/features/viz/lib/graph/shared.d.ts +59 -0
- package/dist/features/viz/lib/graph/shared.js +301 -0
- package/dist/features/viz/lib/graph/shared.js.map +7 -0
- package/dist/features/viz/lib/graph/tree.d.ts +11 -0
- package/dist/features/viz/lib/graph/tree.js +232 -0
- package/dist/features/viz/lib/graph/tree.js.map +7 -0
- package/dist/features/viz/lib/graph/treemap.d.ts +20 -0
- package/dist/features/viz/lib/graph/treemap.js +227 -0
- package/dist/features/viz/lib/graph/treemap.js.map +7 -0
- package/dist/features/viz/lib/graph/types.d.ts +1097 -0
- package/dist/features/viz/lib/hover-card.js +8 -9
- package/dist/features/viz/lib/hover-card.js.map +2 -2
- package/dist/features/viz/lib/hover-data.d.ts +1 -1
- package/dist/features/viz/lib/hover-data.js +5 -2
- package/dist/features/viz/lib/hover-data.js.map +2 -2
- 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 +122 -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/layout-pie.js +9 -13
- package/dist/features/viz/lib/layout-pie.js.map +2 -2
- 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.js +1 -1
- package/dist/features/viz/lib/linear-scale.js.map +2 -2
- 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/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/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/pie-layout.js +2 -1
- package/dist/features/viz/lib/pie-layout.js.map +2 -2
- 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-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.js +4 -1
- package/dist/features/viz/lib/reference-band.js.map +2 -2
- package/dist/features/viz/lib/scale-context.d.ts +1 -1
- package/dist/features/viz/lib/scale-ticks.js +21 -6
- package/dist/features/viz/lib/scale-ticks.js.map +2 -2
- 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/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 +20 -4
- package/dist/features/viz/lib/use-continuous-scale.js +6 -1
- package/dist/features/viz/lib/use-continuous-scale.js.map +2 -2
- package/dist/features/viz/lib/utc-scale.js +11 -10
- package/dist/features/viz/lib/utc-scale.js.map +2 -2
- 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/backdrop-contrast-gpu.d.ts +5 -0
- package/dist/filters/backdrop-contrast-gpu.js +33 -0
- package/dist/filters/backdrop-contrast-gpu.js.map +7 -0
- package/dist/filters/backdrop-contrast.d.ts +21 -0
- package/dist/filters/backdrop-contrast.js +61 -0
- package/dist/filters/backdrop-contrast.js.map +7 -0
- package/dist/filters/displacement.js +1 -1
- package/dist/filters/displacement.js.map +2 -2
- 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 +104 -0
- package/dist/filters/emboss.js.map +7 -0
- package/dist/filters/filter-executor.d.ts +11 -4
- package/dist/filters/filter-executor.js +104 -49
- package/dist/filters/filter-executor.js.map +2 -2
- package/dist/filters/reflected-light.js +1 -1
- package/dist/filters/reflected-light.js.map +2 -2
- 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-backdrop-contrast-boundary.d.ts +31 -0
- package/dist/filters/render-backdrop-contrast-boundary.js +116 -0
- package/dist/filters/render-backdrop-contrast-boundary.js.map +7 -0
- 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 +9 -5
- package/dist/filters.js +4 -0
- package/dist/filters.js.map +2 -2
- package/dist/index.d.ts +9 -5
- package/dist/index.js +18 -2
- package/dist/index.js.map +2 -2
- package/dist/internal.d.ts +4 -0
- package/dist/internal.js +6 -0
- package/dist/internal.js.map +2 -2
- package/dist/layout-kernel.d.ts +12 -0
- package/dist/layout-kernel.js +11 -0
- package/dist/layout-kernel.js.map +7 -0
- package/dist/layout-kernel.mjs +1 -0
- package/dist/lib/backend/types.d.ts +13 -1
- package/dist/lib/backend/types.js.map +2 -2
- package/dist/lib/components/arc-geometry.js +2 -1
- package/dist/lib/components/arc-geometry.js.map +2 -2
- package/dist/lib/components/g.js +2 -0
- package/dist/lib/components/g.js.map +2 -2
- package/dist/lib/components/html-box.js +2 -1
- package/dist/lib/components/html-box.js.map +2 -2
- package/dist/lib/components/img.js +3 -3
- package/dist/lib/components/img.js.map +2 -2
- package/dist/lib/components/layer.js +98 -16
- package/dist/lib/components/layer.js.map +3 -3
- package/dist/lib/components/text.d.ts +16 -0
- package/dist/lib/components/text.js +131 -24
- package/dist/lib/components/text.js.map +2 -2
- package/dist/lib/define-primitive.d.ts +4 -2
- package/dist/lib/define-primitive.js +3 -1
- package/dist/lib/define-primitive.js.map +2 -2
- package/dist/lib/element/metadata.d.ts +9 -0
- package/dist/lib/element/metadata.js +19 -0
- package/dist/lib/element/metadata.js.map +2 -2
- package/dist/lib/element/resolve-primitive-inputs.d.ts +2 -0
- package/dist/lib/element/resolve-primitive-inputs.js +17 -4
- package/dist/lib/element/resolve-primitive-inputs.js.map +2 -2
- package/dist/lib/events/event-facade.d.ts +18 -0
- package/dist/lib/events/event-facade.js +28 -2
- package/dist/lib/events/event-facade.js.map +2 -2
- package/dist/lib/events/hit-test.js +2 -1
- package/dist/lib/events/hit-test.js.map +2 -2
- package/dist/lib/events/propagation.d.ts +2 -1
- package/dist/lib/events/propagation.js +22 -16
- package/dist/lib/events/propagation.js.map +2 -2
- package/dist/lib/events/registrations.d.ts +10 -0
- package/dist/lib/events/registrations.js +160 -5
- package/dist/lib/events/registrations.js.map +2 -2
- package/dist/lib/execute-render.js +25 -1
- package/dist/lib/execute-render.js.map +2 -2
- package/dist/lib/filter/filter-region.js +3 -10
- package/dist/lib/filter/filter-region.js.map +2 -2
- package/dist/lib/focus/focus-manager.d.ts +8 -1
- package/dist/lib/focus/focus-manager.js +87 -43
- package/dist/lib/focus/focus-manager.js.map +2 -2
- package/dist/lib/focus/geometry.d.ts +2 -0
- package/dist/lib/focus/geometry.js +6 -0
- package/dist/lib/focus/geometry.js.map +2 -2
- package/dist/lib/geometry/path-bend-guide.js +1 -1
- package/dist/lib/geometry/path-bend-guide.js.map +2 -2
- package/dist/lib/geometry/path-geometry.js +12 -11
- package/dist/lib/geometry/path-geometry.js.map +2 -2
- package/dist/lib/geometry/path-transforms.js +17 -21
- package/dist/lib/geometry/path-transforms.js.map +2 -2
- package/dist/lib/geometry/path-warp-bezier.js +3 -1
- package/dist/lib/geometry/path-warp-bezier.js.map +2 -2
- package/dist/lib/geometry/path-warp.js +1 -1
- package/dist/lib/geometry/path-warp.js.map +2 -2
- package/dist/lib/global-state.js +2 -0
- package/dist/lib/global-state.js.map +2 -2
- package/dist/lib/html/html-events.d.ts +32 -0
- package/dist/lib/html/html-events.js +179 -0
- package/dist/lib/html/html-events.js.map +7 -0
- package/dist/lib/html/html-service.d.ts +8 -2
- package/dist/lib/html/html-service.js +198 -65
- package/dist/lib/html/html-service.js.map +2 -2
- package/dist/lib/html/overlay-config.js +7 -6
- package/dist/lib/html/overlay-config.js.map +2 -2
- package/dist/lib/html/types.d.ts +29 -2
- package/dist/lib/layout/absolute.d.ts +11 -5
- package/dist/lib/layout/absolute.js +329 -55
- package/dist/lib/layout/absolute.js.map +3 -3
- package/dist/lib/layout/allocation-checkpoint-owner.d.ts +11 -0
- package/dist/lib/layout/allocation-checkpoint-owner.js +86 -0
- package/dist/lib/layout/allocation-checkpoint-owner.js.map +7 -0
- package/dist/lib/layout/allocation-checkpoint.d.ts +53 -0
- package/dist/lib/layout/allocation-checkpoint.js +463 -0
- package/dist/lib/layout/allocation-checkpoint.js.map +7 -0
- package/dist/lib/layout/allocation-dependencies.d.ts +30 -0
- package/dist/lib/layout/allocation-dependencies.js +90 -0
- package/dist/lib/layout/allocation-dependencies.js.map +7 -0
- package/dist/lib/layout/allocation-revision.d.ts +13 -0
- package/dist/lib/layout/allocation-revision.js +67 -0
- package/dist/lib/layout/allocation-revision.js.map +7 -0
- package/dist/lib/layout/box-insets.d.ts +17 -0
- package/dist/lib/layout/box-insets.js +138 -0
- package/dist/lib/layout/box-insets.js.map +7 -0
- package/dist/lib/layout/box-sizing.d.ts +16 -0
- package/dist/lib/layout/box-sizing.js +77 -0
- package/dist/lib/layout/box-sizing.js.map +7 -0
- package/dist/lib/layout/box.js +42 -12
- package/dist/lib/layout/box.js.map +2 -2
- package/dist/lib/layout/canvas-measurement.d.ts +13 -0
- package/dist/lib/layout/canvas-measurement.js +57 -0
- package/dist/lib/layout/canvas-measurement.js.map +7 -0
- package/dist/lib/layout/context.d.ts +35 -6
- package/dist/lib/layout/context.js +72 -3
- package/dist/lib/layout/context.js.map +2 -2
- package/dist/lib/layout/define-layout-component.d.ts +23 -0
- package/dist/lib/layout/define-layout-component.js +84 -0
- package/dist/lib/layout/define-layout-component.js.map +7 -0
- package/dist/lib/layout/flex-allocation-cache.d.ts +42 -0
- package/dist/lib/layout/flex-baseline-mode.d.ts +2 -0
- package/dist/lib/layout/flex-baseline-mode.js +7 -0
- package/dist/lib/layout/flex-baseline-mode.js.map +7 -0
- package/dist/lib/layout/flex.d.ts +50 -15
- package/dist/lib/layout/flex.js +2124 -195
- package/dist/lib/layout/flex.js.map +3 -3
- package/dist/lib/layout/flow.js +225 -49
- package/dist/lib/layout/flow.js.map +2 -2
- package/dist/lib/layout/geometry-publication.d.ts +53 -0
- package/dist/lib/layout/geometry-publication.js +244 -0
- package/dist/lib/layout/geometry-publication.js.map +7 -0
- package/dist/lib/layout/grid-kernel.d.ts +63 -0
- package/dist/lib/layout/grid-kernel.js +168 -0
- package/dist/lib/layout/grid-kernel.js.map +7 -0
- package/dist/lib/layout/grid.d.ts +63 -4
- package/dist/lib/layout/grid.js +767 -171
- package/dist/lib/layout/grid.js.map +3 -3
- package/dist/lib/layout/measure.d.ts +55 -3
- package/dist/lib/layout/measure.js +448 -15
- package/dist/lib/layout/measure.js.map +2 -2
- package/dist/lib/layout/overlay.js +81 -23
- package/dist/lib/layout/overlay.js.map +2 -2
- package/dist/lib/layout/participation.d.ts +27 -0
- package/dist/lib/layout/participation.js +188 -0
- package/dist/lib/layout/participation.js.map +7 -0
- package/dist/lib/layout/place-child.js +1 -1
- package/dist/lib/layout/place-child.js.map +2 -2
- package/dist/lib/layout/positioning-diagnostics.d.ts +1 -1
- package/dist/lib/layout/positioning-diagnostics.js +13 -2
- package/dist/lib/layout/positioning-diagnostics.js.map +2 -2
- package/dist/lib/layout/prepared-root.d.ts +121 -0
- package/dist/lib/layout/prepared-root.js +360 -0
- package/dist/lib/layout/prepared-root.js.map +7 -0
- package/dist/lib/layout/standalone-kernel.d.ts +60 -0
- package/dist/lib/layout/standalone-kernel.js +722 -0
- package/dist/lib/layout/standalone-kernel.js.map +7 -0
- package/dist/lib/layout/topology.d.ts +21 -0
- package/dist/lib/layout/topology.js +113 -0
- package/dist/lib/layout/topology.js.map +7 -0
- package/dist/lib/layout/types.d.ts +5 -0
- package/dist/lib/layout/wasm/artifact.d.ts +1 -0
- package/dist/lib/layout/wasm/artifact.js +5 -0
- package/dist/lib/layout/wasm/artifact.js.map +7 -0
- package/dist/lib/layout/wasm/bytes.d.ts +1 -0
- package/dist/lib/layout/wasm/bytes.js +5 -0
- package/dist/lib/layout/wasm/bytes.js.map +7 -0
- package/dist/lib/layout/wasm/embedded.d.ts +2 -0
- package/dist/lib/layout/wasm/embedded.js +12 -0
- package/dist/lib/layout/wasm/embedded.js.map +7 -0
- package/dist/lib/layout/wasm/layout.wasm +0 -0
- package/dist/lib/layout/wasm/module.d.ts +8 -0
- package/dist/lib/layout/wasm/module.js +70 -0
- package/dist/lib/layout/wasm/module.js.map +7 -0
- package/dist/lib/layout/wasm/region.d.ts +267 -0
- package/dist/lib/layout/wasm/region.js +1018 -0
- package/dist/lib/layout/wasm/region.js.map +7 -0
- package/dist/lib/manipulation/controller.js +4 -7
- package/dist/lib/manipulation/controller.js.map +2 -2
- package/dist/lib/manipulation/frame.js +1 -1
- package/dist/lib/manipulation/frame.js.map +2 -2
- package/dist/lib/manipulation/handles.js +32 -33
- package/dist/lib/manipulation/handles.js.map +2 -2
- package/dist/lib/manipulation/solve.js +12 -10
- package/dist/lib/manipulation/solve.js.map +2 -2
- package/dist/lib/mount-pibbl.js +1 -0
- package/dist/lib/mount-pibbl.js.map +2 -2
- package/dist/lib/mount-prepared-pibbl.d.ts +5 -0
- package/dist/lib/mount-prepared-pibbl.js +29 -0
- package/dist/lib/mount-prepared-pibbl.js.map +7 -0
- package/dist/lib/mount-request.d.ts +8 -0
- package/dist/lib/mount-request.js +41 -0
- package/dist/lib/mount-request.js.map +7 -0
- package/dist/lib/pibbl.d.ts +21 -13
- package/dist/lib/pibbl.js +18 -16
- package/dist/lib/pibbl.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-layer/controller.d.ts +9 -3
- package/dist/lib/render-layer/controller.js +259 -110
- package/dist/lib/render-layer/controller.js.map +2 -2
- package/dist/lib/render-transaction.d.ts +12 -2
- package/dist/lib/render-transaction.js +69 -1
- package/dist/lib/render-transaction.js.map +2 -2
- package/dist/lib/render.js +32 -8
- package/dist/lib/render.js.map +2 -2
- package/dist/lib/scheduler/realm-scheduler.d.ts +2 -0
- package/dist/lib/scheduler/realm-scheduler.js +55 -26
- package/dist/lib/scheduler/realm-scheduler.js.map +2 -2
- package/dist/lib/scheduler/renderer-participant.js +1 -0
- package/dist/lib/scheduler/renderer-participant.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/signals/edge.d.ts +7 -4
- package/dist/lib/signals/edge.js +25 -3
- package/dist/lib/signals/edge.js.map +2 -2
- package/dist/lib/signals/graph.d.ts +16 -2
- package/dist/lib/signals/graph.js +54 -12
- package/dist/lib/signals/graph.js.map +2 -2
- package/dist/lib/signals/input-provision.d.ts +15 -0
- package/dist/lib/signals/input-provision.js +53 -3
- package/dist/lib/signals/input-provision.js.map +2 -2
- package/dist/lib/signals/render-consumer.d.ts +3 -0
- package/dist/lib/signals/render-consumer.js +22 -14
- package/dist/lib/signals/render-consumer.js.map +2 -2
- package/dist/lib/style/positioning.d.ts +50 -2
- package/dist/lib/style/positioning.js +28 -4
- package/dist/lib/style/positioning.js.map +2 -2
- package/dist/lib/style/resolve-built-in.d.ts +4 -3
- package/dist/lib/style/resolve-built-in.js +17 -3
- package/dist/lib/style/resolve-built-in.js.map +2 -2
- package/dist/lib/style/resolve-dispatch.d.ts +3 -0
- package/dist/lib/style/resolve-dispatch.js +77 -4
- package/dist/lib/style/resolve-dispatch.js.map +2 -2
- package/dist/lib/style/resolve-length.d.ts +2 -0
- package/dist/lib/style/resolve-length.js +13 -9
- package/dist/lib/style/resolve-length.js.map +2 -2
- package/dist/lib/style/sizing-length.d.ts +51 -0
- package/dist/lib/style/sizing-length.js +77 -0
- package/dist/lib/style/sizing-length.js.map +7 -0
- package/dist/lib/style/types.d.ts +63 -25
- package/dist/lib/surface/root-surface.js +10 -6
- package/dist/lib/surface/root-surface.js.map +2 -2
- package/dist/lib/textures/texture.js +10 -8
- package/dist/lib/textures/texture.js.map +2 -2
- package/dist/lib/transitions/capture.js +4 -1
- package/dist/lib/transitions/capture.js.map +2 -2
- package/dist/lib/transitions/embers-physics.js +17 -10
- package/dist/lib/transitions/embers-physics.js.map +2 -2
- package/dist/lib/types.d.ts +110 -1
- package/dist/sync.d.ts +16 -0
- package/dist/sync.js +13 -0
- package/dist/sync.js.map +7 -0
- package/dist/sync.mjs +1 -0
- package/package.json +26 -3
package/THIRD_PARTY_NOTICES.txt
CHANGED
|
@@ -203,3 +203,84 @@ License: Apache-2.0
|
|
|
203
203
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
204
204
|
See the License for the specific language governing permissions and
|
|
205
205
|
limitations under the License.
|
|
206
|
+
|
|
207
|
+
|
|
208
|
+
Recording/GIF WASM dependency: gif-0.14.1
|
|
209
|
+
Source: https://github.com/image-rs/image-gif
|
|
210
|
+
License: MIT
|
|
211
|
+
|
|
212
|
+
The MIT License (MIT)
|
|
213
|
+
|
|
214
|
+
Copyright (c) 2015 nwin
|
|
215
|
+
|
|
216
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
217
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
218
|
+
in the Software without restriction, including without limitation the rights
|
|
219
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
220
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
221
|
+
furnished to do so, subject to the following conditions:
|
|
222
|
+
|
|
223
|
+
The above copyright notice and this permission notice shall be included in all
|
|
224
|
+
copies or substantial portions of the Software.
|
|
225
|
+
|
|
226
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
227
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
228
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
229
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
230
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
231
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
232
|
+
SOFTWARE.
|
|
233
|
+
|
|
234
|
+
|
|
235
|
+
Recording/GIF WASM dependency: color_quant-1.1.0
|
|
236
|
+
Source: https://github.com/image-rs/color_quant
|
|
237
|
+
License: MIT
|
|
238
|
+
|
|
239
|
+
The MIT License (MIT)
|
|
240
|
+
|
|
241
|
+
Copyright (c) 2016 PistonDevelopers
|
|
242
|
+
|
|
243
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
244
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
245
|
+
in the Software without restriction, including without limitation the rights
|
|
246
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
247
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
248
|
+
furnished to do so, subject to the following conditions:
|
|
249
|
+
|
|
250
|
+
The above copyright notice and this permission notice shall be included in all
|
|
251
|
+
copies or substantial portions of the Software.
|
|
252
|
+
|
|
253
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
254
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
255
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
256
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
257
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
258
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
259
|
+
SOFTWARE.
|
|
260
|
+
|
|
261
|
+
|
|
262
|
+
Recording/GIF WASM dependency: weezl-0.1.12
|
|
263
|
+
Source: https://github.com/image-rs/weezl
|
|
264
|
+
License: MIT
|
|
265
|
+
|
|
266
|
+
The MIT License (MIT)
|
|
267
|
+
|
|
268
|
+
Copyright (c) HeroicKatora 2020
|
|
269
|
+
|
|
270
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
271
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
272
|
+
in the Software without restriction, including without limitation the rights
|
|
273
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
274
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
275
|
+
furnished to do so, subject to the following conditions:
|
|
276
|
+
|
|
277
|
+
The above copyright notice and this permission notice shall be included in all
|
|
278
|
+
copies or substantial portions of the Software.
|
|
279
|
+
|
|
280
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
281
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
282
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
283
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
284
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
285
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
286
|
+
SOFTWARE.
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
* host frames; a physics world may run zero, one, or several fixed ticks in a
|
|
6
6
|
* host frame according to its public fixed-step configuration.
|
|
7
7
|
*/
|
|
8
|
-
import {
|
|
8
|
+
import type { PibblNode } from "@pibbl/core";
|
|
9
9
|
/**
|
|
10
10
|
* Caller-owned canvas, root factory, and observation callback for deterministic physics testing.
|
|
11
11
|
*
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { pibblSync } from "../../sync.js";
|
|
2
2
|
import {
|
|
3
3
|
PibblInternalManualSchedulerDriver,
|
|
4
4
|
pibblInternalInstallTestSchedulerDriver,
|
|
@@ -119,7 +119,7 @@ function createPhysicsTestHarness2D(options) {
|
|
|
119
119
|
}
|
|
120
120
|
}
|
|
121
121
|
function mountRoot(options) {
|
|
122
|
-
return
|
|
122
|
+
return pibblSync(options.canvas, options.root());
|
|
123
123
|
}
|
|
124
124
|
function requireFrameCount(count) {
|
|
125
125
|
if (!Number.isSafeInteger(count) || count < 0) {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/features/physics/2d-testing.ts"],
|
|
4
|
-
"sourcesContent": ["/**\n * Deterministic test support for public 2D physics compositions.\n *\n * The harness drives Pibbl's existing realm scheduler. `advanceFrames()` advances\n * host frames; a physics world may run zero, one, or several fixed ticks in a\n * host frame according to its public fixed-step configuration.\n */\nimport {
|
|
5
|
-
"mappings": "
|
|
4
|
+
"sourcesContent": ["/**\n * Deterministic test support for public 2D physics compositions.\n *\n * The harness drives Pibbl's existing realm scheduler. `advanceFrames()` advances\n * host frames; a physics world may run zero, one, or several fixed ticks in a\n * host frame according to its public fixed-step configuration.\n */\nimport type { PibblController, PibblNode } from \"@pibbl/core\";\nimport { pibblSync } from \"../../sync.js\";\nimport {\n PibblInternalManualSchedulerDriver,\n pibblInternalInstallTestSchedulerDriver,\n pibblInternalSnapshotRealmScheduler,\n} from \"@pibbl/core/internal\";\n\n/**\n * Caller-owned canvas, root factory, and observation callback for deterministic physics testing.\n *\n * @see {@link PibblNode}\n * @see {@link createPhysicsTestHarness2D}\n */\nexport interface PibblPhysicsTestHarness2DOptions<Observation> {\n /** The caller owns this canvas; disposing the harness never removes it. */\n readonly canvas: HTMLCanvasElement;\n /**\n * Creates a new public Pibbl root for the initial mount and each reset.\n * @returns The Pibbl root tree mounted by the test harness. See {@link PibblNode}.\n */\n readonly root: () => PibblNode;\n /**\n * Reads application state after a frame or action.\n * @returns The semantic state to expose through the harness's observe method.\n */\n readonly observe: () => Observation;\n}\n\n/**\n * A disposable test mount with explicit host-frame advancement and public-state observations.\n *\n * @see {@link createPhysicsTestHarness2D}\n */\nexport interface PibblPhysicsTestHarness2D<Observation> {\n /** Number of host callbacks currently requested by Pibbl (zero or one). */\n readonly pendingFrames: number;\n /**\n * Delivers one already-requested host frame at the current host time.\n * @returns Whether a pending frame was flushed.\n */\n flush(): boolean;\n /**\n * Advances up to `count` requested host frames by `milliseconds` each.\n * This advances the host clock, not a guaranteed count of physics fixed ticks.\n * @param count - Number of frames to advance.\n * @param milliseconds - Duration of each frame in milliseconds.\n * @returns The number of frames advanced.\n */\n advanceFrames(count: number, milliseconds?: number): number;\n /**\n * Runs an application action and delivers one resulting frame at the current time.\n * @param callback - Action to run within the harness's deterministic scheduling context.\n * @returns The action's return value.\n */\n act<Result>(callback: () => Result): Result;\n /**\n * Reads the caller-provided public observation without scheduling work.\n * @returns The current observation from the configured observer.\n */\n observe(): Observation;\n /** Disposes the mounted root and mounts a new one without moving host time backward. */\n reset(): void;\n /** Disposes the root and restores the previous realm scheduler driver. */\n dispose(): void;\n}\n\nconst DEFAULT_FRAME_MILLISECONDS = 1000 / 60;\n\n/**\n * Creates an isolated manual-clock test mount for one Pibbl 2D physics composition.\n *\n * It refuses a realm with an existing root because a Pibbl realm deliberately has\n * one scheduler. Use ordinary browser tests when a test needs multiple roots.\n *\n * @param options - Caller-owned canvas, root factory, and semantic state observer. See\n * {@link PibblPhysicsTestHarness2DOptions} .\n * @returns A harness owning the test mount and scheduler lifetime; dispose it after use. See\n * {@link PibblPhysicsTestHarness2D} .\n *\n * @see {@link PibblPhysicsTestHarness2DOptions}\n * @see {@link PibblPhysicsTestHarness2D}\n */\nexport function createPhysicsTestHarness2D<Observation>(\n options: PibblPhysicsTestHarness2DOptions<Observation>,\n): PibblPhysicsTestHarness2D<Observation> {\n const before = pibblInternalSnapshotRealmScheduler();\n if (before.registeredRoots !== 0) {\n throw new Error(\n \"createPhysicsTestHarness2D() requires an isolated Pibbl realm; dispose existing Pibbl roots before creating the harness.\",\n );\n }\n if (before.phase !== \"idle\" || before.pendingHostFrames !== 0) {\n throw new Error(\n \"createPhysicsTestHarness2D() cannot replace the Pibbl clock while realm work is active.\",\n );\n }\n\n const driver = new PibblInternalManualSchedulerDriver();\n let restoreDriver: (() => void) | undefined;\n let controller: PibblController | undefined;\n let disposed = false;\n let hostTime = 0;\n\n try {\n restoreDriver = pibblInternalInstallTestSchedulerDriver(driver);\n controller = mountRoot(options);\n } catch (error) {\n try {\n controller?.dispose();\n } finally {\n controller = undefined;\n restoreSchedulerDriver();\n }\n throw error;\n }\n\n const requireLive = (): void => {\n if (disposed) {\n throw new Error(\"This Pibbl physics 2D test harness has been disposed.\");\n }\n };\n const flush = (): boolean => {\n requireLive();\n if (driver.pendingHostFrames === 0) return false;\n driver.flush(hostTime);\n return true;\n };\n\n return Object.freeze({\n get pendingFrames(): number {\n return driver.pendingHostFrames;\n },\n flush,\n advanceFrames(\n count: number,\n milliseconds = DEFAULT_FRAME_MILLISECONDS,\n ): number {\n requireLive();\n requireFrameCount(count);\n requireMilliseconds(milliseconds);\n let advanced = 0;\n for (let index = 0; index < count; index++) {\n if (driver.pendingHostFrames === 0) break;\n const nextHostTime = hostTime + milliseconds;\n if (!Number.isFinite(nextHostTime)) {\n throw new RangeError(\n \"advanceFrames() cannot advance the host clock beyond a finite time.\",\n );\n }\n hostTime = nextHostTime;\n driver.flush(hostTime);\n advanced++;\n }\n return advanced;\n },\n act<Result>(callback: () => Result): Result {\n requireLive();\n const result = callback();\n flush();\n return result;\n },\n observe(): Observation {\n requireLive();\n return options.observe();\n },\n reset(): void {\n requireLive();\n const previousController = controller;\n controller = undefined;\n try {\n previousController?.dispose();\n controller = mountRoot(options);\n } catch (error) {\n disposed = true;\n try {\n restoreSchedulerDriver();\n } catch (restoreError) {\n throw new AggregateError(\n [error, restoreError],\n \"Pibbl physics 2D test harness reset failed and could not restore the scheduler driver.\",\n { cause: restoreError },\n );\n }\n throw error;\n }\n },\n dispose(): void {\n if (disposed) return;\n disposed = true;\n const currentController = controller;\n controller = undefined;\n try {\n currentController?.dispose();\n } finally {\n restoreSchedulerDriver();\n }\n },\n });\n\n function restoreSchedulerDriver(): void {\n const restore = restoreDriver;\n restoreDriver = undefined;\n restore?.();\n }\n}\n\nfunction mountRoot<Observation>(\n options: PibblPhysicsTestHarness2DOptions<Observation>,\n): PibblController {\n return pibblSync(options.canvas, options.root());\n}\n\nfunction requireFrameCount(count: number): void {\n if (!Number.isSafeInteger(count) || count < 0) {\n throw new RangeError(\n \"advanceFrames(count) requires a non-negative safe integer.\",\n );\n }\n}\n\nfunction requireMilliseconds(milliseconds: number): void {\n if (!Number.isFinite(milliseconds) || milliseconds < 0) {\n throw new RangeError(\n \"advanceFrames(milliseconds) requires a finite non-negative number.\",\n );\n }\n}\n"],
|
|
5
|
+
"mappings": "AAQA,SAAS,iBAAiB;AAC1B;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,OACK;AA6DP,MAAM,6BAA6B,MAAO;AAgBnC,SAAS,2BACd,SACwC;AACxC,QAAM,SAAS,oCAAoC;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YAAM;AACN,aAAO;AAAA,IACT;AAAA,IACA,UAAuB;AACrB,kBAAY;AACZ,aAAO,QAAQ,QAAQ;AAAA,IACzB;AAAA,IACA,QAAc;AACZ,kBAAY;AACZ,YAAM,qBAAqB;AAC3B,mBAAa;AACb,UAAI;AACF,4BAAoB,QAAQ;AAC5B,qBAAa,UAAU,OAAO;AAAA,MAChC,SAAS,OAAO;AACd,mBAAW;AACX,YAAI;AACF,iCAAuB;AAAA,QACzB,SAAS,cAAc;AACrB,gBAAM,IAAI;AAAA,YACR,CAAC,OAAO,YAAY;AAAA,YACpB;AAAA,YACA,EAAE,OAAO,aAAa;AAAA,UACxB;AAAA,QACF;AACA,cAAM;AAAA,MACR;AAAA,IACF;AAAA,IACA,UAAgB;AACd,UAAI,SAAU;AACd,iBAAW;AACX,YAAM,oBAAoB;AAC1B,mBAAa;AACb,UAAI;AACF,2BAAmB,QAAQ;AAAA,MAC7B,UAAE;AACA,+BAAuB;AAAA,MACzB;AAAA,IACF;AAAA,EACF,CAAC;AAED,WAAS,yBAA+B;AACtC,UAAM,UAAU;AAChB,oBAAgB;AAChB,cAAU;AAAA,EACZ;AACF;AAEA,SAAS,UACP,SACiB;AACjB,SAAO,UAAU,QAAQ,QAAQ,QAAQ,KAAK,CAAC;AACjD;AAEA,SAAS,kBAAkB,OAAqB;AAC9C,MAAI,CAAC,OAAO,cAAc,KAAK,KAAK,QAAQ,GAAG;AAC7C,UAAM,IAAI;AAAA,MACR;AAAA,IACF;AAAA,EACF;AACF;AAEA,SAAS,oBAAoB,cAA4B;AACvD,MAAI,CAAC,OAAO,SAAS,YAAY,KAAK,eAAe,GAAG;AACtD,UAAM,IAAI;AAAA,MACR;AAAA,IACF;AAAA,EACF;AACF;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -6,6 +6,27 @@ import {
|
|
|
6
6
|
import { boundsOfShape2D, capsuleShape2D, chainShape2D, segmentShape2D } from "../shapes.js";
|
|
7
7
|
import { requireShapeRecord2D } from "../shape-records.js";
|
|
8
8
|
import { installCustomShapeResolver2D } from "./inference.js";
|
|
9
|
+
const layoutPropertyKeys = [
|
|
10
|
+
"width",
|
|
11
|
+
"height",
|
|
12
|
+
"minWidth",
|
|
13
|
+
"maxWidth",
|
|
14
|
+
"minHeight",
|
|
15
|
+
"maxHeight",
|
|
16
|
+
"padding",
|
|
17
|
+
"overflow",
|
|
18
|
+
"left",
|
|
19
|
+
"top",
|
|
20
|
+
"alignSelf",
|
|
21
|
+
"justifySelf",
|
|
22
|
+
"flexBasis",
|
|
23
|
+
"flexGrow",
|
|
24
|
+
"flexShrink",
|
|
25
|
+
"gridColumnStart",
|
|
26
|
+
"gridColumnSpan",
|
|
27
|
+
"gridRowStart",
|
|
28
|
+
"gridRowSpan"
|
|
29
|
+
];
|
|
9
30
|
function renderPhysicsShape2D(props, style, context) {
|
|
10
31
|
renderShape(props, style, style.shape, context);
|
|
11
32
|
}
|
|
@@ -154,27 +175,10 @@ function appendCapsule(path, start, end, radius) {
|
|
|
154
175
|
}
|
|
155
176
|
function stripLayout(style) {
|
|
156
177
|
const result = { ...style };
|
|
157
|
-
for (
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
"maxWidth",
|
|
162
|
-
"minHeight",
|
|
163
|
-
"maxHeight",
|
|
164
|
-
"padding",
|
|
165
|
-
"overflow",
|
|
166
|
-
"left",
|
|
167
|
-
"top",
|
|
168
|
-
"alignSelf",
|
|
169
|
-
"justifySelf",
|
|
170
|
-
"flexBasis",
|
|
171
|
-
"flexGrow",
|
|
172
|
-
"flexShrink",
|
|
173
|
-
"gridColumnStart",
|
|
174
|
-
"gridColumnSpan",
|
|
175
|
-
"gridRowStart",
|
|
176
|
-
"gridRowSpan"
|
|
177
|
-
]) delete result[key];
|
|
178
|
+
for (let keyIndex = 0; keyIndex < layoutPropertyKeys.length; keyIndex++) {
|
|
179
|
+
const key = layoutPropertyKeys[keyIndex];
|
|
180
|
+
delete result[key];
|
|
181
|
+
}
|
|
178
182
|
return result;
|
|
179
183
|
}
|
|
180
184
|
function copyPoints(value, path) {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../../../src/features/physics/lib/2d/canvas/components.ts"],
|
|
4
|
-
"sourcesContent": ["import { resolveTexturePaint } from '@pibbl/core/internal';\nimport type { FillStyle, StrokeStyle } from '@pibbl/core';\nimport {\n useEventTarget,\n definePrimitive,\n type RenderingContext2D,\n} from '@pibbl/core';\nimport type {\n Capsule2DProps,\n Capsule2DStyle,\n Chain2DProps,\n Chain2DStyle,\n PhysicsShape2DProps,\n PhysicsShape2DStyle,\n Segment2DProps,\n Segment2DStyle,\n} from '../types.js';\nimport type { PibblPhysicsShape2D, PibblPhysicsVector2 } from '../../../2d-geometry.js';\nimport { boundsOfShape2D, capsuleShape2D, chainShape2D, segmentShape2D } from '../shapes.js';\nimport { requireShapeRecord2D, type ConvexLeaf2D } from '../shape-records.js';\nimport { installCustomShapeResolver2D } from './inference.js';\n\ntype ResolvedPhysicsShapeStyle2D = Readonly<PhysicsShape2DStyle>;\ntype ResolvedCapsuleStyle2D = Omit<Readonly<Capsule2DStyle>, 'start' | 'end'> & {\n readonly start: PibblPhysicsVector2;\n readonly end: PibblPhysicsVector2;\n};\ntype ResolvedSegmentStyle2D = Omit<Readonly<Segment2DStyle>, 'start' | 'end'> & {\n readonly start: PibblPhysicsVector2;\n readonly end: PibblPhysicsVector2;\n};\ntype ResolvedChainStyle2D = Omit<Readonly<Chain2DStyle>, 'points'> & {\n readonly points: readonly PibblPhysicsVector2[];\n};\n\nfunction renderPhysicsShape2D(\n props: PhysicsShape2DProps,\n style: ResolvedPhysicsShapeStyle2D,\n context: RenderingContext2D,\n): void {\n renderShape(props, style, style.shape, context);\n}\n\nfunction renderCapsule2D(\n props: Capsule2DProps,\n style: Readonly<ResolvedCapsuleStyle2D>,\n context: RenderingContext2D,\n): void {\n renderShape(props, style, capsuleShape2D(style), context);\n}\n\nfunction renderSegment2D(\n props: Segment2DProps,\n style: Readonly<ResolvedSegmentStyle2D>,\n context: RenderingContext2D,\n): void {\n renderShape(props, style, segmentShape2D(style), context);\n}\n\nfunction renderChain2D(\n props: Chain2DProps,\n style: Readonly<ResolvedChainStyle2D>,\n context: RenderingContext2D,\n): void {\n renderShape(props, style, chainShape2D(style), context);\n}\n\n/**\n * Draws an immutable physics shape as a Canvas primitive with optional body or collider\n * attachment.\n *\n * @param props - Authored component inputs, supplied through JSX or createElement. See the linked\n * props and style types.\n * @throws When called directly; Pibbl mounts this component through JSX or createElement.\n *\n * @see {@link PhysicsShape2DProps}\n * @see {@link PhysicsShape2DStyle}\n */\nexport const PhysicsShape2D = definePrimitive<\n PhysicsShape2DProps,\n PhysicsShape2DStyle,\n PhysicsShape2DStyle,\n PhysicsShape2DStyle\n>(renderPhysicsShape2D, { resolveStyle: resolvePhysicsShapeStyle });\n\n/**\n * Draws a capsule between two endpoints with optional physics attachment.\n *\n * @param props - Authored component inputs, supplied through JSX or createElement. See the linked\n * props and style types.\n * @throws When called directly; Pibbl mounts this component through JSX or createElement.\n *\n * @see {@link Capsule2DProps}\n * @see {@link Capsule2DStyle}\n */\nexport const Capsule2D = definePrimitive<\n Capsule2DProps,\n Capsule2DStyle,\n Capsule2DStyle,\n ResolvedCapsuleStyle2D\n>(renderCapsule2D, { resolveStyle: style => ({\n ...stripLayout(style),\n start: copyPoint(style.start, 'Capsule2D.start'),\n end: copyPoint(style.end, 'Capsule2D.end'),\n radius: positive(style.radius, 'Capsule2D.radius'),\n}) });\n\n/**\n * Draws a line segment with optional physics attachment.\n *\n * @param props - Authored component inputs, supplied through JSX or createElement. See the linked\n * props and style types.\n * @throws When called directly; Pibbl mounts this component through JSX or createElement.\n *\n * @see {@link Segment2DProps}\n * @see {@link Segment2DStyle}\n */\nexport const Segment2D = definePrimitive<\n Segment2DProps,\n Segment2DStyle,\n Segment2DStyle,\n ResolvedSegmentStyle2D\n>(renderSegment2D, { resolveStyle: style => ({\n ...stripLayout(style),\n start: copyPoint(style.start, 'Segment2D.start'),\n end: copyPoint(style.end, 'Segment2D.end'),\n}) });\n\n/**\n * Draws an open or closed point chain with optional physics attachment.\n *\n * @param props - Authored component inputs, supplied through JSX or createElement. See the linked\n * props and style types.\n * @throws When called directly; Pibbl mounts this component through JSX or createElement.\n *\n * @see {@link Chain2DProps}\n * @see {@link Chain2DStyle}\n */\nexport const Chain2D = definePrimitive<\n Chain2DProps,\n Chain2DStyle,\n Chain2DStyle,\n ResolvedChainStyle2D\n>(renderChain2D, { resolveStyle: style => ({\n ...stripLayout(style),\n points: Object.freeze(style.points.map((point, index) => copyPoint(point, `Chain2D.points[${index}]`))),\n closed: style.closed ?? false,\n radius: nonnegative(style.radius ?? 0, 'Chain2D.radius'),\n}) });\n\ninstallCustomShapeResolver2D(PhysicsShape2D, style => requireShape(style.shape, 'PhysicsShape2D.shape'));\ninstallCustomShapeResolver2D(Capsule2D, style => capsuleShape2D({\n start: copyPoint(style.start, 'Capsule2D.start'),\n end: copyPoint(style.end, 'Capsule2D.end'),\n radius: positive(style.radius, 'Capsule2D.radius'),\n}));\ninstallCustomShapeResolver2D(Segment2D, style => segmentShape2D({\n start: copyPoint(style.start, 'Segment2D.start'),\n end: copyPoint(style.end, 'Segment2D.end'),\n}));\ninstallCustomShapeResolver2D(Chain2D, style => chainShape2D({\n points: copyPoints(style.points, 'Chain2D.points'),\n closed: style.closed === true,\n radius: nonnegative(style.radius ?? 0, 'Chain2D.radius'),\n}));\n\nfunction resolvePhysicsShapeStyle(style: Readonly<PhysicsShape2DStyle>): ResolvedPhysicsShapeStyle2D {\n requireShape(style.shape, 'PhysicsShape2D.shape');\n return stripLayout(style) as ResolvedPhysicsShapeStyle2D;\n}\n\nfunction renderShape(\n props: PhysicsShape2DProps,\n style: Readonly<{\n readonly fill?: FillStyle;\n readonly stroke?: StrokeStyle;\n readonly strokeWidth?: number;\n readonly opacity?: number;\n readonly cursor?: string;\n readonly lineInteractionWidth?: number;\n }>,\n shape: PibblPhysicsShape2D,\n context: RenderingContext2D,\n): void {\n const record = requireShapeRecord2D(shape);\n const path = pathForShape(shape);\n const opacity = style.opacity ?? 1;\n if (!Number.isFinite(opacity) || opacity < 0 || opacity > 1) {\n throw new RangeError('Physics shape opacity must be finite from zero through one.');\n }\n const bounds = boundsOfShape2D(shape);\n const paintBounds = {x: bounds.min[0], y: bounds.min[1], width: bounds.max[0]-bounds.min[0], height: bounds.max[1]-bounds.min[1]};\n context.globalAlpha *= opacity;\n if (style.fill !== undefined) {\n context.fillStyle = resolveTexturePaint(style.fill, context, paintBounds);\n context.fill(path);\n }\n const strokeWidth = nonnegative(style.strokeWidth ?? 0, 'Physics shape strokeWidth');\n if (style.stroke !== undefined && strokeWidth > 0) {\n context.strokeStyle = resolveTexturePaint(style.stroke, context, paintBounds);\n context.lineWidth = strokeWidth;\n context.stroke(path);\n }\n const interactivePath = props.pointerEvents === 'none' ? new Path2D() : path;\n useEventTarget(props, {\n path: interactivePath,\n fill: style.fill !== undefined && record.area > 0,\n lineInteractionWidth: style.lineInteractionWidth ?? strokeWidth,\n cursor: style.cursor,\n keyboardFocusable: props.keyboardFocusable,\n keyboardNavigationBounds: props.keyboardNavigationBounds ?? {\n x: bounds.min[0], y: bounds.min[1],\n width: bounds.max[0] - bounds.min[0], height: bounds.max[1] - bounds.min[1],\n },\n });\n}\n\nfunction pathForShape(shape: PibblPhysicsShape2D): Path2D {\n const record = requireShapeRecord2D(shape);\n const local = new Path2D();\n for (const leaf of record.leaves) appendLeaf(local, leaf);\n if (record.localPose.x === 0 && record.localPose.y === 0 && record.localPose.rotationRadians === 0) return local;\n const result = new Path2D();\n result.addPath(local, new DOMMatrix()\n .translate(record.localPose.x, record.localPose.y)\n .rotate(record.localPose.rotationRadians * 180 / Math.PI));\n return result;\n}\n\nfunction appendLeaf(path: Path2D, leaf: ConvexLeaf2D): void {\n switch (leaf.kind) {\n case 'circle':\n path.moveTo(leaf.center[0]! + leaf.radius, leaf.center[1]!);\n path.arc(leaf.center[0]!, leaf.center[1]!, leaf.radius, 0, Math.PI * 2);\n path.closePath();\n return;\n case 'ellipse':\n path.moveTo(leaf.center[0]! + leaf.radiusX, leaf.center[1]!);\n path.ellipse(leaf.center[0]!, leaf.center[1]!, leaf.radiusX, leaf.radiusY, leaf.rotationRadians, 0, Math.PI * 2);\n path.closePath();\n return;\n case 'box':\n path.rect(leaf.center[0]! - leaf.halfWidth, leaf.center[1]! - leaf.halfHeight, leaf.halfWidth * 2, leaf.halfHeight * 2);\n return;\n case 'rounded-box':\n path.roundRect(\n leaf.center[0]! - leaf.halfWidth,\n leaf.center[1]! - leaf.halfHeight,\n leaf.halfWidth * 2,\n leaf.halfHeight * 2,\n Array.from(leaf.radii),\n );\n return;\n case 'capsule':\n appendCapsule(path, leaf.start, leaf.end, leaf.radius);\n return;\n case 'segment':\n path.moveTo(leaf.start[0]!, leaf.start[1]!);\n path.lineTo(leaf.end[0]!, leaf.end[1]!);\n return;\n case 'polygon':\n path.moveTo(leaf.vertices[0]!, leaf.vertices[1]!);\n for (let index = 2; index < leaf.vertices.length; index += 2) path.lineTo(leaf.vertices[index]!, leaf.vertices[index + 1]!);\n path.closePath();\n }\n}\n\nfunction appendCapsule(path: Path2D, start: Float64Array, end: Float64Array, radius: number): void {\n const dx = end[0]! - start[0]!, dy = end[1]! - start[1]!, length = Math.hypot(dx, dy);\n if (length === 0) {\n path.moveTo(start[0]! + radius, start[1]!);\n path.arc(start[0]!, start[1]!, radius, 0, Math.PI * 2);\n path.closePath();\n return;\n }\n const normal = Math.atan2(dy, dx) - Math.PI / 2;\n path.moveTo(start[0]! + Math.cos(normal) * radius, start[1]! + Math.sin(normal) * radius);\n path.lineTo(end[0]! + Math.cos(normal) * radius, end[1]! + Math.sin(normal) * radius);\n path.arc(end[0]!, end[1]!, radius, normal, normal + Math.PI);\n path.lineTo(start[0]! - Math.cos(normal) * radius, start[1]! - Math.sin(normal) * radius);\n path.arc(start[0]!, start[1]!, radius, normal + Math.PI, normal + Math.PI * 2);\n path.closePath();\n}\n\nfunction stripLayout<T extends Readonly<Record<PropertyKey, unknown>>>(style: T): T {\n const result = { ...style } as Record<PropertyKey, unknown>;\n for (const key of [\n 'width', 'height', 'minWidth', 'maxWidth', 'minHeight', 'maxHeight', 'padding', 'overflow',\n 'left', 'top', 'alignSelf', 'justifySelf', 'flexBasis', 'flexGrow', 'flexShrink',\n 'gridColumnStart', 'gridColumnSpan', 'gridRowStart', 'gridRowSpan',\n ]) delete result[key];\n return result as T;\n}\n\nfunction copyPoints(value: unknown, path: string): readonly PibblPhysicsVector2[] {\n if (!Array.isArray(value)) throw new TypeError(`${path} must be an array.`);\n return Object.freeze(value.map((point, index) => copyPoint(point, `${path}[${index}]`)));\n}\n\nfunction copyPoint(value: unknown, path: string): PibblPhysicsVector2 {\n if (!Array.isArray(value) || value.length !== 2 || value.some(entry => typeof entry !== 'number' || !Number.isFinite(entry))) {\n throw new TypeError(`${path} must be a finite two-dimensional point.`);\n }\n return Object.freeze([value[0] as number, value[1] as number] as const);\n}\n\nfunction positive(value: unknown, path: string): number {\n if (typeof value !== 'number' || !Number.isFinite(value) || value <= 0) throw new RangeError(`${path} must be finite and greater than zero.`);\n return value;\n}\n\nfunction nonnegative(value: unknown, path: string): number {\n if (typeof value !== 'number' || !Number.isFinite(value) || value < 0) throw new RangeError(`${path} must be finite and nonnegative.`);\n return value;\n}\n\nfunction requireShape(value: unknown, path: string): PibblPhysicsShape2D {\n try {\n requireShapeRecord2D(value as PibblPhysicsShape2D);\n return value as PibblPhysicsShape2D;\n } catch {\n throw new TypeError(`${path} must be a Pibbl physics 2D shape.`);\n }\n}\n"],
|
|
5
|
-
"mappings": "AAAA,SAAS,2BAA2B;AAEpC;AAAA,EACE;AAAA,EACA;AAAA,OAEK;AAYP,SAAS,iBAAiB,gBAAgB,cAAc,sBAAsB;AAC9E,SAAS,4BAA+C;AACxD,SAAS,oCAAoC;
|
|
4
|
+
"sourcesContent": ["import { resolveTexturePaint } from '@pibbl/core/internal';\nimport type { FillStyle, StrokeStyle } from '@pibbl/core';\nimport {\n useEventTarget,\n definePrimitive,\n type RenderingContext2D,\n} from '@pibbl/core';\nimport type {\n Capsule2DProps,\n Capsule2DStyle,\n Chain2DProps,\n Chain2DStyle,\n PhysicsShape2DProps,\n PhysicsShape2DStyle,\n Segment2DProps,\n Segment2DStyle,\n} from '../types.js';\nimport type { PibblPhysicsShape2D, PibblPhysicsVector2 } from '../../../2d-geometry.js';\nimport { boundsOfShape2D, capsuleShape2D, chainShape2D, segmentShape2D } from '../shapes.js';\nimport { requireShapeRecord2D, type ConvexLeaf2D } from '../shape-records.js';\nimport { installCustomShapeResolver2D } from './inference.js';\nconst layoutPropertyKeys = [\n 'width', 'height', 'minWidth', 'maxWidth', 'minHeight', 'maxHeight', 'padding', 'overflow',\n 'left', 'top', 'alignSelf', 'justifySelf', 'flexBasis', 'flexGrow', 'flexShrink',\n 'gridColumnStart', 'gridColumnSpan', 'gridRowStart', 'gridRowSpan',\n ] as const;\n\ntype LayoutProperty = typeof layoutPropertyKeys[number];\ntype ResolvedPhysicsShapeStyle2D = Omit<Readonly<PhysicsShape2DStyle>, LayoutProperty>;\ntype ResolvedCapsuleStyle2D = Omit<Readonly<Capsule2DStyle>, 'start' | 'end' | LayoutProperty> & {\n readonly start: PibblPhysicsVector2;\n readonly end: PibblPhysicsVector2;\n};\ntype ResolvedSegmentStyle2D = Omit<Readonly<Segment2DStyle>, 'start' | 'end' | LayoutProperty> & {\n readonly start: PibblPhysicsVector2;\n readonly end: PibblPhysicsVector2;\n};\ntype ResolvedChainStyle2D = Omit<Readonly<Chain2DStyle>, 'points' | LayoutProperty> & {\n readonly points: readonly PibblPhysicsVector2[];\n};\n\nfunction renderPhysicsShape2D(\n props: PhysicsShape2DProps,\n style: ResolvedPhysicsShapeStyle2D,\n context: RenderingContext2D,\n): void {\n renderShape(props, style, style.shape, context);\n}\n\nfunction renderCapsule2D(\n props: Capsule2DProps,\n style: Readonly<ResolvedCapsuleStyle2D>,\n context: RenderingContext2D,\n): void {\n renderShape(props, style, capsuleShape2D(style), context);\n}\n\nfunction renderSegment2D(\n props: Segment2DProps,\n style: Readonly<ResolvedSegmentStyle2D>,\n context: RenderingContext2D,\n): void {\n renderShape(props, style, segmentShape2D(style), context);\n}\n\nfunction renderChain2D(\n props: Chain2DProps,\n style: Readonly<ResolvedChainStyle2D>,\n context: RenderingContext2D,\n): void {\n renderShape(props, style, chainShape2D(style), context);\n}\n\n/**\n * Draws an immutable physics shape as a Canvas primitive with optional body or collider\n * attachment.\n *\n * @param props - Authored component inputs, supplied through JSX or createElement. See the linked\n * props and style types.\n * @throws When called directly; Pibbl mounts this component through JSX or createElement.\n *\n * @see {@link PhysicsShape2DProps}\n * @see {@link PhysicsShape2DStyle}\n */\nexport const PhysicsShape2D = definePrimitive<\n PhysicsShape2DProps,\n PhysicsShape2DStyle,\n PhysicsShape2DStyle,\n ResolvedPhysicsShapeStyle2D\n>(renderPhysicsShape2D, { resolveStyle: resolvePhysicsShapeStyle });\n\n/**\n * Draws a capsule between two endpoints with optional physics attachment.\n *\n * @param props - Authored component inputs, supplied through JSX or createElement. See the linked\n * props and style types.\n * @throws When called directly; Pibbl mounts this component through JSX or createElement.\n *\n * @see {@link Capsule2DProps}\n * @see {@link Capsule2DStyle}\n */\nexport const Capsule2D = definePrimitive<\n Capsule2DProps,\n Capsule2DStyle,\n Capsule2DStyle,\n ResolvedCapsuleStyle2D\n>(renderCapsule2D, { resolveStyle: style => ({\n ...stripLayout(style),\n start: copyPoint(style.start, 'Capsule2D.start'),\n end: copyPoint(style.end, 'Capsule2D.end'),\n radius: positive(style.radius, 'Capsule2D.radius'),\n}) });\n\n/**\n * Draws a line segment with optional physics attachment.\n *\n * @param props - Authored component inputs, supplied through JSX or createElement. See the linked\n * props and style types.\n * @throws When called directly; Pibbl mounts this component through JSX or createElement.\n *\n * @see {@link Segment2DProps}\n * @see {@link Segment2DStyle}\n */\nexport const Segment2D = definePrimitive<\n Segment2DProps,\n Segment2DStyle,\n Segment2DStyle,\n ResolvedSegmentStyle2D\n>(renderSegment2D, { resolveStyle: style => ({\n ...stripLayout(style),\n start: copyPoint(style.start, 'Segment2D.start'),\n end: copyPoint(style.end, 'Segment2D.end'),\n}) });\n\n/**\n * Draws an open or closed point chain with optional physics attachment.\n *\n * @param props - Authored component inputs, supplied through JSX or createElement. See the linked\n * props and style types.\n * @throws When called directly; Pibbl mounts this component through JSX or createElement.\n *\n * @see {@link Chain2DProps}\n * @see {@link Chain2DStyle}\n */\nexport const Chain2D = definePrimitive<\n Chain2DProps,\n Chain2DStyle,\n Chain2DStyle,\n ResolvedChainStyle2D\n>(renderChain2D, { resolveStyle: style => ({\n ...stripLayout(style),\n points: Object.freeze(style.points.map((point, index) => copyPoint(point, `Chain2D.points[${index}]`))),\n closed: style.closed ?? false,\n radius: nonnegative(style.radius ?? 0, 'Chain2D.radius'),\n}) });\n\ninstallCustomShapeResolver2D(PhysicsShape2D, style => requireShape(style.shape, 'PhysicsShape2D.shape'));\ninstallCustomShapeResolver2D(Capsule2D, style => capsuleShape2D({\n start: copyPoint(style.start, 'Capsule2D.start'),\n end: copyPoint(style.end, 'Capsule2D.end'),\n radius: positive(style.radius, 'Capsule2D.radius'),\n}));\ninstallCustomShapeResolver2D(Segment2D, style => segmentShape2D({\n start: copyPoint(style.start, 'Segment2D.start'),\n end: copyPoint(style.end, 'Segment2D.end'),\n}));\ninstallCustomShapeResolver2D(Chain2D, style => chainShape2D({\n points: copyPoints(style.points, 'Chain2D.points'),\n closed: style.closed === true,\n radius: nonnegative(style.radius ?? 0, 'Chain2D.radius'),\n}));\n\nfunction resolvePhysicsShapeStyle(style: Readonly<PhysicsShape2DStyle>): ResolvedPhysicsShapeStyle2D {\n requireShape(style.shape, 'PhysicsShape2D.shape');\n return stripLayout(style) as ResolvedPhysicsShapeStyle2D;\n}\n\nfunction renderShape(\n props: PhysicsShape2DProps,\n style: Readonly<{\n readonly fill?: FillStyle;\n readonly stroke?: StrokeStyle;\n readonly strokeWidth?: number;\n readonly opacity?: number;\n readonly cursor?: string;\n readonly lineInteractionWidth?: number;\n }>,\n shape: PibblPhysicsShape2D,\n context: RenderingContext2D,\n): void {\n const record = requireShapeRecord2D(shape);\n const path = pathForShape(shape);\n const opacity = style.opacity ?? 1;\n if (!Number.isFinite(opacity) || opacity < 0 || opacity > 1) {\n throw new RangeError('Physics shape opacity must be finite from zero through one.');\n }\n const bounds = boundsOfShape2D(shape);\n const paintBounds = {x: bounds.min[0], y: bounds.min[1], width: bounds.max[0]-bounds.min[0], height: bounds.max[1]-bounds.min[1]};\n context.globalAlpha *= opacity;\n if (style.fill !== undefined) {\n context.fillStyle = resolveTexturePaint(style.fill, context, paintBounds);\n context.fill(path);\n }\n const strokeWidth = nonnegative(style.strokeWidth ?? 0, 'Physics shape strokeWidth');\n if (style.stroke !== undefined && strokeWidth > 0) {\n context.strokeStyle = resolveTexturePaint(style.stroke, context, paintBounds);\n context.lineWidth = strokeWidth;\n context.stroke(path);\n }\n const interactivePath = props.pointerEvents === 'none' ? new Path2D() : path;\n useEventTarget(props, {\n path: interactivePath,\n fill: style.fill !== undefined && record.area > 0,\n lineInteractionWidth: style.lineInteractionWidth ?? strokeWidth,\n cursor: style.cursor,\n keyboardFocusable: props.keyboardFocusable,\n keyboardNavigationBounds: props.keyboardNavigationBounds ?? {\n x: bounds.min[0], y: bounds.min[1],\n width: bounds.max[0] - bounds.min[0], height: bounds.max[1] - bounds.min[1],\n },\n });\n}\n\nfunction pathForShape(shape: PibblPhysicsShape2D): Path2D {\n const record = requireShapeRecord2D(shape);\n const local = new Path2D();\n for (const leaf of record.leaves) appendLeaf(local, leaf);\n if (record.localPose.x === 0 && record.localPose.y === 0 && record.localPose.rotationRadians === 0) return local;\n const result = new Path2D();\n result.addPath(local, new DOMMatrix()\n .translate(record.localPose.x, record.localPose.y)\n .rotate(record.localPose.rotationRadians * 180 / Math.PI));\n return result;\n}\n\nfunction appendLeaf(path: Path2D, leaf: ConvexLeaf2D): void {\n switch (leaf.kind) {\n case 'circle':\n path.moveTo(leaf.center[0]! + leaf.radius, leaf.center[1]!);\n path.arc(leaf.center[0]!, leaf.center[1]!, leaf.radius, 0, Math.PI * 2);\n path.closePath();\n return;\n case 'ellipse':\n path.moveTo(leaf.center[0]! + leaf.radiusX, leaf.center[1]!);\n path.ellipse(leaf.center[0]!, leaf.center[1]!, leaf.radiusX, leaf.radiusY, leaf.rotationRadians, 0, Math.PI * 2);\n path.closePath();\n return;\n case 'box':\n path.rect(leaf.center[0]! - leaf.halfWidth, leaf.center[1]! - leaf.halfHeight, leaf.halfWidth * 2, leaf.halfHeight * 2);\n return;\n case 'rounded-box':\n path.roundRect(\n leaf.center[0]! - leaf.halfWidth,\n leaf.center[1]! - leaf.halfHeight,\n leaf.halfWidth * 2,\n leaf.halfHeight * 2,\n Array.from(leaf.radii),\n );\n return;\n case 'capsule':\n appendCapsule(path, leaf.start, leaf.end, leaf.radius);\n return;\n case 'segment':\n path.moveTo(leaf.start[0]!, leaf.start[1]!);\n path.lineTo(leaf.end[0]!, leaf.end[1]!);\n return;\n case 'polygon':\n path.moveTo(leaf.vertices[0]!, leaf.vertices[1]!);\n for (let index = 2; index < leaf.vertices.length; index += 2) path.lineTo(leaf.vertices[index]!, leaf.vertices[index + 1]!);\n path.closePath();\n }\n}\n\nfunction appendCapsule(path: Path2D, start: Float64Array, end: Float64Array, radius: number): void {\n const dx = end[0]! - start[0]!, dy = end[1]! - start[1]!, length = Math.hypot(dx, dy);\n if (length === 0) {\n path.moveTo(start[0]! + radius, start[1]!);\n path.arc(start[0]!, start[1]!, radius, 0, Math.PI * 2);\n path.closePath();\n return;\n }\n const normal = Math.atan2(dy, dx) - Math.PI / 2;\n path.moveTo(start[0]! + Math.cos(normal) * radius, start[1]! + Math.sin(normal) * radius);\n path.lineTo(end[0]! + Math.cos(normal) * radius, end[1]! + Math.sin(normal) * radius);\n path.arc(end[0]!, end[1]!, radius, normal, normal + Math.PI);\n path.lineTo(start[0]! - Math.cos(normal) * radius, start[1]! - Math.sin(normal) * radius);\n path.arc(start[0]!, start[1]!, radius, normal + Math.PI, normal + Math.PI * 2);\n path.closePath();\n}\n\nfunction stripLayout<T extends Readonly<Record<PropertyKey, unknown>>>(style: T): T {\n const result = { ...style } as Record<PropertyKey, unknown>;\n for (let keyIndex = 0; keyIndex < layoutPropertyKeys.length; keyIndex++) {\n const key = layoutPropertyKeys[keyIndex];\n delete result[key];\n }\n return result as T;\n}\n\nfunction copyPoints(value: unknown, path: string): readonly PibblPhysicsVector2[] {\n if (!Array.isArray(value)) throw new TypeError(`${path} must be an array.`);\n return Object.freeze(value.map((point, index) => copyPoint(point, `${path}[${index}]`)));\n}\n\nfunction copyPoint(value: unknown, path: string): PibblPhysicsVector2 {\n if (!Array.isArray(value) || value.length !== 2 || value.some(entry => typeof entry !== 'number' || !Number.isFinite(entry))) {\n throw new TypeError(`${path} must be a finite two-dimensional point.`);\n }\n return Object.freeze([value[0] as number, value[1] as number] as const);\n}\n\nfunction positive(value: unknown, path: string): number {\n if (typeof value !== 'number' || !Number.isFinite(value) || value <= 0) throw new RangeError(`${path} must be finite and greater than zero.`);\n return value;\n}\n\nfunction nonnegative(value: unknown, path: string): number {\n if (typeof value !== 'number' || !Number.isFinite(value) || value < 0) throw new RangeError(`${path} must be finite and nonnegative.`);\n return value;\n}\n\nfunction requireShape(value: unknown, path: string): PibblPhysicsShape2D {\n try {\n requireShapeRecord2D(value as PibblPhysicsShape2D);\n return value as PibblPhysicsShape2D;\n } catch {\n throw new TypeError(`${path} must be a Pibbl physics 2D shape.`);\n }\n}\n"],
|
|
5
|
+
"mappings": "AAAA,SAAS,2BAA2B;AAEpC;AAAA,EACE;AAAA,EACA;AAAA,OAEK;AAYP,SAAS,iBAAiB,gBAAgB,cAAc,sBAAsB;AAC9E,SAAS,4BAA+C;AACxD,SAAS,oCAAoC;AAC7C,MAAM,qBAAqB;AAAA,EACvB;AAAA,EAAS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
|
|
106
106
|
}
|
|
107
107
|
}
|
|
108
108
|
function validateFiniteInvertible(matrix, label) {
|
|
109
|
-
|
|
110
|
-
if (values.some((value) => !Number.isFinite(value))) {
|
|
109
|
+
if (!Number.isFinite(matrix.a) || !Number.isFinite(matrix.b) || !Number.isFinite(matrix.c) || !Number.isFinite(matrix.d) || !Number.isFinite(matrix.e) || !Number.isFinite(matrix.f)) {
|
|
111
110
|
throw new TypeError(`${label} must contain only finite values.`);
|
|
112
111
|
}
|
|
113
112
|
if (Math.abs(matrix.a * matrix.d - matrix.b * matrix.c) <= 1e-10) {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../../../src/features/physics/lib/2d/canvas/presentation.ts"],
|
|
4
|
-
"sourcesContent": ["import type { PibblPhysicsPose2D } from \"../../../2d-geometry.js\";\nimport { Group } from \"@pibbl/core\";\n\nconst MATRIX_EPSILON = 1e-6;\n\nexport interface CanvasBodyPresentationCapture2D {\n readonly initialPose: PibblPhysicsPose2D;\n readonly parentWorld: DOMMatrix;\n readonly initialBodyLocal: DOMMatrix;\n readonly poseResidual: DOMMatrix;\n}\n\nexport function captureBodyPresentation2D(\n parentWorld: DOMMatrixReadOnly,\n initialBodyLocal: DOMMatrixReadOnly,\n componentName: string,\n requireRigidAncestor = true,\n): CanvasBodyPresentationCapture2D {\n if (requireRigidAncestor) validateRigidAncestor(parentWorld, componentName);\n else\n validateFiniteInvertible(\n parentWorld,\n `${componentName} ancestor transform`,\n );\n validateFiniteInvertible(\n initialBodyLocal,\n `${componentName} authored transform`,\n );\n if (requireRigidAncestor) {\n validateUnskewed(initialBodyLocal, `${componentName} authored transform`);\n }\n const world = copyMatrix(parentWorld).multiply(initialBodyLocal);\n const scaleX = Math.hypot(world.a, world.b);\n const initialPose = Object.freeze({\n position: Object.freeze([clean(world.e), clean(world.f)] as const),\n rotationDegrees: clean(\n (Math.atan2(world.b / scaleX, world.a / scaleX) * 180) / Math.PI,\n ),\n });\n const poseMatrix = matrixFromPose(initialPose);\n return Object.freeze({\n initialPose,\n parentWorld: copyMatrix(parentWorld),\n initialBodyLocal: copyMatrix(initialBodyLocal),\n poseResidual: poseMatrix.inverse().multiply(world),\n });\n}\n\nexport function resolveDynamicPresentationTransform2D(\n capture: CanvasBodyPresentationCapture2D,\n presentedPose: PibblPhysicsPose2D,\n parentWorld: DOMMatrixReadOnly,\n currentBodyLocal: DOMMatrixReadOnly,\n componentName: string,\n): DOMMatrix {\n validateRigidAncestor(parentWorld, componentName);\n if (!sameMatrix(parentWorld, capture.parentWorld)) {\n throw new Error(\n `${componentName} ancestor transform changed while an enabled dynamic body owns pose. ` +\n \"Use teleportBody2D(), a kinematic body, or disable physics before authored motion.\",\n );\n }\n if (!sameMatrix(currentBodyLocal, capture.initialBodyLocal)) {\n throw new Error(\n `${componentName} authored pose changed while an enabled dynamic body owns pose. ` +\n \"Use teleportBody2D(), a kinematic body, or disable physics before authored motion.\",\n );\n }\n validatePose(presentedPose, componentName);\n const presentedWorld = matrixFromPose(presentedPose).multiply(\n capture.poseResidual,\n );\n const result = copyMatrix(parentWorld)\n .inverse()\n .multiply(presentedWorld)\n .multiply(copyMatrix(capture.initialBodyLocal).inverse());\n return cleanMatrix(result);\n}\n\nexport function bodyLocalTransformFromPrimitive2D(\n componentType: Function,\n style: Readonly<Record<PropertyKey, unknown>>,\n): DOMMatrix {\n let transform = new DOMMatrix().translate(\n finiteStyleNumber(style.left, 0, \"left\"),\n finiteStyleNumber(style.top, 0, \"top\"),\n );\n if (componentType !== Group) return transform;\n const scaleX = finiteStyleNumber(style.scaleX, 1, \"scaleX\");\n const scaleY = finiteStyleNumber(style.scaleY, 1, \"scaleY\");\n if (scaleX !== 1 || scaleY !== 1) transform = transform.scale(scaleX, scaleY);\n const rotation = finiteStyleNumber(\n style.rotationDegrees,\n 0,\n \"rotationDegrees\",\n );\n if (rotation !== 0) {\n const origin = style.rotationOrigin ?? [0, 0];\n if (\n !Array.isArray(origin) ||\n origin.length !== 2 ||\n origin.some(\n (value) => typeof value !== \"number\" || !Number.isFinite(value),\n )\n ) {\n throw new TypeError(\n \"Group rotationOrigin must be a finite two-dimensional point.\",\n );\n }\n transform = transform\n .translate(origin[0], origin[1])\n .rotate(rotation)\n .translate(-origin[0], -origin[1]);\n }\n const translateX = finiteStyleNumber(style.translateX, 0, \"translateX\");\n const translateY = finiteStyleNumber(style.translateY, 0, \"translateY\");\n if (translateX !== 0 || translateY !== 0)\n transform = transform.translate(translateX, translateY);\n const skewX = finiteStyleNumber(style.skewX, 0, \"skewX\");\n const skewY = finiteStyleNumber(style.skewY, 0, \"skewY\");\n if (skewX !== 0) transform = transform.skewX(skewX);\n if (skewY !== 0) transform = transform.skewY(skewY);\n return transform;\n}\n\nfunction validatePose(pose: PibblPhysicsPose2D, componentName: string): void {\n if (\n !Number.isFinite(pose.position[0]) ||\n !Number.isFinite(pose.position[1]) ||\n !Number.isFinite(pose.rotationDegrees)\n ) {\n throw new TypeError(\n `${componentName} physics presentation pose must be finite.`,\n );\n }\n}\n\nfunction validateRigidAncestor(\n matrix: DOMMatrixReadOnly,\n componentName: string,\n): void {\n validateFiniteInvertible(\n matrix,\n `${componentName} dynamic ancestor transform`,\n );\n validateUnskewed(matrix, `${componentName} dynamic ancestor transform`);\n const scaleX = Math.hypot(matrix.a, matrix.b);\n const scaleY = Math.hypot(matrix.c, matrix.d);\n if (!close(scaleX, 1) || !close(scaleY, 1)) {\n throw new Error(\n `${componentName} has a non-rigid dynamic ancestor scale. Bake scale into collider geometry or move the body outside that ancestor.`,\n );\n }\n}\n\nfunction validateFiniteInvertible(\n matrix: DOMMatrixReadOnly,\n label: string,\n): void {\n
|
|
5
|
-
"mappings": "AACA,SAAS,aAAa;AAEtB,MAAM,iBAAiB;AAShB,SAAS,0BACd,aACA,kBACA,eACA,uBAAuB,MACU;AACjC,MAAI,qBAAsB,uBAAsB,aAAa,aAAa;AAAA;AAExE;AAAA,MACE;AAAA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AU,MAAM,KAAK;AAClD,SAAO;AACT;AAEA,SAAS,aAAa,MAA0B,eAA6B;AAC3E,MACE,CAAC,OAAO,SAAS,KAAK,SAAS,CAAC,CAAC,KACjC,CAAC,OAAO,SAAS,KAAK,SAAS,CAAC,CAAC,KACjC,CAAC,OAAO,SAAS,KAAK,eAAe,GACrC;AACA,UAAM,IAAI;AAAA,MACR,GAAG,aAAa;AAAA,IAClB;AAAA,EACF;AACF;AAEA,SAAS,sBACP,QACA,eACM;AACN;AAAA,IACE;AAAA,IACA,GAAG,aAAa;AAAA,EAClB;AACA,mBAAiB,QAAQ,GAAG,aAAa,6BAA6B;AACtE,QAAM,SAAS,KAAK,MAAM,OAAO,GAAG,OAAO,CAAC;AAC5C,QAAM,SAAS,KAAK,MAAM,OAAO,GAAG,OAAO,CAAC;AAC5C,MAAI,CAAC,MAAM,QAAQ,CAAC,KAAK,CAAC,MAAM,QAAQ,CAAC,GAAG;AAC1C,UAAM,IAAI;AAAA,MACR,GAAG,aAAa;AAAA,IAClB;AAAA,EACF;AACF;AAEA,SAAS,yBACP,QACA,OACM;AACN,
|
|
4
|
+
"sourcesContent": ["import type { PibblPhysicsPose2D } from \"../../../2d-geometry.js\";\nimport { Group } from \"@pibbl/core\";\n\nconst MATRIX_EPSILON = 1e-6;\n\nexport interface CanvasBodyPresentationCapture2D {\n readonly initialPose: PibblPhysicsPose2D;\n readonly parentWorld: DOMMatrix;\n readonly initialBodyLocal: DOMMatrix;\n readonly poseResidual: DOMMatrix;\n}\n\nexport function captureBodyPresentation2D(\n parentWorld: DOMMatrixReadOnly,\n initialBodyLocal: DOMMatrixReadOnly,\n componentName: string,\n requireRigidAncestor = true,\n): CanvasBodyPresentationCapture2D {\n if (requireRigidAncestor) validateRigidAncestor(parentWorld, componentName);\n else\n validateFiniteInvertible(\n parentWorld,\n `${componentName} ancestor transform`,\n );\n validateFiniteInvertible(\n initialBodyLocal,\n `${componentName} authored transform`,\n );\n if (requireRigidAncestor) {\n validateUnskewed(initialBodyLocal, `${componentName} authored transform`);\n }\n const world = copyMatrix(parentWorld).multiply(initialBodyLocal);\n const scaleX = Math.hypot(world.a, world.b);\n const initialPose = Object.freeze({\n position: Object.freeze([clean(world.e), clean(world.f)] as const),\n rotationDegrees: clean(\n (Math.atan2(world.b / scaleX, world.a / scaleX) * 180) / Math.PI,\n ),\n });\n const poseMatrix = matrixFromPose(initialPose);\n return Object.freeze({\n initialPose,\n parentWorld: copyMatrix(parentWorld),\n initialBodyLocal: copyMatrix(initialBodyLocal),\n poseResidual: poseMatrix.inverse().multiply(world),\n });\n}\n\nexport function resolveDynamicPresentationTransform2D(\n capture: CanvasBodyPresentationCapture2D,\n presentedPose: PibblPhysicsPose2D,\n parentWorld: DOMMatrixReadOnly,\n currentBodyLocal: DOMMatrixReadOnly,\n componentName: string,\n): DOMMatrix {\n validateRigidAncestor(parentWorld, componentName);\n if (!sameMatrix(parentWorld, capture.parentWorld)) {\n throw new Error(\n `${componentName} ancestor transform changed while an enabled dynamic body owns pose. ` +\n \"Use teleportBody2D(), a kinematic body, or disable physics before authored motion.\",\n );\n }\n if (!sameMatrix(currentBodyLocal, capture.initialBodyLocal)) {\n throw new Error(\n `${componentName} authored pose changed while an enabled dynamic body owns pose. ` +\n \"Use teleportBody2D(), a kinematic body, or disable physics before authored motion.\",\n );\n }\n validatePose(presentedPose, componentName);\n const presentedWorld = matrixFromPose(presentedPose).multiply(\n capture.poseResidual,\n );\n const result = copyMatrix(parentWorld)\n .inverse()\n .multiply(presentedWorld)\n .multiply(copyMatrix(capture.initialBodyLocal).inverse());\n return cleanMatrix(result);\n}\n\nexport function bodyLocalTransformFromPrimitive2D(\n componentType: Function,\n style: Readonly<Record<PropertyKey, unknown>>,\n): DOMMatrix {\n let transform = new DOMMatrix().translate(\n finiteStyleNumber(style.left, 0, \"left\"),\n finiteStyleNumber(style.top, 0, \"top\"),\n );\n if (componentType !== Group) return transform;\n const scaleX = finiteStyleNumber(style.scaleX, 1, \"scaleX\");\n const scaleY = finiteStyleNumber(style.scaleY, 1, \"scaleY\");\n if (scaleX !== 1 || scaleY !== 1) transform = transform.scale(scaleX, scaleY);\n const rotation = finiteStyleNumber(\n style.rotationDegrees,\n 0,\n \"rotationDegrees\",\n );\n if (rotation !== 0) {\n const origin = style.rotationOrigin ?? [0, 0];\n if (\n !Array.isArray(origin) ||\n origin.length !== 2 ||\n origin.some(\n (value) => typeof value !== \"number\" || !Number.isFinite(value),\n )\n ) {\n throw new TypeError(\n \"Group rotationOrigin must be a finite two-dimensional point.\",\n );\n }\n transform = transform\n .translate(origin[0], origin[1])\n .rotate(rotation)\n .translate(-origin[0], -origin[1]);\n }\n const translateX = finiteStyleNumber(style.translateX, 0, \"translateX\");\n const translateY = finiteStyleNumber(style.translateY, 0, \"translateY\");\n if (translateX !== 0 || translateY !== 0)\n transform = transform.translate(translateX, translateY);\n const skewX = finiteStyleNumber(style.skewX, 0, \"skewX\");\n const skewY = finiteStyleNumber(style.skewY, 0, \"skewY\");\n if (skewX !== 0) transform = transform.skewX(skewX);\n if (skewY !== 0) transform = transform.skewY(skewY);\n return transform;\n}\n\nfunction validatePose(pose: PibblPhysicsPose2D, componentName: string): void {\n if (\n !Number.isFinite(pose.position[0]) ||\n !Number.isFinite(pose.position[1]) ||\n !Number.isFinite(pose.rotationDegrees)\n ) {\n throw new TypeError(\n `${componentName} physics presentation pose must be finite.`,\n );\n }\n}\n\nfunction validateRigidAncestor(\n matrix: DOMMatrixReadOnly,\n componentName: string,\n): void {\n validateFiniteInvertible(\n matrix,\n `${componentName} dynamic ancestor transform`,\n );\n validateUnskewed(matrix, `${componentName} dynamic ancestor transform`);\n const scaleX = Math.hypot(matrix.a, matrix.b);\n const scaleY = Math.hypot(matrix.c, matrix.d);\n if (!close(scaleX, 1) || !close(scaleY, 1)) {\n throw new Error(\n `${componentName} has a non-rigid dynamic ancestor scale. Bake scale into collider geometry or move the body outside that ancestor.`,\n );\n }\n}\n\nfunction validateFiniteInvertible(\n matrix: DOMMatrixReadOnly,\n label: string,\n): void {\n if (\n !Number.isFinite(matrix.a) || !Number.isFinite(matrix.b) ||\n !Number.isFinite(matrix.c) || !Number.isFinite(matrix.d) ||\n !Number.isFinite(matrix.e) || !Number.isFinite(matrix.f)\n ) {\n throw new TypeError(`${label} must contain only finite values.`);\n }\n if (Math.abs(matrix.a * matrix.d - matrix.b * matrix.c) <= 1e-10) {\n throw new Error(`${label} is noninvertible.`);\n }\n}\n\nfunction validateUnskewed(matrix: DOMMatrixReadOnly, label: string): void {\n const scaleX = Math.hypot(matrix.a, matrix.b);\n const scaleY = Math.hypot(matrix.c, matrix.d);\n const dot = (matrix.a * matrix.c + matrix.b * matrix.d) / (scaleX * scaleY);\n if (Math.abs(dot) > 1e-8)\n throw new Error(`${label} is skewed and cannot define a rigid body pose.`);\n}\n\nfunction sameMatrix(\n left: DOMMatrixReadOnly,\n right: DOMMatrixReadOnly,\n): boolean {\n return (\n close(left.a, right.a) &&\n close(left.b, right.b) &&\n close(left.c, right.c) &&\n close(left.d, right.d) &&\n close(left.e, right.e) &&\n close(left.f, right.f)\n );\n}\n\nfunction close(left: number, right: number): boolean {\n return Math.abs(left - right) <= MATRIX_EPSILON;\n}\n\nfunction clean(value: number): number {\n return Math.abs(value) <= MATRIX_EPSILON ? 0 : value;\n}\n\nfunction cleanMatrix(source: DOMMatrixReadOnly): DOMMatrix {\n return new DOMMatrix([\n clean(source.a),\n clean(source.b),\n clean(source.c),\n clean(source.d),\n clean(source.e),\n clean(source.f),\n ]);\n}\n\nfunction copyMatrix(source: DOMMatrixReadOnly): DOMMatrix {\n return new DOMMatrix([\n source.a,\n source.b,\n source.c,\n source.d,\n source.e,\n source.f,\n ]);\n}\n\nexport function matrixFromPose(pose: PibblPhysicsPose2D): DOMMatrix {\n return new DOMMatrix()\n .translate(pose.position[0], pose.position[1])\n .rotate(pose.rotationDegrees);\n}\n\nfunction finiteStyleNumber(\n value: unknown,\n fallback: number,\n property: string,\n): number {\n const resolved = value ?? fallback;\n if (typeof resolved !== \"number\" || !Number.isFinite(resolved)) {\n throw new TypeError(`Resolved Group ${property} must be finite.`);\n }\n return resolved;\n}\n"],
|
|
5
|
+
"mappings": "AACA,SAAS,aAAa;AAEtB,MAAM,iBAAiB;AAShB,SAAS,0BACd,aACA,kBACA,eACA,uBAAuB,MACU;AACjC,MAAI,qBAAsB,uBAAsB,aAAa,aAAa;AAAA;AAExE;AAAA,MACE;AAAA,MACA,GAAG,aAAa;AAAA,IAClB;AACF;AAAA,IACE;AAAA,IACA,GAAG,aAAa;AAAA,EAClB;AACA,MAAI,sBAAsB;AACxB,qBAAiB,kBAAkB,GAAG,aAAa,qBAAqB;AAAA,EAC1E;AACA,QAAM,QAAQ,WAAW,WAAW,EAAE,SAAS,gBAAgB;AAC/D,QAAM,SAAS,KAAK,MAAM,MAAM,GAAG,MAAM,CAAC;AAC1C,QAAM,cAAc,OAAO,OAAO;AAAA,IAChC,UAAU,OAAO,OAAO,CAAC,MAAM,MAAM,CAAC,GAAG,MAAM,MAAM,CAAC,CAAC,CAAU;AAAA,IACjE,iBAAiB;AAAA,MACd,KAAK,MAAM,MAAM,IAAI,QAAQ,MAAM,IAAI,MAAM,IAAI,MAAO,KAAK;AAAA,IAChE;AAAA,EACF,CAAC;AACD,QAAM,aAAa,eAAe,WAAW;AAC7C,SAAO,OAAO,OAAO;AAAA,IACnB;AAAA,IACA,aAAa,WAAW,WAAW;AAAA,IACnC,kBAAkB,WAAW,gBAAgB;AAAA,IAC7C,cAAc,WAAW,QAAQ,EAAE,SAAS,KAAK;AAAA,EACnD,CAAC;AACH;AAEO,SAAS,sCACd,SACA,eACA,aACA,kBACA,eACW;AACX,wBAAsB,aAAa,aAAa;AAChD,MAAI,CAAC,WAAW,aAAa,QAAQ,WAAW,GAAG;AACjD,UAAM,IAAI;AAAA,MACR,GAAG,aAAa;AAAA,IAElB;AAAA,EACF;AACA,MAAI,CAAC,WAAW,kBAAkB,QAAQ,gBAAgB,GAAG;AAC3D,UAAM,IAAI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P,OAAO;AAAA,IACP,OAAO;AAAA,EACT,CAAC;AACH;AAEO,SAAS,eAAe,MAAqC;AAClE,SAAO,IAAI,UAAU,EAClB,UAAU,KAAK,SAAS,CAAC,GAAG,KAAK,SAAS,CAAC,CAAC,EAC5C,OAAO,KAAK,eAAe;AAChC;AAEA,SAAS,kBACP,OACA,UACA,UACQ;AACR,QAAM,WAAW,SAAS;AAC1B,MAAI,OAAO,aAAa,YAAY,CAAC,OAAO,SAAS,QAAQ,GAAG;AAC9D,UAAM,IAAI,UAAU,kBAAkB,QAAQ,kBAAkB;AAAA,EAClE;AACA,SAAO;AACT;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -234,7 +234,7 @@ function raycastCapsule(leaf, pose, originX, originY, directionX, directionY, ma
|
|
|
234
234
|
const acrossDirection = directionX * sideNormalX + directionY * sideNormalY;
|
|
235
235
|
const distances = [];
|
|
236
236
|
if (Math.abs(acrossDirection) > GEOMETRY_EPSILON) {
|
|
237
|
-
for (
|
|
237
|
+
for (let side = -1; side <= 1; side += 2) {
|
|
238
238
|
const distance = (side * leaf.radius - acrossOrigin) / acrossDirection;
|
|
239
239
|
const along = alongOrigin + distance * alongDirection;
|
|
240
240
|
if (distance >= -CAST_TIME_TOLERANCE && distance <= maxDistance + CAST_TIME_TOLERANCE && along >= -CAST_HIT_TOLERANCE && along <= segmentLength + CAST_HIT_TOLERANCE) {
|
|
@@ -242,7 +242,9 @@ function raycastCapsule(leaf, pose, originX, originY, directionX, directionY, ma
|
|
|
242
242
|
}
|
|
243
243
|
}
|
|
244
244
|
}
|
|
245
|
-
for (
|
|
245
|
+
for (let endpoint = 0; endpoint < 2; endpoint++) {
|
|
246
|
+
const centerX = endpoint === 0 ? startX : endX;
|
|
247
|
+
const centerY = endpoint === 0 ? startY : endY;
|
|
246
248
|
const distance = rayCircleDistance(
|
|
247
249
|
originX,
|
|
248
250
|
originY,
|