@moku-labs/game 0.15.161 → 0.15.163

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.
Files changed (33) hide show
  1. package/dist/app/page.d.mts +1 -1
  2. package/dist/app/page.mjs +1 -1
  3. package/dist/app/system.d.mts +3 -3
  4. package/dist/app.d.mts +3 -3
  5. package/dist/app.mjs +1 -1
  6. package/dist/assets.d.mts +1 -1
  7. package/dist/{commands-CLhKYlot.d.mts → commands-CAvCuLaL.d.mts} +5 -5
  8. package/dist/control.d.mts +4 -4
  9. package/dist/{define-3zxu6rIq.d.mts → define-DSOTwTUY.d.mts} +2 -2
  10. package/dist/{headless-DFkrIVO4.d.mts → headless-PANjNy6-.d.mts} +1 -1
  11. package/dist/{index-CVmEBBm5.d.mts → index-oS9wiCoO.d.mts} +12 -12
  12. package/dist/index.d.mts +4 -4
  13. package/dist/index.mjs +1 -1
  14. package/dist/inspect.d.mts +6 -6
  15. package/dist/inspect.mjs +1 -1
  16. package/dist/jsx-dev-runtime.d.mts +1 -1
  17. package/dist/jsx-runtime.d.mts +1 -1
  18. package/dist/{runtime-CI8p6sVn.d.mts → runtime-Bb5sNTGb.d.mts} +1 -1
  19. package/dist/{sources-D9Fk3Z4d.mjs → sources-DRP-bS6e.mjs} +2 -1
  20. package/dist/{src-qeTzNTZA.mjs → src-DBhsppmi.mjs} +1075 -308
  21. package/dist/testing.d.mts +4 -4
  22. package/dist/testing.mjs +1 -1
  23. package/dist/{types-CM7Ng3EN.d.mts → types-BuN6rLDs.d.mts} +2 -2
  24. package/dist/{types-Bl9jyah_.d.mts → types-C4d1Ptfc.d.mts} +1881 -39
  25. package/dist/{types-D1xdKk_t.d.mts → types-DTkhpupa.d.mts} +91 -22
  26. package/dist/{types-DHWjH6p9.d.mts → types-SUCTOeQZ.d.mts} +4 -4
  27. package/dist/types-dSup2_q9.d.mts +1841 -0
  28. package/dist/{visual-D_4mmn1u.d.mts → visual-BZrQT1r1.d.mts} +5 -6
  29. package/dist/visual.d.mts +1 -1
  30. package/dist/visual.mjs +1 -1
  31. package/llms.txt +1 -1
  32. package/package.json +3 -3
  33. package/dist/types-D-vnlN3n.d.mts +0 -3632
