@glass-sdk/liquid-glass 0.0.0-stage → 0.0.2

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.
Files changed (129) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +235 -2
  3. package/dist/core/concentric.js +86 -0
  4. package/dist/core/materials.js +41 -0
  5. package/dist/core/morph-path.js +206 -0
  6. package/dist/core/optics.js +7 -0
  7. package/dist/core/progressive.js +35 -0
  8. package/dist/core/shape.js +95 -0
  9. package/dist/core/spring.js +78 -0
  10. package/dist/core/union.js +117 -0
  11. package/dist/core.js +6 -0
  12. package/dist/dom/compose-layers.js +54 -0
  13. package/dist/dom/compound-field.js +23 -0
  14. package/dist/dom/control-motion.js +101 -0
  15. package/dist/dom/engine.js +7 -0
  16. package/dist/dom/exit-handoff.js +14 -0
  17. package/dist/dom/filter-bounds.js +87 -0
  18. package/dist/dom/filter-budget.js +45 -0
  19. package/dist/dom/filter-groups.js +38 -0
  20. package/dist/dom/filter-paint-root.js +41 -0
  21. package/dist/dom/filter-patch.js +129 -0
  22. package/dist/dom/filter-reach.js +36 -0
  23. package/dist/dom/filter-stages.js +7 -0
  24. package/dist/dom/fixed-shape.js +20 -0
  25. package/dist/dom/foreground.js +36 -0
  26. package/dist/dom/interaction.js +129 -0
  27. package/dist/dom/lens-layers.js +163 -0
  28. package/dist/dom/map-blend.js +8 -0
  29. package/dist/dom/map-encoder.js +47 -0
  30. package/dist/dom/map-encoder.worker.js +16 -0
  31. package/dist/dom/map-encoding.js +17 -0
  32. package/dist/dom/map-image.js +34 -0
  33. package/dist/dom/map-store.js +189 -0
  34. package/dist/dom/maps.js +131 -0
  35. package/dist/dom/material-graph.js +52 -0
  36. package/dist/dom/morph.js +296 -0
  37. package/dist/dom/page-zoom.js +46 -0
  38. package/dist/dom/png.js +105 -0
  39. package/dist/dom/progressive.js +299 -0
  40. package/dist/dom/renderer.js +6 -0
  41. package/dist/dom/sampling-bounds.js +22 -0
  42. package/dist/dom/selection.js +106 -0
  43. package/dist/dom/shape-layout.js +199 -0
  44. package/dist/dom/shared-backdrop.js +41 -0
  45. package/dist/dom/ticker.js +103 -0
  46. package/dist/dom/warm.js +108 -0
  47. package/dist/dom.js +694 -0
  48. package/dist/gpu/geometry.js +9 -0
  49. package/dist/gpu/maps.js +8 -0
  50. package/dist/gpu/planes.js +4 -0
  51. package/dist/gpu.js +213 -0
  52. package/dist/index.js +11 -0
  53. package/dist/react/button.js +23 -0
  54. package/dist/react/control-thumb.js +50 -0
  55. package/dist/react/menu.js +159 -0
  56. package/dist/react/merged-ref.js +18 -0
  57. package/dist/react/progressive.js +73 -0
  58. package/dist/react/scene.js +122 -0
  59. package/dist/react/shape.js +93 -0
  60. package/dist/react/surface.js +69 -0
  61. package/dist/react/tabs.js +94 -0
  62. package/dist/react/toolbar.js +145 -0
  63. package/dist/react/value-control-motion.js +9 -0
  64. package/dist/react/value-controls.js +176 -0
  65. package/dist/styles.css +360 -0
  66. package/dist/styles.d.css.ts +2 -0
  67. package/dist/types/core/concentric.d.ts +32 -0
  68. package/dist/types/core/index.d.ts +10 -0
  69. package/dist/types/core/materials.d.ts +43 -0
  70. package/dist/types/core/morph-path.d.ts +110 -0
  71. package/dist/types/core/optics.d.ts +1 -0
  72. package/dist/types/core/progressive.d.ts +17 -0
  73. package/dist/types/core/shape.d.ts +16 -0
  74. package/dist/types/core/spring.d.ts +60 -0
  75. package/dist/types/core/union.d.ts +20 -0
  76. package/dist/types/dom/compose-layers.d.ts +15 -0
  77. package/dist/types/dom/compound-field.d.ts +35 -0
  78. package/dist/types/dom/control-motion.d.ts +13 -0
  79. package/dist/types/dom/engine.d.ts +9 -0
  80. package/dist/types/dom/exit-handoff.d.ts +7 -0
  81. package/dist/types/dom/filter-bounds.d.ts +30 -0
  82. package/dist/types/dom/filter-budget.d.ts +20 -0
  83. package/dist/types/dom/filter-groups.d.ts +25 -0
  84. package/dist/types/dom/filter-paint-root.d.ts +9 -0
  85. package/dist/types/dom/filter-patch.d.ts +4 -0
  86. package/dist/types/dom/filter-reach.d.ts +23 -0
  87. package/dist/types/dom/filter-stages.d.ts +5 -0
  88. package/dist/types/dom/fixed-shape.d.ts +3 -0
  89. package/dist/types/dom/foreground.d.ts +20 -0
  90. package/dist/types/dom/index.d.ts +64 -0
  91. package/dist/types/dom/interaction.d.ts +16 -0
  92. package/dist/types/dom/lens-layers.d.ts +68 -0
  93. package/dist/types/dom/map-blend.d.ts +22 -0
  94. package/dist/types/dom/map-encoder.d.ts +5 -0
  95. package/dist/types/dom/map-encoder.worker.d.ts +1 -0
  96. package/dist/types/dom/map-encoding.d.ts +5 -0
  97. package/dist/types/dom/map-image.d.ts +17 -0
  98. package/dist/types/dom/map-store.d.ts +22 -0
  99. package/dist/types/dom/maps.d.ts +31 -0
  100. package/dist/types/dom/material-graph.d.ts +22 -0
  101. package/dist/types/dom/morph.d.ts +78 -0
  102. package/dist/types/dom/page-zoom.d.ts +18 -0
  103. package/dist/types/dom/png.d.ts +9 -0
  104. package/dist/types/dom/progressive.d.ts +42 -0
  105. package/dist/types/dom/renderer.d.ts +4 -0
  106. package/dist/types/dom/sampling-bounds.d.ts +10 -0
  107. package/dist/types/dom/selection.d.ts +5 -0
  108. package/dist/types/dom/shape-layout.d.ts +29 -0
  109. package/dist/types/dom/shared-backdrop.d.ts +19 -0
  110. package/dist/types/dom/ticker.d.ts +36 -0
  111. package/dist/types/dom/warm.d.ts +17 -0
  112. package/dist/types/gpu/geometry.d.ts +17 -0
  113. package/dist/types/gpu/index.d.ts +36 -0
  114. package/dist/types/gpu/planes.d.ts +2 -0
  115. package/dist/types/index.d.ts +4 -0
  116. package/dist/types/react/button.d.ts +11 -0
  117. package/dist/types/react/control-thumb.d.ts +11 -0
  118. package/dist/types/react/index.d.ts +20 -0
  119. package/dist/types/react/menu.d.ts +29 -0
  120. package/dist/types/react/merged-ref.d.ts +3 -0
  121. package/dist/types/react/progressive.d.ts +15 -0
  122. package/dist/types/react/scene.d.ts +35 -0
  123. package/dist/types/react/shape.d.ts +23 -0
  124. package/dist/types/react/surface.d.ts +35 -0
  125. package/dist/types/react/tabs.d.ts +29 -0
  126. package/dist/types/react/toolbar.d.ts +21 -0
  127. package/dist/types/react/value-control-motion.d.ts +9 -0
  128. package/dist/types/react/value-controls.d.ts +20 -0
  129. package/package.json +80 -4
