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
@@ -0,0 +1 @@
1
+ {"version":3,"file":"DomSlug.js","names":[],"sources":["../../src/dom/DomSlug.ts"],"sourcesContent":["import { Group, Mesh, type InstancedBufferGeometry, type WebGPURenderer } from 'three/webgpu'\n\nimport {\n buildStandaloneSlugBackend,\n type StandaloneSlugBackend,\n} from '../slug/standaloneRuntime.js'\nimport {\n canUpdateDecorationGeometry,\n createDecorationGeometry,\n TextDecorationMaterial,\n updateDecorationGeometry,\n} from '../text/decorations.js'\nimport {\n createRectGeometry,\n needsRunMotion,\n rectContentFits,\n updateRectGeometry,\n} from '../text/geometry.js'\nimport { isAnimatedMotion, type GlyphTextMaterial } from '../text/GlyphTextMaterial.js'\nimport { createRectMaterial } from '../text/RectMaterial.js'\nimport { reflowSnapshot } from '../text/reflow.js'\nimport type { ResolvedTextTone } from '../text/tone.js'\nimport type {\n DomLayoutSnapshot,\n DomSlugOptions,\n DomSlugRebuildOptions,\n DomSlugStats,\n SdfMotionOptions,\n} from '../types.js'\nimport { createTracedOutlineProvider, type TracedOutlines } from '../windfoil/tracedOutlines.js'\nimport { layoutSignatureOf } from './layoutSignature.js'\nimport { DEFAULT_RECT_SELECTOR } from './markup.js'\nimport { collectDomSnapshot } from './snapshot.js'\nimport { resolveDomTextTone } from './tone.js'\n\nconst EMPTY_SLUG_STATS: Readonly<DomSlugStats> = 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: 'slug',\n atlasMode: null,\n textStorageBytes: 0,\n})\n\nconst ATTRIBUTE_DEBOUNCE_MS = 80\nconst ATTRIBUTE_MAX_WAIT_MS = 320\n\ninterface SlugContentBundle {\n readonly g: Group\n readonly m: GlyphTextMaterial\n readonly tg: InstancedBufferGeometry\n sm(change: SdfMotionOptions, live: SdfMotionOptions): void\n st(tone: ResolvedTextTone | null): boolean\n ud(snapshot: DomLayoutSnapshot, backend: StandaloneSlugBackend, motion: SdfMotionOptions): void\n rg(geometry: InstancedBufferGeometry): void\n u(\n snapshot: DomLayoutSnapshot,\n backend: StandaloneSlugBackend,\n motion: SdfMotionOptions,\n tone?: ResolvedTextTone | null,\n ): boolean\n d(): void\n}\n\nfunction now(): number {\n return performance.now()\n}\n\nfunction abortError(message = 'The DOM Slug 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 createSlugContent(\n snapshot: DomLayoutSnapshot,\n backend: StandaloneSlugBackend,\n options: DomSlugOptions,\n motion: SdfMotionOptions,\n tone: ResolvedTextTone | null,\n): SlugContentBundle {\n const materialOptions = { ...options, tone: tone ?? (false as const) }\n const group = new Group()\n group.name = 'ultra-text generated DOM Slug content'\n group.matrixAutoUpdate = false\n group.updateMatrix()\n\n const strength = motion.strength ?? 18\n let animated = isAnimatedMotion(motion)\n const materialMotion = (live: SdfMotionOptions): SdfMotionOptions | false =>\n animated ? live : false\n const runMotion = needsRunMotion(snapshot)\n const { geometry: glyphGeometry, maxSequence } = backend.createGeometry(snapshot, strength)\n\n let textMaterial: GlyphTextMaterial\n try {\n textMaterial = backend.createMaterial({\n ...materialOptions,\n maxSequence,\n motion: materialMotion(motion),\n })\n } catch (error) {\n glyphGeometry.dispose()\n throw error\n }\n\n const text = new Mesh(glyphGeometry, textMaterial)\n text.name = 'ultra-text slug 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 }\n ownedMeshes.length = 0\n group.clear()\n }\n\n let decorations: Mesh<InstancedBufferGeometry, TextDecorationMaterial> | null = null\n const glyphDrawable = (retained: StandaloneSlugBackend, key: string): boolean =>\n (retained.glyphs.get(key)?.monotonePieceCount ?? 0) > 0\n\n const prepareDecorations = (\n layout: DomLayoutSnapshot,\n retained: StandaloneSlugBackend,\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\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\n const updateDecorations = (\n layout: DomLayoutSnapshot,\n retained: StandaloneSlugBackend,\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\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 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 const setTone = (next: ResolvedTextTone | null): boolean => textMaterial.setTone(next)\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 tg(): InstancedBufferGeometry {\n return text.geometry\n },\n sm(change, live) {\n if (animated) {\n textMaterial.setMotion(change)\n decorations?.material.setMotion(change)\n return\n }\n if (!isAnimatedMotion(live)) return\n const meshes: Mesh<InstancedBufferGeometry, GlyphTextMaterial>[] = [\n text,\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 rg(geometry: InstancedBufferGeometry): void {\n swapGeometry(text, geometry)\n },\n u(nextSnapshot, nextBackend, liveMotion, nextTone) {\n if (\n nextTone !== undefined &&\n (!toneFits(nextTone) || animated !== isAnimatedMotion(liveMotion))\n ) {\n return false\n }\n if (runMotion !== needsRunMotion(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 nextStrength = 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 const glyphsFit = decorationsFit && nextBackend.contentFits(text.geometry, nextSnapshot)\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\n let built: { geometry: InstancedBufferGeometry; maxSequence: number } | null = 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 nextPlain?.dispose()\n nextReceivers?.dispose()\n nextDecorations?.[0]?.dispose()\n nextDecorations?.[1]?.dispose()\n }\n try {\n if (!glyphsFit) built = nextBackend.createGeometry(nextSnapshot, nextStrength)\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\n if (built) {\n swapGeometry(text, built.geometry)\n textMaterial.maxSequence.value = built.maxSequence\n } else {\n const updatedMax = nextBackend.updateGeometry(text.geometry, nextSnapshot, nextStrength)\n if (updatedMax === null) {\n releaseStaged()\n throw new Error('DomSlug: glyph buffers changed during the update')\n }\n textMaterial.maxSequence.value = updatedMax\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 }\n if (receivers && nextReceivers) swapGeometry(receivers, nextReceivers)\n else if (receivers) {\n updateRectGeometry(receivers.geometry as InstancedBufferGeometry, nextSnapshot, true)\n }\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\n/**\n * Retained Three.js WebGPU/TSL controller for pure GPU Slug quadratic-curve text (`ultra-text/slug`).\n * Excludes all SDF rasterization, JFA atlas compute, and texture state.\n */\nexport class DomSlug extends Group {\n readonly renderer: WebGPURenderer\n readonly source: HTMLElement\n readonly options: Readonly<DomSlugOptions>\n protected readonly pageBackdrop: boolean = true\n\n #r: StandaloneSlugBackend | null = null\n #c: SlugContentBundle | 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 #st: Readonly<DomSlugStats> = EMPTY_SLUG_STATS\n #m: SdfMotionOptions\n #to: TracedOutlines | null = null\n\n protected constructor(renderer: WebGPURenderer, source: HTMLElement, options: DomSlugOptions) {\n super()\n this.name = 'ultra-text DOM Slug'\n this.renderer = renderer\n this.source = source\n const copy = { ...options }\n for (const key of ['motion', 'slug', 'svg', 'tone'] as const) {\n if (typeof copy[key] === 'object') {\n ;(copy as Record<string, unknown>)[key] = Object.freeze({ ...copy[key] })\n }\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: DomSlugOptions = {},\n ): Promise<DomSlug> {\n const domSlug = new DomSlug(renderer, source, options)\n await domSlug.initialize()\n return domSlug\n }\n\n protected async initialize(): Promise<void> {\n try {\n await this.rebuild({ outlines: 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<DomSlugStats> {\n return this.#st\n }\n\n /** Always `null` on `DomSlug`: pure Slug stores curves in GPU buffers, never textures. */\n readonly atlasTexture = null\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('DomSlug.reflow: this instance is disposed')\n if (!this.snapshot) {\n throw new Error('DomSlug.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 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 let maxSequence = retained.updateGeometry(content.tg, reflowed, strength)\n if (maxSequence === null) {\n const built = retained.createGeometry(reflowed, 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 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: DomSlugRebuildOptions = {}): Promise<void> {\n if (this.#d) throw new Error('DomSlug.rebuild: this instance is disposed')\n const externalSignal = this.options.signal\n if (externalSignal?.aborted) {\n throw externalSignal.reason ?? abortError()\n }\n const opts = this.options\n if (opts.textShaping === 'browser') {\n throw new Error(\n 'DomSlug: textShaping \"browser\" requires an SDF atlas; use \"none\" (default) for pure Slug outlines',\n )\n }\n\n this.#a?.abort(abortError('Superseded by a newer DOM Slug 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: StandaloneSlugBackend | null = null\n let ownsNextRetained = false\n let nextContent: SlugContentBundle | null = null\n const forceOutlines = rebuildOptions.outlines === true || rebuildOptions.atlas === true\n\n try {\n await Promise.resolve()\n throwIfAborted(controller.signal)\n if (generation !== this.#g) {\n throw abortError('Superseded by a newer DOM Slug build')\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 const retained = this.#r\n const canReuseRetainedText =\n !forceOutlines &&\n retained !== null &&\n (this.#as === snapshot.atlasSignature ||\n snapshot.requests.every((request) => retained.covers(request.key)))\n const signature =\n canReuseRetainedText && this.#c !== null && this.#cm\n ? layoutSignatureOf(snapshot)\n : undefined\n\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 if (canReuseRetainedText) {\n nextRetained = retained\n } else {\n const buildStarted = now()\n const customProvider = opts.outlineProvider ?? opts.slug?.outlineProvider\n if (customProvider !== undefined && typeof customProvider !== 'function') {\n throw new TypeError('DomSlug: outlineProvider must be a function')\n }\n let resolvedProvider = customProvider\n if (!resolvedProvider) {\n if (!this.#to) {\n this.#to = createTracedOutlineProvider(this.source.ownerDocument, {\n ...(opts.colorGlyphs === undefined ? {} : { colorGlyphs: opts.colorGlyphs }),\n ...(opts.traceSize === undefined ? {} : { size: opts.traceSize }),\n ...(opts.traceTolerance === undefined ? {} : { tolerance: opts.traceTolerance }),\n })\n } else if (forceOutlines) {\n this.#to.clear()\n }\n resolvedProvider = this.#to.provider\n }\n const targetPiecesPerBand = opts.targetPiecesPerBand ?? opts.slug?.targetPiecesPerBand\n nextRetained = await buildStandaloneSlugBackend(\n this.renderer,\n snapshot.requests,\n {\n outlineProvider: resolvedProvider,\n missingGlyphs: opts.missingGlyphs ?? (customProvider ? 'error' : 'skip'),\n ...(targetPiecesPerBand === undefined ? {} : { targetPiecesPerBand }),\n },\n controller.signal,\n )\n ownsNextRetained = true\n atlasBuildMs = now() - buildStarted\n }\n throwIfAborted(controller.signal)\n if (generation !== this.#g) {\n throw abortError('Superseded by a newer DOM Slug build')\n }\n\n const geometryStarted = now()\n nextRetained.setGlyphEm(!!tone?.dilationPx)\n const updatedInPlace =\n canReuseRetainedText && (this.#c?.u(snapshot, nextRetained, this.#m, tone) ?? false)\n if (!updatedInPlace) {\n nextContent = createSlugContent(snapshot, nextRetained, opts, this.#m, tone)\n }\n const geometryBuildMs = now() - geometryStarted\n throwIfAborted(controller.signal)\n\n const oldContent = this.#c\n const oldRetained = this.#r\n let activeContent: SlugContentBundle\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 this.#r = nextRetained\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 ?? layoutSignatureOf(snapshot)\n this.#cm = true\n if (opts.svg) this.#om()\n this.#to?.retain(snapshot.requests.map((request) => request.key))\n\n let glyphCount = 0\n let shapeCount = 0\n let skippedCount = 0\n for (const glyph of snapshot.glyphs) {\n if (glyph.shapeGroup !== undefined) {\n shapeCount++\n continue\n }\n glyphCount++\n if (nextRetained.skippedKeys.has(glyph.glyphKey)) skippedCount++\n }\n\n this.#st = Object.freeze({\n atlasBuildMs,\n layoutReadMs,\n geometryBuildMs,\n glyphs: glyphCount,\n shapes: shapeCount,\n colorGlyphs: 0,\n fallbackGlyphs: skippedCount,\n switchableGlyphs: 0,\n rects: snapshot.rects.length,\n lines: snapshot.lineCount,\n draws: activeContent.g.children.length,\n atlasWidth: 0,\n atlasHeight: 0,\n textBackend: 'slug',\n atlasMode: null,\n textStorageBytes: nextRetained.storageBytes,\n })\n nextContent = null\n ownsNextRetained = false\n if (oldContent && oldContent !== activeContent) oldContent.d()\n if (oldRetained && oldRetained !== nextRetained) oldRetained.dispose()\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(forceOutlines = false, lazy = false): void {\n if (this.#d) return\n this.#fa ||= forceOutlines\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 outlines = this.#fa\n this.#fa = false\n void this.rebuild({ outlines }).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 Slug 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 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.#cm = false\n this.#as = this.#ls = ''\n this.#st = EMPTY_SLUG_STATS\n this.source.classList.remove('sdf-selectable')\n this.clear()\n super.dispose()\n }\n}\n"],"mappings":";;;;;;;;;;;;;AAmCA,IAAM,mBAA2C,OAAO,OAAO;CAC7D,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;AAED,IAAM,wBAAwB;AAC9B,IAAM,wBAAwB;AAmB9B,SAAS,MAAc;CACrB,OAAO,YAAY,IAAI;AACzB;AAEA,SAAS,WAAW,UAAU,kCAAgD;CAC5E,OAAO,IAAI,aAAa,SAAS,YAAY;AAC/C;AAEA,SAAS,eAAe,QAA2B;CACjD,IAAI,OAAO,SAAS,MAAM,OAAO,UAAU,WAAW;AACxD;AAEA,SAAS,kBACP,UACA,SACA,SACA,QACA,MACmB;CACnB,MAAM,kBAAkB;EAAE,GAAG;EAAS,MAAM,QAAS;CAAgB;CACrE,MAAM,QAAQ,IAAI,MAAM;CACxB,MAAM,OAAO;CACb,MAAM,mBAAmB;CACzB,MAAM,aAAa;CAEnB,MAAM,WAAW,OAAO,YAAY;CACpC,IAAI,WAAW,iBAAiB,MAAM;CACtC,MAAM,kBAAkB,SACtB,WAAW,OAAO;CACpB,MAAM,YAAY,eAAe,QAAQ;CACzC,MAAM,EAAE,UAAU,eAAe,gBAAgB,QAAQ,eAAe,UAAU,QAAQ;CAE1F,IAAI;CACJ,IAAI;EACF,eAAe,QAAQ,eAAe;GACpC,GAAG;GACH;GACA,QAAQ,eAAe,MAAM;EAC/B,CAAC;CACH,SAAS,OAAO;EACd,cAAc,QAAQ;EACtB,MAAM;CACR;CAEA,MAAM,OAAO,IAAI,KAAK,eAAe,YAAY;CACjD,KAAK,OAAO;CACZ,KAAK,aAAa,QAAQ,eAAe;CACzC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derer } from 'three/webgpu';
2
+ import type { DomSlugOptions, DomSlugRebuildOptions, SlugTextOptions, TextClass, TextCss } from '../types.js';
3
+ import { DomSlug } from './DomSlug.js';
4
+ export declare class SlugText extends DomSlug {
5
+ #private;
6
+ readonly options: Readonly<SlugTextOptions>;
7
+ readonly ready: Promise<this>;
8
+ protected readonly pageBackdrop = false;
9
+ constructor(message: string, options: SlugTextOptions);
10
+ static create(message: string, options: SlugTextOptions): Promise<SlugText>;
11
+ static create(renderer: WebGPURenderer, source: HTMLElement, options?: DomSlugOptions): Promise<DomSlug>;
12
+ get text(): string;
13
+ set text(message: string);
14
+ setCss(css: TextCss): this;
15
+ setClass(cssClass: TextClass): this;
16
+ rebuild(options?: DomSlugRebuildOptions): Promise<void>;
17
+ dispose(): void;
18
+ }
@@ -0,0 +1,94 @@
1
+ import { classNames, copyTextOptions, createTextSource, cssDeclarations, waitForHostFonts } from "./textHost.js";
2
+ import { DomSlug } from "./DomSlug.js";
3
+ // src/dom/SlugText.ts
4
+ var SlugText = class SlugText extends DomSlug {
5
+ ready;
6
+ pageBackdrop = false;
7
+ #h;
8
+ #a = new AbortController();
9
+ #d = false;
10
+ #r = 0;
11
+ #i = false;
12
+ constructor(message, options) {
13
+ const input = copyTextOptions(options);
14
+ const [parent, host, source] = createTextSource(message, input);
15
+ super(input.renderer, source, input);
16
+ this.name = "ultra-text slug string text";
17
+ this.#h = host;
18
+ try {
19
+ parent.append(host);
20
+ } catch (error) {
21
+ this.dispose();
22
+ throw error;
23
+ }
24
+ this.ready = this.#p();
25
+ }
26
+ static async create(messageOrRenderer, optionsOrSource, maybeOptions) {
27
+ if (typeof messageOrRenderer === "string") return new SlugText(messageOrRenderer, optionsOrSource).ready;
28
+ return super.create(messageOrRenderer, optionsOrSource, maybeOptions);
29
+ }
30
+ async #p() {
31
+ try {
32
+ let revision = await this.#wf();
33
+ this.#i = true;
34
+ const initial = this.initialize();
35
+ this.#i = false;
36
+ await initial;
37
+ while (revision !== this.#r) {
38
+ revision = await this.#wf();
39
+ await super.rebuild();
40
+ }
41
+ this.#a.signal.throwIfAborted();
42
+ this.options.signal?.throwIfAborted();
43
+ return this;
44
+ } catch (error) {
45
+ this.dispose();
46
+ throw error;
47
+ }
48
+ }
49
+ async #wf() {
50
+ let revision;
51
+ do {
52
+ revision = this.#r;
53
+ this.source.getBoundingClientRect();
54
+ await waitForHostFonts(this.source.ownerDocument, [this.#a.signal, ...this.options.signal ? [this.options.signal] : []]);
55
+ } while (revision !== this.#r);
56
+ return revision;
57
+ }
58
+ get text() {
59
+ return this.source.textContent;
60
+ }
61
+ set text(message) {
62
+ this.#l();
63
+ this.source.textContent = message;
64
+ }
65
+ setCss(css) {
66
+ this.#l();
67
+ this.source.style.cssText = cssDeclarations(this.source.ownerDocument, css);
68
+ return this;
69
+ }
70
+ setClass(cssClass) {
71
+ this.#l();
72
+ this.source.className = classNames(cssClass);
73
+ if (this.options.selectable) this.source.classList.add("sdf-selectable");
74
+ return this;
75
+ }
76
+ async rebuild(options = {}) {
77
+ if (!this.#i) await this.ready;
78
+ await super.rebuild(options);
79
+ }
80
+ #l() {
81
+ if (this.#d) throw new Error("SlugText: this instance is disposed");
82
+ this.#r++;
83
+ }
84
+ dispose() {
85
+ if (this.#d) return;
86
+ this.#d = true;
87
+ this.#a.abort(new DOMException("The SlugText instance was disposed", "AbortError"));
88
+ super.dispose();
89
+ this.#h.remove();
90
+ }
91
+ };
92
+ export { SlugText };
93
+
94
+ //# sourceMappingURL=SlugText.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"SlugText.js","names":[],"sources":["../../src/dom/SlugText.ts"],"sourcesContent":["import type { WebGPURenderer } from 'three/webgpu'\n\nimport type {\n DomSlugOptions,\n DomSlugRebuildOptions,\n SlugTextOptions,\n TextClass,\n TextCss,\n} from '../types.js'\nimport { DomSlug } from './DomSlug.js'\nimport {\n classNames,\n copyTextOptions,\n createTextSource,\n cssDeclarations,\n waitForHostFonts,\n} from './textHost.js'\n\nexport class SlugText extends DomSlug {\n declare readonly options: Readonly<SlugTextOptions>\n readonly ready: Promise<this>\n protected override readonly pageBackdrop = false\n #h: HTMLElement\n #a = new AbortController()\n #d = false\n #r = 0\n #i = false\n\n constructor(message: string, options: SlugTextOptions) {\n const input = copyTextOptions(options)\n const [parent, host, source] = createTextSource(message, input)\n super(input.renderer, source, input)\n this.name = 'ultra-text slug string text'\n this.#h = host\n try {\n parent.append(host)\n } catch (error) {\n this.dispose()\n throw error\n }\n this.ready = this.#p()\n }\n\n static override create(message: string, options: SlugTextOptions): Promise<SlugText>\n static override create(\n renderer: WebGPURenderer,\n source: HTMLElement,\n options?: DomSlugOptions,\n ): Promise<DomSlug>\n static override async create(\n messageOrRenderer: string | WebGPURenderer,\n optionsOrSource: SlugTextOptions | HTMLElement,\n maybeOptions?: DomSlugOptions,\n ): Promise<DomSlug> {\n if (typeof messageOrRenderer === 'string') {\n const instance = new SlugText(messageOrRenderer, optionsOrSource as SlugTextOptions)\n return instance.ready\n }\n return super.create(messageOrRenderer, optionsOrSource as HTMLElement, maybeOptions)\n }\n\n async #p(): Promise<this> {\n try {\n let revision = await this.#wf()\n this.#i = true\n const initial = this.initialize()\n this.#i = false\n await initial\n while (revision !== this.#r) {\n revision = await this.#wf()\n await super.rebuild()\n }\n this.#a.signal.throwIfAborted()\n this.options.signal?.throwIfAborted()\n return this\n } catch (error) {\n this.dispose()\n throw error\n }\n }\n\n async #wf(): Promise<number> {\n let revision: number\n do {\n revision = this.#r\n this.source.getBoundingClientRect()\n await waitForHostFonts(this.source.ownerDocument, [\n this.#a.signal,\n ...(this.options.signal ? [this.options.signal] : []),\n ])\n } while (revision !== this.#r)\n return revision\n }\n\n get text(): string {\n return this.source.textContent\n }\n\n set text(message: string) {\n this.#l()\n this.source.textContent = message\n }\n\n setCss(css: TextCss): this {\n this.#l()\n this.source.style.cssText = cssDeclarations(this.source.ownerDocument, css)\n return this\n }\n\n setClass(cssClass: TextClass): this {\n this.#l()\n this.source.className = classNames(cssClass)\n if (this.options.selectable) this.source.classList.add('sdf-selectable')\n return this\n }\n\n override async rebuild(options: DomSlugRebuildOptions = {}): Promise<void> {\n if (!this.#i) await this.ready\n await super.rebuild(options)\n }\n\n #l(): void {\n if (this.#d) throw new Error('SlugText: this instance is disposed')\n this.#r++\n }\n\n override dispose(): void {\n if (this.#d) return\n this.#d = true\n this.#a.abort(new DOMException('The SlugText instance was disposed', 'AbortError'))\n super.dispose()\n this.#h.remove()\n }\n}\n"],"mappings":";;;AAkBA,IAAa,WAAb,MAAa,iBAAiB,QAAQ;CAEpC;CACA,eAA2C;CAC3C;CACA,KAAK,IAAI,gBAAgB;CACzB,KAAK;CACL,KAAK;CACL,KAAK;CAEL,YAAY,SAAiB,SAA0B;EACrD,MAAM,QAAQ,gBAAgB,OAAO;EACrC,MAAM,CAAC,QAAQ,MAAM,UAAU,iBAAiB,SAAS,KAAK;EAC9D,MAAM,MAAM,UAAU,QAAQ,KAAK;EACnC,KAAK,OAAO;EACZ,KAAK,KAAK;EACV,IAAI;GACF,OAAO,OAAO,IAAI;EACpB,SAAS,OAAO;GACd,KAAK,QAAQ;GACb,MAAM;EACR;EACA,KAAK,QAAQ,KAAK,GAAG;CACvB;CAQA,aAAsB,OACpB,mBACA,iBACA,cACkB;EAClB,IAAI,OAAO,sBAAsB,UAE/B,OAAO,IADc,SAAS,mBAAmB,eAC1C,CAAA,CAAS;EAElB,OAAO,MAAM,OAAO,mBAAmB,iBAAgC,YAAY;CACrF;CAEA,MAAM,KAAoB;EACxB,IAAI;GACF,IAAI,WAAW,MAAM,KAAK,IAAI;GAC9B,KAAK,KAAK;GACV,MAAM,UAAU,KAAK,WAAW;GAChC,KAAK,KAAK;GACV,MAAM;GACN,OAAO,aAAa,KAAK,IAAI;IAC3B,WAAW,MAAM,KAAK,IAAI;IAC1B,MAAM,MAAM,QAAQ;GACtB;GACA,KAAK,GAAG,OAAO,eAAe;GAC9B,KAAK,QAAQ,QAAQ,eAAe;GACpC,OAAO;EACT,SAAS,OAAO;GACd,KAAK,QAAQ;GACb,MAAM;EACR;CACF;CAEA,MAAM,MAAuB;EAC3B,IAAI;EACJ,GAAG;GACD,WAAW,KAAK;GAChB,KAAK,OAAO,sBAAsB;GAClC,MAAM,iBAAiB,KAAK,OAAO,eAAe,CAChD,KAAK,GAAG,QACR,GAAI,KAAK,QAAQ,SAAS,CAAC,KAAK,QAAQ,MAAM,IAAI,CAAC,CACrD,CAAC;EACH,SAAS,aAAa,KAAK;EAC3B,OAAO;CACT;CAEA,IAAI,OAAe;EACjB,OAAO,KAAK,OAAO;CACrB;CAEA,IAAI,KAAK,SAAiB;EACxB,KAAK,GAAG;EACR,KAAK,OAAO,cAAc;CAC5B;CAEA,OAAO,KAAoB;EACzB,KAAK,GAAG;EACR,KAAK,OAAO,MAAM,UAAU,gBAAgB,KAAK,OAAO,eAAe,GAAG;EAC1E,OAAO;CACT;CAEA,SAAS,UAA2B;EAClC,KAAK,GAAG;EACR,KAAK,OAAO,YAAY,WAAW,QAAQ;EAC3C,IAAI,KAAK,QAAQ,YAAY,KAAK,OAAO,UAAU,IAAI,gBAAgB;EACvE,OAAO;CACT;CAEA,MAAe,QAAQ,UAAiC,CAAC,GAAkB;EACzE,IAAI,CAAC,KAAK,IAAI,MAAM,KAAK;EACzB,MAAM,MAAM,QAAQ,OAAO;CAC7B;CAEA,KAAW;EACT,IAAI,KAAK,IAAI,MAAM,IAAI,MAAM,qCAAqC;EAClE,KAAK;CACP;CAEA,UAAyB;EACvB,IAAI,KAAK,IAAI;EACb,KAAK,KAAK;EACV,KAAK,GAAG,MAAM,IAAI,aAAa,sCAAsC,YAAY,CAAC;EAClF,MAAM,QAAQ;EACd,KAAK,GAAG,OAAO;CACjB;AACF"}
package/dist/dom/Text.js CHANGED
@@ -1,69 +1,6 @@
1
1
  import { DomSdf } from "./DomSdf.js";
2
+ import { classNames, copyTextOptions, createTextSource, cssDeclarations, waitForHostFonts } from "./textHost.js";
2
3
  // src/dom/Text.ts
3
- var UNITLESS = new Set("animation-iteration-count aspect-ratio column-count fill-opacity flex flex-grow flex-shrink font-size-adjust font-weight initial-letter line-clamp line-height math-depth opacity order orphans scale stop-opacity stroke-miterlimit stroke-opacity tab-size widows z-index zoom".split(" "));
4
- var UNITLESS_RE = /^(?:border-image-|grid-(?:column|row))/;
5
- function cssDeclarations(document, css) {
6
- if (typeof css === "string") return css;
7
- const style = document.createElement("div").style;
8
- for (const [key, value] of Object.entries(css)) {
9
- if (value === null || value === void 0) continue;
10
- const property = key.startsWith("--") ? key : key === "cssFloat" ? "float" : key.replace(/[A-Z]/g, (letter) => `-${letter.toLowerCase()}`).replace(/^(webkit|moz|ms|o)-/, "-$1-");
11
- const unprefixed = property.replace(/^-(webkit|moz|ms|o)-/, "");
12
- if (typeof value === "number" && !Number.isFinite(value)) throw new TypeError(`Text: CSS ${key} must be finite`);
13
- style.setProperty(property, typeof value === "number" && !key.startsWith("--") && !UNITLESS.has(unprefixed) && !UNITLESS_RE.test(unprefixed) ? `${value}px` : String(value));
14
- }
15
- return style.cssText;
16
- }
17
- function classNames(cssClass) {
18
- const names = typeof cssClass === "string" ? cssClass : Array.isArray(cssClass) ? cssClass.join(" ") : Object.keys(cssClass).filter((k) => cssClass[k]).join(" ");
19
- return [...new Set(names.trim().split(/\s+/).filter(Boolean))].join(" ");
20
- }
21
- function copyOptions(options) {
22
- const { css, cssClass } = options;
23
- return {
24
- ...options,
25
- ...typeof css === "object" ? { css: Object.freeze({ ...css }) } : {},
26
- ...typeof cssClass === "object" ? { cssClass: Object.freeze(Array.isArray(cssClass) ? [...cssClass] : { ...cssClass }) } : {}
27
- };
28
- }
29
- function createSource(message, options) {
30
- const parent = options.parent ?? (typeof globalThis.document === "undefined" ? void 0 : globalThis.document.body);
31
- if (!parent?.isConnected) throw new Error("Text: parent must be connected; create text after document.body is available");
32
- const document = parent.ownerDocument;
33
- const host = document.createElement("div");
34
- host.setAttribute("data-ultra-text-host", "");
35
- host.style.cssText = "position:fixed;left:0;top:0;display:grid;width:max-content;max-width:100%;min-width:1px;min-height:1px;margin:0;padding:0;border:0;clip-path:inset(100%);pointer-events:none;z-index:-2147483648;".replaceAll(";", "!important;") + "white-space:pre-wrap;";
36
- const source = document.createElement("div");
37
- source.setAttribute("data-sdf-block", "");
38
- source.textContent = message;
39
- if (options.css !== void 0) source.style.cssText = cssDeclarations(document, options.css);
40
- if (options.cssClass !== void 0) source.className = classNames(options.cssClass);
41
- host.append(source);
42
- return [
43
- parent,
44
- host,
45
- source
46
- ];
47
- }
48
- function waitForFonts(document, signals) {
49
- return new Promise((resolve, reject) => {
50
- const cleanup = () => {
51
- for (const s of signals) s.removeEventListener("abort", aborted);
52
- };
53
- const aborted = () => {
54
- cleanup();
55
- reject(signals.find((s) => s.aborted)?.reason ?? new DOMException("Text initialization was aborted", "AbortError"));
56
- };
57
- if (signals.some((s) => s.aborted)) {
58
- aborted();
59
- return;
60
- }
61
- for (const s of signals) s.addEventListener("abort", aborted, { once: true });
62
- Promise.resolve(document.fonts?.ready).finally(cleanup).then(() => {
63
- resolve();
64
- }, reject);
65
- });
66
- }
67
4
  var Text = class extends DomSdf {
68
5
  ready;
69
6
  pageBackdrop = false;
@@ -73,8 +10,8 @@ var Text = class extends DomSdf {
73
10
  #r = 0;
74
11
  #i = false;
75
12
  constructor(message, options) {
76
- const input = copyOptions(options);
77
- const [parent, host, source] = createSource(message, input);
13
+ const input = copyTextOptions(options);
14
+ const [parent, host, source] = createTextSource(message, input);
78
15
  super(input.renderer, source, input);
79
16
  this.name = "ultra-text string text";
80
17
  this.#h = host;
@@ -110,7 +47,7 @@ var Text = class extends DomSdf {
110
47
  do {
111
48
  revision = this.#r;
112
49
  this.source.getBoundingClientRect();
113
- await waitForFonts(this.source.ownerDocument, [this.#a.signal, ...this.options.signal ? [this.options.signal] : []]);
50
+ await waitForHostFonts(this.source.ownerDocument, [this.#a.signal, ...this.options.signal ? [this.options.signal] : []]);
114
51
  } while (revision !== this.#r);
115
52
  return revision;
116
53
  }
@@ -1 +1 @@
1
- {"version":3,"file":"Text.js","names":[],"sources":["../../src/dom/Text.ts"],"sourcesContent":["import type { TextClass, TextCss, TextOptions } from '../types.js'\nimport { DomSdf, type DomSdfRebuildOptions } from './DomSdf.js'\n\nconst UNITLESS = new Set(\n 'animation-iteration-count aspect-ratio column-count fill-opacity flex flex-grow flex-shrink font-size-adjust font-weight initial-letter line-clamp line-height math-depth opacity order orphans scale stop-opacity stroke-miterlimit stroke-opacity tab-size widows z-index zoom'.split(\n ' ',\n ),\n)\nconst UNITLESS_RE = /^(?:border-image-|grid-(?:column|row))/\n\nfunction cssDeclarations(document: Document, css: TextCss): string {\n if (typeof css === 'string') return css\n const style = document.createElement('div').style\n for (const [key, value] of Object.entries(css)) {\n if (value === null || value === undefined) continue\n const property = key.startsWith('--')\n ? key\n : key === 'cssFloat'\n ? 'float'\n : key\n .replace(/[A-Z]/g, (letter) => `-${letter.toLowerCase()}`)\n .replace(/^(webkit|moz|ms|o)-/, '-$1-')\n const unprefixed = property.replace(/^-(webkit|moz|ms|o)-/, '')\n if (typeof value === 'number' && !Number.isFinite(value))\n throw new TypeError(`Text: CSS ${key} must be finite`)\n style.setProperty(\n property,\n typeof value === 'number' &&\n !key.startsWith('--') &&\n !UNITLESS.has(unprefixed) &&\n !UNITLESS_RE.test(unprefixed)\n ? `${value}px`\n : String(value),\n )\n }\n return style.cssText\n}\n\nfunction classNames(cssClass: TextClass): string {\n const names =\n typeof cssClass === 'string'\n ? cssClass\n : Array.isArray(cssClass)\n ? cssClass.join(' ')\n : Object.keys(cssClass)\n .filter((k) => (cssClass as Readonly<Record<string, boolean | undefined>>)[k])\n .join(' ')\n return [...new Set(names.trim().split(/\\s+/).filter(Boolean))].join(' ')\n}\n\nfunction copyOptions(options: TextOptions): TextOptions {\n const { css, cssClass } = options\n return {\n ...options,\n ...(typeof css === 'object' ? { css: Object.freeze({ ...css }) } : {}),\n ...(typeof cssClass === 'object'\n ? {\n cssClass: Object.freeze(\n Array.isArray(cssClass)\n ? [...(cssClass as readonly string[])]\n : { ...(cssClass as object) },\n ),\n }\n : {}),\n }\n}\n\nfunction createSource(\n message: string,\n options: TextOptions,\n): readonly [HTMLElement, HTMLElement, HTMLElement] {\n const parent =\n options.parent ??\n (typeof globalThis.document === 'undefined' ? undefined : globalThis.document.body)\n if (!parent?.isConnected)\n throw new Error('Text: parent must be connected; create text after document.body is available')\n const document = parent.ownerDocument\n const host = document.createElement('div')\n host.setAttribute('data-ultra-text-host', '')\n host.style.cssText =\n 'position:fixed;left:0;top:0;display:grid;width:max-content;max-width:100%;min-width:1px;min-height:1px;margin:0;padding:0;border:0;clip-path:inset(100%);pointer-events:none;z-index:-2147483648;'.replaceAll(\n ';',\n '!important;',\n ) + 'white-space:pre-wrap;'\n const source = document.createElement('div')\n source.setAttribute('data-sdf-block', '')\n source.textContent = message\n if (options.css !== undefined) source.style.cssText = cssDeclarations(document, options.css)\n if (options.cssClass !== undefined) source.className = classNames(options.cssClass)\n host.append(source)\n return [parent, host, source]\n}\n\nfunction waitForFonts(document: Document, signals: readonly AbortSignal[]): Promise<void> {\n return new Promise((resolve, reject) => {\n const cleanup = () => {\n for (const s of signals) s.removeEventListener('abort', aborted)\n }\n const aborted = () => {\n cleanup()\n // eslint-disable-next-line @typescript-eslint/prefer-promise-reject-errors\n reject(\n signals.find((s) => s.aborted)?.reason ??\n new DOMException('Text initialization was aborted', 'AbortError'),\n )\n }\n if (signals.some((s) => s.aborted)) {\n aborted()\n return\n }\n for (const s of signals) s.addEventListener('abort', aborted, { once: true })\n void Promise.resolve((document.fonts as FontFaceSet | undefined)?.ready)\n .finally(cleanup)\n .then(() => {\n resolve()\n }, reject)\n })\n}\n\nexport class Text extends DomSdf {\n declare readonly options: Readonly<TextOptions>\n readonly ready: Promise<this>\n protected override readonly pageBackdrop = false\n #h: HTMLElement\n #a = new AbortController()\n #d = false\n #r = 0\n #i = false\n\n constructor(message: string, options: TextOptions) {\n const input = copyOptions(options)\n const [parent, host, source] = createSource(message, input)\n super(input.renderer, source, input)\n this.name = 'ultra-text string text'\n this.#h = host\n try {\n parent.append(host)\n } catch (error) {\n this.dispose()\n throw error\n }\n this.ready = this.#p()\n }\n\n async #p(): Promise<this> {\n try {\n let revision = await this.#wf()\n this.#i = true\n const initial = this.initialize()\n this.#i = false\n await initial\n while (revision !== this.#r) {\n revision = await this.#wf()\n await super.rebuild()\n }\n this.#a.signal.throwIfAborted()\n this.options.signal?.throwIfAborted()\n return this\n } catch (error) {\n this.dispose()\n throw error\n }\n }\n\n async #wf(): Promise<number> {\n let revision: number\n do {\n revision = this.#r\n this.source.getBoundingClientRect()\n await waitForFonts(this.source.ownerDocument, [\n this.#a.signal,\n ...(this.options.signal ? [this.options.signal] : []),\n ])\n } while (revision !== this.#r)\n return revision\n }\n\n get text(): string {\n return this.source.textContent\n }\n\n set text(message: string) {\n this.#l()\n this.source.textContent = message\n }\n\n setCss(css: TextCss): this {\n this.#l()\n this.source.style.cssText = cssDeclarations(this.source.ownerDocument, css)\n return this\n }\n\n setClass(cssClass: TextClass): this {\n this.#l()\n this.source.className = classNames(cssClass)\n if (this.options.selectable) this.source.classList.add('sdf-selectable')\n return this\n }\n\n override async rebuild(options: DomSdfRebuildOptions = {}): Promise<void> {\n if (!this.#i) await this.ready\n await super.rebuild(options)\n }\n\n #l(): void {\n if (this.#d) throw new Error('Text: this instance is disposed')\n this.#r++\n }\n\n override dispose(): void {\n if (this.#d) return\n this.#d = true\n this.#a.abort(new DOMException('The Text instance was disposed', 'AbortError'))\n super.dispose()\n this.#h.remove()\n }\n}\n"],"mappings":";;AAGA,IAAM,WAAW,IAAI,IACnB,mRAAmR,MACjR,GACF,CACF;AACA,IAAM,cAAc;AAEpB,SAAS,gBAAgB,UAAoB,KAAsB;CACjE,IAAI,OAAO,QAAQ,UAAU,OAAO;CACpC,MAAM,QAAQ,SAAS,cAAc,KAAK,CAAC,CAAC;CAC5C,KAAK,MAAM,CAAC,KAAK,UAAU,OAAO,QAAQ,GAAG,GAAG;EA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AK,GAAG;EACR,KAAK,OAAO,YAAY,WAAW,QAAQ;EAC3C,IAAI,KAAK,QAAQ,YAAY,KAAK,OAAO,UAAU,IAAI,gBAAgB;EACvE,OAAO;CACT;CAEA,MAAe,QAAQ,UAAgC,CAAC,GAAkB;EACxE,IAAI,CAAC,KAAK,IAAI,MAAM,KAAK;EACzB,MAAM,MAAM,QAAQ,OAAO;CAC7B;CAEA,KAAW;EACT,IAAI,KAAK,IAAI,MAAM,IAAI,MAAM,iCAAiC;EAC9D,KAAK;CACP;CAEA,UAAyB;EACvB,IAAI,KAAK,IAAI;EACb,KAAK,KAAK;EACV,KAAK,GAAG,MAAM,IAAI,aAAa,kCAAkC,YAAY,CAAC;EAC9E,MAAM,QAAQ;EACd,KAAK,GAAG,OAAO;CACjB;AACF"}
1
+ {"version":3,"file":"Text.js","names":[],"sources":["../../src/dom/Text.ts"],"sourcesContent":["import type { TextClass, TextCss, TextOptions } from '../types.js'\nimport { DomSdf, type DomSdfRebuildOptions } from './DomSdf.js'\nimport {\n classNames,\n copyTextOptions,\n createTextSource,\n cssDeclarations,\n waitForHostFonts,\n} from './textHost.js'\n\nexport class Text extends DomSdf {\n declare readonly options: Readonly<TextOptions>\n readonly ready: Promise<this>\n protected override readonly pageBackdrop = false\n #h: HTMLElement\n #a = new AbortController()\n #d = false\n #r = 0\n #i = false\n\n constructor(message: string, options: TextOptions) {\n const input = copyTextOptions(options)\n const [parent, host, source] = createTextSource(message, input)\n super(input.renderer, source, input)\n this.name = 'ultra-text string text'\n this.#h = host\n try {\n parent.append(host)\n } catch (error) {\n this.dispose()\n throw error\n }\n this.ready = this.#p()\n }\n\n async #p(): Promise<this> {\n try {\n let revision = await this.#wf()\n this.#i = true\n const initial = this.initialize()\n this.#i = false\n await initial\n while (revision !== this.#r) {\n revision = await this.#wf()\n await super.rebuild()\n }\n this.#a.signal.throwIfAborted()\n this.options.signal?.throwIfAborted()\n return this\n } catch (error) {\n this.dispose()\n throw error\n }\n }\n\n async #wf(): Promise<number> {\n let revision: number\n do {\n revision = this.#r\n this.source.getBoundingClientRect()\n await waitForHostFonts(this.source.ownerDocument, [\n this.#a.signal,\n ...(this.options.signal ? [this.options.signal] : []),\n ])\n } while (revision !== this.#r)\n return revision\n }\n\n get text(): string {\n return this.source.textContent\n }\n\n set text(message: string) {\n this.#l()\n this.source.textContent = message\n }\n\n setCss(css: TextCss): this {\n this.#l()\n this.source.style.cssText = cssDeclarations(this.source.ownerDocument, css)\n return this\n }\n\n setClass(cssClass: TextClass): this {\n this.#l()\n this.source.className = classNames(cssClass)\n if (this.options.selectable) this.source.classList.add('sdf-selectable')\n return this\n }\n\n override async rebuild(options: DomSdfRebuildOptions = {}): Promise<void> {\n if (!this.#i) await this.ready\n await super.rebuild(options)\n }\n\n #l(): void {\n if (this.#d) throw new Error('Text: this instance is disposed')\n this.#r++\n }\n\n override dispose(): void {\n if (this.#d) return\n this.#d = true\n this.#a.abort(new DOMException('The Text instance was disposed', 'AbortError'))\n super.dispose()\n this.#h.remove()\n }\n}\n"],"mappings":";;;AAUA,IAAa,OAAb,cAA0B,OAAO;CAE/B;CACA,eAA2C;CAC3C;CACA,KAAK,IAAI,gBAAgB;CACzB,KAAK;CACL,KAAK;CACL,KAAK;CAEL,YAAY,SAAiB,SAAsB;EACjD,MAAM,QAAQ,gBAAgB,OAAO;EACrC,MAAM,CAAC,QAAQ,MAAM,UAAU,iBAAiB,SAAS,KAAK;EAC9D,MAAM,MAAM,UAAU,QAAQ,KAAK;EACnC,KAAK,OAAO;EACZ,KAAK,KAAK;EACV,IAAI;GACF,OAAO,OAAO,IAAI;EACpB,SAAS,OAAO;GACd,KAAK,QAAQ;GACb,MAAM;EACR;EACA,KAAK,QAAQ,KAAK,GAAG;CACvB;CAEA,MAAM,KAAoB;EACxB,IAAI;GACF,IAAI,WAAW,MAAM,KAAK,IAAI;GAC9B,KAAK,KAAK;GACV,MAAM,UAAU,KAAK,WAAW;GAChC,KAAK,KAAK;GACV,MAAM;GACN,OAAO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F"}
@@ -0,0 +1,2 @@
1
+ import type { setShapingContext } from './browserShaping.js';
2
+ export type ShapingContext = typeof setShapingContext;
@@ -0,0 +1,101 @@
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 = /\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
+ for (const [property, value] of [
55
+ ["all", "initial"],
56
+ ["display", "none"],
57
+ ["direction", "ltr"],
58
+ ["-webkit-font-smoothing", "antialiased"],
59
+ ["-moz-osx-font-smoothing", "grayscale"]
60
+ ]) canvas.style.setProperty(property, value, "important");
61
+ canvas.dir = "ltr";
62
+ canvas.lang = "";
63
+ document.documentElement.append(canvas);
64
+ return canvas;
65
+ }
66
+ /** @internal True when the document has a FontFaceSet whose registered faces are all loaded. */
67
+ function allFontsLoaded(document) {
68
+ const fonts = document.fonts;
69
+ if (fonts?.status !== "loaded") return false;
70
+ const faceSet = fonts;
71
+ if (typeof faceSet.load !== "function" || "mock" in faceSet.load || typeof faceSet.check !== "function" || "mock" in faceSet.check || typeof faceSet[Symbol.iterator] !== "function") return false;
72
+ for (const face of fonts) if (face.status !== "loaded") return false;
73
+ return true;
74
+ }
75
+ /** @internal Loads every face the text requests draw with; shared with the outline tracer. */
76
+ async function waitForFonts(document, requests, signal) {
77
+ if (signal?.aborted) throw signal.reason ?? new DOMException("The atlas build was aborted", "AbortError");
78
+ const fonts = document.fonts;
79
+ if (!fonts || allFontsLoaded(document)) return;
80
+ const byFont = /* @__PURE__ */ new Map();
81
+ for (const request of requests) {
82
+ if (request.shape) continue;
83
+ const current = byFont.get(request.font.key);
84
+ if (current) current.text += request.character;
85
+ else byFont.set(request.font.key, {
86
+ font: request.font.canvasFont,
87
+ text: request.character
88
+ });
89
+ }
90
+ const ok = fonts.status === "loaded" && !("mock" in fonts.load);
91
+ await Promise.all(Array.from(byFont.values(), (i) => {
92
+ try {
93
+ if (ok && fonts.check(i.font, i.text)) return;
94
+ } catch {}
95
+ return fonts.load(i.font, i.text);
96
+ }));
97
+ if (signal?.aborted) throw signal.reason ?? new DOMException("The atlas build was aborted", "AbortError");
98
+ }
99
+ export { allFontsLoaded, createCanvas, isColorCandidate, setFontContext, waitForFonts };
100
+
101
+ //# 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 (/\\b(?:(?:all-)?(?:small|petite)-caps|unicase|titling-caps)\\b/.exec(font.variant)?.[0] ??\n '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 for (const [property, value] of [\n ['all', 'initial'],\n ['display', 'none'],\n ['direction', 'ltr'],\n ['-webkit-font-smoothing', 'antialiased'],\n ['-moz-osx-font-smoothing', 'grayscale'],\n ] as const)\n canvas.style.setProperty(property, value, '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"],"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,KA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AAW,UAAU,OAAO;CACvC,MAAM,UAAU;CAKhB,IACE,OAAO,QAAQ,SAAS,cACxB,UAAU,QAAQ,QAClB,OAAO,QAAQ,UAAU,cACzB,UAAU,QAAQ,SAClB,OAAO,QAAQ,OAAO,cAAc,YAEpC,OAAO;CAET,KAAK,MAAM,QAAQ,OACjB,IAAI,KAAK,WAAW,UAAU,OAAO;CAEvC,OAAO;AACT;;AAGA,eAAsB,aACpB,UACA,UACA,QACe;CACf,IAAI,QAAQ,SACV,MAAM,OAAO,UAAU,IAAI,aAAa,+BAA+B,YAAY;CAErF,MAAM,QAAQ,SAAS;CACvB,IAAI,CAAC,SAAS,eAAe,QAAQ,GAAG;CACxC,MAAM,yBAAS,IAAI,IAA4C;CAC/D,KAAK,MAAM,WAAW,UAAU;EAC9B,IAAI,QAAQ,OAAO;EACnB,MAAM,UAAU,OAAO,IAAI,QAAQ,KAAK,GAAG;EAC3C,IAAI,SAAS,QAAQ,QAAQ,QAAQ;OAChC,OAAO,IAAI,QAAQ,KAAK,KAAK;GAAE,MAAM,QAAQ,KAAK;GAAY,MAAM,QAAQ;EAAU,CAAC;CAC9F;CACA,MAAM,KAAK,MAAM,WAAW,YAAY,EAAE,UAAW,MAA2B;CAChF,MAAM,QAAQ,IACZ,MAAM,KAAK,OAAO,OAAO,IAAI,MAAM;EACjC,IAAI;GACF,IAAI,MAAM,MAAM,MAAM,EAAE,MAAM,EAAE,IAAI,GAAG;EACzC,QAAQ,CAER;EACA,OAAO,MAAM,KAAK,EAAE,MAAM,EAAE,IAAI;CAClC,CAAC,CACH;CACA,IAAI,QAAQ,SACV,MAAM,OAAO,UAAU,IAAI,aAAa,+BAA+B,YAAY;AAEvF"}
@@ -70,11 +70,38 @@ function layoutSignatureOf(snapshot) {
70
70
  strings.clear();
71
71
  const glyphs = snapshot.glyphs;
72
72
  push(glyphs.length);
73
+ let prevKey;
74
+ let prevKeyId = -1;
73
75
  for (let index = 0, length = glyphs.length; index < length; index++) {
74
76
  const g = glyphs[index];
75
77
  const { clip, color } = g;
76
- walkString(g.glyphKey);
77
- walkString(g.breakBefore);
78
+ const glyphKey = g.glyphKey;
79
+ if (glyphKey === prevKey) {
80
+ push(STRING_ID);
81
+ push(prevKeyId);
82
+ } else {
83
+ prevKey = glyphKey;
84
+ let id = strings.get(glyphKey);
85
+ if (id === void 0) {
86
+ id = strings.size;
87
+ strings.set(glyphKey, id);
88
+ push(STRING);
89
+ push(glyphKey.length);
90
+ for (let i = 0; i < glyphKey.length; i++) push(glyphKey.charCodeAt(i));
91
+ } else {
92
+ push(STRING_ID);
93
+ push(id);
94
+ }
95
+ prevKeyId = id;
96
+ }
97
+ const breakBefore = g.breakBefore;
98
+ if (breakBefore === "none") push(0);
99
+ else if (breakBefore === "soft") push(1);
100
+ else if (breakBefore === "hard") push(2);
101
+ else {
102
+ push(3);
103
+ walkString(breakBefore);
104
+ }
78
105
  if (count > 2024) flush();
79
106
  words[count++] = g.fontSize + 0;
80
107
  words[count++] = g.originX + 0;
@@ -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.hasOwn(root, key)) walk(root[key])\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,OAAqB;CACvC,MAAM,KAAK,QAAQ,IAAI,KAAK;CAC5B,IAAI,O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AM,UAAU;EACxB,WAAW,EAAE,QAAQ;EACrB,WAAW,EAAE,WAAW;EACxB,IAAI,QAAQ,MAAY,MAAM;EAC9B,MAAM,WAAW,EAAE,WAAW;EAC9B,MAAM,WAAW,EAAE,UAAU;EAC7B,MAAM,WAAW,EAAE,aAAa;EAChC,MAAM,WAAW,EAAE,UAAU;EAC7B,MAAM,WAAW,EAAE,QAAQ;EAC3B,MAAM,WAAW,EAAE,WAAW;EAC9B,MAAM,WAAW,EAAE,IAAI;EACvB,MAAM,WAAW,KAAK,KAAK;EAC3B,MAAM,WAAW,KAAK,KAAK;EAC3B,MAAM,WAAW,KAAK,KAAK;EAC3B,MAAM,WAAW,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): 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 let prevKey: string | undefined\n let prevKeyId = -1\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 push(STRING_ID)\n push(prevKeyId)\n } else {\n prevKey = glyphKey\n let id = strings.get(glyphKey)\n if (id === undefined) {\n id = strings.size\n strings.set(glyphKey, id)\n push(STRING)\n push(glyphKey.length)\n for (let i = 0; i < glyphKey.length; i++) push(glyphKey.charCodeAt(i))\n } else {\n push(STRING_ID)\n push(id)\n }\n prevKeyId = id\n }\n const breakBefore: string = g.breakBefore\n if (breakBefore === 'none') push(0)\n else if (breakBefore === 'soft') push(1)\n else if (breakBefore === 'hard') push(2)\n else {\n push(3)\n walkString(breakBefore)\n }\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 !== 'gl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