@moku-labs/game 0.15.117 → 0.15.119

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.
@@ -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 } from "./visual-CYq-xUqz.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";
@@ -55689,7 +55689,9 @@ const PointerOver = /*#__PURE__*/ tag("PointerOver");
55689
55689
  * On every ui scroll container, internal: ui writes it, input reads it, a game never sees it. A
55690
55690
  * press that leaves the tap slop along `axis` goes from the pressed view to the innermost scroll
55691
55691
  * of that axis the view hangs in by its `Parent` chain; a finger that lands on a view inside a
55692
- * scroll that is `moving` stops it and answers nothing.
55692
+ * scroll that is `moving` stops it and answers nothing. A `locked` scroll takes neither: the
55693
+ * hand-off ends there with the press caught and given to no one, the view under a finger keeps
55694
+ * the press while the scroll moves, and a press held on it is dropped.
55693
55695
  */
55694
55696
  const Scrollable = /*#__PURE__*/ component("Scrollable", scrollableDefaults);
55695
55697
  /**
@@ -55944,8 +55946,9 @@ function submitBlocked(ctx) {
55944
55946
  * which answers `undefined` without a DOM, and every accept function refuses a view that is
55945
55947
  * already playing its exit. A trace takes a cell only inside a circle smaller than its box. The
55946
55948
  * scroll a press belongs to is found up the pressed view's own `Parent` chain, never under the
55947
- * point: a view drawn over a scroll from another root keeps its press. While the lock of a guide
55948
- * stands, a point outside its window finds no view at all.
55949
+ * point: a view drawn over a scroll from another root keeps its press; a scroll its `locked` prop
55950
+ * holds takes none. While the lock of a guide stands, a point outside its window finds no view at
55951
+ * all.
55949
55952
  */
55950
55953
  /** How deep a `Parent` chain is followed; deeper is treated as a loop. */
55951
55954
  const MAX_DEPTH$2 = 32;
@@ -56048,11 +56051,32 @@ function findPressed(ctx, x, y) {
56048
56051
  return ctx.deps.renderer.sync.hitTest(x, y, (entity) => acceptPress(ctx, entity));
56049
56052
  }