@@ -0,0 +1,110 @@
1
+ import type { ShapePoint } from "./concentric.js";
2
+ import type { GlassRadius } from "./shape.js";
3
+ /** A box in any shared coordinate space. */
4
+ export interface Box {
5
+ left: number;
6
+ top: number;
7
+ width: number;
8
+ height: number;
9
+ }
10
+ /** A rounded box: the outline of glass in motion. */
11
+ export interface MorphShape extends Box {
12
+ radius: number;
13
+ }
14
+ /** A shape whose maps can be prepared: dimensions, corners, and an optional
15
+ * traced outline in the shape's own box. */
16
+ export interface MorphGeometry {
17
+ width: number;
18
+ height: number;
19
+ radius: GlassRadius;
20
+ outline?: ShapePoint[];
21
+ /** Map density. Resting shapes match their surface exactly; shapes passed
22
+ * through in motion use one pixel per CSS pixel. */
23
+ dpr?: number;
24
+ /** A resting shape, whose maps are worth keeping across loads. */
25
+ resting?: boolean;
26
+ }
27
+ export declare const mix: (a: number, b: number, t: number) => number;
28
+ export declare function smoothstep(edge0: number, edge1: number, x: number): number;
29
+ /** Pixel radius of a declared glass shape at a given size. */
30
+ export declare function radiusPixels(radius: GlassRadius | string | null | undefined, width: number, height: number): number;
31
+ /** How far apart two shapes are: relative size, then corners. */
32
+ export declare function shapeDistance(a: {
33
+ width: number;
34
+ height: number;
35
+ radius: GlassRadius;
36
+ }, b: {
37
+ width: number;
38
+ height: number;
39
+ radius: GlassRadius;
40
+ }): number;
41
+ /** Gap between two boxes, or zero when they overlap. */
42
+ export declare const boxGap: (a: Box, b: Box) => number;
43
+ /** Where glass grows from and where it grows to. */
44
+ export interface MorphEndpoints {
45
+ from: Box;
46
+ fromRadius: GlassRadius;
47
+ to: Box;
48
+ toRadius: GlassRadius;
49
+ /** The axis the surface opens along leads the growth; the other follows.
50
+ * Undefined: both axes move together, as for a layout change. */
51
+ along?: "x" | "y";
52
+ }
53
+ /** The axis along which `to` lies beyond `from`: the direction a popup opens. */
54
+ export declare function openingAxis(from: Box, to: Box): "x" | "y";
55
+ /** The outline at progress `p` along the path: it leaves its source with
56
+ * fully rounded, drop-like corners, stretches along the opening axis before
57
+ * it widens, and only takes its final corners once it has nearly arrived. */
58
+ export declare function morphShape(e: MorphEndpoints, p: number): MorphShape;
59
+ /** Visibility of a popup's content: it appears once the glass has room. */
60
+ export declare const contentReveal: (p: number) => number;
61
+ /** How far the source's own content has withdrawn into the glass that left it. */
62
+ export declare const sourceConceal: (p: number) => number;
63
+ /** How far apart a drop and its glass can be and still flow together; the
64
+ * neck thins as the drop reaches its place, so it pinches off and rests as
65
+ * its own shape even right beside its source. */
66
+ export declare const neckWidth: (p: number, neck: number) => number;
67
+ /** One prepared shape on the path. */
68
+ export interface MorphStop {
69
+ p: number;
70
+ shape: MorphGeometry;
71
+ /** Drawn in this box rather than stretched to the live outline: a traced
72
+ * union, or the glass a drop is still inside. */
73
+ box?: Box;
74
+ /** Draws the source glass as part of itself. */
75
+ absorbs: boolean;
76
+ }
77
+ export interface MorphPlanOptions {
78
+ /** Shapes prepared between the endpoints. */
79
+ stops?: number;
80
+ /** Union samples while a drop is joined to its glass. */
81
+ unions?: number;
82
+ /** Neck reach in pixels. */
83
+ neck?: number;
84
+ /** Map density of the shapes in motion. */
85
+ dpr?: number;
86
+ /** Map density of the resting endpoints. */
87
+ restDpr?: number;
88
+ }
89
+ /** The glass a drop detaches from. `width` and `height` are its layout size
90
+ * and `radius` its declared corners, so its stop matches its own resting map. */
91
+ export interface MorphGlass extends Box {
92
+ radius: GlassRadius;
93
+ layoutWidth: number;
94
+ layoutHeight: number;
95
+ }
96
+ /** Plan the shapes an animation passes through, so their maps can be
97
+ * prepared together before it starts. Stops are spaced evenly by how much
98
+ * the shape changes between them; the endpoints are exact. A drop leaving
99
+ * glass adds the traced unions of the two while they are joined, beginning
100
+ * with the glass's own shape while the drop is still inside it. */
101
+ export declare function planMorph(e: MorphEndpoints, glass: MorphGlass | undefined, options?: MorphPlanOptions): MorphStop[];
102
+ /** What to draw at progress `p`: the two stops around it and their blend,
103
+ * plus how much of the source glass the frame draws in its place. */
104
+ export interface MorphDraw {
105
+ a: MorphStop;
106
+ b?: MorphStop;
107
+ mix: number;
108
+ absorb: number;
109
+ }
110
+ export declare function morphDraw(stops: readonly MorphStop[], p: number): MorphDraw | undefined;
@@ -0,0 +1 @@
1
+ export declare function edgeDisplacement(distance: number, amount: number, inverseHeight: number): number;
@@ -0,0 +1,17 @@
1
+ export type GlassBlurEdge = "top" | "bottom" | "inline-start" | "inline-end";
2
+ export type PhysicalEdge = "top" | "bottom" | "left" | "right";
3
+ export interface ProgressiveBlurOptions {
4
+ /** Edge where blur is strongest. Default: bottom. */
5
+ edge?: GlassBlurEdge;
6
+ /** Depth in CSS pixels. Default: 80. Clamped to half the viewport for scroll edges. */
7
+ size?: number;
8
+ /** Maximum Gaussian standard deviation in CSS pixels. Default: 20. */
9
+ blur?: number;
10
+ /** Maximum optical travel in CSS pixels. Default: 0. */
11
+ refraction?: number;
12
+ disabled?: boolean;
13
+ }
14
+ export declare function validateProgressive(options: ProgressiveBlurOptions): void;
15
+ export declare function physicalEdge(edge: GlassBlurEdge, rtl: boolean): PhysicalEdge;
16
+ /** Clamp Safari rubber-banding; RTL scrollLeft is negative in modern engines. */
17
+ export declare function scrollEdgeStrength(edge: PhysicalEdge, left: number, top: number, maxX: number, maxY: number, rtl: boolean, size: number): number;
@@ -0,0 +1,16 @@
1
+ import type { SmoothCornerOptions } from "@lisse/core";
2
+ /** A fixed continuous corner, a continuous capsule, or a circular cap. */
3
+ export type GlassRadius = number | "capsule" | "circle";
4
+ export declare function cornerOptions(radius: GlassRadius): SmoothCornerOptions;
5
+ export declare function shapePath(width: number, height: number, radius: GlassRadius): string;
6
+ export declare function shapeClip(width: number, height: number, radius: GlassRadius): string;
7
+ type Point = [number, number];
8
+ /** Tessellate Lisse's SVG path for the WGSL distance field. This is the same
9
+ * outline used by the DOM, not a second corner formula. Uniform shapes are
10
+ * symmetric, so the GPU only needs the top-right quadrant. */
11
+ export declare function shapePolygon(width: number, height: number, radius: GlassRadius): Point[];
12
+ export declare function shapeSegments(width: number, height: number, radius: GlassRadius): {
13
+ segments: number[][];
14
+ count: number;
15
+ };
16
+ export {};
@@ -0,0 +1,60 @@
1
+ /** Perceptual spring duration in
2
+ * seconds and bounce from 0 (critically damped) to just under 1. */
3
+ export interface SpringOptions {
4
+ duration: number;
5
+ bounce: number;
6
+ }
7
+ /** Named springs shared by every glass interaction, so motion reads as one material. */
8
+ export declare const springs: {
9
+ /** The material catching a finger or pointer. */
10
+ readonly press: {
11
+ readonly duration: 0.24;
12
+ readonly bounce: 0.2;
13
+ };
14
+ /** Letting go: gel-like overshoot back to rest. */
15
+ readonly release: {
16
+ readonly duration: 0.5;
17
+ readonly bounce: 0.42;
18
+ };
19
+ /** Light settling into and out of the material. */
20
+ readonly glow: {
21
+ readonly duration: 0.42;
22
+ readonly bounce: 0;
23
+ };
24
+ /** Glass growing out of, or back into, another shape. */
25
+ readonly morph: {
26
+ readonly duration: 0.42;
27
+ readonly bounce: 0.18;
28
+ };
29
+ /** A surface flowing to a new layout. */
30
+ readonly layout: {
31
+ readonly duration: 0.4;
32
+ readonly bounce: 0.16;
33
+ };
34
+ /** A selection lens following a drag. */
35
+ readonly track: {
36
+ readonly duration: 0.18;
37
+ readonly bounce: 0;
38
+ };
39
+ };
40
+ /** One damped harmonic oscillator. Retargeting keeps the current velocity, so
41
+ * every animation built on it can be interrupted and reversed mid-flight. */
42
+ export declare class Spring {
43
+ value: number;
44
+ velocity: number;
45
+ target: number;
46
+ private stiffness;
47
+ private damping;
48
+ constructor(value: number, options: SpringOptions);
49
+ configure({ duration, bounce }: SpringOptions): this;
50
+ /** Move to `value` immediately and stop. */
51
+ jump(value: number): this;
52
+ get settled(): boolean;
53
+ /** Advance by `dt` seconds with the closed-form solution; large frames stay stable. */
54
+ step(dt: number): this;
55
+ }
56
+ /** Seconds until a spring released from `from` toward `to` with `velocity`
57
+ * comes to rest, or stays within `precision` (a fraction of the travel). */
58
+ export declare function settleTime(options: SpringOptions, from: number, to: number, velocity?: number, precision?: number): number;
59
+ /** iOS-style rubber band: follows a short drag, then resists without a hard stop. */
60
+ export declare function rubberBand(offset: number, limit: number, coefficient?: number): number;
@@ -0,0 +1,20 @@
1
+ import type { ShapePoint } from "./concentric.js";
2
+ /** An axis-aligned rounded rectangle in any shared coordinate space. */
3
+ export interface RoundRect {
4
+ x: number;
5
+ y: number;
6
+ width: number;
7
+ height: number;
8
+ radius: number;
9
+ }
10
+ /** Signed distance to a rounded rectangle: negative inside. */
11
+ export declare function roundRectDistance(px: number, py: number, r: RoundRect): number;
12
+ /** Polynomial smooth minimum: shapes closer than `k` flow into each other. */
13
+ export declare function smoothMin(a: number, b: number, k: number): number;
14
+ /** Twice the signed area; positive for the clockwise-on-screen winding the
15
+ * renderer expects (top edge left to right, with y pointing down). */
16
+ export declare function windingArea(points: readonly ShapePoint[]): number;
17
+ /** Outlines of the smooth union of rounded rectangles, traced with marching
18
+ * squares at `step` pixels. Returns one loop per connected body, wound the way
19
+ * the renderer expects and simplified to at most `limit` edges each. */
20
+ export declare function smoothUnion(shapes: readonly RoundRect[], k: number, step?: number, limit?: number): ShapePoint[][];
@@ -0,0 +1,15 @@
1
+ import type { FilterBounds } from "./filter-bounds.js";
2
+ export interface SparseCompositionUnit {
3
+ /** Stable identity of this material unit. */
4
+ id: string;
5
+ mask: string;
6
+ /** Material, outline and light, in their source-over paint order. */
7
+ layers: readonly string[];
8
+ /** Union of every member's output bounds, including outline padding. */
9
+ bounds: FilterBounds;
10
+ }
11
+ /** Replace the source in disjoint rectangular regions. Each region keeps
12
+ * the exact sequential alpha composition, but its intermediate buffers only
13
+ * cover nearby surfaces. Erasing rectangles instead of derived material
14
+ * alpha avoids rewalking the optical graph when WebKit computes outsets. */
15
+ export declare function composeSparseLayers(units: readonly SparseCompositionUnit[], result?: string, source?: string): string;
@@ -0,0 +1,35 @@
1
+ import type { MaterialOptions } from "../core/materials.js";
2
+ import type { FilterBounds } from "./filter-bounds.js";
3
+ import type { MapPlane } from "./map-image.js";
4
+ interface FieldSurface {
5
+ element: Element;
6
+ options: MaterialOptions;
7
+ maps?: unknown;
8
+ x: number;
9
+ y: number;
10
+ w: number;
11
+ h: number;
12
+ opacity: number;
13
+ baseOpacity?: number;
14
+ }
15
+ interface FieldContext<T> {
16
+ source(surface: T): Element | undefined;
17
+ nested(surface: T): boolean;
18
+ refraction(surface: T): number;
19
+ reach(surface: T): number;
20
+ }
21
+ export declare const fieldTouches: (a: Pick<FieldSurface, "x" | "y" | "w" | "h">, b: Pick<FieldSurface, "x" | "y" | "w" | "h">, reach?: number) => boolean;
22
+ /** A detached popup and its source can share one optical field when they
23
+ * have the same opaque material. Moving the source to the popup's paint
24
+ * position must not change any intervening surface's sampled backdrop. */
25
+ export declare function compoundSources<T extends FieldSurface>(ordered: readonly T[], context: FieldContext<T>): Map<T, T>;
26
+ interface FieldMember {
27
+ serial: number;
28
+ opacity: number;
29
+ baseOpacity?: number;
30
+ }
31
+ /** Draw one plane of a compound field: the source's glass, faded as the
32
+ * popup absorbs it, under the popup's. A field's alpha is its coverage, so
33
+ * fading and merging fields also merges the shapes the material fills. */
34
+ export declare function compoundFieldImage<T extends FieldMember>(source: T, popup: T, plane: MapPlane, result: string, box: FilterBounds, image: (member: T, plane: MapPlane, result: string) => string): string;
35
+ export {};
@@ -0,0 +1,13 @@
1
+ import type { GlassMotion } from "./interaction.js";
2
+ /** Motion options for native-style value controls. */
3
+ export interface ControlMotionOptions {
4
+ /** Override the scene's motion level. */
5
+ motion?: GlassMotion;
6
+ /** Lift the thumb into glass under a press. Default: true. */
7
+ interactive?: boolean;
8
+ }
9
+ /** Advance visible thumbs before the scene samples their optical geometry.
10
+ * Returns whether any thumb in the scene is still moving. */
11
+ export declare function updateControlMotion(root: HTMLElement, now: number): boolean;
12
+ /** Controls have their own measured geometry; generic button press scaling must not compound it. */
13
+ export declare function attachNativeControlMotion(element: HTMLElement, motion: GlassMotion, interactive: boolean): () => void;
@@ -0,0 +1,9 @@
1
+ /** Rendering engine, which decides how SVG filters on HTML are painted:
2
+ * Chromium on the GPU, WebKit and Gecko mostly in software. */
3
+ /** iOS browser brands can report a different vendor while still using WebKit. */
4
+ export declare function isWebKit(agent: Pick<Navigator, "vendor" | "userAgent">): boolean;
5
+ export declare const webkit: boolean;
6
+ /** Gecko caps a filter chain at 64 operations and renders graphs with images
7
+ * or displacement in software. */
8
+ export declare const gecko: boolean;
9
+ export declare const chromium: boolean;
@@ -0,0 +1,7 @@
1
+ /** Once a replacement starts entering, its sibling no longer owns the
2
+ * submenu slot. Finish the old return before painting the new glass. */
3
+ export declare function finishRetainedExit(parent: Element): void;
4
+ /** A submenu's newest outgoing sibling keeps its return animation. Older
5
+ * exits have already been superseded: finish them before another panel
6
+ * starts returning, rather than accumulating overlapping optical layers. */
7
+ export declare function retainLatestExit(parent: Element, complete: () => void): () => void;
@@ -0,0 +1,30 @@
1
+ /** Bounds of the source and every optical surface, including transformed controls. */
2
+ export interface FilterBounds {
3
+ x: number;
4
+ y: number;
5
+ width: number;
6
+ height: number;
7
+ }
8
+ export declare function filterBounds(width: number, height: number, surfaces: readonly FilterBounds[], padding: number): FilterBounds;
9
+ export interface EdgeSides {
10
+ left: boolean;
11
+ top: boolean;
12
+ right: boolean;
13
+ bottom: boolean;
14
+ /** Corners some region reaches past on both of its sides, indexed [x][y] as 0 or 2. */
15
+ corners: Set<string>;
16
+ }
17
+ /** Which content edges, and which corners, a sampled region crosses. */
18
+ export declare function crossedSides(width: number, height: number, regions: readonly FilterBounds[]): EdgeSides;
19
+ /** Edge tiles that extend the live source past its sides by repeating its
20
+ * edge pixels, like a clamp-to-edge sampler. Only the sides and corners some
21
+ * surface samples past are produced; a scene whose glass stays inside its
22
+ * content needs none. Each tile is a named result a surface merges into its
23
+ * own cropped backdrop, so no full-size extended copy of the source is ever
24
+ * built or re-evaluated. */
25
+ export declare function edgeTiles(width: number, height: number, bounds: FilterBounds, prefix: string, sides: EdgeSides, source?: string): {
26
+ markup: string;
27
+ names: Record<string, string>;
28
+ };
29
+ /** The tile keys a region needs: its crossed sides, and the corners of two crossed sides. */
30
+ export declare function tilesFor(width: number, height: number, r: FilterBounds): string[];
@@ -0,0 +1,20 @@
1
+ export { isWebKit, webkit } from "./engine.js";
2
+ /** WebKit paints CSS reference filters in software and adds up the outsets of
3
+ * every blur and displacement primitive in an element's filters: along a
4
+ * chain of `url()` filters, and across the branches of one filter's graph,
5
+ * whose walk folds only one level at a time and sums what it leaves behind.
6
+ * It then clamps the whole filter buffer to 4096 × 4096 device pixels, and
7
+ * past that clamp draws the result stretched, so glass lands away from its
8
+ * surface. Keeping the sum of outsets inside the budget keeps the geometry
9
+ * exact; the material only softens on scenes that would otherwise overflow. */
10
+ /** Outsets WebKit charges for one Gaussian blur of this sigma, in the blur's own pixels. */
11
+ export declare const blurOutsets: (sigma: number) => number;
12
+ /** Factor to apply to every blur sigma and displacement amount so a filtered
13
+ * box of `width` × `height` device pixels with `outsets` device pixels of
14
+ * accumulated outsets stays inside WebKit's buffer clamp. 1 when it already fits. */
15
+ export declare function filterBudgetFactor(width: number, height: number, outsets: number): number;
16
+ /** Largest outsets, in device pixels, a `width` × `height` device-pixel box can take before the clamp. */
17
+ export declare function outsetBudget(width: number, height: number): number;
18
+ /** Mirror WebKit's depth-first outset fold. Shared inputs are visited again
19
+ * at each use, so counting each blur once underestimates branched graphs. */
20
+ export declare function filterGraphOutsets(markup: string, width?: number, height?: number): number;
@@ -0,0 +1,25 @@
1
+ import type { FilterBounds } from "./filter-bounds.js";
2
+ interface LensBox {
3
+ x: number;
4
+ y: number;
5
+ w: number;
6
+ h: number;
7
+ }
8
+ /** Displacement images are opaque through their two-pixel border. Their
9
+ * padded boxes must not overlap, even when the visible glass does not. */
10
+ export declare function mapBoxesOverlap(a: LensBox, b: LensBox): boolean;
11
+ export interface BranchRegions {
12
+ output: FilterBounds;
13
+ crop: FilterBounds;
14
+ sampled: FilterBounds;
15
+ }
16
+ /** Group compatible, independent surfaces only when sharing their material
17
+ * reduces the pixels processed by its primitives. Map images keep their
18
+ * original area; merging four planes adds four passes over the union box.
19
+ * This keeps distant small lenses from creating a scene-sized software pass.
20
+ * Callers separately check the extra branches against WebKit's outset budget. */
21
+ export declare function clusterFilterBranches<T>(members: readonly T[], regions: (member: T) => BranchRegions, stages: {
22
+ output: number;
23
+ sampled: number;
24
+ }): T[][];
25
+ export {};
@@ -0,0 +1,9 @@
1
+ /** Keep WebKit's CSS reference filter in its target's own paint coordinates.
2
+ * Acquire before applying the filter, and release when that filter is removed.
3
+ * A shared target can be claimed by both scene and foreground filtering.
4
+ */
5
+ export declare function acquireFilterPaintRoot(element: HTMLElement): () => void;
6
+ /** Keep popup mounting from changing the scene's composited backing in WebKit.
7
+ * Opacity preserves the containing block of fixed-position descendants.
8
+ */
9
+ export declare function acquireSceneCompositingLayer(element: HTMLElement): () => void;
@@ -0,0 +1,4 @@
1
+ /** Retain filter primitives and their loaded images across geometry changes.
2
+ * The last description also owns the attribute values, avoiding live DOM
3
+ * collection reads and redundant writes. Exact repeats do no parsing at all. */
4
+ export declare function patchFilters(defs: Element, markup: readonly string[], resolve: (token: string) => string | undefined): (id: string) => string;
@@ -0,0 +1,23 @@
1
+ import type { FilterBounds } from "./filter-bounds.js";
2
+ /** WebKit filters a partial repaint of an HTML element over the dirty rect
3
+ * grown by the element's filter outsets, then grows that region by the
4
+ * outsets again. A primitive whose subregion misses the region yields no
5
+ * image, which fails the whole filter, so the repainted area paints blank:
6
+ * hovering a link far from every lens erases it. The filter must reach
7
+ * from any point of the element to every primitive it evaluates. */
8
+ /** Outsets, in user units, that let any repaint inside a `width` × `height`
9
+ * element reach every primitive subregion of `markup` and every `extra` box. */
10
+ export declare function repaintReach(markup: string, width: number, height: number, extra?: readonly FilterBounds[]): number;
11
+ /** Add `outsets` to the filter's last merge with transparent images that
12
+ * only move pixels. As siblings in that merge they raise its outsets to at
13
+ * least `outsets` instead of adding to the branches beside them.
14
+ *
15
+ * Offsets are cheap copies but stay within half the element, so their
16
+ * shifted image always overlaps the region. A layer WebKit splits into tiles
17
+ * filters each tile over the tile grown by its outsets once, which needs more
18
+ * reach than that; `tiled` pads with blurs of a transparent flood instead,
19
+ * whose outsets grow without moving anything. */
20
+ export declare function padRepaintReach(markup: string, outsets: number, width: number, height: number, tiled?: boolean): string;
21
+ /** A tile grows its own rectangle by the outsets once rather than twice,
22
+ * so it needs about twice the outsets of a whole-layer repaint. */
23
+ export declare const tiledReach = 2;
@@ -0,0 +1,5 @@
1
+ /** Count this library's generated SVG primitives, excluding their child
2
+ * transfer functions and merge inputs. Gecko's operation cap counts the
3
+ * descriptions before expanding merge inputs into GPU operations. */
4
+ export declare function filterPrimitiveCount(markup: string): number;
5
+ export { gecko } from "./engine.js";
@@ -0,0 +1,3 @@
1
+ import type { GlassRadius } from "../core/shape.js";
2
+ /** Apply Lisse geometry without taking ownership of component data-slot/data-state. */
3
+ export declare function observeFixedShape(element: HTMLElement, radius: GlassRadius): () => void;
@@ -0,0 +1,20 @@
1
+ import type { MaterialOptions } from "../core/materials.js";
2
+ import type { MaterialMaps } from "./maps.js";
3
+ export interface ForegroundLens {
4
+ element: HTMLElement;
5
+ x: number;
6
+ y: number;
7
+ w: number;
8
+ h: number;
9
+ opacity: number;
10
+ options: MaterialOptions;
11
+ maps?: MaterialMaps;
12
+ }
13
+ /** Compare sibling stacking branches before falling back to document order. */
14
+ export declare function comparePaintOrder(a: HTMLElement, b: HTMLElement): number;
15
+ export declare function overlaps(a: Pick<ForegroundLens, "x" | "y" | "w" | "h">, b: Pick<ForegroundLens, "x" | "y" | "w" | "h">): boolean;
16
+ /** Filter live foreground DOM through higher lenses, without repainting their rims.
17
+ * Transparent input must stay transparent: unlike the backdrop pass, no edge
18
+ * extension or opaque material fill belongs in this foreground contribution.
19
+ */
20
+ export declare function foregroundFilter(id: string, target: ForegroundLens, overlays: readonly ForegroundLens[]): string;
@@ -0,0 +1,64 @@
1
+ import type { GlassMotion, SurfaceAnimator } from "./interaction.js";
2
+ import type { GlassMorph } from "./morph.js";
3
+ export { attachInteraction, resolveMotion } from "./interaction.js";
4
+ export type { GlassMotion, SurfaceAnimator } from "./interaction.js";
5
+ export { attachGeometryMotion, radiusPixels } from "./morph.js";
6
+ export { attachSelectionLens } from "./selection.js";
7
+ export type { GeometryAnimator, GeometryMotionOptions, GlassMorph, LensFrame, LensPlacement, LensWaypoint } from "./morph.js";
8
+ import type { ScrollEdgesOptions } from "./progressive.js";
9
+ import type { ProgressiveBlurOptions } from "../core/progressive.js";
10
+ export type { ScrollEdgesOptions, GlassScrollTarget } from "./progressive.js";
11
+ import type { MaterialOptions } from "../core/materials.js";
12
+ export { getMaterialMaps, clearMaterialMapCache } from "./maps.js";
13
+ export type { MaterialMaps } from "./maps.js";
14
+ export interface GlassDiagnostic {
15
+ surfaces: number;
16
+ maps: number;
17
+ mapTime: number;
18
+ error?: Error;
19
+ }
20
+ export interface GlassSceneOptions {
21
+ onDiagnostic?: (diagnostic: GlassDiagnostic) => void;
22
+ maxSurfaces?: number;
23
+ }
24
+ /** Material plus the motion a registered surface takes part in. */
25
+ export interface SurfaceOptions extends MaterialOptions {
26
+ /** React to touch and pointer input: grow, stretch toward a drag, settle with
27
+ * overshoot, and light up beneath the pointer. */
28
+ interactive?: boolean;
29
+ /** Grow out of this element when registered, and back into it when Base UI
30
+ * marks the popup with `data-ending-style`. */
31
+ morphFrom?: () => Element | null | undefined;
32
+ /** `become`: the source's glass is this surface, and withdraws its own
33
+ * content while the surface is present. `detach`: this surface leaves the
34
+ * source's glass as a drop, joined by a liquid neck until they part.
35
+ * Default: a glass source is become; a source inside glass, such as a
36
+ * toolbar button, is detached from. */
37
+ morph?: GlassMorph;
38
+ /** Spring the glass outline when the surface's layout box changes. */
39
+ fluid?: boolean;
40
+ /** Motion level for this surface. System reduced motion always applies. */
41
+ motion?: GlassMotion;
42
+ /** Neck reach of a detaching drop in pixels; `0` grows a plain shape. */
43
+ neck?: number;
44
+ /** Grow out of `morphFrom` when registered. `false` only runs the exit. */
45
+ morphEnter?: boolean;
46
+ }
47
+ export interface GlassSceneController {
48
+ /** Optional transparent, nested filter hosts in inner-to-outer order.
49
+ * Gecko uses separate hosts for graphs exceeding its operation limit;
50
+ * reserve the final host for progressive blur. */
51
+ setContent(element: HTMLElement | null): void;
52
+ addSurface(element: HTMLElement, options?: SurfaceOptions): () => void;
53
+ /** Live DOM above the backdrop that must pass through overlapping glass. */
54
+ addForeground(element: HTMLElement): () => void;
55
+ /** Step an animation each frame before the scene samples glass geometry. */
56
+ addAnimator(animator: SurfaceAnimator): () => void;
57
+ addProgressiveBlur(element: HTMLElement, options?: ProgressiveBlurOptions): () => void;
58
+ addScrollEdges(options: ScrollEdgesOptions): () => void;
59
+ dispose(): void;
60
+ }
61
+ /** Refract one explicit live DOM layer. Foreground controls stay semantic HTML. */
62
+ export declare function createGlassScene(root: HTMLElement, config?: GlassSceneOptions): GlassSceneController;
63
+ export { registerShapeContainer, observeConcentricShape, observeCornerPlacement } from "./shape-layout.js";
64
+ export type { ConcentricOptions, CornerOptions, GlassCornerPosition } from "./shape-layout.js";
@@ -0,0 +1,16 @@
1
+ /** `full` follows the system: reduced motion always removes elasticity. */
2
+ export type GlassMotion = "full" | "reduced" | "none";
3
+ export declare function resolveMotion(motion: GlassMotion | undefined): GlassMotion;
4
+ export interface SurfaceAnimator {
5
+ /** Advance to `now` before the scene samples geometry. Returns true while
6
+ * the animation is in motion and needs the next frame. While the scene is
7
+ * `quiet`, an animator leaves the page as it is: nothing moves, so the GPU
8
+ * is free for the maps another surface is waiting on. */
9
+ frame(now: number, quiet?: boolean): boolean | void;
10
+ dispose(): void;
11
+ }
12
+ /** Elastic, illuminated response to touch and pointer input: the surface grows
13
+ * under a press, stretches toward a drag with constant volume, and settles with
14
+ * gel-like overshoot on release. Writes only `translate`, `scale` and custom
15
+ * properties, so consumer `transform` styles continue to compose. */
16
+ export declare function attachInteraction(element: HTMLElement, motion: () => GlassMotion): SurfaceAnimator;
@@ -0,0 +1,68 @@
1
+ import type { MaterialOptions } from "../core/materials.js";
2
+ import type { PlacedMap } from "./map-blend.js";
3
+ import type { MaterialMaps } from "./maps.js";
4
+ import type { ProgressiveRegion } from "./progressive.js";
5
+ /** A surface's border box on screen and the scale its transforms apply. */
6
+ export interface LayerFrame {
7
+ left: number;
8
+ top: number;
9
+ sx: number;
10
+ sy: number;
11
+ clientLeft: number;
12
+ clientTop: number;
13
+ }
14
+ export interface LayerLens {
15
+ serial: number;
16
+ element: HTMLElement;
17
+ options: MaterialOptions;
18
+ maps: MaterialMaps;
19
+ /** Prepared shapes blended in motion, in content coordinates. */
20
+ place?: {
21
+ a: PlacedMap;
22
+ b: PlacedMap;
23
+ mix: number;
24
+ };
25
+ /** Drawn glass in content coordinates. */
26
+ x: number;
27
+ y: number;
28
+ w: number;
29
+ h: number;
30
+ opacity: number;
31
+ /** Displacement travel in CSS pixels. */
32
+ refraction: number;
33
+ /** Glass this surface sits inside, innermost first. */
34
+ parents: readonly LayerLens[];
35
+ /** Earlier glass, not an ancestor, close enough to be refracted. */
36
+ beneath: readonly LayerLens[];
37
+ frame: LayerFrame;
38
+ }
39
+ interface Box {
40
+ left: number;
41
+ top: number;
42
+ width: number;
43
+ height: number;
44
+ }
45
+ /** Gecko renders an SVG filter with images or displacement in software and,
46
+ * once it falls back, rasterizes it again on every paint of the page,
47
+ * whatever changed. A filter over a whole content layer then costs its full
48
+ * area on every frame of any animation anywhere.
49
+ *
50
+ * Here each surface draws its own glass instead. A layer inside the surface,
51
+ * beneath its children, paints a live `-moz-element()` copy of the content
52
+ * (and of the glass under it) and refracts only that. The content layer
53
+ * itself stays unfiltered on the GPU. An unchanged layer is never
54
+ * rasterized again, and a moving one costs only its own area. */
55
+ export declare function createLensLayers(root: HTMLElement): {
56
+ /** `blur` is the scene's progressive blur when it is drawn on a host
57
+ * around the content rather than on the content: layers then blur their
58
+ * own copy of the content the same way, so they never render the whole
59
+ * blurred content to sample a small part of it. */
60
+ update(lenses: readonly LayerLens[], content: HTMLElement, contentRect: Box, blur?: {
61
+ left: number;
62
+ top: number;
63
+ regions: readonly ProgressiveRegion[];
64
+ }): void;
65
+ owns(node: Node): boolean;
66
+ dispose(): void;
67
+ };
68
+ export {};
@@ -0,0 +1,22 @@
1
+ import type { MapPlane } from "./map-image.js";
2
+ import type { MaterialMaps } from "./maps.js";
3
+ export interface PlacedMap {
4
+ maps: MaterialMaps;
5
+ x: number;
6
+ y: number;
7
+ w: number;
8
+ h: number;
9
+ }
10
+ /** Emit an animation's material map, retaining both inputs unless they name
11
+ * the same pixels at the same position. This cuts redundant Gecko filter
12
+ * operations during map preparation and at the end of a spring. */
13
+ export declare function blendMapImage(plane: MapPlane, result: string, placement: {
14
+ a: PlacedMap;
15
+ b: PlacedMap;
16
+ mix: number;
17
+ }, bounds: {
18
+ x: number;
19
+ y: number;
20
+ w: number;
21
+ h: number;
22
+ }, collapseIdentical?: boolean): string;