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,137 @@
1
+ import { createRectMaterial } from "../text/RectMaterial.js";
2
+ import { createRectGeometry, rectContentFits, updateRectGeometry } from "../text/rectGeometry.js";
3
+ import { TextDecorationMaterial, canUpdateDecorationGeometry, createDecorationGeometry, updateDecorationGeometry } from "../text/decorations.js";
4
+ import { Mesh } from "three/webgpu";
5
+ // src/dom/domExtras.ts
6
+ function createContentExtras(snapshot, textGeo, group, ownedMeshes, options, animated, motion, maxSequence, drawable) {
7
+ const materialMotion = (live) => animated() ? live : false;
8
+ let decorations = null;
9
+ const prepareDecorations = (layout, liveMotion, nextTextGeo, nextSequence, canDraw) => {
10
+ const geometry = createDecorationGeometry(layout, nextTextGeo, canDraw, liveMotion.strength ?? 18);
11
+ try {
12
+ return [geometry, geometry && !decorations ? new TextDecorationMaterial({
13
+ textShaping: options.textShaping ?? "none",
14
+ side: options.side,
15
+ vertex: options.vertex,
16
+ motion: materialMotion(liveMotion),
17
+ maxSequence: nextSequence
18
+ }) : null];
19
+ } catch (error) {
20
+ geometry?.dispose();
21
+ throw error;
22
+ }
23
+ };
24
+ const commitDecorations = ([geometry, material], liveMotion, seqValue) => {
25
+ if (!geometry) {
26
+ if (decorations) {
27
+ group.remove(decorations);
28
+ ownedMeshes.splice(ownedMeshes.indexOf(decorations), 1);
29
+ decorations.geometry.dispose();
30
+ decorations.material.dispose();
31
+ decorations = null;
32
+ }
33
+ return;
34
+ }
35
+ if (decorations) {
36
+ const previous = decorations.geometry;
37
+ decorations.geometry = geometry;
38
+ previous.dispose();
39
+ if (animated()) decorations.material.setMotion(liveMotion);
40
+ decorations.material.maxSequence.value = seqValue;
41
+ } else {
42
+ decorations = new Mesh(geometry, material);
43
+ decorations.name = "ultra-text text decorations";
44
+ decorations.castShadow = options.castShadow !== false;
45
+ decorations.renderOrder = 3;
46
+ decorations.frustumCulled = false;
47
+ group.add(decorations);
48
+ ownedMeshes.push(decorations);
49
+ }
50
+ };
51
+ const updateDec = (layout, textGeom, isAnim, liveMotion, seqValue, canDraw) => {
52
+ if (!decorations) return;
53
+ if (updateDecorationGeometry(decorations.geometry, layout, textGeom, canDraw, liveMotion.strength ?? 18)) {
54
+ if (isAnim) decorations.material.setMotion(liveMotion);
55
+ decorations.material.maxSequence.value = seqValue;
56
+ return;
57
+ }
58
+ commitDecorations(prepareDecorations(layout, liveMotion, textGeom, seqValue, canDraw), liveMotion, seqValue);
59
+ };
60
+ const addRects = (receiver, name) => {
61
+ const geometry = createRectGeometry(snapshot, receiver);
62
+ if (!geometry) return null;
63
+ let mesh;
64
+ try {
65
+ mesh = new Mesh(geometry, createRectMaterial(receiver, options.shadowFloor));
66
+ } catch (error) {
67
+ geometry.dispose();
68
+ throw error;
69
+ }
70
+ mesh.name = name;
71
+ mesh.receiveShadow = receiver;
72
+ mesh.frustumCulled = true;
73
+ mesh.renderOrder = 0;
74
+ mesh.matrixAutoUpdate = false;
75
+ mesh.updateMatrix();
76
+ group.add(mesh);
77
+ ownedMeshes.push(mesh);
78
+ return mesh;
79
+ };
80
+ const initialDecorations = prepareDecorations(snapshot, motion, textGeo, maxSequence, drawable);
81
+ if (initialDecorations[0]) commitDecorations(initialDecorations, motion, maxSequence);
82
+ const plainRects = addRects(false, "ultra-text DOM rectangles");
83
+ const receivers = addRects(true, "ultra-text shadow receivers");
84
+ return {
85
+ decMesh: () => decorations,
86
+ setMotion(change) {
87
+ decorations?.material.setMotion(change);
88
+ },
89
+ updateDec,
90
+ fitsLayout(nextSnapshot) {
91
+ const wantsPlain = nextSnapshot.rects.some((r) => !r.receiveShadow);
92
+ const wantsReceivers = nextSnapshot.rects.some((r) => r.receiveShadow);
93
+ return wantsPlain === (plainRects !== null) && wantsReceivers === (receivers !== null);
94
+ },
95
+ decorationsFit(nextSnapshot, canDraw) {
96
+ return canUpdateDecorationGeometry(decorations?.geometry ?? null, nextSnapshot, canDraw);
97
+ },
98
+ prepare(nextSnapshot, nextTextGeo, _isAnim, liveMotion, nextSequence, decFits, canDraw) {
99
+ const plainFit = !plainRects || rectContentFits(plainRects.geometry, nextSnapshot, false);
100
+ const receiverFit = !receivers || rectContentFits(receivers.geometry, nextSnapshot, true);
101
+ let plain = null;
102
+ let rec = null;
103
+ let dec = null;
104
+ const dispose = () => {
105
+ plain?.dispose();
106
+ rec?.dispose();
107
+ dec?.[0]?.dispose();
108
+ dec?.[1]?.dispose();
109
+ };
110
+ try {
111
+ if (plainRects && !plainFit) plain = createRectGeometry(nextSnapshot, false);
112
+ if (receivers && !receiverFit) rec = createRectGeometry(nextSnapshot, true);
113
+ if (!decFits) dec = prepareDecorations(nextSnapshot, liveMotion, nextTextGeo, nextSequence, canDraw);
114
+ } catch (error) {
115
+ dispose();
116
+ throw error;
117
+ }
118
+ return {
119
+ plain,
120
+ receivers: rec,
121
+ decorations: dec,
122
+ dispose
123
+ };
124
+ },
125
+ commit(staged, nextSnapshot, nextTextGeo, isAnim, liveMotion, seqValue, canDraw, swap) {
126
+ if (staged.decorations) commitDecorations(staged.decorations, liveMotion, seqValue);
127
+ else updateDec(nextSnapshot, nextTextGeo, isAnim, liveMotion, seqValue, canDraw);
128
+ if (plainRects && staged.plain) swap(plainRects, staged.plain);
129
+ else if (plainRects) updateRectGeometry(plainRects.geometry, nextSnapshot, false);
130
+ if (receivers && staged.receivers) swap(receivers, staged.receivers);
131
+ else if (receivers) updateRectGeometry(receivers.geometry, nextSnapshot, true);
132
+ }
133
+ };
134
+ }
135
+ export { createContentExtras };
136
+
137
+ //# sourceMappingURL=domExtras.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"domExtras.js","names":[],"sources":["../../src/dom/domExtras.ts"],"sourcesContent":["import { Mesh, type Group, type InstancedBufferGeometry } from 'three/webgpu'\n\nimport {\n canUpdateDecorationGeometry,\n createDecorationGeometry,\n TextDecorationMaterial,\n updateDecorationGeometry,\n} from '../text/decorations.js'\nimport { createRectGeometry, rectContentFits, updateRectGeometry } from '../text/rectGeometry.js'\nimport { createRectMaterial } from '../text/RectMaterial.js'\nimport type { GlyphTextMaterial } from '../text/GlyphTextMaterial.js'\nimport type { DomLayoutSnapshot, SdfMotionOptions } from '../types.js'\n\nexport interface ExtrasOptions {\n readonly textShaping?: 'none' | 'browser'\n readonly side?: GlyphTextMaterial['side']\n readonly vertex?: unknown\n readonly castShadow?: boolean\n readonly shadowFloor?: number\n}\n\nexport interface StagedExtras {\n readonly plain: InstancedBufferGeometry | null\n readonly receivers: InstancedBufferGeometry | null\n readonly decorations:\n readonly [InstancedBufferGeometry | null, TextDecorationMaterial | null] | null\n dispose(): void\n}\n\nexport interface ContentExtrasController {\n readonly decMesh: () => Mesh<InstancedBufferGeometry, TextDecorationMaterial> | null\n setMotion(change: SdfMotionOptions): void\n updateDec(\n layout: DomLayoutSnapshot,\n textGeo: InstancedBufferGeometry,\n animated: boolean,\n liveMotion: SdfMotionOptions,\n maxSequence: number,\n drawable: (key: string) => boolean,\n ): void\n fitsLayout(snapshot: DomLayoutSnapshot): boolean\n decorationsFit(snapshot: DomLayoutSnapshot, drawable: (key: string) => boolean): boolean\n prepare(\n snapshot: DomLayoutSnapshot,\n textGeo: InstancedBufferGeometry,\n animated: boolean,\n liveMotion: SdfMotionOptions,\n maxSequence: number,\n decorationsFit: boolean,\n drawable: (key: string) => boolean,\n ): StagedExtras\n commit(\n staged: StagedExtras,\n snapshot: DomLayoutSnapshot,\n textGeo: InstancedBufferGeometry,\n animated: boolean,\n liveMotion: SdfMotionOptions,\n maxSequence: number,\n drawable: (key: string) => boolean,\n swapGeometry: (mesh: Mesh, geometry: InstancedBufferGeometry) => void,\n ): void\n}\n\nexport function createContentExtras(\n snapshot: DomLayoutSnapshot,\n textGeo: InstancedBufferGeometry,\n group: Group,\n ownedMeshes: Mesh[],\n options: ExtrasOptions,\n animated: () => boolean,\n motion: SdfMotionOptions,\n maxSequence: number,\n drawable: (key: string) => boolean,\n): ContentExtrasController {\n const materialMotion = (live: SdfMotionOptions): SdfMotionOptions | false =>\n animated() ? live : false\n let decorations: Mesh<InstancedBufferGeometry, TextDecorationMaterial> | null = null\n\n const prepareDecorations = (\n layout: DomLayoutSnapshot,\n liveMotion: SdfMotionOptions,\n nextTextGeo: InstancedBufferGeometry,\n nextSequence: number,\n canDraw: (key: string) => boolean,\n ): readonly [InstancedBufferGeometry | null, TextDecorationMaterial | null] => {\n const geometry = createDecorationGeometry(\n layout,\n nextTextGeo,\n canDraw,\n liveMotion.strength ?? 18,\n )\n try {\n return [\n geometry,\n geometry && !decorations\n ? new TextDecorationMaterial({\n textShaping: options.textShaping ?? 'none',\n side: options.side,\n vertex: options.vertex as never,\n motion: materialMotion(liveMotion),\n maxSequence: nextSequence,\n })\n : null,\n ]\n } catch (error) {\n geometry?.dispose()\n throw error\n }\n }\n\n const commitDecorations = (\n [geometry, material]: readonly [InstancedBufferGeometry | null, TextDecorationMaterial | null],\n liveMotion: SdfMotionOptions,\n seqValue: number,\n ): void => {\n if (!geometry) {\n if (decorations) {\n group.remove(decorations)\n ownedMeshes.splice(ownedMeshes.indexOf(decorations), 1)\n decorations.geometry.dispose()\n decorations.material.dispose()\n decorations = null\n }\n return\n }\n if (decorations) {\n const previous = decorations.geometry\n decorations.geometry = geometry\n previous.dispose()\n if (animated()) decorations.material.setMotion(liveMotion)\n decorations.material.maxSequence.value = seqValue\n } else {\n decorations = new Mesh(geometry, material!)\n decorations.name = 'ultra-text text decorations'\n decorations.castShadow = options.castShadow !== false\n decorations.renderOrder = 3\n decorations.frustumCulled = false\n group.add(decorations)\n ownedMeshes.push(decorations)\n }\n }\n\n const updateDec = (\n layout: DomLayoutSnapshot,\n textGeom: InstancedBufferGeometry,\n isAnim: boolean,\n liveMotion: SdfMotionOptions,\n seqValue: number,\n canDraw: (key: string) => boolean,\n ): void => {\n if (!decorations) return\n if (\n updateDecorationGeometry(\n decorations.geometry,\n layout,\n textGeom,\n canDraw,\n liveMotion.strength ?? 18,\n )\n ) {\n if (isAnim) decorations.material.setMotion(liveMotion)\n decorations.material.maxSequence.value = seqValue\n return\n }\n commitDecorations(\n prepareDecorations(layout, liveMotion, textGeom, seqValue, canDraw),\n liveMotion,\n seqValue,\n )\n }\n\n const addRects = (receiver: boolean, name: string): Mesh | null => {\n const geometry = createRectGeometry(snapshot, receiver)\n if (!geometry) return null\n let mesh: Mesh\n try {\n mesh = new Mesh(geometry, createRectMaterial(receiver, options.shadowFloor))\n } catch (error) {\n geometry.dispose()\n throw error\n }\n mesh.name = name\n mesh.receiveShadow = receiver\n mesh.frustumCulled = true\n mesh.renderOrder = 0\n mesh.matrixAutoUpdate = false\n mesh.updateMatrix()\n group.add(mesh)\n ownedMeshes.push(mesh)\n return mesh\n }\n\n const initialDecorations = prepareDecorations(snapshot, motion, textGeo, maxSequence, drawable)\n if (initialDecorations[0]) commitDecorations(initialDecorations, motion, maxSequence)\n const plainRects = addRects(false, 'ultra-text DOM rectangles')\n const receivers = addRects(true, 'ultra-text shadow receivers')\n\n return {\n decMesh: () => decorations,\n setMotion(change) {\n decorations?.material.setMotion(change)\n },\n updateDec,\n fitsLayout(nextSnapshot) {\n const wantsPlain = nextSnapshot.rects.some((r) => !r.receiveShadow)\n const wantsReceivers = nextSnapshot.rects.some((r) => r.receiveShadow)\n return wantsPlain === (plainRects !== null) && wantsReceivers === (receivers !== null)\n },\n decorationsFit(nextSnapshot, canDraw) {\n return canUpdateDecorationGeometry(decorations?.geometry ?? null, nextSnapshot, canDraw)\n },\n prepare(nextSnapshot, nextTextGeo, _isAnim, liveMotion, nextSequence, decFits, canDraw) {\n const plainFit =\n !plainRects ||\n rectContentFits(plainRects.geometry as InstancedBufferGeometry, nextSnapshot, false)\n const receiverFit =\n !receivers ||\n rectContentFits(receivers.geometry as InstancedBufferGeometry, nextSnapshot, true)\n let plain: InstancedBufferGeometry | null = null\n let rec: InstancedBufferGeometry | null = null\n let dec: readonly [InstancedBufferGeometry | null, TextDecorationMaterial | null] | null =\n null\n const dispose = (): void => {\n plain?.dispose()\n rec?.dispose()\n dec?.[0]?.dispose()\n dec?.[1]?.dispose()\n }\n try {\n if (plainRects && !plainFit) plain = createRectGeometry(nextSnapshot, false)\n if (receivers && !receiverFit) rec = createRectGeometry(nextSnapshot, true)\n if (!decFits)\n dec = prepareDecorations(nextSnapshot, liveMotion, nextTextGeo, nextSequence, canDraw)\n } catch (error) {\n dispose()\n throw error\n }\n return { plain, receivers: rec, decorations: dec, dispose }\n },\n commit(staged, nextSnapshot, nextTextGeo, isAnim, liveMotion, seqValue, canDraw, swap) {\n if (staged.decorations) commitDecorations(staged.decorations, liveMotion, seqValue)\n else updateDec(nextSnapshot, nextTextGeo, isAnim, liveMotion, seqValue, canDraw)\n if (plainRects && staged.plain) swap(plainRects, staged.plain)\n else if (plainRects)\n updateRectGeometry(plainRects.geometry as InstancedBufferGeometry, nextSnapshot, false)\n if (receivers && staged.receivers) swap(receivers, staged.receivers)\n else if (receivers)\n updateRectGeometry(receivers.geometry as InstancedBufferGeometry, nextSnapshot, true)\n },\n }\n}\n"],"mappings":";;;;;AA+DA,SAAgB,oBACd,UACA,SACA,OACA,aACA,SACA,UACA,QACA,aACA,UACyB;CACzB,MAAM,kBAAkB,SACtB,SAAS,IAAI,OAAO;CACtB,IAAI,cAA4E;CAEhF,MAAM,sBACJ,QACA,YACA,aACA,cACA,YAC6E;EAC7E,MAAM,WAAW,yBACf,QACA,aACA,SACA,WAAW,YAAY,EACzB;EACA,IAAI;GACF,OAAO,CACL,UACA,YAAY,CAAC,cACT,IAAI,uBAAuB;IACzB,aAAa,QAAQ,eA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,aAAa,MAAM,mBAAmB,cAAc,IAAI;IAC1E,IAAI,CAAC,SACH,MAAM,mBAAmB,cAAc,YAAY,aAAa,cAAc,OAAO;GACzF,SAAS,OAAO;IACd,QAAQ;IACR,MAAM;GACR;GACA,OAAO;IAAE;IAAO,WAAW;IAAK,aAAa;IAAK;GAAQ;EAC5D;EACA,OAAO,QAAQ,cAAc,aAAa,QAAQ,YAAY,UAAU,SAAS,MAAM;GACrF,IAAI,OAAO,aAAa,kBAAkB,OAAO,aAAa,YAAY,QAAQ;QAC7E,UAAU,cAAc,aAAa,QAAQ,YAAY,UAAU,OAAO;GAC/E,IAAI,cAAc,OAAO,OAAO,KAAK,YAAY,OAAO,KAAK;QACxD,IAAI,YACP,mBAAmB,WAAW,UAAqC,cAAc,KAAK;GACxF,IAAI,aAAa,OAAO,WAAW,KAAK,WAAW,OAAO,SAAS;QAC9D,IAAI,WACP,mBAAmB,UAAU,UAAqC,cAAc,IAAI;EACxF;CACF;AACF"}
@@ -0,0 +1,2 @@
1
+ import type { setShapingContext } from './browserShaping.js';
2
+ export type ShapingContext = typeof setShapingContext;
@@ -0,0 +1,119 @@
1
+ import { isEmojiCandidate } from "./clusters.js";
2
+ // src/dom/fontCanvas.ts
3
+ var CANVAS_FONT_STRETCHES = [
4
+ ["ultra-condensed", 50],
5
+ ["extra-condensed", 62.5],
6
+ ["condensed", 75],
7
+ ["semi-condensed", 87.5],
8
+ ["normal", 100],
9
+ ["semi-expanded", 112.5],
10
+ ["expanded", 125],
11
+ ["extra-expanded", 150],
12
+ ["ultra-expanded", 200]
13
+ ];
14
+ function canvasFontStretch(value) {
15
+ if (value === "100%" || value === "normal") return "normal";
16
+ const percentage = Number.parseFloat(value);
17
+ if (!Number.isFinite(percentage)) return CANVAS_FONT_STRETCHES.find(([name]) => name === value)?.[0] ?? "normal";
18
+ return CANVAS_FONT_STRETCHES.reduce((a, b) => Math.abs(b[1] - percentage) < Math.abs(a[1] - percentage) ? b : a)[0];
19
+ }
20
+ /** @internal Shared atlas compatibility and raster candidacy rule. */
21
+ function isColorCandidate(request, mode = "emoji") {
22
+ if (request.shape) return request.shape.bitmap === true;
23
+ return mode === "all" || mode === "emoji" && isEmojiCandidate(request.character);
24
+ }
25
+ /** @internal The bake canvas's font state for a request, shared with the outline tracer. */
26
+ function setFontContext(context, request, shaping, lastFont) {
27
+ const { font } = request;
28
+ if (lastFont !== font) {
29
+ const extended = context;
30
+ context.font = font.canvasFont;
31
+ if (!lastFont) {
32
+ context.textAlign = "left";
33
+ context.textBaseline = "alphabetic";
34
+ }
35
+ if ("fontKerning" in extended) extended.fontKerning = font.kerning;
36
+ if ("fontStretch" in extended) extended.fontStretch = canvasFontStretch(font.stretch);
37
+ if ("fontVariantCaps" in extended) extended.fontVariantCaps = font.variant === "normal" ? "normal" : /\b(?:(?:all-)?(?:small|petite)-caps|unicase|titling-caps)\b/.exec(font.variant)?.[0] ?? "normal";
38
+ }
39
+ shaping?.(context, request);
40
+ return font;
41
+ }
42
+ /**
43
+ * The bake canvas. Font smoothing follows the canvas element's computed style, and only while
44
+ * the element is in a document: there it is turned off, in every engine, so a mask is the
45
+ * outline itself. Everything else a page would hand down (spacing, font features and
46
+ * variations, direction, language) is cut off, so the mask stays what a detached canvas draws.
47
+ * The caller takes it out of the document again.
48
+ * @internal Shared with the atlas append path and the outline tracer.
49
+ */
50
+ function createCanvas(document) {
51
+ const canvas = document.createElement("canvas");
52
+ canvas.width = 1;
53
+ canvas.height = 1;
54
+ canvas.style.cssText = "all:initial!important;display:none!important;direction:ltr!important;-webkit-font-smoothing:antialiased!important;-moz-osx-font-smoothing:grayscale!important;";
55
+ canvas.dir = "ltr";
56
+ canvas.lang = "";
57
+ document.documentElement.append(canvas);
58
+ return canvas;
59
+ }
60
+ /** @internal True when the document has a FontFaceSet whose registered faces are all loaded. */
61
+ function allFontsLoaded(document) {
62
+ const fonts = document.fonts;
63
+ if (fonts?.status !== "loaded") return false;
64
+ const faceSet = fonts;
65
+ if (typeof faceSet.load !== "function" || "mock" in faceSet.load || typeof faceSet.check !== "function" || "mock" in faceSet.check || typeof faceSet[Symbol.iterator] !== "function") return false;
66
+ for (const face of fonts) if (face.status !== "loaded") return false;
67
+ return true;
68
+ }
69
+ /** @internal Loads every face the text requests draw with; shared with the outline tracer. */
70
+ async function waitForFonts(document, requests, signal) {
71
+ if (signal?.aborted) throw signal.reason ?? new DOMException("The atlas build was aborted", "AbortError");
72
+ const fonts = document.fonts;
73
+ if (!fonts || allFontsLoaded(document)) return;
74
+ const byFont = /* @__PURE__ */ new Map();
75
+ for (const request of requests) {
76
+ if (request.shape) continue;
77
+ const current = byFont.get(request.font.key);
78
+ if (current) current.text += request.character;
79
+ else byFont.set(request.font.key, {
80
+ font: request.font.canvasFont,
81
+ text: request.character
82
+ });
83
+ }
84
+ const ok = fonts.status === "loaded" && !("mock" in fonts.load);
85
+ await Promise.all(Array.from(byFont.values(), (i) => {
86
+ try {
87
+ if (ok && fonts.check(i.font, i.text)) return;
88
+ } catch {}
89
+ return fonts.load(i.font, i.text);
90
+ }));
91
+ if (signal?.aborted) throw signal.reason ?? new DOMException("The atlas build was aborted", "AbortError");
92
+ }
93
+ var sharedOffscreenMeasure;
94
+ /** @internal True in real browsers with native OffscreenCanvas and unmocked Canvas2D getContext. */
95
+ function isNativeMeasureBrowser(document) {
96
+ const view = document.defaultView;
97
+ if (!view) return false;
98
+ const fonts = document.fonts;
99
+ if (!("CanvasRenderingContext2D" in view) || !("OffscreenCanvas" in view) || fonts?.status !== "loaded" || !Function.prototype.toString.call(view.OffscreenCanvas).includes("[native")) return false;
100
+ const getContextFn = Object.getOwnPropertyDescriptor(view.HTMLCanvasElement.prototype, "getContext")?.value;
101
+ return !(getContextFn && "mock" in getContextFn);
102
+ }
103
+ /** @internal Shared OffscreenCanvas measurement context (without `willReadFrequently`) when native. */
104
+ function createSharedMeasureContext(document) {
105
+ const view = document.defaultView;
106
+ if (view && isNativeMeasureBrowser(document)) {
107
+ if (sharedOffscreenMeasure === void 0) sharedOffscreenMeasure = new view.OffscreenCanvas(1, 1).getContext("2d");
108
+ if (sharedOffscreenMeasure) {
109
+ if ("letterSpacing" in sharedOffscreenMeasure) sharedOffscreenMeasure.letterSpacing = "0px";
110
+ sharedOffscreenMeasure.textAlign = "left";
111
+ sharedOffscreenMeasure.textBaseline = "alphabetic";
112
+ return sharedOffscreenMeasure;
113
+ }
114
+ }
115
+ return document.createElement("canvas").getContext("2d");
116
+ }
117
+ export { allFontsLoaded, createCanvas, createSharedMeasureContext, isColorCandidate, isNativeMeasureBrowser, setFontContext, waitForFonts };
118
+
119
+ //# sourceMappingURL=fontCanvas.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"fontCanvas.js","names":[],"sources":["../../src/dom/fontCanvas.ts"],"sourcesContent":["import type { ColorGlyphMode, GlyphRequest } from '../types.js'\nimport type { setShapingContext } from './browserShaping.js'\nimport { isEmojiCandidate } from './clusters.js'\n\nexport type ShapingContext = typeof setShapingContext\n\ninterface CanvasFontContext extends CanvasRenderingContext2D {\n fontKerning: CanvasFontKerning\n fontStretch: CanvasFontStretch\n fontVariantCaps: CanvasFontVariantCaps\n letterSpacing: string\n wordSpacing: string\n}\n\nconst CANVAS_FONT_STRETCHES = [\n ['ultra-condensed', 50],\n ['extra-condensed', 62.5],\n ['condensed', 75],\n ['semi-condensed', 87.5],\n ['normal', 100],\n ['semi-expanded', 112.5],\n ['expanded', 125],\n ['extra-expanded', 150],\n ['ultra-expanded', 200],\n] as const satisfies readonly (readonly [CanvasFontStretch, number])[]\n\nfunction canvasFontStretch(value: string): CanvasFontStretch {\n if (value === '100%' || value === 'normal') return 'normal'\n const percentage = Number.parseFloat(value)\n if (!Number.isFinite(percentage)) {\n return CANVAS_FONT_STRETCHES.find(([name]) => name === value)?.[0] ?? 'normal'\n }\n return CANVAS_FONT_STRETCHES.reduce((a, b) =>\n Math.abs(b[1] - percentage) < Math.abs(a[1] - percentage) ? b : a,\n )[0]\n}\n\n/** @internal Shared atlas compatibility and raster candidacy rule. */\nexport function isColorCandidate(request: GlyphRequest, mode: ColorGlyphMode = 'emoji'): boolean {\n if (request.shape) return request.shape.bitmap === true\n return mode === 'all' || (mode === 'emoji' && isEmojiCandidate(request.character))\n}\n\n/** @internal The bake canvas's font state for a request, shared with the outline tracer. */\nexport function setFontContext(\n context: CanvasRenderingContext2D,\n request: GlyphRequest,\n shaping: ShapingContext | undefined,\n lastFont: GlyphRequest['font'] | null,\n): GlyphRequest['font'] {\n const { font } = request\n if (lastFont !== font) {\n const extended: CanvasFontContext = context\n context.font = font.canvasFont\n if (!lastFont) {\n context.textAlign = 'left'\n context.textBaseline = 'alphabetic'\n }\n if ('fontKerning' in extended) extended.fontKerning = font.kerning as CanvasFontKerning\n if ('fontStretch' in extended) extended.fontStretch = canvasFontStretch(font.stretch)\n if ('fontVariantCaps' in extended)\n extended.fontVariantCaps =\n font.variant === 'normal'\n ? 'normal'\n : ((/\\b(?:(?:all-)?(?:small|petite)-caps|unicase|titling-caps)\\b/.exec(\n font.variant,\n )?.[0] ?? 'normal') as CanvasFontVariantCaps)\n }\n shaping?.(context, request)\n return font\n}\n\n/**\n * The bake canvas. Font smoothing follows the canvas element's computed style, and only while\n * the element is in a document: there it is turned off, in every engine, so a mask is the\n * outline itself. Everything else a page would hand down (spacing, font features and\n * variations, direction, language) is cut off, so the mask stays what a detached canvas draws.\n * The caller takes it out of the document again.\n * @internal Shared with the atlas append path and the outline tracer.\n */\nexport function createCanvas(document: Document): HTMLCanvasElement {\n const canvas = document.createElement('canvas')\n canvas.width = 1\n canvas.height = 1\n canvas.style.cssText =\n 'all:initial!important;display:none!important;direction:ltr!important;-webkit-font-smoothing:antialiased!important;-moz-osx-font-smoothing:grayscale!important;'\n canvas.dir = 'ltr'\n canvas.lang = ''\n document.documentElement.append(canvas)\n return canvas\n}\n\n/** @internal True when the document has a FontFaceSet whose registered faces are all loaded. */\nexport function allFontsLoaded(document: Document): boolean {\n const fonts = document.fonts as FontFaceSet | undefined\n if (fonts?.status !== 'loaded') return false\n const faceSet = fonts as {\n load?: unknown\n check?: unknown\n [Symbol.iterator]?: unknown\n }\n if (\n typeof faceSet.load !== 'function' ||\n 'mock' in faceSet.load ||\n typeof faceSet.check !== 'function' ||\n 'mock' in faceSet.check ||\n typeof faceSet[Symbol.iterator] !== 'function'\n ) {\n return false\n }\n for (const face of fonts as Iterable<FontFace>) {\n if (face.status !== 'loaded') return false\n }\n return true\n}\n\n/** @internal Loads every face the text requests draw with; shared with the outline tracer. */\nexport async function waitForFonts(\n document: Document,\n requests: readonly GlyphRequest[],\n signal?: AbortSignal,\n): Promise<void> {\n if (signal?.aborted) {\n throw signal.reason ?? new DOMException('The atlas build was aborted', 'AbortError')\n }\n const fonts = document.fonts as FontFaceSet | undefined\n if (!fonts || allFontsLoaded(document)) return\n const byFont = new Map<string, { font: string; text: string }>()\n for (const request of requests) {\n if (request.shape) continue\n const current = byFont.get(request.font.key)\n if (current) current.text += request.character\n else byFont.set(request.font.key, { font: request.font.canvasFont, text: request.character })\n }\n const ok = fonts.status === 'loaded' && !('mock' in (fonts as { load: object }).load)\n await Promise.all(\n Array.from(byFont.values(), (i) => {\n try {\n if (ok && fonts.check(i.font, i.text)) return\n } catch {\n // Load below when check rejects an uncommon font shorthand.\n }\n return fonts.load(i.font, i.text)\n }) as Promise<unknown>[],\n )\n if (signal?.aborted) {\n throw signal.reason ?? new DOMException('The atlas build was aborted', 'AbortError')\n }\n}\n\nlet sharedOffscreenMeasure: OffscreenCanvasRenderingContext2D | null | undefined\n\n/** @internal True in real browsers with native OffscreenCanvas and unmocked Canvas2D getContext. */\nexport function isNativeMeasureBrowser(document: Document): boolean {\n const view = document.defaultView\n if (!view) return false\n const fonts = document.fonts as FontFaceSet | undefined\n if (\n !('CanvasRenderingContext2D' in view) ||\n !('OffscreenCanvas' in view) ||\n fonts?.status !== 'loaded' ||\n !Function.prototype.toString.call(view.OffscreenCanvas).includes('[native')\n ) {\n return false\n }\n const getContextFn = Object.getOwnPropertyDescriptor(\n view.HTMLCanvasElement.prototype,\n 'getContext',\n )?.value as object | undefined\n return !(getContextFn && 'mock' in getContextFn)\n}\n\n/** @internal Shared OffscreenCanvas measurement context (without `willReadFrequently`) when native. */\nexport function createSharedMeasureContext(document: Document): CanvasRenderingContext2D | null {\n const view = document.defaultView\n if (view && isNativeMeasureBrowser(document)) {\n if (sharedOffscreenMeasure === undefined) {\n sharedOffscreenMeasure = new (\n view as Window & { OffscreenCanvas: typeof OffscreenCanvas }\n ).OffscreenCanvas(1, 1).getContext('2d')\n }\n if (sharedOffscreenMeasure) {\n if ('letterSpacing' in sharedOffscreenMeasure) sharedOffscreenMeasure.letterSpacing = '0px'\n sharedOffscreenMeasure.textAlign = 'left'\n sharedOffscreenMeasure.textBaseline = 'alphabetic'\n return sharedOffscreenMeasure as unknown as CanvasRenderingContext2D\n }\n }\n return document.createElement('canvas').getContext('2d')\n}\n"],"mappings":";;AAcA,IAAM,wBAAwB;CAC5B,CAAC,mBAAmB,EAAE;CACtB,CAAC,mBAAmB,IAAI;CACxB,CAAC,aAAa,EAAE;CAChB,CAAC,kBAAkB,IAAI;CACvB,CAAC,UAAU,GAAG;CACd,CAAC,iBAAiB,KAAK;CACvB,CAAC,YAAY,GAAG;CAChB,CAAC,kBAAkB,GAAG;CACtB,CAAC,kBAAkB,GAAG;AACxB;AAEA,SAAS,kBAAkB,OAAkC;CAC3D,IAAI,UAAU,UAAU,UAAU,UAAU,OAAO;CACnD,MAAM,aAAa,OAAO,WAAW,KAAK;CAC1C,IAAI,CAAC,OAAO,SAAS,UAAU,GAC7B,OAAO,sBAAsB,MAAM,CAAC,UAAU,SAAS,KAAK,CAAC,GAAG,MAAM;CAExE,OAAO,sBAAsB,QAAQ,GAAG,MACtC,KAAK,IAAI,EAAE,KAAK,UAAU,IAAI,KAAK,IAAI,EAAE,KAAK,UAAU,IAAI,IAAI,CAClE,CAAC,CAAC;AACJ;;AAGA,SAAgB,iBAAiB,SAAuB,OAAuB,SAAkB;CAC/F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AW,IAAI;EAEzC,IAAI,wBAAwB;GAC1B,IAAI,mBAAmB,wBAAwB,uBAAuB,gBAAgB;GACtF,uBAAuB,YAAY;GACnC,uBAAuB,eAAe;GACtC,OAAO;EACT;CACF;CACA,OAAO,SAAS,cAAc,QAAQ,CAAC,CAAC,WAAW,IAAI;AACzD"}
@@ -30,16 +30,27 @@ function push(value) {
30
30
  words[count++] = value;
31
31
  }
