ultra-text 1.0.2 → 1.0.3

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 (206) hide show
  1. package/README.md +193 -115
  2. package/dist/assets/{cpuSdf.worker--X1Qpmdp.js → cpuSdf.worker-Dy4P5_TI.js} +98 -43
  3. package/dist/assets/cpuSdf.worker-Dy4P5_TI.js.map +1 -0
  4. package/dist/assets/traceOutline.worker-B5uVKmR4.js +1725 -0
  5. package/dist/assets/traceOutline.worker-B5uVKmR4.js.map +1 -0
  6. package/dist/atlas/appendAtlas.js +35 -11
  7. package/dist/atlas/appendAtlas.js.map +1 -1
  8. package/dist/atlas/buildAtlas.js +1 -1
  9. package/dist/atlas/buildAtlas.js.map +1 -1
  10. package/dist/atlas/colorGlyphs.d.ts +0 -10
  11. package/dist/atlas/colorGlyphs.js +97 -155
  12. package/dist/atlas/colorGlyphs.js.map +1 -1
  13. package/dist/atlas/colorTexture.d.ts +1 -0
  14. package/dist/atlas/colorTexture.js +64 -0
  15. package/dist/atlas/colorTexture.js.map +1 -0
  16. package/dist/atlas/cpuAtlas.js +8 -3
  17. package/dist/atlas/cpuAtlas.js.map +1 -1
  18. package/dist/atlas/cpuSdf.d.ts +1 -1
  19. package/dist/atlas/cpuSdf.js +97 -42
  20. package/dist/atlas/cpuSdf.js.map +1 -1
  21. package/dist/atlas/cpuWorker.d.ts +10 -4
  22. package/dist/atlas/cpuWorker.js +99 -49
  23. package/dist/atlas/cpuWorker.js.map +1 -1
  24. package/dist/atlas/gpuAtlas.js +133 -56
  25. package/dist/atlas/gpuAtlas.js.map +1 -1
  26. package/dist/atlas/gpuCommon.d.ts +140 -18
  27. package/dist/atlas/gpuCommon.js +726 -104
  28. package/dist/atlas/gpuCommon.js.map +1 -1
  29. package/dist/atlas/jfaWgsl.d.ts +1 -1
  30. package/dist/atlas/jfaWgsl.js +232 -61
  31. package/dist/atlas/jfaWgsl.js.map +1 -1
  32. package/dist/atlas/rasterize.d.ts +22 -0
  33. package/dist/atlas/rasterize.js +237 -111
  34. package/dist/atlas/rasterize.js.map +1 -1
  35. package/dist/atlas/vanillaCore.js +156 -103
  36. package/dist/atlas/vanillaCore.js.map +1 -1
  37. package/dist/atlas/vanillaCpuAtlas.js +37 -52
  38. package/dist/atlas/vanillaCpuAtlas.js.map +1 -1
  39. package/dist/atlas/vanillaExtras.js +91 -90
  40. package/dist/atlas/vanillaExtras.js.map +1 -1
  41. package/dist/atlas/vanillaGpuHelpers.d.ts +70 -7
  42. package/dist/atlas/vanillaGpuHelpers.js +262 -27
  43. package/dist/atlas/vanillaGpuHelpers.js.map +1 -1
  44. package/dist/dom/DomSdf.js +85 -79
  45. package/dist/dom/DomSdf.js.map +1 -1
  46. package/dist/dom/DomSlug.js +23 -18
  47. package/dist/dom/DomSlug.js.map +1 -1
  48. package/dist/dom/Text.d.ts +4 -1
  49. package/dist/dom/Text.js +5 -1
  50. package/dist/dom/Text.js.map +1 -1
  51. package/dist/dom/browserShaping.js +31 -14
  52. package/dist/dom/browserShaping.js.map +1 -1
  53. package/dist/dom/clusters.js +13 -2
  54. package/dist/dom/clusters.js.map +1 -1
  55. package/dist/dom/cssEffects.d.ts +4 -0
  56. package/dist/dom/cssEffects.js +72 -0
  57. package/dist/dom/cssEffects.js.map +1 -0
  58. package/dist/dom/domAnalytic.d.ts +1 -2
  59. package/dist/dom/domAnalytic.js +1 -1
  60. package/dist/dom/domAnalytic.js.map +1 -1
  61. package/dist/dom/fontCanvas.d.ts +16 -0
  62. package/dist/dom/fontCanvas.js +4 -4
  63. package/dist/dom/fontCanvas.js.map +1 -1
  64. package/dist/dom/layoutSignature.js +28 -12
  65. package/dist/dom/layoutSignature.js.map +1 -1
  66. package/dist/dom/markup.d.ts +10 -0
  67. package/dist/dom/markup.js +16 -1
  68. package/dist/dom/markup.js.map +1 -1
  69. package/dist/dom/pretextLayout.js +27 -19
  70. package/dist/dom/pretextLayout.js.map +1 -1
  71. package/dist/dom/snapshot.d.ts +4 -0
  72. package/dist/dom/snapshot.js +747 -505
  73. package/dist/dom/snapshot.js.map +1 -1
  74. package/dist/dom/snapshotsEqual.d.ts +7 -0
  75. package/dist/dom/snapshotsEqual.js +68 -0
  76. package/dist/dom/snapshotsEqual.js.map +1 -0
  77. package/dist/dom/svgCapture.js +30 -27
  78. package/dist/dom/svgCapture.js.map +1 -1
  79. package/dist/dom/textTransform.d.ts +13 -1
  80. package/dist/dom/textTransform.js +31 -13
  81. package/dist/dom/textTransform.js.map +1 -1
  82. package/dist/dom/tone.js +15 -8
  83. package/dist/dom/tone.js.map +1 -1
  84. package/dist/slug/SlugMaterial.d.ts +6 -0
  85. package/dist/slug/SlugMaterial.js +48 -20
  86. package/dist/slug/SlugMaterial.js.map +1 -1
  87. package/dist/slug/cff.d.ts +5 -0
  88. package/dist/slug/cff.js +780 -0
  89. package/dist/slug/cff.js.map +1 -0
  90. package/dist/slug/coverage.d.ts +3 -3
  91. package/dist/slug/coverage.js +283 -101
  92. package/dist/slug/coverage.js.map +1 -1
  93. package/dist/slug/preprocessCore.d.ts +1 -1
  94. package/dist/slug/preprocessCore.js +100 -80
  95. package/dist/slug/preprocessCore.js.map +1 -1
  96. package/dist/slug/runtime.js +32 -39
  97. package/dist/slug/runtime.js.map +1 -1
  98. package/dist/slug/standaloneRuntime.js +47 -37
  99. package/dist/slug/standaloneRuntime.js.map +1 -1
  100. package/dist/slug/truetype.d.ts +14 -6
  101. package/dist/slug/truetype.js +190 -62
  102. package/dist/slug/truetype.js.map +1 -1
  103. package/dist/slug/vanillaCore.d.ts +74 -4
  104. package/dist/slug/vanillaCore.js +226 -217
  105. package/dist/slug/vanillaCore.js.map +1 -1
  106. package/dist/slug-vanilla.d.ts +1 -1
  107. package/dist/slug-vanilla.js +5 -4
  108. package/dist/slug.d.ts +1 -1
  109. package/dist/slug.js +3 -3
  110. package/dist/text/GlyphTextMaterial.d.ts +5 -0
  111. package/dist/text/GlyphTextMaterial.js +11 -7
  112. package/dist/text/GlyphTextMaterial.js.map +1 -1
  113. package/dist/text/RectMaterial.js +6 -10
  114. package/dist/text/RectMaterial.js.map +1 -1
  115. package/dist/text/SdfTextMaterial.d.ts +9 -3
  116. package/dist/text/SdfTextMaterial.js +122 -37
  117. package/dist/text/SdfTextMaterial.js.map +1 -1
  118. package/dist/text/decorations.d.ts +7 -2
  119. package/dist/text/decorations.js +187 -96
  120. package/dist/text/decorations.js.map +1 -1
  121. package/dist/text/geometryUtils.d.ts +5 -0
  122. package/dist/text/geometryUtils.js +63 -9
  123. package/dist/text/geometryUtils.js.map +1 -1
  124. package/dist/text/glyphGeometry.d.ts +1 -1
  125. package/dist/text/glyphGeometry.js +281 -200
  126. package/dist/text/glyphGeometry.js.map +1 -1
  127. package/dist/text/rectGeometry.js +46 -42
  128. package/dist/text/rectGeometry.js.map +1 -1
  129. package/dist/text/reflow.d.ts +5 -0
  130. package/dist/text/reflow.js +127 -68
  131. package/dist/text/reflow.js.map +1 -1
  132. package/dist/text/snap.d.ts +15 -1
  133. package/dist/text/snap.js +1 -1
  134. package/dist/text/snap.js.map +1 -1
  135. package/dist/text/tone.js +2 -2
  136. package/dist/text/tone.js.map +1 -1
  137. package/dist/types.d.ts +23 -7
  138. package/dist/vanilla.js +1 -1
  139. package/dist/windfoil/WindfoilCompositeMaterial.d.ts +1 -1
  140. package/dist/windfoil/WindfoilCompositeMaterial.js +10 -3
  141. package/dist/windfoil/WindfoilCompositeMaterial.js.map +1 -1
  142. package/dist/windfoil/WindfoilMaterial.d.ts +12 -5
  143. package/dist/windfoil/WindfoilMaterial.js +71 -8
  144. package/dist/windfoil/WindfoilMaterial.js.map +1 -1
  145. package/dist/windfoil/compositeGeometry.js +12 -5
  146. package/dist/windfoil/compositeGeometry.js.map +1 -1
  147. package/dist/windfoil/coverage.d.ts +10 -2
  148. package/dist/windfoil/coverage.js +147 -59
  149. package/dist/windfoil/coverage.js.map +1 -1
  150. package/dist/windfoil/geometry.d.ts +15 -0
  151. package/dist/windfoil/geometry.js +154 -64
  152. package/dist/windfoil/geometry.js.map +1 -1
  153. package/dist/windfoil/layerGrid.js +8 -8
  154. package/dist/windfoil/layerGrid.js.map +1 -1
  155. package/dist/windfoil/mixed.js +13 -4
  156. package/dist/windfoil/mixed.js.map +1 -1
  157. package/dist/windfoil/preprocess.js +2 -2
  158. package/dist/windfoil/preprocessCore.d.ts +1 -0
  159. package/dist/windfoil/preprocessCore.js +63 -36
  160. package/dist/windfoil/preprocessCore.js.map +1 -1
  161. package/dist/windfoil/requests.d.ts +1 -1
  162. package/dist/windfoil/requests.js +11 -4
  163. package/dist/windfoil/requests.js.map +1 -1
  164. package/dist/windfoil/resolveOutline.d.ts +9 -0
  165. package/dist/windfoil/resolveOutline.js +20 -0
  166. package/dist/windfoil/resolveOutline.js.map +1 -0
  167. package/dist/windfoil/runtime.d.ts +1 -0
  168. package/dist/windfoil/runtime.js +8 -24
  169. package/dist/windfoil/runtime.js.map +1 -1
  170. package/dist/windfoil/shapeGeometry.js +80 -34
  171. package/dist/windfoil/shapeGeometry.js.map +1 -1
  172. package/dist/windfoil/sizeSwitch.d.ts +1 -1
  173. package/dist/windfoil/sizeSwitch.js +13 -8
  174. package/dist/windfoil/sizeSwitch.js.map +1 -1
  175. package/dist/windfoil/storage.d.ts +23 -9
  176. package/dist/windfoil/storage.js +49 -30
  177. package/dist/windfoil/storage.js.map +1 -1
  178. package/dist/windfoil/svg/curves.d.ts +20 -0
  179. package/dist/windfoil/svg/curves.js +145 -42
  180. package/dist/windfoil/svg/curves.js.map +1 -1
  181. package/dist/windfoil/svg/document.js +10 -1
  182. package/dist/windfoil/svg/document.js.map +1 -1
  183. package/dist/windfoil/svg/pathConverter.js +66 -50
  184. package/dist/windfoil/svg/pathConverter.js.map +1 -1
  185. package/dist/windfoil/svg/pathData.d.ts +9 -0
  186. package/dist/windfoil/svg/pathData.js +142 -109
  187. package/dist/windfoil/svg/pathData.js.map +1 -1
  188. package/dist/windfoil/svg/winding.js +34 -10
  189. package/dist/windfoil/svg/winding.js.map +1 -1
  190. package/dist/windfoil/trace/contours.js +120 -50
  191. package/dist/windfoil/trace/contours.js.map +1 -1
  192. package/dist/windfoil/trace/fit.js +578 -224
  193. package/dist/windfoil/trace/fit.js.map +1 -1
  194. package/dist/windfoil/trace/traceOutline.worker.d.ts +24 -0
  195. package/dist/windfoil/trace/traceWorker.d.ts +13 -0
  196. package/dist/windfoil/trace/traceWorker.js +192 -0
  197. package/dist/windfoil/trace/traceWorker.js.map +1 -0
  198. package/dist/windfoil/tracedOutlines.d.ts +2 -0
  199. package/dist/windfoil/tracedOutlines.js +335 -70
  200. package/dist/windfoil/tracedOutlines.js.map +1 -1
  201. package/package.json +48 -29
  202. package/skills/ultra-text/SKILL.md +9 -10
  203. package/skills/ultra-text/references/frameworks.md +46 -2
  204. package/skills/ultra-text/references/three-tsl.md +26 -24
  205. package/skills/ultra-text/references/vanilla-webgpu.md +3 -1
  206. package/dist/assets/cpuSdf.worker--X1Qpmdp.js.map +0 -1
