ultra-text 1.0.0 → 1.0.1

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 (134) hide show
  1. package/README.md +168 -85
  2. package/THIRD_PARTY_NOTICES.md +3 -0
  3. package/dist/assets/{cpuSdf.worker-Du9o8q4p.js → cpuSdf.worker-xS57yQbP.js} +13 -11
  4. package/dist/assets/cpuSdf.worker-xS57yQbP.js.map +1 -0
  5. package/dist/atlas/appendAtlas.js +2 -1
  6. package/dist/atlas/appendAtlas.js.map +1 -1
  7. package/dist/atlas/buildAtlas.js +3 -14
  8. package/dist/atlas/buildAtlas.js.map +1 -1
  9. package/dist/atlas/cpuSdf.js +12 -10
  10. package/dist/atlas/cpuSdf.js.map +1 -1
  11. package/dist/atlas/cpuWorker.js +1 -1
  12. package/dist/atlas/cpuWorker.js.map +1 -1
  13. package/dist/atlas/gpuAtlas.d.ts +7 -6
  14. package/dist/atlas/gpuAtlas.js +280 -145
  15. package/dist/atlas/gpuAtlas.js.map +1 -1
  16. package/dist/atlas/jfaWgsl.js +201 -73
  17. package/dist/atlas/jfaWgsl.js.map +1 -1
  18. package/dist/atlas/rasterize.d.ts +2 -0
  19. package/dist/atlas/rasterize.js +2 -87
  20. package/dist/atlas/rasterize.js.map +1 -1
  21. package/dist/dom/DomSdf.js +66 -15
  22. package/dist/dom/DomSdf.js.map +1 -1
  23. package/dist/dom/DomSlug.d.ts +26 -0
  24. package/dist/dom/DomSlug.js +640 -0
  25. package/dist/dom/DomSlug.js.map +1 -0
  26. package/dist/dom/SlugText.d.ts +18 -0
  27. package/dist/dom/SlugText.js +94 -0
  28. package/dist/dom/SlugText.js.map +1 -0
  29. package/dist/dom/Text.js +4 -67
  30. package/dist/dom/Text.js.map +1 -1
  31. package/dist/dom/fontCanvas.d.ts +2 -0
  32. package/dist/dom/fontCanvas.js +101 -0
  33. package/dist/dom/fontCanvas.js.map +1 -0
  34. package/dist/dom/layoutSignature.js +29 -2
  35. package/dist/dom/layoutSignature.js.map +1 -1
  36. package/dist/dom/snapshot.js +251 -96
  37. package/dist/dom/snapshot.js.map +1 -1
  38. package/dist/dom/textHost.d.ts +11 -0
  39. package/dist/dom/textHost.js +68 -0
  40. package/dist/dom/textHost.js.map +1 -0
  41. package/dist/slug/SlugMaterial.d.ts +3 -2
  42. package/dist/slug/SlugMaterial.js +28 -2
  43. package/dist/slug/SlugMaterial.js.map +1 -1
  44. package/dist/slug/coverage.d.ts +1 -1
  45. package/dist/slug/coverage.js +1 -1
  46. package/dist/slug/coverage.js.map +1 -1
  47. package/dist/slug/preprocessCore.d.ts +1 -2
  48. package/dist/slug/preprocessCore.js +39 -16
  49. package/dist/slug/preprocessCore.js.map +1 -1
  50. package/dist/slug/runtime.js +6 -4
  51. package/dist/slug/runtime.js.map +1 -1
  52. package/dist/slug/standaloneRuntime.d.ts +39 -0
  53. package/dist/slug/standaloneRuntime.js +140 -0
  54. package/dist/slug/standaloneRuntime.js.map +1 -0
  55. package/dist/slug/truetype.d.ts +22 -0
  56. package/dist/slug/truetype.js +494 -0
  57. package/dist/slug/truetype.js.map +1 -0
  58. package/dist/slug-vanilla.d.ts +364 -0
  59. package/dist/slug-vanilla.js +1461 -0
  60. package/dist/slug-vanilla.js.map +1 -0
  61. package/dist/slug.d.ts +21 -0
  62. package/dist/slug.js +19 -0
  63. package/dist/text/GlyphTextMaterial.d.ts +11 -11
  64. package/dist/text/GlyphTextMaterial.js +98 -29
  65. package/dist/text/GlyphTextMaterial.js.map +1 -1
  66. package/dist/text/SdfTextMaterial.d.ts +5 -4
  67. package/dist/text/SdfTextMaterial.js +22 -4
  68. package/dist/text/SdfTextMaterial.js.map +1 -1
  69. package/dist/types.d.ts +63 -14
  70. package/dist/vanilla.d.ts +3 -0
  71. package/dist/vanilla.js +132 -59
  72. package/dist/vanilla.js.map +1 -1
  73. package/dist/windfoil/WindfoilMaterial.d.ts +2 -1
  74. package/dist/windfoil/WindfoilMaterial.js +8 -1
  75. package/dist/windfoil/WindfoilMaterial.js.map +1 -1
  76. package/dist/windfoil/abortable.d.ts +2 -0
  77. package/dist/windfoil/abortable.js +26 -0
  78. package/dist/windfoil/abortable.js.map +1 -0
  79. package/dist/windfoil/color.js +2 -1
  80. package/dist/windfoil/color.js.map +1 -1
  81. package/dist/windfoil/coverage.d.ts +3 -20
  82. package/dist/windfoil/coverage.js +7 -20
  83. package/dist/windfoil/coverage.js.map +1 -1
  84. package/dist/windfoil/emoji.js +1 -1
  85. package/dist/windfoil/emoji.js.map +1 -1
  86. package/dist/windfoil/emojiMetrics.js +1 -1
  87. package/dist/windfoil/emojiMetrics.js.map +1 -1
  88. package/dist/windfoil/geometry.js +100 -33
  89. package/dist/windfoil/geometry.js.map +1 -1
  90. package/dist/windfoil/layerGrid.js +14 -10
  91. package/dist/windfoil/layerGrid.js.map +1 -1
  92. package/dist/windfoil/layerNormalization.d.ts +1 -1
  93. package/dist/windfoil/layerNormalization.js +1 -1
  94. package/dist/windfoil/layerNormalization.js.map +1 -1
  95. package/dist/windfoil/outlineValidation.d.ts +86 -0
  96. package/dist/windfoil/outlineValidation.js +65 -0
  97. package/dist/windfoil/outlineValidation.js.map +1 -0
  98. package/dist/windfoil/preprocess.js +3 -2
  99. package/dist/windfoil/preprocess.js.map +1 -1
  100. package/dist/windfoil/preprocessCore.d.ts +4 -85
  101. package/dist/windfoil/preprocessCore.js +210 -206
  102. package/dist/windfoil/preprocessCore.js.map +1 -1
  103. package/dist/windfoil/requests.js +1 -1
  104. package/dist/windfoil/requests.js.map +1 -1
  105. package/dist/windfoil/runtime.d.ts +2 -1
  106. package/dist/windfoil/runtime.js +3 -2
  107. package/dist/windfoil/runtime.js.map +1 -1
  108. package/dist/windfoil/shapeResources.js +2 -1
  109. package/dist/windfoil/shapeResources.js.map +1 -1
  110. package/dist/windfoil/shapes.js +1 -1
  111. package/dist/windfoil/skirt.d.ts +22 -0
  112. package/dist/windfoil/skirt.js +20 -0
  113. package/dist/windfoil/skirt.js.map +1 -0
  114. package/dist/windfoil/storage.d.ts +2 -2
  115. package/dist/windfoil/storage.js +1 -22
  116. package/dist/windfoil/storage.js.map +1 -1
  117. package/dist/windfoil/trace/contours.d.ts +0 -5
  118. package/dist/windfoil/trace/contours.js +81 -114
  119. package/dist/windfoil/trace/contours.js.map +1 -1
  120. package/dist/windfoil/trace/fit.d.ts +0 -6
  121. package/dist/windfoil/trace/fit.js +304 -308
  122. package/dist/windfoil/trace/fit.js.map +1 -1
  123. package/dist/windfoil/trace/outline.js +10 -10
  124. package/dist/windfoil/trace/outline.js.map +1 -1
  125. package/dist/windfoil/trace/types.d.ts +5 -3
  126. package/dist/windfoil/tracedOutlines.d.ts +37 -1
  127. package/dist/windfoil/tracedOutlines.js +172 -33
  128. package/dist/windfoil/tracedOutlines.js.map +1 -1
  129. package/package.json +57 -8
  130. package/skills/ultra-text/SKILL.md +114 -0
  131. package/skills/ultra-text/references/frameworks.md +43 -0
  132. package/skills/ultra-text/references/three-tsl.md +78 -0
  133. package/skills/ultra-text/references/vanilla-webgpu.md +95 -0
  134. package/dist/assets/cpuSdf.worker-Du9o8q4p.js.map +0 -1
