@clipkit/runtime 1.0.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 (219) hide show
  1. package/LICENSE +54 -0
  2. package/README.md +98 -0
  3. package/dist/animation/easings.d.ts +9 -0
  4. package/dist/animation/easings.d.ts.map +1 -0
  5. package/dist/animation/easings.js +230 -0
  6. package/dist/animation/easings.js.map +1 -0
  7. package/dist/animation/expr.d.ts +44 -0
  8. package/dist/animation/expr.d.ts.map +1 -0
  9. package/dist/animation/expr.js +236 -0
  10. package/dist/animation/expr.js.map +1 -0
  11. package/dist/animation/keyframes.d.ts +23 -0
  12. package/dist/animation/keyframes.d.ts.map +1 -0
  13. package/dist/animation/keyframes.js +117 -0
  14. package/dist/animation/keyframes.js.map +1 -0
  15. package/dist/animation/motion-path.d.ts +18 -0
  16. package/dist/animation/motion-path.d.ts.map +1 -0
  17. package/dist/animation/motion-path.js +269 -0
  18. package/dist/animation/motion-path.js.map +1 -0
  19. package/dist/animation/noise1d.d.ts +5 -0
  20. package/dist/animation/noise1d.d.ts.map +1 -0
  21. package/dist/animation/noise1d.js +27 -0
  22. package/dist/animation/noise1d.js.map +1 -0
  23. package/dist/animation/presets.d.ts +60 -0
  24. package/dist/animation/presets.d.ts.map +1 -0
  25. package/dist/animation/presets.js +221 -0
  26. package/dist/animation/presets.js.map +1 -0
  27. package/dist/assets/cache.d.ts +18 -0
  28. package/dist/assets/cache.d.ts.map +1 -0
  29. package/dist/assets/cache.js +56 -0
  30. package/dist/assets/cache.js.map +1 -0
  31. package/dist/assets/fonts.d.ts +20 -0
  32. package/dist/assets/fonts.d.ts.map +1 -0
  33. package/dist/assets/fonts.js +127 -0
  34. package/dist/assets/fonts.js.map +1 -0
  35. package/dist/assets/loader.d.ts +18 -0
  36. package/dist/assets/loader.d.ts.map +1 -0
  37. package/dist/assets/loader.js +87 -0
  38. package/dist/assets/loader.js.map +1 -0
  39. package/dist/assets/lut.d.ts +5 -0
  40. package/dist/assets/lut.d.ts.map +1 -0
  41. package/dist/assets/lut.js +77 -0
  42. package/dist/assets/lut.js.map +1 -0
  43. package/dist/assets/media-time.d.ts +31 -0
  44. package/dist/assets/media-time.d.ts.map +1 -0
  45. package/dist/assets/media-time.js +65 -0
  46. package/dist/assets/media-time.js.map +1 -0
  47. package/dist/assets/mp4-frame-source.d.ts +44 -0
  48. package/dist/assets/mp4-frame-source.d.ts.map +1 -0
  49. package/dist/assets/mp4-frame-source.js +387 -0
  50. package/dist/assets/mp4-frame-source.js.map +1 -0
  51. package/dist/audio/encoder.d.ts +31 -0
  52. package/dist/audio/encoder.d.ts.map +1 -0
  53. package/dist/audio/encoder.js +96 -0
  54. package/dist/audio/encoder.js.map +1 -0
  55. package/dist/audio/fades.d.ts +16 -0
  56. package/dist/audio/fades.d.ts.map +1 -0
  57. package/dist/audio/fades.js +43 -0
  58. package/dist/audio/fades.js.map +1 -0
  59. package/dist/audio/limiter.d.ts +8 -0
  60. package/dist/audio/limiter.d.ts.map +1 -0
  61. package/dist/audio/limiter.js +39 -0
  62. package/dist/audio/limiter.js.map +1 -0
  63. package/dist/audio/loader.d.ts +6 -0
  64. package/dist/audio/loader.d.ts.map +1 -0
  65. package/dist/audio/loader.js +42 -0
  66. package/dist/audio/loader.js.map +1 -0
  67. package/dist/audio/mixer.d.ts +17 -0
  68. package/dist/audio/mixer.d.ts.map +1 -0
  69. package/dist/audio/mixer.js +204 -0
  70. package/dist/audio/mixer.js.map +1 -0
  71. package/dist/audio/varispeed.d.ts +24 -0
  72. package/dist/audio/varispeed.d.ts.map +1 -0
  73. package/dist/audio/varispeed.js +114 -0
  74. package/dist/audio/varispeed.js.map +1 -0
  75. package/dist/audio/wav.d.ts +6 -0
  76. package/dist/audio/wav.d.ts.map +1 -0
  77. package/dist/audio/wav.js +62 -0
  78. package/dist/audio/wav.js.map +1 -0
  79. package/dist/backend/backend.d.ts +579 -0
  80. package/dist/backend/backend.d.ts.map +1 -0
  81. package/dist/backend/backend.js +17 -0
  82. package/dist/backend/backend.js.map +1 -0
  83. package/dist/backend/webgl-backend.d.ts +97 -0
  84. package/dist/backend/webgl-backend.d.ts.map +1 -0
  85. package/dist/backend/webgl-backend.js +2142 -0
  86. package/dist/backend/webgl-backend.js.map +1 -0
  87. package/dist/backend/webgpu-backend.d.ts +121 -0
  88. package/dist/backend/webgpu-backend.d.ts.map +1 -0
  89. package/dist/backend/webgpu-backend.js +2481 -0
  90. package/dist/backend/webgpu-backend.js.map +1 -0
  91. package/dist/compositor/bitfont.d.ts +8 -0
  92. package/dist/compositor/bitfont.d.ts.map +1 -0
  93. package/dist/compositor/bitfont.js +52 -0
  94. package/dist/compositor/bitfont.js.map +1 -0
  95. package/dist/compositor/camera.d.ts +5 -0
  96. package/dist/compositor/camera.d.ts.map +1 -0
  97. package/dist/compositor/camera.js +114 -0
  98. package/dist/compositor/camera.js.map +1 -0
  99. package/dist/compositor/color.d.ts +26 -0
  100. package/dist/compositor/color.d.ts.map +1 -0
  101. package/dist/compositor/color.js +189 -0
  102. package/dist/compositor/color.js.map +1 -0
  103. package/dist/compositor/element-renderers/caption.d.ts +4 -0
  104. package/dist/compositor/element-renderers/caption.d.ts.map +1 -0
  105. package/dist/compositor/element-renderers/caption.js +376 -0
  106. package/dist/compositor/element-renderers/caption.js.map +1 -0
  107. package/dist/compositor/element-renderers/group.d.ts +12 -0
  108. package/dist/compositor/element-renderers/group.d.ts.map +1 -0
  109. package/dist/compositor/element-renderers/group.js +259 -0
  110. package/dist/compositor/element-renderers/group.js.map +1 -0
  111. package/dist/compositor/element-renderers/image.d.ts +4 -0
  112. package/dist/compositor/element-renderers/image.d.ts.map +1 -0
  113. package/dist/compositor/element-renderers/image.js +97 -0
  114. package/dist/compositor/element-renderers/image.js.map +1 -0
  115. package/dist/compositor/element-renderers/lit.d.ts +6 -0
  116. package/dist/compositor/element-renderers/lit.d.ts.map +1 -0
  117. package/dist/compositor/element-renderers/lit.js +82 -0
  118. package/dist/compositor/element-renderers/lit.js.map +1 -0
  119. package/dist/compositor/element-renderers/particles.d.ts +4 -0
  120. package/dist/compositor/element-renderers/particles.d.ts.map +1 -0
  121. package/dist/compositor/element-renderers/particles.js +212 -0
  122. package/dist/compositor/element-renderers/particles.js.map +1 -0
  123. package/dist/compositor/element-renderers/shape.d.ts +4 -0
  124. package/dist/compositor/element-renderers/shape.d.ts.map +1 -0
  125. package/dist/compositor/element-renderers/shape.js +171 -0
  126. package/dist/compositor/element-renderers/shape.js.map +1 -0
  127. package/dist/compositor/element-renderers/svg.d.ts +4 -0
  128. package/dist/compositor/element-renderers/svg.d.ts.map +1 -0
  129. package/dist/compositor/element-renderers/svg.js +210 -0
  130. package/dist/compositor/element-renderers/svg.js.map +1 -0
  131. package/dist/compositor/element-renderers/text.d.ts +25 -0
  132. package/dist/compositor/element-renderers/text.d.ts.map +1 -0
  133. package/dist/compositor/element-renderers/text.js +1358 -0
  134. package/dist/compositor/element-renderers/text.js.map +1 -0
  135. package/dist/compositor/element-renderers/video.d.ts +12 -0
  136. package/dist/compositor/element-renderers/video.d.ts.map +1 -0
  137. package/dist/compositor/element-renderers/video.js +109 -0
  138. package/dist/compositor/element-renderers/video.js.map +1 -0
  139. package/dist/compositor/fit.d.ts +18 -0
  140. package/dist/compositor/fit.d.ts.map +1 -0
  141. package/dist/compositor/fit.js +106 -0
  142. package/dist/compositor/fit.js.map +1 -0
  143. package/dist/compositor/lighting.d.ts +63 -0
  144. package/dist/compositor/lighting.d.ts.map +1 -0
  145. package/dist/compositor/lighting.js +141 -0
  146. package/dist/compositor/lighting.js.map +1 -0
  147. package/dist/compositor/mat4.d.ts +88 -0
  148. package/dist/compositor/mat4.d.ts.map +1 -0
  149. package/dist/compositor/mat4.js +245 -0
  150. package/dist/compositor/mat4.js.map +1 -0
  151. package/dist/compositor/project.d.ts +24 -0
  152. package/dist/compositor/project.d.ts.map +1 -0
  153. package/dist/compositor/project.js +105 -0
  154. package/dist/compositor/project.js.map +1 -0
  155. package/dist/compositor/render-context.d.ts +194 -0
  156. package/dist/compositor/render-context.d.ts.map +1 -0
  157. package/dist/compositor/render-context.js +10 -0
  158. package/dist/compositor/render-context.js.map +1 -0
  159. package/dist/compositor/resolve.d.ts +80 -0
  160. package/dist/compositor/resolve.d.ts.map +1 -0
  161. package/dist/compositor/resolve.js +276 -0
  162. package/dist/compositor/resolve.js.map +1 -0
  163. package/dist/compositor/scene.d.ts +10 -0
  164. package/dist/compositor/scene.d.ts.map +1 -0
  165. package/dist/compositor/scene.js +658 -0
  166. package/dist/compositor/scene.js.map +1 -0
  167. package/dist/compositor/transform.d.ts +73 -0
  168. package/dist/compositor/transform.d.ts.map +1 -0
  169. package/dist/compositor/transform.js +229 -0
  170. package/dist/compositor/transform.js.map +1 -0
  171. package/dist/compositor/unit.d.ts +27 -0
  172. package/dist/compositor/unit.d.ts.map +1 -0
  173. package/dist/compositor/unit.js +74 -0
  174. package/dist/compositor/unit.js.map +1 -0
  175. package/dist/encoder/exporter.d.ts +95 -0
  176. package/dist/encoder/exporter.d.ts.map +1 -0
  177. package/dist/encoder/exporter.js +341 -0
  178. package/dist/encoder/exporter.js.map +1 -0
  179. package/dist/encoder/index.d.ts +3 -0
  180. package/dist/encoder/index.d.ts.map +1 -0
  181. package/dist/encoder/index.js +2 -0
  182. package/dist/encoder/index.js.map +1 -0
  183. package/dist/index.d.ts +12 -0
  184. package/dist/index.d.ts.map +1 -0
  185. package/dist/index.js +27 -0
  186. package/dist/index.js.map +1 -0
  187. package/dist/logger.d.ts +13 -0
  188. package/dist/logger.d.ts.map +1 -0
  189. package/dist/logger.js +32 -0
  190. package/dist/logger.js.map +1 -0
  191. package/dist/runtime.d.ts +216 -0
  192. package/dist/runtime.d.ts.map +1 -0
  193. package/dist/runtime.js +1012 -0
  194. package/dist/runtime.js.map +1 -0
  195. package/dist/svg/morph.d.ts +6 -0
  196. package/dist/svg/morph.d.ts.map +1 -0
  197. package/dist/svg/morph.js +62 -0
  198. package/dist/svg/morph.js.map +1 -0
  199. package/dist/svg/svg-renderer.d.ts +18 -0
  200. package/dist/svg/svg-renderer.d.ts.map +1 -0
  201. package/dist/svg/svg-renderer.js +142 -0
  202. package/dist/svg/svg-renderer.js.map +1 -0
  203. package/dist/text/caption-chunk.d.ts +17 -0
  204. package/dist/text/caption-chunk.d.ts.map +1 -0
  205. package/dist/text/caption-chunk.js +76 -0
  206. package/dist/text/caption-chunk.js.map +1 -0
  207. package/dist/text/font-atlas.d.ts +63 -0
  208. package/dist/text/font-atlas.d.ts.map +1 -0
  209. package/dist/text/font-atlas.js +225 -0
  210. package/dist/text/font-atlas.js.map +1 -0
  211. package/dist/text/measure.d.ts +38 -0
  212. package/dist/text/measure.d.ts.map +1 -0
  213. package/dist/text/measure.js +164 -0
  214. package/dist/text/measure.js.map +1 -0
  215. package/dist/text/text-animation.d.ts +52 -0
  216. package/dist/text/text-animation.d.ts.map +1 -0
  217. package/dist/text/text-animation.js +133 -0
  218. package/dist/text/text-animation.js.map +1 -0
  219. package/package.json +47 -0
