ultra-text 1.0.1 → 1.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (150) hide show
  1. package/README.md +224 -1002
  2. package/dist/assets/{cpuSdf.worker-xS57yQbP.js → cpuSdf.worker--X1Qpmdp.js} +136 -47
  3. package/dist/assets/cpuSdf.worker--X1Qpmdp.js.map +1 -0
  4. package/dist/atlas/appendAtlas.js +67 -25
  5. package/dist/atlas/appendAtlas.js.map +1 -1
  6. package/dist/atlas/buildAtlas.js +3 -2
  7. package/dist/atlas/buildAtlas.js.map +1 -1
  8. package/dist/atlas/cpuAtlas.d.ts +4 -1
  9. package/dist/atlas/cpuAtlas.js +8 -6
  10. package/dist/atlas/cpuAtlas.js.map +1 -1
  11. package/dist/atlas/cpuSdf.js +152 -40
  12. package/dist/atlas/cpuSdf.js.map +1 -1
  13. package/dist/atlas/cpuWorker.d.ts +5 -3
  14. package/dist/atlas/cpuWorker.js +119 -12
  15. package/dist/atlas/cpuWorker.js.map +1 -1
  16. package/dist/atlas/gpuAtlas.js +100 -276
  17. package/dist/atlas/gpuAtlas.js.map +1 -1
  18. package/dist/atlas/gpuCommon.d.ts +135 -0
  19. package/dist/atlas/gpuCommon.js +223 -0
  20. package/dist/atlas/gpuCommon.js.map +1 -0
  21. package/dist/atlas/jfaWgsl.js +47 -241
  22. package/dist/atlas/jfaWgsl.js.map +1 -1
  23. package/dist/atlas/rasterize.js +103 -58
  24. package/dist/atlas/rasterize.js.map +1 -1
  25. package/dist/atlas/shapeRaster.js +2 -1
  26. package/dist/atlas/shapeRaster.js.map +1 -1
  27. package/dist/atlas/vanillaBounds.d.ts +64 -0
  28. package/dist/atlas/vanillaBounds.js +42 -0
  29. package/dist/atlas/vanillaBounds.js.map +1 -0
  30. package/dist/atlas/vanillaCore.d.ts +100 -0
  31. package/dist/atlas/vanillaCore.js +1012 -0
  32. package/dist/atlas/vanillaCore.js.map +1 -0
  33. package/dist/atlas/vanillaCpuAtlas.d.ts +9 -0
  34. package/dist/atlas/vanillaCpuAtlas.js +87 -0
  35. package/dist/atlas/vanillaCpuAtlas.js.map +1 -0
  36. package/dist/atlas/vanillaExtras.d.ts +8 -0
  37. package/dist/atlas/vanillaExtras.js +166 -0
  38. package/dist/atlas/vanillaExtras.js.map +1 -0
  39. package/dist/atlas/vanillaGpuHelpers.d.ts +232 -0
  40. package/dist/atlas/vanillaGpuHelpers.js +119 -0
  41. package/dist/atlas/vanillaGpuHelpers.js.map +1 -0
  42. package/dist/dom/DomSdf.js +224 -284
  43. package/dist/dom/DomSdf.js.map +1 -1
  44. package/dist/dom/DomSlug.js +75 -151
  45. package/dist/dom/DomSlug.js.map +1 -1
  46. package/dist/dom/domAnalytic.d.ts +54 -0
  47. package/dist/dom/domAnalytic.js +282 -0
  48. package/dist/dom/domAnalytic.js.map +1 -0
  49. package/dist/dom/domExtras.d.ts +27 -0
  50. package/dist/dom/domExtras.js +137 -0
  51. package/dist/dom/domExtras.js.map +1 -0
  52. package/dist/dom/fontCanvas.js +27 -9
  53. package/dist/dom/fontCanvas.js.map +1 -1
  54. package/dist/dom/layoutSignature.js +150 -48
  55. package/dist/dom/layoutSignature.js.map +1 -1
  56. package/dist/dom/pretextLayout.js +55 -13
  57. package/dist/dom/pretextLayout.js.map +1 -1
  58. package/dist/dom/snapshot.js +369 -204
  59. package/dist/dom/snapshot.js.map +1 -1
  60. package/dist/dom/svgCapture.d.ts +8 -1
  61. package/dist/dom/svgCapture.js +75 -1
  62. package/dist/dom/svgCapture.js.map +1 -1
  63. package/dist/dom/tone.js +76 -36
  64. package/dist/dom/tone.js.map +1 -1
  65. package/dist/index.js +4 -3
  66. package/dist/slug/SlugMaterial.d.ts +11 -3
  67. package/dist/slug/SlugMaterial.js +54 -10
  68. package/dist/slug/SlugMaterial.js.map +1 -1
  69. package/dist/slug/coverage.d.ts +16 -12
  70. package/dist/slug/coverage.js +194 -221
  71. package/dist/slug/coverage.js.map +1 -1
  72. package/dist/slug/preprocessCore.d.ts +5 -1
  73. package/dist/slug/preprocessCore.js +118 -87
  74. package/dist/slug/preprocessCore.js.map +1 -1
  75. package/dist/slug/runtime.d.ts +1 -0
  76. package/dist/slug/runtime.js +90 -44
  77. package/dist/slug/runtime.js.map +1 -1
  78. package/dist/slug/standaloneRuntime.d.ts +3 -2
  79. package/dist/slug/standaloneRuntime.js +75 -40
  80. package/dist/slug/standaloneRuntime.js.map +1 -1
  81. package/dist/slug/truetype.js +166 -193
  82. package/dist/slug/truetype.js.map +1 -1
  83. package/dist/slug/vanillaCore.d.ts +340 -0
  84. package/dist/slug/vanillaCore.js +1621 -0
  85. package/dist/slug/vanillaCore.js.map +1 -0
  86. package/dist/slug-vanilla.d.ts +13 -364
  87. package/dist/slug-vanilla.js +5 -1453
  88. package/dist/slug.d.ts +1 -1
  89. package/dist/slug.js +6 -6
  90. package/dist/text/GlyphTextMaterial.d.ts +1 -1
  91. package/dist/text/GlyphTextMaterial.js +5 -5
  92. package/dist/text/GlyphTextMaterial.js.map +1 -1
  93. package/dist/text/SdfTextMaterial.js +7 -5
  94. package/dist/text/SdfTextMaterial.js.map +1 -1
  95. package/dist/text/decorations.js +36 -19
  96. package/dist/text/decorations.js.map +1 -1
  97. package/dist/text/geometry.d.ts +3 -22
  98. package/dist/text/geometryUtils.d.ts +11 -1
  99. package/dist/text/geometryUtils.js +22 -1
  100. package/dist/text/geometryUtils.js.map +1 -1
  101. package/dist/text/glyphGeometry.d.ts +9 -0
  102. package/dist/text/glyphGeometry.js +353 -0
  103. package/dist/text/glyphGeometry.js.map +1 -0
  104. package/dist/text/index.d.ts +2 -1
  105. package/dist/text/rectGeometry.d.ts +13 -0
  106. package/dist/text/rectGeometry.js +97 -0
  107. package/dist/text/rectGeometry.js.map +1 -0
  108. package/dist/text/reflow.d.ts +18 -1
  109. package/dist/text/reflow.js +108 -38
  110. package/dist/text/reflow.js.map +1 -1
  111. package/dist/text/snap.d.ts +1 -0
  112. package/dist/text/snap.js +26 -0
  113. package/dist/text/snap.js.map +1 -0
  114. package/dist/vanilla.d.ts +13 -363
  115. package/dist/vanilla.js +6 -1473
  116. package/dist/windfoil/geometry.d.ts +2 -2
  117. package/dist/windfoil/geometry.js +113 -40
  118. package/dist/windfoil/geometry.js.map +1 -1
  119. package/dist/windfoil/mixed.d.ts +1 -0
  120. package/dist/windfoil/mixed.js +44 -25
  121. package/dist/windfoil/mixed.js.map +1 -1
  122. package/dist/windfoil/preprocess.js +2 -2
  123. package/dist/windfoil/preprocessCore.d.ts +1 -0
  124. package/dist/windfoil/preprocessCore.js +9 -4
  125. package/dist/windfoil/preprocessCore.js.map +1 -1
  126. package/dist/windfoil/runtime.d.ts +3 -1
  127. package/dist/windfoil/runtime.js +62 -40
  128. package/dist/windfoil/runtime.js.map +1 -1
  129. package/dist/windfoil/storage.d.ts +60 -2
  130. package/dist/windfoil/storage.js +142 -6
  131. package/dist/windfoil/storage.js.map +1 -1
  132. package/dist/windfoil/trace/contours.d.ts +5 -0
  133. package/dist/windfoil/trace/contours.js +167 -43
  134. package/dist/windfoil/trace/contours.js.map +1 -1
  135. package/dist/windfoil/trace/fit.d.ts +3 -1
  136. package/dist/windfoil/trace/fit.js +471 -175
  137. package/dist/windfoil/trace/fit.js.map +1 -1
  138. package/dist/windfoil/trace/outline.js +55 -30
  139. package/dist/windfoil/trace/outline.js.map +1 -1
  140. package/dist/windfoil/trace/types.d.ts +10 -0
  141. package/dist/windfoil/tracedOutlines.js +59 -34
  142. package/dist/windfoil/tracedOutlines.js.map +1 -1
  143. package/package.json +11 -11
  144. package/skills/ultra-text/references/three-tsl.md +2 -2
  145. package/skills/ultra-text/references/vanilla-webgpu.md +3 -2
  146. package/dist/assets/cpuSdf.worker-xS57yQbP.js.map +0 -1
  147. package/dist/slug-vanilla.js.map +0 -1
  148. package/dist/text/geometry.js +0 -348
  149. package/dist/text/geometry.js.map +0 -1
  150. package/dist/vanilla.js.map +0 -1
@@ -1,14 +1,10 @@
1
1
  import { resolveDomTextTone } from "./tone.js";
2
2
  import { isAnimatedMotion } from "../text/GlyphTextMaterial.js";
3
- import { createRectMaterial } from "../text/RectMaterial.js";
4
- import { createRectGeometry, needsRunMotion, rectContentFits, updateRectGeometry } from "../text/geometry.js";
5
- import { reflowSnapshot } from "../text/reflow.js";
6
- import { TextDecorationMaterial, canUpdateDecorationGeometry, createDecorationGeometry, updateDecorationGeometry } from "../text/decorations.js";
3
+ import { hasDecorations, needsRunMotion } from "../text/geometryUtils.js";
7
4
  import "./markup.js";
8
5
  import { collectDomSnapshot } from "./snapshot.js";
9
6
  import { layoutSignatureOf } from "./layoutSignature.js";
10
7
  import { buildStandaloneSlugBackend } from "../slug/standaloneRuntime.js";
11
- import { createTracedOutlineProvider } from "../windfoil/tracedOutlines.js";
12
8
  import { Group, Mesh } from "three/webgpu";
13
9
  // src/dom/DomSlug.ts
