ultra-text 1.0.0 → 1.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (200) hide show
  1. package/README.md +267 -962
  2. package/THIRD_PARTY_NOTICES.md +3 -0
  3. package/dist/assets/{cpuSdf.worker-Du9o8q4p.js → cpuSdf.worker--X1Qpmdp.js} +148 -57
  4. package/dist/assets/cpuSdf.worker--X1Qpmdp.js.map +1 -0
  5. package/dist/atlas/appendAtlas.js +69 -26
  6. package/dist/atlas/appendAtlas.js.map +1 -1
  7. package/dist/atlas/buildAtlas.js +5 -15
  8. package/dist/atlas/buildAtlas.js.map +1 -1
  9. package/dist/atlas/cpuAtlas.d.ts +4 -1
  10. package/dist/atlas/cpuAtlas.js +8 -6
  11. package/dist/atlas/cpuAtlas.js.map +1 -1
  12. package/dist/atlas/cpuSdf.js +164 -50
  13. package/dist/atlas/cpuSdf.js.map +1 -1
  14. package/dist/atlas/cpuWorker.d.ts +5 -3
  15. package/dist/atlas/cpuWorker.js +119 -12
  16. package/dist/atlas/cpuWorker.js.map +1 -1
  17. package/dist/atlas/gpuAtlas.d.ts +7 -6
  18. package/dist/atlas/gpuAtlas.js +206 -247
  19. package/dist/atlas/gpuAtlas.js.map +1 -1
  20. package/dist/atlas/gpuCommon.d.ts +135 -0
  21. package/dist/atlas/gpuCommon.js +223 -0
  22. package/dist/atlas/gpuCommon.js.map +1 -0
  23. package/dist/atlas/jfaWgsl.js +59 -125
  24. package/dist/atlas/jfaWgsl.js.map +1 -1
  25. package/dist/atlas/rasterize.d.ts +2 -0
  26. package/dist/atlas/rasterize.js +104 -144
  27. package/dist/atlas/rasterize.js.map +1 -1
  28. package/dist/atlas/shapeRaster.js +2 -1
  29. package/dist/atlas/shapeRaster.js.map +1 -1
  30. package/dist/atlas/vanillaBounds.d.ts +64 -0
  31. package/dist/atlas/vanillaBounds.js +42 -0
  32. package/dist/atlas/vanillaBounds.js.map +1 -0
  33. package/dist/atlas/vanillaCore.d.ts +100 -0
  34. package/dist/atlas/vanillaCore.js +1012 -0
  35. package/dist/atlas/vanillaCore.js.map +1 -0
  36. package/dist/atlas/vanillaCpuAtlas.d.ts +9 -0
  37. package/dist/atlas/vanillaCpuAtlas.js +87 -0
  38. package/dist/atlas/vanillaCpuAtlas.js.map +1 -0
  39. package/dist/atlas/vanillaExtras.d.ts +8 -0
  40. package/dist/atlas/vanillaExtras.js +166 -0
  41. package/dist/atlas/vanillaExtras.js.map +1 -0
  42. package/dist/atlas/vanillaGpuHelpers.d.ts +232 -0
  43. package/dist/atlas/vanillaGpuHelpers.js +119 -0
  44. package/dist/atlas/vanillaGpuHelpers.js.map +1 -0
  45. package/dist/dom/DomSdf.js +263 -272
  46. package/dist/dom/DomSdf.js.map +1 -1
  47. package/dist/dom/DomSlug.d.ts +26 -0
  48. package/dist/dom/DomSlug.js +564 -0
  49. package/dist/dom/DomSlug.js.map +1 -0
  50. package/dist/dom/SlugText.d.ts +18 -0
  51. package/dist/dom/SlugText.js +94 -0
  52. package/dist/dom/SlugText.js.map +1 -0
  53. package/dist/dom/Text.js +4 -67
  54. package/dist/dom/Text.js.map +1 -1
  55. package/dist/dom/domAnalytic.d.ts +54 -0
  56. package/dist/dom/domAnalytic.js +282 -0
  57. package/dist/dom/domAnalytic.js.map +1 -0
  58. package/dist/dom/domExtras.d.ts +27 -0
  59. package/dist/dom/domExtras.js +137 -0
  60. package/dist/dom/domExtras.js.map +1 -0
  61. package/dist/dom/fontCanvas.d.ts +2 -0
  62. package/dist/dom/fontCanvas.js +119 -0
  63. package/dist/dom/fontCanvas.js.map +1 -0
  64. package/dist/dom/layoutSignature.js +156 -27
  65. package/dist/dom/layoutSignature.js.map +1 -1
  66. package/dist/dom/pretextLayout.js +55 -13
  67. package/dist/dom/pretextLayout.js.map +1 -1
  68. package/dist/dom/snapshot.js +563 -243
  69. package/dist/dom/snapshot.js.map +1 -1
  70. package/dist/dom/svgCapture.d.ts +8 -1
  71. package/dist/dom/svgCapture.js +75 -1
  72. package/dist/dom/svgCapture.js.map +1 -1
  73. package/dist/dom/textHost.d.ts +11 -0
  74. package/dist/dom/textHost.js +68 -0
  75. package/dist/dom/textHost.js.map +1 -0
  76. package/dist/dom/tone.js +76 -36
  77. package/dist/dom/tone.js.map +1 -1
  78. package/dist/index.js +4 -3
  79. package/dist/slug/SlugMaterial.d.ts +13 -4
  80. package/dist/slug/SlugMaterial.js +82 -12
  81. package/dist/slug/SlugMaterial.js.map +1 -1
  82. package/dist/slug/coverage.d.ts +17 -13
  83. package/dist/slug/coverage.js +195 -222
  84. package/dist/slug/coverage.js.map +1 -1
  85. package/dist/slug/preprocessCore.d.ts +6 -3
  86. package/dist/slug/preprocessCore.js +149 -95
  87. package/dist/slug/preprocessCore.js.map +1 -1
  88. package/dist/slug/runtime.d.ts +1 -0
  89. package/dist/slug/runtime.js +94 -46
  90. package/dist/slug/runtime.js.map +1 -1
  91. package/dist/slug/standaloneRuntime.d.ts +40 -0
  92. package/dist/slug/standaloneRuntime.js +175 -0
  93. package/dist/slug/standaloneRuntime.js.map +1 -0
  94. package/dist/slug/truetype.d.ts +22 -0
  95. package/dist/slug/truetype.js +467 -0
  96. package/dist/slug/truetype.js.map +1 -0
  97. package/dist/slug/vanillaCore.d.ts +340 -0
  98. package/dist/slug/vanillaCore.js +1621 -0
  99. package/dist/slug/vanillaCore.js.map +1 -0
  100. package/dist/slug-vanilla.d.ts +13 -0
  101. package/dist/slug-vanilla.js +13 -0
  102. package/dist/slug.d.ts +21 -0
  103. package/dist/slug.js +19 -0
  104. package/dist/text/GlyphTextMaterial.d.ts +11 -11
  105. package/dist/text/GlyphTextMaterial.js +102 -33
  106. package/dist/text/GlyphTextMaterial.js.map +1 -1
  107. package/dist/text/SdfTextMaterial.d.ts +5 -4
  108. package/dist/text/SdfTextMaterial.js +29 -9
  109. package/dist/text/SdfTextMaterial.js.map +1 -1
  110. package/dist/text/decorations.js +36 -19
  111. package/dist/text/decorations.js.map +1 -1
  112. package/dist/text/geometry.d.ts +3 -22
  113. package/dist/text/geometryUtils.d.ts +11 -1
  114. package/dist/text/geometryUtils.js +22 -1
  115. package/dist/text/geometryUtils.js.map +1 -1
  116. package/dist/text/glyphGeometry.d.ts +9 -0
  117. package/dist/text/glyphGeometry.js +353 -0
  118. package/dist/text/glyphGeometry.js.map +1 -0
  119. package/dist/text/index.d.ts +2 -1
  120. package/dist/text/rectGeometry.d.ts +13 -0
  121. package/dist/text/rectGeometry.js +97 -0
  122. package/dist/text/rectGeometry.js.map +1 -0
  123. package/dist/text/reflow.d.ts +18 -1
  124. package/dist/text/reflow.js +108 -38
  125. package/dist/text/reflow.js.map +1 -1
  126. package/dist/text/snap.d.ts +1 -0
  127. package/dist/text/snap.js +26 -0
  128. package/dist/text/snap.js.map +1 -0
  129. package/dist/types.d.ts +63 -14
  130. package/dist/vanilla.d.ts +13 -360
  131. package/dist/vanilla.js +8 -1402
  132. package/dist/windfoil/WindfoilMaterial.d.ts +2 -1
  133. package/dist/windfoil/WindfoilMaterial.js +8 -1
  134. package/dist/windfoil/WindfoilMaterial.js.map +1 -1
  135. package/dist/windfoil/abortable.d.ts +2 -0
  136. package/dist/windfoil/abortable.js +26 -0
  137. package/dist/windfoil/abortable.js.map +1 -0
  138. package/dist/windfoil/color.js +2 -1
  139. package/dist/windfoil/color.js.map +1 -1
  140. package/dist/windfoil/coverage.d.ts +3 -20
  141. package/dist/windfoil/coverage.js +7 -20
  142. package/dist/windfoil/coverage.js.map +1 -1
  143. package/dist/windfoil/emoji.js +1 -1
  144. package/dist/windfoil/emoji.js.map +1 -1
  145. package/dist/windfoil/emojiMetrics.js +1 -1
  146. package/dist/windfoil/emojiMetrics.js.map +1 -1
  147. package/dist/windfoil/geometry.d.ts +2 -2
  148. package/dist/windfoil/geometry.js +204 -64
  149. package/dist/windfoil/geometry.js.map +1 -1
  150. package/dist/windfoil/layerGrid.js +14 -10
  151. package/dist/windfoil/layerGrid.js.map +1 -1
  152. package/dist/windfoil/layerNormalization.d.ts +1 -1
  153. package/dist/windfoil/layerNormalization.js +1 -1
  154. package/dist/windfoil/layerNormalization.js.map +1 -1
  155. package/dist/windfoil/mixed.d.ts +1 -0
  156. package/dist/windfoil/mixed.js +44 -25
  157. package/dist/windfoil/mixed.js.map +1 -1
  158. package/dist/windfoil/outlineValidation.d.ts +86 -0
  159. package/dist/windfoil/outlineValidation.js +65 -0
  160. package/dist/windfoil/outlineValidation.js.map +1 -0
  161. package/dist/windfoil/preprocess.js +3 -2
  162. package/dist/windfoil/preprocess.js.map +1 -1
  163. package/dist/windfoil/preprocessCore.d.ts +5 -85
  164. package/dist/windfoil/preprocessCore.js +218 -209
  165. package/dist/windfoil/preprocessCore.js.map +1 -1
  166. package/dist/windfoil/requests.js +1 -1
  167. package/dist/windfoil/requests.js.map +1 -1
  168. package/dist/windfoil/runtime.d.ts +5 -2
  169. package/dist/windfoil/runtime.js +63 -40
  170. package/dist/windfoil/runtime.js.map +1 -1
  171. package/dist/windfoil/shapeResources.js +2 -1
  172. package/dist/windfoil/shapeResources.js.map +1 -1
  173. package/dist/windfoil/shapes.js +1 -1
  174. package/dist/windfoil/skirt.d.ts +22 -0
  175. package/dist/windfoil/skirt.js +20 -0
  176. package/dist/windfoil/skirt.js.map +1 -0
  177. package/dist/windfoil/storage.d.ts +62 -4
  178. package/dist/windfoil/storage.js +143 -28
  179. package/dist/windfoil/storage.js.map +1 -1
  180. package/dist/windfoil/trace/contours.d.ts +3 -3
  181. package/dist/windfoil/trace/contours.js +228 -137
  182. package/dist/windfoil/trace/contours.js.map +1 -1
  183. package/dist/windfoil/trace/fit.d.ts +3 -7
  184. package/dist/windfoil/trace/fit.js +668 -376
  185. package/dist/windfoil/trace/fit.js.map +1 -1
  186. package/dist/windfoil/trace/outline.js +60 -35
  187. package/dist/windfoil/trace/outline.js.map +1 -1
  188. package/dist/windfoil/trace/types.d.ts +15 -3
  189. package/dist/windfoil/tracedOutlines.d.ts +37 -1
  190. package/dist/windfoil/tracedOutlines.js +228 -64
  191. package/dist/windfoil/tracedOutlines.js.map +1 -1
  192. package/package.json +60 -11
  193. package/skills/ultra-text/SKILL.md +114 -0
  194. package/skills/ultra-text/references/frameworks.md +43 -0
  195. package/skills/ultra-text/references/three-tsl.md +78 -0
  196. package/skills/ultra-text/references/vanilla-webgpu.md +96 -0
  197. package/dist/assets/cpuSdf.worker-Du9o8q4p.js.map +0 -1
  198. package/dist/text/geometry.js +0 -348
  199. package/dist/text/geometry.js.map +0 -1
  200. package/dist/vanilla.js.map +0 -1