56050
56053
  /**
56054
+ * Tells whether a view is a scroll its `locked` prop holds (F177): the finger neither moves nor
56055
+ * stops it. Reads only, allocates nothing.
56056
+ *
56057
+ * @param ctx - Domain context of the input plugin.
56058
+ * @param entity - The view.
56059
+ * @returns True when it carries a `Scrollable` with `locked` true.
56060
+ */
56061
+ function isLockedScroll(ctx, entity) {
56062
+ return ctx.deps.world.ecs.get(entity, Scrollable)?.locked === true;
56063
+ }
56064
+ /**
56065
+ * Tells whether a `Scrollable` value glides now and its `locked` prop does not hold it.
56066
+ *
56067
+ * @param scrollable - The view's `Scrollable` value, or `undefined` for a view that has none.
56068
+ * @returns True for a moving scroll that is not locked.
56069
+ */
56070
+ function isMovingUnlocked(scrollable) {
56071
+ return scrollable?.moving === true && scrollable.locked !== true;
56072
+ }
56073
+ /**
56051
56074
  * The innermost scroll a view sits in that moves now: the view itself or the nearest ancestor of
56052
- * its `Parent` chain that carries a `Scrollable` with `moving` true and is not on its way out. A
56053
- * finger that lands on the view stops that scroll. A view of another root drawn over the scroll,
56054
- * a HUD button or a popup, hangs in no chain of it, so it keeps its press. Reads only, allocates
56055
- * nothing.
56075
+ * its `Parent` chain that carries a `Scrollable` with `moving` true, is not locked and is not on
56076
+ * its way out. A finger that lands on the view stops that scroll. A locked scroll is passed over:
56077
+ * the walk goes on up the chain, and with no other scroll moving the view under the finger takes
56078
+ * the press as on a still scroll. A view of another root drawn over the scroll, a HUD button or a
56079
+ * popup, hangs in no chain of it, so it keeps its press. Reads only, allocates nothing.
56056
56080
  *
56057
56081
  * @param ctx - Domain context of the input plugin.
56058
56082
  * @param entity - The view the hit test found under the finger.
@@ -56062,7 +56086,7 @@ function movingScrollOf(ctx, entity) {
56062
56086
  const { ecs } = ctx.deps.world;
56063
56087
  let current = entity;
56064
56088
  for (let depth = 0; depth < MAX_DEPTH$2 && current !== 0; depth += 1) {
56065
- if (ecs.get(current, Scrollable)?.moving === true && !ecs.has(current, Exiting)) return current;
56089
+ if (isMovingUnlocked(ecs.get(current, Scrollable)) && !ecs.has(current, Exiting)) return current;
56066
56090
  current = parentOf$1(ecs, current);
56067
56091
  }
56068
56092
  }
@@ -57247,12 +57271,42 @@ function onDown(ctx, pointer, point, sample) {
57247
57271
  if (ecs.has(entity, Draggable) && ecs.has(entity, Swipeable)) ctx.log.warn("input: Draggable wins over Swipeable", { view: ctx.state.key });
57248
57272
  }
57249
57273
  /**
57274
+ * Lets the press go with no answer while the finger stays followed: the pressed view loses
57275
+ * `Pressed`, and the press is caught and belongs to no view, so a later move hands nothing on and
57276
+ * the release answers nothing and runs no listener.
57277
+ *
57278
+ * @param ctx - Domain context of the input plugin.
57279
+ */
57280
+ function dropPress(ctx) {
57281
+ const { entity } = ctx.state;
57282
+ if (entity !== void 0) ctx.deps.world.ecs.untag(entity, Pressed);
57283
+ ctx.state.caught = true;
57284
+ ctx.state.entity = void 0;
57285
+ ctx.state.key = void 0;
57286
+ }
57287
+ /**
57288
+ * Drops a press held on a scroll its `locked` prop holds (F177), after the samples are drained: a
57289
+ * press that landed on its own background, or one it held when the lock came. The finger stays
57290
+ * followed until it lifts, so an unlock before the lift gives the scroll nothing. A press on a view
57291
+ * inside the scroll is that view's and stays.
57292
+ *
57293
+ * @param ctx - Domain context of the input plugin.
57294
+ */
57295
+ function dropLockedPress(ctx) {
57296
+ const { entity, phase } = ctx.state;
57297
+ if (phase !== "pressed" || entity === void 0 || !isLockedScroll(ctx, entity)) return;
57298
+ dropPress(ctx);
57299
+ }
57300
+ /**
57250
57301
  * The press just left the tap slop: it goes to the scroll it pans, the innermost `Scrollable` of
57251
57302
  * the pressed view's own `Parent` chain (the view itself included) that moves on the dominant axis
57252
57303
  * of the move. The view loses `Pressed`, and the press is marked caught: it is a scroll gesture
57253
- * now, so its release answers nothing, also when the finger came back inside the slop. A
57254
- * draggable or swipeable view keeps its gesture, a caught press keeps its scroll, and a view that
57255
- * sits in no scroll of that axis keeps its press, also a popup button drawn over a list.
57304
+ * now, so its release answers nothing, also when the finger came back inside the slop. A locked
57305
+ * scroll does nothing with it: the press is dropped and no scroll is pressed, also not one of the
57306
+ * same axis around it. A press that sits on a locked scroll's own background is dropped the same
57307
+ * way, whatever axis the move has. A draggable or swipeable view keeps its gesture, a caught press keeps its
57308
+ * scroll, and a view that sits in no scroll of that axis keeps its press, also a popup button
57309
+ * drawn over a list.
57256
57310
  *
57257
57311
  * @param ctx - Domain context of the input plugin.
57258
57312
  * @param point - Where the finger is, in reference units.
@@ -57262,9 +57316,17 @@ function handOff(ctx, point) {
57262
57316
  const { ecs } = ctx.deps.world;
57263
57317
  if (entity === void 0 || caught) return;
57264
57318
  if (ecs.has(entity, Draggable) || ecs.has(entity, Swipeable)) return;
57319
+ if (isLockedScroll(ctx, entity)) {
57320
+ dropPress(ctx);
57321
+ return;
57322
+ }
57265
57323
  const scroll = scrollOnAxisOf(ctx, entity, axisOf$1(start, point));
57266
57324
  if (scroll === void 0 || scroll === entity) return;
57267
57325
  lostPress(ctx, "scroll");
57326
+ if (isLockedScroll(ctx, scroll)) {
57327
+ dropPress(ctx);
57328
+ return;
57329
+ }
57268
57330
  ecs.untag(entity, Pressed);
57269
57331
  ctx.state.caught = true;
57270
57332
  press(ctx, scroll);
@@ -57597,7 +57659,8 @@ function clearJust(pointer) {
57597
57659
  * (F61): the pressed view is tagged and a release answers the gate now, so the press look starts
57598
57660
  * in the next frame and a node that awaits nothing commits before it. The first resolve after a
57599
57661
  * frame clears that frame's flags; the next frame step keeps the ones it wrote. Only a live world
57600
- * resolves early: fast and paused leave the samples to the frame step, as before.
57662
+ * resolves early: fast and paused leave the samples to the frame step, as before. A press that
57663
+ * landed on a locked scroll is dropped here, before any system sees it.
57601
57664
  *
57602
57665
  * @param ctx - Domain context of the input plugin.
57603
57666
  */
@@ -57611,6 +57674,7 @@ function resolveEarly(ctx) {
57611
57674
  }
57612
57675
  ctx.state.samples = [];
57613
57676
  drainSamples(ctx, pointer, queue);
57677
+ dropLockedPress(ctx);
57614
57678
  syncCursor(ctx);
57615
57679
  pointer.id = ctx.state.pointerId ?? -1;
57616
57680
  }
