@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.
- package/CHANGELOG.md +124 -0
- package/README.md +66 -149
- package/dist/core/concentric.js +20 -3
- package/dist/core/corner-options.js +12 -0
- package/dist/core/corner-path.js +118 -0
- package/dist/core/materials.js +264 -32
- package/dist/core/optics.js +1 -2
- package/dist/core/progressive.js +1 -2
- package/dist/core/shape.js +18 -28
- package/dist/core/spring.js +5 -10
- package/dist/core.js +5 -6
- package/dist/dom/backdrop-glass.js +46 -0
- package/dist/dom/compose-layers.js +42 -31
- package/dist/dom/composited.js +136 -0
- package/dist/dom/control-motion.js +58 -47
- package/dist/dom/engine.js +1 -2
- package/dist/dom/escaped-layers.js +179 -0
- package/dist/dom/filter-bounds.js +42 -13
- package/dist/dom/filter-budget.js +1 -2
- package/dist/dom/filter-chain.js +40 -0
- package/dist/dom/filter-groups.js +33 -14
- package/dist/dom/filter-paint-root.js +8 -6
- package/dist/dom/filter-patch.js +94 -55
- package/dist/dom/filter-reach.js +32 -19
- package/dist/dom/filter-stages.js +1 -2
- package/dist/dom/fixed-shape.js +23 -16
- package/dist/dom/foreground.js +16 -17
- package/dist/dom/interaction.js +65 -92
- package/dist/dom/layout-rect.js +42 -0
- package/dist/dom/layout-size.js +28 -0
- package/dist/dom/lens-layers.js +250 -136
- package/dist/dom/map-encoder.js +16 -13
- package/dist/dom/map-encoder.worker.js +2 -3
- package/dist/dom/map-encoding.js +49 -12
- package/dist/dom/map-image.js +29 -7
- package/dist/dom/map-store.js +1 -2
- package/dist/dom/maps.js +133 -83
- package/dist/dom/material-graph.js +108 -29
- package/dist/dom/media-mirror.js +244 -0
- package/dist/dom/page-zoom.js +19 -18
- package/dist/dom/png.js +1 -2
- package/dist/dom/progressive.js +152 -147
- package/dist/dom/renderer.js +1 -2
- package/dist/dom/sampling-bounds.js +1 -2
- package/dist/dom/selection.js +133 -79
- package/dist/dom/shape-attributes.js +9 -0
- package/dist/dom/shape-effects.js +14 -0
- package/dist/dom/shape-geometry.js +3 -0
- package/dist/dom/shape-layout.js +115 -116
- package/dist/dom/shared-backdrop.js +33 -25
- package/dist/dom/specular.js +116 -0
- package/dist/dom/ticker.js +28 -19
- package/dist/dom/tint-color.js +24 -0
- package/dist/dom/warm.js +63 -59
- package/dist/dom.js +591 -505
- package/dist/gpu/geometry.js +2 -3
- package/dist/gpu/maps.js +1109 -7
- package/dist/gpu/planes.js +2 -3
- package/dist/gpu.js +66 -64
- package/dist/index.js +12 -10
- package/dist/react/button.js +12 -11
- package/dist/react/color-picker.js +199 -0
- package/dist/react/control-thumb.js +4 -5
- package/dist/react/menu.js +82 -111
- package/dist/react/merged-ref.js +1 -2
- package/dist/react/progressive.js +1 -2
- package/dist/react/scene.js +71 -55
- package/dist/react/shape.js +67 -47
- package/dist/react/slider.js +81 -0
- package/dist/react/surface.js +90 -56
- package/dist/react/switch.js +101 -0
- package/dist/react/tabs.js +85 -63
- package/dist/react/toolbar.js +38 -123
- package/dist/react/value-control-motion.js +1 -2
- package/dist/styles.css +517 -111
- package/dist/types/core/concentric.d.ts +8 -0
- package/dist/types/core/corner-options.d.ts +4 -0
- package/dist/types/core/corner-path.d.ts +8 -0
- package/dist/types/core/index.d.ts +3 -5
- package/dist/types/core/materials.d.ts +100 -28
- package/dist/types/core/shape.d.ts +4 -6
- package/dist/types/core/spring.d.ts +8 -12
- package/dist/types/dom/backdrop-glass.d.ts +38 -0
- package/dist/types/dom/compose-layers.d.ts +4 -0
- package/dist/types/dom/composited.d.ts +61 -0
- package/dist/types/dom/escaped-layers.d.ts +32 -0
- package/dist/types/dom/filter-bounds.d.ts +4 -0
- package/dist/types/dom/filter-chain.d.ts +6 -0
- package/dist/types/dom/filter-groups.d.ts +1 -1
- package/dist/types/dom/filter-paint-root.d.ts +3 -0
- package/dist/types/dom/filter-patch.d.ts +5 -0
- package/dist/types/dom/filter-reach.d.ts +9 -9
- package/dist/types/dom/foreground.d.ts +2 -1
- package/dist/types/dom/index.d.ts +8 -19
- package/dist/types/dom/interaction.d.ts +8 -8
- package/dist/types/dom/layout-rect.d.ts +17 -0
- package/dist/types/dom/layout-size.d.ts +11 -0
- package/dist/types/dom/lens-layers.d.ts +18 -10
- package/dist/types/dom/map-encoder.d.ts +5 -2
- package/dist/types/dom/map-encoding.d.ts +12 -3
- package/dist/types/dom/map-image.d.ts +7 -1
- package/dist/types/dom/maps.d.ts +25 -7
- package/dist/types/dom/material-graph.d.ts +73 -10
- package/dist/types/dom/media-mirror.d.ts +49 -0
- package/dist/types/dom/progressive.d.ts +2 -5
- package/dist/types/dom/sampling-bounds.d.ts +1 -3
- package/dist/types/dom/selection.d.ts +29 -4
- package/dist/types/dom/shape-attributes.d.ts +6 -0
- package/dist/types/dom/shape-effects.d.ts +10 -0
- package/dist/types/dom/shape-geometry.d.ts +6 -0
- package/dist/types/dom/shape-layout.d.ts +2 -4
- package/dist/types/dom/shared-backdrop.d.ts +7 -3
- package/dist/types/dom/specular.d.ts +50 -0
- package/dist/types/dom/ticker.d.ts +4 -1
- package/dist/types/dom/tint-color.d.ts +11 -0
- package/dist/types/dom/warm.d.ts +8 -2
- package/dist/types/gpu/geometry.d.ts +2 -0
- package/dist/types/gpu/planes.d.ts +3 -2
- package/dist/types/index.d.ts +1 -1
- package/dist/types/react/button.d.ts +1 -1
- package/dist/types/react/color-picker.d.ts +26 -0
- package/dist/types/react/index.d.ts +14 -10
- package/dist/types/react/menu.d.ts +4 -5
- package/dist/types/react/progressive.d.ts +1 -1
- package/dist/types/react/scene.d.ts +4 -2
- package/dist/types/react/shape.d.ts +11 -1
- package/dist/types/react/slider.d.ts +14 -0
- package/dist/types/react/surface.d.ts +11 -22
- package/dist/types/react/switch.d.ts +9 -0
- package/dist/types/react/tabs.d.ts +3 -3
- package/dist/types/react/toolbar.d.ts +1 -1
- package/package.json +46 -40
- package/dist/core/morph-path.js +0 -206
- package/dist/core/union.js +0 -117
- package/dist/dom/compound-field.js +0 -23
- package/dist/dom/exit-handoff.js +0 -14
- package/dist/dom/map-blend.js +0 -8
- package/dist/dom/morph.js +0 -296
- package/dist/react/value-controls.js +0 -176
- package/dist/types/core/morph-path.d.ts +0 -110
- package/dist/types/core/union.d.ts +0 -20
- package/dist/types/dom/compound-field.d.ts +0 -35
- package/dist/types/dom/exit-handoff.d.ts +0 -7
- package/dist/types/dom/map-blend.d.ts +0 -22
- package/dist/types/dom/morph.d.ts +0 -78
- package/dist/types/react/value-controls.d.ts +0 -20
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import type { MaterialOptions } from "../core/materials.js";
|
|
2
|
-
import type { PlacedMap } from "./map-blend.js";
|
|
3
2
|
import type { MaterialMaps } from "./maps.js";
|
|
4
3
|
import type { ProgressiveRegion } from "./progressive.js";
|
|
5
4
|
/** A surface's border box on screen and the scale its transforms apply. */
|
|
@@ -11,17 +10,20 @@ export interface LayerFrame {
|
|
|
11
10
|
clientLeft: number;
|
|
12
11
|
clientTop: number;
|
|
13
12
|
}
|
|
13
|
+
/** How a surface's layer gets what is behind it. `copy` paints a live
|
|
14
|
+
* `-moz-element()` view of the content and refracts it: Gecko, for glass
|
|
15
|
+
* beside the content. `backdrop` filters the surface's own backdrop with the
|
|
16
|
+
* material on the GPU, without refraction: Gecko, for glass inside the
|
|
17
|
+
* content, which a copy of the content would show its own face. `flat` gives
|
|
18
|
+
* the glass a body of the backdrop color: WebKit, for glass inside the
|
|
19
|
+
* content, which WebKit cannot filter from beneath. */
|
|
20
|
+
export type LayerMode = "copy" | "backdrop" | "flat";
|
|
14
21
|
export interface LayerLens {
|
|
15
22
|
serial: number;
|
|
23
|
+
mode: LayerMode;
|
|
16
24
|
element: HTMLElement;
|
|
17
25
|
options: MaterialOptions;
|
|
18
26
|
maps: MaterialMaps;
|
|
19
|
-
/** Prepared shapes blended in motion, in content coordinates. */
|
|
20
|
-
place?: {
|
|
21
|
-
a: PlacedMap;
|
|
22
|
-
b: PlacedMap;
|
|
23
|
-
mix: number;
|
|
24
|
-
};
|
|
25
27
|
/** Drawn glass in content coordinates. */
|
|
26
28
|
x: number;
|
|
27
29
|
y: number;
|
|
@@ -30,6 +32,9 @@ export interface LayerLens {
|
|
|
30
32
|
opacity: number;
|
|
31
33
|
/** Displacement travel in CSS pixels. */
|
|
32
34
|
refraction: number;
|
|
35
|
+
/** The surface's own size, before any transform. */
|
|
36
|
+
layoutWidth?: number;
|
|
37
|
+
layoutHeight?: number;
|
|
33
38
|
/** Glass this surface sits inside, innermost first. */
|
|
34
39
|
parents: readonly LayerLens[];
|
|
35
40
|
/** Earlier glass, not an ancestor, close enough to be refracted. */
|
|
@@ -52,16 +57,19 @@ interface Box {
|
|
|
52
57
|
* (and of the glass under it) and refracts only that. The content layer
|
|
53
58
|
* itself stays unfiltered on the GPU. An unchanged layer is never
|
|
54
59
|
* rasterized again, and a moving one costs only its own area. */
|
|
60
|
+
export type LensLayers = ReturnType<typeof createLensLayers>;
|
|
55
61
|
export declare function createLensLayers(root: HTMLElement): {
|
|
56
62
|
/** `blur` is the scene's progressive blur when it is drawn on a host
|
|
57
63
|
* around the content rather than on the content: layers then blur their
|
|
58
64
|
* 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
|
-
|
|
65
|
+
* blurred content to sample a small part of it. With `backdrop`, each
|
|
66
|
+
* layer's copy lies over the scene's backdrop color, which a backdrop
|
|
67
|
+
* filter receives resolved as `backdropColor`. */
|
|
68
|
+
update(lenses: readonly LayerLens[], content: HTMLElement | null, contentRect: Box, blur?: {
|
|
61
69
|
left: number;
|
|
62
70
|
top: number;
|
|
63
71
|
regions: readonly ProgressiveRegion[];
|
|
64
|
-
}): void;
|
|
72
|
+
}, backdrop?: boolean, resolvedBackdrop?: string): void;
|
|
65
73
|
owns(node: Node): boolean;
|
|
66
74
|
dispose(): void;
|
|
67
75
|
};
|
|
@@ -1,5 +1,8 @@
|
|
|
1
|
-
|
|
1
|
+
import type { NineCut } from "./map-encoding.js";
|
|
2
|
+
/** Encode map planes (and capsule slices and nine-slice tiles) to `data:` URLs on a worker, so the
|
|
2
3
|
* main thread never compresses images. Without workers (including under a
|
|
3
4
|
* restrictive CSP) the identical encoder runs locally. The pixels are copied
|
|
4
5
|
* for the worker, so they remain available for that fallback. */
|
|
5
|
-
export declare function encodeMaterialPixels(pixels: Uint8Array, width: number, height: number, cap?: number): Promise<string[][]>;
|
|
6
|
+
export declare function encodeMaterialPixels(pixels: Uint8Array, width: number, height: number, cap?: number, nine?: NineCut): Promise<string[][]>;
|
|
7
|
+
/** Starts the encoder's worker ahead of the first map that needs it. */
|
|
8
|
+
export declare function warmMapEncoder(): void;
|
|
@@ -1,5 +1,14 @@
|
|
|
1
|
+
/** How to cut a map into nine tiles for Chromium's backdrop glass: the
|
|
2
|
+
* corner tiles' width and height in map pixels. Between the corners a shape's
|
|
3
|
+
* edge runs straight and its maps do not change along it, so one column or
|
|
4
|
+
* row of pixels repeated across that span draws it exactly. */
|
|
5
|
+
export interface NineCut {
|
|
6
|
+
x: number;
|
|
7
|
+
y: number;
|
|
8
|
+
}
|
|
1
9
|
/** Encode GPU readback pixels, never DOM content. The atlas holds its planes
|
|
2
10
|
* stacked vertically. Each plane yields its full image followed, for capsule
|
|
3
|
-
* maps, by its left, middle, and right slices
|
|
4
|
-
*
|
|
5
|
-
|
|
11
|
+
* maps, by its left, middle, and right slices, and then, with a nine-slice
|
|
12
|
+
* cut, by its nine tiles row by row: corners, and the single column or row
|
|
13
|
+
* between them. Everything runs on the CPU of whichever thread calls it. */
|
|
14
|
+
export declare function encodeMapPixels(pixels: Uint8Array, width: number, height: number, cap?: number, nine?: NineCut): Promise<string[][]>;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { MapGeometry } from "../gpu/geometry.js";
|
|
2
2
|
import type { MaterialMaps } from "./maps.js";
|
|
3
|
-
export type MapPlane = "field" | "
|
|
3
|
+
export type MapPlane = "field" | "rim" | "light";
|
|
4
4
|
/** Map resources belong to a surface, even when its material branch is
|
|
5
5
|
* regrouped as another surface enters, moves nearby, or is absorbed. */
|
|
6
6
|
export declare const surfaceMapResult: (serial: number, plane: MapPlane) => string;
|
|
@@ -15,3 +15,9 @@ export declare function releaseMapToken(url: string): void;
|
|
|
15
15
|
* capsule keeps round ends: caps scale with its height and only the straight
|
|
16
16
|
* middle stretches. No DOM rasterization. */
|
|
17
17
|
export declare function mapImage(maps: MaterialMaps, plane: MapPlane, result: string, x: number, y: number, width: number, height: number, unitX?: number, unitY?: number): string;
|
|
18
|
+
/** Place one plane of maps cut into nine tiles (see `MaterialMaps.nine`):
|
|
19
|
+
* corners at their own size and the strips between them stretched. Maps that
|
|
20
|
+
* are not cut are placed whole. */
|
|
21
|
+
export declare function nineMapImage(maps: MaterialMaps, plane: MapPlane, result: string, x: number, y: number, width: number, height: number,
|
|
22
|
+
/** CSS pixels per device pixel; tile edges land on device pixels. */
|
|
23
|
+
pixel?: number): string;
|
package/dist/types/dom/maps.d.ts
CHANGED
|
@@ -3,8 +3,10 @@ import type { MapPlane } from "./map-image.js";
|
|
|
3
3
|
export interface MaterialMaps {
|
|
4
4
|
/** Displacement in red and green, shape coverage in alpha. */
|
|
5
5
|
field: string;
|
|
6
|
-
/**
|
|
7
|
-
|
|
6
|
+
/** The outline just outside the shape, as black coverage. */
|
|
7
|
+
rim: string;
|
|
8
|
+
/** The key and fill light on the rim, as white light to add to the glass. */
|
|
9
|
+
light: string;
|
|
8
10
|
duration: number;
|
|
9
11
|
/** Capsule maps reused at any width: CSS cap width, plane height, and slices. */
|
|
10
12
|
capsule?: {
|
|
@@ -12,13 +14,26 @@ export interface MaterialMaps {
|
|
|
12
14
|
height: number;
|
|
13
15
|
planes: Record<MapPlane, [string, string, string]>;
|
|
14
16
|
};
|
|
17
|
+
/** The maps cut for Chromium's backdrop glass, whose filters carry their
|
|
18
|
+
* images, pixel for pixel, into every frame they draw: each plane's four
|
|
19
|
+
* corners and the single column or row between them, stretched along the
|
|
20
|
+
* straight edges. `x` and `y` are the corner tiles' size in CSS pixels; each
|
|
21
|
+
* plane's nine tiles are listed row by row. */
|
|
22
|
+
nine?: {
|
|
23
|
+
x: number;
|
|
24
|
+
y: number;
|
|
25
|
+
planes: Record<MapPlane, string[]>;
|
|
26
|
+
};
|
|
15
27
|
}
|
|
28
|
+
/**
|
|
29
|
+
* Readies what drawing a new map takes before any glass needs one: the GPU renderer (its device,
|
|
30
|
+
* its compiled shader and a first render) and the encoder's worker. Glass of a size not drawn
|
|
31
|
+
* before (a dialog the first time it opens) then waits only for its own map, not for them.
|
|
32
|
+
*/
|
|
33
|
+
export declare function warmMapPipeline(): void;
|
|
16
34
|
export declare function getMaterialMaps(g: MapGeometry): Promise<MaterialMaps>;
|
|
17
|
-
/** Internal surface path; public map requests still return the exact geometry.
|
|
18
|
-
|
|
19
|
-
* loads: with `persist` false they are rendered at once and never wait on the
|
|
20
|
-
* store, whose startup read can take longer than the animation. */
|
|
21
|
-
export declare function getSurfaceMaterialMaps(g: MapGeometry, persist?: boolean): Promise<MaterialMaps>;
|
|
35
|
+
/** Internal surface path; public map requests still return the exact geometry. */
|
|
36
|
+
export declare function getSurfaceMaterialMaps(g: MapGeometry): Promise<MaterialMaps>;
|
|
22
37
|
/** Maps for a surface available without waiting a task: already shown, or
|
|
23
38
|
* stored from an earlier load. Stored maps are handed out before their images
|
|
24
39
|
* are decoded; a filter image resolves a `data:` URL in the frame it is
|
|
@@ -28,4 +43,7 @@ export declare function peekMaterialMaps(g: MapGeometry): MaterialMaps | undefin
|
|
|
28
43
|
export declare function decode(url: string): Promise<void>;
|
|
29
44
|
/** Record that maps were drawn, so eviction never releases images on screen. */
|
|
30
45
|
export declare function touchMaps(maps: MaterialMaps): void;
|
|
46
|
+
/** The images glass draws from a set of maps, which are decoded and warmed
|
|
47
|
+
* before it shows: Chromium's backdrop glass draws only the nine tiles. */
|
|
48
|
+
export declare function drawnMapUrls(maps: MaterialMaps): string[];
|
|
31
49
|
export declare function clearMaterialMapCache(): void;
|
|
@@ -1,12 +1,47 @@
|
|
|
1
|
-
import type { MaterialOptions } from "../core/materials.js";
|
|
2
|
-
/**
|
|
3
|
-
*
|
|
4
|
-
|
|
1
|
+
import type { GlassShadow, MaterialOptions } from "../core/materials.js";
|
|
2
|
+
/** Filter passes shared by every renderer of one lens: the frosted backdrop,
|
|
3
|
+
* the calibrated tone of each material, and tint. Each names its results
|
|
4
|
+
* after the lens prefix `p`. */
|
|
5
|
+
/** The scene's backdrop color: what glass treats as behind it wherever the
|
|
6
|
+
* content is transparent. It resolves where the glass draws, so a theme
|
|
7
|
+
* changing `--lg-backdrop` recolors the glass without a new filter. */
|
|
8
|
+
export declare const backdropColor = "var(--lg-backdrop, transparent)";
|
|
9
|
+
/** Whether a computed `--lg-backdrop` paints anything. Unset, it is empty
|
|
10
|
+
* (or transparent, once the stylesheet registers it as a color), and the
|
|
11
|
+
* glass is drawn exactly as without a backdrop. */
|
|
12
|
+
export declare function hasBackdrop(value: string): boolean;
|
|
13
|
+
/** The backdrop color across `box`, named `result`. */
|
|
14
|
+
export declare function backdropMarkup(result: string, box: {
|
|
15
|
+
x: number;
|
|
16
|
+
y: number;
|
|
17
|
+
width: number;
|
|
18
|
+
height: number;
|
|
19
|
+
}): string;
|
|
20
|
+
/** Glass refracts a lightly frosted copy of its backdrop: one blur, as wide
|
|
21
|
+
* as the material, its size and its frost call for. Glass with no frost reads
|
|
22
|
+
* its backdrop directly. */
|
|
23
|
+
export declare function frostMarkup(p: string, input: string, o: MaterialOptions, size: number, soften?: number): {
|
|
5
24
|
markup: string;
|
|
6
25
|
result: string;
|
|
7
26
|
};
|
|
8
|
-
|
|
9
|
-
|
|
27
|
+
export declare function refractMarkup(p: string, input: string, amount: number, aberration?: number): string;
|
|
28
|
+
/** The softer copy of the backdrop Regular glass blends with its refracted
|
|
29
|
+
* face, read from `backdrop` where the glass is, unrefracted: dark glass keeps
|
|
30
|
+
* the darker of the two and light glass the lighter, then the glass slider
|
|
31
|
+
* lays more of the softer copy over the whole face. Returns `refracted`
|
|
32
|
+
* unchanged for glass without one. */
|
|
33
|
+
export declare function fillMarkup(p: string, refracted: string, backdrop: string, o: MaterialOptions, size: number, soften?: number, frosted?: string): {
|
|
34
|
+
markup: string;
|
|
35
|
+
result: string;
|
|
36
|
+
};
|
|
37
|
+
/** The material's color applied to `${p}refracted`, written to `${p}color`.
|
|
38
|
+
*
|
|
39
|
+
* As on macOS, brightness is shaped on luminance and applied to each pixel as
|
|
40
|
+
* one multiplier, so the glass keeps the hue and colorfulness of what is
|
|
41
|
+
* behind it; only the lift of the blacks is added evenly. Shaping each channel
|
|
42
|
+
* on its own would flatten bright colors toward gray. The curve runs through
|
|
43
|
+
* the calibrated black, middle and white outputs: `black + L * h(L)`. */
|
|
44
|
+
export declare function toneMarkup(p: string, o: MaterialOptions, size: number, input?: string): string;
|
|
10
45
|
/** Tint as linear RGB channels, when it is a hex color. */
|
|
11
46
|
export declare function tintChannels(o: MaterialOptions): number[] | undefined;
|
|
12
47
|
/** Colored glass transmits luminance, rather than mixing neutral backdrop RGB
|
|
@@ -16,7 +51,35 @@ export declare function tintMarkup(p: string, o: MaterialOptions, tint: number[]
|
|
|
16
51
|
markup: string;
|
|
17
52
|
color: string;
|
|
18
53
|
};
|
|
19
|
-
/** The
|
|
20
|
-
*
|
|
21
|
-
*
|
|
22
|
-
|
|
54
|
+
/** The outline just outside glass, as macOS draws it: what is behind the
|
|
55
|
+
* glass (`backdrop`) darkens where the rim map (`rim`) has coverage, by black
|
|
56
|
+
* at `rim × (base + slope × x)` for a backdrop of brightness x (see
|
|
57
|
+
* `outlineFor`), returned as `${p}outline`. */
|
|
58
|
+
export declare function outlineMarkup(p: string, backdrop: string, rim: string, opacity?: number, shape?: {
|
|
59
|
+
base: number;
|
|
60
|
+
slope: number;
|
|
61
|
+
}): string;
|
|
62
|
+
/** Add the rim's key and fill light (`light`, white light as coverage) to the
|
|
63
|
+
* glass's color `color`, then keep it to the coverage `mask`, as macOS lights
|
|
64
|
+
* its glass: the light adds to the face rather than covering it. Masking once,
|
|
65
|
+
* after the light, keeps a partly covered edge pixel's coverage exact, so the
|
|
66
|
+
* page behind never shows through the rim. Regular glass adds the same light
|
|
67
|
+
* over any face; Clear adds more over a brighter one, as its light scales what
|
|
68
|
+
* is behind it (measured: its light over mid gray is 1.7 times its light over
|
|
69
|
+
* black). */
|
|
70
|
+
export declare function lightMarkup(p: string, color: string, light: string, mask: string, material?: MaterialOptions["material"]): string;
|
|
71
|
+
/** The rim's key light is white. Scaling its color recolors the light alone
|
|
72
|
+
* and keeps the coverage the WGSL renderer computed. */
|
|
73
|
+
export declare function overlayTintMarkup(input: string, result: string, tint: number[]): string;
|
|
74
|
+
/** Regular glass's shadow, from its coverage `mask` over `box`: the coverage
|
|
75
|
+
* blurred, moved down and kept outside the shape, as black at the shadow's
|
|
76
|
+
* opacity. Every primitive names its own region, which reaches past the glass. */
|
|
77
|
+
export declare function glassShadowMarkup(p: string, mask: string, box: {
|
|
78
|
+
x: number;
|
|
79
|
+
y: number;
|
|
80
|
+
width: number;
|
|
81
|
+
height: number;
|
|
82
|
+
}, opacity: number, shadow: GlassShadow): {
|
|
83
|
+
markup: string;
|
|
84
|
+
result: string;
|
|
85
|
+
};
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import type { LayerBox, MirroredMedia } from "./composited.js";
|
|
2
|
+
/** WebKit hands video and canvas pixels straight to its compositor, above the
|
|
3
|
+
* content's glass filter, and ignores filters on the element itself. While
|
|
4
|
+
* glass is over one, a canvas just beneath it holds the same frame where the
|
|
5
|
+
* glass samples, and a hole in the media's clip shows that canvas. Everywhere
|
|
6
|
+
* else the media stays as it is, controls included.
|
|
7
|
+
*
|
|
8
|
+
* The canvas is a layer of its own that takes the glass on itself, like any
|
|
9
|
+
* other composited layer: a new frame repaints only that layer, never the
|
|
10
|
+
* content's filter, which WebKit would evaluate over the whole repaint and
|
|
11
|
+
* fail for lenses far from it. Drawing a frame onto a visible canvas never
|
|
12
|
+
* reads its pixels back, so cross-origin media mirror too. Encrypted media
|
|
13
|
+
* cannot be drawn at all. */
|
|
14
|
+
export type { MirroredMedia } from "./composited.js";
|
|
15
|
+
/** A lens over the media, in the media's border-box coordinates. */
|
|
16
|
+
export interface MediaHole extends LayerBox {
|
|
17
|
+
radius: number;
|
|
18
|
+
}
|
|
19
|
+
export interface MediaMirrorPlan {
|
|
20
|
+
/** Content to mirror, in the media's border-box coordinates; one canvas each. */
|
|
21
|
+
regions: readonly LayerBox[];
|
|
22
|
+
holes: readonly MediaHole[];
|
|
23
|
+
/** Where each canvas measured relative to the media's border box, to correct
|
|
24
|
+
* its placement inside the containing block it shares with the media. */
|
|
25
|
+
measured?: readonly ({
|
|
26
|
+
x: number;
|
|
27
|
+
y: number;
|
|
28
|
+
} | undefined)[];
|
|
29
|
+
}
|
|
30
|
+
/** Where replaced content lands in its box for `object-fit` and `object-position`. */
|
|
31
|
+
export declare function objectBox(box: LayerBox, intrinsic: {
|
|
32
|
+
width: number;
|
|
33
|
+
height: number;
|
|
34
|
+
}, fit: string, position: string): LayerBox;
|
|
35
|
+
/** An even-odd clip path: the whole box, less a rounded rectangle per hole. */
|
|
36
|
+
export declare function holeClip(width: number, height: number, holes: readonly MediaHole[]): string;
|
|
37
|
+
export interface MediaMirrors {
|
|
38
|
+
/** Mirror exactly the planned media this frame; every other mirror rests. */
|
|
39
|
+
update(plans: ReadonlyMap<MirroredMedia, MediaMirrorPlan>): void;
|
|
40
|
+
/** Whether a mirrored canvas is changing, which follows the page's frames. */
|
|
41
|
+
animating(): boolean;
|
|
42
|
+
ownsCanvas(node: Node): boolean;
|
|
43
|
+
/** The mirror canvases of a media element, in plan order, while shown. */
|
|
44
|
+
canvasesOf(media: MirroredMedia): readonly HTMLCanvasElement[];
|
|
45
|
+
/** Whether the media's own clip keeps it from taking holes; it is then mirrored whole. */
|
|
46
|
+
whole(media: MirroredMedia): boolean;
|
|
47
|
+
dispose(): void;
|
|
48
|
+
}
|
|
49
|
+
export declare function createMediaMirrors(onFrame: () => void): MediaMirrors;
|
|
@@ -17,12 +17,9 @@ export interface ProgressiveRegion extends Box {
|
|
|
17
17
|
blur: number;
|
|
18
18
|
refraction: number;
|
|
19
19
|
}
|
|
20
|
-
/**
|
|
21
|
-
* σ = depth / 6, rises as Φ(6u − 3) across it. These tables map that ramp
|
|
22
|
-
* to each level's weight. Floods, blurs, transfers and composites are the
|
|
23
|
-
* primitives Gecko renders on the GPU; an image anywhere in the graph sends
|
|
24
|
-
* the whole element to its software fallback. */
|
|
20
|
+
/** Gecko filters in floating point, where weights add exactly. */
|
|
25
21
|
export declare const rampTables: string[];
|
|
22
|
+
export declare const coverTables: string[];
|
|
26
23
|
export declare function maskUrl(token: string): string | undefined;
|
|
27
24
|
/** One filter graph that keeps the sharp source and blurs only near edges. */
|
|
28
25
|
export declare function progressiveGraph(id: string, regions: ProgressiveRegion[], width: number, height: number, target?: FilterEngine): string;
|
|
@@ -4,7 +4,5 @@ import type { FilterBounds } from "./filter-bounds.js";
|
|
|
4
4
|
* border. Only a symmetric Lisse field may opt into the inward bound;
|
|
5
5
|
* arbitrary outlines and outward (negative) refraction keep full reach. */
|
|
6
6
|
export declare function refractionSamplingBounds(box: FilterBounds, amount: number, symmetric?: boolean): FilterBounds;
|
|
7
|
-
/** Combine independently proven sampling regions.
|
|
8
|
-
* can quantize premultiplied channels at low alpha; callers must use full
|
|
9
|
-
* reach for such blends unless their opaque coverage is known to coincide. */
|
|
7
|
+
/** Combine independently proven sampling regions. */
|
|
10
8
|
export declare function unionSamplingBounds(boxes: readonly FilterBounds[]): FilterBounds;
|
|
@@ -1,5 +1,30 @@
|
|
|
1
1
|
import type { GlassMotion, SurfaceAnimator } from "./interaction.js";
|
|
2
|
-
/**
|
|
3
|
-
*
|
|
4
|
-
*
|
|
5
|
-
|
|
2
|
+
/**
|
|
3
|
+
* The motion of a tab bar's selection, as macOS 27 draws its tabs (measured on
|
|
4
|
+
* `NSSegmentedControl` with the tabs role):
|
|
5
|
+
*
|
|
6
|
+
* - At rest the chosen tab sits on a small glass plate.
|
|
7
|
+
* - A press lifts a lens out of it: the lens grows by a third of the tab's
|
|
8
|
+
* height at each end and by 0.29 of it above and below, in about 250ms
|
|
9
|
+
* without overshoot, while the plate fades out beneath it. Pressing another
|
|
10
|
+
* tab carries the lens there as it grows.
|
|
11
|
+
* - Dragging moves the lens with the pointer, one to one, at the size it was
|
|
12
|
+
* lifted at. It squashes along its path with speed and wobbles when it
|
|
13
|
+
* stops. Only at either end of the bar does it take on that end tab's size.
|
|
14
|
+
* - Letting go settles the lens onto the tab under its centre, at that tab's
|
|
15
|
+
* size, in about 400ms, while the plate fades back in.
|
|
16
|
+
*
|
|
17
|
+
* The plate is the bar's `[role=tablist]` child `plate`; the lens is a
|
|
18
|
+
* separate element given with `setLens`, drawn above the tab labels so it
|
|
19
|
+
* magnifies them, and kept outside the bar so the bar's clip never cuts it.
|
|
20
|
+
* Selection itself stays with the tabs: the lens only clicks the tab it lands
|
|
21
|
+
* on, so keyboard and state handling are unchanged.
|
|
22
|
+
*/
|
|
23
|
+
export interface SelectionLens extends SurfaceAnimator {
|
|
24
|
+
/** The lens element: absolutely positioned in `container` (the scene root). */
|
|
25
|
+
setLens(lens: HTMLElement | null, container: HTMLElement | null): void;
|
|
26
|
+
}
|
|
27
|
+
export declare function attachSelectionLens(plate: HTMLElement, level: () => GlassMotion,
|
|
28
|
+
/** Called when a press needs the lens, and when it has settled away, so
|
|
29
|
+
* the lens is a glass surface only while it shows. */
|
|
30
|
+
onLifted?: (lifted: boolean) => void): SelectionLens;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { GlassRadius } from "../core/corner-options.js";
|
|
2
|
+
/** The attributes that make an element a shape container other glass follows (concentric). */
|
|
3
|
+
export declare function shapeContainerAttributes(radius: GlassRadius): {
|
|
4
|
+
"data-lg-container": string;
|
|
5
|
+
"data-lg-container-radius": string;
|
|
6
|
+
};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { SmoothCornerOptions } from "@lisse/core";
|
|
2
|
+
/** Redraw an element's border and box shadows along its continuous outline,
|
|
3
|
+
* which its clip would otherwise cut. Loaded only for shapes that have them. */
|
|
4
|
+
export declare function createShapeEffects(element: HTMLElement): {
|
|
5
|
+
update(options: SmoothCornerOptions, width: number, height: number, offset: {
|
|
6
|
+
x: number;
|
|
7
|
+
y: number;
|
|
8
|
+
}): void;
|
|
9
|
+
dispose(): void;
|
|
10
|
+
};
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The geometry of shapes: clip paths for fixed and concentric corners, and corner placement.
|
|
3
|
+
* Loaded when the first shape mounts, not with the components that declare shapes.
|
|
4
|
+
*/
|
|
5
|
+
export { observeFixedShape } from "./fixed-shape.js";
|
|
6
|
+
export { observeConcentricShape, observeCornerPlacement } from "./shape-layout.js";
|
|
@@ -1,11 +1,9 @@
|
|
|
1
|
+
import { shapeContainerAttributes } from "./shape-attributes.js";
|
|
2
|
+
export { shapeContainerAttributes };
|
|
1
3
|
import type { ShapePoint } from "../core/concentric.js";
|
|
2
4
|
import type { GlassRadius } from "../core/shape.js";
|
|
3
5
|
/** Wake the shared loop, for callers that learn of a container change first. */
|
|
4
6
|
export declare function wakeShapeLayout(element?: Element): void;
|
|
5
|
-
export declare function shapeContainerAttributes(radius: GlassRadius): {
|
|
6
|
-
"data-lg-container": string;
|
|
7
|
-
"data-lg-container-radius": string;
|
|
8
|
-
};
|
|
9
7
|
/** Declare geometry for DOM consumers without clipping or changing layout. */
|
|
10
8
|
export declare function registerShapeContainer(element: HTMLElement, radius: GlassRadius): () => void;
|
|
11
9
|
export declare function setResolvedShape(element: HTMLElement, points?: ShapePoint[]): void;
|
|
@@ -5,6 +5,8 @@ interface BackdropConsumer<T> {
|
|
|
5
5
|
/** Stable material-unit identity, independent of the other consumers. */
|
|
6
6
|
id: string;
|
|
7
7
|
options: MaterialOptions;
|
|
8
|
+
/** The shorter side of the glass, which sets its frost. */
|
|
9
|
+
size: number;
|
|
8
10
|
bounds: FilterBounds;
|
|
9
11
|
/** Additional glass layers sampled alongside SourceGraphic. */
|
|
10
12
|
inputs: readonly unknown[];
|
|
@@ -13,7 +15,9 @@ interface BackdropMaterial {
|
|
|
13
15
|
result: string;
|
|
14
16
|
markup: string;
|
|
15
17
|
}
|
|
16
|
-
/**
|
|
17
|
-
*
|
|
18
|
-
|
|
18
|
+
/** Glass reading the same unmodified backdrop, frosted alike, can reuse its
|
|
19
|
+
* blur. Refraction, tone, tint and coverage remain per lens. With `backdrop`,
|
|
20
|
+
* the scene's backdrop color lies beneath the source, across only what the
|
|
21
|
+
* blur reads. */
|
|
22
|
+
export declare function sharedBackdropMaterials<T>(consumers: readonly BackdropConsumer<T>[], soften: number, backdrop?: boolean): Map<T, BackdropMaterial>;
|
|
19
23
|
export {};
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import type { MaterialMaps } from "./maps.js";
|
|
2
|
+
/** Where the light is, shared by every scene of a window: the pointer, or the
|
|
3
|
+
* device's tilt where the browser reports it without asking for permission. */
|
|
4
|
+
interface Light {
|
|
5
|
+
pointer?: {
|
|
6
|
+
x: number;
|
|
7
|
+
y: number;
|
|
8
|
+
};
|
|
9
|
+
/** Tilt away from how the device was being held, in degrees. */
|
|
10
|
+
tilt?: {
|
|
11
|
+
x: number;
|
|
12
|
+
y: number;
|
|
13
|
+
};
|
|
14
|
+
}
|
|
15
|
+
/** Follow the light for as long as `wake` is subscribed. */
|
|
16
|
+
export declare function subscribeLight(view: Window, wake: () => void): {
|
|
17
|
+
light: Light;
|
|
18
|
+
release(): void;
|
|
19
|
+
};
|
|
20
|
+
/** The axis of the two highlights at rest: top left and bottom right, as on iOS. */
|
|
21
|
+
export declare const restingAngle: number;
|
|
22
|
+
/** Axis of the highlights, in radians on screen (y down), for glass centered
|
|
23
|
+
* at `x`, `y`: toward the pointer, else turned by the device's tilt. Both
|
|
24
|
+
* ends of the axis are lit alike, so an angle and its opposite are the same. */
|
|
25
|
+
export declare function lightAngle(light: Light, x: number, y: number): number;
|
|
26
|
+
/** Turn `angle` toward `target` the short way. The axis repeats every half turn. */
|
|
27
|
+
export declare function approachAngle(angle: number, target: number, dt: number, time?: number): number;
|
|
28
|
+
/** Brightness of the rim for v, the rim's facing along the axis scaled by
|
|
29
|
+
* its closeness to the edge. Both ends of the axis are lit the same. */
|
|
30
|
+
export declare function specularResponse(v: number): number;
|
|
31
|
+
/** The field map stores each pixel's outward normal, scaled by how close it
|
|
32
|
+
* is to the rim, as 0.5 − n/2 in red and green. One color matrix takes its
|
|
33
|
+
* dot product with the light; a table shapes the lobes; coverage cuts the
|
|
34
|
+
* result to the glass. Moving the light only rewrites the matrix. */
|
|
35
|
+
export declare function specularMatrix(angle: number): string;
|
|
36
|
+
export declare function specularFilterMarkup(id: string): string;
|
|
37
|
+
/** Whether a node is a specular layer this library wrote. */
|
|
38
|
+
export declare const ownsSpecular: (node: Node) => boolean;
|
|
39
|
+
export interface SpecularLayer {
|
|
40
|
+
/** Draw the rim of these maps over a surface of this layout size. */
|
|
41
|
+
place(maps: MaterialMaps | undefined, width: number, height: number): void;
|
|
42
|
+
/** Point the light at `angle` and set how bright it is. */
|
|
43
|
+
aim(angle: number, strength: number): void;
|
|
44
|
+
dispose(): void;
|
|
45
|
+
}
|
|
46
|
+
/** A thin layer inside the surface, beneath its children, that lights the
|
|
47
|
+
* rim. It filters only itself, so moving the light never redraws the
|
|
48
|
+
* glass's content filter. */
|
|
49
|
+
export declare function createSpecularLayer(element: HTMLElement, defs: SVGDefsElement, id: string): SpecularLayer | undefined;
|
|
50
|
+
export {};
|
|
@@ -12,6 +12,9 @@
|
|
|
12
12
|
export interface Ticker {
|
|
13
13
|
/** Run on the next frame, if not already scheduled. */
|
|
14
14
|
wake(): void;
|
|
15
|
+
/** Run before this frame paints: in a microtask, so a DOM change made by
|
|
16
|
+
* an event handler and the step's writes show in the same frame. */
|
|
17
|
+
flush(): void;
|
|
15
18
|
/** Wake when this element's size changes. */
|
|
16
19
|
observe(element: Element): void;
|
|
17
20
|
unobserve(element: Element): void;
|
|
@@ -21,7 +24,7 @@ export interface TickerOptions {
|
|
|
21
24
|
/** Where mutations, input, and animation events are listened for. */
|
|
22
25
|
root: Node;
|
|
23
26
|
/** Mutations in these nodes are the ticker's own output and never wake it. */
|
|
24
|
-
ignore?: (target: Node) => boolean;
|
|
27
|
+
ignore?: (target: Node, record: MutationRecord) => boolean;
|
|
25
28
|
/** Called for mutations that are not ignored, before the next frame. */
|
|
26
29
|
onMutation?: () => void;
|
|
27
30
|
/** Milliseconds between heartbeats while idle. */
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/** A tint written as a six-digit hex color, which the glass filter reads
|
|
2
|
+
* directly. Any other CSS color, including `var(--accent)` or `oklch(…)`, is
|
|
3
|
+
* resolved on the surface it tints (see `resolveTint`). */
|
|
4
|
+
export declare const hexTint: RegExp;
|
|
5
|
+
/** A computed CSS color as a six-digit hex color, or undefined for none or a
|
|
6
|
+
* fully transparent one. A 1×1 canvas parses every color syntax the browser
|
|
7
|
+
* knows; results are cached, so a theme's few colors are read once. */
|
|
8
|
+
export declare function colorToHex(color: string): string | undefined;
|
|
9
|
+
/** The hex color `tint` is on `element`, which carries it as `--lg-tint`, so
|
|
10
|
+
* custom properties resolve where the glass is and follow theme changes. */
|
|
11
|
+
export declare function resolveTint(element: HTMLElement, tint: string): string | undefined;
|
package/dist/types/dom/warm.d.ts
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import type { MaterialMaps } from "./maps.js";
|
|
2
|
-
/** First-use grace shared by map admission and scene animation readiness.
|
|
3
|
-
|
|
2
|
+
/** First-use grace shared by map admission and scene animation readiness.
|
|
3
|
+
* WebKit loads a `data:` map within a frame and repaints an animating
|
|
4
|
+
* filter every frame; Chromium can paint a fresh image blank for longer. */
|
|
5
|
+
export declare const mapWarmup: number;
|
|
4
6
|
/** Chromium draws a newly referenced filter image blank until it has been
|
|
5
7
|
* loaded and decoded for painting, which reads as the glass blinking when an
|
|
6
8
|
* animation switches maps. A warmer paints every new map once, through its
|
|
@@ -15,3 +17,7 @@ export declare function createMapWarmer(root: HTMLElement): {
|
|
|
15
17
|
owns(node: Node): boolean;
|
|
16
18
|
dispose(): void;
|
|
17
19
|
};
|
|
20
|
+
/** WebKit spends 10–20 ms restyling the page the first time a popup opens,
|
|
21
|
+
* and almost nothing on later openings. One full restyle while the page is
|
|
22
|
+
* quiet takes that cost off the first gesture. */
|
|
23
|
+
export declare function warmDocumentStyle(document: Document): void;
|
|
@@ -8,6 +8,8 @@ export interface MapGeometry {
|
|
|
8
8
|
radius: GlassRadius;
|
|
9
9
|
dpr?: number;
|
|
10
10
|
appearance?: "light" | "dark";
|
|
11
|
+
/** The material, which sets how the rim's outline falls around the shape. */
|
|
12
|
+
material?: "clear" | "regular" | "lens";
|
|
11
13
|
}
|
|
12
14
|
export declare const maxAtlasRows = 8192;
|
|
13
15
|
/** Pixels per CSS pixel a map is rendered at. Maps are stretched to their
|
|
@@ -1,2 +1,3 @@
|
|
|
1
|
-
/** Planes per map: field (displacement and coverage)
|
|
2
|
-
|
|
1
|
+
/** Planes per map: field (displacement and coverage), rim (the outline just
|
|
2
|
+
* outside the shape) and light (the key and fill light on the rim). */
|
|
3
|
+
export declare const mapPlanes = 3;
|
package/dist/types/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
export * from "./react/index.js";
|
|
2
|
-
export type { MaterialOptions, GlassMaterial, GlassAppearance
|
|
2
|
+
export type { MaterialOptions, GlassMaterial, GlassAppearance } from "./core/materials.js";
|
|
3
3
|
export type { GlassDiagnostic, GlassSceneController, SurfaceOptions } from "./dom/index.js";
|
|
4
4
|
export type { GlassRadius } from "./core/shape.js";
|
|
@@ -8,4 +8,4 @@ export interface GlassButtonProps extends Omit<ComponentPropsWithRef<typeof Butt
|
|
|
8
8
|
style?: CSSProperties;
|
|
9
9
|
size?: GlassButtonSize;
|
|
10
10
|
}
|
|
11
|
-
export declare function GlassButton({ material, appearance, radius, refraction, tint, interactive, motion, size, className, style, children, ...props }: GlassButtonProps): import("react").JSX.Element;
|
|
11
|
+
export declare function GlassButton({ material, appearance, radius, refraction, tint, specular, frost, interactive, motion, size, className, style, children, ...props }: GlassButtonProps): import("react").JSX.Element;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import type { CSSProperties } from "react";
|
|
2
|
+
import type { GlassMotion } from "../dom/index.js";
|
|
3
|
+
import type { MaterialOptions } from "../core/materials.js";
|
|
4
|
+
export interface GlassColorPickerProps extends Pick<MaterialOptions, "appearance" | "refraction" | "specular"> {
|
|
5
|
+
/** Six-digit hex color, such as "#34c759". */
|
|
6
|
+
value?: string;
|
|
7
|
+
defaultValue?: string;
|
|
8
|
+
/** Called as the color changes, with a lowercase six-digit hex color. */
|
|
9
|
+
onValueChange?: (value: string) => void;
|
|
10
|
+
/** Called when a drag or key press ends. */
|
|
11
|
+
onValueCommitted?: (value: string) => void;
|
|
12
|
+
/** Wheel diameter in pixels. Default: 240. */
|
|
13
|
+
size?: number;
|
|
14
|
+
/** Name of a hidden input that submits the hex value with a form. */
|
|
15
|
+
name?: string;
|
|
16
|
+
disabled?: boolean;
|
|
17
|
+
motion?: GlassMotion;
|
|
18
|
+
"aria-label"?: string;
|
|
19
|
+
className?: string;
|
|
20
|
+
style?: CSSProperties;
|
|
21
|
+
}
|
|
22
|
+
/** A hue and saturation wheel. A small dot of the chosen color marks it
|
|
23
|
+
* exactly; pressing the wheel grows the dot into a Clear glass bubble that
|
|
24
|
+
* follows the pointer, with a point at its center on the exact color. The
|
|
25
|
+
* glass is always Clear, so the color under it is seen as it is. */
|
|
26
|
+
export declare function GlassColorPicker({ value, defaultValue, onValueChange, onValueCommitted, size, name, disabled, appearance, refraction, specular, motion, "aria-label": label, className, style, }: GlassColorPickerProps): import("react").JSX.Element;
|