@pibbl/core 0.0.1 → 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/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-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/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/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/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 +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/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/physics/lib/2d/world/rapier.js +22 -26
- package/dist/features/physics/lib/2d/world/rapier.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/loader.js +6 -3
- package/dist/features/sprites/loader.js.map +2 -2
- 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 +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 +92 -5
- package/dist/features/viz/index.js +202 -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 +24 -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 +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 +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 +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-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/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-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 +30 -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 +124 -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/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 +10 -6
- 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/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/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/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/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 +43 -6
- 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
|
@@ -10,14 +10,7 @@ function resolveLength(value, reference, property, context = {}) {
|
|
|
10
10
|
}
|
|
11
11
|
return value;
|
|
12
12
|
}
|
|
13
|
-
|
|
14
|
-
throw diagnostic(
|
|
15
|
-
property,
|
|
16
|
-
value,
|
|
17
|
-
`uses an unsupported length value ${String(value)}`,
|
|
18
|
-
context
|
|
19
|
-
);
|
|
20
|
-
}
|
|
13
|
+
const percentage = parsePercentage(value, property, context);
|
|
21
14
|
if (reference === void 0 || !Number.isFinite(reference)) {
|
|
22
15
|
throw diagnostic(
|
|
23
16
|
property,
|
|
@@ -34,7 +27,7 @@ function resolveLength(value, reference, property, context = {}) {
|
|
|
34
27
|
context
|
|
35
28
|
);
|
|
36
29
|
}
|
|
37
|
-
const resolved =
|
|
30
|
+
const resolved = percentage / 100 * reference;
|
|
38
31
|
if (!Number.isFinite(resolved)) {
|
|
39
32
|
throw diagnostic(
|
|
40
33
|
property,
|
|
@@ -45,10 +38,21 @@ function resolveLength(value, reference, property, context = {}) {
|
|
|
45
38
|
}
|
|
46
39
|
return resolved;
|
|
47
40
|
}
|
|
41
|
+
function parsePercentage(value, property, context = {}) {
|
|
42
|
+
if (typeof value !== "string" || !DECIMAL_PERCENTAGE.test(value)) {
|
|
43
|
+
throw diagnostic(property, value, `uses an unsupported length value ${String(value)}`, context);
|
|
44
|
+
}
|
|
45
|
+
const percentage = Number.parseFloat(value);
|
|
46
|
+
if (!Number.isFinite(percentage)) {
|
|
47
|
+
throw diagnostic(property, value, "percentage must be finite", context);
|
|
48
|
+
}
|
|
49
|
+
return percentage;
|
|
50
|
+
}
|
|
48
51
|
function diagnostic(property, value, reason, context) {
|
|
49
52
|
return layoutDiagnostic({ ...context, property, value, reason });
|
|
50
53
|
}
|
|
51
54
|
export {
|
|
55
|
+
parsePercentage,
|
|
52
56
|
resolveLength
|
|
53
57
|
};
|
|
54
58
|
//# sourceMappingURL=resolve-length.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/lib/style/resolve-length.ts"],
|
|
4
|
-
"sourcesContent": ["import {\n layoutDiagnostic,\n type LayoutDiagnosticContext,\n} from './diagnostics.js';\nimport type { Length } from './types.js';\n\nconst DECIMAL_PERCENTAGE = /^[+-]?(?:\\d+(?:\\.\\d+)?|\\.\\d+)%$/;\n\n/**\n * Resolves a numeric or percentage length; automatic sizing returns undefined.\n *\n * @param value - Logical length or percentage to resolve. See {@link Length}.\n * @param reference - Reference length for percentages, or undefined if unavailable.\n * @param property - Property name used in diagnostics.\n * @param context - Component and property context for diagnostic messages. See\n * {@link LayoutDiagnosticContext} .\n * @returns The resolved logical length, or undefined for an unresolved automatic length.\n *\n * @see {@link Length}\n * @see {@link LayoutDiagnosticContext}\n */\nexport function resolveLength(\n value: Length,\n reference: number | undefined,\n property: string,\n context: Readonly<LayoutDiagnosticContext> = {},\n): number | undefined {\n if (value === 'auto') return undefined;\n\n if (typeof value === 'number') {\n if (!Number.isFinite(value)) {\n throw diagnostic(property, value, 'must be a finite number', context);\n }\n return value;\n }\n\n
|
|
5
|
-
"mappings": "AAAA;AAAA,EACE;AAAA,OAEK;AAGP,MAAM,qBAAqB;AAepB,SAAS,cACd,OACA,WACA,UACA,UAA6C,CAAC,GAC1B;AACpB,MAAI,UAAU,OAAQ,QAAO;AAE7B,MAAI,OAAO,UAAU,UAAU;AAC7B,QAAI,CAAC,OAAO,SAAS,KAAK,GAAG;AAC3B,YAAM,WAAW,UAAU,OAAO,2BAA2B,OAAO;AAAA,IACtE;AACA,WAAO;AAAA,EACT;AAEA,
|
|
4
|
+
"sourcesContent": ["import {\n layoutDiagnostic,\n type LayoutDiagnosticContext,\n} from './diagnostics.js';\nimport type { Length } from './types.js';\n\nconst DECIMAL_PERCENTAGE = /^[+-]?(?:\\d+(?:\\.\\d+)?|\\.\\d+)%$/;\n\n/**\n * Resolves a numeric or percentage length; automatic sizing returns undefined.\n *\n * @param value - Logical length or percentage to resolve. See {@link Length}.\n * @param reference - Reference length for percentages, or undefined if unavailable.\n * @param property - Property name used in diagnostics.\n * @param context - Component and property context for diagnostic messages. See\n * {@link LayoutDiagnosticContext} .\n * @returns The resolved logical length, or undefined for an unresolved automatic length.\n *\n * @see {@link Length}\n * @see {@link LayoutDiagnosticContext}\n */\nexport function resolveLength(\n value: Length,\n reference: number | undefined,\n property: string,\n context: Readonly<LayoutDiagnosticContext> = {},\n): number | undefined {\n if (value === 'auto') return undefined;\n\n if (typeof value === 'number') {\n if (!Number.isFinite(value)) {\n throw diagnostic(property, value, 'must be a finite number', context);\n }\n return value;\n }\n\n const percentage = parsePercentage(value, property, context);\n\n if (reference === undefined || !Number.isFinite(reference)) {\n throw diagnostic(\n property,\n value,\n 'requires a definite finite percentage reference',\n context,\n );\n }\n if (reference < 0) {\n throw diagnostic(\n property,\n value,\n 'percentage reference must be nonnegative',\n context,\n );\n }\n\n const resolved = (percentage / 100) * reference;\n if (!Number.isFinite(resolved)) {\n throw diagnostic(\n property,\n value,\n 'resolved percentage arithmetic must remain finite',\n context,\n );\n }\n return resolved;\n}\n\n/** @internal Parse a percentage independently of its containing-size reference. */\nexport function parsePercentage(value: unknown, property: string, context: Readonly<LayoutDiagnosticContext> = {}): number {\n if (typeof value !== 'string' || !DECIMAL_PERCENTAGE.test(value)) {\n throw diagnostic(property, value, `uses an unsupported length value ${String(value)}`, context);\n }\n const percentage = Number.parseFloat(value);\n if (!Number.isFinite(percentage)) {\n throw diagnostic(property, value, 'percentage must be finite', context);\n }\n return percentage;\n}\n\nfunction diagnostic(\n property: string,\n value: unknown,\n reason: string,\n context: Readonly<LayoutDiagnosticContext>,\n) {\n return layoutDiagnostic({ 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|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { type LayoutDiagnosticContext } from './diagnostics.js';
|
|
2
|
+
import type { Length, Percentage } from './types.js';
|
|
3
|
+
declare const fitContentBrand: unique symbol;
|
|
4
|
+
/** Sizing values requiring an intrinsic layout owner. See {@link SizingLength}. */
|
|
5
|
+
export type SizingKeyword = 'min-content' | 'max-content';
|
|
6
|
+
/** Immutable fit-content bound created by {@link fitContent}. See {@link SizingLength}. */
|
|
7
|
+
export interface FitContent {
|
|
8
|
+
/** Finite nonnegative logical length or parent-axis percentage. See {@link Percentage}. */
|
|
9
|
+
readonly limit: number | Percentage;
|
|
10
|
+
readonly [fitContentBrand]: true;
|
|
11
|
+
}
|
|
12
|
+
/** Sizing-only value; padding and insets retain {@link Length}. See {@link FitContent}, {@link SizingKeyword}. */
|
|
13
|
+
export type SizingLength = Length | SizingKeyword | FitContent | 'stretch';
|
|
14
|
+
/** A scalar result or an owner-resolved intrinsic sizing request. */
|
|
15
|
+
export type NormalizedSizingLength = Readonly<{
|
|
16
|
+
kind: 'auto';
|
|
17
|
+
}> | Readonly<{
|
|
18
|
+
kind: 'length';
|
|
19
|
+
value: number;
|
|
20
|
+
}> | Readonly<{
|
|
21
|
+
kind: 'min-content';
|
|
22
|
+
}> | Readonly<{
|
|
23
|
+
kind: 'max-content';
|
|
24
|
+
}> | Readonly<{
|
|
25
|
+
kind: 'fit-content';
|
|
26
|
+
limit: number;
|
|
27
|
+
}>;
|
|
28
|
+
/** Options supplied by the layout owner that owns intrinsic-size policy. */
|
|
29
|
+
export interface SizingNormalizationOptions {
|
|
30
|
+
readonly reference: number | undefined;
|
|
31
|
+
readonly property: string;
|
|
32
|
+
readonly context?: Readonly<LayoutDiagnosticContext>;
|
|
33
|
+
readonly allowAuto: boolean;
|
|
34
|
+
readonly allowIntrinsic: boolean;
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* Creates an immutable bound between measured min- and max-content widths.
|
|
38
|
+
* @param limit - Nonnegative finite logical width or parent-axis {@link Percentage}.
|
|
39
|
+
* @returns Branded immutable {@link FitContent} sizing value.
|
|
40
|
+
* @see {@link SizingLength}
|
|
41
|
+
*/
|
|
42
|
+
export declare function fitContent(limit: number | Percentage): FitContent;
|
|
43
|
+
/** Identifies a fit-content value without accepting lookalike style records. */
|
|
44
|
+
export declare function isFitContent(value: unknown): value is FitContent;
|
|
45
|
+
/** Identifies a non-scalar sizing request without widening scalar length users. */
|
|
46
|
+
export declare function isIntrinsicSizingValue(value: unknown): value is SizingKeyword | FitContent;
|
|
47
|
+
/** Resolves only scalar sizing input at a non-intrinsic owner boundary. */
|
|
48
|
+
export declare function resolveScalarSizingLength(value: SizingLength, reference: number | undefined, property: string, context?: Readonly<LayoutDiagnosticContext>): number | undefined;
|
|
49
|
+
/** Normalizes sizing syntax without teaching scalar length users intrinsic semantics. */
|
|
50
|
+
export declare function normalizeSizingLength(value: SizingLength | undefined, options: Readonly<SizingNormalizationOptions>): NormalizedSizingLength | undefined;
|
|
51
|
+
export {};
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
import { layoutDiagnostic } from "./diagnostics.js";
|
|
2
|
+
import { parsePercentage, resolveLength } from "./resolve-length.js";
|
|
3
|
+
const fitContentBrand = /* @__PURE__ */ Symbol("pibbl.fit-content");
|
|
4
|
+
function fitContent(limit) {
|
|
5
|
+
const numeric = typeof limit === "number" ? limit : parsePercentage(limit, "fitContent");
|
|
6
|
+
if (!Number.isFinite(numeric) || numeric < 0) {
|
|
7
|
+
throw layoutDiagnostic({
|
|
8
|
+
property: "fitContent",
|
|
9
|
+
value: limit,
|
|
10
|
+
reason: "limit must be finite and nonnegative"
|
|
11
|
+
});
|
|
12
|
+
}
|
|
13
|
+
return Object.freeze({ [fitContentBrand]: true, limit });
|
|
14
|
+
}
|
|
15
|
+
function isFitContent(value) {
|
|
16
|
+
return typeof value === "object" && value !== null && value[fitContentBrand] === true;
|
|
17
|
+
}
|
|
18
|
+
function isIntrinsicSizingValue(value) {
|
|
19
|
+
return value === "min-content" || value === "max-content" || isFitContent(value);
|
|
20
|
+
}
|
|
21
|
+
function resolveScalarSizingLength(value, reference, property, context = {}) {
|
|
22
|
+
if (value === "stretch") {
|
|
23
|
+
if (reference !== void 0 && Number.isFinite(reference) && reference >= 0) return reference;
|
|
24
|
+
throw layoutDiagnostic({ ...context, property, value, reason: "stretch requires a finite owning allocation" });
|
|
25
|
+
}
|
|
26
|
+
if (isIntrinsicSizingValue(value)) {
|
|
27
|
+
throw layoutDiagnostic({
|
|
28
|
+
...context,
|
|
29
|
+
property,
|
|
30
|
+
value,
|
|
31
|
+
reason: "requires a direct finite Flex intrinsic-sizing owner"
|
|
32
|
+
});
|
|
33
|
+
}
|
|
34
|
+
return resolveLength(value, reference, property, context);
|
|
35
|
+
}
|
|
36
|
+
function normalizeSizingLength(value, options) {
|
|
37
|
+
if (value === void 0) return void 0;
|
|
38
|
+
const context = options.context ?? {};
|
|
39
|
+
if (isFitContent(value)) {
|
|
40
|
+
if (!options.allowIntrinsic) throw unsupported(options, value, "intrinsic sizing requires a measuring layout owner");
|
|
41
|
+
const limit = resolveLength(value.limit, options.reference, options.property, context);
|
|
42
|
+
if (limit === void 0 || limit < 0) {
|
|
43
|
+
throw layoutDiagnostic({ ...context, property: options.property, value, reason: "fit-content limit must resolve to a finite nonnegative length" });
|
|
44
|
+
}
|
|
45
|
+
return { kind: "fit-content", limit };
|
|
46
|
+
}
|
|
47
|
+
if (value === "min-content" || value === "max-content") {
|
|
48
|
+
if (!options.allowIntrinsic) throw unsupported(options, value, "intrinsic sizing requires a measuring layout owner");
|
|
49
|
+
return { kind: value };
|
|
50
|
+
}
|
|
51
|
+
if (value === "stretch") {
|
|
52
|
+
const resolved2 = resolveScalarSizingLength(value, options.reference, options.property, context);
|
|
53
|
+
return { kind: "length", value: resolved2 };
|
|
54
|
+
}
|
|
55
|
+
const resolved = resolveLength(value, options.reference, options.property, context);
|
|
56
|
+
if (resolved === void 0) {
|
|
57
|
+
if (!options.allowAuto) throw unsupported(options, value, "automatic sizing is not allowed for this property");
|
|
58
|
+
return { kind: "auto" };
|
|
59
|
+
}
|
|
60
|
+
return { kind: "length", value: resolved };
|
|
61
|
+
}
|
|
62
|
+
function unsupported(options, value, reason) {
|
|
63
|
+
return layoutDiagnostic({
|
|
64
|
+
...options.context ?? {},
|
|
65
|
+
property: options.property,
|
|
66
|
+
value,
|
|
67
|
+
reason
|
|
68
|
+
});
|
|
69
|
+
}
|
|
70
|
+
export {
|
|
71
|
+
fitContent,
|
|
72
|
+
isFitContent,
|
|
73
|
+
isIntrinsicSizingValue,
|
|
74
|
+
normalizeSizingLength,
|
|
75
|
+
resolveScalarSizingLength
|
|
76
|
+
};
|
|
77
|
+
//# sourceMappingURL=sizing-length.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../src/lib/style/sizing-length.ts"],
|
|
4
|
+
"sourcesContent": ["import { layoutDiagnostic, type LayoutDiagnosticContext } from './diagnostics.js';\nimport { parsePercentage, resolveLength } from './resolve-length.js';\nimport type { Length, Percentage } from './types.js';\n\nconst fitContentBrand: unique symbol = Symbol('pibbl.fit-content');\n\n/** Sizing values requiring an intrinsic layout owner. See {@link SizingLength}. */\nexport type SizingKeyword = 'min-content' | 'max-content';\n\n/** Immutable fit-content bound created by {@link fitContent}. See {@link SizingLength}. */\nexport interface FitContent {\n /** Finite nonnegative logical length or parent-axis percentage. See {@link Percentage}. */\n readonly limit: number | Percentage;\n readonly [fitContentBrand]: true;\n}\n\n/** Sizing-only value; padding and insets retain {@link Length}. See {@link FitContent}, {@link SizingKeyword}. */\nexport type SizingLength = Length | SizingKeyword | FitContent | 'stretch';\n\n/** A scalar result or an owner-resolved intrinsic sizing request. */\nexport type NormalizedSizingLength =\n | Readonly<{ kind: 'auto' }>\n | Readonly<{ kind: 'length'; value: number }>\n | Readonly<{ kind: 'min-content' }>\n | Readonly<{ kind: 'max-content' }>\n | Readonly<{ kind: 'fit-content'; limit: number }>;\n\n/** Options supplied by the layout owner that owns intrinsic-size policy. */\nexport interface SizingNormalizationOptions {\n readonly reference: number | undefined;\n readonly property: string;\n readonly context?: Readonly<LayoutDiagnosticContext>;\n readonly allowAuto: boolean;\n readonly allowIntrinsic: boolean;\n}\n\n/**\n * Creates an immutable bound between measured min- and max-content widths.\n * @param limit - Nonnegative finite logical width or parent-axis {@link Percentage}.\n * @returns Branded immutable {@link FitContent} sizing value.\n * @see {@link SizingLength}\n */\nexport function fitContent(limit: number | Percentage): FitContent {\n const numeric = typeof limit === 'number' ? limit : parsePercentage(limit, 'fitContent');\n if (!Number.isFinite(numeric) || numeric < 0) {\n throw layoutDiagnostic({\n property: 'fitContent',\n value: limit,\n reason: 'limit must be finite and nonnegative',\n });\n }\n return Object.freeze({ [fitContentBrand]: true, limit }) as FitContent;\n}\n\n/** Identifies a fit-content value without accepting lookalike style records. */\nexport function isFitContent(value: unknown): value is FitContent {\n return typeof value === 'object' && value !== null &&\n (value as Partial<FitContent>)[fitContentBrand] === true;\n}\n\n/** Identifies a non-scalar sizing request without widening scalar length users. */\nexport function isIntrinsicSizingValue(value: unknown): value is SizingKeyword | FitContent {\n return value === 'min-content' || value === 'max-content' || isFitContent(value);\n}\n\n/** Resolves only scalar sizing input at a non-intrinsic owner boundary. */\nexport function resolveScalarSizingLength(\n value: SizingLength,\n reference: number | undefined,\n property: string,\n context: Readonly<LayoutDiagnosticContext> = {},\n): number | undefined {\n if (value === 'stretch') {\n if (reference !== undefined && Number.isFinite(reference) && reference >= 0) return reference;\n throw layoutDiagnostic({ ...context, property, value, reason: 'stretch requires a finite owning allocation' });\n }\n if (isIntrinsicSizingValue(value)) {\n throw layoutDiagnostic({\n ...context,\n property,\n value,\n reason: 'requires a direct finite Flex intrinsic-sizing owner',\n });\n }\n return resolveLength(value, reference, property, context);\n}\n\n/** Normalizes sizing syntax without teaching scalar length users intrinsic semantics. */\nexport function normalizeSizingLength(\n value: SizingLength | undefined,\n options: Readonly<SizingNormalizationOptions>,\n): NormalizedSizingLength | undefined {\n if (value === undefined) return undefined;\n const context = options.context ?? {};\n if (isFitContent(value)) {\n if (!options.allowIntrinsic) throw unsupported(options, value, 'intrinsic sizing requires a measuring layout owner');\n const limit = resolveLength(value.limit, options.reference, options.property, context);\n if (limit === undefined || limit < 0) {\n throw layoutDiagnostic({ ...context, property: options.property, value, reason: 'fit-content limit must resolve to a finite nonnegative length' });\n }\n return { kind: 'fit-content', limit };\n }\n if (value === 'min-content' || value === 'max-content') {\n if (!options.allowIntrinsic) throw unsupported(options, value, 'intrinsic sizing requires a measuring layout owner');\n return { kind: value };\n }\n if (value === 'stretch') {\n const resolved = resolveScalarSizingLength(value, options.reference, options.property, context)!;\n return { kind: 'length', value: resolved };\n }\n const resolved = resolveLength(value, options.reference, options.property, context);\n if (resolved === undefined) {\n if (!options.allowAuto) throw unsupported(options, value, 'automatic sizing is not allowed for this property');\n return { kind: 'auto' };\n }\n return { kind: 'length', value: resolved };\n}\n\nfunction unsupported(\n options: Readonly<SizingNormalizationOptions>,\n value: unknown,\n reason: string,\n): Error {\n return layoutDiagnostic({\n ...(options.context ?? {}),\n property: options.property,\n value,\n reason,\n });\n}\n"],
|
|
5
|
+
"mappings": "AAAA,SAAS,wBAAsD;AAC/D,SAAS,iBAAiB,qBAAqB;AAG/C,MAAM,kBAAiC,uBAAO,mBAAmB;AAsC1D,SAAS,WAAW,OAAwC;AACjE,QAAM,UAAU,OAAO,UAAU,WAAW,QAAQ,gBAAgB,OAAO,YAAY;AACvF,MAAI,CAAC,OAAO,SAAS,OAAO,KAAK,UAAU,GAAG;AAC5C,UAAM,iBAAiB;AAAA,MACrB,UAAU;AAAA,MACV,OAAO;AAAA,MACP,QAAQ;AAAA,IACV,CAAC;AAAA,EACH;AACA,SAAO,OAAO,OAAO,EAAE,CAAC,eAAe,GAAG,MAAM,MAAM,CAAC;AACzD;AAGO,SAAS,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Q,WAAW,QAAQ,UAAU,OAAO;AAC9F,WAAO,EAAE,MAAM,UAAU,OAAOA,UAAS;AAAA,EAC3C;AACA,QAAM,WAAW,cAAc,OAAO,QAAQ,WAAW,QAAQ,UAAU,OAAO;AAClF,MAAI,aAAa,QAAW;AAC1B,QAAI,CAAC,QAAQ,UAAW,OAAM,YAAY,SAAS,OAAO,mDAAmD;AAC7G,WAAO,EAAE,MAAM,OAAO;AAAA,EACxB;AACA,SAAO,EAAE,MAAM,UAAU,OAAO,SAAS;AAC3C;AAEA,SAAS,YACP,SACA,OACA,QACO;AACP,SAAO,iBAAiB;AAAA,IACtB,GAAI,QAAQ,WAAW,CAAC;AAAA,IACxB,UAAU,QAAQ;AAAA,IAClB;AAAA,IACA;AAAA,EACF,CAAC;AACH;",
|
|
6
|
+
"names": ["resolved"]
|
|
7
|
+
}
|
|
@@ -10,6 +10,7 @@ import type { PathGeometry } from '../geometry/path-geometry.js';
|
|
|
10
10
|
import type { FillStyle, PixelGridAlignment, StrokeStyle, SystemStyle } from '../types.js';
|
|
11
11
|
import type { LayoutBox } from '../layout/types.js';
|
|
12
12
|
import type { PositioningStyle } from './positioning.js';
|
|
13
|
+
import type { SizingLength } from './sizing-length.js';
|
|
13
14
|
/**
|
|
14
15
|
* A percentage string resolved against the relevant parent layout dimension.
|
|
15
16
|
*
|
|
@@ -42,18 +43,20 @@ export interface RoundedCornerStyle {
|
|
|
42
43
|
/**
|
|
43
44
|
* One inset for every edge or independently specified top, right, bottom, and left insets.
|
|
44
45
|
*
|
|
46
|
+
* @typeParam T - Permitted edge values; defaults to numeric insets. Padding may opt into {@link Percentage}.
|
|
47
|
+
*
|
|
45
48
|
* @see {@link BoxStyle}
|
|
46
49
|
* @see {@link normalizeEdges}
|
|
47
50
|
*/
|
|
48
|
-
export type EdgeValues = number | Readonly<{
|
|
51
|
+
export type EdgeValues<T extends number | Percentage = number> = T | Readonly<{
|
|
49
52
|
/** Top edge value or top envelope guide. See {@link EdgeValues}. */
|
|
50
|
-
top?:
|
|
53
|
+
top?: T;
|
|
51
54
|
/** Right edge coordinate or inset. See {@link EdgeValues}. */
|
|
52
|
-
right?:
|
|
55
|
+
right?: T;
|
|
53
56
|
/** Bottom edge value or bottom envelope guide. See {@link EdgeValues}. */
|
|
54
|
-
bottom?:
|
|
57
|
+
bottom?: T;
|
|
55
58
|
/** Left edge coordinate or inset. See {@link EdgeValues}. */
|
|
56
|
-
left?:
|
|
59
|
+
left?: T;
|
|
57
60
|
}>;
|
|
58
61
|
/**
|
|
59
62
|
* Declared box dimensions, size limits, padding, and overflow behavior.
|
|
@@ -66,20 +69,37 @@ export type EdgeValues = number | Readonly<{
|
|
|
66
69
|
* @see {@link RectStyle}
|
|
67
70
|
*/
|
|
68
71
|
export interface BoxStyle extends SystemStyle {
|
|
69
|
-
/**
|
|
70
|
-
|
|
71
|
-
/**
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
72
|
+
/** Positive finite width/height ratio. A declared definite axis derives the automatic axis before its bounds; boxSizing selects content or border geometry. See {@link resolveBox}. */
|
|
73
|
+
aspectRatio?: number;
|
|
74
|
+
/** Selects whether dimensions, bounds and Flex basis include padding and layout borders. Defaults to content-box.
|
|
75
|
+
* Border-box content floors at zero and the outer box floors at total axis padding plus layout borders.
|
|
76
|
+
* Painted stroke widths remain independent. See {@link ResolvedBoxStyle}.
|
|
77
|
+
*/
|
|
78
|
+
boxSizing?: 'content-box' | 'border-box';
|
|
79
|
+
/** Horizontal extent in the units of the containing geometry or surface. See {@link SizingLength}. */
|
|
80
|
+
width?: SizingLength;
|
|
81
|
+
/** Vertical extent in the units of the containing geometry or surface. See {@link SizingLength}. */
|
|
82
|
+
height?: SizingLength;
|
|
83
|
+
/** Minimum permitted horizontal width. Finite horizontal Flex intrinsic owners also accept intrinsic sizing requests; automatic remains invalid. See {@link SizingLength}. */
|
|
84
|
+
minWidth?: Exclude<SizingLength, 'auto'>;
|
|
85
|
+
/** Maximum permitted horizontal width. Finite horizontal Flex intrinsic owners also accept intrinsic sizing requests; automatic remains invalid. See {@link SizingLength}. */
|
|
86
|
+
maxWidth?: Exclude<SizingLength, 'auto'>;
|
|
77
87
|
/** Minimum permitted height. See {@link Length}. */
|
|
78
|
-
minHeight?: Exclude<
|
|
88
|
+
minHeight?: Exclude<SizingLength, 'auto'>;
|
|
79
89
|
/** Maximum permitted height. See {@link Length}. */
|
|
80
|
-
maxHeight?: Exclude<
|
|
81
|
-
/**
|
|
82
|
-
padding?: EdgeValues
|
|
90
|
+
maxHeight?: Exclude<SizingLength, 'auto'>;
|
|
91
|
+
/** Padding inside layout borders. Experimental allocated Flex percentages use owner content width for every edge. See {@link EdgeValues}, {@link Percentage}. */
|
|
92
|
+
padding?: EdgeValues<number | Percentage>;
|
|
93
|
+
/** Nonnegative inline-start padding overriding its physical padding edge. Experimental percentages require an allocated Flex owner and use its content width. See {@link BoxStyle}. */
|
|
94
|
+
paddingStart?: number | Percentage;
|
|
95
|
+
/** Nonnegative inline-end padding overriding its physical padding edge. See {@link BoxStyle}. */
|
|
96
|
+
paddingEnd?: number | Percentage;
|
|
97
|
+
/** Layout-only physical border insets, in logical pixels. Defaults to zero; does not paint a stroke. See {@link EdgeValues}. */
|
|
98
|
+
borderWidth?: EdgeValues;
|
|
99
|
+
/** Experimental nonnegative numeric inline-start layout border overriding its physical borderWidth edge. Does not paint a stroke. See {@link BoxStyle}. */
|
|
100
|
+
borderStartWidth?: number;
|
|
101
|
+
/** Experimental nonnegative numeric inline-end layout border overriding its physical borderWidth edge. See {@link BoxStyle}. */
|
|
102
|
+
borderEndWidth?: number;
|
|
83
103
|
/** Selects `"visible"`, `"clip"` for overflow. See {@link BoxStyle}. */
|
|
84
104
|
overflow?: 'visible' | 'clip';
|
|
85
105
|
}
|
|
@@ -95,6 +115,8 @@ export interface ResolvedBoxStyle {
|
|
|
95
115
|
/** The resolved rectangle available to content after padding. See {@link LayoutBox}. */
|
|
96
116
|
contentBox: LayoutBox;
|
|
97
117
|
}
|
|
118
|
+
/** Flex edge margin value. Auto distributes remaining space on supported finite experimental Flex axes. See {@link FlexItemStyle}. */
|
|
119
|
+
export type FlexMargin = number | Percentage | 'auto';
|
|
98
120
|
/**
|
|
99
121
|
* Parent-layout participation: positioning, self-alignment, flex sizing, and explicit grid placement.
|
|
100
122
|
*
|
|
@@ -104,12 +126,28 @@ export interface ResolvedBoxStyle {
|
|
|
104
126
|
* @see {@link PathStyle}
|
|
105
127
|
*/
|
|
106
128
|
export interface LayoutItemStyle extends PositioningStyle {
|
|
129
|
+
/** Positive finite outer width/height ratio consumed by finite Flex, including wrapped lines. Final per-line main size derives cross size before cross bounds; intrinsic main sizing is unsupported. A documented direct absolute Flex child may derive exactly one automatic outer axis from its declared numeric opposite axis when no opposing inset pair supplies that axis. See {@link FlexItemStyle}. */
|
|
130
|
+
aspectRatio?: number;
|
|
131
|
+
/** Uniform physical margin in logical Canvas units, a percentage of allocated Flex content width, or auto on supported finite Flex axes. Finite negatives are allowed; specific edges override this value. Consumed by experimental Flex only. See {@link LayoutItemStyle}. */
|
|
132
|
+
margin?: FlexMargin;
|
|
133
|
+
/** Physical top margin overriding margin. See {@link LayoutItemStyle}. */
|
|
134
|
+
marginTop?: FlexMargin;
|
|
135
|
+
/** Physical right margin overriding margin. See {@link LayoutItemStyle}. */
|
|
136
|
+
marginRight?: FlexMargin;
|
|
137
|
+
/** Physical bottom margin overriding margin. See {@link LayoutItemStyle}. */
|
|
138
|
+
marginBottom?: FlexMargin;
|
|
139
|
+
/** Physical left margin overriding margin. See {@link LayoutItemStyle}. */
|
|
140
|
+
marginLeft?: FlexMargin;
|
|
141
|
+
/** Inline-start margin overriding the corresponding physical edge and margin shorthand in experimental Flex. Signed percentages use allocated content width. See {@link LayoutItemStyle}. */
|
|
142
|
+
marginStart?: FlexMargin;
|
|
143
|
+
/** Inline-end margin overriding the corresponding physical edge and margin shorthand in experimental Flex. See {@link LayoutItemStyle}. */
|
|
144
|
+
marginEnd?: FlexMargin;
|
|
107
145
|
/** This child's cross-axis or block-axis alignment override. See {@link LayoutItemStyle}. */
|
|
108
146
|
alignSelf?: 'auto' | 'start' | 'end' | 'center' | 'stretch' | 'flex-start' | 'flex-end';
|
|
109
147
|
/** This child's inline-axis alignment override. See {@link LayoutItemStyle}. */
|
|
110
148
|
justifySelf?: 'auto' | 'start' | 'end' | 'center' | 'stretch';
|
|
111
|
-
/** Initial main-axis size before flex growth or shrinkage. See {@link
|
|
112
|
-
flexBasis?:
|
|
149
|
+
/** Initial main-axis size before flex growth or shrinkage. See {@link SizingLength}. */
|
|
150
|
+
flexBasis?: SizingLength;
|
|
113
151
|
/** Relative share of positive free space assigned to this child. See {@link LayoutItemStyle}. */
|
|
114
152
|
flexGrow?: number;
|
|
115
153
|
/** Relative factor used when reducing main-axis size. See {@link LayoutItemStyle}. */
|
|
@@ -128,9 +166,9 @@ export interface LayoutItemStyle extends PositioningStyle {
|
|
|
128
166
|
*
|
|
129
167
|
* @see {@link LayoutItemStyle}
|
|
130
168
|
*/
|
|
131
|
-
export type FlexItemStyle = Pick<LayoutItemStyle, 'flexBasis' | 'flexGrow' | 'flexShrink'> & {
|
|
169
|
+
export type FlexItemStyle = Pick<LayoutItemStyle, 'position' | 'left' | 'right' | 'top' | 'bottom' | 'insetStart' | 'insetEnd' | 'aspectRatio' | 'flexBasis' | 'flexGrow' | 'flexShrink' | 'margin' | 'marginTop' | 'marginRight' | 'marginBottom' | 'marginLeft' | 'marginStart' | 'marginEnd'> & {
|
|
132
170
|
/** This child's cross-axis or block-axis alignment override. See {@link FlexItemStyle}. */
|
|
133
|
-
alignSelf?: 'auto' | 'stretch' | 'flex-start' | 'flex-end' | 'center';
|
|
171
|
+
alignSelf?: 'auto' | 'stretch' | 'flex-start' | 'flex-end' | 'center' | 'start' | 'end';
|
|
134
172
|
};
|
|
135
173
|
/**
|
|
136
174
|
* Explicit grid cell placement, spans, and alignment of a child.
|
|
@@ -221,10 +259,10 @@ export interface PathStyle extends SystemStyle, PaintStyle, CursorStyle, BoxStyl
|
|
|
221
259
|
* @see {@link PixelGridAlignment}
|
|
222
260
|
*/
|
|
223
261
|
export interface RectStyle extends RoundedCornerStyle, SystemStyle, PaintStyle, CursorStyle, BoxStyle, LayoutItemStyle {
|
|
224
|
-
/** Horizontal extent in the units of the containing geometry or surface. See {@link
|
|
225
|
-
width:
|
|
226
|
-
/** Vertical extent in the units of the containing geometry or surface. See {@link
|
|
227
|
-
height:
|
|
262
|
+
/** Horizontal extent in the units of the containing geometry or surface. See {@link SizingLength}. */
|
|
263
|
+
width: SizingLength;
|
|
264
|
+
/** Vertical extent in the units of the containing geometry or surface. See {@link SizingLength}. */
|
|
265
|
+
height: SizingLength;
|
|
228
266
|
/**
|
|
229
267
|
* Pixel-grid alignment policy applied to the resolved geometry. See {@link PixelGridAlignment}.
|
|
230
268
|
*/
|
|
@@ -99,11 +99,12 @@ function prepareSurface(instance) {
|
|
|
99
99
|
return snapshot;
|
|
100
100
|
}
|
|
101
101
|
function readCanvasContentBox(canvas) {
|
|
102
|
-
|
|
102
|
+
if (canvas.getClientRects().length === 0) return { width: 0, height: 0 };
|
|
103
103
|
const style = getComputedStyle(canvas);
|
|
104
|
+
const borderBox = style.boxSizing === "border-box";
|
|
104
105
|
return {
|
|
105
|
-
width: Math.max(0,
|
|
106
|
-
height: Math.max(0,
|
|
106
|
+
width: Math.max(0, pixelValue(style.width) - (borderBox ? boxInsets(style, "width") : 0)),
|
|
107
|
+
height: Math.max(0, pixelValue(style.height) - (borderBox ? boxInsets(style, "height") : 0))
|
|
107
108
|
};
|
|
108
109
|
}
|
|
109
110
|
function mountDensityObservers(instance, canvas, state) {
|
|
@@ -144,7 +145,8 @@ function setDisplaySize(state, display) {
|
|
|
144
145
|
return true;
|
|
145
146
|
}
|
|
146
147
|
function ownInlineSize(canvas, property, value, current) {
|
|
147
|
-
const
|
|
148
|
+
const style = getComputedStyle(canvas);
|
|
149
|
+
const owned = `${value + (style.boxSizing === "border-box" ? boxInsets(style, property) : 0)}px`;
|
|
148
150
|
const previous = current?.previous ?? canvas.style[property];
|
|
149
151
|
canvas.style[property] = owned;
|
|
150
152
|
return { previous, owned };
|
|
@@ -155,8 +157,10 @@ function restoreOwnedSize(canvas, property, record) {
|
|
|
155
157
|
}
|
|
156
158
|
}
|
|
157
159
|
function boxInsets(style, axis) {
|
|
158
|
-
|
|
159
|
-
|
|
160
|
+
return axis === "width" ? pixelValue(style.borderLeftWidth) + pixelValue(style.borderRightWidth) + pixelValue(style.paddingLeft) + pixelValue(style.paddingRight) : pixelValue(style.borderTopWidth) + pixelValue(style.borderBottomWidth) + pixelValue(style.paddingTop) + pixelValue(style.paddingBottom);
|
|
161
|
+
}
|
|
162
|
+
function pixelValue(value) {
|
|
163
|
+
return Number.parseFloat(value) || 0;
|
|
160
164
|
}
|
|
161
165
|
function nearlyEqual(left, right) {
|
|
162
166
|
return Math.abs(left - right) < 0.01;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/lib/surface/root-surface.ts"],
|
|
4
|
-
"sourcesContent": ["import type { PibblInstance } from '../types.js';\nimport { update } from '../update.js';\nimport { createLayerSurface, resolveSurface } from './resolve-surface.js';\nimport type {\n PibblConfig,\n PibblSurfaceSnapshot,\n LayerSurfaceState,\n RootSurfaceState,\n SurfaceDisplaySize,\n} from './types.js';\nimport { validateSurfaceConfig } from './resolve-surface.js';\n\nexport function createRootSurfaceState(\n canvas: HTMLCanvasElement,\n config?: PibblConfig,\n): RootSurfaceState {\n const resolved = validateSurfaceConfig(canvas, config);\n return {\n kind: 'root',\n config: resolved,\n display: readCanvasContentBox(canvas),\n pixelRatio: readRequestedPixelRatio(resolved.pixelRatio),\n snapshot: undefined,\n ownedWidth: undefined,\n ownedHeight: undefined,\n };\n}\n\nexport function createLegacyLayerSurfaceState(\n width: number,\n height: number,\n): LayerSurfaceState {\n return {\n kind: 'layer',\n managed: false,\n snapshot: createLayerSurface(width, height, 1, 1),\n };\n}\n\nexport function mountRootSurface(\n instance: PibblInstance,\n canvas: HTMLCanvasElement,\n): void {\n const state = instance.surface;\n if (state.kind !== 'root') return;\n\n if (typeof ResizeObserver !== 'function') {\n throw new Error('Pibbl requires ResizeObserver for Canvas surface sizing.');\n }\n\n const resizeObserver = new ResizeObserver(() => {\n const display = readCanvasContentBox(canvas);\n if (setDisplaySize(state, display)) {\n update(canvas);\n }\n });\n resizeObserver.observe(canvas);\n instance.mainTeardowns.add(() => resizeObserver.disconnect());\n\n instance.mainTeardowns.add(() => {\n restoreOwnedSize(canvas, 'width', state.ownedWidth);\n restoreOwnedSize(canvas, 'height', state.ownedHeight);\n });\n\n if (state.config.pixelRatio === 'device') {\n mountDensityObservers(instance, canvas, state);\n }\n}\n\nexport function prepareSurface(\n instance: PibblInstance,\n): PibblSurfaceSnapshot | undefined {\n const state = instance.surface;\n if (state.kind === 'layer') {\n if (!state.managed) {\n state.snapshot = createLayerSurface(\n instance.canvas.width,\n instance.canvas.height,\n 1,\n 1,\n );\n }\n return state.snapshot;\n }\n\n const canvas = instance.canvas as HTMLCanvasElement;\n state.display = readCanvasContentBox(canvas);\n if (state.config.pixelRatio === 'device') {\n state.pixelRatio = readRequestedPixelRatio('device');\n }\n let snapshot = resolveSurface(state.config, state.display, state.pixelRatio);\n state.snapshot = snapshot;\n if (!snapshot) return undefined;\n\n const before = state.display;\n const dimensionsChanged = canvas.width !== snapshot.backingWidth ||\n canvas.height !== snapshot.backingHeight;\n if (dimensionsChanged) {\n canvas.width = snapshot.backingWidth;\n canvas.height = snapshot.backingHeight;\n const after = readCanvasContentBox(canvas);\n if (!nearlyEqual(after.width, before.width)) {\n state.ownedWidth = ownInlineSize(\n canvas,\n 'width',\n before.width,\n state.ownedWidth,\n );\n }\n if (!nearlyEqual(after.height, before.height)) {\n state.ownedHeight = ownInlineSize(\n canvas,\n 'height',\n before.height,\n state.ownedHeight,\n );\n }\n const stabilized = readCanvasContentBox(canvas);\n if (setDisplaySize(state, stabilized)) {\n snapshot = resolveSurface(state.config, stabilized, state.pixelRatio);\n state.snapshot = snapshot;\n if (!snapshot) return undefined;\n if (\n canvas.width !== snapshot.backingWidth ||\n canvas.height !== snapshot.backingHeight\n ) {\n canvas.width = snapshot.backingWidth;\n canvas.height = snapshot.backingHeight;\n }\n }\n }\n return snapshot;\n}\n\nexport function readCanvasContentBox(\n canvas: HTMLCanvasElement,\n): SurfaceDisplaySize {\n
|
|
5
|
-
"mappings": "AACA,SAAS,cAAc;AACvB,SAAS,oBAAoB,sBAAsB;AAQnD,SAAS,6BAA6B;AAE/B,SAAS,uBACd,QACA,QACkB;AAClB,QAAM,WAAW,sBAAsB,QAAQ,MAAM;AACrD,SAAO;AAAA,IACL,MAAM;AAAA,IACN,QAAQ;AAAA,IACR,SAAS,qBAAqB,MAAM;AAAA,IACpC,YAAY,wBAAwB,SAAS,UAAU;AAAA,IACvD,UAAU;AAAA,IACV,YAAY;AAAA,IACZ,aAAa;AAAA,EACf;AACF;AAEO,SAAS,8BACd,OACA,QACmB;AACnB,SAAO;AAAA,IACL,MAAM;AAAA,IACN,SAAS;AAAA,IACT,UAAU,mBAAmB,OAAO,QAAQ,GAAG,CAAC;AAAA,EAClD;AACF;AAEO,SAAS,iBACd,UACA,QACM;AACN,QAAM,QAAQ,SAAS;AACvB,MAAI,MAAM,SAAS,OAAQ;AAE3B,MAAI,OAAO,mBAAmB,YAAY;AACxC,UAAM,IAAI,MAAM,0DAA0D;AAAA,EAC5E;AAEA,QAAM,iBAAiB,IAAI,eAAe,MAAM;AAC9C,UAAM,UAAU,qBAAqB,MAAM;AAC3C,QAAI,eAAe,OAAO,OAAO,GAAG;AAClC,aAAO,MAAM;AAAA,IACf;AAAA,EACF,CAAC;AACD,iBAAe,QAAQ,MAAM;AAC7B,WAAS,cAAc,IAAI,MAAM,eAAe,WAAW,CAAC;AAE5D,WAAS,cAAc,IAAI,MAAM;AAC/B,qBAAiB,QAAQ,SAAS,M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Ae,MAAM,QAAQ,YAAY,MAAM,UAAU;AACpE,YAAM,WAAW;AACjB,UAAI,CAAC,SAAU,QAAO;AACtB,UACE,OAAO,UAAU,SAAS,gBAC1B,OAAO,WAAW,SAAS,eAC3B;AACA,eAAO,QAAQ,SAAS;AACxB,eAAO,SAAS,SAAS;AAAA,MAC3B;AAAA,IACF;AAAA,EACF;AACA,SAAO;AACT;AAEO,SAAS,qBACd,QACoB;
|
|
4
|
+
"sourcesContent": ["import type { PibblInstance } from '../types.js';\nimport { update } from '../update.js';\nimport { createLayerSurface, resolveSurface } from './resolve-surface.js';\nimport type {\n PibblConfig,\n PibblSurfaceSnapshot,\n LayerSurfaceState,\n RootSurfaceState,\n SurfaceDisplaySize,\n} from './types.js';\nimport { validateSurfaceConfig } from './resolve-surface.js';\n\nexport function createRootSurfaceState(\n canvas: HTMLCanvasElement,\n config?: PibblConfig,\n): RootSurfaceState {\n const resolved = validateSurfaceConfig(canvas, config);\n return {\n kind: 'root',\n config: resolved,\n display: readCanvasContentBox(canvas),\n pixelRatio: readRequestedPixelRatio(resolved.pixelRatio),\n snapshot: undefined,\n ownedWidth: undefined,\n ownedHeight: undefined,\n };\n}\n\nexport function createLegacyLayerSurfaceState(\n width: number,\n height: number,\n): LayerSurfaceState {\n return {\n kind: 'layer',\n managed: false,\n snapshot: createLayerSurface(width, height, 1, 1),\n };\n}\n\nexport function mountRootSurface(\n instance: PibblInstance,\n canvas: HTMLCanvasElement,\n): void {\n const state = instance.surface;\n if (state.kind !== 'root') return;\n\n if (typeof ResizeObserver !== 'function') {\n throw new Error('Pibbl requires ResizeObserver for Canvas surface sizing.');\n }\n\n const resizeObserver = new ResizeObserver(() => {\n const display = readCanvasContentBox(canvas);\n if (setDisplaySize(state, display)) {\n update(canvas);\n }\n });\n resizeObserver.observe(canvas);\n instance.mainTeardowns.add(() => resizeObserver.disconnect());\n\n instance.mainTeardowns.add(() => {\n restoreOwnedSize(canvas, 'width', state.ownedWidth);\n restoreOwnedSize(canvas, 'height', state.ownedHeight);\n });\n\n if (state.config.pixelRatio === 'device') {\n mountDensityObservers(instance, canvas, state);\n }\n}\n\nexport function prepareSurface(\n instance: PibblInstance,\n): PibblSurfaceSnapshot | undefined {\n const state = instance.surface;\n if (state.kind === 'layer') {\n if (!state.managed) {\n state.snapshot = createLayerSurface(\n instance.canvas.width,\n instance.canvas.height,\n 1,\n 1,\n );\n }\n return state.snapshot;\n }\n\n const canvas = instance.canvas as HTMLCanvasElement;\n state.display = readCanvasContentBox(canvas);\n if (state.config.pixelRatio === 'device') {\n state.pixelRatio = readRequestedPixelRatio('device');\n }\n let snapshot = resolveSurface(state.config, state.display, state.pixelRatio);\n state.snapshot = snapshot;\n if (!snapshot) return undefined;\n\n const before = state.display;\n const dimensionsChanged = canvas.width !== snapshot.backingWidth ||\n canvas.height !== snapshot.backingHeight;\n if (dimensionsChanged) {\n canvas.width = snapshot.backingWidth;\n canvas.height = snapshot.backingHeight;\n const after = readCanvasContentBox(canvas);\n if (!nearlyEqual(after.width, before.width)) {\n state.ownedWidth = ownInlineSize(\n canvas,\n 'width',\n before.width,\n state.ownedWidth,\n );\n }\n if (!nearlyEqual(after.height, before.height)) {\n state.ownedHeight = ownInlineSize(\n canvas,\n 'height',\n before.height,\n state.ownedHeight,\n );\n }\n const stabilized = readCanvasContentBox(canvas);\n if (setDisplaySize(state, stabilized)) {\n snapshot = resolveSurface(state.config, stabilized, state.pixelRatio);\n state.snapshot = snapshot;\n if (!snapshot) return undefined;\n if (\n canvas.width !== snapshot.backingWidth ||\n canvas.height !== snapshot.backingHeight\n ) {\n canvas.width = snapshot.backingWidth;\n canvas.height = snapshot.backingHeight;\n }\n }\n }\n return snapshot;\n}\n\nexport function readCanvasContentBox(\n canvas: HTMLCanvasElement,\n): SurfaceDisplaySize {\n // A shared page transform changes the screen bounding rectangle, not the\n // Canvas CSS content box. Resolved CSS sizes retain local fractional lengths.\n // Hidden ancestors have no layout box even when computed width remains set.\n if (canvas.getClientRects().length === 0) return { width: 0, height: 0 };\n const style = getComputedStyle(canvas);\n const borderBox = style.boxSizing === 'border-box';\n return {\n width: Math.max(0, pixelValue(style.width) - (borderBox ? boxInsets(style, 'width') : 0)),\n height: Math.max(0, pixelValue(style.height) - (borderBox ? boxInsets(style, 'height') : 0)),\n };\n}\n\nfunction mountDensityObservers(\n instance: PibblInstance,\n canvas: HTMLCanvasElement,\n state: RootSurfaceState,\n): void {\n let mediaQuery: MediaQueryList | undefined;\n let closed = false;\n const onDensityChange = () => {\n if (closed) return;\n const next = readRequestedPixelRatio('device');\n bindMediaQuery(next);\n if (next !== state.pixelRatio) {\n state.pixelRatio = next;\n update(canvas);\n }\n };\n const bindMediaQuery = (ratio: number) => {\n mediaQuery?.removeEventListener('change', onDensityChange);\n mediaQuery = matchMedia(`(resolution: ${ratio}dppx)`);\n mediaQuery.addEventListener('change', onDensityChange);\n };\n\n bindMediaQuery(state.pixelRatio);\n window.addEventListener('resize', onDensityChange);\n instance.mainTeardowns.add(() => {\n closed = true;\n mediaQuery?.removeEventListener('change', onDensityChange);\n window.removeEventListener('resize', onDensityChange);\n });\n}\n\nfunction readRequestedPixelRatio(requested: 'device' | number): number {\n if (requested !== 'device') return requested;\n const ratio = window.devicePixelRatio;\n return Number.isFinite(ratio) && ratio > 0 ? ratio : 1;\n}\n\nfunction setDisplaySize(\n state: RootSurfaceState,\n display: SurfaceDisplaySize,\n): boolean {\n if (\n nearlyEqual(state.display.width, display.width) &&\n nearlyEqual(state.display.height, display.height)\n ) {\n return false;\n }\n state.display = display;\n return true;\n}\n\nfunction ownInlineSize(\n canvas: HTMLCanvasElement,\n property: 'width' | 'height',\n value: number,\n current: RootSurfaceState['ownedWidth'],\n) {\n const style = getComputedStyle(canvas);\n const owned = `${value + (style.boxSizing === 'border-box' ? boxInsets(style, property) : 0)}px`;\n const previous = current?.previous ?? canvas.style[property];\n canvas.style[property] = owned;\n return { previous, owned };\n}\n\nfunction restoreOwnedSize(\n canvas: HTMLCanvasElement,\n property: 'width' | 'height',\n record: RootSurfaceState['ownedWidth'],\n): void {\n if (record && canvas.style[property] === record.owned) {\n canvas.style[property] = record.previous;\n }\n}\n\nfunction boxInsets(\n style: CSSStyleDeclaration,\n axis: 'width' | 'height',\n): number {\n return axis === 'width'\n ? pixelValue(style.borderLeftWidth) + pixelValue(style.borderRightWidth) + pixelValue(style.paddingLeft) + pixelValue(style.paddingRight)\n : pixelValue(style.borderTopWidth) + pixelValue(style.borderBottomWidth) + pixelValue(style.paddingTop) + pixelValue(style.paddingBottom);\n}\n\nfunction pixelValue(value: string): number {\n return Number.parseFloat(value) || 0;\n}\n\nfunction nearlyEqual(left: number, right: number): boolean {\n return Math.abs(left - right) < 0.01;\n}\n"],
|
|
5
|
+
"mappings": "AACA,SAAS,cAAc;AACvB,SAAS,oBAAoB,sBAAsB;AAQnD,SAAS,6BAA6B;AAE/B,SAAS,uBACd,QACA,QACkB;AAClB,QAAM,WAAW,sBAAsB,QAAQ,MAAM;AACrD,SAAO;AAAA,IACL,MAAM;AAAA,IACN,QAAQ;AAAA,IACR,SAAS,qBAAqB,MAAM;AAAA,IACpC,YAAY,wBAAwB,SAAS,UAAU;AAAA,IACvD,UAAU;AAAA,IACV,YAAY;AAAA,IACZ,aAAa;AAAA,EACf;AACF;AAEO,SAAS,8BACd,OACA,QACmB;AACnB,SAAO;AAAA,IACL,MAAM;AAAA,IACN,SAAS;AAAA,IACT,UAAU,mBAAmB,OAAO,QAAQ,GAAG,CAAC;AAAA,EAClD;AACF;AAEO,SAAS,iBACd,UACA,QACM;AACN,QAAM,QAAQ,SAAS;AACvB,MAAI,MAAM,SAAS,OAAQ;AAE3B,MAAI,OAAO,mBAAmB,YAAY;AACxC,UAAM,IAAI,MAAM,0DAA0D;AAAA,EAC5E;AAEA,QAAM,iBAAiB,IAAI,eAAe,MAAM;AAC9C,UAAM,UAAU,qBAAqB,MAAM;AAC3C,QAAI,eAAe,OAAO,OAAO,GAAG;AAClC,aAAO,MAAM;AAAA,IACf;AAAA,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D,SAAO,KAAK,IAAI,OAAO,KAAK,IAAI;AAClC;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -9,6 +9,13 @@ import { signal } from "../signals/graph.js";
|
|
|
9
9
|
import {
|
|
10
10
|
registerTexturePaint
|
|
11
11
|
} from "./texture-protocol.js";
|
|
12
|
+
const placementKeys = [
|
|
13
|
+
"tileWidth",
|
|
14
|
+
"tileHeight",
|
|
15
|
+
"offsetX",
|
|
16
|
+
"offsetY",
|
|
17
|
+
"rotation"
|
|
18
|
+
];
|
|
12
19
|
const recipes = /* @__PURE__ */ new WeakMap();
|
|
13
20
|
function defineTexture(definition) {
|
|
14
21
|
const stable = Object.freeze({ ...definition });
|
|
@@ -24,13 +31,8 @@ function defineTexture(definition) {
|
|
|
24
31
|
function placement(value = {}) {
|
|
25
32
|
if (value.mode !== void 0 && value.mode !== "repeat" && value.mode !== "stretch")
|
|
26
33
|
throw new TypeError("Unknown texture placement mode.");
|
|
27
|
-
for (
|
|
28
|
-
|
|
29
|
-
"tileHeight",
|
|
30
|
-
"offsetX",
|
|
31
|
-
"offsetY",
|
|
32
|
-
"rotation"
|
|
33
|
-
]) {
|
|
34
|
+
for (let keyIndex = 0; keyIndex < placementKeys.length; keyIndex++) {
|
|
35
|
+
const key = placementKeys[keyIndex];
|
|
34
36
|
const n = value[key];
|
|
35
37
|
if (n !== void 0 && (!Number.isFinite(n) || (key === "tileWidth" || key === "tileHeight") && n <= 0))
|
|
36
38
|
throw new RangeError(`Invalid texture placement ${key}.`);
|
|
@@ -39,7 +41,7 @@ function placement(value = {}) {
|
|
|
39
41
|
}
|
|
40
42
|
function dimensions(options) {
|
|
41
43
|
const width = options.resolution?.width ?? 256, height = options.resolution?.height ?? 160;
|
|
42
|
-
if (!
|
|
44
|
+
if (!(Number.isInteger(width) && width >= 8 && width <= 1024 && Number.isInteger(height) && height >= 8 && height <= 1024) || width * height > 262144)
|
|
43
45
|
throw new RangeError(
|
|
44
46
|
"Texture resolution must be 8..1024 cells per axis, at most 262144 cells."
|
|
45
47
|
);
|