@vectojs/core 1.39.0 → 1.39.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +43 -135
- package/dist/{chunk-RUM2KEDI.mjs → chunk-AISSDI6U.mjs} +15 -8
- package/dist/{chunk-KRUDTGNR.js → chunk-BKXERWAD.js} +15 -8
- package/dist/index.js +202 -122
- package/dist/index.mjs +88 -8
- package/dist/renderer.js +2 -2
- package/dist/renderer.mjs +1 -1
- package/dist/tree/Scene.d.ts +17 -0
- package/package.json +4 -4
package/README.md
CHANGED
|
@@ -1,18 +1,12 @@
|
|
|
1
1
|
# @vectojs/core
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
transforms, render scheduling, layout, text flow, spatial hit-testing, event propagation, renderer
|
|
11
|
-
backends, and the accessibility/automation projection layer.
|
|
12
|
-
|
|
13
|
-
[Core guide](https://vectojs.org/learn/core-scene/) ·
|
|
14
|
-
[API reference](https://vectojs.org/reference/core-api/) ·
|
|
15
|
-
[Main repository](https://github.com/vectojs/vectojs)
|
|
3
|
+
`@vectojs/core` is the runtime at the root of the VectoJS dependency graph: a retained
|
|
4
|
+
`Scene`/`Entity` scene graph (the Virtual Math Tree) that renders to a single canvas, with
|
|
5
|
+
transforms, render scheduling, spatial hit-testing, DOM-like event propagation, layout and text
|
|
6
|
+
engines, Canvas/SVG/WebGL/WebGPU renderer backends, and the accessibility/automation projection
|
|
7
|
+
layer. It is also the composition point of the framework — it depends on and re-exports
|
|
8
|
+
`@vectojs/layout`, `@vectojs/text`, `@vectojs/math`, and `@vectojs/animation`, so `@vectojs/ui`
|
|
9
|
+
and every higher-level package build directly on it.
|
|
16
10
|
|
|
17
11
|
## Install
|
|
18
12
|
|
|
@@ -20,7 +14,7 @@ backends, and the accessibility/automation projection layer.
|
|
|
20
14
|
bun add @vectojs/core
|
|
21
15
|
```
|
|
22
16
|
|
|
23
|
-
##
|
|
17
|
+
## Usage
|
|
24
18
|
|
|
25
19
|
```ts
|
|
26
20
|
import { Entity, type IRenderer, Scene } from '@vectojs/core';
|
|
@@ -57,124 +51,38 @@ scene.add(new Dot().setPosition(80, 80));
|
|
|
57
51
|
scene.start();
|
|
58
52
|
```
|
|
59
53
|
|
|
60
|
-
##
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
scene.
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
```ts
|
|
97
|
-
import { Scene, Entity } from '@vectojs/core';
|
|
98
|
-
import { LayoutEngine } from '@vectojs/core/layout';
|
|
99
|
-
import type { IRenderer } from '@vectojs/core/renderer';
|
|
100
|
-
import { TextEntity } from '@vectojs/core/text';
|
|
101
|
-
```
|
|
102
|
-
|
|
103
|
-
Both ESM and CommonJS outputs are published with TypeScript declarations.
|
|
104
|
-
|
|
105
|
-
## Accessibility and automation
|
|
106
|
-
|
|
107
|
-
Canvas pixels have no semantics. Interactive entities can implement `getA11yAttributes()`; the
|
|
108
|
-
Scene projects transparent DOM nodes over their world-space bounds and forwards native input back
|
|
109
|
-
into the VectoJS event system.
|
|
110
|
-
|
|
111
|
-
This projection is intentionally thin. Applications still own accessible names, keyboard behavior,
|
|
112
|
-
focus order, contrast, and correct control semantics. See the
|
|
113
|
-
[accessibility guide](https://vectojs.org/learn/accessibility/).
|
|
114
|
-
|
|
115
|
-
Non-control workspaces that own keyboard shortcuts can opt into focus order
|
|
116
|
-
explicitly: return `{ role: 'region', label: 'Canvas workspace', tabIndex: 0 }`.
|
|
117
|
-
The Scene refreshes the projected `tabindex` when attributes change. Keep native
|
|
118
|
-
text inputs and editable content in charge of their own editing shortcuts.
|
|
119
|
-
|
|
120
|
-
Interactive projected nodes capture the active pointer on `pointerdown` and route
|
|
121
|
-
`pointermove`, `pointerup`, and `pointercancel` through normal VMT capture/bubble propagation.
|
|
122
|
-
Treat `pointercancel` as rollback: discard transient gesture state and do not create durable
|
|
123
|
-
history. Pointer capture is released safely on both completion paths.
|
|
124
|
-
|
|
125
|
-
## Static content projection
|
|
126
|
-
|
|
127
|
-
Canvas-rendered text can opt into browser-native find, translation, selection, and copy without
|
|
128
|
-
turning the application into a DOM layout. Override `getContentProjection()` on the owning Entity;
|
|
129
|
-
the Scene creates a transparent, position-synchronized mirror while the VMT remains authoritative:
|
|
130
|
-
|
|
131
|
-
```ts
|
|
132
|
-
class SelectableLabel extends Entity {
|
|
133
|
-
getContentProjection() {
|
|
134
|
-
return {
|
|
135
|
-
text: 'Selectable canvas text',
|
|
136
|
-
font: '18px Inter',
|
|
137
|
-
lineHeight: 24,
|
|
138
|
-
selectable: true,
|
|
139
|
-
};
|
|
140
|
-
}
|
|
141
|
-
}
|
|
142
|
-
```
|
|
143
|
-
|
|
144
|
-
`selectable` controls whether the mirror receives pointer input. The Scene keeps projection order
|
|
145
|
-
aligned with VMT order, removes descendant mirrors with their subtree, and hides mirrors fully
|
|
146
|
-
outside the viewport or a `clipChildren` ancestor. Tooling can inspect the currently materialized
|
|
147
|
-
node with `scene.getContentElement(entityId)`. Virtualized or non-materialized off-viewport text is
|
|
148
|
-
not searchable until the application brings it into the active scene.
|
|
149
|
-
|
|
150
|
-
Code-like renderers can compile their logical source once with `prepareContentGrid()` and return the
|
|
151
|
-
same immutable plan as `ContentProjection.grid`. The plan retains UTF-16 source ranges, legal
|
|
152
|
-
grapheme carets, CR/LF ownership, tab stops, wide CJK/emoji advances, Arabic shaping, and Unicode
|
|
153
|
-
bidi positions. Scene projects those cells in logical source order, performs font calibration in a
|
|
154
|
-
cold offscreen batch, and uses the plan's local geometry for pointer selection even when the entity
|
|
155
|
-
is rotated, scaled, or the page is zoomed.
|
|
156
|
-
|
|
157
|
-
Selection routing preserves forward/reverse drag direction, Shift extension, word and line
|
|
158
|
-
selection, and exact clipboard source. Projection rebuild/removal/destroy paths release active
|
|
159
|
-
selection and pending calibration ownership before replacing DOM carriers.
|
|
160
|
-
|
|
161
|
-
## Performance model
|
|
162
|
-
|
|
163
|
-
Useful levers include on-demand rendering, viewport culling, spatial hashing, prepared text layout,
|
|
164
|
-
typed reusable buffers, batched WebGL points, and optional WebGPU particle compute. None makes every
|
|
165
|
-
workload allocation-free or GPU-bound; profile the renderer and entity types used by your app.
|
|
166
|
-
|
|
167
|
-
Run the repository benchmarks with `bun run benchmark`, `bun run compare:dom`, and
|
|
168
|
-
`bun run compare`. Prepared-grid scaling can be measured independently with
|
|
169
|
-
`bun run --cwd packages/core benchmark:grid`; benchmark timing is release evidence rather than a
|
|
170
|
-
wall-clock CI gate.
|
|
171
|
-
|
|
172
|
-
## Related packages
|
|
173
|
-
|
|
174
|
-
- [`@vectojs/ui`](https://github.com/vectojs/vectojs/tree/main/packages/ui) — high-level accessible components
|
|
175
|
-
- [`@vectojs/three`](https://github.com/vectojs/vectojs/tree/main/packages/three) — Three.js/WebXR projection and raycast routing
|
|
176
|
-
- [`@vectojs/video-exporter`](https://github.com/vectojs/vectojs/tree/main/packages/video-exporter) — deterministic H.264 capture
|
|
177
|
-
|
|
178
|
-
## License
|
|
179
|
-
|
|
180
|
-
[MIT](https://github.com/vectojs/vectojs/blob/main/LICENSE) © 2026 Xuepoo
|
|
54
|
+
## Highlights
|
|
55
|
+
|
|
56
|
+
- Retained `Scene`/`Entity` tree with affine transforms, capture/bubble event dispatch,
|
|
57
|
+
viewport culling, and dirty-flag `renderMode: 'onDemand'` rendering; `scene.step(dt)` drives a
|
|
58
|
+
deterministic frame for tests and video export.
|
|
59
|
+
- Backend-neutral `IRenderer` drawing contract with modular backends: `CanvasRenderer`,
|
|
60
|
+
`SVGRenderer`, batched WebGL points (`WebGLPointRenderer`), and WebGPU particle compute
|
|
61
|
+
(`WebGPUParticleSystemManager`) — registered on load via `Scene.register*`, selected through
|
|
62
|
+
`pointBackend` / `particleBackend` options.
|
|
63
|
+
- Optional Rust WASM kernels (`crates/vectojs-core-rs`) hot-swapped per subsystem with
|
|
64
|
+
`scene.enableWasmTransforms / enableWasmHitTest / enableWasmAnimBatching / enableWasmParticles`;
|
|
65
|
+
fallible exports return `WASM_STATUS` codes (`OK`/`CAPACITY`/`UNINITIALIZED`/`BAD_RUN`/
|
|
66
|
+
`OVERFLOW`) so any rejected batch degrades to the JS path instead of rendering half-written state.
|
|
67
|
+
- Semantic accessibility projection: entities implementing `getA11yAttributes()` get transparent,
|
|
68
|
+
position-synchronized DOM mirrors for screen readers, keyboard users, Playwright, and AI agents;
|
|
69
|
+
static text opts into browser-native selection/find/copy through `getContentProjection()` and
|
|
70
|
+
Core's prepared content grid (`prepareContentGrid()`).
|
|
71
|
+
- Entity-based text renderers stay here because they extend `Entity`: `TextEntity`,
|
|
72
|
+
`GridTextEntity`, GPU-resolved `MSDFTextEntity` (off-thread layout via `LayoutWorkerManager`),
|
|
73
|
+
`SVGEntity`, and `DOMPortalEntity`.
|
|
74
|
+
- The standalone engines are re-exported from this barrel and remain available as subpaths, so
|
|
75
|
+
existing imports keep working:
|
|
76
|
+
`@vectojs/core/layout`, `@vectojs/core/text`, `@vectojs/core/renderer`.
|
|
77
|
+
- Lifecycle ownership is explicit: a `Scene` owns renderers, workers, observers, and projected DOM
|
|
78
|
+
nodes; `scene.destroy()` releases all of them.
|
|
79
|
+
|
|
80
|
+
> Documents @vectojs/core@1.39.0.
|
|
81
|
+
|
|
82
|
+
## Documentation
|
|
83
|
+
|
|
84
|
+
- [Core Scene architecture](https://vectojs.org/learn/core-scene/)
|
|
85
|
+
- [`@vectojs/core` API reference](https://vectojs.org/reference/core-api/)
|
|
86
|
+
- [`Entity` reference](https://vectojs.org/reference/core-entity/)
|
|
87
|
+
- [Renderers reference](https://vectojs.org/reference/core-renderer/)
|
|
88
|
+
- [Accessibility & automation guide](https://vectojs.org/learn/accessibility/)
|
|
@@ -63,7 +63,8 @@ function emptyDrawCounters() {
|
|
|
63
63
|
}
|
|
64
64
|
var TWO_PI = Math.PI * 2;
|
|
65
65
|
function getDevicePixelRatio() {
|
|
66
|
-
|
|
66
|
+
const raw = typeof window !== "undefined" ? window.devicePixelRatio : 1;
|
|
67
|
+
return Number.isFinite(raw) && raw > 0 ? raw : 1;
|
|
67
68
|
}
|
|
68
69
|
var CanvasRenderer = class _CanvasRenderer {
|
|
69
70
|
ctx;
|
|
@@ -209,7 +210,9 @@ var CanvasRenderer = class _CanvasRenderer {
|
|
|
209
210
|
/** Real `devicePixelRatio`, clamped to {@link maxDPR} when set. */
|
|
210
211
|
effectiveDPR() {
|
|
211
212
|
const real = getDevicePixelRatio();
|
|
212
|
-
|
|
213
|
+
if (this.maxDPR === void 0) return real;
|
|
214
|
+
if (!Number.isFinite(this.maxDPR) || this.maxDPR <= 0) return real;
|
|
215
|
+
return Math.min(real, this.maxDPR);
|
|
213
216
|
}
|
|
214
217
|
/**
|
|
215
218
|
* @inheritdoc
|
|
@@ -240,14 +243,18 @@ var CanvasRenderer = class _CanvasRenderer {
|
|
|
240
243
|
*/
|
|
241
244
|
resize(width, height) {
|
|
242
245
|
const dpr = this.effectiveDPR();
|
|
246
|
+
const safeWidth = Number.isFinite(width) && width >= 0 ? width : this.width;
|
|
247
|
+
const safeHeight = Number.isFinite(height) && height >= 0 ? height : this.height;
|
|
248
|
+
const backingW = Number.isFinite(safeWidth * dpr) ? Math.max(1, Math.round(safeWidth * dpr)) : 1;
|
|
249
|
+
const backingH = Number.isFinite(safeHeight * dpr) ? Math.max(1, Math.round(safeHeight * dpr)) : 1;
|
|
243
250
|
this.appliedDPR = dpr;
|
|
244
|
-
this.width =
|
|
245
|
-
this.height =
|
|
246
|
-
this.ctx.canvas.width =
|
|
247
|
-
this.ctx.canvas.height =
|
|
251
|
+
this.width = safeWidth;
|
|
252
|
+
this.height = safeHeight;
|
|
253
|
+
this.ctx.canvas.width = backingW;
|
|
254
|
+
this.ctx.canvas.height = backingH;
|
|
248
255
|
if (this.ctx.canvas.style) {
|
|
249
|
-
this.ctx.canvas.style.width = `${
|
|
250
|
-
this.ctx.canvas.style.height = `${
|
|
256
|
+
this.ctx.canvas.style.width = `${safeWidth}px`;
|
|
257
|
+
this.ctx.canvas.style.height = `${safeHeight}px`;
|
|
251
258
|
}
|
|
252
259
|
this.ctx.scale(dpr, dpr);
|
|
253
260
|
this._cachedFont = "";
|
|
@@ -65,7 +65,8 @@ function emptyDrawCounters() {
|
|
|
65
65
|
}
|
|
66
66
|
var TWO_PI = Math.PI * 2;
|
|
67
67
|
function getDevicePixelRatio() {
|
|
68
|
-
|
|
68
|
+
const raw = typeof window !== "undefined" ? window.devicePixelRatio : 1;
|
|
69
|
+
return Number.isFinite(raw) && raw > 0 ? raw : 1;
|
|
69
70
|
}
|
|
70
71
|
var CanvasRenderer = (_class = class _CanvasRenderer {
|
|
71
72
|
|
|
@@ -211,7 +212,9 @@ var CanvasRenderer = (_class = class _CanvasRenderer {
|
|
|
211
212
|
/** Real `devicePixelRatio`, clamped to {@link maxDPR} when set. */
|
|
212
213
|
effectiveDPR() {
|
|
213
214
|
const real = getDevicePixelRatio();
|
|
214
|
-
|
|
215
|
+
if (this.maxDPR === void 0) return real;
|
|
216
|
+
if (!Number.isFinite(this.maxDPR) || this.maxDPR <= 0) return real;
|
|
217
|
+
return Math.min(real, this.maxDPR);
|
|
215
218
|
}
|
|
216
219
|
/**
|
|
217
220
|
* @inheritdoc
|
|
@@ -242,14 +245,18 @@ var CanvasRenderer = (_class = class _CanvasRenderer {
|
|
|
242
245
|
*/
|
|
243
246
|
resize(width, height) {
|
|
244
247
|
const dpr = this.effectiveDPR();
|
|
248
|
+
const safeWidth = Number.isFinite(width) && width >= 0 ? width : this.width;
|
|
249
|
+
const safeHeight = Number.isFinite(height) && height >= 0 ? height : this.height;
|
|
250
|
+
const backingW = Number.isFinite(safeWidth * dpr) ? Math.max(1, Math.round(safeWidth * dpr)) : 1;
|
|
251
|
+
const backingH = Number.isFinite(safeHeight * dpr) ? Math.max(1, Math.round(safeHeight * dpr)) : 1;
|
|
245
252
|
this.appliedDPR = dpr;
|
|
246
|
-
this.width =
|
|
247
|
-
this.height =
|
|
248
|
-
this.ctx.canvas.width =
|
|
249
|
-
this.ctx.canvas.height =
|
|
253
|
+
this.width = safeWidth;
|
|
254
|
+
this.height = safeHeight;
|
|
255
|
+
this.ctx.canvas.width = backingW;
|
|
256
|
+
this.ctx.canvas.height = backingH;
|
|
250
257
|
if (this.ctx.canvas.style) {
|
|
251
|
-
this.ctx.canvas.style.width = `${
|
|
252
|
-
this.ctx.canvas.style.height = `${
|
|
258
|
+
this.ctx.canvas.style.width = `${safeWidth}px`;
|
|
259
|
+
this.ctx.canvas.style.height = `${safeHeight}px`;
|
|
253
260
|
}
|
|
254
261
|
this.ctx.scale(dpr, dpr);
|
|
255
262
|
this._cachedFont = "";
|
package/dist/index.js
CHANGED
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
|
|
13
13
|
|
|
14
14
|
|
|
15
|
-
var
|
|
15
|
+
var _chunkBKXERWADjs = require('./chunk-BKXERWAD.js');
|
|
16
16
|
|
|
17
17
|
|
|
18
18
|
|
|
@@ -1070,8 +1070,11 @@ var CanvasGeometry = (_class3 = class {
|
|
|
1070
1070
|
/** Effective device pixel ratio, matching CanvasRenderer: real DPR clamped to
|
|
1071
1071
|
* `maxDPR` when set. */
|
|
1072
1072
|
effectiveDPR(maxDPR) {
|
|
1073
|
-
const
|
|
1074
|
-
|
|
1073
|
+
const raw = typeof window !== "undefined" ? window.devicePixelRatio : 1;
|
|
1074
|
+
const real = Number.isFinite(raw) && raw > 0 ? raw : 1;
|
|
1075
|
+
if (maxDPR === void 0) return real;
|
|
1076
|
+
if (!Number.isFinite(maxDPR) || maxDPR <= 0) return real;
|
|
1077
|
+
return Math.min(real, maxDPR);
|
|
1075
1078
|
}
|
|
1076
1079
|
/** Size the WebGPU particle canvas: backing store at logical × DPR, CSS box at
|
|
1077
1080
|
* the logical size. Sizing the backing store in logical px (the old
|
|
@@ -4179,8 +4182,10 @@ var Scene = (_class15 = class _Scene {
|
|
|
4179
4182
|
* this an embedded canvas stayed at its initial size forever. */
|
|
4180
4183
|
__init140() {this.canvasResizeObserver = null}
|
|
4181
4184
|
__init141() {this.dprChangeHandler = null}
|
|
4185
|
+
__init142() {this.dprPollInterval = null}
|
|
4186
|
+
__init143() {this.lastDpr = 1}
|
|
4182
4187
|
// --- domain: a11y-projection — focus, overlay geometry, DOM ordering, portals ---
|
|
4183
|
-
|
|
4188
|
+
__init144() {this.focusedA11yElement = null}
|
|
4184
4189
|
/**
|
|
4185
4190
|
* Canvas box geometry: the CSS↔logical mapping, overlay layer alignment, and
|
|
4186
4191
|
* the DPR math (extraction 5, `DEC-0024`).
|
|
@@ -4207,7 +4212,7 @@ var Scene = (_class15 = class _Scene {
|
|
|
4207
4212
|
/** Shadow elements the pointer is currently inside. Lets a removal that happens
|
|
4208
4213
|
* mid-hover synthesize the `pointerleave` the browser never sends for a
|
|
4209
4214
|
* detached element, so the entity doesn't keep its hover state. */
|
|
4210
|
-
|
|
4215
|
+
__init145() {this.hoveredA11yElements = /* @__PURE__ */ new WeakSet()}
|
|
4211
4216
|
/**
|
|
4212
4217
|
* Entity ids the application has pinned via {@link requestA11yProjection}.
|
|
4213
4218
|
*
|
|
@@ -4215,13 +4220,13 @@ var Scene = (_class15 = class _Scene {
|
|
|
4215
4220
|
* a stale id simply never matches. Cleared per-entity by
|
|
4216
4221
|
* {@link releaseA11yProjection}.
|
|
4217
4222
|
*/
|
|
4218
|
-
|
|
4223
|
+
__init146() {this.a11yProjectionRequests = /* @__PURE__ */ new Set()}
|
|
4219
4224
|
/** Persistent tabindex=-1 element in a11yRoot. When the focused a11y mirror is
|
|
4220
4225
|
* pruned (virtualization/streaming/removal) while it holds focus, we move
|
|
4221
4226
|
* focus here instead of letting the browser drop it to <body> — keeping the
|
|
4222
4227
|
* screen-reader virtual cursor inside the scene's a11y region. */
|
|
4223
|
-
|
|
4224
|
-
|
|
4228
|
+
__init147() {this.focusSentinel = null}
|
|
4229
|
+
__init148() {this.caretBlinkTimer = null}
|
|
4225
4230
|
/**
|
|
4226
4231
|
* The projected DOM's ordering engine — the reorder flag, the per-pass scratch
|
|
4227
4232
|
* collections, the visual reading-order sort and the cursor-based
|
|
@@ -4231,7 +4236,7 @@ var Scene = (_class15 = class _Scene {
|
|
|
4231
4236
|
* delegate here; the collect-and-prune walk stays behind because it needs
|
|
4232
4237
|
* {@link shouldProjectA11y} and the focus/caret state.
|
|
4233
4238
|
*/
|
|
4234
|
-
|
|
4239
|
+
__init149() {this.a11yOrder = new A11yProjectionManager()}
|
|
4235
4240
|
/**
|
|
4236
4241
|
* The content projection's selection preservation and grid calibration
|
|
4237
4242
|
* (extraction 3, `DEC-0022`).
|
|
@@ -4283,11 +4288,11 @@ var Scene = (_class15 = class _Scene {
|
|
|
4283
4288
|
set a11yNeedsReorder(value) {
|
|
4284
4289
|
this.a11yOrder.needsReorder = value;
|
|
4285
4290
|
}
|
|
4286
|
-
|
|
4287
|
-
|
|
4288
|
-
|
|
4289
|
-
|
|
4290
|
-
|
|
4291
|
+
__init150() {this.portalRoot = null}
|
|
4292
|
+
__init151() {this.activePortalsThisFrame = /* @__PURE__ */ new Set()}
|
|
4293
|
+
__init152() {this.activePortalsPrevFrame = /* @__PURE__ */ new Set()}
|
|
4294
|
+
__init153() {this.portalEntities = /* @__PURE__ */ new Map()}
|
|
4295
|
+
__init154() {this.renderOrderCounter = 0}
|
|
4291
4296
|
// --- domain: render-scheduler — authoritative frame counter ---
|
|
4292
4297
|
/**
|
|
4293
4298
|
* Monotonic render-frame counter, bumped once per authoritative `render()`
|
|
@@ -4297,7 +4302,7 @@ var Scene = (_class15 = class _Scene {
|
|
|
4297
4302
|
* back to the ancestor walk. Public for the same reason `Entity._getTrig`/
|
|
4298
4303
|
* `_setWorldCache` are: it is a cross-class render-internal contract.
|
|
4299
4304
|
*/
|
|
4300
|
-
|
|
4305
|
+
__init155() {this.currentFrame = 0}
|
|
4301
4306
|
// --- domain: wasm-backend-facade — EXTRACTED (see scene/WasmBackendFacade.ts) ---
|
|
4302
4307
|
/**
|
|
4303
4308
|
* The four invisible WASM accelerators and the resident transform store.
|
|
@@ -4367,8 +4372,8 @@ var Scene = (_class15 = class _Scene {
|
|
|
4367
4372
|
// Stays on `Scene`: it walks `root` *and* `overlayRoot` for entities the
|
|
4368
4373
|
// render walk consumes, so only its cache key is store state. The facade owns
|
|
4369
4374
|
// the key; the walk stays here.
|
|
4370
|
-
|
|
4371
|
-
|
|
4375
|
+
__init156() {this._computeEntities = []}
|
|
4376
|
+
__init157() {this._computeEntitiesVersion = -1}
|
|
4372
4377
|
/** Invalidate the resident WASM store layout; the next wasm-mode frame rebuilds
|
|
4373
4378
|
* it. Called by `Entity.add`/`remove` (topology changes only). */
|
|
4374
4379
|
markStructureChanged() {
|
|
@@ -4607,7 +4612,7 @@ var Scene = (_class15 = class _Scene {
|
|
|
4607
4612
|
get animBatchedLastFrame() {
|
|
4608
4613
|
return this._wasmBackend.animBatchedLastFrame;
|
|
4609
4614
|
}
|
|
4610
|
-
|
|
4615
|
+
__init158() {this.animGate = {
|
|
4611
4616
|
spring: 128,
|
|
4612
4617
|
tween: 256,
|
|
4613
4618
|
mixed: 128
|
|
@@ -4703,7 +4708,7 @@ var Scene = (_class15 = class _Scene {
|
|
|
4703
4708
|
* `tickDrivers()`'s per-frame stamp would skip it a full frame — a one-frame
|
|
4704
4709
|
* JS/WASM divergence. Written in {@link render} next to `_tickBatchedDrivers`.
|
|
4705
4710
|
*/
|
|
4706
|
-
|
|
4711
|
+
__init159() {this._updateWalkDt = null}
|
|
4707
4712
|
// --- domain: render-scheduler — batched driver tick (extraction 6), reads the anim backend ---
|
|
4708
4713
|
/**
|
|
4709
4714
|
* Advance every registered entity's active drivers for this frame, batching
|
|
@@ -4731,25 +4736,25 @@ var Scene = (_class15 = class _Scene {
|
|
|
4731
4736
|
* sync, so retaining the order prevents a newly opened overlay from spending
|
|
4732
4737
|
* its first frame below previously projected controls.
|
|
4733
4738
|
*/
|
|
4734
|
-
|
|
4739
|
+
__init160() {this.a11yRenderOrders = /* @__PURE__ */ new Map()}
|
|
4735
4740
|
// --- domain: context-and-resize — GL/GPU canvases, device state, pointer, size warnings ---
|
|
4736
4741
|
// Optional WebGL point-cloud layer (see SceneOptions.pointBackend).
|
|
4737
|
-
|
|
4738
|
-
|
|
4739
|
-
|
|
4740
|
-
|
|
4742
|
+
__init161() {this.pointRenderer = null}
|
|
4743
|
+
__init162() {this.glCanvas = null}
|
|
4744
|
+
__init163() {this.glContextLostHandler = null}
|
|
4745
|
+
__init164() {this.glContextRestoredHandler = null}
|
|
4741
4746
|
|
|
4742
4747
|
|
|
4743
4748
|
|
|
4744
|
-
|
|
4749
|
+
__init165() {this.disableWindowResize = false}
|
|
4745
4750
|
/** See {@link SceneOptions.maxDPR}. `undefined` = uncapped (real DPR). */
|
|
4746
4751
|
|
|
4747
4752
|
// WebGPU properties
|
|
4748
|
-
|
|
4749
|
-
|
|
4750
|
-
|
|
4751
|
-
|
|
4752
|
-
|
|
4753
|
+
__init166() {this.destroyed = false}
|
|
4754
|
+
__init167() {this.device = null}
|
|
4755
|
+
__init168() {this.deviceLost = false}
|
|
4756
|
+
__init169() {this.particleBackend = "auto"}
|
|
4757
|
+
__init170() {this._webgpuDisabled = false}
|
|
4753
4758
|
get webgpuDisabled() {
|
|
4754
4759
|
return this._webgpuDisabled || this.particleBackend === "cpu";
|
|
4755
4760
|
}
|
|
@@ -4777,28 +4782,28 @@ var Scene = (_class15 = class _Scene {
|
|
|
4777
4782
|
set webgpuDisabled(value) {
|
|
4778
4783
|
this._webgpuDisabled = value;
|
|
4779
4784
|
}
|
|
4780
|
-
|
|
4781
|
-
|
|
4782
|
-
|
|
4783
|
-
|
|
4784
|
-
|
|
4785
|
+
__init171() {this.recoveryTimerId = null}
|
|
4786
|
+
__init172() {this.manager = null}
|
|
4787
|
+
__init173() {this.initializingWebGPU = false}
|
|
4788
|
+
__init174() {this.gpuCanvas = null}
|
|
4789
|
+
__init175() {this.gpuContext = null}
|
|
4785
4790
|
/** True while the GPU canvas holds a presented particle frame (needs clearing when they leave). */
|
|
4786
|
-
|
|
4787
|
-
|
|
4788
|
-
|
|
4789
|
-
|
|
4790
|
-
|
|
4791
|
+
__init176() {this.gpuHasContent = false}
|
|
4792
|
+
__init177() {this.mouseX = -9999}
|
|
4793
|
+
__init178() {this.mouseY = -9999}
|
|
4794
|
+
__init179() {this.pointerMoveListener = null}
|
|
4795
|
+
__init180() {this.pointerLeaveListener = null}
|
|
4791
4796
|
/** Element the pointer listeners are bound to (parent container if present,
|
|
4792
4797
|
* else the canvas). Stored so `destroy()` detaches from the same element. */
|
|
4793
|
-
|
|
4798
|
+
__init181() {this.pointerEventTarget = null}
|
|
4794
4799
|
// --- scene-level keyboard channel state (see on/off/registerShortcut) ---
|
|
4795
|
-
|
|
4796
|
-
|
|
4800
|
+
__init182() {this.keydownHandlers = []}
|
|
4801
|
+
__init183() {this.keyupHandlers = []}
|
|
4797
4802
|
/** Chord-normalized shortcut table, matched on keydown only. */
|
|
4798
|
-
|
|
4799
|
-
|
|
4800
|
-
|
|
4801
|
-
|
|
4803
|
+
__init184() {this.shortcuts = []}
|
|
4804
|
+
__init185() {this.windowKeyDownHandler = null}
|
|
4805
|
+
__init186() {this.windowKeyUpHandler = null}
|
|
4806
|
+
__init187() {this.hasWarnedZeroSize = false}
|
|
4802
4807
|
/**
|
|
4803
4808
|
* Latch for {@link Scene.resize}'s invalid-dimension warning.
|
|
4804
4809
|
*
|
|
@@ -4808,8 +4813,8 @@ var Scene = (_class15 = class _Scene {
|
|
|
4808
4813
|
* because `resize()` is commonly driven from a `ResizeObserver`, which would
|
|
4809
4814
|
* otherwise warn on every frame of a drag.
|
|
4810
4815
|
*/
|
|
4811
|
-
|
|
4812
|
-
|
|
4816
|
+
__init188() {this.hasWarnedInvalidResize = false}
|
|
4817
|
+
__init189() {this.fontLoadHandler = null}
|
|
4813
4818
|
// --- domain: scene-facade — dev-mode diagnostics ---
|
|
4814
4819
|
// ── Dev-mode warning infrastructure ──────────────────────────────
|
|
4815
4820
|
//
|
|
@@ -4834,7 +4839,7 @@ var Scene = (_class15 = class _Scene {
|
|
|
4834
4839
|
}
|
|
4835
4840
|
static set devMode(active) {
|
|
4836
4841
|
_Scene._devMode = active;
|
|
4837
|
-
|
|
4842
|
+
_chunkBKXERWADjs.setRendererDevMode.call(void 0, active);
|
|
4838
4843
|
}
|
|
4839
4844
|
static _devModeDetected() {
|
|
4840
4845
|
if (_Scene._devMode) return true;
|
|
@@ -4844,7 +4849,7 @@ var Scene = (_class15 = class _Scene {
|
|
|
4844
4849
|
return false;
|
|
4845
4850
|
}
|
|
4846
4851
|
|
|
4847
|
-
|
|
4852
|
+
__init190() {this._devFrameCount = 0}
|
|
4848
4853
|
_devWarn(message) {
|
|
4849
4854
|
if (!this._devActive) return;
|
|
4850
4855
|
console.warn(`[vectojs/dev] ${message}`);
|
|
@@ -4922,7 +4927,7 @@ var Scene = (_class15 = class _Scene {
|
|
|
4922
4927
|
walkProjections(this.root);
|
|
4923
4928
|
}
|
|
4924
4929
|
// --- domain: scene-facade — construction (wires every collaborator) ---
|
|
4925
|
-
constructor(canvas, options = {}) {;_class15.prototype.__init88.call(this);_class15.prototype.__init89.call(this);_class15.prototype.__init90.call(this);_class15.prototype.__init91.call(this);_class15.prototype.__init92.call(this);_class15.prototype.__init93.call(this);_class15.prototype.__init94.call(this);_class15.prototype.__init95.call(this);_class15.prototype.__init96.call(this);_class15.prototype.__init97.call(this);_class15.prototype.__init98.call(this);_class15.prototype.__init99.call(this);_class15.prototype.__init100.call(this);_class15.prototype.__init101.call(this);_class15.prototype.__init102.call(this);_class15.prototype.__init103.call(this);_class15.prototype.__init104.call(this);_class15.prototype.__init105.call(this);_class15.prototype.__init106.call(this);_class15.prototype.__init107.call(this);_class15.prototype.__init108.call(this);_class15.prototype.__init109.call(this);_class15.prototype.__init110.call(this);_class15.prototype.__init111.call(this);_class15.prototype.__init112.call(this);_class15.prototype.__init113.call(this);_class15.prototype.__init114.call(this);_class15.prototype.__init115.call(this);_class15.prototype.__init116.call(this);_class15.prototype.__init117.call(this);_class15.prototype.__init118.call(this);_class15.prototype.__init119.call(this);_class15.prototype.__init120.call(this);_class15.prototype.__init121.call(this);_class15.prototype.__init122.call(this);_class15.prototype.__init123.call(this);_class15.prototype.__init124.call(this);_class15.prototype.__init125.call(this);_class15.prototype.__init126.call(this);_class15.prototype.__init127.call(this);_class15.prototype.__init128.call(this);_class15.prototype.__init129.call(this);_class15.prototype.__init130.call(this);_class15.prototype.__init131.call(this);_class15.prototype.__init132.call(this);_class15.prototype.__init133.call(this);_class15.prototype.__init134.call(this);_class15.prototype.__init135.call(this);_class15.prototype.__init136.call(this);_class15.prototype.__init137.call(this);_class15.prototype.__init138.call(this);_class15.prototype.__init139.call(this);_class15.prototype.__init140.call(this);_class15.prototype.__init141.call(this);_class15.prototype.__init142.call(this);_class15.prototype.__init143.call(this);_class15.prototype.__init144.call(this);_class15.prototype.__init145.call(this);_class15.prototype.__init146.call(this);_class15.prototype.__init147.call(this);_class15.prototype.__init148.call(this);_class15.prototype.__init149.call(this);_class15.prototype.__init150.call(this);_class15.prototype.__init151.call(this);_class15.prototype.__init152.call(this);_class15.prototype.__init153.call(this);_class15.prototype.__init154.call(this);_class15.prototype.__init155.call(this);_class15.prototype.__init156.call(this);_class15.prototype.__init157.call(this);_class15.prototype.__init158.call(this);_class15.prototype.__init159.call(this);_class15.prototype.__init160.call(this);_class15.prototype.__init161.call(this);_class15.prototype.__init162.call(this);_class15.prototype.__init163.call(this);_class15.prototype.__init164.call(this);_class15.prototype.__init165.call(this);_class15.prototype.__init166.call(this);_class15.prototype.__init167.call(this);_class15.prototype.__init168.call(this);_class15.prototype.__init169.call(this);_class15.prototype.__init170.call(this);_class15.prototype.__init171.call(this);_class15.prototype.__init172.call(this);_class15.prototype.__init173.call(this);_class15.prototype.__init174.call(this);_class15.prototype.__init175.call(this);_class15.prototype.__init176.call(this);_class15.prototype.__init177.call(this);_class15.prototype.__init178.call(this);_class15.prototype.__init179.call(this);_class15.prototype.__init180.call(this);_class15.prototype.__init181.call(this);_class15.prototype.__init182.call(this);_class15.prototype.__init183.call(this);_class15.prototype.__init184.call(this);_class15.prototype.__init185.call(this);_class15.prototype.__init186.call(this);_class15.prototype.__init187.call(this);_class15.prototype.__init188.call(this);
|
|
4930
|
+
constructor(canvas, options = {}) {;_class15.prototype.__init88.call(this);_class15.prototype.__init89.call(this);_class15.prototype.__init90.call(this);_class15.prototype.__init91.call(this);_class15.prototype.__init92.call(this);_class15.prototype.__init93.call(this);_class15.prototype.__init94.call(this);_class15.prototype.__init95.call(this);_class15.prototype.__init96.call(this);_class15.prototype.__init97.call(this);_class15.prototype.__init98.call(this);_class15.prototype.__init99.call(this);_class15.prototype.__init100.call(this);_class15.prototype.__init101.call(this);_class15.prototype.__init102.call(this);_class15.prototype.__init103.call(this);_class15.prototype.__init104.call(this);_class15.prototype.__init105.call(this);_class15.prototype.__init106.call(this);_class15.prototype.__init107.call(this);_class15.prototype.__init108.call(this);_class15.prototype.__init109.call(this);_class15.prototype.__init110.call(this);_class15.prototype.__init111.call(this);_class15.prototype.__init112.call(this);_class15.prototype.__init113.call(this);_class15.prototype.__init114.call(this);_class15.prototype.__init115.call(this);_class15.prototype.__init116.call(this);_class15.prototype.__init117.call(this);_class15.prototype.__init118.call(this);_class15.prototype.__init119.call(this);_class15.prototype.__init120.call(this);_class15.prototype.__init121.call(this);_class15.prototype.__init122.call(this);_class15.prototype.__init123.call(this);_class15.prototype.__init124.call(this);_class15.prototype.__init125.call(this);_class15.prototype.__init126.call(this);_class15.prototype.__init127.call(this);_class15.prototype.__init128.call(this);_class15.prototype.__init129.call(this);_class15.prototype.__init130.call(this);_class15.prototype.__init131.call(this);_class15.prototype.__init132.call(this);_class15.prototype.__init133.call(this);_class15.prototype.__init134.call(this);_class15.prototype.__init135.call(this);_class15.prototype.__init136.call(this);_class15.prototype.__init137.call(this);_class15.prototype.__init138.call(this);_class15.prototype.__init139.call(this);_class15.prototype.__init140.call(this);_class15.prototype.__init141.call(this);_class15.prototype.__init142.call(this);_class15.prototype.__init143.call(this);_class15.prototype.__init144.call(this);_class15.prototype.__init145.call(this);_class15.prototype.__init146.call(this);_class15.prototype.__init147.call(this);_class15.prototype.__init148.call(this);_class15.prototype.__init149.call(this);_class15.prototype.__init150.call(this);_class15.prototype.__init151.call(this);_class15.prototype.__init152.call(this);_class15.prototype.__init153.call(this);_class15.prototype.__init154.call(this);_class15.prototype.__init155.call(this);_class15.prototype.__init156.call(this);_class15.prototype.__init157.call(this);_class15.prototype.__init158.call(this);_class15.prototype.__init159.call(this);_class15.prototype.__init160.call(this);_class15.prototype.__init161.call(this);_class15.prototype.__init162.call(this);_class15.prototype.__init163.call(this);_class15.prototype.__init164.call(this);_class15.prototype.__init165.call(this);_class15.prototype.__init166.call(this);_class15.prototype.__init167.call(this);_class15.prototype.__init168.call(this);_class15.prototype.__init169.call(this);_class15.prototype.__init170.call(this);_class15.prototype.__init171.call(this);_class15.prototype.__init172.call(this);_class15.prototype.__init173.call(this);_class15.prototype.__init174.call(this);_class15.prototype.__init175.call(this);_class15.prototype.__init176.call(this);_class15.prototype.__init177.call(this);_class15.prototype.__init178.call(this);_class15.prototype.__init179.call(this);_class15.prototype.__init180.call(this);_class15.prototype.__init181.call(this);_class15.prototype.__init182.call(this);_class15.prototype.__init183.call(this);_class15.prototype.__init184.call(this);_class15.prototype.__init185.call(this);_class15.prototype.__init186.call(this);_class15.prototype.__init187.call(this);_class15.prototype.__init188.call(this);_class15.prototype.__init189.call(this);_class15.prototype.__init190.call(this);
|
|
4926
4931
|
this.canvas = canvas;
|
|
4927
4932
|
this.debugA11y = _nullishCoalesce(options.debugA11y, () => ( false));
|
|
4928
4933
|
this.disableWindowResize = _nullishCoalesce(options.disableWindowResize, () => ( false));
|
|
@@ -4933,8 +4938,13 @@ var Scene = (_class15 = class _Scene {
|
|
|
4933
4938
|
this.width = _nullishCoalesce(styleWidth, () => ( (canvas.width || canvas.clientWidth || 0)));
|
|
4934
4939
|
this.height = _nullishCoalesce(styleHeight, () => ( (canvas.height || canvas.clientHeight || 0)));
|
|
4935
4940
|
} else {
|
|
4936
|
-
|
|
4937
|
-
|
|
4941
|
+
if (typeof canvas.isConnected === "boolean" && !canvas.isConnected) {
|
|
4942
|
+
this.width = 0;
|
|
4943
|
+
this.height = 0;
|
|
4944
|
+
} else {
|
|
4945
|
+
this.width = typeof window !== "undefined" ? window.innerWidth : canvas.clientWidth || canvas.width || 800;
|
|
4946
|
+
this.height = typeof window !== "undefined" ? window.innerHeight : canvas.clientHeight || canvas.height || 600;
|
|
4947
|
+
}
|
|
4938
4948
|
}
|
|
4939
4949
|
const globalProcess = typeof globalThis !== "undefined" ? globalThis.process : void 0;
|
|
4940
4950
|
const isTest = globalProcess && (_optionalChain([globalProcess, 'access', _115 => _115.env, 'optionalAccess', _116 => _116.NODE_ENV]) === "test" || _optionalChain([globalProcess, 'access', _117 => _117.env, 'optionalAccess', _118 => _118.VITEST]) === "true");
|
|
@@ -4952,7 +4962,7 @@ var Scene = (_class15 = class _Scene {
|
|
|
4952
4962
|
this.readingDirection = _nullishCoalesce(options.readingDirection, () => ( "ltr"));
|
|
4953
4963
|
this.renderMode = _nullishCoalesce(options.renderMode, () => ( "always"));
|
|
4954
4964
|
this._devActive = _Scene._devModeDetected();
|
|
4955
|
-
|
|
4965
|
+
_chunkBKXERWADjs.setRendererDevMode.call(void 0, this._devActive);
|
|
4956
4966
|
this._warnUnknownOptions(options);
|
|
4957
4967
|
this.reducedMotionQuery = typeof window !== "undefined" && typeof window.matchMedia === "function" ? window.matchMedia("(prefers-reduced-motion: reduce)") : null;
|
|
4958
4968
|
if (typeof window !== "undefined" && typeof window.matchMedia === "function") {
|
|
@@ -4983,7 +4993,7 @@ var Scene = (_class15 = class _Scene {
|
|
|
4983
4993
|
if (options.renderer) {
|
|
4984
4994
|
this.renderer = options.renderer;
|
|
4985
4995
|
} else {
|
|
4986
|
-
this.renderer = new (0,
|
|
4996
|
+
this.renderer = new (0, _chunkBKXERWADjs.CanvasRenderer)(
|
|
4987
4997
|
canvas,
|
|
4988
4998
|
this.disableWindowResize ? { width: this.width, height: this.height } : void 0,
|
|
4989
4999
|
this.maxDPR
|
|
@@ -5166,16 +5176,52 @@ var Scene = (_class15 = class _Scene {
|
|
|
5166
5176
|
if (this.dprMediaQuery && this.dprChangeHandler) {
|
|
5167
5177
|
_optionalChain([this, 'access', _128 => _128.dprMediaQuery, 'access', _129 => _129.removeEventListener, 'optionalCall', _130 => _130("change", this.dprChangeHandler)]);
|
|
5168
5178
|
}
|
|
5169
|
-
const
|
|
5179
|
+
const raw = window.devicePixelRatio;
|
|
5180
|
+
const dpr = Number.isFinite(raw) && raw > 0 ? raw : 1;
|
|
5170
5181
|
const query = window.matchMedia(`(resolution: ${dpr}dppx)`);
|
|
5171
5182
|
const handler = () => {
|
|
5172
|
-
|
|
5173
|
-
|
|
5183
|
+
const curRaw = window.devicePixelRatio;
|
|
5184
|
+
const cur = Number.isFinite(curRaw) && curRaw > 0 ? curRaw : 1;
|
|
5185
|
+
if (Math.abs(cur - dpr) <= 1e-3) {
|
|
5186
|
+
this.watchDevicePixelRatio();
|
|
5187
|
+
return;
|
|
5188
|
+
}
|
|
5189
|
+
this.lastDpr = cur;
|
|
5190
|
+
try {
|
|
5191
|
+
this.resize(this.width, this.height);
|
|
5192
|
+
} catch (err) {
|
|
5193
|
+
console.warn("[VectoJS] DPR resize failed", err);
|
|
5194
|
+
}
|
|
5195
|
+
try {
|
|
5196
|
+
if (_optionalChain([this, 'access', _131 => _131.renderer, 'access', _132 => _132.isContextLost, 'optionalCall', _133 => _133()]) !== true) this.render(this.renderer);
|
|
5197
|
+
} catch (err) {
|
|
5198
|
+
console.warn("[VectoJS] DPR repaint failed", err);
|
|
5199
|
+
}
|
|
5174
5200
|
this.watchDevicePixelRatio();
|
|
5175
5201
|
};
|
|
5176
5202
|
_optionalChain([query, 'access', _134 => _134.addEventListener, 'optionalCall', _135 => _135("change", handler)]);
|
|
5177
5203
|
this.dprMediaQuery = query;
|
|
5178
5204
|
this.dprChangeHandler = handler;
|
|
5205
|
+
this.lastDpr = dpr;
|
|
5206
|
+
if (this.dprPollInterval === null && typeof setInterval === "function") {
|
|
5207
|
+
this.dprPollInterval = setInterval(() => {
|
|
5208
|
+
const rawPoll = window.devicePixelRatio;
|
|
5209
|
+
const curPoll = Number.isFinite(rawPoll) && rawPoll > 0 ? rawPoll : 1;
|
|
5210
|
+
if (Math.abs(curPoll - this.lastDpr) <= 1e-3) return;
|
|
5211
|
+
this.lastDpr = curPoll;
|
|
5212
|
+
try {
|
|
5213
|
+
this.resize(this.width, this.height);
|
|
5214
|
+
} catch (err) {
|
|
5215
|
+
console.warn("[VectoJS] DPR poll resize failed", err);
|
|
5216
|
+
}
|
|
5217
|
+
try {
|
|
5218
|
+
if (_optionalChain([this, 'access', _136 => _136.renderer, 'access', _137 => _137.isContextLost, 'optionalCall', _138 => _138()]) !== true) this.render(this.renderer);
|
|
5219
|
+
} catch (err) {
|
|
5220
|
+
console.warn("[VectoJS] DPR poll repaint failed", err);
|
|
5221
|
+
}
|
|
5222
|
+
this.watchDevicePixelRatio();
|
|
5223
|
+
}, 1e3);
|
|
5224
|
+
}
|
|
5179
5225
|
}
|
|
5180
5226
|
/**
|
|
5181
5227
|
* Recover the WebGL point layer from a GPU context loss (driver TDR reset,
|
|
@@ -5193,7 +5239,7 @@ var Scene = (_class15 = class _Scene {
|
|
|
5193
5239
|
if (typeof gl.addEventListener !== "function") return;
|
|
5194
5240
|
this.glContextLostHandler = (e) => {
|
|
5195
5241
|
e.preventDefault();
|
|
5196
|
-
_optionalChain([this, 'access',
|
|
5242
|
+
_optionalChain([this, 'access', _139 => _139.pointRenderer, 'optionalAccess', _140 => _140.destroy, 'call', _141 => _141()]);
|
|
5197
5243
|
this.pointRenderer = null;
|
|
5198
5244
|
};
|
|
5199
5245
|
this.glContextRestoredHandler = () => {
|
|
@@ -5209,6 +5255,35 @@ var Scene = (_class15 = class _Scene {
|
|
|
5209
5255
|
gl.addEventListener("webglcontextlost", this.glContextLostHandler);
|
|
5210
5256
|
gl.addEventListener("webglcontextrestored", this.glContextRestoredHandler);
|
|
5211
5257
|
}
|
|
5258
|
+
/**
|
|
5259
|
+
* One-shot adoption of the window viewport once an initially-detached canvas
|
|
5260
|
+
* gains layout (#817). A full-window scene constructed before its canvas is
|
|
5261
|
+
* attached starts at 0×0, and no window `resize` fires on attachment — so
|
|
5262
|
+
* without this latch the scene would stay unsized forever. The first nonzero
|
|
5263
|
+
* layout box adopts `window.innerWidth/innerHeight` (the same sizing the
|
|
5264
|
+
* window resize handler applies, keeping the full-window contract), then the
|
|
5265
|
+
* observer disconnects: steady-state sizing stays exactly as if the canvas
|
|
5266
|
+
* had been attached before construction. An explicit user `resize()` between
|
|
5267
|
+
* construction and attachment is respected and skips adoption.
|
|
5268
|
+
*
|
|
5269
|
+
* No-op when the scene already has a size (attached at construction) or when
|
|
5270
|
+
* `ResizeObserver` is unavailable (the caller then drives sizing explicitly).
|
|
5271
|
+
*/
|
|
5272
|
+
armAttachmentViewportLatch() {
|
|
5273
|
+
if (this.width > 0 && this.height > 0) return;
|
|
5274
|
+
if (typeof ResizeObserver === "undefined") return;
|
|
5275
|
+
const observer = new ResizeObserver((entries) => {
|
|
5276
|
+
const box = _optionalChain([entries, 'access', _142 => _142[0], 'optionalAccess', _143 => _143.contentRect]);
|
|
5277
|
+
if (!box || !(box.width > 0) || !(box.height > 0)) return;
|
|
5278
|
+
observer.disconnect();
|
|
5279
|
+
this.canvasResizeObserver = null;
|
|
5280
|
+
if (this.width === 0 || this.height === 0) {
|
|
5281
|
+
this.resize(window.innerWidth, window.innerHeight);
|
|
5282
|
+
}
|
|
5283
|
+
});
|
|
5284
|
+
this.canvasResizeObserver = observer;
|
|
5285
|
+
observer.observe(this.canvas);
|
|
5286
|
+
}
|
|
5212
5287
|
// --- domain: scene-facade — renderer accessor ---
|
|
5213
5288
|
/**
|
|
5214
5289
|
* Expose the underlying {@link IRenderer} for advanced direct-draw operations.
|
|
@@ -5390,12 +5465,16 @@ var Scene = (_class15 = class _Scene {
|
|
|
5390
5465
|
this.canvasResizeObserver = null;
|
|
5391
5466
|
}
|
|
5392
5467
|
if (this.dprMediaQuery && this.dprChangeHandler) {
|
|
5393
|
-
_optionalChain([this, 'access',
|
|
5468
|
+
_optionalChain([this, 'access', _144 => _144.dprMediaQuery, 'access', _145 => _145.removeEventListener, 'optionalCall', _146 => _146("change", this.dprChangeHandler)]);
|
|
5394
5469
|
this.dprMediaQuery = null;
|
|
5395
5470
|
this.dprChangeHandler = null;
|
|
5396
5471
|
}
|
|
5472
|
+
if (this.dprPollInterval !== null) {
|
|
5473
|
+
clearInterval(this.dprPollInterval);
|
|
5474
|
+
this.dprPollInterval = null;
|
|
5475
|
+
}
|
|
5397
5476
|
if (this.forcedColorsQuery && this.forcedColorsChangeHandler) {
|
|
5398
|
-
_optionalChain([this, 'access',
|
|
5477
|
+
_optionalChain([this, 'access', _147 => _147.forcedColorsQuery, 'access', _148 => _148.removeEventListener, 'optionalCall', _149 => _149("change", this.forcedColorsChangeHandler)]);
|
|
5399
5478
|
this.forcedColorsQuery = null;
|
|
5400
5479
|
this.forcedColorsChangeHandler = null;
|
|
5401
5480
|
}
|
|
@@ -5426,9 +5505,9 @@ var Scene = (_class15 = class _Scene {
|
|
|
5426
5505
|
}
|
|
5427
5506
|
this.pointerEventTarget = null;
|
|
5428
5507
|
}
|
|
5429
|
-
_optionalChain([this, 'access',
|
|
5508
|
+
_optionalChain([this, 'access', _150 => _150.a11yRoot, 'optionalAccess', _151 => _151.remove, 'call', _152 => _152()]);
|
|
5430
5509
|
this.focusSentinel = null;
|
|
5431
|
-
_optionalChain([this, 'access',
|
|
5510
|
+
_optionalChain([this, 'access', _153 => _153.portalRoot, 'optionalAccess', _154 => _154.remove, 'call', _155 => _155()]);
|
|
5432
5511
|
this.a11yElements.clear();
|
|
5433
5512
|
for (const el of this.contentElements.values()) el.remove();
|
|
5434
5513
|
this.contentElements.clear();
|
|
@@ -5444,10 +5523,10 @@ var Scene = (_class15 = class _Scene {
|
|
|
5444
5523
|
}
|
|
5445
5524
|
this.glContextLostHandler = null;
|
|
5446
5525
|
this.glContextRestoredHandler = null;
|
|
5447
|
-
_optionalChain([this, 'access',
|
|
5448
|
-
_optionalChain([this, 'access',
|
|
5449
|
-
_optionalChain([this, 'access',
|
|
5450
|
-
_optionalChain([this, 'access',
|
|
5526
|
+
_optionalChain([this, 'access', _156 => _156.pointRenderer, 'optionalAccess', _157 => _157.destroy, 'call', _158 => _158()]);
|
|
5527
|
+
_optionalChain([this, 'access', _159 => _159.renderer, 'access', _160 => _160.dispose, 'optionalCall', _161 => _161()]);
|
|
5528
|
+
_optionalChain([this, 'access', _162 => _162.glCanvas, 'optionalAccess', _163 => _163.remove, 'call', _164 => _164()]);
|
|
5529
|
+
_optionalChain([this, 'access', _165 => _165.gpuCanvas, 'optionalAccess', _166 => _166.remove, 'call', _167 => _167()]);
|
|
5451
5530
|
this.gpuCanvas = null;
|
|
5452
5531
|
this.gpuContext = null;
|
|
5453
5532
|
if (this.recoveryTimerId) {
|
|
@@ -5459,7 +5538,7 @@ var Scene = (_class15 = class _Scene {
|
|
|
5459
5538
|
this.manager = null;
|
|
5460
5539
|
}
|
|
5461
5540
|
if (this.device) {
|
|
5462
|
-
_optionalChain([this, 'access',
|
|
5541
|
+
_optionalChain([this, 'access', _168 => _168.device, 'access', _169 => _169.destroy, 'optionalCall', _170 => _170()]);
|
|
5463
5542
|
this.device = null;
|
|
5464
5543
|
}
|
|
5465
5544
|
}
|
|
@@ -5467,6 +5546,7 @@ var Scene = (_class15 = class _Scene {
|
|
|
5467
5546
|
setupEvents() {
|
|
5468
5547
|
if (typeof window !== "undefined" && !this.disableWindowResize) {
|
|
5469
5548
|
window.addEventListener("resize", this.resizeHandler);
|
|
5549
|
+
this.armAttachmentViewportLatch();
|
|
5470
5550
|
} else if (this.disableWindowResize && typeof ResizeObserver !== "undefined" && this.canvas && typeof this.canvas.getBoundingClientRect === "function") {
|
|
5471
5551
|
this.canvasResizeObserver = new ResizeObserver((entries) => {
|
|
5472
5552
|
const entry = entries[0];
|
|
@@ -5911,7 +5991,7 @@ var Scene = (_class15 = class _Scene {
|
|
|
5911
5991
|
if (this.mouseX > -9e3 && !this.projectsSelectableText(node)) {
|
|
5912
5992
|
if (node.isPointInside(this.mouseX, this.mouseY)) return true;
|
|
5913
5993
|
}
|
|
5914
|
-
const existing = _optionalChain([this, 'access',
|
|
5994
|
+
const existing = _optionalChain([this, 'access', _171 => _171.a11yElements, 'optionalAccess', _172 => _172.get, 'call', _173 => _173(node.id)]);
|
|
5915
5995
|
if (existing && typeof document !== "undefined" && document.activeElement === existing) {
|
|
5916
5996
|
return true;
|
|
5917
5997
|
}
|
|
@@ -5925,8 +6005,8 @@ var Scene = (_class15 = class _Scene {
|
|
|
5925
6005
|
* selection.
|
|
5926
6006
|
*/
|
|
5927
6007
|
projectsSelectableText(node) {
|
|
5928
|
-
const projection = _optionalChain([node, 'access',
|
|
5929
|
-
return !!_optionalChain([projection, 'optionalAccess',
|
|
6008
|
+
const projection = _optionalChain([node, 'access', _174 => _174.getContentProjection, 'optionalCall', _175 => _175()]);
|
|
6009
|
+
return !!_optionalChain([projection, 'optionalAccess', _176 => _176.text]) && projection.selectable !== false;
|
|
5930
6010
|
}
|
|
5931
6011
|
/**
|
|
5932
6012
|
* Keep `entity`'s a11y shadow node projected while it has
|
|
@@ -6128,7 +6208,7 @@ var Scene = (_class15 = class _Scene {
|
|
|
6128
6208
|
el.addEventListener("compositionupdate", (e) => {
|
|
6129
6209
|
const data = _nullishCoalesce(e.data, () => ( ""));
|
|
6130
6210
|
composition = {
|
|
6131
|
-
start: _nullishCoalesce(_optionalChain([composition, 'optionalAccess',
|
|
6211
|
+
start: _nullishCoalesce(_optionalChain([composition, 'optionalAccess', _177 => _177.start]), () => ( 0)),
|
|
6132
6212
|
length: data.length
|
|
6133
6213
|
};
|
|
6134
6214
|
forward();
|
|
@@ -6210,7 +6290,7 @@ var Scene = (_class15 = class _Scene {
|
|
|
6210
6290
|
this.syncOptionalAttribute(
|
|
6211
6291
|
el,
|
|
6212
6292
|
"href",
|
|
6213
|
-
attrs.href === void 0 ? void 0 :
|
|
6293
|
+
attrs.href === void 0 ? void 0 : _chunkBKXERWADjs.sanitizeUrl.call(void 0, attrs.href)
|
|
6214
6294
|
);
|
|
6215
6295
|
this.syncOptionalAttribute(el, "target", attrs.target);
|
|
6216
6296
|
}
|
|
@@ -6379,7 +6459,7 @@ var Scene = (_class15 = class _Scene {
|
|
|
6379
6459
|
const display = visible ? "" : "none";
|
|
6380
6460
|
if (el.style.display !== display) el.style.display = display;
|
|
6381
6461
|
}
|
|
6382
|
-
_optionalChain([emitInitialScroll, 'optionalCall',
|
|
6462
|
+
_optionalChain([emitInitialScroll, 'optionalCall', _178 => _178()]);
|
|
6383
6463
|
}
|
|
6384
6464
|
if (this.phases.enabled) {
|
|
6385
6465
|
const projectionStart = performance.now();
|
|
@@ -6840,8 +6920,8 @@ var Scene = (_class15 = class _Scene {
|
|
|
6840
6920
|
next.f = f2;
|
|
6841
6921
|
next.tier = tier;
|
|
6842
6922
|
next.hasBand = lineBand !== null;
|
|
6843
|
-
next.bandMin = _nullishCoalesce(_optionalChain([lineBand, 'optionalAccess',
|
|
6844
|
-
next.bandMax = _nullishCoalesce(_optionalChain([lineBand, 'optionalAccess',
|
|
6923
|
+
next.bandMin = _nullishCoalesce(_optionalChain([lineBand, 'optionalAccess', _179 => _179.minY]), () => ( 0));
|
|
6924
|
+
next.bandMax = _nullishCoalesce(_optionalChain([lineBand, 'optionalAccess', _180 => _180.maxY]), () => ( 0));
|
|
6845
6925
|
next.visible = visible;
|
|
6846
6926
|
next.width = node.width;
|
|
6847
6927
|
next.height = node.height;
|
|
@@ -7027,7 +7107,7 @@ var Scene = (_class15 = class _Scene {
|
|
|
7027
7107
|
* (and {@link respectReducedMotion} is on). `0` means uncapped.
|
|
7028
7108
|
*/
|
|
7029
7109
|
effectiveMaxFPS() {
|
|
7030
|
-
const reduced = this.respectReducedMotion && !!_optionalChain([this, 'access',
|
|
7110
|
+
const reduced = this.respectReducedMotion && !!_optionalChain([this, 'access', _181 => _181.reducedMotionQuery, 'optionalAccess', _182 => _182.matches]);
|
|
7031
7111
|
if (reduced)
|
|
7032
7112
|
return this.maxFPS > 0 ? Math.min(this.maxFPS, REDUCED_MOTION_FPS) : REDUCED_MOTION_FPS;
|
|
7033
7113
|
return this.maxFPS;
|
|
@@ -7122,7 +7202,7 @@ var Scene = (_class15 = class _Scene {
|
|
|
7122
7202
|
* @param time - Current absolute time in milliseconds (default 0).
|
|
7123
7203
|
*/
|
|
7124
7204
|
render(renderer, dt = 0, time = 0) {
|
|
7125
|
-
if (_optionalChain([renderer, 'access',
|
|
7205
|
+
if (_optionalChain([renderer, 'access', _183 => _183.isContextLost, 'optionalCall', _184 => _184()])) return;
|
|
7126
7206
|
const isMainRenderer = renderer === this.renderer;
|
|
7127
7207
|
if (isMainRenderer && this.a11yRoot && this.canvas.parentElement) {
|
|
7128
7208
|
const parentStyle = this.canvas.parentElement.style;
|
|
@@ -7272,7 +7352,7 @@ var Scene = (_class15 = class _Scene {
|
|
|
7272
7352
|
}
|
|
7273
7353
|
renderer.clear();
|
|
7274
7354
|
if (isMainRenderer) {
|
|
7275
|
-
_optionalChain([this, 'access',
|
|
7355
|
+
_optionalChain([this, 'access', _185 => _185.pointRenderer, 'optionalAccess', _186 => _186.begin, 'call', _187 => _187()]);
|
|
7276
7356
|
}
|
|
7277
7357
|
const vw = this.width;
|
|
7278
7358
|
const vh = this.height;
|
|
@@ -7523,9 +7603,9 @@ var Scene = (_class15 = class _Scene {
|
|
|
7523
7603
|
const flushT0 = this.phases.enabled ? performance.now() : 0;
|
|
7524
7604
|
renderer.flush();
|
|
7525
7605
|
if (isMainRenderer) {
|
|
7526
|
-
_optionalChain([this, 'access',
|
|
7606
|
+
_optionalChain([this, 'access', _188 => _188.pointRenderer, 'optionalAccess', _189 => _189.flush, 'call', _190 => _190()]);
|
|
7527
7607
|
}
|
|
7528
|
-
_optionalChain([renderer, 'access',
|
|
7608
|
+
_optionalChain([renderer, 'access', _191 => _191.present, 'optionalCall', _192 => _192()]);
|
|
7529
7609
|
if (this.phases.enabled) this.phases.record("flush", performance.now() - flushT0);
|
|
7530
7610
|
if (flushTiming) endVectoUserTiming(flushTiming);
|
|
7531
7611
|
if (this._devActive) {
|
|
@@ -7538,7 +7618,7 @@ var Scene = (_class15 = class _Scene {
|
|
|
7538
7618
|
* Export the current scene state to a lightweight, flat SVG XML string.
|
|
7539
7619
|
*/
|
|
7540
7620
|
toSVG() {
|
|
7541
|
-
const renderer = new (0,
|
|
7621
|
+
const renderer = new (0, _chunkBKXERWADjs.SVGRenderer)(this.width, this.height);
|
|
7542
7622
|
this.render(renderer, 0, 0);
|
|
7543
7623
|
return renderer.toXMLString();
|
|
7544
7624
|
}
|
|
@@ -7756,15 +7836,15 @@ var TextEntity = (_class16 = class extends _chunkPOPXUPKRjs.Entity {
|
|
|
7756
7836
|
|
|
7757
7837
|
|
|
7758
7838
|
|
|
7759
|
-
|
|
7839
|
+
__init191() {this.nodes = []}
|
|
7760
7840
|
|
|
7761
|
-
|
|
7762
|
-
|
|
7763
|
-
|
|
7764
|
-
|
|
7765
|
-
|
|
7841
|
+
__init192() {this.fillStyle = "#94a3b8"}
|
|
7842
|
+
__init193() {this.strokeStyle = null}
|
|
7843
|
+
__init194() {this.hoveredFillStyle = "#ffffff"}
|
|
7844
|
+
__init195() {this.lineWidth = 1}
|
|
7845
|
+
__init196() {this.isHovered = false}
|
|
7766
7846
|
/** Bumped by {@link applyLayout}; read by `Scene` to skip an unchanged sync. */
|
|
7767
|
-
|
|
7847
|
+
__init197() {this.contentEpoch = 0}
|
|
7768
7848
|
/**
|
|
7769
7849
|
* Visual lines with real canvas geometry, rebuilt by {@link applyLayout}
|
|
7770
7850
|
* exactly when `this.nodes` changes.
|
|
@@ -7776,9 +7856,9 @@ var TextEntity = (_class16 = class extends _chunkPOPXUPKRjs.Entity {
|
|
|
7776
7856
|
* ~0.35 em per line for a 24 px font, Firefox). Per-line carriers pin the DOM
|
|
7777
7857
|
* baseline to the canvas baseline by construction, same as `ui/Text`.
|
|
7778
7858
|
*/
|
|
7779
|
-
|
|
7859
|
+
__init198() {this.projectionLines = []}
|
|
7780
7860
|
constructor(text, atlas, maxWidth, fontSize = 24) {
|
|
7781
|
-
super();_class16.prototype.
|
|
7861
|
+
super();_class16.prototype.__init191.call(this);_class16.prototype.__init192.call(this);_class16.prototype.__init193.call(this);_class16.prototype.__init194.call(this);_class16.prototype.__init195.call(this);_class16.prototype.__init196.call(this);_class16.prototype.__init197.call(this);_class16.prototype.__init198.call(this);;
|
|
7782
7862
|
this.text = text;
|
|
7783
7863
|
this.atlas = atlas;
|
|
7784
7864
|
this.fontSize = fontSize;
|
|
@@ -7957,15 +8037,15 @@ var TextEntity = (_class16 = class extends _chunkPOPXUPKRjs.Entity {
|
|
|
7957
8037
|
// src/components/GridTextEntity.ts
|
|
7958
8038
|
var GridTextEntity = (_class17 = class extends _chunkPOPXUPKRjs.Entity {
|
|
7959
8039
|
|
|
7960
|
-
|
|
7961
|
-
|
|
8040
|
+
__init199() {this.fillStyle = "#ffffff"}
|
|
8041
|
+
__init200() {this.grid = []}
|
|
7962
8042
|
// Array of rows
|
|
7963
|
-
|
|
7964
|
-
|
|
8043
|
+
__init201() {this.cols = 0}
|
|
8044
|
+
__init202() {this.rows = 0}
|
|
7965
8045
|
|
|
7966
8046
|
|
|
7967
8047
|
constructor(_atlas, fontSize = 10) {
|
|
7968
|
-
super();_class17.prototype.
|
|
8048
|
+
super();_class17.prototype.__init199.call(this);_class17.prototype.__init200.call(this);_class17.prototype.__init201.call(this);_class17.prototype.__init202.call(this);;
|
|
7969
8049
|
this.fontSize = fontSize;
|
|
7970
8050
|
this.charWidth = fontSize * 1;
|
|
7971
8051
|
this.charHeight = fontSize * 1.1;
|
|
@@ -7974,7 +8054,7 @@ var GridTextEntity = (_class17 = class extends _chunkPOPXUPKRjs.Entity {
|
|
|
7974
8054
|
updateGrid(ascii) {
|
|
7975
8055
|
this.grid = ascii;
|
|
7976
8056
|
this.rows = ascii.length;
|
|
7977
|
-
this.cols = ascii.reduce((widest, row) => Math.max(widest, _nullishCoalesce(_optionalChain([row, 'optionalAccess',
|
|
8057
|
+
this.cols = ascii.reduce((widest, row) => Math.max(widest, _nullishCoalesce(_optionalChain([row, 'optionalAccess', _193 => _193.length]), () => ( 0))), 0);
|
|
7978
8058
|
}
|
|
7979
8059
|
isPointInside(_globalX, _globalY) {
|
|
7980
8060
|
return false;
|
|
@@ -8057,17 +8137,17 @@ var SplineEntity = (_class18 = class extends _chunkPOPXUPKRjs.Entity {
|
|
|
8057
8137
|
|
|
8058
8138
|
|
|
8059
8139
|
|
|
8060
|
-
|
|
8061
|
-
|
|
8140
|
+
__init203() {this.offscreen = null}
|
|
8141
|
+
__init204() {this.baked = false}
|
|
8062
8142
|
/** Logical (CSS-pixel) size of the baked bitmap — the blit destination size. */
|
|
8063
|
-
|
|
8064
|
-
|
|
8143
|
+
__init205() {this.bakedWidth = 0}
|
|
8144
|
+
__init206() {this.bakedHeight = 0}
|
|
8065
8145
|
/**
|
|
8066
8146
|
* Device-pixel ratio the bitmap was rasterized at. Tracked so a DPR change
|
|
8067
8147
|
* (browser zoom, a monitor move, a renderer whose clamp changed) re-bakes
|
|
8068
8148
|
* instead of blitting a bitmap at the wrong device density forever.
|
|
8069
8149
|
*/
|
|
8070
|
-
|
|
8150
|
+
__init207() {this.bakedDPR = 0}
|
|
8071
8151
|
/**
|
|
8072
8152
|
* Gradient strokes can't be baked to a solid-color bitmap; they render
|
|
8073
8153
|
* per-frame. Derived from `_doc`, so it is NOT readonly — assigning a new
|
|
@@ -8075,7 +8155,7 @@ var SplineEntity = (_class18 = class extends _chunkPOPXUPKRjs.Entity {
|
|
|
8075
8155
|
*/
|
|
8076
8156
|
|
|
8077
8157
|
/** Lazily-flattened polylines (one Float32Array of [x,y,...] per segment) for hit-testing. */
|
|
8078
|
-
|
|
8158
|
+
__init208() {this.polylines = null}
|
|
8079
8159
|
/**
|
|
8080
8160
|
* The spline document to render. Assigning a new document invalidates all
|
|
8081
8161
|
* caches (baked canvas, flattened polylines, bounds).
|
|
@@ -8109,9 +8189,9 @@ var SplineEntity = (_class18 = class extends _chunkPOPXUPKRjs.Entity {
|
|
|
8109
8189
|
* local bounds after painting the curves. Useful for drag feedback and
|
|
8110
8190
|
* debugging hit areas. Defaults to `false`.
|
|
8111
8191
|
*/
|
|
8112
|
-
|
|
8192
|
+
__init209() {this.showBounds = false}
|
|
8113
8193
|
constructor(doc, opts = {}) {
|
|
8114
|
-
super();_class18.prototype.
|
|
8194
|
+
super();_class18.prototype.__init203.call(this);_class18.prototype.__init204.call(this);_class18.prototype.__init205.call(this);_class18.prototype.__init206.call(this);_class18.prototype.__init207.call(this);_class18.prototype.__init208.call(this);_class18.prototype.__init209.call(this);;
|
|
8115
8195
|
this._doc = doc;
|
|
8116
8196
|
this._lineWidth = _nullishCoalesce(opts.lineWidth, () => ( 2));
|
|
8117
8197
|
this.cache = _nullishCoalesce(opts.cache, () => ( true));
|
|
@@ -8131,7 +8211,7 @@ var SplineEntity = (_class18 = class extends _chunkPOPXUPKRjs.Entity {
|
|
|
8131
8211
|
*/
|
|
8132
8212
|
computeContainsGradient() {
|
|
8133
8213
|
const isGradient = (c) => c !== null && !Array.isArray(c);
|
|
8134
|
-
return (_nullishCoalesce(_optionalChain([this, 'access',
|
|
8214
|
+
return (_nullishCoalesce(_optionalChain([this, 'access', _194 => _194._doc, 'access', _195 => _195.equations, 'optionalAccess', _196 => _196.some, 'call', _197 => _197((eq) => isGradient(eq.color_rgb))]), () => ( false))) || (_nullishCoalesce(_optionalChain([this, 'access', _198 => _198._doc, 'access', _199 => _199.paths, 'optionalAccess', _200 => _200.some, 'call', _201 => _201((p) => isGradient(p.color_rgb))]), () => ( false)));
|
|
8135
8215
|
}
|
|
8136
8216
|
/** Clear cached baked canvas and hit-test polylines. */
|
|
8137
8217
|
invalidateCache() {
|
|
@@ -8518,19 +8598,19 @@ var _math = require('@vectojs/math'); _createStarExport(_math);
|
|
|
8518
8598
|
// src/tree/DOMPortalEntity.ts
|
|
8519
8599
|
var DOMPortalEntity = (_class19 = class extends _chunkPOPXUPKRjs.Entity {
|
|
8520
8600
|
|
|
8521
|
-
|
|
8522
|
-
|
|
8523
|
-
|
|
8524
|
-
|
|
8525
|
-
|
|
8526
|
-
|
|
8527
|
-
|
|
8528
|
-
|
|
8529
|
-
|
|
8530
|
-
|
|
8531
|
-
|
|
8601
|
+
__init210() {this.isDOMPortal = true}
|
|
8602
|
+
__init211() {this.domListeners = []}
|
|
8603
|
+
__init212() {this.resizeObserver = null}
|
|
8604
|
+
__init213() {this.domBound = false}
|
|
8605
|
+
__init214() {this.cachedWidth = 100}
|
|
8606
|
+
__init215() {this.cachedHeight = 100}
|
|
8607
|
+
__init216() {this.lastWidth = ""}
|
|
8608
|
+
__init217() {this.lastHeight = ""}
|
|
8609
|
+
__init218() {this.lastTransform = ""}
|
|
8610
|
+
__init219() {this.lastZIndex = ""}
|
|
8611
|
+
__init220() {this.lastOpacity = ""}
|
|
8532
8612
|
constructor(domElement, width, height, id) {
|
|
8533
|
-
super(id);_class19.prototype.
|
|
8613
|
+
super(id);_class19.prototype.__init210.call(this);_class19.prototype.__init211.call(this);_class19.prototype.__init212.call(this);_class19.prototype.__init213.call(this);_class19.prototype.__init214.call(this);_class19.prototype.__init215.call(this);_class19.prototype.__init216.call(this);_class19.prototype.__init217.call(this);_class19.prototype.__init218.call(this);_class19.prototype.__init219.call(this);_class19.prototype.__init220.call(this);;
|
|
8534
8614
|
this.domElement = domElement;
|
|
8535
8615
|
this.width = _nullishCoalesce(width, () => ( 0));
|
|
8536
8616
|
this.height = _nullishCoalesce(height, () => ( 0));
|
|
@@ -8642,8 +8722,8 @@ var DOMPortalEntity = (_class19 = class extends _chunkPOPXUPKRjs.Entity {
|
|
|
8642
8722
|
}, _class19);
|
|
8643
8723
|
|
|
8644
8724
|
// src/index.ts
|
|
8645
|
-
Scene.registerWebGLPointRendererCreator(
|
|
8646
|
-
Scene.registerWebGPUParticleSystemManager(
|
|
8725
|
+
Scene.registerWebGLPointRendererCreator(_chunkBKXERWADjs.createWebGLPointRenderer);
|
|
8726
|
+
Scene.registerWebGPUParticleSystemManager(_chunkBKXERWADjs.WebGPUParticleSystemManager);
|
|
8647
8727
|
|
|
8648
8728
|
|
|
8649
8729
|
|
|
@@ -8692,4 +8772,4 @@ Scene.registerWebGPUParticleSystemManager(_chunkKRUDTGNRjs.WebGPUParticleSystemM
|
|
|
8692
8772
|
|
|
8693
8773
|
|
|
8694
8774
|
|
|
8695
|
-
exports.CanvasRenderer =
|
|
8775
|
+
exports.CanvasRenderer = _chunkBKXERWADjs.CanvasRenderer; exports.Circle = Circle; exports.ComputeParticleEntity = ComputeParticleEntity; exports.DEFAULT_CONTENT_SEMANTIC_BUDGET = DEFAULT_CONTENT_SEMANTIC_BUDGET; exports.DOMPortalEntity = DOMPortalEntity; exports.Entity = _chunkPOPXUPKRjs.Entity; exports.GlyphRasterAtlas = _chunkBKXERWADjs.GlyphRasterAtlas; exports.GridTextEntity = GridTextEntity; exports.Group = Group; exports.KEYBOARD_OWNING_ROLES = KEYBOARD_OWNING_ROLES; exports.MSDFTextEntity = _chunkPOPXUPKRjs.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.SCENE_OPTION_KEYS = SCENE_OPTION_KEYS; exports.SVGEntity = _chunkPOPXUPKRjs.SVGEntity; exports.SVGRenderer = _chunkBKXERWADjs.SVGRenderer; exports.Scene = Scene; exports.SplineEntity = SplineEntity; exports.TextEntity = TextEntity; exports.TextRasterCache = _chunkBKXERWADjs.TextRasterCache; exports.VECTO_USER_TIMING = VECTO_USER_TIMING; exports.VectoJSEvent = _chunkPOPXUPKRjs.VectoJSEvent; exports.WebGPUParticleSystemManager = _chunkBKXERWADjs.WebGPUParticleSystemManager; exports.beginVectoUserTiming = beginVectoUserTiming; exports.contentLineInHint = _chunkPOPXUPKRjs.contentLineInHint; exports.createWebGLPointRenderer = _chunkBKXERWADjs.createWebGLPointRenderer; exports.endVectoUserTiming = endVectoUserTiming; exports.installRendererDevTraps = _chunkBKXERWADjs.installRendererDevTraps; exports.isRendererDevMode = _chunkBKXERWADjs.isRendererDevMode; exports.isSafeUrl = _chunkBKXERWADjs.isSafeUrl; exports.loadSpline = loadSpline; exports.measureVectoUserTiming = measureVectoUserTiming; exports.normalizeChord = normalizeChord; exports.ownsKeyboard = ownsKeyboard; exports.parseColorToRGBA = _chunkBKXERWADjs.parseColorToRGBA; exports.polySegmentToBezier = polySegmentToBezier; exports.sanitizeUrl = _chunkBKXERWADjs.sanitizeUrl; exports.setRendererDevMode = _chunkBKXERWADjs.setRendererDevMode;
|
package/dist/index.mjs
CHANGED
|
@@ -11,7 +11,7 @@ import {
|
|
|
11
11
|
parseColorToRGBA,
|
|
12
12
|
sanitizeUrl,
|
|
13
13
|
setRendererDevMode
|
|
14
|
-
} from "./chunk-
|
|
14
|
+
} from "./chunk-AISSDI6U.mjs";
|
|
15
15
|
import {
|
|
16
16
|
Entity,
|
|
17
17
|
MSDFTextEntity,
|
|
@@ -1069,8 +1069,11 @@ var CanvasGeometry = class {
|
|
|
1069
1069
|
/** Effective device pixel ratio, matching CanvasRenderer: real DPR clamped to
|
|
1070
1070
|
* `maxDPR` when set. */
|
|
1071
1071
|
effectiveDPR(maxDPR) {
|
|
1072
|
-
const
|
|
1073
|
-
|
|
1072
|
+
const raw = typeof window !== "undefined" ? window.devicePixelRatio : 1;
|
|
1073
|
+
const real = Number.isFinite(raw) && raw > 0 ? raw : 1;
|
|
1074
|
+
if (maxDPR === void 0) return real;
|
|
1075
|
+
if (!Number.isFinite(maxDPR) || maxDPR <= 0) return real;
|
|
1076
|
+
return Math.min(real, maxDPR);
|
|
1074
1077
|
}
|
|
1075
1078
|
/** Size the WebGPU particle canvas: backing store at logical × DPR, CSS box at
|
|
1076
1079
|
* the logical size. Sizing the backing store in logical px (the old
|
|
@@ -4178,6 +4181,8 @@ var Scene = class _Scene {
|
|
|
4178
4181
|
* this an embedded canvas stayed at its initial size forever. */
|
|
4179
4182
|
canvasResizeObserver = null;
|
|
4180
4183
|
dprChangeHandler = null;
|
|
4184
|
+
dprPollInterval = null;
|
|
4185
|
+
lastDpr = 1;
|
|
4181
4186
|
// --- domain: a11y-projection — focus, overlay geometry, DOM ordering, portals ---
|
|
4182
4187
|
focusedA11yElement = null;
|
|
4183
4188
|
/**
|
|
@@ -4932,8 +4937,13 @@ var Scene = class _Scene {
|
|
|
4932
4937
|
this.width = styleWidth ?? (canvas.width || canvas.clientWidth || 0);
|
|
4933
4938
|
this.height = styleHeight ?? (canvas.height || canvas.clientHeight || 0);
|
|
4934
4939
|
} else {
|
|
4935
|
-
|
|
4936
|
-
|
|
4940
|
+
if (typeof canvas.isConnected === "boolean" && !canvas.isConnected) {
|
|
4941
|
+
this.width = 0;
|
|
4942
|
+
this.height = 0;
|
|
4943
|
+
} else {
|
|
4944
|
+
this.width = typeof window !== "undefined" ? window.innerWidth : canvas.clientWidth || canvas.width || 800;
|
|
4945
|
+
this.height = typeof window !== "undefined" ? window.innerHeight : canvas.clientHeight || canvas.height || 600;
|
|
4946
|
+
}
|
|
4937
4947
|
}
|
|
4938
4948
|
const globalProcess = typeof globalThis !== "undefined" ? globalThis.process : void 0;
|
|
4939
4949
|
const isTest = globalProcess && (globalProcess.env?.NODE_ENV === "test" || globalProcess.env?.VITEST === "true");
|
|
@@ -5165,16 +5175,52 @@ var Scene = class _Scene {
|
|
|
5165
5175
|
if (this.dprMediaQuery && this.dprChangeHandler) {
|
|
5166
5176
|
this.dprMediaQuery.removeEventListener?.("change", this.dprChangeHandler);
|
|
5167
5177
|
}
|
|
5168
|
-
const
|
|
5178
|
+
const raw = window.devicePixelRatio;
|
|
5179
|
+
const dpr = Number.isFinite(raw) && raw > 0 ? raw : 1;
|
|
5169
5180
|
const query = window.matchMedia(`(resolution: ${dpr}dppx)`);
|
|
5170
5181
|
const handler = () => {
|
|
5171
|
-
|
|
5172
|
-
|
|
5182
|
+
const curRaw = window.devicePixelRatio;
|
|
5183
|
+
const cur = Number.isFinite(curRaw) && curRaw > 0 ? curRaw : 1;
|
|
5184
|
+
if (Math.abs(cur - dpr) <= 1e-3) {
|
|
5185
|
+
this.watchDevicePixelRatio();
|
|
5186
|
+
return;
|
|
5187
|
+
}
|
|
5188
|
+
this.lastDpr = cur;
|
|
5189
|
+
try {
|
|
5190
|
+
this.resize(this.width, this.height);
|
|
5191
|
+
} catch (err) {
|
|
5192
|
+
console.warn("[VectoJS] DPR resize failed", err);
|
|
5193
|
+
}
|
|
5194
|
+
try {
|
|
5195
|
+
if (this.renderer.isContextLost?.() !== true) this.render(this.renderer);
|
|
5196
|
+
} catch (err) {
|
|
5197
|
+
console.warn("[VectoJS] DPR repaint failed", err);
|
|
5198
|
+
}
|
|
5173
5199
|
this.watchDevicePixelRatio();
|
|
5174
5200
|
};
|
|
5175
5201
|
query.addEventListener?.("change", handler);
|
|
5176
5202
|
this.dprMediaQuery = query;
|
|
5177
5203
|
this.dprChangeHandler = handler;
|
|
5204
|
+
this.lastDpr = dpr;
|
|
5205
|
+
if (this.dprPollInterval === null && typeof setInterval === "function") {
|
|
5206
|
+
this.dprPollInterval = setInterval(() => {
|
|
5207
|
+
const rawPoll = window.devicePixelRatio;
|
|
5208
|
+
const curPoll = Number.isFinite(rawPoll) && rawPoll > 0 ? rawPoll : 1;
|
|
5209
|
+
if (Math.abs(curPoll - this.lastDpr) <= 1e-3) return;
|
|
5210
|
+
this.lastDpr = curPoll;
|
|
5211
|
+
try {
|
|
5212
|
+
this.resize(this.width, this.height);
|
|
5213
|
+
} catch (err) {
|
|
5214
|
+
console.warn("[VectoJS] DPR poll resize failed", err);
|
|
5215
|
+
}
|
|
5216
|
+
try {
|
|
5217
|
+
if (this.renderer.isContextLost?.() !== true) this.render(this.renderer);
|
|
5218
|
+
} catch (err) {
|
|
5219
|
+
console.warn("[VectoJS] DPR poll repaint failed", err);
|
|
5220
|
+
}
|
|
5221
|
+
this.watchDevicePixelRatio();
|
|
5222
|
+
}, 1e3);
|
|
5223
|
+
}
|
|
5178
5224
|
}
|
|
5179
5225
|
/**
|
|
5180
5226
|
* Recover the WebGL point layer from a GPU context loss (driver TDR reset,
|
|
@@ -5208,6 +5254,35 @@ var Scene = class _Scene {
|
|
|
5208
5254
|
gl.addEventListener("webglcontextlost", this.glContextLostHandler);
|
|
5209
5255
|
gl.addEventListener("webglcontextrestored", this.glContextRestoredHandler);
|
|
5210
5256
|
}
|
|
5257
|
+
/**
|
|
5258
|
+
* One-shot adoption of the window viewport once an initially-detached canvas
|
|
5259
|
+
* gains layout (#817). A full-window scene constructed before its canvas is
|
|
5260
|
+
* attached starts at 0×0, and no window `resize` fires on attachment — so
|
|
5261
|
+
* without this latch the scene would stay unsized forever. The first nonzero
|
|
5262
|
+
* layout box adopts `window.innerWidth/innerHeight` (the same sizing the
|
|
5263
|
+
* window resize handler applies, keeping the full-window contract), then the
|
|
5264
|
+
* observer disconnects: steady-state sizing stays exactly as if the canvas
|
|
5265
|
+
* had been attached before construction. An explicit user `resize()` between
|
|
5266
|
+
* construction and attachment is respected and skips adoption.
|
|
5267
|
+
*
|
|
5268
|
+
* No-op when the scene already has a size (attached at construction) or when
|
|
5269
|
+
* `ResizeObserver` is unavailable (the caller then drives sizing explicitly).
|
|
5270
|
+
*/
|
|
5271
|
+
armAttachmentViewportLatch() {
|
|
5272
|
+
if (this.width > 0 && this.height > 0) return;
|
|
5273
|
+
if (typeof ResizeObserver === "undefined") return;
|
|
5274
|
+
const observer = new ResizeObserver((entries) => {
|
|
5275
|
+
const box = entries[0]?.contentRect;
|
|
5276
|
+
if (!box || !(box.width > 0) || !(box.height > 0)) return;
|
|
5277
|
+
observer.disconnect();
|
|
5278
|
+
this.canvasResizeObserver = null;
|
|
5279
|
+
if (this.width === 0 || this.height === 0) {
|
|
5280
|
+
this.resize(window.innerWidth, window.innerHeight);
|
|
5281
|
+
}
|
|
5282
|
+
});
|
|
5283
|
+
this.canvasResizeObserver = observer;
|
|
5284
|
+
observer.observe(this.canvas);
|
|
5285
|
+
}
|
|
5211
5286
|
// --- domain: scene-facade — renderer accessor ---
|
|
5212
5287
|
/**
|
|
5213
5288
|
* Expose the underlying {@link IRenderer} for advanced direct-draw operations.
|
|
@@ -5393,6 +5468,10 @@ var Scene = class _Scene {
|
|
|
5393
5468
|
this.dprMediaQuery = null;
|
|
5394
5469
|
this.dprChangeHandler = null;
|
|
5395
5470
|
}
|
|
5471
|
+
if (this.dprPollInterval !== null) {
|
|
5472
|
+
clearInterval(this.dprPollInterval);
|
|
5473
|
+
this.dprPollInterval = null;
|
|
5474
|
+
}
|
|
5396
5475
|
if (this.forcedColorsQuery && this.forcedColorsChangeHandler) {
|
|
5397
5476
|
this.forcedColorsQuery.removeEventListener?.("change", this.forcedColorsChangeHandler);
|
|
5398
5477
|
this.forcedColorsQuery = null;
|
|
@@ -5466,6 +5545,7 @@ var Scene = class _Scene {
|
|
|
5466
5545
|
setupEvents() {
|
|
5467
5546
|
if (typeof window !== "undefined" && !this.disableWindowResize) {
|
|
5468
5547
|
window.addEventListener("resize", this.resizeHandler);
|
|
5548
|
+
this.armAttachmentViewportLatch();
|
|
5469
5549
|
} else if (this.disableWindowResize && typeof ResizeObserver !== "undefined" && this.canvas && typeof this.canvas.getBoundingClientRect === "function") {
|
|
5470
5550
|
this.canvasResizeObserver = new ResizeObserver((entries) => {
|
|
5471
5551
|
const entry = entries[0];
|
package/dist/renderer.js
CHANGED
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
|
|
11
11
|
|
|
12
12
|
|
|
13
|
-
var
|
|
13
|
+
var _chunkBKXERWADjs = require('./chunk-BKXERWAD.js');
|
|
14
14
|
|
|
15
15
|
|
|
16
16
|
|
|
@@ -22,4 +22,4 @@ var _chunkKRUDTGNRjs = require('./chunk-KRUDTGNR.js');
|
|
|
22
22
|
|
|
23
23
|
|
|
24
24
|
|
|
25
|
-
exports.CanvasRenderer =
|
|
25
|
+
exports.CanvasRenderer = _chunkBKXERWADjs.CanvasRenderer; exports.GlyphRasterAtlas = _chunkBKXERWADjs.GlyphRasterAtlas; exports.SVGRenderer = _chunkBKXERWADjs.SVGRenderer; exports.TextRasterCache = _chunkBKXERWADjs.TextRasterCache; exports.WebGPUParticleSystemManager = _chunkBKXERWADjs.WebGPUParticleSystemManager; exports.createWebGLPointRenderer = _chunkBKXERWADjs.createWebGLPointRenderer; exports.installRendererDevTraps = _chunkBKXERWADjs.installRendererDevTraps; exports.isRendererDevMode = _chunkBKXERWADjs.isRendererDevMode; exports.parseColorToRGBA = _chunkBKXERWADjs.parseColorToRGBA; exports.setRendererDevMode = _chunkBKXERWADjs.setRendererDevMode;
|
package/dist/renderer.mjs
CHANGED
package/dist/tree/Scene.d.ts
CHANGED
|
@@ -603,6 +603,8 @@ export declare class Scene {
|
|
|
603
603
|
* this an embedded canvas stayed at its initial size forever. */
|
|
604
604
|
private canvasResizeObserver;
|
|
605
605
|
private dprChangeHandler;
|
|
606
|
+
private dprPollInterval;
|
|
607
|
+
private lastDpr;
|
|
606
608
|
private focusedA11yElement;
|
|
607
609
|
/**
|
|
608
610
|
* Canvas box geometry: the CSS↔logical mapping, overlay layer alignment, and
|
|
@@ -1155,6 +1157,21 @@ export declare class Scene {
|
|
|
1155
1157
|
* on the same canvas, restore DPR/size, and repaint.
|
|
1156
1158
|
*/
|
|
1157
1159
|
private setupGLContextRecovery;
|
|
1160
|
+
/**
|
|
1161
|
+
* One-shot adoption of the window viewport once an initially-detached canvas
|
|
1162
|
+
* gains layout (#817). A full-window scene constructed before its canvas is
|
|
1163
|
+
* attached starts at 0×0, and no window `resize` fires on attachment — so
|
|
1164
|
+
* without this latch the scene would stay unsized forever. The first nonzero
|
|
1165
|
+
* layout box adopts `window.innerWidth/innerHeight` (the same sizing the
|
|
1166
|
+
* window resize handler applies, keeping the full-window contract), then the
|
|
1167
|
+
* observer disconnects: steady-state sizing stays exactly as if the canvas
|
|
1168
|
+
* had been attached before construction. An explicit user `resize()` between
|
|
1169
|
+
* construction and attachment is respected and skips adoption.
|
|
1170
|
+
*
|
|
1171
|
+
* No-op when the scene already has a size (attached at construction) or when
|
|
1172
|
+
* `ResizeObserver` is unavailable (the caller then drives sizing explicitly).
|
|
1173
|
+
*/
|
|
1174
|
+
private armAttachmentViewportLatch;
|
|
1158
1175
|
/**
|
|
1159
1176
|
* Expose the underlying {@link IRenderer} for advanced direct-draw operations.
|
|
1160
1177
|
*
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vectojs/core",
|
|
3
|
-
"version": "1.39.
|
|
3
|
+
"version": "1.39.1",
|
|
4
4
|
"publishConfig": {
|
|
5
5
|
"access": "public"
|
|
6
6
|
},
|
|
@@ -71,11 +71,11 @@
|
|
|
71
71
|
},
|
|
72
72
|
"devDependencies": {
|
|
73
73
|
"@guidepup/virtual-screen-reader": "0.32.1",
|
|
74
|
-
"@vitest/coverage-v8": "^4.1.
|
|
74
|
+
"@vitest/coverage-v8": "^4.1.11",
|
|
75
75
|
"esbuild": "^0.28.1",
|
|
76
76
|
"jsdom": "^30.0.1",
|
|
77
|
-
"puppeteer-core": "^25.
|
|
77
|
+
"puppeteer-core": "^25.8.0",
|
|
78
78
|
"tsup": "^8.3.5",
|
|
79
|
-
"vitest": "^4.1.
|
|
79
|
+
"vitest": "^4.1.11"
|
|
80
80
|
}
|
|
81
81
|
}
|