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
@@ -0,0 +1,86 @@
1
+ import type { normalizeLayers } from './layerNormalization.js';
2
+ import type { GlyphRequest, WindfoilBoundingBox, WindfoilGlyphOutline, WindfoilPaint } from '../types.js';
3
+ export declare const WINDFOIL_MAX_LAYERS = 1024;
4
+ export interface WindfoilGlyphSource {
5
+ readonly request: GlyphRequest;
6
+ readonly outline: WindfoilGlyphOutline;
7
+ }
8
+ export interface WindfoilLayerHeader {
9
+ readonly rowBase: number;
10
+ readonly bandCount: number;
11
+ readonly bandH: number;
12
+ readonly invH: number;
13
+ readonly bbox: WindfoilBoundingBox;
14
+ readonly monotonePieceCount: number;
15
+ readonly paintKind: 0 | 1 | 2;
16
+ readonly rgba: readonly [number, number, number, number];
17
+ readonly paint: WindfoilPaint;
18
+ readonly paintLabel: string;
19
+ /** Bands run along x: the stored pieces and band header have x and y swapped. */
20
+ readonly transposed?: boolean;
21
+ paintIndex?: number;
22
+ }
23
+ export interface WindfoilGlyphHeader {
24
+ /** Index of the first row record, not the first u32. */
25
+ readonly rowBase: number;
26
+ readonly bandCount: number;
27
+ readonly bandH: number;
28
+ readonly invH: number;
29
+ readonly unitsPerEm: number;
30
+ readonly ascent: number;
31
+ readonly descent: number;
32
+ readonly bbox: WindfoilBoundingBox;
33
+ readonly monotonePieceCount: number;
34
+ readonly layers?: readonly WindfoilLayerHeader[];
35
+ readonly clipBox?: WindfoilBoundingBox;
36
+ }
37
+ export interface WindfoilPreprocessStats {
38
+ readonly paintLayers: number;
39
+ readonly uniqueGlyphs: number;
40
+ readonly monotonePieces: number;
41
+ readonly bandCount: number;
42
+ readonly bandedPieces: number;
43
+ readonly duplication: number;
44
+ }
45
+ export interface WindfoilPreprocessResult {
46
+ /**
47
+ * Three vec2 values per band-duplicated monotone quadratic. From `curveStart`,
48
+ * each band stores its `curveCount` pieces by descending x-maximum, then the
49
+ * same pieces again by ascending x-minimum.
50
+ */
51
+ readonly layered: boolean;
52
+ readonly curves: Float32Array;
53
+ /** `[curveStart, curveCount, densityBits, xMinBits, xMaxBits, splitBits]` per band. */
54
+ readonly rows: Uint32Array;
55
+ /** Glyph metadata keyed by `GlyphRequest.key`. */
56
+ readonly glyphs: ReadonlyMap<string, WindfoilGlyphHeader>;
57
+ readonly stats: WindfoilPreprocessStats;
58
+ }
59
+ export interface WindfoilPreprocessOptions {
60
+ /** Target monotone-piece count before band overlap; defaults to `10`. */
61
+ readonly targetPiecesPerBand?: number;
62
+ readonly signal?: AbortSignal;
63
+ readonly normalizeLayers?: typeof normalizeLayers;
64
+ /**
65
+ * Layered outlines this returns true for are drawn only by the composite shader, which may
66
+ * integrate a layer along x: such a layer is filed in vertical bands when that walks fewer
67
+ * pieces (wide, short layers), and its header is marked `transposed`.
68
+ */
69
+ readonly orientLayers?: (outline: {
70
+ readonly clipBox?: WindfoilBoundingBox;
71
+ }) => boolean;
72
+ }
73
+ export interface NormalizedLayer {
74
+ readonly bbox: WindfoilBoundingBox;
75
+ readonly quadratics: ArrayLike<number>;
76
+ readonly paint: WindfoilPaint;
77
+ readonly paintLabel: string;
78
+ readonly paintKind: 0 | 1 | 2;
79
+ readonly rgba: readonly [number, number, number, number];
80
+ }
81
+ export declare function checkFloat32(value: number, label: string): number;
82
+ export declare function float32Bits(value: number, label: string): number;
83
+ export declare function readFiniteFloat32(value: unknown, label: string): number;
84
+ export declare function readFlatNumbers(value: unknown, label: string, expectedLength?: number): readonly number[];
85
+ export declare function readFlatCoordinates(value: unknown, label: string): ArrayLike<number>;
86
+ export declare function readBox(value: unknown, label: string): WindfoilBoundingBox;
@@ -0,0 +1,65 @@
1
+ // src/windfoil/outlineValidation.ts
2
+ var WINDFOIL_MAX_LAYERS = 1024;
3
+ var scratchF32 = /* @__PURE__ */ new Float32Array(1);
4
+ var scratchU32 = new Uint32Array(scratchF32.buffer);
5
+ function checkFloat32(value, label) {
6
+ scratchF32[0] = value;
7
+ const f = scratchF32[0];
8
+ if (f - f !== 0) throw new RangeError(`${label} must be representable as a finite float32`);
9
+ return f;
10
+ }
11
+ function float32Bits(value, label) {
12
+ checkFloat32(value, label);
13
+ return scratchU32[0];
14
+ }
15
+ function readFiniteFloat32(value, label) {
16
+ if (typeof value !== "number" || !Number.isFinite(value)) throw new TypeError(`${label} must be a finite number`);
17
+ checkFloat32(value, label);
18
+ return value;
19
+ }
20
+ function readFlatNumbers(value, label, expectedLength) {
21
+ if (typeof value !== "object" || value === null || !("length" in value)) throw new TypeError(`${label} must be an array-like list of numbers`);
22
+ const length = value.length;
23
+ if (!Number.isSafeInteger(length) || length < 0) throw new RangeError(`${label}.length must be a non-negative safe integer`);
24
+ if (expectedLength !== void 0 && length !== expectedLength) throw new RangeError(`${label} must contain exactly ${expectedLength} numbers`);
25
+ const source = value;
26
+ const result = new Array(length);
27
+ for (let index = 0; index < result.length; index++) {
28
+ const item = source[index];
29
+ result[index] = typeof item === "number" && Number.isFinite(Math.fround(item)) ? item : readFiniteFloat32(item, `${label}[${index}]`);
30
+ }
31
+ return result;
32
+ }
33
+ function readFlatCoordinates(value, label) {
34
+ if (value instanceof Float32Array) {
35
+ for (let index = 0; index < value.length; index++) {
36
+ const v = value[index];
37
+ if (v - v !== 0) readFiniteFloat32(v, `${label}[${index}]`);
38
+ }
39
+ return value;
40
+ }
41
+ if (value instanceof Float64Array) {
42
+ for (let index = 0; index < value.length; index++) {
43
+ const f = Math.fround(value[index]);
44
+ if (f - f !== 0) readFiniteFloat32(value[index], `${label}[${index}]`);
45
+ }
46
+ return value;
47
+ }
48
+ if (Array.isArray(value)) {
49
+ for (let index = 0, len = value.length; index < len; index++) {
50
+ const item = value[index];
51
+ const f = typeof item === "number" ? Math.fround(item) : NaN;
52
+ if (f - f !== 0) readFiniteFloat32(item, `${label}[${index}]`);
53
+ }
54
+ return value;
55
+ }
56
+ return readFlatNumbers(value, label);
57
+ }
58
+ function readBox(value, label) {
59
+ const v = readFlatNumbers(value, label, 4);
60
+ if (v[0] > v[2] || v[1] > v[3]) throw new RangeError(`${label} minima must not exceed its maxima`);
61
+ return v;
62
+ }
63
+ export { WINDFOIL_MAX_LAYERS, checkFloat32, float32Bits, readBox, readFiniteFloat32, readFlatCoordinates, readFlatNumbers };
64
+
65
+ //# sourceMappingURL=outlineValidation.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"outlineValidation.js","names":[],"sources":["../../src/windfoil/outlineValidation.ts"],"sourcesContent":["import type { normalizeLayers } from './layerNormalization.js'\nimport type {\n GlyphRequest,\n WindfoilBoundingBox,\n WindfoilGlyphOutline,\n WindfoilPaint,\n} from '../types.js'\n\nexport const WINDFOIL_MAX_LAYERS = 1024\n\nexport interface WindfoilGlyphSource {\n readonly request: GlyphRequest\n readonly outline: WindfoilGlyphOutline\n}\n\nexport interface WindfoilLayerHeader {\n readonly rowBase: number\n readonly bandCount: number\n readonly bandH: number\n readonly invH: number\n readonly bbox: WindfoilBoundingBox\n readonly monotonePieceCount: number\n readonly paintKind: 0 | 1 | 2\n readonly rgba: readonly [number, number, number, number]\n readonly paint: WindfoilPaint\n readonly paintLabel: string\n /** Bands run along x: the stored pieces and band header have x and y swapped. */\n readonly transposed?: boolean\n paintIndex?: number\n}\n\nexport interface WindfoilGlyphHeader {\n /** Index of the first row record, not the first u32. */\n readonly rowBase: number\n readonly bandCount: number\n readonly bandH: number\n readonly invH: number\n readonly unitsPerEm: number\n readonly ascent: number\n readonly descent: number\n readonly bbox: WindfoilBoundingBox\n readonly monotonePieceCount: number\n readonly layers?: readonly WindfoilLayerHeader[]\n readonly clipBox?: WindfoilBoundingBox\n}\n\nexport interface WindfoilPreprocessStats {\n readonly paintLayers: number\n readonly uniqueGlyphs: number\n readonly monotonePieces: number\n readonly bandCount: number\n readonly bandedPieces: number\n readonly duplication: number\n}\n\nexport interface WindfoilPreprocessResult {\n /**\n * Three vec2 values per band-duplicated monotone quadratic. From `curveStart`,\n * each band stores its `curveCount` pieces by descending x-maximum, then the\n * same pieces again by ascending x-minimum.\n */\n readonly layered: boolean\n readonly curves: Float32Array\n /** `[curveStart, curveCount, densityBits, xMinBits, xMaxBits, splitBits]` per band. */\n readonly rows: Uint32Array\n /** Glyph metadata keyed by `GlyphRequest.key`. */\n readonly glyphs: ReadonlyMap<string, WindfoilGlyphHeader>\n readonly stats: WindfoilPreprocessStats\n}\n\nexport interface WindfoilPreprocessOptions {\n /** Target monotone-piece count before band overlap; defaults to `10`. */\n readonly targetPiecesPerBand?: number\n readonly signal?: AbortSignal\n readonly normalizeLayers?: typeof normalizeLayers\n /**\n * Layered outlines this returns true for are drawn only by the composite shader, which may\n * integrate a layer along x: such a layer is filed in vertical bands when that walks fewer\n * pieces (wide, short layers), and its header is marked `transposed`.\n */\n readonly orientLayers?: (outline: { readonly clipBox?: WindfoilBoundingBox }) => boolean\n}\n\nexport interface NormalizedLayer {\n readonly bbox: WindfoilBoundingBox\n readonly quadratics: ArrayLike<number>\n readonly paint: WindfoilPaint\n readonly paintLabel: string\n readonly paintKind: 0 | 1 | 2\n readonly rgba: readonly [number, number, number, number]\n}\n\nconst scratchF32 = new Float32Array(1)\nconst scratchU32 = new Uint32Array(scratchF32.buffer)\n\nexport function checkFloat32(value: number, label: string): number {\n scratchF32[0] = value\n const f = scratchF32[0]\n if (f - f !== 0) {\n throw new RangeError(`${label} must be representable as a finite float32`)\n }\n return f\n}\n\nexport function float32Bits(value: number, label: string): number {\n checkFloat32(value, label)\n return scratchU32[0]!\n}\n\nexport function readFiniteFloat32(value: unknown, label: string): number {\n if (typeof value !== 'number' || !Number.isFinite(value)) {\n throw new TypeError(`${label} must be a finite number`)\n }\n checkFloat32(value, label)\n return value\n}\n\nexport function readFlatNumbers(\n value: unknown,\n label: string,\n expectedLength?: number,\n): readonly number[] {\n if (typeof value !== 'object' || value === null || !('length' in value)) {\n throw new TypeError(`${label} must be an array-like list of numbers`)\n }\n\n const length = (value as { readonly length: unknown }).length\n if (!Number.isSafeInteger(length) || (length as number) < 0) {\n throw new RangeError(`${label}.length must be a non-negative safe integer`)\n }\n if (expectedLength !== undefined && length !== expectedLength) {\n throw new RangeError(`${label} must contain exactly ${expectedLength} numbers`)\n }\n\n const source = value as Readonly<Record<number, unknown>>\n const result = new Array<number>(length as number)\n for (let index = 0; index < result.length; index++) {\n const item = source[index]\n result[index] =\n typeof item === 'number' && Number.isFinite(Math.fround(item))\n ? item\n : readFiniteFloat32(item, `${label}[${index}]`)\n }\n return result\n}\n\nexport function readFlatCoordinates(value: unknown, label: string): ArrayLike<number> {\n if (value instanceof Float32Array) {\n for (let index = 0; index < value.length; index++) {\n const v = value[index]!\n if (v - v !== 0) readFiniteFloat32(v, `${label}[${index}]`)\n }\n return value\n }\n if (value instanceof Float64Array) {\n for (let index = 0; index < value.length; index++) {\n const f = Math.fround(value[index]!)\n if (f - f !== 0) readFiniteFloat32(value[index], `${label}[${index}]`)\n }\n return value\n }\n if (Array.isArray(value)) {\n for (let index = 0, len = value.length; index < len; index++) {\n const item: unknown = value[index]\n const f = typeof item === 'number' ? Math.fround(item) : NaN\n if (f - f !== 0) readFiniteFloat32(item, `${label}[${index}]`)\n }\n return value as readonly number[]\n }\n return readFlatNumbers(value, label)\n}\n\nexport function readBox(value: unknown, label: string): WindfoilBoundingBox {\n const v = readFlatNumbers(value, label, 4)\n if (v[0]! > v[2]! || v[1]! > v[3]!)\n throw new RangeError(`${label} minima must not exceed its maxima`)\n return v as unknown as WindfoilBoundingBox\n}\n"],"mappings":";AAQA,IAAa,sBAAsB;AAoFnC,IAAM,6BAAa,IAAI,aAAa,CAAC;AACrC,IAAM,aAAa,IAAI,YAAY,WAAW,MAAM;AAEpD,SAAgB,aAAa,OAAe,OAAuB;CACjE,WAAW,KAAK;CAChB,MAAM,IAAI,WAAW;CACrB,IAAI,IAAI,MAAM,GACZ,MAAM,IAAI,WAAW,GAAG,MAAM,2CAA2C;CAE3E,OAAO;AACT;AAEA,SAAgB,YAAY,OAAe,OAAuB;CAChE,aAAa,OAAO,KAAK;CACzB,OAAO,WAAW;AACpB;AAEA,SAAgB,kBAAkB,OAAgB,OAAuB;CACvE,IAAI,OAAO,UAAU,YAAY,CAAC,OAAO,SAAS,KAAK,GACrD,MAAM,IAAI,UAAU,GAAG,MAAM,yBAAyB;CAExD,aAAa,OAAO,KAAK;CACzB,OAAO;AACT;AAEA,SAAgB,gBACd,OACA,OACA,gBACmB;CACnB,IAAI,OAAO,UAAU,YAAY,UAAU,QAAQ,EAAE,YAAY,QAC/D,MAAM,IAAI,UAAU,GAAG,MAAM,uCAAuC;CAGtE,MAAM,SAAU,MAAuC;CACvD,IAAI,CAAC,OAAO,cAAc,MAAM,KAAM,SAAoB,GACxD,MAAM,IAAI,WAAW,GAAG,MAAM,4CAA4C;CAE5E,IAAI,mBAAmB,KAAA,KAAa,WAAW,gBAC7C,MAAM,IAAI,WAAW,GAAG,MAAM,wBAAwB,eAAe,SAAS;CAGhF,MAAM,SAAS;CACf,MAAM,SAAS,IAAI,MAAc,MAAgB;CACjD,KAAK,IAAI,QAAQ,GAAG,QAAQ,OAAO,QAAQ,SAAS;EAClD,MAAM,OAAO,OAAO;EACpB,OAAO,SACL,OAAO,SAAS,YAAY,OAAO,SAAS,KAAK,OAAO,IAAI,CAAC,IACzD,OACA,kBAAkB,MAAM,GAAG,MAAM,GAAG,MAAM,EAAE;CACpD;CACA,OAAO;AACT;AAEA,SAAgB,oBAAoB,OAAgB,OAAkC;CACpF,IAAI,iBAAiB,cAAc;EACjC,KAAK,IAAI,QAAQ,GAAG,QAAQ,MAAM,QAAQ,SAAS;GACjD,MAAM,IAAI,MAAM;GAChB,IAAI,IAAI,MAAM,GAAG,kBAAkB,GAAG,GAAG,MAAM,GAAG,MAAM,EAAE;EAC5D;EACA,OAAO;CACT;CACA,IAAI,iBAAiB,cAAc;EACjC,KAAK,IAAI,QAAQ,GAAG,QAAQ,MAAM,QAAQ,SAAS;GACjD,MAAM,IAAI,KAAK,OAAO,MAAM,MAAO;GACnC,IAAI,IAAI,MAAM,GAAG,kBAAkB,MAAM,QAAQ,GAAG,MAAM,GAAG,MAAM,EAAE;EACvE;EACA,OAAO;CACT;CACA,IAAI,MAAM,QAAQ,KAAK,GAAG;EACxB,KAAK,IAAI,QAAQ,GAAG,MAAM,MAAM,QAAQ,QAAQ,KAAK,SAAS;GAC5D,MAAM,OAAgB,MAAM;GAC5B,MAAM,IAAI,OAAO,SAAS,WAAW,KAAK,OAAO,IAAI,IAAI;GACzD,IAAI,IAAI,MAAM,GAAG,kBAAkB,MAAM,GAAG,MAAM,GAAG,MAAM,EAAE;EAC/D;EACA,OAAO;CACT;CACA,OAAO,gBAAgB,OAAO,KAAK;AACrC;AAEA,SAAgB,QAAQ,OAAgB,OAAoC;CAC1E,MAAM,IAAI,gBAAgB,OAAO,OAAO,CAAC;CACzC,IAAI,EAAE,KAAM,EAAE,MAAO,EAAE,KAAM,EAAE,IAC7B,MAAM,IAAI,WAAW,GAAG,MAAM,mCAAmC;CACnE,OAAO;AACT"}
@@ -1,5 +1,6 @@
1
- import { WINDFOIL_MAX_LAYERS, preprocessWindfoilOutlines as preprocessWindfoilOutlines$1, readBox, readFiniteFloat32, readFlatCoordinates, readFlatNumbers, validateWindfoilGlyphOutline as validateWindfoilGlyphOutline$1 } from "./preprocessCore.js";
1
+ import { readBox, readFiniteFloat32, readFlatCoordinates } from "./outlineValidation.js";
2
2
  import { normalizeLayers } from "./layerNormalization.js";
