@moku-labs/game 0.15.118 → 0.15.120

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 (34) hide show
  1. package/README.md +10 -0
  2. package/dist/app/page.d.mts +1 -1
  3. package/dist/app/page.mjs +1 -1
  4. package/dist/app/system.d.mts +3 -3
  5. package/dist/app.d.mts +3 -3
  6. package/dist/app.mjs +1 -1
  7. package/dist/assets.d.mts +1 -1
  8. package/dist/{commands-B16wtdhf.d.mts → commands-Cwxtb672.d.mts} +5 -5
  9. package/dist/control.d.mts +4 -4
  10. package/dist/{define-OPEOQ5MS.d.mts → define-BLFk9wyQ.d.mts} +2 -2
  11. package/dist/{headless-C5kxf9oU.d.mts → headless-DjvkUuv6.d.mts} +1 -1
  12. package/dist/{index-Fth_AFjs.d.mts → index-DSTbAOZZ.d.mts} +9 -7
  13. package/dist/index.d.mts +5 -5
  14. package/dist/index.mjs +2 -2
  15. package/dist/inspect.d.mts +6 -6
  16. package/dist/inspect.mjs +1 -1
  17. package/dist/jsx-dev-runtime.d.mts +1 -1
  18. package/dist/jsx-runtime.d.mts +1 -1
  19. package/dist/{runtime-DylBqKWf.d.mts → runtime-Dl3k95wc.d.mts} +1 -1
  20. package/dist/{sources-WiVMRhXq.mjs → sources-CuG-Vma9.mjs} +1 -1
  21. package/dist/{src-CvM4Qhtr.mjs → src-CvDV2vqI.mjs} +185 -78
  22. package/dist/testing.d.mts +4 -4
  23. package/dist/testing.mjs +1 -1
  24. package/dist/{types-ktcMr5ce.d.mts → types-CKCNyjAI.d.mts} +4 -4
  25. package/dist/{types-CMFC7k5L.d.mts → types-DOsd3uSB.d.mts} +60 -14
  26. package/dist/{types-DIdCmTQx.d.mts → types-DmOnlY66.d.mts} +14 -8
  27. package/dist/{types-BUR4LWSa.d.mts → types-TmWmx6Ca.d.mts} +51 -6
  28. package/dist/{types-CATC2vK8.d.mts → types-ohTEXbrA.d.mts} +2 -2
  29. package/dist/{visual-m6n16q7E.d.mts → visual-DFxSs-Vp.d.mts} +6 -6
  30. package/dist/{visual-CvFDvkA_.mjs → visual-x0TPowBE.mjs} +187 -56
  31. package/dist/visual.d.mts +1 -1
  32. package/dist/visual.mjs +1 -1
  33. package/llms.txt +2 -2
  34. package/package.json +1 -1
@@ -2,7 +2,7 @@ import { t as __exportAll } from "./rolldown-runtime-D7D4PA-g.mjs";
2
2
  import { i as systemSource, r as MAX_TIMER_MS, t as memory } from "./memory-DeD9wis6.mjs";
3
3
  import { a as finishDrafts, i as enableDraftPatches, n as deepFreeze$1, o as openDrafts, r as dropDrafts } from "./drafts-BawpSaVp.mjs";
4
4
  import { _ as compact, c as collectFlows, d as findNode, f as framePath, g as slotNames, h as restlessCapOf, i as servePaused, l as describeGraph, m as isRestCheckpoint, n as captureFrame, o as epochOf, p as graphHash, r as serveCaptures, s as pageNow$1, t as cancelCaptures, v as pushEntry } from "./capture-BtS6_oWr.mjs";
5
- import { $ as Parent, A as Countdown, B as applyPose, C as uiFor, D as isTextFormat, E as formatBound, G as rootPointOf, H as localPoseOf, J as Display, K as rootPoseInto, N as boldLookOf, O as unitOf, P as builtInStyles, Q as OverlayLevel, R as readStyle, U as parentOf$1, V as isLeaving, W as poseUnder, X as NineSlice, Y as HudPart, Z as Overlay, _ as LocalWrite, a as fieldsLeftAlone, b as UI_OWNER, c as namesFormat, ct as Now, d as visualOf$1, dt as component, et as Shape, f as visualRectOf, g as Escapable, gt as tag, h as DebugTrigger, ht as systemsFor, i as drawnRect, it as componentsFor, j as Text, k as wholeValue, l as restValueOf, lt as Order, m as Covered, mt as system, n as CONTENT$1, nt as Transform, o as fitScaleOf, ot as Exiting, p as Box, pt as resource, q as rootPoseOf, r as bindOf, rt as arcDefaults, s as livePatch, st as Layer, tt as Sprite, u as samePose, ut as Tree, v as Scroll, x as UiCounters, y as ScrollState, z as textFor } from "./visual-CvFDvkA_.mjs";
5
+ import { $ as Overlay, A as unitOf, B as readStyle, C as UiCounters, F as boldLookOf, G as parentOf$1, H as applyPose, I as builtInStyles, J as rootPoseInto, K as poseUnder, M as Countdown, N as Text, O as formatBound, Q as NineSlice, S as UI_OWNER, T as uiFor, U as isLeaving, V as textFor, W as localPoseOf, X as Display, Y as rootPoseOf, Z as HudPart, _ as DebugTrigger, _t as systemsFor, a as fieldsLeftAlone, at as arcDefaults, b as Scroll, c as namedKeyOf, ct as Exiting, d as samePose, dt as Order, et as OverlayLevel, f as visualOf$1, ft as Tree, g as Covered, gt as system, h as Box, ht as resource, i as drawnRect, it as Transform, j as wholeValue, k as isTextFormat, l as namesFormat, lt as Layer, m as writtenKeyOf, n as CONTENT$1, nt as Shape, o as fitScaleOf, ot as componentsFor, p as visualRectOf, pt as component, q as rootPointOf, r as bindOf, rt as Sprite, s as livePatch, tt as Parent, u as restValueOf, ut as Now, v as Escapable, vt as tag, x as ScrollState, y as LocalWrite, yt as neutralOf } from "./visual-x0TPowBE.mjs";
6
6
  import { a as isDev$1 } from "./dev-BNndV-hU.mjs";
7
7
  import { n as isComponentDefinition } from "./component-DGg5DqKK.mjs";
8
8
  import { n as flatten } from "./flatten-nUX9PpGo.mjs";
