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
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
/** Engine-agnostic 3D axis-aligned bounding box and bounding sphere. */
|
|
2
|
+
export interface VanillaBounds {
|
|
3
|
+
readonly min: readonly [x: number, y: number, z: number];
|
|
4
|
+
readonly max: readonly [x: number, y: number, z: number];
|
|
5
|
+
readonly center: readonly [x: number, y: number, z: number];
|
|
6
|
+
readonly radius: number;
|
|
7
|
+
}
|
|
8
|
+
/** Packed typed-array instance attributes for SDF glyphs. */
|
|
9
|
+
export interface VanillaGlyphInstances {
|
|
10
|
+
count: number;
|
|
11
|
+
maxSequence: number;
|
|
12
|
+
/** `[x0, y0, x1, y1]` per glyph in local capture units (`count * 4`). */
|
|
13
|
+
rects: Float32Array;
|
|
14
|
+
/** Normalized `unorm16` `[u0, v1, u1, v0]` per glyph (`count * 4`). */
|
|
15
|
+
uvRects: Uint16Array;
|
|
16
|
+
/** Normalized `unorm16` support trim `[u0, v1, u1, v0]` per glyph (`count * 4`), or `null` with `runMotion`. */
|
|
17
|
+
trims: Uint16Array | null;
|
|
18
|
+
/** `[x0, y0, x1, y1]` clip box per glyph (`count * 4`). */
|
|
19
|
+
clips: Float32Array;
|
|
20
|
+
/** Normalized `unorm8` `[r, g, b, a]` per glyph (`count * 4`). */
|
|
21
|
+
colors: Uint8Array;
|
|
22
|
+
/** `[sequence, z]` or `[sequence, z, switchEm]` per glyph (`count * metaItemSize`). */
|
|
23
|
+
metadata: Float32Array;
|
|
24
|
+
metaItemSize: 2 | 3;
|
|
25
|
+
/** `[centerX, centerY, ordinal]` per glyph (`count * 3`) when shaped runs or SVG groups are present. */
|
|
26
|
+
runMotion: Float32Array | null;
|
|
27
|
+
bounds: VanillaBounds;
|
|
28
|
+
}
|
|
29
|
+
/** Packed typed-array instance attributes for DOM background rectangles. */
|
|
30
|
+
export interface VanillaRectInstances {
|
|
31
|
+
count: number;
|
|
32
|
+
readonly receiveShadow: boolean;
|
|
33
|
+
/** `[x0, y0, x1, y1]` per rectangle (`count * 4`). */
|
|
34
|
+
rects: Float32Array;
|
|
35
|
+
/** Normalized `unorm8` `[r, g, b, a]` per rectangle (`count * 4`). */
|
|
36
|
+
colors: Uint8Array;
|
|
37
|
+
/** Corner radius per rectangle (`count`). */
|
|
38
|
+
radii: Float32Array;
|
|
39
|
+
/** Z depth per rectangle (`count`). */
|
|
40
|
+
depths: Float32Array;
|
|
41
|
+
bounds: VanillaBounds;
|
|
42
|
+
}
|
|
43
|
+
/** Packed typed-array instance attributes for CSS text decorations. */
|
|
44
|
+
export interface VanillaDecorationInstances {
|
|
45
|
+
count: number;
|
|
46
|
+
/** Source glyph `[x0, y0, x1, y1]` per decoration (`count * 4`). */
|
|
47
|
+
rects: Float32Array;
|
|
48
|
+
/** Decoration stroke `[x0, y0, x1, y1]` per decoration (`count * 4`). */
|
|
49
|
+
decorationRects: Float32Array;
|
|
50
|
+
/** Motion index per decoration (`count`). */
|
|
51
|
+
decorationIndices: Float32Array;
|
|
52
|
+
/** Normalized `unorm8` `[r, g, b, a]` per decoration (`count * 4`). */
|
|
53
|
+
colors: Uint8Array;
|
|
54
|
+
/** `[x0, y0, x1, y1]` clip box per decoration (`count * 4`). */
|
|
55
|
+
clips: Float32Array;
|
|
56
|
+
/** `[sequence, z]` per decoration (`count * 2`). */
|
|
57
|
+
metadata: Float32Array;
|
|
58
|
+
/** `[centerX, centerY, ordinal]` per decoration (`count * 3`) when shaped runs are present. */
|
|
59
|
+
runMotion: Float32Array | null;
|
|
60
|
+
bounds: VanillaBounds;
|
|
61
|
+
}
|
|
62
|
+
export declare function byte(value: number): number;
|
|
63
|
+
/** Computes a bounding box and sphere in local capture coordinates. */
|
|
64
|
+
export declare function computeInstanceBounds(width: number, height: number, padding?: number, minZ?: number, maxZ?: number): VanillaBounds;
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
// src/atlas/vanillaBounds.ts
|
|
2
|
+
function byte(value) {
|
|
3
|
+
if (value <= 0) return 0;
|
|
4
|
+
if (value >= 1) return 255;
|
|
5
|
+
return value * 255 + .5 | 0;
|
|
6
|
+
}
|
|
7
|
+
/** Computes a bounding box and sphere in local capture coordinates. */
|
|
8
|
+
function computeInstanceBounds(width, height, padding = 0, minZ = 0, maxZ = 0) {
|
|
9
|
+
const minX = -padding;
|
|
10
|
+
const minY = -padding;
|
|
11
|
+
const minBoundZ = minZ - padding;
|
|
12
|
+
const maxX = width + padding;
|
|
13
|
+
const maxY = height + padding;
|
|
14
|
+
const maxBoundZ = maxZ + padding;
|
|
15
|
+
const cx = (minX + maxX) * .5;
|
|
16
|
+
const cy = (minY + maxY) * .5;
|
|
17
|
+
const cz = (minBoundZ + maxBoundZ) * .5;
|
|
18
|
+
const dx = maxX - cx;
|
|
19
|
+
const dy = maxY - cy;
|
|
20
|
+
const dz = maxBoundZ - cz;
|
|
21
|
+
return {
|
|
22
|
+
min: [
|
|
23
|
+
minX,
|
|
24
|
+
minY,
|
|
25
|
+
minBoundZ
|
|
26
|
+
],
|
|
27
|
+
max: [
|
|
28
|
+
maxX,
|
|
29
|
+
maxY,
|
|
30
|
+
maxBoundZ
|
|
31
|
+
],
|
|
32
|
+
center: [
|
|
33
|
+
cx,
|
|
34
|
+
cy,
|
|
35
|
+
cz
|
|
36
|
+
],
|
|
37
|
+
radius: Math.sqrt(dx * dx + dy * dy + dz * dz)
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
export { byte, computeInstanceBounds };
|
|
41
|
+
|
|
42
|
+
//# sourceMappingURL=vanillaBounds.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"vanillaBounds.js","names":[],"sources":["../../src/atlas/vanillaBounds.ts"],"sourcesContent":["/** Engine-agnostic 3D axis-aligned bounding box and bounding sphere. */\nexport interface VanillaBounds {\n readonly min: readonly [x: number, y: number, z: number]\n readonly max: readonly [x: number, y: number, z: number]\n readonly center: readonly [x: number, y: number, z: number]\n readonly radius: number\n}\n\n/** Packed typed-array instance attributes for SDF glyphs. */\nexport interface VanillaGlyphInstances {\n count: number\n maxSequence: number\n /** `[x0, y0, x1, y1]` per glyph in local capture units (`count * 4`). */\n rects: Float32Array\n /** Normalized `unorm16` `[u0, v1, u1, v0]` per glyph (`count * 4`). */\n uvRects: Uint16Array\n /** Normalized `unorm16` support trim `[u0, v1, u1, v0]` per glyph (`count * 4`), or `null` with `runMotion`. */\n trims: Uint16Array | null\n /** `[x0, y0, x1, y1]` clip box per glyph (`count * 4`). */\n clips: Float32Array\n /** Normalized `unorm8` `[r, g, b, a]` per glyph (`count * 4`). */\n colors: Uint8Array\n /** `[sequence, z]` or `[sequence, z, switchEm]` per glyph (`count * metaItemSize`). */\n metadata: Float32Array\n metaItemSize: 2 | 3\n /** `[centerX, centerY, ordinal]` per glyph (`count * 3`) when shaped runs or SVG groups are present. */\n runMotion: Float32Array | null\n bounds: VanillaBounds\n}\n\n/** Packed typed-array instance attributes for DOM background rectangles. */\nexport interface VanillaRectInstances {\n count: number\n readonly receiveShadow: boolean\n /** `[x0, y0, x1, y1]` per rectangle (`count * 4`). */\n rects: Float32Array\n /** Normalized `unorm8` `[r, g, b, a]` per rectangle (`count * 4`). */\n colors: Uint8Array\n /** Corner radius per rectangle (`count`). */\n radii: Float32Array\n /** Z depth per rectangle (`count`). */\n depths: Float32Array\n bounds: VanillaBounds\n}\n\n/** Packed typed-array instance attributes for CSS text decorations. */\nexport interface VanillaDecorationInstances {\n count: number\n /** Source glyph `[x0, y0, x1, y1]` per decoration (`count * 4`). */\n rects: Float32Array\n /** Decoration stroke `[x0, y0, x1, y1]` per decoration (`count * 4`). */\n decorationRects: Float32Array\n /** Motion index per decoration (`count`). */\n decorationIndices: Float32Array\n /** Normalized `unorm8` `[r, g, b, a]` per decoration (`count * 4`). */\n colors: Uint8Array\n /** `[x0, y0, x1, y1]` clip box per decoration (`count * 4`). */\n clips: Float32Array\n /** `[sequence, z]` per decoration (`count * 2`). */\n metadata: Float32Array\n /** `[centerX, centerY, ordinal]` per decoration (`count * 3`) when shaped runs are present. */\n runMotion: Float32Array | null\n bounds: VanillaBounds\n}\n\nexport function byte(value: number): number {\n if (value <= 0) return 0\n if (value >= 1) return 255\n return (value * 255 + 0.5) | 0\n}\n\n/** Computes a bounding box and sphere in local capture coordinates. */\nexport function computeInstanceBounds(\n width: number,\n height: number,\n padding = 0,\n minZ = 0,\n maxZ = 0,\n): VanillaBounds {\n const minX = -padding\n const minY = -padding\n const minBoundZ = minZ - padding\n const maxX = width + padding\n const maxY = height + padding\n const maxBoundZ = maxZ + padding\n const cx = (minX + maxX) * 0.5\n const cy = (minY + maxY) * 0.5\n const cz = (minBoundZ + maxBoundZ) * 0.5\n const dx = maxX - cx\n const dy = maxY - cy\n const dz = maxBoundZ - cz\n return {\n min: [minX, minY, minBoundZ],\n max: [maxX, maxY, maxBoundZ],\n center: [cx, cy, cz],\n radius: Math.sqrt(dx * dx + dy * dy + dz * dz),\n }\n}\n"],"mappings":";AAiEA,SAAgB,KAAK,OAAuB;CAC1C,IAAI,SAAS,GAAG,OAAO;CACvB,IAAI,SAAS,GAAG,OAAO;CACvB,OAAQ,QAAQ,MAAM,KAAO;AAC/B;;AAGA,SAAgB,sBACd,OACA,QACA,UAAU,GACV,OAAO,GACP,OAAO,GACQ;CACf,MAAM,OAAO,CAAC;CACd,MAAM,OAAO,CAAC;CACd,MAAM,YAAY,OAAO;CACzB,MAAM,OAAO,QAAQ;CACrB,MAAM,OAAO,SAAS;CACtB,MAAM,YAAY,OAAO;CACzB,MAAM,MAAM,OAAO,QAAQ;CAC3B,MAAM,MAAM,OAAO,QAAQ;CAC3B,MAAM,MAAM,YAAY,aAAa;CACrC,MAAM,KAAK,OAAO;CAClB,MAAM,KAAK,OAAO;CAClB,MAAM,KAAK,YAAY;CACvB,OAAO;EACL,KAAK;GAAC;GAAM;GAAM;EAAS;EAC3B,KAAK;GAAC;GAAM;GAAM;EAAS;EAC3B,QAAQ;GAAC;GAAI;GAAI;EAAE;EACnB,QAAQ,KAAK,KAAK,KAAK,KAAK,KAAK,KAAK,KAAK,EAAE;CAC/C;AACF"}
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
import type { BuildSdfAtlasOptions, DomLayoutSnapshot, DomSdfOptions, DomSdfStats, RasterAtlas, SdfMotionOptions, TextClass, TextCss } from '../types.js';
|
|
2
|
+
import { type ResolvedTextTone } from '../dom/tone.js';
|
|
3
|
+
import type { PreparedCpuWorker } from './cpuWorker.js';
|
|
4
|
+
import { computeInstanceBounds, type VanillaBounds, type VanillaDecorationInstances, type VanillaGlyphInstances, type VanillaRectInstances } from './vanillaBounds.js';
|
|
5
|
+
import { type VanillaGpuDevice, type VanillaGpuDeviceSource, type VanillaGpuTexture, type VanillaSdfAtlas, type VanillaSdfColorLayer } from './vanillaGpuHelpers.js';
|
|
6
|
+
export { computeInstanceBounds, type VanillaBounds, type VanillaDecorationInstances, type VanillaGlyphInstances, type VanillaGpuDevice, type VanillaGpuDeviceSource, type VanillaGpuTexture, type VanillaRectInstances, type VanillaSdfAtlas, type VanillaSdfColorLayer, };
|
|
7
|
+
export declare function buildVanillaGpuSdfAtlas(device: VanillaGpuDevice, raster: RasterAtlas, options?: Omit<BuildSdfAtlasOptions, 'mode'>): Promise<VanillaSdfAtlas>;
|
|
8
|
+
/**
|
|
9
|
+
* Engine-agnostic SDF atlas builder. Accepts a `GPUDevice`, an object holding `{ device }`
|
|
10
|
+
* (such as a Mini3 `Renderer`), or `null`/`undefined` for CPU generation.
|
|
11
|
+
* In `'auto'` mode (default), tries the WebGPU JFA path when a device is provided and falls
|
|
12
|
+
* back to the exact CPU EDT encoder if the device is absent or rejects the passes.
|
|
13
|
+
*/
|
|
14
|
+
export declare function buildVanillaSdfAtlas(deviceOrRenderer: VanillaGpuDeviceSource, raster: RasterAtlas, options?: BuildSdfAtlasOptions,
|
|
15
|
+
/** @internal */
|
|
16
|
+
preparedWorker?: PreparedCpuWorker | null): Promise<VanillaSdfAtlas>;
|
|
17
|
+
export { buildVanillaSdfAtlas as buildSdfAtlas };
|
|
18
|
+
/** Unit quad vertex positions (`[0,0,0, 1,0,0, 1,1,0, 0,1,0]`, 4 vertices × 3 floats). */
|
|
19
|
+
export declare const UNIT_QUAD_POSITIONS: Float32Array<ArrayBuffer>;
|
|
20
|
+
/** Unit quad vertex normals (`[0,0,1, ...]`, 4 vertices × 3 floats). */
|
|
21
|
+
export declare const UNIT_QUAD_NORMALS: Float32Array<ArrayBuffer>;
|
|
22
|
+
/** Unit quad triangle indices (`[0, 1, 2, 0, 2, 3]`, 6 uint16 indices). */
|
|
23
|
+
export declare const UNIT_QUAD_INDICES: Uint16Array<ArrayBuffer>;
|
|
24
|
+
export type GlyphAtlasLookup = Pick<VanillaSdfAtlas, 'bakeSize' | 'glyphs'>;
|
|
25
|
+
/** Packs instanced glyph attribute arrays from a layout snapshot and SDF atlas. */
|
|
26
|
+
export declare function packGlyphInstances(snapshot: DomLayoutSnapshot, atlas: GlyphAtlasLookup, motionPadding?: number, motionOrdinals?: Float32Array): VanillaGlyphInstances;
|
|
27
|
+
/**
|
|
28
|
+
* Rewrites the glyph instance arrays that change on a reflow (`rects`, `clips`, `metadata`,
|
|
29
|
+
* `runMotion`, `bounds`) in place without reallocating. Returns `maxSequence`, or `null` when
|
|
30
|
+
* the glyph count no longer matches.
|
|
31
|
+
*/
|
|
32
|
+
export declare function updateGlyphInstances(instances: VanillaGlyphInstances, snapshot: DomLayoutSnapshot, atlas: GlyphAtlasLookup, motionPadding?: number, motionOrdinals?: Float32Array): number | null;
|
|
33
|
+
/**
|
|
34
|
+
* Rewrites all glyph instance arrays in place when the drawable count and layout match.
|
|
35
|
+
* Returns `maxSequence`, or `null` without mutating when the buffers do not fit.
|
|
36
|
+
*/
|
|
37
|
+
export declare function updateGlyphContentInstances(instances: VanillaGlyphInstances, snapshot: DomLayoutSnapshot, atlas: GlyphAtlasLookup, motionPadding?: number, motionOrdinals?: Float32Array): number | null;
|
|
38
|
+
export interface VanillaDomTextRebuildOptions {
|
|
39
|
+
signal?: AbortSignal;
|
|
40
|
+
}
|
|
41
|
+
export type VanillaChangeReason = 'create' | 'rebuild' | 'reflow' | 'motion' | 'dispose';
|
|
42
|
+
/** Options for `VanillaDomText` (`DomText` / `DomSdf` in `ultra-text/vanilla`). */
|
|
43
|
+
export interface VanillaDomTextOptions extends Omit<DomSdfOptions, 'fill' | 'vertex' | 'sharedAtlas' | 'side' | 'textBackend' | 'windfoil'> {
|
|
44
|
+
/** Optional shared `VanillaSdfAtlas` across multiple `VanillaDomText` instances. */
|
|
45
|
+
sharedAtlas?: VanillaSdfAtlas;
|
|
46
|
+
/** Called after initial creation, rebuild, reflow, motion update, or disposal. */
|
|
47
|
+
onChange?: (instance: VanillaDomText, reason: VanillaChangeReason) => void;
|
|
48
|
+
}
|
|
49
|
+
export declare class VanillaDomText {
|
|
50
|
+
#private;
|
|
51
|
+
readonly element: HTMLElement;
|
|
52
|
+
readonly device: VanillaGpuDevice | null;
|
|
53
|
+
readonly options: Readonly<VanillaDomTextOptions>;
|
|
54
|
+
glyphs: VanillaGlyphInstances;
|
|
55
|
+
plainRects: VanillaRectInstances | null;
|
|
56
|
+
litRects: VanillaRectInstances | null;
|
|
57
|
+
decorations: VanillaDecorationInstances | null;
|
|
58
|
+
tone: ResolvedTextTone | null;
|
|
59
|
+
motion: Required<SdfMotionOptions>;
|
|
60
|
+
protected constructor(element: HTMLElement, deviceOrRenderer: VanillaGpuDeviceSource, options: VanillaDomTextOptions);
|
|
61
|
+
static create(element: HTMLElement, deviceOrRenderer?: VanillaGpuDeviceSource, options?: VanillaDomTextOptions): Promise<VanillaDomText>;
|
|
62
|
+
get atlas(): VanillaSdfAtlas;
|
|
63
|
+
get stats(): Readonly<DomSdfStats>;
|
|
64
|
+
get snapshot(): DomLayoutSnapshot | null;
|
|
65
|
+
get width(): number;
|
|
66
|
+
get height(): number;
|
|
67
|
+
get isDisposed(): boolean;
|
|
68
|
+
subscribe(listener: (instance: VanillaDomText, reason: VanillaChangeReason) => void): () => void;
|
|
69
|
+
reflow(width: number): this;
|
|
70
|
+
setMotion(motion: SdfMotionOptions): this;
|
|
71
|
+
rebuild(rebuildOptions?: VanillaDomTextRebuildOptions): Promise<this>;
|
|
72
|
+
dispose(): void;
|
|
73
|
+
protected resolveCaptureTone(snapshot: DomLayoutSnapshot): ResolvedTextTone | null;
|
|
74
|
+
protected notify(reason: VanillaChangeReason): void;
|
|
75
|
+
protected applySelectableAttribute(): void;
|
|
76
|
+
protected setupObservers(): void;
|
|
77
|
+
}
|
|
78
|
+
export { VanillaDomText as DomSdf, VanillaDomText as DomText };
|
|
79
|
+
export interface VanillaTextOptions extends VanillaDomTextOptions {
|
|
80
|
+
device?: VanillaGpuDeviceSource;
|
|
81
|
+
renderer?: VanillaGpuDeviceSource;
|
|
82
|
+
css?: TextCss;
|
|
83
|
+
cssClass?: TextClass;
|
|
84
|
+
parent?: HTMLElement;
|
|
85
|
+
}
|
|
86
|
+
export declare class VanillaText extends VanillaDomText {
|
|
87
|
+
#private;
|
|
88
|
+
readonly ready: Promise<this>;
|
|
89
|
+
constructor(text: string, options?: VanillaTextOptions);
|
|
90
|
+
static create(text: string, options?: VanillaTextOptions): Promise<VanillaText>;
|
|
91
|
+
static create(element: HTMLElement, deviceOrRenderer?: VanillaGpuDeviceSource, options?: VanillaDomTextOptions): Promise<VanillaDomText>;
|
|
92
|
+
get text(): string;
|
|
93
|
+
set text(value: string);
|
|
94
|
+
setText(value: string, options?: VanillaDomTextRebuildOptions): Promise<this>;
|
|
95
|
+
setCss(css: TextCss | undefined, options?: VanillaDomTextRebuildOptions): Promise<this>;
|
|
96
|
+
setClass(cssClass: TextClass | undefined, options?: VanillaDomTextRebuildOptions): Promise<this>;
|
|
97
|
+
dispose(): void;
|
|
98
|
+
protected resolveCaptureTone(snapshot: DomLayoutSnapshot): ResolvedTextTone | null;
|
|
99
|
+
}
|
|
100
|
+
export { VanillaText as Text };
|