@glass-sdk/liquid-glass 0.0.2 → 0.0.3-beta.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.
Files changed (146) hide show
  1. package/CHANGELOG.md +124 -0
  2. package/README.md +66 -149
  3. package/dist/core/concentric.js +20 -3
  4. package/dist/core/corner-options.js +12 -0
  5. package/dist/core/corner-path.js +118 -0
  6. package/dist/core/materials.js +264 -32
  7. package/dist/core/optics.js +1 -2
  8. package/dist/core/progressive.js +1 -2
  9. package/dist/core/shape.js +18 -28
  10. package/dist/core/spring.js +5 -10
  11. package/dist/core.js +5 -6
  12. package/dist/dom/backdrop-glass.js +46 -0
  13. package/dist/dom/compose-layers.js +42 -31
  14. package/dist/dom/composited.js +136 -0
  15. package/dist/dom/control-motion.js +58 -47
  16. package/dist/dom/engine.js +1 -2
  17. package/dist/dom/escaped-layers.js +179 -0
  18. package/dist/dom/filter-bounds.js +42 -13
  19. package/dist/dom/filter-budget.js +1 -2
  20. package/dist/dom/filter-chain.js +40 -0
  21. package/dist/dom/filter-groups.js +33 -14
  22. package/dist/dom/filter-paint-root.js +8 -6
  23. package/dist/dom/filter-patch.js +94 -55
  24. package/dist/dom/filter-reach.js +32 -19
  25. package/dist/dom/filter-stages.js +1 -2
  26. package/dist/dom/fixed-shape.js +23 -16
  27. package/dist/dom/foreground.js +16 -17
  28. package/dist/dom/interaction.js +65 -92
  29. package/dist/dom/layout-rect.js +42 -0
  30. package/dist/dom/layout-size.js +28 -0
  31. package/dist/dom/lens-layers.js +250 -136
  32. package/dist/dom/map-encoder.js +16 -13
  33. package/dist/dom/map-encoder.worker.js +2 -3
  34. package/dist/dom/map-encoding.js +49 -12
  35. package/dist/dom/map-image.js +29 -7
  36. package/dist/dom/map-store.js +1 -2
  37. package/dist/dom/maps.js +133 -83
  38. package/dist/dom/material-graph.js +108 -29
  39. package/dist/dom/media-mirror.js +244 -0
  40. package/dist/dom/page-zoom.js +19 -18
  41. package/dist/dom/png.js +1 -2
  42. package/dist/dom/progressive.js +152 -147
  43. package/dist/dom/renderer.js +1 -2
  44. package/dist/dom/sampling-bounds.js +1 -2
  45. package/dist/dom/selection.js +133 -79
  46. package/dist/dom/shape-attributes.js +9 -0
  47. package/dist/dom/shape-effects.js +14 -0
  48. package/dist/dom/shape-geometry.js +3 -0
  49. package/dist/dom/shape-layout.js +115 -116
  50. package/dist/dom/shared-backdrop.js +33 -25
  51. package/dist/dom/specular.js +116 -0
  52. package/dist/dom/ticker.js +28 -19
  53. package/dist/dom/tint-color.js +24 -0
  54. package/dist/dom/warm.js +63 -59
  55. package/dist/dom.js +591 -505
  56. package/dist/gpu/geometry.js +2 -3
  57. package/dist/gpu/maps.js +1109 -7
  58. package/dist/gpu/planes.js +2 -3
  59. package/dist/gpu.js +66 -64
  60. package/dist/index.js +12 -10
  61. package/dist/react/button.js +12 -11
  62. package/dist/react/color-picker.js +199 -0
  63. package/dist/react/control-thumb.js +4 -5
  64. package/dist/react/menu.js +82 -111
  65. package/dist/react/merged-ref.js +1 -2
  66. package/dist/react/progressive.js +1 -2
  67. package/dist/react/scene.js +71 -55
  68. package/dist/react/shape.js +67 -47
  69. package/dist/react/slider.js +81 -0
  70. package/dist/react/surface.js +90 -56
  71. package/dist/react/switch.js +101 -0
  72. package/dist/react/tabs.js +85 -63
  73. package/dist/react/toolbar.js +38 -123
  74. package/dist/react/value-control-motion.js +1 -2
  75. package/dist/styles.css +517 -111
  76. package/dist/types/core/concentric.d.ts +8 -0
  77. package/dist/types/core/corner-options.d.ts +4 -0
  78. package/dist/types/core/corner-path.d.ts +8 -0
  79. package/dist/types/core/index.d.ts +3 -5
  80. package/dist/types/core/materials.d.ts +100 -28
  81. package/dist/types/core/shape.d.ts +4 -6
  82. package/dist/types/core/spring.d.ts +8 -12
  83. package/dist/types/dom/backdrop-glass.d.ts +38 -0
  84. package/dist/types/dom/compose-layers.d.ts +4 -0
  85. package/dist/types/dom/composited.d.ts +61 -0
  86. package/dist/types/dom/escaped-layers.d.ts +32 -0
  87. package/dist/types/dom/filter-bounds.d.ts +4 -0
  88. package/dist/types/dom/filter-chain.d.ts +6 -0
  89. package/dist/types/dom/filter-groups.d.ts +1 -1
  90. package/dist/types/dom/filter-paint-root.d.ts +3 -0
  91. package/dist/types/dom/filter-patch.d.ts +5 -0
  92. package/dist/types/dom/filter-reach.d.ts +9 -9
  93. package/dist/types/dom/foreground.d.ts +2 -1
  94. package/dist/types/dom/index.d.ts +8 -19
  95. package/dist/types/dom/interaction.d.ts +8 -8
  96. package/dist/types/dom/layout-rect.d.ts +17 -0
  97. package/dist/types/dom/layout-size.d.ts +11 -0
  98. package/dist/types/dom/lens-layers.d.ts +18 -10
  99. package/dist/types/dom/map-encoder.d.ts +5 -2
  100. package/dist/types/dom/map-encoding.d.ts +12 -3
  101. package/dist/types/dom/map-image.d.ts +7 -1
  102. package/dist/types/dom/maps.d.ts +25 -7
  103. package/dist/types/dom/material-graph.d.ts +73 -10
  104. package/dist/types/dom/media-mirror.d.ts +49 -0
  105. package/dist/types/dom/progressive.d.ts +2 -5
  106. package/dist/types/dom/sampling-bounds.d.ts +1 -3
  107. package/dist/types/dom/selection.d.ts +29 -4
  108. package/dist/types/dom/shape-attributes.d.ts +6 -0
  109. package/dist/types/dom/shape-effects.d.ts +10 -0
  110. package/dist/types/dom/shape-geometry.d.ts +6 -0
  111. package/dist/types/dom/shape-layout.d.ts +2 -4
  112. package/dist/types/dom/shared-backdrop.d.ts +7 -3
  113. package/dist/types/dom/specular.d.ts +50 -0
  114. package/dist/types/dom/ticker.d.ts +4 -1
  115. package/dist/types/dom/tint-color.d.ts +11 -0
  116. package/dist/types/dom/warm.d.ts +8 -2
  117. package/dist/types/gpu/geometry.d.ts +2 -0
  118. package/dist/types/gpu/planes.d.ts +3 -2
  119. package/dist/types/index.d.ts +1 -1
  120. package/dist/types/react/button.d.ts +1 -1
  121. package/dist/types/react/color-picker.d.ts +26 -0
  122. package/dist/types/react/index.d.ts +14 -10
  123. package/dist/types/react/menu.d.ts +4 -5
  124. package/dist/types/react/progressive.d.ts +1 -1
  125. package/dist/types/react/scene.d.ts +4 -2
  126. package/dist/types/react/shape.d.ts +11 -1
  127. package/dist/types/react/slider.d.ts +14 -0
  128. package/dist/types/react/surface.d.ts +11 -22
  129. package/dist/types/react/switch.d.ts +9 -0
  130. package/dist/types/react/tabs.d.ts +3 -3
  131. package/dist/types/react/toolbar.d.ts +1 -1
  132. package/package.json +46 -40
  133. package/dist/core/morph-path.js +0 -206
  134. package/dist/core/union.js +0 -117
  135. package/dist/dom/compound-field.js +0 -23
  136. package/dist/dom/exit-handoff.js +0 -14
  137. package/dist/dom/map-blend.js +0 -8
  138. package/dist/dom/morph.js +0 -296
  139. package/dist/react/value-controls.js +0 -176
  140. package/dist/types/core/morph-path.d.ts +0 -110
  141. package/dist/types/core/union.d.ts +0 -20
  142. package/dist/types/dom/compound-field.d.ts +0 -35
  143. package/dist/types/dom/exit-handoff.d.ts +0 -7
  144. package/dist/types/dom/map-blend.d.ts +0 -22
  145. package/dist/types/dom/morph.d.ts +0 -78
  146. package/dist/types/react/value-controls.d.ts +0 -20