@@ -57618,6 +57682,7 @@ function resolveEarly(ctx) {
57618
57682
  * The one frame step of the plugin, registered with `time.onFrame("input")` in `onInit`, so it
57619
57683
  * runs before the `world` callback of the same phase: `Pointer`, `Held`, `Hovered` and `Pressed`
57620
57684
  * are fresh when game systems of phase `input` read them.
57685
+ * A press held on a locked scroll is dropped once the samples are drained.
57621
57686
  * The canvas cursor is set right after the hover. `Pointer.id` is written last, once per step: the
57622
57687
  * followed `pointerId`, `-1` when no pointer is followed.
57623
57688
  *
@@ -57644,6 +57709,7 @@ function stepGestures(ctx, time) {
57644
57709
  else clearJust(pointer);
57645
57710
  ctx.state.samples = [];
57646
57711
  drainSamples(ctx, pointer, queue);
57712
+ dropLockedPress(ctx);
57647
57713
  syncCursor(ctx);
57648
57714
  advanceTime(ctx, pointer, time.delta);
57649
57715
  if (ctx.state.phase === "dragging") followDrag(ctx, pointer);
@@ -64191,6 +64257,7 @@ function scrollMotionOf(node) {
64191
64257
  seen: 0,
64192
64258
  aim: void 0,
64193
64259
  glideMs: NaN,
64260
+ locked: false,
64194
64261
  placed: false,
64195
64262
  atProp: false
64196
64263
  };
@@ -64332,19 +64399,18 @@ function contentOf$2(element, resolvedOf) {
64332
64399
  }
64333
64400
  /**
64334
64401
  * The text style key of a text element: the style a format of the game answered, for a text whose
64335
- * bind names one; else the `style` prop while that is a key.
64402
+ * bind names one; else the key its style object took for this frame (F182); else the `style` prop
64403
+ * while that is a key.
64336
64404
  *
64337
64405
  * @param element - The element to read.
64338
64406
  * @param shownStyleOf - Reads `Text.style` of an entity; none for a tree read without a world.
64339
- * @returns The key, or `undefined` for any other element and for a text with a `Style` object or
64340
- * no style.
64407
+ * @returns The key, or `undefined` for any other element and for a text whose style names none.
64341
64408
  */
64342
64409
  function textStyleOf(element, shownStyleOf) {
64343
64410
  if (element.type !== "text") return void 0;
64344
64411
  const shown = namesFormat(element) ? shownStyleOf?.(element.entity) : void 0;
64345
64412
  if (shown !== void 0) return shown;
64346
- const style = element.node.props.style;
64347
- return typeof style === "string" ? style : void 0;
64413
+ return namedKeyOf(element.style, element.node.props.style);
64348
64414
  }
64349
64415
  /**
64350
64416
  * Turns one element and its subtree into snapshot nodes. The rect is natural; a fitted element
@@ -64878,8 +64944,9 @@ function formatIfLoaded(ctx, message, locale) {
64878
64944
  }
64879
64945
  }
64880
64946
  /**
64881
- * Measures a text in every loaded locale and reports the widest one that does not fit. A lazy
64882
- * locale the player has not picked yet cannot be measured, so it is skipped.
64947
+ * Measures a text in every loaded locale, in the key its markup names for this frame, and reports
64948
+ * the widest one that does not fit. A lazy locale the player has not picked yet cannot be
64949
+ * measured, so it is skipped.
64883
64950
  *
64884
64951
  * @param ctx - Domain context of the ui plugin.
64885
64952
  * @param element - The text element.
@@ -64888,7 +64955,7 @@ function formatIfLoaded(ctx, message, locale) {
64888
64955
  function textOverflow(ctx, element) {
64889
64956
  if (element.type !== "text") return void 0;
64890
64957
  const content = element.node.props.content;
64891
- const style = typeof element.node.props.style === "string" ? element.node.props.style : "body";
64958
+ const style = writtenKeyOf(element);
64892
64959
  if (typeof content !== "object" || content === null) return void 0;
64893
64960
  for (const locale of ctx.deps.i18n.locales()) {
64894
64961
  const parts = formatIfLoaded(ctx, content, locale);
@@ -67463,6 +67530,12 @@ const TEXT_KEPT = Object.freeze([
67463
67530
  "content",
67464
67531
  "style"
67465
67532
  ]);
67533
+ /**
67534
+ * The fields of `Text` a write leaves alone when the markup says what it said but its style names
67535
+ * another text style key for this frame (F182): the style is written, the content a game's system
67536
+ * may have written stays (F167).
67537
+ */
67538
+ const TEXT_CONTENT_KEPT = Object.freeze([...Text.owned, "content"]);
67466
67539
  /** The time of a reconcile a test steps by hand: no ms pass, so no scroll moves. */
67467
67540
  const NO_TIME = Object.freeze({
67468
67541
  delta: 0,
@@ -67691,7 +67764,8 @@ function answerOf(node) {
67691
67764
  * The input components of an element: a button answers the gate, writes local state, or only
67692
67765
  * swallows the tap; a panel swallows the tap too, so nothing under it answers; a text field takes
67693
67766
  * the tap that starts its editing; a scroll container takes the press that moves its content and
67694
- * carries where it stands, on the axis it spawned with. A button of a covered popup answers
67767
+ * carries where it stands, on the axis it spawned with, locked from the start when its first render
67768
+ * says `locked`. A button of a covered popup answers
67695
67769
  * nothing, so only the top popup answers the gate. A button with the `escape` prop that answers
67696
67770
  * also carries `Escapable`, the control the Escape key taps.
67697
67771
  *
@@ -67702,13 +67776,18 @@ function inputOf(element) {
67702
67776
  const { type, node, is } = element;
67703
67777
  if (type === "scroll") {
67704
67778
  const axis = element.scroll?.axis ?? "y";
67779
+ const scrollable = node.props.locked === true ? Scrollable({
67780
+ axis,
67781
+ moving: false,
67782
+ locked: true
67783
+ }) : Scrollable({
67784
+ axis,
67785
+ moving: false
67786
+ });
67705
67787
  return [
67706
67788
  Touchable(),
67707
67789
  Scroll({ axis }),
67708
- Scrollable({
67709
- axis,
67710
- moving: false
67711
- }),
67790
+ scrollable,
67712
67791
  ScrollState()
67713
67792
  ];
67714
67793
  }
@@ -67972,6 +68051,7 @@ function createReconciler(ctx, modules, fields) {
67972
68051
  let slotsRoots = -1;
67973
68052
  let placedUnder;
67974
68053
  let textKept = false;
68054
+ let keyKept = true;
67975
68055
  let rendered = 0;
67976
68056
  const isAside = (entity) => ctx.deps.world.projection.isBuilding(entity);
67977
68057
  let released = false;
@@ -68266,10 +68346,13 @@ function createReconciler(ctx, modules, fields) {
68266
68346
  *
68267
68347
  * @param element - The element that changed.
68268
68348
  * @param keepsText - Whether the markup's `content`, `style` and `bind` say what they said.
68349
+ * @param keepsKey - Whether the text style key of this frame is the one before; a new one is
68350
+ * written into `Text.style` even when the markup says the same (F182).
68269
68351
  */
68270
- function writeLive(element, keepsText) {
68352
+ function writeLive(element, keepsText, keepsKey = true) {
68271
68353
  state.written += 1;
68272
68354
  textKept = keepsText;
68355
+ keyKept = keepsKey;
68273
68356
  writeOrder(element);
68274
68357
  const visuals = visualOf$1(element);
68275
68358
  const inputs = inputOf(element);
@@ -68331,7 +68414,8 @@ function createReconciler(ctx, modules, fields) {
68331
68414
  }
68332
68415
  /**
68333
68416
  * The fields a write of the current pass leaves alone: those of `fieldsLeftAlone`, and on the
68334
- * `Text` of a write with no new content in the markup its content and style too.
68417
+ * `Text` of a write with no new content in the markup its content, and its style too unless the
68418
+ * frame names another key for it (a style a named format answers always stays).
68335
68419
  *
68336
68420
  * @param element - The live element.
68337
68421
  * @param type - The component type of the value.
@@ -68339,7 +68423,8 @@ function createReconciler(ctx, modules, fields) {
68339
68423
  * @returns The fields left alone: a list of the module, never a new one, for a kept text.
68340
68424
  */
68341
68425
  function leftAlone(element, type, owned) {
68342
- return type === Text && textKept ? TEXT_KEPT : fieldsLeftAlone(element, type, owned);
68426
+ if (type !== Text || !textKept) return fieldsLeftAlone(element, type, owned);
68427
+ return keyKept || namesFormat(element) ? TEXT_KEPT : TEXT_CONTENT_KEPT;
68343
68428
  }
68344
68429
  /**
68345
68430
  * Writes one visual or input value onto a live element: added when the entity lacks it, else
@@ -68388,6 +68473,7 @@ function createReconciler(ctx, modules, fields) {
68388
68473
  const keepsStyle = stands && sameStyle && sameValue(element.is, is);
68389
68474
  const style = keepsStyle ? element.style : styleFor(parent, node, is);
68390
68475
  const sameContent = sameValue(previous.props.content, node.props.content);
68476
+ const keepsKey = namedKeyOf(element.style, previous.props.style) === namedKeyOf(style, node.props.style);
68391
68477
  return {
68392
68478
  is,
68393
68479
  style,
@@ -68396,6 +68482,7 @@ function createReconciler(ctx, modules, fields) {
68396
68482
  moved: !keepsStyle && modules.layout.affectsRect(element.style, style),
68397
68483
  measures: !stands || !sameStyle || !sameContent,
68398
68484
  keepsText: sameStyle && sameContent && sameValue(previous.props.bind, node.props.bind),
68485
+ keepsKey,
68399
68486
  unchanged: keepsStyle && sameContent && writesSame(previous, node)
68400
68487
  };
68401
68488
  }
@@ -68416,7 +68503,7 @@ function createReconciler(ctx, modules, fields) {
68416
68503
  root.needsSolve = true;
68417
68504
  }
68418
68505
  if (!element.live) return;
68419
- writeLive(element, change.keepsText);
68506
+ writeLive(element, change.keepsText, change.keepsKey);
68420
68507
  if (!change.moved) modules.layout.repose(element, parentRect(element), false, hintOf(state, element));
68421
68508
  }
68422
68509
  /**
@@ -71157,8 +71244,8 @@ function guardPointer(ctx, door) {
71157
71244
  }
71158
71245
  //#endregion
71159
71246
  //#region src/plugins/ui/layout/measure.ts
71160
- /** What a text is drawn in when its `style` prop is a layout style instead of a style key. */
71161
- const DEFAULT_TEXT_STYLE = "body";
71247
+ /** The text style an icon without a size is squared on. */
71248
+ const ICON_LINE_STYLE = "body";
71162
71249
  /** The glyph an icon is sized from: one line of the text style it sits in. */
71163
71250
  const LINE_SAMPLE = "M";
71164
71251
  /** Below this a measured length counts as whole: the tolerance Yoga's own rounding uses. */
@@ -71170,7 +71257,7 @@ const WHOLE_EPSILON = 1e-4;
71170
71257
  * @returns The height of that line, as `text` measures it now.
71171
71258
  */
71172
71259
  function lineOf(source) {
71173
- return source.measure(LINE_SAMPLE, DEFAULT_TEXT_STYLE).height;
71260
+ return source.measure(LINE_SAMPLE, ICON_LINE_STYLE).height;
71174
71261
  }
71175
71262
  /**
71176
71263
  * Tells whether the line the icons are squared on moved since an icon was last measured: the
@@ -71218,24 +71305,15 @@ function needsMeasure(element) {
71218
71305
  return typeof element.style.width !== "number" || typeof element.style.height !== "number";
71219
71306
  }
71220
71307
  /**
71221
- * Reads the style key of a text or an icon out of its props.
71222
- *
71223
- * @param element - The element.
71224
- * @returns The key `text.measure` takes.
71225
- */
71226
- function styleKeyOf(element) {
71227
- const { style } = element.node.props;
71228
- return typeof style === "string" ? style : DEFAULT_TEXT_STYLE;
71229
- }
71230
- /**
71231
- * Reads what a text draws out of its props.
71308
+ * Reads what a text draws out of its markup: the content of its props, and the key its style of
71309
+ * this frame names (`writtenKeyOf`).
71232
71310
  *
71233
71311
  * @param element - The text element.
71234
71312
  * @returns The content and the style key `text.measure` takes.
71235
71313
  */
71236
71314
  function contentOf$1(element) {
71237
71315
  const { content } = element.node.props;
71238
- const styleKey = styleKeyOf(element);
71316
+ const styleKey = writtenKeyOf(element);
71239
71317
  if (typeof content === "string") return {
71240
71318
  content,
71241
71319
  style: styleKey
@@ -71294,7 +71372,7 @@ function boundShown(element, bind, source) {
71294
71372
  */
71295
71373
  function namedSize(element, bind, source, width) {
71296
71374
  const resolved = source.resolved(element.entity);
71297
- if (resolved !== void 0) return source.measure(resolved, source.style(element.entity) ?? styleKeyOf(element), width);
71375
+ if (resolved !== void 0) return source.measure(resolved, source.style(element.entity) ?? writtenKeyOf(element), width);
71298
71376
  const value = listedValueOf(element, bind);
71299
71377
  const answer = value === void 0 ? void 0 : source.formatted(bind.format, value);
71300
71378
  return answer === void 0 ? void 0 : source.measure(answer.text, answer.style, width);
@@ -71315,7 +71393,7 @@ function contentSize(element, source, width) {
71315
71393
  const written = contentOf$1(element);
71316
71394
  return source.measure(written.content, written.style, width);
71317
71395
  }
71318
- return source.measure(content, source.style(element.entity) ?? styleKeyOf(element), width);
71396
+ return source.measure(content, source.style(element.entity) ?? writtenKeyOf(element), width);
71319
71397
  }
71320
71398
  /**
71321
71399
  * The size a text measures to: a bound one by what it shows, any other by its content.
@@ -71328,7 +71406,7 @@ function contentSize(element, source, width) {
71328
71406
  function textSize(element, source, width) {
71329
71407
  const bind = bindOf(element);
71330
71408
  if (bind === void 0) return contentSize(element, source, width);
71331
- return (isTextFormat(bind.format) ? void 0 : namedSize(element, bind, source, width)) ?? source.measure(boundShown(element, bind, source), styleKeyOf(element), width);
71409
+ return (isTextFormat(bind.format) ? void 0 : namedSize(element, bind, source, width)) ?? source.measure(boundShown(element, bind, source), writtenKeyOf(element), width);
71332
71410
  }
71333
71411
  /**
71334
71412
  * The size a text or an icon takes before Yoga clamps it: an icon is square on one line of its
@@ -71343,7 +71421,7 @@ function textSize(element, source, width) {
71343
71421
  * @returns The width and the height, in whole units.
71344
71422
  */
71345
71423
  function naturalSize(element, source, width) {
71346
- const size = element.type === "icon" ? squareOf(source.measure(LINE_SAMPLE, styleKeyOf(element))) : textSize(element, source, width);
71424
+ const size = element.type === "icon" ? squareOf(source.measure(LINE_SAMPLE, writtenKeyOf(element))) : textSize(element, source, width);
71347
71425
  return {
71348
71426
  width: Math.ceil(size.width - WHOLE_EPSILON),
71349
71427
  height: Math.ceil(size.height - WHOLE_EPSILON)
@@ -71588,9 +71666,12 @@ function createPopupHandler(ctx, state, jsx) {
71588
71666
  * then in a fling that slows down, or in a glide to a `snap` stop; it starts at its `offset`
71589
71667
  * prop, glides there again when the prop or its `aim` changes (in `glideMs` when it gives one),
71590
71668
  * stands there at once with `jump`, and stays inside the range every solve gives it, with hard
71591
- * edges. The content moves by one `Transform` write on the axis: no solve, no motion, the children
71592
- * keep their rects. `Scroll` holds the offset the way the windowed range is cut with (0 and below),
71593
- * `ScrollState` the way a game reads it (0 to `max`), `Scrollable` whether it moves, for `input`.
71669
+ * edges. While its `locked` prop is true (F177) the finger neither moves nor stops it: a finger on
71670
+ * it counts as none, a finger that holds it when the lock comes is let go with no velocity, and the
71671
+ * props still move it. The content moves by one `Transform` write on the axis: no solve, no motion,
71672
+ * the children keep their rects. `Scroll` holds the offset the way the windowed range is cut with
71673
+ * (0 and below), `ScrollState` the way a game reads it (0 to `max`), `Scrollable` whether it moves
71674
+ * and whether it is locked, for `input`.
71594
71675
  * The exact numbers live on the element's `scroll` record and the samples of the press in the
71595
71676
  * layout state, written in place; the components get whole reference units. A frame allocates
71596
71677
  * nothing.
@@ -71712,6 +71793,15 @@ function aimOf(container) {
71712
71793
  return typeof aim === "number" && Number.isFinite(aim) ? aim : void 0;
71713
71794
  }
71714
71795
  /**
71796
+ * Whether the scroll's last render keeps the finger from moving it: only the value `true` locks.
71797
+ *
71798
+ * @param container - The scroll element.
71799
+ * @returns True when its `locked` prop is true.
71800
+ */
71801
+ function lockedOf(container) {
71802
+ return container.node.props.locked === true;
71803
+ }
71804
+ /**
71715
71805
  * The `snap` prop of the scroll's last render.
71716
71806
  *
71717
71807
  * @param container - The scroll element.
@@ -71849,7 +71939,7 @@ function releaseVelocity(state) {
71849
71939
  /**
71850
71940
  * Lets go of a scroll the finger held. With `snap` it glides to the stop nearest to where its
71851
71941
  * velocity carries in 260 ms; without, it flings, or stands when it was let go too slowly. A
71852
- * press whose samples a later press took lets go with no velocity.
71942
+ * press whose samples a later press took, and a press a lock let go, let go with no velocity.
71853
71943
  *
71854
71944
  * @param state - The layout state, which keeps the samples of the press.
71855
71945
  * @param container - The scroll that was held.
@@ -71932,9 +72022,33 @@ function moveContent(ctx, state, container, content, motion) {
71932
72022
  ecs.set(content.entity, Transform, state.scrollPatches.y);
71933
72023
  }
71934
72024
  /**
72025
+ * Writes `Scrollable` when `moving` or `locked` changed, in one write: with `locked` once the lock
72026
+ * differs from the world's, with `moving` alone otherwise, so a scroll never locked keeps a
72027
+ * `Scrollable` without the field. Nothing when both are the same.
72028
+ *
72029
+ * @param ctx - Domain context of the ui plugin.
72030
+ * @param state - The layout state, which keeps the patches.
72031
+ * @param container - The scroll element.
72032
+ * @param moving - Whether it moves now.
72033
+ * @param locked - Whether its `locked` prop holds.
72034
+ */
72035
+ function writeScrollable(ctx, state, container, moving, locked) {
72036
+ const ecs = ctx.deps.world.ecs;
72037
+ const scrollable = ecs.get(container.entity, Scrollable);
72038
+ if (scrollable === void 0) return;
72039
+ if (scrollable.locked === true !== locked) {
72040
+ state.scrollPatches.scrollLock.moving = moving;
72041
+ state.scrollPatches.scrollLock.locked = locked;
72042
+ ecs.set(container.entity, Scrollable, state.scrollPatches.scrollLock);
72043
+ } else if (scrollable.moving !== moving) {
72044
+ state.scrollPatches.scrollable.moving = moving;
72045
+ ecs.set(container.entity, Scrollable, state.scrollPatches.scrollable);
72046
+ }
72047
+ }
72048
+ /**
71935
72049
  * Writes what changed of a scroll, in whole units: `Scroll` when its offset or range moved,
71936
- * `ScrollState` when the offset, `max` or `moving` changed, `Scrollable` when `moving` did, and
71937
- * the content's pose. A frame where nothing changed writes nothing.
72050
+ * `ScrollState` when the offset, `max` or `moving` changed, `Scrollable` when `moving` or `locked`
72051
+ * did, and the content's pose. A frame where nothing changed writes nothing.
71938
72052
  *
71939
72053
  * @param ctx - Domain context of the ui plugin.
71940
72054
  * @param state - The layout state, which keeps the patches.
@@ -71949,7 +72063,6 @@ function show(ctx, state, container, content, motion) {
71949
72063
  const moving = motion.mode !== "still";
71950
72064
  const scroll = ecs.get(container.entity, Scroll);
71951
72065
  const shown = ecs.get(container.entity, ScrollState);
71952
- const scrollable = ecs.get(container.entity, Scrollable);
71953
72066
  const rangeMoved = scroll !== void 0 && (scroll.offset !== 0 - offset || scroll.min !== 0 - motion.max);
71954
72067
  const stateMoved = shown !== void 0 && (shown.offset !== offset || shown.max !== motion.max || shown.moving !== moving);
71955
72068
  if (rangeMoved) {
@@ -71963,10 +72076,7 @@ function show(ctx, state, container, content, motion) {
71963
72076
  patches.state.moving = moving;
71964
72077
  ecs.set(container.entity, ScrollState, patches.state);
71965
72078
  }
71966
- if (scrollable !== void 0 && scrollable.moving !== moving) {
71967
- patches.scrollable.moving = moving;
71968
- ecs.set(container.entity, Scrollable, patches.scrollable);
71969
- }
72079
+ writeScrollable(ctx, state, container, moving, motion.locked);
71970
72080
  moveContent(ctx, state, container, content, motion);
71971
72081
  }
71972
72082
  /**
@@ -71982,8 +72092,9 @@ function isIdle(motion, pressed) {
71982
72092
  }
71983
72093
  /**
71984
72094
  * Moves one scroll by the frame: the finger while it is pressed, the release when it lets go,
71985
- * then a fling or a glide, and writes what changed. A still scroll no finger is on costs a tag
71986
- * check.
72095
+ * then a fling or a glide, and writes what changed. `Pressed` on a locked scroll counts as no
72096
+ * finger: `input` drops that press at its next step, and the settle of the lock already let a held
72097
+ * scroll go. A still scroll no finger is on costs a tag check, a locked one a flag check more.
71987
72098
  *
71988
72099
  * @param ctx - Domain context of the ui plugin.
71989
72100
  * @param state - The layout state.
@@ -71995,10 +72106,10 @@ function isIdle(motion, pressed) {
71995
72106
  */
71996
72107
  function stepOne(ctx, state, container, lookup, pointer, time) {
71997
72108
  const ecs = ctx.deps.world.ecs;
71998
- const pressed = ecs.has(container.entity, Pressed);
72109
+ const motion = container.scroll;
72110
+ const pressed = ecs.has(container.entity, Pressed) && motion?.locked !== true;
71999
72111
  const released = !pressed && state.scrolling === container.entity;
72000
72112
  if (released) state.scrolling = void 0;
72001
- const motion = container.scroll;
72002
72113
  if (motion === void 0 || isIdle(motion, pressed)) return false;
72003
72114
  const content = contentOf(container, lookup);
72004
72115
  if (content === void 0 || !ecs.has(container.entity, Scroll)) return false;
@@ -72051,9 +72162,9 @@ function resize(motion, max) {
72051
72162
  }
72052
72163
  /**
72053
72164
  * Puts a scroll the solve just spawned at its `offset` prop, inside its range, and lets it follow
72054
- * the prop from there. Its `aim` and `glideMs` are recorded: the first `aim` moves nothing more.
72055
- * Its spawn waits in the queue of the phase: these values replace the queued ones at the flush,
72056
- * before the first draw.
72165
+ * the prop from there. Its `aim`, `glideMs` and `locked` are recorded: the first `aim` moves
72166
+ * nothing more, and the first `Scrollable` already carries the lock. Its spawn waits in the queue
72167
+ * of the phase: these values replace the queued ones at the flush, before the first draw.
72057
72168
  *
72058
72169
  * @param ctx - Domain context of the ui plugin.
72059
72170
  * @param container - The scroll element, live since this solve.
@@ -72069,6 +72180,7 @@ function place$1(ctx, container, content, motion) {
72069
72180
  motion.seen = askedOffsetOf(container);
72070
72181
  motion.aim = aimOf(container);
72071
72182
  motion.glideMs = glideMsOf(container);
72183
+ motion.locked = lockedOf(container);
72072
72184
  motion.offset = within(motion.seen, motion.max);
72073
72185
  const offset = Math.round(motion.offset);
72074
72186
  const pose = motion.axis === "x" ? {
@@ -72113,7 +72225,9 @@ function followOffset(motion, container, asked) {
72113
72225
  * a new range at once, then a glide to a new `offset` prop or to the same one under a new `aim`,
72114
72226
  * which the scroll follows from then on. With `jump` it stands at the prop at once instead, in the
72115
72227
  * solve that gave the content its new rects; a glide to the prop that runs, the one a new range
72116
- * re-aimed too, ends at its target. A scroll the finger holds only remembers the prop and the aim.
72228
+ * re-aimed too, ends at its target. A scroll the finger holds only remembers the prop and the aim,
72229
+ * unless this render locks it: the finger is let go first, with no velocity, so a new prop or aim
72230
+ * of the same render is followed, and a prop only remembered before is not.
72117
72231
  *
72118
72232
  * @param ctx - Domain context of the ui plugin.
72119
72233
  * @param state - The layout state, which keeps the patches.
@@ -72123,7 +72237,12 @@ function followOffset(motion, container, asked) {
72123
72237
  */
72124
72238
  function settle(ctx, state, container, content, motion) {
72125
72239
  motion.glideMs = glideMsOf(container);
72240
+ motion.locked = lockedOf(container);
72126
72241
  resize(motion, maxOf(container, content, motion.axis));
72242
+ if (motion.locked && motion.mode === "held") {
72243
+ if (state.scrolling === container.entity) state.scrolling = void 0;
72244
+ letGo$1(state, container, motion, false);
72245
+ }
72127
72246
  const asked = askedOffsetOf(container);
72128
72247
  const aim = aimOf(container);
72129
72248
  const aimed = !Object.is(aim, motion.aim);
@@ -72158,10 +72277,10 @@ function standAtTarget(ctx, state, container, content, motion) {
72158
72277
  * inside a new range at once, a running glide's target too, and glides to a new `offset` prop, or
72159
72278
  * to the same one under a new `aim`, in `glideMs` when it gives one; the same value and aim on a
72160
72279
  * re-render do nothing, `jump` ends a glide to the prop at its target, and a scroll the finger
72161
- * holds only remembers the prop and the aim. A scroll nobody sees yet (`stands`: a root built
72162
- * aside or held warm) stands at its target at once instead of gliding, so no glide plays hidden or
72163
- * at its open. A scroll left moving wakes the loop the way `stepScroll` does: not at a time scale
72164
- * of 0, where it stands.
72280
+ * holds only remembers the prop and the aim; a render that locks it lets the finger go first. A
72281
+ * scroll nobody sees yet (`stands`: a root built aside or held warm) stands at its target at once
72282
+ * instead of gliding, so no glide plays hidden or at its open. A scroll left moving wakes the loop
72283
+ * the way `stepScroll` does: not at a time scale of 0, where it stands.
72165
72284
  *
72166
72285
  * @param ctx - Domain context of the ui plugin.
72167
72286
  * @param state - The layout state, which keeps the patches.
@@ -74159,10 +74278,13 @@ function edgesOf(edges, safeArea) {
74159
74278
  *
74160
74279
  * @param into - The style built so far.
74161
74280
  * @param variant - The variant to lay over it.
74281
+ * @param keepsText - Whether a `text` field of the variant is merged in. An `is` variant never
74282
+ * moves the text style key: a press must not change the letters, so a plain object that carries
74283
+ * one there is ignored.
74162
74284
  */
74163
- function merge(into, variant) {
74285
+ function merge(into, variant, keepsText = true) {
74164
74286
  if (variant === void 0) return;
74165
- for (const [field, value] of Object.entries(variant)) if (value !== void 0) into[field] = value;
74287
+ for (const [field, value] of Object.entries(variant)) if (value !== void 0 && (keepsText || field !== "text")) into[field] = value;
74166
74288
  }
74167
74289
  /**
74168
74290
  * Replaces every safe-area token of a merged style with the number of this viewport.
@@ -74219,7 +74341,7 @@ function resolve(style, flags, viewport) {
74219
74341
  for (const name of IS_ORDER) {
74220
74342
  const pointer = name === "hover" || name === "pressed";
74221
74343
  if (!flags[name] || flags.disabled && pointer) continue;
74222
- merge(merged, is?.[name]);
74344
+ merge(merged, is?.[name], false);
74223
74345
  }
74224
74346
  }
74225
74347
  return Object.freeze(withSafeArea(merged, viewport));
@@ -74367,6 +74489,10 @@ function scrollPatches() {
74367
74489
  moving: false
74368
74490
  },
74369
74491
  scrollable: { moving: false },
74492
+ scrollLock: {
74493
+ moving: false,
74494
+ locked: false
74495
+ },
74370
74496
  x: { x: 0 },
74371
74497
  y: { y: 0 }
74372
74498
  };
@@ -1,6 +1,6 @@
1
1
  import { Fr as ClockSource, Jn as NodeFx, Lr as FakeClock, Nn as AnyFlow, Un as Descriptor, Ur as Json, jn as FeaturePlugin, qn as Hint, zn as NodeTable } from "./types-BUR4LWSa.mjs";
2
- import { t as createApp } from "./index-Cdl7-lTx.mjs";
3
- import { b as memory, x as saveOf, y as WithGameState } from "./types-DGBAOEkO.mjs";
2
+ import { t as createApp } from "./index-CKF3qS2-.mjs";
3
+ import { b as memory, x as saveOf, y as WithGameState } from "./types-XygtsVg3.mjs";
4
4
  import { a as createHeadless, i as ReproResult, n as HeadlessGame, o as runRepro, r as Repro, s as stepFrames, t as HeadlessApp } from "./headless-C5kxf9oU.mjs";
5
5
  import { AnyPluginInstance } from "@moku-labs/core";
6
6
 
package/dist/testing.mjs CHANGED
@@ -1,4 +1,4 @@
1
- import { dn as refuseStart, gn as type, pn as exit, t as createApp, w as flattenFeatures } from "./src-spqsx3lB.mjs";
1
+ import { dn as refuseStart, gn as type, pn as exit, t as createApp, w as flattenFeatures } from "./src-_nn6V6aX.mjs";
2
2
  import { n as saveOf, t as memory } from "./memory-DeD9wis6.mjs";
3
3
  import { n as fakeClock } from "./fake-hnJcJeYf.mjs";
4
4
  import { i as stepFrames, r as runRepro, t as createHeadless } from "./headless-CCiUwvlp.mjs";