@vectojs/core 0.1.0 → 0.2.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (46) hide show
  1. package/dist/animation/drivers.d.ts +48 -0
  2. package/dist/animation/easing.d.ts +16 -0
  3. package/dist/{chunk-M2IZPGOL.mjs → chunk-H3QIE77O.mjs} +316 -12
  4. package/dist/{chunk-53DAQC3U.js → chunk-LA3FJLP2.js} +369 -65
  5. package/dist/components/GridTextEntity.d.ts +15 -0
  6. package/dist/components/SplineEntity.d.ts +144 -0
  7. package/dist/components/TextEntity.d.ts +35 -0
  8. package/dist/index.d.ts +26 -577
  9. package/dist/index.js +121 -136
  10. package/dist/index.mjs +19 -34
  11. package/dist/{layout.d.mts → layout/LayoutEngine.d.ts} +15 -70
  12. package/dist/layout/LayoutWorker.d.ts +23 -0
  13. package/dist/layout/LayoutWorkerManager.d.ts +22 -0
  14. package/dist/layout/LayoutWorkerSource.d.ts +1 -0
  15. package/dist/layout/index.d.ts +3 -0
  16. package/dist/layout/measure.d.ts +20 -0
  17. package/dist/math/SpatialHashGrid.d.ts +53 -0
  18. package/dist/math/SpringPhysics.d.ts +13 -0
  19. package/dist/renderer/CanvasRenderer.d.ts +81 -0
  20. package/dist/renderer/IRenderer.d.ts +178 -0
  21. package/dist/renderer/SVGRenderer.d.ts +69 -0
  22. package/dist/renderer/WebGLPointRenderer.d.ts +62 -0
  23. package/dist/renderer/WebGPUParticleSystemManager.d.ts +14 -0
  24. package/dist/renderer/colorParse.d.ts +17 -0
  25. package/dist/renderer/index.d.ts +6 -0
  26. package/dist/text/ArabicShaper.d.ts +10 -0
  27. package/dist/text/BidiResolver.d.ts +6 -0
  28. package/dist/{text.d.ts → text/MSDFFont.d.ts} +10 -82
  29. package/dist/text/MSDFTextEntity.d.ts +30 -0
  30. package/dist/text/SVGEntity.d.ts +22 -0
  31. package/dist/text/index.d.ts +5 -0
  32. package/dist/text.js +2 -2
  33. package/dist/text.mjs +1 -1
  34. package/dist/tree/ComputeParticleEntity.d.ts +118 -0
  35. package/dist/tree/DOMPortalEntity.d.ts +18 -0
  36. package/dist/{Entity-D-rfAFCf.d.mts → tree/Entity.d.ts} +71 -201
  37. package/dist/tree/Scene.d.ts +302 -0
  38. package/package.json +5 -5
  39. package/dist/Entity-D-rfAFCf.d.ts +0 -572
  40. package/dist/index-ByBDSmMK.d.mts +0 -365
  41. package/dist/index-C3Fd_XmG.d.ts +0 -365
  42. package/dist/index.d.mts +0 -577
  43. package/dist/layout.d.ts +0 -319
  44. package/dist/renderer.d.mts +0 -2
  45. package/dist/renderer.d.ts +0 -2
  46. package/dist/text.d.mts +0 -201
