vireglass 0.1.0

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 (72) hide show
  1. package/LICENSE +202 -0
  2. package/NOTICE +10 -0
  3. package/README.md +216 -0
  4. package/android/build.gradle +15 -0
  5. package/android/src/main/AndroidManifest.xml +1 -0
  6. package/android/src/main/java/expo/modules/glasslens/GlassBackdropView.kt +335 -0
  7. package/android/src/main/java/expo/modules/glasslens/GlassLensModule.kt +49 -0
  8. package/android/src/main/java/expo/modules/glasslens/GlassLensView.kt +463 -0
  9. package/android/src/main/java/expo/modules/glasslens/GlassProbeView.kt +76 -0
  10. package/dist/adaptation-BSbbdExK.d.cts +78 -0
  11. package/dist/adaptation-BSbbdExK.d.ts +78 -0
  12. package/dist/adapters-BPB0D5nr.d.cts +357 -0
  13. package/dist/adapters-BgSc-smX.d.ts +357 -0
  14. package/dist/chunk-HF2AWZEZ.js +1741 -0
  15. package/dist/chunk-HF2AWZEZ.js.map +1 -0
  16. package/dist/chunk-JNRZNMJJ.js +20 -0
  17. package/dist/chunk-JNRZNMJJ.js.map +1 -0
  18. package/dist/index.cjs +2159 -0
  19. package/dist/index.cjs.map +1 -0
  20. package/dist/index.d.cts +294 -0
  21. package/dist/index.d.ts +294 -0
  22. package/dist/index.js +286 -0
  23. package/dist/index.js.map +1 -0
  24. package/dist/material-CkUHUBoy.d.cts +408 -0
  25. package/dist/material-CkUHUBoy.d.ts +408 -0
  26. package/dist/react.cjs +73 -0
  27. package/dist/react.cjs.map +1 -0
  28. package/dist/react.d.cts +25 -0
  29. package/dist/react.d.ts +25 -0
  30. package/dist/react.js +59 -0
  31. package/dist/react.js.map +1 -0
  32. package/dist/web/index.cjs +1990 -0
  33. package/dist/web/index.cjs.map +1 -0
  34. package/dist/web/index.d.cts +148 -0
  35. package/dist/web/index.d.ts +148 -0
  36. package/dist/web/index.js +657 -0
  37. package/dist/web/index.js.map +1 -0
  38. package/expo-module.config.json +6 -0
  39. package/package.json +127 -0
  40. package/src/accessibility.ts +51 -0
  41. package/src/adaptation.ts +85 -0
  42. package/src/adapters.ts +362 -0
  43. package/src/concentric.ts +25 -0
  44. package/src/geometry.ts +151 -0
  45. package/src/glass-scale.ts +37 -0
  46. package/src/group-model.ts +224 -0
  47. package/src/index.ts +17 -0
  48. package/src/lens-shader.ts +547 -0
  49. package/src/material.ts +553 -0
  50. package/src/native/environment.ts +70 -0
  51. package/src/native/glass-group.tsx +107 -0
  52. package/src/native/glass-ink.tsx +44 -0
  53. package/src/native/glass-surface.tsx +477 -0
  54. package/src/native/index.ts +18 -0
  55. package/src/native/lens.ts +106 -0
  56. package/src/native/provider.tsx +58 -0
  57. package/src/native/surface-registry.ts +51 -0
  58. package/src/native/system-accessibility.ts +90 -0
  59. package/src/optics.ts +177 -0
  60. package/src/react.ts +102 -0
  61. package/src/reference-scene.ts +222 -0
  62. package/src/scroll-edge.ts +30 -0
  63. package/src/sdf.ts +149 -0
  64. package/src/surface-shader.ts +287 -0
  65. package/src/targets/agsl.ts +8 -0
  66. package/src/targets/glsl.ts +140 -0
  67. package/src/touch-response.ts +195 -0
  68. package/src/web/gl.ts +119 -0
  69. package/src/web/index.ts +3 -0
  70. package/src/web/probe.ts +312 -0
  71. package/src/web/reference-draw.ts +142 -0
  72. package/src/web/renderer.ts +524 -0