@@ -14963,7 +14963,7 @@ function emptyMap$9() {
14963
14963
  *
14964
14964
  * @returns An empty weak map.
14965
14965
  */
14966
- function emptyWeakMap$3() {
14966
+ function emptyWeakMap$4() {
14967
14967
  return /* @__PURE__ */ new WeakMap();
14968
14968
  }
14969
14969
  /**
@@ -14998,10 +14998,10 @@ function createProjectionState() {
14998
14998
  keys: emptyMap$9(),
14999
14999
  keysByEntity: emptyMap$9(),
15000
15000
  mutes: emptyMap$9(),
15001
- muteCounts: emptyWeakMap$3(),
15002
- initialOnly: emptyWeakMap$3(),
15003
- ownedSets: emptyWeakMap$3(),
15004
- joinedMutes: emptyWeakMap$3(),
15001
+ muteCounts: emptyWeakMap$4(),
15002
+ initialOnly: emptyWeakMap$4(),
15003
+ ownedSets: emptyWeakMap$4(),
15004
+ joinedMutes: emptyWeakMap$4(),
15005
15005
  converged: [],
15006
15006
  offHints: [],
15007
15007
  leaving: emptyMap$9(),
@@ -15809,41 +15809,126 @@ function isTarget$3(source) {
15809
15809
  return source.uploadMethodId === "unknown" && (source.resource === null || source.resource === void 0);
15810
15810
  }
15811
15811
  /**
15812
- * Counts the texture sources the GPU holds and sums their estimated bytes, split three ways: a
15813
- * source with no upload method and no resource is a render target (a filter texture, a picture
15814
- * Pixi renders into), one the engine keeps as a picture is kept, every other source is art.
15815
- * Pixi's `managedTextures` exists on the WebGPU and the WebGL texture system alike (checked in
15816
- * 8.22); Pixi's canvas renderer keeps no GPU texture and answers zero. Both systems answer
15817
- * `Object.values` of a `GCManagedHash`, which keeps a `null` slot for every unloaded source, so
15818
- * only the live sources are counted. An indexed walk: no array is made.
15812
+ * The one usage the walk writes into: `textureUsage` runs at every `stats()` call, so it makes no object. Every call
15813
+ * writes over it.
15814
+ */
15815
+ const usage$1 = {
15816
+ count: 0,
15817
+ bytes: 0,
15818
+ art: 0,
15819
+ text: 0,
15820
+ targets: 0,
15821
+ kept: 0,
15822
+ other: 0,
15823
+ idleTargets: 0,
15824
+ idleKept: 0
15825
+ };
15826
+ /**
15827
+ * Counts the texture sources the GPU holds and sums their estimated bytes, split five ways, the first that fits: a
15828
+ * source the engine keeps as a picture is kept (and idle too while it waits in the kept pool); one with no upload
15829
+ * method and no resource is a render target (a filter texture, a picture Pixi renders into); one `sync` marked is text
15830
+ * or art; every other source is other. Pixi's `managedTextures` exists on the WebGPU and the WebGL texture system
15831
+ * alike (checked in 8.22); Pixi's canvas renderer keeps no GPU texture and answers zero. Both systems answer
15832
+ * `Object.values` of a `GCManagedHash`, which keeps a `null` slot for every unloaded source, so only the live sources
15833
+ * are counted. One indexed walk that makes nothing: the answer is the same object every call, `idleTargets` 0 (only
15834
+ * `host.textures()` reads Pixi's pool).
15819
15835
  *
15820
15836
  * @param app - The application that draws.
15821
- * @param kept - The sources the engine keeps as pictures.
15822
- * @returns The count, the bytes and their split.
15837
+ * @param kinds - The kept sources, the marks of `sync` and the idle kept sources: the host state.
15838
+ * @returns The count, the bytes and their split, written over by the next call.
15823
15839
  */
15824
- function textureUsage(app, kept) {
15840
+ function textureUsage(app, kinds) {
15825
15841
  const system = app.renderer.texture;
15826
- const usage = {
15827
- count: 0,
15828
- bytes: 0,
15829
- art: 0,
15830
- targets: 0,
15831
- kept: 0
15832
- };
15833
- if (!("managedTextures" in system)) return usage;
15842
+ usage$1.count = 0;
15843
+ usage$1.bytes = 0;
15844
+ usage$1.art = 0;
15845
+ usage$1.text = 0;
15846
+ usage$1.targets = 0;
15847
+ usage$1.kept = 0;
15848
+ usage$1.other = 0;
15849
+ usage$1.idleTargets = 0;
15850
+ usage$1.idleKept = 0;
15851
+ if (!("managedTextures" in system)) return usage$1;
15834
15852
  const sources = system.managedTextures;
15835
15853
  const total = sources.length;
15836
15854
  for (let index = 0; index < total; index += 1) {
15837
15855
  const source = sources[index];
15838
15856
  if (!source) continue;
15839
15857
  const bytes = sourceBytes(source);
15840
- usage.count += 1;
15841
- usage.bytes += bytes;
15842
- if (kept.has(source)) usage.kept += bytes;
15843
- else if (isTarget$3(source)) usage.targets += bytes;
15844
- else usage.art += bytes;
15858
+ usage$1.count += 1;
15859
+ usage$1.bytes += bytes;
15860
+ if (kinds.kept.has(source)) {
15861
+ usage$1.kept += bytes;
15862
+ if (kinds.idle.has(source)) usage$1.idleKept += bytes;
15863
+ } else if (isTarget$3(source)) usage$1.targets += bytes;
15864
+ else addMarked(kinds.marks.get(source), bytes);
15845
15865
  }
15846
- return usage;
15866
+ return usage$1;
15867
+ }
15868
+ /**
15869
+ * Adds the bytes of a source that is neither kept nor a target to its kind: text, art, or other without a mark.
15870
+ *
15871
+ * @param kind - The mark `sync` gave it, or `undefined`.
15872
+ * @param bytes - Its bytes.
15873
+ */
15874
+ function addMarked(kind, bytes) {
15875
+ if (kind === "text") usage$1.text += bytes;
15876
+ else if (kind === "art") usage$1.art += bytes;
15877
+ else usage$1.other += bytes;
15878
+ }
15879
+ /**
15880
+ * The scratch of the bucket walk: the kept sources it skips, set for the length of one `idleTargetBytes` call, and the
15881
+ * bytes it summed so far. One walk at a time, nothing of it leaves.
15882
+ */
15883
+ const walk$2 = {
15884
+ kept: void 0,
15885
+ bytes: 0
15886
+ };
15887
+ /**
15888
+ * The bytes of one texture that waits for reuse: a live source the engine does not keep.
15889
+ *
15890
+ * @param texture - An idle texture.
15891
+ * @param kept - The sources the engine keeps as pictures.
15892
+ * @returns Its bytes, or 0.
15893
+ */
15894
+ function idleBytes(texture, kept) {
15895
+ if (texture === void 0) return 0;
15896
+ const { source } = texture;
15897
+ return source.destroyed || kept.has(source) ? 0 : sourceBytes(source);
15898
+ }
15899
+ /**
15900
+ * Adds the idle textures of one bucket of Pixi's pool to the walk: the callback `Map.prototype.forEach` takes, made
15901
+ * once at module level, so the walk makes no function and no iterator.
15902
+ *
15903
+ * @param textures - The idle textures of one bucket.
15904
+ */
15905
+ function addBucket(textures) {
15906
+ const { kept } = walk$2;
15907
+ if (kept === void 0) return;
15908
+ for (let index = 0; index < textures.length; index += 1) walk$2.bytes += idleBytes(textures[index], kept);
15909
+ }
15910
+ /**
15911
+ * The bytes of the render targets waiting for reuse: the idle textures of Pixi's `TexturePool` and the targets the
15912
+ * trim holds until their bind groups let go (`pool.held`). A texture counts when its source is not destroyed and not
15913
+ * kept. Reads the private buckets of Pixi 8, as the trim does; without them it answers 0. Makes nothing: one
15914
+ * `forEach` with a module-level callback, indexed walks inside.
15915
+ *
15916
+ * @param pixi - The module the renderer loaded.
15917
+ * @param held - The targets the trim holds.
15918
+ * @param kept - The sources the engine keeps as pictures.
15919
+ * @returns The bytes.
15920
+ */
15921
+ function idleTargetBytes(pixi, held, kept) {
15922
+ const buckets = pixi.TexturePool._buckets;
15923
+ if (!(buckets instanceof Map)) return 0;
15924
+ walk$2.kept = kept;
15925
+ walk$2.bytes = 0;
15926
+ buckets.forEach(addBucket);
15927
+ let bytes = walk$2.bytes;
15928
+ walk$2.kept = void 0;
15929
+ walk$2.bytes = 0;
15930
+ for (let index = 0; index < held.length; index += 1) bytes += idleBytes(held[index], kept);
15931
+ return bytes;
15847
15932
  }
15848
15933
  /**
15849
15934
  * Hides containers for the length of one synchronous call and shows them again right after it,
@@ -15955,7 +16040,7 @@ function beginLoss(ctx, kind, reason) {
15955
16040
  const info = {
15956
16041
  kind,
15957
16042
  reason,
15958
- textureBytes: state.app === void 0 ? 0 : textureUsage(state.app, state.kept).bytes
16043
+ textureBytes: state.app === void 0 ? 0 : textureUsage(state.app, state).bytes
15959
16044
  };
15960
16045
  state.ready = false;
15961
16046
  state.restoring = true;
@@ -17488,6 +17573,14 @@ function emptyWeakSet$3() {
17488
17573
  return /* @__PURE__ */ new WeakSet();
17489
17574
  }
17490
17575
  /**
17576
+ * Creates an empty weak map, out of the exported declaration for lint rule L5 as `emptyWeakSet` is.
17577
+ *
17578
+ * @returns An empty weak map.
17579
+ */
17580
+ function emptyWeakMap$3() {
17581
+ return /* @__PURE__ */ new WeakMap();
17582
+ }
17583
+ /**
17491
17584
  * Creates the state of the pool trim: no frame drawn, no scene change waiting, no rest judged, nothing trimmed.
17492
17585
  *
17493
17586
  * @returns The pool branch of the host state.
@@ -17504,8 +17597,8 @@ function createPoolState() {
17504
17597
  /**
17505
17598
  * Creates the initial host state: no Pixi, no application, nothing drawn, nothing listening, no
17506
17599
  * counting, no bitmap text pipe and no render-group pipe installed, the resolution of a page without a window (device
17507
- * pixels 1, cap 2, no override, nothing pending, the whole scale, no scale allowed yet), no own GPU, no kept picture
17508
- * and no pool trim yet.
17600
+ * pixels 1, cap 2, no override, nothing pending, the whole scale, no scale allowed yet), no own GPU, no kept picture,
17601
+ * no marked or idle source and no pool trim yet.
17509
17602
  *
17510
17603
  * @returns The host branch of the plugin state.
17511
17604
  */
@@ -17541,6 +17634,8 @@ function createHostState() {
17541
17634
  onResolutionChange: [],
17542
17635
  ownGpu: void 0,
17543
17636
  kept: emptyWeakSet$3(),
17637
+ marks: emptyWeakMap$3(),
17638
+ idle: emptyWeakSet$3(),
17544
17639
  pixelsFailed: false,
17545
17640
  pool: createPoolState(),
17546
17641
  onTrim: [],
@@ -17940,11 +18035,11 @@ function cellU8(column, index) {
17940
18035
  * managed textures; called only when a trim is due.
17941
18036
  *
17942
18037
  * @param app - The application that draws.
17943
- * @param kept - The sources the engine keeps as pictures: never counted as targets.
18038
+ * @param kinds - The host state: its kept pictures are never counted as targets.
17944
18039
  * @returns The bytes.
17945
18040
  */
17946
- function targetBytes(app, kept) {
17947
- return textureUsage(app, kept).targets;
18041
+ function targetBytes(app, kinds) {
18042
+ return textureUsage(app, kinds).targets;
17948
18043
  }
17949
18044
  /**
17950
18045
  * Which trim is due after a frame: a rest once the screen drew nothing for `restMs`, once per rest; else a scene
@@ -18027,9 +18122,9 @@ function trimPool(ctx, reason) {
18027
18122
  const state = ctx.state.host;
18028
18123
  const { app, pixi } = state;
18029
18124
  if (!state.ready || pixi === void 0 || app === void 0) return 0;
18030
- const before = targetBytes(app, state.kept);
18125
+ const before = targetBytes(app, state);
18031
18126
  clearPool(pixi, state.pool.held);
18032
- const after = targetBytes(app, state.kept);
18127
+ const after = targetBytes(app, state);
18033
18128
  const freedMb = roundTo((before - after) / BYTES_PER_MB$2, 2);
18034
18129
  state.pool.baseline = after;
18035
18130
  state.pool.restDone = true;
@@ -18062,7 +18157,7 @@ function afterFrame(ctx, drawn) {
18062
18157
  }
18063
18158
  const due = dueReason(pool, config, now, drawn);
18064
18159
  if (due === void 0) return;
18065
- if (targetBytes(app, state.kept) - pool.baseline < config.aboveMb * 1048576) {
18160
+ if (targetBytes(app, state) - pool.baseline < config.aboveMb * 1048576) {
18066
18161
  pool.restDone = true;
18067
18162
  pool.sceneAt = void 0;
18068
18163
  return;
@@ -18080,7 +18175,7 @@ function trimOnPause(ctx) {
18080
18175
  const state = ctx.state.host;
18081
18176
  const app = state.app;
18082
18177
  if (!state.ready || app === void 0) return 0;
18083
- return targetBytes(app, state.kept) > state.pool.baseline ? trimPool(ctx, "pause") : 0;
18178
+ return targetBytes(app, state) > state.pool.baseline ? trimPool(ctx, "pause") : 0;
18084
18179
  }
18085
18180
  /**
18086
18181
  * Remembers a scene change; the policy trims `restMs` after it. A later change moves the moment.
@@ -18253,6 +18348,13 @@ function createHostApi(ctx, deps) {
18253
18348
  if (on) state.kept.add(source);
18254
18349
  else state.kept.delete(source);
18255
18350
  },
18351
+ mark: (source, kind) => {
18352
+ state.marks.set(source, kind);
18353
+ },
18354
+ idle: (source, on) => {
18355
+ if (on) state.idle.add(source);
18356
+ else state.idle.delete(source);
18357
+ },
18256
18358
  extract: async (hidden) => {
18257
18359
  const app = state.app;
18258
18360
  if (!state.ready || app === void 0) return void 0;
@@ -18268,10 +18370,16 @@ function createHostApi(ctx, deps) {
18268
18370
  count: 0,
18269
18371
  bytes: 0,
18270
18372
  art: 0,
18373
+ text: 0,
18271
18374
  targets: 0,
18272
- kept: 0
18375
+ kept: 0,
18376
+ other: 0,
18377
+ idleTargets: 0,
18378
+ idleKept: 0
18273
18379
  };
18274
- return textureUsage(app, state.kept);
18380
+ const usage = textureUsage(app, state);
18381
+ if (state.pixi !== void 0) usage.idleTargets = idleTargetBytes(state.pixi, state.pool.held, state.kept);
18382
+ return usage;
18275
18383
  },
18276
18384
  pixels: (resolution) => {
18277
18385
  const app = state.app;
@@ -18835,7 +18943,8 @@ function fromPool(kctx, size) {
18835
18943
  }
18836
18944
  /**
18837
18945
  * Puts a texture of a record whose view left into the pool (F119), for the next take of its size: a scene that leaves
18838
- * and comes back makes no render target. Its bytes count in the budget until it is taken or dropped.
18946
+ * and comes back makes no render target. Its bytes count in the budget, and as idle in `host.textures()`, until it is
18947
+ * taken or dropped.
18839
18948
  *
18840
18949
  * @param kctx - The kept context.
18841
18950
  * @param texture - The texture.
@@ -18847,9 +18956,10 @@ function poolTexture(kctx, texture) {
18847
18956
  kctx.state.pool.push(texture);
18848
18957
  kctx.state.bytes += bytes;
18849
18958
  kctx.state.poolBytes += bytes;
18959
+ kctx.host.idle(source, true);
18850
18960
  }
18851
18961
  /**
18852
- * Gives back the bytes of a texture that left the pool.
18962
+ * Gives back the bytes of a texture that left the pool, taken or destroyed; it is idle no longer.
18853
18963
  *
18854
18964
  * @param kctx - The kept context.
18855
18965
  * @param texture - The texture.
@@ -18859,6 +18969,7 @@ function unpool(kctx, texture) {
18859
18969
  const bytes = textureBytes(source.width, source.height, source.resolution);
18860
18970
  kctx.state.bytes -= bytes;
18861
18971
  kctx.state.poolBytes -= bytes;
18972
+ kctx.host.idle(source, false);
18862
18973
  }
18863
18974
  /**
18864
18975
  * Destroys every texture of the pool and gives its bytes back: room for a take, a reset.
@@ -26098,8 +26209,14 @@ function sampleLine(pc, start, end) {
26098
26209
  count: usage.count,
26099
26210
  mb: ms(usage.bytes / BYTES_PER_MB$2),
26100
26211
  art: ms(usage.art / BYTES_PER_MB$2),
26212
+ text: ms(usage.text / BYTES_PER_MB$2),
26101
26213
  targets: ms(usage.targets / BYTES_PER_MB$2),
26102
- kept: ms(usage.kept / BYTES_PER_MB$2)
26214
+ kept: ms(usage.kept / BYTES_PER_MB$2),
26215
+ other: ms(usage.other / BYTES_PER_MB$2),
26216
+ idle: {
26217
+ targets: ms(usage.idleTargets / BYTES_PER_MB$2),
26218
+ kept: ms(usage.idleKept / BYTES_PER_MB$2)
26219
+ }
26103
26220
  },
26104
26221
  views: views.views,
26105
26222
  pooled: views.pooled,
@@ -28257,8 +28374,14 @@ function createMonitorApi(ctx, deps) {
28257
28374
  textureMb: roundTo(usage.bytes / BYTES_PER_MB$2, 2),
28258
28375
  textureMbSplit: {
28259
28376
  art: roundTo(usage.art / BYTES_PER_MB$2, 2),
28377
+ text: roundTo(usage.text / BYTES_PER_MB$2, 2),
28260
28378
  targets: roundTo(usage.targets / BYTES_PER_MB$2, 2),
28261
- kept: roundTo(usage.kept / BYTES_PER_MB$2, 2)
28379
+ kept: roundTo(usage.kept / BYTES_PER_MB$2, 2),
28380
+ other: roundTo(usage.other / BYTES_PER_MB$2, 2),
28381
+ idle: {
28382
+ targets: roundTo(usage.idleTargets / BYTES_PER_MB$2, 2),
28383
+ kept: roundTo(usage.idleKept / BYTES_PER_MB$2, 2)
28384
+ }
28262
28385
  },
28263
28386
  views: counts.views,
28264
28387
  pooled: counts.pooled,
@@ -29529,9 +29652,12 @@ function isDrawn(view, root) {
29529
29652
  function passesOf(slots) {
29530
29653
  let passes = 0;
29531
29654
  let enabled = false;
29532
- for (const slot of slots) if (slot.filter.enabled) {
29533
- passes += slot.passes;
29534
- enabled = true;
29655
+ for (let index = 0; index < slots.length; index += 1) {
29656
+ const slot = slots[index];
29657
+ if (slot?.filter.enabled) {
29658
+ passes += slot.passes;
29659
+ enabled = true;
29660
+ }
29535
29661
  }
29536
29662
  return enabled ? 1 + passes : 0;
29537
29663
  }
@@ -29552,7 +29678,9 @@ function addFiltered(slots, entity) {
29552
29678
  const { sync, kept } = walk$1;
29553
29679
  if (sync === void 0 || kept === void 0 || sync.root === void 0) return;
29554
29680
  const cache = sync.passes;
29555
- for (const slot of slots) {
29681
+ for (let index = 0; index < slots.length; index += 1) {
29682
+ const slot = slots[index];
29683
+ if (slot === void 0) continue;
29556
29684
  cache.filters[cache.count] = slot.filter;
29557
29685
  cache.enabled[cache.count] = slot.filter.enabled;
29558
29686
  cache.count += 1;
@@ -30416,7 +30544,7 @@ function parseFont(pixi, key, fnt) {
30416
30544
  /**
30417
30545
  * Installs a font for an asset key. Installing the same key again replaces the font, which is
30418
30546
  * what a bundle that was unloaded and loaded again needs. The first font of a device queues the
30419
- * text probe of the warm-up (F4).
30547
+ * text probe of the warm-up (F4). Its page counts as text in `stats().textureMbSplit` (F236).
30420
30548
  *
30421
30549
  * @param sctx - Domain context of the sync module.
30422
30550
  * @param key - The asset key of the font.
@@ -30433,6 +30561,7 @@ function installFont$1(sctx, key, fnt, texture) {
30433
30561
  textures: [texture]
30434
30562
  });
30435
30563
  drawFromLineTop(font);
30564
+ sctx.deps.host.mark(texture.source, "text");
30436
30565
  const cacheKey = `${key}${CACHE_SUFFIX}`;
30437
30566
  if (pixi.Cache.has(cacheKey)) pixi.Cache.remove(cacheKey);
30438
30567
  pixi.Cache.set(cacheKey, font);
@@ -31940,6 +32069,7 @@ function defaultBordersOf(nine) {
31940
32069
  /**
31941
32070
  * Makes a Pixi texture out of a decoded image, on behalf of `assets`, which decides when it leaves the GPU.
31942
32071
  * An ImageBitmap is held until its source is on the GPU, then closed and replaced by a 1x1 stand-in (sync/release.ts).
32072
+ * Its source counts as art in `stats().textureMbSplit` (F236).
31943
32073
  *
31944
32074
  * @param sctx - Domain context of the sync module.
31945
32075
  * @param image - The decoded image.
@@ -31955,6 +32085,7 @@ function createTexture(sctx, image, options) {
31955
32085
  }) : pixi.Texture.from(image);
31956
32086
  const nine = options?.nine;
31957
32087
  base.source.autoGarbageCollect = false;
32088
+ sctx.deps.host.mark(base.source, "art");
31958
32089
  holdImage(sctx.ctx.state.sync, base.source);
31959
32090
  if (nine === void 0) return base;
31960
32091
  const bordered = new pixi.Texture({
@@ -32320,7 +32451,7 @@ const DOUBLE_SEED$1 = .5;
32320
32451
  * (`position.x = x`) takes the number as an argument, and a double handed to a call that is not inlined is boxed: 16 B
32321
32452
  * a frame, whether it is inlined or not depends on the optimizer's budget (`transition.perf.ts`).
32322
32453
  */
32323
- const AT = {
32454
+ const AT$1 = {
32324
32455
  x: DOUBLE_SEED$1,
32325
32456
  y: DOUBLE_SEED$1
32326
32457
  };
@@ -32620,8 +32751,8 @@ function paintSprite(sprite, picture, playing, screen) {
32620
32751
  const eased = EASED[0] ?? 0;
32621
32752
  const { transition } = playing;
32622
32753
  if (sprite.texture !== picture) sprite.texture = picture;
32623
- AT.x = screen.x;
32624
- AT.y = screen.y;
32754
+ AT$1.x = screen.x;
32755
+ AT$1.y = screen.y;
32625
32756
  SCALED.x = screen.width / picture.width;
32626
32757
  SCALED.y = screen.height / picture.height;
32627
32758
  if (transition.kind !== "slide") {
@@ -32632,15 +32763,15 @@ function paintSprite(sprite, picture, playing, screen) {
32632
32763
  sprite.alpha = 1;
32633
32764
  switch (transition.to) {
32634
32765
  case "left":
32635
- AT.x = screen.x - eased * screen.width;
32766
+ AT$1.x = screen.x - eased * screen.width;
32636
32767
  break;
32637
32768
  case "right":
32638
- AT.x = screen.x + eased * screen.width;
32769
+ AT$1.x = screen.x + eased * screen.width;
32639
32770
  break;
32640
32771
  case "up":
32641
- AT.y = screen.y - eased * screen.height;
32772
+ AT$1.y = screen.y - eased * screen.height;
32642
32773
  break;
32643
- case "down": AT.y = screen.y + eased * screen.height;
32774
+ case "down": AT$1.y = screen.y + eased * screen.height;
32644
32775
  }
32645
32776
  placeAt(sprite);
32646
32777
  }
@@ -32651,7 +32782,7 @@ function paintSprite(sprite, picture, playing, screen) {
32651
32782
  * @param shown - The sprite or the mesh.
32652
32783
  */
32653
32784
  function placeAt(shown) {
32654
- shown.position.copyFrom(AT);
32785
+ shown.position.copyFrom(AT$1);
32655
32786
  shown.scale.copyFrom(SCALED);
32656
32787
  }
32657
32788
  /**
@@ -32860,8 +32991,8 @@ function paintMesh(sctx, pixi, objects, playing, screen) {
32860
32991
  }
32861
32992
  const { mesh } = picture;
32862
32993
  if (mesh.shader !== shader) mesh.shader = shader;
32863
- AT.x = screen.x;
32864
- AT.y = screen.y;
32994
+ AT$1.x = screen.x;
32995
+ AT$1.y = screen.y;
32865
32996
  SCALED.x = screen.width;
32866
32997
  SCALED.y = screen.height;
32867
32998
  placeAt(mesh);
@@ -35934,7 +36065,7 @@ function writeTrail(ctx, trail, record) {
35934
36065
  record.uptimeS = uptimeOf(now);
35935
36066
  record.path = pathOf$1(ctx);
35936
36067
  record.kind = host.kind;
35937
- record.textureMb = host.app === void 0 ? 0 : tenth(textureUsage(host.app, host.kept).bytes / BYTES_PER_MB$1);
36068
+ record.textureMb = host.app === void 0 ? 0 : tenth(textureUsage(host.app, host).bytes / BYTES_PER_MB$1);
35938
36069
  record.heapMb = heapMb$1();
35939
36070
  record.fps = spanMs > 0 ? tenth(trail.frames * MS_PER_S / spanMs) : 0;
35940
36071
  record.uploadFrames = trail.uploadFrames;
@@ -38227,7 +38358,10 @@ function keeps(record, key) {
38227
38358
  */
38228
38359
  function factorOf(order, key) {
38229
38360
  let factor = 1;
38230
- for (const record of order) factor += (keeps(record, key) - factor) * record.level;
38361
+ for (let index = 0; index < order.length; index += 1) {
38362
+ const record = order[index];
38363
+ if (record !== void 0) factor += (keeps(record, key) - factor) * record.level;
38364
+ }
38231
38365
  return factor;
38232
38366
  }
38233
38367
  /**
@@ -38239,7 +38373,10 @@ function factorOf(order, key) {
38239
38373
  */
38240
38374
  function targetOf$3(order, key) {
38241
38375
  let target = 1;
38242
- for (const record of order) if (record.phase !== "exiting") target = keeps(record, key);
38376
+ for (let index = 0; index < order.length; index += 1) {
38377
+ const record = order[index];
38378
+ if (record !== void 0 && record.phase !== "exiting") target = keeps(record, key);
38379
+ }
38243
38380
  return target;
38244
38381
  }
38245
38382
  /**
@@ -38251,7 +38388,9 @@ function targetOf$3(order, key) {
38251
38388
  * @returns True when a tap does not reach the part.
38252
38389
  */
38253
38390
  function inertOf(order, key) {
38254
- for (const record of order) {
38391
+ for (let index = 0; index < order.length; index += 1) {
38392
+ const record = order[index];
38393
+ if (record === void 0) continue;
38255
38394
  const { hud, hudInert } = record.value;
38256
38395
  if (!hudInert || hud === "none" || hud === "under") continue;
38257
38396
  if (hud === "all" || hud.includes(key)) return true;
@@ -38267,7 +38406,10 @@ function inertOf(order, key) {
38267
38406
  */
38268
38407
  function holdsSame(list, set) {
38269
38408
  if (list.length !== set.size) return false;
38270
- for (const node of list) if (!set.has(node)) return false;
38409
+ for (let index = 0; index < list.length; index += 1) {
38410
+ const node = list[index];
38411
+ if (node !== void 0 && !set.has(node)) return false;
38412
+ }
38271
38413
  return true;
38272
38414
  }
38273
38415
  /**
@@ -38285,7 +38427,10 @@ function keepOff(sctx, count) {
38285
38427
  if (holdsSame(offList, overlay.offTops)) return;
38286
38428
  const next = overlay.nextOff;
38287
38429
  if (next.size > 0) next.clear();
38288
- for (const top of offList) next.add(top);
38430
+ for (let index = 0; index < offList.length; index += 1) {
38431
+ const top = offList[index];
38432
+ if (top !== void 0) next.add(top);
38433
+ }
38289
38434
  overlay.nextOff = overlay.offTops;
38290
38435
  overlay.offTops = next;
38291
38436
  }
@@ -38307,6 +38452,41 @@ function warnOutside(sctx, entity, key) {
38307
38452
  key
38308
38453
  });
38309
38454
  }
38455
+ /** What the walk of the HUD parts reads, set before the walk: one at a time, no closure per frame. */
38456
+ const partsWalk = {
38457
+ sctx: void 0,
38458
+ hud: void 0,
38459
+ settling: false,
38460
+ count: 0
38461
+ };
38462
+ /**
38463
+ * Steps one HUD part of the walk: judged against the HUD layer, faded by the factor of the overlays, and noted in the
38464
+ * list of the tops that take no tap when it fades, is going to fade, or is kept by an inert overlay.
38465
+ *
38466
+ * @param entity - The part.
38467
+ */
38468
+ function stepPart(entity) {
38469
+ const { sctx, hud, settling } = partsWalk;
38470
+ if (sctx === void 0) return;
38471
+ const state = sctx.ctx.state.sync;
38472
+ const overlay = state.overlay;
38473
+ const view = state.views.get(entity);
38474
+ if (view === void 0) return;
38475
+ const key = sctx.ctx.deps.world.ecs.get(entity, HudPart)?.key ?? "";
38476
+ if (hud === void 0 || layerOf$1(sctx, entity) !== hud) {
38477
+ if (!(settling || sctx.ctx.deps.world.projection.isBuilding(entity))) warnOutside(sctx, entity, key);
38478
+ applyHud(sctx, entity, view, 1);
38479
+ return;
38480
+ }
38481
+ const factor = factorOf(overlay.order, key);
38482
+ applyHud(sctx, entity, view, factor);
38483
+ if (factor < 1 || targetOf$3(overlay.order, key) < 1 || inertOf(overlay.order, key)) {
38484
+ const top = view.wrapper ?? view.object;
38485
+ const { offList } = overlay;
38486
+ if (offList[partsWalk.count] !== top) offList[partsWalk.count] = top;
38487
+ partsWalk.count += 1;
38488
+ }
38489
+ }
38310
38490
  /**
38311
38491
  * The HUD parts: every part of the HUD layer is drawn with the factor of the overlays' levels of this frame, and the
38312
38492
  * parts leaving or not fully back take no tap, and the parts an inert overlay keeps shown take no tap either. A part
@@ -38320,29 +38500,14 @@ function stepParts(sctx) {
38320
38500
  const state = sctx.ctx.state.sync;
38321
38501
  const overlay = state.overlay;
38322
38502
  if (overlay.parts.size === 0 && overlay.offTops.size === 0) return;
38323
- const hud = state.hudLayer;
38324
- const settling = heldWaiting(sctx);
38325
- const ecs = sctx.ctx.deps.world.ecs;
38326
- const projection = sctx.ctx.deps.world.projection;
38327
- const { offList } = overlay;
38328
- let count = 0;
38329
- for (const entity of overlay.parts) {
38330
- const view = state.views.get(entity);
38331
- if (view === void 0) continue;
38332
- const key = ecs.get(entity, HudPart)?.key ?? "";
38333
- if (hud === void 0 || layerOf$1(sctx, entity) !== hud) {
38334
- if (!(settling || projection.isBuilding(entity))) warnOutside(sctx, entity, key);
38335
- applyHud(sctx, entity, view, 1);
38336
- continue;
38337
- }
38338
- const factor = factorOf(overlay.order, key);
38339
- applyHud(sctx, entity, view, factor);
38340
- if (factor < 1 || targetOf$3(overlay.order, key) < 1 || inertOf(overlay.order, key)) {
38341
- const top = view.wrapper ?? view.object;
38342
- if (offList[count] !== top) offList[count] = top;
38343
- count += 1;
38344
- }
38345
- }
38503
+ partsWalk.sctx = sctx;
38504
+ partsWalk.hud = state.hudLayer;
38505
+ partsWalk.settling = heldWaiting(sctx);
38506
+ partsWalk.count = 0;
38507
+ overlay.parts.forEach(stepPart);
38508
+ const count = partsWalk.count;
38509
+ partsWalk.sctx = void 0;
38510
+ partsWalk.hud = void 0;
38346
38511
  keepOff(sctx, count);
38347
38512
  }
38348
38513
  //#endregion
@@ -39713,10 +39878,10 @@ const NONE = {
39713
39878
  * The sizes of the probes: the public contract. A page, a game or the native shell sets `--moku-safe-*`; the editor sets
39714
39879
  * `--moku-device-safe-*` from its device preset, which a page's own value still overrides.
39715
39880
  */
39716
- const TOP = "var(--moku-safe-top, var(--moku-device-safe-top, env(safe-area-inset-top, 0px)))";
39717
- const RIGHT = "var(--moku-safe-right, var(--moku-device-safe-right, env(safe-area-inset-right, 0px)))";
39718
- const BOTTOM = "var(--moku-safe-bottom, var(--moku-device-safe-bottom, env(safe-area-inset-bottom, 0px)))";
39719
- const LEFT = "var(--moku-safe-left, var(--moku-device-safe-left, env(safe-area-inset-left, 0px)))";
39881
+ const TOP$1 = "var(--moku-safe-top, var(--moku-device-safe-top, env(safe-area-inset-top, 0px)))";
39882
+ const RIGHT$1 = "var(--moku-safe-right, var(--moku-device-safe-right, env(safe-area-inset-right, 0px)))";
39883
+ const BOTTOM$1 = "var(--moku-safe-bottom, var(--moku-device-safe-bottom, env(safe-area-inset-bottom, 0px)))";
39884
+ const LEFT$1 = "var(--moku-safe-left, var(--moku-device-safe-left, env(safe-area-inset-left, 0px)))";
39720
39885
  /**
39721
39886
  * Reads one CSS length in pixels.
39722
39887
  *
@@ -39773,12 +39938,12 @@ function createSafeAreaProbes() {
39773
39938
  const { document } = globalThis;
39774
39939
  return {
39775
39940
  start: createProbe(document, "start", {
39776
- width: LEFT,
39777
- height: TOP
39941
+ width: LEFT$1,
39942
+ height: TOP$1
39778
39943
  }),
39779
39944
  end: createProbe(document, "end", {
39780
- width: RIGHT,
39781
- height: BOTTOM
39945
+ width: RIGHT$1,
39946
+ height: BOTTOM$1
39782
39947
  })
39783
39948
  };
39784
39949
  }
@@ -42478,6 +42643,55 @@ function sumOffsets(actx, key) {
42478
42643
  return cellValue(SUM);
42479
42644
  }
42480
42645
  //#endregion
42646
+ //#region src/plugins/anim/tween/slots.ts
42647
+ /** Bytes of one double. */
42648
+ const DOUBLE = 8;
42649
+ /** The cells of the clock: running time and normalised time. */
42650
+ const CLOCK_CELLS = 2;
42651
+ /** How many arrays of doubles follow the clock (`targets`, `starts`, `values`, `seen`). */
42652
+ const DOUBLE_ARRAYS = 4;
42653
+ /** How many arrays of bytes follow the doubles (`live`, `moved`, `colors`, `partialMoved`). */
42654
+ const BYTE_ARRAYS = 4;
42655
+ /**
42656
+ * Cuts the nine typed arrays of a track out of one buffer: the arrays of doubles first, so each
42657
+ * starts on an aligned offset, then the arrays of bytes. `live` starts at 1 and `seen` at `NaN`,
42658
+ * the rest at 0.
42659
+ *
42660
+ * @param count - How many slots the track has.
42661
+ * @returns The nine views, all over the same `ArrayBuffer`.
42662
+ * @example
42663
+ * ```ts
42664
+ * const cells = slotCellsOf(2);
42665
+ * cells.targets.buffer === cells.live.buffer; // true
42666
+ * cells.targets.length; // 2
42667
+ * ```
42668
+ */
42669
+ function slotCellsOf(count) {
42670
+ const doubleBytes = (CLOCK_CELLS + DOUBLE_ARRAYS * count) * DOUBLE;
42671
+ const buffer = new ArrayBuffer(doubleBytes + BYTE_ARRAYS * count);
42672
+ const step = count * DOUBLE;
42673
+ const live = new Uint8Array(buffer, doubleBytes, count).fill(1);
42674
+ const targetsAt = 16;
42675
+ const startsAt = targetsAt + step;
42676
+ const valuesAt = startsAt + step;
42677
+ const seenAt = valuesAt + step;
42678
+ const movedAt = doubleBytes + count;
42679
+ const colorsAt = movedAt + count;
42680
+ const partialAt = colorsAt + count;
42681
+ const seen = new Float64Array(buffer, seenAt, count).fill(NaN);
42682
+ return {
42683
+ clock: new Float64Array(buffer, 0, CLOCK_CELLS),
42684
+ targets: new Float64Array(buffer, targetsAt, count),
42685
+ starts: new Float64Array(buffer, startsAt, count),
42686
+ values: new Float64Array(buffer, valuesAt, count),
42687
+ seen,
42688
+ live,
42689
+ moved: new Uint8Array(buffer, movedAt, count),
42690
+ colors: new Uint8Array(buffer, colorsAt, count),
42691
+ partialMoved: new Uint8Array(buffer, partialAt, count)
42692
+ };
42693
+ }
42694
+ //#endregion
42481
42695
  //#region src/plugins/anim/tween/advance.ts
42482
42696
  /**
42483
42697
  * @file anim/tween — the one track table: starting a track, the retarget policy per field, the
@@ -42937,28 +43151,27 @@ function endTrack(actx, track) {
42937
43151
  function dropField(actx, track, field) {
42938
43152
  delete track.to[field];
42939
43153
  track.live[track.names.indexOf(field)] = 0;
43154
+ track.kept -= 1;
42940
43155
  track.patch = { ...track.to };
42941
- if (Object.keys(track.to).length === 0) endTrack(actx, track);
43156
+ if (track.kept === 0) endTrack(actx, track);
42942
43157
  }
42943
43158
  /**
42944
- * Books every field of an absolute track and cancels the older owner of each, field by field.
43159
+ * Books every field of an absolute track and cancels the older owner of each, field by field: the
43160
+ * older owner drops the field as the walk reaches it, and ends with its last one.
42945
43161
  *
42946
43162
  * @param actx - Domain context of the anim plugin.
42947
43163
  * @param track - The new absolute track.
42948
43164
  */
42949
43165
  function claimFields(actx, track) {
42950
- const taken = [];
42951
- for (const field of Object.keys(track.to)) {
42952
- const key = keyOf$2(track, field);
43166
+ const { names, slotKeys } = track;
43167
+ for (let slot = 0; slot < names.length; slot++) {
43168
+ const field = names[slot] ?? "";
43169
+ const key = slotKeys[slot] ?? "";
42953
43170
  const ownerId = actx.state.owner.get(key);
42954
43171
  const older = ownerId === void 0 ? void 0 : actx.state.tracks.get(ownerId);
42955
43172
  actx.state.owner.set(key, track.id);
42956
- if (older !== void 0) taken.push({
42957
- older,
42958
- field
42959
- });
43173
+ if (older !== void 0) dropField(actx, older, field);
42960
43174
  }
42961
- for (const entry of taken) dropField(actx, entry.older, entry.field);
42962
43175
  }
42963
43176
  /**
42964
43177
  * Reports once each time the table grows past `maxTracks`, so a leak is visible in development
@@ -43014,6 +43227,24 @@ function targetOf$1(to, segments) {
43014
43227
  return Object.assign(target, to);
43015
43228
  }
43016
43229
  /**
43230
+ * The typed arrays of a new track, over one buffer, with the target and the colour flag of each
43231
+ * slot written in.
43232
+ *
43233
+ * @param component - The component the track writes.
43234
+ * @param names - The target fields in slot order.
43235
+ * @param target - The target record the track owns.
43236
+ * @returns The nine views of the track.
43237
+ */
43238
+ function cellsOf(component, names, target) {
43239
+ const cells = slotCellsOf(names.length);
43240
+ for (let slot = 0; slot < names.length; slot++) {
43241
+ const field = names[slot] ?? "";
43242
+ cells.targets[slot] = target[field] ?? 0;
43243
+ cells.colors[slot] = isColorField(component, field) ? 1 : 0;
43244
+ }
43245
+ return cells;
43246
+ }
43247
+ /**
43017
43248
  * Tells whether a field sizes a built-in visual: a loop of it may bring the view onto the screen. Pure.
43018
43249
  *
43019
43250
  * @param field - A field of a Sprite, a NineSlice or a Shape.
@@ -43098,17 +43329,11 @@ function startTrack$1(actx, entity, component, to, options, muted, driven = fals
43098
43329
  ms: instant ? 0 : options.ms,
43099
43330
  ease: options.ease ?? "out",
43100
43331
  delayMs: instant ? 0 : options.delayMs ?? 0,
43101
- clock: /* @__PURE__ */ new Float64Array(2),
43332
+ ...cellsOf(component, names, target),
43102
43333
  begun: false,
43103
43334
  names,
43335
+ kept: names.length,
43104
43336
  slotKeys: names.map((field) => keys[field] ?? ""),
43105
- targets: Float64Array.from(names, (field) => target[field] ?? 0),
43106
- starts: new Float64Array(names.length),
43107
- live: new Uint8Array(names.length).fill(1),
43108
- moved: new Uint8Array(names.length),
43109
- values: new Float64Array(names.length),
43110
- colors: Uint8Array.from(names, (field) => isColorField(component, field) ? 1 : 0),
43111
- seen: new Float64Array(names.length).fill(NaN),
43112
43337
  muted,
43113
43338
  additive: options.additive === true,
43114
43339
  driven,
@@ -43121,8 +43346,7 @@ function startTrack$1(actx, entity, component, to, options, muted, driven = fals
43121
43346
  keep,
43122
43347
  reveals: revealsOf(component, target),
43123
43348
  patch: { ...target },
43124
- partial: void 0,
43125
- partialMoved: new Uint8Array(names.length)
43349
+ partial: void 0
43126
43350
  };
43127
43351
  actx.state.nextId += 1;
43128
43352
  if (track.ended) return track;
@@ -64088,7 +64312,7 @@ function dropLayouts(state) {
64088
64312
  * @param style - The style name it shows it in.
64089
64313
  * @param box - The box of its `Text`.
64090
64314
  */
64091
- function keepSize(ctx, entity, resolved, style, box) {
64315
+ function keepSize$1(ctx, entity, resolved, style, box) {
64092
64316
  const layout = layoutFor(ctx, resolved, style, box);
64093
64317
  const size = ctx.state.measured.get(entity);
64094
64318
  if (size === void 0) ctx.state.measured.set(entity, sizeOf(layout));
@@ -64156,7 +64380,7 @@ function showBound(ctx, entity, text, next, value, style = text.style) {
64156
64380
  const restyled = style !== text.style;
64157
64381
  const changed = restyled || next !== text.resolved;
64158
64382
  if (changed) writeBound(ctx, entity, text, next, value, restyled ? style : void 0);
64159
- if (changed || !ctx.state.measured.has(entity)) keepSize(ctx, entity, next, style, text.box);
64383
+ if (changed || !ctx.state.measured.has(entity)) keepSize$1(ctx, entity, next, style, text.box);
64160
64384
  }
64161
64385
  /**
64162
64386
  * Writes the new string of a bound label, its new style when a named format picked another, and
@@ -64189,7 +64413,7 @@ function writeBound(ctx, entity, text, next, value, style) {
64189
64413
  */
64190
64414
  function showAgain(ctx, entity, text) {
64191
64415
  ctx.deps.world.ecs.set(entity, Text, { resolved: text.resolved });
64192
- keepSize(ctx, entity, text.resolved, text.style, text.box);
64416
+ keepSize$1(ctx, entity, text.resolved, text.style, text.box);
64193
64417
  }
64194
64418
  /**
64195
64419
  * Reports a bound label whose style is not a digits style, once per style. An unknown style name
@@ -64284,7 +64508,7 @@ function stepNamed(ctx, entity, text, bind, format, value, frame) {
64284
64508
  function standStill(ctx, entity, text, seen, marked) {
64285
64509
  if (!marked && !boxMoved(ctx, seen, text)) return;
64286
64510
  if (marked) showAgain(ctx, entity, text);
64287
- else keepSize(ctx, entity, text.resolved, text.style, text.box);
64511
+ else keepSize$1(ctx, entity, text.resolved, text.style, text.box);
64288
64512
  seen.box = text.box;
64289
64513
  }
64290
64514
  /**
@@ -64318,7 +64542,7 @@ function stepText(ctx, entity, text, frame) {
64318
64542
  return;
64319
64543
  }
64320
64544
  if (!isStale(ctx, entity, text, frame)) return;
64321
- keepSize(ctx, entity, resolveContent(ctx, entity, text), text.style, text.box);
64545
+ keepSize$1(ctx, entity, resolveContent(ctx, entity, text), text.style, text.box);
64322
64546
  ctx.state.dirty.delete(entity);
64323
64547
  remember(ctx, entity, text, frame);
64324
64548
  }
@@ -66591,10 +66815,51 @@ const NO_HOSTS = Object.freeze([]);
66591
66815
  */
66592
66816
  function isNameList(value) {
66593
66817
  if (!Array.isArray(value)) return false;
66594
- for (const name of value) if (typeof name !== "string") return false;
66818
+ for (let index = 0; index < value.length; index += 1) if (typeof value[index] !== "string") return false;
66595
66819
  return true;
66596
66820
  }
66597
66821
  /**
66822
+ * The walks of the hosting step over the host set and the hosted views: a callback each, made
66823
+ * once per jsx state, and the fields the walk under way reads and answers. A `for…of` over a set
66824
+ * or a map builds an iterator and its results while the code runs unoptimized (F230 U3).
66825
+ *
66826
+ * @param state - The jsx state the walks belong to.
66827
+ * @returns The walks.
66828
+ */
66829
+ function createHostWalk(state) {
66830
+ const walk = {
66831
+ ctx: void 0,
66832
+ name: "",
66833
+ owner: void 0,
66834
+ owners: (host) => {
66835
+ if (walk.owner !== void 0) return;
66836
+ const element = liveHost(state, host);
66837
+ if (element !== void 0 && hostsOf(element.node).includes(walk.name)) walk.owner = host;
66838
+ },
66839
+ hosting: (host) => {
66840
+ const element = liveHost(state, host);
66841
+ if (element !== void 0 && walk.ctx !== void 0) hostNames(walk.ctx, state, element);
66842
+ },
66843
+ releasing: (host, view) => {
66844
+ const ctx = walk.ctx;
66845
+ if (ctx === void 0 || stillHosts(ctx, state, view, host)) return;
66846
+ state.hosted.delete(view);
66847
+ unparent(ctx, view, host);
66848
+ }
66849
+ };
66850
+ return walk;
66851
+ }
66852
+ /**
66853
+ * The walks of one jsx state, made at their first use.
66854
+ *
66855
+ * @param state - The jsx state.
66856
+ * @returns Its walks.
66857
+ */
66858
+ function walkOf(state) {
66859
+ state.hostWalk ??= createHostWalk(state);
66860
+ return state.hostWalk;
66861
+ }
66862
+ /**
66598
66863
  * The projection names an element hosts. Allocates nothing: the prop itself, or one shared
66599
66864
  * empty list.
66600
66865
  *
@@ -66664,10 +66929,11 @@ function liveHost(state, host) {
66664
66929
  * @returns The owning host, `undefined` when no live host names the projection.
66665
66930
  */
66666
66931
  function ownerOf(state, name) {
66667
- for (const host of state.hosts) {
66668
- const element = liveHost(state, host);
66669
- if (element !== void 0 && hostsOf(element.node).includes(name)) return host;
66670
- }
66932
+ const walk = walkOf(state);
66933
+ walk.name = name;
66934
+ walk.owner = void 0;
66935
+ state.hosts.forEach(walk.owners);
66936
+ return walk.owner;
66671
66937
  }
66672
66938
  /**
66673
66939
  * Gives the host as parent to every view of one projection that has no parent and is not held
@@ -66685,7 +66951,10 @@ function parentViews(ctx, state, name, host) {
66685
66951
  const ecs = ctx.deps.world.ecs;
66686
66952
  const projection = ctx.deps.world.projection;
66687
66953
  const aside = projection.isBuilding(host);
66688
- for (const view of projection.entitiesOf(name)) {
66954
+ const views = projection.entitiesOf(name);
66955
+ for (let index = 0; index < views.length; index += 1) {
66956
+ const view = views[index];
66957
+ if (view === void 0) continue;
66689
66958
  if (ecs.has(view, Held) || projection.isBuilding(view) !== aside) continue;
66690
66959
  if (ecs.has(view, Parent) && !state.released.has(view)) continue;
66691
66960
  ecs.add(view, Parent({ entity: host }));
@@ -66747,10 +67016,9 @@ function hostViews(ctx, state, only) {
66747
67016
  state.membershipSeen = membership;
66748
67017
  releaseLeft(ctx, state);
66749
67018
  }
66750
- for (const host of only ?? state.hosts) {
66751
- const element = liveHost(state, host);
66752
- if (element !== void 0) hostNames(ctx, state, element);
66753
- }
67019
+ const walk = walkOf(state);
67020
+ walk.ctx = ctx;
67021
+ (only ?? state.hosts).forEach(walk.hosting);
66754
67022
  }
66755
67023
  /**
66756
67024
  * Takes the parent back from every hosted view its host no longer holds: the view falls back to
@@ -66761,12 +67029,9 @@ function hostViews(ctx, state, only) {
66761
67029
  */
66762
67030
  function releaseLeft(ctx, state) {
66763
67031
  if (state.released.size > 0) state.released.clear();
66764
- for (const view of state.hosted.keys()) {
66765
- const host = state.hosted.get(view);
66766
- if (host === void 0 || stillHosts(ctx, state, view, host)) continue;
66767
- state.hosted.delete(view);
66768
- unparent(ctx, view, host);
66769
- }
67032
+ const walk = walkOf(state);
67033
+ walk.ctx = ctx;
67034
+ state.hosted.forEach(walk.releasing);
66770
67035
  }
66771
67036
  /**
66772
67037
  * Hosts the views of every projection a live host names and owns; a name listed twice counts once.
@@ -68856,15 +69121,33 @@ function waits$1(state, root) {
68856
69121
  return (root.popup?.released === true || root.covered) && !state.removing.has(root.entity);
68857
69122
  }
68858
69123
  /**
69124
+ * The walk of the popup step over the roots: its callback made once per jsx state.
69125
+ *
69126
+ * @param state - The jsx state the walk belongs to.
69127
+ * @returns The walk.
69128
+ */
69129
+ function createPopupWalk(state) {
69130
+ const walk = {
69131
+ found: false,
69132
+ waiting: (root) => {
69133
+ if (!walk.found && waits$1(state, root)) walk.found = true;
69134
+ }
69135
+ };
69136
+ return walk;
69137
+ }
69138
+ /**
68859
69139
  * Tells whether any root waits for the settle step. Allocates nothing, so a frame without a
68860
- * released or covered popup costs one scan.
69140
+ * released or covered popup costs one scan: a callback made once, no iterator (F230 U3).
68861
69141
  *
68862
69142
  * @param state - The jsx state.
68863
69143
  * @returns True when at least one root waits.
68864
69144
  */
68865
69145
  function anyWaits(state) {
68866
- for (const root of state.roots.values()) if (waits$1(state, root)) return true;
68867
- return false;
69146
+ state.popupWalk ??= createPopupWalk(state);
69147
+ const walk = state.popupWalk;
69148
+ walk.found = false;
69149
+ state.roots.forEach(walk.waiting);
69150
+ return walk.found;
68868
69151
  }
68869
69152
  /**
68870
69153
  * The step at the top of every reconcile: released popup roots leave once the flow rests, the
@@ -71043,8 +71326,14 @@ function sameList(left, right) {
71043
71326
  * ```
71044
71327
  */
71045
71328
  function sameFieldsDeep(left, right) {
71046
- const keys = Object.keys(left);
71047
- return keys.length === Object.keys(right).length && keys.every((key) => Object.hasOwn(right, key) && sameValue(left[key], right[key]));
71329
+ let count = 0;
71330
+ for (const key in left) {
71331
+ if (!Object.hasOwn(left, key)) continue;
71332
+ if (!Object.hasOwn(right, key) || !sameValue(left[key], right[key])) return false;
71333
+ count += 1;
71334
+ }
71335
+ for (const key in right) if (Object.hasOwn(right, key)) count -= 1;
71336
+ return count === 0;
71048
71337
  }
71049
71338
  /**
71050
71339
  * Tells whether two prop values say the same. Plain objects and arrays are compared by value,
@@ -71405,7 +71694,11 @@ const WRITTEN = [
71405
71694
  * ```
71406
71695
  */
71407
71696
  function writesSame(previous, next) {
71408
- return WRITTEN.every((name) => sameValue(previous.props[name], next.props[name]));
71697
+ for (let index = 0; index < WRITTEN.length; index += 1) {
71698
+ const name = WRITTEN[index] ?? "";
71699
+ if (!sameValue(previous.props[name], next.props[name])) return false;
71700
+ }
71701
+ return true;
71409
71702
  }
71410
71703
  /**
71411
71704
  * The children one element is diffed against. A scroll container holds exactly one of them: the
@@ -71446,6 +71739,58 @@ function childrenOf(node, slots, axis = "y") {
71446
71739
  function identityOf(parentIdentity, node, index) {
71447
71740
  return `${parentIdentity}|${node.key ?? `${node.type}@${index}`}|${node.type}`;
71448
71741
  }
71742
+ /** The char code of `|`, the separator of an identity. */
71743
+ const BAR = 124;
71744
+ /** The char code of `@`, between the type and the index of an unkeyed name. */
71745
+ const AT = 64;
71746
+ /** The char code of `0`. */
71747
+ const ZERO = 48;
71748
+ /**
71749
+ * Tells whether an identity is the one `identityOf` builds for a node, without building it: the
71750
+ * parent identity, `|`, the key or the type, `@` and the index, `|`, the type, compared in place.
71751
+ *
71752
+ * @param identity - The identity an element keeps.
71753
+ * @param parentIdentity - The identity of the parent element.
71754
+ * @param node - The node being placed.
71755
+ * @param index - Its position among its siblings.
71756
+ * @returns True when `identityOf(parentIdentity, node, index)` equals `identity`.
71757
+ * @example
71758
+ * ```ts
71759
+ * isIdentityOf("0|row@2|row", "0", { type: "row", props: {}, children: [] }, 2); // true
71760
+ * ```
71761
+ */
71762
+ function isIdentityOf(identity, parentIdentity, node, index) {
71763
+ const type = node.type;
71764
+ const head = parentIdentity.length + 1;
71765
+ const tail = identity.length - type.length - 1;
71766
+ if (!(tail >= head && identity.startsWith(parentIdentity) && identity.charCodeAt(head - 1) === BAR && identity.charCodeAt(tail) === BAR && identity.endsWith(type))) return false;
71767
+ if (node.key !== void 0) return tail - head === node.key.length && identity.startsWith(node.key, head);
71768
+ const at = head + type.length;
71769
+ if (!identity.startsWith(type, head) || identity.charCodeAt(at) !== AT) return false;
71770
+ let digit = tail - 1;
71771
+ let rest = index;
71772
+ do {
71773
+ const last = rest % 10;
71774
+ if (digit <= at || identity.charCodeAt(digit) !== ZERO + last) return false;
71775
+ rest = (rest - last) / 10;
71776
+ digit -= 1;
71777
+ } while (rest > 0);
71778
+ return digit === at;
71779
+ }
71780
+ /**
71781
+ * The identity of a node placed where an element stood: the element's own string when it is the
71782
+ * one `identityOf` would build, so an element that stayed concatenates nothing; else a new one.
71783
+ *
71784
+ * @param parentIdentity - The identity of the parent element.
71785
+ * @param node - The node being placed.
71786
+ * @param index - Its position among its siblings.
71787
+ * @param old - The element that stood at that place at the last diff, if any.
71788
+ * @returns The identity.
71789
+ */
71790
+ function identityAt(parentIdentity, node, index, old) {
71791
+ if (old !== void 0 && isIdentityOf(old.identity, parentIdentity, node, index)) return old.identity;
71792
+ return identityOf(parentIdentity, node, index);
71793
+ }
71449
71794
  /**
71450
71795
  * Gives the subtree of a component the key the component tag carried, so the element is
71451
71796
  * addressable under the name the markup wrote.
@@ -71760,6 +72105,46 @@ function entitySet(entities) {
71760
72105
  return new Set(entities);
71761
72106
  }
71762
72107
  /**
72108
+ * Tells whether the entities a diff placed are a child list as it stands: the same entities in the
72109
+ * same order.
72110
+ *
72111
+ * @param placed - The entities of this render, a scratch buffer.
72112
+ * @param count - How many of them this render placed.
72113
+ * @param children - The child list of the last diff.
72114
+ * @returns True when the list stays.
72115
+ */
72116
+ function sameEntities(placed, count, children) {
72117
+ if (count !== children.length) return false;
72118
+ for (let index = 0; index < count; index += 1) if (placed[index] !== children[index]) return false;
72119
+ return true;
72120
+ }
72121
+ /**
72122
+ * The change record a reconciler writes every compare into, before its first compare.
72123
+ *
72124
+ * @returns A record with no flag set and an empty style.
72125
+ */
72126
+ function emptyChange() {
72127
+ return {
72128
+ is: {
72129
+ pressed: false,
72130
+ hover: false,
72131
+ focus: false,
72132
+ disabled: false,
72133
+ active: false,
72134
+ selected: false,
72135
+ covered: false
72136
+ },
72137
+ style: {},
72138
+ rowHeight: void 0,
72139
+ resolved: false,
72140
+ moved: false,
72141
+ measures: false,
72142
+ keepsText: false,
72143
+ keepsKey: false,
72144
+ unchanged: false
72145
+ };
72146
+ }
72147
+ /**
71763
72148
  * Collects the identities of the children of one render. Its own function, because lint rule L5
71764
72149
  * refuses a collection built inside an exported declaration.
71765
72150
  *
@@ -71855,6 +72240,35 @@ function createReconciler(ctx, modules, fields) {
71855
72240
  whole: (element, value) => writeValue(element, value),
71856
72241
  others: (element, type, next) => writeOthers(element, next, type)
71857
72242
  };
72243
+ const change = emptyChange();
72244
+ let expandedNode;
72245
+ let expandedInstance;
72246
+ const identityStack = [];
72247
+ const entityStack = [];
72248
+ let depth = 0;
72249
+ let viewportMoved = false;
72250
+ let dirtyCount = 0;
72251
+ let pendingCount = 0;
72252
+ let scrollsAside = false;
72253
+ const listDirty = (root) => {
72254
+ if (state.removing.has(root.entity)) return;
72255
+ if (viewportMoved) root.needsSolve = true;
72256
+ else if (!root.dirty) return;
72257
+ dirtyList[dirtyCount] = root;
72258
+ dirtyCount += 1;
72259
+ };
72260
+ const notePending = (root) => {
72261
+ const waits = root.element !== void 0 && lookup(root.element) !== void 0 && (root.needsSolve || root.slot !== void 0);
72262
+ root.pending = waits;
72263
+ if (waits) pendingCount += 1;
72264
+ };
72265
+ const listScroll = (entity) => {
72266
+ const element = state.elements.get(entity);
72267
+ if (element?.live !== true) return;
72268
+ if (parts.working() && parts.waits(state.roots.get(element.root))) return;
72269
+ if (!scrollsAside && isAsideScroll(element)) return;
72270
+ scrollList.push(element);
72271
+ };
71858
72272
  /**
71859
72273
  * Registers the key of an element under its root, so `find` and `entityOf` answer for it. A key
71860
72274
  * `ui` gave a node of its own, a spacer's, is never registered. A root built aside or held warm
@@ -72249,10 +72663,12 @@ function createReconciler(ctx, modules, fields) {
72249
72663
  function compare(root, element, node) {
72250
72664
  const previous = element.node;
72251
72665
  const parent = parentOf(element);
72252
- const is = isFlagsOf(node, {
72253
- pressed: element.is.pressed,
72254
- hover: element.is.hover,
72255
- focus: element.is.focus,
72666
+ const declared = node.props.state;
72667
+ const kept = element.is;
72668
+ const is = kept.covered === root.covered && kept.disabled === (declared?.disabled === true) && kept.active === (declared?.active === true) && kept.selected === (declared?.selected === true) ? kept : isFlagsOf(node, {
72669
+ pressed: kept.pressed,
72670
+ hover: kept.hover,
72671
+ focus: kept.focus,
72256
72672
  covered: root.covered
72257
72673
  });
72258
72674
  const rowHeight = range.rowHeightOf(parent, node);
@@ -72262,17 +72678,16 @@ function createReconciler(ctx, modules, fields) {
72262
72678
  const style = keepsStyle ? element.style : styleFor(parent, node, is);
72263
72679
  const sameContent = sameValue(previous.props.content, node.props.content);
72264
72680
  const keepsKey = namedKeyOf(element.style, previous.props.style) === namedKeyOf(style, node.props.style);
72265
- return {
72266
- is,
72267
- style,
72268
- rowHeight,
72269
- resolved: !keepsStyle,
72270
- moved: !keepsStyle && modules.layout.affectsRect(element.style, style),
72271
- measures: !stands || !sameStyle || !sameContent,
72272
- keepsText: sameStyle && sameContent && sameValue(previous.props.bind, node.props.bind),
72273
- keepsKey,
72274
- unchanged: keepsStyle && sameContent && writesSame(previous, node)
72275
- };
72681
+ change.is = is;
72682
+ change.style = style;
72683
+ change.rowHeight = rowHeight;
72684
+ change.resolved = !keepsStyle;
72685
+ change.moved = !keepsStyle && modules.layout.affectsRect(element.style, style);
72686
+ change.measures = !stands || !sameStyle || !sameContent;
72687
+ change.keepsText = sameStyle && sameContent && sameValue(previous.props.bind, node.props.bind);
72688
+ change.keepsKey = keepsKey;
72689
+ change.unchanged = keepsStyle && sameContent && writesSame(previous, node);
72690
+ return change;
72276
72691
  }
72277
72692
  /**
72278
72693
  * Writes what a patch changed on one element: its style onto the layout node when a rect or a
@@ -72284,15 +72699,16 @@ function createReconciler(ctx, modules, fields) {
72284
72699
  * @param change - What the patch found.
72285
72700
  */
72286
72701
  function rewrite(root, element, change) {
72287
- const applies = change.moved || change.measures;
72702
+ const { moved, keepsText, keepsKey } = change;
72703
+ const applies = moved || change.measures;
72288
72704
  if (change.resolved || applies) state.styled += 1;
72289
72705
  if (applies) {
72290
72706
  modules.layout.applyStyle(element);
72291
72707
  root.needsSolve = true;
72292
72708
  }
72293
72709
  if (!element.live) return;
72294
- writeLive(element, change.keepsText, change.keepsKey);
72295
- if (!change.moved) modules.layout.repose(element, parentRect(element), false, hintOf(state, element));
72710
+ writeLive(element, keepsText, keepsKey);
72711
+ if (!moved) modules.layout.repose(element, parentRect(element), false, hintOf(state, element));
72296
72712
  }
72297
72713
  /**
72298
72714
  * Updates one live element from its new node. An element whose description says what it said is
@@ -72313,11 +72729,12 @@ function createReconciler(ctx, modules, fields) {
72313
72729
  checkWindow(node);
72314
72730
  warnAxis(element, node);
72315
72731
  const change = compare(root, element, node);
72732
+ const { unchanged, rowHeight } = change;
72316
72733
  const motion = node.props.motion;
72317
72734
  const loopChanged = !sameLoop(element.motion?.loop, motion?.loop);
72318
72735
  const motionChanged = motion !== element.motion;
72319
72736
  if (typeof __MOKU_GAME_DEV__ !== "undefined" && __MOKU_GAME_DEV__) countRebuild(element, element.motion?.loop, motion?.loop);
72320
- if (!change.unchanged) delete element.basis;
72737
+ if (!unchanged) delete element.basis;
72321
72738
  element.node = node;
72322
72739
  element.is = change.is;
72323
72740
  element.style = change.style;
@@ -72326,11 +72743,11 @@ function createReconciler(ctx, modules, fields) {
72326
72743
  trackHost(state, element);
72327
72744
  if (element.type === "input") fields.patch(element);
72328
72745
  if (loopChanged && element.entered) modules.layout.loop(element);
72329
- if (!change.unchanged) {
72746
+ if (!unchanged) {
72330
72747
  rewrite(root, element, change);
72331
72748
  element.basis = {
72332
72749
  epoch: state.epoch,
72333
- rowHeight: change.rowHeight
72750
+ rowHeight
72334
72751
  };
72335
72752
  }
72336
72753
  if (typeof __MOKU_GAME_DEV__ !== "undefined" && __MOKU_GAME_DEV__ && motionChanged && element.live) warnIdleChanges(ctx, element);
@@ -72372,24 +72789,23 @@ function createReconciler(ctx, modules, fields) {
72372
72789
  }
72373
72790
  /**
72374
72791
  * Expands a component node with its instance, so the view runs with the local state of that
72375
- * identity.
72792
+ * identity. The subtree to place goes to `expandedNode`, the instance it belongs to to
72793
+ * `expandedInstance`: no object is built, and the caller reads both before it places anything.
72376
72794
  *
72377
72795
  * @param node - The node the markup wrote.
72378
72796
  * @param identity - Its identity.
72379
- * @returns The subtree to place and the instance it belongs to.
72380
72797
  */
72381
72798
  function expand(node, identity) {
72382
72799
  const definition = state.components.get(node.type);
72383
- if (definition === void 0) return {
72384
- node,
72385
- instance: void 0
72386
- };
72800
+ if (definition === void 0) {
72801
+ expandedNode = node;
72802
+ expandedInstance = void 0;
72803
+ return;
72804
+ }
72387
72805
  const instance = instanceFor(state, identity, definition, node.props);
72388
72806
  instance.dirty = false;
72389
- return {
72390
- node: runView(ctx, definition, instance, node.key),
72391
- instance: identity
72392
- };
72807
+ expandedNode = runView(ctx, definition, instance, node.key);
72808
+ expandedInstance = identity;
72393
72809
  }
72394
72810
  /**
72395
72811
  * Places one node: enter, patch, or exit and enter when the element at its identity is another
@@ -72406,10 +72822,11 @@ function createReconciler(ctx, modules, fields) {
72406
72822
  * @returns The entity of the element, or `undefined` when a component view threw.
72407
72823
  */
72408
72824
  function diffNode(root, parent, node, index, identity, instance) {
72409
- const expanded = expand(node, identity);
72410
- const view = expanded.node;
72411
- const owner = expanded.instance ?? instance;
72412
- const effective = view !== void 0 && expanded.instance !== void 0 ? withKey(view, node.key) : view;
72825
+ expand(node, identity);
72826
+ const view = expandedNode;
72827
+ const expansion = expandedInstance;
72828
+ const owner = expansion ?? instance;
72829
+ const effective = view !== void 0 && expansion !== void 0 ? withKey(view, node.key) : view;
72413
72830
  if (effective === void 0) return state.byIdentity.get(identity);
72414
72831
  const existing = state.byIdentity.get(identity);
72415
72832
  const element = existing === void 0 ? void 0 : state.elements.get(existing);
@@ -72443,22 +72860,67 @@ function createReconciler(ctx, modules, fields) {
72443
72860
  * @param instance - The identity of the nearest component instance.
72444
72861
  */
72445
72862
  function diffChildren(root, parent, nodes, instance) {
72446
- const identities = nodes.map((node, index) => identityOf(parent.identity, node, index));
72447
- leaveOut(parent, identities);
72448
- const next = [];
72449
- for (const [index, node] of nodes.entries()) {
72450
- const entity = diffNode(root, parent, node, index, identities[index] ?? identityOf(parent.identity, node, index), instance);
72451
- if (entity !== void 0) next.push(entity);
72863
+ const level = depth;
72864
+ depth += 1;
72865
+ try {
72866
+ diffChildrenAt(root, parent, nodes, instance, level);
72867
+ } finally {
72868
+ depth = level;
72869
+ }
72870
+ }
72871
+ /**
72872
+ * The diff of `diffChildren` on the scratch buffers of one depth: the identities of this render
72873
+ * and the entities they placed, counted, so an element whose children stayed builds no array, no
72874
+ * set and no string, and keeps its child list.
72875
+ *
72876
+ * @param root - The root being reconciled.
72877
+ * @param parent - The element whose children are diffed.
72878
+ * @param nodes - The children of this render.
72879
+ * @param instance - The identity of the nearest component instance.
72880
+ * @param level - The depth whose buffers this diff uses.
72881
+ */
72882
+ function diffChildrenAt(root, parent, nodes, instance, level) {
72883
+ const identities = identityStack[level] ?? [];
72884
+ const placed = entityStack[level] ?? [];
72885
+ const before = parent.children;
72886
+ identityStack[level] = identities;
72887
+ entityStack[level] = placed;
72888
+ for (let index = 0; index < nodes.length; index += 1) {
72889
+ const node = nodes[index];
72890
+ const old = before[index];
72891
+ if (node === void 0) continue;
72892
+ identities[index] = identityAt(parent.identity, node, index, old === void 0 ? void 0 : state.elements.get(old));
72893
+ }
72894
+ leaveOut(parent, identities, nodes.length);
72895
+ let count = 0;
72896
+ for (let index = 0; index < nodes.length; index += 1) {
72897
+ const node = nodes[index];
72898
+ if (node === void 0) continue;
72899
+ const identity = identities[index] ?? identityOf(parent.identity, node, index);
72900
+ const entity = diffNode(root, parent, node, index, identity, instance);
72901
+ if (entity === void 0) continue;
72902
+ placed[count] = entity;
72903
+ count += 1;
72452
72904
  }
72905
+ if (sameEntities(placed, count, parent.children)) return;
72906
+ commitChildren(root, parent, placed.slice(0, count));
72907
+ }
72908
+ /**
72909
+ * Makes a changed list of children the parent's: an old child no entity of this render took leaves,
72910
+ * the new ones are drawn in the order of the render and laid out again, and the root solves again.
72911
+ *
72912
+ * @param root - The root being reconciled.
72913
+ * @param parent - The element whose children changed.
72914
+ * @param next - The entities of this render, in markup order.
72915
+ */
72916
+ function commitChildren(root, parent, next) {
72453
72917
  const kept = entitySet(next);
72454
72918
  for (const old of parent.children) {
72455
72919
  if (kept.has(old) || state.exiting.has(old)) continue;
72456
72920
  const element = state.elements.get(old);
72457
72921
  if (element !== void 0) removeChild(parent, element);
72458
72922
  }
72459
- const same = next.length === parent.children.length && next.every((entity, index) => parent.children[index] === entity);
72460
72923
  parent.children = next;
72461
- if (same) return;
72462
72924
  placeChildren(parent, next);
72463
72925
  modules.layout.place(parent, next.map((entity) => state.elements.get(entity)).filter((element) => isElement(element)));
72464
72926
  root.needsSolve = true;
@@ -72504,14 +72966,18 @@ function createReconciler(ctx, modules, fields) {
72504
72966
  * starts, and everything under it plays its own, before a new child enters.
72505
72967
  *
72506
72968
  * @param parent - The element whose children are diffed.
72507
- * @param identities - The identities of the children of this render, in markup order.
72969
+ * @param identities - The identities of the children of this render, in markup order; a scratch
72970
+ * buffer, of which the first `count` are this render's.
72971
+ * @param count - How many children this render has.
72508
72972
  */
72509
- function leaveOut(parent, identities) {
72973
+ function leaveOut(parent, identities, count) {
72510
72974
  let listed;
72511
- for (const [index, old] of parent.children.entries()) {
72512
- const element = state.elements.get(old);
72513
- if (element === void 0 || identities[index] === element.identity) continue;
72514
- listed ??= identitySet(identities);
72975
+ const children = parent.children;
72976
+ for (let index = 0; index < children.length; index += 1) {
72977
+ const old = children[index];
72978
+ const element = old === void 0 ? void 0 : state.elements.get(old);
72979
+ if (element === void 0 || index < count && identities[index] === element.identity) continue;
72980
+ listed ??= identitySet(identities.slice(0, count));
72515
72981
  if (!listed.has(element.identity)) removeChild(parent, element);
72516
72982
  }
72517
72983
  }
@@ -72899,13 +73365,9 @@ function createReconciler(ctx, modules, fields) {
72899
73365
  * @returns How many roots wait.
72900
73366
  */
72901
73367
  function pendingRoots() {
72902
- let count = 0;
72903
- for (const root of state.roots.values()) {
72904
- const waits = root.element !== void 0 && lookup(root.element) !== void 0 && (root.needsSolve || root.slot !== void 0);
72905
- root.pending = waits;
72906
- if (waits) count += 1;
72907
- }
72908
- return count;
73368
+ pendingCount = 0;
73369
+ state.roots.forEach(notePending);
73370
+ return pendingCount;
72909
73371
  }
72910
73372
  /**
72911
73373
  * The box a root in a slot is solved in: the slot's content box, once the slot's own root needs
@@ -73174,10 +73636,10 @@ function createReconciler(ctx, modules, fields) {
73174
73636
  * @param root - The root to reconcile.
73175
73637
  */
73176
73638
  function reconcileRoot(root) {
73177
- const identity = identityOf(String(root.entity), root.tree, 0);
73178
73639
  const first = root.element === void 0;
73179
73640
  if (first) root.cause ??= ctx.deps.world.projection.causeOf(root.entity) ?? "change";
73180
73641
  const previous = root.element === void 0 ? void 0 : lookup(root.element);
73642
+ const identity = identityAt(String(root.entity), root.tree, 0, previous);
73181
73643
  if (previous !== void 0 && previous.identity !== identity) exitElement(previous, "change");
73182
73644
  state.building = first ? root.cause : "change";
73183
73645
  try {
@@ -73199,13 +73661,8 @@ function createReconciler(ctx, modules, fields) {
73199
73661
  */
73200
73662
  function scrollContainers(aside) {
73201
73663
  while (scrollList.length > 0) scrollList.pop();
73202
- for (const entity of state.scrolls) {
73203
- const element = state.elements.get(entity);
73204
- if (element?.live !== true) continue;
73205
- if (parts.working() && parts.waits(state.roots.get(element.root))) continue;
73206
- if (!aside && isAsideScroll(element)) continue;
73207
- scrollList.push(element);
73208
- }
73664
+ scrollsAside = aside;
73665
+ state.scrolls.forEach(listScroll);
73209
73666
  return scrollList;
73210
73667
  }
73211
73668
  /**
@@ -73220,15 +73677,10 @@ function createReconciler(ctx, modules, fields) {
73220
73677
  const root = state.roots.get(entity);
73221
73678
  if (root !== void 0 && !state.removing.has(entity)) root.dirty = true;
73222
73679
  }
73223
- let count = 0;
73224
- for (const root of state.roots.values()) {
73225
- if (state.removing.has(root.entity)) continue;
73226
- if (viewportChanged) root.needsSolve = true;
73227
- else if (!root.dirty) continue;
73228
- dirtyList[count] = root;
73229
- count += 1;
73230
- }
73231
- return count;
73680
+ dirtyCount = 0;
73681
+ viewportMoved = viewportChanged;
73682
+ state.roots.forEach(listDirty);
73683
+ return dirtyCount;
73232
73684
  }
73233
73685
  /**
73234
73686
  * Takes the order the projection wrote on a root's entity (spec 16 U1.6) and gives it to the
@@ -73778,6 +74230,44 @@ const LAYOUT_FIELDS = [
73778
74230
  "right",
73779
74231
  "bottom"
73780
74232
  ];
74233
+ const FLEX_DIRECTION = 0;
74234
+ const FLEX_WRAP = 1;
74235
+ const JUSTIFY = 2;
74236
+ const ALIGN_ITEMS = 3;
74237
+ const ALIGN_SELF = 4;
74238
+ const GROW = 5;
74239
+ const SHRINK = 6;
74240
+ const ASPECT = 7;
74241
+ const OVERFLOW = 8;
74242
+ const POSITION_TYPE = 9;
74243
+ const GAP = 10;
74244
+ /** The first padding length; the edges follow in the order top, right, bottom, left. */
74245
+ const PADDING = 12;
74246
+ /** The first margin length, in the same edge order. */
74247
+ const MARGIN = 20;
74248
+ const WIDTH = 28;
74249
+ const HEIGHT = 30;
74250
+ const MIN_WIDTH = 32;
74251
+ const MIN_HEIGHT = 34;
74252
+ const MAX_WIDTH = 36;
74253
+ const MAX_HEIGHT = 38;
74254
+ const LEFT = 40;
74255
+ const TOP = 42;
74256
+ const RIGHT = 44;
74257
+ const BOTTOM = 46;
74258
+ /** Slots of a kept record. */
74259
+ const SLOTS = 48;
74260
+ /**
74261
+ * The kind of a length a number writes, and of an unset length (its number `NaN`). It is 0, so a
74262
+ * new record holds it in every kind slot: the gap, the edges and the positions only ever take it.
74263
+ */
74264
+ const POINT = 0;
74265
+ /** The kind of a length a percent string writes. */
74266
+ const PERCENT = 1;
74267
+ /** The kind of a length `"auto"` writes; its number is `NaN`. */
74268
+ const AUTO = 2;
74269
+ /** The kind a staged extent takes when the style writes nothing for it. Never kept. */
74270
+ const SKIP = -1;
73781
74271
  /**
73782
74272
  * Tells whether two resolved styles would give the same rect.
73783
74273
  *
@@ -73795,6 +74285,266 @@ function layoutChanged(first, second) {
73795
74285
  return false;
73796
74286
  }
73797
74287
  /**
74288
+ * Reads what a node Yoga just made holds into a kept record: the enums and the flex factors through
74289
+ * their getters, once. A length is not read: its getter answers a `Value` object, so it starts
74290
+ * as Yoga's unset one, a point of `NaN`. The aspect ratio starts as one no style writes, so the
74291
+ * first write of every node calls `setAspectRatio`: the `isDirty()` of a node that never had
74292
+ * it called allocates 64 B a call (measured, `anchor.perf.ts`; a ratio of `NaN` does not cure it).
74293
+ *
74294
+ * @param yoga - The loaded Yoga module.
74295
+ * @returns The record of a fresh node.
74296
+ */
74297
+ function readFresh(yoga) {
74298
+ const node = yoga.Node.create();
74299
+ const fresh = new Float64Array(SLOTS);
74300
+ fresh[FLEX_DIRECTION] = node.getFlexDirection();
74301
+ fresh[FLEX_WRAP] = node.getFlexWrap();
74302
+ fresh[JUSTIFY] = node.getJustifyContent();
74303
+ fresh[ALIGN_ITEMS] = node.getAlignItems();
74304
+ fresh[ALIGN_SELF] = node.getAlignSelf();
74305
+ fresh[GROW] = node.getFlexGrow();
74306
+ fresh[SHRINK] = node.getFlexShrink();
74307
+ fresh[OVERFLOW] = node.getOverflow();
74308
+ fresh[POSITION_TYPE] = node.getPositionType();
74309
+ node.free();
74310
+ for (let slot = 11; slot < SLOTS; slot += 2) fresh[slot] = NaN;
74311
+ fresh[ASPECT] = Number.NEGATIVE_INFINITY;
74312
+ return fresh;
74313
+ }
74314
+ /**
74315
+ * Builds the tables a style write reads for one loaded Yoga module: the enum of every word a style
74316
+ * names, what a fresh node holds, read once from a node made for it, and the record a write stages
74317
+ * its numbers in.
74318
+ *
74319
+ * @param yoga - The loaded Yoga module.
74320
+ * @returns The tables.
74321
+ */
74322
+ function styleTablesOf(yoga) {
74323
+ return {
74324
+ yoga,
74325
+ justify: {
74326
+ start: yoga.JUSTIFY_FLEX_START,
74327
+ center: yoga.JUSTIFY_CENTER,
74328
+ end: yoga.JUSTIFY_FLEX_END,
74329
+ between: yoga.JUSTIFY_SPACE_BETWEEN,
74330
+ around: yoga.JUSTIFY_SPACE_AROUND,
74331
+ evenly: yoga.JUSTIFY_SPACE_EVENLY
74332
+ },
74333
+ align: {
74334
+ start: yoga.ALIGN_FLEX_START,
74335
+ center: yoga.ALIGN_CENTER,
74336
+ end: yoga.ALIGN_FLEX_END,
74337
+ stretch: yoga.ALIGN_STRETCH
74338
+ },
74339
+ alignSelf: {
74340
+ auto: yoga.ALIGN_AUTO,
74341
+ start: yoga.ALIGN_FLEX_START,
74342
+ center: yoga.ALIGN_CENTER,
74343
+ end: yoga.ALIGN_FLEX_END,
74344
+ stretch: yoga.ALIGN_STRETCH
74345
+ },
74346
+ overflow: {
74347
+ visible: yoga.OVERFLOW_VISIBLE,
74348
+ hidden: yoga.OVERFLOW_HIDDEN,
74349
+ scroll: yoga.OVERFLOW_SCROLL
74350
+ },
74351
+ fresh: readFresh(yoga),
74352
+ staged: new Float64Array(SLOTS)
74353
+ };
74354
+ }
74355
+ /**
74356
+ * The kept record of a node Yoga just made: a copy of what the tables read off a fresh node.
74357
+ *
74358
+ * @param tables - The tables of the loaded Yoga module.
74359
+ * @returns A record of its own.
74360
+ */
74361
+ function freshKept(tables) {
74362
+ return new Float64Array(tables.fresh);
74363
+ }
74364
+ /**
74365
+ * Notes a width and a height written onto a node outside a style write, as the anchor pass sizes
74366
+ * the tree of an anchor, so a later style write that sets them back is not skipped.
74367
+ *
74368
+ * @param kept - The node's kept record; none for a node `ui` did not make.
74369
+ * @param size - The width and the height written, in points. Read here, not handed over as two
74370
+ * numbers: a fractional number passed to a call V8 does not inline is boxed.
74371
+ * @param size.w - The width.
74372
+ * @param size.h - The height.
74373
+ */
74374
+ function keepSize(kept, size) {
74375
+ if (kept === void 0) return;
74376
+ kept[WIDTH] = POINT;
74377
+ kept[29] = size.w;
74378
+ kept[HEIGHT] = POINT;
74379
+ kept[31] = size.h;
74380
+ }
74381
+ /**
74382
+ * Whether an enum must be written, and keeps it when it must. With no record every value is
74383
+ * written, as before the records.
74384
+ *
74385
+ * @param kept - The node's kept record.
74386
+ * @param slot - The enum's slot.
74387
+ * @param value - The enum of this write.
74388
+ * @returns True when the setter must be called.
74389
+ */
74390
+ function enumMoved(kept, slot, value) {
74391
+ if (kept === void 0) return true;
74392
+ if (kept[slot] === value) return false;
74393
+ kept[slot] = value;
74394
+ return true;
74395
+ }
74396
+ /**
74397
+ * Whether a staged number must be written, and keeps it when it must: it differs from the kept
74398
+ * one unless both are equal or both unset (`NaN`).
74399
+ *
74400
+ * @param kept - The node's kept record.
74401
+ * @param staged - The staged values of this write.
74402
+ * @param slot - The number's slot.
74403
+ * @returns True when the setter must be called.
74404
+ */
74405
+ function numberMoved(kept, staged, slot) {
74406
+ if (kept === void 0) return true;
74407
+ const before = kept[slot];
74408
+ const after = staged[slot];
74409
+ if (before === after || Number.isNaN(before) && Number.isNaN(after)) return false;
74410
+ kept[slot] = after ?? NaN;
74411
+ return true;
74412
+ }
74413
+ /**
74414
+ * Whether a staged length must be written, and keeps it when it must: its kind and its number
74415
+ * both stand, or it is staged as nothing to write.
74416
+ *
74417
+ * @param kept - The node's kept record.
74418
+ * @param staged - The staged values of this write.
74419
+ * @param slot - The length's first slot.
74420
+ * @returns True when the setter must be called.
74421
+ */
74422
+ function lengthMoved(kept, staged, slot) {
74423
+ const kind = staged[slot];
74424
+ if (kind === SKIP) return false;
74425
+ if (kept === void 0) return true;
74426
+ if (kept[slot] === kind && !numberMoved(kept, staged, slot + 1)) return false;
74427
+ kept[slot] = kind ?? POINT;
74428
+ kept[slot + 1] = staged[slot + 1] ?? NaN;
74429
+ return true;
74430
+ }
74431
+ /** Where each edge's number sits from the first slot of a padding or margin (a kind comes first). */
74432
+ const EDGE_TOP_AT = 1;
74433
+ const EDGE_RIGHT_AT = 3;
74434
+ const EDGE_BOTTOM_AT = 5;
74435
+ const EDGE_LEFT_AT = 7;
74436
+ /**
74437
+ * Stages the four edges of a padding or margin given per edge; an edge it leaves out is unset.
74438
+ *
74439
+ * @param staged - The staged values of this write.
74440
+ * @param slot - The first slot of the four lengths.
74441
+ * @param edges - The edges.
74442
+ * @param edges.top - The top edge.
74443
+ * @param edges.right - The right edge.
74444
+ * @param edges.bottom - The bottom edge.
74445
+ * @param edges.left - The left edge.
74446
+ */
74447
+ function stageSides(staged, slot, edges) {
74448
+ staged[slot + EDGE_TOP_AT] = edges.top ?? NaN;
74449
+ staged[slot + EDGE_RIGHT_AT] = edges.right ?? NaN;
74450
+ staged[slot + EDGE_BOTTOM_AT] = edges.bottom ?? NaN;
74451
+ staged[slot + EDGE_LEFT_AT] = edges.left ?? NaN;
74452
+ }
74453
+ /**
74454
+ * Stages an extent that is not a number: a percent string, `"auto"`, or nothing. `undefined`
74455
+ * writes nothing, and so does `"auto"` on a min or max extent.
74456
+ *
74457
+ * @param staged - The staged values of this write.
74458
+ * @param slot - The extent's first slot.
74459
+ * @param value - What the style carries.
74460
+ * @param autoSkips - Whether `"auto"` writes nothing here.
74461
+ */
74462
+ function stageWord(staged, slot, value, autoSkips) {
74463
+ if (value === void 0 || autoSkips && value === "auto") staged[slot] = SKIP;
74464
+ else if (value === "auto") {
74465
+ staged[slot] = AUTO;
74466
+ staged[slot + 1] = NaN;
74467
+ } else {
74468
+ staged[slot] = value.endsWith("%") ? PERCENT : POINT;
74469
+ staged[slot + 1] = Number.parseFloat(value);
74470
+ }
74471
+ }
74472
+ /**
74473
+ * Stages the edges of the padding and the margin.
74474
+ *
74475
+ * @param staged - The staged values of this write.
74476
+ * @param style - The resolved style.
74477
+ */
74478
+ function stageEdges(staged, style) {
74479
+ const { padding, margin } = style;
74480
+ if (typeof padding === "object") stageSides(staged, PADDING, padding);
74481
+ else {
74482
+ const all = padding ?? NaN;
74483
+ staged[13] = all;
74484
+ staged[15] = all;
74485
+ staged[17] = all;
74486
+ staged[19] = all;
74487
+ }
74488
+ if (typeof margin === "object") stageSides(staged, MARGIN, margin);
74489
+ else {
74490
+ const all = margin ?? NaN;
74491
+ staged[21] = all;
74492
+ staged[23] = all;
74493
+ staged[25] = all;
74494
+ staged[27] = all;
74495
+ }
74496
+ }
74497
+ /**
74498
+ * Stages the six extents and the aspect ratio. A number is staged here, where it is read; a word by
74499
+ * `stageWord`.
74500
+ *
74501
+ * @param staged - The staged values of this write.
74502
+ * @param style - The resolved style.
74503
+ */
74504
+ function stageExtents(staged, style) {
74505
+ const { width, height, minWidth, minHeight, maxWidth, maxHeight } = style;
74506
+ if (typeof width === "number") {
74507
+ staged[WIDTH] = POINT;
74508
+ staged[29] = width;
74509
+ } else stageWord(staged, WIDTH, width, false);
74510
+ if (typeof height === "number") {
74511
+ staged[HEIGHT] = POINT;
74512
+ staged[31] = height;
74513
+ } else stageWord(staged, HEIGHT, height, false);
74514
+ if (typeof minWidth === "number") {
74515
+ staged[MIN_WIDTH] = POINT;
74516
+ staged[33] = minWidth;
74517
+ } else stageWord(staged, MIN_WIDTH, minWidth, true);
74518
+ if (typeof minHeight === "number") {
74519
+ staged[MIN_HEIGHT] = POINT;
74520
+ staged[35] = minHeight;
74521
+ } else stageWord(staged, MIN_HEIGHT, minHeight, true);
74522
+ if (typeof maxWidth === "number") {
74523
+ staged[MAX_WIDTH] = POINT;
74524
+ staged[37] = maxWidth;
74525
+ } else stageWord(staged, MAX_WIDTH, maxWidth, true);
74526
+ if (typeof maxHeight === "number") {
74527
+ staged[MAX_HEIGHT] = POINT;
74528
+ staged[39] = maxHeight;
74529
+ } else stageWord(staged, MAX_HEIGHT, maxHeight, true);
74530
+ staged[ASPECT] = style.aspect ?? NaN;
74531
+ }
74532
+ /**
74533
+ * Stages the numbers of the flow and position groups: gap, grow, shrink and the four positions.
74534
+ *
74535
+ * @param staged - The staged values of this write.
74536
+ * @param style - The resolved style.
74537
+ */
74538
+ function stageFlowAndPosition(staged, style) {
74539
+ staged[11] = style.gap ?? 0;
74540
+ staged[GROW] = style.grow ?? 0;
74541
+ staged[SHRINK] = style.shrink ?? 0;
74542
+ staged[41] = style.left ?? NaN;
74543
+ staged[43] = style.top ?? NaN;
74544
+ staged[45] = style.right ?? NaN;
74545
+ staged[47] = style.bottom ?? NaN;
74546
+ }
74547
+ /**
73798
74548
  * Reads one edge of a padding or margin.
73799
74549
  *
73800
74550
  * @param edges - What the resolved style carries.
@@ -73809,127 +74559,121 @@ function edge(edges, edge) {
73809
74559
  /**
73810
74560
  * Writes the flow group onto a node.
73811
74561
  *
73812
- * @param yoga - The loaded Yoga module, which carries the enums.
74562
+ * @param tables - The tables of the loaded Yoga module, its numbers staged.
73813
74563
  * @param node - The node of the element.
73814
74564
  * @param style - The resolved style.
73815
74565
  * @param column - Whether the tag lays its children out in a column.
74566
+ * @param kept - The node's kept record.
74567
+ */
74568
+ function applyFlow(tables, node, style, column, kept) {
74569
+ const { yoga, staged } = tables;
74570
+ const direction = (style.direction ?? (column ? "column" : "row")) === "row" ? yoga.FLEX_DIRECTION_ROW : yoga.FLEX_DIRECTION_COLUMN;
74571
+ const wrap = style.wrap === true ? yoga.WRAP_WRAP : yoga.WRAP_NO_WRAP;
74572
+ const justify = tables.justify[style.justify ?? "start"];
74573
+ const align = tables.align[style.align ?? "stretch"];
74574
+ const alignSelf = tables.alignSelf[style.alignSelf ?? "auto"];
74575
+ if (enumMoved(kept, FLEX_DIRECTION, direction)) node.setFlexDirection(direction);
74576
+ if (enumMoved(kept, FLEX_WRAP, wrap)) node.setFlexWrap(wrap);
74577
+ if (enumMoved(kept, JUSTIFY, justify)) node.setJustifyContent(justify);
74578
+ if (enumMoved(kept, ALIGN_ITEMS, align)) node.setAlignItems(align);
74579
+ if (enumMoved(kept, ALIGN_SELF, alignSelf)) node.setAlignSelf(alignSelf);
74580
+ if (lengthMoved(kept, staged, GAP)) node.setGap(yoga.GUTTER_ALL, style.gap ?? 0);
74581
+ if (numberMoved(kept, staged, GROW)) node.setFlexGrow(style.grow ?? 0);
74582
+ if (numberMoved(kept, staged, SHRINK)) node.setFlexShrink(style.shrink ?? 0);
74583
+ }
74584
+ /**
74585
+ * Writes the padding and the margin of one edge.
74586
+ *
74587
+ * @param node - The node of the element.
74588
+ * @param style - The resolved style.
74589
+ * @param kept - The node's kept record.
74590
+ * @param staged - The staged values of this write.
74591
+ * @param side - The edge, by name.
74592
+ * @param index - Its place in the order top, right, bottom, left.
74593
+ * @param which - The edge, as Yoga names it.
73816
74594
  */
73817
- function applyFlow(yoga, node, style, column) {
73818
- const direction = style.direction ?? (column ? "column" : "row");
73819
- node.setFlexDirection(direction === "row" ? yoga.FLEX_DIRECTION_ROW : yoga.FLEX_DIRECTION_COLUMN);
73820
- node.setFlexWrap(style.wrap === true ? yoga.WRAP_WRAP : yoga.WRAP_NO_WRAP);
73821
- node.setJustifyContent({
73822
- start: yoga.JUSTIFY_FLEX_START,
73823
- center: yoga.JUSTIFY_CENTER,
73824
- end: yoga.JUSTIFY_FLEX_END,
73825
- between: yoga.JUSTIFY_SPACE_BETWEEN,
73826
- around: yoga.JUSTIFY_SPACE_AROUND,
73827
- evenly: yoga.JUSTIFY_SPACE_EVENLY
73828
- }[style.justify ?? "start"]);
73829
- node.setAlignItems({
73830
- start: yoga.ALIGN_FLEX_START,
73831
- center: yoga.ALIGN_CENTER,
73832
- end: yoga.ALIGN_FLEX_END,
73833
- stretch: yoga.ALIGN_STRETCH
73834
- }[style.align ?? "stretch"]);
73835
- node.setAlignSelf({
73836
- auto: yoga.ALIGN_AUTO,
73837
- start: yoga.ALIGN_FLEX_START,
73838
- center: yoga.ALIGN_CENTER,
73839
- end: yoga.ALIGN_FLEX_END,
73840
- stretch: yoga.ALIGN_STRETCH
73841
- }[style.alignSelf ?? "auto"]);
73842
- node.setGap(yoga.GUTTER_ALL, style.gap ?? 0);
73843
- node.setFlexGrow(style.grow ?? 0);
73844
- node.setFlexShrink(style.shrink ?? 0);
73845
- }
73846
- /**
73847
- * Writes one extent through the right setter: `"auto"`, a percent string and a number are three
73848
- * different Yoga calls.
74595
+ function applyEdge(node, style, kept, staged, side, index, which) {
74596
+ if (lengthMoved(kept, staged, PADDING + index * 2)) node.setPadding(which, edge(style.padding, side));
74597
+ if (lengthMoved(kept, staged, MARGIN + index * 2)) node.setMargin(which, edge(style.margin, side));
74598
+ }
74599
+ /**
74600
+ * Writes the six extents through the right setter: `"auto"`, a percent string and a number are
74601
+ * three different Yoga calls. An extent staged as nothing to write is left alone.
73849
74602
  *
73850
74603
  * @param node - The node of the element.
73851
- * @param field - Which extent is written.
73852
- * @param value - What the style carries.
74604
+ * @param style - The resolved style.
74605
+ * @param kept - The node's kept record.
74606
+ * @param staged - The staged values of this write.
73853
74607
  */
73854
- function applyExtent(node, field, value) {
73855
- if (value === void 0) return;
73856
- if (field === "width") node.setWidth(value);
73857
- else if (field === "height") node.setHeight(value);
73858
- else if (value !== "auto") switch (field) {
73859
- case "minWidth":
73860
- node.setMinWidth(value);
73861
- break;
73862
- case "minHeight":
73863
- node.setMinHeight(value);
73864
- break;
73865
- case "maxWidth":
73866
- node.setMaxWidth(value);
73867
- break;
73868
- default: node.setMaxHeight(value);
73869
- }
74608
+ function applyExtents(node, style, kept, staged) {
74609
+ const { width, height, minWidth, minHeight, maxWidth, maxHeight } = style;
74610
+ if (lengthMoved(kept, staged, WIDTH)) node.setWidth(width);
74611
+ if (lengthMoved(kept, staged, HEIGHT)) node.setHeight(height);
74612
+ if (minWidth !== "auto" && lengthMoved(kept, staged, MIN_WIDTH)) node.setMinWidth(minWidth);
74613
+ if (minHeight !== "auto" && lengthMoved(kept, staged, MIN_HEIGHT)) node.setMinHeight(minHeight);
74614
+ if (maxWidth !== "auto" && lengthMoved(kept, staged, MAX_WIDTH)) node.setMaxWidth(maxWidth);
74615
+ if (maxHeight !== "auto" && lengthMoved(kept, staged, MAX_HEIGHT)) node.setMaxHeight(maxHeight);
73870
74616
  }
73871
74617
  /**
73872
74618
  * Writes the box group onto a node.
73873
74619
  *
73874
- * @param yoga - The loaded Yoga module.
74620
+ * @param tables - The tables of the loaded Yoga module, its numbers staged.
73875
74621
  * @param node - The node of the element.
73876
74622
  * @param style - The resolved style.
74623
+ * @param kept - The node's kept record.
73877
74624
  */
73878
- function applyBox(yoga, node, style) {
73879
- const edges = [
73880
- ["top", yoga.EDGE_TOP],
73881
- ["right", yoga.EDGE_RIGHT],
73882
- ["bottom", yoga.EDGE_BOTTOM],
73883
- ["left", yoga.EDGE_LEFT]
73884
- ];
73885
- for (const [name, which] of edges) {
73886
- node.setPadding(which, edge(style.padding, name));
73887
- node.setMargin(which, edge(style.margin, name));
73888
- }
73889
- applyExtent(node, "width", style.width);
73890
- applyExtent(node, "height", style.height);
73891
- applyExtent(node, "minWidth", style.minWidth);
73892
- applyExtent(node, "minHeight", style.minHeight);
73893
- applyExtent(node, "maxWidth", style.maxWidth);
73894
- applyExtent(node, "maxHeight", style.maxHeight);
73895
- node.setAspectRatio(style.aspect);
73896
- node.setOverflow({
73897
- visible: yoga.OVERFLOW_VISIBLE,
73898
- hidden: yoga.OVERFLOW_HIDDEN,
73899
- scroll: yoga.OVERFLOW_SCROLL
73900
- }[style.overflow ?? "visible"]);
74625
+ function applyBox(tables, node, style, kept) {
74626
+ const { yoga, staged } = tables;
74627
+ const overflow = tables.overflow[style.overflow ?? "visible"];
74628
+ applyEdge(node, style, kept, staged, "top", 0, yoga.EDGE_TOP);
74629
+ applyEdge(node, style, kept, staged, "right", 1, yoga.EDGE_RIGHT);
74630
+ applyEdge(node, style, kept, staged, "bottom", 2, yoga.EDGE_BOTTOM);
74631
+ applyEdge(node, style, kept, staged, "left", 3, yoga.EDGE_LEFT);
74632
+ applyExtents(node, style, kept, staged);
74633
+ if (numberMoved(kept, staged, ASPECT)) node.setAspectRatio(style.aspect);
74634
+ if (enumMoved(kept, OVERFLOW, overflow)) node.setOverflow(overflow);
73901
74635
  }
73902
74636
  /**
73903
74637
  * Writes the position group onto a node. A child of a `stack` is absolute unless it says
73904
74638
  * otherwise, which is what makes a stack a stack. A fitted element is absolute too: it keeps its
73905
74639
  * own size and never stretches its parent, and the solve centres it in the parent's content box.
73906
74640
  *
73907
- * @param yoga - The loaded Yoga module.
74641
+ * @param tables - The tables of the loaded Yoga module, its numbers staged.
73908
74642
  * @param node - The node of the element.
73909
74643
  * @param style - The resolved style.
73910
74644
  * @param stacked - Whether the parent tag is a `stack`.
74645
+ * @param kept - The node's kept record.
73911
74646
  */
73912
- function applyPosition(yoga, node, style, stacked) {
73913
- const absolute = style.position === "absolute" || style.fit === "contain" || stacked && style.position === void 0;
73914
- node.setPositionType(absolute ? yoga.POSITION_TYPE_ABSOLUTE : yoga.POSITION_TYPE_RELATIVE);
73915
- node.setPosition(yoga.EDGE_LEFT, style.left);
73916
- node.setPosition(yoga.EDGE_TOP, style.top);
73917
- node.setPosition(yoga.EDGE_RIGHT, style.right);
73918
- node.setPosition(yoga.EDGE_BOTTOM, style.bottom);
74647
+ function applyPosition(tables, node, style, stacked, kept) {
74648
+ const { yoga, staged } = tables;
74649
+ const type = style.position === "absolute" || style.fit === "contain" || stacked && style.position === void 0 ? yoga.POSITION_TYPE_ABSOLUTE : yoga.POSITION_TYPE_RELATIVE;
74650
+ if (enumMoved(kept, POSITION_TYPE, type)) node.setPositionType(type);
74651
+ if (lengthMoved(kept, staged, LEFT)) node.setPosition(yoga.EDGE_LEFT, style.left);
74652
+ if (lengthMoved(kept, staged, TOP)) node.setPosition(yoga.EDGE_TOP, style.top);
74653
+ if (lengthMoved(kept, staged, RIGHT)) node.setPosition(yoga.EDGE_RIGHT, style.right);
74654
+ if (lengthMoved(kept, staged, BOTTOM)) node.setPosition(yoga.EDGE_BOTTOM, style.bottom);
73919
74655
  }
73920
74656
  /**
73921
- * Writes one resolved style onto one Yoga node.
74657
+ * Writes one resolved style onto one Yoga node. With the node's kept record, a setter is called
74658
+ * only for a value that differs from the one the record keeps, and the record takes what was
74659
+ * written; without one, every setter is called. The order of the calls is the order of the groups:
74660
+ * flow, box (each edge's padding then margin, the extents, the ratio, the overflow), position.
73922
74661
  *
73923
74662
  * @param yoga - The loaded Yoga module.
73924
74663
  * @param node - The node of the element.
73925
74664
  * @param style - The resolved style.
73926
74665
  * @param tag - The intrinsic tag, which decides the default direction.
73927
74666
  * @param parentTag - The tag of the parent, which decides whether children stack.
74667
+ * @param kept - The node's kept record, made with the node; none writes every value.
74668
+ * @param tables - The tables of the loaded module; built for this call when none is given.
73928
74669
  */
73929
- function applyStyleToNode(yoga, node, style, tag, parentTag) {
73930
- applyFlow(yoga, node, style, tag !== "row");
73931
- applyBox(yoga, node, style);
73932
- applyPosition(yoga, node, style, parentTag === "stack");
74670
+ function applyStyleToNode(yoga, node, style, tag, parentTag, kept, tables = styleTablesOf(yoga)) {
74671
+ stageEdges(tables.staged, style);
74672
+ stageExtents(tables.staged, style);
74673
+ stageFlowAndPosition(tables.staged, style);
74674
+ applyFlow(tables, node, style, tag !== "row", kept);
74675
+ applyBox(tables, node, style, kept);
74676
+ applyPosition(tables, node, style, parentTag === "stack", kept);
73933
74677
  }
73934
74678
  //#endregion
73935
74679
  //#region src/plugins/ui/layout/motion.ts
@@ -74499,7 +75243,21 @@ function liftRest(ctx, element, units) {
74499
75243
  //#endregion
74500
75244
  //#region src/plugins/ui/layout/nodes.ts
74501
75245
  /**
74502
- * Creates the node of an element and counts it.
75246
+ * The style tables of the loaded module, built the first time a node of it is made.
75247
+ *
75248
+ * @param state - The layout state.
75249
+ * @param yoga - The loaded Yoga module.
75250
+ * @returns The tables.
75251
+ */
75252
+ function tablesOf(state, yoga) {
75253
+ const tables = state.tables;
75254
+ if (tables !== void 0 && tables.yoga === yoga) return tables;
75255
+ const built = styleTablesOf(yoga);
75256
+ state.tables = built;
75257
+ return built;
75258
+ }
75259
+ /**
75260
+ * Creates the node of an element and counts it, with the kept record of a fresh node.
74503
75261
  *
74504
75262
  * @param state - The layout state.
74505
75263
  * @param element - The element that entered.
@@ -74511,6 +75269,7 @@ function createNode(state, element) {
74511
75269
  if (existing !== void 0) return existing;
74512
75270
  const node = state.yoga.Node.create();
74513
75271
  state.byEntity.set(element.entity, node);
75272
+ state.kept.set(node, freshKept(tablesOf(state, state.yoga)));
74514
75273
  state.nodes += 1;
74515
75274
  return node;
74516
75275
  }
@@ -74538,6 +75297,7 @@ function freeNode(state, element) {
74538
75297
  detachNode(state, element);
74539
75298
  node.setMeasureFunc(null);
74540
75299
  node.free();
75300
+ state.kept.delete(node);
74541
75301
  state.byEntity.delete(element.entity);
74542
75302
  state.nodes -= 1;
74543
75303
  }
@@ -76491,7 +77251,7 @@ function writeStyle(state, source, element) {
76491
77251
  const node = state.byEntity.get(element.entity);
76492
77252
  if (node === void 0 || state.yoga === void 0) return;
76493
77253
  const tag = element.scroll?.axis === "x" ? "row" : element.type;
76494
- applyStyleToNode(state.yoga, node, element.style, tag, element.parentType);
77254
+ applyStyleToNode(state.yoga, node, element.style, tag, element.parentType, state.kept.get(node), state.tables);
76495
77255
  installMeasure(state, node, element, source);
76496
77256
  }
76497
77257
  /**
@@ -76511,7 +77271,9 @@ function createLayoutApi(ctx) {
76511
77271
  };
76512
77272
  return {
76513
77273
  load: async () => {
76514
- state.yoga = await loadYogaModule();
77274
+ const yoga = await loadYogaModule();
77275
+ state.yoga = yoga;
77276
+ state.tables = styleTablesOf(yoga);
76515
77277
  },
76516
77278
  loaded: () => state.yoga !== void 0,
76517
77279
  attach: (element) => {
@@ -77034,6 +77796,7 @@ function createAnchorPass(ctx, jsx) {
77034
77796
  if (yoga === void 0 || node === void 0) return;
77035
77797
  node.setWidth(element.rect.w);
77036
77798
  node.setHeight(element.rect.h);
77799
+ keepSize(layout.kept.get(node), element.rect);
77037
77800
  node.calculateLayout(element.rect.w, element.rect.h, yoga.DIRECTION_LTR);
77038
77801
  layout.solves += 1;
77039
77802
  placeUnder(element);
@@ -78055,8 +78818,10 @@ function stopUi(state) {
78055
78818
  node.free();
78056
78819
  }
78057
78820
  state.layout.byEntity.clear();
78821
+ state.layout.kept.clear();
78058
78822
  state.layout.nodes = 0;
78059
78823
  state.layout.yoga = void 0;
78824
+ state.layout.tables = void 0;
78060
78825
  state.layout.scrolling = void 0;
78061
78826
  state.layout.scrollSamples = 0;
78062
78827
  state.layout.iconLine = void 0;
@@ -78429,6 +79194,8 @@ function createLayoutState() {
78429
79194
  return {
78430
79195
  yoga: void 0,
78431
79196
  byEntity: emptyMap(),
79197
+ tables: void 0,
79198
+ kept: emptyMap(),
78432
79199
  nodes: 0,
78433
79200
  measured: 0,
78434
79201
  solves: 0,