@@ -10925,6 +10925,44 @@ function splitFields(value) {
10925
10925
  };
10926
10926
  }
10927
10927
  /**
10928
+ * The rest value of a component with the neutral value of every optional field the stored value carries and the rest
10929
+ * leaves out (`Transform`'s `scaleX`: a stored `0` is brought home to 1). The rest itself comes back when there is
10930
+ * nothing to add, so a view that never set such a field copies nothing (the walk over the stored keys is its only cost).
10931
+ *
10932
+ * @param type - The component type, which may declare neutral values.
10933
+ * @param rest - The rest value.
10934
+ * @param stored - The value the entity carries now.
10935
+ * @returns The rest value, completed with neutrals where the stored value has a field the rest lacks.
10936
+ * @example
10937
+ * ```ts
10938
+ * restWithNeutrals(Transform, { x: 0 }, { x: 0, scaleX: 0 }); // { x: 0, scaleX: 1 }
10939
+ * restWithNeutrals(Transform, { x: 0 }, { x: 5 }); // the same object as the rest
10940
+ * ```
10941
+ */
10942
+ function restWithNeutrals(type, rest, stored) {
10943
+ if (stored === void 0) return rest;
10944
+ let completed;
10945
+ for (const field of Object.keys(stored)) {
10946
+ if (field in rest) continue;
10947
+ const neutral = neutralOf(type, field);
10948
+ if (neutral === void 0) continue;
10949
+ completed ??= { ...rest };
10950
+ completed[field] = neutral;
10951
+ }
10952
+ return completed ?? rest;
10953
+ }
10954
+ /**
10955
+ * The values that bring a rest component home: its rest value, with the neutral of an optional field the entity carries.
10956
+ *
10957
+ * @param pctx - Domain context of the projection module.
10958
+ * @param view - The view to bring home.
10959
+ * @param value - The rest value of the component, which names its type.
10960
+ * @returns The fields to write.
10961
+ */
10962
+ function restHome(pctx, view, value) {
10963
+ return restWithNeutrals(value.type, value.value, storedValue(pctx, view.entity, value.type));
10964
+ }
10965
+ /**
10928
10966
  * Writes a patch, leaving out every field another writer owns.
10929
10967
  *
10930
10968
  * @param pctx - Domain context of the projection module.
@@ -10977,7 +11015,7 @@ function createViewHandle(pctx, view, peers) {
10977
11015
  toRest: (component, options) => {
10978
11016
  const target = view.rest.get(component.componentName);
10979
11017
  if (target === void 0 || target.value === true) return inertHandle();
10980
- const { numeric, other } = splitFields(target.value);
11018
+ const { numeric, other } = splitFields(restWithNeutrals(target.type, target.value, storedValue(pctx, view.entity, target.type)));
10981
11019
  if (Object.keys(other).length > 0) writeUnmuted(pctx, view.entity, target, other);
10982
11020
  return startTrack$2(pctx, view.entity, asComponent$1(component), numeric, {
10983
11021
  ms: options?.ms ?? pctx.ctx.config.settleMs,
@@ -11110,7 +11148,7 @@ function looseComponents(pctx, view) {
11110
11148
  for (const [name, value] of view.rest) {
11111
11149
  if (driven.has(name) || value.value === true) continue;
11112
11150
  const under = valueUnderLoop(pctx, view, value);
11113
- if (under !== void 0 && !deepEquals(under, value.value)) loose.push(name);
11151
+ if (under !== void 0 && !deepEquals(under, restWithNeutrals(value.type, value.value, under))) loose.push(name);
11114
11152
  }
11115
11153
  return loose;
11116
11154
  }
@@ -11193,7 +11231,7 @@ function writeRestUnderLoops(pctx, view, components) {
11193
11231
  for (const name of components) {
11194
11232
  const value = view.rest.get(name);
11195
11233
  if (value === void 0 || value.value === true) continue;
11196
- writeUnderLoop(pctx, view, value, value.value);
11234
+ writeUnderLoop(pctx, view, value, restHome(pctx, view, value));
11197
11235
  }
11198
11236
  }
11199
11237
  /**
@@ -11209,7 +11247,7 @@ function writeRestNow(pctx, view, components) {
11209
11247
  for (const name of components) {
11210
11248
  const value = view.rest.get(name);
11211
11249
  if (value === void 0 || value.value === true) continue;
11212
- writeUnmuted(pctx, view.entity, value, value.value);
11250
+ writeUnmuted(pctx, view.entity, value, restHome(pctx, view, value));
11213
11251
  }
11214
11252
  }
11215
11253
  /**
@@ -11279,7 +11317,8 @@ function offRestFields(pctx, view, name, value) {
11279
11317
  const under = valueUnderLoop(pctx, view, value);
11280
11318
  if (under === void 0) return patch;
11281
11319
  const muted = mutedFields(pctx, view.entity, name);
11282
- for (const [field, entry] of Object.entries(value.value)) if (!muted.has(field) && !atRest(under[field], entry)) patch[field] = entry;
11320
+ const rest = restWithNeutrals(value.type, value.value, under);
11321
+ for (const [field, entry] of Object.entries(rest)) if (!muted.has(field) && !atRest(under[field], entry)) patch[field] = entry;
11283
11322
  return patch;
11284
11323
  }
11285
11324
  /**
@@ -33388,7 +33427,8 @@ function writeVisual(sctx, entity, view) {
33388
33427
  measureDisplay(view);
33389
33428
  }
33390
33429
  /**
33391
- * Writes the `Transform` component: `position` is where the `pivot` lands. The stretch of the
33430
+ * Writes the `Transform` component: `position` is where the `pivot` lands, and the drawn scale is `scale` times the
33431
+ * per-axis factor (`scaleX`, `scaleY`, 1 when absent) on each axis. The stretch of the
33392
33432
  * visual (a sized sprite, the 64 x 64 placeholder) is folded into the object's scale, so the
33393
33433
  * pivot is written in the object's own units. A wrapper carries the pose instead, and the visual
33394
33434
  * inside it keeps only its stretch.
@@ -33401,14 +33441,18 @@ function applyTransform(sctx, entity, view) {
33401
33441
  const value = sctx.ctx.deps.world.ecs.get(entity, Transform) ?? Transform.defaults;
33402
33442
  const target = view.wrapper ?? view.object;
33403
33443
  const stretch = view.drawScale;
33444
+ const factorX = "scaleX" in value ? value.scaleX ?? 1 : 1;
33445
+ const factorY = "scaleY" in value ? value.scaleY ?? 1 : 1;
33446
+ const scaleX = value.scale * factorX;
33447
+ const scaleY = value.scale * factorY;
33404
33448
  writePoint(sctx, entity, target.position, value.x, value.y, markMoved);
33405
33449
  writeRotation(sctx, entity, target, value.rotation, markMoved);
33406
33450
  if (view.wrapper === void 0) {
33407
- writePoint(sctx, entity, target.scale, value.scale * stretch.x, value.scale * stretch.y, markMoved);
33451
+ writePoint(sctx, entity, target.scale, scaleX * stretch.x, scaleY * stretch.y, markMoved);
33408
33452
  writePoint(sctx, entity, target.pivot, value.pivot.x / stretch.x, value.pivot.y / stretch.y, markMoved);
33409
33453
  return;
33410
33454
  }
33411
- writePoint(sctx, entity, target.scale, value.scale, value.scale, markMoved);
33455
+ writePoint(sctx, entity, target.scale, scaleX, scaleY, markMoved);
33412
33456
  writePoint(sctx, entity, target.pivot, value.pivot.x, value.pivot.y, markMoved);
33413
33457
  writePoint(sctx, entity, view.object.position, 0, 0);
33414
33458
  writeRotation(sctx, entity, view.object, 0);
@@ -34762,6 +34806,8 @@ function takeWalk(sctx) {
34762
34806
  y: 0,
34763
34807
  rotation: 0,
34764
34808
  scale: 1,
34809
+ scaleX: 1,
34810
+ scaleY: 1,
34765
34811
  pivot: {
34766
34812
  x: 0,
34767
34813
  y: 0
@@ -34809,12 +34855,14 @@ function localPoint(sctx, walk, entity) {
34809
34855
  }
34810
34856
  const above = rootPoseInto(sctx.ctx.deps.world.ecs, entity, walk.pose);
34811
34857
  const scale = above.scale === 0 ? 1 : above.scale;
34858
+ const scaleX = above.scaleX === 0 ? scale : scale * above.scaleX;
34859
+ const scaleY = above.scaleY === 0 ? scale : scale * above.scaleY;
34812
34860
  const cos = Math.cos(-above.rotation);
34813
34861
  const sin = Math.sin(-above.rotation);
34814
34862
  const dx = walk.x - above.x;
34815
34863
  const dy = walk.y - above.y;
34816
- local.x = above.pivot.x + (dx * cos - dy * sin) / scale;
34817
- local.y = above.pivot.y + (dx * sin + dy * cos) / scale;
34864
+ local.x = above.pivot.x + (dx * cos - dy * sin) / scaleX;
34865
+ local.y = above.pivot.y + (dx * sin + dy * cos) / scaleY;
34818
34866
  return local;
34819
34867
  }
34820
34868
  /**
@@ -39816,12 +39864,15 @@ const POSE_FIELDS = [
39816
39864
  "x",
39817
39865
  "y",
39818
39866
  "rotation",
39819
- "scale"
39867
+ "scale",
39868
+ "scaleX",
39869
+ "scaleY"
39820
39870
  ];
39821
39871
  /**
39822
39872
  * Turns the root-space target of a tween into the local target under the entity's parent. A field
39823
39873
  * the step does not name is read from where the entity stands now and is not written, so a step
39824
- * that names only `scale` leaves `x` and `y` alone. A component other than `Transform`, and an
39874
+ * that names only `scale` leaves `x` and `y` alone. `scale` is divided by the parents' uniform scale, `scaleX` and
39875
+ * `scaleY` by the parents' per-axis factors. A component other than `Transform`, and an
39825
39876
  * entity without a parent, keep the target as it is.
39826
39877
  *
39827
39878
  * @param ecs - The world read, `world.ecs`.
@@ -39835,15 +39886,19 @@ function localTargetOf(ecs, entity, component, to) {
39835
39886
  const parent = parentOf$1(ecs, entity);
39836
39887
  if (component !== asComponent(Transform) || parent === 0) return local;
39837
39888
  const now = rootPoseOf(ecs, entity);
39889
+ const scaleX = to.scaleX ?? now.scaleX;
39890
+ const scaleY = to.scaleY ?? now.scaleY;
39838
39891
  const root = {
39839
39892
  x: to.x ?? now.x,
39840
39893
  y: to.y ?? now.y,
39841
39894
  rotation: to.rotation ?? now.rotation,
39842
39895
  scale: to.scale ?? now.scale,
39896
+ ...scaleX === void 0 ? {} : { scaleX },
39897
+ ...scaleY === void 0 ? {} : { scaleY },
39843
39898
  pivot: now.pivot
39844
39899
  };
39845
39900
  const landed = localPoseOf(ecs, parent, root);
39846
- for (const field of POSE_FIELDS) if (to[field] !== void 0) local[field] = landed[field];
39901
+ for (const field of POSE_FIELDS) if (to[field] !== void 0) local[field] = landed[field] ?? 1;
39847
39902
  return local;
39848
39903
  }
39849
39904
  //#endregion
@@ -40110,7 +40165,7 @@ function beginTrack(actx, track, stored) {
40110
40165
  if (track.live[slot] === 0 || field === void 0 || key === void 0) continue;
40111
40166
  const base = actx.state.bases.get(key);
40112
40167
  const current = stored[field];
40113
- const read = typeof current === "number" ? current : track.targets[slot] ?? 0;
40168
+ const read = typeof current === "number" ? current : neutralOf(track.component, field) ?? track.targets[slot] ?? 0;
40114
40169
  if (base !== void 0 && actx.state.offsets.has(key)) track.starts[slot] = cellValue(base);
40115
40170
  else {
40116
40171
  track.starts[slot] = read;
@@ -52618,7 +52673,7 @@ function syncDirty(ectx, pixi) {
52618
52673
  return moved;
52619
52674
  }
52620
52675
  /**
52621
- * Tells whether a box of a view, times the view's scale, covers the viewport on both axes.
52676
+ * Tells whether a box of a view, times the view's scale and its per-axis factors, covers the viewport on both axes.
52622
52677
  *
52623
52678
  * @param ectx - Domain context of the effects plugin.
52624
52679
  * @param entity - The entity.
@@ -52628,8 +52683,11 @@ function syncDirty(ectx, pixi) {
52628
52683
  * @returns True when the scaled box covers the viewport.
52629
52684
  */