@@ -30,3 +30,11 @@ export declare function outlineSegments(points: ShapePoint[]): {
30
30
  segments: number[][];
31
31
  count: number;
32
32
  };
33
+ /**
34
+ * The container's shape as its scrolled content sees it: as tall and wide as everything that
35
+ * scrolls in it, with its corners at the content's ends. A row in a scrolling list takes its
36
+ * shape from where it lies in the list, not from where scrolling has put it on screen: the
37
+ * first row meets the top corners and the last the bottom ones, as they do when scrolled to,
38
+ * and nothing in between changes while the list scrolls.
39
+ */
40
+ export declare function scrolledShape(shape: ShapeGeometry, extraWidth: number, extraHeight: number): ShapeGeometry;
@@ -0,0 +1,4 @@
1
+ import type { CornerOptions } from "./corner-path.js";
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): CornerOptions;
@@ -0,0 +1,8 @@
1
+ export interface CornerOptions {
2
+ radius: number;
3
+ smoothing: number;
4
+ preserveSmoothing: boolean;
5
+ curve: "squircle" | "arc";
6
+ }
7
+ /** SVG path `d` for a rectangle with continuous corners. */
8
+ export declare function cornerPath(width: number, height: number, { radius, smoothing, preserveSmoothing, curve }: CornerOptions): string;
@@ -1,10 +1,8 @@
1
1
  export { edgeDisplacement } from "./optics.js";