@@ -0,0 +1,148 @@
1
+ import { j as VireGlassGeometry, k as VireGlassMorph, q as VireGlassTouch, V as VireGlassAccent, n as VireGlassRefScene } from '../adapters-BPB0D5nr.cjs';
2
+ import { V as VireGlassOptics, n as VireGlassDebugMode } from '../material-CkUHUBoy.cjs';
3
+
4
+ declare const PROBE_GRID_WIDTH = 48;
5
+ declare const PROBE_GRID_HEIGHT = 96;
6
+ /** Stats for the lens rectangle from a single probe sample. `null` until the first ready frame
7
+ * has come in — the shader falls back to `u_probeLuma = -1` in that case (see `lens-shader.ts`). */
8
+ type ProbeStats = {
9
+ luma: number;
10
+ busy: number;
11
+ lo: number;
12
+ hi: number;
13
+ slopeX: number;
14
+ slopeY: number;
15
+ r: number;
16
+ g: number;
17
+ b: number;
18
+ };
19
+ type ProbeRect = {
20
+ centerX: number;
21
+ centerY: number;
22
+ halfWidth: number;
23
+ halfHeight: number;
24
+ };
25
+ type Probe = {
26
+ /** Renders a downsample of the current `contentTexture` into its own FBO and advances the PBO
27
+ * read pipeline. Returns stats for the lens rectangle — lagging by a frame or two, or `null`
28
+ * until a reader is ready. */
29
+ sample(contentTexture: WebGLTexture, contentWidth: number, contentHeight: number, rect: ProbeRect): ProbeStats | null;
30
+ /** Stats for another rectangle from the ALREADY-captured grid — no new pass, no new read. */
31
+ statsFor(contentWidth: number, contentHeight: number, rect: ProbeRect): ProbeStats | null;
32
+ destroy(): void;
33
+ };
34
+ declare function createProbe(gl: WebGL2RenderingContext, vertexSource: string): Probe;
35
+
36
+ /** The scene draws itself with an offset: the lenses in the frame stay put while the canvas
37
+ * underneath them slides — only this way can you actually see what refraction does to whatever
38
+ * passes under the element. Offset in device-px. */
39
+ type VireGlassSceneDrawer = (ctx: CanvasRenderingContext2D, width: number, height: number, offsetX: number, offsetY: number,
40
+ /** Pixels per dp — the same value used for elements. The canvas and the glass must live at the
41
+ * same scale: as a fraction of canvas width, a cell on desktop came out five times larger than
42
+ * on a phone, and an element of the same size looked completely different on the lab bench
43
+ * than on a device. */
44
+ density: number) => void;
45
+ /** One glass element in the frame. Each has its own material — that's how they're compared side by side. */
46
+ type VireGlassPiece = {
47
+ optics: VireGlassOptics;
48
+ geometry: VireGlassGeometry;
49
+ /** Element center in CANVAS PIXELS (device-px). Shared between the lens and the surface. */
50
+ centerX: number;
51
+ centerY: number;
52
+ morph?: VireGlassMorph;
53
+ /** Third shape of the same body: breaking the element into pieces uses two bridges. */
54
+ morph2?: VireGlassMorph;
55
+ /** Local finger response: touch point, drag, press, wave. */
56
+ touch?: VireGlassTouch;
57
+ /** Press response, 0…1 — the highlight blooms, the body thickens slightly. */
58
+ press?: number;
59
+ /** Element under the finger, 0…1 — a stronger highlight and rim light. */
60
+ active?: number;
61
+ /** Played fraction, 0…1: an active state expressed as a field. Omitted means no progress. */
62
+ progress?: number;
63
+ /** Whether to draw the icon from the frame's shared mask on this element (see `iconMask` in the frame options). */
64
+ icon?: boolean;
65
+ /** Whether to draw the frame's colored layer on this element (see `colorLayer`). */
66
+ overlay?: boolean;
67
+ /** Icon color at rest and in the active state, RGBA 0…1. */
68
+ inkIdle?: readonly number[];
69
+ inkActive?: readonly number[];
70
+ /** Key light direction in screen space; defaults to the light at rest. */
71
+ light?: readonly [number, number];
72
+ /** 0…1: the element appearing as the lens builds up (M 2:55). */
73
+ appear?: number;
74
+ /** 0 — the element sinks in under the finger, 1 — it rises into glass (reference §5). */
75
+ lift?: number;
76
+ /** Tint for the primary action — colored glass, not a fill. */
77
+ accent?: VireGlassAccent;
78
+ };
79
+ type VireGlassRenderOptions = {
80
+ /** `devicePixelRatio` — passed as an argument rather than read globally, so the renderer stays
81
+ * testable and isn't tied to a specific window. */
82
+ density: number;
83
+ debug: VireGlassDebugMode;
84
+ pieces: readonly VireGlassPiece[];
85
+ scene: VireGlassSceneDrawer;
86
+ /** Canvas offset under stationary elements, device-px. */
87
+ offsetX?: number;
88
+ offsetY?: number;
89
+ /**
90
+ * Ink mask the size of the canvas, screen coordinates, read from the GREEN channel. White on
91
+ * BLACK: antialiasing has to live in color, not alpha, otherwise green holds at one all the way
92
+ * to the edge inside a stroke and the icon's edges tear.
93
+ *
94
+ * The mask does NOT carry and must not carry a calm backing under the ink: that's a property of
95
+ * the material itself (`legibility`), the same across the whole element. While the app used to
96
+ * supply that backing, one element had it and another didn't, with nothing to explain the
97
+ * difference.
98
+ */
99
+ iconMask?: TexImageSource | null;
100
+ /**
101
+ * App-colored layer the size of the canvas, screen coordinates: cover art, a thumbnail —
102
+ * anything the app puts ON the glass in color. Separate from the ink mask, because that one
103
+ * carries a single channel colored by polarity, while this one has its own color.
104
+ *
105
+ * Drawn INSIDE the material, at the same coordinate as the ink: only this way does the
106
+ * surface's deformation carry them together. As a separate layer on top of the glass, text used
107
+ * to shake on press while the cover art stayed put.
108
+ */
109
+ colorLayer?: TexImageSource | null;
110
+ };
111
+ type VireGlassRenderResult = {
112
+ /** One backdrop sample per element, in the same order as `pieces`. */
113
+ probes: readonly (ProbeStats | null)[];
114
+ };
115
+ type VireGlassRenderer = {
116
+ resize(widthPx: number, heightPx: number): void;
117
+ render(options: VireGlassRenderOptions): VireGlassRenderResult;
118
+ destroy(): void;
119
+ };
120
+ declare function createVireGlassRenderer(canvas: HTMLCanvasElement): VireGlassRenderer;
121
+
122
+ /**
123
+ * Drawing the reference canvas onto a canvas element. Lives in `web/` because it knows about the
124
+ * 2D context; the canvases themselves are data in `reference-scene.ts`, and the mobile lab lays
125
+ * out the same data as native views.
126
+ *
127
+ * The same drawer is used by the `check:optics` gate: only this way do the eye at the bench and
128
+ * the number in the gate look at the same canvas. The one difference between them is the fit mode.
129
+ */
130
+
131
+ type VireGlassRefDrawOptions = {
132
+ /** Pixels per dp. The same value used for elements: the canvas and the glass must live at the
133
+ * same scale. */
134
+ readonly density: number;
135
+ /** Canvas lightness; canvases that don't need it ignore it. Defaults to the canvas's own. */
136
+ readonly level?: number;
137
+ /**
138
+ * `band` — a `REFERENCE_SCENE_WIDTH`×`REFERENCE_SCENE_HEIGHT` dp panel centered on the stage,
139
+ * with a surrounding field: only this way do two benches show the SAME canvas, including the
140
+ * pattern's phase under the element. `frame` — stripes stretched across the whole frame: the
141
+ * gate has its own fixed stage, and the surrounding field would get in the way of sampling
142
+ * pixels.
143
+ */
144
+ readonly fit?: 'band' | 'frame';
145
+ };
146
+ declare function drawReferenceScene(ctx: CanvasRenderingContext2D, scene: VireGlassRefScene, width: number, height: number, options: VireGlassRefDrawOptions): void;
147
+
148
+ export { PROBE_GRID_HEIGHT, PROBE_GRID_WIDTH, type Probe, type ProbeRect, type ProbeStats, type VireGlassPiece, type VireGlassRefDrawOptions, type VireGlassRenderOptions, type VireGlassRenderResult, type VireGlassRenderer, type VireGlassSceneDrawer, createProbe, createVireGlassRenderer, drawReferenceScene };
@@ -0,0 +1,148 @@
1
+ import { j as VireGlassGeometry, k as VireGlassMorph, q as VireGlassTouch, V as VireGlassAccent, n as VireGlassRefScene } from '../adapters-BgSc-smX.js';
2
+ import { V as VireGlassOptics, n as VireGlassDebugMode } from '../material-CkUHUBoy.js';
3
+
4
+ declare const PROBE_GRID_WIDTH = 48;
5
+ declare const PROBE_GRID_HEIGHT = 96;
6
+ /** Stats for the lens rectangle from a single probe sample. `null` until the first ready frame
7
+ * has come in — the shader falls back to `u_probeLuma = -1` in that case (see `lens-shader.ts`). */
8
+ type ProbeStats = {
9
+ luma: number;
10
+ busy: number;
11
+ lo: number;
12
+ hi: number;
13
+ slopeX: number;
14
+ slopeY: number;
15
+ r: number;
16
+ g: number;
17
+ b: number;
18
+ };
19
+ type ProbeRect = {
20
+ centerX: number;
21
+ centerY: number;
22
+ halfWidth: number;
23
+ halfHeight: number;
24
+ };
25
+ type Probe = {
26
+ /** Renders a downsample of the current `contentTexture` into its own FBO and advances the PBO
27
+ * read pipeline. Returns stats for the lens rectangle — lagging by a frame or two, or `null`
28
+ * until a reader is ready. */
29
+ sample(contentTexture: WebGLTexture, contentWidth: number, contentHeight: number, rect: ProbeRect): ProbeStats | null;
30
+ /** Stats for another rectangle from the ALREADY-captured grid — no new pass, no new read. */
31
+ statsFor(contentWidth: number, contentHeight: number, rect: ProbeRect): ProbeStats | null;
32
+ destroy(): void;
33
+ };
34
+ declare function createProbe(gl: WebGL2RenderingContext, vertexSource: string): Probe;
35
+
36
+ /** The scene draws itself with an offset: the lenses in the frame stay put while the canvas
37
+ * underneath them slides — only this way can you actually see what refraction does to whatever
38
+ * passes under the element. Offset in device-px. */
39
+ type VireGlassSceneDrawer = (ctx: CanvasRenderingContext2D, width: number, height: number, offsetX: number, offsetY: number,
40
+ /** Pixels per dp — the same value used for elements. The canvas and the glass must live at the
41
+ * same scale: as a fraction of canvas width, a cell on desktop came out five times larger than
42
+ * on a phone, and an element of the same size looked completely different on the lab bench
43
+ * than on a device. */
44
+ density: number) => void;
45
+ /** One glass element in the frame. Each has its own material — that's how they're compared side by side. */
46
+ type VireGlassPiece = {
47
+ optics: VireGlassOptics;
48
+ geometry: VireGlassGeometry;
49
+ /** Element center in CANVAS PIXELS (device-px). Shared between the lens and the surface. */
50
+ centerX: number;
51
+ centerY: number;
52
+ morph?: VireGlassMorph;
53
+ /** Third shape of the same body: breaking the element into pieces uses two bridges. */
54
+ morph2?: VireGlassMorph;
55
+ /** Local finger response: touch point, drag, press, wave. */
56
+ touch?: VireGlassTouch;
57
+ /** Press response, 0…1 — the highlight blooms, the body thickens slightly. */
58
+ press?: number;
59
+ /** Element under the finger, 0…1 — a stronger highlight and rim light. */
60
+ active?: number;
61
+ /** Played fraction, 0…1: an active state expressed as a field. Omitted means no progress. */
62
+ progress?: number;
63
+ /** Whether to draw the icon from the frame's shared mask on this element (see `iconMask` in the frame options). */
64
+ icon?: boolean;
65
+ /** Whether to draw the frame's colored layer on this element (see `colorLayer`). */
66
+ overlay?: boolean;
67
+ /** Icon color at rest and in the active state, RGBA 0…1. */
68
+ inkIdle?: readonly number[];
69
+ inkActive?: readonly number[];
70
+ /** Key light direction in screen space; defaults to the light at rest. */
71
+ light?: readonly [number, number];
72
+ /** 0…1: the element appearing as the lens builds up (M 2:55). */
73
+ appear?: number;
74
+ /** 0 — the element sinks in under the finger, 1 — it rises into glass (reference §5). */
75
+ lift?: number;
76
+ /** Tint for the primary action — colored glass, not a fill. */
77
+ accent?: VireGlassAccent;
78
+ };
79
+ type VireGlassRenderOptions = {
80
+ /** `devicePixelRatio` — passed as an argument rather than read globally, so the renderer stays
81
+ * testable and isn't tied to a specific window. */
82
+ density: number;
83
+ debug: VireGlassDebugMode;
84
+ pieces: readonly VireGlassPiece[];
85
+ scene: VireGlassSceneDrawer;
86
+ /** Canvas offset under stationary elements, device-px. */
87
+ offsetX?: number;
88
+ offsetY?: number;
89
+ /**
90
+ * Ink mask the size of the canvas, screen coordinates, read from the GREEN channel. White on
91
+ * BLACK: antialiasing has to live in color, not alpha, otherwise green holds at one all the way
92
+ * to the edge inside a stroke and the icon's edges tear.
93
+ *
94
+ * The mask does NOT carry and must not carry a calm backing under the ink: that's a property of
95
+ * the material itself (`legibility`), the same across the whole element. While the app used to
96
+ * supply that backing, one element had it and another didn't, with nothing to explain the
97
+ * difference.
98
+ */
99
+ iconMask?: TexImageSource | null;
100
+ /**
101
+ * App-colored layer the size of the canvas, screen coordinates: cover art, a thumbnail —
102
+ * anything the app puts ON the glass in color. Separate from the ink mask, because that one
103
+ * carries a single channel colored by polarity, while this one has its own color.
104
+ *
105
+ * Drawn INSIDE the material, at the same coordinate as the ink: only this way does the
106
+ * surface's deformation carry them together. As a separate layer on top of the glass, text used
107
+ * to shake on press while the cover art stayed put.
108
+ */
109
+ colorLayer?: TexImageSource | null;
110
+ };
111
+ type VireGlassRenderResult = {
112
+ /** One backdrop sample per element, in the same order as `pieces`. */
113
+ probes: readonly (ProbeStats | null)[];
114
+ };
115
+ type VireGlassRenderer = {
116
+ resize(widthPx: number, heightPx: number): void;
117
+ render(options: VireGlassRenderOptions): VireGlassRenderResult;
118
+ destroy(): void;
119
+ };
120
+ declare function createVireGlassRenderer(canvas: HTMLCanvasElement): VireGlassRenderer;
121
+
122
+ /**
123
+ * Drawing the reference canvas onto a canvas element. Lives in `web/` because it knows about the
124
+ * 2D context; the canvases themselves are data in `reference-scene.ts`, and the mobile lab lays
125
+ * out the same data as native views.
126
+ *
127
+ * The same drawer is used by the `check:optics` gate: only this way do the eye at the bench and
128
+ * the number in the gate look at the same canvas. The one difference between them is the fit mode.
129
+ */
130
+
131
+ type VireGlassRefDrawOptions = {
132
+ /** Pixels per dp. The same value used for elements: the canvas and the glass must live at the
133
+ * same scale. */
134
+ readonly density: number;
135
+ /** Canvas lightness; canvases that don't need it ignore it. Defaults to the canvas's own. */
136
+ readonly level?: number;
137
+ /**
138
+ * `band` — a `REFERENCE_SCENE_WIDTH`×`REFERENCE_SCENE_HEIGHT` dp panel centered on the stage,
139
+ * with a surrounding field: only this way do two benches show the SAME canvas, including the
140
+ * pattern's phase under the element. `frame` — stripes stretched across the whole frame: the
141
+ * gate has its own fixed stage, and the surrounding field would get in the way of sampling
142
+ * pixels.
143
+ */
144
+ readonly fit?: 'band' | 'frame';
145
+ };
146
+ declare function drawReferenceScene(ctx: CanvasRenderingContext2D, scene: VireGlassRefScene, width: number, height: number, options: VireGlassRefDrawOptions): void;
147
+
148
+ export { PROBE_GRID_HEIGHT, PROBE_GRID_WIDTH, type Probe, type ProbeRect, type ProbeStats, type VireGlassPiece, type VireGlassRefDrawOptions, type VireGlassRenderOptions, type VireGlassRenderResult, type VireGlassRenderer, type VireGlassSceneDrawer, createProbe, createVireGlassRenderer, drawReferenceScene };