@@ -0,0 +1,178 @@
1
+ /**
2
+ * Renderer abstraction consumed by every {@link Entity}.
3
+ *
4
+ * Implementations wrap a concrete drawing backend (Canvas 2D, WebGL, …) and
5
+ * expose a path-based drawing API. Entities must only depend on `IRenderer`
6
+ * so they remain backend-agnostic.
7
+ *
8
+ * @example
9
+ * // Inside an Entity.render() implementation:
10
+ * render(r: IRenderer) {
11
+ * r.beginPath();
12
+ * r.fill('#38bdf8');
13
+ * }
14
+ */
15
+ export interface IRenderer {
16
+ /** Clear the entire drawing surface to transparent / background color. */
17
+ clear(): void;
18
+ /** Push the current transform + state onto the renderer's stack. */
19
+ save(): void;
20
+ /** Pop the last saved transform + state from the renderer's stack. */
21
+ restore(): void;
22
+ /**
23
+ * Apply a translation to the current transform matrix.
24
+ *
25
+ * @param x - Horizontal offset in pixels.
26
+ * @param y - Vertical offset in pixels.
27
+ */
28
+ translate(x: number, y: number): void;
29
+ /**
30
+ * Apply a scale to the current transform matrix.
31
+ *
32
+ * @param x - Horizontal scale factor.
33
+ * @param y - Vertical scale factor.
34
+ */
35
+ scale(x: number, y: number): void;
36
+ /**
37
+ * Apply a clockwise rotation to the current transform matrix.
38
+ *
39
+ * @param angle - Rotation angle in radians.
40
+ */
41
+ rotate(angle: number): void;
42
+ /**
43
+ * Set the global opacity applied to all subsequent draw calls.
44
+ *
45
+ * @param alpha - Opacity in the range `[0, 1]`.
46
+ */
47
+ setGlobalAlpha(alpha: number): void;
48
+ /**
49
+ * Intersect the current clip region with a rectangle. Affects all subsequent
50
+ * draws until the next {@link restore}; wrap in {@link save}/{@link restore}.
51
+ *
52
+ * @param x - Left edge.
53
+ * @param y - Top edge.
54
+ * @param width - Rectangle width.
55
+ * @param height - Rectangle height.
56
+ */
57
+ clip(x: number, y: number, width: number, height: number): void;
58
+ /** Begin a new sub-path, discarding the current path. */
59
+ beginPath(): void;
60
+ /**
61
+ * Move the pen to the given point without drawing a line.
62
+ *
63
+ * @param x - Target X coordinate.
64
+ * @param y - Target Y coordinate.
65
+ */
66
+ moveTo(x: number, y: number): void;
67
+ /**
68
+ * Add a straight line segment from the current pen position to the given point.
69
+ *
70
+ * @param x - Target X coordinate.
71
+ * @param y - Target Y coordinate.
72
+ */
73
+ lineTo(x: number, y: number): void;
74
+ /**
75
+ * Add a cubic Bézier curve to the current path.
76
+ *
77
+ * @param cp1x - X of the first control point.
78
+ * @param cp1y - Y of the first control point.
79
+ * @param cp2x - X of the second control point.
80
+ * @param cp2y - Y of the second control point.
81
+ * @param x - X of the end point.
82
+ * @param y - Y of the end point.
83
+ */
84
+ bezierCurveTo(cp1x: number, cp1y: number, cp2x: number, cp2y: number, x: number, y: number): void;
85
+ /** Close the current sub-path by drawing a line back to its starting point. */
86
+ closePath(): void;
87
+ /**
88
+ * Add a circular arc to the current path.
89
+ *
90
+ * @param x - X of the arc center.
91
+ * @param y - Y of the arc center.
92
+ * @param radius - Arc radius in pixels.
93
+ * @param startAngle - Start angle in radians (0 = 3 o'clock).
94
+ * @param endAngle - End angle in radians.
95
+ * @param counterclockwise - If `true`, draws the arc counter-clockwise.
96
+ */
97
+ arc(x: number, y: number, radius: number, startAngle: number, endAngle: number, counterclockwise?: boolean): void;
98
+ /**
99
+ * Add a rounded rectangle to the current path.
100
+ *
101
+ * @param x - Left edge.
102
+ * @param y - Top edge.
103
+ * @param width - Rectangle width.
104
+ * @param height - Rectangle height.
105
+ * @param radii - Corner radius (uniform) or per-corner array as accepted by `CanvasRenderingContext2D.roundRect()`.
106
+ */
107
+ roundRect(x: number, y: number, width: number, height: number, radii: number | number[]): void;
108
+ /**
109
+ * Draw an image or video frame into the canvas.
110
+ *
111
+ * @param source - The image source (HTMLImageElement, HTMLVideoElement, HTMLCanvasElement, etc.).
112
+ * @param dx - Destination X.
113
+ * @param dy - Destination Y.
114
+ * @param dw - Destination width.
115
+ * @param dh - Destination height.
116
+ */
117
+ drawImage(source: CanvasImageSource, dx: number, dy: number, dw: number, dh: number): void;
118
+ /**
119
+ * Fill the current path with the given color or gradient.
120
+ *
121
+ * @param colorOrGradient - CSS color string or a gradient object.
122
+ */
123
+ fill(colorOrGradient: string | any): void;
124
+ /**
125
+ * Stroke the current path with the given color or gradient.
126
+ *
127
+ * @param colorOrGradient - CSS color string or a gradient object.
128
+ * @param lineWidth - Stroke width in pixels (default: `1`).
129
+ */
130
+ stroke(colorOrGradient: string | any, lineWidth?: number): void;
131
+ /**
132
+ * Render a text string at the given position.
133
+ *
134
+ * @param text - The string to draw.
135
+ * @param x - Left edge of the text baseline.
136
+ * @param y - Baseline Y coordinate.
137
+ * @param font - CSS font shorthand, e.g. `'16px monospace'`.
138
+ * @param color - CSS color string or gradient.
139
+ */
140
+ fillText(text: string, x: number, y: number, font: string, color: string | any): void;
141
+ /**
142
+ * Draw a filled circle through the order-preserving batch.
143
+ *
144
+ * Consecutive calls sharing the same `color` and `alpha` are coalesced into a
145
+ * single path and committed with one `fill()` on {@link flush} (or when the
146
+ * style changes / another draw call intervenes). Coordinates are in the
147
+ * current transform space. This collapses the per-entity
148
+ * `beginPath`/`arc`/`fill` of large point clouds into a handful of draw calls
149
+ * while preserving painter's-order semantics.
150
+ *
151
+ * @param cx - Center X in the current transform space.
152
+ * @param cy - Center Y in the current transform space.
153
+ * @param radius - Circle radius.
154
+ * @param color - CSS color string.
155
+ * @param alpha - Opacity in `[0, 1]` (default `1`).
156
+ */
157
+ fillCircle(cx: number, cy: number, radius: number, color: string, alpha?: number): void;
158
+ /**
159
+ * Commit any pending batched draws (see {@link fillCircle}). Safe to call when
160
+ * no batch is active (no-op). The {@link Scene} flushes at the end of each
161
+ * sibling group and frame.
162
+ */
163
+ flush(): void;
164
+ /**
165
+ * Create a linear gradient between two points with the given color stops.
166
+ *
167
+ * @param x0 - X of the gradient start point.
168
+ * @param y0 - Y of the gradient start point.
169
+ * @param x1 - X of the gradient end point.
170
+ * @param y1 - Y of the gradient end point.
171
+ * @param colorStops - Array of `{ stop, color }` pairs where `stop` is in `[0, 1]`.
172
+ * @returns An opaque gradient object suitable for {@link fill} or {@link stroke}.
173
+ */
174
+ createLinearGradient(x0: number, y0: number, x1: number, y1: number, colorStops: {
175
+ stop: number;
176
+ color: string;
177
+ }[]): any;
178
+ }
@@ -0,0 +1,69 @@
1
+ import { IRenderer } from './IRenderer';
2
+ export interface SVGLinearGradient {
3
+ type: 'linear';
4
+ id?: string;
5
+ x0: number;
6
+ y0: number;
7
+ x1: number;
8
+ y1: number;
9
+ colorStops: {
10
+ stop: number;
11
+ color: string;
12
+ }[];
13
+ createMatrix: number[];
14
+ }
15
+ export declare class SVGRenderer implements IRenderer {
16
+ private width;
17
+ private height;
18
+ private buffer;
19
+ private defsBuffer;
20
+ private currentPath;
21
+ private mStack;
22
+ private ma;
23
+ private mb;
24
+ private mc;
25
+ private md;
26
+ private me;
27
+ private mf;
28
+ private alphaStack;
29
+ private globalAlpha;
30
+ private clipDepthStack;
31
+ private clipDepth;
32
+ private clipCounter;
33
+ private batchCircles;
34
+ private batchMatrix;
35
+ private batchColor;
36
+ private batchAlpha;
37
+ private batchActive;
38
+ private gradientCounter;
39
+ private gradientCache;
40
+ constructor(width: number, height: number);
41
+ clear(): void;
42
+ save(): void;
43
+ restore(): void;
44
+ translate(dx: number, dy: number): void;
45
+ scale(sx: number, sy: number): void;
46
+ rotate(angle: number): void;
47
+ setGlobalAlpha(alpha: number): void;
48
+ beginPath(): void;
49
+ moveTo(x: number, y: number): void;
50
+ lineTo(x: number, y: number): void;
51
+ bezierCurveTo(cp1x: number, cp1y: number, cp2x: number, cp2y: number, x: number, y: number): void;
52
+ closePath(): void;
53
+ arc(x: number, y: number, r: number, startAngle: number, endAngle: number, ccw?: boolean): void;
54
+ roundRect(x: number, y: number, w: number, h: number, radii: number | number[]): void;
55
+ fill(colorOrGradient: string | SVGLinearGradient): void;
56
+ stroke(colorOrGradient: string | SVGLinearGradient, lineWidth?: number): void;
57
+ fillText(text: string, x: number, y: number, font: string, color: string | SVGLinearGradient): void;
58
+ fillCircle(cx: number, cy: number, radius: number, color: string, alpha?: number): void;
59
+ drawImage(source: any, dx: number, dy: number, dw: number, dh: number): void;
60
+ flush(): void;
61
+ createLinearGradient(x0: number, y0: number, x1: number, y1: number, colorStops: {
62
+ stop: number;
63
+ color: string;
64
+ }[]): SVGLinearGradient;
65
+ clip(x: number, y: number, width: number, height: number): void;
66
+ toXMLString(): string;
67
+ private resolveGradient;
68
+ private escapeXML;
69
+ }
@@ -0,0 +1,62 @@
1
+ /**
2
+ * A GPU-accelerated layer that draws large sets of circles and rectangles in a
3
+ * couple of draw calls. Used by {@link Scene} (via `pointBackend: 'webgl'`) to
4
+ * render `getBatchCircle()` / `getBatchRect()` entities — the point-cloud /
5
+ * particle case where Canvas2D tops out at ~7 fps for 100k primitives.
6
+ */
7
+ export interface PointRenderer {
8
+ /** Resize the backing buffer + GL viewport to a logical `w × h` (DPR applied). */
9
+ resize(width: number, height: number): void;
10
+ /** Begin a frame: reset the accumulated primitive buffers. */
11
+ begin(): void;
12
+ /** Add one circle in world (CSS-pixel) coordinates; `alpha` multiplies the color's. */
13
+ addCircle(x: number, y: number, radius: number, color: string, alpha?: number): void;
14
+ /**
15
+ * Add one rectangle: top-left at world `(x, y)`, `width × height` in world units,
16
+ * rotated `rotation` radians about `(x, y)`; `alpha` multiplies the color's.
17
+ */
18
+ addRect(x: number, y: number, width: number, height: number, color: string, alpha?: number, rotation?: number): void;
19
+ /**
20
+ * Upload a texture atlas used by {@link addSprite}. Pass any `TexImageSource`
21
+ * (HTMLImageElement, HTMLCanvasElement, ImageBitmap, …). Call once (or whenever
22
+ * the atlas changes) before adding sprites.
23
+ */
24
+ setTexture(source: TexImageSource): void;
25
+ /**
26
+ * Add one textured sprite sampling the atlas region `[u0,v0]–[u1,v1]` (UVs in
27
+ * `0..1`): top-left at world `(x, y)`, `width × height` in world units, rotated
28
+ * `rotation` radians about `(x, y)`. `color` multiplies the sampled texel
29
+ * (white = unchanged; use it to tint white glyphs); `alpha` multiplies further.
30
+ * No-op until a texture is set via {@link setTexture}.
31
+ */
32
+ addSprite(x: number, y: number, width: number, height: number, u0: number, v0: number, u1: number, v1: number, color?: string, alpha?: number, rotation?: number): void;
33
+ /**
34
+ * Upload an MSDF (multi-channel signed distance field) glyph atlas used by
35
+ * {@link addGlyph}, kept separate from the {@link setTexture} atlas so both can
36
+ * be active. `distanceRange` is the field's pixel range (the atlas JSON's
37
+ * `atlas.distanceRange`) — it drives the shader's edge sharpness. Pair with
38
+ * `MSDFFont.layout` to position the glyphs.
39
+ */
40
+ setMSDFTexture(source: TexImageSource, distanceRange: number): void;
41
+ /**
42
+ * Add one MSDF glyph quad sampling `[u0,v0]–[u1,v1]` (UVs in `0..1`): top-left
43
+ * at world `(x, y)`, `width × height` in world units. The fragment shader
44
+ * reconstructs a crisp, resolution-independent edge from the distance field, so
45
+ * glyphs stay sharp at any scale. `color` tints the glyph (default white);
46
+ * `alpha` multiplies coverage. No-op until {@link setMSDFTexture} is called.
47
+ */
48
+ addGlyph(x: number, y: number, width: number, height: number, u0: number, v0: number, u1: number, v1: number, color?: string, alpha?: number, rotation?: number): void;
49
+ /** Clear the layer and draw all accumulated primitives. */
50
+ flush(): void;
51
+ /** Release GL resources. */
52
+ destroy(): void;
53
+ }
54
+ /**
55
+ * Create a WebGL2-backed {@link PointRenderer} on `canvas`, or `null` when WebGL2
56
+ * (or shader compilation) is unavailable — callers fall back to Canvas2D.
57
+ *
58
+ * @param canvas - A dedicated canvas (WebGL2 context); should be stacked over the
59
+ * scene's 2D canvas.
60
+ * @returns A point renderer, or `null` if WebGL2 isn't supported.
61
+ */
62
+ export declare function createWebGLPointRenderer(canvas: HTMLCanvasElement): PointRenderer | null;
@@ -0,0 +1,14 @@
1
+ import { ComputeParticleEntity } from '../tree/ComputeParticleEntity';
2
+ export declare class WebGPUParticleSystemManager {
3
+ private device;
4
+ private computePipeline;
5
+ private renderPipeline;
6
+ private computeBindGroupLayout;
7
+ private renderBindGroupLayout;
8
+ constructor(device: GPUDevice);
9
+ initPipelines(format: GPUTextureFormat): void;
10
+ setupEntityResources(entity: ComputeParticleEntity): void;
11
+ recordComputePass(pass: GPUComputePassEncoder, entity: ComputeParticleEntity, dt: number, mouseX: number, mouseY: number, width: number, height: number): void;
12
+ recordRenderPass(pass: GPURenderPassEncoder, entity: ComputeParticleEntity): void;
13
+ destroy(): void;
14
+ }
@@ -0,0 +1,17 @@
1
+ /**
2
+ * Parsed color as normalized `[r, g, b, a]` floats in `[0, 1]`.
3
+ */
4
+ export type RGBA = [number, number, number, number];
5
+ /**
6
+ * Parse a CSS color string into normalized `[r, g, b, a]` floats.
7
+ *
8
+ * Fast paths handle `#rgb`/`#rgba`/`#rrggbb`/`#rrggbbaa` and `rgb()`/`rgba()`;
9
+ * other forms (named colors, `hsl()`, …) resolve via a cached 1×1 canvas when a
10
+ * DOM is available. Results are cached per input string and shared by identity,
11
+ * so callers must treat the returned array as read-only. Unparseable input with
12
+ * no DOM yields opaque black `[0, 0, 0, 1]`.
13
+ *
14
+ * @param css - A CSS color string, e.g. `'#38bdf8'` or `'rgba(0,0,0,.5)'`.
15
+ * @returns The cached `[r, g, b, a]` tuple in `[0, 1]`.
16
+ */
17
+ export declare function parseColorToRGBA(css: string): RGBA;
@@ -0,0 +1,6 @@
1
+ export * from './CanvasRenderer';
2
+ export * from './SVGRenderer';
3
+ export * from './WebGLPointRenderer';
4
+ export * from './WebGPUParticleSystemManager';
5
+ export * from './IRenderer';
6
+ export * from './colorParse';
@@ -0,0 +1,10 @@
1
+ export interface ShapedResult {
2
+ shapedText: string;
3
+ indexMap: Int32Array;
4
+ }
5
+ export declare class ArabicShaper {
6
+ private static MAPPINGS;
7
+ private static isHarakat;
8
+ private static getJoiningType;
9
+ static shapeArabic(text: string): ShapedResult;
10
+ }
@@ -0,0 +1,6 @@
1
+ export declare class BidiResolver {
2
+ private static getDirectionClass;
3
+ static getBaseLevel(text: string): number;
4
+ static resolveLevels(text: string): Uint8Array;
5
+ static reorderVisual(nodes: any[], baseLevel: number): void;
6
+ }
@@ -1,5 +1,3 @@
1
- import { E as Entity, I as IRenderer } from './Entity-D-rfAFCf.js';
2
-
3
1
  /**
4
2
  * MSDF (Multi-channel Signed Distance Field) font support.
5
3
  *
@@ -14,7 +12,7 @@ import { E as Entity, I as IRenderer } from './Entity-D-rfAFCf.js';
14
12
  * Y-flip, the same as `setTexture`/`addSprite`).
15
13
  */
