@moku-labs/game 0.15.87 → 0.15.88
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/page.d.mts +1 -1
- package/dist/app/page.mjs +1 -1
- package/dist/app/system.d.mts +3 -3
- package/dist/app.d.mts +3 -3
- package/dist/app.mjs +1 -1
- package/dist/assets.d.mts +1 -1
- package/dist/{commands-DxUF13zr.d.mts → commands-C6RMqrY8.d.mts} +5 -5
- package/dist/control.d.mts +4 -4
- package/dist/{define-CMl6NcM4.d.mts → define-DE1XcBwC.d.mts} +2 -2
- package/dist/{headless-DtDdn5gg.d.mts → headless-CtRq6Uij.d.mts} +1 -1
- package/dist/{index-Bn0pFiae.d.mts → index-nK7iVsWx.d.mts} +30 -7
- package/dist/index.d.mts +5 -5
- package/dist/index.mjs +3 -3
- package/dist/inspect.d.mts +6 -6
- package/dist/inspect.mjs +1 -1
- package/dist/jsx-dev-runtime.d.mts +1 -1
- package/dist/jsx-runtime.d.mts +1 -1
- package/dist/{runtime-DOvgFNLH.d.mts → runtime-CmRqaHmz.d.mts} +1 -1
- package/dist/{sources-CyltHb9o.mjs → sources-kL64Svgl.mjs} +1 -1
- package/dist/{src-BFa-zMmW.mjs → src-BTPWdbHH.mjs} +268 -158
- package/dist/testing.d.mts +4 -4
- package/dist/testing.mjs +1 -1
- package/dist/{types-OBpR0u05.d.mts → types-BbLjYfGR.d.mts} +113 -16
- package/dist/{types-OKAnpylW.d.mts → types-BlXL-VC3.d.mts} +4 -4
- package/dist/{types-C5gLBKbm.d.mts → types-CJYudpme.d.mts} +2 -2
- package/dist/{types-BpipkaVe.d.mts → types-ehmvA6yu.d.mts} +2 -2
- package/dist/{types-CbVXXqPs.d.mts → types-w5_A5TPL.d.mts} +35 -4
- package/dist/{visual-B7TxMv1J.mjs → visual-CULAJg6b.mjs} +161 -10
- package/dist/{visual-CMnWgCkh.d.mts → visual-DvhjRhgP.d.mts} +6 -6
- package/dist/visual.d.mts +1 -1
- package/dist/visual.mjs +1 -1
- package/llms.txt +4 -3
- package/package.json +1 -1
|
@@ -2,7 +2,7 @@ import { t as __exportAll } from "./rolldown-runtime-D7D4PA-g.mjs";
|
|
|
2
2
|
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
|
-
import { $ as
|
|
5
|
+
import { $ as Shape, A as Countdown, B as isLeaving, C as uiFor, D as isTextFormat, E as formatBound, G as rootPoseInto, H as parentOf$1, J as HudPart, K as rootPoseOf, L as readStyle, N as builtInStyles, O as unitOf, Q as Parent, R as textFor, U as poseUnder, V as localPoseOf, W as rootPointOf, X as Overlay, Y as NineSlice, Z as OverlayLevel, _ as LocalWrite, a as fieldsLeftAlone, at as Exiting, b as UI_OWNER, c as namesFormat, ct as Order, d as visualOf$1, et as Sprite, f as visualRectOf, ft as resource, g as Escapable, h as DebugTrigger, ht as tag, i as drawnRect, j as Text, k as wholeValue, l as restValueOf, lt as Tree, m as Covered, mt as systemsFor, n as CONTENT$1, nt as arcDefaults, o as fitScaleOf, ot as Layer, p as Box, pt as system, q as Display, r as bindOf, rt as componentsFor, s as livePatch, st as Now, tt as Transform, u as samePose, ut as component, v as Scroll, x as UiCounters, y as ScrollState, z as applyPose } from "./visual-CULAJg6b.mjs";
|
|
6
6
|
import { a as isDev } 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";
|
|
@@ -838,7 +838,7 @@ const BUSY = 4;
|
|
|
838
838
|
/** The thermal rank from which the rule never steps up: `"moderate"` and every hotter status. */
|
|
839
839
|
const HEAT_LIMIT_RANK = 2;
|
|
840
840
|
/** Milliseconds in a second: turns a rate into the period of one frame. */
|
|
841
|
-
const SECOND_MS$
|
|
841
|
+
const SECOND_MS$2 = 1e3;
|
|
842
842
|
/** Every choice `setRate` takes: `"auto"` and the three fixed rates. */
|
|
843
843
|
const RATE_CHOICES = Object.freeze([
|
|
844
844
|
"auto",
|
|
@@ -1432,8 +1432,8 @@ function judgeFrame$1(ctx, g, intervalMs, at) {
|
|
|
1432
1432
|
const { fps } = ctx.state.rate;
|
|
1433
1433
|
const higher = stepAbove(g.ladder, fps);
|
|
1434
1434
|
const missed = intervalMs > missLineMs(fps, ctx.state.rate.display.hz ?? fps);
|
|
1435
|
-
const heavy = higher !== void 0 && g.lastWorkMs > .5 * SECOND_MS$
|
|
1436
|
-
const busy = missed && g.lastWorkMs > SECOND_MS$
|
|
1435
|
+
const heavy = higher !== void 0 && g.lastWorkMs > .5 * SECOND_MS$2 / higher;
|
|
1436
|
+
const busy = missed && g.lastWorkMs > SECOND_MS$2 / fps;
|
|
1437
1437
|
const slot = g.written % 512;
|
|
1438
1438
|
evict$2(g, at);
|
|
1439
1439
|
g.sampleAt[slot] = at;
|
|
@@ -11747,11 +11747,11 @@ function reseedViews(state, name, from, to) {
|
|
|
11747
11747
|
//#endregion
|
|
11748
11748
|
//#region src/plugins/world/projection/warm.ts
|
|
11749
11749
|
/** A second in ms: the frame interval is this over the frame rate. */
|
|
11750
|
-
const SECOND_MS$
|
|
11750
|
+
const SECOND_MS$1 = 1e3;
|
|
11751
11751
|
/** The share of a frame interval a warm window may take: two thirds, the share of a scene build's `"auto"`. */
|
|
11752
11752
|
const WARM_SHARE = 2 / 3;
|
|
11753
11753
|
/** The budget of a frame when the loop answers no usable rate: two thirds of a 60 Hz frame, ≈ 11.1 ms. */
|
|
11754
|
-
const FALLBACK_WARM_MS = SECOND_MS$
|
|
11754
|
+
const FALLBACK_WARM_MS = SECOND_MS$1 / 60 * WARM_SHARE;
|
|
11755
11755
|
/**
|
|
11756
11756
|
* The building budget of one frame for a warm window: two thirds of the frame interval at `fps`, or of a 60 Hz frame
|
|
11757
11757
|
* for a rate that is not a finite number above 0. Pure.
|
|
@@ -11764,7 +11764,7 @@ const FALLBACK_WARM_MS = SECOND_MS$2 / 60 * WARM_SHARE;
|
|
|
11764
11764
|
* ```
|
|
11765
11765
|
*/
|
|
11766
11766
|
function warmBudget(fps) {
|
|
11767
|
-
return Number.isFinite(fps) && fps > 0 ? SECOND_MS$
|
|
11767
|
+
return Number.isFinite(fps) && fps > 0 ? SECOND_MS$1 / fps * WARM_SHARE : FALLBACK_WARM_MS;
|
|
11768
11768
|
}
|
|
11769
11769
|
/**
|
|
11770
11770
|
* Tells whether two items have the same content: the same object, or equal as JSON. Pure.
|
|
@@ -43305,11 +43305,11 @@ function swapIn(ctx, scene, named, build) {
|
|
|
43305
43305
|
* in. An abort of the node discards the build and leaves the world as it stood.
|
|
43306
43306
|
*/
|
|
43307
43307
|
/** A second in ms: the frame interval is this over the frame rate. */
|
|
43308
|
-
const SECOND_MS
|
|
43308
|
+
const SECOND_MS = 1e3;
|
|
43309
43309
|
/** The share of a frame interval `"auto"` gives the building work: two thirds. */
|
|
43310
43310
|
const BUILD_SHARE = 2 / 3;
|
|
43311
43311
|
/** The frame interval when `time` answers no usable frame rate: a 60 Hz frame, ≈ 16.7 ms. */
|
|
43312
|
-
const FALLBACK_FRAME_MS = SECOND_MS
|
|
43312
|
+
const FALLBACK_FRAME_MS = SECOND_MS / 60;
|
|
43313
43313
|
/**
|
|
43314
43314
|
* The frames past the counter at the look's start a floor asks for: `signals` runs before `render`, so a swap in the
|
|
43315
43315
|
* first frame has no `render` of the look behind it, and a swap in the second has one, even when one long frame ate the
|
|
@@ -43352,7 +43352,7 @@ function agentNow(ctx) {
|
|
|
43352
43352
|
*/
|
|
43353
43353
|
function frameMsOf(ctx) {
|
|
43354
43354
|
const { fps } = ctx.deps.time.rate();
|
|
43355
|
-
return isPositiveFinite(fps) ? SECOND_MS
|
|
43355
|
+
return isPositiveFinite(fps) ? SECOND_MS / fps : FALLBACK_FRAME_MS;
|
|
43356
43356
|
}
|
|
43357
43357
|
/**
|
|
43358
43358
|
* The building budget of a frame for a build that starts now: the number a game configured, or
|
|
@@ -57299,91 +57299,6 @@ function layoutRuns(runs, style, tables, options, box = 0) {
|
|
|
57299
57299
|
};
|
|
57300
57300
|
}
|
|
57301
57301
|
//#endregion
|
|
57302
|
-
//#region src/plugins/text/format.ts
|
|
57303
|
-
/** Milliseconds in one second. */
|
|
57304
|
-
const SECOND_MS = 1e3;
|
|
57305
|
-
/** Seconds in one minute. */
|
|
57306
|
-
const SECONDS_PER_MINUTE = 60;
|
|
57307
|
-
/** Seconds in one hour. */
|
|
57308
|
-
const SECONDS_PER_HOUR = 3600;
|
|
57309
|
-
/**
|
|
57310
|
-
* Tells whether a string is one of the four formats, for a bind that slipped past the type.
|
|
57311
|
-
*
|
|
57312
|
-
* @param format - What a bind carries.
|
|
57313
|
-
* @returns True for `"int"`, `"mm:ss"`, `"h:mm:ss"` and `"duration"`.
|
|
57314
|
-
* @example
|
|
57315
|
-
* ```ts
|
|
57316
|
-
* isTextFormat("ss"); // false
|
|
57317
|
-
* ```
|
|
57318
|
-
*/
|
|
57319
|
-
function isTextFormat(format) {
|
|
57320
|
-
return format === "int" || format === "mm:ss" || format === "h:mm:ss" || format === "duration";
|
|
57321
|
-
}
|
|
57322
|
-
/**
|
|
57323
|
-
* Pads a number to two digits. A longer number stays as it is.
|
|
57324
|
-
*
|
|
57325
|
-
* @param value - A whole number, 0 or more.
|
|
57326
|
-
* @returns The number with a leading zero below 10.
|
|
57327
|
-
* @example
|
|
57328
|
-
* ```ts
|
|
57329
|
-
* pad2(5); // "05"
|
|
57330
|
-
* ```
|
|
57331
|
-
*/
|
|
57332
|
-
function pad2(value) {
|
|
57333
|
-
return String(value).padStart(2, "0");
|
|
57334
|
-
}
|
|
57335
|
-
/**
|
|
57336
|
-
* Whole seconds of a time in milliseconds, rounded up, never below zero. A value that is not
|
|
57337
|
-
* finite counts as zero.
|
|
57338
|
-
*
|
|
57339
|
-
* @param ms - The time in milliseconds.
|
|
57340
|
-
* @returns The whole seconds a timer shows.
|
|
57341
|
-
* @example
|
|
57342
|
-
* ```ts
|
|
57343
|
-
* wholeSeconds(94_001); // 95
|
|
57344
|
-
* ```
|
|
57345
|
-
*/
|
|
57346
|
-
function wholeSeconds(ms) {
|
|
57347
|
-
return Number.isFinite(ms) ? Math.max(0, Math.ceil(ms / SECOND_MS)) : 0;
|
|
57348
|
-
}
|
|
57349
|
-
/**
|
|
57350
|
-
* What the shown string of a bound value is built from: the rounded value for `"int"`, whole
|
|
57351
|
-
* seconds for a time format. Two values with the same unit show the same string.
|
|
57352
|
-
*
|
|
57353
|
-
* @param value - The bound number.
|
|
57354
|
-
* @param format - How it is shown.
|
|
57355
|
-
* @returns The unit of the shown string.
|
|
57356
|
-
* @example
|
|
57357
|
-
* ```ts
|
|
57358
|
-
* unitOf(94_500, "mm:ss"); // 95
|
|
57359
|
-
* ```
|
|
57360
|
-
*/
|
|
57361
|
-
function unitOf(value, format) {
|
|
57362
|
-
if (format !== "int") return wholeSeconds(value);
|
|
57363
|
-
return Number.isFinite(value) ? Math.round(value) : 0;
|
|
57364
|
-
}
|
|
57365
|
-
/**
|
|
57366
|
-
* Shows a bound number in one of the four formats. A value that is not finite shows as zero.
|
|
57367
|
-
*
|
|
57368
|
-
* @param value - The number; milliseconds for the time formats.
|
|
57369
|
-
* @param format - How it is shown.
|
|
57370
|
-
* @param duration - Formats milliseconds as words in the current locale.
|
|
57371
|
-
* @returns The string a label shows.
|
|
57372
|
-
* @example
|
|
57373
|
-
* ```ts
|
|
57374
|
-
* formatBound(95_000, "mm:ss", () => ""); // "01:35"
|
|
57375
|
-
* ```
|
|
57376
|
-
*/
|
|
57377
|
-
function formatBound(value, format, duration) {
|
|
57378
|
-
const unit = unitOf(value, format);
|
|
57379
|
-
switch (format) {
|
|
57380
|
-
case "int": return String(unit);
|
|
57381
|
-
case "mm:ss": return `${pad2(Math.floor(unit / SECONDS_PER_MINUTE))}:${pad2(unit % SECONDS_PER_MINUTE)}`;
|
|
57382
|
-
case "h:mm:ss": return `${Math.floor(unit / SECONDS_PER_HOUR)}:${pad2(Math.floor(unit / SECONDS_PER_MINUTE) % SECONDS_PER_MINUTE)}:${pad2(unit % SECONDS_PER_MINUTE)}`;
|
|
57383
|
-
case "duration": return duration(unit * SECOND_MS);
|
|
57384
|
-
}
|
|
57385
|
-
}
|
|
57386
|
-
//#endregion
|
|
57387
57302
|
//#region src/plugins/text/tags.ts
|
|
57388
57303
|
/** Matches an opening colour tag. Six hex digits: `#rgb` is not accepted. */
|
|
57389
57304
|
const COLOR_TAG = /^color=#([\da-f]{6})$/i;
|
|
@@ -57769,12 +57684,59 @@ function boundValue(ctx, entity, bind, frame) {
|
|
|
57769
57684
|
*/
|
|
57770
57685
|
function formatOf(ctx, entity, bind, value) {
|
|
57771
57686
|
if (isTextFormat(bind.format) && Number.isFinite(value)) return bind.format;
|
|
57687
|
+
warnBadFormat(ctx, entity, bind);
|
|
57688
|
+
return "int";
|
|
57689
|
+
}
|
|
57690
|
+
/**
|
|
57691
|
+
* Reports a bind that names no format, or a value that is not finite, once per entity.
|
|
57692
|
+
*
|
|
57693
|
+
* @param ctx - Domain context of the text plugin.
|
|
57694
|
+
* @param entity - The entity the label sits on.
|
|
57695
|
+
* @param bind - What the label carries.
|
|
57696
|
+
*/
|
|
57697
|
+
function warnBadFormat(ctx, entity, bind) {
|
|
57772
57698
|
warnOnce(ctx, `bind-format:${entity}`, "text: bad bind format", {
|
|
57773
57699
|
component: bind.component,
|
|
57774
57700
|
field: bind.field,
|
|
57775
57701
|
format: bind.format
|
|
57776
57702
|
});
|
|
57777
|
-
|
|
57703
|
+
}
|
|
57704
|
+
/**
|
|
57705
|
+
* Asks a format a feature registered. A format that throws is reported once per name.
|
|
57706
|
+
*
|
|
57707
|
+
* @param ctx - Domain context of the text plugin.
|
|
57708
|
+
* @param name - The name it was registered under.
|
|
57709
|
+
* @param format - The function.
|
|
57710
|
+
* @param value - The whole value.
|
|
57711
|
+
* @returns What it answered, or `undefined` when it threw.
|
|
57712
|
+
*/
|
|
57713
|
+
function askFormat(ctx, name, format, value) {
|
|
57714
|
+
try {
|
|
57715
|
+
return format(value);
|
|
57716
|
+
} catch (error) {
|
|
57717
|
+
warnOnce(ctx, `bind-format-threw:${name}`, "text: bind format threw", {
|
|
57718
|
+
format: name,
|
|
57719
|
+
error
|
|
57720
|
+
});
|
|
57721
|
+
return;
|
|
57722
|
+
}
|
|
57723
|
+
}
|
|
57724
|
+
/**
|
|
57725
|
+
* What a format a feature registered answers for a number, before any label shows it.
|
|
57726
|
+
*
|
|
57727
|
+
* @param ctx - Domain context of the text plugin.
|
|
57728
|
+
* @param name - The format name.
|
|
57729
|
+
* @param value - The number; rounded as `"int"` rounds it.
|
|
57730
|
+
* @returns The string and the style, or `undefined` for a name no feature registered and for a
|
|
57731
|
+
* format that threw.
|
|
57732
|
+
*/
|
|
57733
|
+
function formattedBy(ctx, name, value) {
|
|
57734
|
+
const format = ctx.state.formats.get(name);
|
|
57735
|
+
const answer = format === void 0 ? void 0 : askFormat(ctx, name, format, wholeValue(value));
|
|
57736
|
+
return answer === void 0 ? void 0 : {
|
|
57737
|
+
text: sourceOf(ctx, answer.content),
|
|
57738
|
+
style: answer.style
|
|
57739
|
+
};
|
|
57778
57740
|
}
|
|
57779
57741
|
/**
|
|
57780
57742
|
* The key of a bind, so a changed binding or format is seen as a change. Built once per attached
|
|
@@ -57810,13 +57772,14 @@ function isSameBind(seen, bind) {
|
|
|
57810
57772
|
* @param text - Its component value.
|
|
57811
57773
|
* @param frame - What this run of the system shares.
|
|
57812
57774
|
* @param unit - What a bound label's string was built from; `undefined` for any other label.
|
|
57775
|
+
* @param style - The style the label shows: the one a format answered may be newer than `text`.
|
|
57813
57776
|
*/
|
|
57814
|
-
function remember(ctx, entity, text, frame, unit) {
|
|
57777
|
+
function remember(ctx, entity, text, frame, unit, style = text.style) {
|
|
57815
57778
|
const seen = ctx.state.seen.get(entity);
|
|
57816
57779
|
if (seen === void 0) {
|
|
57817
57780
|
ctx.state.seen.set(entity, {
|
|
57818
57781
|
content: text.content,
|
|
57819
|
-
style
|
|
57782
|
+
style,
|
|
57820
57783
|
bindRef: text.bind,
|
|
57821
57784
|
bind: bindKeyOf(text.bind),
|
|
57822
57785
|
locale: frame.locale,
|
|
@@ -57830,7 +57793,7 @@ function remember(ctx, entity, text, frame, unit) {
|
|
|
57830
57793
|
seen.bind = bindKeyOf(text.bind);
|
|
57831
57794
|
}
|
|
57832
57795
|
seen.content = text.content;
|
|
57833
|
-
seen.style =
|
|
57796
|
+
seen.style = style;
|
|
57834
57797
|
seen.locale = frame.locale;
|
|
57835
57798
|
seen.unit = unit;
|
|
57836
57799
|
seen.box = text.box;
|
|
@@ -57869,17 +57832,18 @@ function keepSize(ctx, entity, layout) {
|
|
|
57869
57832
|
}
|
|
57870
57833
|
/**
|
|
57871
57834
|
* Tells whether a bound label already shows what its value would build: the same unit, style and
|
|
57872
|
-
* binding, and for a
|
|
57835
|
+
* binding, and for a format whose words depend on the language, the same locale. Reads and
|
|
57836
|
+
* compares: no key is built, nothing is kept, no format is called.
|
|
57873
57837
|
*
|
|
57874
57838
|
* @param seen - What was resolved for the label last.
|
|
57875
57839
|
* @param text - Its component value.
|
|
57876
57840
|
* @param unit - The unit of the value this frame.
|
|
57877
|
-
* @param
|
|
57841
|
+
* @param worded - Whether the shown string depends on the locale: a `"duration"` or a named format.
|
|
57878
57842
|
* @param frame - What this run of the system shares.
|
|
57879
57843
|
* @returns True when nothing has to be formatted or written.
|
|
57880
57844
|
*/
|
|
57881
|
-
function isShown(seen, text, unit,
|
|
57882
|
-
return seen.unit === unit && seen.style === text.style && isSameBind(seen, text.bind) && (
|
|
57845
|
+
function isShown(seen, text, unit, worded, frame) {
|
|
57846
|
+
return seen.unit === unit && seen.style === text.style && isSameBind(seen, text.bind) && (!worded || seen.locale === frame.locale);
|
|
57883
57847
|
}
|
|
57884
57848
|
/**
|
|
57885
57849
|
* Writes the new string of a bound label, its measured size, and for a countdown the time left,
|
|
@@ -57890,14 +57854,19 @@ function isShown(seen, text, unit, format, frame) {
|
|
|
57890
57854
|
* @param text - Its component value.
|
|
57891
57855
|
* @param next - The string the label shows now.
|
|
57892
57856
|
* @param value - The bound number, the time left for a countdown.
|
|
57857
|
+
* @param style - The style it shows it in: another one only for what a named format answered.
|
|
57893
57858
|
*/
|
|
57894
|
-
function showBound(ctx, entity, text, next, value) {
|
|
57895
|
-
const
|
|
57859
|
+
function showBound(ctx, entity, text, next, value, style = text.style) {
|
|
57860
|
+
const restyled = style !== text.style;
|
|
57861
|
+
const changed = restyled || next !== text.resolved;
|
|
57896
57862
|
if (changed) {
|
|
57897
|
-
ctx.deps.world.ecs.set(entity, Text,
|
|
57863
|
+
ctx.deps.world.ecs.set(entity, Text, restyled ? {
|
|
57864
|
+
resolved: next,
|
|
57865
|
+
style
|
|
57866
|
+
} : { resolved: next });
|
|
57898
57867
|
if (value !== void 0 && text.bind !== void 0 && isCountdownLeft(text.bind)) ctx.deps.world.ecs.set(entity, Countdown, { left: value });
|
|
57899
57868
|
}
|
|
57900
|
-
if (changed || !ctx.state.measured.has(entity)) keepSize(ctx, entity, layoutFor(ctx, next,
|
|
57869
|
+
if (changed || !ctx.state.measured.has(entity)) keepSize(ctx, entity, layoutFor(ctx, next, style, text.box));
|
|
57901
57870
|
}
|
|
57902
57871
|
/**
|
|
57903
57872
|
* Writes the string a bound label already shows once more, and measures it again. A mark on a
|
|
@@ -57931,7 +57900,8 @@ function warnWithoutDigits(ctx, styleName) {
|
|
|
57931
57900
|
* nothing: no tag is parsed, no key is built. A marked label that stands still is written once
|
|
57932
57901
|
* with the string it shows; one of a `"box"` style that ui laid out at another box is measured at
|
|
57933
57902
|
* it. The style is checked for digits only when the label is written, so a label on a wrong style
|
|
57934
|
-
* builds no warning key per frame.
|
|
57903
|
+
* builds no warning key per frame. A bind that names a format a feature registered goes its own
|
|
57904
|
+
* way; the name is looked up only after it proved none of the four built-in ones.
|
|
57935
57905
|
*
|
|
57936
57906
|
* @param ctx - Domain context of the text plugin.
|
|
57937
57907
|
* @param entity - The entity.
|
|
@@ -57941,11 +57911,17 @@ function warnWithoutDigits(ctx, styleName) {
|
|
|
57941
57911
|
*/
|
|
57942
57912
|
function stepBound(ctx, entity, text, bind, frame) {
|
|
57943
57913
|
const value = boundValue(ctx, entity, bind, frame);
|
|
57914
|
+
const named = isTextFormat(bind.format) ? void 0 : ctx.state.formats.get(bind.format);
|
|
57915
|
+
if (named !== void 0) {
|
|
57916
|
+
stepNamed(ctx, entity, text, bind, named, value, frame);
|
|
57917
|
+
return;
|
|
57918
|
+
}
|
|
57944
57919
|
const format = value === void 0 ? "int" : formatOf(ctx, entity, bind, value);
|
|
57945
57920
|
const unit = value === void 0 ? void 0 : unitOf(value, format);
|
|
57946
57921
|
const marked = ctx.state.dirty.delete(entity);
|
|
57947
57922
|
const seen = ctx.state.seen.get(entity);
|
|
57948
|
-
if (seen !== void 0 && isShown(seen, text, unit, format, frame)) {
|
|
57923
|
+
if (seen !== void 0 && isShown(seen, text, unit, format === "duration", frame)) {
|
|
57924
|
+
if (marked) warnWithoutDigits(ctx, text.style);
|
|
57949
57925
|
standStill(ctx, entity, text, seen, marked);
|
|
57950
57926
|
return;
|
|
57951
57927
|
}
|
|
@@ -57954,6 +57930,39 @@ function stepBound(ctx, entity, text, bind, frame) {
|
|
|
57954
57930
|
remember(ctx, entity, text, frame, unit);
|
|
57955
57931
|
}
|
|
57956
57932
|
/**
|
|
57933
|
+
* One frame of a label whose bind names a format a feature registered. Its unit is the whole value.
|
|
57934
|
+
* While that, the locale, the bind and the style stand the frame is reads and compares: the format
|
|
57935
|
+
* is not called, a mark included, and nothing is kept. Else it is asked once, and its answer is
|
|
57936
|
+
* written only when it differs. The format picks the style, so no style is checked for digits. A
|
|
57937
|
+
* bound field that holds no number shows nothing, as under a built-in format.
|
|
57938
|
+
*
|
|
57939
|
+
* @param ctx - Domain context of the text plugin.
|
|
57940
|
+
* @param entity - The entity.
|
|
57941
|
+
* @param text - Its component value.
|
|
57942
|
+
* @param bind - What it carries: the name of the format.
|
|
57943
|
+
* @param format - The function of the format.
|
|
57944
|
+
* @param value - The number of this frame, when there is one.
|
|
57945
|
+
* @param frame - What this run of the system shares.
|
|
57946
|
+
*/
|
|
57947
|
+
function stepNamed(ctx, entity, text, bind, format, value, frame) {
|
|
57948
|
+
if (value !== void 0 && !Number.isFinite(value)) warnBadFormat(ctx, entity, bind);
|
|
57949
|
+
const unit = value === void 0 ? void 0 : wholeValue(value);
|
|
57950
|
+
const marked = ctx.state.dirty.delete(entity);
|
|
57951
|
+
const seen = ctx.state.seen.get(entity);
|
|
57952
|
+
if (seen !== void 0 && isShown(seen, text, unit, true, frame)) {
|
|
57953
|
+
standStill(ctx, entity, text, seen, marked);
|
|
57954
|
+
return;
|
|
57955
|
+
}
|
|
57956
|
+
const answer = unit === void 0 ? void 0 : askFormat(ctx, bind.format, format, unit);
|
|
57957
|
+
if (answer === void 0) {
|
|
57958
|
+
showBound(ctx, entity, text, unit === void 0 ? "" : String(unit), value);
|
|
57959
|
+
remember(ctx, entity, text, frame, unit);
|
|
57960
|
+
return;
|
|
57961
|
+
}
|
|
57962
|
+
showBound(ctx, entity, text, sourceOf(ctx, answer.content), value, answer.style);
|
|
57963
|
+
remember(ctx, entity, text, frame, unit, answer.style);
|
|
57964
|
+
}
|
|
57965
|
+
/**
|
|
57957
57966
|
* One frame of a bound label whose unit stands still: a marked one is written once as it is, one of
|
|
57958
57967
|
* a `"box"` style that ui laid out at another box is measured at it. Either way the box is noted.
|
|
57959
57968
|
*
|
|
@@ -57964,10 +57973,8 @@ function stepBound(ctx, entity, text, bind, frame) {
|
|
|
57964
57973
|
* @param marked - Whether the label was marked this frame.
|
|
57965
57974
|
*/
|
|
57966
57975
|
function standStill(ctx, entity, text, seen, marked) {
|
|
57967
|
-
if (marked)
|
|
57968
|
-
|
|
57969
|
-
showAgain(ctx, entity, text);
|
|
57970
|
-
} else if (boxMoved(ctx, seen, text)) keepSize(ctx, entity, layoutFor(ctx, text.resolved, text.style, text.box));
|
|
57976
|
+
if (marked) showAgain(ctx, entity, text);
|
|
57977
|
+
else if (boxMoved(ctx, seen, text)) keepSize(ctx, entity, layoutFor(ctx, text.resolved, text.style, text.box));
|
|
57971
57978
|
else return;
|
|
57972
57979
|
seen.box = text.box;
|
|
57973
57980
|
}
|
|
@@ -58817,8 +58824,8 @@ function asContainer(object) {
|
|
|
58817
58824
|
//#region src/plugins/text/lifecycle.ts
|
|
58818
58825
|
/**
|
|
58819
58826
|
* @file text plugin — lifecycle: the dependency resolution, the style table read out of the
|
|
58820
|
-
* feature descriptions and written again by the dev hot swap, the
|
|
58821
|
-
* opens, and the teardown that closes exactly those.
|
|
58827
|
+
* feature descriptions and written again by the dev hot swap, the number formats read out of them
|
|
58828
|
+
* too, the four registrations `onStart` opens, and the teardown that closes exactly those.
|
|
58822
58829
|
*/
|
|
58823
58830
|
/** The owner of the two built-in styles, which no feature can collide with. */
|
|
58824
58831
|
const BUILT_IN = "text";
|
|
@@ -58888,6 +58895,57 @@ function buildStyles(ctx) {
|
|
|
58888
58895
|
}
|
|
58889
58896
|
}
|
|
58890
58897
|
/**
|
|
58898
|
+
* Tells whether a feature entry is a format map `text` can read.
|
|
58899
|
+
*
|
|
58900
|
+
* @param entry - What the feature put under its `textFormats` key.
|
|
58901
|
+
* @returns True when it carries a map of formats.
|
|
58902
|
+
*/
|
|
58903
|
+
function isFormatMap(entry) {
|
|
58904
|
+
return typeof entry === "object" && entry !== null && "kind" in entry && entry.kind === "textFormats" && "map" in entry && typeof entry.map === "object" && entry.map !== null;
|
|
58905
|
+
}
|
|
58906
|
+
/**
|
|
58907
|
+
* Tells whether an entry of a format map is a function. What it answers shows only when it runs.
|
|
58908
|
+
*
|
|
58909
|
+
* @param value - What the feature put under a format name.
|
|
58910
|
+
* @returns True for a function.
|
|
58911
|
+
*/
|
|
58912
|
+
function isFormatFunction(value) {
|
|
58913
|
+
return typeof value === "function";
|
|
58914
|
+
}
|
|
58915
|
+
/**
|
|
58916
|
+
* Refuses one entry of a feature's format map, or hands its function back.
|
|
58917
|
+
*
|
|
58918
|
+
* @param ctx - Domain context of the text plugin.
|
|
58919
|
+
* @param feature - The name of the feature that brought it.
|
|
58920
|
+
* @param name - The format name.
|
|
58921
|
+
* @param value - What the feature put under that name.
|
|
58922
|
+
* @returns The function.
|
|
58923
|
+
* @throws {Error} When the name is a built-in format, another feature's, or holds no function.
|
|
58924
|
+
*/
|
|
58925
|
+
function checkedFormat(ctx, feature, name, value) {
|
|
58926
|
+
if (isTextFormat(name)) throw new Error(`[game] Text format "${name}" of feature "${feature}" is a built-in format.\n Rename it: the engine owns this name.`);
|
|
58927
|
+
const owner = ctx.state.formatOwner.get(name);
|
|
58928
|
+
if (owner !== void 0) throw new Error(`[game] Text format "${name}" is defined by features "${owner}" and "${feature}".\n Keep it in one feature or rename one of them.`);
|
|
58929
|
+
if (!isFormatFunction(value)) throw new TypeError(`[game] Text format "${name}" of feature "${feature}" is not a function.\n Use a function of the value that answers { content, style }.`);
|
|
58930
|
+
return value;
|
|
58931
|
+
}
|
|
58932
|
+
/**
|
|
58933
|
+
* Fills the format table from every feature, in feature order.
|
|
58934
|
+
*
|
|
58935
|
+
* @param ctx - Domain context of the text plugin.
|
|
58936
|
+
* @throws {Error} When a name is a built-in format, two features define it, or it holds no function.
|
|
58937
|
+
*/
|
|
58938
|
+
function buildFormats(ctx) {
|
|
58939
|
+
for (const feature of ctx.deps.flow.features.all()) {
|
|
58940
|
+
const entry = feature.description.textFormats;
|
|
58941
|
+
if (!isFormatMap(entry)) continue;
|
|
58942
|
+
for (const [name, value] of Object.entries(entry.map)) {
|
|
58943
|
+
ctx.state.formats.set(name, checkedFormat(ctx, feature.name, name, value));
|
|
58944
|
+
ctx.state.formatOwner.set(name, feature.name);
|
|
58945
|
+
}
|
|
58946
|
+
}
|
|
58947
|
+
}
|
|
58948
|
+
/**
|
|
58891
58949
|
* Collects every font a style can draw with: the two of the config, then the regular, bold and
|
|
58892
58950
|
* italic font of every registered style.
|
|
58893
58951
|
*
|
|
@@ -58925,7 +58983,7 @@ function replaceStyles(ctx, styles) {
|
|
|
58925
58983
|
ctx.deps.time.wake();
|
|
58926
58984
|
}
|
|
58927
58985
|
/**
|
|
58928
|
-
* Opens what the plugin owns: the style table, the font keys, the layout system, the step after
|
|
58986
|
+
* Opens what the plugin owns: the style table, the number formats, the font keys, the layout system, the step after
|
|
58929
58987
|
* the layout flush, the two world hooks of `Text` and the display adapter. The step is a frame
|
|
58930
58988
|
* callback of phase `layout`: `world` registered its own in its `onStart`, which runs before this
|
|
58931
58989
|
* one (`text` depends on `world`), so the step runs after the world's layout phase and its flush,
|
|
@@ -58934,12 +58992,14 @@ function replaceStyles(ctx, styles) {
|
|
|
58934
58992
|
*
|
|
58935
58993
|
* @param ctx - Kernel context of the text plugin.
|
|
58936
58994
|
* @throws {Error} When two features define the same style name.
|
|
58995
|
+
* @throws {Error} When a number format is refused: see `buildFormats`.
|
|
58937
58996
|
*/
|
|
58938
58997
|
function startText(ctx) {
|
|
58939
58998
|
const tctx = withDeps$1(ctx);
|
|
58940
58999
|
const ecs = tctx.deps.world.ecs;
|
|
58941
59000
|
const frame = createTextFrame(tctx);
|
|
58942
59001
|
buildStyles(tctx);
|
|
59002
|
+
buildFormats(tctx);
|
|
58943
59003
|
collectFonts(tctx);
|
|
58944
59004
|
tctx.state.removers.push(ecs.system(createTextSystem(tctx, frame)), tctx.deps.time.onFrame("layout", () => resolveAdded(tctx, frame)), ecs.onAdded(Text, (entity) => noteAdded(tctx, entity)), ecs.onRemoved(Text, (entity) => {
|
|
58945
59005
|
forgetText(tctx.state, entity);
|
|
@@ -58958,6 +59018,8 @@ function stopText(state) {
|
|
|
58958
59018
|
state.removers.length = 0;
|
|
58959
59019
|
state.styles.clear();
|
|
58960
59020
|
state.styleOwner.clear();
|
|
59021
|
+
state.formats.clear();
|
|
59022
|
+
state.formatOwner.clear();
|
|
58961
59023
|
state.fontKeys.clear();
|
|
58962
59024
|
state.tables.clear();
|
|
58963
59025
|
state.installed.clear();
|
|
@@ -58974,13 +59036,14 @@ function stopText(state) {
|
|
|
58974
59036
|
//#endregion
|
|
58975
59037
|
//#region src/plugins/text/api.ts
|
|
58976
59038
|
/**
|
|
58977
|
-
* @file text plugin — API factory.
|
|
58978
|
-
* a glyph,
|
|
58979
|
-
*
|
|
59039
|
+
* @file text plugin — API factory. Five members: how big a piece of text is, whether a font has
|
|
59040
|
+
* a glyph, what a game's number format answers, which styles the game registered, and the dev hot
|
|
59041
|
+
* swap of a styles file. The domain context is built on the first call, because the kernel builds
|
|
59042
|
+
* the plugin APIs before every dependency is resolvable.
|
|
58980
59043
|
*/
|
|
58981
59044
|
/**
|
|
58982
|
-
* Creates the text API: `app.text.measure(...)`, `app.text.hasGlyph(...)`,
|
|
58983
|
-
* and `app.text.replaceStyles(...)`.
|
|
59045
|
+
* Creates the text API: `app.text.measure(...)`, `app.text.hasGlyph(...)`,
|
|
59046
|
+
* `app.text.formatted(...)`, `app.text.styles()` and `app.text.replaceStyles(...)`.
|
|
58984
59047
|
*
|
|
58985
59048
|
* @param ctx - Kernel context of the text plugin.
|
|
58986
59049
|
* @returns The plugin API.
|
|
@@ -58998,6 +59061,7 @@ function createTextApi(ctx) {
|
|
|
58998
59061
|
return sizeOf(layoutFor(tctx, sourceOf(tctx, content), style, width));
|
|
58999
59062
|
},
|
|
59000
59063
|
hasGlyph: (char, style) => hasGlyphOf(text(), char, style),
|
|
59064
|
+
formatted: (name, value) => formattedBy(text(), name, value),
|
|
59001
59065
|
styles: () => Object.freeze([...ctx.state.styles.keys()]),
|
|
59002
59066
|
replaceStyles: (styles) => {
|
|
59003
59067
|
replaceStyles(text(), styles);
|
|
@@ -59110,6 +59174,8 @@ function createTextState$1() {
|
|
|
59110
59174
|
return {
|
|
59111
59175
|
styles: emptyMap$2(),
|
|
59112
59176
|
styleOwner: emptyMap$2(),
|
|
59177
|
+
formats: emptyMap$2(),
|
|
59178
|
+
formatOwner: emptyMap$2(),
|
|
59113
59179
|
fontKeys: emptySet$1(),
|
|
59114
59180
|
tables: emptyMap$2(),
|
|
59115
59181
|
installed: emptySet$1(),
|
|
@@ -61307,14 +61373,18 @@ function contentOf$2(element, resolvedOf) {
|
|
|
61307
61373
|
return plain === "" ? void 0 : plain;
|
|
61308
61374
|
}
|
|
61309
61375
|
/**
|
|
61310
|
-
* The text style key a text element
|
|
61376
|
+
* The text style key of a text element: the style a format of the game answered, for a text whose
|
|
61377
|
+
* bind names one; else the `style` prop while that is a key.
|
|
61311
61378
|
*
|
|
61312
61379
|
* @param element - The element to read.
|
|
61380
|
+
* @param shownStyleOf - Reads `Text.style` of an entity; none for a tree read without a world.
|
|
61313
61381
|
* @returns The key, or `undefined` for any other element and for a text with a `Style` object or
|
|
61314
61382
|
* no style.
|
|
61315
61383
|
*/
|
|
61316
|
-
function textStyleOf(element) {
|
|
61384
|
+
function textStyleOf(element, shownStyleOf) {
|
|
61317
61385
|
if (element.type !== "text") return void 0;
|
|
61386
|
+
const shown = namesFormat(element) ? shownStyleOf?.(element.entity) : void 0;
|
|
61387
|
+
if (shown !== void 0) return shown;
|
|
61318
61388
|
const style = element.node.props.style;
|
|
61319
61389
|
return typeof style === "string" ? style : void 0;
|
|
61320
61390
|
}
|
|
@@ -61328,14 +61398,15 @@ function textStyleOf(element) {
|
|
|
61328
61398
|
* @param state - The jsx state.
|
|
61329
61399
|
* @param element - The element to read.
|
|
61330
61400
|
* @param resolvedOf - Reads the resolved string of a text entity; none in a read without a world.
|
|
61401
|
+
* @param shownStyleOf - Reads `Text.style` of a text entity; none in a read without a world.
|
|
61331
61402
|
* @param place - Maps a rect of a slotted root into root coordinates; none for a root on the viewport.
|
|
61332
61403
|
* @returns The node, with its children in child order.
|
|
61333
61404
|
*/
|
|
61334
|
-
function nodeOf(state, element, resolvedOf, place) {
|
|
61405
|
+
function nodeOf(state, element, resolvedOf, shownStyleOf, place) {
|
|
61335
61406
|
const children = [];
|
|
61336
61407
|
for (const child of element.children) {
|
|
61337
61408
|
const childElement = state.elements.get(child);
|
|
61338
|
-
if (childElement !== void 0 && !isOwnKey(childElement.key)) children.push(nodeOf(state, childElement, resolvedOf, place));
|
|
61409
|
+
if (childElement !== void 0 && !isOwnKey(childElement.key)) children.push(nodeOf(state, childElement, resolvedOf, shownStyleOf, place));
|
|
61339
61410
|
}
|
|
61340
61411
|
const node = {
|
|
61341
61412
|
key: element.key,
|
|
@@ -61350,7 +61421,7 @@ function nodeOf(state, element, resolvedOf, place) {
|
|
|
61350
61421
|
...node,
|
|
61351
61422
|
content
|
|
61352
61423
|
};
|
|
61353
|
-
const textStyle = textStyleOf(element);
|
|
61424
|
+
const textStyle = textStyleOf(element, shownStyleOf);
|
|
61354
61425
|
const styled = textStyle === void 0 ? worded : {
|
|
61355
61426
|
...worded,
|
|
61356
61427
|
textStyle
|
|
@@ -61429,17 +61500,18 @@ function placeOf(root, slotPose) {
|
|
|
61429
61500
|
* @param resolvedOf - Reads the string `text` resolved for an entity; none in a read without a world.
|
|
61430
61501
|
* @param slotPose - The root pose of a slot, `rootPoseOf` of `renderer`; none in a read without a world.
|
|
61431
61502
|
* @param isAside - Whether an entity belongs to the scene `world` builds aside: such a root is not read.
|
|
61503
|
+
* @param shownStyleOf - Reads `Text.style` of an entity; none in a read without a world.
|
|
61432
61504
|
* @returns One root node, or every root under a `screen` node.
|
|
61433
61505
|
* @example
|
|
61434
61506
|
* ```ts
|
|
61435
61507
|
* readTree({ roots: new Map(), elements: new Map() } as unknown as JsxState).type; // "screen"
|
|
61436
61508
|
* ```
|
|
61437
61509
|
*/
|
|
61438
|
-
function readTree(state, layers = [], resolvedOf, slotPose, isAside) {
|
|
61510
|
+
function readTree(state, layers = [], resolvedOf, slotPose, isAside, shownStyleOf) {
|
|
61439
61511
|
const nodes = [];
|
|
61440
61512
|
for (const root of sortedRoots(state, layers, isAside)) {
|
|
61441
61513
|
const element = root.element === void 0 ? void 0 : state.elements.get(root.element);
|
|
61442
|
-
if (element !== void 0) nodes.push(nodeOf(state, element, resolvedOf, placeOf(root, slotPose)));
|
|
61514
|
+
if (element !== void 0) nodes.push(nodeOf(state, element, resolvedOf, shownStyleOf, placeOf(root, slotPose)));
|
|
61443
61515
|
}
|
|
61444
61516
|
const single = nodes.length === 1 ? nodes[0] : void 0;
|
|
61445
61517
|
if (single !== void 0) return single;
|
|
@@ -66626,6 +66698,7 @@ function createJsxApi(ctx, modules) {
|
|
|
66626
66698
|
const frame = createReconciler(ctx, modules, fields);
|
|
66627
66699
|
const focus = createFocus(ctx, frame.markPointer, topRoot, fields);
|
|
66628
66700
|
const resolvedOf = (entity) => ctx.deps.world.ecs.get(entity, Text)?.resolved;
|
|
66701
|
+
const shownStyleOf = (entity) => ctx.deps.world.ecs.get(entity, Text)?.style;
|
|
66629
66702
|
const lookup = (entity) => state.elements.get(entity);
|
|
66630
66703
|
const find = (key) => {
|
|
66631
66704
|
for (const root of sortedRoots(state, layerNames(), isAside)) {
|
|
@@ -66634,7 +66707,7 @@ function createJsxApi(ctx, modules) {
|
|
|
66634
66707
|
}
|
|
66635
66708
|
};
|
|
66636
66709
|
return {
|
|
66637
|
-
tree: () => readTree(state, layerNames(), resolvedOf, (slot) => rootPoseOf(ctx.deps.world.ecs, slot), isAside),
|
|
66710
|
+
tree: () => readTree(state, layerNames(), resolvedOf, (slot) => rootPoseOf(ctx.deps.world.ecs, slot), isAside, shownStyleOf),
|
|
66638
66711
|
find,
|
|
66639
66712
|
lint: () => runLint(ctx),
|
|
66640
66713
|
fill: (key, value) => {
|
|
@@ -68099,14 +68172,24 @@ function needsMeasure(element) {
|
|
|
68099
68172
|
return typeof element.style.width !== "number" || typeof element.style.height !== "number";
|
|
68100
68173
|
}
|
|
68101
68174
|
/**
|
|
68175
|
+
* Reads the style key of a text or an icon out of its props.
|
|
68176
|
+
*
|
|
68177
|
+
* @param element - The element.
|
|
68178
|
+
* @returns The key `text.measure` takes.
|
|
68179
|
+
*/
|
|
68180
|
+
function styleKeyOf(element) {
|
|
68181
|
+
const { style } = element.node.props;
|
|
68182
|
+
return typeof style === "string" ? style : DEFAULT_TEXT_STYLE;
|
|
68183
|
+
}
|
|
68184
|
+
/**
|
|
68102
68185
|
* Reads what a text draws out of its props.
|
|
68103
68186
|
*
|
|
68104
68187
|
* @param element - The text element.
|
|
68105
68188
|
* @returns The content and the style key `text.measure` takes.
|
|
68106
68189
|
*/
|
|
68107
68190
|
function contentOf$1(element) {
|
|
68108
|
-
const { content
|
|
68109
|
-
const styleKey =
|
|
68191
|
+
const { content } = element.node.props;
|
|
68192
|
+
const styleKey = styleKeyOf(element);
|
|
68110
68193
|
if (typeof content === "string") return {
|
|
68111
68194
|
content,
|
|
68112
68195
|
style: styleKey
|
|
@@ -68121,16 +68204,6 @@ function contentOf$1(element) {
|
|
|
68121
68204
|
};
|
|
68122
68205
|
}
|
|
68123
68206
|
/**
|
|
68124
|
-
* The bind of a text, when the markup gave it one.
|
|
68125
|
-
*
|
|
68126
|
-
* @param element - The element to ask about.
|
|
68127
|
-
* @returns What `bind()` built, or `undefined` for any other element.
|
|
68128
|
-
*/
|
|
68129
|
-
function bindOf(element) {
|
|
68130
|
-
const { bind } = element.node.props;
|
|
68131
|
-
return element.type === "text" && typeof bind === "object" && bind !== null ? bind : void 0;
|
|
68132
|
-
}
|
|
68133
|
-
/**
|
|
68134
68207
|
* The bound number as the `components` prop of a text lists it. Of two values of the bound
|
|
68135
68208
|
* component the last wins, as it does for the element.
|
|
68136
68209
|
*
|
|
@@ -68146,18 +68219,14 @@ function listedValueOf(element, bind) {
|
|
|
68146
68219
|
return typeof field === "number" ? field : void 0;
|
|
68147
68220
|
}
|
|
68148
68221
|
/**
|
|
68149
|
-
* The string a
|
|
68150
|
-
* for the first solve, the bound field of its `components` value in the format of the bind, so
|
|
68151
|
-
* `text` resolves what was measured. A `Countdown` shows the `left` it lists, 0, until `text`
|
|
68152
|
-
* derives it.
|
|
68222
|
+
* The string a text with this bind shows, see `shownOf`.
|
|
68153
68223
|
*
|
|
68154
68224
|
* @param element - The text element.
|
|
68225
|
+
* @param bind - Its bind.
|
|
68155
68226
|
* @param source - Where `Text.resolved` and the duration words are read.
|
|
68156
|
-
* @returns The string
|
|
68227
|
+
* @returns The string.
|
|
68157
68228
|
*/
|
|
68158
|
-
function
|
|
68159
|
-
const bind = bindOf(element);
|
|
68160
|
-
if (bind === void 0) return void 0;
|
|
68229
|
+
function boundShown(element, bind, source) {
|
|
68161
68230
|
const resolved = source.resolved(element.entity);
|
|
68162
68231
|
if (resolved !== void 0) return resolved;
|
|
68163
68232
|
const value = listedValueOf(element, bind);
|
|
@@ -68165,6 +68234,42 @@ function shownOf(element, source) {
|
|
|
68165
68234
|
return value === void 0 ? "" : formatBound(value, format, (ms) => source.duration(ms));
|
|
68166
68235
|
}
|
|
68167
68236
|
/**
|
|
68237
|
+
* The size of a text whose bind names a format of the game. A format picks the style too, so the
|
|
68238
|
+
* string alone does not say it: once the entity carries its `Text` both are read from there.
|
|
68239
|
+
* Before that, for the first solve, the format is asked on the bound field of its `components`
|
|
68240
|
+
* value, so `text` resolves what was measured.
|
|
68241
|
+
*
|
|
68242
|
+
* @param element - The text element.
|
|
68243
|
+
* @param bind - Its bind.
|
|
68244
|
+
* @param source - What it is measured through.
|
|
68245
|
+
* @param width - The width Yoga offers, or `undefined` when it bounds none.
|
|
68246
|
+
* @returns The size, or `undefined` when there is no answer to measure: an unknown name, a format
|
|
68247
|
+
* that threw, or no listed value.
|
|
68248
|
+
*/
|
|
68249
|
+
function namedSize(element, bind, source, width) {
|
|
68250
|
+
const resolved = source.resolved(element.entity);
|
|
68251
|
+
if (resolved !== void 0) return source.measure(resolved, source.style(element.entity) ?? styleKeyOf(element), width);
|
|
68252
|
+
const value = listedValueOf(element, bind);
|
|
68253
|
+
const answer = value === void 0 ? void 0 : source.formatted(bind.format, value);
|
|
68254
|
+
return answer === void 0 ? void 0 : source.measure(answer.text, answer.style, width);
|
|
68255
|
+
}
|
|
68256
|
+
/**
|
|
68257
|
+
* The size a text measures to: a bound one by what it shows, any other by its content.
|
|
68258
|
+
*
|
|
68259
|
+
* @param element - The text element.
|
|
68260
|
+
* @param source - What it is measured through.
|
|
68261
|
+
* @param width - The width Yoga offers, or `undefined` when it bounds none.
|
|
68262
|
+
* @returns The size before it is rounded.
|
|
68263
|
+
*/
|
|
68264
|
+
function textSize(element, source, width) {
|
|
68265
|
+
const bind = bindOf(element);
|
|
68266
|
+
if (bind === void 0) {
|
|
68267
|
+
const { content, style } = contentOf$1(element);
|
|
68268
|
+
return source.measure(content, style, width);
|
|
68269
|
+
}
|
|
68270
|
+
return (isTextFormat(bind.format) ? void 0 : namedSize(element, bind, source, width)) ?? source.measure(boundShown(element, bind, source), styleKeyOf(element), width);
|
|
68271
|
+
}
|
|
68272
|
+
/**
|
|
68168
68273
|
* The size a text or an icon takes before Yoga clamps it: an icon is square on one line of its
|
|
68169
68274
|
* text style, a bound text measures the string it shows, any other text its content, wrapped at
|
|
68170
68275
|
* `width` when its style wraps at its box. The size is rounded up to whole units. Yoga rounds a
|
|
@@ -68177,8 +68282,7 @@ function shownOf(element, source) {
|
|
|
68177
68282
|
* @returns The width and the height, in whole units.
|
|
68178
68283
|
*/
|
|
68179
68284
|
function naturalSize(element, source, width) {
|
|
68180
|
-
const
|
|
68181
|
-
const size = element.type === "icon" ? squareOf(source.measure(LINE_SAMPLE, style)) : source.measure(shownOf(element, source) ?? content, style, width);
|
|
68285
|
+
const size = element.type === "icon" ? squareOf(source.measure(LINE_SAMPLE, styleKeyOf(element))) : textSize(element, source, width);
|
|
68182
68286
|
return {
|
|
68183
68287
|
width: Math.ceil(size.width - WHOLE_EPSILON),
|
|
68184
68288
|
height: Math.ceil(size.height - WHOLE_EPSILON)
|
|
@@ -69194,7 +69298,7 @@ async function loadYogaModule() {
|
|
|
69194
69298
|
//#region src/plugins/ui/layout/api.ts
|
|
69195
69299
|
/**
|
|
69196
69300
|
* What the text elements are measured through: `text.measure`, the string `text` resolved for an
|
|
69197
|
-
* entity, and the duration words of `i18n`.
|
|
69301
|
+
* entity and its style, what a format of the game answers, and the duration words of `i18n`.
|
|
69198
69302
|
*
|
|
69199
69303
|
* @param ctx - Domain context of the ui plugin.
|
|
69200
69304
|
* @returns The source every measure function reads.
|
|
@@ -69203,6 +69307,8 @@ function textSourceOf(ctx) {
|
|
|
69203
69307
|
return {
|
|
69204
69308
|
measure: (content, style, width) => ctx.deps.text.measure(content, style, width),
|
|
69205
69309
|
resolved: (entity) => ctx.deps.world.ecs.get(entity, Text)?.resolved,
|
|
69310
|
+
style: (entity) => ctx.deps.world.ecs.get(entity, Text)?.style,
|
|
69311
|
+
formatted: (name, value) => ctx.deps.text.formatted(name, value),
|
|
69206
69312
|
duration: (ms) => ctx.deps.i18n.duration(ms)
|
|
69207
69313
|
};
|
|
69208
69314
|
}
|
|
@@ -70135,8 +70241,9 @@ const STRINGS_FILE = /\/generated\/strings\.(?:[\w-]+\.)?([\w-]+)\.ts$/;
|
|
|
70135
70241
|
const ASSETS_STAMP = "/.moku/assets-stamp.ts";
|
|
70136
70242
|
/**
|
|
70137
70243
|
* The `kind` of every value a game registers by value at start: ECS component and tag types
|
|
70138
|
-
* (filters too), nodes, slots, flows, asset bundles
|
|
70139
|
-
* data, an effect descriptor or a timeline step,
|
|
70244
|
+
* (filters too), nodes, slots, flows, asset bundles, plugin owners and text formats, which `text`
|
|
70245
|
+
* reads once and never swaps. Any other `kind` marks data, an effect descriptor or a timeline step,
|
|
70246
|
+
* which a node reads through the live binding.
|
|
70140
70247
|
*/
|
|
70141
70248
|
const REGISTERED_KINDS = {
|
|
70142
70249
|
component: true,
|
|
@@ -70145,7 +70252,8 @@ const REGISTERED_KINDS = {
|
|
|
70145
70252
|
slot: true,
|
|
70146
70253
|
flow: true,
|
|
70147
70254
|
bundles: true,
|
|
70148
|
-
plugin: true
|
|
70255
|
+
plugin: true,
|
|
70256
|
+
textFormats: true
|
|
70149
70257
|
};
|
|
70150
70258
|
/**
|
|
70151
70259
|
* Tells whether a value carries own members a definition could sit on.
|
|
@@ -70258,8 +70366,8 @@ function isTextStyles(value) {
|
|
|
70258
70366
|
}
|
|
70259
70367
|
/**
|
|
70260
70368
|
* Tells whether an export is something the game registers by value at start. An own string
|
|
70261
|
-
* `kind` decides alone: a flow, a node, a slot, an ECS component or tag, a filter, bundles
|
|
70262
|
-
* plugin owner refuse, a descriptor such as `sfx(...)` or a step such as `mark(...)` passes.
|
|
70369
|
+
* `kind` decides alone: a flow, a node, a slot, an ECS component or tag, a filter, bundles, a
|
|
70370
|
+
* plugin owner or text formats refuse, a descriptor such as `sfx(...)` or a step such as `mark(...)` passes.
|
|
70263
70371
|
* Without a `kind`, an object with an own string `id` or `name` refuses: a scene, a system, a
|
|
70264
70372
|
* feature or a plugin. A function without a `kind` passes, since every function has an own `name`.
|
|
70265
70373
|
*
|
|
@@ -72772,7 +72880,9 @@ const createPlugin = framework.createPlugin;
|
|
|
72772
72880
|
* a string key written in code (a key that comes from data is checked with `app.i18n.isKey`).
|
|
72773
72881
|
*
|
|
72774
72882
|
* @returns The helpers typed with the game's `player`, `session`, `assets`, `bundles`, `strings`,
|
|
72775
|
-
* `
|
|
72883
|
+
* `textStyles`, `textFormats` (the format names of `bind`, next to the four built-in ones, with
|
|
72884
|
+
* `defineTextFormats` answering the game's styles), `emitters` and `hud` (the HUD part keys of
|
|
72885
|
+
* `HudPart` and `Overlay`).
|
|
72776
72886
|
* @example
|
|
72777
72887
|
* ```ts
|
|
72778
72888
|
* // kit.ts of a game: bound once, imported by every node, flow and view file.
|