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.
- package/README.md +224 -1002
- package/dist/assets/{cpuSdf.worker-xS57yQbP.js → cpuSdf.worker--X1Qpmdp.js} +136 -47
- package/dist/assets/cpuSdf.worker--X1Qpmdp.js.map +1 -0
- package/dist/atlas/appendAtlas.js +67 -25
- package/dist/atlas/appendAtlas.js.map +1 -1
- package/dist/atlas/buildAtlas.js +3 -2
- package/dist/atlas/buildAtlas.js.map +1 -1
- package/dist/atlas/cpuAtlas.d.ts +4 -1
- package/dist/atlas/cpuAtlas.js +8 -6
- package/dist/atlas/cpuAtlas.js.map +1 -1
- package/dist/atlas/cpuSdf.js +152 -40
- package/dist/atlas/cpuSdf.js.map +1 -1
- package/dist/atlas/cpuWorker.d.ts +5 -3
- package/dist/atlas/cpuWorker.js +119 -12
- package/dist/atlas/cpuWorker.js.map +1 -1
- package/dist/atlas/gpuAtlas.js +100 -276
- package/dist/atlas/gpuAtlas.js.map +1 -1
- package/dist/atlas/gpuCommon.d.ts +135 -0
- package/dist/atlas/gpuCommon.js +223 -0
- package/dist/atlas/gpuCommon.js.map +1 -0
- package/dist/atlas/jfaWgsl.js +47 -241
- package/dist/atlas/jfaWgsl.js.map +1 -1
- package/dist/atlas/rasterize.js +103 -58
- package/dist/atlas/rasterize.js.map +1 -1
- package/dist/atlas/shapeRaster.js +2 -1
- package/dist/atlas/shapeRaster.js.map +1 -1
- package/dist/atlas/vanillaBounds.d.ts +64 -0
- package/dist/atlas/vanillaBounds.js +42 -0
- package/dist/atlas/vanillaBounds.js.map +1 -0
- package/dist/atlas/vanillaCore.d.ts +100 -0
- package/dist/atlas/vanillaCore.js +1012 -0
- package/dist/atlas/vanillaCore.js.map +1 -0
- package/dist/atlas/vanillaCpuAtlas.d.ts +9 -0
- package/dist/atlas/vanillaCpuAtlas.js +87 -0
- package/dist/atlas/vanillaCpuAtlas.js.map +1 -0
- package/dist/atlas/vanillaExtras.d.ts +8 -0
- package/dist/atlas/vanillaExtras.js +166 -0
- package/dist/atlas/vanillaExtras.js.map +1 -0
- package/dist/atlas/vanillaGpuHelpers.d.ts +232 -0
- package/dist/atlas/vanillaGpuHelpers.js +119 -0
- package/dist/atlas/vanillaGpuHelpers.js.map +1 -0
- package/dist/dom/DomSdf.js +224 -284
- package/dist/dom/DomSdf.js.map +1 -1
- package/dist/dom/DomSlug.js +75 -151
- package/dist/dom/DomSlug.js.map +1 -1
- package/dist/dom/domAnalytic.d.ts +54 -0
- package/dist/dom/domAnalytic.js +282 -0
- package/dist/dom/domAnalytic.js.map +1 -0
- package/dist/dom/domExtras.d.ts +27 -0
- package/dist/dom/domExtras.js +137 -0
- package/dist/dom/domExtras.js.map +1 -0
- package/dist/dom/fontCanvas.js +27 -9
- package/dist/dom/fontCanvas.js.map +1 -1
- package/dist/dom/layoutSignature.js +150 -48
- package/dist/dom/layoutSignature.js.map +1 -1
- package/dist/dom/pretextLayout.js +55 -13
- package/dist/dom/pretextLayout.js.map +1 -1
- package/dist/dom/snapshot.js +369 -204
- package/dist/dom/snapshot.js.map +1 -1
- package/dist/dom/svgCapture.d.ts +8 -1
- package/dist/dom/svgCapture.js +75 -1
- package/dist/dom/svgCapture.js.map +1 -1
- package/dist/dom/tone.js +76 -36
- package/dist/dom/tone.js.map +1 -1
- package/dist/index.js +4 -3
- package/dist/slug/SlugMaterial.d.ts +11 -3
- package/dist/slug/SlugMaterial.js +54 -10
- package/dist/slug/SlugMaterial.js.map +1 -1
- package/dist/slug/coverage.d.ts +16 -12
- package/dist/slug/coverage.js +194 -221
- package/dist/slug/coverage.js.map +1 -1
- package/dist/slug/preprocessCore.d.ts +5 -1
- package/dist/slug/preprocessCore.js +118 -87
- package/dist/slug/preprocessCore.js.map +1 -1
- package/dist/slug/runtime.d.ts +1 -0
- package/dist/slug/runtime.js +90 -44
- package/dist/slug/runtime.js.map +1 -1
- package/dist/slug/standaloneRuntime.d.ts +3 -2
- package/dist/slug/standaloneRuntime.js +75 -40
- package/dist/slug/standaloneRuntime.js.map +1 -1
- package/dist/slug/truetype.js +166 -193
- package/dist/slug/truetype.js.map +1 -1
- package/dist/slug/vanillaCore.d.ts +340 -0
- package/dist/slug/vanillaCore.js +1621 -0
- package/dist/slug/vanillaCore.js.map +1 -0
- package/dist/slug-vanilla.d.ts +13 -364
- package/dist/slug-vanilla.js +5 -1453
- package/dist/slug.d.ts +1 -1
- package/dist/slug.js +6 -6
- package/dist/text/GlyphTextMaterial.d.ts +1 -1
- package/dist/text/GlyphTextMaterial.js +5 -5
- package/dist/text/GlyphTextMaterial.js.map +1 -1
- package/dist/text/SdfTextMaterial.js +7 -5
- package/dist/text/SdfTextMaterial.js.map +1 -1
- package/dist/text/decorations.js +36 -19
- package/dist/text/decorations.js.map +1 -1
- package/dist/text/geometry.d.ts +3 -22
- package/dist/text/geometryUtils.d.ts +11 -1
- package/dist/text/geometryUtils.js +22 -1
- package/dist/text/geometryUtils.js.map +1 -1
- package/dist/text/glyphGeometry.d.ts +9 -0
- package/dist/text/glyphGeometry.js +353 -0
- package/dist/text/glyphGeometry.js.map +1 -0
- package/dist/text/index.d.ts +2 -1
- package/dist/text/rectGeometry.d.ts +13 -0
- package/dist/text/rectGeometry.js +97 -0
- package/dist/text/rectGeometry.js.map +1 -0
- package/dist/text/reflow.d.ts +18 -1
- package/dist/text/reflow.js +108 -38
- package/dist/text/reflow.js.map +1 -1
- package/dist/text/snap.d.ts +1 -0
- package/dist/text/snap.js +26 -0
- package/dist/text/snap.js.map +1 -0
- package/dist/vanilla.d.ts +13 -363
- package/dist/vanilla.js +6 -1473
- package/dist/windfoil/geometry.d.ts +2 -2
- package/dist/windfoil/geometry.js +113 -40
- package/dist/windfoil/geometry.js.map +1 -1
- package/dist/windfoil/mixed.d.ts +1 -0
- package/dist/windfoil/mixed.js +44 -25
- package/dist/windfoil/mixed.js.map +1 -1
- package/dist/windfoil/preprocess.js +2 -2
- package/dist/windfoil/preprocessCore.d.ts +1 -0
- package/dist/windfoil/preprocessCore.js +9 -4
- package/dist/windfoil/preprocessCore.js.map +1 -1
- package/dist/windfoil/runtime.d.ts +3 -1
- package/dist/windfoil/runtime.js +62 -40
- package/dist/windfoil/runtime.js.map +1 -1
- package/dist/windfoil/storage.d.ts +60 -2
- package/dist/windfoil/storage.js +142 -6
- package/dist/windfoil/storage.js.map +1 -1
- package/dist/windfoil/trace/contours.d.ts +5 -0
- package/dist/windfoil/trace/contours.js +167 -43
- package/dist/windfoil/trace/contours.js.map +1 -1
- package/dist/windfoil/trace/fit.d.ts +3 -1
- package/dist/windfoil/trace/fit.js +471 -175
- package/dist/windfoil/trace/fit.js.map +1 -1
- package/dist/windfoil/trace/outline.js +55 -30
- package/dist/windfoil/trace/outline.js.map +1 -1
- package/dist/windfoil/trace/types.d.ts +10 -0
- package/dist/windfoil/tracedOutlines.js +59 -34
- package/dist/windfoil/tracedOutlines.js.map +1 -1
- package/package.json +11 -11
- package/skills/ultra-text/references/three-tsl.md +2 -2
- package/skills/ultra-text/references/vanilla-webgpu.md +3 -2
- package/dist/assets/cpuSdf.worker-xS57yQbP.js.map +0 -1
- package/dist/slug-vanilla.js.map +0 -1
- package/dist/text/geometry.js +0 -348
- package/dist/text/geometry.js.map +0 -1
- package/dist/vanilla.js.map +0 -1
|
@@ -1,53 +1,29 @@
|
|
|
1
1
|
import { abortable, throwIfAborted } from "../windfoil/abortable.js";
|
|
2
2
|
import { createWindfoilGlyphGeometry, updateWindfoilGlyphGeometry, windfoilContentFits } from "../windfoil/geometry.js";
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
3
|
+
import { collectMissingRequests, createRetainedSlugStorage, createRetainedWindfoilStorage, mergePreprocessStats, resolveOutlineRequests } from "../windfoil/storage.js";
|
|
4
|
+
import { preprocessSlugGlyphsBatch } from "./preprocessCore.js";
|
|
5
5
|
import { SlugMaterial } from "./SlugMaterial.js";
|
|
6
6
|
import { WebGPUBackend } from "three/webgpu";
|
|
7
7
|
// src/slug/standaloneRuntime.ts
|
|
8
8
|
/** Builds a pure GPU Slug backend without any SDF companion or atlas dependency. */
|
|
9
|
-
async function buildStandaloneSlugBackend(renderer, requests, options, signal) {
|
|
9
|
+
async function buildStandaloneSlugBackend(renderer, requests, options, signal, headroom = false) {
|
|
10
10
|
await abortable(renderer.init(), signal);
|
|
11
11
|
throwIfAborted(signal);
|
|
12
12
|
if (!(renderer.backend instanceof WebGPUBackend)) throw new Error("DomSlug: the Slug text backend requires WebGPU");
|
|
13
13
|
const limit = renderer.backend.device?.limits.maxVertexBuffers ?? 8;
|
|
14
14
|
if (limit < 7) throw new Error("DomSlug: Slug requires at least seven vertex buffers");
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
if (extensions) resolved = await abortable(Promise.all(requests.map(async (request) => ({
|
|
18
|
-
request,
|
|
19
|
-
outline: await extensions.resolveShapeRequest(request, { outlineProvider: options.outlineProvider }, signal)
|
|
20
|
-
}))), signal);
|
|
21
|
-
else {
|
|
22
|
-
const syncResolved = [];
|
|
23
|
-
let pending = null;
|
|
24
|
-
for (const request of requests) {
|
|
25
|
-
const out = options.outlineProvider(request, signal);
|
|
26
|
-
if (out instanceof Promise) {
|
|
27
|
-
pending ??= syncResolved.map((item) => Promise.resolve(item));
|
|
28
|
-
pending.push(out.then((outline) => ({
|
|
29
|
-
request,
|
|
30
|
-
outline
|
|
31
|
-
})));
|
|
32
|
-
} else if (pending) pending.push(Promise.resolve({
|
|
33
|
-
request,
|
|
34
|
-
outline: out
|
|
35
|
-
}));
|
|
36
|
-
else syncResolved.push({
|
|
37
|
-
request,
|
|
38
|
-
outline: out
|
|
39
|
-
});
|
|
40
|
-
}
|
|
41
|
-
resolved = pending ? await abortable(Promise.all(pending), signal) : syncResolved;
|
|
42
|
-
}
|
|
15
|
+
let extensions = requests.some((request) => request.shape !== void 0) ? await abortable(import("../windfoil/requests.js"), signal) : null;
|
|
16
|
+
const resolved = await resolveOutlineRequests(requests, options, signal, extensions);
|
|
43
17
|
throwIfAborted(signal);
|
|
44
18
|
const missing = resolved.filter((item) => item.outline === null);
|
|
45
19
|
const missingMode = options.missingGlyphs ?? "error";
|
|
46
20
|
if (missing.length > 0 && missingMode === "error") throw new Error(`DomSlug: outlineProvider returned null for ${JSON.stringify(missing[0].request.character)} in ${missing[0].request.font.family}`);
|
|
47
21
|
const skippedKeys = new Set(missing.map((item) => item.request.key));
|
|
48
|
-
|
|
49
|
-
const
|
|
22
|
+
let layerModule = resolved.some((item) => item.outline?.layers !== void 0 || item.outline?.clipBox !== void 0) ? await abortable(import("../windfoil/layerNormalization.js"), signal) : null;
|
|
23
|
+
const wantsComposite = resolved.some((item) => item.outline?.clipBox !== void 0);
|
|
24
|
+
const prepared = preprocessSlugGlyphsBatch(resolved.filter((item) => item.outline !== null), {
|
|
50
25
|
signal,
|
|
26
|
+
vec4Curves: !wantsComposite,
|
|
51
27
|
...layerModule ? { normalizeLayers: layerModule.normalizeLayers } : {},
|
|
52
28
|
...options.targetPiecesPerBand === void 0 ? {} : { targetPiecesPerBand: options.targetPiecesPerBand }
|
|
53
29
|
});
|
|
@@ -59,12 +35,22 @@ async function buildStandaloneSlugBackend(renderer, requests, options, signal) {
|
|
|
59
35
|
try {
|
|
60
36
|
const colorModule = colorPromise ? await abortable(colorPromise, signal) : null;
|
|
61
37
|
throwIfAborted(signal);
|
|
62
|
-
|
|
38
|
+
const storageHeadroom = headroom ? {
|
|
39
|
+
minCurveFloats: 4096,
|
|
40
|
+
minRowUints: 512,
|
|
41
|
+
rowAlign: 1,
|
|
42
|
+
maxCurveFloats: 1 << 19
|
|
43
|
+
} : false;
|
|
44
|
+
coverage = wantsComposite ? createRetainedWindfoilStorage(renderer, prepared, storageHeadroom) : createRetainedSlugStorage(renderer, prepared, storageHeadroom);
|
|
63
45
|
colorResources = colorModule?.buildWindfoilColorResources(renderer, prepared, {
|
|
64
46
|
outlineProvider: options.outlineProvider,
|
|
65
47
|
compositing: "layers"
|
|
66
48
|
}, coverage, signal) ?? null;
|
|
49
|
+
const glyphs = prepared.glyphs;
|
|
67
50
|
const plainGlyphs = colorResources?.plainGlyphs ?? prepared.glyphs;
|
|
51
|
+
let usedCurves = prepared.curves.length;
|
|
52
|
+
let usedRows = prepared.rows.length;
|
|
53
|
+
let stats = prepared.stats;
|
|
68
54
|
let glyphEm = false;
|
|
69
55
|
const sized = /* @__PURE__ */ new WeakMap();
|
|
70
56
|
const withEm = (snapshot) => {
|
|
@@ -89,12 +75,14 @@ async function buildStandaloneSlugBackend(renderer, requests, options, signal) {
|
|
|
89
75
|
return {
|
|
90
76
|
kind: "slug",
|
|
91
77
|
layered,
|
|
92
|
-
glyphs
|
|
78
|
+
glyphs,
|
|
93
79
|
skippedKeys,
|
|
94
80
|
storageBytes: coverage.storageBytes + (colorResources?.storageBytes ?? 0),
|
|
95
|
-
preprocessStats
|
|
81
|
+
get preprocessStats() {
|
|
82
|
+
return stats;
|
|
83
|
+
},
|
|
96
84
|
covers(key) {
|
|
97
|
-
return
|
|
85
|
+
return glyphs.has(key) || skippedKeys.has(key);
|
|
98
86
|
},
|
|
99
87
|
analyticCovers(key) {
|
|
100
88
|
return !!plainGlyphs.get(key)?.monotonePieceCount;
|
|
@@ -108,15 +96,62 @@ async function buildStandaloneSlugBackend(renderer, requests, options, signal) {
|
|
|
108
96
|
if (geometryLayered && limit < 8) throw new Error("DomSlug: layered Slug requires eight vertex buffers");
|
|
109
97
|
return createWindfoilGlyphGeometry(layout, plainGlyphs, padding, geometryLayered);
|
|
110
98
|
},
|
|
111
|
-
updateGeometry(geometry, snapshot, padding) {
|
|
112
|
-
return updateWindfoilGlyphGeometry(geometry, withEm(snapshot), plainGlyphs, padding);
|
|
99
|
+
updateGeometry(geometry, snapshot, padding, checked = false) {
|
|
100
|
+
return updateWindfoilGlyphGeometry(geometry, withEm(snapshot), plainGlyphs, padding, void 0, checked);
|
|
101
|
+
},
|
|
102
|
+
async append(nextRequests, appendSignal) {
|
|
103
|
+
if (disposed) return false;
|
|
104
|
+
const missingReqs = collectMissingRequests(nextRequests, (key) => glyphs.has(key) || skippedKeys.has(key));
|
|
105
|
+
if (missingReqs.length === 0) return true;
|
|
106
|
+
if (!extensions && missingReqs.some((req) => req.shape !== void 0)) extensions = await abortable(import("../windfoil/requests.js"), appendSignal);
|
|
107
|
+
const deltaResolved = await resolveOutlineRequests(missingReqs, options, appendSignal, extensions);
|
|
108
|
+
throwIfAborted(appendSignal);
|
|
109
|
+
const deltaMissing = deltaResolved.filter((item) => item.outline === null);
|
|
110
|
+
if (deltaMissing.length > 0 && missingMode === "error") throw new Error(`DomSlug: outlineProvider returned null for ${JSON.stringify(deltaMissing[0].request.character)} in ${deltaMissing[0].request.font.family}`);
|
|
111
|
+
const nonNull = deltaResolved.filter((item) => item.outline !== null);
|
|
112
|
+
if (nonNull.length === 0) {
|
|
113
|
+
for (const item of deltaMissing) skippedKeys.add(item.request.key);
|
|
114
|
+
return true;
|
|
115
|
+
}
|
|
116
|
+
if (!layerModule && nonNull.some((item) => item.outline.layers !== void 0 || item.outline.clipBox !== void 0)) {
|
|
117
|
+
layerModule = await abortable(import("../windfoil/layerNormalization.js"), appendSignal);
|
|
118
|
+
throwIfAborted(appendSignal);
|
|
119
|
+
}
|
|
120
|
+
let delta;
|
|
121
|
+
try {
|
|
122
|
+
delta = preprocessSlugGlyphsBatch(nonNull, {
|
|
123
|
+
signal: appendSignal,
|
|
124
|
+
vec4Curves: !wantsComposite,
|
|
125
|
+
...layerModule ? { normalizeLayers: layerModule.normalizeLayers } : {},
|
|
126
|
+
...options.targetPiecesPerBand === void 0 ? {} : { targetPiecesPerBand: options.targetPiecesPerBand }
|
|
127
|
+
}, usedCurves, usedRows);
|
|
128
|
+
} catch (error) {
|
|
129
|
+
if (error instanceof RangeError && (error.message.includes("17-bit") || error.message.includes("18-bit"))) return false;
|
|
130
|
+
throw error;
|
|
131
|
+
}
|
|
132
|
+
if (delta.layered && !layered) return false;
|
|
133
|
+
for (const header of delta.glyphs.values()) if ((header.layers?.some((layer) => layer.paintKind === 2) ?? false) || header.layers && !!header.clipBox) return false;
|
|
134
|
+
if (usedCurves + delta.curves.length > retained.curveCapacityFloats || usedRows + delta.rows.length > retained.rowCapacityUints) return false;
|
|
135
|
+
throwIfAborted(appendSignal);
|
|
136
|
+
retained.writeCurves(usedCurves, delta.curves);
|
|
137
|
+
retained.writeRows(usedRows, delta.rows);
|
|
138
|
+
usedCurves += delta.curves.length;
|
|
139
|
+
usedRows += delta.rows.length;
|
|
140
|
+
for (const item of deltaMissing) skippedKeys.add(item.request.key);
|
|
141
|
+
for (const [key, header] of delta.glyphs) {
|
|
142
|
+
glyphs.set(key, header);
|
|
143
|
+
if (plainGlyphs !== glyphs) plainGlyphs.set(key, header);
|
|
144
|
+
}
|
|
145
|
+
stats = mergePreprocessStats(stats, delta.stats, glyphs.size);
|
|
146
|
+
return true;
|
|
113
147
|
},
|
|
114
148
|
setGlyphEm(value) {
|
|
115
149
|
glyphEm = value;
|
|
116
150
|
},
|
|
117
151
|
createMaterial(materialOptions) {
|
|
118
152
|
return new SlugMaterial({
|
|
119
|
-
|
|
153
|
+
curves: retained.curves,
|
|
154
|
+
rows: retained.rows,
|
|
120
155
|
layered: geometryLayered,
|
|
121
156
|
...colorResources ? { paintFunctions: colorResources.paintFunctions } : {},
|
|
122
157
|
...materialOptions
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"standaloneRuntime.js","names":[],"sources":["../../src/slug/standaloneRuntime.ts"],"sourcesContent":["import {\n WebGPUBackend,\n type InstancedBufferGeometry,\n type Side,\n type WebGPURenderer,\n} from 'three/webgpu'\nimport type { GlyphTextMaterial } from '../text/GlyphTextMaterial.js'\nimport type { ResolvedTextTone } from '../text/tone.js'\nimport type {\n DomLayoutSnapshot,\n GlyphRequest,\n SdfMotionOptions,\n TextFill,\n TextToneOptions,\n TextVertex,\n WindfoilOutlineProvider,\n} from '../types.js'\nimport type { WindfoilColorResources } from '../windfoil/color.js'\nimport {\n createWindfoilGlyphGeometry,\n updateWindfoilGlyphGeometry,\n windfoilContentFits,\n} from '../windfoil/geometry.js'\nimport type { WindfoilGlyphHeader, WindfoilPreprocessStats } from '../windfoil/preprocessCore.js'\nimport { abortable, createWindfoilStorage, throwIfAborted } from '../windfoil/storage.js'\nimport { preprocessSlugGlyphs } from './preprocessCore.js'\nimport { SlugMaterial } from './SlugMaterial.js'\n\nexport interface StandaloneSlugBuildOptions {\n readonly outlineProvider: WindfoilOutlineProvider\n readonly missingGlyphs?: 'skip' | 'error'\n readonly targetPiecesPerBand?: number\n}\n\nexport interface StandaloneSlugBackend {\n readonly kind: 'slug'\n readonly layered: boolean\n readonly glyphs: ReadonlyMap<string, WindfoilGlyphHeader>\n readonly skippedKeys: ReadonlySet<string>\n readonly storageBytes: number\n readonly preprocessStats: WindfoilPreprocessStats\n covers(key: string): boolean\n analyticCovers(key: string): boolean\n contentFits(geometry: InstancedBufferGeometry, snapshot: DomLayoutSnapshot): boolean\n createGeometry(\n snapshot: DomLayoutSnapshot,\n motionPadding: number,\n ): { geometry: InstancedBufferGeometry; maxSequence: number }\n updateGeometry(\n geometry: InstancedBufferGeometry,\n snapshot: DomLayoutSnapshot,\n motionPadding: number,\n ): number | null\n setGlyphEm(value: boolean): void\n createMaterial(options: {\n readonly fill?: TextFill\n readonly vertex?: TextVertex\n readonly shadowCutoff?: number\n readonly side?: Side\n readonly motion: SdfMotionOptions | false\n readonly maxSequence: number\n readonly tone?: TextToneOptions | ResolvedTextTone | false\n }): GlyphTextMaterial\n dispose(): void\n}\n\n/** Builds a pure GPU Slug backend without any SDF companion or atlas dependency. */\nexport async function buildStandaloneSlugBackend(\n renderer: WebGPURenderer,\n requests: readonly GlyphRequest[],\n options: StandaloneSlugBuildOptions,\n signal: AbortSignal,\n): Promise<StandaloneSlugBackend> {\n await abortable(renderer.init(), signal)\n throwIfAborted(signal)\n if (!(renderer.backend instanceof WebGPUBackend)) {\n throw new Error('DomSlug: the Slug text backend requires WebGPU')\n }\n const limit =\n (renderer.backend as unknown as { device?: { limits: { maxVertexBuffers: number } } }).device\n ?.limits.maxVertexBuffers ?? 8\n if (limit < 7) {\n throw new Error('DomSlug: Slug requires at least seven vertex buffers')\n }\n\n const hasShapes = requests.some((request) => request.shape !== undefined)\n const extensions = hasShapes ? await abortable(import('../windfoil/requests.js'), signal) : null\n\n let resolved: {\n request: GlyphRequest\n outline: Awaited<ReturnType<WindfoilOutlineProvider>>\n }[]\n if (extensions) {\n resolved = await abortable(\n Promise.all(\n requests.map(async (request) => ({\n request,\n outline: await extensions.resolveShapeRequest(\n request,\n { outlineProvider: options.outlineProvider },\n signal,\n ),\n })),\n ),\n signal,\n )\n } else {\n const syncResolved: {\n request: GlyphRequest\n outline: Awaited<ReturnType<WindfoilOutlineProvider>>\n }[] = []\n let pending:\n | Promise<{\n request: GlyphRequest\n outline: Awaited<ReturnType<WindfoilOutlineProvider>>\n }>[]\n | null = null\n for (const request of requests) {\n const out = options.outlineProvider(request, signal)\n if (out instanceof Promise) {\n pending ??= syncResolved.map((item) => Promise.resolve(item))\n pending.push(out.then((outline) => ({ request, outline })))\n } else if (pending) {\n pending.push(Promise.resolve({ request, outline: out }))\n } else {\n syncResolved.push({ request, outline: out })\n }\n }\n resolved = pending ? await abortable(Promise.all(pending), signal) : syncResolved\n }\n throwIfAborted(signal)\n\n const missing = resolved.filter((item) => item.outline === null)\n const missingMode = options.missingGlyphs ?? 'error'\n if (missing.length > 0 && missingMode === 'error') {\n throw new Error(\n `DomSlug: outlineProvider returned null for ${JSON.stringify(missing[0]!.request.character)} in ${missing[0]!.request.font.family}`,\n )\n }\n const skippedKeys = new Set(missing.map((item) => item.request.key))\n\n const needsLayerNormalization = resolved.some(\n (item) => item.outline?.layers !== undefined || item.outline?.clipBox !== undefined,\n )\n const layerModule = needsLayerNormalization\n ? await abortable(import('../windfoil/layerNormalization.js'), signal)\n : null\n\n const prepared = preprocessSlugGlyphs(\n resolved.filter(\n (item): item is typeof item & { outline: NonNullable<typeof item.outline> } =>\n item.outline !== null,\n ),\n {\n signal,\n ...(layerModule ? { normalizeLayers: layerModule.normalizeLayers } : {}),\n ...(options.targetPiecesPerBand === undefined\n ? {}\n : { targetPiecesPerBand: options.targetPiecesPerBand }),\n },\n )\n\n const layered = prepared.layered\n if (layered && limit < 8) {\n throw new Error('DomSlug: layered Slug requires eight vertex buffers')\n }\n\n const wantsColor = [...prepared.glyphs.values()].some(\n (header) => header.layers?.some((layer) => layer.paintKind === 2) ?? false,\n )\n const colorPromise = wantsColor ? import('../windfoil/color.js') : null\n\n let coverage: ReturnType<typeof createWindfoilStorage> | undefined\n let colorResources: WindfoilColorResources | null = null\n try {\n const colorModule = colorPromise ? await abortable(colorPromise, signal) : null\n throwIfAborted(signal)\n coverage = createWindfoilStorage(renderer, prepared)\n colorResources =\n colorModule?.buildWindfoilColorResources(\n renderer,\n prepared,\n { outlineProvider: options.outlineProvider, compositing: 'layers' },\n coverage,\n signal,\n ) ?? null\n const plainGlyphs = colorResources?.plainGlyphs ?? prepared.glyphs\n\n let glyphEm = false\n const sized = new WeakMap<DomLayoutSnapshot, DomLayoutSnapshot>()\n const withEm = (snapshot: DomLayoutSnapshot): DomLayoutSnapshot => {\n if (!glyphEm) return snapshot\n let layout = sized.get(snapshot)\n if (!layout) {\n layout = {\n ...snapshot,\n sizeSwitched: true,\n glyphs: snapshot.glyphs.map((glyph) => ({\n ...glyph,\n switchEm: glyph.shapeGroup === undefined ? -glyph.fontSize : 0,\n })),\n }\n sized.set(snapshot, layout)\n }\n return layout\n }\n\n let geometryLayered = layered\n let disposed = false\n const retained = coverage\n return {\n kind: 'slug',\n layered,\n glyphs: prepared.glyphs,\n skippedKeys,\n storageBytes: coverage.storageBytes + (colorResources?.storageBytes ?? 0),\n preprocessStats: prepared.stats,\n covers(key) {\n return prepared.glyphs.has(key) || skippedKeys.has(key)\n },\n analyticCovers(key) {\n return !!plainGlyphs.get(key)?.monotonePieceCount\n },\n contentFits(geometry, snapshot) {\n return windfoilContentFits(geometry, withEm(snapshot), plainGlyphs)\n },\n createGeometry(snapshot, padding) {\n const layout = withEm(snapshot)\n geometryLayered = layered || layout.glyphs.some((glyph) => !!glyph.motionOrigin)\n if (geometryLayered && limit < 8) {\n throw new Error('DomSlug: layered Slug requires eight vertex buffers')\n }\n return createWindfoilGlyphGeometry(layout, plainGlyphs, padding, geometryLayered)\n },\n updateGeometry(geometry, snapshot, padding) {\n return updateWindfoilGlyphGeometry(geometry, withEm(snapshot), plainGlyphs, padding)\n },\n setGlyphEm(value) {\n glyphEm = value\n },\n createMaterial(materialOptions) {\n return new SlugMaterial({\n ...retained,\n layered: geometryLayered,\n ...(colorResources ? { paintFunctions: colorResources.paintFunctions } : {}),\n ...materialOptions,\n })\n },\n dispose() {\n if (disposed) return\n disposed = true\n retained.dispose()\n colorResources?.dispose()\n },\n }\n } catch (error) {\n coverage?.dispose()\n colorResources?.dispose()\n throw error\n }\n}\n"],"mappings":";;;;;;;;AAmEA,eAAsB,2BACpB,UACA,UACA,SACA,QACgC;CAChC,MAAM,UAAU,SAAS,KAAK,GAAG,MAAM;CACvC,eAAe,MAAM;CACrB,IAAI,EAAE,SAAS,mBAAmB,gBAChC,MAAM,IAAI,MAAM,gDAAgD;CAElE,MAAM,QACH,SAAS,QAA6E,QACnF,OAAO,oBAAoB;CACjC,IAAI,QAAQ,GACV,MAAM,IAAI,MAAM,sDAAsD;CAIxE,MAAM,aADY,SAAS,MAAM,YAAY,QAAQ,UAAU,KAAA,CAC5C,IAAY,MAAM,UAAU,OAAO,4BAA4B,MAAM,IAAI;CAE5F,IAAI;CAIJ,IAAI,YACF,WAAW,MAAM,UACf,QAAQ,IACN,SAAS,IAAI,OAAO,aAAa;EAC/B;EACA,SAAS,MAAM,WAAW,oBACxB,SACA,EAAE,iBAAiB,QAAQ,gBAAgB,GAC3C,MACF;CACF,EAAE,CACJ,GACA,MACF;MACK;EACL,MAAM,eAGA,CAAC;EACP,IAAI,UAKO;EACX,KAAK,MAAM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AU,SAAS;IAChC,MAAM,SAAS,OAAO,QAAQ;IAC9B,kBAAkB,WAAW,OAAO,OAAO,MAAM,UAAU,CAAC,CAAC,MAAM,YAAY;IAC/E,IAAI,mBAAmB,QAAQ,GAC7B,MAAM,IAAI,MAAM,qDAAqD;IAEvE,OAAO,4BAA4B,QAAQ,aAAa,SAAS,eAAe;GAClF;GACA,eAAe,UAAU,UAAU,SAAS;IAC1C,OAAO,4BAA4B,UAAU,OAAO,QAAQ,GAAG,aAAa,OAAO;GACrF;GACA,WAAW,OAAO;IAChB,UAAU;GACZ;GACA,eAAe,iBAAiB;IAC9B,OAAO,IAAI,aAAa;KACtB,GAAG;KACH,SAAS;KACT,GAAI,iBAAiB,EAAE,gBAAgB,eAAe,eAAe,IAAI,CAAC;KAC1E,GAAG;IACL,CAAC;GACH;GACA,UAAU;IACR,IAAI,UAAU;IACd,WAAW;IACX,SAAS,QAAQ;IACjB,gBAAgB,QAAQ;GAC1B;EACF;CACF,SAAS,OAAO;EACd,UAAU,QAAQ;EAClB,gBAAgB,QAAQ;EACxB,MAAM;CACR;AACF"}
|
|
1
|
+
{"version":3,"file":"standaloneRuntime.js","names":[],"sources":["../../src/slug/standaloneRuntime.ts"],"sourcesContent":["import {\n WebGPUBackend,\n type InstancedBufferGeometry,\n type Side,\n type WebGPURenderer,\n} from 'three/webgpu'\nimport type { GlyphTextMaterial } from '../text/GlyphTextMaterial.js'\nimport type { ResolvedTextTone } from '../text/tone.js'\nimport type {\n DomLayoutSnapshot,\n GlyphRequest,\n SdfMotionOptions,\n TextFill,\n TextToneOptions,\n TextVertex,\n WindfoilOutlineProvider,\n} from '../types.js'\nimport type { WindfoilColorResources } from '../windfoil/color.js'\nimport {\n createWindfoilGlyphGeometry,\n updateWindfoilGlyphGeometry,\n windfoilContentFits,\n} from '../windfoil/geometry.js'\nimport type { WindfoilGlyphHeader, WindfoilPreprocessStats } from '../windfoil/preprocessCore.js'\nimport type { WindfoilStorage } from '../windfoil/WindfoilMaterial.js'\nimport {\n abortable,\n collectMissingRequests,\n createRetainedSlugStorage,\n createRetainedWindfoilStorage,\n mergePreprocessStats,\n resolveOutlineRequests,\n throwIfAborted,\n type RetainedSlugStorage,\n type RetainedWindfoilStorage,\n} from '../windfoil/storage.js'\nimport { preprocessSlugGlyphsBatch } from './preprocessCore.js'\nimport { SlugMaterial } from './SlugMaterial.js'\n\nexport interface StandaloneSlugBuildOptions {\n readonly outlineProvider: WindfoilOutlineProvider\n readonly missingGlyphs?: 'skip' | 'error'\n readonly targetPiecesPerBand?: number\n}\n\nexport interface StandaloneSlugBackend {\n readonly kind: 'slug'\n readonly layered: boolean\n readonly glyphs: ReadonlyMap<string, WindfoilGlyphHeader>\n readonly skippedKeys: ReadonlySet<string>\n readonly storageBytes: number\n readonly preprocessStats: WindfoilPreprocessStats\n covers(key: string): boolean\n analyticCovers(key: string): boolean\n contentFits(geometry: InstancedBufferGeometry, snapshot: DomLayoutSnapshot): boolean\n createGeometry(\n snapshot: DomLayoutSnapshot,\n motionPadding: number,\n ): { geometry: InstancedBufferGeometry; maxSequence: number }\n updateGeometry(\n geometry: InstancedBufferGeometry,\n snapshot: DomLayoutSnapshot,\n motionPadding: number,\n checked?: boolean,\n ): number | null\n append?(requests: readonly GlyphRequest[], signal: AbortSignal): Promise<boolean>\n setGlyphEm(value: boolean): void\n createMaterial(options: {\n readonly fill?: TextFill\n readonly vertex?: TextVertex\n readonly shadowCutoff?: number\n readonly side?: Side\n readonly motion: SdfMotionOptions | false\n readonly maxSequence: number\n readonly tone?: TextToneOptions | ResolvedTextTone | false\n }): GlyphTextMaterial\n dispose(): void\n}\n\n/** Builds a pure GPU Slug backend without any SDF companion or atlas dependency. */\nexport async function buildStandaloneSlugBackend(\n renderer: WebGPURenderer,\n requests: readonly GlyphRequest[],\n options: StandaloneSlugBuildOptions,\n signal: AbortSignal,\n headroom = false,\n): Promise<StandaloneSlugBackend> {\n await abortable(renderer.init(), signal)\n throwIfAborted(signal)\n if (!(renderer.backend instanceof WebGPUBackend)) {\n throw new Error('DomSlug: the Slug text backend requires WebGPU')\n }\n const limit =\n (renderer.backend as unknown as { device?: { limits: { maxVertexBuffers: number } } }).device\n ?.limits.maxVertexBuffers ?? 8\n if (limit < 7) {\n throw new Error('DomSlug: Slug requires at least seven vertex buffers')\n }\n\n const hasShapes = requests.some((request) => request.shape !== undefined)\n let extensions = hasShapes ? await abortable(import('../windfoil/requests.js'), signal) : null\n const resolved = await resolveOutlineRequests(requests, options, signal, extensions)\n throwIfAborted(signal)\n\n const missing = resolved.filter((item) => item.outline === null)\n const missingMode = options.missingGlyphs ?? 'error'\n if (missing.length > 0 && missingMode === 'error') {\n throw new Error(\n `DomSlug: outlineProvider returned null for ${JSON.stringify(missing[0]!.request.character)} in ${missing[0]!.request.font.family}`,\n )\n }\n const skippedKeys = new Set(missing.map((item) => item.request.key))\n\n const needsLayerNormalization = resolved.some(\n (item) => item.outline?.layers !== undefined || item.outline?.clipBox !== undefined,\n )\n let layerModule = needsLayerNormalization\n ? await abortable(import('../windfoil/layerNormalization.js'), signal)\n : null\n\n const wantsComposite = resolved.some((item) => item.outline?.clipBox !== undefined)\n const prepared = preprocessSlugGlyphsBatch(\n resolved.filter(\n (item): item is typeof item & { outline: NonNullable<typeof item.outline> } =>\n item.outline !== null,\n ),\n {\n signal,\n vec4Curves: !wantsComposite,\n ...(layerModule ? { normalizeLayers: layerModule.normalizeLayers } : {}),\n ...(options.targetPiecesPerBand === undefined\n ? {}\n : { targetPiecesPerBand: options.targetPiecesPerBand }),\n },\n )\n\n const layered = prepared.layered\n if (layered && limit < 8) {\n throw new Error('DomSlug: layered Slug requires eight vertex buffers')\n }\n\n const wantsColor = [...prepared.glyphs.values()].some(\n (header) => header.layers?.some((layer) => layer.paintKind === 2) ?? false,\n )\n const colorPromise = wantsColor ? import('../windfoil/color.js') : null\n\n let coverage: RetainedSlugStorage | RetainedWindfoilStorage | undefined\n let colorResources: WindfoilColorResources | null = null\n try {\n const colorModule = colorPromise ? await abortable(colorPromise, signal) : null\n throwIfAborted(signal)\n const storageHeadroom = headroom\n ? { minCurveFloats: 4096, minRowUints: 512, rowAlign: 1, maxCurveFloats: 1 << 19 }\n : false\n coverage = wantsComposite\n ? createRetainedWindfoilStorage(renderer, prepared, storageHeadroom)\n : createRetainedSlugStorage(renderer, prepared, storageHeadroom)\n colorResources =\n colorModule?.buildWindfoilColorResources(\n renderer,\n prepared,\n { outlineProvider: options.outlineProvider, compositing: 'layers' },\n coverage as WindfoilStorage,\n signal,\n ) ?? null\n const glyphs = prepared.glyphs as Map<string, WindfoilGlyphHeader>\n const plainGlyphs = (colorResources?.plainGlyphs ?? prepared.glyphs) as Map<\n string,\n WindfoilGlyphHeader\n >\n let usedCurves = prepared.curves.length\n let usedRows = prepared.rows.length\n let stats = prepared.stats\n\n let glyphEm = false\n const sized = new WeakMap<DomLayoutSnapshot, DomLayoutSnapshot>()\n const withEm = (snapshot: DomLayoutSnapshot): DomLayoutSnapshot => {\n if (!glyphEm) return snapshot\n let layout = sized.get(snapshot)\n if (!layout) {\n layout = {\n ...snapshot,\n sizeSwitched: true,\n glyphs: snapshot.glyphs.map((glyph) => ({\n ...glyph,\n switchEm: glyph.shapeGroup === undefined ? -glyph.fontSize : 0,\n })),\n }\n sized.set(snapshot, layout)\n }\n return layout\n }\n\n let geometryLayered = layered\n let disposed = false\n const retained = coverage\n return {\n kind: 'slug',\n layered,\n glyphs,\n skippedKeys,\n storageBytes: coverage.storageBytes + (colorResources?.storageBytes ?? 0),\n get preprocessStats() {\n return stats\n },\n covers(key) {\n return glyphs.has(key) || skippedKeys.has(key)\n },\n analyticCovers(key) {\n return !!plainGlyphs.get(key)?.monotonePieceCount\n },\n contentFits(geometry, snapshot) {\n return windfoilContentFits(geometry, withEm(snapshot), plainGlyphs)\n },\n createGeometry(snapshot, padding) {\n const layout = withEm(snapshot)\n geometryLayered = layered || layout.glyphs.some((glyph) => !!glyph.motionOrigin)\n if (geometryLayered && limit < 8) {\n throw new Error('DomSlug: layered Slug requires eight vertex buffers')\n }\n return createWindfoilGlyphGeometry(layout, plainGlyphs, padding, geometryLayered)\n },\n updateGeometry(geometry, snapshot, padding, checked = false) {\n return updateWindfoilGlyphGeometry(\n geometry,\n withEm(snapshot),\n plainGlyphs,\n padding,\n undefined,\n checked,\n )\n },\n async append(nextRequests, appendSignal) {\n if (disposed) return false\n const missingReqs = collectMissingRequests(\n nextRequests,\n (key) => glyphs.has(key) || skippedKeys.has(key),\n )\n if (missingReqs.length === 0) return true\n if (!extensions && missingReqs.some((req) => req.shape !== undefined)) {\n extensions = await abortable(import('../windfoil/requests.js'), appendSignal)\n }\n const deltaResolved = await resolveOutlineRequests(\n missingReqs,\n options,\n appendSignal,\n extensions,\n )\n throwIfAborted(appendSignal)\n const deltaMissing = deltaResolved.filter((item) => item.outline === null)\n if (deltaMissing.length > 0 && missingMode === 'error') {\n throw new Error(\n `DomSlug: outlineProvider returned null for ${JSON.stringify(deltaMissing[0]!.request.character)} in ${deltaMissing[0]!.request.font.family}`,\n )\n }\n const nonNull = deltaResolved.filter(\n (item): item is typeof item & { outline: NonNullable<typeof item.outline> } =>\n item.outline !== null,\n )\n if (nonNull.length === 0) {\n for (const item of deltaMissing) skippedKeys.add(item.request.key)\n return true\n }\n if (\n !layerModule &&\n nonNull.some(\n (item) => item.outline.layers !== undefined || item.outline.clipBox !== undefined,\n )\n ) {\n layerModule = await abortable(import('../windfoil/layerNormalization.js'), appendSignal)\n throwIfAborted(appendSignal)\n }\n let delta: ReturnType<typeof preprocessSlugGlyphsBatch>\n try {\n delta = preprocessSlugGlyphsBatch(\n nonNull,\n {\n signal: appendSignal,\n vec4Curves: !wantsComposite,\n ...(layerModule ? { normalizeLayers: layerModule.normalizeLayers } : {}),\n ...(options.targetPiecesPerBand === undefined\n ? {}\n : { targetPiecesPerBand: options.targetPiecesPerBand }),\n },\n usedCurves,\n usedRows,\n )\n } catch (error) {\n if (\n error instanceof RangeError &&\n (error.message.includes('17-bit') || error.message.includes('18-bit'))\n )\n return false\n throw error\n }\n if (delta.layered && !layered) return false\n for (const header of delta.glyphs.values()) {\n if (\n (header.layers?.some((layer) => layer.paintKind === 2) ?? false) ||\n (header.layers && !!header.clipBox)\n ) {\n return false\n }\n }\n if (\n usedCurves + delta.curves.length > retained.curveCapacityFloats ||\n usedRows + delta.rows.length > retained.rowCapacityUints\n ) {\n return false\n }\n throwIfAborted(appendSignal)\n retained.writeCurves(usedCurves, delta.curves)\n retained.writeRows(usedRows, delta.rows)\n usedCurves += delta.curves.length\n usedRows += delta.rows.length\n for (const item of deltaMissing) skippedKeys.add(item.request.key)\n for (const [key, header] of delta.glyphs) {\n glyphs.set(key, header)\n if (plainGlyphs !== glyphs) plainGlyphs.set(key, header)\n }\n stats = mergePreprocessStats(stats, delta.stats, glyphs.size)\n return true\n },\n setGlyphEm(value) {\n glyphEm = value\n },\n createMaterial(materialOptions) {\n return new SlugMaterial({\n curves: retained.curves,\n rows: retained.rows,\n layered: geometryLayered,\n ...(colorResources ? { paintFunctions: colorResources.paintFunctions } : {}),\n ...materialOptions,\n })\n },\n dispose() {\n if (disposed) return\n disposed = true\n retained.dispose()\n colorResources?.dispose()\n },\n }\n } catch (error) {\n coverage?.dispose()\n colorResources?.dispose()\n throw error\n }\n}\n"],"mappings":";;;;;;;;AAgFA,eAAsB,2BACpB,UACA,UACA,SACA,QACA,WAAW,OACqB;CAChC,MAAM,UAAU,SAAS,KAAK,GAAG,MAAM;CACvC,eAAe,MAAM;CACrB,IAAI,EAAE,SAAS,mBAAmB,gBAChC,MAAM,IAAI,MAAM,gDAAgD;CAElE,MAAM,QACH,SAAS,QAA6E,QACnF,OAAO,oBAAoB;CACjC,IAAI,QAAQ,GACV,MAAM,IAAI,MAAM,sDAAsD;CAIxE,IAAI,aADc,SAAS,MAAM,YAAY,QAAQ,UAAU,KAAA,CAC9C,IAAY,MAAM,UAAU,OAAO,4BAA4B,MAAM,IAAI;CAC1F,MAAM,WAAW,MAAM,uBAAuB,UAAU,SAAS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