@vectojs/core 0.1.0
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 +56 -0
- package/dist/Entity-D-rfAFCf.d.mts +572 -0
- package/dist/Entity-D-rfAFCf.d.ts +572 -0
- package/dist/chunk-2Y45S4JK.mjs +1380 -0
- package/dist/chunk-53DAQC3U.js +907 -0
- package/dist/chunk-72WVPMSJ.js +615 -0
- package/dist/chunk-LIX7DJTI.js +1380 -0
- package/dist/chunk-M2IZPGOL.mjs +907 -0
- package/dist/chunk-RW6NC4RB.js +376 -0
- package/dist/chunk-T456DL4P.mjs +615 -0
- package/dist/chunk-YA2J5ZH7.mjs +376 -0
- package/dist/index-ByBDSmMK.d.mts +365 -0
- package/dist/index-C3Fd_XmG.d.ts +365 -0
- package/dist/index.d.mts +577 -0
- package/dist/index.d.ts +577 -0
- package/dist/index.js +2238 -0
- package/dist/index.mjs +2238 -0
- package/dist/layout.d.mts +319 -0
- package/dist/layout.d.ts +319 -0
- package/dist/layout.js +16 -0
- package/dist/layout.mjs +16 -0
- package/dist/renderer.d.mts +2 -0
- package/dist/renderer.d.ts +2 -0
- package/dist/renderer.js +14 -0
- package/dist/renderer.mjs +14 -0
- package/dist/text.d.mts +201 -0
- package/dist/text.d.ts +201 -0
- package/dist/text.js +16 -0
- package/dist/text.mjs +16 -0
- package/package.json +68 -0
package/dist/renderer.js
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true});
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
var _chunkLIX7DJTIjs = require('./chunk-LIX7DJTI.js');
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
exports.CanvasRenderer = _chunkLIX7DJTIjs.CanvasRenderer; exports.SVGRenderer = _chunkLIX7DJTIjs.SVGRenderer; exports.WebGPUParticleSystemManager = _chunkLIX7DJTIjs.WebGPUParticleSystemManager; exports.createWebGLPointRenderer = _chunkLIX7DJTIjs.createWebGLPointRenderer; exports.parseColorToRGBA = _chunkLIX7DJTIjs.parseColorToRGBA;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import {
|
|
2
|
+
CanvasRenderer,
|
|
3
|
+
SVGRenderer,
|
|
4
|
+
WebGPUParticleSystemManager,
|
|
5
|
+
createWebGLPointRenderer,
|
|
6
|
+
parseColorToRGBA
|
|
7
|
+
} from "./chunk-2Y45S4JK.mjs";
|
|
8
|
+
export {
|
|
9
|
+
CanvasRenderer,
|
|
10
|
+
SVGRenderer,
|
|
11
|
+
WebGPUParticleSystemManager,
|
|
12
|
+
createWebGLPointRenderer,
|
|
13
|
+
parseColorToRGBA
|
|
14
|
+
};
|
package/dist/text.d.mts
ADDED
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
import { E as Entity, I as IRenderer } from './Entity-D-rfAFCf.mjs';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* MSDF (Multi-channel Signed Distance Field) font support.
|
|
5
|
+
*
|
|
6
|
+
* Parses the `msdf-atlas-gen` JSON layout — the de-facto MSDF format produced by
|
|
7
|
+
* Chlumsky's `msdf-atlas-gen` / `msdfgen` — and lays a string out into textured
|
|
8
|
+
* quads positioned in CSS pixels with atlas UVs. Pair {@link MSDFFont.layout}
|
|
9
|
+
* with the WebGL backend's `setMSDFTexture` + `addGlyph` to render GPU text that
|
|
10
|
+
* stays crisp at any scale (and supports outline/glow in the shader).
|
|
11
|
+
*
|
|
12
|
+
* Geometry conventions match the renderer: local space is y-down, top-left
|
|
13
|
+
* origin; UVs use v=0 at the top of the atlas image (atlas uploaded without a
|
|
14
|
+
* Y-flip, the same as `setTexture`/`addSprite`).
|
|
15
|
+
*/
|
|
16
|
+
/** Atlas section of an `msdf-atlas-gen` JSON file. */
|
|
17
|
+
interface MSDFAtlasInfo {
|
|
18
|
+
/** Field type, e.g. `'msdf'` | `'mtsdf'` | `'sdf'`. */
|
|
19
|
+
type: string;
|
|
20
|
+
/** Distance field range in atlas pixels — drives the shader's edge sharpness. */
|
|
21
|
+
distanceRange: number;
|
|
22
|
+
/** Glyph size the atlas was rasterized at (em → px), informational. */
|
|
23
|
+
size: number;
|
|
24
|
+
/** Atlas image width in pixels. */
|
|
25
|
+
width: number;
|
|
26
|
+
/** Atlas image height in pixels. */
|
|
27
|
+
height: number;
|
|
28
|
+
/** Whether `atlasBounds` are measured from the image bottom or top. */
|
|
29
|
+
yOrigin: 'bottom' | 'top';
|
|
30
|
+
}
|
|
31
|
+
/** Font-wide metrics in em units. */
|
|
32
|
+
interface MSDFMetrics {
|
|
33
|
+
emSize: number;
|
|
34
|
+
/** Line advance in em (multiply by font size for px). */
|
|
35
|
+
lineHeight: number;
|
|
36
|
+
/** Distance from baseline to the top of the line in em (positive, up). */
|
|
37
|
+
ascender: number;
|
|
38
|
+
/** Distance from baseline to the bottom in em (negative, down). */
|
|
39
|
+
descender: number;
|
|
40
|
+
underlineY?: number;
|
|
41
|
+
underlineThickness?: number;
|
|
42
|
+
}
|
|
43
|
+
/** Em-unit / atlas-pixel rectangle as emitted by `msdf-atlas-gen`. */
|
|
44
|
+
interface MSDFBounds {
|
|
45
|
+
left: number;
|
|
46
|
+
bottom: number;
|
|
47
|
+
right: number;
|
|
48
|
+
top: number;
|
|
49
|
+
}
|
|
50
|
+
/** One glyph's metrics. Whitespace has `advance` but no plane/atlas bounds. */
|
|
51
|
+
interface MSDFGlyphDef {
|
|
52
|
+
unicode: number;
|
|
53
|
+
/** Horizontal advance in em units. */
|
|
54
|
+
advance: number;
|
|
55
|
+
/** Quad position relative to the baseline, em units, y-up. */
|
|
56
|
+
planeBounds?: MSDFBounds;
|
|
57
|
+
/** Source rectangle in the atlas, pixels. */
|
|
58
|
+
atlasBounds?: MSDFBounds;
|
|
59
|
+
}
|
|
60
|
+
/** Kerning pair adjustment in em units. */
|
|
61
|
+
interface MSDFKerning {
|
|
62
|
+
unicode1: number;
|
|
63
|
+
unicode2: number;
|
|
64
|
+
advance: number;
|
|
65
|
+
}
|
|
66
|
+
/** A parsed `msdf-atlas-gen` JSON document. */
|
|
67
|
+
interface MSDFFontData {
|
|
68
|
+
atlas: MSDFAtlasInfo;
|
|
69
|
+
metrics: MSDFMetrics;
|
|
70
|
+
glyphs: MSDFGlyphDef[];
|
|
71
|
+
kerning?: MSDFKerning[];
|
|
72
|
+
}
|
|
73
|
+
/** A glyph positioned for rendering: a CSS-pixel quad + atlas UVs (0..1). */
|
|
74
|
+
interface PositionedGlyph {
|
|
75
|
+
/** Source character (may be a surrogate-pair astral codepoint). */
|
|
76
|
+
char: string;
|
|
77
|
+
/** Quad top-left in local CSS pixels (y-down). */
|
|
78
|
+
x: number;
|
|
79
|
+
y: number;
|
|
80
|
+
/** Quad size in CSS pixels. */
|
|
81
|
+
w: number;
|
|
82
|
+
h: number;
|
|
83
|
+
/** Atlas UVs: `(u0,v0)` top-left, `(u1,v1)` bottom-right; v=0 is the atlas top. */
|
|
84
|
+
u0: number;
|
|
85
|
+
v0: number;
|
|
86
|
+
u1: number;
|
|
87
|
+
v1: number;
|
|
88
|
+
}
|
|
89
|
+
/** Result of {@link MSDFFont.layout}. */
|
|
90
|
+
interface MSDFLayoutResult {
|
|
91
|
+
glyphs: PositionedGlyph[];
|
|
92
|
+
/** Total pen advance of the widest line in CSS pixels. */
|
|
93
|
+
width: number;
|
|
94
|
+
/** `lineCount × lineHeight × fontSize` in CSS pixels. */
|
|
95
|
+
height: number;
|
|
96
|
+
}
|
|
97
|
+
/** Options for {@link MSDFFont.layout}. */
|
|
98
|
+
interface MSDFLayoutOptions {
|
|
99
|
+
/** Pen origin x (left of the first glyph), CSS pixels. Default 0. */
|
|
100
|
+
x?: number;
|
|
101
|
+
/** Text-block top y (baseline of line 0 = `y + ascender×size`). Default 0. */
|
|
102
|
+
y?: number;
|
|
103
|
+
/** Extra advance added after every glyph, CSS pixels. Default 0. */
|
|
104
|
+
letterSpacing?: number;
|
|
105
|
+
}
|
|
106
|
+
/**
|
|
107
|
+
* A loaded MSDF font. Construct from parsed {@link MSDFFontData}, or use
|
|
108
|
+
* {@link MSDFFont.parse} to read the JSON string straight from `msdf-atlas-gen`.
|
|
109
|
+
*/
|
|
110
|
+
declare class MSDFFont {
|
|
111
|
+
private static idCounter;
|
|
112
|
+
readonly id: string;
|
|
113
|
+
readonly data: MSDFFontData;
|
|
114
|
+
private readonly byCode;
|
|
115
|
+
private readonly kern;
|
|
116
|
+
constructor(data: MSDFFontData);
|
|
117
|
+
/** Parse the `msdf-atlas-gen` JSON (string or already-parsed object). */
|
|
118
|
+
static parse(json: string | MSDFFontData): MSDFFont;
|
|
119
|
+
/** Get a glyph's definition by its unicode value in O(1) time. */
|
|
120
|
+
getGlyph(unicode: number): MSDFGlyphDef | undefined;
|
|
121
|
+
/** Distance field range in atlas pixels (for the shader's `u_distanceRange`). */
|
|
122
|
+
get distanceRange(): number;
|
|
123
|
+
get atlasWidth(): number;
|
|
124
|
+
get atlasHeight(): number;
|
|
125
|
+
/**
|
|
126
|
+
* Lay `text` out at `fontSizePx`. Returns positioned quads (skipping glyphs the
|
|
127
|
+
* font doesn't contain), the widest line's advance, and the total block height.
|
|
128
|
+
* Honors `\n`, kerning pairs, and `letterSpacing`.
|
|
129
|
+
*/
|
|
130
|
+
layout(text: string, fontSizePx: number, opts?: MSDFLayoutOptions): MSDFLayoutResult;
|
|
131
|
+
}
|
|
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 };
|
package/dist/text.d.ts
ADDED
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
import { E as Entity, I as IRenderer } from './Entity-D-rfAFCf.js';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* MSDF (Multi-channel Signed Distance Field) font support.
|
|
5
|
+
*
|
|
6
|
+
* Parses the `msdf-atlas-gen` JSON layout — the de-facto MSDF format produced by
|
|
7
|
+
* Chlumsky's `msdf-atlas-gen` / `msdfgen` — and lays a string out into textured
|
|
8
|
+
* quads positioned in CSS pixels with atlas UVs. Pair {@link MSDFFont.layout}
|
|
9
|
+
* with the WebGL backend's `setMSDFTexture` + `addGlyph` to render GPU text that
|
|
10
|
+
* stays crisp at any scale (and supports outline/glow in the shader).
|
|
11
|
+
*
|
|
12
|
+
* Geometry conventions match the renderer: local space is y-down, top-left
|
|
13
|
+
* origin; UVs use v=0 at the top of the atlas image (atlas uploaded without a
|
|
14
|
+
* Y-flip, the same as `setTexture`/`addSprite`).
|
|
15
|
+
*/
|
|
16
|
+
/** Atlas section of an `msdf-atlas-gen` JSON file. */
|
|
17
|
+
interface MSDFAtlasInfo {
|
|
18
|
+
/** Field type, e.g. `'msdf'` | `'mtsdf'` | `'sdf'`. */
|
|
19
|
+
type: string;
|
|
20
|
+
/** Distance field range in atlas pixels — drives the shader's edge sharpness. */
|
|
21
|
+
distanceRange: number;
|
|
22
|
+
/** Glyph size the atlas was rasterized at (em → px), informational. */
|
|
23
|
+
size: number;
|
|
24
|
+
/** Atlas image width in pixels. */
|
|
25
|
+
width: number;
|
|
26
|
+
/** Atlas image height in pixels. */
|
|
27
|
+
height: number;
|
|
28
|
+
/** Whether `atlasBounds` are measured from the image bottom or top. */
|
|
29
|
+
yOrigin: 'bottom' | 'top';
|
|
30
|
+
}
|
|
31
|
+
/** Font-wide metrics in em units. */
|
|
32
|
+
interface MSDFMetrics {
|
|
33
|
+
emSize: number;
|
|
34
|
+
/** Line advance in em (multiply by font size for px). */
|
|
35
|
+
lineHeight: number;
|
|
36
|
+
/** Distance from baseline to the top of the line in em (positive, up). */
|
|
37
|
+
ascender: number;
|
|
38
|
+
/** Distance from baseline to the bottom in em (negative, down). */
|
|
39
|
+
descender: number;
|
|
40
|
+
underlineY?: number;
|
|
41
|
+
underlineThickness?: number;
|
|
42
|
+
}
|
|
43
|
+
/** Em-unit / atlas-pixel rectangle as emitted by `msdf-atlas-gen`. */
|
|
44
|
+
interface MSDFBounds {
|
|
45
|
+
left: number;
|
|
46
|
+
bottom: number;
|
|
47
|
+
right: number;
|
|
48
|
+
top: number;
|
|
49
|
+
}
|
|
50
|
+
/** One glyph's metrics. Whitespace has `advance` but no plane/atlas bounds. */
|
|
51
|
+
interface MSDFGlyphDef {
|
|
52
|
+
unicode: number;
|
|
53
|
+
/** Horizontal advance in em units. */
|
|
54
|
+
advance: number;
|
|
55
|
+
/** Quad position relative to the baseline, em units, y-up. */
|
|
56
|
+
planeBounds?: MSDFBounds;
|
|
57
|
+
/** Source rectangle in the atlas, pixels. */
|
|
58
|
+
atlasBounds?: MSDFBounds;
|
|
59
|
+
}
|
|
60
|
+
/** Kerning pair adjustment in em units. */
|
|
61
|
+
interface MSDFKerning {
|
|
62
|
+
unicode1: number;
|
|
63
|
+
unicode2: number;
|
|
64
|
+
advance: number;
|
|
65
|
+
}
|
|
66
|
+
/** A parsed `msdf-atlas-gen` JSON document. */
|
|
67
|
+
interface MSDFFontData {
|
|
68
|
+
atlas: MSDFAtlasInfo;
|
|
69
|
+
metrics: MSDFMetrics;
|
|
70
|
+
glyphs: MSDFGlyphDef[];
|
|
71
|
+
kerning?: MSDFKerning[];
|
|
72
|
+
}
|
|
73
|
+
/** A glyph positioned for rendering: a CSS-pixel quad + atlas UVs (0..1). */
|
|
74
|
+
interface PositionedGlyph {
|
|
75
|
+
/** Source character (may be a surrogate-pair astral codepoint). */
|
|
76
|
+
char: string;
|
|
77
|
+
/** Quad top-left in local CSS pixels (y-down). */
|
|
78
|
+
x: number;
|
|
79
|
+
y: number;
|
|
80
|
+
/** Quad size in CSS pixels. */
|
|
81
|
+
w: number;
|
|
82
|
+
h: number;
|
|
83
|
+
/** Atlas UVs: `(u0,v0)` top-left, `(u1,v1)` bottom-right; v=0 is the atlas top. */
|
|
84
|
+
u0: number;
|
|
85
|
+
v0: number;
|
|
86
|
+
u1: number;
|
|
87
|
+
v1: number;
|
|
88
|
+
}
|
|
89
|
+
/** Result of {@link MSDFFont.layout}. */
|
|
90
|
+
interface MSDFLayoutResult {
|
|
91
|
+
glyphs: PositionedGlyph[];
|
|
92
|
+
/** Total pen advance of the widest line in CSS pixels. */
|
|
93
|
+
width: number;
|
|
94
|
+
/** `lineCount × lineHeight × fontSize` in CSS pixels. */
|
|
95
|
+
height: number;
|
|
96
|
+
}
|
|
97
|
+
/** Options for {@link MSDFFont.layout}. */
|
|
98
|
+
interface MSDFLayoutOptions {
|
|
99
|
+
/** Pen origin x (left of the first glyph), CSS pixels. Default 0. */
|
|
100
|
+
x?: number;
|
|
101
|
+
/** Text-block top y (baseline of line 0 = `y + ascender×size`). Default 0. */
|
|
102
|
+
y?: number;
|
|
103
|
+
/** Extra advance added after every glyph, CSS pixels. Default 0. */
|
|
104
|
+
letterSpacing?: number;
|
|
105
|
+
}
|
|
106
|
+
/**
|
|
107
|
+
* A loaded MSDF font. Construct from parsed {@link MSDFFontData}, or use
|
|
108
|
+
* {@link MSDFFont.parse} to read the JSON string straight from `msdf-atlas-gen`.
|
|
109
|
+
*/
|
|
110
|
+
declare class MSDFFont {
|
|
111
|
+
private static idCounter;
|
|
112
|
+
readonly id: string;
|
|
113
|
+
readonly data: MSDFFontData;
|
|
114
|
+
private readonly byCode;
|
|
115
|
+
private readonly kern;
|
|
116
|
+
constructor(data: MSDFFontData);
|
|
117
|
+
/** Parse the `msdf-atlas-gen` JSON (string or already-parsed object). */
|
|
118
|
+
static parse(json: string | MSDFFontData): MSDFFont;
|
|
119
|
+
/** Get a glyph's definition by its unicode value in O(1) time. */
|
|
120
|
+
getGlyph(unicode: number): MSDFGlyphDef | undefined;
|
|
121
|
+
/** Distance field range in atlas pixels (for the shader's `u_distanceRange`). */
|
|
122
|
+
get distanceRange(): number;
|
|
123
|
+
get atlasWidth(): number;
|
|
124
|
+
get atlasHeight(): number;
|
|
125
|
+
/**
|
|
126
|
+
* Lay `text` out at `fontSizePx`. Returns positioned quads (skipping glyphs the
|
|
127
|
+
* font doesn't contain), the widest line's advance, and the total block height.
|
|
128
|
+
* Honors `\n`, kerning pairs, and `letterSpacing`.
|
|
129
|
+
*/
|
|
130
|
+
layout(text: string, fontSizePx: number, opts?: MSDFLayoutOptions): MSDFLayoutResult;
|
|
131
|
+
}
|
|
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 };
|
package/dist/text.js
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true});
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
var _chunk53DAQC3Ujs = require('./chunk-53DAQC3U.js');
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
var _chunkRW6NC4RBjs = require('./chunk-RW6NC4RB.js');
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
exports.ArabicShaper = _chunkRW6NC4RBjs.ArabicShaper; exports.BidiResolver = _chunkRW6NC4RBjs.BidiResolver; exports.MSDFFont = _chunk53DAQC3Ujs.MSDFFont; exports.MSDFTextEntity = _chunk53DAQC3Ujs.MSDFTextEntity; exports.SVGEntity = _chunk53DAQC3Ujs.SVGEntity;
|
package/dist/text.mjs
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import {
|
|
2
|
+
MSDFFont,
|
|
3
|
+
MSDFTextEntity,
|
|
4
|
+
SVGEntity
|
|
5
|
+
} from "./chunk-M2IZPGOL.mjs";
|
|
6
|
+
import {
|
|
7
|
+
ArabicShaper,
|
|
8
|
+
BidiResolver
|
|
9
|
+
} from "./chunk-YA2J5ZH7.mjs";
|
|
10
|
+
export {
|
|
11
|
+
ArabicShaper,
|
|
12
|
+
BidiResolver,
|
|
13
|
+
MSDFFont,
|
|
14
|
+
MSDFTextEntity,
|
|
15
|
+
SVGEntity
|
|
16
|
+
};
|
package/package.json
ADDED
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@vectojs/core",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"publishConfig": {
|
|
5
|
+
"access": "public"
|
|
6
|
+
},
|
|
7
|
+
"description": "A zero-DOM, Canvas 2D Entity Component System (ECS) rendering framework — 60 FPS with 100,000+ entities.",
|
|
8
|
+
"keywords": [
|
|
9
|
+
"canvas",
|
|
10
|
+
"ecs",
|
|
11
|
+
"fourier",
|
|
12
|
+
"spline",
|
|
13
|
+
"rendering",
|
|
14
|
+
"60fps",
|
|
15
|
+
"typescript",
|
|
16
|
+
"vectorization"
|
|
17
|
+
],
|
|
18
|
+
"license": "MIT",
|
|
19
|
+
"repository": {
|
|
20
|
+
"type": "git",
|
|
21
|
+
"url": "git+https://github.com/vectojs/vectojs.git"
|
|
22
|
+
},
|
|
23
|
+
"bugs": {
|
|
24
|
+
"url": "https://github.com/vectojs/vectojs/issues"
|
|
25
|
+
},
|
|
26
|
+
"homepage": "https://github.com/vectojs/vectojs#readme",
|
|
27
|
+
"main": "./dist/index.js",
|
|
28
|
+
"module": "./dist/index.mjs",
|
|
29
|
+
"types": "./dist/index.d.ts",
|
|
30
|
+
"sideEffects": false,
|
|
31
|
+
"exports": {
|
|
32
|
+
".": {
|
|
33
|
+
"types": "./dist/index.d.ts",
|
|
34
|
+
"import": "./dist/index.mjs",
|
|
35
|
+
"require": "./dist/index.js"
|
|
36
|
+
},
|
|
37
|
+
"./layout": {
|
|
38
|
+
"types": "./dist/layout.d.ts",
|
|
39
|
+
"import": "./dist/layout.mjs",
|
|
40
|
+
"require": "./dist/layout.js"
|
|
41
|
+
},
|
|
42
|
+
"./renderer": {
|
|
43
|
+
"types": "./dist/renderer.d.ts",
|
|
44
|
+
"import": "./dist/renderer.mjs",
|
|
45
|
+
"require": "./dist/renderer.js"
|
|
46
|
+
},
|
|
47
|
+
"./text": {
|
|
48
|
+
"types": "./dist/text.d.ts",
|
|
49
|
+
"import": "./dist/text.mjs",
|
|
50
|
+
"require": "./dist/text.js"
|
|
51
|
+
}
|
|
52
|
+
},
|
|
53
|
+
"files": [
|
|
54
|
+
"dist"
|
|
55
|
+
],
|
|
56
|
+
"scripts": {
|
|
57
|
+
"build": "node scripts/build-worker.js && tsup",
|
|
58
|
+
"test": "vitest run"
|
|
59
|
+
},
|
|
60
|
+
"dependencies": {},
|
|
61
|
+
"devDependencies": {
|
|
62
|
+
"@vitest/coverage-v8": "^4.1.9",
|
|
63
|
+
"esbuild": "^0.21.5",
|
|
64
|
+
"jsdom": "^29.1.1",
|
|
65
|
+
"tsup": "^8.3.5",
|
|
66
|
+
"vitest": "^4.1.9"
|
|
67
|
+
}
|
|
68
|
+
}
|