@@ -5,12 +5,12 @@ import { rasterizeGlyphAtlas } from "../atlas/rasterize.js";
5
5
  import { resolveDomTextTone } from "./tone.js";
6
6
  import { isAnimatedMotion } from "../text/GlyphTextMaterial.js";
7
7
  import { SdfTextMaterial } from "../text/SdfTextMaterial.js";
8
- import { hasDecorations, needsRunMotion } from "../text/geometryUtils.js";
8
+ import { withImmutableCapture } from "./markup.js";
9
+ import { hasDecorations, isDomSnapshot, needsRunMotion } from "../text/geometryUtils.js";
9
10
  import { createGlyphGeometry, glyphContentFits, updateGlyphContent, updateGlyphGeometry } from "../text/glyphGeometry.js";
10
- import "./markup.js";
11
11
  import { collectDomSnapshot } from "./snapshot.js";
12
- import { layoutSignatureOf } from "./layoutSignature.js";
13
- import { Group, Mesh } from "three/webgpu";
12
+ import { snapshotsEqual } from "./snapshotsEqual.js";
13
+ import { Group, Mesh, WebGPUBackend } from "three/webgpu";
14
14
  // src/dom/DomSdf.ts
15
15
  var EMPTY_STATS = Object.freeze({
16
16
  atlasBuildMs: 0,
@@ -44,6 +44,11 @@ var ATTRIBUTE_MAX_WAIT_MS = 320;
44
44
  function now() {
45
45
  return performance.now();
46
46
  }
47
+ function prepareCpuAtlas(cpuWorker) {
48
+ const useWorker = cpuWorker !== false && typeof Worker !== "undefined";
49
+ import("../atlas/cpuAtlas.js").then((mod) => useWorker ? void 0 : mod.loadCpuEncoder()).catch(() => null);
50
+ return useWorker ? import("../atlas/cpuWorker.js").then(({ prepareCpuWorker }) => prepareCpuWorker()).catch(() => null) : null;
51
+ }
47
52
  function copyDefined(target, source, keys) {
48
53
  const src = source;
49
54
  for (const key of keys) if (src[key] !== void 0) target[key] = src[key];
@@ -54,6 +59,12 @@ function abortError(message = "The DOM SDF build was aborted") {
54
59
  function throwIfAborted(signal) {
55
60
  if (signal.aborted) throw signal.reason ?? abortError();
56
61
  }
62
+ function sameEffect(a, b) {
63
+ if (a === b) return true;
64
+ if (!a || !b || typeof a !== "object" || typeof b !== "object") return false;
65
+ const keys = Object.keys(a);
66
+ return keys.length === Object.keys(b).length && keys.every((k) => a[k] === b[k]);
67
+ }
57
68
  function createContent(snapshot, backend, options, motion, tone, extrasMod) {
58
69
  const materialOptions = {
59
70
  ...options,
@@ -175,7 +186,7 @@ function createContent(snapshot, backend, options, motion, tone, extrasMod) {
175
186
  const strength = liveMotion.strength ?? 18;
176
187
  const drawable = (key) => glyphDrawable(nextBackend, key);
177
188
  const decorationsFit = ce ? ce.decorationsFit(nextSnapshot, drawable) : true;
178
- const glyphsFit = decorationsFit && glyphContentFits(text.geometry, nextSnapshot, nextBackend);
189
+ const glyphsFit = decorationsFit && glyphContentFits(text.geometry, nextSnapshot, nextBackend, void 0, !nextSnapshot.textShaping && !options.svg);
179
190
  let built = null;
180
191
  let stagedExtras = null;
181
192
  const releaseStaged = () => {
@@ -238,12 +249,12 @@ var DomSdf = class DomSdf extends Group {
238
249
  #w = 0;
239
250
  #h = 0;
240
251
  #as = "";
241
- #ls = "";
242
252
  #ps = null;
243
- #pc = null;
244
253
  #cm = false;
245
254
  #ga = false;
255
+ #apm = null;
246
256
  #ac;
257
+ #sb = 0;
247
258
  #st = EMPTY_STATS;
248
259
  #m;
249
260
  #to = null;
@@ -336,6 +347,7 @@ var DomSdf = class DomSdf extends Group {
336
347
  reflowedLines = reflowed.lineCount;
337
348
  }
338
349
  this.#cm = false;
350
+ this.#ps = null;
339
351
  this.#w = reflowedWidth;
340
352
  this.#h = reflowedHeight;
341
353
  this.#st = Object.freeze({
@@ -372,23 +384,37 @@ var DomSdf = class DomSdf extends Group {
372
384
  let reflowPromise = null;
373
385
  try {
374
386
  const opts = this.options;
375
- const backendKind = opts.textBackend;
376
- const isAnalyticOption = backendKind === "windfoil" || backendKind === "slug";
377
- const analytic = (backendKind === "slug" ? opts.slug ?? opts.windfoil : opts.windfoil) ?? {};
378
- const fallback = analytic.fallback ?? (analytic.outlineProvider ? "error" : "sdf-glyphs");
379
- const mayBuildSdf = !isAnalyticOption || opts.textShaping === "browser" || fallback !== "error" || analytic.sdfBelowPx !== void 0 || opts.outline !== void 0 || opts.dropShadow !== void 0;
380
- if (opts.atlasMode === "cpu" && mayBuildSdf && !this.#r) {
381
- import("../atlas/cpuAtlas.js").catch(() => null);
382
- if (opts.cpuWorker !== false && typeof Worker !== "undefined") preparedWorkerPromise = import("../atlas/cpuWorker.js").then(({ prepareCpuWorker }) => prepareCpuWorker()).catch(() => null);
383
- }
387
+ const requestedBackend = opts.textBackend ?? "sdf";
388
+ const mayAutoAnalytic = requestedBackend === "auto";
389
+ const initialAnalytic = requestedBackend === "slug" ? opts.slug ?? opts.windfoil : opts.windfoil;
390
+ const initialSharedAtlas = requestedBackend === "windfoil" || requestedBackend === "slug" ? void 0 : opts.sharedAtlas;
391
+ const prewarm = (requestedBackend === "sdf" || mayAutoAnalytic || opts.textShaping === "browser" || (initialAnalytic?.fallback ?? (initialAnalytic?.outlineProvider ? "error" : "sdf-glyphs")) !== "error" || initialAnalytic?.sdfBelowPx !== void 0 || opts.outline !== void 0 || opts.dropShadow !== void 0) && !this.#r && !initialSharedAtlas;
392
+ if (prewarm && opts.atlasMode === "cpu") preparedWorkerPromise = prepareCpuAtlas(opts.cpuWorker);
384
393
  if (opts.reflowable === true && !this.#rm) reflowPromise = import("../text/reflow.js").then((mod) => {
385
394
  this.#rm = mod;
386
395
  });
387
396
  await Promise.resolve();
388
397
  throwIfAborted(controller.signal);
389
398
  if (generation !== this.#g) throw abortError("Superseded by a newer DOM SDF build");
399
+ let backendKind;
400
+ if (mayAutoAnalytic) {
401
+ if (!this.renderer.initialized && typeof this.renderer.init === "function") {
402
+ await this.renderer.init();
403
+ throwIfAborted(controller.signal);
404
+ if (generation !== this.#g) throw abortError("Superseded by a newer DOM SDF build");
405
+ }
406
+ const backend = this.renderer.backend;
407
+ backendKind = !!backend && (backend.isWebGPUBackend === true || backend instanceof WebGPUBackend) && (backend.device?.limits?.maxVertexBuffers ?? 8) >= 7 ? "slug" : "sdf";
408
+ } else backendKind = requestedBackend;
409
+ const isAnalyticOption = backendKind === "windfoil" || backendKind === "slug";
410
+ const analytic = mayAutoAnalytic && backendKind === "slug" ? {
411
+ ...opts.windfoil,
412
+ ...opts.slug,
413
+ sdfBelowPx: opts.slug?.sdfBelowPx ?? opts.windfoil?.sdfBelowPx ?? opts.bakeSize ?? 96,
414
+ fallback: "sdf-glyphs"
415
+ } : (backendKind === "slug" ? opts.slug ?? opts.windfoil : opts.windfoil) ?? {};
390
416
  const gpuUpload = opts.atlasMode !== "cpu" && this.renderer.initialized && this.renderer.backend.isWebGPUBackend === true;
391
- if (gpuUpload && mayBuildSdf && !this.#r) prepareAtlasPasses(this.renderer, opts.padding);
417
+ if (prewarm && gpuUpload) prepareAtlasPasses(this.renderer, opts.padding);
392
418
  let preloadAnalytic = null;
393
419
  let preloadBackend = null;
394
420
  let preloadTraced = null;
@@ -399,11 +425,16 @@ var DomSdf = class DomSdf extends Group {
399
425
  }
400
426
  const svgPromise = opts.svg && !this.#sm ? import("./svgCapture.js").then((m) => this.#sm = m) : null;
401
427
  const layoutStarted = now();
402
- const snapshot = await collectDomSnapshot(this.source, opts);
428
+ const snapshot = await withImmutableCapture(() => collectDomSnapshot(this.source, opts));
429
+ const resolvedOpts = opts.dropShadow === "css" || opts.outline === "css" ? {
430
+ ...opts,
431
+ dropShadow: opts.dropShadow === "css" ? snapshot.dropShadow : opts.dropShadow,
432
+ outline: opts.outline === "css" ? snapshot.outline : opts.outline
433
+ } : opts;
403
434
  const tone = resolveDomTextTone(this.source, opts.tone, {
404
435
  glyphs: snapshot.glyphs,
405
436
  rects: snapshot.rects,
406
- rootRect: opts.includeRootBackground !== false || this.source.matches(opts.rectSelector ?? "[data-text-rect], [data-sdf-rect]"),
437
+ rootRect: opts.includeRootBackground !== false || snapshot.rects.length > 0 && this.source.matches(opts.rectSelector ?? "[data-text-rect], [data-sdf-rect]"),
407
438
  page: this.pageBackdrop
408
439
  });
409
440
  const layoutReadMs = now() - layoutStarted;
@@ -428,16 +459,11 @@ var DomSdf = class DomSdf extends Group {
428
459
  });
429
460
  };
430
461
  const retained = this.#r;
431
- const canReuseRetainedText = rebuildOptions.atlas !== true && retained !== null && (this.#as === snapshot.atlasSignature || (isWindfoilBackend(retained) ? snapshot.requests.every((request) => retained.covers(request.key)) : atlasCovers(retained)));
432
- if (canReuseRetainedText && this.#c !== null && this.#cm && this.#ls === "") {
433
- const previousSnapshot = this.#ps ?? this.snapshot;
434
- if (previousSnapshot) {
435
- this.#ls = layoutSignatureOf(previousSnapshot);
436
- this.#cs();
437
- }
438
- }
439
- const signature = canReuseRetainedText && this.#c !== null && this.#cm ? layoutSignatureOf(snapshot) : void 0;
440
- if (canReuseRetainedText && this.#c !== null && this.#cm && signature === this.#ls && generation === this.#g && this.#c.st(tone)) {
462
+ const previousSnapshot = this.#ps ?? this.snapshot;
463
+ const effectsChanged = previousSnapshot !== null && (opts.dropShadow === "css" && !sameEffect(previousSnapshot.dropShadow, snapshot.dropShadow) || opts.outline === "css" && !sameEffect(previousSnapshot.outline, snapshot.outline));
464
+ const needsAnalyticUnderlay = retained !== null && isWindfoilBackend(retained) && !retained.effects && effectsChanged && (resolvedOpts.outline !== void 0 || resolvedOpts.dropShadow !== void 0);
465
+ const canReuseRetainedText = rebuildOptions.atlas !== true && !needsAnalyticUnderlay && retained !== null && (this.#as === snapshot.atlasSignature || (isWindfoilBackend(retained) ? snapshot.requests.every((request) => retained.covers(request.key)) : atlasCovers(retained)));
466
+ if (canReuseRetainedText && this.#c !== null && this.#cm && previousSnapshot !== null && snapshotsEqual(previousSnapshot, snapshot) && generation === this.#g && this.#c.st(tone)) {
441
467
  this.#st = Object.freeze({
442
468
  ...this.#st,
443
469
  layoutReadMs,
@@ -457,12 +483,16 @@ var DomSdf = class DomSdf extends Group {
457
483
  ownsNextRetained = false;
458
484
  } else {
459
485
  const atlasStarted = now();
486
+ if (sharedAtlas && !retained) {
487
+ if (gpuUpload) prepareAtlasPasses(this.renderer, opts.padding);
488
+ else if (opts.atlasMode === "cpu") preparedWorkerPromise = prepareCpuAtlas(opts.cpuWorker);
489
+ }
460
490
  if (isAnalyticOption && opts.textShaping !== "browser" && rebuildOptions.atlas !== true && retained !== null && isWindfoilBackend(retained) && retained.append && await retained.append(snapshot.requests, controller.signal)) {
461
491
  appended = true;
462
492
  nextRetained = retained;
463
493
  } else {
464
494
  const appendTo = !isAnalyticOption && rebuildOptions.atlas !== true && this.#o && retained && !isWindfoilBackend(retained) ? retained : null;
465
- const chunk = appendTo && await (this.#ac ??= import("../atlas/appendAtlas.js").catch(() => null));
495
+ const chunk = appendTo ? this.#apm ?? await (this.#ac ??= import("../atlas/appendAtlas.js").then((mod) => this.#apm = mod).catch(() => null)) : null;
466
496
  if (appendTo && chunk) {
467
497
  this.#ga = true;
468
498
  nextRetained = await chunk.appendGlyphs(this.renderer, this.source.ownerDocument, appendTo, snapshot.requests, opts, controller.signal);
@@ -475,7 +505,10 @@ var DomSdf = class DomSdf extends Group {
475
505
  signal,
476
506
  previousAtlas,
477
507
  appendable,
478
- ...gpuUpload ? { gpuUpload } : {}
508
+ ...gpuUpload ? {
509
+ gpuUpload,
510
+ deferColorBleed: true
511
+ } : {}
479
512
  };
480
513
  copyDefined(rasterOptions, opts, [
481
514
  "colorGlyphs",
@@ -499,7 +532,7 @@ var DomSdf = class DomSdf extends Group {
499
532
  if (signal.aborted || generation !== this.#g || staged.content) return;
500
533
  const geometryT0 = now();
501
534
  try {
502
- staged.content = createContent(snapshot, provisionalAtlas, opts, this.#m, tone, this.#em);
535
+ staged.content = createContent(snapshot, provisionalAtlas, resolvedOpts, this.#m, tone, this.#em);
503
536
  staged.atlas = provisionalAtlas;
504
537
  staged.ms = now() - geometryT0;
505
538
  } catch {
@@ -521,12 +554,12 @@ var DomSdf = class DomSdf extends Group {
521
554
  raster.canvas.height = 0;
522
555
  }
523
556
  };
524
- if (!appended && isAnalyticOption && opts.textShaping !== "browser") {
557
+ if (!appended && (backendKind === "windfoil" || backendKind === "slug") && opts.textShaping !== "browser") {
525
558
  if (rebuildOptions.atlas === true) this.#ga = false;
526
559
  else if (retained !== null) this.#ga = true;
527
560
  const am = this.#am ?? (this.#am = await (preloadAnalytic ?? import("./domAnalytic.js")));
528
561
  throwIfAborted(controller.signal);
529
- const res = await am.buildDomAnalyticBackend(this.renderer, this.source.ownerDocument, snapshot, opts, backendKind, analytic, this.#ga, this.#to, rebuildOptions.atlas === true, controller.signal, throwIfAborted, {
562
+ const res = await am.buildDomAnalyticBackend(this.renderer, this.source.ownerDocument, snapshot, resolvedOpts, backendKind, analytic, this.#ga, this.#to, rebuildOptions.atlas === true, controller.signal, throwIfAborted, {
530
563
  preloadBackend,
531
564
  preloadTraced,
532
565
  loadTraced: () => import("../windfoil/tracedOutlines.js"),
@@ -563,14 +596,14 @@ var DomSdf = class DomSdf extends Group {
563
596
  const am = this.#am ?? (this.#am = await (preloadAnalytic ?? import("./domAnalytic.js")));
564
597
  throwIfAborted(controller.signal);
565
598
  const analyticBundle = this.#c;
566
- if (!((canReuseRetainedText || appended) && (analyticBundle?.u(snapshot, nextRetained, this.#m, tone) ?? false))) {
599
+ if (!(!effectsChanged && (canReuseRetainedText || appended) && (analyticBundle?.u(snapshot, nextRetained, this.#m, tone) ?? false))) {
567
600
  const extra = nextRetained.companion || nextRetained.color ? await am.loadMixedExtras() : void 0;
568
601
  throwIfAborted(controller.signal);
569
- nextContent = am.createAnalyticContent(snapshot, nextRetained, opts, this.#m, tone, extra?.createExtraTextParts, this.#em);
602
+ nextContent = am.createAnalyticContent(snapshot, nextRetained, resolvedOpts, this.#m, tone, extra?.createExtraTextParts, this.#em);
570
603
  }
571
604
  } else {
572
605
  const sdfBundle = this.#c;
573
- if (!((canReuseRetainedText || appended) && (sdfBundle?.u(snapshot, nextRetained, this.#m, tone) ?? false))) nextContent = createContent(snapshot, nextRetained, opts, this.#m, tone, this.#em);
606
+ if (!(!effectsChanged && (canReuseRetainedText || appended) && (sdfBundle?.u(snapshot, nextRetained, this.#m, tone) ?? false))) nextContent = createContent(snapshot, nextRetained, resolvedOpts, this.#m, tone, this.#em);
574
607
  }
575
608
  geometryBuildMs = now() - geometryStarted;
576
609
  }
@@ -589,18 +622,13 @@ var DomSdf = class DomSdf extends Group {
589
622
  const ownedPrevious = this.#o;
590
623
  this.#r = nextRetained;
591
624
  this.#o = canReuseRetainedText || appended ? ownedPrevious : ownsNextRetained;
592
- this.#cs();
593
625
  this.snapshot = opts.reflowable === true ? snapshot : null;
626
+ this.#ps = opts.reflowable === true ? null : snapshot;
594
627
  this.#rf = null;
595
628
  this.#w = snapshot.width;
596
629
  this.#h = snapshot.height;
597
630
  this.#as = snapshot.atlasSignature;
598
631
  this.#cm = true;
599
- if (signature !== void 0) this.#ls = signature;
600
- else {
601
- this.#ls = "";
602
- this.#ds(snapshot);
603
- }
604
632
  if (opts.svg) this.#om();
605
633
  this.#to?.retain(snapshot.requests.map((request) => request.key));
606
634
  const windfoil = isWindfoilBackend(nextRetained) ? nextRetained : null;
@@ -611,14 +639,21 @@ var DomSdf = class DomSdf extends Group {
611
639
  let fallbackGlyphCount = 0;
612
640
  let switchableGlyphCount = 0;
613
641
  if (windfoil && this.#am) [glyphCount, shapeCount, colorGlyphCount, fallbackGlyphCount, switchableGlyphCount] = this.#am.countAnalyticStats(snapshot, windfoil);
642
+ else if (isDomSnapshot(snapshot) && atlas?.colorLayer === void 0 && !opts.svg && !snapshot.textShaping) glyphCount = snapshot.glyphs.length;
614
643
  else {
615
644
  const glyphs = atlas?.glyphs;
645
+ let prevKey;
646
+ let prevColor = false;
616
647
  for (const glyph of snapshot.glyphs) if (glyph.shapeGroup !== void 0) shapeCount++;
617
648
  else {
618
649
  glyphCount++;
619
- if (glyphs?.get(glyph.glyphKey)?.color) colorGlyphCount++;
650
+ if (glyphs) {
651
+ const key = glyph.glyphKey;
652
+ if (key === prevKey ? prevColor : (prevKey = key, prevColor = !!glyphs.get(key)?.color)) colorGlyphCount++;
653
+ }
620
654
  }
621
655
  }
656
+ if (nextRetained !== oldRetained || appended) this.#sb = atlas ? sdfStorageBytes(atlas, opts.quality === "high") : 0;
622
657
  this.#st = Object.freeze({
623
658
  atlasBuildMs,
624
659
  layoutReadMs,
@@ -635,7 +670,7 @@ var DomSdf = class DomSdf extends Group {
635
670
  atlasHeight: atlas?.height ?? 0,
636
671
  textBackend: windfoil ? windfoil.kind : "sdf",
637
672
  atlasMode: atlas?.mode ?? null,
638
- textStorageBytes: (windfoil?.storageBytes ?? 0) + (atlas ? sdfStorageBytes(atlas, opts.quality === "high") : 0)
673
+ textStorageBytes: (windfoil?.storageBytes ?? 0) + (atlas ? this.#sb : 0)
639
674
  });
640
675
  nextContent = null;
641
676
  ownsNextRetained = false;
@@ -652,36 +687,6 @@ var DomSdf = class DomSdf extends Group {
652
687
  if (this.#a === controller) this.#a = null;
653
688
  }
654
689
  }
655
- #cs() {
656
- this.#pc?.();
657
- this.#pc = null;
658
- this.#ps = null;
659
- }
660
- #ds(snapshot) {
661
- this.#cs();
662
- if (this.snapshot === snapshot) return;
663
- if (typeof MessageChannel !== "function") {
664
- this.#ls = layoutSignatureOf(snapshot);
665
- return;
666
- }
667
- this.#ps = snapshot;
668
- const { port1, port2 } = new MessageChannel();
669
- const cancel = () => {
670
- port1.onmessage = null;
671
- port1.close();
672
- port2.close();
673
- };
674
- this.#pc = cancel;
675
- port1.onmessage = () => {
676
- cancel();
677
- if (this.#pc === cancel) this.#pc = null;
678
- if (!this.#d && this.#ps === snapshot) {
679
- this.#ps = null;
680
- this.#ls = layoutSignatureOf(snapshot);
681
- }
682
- };
683
- port2.postMessage(null);
684
- }
685
690
  #sr(forceAtlas = false, lazy = false) {
686
691
  if (this.#d) return;
687
692
  this.#fa ||= forceAtlas;
@@ -767,13 +772,14 @@ var DomSdf = class DomSdf extends Group {
767
772
  this.remove(this.#c.g);
768
773
  this.#c.d();
769
774
  }
770
- this.#cs();
771
775
  if (this.#o) this.#r?.dispose();
772
776
  this.#to?.clear();
773
- this.#a = this.#ro = this.#mo = this.#uf = this.#c = this.#r = this.#to = this.snapshot = null;
774
- this.#f = this.#t = this.#w = this.#h = 0;
777
+ this.#rf = null;
778
+ this.#a = this.#ro = this.#mo = this.#uf = this.#c = this.#r = this.#to = this.snapshot = this.#ps = null;
779
+ this.#f = this.#t = this.#w = this.#h = this.#sb = 0;
775
780
  this.#o = this.#cm = false;
776
- this.#as = this.#ls = "";
781
+ this.#apm = null;
782
+ this.#as = "";
777
783
  this.#st = EMPTY_STATS;
778
784
  this.source.classList.remove("sdf-selectable");
779
785
  this.clear();
@@ -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 type { PreparedCpuWorker } from '../atlas/cpuWorker.js'\nimport { prepareAtlasPasses } from '../atlas/gpuAtlas.js'\nimport { isColorCandidate, rasterizeGlyphAtlas, type RasterizeOptions } from '../atlas/rasterize.js'\nimport { isAnimatedMotion, type GlyphTextMaterial } from '../text/GlyphTextMaterial.js'\nimport { SdfTextMaterial } from '../text/SdfTextMaterial.js'\nimport {\n createGlyphGeometry,\n glyphContentFits,\n updateGlyphContent,\n updateGlyphGeometry,\n} from '../text/glyphGeometry.js'\nimport { hasDecorations, needsRunMotion } from '../text/geometryUtils.js'\nimport type * as ReflowModule from '../text/reflow.js'\nimport type { ReflowState } from '../text/reflow.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 * as SlugRuntime from '../slug/runtime.js'\nimport type * as WindfoilRuntime from '../windfoil/runtime.js'\nimport type { WindfoilBackend } from '../windfoil/runtime.js'\nimport type * as TracedOutlinesModule from '../windfoil/tracedOutlines.js'\nimport type { TracedOutlines } from '../windfoil/tracedOutlines.js'\nimport type { AnalyticContentBundle } from './domAnalytic.js'\nimport type * as DomAnalyticModule from './domAnalytic.js'\nimport type { ContentExtrasController, StagedExtras } from './domExtras.js'\nimport type * as DomExtrasModule from './domExtras.js'\nimport type * as SvgCaptureModule from './svgCapture.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 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: SdfAtlas, motion: SdfMotionOptions): void\n rg(geometry: InstancedBufferGeometry): void\n u(\n snapshot: DomLayoutSnapshot,\n backend: SdfAtlas,\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 copyDefined(\n target: Record<string, unknown>,\n source: object,\n keys: readonly string[],\n): void {\n const src = source as Record<string, unknown>\n for (const key of keys) if (src[key] !== undefined) target[key] = src[key]\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: SdfAtlas,\n options: DomSdfOptions,\n motion: SdfMotionOptions,\n tone: ResolvedTextTone | null,\n extrasMod?: typeof DomExtrasModule | null,\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 const strength = motion.strength ?? 18\n let animated = isAnimatedMotion(motion)\n const materialMotion = (live: SdfMotionOptions): SdfMotionOptions | false =>\n animated ? live : false\n const { geometry: glyphGeometry, maxSequence } = createGlyphGeometry(snapshot, backend, strength)\n const usesColor = (layout: DomLayoutSnapshot): boolean =>\n !!backend.colorLayer &&\n (options.colorGlyphs !== 'none' || layout.requests.some((request) => request.shape?.bitmap))\n const colorEnabled = usesColor(snapshot)\n const runMotion = needsRunMotion(snapshot)\n let textMaterial: GlyphTextMaterial\n try {\n textMaterial = 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 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 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 const glyphDrawable = (retained: SdfAtlas, key: string): boolean => retained.glyphs.has(key)\n let ce: ContentExtrasController | null = null\n try {\n if (extrasMod) {\n ce = extrasMod.createContentExtras(\n snapshot,\n text.geometry,\n group,\n ownedMeshes,\n options,\n () => animated,\n motion,\n textMaterial.maxSequence.value,\n (key) => glyphDrawable(backend, key),\n )\n }\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 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 a(): boolean {\n return animated\n },\n sm(change, live) {\n if (animated) {\n textMaterial.setMotion(change)\n ce?.setMotion(change)\n return\n }\n if (!isAnimatedMotion(live)) return\n const decMesh = ce?.decMesh()\n const meshes: Mesh<InstancedBufferGeometry, GlyphTextMaterial>[] = [\n text,\n ...(decMesh ? [decMesh] : []),\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(layout, retained, liveMotion) {\n ce?.updateDec(\n layout,\n text.geometry,\n animated,\n liveMotion,\n textMaterial.maxSequence.value,\n (key) => glyphDrawable(retained, key),\n )\n },\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: SdfAtlas,\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)) return false\n if (colorEnabled !== usesColor(nextSnapshot)) return false\n if (\n ce\n ? !ce.fitsLayout(nextSnapshot)\n : nextSnapshot.rects.length > 0 || hasDecorations(nextSnapshot)\n ) {\n return false\n }\n const strength = liveMotion.strength ?? 18\n const drawable = (key: string): boolean => glyphDrawable(nextBackend, key)\n const decorationsFit = ce ? ce.decorationsFit(nextSnapshot, drawable) : true\n const glyphsFit = decorationsFit && glyphContentFits(text.geometry, nextSnapshot, nextBackend)\n let built: { geometry: InstancedBufferGeometry; maxSequence: number } | null = null\n let stagedExtras: StagedExtras | null = null\n const releaseStaged = (): void => {\n built?.geometry.dispose()\n stagedExtras?.dispose()\n }\n try {\n if (!glyphsFit) built = createGlyphGeometry(nextSnapshot, nextBackend, strength)\n if (ce) {\n stagedExtras = ce.prepare(\n nextSnapshot,\n built?.geometry ?? text.geometry,\n animated,\n liveMotion,\n built?.maxSequence ?? textMaterial.maxSequence.value,\n decorationsFit,\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 = updateGlyphContent(\n text.geometry,\n nextSnapshot,\n nextBackend,\n strength,\n undefined,\n true,\n )\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 ce?.commit(\n stagedExtras!,\n nextSnapshot,\n text.geometry,\n animated,\n liveMotion,\n textMaterial.maxSequence.value,\n drawable,\n swapGeometry,\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\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 | AnalyticContentBundle | 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 #rf: ReflowState | null = null\n #rm: typeof ReflowModule | null = null\n #em: typeof DomExtrasModule | null = null\n #am: typeof DomAnalyticModule | null = null\n #sm: typeof SvgCaptureModule | null = null\n #w = 0\n #h = 0\n #as = ''\n #ls = ''\n #ps: DomLayoutSnapshot | null = null\n #pc: (() => void) | null = null\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 const rm = this.#rm\n if (!this.snapshot || !rm) {\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 const started = now()\n let reflowedWidth: number\n let reflowedHeight: number\n let reflowedLines: number\n if (isWindfoilBackend(retained)) {\n const res = this.#am!.reflowAnalytic(\n this.snapshot,\n retained,\n content as AnalyticContentBundle,\n width,\n this.#m,\n rm,\n this.#rf,\n )\n this.#rf = res.state\n reflowedWidth = res.width\n reflowedHeight = res.height\n reflowedLines = res.lines\n } else {\n const reflowed = rm.reflowSnapshotWithState(\n this.snapshot,\n width,\n (this.#rf ??= rm.createReflowState(this.snapshot)),\n )\n const sdfContent = content as ContentBundle\n const strength = this.#m.strength ?? 18\n let maxSequence = updateGlyphGeometry(sdfContent.tg, reflowed, retained, strength)\n if (maxSequence === null) {\n const built = createGlyphGeometry(reflowed, retained, strength)\n sdfContent.rg(built.geometry)\n maxSequence = built.maxSequence\n }\n sdfContent.m.maxSequence.value = maxSequence\n sdfContent.ud(reflowed, retained, this.#m)\n reflowedWidth = reflowed.width\n reflowedHeight = reflowed.height\n reflowedLines = reflowed.lineCount\n }\n this.#cm = false\n this.#w = reflowedWidth\n this.#h = reflowedHeight\n this.#st = Object.freeze({\n ...this.#st,\n lines: reflowedLines,\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 | AnalyticContentBundle | null = null\n const staged: { content: ContentBundle | null; atlas: SdfAtlas | null; ms: number } = {\n content: null,\n atlas: null,\n ms: 0,\n }\n let preparedWorkerPromise: Promise<PreparedCpuWorker | null> | null = null\n let reflowPromise: Promise<unknown> | null = null\n try {\n const opts = this.options\n const backendKind = opts.textBackend\n const isAnalyticOption = backendKind === 'windfoil' || backendKind === 'slug'\n const analytic = (backendKind === 'slug' ? (opts.slug ?? opts.windfoil) : opts.windfoil) ?? {}\n const fallback = analytic.fallback ?? (analytic.outlineProvider ? 'error' : 'sdf-glyphs')\n const mayBuildSdf =\n !isAnalyticOption ||\n opts.textShaping === 'browser' ||\n fallback !== 'error' ||\n analytic.sdfBelowPx !== undefined ||\n opts.outline !== undefined ||\n opts.dropShadow !== undefined\n if (opts.atlasMode === 'cpu' && mayBuildSdf && !this.#r) {\n void import('../atlas/cpuAtlas.js').catch(() => null)\n if (opts.cpuWorker !== false && typeof Worker !== 'undefined') {\n preparedWorkerPromise = import('../atlas/cpuWorker.js')\n .then(({ prepareCpuWorker }) => prepareCpuWorker())\n .catch(() => null)\n }\n }\n if (opts.reflowable === true && !this.#rm) {\n reflowPromise = import('../text/reflow.js').then((mod) => {\n this.#rm = mod\n })\n }\n\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 gpuUpload =\n opts.atlasMode !== 'cpu' &&\n this.renderer.initialized &&\n (this.renderer.backend as { isWebGPUBackend?: boolean }).isWebGPUBackend === true\n if (gpuUpload && mayBuildSdf && !this.#r) prepareAtlasPasses(this.renderer, opts.padding)\n let preloadAnalytic: Promise<typeof DomAnalyticModule> | null = null\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 if (!this.#am) preloadAnalytic = import('./domAnalytic.js').then((m) => (this.#am = m))\n preloadBackend = (\n backendKind === 'slug' ? import('../slug/runtime.js') : import('../windfoil/runtime.js')\n ).catch(() => null)\n if (!analytic.outlineProvider && !this.#to) {\n preloadTraced = import('../windfoil/tracedOutlines.js').catch(() => null)\n }\n }\n const svgPromise =\n opts.svg && !this.#sm ? import('./svgCapture.js').then((m) => (this.#sm = m)) : null\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 extrasPromise: Promise<unknown> | null =\n !this.#em && (snapshot.rects.length > 0 || hasDecorations(snapshot))\n ? import('./domExtras.js').then((mod) => {\n this.#em = mod\n })\n : null\n const ensureLazyMods = async (): Promise<void> => {\n if (!extrasPromise) return\n const p = extrasPromise\n extrasPromise = null\n await p\n throwIfAborted(controller.signal)\n if (generation !== this.#g) throw abortError('Superseded by a newer DOM SDF build')\n }\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 if (canReuseRetainedText && this.#c !== null && this.#cm && this.#ls === '') {\n const previousSnapshot = this.#ps ?? this.snapshot\n if (previousSnapshot) {\n this.#ls = layoutSignatureOf(previousSnapshot)\n this.#cs()\n }\n }\n const 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 (svgPromise) await svgPromise\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 if (\n isAnalyticOption &&\n opts.textShaping !== 'browser' &&\n rebuildOptions.atlas !== true &&\n retained !== null &&\n isWindfoilBackend(retained) &&\n retained.append &&\n (await retained.append(snapshot.requests, controller.signal))\n ) {\n appended = true\n nextRetained = retained\n } else {\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 }\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 rasterOptions: RasterizeOptions = {\n signal,\n previousAtlas,\n appendable,\n ...(gpuUpload ? { gpuUpload } : {}),\n }\n copyDefined(rasterOptions as Record<string, unknown>, opts, [\n 'colorGlyphs',\n 'bakeSize',\n 'padding',\n 'maxAtlasSize',\n 'adaptiveBakeSize',\n ])\n const raster = await rasterizeGlyphAtlas(\n this.source.ownerDocument,\n requests,\n rasterOptions,\n )\n const atlasOptions: Parameters<typeof buildSdfAtlas>[2] = {\n signal,\n mipmaps: opts.quality === 'high',\n anisotropy: opts.quality === 'high' ? 4 : 1,\n ...(opts.atlasMode === undefined ? {} : { mode: opts.atlasMode }),\n }\n copyDefined(atlasOptions as Record<string, unknown>, opts, ['cpuWorker'])\n await ensureLazyMods()\n try {\n if (allowProvisional && gpuUpload && opts.quality !== 'high') {\n return await buildSdfAtlas(\n this.renderer,\n raster,\n atlasOptions,\n {\n stage: (provisionalAtlas) => {\n if (signal.aborted || generation !== this.#g || staged.content) return\n const geometryT0 = now()\n try {\n staged.content = createContent(\n snapshot,\n provisionalAtlas,\n opts,\n this.#m,\n tone,\n this.#em,\n )\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 preparedWorkerPromise ?? undefined,\n )\n }\n return await (preparedWorkerPromise\n ? buildSdfAtlas(this.renderer, raster, atlasOptions, undefined, preparedWorkerPromise)\n : buildSdfAtlas(this.renderer, raster, atlasOptions))\n } finally {\n raster.canvas.width = 0\n raster.canvas.height = 0\n }\n }\n if (!appended && isAnalyticOption && opts.textShaping !== 'browser') {\n if (rebuildOptions.atlas === true) this.#ga = false\n else if (retained !== null) this.#ga = true\n const am = this.#am ?? (this.#am = await (preloadAnalytic ?? import('./domAnalytic.js')))\n throwIfAborted(controller.signal)\n const res = await am.buildDomAnalyticBackend(\n this.renderer,\n this.source.ownerDocument,\n snapshot,\n opts,\n backendKind,\n analytic,\n this.#ga,\n this.#to,\n rebuildOptions.atlas === true,\n controller.signal,\n throwIfAborted,\n {\n preloadBackend,\n preloadTraced,\n loadTraced: () => import('../windfoil/tracedOutlines.js'),\n buildAtlas,\n },\n )\n if (res.traced) this.#to = res.traced\n nextRetained = res.retained\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 await ensureLazyMods()\n const geometryStarted = now()\n if (isWindfoilBackend(nextRetained)) {\n nextRetained.setGlyphEm(!!tone?.dilationPx)\n const am = this.#am ?? (this.#am = await (preloadAnalytic ?? import('./domAnalytic.js')))\n throwIfAborted(controller.signal)\n const analyticBundle = this.#c as AnalyticContentBundle | null\n const updatedInPlace =\n (canReuseRetainedText || appended) &&\n (analyticBundle?.u(snapshot, nextRetained, this.#m, tone) ?? false)\n if (!updatedInPlace) {\n const extra =\n nextRetained.companion || nextRetained.color ? await am.loadMixedExtras() : undefined\n throwIfAborted(controller.signal)\n nextContent = am.createAnalyticContent(\n snapshot,\n nextRetained,\n opts,\n this.#m,\n tone,\n extra?.createExtraTextParts,\n this.#em,\n )\n }\n } else {\n const sdfBundle = this.#c as ContentBundle | null\n const updatedInPlace =\n (canReuseRetainedText || appended) &&\n (sdfBundle?.u(snapshot, nextRetained, this.#m, tone) ?? false)\n if (!updatedInPlace) {\n nextContent = createContent(snapshot, nextRetained, opts, this.#m, tone, this.#em)\n }\n }\n geometryBuildMs = now() - geometryStarted\n }\n if (reflowPromise) await reflowPromise\n if (svgPromise) await svgPromise\n throwIfAborted(controller.signal)\n\n const oldContent = this.#c\n const oldRetained = this.#r\n let activeContent: ContentBundle | AnalyticContentBundle\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.#cs()\n this.snapshot = opts.reflowable === true ? snapshot : null\n this.#rf = null\n this.#w = snapshot.width\n this.#h = snapshot.height\n this.#as = snapshot.atlasSignature\n this.#cm = true\n if (signature !== undefined) {\n this.#ls = signature\n } else {\n this.#ls = ''\n this.#ds(snapshot)\n }\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 let glyphCount = 0\n let shapeCount = 0\n let colorGlyphCount = 0\n let fallbackGlyphCount = 0\n let switchableGlyphCount = 0\n if (windfoil && this.#am) {\n ;[glyphCount, shapeCount, colorGlyphCount, fallbackGlyphCount, switchableGlyphCount] =\n this.#am.countAnalyticStats(snapshot, windfoil)\n } else {\n const glyphs = atlas?.glyphs\n for (const glyph of snapshot.glyphs) {\n if (glyph.shapeGroup !== undefined) {\n shapeCount++\n } else {\n glyphCount++\n if (glyphs?.get(glyph.glyphKey)?.color) colorGlyphCount++\n }\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 void preparedWorkerPromise?.then((worker) => worker?.dispose())\n externalSignal?.removeEventListener('abort', forwardAbort)\n if (this.#a === controller) this.#a = null\n }\n }\n\n #cs(): void {\n this.#pc?.()\n this.#pc = null\n this.#ps = null\n }\n\n #ds(snapshot: DomLayoutSnapshot): void {\n this.#cs()\n if (this.snapshot === snapshot) return\n if (typeof MessageChannel !== 'function') {\n this.#ls = layoutSignatureOf(snapshot)\n return\n }\n this.#ps = snapshot\n const { port1, port2 } = new MessageChannel()\n const cancel = (): void => {\n port1.onmessage = null\n port1.close()\n port2.close()\n }\n this.#pc = cancel\n port1.onmessage = () => {\n cancel()\n if (this.#pc === cancel) this.#pc = null\n if (!this.#d && this.#ps === snapshot) {\n this.#ps = null\n this.#ls = layoutSignatureOf(snapshot)\n }\n }\n port2.postMessage(null)\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) this.#sm?.observeSvgUses(observer, this.source, options)\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 this.#cs()\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":";;;;;;;;;;;;;;AAyCA,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,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;;AAqBA,IAAM,wBAAwB;;AAE9B,IAAM,wBAAwB;AAU9B,SAAS,MAAc;CACrB,OAAO,YAAY,IAAI;AACzB;AAEA,SAAS,YACP,QACA,QACA,MACM;CACN,MAAM,MAAM;CACZ,KAAK,MAAM,OAAO,MAAM,IAAI,IAAI,SAAS,KAAA,GAAW,OAAO,OAAO,IAAI;AACxE;AAEA,SAAS,WAAW,UAAU,iCAA+C;CAC3E,OAAO,IAAI,aAAa,SAAS,YAAY;AAC/C;AAEA,SAAS,eAAe,QAA2B;CACjD,IAAI,OAAO,SAAS,MAAM,OAAO,UAAU,WAAW;AACxD;AAEA,SA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,UAAU;GAAE,YAAY;GAAM,eAAe;GAAM,WAAW;GAAM,SAAS;EAAK;EACxF,SAAS,QAAQ,KAAK,QAAQ,OAAO;EACrC,IAAI,KAAK,QAAQ,KAAK,KAAK,KAAK,eAAe,UAAU,KAAK,QAAQ,OAAO;CAC/E;CAEA,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,KAAK,IAAI;EACT,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 {\n Group,\n Mesh,\n WebGPUBackend,\n type InstancedBufferGeometry,\n type WebGPURenderer,\n} from 'three/webgpu'\n\nimport type * as AppendAtlas from '../atlas/appendAtlas.js'\nimport { buildSdfAtlas } from '../atlas/buildAtlas.js'\nimport type { PreparedCpuWorker } from '../atlas/cpuWorker.js'\nimport { prepareAtlasPasses } from '../atlas/gpuAtlas.js'\nimport { isColorCandidate, rasterizeGlyphAtlas, type RasterizeOptions } from '../atlas/rasterize.js'\nimport { isAnimatedMotion, type GlyphTextMaterial } from '../text/GlyphTextMaterial.js'\nimport { SdfTextMaterial } from '../text/SdfTextMaterial.js'\nimport {\n createGlyphGeometry,\n glyphContentFits,\n updateGlyphContent,\n updateGlyphGeometry,\n} from '../text/glyphGeometry.js'\nimport { hasDecorations, isDomSnapshot, needsRunMotion } from '../text/geometryUtils.js'\nimport type * as ReflowModule from '../text/reflow.js'\nimport type { ReflowState } from '../text/reflow.js'\nimport type { ResolvedTextTone } from '../text/tone.js'\nimport type {\n DomLayoutSnapshot,\n DomSdfOptions,\n DomSdfStats,\n SdfAtlas,\n SdfDropShadowOptions,\n SdfMotionOptions,\n SdfOutlineOptions,\n WindfoilOptions,\n} from '../types.js'\nimport type * as SlugRuntime from '../slug/runtime.js'\nimport type * as WindfoilRuntime from '../windfoil/runtime.js'\nimport type { WindfoilBackend } from '../windfoil/runtime.js'\nimport type * as TracedOutlinesModule from '../windfoil/tracedOutlines.js'\nimport type { TracedOutlines } from '../windfoil/tracedOutlines.js'\nimport type { AnalyticContentBundle } from './domAnalytic.js'\nimport type * as DomAnalyticModule from './domAnalytic.js'\nimport type { ContentExtrasController, StagedExtras } from './domExtras.js'\nimport type * as DomExtrasModule from './domExtras.js'\nimport type * as SvgCaptureModule from './svgCapture.js'\nimport { DEFAULT_RECT_SELECTOR, withImmutableCapture } from './markup.js'\nimport { collectDomSnapshot } from './snapshot.js'\nimport { snapshotsEqual } from './snapshotsEqual.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 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: SdfAtlas, motion: SdfMotionOptions): void\n rg(geometry: InstancedBufferGeometry): void\n u(\n snapshot: DomLayoutSnapshot,\n backend: SdfAtlas,\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 prepareCpuAtlas(cpuWorker: boolean | undefined): Promise<PreparedCpuWorker | null> | null {\n const useWorker = cpuWorker !== false && typeof Worker !== 'undefined'\n void import('../atlas/cpuAtlas.js')\n .then((mod) => (useWorker ? undefined : mod.loadCpuEncoder()))\n .catch(() => null)\n return useWorker\n ? import('../atlas/cpuWorker.js')\n .then(({ prepareCpuWorker }) => prepareCpuWorker())\n .catch(() => null)\n : null\n}\n\nfunction copyDefined(\n target: Record<string, unknown>,\n source: object,\n keys: readonly string[],\n): void {\n const src = source as Record<string, unknown>\n for (const key of keys) if (src[key] !== undefined) target[key] = src[key]\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\ntype ResolvedEffectsOptions = Omit<DomSdfOptions, 'outline' | 'dropShadow'> & {\n readonly outline?: SdfOutlineOptions | undefined\n readonly dropShadow?: SdfDropShadowOptions | undefined\n}\n\nfunction sameEffect(a: unknown, b: unknown): boolean {\n if (a === b) return true\n if (!a || !b || typeof a !== 'object' || typeof b !== 'object') return false\n const keys = Object.keys(a)\n return (\n keys.length === Object.keys(b).length &&\n keys.every((k) => (a as Record<string, unknown>)[k] === (b as Record<string, unknown>)[k])\n )\n}\n\nfunction createContent(\n snapshot: DomLayoutSnapshot,\n backend: SdfAtlas,\n options: ResolvedEffectsOptions,\n motion: SdfMotionOptions,\n tone: ResolvedTextTone | null,\n extrasMod?: typeof DomExtrasModule | null,\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 const strength = motion.strength ?? 18\n let animated = isAnimatedMotion(motion)\n const materialMotion = (live: SdfMotionOptions): SdfMotionOptions | false =>\n animated ? live : false\n const { geometry: glyphGeometry, maxSequence } = createGlyphGeometry(snapshot, backend, strength)\n const usesColor = (layout: DomLayoutSnapshot): boolean =>\n !!backend.colorLayer &&\n (options.colorGlyphs !== 'none' || layout.requests.some((request) => request.shape?.bitmap))\n const colorEnabled = usesColor(snapshot)\n const runMotion = needsRunMotion(snapshot)\n let textMaterial: GlyphTextMaterial\n try {\n textMaterial = 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 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 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 const glyphDrawable = (retained: SdfAtlas, key: string): boolean => retained.glyphs.has(key)\n let ce: ContentExtrasController | null = null\n try {\n if (extrasMod) {\n ce = extrasMod.createContentExtras(\n snapshot,\n text.geometry,\n group,\n ownedMeshes,\n options,\n () => animated,\n motion,\n textMaterial.maxSequence.value,\n (key) => glyphDrawable(backend, key),\n )\n }\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 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 a(): boolean {\n return animated\n },\n sm(change, live) {\n if (animated) {\n textMaterial.setMotion(change)\n ce?.setMotion(change)\n return\n }\n if (!isAnimatedMotion(live)) return\n const decMesh = ce?.decMesh()\n const meshes: Mesh<InstancedBufferGeometry, GlyphTextMaterial>[] = [\n text,\n ...(decMesh ? [decMesh] : []),\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(layout, retained, liveMotion) {\n ce?.updateDec(\n layout,\n text.geometry,\n animated,\n liveMotion,\n textMaterial.maxSequence.value,\n (key) => glyphDrawable(retained, key),\n )\n },\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: SdfAtlas,\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)) return false\n if (colorEnabled !== usesColor(nextSnapshot)) return false\n if (\n ce\n ? !ce.fitsLayout(nextSnapshot)\n : nextSnapshot.rects.length > 0 || hasDecorations(nextSnapshot)\n ) {\n return false\n }\n const strength = liveMotion.strength ?? 18\n const drawable = (key: string): boolean => glyphDrawable(nextBackend, key)\n const decorationsFit = ce ? ce.decorationsFit(nextSnapshot, drawable) : true\n const glyphsFit =\n decorationsFit &&\n glyphContentFits(\n text.geometry,\n nextSnapshot,\n nextBackend,\n undefined,\n !nextSnapshot.textShaping && !options.svg,\n )\n let built: { geometry: InstancedBufferGeometry; maxSequence: number } | null = null\n let stagedExtras: StagedExtras | null = null\n const releaseStaged = (): void => {\n built?.geometry.dispose()\n stagedExtras?.dispose()\n }\n try {\n if (!glyphsFit) built = createGlyphGeometry(nextSnapshot, nextBackend, strength)\n if (ce) {\n stagedExtras = ce.prepare(\n nextSnapshot,\n built?.geometry ?? text.geometry,\n animated,\n liveMotion,\n built?.maxSequence ?? textMaterial.maxSequence.value,\n decorationsFit,\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 = updateGlyphContent(\n text.geometry,\n nextSnapshot,\n nextBackend,\n strength,\n undefined,\n true,\n )\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 ce?.commit(\n stagedExtras!,\n nextSnapshot,\n text.geometry,\n animated,\n liveMotion,\n textMaterial.maxSequence.value,\n drawable,\n swapGeometry,\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\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 | AnalyticContentBundle | 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 #rf: ReflowState | null = null\n #rm: typeof ReflowModule | null = null\n #em: typeof DomExtrasModule | null = null\n #am: typeof DomAnalyticModule | null = null\n #sm: typeof SvgCaptureModule | null = null\n #w = 0\n #h = 0\n #as = ''\n #ps: DomLayoutSnapshot | null = null\n #cm = false\n #ga = false\n #apm: typeof AppendAtlas | null = null\n #ac: Promise<typeof AppendAtlas | null> | undefined\n #sb = 0\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 const rm = this.#rm\n if (!this.snapshot || !rm) {\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 const started = now()\n let reflowedWidth: number\n let reflowedHeight: number\n let reflowedLines: number\n if (isWindfoilBackend(retained)) {\n const res = this.#am!.reflowAnalytic(\n this.snapshot,\n retained,\n content as AnalyticContentBundle,\n width,\n this.#m,\n rm,\n this.#rf,\n )\n this.#rf = res.state\n reflowedWidth = res.width\n reflowedHeight = res.height\n reflowedLines = res.lines\n } else {\n const reflowed = rm.reflowSnapshotWithState(\n this.snapshot,\n width,\n (this.#rf ??= rm.createReflowState(this.snapshot)),\n )\n const sdfContent = content as ContentBundle\n const strength = this.#m.strength ?? 18\n let maxSequence = updateGlyphGeometry(sdfContent.tg, reflowed, retained, strength)\n if (maxSequence === null) {\n const built = createGlyphGeometry(reflowed, retained, strength)\n sdfContent.rg(built.geometry)\n maxSequence = built.maxSequence\n }\n sdfContent.m.maxSequence.value = maxSequence\n sdfContent.ud(reflowed, retained, this.#m)\n reflowedWidth = reflowed.width\n reflowedHeight = reflowed.height\n reflowedLines = reflowed.lineCount\n }\n this.#cm = false\n this.#ps = null\n this.#w = reflowedWidth\n this.#h = reflowedHeight\n this.#st = Object.freeze({\n ...this.#st,\n lines: reflowedLines,\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 | AnalyticContentBundle | null = null\n const staged: { content: ContentBundle | null; atlas: SdfAtlas | null; ms: number } = {\n content: null,\n atlas: null,\n ms: 0,\n }\n let preparedWorkerPromise: Promise<PreparedCpuWorker | null> | null = null\n let reflowPromise: Promise<unknown> | null = null\n try {\n const opts = this.options\n const requestedBackend = opts.textBackend ?? 'sdf'\n const mayAutoAnalytic = requestedBackend === 'auto'\n const initialAnalytic =\n requestedBackend === 'slug' ? (opts.slug ?? opts.windfoil) : opts.windfoil\n const initialSharedAtlas =\n requestedBackend === 'windfoil' || requestedBackend === 'slug'\n ? undefined\n : opts.sharedAtlas\n const mayBuildSdf =\n requestedBackend === 'sdf' ||\n mayAutoAnalytic ||\n opts.textShaping === 'browser' ||\n (initialAnalytic?.fallback ??\n (initialAnalytic?.outlineProvider ? 'error' : 'sdf-glyphs')) !== 'error' ||\n initialAnalytic?.sdfBelowPx !== undefined ||\n opts.outline !== undefined ||\n opts.dropShadow !== undefined\n const prewarm = mayBuildSdf && !this.#r && !initialSharedAtlas\n if (prewarm && opts.atlasMode === 'cpu') {\n preparedWorkerPromise = prepareCpuAtlas(opts.cpuWorker)\n }\n if (opts.reflowable === true && !this.#rm) {\n reflowPromise = import('../text/reflow.js').then((mod) => {\n this.#rm = mod\n })\n }\n\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 let backendKind: 'sdf' | 'windfoil' | 'slug'\n if (mayAutoAnalytic) {\n if (!this.renderer.initialized && typeof this.renderer.init === 'function') {\n await this.renderer.init()\n throwIfAborted(controller.signal)\n if (generation !== this.#g) throw abortError('Superseded by a newer DOM SDF build')\n }\n const backend = this.renderer.backend as\n | {\n readonly isWebGPUBackend?: boolean\n readonly device?: { readonly limits?: { readonly maxVertexBuffers?: number } }\n }\n | undefined\n const webgpu =\n !!backend &&\n (backend.isWebGPUBackend === true || backend instanceof WebGPUBackend) &&\n ((\n backend as {\n readonly device?: { readonly limits?: { readonly maxVertexBuffers?: number } }\n }\n ).device?.limits?.maxVertexBuffers ?? 8) >= 7\n backendKind = webgpu ? 'slug' : 'sdf'\n } else {\n backendKind = requestedBackend\n }\n const isAnalyticOption = backendKind === 'windfoil' || backendKind === 'slug'\n const analytic: WindfoilOptions =\n mayAutoAnalytic && backendKind === 'slug'\n ? {\n ...opts.windfoil,\n ...opts.slug,\n sdfBelowPx: opts.slug?.sdfBelowPx ?? opts.windfoil?.sdfBelowPx ?? opts.bakeSize ?? 96,\n fallback: 'sdf-glyphs',\n }\n : ((backendKind === 'slug' ? (opts.slug ?? opts.windfoil) : opts.windfoil) ?? {})\n\n const gpuUpload =\n opts.atlasMode !== 'cpu' &&\n this.renderer.initialized &&\n (this.renderer.backend as { isWebGPUBackend?: boolean }).isWebGPUBackend === true\n if (prewarm && gpuUpload) prepareAtlasPasses(this.renderer, opts.padding)\n let preloadAnalytic: Promise<typeof DomAnalyticModule> | null = null\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 if (!this.#am) preloadAnalytic = import('./domAnalytic.js').then((m) => (this.#am = m))\n preloadBackend = (\n backendKind === 'slug' ? import('../slug/runtime.js') : import('../windfoil/runtime.js')\n ).catch(() => null)\n if (!analytic.outlineProvider && !this.#to) {\n preloadTraced = import('../windfoil/tracedOutlines.js').catch(() => null)\n }\n }\n const svgPromise =\n opts.svg && !this.#sm ? import('./svgCapture.js').then((m) => (this.#sm = m)) : null\n\n const layoutStarted = now()\n const snapshot = await withImmutableCapture(() => collectDomSnapshot(this.source, opts))\n const resolvedOpts: ResolvedEffectsOptions =\n opts.dropShadow === 'css' || opts.outline === 'css'\n ? {\n ...opts,\n dropShadow: opts.dropShadow === 'css' ? snapshot.dropShadow : opts.dropShadow,\n outline: opts.outline === 'css' ? snapshot.outline : opts.outline,\n }\n : (opts as ResolvedEffectsOptions)\n const tone = resolveDomTextTone(this.source, opts.tone, {\n glyphs: snapshot.glyphs,\n rects: snapshot.rects,\n rootRect:\n opts.includeRootBackground !== false ||\n (snapshot.rects.length > 0 &&\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 extrasPromise: Promise<unknown> | null =\n !this.#em && (snapshot.rects.length > 0 || hasDecorations(snapshot))\n ? import('./domExtras.js').then((mod) => {\n this.#em = mod\n })\n : null\n const ensureLazyMods = async (): Promise<void> => {\n if (!extrasPromise) return\n const p = extrasPromise\n extrasPromise = null\n await p\n throwIfAborted(controller.signal)\n if (generation !== this.#g) throw abortError('Superseded by a newer DOM SDF build')\n }\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 previousSnapshot = this.#ps ?? this.snapshot\n const effectsChanged =\n previousSnapshot !== null &&\n ((opts.dropShadow === 'css' &&\n !sameEffect(previousSnapshot.dropShadow, snapshot.dropShadow)) ||\n (opts.outline === 'css' && !sameEffect(previousSnapshot.outline, snapshot.outline)))\n const needsAnalyticUnderlay =\n retained !== null &&\n isWindfoilBackend(retained) &&\n !retained.effects &&\n effectsChanged &&\n (resolvedOpts.outline !== undefined || resolvedOpts.dropShadow !== undefined)\n const canReuseRetainedText =\n rebuildOptions.atlas !== true &&\n !needsAnalyticUnderlay &&\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 canCheckSame = canReuseRetainedText && this.#c !== null && this.#cm\n if (\n canCheckSame &&\n previousSnapshot !== null &&\n snapshotsEqual(previousSnapshot, snapshot) &&\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 (svgPromise) await svgPromise\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 // A partial shared atlas still overlaps private pipeline or worker startup with rasterization.\n if (sharedAtlas && !retained) {\n if (gpuUpload) prepareAtlasPasses(this.renderer, opts.padding)\n else if (opts.atlasMode === 'cpu') preparedWorkerPromise = prepareCpuAtlas(opts.cpuWorker)\n }\n if (\n isAnalyticOption &&\n opts.textShaping !== 'browser' &&\n rebuildOptions.atlas !== true &&\n retained !== null &&\n isWindfoilBackend(retained) &&\n retained.append &&\n (await retained.append(snapshot.requests, controller.signal))\n ) {\n appended = true\n nextRetained = retained\n } else {\n const appendTo =\n !isAnalyticOption &&\n rebuildOptions.atlas !== true &&\n this.#o &&\n retained &&\n !isWindfoilBackend(retained)\n ? retained\n : null\n const chunk = appendTo\n ? (this.#apm ??\n (await (this.#ac ??= import('../atlas/appendAtlas.js')\n .then((mod) => (this.#apm = mod))\n .catch(() => null))))\n : 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 }\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 rasterOptions: RasterizeOptions = {\n signal,\n previousAtlas,\n appendable,\n ...(gpuUpload ? { gpuUpload, deferColorBleed: true } : {}),\n }\n copyDefined(rasterOptions as Record<string, unknown>, opts, [\n 'colorGlyphs',\n 'bakeSize',\n 'padding',\n 'maxAtlasSize',\n 'adaptiveBakeSize',\n ])\n const raster = await rasterizeGlyphAtlas(\n this.source.ownerDocument,\n requests,\n rasterOptions,\n )\n const atlasOptions: Parameters<typeof buildSdfAtlas>[2] = {\n signal,\n mipmaps: opts.quality === 'high',\n anisotropy: opts.quality === 'high' ? 4 : 1,\n ...(opts.atlasMode === undefined ? {} : { mode: opts.atlasMode }),\n }\n copyDefined(atlasOptions as Record<string, unknown>, opts, ['cpuWorker'])\n await ensureLazyMods()\n try {\n if (allowProvisional && gpuUpload && opts.quality !== 'high') {\n return await buildSdfAtlas(\n this.renderer,\n raster,\n atlasOptions,\n {\n stage: (provisionalAtlas) => {\n if (signal.aborted || generation !== this.#g || staged.content) return\n const geometryT0 = now()\n try {\n staged.content = createContent(\n snapshot,\n provisionalAtlas,\n resolvedOpts,\n this.#m,\n tone,\n this.#em,\n )\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 preparedWorkerPromise ?? undefined,\n )\n }\n return await (preparedWorkerPromise\n ? buildSdfAtlas(this.renderer, raster, atlasOptions, undefined, preparedWorkerPromise)\n : buildSdfAtlas(this.renderer, raster, atlasOptions))\n } finally {\n raster.canvas.width = 0\n raster.canvas.height = 0\n }\n }\n if (\n !appended &&\n (backendKind === 'windfoil' || backendKind === 'slug') &&\n opts.textShaping !== 'browser'\n ) {\n if (rebuildOptions.atlas === true) this.#ga = false\n else if (retained !== null) this.#ga = true\n const am = this.#am ?? (this.#am = await (preloadAnalytic ?? import('./domAnalytic.js')))\n throwIfAborted(controller.signal)\n const res = await am.buildDomAnalyticBackend(\n this.renderer,\n this.source.ownerDocument,\n snapshot,\n resolvedOpts as DomSdfOptions,\n backendKind,\n analytic,\n this.#ga,\n this.#to,\n rebuildOptions.atlas === true,\n controller.signal,\n throwIfAborted,\n {\n preloadBackend,\n preloadTraced,\n loadTraced: () => import('../windfoil/tracedOutlines.js'),\n buildAtlas,\n },\n )\n if (res.traced) this.#to = res.traced\n nextRetained = res.retained\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 await ensureLazyMods()\n const geometryStarted = now()\n if (isWindfoilBackend(nextRetained)) {\n nextRetained.setGlyphEm(!!tone?.dilationPx)\n const am = this.#am ?? (this.#am = await (preloadAnalytic ?? import('./domAnalytic.js')))\n throwIfAborted(controller.signal)\n const analyticBundle = this.#c as AnalyticContentBundle | null\n const updatedInPlace =\n !effectsChanged &&\n (canReuseRetainedText || appended) &&\n (analyticBundle?.u(snapshot, nextRetained, this.#m, tone) ?? false)\n if (!updatedInPlace) {\n const extra =\n nextRetained.companion || nextRetained.color ? await am.loadMixedExtras() : undefined\n throwIfAborted(controller.signal)\n nextContent = am.createAnalyticContent(\n snapshot,\n nextRetained,\n resolvedOpts as DomSdfOptions,\n this.#m,\n tone,\n extra?.createExtraTextParts,\n this.#em,\n )\n }\n } else {\n const sdfBundle = this.#c as ContentBundle | null\n const updatedInPlace =\n !effectsChanged &&\n (canReuseRetainedText || appended) &&\n (sdfBundle?.u(snapshot, nextRetained, this.#m, tone) ?? false)\n if (!updatedInPlace) {\n nextContent = createContent(\n snapshot,\n nextRetained,\n resolvedOpts,\n this.#m,\n tone,\n this.#em,\n )\n }\n }\n geometryBuildMs = now() - geometryStarted\n }\n if (reflowPromise) await reflowPromise\n if (svgPromise) await svgPromise\n throwIfAborted(controller.signal)\n\n const oldContent = this.#c\n const oldRetained = this.#r\n let activeContent: ContentBundle | AnalyticContentBundle\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.#ps = opts.reflowable === true ? null : snapshot\n this.#rf = null\n this.#w = snapshot.width\n this.#h = snapshot.height\n this.#as = snapshot.atlasSignature\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 let glyphCount = 0\n let shapeCount = 0\n let colorGlyphCount = 0\n let fallbackGlyphCount = 0\n let switchableGlyphCount = 0\n if (windfoil && this.#am) {\n ;[glyphCount, shapeCount, colorGlyphCount, fallbackGlyphCount, switchableGlyphCount] =\n this.#am.countAnalyticStats(snapshot, windfoil)\n } else if (\n isDomSnapshot(snapshot) &&\n atlas?.colorLayer === undefined &&\n !opts.svg &&\n !snapshot.textShaping\n ) {\n glyphCount = snapshot.glyphs.length\n } else {\n const glyphs = atlas?.glyphs\n let prevKey: string | undefined\n let prevColor = false\n for (const glyph of snapshot.glyphs) {\n if (glyph.shapeGroup !== undefined) {\n shapeCount++\n } else {\n glyphCount++\n if (glyphs) {\n const key = glyph.glyphKey\n const isCol =\n key === prevKey\n ? prevColor\n : ((prevKey = key), (prevColor = !!glyphs.get(key)?.color))\n if (isCol) colorGlyphCount++\n }\n }\n }\n }\n if (nextRetained !== oldRetained || appended) {\n this.#sb = atlas ? sdfStorageBytes(atlas, opts.quality === 'high') : 0\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: (windfoil?.storageBytes ?? 0) + (atlas ? this.#sb : 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 void preparedWorkerPromise?.then((worker) => worker?.dispose())\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) this.#sm?.observeSvgUses(observer, this.source, options)\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.#rf = null\n this.#a =\n this.#ro =\n this.#mo =\n this.#uf =\n this.#c =\n this.#r =\n this.#to =\n this.snapshot =\n this.#ps =\n null\n this.#f = this.#t = this.#w = this.#h = this.#sb = 0\n this.#o = this.#cm = false\n this.#apm = null\n this.#as = ''\n this.#st = EMPTY_STATS\n this.source.classList.remove('sdf-selectable')\n this.clear()\n super.dispose()\n }\n}\n"],"mappings":";;;;;;;;;;;;;;AAkDA,IAAM,cAAqC,OAAO,OAAO;CACvD,cAAc;CACd,cAAc;CAC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