@moku-labs/game 0.15.149 → 0.15.151
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/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-Rk3il_Pn.d.mts → commands-DXSaq2AP.d.mts} +5 -5
- package/dist/control.d.mts +4 -4
- package/dist/{define-CXfxHIZS.d.mts → define-DoJN_Ctu.d.mts} +2 -2
- package/dist/{headless-CayFBKSj.d.mts → headless-CO19o31k.d.mts} +1 -1
- package/dist/{index-DP9hZTrk.d.mts → index-Dgwheaoi.d.mts} +3 -3
- package/dist/index.d.mts +4 -4
- package/dist/index.mjs +1 -1
- package/dist/inspect.d.mts +6 -6
- package/dist/jsx-dev-runtime.d.mts +1 -1
- package/dist/jsx-runtime.d.mts +1 -1
- package/dist/{runtime-CaKaJAak.d.mts → runtime-CX1RTfCg.d.mts} +1 -1
- package/dist/{src-6rmoFaD5.mjs → src-CpV819p3.mjs} +514 -72
- package/dist/testing.d.mts +4 -4
- package/dist/testing.mjs +1 -1
- package/dist/{types-BbHpVeAD.d.mts → types-BaarAgv8.d.mts} +1 -1
- package/dist/{types-fkR2U4dd.d.mts → types-BpmdVJso.d.mts} +2 -2
- package/dist/{types-Cy2IGCQU.d.mts → types-C2-KGQGt.d.mts} +4 -4
- package/dist/{types-BMhuZtOK.d.mts → types-CbSTnp8T.d.mts} +2 -2
- package/dist/{types-DFmiN69h.d.mts → types-VJcIdmHU.d.mts} +69 -19
- package/dist/{visual-CrXEquz3.d.mts → visual-Dw4QXpgC.d.mts} +6 -6
- package/dist/visual.d.mts +1 -1
- package/llms.txt +3 -2
- package/package.json +1 -1
|
@@ -11801,8 +11801,8 @@ function dropDeadRest(_pose, entity, rests) {
|
|
|
11801
11801
|
if (sweeping.pctx?.deps.ecs.ownerOf(entity) === void 0) rests.delete(entity);
|
|
11802
11802
|
}
|
|
11803
11803
|
/**
|
|
11804
|
-
* Drops the key of an element whose entity is gone, and its side of the key table
|
|
11805
|
-
* still names that entity.
|
|
11804
|
+
* Drops the key of an element whose entity is gone, and its side of the key table, or of the keys
|
|
11805
|
+
* held elements wait with, when the key still names that entity.
|
|
11806
11806
|
*
|
|
11807
11807
|
* @param place - The projection and key of the element.
|
|
11808
11808
|
* @param entity - Its entity.
|
|
@@ -11812,8 +11812,11 @@ function dropDeadKey(place, entity, keysByEntity) {
|
|
|
11812
11812
|
const pctx = sweeping.pctx;
|
|
11813
11813
|
if (pctx === void 0 || pctx.deps.ecs.ownerOf(entity) !== void 0) return;
|
|
11814
11814
|
keysByEntity.delete(entity);
|
|
11815
|
-
const
|
|
11815
|
+
const state = pctx.ctx.state.projection;
|
|
11816
|
+
const byKey = state.keys.get(place.projection);
|
|
11816
11817
|
if (byKey?.get(place.key) === entity) byKey.delete(place.key);
|
|
11818
|
+
const waiting = state.heldKeys.size > 0 ? state.heldKeys.get(place.projection) : void 0;
|
|
11819
|
+
if (waiting?.get(place.key) === entity) waiting.delete(place.key);
|
|
11817
11820
|
}
|
|
11818
11821
|
/**
|
|
11819
11822
|
* Drops what the projection keeps about an element whose entity is gone: the rest pose `setRest`
|
|
@@ -12417,7 +12420,9 @@ function ensureWarm(state, spec) {
|
|
|
12417
12420
|
const record = {
|
|
12418
12421
|
name: spec.name,
|
|
12419
12422
|
entities: /* @__PURE__ */ new Set(),
|
|
12420
|
-
phase: "cold"
|
|
12423
|
+
phase: "cold",
|
|
12424
|
+
next: false,
|
|
12425
|
+
waiting: false
|
|
12421
12426
|
};
|
|
12422
12427
|
state.warm.set(spec.name, record);
|
|
12423
12428
|
state.warmList.push(record);
|
|
@@ -12441,8 +12446,9 @@ function heldFor(state, name, key) {
|
|
|
12441
12446
|
}
|
|
12442
12447
|
/**
|
|
12443
12448
|
* Despawns what a record holds: its view, with the cause `"discard"` and no motion, then every entity `adopt` marked
|
|
12444
|
-
* for it that is still there. The removal hooks still see them held.
|
|
12445
|
-
* alone. The record keeps its phase; the
|
|
12449
|
+
* for it that is still there. The removal hooks still see them held. The keys its elements wait with are forgotten:
|
|
12450
|
+
* the live elements keep theirs. A shown view belongs to `mounted` and is left alone. The record keeps its phase; the
|
|
12451
|
+
* caller sets it.
|
|
12446
12452
|
*
|
|
12447
12453
|
* @param pctx - Domain context of the projection module.
|
|
12448
12454
|
* @param record - The record.
|
|
@@ -12451,6 +12457,7 @@ function dropHeld(pctx, record) {
|
|
|
12451
12457
|
const state = pctx.ctx.state.projection;
|
|
12452
12458
|
const ecs = pctx.deps.ecs;
|
|
12453
12459
|
const view = record.view;
|
|
12460
|
+
if (state.heldKeys.size > 0) state.heldKeys.delete(record.name);
|
|
12454
12461
|
if (view !== void 0 && record.phase !== "shown") {
|
|
12455
12462
|
cancelTracks(pctx, view.entity);
|
|
12456
12463
|
state.byEntity.delete(view.entity);
|
|
@@ -12466,13 +12473,17 @@ function dropHeld(pctx, record) {
|
|
|
12466
12473
|
record.entities.clear();
|
|
12467
12474
|
}
|
|
12468
12475
|
/**
|
|
12469
|
-
* Leaves a record cold: nothing held, no longer in work, and the warm step looks at it
|
|
12476
|
+
* Leaves a record cold: nothing held, no longer in work, no next view, no read waiting, and the warm step looks at it
|
|
12477
|
+
* again.
|
|
12470
12478
|
*
|
|
12471
12479
|
* @param state - The projection branch of the plugin state.
|
|
12472
12480
|
* @param record - The record.
|
|
12473
12481
|
*/
|
|
12474
12482
|
function coolRecord(state, record) {
|
|
12475
12483
|
record.phase = "cold";
|
|
12484
|
+
record.next = false;
|
|
12485
|
+
record.waiting = false;
|
|
12486
|
+
delete record.pending;
|
|
12476
12487
|
delete record.key;
|
|
12477
12488
|
delete record.item;
|
|
12478
12489
|
delete record.view;
|
|
@@ -12536,6 +12547,8 @@ function clearWarm(pctx) {
|
|
|
12536
12547
|
state.warm.clear();
|
|
12537
12548
|
state.warmList.length = 0;
|
|
12538
12549
|
state.warmHeld.clear();
|
|
12550
|
+
state.heldKeys.clear();
|
|
12551
|
+
state.warmLoose = -1;
|
|
12539
12552
|
state.held.clear();
|
|
12540
12553
|
state.showing.length = 0;
|
|
12541
12554
|
state.fed.clear();
|
|
@@ -12545,35 +12558,122 @@ function clearWarm(pctx) {
|
|
|
12545
12558
|
}
|
|
12546
12559
|
/**
|
|
12547
12560
|
* Marks an entity another plugin spawned for the record in work, so `isBuilding` answers for it and a discard
|
|
12548
|
-
* despawns it with the view.
|
|
12561
|
+
* despawns it with the view. While no record is in work it only remembers the entity: ui adopts an element of a root
|
|
12562
|
+
* held warm right after its spawn, then registers its key, and `holdRegistered` reads it there.
|
|
12549
12563
|
*
|
|
12550
12564
|
* @param state - The projection branch of the plugin state.
|
|
12551
12565
|
* @param entity - The entity.
|
|
12552
12566
|
*/
|
|
12553
12567
|
function adoptWarm(state, entity) {
|
|
12554
12568
|
const active = state.warmActive;
|
|
12555
|
-
if (active === void 0)
|
|
12569
|
+
if (active === void 0) {
|
|
12570
|
+
state.warmLoose = entity;
|
|
12571
|
+
return;
|
|
12572
|
+
}
|
|
12556
12573
|
active.entities.add(entity);
|
|
12557
12574
|
state.warmHeld.add(entity);
|
|
12558
12575
|
}
|
|
12559
12576
|
/**
|
|
12560
|
-
*
|
|
12561
|
-
*
|
|
12562
|
-
*
|
|
12563
|
-
*
|
|
12564
|
-
*
|
|
12577
|
+
* Tells whether an element whose key a plugin registers under a projection belongs to a held root, and holds it with
|
|
12578
|
+
* the record when it does. An element `adopt` marked for the record in work is held already. One made after the record
|
|
12579
|
+
* was ready (a row a windowed list ranges in after the solve) is held when the projection's record holds a view not
|
|
12580
|
+
* shown and either `adopt` was handed the element since its spawn (ui adopts every element of a root held warm), or
|
|
12581
|
+
* the projection shows no live view, so it can only be one of the held root's. It joins the record as an adopted one:
|
|
12582
|
+
* `isBuilding` answers true, `entityOf` nothing, until the open; a discard despawns it with the view. An element of a
|
|
12583
|
+
* live view of the projection (the dim of a gated window) is live.
|
|
12565
12584
|
*
|
|
12566
12585
|
* @param state - The projection branch of the plugin state.
|
|
12567
12586
|
* @param projection - The projection the key is registered under.
|
|
12568
12587
|
* @param entity - The element.
|
|
12588
|
+
* @returns True when the element is held.
|
|
12569
12589
|
*/
|
|
12570
12590
|
function holdRegistered(state, projection, entity) {
|
|
12571
|
-
|
|
12591
|
+
const loose = state.warmLoose === entity;
|
|
12592
|
+
if (loose) state.warmLoose = -1;
|
|
12593
|
+
if (state.warm.size === 0) return false;
|
|
12594
|
+
if (state.warmHeld.has(entity)) return true;
|
|
12572
12595
|
const record = state.warm.get(projection);
|
|
12573
|
-
if (record?.view === void 0 || record.phase === "shown") return;
|
|
12574
|
-
if (state.mounted.get(projection)?.live.size !== 0) return;
|
|
12596
|
+
if (record?.view === void 0 || record.phase === "shown") return false;
|
|
12597
|
+
if (!loose && state.mounted.get(projection)?.live.size !== 0) return false;
|
|
12575
12598
|
record.entities.add(entity);
|
|
12576
12599
|
state.warmHeld.add(entity);
|
|
12600
|
+
return true;
|
|
12601
|
+
}
|
|
12602
|
+
/**
|
|
12603
|
+
* Creates the table of waiting keys of one projection with its first key. Its own function, because lint rule L5
|
|
12604
|
+
* refuses a collection built inside an exported declaration.
|
|
12605
|
+
*
|
|
12606
|
+
* @param key - The first key.
|
|
12607
|
+
* @param entity - The element that waits with it.
|
|
12608
|
+
* @returns The table.
|
|
12609
|
+
*/
|
|
12610
|
+
function keyTable(key, entity) {
|
|
12611
|
+
return /* @__PURE__ */ new Map([[key, entity]]);
|
|
12612
|
+
}
|
|
12613
|
+
/**
|
|
12614
|
+
* Lets the key of a held element wait while a live element of its projection holds the same key: the live one keeps
|
|
12615
|
+
* it in `keys`, so `entityOf` answers the element on the screen until the show of the record.
|
|
12616
|
+
*
|
|
12617
|
+
* @param state - The projection branch of the plugin state.
|
|
12618
|
+
* @param projection - The projection the key is registered under.
|
|
12619
|
+
* @param key - The key.
|
|
12620
|
+
* @param entity - The held element.
|
|
12621
|
+
* @returns True when the key waits; false when the key is free, and the element takes it as before.
|
|
12622
|
+
*/
|
|
12623
|
+
function waitHeldKey(state, projection, key, entity) {
|
|
12624
|
+
const holder = state.keys.get(projection)?.get(key);
|
|
12625
|
+
if (holder === void 0 || holder === entity || state.warmHeld.has(holder)) return false;
|
|
12626
|
+
const waiting = state.heldKeys.get(projection);
|
|
12627
|
+
if (waiting === void 0) state.heldKeys.set(projection, keyTable(key, entity));
|
|
12628
|
+
else waiting.set(key, entity);
|
|
12629
|
+
return true;
|
|
12630
|
+
}
|
|
12631
|
+
/**
|
|
12632
|
+
* Lets a held element that holds a key wait with it when a live element of its projection registers the same key
|
|
12633
|
+
* (the dim's elements registered after the open view's): the live one takes the key, the held one gets it back at
|
|
12634
|
+
* the show. With nothing held it reads one size.
|
|
12635
|
+
*
|
|
12636
|
+
* @param state - The projection branch of the plugin state.
|
|
12637
|
+
* @param projection - The projection the key is registered under.
|
|
12638
|
+
* @param key - The key the live element registers.
|
|
12639
|
+
*/
|
|
12640
|
+
function yieldHeldKey(state, projection, key) {
|
|
12641
|
+
if (state.warmHeld.size === 0) return;
|
|
12642
|
+
const holder = state.keys.get(projection)?.get(key);
|
|
12643
|
+
if (holder === void 0 || !state.warmHeld.has(holder)) return;
|
|
12644
|
+
const waiting = state.heldKeys.get(projection);
|
|
12645
|
+
if (waiting === void 0) state.heldKeys.set(projection, keyTable(key, holder));
|
|
12646
|
+
else waiting.set(key, holder);
|
|
12647
|
+
}
|
|
12648
|
+
/**
|
|
12649
|
+
* Forgets the waiting key of a held element: its remover was called.
|
|
12650
|
+
*
|
|
12651
|
+
* @param state - The projection branch of the plugin state.
|
|
12652
|
+
* @param projection - The projection the key was registered under.
|
|
12653
|
+
* @param key - The key.
|
|
12654
|
+
* @param entity - The element.
|
|
12655
|
+
*/
|
|
12656
|
+
function dropHeldKey(state, projection, key, entity) {
|
|
12657
|
+
const waiting = state.heldKeys.get(projection);
|
|
12658
|
+
if (waiting?.get(key) === entity) waiting.delete(key);
|
|
12659
|
+
}
|
|
12660
|
+
/**
|
|
12661
|
+
* Gives the waiting keys of a projection's held view their place at its show: each replaces the entry of the live
|
|
12662
|
+
* element that held it, which leaves with the live view it belonged to.
|
|
12663
|
+
*
|
|
12664
|
+
* @param state - The projection branch of the plugin state.
|
|
12665
|
+
* @param name - The projection.
|
|
12666
|
+
*/
|
|
12667
|
+
function releaseHeldKeys(state, name) {
|
|
12668
|
+
const waiting = state.heldKeys.get(name);
|
|
12669
|
+
if (waiting === void 0) return;
|
|
12670
|
+
state.heldKeys.delete(name);
|
|
12671
|
+
const byKey = state.keys.get(name);
|
|
12672
|
+
if (byKey === void 0) {
|
|
12673
|
+
state.keys.set(name, waiting);
|
|
12674
|
+
return;
|
|
12675
|
+
}
|
|
12676
|
+
for (const [key, entity] of waiting) byKey.set(key, entity);
|
|
12577
12677
|
}
|
|
12578
12678
|
/** What the prune's callback reads: set before the walk, so the callback is module-level and a walk makes no closure. */
|
|
12579
12679
|
const pruning = { pctx: void 0 };
|
|
@@ -12618,8 +12718,8 @@ function frameBudget(state) {
|
|
|
12618
12718
|
}
|
|
12619
12719
|
/**
|
|
12620
12720
|
* Shows the held view of a record: it and every entity marked for it stop being held, the view joins the live views
|
|
12621
|
-
* of its projection with the cause of the reconcile,
|
|
12622
|
-
* ui builds the rest of its root in one block.
|
|
12721
|
+
* of its projection with the cause of the reconcile, the keys its elements waited with take their place, and the
|
|
12722
|
+
* record is shown. A record still in work leaves the work: ui builds the rest of its root in one block.
|
|
12623
12723
|
*
|
|
12624
12724
|
* @param pctx - Domain context of the projection module.
|
|
12625
12725
|
* @param mounted - The mounted projection.
|
|
@@ -12632,7 +12732,9 @@ function showHeld$1(pctx, mounted, record, cause) {
|
|
|
12632
12732
|
for (const entity of record.entities) state.warmHeld.delete(entity);
|
|
12633
12733
|
record.entities.clear();
|
|
12634
12734
|
if (state.warmActive === record) delete state.warmActive;
|
|
12735
|
+
if (state.heldKeys.size > 0) releaseHeldKeys(state, record.name);
|
|
12635
12736
|
record.phase = "shown";
|
|
12737
|
+
record.next = false;
|
|
12636
12738
|
view.cause = cause;
|
|
12637
12739
|
mounted.live.set(view.key, view);
|
|
12638
12740
|
state.membershipVersion += 1;
|
|
@@ -12859,52 +12961,136 @@ function refreshWarm(pctx, spec, record, warm) {
|
|
|
12859
12961
|
return true;
|
|
12860
12962
|
}
|
|
12861
12963
|
/**
|
|
12964
|
+
* How the key of a warm item stands in its projection: `from` does not show it (`"closed"`), shows it with the same
|
|
12965
|
+
* content (`"open"`: the window is open, it is not built twice), or shows it with another content (`"next"`: the dim
|
|
12966
|
+
* of a gated window, whose open view is built aside, F202). A map lookup and, for a shown key, one `sameItem`.
|
|
12967
|
+
*
|
|
12968
|
+
* @param state - The projection branch of the plugin state.
|
|
12969
|
+
* @param name - The projection.
|
|
12970
|
+
* @param warm - The warm item and its key.
|
|
12971
|
+
* @returns How the key stands.
|
|
12972
|
+
*/
|
|
12973
|
+
function standing(state, name, warm) {
|
|
12974
|
+
const mounted = state.mounted.get(name);
|
|
12975
|
+
if (mounted?.items.has(warm.key) !== true) return "closed";
|
|
12976
|
+
const live = mounted.live.get(warm.key);
|
|
12977
|
+
return live === void 0 || sameItem(live.item, warm.item) ? "open" : "next";
|
|
12978
|
+
}
|
|
12979
|
+
/** The turn of a warm step, filled in place by `stepNext`, so a frame under a motion makes no object. */
|
|
12980
|
+
const stepTurn = {
|
|
12981
|
+
snapshot: Object.freeze({
|
|
12982
|
+
player: {},
|
|
12983
|
+
session: {},
|
|
12984
|
+
rng: {
|
|
12985
|
+
seed: 0,
|
|
12986
|
+
streams: {}
|
|
12987
|
+
}
|
|
12988
|
+
}),
|
|
12989
|
+
moving: false
|
|
12990
|
+
};
|
|
12991
|
+
/** What `readTurn` answers for a record that has no turn: read against this state, and not waiting to be stepped. */
|
|
12992
|
+
const NO_TURN = Object.freeze({
|
|
12993
|
+
item: void 0,
|
|
12994
|
+
key: ""
|
|
12995
|
+
});
|
|
12996
|
+
/**
|
|
12997
|
+
* The read a record's turn works from: the one it waited with, when the state did not change since and no owned
|
|
12998
|
+
* motion runs any more; `NO_TURN` while it still waits or was stepped against this state; else a new read of its item,
|
|
12999
|
+
* once per state (a throw is logged once per commit, not on every frame).
|
|
13000
|
+
*
|
|
13001
|
+
* @param pctx - Domain context of the projection module.
|
|
13002
|
+
* @param spec - The projection spec.
|
|
13003
|
+
* @param record - The record.
|
|
13004
|
+
* @param turn - The state now and whether an owned motion runs.
|
|
13005
|
+
* @returns The read, `undefined` for no item, or `NO_TURN`.
|
|
13006
|
+
*/
|
|
13007
|
+
function readTurn(pctx, spec, record, turn) {
|
|
13008
|
+
if (isSeen(record.seen, turn.snapshot)) {
|
|
13009
|
+
if (!record.waiting || turn.moving) return NO_TURN;
|
|
13010
|
+
const pending = record.pending;
|
|
13011
|
+
record.waiting = false;
|
|
13012
|
+
delete record.pending;
|
|
13013
|
+
return pending;
|
|
13014
|
+
}
|
|
13015
|
+
record.waiting = false;
|
|
13016
|
+
delete record.pending;
|
|
13017
|
+
record.seen = turn.snapshot;
|
|
13018
|
+
return readWarm(pctx, spec, turn.snapshot);
|
|
13019
|
+
}
|
|
13020
|
+
/**
|
|
12862
13021
|
* One record's turn in the warm step: a record shown, in work, or read against this state is passed over. Otherwise
|
|
12863
|
-
* its item is read (`warm`, or `from`'s first while held): with no item, or with a key `from` shows
|
|
12864
|
-
* dropped; a cold record spawns its held view, a ready one is brought up to date.
|
|
13022
|
+
* its item is read (`warm`, or `from`'s first while held): with no item, or with a key `from` shows with that content,
|
|
13023
|
+
* what is held is dropped; a cold record spawns its held view, a ready one is brought up to date. While a motion that
|
|
13024
|
+
* owns its fields runs, only a record whose key `from` shows with another content (the dim of a gated window, F202)
|
|
13025
|
+
* does its work; any other one with work waits with its read, and does it once no such motion runs.
|
|
12865
13026
|
*
|
|
12866
13027
|
* @param pctx - Domain context of the projection module.
|
|
12867
13028
|
* @param record - The record.
|
|
12868
|
-
* @param
|
|
13029
|
+
* @param turn - The state now and whether an owned motion runs.
|
|
12869
13030
|
* @returns True when the step did work, so the frame takes no more.
|
|
12870
13031
|
*/
|
|
12871
|
-
function stepRecord$1(pctx, record,
|
|
13032
|
+
function stepRecord$1(pctx, record, turn) {
|
|
12872
13033
|
if (record.phase === "shown" || record.phase === "building") return false;
|
|
12873
|
-
if (isSeen(record.seen, snapshot)) return false;
|
|
12874
13034
|
const state = pctx.ctx.state.projection;
|
|
12875
13035
|
const spec = state.specs.get(record.name);
|
|
12876
13036
|
if (spec === void 0) return false;
|
|
12877
|
-
|
|
12878
|
-
|
|
12879
|
-
|
|
12880
|
-
|
|
13037
|
+
const read = readTurn(pctx, spec, record, turn);
|
|
13038
|
+
if (read === NO_TURN) return false;
|
|
13039
|
+
const stands = read === void 0 ? "open" : standing(state, record.name, read);
|
|
13040
|
+
if (stands === "open" && record.view === void 0) return false;
|
|
13041
|
+
if (turn.moving && stands !== "next") {
|
|
13042
|
+
record.waiting = true;
|
|
13043
|
+
record.next = false;
|
|
13044
|
+
if (read !== void 0) record.pending = read;
|
|
13045
|
+
return false;
|
|
13046
|
+
}
|
|
13047
|
+
if (read === void 0 || stands === "open") {
|
|
12881
13048
|
dropHeld(pctx, record);
|
|
12882
13049
|
coolRecord(state, record);
|
|
12883
13050
|
return true;
|
|
12884
13051
|
}
|
|
12885
|
-
|
|
12886
|
-
|
|
12887
|
-
|
|
13052
|
+
let worked;
|
|
13053
|
+
if (record.phase === "ready") worked = refreshWarm(pctx, spec, record, read);
|
|
13054
|
+
else {
|
|
13055
|
+
spawnWarm(pctx, spec, record, read);
|
|
13056
|
+
worked = record.view !== void 0;
|
|
13057
|
+
}
|
|
13058
|
+
record.next = stands === "next" && record.view !== void 0;
|
|
13059
|
+
return worked;
|
|
12888
13060
|
}
|
|
12889
13061
|
/**
|
|
12890
13062
|
* Takes the next record that has work, in mounted order, and does its one step. A walk that finds none leaves the
|
|
12891
|
-
* world at rest until a commit or a close
|
|
13063
|
+
* world at rest until a commit or a close; one that passed a record over under an owned motion stays stale, so the
|
|
13064
|
+
* record is stepped once the motion ends. Index loop: under a motion this walk runs every frame.
|
|
12892
13065
|
*
|
|
12893
13066
|
* @param pctx - Domain context of the projection module.
|
|
13067
|
+
* @param moving - Whether a motion that owns its fields runs.
|
|
12894
13068
|
*/
|
|
12895
|
-
function stepNext(pctx) {
|
|
13069
|
+
function stepNext(pctx, moving) {
|
|
12896
13070
|
const state = pctx.ctx.state.projection;
|
|
12897
|
-
const
|
|
12898
|
-
|
|
12899
|
-
|
|
13071
|
+
const list = state.warmList;
|
|
13072
|
+
const count = list.length;
|
|
13073
|
+
const turn = stepTurn;
|
|
13074
|
+
let waits = false;
|
|
13075
|
+
turn.snapshot = pctx.ctx.deps.model.store.snapshot();
|
|
13076
|
+
turn.moving = moving;
|
|
13077
|
+
for (let index = 0; index < count; index += 1) {
|
|
13078
|
+
const record = list[index];
|
|
13079
|
+
if (record === void 0) continue;
|
|
13080
|
+
if (stepRecord$1(pctx, record, turn)) return;
|
|
13081
|
+
if (record.waiting) waits = true;
|
|
13082
|
+
}
|
|
13083
|
+
state.warmStale = waits;
|
|
12900
13084
|
}
|
|
12901
13085
|
/**
|
|
12902
13086
|
* One step of the warm windows, run in world's `input` callback after the reconcile. At rest it reads two fields and
|
|
12903
|
-
* returns. It runs only in a live world with no scene build
|
|
12904
|
-
*
|
|
12905
|
-
*
|
|
12906
|
-
*
|
|
12907
|
-
*
|
|
13087
|
+
* returns. It runs only in a live world with no scene build and a drawing plugin. Where it may not run, the record in
|
|
13088
|
+
* work is dropped: a paused or fast world builds no part of it, and `left()` would stay finite for good; it is built
|
|
13089
|
+
* again once the step runs. While a record is in work its checks are polled; otherwise the next record with work
|
|
13090
|
+
* spawns, patches or drops its held view. One step a frame. The frames of a motion that owns its fields and ends get
|
|
13091
|
+
* no work of an ordinary record (no spawn, no patch, no poll), but a record that holds the next view of a key `from`
|
|
13092
|
+
* shows live is stepped and polled through it: the tapped button's press tween runs through the whole dim of a gated
|
|
13093
|
+
* window (F202, the album).
|
|
12908
13094
|
*
|
|
12909
13095
|
* @param pctx - Domain context of the projection module.
|
|
12910
13096
|
*/
|
|
@@ -12916,9 +13102,9 @@ function stepWarm(pctx) {
|
|
|
12916
13102
|
if (active !== void 0) discardWarm(pctx, active);
|
|
12917
13103
|
return;
|
|
12918
13104
|
}
|
|
12919
|
-
|
|
12920
|
-
if (active === void 0) stepNext(pctx);
|
|
12921
|
-
else pollActive(state, active);
|
|
13105
|
+
const moving = ownedMotionRuns(state.tracks);
|
|
13106
|
+
if (active === void 0) stepNext(pctx, moving);
|
|
13107
|
+
else if (!moving || active.next) pollActive(state, active);
|
|
12922
13108
|
}
|
|
12923
13109
|
//#endregion
|
|
12924
13110
|
//#region src/plugins/world/projection/reconcile.ts
|
|
@@ -13076,8 +13262,40 @@ function enterEntry(pctx, spec, mounted, entry) {
|
|
|
13076
13262
|
* @param entry.used - The hints that reached an entry.
|
|
13077
13263
|
*/
|
|
13078
13264
|
function adoptEntry(pctx, spec, mounted, record, entry) {
|
|
13265
|
+
showWithItem(pctx, spec, mounted, record, entry, heldDifference(pctx, spec, record, entry.item));
|
|
13266
|
+
}
|
|
13267
|
+
/**
|
|
13268
|
+
* The output of `view` a held view needs to show an item: none for an item with the content of the held one, else
|
|
13269
|
+
* `view(item)`. A `view` that throws throws here, before anything is shown.
|
|
13270
|
+
*
|
|
13271
|
+
* @param pctx - Domain context of the projection module.
|
|
13272
|
+
* @param spec - The projection spec.
|
|
13273
|
+
* @param record - The warm record that holds the view.
|
|
13274
|
+
* @param item - The item the view is shown with.
|
|
13275
|
+
* @returns The component values, or `undefined` when nothing is to be written.
|
|
13276
|
+
*/
|
|
13277
|
+
function heldDifference(pctx, spec, record, item) {
|
|
13278
|
+
return sameItem(record.item, item) ? void 0 : collectView(pctx, spec, item);
|
|
13279
|
+
}
|
|
13280
|
+
/**
|
|
13281
|
+
* Shows the held view of a record with an item: the record is shown, then the item is stored (no `view` ran) or the
|
|
13282
|
+
* difference `next` is written directly, with no `change` hook, and the view comes as a spawned view does
|
|
13283
|
+
* (`playEnter`).
|
|
13284
|
+
*
|
|
13285
|
+
* @param pctx - Domain context of the projection module.
|
|
13286
|
+
* @param spec - The projection spec.
|
|
13287
|
+
* @param mounted - The mounted projection.
|
|
13288
|
+
* @param record - The warm record that holds the view.
|
|
13289
|
+
* @param entry - The key, its item, the peers, the mode and the used hints.
|
|
13290
|
+
* @param entry.key - The model key.
|
|
13291
|
+
* @param entry.item - The model item.
|
|
13292
|
+
* @param entry.peers - The new and the old items.
|
|
13293
|
+
* @param entry.direct - Whether the reconcile writes without motions.
|
|
13294
|
+
* @param entry.used - The hints that reached an entry.
|
|
13295
|
+
* @param next - The output of `view(item)`, or `undefined` for an item with the held one's content.
|
|
13296
|
+
*/
|
|
13297
|
+
function showWithItem(pctx, spec, mounted, record, entry, next) {
|
|
13079
13298
|
const view = record.view;
|
|
13080
|
-
const next = sameItem(record.item, entry.item) ? void 0 : collectView(pctx, spec, entry.item);
|
|
13081
13299
|
showHeld$1(pctx, mounted, record, entry.direct ? "mount" : "change");
|
|
13082
13300
|
if (next === void 0) {
|
|
13083
13301
|
view.item = entry.item;
|
|
@@ -13086,6 +13304,55 @@ function adoptEntry(pctx, spec, mounted, record, entry) {
|
|
|
13086
13304
|
playEnter$1(pctx, spec, view, entry);
|
|
13087
13305
|
}
|
|
13088
13306
|
/**
|
|
13307
|
+
* The record whose held view takes the place of a live view: a warm record holds a view of the live key, not shown
|
|
13308
|
+
* (the open view of a gated window, built under its dim, F202), and the new item differs in content from the live
|
|
13309
|
+
* one. `heldFor` is asked first: with nothing warm it reads one size. The gate's own dim → dim commit (a new object,
|
|
13310
|
+
* the same content) swaps nothing.
|
|
13311
|
+
*
|
|
13312
|
+
* @param pctx - Domain context of the projection module.
|
|
13313
|
+
* @param spec - The projection spec.
|
|
13314
|
+
* @param live - The live view of the key.
|
|
13315
|
+
* @param item - The new item, another object than the live one's.
|
|
13316
|
+
* @returns The record, or `undefined` when the live view changes as before.
|
|
13317
|
+
*/
|
|
13318
|
+
function swapFor(pctx, spec, live, item) {
|
|
13319
|
+
const held = heldFor(pctx.ctx.state.projection, spec.name, live.key);
|
|
13320
|
+
return held === void 0 || sameItem(live.item, item) ? void 0 : held;
|
|
13321
|
+
}
|
|
13322
|
+
/**
|
|
13323
|
+
* Swaps the held view of a record in for the live view of its key: the new item's `view` runs first, then the live
|
|
13324
|
+
* view leaves at once (out of `live`, the cause `"discard"`, despawned with no exit hook) and the held view is shown
|
|
13325
|
+
* with the item (`showWithItem`: the difference written if any, its enter played). A `view` that throws is logged as
|
|
13326
|
+
* a projection that failed and changes nothing: the key keeps its live view and the record its held one until the
|
|
13327
|
+
* next commit.
|
|
13328
|
+
*
|
|
13329
|
+
* @param pctx - Domain context of the projection module.
|
|
13330
|
+
* @param spec - The projection spec.
|
|
13331
|
+
* @param mounted - The mounted projection.
|
|
13332
|
+
* @param live - The live view of the key.
|
|
13333
|
+
* @param record - The record that holds the next view of the key.
|
|
13334
|
+
* @param entry - The key, its item, the peers, the mode and the used hints.
|
|
13335
|
+
* @param entry.key - The model key.
|
|
13336
|
+
* @param entry.item - The model item.
|
|
13337
|
+
* @param entry.peers - The new and the old items.
|
|
13338
|
+
* @param entry.direct - Whether the reconcile writes without motions.
|
|
13339
|
+
* @param entry.used - The hints that reached an entry.
|
|
13340
|
+
* @returns True when the held view was swapped in.
|
|
13341
|
+
*/
|
|
13342
|
+
function swapEntry(pctx, spec, mounted, live, record, entry) {
|
|
13343
|
+
let next;
|
|
13344
|
+
try {
|
|
13345
|
+
next = heldDifference(pctx, spec, record, entry.item);
|
|
13346
|
+
} catch (error) {
|
|
13347
|
+
pctx.ctx.log.error("world:projection-failed", { projection: spec.name }, asError$2(error));
|
|
13348
|
+
return false;
|
|
13349
|
+
}
|
|
13350
|
+
live.cause = "discard";
|
|
13351
|
+
despawnView(pctx, mounted, live);
|
|
13352
|
+
showWithItem(pctx, spec, mounted, record, entry, next);
|
|
13353
|
+
return true;
|
|
13354
|
+
}
|
|
13355
|
+
/**
|
|
13089
13356
|
* A key whose item is another object than before: structural changes are written, a changed
|
|
13090
13357
|
* component with a hook is handed to it and one without is written directly, then the retarget
|
|
13091
13358
|
* settles what is loose. A view no motion moves after that gets its pending `lift(false)`.
|
|
@@ -13244,8 +13511,39 @@ function settleUnchanged(pctx, spec, view, entry) {
|
|
|
13244
13511
|
dropIfStill(pctx, view);
|
|
13245
13512
|
}
|
|
13246
13513
|
/**
|
|
13247
|
-
*
|
|
13248
|
-
*
|
|
13514
|
+
* The entry of a key that has a live view. The same object, or in play mode the same content: nothing to project. A
|
|
13515
|
+
* restore and a load still write its rest pose, once for every live view, in `convergeMounted`; a rollback settles it
|
|
13516
|
+
* when it stands off it. A warm record that holds the next view of the key (a gated window's open view, built under
|
|
13517
|
+
* its dim) has it swapped in, or nothing happens when its `view` throws. Otherwise the view changes.
|
|
13518
|
+
*
|
|
13519
|
+
* @param pctx - Domain context of the projection module.
|
|
13520
|
+
* @param spec - The projection spec.
|
|
13521
|
+
* @param mounted - The mounted projection.
|
|
13522
|
+
* @param live - The live view of the key.
|
|
13523
|
+
* @param entry - The key, its item, the peers, the mode, the flags and the used hints.
|
|
13524
|
+
* @param entry.key - The model key.
|
|
13525
|
+
* @param entry.item - The model item.
|
|
13526
|
+
* @param entry.peers - The new and the old items.
|
|
13527
|
+
* @param entry.direct - Whether the reconcile writes without motions.
|
|
13528
|
+
* @param entry.force - Whether an unchanged item is projected again.
|
|
13529
|
+
* @param entry.settle - Whether an unchanged view that stands off its rest pose is settled.
|
|
13530
|
+
* @param entry.used - The hints that reached an entry.
|
|
13531
|
+
* @param entry.unchanged - The unchanged views of a direct reconcile that settles.
|
|
13532
|
+
* @param entry.rewritten - The views a direct reconcile wrote, written again after its flush.
|
|
13533
|
+
* @param counts - The counters of this reconcile.
|
|
13534
|
+
*/
|
|
13535
|
+
function applyLive(pctx, spec, mounted, live, entry, counts) {
|
|
13536
|
+
const same = !entry.force && live.item === entry.item;
|
|
13537
|
+
const swap = same ? void 0 : swapFor(pctx, spec, live, entry.item);
|
|
13538
|
+
if (swap !== void 0) {
|
|
13539
|
+
if (swapEntry(pctx, spec, mounted, live, swap, entry)) counts.entered += 1;
|
|
13540
|
+
} else if (!same && changeEntry(pctx, spec, live, entry)) counts.changed += 1;
|
|
13541
|
+
else if (entry.settle) settleUnchanged(pctx, spec, live, entry);
|
|
13542
|
+
}
|
|
13543
|
+
/**
|
|
13544
|
+
* Routes one key of the new state to the entry it belongs to: a live view changes, or gives its place to the next
|
|
13545
|
+
* view a warm record holds of its key, a queued view revives, a key a warm window holds is shown, an unknown key
|
|
13546
|
+
* enters.
|
|
13249
13547
|
*
|
|
13250
13548
|
* @param pctx - Domain context of the projection module.
|
|
13251
13549
|
* @param spec - The projection spec.
|
|
@@ -13265,8 +13563,7 @@ function settleUnchanged(pctx, spec, view, entry) {
|
|
|
13265
13563
|
function applyEntry(pctx, spec, mounted, entry, counts) {
|
|
13266
13564
|
const live = mounted.live.get(entry.key);
|
|
13267
13565
|
if (live !== void 0) {
|
|
13268
|
-
|
|
13269
|
-
else if (entry.settle) settleUnchanged(pctx, spec, live, entry);
|
|
13566
|
+
applyLive(pctx, spec, mounted, live, entry, counts);
|
|
13270
13567
|
return;
|
|
13271
13568
|
}
|
|
13272
13569
|
const queued = mounted.queue.find((view) => view.key === entry.key);
|
|
@@ -14246,16 +14543,18 @@ function createProjectionApi(ctx, deps) {
|
|
|
14246
14543
|
registerKey: (projection, key, entity) => {
|
|
14247
14544
|
if (state.mounted.get(projection)?.live.has(key) === true) throw new Error(`[game] Key "${key}" of projection "${projection}" is already a live view.\n Register the element under another key.`);
|
|
14248
14545
|
const byKey = state.keys.get(projection) ?? emptyKeys$2();
|
|
14249
|
-
|
|
14546
|
+
const held = holdRegistered(state, projection, entity);
|
|
14547
|
+
if (!held) yieldHeldKey(state, projection, key);
|
|
14548
|
+
if (!held || !waitHeldKey(state, projection, key, entity)) byKey.set(key, entity);
|
|
14250
14549
|
state.keys.set(projection, byKey);
|
|
14251
14550
|
state.keysByEntity.set(entity, {
|
|
14252
14551
|
projection,
|
|
14253
14552
|
key
|
|
14254
14553
|
});
|
|
14255
14554
|
state.sweptDespawns = -1;
|
|
14256
|
-
holdRegistered(state, projection, entity);
|
|
14257
14555
|
return () => {
|
|
14258
14556
|
if (byKey.get(key) === entity) byKey.delete(key);
|
|
14557
|
+
if (state.heldKeys.size > 0) dropHeldKey(state, projection, key, entity);
|
|
14259
14558
|
if (state.keysByEntity.get(entity)?.key === key) state.keysByEntity.delete(entity);
|
|
14260
14559
|
state.rests.delete(entity);
|
|
14261
14560
|
};
|
|
@@ -14651,7 +14950,7 @@ function emptySet$8() {
|
|
|
14651
14950
|
* running track and no driver, so every motion is instant until `anim` installs one. No build
|
|
14652
14951
|
* runs: `building` is absent. No warm window is held, and none is being built: `warmActive` is
|
|
14653
14952
|
* absent. The warm budget starts at two thirds of a 60 Hz frame until a step reads the rate. No
|
|
14654
|
-
* projection is held, no `show` is owed, and nothing was
|
|
14953
|
+
* projection is held, no `show` is owed, nothing was fed, no held key waits and nothing was adopted.
|
|
14655
14954
|
*
|
|
14656
14955
|
* @returns The projection branch of the plugin state.
|
|
14657
14956
|
*/
|
|
@@ -14685,6 +14984,8 @@ function createProjectionState() {
|
|
|
14685
14984
|
warm: emptyMap$9(),
|
|
14686
14985
|
warmList: [],
|
|
14687
14986
|
warmHeld: emptySet$8(),
|
|
14987
|
+
heldKeys: emptyMap$9(),
|
|
14988
|
+
warmLoose: -1,
|
|
14688
14989
|
warmStale: false,
|
|
14689
14990
|
warmBudgetMs: FALLBACK_WARM_MS,
|
|
14690
14991
|
held: emptySet$8(),
|
|
@@ -44876,31 +45177,114 @@ function ageReadyWaiting(state) {
|
|
|
44876
45177
|
else state.readyWaiting.set(name, rests + 1);
|
|
44877
45178
|
}
|
|
44878
45179
|
/**
|
|
45180
|
+
* Tells whether a warm view is in work for a `ready` to wait on: `world.projection.left()` is finite (a warm record
|
|
45181
|
+
* builds, or a scene build runs), and no capped post waived the wait.
|
|
45182
|
+
*
|
|
45183
|
+
* @param ctx - Domain context of the plugin.
|
|
45184
|
+
* @returns True while the `ready` waits for the build too.
|
|
45185
|
+
*/
|
|
45186
|
+
function warmInWork(ctx) {
|
|
45187
|
+
return ctx.state.readyWait !== "waived" && ctx.deps.world.projection.left() !== Number.POSITIVE_INFINITY;
|
|
45188
|
+
}
|
|
45189
|
+
/**
|
|
45190
|
+
* Lets the post of `ready` wait for the warm view in work: the system `assets.ready` posts it once `left()` turns
|
|
45191
|
+
* infinite, or at the cap. A wait already running keeps its start.
|
|
45192
|
+
*
|
|
45193
|
+
* @param state - The plugin state.
|
|
45194
|
+
* @param ask - The number `beginAsk` gave the ask whose post waits.
|
|
45195
|
+
*/
|
|
45196
|
+
function waitForWarm(state, ask) {
|
|
45197
|
+
state.readyWarmAsk = ask;
|
|
45198
|
+
if (state.readyWait === "warm") return;
|
|
45199
|
+
state.readyWait = "warm";
|
|
45200
|
+
state.readySince = -1;
|
|
45201
|
+
}
|
|
45202
|
+
/**
|
|
45203
|
+
* Posts the `ready` of the latest waiting ask, through `settleAsk` (F204): only to the rest that ask leads to.
|
|
45204
|
+
*
|
|
45205
|
+
* @param ctx - Domain context of the plugin.
|
|
45206
|
+
*/
|
|
45207
|
+
function postReady(ctx) {
|
|
45208
|
+
settleAsk(ctx, ctx.state.readyWarmAsk);
|
|
45209
|
+
}
|
|
45210
|
+
/**
|
|
45211
|
+
* The bundles a `ready` answered `false` for settled: it posts at once, or, in a live game with a warm view in work,
|
|
45212
|
+
* leaves the post to the system `assets.ready`.
|
|
45213
|
+
*
|
|
45214
|
+
* @param ctx - Domain context of the plugin.
|
|
45215
|
+
* @param live - Whether the effect ran in live mode.
|
|
45216
|
+
* @param ask - The number `beginAsk` gave the ask.
|
|
45217
|
+
*/
|
|
45218
|
+
function bundlesSettled(ctx, live, ask) {
|
|
45219
|
+
if (live && warmInWork(ctx)) waitForWarm(ctx.state, ask);
|
|
45220
|
+
else settleAsk(ctx, ask);
|
|
45221
|
+
}
|
|
45222
|
+
/**
|
|
45223
|
+
* One frame of the system `assets.ready` (phase `sync`): with no wait it reads one field. A `ready` waiting for the
|
|
45224
|
+
* warm view in work posts once `left()` turns infinite (the record became ready, or was discarded, paused or dropped by
|
|
45225
|
+
* a scene build or a restore: every end of it counts), or `READY_WARM_CAP_MS` after its first frame, which waives the
|
|
45226
|
+
* wait until the build ends, so the re-ask goes on and nothing posts again. A waived wait ends when `left()` turns
|
|
45227
|
+
* infinite.
|
|
45228
|
+
*
|
|
45229
|
+
* @param ctx - Domain context of the plugin.
|
|
45230
|
+
* @param frame - What the system run gets: the frame's `Time`.
|
|
45231
|
+
* @param frame.time - The frame's `Time`, its game clock read only while a wait runs.
|
|
45232
|
+
* @param frame.time.elapsed - The game clock, in scaled ms.
|
|
45233
|
+
*/
|
|
45234
|
+
function stepReady(ctx, frame) {
|
|
45235
|
+
const state = ctx.state;
|
|
45236
|
+
const wait = state.readyWait;
|
|
45237
|
+
if (wait === "none") return;
|
|
45238
|
+
const rests = ctx.deps.world.projection.left() === Number.POSITIVE_INFINITY;
|
|
45239
|
+
if (wait === "waived") {
|
|
45240
|
+
if (rests) state.readyWait = "none";
|
|
45241
|
+
return;
|
|
45242
|
+
}
|
|
45243
|
+
if (rests) {
|
|
45244
|
+
state.readyWait = "none";
|
|
45245
|
+
postReady(ctx);
|
|
45246
|
+
return;
|
|
45247
|
+
}
|
|
45248
|
+
const now = frame.time.elapsed;
|
|
45249
|
+
if (state.readySince < 0) state.readySince = now;
|
|
45250
|
+
else if (now - state.readySince >= 400) {
|
|
45251
|
+
state.readyWait = "waived";
|
|
45252
|
+
postReady(ctx);
|
|
45253
|
+
}
|
|
45254
|
+
}
|
|
45255
|
+
/**
|
|
44879
45256
|
* The handler of the `ready` effect (F52). Headless it answers `true` before any name check, as the
|
|
44880
|
-
* `load` effect does. Every bundle there: `true`, and nothing is posted.
|
|
44881
|
-
* warm of each bundle that is not there, answers `false`, and posts
|
|
44882
|
-
* `flow.inbox` once all of them settled,
|
|
44883
|
-
*
|
|
44884
|
-
*
|
|
44885
|
-
*
|
|
45257
|
+
* `load` effect does. Every bundle there and no warm view in work: `true`, and nothing is posted.
|
|
45258
|
+
* Otherwise it starts the warm of each bundle that is not there, answers `false`, and posts
|
|
45259
|
+
* `{ type: "ready" }` into `flow.inbox` once all of them settled and, in live mode, the warm view in
|
|
45260
|
+
* work is built (F202: the open view of a gated window, built under its dim; at most
|
|
45261
|
+
* `READY_WARM_CAP_MS` later, see `stepReady`), for the rest this ask leads to only (F204,
|
|
45262
|
+
* `settleAsk`): a `ready` nobody rests on would end the next wait at once. The posting does not
|
|
45263
|
+
* wait on the node's signal: the warm is shared work. A bundle it answers `false` for
|
|
45264
|
+
* is rested on (`readyWaiting`) until a `ready` finds it there: neither the budget nor the `"leave"`
|
|
44886
45265
|
* release of the rest in between takes it, else the node that asks again finds it gone and the two
|
|
44887
45266
|
* nodes cycle forever (F190). `ageReadyWaiting` ends the hold of one nobody asks for again.
|
|
44888
45267
|
*
|
|
44889
45268
|
* @param ctx - Domain context of the plugin.
|
|
44890
45269
|
* @param bundles - The bundle names of the descriptor.
|
|
45270
|
+
* @param live - Whether the effect runs in live mode: a fast walk builds no warm view and waits for none.
|
|
44891
45271
|
* @returns True when the node may go on, false when it should rest until the inbox event `ready`.
|
|
44892
45272
|
* @throws {Error} When the manifest has no such bundle.
|
|
44893
45273
|
*/
|
|
44894
|
-
function answerReady(ctx, bundles) {
|
|
45274
|
+
function answerReady(ctx, bundles, live = true) {
|
|
44895
45275
|
const state = ctx.state;
|
|
44896
45276
|
if (state.io === void 0) return true;
|
|
44897
45277
|
for (const name of bundles) if (state.manifest.bundles[name] === void 0) throw unknownBundle(name);
|
|
44898
45278
|
const missing = bundles.filter((name) => !isThere(state, name));
|
|
44899
45279
|
for (const name of bundles) if (missing.includes(name)) state.readyWaiting.set(name, 0);
|
|
44900
45280
|
else state.readyWaiting.delete(name);
|
|
44901
|
-
if (missing.length === 0)
|
|
45281
|
+
if (missing.length === 0) {
|
|
45282
|
+
if (!live || !warmInWork(ctx)) return true;
|
|
45283
|
+
waitForWarm(state, beginAsk(ctx));
|
|
45284
|
+
return false;
|
|
45285
|
+
}
|
|
44902
45286
|
const ask = beginAsk(ctx);
|
|
44903
|
-
Promise.all(missing.map((name) => warmForReady(ctx, name))).then(() =>
|
|
45287
|
+
Promise.all(missing.map((name) => warmForReady(ctx, name))).then(() => bundlesSettled(ctx, live, ask));
|
|
44904
45288
|
return false;
|
|
44905
45289
|
}
|
|
44906
45290
|
/**
|
|
@@ -44980,7 +45364,7 @@ function passReadyNode(ctx, node) {
|
|
|
44980
45364
|
//#endregion
|
|
44981
45365
|
//#region src/plugins/assets/lifecycle.ts
|
|
44982
45366
|
/**
|
|
44983
|
-
* @file assets plugin — lifecycle: the
|
|
45367
|
+
* @file assets plugin — lifecycle: the eight registrations of `onInit`, the boot of `onStart`
|
|
44984
45368
|
* and the teardown that frees every texture and cancels every fetch.
|
|
44985
45369
|
*/
|
|
44986
45370
|
/**
|
|
@@ -45123,15 +45507,16 @@ async function enterNode(ctx, node, run) {
|
|
|
45123
45507
|
/**
|
|
45124
45508
|
* Connects the plugin in `onInit`: the `load` stage of `onEnter`, the handlers of the `load` and
|
|
45125
45509
|
* the `ready` effects (F52), both run in fast mode too, the texture provider of `renderer`, the
|
|
45126
|
-
* start and the end of an exit in `world`, counted,
|
|
45127
|
-
* which lets a leaving scene's bundles go once its elements played their exit (F51)
|
|
45128
|
-
*
|
|
45510
|
+
* start and the end of an exit in `world`, counted, the system `assets.leave` of phase `sync`,
|
|
45511
|
+
* which lets a leaving scene's bundles go once its elements played their exit (F51), and the system
|
|
45512
|
+
* `assets.ready` of the same phase, which posts a `ready` that waits for a warm view once its build
|
|
45513
|
+
* ended (F202). The eight removers go to the state, because `onStop` has nothing but the state.
|
|
45129
45514
|
*
|
|
45130
45515
|
* @param ctx - Kernel context of the assets plugin.
|
|
45131
45516
|
*/
|
|
45132
45517
|
function connectAssets(ctx) {
|
|
45133
45518
|
const assets = withDeps$6(ctx);
|
|
45134
|
-
assets.state.removers.push(assets.deps.flow.onEnter("load", (node, run) => enterNode(assets, node, run)), assets.deps.flow.fx.handle("load", (descriptor, run) => runLoadEffect(assets, descriptor, run), { runInFast: true }), assets.deps.flow.fx.handle("ready", (descriptor) => answerReady(assets, bundlesOfDescriptor(descriptor)), { runInFast: true }), assets.deps.renderer.sync.textures.provide((key) => lookupTexture(assets, key)), assets.deps.world.ecs.onAdded(Exiting, () => {
|
|
45519
|
+
assets.state.removers.push(assets.deps.flow.onEnter("load", (node, run) => enterNode(assets, node, run)), assets.deps.flow.fx.handle("load", (descriptor, run) => runLoadEffect(assets, descriptor, run), { runInFast: true }), assets.deps.flow.fx.handle("ready", (descriptor, run) => answerReady(assets, bundlesOfDescriptor(descriptor), run.mode === "live"), { runInFast: true }), assets.deps.renderer.sync.textures.provide((key) => lookupTexture(assets, key)), assets.deps.world.ecs.onAdded(Exiting, () => {
|
|
45135
45520
|
assets.state.exiting += 1;
|
|
45136
45521
|
}), assets.deps.world.ecs.onRemoved(Exiting, () => {
|
|
45137
45522
|
assets.state.exiting -= 1;
|
|
@@ -45140,6 +45525,11 @@ function connectAssets(ctx) {
|
|
|
45140
45525
|
phase: "sync",
|
|
45141
45526
|
query: [],
|
|
45142
45527
|
run: () => releaseSceneLeft(assets)
|
|
45528
|
+
})), assets.deps.world.ecs.system(system({
|
|
45529
|
+
name: "assets.ready",
|
|
45530
|
+
phase: "sync",
|
|
45531
|
+
query: [],
|
|
45532
|
+
run: (_rows, frame) => stepReady(assets, frame)
|
|
45143
45533
|
})));
|
|
45144
45534
|
}
|
|
45145
45535
|
/**
|
|
@@ -45211,7 +45601,7 @@ async function startAssets(ctx) {
|
|
|
45211
45601
|
}
|
|
45212
45602
|
/**
|
|
45213
45603
|
* Frees everything in `onStop`: the preload and every running load are aborted, every texture is
|
|
45214
|
-
* destroyed, the
|
|
45604
|
+
* destroyed, the eight registrations are removed and the registries are emptied, the companions
|
|
45215
45605
|
* too. A teardown context carries the state and nothing else, so no other plugin is called here:
|
|
45216
45606
|
* no companion's `unload` either, its plugin stopped before this one.
|
|
45217
45607
|
*
|
|
@@ -45250,6 +45640,8 @@ function releaseAll(state) {
|
|
|
45250
45640
|
state.exiting = 0;
|
|
45251
45641
|
state.restPending = false;
|
|
45252
45642
|
state.restedLive = false;
|
|
45643
|
+
state.readyWait = "none";
|
|
45644
|
+
state.readySince = -1;
|
|
45253
45645
|
state.stamps = void 0;
|
|
45254
45646
|
state.swapping = void 0;
|
|
45255
45647
|
state.io = void 0;
|
|
@@ -46122,7 +46514,10 @@ function createAssetsState() {
|
|
|
46122
46514
|
restPending: false,
|
|
46123
46515
|
restedLive: false,
|
|
46124
46516
|
readyFailed: emptySet$2(),
|
|
46125
|
-
warmed: emptyMap$3()
|
|
46517
|
+
warmed: emptyMap$3(),
|
|
46518
|
+
readyWait: "none",
|
|
46519
|
+
readySince: -1,
|
|
46520
|
+
readyWarmAsk: 0
|
|
46126
46521
|
};
|
|
46127
46522
|
}
|
|
46128
46523
|
/**
|
|
@@ -56919,6 +57314,8 @@ async function startI18n(ctx) {
|
|
|
56919
57314
|
* hot swap calls. This is the only place in the
|
|
56920
57315
|
* engine where a locale is read.
|
|
56921
57316
|
*/
|
|
57317
|
+
/** The parameters of a message without any: one frozen object, so a format builds none. */
|
|
57318
|
+
const EMPTY_PARAMS = Object.freeze({});
|
|
56922
57319
|
/**
|
|
56923
57320
|
* Answers the formatter kit of one locale, building it on first use.
|
|
56924
57321
|
*
|
|
@@ -56972,6 +57369,54 @@ function missing(ctx, key, locale) {
|
|
|
56972
57369
|
return missingParts(key);
|
|
56973
57370
|
}
|
|
56974
57371
|
/**
|
|
57372
|
+
* Tells whether a parameter is a message `tr` built: an object with a string `key` and no
|
|
57373
|
+
* `type`, which an element passed as a parameter always has.
|
|
57374
|
+
*
|
|
57375
|
+
* @param value - One parameter of a message.
|
|
57376
|
+
* @returns True for a message.
|
|
57377
|
+
* @example
|
|
57378
|
+
* ```ts
|
|
57379
|
+
* isMessage({ key: "album.set" }); // true
|
|
57380
|
+
* ```
|
|
57381
|
+
*/
|
|
57382
|
+
function isMessage(value) {
|
|
57383
|
+
if (typeof value !== "object" || value === null || Array.isArray(value)) return false;
|
|
57384
|
+
return typeof value.key === "string" && !("type" in value);
|
|
57385
|
+
}
|
|
57386
|
+
/**
|
|
57387
|
+
* The parameters a compiled message reads: a message passed as a parameter is replaced by its
|
|
57388
|
+
* words in the same locale (F209). The parameters themselves when none is a message, so a label
|
|
57389
|
+
* without one builds nothing.
|
|
57390
|
+
*
|
|
57391
|
+
* @param ctx - Kernel context of the i18n plugin.
|
|
57392
|
+
* @param params - The parameters of the outer message.
|
|
57393
|
+
* @param locale - The locale the outer message is read in.
|
|
57394
|
+
* @returns The parameters to hand the compiled message.
|
|
57395
|
+
*/
|
|
57396
|
+
function paramsIn(ctx, params, locale) {
|
|
57397
|
+
let words;
|
|
57398
|
+
for (const name in params) {
|
|
57399
|
+
const value = params[name];
|
|
57400
|
+
if (!isMessage(value)) continue;
|
|
57401
|
+
words ??= { ...params };
|
|
57402
|
+
words[name] = plainOf$1(formatAt(ctx, value, locale));
|
|
57403
|
+
}
|
|
57404
|
+
return words ?? params;
|
|
57405
|
+
}
|
|
57406
|
+
/**
|
|
57407
|
+
* Formats one message in a locale that can be read, through the fallback chain.
|
|
57408
|
+
*
|
|
57409
|
+
* @param ctx - Kernel context of the i18n plugin.
|
|
57410
|
+
* @param message - What `tr` returned.
|
|
57411
|
+
* @param target - The locale to read first.
|
|
57412
|
+
* @returns The parts of the sentence, adjacent text merged.
|
|
57413
|
+
*/
|
|
57414
|
+
function formatAt(ctx, message, target) {
|
|
57415
|
+
const compiled = resolve$1(ctx.state, message.key, target, ctx.config.fallback);
|
|
57416
|
+
if (compiled === void 0) return missing(ctx, message.key, target);
|
|
57417
|
+
return mergeParts(compiled(paramsIn(ctx, message.params ?? EMPTY_PARAMS, target), kitOf(ctx.state, target)));
|
|
57418
|
+
}
|
|
57419
|
+
/**
|
|
56975
57420
|
* Formats one message in one locale, through the fallback chain.
|
|
56976
57421
|
*
|
|
56977
57422
|
* @param ctx - Kernel context of the i18n plugin.
|
|
@@ -56981,10 +57426,7 @@ function missing(ctx, key, locale) {
|
|
|
56981
57426
|
* @throws {Error} When a named locale is not registered or not loaded.
|
|
56982
57427
|
*/
|
|
56983
57428
|
function formatIn(ctx, message, locale) {
|
|
56984
|
-
|
|
56985
|
-
const compiled = resolve$1(ctx.state, message.key, target, ctx.config.fallback);
|
|
56986
|
-
if (compiled === void 0) return missing(ctx, message.key, target);
|
|
56987
|
-
return mergeParts(compiled(message.params ?? {}, kitOf(ctx.state, target)));
|
|
57429
|
+
return formatAt(ctx, message, locale === void 0 ? ctx.state.locale : readable(ctx, locale));
|
|
56988
57430
|
}
|
|
56989
57431
|
/**
|
|
56990
57432
|
* Joins the text parts of a sentence, elements dropped, and reads every `\<` as the `<` it
|