3
+ import { preprocessWindfoilGlyphsBatch, preprocessWindfoilOutlines as preprocessWindfoilOutlines$1, validateWindfoilGlyphOutline as validateWindfoilGlyphOutline$1 } from "./preprocessCore.js";
3
4
  // src/windfoil/preprocess.ts
4
5
  function preprocessWindfoilOutlines(sources, options = {}) {
5
6
  return preprocessWindfoilOutlines$1(sources, {
@@ -10,6 +11,6 @@ function preprocessWindfoilOutlines(sources, options = {}) {
10
11
  function validateWindfoilGlyphOutline(outline) {
11
12
  validateWindfoilGlyphOutline$1(outline, normalizeLayers);
12
13
  }
13
- export { WINDFOIL_MAX_LAYERS, preprocessWindfoilOutlines, readBox, readFiniteFloat32, readFlatCoordinates, readFlatNumbers, validateWindfoilGlyphOutline };
14
+ export { preprocessWindfoilGlyphsBatch, preprocessWindfoilOutlines, readBox, readFiniteFloat32, readFlatCoordinates, validateWindfoilGlyphOutline };
14
15
 
15
16
  //# sourceMappingURL=preprocess.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"preprocess.js","names":["core.preprocessWindfoilOutlines"],"sources":["../../src/windfoil/preprocess.ts"],"sourcesContent":["import type { WindfoilGlyphOutline } from '../types.js'\nimport * as core from './preprocessCore.js'\nimport { normalizeLayers } from './layerNormalization.js'\nexport * from './preprocessCore.js'\nexport function preprocessWindfoilGlyphs(\n sources: readonly core.WindfoilGlyphSource[],\n options: core.WindfoilPreprocessOptions = {},\n): core.WindfoilPreprocessResult {\n return core.preprocessWindfoilGlyphs(sources, { ...options, normalizeLayers })\n}\nexport function preprocessWindfoilOutlines(\n sources: readonly { readonly key: string; readonly outline: WindfoilGlyphOutline }[],\n options: core.WindfoilPreprocessOptions = {},\n): core.WindfoilPreprocessResult {\n return core.preprocessWindfoilOutlines(sources, { ...options, normalizeLayers })\n}\nexport function validateWindfoilGlyphOutline(\n outline: unknown,\n): asserts outline is WindfoilGlyphOutline {\n core.validateWindfoilGlyphOutline(outline, normalizeLayers)\n}\n"],"mappings":";;;AAUA,SAAgB,2BACd,SACA,UAA0C,CAAC,GACZ;CAC/B,OAAOA,6BAAgC,SAAS;EAAE,GAAG;EAAS;CAAgB,CAAC;AACjF;AACA,SAAgB,6BACd,SACyC;CACzC,+BAAkC,SAAS,eAAe;AAC5D"}
1
+ {"version":3,"file":"preprocess.js","names":["core.preprocessWindfoilOutlines"],"sources":["../../src/windfoil/preprocess.ts"],"sourcesContent":["import type { WindfoilGlyphOutline } from '../types.js'\nimport * as core from './preprocessCore.js'\nimport { normalizeLayers } from './layerNormalization.js'\nexport * from './preprocessCore.js'\nexport function preprocessWindfoilGlyphs(\n sources: readonly core.WindfoilGlyphSource[],\n options: core.WindfoilPreprocessOptions = {},\n): core.WindfoilPreprocessResult {\n return core.preprocessWindfoilGlyphs(sources, { ...options, normalizeLayers })\n}\nexport function preprocessWindfoilOutlines(\n sources: readonly { readonly key: string; readonly outline: WindfoilGlyphOutline }[],\n options: core.WindfoilPreprocessOptions = {},\n): core.WindfoilPreprocessResult {\n return core.preprocessWindfoilOutlines(sources, { ...options, normalizeLayers })\n}\nexport function validateWindfoilGlyphOutline(\n outline: unknown,\n): asserts outline is WindfoilGlyphOutline {\n core.validateWindfoilGlyphOutline(outline, normalizeLayers)\n}\n"],"mappings":";;;;AAUA,SAAgB,2BACd,SACA,UAA0C,CAAC,GACZ;CAC/B,OAAOA,6BAAgC,SAAS;EAAE,GAAG;EAAS;CAAgB,CAAC;AACjF;AACA,SAAgB,6BACd,SACyC;CACzC,+BAAkC,SAAS,eAAe;AAC5D"}
@@ -1,6 +1,7 @@
1
- import type { normalizeLayers } from './layerNormalization.js';
2
- import type { GlyphRequest, WindfoilBoundingBox, WindfoilGlyphOutline, WindfoilPaint, WindfoilQuadratic } from '../types.js';
3
- export type { WindfoilBoundingBox, WindfoilGlyphOutline, WindfoilQuadratic } from '../types.js';
1
+ import type { GlyphRequest, WindfoilBoundingBox, WindfoilGlyphOutline, WindfoilQuadratic } from '../types.js';
2
+ import { readBox, readFiniteFloat32, readFlatCoordinates, readFlatNumbers, WINDFOIL_MAX_LAYERS, type NormalizedLayer, type WindfoilGlyphHeader, type WindfoilGlyphSource, type WindfoilLayerHeader, type WindfoilPreprocessOptions, type WindfoilPreprocessResult, type WindfoilPreprocessStats } from './outlineValidation.js';
3
+ export { readBox, readFiniteFloat32, readFlatCoordinates, readFlatNumbers, WINDFOIL_MAX_LAYERS, type NormalizedLayer, type WindfoilGlyphHeader, type WindfoilGlyphSource, type WindfoilLayerHeader, type WindfoilPreprocessOptions, type WindfoilPreprocessResult, type WindfoilPreprocessStats, };
4
+ export type { GlyphRequest, WindfoilBoundingBox, WindfoilGlyphOutline, WindfoilQuadratic };
4
5
  /**
5
6
  * CPU preprocessing for the horizontal-band acceleration structure described by
6
7
  * texel-org/windfoil. The geometry and banding behavior is based on the
@@ -9,88 +10,6 @@ export type { WindfoilBoundingBox, WindfoilGlyphOutline, WindfoilQuadratic } fro
9
10
  export declare const WINDFOIL_ROW_STRIDE = 6;
10
11
  export declare const WINDFOIL_TARGET_PIECES_PER_BAND = 10;
11
12
  export declare const WINDFOIL_MAX_BANDS = 64;
12
- export declare const WINDFOIL_MAX_LAYERS = 1024;
13
- export interface WindfoilGlyphSource {
14
- readonly request: GlyphRequest;
15
- readonly outline: WindfoilGlyphOutline;
16
- }
17
- export interface WindfoilLayerHeader {
18
- readonly rowBase: number;
19
- readonly bandCount: number;
20
- readonly bandH: number;
21
- readonly invH: number;
22
- readonly bbox: WindfoilBoundingBox;
23
- readonly monotonePieceCount: number;
24
- readonly paintKind: 0 | 1 | 2;
25
- readonly rgba: readonly [number, number, number, number];
26
- readonly paint: WindfoilPaint;
27
- readonly paintLabel: string;
28
- /** Bands run along x: the stored pieces and band header have x and y swapped. */
29
- readonly transposed?: boolean;
30
- paintIndex?: number;
31
- }
32
- export interface WindfoilGlyphHeader {
33
- /** Index of the first row record, not the first u32. */
34
- readonly rowBase: number;
35
- readonly bandCount: number;
36
- readonly bandH: number;
37
- readonly invH: number;
38
- readonly unitsPerEm: number;
39
- readonly ascent: number;
40
- readonly descent: number;
41
- readonly bbox: WindfoilBoundingBox;
42
- readonly monotonePieceCount: number;
43
- readonly layers?: readonly WindfoilLayerHeader[];
44
- readonly clipBox?: WindfoilBoundingBox;
45
- }
46
- export interface WindfoilPreprocessStats {
47
- readonly paintLayers: number;
48
- readonly uniqueGlyphs: number;
49
- readonly monotonePieces: number;
50
- readonly bandCount: number;
51
- readonly bandedPieces: number;
52
- readonly duplication: number;
53
- }
54
- export interface WindfoilPreprocessResult {
55
- /**
56
- * Three vec2 values per band-duplicated monotone quadratic. From `curveStart`,
57
- * each band stores its `curveCount` pieces by descending x-maximum, then the
58
- * same pieces again by ascending x-minimum.
59
- */
60
- readonly layered: boolean;
61
- readonly curves: Float32Array;
62
- /** `[curveStart, curveCount, densityBits, xMinBits, xMaxBits, splitBits]` per band. */
63
- readonly rows: Uint32Array;
64
- /** Glyph metadata keyed by `GlyphRequest.key`. */
65
- readonly glyphs: ReadonlyMap<string, WindfoilGlyphHeader>;
66
- readonly stats: WindfoilPreprocessStats;
67
- }
68
- export interface WindfoilPreprocessOptions {
69
- /** Target monotone-piece count before band overlap; defaults to `10`. */
70
- readonly targetPiecesPerBand?: number;
71
- readonly signal?: AbortSignal;
72
- readonly normalizeLayers?: typeof normalizeLayers;
73
- /**
74
- * Layered outlines this returns true for are drawn only by the composite shader, which may
75
- * integrate a layer along x: such a layer is filed in vertical bands when that walks fewer
76
- * pieces (wide, short layers), and its header is marked `transposed`.
77
- */
78
- readonly orientLayers?: (outline: {
79
- readonly clipBox?: WindfoilBoundingBox;
80
- }) => boolean;
81
- }
82
- export interface NormalizedLayer {
83
- readonly bbox: WindfoilBoundingBox;
84
- readonly quadratics: ArrayLike<number>;
85
- readonly paint: WindfoilPaint;
86
- readonly paintLabel: string;
87
- readonly paintKind: 0 | 1 | 2;
88
- readonly rgba: readonly [number, number, number, number];
89
- }
90
- export declare function readFiniteFloat32(value: unknown, label: string): number;
91
- export declare function readFlatNumbers(value: unknown, label: string, expectedLength?: number): readonly number[];
92
- export declare function readFlatCoordinates(value: unknown, label: string): ArrayLike<number>;
93
- export declare function readBox(value: unknown, label: string): WindfoilBoundingBox;
94
13
  /** Runtime validation for data received from a font-outline provider. */
95
14
  export declare function validateWindfoilGlyphOutline(outline: unknown, normalizeLayers?: WindfoilPreprocessOptions['normalizeLayers']): asserts outline is WindfoilGlyphOutline;
96
15
  /** Splits one quadratic at each interior x/y extremum, producing one to three pieces. */
@@ -100,6 +19,7 @@ export declare function splitQuadraticIntoMonotonePieces(quadratic: ArrayLike<nu
100
19
  * Conflicting outlines under one key reject instead of making sharing order-dependent.
101
20
  */
102
21
  export declare function preprocessWindfoilGlyphs(sources: readonly WindfoilGlyphSource[], options?: WindfoilPreprocessOptions): WindfoilPreprocessResult;
22
+ export declare function preprocessWindfoilGlyphsBatch(sources: readonly WindfoilGlyphSource[], options?: WindfoilPreprocessOptions, curveFloatOffset?: number, rowUintOffset?: number): WindfoilPreprocessResult;
103
23
  /** Shared keyed-outline preprocessing for the shapes API. */
104
24
  export declare function preprocessWindfoilOutlines(sources: readonly {
105
25
  readonly key: string;