@moku-labs/game 0.15.87 → 0.15.89
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-COLf1y-2.d.mts} +5 -5
- package/dist/control.d.mts +4 -4
- package/dist/{define-CMl6NcM4.d.mts → define-CegLUMAK.d.mts} +2 -2
- package/dist/{headless-DtDdn5gg.d.mts → headless-DhNDRVXy.d.mts} +1 -1
- package/dist/{index-Bn0pFiae.d.mts → index-B1bdw4B2.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-a9AK--Fj.d.mts} +1 -1
- package/dist/{sources-CyltHb9o.mjs → sources-kL64Svgl.mjs} +1 -1
- package/dist/{src-BFa-zMmW.mjs → src-CZSz-mMz.mjs} +460 -202
- package/dist/testing.d.mts +4 -4
- package/dist/testing.mjs +1 -1
- package/dist/{types-CbVXXqPs.d.mts → types--QXvRPXM.d.mts} +44 -10
- package/dist/{types-BpipkaVe.d.mts → types-CJzm90e_.d.mts} +2 -2
- package/dist/{types-OBpR0u05.d.mts → types-CXbcEveH.d.mts} +113 -16
- package/dist/{types-C5gLBKbm.d.mts → types-CgrPwBjC.d.mts} +2 -2
- package/dist/{types-OKAnpylW.d.mts → types-Fbq4snuX.d.mts} +4 -4
- package/dist/{visual-B7TxMv1J.mjs → visual-CULAJg6b.mjs} +161 -10
- package/dist/{visual-CMnWgCkh.d.mts → visual-xduW0Ojp.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.
|
|
@@ -19198,7 +19198,8 @@ const NOW = {
|
|
|
19198
19198
|
c: 0,
|
|
19199
19199
|
d: 1,
|
|
19200
19200
|
tx: 0,
|
|
19201
|
-
ty: 0
|
|
19201
|
+
ty: 0,
|
|
19202
|
+
under: false
|
|
19202
19203
|
};
|
|
19203
19204
|
/** What a kept record owes `refresh`: nothing, the filter output, or the pre-pass results and the filter output. */
|
|
19204
19205
|
const OWED = {
|
|
@@ -19269,15 +19270,16 @@ function drawsDirect(stack) {
|
|
|
19269
19270
|
* filter with a quad, no inputs, on `"inherit"`, at the canvas resolution, and not drawn direct. An `Alpha` beside it does
|
|
19270
19271
|
* not fit: stage 3 draws `F(A·x)` in stack order, the mesh would draw `A·F(x)`, and for a body that is not alpha-linear
|
|
19271
19272
|
* the picture would pop at every entry. A top that blends otherwise never gets here: `pictureWhy` refuses it. A mesh
|
|
19272
|
-
* destroyed with a parent around it has nothing left to draw on.
|
|
19273
|
+
* destroyed with a parent around it has nothing left to draw on. Allocates nothing.
|
|
19273
19274
|
*
|
|
19274
19275
|
* @param kctx - The kept context.
|
|
19275
19276
|
* @param record - The record.
|
|
19277
|
+
* @param stack - The stack of this frame.
|
|
19276
19278
|
* @returns True when it fits.
|
|
19277
19279
|
*/
|
|
19278
|
-
function shadeFits(kctx, record) {
|
|
19279
|
-
if (kctx.host.kind() !== "webgpu" ||
|
|
19280
|
-
if (
|
|
19280
|
+
function shadeFits(kctx, record, stack) {
|
|
19281
|
+
if (kctx.host.kind() !== "webgpu" || stack.enabled !== 1) return false;
|
|
19282
|
+
if (stack.rs !== NOW.r || drawsDirect(stack)) return false;
|
|
19281
19283
|
const slot = enabledSlot(record.slots);
|
|
19282
19284
|
const bodyOnQuad = slot?.quad !== void 0 && slot.inputs === void 0;
|
|
19283
19285
|
const followsCanvas = slot?.filter.resolution === "inherit";
|
|
@@ -19393,8 +19395,8 @@ function drawnAnyway(kctx, node) {
|
|
|
19393
19395
|
return node.renderable || kctx.sync.hiddenOnlyAmong(kctx.hidden, node, DRAWN_ANYWAY);
|
|
19394
19396
|
}
|
|
19395
19397
|
/**
|
|
19396
|
-
* Tells whether an ancestor filters a placed record's view: a filter of its own or its kept picture.
|
|
19397
|
-
*
|
|
19398
|
+
* Tells whether an ancestor filters a placed record's view: a filter of its own or its kept picture. Live, the canvas
|
|
19399
|
+
* position of a placed filter is then relative to that filter's texture.
|
|
19398
19400
|
*
|
|
19399
19401
|
* @param kctx - The kept context.
|
|
19400
19402
|
* @param record - The record.
|
|
@@ -19406,23 +19408,27 @@ function filtersPlaced(kctx, record, node) {
|
|
|
19406
19408
|
}
|
|
19407
19409
|
/**
|
|
19408
19410
|
* Tells whether an ancestor draws what is under it as a picture would: visible, untinted, blending normally, drawn (an
|
|
19409
|
-
* overlay's range and a kept ancestor's picture count)
|
|
19410
|
-
*
|
|
19411
|
-
*
|
|
19412
|
-
*
|
|
19413
|
-
*
|
|
19411
|
+
* overlay's range and a kept ancestor's picture count). For a placed filter it may also hold a filter, noted in
|
|
19412
|
+
* `NOW.under`, while the record fits the mode: a stage 3 picture would hold the wrong place, the record's own body on its
|
|
19413
|
+
* quad reads the canvas place from the world transform, whatever target the ancestor renders into. Its alpha is not read
|
|
19414
|
+
* (F113): the quad hangs in the top's parent and Pixi multiplies it by the ancestors' alpha, while stage 1 renders the
|
|
19415
|
+
* top as a root without them. A fading ancestor so draws the picture at `A·F(x)`, live draws `F(A·x)`: the same for an
|
|
19416
|
+
* alpha-linear filter, the whole picture faded for one that is not.
|
|
19414
19417
|
*
|
|
19415
19418
|
* @param kctx - The kept context.
|
|
19416
19419
|
* @param record - The record.
|
|
19417
19420
|
* @param node - The ancestor.
|
|
19421
|
+
* @param stack - The stack of this frame.
|
|
19418
19422
|
* @returns 0 when it does, else the `WHY` it does not.
|
|
19419
19423
|
*/
|
|
19420
|
-
function ancestorWhy(kctx, record, node) {
|
|
19424
|
+
function ancestorWhy(kctx, record, node, stack) {
|
|
19421
19425
|
if (!node.visible) return WHY.ancestorHidden;
|
|
19422
19426
|
if (node.tint !== WHITE$2) return WHY.ancestorTint;
|
|
19423
19427
|
if (!plainBlend(node.blendMode)) return WHY.ancestorBlend;
|
|
19424
19428
|
if (!drawnAnyway(kctx, node)) return WHY.ancestorHidden;
|
|
19425
|
-
|
|
19429
|
+
if (!filtersPlaced(kctx, record, node)) return 0;
|
|
19430
|
+
NOW.under = true;
|
|
19431
|
+
return shadeFits(kctx, record, stack) ? 0 : WHY.placedUnderFilter;
|
|
19426
19432
|
}
|
|
19427
19433
|
/**
|
|
19428
19434
|
* Tells whether every ancestor up to the stage draws the view as a picture would (`ancestorWhy`).
|
|
@@ -19430,12 +19436,13 @@ function ancestorWhy(kctx, record, node) {
|
|
|
19430
19436
|
* @param kctx - The kept context.
|
|
19431
19437
|
* @param record - The record.
|
|
19432
19438
|
* @param stage - The stage of the application.
|
|
19439
|
+
* @param stack - The stack of this frame.
|
|
19433
19440
|
* @returns 0 when they do, else the `WHY` of the first that does not.
|
|
19434
19441
|
*/
|
|
19435
|
-
function ancestorsWhy(kctx, record, stage) {
|
|
19442
|
+
function ancestorsWhy(kctx, record, stage, stack) {
|
|
19436
19443
|
for (let node = record.top.parent; node !== stage; node = node.parent) {
|
|
19437
19444
|
if (node === null) return WHY.ancestorHidden;
|
|
19438
|
-
const why = ancestorWhy(kctx, record, node);
|
|
19445
|
+
const why = ancestorWhy(kctx, record, node, stack);
|
|
19439
19446
|
if (why !== 0) return why;
|
|
19440
19447
|
}
|
|
19441
19448
|
return 0;
|
|
@@ -19459,7 +19466,7 @@ function eligible(kctx, record, view, stack) {
|
|
|
19459
19466
|
const picture = pictureWhy(record.top, view);
|
|
19460
19467
|
if (picture !== 0) return picture;
|
|
19461
19468
|
if (!topDrawn(kctx.sync, view)) return WHY.hidden;
|
|
19462
|
-
return ancestorsWhy(kctx, record, stage);
|
|
19469
|
+
return ancestorsWhy(kctx, record, stage, stack);
|
|
19463
19470
|
}
|
|
19464
19471
|
/**
|
|
19465
19472
|
* Tells whether the kept cache may keep anything this frame: switched on and not bypassed.
|
|
@@ -19950,7 +19957,7 @@ function renderStages(kctx, pixi, matrices, record, view, now) {
|
|
|
19950
19957
|
return ok;
|
|
19951
19958
|
}
|
|
19952
19959
|
record.direct = false;
|
|
19953
|
-
|
|
19960
|
+
meshForTake(kctx, pixi, record, ok);
|
|
19954
19961
|
if (ok && first !== void 0) renderStage2(kctx, pixi, matrices, record, {
|
|
19955
19962
|
inputs: first.inputs,
|
|
19956
19963
|
resolution: now.r,
|
|
@@ -19964,6 +19971,23 @@ function renderStages(kctx, pixi, matrices, record, view, now) {
|
|
|
19964
19971
|
return ok;
|
|
19965
19972
|
}
|
|
19966
19973
|
/**
|
|
19974
|
+
* Settles what a take draws through, before its output: a stack that stopped fitting leaves before anything is drawn
|
|
19975
|
+
* for it, and the frame draws a sprite of stage 3. Under a filter there is no sprite to draw, so a picture that rendered
|
|
19976
|
+
* goes on the mesh; the sprite a mesh takes the place of may not exist yet.
|
|
19977
|
+
*
|
|
19978
|
+
* @param kctx - The kept context.
|
|
19979
|
+
* @param pixi - The module that draws.
|
|
19980
|
+
* @param record - The record, its take keys written.
|
|
19981
|
+
* @param ok - Stage 1 rendered.
|
|
19982
|
+
*/
|
|
19983
|
+
function meshForTake(kctx, pixi, record, ok) {
|
|
19984
|
+
if (record.shaded && !shadeFits(kctx, record, NOW)) leaveShade(record);
|
|
19985
|
+
const quad = enabledSlot(record.slots)?.quad;
|
|
19986
|
+
if (!ok || !NOW.under || record.shaded || quad === void 0) return;
|
|
19987
|
+
quadDrawing(pixi, record, record.s3 ?? pixi.Texture.EMPTY);
|
|
19988
|
+
enterShade(kctx, pixi, record, quad, NOW);
|
|
19989
|
+
}
|
|
19990
|
+
/**
|
|
19967
19991
|
* Puts the filters of a live record whose take failed back on its top: it draws live again.
|
|
19968
19992
|
*
|
|
19969
19993
|
* @param kctx - The kept context.
|
|
@@ -20339,7 +20363,8 @@ function retakeOrGoLive(kctx, pixi, matrices, record, view, why) {
|
|
|
20339
20363
|
}
|
|
20340
20364
|
/**
|
|
20341
20365
|
* A stage-1 change of a kept record (P4.3): retaken, or after three in a row drawn live and calm, so it stands still
|
|
20342
|
-
* for eight frames before the next take.
|
|
20366
|
+
* for eight frames before the next take. Under a filter it is always retaken: live, a body that reads its place reads
|
|
20367
|
+
* another one, and a glow would jump; only a refused take or an eviction goes live there.
|
|
20343
20368
|
*
|
|
20344
20369
|
* @param kctx - The kept context.
|
|
20345
20370
|
* @param pixi - The module that draws.
|
|
@@ -20350,7 +20375,7 @@ function retakeOrGoLive(kctx, pixi, matrices, record, view, why) {
|
|
|
20350
20375
|
*/
|
|
20351
20376
|
function churn(kctx, pixi, matrices, record, view, why) {
|
|
20352
20377
|
record.churn += 1;
|
|
20353
|
-
if (record.churn < 3) {
|
|
20378
|
+
if (record.churn < 3 || NOW.under) {
|
|
20354
20379
|
retakeOrGoLive(kctx, pixi, matrices, record, view, why);
|
|
20355
20380
|
return;
|
|
20356
20381
|
}
|
|
@@ -20631,10 +20656,11 @@ function refresh$1(kctx, pixi, matrices, record, view, hold) {
|
|
|
20631
20656
|
* @returns True when the record was taken whole.
|
|
20632
20657
|
*/
|
|
20633
20658
|
function refreshOutput(kctx, pixi, matrices, record, view, hold) {
|
|
20634
|
-
const fits = shadeFits(kctx, record);
|
|
20659
|
+
const fits = shadeFits(kctx, record, NOW);
|
|
20635
20660
|
const unfit = record.shaded && !fits;
|
|
20636
20661
|
if (unfit) leaveShade(record);
|
|
20637
|
-
const
|
|
20662
|
+
const unplaced = unfit || NOW.under && !record.shaded;
|
|
20663
|
+
const owed = Math.max(stagesOwed(record, hold), unplaced ? OWED.output : OWED.none);
|
|
20638
20664
|
if (owed === OWED.none) return leaveAtRest(kctx, pixi, matrices, record, view, hold);
|
|
20639
20665
|
const chain = owed === OWED.chain;
|
|
20640
20666
|
const why = refreshWhy(record, chain, hold);
|
|
@@ -20644,6 +20670,7 @@ function refreshOutput(kctx, pixi, matrices, record, view, hold) {
|
|
|
20644
20670
|
}
|
|
20645
20671
|
const inputs = firstInputs(record.slots)?.inputs;
|
|
20646
20672
|
if (inputs === void 0 && record.s2Of !== void 0) releaseInputs(kctx, record);
|
|
20673
|
+
record.direct = false;
|
|
20647
20674
|
if (!unfit && enterShadeWhenDue(kctx, pixi, record, owed, fits)) {
|
|
20648
20675
|
redrawShade(kctx, pixi, matrices, record);
|
|
20649
20676
|
return false;
|
|
@@ -20654,7 +20681,6 @@ function refreshOutput(kctx, pixi, matrices, record, view, hold) {
|
|
|
20654
20681
|
padding: NOW.P
|
|
20655
20682
|
});
|
|
20656
20683
|
noteTake(kctx, record, why);
|
|
20657
|
-
record.direct = false;
|
|
20658
20684
|
renderStage3(kctx, pixi, matrices, record, NOW);
|
|
20659
20685
|
account(kctx, record);
|
|
20660
20686
|
if (!chain) kctx.state.refreshesOpen += 1;
|
|
@@ -20691,7 +20717,8 @@ function redrawShade(kctx, pixi, matrices, record) {
|
|
|
20691
20717
|
/**
|
|
20692
20718
|
* Counts an output owed by a record on its sprite, and puts the record on its mesh when it is due: stage 3 alone was owed
|
|
20693
20719
|
* more than `QUAD_AFTER` times without a gap of `CALM_AFTER` frames, and it fits. The gap rule, not a reset on a quiet
|
|
20694
|
-
* frame: a tween that writes every second frame reaches the mode.
|
|
20720
|
+
* frame: a tween that writes every second frame reaches the mode. Under a filter nothing is counted: it may draw no other
|
|
20721
|
+
* way. A shaded record counts nothing.
|
|
20695
20722
|
*
|
|
20696
20723
|
* @param kctx - The kept context.
|
|
20697
20724
|
* @param pixi - The module that draws.
|
|
@@ -20706,9 +20733,7 @@ function enterShadeWhenDue(kctx, pixi, record, owed, fits) {
|
|
|
20706
20733
|
record.outputRuns = frame - record.outputAt > 8 ? 1 : record.outputRuns + 1;
|
|
20707
20734
|
record.outputAt = frame;
|
|
20708
20735
|
const quad = enabledSlot(record.slots)?.quad;
|
|
20709
|
-
|
|
20710
|
-
const ranLong = record.outputRuns > 2;
|
|
20711
|
-
if (!outputAlone || !fits || !ranLong || quad === void 0) return false;
|
|
20736
|
+
if (!(NOW.under || owed === OWED.output && record.outputRuns > 2) || !fits || quad === void 0) return false;
|
|
20712
20737
|
return enterShade(kctx, pixi, record, quad, NOW);
|
|
20713
20738
|
}
|
|
20714
20739
|
/**
|
|
@@ -20725,7 +20750,8 @@ function shadedCalm(state, record) {
|
|
|
20725
20750
|
* A shaded record that owes nothing and stood `QUAD_CALM` frames goes back to its sprite (F126 stage 2): a resting mesh
|
|
20726
20751
|
* runs the whole body every frame. Under `limitLeft`, shared with the refining and the settle, it stays shaded in a frame
|
|
20727
20752
|
* the limit is spent. It counts as a refresh. The pixels do not change, so the pass marks nothing above; a stack whose
|
|
20728
|
-
* resolution moved under a held step is taken whole, as `refresh` takes it, and that does change them.
|
|
20753
|
+
* resolution moved under a held step is taken whole, as `refresh` takes it, and that does change them. Under a filter
|
|
20754
|
+
* it stays: its clock starts over, so a calm frame leaves it alone until it comes round again.
|
|
20729
20755
|
*
|
|
20730
20756
|
* @param kctx - The kept context.
|
|
20731
20757
|
* @param pixi - The module that draws.
|
|
@@ -20737,6 +20763,7 @@ function shadedCalm(state, record) {
|
|
|
20737
20763
|
*/
|
|
20738
20764
|
function leaveAtRest(kctx, pixi, matrices, record, view, hold) {
|
|
20739
20765
|
const { state } = kctx;
|
|
20766
|
+
if (shadedCalm(state, record) && NOW.under) record.shadedAt = state.frame;
|
|
20740
20767
|
if (!shadedCalm(state, record) || !limitLeft(kctx)) return false;
|
|
20741
20768
|
leaveShade(record);
|
|
20742
20769
|
if (hold && record.key[KEY.rs] !== NOW.rs) {
|
|
@@ -20870,6 +20897,7 @@ function stepRecord(kctx, pixi, matrices, record, view) {
|
|
|
20870
20897
|
record.idleSeen = false;
|
|
20871
20898
|
}
|
|
20872
20899
|
readStack(record.slots, pixi.AlphaFilter, NOW);
|
|
20900
|
+
NOW.under = false;
|
|
20873
20901
|
const why = eligible(kctx, record, view, NOW);
|
|
20874
20902
|
if (why === 0) stepEligible(kctx, pixi, matrices, record, view);
|
|
20875
20903
|
else stepIneligible(kctx, record, view, why);
|
|
@@ -21007,6 +21035,8 @@ function bypassRecord(kctx, record, view, live) {
|
|
|
21007
21035
|
* logged, every record goes live and every range is owed a render (the policy takes them again). The call site guards
|
|
21008
21036
|
* it inline, so a production bundle drops this module.
|
|
21009
21037
|
*/
|
|
21038
|
+
/** What the read of the live frame answers when the frame is not compared. */
|
|
21039
|
+
const PLACE_DIFFERS = "place";
|
|
21010
21040
|
/**
|
|
21011
21041
|
* Tells whether a kept record's quad stands off its picture's grid: it is moving, drawn scaled to another linear part
|
|
21012
21042
|
* than at the take (F67), or drawn at another resolution than the canvas after a step (F126), and sampled linearly
|
|
@@ -21036,6 +21066,81 @@ function faded(record) {
|
|
|
21036
21066
|
return false;
|
|
21037
21067
|
}
|
|
21038
21068
|
/**
|
|
21069
|
+
* Where a filter pass starts on one axis, as Pixi works it out (`FilterSystem._calculateFilterBounds`): the bounds cut to
|
|
21070
|
+
* the canvas while the stack clips to it, floored to the pass's grid, then padded. Pure.
|
|
21071
|
+
*
|
|
21072
|
+
* @param start - The bounds' start on the canvas, CSS px.
|
|
21073
|
+
* @param resolution - The pass's resolution.
|
|
21074
|
+
* @param padding - The pass's padding, whole px.
|
|
21075
|
+
* @param clipped - Every enabled filter of the stack has `clipToViewport` on.
|
|
21076
|
+
* @returns The pass's start, CSS px.
|
|
21077
|
+
* @example
|
|
21078
|
+
* ```ts
|
|
21079
|
+
* passStart(-5, 1, 8, true); // -8
|
|
21080
|
+
* ```
|
|
21081
|
+
*/
|
|
21082
|
+
function passStart(start, resolution, padding, clipped) {
|
|
21083
|
+
return Math.floor((clipped ? Math.max(start, 0) : start) * resolution) / resolution - padding;
|
|
21084
|
+
}
|
|
21085
|
+
/**
|
|
21086
|
+
* The box a filter pass over a node measures, on the node's own axes: its filter area when it holds one, which replaces
|
|
21087
|
+
* the bounds, else what its subtree draws. Read with every picture live: the tree then holds the views, not their quads,
|
|
21088
|
+
* which stand padded.
|
|
21089
|
+
*
|
|
21090
|
+
* @param pixi - The module that draws.
|
|
21091
|
+
* @param node - The node.
|
|
21092
|
+
* @returns The box.
|
|
21093
|
+
*/
|
|
21094
|
+
function passBox(pixi, node) {
|
|
21095
|
+
const area = node.filterArea;
|
|
21096
|
+
if (area === null || area === void 0) return drawnBounds(pixi, node);
|
|
21097
|
+
const { x, y, width, height } = area;
|
|
21098
|
+
return {
|
|
21099
|
+
minX: x,
|
|
21100
|
+
minY: y,
|
|
21101
|
+
maxX: x + width,
|
|
21102
|
+
maxY: y + height
|
|
21103
|
+
};
|
|
21104
|
+
}
|
|
21105
|
+
/**
|
|
21106
|
+
* Tells whether a filter pass over a node starts off the canvas origin.
|
|
21107
|
+
*
|
|
21108
|
+
* @param kctx - The kept context.
|
|
21109
|
+
* @param pixi - The module that draws.
|
|
21110
|
+
* @param node - The node.
|
|
21111
|
+
* @param filters - Its enabled filters.
|
|
21112
|
+
* @returns True when it does.
|
|
21113
|
+
*/
|
|
21114
|
+
function passOffOrigin(kctx, pixi, node, filters) {
|
|
21115
|
+
const canvasResolution = kctx.host.resolution();
|
|
21116
|
+
const resolutions = filters.map(({ resolution }) => resolution === "inherit" ? canvasResolution : resolution);
|
|
21117
|
+
const resolution = Math.min(...resolutions);
|
|
21118
|
+
const clipped = filters.every((filter) => filter.clipToViewport);
|
|
21119
|
+
const padding = Math.trunc(filters.reduce((sum, filter) => sum + filter.padding, 0));
|
|
21120
|
+
const { a, b, c, d, tx, ty } = node.getGlobalTransform(new pixi.Matrix(), false);
|
|
21121
|
+
const box = linearBounds(a, b, c, d, passBox(pixi, node));
|
|
21122
|
+
return passStart(tx + box.x0, resolution, padding, clipped) !== 0 || passStart(ty + box.y0, resolution, padding, clipped) !== 0;
|
|
21123
|
+
}
|
|
21124
|
+
/**
|
|
21125
|
+
* Tells whether a shaded placed record hangs under a filter whose pass starts off the canvas origin. Live, its body
|
|
21126
|
+
* reads a place relative to that pass's texture; on the mesh it reads the canvas (spec 23 P8.3). The two differ by that
|
|
21127
|
+
* origin by design, not by a stale picture. Only the closest filter counts: Pixi offsets by that one alone. Read with
|
|
21128
|
+
* every picture live: a kept ancestor's filters are back on its top, and the views are back in the tree.
|
|
21129
|
+
*
|
|
21130
|
+
* @param kctx - The kept context.
|
|
21131
|
+
* @param record - The record, kept.
|
|
21132
|
+
* @returns True when the frame is not compared.
|
|
21133
|
+
*/
|
|
21134
|
+
function placeDiffers(kctx, record) {
|
|
21135
|
+
const pixi = kctx.host.pixi();
|
|
21136
|
+
if (!record.shaded || record.category !== "placed" || pixi === void 0) return false;
|
|
21137
|
+
for (let node = record.top.parent; node !== null; node = node.parent) {
|
|
21138
|
+
const filters = node.filters?.filter((filter) => filter.enabled) ?? [];
|
|
21139
|
+
if (filters.length > 0) return passOffOrigin(kctx, pixi, node, filters);
|
|
21140
|
+
}
|
|
21141
|
+
return false;
|
|
21142
|
+
}
|
|
21143
|
+
/**
|
|
21039
21144
|
* Tells whether the padded picture of a kept record reaches past the canvas edge, where Pixi clips the live filter.
|
|
21040
21145
|
*
|
|
21041
21146
|
* @param record - The record, kept.
|
|
@@ -21124,9 +21229,9 @@ function logStale(kctx, pixels, records, ranges) {
|
|
|
21124
21229
|
}
|
|
21125
21230
|
/**
|
|
21126
21231
|
* The pixel leg after a drawn frame: the picture as drawn against the same frame with every picture live. Frames in
|
|
21127
|
-
* which a picture moves off its grid, was drawn at another resolution (F126), is translucent itself (F120)
|
|
21128
|
-
* under a translucent ancestor (F113)
|
|
21129
|
-
* compared.
|
|
21232
|
+
* which a picture moves off its grid, was drawn at another resolution (F126), is translucent itself (F120), hangs
|
|
21233
|
+
* under a translucent ancestor (F113) or reads its place under a filter off the canvas origin are skipped and counted;
|
|
21234
|
+
* at rest, opaque, under opaque ancestors every picture is compared.
|
|
21130
21235
|
*
|
|
21131
21236
|
* @param kctx - The kept context.
|
|
21132
21237
|
* @param bypass - Draws every kept record live (true) or as its picture again (false).
|
|
@@ -21144,7 +21249,11 @@ function verifyPictures(kctx, bypass, recover) {
|
|
|
21144
21249
|
const resolution = host.resolution();
|
|
21145
21250
|
const drawn = host.pixels(resolution);
|
|
21146
21251
|
if (drawn === void 0) return;
|
|
21147
|
-
const live = drawLive(kctx, bypass, () => host.pixels(resolution));
|
|
21252
|
+
const live = drawLive(kctx, bypass, () => records.some((record) => placeDiffers(kctx, record)) ? PLACE_DIFFERS : host.pixels(resolution));
|
|
21253
|
+
if (live === PLACE_DIFFERS) {
|
|
21254
|
+
state.verifySkipped += 1;
|
|
21255
|
+
return;
|
|
21256
|
+
}
|
|
21148
21257
|
if (live === void 0 || live.length !== drawn.length) return;
|
|
21149
21258
|
const screen = host.screen();
|
|
21150
21259
|
const width = screen === void 0 ? 0 : Math.round(screen.width * resolution);
|
|
@@ -27767,8 +27876,11 @@ function renderPassesOf(state, kept) {
|
|
|
27767
27876
|
* ends the warm-up of the application: a throw inside Pixi's render leaves its filter stack unbalanced, which no public
|
|
27768
27877
|
* API rebalances, so another probe would only throw again. A filter handed over with its quad draws a mesh of that
|
|
27769
27878
|
* program after it, on WebGPU, inside an error scope: a quad program that does not fit its pipeline fails asynchronously,
|
|
27770
|
-
* as a blank view with nothing in the logs, and this is the one place such a fault can be seen.
|
|
27771
|
-
*
|
|
27879
|
+
* as a blank view with nothing in the logs, and this is the one place such a fault can be seen. A mesh draws onto the
|
|
27880
|
+
* canvas, or inside an outer filter pass or picture, whose target holds no stencil: another pipeline. The texture of the
|
|
27881
|
+
* texture variants cannot make it (a clip gave it a stencil for good), so that draw goes into a second texture no clip
|
|
27882
|
+
* ever draws into, in the frame of the first. The end of a run reaches the monitor through `onWarm`; this file never
|
|
27883
|
+
* imports the monitor (LEAD-FIXES-3 O24).
|
|
27772
27884
|
*/
|
|
27773
27885
|
/** The side of every probe, in CSS pixels: the smallest thing that still draws a triangle. */
|
|
27774
27886
|
const PROBE_SIZE = 4;
|
|
@@ -27803,6 +27915,8 @@ const TEXTURE_VARIANTS = Object.freeze(["texture", "texture+clip"]);
|
|
|
27803
27915
|
const CANVAS_VARIANT = Object.freeze(["canvas"]);
|
|
27804
27916
|
/** WebGL on a canvas that is not cleared: the one variant that leaves no pixel. */
|
|
27805
27917
|
const TEXTURE_VARIANT = Object.freeze(["texture"]);
|
|
27918
|
+
/** The second draw of a quad: a target with no stencil, as an outer filter pass or a picture is. */
|
|
27919
|
+
const PLAIN_VARIANT = Object.freeze(["plain"]);
|
|
27806
27920
|
/**
|
|
27807
27921
|
* The per-particle properties `effects` uploads every frame: the vertex layout its particle pipeline is keyed by.
|
|
27808
27922
|
*
|
|
@@ -27874,6 +27988,13 @@ function buildObjects(pixi) {
|
|
|
27874
27988
|
autoGarbageCollect: false,
|
|
27875
27989
|
label: "renderer.warm.texture"
|
|
27876
27990
|
});
|
|
27991
|
+
const plain = pixi.RenderTexture.create({
|
|
27992
|
+
width: PROBE_SIZE,
|
|
27993
|
+
height: PROBE_SIZE,
|
|
27994
|
+
antialias: false,
|
|
27995
|
+
autoGarbageCollect: false,
|
|
27996
|
+
label: "renderer.warm.plain"
|
|
27997
|
+
});
|
|
27877
27998
|
const holder = new pixi.Container();
|
|
27878
27999
|
const graphics = new pixi.Graphics().rect(0, 0, PROBE_SIZE, PROBE_SIZE).fill(16777215);
|
|
27879
28000
|
root.label = "renderer.warm";
|
|
@@ -27890,6 +28011,7 @@ function buildObjects(pixi) {
|
|
|
27890
28011
|
clip,
|
|
27891
28012
|
mask,
|
|
27892
28013
|
target,
|
|
28014
|
+
plain,
|
|
27893
28015
|
holder,
|
|
27894
28016
|
list: [],
|
|
27895
28017
|
sprite: whiteSprite(pixi),
|
|
@@ -27959,6 +28081,7 @@ function dropObjects(warm) {
|
|
|
27959
28081
|
];
|
|
27960
28082
|
for (const node of nodes) node?.destroy({ children: true });
|
|
27961
28083
|
destroyWhole(objects.target);
|
|
28084
|
+
destroyWhole(objects.plain);
|
|
27962
28085
|
}
|
|
27963
28086
|
/**
|
|
27964
28087
|
* Logs one warning once per key: a probe tree Pixi could not build, or the canvas variants left out.
|
|
@@ -28002,8 +28125,8 @@ function enqueue$1(warm, subject, variants) {
|
|
|
28002
28125
|
});
|
|
28003
28126
|
}
|
|
28004
28127
|
/**
|
|
28005
|
-
* Queues the draws of a filter, then the
|
|
28006
|
-
* filter alone.
|
|
28128
|
+
* Queues the draws of a filter, then the two of its quad: one for the canvas, one for a target with no stencil. A quad
|
|
28129
|
+
* program is a WebGPU program: WebGL draws the filter alone.
|
|
28007
28130
|
*
|
|
28008
28131
|
* @param sctx - Domain context of the sync module.
|
|
28009
28132
|
* @param filter - The filter.
|
|
@@ -28020,7 +28143,11 @@ function enqueueFilter(sctx, filter, variants) {
|
|
|
28020
28143
|
filter,
|
|
28021
28144
|
quad
|
|
28022
28145
|
}, once);
|
|
28023
|
-
|
|
28146
|
+
enqueue$1(warm, {
|
|
28147
|
+
filter,
|
|
28148
|
+
quad
|
|
28149
|
+
}, PLAIN_VARIANT);
|
|
28150
|
+
return variants.length + once.length + PLAIN_VARIANT.length;
|
|
28024
28151
|
}
|
|
28025
28152
|
/**
|
|
28026
28153
|
* Tells whether the renderer can warm anything now: the config asks for draws, a device draws, and no probe threw on
|
|
@@ -28317,14 +28444,14 @@ function drawProbe(sctx, pixi, objects, draw) {
|
|
|
28317
28444
|
const node = nodeOf$1(pixi, warm, objects, draw.subject);
|
|
28318
28445
|
if (node === void 0) return true;
|
|
28319
28446
|
const clipped = draw.variant === "canvas+clip" || draw.variant === "texture+clip";
|
|
28320
|
-
const
|
|
28447
|
+
const target = draw.variant === "texture" || draw.variant === "texture+clip" ? objects.target : void 0;
|
|
28321
28448
|
if (clipped) {
|
|
28322
28449
|
objects.clip.addChild(node);
|
|
28323
28450
|
objects.root.addChild(objects.clipFrame);
|
|
28324
28451
|
} else objects.root.addChild(node);
|
|
28325
28452
|
const scope = openScope(sctx, draw.subject);
|
|
28326
28453
|
try {
|
|
28327
|
-
sctx.deps.host.renderProbe(objects.root,
|
|
28454
|
+
sctx.deps.host.renderProbe(objects.root, draw.variant === "plain" ? objects.plain : target);
|
|
28328
28455
|
return true;
|
|
28329
28456
|
} catch (error) {
|
|
28330
28457
|
failWarm(sctx, draw, error);
|
|
@@ -28385,10 +28512,31 @@ function objectsOf$1(sctx, pixi) {
|
|
|
28385
28512
|
}
|
|
28386
28513
|
}
|
|
28387
28514
|
/**
|
|
28388
|
-
*
|
|
28389
|
-
*
|
|
28390
|
-
*
|
|
28391
|
-
*
|
|
28515
|
+
* Tells whether the next draw of the queue goes with the one before it: a quad's draw into the plain texture.
|
|
28516
|
+
*
|
|
28517
|
+
* @param warm - The warm branch of the sync state.
|
|
28518
|
+
* @returns True when it asks for no frame of its own.
|
|
28519
|
+
*/
|
|
28520
|
+
function ridesAlong(warm) {
|
|
28521
|
+
return warm.queue[warm.head]?.variant === "plain";
|
|
28522
|
+
}
|
|
28523
|
+
/**
|
|
28524
|
+
* Tells whether a warm frame draws one more probe: one is queued, and the budget has room or it asks for none.
|
|
28525
|
+
*
|
|
28526
|
+
* @param warm - The warm branch of the sync state.
|
|
28527
|
+
* @param drawn - The draws of this frame so far.
|
|
28528
|
+
* @param budget - `renderer.warm`.
|
|
28529
|
+
* @returns True when it does.
|
|
28530
|
+
*/
|
|
28531
|
+
function wantsDraw(warm, drawn, budget) {
|
|
28532
|
+
return warm.head < warm.queue.length && (drawn < budget || ridesAlong(warm));
|
|
28533
|
+
}
|
|
28534
|
+
/**
|
|
28535
|
+
* Draws up to `renderer.warm` probes before the stage pass of a drawn frame, and the plain draw of a quad with the draw
|
|
28536
|
+
* before it; answers whether it drew any, so the frame is told to `time` as a probed one. A draw is counted only after
|
|
28537
|
+
* its own render call ran; a queue that still holds draws asks for the next frame; a probe that threw ends the warm-up
|
|
28538
|
+
* there. Allocates nothing while the queue is empty, and nothing but Pixi's own work on a warm frame: the probe tree is
|
|
28539
|
+
* made once per device.
|
|
28392
28540
|
*
|
|
28393
28541
|
* @param sctx - Domain context of the sync module.
|
|
28394
28542
|
* @returns True when a probe was drawn in this frame.
|
|
@@ -28401,7 +28549,7 @@ function warmStep(sctx) {
|
|
|
28401
28549
|
if (pixi === void 0 || objects === void 0) return false;
|
|
28402
28550
|
const budget = sctx.ctx.config.warm;
|
|
28403
28551
|
let drawn = 0;
|
|
28404
|
-
while (drawn
|
|
28552
|
+
while (wantsDraw(warm, drawn, budget)) {
|
|
28405
28553
|
const draw = warm.queue[warm.head];
|
|
28406
28554
|
warm.head += 1;
|
|
28407
28555
|
if (draw === void 0) continue;
|
|
@@ -43305,11 +43453,11 @@ function swapIn(ctx, scene, named, build) {
|
|
|
43305
43453
|
* in. An abort of the node discards the build and leaves the world as it stood.
|
|
43306
43454
|
*/
|
|
43307
43455
|
/** A second in ms: the frame interval is this over the frame rate. */
|
|
43308
|
-
const SECOND_MS
|
|
43456
|
+
const SECOND_MS = 1e3;
|
|
43309
43457
|
/** The share of a frame interval `"auto"` gives the building work: two thirds. */
|
|
43310
43458
|
const BUILD_SHARE = 2 / 3;
|
|
43311
43459
|
/** The frame interval when `time` answers no usable frame rate: a 60 Hz frame, ≈ 16.7 ms. */
|
|
43312
|
-
const FALLBACK_FRAME_MS = SECOND_MS
|
|
43460
|
+
const FALLBACK_FRAME_MS = SECOND_MS / 60;
|
|
43313
43461
|
/**
|
|
43314
43462
|
* The frames past the counter at the look's start a floor asks for: `signals` runs before `render`, so a swap in the
|
|
43315
43463
|
* 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 +43500,7 @@ function agentNow(ctx) {
|
|
|
43352
43500
|
*/
|
|
43353
43501
|
function frameMsOf(ctx) {
|
|
43354
43502
|
const { fps } = ctx.deps.time.rate();
|
|
43355
|
-
return isPositiveFinite(fps) ? SECOND_MS
|
|
43503
|
+
return isPositiveFinite(fps) ? SECOND_MS / fps : FALLBACK_FRAME_MS;
|
|
43356
43504
|
}
|
|
43357
43505
|
/**
|
|
43358
43506
|
* The building budget of a frame for a build that starts now: the number a game configured, or
|
|
@@ -57299,91 +57447,6 @@ function layoutRuns(runs, style, tables, options, box = 0) {
|
|
|
57299
57447
|
};
|
|
57300
57448
|
}
|
|
57301
57449
|
//#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
57450
|
//#region src/plugins/text/tags.ts
|
|
57388
57451
|
/** Matches an opening colour tag. Six hex digits: `#rgb` is not accepted. */
|
|
57389
57452
|
const COLOR_TAG = /^color=#([\da-f]{6})$/i;
|
|
@@ -57769,12 +57832,59 @@ function boundValue(ctx, entity, bind, frame) {
|
|
|
57769
57832
|
*/
|
|
57770
57833
|
function formatOf(ctx, entity, bind, value) {
|
|
57771
57834
|
if (isTextFormat(bind.format) && Number.isFinite(value)) return bind.format;
|
|
57835
|
+
warnBadFormat(ctx, entity, bind);
|
|
57836
|
+
return "int";
|
|
57837
|
+
}
|
|
57838
|
+
/**
|
|
57839
|
+
* Reports a bind that names no format, or a value that is not finite, once per entity.
|
|
57840
|
+
*
|
|
57841
|
+
* @param ctx - Domain context of the text plugin.
|
|
57842
|
+
* @param entity - The entity the label sits on.
|
|
57843
|
+
* @param bind - What the label carries.
|
|
57844
|
+
*/
|
|
57845
|
+
function warnBadFormat(ctx, entity, bind) {
|
|
57772
57846
|
warnOnce(ctx, `bind-format:${entity}`, "text: bad bind format", {
|
|
57773
57847
|
component: bind.component,
|
|
57774
57848
|
field: bind.field,
|
|
57775
57849
|
format: bind.format
|
|
57776
57850
|
});
|
|
57777
|
-
|
|
57851
|
+
}
|
|
57852
|
+
/**
|
|
57853
|
+
* Asks a format a feature registered. A format that throws is reported once per name.
|
|
57854
|
+
*
|
|
57855
|
+
* @param ctx - Domain context of the text plugin.
|
|
57856
|
+
* @param name - The name it was registered under.
|
|
57857
|
+
* @param format - The function.
|
|
57858
|
+
* @param value - The whole value.
|
|
57859
|
+
* @returns What it answered, or `undefined` when it threw.
|
|
57860
|
+
*/
|
|
57861
|
+
function askFormat(ctx, name, format, value) {
|
|
57862
|
+
try {
|
|
57863
|
+
return format(value);
|
|
57864
|
+
} catch (error) {
|
|
57865
|
+
warnOnce(ctx, `bind-format-threw:${name}`, "text: bind format threw", {
|
|
57866
|
+
format: name,
|
|
57867
|
+
error
|
|
57868
|
+
});
|
|
57869
|
+
return;
|
|
57870
|
+
}
|
|
57871
|
+
}
|
|
57872
|
+
/**
|
|
57873
|
+
* What a format a feature registered answers for a number, before any label shows it.
|
|
57874
|
+
*
|
|
57875
|
+
* @param ctx - Domain context of the text plugin.
|
|
57876
|
+
* @param name - The format name.
|
|
57877
|
+
* @param value - The number; rounded as `"int"` rounds it.
|
|
57878
|
+
* @returns The string and the style, or `undefined` for a name no feature registered and for a
|
|
57879
|
+
* format that threw.
|
|
57880
|
+
*/
|
|
57881
|
+
function formattedBy(ctx, name, value) {
|
|
57882
|
+
const format = ctx.state.formats.get(name);
|
|
57883
|
+
const answer = format === void 0 ? void 0 : askFormat(ctx, name, format, wholeValue(value));
|
|
57884
|
+
return answer === void 0 ? void 0 : {
|
|
57885
|
+
text: sourceOf(ctx, answer.content),
|
|
57886
|
+
style: answer.style
|
|
57887
|
+
};
|
|
57778
57888
|
}
|
|
57779
57889
|
/**
|
|
57780
57890
|
* The key of a bind, so a changed binding or format is seen as a change. Built once per attached
|
|
@@ -57810,13 +57920,14 @@ function isSameBind(seen, bind) {
|
|
|
57810
57920
|
* @param text - Its component value.
|
|
57811
57921
|
* @param frame - What this run of the system shares.
|
|
57812
57922
|
* @param unit - What a bound label's string was built from; `undefined` for any other label.
|
|
57923
|
+
* @param style - The style the label shows: the one a format answered may be newer than `text`.
|
|
57813
57924
|
*/
|
|
57814
|
-
function remember(ctx, entity, text, frame, unit) {
|
|
57925
|
+
function remember(ctx, entity, text, frame, unit, style = text.style) {
|
|
57815
57926
|
const seen = ctx.state.seen.get(entity);
|
|
57816
57927
|
if (seen === void 0) {
|
|
57817
57928
|
ctx.state.seen.set(entity, {
|
|
57818
57929
|
content: text.content,
|
|
57819
|
-
style
|
|
57930
|
+
style,
|
|
57820
57931
|
bindRef: text.bind,
|
|
57821
57932
|
bind: bindKeyOf(text.bind),
|
|
57822
57933
|
locale: frame.locale,
|
|
@@ -57830,7 +57941,7 @@ function remember(ctx, entity, text, frame, unit) {
|
|
|
57830
57941
|
seen.bind = bindKeyOf(text.bind);
|
|
57831
57942
|
}
|
|
57832
57943
|
seen.content = text.content;
|
|
57833
|
-
seen.style =
|
|
57944
|
+
seen.style = style;
|
|
57834
57945
|
seen.locale = frame.locale;
|
|
57835
57946
|
seen.unit = unit;
|
|
57836
57947
|
seen.box = text.box;
|
|
@@ -57869,17 +57980,18 @@ function keepSize(ctx, entity, layout) {
|
|
|
57869
57980
|
}
|
|
57870
57981
|
/**
|
|
57871
57982
|
* Tells whether a bound label already shows what its value would build: the same unit, style and
|
|
57872
|
-
* binding, and for a
|
|
57983
|
+
* binding, and for a format whose words depend on the language, the same locale. Reads and
|
|
57984
|
+
* compares: no key is built, nothing is kept, no format is called.
|
|
57873
57985
|
*
|
|
57874
57986
|
* @param seen - What was resolved for the label last.
|
|
57875
57987
|
* @param text - Its component value.
|
|
57876
57988
|
* @param unit - The unit of the value this frame.
|
|
57877
|
-
* @param
|
|
57989
|
+
* @param worded - Whether the shown string depends on the locale: a `"duration"` or a named format.
|
|
57878
57990
|
* @param frame - What this run of the system shares.
|
|
57879
57991
|
* @returns True when nothing has to be formatted or written.
|
|
57880
57992
|
*/
|
|
57881
|
-
function isShown(seen, text, unit,
|
|
57882
|
-
return seen.unit === unit && seen.style === text.style && isSameBind(seen, text.bind) && (
|
|
57993
|
+
function isShown(seen, text, unit, worded, frame) {
|
|
57994
|
+
return seen.unit === unit && seen.style === text.style && isSameBind(seen, text.bind) && (!worded || seen.locale === frame.locale);
|
|
57883
57995
|
}
|
|
57884
57996
|
/**
|
|
57885
57997
|
* Writes the new string of a bound label, its measured size, and for a countdown the time left,
|
|
@@ -57890,14 +58002,19 @@ function isShown(seen, text, unit, format, frame) {
|
|
|
57890
58002
|
* @param text - Its component value.
|
|
57891
58003
|
* @param next - The string the label shows now.
|
|
57892
58004
|
* @param value - The bound number, the time left for a countdown.
|
|
58005
|
+
* @param style - The style it shows it in: another one only for what a named format answered.
|
|
57893
58006
|
*/
|
|
57894
|
-
function showBound(ctx, entity, text, next, value) {
|
|
57895
|
-
const
|
|
58007
|
+
function showBound(ctx, entity, text, next, value, style = text.style) {
|
|
58008
|
+
const restyled = style !== text.style;
|
|
58009
|
+
const changed = restyled || next !== text.resolved;
|
|
57896
58010
|
if (changed) {
|
|
57897
|
-
ctx.deps.world.ecs.set(entity, Text,
|
|
58011
|
+
ctx.deps.world.ecs.set(entity, Text, restyled ? {
|
|
58012
|
+
resolved: next,
|
|
58013
|
+
style
|
|
58014
|
+
} : { resolved: next });
|
|
57898
58015
|
if (value !== void 0 && text.bind !== void 0 && isCountdownLeft(text.bind)) ctx.deps.world.ecs.set(entity, Countdown, { left: value });
|
|
57899
58016
|
}
|
|
57900
|
-
if (changed || !ctx.state.measured.has(entity)) keepSize(ctx, entity, layoutFor(ctx, next,
|
|
58017
|
+
if (changed || !ctx.state.measured.has(entity)) keepSize(ctx, entity, layoutFor(ctx, next, style, text.box));
|
|
57901
58018
|
}
|
|
57902
58019
|
/**
|
|
57903
58020
|
* Writes the string a bound label already shows once more, and measures it again. A mark on a
|
|
@@ -57931,7 +58048,8 @@ function warnWithoutDigits(ctx, styleName) {
|
|
|
57931
58048
|
* nothing: no tag is parsed, no key is built. A marked label that stands still is written once
|
|
57932
58049
|
* with the string it shows; one of a `"box"` style that ui laid out at another box is measured at
|
|
57933
58050
|
* 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.
|
|
58051
|
+
* builds no warning key per frame. A bind that names a format a feature registered goes its own
|
|
58052
|
+
* way; the name is looked up only after it proved none of the four built-in ones.
|
|
57935
58053
|
*
|
|
57936
58054
|
* @param ctx - Domain context of the text plugin.
|
|
57937
58055
|
* @param entity - The entity.
|
|
@@ -57941,11 +58059,17 @@ function warnWithoutDigits(ctx, styleName) {
|
|
|
57941
58059
|
*/
|
|
57942
58060
|
function stepBound(ctx, entity, text, bind, frame) {
|
|
57943
58061
|
const value = boundValue(ctx, entity, bind, frame);
|
|
58062
|
+
const named = isTextFormat(bind.format) ? void 0 : ctx.state.formats.get(bind.format);
|
|
58063
|
+
if (named !== void 0) {
|
|
58064
|
+
stepNamed(ctx, entity, text, bind, named, value, frame);
|
|
58065
|
+
return;
|
|
58066
|
+
}
|
|
57944
58067
|
const format = value === void 0 ? "int" : formatOf(ctx, entity, bind, value);
|
|
57945
58068
|
const unit = value === void 0 ? void 0 : unitOf(value, format);
|
|
57946
58069
|
const marked = ctx.state.dirty.delete(entity);
|
|
57947
58070
|
const seen = ctx.state.seen.get(entity);
|
|
57948
|
-
if (seen !== void 0 && isShown(seen, text, unit, format, frame)) {
|
|
58071
|
+
if (seen !== void 0 && isShown(seen, text, unit, format === "duration", frame)) {
|
|
58072
|
+
if (marked) warnWithoutDigits(ctx, text.style);
|
|
57949
58073
|
standStill(ctx, entity, text, seen, marked);
|
|
57950
58074
|
return;
|
|
57951
58075
|
}
|
|
@@ -57954,6 +58078,39 @@ function stepBound(ctx, entity, text, bind, frame) {
|
|
|
57954
58078
|
remember(ctx, entity, text, frame, unit);
|
|
57955
58079
|
}
|
|
57956
58080
|
/**
|
|
58081
|
+
* One frame of a label whose bind names a format a feature registered. Its unit is the whole value.
|
|
58082
|
+
* While that, the locale, the bind and the style stand the frame is reads and compares: the format
|
|
58083
|
+
* is not called, a mark included, and nothing is kept. Else it is asked once, and its answer is
|
|
58084
|
+
* written only when it differs. The format picks the style, so no style is checked for digits. A
|
|
58085
|
+
* bound field that holds no number shows nothing, as under a built-in format.
|
|
58086
|
+
*
|
|
58087
|
+
* @param ctx - Domain context of the text plugin.
|
|
58088
|
+
* @param entity - The entity.
|
|
58089
|
+
* @param text - Its component value.
|
|
58090
|
+
* @param bind - What it carries: the name of the format.
|
|
58091
|
+
* @param format - The function of the format.
|
|
58092
|
+
* @param value - The number of this frame, when there is one.
|
|
58093
|
+
* @param frame - What this run of the system shares.
|
|
58094
|
+
*/
|
|
58095
|
+
function stepNamed(ctx, entity, text, bind, format, value, frame) {
|
|
58096
|
+
if (value !== void 0 && !Number.isFinite(value)) warnBadFormat(ctx, entity, bind);
|
|
58097
|
+
const unit = value === void 0 ? void 0 : wholeValue(value);
|
|
58098
|
+
const marked = ctx.state.dirty.delete(entity);
|
|
58099
|
+
const seen = ctx.state.seen.get(entity);
|
|
58100
|
+
if (seen !== void 0 && isShown(seen, text, unit, true, frame)) {
|
|
58101
|
+
standStill(ctx, entity, text, seen, marked);
|
|
58102
|
+
return;
|
|
58103
|
+
}
|
|
58104
|
+
const answer = unit === void 0 ? void 0 : askFormat(ctx, bind.format, format, unit);
|
|
58105
|
+
if (answer === void 0) {
|
|
58106
|
+
showBound(ctx, entity, text, unit === void 0 ? "" : String(unit), value);
|
|
58107
|
+
remember(ctx, entity, text, frame, unit);
|
|
58108
|
+
return;
|
|
58109
|
+
}
|
|
58110
|
+
showBound(ctx, entity, text, sourceOf(ctx, answer.content), value, answer.style);
|
|
58111
|
+
remember(ctx, entity, text, frame, unit, answer.style);
|
|
58112
|
+
}
|
|
58113
|
+
/**
|
|
57957
58114
|
* One frame of a bound label whose unit stands still: a marked one is written once as it is, one of
|
|
57958
58115
|
* a `"box"` style that ui laid out at another box is measured at it. Either way the box is noted.
|
|
57959
58116
|
*
|
|
@@ -57964,10 +58121,8 @@ function stepBound(ctx, entity, text, bind, frame) {
|
|
|
57964
58121
|
* @param marked - Whether the label was marked this frame.
|
|
57965
58122
|
*/
|
|
57966
58123
|
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));
|
|
58124
|
+
if (marked) showAgain(ctx, entity, text);
|
|
58125
|
+
else if (boxMoved(ctx, seen, text)) keepSize(ctx, entity, layoutFor(ctx, text.resolved, text.style, text.box));
|
|
57971
58126
|
else return;
|
|
57972
58127
|
seen.box = text.box;
|
|
57973
58128
|
}
|
|
@@ -58817,8 +58972,8 @@ function asContainer(object) {
|
|
|
58817
58972
|
//#region src/plugins/text/lifecycle.ts
|
|
58818
58973
|
/**
|
|
58819
58974
|
* @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.
|
|
58975
|
+
* feature descriptions and written again by the dev hot swap, the number formats read out of them
|
|
58976
|
+
* too, the four registrations `onStart` opens, and the teardown that closes exactly those.
|
|
58822
58977
|
*/
|
|
58823
58978
|
/** The owner of the two built-in styles, which no feature can collide with. */
|
|
58824
58979
|
const BUILT_IN = "text";
|
|
@@ -58888,6 +59043,57 @@ function buildStyles(ctx) {
|
|
|
58888
59043
|
}
|
|
58889
59044
|
}
|
|
58890
59045
|
/**
|
|
59046
|
+
* Tells whether a feature entry is a format map `text` can read.
|
|
59047
|
+
*
|
|
59048
|
+
* @param entry - What the feature put under its `textFormats` key.
|
|
59049
|
+
* @returns True when it carries a map of formats.
|
|
59050
|
+
*/
|
|
59051
|
+
function isFormatMap(entry) {
|
|
59052
|
+
return typeof entry === "object" && entry !== null && "kind" in entry && entry.kind === "textFormats" && "map" in entry && typeof entry.map === "object" && entry.map !== null;
|
|
59053
|
+
}
|
|
59054
|
+
/**
|
|
59055
|
+
* Tells whether an entry of a format map is a function. What it answers shows only when it runs.
|
|
59056
|
+
*
|
|
59057
|
+
* @param value - What the feature put under a format name.
|
|
59058
|
+
* @returns True for a function.
|
|
59059
|
+
*/
|
|
59060
|
+
function isFormatFunction(value) {
|
|
59061
|
+
return typeof value === "function";
|
|
59062
|
+
}
|
|
59063
|
+
/**
|
|
59064
|
+
* Refuses one entry of a feature's format map, or hands its function back.
|
|
59065
|
+
*
|
|
59066
|
+
* @param ctx - Domain context of the text plugin.
|
|
59067
|
+
* @param feature - The name of the feature that brought it.
|
|
59068
|
+
* @param name - The format name.
|
|
59069
|
+
* @param value - What the feature put under that name.
|
|
59070
|
+
* @returns The function.
|
|
59071
|
+
* @throws {Error} When the name is a built-in format, another feature's, or holds no function.
|
|
59072
|
+
*/
|
|
59073
|
+
function checkedFormat(ctx, feature, name, value) {
|
|
59074
|
+
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.`);
|
|
59075
|
+
const owner = ctx.state.formatOwner.get(name);
|
|
59076
|
+
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.`);
|
|
59077
|
+
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 }.`);
|
|
59078
|
+
return value;
|
|
59079
|
+
}
|
|
59080
|
+
/**
|
|
59081
|
+
* Fills the format table from every feature, in feature order.
|
|
59082
|
+
*
|
|
59083
|
+
* @param ctx - Domain context of the text plugin.
|
|
59084
|
+
* @throws {Error} When a name is a built-in format, two features define it, or it holds no function.
|
|
59085
|
+
*/
|
|
59086
|
+
function buildFormats(ctx) {
|
|
59087
|
+
for (const feature of ctx.deps.flow.features.all()) {
|
|
59088
|
+
const entry = feature.description.textFormats;
|
|
59089
|
+
if (!isFormatMap(entry)) continue;
|
|
59090
|
+
for (const [name, value] of Object.entries(entry.map)) {
|
|
59091
|
+
ctx.state.formats.set(name, checkedFormat(ctx, feature.name, name, value));
|
|
59092
|
+
ctx.state.formatOwner.set(name, feature.name);
|
|
59093
|
+
}
|
|
59094
|
+
}
|
|
59095
|
+
}
|
|
59096
|
+
/**
|
|
58891
59097
|
* Collects every font a style can draw with: the two of the config, then the regular, bold and
|
|
58892
59098
|
* italic font of every registered style.
|
|
58893
59099
|
*
|
|
@@ -58925,7 +59131,7 @@ function replaceStyles(ctx, styles) {
|
|
|
58925
59131
|
ctx.deps.time.wake();
|
|
58926
59132
|
}
|
|
58927
59133
|
/**
|
|
58928
|
-
* Opens what the plugin owns: the style table, the font keys, the layout system, the step after
|
|
59134
|
+
* Opens what the plugin owns: the style table, the number formats, the font keys, the layout system, the step after
|
|
58929
59135
|
* the layout flush, the two world hooks of `Text` and the display adapter. The step is a frame
|
|
58930
59136
|
* callback of phase `layout`: `world` registered its own in its `onStart`, which runs before this
|
|
58931
59137
|
* one (`text` depends on `world`), so the step runs after the world's layout phase and its flush,
|
|
@@ -58934,12 +59140,14 @@ function replaceStyles(ctx, styles) {
|
|
|
58934
59140
|
*
|
|
58935
59141
|
* @param ctx - Kernel context of the text plugin.
|
|
58936
59142
|
* @throws {Error} When two features define the same style name.
|
|
59143
|
+
* @throws {Error} When a number format is refused: see `buildFormats`.
|
|
58937
59144
|
*/
|
|
58938
59145
|
function startText(ctx) {
|
|
58939
59146
|
const tctx = withDeps$1(ctx);
|
|
58940
59147
|
const ecs = tctx.deps.world.ecs;
|
|
58941
59148
|
const frame = createTextFrame(tctx);
|
|
58942
59149
|
buildStyles(tctx);
|
|
59150
|
+
buildFormats(tctx);
|
|
58943
59151
|
collectFonts(tctx);
|
|
58944
59152
|
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
59153
|
forgetText(tctx.state, entity);
|
|
@@ -58958,6 +59166,8 @@ function stopText(state) {
|
|
|
58958
59166
|
state.removers.length = 0;
|
|
58959
59167
|
state.styles.clear();
|
|
58960
59168
|
state.styleOwner.clear();
|
|
59169
|
+
state.formats.clear();
|
|
59170
|
+
state.formatOwner.clear();
|
|
58961
59171
|
state.fontKeys.clear();
|
|
58962
59172
|
state.tables.clear();
|
|
58963
59173
|
state.installed.clear();
|
|
@@ -58974,13 +59184,14 @@ function stopText(state) {
|
|
|
58974
59184
|
//#endregion
|
|
58975
59185
|
//#region src/plugins/text/api.ts
|
|
58976
59186
|
/**
|
|
58977
|
-
* @file text plugin — API factory.
|
|
58978
|
-
* a glyph,
|
|
58979
|
-
*
|
|
59187
|
+
* @file text plugin — API factory. Five members: how big a piece of text is, whether a font has
|
|
59188
|
+
* a glyph, what a game's number format answers, which styles the game registered, and the dev hot
|
|
59189
|
+
* swap of a styles file. The domain context is built on the first call, because the kernel builds
|
|
59190
|
+
* the plugin APIs before every dependency is resolvable.
|
|
58980
59191
|
*/
|
|
58981
59192
|
/**
|
|
58982
|
-
* Creates the text API: `app.text.measure(...)`, `app.text.hasGlyph(...)`,
|
|
58983
|
-
* and `app.text.replaceStyles(...)`.
|
|
59193
|
+
* Creates the text API: `app.text.measure(...)`, `app.text.hasGlyph(...)`,
|
|
59194
|
+
* `app.text.formatted(...)`, `app.text.styles()` and `app.text.replaceStyles(...)`.
|
|
58984
59195
|
*
|
|
58985
59196
|
* @param ctx - Kernel context of the text plugin.
|
|
58986
59197
|
* @returns The plugin API.
|
|
@@ -58998,6 +59209,7 @@ function createTextApi(ctx) {
|
|
|
58998
59209
|
return sizeOf(layoutFor(tctx, sourceOf(tctx, content), style, width));
|
|
58999
59210
|
},
|
|
59000
59211
|
hasGlyph: (char, style) => hasGlyphOf(text(), char, style),
|
|
59212
|
+
formatted: (name, value) => formattedBy(text(), name, value),
|
|
59001
59213
|
styles: () => Object.freeze([...ctx.state.styles.keys()]),
|
|
59002
59214
|
replaceStyles: (styles) => {
|
|
59003
59215
|
replaceStyles(text(), styles);
|
|
@@ -59110,6 +59322,8 @@ function createTextState$1() {
|
|
|
59110
59322
|
return {
|
|
59111
59323
|
styles: emptyMap$2(),
|
|
59112
59324
|
styleOwner: emptyMap$2(),
|
|
59325
|
+
formats: emptyMap$2(),
|
|
59326
|
+
formatOwner: emptyMap$2(),
|
|
59113
59327
|
fontKeys: emptySet$1(),
|
|
59114
59328
|
tables: emptyMap$2(),
|
|
59115
59329
|
installed: emptySet$1(),
|
|
@@ -61307,14 +61521,18 @@ function contentOf$2(element, resolvedOf) {
|
|
|
61307
61521
|
return plain === "" ? void 0 : plain;
|
|
61308
61522
|
}
|
|
61309
61523
|
/**
|
|
61310
|
-
* The text style key a text element
|
|
61524
|
+
* The text style key of a text element: the style a format of the game answered, for a text whose
|
|
61525
|
+
* bind names one; else the `style` prop while that is a key.
|
|
61311
61526
|
*
|
|
61312
61527
|
* @param element - The element to read.
|
|
61528
|
+
* @param shownStyleOf - Reads `Text.style` of an entity; none for a tree read without a world.
|
|
61313
61529
|
* @returns The key, or `undefined` for any other element and for a text with a `Style` object or
|
|
61314
61530
|
* no style.
|
|
61315
61531
|
*/
|
|
61316
|
-
function textStyleOf(element) {
|
|
61532
|
+
function textStyleOf(element, shownStyleOf) {
|
|
61317
61533
|
if (element.type !== "text") return void 0;
|
|
61534
|
+
const shown = namesFormat(element) ? shownStyleOf?.(element.entity) : void 0;
|
|
61535
|
+
if (shown !== void 0) return shown;
|
|
61318
61536
|
const style = element.node.props.style;
|
|
61319
61537
|
return typeof style === "string" ? style : void 0;
|
|
61320
61538
|
}
|
|
@@ -61328,14 +61546,15 @@ function textStyleOf(element) {
|
|
|
61328
61546
|
* @param state - The jsx state.
|
|
61329
61547
|
* @param element - The element to read.
|
|
61330
61548
|
* @param resolvedOf - Reads the resolved string of a text entity; none in a read without a world.
|
|
61549
|
+
* @param shownStyleOf - Reads `Text.style` of a text entity; none in a read without a world.
|
|
61331
61550
|
* @param place - Maps a rect of a slotted root into root coordinates; none for a root on the viewport.
|
|
61332
61551
|
* @returns The node, with its children in child order.
|
|
61333
61552
|
*/
|
|
61334
|
-
function nodeOf(state, element, resolvedOf, place) {
|
|
61553
|
+
function nodeOf(state, element, resolvedOf, shownStyleOf, place) {
|
|
61335
61554
|
const children = [];
|
|
61336
61555
|
for (const child of element.children) {
|
|
61337
61556
|
const childElement = state.elements.get(child);
|
|
61338
|
-
if (childElement !== void 0 && !isOwnKey(childElement.key)) children.push(nodeOf(state, childElement, resolvedOf, place));
|
|
61557
|
+
if (childElement !== void 0 && !isOwnKey(childElement.key)) children.push(nodeOf(state, childElement, resolvedOf, shownStyleOf, place));
|
|
61339
61558
|
}
|
|
61340
61559
|
const node = {
|
|
61341
61560
|
key: element.key,
|
|
@@ -61350,7 +61569,7 @@ function nodeOf(state, element, resolvedOf, place) {
|
|
|
61350
61569
|
...node,
|
|
61351
61570
|
content
|
|
61352
61571
|
};
|
|
61353
|
-
const textStyle = textStyleOf(element);
|
|
61572
|
+
const textStyle = textStyleOf(element, shownStyleOf);
|
|
61354
61573
|
const styled = textStyle === void 0 ? worded : {
|
|
61355
61574
|
...worded,
|
|
61356
61575
|
textStyle
|
|
@@ -61429,17 +61648,18 @@ function placeOf(root, slotPose) {
|
|
|
61429
61648
|
* @param resolvedOf - Reads the string `text` resolved for an entity; none in a read without a world.
|
|
61430
61649
|
* @param slotPose - The root pose of a slot, `rootPoseOf` of `renderer`; none in a read without a world.
|
|
61431
61650
|
* @param isAside - Whether an entity belongs to the scene `world` builds aside: such a root is not read.
|
|
61651
|
+
* @param shownStyleOf - Reads `Text.style` of an entity; none in a read without a world.
|
|
61432
61652
|
* @returns One root node, or every root under a `screen` node.
|
|
61433
61653
|
* @example
|
|
61434
61654
|
* ```ts
|
|
61435
61655
|
* readTree({ roots: new Map(), elements: new Map() } as unknown as JsxState).type; // "screen"
|
|
61436
61656
|
* ```
|
|
61437
61657
|
*/
|
|
61438
|
-
function readTree(state, layers = [], resolvedOf, slotPose, isAside) {
|
|
61658
|
+
function readTree(state, layers = [], resolvedOf, slotPose, isAside, shownStyleOf) {
|
|
61439
61659
|
const nodes = [];
|
|
61440
61660
|
for (const root of sortedRoots(state, layers, isAside)) {
|
|
61441
61661
|
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)));
|
|
61662
|
+
if (element !== void 0) nodes.push(nodeOf(state, element, resolvedOf, shownStyleOf, placeOf(root, slotPose)));
|
|
61443
61663
|
}
|
|
61444
61664
|
const single = nodes.length === 1 ? nodes[0] : void 0;
|
|
61445
61665
|
if (single !== void 0) return single;
|
|
@@ -66626,6 +66846,7 @@ function createJsxApi(ctx, modules) {
|
|
|
66626
66846
|
const frame = createReconciler(ctx, modules, fields);
|
|
66627
66847
|
const focus = createFocus(ctx, frame.markPointer, topRoot, fields);
|
|
66628
66848
|
const resolvedOf = (entity) => ctx.deps.world.ecs.get(entity, Text)?.resolved;
|
|
66849
|
+
const shownStyleOf = (entity) => ctx.deps.world.ecs.get(entity, Text)?.style;
|
|
66629
66850
|
const lookup = (entity) => state.elements.get(entity);
|
|
66630
66851
|
const find = (key) => {
|
|
66631
66852
|
for (const root of sortedRoots(state, layerNames(), isAside)) {
|
|
@@ -66634,7 +66855,7 @@ function createJsxApi(ctx, modules) {
|
|
|
66634
66855
|
}
|
|
66635
66856
|
};
|
|
66636
66857
|
return {
|
|
66637
|
-
tree: () => readTree(state, layerNames(), resolvedOf, (slot) => rootPoseOf(ctx.deps.world.ecs, slot), isAside),
|
|
66858
|
+
tree: () => readTree(state, layerNames(), resolvedOf, (slot) => rootPoseOf(ctx.deps.world.ecs, slot), isAside, shownStyleOf),
|
|
66638
66859
|
find,
|
|
66639
66860
|
lint: () => runLint(ctx),
|
|
66640
66861
|
fill: (key, value) => {
|
|
@@ -68099,14 +68320,24 @@ function needsMeasure(element) {
|
|
|
68099
68320
|
return typeof element.style.width !== "number" || typeof element.style.height !== "number";
|
|
68100
68321
|
}
|
|
68101
68322
|
/**
|
|
68323
|
+
* Reads the style key of a text or an icon out of its props.
|
|
68324
|
+
*
|
|
68325
|
+
* @param element - The element.
|
|
68326
|
+
* @returns The key `text.measure` takes.
|
|
68327
|
+
*/
|
|
68328
|
+
function styleKeyOf(element) {
|
|
68329
|
+
const { style } = element.node.props;
|
|
68330
|
+
return typeof style === "string" ? style : DEFAULT_TEXT_STYLE;
|
|
68331
|
+
}
|
|
68332
|
+
/**
|
|
68102
68333
|
* Reads what a text draws out of its props.
|
|
68103
68334
|
*
|
|
68104
68335
|
* @param element - The text element.
|
|
68105
68336
|
* @returns The content and the style key `text.measure` takes.
|
|
68106
68337
|
*/
|
|
68107
68338
|
function contentOf$1(element) {
|
|
68108
|
-
const { content
|
|
68109
|
-
const styleKey =
|
|
68339
|
+
const { content } = element.node.props;
|
|
68340
|
+
const styleKey = styleKeyOf(element);
|
|
68110
68341
|
if (typeof content === "string") return {
|
|
68111
68342
|
content,
|
|
68112
68343
|
style: styleKey
|
|
@@ -68121,16 +68352,6 @@ function contentOf$1(element) {
|
|
|
68121
68352
|
};
|
|
68122
68353
|
}
|
|
68123
68354
|
/**
|
|
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
68355
|
* The bound number as the `components` prop of a text lists it. Of two values of the bound
|
|
68135
68356
|
* component the last wins, as it does for the element.
|
|
68136
68357
|
*
|
|
@@ -68146,18 +68367,14 @@ function listedValueOf(element, bind) {
|
|
|
68146
68367
|
return typeof field === "number" ? field : void 0;
|
|
68147
68368
|
}
|
|
68148
68369
|
/**
|
|
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.
|
|
68370
|
+
* The string a text with this bind shows, see `shownOf`.
|
|
68153
68371
|
*
|
|
68154
68372
|
* @param element - The text element.
|
|
68373
|
+
* @param bind - Its bind.
|
|
68155
68374
|
* @param source - Where `Text.resolved` and the duration words are read.
|
|
68156
|
-
* @returns The string
|
|
68375
|
+
* @returns The string.
|
|
68157
68376
|
*/
|
|
68158
|
-
function
|
|
68159
|
-
const bind = bindOf(element);
|
|
68160
|
-
if (bind === void 0) return void 0;
|
|
68377
|
+
function boundShown(element, bind, source) {
|
|
68161
68378
|
const resolved = source.resolved(element.entity);
|
|
68162
68379
|
if (resolved !== void 0) return resolved;
|
|
68163
68380
|
const value = listedValueOf(element, bind);
|
|
@@ -68165,6 +68382,42 @@ function shownOf(element, source) {
|
|
|
68165
68382
|
return value === void 0 ? "" : formatBound(value, format, (ms) => source.duration(ms));
|
|
68166
68383
|
}
|
|
68167
68384
|
/**
|
|
68385
|
+
* The size of a text whose bind names a format of the game. A format picks the style too, so the
|
|
68386
|
+
* string alone does not say it: once the entity carries its `Text` both are read from there.
|
|
68387
|
+
* Before that, for the first solve, the format is asked on the bound field of its `components`
|
|
68388
|
+
* value, so `text` resolves what was measured.
|
|
68389
|
+
*
|
|
68390
|
+
* @param element - The text element.
|
|
68391
|
+
* @param bind - Its bind.
|
|
68392
|
+
* @param source - What it is measured through.
|
|
68393
|
+
* @param width - The width Yoga offers, or `undefined` when it bounds none.
|
|
68394
|
+
* @returns The size, or `undefined` when there is no answer to measure: an unknown name, a format
|
|
68395
|
+
* that threw, or no listed value.
|
|
68396
|
+
*/
|
|
68397
|
+
function namedSize(element, bind, source, width) {
|
|
68398
|
+
const resolved = source.resolved(element.entity);
|
|
68399
|
+
if (resolved !== void 0) return source.measure(resolved, source.style(element.entity) ?? styleKeyOf(element), width);
|
|
68400
|
+
const value = listedValueOf(element, bind);
|
|
68401
|
+
const answer = value === void 0 ? void 0 : source.formatted(bind.format, value);
|
|
68402
|
+
return answer === void 0 ? void 0 : source.measure(answer.text, answer.style, width);
|
|
68403
|
+
}
|
|
68404
|
+
/**
|
|
68405
|
+
* The size a text measures to: a bound one by what it shows, any other by its content.
|
|
68406
|
+
*
|
|
68407
|
+
* @param element - The text element.
|
|
68408
|
+
* @param source - What it is measured through.
|
|
68409
|
+
* @param width - The width Yoga offers, or `undefined` when it bounds none.
|
|
68410
|
+
* @returns The size before it is rounded.
|
|
68411
|
+
*/
|
|
68412
|
+
function textSize(element, source, width) {
|
|
68413
|
+
const bind = bindOf(element);
|
|
68414
|
+
if (bind === void 0) {
|
|
68415
|
+
const { content, style } = contentOf$1(element);
|
|
68416
|
+
return source.measure(content, style, width);
|
|
68417
|
+
}
|
|
68418
|
+
return (isTextFormat(bind.format) ? void 0 : namedSize(element, bind, source, width)) ?? source.measure(boundShown(element, bind, source), styleKeyOf(element), width);
|
|
68419
|
+
}
|
|
68420
|
+
/**
|
|
68168
68421
|
* The size a text or an icon takes before Yoga clamps it: an icon is square on one line of its
|
|
68169
68422
|
* text style, a bound text measures the string it shows, any other text its content, wrapped at
|
|
68170
68423
|
* `width` when its style wraps at its box. The size is rounded up to whole units. Yoga rounds a
|
|
@@ -68177,8 +68430,7 @@ function shownOf(element, source) {
|
|
|
68177
68430
|
* @returns The width and the height, in whole units.
|
|
68178
68431
|
*/
|
|
68179
68432
|
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);
|
|
68433
|
+
const size = element.type === "icon" ? squareOf(source.measure(LINE_SAMPLE, styleKeyOf(element))) : textSize(element, source, width);
|
|
68182
68434
|
return {
|
|
68183
68435
|
width: Math.ceil(size.width - WHOLE_EPSILON),
|
|
68184
68436
|
height: Math.ceil(size.height - WHOLE_EPSILON)
|
|
@@ -69194,7 +69446,7 @@ async function loadYogaModule() {
|
|
|
69194
69446
|
//#region src/plugins/ui/layout/api.ts
|
|
69195
69447
|
/**
|
|
69196
69448
|
* What the text elements are measured through: `text.measure`, the string `text` resolved for an
|
|
69197
|
-
* entity, and the duration words of `i18n`.
|
|
69449
|
+
* entity and its style, what a format of the game answers, and the duration words of `i18n`.
|
|
69198
69450
|
*
|
|
69199
69451
|
* @param ctx - Domain context of the ui plugin.
|
|
69200
69452
|
* @returns The source every measure function reads.
|
|
@@ -69203,6 +69455,8 @@ function textSourceOf(ctx) {
|
|
|
69203
69455
|
return {
|
|
69204
69456
|
measure: (content, style, width) => ctx.deps.text.measure(content, style, width),
|
|
69205
69457
|
resolved: (entity) => ctx.deps.world.ecs.get(entity, Text)?.resolved,
|
|
69458
|
+
style: (entity) => ctx.deps.world.ecs.get(entity, Text)?.style,
|
|
69459
|
+
formatted: (name, value) => ctx.deps.text.formatted(name, value),
|
|
69206
69460
|
duration: (ms) => ctx.deps.i18n.duration(ms)
|
|
69207
69461
|
};
|
|
69208
69462
|
}
|
|
@@ -70135,8 +70389,9 @@ const STRINGS_FILE = /\/generated\/strings\.(?:[\w-]+\.)?([\w-]+)\.ts$/;
|
|
|
70135
70389
|
const ASSETS_STAMP = "/.moku/assets-stamp.ts";
|
|
70136
70390
|
/**
|
|
70137
70391
|
* 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,
|
|
70392
|
+
* (filters too), nodes, slots, flows, asset bundles, plugin owners and text formats, which `text`
|
|
70393
|
+
* reads once and never swaps. Any other `kind` marks data, an effect descriptor or a timeline step,
|
|
70394
|
+
* which a node reads through the live binding.
|
|
70140
70395
|
*/
|
|
70141
70396
|
const REGISTERED_KINDS = {
|
|
70142
70397
|
component: true,
|
|
@@ -70145,7 +70400,8 @@ const REGISTERED_KINDS = {
|
|
|
70145
70400
|
slot: true,
|
|
70146
70401
|
flow: true,
|
|
70147
70402
|
bundles: true,
|
|
70148
|
-
plugin: true
|
|
70403
|
+
plugin: true,
|
|
70404
|
+
textFormats: true
|
|
70149
70405
|
};
|
|
70150
70406
|
/**
|
|
70151
70407
|
* Tells whether a value carries own members a definition could sit on.
|
|
@@ -70258,8 +70514,8 @@ function isTextStyles(value) {
|
|
|
70258
70514
|
}
|
|
70259
70515
|
/**
|
|
70260
70516
|
* 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.
|
|
70517
|
+
* `kind` decides alone: a flow, a node, a slot, an ECS component or tag, a filter, bundles, a
|
|
70518
|
+
* plugin owner or text formats refuse, a descriptor such as `sfx(...)` or a step such as `mark(...)` passes.
|
|
70263
70519
|
* Without a `kind`, an object with an own string `id` or `name` refuses: a scene, a system, a
|
|
70264
70520
|
* feature or a plugin. A function without a `kind` passes, since every function has an own `name`.
|
|
70265
70521
|
*
|
|
@@ -72772,7 +73028,9 @@ const createPlugin = framework.createPlugin;
|
|
|
72772
73028
|
* a string key written in code (a key that comes from data is checked with `app.i18n.isKey`).
|
|
72773
73029
|
*
|
|
72774
73030
|
* @returns The helpers typed with the game's `player`, `session`, `assets`, `bundles`, `strings`,
|
|
72775
|
-
* `
|
|
73031
|
+
* `textStyles`, `textFormats` (the format names of `bind`, next to the four built-in ones, with
|
|
73032
|
+
* `defineTextFormats` answering the game's styles), `emitters` and `hud` (the HUD part keys of
|
|
73033
|
+
* `HudPart` and `Overlay`).
|
|
72776
73034
|
* @example
|
|
72777
73035
|
* ```ts
|
|
72778
73036
|
* // kit.ts of a game: bound once, imported by every node, flow and view file.
|