52630
52685
  function boxCovers(ectx, entity, width, height, size) {
52631
- const scale = ectx.deps.world.ecs.get(entity, Transform)?.scale ?? 1;
52632
- return width * scale >= size.width && height * scale >= size.height;
52686
+ const transform = ectx.deps.world.ecs.get(entity, Transform);
52687
+ const scale = transform?.scale ?? 1;
52688
+ const factorX = transform !== void 0 && "scaleX" in transform ? transform.scaleX ?? 1 : 1;
52689
+ const factorY = transform !== void 0 && "scaleY" in transform ? transform.scaleY ?? 1 : 1;
52690
+ return width * scale * factorX >= size.width && height * scale * factorY >= size.height;
52633
52691
  }
52634
52692
  /**
52635
52693
  * Tells whether a filtered view covers the whole viewport. A view whose enabled filters declare an
@@ -53626,6 +53684,8 @@ const POSE = {
53626
53684
  y: 0,
53627
53685
  rotation: 0,
53628
53686
  scale: 1,
53687
+ scaleX: 1,
53688
+ scaleY: 1,
53629
53689
  pivot: {
53630
53690
  x: 0,
53631
53691
  y: 0
@@ -62277,7 +62337,8 @@ function poseOf(reader, entity) {
62277
62337
  * Writes where an entity really is: its pose composed through every entity it is drawn under,
62278
62338
  * the arithmetic of `rootPoseInto`, over `upOf`. The answer keeps the entity's own pivot. Kept in
62279
62339
  * step with `rootPoseInto` of `renderer/sync/pose.ts`: the same composition, step by step, over the
62280
- * parents of `ui` elements and the rest pose of an element whose `Transform` has not landed.
62340
+ * parents of `ui` elements and the rest pose of an element whose `Transform` has not landed. Both
62341
+ * per-axis factors are written on every call, 1 for an entity without them.
62281
62342
  *
62282
62343
  * @param reader - What the resolver reads.
62283
62344
  * @param entity - The entity.
@@ -62291,6 +62352,8 @@ function drawnPoseInto(reader, entity, out) {
62291
62352
  out.y = own.y;
62292
62353
  out.rotation = own.rotation;
62293
62354
  out.scale = own.scale;
62355
+ out.scaleX = "scaleX" in own ? own.scaleX ?? 1 : 1;
62356
+ out.scaleY = "scaleY" in own ? own.scaleY ?? 1 : 1;
62294
62357
  out.pivot.x = own.pivot.x;
62295
62358
  out.pivot.y = own.pivot.y;
62296
62359
  let current = entity;
@@ -62300,12 +62363,16 @@ function drawnPoseInto(reader, entity, out) {
62300
62363
  const above = poseOf(reader, parent) ?? Transform.defaults;
62301
62364
  const cos = Math.cos(above.rotation);
62302
62365
  const sin = Math.sin(above.rotation);
62303
- const dx = out.x - above.pivot.x;
62304
- const dy = out.y - above.pivot.y;
62366
+ const factorX = "scaleX" in above ? above.scaleX ?? 1 : 1;
62367
+ const factorY = "scaleY" in above ? above.scaleY ?? 1 : 1;
62368
+ const dx = (out.x - above.pivot.x) * factorX;
62369
+ const dy = (out.y - above.pivot.y) * factorY;
62305
62370
  out.x = above.x + above.scale * (dx * cos - dy * sin);
62306
62371
  out.y = above.y + above.scale * (dx * sin + dy * cos);
62307
62372
  out.rotation += above.rotation;
62308
62373
  out.scale *= above.scale;
62374
+ out.scaleX *= factorX;
62375
+ out.scaleY *= factorY;
62309
62376
  current = parent;
62310
62377
  }
62311
62378
  return true;
@@ -62345,17 +62412,24 @@ function visible(reader, entity) {
62345
62412
  }
62346
62413
  /**
62347
62414
  * Moves a local box of an entity into root space, in place: moved by the pose, scaled around its
62348
- * pivot, the rotation left out. The numbers stay in the rect: a fractional number handed to a call
62349
- * is boxed.
62415
+ * pivot per axis, the rotation left out. The numbers stay in the rect: a fractional number handed to
62416
+ * a call is boxed. A size is a magnitude: a view flipped by a negative factor covers the same
62417
+ * ground mirrored, so its rect is as wide as the unflipped one and starts at its left edge.
62350
62418
  *
62351
62419
  * @param pose - The root pose of the entity.
62352
62420
  * @param out - The box in the entity's own units, written in root space.
62353
62421
  */