32
32
  function walkString(value) {
33
- const id = strings.get(value);
33
+ let id = strings.get(value);
34
34
  if (id === void 0) {
35
- strings.set(value, strings.size);
36
- push(STRING);
37
- push(value.length);
38
- for (let index = 0; index < value.length; index++) push(value.charCodeAt(index));
35
+ id = strings.size;
36
+ strings.set(value, id);
37
+ const len = value.length;
38
+ if (len < 128) {
39
+ if (count + 2 + len > WORDS) flush();
40
+ words[count++] = STRING;
41
+ words[count++] = len;
42
+ for (let index = 0; index < len; index++) words[count++] = value.charCodeAt(index);
43
+ } else {
44
+ push(STRING);
45
+ push(len);
46
+ for (let index = 0; index < len; index++) push(value.charCodeAt(index));
47
+ }
39
48
  } else {
40
- push(STRING_ID);
41
- push(id);
49
+ if (count > 2046) flush();
50
+ words[count++] = STRING_ID;
51
+ words[count++] = id;
42
52
  }
53
+ return id;
43
54
  }
44
55
  function walk(value) {
45
56
  if (typeof value === "number") {
@@ -70,12 +81,75 @@ function layoutSignatureOf(snapshot) {
70
81
  strings.clear();
71
82
  const glyphs = snapshot.glyphs;
72
83
  push(glyphs.length);
84
+ let prevKey;
85
+ let prevKeyId = -1;
86
+ let prevClip;
87
+ let pClip0 = 0;
88
+ let pClip1 = 0;
89
+ let pClip2 = 0;
90
+ let pClip3 = 0;
91
+ let prevColor;
92
+ let pColor0 = 0;
93
+ let pColor1 = 0;
94
+ let pColor2 = 0;
95
+ let pColor3 = 0;
73
96
  for (let index = 0, length = glyphs.length; index < length; index++) {
74
97
  const g = glyphs[index];
75
98
  const { clip, color } = g;
76
- walkString(g.glyphKey);
77
- walkString(g.breakBefore);
78
- if (count > 2024) flush();
99
+ const glyphKey = g.glyphKey;
100
+ if (glyphKey === prevKey) {
101
+ if (count > 2046) flush();
102
+ words[count++] = STRING_ID;
103
+ words[count++] = prevKeyId;
104
+ } else prevKeyId = walkString(prevKey = glyphKey);
105
+ let sameClip = index > 0 && clip === prevClip;
106
+ let c0 = 0;
107
+ let c1 = 0;
108
+ let c2 = 0;
109
+ let c3 = 0;
110
+ if (!sameClip) {
111
+ c0 = clip[0] + 0;
112
+ c1 = clip[1] + 0;
113
+ c2 = clip[2] + 0;
114
+ c3 = clip[3] + 0;
115
+ sameClip = index > 0 && c0 === pClip0 && c1 === pClip1 && c2 === pClip2 && c3 === pClip3;
116
+ }
117
+ let sameColor = index > 0 && color === prevColor;
118
+ let col0 = 0;
119
+ let col1 = 0;
120
+ let col2 = 0;
121
+ let col3 = 0;
122
+ if (!sameColor) {
123
+ col0 = color[0] + 0;
124
+ col1 = color[1] + 0;
125
+ col2 = color[2] + 0;
126
+ col3 = color[3] + 0;
127
+ sameColor = index > 0 && col0 === pColor0 && col1 === pColor1 && col2 === pColor2 && col3 === pColor3;
128
+ }
129
+ const breakBefore = g.breakBefore;
130
+ let flags = breakBefore === "none" ? 0 : breakBefore === "soft" ? 1 : breakBefore === "hard" ? 2 : 3;
131
+ if (sameClip) flags |= 4;
132
+ if (sameColor) flags |= 8;
133
+ const shapeGroup = g.shapeGroup;
134
+ const decorationWidth = g.decorationWidth;
135
+ const baselineOffset = g.baselineOffset;
136
+ const switchEm = g.switchEm;
137
+ const gapBefore = g.gapBefore;
138
+ const decorations = g.decorations;
139
+ const snap = g.snap;
140
+ const motionOrigin = g.motionOrigin;
141
+ if (shapeGroup !== void 0) flags |= 16;
142
+ if (decorationWidth !== void 0) flags |= 32;
143
+ if (baselineOffset !== void 0) flags |= 64;
144
+ if (switchEm !== void 0) flags |= 128;
145
+ if (gapBefore !== void 0) flags |= 256;
146
+ if (decorations !== void 0) flags |= 512;
147
+ if (snap !== void 0) flags |= 1024;
148
+ if (motionOrigin !== void 0) flags |= 2048;
149
+ if (count === WORDS) flush();
150
+ words[count++] = flags;
151
+ if ((flags & 3) === 3) walkString(breakBefore);
152
+ if (count > 2022) flush();
79
153
  words[count++] = g.fontSize + 0;
80
154
  words[count++] = g.originX + 0;
81
155
  words[count++] = g.lineBottom + 0;
@@ -83,25 +157,80 @@ function layoutSignatureOf(snapshot) {
83
157
  words[count++] = g.block + 0;
84
158
  words[count++] = g.sequence + 0;
85
159
  words[count++] = g.z + 0;
86
- words[count++] = clip[0] + 0;
87
- words[count++] = clip[1] + 0;
88
- words[count++] = clip[2] + 0;
89
- words[count++] = clip[3] + 0;
90
- words[count++] = color[0] + 0;
91
- words[count++] = color[1] + 0;
92
- words[count++] = color[2] + 0;
93
- words[count++] = color[3] + 0;
94
- words[count++] = (g.shapeGroup ?? OTHER) + 0;
95
- words[count++] = (g.decorationWidth ?? OTHER) + 0;
96
- words[count++] = (g.baselineOffset ?? OTHER) + 0;
97
- words[count++] = (g.switchEm ?? OTHER) + 0;
98
- words[count++] = (g.gapBefore ?? OTHER) + 0;
99
- if (g.decorations) walk(g.decorations);
100
- if (g.snap) walk(g.snap);
101
- if (g.motionOrigin) walk(g.motionOrigin);
160
+ if (!sameClip) {
161
+ words[count++] = pClip0 = c0;
162
+ words[count++] = pClip1 = c1;
163
+ words[count++] = pClip2 = c2;
164
+ words[count++] = pClip3 = c3;
165
+ prevClip = clip;
166
+ }
167
+ if (!sameColor) {
168
+ words[count++] = pColor0 = col0;
169
+ words[count++] = pColor1 = col1;
170
+ words[count++] = pColor2 = col2;
171
+ words[count++] = pColor3 = col3;
172
+ prevColor = color;
173
+ }
174
+ if (shapeGroup !== void 0) words[count++] = shapeGroup + 0;
175
+ if (decorationWidth !== void 0) words[count++] = decorationWidth + 0;
176
+ if (baselineOffset !== void 0) words[count++] = baselineOffset + 0;
177
+ if (switchEm !== void 0) words[count++] = switchEm + 0;
178
+ if (gapBefore !== void 0) words[count++] = gapBefore + 0;
179
+ if (snap !== void 0) {
180
+ words[count++] = snap[0] + 0;
181
+ words[count++] = snap[1] + 0;
182
+ }
183
+ if (motionOrigin !== void 0) {
184
+ words[count++] = motionOrigin[0] + 0;
185
+ words[count++] = motionOrigin[1] + 0;
186
+ words[count++] = motionOrigin[2] + 0;
187
+ }
188
+ if (decorations !== void 0) walk(decorations);
189
+ }
190
+ const blocks = snapshot.blocks;
191
+ push(blocks.length);
192
+ for (let index = 0, length = blocks.length; index < length; index++) {
193
+ const b = blocks[index];
194
+ const bClip = b.clip;
195
+ if (count > 2038) flush();
196
+ words[count++] = b.left + 0;
197
+ words[count++] = b.firstBaseline + 0;
198
+ words[count++] = b.linePitch + 0;
199
+ words[count++] = b.width + 0;
200
+ words[count++] = bClip[0] + 0;
201
+ words[count++] = bClip[1] + 0;
202
+ words[count++] = bClip[2] + 0;
203
+ words[count++] = bClip[3] + 0;
204
+ let bFlags = 0;
205
+ if (b.direction !== void 0) bFlags |= 1;
206
+ if (b.textAlign !== void 0) bFlags |= 2;
207
+ if (b.textAlignLast !== void 0) bFlags |= 4;
208
+ words[count++] = bFlags;
209
+ if (b.direction !== void 0) walkString(b.direction);
210
+ if (b.textAlign !== void 0) walkString(b.textAlign);
211
+ if (b.textAlignLast !== void 0) walkString(b.textAlignLast);
212
+ }
213
+ const rects = snapshot.rects;
214
+ push(rects.length);
215
+ for (let index = 0, length = rects.length; index < length; index++) {
216
+ const r = rects[index];
217
+ const rr = r.rect;
218
+ const rc = r.color;
219
+ if (count > 2036) flush();
220
+ words[count++] = rr[0] + 0;
221
+ words[count++] = rr[1] + 0;
222
+ words[count++] = rr[2] + 0;
223
+ words[count++] = rr[3] + 0;
224
+ words[count++] = rc[0] + 0;
225
+ words[count++] = rc[1] + 0;
226
+ words[count++] = rc[2] + 0;
227
+ words[count++] = rc[3] + 0;
228
+ words[count++] = r.radius + 0;
229
+ words[count++] = r.z + 0;
230
+ words[count++] = r.receiveShadow ? TRUE : FALSE;
102
231
  }
103
232
  const root = snapshot;
104
- for (const key in root) if (key !== "requests" && key !== "glyphs" && Object.hasOwn(root, key)) walk(root[key]);
233
+ for (const key in root) if (key !== "requests" && key !== "glyphs" && key !== "blocks" && key !== "rects" && Object.hasOwn(root, key)) walk(root[key]);
105
234
  flush();
106
235
  strings.clear();
107
236
  return `${h1}:${h2}`;
@@ -1 +1 @@
1
- {"version":3,"file":"layoutSignature.js","names":[],"sources":["../../src/dom/layoutSignature.ts"],"sourcesContent":["import type { DomLayoutSnapshot } from '../types.js'\n\n// The walk below writes the capture's values as float64 words into this small buffer, which\n// is hashed in one tight loop whenever it fills: about 2.5 times faster than mixing each value\n// through a closure, and nothing larger than these 16 KB stays allocated.\nconst WORDS = 2048\nconst words = new Float64Array(WORDS)\nconst bits = new Int32Array(words.buffer)\nconst strings = new Map<string, number>()\nlet count = 0\nlet h1 = 0\nlet h2 = 0\n\n// Markers for what is not a number; values this large never occur in a capture.\nconst STRING = -1e300\nconst STRING_ID = -2e300\nconst TRUE = -3e300\nconst FALSE = -4e300\nconst OPEN = -5e300\nconst CLOSE = -6e300\nconst OTHER = -7e300\n\nfunction flush(): void {\n let a = h1\n let b = h2\n for (let index = 0, end = count * 2; index < end; index++) {\n const value = bits[index]!\n a = Math.imul(a ^ value, 16777619)\n b = Math.imul(b ^ value, 1597334677)\n }\n h1 = a\n h2 = b\n count = 0\n}\n\nfunction push(value: number): void {\n if (count === WORDS) flush()\n words[count++] = value\n}\n\nfunction walkString(value: string): void {\n const id = strings.get(value)\n if (id === undefined) {\n strings.set(value, strings.size)\n push(STRING)\n push(value.length)\n for (let index = 0; index < value.length; index++) push(value.charCodeAt(index))\n } else {\n push(STRING_ID)\n push(id)\n }\n}\n\nfunction walk(value: unknown): void {\n // `+ 0` folds -0 into 0: both lay out the same.\n if (typeof value === 'number') {\n if (count === WORDS) flush()\n words[count++] = value + 0\n } else if (typeof value === 'string') walkString(value)\n else if (typeof value === 'boolean') push(value ? TRUE : FALSE)\n else if (typeof value === 'object' && value !== null) {\n push(OPEN)\n // Capture records have a fixed schema and stable declaration order.\n // Field names are identical across captures; only their values matter.\n if (Array.isArray(value)) {\n const length = value.length\n if (length > 0 && typeof value[0] === 'number') {\n if (count + length > WORDS) flush()\n for (let index = 0; index < length; index++) words[count++] = (value[index] as number) + 0\n } else {\n for (let index = 0; index < length; index++) walk(value[index])\n }\n } else {\n const record = value as Record<string, unknown>\n for (const key in record) {\n if (Object.hasOwn(record, key)) walk(record[key])\n }\n }\n push(CLOSE)\n } else push(OTHER)\n}\n\n/** Hash the capture directly, without allocating its much larger JSON string. */\nexport function layoutSignatureOf(snapshot: DomLayoutSnapshot): string {\n h1 = 0x811c9dc5\n h2 = 0x811c9dc5 ^ 0x5bd1e995\n count = 0\n strings.clear()\n const glyphs = snapshot.glyphs\n push(glyphs.length)\n for (let index = 0, length = glyphs.length; index < length; index++) {\n const g = glyphs[index]!\n const { clip, color } = g\n walkString(g.glyphKey)\n walkString(g.breakBefore)\n if (count > WORDS - 24) flush()\n words[count++] = g.fontSize + 0\n words[count++] = g.originX + 0\n words[count++] = g.lineBottom + 0\n words[count++] = g.advance + 0\n words[count++] = g.block + 0\n words[count++] = g.sequence + 0\n words[count++] = g.z + 0\n words[count++] = clip[0] + 0\n words[count++] = clip[1] + 0\n words[count++] = clip[2] + 0\n words[count++] = clip[3] + 0\n words[count++] = color[0] + 0\n words[count++] = color[1] + 0\n words[count++] = color[2] + 0\n words[count++] = color[3] + 0\n words[count++] = (g.shapeGroup ?? OTHER) + 0\n words[count++] = (g.decorationWidth ?? OTHER) + 0\n words[count++] = (g.baselineOffset ?? OTHER) + 0\n words[count++] = (g.switchEm ?? OTHER) + 0\n words[count++] = (g.gapBefore ?? OTHER) + 0\n if (g.decorations) walk(g.decorations)\n if (g.snap) walk(g.snap)\n if (g.motionOrigin) walk(g.motionOrigin)\n }\n // Requests select retained glyph data separately through atlasSignature.\n const root = snapshot as unknown as Record<string, unknown>\n for (const key in root) {\n if (key !== 'requests' && key !== 'glyphs' && Object.h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AW,KAAK,KAAK;EAC3B,MAAM,WAAW,MAAM,KAAK;EAC5B,MAAM,WAAW,MAAM,KAAK;EAC5B,MAAM,WAAW,MAAM,KAAK;EAC5B,MAAM,WAAW,MAAM,KAAK;EAC5B,MAAM,YAAY,EAAE,cAAc,SAAS;EAC3C,MAAM,YAAY,EAAE,mBAAmB,SAAS;EAChD,MAAM,YAAY,EAAE,kBAAkB,SAAS;EAC/C,MAAM,YAAY,EAAE,YAAY,SAAS;EACzC,MAAM,YAAY,EAAE,aAAa,SAAS;EAC1C,IAAI,EAAE,aAAa,KAAK,EAAE,WAAW;EACrC,IAAI,EAAE,MAAM,KAAK,EAAE,IAAI;EACvB,IAAI,EAAE,cAAc,KAAK,EAAE,YAAY;CACzC;CAEA,MAAM,OAAO;CACb,KAAK,MAAM,OAAO,MAChB,IAAI,QAAQ,cAAc,QAAQ,YAAY,OAAO,OAAO,MAAM,GAAG,GAAG,KAAK,KAAK,IAAI;CAExF,MAAM;CACN,QAAQ,MAAM;CACd,OAAO,GAAG,GAAG,GAAG;AAClB"}
1
+ {"version":3,"file":"layoutSignature.js","names":[],"sources":["../../src/dom/layoutSignature.ts"],"sourcesContent":["import type { DomLayoutSnapshot } from '../types.js'\n\n// The walk below writes the capture's values as float64 words into this small buffer, which\n// is hashed in one tight loop whenever it fills: about 2.5 times faster than mixing each value\n// through a closure, and nothing larger than these 16 KB stays allocated.\nconst WORDS = 2048\nconst words = new Float64Array(WORDS)\nconst bits = new Int32Array(words.buffer)\nconst strings = new Map<string, number>()\nlet count = 0\nlet h1 = 0\nlet h2 = 0\n\n// Markers for what is not a number; values this large never occur in a capture.\nconst STRING = -1e300\nconst STRING_ID = -2e300\nconst TRUE = -3e300\nconst FALSE = -4e300\nconst OPEN = -5e300\nconst CLOSE = -6e300\nconst OTHER = -7e300\n\nfunction flush(): void {\n let a = h1\n let b = h2\n for (let index = 0, end = count * 2; index < end; index++) {\n const value = bits[index]!\n a = Math.imul(a ^ value, 16777619)\n b = Math.imul(b ^ value, 1597334677)\n }\n h1 = a\n h2 = b\n count = 0\n}\n\nfunction push(value: number): void {\n if (count === WORDS) flush()\n words[count++] = value\n}\n\nfunction walkString(value: string): number {\n let id = strings.get(value)\n if (id === undefined) {\n id = strings.size\n strings.set(value, id)\n const len = value.length\n if (len < 128) {\n if (count + 2 + len > WORDS) flush()\n words[count++] = STRING\n words[count++] = len\n for (let index = 0; index < len; index++) words[count++] = value.charCodeAt(index)\n } else {\n push(STRING)\n push(len)\n for (let index = 0; index < len; index++) push(value.charCodeAt(index))\n }\n } else {\n if (count > WORDS - 2) flush()\n words[count++] = STRING_ID\n words[count++] = id\n }\n return id\n}\n\nfunction walk(value: unknown): void {\n // `+ 0` folds -0 into 0: both lay out the same.\n if (typeof value === 'number') {\n if (count === WORDS) flush()\n words[count++] = value + 0\n } else if (typeof value === 'string') walkString(value)\n else if (typeof value === 'boolean') push(value ? TRUE : FALSE)\n else if (typeof value === 'object' && value !== null) {\n push(OPEN)\n // Capture records have a fixed schema and stable declaration order.\n // Field names are identical across captures; only their values matter.\n if (Array.isArray(value)) {\n const length = value.length\n if (length > 0 && typeof value[0] === 'number') {\n if (count + length > WORDS) flush()\n for (let index = 0; index < length; index++) words[count++] = (value[index] as number) + 0\n } else {\n for (let index = 0; index < length; index++) walk(value[index])\n }\n } else {\n const record = value as Record<string, unknown>\n for (const key in record) {\n if (Object.hasOwn(record, key)) walk(record[key])\n }\n }\n push(CLOSE)\n } else push(OTHER)\n}\n\n/** Hash the capture directly, without allocating its much larger JSON string. */\nexport function layoutSignatureOf(snapshot: DomLayoutSnapshot): string {\n h1 = 0x811c9dc5\n h2 = 0x811c9dc5 ^ 0x5bd1e995\n count = 0\n strings.clear()\n const glyphs = snapshot.glyphs\n push(glyphs.length)\n let prevKey: string | undefined\n let prevKeyId = -1\n let prevClip: readonly [number, number, number, number] | undefined\n let pClip0 = 0\n let pClip1 = 0\n let pClip2 = 0\n let pClip3 = 0\n let prevColor: readonly [number, number, number, number] | undefined\n let pColor0 = 0\n let pColor1 = 0\n let pColor2 = 0\n let pColor3 = 0\n for (let index = 0, length = glyphs.length; index < length; index++) {\n const g = glyphs[index]!\n const { clip, color } = g\n const glyphKey = g.glyphKey\n if (glyphKey === prevKey) {\n if (count > WORDS - 2) flush()\n words[count++] = STRING_ID\n words[count++] = prevKeyId\n } else {\n prevKeyId = walkString((prevKey = glyphKey))\n }\n let sameClip = index > 0 && clip === prevClip\n let c0 = 0\n let c1 = 0\n let c2 = 0\n let c3 = 0\n if (!sameClip) {\n c0 = clip[0] + 0\n c1 = clip[1] + 0\n c2 = clip[2] + 0\n c3 = clip[3] + 0\n sameClip = index > 0 && c0 === pClip0 && c1 === pClip1 && c2 === pClip2 && c3 === pClip3\n }\n let sameColor = index > 0 && color === prevColor\n let col0 = 0\n let col1 = 0\n let col2 = 0\n let col3 = 0\n if (!sameColor) {\n col0 = color[0] + 0\n col1 = color[1] + 0\n col2 = color[2] + 0\n col3 = color[3] + 0\n sameColor =\n index > 0 && col0 === pColor0 && col1 === pColor1 && col2 === pColor2 && col3 === pColor3\n }\n const breakBefore: string = g.breakBefore\n let flags =\n breakBefore === 'none' ? 0 : breakBefore === 'soft' ? 1 : breakBefore === 'hard' ? 2 : 3\n if (sameClip) flags |= 4\n if (sameColor) flags |= 8\n const shapeGroup = g.shapeGroup\n const decorationWidth = g.decorationWidth\n const baselineOffset = g.baselineOffset\n const switchEm = g.switchEm\n const gapBefore = g.gapBefore\n const decorations = g.decorations\n const snap = g.snap\n const motionOrigin = g.motionOrigin\n if (shapeGroup !== undefined) flags |= 16\n if (decorationWidth !== undefined) flags |= 32\n if (baselineOffset !== undefined) flags |= 64\n if (switchEm !== undefined) flags |= 128\n if (gapBefore !== undefined) flags |= 256\n if (decorations !== undefined) flags |= 512\n if (snap !== undefined) flags |= 1024\n if (motionOrigin !== undefined) flags |= 2048\n if (count === WORDS) flush()\n words[count++] = flags\n if ((flags & 3) === 3) walkString(breakBefore)\n if (count > WORDS - 26) flush()\n words[count++] = g.fontSize + 0\n words[count++] = g.originX + 0\n words[count++] = g.lineBottom + 0\n words[count++] = g.advance + 0\n words[count++] = g.block + 0\n words[count++] = g.sequence + 0\n words[count++] = g.z + 0\n if (!sameClip) {\n words[count++] = pClip0 = c0\n words[count++] = pClip1 = c1\n words[count++] = pClip2 = c2\n words[count++] = pClip3 = c3\n prevClip = clip\n }\n if (!sameColor) {\n words[count++] = pColor0 = col0\n words[count++] = pColor1 = col1\n words[count++] = pColor2 = col2\n words[count++] = pColor3 = col3\n prevColor = color\n }\n if (shapeGroup !== undefined) words[count++] = shapeGroup + 0\n if (decorationWidth !== undefined) words[count++] = decorationWidth + 0\n if (baselineOffset !== undefined) words[count++] = baselineOffset + 0\n if (switchEm !== undefined) words[count++] = switchEm + 0\n if (gapBefore !== undefined) words[count++] = gapBefore + 0\n if (snap !== undefined) {\n words[count++] = snap[0] + 0\n words[count++] = snap[1] + 0\n }\n if (motionOrigin !== undefined) {\n words[count++] = motionOrigin[0] + 0\n words[count++] = motionOrigin[1] + 0\n words[count++] = motionOrigin[2] + 0\n }\n if (decorations !== undefined) walk(decorations)\n }\n const blocks = snapshot.blocks\n push(blocks.length)\n for (let index = 0, length = blocks.length; index < length; index++) {\n const b = blocks[index]!\n const bClip = b.clip\n if (count > WORDS - 10) flush()\n words[count++] = b.left + 0\n words[count++] = b.firstBaseline + 0\n words[count++] = b.linePitch + 0\n words[count++] = b.width + 0\n words[count++] = bClip[0] + 0\n words[count++] = bClip[1] + 0\n words[count++] = bClip[2] + 0\n words[count++] = bClip[3] + 0\n let bFlags = 0\n if (b.direction !== undefined) bFlags |= 1\n if (b.textAlign !== undefined) bFlags |= 2\n if (b.textAlignLast !== undefined) bFlags |= 4\n words[count++] = bFlags\n if (b.direction !== undefined) walkString(b.direction)\n if (b.textAlign !== undefined) walkString(b.textAlign)\n if (b.textAlignLast !== undefined) walkString(b.textAlignLast)\n }\n const rects = snapshot.rects\n push(rects.length)\n for (let index = 0, length = rects.length; index < length; index++) {\n const r = rects[index]!\n const rr = r.rect\n const rc = r.color\n if (count > WORDS - 12) flush()\n words[count++] = rr[0] + 0\n words[count++] = rr[1] + 0\n words[count++] = rr[2] + 0\n words[count++] = rr[3] + 0\n words[count++] = rc[0] + 0\n words[count++] = rc[1] + 0\n words[count++] = rc[2] + 0\n words[count++] = rc[3] + 0\n words[count++] = r.radius + 0\n words[count++] = r.z + 0\n words[count++] = r.receiveShadow ? TRUE : FALSE\n }\n // Requests select retained glyph data separately through atlasSignature.\n const root = snapshot as unknown as Record<string, unknown>\n for (const key in root) {\n if (\n key !== 'requests' &&\n key !== 'glyphs' &&\n key !== 'blocks' &&\n key !== 'rects' &&\n Object.hasOwn(root, key)\n ) {\n walk(root[key])\n }\n }\n flush()\n strings.clear()\n return `${h1}:${h2}`\n}\n"],"mappings":";AAKA,IAAM,QAAQ;AACd,IAAM,QAAQ,IAAI,aAAa,KAAK;AACpC,IAAM,OAAO,IAAI,WAAW,MAAM,MAAM;AACxC,IAAM,0BAAU,IAAI,IAAoB;AACxC,IAAI,QAAQ;AACZ,IAAI,KAAK;AACT,IAAI,KAAK;AAGT,IAAM,SAAS;AACf,IAAM,YAAY;AAClB,IAAM,OAAO;AACb,IAAM,QAAQ;AACd,IAAM,OAAO;AACb,IAAM,QAAQ;AACd,IAAM,QAAQ;AAEd,SAAS,QAAc;CACrB,IAAI,IAAI;CACR,IAAI,IAAI;CACR,KAAK,IAAI,QAAQ,GAAG,MAAM,QAAQ,GAAG,QAAQ,KAAK,SAAS;EACzD,MAAM,QAAQ,KAAK;EACnB,IAAI,KAAK,KAAK,IAAI,OAAO,QAAQ;EACjC,IAAI,KAAK,KAAK,IAAI,OAAO,UAAU;CACrC;CACA,KAAK;CACL,KAAK;CACL,QAAQ;AACV;AAEA,SAAS,KAAK,OAAqB;CACjC,IAAI,UAAU,OAAO,MAAM;CAC3B,MAAM,WAAW;AACnB;AAEA,SAAS,WAAW,OAAuB;CACzC,IAAI,KAAK,QAAQ,IAAI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