2
- export { materials } from "./materials.js";
3
- export type { MaterialOptions, GlassMaterial, GlassAppearance, } from "./materials.js";
2
+ export { glassRecipe, refraction } from "./materials.js";
3
+ export type { MaterialOptions, GlassMaterial, GlassAppearance } from "./materials.js";
4
4
  export type { GlassRadius } from "./shape.js";
5
- export { insetShape, concentricOutline, cornerPlacement, contentInsets, polygonClip } from "./concentric.js";
5
+ export { insetShape, concentricOutline, cornerPlacement, contentInsets, polygonClip, } from "./concentric.js";
6
6
  export type { ShapeGeometry, ShapeBounds, ShapePoint } from "./concentric.js";
7
7
  export { Spring, springs, settleTime, rubberBand } from "./spring.js";
8
8
  export type { SpringOptions } from "./spring.js";
9
- export { smoothUnion, smoothMin, roundRectDistance } from "./union.js";
10
- export type { RoundRect } from "./union.js";
@@ -1,5 +1,8 @@
1
1
  import type { GlassRadius } from "./shape.js";
2
- export type GlassMaterial = "clear" | "regular";
2
+ /** Regular and Clear are the two glass styles macOS draws. Lens is the glass
3
+ * a control's thumb turns into under a press: a clear magnifier with colored
4
+ * fringes at its rim, showing the exact pixels under it. */
5
+ export type GlassMaterial = "clear" | "regular" | "lens";
3
6
  export type GlassAppearance = "light" | "dark";
