@vectojs/core 0.2.6 → 0.2.8
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-SSOP3F5F.mjs → chunk-FNXOS7IA.mjs} +161 -15
- package/dist/{chunk-SL654OMF.mjs → chunk-G6GQO7W2.mjs} +26 -0
- package/dist/{chunk-GADBN53Z.js → chunk-XB3ZY5MF.js} +82 -1
- package/dist/{chunk-BWLNEJJW.js → chunk-XLZDOFSB.js} +175 -29
- package/dist/{chunk-4BO5XBJL.js → chunk-XRWZS2DM.js} +34 -8
- package/dist/{chunk-PK5EYWIT.mjs → chunk-YBW7ECZP.mjs} +82 -1
- package/dist/components/TextEntity.d.ts +17 -1
- package/dist/index.js +288 -143
- package/dist/index.mjs +171 -26
- package/dist/layout/LayoutEngine.d.ts +24 -0
- package/dist/layout.js +2 -2
- package/dist/layout.mjs +1 -1
- package/dist/renderer.js +2 -2
- package/dist/renderer.mjs +1 -1
- package/dist/text/MSDFTextEntity.d.ts +6 -1
- package/dist/text.js +2 -2
- package/dist/text.mjs +1 -1
- package/dist/tree/Entity.d.ts +31 -0
- package/dist/tree/Scene.d.ts +29 -2
- package/package.json +5 -3
package/dist/index.js
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
|
|
4
4
|
|
|
5
5
|
|
|
6
|
-
var
|
|
6
|
+
var _chunkXLZDOFSBjs = require('./chunk-XLZDOFSB.js');
|
|
7
7
|
|
|
8
8
|
|
|
9
9
|
|
|
@@ -12,7 +12,7 @@ var _chunkBWLNEJJWjs = require('./chunk-BWLNEJJW.js');
|
|
|
12
12
|
|
|
13
13
|
|
|
14
14
|
|
|
15
|
-
var
|
|
15
|
+
var _chunkXB3ZY5MFjs = require('./chunk-XB3ZY5MF.js');
|
|
16
16
|
|
|
17
17
|
|
|
18
18
|
|
|
@@ -24,7 +24,7 @@ var _chunkGADBN53Zjs = require('./chunk-GADBN53Z.js');
|
|
|
24
24
|
|
|
25
25
|
|
|
26
26
|
|
|
27
|
-
var
|
|
27
|
+
var _chunkXRWZS2DMjs = require('./chunk-XRWZS2DM.js');
|
|
28
28
|
|
|
29
29
|
|
|
30
30
|
|
|
@@ -41,7 +41,7 @@ var PARTICLE_OFFSET_ORIGIN_X = 4;
|
|
|
41
41
|
var PARTICLE_OFFSET_ORIGIN_Y = 5;
|
|
42
42
|
var PARTICLE_OFFSET_SIZE = 6;
|
|
43
43
|
var PARTICLE_OFFSET_LIFE = 7;
|
|
44
|
-
var ComputeParticleEntity = (_class = class extends
|
|
44
|
+
var ComputeParticleEntity = (_class = class extends _chunkXRWZS2DMjs.Entity {
|
|
45
45
|
|
|
46
46
|
|
|
47
47
|
|
|
@@ -296,6 +296,11 @@ var ComputeParticleEntity = (_class = class extends _chunk4BO5XBJLjs.Entity {
|
|
|
296
296
|
|
|
297
297
|
// src/tree/Scene.ts
|
|
298
298
|
var REDUCED_MOTION_FPS = 30;
|
|
299
|
+
function parseInlinePx(value) {
|
|
300
|
+
if (!value || !value.endsWith("px")) return null;
|
|
301
|
+
const n = parseFloat(value);
|
|
302
|
+
return Number.isFinite(n) && n > 0 ? n : null;
|
|
303
|
+
}
|
|
299
304
|
var Scene = (_class2 = class _Scene {
|
|
300
305
|
static __initStatic() {this.webglCreator = null}
|
|
301
306
|
static __initStatic2() {this.webgpuManagerClass = null}
|
|
@@ -350,69 +355,80 @@ var Scene = (_class2 = class _Scene {
|
|
|
350
355
|
// server-side (e.g. headless layout / vector export) without jsdom.
|
|
351
356
|
|
|
352
357
|
__init18() {this.a11yElements = /* @__PURE__ */ new Map()}
|
|
358
|
+
/** DOM nodes mirroring static text content, keyed by entity id. */
|
|
359
|
+
__init19() {this.contentElements = /* @__PURE__ */ new Map()}
|
|
360
|
+
__init20() {this.contentProjectionEnabled = true}
|
|
361
|
+
// Animation/interactive flags collected during the render walk (tree-walk
|
|
362
|
+
// fusion): the loop reads last frame's answers instead of re-walking the
|
|
363
|
+
// tree up to 4× per tick. Start true so the first tick stays conservative.
|
|
364
|
+
__init21() {this.frameHadAnimation = true}
|
|
365
|
+
__init22() {this.frameHadInteractive = true}
|
|
353
366
|
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
367
|
+
__init23() {this.focusedA11yElement = null}
|
|
368
|
+
__init24() {this.caretBlinkTimer = null}
|
|
369
|
+
__init25() {this.a11yNeedsReorder = true}
|
|
370
|
+
__init26() {this.portalRoot = null}
|
|
371
|
+
__init27() {this.fullViewportElements = []}
|
|
372
|
+
__init28() {this.normalElements = []}
|
|
373
|
+
__init29() {this.activeIds = /* @__PURE__ */ new Set()}
|
|
374
|
+
__init30() {this.activePortalsThisFrame = /* @__PURE__ */ new Set()}
|
|
375
|
+
__init31() {this.activePortalsPrevFrame = /* @__PURE__ */ new Set()}
|
|
376
|
+
__init32() {this.portalEntities = /* @__PURE__ */ new Map()}
|
|
377
|
+
__init33() {this.renderOrderCounter = 0}
|
|
365
378
|
// Optional WebGL point-cloud layer (see SceneOptions.pointBackend).
|
|
366
|
-
|
|
367
|
-
|
|
379
|
+
__init34() {this.pointRenderer = null}
|
|
380
|
+
__init35() {this.glCanvas = null}
|
|
368
381
|
|
|
369
382
|
|
|
370
383
|
|
|
371
|
-
|
|
384
|
+
__init36() {this.disableWindowResize = false}
|
|
372
385
|
// WebGPU properties
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
386
|
+
__init37() {this.destroyed = false}
|
|
387
|
+
__init38() {this.device = null}
|
|
388
|
+
__init39() {this.deviceLost = false}
|
|
389
|
+
__init40() {this.particleBackend = "auto"}
|
|
390
|
+
__init41() {this._webgpuDisabled = false}
|
|
378
391
|
get webgpuDisabled() {
|
|
379
392
|
return this._webgpuDisabled || this.particleBackend === "cpu";
|
|
380
393
|
}
|
|
381
394
|
set webgpuDisabled(value) {
|
|
382
395
|
this._webgpuDisabled = value;
|
|
383
396
|
}
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
397
|
+
__init42() {this.recoveryTimerId = null}
|
|
398
|
+
__init43() {this.manager = null}
|
|
399
|
+
__init44() {this.initializingWebGPU = false}
|
|
400
|
+
__init45() {this.gpuCanvas = null}
|
|
401
|
+
__init46() {this.gpuContext = null}
|
|
389
402
|
/** True while the GPU canvas holds a presented particle frame (needs clearing when they leave). */
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
constructor(canvas, options = {}) {;_class2.prototype.__init7.call(this);_class2.prototype.__init8.call(this);_class2.prototype.__init9.call(this);_class2.prototype.__init10.call(this);_class2.prototype.__init11.call(this);_class2.prototype.__init12.call(this);_class2.prototype.__init13.call(this);_class2.prototype.__init14.call(this);_class2.prototype.__init15.call(this);_class2.prototype.__init16.call(this);_class2.prototype.__init17.call(this);_class2.prototype.__init18.call(this);_class2.prototype.__init19.call(this);_class2.prototype.__init20.call(this);_class2.prototype.__init21.call(this);_class2.prototype.__init22.call(this);_class2.prototype.__init23.call(this);_class2.prototype.__init24.call(this);_class2.prototype.__init25.call(this);_class2.prototype.__init26.call(this);_class2.prototype.__init27.call(this);_class2.prototype.__init28.call(this);_class2.prototype.__init29.call(this);_class2.prototype.__init30.call(this);_class2.prototype.__init31.call(this);_class2.prototype.__init32.call(this);_class2.prototype.__init33.call(this);_class2.prototype.__init34.call(this);_class2.prototype.__init35.call(this);_class2.prototype.__init36.call(this);_class2.prototype.__init37.call(this);_class2.prototype.__init38.call(this);_class2.prototype.__init39.call(this);_class2.prototype.__init40.call(this);_class2.prototype.__init41.call(this);_class2.prototype.__init42.call(this);_class2.prototype.__init43.call(this);_class2.prototype.__init44.call(this);_class2.prototype.__init45.call(this);_class2.prototype.__init46.call(this);_class2.prototype.__init47.call(this);_class2.prototype.__init48.call(this);
|
|
403
|
+
__init47() {this.gpuHasContent = false}
|
|
404
|
+
__init48() {this.mouseX = -9999}
|
|
405
|
+
__init49() {this.mouseY = -9999}
|
|
406
|
+
__init50() {this.pointerMoveListener = null}
|
|
407
|
+
__init51() {this.pointerLeaveListener = null}
|
|
408
|
+
__init52() {this.hasWarnedZeroSize = false}
|
|
409
|
+
constructor(canvas, options = {}) {;_class2.prototype.__init7.call(this);_class2.prototype.__init8.call(this);_class2.prototype.__init9.call(this);_class2.prototype.__init10.call(this);_class2.prototype.__init11.call(this);_class2.prototype.__init12.call(this);_class2.prototype.__init13.call(this);_class2.prototype.__init14.call(this);_class2.prototype.__init15.call(this);_class2.prototype.__init16.call(this);_class2.prototype.__init17.call(this);_class2.prototype.__init18.call(this);_class2.prototype.__init19.call(this);_class2.prototype.__init20.call(this);_class2.prototype.__init21.call(this);_class2.prototype.__init22.call(this);_class2.prototype.__init23.call(this);_class2.prototype.__init24.call(this);_class2.prototype.__init25.call(this);_class2.prototype.__init26.call(this);_class2.prototype.__init27.call(this);_class2.prototype.__init28.call(this);_class2.prototype.__init29.call(this);_class2.prototype.__init30.call(this);_class2.prototype.__init31.call(this);_class2.prototype.__init32.call(this);_class2.prototype.__init33.call(this);_class2.prototype.__init34.call(this);_class2.prototype.__init35.call(this);_class2.prototype.__init36.call(this);_class2.prototype.__init37.call(this);_class2.prototype.__init38.call(this);_class2.prototype.__init39.call(this);_class2.prototype.__init40.call(this);_class2.prototype.__init41.call(this);_class2.prototype.__init42.call(this);_class2.prototype.__init43.call(this);_class2.prototype.__init44.call(this);_class2.prototype.__init45.call(this);_class2.prototype.__init46.call(this);_class2.prototype.__init47.call(this);_class2.prototype.__init48.call(this);_class2.prototype.__init49.call(this);_class2.prototype.__init50.call(this);_class2.prototype.__init51.call(this);_class2.prototype.__init52.call(this);
|
|
397
410
|
this.canvas = canvas;
|
|
398
411
|
this.debugA11y = _nullishCoalesce(options.debugA11y, () => ( false));
|
|
399
412
|
this.disableWindowResize = _nullishCoalesce(options.disableWindowResize, () => ( false));
|
|
400
413
|
if (this.disableWindowResize) {
|
|
401
|
-
|
|
402
|
-
|
|
414
|
+
const styleWidth = parseInlinePx(_optionalChain([canvas, 'access', _15 => _15.style, 'optionalAccess', _16 => _16.width]));
|
|
415
|
+
const styleHeight = parseInlinePx(_optionalChain([canvas, 'access', _17 => _17.style, 'optionalAccess', _18 => _18.height]));
|
|
416
|
+
this.width = _nullishCoalesce(styleWidth, () => ( (canvas.width || canvas.clientWidth || 0)));
|
|
417
|
+
this.height = _nullishCoalesce(styleHeight, () => ( (canvas.height || canvas.clientHeight || 0)));
|
|
403
418
|
} else {
|
|
404
419
|
this.width = typeof window !== "undefined" ? window.innerWidth : canvas.clientWidth || canvas.width || 800;
|
|
405
420
|
this.height = typeof window !== "undefined" ? window.innerHeight : canvas.clientHeight || canvas.height || 600;
|
|
406
421
|
}
|
|
407
422
|
const globalProcess = typeof globalThis !== "undefined" ? globalThis.process : void 0;
|
|
408
|
-
const isTest = globalProcess && (_optionalChain([globalProcess, 'access',
|
|
423
|
+
const isTest = globalProcess && (_optionalChain([globalProcess, 'access', _19 => _19.env, 'optionalAccess', _20 => _20.NODE_ENV]) === "test" || _optionalChain([globalProcess, 'access', _21 => _21.env, 'optionalAccess', _22 => _22.VITEST]) === "true");
|
|
409
424
|
this.maxFPS = _nullishCoalesce(options.maxFPS, () => ( (isTest ? 0 : 60)));
|
|
410
425
|
this.respectReducedMotion = _nullishCoalesce(options.respectReducedMotion, () => ( true));
|
|
411
426
|
this.autoThrottle = _nullishCoalesce(options.autoThrottle, () => ( true));
|
|
412
427
|
this.particleBackend = _nullishCoalesce(options.particleBackend, () => ( "auto"));
|
|
413
428
|
this.a11ySyncInterval = _nullishCoalesce(options.a11ySyncInterval, () => ( 0));
|
|
429
|
+
this.contentProjectionEnabled = _nullishCoalesce(options.contentProjection, () => ( true));
|
|
414
430
|
this.reducedMotionQuery = typeof window !== "undefined" && typeof window.matchMedia === "function" ? window.matchMedia("(prefers-reduced-motion: reduce)") : null;
|
|
415
|
-
this.root = new class RootEntity extends
|
|
431
|
+
this.root = new class RootEntity extends _chunkXRWZS2DMjs.Entity {
|
|
416
432
|
isPointInside() {
|
|
417
433
|
return false;
|
|
418
434
|
}
|
|
@@ -421,7 +437,7 @@ var Scene = (_class2 = class _Scene {
|
|
|
421
437
|
}
|
|
422
438
|
}("root");
|
|
423
439
|
this.root._scene = this;
|
|
424
|
-
this.overlayRoot = new class OverlayRoot extends
|
|
440
|
+
this.overlayRoot = new class OverlayRoot extends _chunkXRWZS2DMjs.Entity {
|
|
425
441
|
isPointInside() {
|
|
426
442
|
return false;
|
|
427
443
|
}
|
|
@@ -432,7 +448,7 @@ var Scene = (_class2 = class _Scene {
|
|
|
432
448
|
if (options.renderer) {
|
|
433
449
|
this.renderer = options.renderer;
|
|
434
450
|
} else {
|
|
435
|
-
this.renderer = new (0,
|
|
451
|
+
this.renderer = new (0, _chunkXB3ZY5MFjs.CanvasRenderer)(
|
|
436
452
|
canvas,
|
|
437
453
|
this.disableWindowResize ? { width: this.width, height: this.height } : void 0
|
|
438
454
|
);
|
|
@@ -498,7 +514,7 @@ var Scene = (_class2 = class _Scene {
|
|
|
498
514
|
}
|
|
499
515
|
/** Convert browser viewport coordinates into this Scene's logical coordinates. */
|
|
500
516
|
clientToScene(clientX, clientY) {
|
|
501
|
-
const rect = _optionalChain([this, 'access',
|
|
517
|
+
const rect = _optionalChain([this, 'access', _23 => _23.canvas, 'access', _24 => _24.getBoundingClientRect, 'optionalCall', _25 => _25()]);
|
|
502
518
|
if (!rect) return { x: clientX, y: clientY };
|
|
503
519
|
const cssWidth = rect.width || this.canvas.clientWidth || this.width;
|
|
504
520
|
const cssHeight = rect.height || this.canvas.clientHeight || this.height;
|
|
@@ -564,6 +580,11 @@ var Scene = (_class2 = class _Scene {
|
|
|
564
580
|
* @param entity - The subtree whose shadow nodes should be removed.
|
|
565
581
|
*/
|
|
566
582
|
detachA11y(entity) {
|
|
583
|
+
const contentEl = this.contentElements.get(entity.id);
|
|
584
|
+
if (contentEl) {
|
|
585
|
+
contentEl.remove();
|
|
586
|
+
this.contentElements.delete(entity.id);
|
|
587
|
+
}
|
|
567
588
|
this.removeA11yRecursively(entity);
|
|
568
589
|
}
|
|
569
590
|
/**
|
|
@@ -607,13 +628,15 @@ var Scene = (_class2 = class _Scene {
|
|
|
607
628
|
this.canvas.removeEventListener("pointerleave", this.pointerLeaveListener);
|
|
608
629
|
}
|
|
609
630
|
}
|
|
610
|
-
_optionalChain([this, 'access',
|
|
611
|
-
_optionalChain([this, 'access',
|
|
631
|
+
_optionalChain([this, 'access', _26 => _26.a11yRoot, 'optionalAccess', _27 => _27.remove, 'call', _28 => _28()]);
|
|
632
|
+
_optionalChain([this, 'access', _29 => _29.portalRoot, 'optionalAccess', _30 => _30.remove, 'call', _31 => _31()]);
|
|
612
633
|
this.a11yElements.clear();
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
_optionalChain([this, 'access',
|
|
616
|
-
_optionalChain([this, 'access',
|
|
634
|
+
for (const el of this.contentElements.values()) el.remove();
|
|
635
|
+
this.contentElements.clear();
|
|
636
|
+
_optionalChain([this, 'access', _32 => _32.pointRenderer, 'optionalAccess', _33 => _33.destroy, 'call', _34 => _34()]);
|
|
637
|
+
_optionalChain([this, 'access', _35 => _35.renderer, 'access', _36 => _36.dispose, 'optionalCall', _37 => _37()]);
|
|
638
|
+
_optionalChain([this, 'access', _38 => _38.glCanvas, 'optionalAccess', _39 => _39.remove, 'call', _40 => _40()]);
|
|
639
|
+
_optionalChain([this, 'access', _41 => _41.gpuCanvas, 'optionalAccess', _42 => _42.remove, 'call', _43 => _43()]);
|
|
617
640
|
this.gpuCanvas = null;
|
|
618
641
|
this.gpuContext = null;
|
|
619
642
|
if (this.recoveryTimerId) {
|
|
@@ -625,7 +648,7 @@ var Scene = (_class2 = class _Scene {
|
|
|
625
648
|
this.manager = null;
|
|
626
649
|
}
|
|
627
650
|
if (this.device) {
|
|
628
|
-
_optionalChain([this, 'access',
|
|
651
|
+
_optionalChain([this, 'access', _44 => _44.device, 'access', _45 => _45.destroy, 'optionalCall', _46 => _46()]);
|
|
629
652
|
this.device = null;
|
|
630
653
|
}
|
|
631
654
|
}
|
|
@@ -693,6 +716,18 @@ var Scene = (_class2 = class _Scene {
|
|
|
693
716
|
* Essential for deterministic rendering (e.g. video export).
|
|
694
717
|
* Note: You should call `scene.stop()` before using this to avoid conflict with the rAF loop.
|
|
695
718
|
*/
|
|
719
|
+
/**
|
|
720
|
+
* The scene-graph root entity. Exposed read-only for tooling — the devtools
|
|
721
|
+
* inspector walks it to build the Virtual Math Tree view. Mutate the graph
|
|
722
|
+
* through {@link add}/{@link remove}, not by editing this node directly.
|
|
723
|
+
*/
|
|
724
|
+
get rootEntity() {
|
|
725
|
+
return this.root;
|
|
726
|
+
}
|
|
727
|
+
/** The overlay layer root (see {@link showOverlay}), read-only for tooling. */
|
|
728
|
+
get overlayRootEntity() {
|
|
729
|
+
return this.overlayRoot;
|
|
730
|
+
}
|
|
696
731
|
step(dt) {
|
|
697
732
|
const time = this.lastTime + dt;
|
|
698
733
|
this.lastTime = time;
|
|
@@ -709,21 +744,7 @@ var Scene = (_class2 = class _Scene {
|
|
|
709
744
|
this.dirty = true;
|
|
710
745
|
}
|
|
711
746
|
/** True when any node in the subtree has a pending animation. */
|
|
712
|
-
hasAnyPendingAnimation(node) {
|
|
713
|
-
if (node.hasPendingAnimations()) return true;
|
|
714
|
-
for (const child of node.children) {
|
|
715
|
-
if (this.hasAnyPendingAnimation(child)) return true;
|
|
716
|
-
}
|
|
717
|
-
return false;
|
|
718
|
-
}
|
|
719
747
|
/** True when any node in the subtree is interactive (drives a11y sync). */
|
|
720
|
-
hasAnyInteractive(node) {
|
|
721
|
-
if (node.interactive) return true;
|
|
722
|
-
for (const child of node.children) {
|
|
723
|
-
if (this.hasAnyInteractive(child)) return true;
|
|
724
|
-
}
|
|
725
|
-
return false;
|
|
726
|
-
}
|
|
727
748
|
syncA11y(node) {
|
|
728
749
|
if (!this.a11yRoot) return;
|
|
729
750
|
if (node.isDOMPortal) {
|
|
@@ -769,42 +790,42 @@ var Scene = (_class2 = class _Scene {
|
|
|
769
790
|
el.style.background = "transparent";
|
|
770
791
|
}
|
|
771
792
|
el.addEventListener("click", (e) => {
|
|
772
|
-
node.dispatchEvent(new (0,
|
|
793
|
+
node.dispatchEvent(new (0, _chunkXRWZS2DMjs.VectoJSEvent)("click", node, e));
|
|
773
794
|
});
|
|
774
795
|
el.addEventListener("mouseenter", (e) => {
|
|
775
796
|
if (this.debugA11y) el.style.backgroundColor = "rgba(56, 189, 248, 0.2)";
|
|
776
|
-
node.dispatchEvent(new (0,
|
|
797
|
+
node.dispatchEvent(new (0, _chunkXRWZS2DMjs.VectoJSEvent)("hover", node, e, false));
|
|
777
798
|
});
|
|
778
799
|
el.addEventListener("mouseleave", (e) => {
|
|
779
800
|
if (this.debugA11y) el.style.backgroundColor = "rgba(56, 189, 248, 0.05)";
|
|
780
|
-
node.dispatchEvent(new (0,
|
|
801
|
+
node.dispatchEvent(new (0, _chunkXRWZS2DMjs.VectoJSEvent)("pointerleave", node, e, false));
|
|
781
802
|
});
|
|
782
803
|
const capEl = el;
|
|
783
804
|
el.addEventListener("pointerdown", (e) => {
|
|
784
805
|
if (typeof capEl.setPointerCapture === "function") capEl.setPointerCapture(e.pointerId);
|
|
785
|
-
node.dispatchEvent(new (0,
|
|
806
|
+
node.dispatchEvent(new (0, _chunkXRWZS2DMjs.VectoJSEvent)("pointerdown", node, e));
|
|
786
807
|
});
|
|
787
808
|
el.addEventListener("pointerup", (e) => {
|
|
788
809
|
if (typeof capEl.releasePointerCapture === "function")
|
|
789
810
|
capEl.releasePointerCapture(e.pointerId);
|
|
790
|
-
node.dispatchEvent(new (0,
|
|
811
|
+
node.dispatchEvent(new (0, _chunkXRWZS2DMjs.VectoJSEvent)("pointerup", node, e));
|
|
791
812
|
});
|
|
792
813
|
el.addEventListener(
|
|
793
814
|
"pointermove",
|
|
794
|
-
(e) => node.dispatchEvent(new (0,
|
|
815
|
+
(e) => node.dispatchEvent(new (0, _chunkXRWZS2DMjs.VectoJSEvent)("pointermove", node, e))
|
|
795
816
|
);
|
|
796
817
|
el.addEventListener(
|
|
797
818
|
"wheel",
|
|
798
819
|
(e) => {
|
|
799
|
-
node.dispatchEvent(new (0,
|
|
820
|
+
node.dispatchEvent(new (0, _chunkXRWZS2DMjs.VectoJSEvent)("wheel", node, e));
|
|
800
821
|
},
|
|
801
822
|
{ passive: false }
|
|
802
823
|
);
|
|
803
824
|
el.addEventListener("keydown", (e) => {
|
|
804
|
-
node.dispatchEvent(new (0,
|
|
825
|
+
node.dispatchEvent(new (0, _chunkXRWZS2DMjs.VectoJSEvent)("keydown", node, e));
|
|
805
826
|
});
|
|
806
827
|
el.addEventListener("keyup", (e) => {
|
|
807
|
-
node.dispatchEvent(new (0,
|
|
828
|
+
node.dispatchEvent(new (0, _chunkXRWZS2DMjs.VectoJSEvent)("keyup", node, e));
|
|
808
829
|
});
|
|
809
830
|
if (el instanceof HTMLInputElement || el instanceof HTMLTextAreaElement) {
|
|
810
831
|
const input = el;
|
|
@@ -831,7 +852,7 @@ var Scene = (_class2 = class _Scene {
|
|
|
831
852
|
});
|
|
832
853
|
el.addEventListener("compositionupdate", (e) => {
|
|
833
854
|
const data = _nullishCoalesce(e.data, () => ( ""));
|
|
834
|
-
composition = { start: _nullishCoalesce(_optionalChain([composition, 'optionalAccess',
|
|
855
|
+
composition = { start: _nullishCoalesce(_optionalChain([composition, 'optionalAccess', _47 => _47.start]), () => ( 0)), length: data.length };
|
|
835
856
|
forward();
|
|
836
857
|
});
|
|
837
858
|
el.addEventListener("compositionend", () => {
|
|
@@ -877,7 +898,7 @@ var Scene = (_class2 = class _Scene {
|
|
|
877
898
|
el.addEventListener("keydown", (e) => {
|
|
878
899
|
if (e.key === "Enter" || e.key === " ") {
|
|
879
900
|
e.preventDefault();
|
|
880
|
-
node.dispatchEvent(new (0,
|
|
901
|
+
node.dispatchEvent(new (0, _chunkXRWZS2DMjs.VectoJSEvent)("click", node, e));
|
|
881
902
|
}
|
|
882
903
|
});
|
|
883
904
|
}
|
|
@@ -902,7 +923,7 @@ var Scene = (_class2 = class _Scene {
|
|
|
902
923
|
if (el.placeholder !== attrs.placeholder) el.placeholder = attrs.placeholder;
|
|
903
924
|
}
|
|
904
925
|
if (attrs.href !== void 0 && el instanceof HTMLAnchorElement) {
|
|
905
|
-
const safeHref =
|
|
926
|
+
const safeHref = _chunkXB3ZY5MFjs.sanitizeUrl.call(void 0, attrs.href);
|
|
906
927
|
if (el.getAttribute("href") !== safeHref) el.setAttribute("href", safeHref);
|
|
907
928
|
}
|
|
908
929
|
if (el instanceof HTMLImageElement) {
|
|
@@ -972,11 +993,96 @@ var Scene = (_class2 = class _Scene {
|
|
|
972
993
|
el.style.transform = `matrix(${a}, ${b}, ${c}, ${d}, 0, 0)`;
|
|
973
994
|
}
|
|
974
995
|
}
|
|
996
|
+
this.syncContentProjection(node);
|
|
975
997
|
for (const child of node.children) this.syncA11y(child);
|
|
976
998
|
if (node === this.root) {
|
|
977
999
|
for (const overlay of this.overlayRoot.children) this.syncA11y(overlay);
|
|
978
1000
|
}
|
|
979
1001
|
}
|
|
1002
|
+
/**
|
|
1003
|
+
* Mirror one entity's static text ({@link Entity.getContentProjection}) as a
|
|
1004
|
+
* transparent DOM node positioned over the drawn glyphs. Runs on the a11y
|
|
1005
|
+
* sync cadence; all writes are dirty-checked. Off-viewport projections are
|
|
1006
|
+
* hidden (`display: none`) so text-heavy scenes only materialize what is
|
|
1007
|
+
* visible to the browser's text machinery anyway.
|
|
1008
|
+
*/
|
|
1009
|
+
syncContentProjection(node) {
|
|
1010
|
+
if (!this.contentProjectionEnabled || !this.a11yRoot) return;
|
|
1011
|
+
const projection = node.getContentProjection();
|
|
1012
|
+
let el = this.contentElements.get(node.id);
|
|
1013
|
+
if (!projection || !projection.text) {
|
|
1014
|
+
if (el) {
|
|
1015
|
+
el.remove();
|
|
1016
|
+
this.contentElements.delete(node.id);
|
|
1017
|
+
}
|
|
1018
|
+
return;
|
|
1019
|
+
}
|
|
1020
|
+
if (!el) {
|
|
1021
|
+
el = document.createElement("div");
|
|
1022
|
+
el.setAttribute("data-vecto-content", node.id);
|
|
1023
|
+
const s = el.style;
|
|
1024
|
+
s.position = "absolute";
|
|
1025
|
+
s.transformOrigin = "0 0";
|
|
1026
|
+
s.margin = "0";
|
|
1027
|
+
s.padding = "0";
|
|
1028
|
+
s.color = "transparent";
|
|
1029
|
+
s.whiteSpace = "pre-wrap";
|
|
1030
|
+
s.overflow = "hidden";
|
|
1031
|
+
s.zIndex = "0";
|
|
1032
|
+
el.addEventListener(
|
|
1033
|
+
"wheel",
|
|
1034
|
+
(e2) => {
|
|
1035
|
+
node.dispatchEvent(new (0, _chunkXRWZS2DMjs.VectoJSEvent)("wheel", node, e2));
|
|
1036
|
+
},
|
|
1037
|
+
{ passive: false }
|
|
1038
|
+
);
|
|
1039
|
+
this.a11yRoot.appendChild(el);
|
|
1040
|
+
this.contentElements.set(node.id, el);
|
|
1041
|
+
}
|
|
1042
|
+
if (el.textContent !== projection.text) el.textContent = projection.text;
|
|
1043
|
+
const font = _nullishCoalesce(projection.font, () => ( ""));
|
|
1044
|
+
if (el.style.font !== font) el.style.font = font;
|
|
1045
|
+
const lineHeight = projection.lineHeight !== void 0 ? `${projection.lineHeight}px` : "";
|
|
1046
|
+
if (el.style.lineHeight !== lineHeight) el.style.lineHeight = lineHeight;
|
|
1047
|
+
const hidden = node.interactive ? "true" : null;
|
|
1048
|
+
if (el.getAttribute("aria-hidden") !== hidden) {
|
|
1049
|
+
if (hidden) el.setAttribute("aria-hidden", hidden);
|
|
1050
|
+
else el.removeAttribute("aria-hidden");
|
|
1051
|
+
}
|
|
1052
|
+
const selectable = projection.selectable === true;
|
|
1053
|
+
const pointerEvents = selectable ? "auto" : "none";
|
|
1054
|
+
if (el.style.pointerEvents !== pointerEvents) {
|
|
1055
|
+
el.style.pointerEvents = pointerEvents;
|
|
1056
|
+
el.style.userSelect = selectable ? "text" : "none";
|
|
1057
|
+
el.style.cursor = selectable ? "text" : "";
|
|
1058
|
+
}
|
|
1059
|
+
const { a, b, c, d, e, f } = node.getWorldTransform();
|
|
1060
|
+
el.style.left = `${e}px`;
|
|
1061
|
+
el.style.top = `${f}px`;
|
|
1062
|
+
if (node.width > 0) el.style.width = `${node.width}px`;
|
|
1063
|
+
if (node.height > 0) el.style.height = `${node.height}px`;
|
|
1064
|
+
el.style.transform = `matrix(${a}, ${b}, ${c}, ${d}, 0, 0)`;
|
|
1065
|
+
let visible = true;
|
|
1066
|
+
if (node.width > 0 && node.height > 0) {
|
|
1067
|
+
let minX = Infinity;
|
|
1068
|
+
let minY = Infinity;
|
|
1069
|
+
let maxX = -Infinity;
|
|
1070
|
+
let maxY = -Infinity;
|
|
1071
|
+
for (let i = 0; i < 4; i++) {
|
|
1072
|
+
const lx = i & 1 ? node.width : 0;
|
|
1073
|
+
const ly = i & 2 ? node.height : 0;
|
|
1074
|
+
const wx = a * lx + c * ly + e;
|
|
1075
|
+
const wy = b * lx + d * ly + f;
|
|
1076
|
+
if (wx < minX) minX = wx;
|
|
1077
|
+
if (wx > maxX) maxX = wx;
|
|
1078
|
+
if (wy < minY) minY = wy;
|
|
1079
|
+
if (wy > maxY) maxY = wy;
|
|
1080
|
+
}
|
|
1081
|
+
visible = maxX >= 0 && minX <= this.width && maxY >= 0 && minY <= this.height;
|
|
1082
|
+
}
|
|
1083
|
+
const display = visible ? "" : "none";
|
|
1084
|
+
if (el.style.display !== display) el.style.display = display;
|
|
1085
|
+
}
|
|
980
1086
|
enforceA11yDomOrder() {
|
|
981
1087
|
if (!this.a11yRoot) return;
|
|
982
1088
|
this.fullViewportElements.length = 0;
|
|
@@ -1035,12 +1141,12 @@ var Scene = (_class2 = class _Scene {
|
|
|
1035
1141
|
syncOverlayGeometry() {
|
|
1036
1142
|
const parent = this.canvas.parentElement;
|
|
1037
1143
|
if (!parent) return;
|
|
1038
|
-
const canvasRect = _optionalChain([this, 'access',
|
|
1039
|
-
const parentRect = _optionalChain([parent, 'access',
|
|
1040
|
-
const cssWidth = _optionalChain([canvasRect, 'optionalAccess',
|
|
1041
|
-
const cssHeight = _optionalChain([canvasRect, 'optionalAccess',
|
|
1042
|
-
const left = (_nullishCoalesce(_optionalChain([canvasRect, 'optionalAccess',
|
|
1043
|
-
const top = (_nullishCoalesce(_optionalChain([canvasRect, 'optionalAccess',
|
|
1144
|
+
const canvasRect = _optionalChain([this, 'access', _48 => _48.canvas, 'access', _49 => _49.getBoundingClientRect, 'optionalCall', _50 => _50()]);
|
|
1145
|
+
const parentRect = _optionalChain([parent, 'access', _51 => _51.getBoundingClientRect, 'optionalCall', _52 => _52()]);
|
|
1146
|
+
const cssWidth = _optionalChain([canvasRect, 'optionalAccess', _53 => _53.width]) || this.canvas.clientWidth || this.width;
|
|
1147
|
+
const cssHeight = _optionalChain([canvasRect, 'optionalAccess', _54 => _54.height]) || this.canvas.clientHeight || this.height;
|
|
1148
|
+
const left = (_nullishCoalesce(_optionalChain([canvasRect, 'optionalAccess', _55 => _55.left]), () => ( 0))) - (_nullishCoalesce(_optionalChain([parentRect, 'optionalAccess', _56 => _56.left]), () => ( 0))) - (parent.clientLeft || 0) + parent.scrollLeft;
|
|
1149
|
+
const top = (_nullishCoalesce(_optionalChain([canvasRect, 'optionalAccess', _57 => _57.top]), () => ( 0))) - (_nullishCoalesce(_optionalChain([parentRect, 'optionalAccess', _58 => _58.top]), () => ( 0))) - (parent.clientTop || 0) + parent.scrollTop;
|
|
1044
1150
|
const scaleX = this.width > 0 ? cssWidth / this.width : 1;
|
|
1045
1151
|
const scaleY = this.height > 0 ? cssHeight / this.height : 1;
|
|
1046
1152
|
for (const root of [this.a11yRoot, this.portalRoot]) {
|
|
@@ -1165,7 +1271,7 @@ var Scene = (_class2 = class _Scene {
|
|
|
1165
1271
|
* (and {@link respectReducedMotion} is on). `0` means uncapped.
|
|
1166
1272
|
*/
|
|
1167
1273
|
effectiveMaxFPS() {
|
|
1168
|
-
const reduced = this.respectReducedMotion && !!_optionalChain([this, 'access',
|
|
1274
|
+
const reduced = this.respectReducedMotion && !!_optionalChain([this, 'access', _59 => _59.reducedMotionQuery, 'optionalAccess', _60 => _60.matches]);
|
|
1169
1275
|
if (reduced)
|
|
1170
1276
|
return this.maxFPS > 0 ? Math.min(this.maxFPS, REDUCED_MOTION_FPS) : REDUCED_MOTION_FPS;
|
|
1171
1277
|
return this.maxFPS;
|
|
@@ -1173,7 +1279,7 @@ var Scene = (_class2 = class _Scene {
|
|
|
1173
1279
|
loop(time) {
|
|
1174
1280
|
if (!this.isRunning) return;
|
|
1175
1281
|
let cap = this.effectiveMaxFPS();
|
|
1176
|
-
const isIdle = !this.dirty && !this.
|
|
1282
|
+
const isIdle = !this.dirty && !this.frameHadAnimation;
|
|
1177
1283
|
if (isIdle && this.autoThrottle && this.renderMode === "always" && this.maxFPS > 0) {
|
|
1178
1284
|
cap = Math.min(cap, 2);
|
|
1179
1285
|
}
|
|
@@ -1189,12 +1295,13 @@ var Scene = (_class2 = class _Scene {
|
|
|
1189
1295
|
}
|
|
1190
1296
|
this.dirty = false;
|
|
1191
1297
|
this.render(this.renderer, dt, time);
|
|
1192
|
-
const hasActiveAnimation = this.
|
|
1193
|
-
const hasInteractive = this.
|
|
1298
|
+
const hasActiveAnimation = this.frameHadAnimation;
|
|
1299
|
+
const hasInteractive = this.frameHadInteractive;
|
|
1300
|
+
const wantsContentSync = this.contentProjectionEnabled;
|
|
1194
1301
|
const shouldSyncInterval = this.a11ySyncInterval <= 0 || time - this.lastA11ySync >= this.a11ySyncInterval;
|
|
1195
|
-
if ((hasInteractive || this.a11yElements.size > 0) && (shouldSyncInterval || this.a11yPendingSyncAfterAnimation)) {
|
|
1302
|
+
if ((hasInteractive || this.a11yElements.size > 0 || wantsContentSync) && (shouldSyncInterval || this.a11yPendingSyncAfterAnimation)) {
|
|
1196
1303
|
this.lastA11ySync = time;
|
|
1197
|
-
if (hasInteractive) {
|
|
1304
|
+
if (hasInteractive || wantsContentSync) {
|
|
1198
1305
|
this.syncA11y(this.root);
|
|
1199
1306
|
}
|
|
1200
1307
|
this.enforceA11yDomOrder();
|
|
@@ -1342,12 +1449,18 @@ var Scene = (_class2 = class _Scene {
|
|
|
1342
1449
|
}
|
|
1343
1450
|
renderer.clear();
|
|
1344
1451
|
if (isMainRenderer) {
|
|
1345
|
-
_optionalChain([this, 'access',
|
|
1452
|
+
_optionalChain([this, 'access', _61 => _61.pointRenderer, 'optionalAccess', _62 => _62.begin, 'call', _63 => _63()]);
|
|
1346
1453
|
}
|
|
1347
1454
|
const vw = this.width;
|
|
1348
1455
|
const vh = this.height;
|
|
1456
|
+
let walkHadAnimation = false;
|
|
1457
|
+
let walkHadInteractive = false;
|
|
1349
1458
|
const renderNode = (node, pa, pb, pc, pd, pe, pf, parentOpacity) => {
|
|
1350
|
-
if (isMainRenderer)
|
|
1459
|
+
if (isMainRenderer) {
|
|
1460
|
+
node.update(dt, time);
|
|
1461
|
+
if (!walkHadAnimation && node.hasPendingAnimations()) walkHadAnimation = true;
|
|
1462
|
+
if (!walkHadInteractive && node.interactive) walkHadInteractive = true;
|
|
1463
|
+
}
|
|
1351
1464
|
const cos = Math.cos(node.rotation);
|
|
1352
1465
|
const sin = Math.sin(node.rotation);
|
|
1353
1466
|
const te = pa * node.x + pc * node.y + pe;
|
|
@@ -1467,18 +1580,22 @@ var Scene = (_class2 = class _Scene {
|
|
|
1467
1580
|
for (const overlay of this.overlayRoot.children) {
|
|
1468
1581
|
renderNode(overlay, 1, 0, 0, 1, 0, 0, 1);
|
|
1469
1582
|
}
|
|
1470
|
-
if (isMainRenderer)
|
|
1583
|
+
if (isMainRenderer) {
|
|
1584
|
+
this.frameHadAnimation = walkHadAnimation;
|
|
1585
|
+
this.frameHadInteractive = walkHadInteractive;
|
|
1586
|
+
this.reconcilePortals();
|
|
1587
|
+
}
|
|
1471
1588
|
renderer.flush();
|
|
1472
1589
|
if (isMainRenderer) {
|
|
1473
|
-
_optionalChain([this, 'access',
|
|
1590
|
+
_optionalChain([this, 'access', _64 => _64.pointRenderer, 'optionalAccess', _65 => _65.flush, 'call', _66 => _66()]);
|
|
1474
1591
|
}
|
|
1475
|
-
_optionalChain([renderer, 'access',
|
|
1592
|
+
_optionalChain([renderer, 'access', _67 => _67.present, 'optionalCall', _68 => _68()]);
|
|
1476
1593
|
}
|
|
1477
1594
|
/**
|
|
1478
1595
|
* Export the current scene state to a lightweight, flat SVG XML string.
|
|
1479
1596
|
*/
|
|
1480
1597
|
toSVG() {
|
|
1481
|
-
const renderer = new (0,
|
|
1598
|
+
const renderer = new (0, _chunkXB3ZY5MFjs.SVGRenderer)(this.width, this.height);
|
|
1482
1599
|
this.render(renderer, 0, 0);
|
|
1483
1600
|
return renderer.toXMLString();
|
|
1484
1601
|
}
|
|
@@ -1491,7 +1608,7 @@ var Scene = (_class2 = class _Scene {
|
|
|
1491
1608
|
if (typeof this.renderer.resize === "function") {
|
|
1492
1609
|
this.renderer.resize(width, height);
|
|
1493
1610
|
}
|
|
1494
|
-
_optionalChain([this, 'access',
|
|
1611
|
+
_optionalChain([this, 'access', _69 => _69.pointRenderer, 'optionalAccess', _70 => _70.resize, 'call', _71 => _71(width, height)]);
|
|
1495
1612
|
if (this.gpuCanvas) {
|
|
1496
1613
|
this.gpuCanvas.width = width;
|
|
1497
1614
|
this.gpuCanvas.height = height;
|
|
@@ -1535,7 +1652,7 @@ var Scene = (_class2 = class _Scene {
|
|
|
1535
1652
|
});
|
|
1536
1653
|
pass.end();
|
|
1537
1654
|
this.device.queue.submit([encoder.finish()]);
|
|
1538
|
-
} catch (
|
|
1655
|
+
} catch (e3) {
|
|
1539
1656
|
}
|
|
1540
1657
|
this.gpuHasContent = false;
|
|
1541
1658
|
}
|
|
@@ -1672,33 +1789,41 @@ var Scene = (_class2 = class _Scene {
|
|
|
1672
1789
|
// src/components/TextEntity.ts
|
|
1673
1790
|
var sharedMeasurer;
|
|
1674
1791
|
function defaultMeasurer() {
|
|
1675
|
-
if (sharedMeasurer === void 0) sharedMeasurer =
|
|
1792
|
+
if (sharedMeasurer === void 0) sharedMeasurer = _chunkXLZDOFSBjs.createCanvasMeasurer.call(void 0, "sans-serif");
|
|
1676
1793
|
return sharedMeasurer;
|
|
1677
1794
|
}
|
|
1678
|
-
var TextEntity = (_class3 = class extends
|
|
1795
|
+
var TextEntity = (_class3 = class extends _chunkXRWZS2DMjs.Entity {
|
|
1679
1796
|
|
|
1680
1797
|
|
|
1681
1798
|
|
|
1682
1799
|
|
|
1683
|
-
|
|
1800
|
+
__init53() {this.nodes = []}
|
|
1684
1801
|
|
|
1685
|
-
|
|
1686
|
-
|
|
1687
|
-
|
|
1688
|
-
|
|
1689
|
-
|
|
1802
|
+
__init54() {this.fillStyle = "#94a3b8"}
|
|
1803
|
+
__init55() {this.strokeStyle = null}
|
|
1804
|
+
__init56() {this.hoveredFillStyle = "#ffffff"}
|
|
1805
|
+
__init57() {this.lineWidth = 1}
|
|
1806
|
+
__init58() {this.isHovered = false}
|
|
1690
1807
|
constructor(text, atlas, maxWidth, fontSize = 24) {
|
|
1691
|
-
super();_class3.prototype.
|
|
1808
|
+
super();_class3.prototype.__init53.call(this);_class3.prototype.__init54.call(this);_class3.prototype.__init55.call(this);_class3.prototype.__init56.call(this);_class3.prototype.__init57.call(this);_class3.prototype.__init58.call(this);;
|
|
1692
1809
|
this.text = text;
|
|
1693
1810
|
this.atlas = atlas;
|
|
1694
1811
|
this.fontSize = fontSize;
|
|
1695
|
-
this.layout = new (0,
|
|
1812
|
+
this.layout = new (0, _chunkXLZDOFSBjs.LayoutEngine)(maxWidth, 1e4, defaultMeasurer());
|
|
1696
1813
|
this.prepared = this.layout.prepare(this.text, this.atlas, this.fontSize);
|
|
1697
1814
|
this.applyLayout();
|
|
1698
1815
|
this.interactive = true;
|
|
1699
1816
|
this.on("hover", () => this.isHovered = true);
|
|
1700
1817
|
this.on("pointerleave", () => this.isHovered = false);
|
|
1701
1818
|
}
|
|
1819
|
+
/**
|
|
1820
|
+
* Mirror the rendered text into the DOM content layer: find-in-page, screen
|
|
1821
|
+
* readers, crawlers, and translation see the same string the canvas draws.
|
|
1822
|
+
*/
|
|
1823
|
+
getContentProjection() {
|
|
1824
|
+
if (!this.text) return null;
|
|
1825
|
+
return { text: this.text, font: `${this.fontSize}px sans-serif` };
|
|
1826
|
+
}
|
|
1702
1827
|
/**
|
|
1703
1828
|
* Replace the text content. Runs the **cold** measurement pass (re-segment +
|
|
1704
1829
|
* re-measure) since the glyphs changed, then re-lays out.
|
|
@@ -1723,6 +1848,26 @@ var TextEntity = (_class3 = class extends _chunk4BO5XBJLjs.Entity {
|
|
|
1723
1848
|
this.applyLayout();
|
|
1724
1849
|
return this;
|
|
1725
1850
|
}
|
|
1851
|
+
/**
|
|
1852
|
+
* Set horizontal alignment (`'justify'` stretches wrapped lines flush to
|
|
1853
|
+
* the wrap width; the last line stays ragged) and reflow.
|
|
1854
|
+
*/
|
|
1855
|
+
setTextAlign(align) {
|
|
1856
|
+
this.layout.textAlign = align;
|
|
1857
|
+
this.applyLayout();
|
|
1858
|
+
return this;
|
|
1859
|
+
}
|
|
1860
|
+
/**
|
|
1861
|
+
* Plug a hyphenator (word → parts). Break opportunities are baked in during
|
|
1862
|
+
* the cold pass, so this re-prepares the current text. Soft hyphens
|
|
1863
|
+
* (U+00AD) in the text work without one.
|
|
1864
|
+
*/
|
|
1865
|
+
setHyphenator(fn) {
|
|
1866
|
+
this.layout.hyphenate = fn;
|
|
1867
|
+
this.prepared = this.layout.prepare(this.text, this.atlas, this.fontSize);
|
|
1868
|
+
this.applyLayout();
|
|
1869
|
+
return this;
|
|
1870
|
+
}
|
|
1726
1871
|
/** Hot pass: place the cached {@link PreparedText} and refresh the a11y box. */
|
|
1727
1872
|
applyLayout() {
|
|
1728
1873
|
const result = this.layout.layoutPrepared(this.prepared);
|
|
@@ -1773,17 +1918,17 @@ var TextEntity = (_class3 = class extends _chunk4BO5XBJLjs.Entity {
|
|
|
1773
1918
|
}, _class3);
|
|
1774
1919
|
|
|
1775
1920
|
// src/components/GridTextEntity.ts
|
|
1776
|
-
var GridTextEntity = (_class4 = class extends
|
|
1921
|
+
var GridTextEntity = (_class4 = class extends _chunkXRWZS2DMjs.Entity {
|
|
1777
1922
|
|
|
1778
|
-
|
|
1779
|
-
|
|
1923
|
+
__init59() {this.fillStyle = "#ffffff"}
|
|
1924
|
+
__init60() {this.grid = []}
|
|
1780
1925
|
// Array of rows
|
|
1781
|
-
|
|
1782
|
-
|
|
1926
|
+
__init61() {this.cols = 0}
|
|
1927
|
+
__init62() {this.rows = 0}
|
|
1783
1928
|
|
|
1784
1929
|
|
|
1785
1930
|
constructor(_atlas, fontSize = 10) {
|
|
1786
|
-
super();_class4.prototype.
|
|
1931
|
+
super();_class4.prototype.__init59.call(this);_class4.prototype.__init60.call(this);_class4.prototype.__init61.call(this);_class4.prototype.__init62.call(this);;
|
|
1787
1932
|
this.fontSize = fontSize;
|
|
1788
1933
|
this.charWidth = fontSize * 1;
|
|
1789
1934
|
this.charHeight = fontSize * 1.1;
|
|
@@ -1792,7 +1937,7 @@ var GridTextEntity = (_class4 = class extends _chunk4BO5XBJLjs.Entity {
|
|
|
1792
1937
|
updateGrid(ascii) {
|
|
1793
1938
|
this.grid = ascii;
|
|
1794
1939
|
this.rows = ascii.length;
|
|
1795
|
-
this.cols = _optionalChain([ascii, 'access',
|
|
1940
|
+
this.cols = _optionalChain([ascii, 'access', _72 => _72[0], 'optionalAccess', _73 => _73.length]) || 0;
|
|
1796
1941
|
}
|
|
1797
1942
|
isPointInside(_globalX, _globalY) {
|
|
1798
1943
|
return false;
|
|
@@ -1867,7 +2012,7 @@ function distSqToSegment(px, py, x1, y1, x2, y2) {
|
|
|
1867
2012
|
const ey = py - cy;
|
|
1868
2013
|
return ex * ex + ey * ey;
|
|
1869
2014
|
}
|
|
1870
|
-
var SplineEntity = (_class5 = class extends
|
|
2015
|
+
var SplineEntity = (_class5 = class extends _chunkXRWZS2DMjs.Entity {
|
|
1871
2016
|
|
|
1872
2017
|
|
|
1873
2018
|
|
|
@@ -1875,23 +2020,23 @@ var SplineEntity = (_class5 = class extends _chunk4BO5XBJLjs.Entity {
|
|
|
1875
2020
|
|
|
1876
2021
|
|
|
1877
2022
|
|
|
1878
|
-
|
|
1879
|
-
|
|
2023
|
+
__init63() {this.offscreen = null}
|
|
2024
|
+
__init64() {this.baked = false}
|
|
1880
2025
|
/** Logical (CSS-pixel) size of the baked bitmap — the blit destination size. */
|
|
1881
|
-
|
|
1882
|
-
|
|
2026
|
+
__init65() {this.bakedWidth = 0}
|
|
2027
|
+
__init66() {this.bakedHeight = 0}
|
|
1883
2028
|
/** Gradient strokes can't be baked to a solid-color bitmap; they render per-frame. */
|
|
1884
2029
|
|
|
1885
2030
|
/** Lazily-flattened polylines (one Float32Array of [x,y,...] per segment) for hit-testing. */
|
|
1886
|
-
|
|
2031
|
+
__init67() {this.polylines = null}
|
|
1887
2032
|
/**
|
|
1888
2033
|
* When `true`, the renderer draws a rounded-rect outline of the entity's
|
|
1889
2034
|
* local bounds after painting the curves. Useful for drag feedback and
|
|
1890
2035
|
* debugging hit areas. Defaults to `false`.
|
|
1891
2036
|
*/
|
|
1892
|
-
|
|
2037
|
+
__init68() {this.showBounds = false}
|
|
1893
2038
|
constructor(doc, opts = {}) {
|
|
1894
|
-
super();_class5.prototype.
|
|
2039
|
+
super();_class5.prototype.__init63.call(this);_class5.prototype.__init64.call(this);_class5.prototype.__init65.call(this);_class5.prototype.__init66.call(this);_class5.prototype.__init67.call(this);_class5.prototype.__init68.call(this);;
|
|
1895
2040
|
this.doc = doc;
|
|
1896
2041
|
this.lineWidth = _nullishCoalesce(opts.lineWidth, () => ( 2));
|
|
1897
2042
|
this.cache = _nullishCoalesce(opts.cache, () => ( true));
|
|
@@ -1902,7 +2047,7 @@ var SplineEntity = (_class5 = class extends _chunk4BO5XBJLjs.Entity {
|
|
|
1902
2047
|
this.width = this.bounds.width;
|
|
1903
2048
|
this.height = this.bounds.height;
|
|
1904
2049
|
const isGradient = (c) => c !== null && !Array.isArray(c);
|
|
1905
|
-
this.containsGradient = (_nullishCoalesce(_optionalChain([this, 'access',
|
|
2050
|
+
this.containsGradient = (_nullishCoalesce(_optionalChain([this, 'access', _74 => _74.doc, 'access', _75 => _75.equations, 'optionalAccess', _76 => _76.some, 'call', _77 => _77((eq) => isGradient(eq.color_rgb))]), () => ( false))) || (_nullishCoalesce(_optionalChain([this, 'access', _78 => _78.doc, 'access', _79 => _79.paths, 'optionalAccess', _80 => _80.some, 'call', _81 => _81((p) => isGradient(p.color_rgb))]), () => ( false)));
|
|
1906
2051
|
this.interactive = true;
|
|
1907
2052
|
}
|
|
1908
2053
|
computeBounds() {
|
|
@@ -2144,9 +2289,9 @@ async function loadSpline(url) {
|
|
|
2144
2289
|
// src/math/SpatialHashGrid.ts
|
|
2145
2290
|
var SpatialHashGrid = (_class6 = class {
|
|
2146
2291
|
|
|
2147
|
-
|
|
2148
|
-
|
|
2149
|
-
constructor(cellSize = 64) {;_class6.prototype.
|
|
2292
|
+
__init69() {this.grid = /* @__PURE__ */ new Map()}
|
|
2293
|
+
__init70() {this.entityCells = /* @__PURE__ */ new Map()}
|
|
2294
|
+
constructor(cellSize = 64) {;_class6.prototype.__init69.call(this);_class6.prototype.__init70.call(this);
|
|
2150
2295
|
this.cellSize = cellSize;
|
|
2151
2296
|
}
|
|
2152
2297
|
hash(cx, cy) {
|
|
@@ -2200,7 +2345,7 @@ var SpatialHashGrid = (_class6 = class {
|
|
|
2200
2345
|
const keys = this.entityCells.get(id);
|
|
2201
2346
|
if (!keys) return;
|
|
2202
2347
|
for (const key of keys) {
|
|
2203
|
-
_optionalChain([this, 'access',
|
|
2348
|
+
_optionalChain([this, 'access', _82 => _82.grid, 'access', _83 => _83.get, 'call', _84 => _84(key), 'optionalAccess', _85 => _85.delete, 'call', _86 => _86(id)]);
|
|
2204
2349
|
}
|
|
2205
2350
|
this.entityCells.delete(id);
|
|
2206
2351
|
}
|
|
@@ -2236,20 +2381,20 @@ var SpatialHashGrid = (_class6 = class {
|
|
|
2236
2381
|
}, _class6);
|
|
2237
2382
|
|
|
2238
2383
|
// src/tree/DOMPortalEntity.ts
|
|
2239
|
-
var DOMPortalEntity = (_class7 = class extends
|
|
2384
|
+
var DOMPortalEntity = (_class7 = class extends _chunkXRWZS2DMjs.Entity {
|
|
2240
2385
|
|
|
2241
|
-
|
|
2242
|
-
|
|
2243
|
-
|
|
2244
|
-
|
|
2245
|
-
|
|
2246
|
-
|
|
2247
|
-
|
|
2248
|
-
|
|
2249
|
-
|
|
2250
|
-
|
|
2386
|
+
__init71() {this.isDOMPortal = true}
|
|
2387
|
+
__init72() {this.domListeners = []}
|
|
2388
|
+
__init73() {this.resizeObserver = null}
|
|
2389
|
+
__init74() {this.cachedWidth = 100}
|
|
2390
|
+
__init75() {this.cachedHeight = 100}
|
|
2391
|
+
__init76() {this.lastWidth = ""}
|
|
2392
|
+
__init77() {this.lastHeight = ""}
|
|
2393
|
+
__init78() {this.lastTransform = ""}
|
|
2394
|
+
__init79() {this.lastZIndex = ""}
|
|
2395
|
+
__init80() {this.lastOpacity = ""}
|
|
2251
2396
|
constructor(domElement, width, height, id) {
|
|
2252
|
-
super(id);_class7.prototype.
|
|
2397
|
+
super(id);_class7.prototype.__init71.call(this);_class7.prototype.__init72.call(this);_class7.prototype.__init73.call(this);_class7.prototype.__init74.call(this);_class7.prototype.__init75.call(this);_class7.prototype.__init76.call(this);_class7.prototype.__init77.call(this);_class7.prototype.__init78.call(this);_class7.prototype.__init79.call(this);_class7.prototype.__init80.call(this);;
|
|
2253
2398
|
this.domElement = domElement;
|
|
2254
2399
|
this.width = _nullishCoalesce(width, () => ( 0));
|
|
2255
2400
|
this.height = _nullishCoalesce(height, () => ( 0));
|
|
@@ -2271,7 +2416,7 @@ var DOMPortalEntity = (_class7 = class extends _chunk4BO5XBJLjs.Entity {
|
|
|
2271
2416
|
const events = ["click", "pointerdown", "pointerup", "pointermove", "wheel"];
|
|
2272
2417
|
for (const type of events) {
|
|
2273
2418
|
const handler = (e) => {
|
|
2274
|
-
this.dispatchEvent(new (0,
|
|
2419
|
+
this.dispatchEvent(new (0, _chunkXRWZS2DMjs.VectoJSEvent)(type, this, e));
|
|
2275
2420
|
};
|
|
2276
2421
|
this.domElement.addEventListener(type, handler);
|
|
2277
2422
|
this.domListeners.push({ type, handler, capture: false });
|
|
@@ -2282,7 +2427,7 @@ var DOMPortalEntity = (_class7 = class extends _chunk4BO5XBJLjs.Entity {
|
|
|
2282
2427
|
];
|
|
2283
2428
|
for (const { native, vecto } of hoverEvents) {
|
|
2284
2429
|
const handler = (e) => {
|
|
2285
|
-
this.dispatchEvent(new (0,
|
|
2430
|
+
this.dispatchEvent(new (0, _chunkXRWZS2DMjs.VectoJSEvent)(vecto, this, e, false));
|
|
2286
2431
|
};
|
|
2287
2432
|
this.domElement.addEventListener(native, handler);
|
|
2288
2433
|
this.domListeners.push({ type: native, handler, capture: false });
|
|
@@ -2290,7 +2435,7 @@ var DOMPortalEntity = (_class7 = class extends _chunk4BO5XBJLjs.Entity {
|
|
|
2290
2435
|
const focusEvents = ["focus", "blur"];
|
|
2291
2436
|
for (const type of focusEvents) {
|
|
2292
2437
|
const handler = (e) => {
|
|
2293
|
-
this.dispatchEvent(new (0,
|
|
2438
|
+
this.dispatchEvent(new (0, _chunkXRWZS2DMjs.VectoJSEvent)(type, this, e, true));
|
|
2294
2439
|
};
|
|
2295
2440
|
this.domElement.addEventListener(type, handler, true);
|
|
2296
2441
|
this.domListeners.push({ type, handler, capture: true });
|
|
@@ -2329,8 +2474,8 @@ var DOMPortalEntity = (_class7 = class extends _chunk4BO5XBJLjs.Entity {
|
|
|
2329
2474
|
}, _class7);
|
|
2330
2475
|
|
|
2331
2476
|
// src/index.ts
|
|
2332
|
-
Scene.registerWebGLPointRendererCreator(
|
|
2333
|
-
Scene.registerWebGPUParticleSystemManager(
|
|
2477
|
+
Scene.registerWebGLPointRendererCreator(_chunkXB3ZY5MFjs.createWebGLPointRenderer);
|
|
2478
|
+
Scene.registerWebGPUParticleSystemManager(_chunkXB3ZY5MFjs.WebGPUParticleSystemManager);
|
|
2334
2479
|
|
|
2335
2480
|
|
|
2336
2481
|
|
|
@@ -2375,4 +2520,4 @@ Scene.registerWebGPUParticleSystemManager(_chunkGADBN53Zjs.WebGPUParticleSystemM
|
|
|
2375
2520
|
|
|
2376
2521
|
|
|
2377
2522
|
|
|
2378
|
-
exports.ArabicShaper = _chunkCTZQOM5Zjs.ArabicShaper; exports.BidiResolver = _chunkCTZQOM5Zjs.BidiResolver; exports.CanvasRenderer =
|
|
2523
|
+
exports.ArabicShaper = _chunkCTZQOM5Zjs.ArabicShaper; exports.BidiResolver = _chunkCTZQOM5Zjs.BidiResolver; exports.CanvasRenderer = _chunkXB3ZY5MFjs.CanvasRenderer; exports.ComputeParticleEntity = ComputeParticleEntity; exports.DOMPortalEntity = DOMPortalEntity; exports.Easing = _chunkXRWZS2DMjs.Easing; exports.Entity = _chunkXRWZS2DMjs.Entity; exports.GridTextEntity = GridTextEntity; exports.LayoutEngine = _chunkXLZDOFSBjs.LayoutEngine; exports.LayoutResultBuffer = _chunkXLZDOFSBjs.LayoutResultBuffer; exports.LayoutWorkerManager = _chunkCTZQOM5Zjs.LayoutWorkerManager; exports.MSDFFont = _chunkXRWZS2DMjs.MSDFFont; exports.MSDFTextEntity = _chunkXRWZS2DMjs.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 = _chunkXRWZS2DMjs.SVGEntity; exports.SVGRenderer = _chunkXB3ZY5MFjs.SVGRenderer; exports.Scene = Scene; exports.SpatialHashGrid = SpatialHashGrid; exports.SplineEntity = SplineEntity; exports.SpringDriver = _chunkXRWZS2DMjs.SpringDriver; exports.SpringPhysics = _chunkXRWZS2DMjs.SpringPhysics; exports.TextEntity = TextEntity; exports.TweenDriver = _chunkXRWZS2DMjs.TweenDriver; exports.VectoJSEvent = _chunkXRWZS2DMjs.VectoJSEvent; exports.WebGPUParticleSystemManager = _chunkXB3ZY5MFjs.WebGPUParticleSystemManager; exports.computeLineSegments = _chunkXLZDOFSBjs.computeLineSegments; exports.createCanvasMeasurer = _chunkXLZDOFSBjs.createCanvasMeasurer; exports.createWebGLPointRenderer = _chunkXB3ZY5MFjs.createWebGLPointRenderer; exports.isSafeUrl = _chunkXB3ZY5MFjs.isSafeUrl; exports.isTweenConfig = _chunkXRWZS2DMjs.isTweenConfig; exports.loadSpline = loadSpline; exports.parseColorToRGBA = _chunkXB3ZY5MFjs.parseColorToRGBA; exports.polySegmentToBezier = polySegmentToBezier; exports.sanitizeUrl = _chunkXB3ZY5MFjs.sanitizeUrl;
|