62354
62422
  function toRoot(pose, out) {
62355
- out.x = pose.x + pose.scale * (out.x - pose.pivot.x);
62356
- out.y = pose.y + pose.scale * (out.y - pose.pivot.y);
62357
- out.w *= pose.scale;
62358
- out.h *= pose.scale;
62423
+ const factorX = pose.scale * pose.scaleX;
62424
+ const factorY = pose.scale * pose.scaleY;
62425
+ const width = out.w * Math.abs(factorX);
62426
+ const height = out.h * Math.abs(factorY);
62427
+ const left = pose.x + factorX * (out.x - pose.pivot.x);
62428
+ const top = pose.y + factorY * (out.y - pose.pivot.y);
62429
+ out.x = factorX < 0 ? left - width : left;
62430
+ out.y = factorY < 0 ? top - height : top;
62431
+ out.w = width;
62432
+ out.h = height;
62359
62433
  }
62360
62434
  /**
62361
62435
  * Writes the box of an entity in its own units, by what it draws: the layout box of a ui element,
@@ -62418,8 +62492,8 @@ function localBoxInto(reader, entity, pose, out) {
62418
62492
  * Writes where an entity is drawn, in screen reference units, when it is shown. A box of no area is
62419
62493
  * shown at its point: a width or a height of 0. Not shown: the entity belongs to a scene built
62420
62494
  * aside, it or something it is drawn under is leaving, the alphas on its way up multiply to 0.01 or
62421
- * less, its root pose is at scale 0 or less (it pops in from scale 0, or hangs under a collapsed
62422
- * parent), it draws no box, or the box is turned inside out (a size below 0).
62495
+ * less, its root pose is at scale 0 or less or has a per-axis factor (`scaleX`, `scaleY`) of exactly 0
62496
+ * (it pops in from scale 0, or hangs under a collapsed parent), it draws no box, or the box is turned inside out (a size below 0).
62423
62497
  *
62424
62498
  * @param reader - What the resolver reads.
62425
62499
  * @param entity - The entity of the target.
@@ -62429,7 +62503,8 @@ function localBoxInto(reader, entity, pose, out) {
62429
62503
  */