14
10
  var EMPTY_SLUG_STATS = Object.freeze({
@@ -40,7 +36,7 @@ function abortError(message = "The DOM Slug build was aborted") {
40
36
  function throwIfAborted(signal) {
41
37
  if (signal.aborted) throw signal.reason ?? abortError();
42
38
  }
43
- function createSlugContent(snapshot, backend, options, motion, tone) {
39
+ function createSlugContent(snapshot, backend, options, motion, tone, extrasMod) {
44
40
  const materialOptions = {
45
41
  ...options,
46
42
  tone: tone ?? false
@@ -82,86 +78,10 @@ function createSlugContent(snapshot, backend, options, motion, tone) {
82
78
  ownedMeshes.length = 0;
83
79
  group.clear();
84
80
  };
85
- let decorations = null;
86
81
  const glyphDrawable = (retained, key) => (retained.glyphs.get(key)?.monotonePieceCount ?? 0) > 0;
87
- const prepareDecorations = (layout, retained, liveMotion, nextTextGeometry, nextSequence, drawable = (key) => glyphDrawable(retained, key)) => {
88
- const geometry = createDecorationGeometry(layout, nextTextGeometry, drawable, liveMotion.strength ?? 18);
89
- try {
90
- return [geometry, geometry && !decorations ? new TextDecorationMaterial({
91
- textShaping: options.textShaping ?? "none",
92
- side: options.side,
93
- vertex: options.vertex,
94
- motion: materialMotion(liveMotion),
95
- maxSequence: nextSequence
96
- }) : null];
97
- } catch (error) {
98
- geometry?.dispose();
99
- throw error;
100
- }
101
- };
102
- const commitDecorations = ([geometry, material], liveMotion) => {
103
- if (!geometry) {
104
- if (decorations) {
105
- group.remove(decorations);
106
- ownedMeshes.splice(ownedMeshes.indexOf(decorations), 1);
107
- decorations.geometry.dispose();
108
- decorations.material.dispose();
109
- decorations = null;
110
- }
111
- return;
112
- }
113
- if (decorations) {
114
- const previous = decorations.geometry;
115
- decorations.geometry = geometry;
116
- previous.dispose();
117
- if (animated) decorations.material.setMotion(liveMotion);
118
- decorations.material.maxSequence.value = textMaterial.maxSequence.value;
119
- } else {
120
- decorations = new Mesh(geometry, material);
121
- decorations.name = "ultra-text text decorations";
122
- decorations.castShadow = options.castShadow !== false;
123
- decorations.renderOrder = 3;
124
- decorations.frustumCulled = false;
125
- group.add(decorations);
126
- ownedMeshes.push(decorations);
127
- }
128
- };
129
- const updateDecorations = (layout, retained, liveMotion, drawable = (key) => glyphDrawable(retained, key)) => {
130
- if (!decorations) return;
131
- if (updateDecorationGeometry(decorations.geometry, layout, text.geometry, drawable, liveMotion.strength ?? 18)) {
132
- if (animated) decorations.material.setMotion(liveMotion);
133
- decorations.material.maxSequence.value = textMaterial.maxSequence.value;
134
- return;
135
- }
136
- commitDecorations(prepareDecorations(layout, retained, liveMotion, text.geometry, textMaterial.maxSequence.value, drawable), liveMotion);
137
- };
138
- const addRects = (receiver, name) => {
139
- const geometry = createRectGeometry(snapshot, receiver);
140
- if (!geometry) return null;
141
- let mesh;
142
- try {
143
- mesh = new Mesh(geometry, createRectMaterial(receiver, options.shadowFloor));
144
- } catch (error) {
145
- geometry.dispose();
146
- throw error;
147
- }
148
- mesh.name = name;
149
- mesh.receiveShadow = receiver;
150
- mesh.frustumCulled = true;
151
- mesh.renderOrder = 0;
152
- mesh.matrixAutoUpdate = false;
153
- mesh.updateMatrix();
154
- group.add(mesh);
155
- ownedMeshes.push(mesh);
156
- return mesh;
157
- };
158
- let plainRects = null;
159
- let receivers = null;
82
+ let ce = null;
160
83
  try {
161
- const initialDecorations = prepareDecorations(snapshot, backend, motion, text.geometry, textMaterial.maxSequence.value);
162
- if (initialDecorations[0]) commitDecorations(initialDecorations, motion);
163
- plainRects = addRects(false, "ultra-text DOM rectangles");
164
- receivers = addRects(true, "ultra-text shadow receivers");
84
+ if (extrasMod) ce = extrasMod.createContentExtras(snapshot, text.geometry, group, ownedMeshes, options, () => animated, motion, textMaterial.maxSequence.value, (key) => glyphDrawable(backend, key));
165
85
  } catch (error) {
166
86
  disposeMeshes();
167
87
  throw error;
@@ -188,11 +108,12 @@ function createSlugContent(snapshot, backend, options, motion, tone) {
188
108
  sm(change, live) {
189
109
  if (animated) {
190
110
  textMaterial.setMotion(change);
191
- decorations?.material.setMotion(change);
111
+ ce?.setMotion(change);
192
112
  return;
193
113
  }
194
114
  if (!isAnimatedMotion(live)) return;
195
- const meshes = [text, ...decorations ? [decorations] : []];
115
+ const decMesh = ce?.decMesh();
116
+ const meshes = [text, ...decMesh ? [decMesh] : []];
196
117
  const twins = [];
197
118
  try {
198
119
  for (const mesh of meshes) twins.push(mesh.material.withMotion(live));
@@ -209,41 +130,29 @@ function createSlugContent(snapshot, backend, options, motion, tone) {
209
130
  animated = true;
210
131
  },
211
132
  st: setTone,
212
- ud: updateDecorations,
133
+ ud(layout, retained, liveMotion) {
134
+ ce?.updateDec(layout, text.geometry, animated, liveMotion, textMaterial.maxSequence.value, (key) => glyphDrawable(retained, key));
135
+ },
213
136
  rg(geometry) {
214
137
  swapGeometry(text, geometry);
215
138
  },
216
139
  u(nextSnapshot, nextBackend, liveMotion, nextTone) {
217
140
  if (nextTone !== void 0 && (!toneFits(nextTone) || animated !== isAnimatedMotion(liveMotion))) return false;
218
141
  if (runMotion !== needsRunMotion(nextSnapshot)) return false;
219
- const wantsPlain = nextSnapshot.rects.some((rect) => !rect.receiveShadow);
220
- const wantsReceivers = nextSnapshot.rects.some((rect) => rect.receiveShadow);
221
- if (wantsPlain !== (plainRects !== null) || wantsReceivers !== (receivers !== null)) return false;
142
+ if (ce ? !ce.fitsLayout(nextSnapshot) : nextSnapshot.rects.length > 0 || hasDecorations(nextSnapshot)) return false;
222
143
  const nextStrength = liveMotion.strength ?? 18;
223
144
  const drawable = (key) => glyphDrawable(nextBackend, key);
224
- const decorationsFit = canUpdateDecorationGeometry(decorations?.geometry ?? null, nextSnapshot, drawable);
145
+ const decorationsFit = ce ? ce.decorationsFit(nextSnapshot, drawable) : true;
225
146
  const glyphsFit = decorationsFit && nextBackend.contentFits(text.geometry, nextSnapshot);
226
- const plainFit = !plainRects || rectContentFits(plainRects.geometry, nextSnapshot, false);
227
- const receiverFit = !receivers || rectContentFits(receivers.geometry, nextSnapshot, true);
228
147
  let built = null;
229
- let nextPlain = null;
230
- let nextReceivers = null;
231
- let nextDecorations = null;
148
+ let stagedExtras = null;
232
149
  const releaseStaged = () => {
233
150
  built?.geometry.dispose();
234
- nextPlain?.dispose();
235
- nextReceivers?.dispose();
236
- nextDecorations?.[0]?.dispose();
237
- nextDecorations?.[1]?.dispose();
151
+ stagedExtras?.dispose();
238
152
  };
239
153
  try {
240
154
  if (!glyphsFit) built = nextBackend.createGeometry(nextSnapshot, nextStrength);
241
- if (plainRects && !plainFit) nextPlain = createRectGeometry(nextSnapshot, false);
242
- if (receivers && !receiverFit) nextReceivers = createRectGeometry(nextSnapshot, true);
243
- if (!decorationsFit) {
244
- const source = built?.geometry ?? text.geometry;
245
- nextDecorations = prepareDecorations(nextSnapshot, nextBackend, liveMotion, source, built?.maxSequence ?? textMaterial.maxSequence.value, drawable);
246
- }
155
+ if (ce) stagedExtras = ce.prepare(nextSnapshot, built?.geometry ?? text.geometry, animated, liveMotion, built?.maxSequence ?? textMaterial.maxSequence.value, decorationsFit, drawable);
247
156
  } catch (error) {
248
157
  releaseStaged();
249
158
  throw error;
@@ -252,19 +161,14 @@ function createSlugContent(snapshot, backend, options, motion, tone) {
252
161
  swapGeometry(text, built.geometry);
253
162
  textMaterial.maxSequence.value = built.maxSequence;
254
163
  } else {
255
- const updatedMax = nextBackend.updateGeometry(text.geometry, nextSnapshot, nextStrength);
164
+ const updatedMax = nextBackend.updateGeometry(text.geometry, nextSnapshot, nextStrength, true);
256
165
  if (updatedMax === null) {
257
166
  releaseStaged();
258
167
  throw new Error("DomSlug: glyph buffers changed during the update");
259
168
  }
260
169
  textMaterial.maxSequence.value = updatedMax;
261
170
  }
262
- if (nextDecorations) commitDecorations(nextDecorations, liveMotion);
263
- else updateDecorations(nextSnapshot, nextBackend, liveMotion, drawable);
264
- if (plainRects && nextPlain) swapGeometry(plainRects, nextPlain);
265
- else if (plainRects) updateRectGeometry(plainRects.geometry, nextSnapshot, false);
266
- if (receivers && nextReceivers) swapGeometry(receivers, nextReceivers);
267
- else if (receivers) updateRectGeometry(receivers.geometry, nextSnapshot, true);
171
+ ce?.commit(stagedExtras, nextSnapshot, text.geometry, animated, liveMotion, textMaterial.maxSequence.value, drawable, swapGeometry);
268
172
  if (nextTone !== void 0) setTone(nextTone);
269
173
  return true;
270
174
  },
@@ -297,11 +201,16 @@ var DomSlug = class DomSlug extends Group {
297
201
  #mo = null;
298
202
  #uf = null;
299
203
  snapshot = null;
204
+ #rf = null;
205
+ #rm = null;
206
+ #em = null;
207
+ #sm = null;
300
208
  #w = 0;
301
209
  #h = 0;
302
210
  #as = "";
303
211
  #ls = "";
304
212
  #cm = false;
213
+ #ga = false;
305
214
  #st = EMPTY_SLUG_STATS;
306
215
  #m;
307
216
  #to = null;
@@ -357,13 +266,14 @@ var DomSlug = class DomSlug extends Group {
357
266
  }
358
267
  reflow(width) {
359
268
  if (this.#d) throw new Error("DomSlug.reflow: this instance is disposed");
360
- if (!this.snapshot) throw new Error("DomSlug.reflow: create the instance with reflowable: true first");
269
+ const rm = this.#rm;
270
+ if (!this.snapshot || !rm) throw new Error("DomSlug.reflow: create the instance with reflowable: true first");
361
271
  if (!this.#r || !this.#c) return this;
362
272
  const retained = this.#r;
363
273
  const content = this.#c;
364
274
  retained.setGlyphEm(!!content.m.tone?.dilates);
365
275
  const started = now();
366
- const reflowed = reflowSnapshot(this.snapshot, width);
276
+ const reflowed = rm.reflowSnapshotWithState(this.snapshot, width, this.#rf ??= rm.createReflowState(this.snapshot));
367
277
  const strength = this.#m.strength ?? 18;
368
278
  let maxSequence = retained.updateGeometry(content.tg, reflowed, strength);
369
279
  if (maxSequence === null) {
@@ -403,10 +313,17 @@ var DomSlug = class DomSlug extends Group {
403
313
  let ownsNextRetained = false;
404
314
  let nextContent = null;
405
315
  const forceOutlines = rebuildOptions.outlines === true || rebuildOptions.atlas === true;
316
+ let reflowPromise = null;
406
317
  try {
318
+ if (opts.reflowable === true && !this.#rm) reflowPromise = import("../text/reflow.js").then((mod) => {
319
+ this.#rm = mod;
320
+ });
407
321
  await Promise.resolve();
408
322
  throwIfAborted(controller.signal);
409
323
  if (generation !== this.#g) throw abortError("Superseded by a newer DOM Slug build");
324
+ const customProvider = opts.outlineProvider ?? opts.slug?.outlineProvider;
325
+ const preloadTraced = !customProvider && !this.#to ? import("../windfoil/tracedOutlines.js").catch(() => null) : null;
326
+ const svgPromise = opts.svg && !this.#sm ? import("./svgCapture.js").then((m) => this.#sm = m) : null;
410
327
  const layoutStarted = now();
411
328
  const snapshot = await collectDomSnapshot(this.source, opts);
412
329
  const tone = resolveDomTextTone(this.source, opts.tone, {
@@ -417,6 +334,9 @@ var DomSlug = class DomSlug extends Group {
417
334
  });
418
335
  const layoutReadMs = now() - layoutStarted;
419
336
  throwIfAborted(controller.signal);
337
+ const extrasPromise = !this.#em && (snapshot.rects.length > 0 || hasDecorations(snapshot)) ? import("./domExtras.js").then((mod) => {
338
+ this.#em = mod;
339
+ }) : null;
420
340
  const retained = this.#r;
421
341
  const canReuseRetainedText = !forceOutlines && retained !== null && (this.#as === snapshot.atlasSignature || snapshot.requests.every((request) => retained.covers(request.key)));
422
342
  const signature = canReuseRetainedText && this.#c !== null && this.#cm ? layoutSignatureOf(snapshot) : void 0;
@@ -427,40 +347,59 @@ var DomSlug = class DomSlug extends Group {
427
347
  atlasBuildMs: 0,
428
348
  geometryBuildMs: 0
429
349
  });
350
+ if (svgPromise) await svgPromise;
430
351
  if (opts.svg) this.#om();
431
352
  return;
432
353
  }
354
+ let appended = false;
433
355
  let atlasBuildMs = 0;
434
356
  if (canReuseRetainedText) nextRetained = retained;
435
357
  else {
436
358
  const buildStarted = now();
437
- const customProvider = opts.outlineProvider ?? opts.slug?.outlineProvider;
438
- if (customProvider !== void 0 && typeof customProvider !== "function") throw new TypeError("DomSlug: outlineProvider must be a function");
439
- let resolvedProvider = customProvider;
440
- if (!resolvedProvider) {
441
- if (!this.#to) this.#to = createTracedOutlineProvider(this.source.ownerDocument, {
442
- ...opts.colorGlyphs === void 0 ? {} : { colorGlyphs: opts.colorGlyphs },
443
- ...opts.traceSize === void 0 ? {} : { size: opts.traceSize },
444
- ...opts.traceTolerance === void 0 ? {} : { tolerance: opts.traceTolerance }
445
- });
446
- else if (forceOutlines) this.#to.clear();
447
- resolvedProvider = this.#to.provider;
359
+ if (!forceOutlines && retained?.append && await retained.append(snapshot.requests, controller.signal)) {
360
+ appended = true;
361
+ nextRetained = retained;
362
+ } else {
363
+ if (forceOutlines) this.#ga = false;
364
+ else if (retained !== null) this.#ga = true;
365
+ if (customProvider !== void 0 && typeof customProvider !== "function") throw new TypeError("DomSlug: outlineProvider must be a function");
366
+ let resolvedProvider = customProvider;
367
+ if (!resolvedProvider) {
368
+ if (!this.#to) {
369
+ const { createTracedOutlineProvider } = await preloadTraced ?? await import("../windfoil/tracedOutlines.js");
370
+ throwIfAborted(controller.signal);
371
+ if (generation !== this.#g) throw abortError("Superseded by a newer DOM Slug build");
372
+ this.#to ??= createTracedOutlineProvider(this.source.ownerDocument, {
373
+ ...opts.colorGlyphs === void 0 ? {} : { colorGlyphs: opts.colorGlyphs },
374
+ ...opts.traceSize === void 0 ? {} : { size: opts.traceSize },
375
+ ...opts.traceTolerance === void 0 ? {} : { tolerance: opts.traceTolerance }
376
+ });
377
+ } else if (forceOutlines) this.#to.clear();
378
+ resolvedProvider = this.#to.provider;
379
+ }
380
+ const targetPiecesPerBand = opts.targetPiecesPerBand ?? opts.slug?.targetPiecesPerBand;
381
+ nextRetained = await buildStandaloneSlugBackend(this.renderer, snapshot.requests, {
382
+ outlineProvider: resolvedProvider,
383
+ missingGlyphs: opts.missingGlyphs ?? (customProvider ? "error" : "skip"),
384
+ ...targetPiecesPerBand === void 0 ? {} : { targetPiecesPerBand }
385
+ }, controller.signal, this.#ga);
386
+ ownsNextRetained = true;
448
387
  }
449
- const targetPiecesPerBand = opts.targetPiecesPerBand ?? opts.slug?.targetPiecesPerBand;
450
- nextRetained = await buildStandaloneSlugBackend(this.renderer, snapshot.requests, {
451
- outlineProvider: resolvedProvider,
452
- missingGlyphs: opts.missingGlyphs ?? (customProvider ? "error" : "skip"),
453
- ...targetPiecesPerBand === void 0 ? {} : { targetPiecesPerBand }
454
- }, controller.signal);
455
- ownsNextRetained = true;
456
388
  atlasBuildMs = now() - buildStarted;
457
389
  }
458
390
  throwIfAborted(controller.signal);
459
391
  if (generation !== this.#g) throw abortError("Superseded by a newer DOM Slug build");
392
+ if (extrasPromise) {
393
+ await extrasPromise;
394
+ throwIfAborted(controller.signal);
395
+ if (generation !== this.#g) throw abortError("Superseded by a newer DOM Slug build");
396
+ }
460
397
  const geometryStarted = now();
461
398
  nextRetained.setGlyphEm(!!tone?.dilationPx);
462
- if (!(canReuseRetainedText && (this.#c?.u(snapshot, nextRetained, this.#m, tone) ?? false))) nextContent = createSlugContent(snapshot, nextRetained, opts, this.#m, tone);
399
+ if (!((canReuseRetainedText || appended) && (this.#c?.u(snapshot, nextRetained, this.#m, tone) ?? false))) nextContent = createSlugContent(snapshot, nextRetained, opts, this.#m, tone, this.#em);
463
400
  const geometryBuildMs = now() - geometryStarted;
401
+ if (reflowPromise) await reflowPromise;
402
+ if (svgPromise) await svgPromise;
464
403
  throwIfAborted(controller.signal);
465
404
  const oldContent = this.#c;
466
405
  const oldRetained = this.#r;
@@ -473,6 +412,7 @@ var DomSlug = class DomSlug extends Group {
473
412
  } else activeContent = oldContent;
474
413
  this.#r = nextRetained;
475
414
  this.snapshot = opts.reflowable === true ? snapshot : null;
415
+ this.#rf = null;
476
416
  this.#w = snapshot.width;
477
417
  this.#h = snapshot.height;
478
418
  this.#as = snapshot.atlasSignature;
@@ -590,23 +530,7 @@ var DomSlug = class DomSlug extends Group {
590
530
  subtree: true
591
531
  };
592
532
  observer.observe(this.source, options);
593
- if (!this.options.svg) return;
594
- const seen = /* @__PURE__ */ new Set([this.source]);
595
- const pending = [this.source];
596
- while (pending.length) {
597
- const source = pending.pop();
598
- const uses = [...source.querySelectorAll("use")];
599
- if (source.localName === "use") uses.unshift(source);
600
- for (const use of uses) {
601
- const href = use.getAttribute("href") ?? use.getAttribute("xlink:href") ?? "";
602
- const tree = use.getRootNode();
603
- const target = href.startsWith("#") ? tree.getElementById(href.slice(1)) : null;
604
- if (!target || seen.has(target)) continue;
605
- seen.add(target);
606
- if (!this.source.contains(target)) observer.observe(target, options);
607
- pending.push(target);
608
- }
609
- }
533
+ if (this.options.svg) this.#sm?.observeSvgUses(observer, this.source, options);
610
534
  }
611
535
  dispose() {
612
536
  if (this.#d) return;
@@ -1 +1 @@
1
- {"version":3,"file":"DomSlug.js","names":[],"sources":["../../src/dom/DomSlug.ts"],"sourcesContent":["import { Group, Mesh, type InstancedBufferGeometry, type WebGPURenderer } from 'three/webgpu'\n\nimport {\n buildStandaloneSlugBackend,\n type StandaloneSlugBackend,\n} from '../slug/standaloneRuntime.js'\nimport {\n canUpdateDecorationGeometry,\n createDecorationGeometry,\n TextDecorationMaterial,\n updateDecorationGeometry,\n} from '../text/decorations.js'\nimport {\n createRectGeometry,\n needsRunMotion,\n rectContentFits,\n updateRectGeometry,\n} from '../text/geometry.js'\nimport { isAnimatedMotion, type GlyphTextMaterial } from '../text/GlyphTextMaterial.js'\nimport { createRectMaterial } from '../text/RectMaterial.js'\nimport { reflowSnapshot } from '../text/reflow.js'\nimport type { ResolvedTextTone } from '../text/tone.js'\nimport type {\n DomLayoutSnapshot,\n DomSlugOptions,\n DomSlugRebuildOptions,\n DomSlugStats,\n SdfMotionOptions,\n} from '../types.js'\nimport { createTracedOutlineProvider, type TracedOutlines } from '../windfoil/tracedOutlines.js'\nimport { layoutSignatureOf } from './layoutSignature.js'\nimport { DEFAULT_RECT_SELECTOR } from './markup.js'\nimport { collectDomSnapshot } from './snapshot.js'\nimport { resolveDomTextTone } from './tone.js'\n\nconst EMPTY_SLUG_STATS: Readonly<DomSlugStats> = Object.freeze({\n atlasBuildMs: 0,\n layoutReadMs: 0,\n geometryBuildMs: 0,\n glyphs: 0,\n shapes: 0,\n colorGlyphs: 0,\n fallbackGlyphs: 0,\n switchableGlyphs: 0,\n rects: 0,\n lines: 0,\n draws: 0,\n atlasWidth: 0,\n atlasHeight: 0,\n textBackend: 'slug',\n atlasMode: null,\n textStorageBytes: 0,\n})\n\nconst ATTRIBUTE_DEBOUNCE_MS = 80\nconst ATTRIBUTE_MAX_WAIT_MS = 320\n\ninterface SlugContentBundle {\n readonly g: Group\n readonly m: GlyphTextMaterial\n readonly tg: InstancedBufferGeometry\n sm(change: SdfMotionOptions, live: SdfMotionOptions): void\n st(tone: ResolvedTextTone | null): boolean\n ud(snapshot: DomLayoutSnapshot, backend: StandaloneSlugBackend, motion: SdfMotionOptions): void\n rg(geometry: InstancedBufferGeometry): void\n u(\n snapshot: DomLayoutSnapshot,\n backend: StandaloneSlugBackend,\n motion: SdfMotionOptions,\n tone?: ResolvedTextTone | null,\n ): boolean\n d(): void\n}\n\nfunction now(): number {\n return performance.now()\n}\n\nfunction abortError(message = 'The DOM Slug build was aborted'): DOMException {\n return new DOMException(message, 'AbortError')\n}\n\nfunction throwIfAborted(signal: AbortSignal): void {\n if (signal.aborted) throw signal.reason ?? abortError()\n}\n\nfunction createSlugContent(\n snapshot: DomLayoutSnapshot,\n backend: StandaloneSlugBackend,\n options: DomSlugOptions,\n motion: SdfMotionOptions,\n tone: ResolvedTextTone | null,\n): SlugContentBundle {\n const materialOptions = { ...options, tone: tone ?? (false as const) }\n const group = new Group()\n group.name = 'ultra-text generated DOM Slug content'\n group.matrixAutoUpdate = false\n group.updateMatrix()\n\n const strength = motion.strength ?? 18\n let animated = isAnimatedMotion(motion)\n const materialMotion = (live: SdfMotionOptions): SdfMotionOptions | false =>\n animated ? live : false\n const runMotion = needsRunMotion(snapshot)\n const { geometry: glyphGeometry, maxSequence } = backend.createGeometry(snapshot, strength)\n\n let textMaterial: GlyphTextMaterial\n try {\n textMaterial = backend.createMaterial({\n ...materialOptions,\n maxSequence,\n motion: materialMotion(motion),\n })\n } catch (error) {\n glyphGeometry.dispose()\n throw error\n }\n\n const text = new Mesh(glyphGeometry, textMaterial)\n text.name = 'ultra-text slug text'\n text.castShadow = options.castShadow !== false\n text.frustumCulled = false\n text.renderOrder = 2\n text.matrixAutoUpdate = false\n text.updateMatrix()\n group.add(text)\n\n const ownedMeshes: Mesh[] = [text]\n const disposeMeshes = (): void => {\n for (const mesh of ownedMeshes) {\n mesh.geometry.dispose()\n for (const material of Array.isArray(mesh.material) ? mesh.material : [mesh.material]) {\n material.dispose()\n }\n }\n ownedMeshes.length = 0\n group.clear()\n }\n\n let decorations: Mesh<InstancedBufferGeometry, TextDecorationMaterial> | null = null\n const glyphDrawable = (retained: StandaloneSlugBackend, key: string): boolean =>\n (retained.glyphs.get(key)?.monotonePieceCount ?? 0) > 0\n\n const prepareDecorations = (\n layout: DomLayoutSnapshot,\n retained: StandaloneSlugBackend,\n liveMotion: SdfMotionOptions,\n nextTextGeometry: InstancedBufferGeometry,\n nextSequence: number,\n drawable: (key: string) => boolean = (key) => glyphDrawable(retained, key),\n ): readonly [InstancedBufferGeometry | null, TextDecorationMaterial | null] => {\n const geometry = createDecorationGeometry(\n layout,\n nextTextGeometry,\n drawable,\n liveMotion.strength ?? 18,\n )\n try {\n return [\n geometry,\n geometry && !decorations\n ? new TextDecorationMaterial({\n textShaping: options.textShaping ?? 'none',\n side: options.side,\n vertex: options.vertex,\n motion: materialMotion(liveMotion),\n maxSequence: nextSequence,\n })\n : null,\n ]\n } catch (error) {\n geometry?.dispose()\n throw error\n }\n }\n\n const commitDecorations = (\n [geometry, material]: ReturnType<typeof prepareDecorations>,\n liveMotion: SdfMotionOptions,\n ): void => {\n if (!geometry) {\n if (decorations) {\n group.remove(decorations)\n ownedMeshes.splice(ownedMeshes.indexOf(decorations), 1)\n decorations.geometry.dispose()\n decorations.material.dispose()\n decorations = null\n }\n return\n }\n if (decorations) {\n const previous = decorations.geometry\n decorations.geometry = geometry\n previous.dispose()\n if (animated) decorations.material.setMotion(liveMotion)\n decorations.material.maxSequence.value = textMaterial.maxSequence.value\n } else {\n decorations = new Mesh(geometry, material!)\n decorations.name = 'ultra-text text decorations'\n decorations.castShadow = options.castShadow !== false\n decorations.renderOrder = 3\n decorations.frustumCulled = false\n group.add(decorations)\n ownedMeshes.push(decorations)\n }\n }\n\n const updateDecorations = (\n layout: DomLayoutSnapshot,\n retained: StandaloneSlugBackend,\n liveMotion: SdfMotionOptions,\n drawable: (key: string) => boolean = (key) => glyphDrawable(retained, key),\n ): void => {\n if (!decorations) return\n if (\n updateDecorationGeometry(\n decorations.geometry,\n layout,\n text.geometry,\n drawable,\n liveMotion.strength ?? 18,\n )\n ) {\n if (animated) decorations.material.setMotion(liveMotion)\n decorations.material.maxSequence.value = textMaterial.maxSequence.value\n return\n }\n commitDecorations(\n prepareDecorations(\n layout,\n retained,\n liveMotion,\n text.geometry,\n textMaterial.maxSequence.value,\n drawable,\n ),\n liveMotion,\n )\n }\n\n const addRects = (receiver: boolean, name: string): Mesh | null => {\n const geometry = createRectGeometry(snapshot, receiver)\n if (!geometry) return null\n let mesh: Mesh\n try {\n mesh = new Mesh(geometry, createRectMaterial(receiver, options.shadowFloor))\n } catch (error) {\n geometry.dispose()\n throw error\n }\n mesh.name = name\n mesh.receiveShadow = receiver\n mesh.frustumCulled = true\n mesh.renderOrder = 0\n mesh.matrixAutoUpdate = false\n mesh.updateMatrix()\n group.add(mesh)\n ownedMeshes.push(mesh)\n return mesh\n }\n\n let plainRects: Mesh | null = null\n let receivers: Mesh | null = null\n try {\n const initialDecorations = prepareDecorations(\n snapshot,\n backend,\n motion,\n text.geometry,\n textMaterial.maxSequence.value,\n )\n if (initialDecorations[0]) commitDecorations(initialDecorations, motion)\n plainRects = addRects(false, 'ultra-text DOM rectangles')\n receivers = addRects(true, 'ultra-text shadow receivers')\n } catch (error) {\n disposeMeshes()\n throw error\n }\n\n const swapGeometry = (mesh: Mesh, geometry: InstancedBufferGeometry): void => {\n const previous = mesh.geometry\n mesh.geometry = geometry\n previous.dispose()\n }\n\n const setTone = (next: ResolvedTextTone | null): boolean => textMaterial.setTone(next)\n const toneFits = (next: ResolvedTextTone | null): boolean => {\n const current = textMaterial.tone\n return current && next ? current.fits(next) : !current && !next\n }\n\n let disposed = false\n return {\n g: group,\n get m(): GlyphTextMaterial {\n return textMaterial\n },\n get tg(): InstancedBufferGeometry {\n return text.geometry\n },\n sm(change, live) {\n if (animated) {\n textMaterial.setMotion(change)\n decorations?.material.setMotion(change)\n return\n }\n if (!isAnimatedMotion(live)) return\n const meshes: Mesh<InstancedBufferGeometry, GlyphTextMaterial>[] = [\n text,\n ...(decorations ? [decorations] : []),\n ]\n const twins: GlyphTextMaterial[] = []\n try {\n for (const mesh of meshes) twins.push(mesh.material.withMotion(live))\n } catch (error) {\n for (const twin of twins) twin.dispose()\n throw error\n }\n meshes.forEach((mesh, index) => {\n const previous = mesh.material\n mesh.material = twins[index]!\n previous.dispose()\n })\n textMaterial = twins[0]!\n animated = true\n },\n st: setTone,\n ud: updateDecorations,\n rg(geometry: InstancedBufferGeometry): void {\n swapGeometry(text, geometry)\n },\n u(nextSnapshot, nextBackend, liveMotion, nextTone) {\n if (\n nextTone !== undefined &&\n (!toneFits(nextTone) || animated !== isAnimatedMotion(liveMotion))\n ) {\n return false\n }\n if (runMotion !== needsRunMotion(nextSnapshot)) return false\n const wantsPlain = nextSnapshot.rects.some((rect) => !rect.receiveShadow)\n const wantsReceivers = nextSnapshot.rects.some((rect) => rect.receiveShadow)\n if (wantsPlain !== (plainRects !== null) || wantsReceivers !== (receivers !== null)) {\n return false\n }\n const nextStrength = liveMotion.strength ?? 18\n const drawable = (key: string): boolean => glyphDrawable(nextBackend, key)\n const decorationsFit = canUpdateDecorationGeometry(\n decorations?.geometry ?? null,\n nextSnapshot,\n drawable,\n )\n const glyphsFit = decorationsFit && nextBackend.contentFits(text.geometry, nextSnapshot)\n const plainFit =\n !plainRects ||\n rectContentFits(plainRects.geometry as InstancedBufferGeometry, nextSnapshot, false)\n const receiverFit =\n !receivers ||\n rectContentFits(receivers.geometry as InstancedBufferGeometry, nextSnapshot, true)\n\n let built: { geometry: InstancedBufferGeometry; maxSequence: number } | null = null\n let nextPlain: InstancedBufferGeometry | null = null\n let nextReceivers: InstancedBufferGeometry | null = null\n let nextDecorations: ReturnType<typeof prepareDecorations> | null = null\n const releaseStaged = (): void => {\n built?.geometry.dispose()\n nextPlain?.dispose()\n nextReceivers?.dispose()\n nextDecorations?.[0]?.dispose()\n nextDecorations?.[1]?.dispose()\n }\n try {\n if (!glyphsFit) built = nextBackend.createGeometry(nextSnapshot, nextStrength)\n if (plainRects && !plainFit) nextPlain = createRectGeometry(nextSnapshot, false)\n if (receivers && !receiverFit) nextReceivers = createRectGeometry(nextSnapshot, true)\n if (!decorationsFit) {\n const source = built?.geometry ?? text.geometry\n nextDecorations = prepareDecorations(\n nextSnapshot,\n nextBackend,\n liveMotion,\n source,\n built?.maxSequence ?? textMaterial.maxSequence.value,\n drawable,\n )\n }\n } catch (error) {\n releaseStaged()\n throw error\n }\n\n if (built) {\n swapGeometry(text, built.geometry)\n textMaterial.maxSequence.value = built.maxSequence\n } else {\n const updatedMax = nextBackend.updateGeometry(text.geometry, nextSnapshot, nextStrength)\n if (updatedMax === null) {\n releaseStaged()\n throw new Error('DomSlug: glyph buffers changed during the update')\n }\n textMaterial.maxSequence.value = updatedMax\n }\n if (nextDecorations) commitDecorations(nextDecorations, liveMotion)\n else updateDecorations(nextSnapshot, nextBackend, liveMotion, drawable)\n if (plainRects && nextPlain) swapGeometry(plainRects, nextPlain)\n else if (plainRects) {\n updateRectGeometry(plainRects.geometry as InstancedBufferGeometry, nextSnapshot, false)\n }\n if (receivers && nextReceivers) swapGeometry(receivers, nextReceivers)\n else if (receivers) {\n updateRectGeometry(receivers.geometry as InstancedBufferGeometry, nextSnapshot, true)\n }\n if (nextTone !== undefined) setTone(nextTone)\n return true\n },\n d(): void {\n if (disposed) return\n disposed = true\n disposeMeshes()\n },\n }\n}\n\n/**\n * Retained Three.js WebGPU/TSL controller for pure GPU Slug quadratic-curve text (`ultra-text/slug`).\n * Excludes all SDF rasterization, JFA atlas compute, and texture state.\n */\nexport class DomSlug extends Group {\n readonly renderer: WebGPURenderer\n readonly source: HTMLElement\n readonly options: Readonly<DomSlugOptions>\n protected readonly pageBackdrop: boolean = true\n\n #r: StandaloneSlugBackend | null = null\n #c: SlugContentBundle | null = null\n #a: AbortController | null = null\n #g = 0\n #d = false\n #f = 0\n #t = 0\n #dl = 0\n #fa = false\n #ro: ResizeObserver | null = null\n #mo: MutationObserver | null = null\n #uf: (() => void) | null = null\n private snapshot: DomLayoutSnapshot | null = null\n #w = 0\n #h = 0\n #as = ''\n #ls = ''\n #cm = false\n #st: Readonly<DomSlugStats> = EMPTY_SLUG_STATS\n #m: SdfMotionOptions\n #to: TracedOutlines | null = null\n\n protected constructor(renderer: WebGPURenderer, source: HTMLElement, options: DomSlugOptions) {\n super()\n this.name = 'ultra-text DOM Slug'\n this.renderer = renderer\n this.source = source\n const copy = { ...options }\n for (const key of ['motion', 'slug', 'svg', 'tone'] as const) {\n if (typeof copy[key] === 'object') {\n ;(copy as Record<string, unknown>)[key] = Object.freeze({ ...copy[key] })\n }\n }\n this.options = Object.freeze(copy)\n this.#m = { ...options.motion }\n if (options.selectable) this.source.classList.add('sdf-selectable')\n }\n\n static async create(\n renderer: WebGPURenderer,\n source: HTMLElement,\n options: DomSlugOptions = {},\n ): Promise<DomSlug> {\n const domSlug = new DomSlug(renderer, source, options)\n await domSlug.initialize()\n return domSlug\n }\n\n protected async initialize(): Promise<void> {\n try {\n await this.rebuild({ outlines: true })\n this.#co()\n } catch (error) {\n this.dispose()\n throw error\n }\n }\n\n get width(): number {\n return this.#c ? this.#w : 0\n }\n\n get height(): number {\n return this.#c ? this.#h : 0\n }\n\n get stats(): Readonly<DomSlugStats> {\n return this.#st\n }\n\n /** Always `null` on `DomSlug`: pure Slug stores curves in GPU buffers, never textures. */\n readonly atlasTexture = null\n\n setMotion(options: SdfMotionOptions): this {\n const motion = { ...this.#m, ...options }\n this.#c?.sm(options, motion)\n this.#m = motion\n return this\n }\n\n reflow(width: number): this {\n if (this.#d) throw new Error('DomSlug.reflow: this instance is disposed')\n if (!this.snapshot) {\n throw new Error('DomSlug.reflow: create the instance with reflowable: true first')\n }\n if (!this.#r || !this.#c) return this\n const retained = this.#r\n const content = this.#c\n retained.setGlyphEm(!!content.m.tone?.dilates)\n\n const started = now()\n const reflowed = reflowSnapshot(this.snapshot, width)\n const strength = this.#m.strength ?? 18\n let maxSequence = retained.updateGeometry(content.tg, reflowed, strength)\n if (maxSequence === null) {\n const built = retained.createGeometry(reflowed, strength)\n content.rg(built.geometry)\n maxSequence = built.maxSequence\n }\n content.m.maxSequence.value = maxSequence\n content.ud(reflowed, retained, this.#m)\n this.#cm = false\n this.#w = reflowed.width\n this.#h = reflowed.height\n this.#st = Object.freeze({\n ...this.#st,\n lines: reflowed.lineCount,\n layoutReadMs: 0,\n atlasBuildMs: 0,\n geometryBuildMs: now() - started,\n })\n return this\n }\n\n async rebuild(rebuildOptions: DomSlugRebuildOptions = {}): Promise<void> {\n if (this.#d) throw new Error('DomSlug.rebuild: this instance is disposed')\n const externalSignal = this.options.signal\n if (externalSignal?.aborted) {\n throw externalSignal.reason ?? abortError()\n }\n const opts = this.options\n if (opts.textShaping === 'browser') {\n throw new Error(\n 'DomSlug: textShaping \"browser\" requires an SDF atlas; use \"none\" (default) for pure Slug outlines',\n )\n }\n\n this.#a?.abort(abortError('Superseded by a newer DOM Slug build'))\n const controller = new AbortController()\n this.#a = controller\n const generation = ++this.#g\n const forwardAbort = (): void => {\n controller.abort(externalSignal?.reason ?? abortError())\n }\n externalSignal?.addEventListener('abort', forwardAbort, { once: true })\n\n let nextRetained: StandaloneSlugBackend | null = null\n let ownsNextRetained = false\n let nextContent: SlugContentBundle | null = null\n const forceOutlines = rebuildOptions.outlines === true || rebuildOptions.atlas === true\n\n try {\n await Promise.resolve()\n throwIfAborted(controller.signal)\n if (generation !== this.#g) {\n throw abortError('Superseded by a newer DOM Slug build')\n }\n\n const layoutStarted = now()\n const snapshot = await collectDomSnapshot(this.source, opts)\n const tone = resolveDomTextTone(this.source, opts.tone, {\n glyphs: snapshot.glyphs,\n rects: snapshot.rects,\n rootRect:\n opts.includeRootBackground !== false ||\n this.source.matches(opts.rectSelector ?? DEFAULT_RECT_SELECTOR),\n page: this.pageBackdrop,\n })\n const layoutReadMs = now() - layoutStarted\n throwIfAborted(controller.signal)\n\n const retained = this.#r\n const canReuseRetainedText =\n !forceOutlines &&\n retained !== null &&\n (this.#as === snapshot.atlasSignature ||\n snapshot.requests.every((request) => retained.covers(request.key)))\n const signature =\n canReuseRetainedText && this.#c !== null && this.#cm\n ? layoutSignatureOf(snapshot)\n : undefined\n\n if (\n canReuseRetainedText &&\n this.#c !== null &&\n this.#cm &&\n signature === this.#ls &&\n generation === this.#g &&\n this.#c.st(tone)\n ) {\n this.#st = Object.freeze({\n ...this.#st,\n layoutReadMs,\n atlasBuildMs: 0,\n geometryBuildMs: 0,\n })\n if (opts.svg) this.#om()\n return\n }\n\n let atlasBuildMs = 0\n if (canReuseRetainedText) {\n nextRetained = retained\n } else {\n const buildStarted = now()\n const customProvider = opts.outlineProvider ?? opts.slug?.outlineProvider\n if (customProvider !== undefined && typeof customProvider !== 'function') {\n throw new TypeError('DomSlug: outlineProvider must be a function')\n }\n let resolvedProvider = customProvider\n if (!resolvedProvider) {\n if (!this.#to) {\n this.#to = createTracedOutlineProvider(this.source.ownerDocument, {\n ...(opts.colorGlyphs === undefined ? {} : { colorGlyphs: opts.colorGlyphs }),\n ...(opts.traceSize === undefined ? {} : { size: opts.traceSize }),\n ...(opts.traceTolerance === undefined ? {} : { tolerance: opts.traceTolerance }),\n })\n } else if (forceOutlines) {\n this.#to.clear()\n }\n resolvedProvider = this.#to.provider\n }\n const targetPiecesPerBand = opts.targetPiecesPerBand ?? opts.slug?.targetPiecesPerBand\n nextRetained = await buildStandaloneSlugBackend(\n this.renderer,\n snapshot.requests,\n {\n outlineProvider: resolvedProvider,\n missingGlyphs: opts.missingGlyphs ?? (customProvider ? 'error' : 'skip'),\n ...(targetPiecesPerBand === undefined ? {} : { targetPiecesPerBand }),\n },\n controller.signal,\n )\n ownsNextRetained = true\n atlasBuildMs = now() - buildStarted\n }\n throwIfAborted(controller.signal)\n if (generation !== this.#g) {\n throw abortError('Superseded by a newer DOM Slug build')\n }\n\n const geometryStarted = now()\n nextRetained.setGlyphEm(!!tone?.dilationPx)\n const updatedInPlace =\n canReuseRetainedText && (this.#c?.u(snapshot, nextRetained, this.#m, tone) ?? false)\n if (!updatedInPlace) {\n nextContent = createSlugContent(snapshot, nextRetained, opts, this.#m, tone)\n }\n const geometryBuildMs = now() - geometryStarted\n throwIfAborted(controller.signal)\n\n const oldContent = this.#c\n const oldRetained = this.#r\n let activeContent: SlugContentBundle\n if (nextContent) {\n if (oldContent) this.remove(oldContent.g)\n this.add(nextContent.g)\n this.#c = nextContent\n activeContent = nextContent\n } else {\n activeContent = oldContent!\n }\n this.#r = nextRetained\n this.snapshot = opts.reflowable === true ? snapshot : null\n this.#w = snapshot.width\n this.#h = snapshot.height\n this.#as = snapshot.atlasSignature\n this.#ls = signature ?? layoutSignatureOf(snapshot)\n this.#cm = true\n if (opts.svg) this.#om()\n this.#to?.retain(snapshot.requests.map((request) => request.key))\n\n let glyphCount = 0\n let shapeCount = 0\n let skippedCount = 0\n for (const glyph of snapshot.glyphs) {\n if (glyph.shapeGroup !== undefined) {\n shapeCount++\n continue\n }\n glyphCount++\n if (nextRetained.skippedKeys.has(glyph.glyphKey)) skippedCount++\n }\n\n this.#st = Object.freeze({\n atlasBuildMs,\n layoutReadMs,\n geometryBuildMs,\n glyphs: glyphCount,\n shapes: shapeCount,\n colorGlyphs: 0,\n fallbackGlyphs: skippedCount,\n switchableGlyphs: 0,\n rects: snapshot.rects.length,\n lines: snapshot.lineCount,\n draws: activeContent.g.children.length,\n atlasWidth: 0,\n atlasHeight: 0,\n textBackend: 'slug',\n atlasMode: null,\n textStorageBytes: nextRetained.storageBytes,\n })\n nextContent = null\n ownsNextRetained = false\n if (oldContent && oldContent !== activeContent) oldContent.d()\n if (oldRetained && oldRetained !== nextRetained) oldRetained.dispose()\n } catch (error) {\n nextContent?.d()\n if (ownsNextRetained) nextRetained?.dispose()\n throw error\n } finally {\n externalSignal?.removeEventListener('abort', forwardAbort)\n if (this.#a === controller) this.#a = null\n }\n }\n\n #sr(forceOutlines = false, lazy = false): void {\n if (this.#d) return\n this.#fa ||= forceOutlines\n const view = this.source.ownerDocument.defaultView\n if (!view) return\n if (lazy && this.#f === 0) {\n const nowMs = now()\n if (this.#t !== 0) view.clearTimeout(this.#t)\n else this.#dl = nowMs + ATTRIBUTE_MAX_WAIT_MS\n const delay = Math.min(ATTRIBUTE_DEBOUNCE_MS, Math.max(0, this.#dl - nowMs))\n this.#t = view.setTimeout(() => {\n this.#t = 0\n this.#rr()\n }, delay)\n return\n }\n if (this.#t !== 0) {\n view.clearTimeout(this.#t)\n this.#t = 0\n }\n if (this.#f !== 0) return\n this.#f = view.requestAnimationFrame(() => {\n this.#f = 0\n this.#rr()\n })\n }\n\n #rr(): void {\n const outlines = this.#fa\n this.#fa = false\n void this.rebuild({ outlines }).catch((error: unknown) => {\n if (error instanceof DOMException && error.name === 'AbortError') return\n this.options.onError?.(error)\n })\n }\n\n #co(): void {\n if (this.options.observe === false || this.#d) return\n const view = this.source.ownerDocument.defaultView\n if (!view) return\n\n this.#ro = new ResizeObserver(() => {\n this.#sr()\n })\n this.#ro.observe(this.source)\n this.#mo = new MutationObserver((records) => {\n this.#sr(\n false,\n records.every((record) => record.type === 'attributes'),\n )\n })\n this.#om()\n\n const fonts = this.source.ownerDocument.fonts as FontFaceSet | undefined\n if (fonts) {\n const onFontsLoaded = (): void => {\n this.#to?.clear()\n this.#sr(true)\n }\n fonts.addEventListener('loadingdone', onFontsLoaded)\n this.#uf = () => {\n fonts.removeEventListener('loadingdone', onFontsLoaded)\n }\n }\n }\n\n #om(): void {\n const observer = this.#mo\n if (!observer) return\n observer.disconnect()\n const options = { attributes: true, characterData: true, childList: true, subtree: true }\n observer.observe(this.source, options)\n if (!this.options.svg) return\n const seen = new Set<Element>([this.source])\n const pending: Element[] = [this.source]\n while (pending.length) {\n const source = pending.pop()!\n const uses = [...source.querySelectorAll('use')]\n if (source.localName === 'use') uses.unshift(source as SVGUseElement)\n for (const use of uses) {\n const href = use.getAttribute('href') ?? use.getAttribute('xlink:href') ?? ''\n const tree = use.getRootNode() as Document | ShadowRoot\n const target = href.startsWith('#') ? tree.getElementById(href.slice(1)) : null\n if (!target || seen.has(target)) continue\n seen.add(target)\n if (!this.source.contains(target)) observer.observe(target, options)\n pending.push(target)\n }\n }\n }\n\n override dispose(): void {\n if (this.#d) return\n this.#d = true\n this.#g++\n this.#a?.abort(abortError('The DOM Slug instance was disposed'))\n const view = this.source.ownerDocument.defaultView\n if (view && this.#f !== 0) view.cancelAnimationFrame(this.#f)\n if (view && this.#t !== 0) view.clearTimeout(this.#t)\n this.#ro?.disconnect()\n this.#mo?.disconnect()\n this.#uf?.()\n if (this.#c) {\n this.remove(this.#c.g)\n this.#c.d()\n }\n this.#r?.dispose()\n this.#to?.clear()\n this.#a = this.#ro = this.#mo = this.#uf = this.#c = this.#r = this.#to = this.snapshot = null\n this.#f = this.#t = this.#w = this.#h = 0\n this.#cm = false\n this.#as = this.#ls = ''\n this.#st = EMPTY_SLUG_STATS\n this.source.classList.remove('sdf-selectable')\n this.clear()\n super.dispose()\n }\n}\n"],"mappings":";;;;;;;;;;;;;AAmCA,IAAM,mBAA2C,OAAO,OAAO;CAC7D,cAAc;CACd,cAAc;CACd,iBAAiB;CACjB,QAAQ;CACR,QAAQ;CACR,aAAa;CACb,gBAAgB;CAChB,kBAAkB;CAClB,OAAO;CACP,OAAO;CACP,OAAO;CACP,YAAY;CACZ,aAAa;CACb,aAAa;CACb,WAAW;CACX,kBAAkB;AACpB,CAAC;AAED,IAAM,wBAAwB;AAC9B,IAAM,wBAAwB;AAmB9B,SAAS,MAAc;CACrB,OAAO,YAAY,IAAI;AACzB;AAEA,SAAS,WAAW,UAAU,kCAAgD;CAC5E,OAAO,IAAI,aAAa,SAAS,YAAY;AAC/C;AAEA,SAAS,eAAe,QAA2B;CACjD,IAAI,OAAO,SAAS,MAAM,OAAO,UAAU,WAAW;AACxD;AAEA,SAAS,kBACP,UACA,SACA,SACA,QACA,MACmB;CACnB,MAAM,kBAAkB;EAAE,GAAG;EAAS,MAAM,QAAS;CAAgB;CACrE,MAAM,QAAQ,IAAI,MAAM;CACxB,MAAM,OAAO;CACb,MAAM,mBAAmB;CACzB,MAAM,aAAa;CAEnB,MAAM,WAAW,OAAO,YAAY;CACpC,IAAI,WAAW,iBAAiB,MAAM;CACtC,MAAM,kBAAkB,SACtB,WAAW,OAAO;CACpB,MAAM,YAAY,eAAe,QAAQ;CACzC,MAAM,EAAE,UAAU,eAAe,gBAAgB,QAAQ,eAAe,UAAU,QAAQ;CAE1F,IAAI;CACJ,IAAI;EACF,eAAe,QAAQ,eAAe;GACpC,GAAG;GACH;GACA,QAAQ,eAAe,MAAM;EAC/B,CAAC;CACH,SAAS,OAAO;EACd,cAAc,QAAQ;EACtB,MAAM;CAC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AAO,gBAAgB;EAC7C,KAAK,MAAM;EACX,MAAM,QAAQ;CAChB;AACF"}
1
+ {"version":3,"file":"DomSlug.js","names":[],"sources":["../../src/dom/DomSlug.ts"],"sourcesContent":["import { Group, Mesh, type InstancedBufferGeometry, type WebGPURenderer } from 'three/webgpu'\n\nimport {\n buildStandaloneSlugBackend,\n type StandaloneSlugBackend,\n} from '../slug/standaloneRuntime.js'\nimport { hasDecorations, needsRunMotion } from '../text/geometryUtils.js'\nimport { isAnimatedMotion, type GlyphTextMaterial } from '../text/GlyphTextMaterial.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 DomSlugOptions,\n DomSlugRebuildOptions,\n DomSlugStats,\n SdfMotionOptions,\n} from '../types.js'\nimport type * as TracedOutlinesModule from '../windfoil/tracedOutlines.js'\nimport type { TracedOutlines } from '../windfoil/tracedOutlines.js'\nimport type * as DomExtrasModule from './domExtras.js'\nimport type { ContentExtrasController, StagedExtras } from './domExtras.js'\nimport { layoutSignatureOf } from './layoutSignature.js'\nimport { DEFAULT_RECT_SELECTOR } from './markup.js'\nimport { collectDomSnapshot } from './snapshot.js'\nimport type * as SvgCaptureModule from './svgCapture.js'\nimport { resolveDomTextTone } from './tone.js'\n\nconst EMPTY_SLUG_STATS: Readonly<DomSlugStats> = Object.freeze({\n atlasBuildMs: 0,\n layoutReadMs: 0,\n geometryBuildMs: 0,\n glyphs: 0,\n shapes: 0,\n colorGlyphs: 0,\n fallbackGlyphs: 0,\n switchableGlyphs: 0,\n rects: 0,\n lines: 0,\n draws: 0,\n atlasWidth: 0,\n atlasHeight: 0,\n textBackend: 'slug',\n atlasMode: null,\n textStorageBytes: 0,\n})\n\nconst ATTRIBUTE_DEBOUNCE_MS = 80\nconst ATTRIBUTE_MAX_WAIT_MS = 320\n\ninterface SlugContentBundle {\n readonly g: Group\n readonly m: GlyphTextMaterial\n readonly tg: InstancedBufferGeometry\n sm(change: SdfMotionOptions, live: SdfMotionOptions): void\n st(tone: ResolvedTextTone | null): boolean\n ud(snapshot: DomLayoutSnapshot, backend: StandaloneSlugBackend, motion: SdfMotionOptions): void\n rg(geometry: InstancedBufferGeometry): void\n u(\n snapshot: DomLayoutSnapshot,\n backend: StandaloneSlugBackend,\n motion: SdfMotionOptions,\n tone?: ResolvedTextTone | null,\n ): boolean\n d(): void\n}\n\nfunction now(): number {\n return performance.now()\n}\n\nfunction abortError(message = 'The DOM Slug build was aborted'): DOMException {\n return new DOMException(message, 'AbortError')\n}\n\nfunction throwIfAborted(signal: AbortSignal): void {\n if (signal.aborted) throw signal.reason ?? abortError()\n}\n\nfunction createSlugContent(\n snapshot: DomLayoutSnapshot,\n backend: StandaloneSlugBackend,\n options: DomSlugOptions,\n motion: SdfMotionOptions,\n tone: ResolvedTextTone | null,\n extrasMod?: typeof DomExtrasModule | null,\n): SlugContentBundle {\n const materialOptions = { ...options, tone: tone ?? (false as const) }\n const group = new Group()\n group.name = 'ultra-text generated DOM Slug content'\n group.matrixAutoUpdate = false\n group.updateMatrix()\n\n const strength = motion.strength ?? 18\n let animated = isAnimatedMotion(motion)\n const materialMotion = (live: SdfMotionOptions): SdfMotionOptions | false =>\n animated ? live : false\n const runMotion = needsRunMotion(snapshot)\n const { geometry: glyphGeometry, maxSequence } = backend.createGeometry(snapshot, strength)\n\n let textMaterial: GlyphTextMaterial\n try {\n textMaterial = backend.createMaterial({\n ...materialOptions,\n maxSequence,\n motion: materialMotion(motion),\n })\n } catch (error) {\n glyphGeometry.dispose()\n throw error\n }\n\n const text = new Mesh(glyphGeometry, textMaterial)\n text.name = 'ultra-text slug text'\n text.castShadow = options.castShadow !== false\n text.frustumCulled = false\n text.renderOrder = 2\n text.matrixAutoUpdate = false\n text.updateMatrix()\n group.add(text)\n\n const ownedMeshes: Mesh[] = [text]\n const disposeMeshes = (): void => {\n for (const mesh of ownedMeshes) {\n mesh.geometry.dispose()\n for (const material of Array.isArray(mesh.material) ? mesh.material : [mesh.material]) {\n material.dispose()\n }\n }\n ownedMeshes.length = 0\n group.clear()\n }\n\n const glyphDrawable = (retained: StandaloneSlugBackend, key: string): boolean =>\n (retained.glyphs.get(key)?.monotonePieceCount ?? 0) > 0\n\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\n const setTone = (next: ResolvedTextTone | null): boolean => textMaterial.setTone(next)\n const toneFits = (next: ResolvedTextTone | null): boolean => {\n const current = textMaterial.tone\n return current && next ? current.fits(next) : !current && !next\n }\n\n let disposed = false\n return {\n g: group,\n get m(): GlyphTextMaterial {\n return textMaterial\n },\n get tg(): InstancedBufferGeometry {\n return text.geometry\n },\n sm(change, live) {\n if (animated) {\n textMaterial.setMotion(change)\n 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 rg(geometry: InstancedBufferGeometry): void {\n swapGeometry(text, geometry)\n },\n u(nextSnapshot, nextBackend, liveMotion, nextTone) {\n if (\n nextTone !== undefined &&\n (!toneFits(nextTone) || animated !== isAnimatedMotion(liveMotion))\n ) {\n return false\n }\n if (runMotion !== needsRunMotion(nextSnapshot)) return false\n if (\n ce\n ? !ce.fitsLayout(nextSnapshot)\n : nextSnapshot.rects.length > 0 || hasDecorations(nextSnapshot)\n ) {\n return false\n }\n const nextStrength = 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 && nextBackend.contentFits(text.geometry, nextSnapshot)\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 = nextBackend.createGeometry(nextSnapshot, nextStrength)\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\n if (built) {\n swapGeometry(text, built.geometry)\n textMaterial.maxSequence.value = built.maxSequence\n } else {\n const updatedMax = nextBackend.updateGeometry(\n text.geometry,\n nextSnapshot,\n nextStrength,\n true,\n )\n if (updatedMax === null) {\n releaseStaged()\n throw new Error('DomSlug: glyph buffers changed during the update')\n }\n textMaterial.maxSequence.value = updatedMax\n }\n 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\n/**\n * Retained Three.js WebGPU/TSL controller for pure GPU Slug quadratic-curve text (`ultra-text/slug`).\n * Excludes all SDF rasterization, JFA atlas compute, and texture state.\n */\nexport class DomSlug extends Group {\n readonly renderer: WebGPURenderer\n readonly source: HTMLElement\n readonly options: Readonly<DomSlugOptions>\n protected readonly pageBackdrop: boolean = true\n\n #r: StandaloneSlugBackend | null = null\n #c: SlugContentBundle | null = null\n #a: AbortController | null = null\n #g = 0\n #d = false\n #f = 0\n #t = 0\n #dl = 0\n #fa = false\n #ro: ResizeObserver | null = null\n #mo: MutationObserver | null = null\n #uf: (() => void) | null = null\n private snapshot: DomLayoutSnapshot | null = null\n #rf: ReflowState | null = null\n #rm: typeof ReflowModule | null = null\n #em: typeof DomExtrasModule | null = null\n #sm: typeof SvgCaptureModule | null = null\n #w = 0\n #h = 0\n #as = ''\n #ls = ''\n #cm = false\n #ga = false\n #st: Readonly<DomSlugStats> = EMPTY_SLUG_STATS\n #m: SdfMotionOptions\n #to: TracedOutlines | null = null\n\n protected constructor(renderer: WebGPURenderer, source: HTMLElement, options: DomSlugOptions) {\n super()\n this.name = 'ultra-text DOM Slug'\n this.renderer = renderer\n this.source = source\n const copy = { ...options }\n for (const key of ['motion', 'slug', 'svg', 'tone'] as const) {\n if (typeof copy[key] === 'object') {\n ;(copy as Record<string, unknown>)[key] = Object.freeze({ ...copy[key] })\n }\n }\n this.options = Object.freeze(copy)\n this.#m = { ...options.motion }\n if (options.selectable) this.source.classList.add('sdf-selectable')\n }\n\n static async create(\n renderer: WebGPURenderer,\n source: HTMLElement,\n options: DomSlugOptions = {},\n ): Promise<DomSlug> {\n const domSlug = new DomSlug(renderer, source, options)\n await domSlug.initialize()\n return domSlug\n }\n\n protected async initialize(): Promise<void> {\n try {\n await this.rebuild({ outlines: true })\n this.#co()\n } catch (error) {\n this.dispose()\n throw error\n }\n }\n\n get width(): number {\n return this.#c ? this.#w : 0\n }\n\n get height(): number {\n return this.#c ? this.#h : 0\n }\n\n get stats(): Readonly<DomSlugStats> {\n return this.#st\n }\n\n /** Always `null` on `DomSlug`: pure Slug stores curves in GPU buffers, never textures. */\n readonly atlasTexture = null\n\n setMotion(options: SdfMotionOptions): this {\n const motion = { ...this.#m, ...options }\n this.#c?.sm(options, motion)\n this.#m = motion\n return this\n }\n\n reflow(width: number): this {\n if (this.#d) throw new Error('DomSlug.reflow: this instance is disposed')\n const rm = this.#rm\n if (!this.snapshot || !rm) {\n throw new Error('DomSlug.reflow: create the instance with reflowable: true first')\n }\n if (!this.#r || !this.#c) return this\n const retained = this.#r\n const content = this.#c\n retained.setGlyphEm(!!content.m.tone?.dilates)\n\n const started = now()\n const reflowed = rm.reflowSnapshotWithState(\n this.snapshot,\n width,\n (this.#rf ??= rm.createReflowState(this.snapshot)),\n )\n const strength = this.#m.strength ?? 18\n let maxSequence = retained.updateGeometry(content.tg, reflowed, strength)\n if (maxSequence === null) {\n const built = retained.createGeometry(reflowed, strength)\n content.rg(built.geometry)\n maxSequence = built.maxSequence\n }\n content.m.maxSequence.value = maxSequence\n content.ud(reflowed, retained, this.#m)\n this.#cm = false\n this.#w = reflowed.width\n this.#h = reflowed.height\n this.#st = Object.freeze({\n ...this.#st,\n lines: reflowed.lineCount,\n layoutReadMs: 0,\n atlasBuildMs: 0,\n geometryBuildMs: now() - started,\n })\n return this\n }\n\n async rebuild(rebuildOptions: DomSlugRebuildOptions = {}): Promise<void> {\n if (this.#d) throw new Error('DomSlug.rebuild: this instance is disposed')\n const externalSignal = this.options.signal\n if (externalSignal?.aborted) {\n throw externalSignal.reason ?? abortError()\n }\n const opts = this.options\n if (opts.textShaping === 'browser') {\n throw new Error(\n 'DomSlug: textShaping \"browser\" requires an SDF atlas; use \"none\" (default) for pure Slug outlines',\n )\n }\n\n this.#a?.abort(abortError('Superseded by a newer DOM Slug build'))\n const controller = new AbortController()\n this.#a = controller\n const generation = ++this.#g\n const forwardAbort = (): void => {\n controller.abort(externalSignal?.reason ?? abortError())\n }\n externalSignal?.addEventListener('abort', forwardAbort, { once: true })\n\n let nextRetained: StandaloneSlugBackend | null = null\n let ownsNextRetained = false\n let nextContent: SlugContentBundle | null = null\n const forceOutlines = rebuildOptions.outlines === true || rebuildOptions.atlas === true\n let reflowPromise: Promise<unknown> | null = null\n\n try {\n if (opts.reflowable === true && !this.#rm) {\n reflowPromise = import('../text/reflow.js').then((mod) => {\n this.#rm = mod\n })\n }\n await Promise.resolve()\n throwIfAborted(controller.signal)\n if (generation !== this.#g) {\n throw abortError('Superseded by a newer DOM Slug build')\n }\n\n const customProvider = opts.outlineProvider ?? opts.slug?.outlineProvider\n const preloadTraced: Promise<typeof TracedOutlinesModule | null> | null =\n !customProvider && !this.#to\n ? import('../windfoil/tracedOutlines.js').catch(() => null)\n : null\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 const 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\n const retained = this.#r\n const canReuseRetainedText =\n !forceOutlines &&\n retained !== null &&\n (this.#as === snapshot.atlasSignature ||\n snapshot.requests.every((request) => retained.covers(request.key)))\n const signature =\n canReuseRetainedText && this.#c !== null && this.#cm\n ? layoutSignatureOf(snapshot)\n : undefined\n\n if (\n canReuseRetainedText &&\n this.#c !== null &&\n this.#cm &&\n signature === this.#ls &&\n generation === this.#g &&\n this.#c.st(tone)\n ) {\n this.#st = Object.freeze({\n ...this.#st,\n layoutReadMs,\n atlasBuildMs: 0,\n geometryBuildMs: 0,\n })\n if (svgPromise) await svgPromise\n if (opts.svg) this.#om()\n return\n }\n\n let appended = false\n let atlasBuildMs = 0\n if (canReuseRetainedText) {\n nextRetained = retained\n } else {\n const buildStarted = now()\n if (\n !forceOutlines &&\n retained?.append &&\n (await retained.append(snapshot.requests, controller.signal))\n ) {\n appended = true\n nextRetained = retained\n } else {\n if (forceOutlines) this.#ga = false\n else if (retained !== null) this.#ga = true\n if (customProvider !== undefined && typeof customProvider !== 'function') {\n throw new TypeError('DomSlug: outlineProvider must be a function')\n }\n let resolvedProvider = customProvider\n if (!resolvedProvider) {\n if (!this.#to) {\n const { createTracedOutlineProvider } =\n (await preloadTraced) ?? (await import('../windfoil/tracedOutlines.js'))\n throwIfAborted(controller.signal)\n if (generation !== this.#g) {\n throw abortError('Superseded by a newer DOM Slug build')\n }\n this.#to ??= createTracedOutlineProvider(this.source.ownerDocument, {\n ...(opts.colorGlyphs === undefined ? {} : { colorGlyphs: opts.colorGlyphs }),\n ...(opts.traceSize === undefined ? {} : { size: opts.traceSize }),\n ...(opts.traceTolerance === undefined ? {} : { tolerance: opts.traceTolerance }),\n })\n } else if (forceOutlines) {\n this.#to.clear()\n }\n resolvedProvider = this.#to.provider\n }\n const targetPiecesPerBand = opts.targetPiecesPerBand ?? opts.slug?.targetPiecesPerBand\n nextRetained = await buildStandaloneSlugBackend(\n this.renderer,\n snapshot.requests,\n {\n outlineProvider: resolvedProvider,\n missingGlyphs: opts.missingGlyphs ?? (customProvider ? 'error' : 'skip'),\n ...(targetPiecesPerBand === undefined ? {} : { targetPiecesPerBand }),\n },\n controller.signal,\n this.#ga,\n )\n ownsNextRetained = true\n }\n atlasBuildMs = now() - buildStarted\n }\n throwIfAborted(controller.signal)\n if (generation !== this.#g) {\n throw abortError('Superseded by a newer DOM Slug build')\n }\n\n if (extrasPromise) {\n await extrasPromise\n throwIfAborted(controller.signal)\n if (generation !== this.#g) {\n throw abortError('Superseded by a newer DOM Slug build')\n }\n }\n const geometryStarted = now()\n nextRetained.setGlyphEm(!!tone?.dilationPx)\n const updatedInPlace =\n (canReuseRetainedText || appended) &&\n (this.#c?.u(snapshot, nextRetained, this.#m, tone) ?? false)\n if (!updatedInPlace) {\n nextContent = createSlugContent(snapshot, nextRetained, opts, this.#m, tone, this.#em)\n }\n const geometryBuildMs = now() - geometryStarted\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: SlugContentBundle\n if (nextContent) {\n if (oldContent) this.remove(oldContent.g)\n this.add(nextContent.g)\n this.#c = nextContent\n activeContent = nextContent\n } else {\n activeContent = oldContent!\n }\n this.#r = nextRetained\n this.snapshot = opts.reflowable === true ? snapshot : null\n this.#rf = null\n this.#w = snapshot.width\n this.#h = snapshot.height\n this.#as = snapshot.atlasSignature\n this.#ls = signature ?? layoutSignatureOf(snapshot)\n this.#cm = true\n if (opts.svg) this.#om()\n this.#to?.retain(snapshot.requests.map((request) => request.key))\n\n let glyphCount = 0\n let shapeCount = 0\n let skippedCount = 0\n for (const glyph of snapshot.glyphs) {\n if (glyph.shapeGroup !== undefined) {\n shapeCount++\n continue\n }\n glyphCount++\n if (nextRetained.skippedKeys.has(glyph.glyphKey)) skippedCount++\n }\n\n this.#st = Object.freeze({\n atlasBuildMs,\n layoutReadMs,\n geometryBuildMs,\n glyphs: glyphCount,\n shapes: shapeCount,\n colorGlyphs: 0,\n fallbackGlyphs: skippedCount,\n switchableGlyphs: 0,\n rects: snapshot.rects.length,\n lines: snapshot.lineCount,\n draws: activeContent.g.children.length,\n atlasWidth: 0,\n atlasHeight: 0,\n textBackend: 'slug',\n atlasMode: null,\n textStorageBytes: nextRetained.storageBytes,\n })\n nextContent = null\n ownsNextRetained = false\n if (oldContent && oldContent !== activeContent) oldContent.d()\n if (oldRetained && oldRetained !== nextRetained) oldRetained.dispose()\n } catch (error) {\n nextContent?.d()\n if (ownsNextRetained) nextRetained?.dispose()\n throw error\n } finally {\n externalSignal?.removeEventListener('abort', forwardAbort)\n if (this.#a === controller) this.#a = null\n }\n }\n\n #sr(forceOutlines = false, lazy = false): void {\n if (this.#d) return\n this.#fa ||= forceOutlines\n const view = this.source.ownerDocument.defaultView\n if (!view) return\n if (lazy && this.#f === 0) {\n const nowMs = now()\n if (this.#t !== 0) view.clearTimeout(this.#t)\n else this.#dl = nowMs + ATTRIBUTE_MAX_WAIT_MS\n const delay = Math.min(ATTRIBUTE_DEBOUNCE_MS, Math.max(0, this.#dl - nowMs))\n this.#t = view.setTimeout(() => {\n this.#t = 0\n this.#rr()\n }, delay)\n return\n }\n if (this.#t !== 0) {\n view.clearTimeout(this.#t)\n this.#t = 0\n }\n if (this.#f !== 0) return\n this.#f = view.requestAnimationFrame(() => {\n this.#f = 0\n this.#rr()\n })\n }\n\n #rr(): void {\n const outlines = this.#fa\n this.#fa = false\n void this.rebuild({ outlines }).catch((error: unknown) => {\n if (error instanceof DOMException && error.name === 'AbortError') return\n this.options.onError?.(error)\n })\n }\n\n #co(): void {\n if (this.options.observe === false || this.#d) return\n const view = this.source.ownerDocument.defaultView\n if (!view) return\n\n this.#ro = new ResizeObserver(() => {\n this.#sr()\n })\n this.#ro.observe(this.source)\n this.#mo = new MutationObserver((records) => {\n this.#sr(\n false,\n records.every((record) => record.type === 'attributes'),\n )\n })\n this.#om()\n\n const fonts = this.source.ownerDocument.fonts as FontFaceSet | undefined\n if (fonts) {\n const onFontsLoaded = (): void => {\n this.#to?.clear()\n this.#sr(true)\n }\n fonts.addEventListener('loadingdone', onFontsLoaded)\n this.#uf = () => {\n fonts.removeEventListener('loadingdone', onFontsLoaded)\n }\n }\n }\n\n #om(): void {\n const observer = this.#mo\n if (!observer) return\n observer.disconnect()\n const options = { attributes: true, characterData: true, childList: true, subtree: true }\n observer.observe(this.source, options)\n if (this.options.svg) 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 Slug instance was disposed'))\n const view = this.source.ownerDocument.defaultView\n if (view && this.#f !== 0) view.cancelAnimationFrame(this.#f)\n if (view && this.#t !== 0) view.clearTimeout(this.#t)\n this.#ro?.disconnect()\n this.#mo?.disconnect()\n this.#uf?.()\n if (this.#c) {\n this.remove(this.#c.g)\n this.#c.d()\n }\n this.#r?.dispose()\n this.#to?.clear()\n this.#a = this.#ro = this.#mo = this.#uf = this.#c = this.#r = this.#to = this.snapshot = null\n this.#f = this.#t = this.#w = this.#h = 0\n this.#cm = false\n this.#as = this.#ls = ''\n this.#st = EMPTY_SLUG_STATS\n this.source.classList.remove('sdf-selectable')\n this.clear()\n super.dispose()\n }\n}\n"],"mappings":";;;;;;;;;AA4BA,IAAM,mBAA2C,OAAO,OAAO;CAC7D,cAAc;CACd,cAAc;CACd,iBAAiB;CACjB,QAAQ;CACR,QAAQ;CACR,aAAa;CACb,gBAAgB;CAChB,kBAAkB;CAClB,OAAO;CACP,OAAO;CACP,OAAO;CACP,YAAY;CACZ,aAAa;CACb,aAAa;CACb,WAAW;CACX,kBAAkB;AACpB,CAAC;AAED,IAAM,wBAAwB;AAC9B,IAAM,wBAAwB;AAmB9B,SAAS,MAAc;CACrB,OAAO,YAAY,IAAI;AACzB;AAEA,SAAS,WAAW,UAAU,kCAAgD;CAC5E,OAAO,IAAI,aAAa,SAAS,YAAY;AAC/C;AAEA,SAAS,eAAe,QAA2B;CACjD,IAAI,OAAO,SAAS,MAAM,OAAO,UAAU,WAAW;AACxD;AAEA,SAAS,kBACP,UACA,SACA,SACA,QACA,MACA,WACmB;CACnB,MAAM,kBAAkB;EAAE,GAAG;EAAS,MAAM,QAAS;CAAgB;CACrE,MAAM,QAAQ,IAAI,MAAM;CACxB,MAAM,OAAO;CACb,MAAM,mBAAmB;CACzB,MAAM,aAAa;CAEnB,MAAM,WAAW,OAAO,YAAY;CACpC,IAAI,WAAW,iBAAiB,MAAM;CACtC,MAAM,kBAAkB,SACtB,WAAW,OAAO;CACpB,MAAM,YAAY,eAAe,QAAQ;CACzC,MAAM,EAAE,UAA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AM,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,oCAAoC,CAAC;EAC/D,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,QAAQ;EACjB,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,MAAM;EACX,KAAK,MAAM,KAAK,MAAM;EACtB,KAAK,MAAM;EACX,KAAK,OAAO,UAAU,OAAO,gBAAgB;EAC7C,KAAK,MAAM;EACX,MAAM,QAAQ;CAChB;AACF"}
@@ -0,0 +1,54 @@
1
+ import { Group, type InstancedBufferGeometry, type WebGPURenderer } from 'three/webgpu';
2
+ import type { createExtraTextParts } from '../windfoil/mixed.js';
3
+ import type { WindfoilBackend } from '../windfoil/runtime.js';
4
+ import type { TracedOutlines } from '../windfoil/tracedOutlines.js';
5
+ import type * as SlugRuntime from '../slug/runtime.js';
6
+ import type * as WindfoilRuntime from '../windfoil/runtime.js';
7
+ import type * as TracedOutlinesModule from '../windfoil/tracedOutlines.js';
8
+ import type { RasterizeOptions } from '../atlas/rasterize.js';
9
+ import { type GlyphTextMaterial } from '../text/GlyphTextMaterial.js';
10
+ import type { ReflowState } from '../text/reflow.js';
11
+ import type * as ReflowModule from '../text/reflow.js';
12
+ import type { ResolvedTextTone } from '../text/tone.js';
13
+ import type { DomLayoutSnapshot, DomSdfOptions, SdfAtlas, SdfMotionOptions, WindfoilOptions } from '../types.js';
14
+ import type * as DomExtrasModule from './domExtras.js';
15
+ export interface AnalyticRetainedResult {
16
+ readonly retained: WindfoilBackend | null;
17
+ readonly traced: TracedOutlines | null;
18
+ }
19
+ export interface AnalyticBuildCallbacks {
20
+ readonly preloadBackend: Promise<typeof SlugRuntime | typeof WindfoilRuntime | null> | null;
21
+ readonly preloadTraced: Promise<typeof TracedOutlinesModule | null> | null;
22
+ readonly loadTraced: () => Promise<typeof TracedOutlinesModule>;
23
+ readonly buildAtlas: (requests: DomLayoutSnapshot['requests'], signal: AbortSignal, appendable?: RasterizeOptions['appendable']) => Promise<SdfAtlas>;
24
+ }
25
+ export declare function buildDomAnalyticBackend(renderer: WebGPURenderer, doc: Document, snapshot: DomLayoutSnapshot, opts: DomSdfOptions, backendKind: 'windfoil' | 'slug', analytic: WindfoilOptions, headroom: boolean, existingTraced: TracedOutlines | null, resetAtlas: boolean, signal: AbortSignal, throwIfAborted: (s: AbortSignal) => void, callbacks: AnalyticBuildCallbacks): Promise<AnalyticRetainedResult>;
26
+ export declare function loadMixedExtras(): Promise<{
27
+ createExtraTextParts: typeof createExtraTextParts;
28
+ }>;
29
+ export interface AnalyticContentBundle {
30
+ readonly g: Group;
31
+ readonly m: GlyphTextMaterial;
32
+ readonly tg: InstancedBufferGeometry;
33
+ readonly a: boolean;
34
+ sm(change: SdfMotionOptions, live: SdfMotionOptions): void;
35
+ st(tone: ResolvedTextTone | null): boolean;
36
+ ud(snapshot: DomLayoutSnapshot, backend: WindfoilBackend, motion: SdfMotionOptions): void;
37
+ rg(geometry: InstancedBufferGeometry): void;
38
+ u(snapshot: DomLayoutSnapshot, backend: WindfoilBackend, motion: SdfMotionOptions, tone?: ResolvedTextTone | null): boolean;
39
+ d(): void;
40
+ }
41
+ export declare function createAnalyticContent(snapshot: DomLayoutSnapshot, backend: WindfoilBackend, options: DomSdfOptions, motion: SdfMotionOptions, tone: ResolvedTextTone | null, makeExtraParts?: typeof createExtraTextParts, extrasMod?: typeof DomExtrasModule | null): AnalyticContentBundle;
42
+ export declare function reflowAnalytic(snapshot: DomLayoutSnapshot, retained: WindfoilBackend, content: AnalyticContentBundle, width: number, motion: SdfMotionOptions, rm: typeof ReflowModule, reflowState: ReflowState | null): {
43
+ readonly width: number;
44
+ readonly height: number;
45
+ readonly lines: number;
46
+ readonly state: ReflowState;
47
+ };
48
+ export declare function countAnalyticStats(snapshot: DomLayoutSnapshot, windfoil: WindfoilBackend): readonly [
49
+ glyphs: number,
50
+ shapes: number,
51
+ colorGlyphs: number,
52
+ fallbackGlyphs: number,
53
+ switchableGlyphs: number
54
+ ];