@moku-labs/game 0.15.66 → 0.15.67

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/app.mjs CHANGED
@@ -1,4 +1,4 @@
1
- import { Ft as audioPlugin, H as platformPlugin, i as screen, m as flattenFeatures, t as createApp, wt as effectsPlugin } from "./src-CSmeCq6N.mjs";
1
+ import { Ft as audioPlugin, H as platformPlugin, i as screen, m as flattenFeatures, t as createApp, wt as effectsPlugin } from "./src-C6oUOPds.mjs";
2
2
  import { t as memory } from "./memory-CWlqhS7l.mjs";
3
3
  import { n as fakeClock, r as isFakeClock } from "./fake-hnJcJeYf.mjs";
4
4
  //#region src/app/define.ts
@@ -137,8 +137,8 @@ declare const commands: Readonly<{
137
137
  readonly ui: Pick<UiApi, "fill">;
138
138
  }>;
139
139
  scroll: Command<{
140
- readonly to: "number";
141
140
  readonly key: "string";
141
+ readonly to: "number";
142
142
  }, boolean, HeadlessApp & {
143
143
  readonly log: import("@moku-labs/common/browser").LogApi;
144
144
  } & {
@@ -1,6 +1,6 @@
1
1
  import { t as HeadlessApp } from "./headless-BdfPq6Rk.mjs";
2
2
  import { i as InputArguments, n as Command, o as InputSchema, s as Ran } from "./types-C9LTGx_J.mjs";
3
- import { t as commands } from "./commands-Bm8eGFaH.mjs";
3
+ import { t as commands } from "./commands-BxXC3hYN.mjs";
4
4
  import { t as defineCommand } from "./define-CvDuGXk8.mjs";
5
5
 
6
6
  //#region src/plugins/flow/doors/dev.d.ts
package/dist/index.mjs CHANGED
@@ -1,4 +1,4 @@
1
- import { $ as sfx, $t as flowPlugin, A as types_exports$7, At as Glow, B as defineMotion, Bt as Animation, C as types_exports$14, Ct as messageDuration, D as types_exports$10, Dt as Blur, E as types_exports$11, Et as Alpha, F as types_exports$2, Ft as audioPlugin, G as external, Gt as MONITOR_SECTIONS, H as platformPlugin, Ht as rendererPlugin, I as types_exports$1, It as scenesPlugin, J as mark, Jt as PERF_LOG_VERSION, K as frames, Kt as PERF_CAUSES, L as types_exports, Lt as assetsPlugin, M as types_exports$5, Mt as Outline, N as types_exports$4, Nt as defineFilter, O as types_exports$9, Ot as ColorMatrix, P as types_exports$3, Pt as debugPlugin, Q as set, Qt as worldPlugin, R as uiPlugin, Rt as animPlugin, S as types_exports$15, St as messageArgument, T as types_exports$12, Tt as Emitter, U as HAPTIC_KINDS, Ut as PASS_KINDS, V as textPlugin, Vt as Frames, W as defineAnimation, Wt as frameAt, X as play, Xt as SHADER_WHATS, Y as parallel, Yt as PROBLEM_RULES, Z as sequence, Zt as DEMAND_REASONS, _ as defineBundles, _t as Tappable, a as cubicBezier, an as type, at as use, b as types_exports$17, bt as Traced, c as hint, cn as lifecyclePlugin, ct as Draggable, d as defineScene, dt as Hovered, et as spawn, f as tr, ft as Pointer, g as music, gt as Swipeable, h as defineEmitter, ht as Pressed, i as screen, in as to, it as tween, j as types_exports$6, jt as Noise, k as types_exports$8, kt as Displacement, l as schedule, ln as timePlugin, lt as DropTarget, m as flattenFeatures, mt as Pressable, n as createPlugin, nn as exit, nt as stagger, o as defineEffect, on as modelPlugin, ot as wait, p as defineFeature, pt as PointerOver, q as haptic, qt as PERF_GAP_BUCKETS, r as defineGame, rn as slot, rt as stopSfx, s as guide, sn as SaveUnreadableError, st as inputPlugin, t as createApp, tn as contribution, tt as spawned, u as projection, un as clockPlugin, ut as Held, v as load, vt as Touchable, w as types_exports$13, wt as effectsPlugin, x as types_exports$16, xt as i18nPlugin, y as ready, yt as Traceable, z as resolve, zt as AnimPlayer } from "./src-CSmeCq6N.mjs";
1
+ import { $ as sfx, $t as flowPlugin, A as types_exports$7, At as Glow, B as defineMotion, Bt as Animation, C as types_exports$14, Ct as messageDuration, D as types_exports$10, Dt as Blur, E as types_exports$11, Et as Alpha, F as types_exports$2, Ft as audioPlugin, G as external, Gt as MONITOR_SECTIONS, H as platformPlugin, Ht as rendererPlugin, I as types_exports$1, It as scenesPlugin, J as mark, Jt as PERF_LOG_VERSION, K as frames, Kt as PERF_CAUSES, L as types_exports, Lt as assetsPlugin, M as types_exports$5, Mt as Outline, N as types_exports$4, Nt as defineFilter, O as types_exports$9, Ot as ColorMatrix, P as types_exports$3, Pt as debugPlugin, Q as set, Qt as worldPlugin, R as uiPlugin, Rt as animPlugin, S as types_exports$15, St as messageArgument, T as types_exports$12, Tt as Emitter, U as HAPTIC_KINDS, Ut as PASS_KINDS, V as textPlugin, Vt as Frames, W as defineAnimation, Wt as frameAt, X as play, Xt as SHADER_WHATS, Y as parallel, Yt as PROBLEM_RULES, Z as sequence, Zt as DEMAND_REASONS, _ as defineBundles, _t as Tappable, a as cubicBezier, an as type, at as use, b as types_exports$17, bt as Traced, c as hint, cn as lifecyclePlugin, ct as Draggable, d as defineScene, dt as Hovered, et as spawn, f as tr, ft as Pointer, g as music, gt as Swipeable, h as defineEmitter, ht as Pressed, i as screen, in as to, it as tween, j as types_exports$6, jt as Noise, k as types_exports$8, kt as Displacement, l as schedule, ln as timePlugin, lt as DropTarget, m as flattenFeatures, mt as Pressable, n as createPlugin, nn as exit, nt as stagger, o as defineEffect, on as modelPlugin, ot as wait, p as defineFeature, pt as PointerOver, q as haptic, qt as PERF_GAP_BUCKETS, r as defineGame, rn as slot, rt as stopSfx, s as guide, sn as SaveUnreadableError, st as inputPlugin, t as createApp, tn as contribution, tt as spawned, u as projection, un as clockPlugin, ut as Held, v as load, vt as Touchable, w as types_exports$13, wt as effectsPlugin, x as types_exports$16, xt as i18nPlugin, y as ready, yt as Traceable, z as resolve, zt as AnimPlayer } from "./src-C6oUOPds.mjs";
2
2
  import { $ as Layer, B as Display, C as defineStyle, E as bind, G as Parent, H as NineSlice, J as Transform, K as Shape, O as defineTextStyles, Q as Exiting, S as defineTokens, T as Text, U as Overlay, V as HudPart, Z as sprite, _ as ScrollState, at as resource, b as popup, ct as tag, d as Box, et as Now, h as LocalWrite, it as mut, k as label, nt as Tree, ot as system, p as DebugTrigger, q as Sprite, rt as component, tt as Order, w as Countdown } from "./visual-B7TxMv1J.mjs";
3
3
  import { t as defineComponent } from "./component-DGg5DqKK.mjs";
4
4
  export { Alpha, types_exports as Anim, AnimPlayer, Animation, types_exports$1 as Assets, types_exports$2 as Audio, Blur, Box, types_exports$3 as Clock, ColorMatrix, Countdown, DEMAND_REASONS, types_exports$4 as Debug, DebugTrigger, Displacement, Display, Draggable, DropTarget, types_exports$5 as Effects, Emitter, Exiting, types_exports$6 as Flow, Frames, Glow, HAPTIC_KINDS, Held, Hovered, HudPart, types_exports$7 as I18n, types_exports$8 as Input, Layer, types_exports$9 as Lifecycle, LocalWrite, MONITOR_SECTIONS, types_exports$10 as Model, NineSlice, Noise, Now, Order, Outline, Overlay, PASS_KINDS, PERF_CAUSES, PERF_GAP_BUCKETS, PERF_LOG_VERSION, PROBLEM_RULES, Parent, types_exports$11 as Platform, Pointer, PointerOver, Pressable, Pressed, types_exports$12 as Renderer, SHADER_WHATS, SaveUnreadableError, types_exports$13 as Scenes, ScrollState, Shape, Sprite, Swipeable, Tappable, Text, types_exports$14 as TextTypes, types_exports$15 as Time, Touchable, Traceable, Traced, Transform, Tree, types_exports$16 as Ui, types_exports$17 as World, animPlugin, assetsPlugin, audioPlugin, bind, clockPlugin, component, contribution, createApp, createPlugin, cubicBezier, debugPlugin, defineAnimation, defineBundles, defineComponent, defineEffect, defineEmitter, defineFeature, defineFilter, defineGame, defineMotion, defineScene, defineStyle, defineTextStyles, defineTokens, effectsPlugin, exit, external, flattenFeatures, flowPlugin, frameAt, frames, guide, haptic, hint, i18nPlugin, inputPlugin, label, lifecyclePlugin, load, mark, messageArgument, messageDuration, modelPlugin, music, mut, parallel, platformPlugin, play, popup, projection, ready, rendererPlugin, resolve, resource, scenesPlugin, schedule, screen, sequence, set, sfx, slot, spawn, spawned, sprite, stagger, stopSfx, system, tag, textPlugin, timePlugin, to, tr, tween, type, uiPlugin, use, wait, worldPlugin };
@@ -122,8 +122,8 @@ declare const sources: Readonly<{
122
122
  readonly world: Api$1;
123
123
  }>;
124
124
  diff: Source<{
125
- readonly from: "number";
126
125
  readonly to: "number";
126
+ readonly from: "number";
127
127
  }, FrameDiff, HeadlessApp & {
128
128
  readonly world: Api$1;
129
129
  }>;
@@ -3,7 +3,7 @@ import { r as systemSource, t as memory } from "./memory-CWlqhS7l.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
5
  import { $ as Layer, A as readStyle, B as Display, D as builtInStyles, F as parentOf$1, G as Parent, H as NineSlice, I as poseUnder, J as Transform, K as Shape, L as rootPointOf, M as applyPose, N as isLeaving, P as localPoseOf, Q as Exiting, R as rootPoseInto, T as Text, U as Overlay, V as HudPart, W as OverlayLevel, X as componentsFor, Y as arcDefaults, _ as ScrollState, a as fitScaleOf, at as resource, c as samePose, ct as tag, d as Box, et as Now, f as Covered, g as Scroll, h as LocalWrite, i as fieldsLeftAlone, j as textFor, l as visualOf$1, m as Escapable, n as CONTENT$1, nt as Tree, o as livePatch, ot as system, p as DebugTrigger, q as Sprite, r as drawnRect, rt as component, s as restValueOf, st as systemsFor, tt as Order, u as visualRectOf, v as UI_OWNER, w as Countdown, x as uiFor, y as UiCounters, z as rootPoseOf } from "./visual-B7TxMv1J.mjs";
6
- import { a as isDev } from "./dev-BNndV-hU.mjs";
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";
9
9
  import { envPlugin, logPlugin } from "@moku-labs/common/browser";
@@ -3422,6 +3422,30 @@ function objectEquals(left, right) {
3422
3422
  * for an answer that arrived while the gate was closed, and the `guide` narrow.
3423
3423
  */
3424
3424
  /**
3425
+ * Tells whether the dev log is on: a dev build, `__MOKU_GAME_DEV__` defined true.
3426
+ *
3427
+ * @returns True in a dev build.
3428
+ */
3429
+ function isDev() {
3430
+ return typeof __MOKU_GAME_DEV__ !== "undefined" && __MOKU_GAME_DEV__;
3431
+ }
3432
+ /**
3433
+ * Logs, in a dev build, an answer a closed gate refused that no gate will take (F122). The payload
3434
+ * is built only when the line is written.
3435
+ *
3436
+ * @param ctx - Domain context of the flow plugin.
3437
+ * @param answer - The answer that is lost.
3438
+ * @param reason - Why no gate takes it.
3439
+ */
3440
+ function dropped(ctx, answer, reason) {
3441
+ if (!isDev()) return;
3442
+ ctx.log.warn("flow:answer-dropped", {
3443
+ intent: answer.intent,
3444
+ payload: answer.payload,
3445
+ reason
3446
+ });
3447
+ }
3448
+ /**
3425
3449
  * Tells whether an answer is the one a guide names: the intent matches, and the payload too when
3426
3450
  * the guide's answer carries one.
3427
3451
  *
@@ -3512,9 +3536,17 @@ function deliver$1(state, answer) {
3512
3536
  * @param answer - The answer the closed gate refused.
3513
3537
  */
3514
3538
  function hold$1(ctx, answer) {
3515
- if (ctx.state.fx.mode === "fast") return;
3516
- if (!ctx.deps.time.isRunning()) return;
3517
- if (ctx.config.holdMs <= 0 && ctx.state.gate.held !== void 0) return;
3539
+ if (ctx.state.fx.mode === "fast") {
3540
+ dropped(ctx, answer, "fast");
3541
+ return;
3542
+ }
3543
+ if (!ctx.deps.time.isRunning()) {
3544
+ dropped(ctx, answer, "stopped");
3545
+ return;
3546
+ }
3547
+ const previous = ctx.state.gate.held;
3548
+ if (ctx.config.holdMs <= 0 && previous !== void 0) return;
3549
+ if (previous !== void 0) dropped(ctx, previous.answer, "replaced");
3518
3550
  const { frame, elapsed } = ctx.deps.time.snapshot();
3519
3551
  const heldFor = frame === ctx.state.gate.aged ? frame + 1 : frame;
3520
3552
  ctx.state.gate.held = {
@@ -3534,8 +3566,14 @@ function offerHeld(ctx) {
3534
3566
  const held = ctx.state.gate.held;
3535
3567
  if (held === void 0) return;
3536
3568
  ctx.state.gate.held = void 0;
3537
- if (ctx.state.fx.mode === "fast") return;
3538
- if (!accepts(ctx.state.gate, held.answer)) return;
3569
+ if (ctx.state.fx.mode === "fast") {
3570
+ dropped(ctx, held.answer, "fast");
3571
+ return;
3572
+ }
3573
+ if (!accepts(ctx.state.gate, held.answer)) {
3574
+ dropped(ctx, held.answer, "refusedNext");
3575
+ return;
3576
+ }
3539
3577
  deliver$1(ctx.state.gate, held.answer);
3540
3578
  }
3541
3579
  /**
@@ -3595,9 +3633,12 @@ function createGateApi(ctx) {
3595
3633
  if (held.frame === frame) return;
3596
3634
  if (ctx.config.holdMs > 0 && elapsed - held.at <= ctx.config.holdMs) return;
3597
3635
  ctx.state.gate.held = void 0;
3636
+ dropped(ctx, held.answer, "expired");
3598
3637
  },
3599
3638
  dropHeld: () => {
3639
+ const held = ctx.state.gate.held;
3600
3640
  ctx.state.gate.held = void 0;
3641
+ if (held !== void 0) dropped(ctx, held.answer, "jumped");
3601
3642
  }
3602
3643
  };
3603
3644
  }
@@ -49590,7 +49631,7 @@ function bake(ectx, id) {
49590
49631
  }
49591
49632
  textures.push(texture);
49592
49633
  }
49593
- const baked = bakeEmitter(definition, isDev() ? firstSource(ectx, id, keys, textures) : textures);
49634
+ const baked = bakeEmitter(definition, isDev$1() ? firstSource(ectx, id, keys, textures) : textures);
49594
49635
  state.baked.set(id, baked);
49595
49636
  return baked;
49596
49637
  }
@@ -51345,6 +51386,183 @@ const i18nPlugin = /*#__PURE__*/ createPlugin$1("i18n", {
51345
51386
  onStart: startI18n
51346
51387
  });
51347
51388
  //#endregion
51389
+ //#region src/plugins/input/components.ts
51390
+ const scrollableDefaults = {
51391
+ axis: "y",
51392
+ moving: false
51393
+ };
51394
+ /**
51395
+ * Fresh defaults for a component that names an intent. A function, so each component type gets
51396
+ * its own payload object instead of sharing one.
51397
+ *
51398
+ * @returns An empty intent and an empty payload.
51399
+ * @example
51400
+ * ```ts
51401
+ * intentDefaults(); // { intent: "", payload: {} }
51402
+ * ```
51403
+ */
51404
+ function intentDefaults() {
51405
+ return {
51406
+ intent: "",
51407
+ payload: {}
51408
+ };
51409
+ }
51410
+ /**
51411
+ * Fresh defaults for the one component that carries a payload without an intent.
51412
+ *
51413
+ * @returns An empty payload and nothing carried along.
51414
+ * @example
51415
+ * ```ts
51416
+ * carryDefaults(); // { payload: {}, carry: [] }
51417
+ * ```
51418
+ */
51419
+ function carryDefaults() {
51420
+ return {
51421
+ payload: {},
51422
+ carry: []
51423
+ };
51424
+ }
51425
+ const pointerDefaults = {
51426
+ x: 0,
51427
+ y: 0,
51428
+ down: false,
51429
+ justPressed: false,
51430
+ justReleased: false,
51431
+ id: -1
51432
+ };
51433
+ /**
51434
+ * A tap on this view answers `{ intent, payload }`.
51435
+ */
51436
+ const Tappable = /*#__PURE__*/ component("Tappable", intentDefaults());
51437
+ /**
51438
+ * A long press on this view answers `{ intent, payload }`.
51439
+ */
51440
+ const Pressable = /*#__PURE__*/ component("Pressable", intentDefaults());
51441
+ /**
51442
+ * This view can be carried by the finger. It names no intent; the drop target does. The views
51443
+ * whose keys `carry` lists hang under it from the grab to the release and fly home with it. With
51444
+ * an `aim`, the hover and the drop are looked up under that point of the view in the hand.
51445
+ */
51446
+ const Draggable = /*#__PURE__*/ component("Draggable", carryDefaults());
51447
+ /**
51448
+ * A drop on this view answers THIS intent, with the carried payload merged under it.
51449
+ */
51450
+ const DropTarget = /*#__PURE__*/ component("DropTarget", intentDefaults());
51451
+ /**
51452
+ * A swipe on this view answers `{ intent, payload: { ...payload, direction } }`.
51453
+ */
51454
+ const Swipeable = /*#__PURE__*/ component("Swipeable", intentDefaults());
51455
+ /**
51456
+ * A finger drawn through views that carry this answers once, on the release:
51457
+ * `{ intent, payload: { path } }`, the payloads of the cells in the order the finger went through
51458
+ * them. Going back to the cell before the last takes the last one off. It wins over every other
51459
+ * gesture component on the same view.
51460
+ */
51461
+ const Traceable = /*#__PURE__*/ component("Traceable", intentDefaults());
51462
+ /**
51463
+ * Takes a press without naming a gesture: the hit test accepts a view that carries only this tag,
51464
+ * and a tap on it runs the `onTap` listeners and answers nothing. `ui` tags the buttons that
51465
+ * write local state and name no intent.
51466
+ */
51467
+ const Touchable = /*#__PURE__*/ tag("Touchable");
51468
+ /**
51469
+ * On the carried view, from grab to release.
51470
+ */
51471
+ const Held = /*#__PURE__*/ tag("Held");
51472
+ /**
51473
+ * On the topmost drop target under the finger during a drag. At most one, never the held view.
51474
+ */
51475
+ const Hovered = /*#__PURE__*/ tag("Hovered");
51476
+ /**
51477
+ * On every view of the trace in progress, from the moment the finger reaches it until it backs
51478
+ * off it or the trace ends. A game system draws the line through them.
51479
+ */
51480
+ const Traced = /*#__PURE__*/ tag("Traced");
51481
+ /**
51482
+ * On the pressed view, from pointer down until a tap, a long press, a grab, a swipe or a cancel.
51483
+ */
51484
+ const Pressed = /*#__PURE__*/ tag("Pressed");
51485
+ /**
51486
+ * On the topmost view a press would take, while a mouse or a pen moves over it with no press. At
51487
+ * most one view carries it, and a touch never hovers. A touch sample, a pointer cancel, the pointer
51488
+ * leaving the canvas and a paused world take it away. `ui` reads it as `is.hover`. It is not
51489
+ * `Hovered`, which marks the drop target under a drag.
51490
+ */
51491
+ const PointerOver = /*#__PURE__*/ tag("PointerOver");
51492
+ /**
51493
+ * On every ui scroll container, internal: ui writes it, input reads it, a game never sees it. A
51494
+ * press that leaves the tap slop along `axis` goes from the pressed view to the innermost scroll
51495
+ * of that axis the view hangs in by its `Parent` chain; a finger that lands on a view inside a
51496
+ * scroll that is `moving` stops it and answers nothing.
51497
+ */
51498
+ const Scrollable = /*#__PURE__*/ component("Scrollable", scrollableDefaults);
51499
+ /**
51500
+ * Where the one pointer is, in reference units. Written once per frame by the frame step. `id`
51501
+ * names the pointer it follows, `-1` at rest.
51502
+ */
51503
+ const Pointer = /*#__PURE__*/ resource("Pointer", pointerDefaults);
51504
+ //#endregion
51505
+ //#region src/plugins/input/lost.ts
51506
+ /**
51507
+ * Tells whether the dev log is on: a dev build, `__MOKU_GAME_DEV__` defined true.
51508
+ *
51509
+ * @returns True in a dev build.
51510
+ */
51511
+ function dev() {
51512
+ return typeof __MOKU_GAME_DEV__ !== "undefined" && __MOKU_GAME_DEV__;
51513
+ }
51514
+ /**
51515
+ * Logs a press that wore the press look of a button and will not be a tap. Only a pressed view
51516
+ * that carries `Tappable` (or left the world during the press) is told; a press caught by a
51517
+ * scroll was the scroll's from its start, and a view without a tap has nothing to lose.
51518
+ *
51519
+ * @param ctx - Domain context of the input plugin.
51520
+ * @param reason - Why the press is lost.
51521
+ */
51522
+ function lostPress(ctx, reason) {
51523
+ if (!dev()) return;
51524
+ const { entity, caught, key } = ctx.state;
51525
+ if (entity === void 0 || caught) return;
51526
+ if (reason !== "view-gone" && !ctx.deps.world.ecs.has(entity, Tappable)) return;
51527
+ ctx.log.warn("input: pressed, but the tap was not counted", {
51528
+ view: key ?? entity,
51529
+ reason
51530
+ });
51531
+ }
51532
+ /**
51533
+ * Logs an answer the gate did not take. A closed gate holds it for the next gate, so that is told
51534
+ * at debug level only: `flow` warns `flow:answer-dropped` when no gate takes the held answer. Otherwise the line says what
51535
+ * the gate said: `no-edge`, the resting node does not list the intent; `refused`, a guide's narrow
51536
+ * dropped it and names no `blocked`; `blocked`, it answered the guide's `blocked` in its place.
51537
+ *
51538
+ * @param ctx - Domain context of the input plugin.
51539
+ * @param entity - The view the answer came from.
51540
+ * @param answer - The answer the gate refused.
51541
+ * @param gate - What the gate said.
51542
+ * @param gate.open - Whether the gate was open.
51543
+ * @param gate.allowed - The intents the open gate lists.
51544
+ * @param blocked - Whether the guide's `blocked` was taken in the answer's place.
51545
+ */
51546
+ function lostAnswer(ctx, entity, answer, gate, blocked) {
51547
+ if (!dev()) return;
51548
+ const view = ctx.deps.world.projection.keyOf(entity) ?? entity;
51549
+ if (!gate.open && !blocked) {
51550
+ ctx.log.debug("input: counted, the gate is closed: held for the next gate", {
51551
+ view,
51552
+ intent: answer.intent
51553
+ });
51554
+ return;
51555
+ }
51556
+ let said = "refused";
51557
+ if (blocked) said = "blocked";
51558
+ else if (!gate.allowed.includes(answer.intent)) said = "no-edge";
51559
+ ctx.log.warn("input: counted, but the gate took nothing", {
51560
+ view,
51561
+ intent: answer.intent,
51562
+ gate: said
51563
+ });
51564
+ }
51565
+ //#endregion
51348
51566
  //#region src/plugins/input/answers.ts
51349
51567
  /**
51350
51568
  * Reads a component payload as a record. A payload that is not a plain JSON object is dropped:
@@ -51483,7 +51701,8 @@ function notifyTap(ctx, entity) {
51483
51701
  * A press the narrow of a guide drops — another intent, or the allowed intent with another
51484
51702
  * payload (a drop on the wrong cell) — answers the guide's `blocked` instead, once, when the gate
51485
51703
  * is open and the guide names one. A closed gate holds the press as it is and converts nothing.
51486
- * The gate's state is read only for a refused answer, never for an accepted one.
51704
+ * The gate's state is read only for a refused answer, never for an accepted one. A dev build logs
51705
+ * the refusal with the view and what the gate said (F122).
51487
51706
  *
51488
51707
  * @param ctx - Domain context of the input plugin.
51489
51708
  * @param entity - The view the answer came from, for the warning.
@@ -51494,8 +51713,10 @@ function submit(ctx, entity, answer) {
51494
51713
  if (answer.intent === "") ctx.log.warn("input: empty intent", { view: ctx.deps.world.projection.keyOf(entity) });
51495
51714
  const gate = ctx.deps.flow.gate;
51496
51715
  if (gate.answer(answer)) return true;
51497
- const { open, blocked } = gate.state();
51498
- return open && blocked !== void 0 && gate.answer(blocked);
51716
+ const read = gate.state();
51717
+ const taken = read.open && read.blocked !== void 0 && gate.answer(read.blocked);
51718
+ lostAnswer(ctx, entity, answer, read, taken);
51719
+ return taken;
51499
51720
  }
51500
51721
  /**
51501
51722
  * Answers a press the lock of a guide kept from every view: the gate's `blocked`, the answer the
@@ -51512,122 +51733,6 @@ function submitBlocked(ctx) {
51512
51733
  return ctx.deps.flow.gate.answer(blocked);
51513
51734
  }
51514
51735
  //#endregion
51515
- //#region src/plugins/input/components.ts
51516
- const scrollableDefaults = {
51517
- axis: "y",
51518
- moving: false
51519
- };
51520
- /**
51521
- * Fresh defaults for a component that names an intent. A function, so each component type gets
51522
- * its own payload object instead of sharing one.
51523
- *
51524
- * @returns An empty intent and an empty payload.
51525
- * @example
51526
- * ```ts
51527
- * intentDefaults(); // { intent: "", payload: {} }
51528
- * ```
51529
- */
51530
- function intentDefaults() {
51531
- return {
51532
- intent: "",
51533
- payload: {}
51534
- };
51535
- }
51536
- /**
51537
- * Fresh defaults for the one component that carries a payload without an intent.
51538
- *
51539
- * @returns An empty payload and nothing carried along.
51540
- * @example
51541
- * ```ts
51542
- * carryDefaults(); // { payload: {}, carry: [] }
51543
- * ```
51544
- */
51545
- function carryDefaults() {
51546
- return {
51547
- payload: {},
51548
- carry: []
51549
- };
51550
- }
51551
- const pointerDefaults = {
51552
- x: 0,
51553
- y: 0,
51554
- down: false,
51555
- justPressed: false,
51556
- justReleased: false,
51557
- id: -1
51558
- };
51559
- /**
51560
- * A tap on this view answers `{ intent, payload }`.
51561
- */
51562
- const Tappable = /*#__PURE__*/ component("Tappable", intentDefaults());
51563
- /**
51564
- * A long press on this view answers `{ intent, payload }`.
51565
- */
51566
- const Pressable = /*#__PURE__*/ component("Pressable", intentDefaults());
51567
- /**
51568
- * This view can be carried by the finger. It names no intent; the drop target does. The views
51569
- * whose keys `carry` lists hang under it from the grab to the release and fly home with it. With
51570
- * an `aim`, the hover and the drop are looked up under that point of the view in the hand.
51571
- */
51572
- const Draggable = /*#__PURE__*/ component("Draggable", carryDefaults());
51573
- /**
51574
- * A drop on this view answers THIS intent, with the carried payload merged under it.
51575
- */
51576
- const DropTarget = /*#__PURE__*/ component("DropTarget", intentDefaults());
51577
- /**
51578
- * A swipe on this view answers `{ intent, payload: { ...payload, direction } }`.
51579
- */
51580
- const Swipeable = /*#__PURE__*/ component("Swipeable", intentDefaults());
51581
- /**
51582
- * A finger drawn through views that carry this answers once, on the release:
51583
- * `{ intent, payload: { path } }`, the payloads of the cells in the order the finger went through
51584
- * them. Going back to the cell before the last takes the last one off. It wins over every other
51585
- * gesture component on the same view.
51586
- */
51587
- const Traceable = /*#__PURE__*/ component("Traceable", intentDefaults());
51588
- /**
51589
- * Takes a press without naming a gesture: the hit test accepts a view that carries only this tag,
51590
- * and a tap on it runs the `onTap` listeners and answers nothing. `ui` tags the buttons that
51591
- * write local state and name no intent.
51592
- */
51593
- const Touchable = /*#__PURE__*/ tag("Touchable");
51594
- /**
51595
- * On the carried view, from grab to release.
51596
- */
51597
- const Held = /*#__PURE__*/ tag("Held");
51598
- /**
51599
- * On the topmost drop target under the finger during a drag. At most one, never the held view.
51600
- */
51601
- const Hovered = /*#__PURE__*/ tag("Hovered");
51602
- /**
51603
- * On every view of the trace in progress, from the moment the finger reaches it until it backs
51604
- * off it or the trace ends. A game system draws the line through them.
51605
- */
51606
- const Traced = /*#__PURE__*/ tag("Traced");
51607
- /**
51608
- * On the pressed view, from pointer down until a tap, a long press, a grab, a swipe or a cancel.
51609
- */
51610
- const Pressed = /*#__PURE__*/ tag("Pressed");
51611
- /**
51612
- * On the topmost view a press would take, while a mouse or a pen moves over it with no press. At
51613
- * most one view carries it, and a touch never hovers. A touch sample, a pointer cancel, the pointer
51614
- * leaving the canvas and a paused world take it away. `ui` reads it as `is.hover`. It is not
51615
- * `Hovered`, which marks the drop target under a drag.
51616
- */
51617
- const PointerOver = /*#__PURE__*/ tag("PointerOver");
51618
- /**
51619
- * On every ui scroll container, internal: ui writes it, input reads it, a game never sees it. A
51620
- * press that leaves the tap slop along `axis` goes from the pressed view to the innermost scroll
51621
- * of that axis the view hangs in by its `Parent` chain; a finger that lands on a view inside a
51622
- * scroll that is `moving` stops it and answers nothing.
51623
- */
51624
- const Scrollable = /*#__PURE__*/ component("Scrollable", scrollableDefaults);
51625
- /**
51626
- * Where the one pointer is, in reference units. Written once per frame by the frame step. `id`
51627
- * names the pointer it follows, `-1` at rest.
51628
- */
51629
- const Pointer = /*#__PURE__*/ resource("Pointer", pointerDefaults);
51630
- //#endregion
51631
51736
  //#region src/plugins/input/hit.ts
51632
51737
  /**
51633
51738
  * @file input plugin — who is under the finger. Every lookup goes through `renderer.sync.hitTest`,
@@ -52933,6 +53038,7 @@ function handOff(ctx, point) {
52933
53038
  if (ecs.has(entity, Draggable) || ecs.has(entity, Swipeable)) return;
52934
53039
  const scroll = scrollOnAxisOf(ctx, entity, axisOf$1(start, point));
52935
53040
  if (scroll === void 0 || scroll === entity) return;
53041
+ lostPress(ctx, "scroll");
52936
53042
  ecs.untag(entity, Pressed);
52937
53043
  ctx.state.caught = true;
52938
53044
  press(ctx, scroll);
@@ -52981,9 +53087,13 @@ function answerRelease(ctx, entity, point) {
52981
53087
  submit(ctx, entity, tapAnswer(tappable));
52982
53088
  return;
52983
53089
  }
53090
+ if (!ecs.has(entity, Transform)) lostPress(ctx, "view-gone");
52984
53091
  }
52985
53092
  const swipeable = ecs.get(entity, Swipeable);
52986
- if (swipeable === void 0 || travelled < ctx.config.swipeMinPx || ctx.state.pressedMs > ctx.config.swipeMaxMs) return;
53093
+ if (swipeable === void 0 || travelled < ctx.config.swipeMinPx || ctx.state.pressedMs > ctx.config.swipeMaxMs) {
53094
+ if (travelled > ctx.config.tapSlopPx) lostPress(ctx, "moved-off");
53095
+ return;
53096
+ }
52987
53097
  submit(ctx, entity, swipeAnswer(swipeable, direction(ctx.state.start, point)));
52988
53098
  }
52989
53099
  /**
@@ -53010,8 +53120,10 @@ function onUp(ctx, pointer, point) {
53010
53120
  *
53011
53121
  * @param ctx - Domain context of the input plugin.
53012
53122
  * @param pointer - The `Pointer` resource of this frame.
53123
+ * @param reason - What took it away, for the dev log of a lost tap.
53013
53124
  */
53014
- function onCancel(ctx, pointer) {
53125
+ function onCancel(ctx, pointer, reason) {
53126
+ lostPress(ctx, reason);
53015
53127
  pointer.down = false;
53016
53128
  letGestureGo(ctx);
53017
53129
  toIdle(ctx);
@@ -53067,6 +53179,7 @@ function handleSample(ctx, pointer, sample) {
53067
53179
  if (sample.kind === "leave") return void 0;
53068
53180
  if (pointerId !== void 0 && pointerId !== sample.pointerId) {
53069
53181
  if (sample.kind !== "down" || !rests(ctx)) return void 0;
53182
+ lostPress(ctx, "other-finger");
53070
53183
  toIdle(ctx);
53071
53184
  }
53072
53185
  const point = ctx.deps.renderer.viewport.toReference(sample.clientX, sample.clientY);
@@ -53088,7 +53201,7 @@ function handleSample(ctx, pointer, sample) {
53088
53201
  case "up":
53089
53202
  onUp(ctx, pointer, point);
53090
53203
  break;
53091
- default: onCancel(ctx, pointer);
53204
+ default: onCancel(ctx, pointer, sample.kind === "lost" ? "capture-lost" : "cancelled");
53092
53205
  }
53093
53206
  }
53094
53207
  /**
@@ -53191,9 +53304,11 @@ function syncCanvas(ctx) {
53191
53304
  * at once.
53192
53305
  *
53193
53306
  * @param ctx - Domain context of the input plugin.
53307
+ * @param reason - The mode that stopped the world, for the dev log of a lost tap.
53194
53308
  */
53195
- function pauseGestures(ctx) {
53309
+ function pauseGestures(ctx, reason) {
53196
53310
  const pointer = ctx.deps.world.ecs.resource(Pointer);
53311
+ lostPress(ctx, reason);
53197
53312
  ctx.state.samples = [];
53198
53313
  ctx.state.resolvedEarly = false;
53199
53314
  clearPointerOver(ctx);
@@ -53251,11 +53366,11 @@ function stepGestures(ctx, time) {
53251
53366
  if (mode === "fast") {
53252
53367
  ctx.state.samples = [];
53253
53368
  ctx.state.resolvedEarly = false;
53254
- if (ctx.state.phase !== "idle") pauseGestures(ctx);
53369
+ if (ctx.state.phase !== "idle") pauseGestures(ctx, "fast");
53255
53370
  return;
53256
53371
  }
53257
53372
  if (mode === "paused") {
53258
- pauseGestures(ctx);
53373
+ pauseGestures(ctx, "paused");
53259
53374
  syncCursor(ctx);
53260
53375
  return;
53261
53376
  }
@@ -54379,7 +54494,7 @@ function playHaptic(ctx, provider, kind) {
54379
54494
  safely(ctx.log, "haptic", () => provider.haptic(kind));
54380
54495
  return;
54381
54496
  }
54382
- if (!isDev() || ctx.state.warned.has(kind)) return;
54497
+ if (!isDev$1() || ctx.state.warned.has(kind)) return;
54383
54498
  ctx.state.warned.add(kind);
54384
54499
  ctx.log.warn("platform: unknown haptic kind", { kind });
54385
54500
  }
package/dist/testing.mjs CHANGED
@@ -1,4 +1,4 @@
1
- import { an as type, en as refuseStart, m as flattenFeatures, nn as exit, t as createApp } from "./src-CSmeCq6N.mjs";
1
+ import { an as type, en as refuseStart, m as flattenFeatures, nn as exit, t as createApp } from "./src-C6oUOPds.mjs";
2
2
  import { n as saveOf, t as memory } from "./memory-CWlqhS7l.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";
@@ -3,7 +3,7 @@ import { P as AnimApi, r as UiApi } from "./types-feXn09s4.mjs";
3
3
  import { N as InputApi } from "./types-CafT9oPU.mjs";
4
4
  import { r as Repro } from "./headless-BdfPq6Rk.mjs";
5
5
  import { a as InputOf, r as ControlApp } from "./types-C9LTGx_J.mjs";
6
- import { t as commands } from "./commands-Bm8eGFaH.mjs";
6
+ import { t as commands } from "./commands-BxXC3hYN.mjs";
7
7
 
8
8
  //#region src/visual/types.d.ts
9
9
  /** The base commands of the `/control` door, keyed by their short names. */
package/dist/visual.d.mts CHANGED
@@ -1,2 +1,2 @@
1
- import { a as VisualApp, c as VisualRenderer, d as VisualStart, f as VisualStep, h as VisualTolerance, i as CheckpointResult, l as VisualReport, m as VisualTestResult, n as runVisualTests, o as VisualOptions, p as VisualTest, r as defineVisualTest, s as VisualPage, t as parseVisualArgv, u as VisualSetup } from "./visual-DGI5ygP0.mjs";
1
+ import { a as VisualApp, c as VisualRenderer, d as VisualStart, f as VisualStep, h as VisualTolerance, i as CheckpointResult, l as VisualReport, m as VisualTestResult, n as runVisualTests, o as VisualOptions, p as VisualTest, r as defineVisualTest, s as VisualPage, t as parseVisualArgv, u as VisualSetup } from "./visual-DYZgXTAp.mjs";
2
2
  export { type CheckpointResult, type VisualApp, type VisualOptions, type VisualPage, type VisualRenderer, type VisualReport, type VisualSetup, type VisualStart, type VisualStep, type VisualTest, type VisualTestResult, type VisualTolerance, defineVisualTest, parseVisualArgv, runVisualTests };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@moku-labs/game",
3
- "version": "0.15.66",
3
+ "version": "0.15.67",
4
4
  "description": "2D puzzle game engine on TypeScript and PixiJS, built on @moku-labs/core.",
5
5
  "type": "module",
6
6
  "sideEffects": [