package/dist/vanilla.d.ts CHANGED
@@ -1,360 +1,13 @@
1
- import { alphaOfRgba, encodeSdfFromAlpha } from './atlas/cpuSdf.js';
2
- import { isColorCandidate, rasterizeGlyphAtlas, type RasterizeOptions } from './atlas/rasterize.js';
3
- import { layoutSignatureOf } from './dom/layoutSignature.js';
4
- import { collectDomSnapshot } from './dom/snapshot.js';
5
- import { backdropCurve, resolveDomTextTone, resolveTextTone, srgbEncode, toneCoverage, toneLightness, type ResolvedTextTone, type TextToneCapture, type TextToneContext } from './dom/tone.js';
6
- import { reflowSnapshot, snapGlyph } from './text/reflow.js';
7
- import type { BuildSdfAtlasOptions, ColorGlyphMode, DomLayoutSnapshot, DomSdfOptions, DomSdfStats, DomSvgOptions, DomTextBackend, DomTextLayoutEngine, DomTextStats, FontStyleSnapshot, GlyphBreak, GlyphLayout, GlyphRequest, GlyphShape, GlyphShapePath, GlyphShapeStroke, GlyphSlot, RasterAtlas, RasterColorBand, RectLayout, SdfAnimationMode, SdfAtlasMode, SdfDropShadowOptions, SdfMotionOptions, SdfOutlineOptions, SdfTextQuality, SvgEmojiOutlineProviderOptions, SvgToWindfoilOptions, TextBlockLayout, TextClass, TextCss, TextDecorationLayout, TextToneModel, TextToneOptions, WindfoilAffine, WindfoilBoundingBox, WindfoilColorStop, WindfoilEmBox, WindfoilExtendMode, WindfoilForegroundPaint, WindfoilGlyphOutline, WindfoilGradientBase, WindfoilGradientPaint, WindfoilLinearGradientPaint, WindfoilOptions, WindfoilOutlineLayer, WindfoilOutlineProvider, WindfoilPaint, WindfoilQuadratic, WindfoilRadialGradientPaint, WindfoilShapeInstance, WindfoilShapePathLike, WindfoilShapesStats, WindfoilSolidPaint, WindfoilSvgLayer, WindfoilSvgPaint, WindfoilSvgPath, WindfoilSvgResult, WindfoilSvgSource, WindfoilSvgWarning, WindfoilSvgWarningCode, WindfoilSweepGradientPaint } from './types.js';
8
- import { svgToWindfoilOutlines } from './windfoil/svg/convert.js';
9
- import { windfoilOutlineFromSvgPaths } from './windfoil/svg/pathConverter.js';
10
- export { alphaOfRgba, backdropCurve, collectDomSnapshot, encodeSdfFromAlpha, isColorCandidate, layoutSignatureOf, rasterizeGlyphAtlas, reflowSnapshot, resolveDomTextTone, resolveTextTone, snapGlyph, srgbEncode, svgToWindfoilOutlines, toneCoverage, toneLightness, windfoilOutlineFromSvgPaths, };
11
- export type { BuildSdfAtlasOptions, ColorGlyphMode, DomLayoutSnapshot, DomSdfStats, DomSvgOptions, DomTextBackend, DomTextLayoutEngine, DomTextStats, FontStyleSnapshot, GlyphBreak, GlyphLayout, GlyphRequest, GlyphShape, GlyphShapePath, GlyphShapeStroke, GlyphSlot, RasterAtlas, RasterColorBand, RasterizeOptions, RectLayout, ResolvedTextTone, SdfAnimationMode, SdfAtlasMode, SdfDropShadowOptions, SdfMotionOptions, SdfOutlineOptions, SdfTextQuality, SvgEmojiOutlineProviderOptions, SvgToWindfoilOptions, TextBlockLayout, TextClass, TextCss, TextDecorationLayout, TextToneCapture, TextToneContext, TextToneModel, TextToneOptions, WindfoilAffine, WindfoilBoundingBox, WindfoilColorStop, WindfoilEmBox, WindfoilExtendMode, WindfoilForegroundPaint, WindfoilGlyphOutline, WindfoilGradientBase, WindfoilGradientPaint, WindfoilLinearGradientPaint, WindfoilOptions, WindfoilOutlineLayer, WindfoilOutlineProvider, WindfoilPaint, WindfoilQuadratic, WindfoilRadialGradientPaint, WindfoilShapeInstance, WindfoilShapePathLike, WindfoilShapesStats, WindfoilSolidPaint, WindfoilSvgLayer, WindfoilSvgPaint, WindfoilSvgPath, WindfoilSvgResult, WindfoilSvgSource, WindfoilSvgWarning, WindfoilSvgWarningCode, WindfoilSweepGradientPaint, };
12
- /** Structural WebGPU texture handle returned by GPU atlas builds. */
13
- export interface VanillaGpuTexture {
14
- readonly label?: string;
15
- readonly width?: number;
16
- readonly height?: number;
17
- readonly format?: string;
18
- readonly mipLevelCount?: number;
19
- createView(descriptor?: {
20
- baseMipLevel?: number;
21
- mipLevelCount?: number;
22
- }): unknown;
23
- destroy(): void;
24
- }
25
- /** Structural WebGPU device interface so callers need neither Three.js nor `@webgpu/types`. */
26
- export interface VanillaGpuDevice {
27
- readonly limits?: {
28
- readonly maxStorageBufferBindingSize: number;
29
- readonly maxBufferSize: number;
30
- readonly maxComputeInvocationsPerWorkgroup?: number;
31
- readonly maxComputeWorkgroupSizeX?: number;
32
- readonly maxComputeWorkgroupSizeY?: number;
33
- readonly maxStorageBuffersPerShaderStage?: number;
34
- readonly maxStorageBuffersInFragmentStage?: number;
35
- readonly maxTextureDimension2D?: number;
36
- };
37
- createTexture(descriptor: {
38
- label?: string;
39
- size: readonly [number, number] | [number, number];
40
- mipLevelCount?: number;
41
- format: string;
42
- usage: number;
43
- }): VanillaGpuTexture;
44
- createBuffer(descriptor: {
45
- label?: string;
46
- size: number;
47
- usage: number;
48
- mappedAtCreation?: boolean;
49
- }): {
50
- destroy(): void;
51
- };
52
- createSampler(descriptor?: {
53
- label?: string;
54
- minFilter?: 'nearest' | 'linear';
55
- magFilter?: 'nearest' | 'linear';
56
- }): unknown;
57
- createShaderModule(descriptor: {
58
- label?: string;
59
- code: string;
60
- }): unknown;
61
- createComputePipeline(descriptor: {
62
- label?: string;
63
- layout: 'auto';
64
- compute: {
65
- module: unknown;
66
- entryPoint: string;
67
- };
68
- }): {
69
- getBindGroupLayout(index: number): unknown;
70
- };
71
- createRenderPipeline(descriptor: {
72
- label?: string;
73
- layout: 'auto';
74
- vertex: {
75
- module: unknown;
76
- entryPoint: string;
77
- };
78
- fragment: {
79
- module: unknown;
80
- entryPoint: string;
81
- targets: readonly {
82
- format: string;
83
- }[];
84
- };
85
- primitive?: {
86
- topology?: string;
87
- };
88
- }): {
89
- getBindGroupLayout(index: number): unknown;
90
- };
91
- createBindGroup(descriptor: {
92
- layout: unknown;
93
- entries: readonly {
94
- binding: number;
95
- resource: unknown;
96
- }[];
97
- }): unknown;
98
- createCommandEncoder(descriptor?: {
99
- label?: string;
100
- }): {
101
- copyTextureToBuffer(source: {
102
- texture: VanillaGpuTexture;
103
- }, destination: {
104
- buffer: {
105
- destroy(): void;
106
- };
107
- bytesPerRow: number;
108
- rowsPerImage: number;
109
- }, size: readonly [number, number] | [number, number]): void;
110
- beginComputePass(descriptor?: {
111
- label?: string;
112
- }): {
113
- setPipeline(pipeline: unknown): void;
114
- setBindGroup(index: number, bindGroup: unknown): void;
115
- dispatchWorkgroups(x: number, y?: number, z?: number): void;
116
- end(): void;
117
- };
118
- beginRenderPass(descriptor: {
119
- label?: string;
120
- colorAttachments: readonly {
121
- view: unknown;
122
- loadOp: 'clear' | 'load';
123
- storeOp: 'store' | 'discard';
124
- clearValue?: {
125
- r: number;
126
- g: number;
127
- b: number;
128
- a: number;
129
- };
130
- }[];
131
- }): {
132
- setPipeline(pipeline: unknown): void;
133
- setBindGroup(index: number, bindGroup: unknown): void;
134
- draw(vertexCount: number): void;
135
- end(): void;
136
- };
137
- finish(): unknown;
138
- };
139
- readonly queue: {
140
- copyExternalImageToTexture(source: {
141
- source: HTMLCanvasElement;
142
- flipY?: boolean;
143
- }, destination: {
144
- texture: VanillaGpuTexture;
145
- premultipliedAlpha?: boolean;
146
- }, size: readonly [number, number] | [number, number]): void;
147
- writeBuffer(buffer: {
148
- destroy(): void;
149
- }, bufferOffset: number, data: ArrayBufferView, dataOffset?: number, size?: number): void;
150
- writeTexture(destination: {
151
- texture: VanillaGpuTexture;
152
- mipLevel?: number;
153
- }, data: ArrayBufferView, dataLayout: {
154
- offset?: number;
155
- bytesPerRow: number;
156
- rowsPerImage?: number;
157
- }, size: readonly [number, number] | [number, number]): void;
158
- submit(commandBuffers: readonly unknown[]): void;
159
- };
160
- pushErrorScope?(filter: 'validation' | 'out-of-memory' | 'internal'): void;
161
- popErrorScope?(): Promise<{
162
- readonly message?: string;
163
- } | null>;
164
- }
165
- /** A WebGPU `GPUDevice`, an engine renderer holding `{ device }`, or `null`/`undefined` for CPU mode. */
166
- export type VanillaGpuDeviceSource = VanillaGpuDevice | {
167
- readonly device?: VanillaGpuDevice | null | undefined;
168
- } | null | undefined;
169
- /** Companion colour layer owned and disposed by its `VanillaSdfAtlas`. */
170
- export interface VanillaSdfColorLayer {
171
- readonly data: Uint8Array;
172
- readonly gpuTexture?: VanillaGpuTexture | undefined;
173
- readonly width: number;
174
- readonly top: number;
175
- readonly height: number;
176
- }
177
- /** Engine-agnostic SDF atlas with CPU bytes and/or an adopted WebGPU `GPUTexture`. */
178
- export interface VanillaSdfAtlas {
179
- /** Single-channel SDF bytes (`width * height`), present when built on CPU. */
180
- readonly data?: Uint8Array | undefined;
181
- /** WebGPU `r8unorm` texture (`TEXTURE_BINDING | COPY_SRC`), present when built on GPU. */
182
- readonly gpuTexture?: VanillaGpuTexture | undefined;
183
- readonly colorLayer?: VanillaSdfColorLayer | undefined;
184
- readonly shapeTop?: number | undefined;
185
- readonly width: number;
186
- readonly height: number;
187
- readonly pxRange: number;
188
- readonly bakeSize: number;
189
- readonly glyphs: ReadonlyMap<string, GlyphSlot>;
190
- readonly mode: Exclude<SdfAtlasMode, 'auto'>;
191
- /** Requested mipmap flag. */
192
- readonly mipmaps: boolean;
193
- /** Requested anisotropy level. */
194
- readonly anisotropy: number;
195
- dispose(): void;
196
- }
197
- export declare function buildVanillaGpuSdfAtlas(device: VanillaGpuDevice, raster: RasterAtlas, options?: Omit<BuildSdfAtlasOptions, 'mode'>): Promise<VanillaSdfAtlas>;
198
- export declare function buildVanillaCpuSdfAtlas(raster: RasterAtlas, options?: Omit<BuildSdfAtlasOptions, 'mode'> & {
199
- device?: VanillaGpuDeviceSource;
200
- }): Promise<VanillaSdfAtlas>;
201
- /**
202
- * Engine-agnostic SDF atlas builder. Accepts a `GPUDevice`, an object holding `{ device }`
203
- * (such as a Mini3 `Renderer`), or `null`/`undefined` for CPU generation.
204
- * In `'auto'` mode (default), tries the WebGPU JFA path when a device is provided and falls
205
- * back to the exact CPU EDT encoder if the device is absent or rejects the passes.
206
- */
207
- export declare function buildVanillaSdfAtlas(deviceOrRenderer: VanillaGpuDeviceSource, raster: RasterAtlas, options?: BuildSdfAtlasOptions): Promise<VanillaSdfAtlas>;
208
- export { buildVanillaSdfAtlas as buildSdfAtlas };
209
- /** Unit quad vertex positions (`[0,0,0, 1,0,0, 1,1,0, 0,1,0]`, 4 vertices × 3 floats). */
210
- export declare const UNIT_QUAD_POSITIONS: Float32Array<ArrayBuffer>;
211
- /** Unit quad vertex normals (`[0,0,1, ...]`, 4 vertices × 3 floats). */
212
- export declare const UNIT_QUAD_NORMALS: Float32Array<ArrayBuffer>;
213
- /** Unit quad triangle indices (`[0, 1, 2, 0, 2, 3]`, 6 uint16 indices). */
214
- export declare const UNIT_QUAD_INDICES: Uint16Array<ArrayBuffer>;
215
- /** Engine-agnostic 3D axis-aligned bounding box and bounding sphere. */
216
- export interface VanillaBounds {
217
- readonly min: readonly [x: number, y: number, z: number];
218
- readonly max: readonly [x: number, y: number, z: number];
219
- readonly center: readonly [x: number, y: number, z: number];
220
- readonly radius: number;
221
- }
222
- /** Computes a bounding box and sphere in local capture coordinates. */
223
- export declare function computeInstanceBounds(width: number, height: number, padding?: number, minZ?: number, maxZ?: number): VanillaBounds;
224
- /** Packed typed-array instance attributes for SDF glyphs. */
225
- export interface VanillaGlyphInstances {
226
- count: number;
227
- maxSequence: number;
228
- /** `[x0, y0, x1, y1]` per glyph in local capture units (`count * 4`). */
229
- rects: Float32Array;
230
- /** Normalized `unorm16` `[u0, v1, u1, v0]` per glyph (`count * 4`). */
231
- uvRects: Uint16Array;
232
- /** Normalized `unorm16` support trim `[u0, v1, u1, v0]` per glyph (`count * 4`), or `null` with `runMotion`. */
233
- trims: Uint16Array | null;
234
- /** `[x0, y0, x1, y1]` clip box per glyph (`count * 4`). */
235
- clips: Float32Array;
236
- /** Normalized `unorm8` `[r, g, b, a]` per glyph (`count * 4`). */
237
- colors: Uint8Array;
238
- /** `[sequence, z]` or `[sequence, z, switchEm]` per glyph (`count * metaItemSize`). */
239
- metadata: Float32Array;
240
- metaItemSize: 2 | 3;
241
- /** `[centerX, centerY, ordinal]` per glyph (`count * 3`) when shaped runs or SVG groups are present. */
242
- runMotion: Float32Array | null;
243
- bounds: VanillaBounds;
244
- }
245
- /** Packed typed-array instance attributes for DOM background rectangles. */
246
- export interface VanillaRectInstances {
247
- count: number;
248
- readonly receiveShadow: boolean;
249
- /** `[x0, y0, x1, y1]` per rectangle (`count * 4`). */
250
- rects: Float32Array;
251
- /** Normalized `unorm8` `[r, g, b, a]` per rectangle (`count * 4`). */
252
- colors: Uint8Array;
253
- /** Corner radius per rectangle (`count`). */
254
- radii: Float32Array;
255
- /** Z depth per rectangle (`count`). */
256
- depths: Float32Array;
257
- bounds: VanillaBounds;
258
- }
259
- /** Packed typed-array instance attributes for CSS text decorations. */
260
- export interface VanillaDecorationInstances {
261
- count: number;
262
- /** Source glyph `[x0, y0, x1, y1]` per decoration (`count * 4`). */
263
- rects: Float32Array;
264
- /** Decoration stroke `[x0, y0, x1, y1]` per decoration (`count * 4`). */
265
- decorationRects: Float32Array;
266
- /** Motion index per decoration (`count`). */
267
- decorationIndices: Float32Array;
268
- /** Normalized `unorm8` `[r, g, b, a]` per decoration (`count * 4`). */
269
- colors: Uint8Array;
270
- /** `[x0, y0, x1, y1]` clip box per decoration (`count * 4`). */
271
- clips: Float32Array;
272
- /** `[sequence, z]` per decoration (`count * 2`). */
273
- metadata: Float32Array;
274
- /** `[centerX, centerY, ordinal]` per decoration (`count * 3`) when shaped runs are present. */
275
- runMotion: Float32Array | null;
276
- bounds: VanillaBounds;
277
- }
278
- export type GlyphAtlasLookup = Pick<VanillaSdfAtlas, 'bakeSize' | 'glyphs'>;
279
- /** Packs instanced glyph attribute arrays from a layout snapshot and SDF atlas. */
280
- export declare function packGlyphInstances(snapshot: DomLayoutSnapshot, atlas: GlyphAtlasLookup, motionPadding?: number, motionOrdinals?: Float32Array): VanillaGlyphInstances;
281
- /**
282
- * Rewrites the glyph instance arrays that change on a reflow (`rects`, `clips`, `metadata`,
283
- * `runMotion`, `bounds`) in place without reallocating. Returns `maxSequence`, or `null` when
284
- * the glyph count no longer matches.
285
- */
286
- export declare function updateGlyphInstances(instances: VanillaGlyphInstances, snapshot: DomLayoutSnapshot, atlas: GlyphAtlasLookup, motionPadding?: number, motionOrdinals?: Float32Array): number | null;
287
- /**
288
- * Rewrites all glyph instance arrays in place when the drawable count and layout match.
289
- * Returns `maxSequence`, or `null` without mutating when the buffers do not fit.
290
- */
291
- export declare function updateGlyphContentInstances(instances: VanillaGlyphInstances, snapshot: DomLayoutSnapshot, atlas: GlyphAtlasLookup, motionPadding?: number, motionOrdinals?: Float32Array): number | null;
292
- /** Packs instanced rectangle attribute arrays for `receiveShadow: false` or `true`. */
293
- export declare function packRectInstances(snapshot: DomLayoutSnapshot, receiveShadow?: boolean): VanillaRectInstances | null;
294
- /** Rewrites a same-count rectangle batch in place. Returns `false` when the count changed. */
295
- export declare function updateRectInstances(instances: VanillaRectInstances, snapshot: DomLayoutSnapshot, receiveShadow?: boolean): boolean;
296
- export declare function packDecorationInstances(snapshot: DomLayoutSnapshot, sourceGlyphRects: ArrayLike<number>, drawable: (key: string) => boolean, motionPadding?: number): VanillaDecorationInstances | null;
297
- export declare function updateDecorationInstances(instances: VanillaDecorationInstances, snapshot: DomLayoutSnapshot, sourceGlyphRects: ArrayLike<number>, drawable: (key: string) => boolean, motionPadding?: number): boolean;
298
- export interface VanillaDomTextRebuildOptions {
299
- signal?: AbortSignal;
300
- }
301
- export type VanillaChangeReason = 'create' | 'rebuild' | 'reflow' | 'motion' | 'dispose';
302
- /** Options for `VanillaDomText` (`DomText` / `DomSdf` in `ultra-text/vanilla`). */
303
- export interface VanillaDomTextOptions extends Omit<DomSdfOptions, 'fill' | 'vertex' | 'sharedAtlas' | 'side' | 'textBackend' | 'windfoil'> {
304
- /** Optional shared `VanillaSdfAtlas` across multiple `VanillaDomText` instances. */
305
- sharedAtlas?: VanillaSdfAtlas;
306
- /** Called after initial creation, rebuild, reflow, motion update, or disposal. */
307
- onChange?: (instance: VanillaDomText, reason: VanillaChangeReason) => void;
308
- }
309
- export declare class VanillaDomText {
310
- #private;
311
- readonly element: HTMLElement;
312
- readonly device: VanillaGpuDevice | null;
313
- readonly options: Readonly<VanillaDomTextOptions>;
314
- glyphs: VanillaGlyphInstances;
315
- plainRects: VanillaRectInstances | null;
316
- litRects: VanillaRectInstances | null;
317
- decorations: VanillaDecorationInstances | null;
318
- tone: ResolvedTextTone | null;
319
- motion: Required<SdfMotionOptions>;
320
- protected constructor(element: HTMLElement, deviceOrRenderer: VanillaGpuDeviceSource, options: VanillaDomTextOptions);
321
- static create(element: HTMLElement, deviceOrRenderer?: VanillaGpuDeviceSource, options?: VanillaDomTextOptions): Promise<VanillaDomText>;
322
- get atlas(): VanillaSdfAtlas;
323
- get stats(): Readonly<DomSdfStats>;
324
- get snapshot(): DomLayoutSnapshot | null;
325
- get width(): number;
326
- get height(): number;
327
- get isDisposed(): boolean;
328
- subscribe(listener: (instance: VanillaDomText, reason: VanillaChangeReason) => void): () => void;
329
- reflow(width: number): this;
330
- setMotion(motion: SdfMotionOptions): this;
331
- rebuild(rebuildOptions?: VanillaDomTextRebuildOptions): Promise<this>;
332
- dispose(): void;
333
- protected resolveCaptureTone(snapshot: DomLayoutSnapshot): ResolvedTextTone | null;
334
- protected notify(reason: VanillaChangeReason): void;
335
- protected applySelectableAttribute(): void;
336
- protected setupObservers(): void;
337
- }
338
- export { VanillaDomText as DomSdf, VanillaDomText as DomText };
339
- export interface VanillaTextOptions extends VanillaDomTextOptions {
340
- device?: VanillaGpuDeviceSource;
341
- renderer?: VanillaGpuDeviceSource;
342
- css?: TextCss;
343
- cssClass?: TextClass;
344
- parent?: HTMLElement;
345
- }
346
- export declare class VanillaText extends VanillaDomText {
347
- #private;
348
- readonly ready: Promise<this>;
349
- constructor(text: string, options?: VanillaTextOptions);
350
- static create(text: string, options?: VanillaTextOptions): Promise<VanillaText>;
351
- static create(element: HTMLElement, deviceOrRenderer?: VanillaGpuDeviceSource, options?: VanillaDomTextOptions): Promise<VanillaDomText>;
352
- get text(): string;
353
- set text(value: string);
354
- setText(value: string, options?: VanillaDomTextRebuildOptions): Promise<this>;
355
- setCss(css: TextCss | undefined, options?: VanillaDomTextRebuildOptions): Promise<this>;
356
- setClass(cssClass: TextClass | undefined, options?: VanillaDomTextRebuildOptions): Promise<this>;
357
- dispose(): void;
358
- protected resolveCaptureTone(snapshot: DomLayoutSnapshot): ResolvedTextTone | null;
359
- }
360
- export { VanillaText as Text };
1
+ export { alphaOfRgba, encodeSdfFromAlpha } from './atlas/cpuSdf.js';
2
+ export { isColorCandidate, rasterizeGlyphAtlas, type RasterizeOptions } from './atlas/rasterize.js';
3
+ export * from './atlas/vanillaCore.js';
4
+ export { buildVanillaCpuSdfAtlas } from './atlas/vanillaCpuAtlas.js';
5
+ export { packDecorationInstances, packRectInstances, updateDecorationInstances, updateRectInstances, } from './atlas/vanillaExtras.js';
6
+ export { layoutSignatureOf } from './dom/layoutSignature.js';
7
+ export { collectDomSnapshot } from './dom/snapshot.js';
8
+ export { backdropCurve, resolveDomTextTone, resolveTextTone, srgbEncode, toneCoverage, toneLightness, type ResolvedTextTone, type TextToneCapture, type TextToneContext, } from './dom/tone.js';
9
+ export { reflowSnapshot } from './text/reflow.js';
10
+ export { snapGlyph } from './text/snap.js';
11
+ export type { BuildSdfAtlasOptions, ColorGlyphMode, DomLayoutSnapshot, DomSdfStats, DomSvgOptions, DomTextBackend, DomTextLayoutEngine, DomTextStats, FontStyleSnapshot, GlyphBreak, GlyphLayout, GlyphRequest, GlyphShape, GlyphShapePath, GlyphShapeStroke, GlyphSlot, RasterAtlas, RasterColorBand, RectLayout, SdfAnimationMode, SdfAtlasMode, SdfDropShadowOptions, SdfMotionOptions, SdfOutlineOptions, SdfTextQuality, SvgEmojiOutlineProviderOptions, SvgToWindfoilOptions, TextBlockLayout, TextClass, TextCss, TextDecorationLayout, TextToneModel, TextToneOptions, WindfoilAffine, WindfoilBoundingBox, WindfoilColorStop, WindfoilEmBox, WindfoilExtendMode, WindfoilForegroundPaint, WindfoilGlyphOutline, WindfoilGradientBase, WindfoilGradientPaint, WindfoilLinearGradientPaint, WindfoilOptions, WindfoilOutlineLayer, WindfoilOutlineProvider, WindfoilPaint, WindfoilQuadratic, WindfoilRadialGradientPaint, WindfoilShapeInstance, WindfoilShapePathLike, WindfoilShapesStats, WindfoilSolidPaint, WindfoilSvgLayer, WindfoilSvgPaint, WindfoilSvgPath, WindfoilSvgResult, WindfoilSvgSource, WindfoilSvgWarning, WindfoilSvgWarningCode, WindfoilSweepGradientPaint, } from './types.js';
12
+ export { svgToWindfoilOutlines } from './windfoil/svg/convert.js';
13
+ export { windfoilOutlineFromSvgPaths } from './windfoil/svg/pathConverter.js';