@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
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
import { isSignal } from "../lib/signals/graph.js";
|
|
2
|
+
import { layoutDiagnostic } from "../lib/style/diagnostics.js";
|
|
3
|
+
import {
|
|
4
|
+
PIBBL_FILTER_EXECUTOR
|
|
5
|
+
} from "../lib/style/filter-types.js";
|
|
6
|
+
import {
|
|
7
|
+
borrowTextureRaster,
|
|
8
|
+
validateTexturePaint
|
|
9
|
+
} from "../lib/textures/texture-protocol.js";
|
|
10
|
+
import {
|
|
11
|
+
filterBoundaryExecutor
|
|
12
|
+
} from "./filter-executor.js";
|
|
13
|
+
import { processEmboss } from "./render-emboss-boundary.js";
|
|
14
|
+
const definitions = /* @__PURE__ */ new WeakMap();
|
|
15
|
+
const executor = {
|
|
16
|
+
prepare(value, property, context) {
|
|
17
|
+
const definition = definitions.get(value);
|
|
18
|
+
if (!definition)
|
|
19
|
+
throw new Error(
|
|
20
|
+
"An emboss filter was created by an incompatible Pibbl runtime."
|
|
21
|
+
);
|
|
22
|
+
const { options } = definition;
|
|
23
|
+
const fail = (key, value2, reason) => layoutDiagnostic({
|
|
24
|
+
component: context.component,
|
|
25
|
+
property: `${property}.${key}`,
|
|
26
|
+
value: value2,
|
|
27
|
+
algorithm: context.algorithm,
|
|
28
|
+
constraints: context.constraints,
|
|
29
|
+
reason
|
|
30
|
+
});
|
|
31
|
+
const numeric = (key, fallback, maximum) => {
|
|
32
|
+
const input = options[key];
|
|
33
|
+
const value2 = input === void 0 ? fallback : isSignal(input) ? input.get() : input;
|
|
34
|
+
if (typeof value2 !== "number" || !Number.isFinite(value2) || value2 < 0 || value2 > maximum)
|
|
35
|
+
throw fail(key, value2, `must be finite within 0..${maximum}`);
|
|
36
|
+
return value2;
|
|
37
|
+
};
|
|
38
|
+
const depth = numeric("depth", 3, 32), strength = numeric("strength", 1, 1);
|
|
39
|
+
const direction = options.direction ?? [-0.6, -0.8];
|
|
40
|
+
if (!Array.isArray(direction) || direction.length !== 2 || !direction.every(
|
|
41
|
+
(value2) => typeof value2 === "number" && Number.isFinite(value2)
|
|
42
|
+
) || Math.hypot(...direction) === 0)
|
|
43
|
+
throw fail(
|
|
44
|
+
"direction",
|
|
45
|
+
direction,
|
|
46
|
+
"must contain two finite components with nonzero length"
|
|
47
|
+
);
|
|
48
|
+
const length = Math.hypot(...direction);
|
|
49
|
+
const candidate = options.region;
|
|
50
|
+
if (!candidate || typeof candidate !== "object")
|
|
51
|
+
throw fail(
|
|
52
|
+
"region",
|
|
53
|
+
candidate,
|
|
54
|
+
"must contain finite coordinates and positive dimensions"
|
|
55
|
+
);
|
|
56
|
+
const { x, y, width, height } = candidate;
|
|
57
|
+
if (!(typeof x === "number" && Number.isFinite(x) && typeof y === "number" && Number.isFinite(y) && typeof width === "number" && Number.isFinite(width) && typeof height === "number" && Number.isFinite(height)) || width <= 0 || height <= 0)
|
|
58
|
+
throw fail(
|
|
59
|
+
"region",
|
|
60
|
+
candidate,
|
|
61
|
+
"must contain finite coordinates and positive dimensions"
|
|
62
|
+
);
|
|
63
|
+
const region = { x, y, width, height };
|
|
64
|
+
const map = isSignal(definition.map) ? definition.map.get() : definition.map;
|
|
65
|
+
try {
|
|
66
|
+
validateTexturePaint(map);
|
|
67
|
+
if (strength !== 0 && depth !== 0)
|
|
68
|
+
borrowTextureRaster(map, () => void 0);
|
|
69
|
+
} catch (error) {
|
|
70
|
+
throw fail(
|
|
71
|
+
"map",
|
|
72
|
+
map,
|
|
73
|
+
error instanceof Error ? error.message : String(error)
|
|
74
|
+
);
|
|
75
|
+
}
|
|
76
|
+
const settings = {
|
|
77
|
+
opacity: strength,
|
|
78
|
+
depth,
|
|
79
|
+
threshold: 0,
|
|
80
|
+
softness: 1,
|
|
81
|
+
direction: [direction[0] / length, direction[1] / length]
|
|
82
|
+
};
|
|
83
|
+
return Object.freeze({
|
|
84
|
+
executor: filterBoundaryExecutor,
|
|
85
|
+
reverseInfluence: (output) => ({ ...output }),
|
|
86
|
+
process: strength === 0 || depth === 0 ? void 0 : (source, windows) => processEmboss(source, windows, map, settings, region)
|
|
87
|
+
});
|
|
88
|
+
},
|
|
89
|
+
render: filterBoundaryExecutor.render
|
|
90
|
+
};
|
|
91
|
+
function emboss(map, options) {
|
|
92
|
+
const frozen = Object.freeze({
|
|
93
|
+
...options,
|
|
94
|
+
region: Object.freeze({ ...options.region }),
|
|
95
|
+
direction: options.direction && Object.freeze([...options.direction])
|
|
96
|
+
});
|
|
97
|
+
const value = Object.freeze({ [PIBBL_FILTER_EXECUTOR]: executor });
|
|
98
|
+
definitions.set(value, { map, options: frozen });
|
|
99
|
+
return value;
|
|
100
|
+
}
|
|
101
|
+
export {
|
|
102
|
+
emboss
|
|
103
|
+
};
|
|
104
|
+
//# sourceMappingURL=emboss.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../src/filters/emboss.ts"],
|
|
4
|
+
"sourcesContent": ["import { isSignal } from \"../lib/signals/graph.js\";\nimport type { SignalValue } from \"../lib/signals/types.js\";\nimport { layoutDiagnostic } from \"../lib/style/diagnostics.js\";\nimport {\n PIBBL_FILTER_EXECUTOR,\n type PibblFilter,\n type PibblFilterExecutor,\n} from \"../lib/style/filter-types.js\";\nimport {\n borrowTextureRaster,\n validateTexturePaint,\n type TexturePaint,\n} from \"../lib/textures/texture-protocol.js\";\nimport {\n filterBoundaryExecutor,\n type CustomPreparedFilter,\n} from \"./filter-executor.js\";\nimport { processEmboss } from \"./render-emboss-boundary.js\";\n\n/** Directional lighting of grayscale texture height. See {@link emboss}. */\nexport interface PibblEmbossFilterOptions {\n /** Local texture placement region with finite coordinates and positive dimensions. See {@link TexturePaint}. */\n readonly region: Readonly<{\n /** Horizontal origin in local logical coordinates. See {@link PibblEmbossFilterOptions}. */\n x: number;\n /** Vertical origin in local logical coordinates. See {@link PibblEmbossFilterOptions}. */\n y: number;\n /** Positive logical region width. See {@link PibblEmbossFilterOptions}. */\n width: number;\n /** Positive logical region height. See {@link PibblEmbossFilterOptions}. */\n height: number;\n }>;\n /** Height range in logical pixels, finite 0\u201332; default 3. See {@link emboss}. */\n readonly depth?: SignalValue<number>;\n /** Lighting strength, finite 0\u20131; default 1. Zero bypasses processing. See {@link emboss}. */\n readonly strength?: SignalValue<number>;\n /** Nonzero finite direction toward the light in local coordinates; default [-0.6, -0.8]. See {@link emboss}. */\n readonly direction?: readonly [number, number];\n}\nconst definitions = new WeakMap<\n PibblFilter,\n {\n map: SignalValue<TexturePaint>;\n options: Readonly<PibblEmbossFilterOptions>;\n }\n>();\nconst executor: PibblFilterExecutor = {\n prepare(value, property, context) {\n const definition = definitions.get(value);\n if (!definition)\n throw new Error(\n \"An emboss filter was created by an incompatible Pibbl runtime.\",\n );\n const { options } = definition;\n const fail = (key: string, value: unknown, reason: string) =>\n layoutDiagnostic({\n component: context.component,\n property: `${property}.${key}`,\n value,\n algorithm: context.algorithm,\n constraints: context.constraints,\n reason,\n });\n const numeric = (\n key: \"depth\" | \"strength\",\n fallback: number,\n maximum: number,\n ) => {\n const input = options[key];\n const value =\n input === undefined ? fallback : isSignal(input) ? input.get() : input;\n if (\n typeof value !== \"number\" ||\n !Number.isFinite(value) ||\n value < 0 ||\n value > maximum\n )\n throw fail(key, value, `must be finite within 0..${maximum}`);\n return value;\n };\n const depth = numeric(\"depth\", 3, 32),\n strength = numeric(\"strength\", 1, 1);\n const direction: unknown = options.direction ?? [-0.6, -0.8];\n if (\n !Array.isArray(direction) ||\n direction.length !== 2 ||\n !direction.every(\n (value) => typeof value === \"number\" && Number.isFinite(value),\n ) ||\n Math.hypot(...direction) === 0\n )\n throw fail(\n \"direction\",\n direction,\n \"must contain two finite components with nonzero length\",\n );\n const length = Math.hypot(...direction);\n const candidate: unknown = options.region;\n if (!candidate || typeof candidate !== \"object\")\n throw fail(\n \"region\",\n candidate,\n \"must contain finite coordinates and positive dimensions\",\n );\n const { x, y, width, height } = candidate as {\n x: number;\n y: number;\n width: number;\n height: number;\n };\n if (\n !(\n typeof x === \"number\" &&\n Number.isFinite(x) &&\n typeof y === \"number\" &&\n Number.isFinite(y) &&\n typeof width === \"number\" &&\n Number.isFinite(width) &&\n typeof height === \"number\" &&\n Number.isFinite(height)\n ) ||\n width <= 0 ||\n height <= 0\n )\n throw fail(\n \"region\",\n candidate,\n \"must contain finite coordinates and positive dimensions\",\n );\n const region = { x, y, width, height };\n const map = isSignal(definition.map)\n ? definition.map.get()\n : definition.map;\n try {\n validateTexturePaint(map);\n if (strength !== 0 && depth !== 0)\n borrowTextureRaster(map, () => undefined);\n } catch (error) {\n throw fail(\n \"map\",\n map,\n error instanceof Error ? error.message : String(error),\n );\n }\n const settings = {\n opacity: strength,\n depth,\n threshold: 0,\n softness: 1,\n direction: [direction[0] / length, direction[1] / length] as const,\n };\n return Object.freeze({\n executor: filterBoundaryExecutor,\n reverseInfluence: (output) => ({ ...output }),\n process:\n strength === 0 || depth === 0\n ? undefined\n : (source, windows) =>\n processEmboss(source, windows, map, settings, region),\n } satisfies CustomPreparedFilter);\n },\n render: filterBoundaryExecutor.render,\n};\n/**\n * Lights captured pixels using normals derived from a grayscale texture height map.\n * Flat heights are neutral; opposing slopes brighten and darken without changing alpha or geometry.\n * @param map - Mounted height texture, luminance times alpha; white is high. See {@link TexturePaint}.\n * @param options - Local placement, height depth, strength, and light direction. See {@link PibblEmbossFilterOptions}.\n * @returns A filter descriptor for style.filter. See {@link PibblFilter}.\n * @see {@link PibblEmbossFilterOptions}\n */\nexport function emboss(\n map: SignalValue<TexturePaint>,\n options: PibblEmbossFilterOptions,\n): PibblFilter {\n const frozen = Object.freeze({\n ...options,\n region: Object.freeze({ ...options.region }),\n direction:\n options.direction &&\n (Object.freeze([...options.direction]) as readonly [number, number]),\n });\n const value = Object.freeze({ [PIBBL_FILTER_EXECUTOR]: executor });\n definitions.set(value, { map, options: frozen });\n return value;\n}\n"],
|
|
5
|
+
"mappings": "AAAA,SAAS,gBAAgB;AAEzB,SAAS,wBAAwB;AACjC;AAAA,EACE;AAAA,OAGK;AACP;AAAA,EACE;AAAA,EACA;AAAA,OAEK;AACP;AAAA,EACE;AAAA,OAEK;AACP,SAAS,qBAAqB;AAsB9B,MAAM,cAAc,oBAAI,QAMtB;AACF,MAAM,WAAgC;AAAA,EACpC,QAAQ,OAAO,UAAU,SAAS;AAChC,UAAM,aAAa,YAAY,IAAI,KAAK;AACxC,QAAI,CAAC;AACH,YAAM,IAAI;AAAA,QACR;AAAA,MACF;AACF,UAAM,EAAE,QAAQ,IAAI;AACpB,UAAM,OAAO,CAAC,KAAaA,QAAgB,WACzC,iBAAiB;AAAA,MACf,WAAW,QAAQ;AAAA,MACnB,UAAU,GAAG,QAAQ,IAAI,GAAG;AAAA,MAC5B,OAAAA;AAAA,MACA,WAAW,QAAQ;AAAA,MACnB,aAAa,QAAQ;AAAA,MACrB;AAAA,IACF,CAAC;AACH,UAAM,UAA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WAAW;AACf,QAAI;AACF,2BAAqB,GAAG;AACxB,UAAI,aAAa,KAAK,UAAU;AAC9B,4BAAoB,KAAK,MAAM,MAAS;AAAA,IAC5C,SAAS,OAAO;AACd,YAAM;AAAA,QACJ;AAAA,QACA;AAAA,QACA,iBAAiB,QAAQ,MAAM,UAAU,OAAO,KAAK;AAAA,MACvD;AAAA,IACF;AACA,UAAM,WAAW;AAAA,MACf,SAAS;AAAA,MACT;AAAA,MACA,WAAW;AAAA,MACX,UAAU;AAAA,MACV,WAAW,CAAC,UAAU,CAAC,IAAI,QAAQ,UAAU,CAAC,IAAI,MAAM;AAAA,IAC1D;AACA,WAAO,OAAO,OAAO;AAAA,MACnB,UAAU;AAAA,MACV,kBAAkB,CAAC,YAAY,EAAE,GAAG,OAAO;AAAA,MAC3C,SACE,aAAa,KAAK,UAAU,IACxB,SACA,CAAC,QAAQ,YACP,cAAc,QAAQ,SAAS,KAAK,UAAU,MAAM;AAAA,IAC9D,CAAgC;AAAA,EAClC;AAAA,EACA,QAAQ,uBAAuB;AACjC;AASO,SAAS,OACd,KACA,SACa;AACb,QAAM,SAAS,OAAO,OAAO;AAAA,IAC3B,GAAG;AAAA,IACH,QAAQ,OAAO,OAAO,EAAE,GAAG,QAAQ,OAAO,CAAC;AAAA,IAC3C,WACE,QAAQ,aACP,OAAO,OAAO,CAAC,GAAG,QAAQ,SAAS,CAAC;AAAA,EACzC,CAAC;AACD,QAAM,QAAQ,OAAO,OAAO,EAAE,CAAC,qBAAqB,GAAG,SAAS,CAAC;AACjE,cAAY,IAAI,OAAO,EAAE,KAAK,SAAS,OAAO,CAAC;AAC/C,SAAO;AACT;",
|
|
6
|
+
"names": ["value"]
|
|
7
|
+
}
|
|
@@ -1,6 +1,12 @@
|
|
|
1
|
-
import type { TexturePaint } from
|
|
2
|
-
import type {
|
|
3
|
-
import type {
|
|
1
|
+
import type { TexturePaint } from "../lib/textures/texture-protocol.js";
|
|
2
|
+
import type { Canvas } from "../lib/types.js";
|
|
3
|
+
import type { FilterWindows, PixelBounds } from "../lib/filter/filter-region.js";
|
|
4
|
+
import type { PibblFilterBoundaryExecutor, PreparedPibblFilter } from "../lib/style/filter-types.js";
|
|
5
|
+
/** Backing-pixel projection of the already-painted current render target. */
|
|
6
|
+
export interface FilterBackdrop {
|
|
7
|
+
readonly canvas: Canvas;
|
|
8
|
+
readonly transform: DOMMatrix;
|
|
9
|
+
}
|
|
4
10
|
/** An operation-owned pass. The shared executor knows nothing about its inputs. */
|
|
5
11
|
export interface CustomPreparedFilter extends PreparedPibblFilter {
|
|
6
12
|
readonly reverseInfluence: (output: Readonly<PixelBounds>, density: number) => PixelBounds;
|
|
@@ -16,6 +22,7 @@ export interface CustomPreparedFilter extends PreparedPibblFilter {
|
|
|
16
22
|
}>;
|
|
17
23
|
}>;
|
|
18
24
|
readonly fuseWithPrevious?: (previous: CustomPreparedFilter) => CustomPreparedFilter | undefined;
|
|
19
|
-
readonly
|
|
25
|
+
readonly needsBackdrop?: boolean;
|
|
26
|
+
readonly process?: (source: OffscreenCanvas, windows: FilterWindows, backdrop?: FilterBackdrop) => ImageBitmap;
|
|
20
27
|
}
|
|
21
28
|
export declare const filterBoundaryExecutor: PibblFilterBoundaryExecutor;
|
|
@@ -1,8 +1,11 @@
|
|
|
1
1
|
import { GLOBAL_STATE } from "../lib/global-state.js";
|
|
2
2
|
import { getOptionalService } from "../lib/optional-services.js";
|
|
3
|
+
import { getCurrentPaintTransform } from "../lib/render-target.js";
|
|
3
4
|
import { enterPrimitivePresentation } from "../lib/primitive-presentation.js";
|
|
4
5
|
import { renderFilterBoundary } from "../lib/filter/render-filter-boundary.js";
|
|
5
|
-
import {
|
|
6
|
+
import {
|
|
7
|
+
compileNativeFilters
|
|
8
|
+
} from "./native-operations.js";
|
|
6
9
|
import { assertNativeCanvasFilter } from "./native-canvas-filter.js";
|
|
7
10
|
const SCRATCH = /* @__PURE__ */ Symbol("pibbl.filter-pass-scratch");
|
|
8
11
|
class PassScratch {
|
|
@@ -24,11 +27,17 @@ class PassScratch {
|
|
|
24
27
|
if (success || !this.committed) this.dispose();
|
|
25
28
|
}
|
|
26
29
|
target(index, width, height) {
|
|
27
|
-
const canvas = this.surfaces[index] ??= new OffscreenCanvas(
|
|
30
|
+
const canvas = this.surfaces[index] ??= new OffscreenCanvas(
|
|
31
|
+
width,
|
|
32
|
+
height
|
|
33
|
+
);
|
|
28
34
|
if (canvas.width !== width) canvas.width = width;
|
|
29
35
|
if (canvas.height !== height) canvas.height = height;
|
|
30
36
|
const context = canvas.getContext("2d");
|
|
31
|
-
if (!context)
|
|
37
|
+
if (!context)
|
|
38
|
+
throw new Error(
|
|
39
|
+
"Filter passes require an OffscreenCanvas 2D scratch target."
|
|
40
|
+
);
|
|
32
41
|
context.reset();
|
|
33
42
|
return context;
|
|
34
43
|
}
|
|
@@ -60,58 +69,104 @@ const filterBoundaryExecutor = {
|
|
|
60
69
|
}
|
|
61
70
|
return;
|
|
62
71
|
}
|
|
63
|
-
if (operations.every(
|
|
64
|
-
|
|
72
|
+
if (operations.every(
|
|
73
|
+
(operation) => "css" in operation
|
|
74
|
+
)) {
|
|
75
|
+
renderFilterBoundary(
|
|
76
|
+
{
|
|
77
|
+
component: input.component,
|
|
78
|
+
filters: operations,
|
|
79
|
+
presentation: input.presentation
|
|
80
|
+
},
|
|
81
|
+
input.renderSubtree
|
|
82
|
+
);
|
|
65
83
|
return;
|
|
66
84
|
}
|
|
67
|
-
const
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
const
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
const bitmap = operation.process(current, windows);
|
|
103
|
-
try {
|
|
85
|
+
const parent = operations.some(
|
|
86
|
+
(operation) => "needsBackdrop" in operation && operation.needsBackdrop
|
|
87
|
+
) ? GLOBAL_STATE.renderContext : void 0;
|
|
88
|
+
const parentTarget = parent ? GLOBAL_STATE.renderTarget : void 0;
|
|
89
|
+
const paint = parent ? getCurrentPaintTransform() : void 0;
|
|
90
|
+
const boundaryPaint = paint && input.presentation?.transform ? paint.multiply(input.presentation.transform) : paint;
|
|
91
|
+
const bounds = operations.map(
|
|
92
|
+
(operation) => "css" in operation ? operation : {
|
|
93
|
+
executor: filterBoundaryExecutor,
|
|
94
|
+
css: () => "none",
|
|
95
|
+
reverseInfluence: operation.reverseInfluence
|
|
96
|
+
}
|
|
97
|
+
);
|
|
98
|
+
renderFilterBoundary(
|
|
99
|
+
{
|
|
100
|
+
component: input.component,
|
|
101
|
+
filters: bounds,
|
|
102
|
+
presentation: input.presentation,
|
|
103
|
+
process(source, result, windows) {
|
|
104
|
+
const instance = GLOBAL_STATE.currentPibblInstance;
|
|
105
|
+
if (!instance)
|
|
106
|
+
throw new Error(
|
|
107
|
+
"Filter processing requires an active Pibbl instance."
|
|
108
|
+
);
|
|
109
|
+
const scratch = getOptionalService(
|
|
110
|
+
instance,
|
|
111
|
+
SCRATCH,
|
|
112
|
+
() => new PassScratch(instance)
|
|
113
|
+
);
|
|
114
|
+
scratch.used = true;
|
|
115
|
+
let current = source, pass = 0;
|
|
116
|
+
let native = [];
|
|
117
|
+
const target = () => scratch.target(pass++ % 2, source.width, source.height);
|
|
118
|
+
const applyNative = () => {
|
|
119
|
+
if (!native.length) return;
|
|
104
120
|
const context = target();
|
|
105
|
-
|
|
121
|
+
assertNativeCanvasFilter(
|
|
122
|
+
context,
|
|
123
|
+
compileNativeFilters(native, windows.density),
|
|
124
|
+
input.component,
|
|
125
|
+
() => {
|
|
126
|
+
for (const operation of native)
|
|
127
|
+
if (operation.onRejected) {
|
|
128
|
+
assertNativeCanvasFilter(
|
|
129
|
+
context,
|
|
130
|
+
operation.css(windows.density),
|
|
131
|
+
input.component,
|
|
132
|
+
operation.onRejected
|
|
133
|
+
);
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
);
|
|
137
|
+
context.drawImage(current, 0, 0);
|
|
106
138
|
current = context.canvas;
|
|
107
|
-
|
|
108
|
-
|
|
139
|
+
native = [];
|
|
140
|
+
};
|
|
141
|
+
for (const operation of operations) {
|
|
142
|
+
if ("css" in operation) {
|
|
143
|
+
native.push(operation);
|
|
144
|
+
continue;
|
|
145
|
+
}
|
|
146
|
+
applyNative();
|
|
147
|
+
const backdrop = parent && parentTarget && boundaryPaint ? {
|
|
148
|
+
canvas: parent.canvas,
|
|
149
|
+
transform: windows.source.renderTransform.multiply(boundaryPaint.inverse()).multiply(parentTarget.inverseRenderTransform)
|
|
150
|
+
} : void 0;
|
|
151
|
+
const bitmap = operation.process(current, windows, backdrop);
|
|
152
|
+
try {
|
|
153
|
+
const context = target();
|
|
154
|
+
context.drawImage(bitmap, 0, 0);
|
|
155
|
+
current = context.canvas;
|
|
156
|
+
} finally {
|
|
157
|
+
bitmap.close();
|
|
158
|
+
}
|
|
109
159
|
}
|
|
160
|
+
applyNative();
|
|
161
|
+
result.drawImage(
|
|
162
|
+
current,
|
|
163
|
+
windows.sourceToOutputX,
|
|
164
|
+
windows.sourceToOutputY
|
|
165
|
+
);
|
|
110
166
|
}
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
}, input.renderSubtree);
|
|
167
|
+
},
|
|
168
|
+
input.renderSubtree
|
|
169
|
+
);
|
|
115
170
|
}
|
|
116
171
|
};
|
|
117
172
|
export {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/filters/filter-executor.ts"],
|
|
4
|
-
"sourcesContent": ["import type { TexturePaint } from
|
|
5
|
-
"mappings": "AACA,SAAS,oBAAoB;AAC7B,SAAS,0BAA0B;AACnC,SAAS,kCAAkC;AAC3C,SAAS,4BAA4B;
|
|
4
|
+
"sourcesContent": ["import type { TexturePaint } from \"../lib/textures/texture-protocol.js\";\nimport { GLOBAL_STATE } from \"../lib/global-state.js\";\nimport { getOptionalService } from \"../lib/optional-services.js\";\nimport { getCurrentPaintTransform } from \"../lib/render-target.js\";\nimport type { Canvas } from \"../lib/types.js\";\nimport { enterPrimitivePresentation } from \"../lib/primitive-presentation.js\";\nimport { renderFilterBoundary } from \"../lib/filter/render-filter-boundary.js\";\nimport type {\n FilterWindows,\n PixelBounds,\n} from \"../lib/filter/filter-region.js\";\nimport type {\n PibblFilterBoundaryExecutor,\n PreparedPibblFilter,\n} from \"../lib/style/filter-types.js\";\nimport type { PibblInstance } from \"../lib/types.js\";\nimport {\n compileNativeFilters,\n type NativePreparedFilter,\n} from \"./native-operations.js\";\nimport { assertNativeCanvasFilter } from \"./native-canvas-filter.js\";\n\n/** Backing-pixel projection of the already-painted current render target. */\nexport interface FilterBackdrop {\n readonly canvas: Canvas;\n readonly transform: DOMMatrix;\n}\n\n/** An operation-owned pass. The shared executor knows nothing about its inputs. */\nexport interface CustomPreparedFilter extends PreparedPibblFilter {\n readonly reverseInfluence: (\n output: Readonly<PixelBounds>,\n density: number,\n ) => PixelBounds;\n /** Private fusion capability; no concrete GPU implementation enters this module. */\n readonly textureWarp?: Readonly<{\n map: TexturePaint;\n strength: number;\n region: Readonly<{ x: number; y: number; width: number; height: number }>;\n }>;\n readonly fuseWithPrevious?: (\n previous: CustomPreparedFilter,\n ) => CustomPreparedFilter | undefined;\n readonly needsBackdrop?: boolean;\n readonly process?: (\n source: OffscreenCanvas,\n windows: FilterWindows,\n backdrop?: FilterBackdrop,\n ) => ImageBitmap;\n}\ntype Operation = NativePreparedFilter | CustomPreparedFilter;\nconst SCRATCH = Symbol(\"pibbl.filter-pass-scratch\");\nclass PassScratch {\n private readonly surfaces: OffscreenCanvas[] = [];\n used = false;\n private committed = false;\n constructor(private readonly instance: PibblInstance) {}\n beginRender(): void {\n this.used = false;\n }\n endRender(success: boolean): void {\n if (success && this.used) {\n this.committed = true;\n return;\n }\n if (success || !this.committed) this.dispose();\n }\n target(\n index: number,\n width: number,\n height: number,\n ): OffscreenCanvasRenderingContext2D {\n const canvas = (this.surfaces[index] ??= new OffscreenCanvas(\n width,\n height,\n ));\n if (canvas.width !== width) canvas.width = width;\n if (canvas.height !== height) canvas.height = height;\n const context = canvas.getContext(\"2d\");\n if (!context)\n throw new Error(\n \"Filter passes require an OffscreenCanvas 2D scratch target.\",\n );\n context.reset();\n return context;\n }\n dispose(): void {\n for (const canvas of this.surfaces) {\n canvas.width = 0;\n canvas.height = 0;\n }\n this.surfaces.length = 0;\n this.instance.optionalServices.delete(SCRATCH);\n }\n}\n\nexport const filterBoundaryExecutor: PibblFilterBoundaryExecutor = {\n render(input) {\n const operations: Operation[] = [];\n for (const operation of input.filters as readonly Operation[]) {\n if (!(\"css\" in operation) && !operation.process) continue;\n const previous = operations.at(-1);\n const fused =\n previous && !(\"css\" in previous) && !(\"css\" in operation)\n ? operation.fuseWithPrevious?.(previous)\n : undefined;\n if (fused) operations[operations.length - 1] = fused;\n else operations.push(operation);\n }\n if (!operations.length) {\n const release = enterPrimitivePresentation(input.presentation);\n try {\n input.renderSubtree();\n } finally {\n release();\n }\n return;\n }\n if (\n operations.every(\n (operation): operation is NativePreparedFilter => \"css\" in operation,\n )\n ) {\n renderFilterBoundary(\n {\n component: input.component,\n filters: operations,\n presentation: input.presentation,\n },\n input.renderSubtree,\n );\n return;\n }\n // Snapshot the parent projection before capture switches the current render target.\n const parent = operations.some(\n (operation) => \"needsBackdrop\" in operation && operation.needsBackdrop,\n )\n ? GLOBAL_STATE.renderContext\n : undefined;\n const parentTarget = parent ? GLOBAL_STATE.renderTarget : undefined;\n const paint = parent ? getCurrentPaintTransform() : undefined;\n const boundaryPaint =\n paint && input.presentation?.transform\n ? paint.multiply(input.presentation.transform)\n : paint;\n const bounds = operations.map((operation) =>\n \"css\" in operation\n ? operation\n : {\n executor: filterBoundaryExecutor,\n css: () => \"none\",\n reverseInfluence: operation.reverseInfluence,\n },\n );\n renderFilterBoundary(\n {\n component: input.component,\n filters: bounds,\n presentation: input.presentation,\n process(source, result, windows) {\n const instance = GLOBAL_STATE.currentPibblInstance;\n if (!instance)\n throw new Error(\n \"Filter processing requires an active Pibbl instance.\",\n );\n const scratch = getOptionalService(\n instance,\n SCRATCH,\n () => new PassScratch(instance),\n );\n scratch.used = true;\n let current = source,\n pass = 0;\n let native: NativePreparedFilter[] = [];\n const target = () =>\n scratch.target(pass++ % 2, source.width, source.height);\n const applyNative = () => {\n if (!native.length) return;\n const context = target();\n assertNativeCanvasFilter(\n context,\n compileNativeFilters(native, windows.density),\n input.component,\n () => {\n for (const operation of native)\n if (operation.onRejected) {\n assertNativeCanvasFilter(\n context,\n operation.css(windows.density),\n input.component,\n operation.onRejected,\n );\n }\n },\n );\n context.drawImage(current, 0, 0);\n current = context.canvas;\n native = [];\n };\n for (const operation of operations) {\n if (\"css\" in operation) {\n native.push(operation);\n continue;\n }\n applyNative();\n const backdrop =\n parent && parentTarget && boundaryPaint\n ? {\n canvas: parent.canvas,\n transform: windows.source.renderTransform\n .multiply(boundaryPaint.inverse())\n .multiply(parentTarget.inverseRenderTransform),\n }\n : undefined;\n const bitmap = operation.process!(current, windows, backdrop);\n try {\n const context = target();\n context.drawImage(bitmap, 0, 0);\n current = context.canvas;\n } finally {\n bitmap.close();\n }\n }\n applyNative();\n result.drawImage(\n current,\n windows.sourceToOutputX,\n windows.sourceToOutputY,\n );\n },\n },\n input.renderSubtree,\n );\n },\n};\n"],
|
|
5
|
+
"mappings": "AACA,SAAS,oBAAoB;AAC7B,SAAS,0BAA0B;AACnC,SAAS,gCAAgC;AAEzC,SAAS,kCAAkC;AAC3C,SAAS,4BAA4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AAO,SAAS,GAAG,OAAO,OAAO,OAAO,MAAM;AACxD,gBAAM,cAAc,MAAM;AACxB,gBAAI,CAAC,OAAO,OAAQ;AACpB,kBAAM,UAAU,OAAO;AACvB;AAAA,cACE;AAAA,cACA,qBAAqB,QAAQ,QAAQ,OAAO;AAAA,cAC5C,MAAM;AAAA,cACN,MAAM;AACJ,2BAAW,aAAa;AACtB,sBAAI,UAAU,YAAY;AACxB;AAAA,sBACE;AAAA,sBACA,UAAU,IAAI,QAAQ,OAAO;AAAA,sBAC7B,MAAM;AAAA,sBACN,UAAU;AAAA,oBACZ;AAAA,kBACF;AAAA,cACJ;AAAA,YACF;AACA,oBAAQ,UAAU,SAAS,GAAG,CAAC;AAC/B,sBAAU,QAAQ;AAClB,qBAAS,CAAC;AAAA,UACZ;AACA,qBAAW,aAAa,YAAY;AAClC,gBAAI,SAAS,WAAW;AACtB,qBAAO,KAAK,SAAS;AACrB;AAAA,YACF;AACA,wBAAY;AACZ,kBAAM,WACJ,UAAU,gBAAgB,gBACtB;AAAA,cACE,QAAQ,OAAO;AAAA,cACf,WAAW,QAAQ,OAAO,gBACvB,SAAS,cAAc,QAAQ,CAAC,EAChC,SAAS,aAAa,sBAAsB;AAAA,YACjD,IACA;AACN,kBAAM,SAAS,UAAU,QAAS,SAAS,SAAS,QAAQ;AAC5D,gBAAI;AACF,oBAAM,UAAU,OAAO;AACvB,sBAAQ,UAAU,QAAQ,GAAG,CAAC;AAC9B,wBAAU,QAAQ;AAAA,YACpB,UAAE;AACA,qBAAO,MAAM;AAAA,YACf;AAAA,UACF;AACA,sBAAY;AACZ,iBAAO;AAAA,YACL;AAAA,YACA,QAAQ;AAAA,YACR,QAAQ;AAAA,UACV;AAAA,QACF;AAAA,MACF;AAAA,MACA,MAAM;AAAA,IACR;AAAA,EACF;AACF;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -29,7 +29,7 @@ const executor = {
|
|
|
29
29
|
throw fail("region", candidateRegion, "must have finite coordinates and positive dimensions");
|
|
30
30
|
}
|
|
31
31
|
const { x, y, width, height } = candidateRegion;
|
|
32
|
-
if (!
|
|
32
|
+
if (!(typeof x === "number" && Number.isFinite(x) && typeof y === "number" && Number.isFinite(y) && typeof width === "number" && Number.isFinite(width) && typeof height === "number" && Number.isFinite(height))) {
|
|
33
33
|
throw fail("region", candidateRegion, "must have finite coordinates and positive dimensions");
|
|
34
34
|
}
|
|
35
35
|
const numericRegion = { x, y, width, height };
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/filters/reflected-light.ts"],
|
|
4
|
-
"sourcesContent": ["import { isSignal } from '../lib/signals/graph.js';\nimport { layoutDiagnostic } from '../lib/style/diagnostics.js';\nimport { PIBBL_FILTER_EXECUTOR, type PibblFilter, type PibblFilterExecutor, type PibblReflectedLightFilterOptions } from '../lib/style/filter-types.js';\nimport { borrowTextureRaster, validateTexturePaint } from '../lib/textures/texture-protocol.js';\nimport { filterBoundaryExecutor, type CustomPreparedFilter } from './filter-executor.js';\nimport { processReflection, isReflectionImage } from './render-reflection-boundary.js';\nimport { concreteColor } from './native-color.js';\n\nconst definitions = new WeakMap<PibblFilter, Readonly<PibblReflectedLightFilterOptions>>();\nconst executor: PibblFilterExecutor = {\n prepare(value, property, context) {\n const options=definitions.get(value);\n if(!options) throw new Error('A reflected-light filter value was created by an incompatible Pibbl runtime.');\n const fail=(key:string,value:unknown,reason:string)=>layoutDiagnostic({component:context.component,property:`${property}.${key}`,value,algorithm:context.algorithm,constraints:context.constraints,reason});\n const numeric=(key:'opacity'|'threshold'|'softness',fallback:number,min:number,max:number)=>{\n const input=options[key]; const value=input===undefined?fallback:isSignal(input)?input.get():input;\n if(typeof value!=='number'||!Number.isFinite(value)||value<min||value>max||(key==='softness'&&value===0)) throw fail(key,value,`must be finite and within ${min}..${max}${key==='softness'?' (strictly positive)':''}`);\n return value;\n };\n const opacity=numeric('opacity',0.15,0,1), threshold=numeric('threshold',0.1,-1,1), softness=numeric('softness',0.25,0,2);\n const direction: unknown = options.direction ?? [-0.6, -0.8];\n if (!Array.isArray(direction) || direction.length !== 2 || !direction.every(value => typeof value === 'number' && Number.isFinite(value))) {\n throw fail('direction', direction, 'must contain two finite components with nonzero length');\n }\n const length = Math.hypot(direction[0], direction[1]);\n if (length === 0) throw fail('direction', direction, 'must contain two finite components with nonzero length');\n const candidateRegion: unknown = options.region;\n if (!candidateRegion || typeof candidateRegion !== 'object') {\n throw fail('region', candidateRegion, 'must have finite coordinates and positive dimensions');\n }\n const { x, y, width, height } = candidateRegion as { x?: unknown; y?: unknown; width?: unknown; height?: unknown };\n if (!
|
|
5
|
-
"mappings": "AAAA,SAAS,gBAAgB;AACzB,SAAS,wBAAwB;AACjC,SAAS,6BAAgH;AACzH,SAAS,qBAAqB,4BAA4B;AAC1D,SAAS,8BAAyD;AAClE,SAAS,mBAAmB,yBAAyB;AACrD,SAAS,qBAAqB;AAE9B,MAAM,cAAc,oBAAI,QAAiE;AACzF,MAAM,WAAgC;AAAA,EACpC,QAAQ,OAAO,UAAU,SAAS;AAChC,UAAM,UAAQ,YAAY,IAAI,KAAK;AACnC,QAAG,CAAC,QAAS,OAAM,IAAI,MAAM,8EAA8E;AAC3G,UAAM,OAAK,CAAC,KAAWA,QAAc,WAAgB,iBAAiB,EAAC,WAAU,QAAQ,WAAU,UAAS,GAAG,QAAQ,IAAI,GAAG,IAAG,OAAAA,QAAM,WAAU,QAAQ,WAAU,aAAY,QAAQ,aAAY,OAAM,CAAC;AAC1M,UAAM,UAAQ,CAAC,KAAqC,UAAgB,KAAW,QAAa;AAC1F,YAAM,QAAM,QAAQ,GAAG;AAAG,YAAMA,SAAM,UAAQ,SAAU,WAAS,SAAS,KAAK,IAAE,MAAM,IAAI,IAAE;AAC7F,UAAG,OAAOA,WAAQ,YAAU,CAAC,OAAO,SAASA,MAAK,KAAGA,SAAM,OAAKA,SAAM,OAAM,QAAM,cAAYA,WAAQ,EAAI,OAAM,KAAK,KAAIA,QAAM,6BAA6B,GAAG,KAAK,GAAG,GAAG,QAAM,aAAW,yBAAuB,EAAE,EAAE;AACtN,aAAOA;AAAA,IACT;AACA,UAAM,UAAQ,QAAQ,WAAU,MAAK,GAAE,CAAC,GAAG,YAAU,QAAQ,aAAY,KAAI,IAAG,CAAC,GAAG,WAAS,QAAQ,YAAW,MAAK,GAAE,CAAC;AACxH,UAAM,YAAqB,QAAQ,aAAa,CAAC,MAAM,IAAI;AAC3D,QAAI,CAAC,MAAM,QAAQ,SAAS,KAAK,UAAU,WAAW,KAAK,CAAC,UAAU,MAAM,CAAAA,WAAS,OAAOA,WAAU,YAAY,OAAO,SAASA,MAAK,CAAC,GAAG;AACzI,YAAM,KAAK,aAAa,WAAW,wDAAwD;AAAA,IAC7F;AACA,UAAM,SAAS,KAAK,MAAM,UAAU,CAAC,GAAG,UAAU,CAAC,CAAC;AACpD,QAAI,WAAW,EAAG,OAAM,KAAK,aAAa,WAAW,wDAAwD;AAC7G,UAAM,kBAA2B,QAAQ;AACzC,QAAI,CAAC,mBAAmB,OAAO,oBAAoB,UAAU;AAC3D,YAAM,KAAK,UAAU,iBAAiB,sDAAsD;AAAA,IAC9F;AACA,UAAM,EAAE,GAAG,GAAG,OAAO,OAAO,IAAI;AAChC,QAAI,
|
|
4
|
+
"sourcesContent": ["import { isSignal } from '../lib/signals/graph.js';\nimport { layoutDiagnostic } from '../lib/style/diagnostics.js';\nimport { PIBBL_FILTER_EXECUTOR, type PibblFilter, type PibblFilterExecutor, type PibblReflectedLightFilterOptions } from '../lib/style/filter-types.js';\nimport { borrowTextureRaster, validateTexturePaint } from '../lib/textures/texture-protocol.js';\nimport { filterBoundaryExecutor, type CustomPreparedFilter } from './filter-executor.js';\nimport { processReflection, isReflectionImage } from './render-reflection-boundary.js';\nimport { concreteColor } from './native-color.js';\n\nconst definitions = new WeakMap<PibblFilter, Readonly<PibblReflectedLightFilterOptions>>();\nconst executor: PibblFilterExecutor = {\n prepare(value, property, context) {\n const options=definitions.get(value);\n if(!options) throw new Error('A reflected-light filter value was created by an incompatible Pibbl runtime.');\n const fail=(key:string,value:unknown,reason:string)=>layoutDiagnostic({component:context.component,property:`${property}.${key}`,value,algorithm:context.algorithm,constraints:context.constraints,reason});\n const numeric=(key:'opacity'|'threshold'|'softness',fallback:number,min:number,max:number)=>{\n const input=options[key]; const value=input===undefined?fallback:isSignal(input)?input.get():input;\n if(typeof value!=='number'||!Number.isFinite(value)||value<min||value>max||(key==='softness'&&value===0)) throw fail(key,value,`must be finite and within ${min}..${max}${key==='softness'?' (strictly positive)':''}`);\n return value;\n };\n const opacity=numeric('opacity',0.15,0,1), threshold=numeric('threshold',0.1,-1,1), softness=numeric('softness',0.25,0,2);\n const direction: unknown = options.direction ?? [-0.6, -0.8];\n if (!Array.isArray(direction) || direction.length !== 2 || !direction.every(value => typeof value === 'number' && Number.isFinite(value))) {\n throw fail('direction', direction, 'must contain two finite components with nonzero length');\n }\n const length = Math.hypot(direction[0], direction[1]);\n if (length === 0) throw fail('direction', direction, 'must contain two finite components with nonzero length');\n const candidateRegion: unknown = options.region;\n if (!candidateRegion || typeof candidateRegion !== 'object') {\n throw fail('region', candidateRegion, 'must have finite coordinates and positive dimensions');\n }\n const { x, y, width, height } = candidateRegion as { x?: unknown; y?: unknown; width?: unknown; height?: unknown };\n if (!(\n typeof x === 'number' &&\n Number.isFinite(x) &&\n typeof y === 'number' &&\n Number.isFinite(y) &&\n typeof width === 'number' &&\n Number.isFinite(width) &&\n typeof height === 'number' &&\n Number.isFinite(height)\n )) {\n throw fail('region', candidateRegion, 'must have finite coordinates and positive dimensions');\n }\n const numericRegion = { x: x as number, y: y as number, width: width as number, height: height as number };\n if (numericRegion.width <= 0 || numericRegion.height <= 0) {\n throw fail('region', candidateRegion, 'must have finite coordinates and positive dimensions');\n }\n const region = Object.freeze(numericRegion);\n const map=isSignal(options.map)?options.map.get():options.map;\n try { validateTexturePaint(map); if(opacity!==0) borrowTextureRaster(map,()=>undefined); }\n catch(error) { throw fail('map',map,error instanceof Error?error.message:String(error)); }\n const source=options.source===undefined?'#ffffff':isSignal(options.source)?options.source.get():options.source;\n if(typeof source==='string') {\n concreteColor(source,`${property}.source`,context);\n if(typeof CSS==='undefined'||!CSS.supports('color',source)) throw fail('source',source,'must be a supported concrete CSS color');\n } else if(isReflectionImage(source)) {\n const ready='naturalWidth' in source?source.complete&&source.naturalWidth>0&&source.naturalHeight>0:source.width>0&&source.height>0;\n if(!ready) throw fail('source',source,'image must already be decoded and have positive dimensions');\n } else {\n try { validateTexturePaint(source); if(opacity!==0) borrowTextureRaster(source,()=>undefined); }\n catch(error) { throw fail('source',source,error instanceof Error?error.message:String(error)); }\n }\n const settings={opacity,threshold,softness,direction:[direction[0]/length,direction[1]/length] as const};\n const process=(warp?:CustomPreparedFilter['textureWarp']):NonNullable<CustomPreparedFilter['process']>=>(input,windows)=>{\n try { return processReflection(input,windows,map,source,settings,region,warp); }\n catch(error) { const failure=fail('source',source,`reflected-light processing failed: ${error instanceof Error?error.message:String(error)}`); Object.defineProperty(failure,'cause',{value:error});throw failure; }\n };\n return Object.freeze({\n executor:filterBoundaryExecutor,\n reverseInfluence:output=>({...output}),\n process:opacity===0?undefined:process(),\n fuseWithPrevious:previous=>previous.textureWarp?Object.freeze({executor:filterBoundaryExecutor,reverseInfluence:previous.reverseInfluence,process:process(previous.textureWarp)}):undefined,\n } satisfies CustomPreparedFilter);\n },\n render:filterBoundaryExecutor.render,\n};\n\n/**\n * Adds slope-selective surface light without changing scene alpha or geometry.\n *\n * @param options - Lighting texture and reflected-light appearance settings. See\n * {@link PibblReflectedLightFilterOptions} .\n * @returns A reflected-light filter descriptor for style.filter. See {@link PibblFilter}.\n *\n * @see {@link PibblReflectedLightFilterOptions}\n * @see {@link PibblFilter}\n */\nexport function reflectedLight(options: PibblReflectedLightFilterOptions): PibblFilter {\n const rawOptions = options as unknown as { readonly region: unknown; readonly direction?: unknown };\n const region = rawOptions.region && typeof rawOptions.region === 'object'\n ? Object.freeze({ ...(rawOptions.region as object) })\n : rawOptions.region;\n const direction = rawOptions.direction === undefined\n ? undefined\n : Array.isArray(rawOptions.direction)\n ? Object.freeze([...rawOptions.direction])\n : rawOptions.direction;\n const definition = Object.freeze({ ...options, region, direction }) as Readonly<PibblReflectedLightFilterOptions>;\n const value = Object.freeze({ [PIBBL_FILTER_EXECUTOR]: executor });\n definitions.set(value, definition);\n return value;\n}\n"],
|
|
5
|
+
"mappings": "AAAA,SAAS,gBAAgB;AACzB,SAAS,wBAAwB;AACjC,SAAS,6BAAgH;AACzH,SAAS,qBAAqB,4BAA4B;AAC1D,SAAS,8BAAyD;AAClE,SAAS,mBAAmB,yBAAyB;AACrD,SAAS,qBAAqB;AAE9B,MAAM,cAAc,oBAAI,QAAiE;AACzF,MAAM,WAAgC;AAAA,EACpC,QAAQ,OAAO,UAAU,SAAS;AAChC,UAAM,UAAQ,YAAY,IAAI,KAAK;AACnC,QAAG,CAAC,QAAS,OAAM,IAAI,MAAM,8EAA8E;AAC3G,UAAM,OAAK,CAAC,KAAWA,QAAc,WAAgB,iBAAiB,EAAC,WAAU,QAAQ,WAAU,UAAS,GAAG,QAAQ,IAAI,GAAG,IAAG,OAAAA,QAAM,WAAU,QAAQ,WAAU,aAAY,QAAQ,aAAY,OAAM,CAAC;AAC1M,UAAM,UAAQ,CAAC,KAAqC,UAAgB,KAAW,QAAa;AAC1F,YAAM,QAAM,QAAQ,GAAG;AAAG,YAAMA,SAAM,UAAQ,SAAU,WAAS,SAAS,KAAK,IAAE,MAAM,IAAI,IAAE;AAC7F,UAAG,OAAOA,WAAQ,YAAU,CAAC,OAAO,SAASA,MAAK,KAAGA,SAAM,OAAKA,SAAM,OAAM,QAAM,cAAYA,WAAQ,EAAI,OAAM,KAAK,KAAIA,QAAM,6BAA6B,GAAG,KAAK,GAAG,GAAG,QAAM,aAAW,yBAAuB,EAAE,EAAE;AACtN,aAAOA;AAAA,IACT;AACA,UAAM,UAAQ,QAAQ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,MAAK,CAAC;AAAE,cAAM;AAAA,MAAS;AAAA,IACrN;AACA,WAAO,OAAO,OAAO;AAAA,MACnB,UAAS;AAAA,MACT,kBAAiB,aAAS,EAAC,GAAG,OAAM;AAAA,MACpC,SAAQ,YAAU,IAAE,SAAU,QAAQ;AAAA,MACtC,kBAAiB,cAAU,SAAS,cAAY,OAAO,OAAO,EAAC,UAAS,wBAAuB,kBAAiB,SAAS,kBAAiB,SAAQ,QAAQ,SAAS,WAAW,EAAC,CAAC,IAAE;AAAA,IACpL,CAAgC;AAAA,EAClC;AAAA,EACA,QAAO,uBAAuB;AAChC;AAYO,SAAS,eAAe,SAAwD;AACrF,QAAM,aAAa;AACnB,QAAM,SAAS,WAAW,UAAU,OAAO,WAAW,WAAW,WAC7D,OAAO,OAAO,EAAE,GAAI,WAAW,OAAkB,CAAC,IAClD,WAAW;AACf,QAAM,YAAY,WAAW,cAAc,SACvC,SACA,MAAM,QAAQ,WAAW,SAAS,IAChC,OAAO,OAAO,CAAC,GAAG,WAAW,SAAS,CAAC,IACvC,WAAW;AACjB,QAAM,aAAa,OAAO,OAAO,EAAE,GAAG,SAAS,QAAQ,UAAU,CAAC;AAClE,QAAM,QAAQ,OAAO,OAAO,EAAE,CAAC,qBAAqB,GAAG,SAAS,CAAC;AACjE,cAAY,IAAI,OAAO,UAAU;AACjC,SAAO;AACT;",
|
|
6
6
|
"names": ["value"]
|
|
7
7
|
}
|
|
@@ -19,6 +19,7 @@ export interface ReflectionSettings {
|
|
|
19
19
|
readonly threshold: number;
|
|
20
20
|
readonly softness: number;
|
|
21
21
|
readonly direction: readonly [number, number];
|
|
22
|
+
readonly depth?: number;
|
|
22
23
|
}
|
|
23
24
|
export type ReflectionLight = {
|
|
24
25
|
readonly color: string;
|
|
@@ -35,6 +36,7 @@ export interface ReflectionWarp {
|
|
|
35
36
|
/** Optional synchronous image processor; scene pixels are never read back. */
|
|
36
37
|
export declare class ReflectionGpu {
|
|
37
38
|
private readonly callbacks;
|
|
39
|
+
private readonly fragment;
|
|
38
40
|
private readonly canvas;
|
|
39
41
|
private gl;
|
|
40
42
|
private resources;
|
|
@@ -46,7 +48,7 @@ export declare class ReflectionGpu {
|
|
|
46
48
|
private lost;
|
|
47
49
|
private readonly onContextLost;
|
|
48
50
|
private readonly onContextRestored;
|
|
49
|
-
constructor(callbacks?: Readonly<ReflectionGpuCallbacks
|
|
51
|
+
constructor(callbacks?: Readonly<ReflectionGpuCallbacks>, fragment?: string);
|
|
50
52
|
get isContextLost(): boolean;
|
|
51
53
|
private acquireResources;
|
|
52
54
|
apply(source: OffscreenCanvas, map: BorrowedTextureRaster, light: ReflectionLight, settings: ReflectionSettings, coordinates: ReflectionCoordinates, warp?: ReflectionWarp): ImageBitmap;
|
|
@@ -38,12 +38,14 @@ void main() {
|
|
|
38
38
|
}
|
|
39
39
|
`;
|
|
40
40
|
class ReflectionGpu {
|
|
41
|
-
constructor(callbacks = {}) {
|
|
41
|
+
constructor(callbacks = {}, fragment = fragmentSource) {
|
|
42
42
|
this.callbacks = callbacks;
|
|
43
|
+
this.fragment = fragment;
|
|
43
44
|
this.canvas.addEventListener("webglcontextlost", this.onContextLost);
|
|
44
45
|
this.canvas.addEventListener("webglcontextrestored", this.onContextRestored);
|
|
45
46
|
}
|
|
46
47
|
callbacks;
|
|
48
|
+
fragment;
|
|
47
49
|
canvas = new OffscreenCanvas(1, 1);
|
|
48
50
|
gl;
|
|
49
51
|
resources;
|
|
@@ -80,7 +82,7 @@ class ReflectionGpu {
|
|
|
80
82
|
let fragment;
|
|
81
83
|
let program = null;
|
|
82
84
|
try {
|
|
83
|
-
fragment = compile(gl, gl.FRAGMENT_SHADER,
|
|
85
|
+
fragment = compile(gl, gl.FRAGMENT_SHADER, this.fragment);
|
|
84
86
|
program = gl.createProgram();
|
|
85
87
|
if (!program) throw new Error("Could not allocate reflection program.");
|
|
86
88
|
gl.attachShader(program, vertex);
|
|
@@ -186,6 +188,7 @@ class ReflectionGpu {
|
|
|
186
188
|
placement("warpOrigin", "warpSize", "warpRotation", warp?.map.placement ?? map.placement, warp?.region ?? coordinates.region, warp?.map.width ?? map.width, warp?.map.height ?? map.height);
|
|
187
189
|
gl.uniform2f(uniform("warpStrength"), (warp?.strength ?? 0) * coordinates.density / source.width, (warp?.strength ?? 0) * coordinates.density / source.height);
|
|
188
190
|
gl.uniform2f(uniform("direction"), settings.direction[0], settings.direction[1]);
|
|
191
|
+
gl.uniform1f(uniform("depth"), settings.depth ?? 0);
|
|
189
192
|
gl.uniform1f(uniform("opacity"), settings.opacity);
|
|
190
193
|
gl.uniform1f(uniform("threshold"), settings.threshold);
|
|
191
194
|
gl.uniform1f(uniform("softness"), settings.softness);
|