@moku-labs/game 0.15.90 → 0.15.91
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 +1 -1
- package/dist/cli.mjs +3 -2
- package/dist/index.mjs +1 -1
- package/dist/{src-D2-mFvog.mjs → src-BBJh9Uxh.mjs} +108 -14
- package/dist/testing.mjs +1 -1
- package/llms.txt +2 -2
- package/package.json +1 -1
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-
|
|
1
|
+
import { Ft as audioPlugin, H as platformPlugin, i as screen, m as flattenFeatures, t as createApp, wt as effectsPlugin } from "./src-BBJh9Uxh.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
|
package/dist/cli.mjs
CHANGED
|
@@ -397,7 +397,8 @@ function bootImage(boot, toRoot) {
|
|
|
397
397
|
* icons as links (never `url()` in the style: `Bun.build` does not rewrite it), the `head` tags
|
|
398
398
|
* verbatim after the style, then the body: the boot picture first when the page has one (an
|
|
399
399
|
* `<img id="moku-boot">`, its rule in the style), `<div id="game">` and the module script. A page
|
|
400
|
-
* without a boot is the same HTML as before `page.boot`.
|
|
400
|
+
* without a boot is the same HTML as before `page.boot`. The style turns off text selection, the
|
|
401
|
+
* iOS long-press callout and the tap highlight, except in `input` and `textarea`.
|
|
401
402
|
*
|
|
402
403
|
* @param page - The page of the resolved `config.ts`.
|
|
403
404
|
* @param links - The path to the game folder and the script.
|
|
@@ -412,7 +413,7 @@ function bootImage(boot, toRoot) {
|
|
|
412
413
|
function pageHtml(page, links) {
|
|
413
414
|
const background = safeValue(page.background, `[game] moku-game: page.background "${page.background}" is not a CSS color.`);
|
|
414
415
|
const lang = safeValue(page.lang, `[game] moku-game: page.lang "${page.lang}" is not a language tag.`);
|
|
415
|
-
const style = `html, body { margin: 0; height: 100%; background: ${background}; } #game { width: 100%; height: 100%; touch-action: none; }` + (page.boot === void 0 ? "" : bootRule(page.boot));
|
|
416
|
+
const style = `html, body { margin: 0; height: 100%; background: ${background}; } #game { width: 100%; height: 100%; touch-action: none; } html, body, #game { -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; -webkit-tap-highlight-color: transparent; } input, textarea { -webkit-user-select: text; user-select: text; }` + (page.boot === void 0 ? "" : bootRule(page.boot));
|
|
416
417
|
return [
|
|
417
418
|
"<!doctype html>",
|
|
418
419
|
`<html lang="${lang}">`,
|
package/dist/index.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { $ as sfx, $t as worldPlugin, 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 DEMAND_REASONS, 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 CANVAS_RESTARTS, _ as defineBundles, _t as Tappable, a as cubicBezier, an as to, at as use, b as types_exports$17, bt as Traced, c as hint, cn as SaveUnreadableError, ct as Draggable, d as defineScene, dn as clockPlugin, dt as Hovered, en as flowPlugin, 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 slot, it as tween, j as types_exports$6, jt as Noise, k as types_exports$8, kt as Displacement, l as schedule, ln as lifecyclePlugin, lt as DropTarget, m as flattenFeatures, mt as Pressable, n as createPlugin, nn as contribution, nt as stagger, o as defineEffect, on as type, ot as wait, p as defineFeature, pt as PointerOver, q as haptic, qt as PERF_GAP_BUCKETS, r as defineGame, rn as exit, rt as stopSfx, s as guide, sn as modelPlugin, st as inputPlugin, t as createApp, tt as spawned, u as projection, un as timePlugin, 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-
|
|
1
|
+
import { $ as sfx, $t as worldPlugin, 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 DEMAND_REASONS, 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 CANVAS_RESTARTS, _ as defineBundles, _t as Tappable, a as cubicBezier, an as to, at as use, b as types_exports$17, bt as Traced, c as hint, cn as SaveUnreadableError, ct as Draggable, d as defineScene, dn as clockPlugin, dt as Hovered, en as flowPlugin, 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 slot, it as tween, j as types_exports$6, jt as Noise, k as types_exports$8, kt as Displacement, l as schedule, ln as lifecyclePlugin, lt as DropTarget, m as flattenFeatures, mt as Pressable, n as createPlugin, nn as contribution, nt as stagger, o as defineEffect, on as type, ot as wait, p as defineFeature, pt as PointerOver, q as haptic, qt as PERF_GAP_BUCKETS, r as defineGame, rn as exit, rt as stopSfx, s as guide, sn as modelPlugin, st as inputPlugin, t as createApp, tt as spawned, u as projection, un as timePlugin, 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-BBJh9Uxh.mjs";
|
|
2
2
|
import { $ as Shape, A as Countdown, F as defineTextStyles, I as label, J as HudPart, M as bind, P as defineTextFormats, Q as Parent, S as popup, T as defineStyle, X as Overlay, Y as NineSlice, _ as LocalWrite, at as Exiting, ct as Order, dt as mut, et as Sprite, ft as resource, h as DebugTrigger, ht as tag, it as sprite, j as Text, lt as Tree, ot as Layer, p as Box, pt as system, q as Display, st as Now, tt as Transform, ut as component, w as defineTokens, y as ScrollState } from "./visual-CULAJg6b.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, CANVAS_RESTARTS, 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, 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 };
|
|
@@ -56107,6 +56107,16 @@ function onCancel(ctx, pointer, reason) {
|
|
|
56107
56107
|
toIdle(ctx);
|
|
56108
56108
|
}
|
|
56109
56109
|
/**
|
|
56110
|
+
* The capture was lost. The sample carries no place: WebKit sends it at (0, 0) about 9 ms after
|
|
56111
|
+
* the lift (F143), so it never moves the pointer, and it cancels only a press still followed.
|
|
56112
|
+
*
|
|
56113
|
+
* @param ctx - Domain context of the input plugin.
|
|
56114
|
+
* @param pointer - The `Pointer` resource of this frame.
|
|
56115
|
+
*/
|
|
56116
|
+
function onLost(ctx, pointer) {
|
|
56117
|
+
if (ctx.state.pointerId !== void 0) onCancel(ctx, pointer, "capture-lost");
|
|
56118
|
+
}
|
|
56119
|
+
/**
|
|
56110
56120
|
* Lets a running drag or trace go with no answer: the drag is released with no target, so the
|
|
56111
56121
|
* stack settles home, and the trace drops its `Traced` tags.
|
|
56112
56122
|
*
|
|
@@ -56145,7 +56155,7 @@ function leavesSlop(ctx, point) {
|
|
|
56145
56155
|
* thumb or palm never blocks the finger that plays. A move of an idle mouse or pen hit-tests
|
|
56146
56156
|
* nothing: its point is returned, so the drain moves the hover once per frame. A move of a press
|
|
56147
56157
|
* past the tap slop marks the press as moved for good and, in that one sample, hands it to the
|
|
56148
|
-
* scroll it pans. A lost capture ends
|
|
56158
|
+
* scroll it pans. A lost capture ends a followed gesture like a cancel and never moves the pointer.
|
|
56149
56159
|
*
|
|
56150
56160
|
* @param ctx - Domain context of the input plugin.
|
|
56151
56161
|
* @param pointer - The `Pointer` resource of this frame.
|
|
@@ -56160,6 +56170,10 @@ function handleSample(ctx, pointer, sample) {
|
|
|
56160
56170
|
lostPress(ctx, "other-finger");
|
|
56161
56171
|
toIdle(ctx);
|
|
56162
56172
|
}
|
|
56173
|
+
if (sample.kind === "lost") {
|
|
56174
|
+
onLost(ctx, pointer);
|
|
56175
|
+
return;
|
|
56176
|
+
}
|
|
56163
56177
|
const point = ctx.deps.renderer.viewport.toReference(sample.clientX, sample.clientY);
|
|
56164
56178
|
pointer.x = point.x;
|
|
56165
56179
|
pointer.y = point.y;
|
|
@@ -56179,7 +56193,7 @@ function handleSample(ctx, pointer, sample) {
|
|
|
56179
56193
|
case "up":
|
|
56180
56194
|
onUp(ctx, pointer, point);
|
|
56181
56195
|
break;
|
|
56182
|
-
default: onCancel(ctx, pointer,
|
|
56196
|
+
default: onCancel(ctx, pointer, "cancelled");
|
|
56183
56197
|
}
|
|
56184
56198
|
}
|
|
56185
56199
|
/**
|
|
@@ -57571,6 +57585,14 @@ const BOX_SLACK = 1e-4;
|
|
|
57571
57585
|
/** Splits a run's text into words, runs of spaces and line breaks, separators kept. */
|
|
57572
57586
|
const TOKENS = /(\n| +)/;
|
|
57573
57587
|
/**
|
|
57588
|
+
* Splits a word after a hyphen (`-` or U+2010) that joins two parts, the hyphen kept on the first:
|
|
57589
|
+
* `купли-продажи` may break as `купли-` / `продажи`. No break after a leading hyphen, between two
|
|
57590
|
+
* hyphens or before a digit (`-5`, `10-20`), as a browser keeps them.
|
|
57591
|
+
*/
|
|
57592
|
+
const HYPHEN_BREAKS = /(?<=[^\-\u2010][-\u2010])(?=[^\-\u2010\d])/;
|
|
57593
|
+
/** The soft hyphen: a break the text allows, drawn as `-` only when the line breaks there. */
|
|
57594
|
+
const SOFT_HYPHEN = "";
|
|
57595
|
+
/**
|
|
57574
57596
|
* Tells whether a value is a plain record, so its fields can be read one by one.
|
|
57575
57597
|
*
|
|
57576
57598
|
* @param value - Anything `JSON.parse` returned.
|
|
@@ -57848,7 +57870,7 @@ function layoutFixed(runs, style, tables, options) {
|
|
|
57848
57870
|
width += measureRun(run, style, tables, options);
|
|
57849
57871
|
continue;
|
|
57850
57872
|
}
|
|
57851
|
-
const segments = run.text.split("\n");
|
|
57873
|
+
const segments = run.text.replaceAll(SOFT_HYPHEN, "").split("\n");
|
|
57852
57874
|
for (const [index, segment] of segments.entries()) {
|
|
57853
57875
|
if (index > 0) push();
|
|
57854
57876
|
if (segment.length === 0) continue;
|
|
@@ -57886,6 +57908,7 @@ function pushToken(tokens, token, touches) {
|
|
|
57886
57908
|
if (touches && token.kind === "word" && last?.kind === "word") {
|
|
57887
57909
|
last.runs.push(...token.runs);
|
|
57888
57910
|
last.width += token.width;
|
|
57911
|
+
last.tail = token.tail;
|
|
57889
57912
|
return;
|
|
57890
57913
|
}
|
|
57891
57914
|
tokens.push(token);
|
|
@@ -57908,28 +57931,90 @@ function tokenise(runs, style, tables, options) {
|
|
|
57908
57931
|
pushToken(tokens, {
|
|
57909
57932
|
kind: "word",
|
|
57910
57933
|
runs: [run],
|
|
57911
|
-
width
|
|
57934
|
+
width,
|
|
57935
|
+
tail: 0
|
|
57912
57936
|
}, true);
|
|
57913
57937
|
continue;
|
|
57914
57938
|
}
|
|
57915
57939
|
for (const [index, piece] of run.text.split(TOKENS).entries()) {
|
|
57916
57940
|
if (piece.length === 0) continue;
|
|
57941
|
+
const kind = kindOf(piece);
|
|
57942
|
+
if (kind === "word") {
|
|
57943
|
+
pushWord(tokens, run, piece, index === 0, {
|
|
57944
|
+
style,
|
|
57945
|
+
tables,
|
|
57946
|
+
options
|
|
57947
|
+
});
|
|
57948
|
+
continue;
|
|
57949
|
+
}
|
|
57917
57950
|
const part = {
|
|
57918
57951
|
...run,
|
|
57919
57952
|
text: piece
|
|
57920
57953
|
};
|
|
57921
|
-
const kind = kindOf(piece);
|
|
57922
57954
|
const width = kind === "break" ? 0 : measureRun(part, style, tables, options);
|
|
57923
57955
|
pushToken(tokens, {
|
|
57924
57956
|
kind,
|
|
57925
57957
|
runs: [part],
|
|
57926
|
-
width
|
|
57958
|
+
width,
|
|
57959
|
+
tail: 0
|
|
57927
57960
|
}, index === 0);
|
|
57928
57961
|
}
|
|
57929
57962
|
}
|
|
57930
57963
|
return tokens;
|
|
57931
57964
|
}
|
|
57932
57965
|
/**
|
|
57966
|
+
* Puts one word of a run into the tokens, split at its breaks: after a joining hyphen, and at a
|
|
57967
|
+
* soft hyphen, which is dropped from the glyphs and becomes the `-` of a break there.
|
|
57968
|
+
*
|
|
57969
|
+
* @param tokens - The tokens so far.
|
|
57970
|
+
* @param run - The run the word is part of.
|
|
57971
|
+
* @param word - The word, with no spaces and no line break.
|
|
57972
|
+
* @param touches - True when nothing stands between the word and the token before it.
|
|
57973
|
+
* @param metrics - The style, the tables and the warning.
|
|
57974
|
+
*/
|
|
57975
|
+
function pushWord(tokens, run, word, touches, metrics) {
|
|
57976
|
+
for (const [softIndex, between] of word.split(SOFT_HYPHEN).entries()) {
|
|
57977
|
+
if (softIndex > 0) pushSoft(tokens, {
|
|
57978
|
+
...run,
|
|
57979
|
+
text: "-"
|
|
57980
|
+
}, metrics);
|
|
57981
|
+
for (const [index, piece] of between.split(HYPHEN_BREAKS).entries()) {
|
|
57982
|
+
if (index > 0) pushSoft(tokens, void 0, metrics);
|
|
57983
|
+
if (piece.length === 0) continue;
|
|
57984
|
+
const part = {
|
|
57985
|
+
...run,
|
|
57986
|
+
text: piece
|
|
57987
|
+
};
|
|
57988
|
+
const width = measureRun(part, metrics.style, metrics.tables, metrics.options);
|
|
57989
|
+
pushToken(tokens, {
|
|
57990
|
+
kind: "word",
|
|
57991
|
+
runs: [part],
|
|
57992
|
+
width,
|
|
57993
|
+
tail: 0
|
|
57994
|
+
}, touches && softIndex === 0 && index === 0);
|
|
57995
|
+
}
|
|
57996
|
+
}
|
|
57997
|
+
}
|
|
57998
|
+
/**
|
|
57999
|
+
* Puts a break inside a word into the tokens, and gives the word before it the width of the `-`
|
|
58000
|
+
* the break draws.
|
|
58001
|
+
*
|
|
58002
|
+
* @param tokens - The tokens so far.
|
|
58003
|
+
* @param hyphen - The `-` of a soft hyphen, or `undefined` after a hyphen the word already has.
|
|
58004
|
+
* @param metrics - The style, the tables and the warning.
|
|
58005
|
+
*/
|
|
58006
|
+
function pushSoft(tokens, hyphen, metrics) {
|
|
58007
|
+
const width = hyphen === void 0 ? 0 : measureRun(hyphen, metrics.style, metrics.tables, metrics.options);
|
|
58008
|
+
const last = tokens.at(-1);
|
|
58009
|
+
if (last?.kind === "word") last.tail = width;
|
|
58010
|
+
tokens.push({
|
|
58011
|
+
kind: "soft",
|
|
58012
|
+
runs: hyphen === void 0 ? [] : [hyphen],
|
|
58013
|
+
width,
|
|
58014
|
+
tail: 0
|
|
58015
|
+
});
|
|
58016
|
+
}
|
|
58017
|
+
/**
|
|
57933
58018
|
* Closes the open line and starts a new one.
|
|
57934
58019
|
*
|
|
57935
58020
|
* @param builder - The lines built so far.
|
|
@@ -57987,25 +58072,30 @@ function breakWord(builder, token, wrap, metrics) {
|
|
|
57987
58072
|
}
|
|
57988
58073
|
}
|
|
57989
58074
|
/**
|
|
57990
|
-
* Places one word: on the open line when it still fits there with the spaces before it
|
|
57991
|
-
* next one when it does not, and glyph by glyph when
|
|
58075
|
+
* Places one word: on the open line when it still fits there with the spaces before it and the
|
|
58076
|
+
* hyphen a break after it would draw, on the next one when it does not, and glyph by glyph when
|
|
58077
|
+
* it fits on no line at all. A break inside a word stands before it with no width: the line ends
|
|
58078
|
+
* there with the `-` of a soft hyphen, and the word goes on with nothing between when it fits.
|
|
57992
58079
|
*
|
|
57993
58080
|
* @param builder - The lines built so far.
|
|
57994
58081
|
* @param token - The word to place.
|
|
57995
|
-
* @param pending - The spaces
|
|
58082
|
+
* @param pending - The spaces or the break inside a word that stand before it.
|
|
57996
58083
|
* @param wrap - The wrap width in reference pixels.
|
|
57997
58084
|
* @param metrics - The style, the tables and the warning.
|
|
57998
58085
|
*/
|
|
57999
58086
|
function placeWord(builder, token, pending, wrap, metrics) {
|
|
58000
|
-
const
|
|
58001
|
-
|
|
58002
|
-
|
|
58087
|
+
const space = pending?.kind === "space" ? pending : void 0;
|
|
58088
|
+
const lead = space?.width ?? 0;
|
|
58089
|
+
if (builder.runs.length > 0 && builder.width + lead + token.width + token.tail > wrap) {
|
|
58090
|
+
if (pending?.kind === "soft") add(builder, pending);
|
|
58091
|
+
commit(builder);
|
|
58092
|
+
} else if (space !== void 0) add(builder, space);
|
|
58003
58093
|
if (token.width <= wrap) add(builder, token);
|
|
58004
58094
|
else breakWord(builder, token, wrap, metrics);
|
|
58005
58095
|
}
|
|
58006
58096
|
/**
|
|
58007
|
-
* Lays runs out into lines no wider than the wrap. Words break between them
|
|
58008
|
-
* the wrap breaks between its glyphs.
|
|
58097
|
+
* Lays runs out into lines no wider than the wrap. Words break between them, after a hyphen that
|
|
58098
|
+
* joins two parts and at a soft hyphen; a word wider than the wrap breaks between its glyphs.
|
|
58009
58099
|
*
|
|
58010
58100
|
* @param runs - The runs of the block.
|
|
58011
58101
|
* @param metrics - The style, the tables and the warning.
|
|
@@ -58029,6 +58119,10 @@ function layoutWrapped(runs, metrics, wrap) {
|
|
|
58029
58119
|
if (builder.runs.length > 0) pending = token;
|
|
58030
58120
|
continue;
|
|
58031
58121
|
}
|
|
58122
|
+
if (token.kind === "soft") {
|
|
58123
|
+
if (builder.runs.length > 0 && pending === void 0) pending = token;
|
|
58124
|
+
continue;
|
|
58125
|
+
}
|
|
58032
58126
|
placeWord(builder, token, pending, wrap, metrics);
|
|
58033
58127
|
pending = void 0;
|
|
58034
58128
|
}
|
package/dist/testing.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { m as flattenFeatures, on as type, rn as exit, t as createApp, tn as refuseStart } from "./src-
|
|
1
|
+
import { m as flattenFeatures, on as type, rn as exit, t as createApp, tn as refuseStart } from "./src-BBJh9Uxh.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";
|
package/llms.txt
CHANGED
|
@@ -303,7 +303,7 @@ app.model.store.snapshot().session; // { rolls: 2 }
|
|
|
303
303
|
await run.stop();
|
|
304
304
|
```
|
|
305
305
|
|
|
306
|
-
`config.ts` keys and defaults: `page.title` (required, never empty), `page.lang` (`"en"`), `page.background` (`"#000000"`: the page behind the canvas, the `theme-color` meta and the native window; the canvas clear colour stays `pluginConfigs.renderer.background`), `page.orientation` (`"portrait"`, or `"landscape"`, `"any"`: the native build locks it), `page.icons: { favicon?, appleTouch? }` (files relative to the game, `<link>` tags), `page.head` (raw tags, verbatim), `page.boot: { image, width?, fadeMs? }` (absent by default; an `<img id="moku-boot">` centred over the canvas from the first paint until the first scene drew, then faded over `fadeMs`, `300`, and removed; `image` a file relative to the game, `width` `"40vmin"`), `native: { name, identifier, icon?, targets?, signing?, ios?, dev? }` (absent: no native build; `signing.android: { keystorePath, keystorePasswordEnv, keyPasswordEnv?, keyAlias }`, the path absolute, `~/...` or relative to the game, the passwords by env var name only; `signing.apple: { teamId }
|
|
306
|
+
`config.ts` keys and defaults: `page.title` (required, never empty), `page.lang` (`"en"`), `page.background` (`"#000000"`: the page behind the canvas, the `theme-color` meta and the native window; the canvas clear colour stays `pluginConfigs.renderer.background`), `page.orientation` (`"portrait"`, or `"landscape"`, `"any"`: the native build locks it), `page.icons: { favicon?, appleTouch? }` (files relative to the game, `<link>` tags), `page.head` (raw tags, verbatim), `page.boot: { image, width?, fadeMs? }` (absent by default; an `<img id="moku-boot">` centred over the canvas from the first paint until the first scene drew, then faded over `fadeMs`, `300`, and removed; `image` a file relative to the game, `width` `"40vmin"`), `native: { name, identifier, icon?, targets?, signing?, ios?, dev? }` (absent: no native build; `signing.android: { keystorePath, keystorePasswordEnv, keyPasswordEnv?, keyAlias }`, the path absolute, `~/...` or relative to the game, the passwords by env var name only; `signing.apple: { teamId }`, and an iOS store build signs from the command line with an App Store Connect team key in Tauri's env vars `APPLE_API_ISSUER` (the issuer id), `APPLE_API_KEY` (the key id) and `APPLE_API_KEY_PATH` (the `.p8` file, kept outside the repo): an Xcode account sign-in is not seen by `xcodebuild` on the command line, which fails with "No Accounts" and no provisioning profiles; `ios: { minimumVersion?, infoPlist?, privacyManifest? }`, the minimum `"26.0"` by default, `infoPlist` of `PlistValue`: strings, booleans, arrays, dictionaries, a number or `null` refused; the manifest relative to the game; `dev: { identifier, name?, icon? }`, the test app of `--store --dev`, the identifier ending in `.dev` and not `native.identifier`, `name` `"<name> DEV"` and `icon` `native.icon` by default), `system` (`[]`; names `lifecycle`, `back`, `haptics`, `keepAwake`, `store`), `save` (`"memory"`, or `"local"`, `"store"`), `assets.layers` (`{}`; `{ shared: "ui" }` becomes `--layer shared=ui`), `debug.overlay` (`"closed"`, or `"pill"`, `"open"`: how the editor's overlay shows when a debug page starts; the page calls `app.debug.overlay.open({ mode })` right after the agents started; only a page with the agent reads it). A refused value throws, for example `[game] config.save is "disk".` or `[game] config.system names "tray", which the game shell does not wire.`
|
|
307
307
|
|
|
308
308
|
```ts
|
|
309
309
|
// config.ts of a game in a native shell
|
|
@@ -598,7 +598,7 @@ A screen is a projection whose `view` returns JSX. The game's `tsconfig.json` se
|
|
|
598
598
|
- `defineComponent(name, { local?, outcomes?, view(props, local) })`. A component with `outcomes` is a popup: `await fx(popup(Component, props))` opens the gate for its outcomes and resolves with `{ intent, payload }` of the pressed button. A button with `local` writes into the nearest component instance; it never reaches the graph.
|
|
599
599
|
- `tr(key, params?)` returns a frozen `Message` `{ key, params }`; no locale is read at the call site. Strings live in `strings/<locale>.json` of any feature or sub-feature, as ICU MessageFormat 1 (`{n, plural, one {# order} other {# orders}}`, `select`, `selectordinal`, `number`, `date`, `time`; no skeletons, no `currency`). `bun run assets:keys` compiles them. The keys of the top-level features and the layers go into `generated/strings.<locale>.ts`, which one feature registers; a sub-feature's keys start with `<name>.` (`ep01.title`) and go into `generated/strings.<name>.<locale>.ts`, which the sub-feature registers lazily, `strings: { en: () => import("@generated/strings.ep01.en"), ru: () => import("@generated/strings.ep01.ru") }`. With `assets` composed those modules load and unload with the bundle named like the sub-feature: every way the bundle comes (a node entry, a scene's `bundles`, `load`, a restore, the `safeNode`) brings its strings, a locale switch brings them in the new locale, and while the bundle is not loaded a key of it gives `⟦key⟧` and `has(key)` is false. A compiled module calls the root helpers `messageArgument(value, intl)` (an element stays an element part, a list goes through `Intl.ListFormat`, a number through `Intl.NumberFormat`, else text) and `messageDuration(ms)` (`95_000` gives `{ minutes: 1, seconds: 35 }`). `app.i18n`: `locale()`, `setLocale(locale)` (async, emits `i18n:locale-changed`), `format(message, locale?)` returns `Part[]`, `plain(message)` returns a string, `has(key)`, `isKey(value)`, `locales()`, `replace(locale, messages)` (dev hot swap of a generated strings file). Config: `locale: "en"`, `fallback: "en"`, `locales: {}`.
|
|
600
600
|
- Keys that come from data: `I18n.TextKey<Strings>` is the keys of the generated `Strings` without parameters (nothing new is generated). A data table types its keys `TextKey` or builds them with the kit's `key("board.hint.red")`; the kit's `tr` never takes a plain `string`. A key read back from a save is checked where the app is (an effect handler, app or page code, loading a save) with one `isKey(value)`: `defineGameApp({ ..., strings: type<Strings>() })` types the game's `app.i18n`, so a true `app.i18n.isKey(value)` narrows the value to `TextKey`; `ctx.require(i18nPlugin).isKey(value)` in a plugin narrows to `string`. `app.i18n.isKey(value)` answers true for a key of the loaded tables of the current locale or the fallback, and for the `<feature>.` prefix of a sub-feature whose strings are not loaded yet; a key that takes parameters answers true too.
|
|
601
|
-
- Text: `Text` component, `label({ text, style, at, anchor? })` for board text in a projection view, `defineTextStyles({ "hud.digits": { font, size, fill, bold?, italic?, stroke?, strokeWidth?, letterSpacing?, align?, wrap? (a width, "none" or "box": wrap at the laid-out width of its ui element), digits?, lineHeight? (the line as a multiple of size above 0, such as 1.28; glyphs sit in the middle of the line; absent: the font's own line) } })` under the feature's `textStyles` key. Tags inside a string: `<b>`, `<i>`, `<color=#rrggbb>`, `<icon=key>`, `\<`, `\n`. Built-in styles `body` and `digits` from config `fonts: { body: "ui.font-body", digits: "ui.font-digits" }`. `app.text.measure(content, style, width?)` gives the same numbers in a browser and in Bun. `app.text.replaceStyles(styles)` is the dev hot swap of a saved `defineTextStyles` value. A game's own number format: `defineTextFormats({ "pill.number": value => ({ content, style }) })` under the feature's `textFormats` key, named by the `bind` of `defineGame` (`GameTypes.textFormats`): `bind(Counter, "value", { format: "pill.number" })`. It takes the whole value, is pure over value and language, is not called while the whole value and the locale stand, and owns `Text.style`; a `Countdown` calls it every frame. `app.text.formatted(name, value)` answers `{ text, style }`, `undefined` for an unknown or built-in name and for a format that threw. A saved module exporting formats reloads the page.
|
|
601
|
+
- Text: `Text` component, `label({ text, style, at, anchor? })` for board text in a projection view, `defineTextStyles({ "hud.digits": { font, size, fill, bold?, italic?, stroke?, strokeWidth?, letterSpacing?, align?, wrap? (a width, "none" or "box": wrap at the laid-out width of its ui element; lines break between words, after a hyphen inside a word and at a soft hyphen U+00AD, drawn as `-` only where the line breaks), digits?, lineHeight? (the line as a multiple of size above 0, such as 1.28; glyphs sit in the middle of the line; absent: the font's own line) } })` under the feature's `textStyles` key. Tags inside a string: `<b>`, `<i>`, `<color=#rrggbb>`, `<icon=key>`, `\<`, `\n`. Built-in styles `body` and `digits` from config `fonts: { body: "ui.font-body", digits: "ui.font-digits" }`. `app.text.measure(content, style, width?)` gives the same numbers in a browser and in Bun. `app.text.replaceStyles(styles)` is the dev hot swap of a saved `defineTextStyles` value. A game's own number format: `defineTextFormats({ "pill.number": value => ({ content, style }) })` under the feature's `textFormats` key, named by the `bind` of `defineGame` (`GameTypes.textFormats`): `bind(Counter, "value", { format: "pill.number" })`. It takes the whole value, is pure over value and language, is not called while the whole value and the locale stand, and owns `Text.style`; a `Countdown` calls it every frame. `app.text.formatted(name, value)` answers `{ text, style }`, `undefined` for an unknown or built-in name and for a format that threw. A saved module exporting formats reloads the page.
|
|
602
602
|
- Animation is data: `defineAnimation(id, { slots: { name: type<Anim.Target>() }, build: (slots, { at }) => Step })`. Steps: `sequence(...)`, `parallel(...)`, `stagger(items, ms, item => Step)`, `tween(target, Component, to, { ms, ease?, delayMs?, additive?, space?, reduced? })`, `set(target, Component, patch)`, `wait(ms)`, `mark(name)`, `frames(target, { keys, fps, loop? })`, `sfx(key, { bus? })`, `haptic(kind)`, `use(animation, slots, tools?)`, `spawn` (a temporary entity, flying coins, that the timeline despawns when it ends; see the anim README). `Frames({ keys, fps, loop, playing })` is a component that walks a sprite through its textures for the entity's whole life. A target is `{ projection, key }` or an entity. A timeline resolves each `{ projection, key }` target once, when it starts: every step writes the view that held the key then, also after a commit removed it and while its exit plays, until it despawns; a view spawned again under the same key is not followed, and a key nothing held at the start is looked up at its step. `reduced: "keep"` (on a `tween` step, `transition` and `loop` of `defineMotion`, `TweenOptions`, `RestOptions`) plays a track as written under reduced motion, a fade for one; the default `"cut"` lands it at once or holds a loop on its first key. A node plays it with `await fx(play(animation, slots))`; in fast mode it finishes at once. `defineMotion({ states, transition?, on: { enter?, exit?, change? }, when? })` builds the enter, exit and change hooks for a projection or the `motion` prop of a tag; `when: "change"` plays enter and exit only for a commit, so an element that comes or goes with its screen stands at rest and leaves without a motion (default `"always"`). Events `anim:mark` `{ animation, mark }` and `anim:finished` `{ animation }`. `app.anim.replace(definition)` is the dev hot swap: the next `play` builds the new tree. A system cannot `require` a plugin, so it plays through the resource `AnimPlayer`: `res(AnimPlayer).play(animation, slots)` returns the same handle as `app.anim.play`, and the registered animation of `animation.id` wins, so a hot swap reaches the system. Play on a change, never every frame; from phase `input` the tree moves in `animate` of the same frame. Before `anim` starts it throws `[game] AnimPlayer is not ready: anim has not started.` Config `maxTracks: 2000`.
|
|
603
603
|
- A `tween` step takes `segments` and `repeat` as `ViewHandle.tween` does: `tween(chest, Transform, { y: 0, scale: 0 }, { ms: 2400, additive: true, repeat: "forever", segments: [{ at: 0.08, ease: "out", to: { y: -14, scale: 0.06 } }, { at: 1, to: { y: 0, scale: 0 } }] })`. Segments walk over `ms` on one clock, `to` is where the last one ends, an additive walk names offsets; a number counts the extra runs. A definition error throws for empty segments, an `at` outside 0..1 or out of order, a last segment before 1, a bad repeat, and a `sequence` step after one that never ends. A forever step ends only by cancel or finish (a finish and a fast world land it on its start pose), does not play under reduced motion `"cut"`, writes nothing while its view is unseen, and lets the clock idle; a system plays it once through `AnimPlayer` and keeps the handle.
|
|
604
604
|
- Audio is opt-in: `plugins: [...screen, audioPlugin]`. `fx(sfx("orders.complete"))` resolves when the sound started. `await fx(music("board.theme"))` cross-fades; `music(null)` fades out; a scene's `music` key switches the track on `scenes:changed`. Buses `master`, `music`, `sfx`. Volumes come from the committed player: config `volumes: player => (player as Player).settings.audio`, applied on every `model:committed`. `app.audio`: `setVolume(bus, value)`, `volume(bus)`, `mute(bus, on)`, `muted(bus)`, `unlocked()`, `journal()` (the last started sounds, empty unless config `journal` is above 0). Config: `buses: { master: 1, music: 0.6, sfx: 1 }`, `musicFadeMs: 600`, `volumes`, `context`, `journal: 0`, `music: "decode" | "stream"` default `"decode"` (gapless buffer; `"stream"` is an `<audio>` element, less memory, a gap at every loop), `session: "ambient" | "playback" | "auto"` default `"ambient"` (iOS only: ambient mixes with other apps and obeys the silent switch). The context is asked to run at start: where the shell lets audio play (a native webview with the gesture requirement off) `unlocked()` is true with no touch; a browser that wants a gesture unlocks on the first `pointerdown` or `touchend`. Without `audio` every `sfx` and `music` effect resolves `undefined` at once, so the same node runs in a game with no sound. Named sounds: `sfx(key, { bus?, id?, fadeMs? })` with an `id` plays through its own gain, and the next sound with the same `id` fades the old one out over `fadeMs`, else config `sfxFadeMs` (default `120`, real milliseconds); `fx.start(stopSfx(id, { fadeMs? }))` and `app.audio.stop(id, { fadeMs? })` fade it out and end it (`fadeMs: 0` cuts it); an `id` nothing plays under changes nothing, and a sound of that `id` still decoding never starts. Without `id` an `sfx` plays to its end as before.
|