@@ -0,0 +1,579 @@
1
+ import type { RGBA } from '../compositor/color.js';
2
+ /** Acceptable sources for createTexture / updateTexture. */
3
+ export type TextureSource = ImageBitmap | HTMLCanvasElement | OffscreenCanvas | HTMLVideoElement | VideoFrame | HTMLImageElement;
4
+ /** Opaque texture handle. Backends define their own concrete type. */
5
+ export interface Texture {
6
+ readonly width: number;
7
+ readonly height: number;
8
+ readonly id: number;
9
+ }
10
+ export interface BackendGradientStop {
11
+ /** Position 0..1 along the gradient. */
12
+ offset: number;
13
+ /** Premultiplied RGBA. */
14
+ color: RGBA;
15
+ }
16
+ export type BackendGradient = {
17
+ type: 'linear';
18
+ /** Angle in radians. Caller converts from schema degrees. */
19
+ angle: number;
20
+ stops: BackendGradientStop[];
21
+ } | {
22
+ type: 'radial';
23
+ /** Center as fraction of shape's box, 0..1. */
24
+ cx: number;
25
+ cy: number;
26
+ /** Outer radius as fraction of shape's box. */
27
+ radius: number;
28
+ stops: BackendGradientStop[];
29
+ };
30
+ /**
31
+ * PBR lighting payload for a quad draw (CKP/1.0 §4.8). Present only when
32
+ * the element carries a `material` AND the scene has lights — the backend
33
+ * then takes the "lit" shader path; absent ⇒ the unlit fast path.
34
+ * Everything is in world (canvas-pixel, pre-camera) space.
35
+ */
36
+ export interface LitParams {
37
+ /** Straight (non-premultiplied) base color / albedo for shapes. */
38
+ albedo: RGBA;
39
+ /** Straight stroke albedo (when the shape has a stroke). */
40
+ strokeAlbedo?: RGBA;
41
+ roughness: number;
42
+ metalness: number;
43
+ reflectivity: number;
44
+ emissive: number;
45
+ /** Column-major mat4 mapping the unit quad to WORLD (pre-camera) pixels. */
46
+ worldMatrix: ArrayLike<number>;
47
+ /** World-space face normal (unit). */
48
+ normal: readonly [number, number, number];
49
+ /**
50
+ * Tangent-space normal map (§4.8 Phase 2). When present the backend
51
+ * perturbs the face normal by the sampled map using the (tangent,
52
+ * bitangent, normal) basis. Absent ⇒ flat face normal.
53
+ */
54
+ normalMap?: {
55
+ texture: Texture;
56
+ /** Perturbation strength (0 flat .. 1 as-authored .. >1 exaggerated). */
57
+ scale: number;
58
+ /** World-space tangent (unit) — the quad's +U direction. */
59
+ tangent: readonly [number, number, number];
60
+ /** World-space bitangent (unit) — the quad's +V direction. */
61
+ bitangent: readonly [number, number, number];
62
+ };
63
+ /** Camera eye in world space (view-vector origin). */
64
+ eye: readonly [number, number, number];
65
+ /** Summed ambient light color. */
66
+ ambient: readonly [number, number, number];
67
+ /** Directional lights (≤4): unit directions toward the light. */
68
+ lightDirs: ReadonlyArray<readonly [number, number, number]>;
69
+ /** Directional light colors (×intensity), parallel to lightDirs. */
70
+ lightColors: ReadonlyArray<readonly [number, number, number]>;
71
+ /**
72
+ * Scene environment (§4.8) reflective materials sample along the
73
+ * reflection vector. Absent ⇒ no environment reflection. Gradient
74
+ * stops are straight RGB, sorted by offset (≤4); `envAvg` is the mean
75
+ * color (irradiance / fully-rough fallback).
76
+ */
77
+ env?: {
78
+ stopColors: ReadonlyArray<readonly [number, number, number]>;
79
+ stopOffsets: ReadonlyArray<number>;
80
+ avg: readonly [number, number, number];
81
+ /**
82
+ * Equirectangular environment texture (§4.8 Phase 3). When present the
83
+ * shader samples it along the reflection vector instead of the
84
+ * gradient stops; roughness still blurs toward `avg`.
85
+ */
86
+ image?: Texture;
87
+ };
88
+ }
89
+ export interface ShapeDrawParams {
90
+ /** Center X in canvas pixels. */
91
+ cx: number;
92
+ /** Center Y in canvas pixels. */
93
+ cy: number;
94
+ /** Width in canvas pixels. */
95
+ width: number;
96
+ /** Height in canvas pixels. */
97
+ height: number;
98
+ /** Rotation in degrees, around the center. */
99
+ rotation: number;
100
+ /** Premultiplied RGBA in 0..1. Used only when `gradient` is undefined. */
101
+ color: RGBA;
102
+ /**
103
+ * Optional gradient fill. When present, the backend renders with the
104
+ * gradient pipeline and ignores `color`. Up to 4 stops are supported.
105
+ */
106
+ gradient?: BackendGradient;
107
+ /**
108
+ * Corner radius in PIXELS. The backend clamps to half the smaller side so
109
+ * an overflowing value produces a pill / circle instead of a glitch.
110
+ *
111
+ * Corner SDFs run in pixel space inside the shaders, so non-square
112
+ * rectangles still produce circular corner arcs (not stretched ellipses).
113
+ */
114
+ cornerRadius?: number;
115
+ shape?: 'rectangle' | 'ellipse';
116
+ /**
117
+ * Stroke (border) color in premultiplied RGBA, applied to the band of
118
+ * pixels within `strokeWidth` of the shape's boundary. Only used when
119
+ * `strokeWidth > 0`. The fill (`color` or `gradient`) renders inside
120
+ * the stroke band; the stroke renders cleanly over its own pixels
121
+ * (no compositing through translucent fills).
122
+ */
123
+ strokeColor?: RGBA;
124
+ /** Stroke width in PIXELS. 0 or undefined disables the stroke. */
125
+ strokeWidth?: number;
126
+ /**
127
+ * Horizontal skew in DEGREES (CSS `skewX(...)`). Sheares the shape
128
+ * horizontally — top edge moves right for positive values, left for
129
+ * negative. Applied BEFORE rotation in the transform composition, so
130
+ * a `rotation + skew_x` combo matches CSS's `rotate(R) skewX(S)`.
131
+ */
132
+ skewX?: number;
133
+ /**
134
+ * Vertical skew in DEGREES (CSS `skewY(...)`). Positive moves the
135
+ * right edge down. Composes with skewX as a single shear matrix,
136
+ * matching CSS `skew(x, y)`.
137
+ */
138
+ skewY?: number;
139
+ /**
140
+ * CKP/1.0 full-matrix hand-off (§4.4): a pixel-space column-major
141
+ * mat4 (16 values, f64) mapping the shared unit quad (a_pos ∈
142
+ * [-1, 1]², Y-up) to Y-down pixel coordinates, with w carrying any
143
+ * perspective. When present the backend projects it to the current
144
+ * surface (projectPixelMatrix) and IGNORES cx/cy/rotation/skewX/
145
+ * skewY — those are baked in. `width`/`height` are still read for
146
+ * pixel-space SDF uniforms (corner radius, stroke) and must be the
147
+ * element's LOCAL dimensions.
148
+ */
149
+ transform?: ArrayLike<number>;
150
+ /** Blend against the destination. Default 'normal'. */
151
+ blend?: BlendMode;
152
+ /** PBR lighting (§4.8). Present ⇒ lit shader path; absent ⇒ unlit. */
153
+ lit?: LitParams;
154
+ }
155
+ /**
156
+ * Drop-shadow draw call. The shape geometry is the SAME as a
157
+ * companion `drawShape` (centered at `cx, cy` with width/height/etc.);
158
+ * the shadow renders a quad expanded by `blur` on each side and offset
159
+ * by `(offsetX, offsetY)`. Inside the shape's SDF the alpha is full;
160
+ * outside, alpha fades to 0 over `blur` pixels via a smoothstep — so
161
+ * pixels past `blur` discard, and pixels at the shape's edge get full
162
+ * shadow color. Designed to sit BEHIND its companion shape; the shape
163
+ * itself paints over the inside-of-shape shadow region.
164
+ */
165
+ export interface ShapeShadowDrawParams {
166
+ /** Center X of the SHAPE (shadow is offset relative to this). */
167
+ cx: number;
168
+ /** Center Y of the SHAPE. */
169
+ cy: number;
170
+ /** Width of the SHAPE in pixels. */
171
+ width: number;
172
+ /** Height of the SHAPE in pixels. */
173
+ height: number;
174
+ /** Rotation in DEGREES (matches the shape's rotation). */
175
+ rotation: number;
176
+ /** Horizontal skew in DEGREES (matches the shape's skew). */
177
+ skewX?: number;
178
+ /** Vertical skew in DEGREES (matches the shape's skew). */
179
+ skewY?: number;
180
+ /** Corner radius in PIXELS. */
181
+ cornerRadius?: number;
182
+ shape?: 'rectangle' | 'ellipse';
183
+ /** Shadow X offset in pixels. */
184
+ offsetX: number;
185
+ /** Shadow Y offset in pixels. */
186
+ offsetY: number;
187
+ /** Blur radius in pixels (falloff distance). */
188
+ blur: number;
189
+ /** Shadow color in premultiplied RGBA. */
190
+ color: RGBA;
191
+ /**
192
+ * Full-matrix hand-off — see ShapeDrawParams.transform. For shadows
193
+ * the matrix must already place the EXPANDED quad (width + 2·blur ×
194
+ * height + 2·blur, centered at cx + offsetX / cy + offsetY in the
195
+ * element's local plane): when present, the backend skips its own
196
+ * offset/expand composition.
197
+ */
198
+ transform?: ArrayLike<number>;
199
+ }
200
+ export interface TexturedQuadDrawParams {
201
+ cx: number;
202
+ cy: number;
203
+ width: number;
204
+ height: number;
205
+ rotation: number;
206
+ texture: Texture;
207
+ /**
208
+ * Texture sub-region in normalized UV space (0..1). Defaults to the
209
+ * whole texture `[0, 0, 1, 1]`. UV origin is top-left.
210
+ */
211
+ uvRect?: readonly [number, number, number, number];
212
+ /**
213
+ * Premultiplied RGBA color tint, multiplied with the texture sample.
214
+ * Defaults to `[1, 1, 1, 1]` (no tint).
215
+ */
216
+ tint?: RGBA;
217
+ /**
218
+ * Corner radius in PIXELS for rounded-rect masking. When > 0, pixels
219
+ * outside the rounded-rect SDF are discarded (with anti-aliased
220
+ * edges). Clamped to half the smaller dim; pass a huge value for
221
+ * a pill / circle. Matches CSS `border-radius` on `<img>` elements.
222
+ */
223
+ cornerRadius?: number;
224
+ /** Horizontal skew in DEGREES (CSS `skewX`). */
225
+ skewX?: number;
226
+ /** Vertical skew in DEGREES (CSS `skewY`). */
227
+ skewY?: number;
228
+ /** Full-matrix hand-off — see ShapeDrawParams.transform. */
229
+ transform?: ArrayLike<number>;
230
+ /** Blend against the destination. Default 'normal'. */
231
+ blend?: BlendMode;
232
+ /**
233
+ * Exponent applied to the sample's coverage (alpha) before tinting:
234
+ * a' = a^alphaGamma, with the premultiplied color rescaled to match.
235
+ * Default 1 (no-op). The text renderer passes a tint-luminance-
236
+ * derived value to approximate Chrome's gamma-corrected text AA —
237
+ * linear alpha blending over-darkens the fringe of dark-on-light
238
+ * glyphs, which reads as artificial boldness at small sizes.
239
+ */
240
+ alphaGamma?: number;
241
+ /**
242
+ * PBR lighting (§4.8). Present ⇒ lit textured path (the texture's own
243
+ * pixels are the albedo); absent ⇒ unlit. Used for lit images/video
244
+ * and flattened group-card layers. `alphaGamma` is ignored when lit.
245
+ */
246
+ lit?: LitParams;
247
+ }
248
+ /**
249
+ * Capabilities reported by the backend after init.
250
+ */
251
+ export interface BackendCapabilities {
252
+ /** 'webgpu' or 'webgl2'. */
253
+ readonly api: 'webgpu' | 'webgl2';
254
+ /** Maximum texture dimension supported. */
255
+ readonly maxTextureSize: number;
256
+ }
257
+ /**
258
+ * An offscreen layer: draws go INTO it between pushTarget/popTarget,
259
+ * and its `texture` can then be sampled like any uploaded image (via
260
+ * drawTexturedQuad or custom composite passes). The keystone for blend
261
+ * modes, masks, wipes, filters, and group clipping.
262
+ *
263
+ * Dimensions are LOGICAL (source coordinates); the backing store is
264
+ * allocated at the backend's current pixel ratio.
265
+ */
266
+ export interface RenderTarget {
267
+ readonly texture: Texture;
268
+ readonly width: number;
269
+ readonly height: number;
270
+ }
271
+ /** How a mask layer's pixels gate the content layer. */
272
+ export type MaskMode = 'alpha' | 'alpha-inverted' | 'luma' | 'luma-inverted';
273
+ /**
274
+ * How a draw combines with the destination. 'normal'/'multiply'/
275
+ * 'screen'/'add' are fixed-function on premultiplied sources. The
276
+ * piecewise modes — 'overlay'/'hard-light'/'soft-light' — can't be
277
+ * expressed by fixed-function blending; the compositor isolates such
278
+ * elements to a layer and composites them against a backdrop snapshot
279
+ * via drawBackdropBlend() rather than the per-draw `blend` path.
280
+ */
281
+ export type BlendMode = 'normal' | 'multiply' | 'screen' | 'add' | 'overlay' | 'hard-light' | 'soft-light';
282
+ /** The subset of blend modes that require backdrop-sampling compositing. */
283
+ export type ProgrammableBlendMode = 'overlay' | 'hard-light' | 'soft-light';
284
+ export declare function isProgrammableBlend(mode: BlendMode | undefined): mode is ProgrammableBlendMode;
285
+ /**
286
+ * Composite a content texture through a mask texture in one quad —
287
+ * the two-layer primitive behind group masks (and the wipe-family
288
+ * transitions, which are just masks animated over time).
289
+ */
290
+ export interface MaskedQuadDrawParams {
291
+ cx: number;
292
+ cy: number;
293
+ width: number;
294
+ height: number;
295
+ rotation: number;
296
+ /** Content layer (premultiplied). */
297
+ content: Texture;
298
+ /** Mask layer (premultiplied). */
299
+ mask: Texture;
300
+ mode: MaskMode;
301
+ /** Premultiplied tint, defaults [1,1,1,1]. Carries group opacity. */
302
+ tint?: RGBA;
303
+ /** Full-matrix hand-off — see ShapeDrawParams.transform. */
304
+ transform?: ArrayLike<number>;
305
+ /** Blend against the destination. Default 'normal'. */
306
+ blend?: BlendMode;
307
+ }
308
+ /**
309
+ * Composite a layer texture 1:1 onto the current surface through the
310
+ * filter shader — the primitive behind element filters (blur /
311
+ * brightness / contrast / saturation). Always axis-aligned: the
312
+ * element's own transform was already applied when it rendered INTO
313
+ * the layer.
314
+ *
315
+ * Blur is separable: the compositor runs a horizontal pass into a
316
+ * scratch target, then a vertical pass onto the destination. Each
317
+ * pass samples a 25-tap Gaussian spread over ±3σ along
318
+ * `blurDir`. Color ops run on straight (unpremultiplied) alpha in the
319
+ * order brightness → contrast → saturation, and only need to be set
320
+ * on the FINAL pass.
321
+ */
322
+ export interface FilteredQuadDrawParams {
323
+ cx: number;
324
+ cy: number;
325
+ width: number;
326
+ height: number;
327
+ texture: Texture;
328
+ /** Gaussian σ in LOGICAL canvas pixels. 0 disables blur taps. */
329
+ blurRadius: number;
330
+ /** Blur tap direction: [1,0] horizontal pass, [0,1] vertical. */
331
+ blurDir: readonly [number, number];
332
+ /** Brightness multiplier, 1 = unchanged. */
333
+ brightness: number;
334
+ /** Contrast multiplier around mid-gray, 1 = unchanged. */
335
+ contrast: number;
336
+ /** Saturation multiplier (Rec. 709 luma), 1 = unchanged. */
337
+ saturation: number;
338
+ /** Hue rotation in DEGREES (SVG hueRotate matrix), 0 = unchanged. */
339
+ hueRotate?: number;
340
+ /** Premultiplied tint, defaults [1,1,1,1]. */
341
+ tint?: RGBA;
342
+ /** Blend against the destination. Default 'normal'. */
343
+ blend?: BlendMode;
344
+ }
345
+ /**
346
+ * Composite an isolated element layer onto the current target using a
347
+ * piecewise (backdrop-sampling) blend mode — overlay/hard-light/
348
+ * soft-light. The shader reads both `src` (the element, rendered alone
349
+ * into a transparent layer) and `backdrop` (a snapshot of the target
350
+ * taken BEFORE the element drew), runs the W3C separable composite, and
351
+ * REPLACES the target region. Both textures are full surface size and
352
+ * premultiplied.
353
+ */
354
+ export interface BackdropBlendDrawParams {
355
+ /** Isolated element layer, premultiplied, surface-sized. */
356
+ src: Texture;
357
+ /** Backdrop snapshot, premultiplied, surface-sized. */
358
+ backdrop: Texture;
359
+ /** Which piecewise blend to apply. */
360
+ mode: ProgrammableBlendMode;
361
+ /** Full-surface quad size in logical pixels. */
362
+ width: number;
363
+ height: number;
364
+ /** copySurfaceTo may report the snapshot vertically flipped. */
365
+ backdropFlipY?: boolean;
366
+ }
367
+ /** Stylize-effect modes — `element.effects` types (§4.7). */
368
+ export type StylizeMode = 'pixelate' | 'dither' | 'halftone' | 'ascii' | 'drop_shadow' | 'glow' | 'stroke' | 'chroma_key' | 'luma_key' | 'levels' | 'lut' | 'fractal_noise' | 'turbulent_displace' | 'bloom_bright';
369
+ /** Mode → shader index, shared by both stylize shaders. */
370
+ export declare const STYLIZE_MODE_INDEX: Record<StylizeMode, number>;
371
+ /**
372
+ * One stylize pass: a layer texture drawn 1:1 through the effect
373
+ * shader. Like drawFilteredQuad, always axis-aligned — the element's
374
+ * transform was applied when it rendered into the layer. Chained
375
+ * effects ping-pong between two scratch targets; the last pass draws
376
+ * to the surface with the element's blend mode.
377
+ *
378
+ * Param meaning by mode (px values are LOGICAL; the backend scales
379
+ * px-dimensioned params by its pixel ratio):
380
+ * pixelate: p0 = cell size px
381
+ * dither: p0 = levels per channel (NOT px-scaled)
382
+ * halftone: p0 = cell size px, p1 = grid angle degrees
383
+ * ascii: p0 = cell size px (aux = 80×8 glyph-ramp atlas, required)
384
+ * drop_shadow: p0/p1 = offset px (aux = ladder-blurred layer; tint =
385
+ * shadow color × opacity, premultiplied)
386
+ * glow: p0 = intensity (aux = ladder-blurred layer; tint = color)
387
+ * stroke: p0 = width px (tint = color; ring-samples the layer)
388
+ * chroma_key: p0 = CbCr tolerance, p1 = softness (NOT px-scaled;
389
+ * tint = STRAIGHT key color rgb, tint.a = spill strength)
390
+ * luma_key: p0 = luma threshold, p1 = softness (NOT px-scaled;
391
+ * tint.r = invert flag 0/1)
392
+ * levels: p0 = gamma (NOT px-scaled; tint = (in_black, in_white,
393
+ * out_black, out_white))
394
+ * lut: p0 = lattice size N, p1 = intensity (NOT px-scaled;
395
+ * aux = the N²×N LUT atlas, slices along x = blue axis)
396
+ * fractal_noise: p0 = scale px, p1 = evolution (NOT scaled);
397
+ * tint = (offset_x/scale, offset_y/scale, octaves, seed)
398
+ * turbulent_displace: p0 = amount px, p1 = scale px;
399
+ * tint = (evolution, octaves, seed, 0)
400
+ */
401
+ export interface StylizedQuadDrawParams {
402
+ cx: number;
403
+ cy: number;
404
+ width: number;
405
+ height: number;
406
+ texture: Texture;
407
+ mode: StylizeMode;
408
+ p0: number;
409
+ p1?: number;
410
+ /** Secondary texture ('ascii' glyph atlas). Defaults to `texture`. */
411
+ aux?: Texture;
412
+ /** Premultiplied tint, defaults [1,1,1,1]. */
413
+ tint?: RGBA;
414
+ /** Blend against the destination. Default 'normal'. */
415
+ blend?: BlendMode;
416
+ }
417
+ /**
418
+ * The glass composite (§4.7 `glass`) — a faithful port of the
419
+ * ybouane/liquidglass optical model, evaluated ANALYTICALLY from the
420
+ * pane's rounded-rect SDF (glass applies to shape elements, where the
421
+ * geometry is known exactly — deriving it from a blurred alpha field
422
+ * produces flat "lip" artifacts at the rim). Drawn as a full-surface
423
+ * quad; the SDF does the masking and the outside-only drop shadow.
424
+ *
425
+ * Pixel-dimensioned params are LOGICAL px (backend scales by its pixel
426
+ * ratio): paneCx/paneCy/paneHalfW/paneHalfH/cornerRadius/zRadius/
427
+ * shadowSpread/shadowOffY.
428
+ */
429
+ export interface GlassQuadDrawParams {
430
+ /** Full-surface composite quad (like drawFilteredQuad). */
431
+ cx: number;
432
+ cy: number;
433
+ width: number;
434
+ height: number;
435
+ /** FROSTED backdrop snapshot (premultiplied). */
436
+ backdrop: Texture;
437
+ /** UNBLURRED backdrop snapshot; pass `backdrop` when blur is 0. */
438
+ backdropSharp: Texture;
439
+ /** GL-canvas snapshots are bottom-up; the shader flips at sample time. */
440
+ backdropFlipY: boolean;
441
+ /** Pane centre in surface coordinates. */
442
+ paneCx: number;
443
+ paneCy: number;
444
+ /** Pane half-size. */
445
+ paneHalfW: number;
446
+ paneHalfH: number;
447
+ /** Corner radius (clamped to min(half) in-shader). */
448
+ cornerRadius: number;
449
+ /** Pane rotation in degrees (SDF evaluates in pane-local coords). */
450
+ rotation: number;
451
+ /**
452
+ * CKP/1.0 glass under 3D (§4.7): pane-local→surface homography
453
+ * (column-major 3×3, LOGICAL px, origin at the pane centre, y down).
454
+ * When set, pane-local coordinates come from its inverse and
455
+ * refracted backdrop samples forward-map through it; `rotation` and
456
+ * `paneCx`/`paneCy` are ignored (fold them into the homography).
457
+ * Omitted = the 2D orthographic path, byte-stable.
458
+ */
459
+ paneHomography?: ArrayLike<number>;
460
+ /** Bevel z-radius — the lens depth (our `edge_width`). */
461
+ zRadius: number;
462
+ /** Refraction dial, reference scale (≈0..1; displacement ∝ ×30 px). */
463
+ refract: number;
464
+ /** Chromatic aberration dial, reference scale (≈0..1; ×18 px). */
465
+ chroma: number;
466
+ /** Edge highlight (rim/glow/stroke) dial. */
467
+ edgeHighlight: number;
468
+ /** Blinn-Phong specular dial (reference default 0). */
469
+ specular: number;
470
+ /** Fresnel dial (reference default 1). */
471
+ fresnel: number;
472
+ /** Saturation adjustment, −1..1 (0 = unchanged). */
473
+ saturation: number;
474
+ /** Glass tint as STRAIGHT RGBA; alpha = strength. */
475
+ tint: RGBA;
476
+ /** Pane opacity 0..1. */
477
+ alpha: number;
478
+ /** 'pill' = biconvex (0), 'dome' = plano-convex magnifier (1). */
479
+ bevelMode: number;
480
+ /** Shadow opacity 0..1 (painted only outside the SDF). */
481
+ shadowAlpha: number;
482
+ /** Shadow spread in px. */
483
+ shadowSpread: number;
484
+ /** Shadow vertical offset in px. */
485
+ shadowOffY: number;
486
+ /** Blend against the destination. Default 'normal'. */
487
+ blend?: BlendMode;
488
+ }
489
+ export interface Backend {
490
+ /** The canvas this backend renders into. Set at construction. */
491
+ readonly canvas: HTMLCanvasElement | OffscreenCanvas;
492
+ /** Current draw-buffer width in pixels. */
493
+ readonly width: number;
494
+ /** Current draw-buffer height in pixels. */
495
+ readonly height: number;
496
+ /**
497
+ * Initialize the GPU context, device, and pipelines.
498
+ * Returns false if this backend can't run in the current environment
499
+ * (e.g. WebGPU not available). The caller can then fall back to a
500
+ * different backend.
501
+ */
502
+ init(): Promise<boolean>;
503
+ /** Capabilities — only valid after init() resolves true. */
504
+ readonly capabilities: BackendCapabilities;
505
+ /**
506
+ * Resize the draw buffer.
507
+ *
508
+ * `width` and `height` are *logical* dimensions in source coordinates
509
+ * — what `composeQuadTransform` uses to map source positions to NDC.
510
+ * `pixelRatio` (default 1) multiplies the *physical* canvas backing
511
+ * store and viewport. With pixelRatio=2, a source authored at
512
+ * 1920×1080 renders into a 3840×2160 backing store at 2× pixel
513
+ * density. Source coordinates stay the same; shaders rasterize at
514
+ * higher resolution and the encoder pulls the larger frame.
515
+ */
516
+ resize(width: number, height: number, pixelRatio?: number): void;
517
+ /**
518
+ * Create a GPU texture from a source. Sources are assumed to be in
519
+ * straight-alpha; the backend premultiplies during upload.
520
+ */
521
+ createTexture(source: TextureSource): Texture;
522
+ /** Replace the contents of an existing texture (same dimensions). */
523
+ updateTexture(texture: Texture, source: TextureSource): void;
524
+ destroyTexture(texture: Texture): void;
525
+ /**
526
+ * Start a frame. Clears the canvas to the given premultiplied color
527
+ * (defaults to opaque black).
528
+ */
529
+ beginFrame(clearColor?: RGBA): void;
530
+ /** Draw a single-color rectangle / ellipse with optional rounded corners. */
531
+ drawShape(params: ShapeDrawParams): void;
532
+ /** Draw a drop shadow behind a shape — see `ShapeShadowDrawParams`. */
533
+ drawShapeShadow(params: ShapeShadowDrawParams): void;
534
+ /** Draw a textured rectangle. */
535
+ drawTexturedQuad(params: TexturedQuadDrawParams): void;
536
+ /** Composite a content texture through a mask texture. */
537
+ drawMaskedQuad(params: MaskedQuadDrawParams): void;
538
+ /** Composite a layer through the filter shader (blur / color ops). */
539
+ drawFilteredQuad(params: FilteredQuadDrawParams): void;
540
+ /** Composite a layer through one stylize-effect pass (§4.7). */
541
+ drawStylizedQuad(params: StylizedQuadDrawParams): void;
542
+ /** Glass composite — refract/frost a backdrop snapshot (§4.7). */
543
+ drawGlassQuad(params: GlassQuadDrawParams): void;
544
+ /** Composite an isolated layer with a piecewise blend mode (§4.5). */
545
+ drawBackdropBlend(params: BackdropBlendDrawParams): void;
546
+ /**
547
+ * Copy the CURRENT surface's pixels into a render target of the same
548
+ * logical size — the backdrop snapshot behind the glass effect. Call
549
+ * while the surface still holds only the pixels drawn so far (i.e.
550
+ * before pushing the effect chain's scratch targets). Returns whether
551
+ * the copied rows are bottom-up (GL canvas) so the sampler can flip.
552
+ */
553
+ copySurfaceTo(target: RenderTarget): {
554
+ flippedY: boolean;
555
+ };
556
+ /** Allocate an offscreen layer (logical dimensions). */
557
+ createRenderTarget(width: number, height: number): RenderTarget;
558
+ /** Release a layer's GPU resources (including its texture). */
559
+ destroyRenderTarget(target: RenderTarget): void;
560
+ /**
561
+ * Redirect subsequent draws into the target, cleared to `clearColor`
562
+ * (default transparent). Nestable; MUST be balanced with popTarget
563
+ * within the same frame.
564
+ */
565
+ pushTarget(target: RenderTarget, clearColor?: RGBA): void;
566
+ /** Restore drawing to the previous surface (target or canvas). */
567
+ popTarget(): void;
568
+ /** Submit the frame's commands to the GPU and present. */
569
+ endFrame(): void;
570
+ /**
571
+ * Resolve when all submitted GPU work has actually executed. Drains
572
+ * the pipeline — use sparingly (e.g. periodic true-cost measurement
573
+ * for the preview's adaptive motion-blur budget), never per frame.
574
+ */
575
+ finish(): Promise<void>;
576
+ /** Release all GPU resources. After this the backend is unusable. */
577
+ dispose(): void;
578
+ }
579
+ //# sourceMappingURL=backend.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"backend.d.ts","sourceRoot":"","sources":["../../src/backend/backend.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,wBAAwB,CAAC;AAEnD,4DAA4D;AAC5D,MAAM,MAAM,aAAa,GACrB,WAAW,GACX,iBAAiB,GACjB,eAAe,GACf,gBAAgB,GAChB,UAAU,GACV,gBAAgB,CAAC;AAErB,sEAAsE;AACtE,MAAM,WAAW,OAAO;IACtB,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAC;CACrB;AAED,MAAM,WAAW,mBAAmB;IAClC,wCAAwC;IACxC,MAAM,EAAE,MAAM,CAAC;IACf,0BAA0B;IAC1B,KAAK,EAAE,IAAI,CAAC;CACb;AAED,MAAM,MAAM,eAAe,GACvB;IACE,IAAI,EAAE,QAAQ,CAAC;IACf,6DAA6D;IAC7D,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,EAAE,mBAAmB,EAAE,CAAC;CAC9B,GACD;IACE,IAAI,EAAE,QAAQ,CAAC;IACf,+CAA+C;IAC/C,EAAE,EAAE,MAAM,CAAC;IACX,EAAE,EAAE,MAAM,CAAC;IACX,+CAA+C;IAC/C,MAAM,EAAE,MAAM,CAAC;IACf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AAO,IAAI,IAAI,CAAC;CACjB"}
@@ -0,0 +1,17 @@
1
+ // Backend interface — the GPU abstraction the compositor draws into.
2
+ //
3
+ // Designed deliberately small. Element renderers shouldn't know whether
4
+ // they're talking to WebGPU or WebGL2; they just call drawShape / drawTexturedQuad
5
+ // with pixel-space coordinates and premultiplied colors. The backend is
6
+ // responsible for NDC math, buffer allocation, and dispatch.
7
+ export function isProgrammableBlend(mode) {
8
+ return mode === 'overlay' || mode === 'hard-light' || mode === 'soft-light';
9
+ }
10
+ /** Mode → shader index, shared by both stylize shaders. */
11
+ export const STYLIZE_MODE_INDEX = {
12
+ pixelate: 0, dither: 1, halftone: 2, ascii: 3,
13
+ drop_shadow: 4, glow: 5, stroke: 6,
14
+ chroma_key: 7, luma_key: 8, levels: 9, lut: 10,
15
+ fractal_noise: 11, turbulent_displace: 12, bloom_bright: 13,
16
+ };
17
+ //# sourceMappingURL=backend.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"backend.js","sourceRoot":"","sources":["../../src/backend/backend.ts"],"names":[],"mappings":"AAAA,qEAAqE;AACrE,EAAE;AACF,wEAAwE;AACxE,mFAAmF;AACnF,wEAAwE;AACxE,6DAA6D;AAmT7D,MAAM,UAAU,mBAAmB,CAAC,IAA2B;IAC7D,OAAO,IAAI,KAAK,SAAS,IAAI,IAAI,KAAK,YAAY,IAAI,IAAI,KAAK,YAAY,CAAC;AAC9E,CAAC;AAwGD,2DAA2D;AAC3D,MAAM,CAAC,MAAM,kBAAkB,GAAgC;IAC7D,QAAQ,EAAE,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,QAAQ,EAAE,CAAC,EAAE,KAAK,EAAE,CAAC;IAC7C,WAAW,EAAE,CAAC,EAAE,IAAI,EAAE,CAAC,EAAE,MAAM,EAAE,CAAC;IAClC,UAAU,EAAE,CAAC,EAAE,QAAQ,EAAE,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,GAAG,EAAE,EAAE;IAC9C,aAAa,EAAE,EAAE,EAAE,kBAAkB,EAAE,EAAE,EAAE,YAAY,EAAE,EAAE;CAC5D,CAAC"}