@vectojs/core 1.27.1 → 1.28.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/dist/index.js CHANGED
@@ -2002,10 +2002,20 @@ var Scene = (_class7 = class _Scene {
2002
2002
  __init82() {this.activeIds = /* @__PURE__ */ new Set()}
2003
2003
  /** Per-parent insertion cursor, reused by `enforceA11yDomOrder`. */
2004
2004
  __init83() {this.a11yOrderCursors = /* @__PURE__ */ new Map()}
2005
- __init84() {this.activePortalsThisFrame = /* @__PURE__ */ new Set()}
2006
- __init85() {this.activePortalsPrevFrame = /* @__PURE__ */ new Set()}
2007
- __init86() {this.portalEntities = /* @__PURE__ */ new Map()}
2008
- __init87() {this.renderOrderCounter = 0}
2005
+ /** Membership set for the elements being ordered, reused per reorder pass. */
2006
+ __init84() {this.a11yOrderMembers = /* @__PURE__ */ new Set()}
2007
+ /**
2008
+ * Elements that are an *ancestor* of another ordered element, reused per pass.
2009
+ *
2010
+ * A composite widget's container (a `grid` around its rows, a `tree` around its
2011
+ * items) spans every descendant row, so it must not extend a visual row band —
2012
+ * see {@link sortNormalElementsVisually}.
2013
+ */
2014
+ __init85() {this.a11yOrderContainers = /* @__PURE__ */ new Set()}
2015
+ __init86() {this.activePortalsThisFrame = /* @__PURE__ */ new Set()}
2016
+ __init87() {this.activePortalsPrevFrame = /* @__PURE__ */ new Set()}
2017
+ __init88() {this.portalEntities = /* @__PURE__ */ new Map()}
2018
+ __init89() {this.renderOrderCounter = 0}
2009
2019
  /**
2010
2020
  * Monotonic render-frame counter, bumped once per authoritative `render()`
2011
2021
  * pass. Entities stamp their per-frame world-matrix cache with this value and
@@ -2014,7 +2024,7 @@ var Scene = (_class7 = class _Scene {
2014
2024
  * back to the ancestor walk. Public for the same reason `Entity._getTrig`/
2015
2025
  * `_setWorldCache` are: it is a cross-class render-internal contract.
2016
2026
  */
2017
- __init88() {this.currentFrame = 0}
2027
+ __init90() {this.currentFrame = 0}
2018
2028
  // ── WASM transform backend (invisible accelerator) ──────────────────────────
2019
2029
  // When `_transformBackend === 'wasm'`, the main render walk sources each
2020
2030
  // entity's world matrix from an SoA store composed by `_wasm` (see
@@ -2022,24 +2032,24 @@ var Scene = (_class7 = class _Scene {
2022
2032
  // fallback and the default: a null backend, a non-main renderer, or any entity
2023
2033
  // absent from the store all fall back to the JS composition, so WASM can only
2024
2034
  // ever change *how fast* a world matrix is produced, never *what* it is.
2025
- __init89() {this._wasm = null}
2026
- __init90() {this._transformBackend = "js"}
2035
+ __init91() {this._wasm = null}
2036
+ __init92() {this._transformBackend = "js"}
2027
2037
  // Resident store state (Stage 3). The store layout — slot assignment + sibling
2028
2038
  // runs — depends only on tree TOPOLOGY, so it is rebuilt only when the
2029
2039
  // structure changes (add/remove/reparent bump `_structureVersion`). Between
2030
2040
  // rebuilds the per-frame cost is: gather each entity's transform into the
2031
2041
  // resident wasm input view + run the kernel — no reallocation, no readback.
2032
- __init91() {this._treeStore = null}
2033
- __init92() {this._slotEntity = []}
2042
+ __init93() {this._treeStore = null}
2043
+ __init94() {this._slotEntity = []}
2034
2044
  // store slot -> entity (also validates slots)
2035
- __init93() {this._wasmInputs = null}
2036
- __init94() {this._wasmWorld = null}
2037
- __init95() {this._structureVersion = 0}
2038
- __init96() {this._storeStructureVersion = -1}
2045
+ __init95() {this._wasmInputs = null}
2046
+ __init96() {this._wasmWorld = null}
2047
+ __init97() {this._structureVersion = 0}
2048
+ __init98() {this._storeStructureVersion = -1}
2039
2049
  // Cached list of ComputeParticleEntity instances in the tree, keyed by the
2040
2050
  // structure version it was gathered at. Rebuilt only on a topology change.
2041
- __init97() {this._computeEntities = []}
2042
- __init98() {this._computeEntitiesVersion = -1}
2051
+ __init99() {this._computeEntities = []}
2052
+ __init100() {this._computeEntitiesVersion = -1}
2043
2053
  /** Invalidate the resident WASM store layout; the next wasm-mode frame rebuilds
2044
2054
  * it. Called by `Entity.add`/`remove` (topology changes only). */
2045
2055
  markStructureChanged() {
@@ -2124,7 +2134,7 @@ var Scene = (_class7 = class _Scene {
2124
2134
  * cached globally; the instance is per-Scene, which is the isolation that
2125
2135
  * actually matters.
2126
2136
  */
2127
- __init99() {this._wasmRuntime = null}
2137
+ __init101() {this._wasmRuntime = null}
2128
2138
  /**
2129
2139
  * Load (or reuse) this Scene's shared WASM runtime.
2130
2140
  *
@@ -2152,30 +2162,30 @@ var Scene = (_class7 = class _Scene {
2152
2162
  get wasmRuntime() {
2153
2163
  return this._wasmRuntime;
2154
2164
  }
2155
- __init100() {this._hitWasm = null}
2165
+ __init102() {this._hitWasm = null}
2156
2166
  // Cache key: which frame + structure version the grid was last (successfully,
2157
2167
  // non-overflowing) built for. findEntityAt is called ad-hoc (pointer
2158
2168
  // hover/click), not every frame, so the grid is refreshed lazily on demand
2159
2169
  // rather than proactively every render() — unlike the transform store, which
2160
2170
  // every frame's draw depends on.
2161
- __init101() {this._hitGridFrame = -1}
2162
- __init102() {this._hitGridOk = false}
2163
- __init103() {this._hitSlotEntity = []}
2164
- __init104() {this._hitBoundless = []}
2171
+ __init103() {this._hitGridFrame = -1}
2172
+ __init104() {this._hitGridOk = false}
2173
+ __init105() {this._hitSlotEntity = []}
2174
+ __init106() {this._hitBoundless = []}
2165
2175
  /** Reused buffer for the fused gather, so a pointer query allocates nothing. */
2166
- __init105() {this._hitGatherBuffer = null}
2176
+ __init107() {this._hitGatherBuffer = null}
2167
2177
  /**
2168
2178
  * Whether the last grid build sourced its AABBs from the WASM transform store
2169
2179
  * rather than recomputing them in JS. Diagnostic only — both paths must
2170
2180
  * produce the same entity for a given point.
2171
2181
  */
2172
- __init106() {this._hitFusedGather = false}
2182
+ __init108() {this._hitFusedGather = false}
2173
2183
  /**
2174
2184
  * Whether `compute_aabbs` has run against the current frame's world matrices.
2175
2185
  * The AABB pass is only meaningful after a `compose_*`, so the fused gather
2176
2186
  * must not read the views before then.
2177
2187
  */
2178
- __init107() {this._wasmAabbsFresh = false}
2188
+ __init109() {this._wasmAabbsFresh = false}
2179
2189
  /** Did the last hit-grid build use the fused (WASM-store) gather? */
2180
2190
  get hitGatherPath() {
2181
2191
  return this._hitFusedGather ? "fused" : "js";
@@ -2184,9 +2194,9 @@ var Scene = (_class7 = class _Scene {
2184
2194
  * Why the transform accelerator did or did not run on the most recent frame.
2185
2195
  * Written by the render walk and `_syncWasmStore`.
2186
2196
  */
2187
- __init108() {this._transformReason = "not-installed"}
2197
+ __init110() {this._transformReason = "not-installed"}
2188
2198
  /** Why the batched-driver accelerator did or did not run. */
2189
- __init109() {this._animReason = "not-installed"}
2199
+ __init111() {this._animReason = "not-installed"}
2190
2200
  /**
2191
2201
  * Why the hit-test accelerator did or did not serve the last pointer query.
2192
2202
  * The grid is built lazily on demand, not every frame, so this describes the
@@ -2194,11 +2204,11 @@ var Scene = (_class7 = class _Scene {
2194
2204
  * before a backend exists; `_ensureHitGrid` moves it to `'not-applicable'`
2195
2205
  * once one is installed but nothing has queried yet.
2196
2206
  */
2197
- __init110() {this._hitReason = "not-installed"}
2207
+ __init112() {this._hitReason = "not-installed"}
2198
2208
  /** Why the particle accelerator did or did not run. */
2199
- __init111() {this._particleReason = "not-applicable"}
2209
+ __init113() {this._particleReason = "not-applicable"}
2200
2210
  /** Which particle implementation actually simulated the most recent frame. */
2201
- __init112() {this._particlePath = "none"}
2211
+ __init114() {this._particlePath = "none"}
2202
2212
  /**
2203
2213
  * Per-frame status of every invisible accelerator: whether each is installed,
2204
2214
  * whether it actually ran on the most recent frame, and why.
@@ -2358,25 +2368,25 @@ var Scene = (_class7 = class _Scene {
2358
2368
  // EasingFn (which cannot cross into WASM) all fall through to it — WASM can
2359
2369
  // only ever change *how* a driver is advanced, never *what* value it lands
2360
2370
  // on.
2361
- __init113() {this._animWasm = null}
2371
+ __init115() {this._animWasm = null}
2362
2372
  // Entities with at least one active driver, added by Entity._spawnDriver.
2363
2373
  // Self-pruning: _tickBatchedDrivers drops an entry the first time it visits
2364
2374
  // an entity whose drivers have since all completed or been removed. This is
2365
2375
  // what lets the batch pass find its candidates in O(active drivers), not
2366
2376
  // O(tree size) — the exact mistake G3's first integrated benchmark made.
2367
- __init114() {this._activeDriverEntities = /* @__PURE__ */ new Set()}
2377
+ __init116() {this._activeDriverEntities = /* @__PURE__ */ new Set()}
2368
2378
  // Reused across frames instead of allocating a fresh array + N {entity,prop,
2369
2379
  // driver} objects every call — the integrated benchmark
2370
2380
  // (benchmarks/anim-wasm-scene) found that allocation churn was the
2371
2381
  // dominant integrated cost, not the wasm kernel itself. Parallel arrays,
2372
2382
  // truncated to the live count after each use so a stale tail slot never
2373
2383
  // pins a no-longer-active entity/driver in memory.
2374
- __init115() {this._springEntities = []}
2375
- __init116() {this._springProps = []}
2376
- __init117() {this._springDrivers = []}
2377
- __init118() {this._tweenEntities = []}
2378
- __init119() {this._tweenProps = []}
2379
- __init120() {this._tweenDrivers = []}
2384
+ __init117() {this._springEntities = []}
2385
+ __init118() {this._springProps = []}
2386
+ __init119() {this._springDrivers = []}
2387
+ __init120() {this._tweenEntities = []}
2388
+ __init121() {this._tweenProps = []}
2389
+ __init122() {this._tweenDrivers = []}
2380
2390
  /**
2381
2391
  * Minimum number of batchable (spring, or named-easing tween) active drivers
2382
2392
  * before a frame engages the WASM batch path at all; below it, every driver
@@ -2448,7 +2458,7 @@ var Scene = (_class7 = class _Scene {
2448
2458
  * Setting {@link animDriverGateCount} overwrites all three, so existing code
2449
2459
  * that tuned the single knob keeps working unchanged.
2450
2460
  */
2451
- __init121() {this._animBatchedLastFrame = false}
2461
+ __init123() {this._animBatchedLastFrame = false}
2452
2462
  /**
2453
2463
  * Whether the WASM batch path actually ran on the most recent frame.
2454
2464
  *
@@ -2460,7 +2470,7 @@ var Scene = (_class7 = class _Scene {
2460
2470
  get animBatchedLastFrame() {
2461
2471
  return this._animBatchedLastFrame;
2462
2472
  }
2463
- __init122() {this.animGate = {
2473
+ __init124() {this.animGate = {
2464
2474
  spring: 128,
2465
2475
  tween: 256,
2466
2476
  mixed: 128
@@ -2498,7 +2508,7 @@ var Scene = (_class7 = class _Scene {
2498
2508
  // (benchmarks/particle-wasm). f32 (matches the WGSL shader), bit-identical to
2499
2509
  // a JS f32 reference oracle; updateCPU (f64) stays the permanent fallback when
2500
2510
  // no backend is installed or a scene runs on WebGPU.
2501
- __init123() {this._particleWasm = null}
2511
+ __init125() {this._particleWasm = null}
2502
2512
  /** Which backend runs the CPU particle simulation. Reflects only whether a
2503
2513
  * backend is installed (the WebGPU compute path, when active, is used first
2504
2514
  * regardless). */
@@ -2775,24 +2785,24 @@ var Scene = (_class7 = class _Scene {
2775
2785
  * sync, so retaining the order prevents a newly opened overlay from spending
2776
2786
  * its first frame below previously projected controls.
2777
2787
  */
2778
- __init124() {this.a11yRenderOrders = /* @__PURE__ */ new Map()}
2788
+ __init126() {this.a11yRenderOrders = /* @__PURE__ */ new Map()}
2779
2789
  // Optional WebGL point-cloud layer (see SceneOptions.pointBackend).
2780
- __init125() {this.pointRenderer = null}
2781
- __init126() {this.glCanvas = null}
2782
- __init127() {this.glContextLostHandler = null}
2783
- __init128() {this.glContextRestoredHandler = null}
2790
+ __init127() {this.pointRenderer = null}
2791
+ __init128() {this.glCanvas = null}
2792
+ __init129() {this.glContextLostHandler = null}
2793
+ __init130() {this.glContextRestoredHandler = null}
2784
2794
 
2785
2795
 
2786
2796
 
2787
- __init129() {this.disableWindowResize = false}
2797
+ __init131() {this.disableWindowResize = false}
2788
2798
  /** See {@link SceneOptions.maxDPR}. `undefined` = uncapped (real DPR). */
2789
2799
 
2790
2800
  // WebGPU properties
2791
- __init130() {this.destroyed = false}
2792
- __init131() {this.device = null}
2793
- __init132() {this.deviceLost = false}
2794
- __init133() {this.particleBackend = "auto"}
2795
- __init134() {this._webgpuDisabled = false}
2801
+ __init132() {this.destroyed = false}
2802
+ __init133() {this.device = null}
2803
+ __init134() {this.deviceLost = false}
2804
+ __init135() {this.particleBackend = "auto"}
2805
+ __init136() {this._webgpuDisabled = false}
2796
2806
  get webgpuDisabled() {
2797
2807
  return this._webgpuDisabled || this.particleBackend === "cpu";
2798
2808
  }
@@ -2820,22 +2830,22 @@ var Scene = (_class7 = class _Scene {
2820
2830
  set webgpuDisabled(value) {
2821
2831
  this._webgpuDisabled = value;
2822
2832
  }
2823
- __init135() {this.recoveryTimerId = null}
2824
- __init136() {this.manager = null}
2825
- __init137() {this.initializingWebGPU = false}
2826
- __init138() {this.gpuCanvas = null}
2827
- __init139() {this.gpuContext = null}
2833
+ __init137() {this.recoveryTimerId = null}
2834
+ __init138() {this.manager = null}
2835
+ __init139() {this.initializingWebGPU = false}
2836
+ __init140() {this.gpuCanvas = null}
2837
+ __init141() {this.gpuContext = null}
2828
2838
  /** True while the GPU canvas holds a presented particle frame (needs clearing when they leave). */
2829
- __init140() {this.gpuHasContent = false}
2830
- __init141() {this.mouseX = -9999}
2831
- __init142() {this.mouseY = -9999}
2832
- __init143() {this.pointerMoveListener = null}
2833
- __init144() {this.pointerLeaveListener = null}
2839
+ __init142() {this.gpuHasContent = false}
2840
+ __init143() {this.mouseX = -9999}
2841
+ __init144() {this.mouseY = -9999}
2842
+ __init145() {this.pointerMoveListener = null}
2843
+ __init146() {this.pointerLeaveListener = null}
2834
2844
  /** Element the pointer listeners are bound to (parent container if present,
2835
2845
  * else the canvas). Stored so `destroy()` detaches from the same element. */
2836
- __init145() {this.pointerEventTarget = null}
2837
- __init146() {this.hasWarnedZeroSize = false}
2838
- __init147() {this.fontLoadHandler = null}
2846
+ __init147() {this.pointerEventTarget = null}
2847
+ __init148() {this.hasWarnedZeroSize = false}
2848
+ __init149() {this.fontLoadHandler = null}
2839
2849
  // ── Dev-mode warning infrastructure ──────────────────────────────
2840
2850
  //
2841
2851
  // Enable with `Scene.devMode = true` or by setting `globalThis.__DEV__`.
@@ -2869,7 +2879,7 @@ var Scene = (_class7 = class _Scene {
2869
2879
  return false;
2870
2880
  }
2871
2881
 
2872
- __init148() {this._devFrameCount = 0}
2882
+ __init150() {this._devFrameCount = 0}
2873
2883
  _devWarn(message) {
2874
2884
  if (!this._devActive) return;
2875
2885
  console.warn(`[vectojs/dev] ${message}`);
@@ -2944,7 +2954,7 @@ var Scene = (_class7 = class _Scene {
2944
2954
  };
2945
2955
  walkProjections(this.root);
2946
2956
  }
2947
- constructor(canvas, options = {}) {;_class7.prototype.__init27.call(this);_class7.prototype.__init28.call(this);_class7.prototype.__init29.call(this);_class7.prototype.__init30.call(this);_class7.prototype.__init31.call(this);_class7.prototype.__init32.call(this);_class7.prototype.__init33.call(this);_class7.prototype.__init34.call(this);_class7.prototype.__init35.call(this);_class7.prototype.__init36.call(this);_class7.prototype.__init37.call(this);_class7.prototype.__init38.call(this);_class7.prototype.__init39.call(this);_class7.prototype.__init40.call(this);_class7.prototype.__init41.call(this);_class7.prototype.__init42.call(this);_class7.prototype.__init43.call(this);_class7.prototype.__init44.call(this);_class7.prototype.__init45.call(this);_class7.prototype.__init46.call(this);_class7.prototype.__init47.call(this);_class7.prototype.__init48.call(this);_class7.prototype.__init49.call(this);_class7.prototype.__init50.call(this);_class7.prototype.__init51.call(this);_class7.prototype.__init52.call(this);_class7.prototype.__init53.call(this);_class7.prototype.__init54.call(this);_class7.prototype.__init55.call(this);_class7.prototype.__init56.call(this);_class7.prototype.__init57.call(this);_class7.prototype.__init58.call(this);_class7.prototype.__init59.call(this);_class7.prototype.__init60.call(this);_class7.prototype.__init61.call(this);_class7.prototype.__init62.call(this);_class7.prototype.__init63.call(this);_class7.prototype.__init64.call(this);_class7.prototype.__init65.call(this);_class7.prototype.__init66.call(this);_class7.prototype.__init67.call(this);_class7.prototype.__init68.call(this);_class7.prototype.__init69.call(this);_class7.prototype.__init70.call(this);_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);_class7.prototype.__init81.call(this);_class7.prototype.__init82.call(this);_class7.prototype.__init83.call(this);_class7.prototype.__init84.call(this);_class7.prototype.__init85.call(this);_class7.prototype.__init86.call(this);_class7.prototype.__init87.call(this);_class7.prototype.__init88.call(this);_class7.prototype.__init89.call(this);_class7.prototype.__init90.call(this);_class7.prototype.__init91.call(this);_class7.prototype.__init92.call(this);_class7.prototype.__init93.call(this);_class7.prototype.__init94.call(this);_class7.prototype.__init95.call(this);_class7.prototype.__init96.call(this);_class7.prototype.__init97.call(this);_class7.prototype.__init98.call(this);_class7.prototype.__init99.call(this);_class7.prototype.__init100.call(this);_class7.prototype.__init101.call(this);_class7.prototype.__init102.call(this);_class7.prototype.__init103.call(this);_class7.prototype.__init104.call(this);_class7.prototype.__init105.call(this);_class7.prototype.__init106.call(this);_class7.prototype.__init107.call(this);_class7.prototype.__init108.call(this);_class7.prototype.__init109.call(this);_class7.prototype.__init110.call(this);_class7.prototype.__init111.call(this);_class7.prototype.__init112.call(this);_class7.prototype.__init113.call(this);_class7.prototype.__init114.call(this);_class7.prototype.__init115.call(this);_class7.prototype.__init116.call(this);_class7.prototype.__init117.call(this);_class7.prototype.__init118.call(this);_class7.prototype.__init119.call(this);_class7.prototype.__init120.call(this);_class7.prototype.__init121.call(this);_class7.prototype.__init122.call(this);_class7.prototype.__init123.call(this);_class7.prototype.__init124.call(this);_class7.prototype.__init125.call(this);_class7.prototype.__init126.call(this);_class7.prototype.__init127.call(this);_class7.prototype.__init128.call(this);_class7.prototype.__init129.call(this);_class7.prototype.__init130.call(this);_class7.prototype.__init131.call(this);_class7.prototype.__init132.call(this);_class7.prototype.__init133.call(this);_class7.prototype.__init134.call(this);_class7.prototype.__init135.call(this);_class7.prototype.__init136.call(this);_class7.prototype.__init137.call(this);_class7.prototype.__init138.call(this);_class7.prototype.__init139.call(this);_class7.prototype.__init140.call(this);_class7.prototype.__init141.call(this);_class7.prototype.__init142.call(this);_class7.prototype.__init143.call(this);_class7.prototype.__init144.call(this);_class7.prototype.__init145.call(this);_class7.prototype.__init146.call(this);_class7.prototype.__init147.call(this);_class7.prototype.__init148.call(this);
2957
+ constructor(canvas, options = {}) {;_class7.prototype.__init27.call(this);_class7.prototype.__init28.call(this);_class7.prototype.__init29.call(this);_class7.prototype.__init30.call(this);_class7.prototype.__init31.call(this);_class7.prototype.__init32.call(this);_class7.prototype.__init33.call(this);_class7.prototype.__init34.call(this);_class7.prototype.__init35.call(this);_class7.prototype.__init36.call(this);_class7.prototype.__init37.call(this);_class7.prototype.__init38.call(this);_class7.prototype.__init39.call(this);_class7.prototype.__init40.call(this);_class7.prototype.__init41.call(this);_class7.prototype.__init42.call(this);_class7.prototype.__init43.call(this);_class7.prototype.__init44.call(this);_class7.prototype.__init45.call(this);_class7.prototype.__init46.call(this);_class7.prototype.__init47.call(this);_class7.prototype.__init48.call(this);_class7.prototype.__init49.call(this);_class7.prototype.__init50.call(this);_class7.prototype.__init51.call(this);_class7.prototype.__init52.call(this);_class7.prototype.__init53.call(this);_class7.prototype.__init54.call(this);_class7.prototype.__init55.call(this);_class7.prototype.__init56.call(this);_class7.prototype.__init57.call(this);_class7.prototype.__init58.call(this);_class7.prototype.__init59.call(this);_class7.prototype.__init60.call(this);_class7.prototype.__init61.call(this);_class7.prototype.__init62.call(this);_class7.prototype.__init63.call(this);_class7.prototype.__init64.call(this);_class7.prototype.__init65.call(this);_class7.prototype.__init66.call(this);_class7.prototype.__init67.call(this);_class7.prototype.__init68.call(this);_class7.prototype.__init69.call(this);_class7.prototype.__init70.call(this);_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);_class7.prototype.__init81.call(this);_class7.prototype.__init82.call(this);_class7.prototype.__init83.call(this);_class7.prototype.__init84.call(this);_class7.prototype.__init85.call(this);_class7.prototype.__init86.call(this);_class7.prototype.__init87.call(this);_class7.prototype.__init88.call(this);_class7.prototype.__init89.call(this);_class7.prototype.__init90.call(this);_class7.prototype.__init91.call(this);_class7.prototype.__init92.call(this);_class7.prototype.__init93.call(this);_class7.prototype.__init94.call(this);_class7.prototype.__init95.call(this);_class7.prototype.__init96.call(this);_class7.prototype.__init97.call(this);_class7.prototype.__init98.call(this);_class7.prototype.__init99.call(this);_class7.prototype.__init100.call(this);_class7.prototype.__init101.call(this);_class7.prototype.__init102.call(this);_class7.prototype.__init103.call(this);_class7.prototype.__init104.call(this);_class7.prototype.__init105.call(this);_class7.prototype.__init106.call(this);_class7.prototype.__init107.call(this);_class7.prototype.__init108.call(this);_class7.prototype.__init109.call(this);_class7.prototype.__init110.call(this);_class7.prototype.__init111.call(this);_class7.prototype.__init112.call(this);_class7.prototype.__init113.call(this);_class7.prototype.__init114.call(this);_class7.prototype.__init115.call(this);_class7.prototype.__init116.call(this);_class7.prototype.__init117.call(this);_class7.prototype.__init118.call(this);_class7.prototype.__init119.call(this);_class7.prototype.__init120.call(this);_class7.prototype.__init121.call(this);_class7.prototype.__init122.call(this);_class7.prototype.__init123.call(this);_class7.prototype.__init124.call(this);_class7.prototype.__init125.call(this);_class7.prototype.__init126.call(this);_class7.prototype.__init127.call(this);_class7.prototype.__init128.call(this);_class7.prototype.__init129.call(this);_class7.prototype.__init130.call(this);_class7.prototype.__init131.call(this);_class7.prototype.__init132.call(this);_class7.prototype.__init133.call(this);_class7.prototype.__init134.call(this);_class7.prototype.__init135.call(this);_class7.prototype.__init136.call(this);_class7.prototype.__init137.call(this);_class7.prototype.__init138.call(this);_class7.prototype.__init139.call(this);_class7.prototype.__init140.call(this);_class7.prototype.__init141.call(this);_class7.prototype.__init142.call(this);_class7.prototype.__init143.call(this);_class7.prototype.__init144.call(this);_class7.prototype.__init145.call(this);_class7.prototype.__init146.call(this);_class7.prototype.__init147.call(this);_class7.prototype.__init148.call(this);_class7.prototype.__init149.call(this);_class7.prototype.__init150.call(this);
2948
2958
  this.canvas = canvas;
2949
2959
  this.debugA11y = _nullishCoalesce(options.debugA11y, () => ( false));
2950
2960
  this.disableWindowResize = _nullishCoalesce(options.disableWindowResize, () => ( false));
@@ -3893,6 +3903,7 @@ var Scene = (_class7 = class _Scene {
3893
3903
  let el = this.a11yElements.get(node.id);
3894
3904
  const attrs = node.getA11yAttributes();
3895
3905
  const expectedTag = attrs.tag || "div";
3906
+ let emitInitialScroll = null;
3896
3907
  if (el && el.tagName.toLowerCase() !== expectedTag.toLowerCase()) {
3897
3908
  if (el === this.focusedA11yElement) {
3898
3909
  this.focusedA11yElement = null;
@@ -3980,6 +3991,26 @@ var Scene = (_class7 = class _Scene {
3980
3991
  },
3981
3992
  { passive: false }
3982
3993
  );
3994
+ const scrollTarget = el;
3995
+ const emitScroll = () => {
3996
+ node.emit("scroll", {
3997
+ scrollTop: scrollTarget.scrollTop,
3998
+ scrollLeft: scrollTarget.scrollLeft,
3999
+ scrollHeight: scrollTarget.scrollHeight,
4000
+ scrollWidth: scrollTarget.scrollWidth,
4001
+ clientHeight: scrollTarget.clientHeight,
4002
+ clientWidth: scrollTarget.clientWidth
4003
+ });
4004
+ };
4005
+ el.addEventListener(
4006
+ "scroll",
4007
+ () => {
4008
+ emitScroll();
4009
+ this.markDirty();
4010
+ },
4011
+ { passive: true }
4012
+ );
4013
+ emitInitialScroll = emitScroll;
3983
4014
  el.addEventListener("keydown", (e) => {
3984
4015
  node.dispatchEvent(new (0, _chunkZ3HFY75Rjs.VectoJSEvent)("keydown", node, e));
3985
4016
  });
@@ -4210,6 +4241,7 @@ var Scene = (_class7 = class _Scene {
4210
4241
  if (el.style.padding !== padding) el.style.padding = padding;
4211
4242
  if (el.style.boxSizing !== "border-box") el.style.boxSizing = "border-box";
4212
4243
  if (el instanceof HTMLTextAreaElement) el.style.resize = "none";
4244
+ if (el.style.scrollbarWidth !== "none") el.style.scrollbarWidth = "none";
4213
4245
  }
4214
4246
  const nestedIn = container && attrs.role && container.owned.has(attrs.role) ? container : null;
4215
4247
  if (node.a11yFullViewport) {
@@ -4256,6 +4288,7 @@ var Scene = (_class7 = class _Scene {
4256
4288
  const display = visible ? "" : "none";
4257
4289
  if (el.style.display !== display) el.style.display = display;
4258
4290
  }
4291
+ _optionalChain([emitInitialScroll, 'optionalCall', _122 => _122()]);
4259
4292
  }
4260
4293
  if (this._phaseTiming) {
4261
4294
  const projectionStart = performance.now();
@@ -4494,9 +4527,9 @@ var Scene = (_class7 = class _Scene {
4494
4527
  for (let lineIndex = 0; lineIndex < grid.lines.length; lineIndex++) {
4495
4528
  const gridLine = grid.lines[lineIndex];
4496
4529
  const projectedLine = projectionLines[lineIndex];
4497
- const lineHeight = _nullishCoalesce(_optionalChain([projectedLine, 'optionalAccess', _122 => _122.lineHeight]), () => ( grid.lineHeight));
4498
- const baseline = _nullishCoalesce(_optionalChain([projectedLine, 'optionalAccess', _123 => _123.baseline]), () => ( grid.baseline));
4499
- const lineFont = _nullishCoalesce(_optionalChain([projectedLine, 'optionalAccess', _124 => _124.font]), () => ( grid.font));
4530
+ const lineHeight = _nullishCoalesce(_optionalChain([projectedLine, 'optionalAccess', _123 => _123.lineHeight]), () => ( grid.lineHeight));
4531
+ const baseline = _nullishCoalesce(_optionalChain([projectedLine, 'optionalAccess', _124 => _124.baseline]), () => ( grid.baseline));
4532
+ const lineFont = _nullishCoalesce(_optionalChain([projectedLine, 'optionalAccess', _125 => _125.font]), () => ( grid.font));
4500
4533
  const lineSignature = contentGridLineSignature(
4501
4534
  grid,
4502
4535
  gridLine,
@@ -4516,8 +4549,8 @@ var Scene = (_class7 = class _Scene {
4516
4549
  lineElement.dir = "ltr";
4517
4550
  lineElement.dataset.vectoGridLine = `${lineIndex}`;
4518
4551
  lineElement.style.position = "absolute";
4519
- lineElement.style.left = `${_nullishCoalesce(_optionalChain([projectedLine, 'optionalAccess', _125 => _125.x]), () => ( 0))}px`;
4520
- lineElement.style.top = `${(_nullishCoalesce(_optionalChain([projectedLine, 'optionalAccess', _126 => _126.y]), () => ( lineIndex * grid.lineHeight))) + baseline - _text.cssLineBoxBaseline.call(void 0, lineFont, lineHeight)}px`;
4552
+ lineElement.style.left = `${_nullishCoalesce(_optionalChain([projectedLine, 'optionalAccess', _126 => _126.x]), () => ( 0))}px`;
4553
+ lineElement.style.top = `${(_nullishCoalesce(_optionalChain([projectedLine, 'optionalAccess', _127 => _127.y]), () => ( lineIndex * grid.lineHeight))) + baseline - _text.cssLineBoxBaseline.call(void 0, lineFont, lineHeight)}px`;
4521
4554
  lineElement.style.width = `${gridLine.width}px`;
4522
4555
  lineElement.style.height = `${lineHeight}px`;
4523
4556
  lineElement.style.whiteSpace = "pre";
@@ -4587,7 +4620,7 @@ var Scene = (_class7 = class _Scene {
4587
4620
  if (selectionLine !== null && selectionLine >= grid.lines.length) {
4588
4621
  rebuiltSelectionLine = true;
4589
4622
  }
4590
- _optionalChain([el, 'access', _127 => _127.lastElementChild, 'optionalAccess', _128 => _128.remove, 'call', _129 => _129()]);
4623
+ _optionalChain([el, 'access', _128 => _128.lastElementChild, 'optionalAccess', _129 => _129.remove, 'call', _130 => _130()]);
4591
4624
  }
4592
4625
  if (rebuiltSelectionLine) this.releaseContentSelectionForRebuild(el);
4593
4626
  el.dataset.vectoProjectionLines = signature;
@@ -4651,7 +4684,7 @@ var Scene = (_class7 = class _Scene {
4651
4684
  if (previous !== void 0 && typeof cancelAnimationFrame === "function") {
4652
4685
  cancelAnimationFrame(previous);
4653
4686
  }
4654
- _optionalChain([this, 'access', _130 => _130.contentGridCalibrationProbes, 'access', _131 => _131.get, 'call', _132 => _132(entityId), 'optionalAccess', _133 => _133.remove, 'call', _134 => _134()]);
4687
+ _optionalChain([this, 'access', _131 => _131.contentGridCalibrationProbes, 'access', _132 => _132.get, 'call', _133 => _133(entityId), 'optionalAccess', _134 => _134.remove, 'call', _135 => _135()]);
4655
4688
  this.contentGridCalibrationProbes.delete(entityId);
4656
4689
  const calibrationStart = typeof performance !== "undefined" ? performance.now() : 0;
4657
4690
  const probe = document.createElement("div");
@@ -4685,7 +4718,7 @@ var Scene = (_class7 = class _Scene {
4685
4718
  target.dataset.vectoGridCalib = generation;
4686
4719
  continue;
4687
4720
  }
4688
- const sourceText = _nullishCoalesce(_optionalChain([target, 'access', _135 => _135.textContent, 'optionalAccess', _136 => _136.slice, 'call', _137 => _137(0, sourceLength)]), () => ( ""));
4721
+ const sourceText = _nullishCoalesce(_optionalChain([target, 'access', _136 => _136.textContent, 'optionalAccess', _137 => _137.slice, 'call', _138 => _138(0, sourceLength)]), () => ( ""));
4689
4722
  if (!sourceText) {
4690
4723
  target.dataset.vectoGridCalib = generation;
4691
4724
  continue;
@@ -4849,7 +4882,9 @@ var Scene = (_class7 = class _Scene {
4849
4882
  this.a11yOrderCursors.set(parent, at + 1);
4850
4883
  const current = parent.childNodes[at];
4851
4884
  if (current !== expected) {
4885
+ const refocus = document.activeElement === expected;
4852
4886
  parent.insertBefore(expected, current || null);
4887
+ if (refocus) expected.focus({ preventScroll: true });
4853
4888
  }
4854
4889
  }
4855
4890
  this.a11yNeedsReorder = false;
@@ -4878,19 +4913,37 @@ var Scene = (_class7 = class _Scene {
4878
4913
  const els = this.normalElements;
4879
4914
  if (els.length < 2) return;
4880
4915
  const rtl = this._readingDirection === "rtl";
4881
- const topOf = (el) => Number.parseFloat(el.style.top) || 0;
4882
- const leftOf = (el) => Number.parseFloat(el.style.left) || 0;
4883
4916
  const heightOf = (el) => Math.max(Number.parseFloat(el.style.height) || 0, 4);
4884
- const order = els.map((el, i) => ({
4885
- el,
4886
- i,
4887
- top: topOf(el),
4888
- left: leftOf(el)
4889
- }));
4917
+ const members = this.a11yOrderMembers;
4918
+ const containers = this.a11yOrderContainers;
4919
+ members.clear();
4920
+ containers.clear();
4921
+ for (const el of els) members.add(el);
4922
+ for (const el of els) {
4923
+ for (let p = el.parentElement; p; p = p.parentElement) {
4924
+ if (members.has(p)) containers.add(p);
4925
+ }
4926
+ }
4927
+ const absolute = (el) => {
4928
+ let top = 0;
4929
+ let left = 0;
4930
+ for (let node = el; node; node = node.parentElement) {
4931
+ top += Number.parseFloat(node.style.top) || 0;
4932
+ left += Number.parseFloat(node.style.left) || 0;
4933
+ const parent = node.parentElement;
4934
+ if (!parent || !members.has(parent)) break;
4935
+ }
4936
+ return { top, left };
4937
+ };
4938
+ const order = els.map((el, i) => {
4939
+ const { top, left } = absolute(el);
4940
+ return { el, i, top, left, container: containers.has(el) };
4941
+ });
4890
4942
  order.sort((p, q) => p.top - q.top || p.i - q.i);
4943
+ const bandBottom = (r) => r.top + (r.container ? 4 : heightOf(r.el));
4891
4944
  const sorted = [];
4892
4945
  let rowStart = 0;
4893
- let rowBottom = order.length ? order[0].top + heightOf(order[0].el) : 0;
4946
+ let rowBottom = order.length ? bandBottom(order[0]) : 0;
4894
4947
  const flushRow = (end) => {
4895
4948
  const row = order.slice(rowStart, end);
4896
4949
  row.sort((p, q) => (rtl ? q.left - p.left : p.left - q.left) || p.i - q.i);
@@ -4898,11 +4951,11 @@ var Scene = (_class7 = class _Scene {
4898
4951
  };
4899
4952
  for (let k = 1; k < order.length; k++) {
4900
4953
  if (order[k].top < rowBottom) {
4901
- rowBottom = Math.max(rowBottom, order[k].top + heightOf(order[k].el));
4954
+ rowBottom = Math.max(rowBottom, bandBottom(order[k]));
4902
4955
  } else {
4903
4956
  flushRow(k);
4904
4957
  rowStart = k;
4905
- rowBottom = order[k].top + heightOf(order[k].el);
4958
+ rowBottom = bandBottom(order[k]);
4906
4959
  }
4907
4960
  }
4908
4961
  flushRow(order.length);
@@ -4912,12 +4965,12 @@ var Scene = (_class7 = class _Scene {
4912
4965
  syncOverlayGeometry() {
4913
4966
  const parent = this.canvas.parentElement;
4914
4967
  if (!parent) return;
4915
- const canvasRect = _optionalChain([this, 'access', _138 => _138.canvas, 'access', _139 => _139.getBoundingClientRect, 'optionalCall', _140 => _140()]);
4916
- const parentRect = _optionalChain([parent, 'access', _141 => _141.getBoundingClientRect, 'optionalCall', _142 => _142()]);
4917
- const cssWidth = _optionalChain([canvasRect, 'optionalAccess', _143 => _143.width]) || this.canvas.clientWidth || this.width;
4918
- const cssHeight = _optionalChain([canvasRect, 'optionalAccess', _144 => _144.height]) || this.canvas.clientHeight || this.height;
4919
- const left = (_nullishCoalesce(_optionalChain([canvasRect, 'optionalAccess', _145 => _145.left]), () => ( 0))) - (_nullishCoalesce(_optionalChain([parentRect, 'optionalAccess', _146 => _146.left]), () => ( 0))) - (parent.clientLeft || 0) + parent.scrollLeft;
4920
- const top = (_nullishCoalesce(_optionalChain([canvasRect, 'optionalAccess', _147 => _147.top]), () => ( 0))) - (_nullishCoalesce(_optionalChain([parentRect, 'optionalAccess', _148 => _148.top]), () => ( 0))) - (parent.clientTop || 0) + parent.scrollTop;
4968
+ const canvasRect = _optionalChain([this, 'access', _139 => _139.canvas, 'access', _140 => _140.getBoundingClientRect, 'optionalCall', _141 => _141()]);
4969
+ const parentRect = _optionalChain([parent, 'access', _142 => _142.getBoundingClientRect, 'optionalCall', _143 => _143()]);
4970
+ const cssWidth = _optionalChain([canvasRect, 'optionalAccess', _144 => _144.width]) || this.canvas.clientWidth || this.width;
4971
+ const cssHeight = _optionalChain([canvasRect, 'optionalAccess', _145 => _145.height]) || this.canvas.clientHeight || this.height;
4972
+ const left = (_nullishCoalesce(_optionalChain([canvasRect, 'optionalAccess', _146 => _146.left]), () => ( 0))) - (_nullishCoalesce(_optionalChain([parentRect, 'optionalAccess', _147 => _147.left]), () => ( 0))) - (parent.clientLeft || 0) + parent.scrollLeft;
4973
+ const top = (_nullishCoalesce(_optionalChain([canvasRect, 'optionalAccess', _148 => _148.top]), () => ( 0))) - (_nullishCoalesce(_optionalChain([parentRect, 'optionalAccess', _149 => _149.top]), () => ( 0))) - (parent.clientTop || 0) + parent.scrollTop;
4921
4974
  const scaleX = this.width > 0 ? cssWidth / this.width : 1;
4922
4975
  const scaleY = this.height > 0 ? cssHeight / this.height : 1;
4923
4976
  const prev = this._overlayGeometry;
@@ -5056,7 +5109,7 @@ var Scene = (_class7 = class _Scene {
5056
5109
  * (and {@link respectReducedMotion} is on). `0` means uncapped.
5057
5110
  */
5058
5111
  effectiveMaxFPS() {
5059
- const reduced = this.respectReducedMotion && !!_optionalChain([this, 'access', _149 => _149.reducedMotionQuery, 'optionalAccess', _150 => _150.matches]);
5112
+ const reduced = this.respectReducedMotion && !!_optionalChain([this, 'access', _150 => _150.reducedMotionQuery, 'optionalAccess', _151 => _151.matches]);
5060
5113
  if (reduced)
5061
5114
  return this.maxFPS > 0 ? Math.min(this.maxFPS, REDUCED_MOTION_FPS) : REDUCED_MOTION_FPS;
5062
5115
  return this.maxFPS;
@@ -5151,7 +5204,7 @@ var Scene = (_class7 = class _Scene {
5151
5204
  * @param time - Current absolute time in milliseconds (default 0).
5152
5205
  */
5153
5206
  render(renderer, dt = 0, time = 0) {
5154
- if (_optionalChain([renderer, 'access', _151 => _151.isContextLost, 'optionalCall', _152 => _152()])) return;
5207
+ if (_optionalChain([renderer, 'access', _152 => _152.isContextLost, 'optionalCall', _153 => _153()])) return;
5155
5208
  const isMainRenderer = renderer === this.renderer;
5156
5209
  if (isMainRenderer && this.a11yRoot && this.canvas.parentElement) {
5157
5210
  const parentStyle = this.canvas.parentElement.style;
@@ -5295,7 +5348,7 @@ var Scene = (_class7 = class _Scene {
5295
5348
  }
5296
5349
  renderer.clear();
5297
5350
  if (isMainRenderer) {
5298
- _optionalChain([this, 'access', _153 => _153.pointRenderer, 'optionalAccess', _154 => _154.begin, 'call', _155 => _155()]);
5351
+ _optionalChain([this, 'access', _154 => _154.pointRenderer, 'optionalAccess', _155 => _155.begin, 'call', _156 => _156()]);
5299
5352
  }
5300
5353
  const vw = this.width;
5301
5354
  const vh = this.height;
@@ -5509,9 +5562,9 @@ var Scene = (_class7 = class _Scene {
5509
5562
  const flushT0 = this._phaseTiming ? performance.now() : 0;
5510
5563
  renderer.flush();
5511
5564
  if (isMainRenderer) {
5512
- _optionalChain([this, 'access', _156 => _156.pointRenderer, 'optionalAccess', _157 => _157.flush, 'call', _158 => _158()]);
5565
+ _optionalChain([this, 'access', _157 => _157.pointRenderer, 'optionalAccess', _158 => _158.flush, 'call', _159 => _159()]);
5513
5566
  }
5514
- _optionalChain([renderer, 'access', _159 => _159.present, 'optionalCall', _160 => _160()]);
5567
+ _optionalChain([renderer, 'access', _160 => _160.present, 'optionalCall', _161 => _161()]);
5515
5568
  if (this._phaseTiming) this._recordPhase("flush", performance.now() - flushT0);
5516
5569
  if (flushTiming) endVectoUserTiming(flushTiming);
5517
5570
  if (this._devActive) {
@@ -5792,8 +5845,8 @@ function pointInBounds(b, x, y) {
5792
5845
  function contentGridLineSignature(grid, line, projected, lineHeight, baseline, font, isFirstLine) {
5793
5846
  const parts = [
5794
5847
  // Line box: position, size, and the font that resolves its baseline.
5795
- `${_nullishCoalesce(_optionalChain([projected, 'optionalAccess', _161 => _161.x]), () => ( 0))}`,
5796
- `${_nullishCoalesce(_optionalChain([projected, 'optionalAccess', _162 => _162.y]), () => ( ""))}`,
5848
+ `${_nullishCoalesce(_optionalChain([projected, 'optionalAccess', _162 => _162.x]), () => ( 0))}`,
5849
+ `${_nullishCoalesce(_optionalChain([projected, 'optionalAccess', _163 => _163.y]), () => ( ""))}`,
5797
5850
  `${lineHeight}`,
5798
5851
  `${baseline}`,
5799
5852
  font,
@@ -5840,15 +5893,15 @@ var TextEntity = (_class8 = class extends _chunkZ3HFY75Rjs.Entity {
5840
5893
 
5841
5894
 
5842
5895
 
5843
- __init149() {this.nodes = []}
5896
+ __init151() {this.nodes = []}
5844
5897
 
5845
- __init150() {this.fillStyle = "#94a3b8"}
5846
- __init151() {this.strokeStyle = null}
5847
- __init152() {this.hoveredFillStyle = "#ffffff"}
5848
- __init153() {this.lineWidth = 1}
5849
- __init154() {this.isHovered = false}
5898
+ __init152() {this.fillStyle = "#94a3b8"}
5899
+ __init153() {this.strokeStyle = null}
5900
+ __init154() {this.hoveredFillStyle = "#ffffff"}
5901
+ __init155() {this.lineWidth = 1}
5902
+ __init156() {this.isHovered = false}
5850
5903
  constructor(text, atlas, maxWidth, fontSize = 24) {
5851
- super();_class8.prototype.__init149.call(this);_class8.prototype.__init150.call(this);_class8.prototype.__init151.call(this);_class8.prototype.__init152.call(this);_class8.prototype.__init153.call(this);_class8.prototype.__init154.call(this);;
5904
+ super();_class8.prototype.__init151.call(this);_class8.prototype.__init152.call(this);_class8.prototype.__init153.call(this);_class8.prototype.__init154.call(this);_class8.prototype.__init155.call(this);_class8.prototype.__init156.call(this);;
5852
5905
  this.text = text;
5853
5906
  this.atlas = atlas;
5854
5907
  this.fontSize = fontSize;
@@ -5963,15 +6016,15 @@ var TextEntity = (_class8 = class extends _chunkZ3HFY75Rjs.Entity {
5963
6016
  // src/components/GridTextEntity.ts
5964
6017
  var GridTextEntity = (_class9 = class extends _chunkZ3HFY75Rjs.Entity {
5965
6018
 
5966
- __init155() {this.fillStyle = "#ffffff"}
5967
- __init156() {this.grid = []}
6019
+ __init157() {this.fillStyle = "#ffffff"}
6020
+ __init158() {this.grid = []}
5968
6021
  // Array of rows
5969
- __init157() {this.cols = 0}
5970
- __init158() {this.rows = 0}
6022
+ __init159() {this.cols = 0}
6023
+ __init160() {this.rows = 0}
5971
6024
 
5972
6025
 
5973
6026
  constructor(_atlas, fontSize = 10) {
5974
- super();_class9.prototype.__init155.call(this);_class9.prototype.__init156.call(this);_class9.prototype.__init157.call(this);_class9.prototype.__init158.call(this);;
6027
+ super();_class9.prototype.__init157.call(this);_class9.prototype.__init158.call(this);_class9.prototype.__init159.call(this);_class9.prototype.__init160.call(this);;
5975
6028
  this.fontSize = fontSize;
5976
6029
  this.charWidth = fontSize * 1;
5977
6030
  this.charHeight = fontSize * 1.1;
@@ -5980,7 +6033,7 @@ var GridTextEntity = (_class9 = class extends _chunkZ3HFY75Rjs.Entity {
5980
6033
  updateGrid(ascii) {
5981
6034
  this.grid = ascii;
5982
6035
  this.rows = ascii.length;
5983
- this.cols = _optionalChain([ascii, 'access', _163 => _163[0], 'optionalAccess', _164 => _164.length]) || 0;
6036
+ this.cols = _optionalChain([ascii, 'access', _164 => _164[0], 'optionalAccess', _165 => _165.length]) || 0;
5984
6037
  }
5985
6038
  isPointInside(_globalX, _globalY) {
5986
6039
  return false;
@@ -6063,23 +6116,23 @@ var SplineEntity = (_class10 = class extends _chunkZ3HFY75Rjs.Entity {
6063
6116
 
6064
6117
 
6065
6118
 
6066
- __init159() {this.offscreen = null}
6067
- __init160() {this.baked = false}
6119
+ __init161() {this.offscreen = null}
6120
+ __init162() {this.baked = false}
6068
6121
  /** Logical (CSS-pixel) size of the baked bitmap — the blit destination size. */
6069
- __init161() {this.bakedWidth = 0}
6070
- __init162() {this.bakedHeight = 0}
6122
+ __init163() {this.bakedWidth = 0}
6123
+ __init164() {this.bakedHeight = 0}
6071
6124
  /** Gradient strokes can't be baked to a solid-color bitmap; they render per-frame. */
6072
6125
 
6073
6126
  /** Lazily-flattened polylines (one Float32Array of [x,y,...] per segment) for hit-testing. */
6074
- __init163() {this.polylines = null}
6127
+ __init165() {this.polylines = null}
6075
6128
  /**
6076
6129
  * When `true`, the renderer draws a rounded-rect outline of the entity's
6077
6130
  * local bounds after painting the curves. Useful for drag feedback and
6078
6131
  * debugging hit areas. Defaults to `false`.
6079
6132
  */
6080
- __init164() {this.showBounds = false}
6133
+ __init166() {this.showBounds = false}
6081
6134
  constructor(doc, opts = {}) {
6082
- super();_class10.prototype.__init159.call(this);_class10.prototype.__init160.call(this);_class10.prototype.__init161.call(this);_class10.prototype.__init162.call(this);_class10.prototype.__init163.call(this);_class10.prototype.__init164.call(this);;
6135
+ super();_class10.prototype.__init161.call(this);_class10.prototype.__init162.call(this);_class10.prototype.__init163.call(this);_class10.prototype.__init164.call(this);_class10.prototype.__init165.call(this);_class10.prototype.__init166.call(this);;
6083
6136
  this.doc = doc;
6084
6137
  this.lineWidth = _nullishCoalesce(opts.lineWidth, () => ( 2));
6085
6138
  this.cache = _nullishCoalesce(opts.cache, () => ( true));
@@ -6090,7 +6143,7 @@ var SplineEntity = (_class10 = class extends _chunkZ3HFY75Rjs.Entity {
6090
6143
  this.width = this.bounds.width;
6091
6144
  this.height = this.bounds.height;
6092
6145
  const isGradient = (c) => c !== null && !Array.isArray(c);
6093
- this.containsGradient = (_nullishCoalesce(_optionalChain([this, 'access', _165 => _165.doc, 'access', _166 => _166.equations, 'optionalAccess', _167 => _167.some, 'call', _168 => _168((eq) => isGradient(eq.color_rgb))]), () => ( false))) || (_nullishCoalesce(_optionalChain([this, 'access', _169 => _169.doc, 'access', _170 => _170.paths, 'optionalAccess', _171 => _171.some, 'call', _172 => _172((p) => isGradient(p.color_rgb))]), () => ( false)));
6146
+ this.containsGradient = (_nullishCoalesce(_optionalChain([this, 'access', _166 => _166.doc, 'access', _167 => _167.equations, 'optionalAccess', _168 => _168.some, 'call', _169 => _169((eq) => isGradient(eq.color_rgb))]), () => ( false))) || (_nullishCoalesce(_optionalChain([this, 'access', _170 => _170.doc, 'access', _171 => _171.paths, 'optionalAccess', _172 => _172.some, 'call', _173 => _173((p) => isGradient(p.color_rgb))]), () => ( false)));
6094
6147
  this.interactive = true;
6095
6148
  }
6096
6149
  computeBounds() {
@@ -6460,19 +6513,19 @@ var _math = require('@vectojs/math'); _createStarExport(_math);
6460
6513
  // src/tree/DOMPortalEntity.ts
6461
6514
  var DOMPortalEntity = (_class11 = class extends _chunkZ3HFY75Rjs.Entity {
6462
6515
 
6463
- __init165() {this.isDOMPortal = true}
6464
- __init166() {this.domListeners = []}
6465
- __init167() {this.resizeObserver = null}
6466
- __init168() {this.domBound = false}
6467
- __init169() {this.cachedWidth = 100}
6468
- __init170() {this.cachedHeight = 100}
6469
- __init171() {this.lastWidth = ""}
6470
- __init172() {this.lastHeight = ""}
6471
- __init173() {this.lastTransform = ""}
6472
- __init174() {this.lastZIndex = ""}
6473
- __init175() {this.lastOpacity = ""}
6516
+ __init167() {this.isDOMPortal = true}
6517
+ __init168() {this.domListeners = []}
6518
+ __init169() {this.resizeObserver = null}
6519
+ __init170() {this.domBound = false}
6520
+ __init171() {this.cachedWidth = 100}
6521
+ __init172() {this.cachedHeight = 100}
6522
+ __init173() {this.lastWidth = ""}
6523
+ __init174() {this.lastHeight = ""}
6524
+ __init175() {this.lastTransform = ""}
6525
+ __init176() {this.lastZIndex = ""}
6526
+ __init177() {this.lastOpacity = ""}
6474
6527
  constructor(domElement, width, height, id) {
6475
- super(id);_class11.prototype.__init165.call(this);_class11.prototype.__init166.call(this);_class11.prototype.__init167.call(this);_class11.prototype.__init168.call(this);_class11.prototype.__init169.call(this);_class11.prototype.__init170.call(this);_class11.prototype.__init171.call(this);_class11.prototype.__init172.call(this);_class11.prototype.__init173.call(this);_class11.prototype.__init174.call(this);_class11.prototype.__init175.call(this);;
6528
+ super(id);_class11.prototype.__init167.call(this);_class11.prototype.__init168.call(this);_class11.prototype.__init169.call(this);_class11.prototype.__init170.call(this);_class11.prototype.__init171.call(this);_class11.prototype.__init172.call(this);_class11.prototype.__init173.call(this);_class11.prototype.__init174.call(this);_class11.prototype.__init175.call(this);_class11.prototype.__init176.call(this);_class11.prototype.__init177.call(this);;
6476
6529
  this.domElement = domElement;
6477
6530
  this.width = _nullishCoalesce(width, () => ( 0));
6478
6531
  this.height = _nullishCoalesce(height, () => ( 0));
package/dist/index.mjs CHANGED
@@ -2001,6 +2001,16 @@ var Scene = class _Scene {
2001
2001
  activeIds = /* @__PURE__ */ new Set();
2002
2002
  /** Per-parent insertion cursor, reused by `enforceA11yDomOrder`. */
2003
2003
  a11yOrderCursors = /* @__PURE__ */ new Map();
2004
+ /** Membership set for the elements being ordered, reused per reorder pass. */
2005
+ a11yOrderMembers = /* @__PURE__ */ new Set();
2006
+ /**
2007
+ * Elements that are an *ancestor* of another ordered element, reused per pass.
2008
+ *
2009
+ * A composite widget's container (a `grid` around its rows, a `tree` around its
2010
+ * items) spans every descendant row, so it must not extend a visual row band —
2011
+ * see {@link sortNormalElementsVisually}.
2012
+ */
2013
+ a11yOrderContainers = /* @__PURE__ */ new Set();
2004
2014
  activePortalsThisFrame = /* @__PURE__ */ new Set();
2005
2015
  activePortalsPrevFrame = /* @__PURE__ */ new Set();
2006
2016
  portalEntities = /* @__PURE__ */ new Map();
@@ -3892,6 +3902,7 @@ var Scene = class _Scene {
3892
3902
  let el = this.a11yElements.get(node.id);
3893
3903
  const attrs = node.getA11yAttributes();
3894
3904
  const expectedTag = attrs.tag || "div";
3905
+ let emitInitialScroll = null;
3895
3906
  if (el && el.tagName.toLowerCase() !== expectedTag.toLowerCase()) {
3896
3907
  if (el === this.focusedA11yElement) {
3897
3908
  this.focusedA11yElement = null;
@@ -3979,6 +3990,26 @@ var Scene = class _Scene {
3979
3990
  },
3980
3991
  { passive: false }
3981
3992
  );
3993
+ const scrollTarget = el;
3994
+ const emitScroll = () => {
3995
+ node.emit("scroll", {
3996
+ scrollTop: scrollTarget.scrollTop,
3997
+ scrollLeft: scrollTarget.scrollLeft,
3998
+ scrollHeight: scrollTarget.scrollHeight,
3999
+ scrollWidth: scrollTarget.scrollWidth,
4000
+ clientHeight: scrollTarget.clientHeight,
4001
+ clientWidth: scrollTarget.clientWidth
4002
+ });
4003
+ };
4004
+ el.addEventListener(
4005
+ "scroll",
4006
+ () => {
4007
+ emitScroll();
4008
+ this.markDirty();
4009
+ },
4010
+ { passive: true }
4011
+ );
4012
+ emitInitialScroll = emitScroll;
3982
4013
  el.addEventListener("keydown", (e) => {
3983
4014
  node.dispatchEvent(new VectoJSEvent("keydown", node, e));
3984
4015
  });
@@ -4209,6 +4240,7 @@ var Scene = class _Scene {
4209
4240
  if (el.style.padding !== padding) el.style.padding = padding;
4210
4241
  if (el.style.boxSizing !== "border-box") el.style.boxSizing = "border-box";
4211
4242
  if (el instanceof HTMLTextAreaElement) el.style.resize = "none";
4243
+ if (el.style.scrollbarWidth !== "none") el.style.scrollbarWidth = "none";
4212
4244
  }
4213
4245
  const nestedIn = container && attrs.role && container.owned.has(attrs.role) ? container : null;
4214
4246
  if (node.a11yFullViewport) {
@@ -4255,6 +4287,7 @@ var Scene = class _Scene {
4255
4287
  const display = visible ? "" : "none";
4256
4288
  if (el.style.display !== display) el.style.display = display;
4257
4289
  }
4290
+ emitInitialScroll?.();
4258
4291
  }
4259
4292
  if (this._phaseTiming) {
4260
4293
  const projectionStart = performance.now();
@@ -4848,7 +4881,9 @@ var Scene = class _Scene {
4848
4881
  this.a11yOrderCursors.set(parent, at + 1);
4849
4882
  const current = parent.childNodes[at];
4850
4883
  if (current !== expected) {
4884
+ const refocus = document.activeElement === expected;
4851
4885
  parent.insertBefore(expected, current || null);
4886
+ if (refocus) expected.focus({ preventScroll: true });
4852
4887
  }
4853
4888
  }
4854
4889
  this.a11yNeedsReorder = false;
@@ -4877,19 +4912,37 @@ var Scene = class _Scene {
4877
4912
  const els = this.normalElements;
4878
4913
  if (els.length < 2) return;
4879
4914
  const rtl = this._readingDirection === "rtl";
4880
- const topOf = (el) => Number.parseFloat(el.style.top) || 0;
4881
- const leftOf = (el) => Number.parseFloat(el.style.left) || 0;
4882
4915
  const heightOf = (el) => Math.max(Number.parseFloat(el.style.height) || 0, 4);
4883
- const order = els.map((el, i) => ({
4884
- el,
4885
- i,
4886
- top: topOf(el),
4887
- left: leftOf(el)
4888
- }));
4916
+ const members = this.a11yOrderMembers;
4917
+ const containers = this.a11yOrderContainers;
4918
+ members.clear();
4919
+ containers.clear();
4920
+ for (const el of els) members.add(el);
4921
+ for (const el of els) {
4922
+ for (let p = el.parentElement; p; p = p.parentElement) {
4923
+ if (members.has(p)) containers.add(p);
4924
+ }
4925
+ }
4926
+ const absolute = (el) => {
4927
+ let top = 0;
4928
+ let left = 0;
4929
+ for (let node = el; node; node = node.parentElement) {
4930
+ top += Number.parseFloat(node.style.top) || 0;
4931
+ left += Number.parseFloat(node.style.left) || 0;
4932
+ const parent = node.parentElement;
4933
+ if (!parent || !members.has(parent)) break;
4934
+ }
4935
+ return { top, left };
4936
+ };
4937
+ const order = els.map((el, i) => {
4938
+ const { top, left } = absolute(el);
4939
+ return { el, i, top, left, container: containers.has(el) };
4940
+ });
4889
4941
  order.sort((p, q) => p.top - q.top || p.i - q.i);
4942
+ const bandBottom = (r) => r.top + (r.container ? 4 : heightOf(r.el));
4890
4943
  const sorted = [];
4891
4944
  let rowStart = 0;
4892
- let rowBottom = order.length ? order[0].top + heightOf(order[0].el) : 0;
4945
+ let rowBottom = order.length ? bandBottom(order[0]) : 0;
4893
4946
  const flushRow = (end) => {
4894
4947
  const row = order.slice(rowStart, end);
4895
4948
  row.sort((p, q) => (rtl ? q.left - p.left : p.left - q.left) || p.i - q.i);
@@ -4897,11 +4950,11 @@ var Scene = class _Scene {
4897
4950
  };
4898
4951
  for (let k = 1; k < order.length; k++) {
4899
4952
  if (order[k].top < rowBottom) {
4900
- rowBottom = Math.max(rowBottom, order[k].top + heightOf(order[k].el));
4953
+ rowBottom = Math.max(rowBottom, bandBottom(order[k]));
4901
4954
  } else {
4902
4955
  flushRow(k);
4903
4956
  rowStart = k;
4904
- rowBottom = order[k].top + heightOf(order[k].el);
4957
+ rowBottom = bandBottom(order[k]);
4905
4958
  }
4906
4959
  }
4907
4960
  flushRow(order.length);
@@ -374,7 +374,30 @@ export interface A11yAttributes {
374
374
  /**
375
375
  * Union of all pointer/interaction events that can be emitted by an {@link Entity}.
376
376
  */
377
- export type VectoEvent = 'click' | 'dblclick' | 'hover' | 'pointerdown' | 'pointerup' | 'pointercancel' | 'pointermove' | 'pointerleave' | 'change' | 'focus' | 'blur' | 'wheel' | 'keydown' | 'keyup';
377
+ export type VectoEvent = 'click' | 'dblclick' | 'hover' | 'pointerdown' | 'pointerup' | 'pointercancel' | 'pointermove' | 'pointerleave' | 'change' | 'focus' | 'blur' | 'wheel' | 'scroll' | 'keydown' | 'keyup';
378
+ /**
379
+ * Payload of the {@link VectoEvent} `'scroll'`: the scroll geometry of an
380
+ * entity's accessibility/automation shadow node, in CSS pixels.
381
+ *
382
+ * An entity that paints its own view of scrollable content (a text editor, a
383
+ * list) should treat these as authoritative while the mirror exists — the
384
+ * browser resolved them against the same content, and any offset the element
385
+ * reports (`selectionStart` from a click) is relative to them.
386
+ */
387
+ export interface ScrollEventPayload {
388
+ /** The mirror's vertical scroll offset. */
389
+ scrollTop: number;
390
+ /** The mirror's horizontal scroll offset. */
391
+ scrollLeft: number;
392
+ /** Full scrollable content height, including the part out of view. */
393
+ scrollHeight: number;
394
+ /** Full scrollable content width, including the part out of view. */
395
+ scrollWidth: number;
396
+ /** Visible height inside the mirror's padding box (excludes any scrollbar). */
397
+ clientHeight: number;
398
+ /** Visible width inside the mirror's padding box (excludes any scrollbar). */
399
+ clientWidth: number;
400
+ }
378
401
  /** Options for {@link Entity.on} / {@link Entity.off}. */
379
402
  export interface ListenerOptions {
380
403
  /** Register the listener for the capture phase (root→target) instead of bubble. */
@@ -568,6 +568,16 @@ export declare class Scene {
568
568
  private activeIds;
569
569
  /** Per-parent insertion cursor, reused by `enforceA11yDomOrder`. */
570
570
  private a11yOrderCursors;
571
+ /** Membership set for the elements being ordered, reused per reorder pass. */
572
+ private a11yOrderMembers;
573
+ /**
574
+ * Elements that are an *ancestor* of another ordered element, reused per pass.
575
+ *
576
+ * A composite widget's container (a `grid` around its rows, a `tree` around its
577
+ * items) spans every descendant row, so it must not extend a visual row band —
578
+ * see {@link sortNormalElementsVisually}.
579
+ */
580
+ private a11yOrderContainers;
571
581
  private activePortalsThisFrame;
572
582
  private activePortalsPrevFrame;
573
583
  private portalEntities;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vectojs/core",
3
- "version": "1.27.1",
3
+ "version": "1.28.1",
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },
@@ -65,7 +65,7 @@
65
65
  },
66
66
  "dependencies": {
67
67
  "@vectojs/animation": "^0.1.1",
68
- "@vectojs/layout": "^0.5.0",
68
+ "@vectojs/layout": "^0.6.0",
69
69
  "@vectojs/math": "^0.1.1",
70
70
  "@vectojs/text": "^0.3.0"
71
71
  },