@vectojs/core 0.2.4 → 0.2.5
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/dist/{chunk-IKLYTHAL.js → chunk-5KLB6BEZ.js} +16 -20
- package/dist/{chunk-MCULB5VC.mjs → chunk-SB3SCWLT.mjs} +16 -20
- package/dist/index.js +4 -4
- package/dist/index.mjs +1 -1
- package/dist/layout/LayoutEngine.d.ts +1 -0
- package/dist/layout.js +2 -2
- package/dist/layout.mjs +1 -1
- package/package.json +1 -1
|
@@ -79,6 +79,12 @@ var LayoutEngine = (_class = class {
|
|
|
79
79
|
if (this.measurer) return this.measurer.measure(char, fontSize);
|
|
80
80
|
return fontSize * 0.5;
|
|
81
81
|
}
|
|
82
|
+
glyphKeyFor(grapheme, fontAtlas) {
|
|
83
|
+
if (fontAtlas[grapheme]) return grapheme;
|
|
84
|
+
const firstCodePoint = Array.from(grapheme)[0];
|
|
85
|
+
if (firstCodePoint && fontAtlas[firstCodePoint]) return firstCodePoint;
|
|
86
|
+
return grapheme;
|
|
87
|
+
}
|
|
82
88
|
getGraphemes(word) {
|
|
83
89
|
const cached = this.graphemeCache.get(word);
|
|
84
90
|
if (cached) return cached;
|
|
@@ -158,25 +164,20 @@ var LayoutEngine = (_class = class {
|
|
|
158
164
|
const rawEnd = visualEnd === shapedText.length ? paragraph.length : indexMap[visualEnd];
|
|
159
165
|
const sourceIndex = offset + rawStart;
|
|
160
166
|
const sourceLength = rawEnd - rawStart;
|
|
161
|
-
const
|
|
167
|
+
const glyphKey = this.glyphKeyFor(char, fontAtlas);
|
|
162
168
|
const level = levels[visualStart];
|
|
163
|
-
const hasGlyph = !!fontAtlas[
|
|
169
|
+
const hasGlyph = !!fontAtlas[glyphKey];
|
|
164
170
|
if (char.trim().length > 0 && !hasGlyph) {
|
|
165
171
|
pFallback = true;
|
|
166
172
|
fallbackToCanvas = true;
|
|
167
173
|
}
|
|
168
|
-
const w = this.glyphWidth(
|
|
169
|
-
const combining = [];
|
|
170
|
-
for (let cIdx = 1; cIdx < char.length; cIdx++) {
|
|
171
|
-
combining.push(char[cIdx]);
|
|
172
|
-
}
|
|
174
|
+
const w = this.glyphWidth(glyphKey, fontAtlas, fontSize);
|
|
173
175
|
glyphs.push({
|
|
174
|
-
char
|
|
176
|
+
char,
|
|
175
177
|
width: w,
|
|
176
178
|
level,
|
|
177
179
|
sourceIndex,
|
|
178
|
-
sourceLength
|
|
179
|
-
combining: combining.length > 0 ? combining : void 0
|
|
180
|
+
sourceLength
|
|
180
181
|
});
|
|
181
182
|
width += w;
|
|
182
183
|
shapedCharIdx += char.length;
|
|
@@ -280,28 +281,23 @@ var LayoutEngine = (_class = class {
|
|
|
280
281
|
const rawEnd = visualEnd === shapedText.length ? paragraph.length : indexMap[visualEnd];
|
|
281
282
|
const sourceIndex = offset + rawStart;
|
|
282
283
|
const sourceLength = rawEnd - rawStart;
|
|
283
|
-
const
|
|
284
|
+
const glyphKey = this.glyphKeyFor(char, fontAtlas);
|
|
284
285
|
const level = levels[visualStart];
|
|
285
286
|
const style = styleAt[offset + rawStart];
|
|
286
287
|
const gfs = _nullishCoalesce(_optionalChain([style, 'optionalAccess', _ => _.fontSize]), () => ( baseFontSize));
|
|
287
|
-
const hasGlyph = !!fontAtlas[
|
|
288
|
+
const hasGlyph = !!fontAtlas[glyphKey];
|
|
288
289
|
if (char.trim().length > 0 && !hasGlyph) {
|
|
289
290
|
pFallback = true;
|
|
290
291
|
fallbackToCanvas = true;
|
|
291
292
|
}
|
|
292
|
-
const w = this.glyphWidth(
|
|
293
|
-
const combining = [];
|
|
294
|
-
for (let cIdx = 1; cIdx < char.length; cIdx++) {
|
|
295
|
-
combining.push(char[cIdx]);
|
|
296
|
-
}
|
|
293
|
+
const w = this.glyphWidth(glyphKey, fontAtlas, gfs);
|
|
297
294
|
glyphs.push({
|
|
298
|
-
char
|
|
295
|
+
char,
|
|
299
296
|
width: w,
|
|
300
297
|
style,
|
|
301
298
|
level,
|
|
302
299
|
sourceIndex,
|
|
303
|
-
sourceLength
|
|
304
|
-
combining: combining.length > 0 ? combining : void 0
|
|
300
|
+
sourceLength
|
|
305
301
|
});
|
|
306
302
|
width += w;
|
|
307
303
|
shapedCharIdx += char.length;
|
|
@@ -79,6 +79,12 @@ var LayoutEngine = class {
|
|
|
79
79
|
if (this.measurer) return this.measurer.measure(char, fontSize);
|
|
80
80
|
return fontSize * 0.5;
|
|
81
81
|
}
|
|
82
|
+
glyphKeyFor(grapheme, fontAtlas) {
|
|
83
|
+
if (fontAtlas[grapheme]) return grapheme;
|
|
84
|
+
const firstCodePoint = Array.from(grapheme)[0];
|
|
85
|
+
if (firstCodePoint && fontAtlas[firstCodePoint]) return firstCodePoint;
|
|
86
|
+
return grapheme;
|
|
87
|
+
}
|
|
82
88
|
getGraphemes(word) {
|
|
83
89
|
const cached = this.graphemeCache.get(word);
|
|
84
90
|
if (cached) return cached;
|
|
@@ -158,25 +164,20 @@ var LayoutEngine = class {
|
|
|
158
164
|
const rawEnd = visualEnd === shapedText.length ? paragraph.length : indexMap[visualEnd];
|
|
159
165
|
const sourceIndex = offset + rawStart;
|
|
160
166
|
const sourceLength = rawEnd - rawStart;
|
|
161
|
-
const
|
|
167
|
+
const glyphKey = this.glyphKeyFor(char, fontAtlas);
|
|
162
168
|
const level = levels[visualStart];
|
|
163
|
-
const hasGlyph = !!fontAtlas[
|
|
169
|
+
const hasGlyph = !!fontAtlas[glyphKey];
|
|
164
170
|
if (char.trim().length > 0 && !hasGlyph) {
|
|
165
171
|
pFallback = true;
|
|
166
172
|
fallbackToCanvas = true;
|
|
167
173
|
}
|
|
168
|
-
const w = this.glyphWidth(
|
|
169
|
-
const combining = [];
|
|
170
|
-
for (let cIdx = 1; cIdx < char.length; cIdx++) {
|
|
171
|
-
combining.push(char[cIdx]);
|
|
172
|
-
}
|
|
174
|
+
const w = this.glyphWidth(glyphKey, fontAtlas, fontSize);
|
|
173
175
|
glyphs.push({
|
|
174
|
-
char
|
|
176
|
+
char,
|
|
175
177
|
width: w,
|
|
176
178
|
level,
|
|
177
179
|
sourceIndex,
|
|
178
|
-
sourceLength
|
|
179
|
-
combining: combining.length > 0 ? combining : void 0
|
|
180
|
+
sourceLength
|
|
180
181
|
});
|
|
181
182
|
width += w;
|
|
182
183
|
shapedCharIdx += char.length;
|
|
@@ -280,28 +281,23 @@ var LayoutEngine = class {
|
|
|
280
281
|
const rawEnd = visualEnd === shapedText.length ? paragraph.length : indexMap[visualEnd];
|
|
281
282
|
const sourceIndex = offset + rawStart;
|
|
282
283
|
const sourceLength = rawEnd - rawStart;
|
|
283
|
-
const
|
|
284
|
+
const glyphKey = this.glyphKeyFor(char, fontAtlas);
|
|
284
285
|
const level = levels[visualStart];
|
|
285
286
|
const style = styleAt[offset + rawStart];
|
|
286
287
|
const gfs = style?.fontSize ?? baseFontSize;
|
|
287
|
-
const hasGlyph = !!fontAtlas[
|
|
288
|
+
const hasGlyph = !!fontAtlas[glyphKey];
|
|
288
289
|
if (char.trim().length > 0 && !hasGlyph) {
|
|
289
290
|
pFallback = true;
|
|
290
291
|
fallbackToCanvas = true;
|
|
291
292
|
}
|
|
292
|
-
const w = this.glyphWidth(
|
|
293
|
-
const combining = [];
|
|
294
|
-
for (let cIdx = 1; cIdx < char.length; cIdx++) {
|
|
295
|
-
combining.push(char[cIdx]);
|
|
296
|
-
}
|
|
293
|
+
const w = this.glyphWidth(glyphKey, fontAtlas, gfs);
|
|
297
294
|
glyphs.push({
|
|
298
|
-
char
|
|
295
|
+
char,
|
|
299
296
|
width: w,
|
|
300
297
|
style,
|
|
301
298
|
level,
|
|
302
299
|
sourceIndex,
|
|
303
|
-
sourceLength
|
|
304
|
-
combining: combining.length > 0 ? combining : void 0
|
|
300
|
+
sourceLength
|
|
305
301
|
});
|
|
306
302
|
width += w;
|
|
307
303
|
shapedCharIdx += char.length;
|
package/dist/index.js
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
|
|
4
4
|
|
|
5
5
|
|
|
6
|
-
var
|
|
6
|
+
var _chunk5KLB6BEZjs = require('./chunk-5KLB6BEZ.js');
|
|
7
7
|
|
|
8
8
|
|
|
9
9
|
|
|
@@ -1604,7 +1604,7 @@ var Scene = (_class2 = class _Scene {
|
|
|
1604
1604
|
// src/components/TextEntity.ts
|
|
1605
1605
|
var sharedMeasurer;
|
|
1606
1606
|
function defaultMeasurer() {
|
|
1607
|
-
if (sharedMeasurer === void 0) sharedMeasurer =
|
|
1607
|
+
if (sharedMeasurer === void 0) sharedMeasurer = _chunk5KLB6BEZjs.createCanvasMeasurer.call(void 0, "sans-serif");
|
|
1608
1608
|
return sharedMeasurer;
|
|
1609
1609
|
}
|
|
1610
1610
|
var TextEntity = (_class3 = class extends _chunkTQ4H357Qjs.Entity {
|
|
@@ -1624,7 +1624,7 @@ var TextEntity = (_class3 = class extends _chunkTQ4H357Qjs.Entity {
|
|
|
1624
1624
|
this.text = text;
|
|
1625
1625
|
this.atlas = atlas;
|
|
1626
1626
|
this.fontSize = fontSize;
|
|
1627
|
-
this.layout = new (0,
|
|
1627
|
+
this.layout = new (0, _chunk5KLB6BEZjs.LayoutEngine)(maxWidth, 1e4, defaultMeasurer());
|
|
1628
1628
|
this.prepared = this.layout.prepare(this.text, this.atlas, this.fontSize);
|
|
1629
1629
|
this.applyLayout();
|
|
1630
1630
|
this.interactive = true;
|
|
@@ -2295,4 +2295,4 @@ Scene.registerWebGPUParticleSystemManager(_chunkTPNADFNNjs.WebGPUParticleSystemM
|
|
|
2295
2295
|
|
|
2296
2296
|
|
|
2297
2297
|
|
|
2298
|
-
exports.ArabicShaper = _chunk76NMTLYLjs.ArabicShaper; exports.BidiResolver = _chunk76NMTLYLjs.BidiResolver; exports.CanvasRenderer = _chunkTPNADFNNjs.CanvasRenderer; exports.ComputeParticleEntity = ComputeParticleEntity; exports.DOMPortalEntity = DOMPortalEntity; exports.Easing = _chunkTQ4H357Qjs.Easing; exports.Entity = _chunkTQ4H357Qjs.Entity; exports.GridTextEntity = GridTextEntity; exports.LayoutEngine =
|
|
2298
|
+
exports.ArabicShaper = _chunk76NMTLYLjs.ArabicShaper; exports.BidiResolver = _chunk76NMTLYLjs.BidiResolver; exports.CanvasRenderer = _chunkTPNADFNNjs.CanvasRenderer; exports.ComputeParticleEntity = ComputeParticleEntity; exports.DOMPortalEntity = DOMPortalEntity; exports.Easing = _chunkTQ4H357Qjs.Easing; exports.Entity = _chunkTQ4H357Qjs.Entity; exports.GridTextEntity = GridTextEntity; exports.LayoutEngine = _chunk5KLB6BEZjs.LayoutEngine; exports.LayoutResultBuffer = _chunk5KLB6BEZjs.LayoutResultBuffer; exports.LayoutWorkerManager = _chunk76NMTLYLjs.LayoutWorkerManager; exports.MSDFFont = _chunkTQ4H357Qjs.MSDFFont; exports.MSDFTextEntity = _chunkTQ4H357Qjs.MSDFTextEntity; exports.PARTICLE_OFFSET_LIFE = PARTICLE_OFFSET_LIFE; exports.PARTICLE_OFFSET_ORIGIN_X = PARTICLE_OFFSET_ORIGIN_X; exports.PARTICLE_OFFSET_ORIGIN_Y = PARTICLE_OFFSET_ORIGIN_Y; exports.PARTICLE_OFFSET_POSITION_X = PARTICLE_OFFSET_POSITION_X; exports.PARTICLE_OFFSET_POSITION_Y = PARTICLE_OFFSET_POSITION_Y; exports.PARTICLE_OFFSET_SIZE = PARTICLE_OFFSET_SIZE; exports.PARTICLE_OFFSET_VELOCITY_X = PARTICLE_OFFSET_VELOCITY_X; exports.PARTICLE_OFFSET_VELOCITY_Y = PARTICLE_OFFSET_VELOCITY_Y; exports.PARTICLE_STRIDE_FLOATS = PARTICLE_STRIDE_FLOATS; exports.REDUCED_MOTION_FPS = REDUCED_MOTION_FPS; exports.SVGEntity = _chunkTQ4H357Qjs.SVGEntity; exports.SVGRenderer = _chunkTPNADFNNjs.SVGRenderer; exports.Scene = Scene; exports.SpatialHashGrid = SpatialHashGrid; exports.SplineEntity = SplineEntity; exports.SpringDriver = _chunkTQ4H357Qjs.SpringDriver; exports.SpringPhysics = _chunkTQ4H357Qjs.SpringPhysics; exports.TextEntity = TextEntity; exports.TweenDriver = _chunkTQ4H357Qjs.TweenDriver; exports.VectoJSEvent = _chunkTQ4H357Qjs.VectoJSEvent; exports.WebGPUParticleSystemManager = _chunkTPNADFNNjs.WebGPUParticleSystemManager; exports.computeLineSegments = _chunk5KLB6BEZjs.computeLineSegments; exports.createCanvasMeasurer = _chunk5KLB6BEZjs.createCanvasMeasurer; exports.createWebGLPointRenderer = _chunkTPNADFNNjs.createWebGLPointRenderer; exports.isSafeUrl = _chunkTPNADFNNjs.isSafeUrl; exports.isTweenConfig = _chunkTQ4H357Qjs.isTweenConfig; exports.loadSpline = loadSpline; exports.parseColorToRGBA = _chunkTPNADFNNjs.parseColorToRGBA; exports.polySegmentToBezier = polySegmentToBezier; exports.sanitizeUrl = _chunkTPNADFNNjs.sanitizeUrl;
|
package/dist/index.mjs
CHANGED
|
@@ -157,6 +157,7 @@ export declare class LayoutEngine {
|
|
|
157
157
|
* pre-baked atlas entry → injected {@link GlyphMeasurer} → `0.5em` fallback.
|
|
158
158
|
*/
|
|
159
159
|
private glyphWidth;
|
|
160
|
+
private glyphKeyFor;
|
|
160
161
|
private getGraphemes;
|
|
161
162
|
/**
|
|
162
163
|
* Lay out a Unicode string into a list of positioned {@link LayoutNode} glyphs.
|
package/dist/layout.js
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
|
|
4
4
|
|
|
5
5
|
|
|
6
|
-
var
|
|
6
|
+
var _chunk5KLB6BEZjs = require('./chunk-5KLB6BEZ.js');
|
|
7
7
|
|
|
8
8
|
|
|
9
9
|
var _chunk76NMTLYLjs = require('./chunk-76NMTLYL.js');
|
|
@@ -13,4 +13,4 @@ var _chunk76NMTLYLjs = require('./chunk-76NMTLYL.js');
|
|
|
13
13
|
|
|
14
14
|
|
|
15
15
|
|
|
16
|
-
exports.LayoutEngine =
|
|
16
|
+
exports.LayoutEngine = _chunk5KLB6BEZjs.LayoutEngine; exports.LayoutResultBuffer = _chunk5KLB6BEZjs.LayoutResultBuffer; exports.LayoutWorkerManager = _chunk76NMTLYLjs.LayoutWorkerManager; exports.computeLineSegments = _chunk5KLB6BEZjs.computeLineSegments; exports.createCanvasMeasurer = _chunk5KLB6BEZjs.createCanvasMeasurer;
|
package/dist/layout.mjs
CHANGED