@moku-labs/game 0.15.146 → 0.15.147

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 { Gt as audioPlugin, Pt as effectsPlugin, Q as platformPlugin, i as screen, t as createApp, w as flattenFeatures } from "./src-DRt212D0.mjs";
1
+ import { Gt as audioPlugin, Pt as effectsPlugin, Q as platformPlugin, i as screen, t as createApp, w as flattenFeatures } from "./src-lQGIRz7v.mjs";
2
2
  import { t as memory } from "./memory-DeD9wis6.mjs";
3
3
  import { n as fakeClock, r as isFakeClock } from "./fake-hnJcJeYf.mjs";
4
4
  //#region src/app/define.ts
package/dist/index.mjs CHANGED
@@ -1,4 +1,4 @@
1
- import { $ as HAPTIC_KINDS, $t as PASS_KINDS, A as types_exports$17, At as Traced, B as types_exports$7, Bt as Glow, C as defineFeature, Ct as PointerOver, D as defineBundles, Dt as Tappable, E as music, Et as Swipeable, F as types_exports$12, Ft as Emitter, G as types_exports$2, Gt as audioPlugin, H as types_exports$5, Ht as Outline, I as types_exports$11, It as Alpha, J as uiPlugin, Jt as animPlugin, K as types_exports$1, Kt as scenesPlugin, L as types_exports$10, Lt as Blur, M as types_exports$15, Mt as messageArgument, N as types_exports$14, Nt as messageDuration, O as load, Ot as Touchable, P as types_exports$13, Pt as effectsPlugin, Q as platformPlugin, Qt as rendererPlugin, R as types_exports$9, Rt as ColorMatrix, S as tr, St as Pointer, T as defineEmitter, Tt as Pressed, U as types_exports$4, Ut as defineFilter, V as types_exports$6, Vt as Noise, W as types_exports$3, Wt as debugPlugin, X as defineMotion, Xt as Animation, Y as resolve, Yt as AnimPlayer, Z as textPlugin, Zt as Frames, _ as guide, _n as modelPlugin, _t as inputPlugin, a as Vignette, an as PROBLEM_RULES, at as parallel, b as projection, bn as lifecyclePlugin, bt as Held, c as RevealLine, cn as DEMAND_REASONS, ct as set, d as Flash, dt as spawned, en as frameAt, et as defineAnimation, f as Dissolve, fn as contribution, ft as stagger, g as defineEffect, gn as type, gt as wait, h as cubicBezier, hn as to, ht as use, i as screen, in as PERF_LOG_VERSION, it as mark, j as types_exports$16, jt as i18nPlugin, k as ready, kt as Traceable, l as Grade, ln as worldPlugin, lt as sfx, m as Aura, mn as slot, mt as tween, n as createPlugin, nn as PERF_CAUSES, nt as frames, o as Shine, on as SHADER_WHATS, ot as play, p as Bloom, pn as exit, pt as stopSfx, q as types_exports, qt as assetsPlugin, r as defineGame, rn as PERF_GAP_BUCKETS, rt as haptic, s as RevealRound, sn as CANVAS_RESTARTS, st as sequence, t as createApp, tn as MONITOR_SECTIONS, tt as external, u as Fold, un as flowPlugin, ut as spawn, v as hint, vn as SaveUnreadableError, vt as Draggable, w as flattenFeatures, wt as Pressable, x as defineScene, xn as timePlugin, xt as Hovered, y as schedule, yn as clockPlugin, yt as DropTarget, z as types_exports$8, zt as Displacement } from "./src-DRt212D0.mjs";
1
+ import { $ as HAPTIC_KINDS, $t as PASS_KINDS, A as types_exports$17, At as Traced, B as types_exports$7, Bt as Glow, C as defineFeature, Ct as PointerOver, D as defineBundles, Dt as Tappable, E as music, Et as Swipeable, F as types_exports$12, Ft as Emitter, G as types_exports$2, Gt as audioPlugin, H as types_exports$5, Ht as Outline, I as types_exports$11, It as Alpha, J as uiPlugin, Jt as animPlugin, K as types_exports$1, Kt as scenesPlugin, L as types_exports$10, Lt as Blur, M as types_exports$15, Mt as messageArgument, N as types_exports$14, Nt as messageDuration, O as load, Ot as Touchable, P as types_exports$13, Pt as effectsPlugin, Q as platformPlugin, Qt as rendererPlugin, R as types_exports$9, Rt as ColorMatrix, S as tr, St as Pointer, T as defineEmitter, Tt as Pressed, U as types_exports$4, Ut as defineFilter, V as types_exports$6, Vt as Noise, W as types_exports$3, Wt as debugPlugin, X as defineMotion, Xt as Animation, Y as resolve, Yt as AnimPlayer, Z as textPlugin, Zt as Frames, _ as guide, _n as modelPlugin, _t as inputPlugin, a as Vignette, an as PROBLEM_RULES, at as parallel, b as projection, bn as lifecyclePlugin, bt as Held, c as RevealLine, cn as DEMAND_REASONS, ct as set, d as Flash, dt as spawned, en as frameAt, et as defineAnimation, f as Dissolve, fn as contribution, ft as stagger, g as defineEffect, gn as type, gt as wait, h as cubicBezier, hn as to, ht as use, i as screen, in as PERF_LOG_VERSION, it as mark, j as types_exports$16, jt as i18nPlugin, k as ready, kt as Traceable, l as Grade, ln as worldPlugin, lt as sfx, m as Aura, mn as slot, mt as tween, n as createPlugin, nn as PERF_CAUSES, nt as frames, o as Shine, on as SHADER_WHATS, ot as play, p as Bloom, pn as exit, pt as stopSfx, q as types_exports, qt as assetsPlugin, r as defineGame, rn as PERF_GAP_BUCKETS, rt as haptic, s as RevealRound, sn as CANVAS_RESTARTS, st as sequence, t as createApp, tn as MONITOR_SECTIONS, tt as external, u as Fold, un as flowPlugin, ut as spawn, v as hint, vn as SaveUnreadableError, vt as Draggable, w as flattenFeatures, wt as Pressable, x as defineScene, xn as timePlugin, xt as Hovered, y as schedule, yn as clockPlugin, yt as DropTarget, z as types_exports$8, zt as Displacement } from "./src-lQGIRz7v.mjs";
2
2
  import { $ as Overlay, D as defineStyle, E as defineTokens, L as defineTextFormats, M as Countdown, N as Text, P as bind, Q as NineSlice, R as defineTextStyles, X as Display, Z as HudPart, _ as DebugTrigger, ct as Exiting, dt as Order, ft as Tree, gt as system, h as Box, ht as resource, it as Transform, lt as Layer, mt as mut, nt as Shape, pt as component, rt as Sprite, st as sprite, tt as Parent, ut as Now, vt as tag, w as popup, x as ScrollState, y as LocalWrite, z as label } from "./visual-x0TPowBE.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, Aura, Bloom, Blur, Box, CANVAS_RESTARTS, types_exports$3 as Clock, ColorMatrix, Countdown, DEMAND_REASONS, types_exports$4 as Debug, DebugTrigger, Displacement, Display, Dissolve, Draggable, DropTarget, types_exports$5 as Effects, Emitter, Exiting, Flash, types_exports$6 as Flow, Fold, Frames, Glow, Grade, 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, RevealLine, RevealRound, SHADER_WHATS, SaveUnreadableError, types_exports$13 as Scenes, ScrollState, Shape, Shine, Sprite, Swipeable, Tappable, Text, types_exports$14 as TextTypes, types_exports$15 as Time, Touchable, Traceable, Traced, Transform, Tree, types_exports$16 as Ui, Vignette, 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, defineTextFormats, 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 };