@@ -1 +1 @@
1
- {"version":3,"file":"DomSdf.js","names":[],"sources":["../../src/dom/DomSdf.ts"],"sourcesContent":["import { Group, Mesh, type InstancedBufferGeometry, type WebGPURenderer } from 'three/webgpu'\n\nimport type * as AppendAtlas from '../atlas/appendAtlas.js'\nimport { buildSdfAtlas } from '../atlas/buildAtlas.js'\nimport { prepareAtlasPasses } from '../atlas/gpuAtlas.js'\nimport { isColorCandidate, rasterizeGlyphAtlas, type RasterizeOptions } from '../atlas/rasterize.js'\nimport { createRectMaterial } from '../text/RectMaterial.js'\nimport { isAnimatedMotion, type GlyphTextMaterial } from '../text/GlyphTextMaterial.js'\nimport { SdfTextMaterial } from '../text/SdfTextMaterial.js'\nimport {\n createGlyphGeometry,\n createRectGeometry,\n glyphContentFits,\n needsRunMotion,\n rectContentFits,\n updateGlyphContent,\n updateGlyphGeometry,\n updateRectGeometry,\n} from '../text/geometry.js'\nimport { reflowSnapshot } from '../text/reflow.js'\nimport {\n canUpdateDecorationGeometry,\n createDecorationGeometry,\n TextDecorationMaterial,\n updateDecorationGeometry,\n} from '../text/decorations.js'\nimport type { ResolvedTextTone } from '../text/tone.js'\nimport type {\n DomLayoutSnapshot,\n DomSdfOptions,\n DomSdfStats,\n SdfAtlas,\n SdfMotionOptions,\n} from '../types.js'\nimport type { createExtraTextParts } from '../windfoil/mixed.js'\nimport type { WindfoilBackend, WindfoilBuildOptions } from '../windfoil/runtime.js'\nimport type { TracedOutlines } from '../windfoil/tracedOutlines.js'\nimport { DEFAULT_RECT_SELECTOR } from './markup.js'\nimport { collectDomSnapshot } from './snapshot.js'\nimport { layoutSignatureOf } from './layoutSignature.js'\nimport { resolveDomTextTone } from './tone.js'\n\nconst EMPTY_STATS: Readonly<DomSdfStats> = Object.freeze({\n atlasBuildMs: 0,\n layoutReadMs: 0,\n geometryBuildMs: 0,\n glyphs: 0,\n shapes: 0,\n colorGlyphs: 0,\n fallbackGlyphs: 0,\n switchableGlyphs: 0,\n rects: 0,\n lines: 0,\n draws: 0,\n atlasWidth: 0,\n atlasHeight: 0,\n textBackend: 'sdf',\n atlasMode: null,\n textStorageBytes: 0,\n})\n\ntype RetainedTextBackend = SdfAtlas | WindfoilBackend\n\nfunction isWindfoilBackend(backend: RetainedTextBackend): backend is WindfoilBackend {\n return 'kind' in backend\n}\n\nfunction buildGlyphGeometry(\n snapshot: DomLayoutSnapshot,\n backend: RetainedTextBackend,\n motionPadding: number,\n): { geometry: InstancedBufferGeometry; maxSequence: number } {\n return isWindfoilBackend(backend)\n ? backend.createGeometry(snapshot, motionPadding)\n : createGlyphGeometry(snapshot, backend, motionPadding)\n}\n\nfunction sdfStorageBytes(atlas: SdfAtlas, mipmaps: boolean): number {\n const count = (w: number, h: number, bpp: number): number =>\n w * h * bpp + (mipmaps && (w > 1 || h > 1) ? count(w >> 1 || 1, h >> 1 || 1, bpp) : 0)\n return (\n count(atlas.width, atlas.height, 1) +\n (atlas.colorLayer ? count(atlas.width, atlas.colorLayer.height, 4) : 0)\n )\n}\n\ninterface ContentBundle {\n readonly g: Group\n readonly m: GlyphTextMaterial\n readonly tg: InstancedBufferGeometry\n readonly a: boolean\n sm(change: SdfMotionOptions, live: SdfMotionOptions): void\n st(tone: ResolvedTextTone | null): boolean\n ud(snapshot: DomLayoutSnapshot, backend: RetainedTextBackend, motion: SdfMotionOptions): void\n rg(geometry: InstancedBufferGeometry): void\n u(\n snapshot: DomLayoutSnapshot,\n backend: RetainedTextBackend,\n motion: SdfMotionOptions,\n tone?: ResolvedTextTone | null,\n ): boolean\n d(): void\n}\n\n/** Trailing debounce for attribute-only mutations (CSS transitions fire per frame). */\nconst ATTRIBUTE_DEBOUNCE_MS = 80\n/** A perpetually animating page still refreshes at least this often. */\nconst ATTRIBUTE_MAX_WAIT_MS = 320\n\nexport interface DomSdfRebuildOptions {\n /**\n * Regenerate the font atlas even when the requested face/codepoint set has\n * not changed. Use this after a same-family webfont is replaced in place.\n */\n atlas?: boolean\n}\n\nfunction now(): number {\n return performance.now()\n}\n\nfunction abortError(message = 'The DOM SDF build was aborted'): DOMException {\n return new DOMException(message, 'AbortError')\n}\n\nfunction throwIfAborted(signal: AbortSignal): void {\n if (signal.aborted) throw signal.reason ?? abortError()\n}\n\nfunction createContent(\n snapshot: DomLayoutSnapshot,\n backend: RetainedTextBackend,\n options: DomSdfOptions,\n motion: SdfMotionOptions,\n tone: ResolvedTextTone | null,\n makeExtraParts?: typeof createExtraTextParts,\n): ContentBundle {\n // Every text material shows the tone this capture resolved, not the caller's option.\n const materialOptions = { ...options, tone: tone ?? (false as const) }\n const group = new Group()\n group.name = 'ultra-text generated DOM content'\n group.matrixAutoUpdate = false\n group.updateMatrix()\n\n // Live motion, not the frozen construction options: setMotion() can raise the\n // strength after the fact.\n const strength = motion.strength ?? 18\n // The live mode 'none' builds static materials, without the motion graph; the first\n // setMotion() to another mode swaps in animated ones (see `setMotion` below).\n let animated = isAnimatedMotion(motion)\n const materialMotion = (live: SdfMotionOptions): SdfMotionOptions | false =>\n animated ? live : false\n const { geometry: glyphGeometry, maxSequence } = buildGlyphGeometry(snapshot, backend, strength)\n const hasExtras = isWindfoilBackend(backend) && !!(backend.companion ?? backend.color)\n const usesColor = (layout: DomLayoutSnapshot): boolean =>\n !!(isWindfoilBackend(backend) ? backend.companion?.colorLayer : backend.colorLayer) &&\n (options.colorGlyphs !== 'none' || layout.requests.some((request) => request.shape?.bitmap))\n const colorEnabled = usesColor(snapshot)\n const runMotion = needsRunMotion(snapshot) || hasExtras\n const maxSeq = (s: DomLayoutSnapshot): number =>\n s.glyphs.reduce((max, glyph) => Math.max(max, glyph.sequence), 0)\n const globalSequence = hasExtras ? maxSeq(snapshot) : maxSequence\n let textMaterial: GlyphTextMaterial\n try {\n textMaterial = isWindfoilBackend(backend)\n ? backend.createMaterial({\n ...materialOptions,\n maxSequence: hasExtras ? globalSequence : maxSequence,\n motion: materialMotion(motion),\n })\n : new SdfTextMaterial({\n ...materialOptions,\n runMotion,\n ...(colorEnabled ? { colorLayer: backend.colorLayer! } : {}),\n atlas: backend.texture,\n atlasWidth: backend.width,\n atlasHeight: backend.height,\n pxRange: backend.pxRange,\n // The size the atlas was really baked at, which an adaptive bake may have lowered.\n bakeSize: backend.bakeSize,\n shapeTop: backend.shapeTop,\n maxSequence,\n motion: materialMotion(motion),\n })\n } catch (error) {\n glyphGeometry.dispose()\n throw error\n }\n // Made before the text mesh. The parts of one text share its depth, where three draws in\n // creation order: an effects underlay at the text's render order goes under it, while\n // separate texts still sort by depth.\n let extras: ReturnType<typeof createExtraTextParts> | undefined\n try {\n if (hasExtras && isWindfoilBackend(backend))\n extras = makeExtraParts!(snapshot, backend, materialOptions, materialMotion(motion), strength)\n } catch (error) {\n glyphGeometry.dispose()\n textMaterial.dispose()\n throw error\n }\n const text = new Mesh(glyphGeometry, textMaterial)\n text.name = 'ultra-text text'\n text.castShadow = options.castShadow !== false\n text.frustumCulled = false\n text.renderOrder = 2\n text.matrixAutoUpdate = false\n text.updateMatrix()\n group.add(text)\n\n const ownedMeshes: Mesh[] = [text]\n const disposeMeshes = (): void => {\n for (const mesh of ownedMeshes) {\n mesh.geometry.dispose()\n for (const material of Array.isArray(mesh.material) ? mesh.material : [mesh.material])\n material.dispose()\n }\n ownedMeshes.length = 0\n group.clear()\n }\n try {\n if (extras) {\n for (const mesh of extras.meshes) {\n group.add(mesh)\n ownedMeshes.push(mesh)\n }\n extras.mergeRects(snapshot, text.geometry)\n }\n } catch (error) {\n disposeMeshes()\n throw error\n }\n let decorations: Mesh<InstancedBufferGeometry, TextDecorationMaterial> | null = null\n const glyphDrawable = (retained: RetainedTextBackend, key: string): boolean => {\n if (isWindfoilBackend(retained))\n return (\n (retained.glyphs.get(key)?.monotonePieceCount ?? 0) > 0 ||\n !!retained.companion?.glyphs.has(key)\n )\n return retained.glyphs.has(key)\n }\n const prepareDecorations = (\n layout: DomLayoutSnapshot,\n retained: RetainedTextBackend,\n liveMotion: SdfMotionOptions,\n nextTextGeometry: InstancedBufferGeometry,\n nextSequence: number,\n drawable: (key: string) => boolean = (key) => glyphDrawable(retained, key),\n ): readonly [InstancedBufferGeometry | null, TextDecorationMaterial | null] => {\n const geometry = createDecorationGeometry(\n layout,\n nextTextGeometry,\n drawable,\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,\n motion: materialMotion(liveMotion),\n maxSequence: nextSequence,\n })\n : null,\n ]\n } catch (error) {\n geometry?.dispose()\n throw error\n }\n }\n const commitDecorations = (\n [geometry, material]: ReturnType<typeof prepareDecorations>,\n liveMotion: SdfMotionOptions,\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 = textMaterial.maxSequence.value\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 const updateDecorations = (\n layout: DomLayoutSnapshot,\n retained: RetainedTextBackend,\n liveMotion: SdfMotionOptions,\n drawable: (key: string) => boolean = (key) => glyphDrawable(retained, key),\n ): void => {\n if (!decorations) return\n if (\n updateDecorationGeometry(\n decorations.geometry,\n layout,\n text.geometry,\n drawable,\n liveMotion.strength ?? 18,\n )\n ) {\n if (animated) decorations.material.setMotion(liveMotion)\n decorations.material.maxSequence.value = textMaterial.maxSequence.value\n return\n }\n commitDecorations(\n prepareDecorations(\n layout,\n retained,\n liveMotion,\n text.geometry,\n textMaterial.maxSequence.value,\n drawable,\n ),\n liveMotion,\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 let plainRects: Mesh | null = null\n let receivers: Mesh | null = null\n try {\n const initialDecorations = prepareDecorations(\n snapshot,\n backend,\n motion,\n text.geometry,\n textMaterial.maxSequence.value,\n )\n if (initialDecorations[0]) commitDecorations(initialDecorations, motion)\n plainRects = addRects(false, 'ultra-text DOM rectangles')\n receivers = addRects(true, 'ultra-text shadow receivers')\n } catch (error) {\n disposeMeshes()\n throw error\n }\n\n const swapGeometry = (mesh: Mesh, geometry: InstancedBufferGeometry): void => {\n const previous = mesh.geometry\n mesh.geometry = geometry\n previous.dispose()\n }\n\n // The bundle's text materials were built from one tone, so they accept or refuse together.\n const setTone = (next: ResolvedTextTone | null): boolean => {\n if (!textMaterial.setTone(next)) return false\n for (const mesh of extras?.meshes ?? []) mesh.material.setTone(next)\n return true\n }\n /** Whether `setTone` would accept this tone, without writing it. */\n const toneFits = (next: ResolvedTextTone | null): boolean => {\n const current = textMaterial.tone\n return current && next ? current.fits(next) : !current && !next\n }\n\n let disposed = false\n return {\n g: group,\n get m(): GlyphTextMaterial {\n return textMaterial\n },\n get a(): boolean {\n return animated\n },\n sm(change, live) {\n if (animated) {\n textMaterial.setMotion(change)\n extras?.setMotion(change)\n decorations?.material.setMotion(change)\n return\n }\n if (!isAnimatedMotion(live)) return\n const meshes: Mesh<InstancedBufferGeometry, GlyphTextMaterial>[] = [\n text,\n ...(extras?.meshes ?? []),\n ...(decorations ? [decorations] : []),\n ]\n const twins: GlyphTextMaterial[] = []\n try {\n for (const mesh of meshes) twins.push(mesh.material.withMotion(live))\n } catch (error) {\n for (const twin of twins) twin.dispose()\n throw error\n }\n meshes.forEach((mesh, index) => {\n const previous = mesh.material\n mesh.material = twins[index]!\n previous.dispose()\n })\n textMaterial = twins[0]!\n animated = true\n },\n st: setTone,\n ud: updateDecorations,\n get tg(): InstancedBufferGeometry {\n return text.geometry\n },\n rg(geometry: InstancedBufferGeometry): void {\n swapGeometry(text, geometry)\n },\n u(\n nextSnapshot: DomLayoutSnapshot,\n nextBackend: RetainedTextBackend,\n liveMotion: SdfMotionOptions,\n nextTone?: ResolvedTextTone | null,\n ) {\n if (\n nextTone !== undefined &&\n (!toneFits(nextTone) || animated !== isAnimatedMotion(liveMotion))\n )\n return false\n if (runMotion !== (needsRunMotion(nextSnapshot) || hasExtras)) return false\n if (colorEnabled !== usesColor(nextSnapshot)) return false\n const wantsPlain = nextSnapshot.rects.some((rect) => !rect.receiveShadow)\n const wantsReceivers = nextSnapshot.rects.some((rect) => rect.receiveShadow)\n if (wantsPlain !== (plainRects !== null) || wantsReceivers !== (receivers !== null)) {\n return false\n }\n const strength = liveMotion.strength ?? 18\n const drawable = (key: string): boolean => glyphDrawable(nextBackend, key)\n const decorationsFit = canUpdateDecorationGeometry(\n decorations?.geometry ?? null,\n nextSnapshot,\n drawable,\n )\n if (hasExtras && !decorationsFit) return false\n const glyphsFit =\n decorationsFit &&\n (isWindfoilBackend(nextBackend)\n ? nextBackend.contentFits(text.geometry, nextSnapshot)\n : glyphContentFits(text.geometry, nextSnapshot, nextBackend))\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 built: { geometry: InstancedBufferGeometry; maxSequence: number } | null = null\n let nextParts: readonly (InstancedBufferGeometry | null)[] = []\n let nextPlain: InstancedBufferGeometry | null = null\n let nextReceivers: InstancedBufferGeometry | null = null\n let nextDecorations: ReturnType<typeof prepareDecorations> | null = null\n const releaseStaged = (): void => {\n built?.geometry.dispose()\n for (const geometry of nextParts) geometry?.dispose()\n nextPlain?.dispose()\n nextReceivers?.dispose()\n nextDecorations?.[0]?.dispose()\n nextDecorations?.[1]?.dispose()\n }\n try {\n nextParts = extras?.prepare(nextSnapshot, strength) ?? []\n if (!glyphsFit) built = buildGlyphGeometry(nextSnapshot, nextBackend, strength)\n if (plainRects && !plainFit) nextPlain = createRectGeometry(nextSnapshot, false)\n if (receivers && !receiverFit) nextReceivers = createRectGeometry(nextSnapshot, true)\n if (!decorationsFit) {\n const source = built?.geometry ?? text.geometry\n nextDecorations = prepareDecorations(\n nextSnapshot,\n nextBackend,\n liveMotion,\n source,\n built?.maxSequence ?? textMaterial.maxSequence.value,\n drawable,\n )\n }\n } catch (error) {\n releaseStaged()\n throw error\n }\n if (built) {\n swapGeometry(text, built.geometry)\n textMaterial.maxSequence.value = built.maxSequence\n } else {\n const maxSequence = isWindfoilBackend(nextBackend)\n ? nextBackend.updateGeometry(text.geometry, nextSnapshot, strength)\n : updateGlyphContent(text.geometry, nextSnapshot, nextBackend, strength, undefined, true)\n if (maxSequence === null) {\n releaseStaged()\n throw new Error('DomSdf: glyph buffers changed during the update')\n }\n textMaterial.maxSequence.value = maxSequence\n }\n if (extras) {\n extras.commit(nextParts, nextSnapshot, strength)\n textMaterial.maxSequence.value = maxSeq(nextSnapshot)\n extras.mergeRects(nextSnapshot, text.geometry)\n }\n if (nextDecorations) commitDecorations(nextDecorations, liveMotion)\n else updateDecorations(nextSnapshot, nextBackend, liveMotion, drawable)\n if (plainRects && nextPlain) swapGeometry(plainRects, nextPlain)\n else if (plainRects)\n updateRectGeometry(plainRects.geometry as InstancedBufferGeometry, nextSnapshot, false)\n if (receivers && nextReceivers) swapGeometry(receivers, nextReceivers)\n else if (receivers)\n updateRectGeometry(receivers.geometry as InstancedBufferGeometry, nextSnapshot, true)\n if (nextTone !== undefined) setTone(nextTone)\n return true\n },\n d(): void {\n if (disposed) return\n disposed = true\n disposeMeshes()\n },\n }\n}\n\nexport class DomSdf extends Group {\n readonly renderer: WebGPURenderer\n readonly source: HTMLElement\n readonly options: Readonly<DomSdfOptions>\n protected readonly pageBackdrop: boolean = true\n\n #r: RetainedTextBackend | null = null\n #o = false\n #c: ContentBundle | null = null\n #a: AbortController | null = null\n #g = 0\n #d = false\n #f = 0\n #t = 0\n #dl = 0\n #fa = false\n #ro: ResizeObserver | null = null\n #mo: MutationObserver | null = null\n #uf: (() => void) | null = null\n private snapshot: DomLayoutSnapshot | null = null\n #w = 0\n #h = 0\n #as = ''\n #ls = ''\n #cm = false\n #ga = false\n #ac: Promise<typeof AppendAtlas | null> | undefined\n #st: Readonly<DomSdfStats> = EMPTY_STATS\n #m: SdfMotionOptions\n #to: TracedOutlines | null = null\n\n protected constructor(renderer: WebGPURenderer, source: HTMLElement, options: DomSdfOptions) {\n super()\n this.name = 'ultra-text DOM SDF'\n this.renderer = renderer\n this.source = source\n const copy = { ...options }\n for (const key of [\n 'motion',\n 'windfoil',\n 'slug',\n 'svg',\n 'tone',\n 'outline',\n 'dropShadow',\n ] as const) {\n if (typeof copy[key] === 'object')\n (copy as Record<string, unknown>)[key] = Object.freeze({ ...copy[key] })\n }\n this.options = Object.freeze(copy)\n this.#m = { ...options.motion }\n if (options.selectable) this.source.classList.add('sdf-selectable')\n }\n\n static async create(\n renderer: WebGPURenderer,\n source: HTMLElement,\n options: DomSdfOptions = {},\n ): Promise<DomSdf> {\n const domSdf = new DomSdf(renderer, source, options)\n await domSdf.initialize()\n return domSdf\n }\n\n protected async initialize(): Promise<void> {\n try {\n await this.rebuild({ atlas: true })\n this.#co()\n } catch (error) {\n this.dispose()\n throw error\n }\n }\n\n get width(): number {\n return this.#c ? this.#w : 0\n }\n\n get height(): number {\n return this.#c ? this.#h : 0\n }\n\n get stats(): Readonly<DomSdfStats> {\n return this.#st\n }\n\n get atlasTexture(): SdfAtlas['texture'] | null {\n const retained = this.#r\n return retained\n ? isWindfoilBackend(retained)\n ? (retained.companion?.texture ?? null)\n : retained.texture\n : null\n }\n\n setMotion(options: SdfMotionOptions): this {\n const motion = { ...this.#m, ...options }\n this.#c?.sm(options, motion)\n this.#m = motion\n return this\n }\n\n reflow(width: number): this {\n if (this.#d) throw new Error('DomSdf.reflow: this instance is disposed')\n if (!this.snapshot) {\n throw new Error('DomSdf.reflow: create the instance with reflowable: true first')\n }\n if (!this.#r || !this.#c) return this\n const retained = this.#r\n const content = this.#c\n if (isWindfoilBackend(retained)) retained.setGlyphEm(!!content.m.tone?.dilates)\n\n const started = now()\n const reflowed = reflowSnapshot(this.snapshot, width)\n const strength = this.#m.strength ?? 18\n if (isWindfoilBackend(retained) && (retained.companion || retained.color)) {\n if (!content.u(reflowed, retained, this.#m))\n throw new Error('DomSdf.reflow: incompatible retained content')\n } else {\n let maxSequence = isWindfoilBackend(retained)\n ? retained.updateGeometry(content.tg, reflowed, strength)\n : updateGlyphGeometry(content.tg, reflowed, retained, strength)\n if (maxSequence === null) {\n const built = buildGlyphGeometry(reflowed, retained, strength)\n content.rg(built.geometry)\n maxSequence = built.maxSequence\n }\n content.m.maxSequence.value = maxSequence\n content.ud(reflowed, retained, this.#m)\n }\n this.#cm = false\n this.#w = reflowed.width\n this.#h = reflowed.height\n this.#st = Object.freeze({\n ...this.#st,\n lines: reflowed.lineCount,\n layoutReadMs: 0,\n atlasBuildMs: 0,\n geometryBuildMs: now() - started,\n })\n return this\n }\n\n async rebuild(rebuildOptions: DomSdfRebuildOptions = {}): Promise<void> {\n if (this.#d) throw new Error('DomSdf.rebuild: this instance is disposed')\n const externalSignal = this.options.signal\n if (externalSignal?.aborted) {\n throw externalSignal.reason ?? abortError()\n }\n\n this.#a?.abort(abortError('Superseded by a newer DOM SDF build'))\n const controller = new AbortController()\n this.#a = controller\n const generation = ++this.#g\n const forwardAbort = (): void => {\n controller.abort(externalSignal?.reason ?? abortError())\n }\n externalSignal?.addEventListener('abort', forwardAbort, { once: true })\n\n let nextRetained: RetainedTextBackend | null = null\n let ownsNextRetained = false\n let appended = false\n let nextContent: ContentBundle | null = null\n try {\n await Promise.resolve()\n throwIfAborted(controller.signal)\n if (generation !== this.#g) {\n throw abortError('Superseded by a newer DOM SDF build')\n }\n\n const opts = this.options\n const gpuUpload =\n opts.atlasMode !== 'cpu' &&\n this.renderer.initialized &&\n (this.renderer.backend as { isWebGPUBackend?: boolean }).isWebGPUBackend === true\n const backendKind = opts.textBackend\n const isAnalyticOption = backendKind === 'windfoil' || backendKind === 'slug'\n if (gpuUpload && !isAnalyticOption && !this.#r) prepareAtlasPasses(this.renderer)\n\n const layoutStarted = now()\n const snapshot = await collectDomSnapshot(this.source, opts)\n const tone = resolveDomTextTone(this.source, opts.tone, {\n glyphs: snapshot.glyphs,\n rects: snapshot.rects,\n rootRect:\n opts.includeRootBackground !== false ||\n this.source.matches(opts.rectSelector ?? DEFAULT_RECT_SELECTOR),\n page: this.pageBackdrop,\n })\n const layoutReadMs = now() - layoutStarted\n throwIfAborted(controller.signal)\n\n let bitmap: boolean | undefined\n const atlasCovers = (atlas: SdfAtlas): boolean => {\n if (opts.colorGlyphs === 'none') {\n bitmap ??= snapshot.requests.some((request) => request.shape?.bitmap)\n }\n return snapshot.requests.every((request) => {\n const slot = atlas.glyphs.get(request.key)\n return (\n slot !== undefined &&\n !(opts.colorGlyphs === 'none' && bitmap && !request.shape && slot.color) &&\n (!isColorCandidate(request, opts.colorGlyphs) || slot.color !== undefined)\n )\n })\n }\n const retained = this.#r\n const canReuseRetainedText =\n rebuildOptions.atlas !== true &&\n retained !== null &&\n (this.#as === snapshot.atlasSignature ||\n (isWindfoilBackend(retained)\n ? snapshot.requests.every((request) => retained.covers(request.key))\n : atlasCovers(retained)))\n const signature = layoutSignatureOf(snapshot)\n if (\n canReuseRetainedText &&\n this.#c !== null &&\n this.#cm &&\n signature === this.#ls &&\n generation === this.#g &&\n this.#c.st(tone)\n ) {\n this.#st = Object.freeze({\n ...this.#st,\n layoutReadMs,\n atlasBuildMs: 0,\n geometryBuildMs: 0,\n })\n if (opts.svg) this.#om()\n return\n }\n\n let atlasBuildMs = 0\n const sharedAtlas = isAnalyticOption ? undefined : opts.sharedAtlas\n const sharedCovers = sharedAtlas !== undefined && atlasCovers(sharedAtlas)\n if (canReuseRetainedText) {\n nextRetained = retained\n } else if (sharedCovers) {\n nextRetained = sharedAtlas\n ownsNextRetained = false\n } else {\n const atlasStarted = now()\n const appendTo =\n !isAnalyticOption &&\n rebuildOptions.atlas !== true &&\n this.#o &&\n retained &&\n !isWindfoilBackend(retained)\n ? retained\n : null\n const chunk =\n appendTo && (await (this.#ac ??= import('../atlas/appendAtlas.js').catch(() => null)))\n if (appendTo && chunk) {\n this.#ga = true\n nextRetained = await chunk.appendGlyphs(\n this.renderer,\n this.source.ownerDocument,\n appendTo,\n snapshot.requests,\n opts,\n controller.signal,\n )\n appended = !!nextRetained\n }\n const previousAtlas =\n rebuildOptions.atlas !== true &&\n retained !== null &&\n !isWindfoilBackend(retained) &&\n retained !== opts.sharedAtlas\n ? retained\n : undefined\n const buildAtlas = async (\n requests: DomLayoutSnapshot['requests'],\n signal: AbortSignal,\n appendable?: RasterizeOptions['appendable'],\n ): Promise<SdfAtlas> => {\n const def = <K extends keyof DomSdfOptions>(...ks: K[]) =>\n Object.fromEntries(ks.flatMap((k) => (opts[k] === undefined ? [] : [[k, opts[k]]])))\n const raster = await rasterizeGlyphAtlas(this.source.ownerDocument, requests, {\n signal,\n previousAtlas,\n appendable,\n ...(gpuUpload ? { gpuUpload } : {}),\n ...def('colorGlyphs', 'bakeSize', 'padding', 'maxAtlasSize', 'adaptiveBakeSize'),\n })\n return buildSdfAtlas(this.renderer, raster, {\n signal,\n mipmaps: opts.quality === 'high',\n anisotropy: opts.quality === 'high' ? 4 : 1,\n ...(opts.atlasMode === undefined ? {} : { mode: opts.atlasMode }),\n ...def('cpuWorker'),\n })\n }\n if (!appended && isAnalyticOption && opts.textShaping !== 'browser') {\n const analytic =\n (backendKind === 'slug' ? (opts.slug ?? opts.windfoil) : opts.windfoil) ?? {}\n const outlineProvider: unknown = analytic.outlineProvider\n if (outlineProvider !== undefined && typeof outlineProvider !== 'function') {\n throw new TypeError(\n `DomSdf: textBackend \"${backendKind}\" requires ${backendKind}.outlineProvider`,\n )\n }\n let resolved: WindfoilBuildOptions\n if (analytic.outlineProvider) {\n resolved = { ...analytic, outlineProvider: analytic.outlineProvider }\n } else {\n if (!this.#to) {\n const { createTracedOutlineProvider } = await import('../windfoil/tracedOutlines.js')\n throwIfAborted(controller.signal)\n this.#to ??= createTracedOutlineProvider(\n this.source.ownerDocument,\n opts.colorGlyphs === undefined ? {} : { colorGlyphs: opts.colorGlyphs },\n )\n } else if (rebuildOptions.atlas === true) {\n this.#to.clear()\n }\n resolved = {\n ...analytic,\n fallback: analytic.fallback ?? 'sdf-glyphs',\n outlineProvider: this.#to.provider,\n }\n }\n const build =\n backendKind === 'slug'\n ? (await import('../slug/runtime.js')).buildSlugBackend\n : (await import('../windfoil/runtime.js')).buildWindfoilBackend\n nextRetained = await build(\n this.renderer,\n snapshot.requests,\n resolved,\n controller.signal,\n { build: buildAtlas, effects: opts },\n )\n }\n if (!appended) {\n nextRetained ??= await buildAtlas(\n snapshot.requests,\n controller.signal,\n this.#ga ? 'headroom' : true,\n )\n ownsNextRetained = true\n }\n atlasBuildMs = now() - atlasStarted\n }\n throwIfAborted(controller.signal)\n if (generation !== this.#g || !nextRetained) {\n throw abortError('Superseded by a newer DOM SDF build')\n }\n\n const geometryStarted = now()\n if (isWindfoilBackend(nextRetained)) nextRetained.setGlyphEm(!!tone?.dilationPx)\n const updatedInPlace =\n (canReuseRetainedText || appended) &&\n (this.#c?.u(snapshot, nextRetained, this.#m, tone) ?? false)\n if (!updatedInPlace) {\n const extra =\n isWindfoilBackend(nextRetained) && (nextRetained.companion || nextRetained.color)\n ? await import('../windfoil/mixed.js')\n : undefined\n throwIfAborted(controller.signal)\n nextContent = createContent(\n snapshot,\n nextRetained,\n opts,\n this.#m,\n tone,\n extra?.createExtraTextParts,\n )\n }\n const geometryBuildMs = now() - geometryStarted\n throwIfAborted(controller.signal)\n\n const oldContent = this.#c\n const oldRetained = this.#r\n let activeContent: ContentBundle\n if (nextContent) {\n if (oldContent) this.remove(oldContent.g)\n this.add(nextContent.g)\n this.#c = nextContent\n activeContent = nextContent\n } else {\n activeContent = oldContent!\n }\n const ownedPrevious = this.#o\n this.#r = nextRetained\n this.#o = canReuseRetainedText || appended ? ownedPrevious : ownsNextRetained\n this.snapshot = opts.reflowable === true ? snapshot : null\n this.#w = snapshot.width\n this.#h = snapshot.height\n this.#as = snapshot.atlasSignature\n this.#ls = signature\n this.#cm = true\n if (opts.svg) this.#om()\n this.#to?.retain(snapshot.requests.map((request) => request.key))\n const windfoil = isWindfoilBackend(nextRetained) ? nextRetained : null\n const atlas = windfoil ? windfoil.companion : (nextRetained as SdfAtlas)\n const glyphs = atlas?.glyphs\n const switchKeys = windfoil?.sizeSwitch?.keys\n let glyphCount = 0\n let shapeCount = 0\n let colorGlyphCount = 0\n let fallbackGlyphCount = 0\n let switchableGlyphCount = 0\n for (const glyph of snapshot.glyphs) {\n if (switchKeys?.has(glyph.glyphKey)) switchableGlyphCount++\n if (glyph.shapeGroup !== undefined) {\n shapeCount++\n continue\n }\n glyphCount++\n const slot = glyphs?.get(glyph.glyphKey)\n if (slot && !windfoil?.analyticCovers(glyph.glyphKey)) {\n if (slot.color) colorGlyphCount++\n if (windfoil) fallbackGlyphCount++\n }\n }\n this.#st = Object.freeze({\n atlasBuildMs,\n layoutReadMs,\n geometryBuildMs,\n glyphs: glyphCount,\n shapes: shapeCount,\n colorGlyphs: colorGlyphCount,\n fallbackGlyphs: fallbackGlyphCount,\n switchableGlyphs: switchableGlyphCount,\n rects: snapshot.rects.length,\n lines: snapshot.lineCount,\n draws: activeContent.g.children.length,\n atlasWidth: atlas?.width ?? 0,\n atlasHeight: atlas?.height ?? 0,\n textBackend: windfoil ? windfoil.kind : ('sdf' as const),\n atlasMode: atlas?.mode ?? null,\n textStorageBytes:\n (windfoil?.storageBytes ?? 0) +\n (atlas ? sdfStorageBytes(atlas, opts.quality === 'high') : 0),\n })\n nextContent = null\n ownsNextRetained = false\n if (oldContent && oldContent !== activeContent) oldContent.d()\n if (oldRetained && oldRetained !== nextRetained && ownedPrevious && !appended) {\n oldRetained.dispose()\n }\n } catch (error) {\n nextContent?.d()\n if (ownsNextRetained) nextRetained?.dispose()\n throw error\n } finally {\n externalSignal?.removeEventListener('abort', forwardAbort)\n if (this.#a === controller) this.#a = null\n }\n }\n\n #sr(forceAtlas = false, lazy = false): void {\n if (this.#d) return\n this.#fa ||= forceAtlas\n const view = this.source.ownerDocument.defaultView\n if (!view) return\n if (lazy && this.#f === 0) {\n const nowMs = now()\n if (this.#t !== 0) view.clearTimeout(this.#t)\n else this.#dl = nowMs + ATTRIBUTE_MAX_WAIT_MS\n const delay = Math.min(ATTRIBUTE_DEBOUNCE_MS, Math.max(0, this.#dl - nowMs))\n this.#t = view.setTimeout(() => {\n this.#t = 0\n this.#rr()\n }, delay)\n return\n }\n if (this.#t !== 0) {\n view.clearTimeout(this.#t)\n this.#t = 0\n }\n if (this.#f !== 0) return\n this.#f = view.requestAnimationFrame(() => {\n this.#f = 0\n this.#rr()\n })\n }\n\n #rr(): void {\n const atlas = this.#fa\n this.#fa = false\n void this.rebuild({ atlas }).catch((error: unknown) => {\n if (error instanceof DOMException && error.name === 'AbortError') return\n this.options.onError?.(error)\n })\n }\n\n #co(): void {\n if (this.options.observe === false || this.#d) return\n const view = this.source.ownerDocument.defaultView\n if (!view) return\n\n this.#ro = new ResizeObserver(() => {\n this.#sr()\n })\n this.#ro.observe(this.source)\n this.#mo = new MutationObserver((records) => {\n this.#sr(\n false,\n records.every((record) => record.type === 'attributes'),\n )\n })\n this.#om()\n\n const fonts = this.source.ownerDocument.fonts as FontFaceSet | undefined\n if (fonts) {\n const onFontsLoaded = (): void => {\n this.#to?.clear()\n this.#sr(true)\n }\n fonts.addEventListener('loadingdone', onFontsLoaded)\n this.#uf = () => {\n fonts.removeEventListener('loadingdone', onFontsLoaded)\n }\n }\n }\n\n #om(): void {\n const observer = this.#mo\n if (!observer) return\n observer.disconnect()\n const options = { attributes: true, characterData: true, childList: true, subtree: true }\n observer.observe(this.source, options)\n if (!this.options.svg) return\n const seen = new Set<Element>([this.source])\n const pending: Element[] = [this.source]\n while (pending.length) {\n const source = pending.pop()!\n const uses = [...source.querySelectorAll('use')]\n if (source.localName === 'use') uses.unshift(source as SVGUseElement)\n for (const use of uses) {\n const href = use.getAttribute('href') ?? use.getAttribute('xlink:href') ?? ''\n const tree = use.getRootNode() as Document | ShadowRoot\n const target = href.startsWith('#') ? tree.getElementById(href.slice(1)) : null\n if (!target || seen.has(target)) continue\n seen.add(target)\n if (!this.source.contains(target)) observer.observe(target, options)\n pending.push(target)\n }\n }\n }\n\n override dispose(): void {\n if (this.#d) return\n this.#d = true\n this.#g++\n this.#a?.abort(abortError('The DOM SDF instance was disposed'))\n const view = this.source.ownerDocument.defaultView\n if (view && this.#f !== 0) view.cancelAnimationFrame(this.#f)\n if (view && this.#t !== 0) view.clearTimeout(this.#t)\n this.#ro?.disconnect()\n this.#mo?.disconnect()\n this.#uf?.()\n if (this.#c) {\n this.remove(this.#c.g)\n this.#c.d()\n }\n if (this.#o) this.#r?.dispose()\n this.#to?.clear()\n this.#a = this.#ro = this.#mo = this.#uf = this.#c = this.#r = this.#to = this.snapshot = null\n this.#f = this.#t = this.#w = this.#h = 0\n this.#o = this.#cm = false\n this.#as = this.#ls = ''\n this.#st = EMPTY_STATS\n this.source.classList.remove('sdf-selectable')\n this.clear()\n super.dispose()\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;AA0CA,IAAM,cAAqC,OAAO,OAAO;CACvD,cAAc;CACd,cAAc;CACd,iBAAiB;CACjB,QAAQ;CACR,QAAQ;CACR,aAAa;CACb,gBAAgB;CAChB,kBAAkB;CAClB,OAAO;CACP,OAAO;CACP,OAAO;CACP,YAAY;CACZ,aAAa;CACb,aAAa;CACb,WAAW;CACX,kBAAkB;AACpB,CAAC;AAID,SAAS,kBAAkB,SAA0D;CACnF,OAAO,UAAU;AACnB;AAEA,SAAS,mBACP,UACA,SACA,eAC4D;CAC5D,OAAO,kBAAkB,OAAO,IAC5B,QAAQ,eAAe,UAAU,aAAa,IAC9C,oBAAoB,UAAU,SAAS,aAAa;AAC1D;AAEA,SAAS,gBAAgB,OAAiB,SAA0B;CAClE,MAAM,SAAS,GAAW,GAAW,QACnC,IAAI,IAAI,OAAO,YAAY,IAAI,KAAK,IAAI,KAAK,MAAM,KAAK,KAAK,GAAG,KAAK,KAAK,GAAG,GAAG,IAAI;CACtF,OACE,MAAM,MAAM,OAAO,MAAM,QAAQ,CAAC,KACjC,MAAM,aAAa,MAAM,MAAM,OAAO,MAAM,WAAW,QAAQ,CAAC,IAAI;AAEzE;;AAqB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,UAAyB;EACvB,IAAI,KAAK,IAAI;EACb,KAAK,KAAK;EACV,KAAK;EACL,KAAK,IAAI,MAAM,WAAW,mCAAmC,CAAC;EAC9D,MAAM,OAAO,KAAK,OAAO,cAAc;EACvC,IAAI,QAAQ,KAAK,OAAO,GAAG,KAAK,qBAAqB,KAAK,EAAE;EAC5D,IAAI,QAAQ,KAAK,OAAO,GAAG,KAAK,aAAa,KAAK,EAAE;EACpD,KAAK,KAAK,WAAW;EACrB,KAAK,KAAK,WAAW;EACrB,KAAK,MAAM;EACX,IAAI,KAAK,IAAI;GACX,KAAK,OAAO,KAAK,GAAG,CAAC;GACrB,KAAK,GAAG,EAAE;EACZ;EACA,IAAI,KAAK,IAAI,KAAK,IAAI,QAAQ;EAC9B,KAAK,KAAK,MAAM;EAChB,KAAK,KAAK,KAAK,MAAM,KAAK,MAAM,KAAK,MAAM,KAAK,KAAK,KAAK,KAAK,KAAK,MAAM,KAAK,WAAW;EAC1F,KAAK,KAAK,KAAK,KAAK,KAAK,KAAK,KAAK,KAAK;EACxC,KAAK,KAAK,KAAK,MAAM;EACrB,KAAK,MAAM,KAAK,MAAM;EACtB,KAAK,MAAM;EACX,KAAK,OAAO,UAAU,OAAO,gBAAgB;EAC7C,KAAK,MAAM;EACX,MAAM,QAAQ;CAChB;AACF"}
1
+ {"version":3,"file":"DomSdf.js","names":[],"sources":["../../src/dom/DomSdf.ts"],"sourcesContent":["import { Group, Mesh, type InstancedBufferGeometry, type WebGPURenderer } from 'three/webgpu'\n\nimport type * as AppendAtlas from '../atlas/appendAtlas.js'\nimport { buildSdfAtlas } from '../atlas/buildAtlas.js'\nimport { prepareAtlasPasses } from '../atlas/gpuAtlas.js'\nimport { isColorCandidate, rasterizeGlyphAtlas, type RasterizeOptions } from '../atlas/rasterize.js'\nimport { createRectMaterial } from '../text/RectMaterial.js'\nimport { isAnimatedMotion, type GlyphTextMaterial } from '../text/GlyphTextMaterial.js'\nimport { SdfTextMaterial } from '../text/SdfTextMaterial.js'\nimport {\n createGlyphGeometry,\n createRectGeometry,\n glyphContentFits,\n needsRunMotion,\n rectContentFits,\n updateGlyphContent,\n updateGlyphGeometry,\n updateRectGeometry,\n} from '../text/geometry.js'\nimport { reflowSnapshot } from '../text/reflow.js'\nimport {\n canUpdateDecorationGeometry,\n createDecorationGeometry,\n TextDecorationMaterial,\n updateDecorationGeometry,\n} from '../text/decorations.js'\nimport type { ResolvedTextTone } from '../text/tone.js'\nimport type {\n DomLayoutSnapshot,\n DomSdfOptions,\n DomSdfStats,\n SdfAtlas,\n SdfMotionOptions,\n} from '../types.js'\nimport type { createExtraTextParts } from '../windfoil/mixed.js'\nimport type * as SlugRuntime from '../slug/runtime.js'\nimport type * as WindfoilRuntime from '../windfoil/runtime.js'\nimport type { WindfoilBackend, WindfoilBuildOptions } from '../windfoil/runtime.js'\nimport type * as TracedOutlinesModule from '../windfoil/tracedOutlines.js'\nimport type { TracedOutlines } from '../windfoil/tracedOutlines.js'\nimport { DEFAULT_RECT_SELECTOR } from './markup.js'\nimport { collectDomSnapshot } from './snapshot.js'\nimport { layoutSignatureOf } from './layoutSignature.js'\nimport { resolveDomTextTone } from './tone.js'\n\nconst EMPTY_STATS: Readonly<DomSdfStats> = Object.freeze({\n atlasBuildMs: 0,\n layoutReadMs: 0,\n geometryBuildMs: 0,\n glyphs: 0,\n shapes: 0,\n colorGlyphs: 0,\n fallbackGlyphs: 0,\n switchableGlyphs: 0,\n rects: 0,\n lines: 0,\n draws: 0,\n atlasWidth: 0,\n atlasHeight: 0,\n textBackend: 'sdf',\n atlasMode: null,\n textStorageBytes: 0,\n})\n\ntype RetainedTextBackend = SdfAtlas | WindfoilBackend\n\nfunction isWindfoilBackend(backend: RetainedTextBackend): backend is WindfoilBackend {\n return 'kind' in backend\n}\n\nfunction buildGlyphGeometry(\n snapshot: DomLayoutSnapshot,\n backend: RetainedTextBackend,\n motionPadding: number,\n): { geometry: InstancedBufferGeometry; maxSequence: number } {\n return isWindfoilBackend(backend)\n ? backend.createGeometry(snapshot, motionPadding)\n : createGlyphGeometry(snapshot, backend, motionPadding)\n}\n\nfunction sdfStorageBytes(atlas: SdfAtlas, mipmaps: boolean): number {\n const count = (w: number, h: number, bpp: number): number =>\n w * h * bpp + (mipmaps && (w > 1 || h > 1) ? count(w >> 1 || 1, h >> 1 || 1, bpp) : 0)\n return (\n count(atlas.width, atlas.height, 1) +\n (atlas.colorLayer ? count(atlas.width, atlas.colorLayer.height, 4) : 0)\n )\n}\n\ninterface ContentBundle {\n readonly g: Group\n readonly m: GlyphTextMaterial\n readonly tg: InstancedBufferGeometry\n readonly a: boolean\n sm(change: SdfMotionOptions, live: SdfMotionOptions): void\n st(tone: ResolvedTextTone | null): boolean\n ud(snapshot: DomLayoutSnapshot, backend: RetainedTextBackend, motion: SdfMotionOptions): void\n rg(geometry: InstancedBufferGeometry): void\n u(\n snapshot: DomLayoutSnapshot,\n backend: RetainedTextBackend,\n motion: SdfMotionOptions,\n tone?: ResolvedTextTone | null,\n ): boolean\n d(): void\n}\n\n/** Trailing debounce for attribute-only mutations (CSS transitions fire per frame). */\nconst ATTRIBUTE_DEBOUNCE_MS = 80\n/** A perpetually animating page still refreshes at least this often. */\nconst ATTRIBUTE_MAX_WAIT_MS = 320\n\nexport interface DomSdfRebuildOptions {\n /**\n * Regenerate the font atlas even when the requested face/codepoint set has\n * not changed. Use this after a same-family webfont is replaced in place.\n */\n atlas?: boolean\n}\n\nfunction now(): number {\n return performance.now()\n}\n\nfunction abortError(message = 'The DOM SDF build was aborted'): DOMException {\n return new DOMException(message, 'AbortError')\n}\n\nfunction throwIfAborted(signal: AbortSignal): void {\n if (signal.aborted) throw signal.reason ?? abortError()\n}\n\nfunction createContent(\n snapshot: DomLayoutSnapshot,\n backend: RetainedTextBackend,\n options: DomSdfOptions,\n motion: SdfMotionOptions,\n tone: ResolvedTextTone | null,\n makeExtraParts?: typeof createExtraTextParts,\n): ContentBundle {\n // Every text material shows the tone this capture resolved, not the caller's option.\n const materialOptions = { ...options, tone: tone ?? (false as const) }\n const group = new Group()\n group.name = 'ultra-text generated DOM content'\n group.matrixAutoUpdate = false\n group.updateMatrix()\n\n // Live motion, not the frozen construction options: setMotion() can raise the\n // strength after the fact.\n const strength = motion.strength ?? 18\n // The live mode 'none' builds static materials, without the motion graph; the first\n // setMotion() to another mode swaps in animated ones (see `setMotion` below).\n let animated = isAnimatedMotion(motion)\n const materialMotion = (live: SdfMotionOptions): SdfMotionOptions | false =>\n animated ? live : false\n const { geometry: glyphGeometry, maxSequence } = buildGlyphGeometry(snapshot, backend, strength)\n const hasExtras = isWindfoilBackend(backend) && !!(backend.companion ?? backend.color)\n const usesColor = (layout: DomLayoutSnapshot): boolean =>\n !!(isWindfoilBackend(backend) ? backend.companion?.colorLayer : backend.colorLayer) &&\n (options.colorGlyphs !== 'none' || layout.requests.some((request) => request.shape?.bitmap))\n const colorEnabled = usesColor(snapshot)\n const runMotion = needsRunMotion(snapshot) || hasExtras\n const maxSeq = (s: DomLayoutSnapshot): number =>\n s.glyphs.reduce((max, glyph) => Math.max(max, glyph.sequence), 0)\n const globalSequence = hasExtras ? maxSeq(snapshot) : maxSequence\n let textMaterial: GlyphTextMaterial\n try {\n textMaterial = isWindfoilBackend(backend)\n ? backend.createMaterial({\n ...materialOptions,\n maxSequence: hasExtras ? globalSequence : maxSequence,\n motion: materialMotion(motion),\n })\n : new SdfTextMaterial({\n ...materialOptions,\n runMotion,\n ...(colorEnabled ? { colorLayer: backend.colorLayer! } : {}),\n atlas: backend.texture,\n atlasWidth: backend.width,\n atlasHeight: backend.height,\n pxRange: backend.pxRange,\n // The size the atlas was really baked at, which an adaptive bake may have lowered.\n bakeSize: backend.bakeSize,\n shapeTop: backend.shapeTop,\n maxSequence,\n motion: materialMotion(motion),\n })\n } catch (error) {\n glyphGeometry.dispose()\n throw error\n }\n // Made before the text mesh. The parts of one text share its depth, where three draws in\n // creation order: an effects underlay at the text's render order goes under it, while\n // separate texts still sort by depth.\n let extras: ReturnType<typeof createExtraTextParts> | undefined\n try {\n if (hasExtras && isWindfoilBackend(backend))\n extras = makeExtraParts!(snapshot, backend, materialOptions, materialMotion(motion), strength)\n } catch (error) {\n glyphGeometry.dispose()\n textMaterial.dispose()\n throw error\n }\n const text = new Mesh(glyphGeometry, textMaterial)\n text.name = 'ultra-text text'\n text.castShadow = options.castShadow !== false\n text.frustumCulled = false\n text.renderOrder = 2\n text.matrixAutoUpdate = false\n text.updateMatrix()\n group.add(text)\n\n const ownedMeshes: Mesh[] = [text]\n const disposeMeshes = (): void => {\n for (const mesh of ownedMeshes) {\n mesh.geometry.dispose()\n for (const material of Array.isArray(mesh.material) ? mesh.material : [mesh.material])\n material.dispose()\n }\n ownedMeshes.length = 0\n group.clear()\n }\n try {\n if (extras) {\n for (const mesh of extras.meshes) {\n group.add(mesh)\n ownedMeshes.push(mesh)\n }\n extras.mergeRects(snapshot, text.geometry)\n }\n } catch (error) {\n disposeMeshes()\n throw error\n }\n let decorations: Mesh<InstancedBufferGeometry, TextDecorationMaterial> | null = null\n const glyphDrawable = (retained: RetainedTextBackend, key: string): boolean => {\n if (isWindfoilBackend(retained))\n return (\n (retained.glyphs.get(key)?.monotonePieceCount ?? 0) > 0 ||\n !!retained.companion?.glyphs.has(key)\n )\n return retained.glyphs.has(key)\n }\n const prepareDecorations = (\n layout: DomLayoutSnapshot,\n retained: RetainedTextBackend,\n liveMotion: SdfMotionOptions,\n nextTextGeometry: InstancedBufferGeometry,\n nextSequence: number,\n drawable: (key: string) => boolean = (key) => glyphDrawable(retained, key),\n ): readonly [InstancedBufferGeometry | null, TextDecorationMaterial | null] => {\n const geometry = createDecorationGeometry(\n layout,\n nextTextGeometry,\n drawable,\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,\n motion: materialMotion(liveMotion),\n maxSequence: nextSequence,\n })\n : null,\n ]\n } catch (error) {\n geometry?.dispose()\n throw error\n }\n }\n const commitDecorations = (\n [geometry, material]: ReturnType<typeof prepareDecorations>,\n liveMotion: SdfMotionOptions,\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 = textMaterial.maxSequence.value\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 const updateDecorations = (\n layout: DomLayoutSnapshot,\n retained: RetainedTextBackend,\n liveMotion: SdfMotionOptions,\n drawable: (key: string) => boolean = (key) => glyphDrawable(retained, key),\n ): void => {\n if (!decorations) return\n if (\n updateDecorationGeometry(\n decorations.geometry,\n layout,\n text.geometry,\n drawable,\n liveMotion.strength ?? 18,\n )\n ) {\n if (animated) decorations.material.setMotion(liveMotion)\n decorations.material.maxSequence.value = textMaterial.maxSequence.value\n return\n }\n commitDecorations(\n prepareDecorations(\n layout,\n retained,\n liveMotion,\n text.geometry,\n textMaterial.maxSequence.value,\n drawable,\n ),\n liveMotion,\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 let plainRects: Mesh | null = null\n let receivers: Mesh | null = null\n try {\n const initialDecorations = prepareDecorations(\n snapshot,\n backend,\n motion,\n text.geometry,\n textMaterial.maxSequence.value,\n )\n if (initialDecorations[0]) commitDecorations(initialDecorations, motion)\n plainRects = addRects(false, 'ultra-text DOM rectangles')\n receivers = addRects(true, 'ultra-text shadow receivers')\n } catch (error) {\n disposeMeshes()\n throw error\n }\n\n const swapGeometry = (mesh: Mesh, geometry: InstancedBufferGeometry): void => {\n const previous = mesh.geometry\n mesh.geometry = geometry\n previous.dispose()\n }\n\n // The bundle's text materials were built from one tone, so they accept or refuse together.\n const setTone = (next: ResolvedTextTone | null): boolean => {\n if (!textMaterial.setTone(next)) return false\n for (const mesh of extras?.meshes ?? []) mesh.material.setTone(next)\n return true\n }\n /** Whether `setTone` would accept this tone, without writing it. */\n const toneFits = (next: ResolvedTextTone | null): boolean => {\n const current = textMaterial.tone\n return current && next ? current.fits(next) : !current && !next\n }\n\n let disposed = false\n return {\n g: group,\n get m(): GlyphTextMaterial {\n return textMaterial\n },\n get a(): boolean {\n return animated\n },\n sm(change, live) {\n if (animated) {\n textMaterial.setMotion(change)\n extras?.setMotion(change)\n decorations?.material.setMotion(change)\n return\n }\n if (!isAnimatedMotion(live)) return\n const meshes: Mesh<InstancedBufferGeometry, GlyphTextMaterial>[] = [\n text,\n ...(extras?.meshes ?? []),\n ...(decorations ? [decorations] : []),\n ]\n const twins: GlyphTextMaterial[] = []\n try {\n for (const mesh of meshes) twins.push(mesh.material.withMotion(live))\n } catch (error) {\n for (const twin of twins) twin.dispose()\n throw error\n }\n meshes.forEach((mesh, index) => {\n const previous = mesh.material\n mesh.material = twins[index]!\n previous.dispose()\n })\n textMaterial = twins[0]!\n animated = true\n },\n st: setTone,\n ud: updateDecorations,\n get tg(): InstancedBufferGeometry {\n return text.geometry\n },\n rg(geometry: InstancedBufferGeometry): void {\n swapGeometry(text, geometry)\n },\n u(\n nextSnapshot: DomLayoutSnapshot,\n nextBackend: RetainedTextBackend,\n liveMotion: SdfMotionOptions,\n nextTone?: ResolvedTextTone | null,\n ) {\n if (\n nextTone !== undefined &&\n (!toneFits(nextTone) || animated !== isAnimatedMotion(liveMotion))\n )\n return false\n if (runMotion !== (needsRunMotion(nextSnapshot) || hasExtras)) return false\n if (colorEnabled !== usesColor(nextSnapshot)) return false\n const wantsPlain = nextSnapshot.rects.some((rect) => !rect.receiveShadow)\n const wantsReceivers = nextSnapshot.rects.some((rect) => rect.receiveShadow)\n if (wantsPlain !== (plainRects !== null) || wantsReceivers !== (receivers !== null)) {\n return false\n }\n const strength = liveMotion.strength ?? 18\n const drawable = (key: string): boolean => glyphDrawable(nextBackend, key)\n const decorationsFit = canUpdateDecorationGeometry(\n decorations?.geometry ?? null,\n nextSnapshot,\n drawable,\n )\n if (hasExtras && !decorationsFit) return false\n const glyphsFit =\n decorationsFit &&\n (isWindfoilBackend(nextBackend)\n ? nextBackend.contentFits(text.geometry, nextSnapshot)\n : glyphContentFits(text.geometry, nextSnapshot, nextBackend))\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 built: { geometry: InstancedBufferGeometry; maxSequence: number } | null = null\n let nextParts: readonly (InstancedBufferGeometry | null)[] = []\n let nextPlain: InstancedBufferGeometry | null = null\n let nextReceivers: InstancedBufferGeometry | null = null\n let nextDecorations: ReturnType<typeof prepareDecorations> | null = null\n const releaseStaged = (): void => {\n built?.geometry.dispose()\n for (const geometry of nextParts) geometry?.dispose()\n nextPlain?.dispose()\n nextReceivers?.dispose()\n nextDecorations?.[0]?.dispose()\n nextDecorations?.[1]?.dispose()\n }\n try {\n nextParts = extras?.prepare(nextSnapshot, strength) ?? []\n if (!glyphsFit) built = buildGlyphGeometry(nextSnapshot, nextBackend, strength)\n if (plainRects && !plainFit) nextPlain = createRectGeometry(nextSnapshot, false)\n if (receivers && !receiverFit) nextReceivers = createRectGeometry(nextSnapshot, true)\n if (!decorationsFit) {\n const source = built?.geometry ?? text.geometry\n nextDecorations = prepareDecorations(\n nextSnapshot,\n nextBackend,\n liveMotion,\n source,\n built?.maxSequence ?? textMaterial.maxSequence.value,\n drawable,\n )\n }\n } catch (error) {\n releaseStaged()\n throw error\n }\n if (built) {\n swapGeometry(text, built.geometry)\n textMaterial.maxSequence.value = built.maxSequence\n } else {\n const maxSequence = isWindfoilBackend(nextBackend)\n ? nextBackend.updateGeometry(text.geometry, nextSnapshot, strength)\n : updateGlyphContent(text.geometry, nextSnapshot, nextBackend, strength, undefined, true)\n if (maxSequence === null) {\n releaseStaged()\n throw new Error('DomSdf: glyph buffers changed during the update')\n }\n textMaterial.maxSequence.value = maxSequence\n }\n if (extras) {\n extras.commit(nextParts, nextSnapshot, strength)\n textMaterial.maxSequence.value = maxSeq(nextSnapshot)\n extras.mergeRects(nextSnapshot, text.geometry)\n }\n if (nextDecorations) commitDecorations(nextDecorations, liveMotion)\n else updateDecorations(nextSnapshot, nextBackend, liveMotion, drawable)\n if (plainRects && nextPlain) swapGeometry(plainRects, nextPlain)\n else if (plainRects)\n updateRectGeometry(plainRects.geometry as InstancedBufferGeometry, nextSnapshot, false)\n if (receivers && nextReceivers) swapGeometry(receivers, nextReceivers)\n else if (receivers)\n updateRectGeometry(receivers.geometry as InstancedBufferGeometry, nextSnapshot, true)\n if (nextTone !== undefined) setTone(nextTone)\n return true\n },\n d(): void {\n if (disposed) return\n disposed = true\n disposeMeshes()\n },\n }\n}\n\nexport class DomSdf extends Group {\n readonly renderer: WebGPURenderer\n readonly source: HTMLElement\n readonly options: Readonly<DomSdfOptions>\n protected readonly pageBackdrop: boolean = true\n\n #r: RetainedTextBackend | null = null\n #o = false\n #c: ContentBundle | null = null\n #a: AbortController | null = null\n #g = 0\n #d = false\n #f = 0\n #t = 0\n #dl = 0\n #fa = false\n #ro: ResizeObserver | null = null\n #mo: MutationObserver | null = null\n #uf: (() => void) | null = null\n private snapshot: DomLayoutSnapshot | null = null\n #w = 0\n #h = 0\n #as = ''\n #ls = ''\n #cm = false\n #ga = false\n #ac: Promise<typeof AppendAtlas | null> | undefined\n #st: Readonly<DomSdfStats> = EMPTY_STATS\n #m: SdfMotionOptions\n #to: TracedOutlines | null = null\n\n protected constructor(renderer: WebGPURenderer, source: HTMLElement, options: DomSdfOptions) {\n super()\n this.name = 'ultra-text DOM SDF'\n this.renderer = renderer\n this.source = source\n const copy = { ...options }\n for (const key of [\n 'motion',\n 'windfoil',\n 'slug',\n 'svg',\n 'tone',\n 'outline',\n 'dropShadow',\n ] as const) {\n if (typeof copy[key] === 'object')\n (copy as Record<string, unknown>)[key] = Object.freeze({ ...copy[key] })\n }\n this.options = Object.freeze(copy)\n this.#m = { ...options.motion }\n if (options.selectable) this.source.classList.add('sdf-selectable')\n }\n\n static async create(\n renderer: WebGPURenderer,\n source: HTMLElement,\n options: DomSdfOptions = {},\n ): Promise<DomSdf> {\n const domSdf = new DomSdf(renderer, source, options)\n await domSdf.initialize()\n return domSdf\n }\n\n protected async initialize(): Promise<void> {\n try {\n await this.rebuild({ atlas: true })\n this.#co()\n } catch (error) {\n this.dispose()\n throw error\n }\n }\n\n get width(): number {\n return this.#c ? this.#w : 0\n }\n\n get height(): number {\n return this.#c ? this.#h : 0\n }\n\n get stats(): Readonly<DomSdfStats> {\n return this.#st\n }\n\n get atlasTexture(): SdfAtlas['texture'] | null {\n const retained = this.#r\n return retained\n ? isWindfoilBackend(retained)\n ? (retained.companion?.texture ?? null)\n : retained.texture\n : null\n }\n\n setMotion(options: SdfMotionOptions): this {\n const motion = { ...this.#m, ...options }\n this.#c?.sm(options, motion)\n this.#m = motion\n return this\n }\n\n reflow(width: number): this {\n if (this.#d) throw new Error('DomSdf.reflow: this instance is disposed')\n if (!this.snapshot) {\n throw new Error('DomSdf.reflow: create the instance with reflowable: true first')\n }\n if (!this.#r || !this.#c) return this\n const retained = this.#r\n const content = this.#c\n if (isWindfoilBackend(retained)) retained.setGlyphEm(!!content.m.tone?.dilates)\n\n const started = now()\n const reflowed = reflowSnapshot(this.snapshot, width)\n const strength = this.#m.strength ?? 18\n if (isWindfoilBackend(retained) && (retained.companion || retained.color)) {\n if (!content.u(reflowed, retained, this.#m))\n throw new Error('DomSdf.reflow: incompatible retained content')\n } else {\n let maxSequence = isWindfoilBackend(retained)\n ? retained.updateGeometry(content.tg, reflowed, strength)\n : updateGlyphGeometry(content.tg, reflowed, retained, strength)\n if (maxSequence === null) {\n const built = buildGlyphGeometry(reflowed, retained, strength)\n content.rg(built.geometry)\n maxSequence = built.maxSequence\n }\n content.m.maxSequence.value = maxSequence\n content.ud(reflowed, retained, this.#m)\n }\n this.#cm = false\n this.#w = reflowed.width\n this.#h = reflowed.height\n this.#st = Object.freeze({\n ...this.#st,\n lines: reflowed.lineCount,\n layoutReadMs: 0,\n atlasBuildMs: 0,\n geometryBuildMs: now() - started,\n })\n return this\n }\n\n async rebuild(rebuildOptions: DomSdfRebuildOptions = {}): Promise<void> {\n if (this.#d) throw new Error('DomSdf.rebuild: this instance is disposed')\n const externalSignal = this.options.signal\n if (externalSignal?.aborted) {\n throw externalSignal.reason ?? abortError()\n }\n\n this.#a?.abort(abortError('Superseded by a newer DOM SDF build'))\n const controller = new AbortController()\n this.#a = controller\n const generation = ++this.#g\n const forwardAbort = (): void => {\n controller.abort(externalSignal?.reason ?? abortError())\n }\n externalSignal?.addEventListener('abort', forwardAbort, { once: true })\n\n let nextRetained: RetainedTextBackend | null = null\n let ownsNextRetained = false\n let appended = false\n let nextContent: ContentBundle | null = null\n const staged: { content: ContentBundle | null; atlas: SdfAtlas | null; ms: number } = {\n content: null,\n atlas: null,\n ms: 0,\n }\n try {\n await Promise.resolve()\n throwIfAborted(controller.signal)\n if (generation !== this.#g) {\n throw abortError('Superseded by a newer DOM SDF build')\n }\n\n const opts = this.options\n const gpuUpload =\n opts.atlasMode !== 'cpu' &&\n this.renderer.initialized &&\n (this.renderer.backend as { isWebGPUBackend?: boolean }).isWebGPUBackend === true\n const backendKind = opts.textBackend\n const isAnalyticOption = backendKind === 'windfoil' || backendKind === 'slug'\n if (gpuUpload && !isAnalyticOption && !this.#r) prepareAtlasPasses(this.renderer)\n let preloadBackend: Promise<typeof SlugRuntime | typeof WindfoilRuntime | null> | null = null\n let preloadTraced: Promise<typeof TracedOutlinesModule | null> | null = null\n if (isAnalyticOption && opts.textShaping !== 'browser') {\n preloadBackend = (\n backendKind === 'slug' ? import('../slug/runtime.js') : import('../windfoil/runtime.js')\n ).catch(() => null)\n const analytic =\n (backendKind === 'slug' ? (opts.slug ?? opts.windfoil) : opts.windfoil) ?? {}\n if (!analytic.outlineProvider && !this.#to) {\n preloadTraced = import('../windfoil/tracedOutlines.js').catch(() => null)\n }\n }\n\n const layoutStarted = now()\n const snapshot = await collectDomSnapshot(this.source, opts)\n const tone = resolveDomTextTone(this.source, opts.tone, {\n glyphs: snapshot.glyphs,\n rects: snapshot.rects,\n rootRect:\n opts.includeRootBackground !== false ||\n this.source.matches(opts.rectSelector ?? DEFAULT_RECT_SELECTOR),\n page: this.pageBackdrop,\n })\n const layoutReadMs = now() - layoutStarted\n throwIfAborted(controller.signal)\n\n let bitmap: boolean | undefined\n const atlasCovers = (atlas: SdfAtlas): boolean => {\n if (opts.colorGlyphs === 'none') {\n bitmap ??= snapshot.requests.some((request) => request.shape?.bitmap)\n }\n return snapshot.requests.every((request) => {\n const slot = atlas.glyphs.get(request.key)\n return (\n slot !== undefined &&\n !(opts.colorGlyphs === 'none' && bitmap && !request.shape && slot.color) &&\n (!isColorCandidate(request, opts.colorGlyphs) || slot.color !== undefined)\n )\n })\n }\n const retained = this.#r\n const canReuseRetainedText =\n rebuildOptions.atlas !== true &&\n retained !== null &&\n (this.#as === snapshot.atlasSignature ||\n (isWindfoilBackend(retained)\n ? snapshot.requests.every((request) => retained.covers(request.key))\n : atlasCovers(retained)))\n let signature =\n canReuseRetainedText && this.#c !== null && this.#cm\n ? layoutSignatureOf(snapshot)\n : undefined\n if (\n canReuseRetainedText &&\n this.#c !== null &&\n this.#cm &&\n signature === this.#ls &&\n generation === this.#g &&\n this.#c.st(tone)\n ) {\n this.#st = Object.freeze({\n ...this.#st,\n layoutReadMs,\n atlasBuildMs: 0,\n geometryBuildMs: 0,\n })\n if (opts.svg) this.#om()\n return\n }\n\n let atlasBuildMs = 0\n const sharedAtlas = isAnalyticOption ? undefined : opts.sharedAtlas\n const sharedCovers = sharedAtlas !== undefined && atlasCovers(sharedAtlas)\n if (canReuseRetainedText) {\n nextRetained = retained\n } else if (sharedCovers) {\n nextRetained = sharedAtlas\n ownsNextRetained = false\n } else {\n const atlasStarted = now()\n const appendTo =\n !isAnalyticOption &&\n rebuildOptions.atlas !== true &&\n this.#o &&\n retained &&\n !isWindfoilBackend(retained)\n ? retained\n : null\n const chunk =\n appendTo && (await (this.#ac ??= import('../atlas/appendAtlas.js').catch(() => null)))\n if (appendTo && chunk) {\n this.#ga = true\n nextRetained = await chunk.appendGlyphs(\n this.renderer,\n this.source.ownerDocument,\n appendTo,\n snapshot.requests,\n opts,\n controller.signal,\n )\n appended = !!nextRetained\n }\n const previousAtlas =\n rebuildOptions.atlas !== true &&\n retained !== null &&\n !isWindfoilBackend(retained) &&\n retained !== opts.sharedAtlas\n ? retained\n : undefined\n const buildAtlas = async (\n requests: DomLayoutSnapshot['requests'],\n signal: AbortSignal,\n appendable?: RasterizeOptions['appendable'],\n allowProvisional = false,\n ): Promise<SdfAtlas> => {\n const def = <K extends keyof DomSdfOptions>(...ks: K[]) =>\n Object.fromEntries(ks.flatMap((k) => (opts[k] === undefined ? [] : [[k, opts[k]]])))\n const raster = await rasterizeGlyphAtlas(this.source.ownerDocument, requests, {\n signal,\n previousAtlas,\n appendable,\n ...(gpuUpload ? { gpuUpload } : {}),\n ...def('colorGlyphs', 'bakeSize', 'padding', 'maxAtlasSize', 'adaptiveBakeSize'),\n })\n const atlasOptions = {\n signal,\n mipmaps: opts.quality === 'high',\n anisotropy: opts.quality === 'high' ? 4 : 1,\n ...(opts.atlasMode === undefined ? {} : { mode: opts.atlasMode }),\n ...def('cpuWorker'),\n }\n if (allowProvisional && gpuUpload && opts.quality !== 'high') {\n return buildSdfAtlas(this.renderer, raster, atlasOptions, {\n stage: (provisionalAtlas) => {\n if (signal.aborted || generation !== this.#g || staged.content) return\n const geometryT0 = now()\n try {\n signature ??= layoutSignatureOf(snapshot)\n staged.content = createContent(snapshot, provisionalAtlas, opts, this.#m, tone)\n staged.atlas = provisionalAtlas\n staged.ms = now() - geometryT0\n } catch {\n staged.content = null\n staged.atlas = null\n staged.ms = 0\n }\n },\n rollback: () => {\n staged.content?.d()\n staged.content = null\n staged.atlas = null\n staged.ms = 0\n },\n })\n }\n return buildSdfAtlas(this.renderer, raster, atlasOptions)\n }\n if (!appended && isAnalyticOption && opts.textShaping !== 'browser') {\n const analytic =\n (backendKind === 'slug' ? (opts.slug ?? opts.windfoil) : opts.windfoil) ?? {}\n const outlineProvider: unknown = analytic.outlineProvider\n if (outlineProvider !== undefined && typeof outlineProvider !== 'function') {\n throw new TypeError(\n `DomSdf: textBackend \"${backendKind}\" requires ${backendKind}.outlineProvider`,\n )\n }\n let resolved: WindfoilBuildOptions\n if (analytic.outlineProvider) {\n resolved = { ...analytic, outlineProvider: analytic.outlineProvider }\n } else {\n if (!this.#to) {\n const { createTracedOutlineProvider } =\n (await preloadTraced) ?? (await import('../windfoil/tracedOutlines.js'))\n throwIfAborted(controller.signal)\n this.#to ??= createTracedOutlineProvider(\n this.source.ownerDocument,\n opts.colorGlyphs === undefined ? {} : { colorGlyphs: opts.colorGlyphs },\n )\n } else if (rebuildOptions.atlas === true) {\n this.#to.clear()\n }\n resolved = {\n ...analytic,\n fallback: analytic.fallback ?? 'sdf-glyphs',\n outlineProvider: this.#to.provider,\n }\n }\n const build =\n backendKind === 'slug'\n ? (\n ((await preloadBackend) as typeof SlugRuntime | null) ??\n (await import('../slug/runtime.js'))\n ).buildSlugBackend\n : (\n ((await preloadBackend) as typeof WindfoilRuntime | null) ??\n (await import('../windfoil/runtime.js'))\n ).buildWindfoilBackend\n nextRetained = await build(\n this.renderer,\n snapshot.requests,\n resolved,\n controller.signal,\n { build: buildAtlas, effects: opts },\n )\n }\n if (!appended) {\n nextRetained ??= await buildAtlas(\n snapshot.requests,\n controller.signal,\n this.#ga ? 'headroom' : true,\n true,\n )\n ownsNextRetained = true\n }\n atlasBuildMs = Math.max(0, now() - atlasStarted - staged.ms)\n }\n throwIfAborted(controller.signal)\n if (generation !== this.#g || !nextRetained) {\n throw abortError('Superseded by a newer DOM SDF build')\n }\n\n let geometryBuildMs = 0\n if (\n staged.content !== null &&\n staged.atlas === nextRetained &&\n !isWindfoilBackend(nextRetained)\n ) {\n nextContent = staged.content\n staged.content = null\n staged.atlas = null\n geometryBuildMs = staged.ms\n } else {\n if (staged.content) {\n staged.content.d()\n staged.content = null\n staged.atlas = null\n staged.ms = 0\n }\n const geometryStarted = now()\n if (isWindfoilBackend(nextRetained)) nextRetained.setGlyphEm(!!tone?.dilationPx)\n const updatedInPlace =\n (canReuseRetainedText || appended) &&\n (this.#c?.u(snapshot, nextRetained, this.#m, tone) ?? false)\n if (!updatedInPlace) {\n const extra =\n isWindfoilBackend(nextRetained) && (nextRetained.companion || nextRetained.color)\n ? await import('../windfoil/mixed.js')\n : undefined\n throwIfAborted(controller.signal)\n nextContent = createContent(\n snapshot,\n nextRetained,\n opts,\n this.#m,\n tone,\n extra?.createExtraTextParts,\n )\n }\n geometryBuildMs = now() - geometryStarted\n }\n throwIfAborted(controller.signal)\n\n signature ??= layoutSignatureOf(snapshot)\n\n const oldContent = this.#c\n const oldRetained = this.#r\n let activeContent: ContentBundle\n if (nextContent) {\n if (oldContent) this.remove(oldContent.g)\n this.add(nextContent.g)\n this.#c = nextContent\n activeContent = nextContent\n } else {\n activeContent = oldContent!\n }\n const ownedPrevious = this.#o\n this.#r = nextRetained\n this.#o = canReuseRetainedText || appended ? ownedPrevious : ownsNextRetained\n this.snapshot = opts.reflowable === true ? snapshot : null\n this.#w = snapshot.width\n this.#h = snapshot.height\n this.#as = snapshot.atlasSignature\n this.#ls = signature\n this.#cm = true\n if (opts.svg) this.#om()\n this.#to?.retain(snapshot.requests.map((request) => request.key))\n const windfoil = isWindfoilBackend(nextRetained) ? nextRetained : null\n const atlas = windfoil ? windfoil.companion : (nextRetained as SdfAtlas)\n const glyphs = atlas?.glyphs\n const switchKeys = windfoil?.sizeSwitch?.keys\n let glyphCount = 0\n let shapeCount = 0\n let colorGlyphCount = 0\n let fallbackGlyphCount = 0\n let switchableGlyphCount = 0\n for (const glyph of snapshot.glyphs) {\n if (switchKeys?.has(glyph.glyphKey)) switchableGlyphCount++\n if (glyph.shapeGroup !== undefined) {\n shapeCount++\n continue\n }\n glyphCount++\n const slot = glyphs?.get(glyph.glyphKey)\n if (slot && !windfoil?.analyticCovers(glyph.glyphKey)) {\n if (slot.color) colorGlyphCount++\n if (windfoil) fallbackGlyphCount++\n }\n }\n this.#st = Object.freeze({\n atlasBuildMs,\n layoutReadMs,\n geometryBuildMs,\n glyphs: glyphCount,\n shapes: shapeCount,\n colorGlyphs: colorGlyphCount,\n fallbackGlyphs: fallbackGlyphCount,\n switchableGlyphs: switchableGlyphCount,\n rects: snapshot.rects.length,\n lines: snapshot.lineCount,\n draws: activeContent.g.children.length,\n atlasWidth: atlas?.width ?? 0,\n atlasHeight: atlas?.height ?? 0,\n textBackend: windfoil ? windfoil.kind : ('sdf' as const),\n atlasMode: atlas?.mode ?? null,\n textStorageBytes:\n (windfoil?.storageBytes ?? 0) +\n (atlas ? sdfStorageBytes(atlas, opts.quality === 'high') : 0),\n })\n nextContent = null\n ownsNextRetained = false\n if (oldContent && oldContent !== activeContent) oldContent.d()\n if (oldRetained && oldRetained !== nextRetained && ownedPrevious && !appended) {\n oldRetained.dispose()\n }\n } catch (error) {\n staged.content?.d()\n nextContent?.d()\n if (ownsNextRetained) nextRetained?.dispose()\n throw error\n } finally {\n externalSignal?.removeEventListener('abort', forwardAbort)\n if (this.#a === controller) this.#a = null\n }\n }\n\n #sr(forceAtlas = false, lazy = false): void {\n if (this.#d) return\n this.#fa ||= forceAtlas\n const view = this.source.ownerDocument.defaultView\n if (!view) return\n if (lazy && this.#f === 0) {\n const nowMs = now()\n if (this.#t !== 0) view.clearTimeout(this.#t)\n else this.#dl = nowMs + ATTRIBUTE_MAX_WAIT_MS\n const delay = Math.min(ATTRIBUTE_DEBOUNCE_MS, Math.max(0, this.#dl - nowMs))\n this.#t = view.setTimeout(() => {\n this.#t = 0\n this.#rr()\n }, delay)\n return\n }\n if (this.#t !== 0) {\n view.clearTimeout(this.#t)\n this.#t = 0\n }\n if (this.#f !== 0) return\n this.#f = view.requestAnimationFrame(() => {\n this.#f = 0\n this.#rr()\n })\n }\n\n #rr(): void {\n const atlas = this.#fa\n this.#fa = false\n void this.rebuild({ atlas }).catch((error: unknown) => {\n if (error instanceof DOMException && error.name === 'AbortError') return\n this.options.onError?.(error)\n })\n }\n\n #co(): void {\n if (this.options.observe === false || this.#d) return\n const view = this.source.ownerDocument.defaultView\n if (!view) return\n\n this.#ro = new ResizeObserver(() => {\n this.#sr()\n })\n this.#ro.observe(this.source)\n this.#mo = new MutationObserver((records) => {\n this.#sr(\n false,\n records.every((record) => record.type === 'attributes'),\n )\n })\n this.#om()\n\n const fonts = this.source.ownerDocument.fonts as FontFaceSet | undefined\n if (fonts) {\n const onFontsLoaded = (): void => {\n this.#to?.clear()\n this.#sr(true)\n }\n fonts.addEventListener('loadingdone', onFontsLoaded)\n this.#uf = () => {\n fonts.removeEventListener('loadingdone', onFontsLoaded)\n }\n }\n }\n\n #om(): void {\n const observer = this.#mo\n if (!observer) return\n observer.disconnect()\n const options = { attributes: true, characterData: true, childList: true, subtree: true }\n observer.observe(this.source, options)\n if (!this.options.svg) return\n const seen = new Set<Element>([this.source])\n const pending: Element[] = [this.source]\n while (pending.length) {\n const source = pending.pop()!\n const uses = [...source.querySelectorAll('use')]\n if (source.localName === 'use') uses.unshift(source as SVGUseElement)\n for (const use of uses) {\n const href = use.getAttribute('href') ?? use.getAttribute('xlink:href') ?? ''\n const tree = use.getRootNode() as Document | ShadowRoot\n const target = href.startsWith('#') ? tree.getElementById(href.slice(1)) : null\n if (!target || seen.has(target)) continue\n seen.add(target)\n if (!this.source.contains(target)) observer.observe(target, options)\n pending.push(target)\n }\n }\n }\n\n override dispose(): void {\n if (this.#d) return\n this.#d = true\n this.#g++\n this.#a?.abort(abortError('The DOM SDF instance was disposed'))\n const view = this.source.ownerDocument.defaultView\n if (view && this.#f !== 0) view.cancelAnimationFrame(this.#f)\n if (view && this.#t !== 0) view.clearTimeout(this.#t)\n this.#ro?.disconnect()\n this.#mo?.disconnect()\n this.#uf?.()\n if (this.#c) {\n this.remove(this.#c.g)\n this.#c.d()\n }\n if (this.#o) this.#r?.dispose()\n this.#to?.clear()\n this.#a = this.#ro = this.#mo = this.#uf = this.#c = this.#r = this.#to = this.snapshot = null\n this.#f = this.#t = this.#w = this.#h = 0\n this.#o = this.#cm = false\n this.#as = this.#ls = ''\n this.#st = EMPTY_STATS\n this.source.classList.remove('sdf-selectable')\n this.clear()\n super.dispose()\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;AA6CA,IAAM,cAAqC,OAAO,OAAO;CACvD,cAAc;CACd,cAAc;CACd,iBAAiB;CACjB,QAAQ;CACR,QAAQ;CACR,aAAa;CACb,gBAAgB;CAChB,kBAAkB;CAClB,OAAO;CACP,OAAO;CACP,OAAO;CACP,YAAY;CACZ,aAAa;CACb,aAAa;CACb,WAAW;CACX,kBAAkB;AACpB,CAAC;AAID,SAAS,kBAAkB,SAA0D;CACnF,OAAO,UAAU;AACnB;AAEA,SAAS,mBACP,UACA,SACA,eAC4D;CAC5D,OAAO,kBAAkB,OAAO,IAC5B,QAAQ,eAAe,UAAU,aAAa,IAC9C,oBAAoB,UAAU,SAAS,aAAa;AAC1D;AAEA,SAAS,gBAAgB,OAAiB,SAA0B;CAClE,MAAM,SAAS,GAAW,GAAW,QACnC,IAAI,IAAI,OAAO,YAA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DomSlugOptions, DomSlugRebuildOptions, DomSlugStats, SdfMotionOptions } from '../types.js';
3
+ /**
4
+ * Retained Three.js WebGPU/TSL controller for pure GPU Slug quadratic-curve text (`ultra-text/slug`).
5
+ * Excludes all SDF rasterization, JFA atlas compute, and texture state.
6
+ */
7
+ export declare class DomSlug extends Group {
8
+ #private;
9
+ readonly renderer: WebGPURenderer;
10
+ readonly source: HTMLElement;
11
+ readonly options: Readonly<DomSlugOptions>;
12
+ protected readonly pageBackdrop: boolean;
13
+ private snapshot;
14
+ protected constructor(renderer: WebGPURenderer, source: HTMLElement, options: DomSlugOptions);
15
+ static create(renderer: WebGPURenderer, source: HTMLElement, options?: DomSlugOptions): Promise<DomSlug>;
16
+ protected initialize(): Promise<void>;
17
+ get width(): number;
18
+ get height(): number;
19
+ get stats(): Readonly<DomSlugStats>;
20
+ /** Always `null` on `DomSlug`: pure Slug stores curves in GPU buffers, never textures. */
21
+ readonly atlasTexture: null;
22
+ setMotion(options: SdfMotionOptions): this;
23
+ reflow(width: number): this;
24
+ rebuild(rebuildOptions?: DomSlugRebuildOptions): Promise<void>;
25
+ dispose(): void;
26
+ }