@vectojs/core 1.14.0 → 1.15.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/dist/{chunk-XIEQHSBB.mjs → chunk-64UFEHOJ.mjs} +7 -464
- package/dist/{chunk-2Z23LTH3.js → chunk-J6NHSFIE.js} +60 -517
- package/dist/index.d.ts +4 -12
- package/dist/index.js +58 -178
- package/dist/index.mjs +12 -132
- package/dist/layout/index.d.ts +1 -3
- package/dist/layout.js +2 -16
- package/dist/layout.mjs +2 -16
- package/dist/text/MSDFTextEntity.d.ts +1 -1
- package/dist/text/index.d.ts +1 -5
- package/dist/text.js +5 -16
- package/dist/text.mjs +6 -17
- package/dist/tree/Entity.d.ts +2 -2
- package/package.json +8 -6
- package/dist/animation/drivers.d.ts +0 -48
- package/dist/animation/easing.d.ts +0 -16
- package/dist/chunk-4AR425AR.js +0 -1121
- package/dist/chunk-BA5HUUDF.js +0 -760
- package/dist/chunk-IESDTEJ4.mjs +0 -1121
- package/dist/chunk-X7I465AQ.mjs +0 -760
- package/dist/layout/LayoutEngine.d.ts +0 -289
- package/dist/layout/LayoutWorker.d.ts +0 -23
- package/dist/layout/LayoutWorkerManager.d.ts +0 -26
- package/dist/layout/LayoutWorkerSource.d.ts +0 -1
- package/dist/layout/measure.d.ts +0 -20
- package/dist/math/SpatialHashGrid.d.ts +0 -53
- package/dist/math/SpringPhysics.d.ts +0 -13
- package/dist/text/ArabicShaper.d.ts +0 -10
- package/dist/text/BidiResolver.d.ts +0 -5
- package/dist/text/MSDFFont.d.ts +0 -129
- package/dist/text/PreparedContentGrid.d.ts +0 -60
- package/dist/text/Typography.d.ts +0 -11
package/dist/index.d.ts
CHANGED
|
@@ -14,20 +14,12 @@ export * from './components/SplineEntity';
|
|
|
14
14
|
export * from './components/Rect';
|
|
15
15
|
export * from './components/Circle';
|
|
16
16
|
export * from './components/Group';
|
|
17
|
-
export * from '
|
|
18
|
-
export * from '
|
|
19
|
-
export * from '
|
|
20
|
-
export * from '
|
|
21
|
-
export * from './math/SpringPhysics';
|
|
22
|
-
export * from './animation/easing';
|
|
23
|
-
export * from './animation/drivers';
|
|
17
|
+
export * from '@vectojs/layout';
|
|
18
|
+
export * from '@vectojs/text';
|
|
19
|
+
export * from '@vectojs/math';
|
|
20
|
+
export * from '@vectojs/animation';
|
|
24
21
|
export { MSDFTextEntity } from './text/MSDFTextEntity';
|
|
25
22
|
export type { MSDFTextEntityOptions } from './text/MSDFTextEntity';
|
|
26
|
-
export { LayoutWorkerManager } from './layout/LayoutWorkerManager';
|
|
27
23
|
export { DOMPortalEntity } from './tree/DOMPortalEntity';
|
|
28
24
|
export { SVGEntity } from './text/SVGEntity';
|
|
29
25
|
export * from './tree/ComputeParticleEntity';
|
|
30
|
-
export * from './text/ArabicShaper';
|
|
31
|
-
export * from './text/BidiResolver';
|
|
32
|
-
export * from './text/PreparedContentGrid';
|
|
33
|
-
export * from './text/Typography';
|
package/dist/index.js
CHANGED
|
@@ -1,10 +1,4 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; } var _class; var _class2; var _class3; var _class4; var _class5; var _class6;
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
var _chunkBA5HUUDFjs = require('./chunk-BA5HUUDF.js');
|
|
7
|
-
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _createStarExport(obj) { Object.keys(obj) .filter((key) => key !== "default" && key !== "__esModule") .forEach((key) => { if (exports.hasOwnProperty(key)) { return; } Object.defineProperty(exports, key, {enumerable: true, configurable: true, get: () => obj[key]}); }); } function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; } var _class; var _class2; var _class3; var _class4; var _class5; var _class6;
|
|
8
2
|
|
|
9
3
|
|
|
10
4
|
|
|
@@ -19,21 +13,7 @@ var _chunkBEUIB3U7js = require('./chunk-BEUIB3U7.js');
|
|
|
19
13
|
|
|
20
14
|
|
|
21
15
|
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
var _chunk2Z23LTH3js = require('./chunk-2Z23LTH3.js');
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
var _chunk4AR425ARjs = require('./chunk-4AR425AR.js');
|
|
16
|
+
var _chunkJ6NHSFIEjs = require('./chunk-J6NHSFIE.js');
|
|
37
17
|
|
|
38
18
|
// src/tree/ComputeParticleEntity.ts
|
|
39
19
|
var PARTICLE_STRIDE_FLOATS = 8;
|
|
@@ -45,7 +25,7 @@ var PARTICLE_OFFSET_ORIGIN_X = 4;
|
|
|
45
25
|
var PARTICLE_OFFSET_ORIGIN_Y = 5;
|
|
46
26
|
var PARTICLE_OFFSET_SIZE = 6;
|
|
47
27
|
var PARTICLE_OFFSET_LIFE = 7;
|
|
48
|
-
var ComputeParticleEntity = (_class = class extends
|
|
28
|
+
var ComputeParticleEntity = (_class = class extends _chunkJ6NHSFIEjs.Entity {
|
|
49
29
|
|
|
50
30
|
|
|
51
31
|
|
|
@@ -330,6 +310,7 @@ var ComputeParticleEntity = (_class = class extends _chunk2Z23LTH3js.Entity {
|
|
|
330
310
|
}, _class);
|
|
331
311
|
|
|
332
312
|
// src/tree/Scene.ts
|
|
313
|
+
var _text = require('@vectojs/text'); _createStarExport(_text);
|
|
333
314
|
var INTERACTIVE_A11Y_ROLES = /* @__PURE__ */ new Set([
|
|
334
315
|
"button",
|
|
335
316
|
"switch",
|
|
@@ -876,7 +857,7 @@ var Scene = (_class2 = class _Scene {
|
|
|
876
857
|
this.contentProjectionMargin = options.contentProjectionMargin;
|
|
877
858
|
this._devActive = _Scene._devModeDetected();
|
|
878
859
|
this.reducedMotionQuery = typeof window !== "undefined" && typeof window.matchMedia === "function" ? window.matchMedia("(prefers-reduced-motion: reduce)") : null;
|
|
879
|
-
this.root = new class RootEntity extends
|
|
860
|
+
this.root = new class RootEntity extends _chunkJ6NHSFIEjs.Entity {
|
|
880
861
|
isPointInside() {
|
|
881
862
|
return false;
|
|
882
863
|
}
|
|
@@ -885,7 +866,7 @@ var Scene = (_class2 = class _Scene {
|
|
|
885
866
|
}
|
|
886
867
|
}("root");
|
|
887
868
|
this.root._scene = this;
|
|
888
|
-
this.overlayRoot = new class OverlayRoot extends
|
|
869
|
+
this.overlayRoot = new class OverlayRoot extends _chunkJ6NHSFIEjs.Entity {
|
|
889
870
|
isPointInside() {
|
|
890
871
|
return false;
|
|
891
872
|
}
|
|
@@ -1038,7 +1019,7 @@ var Scene = (_class2 = class _Scene {
|
|
|
1038
1019
|
};
|
|
1039
1020
|
if (typeof document !== "undefined" && document.fonts) {
|
|
1040
1021
|
this.fontLoadHandler = () => {
|
|
1041
|
-
|
|
1022
|
+
_text.clearCssLineBoxMetrics.call(void 0, );
|
|
1042
1023
|
this.contentFontEpoch++;
|
|
1043
1024
|
this.markDirty();
|
|
1044
1025
|
};
|
|
@@ -1419,18 +1400,18 @@ var Scene = (_class2 = class _Scene {
|
|
|
1419
1400
|
el.style.background = "transparent";
|
|
1420
1401
|
}
|
|
1421
1402
|
el.addEventListener("click", (e) => {
|
|
1422
|
-
node.dispatchEvent(new (0,
|
|
1403
|
+
node.dispatchEvent(new (0, _chunkJ6NHSFIEjs.VectoJSEvent)("click", node, e));
|
|
1423
1404
|
});
|
|
1424
1405
|
el.addEventListener("dblclick", (e) => {
|
|
1425
|
-
node.dispatchEvent(new (0,
|
|
1406
|
+
node.dispatchEvent(new (0, _chunkJ6NHSFIEjs.VectoJSEvent)("dblclick", node, e));
|
|
1426
1407
|
});
|
|
1427
1408
|
el.addEventListener("mouseenter", (e) => {
|
|
1428
1409
|
if (this.debugA11y) el.style.backgroundColor = "rgba(56, 189, 248, 0.2)";
|
|
1429
|
-
node.dispatchEvent(new (0,
|
|
1410
|
+
node.dispatchEvent(new (0, _chunkJ6NHSFIEjs.VectoJSEvent)("hover", node, e, false));
|
|
1430
1411
|
});
|
|
1431
1412
|
el.addEventListener("mouseleave", (e) => {
|
|
1432
1413
|
if (this.debugA11y) el.style.backgroundColor = "rgba(56, 189, 248, 0.05)";
|
|
1433
|
-
node.dispatchEvent(new (0,
|
|
1414
|
+
node.dispatchEvent(new (0, _chunkJ6NHSFIEjs.VectoJSEvent)("pointerleave", node, e, false));
|
|
1434
1415
|
});
|
|
1435
1416
|
const capEl = el;
|
|
1436
1417
|
const releasePointer = (event) => {
|
|
@@ -1446,32 +1427,32 @@ var Scene = (_class2 = class _Scene {
|
|
|
1446
1427
|
};
|
|
1447
1428
|
el.addEventListener("pointerdown", (e) => {
|
|
1448
1429
|
if (typeof capEl.setPointerCapture === "function") capEl.setPointerCapture(e.pointerId);
|
|
1449
|
-
node.dispatchEvent(new (0,
|
|
1430
|
+
node.dispatchEvent(new (0, _chunkJ6NHSFIEjs.VectoJSEvent)("pointerdown", node, e));
|
|
1450
1431
|
});
|
|
1451
1432
|
el.addEventListener("pointerup", (e) => {
|
|
1452
1433
|
releasePointer(e);
|
|
1453
|
-
node.dispatchEvent(new (0,
|
|
1434
|
+
node.dispatchEvent(new (0, _chunkJ6NHSFIEjs.VectoJSEvent)("pointerup", node, e));
|
|
1454
1435
|
});
|
|
1455
1436
|
el.addEventListener("pointercancel", (e) => {
|
|
1456
1437
|
releasePointer(e);
|
|
1457
|
-
node.dispatchEvent(new (0,
|
|
1438
|
+
node.dispatchEvent(new (0, _chunkJ6NHSFIEjs.VectoJSEvent)("pointercancel", node, e));
|
|
1458
1439
|
});
|
|
1459
1440
|
el.addEventListener(
|
|
1460
1441
|
"pointermove",
|
|
1461
|
-
(e) => node.dispatchEvent(new (0,
|
|
1442
|
+
(e) => node.dispatchEvent(new (0, _chunkJ6NHSFIEjs.VectoJSEvent)("pointermove", node, e))
|
|
1462
1443
|
);
|
|
1463
1444
|
el.addEventListener(
|
|
1464
1445
|
"wheel",
|
|
1465
1446
|
(e) => {
|
|
1466
|
-
node.dispatchEvent(new (0,
|
|
1447
|
+
node.dispatchEvent(new (0, _chunkJ6NHSFIEjs.VectoJSEvent)("wheel", node, e));
|
|
1467
1448
|
},
|
|
1468
1449
|
{ passive: false }
|
|
1469
1450
|
);
|
|
1470
1451
|
el.addEventListener("keydown", (e) => {
|
|
1471
|
-
node.dispatchEvent(new (0,
|
|
1452
|
+
node.dispatchEvent(new (0, _chunkJ6NHSFIEjs.VectoJSEvent)("keydown", node, e));
|
|
1472
1453
|
});
|
|
1473
1454
|
el.addEventListener("keyup", (e) => {
|
|
1474
|
-
node.dispatchEvent(new (0,
|
|
1455
|
+
node.dispatchEvent(new (0, _chunkJ6NHSFIEjs.VectoJSEvent)("keyup", node, e));
|
|
1475
1456
|
});
|
|
1476
1457
|
if (el instanceof HTMLInputElement || el instanceof HTMLTextAreaElement) {
|
|
1477
1458
|
const input = el;
|
|
@@ -1531,7 +1512,7 @@ var Scene = (_class2 = class _Scene {
|
|
|
1531
1512
|
el.addEventListener("keydown", (e) => {
|
|
1532
1513
|
if (e.key === "Enter" || e.key === " ") {
|
|
1533
1514
|
e.preventDefault();
|
|
1534
|
-
node.dispatchEvent(new (0,
|
|
1515
|
+
node.dispatchEvent(new (0, _chunkJ6NHSFIEjs.VectoJSEvent)("click", node, e));
|
|
1535
1516
|
}
|
|
1536
1517
|
});
|
|
1537
1518
|
}
|
|
@@ -1755,7 +1736,7 @@ var Scene = (_class2 = class _Scene {
|
|
|
1755
1736
|
el.addEventListener(
|
|
1756
1737
|
"wheel",
|
|
1757
1738
|
(e2) => {
|
|
1758
|
-
node.dispatchEvent(new (0,
|
|
1739
|
+
node.dispatchEvent(new (0, _chunkJ6NHSFIEjs.VectoJSEvent)("wheel", node, e2));
|
|
1759
1740
|
},
|
|
1760
1741
|
{ passive: false }
|
|
1761
1742
|
);
|
|
@@ -1786,7 +1767,7 @@ var Scene = (_class2 = class _Scene {
|
|
|
1786
1767
|
lineElement.style.position = "absolute";
|
|
1787
1768
|
lineElement.dir = "auto";
|
|
1788
1769
|
lineElement.style.left = `${line.x}px`;
|
|
1789
|
-
lineElement.style.top = `${line.y + line.baseline -
|
|
1770
|
+
lineElement.style.top = `${line.y + line.baseline - _text.cssLineBoxBaseline.call(void 0, lineFont, lineHeight2)}px`;
|
|
1790
1771
|
lineElement.style.whiteSpace = "pre";
|
|
1791
1772
|
if (lineFont) lineElement.style.font = lineFont;
|
|
1792
1773
|
lineElement.style.lineHeight = `${lineHeight2}px`;
|
|
@@ -1838,7 +1819,7 @@ var Scene = (_class2 = class _Scene {
|
|
|
1838
1819
|
const { a, b, c, d, e, f } = worldTf;
|
|
1839
1820
|
const contentX = _nullishCoalesce(projection.contentX, () => ( 0));
|
|
1840
1821
|
const contentY = _nullishCoalesce(projection.contentY, () => ( 0));
|
|
1841
|
-
const baselineOffset = lines && lines.length > 0 ? 0 : projection.baseline === void 0 ? 0 : projection.baseline -
|
|
1822
|
+
const baselineOffset = lines && lines.length > 0 ? 0 : projection.baseline === void 0 ? 0 : projection.baseline - _text.cssLineBoxBaseline.call(void 0, font, _nullishCoalesce(projection.lineHeight, () => ( 16)));
|
|
1842
1823
|
const localY = contentY + baselineOffset;
|
|
1843
1824
|
el.style.left = `${e + a * contentX + c * localY}px`;
|
|
1844
1825
|
el.style.top = `${f + b * contentX + d * localY}px`;
|
|
@@ -1875,7 +1856,7 @@ var Scene = (_class2 = class _Scene {
|
|
|
1875
1856
|
lineElement.dataset.vectoGridLine = `${lineIndex}`;
|
|
1876
1857
|
lineElement.style.position = "absolute";
|
|
1877
1858
|
lineElement.style.left = `${_nullishCoalesce(_optionalChain([projectedLine, 'optionalAccess', _78 => _78.x]), () => ( 0))}px`;
|
|
1878
|
-
lineElement.style.top = `${(_nullishCoalesce(_optionalChain([projectedLine, 'optionalAccess', _79 => _79.y]), () => ( lineIndex * grid.lineHeight))) + baseline -
|
|
1859
|
+
lineElement.style.top = `${(_nullishCoalesce(_optionalChain([projectedLine, 'optionalAccess', _79 => _79.y]), () => ( lineIndex * grid.lineHeight))) + baseline - _text.cssLineBoxBaseline.call(void 0, lineFont, lineHeight)}px`;
|
|
1879
1860
|
lineElement.style.width = `${gridLine.width}px`;
|
|
1880
1861
|
lineElement.style.height = `${lineHeight}px`;
|
|
1881
1862
|
lineElement.style.whiteSpace = "pre";
|
|
@@ -2489,7 +2470,7 @@ var Scene = (_class2 = class _Scene {
|
|
|
2489
2470
|
if (!walkHadAnimation && node.hasPendingAnimations()) walkHadAnimation = true;
|
|
2490
2471
|
if (!walkHadInteractive && node.interactive) walkHadInteractive = true;
|
|
2491
2472
|
if (this._devActive && this._devFrameCount % 120 === 0) {
|
|
2492
|
-
if (node.update !==
|
|
2473
|
+
if (node.update !== _chunkJ6NHSFIEjs.Entity.prototype.update && node.hasPendingAnimations === _chunkJ6NHSFIEjs.Entity.prototype.hasPendingAnimations) {
|
|
2493
2474
|
this._devWarn(
|
|
2494
2475
|
`Entity "${node.id}" overrides update() but not hasPendingAnimations(). Custom motion in update() without overriding hasPendingAnimations() causes the idle throttle to drop the animation to ~2fps. Override hasPendingAnimations() to return true while motion is in flight.`
|
|
2495
2476
|
);
|
|
@@ -2838,12 +2819,16 @@ var Scene = (_class2 = class _Scene {
|
|
|
2838
2819
|
}, _class2.__initStatic(), _class2.__initStatic2(), _class2.__initStatic3(), _class2);
|
|
2839
2820
|
|
|
2840
2821
|
// src/components/TextEntity.ts
|
|
2822
|
+
|
|
2823
|
+
|
|
2824
|
+
|
|
2825
|
+
var _layout = require('@vectojs/layout'); _createStarExport(_layout);
|
|
2841
2826
|
var sharedMeasurer;
|
|
2842
2827
|
function defaultMeasurer() {
|
|
2843
|
-
if (sharedMeasurer === void 0) sharedMeasurer =
|
|
2828
|
+
if (sharedMeasurer === void 0) sharedMeasurer = _layout.createCanvasMeasurer.call(void 0, "sans-serif");
|
|
2844
2829
|
return sharedMeasurer;
|
|
2845
2830
|
}
|
|
2846
|
-
var TextEntity = (_class3 = class extends
|
|
2831
|
+
var TextEntity = (_class3 = class extends _chunkJ6NHSFIEjs.Entity {
|
|
2847
2832
|
|
|
2848
2833
|
|
|
2849
2834
|
|
|
@@ -2860,7 +2845,7 @@ var TextEntity = (_class3 = class extends _chunk2Z23LTH3js.Entity {
|
|
|
2860
2845
|
this.text = text;
|
|
2861
2846
|
this.atlas = atlas;
|
|
2862
2847
|
this.fontSize = fontSize;
|
|
2863
|
-
this.layout = new (0,
|
|
2848
|
+
this.layout = new (0, _layout.LayoutEngine)(maxWidth, 1e4, defaultMeasurer());
|
|
2864
2849
|
this.prepared = this.layout.prepare(this.text, this.atlas, this.fontSize);
|
|
2865
2850
|
this.applyLayout();
|
|
2866
2851
|
this.interactive = true;
|
|
@@ -2969,7 +2954,7 @@ var TextEntity = (_class3 = class extends _chunk2Z23LTH3js.Entity {
|
|
|
2969
2954
|
}, _class3);
|
|
2970
2955
|
|
|
2971
2956
|
// src/components/GridTextEntity.ts
|
|
2972
|
-
var GridTextEntity = (_class4 = class extends
|
|
2957
|
+
var GridTextEntity = (_class4 = class extends _chunkJ6NHSFIEjs.Entity {
|
|
2973
2958
|
|
|
2974
2959
|
__init77() {this.fillStyle = "#ffffff"}
|
|
2975
2960
|
__init78() {this.grid = []}
|
|
@@ -3063,7 +3048,7 @@ function distSqToSegment(px, py, x1, y1, x2, y2) {
|
|
|
3063
3048
|
const ey = py - cy;
|
|
3064
3049
|
return ex * ex + ey * ey;
|
|
3065
3050
|
}
|
|
3066
|
-
var SplineEntity = (_class5 = class extends
|
|
3051
|
+
var SplineEntity = (_class5 = class extends _chunkJ6NHSFIEjs.Entity {
|
|
3067
3052
|
|
|
3068
3053
|
|
|
3069
3054
|
|
|
@@ -3338,7 +3323,7 @@ async function loadSpline(url) {
|
|
|
3338
3323
|
}
|
|
3339
3324
|
|
|
3340
3325
|
// src/components/Rect.ts
|
|
3341
|
-
var Rect = class extends
|
|
3326
|
+
var Rect = class extends _chunkJ6NHSFIEjs.Entity {
|
|
3342
3327
|
|
|
3343
3328
|
|
|
3344
3329
|
|
|
@@ -3387,7 +3372,7 @@ var Rect = class extends _chunk2Z23LTH3js.Entity {
|
|
|
3387
3372
|
};
|
|
3388
3373
|
|
|
3389
3374
|
// src/components/Circle.ts
|
|
3390
|
-
var Circle = class extends
|
|
3375
|
+
var Circle = class extends _chunkJ6NHSFIEjs.Entity {
|
|
3391
3376
|
|
|
3392
3377
|
|
|
3393
3378
|
|
|
@@ -3447,7 +3432,7 @@ var Circle = class extends _chunk2Z23LTH3js.Entity {
|
|
|
3447
3432
|
};
|
|
3448
3433
|
|
|
3449
3434
|
// src/components/Group.ts
|
|
3450
|
-
var Group = class extends
|
|
3435
|
+
var Group = class extends _chunkJ6NHSFIEjs.Entity {
|
|
3451
3436
|
constructor(...children) {
|
|
3452
3437
|
super();
|
|
3453
3438
|
if (children.length > 0) this.add(...children);
|
|
@@ -3459,115 +3444,27 @@ var Group = class extends _chunk2Z23LTH3js.Entity {
|
|
|
3459
3444
|
}
|
|
3460
3445
|
};
|
|
3461
3446
|
|
|
3462
|
-
// src/
|
|
3463
|
-
|
|
3464
|
-
|
|
3465
|
-
|
|
3466
|
-
|
|
3467
|
-
constructor(cellSize = 64) {;_class6.prototype.__init87.call(this);_class6.prototype.__init88.call(this);
|
|
3468
|
-
this.cellSize = cellSize;
|
|
3469
|
-
}
|
|
3470
|
-
hash(cx, cy) {
|
|
3471
|
-
const x = cx < 0 ? -2 * cx - 1 : 2 * cx;
|
|
3472
|
-
const y = cy < 0 ? -2 * cy - 1 : 2 * cy;
|
|
3473
|
-
return (x + y) * (x + y + 1) / 2 + y;
|
|
3474
|
-
}
|
|
3475
|
-
cellsForAABB(x, y, w, h) {
|
|
3476
|
-
const minCx = Math.floor(x / this.cellSize);
|
|
3477
|
-
const minCy = Math.floor(y / this.cellSize);
|
|
3478
|
-
const maxCx = Math.floor((x + w) / this.cellSize);
|
|
3479
|
-
const maxCy = Math.floor((y + h) / this.cellSize);
|
|
3480
|
-
const keys = [];
|
|
3481
|
-
for (let cx = minCx; cx <= maxCx; cx++) {
|
|
3482
|
-
for (let cy = minCy; cy <= maxCy; cy++) {
|
|
3483
|
-
keys.push(this.hash(cx, cy));
|
|
3484
|
-
}
|
|
3485
|
-
}
|
|
3486
|
-
return keys;
|
|
3487
|
-
}
|
|
3488
|
-
/**
|
|
3489
|
-
* Insert or update an entity's axis-aligned bounding box in the grid.
|
|
3490
|
-
*
|
|
3491
|
-
* If the entity is already registered its old cell memberships are removed
|
|
3492
|
-
* before the new ones are computed, so this method is safe to call every
|
|
3493
|
-
* frame.
|
|
3494
|
-
*
|
|
3495
|
-
* @param id - Unique string identifier for the entity.
|
|
3496
|
-
* @param x - Left edge of the AABB in world space.
|
|
3497
|
-
* @param y - Top edge of the AABB in world space.
|
|
3498
|
-
* @param w - Width of the AABB.
|
|
3499
|
-
* @param h - Height of the AABB.
|
|
3500
|
-
*/
|
|
3501
|
-
insert(id, x, y, w, h) {
|
|
3502
|
-
this.remove(id);
|
|
3503
|
-
const keys = this.cellsForAABB(x, y, w, h);
|
|
3504
|
-
this.entityCells.set(id, keys);
|
|
3505
|
-
for (const key of keys) {
|
|
3506
|
-
if (!this.grid.has(key)) this.grid.set(key, /* @__PURE__ */ new Set());
|
|
3507
|
-
this.grid.get(key).add(id);
|
|
3508
|
-
}
|
|
3509
|
-
}
|
|
3510
|
-
/**
|
|
3511
|
-
* Remove an entity from all grid cells it currently occupies.
|
|
3512
|
-
*
|
|
3513
|
-
* Silently does nothing if the entity is not registered.
|
|
3514
|
-
*
|
|
3515
|
-
* @param id - Unique string identifier of the entity to remove.
|
|
3516
|
-
*/
|
|
3517
|
-
remove(id) {
|
|
3518
|
-
const keys = this.entityCells.get(id);
|
|
3519
|
-
if (!keys) return;
|
|
3520
|
-
for (const key of keys) {
|
|
3521
|
-
_optionalChain([this, 'access', _119 => _119.grid, 'access', _120 => _120.get, 'call', _121 => _121(key), 'optionalAccess', _122 => _122.delete, 'call', _123 => _123(id)]);
|
|
3522
|
-
}
|
|
3523
|
-
this.entityCells.delete(id);
|
|
3524
|
-
}
|
|
3525
|
-
/**
|
|
3526
|
-
* Return all entity IDs whose grid cells overlap the given AABB.
|
|
3527
|
-
*
|
|
3528
|
-
* Time complexity: O(k) where k is the number of cells the query AABB spans
|
|
3529
|
-
* plus the number of results — O(1) average for small, similarly-sized entities.
|
|
3530
|
-
*
|
|
3531
|
-
* @param x - Left edge of the query AABB.
|
|
3532
|
-
* @param y - Top edge of the query AABB.
|
|
3533
|
-
* @param w - Width of the query AABB.
|
|
3534
|
-
* @param h - Height of the query AABB.
|
|
3535
|
-
* @returns A `Set` of entity ID strings whose cells intersect the query region.
|
|
3536
|
-
*/
|
|
3537
|
-
query(x, y, w, h) {
|
|
3538
|
-
const result = /* @__PURE__ */ new Set();
|
|
3539
|
-
for (const key of this.cellsForAABB(x, y, w, h)) {
|
|
3540
|
-
const cell = this.grid.get(key);
|
|
3541
|
-
if (cell) for (const id of cell) result.add(id);
|
|
3542
|
-
}
|
|
3543
|
-
return result;
|
|
3544
|
-
}
|
|
3545
|
-
/**
|
|
3546
|
-
* Clear all cells and entity registrations, resetting the grid to an empty state.
|
|
3547
|
-
*
|
|
3548
|
-
* Call once per frame before re-inserting all dynamic entities.
|
|
3549
|
-
*/
|
|
3550
|
-
clear() {
|
|
3551
|
-
this.grid.clear();
|
|
3552
|
-
this.entityCells.clear();
|
|
3553
|
-
}
|
|
3554
|
-
}, _class6);
|
|
3447
|
+
// src/index.ts
|
|
3448
|
+
|
|
3449
|
+
|
|
3450
|
+
var _math = require('@vectojs/math'); _createStarExport(_math);
|
|
3451
|
+
var _animation = require('@vectojs/animation'); _createStarExport(_animation);
|
|
3555
3452
|
|
|
3556
3453
|
// src/tree/DOMPortalEntity.ts
|
|
3557
|
-
var DOMPortalEntity = (
|
|
3454
|
+
var DOMPortalEntity = (_class6 = class extends _chunkJ6NHSFIEjs.Entity {
|
|
3558
3455
|
|
|
3559
|
-
|
|
3560
|
-
|
|
3561
|
-
|
|
3562
|
-
|
|
3563
|
-
|
|
3564
|
-
|
|
3565
|
-
|
|
3566
|
-
|
|
3567
|
-
|
|
3568
|
-
|
|
3456
|
+
__init87() {this.isDOMPortal = true}
|
|
3457
|
+
__init88() {this.domListeners = []}
|
|
3458
|
+
__init89() {this.resizeObserver = null}
|
|
3459
|
+
__init90() {this.cachedWidth = 100}
|
|
3460
|
+
__init91() {this.cachedHeight = 100}
|
|
3461
|
+
__init92() {this.lastWidth = ""}
|
|
3462
|
+
__init93() {this.lastHeight = ""}
|
|
3463
|
+
__init94() {this.lastTransform = ""}
|
|
3464
|
+
__init95() {this.lastZIndex = ""}
|
|
3465
|
+
__init96() {this.lastOpacity = ""}
|
|
3569
3466
|
constructor(domElement, width, height, id) {
|
|
3570
|
-
super(id);
|
|
3467
|
+
super(id);_class6.prototype.__init87.call(this);_class6.prototype.__init88.call(this);_class6.prototype.__init89.call(this);_class6.prototype.__init90.call(this);_class6.prototype.__init91.call(this);_class6.prototype.__init92.call(this);_class6.prototype.__init93.call(this);_class6.prototype.__init94.call(this);_class6.prototype.__init95.call(this);_class6.prototype.__init96.call(this);;
|
|
3571
3468
|
this.domElement = domElement;
|
|
3572
3469
|
this.width = _nullishCoalesce(width, () => ( 0));
|
|
3573
3470
|
this.height = _nullishCoalesce(height, () => ( 0));
|
|
@@ -3596,7 +3493,7 @@ var DOMPortalEntity = (_class7 = class extends _chunk2Z23LTH3js.Entity {
|
|
|
3596
3493
|
];
|
|
3597
3494
|
for (const type of events) {
|
|
3598
3495
|
const handler = (e) => {
|
|
3599
|
-
this.dispatchEvent(new (0,
|
|
3496
|
+
this.dispatchEvent(new (0, _chunkJ6NHSFIEjs.VectoJSEvent)(type, this, e));
|
|
3600
3497
|
};
|
|
3601
3498
|
this.domElement.addEventListener(type, handler);
|
|
3602
3499
|
this.domListeners.push({ type, handler, capture: false });
|
|
@@ -3607,7 +3504,7 @@ var DOMPortalEntity = (_class7 = class extends _chunk2Z23LTH3js.Entity {
|
|
|
3607
3504
|
];
|
|
3608
3505
|
for (const { native, vecto } of hoverEvents) {
|
|
3609
3506
|
const handler = (e) => {
|
|
3610
|
-
this.dispatchEvent(new (0,
|
|
3507
|
+
this.dispatchEvent(new (0, _chunkJ6NHSFIEjs.VectoJSEvent)(vecto, this, e, false));
|
|
3611
3508
|
};
|
|
3612
3509
|
this.domElement.addEventListener(native, handler);
|
|
3613
3510
|
this.domListeners.push({ type: native, handler, capture: false });
|
|
@@ -3615,7 +3512,7 @@ var DOMPortalEntity = (_class7 = class extends _chunk2Z23LTH3js.Entity {
|
|
|
3615
3512
|
const focusEvents = ["focus", "blur"];
|
|
3616
3513
|
for (const type of focusEvents) {
|
|
3617
3514
|
const handler = (e) => {
|
|
3618
|
-
this.dispatchEvent(new (0,
|
|
3515
|
+
this.dispatchEvent(new (0, _chunkJ6NHSFIEjs.VectoJSEvent)(type, this, e, true));
|
|
3619
3516
|
};
|
|
3620
3517
|
this.domElement.addEventListener(type, handler, true);
|
|
3621
3518
|
this.domListeners.push({ type, handler, capture: true });
|
|
@@ -3651,7 +3548,7 @@ var DOMPortalEntity = (_class7 = class extends _chunk2Z23LTH3js.Entity {
|
|
|
3651
3548
|
}
|
|
3652
3549
|
super.destroy();
|
|
3653
3550
|
}
|
|
3654
|
-
},
|
|
3551
|
+
}, _class6);
|
|
3655
3552
|
|
|
3656
3553
|
// src/index.ts
|
|
3657
3554
|
Scene.registerWebGLPointRendererCreator(_chunkBEUIB3U7js.createWebGLPointRenderer);
|
|
@@ -3690,21 +3587,4 @@ Scene.registerWebGPUParticleSystemManager(_chunkBEUIB3U7js.WebGPUParticleSystemM
|
|
|
3690
3587
|
|
|
3691
3588
|
|
|
3692
3589
|
|
|
3693
|
-
|
|
3694
|
-
|
|
3695
|
-
|
|
3696
|
-
|
|
3697
|
-
|
|
3698
|
-
|
|
3699
|
-
|
|
3700
|
-
|
|
3701
|
-
|
|
3702
|
-
|
|
3703
|
-
|
|
3704
|
-
|
|
3705
|
-
|
|
3706
|
-
|
|
3707
|
-
|
|
3708
|
-
|
|
3709
|
-
|
|
3710
|
-
exports.ArabicShaper = _chunk4AR425ARjs.ArabicShaper; exports.BidiResolver = _chunk4AR425ARjs.BidiResolver; exports.CanvasRenderer = _chunkBEUIB3U7js.CanvasRenderer; exports.Circle = Circle; exports.ComputeParticleEntity = ComputeParticleEntity; exports.DOMPortalEntity = DOMPortalEntity; exports.Easing = _chunk2Z23LTH3js.Easing; exports.Entity = _chunk2Z23LTH3js.Entity; exports.GridTextEntity = GridTextEntity; exports.Group = Group; exports.LayoutEngine = _chunkBA5HUUDFjs.LayoutEngine; exports.LayoutResultBuffer = _chunkBA5HUUDFjs.LayoutResultBuffer; exports.LayoutWorkerManager = _chunk4AR425ARjs.LayoutWorkerManager; exports.MSDFFont = _chunk2Z23LTH3js.MSDFFont; exports.MSDFTextEntity = _chunk2Z23LTH3js.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.Rect = Rect; exports.SVGEntity = _chunk2Z23LTH3js.SVGEntity; exports.SVGRenderer = _chunkBEUIB3U7js.SVGRenderer; exports.Scene = Scene; exports.SpatialHashGrid = SpatialHashGrid; exports.SplineEntity = SplineEntity; exports.SpringDriver = _chunk2Z23LTH3js.SpringDriver; exports.SpringPhysics = _chunk2Z23LTH3js.SpringPhysics; exports.TextEntity = TextEntity; exports.TextRasterCache = _chunkBEUIB3U7js.TextRasterCache; exports.TweenDriver = _chunk2Z23LTH3js.TweenDriver; exports.VectoJSEvent = _chunk2Z23LTH3js.VectoJSEvent; exports.WebGPUParticleSystemManager = _chunkBEUIB3U7js.WebGPUParticleSystemManager; exports.clearCssLineBoxMetrics = _chunk2Z23LTH3js.clearCssLineBoxMetrics; exports.computeLineSegments = _chunkBA5HUUDFjs.computeLineSegments; exports.createCanvasMeasurer = _chunkBA5HUUDFjs.createCanvasMeasurer; exports.createWebGLPointRenderer = _chunkBEUIB3U7js.createWebGLPointRenderer; exports.cssLineBoxBaseline = _chunk2Z23LTH3js.cssLineBoxBaseline; exports.isSafeUrl = _chunkBEUIB3U7js.isSafeUrl; exports.isTweenConfig = _chunk2Z23LTH3js.isTweenConfig; exports.loadSpline = loadSpline; exports.parseColorToRGBA = _chunkBEUIB3U7js.parseColorToRGBA; exports.polySegmentToBezier = polySegmentToBezier; exports.prepareContentGrid = _chunk2Z23LTH3js.prepareContentGrid; exports.sanitizeUrl = _chunkBEUIB3U7js.sanitizeUrl;
|
|
3590
|
+
exports.CanvasRenderer = _chunkBEUIB3U7js.CanvasRenderer; exports.Circle = Circle; exports.ComputeParticleEntity = ComputeParticleEntity; exports.DOMPortalEntity = DOMPortalEntity; exports.Entity = _chunkJ6NHSFIEjs.Entity; exports.GridTextEntity = GridTextEntity; exports.Group = Group; exports.MSDFTextEntity = _chunkJ6NHSFIEjs.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.Rect = Rect; exports.SVGEntity = _chunkJ6NHSFIEjs.SVGEntity; exports.SVGRenderer = _chunkBEUIB3U7js.SVGRenderer; exports.Scene = Scene; exports.SplineEntity = SplineEntity; exports.TextEntity = TextEntity; exports.TextRasterCache = _chunkBEUIB3U7js.TextRasterCache; exports.VectoJSEvent = _chunkJ6NHSFIEjs.VectoJSEvent; exports.WebGPUParticleSystemManager = _chunkBEUIB3U7js.WebGPUParticleSystemManager; exports.createWebGLPointRenderer = _chunkBEUIB3U7js.createWebGLPointRenderer; exports.isSafeUrl = _chunkBEUIB3U7js.isSafeUrl; exports.loadSpline = loadSpline; exports.parseColorToRGBA = _chunkBEUIB3U7js.parseColorToRGBA; exports.polySegmentToBezier = polySegmentToBezier; exports.sanitizeUrl = _chunkBEUIB3U7js.sanitizeUrl;
|