@@ -3166,13 +3166,71 @@ async function effectValue(state, log, descriptor, signal) {
3166
3166
  mode: state.mode
3167
3167
  });
3168
3168
  } catch (error) {
3169
- if (descriptor.cosmetic !== true) throw error;
3170
- if (signal.aborted) return;
3171
- log.warn("flow:fx-cosmetic-failed", {
3172
- kind: descriptor.kind,
3173
- message: asError$5(error).message
3169
+ return failedValue(log, descriptor, signal, error);
3170
+ }
3171
+ }
3172
+ /**
3173
+ * What an awaited effect whose handler failed resolves with: a `cosmetic` descriptor swallows the failure after one
3174
+ * warn entry `flow:fx-cosmetic-failed`, or silently after the abort of its signal; any other failure is thrown on.
3175
+ *
3176
+ * @param log - The engine log.
3177
+ * @param descriptor - The awaited descriptor.
3178
+ * @param signal - The signal the handler was called with.
3179
+ * @param error - What the handler threw or rejected with.
3180
+ * @returns `undefined` for a cosmetic descriptor.
3181
+ * @throws {unknown} The failure itself, for a descriptor that is not cosmetic.
3182
+ */
3183
+ function failedValue(log, descriptor, signal, error) {
3184
+ if (descriptor.cosmetic !== true) throw error;
3185
+ if (!signal.aborted) log.warn("flow:fx-cosmetic-failed", {
3186
+ kind: descriptor.kind,
3187
+ message: asError$5(error).message
3188
+ });
3189
+ }
3190
+ /**
3191
+ * Tells whether a handler answered with a promise or another thenable, that is, not synchronously.
3192
+ *
3193
+ * @param result - What the handler returned.
3194
+ * @returns True for a thenable.
3195
+ * @example
3196
+ * ```ts
3197
+ * isThenable(Promise.resolve(1)); // true
3198
+ * isThenable(true); // false
3199
+ * ```
3200
+ */
3201
+ function isThenable(result) {
3202
+ if (typeof result !== "object" && typeof result !== "function") return false;
3203
+ if (result === null) return false;
3204
+ return typeof result.then === "function";
3205
+ }
3206
+ /**
3207
+ * Runs the handler of an awaited effect while the frame loop runs. A handler that answers synchronously (a value, a
3208
+ * throw, or no handler at all) goes on at once, in the frame it was asked in, so "ask `ready`, then commit" is drawn
3209
+ * in the next frame (F203). A promise goes on in the `signals` phase after it settled. So does a synchronous answer
3210
+ * while an effect started earlier is still queued: effects that end in one frame always resume in start order.
3211
+ *
3212
+ * @param state - fx module state.
3213
+ * @param log - The engine log.
3214
+ * @param descriptor - The awaited descriptor.
3215
+ * @param signal - The signal the handler is called with.
3216
+ * @returns What the handler answered, at once or in the `signals` phase.
3217
+ */
3218
+ function runLive(state, log, descriptor, signal) {
3219
+ const entry = handlerFor(state, descriptor.kind);
3220
+ let result;
3221
+ let sync = true;
3222
+ if (entry !== void 0) try {
3223
+ result = entry.run(descriptor, {
3224
+ signal,
3225
+ mode: state.mode
3174
3226
  });
3227
+ sync = !isThenable(result);
3228
+ } catch (error) {
3229
+ result = Promise.reject(error);
3175
3230
  }
3231
+ const work = Promise.resolve(result).catch((error) => failedValue(log, descriptor, signal, error));
3232
+ if (sync && state.settled.length === 0) return work;
3233
+ return enqueue$2(state, work);
3176
3234
  }
3177
3235
  /**
3178
3236
  * Tells whether an awaited effect resolves at once, without the wait for the next `signals` phase: the `schedule` of
@@ -3338,9 +3396,8 @@ function createFxApi(ctx, deps) {
3338
3396
  const answers = descriptor.answers;
3339
3397
  if (answers !== void 0) return openForAnswers(ctx, deps.gate, descriptor, answers, signal);
3340
3398
  const shown = descriptor.kind === "guide" ? beginGuide(state, signal) : signal;
3341
- const work = effectValue(state, ctx.log, descriptor, shown);
3342
- if (state.mode === "fast" || !ctx.deps.time.isRunning() || resolvesAtOnce(descriptor)) return work;
3343
- return enqueue$2(state, work);
3399
+ if (state.mode === "fast" || !ctx.deps.time.isRunning() || resolvesAtOnce(descriptor)) return effectValue(state, ctx.log, descriptor, shown);
3400
+ return runLive(state, ctx.log, descriptor, shown);
3344
3401
  },
3345
3402
  buffer: (item) => {
3346
3403
  if (state.mode === "fast") return;
@@ -44643,6 +44700,17 @@ async function warmBundle(ctx, bundle) {
44643
44700
  */
44644
44701
  function isThere(state, bundle) {
44645
44702
  if (state.readyFailed.has(bundle)) return true;
44703
+ return isWarm(state, bundle);
44704
+ }
44705
+ /**
44706
+ * Tells whether a bundle is loaded and its textures went to the GPU: the `ready` answer `true` without a failed load.
44707
+ * The `load` effect answers at once for such bundles (F203).
44708
+ *
44709
+ * @param state - State of the assets plugin.
44710
+ * @param bundle - Name of a bundle of the manifest.
44711
+ * @returns True when the bundle is loaded and warmed.
44712
+ */
44713
+ function isWarm(state, bundle) {
44646
44714
  return state.records.get(bundle)?.status === "loaded" && state.warmed.get(bundle)?.done === true;
44647
44715
  }
44648
44716
  /**
@@ -44834,22 +44902,46 @@ function bundlesOfDescriptor(descriptor) {
44834
44902
  /**
44835
44903
  * The handler of the `load` effect. It loads the bundles of the payload one after another with
44836
44904
  * the node's signal and reports what arrived, so a loading node can write its own progress.
44837
- * It writes no game state.
44905
+ * It writes no game state. When every bundle is loaded and on the GPU, as `ready` decides, it answers synchronously, so
44906
+ * the node goes on in the frame it asked in (F203); otherwise it answers with a promise.
44838
44907
  *
44839
44908
  * @param ctx - Domain context of the plugin.
44840
44909
  * @param descriptor - The descriptor the node awaited.
44841
44910
  * @param run - The node's mode and signal.
44911
+ * @returns What was loaded and what it cost, at once or as a promise.
44912
+ */
44913
+ function runLoadEffect(ctx, descriptor, run) {
44914
+ const state = ctx.state;
44915
+ const names = bundlesOfDescriptor(descriptor);
44916
+ if (state.io === void 0) return {
44917
+ loaded: [],
44918
+ mb: 0
44919
+ };
44920
+ if (!names.every((name) => isWarm(state, name))) return loadInOrder(ctx, names, run.signal);
44921
+ let mb = 0;
44922
+ for (const name of names) {
44923
+ const record = state.records.get(name);
44924
+ if (record !== void 0) touch(state, record);
44925
+ mb += state.manifest.bundles[name]?.mb ?? 0;
44926
+ }
44927
+ return {
44928
+ loaded: names,
44929
+ mb: Number(mb.toFixed(3))
44930
+ };
44931
+ }
44932
+ /**
44933
+ * Loads the bundles of a `load` effect one after another with the node's signal.
44934
+ *
44935
+ * @param ctx - Domain context of the plugin.
44936
+ * @param names - The bundle names of the descriptor.
44937
+ * @param signal - The node's signal.
44842
44938
  * @returns What was loaded and what it cost.
44843
44939
  */
44844
- async function runLoadEffect(ctx, descriptor, run) {
44940
+ async function loadInOrder(ctx, names, signal) {
44845
44941
  const loaded = [];
44846
44942
  let mb = 0;
44847
- if (ctx.state.io === void 0) return {
44848
- loaded,
44849
- mb
44850
- };
44851
- for (const name of bundlesOfDescriptor(descriptor)) {
44852
- await loadBundle(ctx, name, run.signal, "request");
44943
+ for (const name of names) {
44944
+ await loadBundle(ctx, name, signal, "request");
44853
44945
  loaded.push(name);
44854
44946
  mb += ctx.state.manifest.bundles[name]?.mb ?? 0;
44855
44947
  }
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-DRt212D0.mjs";
1
+ import { dn as refuseStart, gn as type, pn as exit, t as createApp, w as flattenFeatures } from "./src-lQGIRz7v.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-yi2XmYWC.mjs";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@moku-labs/game",
3
- "version": "0.15.146",
3
+ "version": "0.15.147",
4
4
  "description": "2D puzzle game engine on TypeScript and PixiJS, built on @moku-labs/core.",
5
5
  "type": "module",
6
6
  "sideEffects": [