16
14
  /** Atlas section of an `msdf-atlas-gen` JSON file. */
17
- interface MSDFAtlasInfo {
15
+ export interface MSDFAtlasInfo {
18
16
  /** Field type, e.g. `'msdf'` | `'mtsdf'` | `'sdf'`. */
19
17
  type: string;
20
18
  /** Distance field range in atlas pixels — drives the shader's edge sharpness. */
@@ -29,7 +27,7 @@ interface MSDFAtlasInfo {
29
27
  yOrigin: 'bottom' | 'top';
30
28
  }
31
29
  /** Font-wide metrics in em units. */
32
- interface MSDFMetrics {
30
+ export interface MSDFMetrics {
33
31
  emSize: number;
34
32
  /** Line advance in em (multiply by font size for px). */
35
33
  lineHeight: number;
@@ -41,14 +39,14 @@ interface MSDFMetrics {
41
39
  underlineThickness?: number;
42
40
  }
43
41
  /** Em-unit / atlas-pixel rectangle as emitted by `msdf-atlas-gen`. */
44
- interface MSDFBounds {
42
+ export interface MSDFBounds {
45
43
  left: number;
46
44
  bottom: number;
47
45
  right: number;
48
46
  top: number;
49
47
  }
50
48
  /** One glyph's metrics. Whitespace has `advance` but no plane/atlas bounds. */
51
- interface MSDFGlyphDef {
49
+ export interface MSDFGlyphDef {
52
50
  unicode: number;
53
51
  /** Horizontal advance in em units. */
54
52
  advance: number;
@@ -58,20 +56,20 @@ interface MSDFGlyphDef {
58
56
  atlasBounds?: MSDFBounds;
59
57
  }
60
58
  /** Kerning pair adjustment in em units. */
61
- interface MSDFKerning {
59
+ export interface MSDFKerning {
62
60
  unicode1: number;
63
61
  unicode2: number;
64
62
  advance: number;
65
63
  }
66
64
  /** A parsed `msdf-atlas-gen` JSON document. */
67
- interface MSDFFontData {
65
+ export interface MSDFFontData {
68
66
  atlas: MSDFAtlasInfo;
69
67
  metrics: MSDFMetrics;
70
68
  glyphs: MSDFGlyphDef[];
71
69
  kerning?: MSDFKerning[];
72
70
  }
73
71
  /** A glyph positioned for rendering: a CSS-pixel quad + atlas UVs (0..1). */
74
- interface PositionedGlyph {
72
+ export interface PositionedGlyph {
75
73
  /** Source character (may be a surrogate-pair astral codepoint). */
76
74
  char: string;
77
75
  /** Quad top-left in local CSS pixels (y-down). */
@@ -87,7 +85,7 @@ interface PositionedGlyph {
87
85
  v1: number;
88
86
  }
89
87
  /** Result of {@link MSDFFont.layout}. */
90
- interface MSDFLayoutResult {
88
+ export interface MSDFLayoutResult {
91
89
  glyphs: PositionedGlyph[];
92
90
  /** Total pen advance of the widest line in CSS pixels. */
93
91
  width: number;
@@ -95,7 +93,7 @@ interface MSDFLayoutResult {
95
93
  height: number;
96
94
  }
97
95
  /** Options for {@link MSDFFont.layout}. */
98
- interface MSDFLayoutOptions {
96
+ export interface MSDFLayoutOptions {
99
97
  /** Pen origin x (left of the first glyph), CSS pixels. Default 0. */
100
98
  x?: number;
101
99
  /** Text-block top y (baseline of line 0 = `y + ascender×size`). Default 0. */
@@ -107,7 +105,7 @@ interface MSDFLayoutOptions {
107
105
  * A loaded MSDF font. Construct from parsed {@link MSDFFontData}, or use
108
106
  * {@link MSDFFont.parse} to read the JSON string straight from `msdf-atlas-gen`.
109
107
  */
110
- declare class MSDFFont {
108
+ export declare class MSDFFont {
111
109
  private static idCounter;
112
110
  readonly id: string;
113
111
  readonly data: MSDFFontData;
@@ -129,73 +127,3 @@ declare class MSDFFont {
129
127
  */
130
128
  layout(text: string, fontSizePx: number, opts?: MSDFLayoutOptions): MSDFLayoutResult;
131
129
  }
132
-
133
- interface MSDFTextEntityOptions {
134
- font: MSDFFont;
135
- texture: TexImageSource;
136
- fallbackFont?: string;
137
- fontSize?: number;
138
- color?: string;
139
- lineHeight?: number;
140
- letterSpacing?: number;
141
- }
142
- declare class MSDFTextEntity extends Entity {
143
- private font;
144
- private texture;
145
- private fallbackFont;
146
- private fontSize;
147
- color: string;
148
- private letterSpacing;
149
- private lineHeight?;
150
- private text;
151
- private lastRenderedSeqId;
152
- private rgbColorCache;
153
- private fontStringCache;
154
- private layoutResult;
155
- constructor(text: string, options: MSDFTextEntityOptions);
156
- setText(text: string): void;
157
- isPointInside(globalX: number, globalY: number): boolean;
158
- render(renderer: any): void;
159
- destroy(): void;
160
- }
161
-
162
- declare class SVGEntity extends Entity {
163
- private svgSource;
164
- private imageBitmap;
165
- private imageElement;
166
- private blobURL;
167
- private currentImg;
168
- private lodTimeout;
169
- private cachedDoc;
170
- private baseWidth;
171
- private baseHeight;
172
- private lastRasterizedScale;
173
- private targetScale;
174
- constructor(svgSource: string, id?: string);
175
- setSVGSource(svgSource: string): void;
176
- private parseSVGDimensions;
177
- private triggerRasterization;
178
- isPointInside(globalX: number, globalY: number): boolean;
179
- render(r: IRenderer): void;
180
- destroy(): void;
181
- }
182
-
183
- interface ShapedResult {
184
- shapedText: string;
185
- indexMap: Int32Array;
186
- }
187
- declare class ArabicShaper {
188
- private static MAPPINGS;
189
- private static isHarakat;
190
- private static getJoiningType;
191
- static shapeArabic(text: string): ShapedResult;
192
- }
193
-
194
- declare class BidiResolver {
195
- private static getDirectionClass;
196
- static getBaseLevel(text: string): number;
197
- static resolveLevels(text: string): Uint8Array;
198
- static reorderVisual(nodes: any[], baseLevel: number): void;
199
- }
200
-
201
- export { ArabicShaper, BidiResolver, type MSDFAtlasInfo, type MSDFBounds, MSDFFont, type MSDFFontData, type MSDFGlyphDef, type MSDFKerning, type MSDFLayoutOptions, type MSDFLayoutResult, type MSDFMetrics, MSDFTextEntity, type MSDFTextEntityOptions, type PositionedGlyph, SVGEntity, type ShapedResult };
@@ -0,0 +1,30 @@
1
+ import { Entity } from '../tree/Entity';
2
+ import { MSDFFont } from './MSDFFont';
3
+ export interface MSDFTextEntityOptions {
4
+ font: MSDFFont;
5
+ texture: TexImageSource;
6
+ fallbackFont?: string;
7
+ fontSize?: number;
8
+ color?: string;
9
+ lineHeight?: number;
10
+ letterSpacing?: number;
11
+ }
12
+ export declare class MSDFTextEntity extends Entity {
13
+ private font;
14
+ private texture;
15
+ private fallbackFont;
16
+ private fontSize;
17
+ color: string;
18
+ private letterSpacing;
19
+ private lineHeight?;
20
+ private text;
21
+ private lastRenderedSeqId;
22
+ private rgbColorCache;
23
+ private fontStringCache;
24
+ private layoutResult;
25
+ constructor(text: string, options: MSDFTextEntityOptions);
26
+ setText(text: string): void;
27
+ isPointInside(globalX: number, globalY: number): boolean;
28
+ render(renderer: any): void;
29
+ destroy(): void;
30
+ }
@@ -0,0 +1,22 @@
1
+ import { Entity } from '../tree/Entity';
2
+ import { IRenderer } from '../renderer/IRenderer';
3
+ export declare class SVGEntity extends Entity {
4
+ private svgSource;
5
+ private imageBitmap;
6
+ private imageElement;
7
+ private blobURL;
8
+ private currentImg;
9
+ private lodTimeout;
10
+ private cachedDoc;
11
+ private baseWidth;
12
+ private baseHeight;
13
+ private lastRasterizedScale;
14
+ private targetScale;
15
+ constructor(svgSource: string, id?: string);
16
+ setSVGSource(svgSource: string): void;
17
+ private parseSVGDimensions;
18
+ private triggerRasterization;
19
+ isPointInside(globalX: number, globalY: number): boolean;
20
+ render(r: IRenderer): void;
21
+ destroy(): void;
22
+ }
@@ -0,0 +1,5 @@
1
+ export * from './ArabicShaper';
2
+ export * from './BidiResolver';
3
+ export * from './MSDFFont';
4
+ export * from './MSDFTextEntity';
5
+ export * from './SVGEntity';
package/dist/text.js CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
 
4
4
 
5
- var _chunk53DAQC3Ujs = require('./chunk-53DAQC3U.js');
5
+ var _chunkLA3FJLP2js = require('./chunk-LA3FJLP2.js');
6
6
 
7
7
 
8
8
 
@@ -13,4 +13,4 @@ var _chunkRW6NC4RBjs = require('./chunk-RW6NC4RB.js');
13
13
 
14
14
 
15
15
 
16
- exports.ArabicShaper = _chunkRW6NC4RBjs.ArabicShaper; exports.BidiResolver = _chunkRW6NC4RBjs.BidiResolver; exports.MSDFFont = _chunk53DAQC3Ujs.MSDFFont; exports.MSDFTextEntity = _chunk53DAQC3Ujs.MSDFTextEntity; exports.SVGEntity = _chunk53DAQC3Ujs.SVGEntity;
16
+ exports.ArabicShaper = _chunkRW6NC4RBjs.ArabicShaper; exports.BidiResolver = _chunkRW6NC4RBjs.BidiResolver; exports.MSDFFont = _chunkLA3FJLP2js.MSDFFont; exports.MSDFTextEntity = _chunkLA3FJLP2js.MSDFTextEntity; exports.SVGEntity = _chunkLA3FJLP2js.SVGEntity;
package/dist/text.mjs CHANGED
@@ -2,7 +2,7 @@ import {
2
2
  MSDFFont,
3
3
  MSDFTextEntity,
4
4
  SVGEntity
5
- } from "./chunk-M2IZPGOL.mjs";
5
+ } from "./chunk-H3QIE77O.mjs";
6
6
  import {
7
7
  ArabicShaper,
8
8
  BidiResolver