4
7
  export interface MaterialOptions {
5
8
  material?: GlassMaterial;
@@ -9,35 +12,104 @@ export interface MaterialOptions {
9
12
  concentric?: boolean | {
10
13
  inset?: number;
11
14
  };
15
+ /** How far the rim bends in what is behind it, in CSS pixels. Default: set
16
+ * by the material and the glass's size, as on macOS. */
12
17
  refraction?: number;
13
- /** Optional six-digit hex color, e.g. "#007aff". Omit for untinted glass. */
18
+ /** Optional color the glass is tinted with: a six-digit hex color such as
19
+ * "#007aff", or in the DOM scene any CSS color, including a theme variable
20
+ * like "var(--accent)", resolved where the glass is and followed as it
21
+ * changes. Omit for untinted glass. */
14
22
  tint?: string;
23
+ /** A moving highlight along the rim that follows the pointer, and the
24
+ * device's tilt where the browser reports it. Default: false. */
25
+ specular?: boolean;
26
+ /** How frosted the glass is, from 0 (most see-through) to 1 (most frosted),
27
+ * like the Liquid Glass slider in macOS's Appearance settings. Default: 0. */
28
+ frost?: number;
29
+ /** Glass that floats above the window, like a menu, popover or alert,
30
+ * casts the deeper shadow macOS gives those. Default: false. */
31
+ floating?: boolean;
32
+ /** Colored fringes where a Lens bends what is behind it, as macOS draws on
33
+ * a pressed switch or slider thumb. They triple the refraction work, so
34
+ * they are off by default; pressed thumbs turn them on. */
35
+ aberration?: boolean;
15
36
  }
16
- export declare const materials: {
17
- readonly clear: {
18
- readonly blur: 0;
19
- readonly refraction: 60;
20
- readonly light: {
21
- readonly shadowLift: 0.18;
22
- readonly highlightRolloff: 0;
23
- };
24
- readonly dark: {
25
- readonly shadowLift: 0.15;
26
- readonly highlightRolloff: 0.2;
27
- };
28
- };
29
- readonly regular: {
30
- readonly blur: 7.33;
31
- readonly refraction: 60;
32
- readonly light: {
33
- readonly fillSigma: 23;
34
- readonly fillOpacity: 0.34;
35
- readonly tone: readonly [0.36, 0.67, -0.1113, 1.1031];
36
- };
37
- readonly dark: {
38
- readonly fillSigma: 21.8;
39
- readonly fillOpacity: 0.65;
40
- readonly tone: readonly [0.105, 0.83, -0.2091, 1.0648];
41
- };
37
+ /**
38
+ * Native glass changes with its size. macOS 27 derives every value of its
39
+ * glass filter from the shorter side of the shape: controls up to 64 points
40
+ * are nearly clear, and panels pick up frost, a darker face and a shadow as
41
+ * they grow, fully from 160 points. Measured on `NSGlassEffectView` in an
42
+ * active window at 31 sizes.
43
+ */
44
+ /** The size glass takes its look from: its shorter side, in CSS pixels.
45
+ * Floating glass (menus, popovers, dialogs) always looks like a panel, so a
46
+ * short menu and a long one look alike. */
47
+ export declare function glassSize(o: MaterialOptions, width: number, height: number): number;
48
+ export declare function panelAmount(size: number): number;
49
+ /** The lens profile of the rim: how far it reaches in (`amount`) and how
50
+ * deep the bend runs (`height`), both in CSS pixels, for a shape whose
51
+ * shorter side is `size`. */
52
+ export interface Refraction {
53
+ amount: number;
54
+ height: number;
55
+ }
56
+ export declare function refractionFor(material: GlassMaterial, size: number): Refraction;
57
+ /** The most any glass bends, in CSS pixels. */
58
+ export declare const refraction = 60;
59
+ /** Colored fringes at a lens's rim: how far its red and blue channels part
60
+ * from green, in CSS pixels. Only lenses that ask for them have them: macOS
61
+ * shows them on a switch or slider's pressed thumb. */
62
+ export declare function aberrationFor(o: MaterialOptions, size: number): number;
63
+ /**
64
+ * What glass does to the backdrop it sits on. The face reads the refracted
65
+ * backdrop, lightly frosted (`blur`), and blends it with a softer copy of the
66
+ * backdrop beneath it (`fill`): dark glass keeps the darker of the two, light
67
+ * glass the lighter, so fine bright detail melts on dark glass and fine dark
68
+ * detail on light glass while the rest stays sharp. Then saturation and a
69
+ * tone curve shaped on luminance.
70
+ */
71
+ export interface Calibration {
72
+ /** Gaussian standard deviation of the frost, in CSS pixels. */
73
+ blur: number;
74
+ /** Gaussian standard deviation of the softer copy blended in, in CSS
75
+ * pixels; 0 for none. */
76
+ fill: number;
77
+ /** How the softer copy combines: the share kept from the darker (dark) or
78
+ * lighter (light) of the two, and the share of the softer copy laid over
79
+ * everything, which the glass slider raises. */
80
+ fillBlend: {
81
+ mode: "darken" | "lighten";
82
+ amount: number;
83
+ cover: number;
42
84
  };
85
+ /** Saturation applied before the tone curve. */
86
+ saturation: number;
87
+ /** Output (0..1, sRGB) of the tone curve for black, for the middle gray a
88
+ * blurred checkerboard averages to (0.551), and for white. Above 1 clips. */
89
+ tone: readonly [black: number, middle: number, white: number];
90
+ }
91
+ /** The material's frost and tone for its options and size, where `size` is
92
+ * the shorter side of the glass in CSS pixels. */
93
+ export declare function glassRecipe(o: MaterialOptions, size: number): Calibration;
94
+ /** The shadow Regular glass casts outside its shape: a share of black over
95
+ * what is behind it (`opacity`), falling off as a Gaussian of `blur` CSS
96
+ * pixels from the edge, moved down by `dy`. Controls cast next to none;
97
+ * panels and glass that floats above the window cast a soft, wide one. */
98
+ export interface GlassShadow {
99
+ opacity: number;
100
+ blur: number;
101
+ dy: number;
102
+ }
103
+ export declare function shadowFor(o: MaterialOptions, size: number): GlassShadow | undefined;
104
+ /** How far a shadow reaches past its shape, in CSS pixels. */
105
+ export declare function shadowReach(shadow: GlassShadow): number;
106
+ /** How the outline just outside glass darkens what is behind it. A backdrop of
107
+ * brightness x is covered by black at `rim × (base + slope × x)`, where `rim`
108
+ * is the outline's strength from the map (0.47 where the edge faces sideways).
109
+ * Most glass darkens mid gray by 47% and white by 24%; dark Regular glass
110
+ * darkens bright backdrops more, controls a little and panels by up to 71%,
111
+ * as measured on native glass over gray and white. */
112
+ export declare function outlineFor(o: MaterialOptions, size: number): {
113
+ base: number;
114
+ slope: number;
43
115
  };
@@ -1,11 +1,10 @@
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;
1
+ export { cornerOptions } from "./corner-options.js";
2
+ export type { GlassRadius } from "./corner-options.js";
3
+ import type { GlassRadius } from "./corner-options.js";
5
4
  export declare function shapePath(width: number, height: number, radius: GlassRadius): string;
6
5
  export declare function shapeClip(width: number, height: number, radius: GlassRadius): string;
7
6
  type Point = [number, number];
8
- /** Tessellate Lisse's SVG path for the WGSL distance field. This is the same
7
+ /** Tessellate the SVG path for the WGSL distance field. This is the same
9
8
  * outline used by the DOM, not a second corner formula. Uniform shapes are
10
9
  * symmetric, so the GPU only needs the top-right quadrant. */
11
10
  export declare function shapePolygon(width: number, height: number, radius: GlassRadius): Point[];
@@ -13,4 +12,3 @@ export declare function shapeSegments(width: number, height: number, radius: Gla
13
12
  segments: number[][];
14
13
  count: number;
15
14
  };
16
- export {};
@@ -6,27 +6,23 @@ export interface SpringOptions {
6
6
  }
7
7
  /** Named springs shared by every glass interaction, so motion reads as one material. */
8
8
  export declare const springs: {
9
- /** The material catching a finger or pointer. */
9
+ /** The material catching a finger or pointer: grown in about 100ms with a
10
+ * slight overshoot, as macOS glass does. */
10
11
  readonly press: {
11
- readonly duration: 0.24;
12
- readonly bounce: 0.2;
12
+ readonly duration: 0.16;
13
+ readonly bounce: 0.25;
13
14
  };
14
- /** Letting go: gel-like overshoot back to rest. */
15
+ /** Letting go: back to rest in about 200ms, dipping just under it. */
15
16
  readonly release: {
16
- readonly duration: 0.5;
17
- readonly bounce: 0.42;
17
+ readonly duration: 0.26;
18
+ readonly bounce: 0.25;
18
19
  };
19
20
  /** Light settling into and out of the material. */
20
21
  readonly glow: {
21
22
  readonly duration: 0.42;
22
23
  readonly bounce: 0;
23
24
  };
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. */
25
+ /** A selection flowing to a new layout. */
30
26
  readonly layout: {
31
27
  readonly duration: 0.4;
32
28
  readonly bounce: 0.16;
@@ -0,0 +1,38 @@
1
+ import type { MaterialOptions } from "../core/materials.js";
2
+ import type { MaterialMaps } from "./maps.js";
3
+ /**
4
+ * Glass drawn as a backdrop filter of the surface itself, as Chromium can.
5
+ *
6
+ * The filter reads what is painted behind the surface, in the surface's own
7
+ * box and coordinates, and only its own glass: a menu redraws a menu's worth
8
+ * of pixels, not the page's, and glass beneath other glass sees it as it is.
9
+ * What the filter returns is drawn over the backdrop, so it returns only the
10
+ * glass: the face inside the shape, its light and ring, and the outline. The
11
+ * backdrop beyond the box is out of reach, so the shape sits one device pixel
12
+ * inside the box and the outline takes that pixel; the shadow, which reaches
13
+ * far past it, is the surface's box shadow.
14
+ */
15
+ export interface BackdropGlass {
16
+ id: string;
17
+ maps: MaterialMaps;
18
+ options: MaterialOptions;
19
+ /** The surface's layout box, in CSS pixels. */
20
+ width: number;
21
+ height: number;
22
+ /** The shorter side the glass takes its look from (see `glassSize`). */
23
+ size: number;
24
+ /** How far the rim bends, in CSS pixels. */
25
+ refraction: number;
26
+ /** Whether the scene has a backdrop color to show under transparent content. */
27
+ backed: boolean;
28
+ /** CSS pixels per device pixel. */
29
+ pixel: number;
30
+ }
31
+ export declare function backdropGlassFilter(glass: BackdropGlass): string;
32
+ /** The frost Chromium's own `blur()` draws before the glass filter, in CSS
33
+ * pixels: the material's, rounded to a hundredth; 0 for none. */
34
+ export declare function backdropGlassFrost(o: MaterialOptions, size: number): number;
35
+ /** The shadow glass casts, as a CSS box shadow: a Gaussian of `blur` CSS
36
+ * pixels is a box shadow's blur radius of twice that. Glass inside other
37
+ * glass casts none. */
38
+ export declare function backdropGlassShadow(o: MaterialOptions, size: number, nested: boolean): string;
@@ -7,6 +7,10 @@ export interface SparseCompositionUnit {
7
7
  layers: readonly string[];
8
8
  /** Union of every member's output bounds, including outline padding. */
9
9
  bounds: FilterBounds;
10
+ /** Each member's output bounds, when the unit shares one branch between
11
+ * surfaces apart: only these boxes need to be composed with their
12
+ * neighbors, rather than everything inside the union. */
13
+ parts?: readonly FilterBounds[];
10
14
  }
11
15
  /** Replace the source in disjoint rectangular regions. Each region keeps
12
16
  * the exact sequential alpha composition, but its intermediate buffers only
@@ -0,0 +1,61 @@
1
+ /** WebKit cannot run a CSS reference filter in its compositor. It paints the
2
+ * filtered element with the filter applied, then composites every descendant
3
+ * that has a layer of its own on top, unfiltered. Glass drawn by the content's
4
+ * filter therefore lands beneath any such descendant: a video, a WebGL canvas,
5
+ * a 3D transform, a running transform animation, or a positioned element that
6
+ * overlaps one of them. These rules follow `RenderLayerCompositor`.
7
+ *
8
+ * Media keep their pixels in the compositor and ignore filters of their own,
9
+ * so a mirror paints them into the content instead. Every other layer
10
+ * paints its own pixels and takes a copy of the glass on itself. */
11
+ export type CompositingReason = "media" | "layer";
12
+ /** The computed style WebKit decides compositing from. */
13
+ export type CompositingStyle = Pick<CSSStyleDeclaration, "transform" | "translate" | "rotate" | "scale" | "willChange" | "position" | "backfaceVisibility" | "overflowX" | "overflowY" | "zIndex" | "opacity" | "filter" | "clipPath" | "mixBlendMode" | "isolation"> & {
14
+ backdropFilter?: string;
15
+ webkitBackdropFilter?: string;
16
+ maskImage?: string;
17
+ webkitMaskImage?: string;
18
+ };
19
+ /** Whether a computed `transform` or individual transform property moves in depth. */
20
+ export declare function has3DTransform(style: Pick<CompositingStyle, "transform" | "translate" | "rotate" | "scale">): boolean;
21
+ /** Whether the element's transform is declared with 3D operations. */
22
+ export declare function declares3DTransform(element: Element): boolean;
23
+ /** Why WebKit gives this element a compositing layer of its own, if it does. */
24
+ export declare function compositingReason(element: Element, style: CompositingStyle, scrolls: boolean): CompositingReason | undefined;
25
+ /** Whether a running animation changes how its element paints, which
26
+ * WebKit redraws, filters included, on every frame it runs. */
27
+ export declare function animatesPaint(properties: Iterable<string>): boolean;
28
+ /** Whether a running animation is one WebKit runs in its compositor. */
29
+ export declare function animatesInCompositor(properties: Iterable<string>): boolean;
30
+ /** Whether an element paints in a layer of its own, which WebKit must
31
+ * composite once it overlaps an earlier composited layer. */
32
+ export declare function createsLayer(style: CompositingStyle): boolean;
33
+ export interface LayerBox {
34
+ x: number;
35
+ y: number;
36
+ w: number;
37
+ h: number;
38
+ }
39
+ interface Ordered<T> {
40
+ item: T;
41
+ box: LayerBox;
42
+ order: number;
43
+ }
44
+ /** Close a set of composited layers over the layers that paint after and
45
+ * overlap them, as WebKit's overlap testing does. A layer never escapes
46
+ * because of its own ancestor or descendant. */
47
+ export declare function overlapComposited<T>(composited: readonly Ordered<T>[], layered: readonly Ordered<T>[], related: (a: T, b: T) => boolean): T[];
48
+ export declare function intersects(a: LayerBox, b: LayerBox, margin?: number): boolean;
49
+ export interface CompositedLayer {
50
+ element: HTMLElement;
51
+ reason: CompositingReason;
52
+ }
53
+ /** Find the descendants of `content` that WebKit composites apart from it,
54
+ * outermost first. Boxes are in the content's scrolled space, so they stay
55
+ * valid while it scrolls. `skip` excludes nodes the scene owns. */
56
+ export declare function scanCompositedLayers(content: HTMLElement, skip: (element: Element) => boolean): CompositedLayer[];
57
+ /** Video or canvas, whose pixels WebKit hands straight to its compositor. */
58
+ export type MirroredMedia = HTMLVideoElement | HTMLCanvasElement;
59
+ /** Whether the media can be drawn onto a canvas at all. */
60
+ export declare function mirrorable(media: Element): media is MirroredMedia;
61
+ export {};
@@ -0,0 +1,32 @@
1
+ import type { MaterialOptions } from "../core/materials.js";
2
+ import type { LayerBox } from "./composited.js";
3
+ /** Glass over content that WebKit composites apart from the content's filter.
4
+ * Loaded only in WebKit. See `composited.ts` for why such content escapes,
5
+ * and `media-mirror.ts` for how video and canvas pixels are brought back. */
6
+ /** A lens as the scene measured it this frame, in the content's coordinates. */
7
+ export interface EscapeLens extends LayerBox {
8
+ element: HTMLElement;
9
+ options: MaterialOptions;
10
+ /** The shape the lens shows; an outline makes its refraction asymmetric. */
11
+ shown?: {
12
+ outline?: unknown;
13
+ };
14
+ }
15
+ /** A composited layer that draws its own copy of the glass over it. */
16
+ export interface LayerGlass extends LayerBox {
17
+ element: HTMLElement;
18
+ scale: number;
19
+ }
20
+ export interface EscapePlan {
21
+ layers: LayerGlass[];
22
+ /** Whether the next frame must run, for an animation or a mirror still being placed. */
23
+ busy: boolean;
24
+ write: () => void;
25
+ }
26
+ export interface EscapedLayers {
27
+ plan(content: HTMLElement | null, origin: DOMRect, lenses: readonly EscapeLens[], skip: readonly Element[], now: number, structure: number, blur: (lens: EscapeLens) => number): EscapePlan;
28
+ /** Whether a mutation is this module's own output. */
29
+ owns(node: Node, record: MutationRecord): boolean;
30
+ dispose(): void;
31
+ }
32
+ export declare function createEscapedLayers(wake: () => void): EscapedLayers;
@@ -13,6 +13,8 @@ export interface EdgeSides {
13
13
  bottom: boolean;
14
14
  /** Corners some region reaches past on both of its sides, indexed [x][y] as 0 or 2. */
15
15
  corners: Set<string>;
16
+ /** Along each crossed side, the range the regions crossing it cover. */
17
+ spans?: Partial<Record<"left" | "top" | "right" | "bottom", [number, number]>>;
16
18
  }
17
19
  /** Which content edges, and which corners, a sampled region crosses. */
18
20
  export declare function crossedSides(width: number, height: number, regions: readonly FilterBounds[]): EdgeSides;
@@ -28,3 +30,5 @@ export declare function edgeTiles(width: number, height: number, bounds: FilterB
28
30
  };
29
31
  /** The tile keys a region needs: its crossed sides, and the corners of two crossed sides. */
30
32
  export declare function tilesFor(width: number, height: number, r: FilterBounds): string[];
33
+ /** Whether two boxes share any area. */
34
+ export declare const boundsMeet: (a: FilterBounds, b: FilterBounds) => boolean;
@@ -0,0 +1,6 @@
1
+ /** Set one owner's filters on an element; an empty value draws nothing but keeps the claim. */
2
+ export declare function setFilterPart(element: HTMLElement, owner: string, depth: number, value: string): void;
3
+ export declare function releaseFilterPart(element: HTMLElement, owner: string): void;
4
+ export declare function registerSceneRoot(root: Element): () => void;
5
+ /** How many glass scenes enclose this one; inner scenes filter first. */
6
+ export declare function sceneDepth(root: Element): number;
@@ -21,5 +21,5 @@ export interface BranchRegions {
21
21
  export declare function clusterFilterBranches<T>(members: readonly T[], regions: (member: T) => BranchRegions, stages: {
22
22
  output: number;
23
23
  sampled: number;
24
- }): T[][];
24
+ }, limit?: number): T[][];
25
25
  export {};
@@ -7,3 +7,6 @@ export declare function acquireFilterPaintRoot(element: HTMLElement): () => void
7
7
  * Opacity preserves the containing block of fixed-position descendants.
8
8
  */
9
9
  export declare function acquireSceneCompositingLayer(element: HTMLElement): () => void;
10
+ /** Give an element WebKit repaints on every frame a layer of its own, so its
11
+ * repaints never re-run the filter of the content it sits in. */
12
+ export declare function acquireRepaintLayer(element: HTMLElement): () => void;
@@ -1,3 +1,8 @@
1
+ /** Animated geometry and opacity weights approach their targets in steps
2
+ * no display can show, and every changed primitive re-renders the whole
3
+ * filtered layer. Round primitive lengths to 1/16 px and weights to 1/1024,
4
+ * below one 8-bit step, so those frames repeat the last markup exactly. */
5
+ export declare function quantizeFilterMarkup(markup: string): string;
1
6
  /** Retain filter primitives and their loaded images across geometry changes.
2
7
  * The last description also owns the attribute values, avoiding live DOM
3
8
  * collection reads and redundant writes. Exact repeats do no parsing at all. */
@@ -8,16 +8,16 @@ import type { FilterBounds } from "./filter-bounds.js";
8
8
  /** Outsets, in user units, that let any repaint inside a `width` × `height`
9
9
  * element reach every primitive subregion of `markup` and every `extra` box. */
10
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.
11
+ /** Raise repaint reach with a transparent branch in the last merge.
14
12
  *
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;
13
+ * WebKit charges a displacement `scale / 2` of outsets wherever its region
14
+ * is, and an image whose region misses the repaint fails the whole filter.
15
+ * Every primitive region is in reach of any repaint, so a one-pixel seed
16
+ * inside one of them always yields an image, and displacing it by a map
17
+ * with no coverage keeps it transparent. Two one-pixel primitives reach as
18
+ * far as any full-size padding, which software filters fill on every render.
19
+ * Without such a region, a transparent flood covers the element instead. */
20
+ export declare function padRepaintReach(markup: string, outsets: number, width: number, height: number, naturalOutsets?: number): string;
21
21
  /** A tile grows its own rectangle by the outsets once rather than twice,
22
22
  * so it needs about twice the outsets of a whole-layer repaint. */
23
23
  export declare const tiledReach = 2;
@@ -12,7 +12,8 @@ export interface ForegroundLens {
12
12
  }
13
13
  /** Compare sibling stacking branches before falling back to document order. */
14
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;
15
+ /** Whether two boxes overlap, or come within `reach` pixels of each other. */
16
+ export declare function overlaps(a: Pick<ForegroundLens, "x" | "y" | "w" | "h">, b: Pick<ForegroundLens, "x" | "y" | "w" | "h">, reach?: number): boolean;
16
17
  /** Filter live foreground DOM through higher lenses, without repainting their rims.
17
18
  * Transparent input must stay transparent: unlike the backdrop pass, no edge
18
19
  * extension or opaque material fill belongs in this foreground contribution.
@@ -1,10 +1,8 @@
1
1
  import type { GlassMotion, SurfaceAnimator } from "./interaction.js";
2
- import type { GlassMorph } from "./morph.js";
3
2
  export { attachInteraction, resolveMotion } from "./interaction.js";
4
3
  export type { GlassMotion, SurfaceAnimator } from "./interaction.js";
5
- export { attachGeometryMotion, radiusPixels } from "./morph.js";
6
4
  export { attachSelectionLens } from "./selection.js";
7
- export type { GeometryAnimator, GeometryMotionOptions, GlassMorph, LensFrame, LensPlacement, LensWaypoint } from "./morph.js";
5
+ export type { SelectionLens } from "./selection.js";
8
6
  import type { ScrollEdgesOptions } from "./progressive.js";
9
7
  import type { ProgressiveBlurOptions } from "../core/progressive.js";
10
8
  export type { ScrollEdgesOptions, GlassScrollTarget } from "./progressive.js";
@@ -26,23 +24,10 @@ export interface SurfaceOptions extends MaterialOptions {
26
24
  /** React to touch and pointer input: grow, stretch toward a drag, settle with
27
25
  * overshoot, and light up beneath the pointer. */
28
26
  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
27
  /** Motion level for this surface. System reduced motion always applies. */
41
28
  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;
29
+ /** A popup, such as a menu: its scene rises above sibling scenes while it is present. */
30
+ popup?: boolean;
46
31
  }
47
32
  export interface GlassSceneController {
48
33
  /** Optional transparent, nested filter hosts in inner-to-outer order.
@@ -50,6 +35,10 @@ export interface GlassSceneController {
50
35
  * reserve the final host for progressive blur. */
51
36
  setContent(element: HTMLElement | null): void;
52
37
  addSurface(element: HTMLElement, options?: SurfaceOptions): () => void;
38
+ /** Change how an added surface looks (material, appearance, tint, frost,
39
+ * refraction, floating, aberration) without removing it: its shape, place
40
+ * and motion carry on, so nothing anchored to it moves. */
41
+ updateSurface(element: HTMLElement, options: Pick<SurfaceOptions, "material" | "appearance" | "tint" | "frost" | "refraction" | "floating" | "aberration">): void;
53
42
  /** Live DOM above the backdrop that must pass through overlapping glass. */
54
43
  addForeground(element: HTMLElement): () => void;
55
44
  /** Step an animation each frame before the scene samples glass geometry. */
@@ -60,5 +49,5 @@ export interface GlassSceneController {
60
49
  }
61
50
  /** Refract one explicit live DOM layer. Foreground controls stay semantic HTML. */
62
51
  export declare function createGlassScene(root: HTMLElement, config?: GlassSceneOptions): GlassSceneController;
63
- export { registerShapeContainer, observeConcentricShape, observeCornerPlacement } from "./shape-layout.js";
52
+ export { registerShapeContainer, observeConcentricShape, observeCornerPlacement, } from "./shape-layout.js";
64
53
  export type { ConcentricOptions, CornerOptions, GlassCornerPosition } from "./shape-layout.js";
@@ -3,14 +3,14 @@ export type GlassMotion = "full" | "reduced" | "none";
3
3
  export declare function resolveMotion(motion: GlassMotion | undefined): GlassMotion;
4
4
  export interface SurfaceAnimator {
5
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;
6
+ * the animation is in motion and needs the next frame. */
7
+ frame(now: number): boolean | void;
10
8
  dispose(): void;
11
9
  }
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. */
10
+ /** The response of interactive glass to touch and pointer input, as macOS
11
+ * draws it: under a press the glass grows 2.5 points wider, keeping its
12
+ * proportions, and a soft light gathers under the finger; on release it
13
+ * settles back, dipping just under its size. A drag neither moves nor
14
+ * stretches it. Writes only `scale` and custom properties, so consumer
15
+ * `transform` and `translate` styles continue to compose. */
16
16
  export declare function attachInteraction(element: HTMLElement, motion: () => GlassMotion): SurfaceAnimator;
@@ -0,0 +1,17 @@
1
+ /** A box on screen as layout placed it, before any `scale` that glass writes
2
+ * while it is pressed. Interactive glass grows under a press; a popup
3
+ * anchored to something inside it would otherwise move with it. */
4
+ export interface LayoutRect {
5
+ x: number;
6
+ y: number;
7
+ left: number;
8
+ top: number;
9
+ right: number;
10
+ bottom: number;
11
+ width: number;
12
+ height: number;
13
+ }
14
+ /** `element`'s client rect with every inline `scale` on it and its ancestors
15
+ * undone. Each scale is undone about its own transform origin, outermost
16
+ * first, so nested pressed glass resolves too. */
17
+ export declare function layoutRect(element: HTMLElement): LayoutRect;
@@ -0,0 +1,11 @@
1
+ /** An element's border-box size as layout gave it, before any transform. */
2
+ export declare function getLayoutSize(element: HTMLElement, style?: CSSStyleDeclaration): {
3
+ width: number;
4
+ height: number;
5
+ };
6
+ /** Call back with the element's layout size once now and after each resize,
7
+ * at most once per frame. */
8
+ export declare function observeLayoutSize(element: HTMLElement, callback: (size: {
9
+ width: number;
10
+ height: number;
11
+ }) => void): () => void;