62430
62504
  function drawnInto(reader, entity, out, pose) {
62431
62505
  if (building(reader, entity) || !visible(reader, entity)) return false;
62432
- if (!drawnPoseInto(reader, entity, pose) || pose.scale <= 0) return false;
62506
+ if (!drawnPoseInto(reader, entity, pose)) return false;
62507
+ if (pose.scale <= 0 || pose.scaleX === 0 || pose.scaleY === 0) return false;
62433
62508
  if (!localBoxInto(reader, entity, pose, out)) return false;
62434
62509
  return out.w >= 0 && out.h >= 0;
62435
62510
  }
@@ -62516,6 +62591,8 @@ function rectOfTargets(ctx, to) {
62516
62591
  y: 0,
62517
62592
  rotation: 0,
62518
62593
  scale: 1,
62594
+ scaleX: 1,
62595
+ scaleY: 1,
62519
62596
  pivot: {
62520
62597
  x: 0,
62521
62598
  y: 0
@@ -64399,19 +64476,18 @@ function contentOf$2(element, resolvedOf) {
64399
64476
  }
64400
64477
  /**
64401
64478
  * The text style key of a text element: the style a format of the game answered, for a text whose
64402
- * bind names one; else the `style` prop while that is a key.
64479
+ * bind names one; else the key its style object took for this frame (F182); else the `style` prop
64480
+ * while that is a key.
64403
64481
  *
64404
64482
  * @param element - The element to read.
64405
64483
  * @param shownStyleOf - Reads `Text.style` of an entity; none for a tree read without a world.
64406
- * @returns The key, or `undefined` for any other element and for a text with a `Style` object or
64407
- * no style.
64484
+ * @returns The key, or `undefined` for any other element and for a text whose style names none.
64408
64485
  */
64409
64486
  function textStyleOf(element, shownStyleOf) {
64410
64487
  if (element.type !== "text") return void 0;
64411
64488
  const shown = namesFormat(element) ? shownStyleOf?.(element.entity) : void 0;
64412
64489
  if (shown !== void 0) return shown;
64413
- const style = element.node.props.style;
64414
- return typeof style === "string" ? style : void 0;
64490
+ return namedKeyOf(element.style, element.node.props.style);
64415
64491
  }
64416
64492
  /**
64417
64493
  * Turns one element and its subtree into snapshot nodes. The rect is natural; a fitted element
@@ -64945,8 +65021,9 @@ function formatIfLoaded(ctx, message, locale) {
64945
65021
  }
64946
65022
  }
64947
65023
  /**
64948
- * Measures a text in every loaded locale and reports the widest one that does not fit. A lazy
64949
- * locale the player has not picked yet cannot be measured, so it is skipped.
65024
+ * Measures a text in every loaded locale, in the key its markup names for this frame, and reports
65025
+ * the widest one that does not fit. A lazy locale the player has not picked yet cannot be
65026
+ * measured, so it is skipped.
64950
65027
  *
64951
65028
  * @param ctx - Domain context of the ui plugin.
64952
65029
  * @param element - The text element.
@@ -64955,7 +65032,7 @@ function formatIfLoaded(ctx, message, locale) {
64955
65032
  function textOverflow(ctx, element) {
64956
65033
  if (element.type !== "text") return void 0;
64957
65034
  const content = element.node.props.content;
64958
- const style = typeof element.node.props.style === "string" ? element.node.props.style : "body";
65035
+ const style = writtenKeyOf(element);
64959
65036
  if (typeof content !== "object" || content === null) return void 0;
64960
65037
  for (const locale of ctx.deps.i18n.locales()) {
64961
65038
  const parts = formatIfLoaded(ctx, content, locale);
@@ -65344,7 +65421,7 @@ function checkLoop(name, keys) {
65344
65421
  }
65345
65422
  /**
65346
65423
  * The pose one key gives the Transform: `dx` and `dy` as positions from the rest pose, rotation
65347
- * and scale as written.
65424
+ * and scale, scaleX and scaleY as written.
65348
65425
  *
65349
65426
  * @param key - The key.
65350
65427
  * @param rest - The rest position of the view.
@@ -65357,6 +65434,8 @@ function transformPose(key, rest) {
65357
65434
  if (fields?.dy !== void 0) pose.y = rest.y + fields.dy;
65358
65435
  if (fields?.rotation !== void 0) pose.rotation = fields.rotation;
65359
65436
  if (fields?.scale !== void 0) pose.scale = fields.scale;
65437
+ if (fields?.scaleX !== void 0) pose.scaleX = fields.scaleX;
65438
+ if (fields?.scaleY !== void 0) pose.scaleY = fields.scaleY;
65360
65439
  return pose;
65361
65440
  }
65362
65441
  /**
@@ -65396,7 +65475,9 @@ function lanesOf(view) {
65396
65475
  x,
65397
65476
  y,
65398
65477
  rotation,
65399
- scale
65478
+ scale,
65479
+ scaleX: transform.scaleX ?? 1,
65480
+ scaleY: transform.scaleY ?? 1
65400
65481
  },
65401
65482
  pose: (key) => transformPose(key, {
65402
65483
  x,
@@ -65504,7 +65585,7 @@ function exitLane(view, lane, keys, ms, reduced) {
65504
65585
  * @returns The offsets the key names.
65505
65586
  * @example
65506
65587
  * ```ts
65507
- * loopTransformPose({ at: 0.5, Transform: { dx: 4, scale: 0.05 } }); // { x: 4, scale: 0.05 }
65588
+ * loopTransformPose({ at: 0.5, Transform: { dx: 4, scaleX: 0.05 } }); // { x: 4, scaleX: 0.05 }
65508
65589
  * ```
65509
65590
  */
65510
65591
  function loopTransformPose(key) {
@@ -65514,6 +65595,8 @@ function loopTransformPose(key) {
65514
65595
  if (fields?.dy !== void 0) pose.y = fields.dy;
65515
65596
  if (fields?.rotation !== void 0) pose.rotation = fields.rotation;
65516
65597
  if (fields?.scale !== void 0) pose.scale = fields.scale;
65598
+ if (fields?.scaleX !== void 0) pose.scaleX = fields.scaleX;
65599
+ if (fields?.scaleY !== void 0) pose.scaleY = fields.scaleY;
65517
65600
  return pose;
65518
65601
  }
65519
65602
  /**
@@ -67436,6 +67519,8 @@ function createAnchor() {
67436
67519
  y: 0,
67437
67520
  rotation: 0,
67438
67521
  scale: 1,
67522
+ scaleX: 1,
67523
+ scaleY: 1,
67439
67524
  pivot: {
67440
67525
  x: 0,
67441
67526
  y: 0
@@ -67530,6 +67615,12 @@ const TEXT_KEPT = Object.freeze([
67530
67615
  "content",
67531
67616
  "style"
67532
67617
  ]);
67618
+ /**
67619
+ * The fields of `Text` a write leaves alone when the markup says what it said but its style names
67620
+ * another text style key for this frame (F182): the style is written, the content a game's system
67621
+ * may have written stays (F167).
67622
+ */
67623
+ const TEXT_CONTENT_KEPT = Object.freeze([...Text.owned, "content"]);
67533
67624
  /** The time of a reconcile a test steps by hand: no ms pass, so no scroll moves. */
67534
67625
  const NO_TIME = Object.freeze({
67535
67626
  delta: 0,
@@ -68045,6 +68136,7 @@ function createReconciler(ctx, modules, fields) {
68045
68136
  let slotsRoots = -1;
68046
68137
  let placedUnder;
68047
68138
  let textKept = false;
68139
+ let keyKept = true;
68048
68140
  let rendered = 0;
68049
68141
  const isAside = (entity) => ctx.deps.world.projection.isBuilding(entity);
68050
68142
  let released = false;
@@ -68339,10 +68431,13 @@ function createReconciler(ctx, modules, fields) {
68339
68431
  *
68340
68432
  * @param element - The element that changed.
68341
68433
  * @param keepsText - Whether the markup's `content`, `style` and `bind` say what they said.
68434
+ * @param keepsKey - Whether the text style key of this frame is the one before; a new one is
68435
+ * written into `Text.style` even when the markup says the same (F182).
68342
68436
  */
68343
- function writeLive(element, keepsText) {
68437
+ function writeLive(element, keepsText, keepsKey = true) {
68344
68438
  state.written += 1;
68345
68439
  textKept = keepsText;
68440
+ keyKept = keepsKey;
68346
68441
  writeOrder(element);
68347
68442
  const visuals = visualOf$1(element);
68348
68443
  const inputs = inputOf(element);
@@ -68404,7 +68499,8 @@ function createReconciler(ctx, modules, fields) {
68404
68499
  }
68405
68500
  /**
68406
68501
  * The fields a write of the current pass leaves alone: those of `fieldsLeftAlone`, and on the
68407
- * `Text` of a write with no new content in the markup its content and style too.
68502
+ * `Text` of a write with no new content in the markup its content, and its style too unless the
68503
+ * frame names another key for it (a style a named format answers always stays).
68408
68504
  *
68409
68505
  * @param element - The live element.
68410
68506
  * @param type - The component type of the value.
@@ -68412,7 +68508,8 @@ function createReconciler(ctx, modules, fields) {
68412
68508
  * @returns The fields left alone: a list of the module, never a new one, for a kept text.
68413
68509
  */
68414
68510
  function leftAlone(element, type, owned) {
68415
- return type === Text && textKept ? TEXT_KEPT : fieldsLeftAlone(element, type, owned);
68511
+ if (type !== Text || !textKept) return fieldsLeftAlone(element, type, owned);
68512
+ return keyKept || namesFormat(element) ? TEXT_KEPT : TEXT_CONTENT_KEPT;
68416
68513
  }
68417
68514
  /**
68418
68515
  * Writes one visual or input value onto a live element: added when the entity lacks it, else
@@ -68461,6 +68558,7 @@ function createReconciler(ctx, modules, fields) {
68461
68558
  const keepsStyle = stands && sameStyle && sameValue(element.is, is);
68462
68559
  const style = keepsStyle ? element.style : styleFor(parent, node, is);
68463
68560
  const sameContent = sameValue(previous.props.content, node.props.content);
68561
+ const keepsKey = namedKeyOf(element.style, previous.props.style) === namedKeyOf(style, node.props.style);
68464
68562
  return {
68465
68563
  is,
68466
68564
  style,
@@ -68469,6 +68567,7 @@ function createReconciler(ctx, modules, fields) {
68469
68567
  moved: !keepsStyle && modules.layout.affectsRect(element.style, style),
68470
68568
  measures: !stands || !sameStyle || !sameContent,
68471
68569
  keepsText: sameStyle && sameContent && sameValue(previous.props.bind, node.props.bind),
68570
+ keepsKey,
68472
68571
  unchanged: keepsStyle && sameContent && writesSame(previous, node)
68473
68572
  };
68474
68573
  }
@@ -68489,7 +68588,7 @@ function createReconciler(ctx, modules, fields) {
68489
68588
  root.needsSolve = true;
68490
68589
  }
68491
68590
  if (!element.live) return;
68492
- writeLive(element, change.keepsText);
68591
+ writeLive(element, change.keepsText, change.keepsKey);
68493
68592
  if (!change.moved) modules.layout.repose(element, parentRect(element), false, hintOf(state, element));
68494
68593
  }
68495
68594
  /**
@@ -70094,7 +70193,7 @@ function pivotOf(origin, width, height) {
70094
70193
  *
70095
70194
  * @param rect - The rect of the element in root coordinates.
70096
70195
  * @param parent - The rect of its parent, or nothing for a root element.
70097
- * @param style - The resolved style, for `origin`, `offsetX`, `offsetY`, `scale` and `rotation`.
70196
+ * @param style - The resolved style, for `origin`, `offsetX`, `offsetY`, `scale`, `scaleX`, `scaleY` and `rotation`.
70098
70197
  * @param fit - The element's own fit scale, 1 without `fit: "contain"`.
70099
70198
  * @returns The rest transform.
70100
70199
  * @example
@@ -70103,6 +70202,8 @@ function pivotOf(origin, width, height) {
70103
70202
  * // { x: 45, y: 85, rotation: 0, scale: 1, pivot: { x: 5, y: 5 } }
70104
70203
  * restTransform({ x: 0, y: 0, w: 200, h: 80 }, undefined, { rotation: -0.026, origin: "top" });
70105
70204
  * // { x: 100, y: 0, rotation: -0.026, scale: 1, pivot: { x: 100, y: 0 } }
70205
+ * restTransform({ x: 0, y: 0, w: 200, h: 80 }, undefined, { scaleX: 0.5, origin: "topLeft" });
70206
+ * // { x: 0, y: 0, rotation: 0, scale: 1, scaleX: 0.5, pivot: { x: 0, y: 0 } }
70106
70207
  * ```
70107
70208
  */
70108
70209
  function restTransform(rect, parent, style = {}, fit = 1) {
@@ -70115,13 +70216,16 @@ function restTransform(rect, parent, style = {}, fit = 1) {
70115
70216
  x: rect.x - (parent?.x ?? 0),
70116
70217
  y: rect.y - (parent?.y ?? 0)
70117
70218
  };
70118
- return {
70219
+ const rest = {
70119
70220
  x: local.x + centre.x + fit * (pivot.x + (style.offsetX ?? 0) - centre.x),
70120
70221
  y: local.y + centre.y + fit * (pivot.y + (style.offsetY ?? 0) - centre.y),
70121
70222
  rotation: style.rotation ?? 0,
70122
70223
  scale: fit * (style.scale ?? 1),
70123
70224
  pivot
70124
70225
  };
70226
+ if (style.scaleX !== void 0) rest.scaleX = style.scaleX;
70227
+ if (style.scaleY !== void 0) rest.scaleY = style.scaleY;
70228
+ return rest;
70125
70229
  }
70126
70230
  /**
70127
70231
  * Records the rest pose of one element before a hook runs: the transform from `Box` and the
@@ -71131,6 +71235,8 @@ function createGuide(payload, veil) {
71131
71235
  y: 0,
71132
71236
  rotation: 0,
71133
71237
  scale: 1,
71238
+ scaleX: 1,
71239
+ scaleY: 1,
71134
71240
  pivot: {
71135
71241
  x: 0,
71136
71242
  y: 0
@@ -71230,8 +71336,8 @@ function guardPointer(ctx, door) {
71230
71336
  }
71231
71337
  //#endregion
71232
71338
  //#region src/plugins/ui/layout/measure.ts
71233
- /** What a text is drawn in when its `style` prop is a layout style instead of a style key. */
71234
- const DEFAULT_TEXT_STYLE = "body";
71339
+ /** The text style an icon without a size is squared on. */
71340
+ const ICON_LINE_STYLE = "body";
71235
71341
  /** The glyph an icon is sized from: one line of the text style it sits in. */
71236
71342
  const LINE_SAMPLE = "M";
71237
71343
  /** Below this a measured length counts as whole: the tolerance Yoga's own rounding uses. */
@@ -71243,7 +71349,7 @@ const WHOLE_EPSILON = 1e-4;
71243
71349
  * @returns The height of that line, as `text` measures it now.
71244
71350
  */
71245
71351
  function lineOf(source) {
71246
- return source.measure(LINE_SAMPLE, DEFAULT_TEXT_STYLE).height;
71352
+ return source.measure(LINE_SAMPLE, ICON_LINE_STYLE).height;
71247
71353
  }
71248
71354
  /**
71249
71355
  * Tells whether the line the icons are squared on moved since an icon was last measured: the
@@ -71291,24 +71397,15 @@ function needsMeasure(element) {
71291
71397
  return typeof element.style.width !== "number" || typeof element.style.height !== "number";
71292
71398
  }
71293
71399
  /**
71294
- * Reads the style key of a text or an icon out of its props.
71295
- *
71296
- * @param element - The element.
71297
- * @returns The key `text.measure` takes.
71298
- */
71299
- function styleKeyOf(element) {
71300
- const { style } = element.node.props;
71301
- return typeof style === "string" ? style : DEFAULT_TEXT_STYLE;
71302
- }
71303
- /**
71304
- * Reads what a text draws out of its props.
71400
+ * Reads what a text draws out of its markup: the content of its props, and the key its style of
71401
+ * this frame names (`writtenKeyOf`).
71305
71402
  *
71306
71403
  * @param element - The text element.
71307
71404
  * @returns The content and the style key `text.measure` takes.
71308
71405
  */
71309
71406
  function contentOf$1(element) {
71310
71407
  const { content } = element.node.props;
71311
- const styleKey = styleKeyOf(element);
71408
+ const styleKey = writtenKeyOf(element);
71312
71409
  if (typeof content === "string") return {
71313
71410
  content,
71314
71411
  style: styleKey
@@ -71367,7 +71464,7 @@ function boundShown(element, bind, source) {
71367
71464
  */
71368
71465
  function namedSize(element, bind, source, width) {
71369
71466
  const resolved = source.resolved(element.entity);
71370
- if (resolved !== void 0) return source.measure(resolved, source.style(element.entity) ?? styleKeyOf(element), width);
71467
+ if (resolved !== void 0) return source.measure(resolved, source.style(element.entity) ?? writtenKeyOf(element), width);
71371
71468
  const value = listedValueOf(element, bind);
71372
71469
  const answer = value === void 0 ? void 0 : source.formatted(bind.format, value);
71373
71470
  return answer === void 0 ? void 0 : source.measure(answer.text, answer.style, width);
@@ -71388,7 +71485,7 @@ function contentSize(element, source, width) {
71388
71485
  const written = contentOf$1(element);
71389
71486
  return source.measure(written.content, written.style, width);
71390
71487
  }
71391
- return source.measure(content, source.style(element.entity) ?? styleKeyOf(element), width);
71488
+ return source.measure(content, source.style(element.entity) ?? writtenKeyOf(element), width);
71392
71489
  }
71393
71490
  /**
71394
71491
  * The size a text measures to: a bound one by what it shows, any other by its content.
@@ -71401,7 +71498,7 @@ function contentSize(element, source, width) {
71401
71498
  function textSize(element, source, width) {
71402
71499
  const bind = bindOf(element);
71403
71500
  if (bind === void 0) return contentSize(element, source, width);
71404
- return (isTextFormat(bind.format) ? void 0 : namedSize(element, bind, source, width)) ?? source.measure(boundShown(element, bind, source), styleKeyOf(element), width);
71501
+ return (isTextFormat(bind.format) ? void 0 : namedSize(element, bind, source, width)) ?? source.measure(boundShown(element, bind, source), writtenKeyOf(element), width);
71405
71502
  }
71406
71503
  /**
71407
71504
  * The size a text or an icon takes before Yoga clamps it: an icon is square on one line of its
@@ -71416,7 +71513,7 @@ function textSize(element, source, width) {
71416
71513
  * @returns The width and the height, in whole units.
71417
71514
  */
71418
71515
  function naturalSize(element, source, width) {
71419
- const size = element.type === "icon" ? squareOf(source.measure(LINE_SAMPLE, styleKeyOf(element))) : textSize(element, source, width);
71516
+ const size = element.type === "icon" ? squareOf(source.measure(LINE_SAMPLE, writtenKeyOf(element))) : textSize(element, source, width);
71420
71517
  return {
71421
71518
  width: Math.ceil(size.width - WHOLE_EPSILON),
71422
71519
  height: Math.ceil(size.height - WHOLE_EPSILON)
@@ -73001,12 +73098,14 @@ function createAnchorPass(ctx, jsx) {
73001
73098
  /**
73002
73099
  * Maps the union of the targets into the root coordinates of the anchor: through the root pose of
73003
73100
  * the entity it is drawn under (its parent, or the slot of its root), then by its parent's rect,
73004
- * then padded outward. A size an inward pad turns below 0 stops at 0, about the centre of the
73005
- * targets: the anchor stands on that point.
73101
+ * then padded outward, each axis by its own factor (`scale × scaleX`, `scale × scaleY`). A size an
73102
+ * inward pad turns below 0 stops at 0, about the centre of the targets: the anchor stands on that
73103
+ * point.
73006
73104
  *
73007
73105
  * @param element - The anchor.
73008
73106
  * @param anchor - Its record: `screen` is read, `next` written.
73009
- * @returns False when the space it is drawn in is collapsed: nothing of it could be seen.
73107
+ * @returns False when the space it is drawn in is collapsed on an axis, or flipped: nothing of it
73108
+ * could be seen, or no rect maps back.
73010
73109
  */
73011
73110
  function mapInto(element, anchor) {
73012
73111
  const above = element.parent ?? state.roots.get(element.root)?.slot ?? 0;
@@ -73015,19 +73114,22 @@ function createAnchorPass(ctx, jsx) {
73015
73114
  pose.x = 0;
73016
73115
  pose.y = 0;
73017
73116
  pose.scale = 1;
73117
+ pose.scaleX = 1;
73118
+ pose.scaleY = 1;
73018
73119
  pose.pivot.x = 0;
73019
73120
  pose.pivot.y = 0;
73020
73121
  }
73021
- const scale = pose.scale;
73022
- if (scale <= 0) return false;
73122
+ const scaleX = pose.scale * pose.scaleX;
73123
+ const scaleY = pose.scale * pose.scaleY;
73124
+ if (scaleX <= 0 || scaleY <= 0) return false;
73023
73125
  const parent = element.parent === void 0 ? void 0 : lookup(element.parent);
73024
73126
  const given = element.node.props.pad;
73025
73127
  const pad = typeof given === "number" && Number.isFinite(given) ? given : 0;
73026
73128
  const { screen, next } = anchor;
73027
- next.x = pose.pivot.x + (screen.x - pose.x) / scale + (parent?.rect.x ?? 0) - pad;
73028
- next.y = pose.pivot.y + (screen.y - pose.y) / scale + (parent?.rect.y ?? 0) - pad;
73029
- next.w = screen.w / scale + 2 * pad;
73030
- next.h = screen.h / scale + 2 * pad;
73129
+ next.x = pose.pivot.x + (screen.x - pose.x) / scaleX + (parent?.rect.x ?? 0) - pad;
73130
+ next.y = pose.pivot.y + (screen.y - pose.y) / scaleY + (parent?.rect.y ?? 0) - pad;
73131
+ next.w = screen.w / scaleX + 2 * pad;
73132
+ next.h = screen.h / scaleY + 2 * pad;
73031
73133
  if (next.w < 0) {
73032
73134
  next.x += next.w / 2;
73033
73135
  next.w = 0;
@@ -73310,6 +73412,8 @@ function createAnchorPass(ctx, jsx) {
73310
73412
  pose.y = rest.y;
73311
73413
  pose.rotation = rest.rotation;
73312
73414
  pose.scale = rest.scale;
73415
+ if ("scaleX" in rest || "scaleX" in pose) pose.scaleX = "scaleX" in rest ? rest.scaleX ?? 1 : 1;
73416
+ if ("scaleY" in rest || "scaleY" in pose) pose.scaleY = "scaleY" in rest ? rest.scaleY ?? 1 : 1;
73313
73417
  ecs.set(element.entity, Transform, NO_PATCH);
73314
73418
  }
73315
73419
  /**
@@ -74273,10 +74377,13 @@ function edgesOf(edges, safeArea) {
74273
74377
  *
74274
74378
  * @param into - The style built so far.
74275
74379
  * @param variant - The variant to lay over it.
74380
+ * @param keepsText - Whether a `text` field of the variant is merged in. An `is` variant never
74381
+ * moves the text style key: a press must not change the letters, so a plain object that carries
74382
+ * one there is ignored.
74276
74383
  */
74277
- function merge(into, variant) {
74384
+ function merge(into, variant, keepsText = true) {
74278
74385
  if (variant === void 0) return;
74279
- for (const [field, value] of Object.entries(variant)) if (value !== void 0) into[field] = value;
74386
+ for (const [field, value] of Object.entries(variant)) if (value !== void 0 && (keepsText || field !== "text")) into[field] = value;
74280
74387
  }
74281
74388
  /**
74282
74389
  * Replaces every safe-area token of a merged style with the number of this viewport.
@@ -74333,7 +74440,7 @@ function resolve(style, flags, viewport) {
74333
74440
  for (const name of IS_ORDER) {
74334
74441
  const pointer = name === "hover" || name === "pressed";
74335
74442
  if (!flags[name] || flags.disabled && pointer) continue;
74336
- merge(merged, is?.[name]);
74443
+ merge(merged, is?.[name], false);
74337
74444
  }
74338
74445
  }
74339
74446
  return Object.freeze(withSafeArea(merged, viewport));