@moku-labs/game 0.15.46 → 0.15.47
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-DPjJykYd.d.mts → commands-C2-V2uKy.d.mts} +5 -5
- package/dist/control.d.mts +4 -4
- package/dist/{define-CweettNp.d.mts → define-NGQXu7Qj.d.mts} +2 -2
- package/dist/{headless-BlNxy_kO.d.mts → headless-DcJCzBkz.d.mts} +1 -1
- package/dist/{index-BQh16IG6.d.mts → index-DTsi9hds.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-BHmaehdl.d.mts → runtime--I74mwMY.d.mts} +1 -1
- package/dist/{src-Bb6Sb530.mjs → src-CI77RUzT.mjs} +1025 -149
- package/dist/testing.d.mts +4 -4
- package/dist/testing.mjs +1 -1
- package/dist/{types-BMQut7RK.d.mts → types-Bc_re3rB.d.mts} +145 -31
- package/dist/{types-BjNmoeuL.d.mts → types-CiSVMR89.d.mts} +15 -5
- package/dist/{types-C4iNGaXh.d.mts → types-D4Q5MH_l.d.mts} +2 -2
- package/dist/{types-wYdMIjLG.d.mts → types-RX1bYaqD.d.mts} +2 -2
- package/dist/{types-CMZvOBAa.d.mts → types-dF8Qmn7P.d.mts} +4 -4
- package/dist/{visual-Cl_aeC8t.d.mts → visual-wSjsCu_W.d.mts} +6 -6
- package/dist/visual.d.mts +1 -1
- package/package.json +1 -1
|
@@ -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$3 = 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$3 / higher;
|
|
1436
|
+
const busy = missed && g.lastWorkMs > SECOND_MS$3 / fps;
|
|
1437
1437
|
const slot = g.written % 512;
|
|
1438
1438
|
evict$2(g, at);
|
|
1439
1439
|
g.sampleAt[slot] = at;
|
|
@@ -9763,8 +9763,9 @@ function registerFeatures(ctx, ecs, projection) {
|
|
|
9763
9763
|
* callback records the frame history before it clears the change sets; in an agent build the
|
|
9764
9764
|
* timing table starts with the page clock of `time` and the `input` callback zeroes it each
|
|
9765
9765
|
* frame. The resource `Now` gets `clock.now()` once here and first thing in every `input`
|
|
9766
|
-
* callback, so every system of a frame reads one moment; a running scene build
|
|
9767
|
-
* budget from that moment too.
|
|
9766
|
+
* callback, so every system of a frame reads one moment; a running scene build and a warm window in
|
|
9767
|
+
* work count their frame budget from that moment too. After the reconcile the `input` callback
|
|
9768
|
+
* takes one step of the warm windows. `onStart` has no access to the
|
|
9768
9769
|
* plugin's own API, so it builds its own module objects — they are views on `ctx.state`, which is
|
|
9769
9770
|
* the one place the modules keep their data.
|
|
9770
9771
|
*
|
|
@@ -9788,6 +9789,7 @@ function connectWorld(ctx) {
|
|
|
9788
9789
|
projection.startFrame(now);
|
|
9789
9790
|
worldCtx.state.ecs.timing?.ms.fill(0);
|
|
9790
9791
|
projection.reconcileIfDirty();
|
|
9792
|
+
projection.stepWarm();
|
|
9791
9793
|
ecs.runPhase("input", frame);
|
|
9792
9794
|
}), time.onFrame("animate", (frame) => {
|
|
9793
9795
|
projection.sweep();
|
|
@@ -9801,7 +9803,7 @@ function connectWorld(ctx) {
|
|
|
9801
9803
|
/**
|
|
9802
9804
|
* Empties the world in `onStop`: the frame callbacks and the hint listener are removed, then
|
|
9803
9805
|
* every track, view, queued view, entity and resource is dropped, a running scene build and the
|
|
9804
|
-
* `onBuild` checks with them, and the scenes and the frame history are reset.
|
|
9806
|
+
* `onBuild` checks with them, every warm record, and the scenes and the frame history are reset.
|
|
9805
9807
|
* No `onRemoved` fires, because `renderer` stopped earlier and destroyed its own objects.
|
|
9806
9808
|
*
|
|
9807
9809
|
* @param state - The plugin state, the only thing a teardown context carries.
|
|
@@ -9829,6 +9831,11 @@ function clearWorld(state) {
|
|
|
9829
9831
|
state.projection.owedLoops = 0;
|
|
9830
9832
|
delete state.projection.building;
|
|
9831
9833
|
state.projection.buildChecks.length = 0;
|
|
9834
|
+
state.projection.warm.clear();
|
|
9835
|
+
state.projection.warmList.length = 0;
|
|
9836
|
+
state.projection.warmHeld.clear();
|
|
9837
|
+
delete state.projection.warmActive;
|
|
9838
|
+
state.projection.warmStale = false;
|
|
9832
9839
|
state.ecs.generations.length = 0;
|
|
9833
9840
|
state.ecs.free.length = 0;
|
|
9834
9841
|
state.ecs.owners.clear();
|
|
@@ -10028,7 +10035,8 @@ function startTrack$2(pctx, entity, component, to, options) {
|
|
|
10028
10035
|
entity,
|
|
10029
10036
|
component: component.componentName,
|
|
10030
10037
|
handle,
|
|
10031
|
-
additive: options.additive === true
|
|
10038
|
+
additive: options.additive === true,
|
|
10039
|
+
forever: options.repeat === "forever"
|
|
10032
10040
|
});
|
|
10033
10041
|
return handle;
|
|
10034
10042
|
}
|
|
@@ -10178,6 +10186,8 @@ function diffComponents(rest, next, byIdentity) {
|
|
|
10178
10186
|
}
|
|
10179
10187
|
//#endregion
|
|
10180
10188
|
//#region src/plugins/world/projection/views.ts
|
|
10189
|
+
/** The components of a view built aside or held warm at its spawn: none, so it is flagged before the first `onAdded`. */
|
|
10190
|
+
const NO_COMPONENTS = [];
|
|
10181
10191
|
/**
|
|
10182
10192
|
* Normalises a caught value into an `Error`, so the log always gets one.
|
|
10183
10193
|
*
|
|
@@ -10266,27 +10276,64 @@ function drawsAtPlace(pctx, view, order) {
|
|
|
10266
10276
|
return view.rest.has(Tree.componentName) && typeof rest === "object" && "value" in rest && rest.value === order;
|
|
10267
10277
|
}
|
|
10268
10278
|
/**
|
|
10279
|
+
* Moves one screen root from the `Order` of its old place to the new one, on the entity and in the
|
|
10280
|
+
* rest pose. A view that does not draw at the old place keeps its own.
|
|
10281
|
+
*
|
|
10282
|
+
* @param pctx - Domain context of the projection module.
|
|
10283
|
+
* @param view - The view.
|
|
10284
|
+
* @param previous - The `Order` of the place the projection had.
|
|
10285
|
+
* @param order - The `Order` of its new place.
|
|
10286
|
+
*/
|
|
10287
|
+
function placeView(pctx, view, previous, order) {
|
|
10288
|
+
if (!drawsAtPlace(pctx, view, previous)) return;
|
|
10289
|
+
const value = pctx.deps.components.Order({ value: order });
|
|
10290
|
+
view.rest.set(value.type.componentName, value);
|
|
10291
|
+
writeValue(pctx, view.entity, value);
|
|
10292
|
+
}
|
|
10293
|
+
/**
|
|
10269
10294
|
* Keeps a mounted projection for the scene that comes, as a scene switch does for a projection
|
|
10270
10295
|
* both scenes list: it stays mounted into the new layer list, and its screen roots take the
|
|
10271
10296
|
* `Order` of their place in the new list, on the entity and in the rest pose, so the next node of
|
|
10272
|
-
* a root compares equal and writes none
|
|
10273
|
-
* despawned, no motion is cut, no hook runs. A view on its
|
|
10297
|
+
* a root compares equal and writes none; the view a warm window holds hidden does too. Nothing
|
|
10298
|
+
* else is touched: no view is spawned or despawned, no motion is cut, no hook runs. A view on its
|
|
10299
|
+
* way out keeps the order it leaves with.
|
|
10274
10300
|
*
|
|
10275
10301
|
* @param pctx - Domain context of the projection module.
|
|
10276
10302
|
* @param mounted - The mounted projection the new list names again.
|
|
10277
10303
|
* @param order - The `Order` of its place in the new list.
|
|
10304
|
+
* @param held - The view of its warm window, if any: held hidden, or shown and then placed with the
|
|
10305
|
+
* live views already.
|
|
10278
10306
|
*/
|
|
10279
|
-
function placeMounted(pctx, mounted, order) {
|
|
10307
|
+
function placeMounted(pctx, mounted, order, held) {
|
|
10280
10308
|
const previous = mounted.order;
|
|
10281
10309
|
mounted.layers = pctx.ctx.state.projection.layers;
|
|
10282
10310
|
if (previous === order) return;
|
|
10283
10311
|
mounted.order = order;
|
|
10284
|
-
for (const view of mounted.live.values())
|
|
10285
|
-
|
|
10286
|
-
|
|
10287
|
-
|
|
10288
|
-
|
|
10289
|
-
|
|
10312
|
+
for (const view of mounted.live.values()) placeView(pctx, view, previous, order);
|
|
10313
|
+
if (held !== void 0) placeView(pctx, held, previous, order);
|
|
10314
|
+
}
|
|
10315
|
+
/**
|
|
10316
|
+
* Spawns the entity of a view that is built aside or held warm: bare, flagged in `flags`, then
|
|
10317
|
+
* given its `Layer` and its view components in that order. The ecs fires `onAdded` in list order,
|
|
10318
|
+
* so every hook of a plugin already sees the flag (F97), and the `Tree` hook of `ui` the layer.
|
|
10319
|
+
*
|
|
10320
|
+
* @param pctx - Domain context of the projection module.
|
|
10321
|
+
* @param spec - The projection spec.
|
|
10322
|
+
* @param values - The output of `view(item)`, by component name.
|
|
10323
|
+
* @param flags - The set `isBuilding` reads: the scene build's entities, or the warm held ones.
|
|
10324
|
+
* @returns The entity.
|
|
10325
|
+
*/
|
|
10326
|
+
function spawnFlagged(pctx, spec, values, flags) {
|
|
10327
|
+
const ecs = pctx.deps.ecs;
|
|
10328
|
+
const owner = {
|
|
10329
|
+
kind: "projection",
|
|
10330
|
+
name: spec.name
|
|
10331
|
+
};
|
|
10332
|
+
const entity = ecs.spawn(owner, NO_COMPONENTS);
|
|
10333
|
+
flags.add(entity);
|
|
10334
|
+
ecs.add(entity, pctx.deps.components.Layer({ name: spec.layer }));
|
|
10335
|
+
for (const value of values.values()) ecs.add(entity, value);
|
|
10336
|
+
return entity;
|
|
10290
10337
|
}
|
|
10291
10338
|
/**
|
|
10292
10339
|
* Writes the layer of a view.
|
|
@@ -11312,9 +11359,536 @@ function reseedViews(state, name, from, to) {
|
|
|
11312
11359
|
}
|
|
11313
11360
|
}
|
|
11314
11361
|
//#endregion
|
|
11362
|
+
//#region src/plugins/world/projection/warm.ts
|
|
11363
|
+
/** A second in ms: the frame interval is this over the frame rate. */
|
|
11364
|
+
const SECOND_MS$2 = 1e3;
|
|
11365
|
+
/** The share of a frame interval a warm window may take: two thirds, the share of a scene build's `"auto"`. */
|
|
11366
|
+
const WARM_SHARE = 2 / 3;
|
|
11367
|
+
/** The budget of a frame when the loop answers no usable rate: two thirds of a 60 Hz frame, ≈ 11.1 ms. */
|
|
11368
|
+
const FALLBACK_WARM_MS = SECOND_MS$2 / 60 * WARM_SHARE;
|
|
11369
|
+
/**
|
|
11370
|
+
* The building budget of one frame for a warm window: two thirds of the frame interval at `fps`, or of a 60 Hz frame
|
|
11371
|
+
* for a rate that is not a finite number above 0. Pure.
|
|
11372
|
+
*
|
|
11373
|
+
* @param fps - The rate the loop runs at.
|
|
11374
|
+
* @returns Milliseconds per frame.
|
|
11375
|
+
* @example
|
|
11376
|
+
* ```ts
|
|
11377
|
+
* warmBudget(120); // 5.555…
|
|
11378
|
+
* ```
|
|
11379
|
+
*/
|
|
11380
|
+
function warmBudget(fps) {
|
|
11381
|
+
return Number.isFinite(fps) && fps > 0 ? SECOND_MS$2 / fps * WARM_SHARE : FALLBACK_WARM_MS;
|
|
11382
|
+
}
|
|
11383
|
+
/**
|
|
11384
|
+
* Tells whether two items have the same content: the same object, or equal as JSON. Pure.
|
|
11385
|
+
*
|
|
11386
|
+
* @param before - The item the view was built for.
|
|
11387
|
+
* @param after - The item that comes.
|
|
11388
|
+
* @returns True when nothing of the view has to change.
|
|
11389
|
+
* @example
|
|
11390
|
+
* ```ts
|
|
11391
|
+
* sameItem({ page: "main" }, { page: "main" }); // true
|
|
11392
|
+
* ```
|
|
11393
|
+
*/
|
|
11394
|
+
function sameItem(before, after) {
|
|
11395
|
+
return before === after || deepEquals(before, after);
|
|
11396
|
+
}
|
|
11397
|
+
/**
|
|
11398
|
+
* Tells whether a record holds a view.
|
|
11399
|
+
*
|
|
11400
|
+
* @param record - The record.
|
|
11401
|
+
* @returns True when it holds one.
|
|
11402
|
+
*/
|
|
11403
|
+
function holds$2(record) {
|
|
11404
|
+
return record.view !== void 0;
|
|
11405
|
+
}
|
|
11406
|
+
/**
|
|
11407
|
+
* Tells whether a record was read against the state of this snapshot.
|
|
11408
|
+
*
|
|
11409
|
+
* @param seen - The state the record last read.
|
|
11410
|
+
* @param snapshot - The state now.
|
|
11411
|
+
* @returns True when neither root changed since.
|
|
11412
|
+
*/
|
|
11413
|
+
function isSeen(seen, snapshot) {
|
|
11414
|
+
return seen !== void 0 && seen.player === snapshot.player && seen.session === snapshot.session;
|
|
11415
|
+
}
|
|
11416
|
+
/**
|
|
11417
|
+
* Gives a mounted projection that declares `warm` its record, cold, at the end of the warm list. A projection that
|
|
11418
|
+
* has one keeps it: a projection a scene before mounted and the coming one keeps (F23) keeps its held view.
|
|
11419
|
+
*
|
|
11420
|
+
* @param state - The projection branch of the plugin state.
|
|
11421
|
+
* @param spec - The projection spec.
|
|
11422
|
+
*/
|
|
11423
|
+
function ensureWarm(state, spec) {
|
|
11424
|
+
if (spec.warm === void 0 || state.warm.has(spec.name)) return;
|
|
11425
|
+
const record = {
|
|
11426
|
+
name: spec.name,
|
|
11427
|
+
entities: /* @__PURE__ */ new Set(),
|
|
11428
|
+
phase: "cold"
|
|
11429
|
+
};
|
|
11430
|
+
state.warm.set(spec.name, record);
|
|
11431
|
+
state.warmList.push(record);
|
|
11432
|
+
state.warmStale = true;
|
|
11433
|
+
}
|
|
11434
|
+
/**
|
|
11435
|
+
* The record whose held view a new key of a projection shows: one that holds a view of that key, built or still in
|
|
11436
|
+
* work. Only a mounted projection has a record: a name is in one table only, so a projection a scene build mounts
|
|
11437
|
+
* aside has none.
|
|
11438
|
+
*
|
|
11439
|
+
* @param state - The projection branch of the plugin state.
|
|
11440
|
+
* @param name - The projection.
|
|
11441
|
+
* @param key - The key that enters.
|
|
11442
|
+
* @returns The record, or `undefined` when the key spawns as before.
|
|
11443
|
+
*/
|
|
11444
|
+
function heldFor(state, name, key) {
|
|
11445
|
+
if (state.warm.size === 0) return void 0;
|
|
11446
|
+
const record = state.warm.get(name);
|
|
11447
|
+
if (record === void 0 || !holds$2(record) || record.phase === "shown" || record.key !== key) return;
|
|
11448
|
+
return record;
|
|
11449
|
+
}
|
|
11450
|
+
/**
|
|
11451
|
+
* Despawns what a record holds: its view, with the cause `"discard"` and no motion, then every entity `adopt` marked
|
|
11452
|
+
* for it that is still there. The removal hooks still see them held. A shown view belongs to `mounted` and is left
|
|
11453
|
+
* alone. The record keeps its phase; the caller sets it.
|
|
11454
|
+
*
|
|
11455
|
+
* @param pctx - Domain context of the projection module.
|
|
11456
|
+
* @param record - The record.
|
|
11457
|
+
*/
|
|
11458
|
+
function dropHeld(pctx, record) {
|
|
11459
|
+
const state = pctx.ctx.state.projection;
|
|
11460
|
+
const ecs = pctx.deps.ecs;
|
|
11461
|
+
const view = record.view;
|
|
11462
|
+
if (view !== void 0 && record.phase !== "shown") {
|
|
11463
|
+
cancelTracks(pctx, view.entity);
|
|
11464
|
+
state.byEntity.delete(view.entity);
|
|
11465
|
+
state.mutes.delete(view.entity);
|
|
11466
|
+
state.rests.delete(view.entity);
|
|
11467
|
+
view.cause = "discard";
|
|
11468
|
+
state.leaving.set(view.entity, "discard");
|
|
11469
|
+
state.membershipVersion += 1;
|
|
11470
|
+
ecs.despawn(view.entity);
|
|
11471
|
+
}
|
|
11472
|
+
for (const entity of record.entities) if (ecs.ownerOf(entity) !== void 0) ecs.despawn(entity);
|
|
11473
|
+
for (const entity of record.entities) state.warmHeld.delete(entity);
|
|
11474
|
+
record.entities.clear();
|
|
11475
|
+
}
|
|
11476
|
+
/**
|
|
11477
|
+
* Leaves a record cold: nothing held, no longer in work, and the warm step looks at it again.
|
|
11478
|
+
*
|
|
11479
|
+
* @param state - The projection branch of the plugin state.
|
|
11480
|
+
* @param record - The record.
|
|
11481
|
+
*/
|
|
11482
|
+
function coolRecord(state, record) {
|
|
11483
|
+
record.phase = "cold";
|
|
11484
|
+
delete record.key;
|
|
11485
|
+
delete record.item;
|
|
11486
|
+
delete record.view;
|
|
11487
|
+
if (state.warmActive === record) delete state.warmActive;
|
|
11488
|
+
state.warmStale = true;
|
|
11489
|
+
}
|
|
11490
|
+
/**
|
|
11491
|
+
* Drops what a record holds and leaves it cold, to be built again by the warm step.
|
|
11492
|
+
*
|
|
11493
|
+
* @param pctx - Domain context of the projection module.
|
|
11494
|
+
* @param record - The record.
|
|
11495
|
+
*/
|
|
11496
|
+
function discardWarm(pctx, record) {
|
|
11497
|
+
dropHeld(pctx, record);
|
|
11498
|
+
coolRecord(pctx.ctx.state.projection, record);
|
|
11499
|
+
delete record.seen;
|
|
11500
|
+
}
|
|
11501
|
+
/**
|
|
11502
|
+
* Drops the held view of every record and leaves it cold: a restore or a load replaces the state (ui would build held
|
|
11503
|
+
* roots again in one block with its others), and a forced rerun runs `view` anew (a new locale). A view `from` shows
|
|
11504
|
+
* is a live view and stays; its record is warmed again after the close.
|
|
11505
|
+
*
|
|
11506
|
+
* @param pctx - Domain context of the projection module.
|
|
11507
|
+
*/
|
|
11508
|
+
function discardHeld(pctx) {
|
|
11509
|
+
for (const record of pctx.ctx.state.projection.warmList) discardWarm(pctx, record);
|
|
11510
|
+
}
|
|
11511
|
+
/**
|
|
11512
|
+
* Drops the record in work at the start of a scene build: its parts would hold the build's readiness. A ready record
|
|
11513
|
+
* stays held and rests until the build ends; a cold one has nothing.
|
|
11514
|
+
*
|
|
11515
|
+
* @param pctx - Domain context of the projection module.
|
|
11516
|
+
*/
|
|
11517
|
+
function discardActive(pctx) {
|
|
11518
|
+
const active = pctx.ctx.state.projection.warmActive;
|
|
11519
|
+
if (active !== void 0) discardWarm(pctx, active);
|
|
11520
|
+
}
|
|
11521
|
+
/**
|
|
11522
|
+
* Forgets the record of a projection that is unmounted: its held view and the entities marked for it are despawned.
|
|
11523
|
+
*
|
|
11524
|
+
* @param pctx - Domain context of the projection module.
|
|
11525
|
+
* @param name - The projection.
|
|
11526
|
+
*/
|
|
11527
|
+
function forgetWarm(pctx, name) {
|
|
11528
|
+
const state = pctx.ctx.state.projection;
|
|
11529
|
+
const record = state.warm.get(name);
|
|
11530
|
+
if (record === void 0) return;
|
|
11531
|
+
discardWarm(pctx, record);
|
|
11532
|
+
state.warm.delete(name);
|
|
11533
|
+
state.warmList.splice(state.warmList.indexOf(record), 1);
|
|
11534
|
+
}
|
|
11535
|
+
/**
|
|
11536
|
+
* Drops every held view and forgets every record: the clear of the projections.
|
|
11537
|
+
*
|
|
11538
|
+
* @param pctx - Domain context of the projection module.
|
|
11539
|
+
*/
|
|
11540
|
+
function clearWarm(pctx) {
|
|
11541
|
+
const state = pctx.ctx.state.projection;
|
|
11542
|
+
for (const record of state.warmList) dropHeld(pctx, record);
|
|
11543
|
+
state.warm.clear();
|
|
11544
|
+
state.warmList.length = 0;
|
|
11545
|
+
state.warmHeld.clear();
|
|
11546
|
+
delete state.warmActive;
|
|
11547
|
+
state.warmStale = false;
|
|
11548
|
+
}
|
|
11549
|
+
/**
|
|
11550
|
+
* Marks an entity another plugin spawned for the record in work, so `isBuilding` answers for it and a discard
|
|
11551
|
+
* despawns it with the view. Does nothing while no record is in work.
|
|
11552
|
+
*
|
|
11553
|
+
* @param state - The projection branch of the plugin state.
|
|
11554
|
+
* @param entity - The entity.
|
|
11555
|
+
*/
|
|
11556
|
+
function adoptWarm(state, entity) {
|
|
11557
|
+
const active = state.warmActive;
|
|
11558
|
+
if (active === void 0) return;
|
|
11559
|
+
active.entities.add(entity);
|
|
11560
|
+
state.warmHeld.add(entity);
|
|
11561
|
+
}
|
|
11562
|
+
/**
|
|
11563
|
+
* Holds an element whose key a plugin registers under a projection whose warm window is closed: the record holds a
|
|
11564
|
+
* view, not shown, and the projection shows no live view, so the element can only be one of the held root's, made
|
|
11565
|
+
* after the record was ready (a row a windowed list ranges in after the solve). It joins the record as an adopted one:
|
|
11566
|
+
* `isBuilding` answers true, `entityOf` nothing, until the open; a discard despawns it with the view. A projection
|
|
11567
|
+
* that shows other keys live while it warms one is not covered: an element registered for it is taken as live.
|
|
11568
|
+
*
|
|
11569
|
+
* @param state - The projection branch of the plugin state.
|
|
11570
|
+
* @param projection - The projection the key is registered under.
|
|
11571
|
+
* @param entity - The element.
|
|
11572
|
+
*/
|
|
11573
|
+
function holdRegistered(state, projection, entity) {
|
|
11574
|
+
if (state.warm.size === 0) return;
|
|
11575
|
+
const record = state.warm.get(projection);
|
|
11576
|
+
if (record?.view === void 0 || record.phase === "shown") return;
|
|
11577
|
+
if (state.mounted.get(projection)?.live.size !== 0) return;
|
|
11578
|
+
record.entities.add(entity);
|
|
11579
|
+
state.warmHeld.add(entity);
|
|
11580
|
+
}
|
|
11581
|
+
/** What the prune's callback reads: set before the walk, so the callback is module-level and a walk makes no closure. */
|
|
11582
|
+
const pruning = { pctx: void 0 };
|
|
11583
|
+
/**
|
|
11584
|
+
* Forgets one held entity when it is gone: out of the held set and out of the record that marked it.
|
|
11585
|
+
*
|
|
11586
|
+
* @param entity - The held entity.
|
|
11587
|
+
* @param _same - The same entity, as a set hands it twice.
|
|
11588
|
+
* @param held - The held set.
|
|
11589
|
+
*/
|
|
11590
|
+
function dropDeadHeld(entity, _same, held) {
|
|
11591
|
+
const pctx = pruning.pctx;
|
|
11592
|
+
if (pctx === void 0 || pctx.deps.ecs.ownerOf(entity) !== void 0) return;
|
|
11593
|
+
held.delete(entity);
|
|
11594
|
+
const list = pctx.ctx.state.projection.warmList;
|
|
11595
|
+
for (let index = 0; index < list.length; index += 1) list[index]?.entities.delete(entity);
|
|
11596
|
+
}
|
|
11597
|
+
/**
|
|
11598
|
+
* Forgets the held entities that are gone: the elements a plugin despawned while their window was held (the rows a
|
|
11599
|
+
* refresh took away), so the held sets of a window held for a long session do not grow. The sweep calls it after a
|
|
11600
|
+
* frame that despawned an entity; with nothing held it reads one size.
|
|
11601
|
+
*
|
|
11602
|
+
* @param pctx - Domain context of the projection module.
|
|
11603
|
+
*/
|
|
11604
|
+
function forgetDeadHeld(pctx) {
|
|
11605
|
+
const held = pctx.ctx.state.projection.warmHeld;
|
|
11606
|
+
if (held.size === 0) return;
|
|
11607
|
+
const outer = pruning.pctx;
|
|
11608
|
+
pruning.pctx = pctx;
|
|
11609
|
+
held.forEach(dropDeadHeld);
|
|
11610
|
+
pruning.pctx = outer;
|
|
11611
|
+
}
|
|
11612
|
+
/**
|
|
11613
|
+
* The budget `left()` counts down in this frame: the scene build's, else the warm window's while one is in work.
|
|
11614
|
+
*
|
|
11615
|
+
* @param state - The projection branch of the plugin state.
|
|
11616
|
+
* @returns Milliseconds per frame, or `undefined` while nothing is built.
|
|
11617
|
+
*/
|
|
11618
|
+
function frameBudget(state) {
|
|
11619
|
+
if (state.building !== void 0) return state.building.budgetMs;
|
|
11620
|
+
return state.warmActive === void 0 ? void 0 : state.warmBudgetMs;
|
|
11621
|
+
}
|
|
11622
|
+
/**
|
|
11623
|
+
* Shows the held view of a record: it and every entity marked for it stop being held, the view joins the live views
|
|
11624
|
+
* of its projection with the cause of the reconcile, and the record is shown. A record still in work leaves the work:
|
|
11625
|
+
* ui builds the rest of its root in one block.
|
|
11626
|
+
*
|
|
11627
|
+
* @param pctx - Domain context of the projection module.
|
|
11628
|
+
* @param mounted - The mounted projection.
|
|
11629
|
+
* @param record - The record that holds the view.
|
|
11630
|
+
* @param cause - `"mount"` for a direct reconcile, `"change"` for a live one.
|
|
11631
|
+
*/
|
|
11632
|
+
function showHeld(pctx, mounted, record, cause) {
|
|
11633
|
+
const state = pctx.ctx.state.projection;
|
|
11634
|
+
const view = record.view;
|
|
11635
|
+
for (const entity of record.entities) state.warmHeld.delete(entity);
|
|
11636
|
+
record.entities.clear();
|
|
11637
|
+
if (state.warmActive === record) delete state.warmActive;
|
|
11638
|
+
record.phase = "shown";
|
|
11639
|
+
view.cause = cause;
|
|
11640
|
+
mounted.live.set(view.key, view);
|
|
11641
|
+
state.membershipVersion += 1;
|
|
11642
|
+
}
|
|
11643
|
+
/**
|
|
11644
|
+
* The close of a window: when the view leaving is the one a record showed, the record goes cold and is built again
|
|
11645
|
+
* in idle frames. The exit itself runs as for any view.
|
|
11646
|
+
*
|
|
11647
|
+
* @param state - The projection branch of the plugin state.
|
|
11648
|
+
* @param name - The projection.
|
|
11649
|
+
* @param view - The view that leaves the live views.
|
|
11650
|
+
*/
|
|
11651
|
+
function coolShown(state, name, view) {
|
|
11652
|
+
const record = state.warm.get(name);
|
|
11653
|
+
if (record?.view !== view) return;
|
|
11654
|
+
coolRecord(state, record);
|
|
11655
|
+
delete record.seen;
|
|
11656
|
+
}
|
|
11657
|
+
/**
|
|
11658
|
+
* Writes the difference between a view's rest pose and a new output of `view` straight onto its entity: added and
|
|
11659
|
+
* changed components are written, removed ones taken off, no hook runs and no motion plays. The direct write of a
|
|
11660
|
+
* changed item, for a held view and for the one the open shows.
|
|
11661
|
+
*
|
|
11662
|
+
* @param pctx - Domain context of the projection module.
|
|
11663
|
+
* @param view - The view.
|
|
11664
|
+
* @param next - The new output of `view(item)`, by component name.
|
|
11665
|
+
* @param item - The item it was made from.
|
|
11666
|
+
*/
|
|
11667
|
+
function writeDifference(pctx, view, next, item) {
|
|
11668
|
+
const { changed } = diffComponents(view.rest, next, pctx.deps.components.Tree.componentName);
|
|
11669
|
+
for (const [name, value] of next) if (!view.rest.has(name)) writeValue(pctx, view.entity, value);
|
|
11670
|
+
for (const [name, value] of view.rest) if (!next.has(name)) pctx.deps.ecs.remove(view.entity, value.type);
|
|
11671
|
+
view.rest = next;
|
|
11672
|
+
view.item = item;
|
|
11673
|
+
finishHandles(view);
|
|
11674
|
+
writeRestNow(pctx, view, changed);
|
|
11675
|
+
}
|
|
11676
|
+
/**
|
|
11677
|
+
* Tells whether a motion that owns its fields and ends runs: a track that is not additive and does not repeat
|
|
11678
|
+
* forever. A loop adds to its fields and runs for good, and a track that repeats forever never ends, so neither holds
|
|
11679
|
+
* the warm work back.
|
|
11680
|
+
*
|
|
11681
|
+
* @param tracks - The tracks the projection started.
|
|
11682
|
+
* @returns True while one such track is active.
|
|
11683
|
+
*/
|
|
11684
|
+
function ownedMotionRuns(tracks) {
|
|
11685
|
+
const count = tracks.length;
|
|
11686
|
+
for (let index = 0; index < count; index += 1) {
|
|
11687
|
+
const track = tracks[index];
|
|
11688
|
+
if (track !== void 0 && !track.additive && !track.forever && track.handle.active()) return true;
|
|
11689
|
+
}
|
|
11690
|
+
return false;
|
|
11691
|
+
}
|
|
11692
|
+
/**
|
|
11693
|
+
* Tells whether the world may warm now: live, no scene build, and a drawing plugin that registered an `onBuild`
|
|
11694
|
+
* check (a headless world warms nothing).
|
|
11695
|
+
*
|
|
11696
|
+
* @param pctx - Domain context of the projection module.
|
|
11697
|
+
* @returns True when the warm step may run.
|
|
11698
|
+
*/
|
|
11699
|
+
function mayWarm(pctx) {
|
|
11700
|
+
const state = pctx.ctx.state.projection;
|
|
11701
|
+
return state.building === void 0 && state.buildChecks.length > 0 && pctx.deps.ecs.mode() === "live";
|
|
11702
|
+
}
|
|
11703
|
+
/**
|
|
11704
|
+
* Polls the checks of the record in work: when every one answers true its view is built, the record is ready and
|
|
11705
|
+
* `left()` is `Infinity` again.
|
|
11706
|
+
*
|
|
11707
|
+
* @param state - The projection branch of the plugin state.
|
|
11708
|
+
* @param active - The record in work.
|
|
11709
|
+
*/
|
|
11710
|
+
function pollActive(state, active) {
|
|
11711
|
+
const checks = state.buildChecks;
|
|
11712
|
+
const count = checks.length;
|
|
11713
|
+
for (let index = 0; index < count; index += 1) if (checks[index]?.() !== true) return;
|
|
11714
|
+
active.phase = "ready";
|
|
11715
|
+
delete state.warmActive;
|
|
11716
|
+
}
|
|
11717
|
+
/**
|
|
11718
|
+
* Reads the warm item of a projection and its key. A `warm` or a `key` that throws is logged as a projection that
|
|
11719
|
+
* failed, and nothing is warm.
|
|
11720
|
+
*
|
|
11721
|
+
* @param pctx - Domain context of the projection module.
|
|
11722
|
+
* @param spec - The projection spec, which declares `warm`.
|
|
11723
|
+
* @param snapshot - The state now.
|
|
11724
|
+
* @returns The item and its key, or `undefined` for no item and for a throw.
|
|
11725
|
+
*/
|
|
11726
|
+
function readWarm(pctx, spec, snapshot) {
|
|
11727
|
+
try {
|
|
11728
|
+
const item = spec.warm?.(snapshot.player, snapshot.session);
|
|
11729
|
+
if (item === void 0 || item === null) return void 0;
|
|
11730
|
+
return {
|
|
11731
|
+
item,
|
|
11732
|
+
key: spec.key?.(item) ?? spec.name
|
|
11733
|
+
};
|
|
11734
|
+
} catch (error) {
|
|
11735
|
+
pctx.ctx.log.error("world:projection-failed", { projection: spec.name }, asError$2(error));
|
|
11736
|
+
return;
|
|
11737
|
+
}
|
|
11738
|
+
}
|
|
11739
|
+
/**
|
|
11740
|
+
* Runs `view` for a warm item. A throw is logged as a projection that failed.
|
|
11741
|
+
*
|
|
11742
|
+
* @param pctx - Domain context of the projection module.
|
|
11743
|
+
* @param spec - The projection spec.
|
|
11744
|
+
* @param item - The warm item.
|
|
11745
|
+
* @returns The component values, or `undefined` when `view` threw.
|
|
11746
|
+
*/
|
|
11747
|
+
function viewOfItem(pctx, spec, item) {
|
|
11748
|
+
try {
|
|
11749
|
+
return collectView(pctx, spec, item);
|
|
11750
|
+
} catch (error) {
|
|
11751
|
+
pctx.ctx.log.error("world:projection-failed", { projection: spec.name }, asError$2(error));
|
|
11752
|
+
return;
|
|
11753
|
+
}
|
|
11754
|
+
}
|
|
11755
|
+
/**
|
|
11756
|
+
* Starts the work of a record: it becomes the record in work, `left()` counts the warm budget from the frame rate
|
|
11757
|
+
* the loop runs at, and the loop is woken, so the building frames come at the full rate.
|
|
11758
|
+
*
|
|
11759
|
+
* @param pctx - Domain context of the projection module.
|
|
11760
|
+
* @param record - The record.
|
|
11761
|
+
*/
|
|
11762
|
+
function startWork(pctx, record) {
|
|
11763
|
+
const state = pctx.ctx.state.projection;
|
|
11764
|
+
record.phase = "building";
|
|
11765
|
+
state.warmActive = record;
|
|
11766
|
+
state.warmBudgetMs = warmBudget(pctx.ctx.deps.time.rate().fps);
|
|
11767
|
+
pctx.ctx.deps.time.wake();
|
|
11768
|
+
}
|
|
11769
|
+
/**
|
|
11770
|
+
* Spawns the held view of a warm item, as a scene build spawns a view: bare, flagged held, then its `Layer` and its
|
|
11771
|
+
* view components, so an `onAdded` hook already asks `isBuilding` true, and with `"change"` as its cause, so its
|
|
11772
|
+
* enter plays when it is shown. The record is in work from before the spawn: what ui marks in its hooks is the
|
|
11773
|
+
* record's. Nothing is spawned when `view` throws.
|
|
11774
|
+
*
|
|
11775
|
+
* @param pctx - Domain context of the projection module.
|
|
11776
|
+
* @param spec - The projection spec.
|
|
11777
|
+
* @param record - The cold record.
|
|
11778
|
+
* @param warm - The warm item and its key.
|
|
11779
|
+
* @param warm.item - The warm item.
|
|
11780
|
+
* @param warm.key - Its key.
|
|
11781
|
+
*/
|
|
11782
|
+
function spawnWarm(pctx, spec, record, warm) {
|
|
11783
|
+
const values = viewOfItem(pctx, spec, warm.item);
|
|
11784
|
+
if (values === void 0) return;
|
|
11785
|
+
const state = pctx.ctx.state.projection;
|
|
11786
|
+
startWork(pctx, record);
|
|
11787
|
+
const entity = spawnFlagged(pctx, spec, values, state.warmHeld);
|
|
11788
|
+
const view = createViewRecord(entity, spec.name, warm.key, warm.item, values, "change");
|
|
11789
|
+
record.entities.add(entity);
|
|
11790
|
+
seedMutes(state, spec, entity);
|
|
11791
|
+
state.byEntity.set(entity, view);
|
|
11792
|
+
record.view = view;
|
|
11793
|
+
record.key = warm.key;
|
|
11794
|
+
record.item = warm.item;
|
|
11795
|
+
}
|
|
11796
|
+
/**
|
|
11797
|
+
* Brings a ready record up to the warm item a commit gave: the same content changes nothing; the same key writes the
|
|
11798
|
+
* difference into the held view, which ui builds again in parts; another key drops the view and spawns the new one.
|
|
11799
|
+
*
|
|
11800
|
+
* @param pctx - Domain context of the projection module.
|
|
11801
|
+
* @param spec - The projection spec.
|
|
11802
|
+
* @param record - The ready record.
|
|
11803
|
+
* @param warm - The warm item and its key.
|
|
11804
|
+
* @param warm.item - The warm item.
|
|
11805
|
+
* @param warm.key - Its key.
|
|
11806
|
+
* @returns True when the step did work.
|
|
11807
|
+
*/
|
|
11808
|
+
function refreshWarm(pctx, spec, record, warm) {
|
|
11809
|
+
const view = record.view;
|
|
11810
|
+
if (view !== void 0 && warm.key === record.key) {
|
|
11811
|
+
if (sameItem(record.item, warm.item)) return false;
|
|
11812
|
+
const next = viewOfItem(pctx, spec, warm.item);
|
|
11813
|
+
if (next === void 0) {
|
|
11814
|
+
dropHeld(pctx, record);
|
|
11815
|
+
coolRecord(pctx.ctx.state.projection, record);
|
|
11816
|
+
return true;
|
|
11817
|
+
}
|
|
11818
|
+
startWork(pctx, record);
|
|
11819
|
+
writeDifference(pctx, view, next, warm.item);
|
|
11820
|
+
record.item = warm.item;
|
|
11821
|
+
return true;
|
|
11822
|
+
}
|
|
11823
|
+
dropHeld(pctx, record);
|
|
11824
|
+
coolRecord(pctx.ctx.state.projection, record);
|
|
11825
|
+
spawnWarm(pctx, spec, record, warm);
|
|
11826
|
+
return true;
|
|
11827
|
+
}
|
|
11828
|
+
/**
|
|
11829
|
+
* One record's turn in the warm step: a record shown, in work, or read against this state is passed over. Otherwise
|
|
11830
|
+
* `warm` is read: with no item, or with a key `from` shows, what is held is dropped; a cold record spawns its held
|
|
11831
|
+
* view, a ready one is brought up to date.
|
|
11832
|
+
*
|
|
11833
|
+
* @param pctx - Domain context of the projection module.
|
|
11834
|
+
* @param record - The record.
|
|
11835
|
+
* @param snapshot - The state now.
|
|
11836
|
+
* @returns True when the step did work, so the frame takes no more.
|
|
11837
|
+
*/
|
|
11838
|
+
function stepRecord$1(pctx, record, snapshot) {
|
|
11839
|
+
if (record.phase === "shown" || record.phase === "building") return false;
|
|
11840
|
+
if (isSeen(record.seen, snapshot)) return false;
|
|
11841
|
+
const state = pctx.ctx.state.projection;
|
|
11842
|
+
const spec = state.specs.get(record.name);
|
|
11843
|
+
if (spec === void 0) return false;
|
|
11844
|
+
record.seen = snapshot;
|
|
11845
|
+
const warm = readWarm(pctx, spec, snapshot);
|
|
11846
|
+
if (warm === void 0 || state.mounted.get(record.name)?.items.has(warm.key) === true) {
|
|
11847
|
+
if (record.view === void 0) return false;
|
|
11848
|
+
dropHeld(pctx, record);
|
|
11849
|
+
coolRecord(state, record);
|
|
11850
|
+
return true;
|
|
11851
|
+
}
|
|
11852
|
+
if (record.phase === "ready") return refreshWarm(pctx, spec, record, warm);
|
|
11853
|
+
spawnWarm(pctx, spec, record, warm);
|
|
11854
|
+
return record.view !== void 0;
|
|
11855
|
+
}
|
|
11856
|
+
/**
|
|
11857
|
+
* Takes the next record that has work, in mounted order, and does its one step. A walk that finds none leaves the
|
|
11858
|
+
* world at rest until a commit or a close.
|
|
11859
|
+
*
|
|
11860
|
+
* @param pctx - Domain context of the projection module.
|
|
11861
|
+
*/
|
|
11862
|
+
function stepNext(pctx) {
|
|
11863
|
+
const state = pctx.ctx.state.projection;
|
|
11864
|
+
const snapshot = pctx.ctx.deps.model.store.snapshot();
|
|
11865
|
+
for (const record of state.warmList) if (stepRecord$1(pctx, record, snapshot)) return;
|
|
11866
|
+
state.warmStale = false;
|
|
11867
|
+
}
|
|
11868
|
+
/**
|
|
11869
|
+
* One step of the warm windows, run in world's `input` callback after the reconcile. At rest it reads two fields and
|
|
11870
|
+
* returns. It runs only in a live world with no scene build, a drawing plugin, and no motion that owns its fields and
|
|
11871
|
+
* ends: the frames of an animation get no warm step. Where it may not run, the record in work is dropped: a paused or
|
|
11872
|
+
* fast world builds no part of it, and `left()` would stay finite for good; it is built again once the step runs.
|
|
11873
|
+
* While a record is in work its checks are polled; otherwise the next record with work spawns, patches or drops its
|
|
11874
|
+
* held view. One step a frame.
|
|
11875
|
+
*
|
|
11876
|
+
* @param pctx - Domain context of the projection module.
|
|
11877
|
+
*/
|
|
11878
|
+
function stepWarm(pctx) {
|
|
11879
|
+
const state = pctx.ctx.state.projection;
|
|
11880
|
+
const active = state.warmActive;
|
|
11881
|
+
if (active === void 0 && !state.warmStale) return;
|
|
11882
|
+
if (!mayWarm(pctx)) {
|
|
11883
|
+
if (active !== void 0) discardWarm(pctx, active);
|
|
11884
|
+
return;
|
|
11885
|
+
}
|
|
11886
|
+
if (ownedMotionRuns(state.tracks)) return;
|
|
11887
|
+
if (active === void 0) stepNext(pctx);
|
|
11888
|
+
else pollActive(state, active);
|
|
11889
|
+
}
|
|
11890
|
+
//#endregion
|
|
11315
11891
|
//#region src/plugins/world/projection/reconcile.ts
|
|
11316
|
-
/** The components of a view of the build at its spawn: none, so it is flagged before the first `onAdded`. */
|
|
11317
|
-
const NO_COMPONENTS = [];
|
|
11318
11892
|
/**
|
|
11319
11893
|
* Creates the empty set of used hints. It lives in its own non-exported function because lint
|
|
11320
11894
|
* rule L5 refuses a collection built inside an exported declaration.
|
|
@@ -11379,16 +11953,14 @@ function hintFor$1(pctx, projection, key, used) {
|
|
|
11379
11953
|
return hint;
|
|
11380
11954
|
}
|
|
11381
11955
|
/**
|
|
11382
|
-
*
|
|
11383
|
-
*
|
|
11384
|
-
*
|
|
11385
|
-
*
|
|
11386
|
-
* A view of a projection the running build mounts is spawned bare, flagged building, then given
|
|
11387
|
-
* its components in the same order: the `onAdded` hooks of a plugin then tell it apart (F97).
|
|
11956
|
+
* Plays how a view comes when the reconcile plays motions: the `enter` hook and the `loop` hook,
|
|
11957
|
+
* then the settle of what is loose. The loop is not kept with the view's handles: a change cancels
|
|
11958
|
+
* those, and the loop runs until the view dies. A direct reconcile plays neither hook; the view
|
|
11959
|
+
* then owes its loop, which the sweep starts.
|
|
11388
11960
|
*
|
|
11389
11961
|
* @param pctx - Domain context of the projection module.
|
|
11390
11962
|
* @param spec - The projection spec.
|
|
11391
|
-
* @param
|
|
11963
|
+
* @param view - The view that came: spawned now, or shown from a warm window.
|
|
11392
11964
|
* @param entry - The key, its item, the peers, the mode and the used hints.
|
|
11393
11965
|
* @param entry.key - The model key.
|
|
11394
11966
|
* @param entry.item - The model item.
|
|
@@ -11396,33 +11968,12 @@ function hintFor$1(pctx, projection, key, used) {
|
|
|
11396
11968
|
* @param entry.direct - Whether the reconcile writes without motions.
|
|
11397
11969
|
* @param entry.used - The hints that reached an entry.
|
|
11398
11970
|
*/
|
|
11399
|
-
function
|
|
11400
|
-
const values = collectView(pctx, spec, entry.item);
|
|
11401
|
-
const state = pctx.ctx.state.projection;
|
|
11402
|
-
const building = state.building;
|
|
11403
|
-
const ecs = pctx.deps.ecs;
|
|
11404
|
-
const owner = {
|
|
11405
|
-
kind: "projection",
|
|
11406
|
-
name: spec.name
|
|
11407
|
-
};
|
|
11408
|
-
const layer = pctx.deps.components.Layer({ name: spec.layer });
|
|
11409
|
-
let entity;
|
|
11410
|
-
if (building?.mounted.get(spec.name) === mounted) {
|
|
11411
|
-
entity = ecs.spawn(owner, NO_COMPONENTS);
|
|
11412
|
-
building.entities.add(entity);
|
|
11413
|
-
ecs.add(entity, layer);
|
|
11414
|
-
for (const value of values.values()) ecs.add(entity, value);
|
|
11415
|
-
} else entity = ecs.spawn(owner, [layer, ...values.values()]);
|
|
11416
|
-
const view = createViewRecord(entity, spec.name, entry.key, entry.item, values, entry.direct ? "mount" : "change");
|
|
11417
|
-
seedMutes(state, spec, entity);
|
|
11418
|
-
mounted.live.set(entry.key, view);
|
|
11419
|
-
state.byEntity.set(entity, view);
|
|
11420
|
-
state.membershipVersion += 1;
|
|
11971
|
+
function playEnter$1(pctx, spec, view, entry) {
|
|
11421
11972
|
const hook = spec.motion?.enter;
|
|
11422
11973
|
const loop = spec.motion?.loop;
|
|
11423
11974
|
if (entry.direct) {
|
|
11424
11975
|
view.loopOwed = true;
|
|
11425
|
-
state.owedLoops += 1;
|
|
11976
|
+
pctx.ctx.state.projection.owedLoops += 1;
|
|
11426
11977
|
return;
|
|
11427
11978
|
}
|
|
11428
11979
|
if (hook === void 0 && loop === void 0) return;
|
|
@@ -11436,6 +11987,68 @@ function enterEntry(pctx, spec, mounted, entry) {
|
|
|
11436
11987
|
playSettle(pctx, view, spec, entry.peers, looseComponents(pctx, view));
|
|
11437
11988
|
}
|
|
11438
11989
|
/**
|
|
11990
|
+
* A key that is new: spawn the entity with the projection's layer and the view components, then
|
|
11991
|
+
* play how it comes (`playEnter`). A view of a projection the running build mounts is spawned bare,
|
|
11992
|
+
* flagged building, then given its components in the same order: the `onAdded` hooks of a plugin
|
|
11993
|
+
* then tell it apart (F97).
|
|
11994
|
+
*
|
|
11995
|
+
* @param pctx - Domain context of the projection module.
|
|
11996
|
+
* @param spec - The projection spec.
|
|
11997
|
+
* @param mounted - The mounted projection.
|
|
11998
|
+
* @param entry - The key, its item, the peers, the mode and the used hints.
|
|
11999
|
+
* @param entry.key - The model key.
|
|
12000
|
+
* @param entry.item - The model item.
|
|
12001
|
+
* @param entry.peers - The new and the old items.
|
|
12002
|
+
* @param entry.direct - Whether the reconcile writes without motions.
|
|
12003
|
+
* @param entry.used - The hints that reached an entry.
|
|
12004
|
+
*/
|
|
12005
|
+
function enterEntry(pctx, spec, mounted, entry) {
|
|
12006
|
+
const values = collectView(pctx, spec, entry.item);
|
|
12007
|
+
const state = pctx.ctx.state.projection;
|
|
12008
|
+
const building = state.building;
|
|
12009
|
+
let entity;
|
|
12010
|
+
if (building?.mounted.get(spec.name) === mounted) entity = spawnFlagged(pctx, spec, values, building.entities);
|
|
12011
|
+
else {
|
|
12012
|
+
const layer = pctx.deps.components.Layer({ name: spec.layer });
|
|
12013
|
+
entity = pctx.deps.ecs.spawn({
|
|
12014
|
+
kind: "projection",
|
|
12015
|
+
name: spec.name
|
|
12016
|
+
}, [layer, ...values.values()]);
|
|
12017
|
+
}
|
|
12018
|
+
const view = createViewRecord(entity, spec.name, entry.key, entry.item, values, entry.direct ? "mount" : "change");
|
|
12019
|
+
seedMutes(state, spec, entity);
|
|
12020
|
+
mounted.live.set(entry.key, view);
|
|
12021
|
+
state.byEntity.set(entity, view);
|
|
12022
|
+
state.membershipVersion += 1;
|
|
12023
|
+
playEnter$1(pctx, spec, view, entry);
|
|
12024
|
+
}
|
|
12025
|
+
/**
|
|
12026
|
+
* A key that is new while a warm window holds its view: the held view is shown instead of a spawn,
|
|
12027
|
+
* the same entity, built already. An item with the content of the warm one runs no `view` and
|
|
12028
|
+
* writes nothing; another one has the difference written directly, with no `change` hook. Then it
|
|
12029
|
+
* comes as a spawned view does (`playEnter`). A `view` that throws leaves the window held, as an
|
|
12030
|
+
* enter that throws spawns nothing.
|
|
12031
|
+
*
|
|
12032
|
+
* @param pctx - Domain context of the projection module.
|
|
12033
|
+
* @param spec - The projection spec.
|
|
12034
|
+
* @param mounted - The mounted projection.
|
|
12035
|
+
* @param record - The warm record that holds the view of the key.
|
|
12036
|
+
* @param entry - The key, its item, the peers, the mode and the used hints.
|
|
12037
|
+
* @param entry.key - The model key.
|
|
12038
|
+
* @param entry.item - The model item.
|
|
12039
|
+
* @param entry.peers - The new and the old items.
|
|
12040
|
+
* @param entry.direct - Whether the reconcile writes without motions.
|
|
12041
|
+
* @param entry.used - The hints that reached an entry.
|
|
12042
|
+
*/
|
|
12043
|
+
function adoptEntry(pctx, spec, mounted, record, entry) {
|
|
12044
|
+
const view = record.view;
|
|
12045
|
+
const next = sameItem(record.item, entry.item) ? void 0 : collectView(pctx, spec, entry.item);
|
|
12046
|
+
showHeld(pctx, mounted, record, entry.direct ? "mount" : "change");
|
|
12047
|
+
if (next === void 0) view.item = entry.item;
|
|
12048
|
+
else writeDifference(pctx, view, next, entry.item);
|
|
12049
|
+
playEnter$1(pctx, spec, view, entry);
|
|
12050
|
+
}
|
|
12051
|
+
/**
|
|
11439
12052
|
* A key whose item is another object than before: structural changes are written, a changed
|
|
11440
12053
|
* component with a hook is handed to it and one without is written directly, then the retarget
|
|
11441
12054
|
* settles what is loose. A view no motion moves after that gets its pending `lift(false)`.
|
|
@@ -11545,9 +12158,11 @@ function reviveEntry(pctx, spec, mounted, view, entry) {
|
|
|
11545
12158
|
*/
|
|
11546
12159
|
function exitEntry(pctx, spec, mounted, view, entry) {
|
|
11547
12160
|
const hook = spec.motion?.exit;
|
|
12161
|
+
const state = pctx.ctx.state.projection;
|
|
11548
12162
|
mounted.live.delete(view.key);
|
|
11549
|
-
|
|
12163
|
+
state.membershipVersion += 1;
|
|
11550
12164
|
view.cause = entry.direct ? "mount" : "change";
|
|
12165
|
+
coolShown(state, spec.name, view);
|
|
11551
12166
|
if (entry.direct || hook === void 0) {
|
|
11552
12167
|
despawnView(pctx, mounted, view);
|
|
11553
12168
|
return;
|
|
@@ -11590,7 +12205,7 @@ function settleUnchanged(pctx, spec, view, entry) {
|
|
|
11590
12205
|
}
|
|
11591
12206
|
/**
|
|
11592
12207
|
* Routes one key of the new state to the entry it belongs to: a live view changes, a queued view
|
|
11593
|
-
* revives, an unknown key enters.
|
|
12208
|
+
* revives, a key a warm window holds is shown, an unknown key enters.
|
|
11594
12209
|
*
|
|
11595
12210
|
* @param pctx - Domain context of the projection module.
|
|
11596
12211
|
* @param spec - The projection spec.
|
|
@@ -11616,7 +12231,9 @@ function applyEntry(pctx, spec, mounted, entry, counts) {
|
|
|
11616
12231
|
}
|
|
11617
12232
|
const queued = mounted.queue.find((view) => view.key === entry.key);
|
|
11618
12233
|
if (queued === void 0) {
|
|
11619
|
-
|
|
12234
|
+
const held = heldFor(pctx.ctx.state.projection, spec.name, entry.key);
|
|
12235
|
+
if (held === void 0) enterEntry(pctx, spec, mounted, entry);
|
|
12236
|
+
else adoptEntry(pctx, spec, mounted, held, entry);
|
|
11620
12237
|
counts.entered += 1;
|
|
11621
12238
|
return;
|
|
11622
12239
|
}
|
|
@@ -11984,7 +12601,8 @@ function drawsAlike(before, after, spec) {
|
|
|
11984
12601
|
}
|
|
11985
12602
|
/**
|
|
11986
12603
|
* Unmounts projections: every motion of their views is finished, and the live views and the
|
|
11987
|
-
* despawn queue are despawned in the same call
|
|
12604
|
+
* despawn queue are despawned in the same call, and so is the view a warm window holds hidden.
|
|
12605
|
+
* An unknown or unmounted name is skipped.
|
|
11988
12606
|
*
|
|
11989
12607
|
* @param pctx - Domain context of the projection module.
|
|
11990
12608
|
* @param names - Names of the projections to unmount.
|
|
@@ -11995,6 +12613,7 @@ function unmountNames(pctx, names) {
|
|
|
11995
12613
|
const mounted = state.mounted.get(name);
|
|
11996
12614
|
if (mounted === void 0) continue;
|
|
11997
12615
|
clearMounted(pctx, mounted);
|
|
12616
|
+
forgetWarm(pctx, name);
|
|
11998
12617
|
state.mounted.delete(name);
|
|
11999
12618
|
}
|
|
12000
12619
|
}
|
|
@@ -12052,7 +12671,8 @@ function mountNames(pctx, names, owner) {
|
|
|
12052
12671
|
/**
|
|
12053
12672
|
* Gives every projection of a list its place under the current layer list: a missing one gets an
|
|
12054
12673
|
* empty record at the `Order` of its place, a kept one mounted under another list takes its new
|
|
12055
|
-
* place (`placeMounted`). A screen root draws at its place in the list
|
|
12674
|
+
* place (`placeMounted`), its held warm view too. A screen root draws at its place in the list
|
|
12675
|
+
* (spec 16 U1.6). A projection that declares `warm` gets its warm record, cold, unless it has one.
|
|
12056
12676
|
*
|
|
12057
12677
|
* @param pctx - Domain context of the projection module.
|
|
12058
12678
|
* @param names - The projection list of the scene.
|
|
@@ -12064,7 +12684,9 @@ function placeNames(pctx, names, owner) {
|
|
|
12064
12684
|
const order = orderIn(names, name);
|
|
12065
12685
|
const mounted = state.mounted.get(name);
|
|
12066
12686
|
if (mounted === void 0) state.mounted.set(name, emptyMounted(owner, order, state.layers));
|
|
12067
|
-
else if (mounted.layers !== state.layers) placeMounted(pctx, mounted, order);
|
|
12687
|
+
else if (mounted.layers !== state.layers) placeMounted(pctx, mounted, order, state.warm.get(name)?.view);
|
|
12688
|
+
const spec = state.specs.get(name);
|
|
12689
|
+
if (spec !== void 0) ensureWarm(state, spec);
|
|
12068
12690
|
}
|
|
12069
12691
|
}
|
|
12070
12692
|
/**
|
|
@@ -12092,20 +12714,17 @@ function reconcileFresh(pctx, names) {
|
|
|
12092
12714
|
* @param names - The projection list of the coming scene.
|
|
12093
12715
|
* @param layers - The layer list of the coming scene.
|
|
12094
12716
|
* @param owner - Who owns the entities of the projections it mounts.
|
|
12095
|
-
* @param
|
|
12096
|
-
* @
|
|
12097
|
-
* @param timing.now - The game clock at the build start.
|
|
12098
|
-
* @returns The table, its frame starting at the build start.
|
|
12717
|
+
* @param budgetMs - Milliseconds per frame the building work may take.
|
|
12718
|
+
* @returns The table.
|
|
12099
12719
|
*/
|
|
12100
|
-
function emptyBuilding(names, layers, owner,
|
|
12720
|
+
function emptyBuilding(names, layers, owner, budgetMs) {
|
|
12101
12721
|
return {
|
|
12102
12722
|
names: [...names],
|
|
12103
12723
|
layers,
|
|
12104
12724
|
owner,
|
|
12105
12725
|
mounted: /* @__PURE__ */ new Map(),
|
|
12106
12726
|
entities: /* @__PURE__ */ new Set(),
|
|
12107
|
-
|
|
12108
|
-
budgetMs: timing.budgetMs
|
|
12727
|
+
budgetMs
|
|
12109
12728
|
};
|
|
12110
12729
|
}
|
|
12111
12730
|
/**
|
|
@@ -12147,6 +12766,8 @@ function handBack(pctx, building) {
|
|
|
12147
12766
|
* a mount checks it, against the coming layers; a projection the current scene mounts and the
|
|
12148
12767
|
* coming one declares alike stays as it is, and every other one is mounted aside, direct. A view
|
|
12149
12768
|
* that throws leaves nothing behind: what the build spawned is despawned and the throw goes on.
|
|
12769
|
+
* The warm window in work is dropped first, or its parts would hold the build's readiness; a ready
|
|
12770
|
+
* one stays held, and no warm work runs until the build ends. The frame budget counts from now.
|
|
12150
12771
|
*
|
|
12151
12772
|
* @param pctx - Domain context of the projection module.
|
|
12152
12773
|
* @param names - The projection list of the coming scene.
|
|
@@ -12162,10 +12783,9 @@ function buildNames(pctx, names, owner, layers, budgetMs) {
|
|
|
12162
12783
|
if (state.building !== void 0) throw new Error("[game] A scene is already being built.\n Commit or discard the running build before the next one starts.");
|
|
12163
12784
|
const { fresh, again } = sortMount(pctx, names, layers);
|
|
12164
12785
|
if (again.length > 0) return false;
|
|
12165
|
-
|
|
12166
|
-
|
|
12167
|
-
|
|
12168
|
-
});
|
|
12786
|
+
discardActive(pctx);
|
|
12787
|
+
state.frameStart = pctx.ctx.deps.clock.now();
|
|
12788
|
+
const building = emptyBuilding(names, layers, owner, budgetMs);
|
|
12169
12789
|
for (const spec of fresh) building.mounted.set(spec.name, emptyMounted(owner, orderIn(names, spec.name), layers));
|
|
12170
12790
|
state.building = building;
|
|
12171
12791
|
if (fresh.length === 0) return true;
|
|
@@ -12330,6 +12950,8 @@ function createProjectionApi(ctx, deps) {
|
|
|
12330
12950
|
* Reconciles what is dirty. The cause table decides play or direct, whether every live view
|
|
12331
12951
|
* and every element with a recorded rest pose is brought to it (a restore and a load do that),
|
|
12332
12952
|
* and whether an unchanged view that stands off its rest pose is settled (a rollback does).
|
|
12953
|
+
* A restore, a load and a forced rerun drop the views warm windows hold hidden first: they
|
|
12954
|
+
* replace the state or run `view` anew. After a reconcile the warm step looks at its records.
|
|
12333
12955
|
*/
|
|
12334
12956
|
const reconcileIfDirty = () => {
|
|
12335
12957
|
const dirty = state.dirty;
|
|
@@ -12338,12 +12960,14 @@ function createProjectionApi(ctx, deps) {
|
|
|
12338
12960
|
const direct = dirty.force || dirty.causes.some((cause) => isDirectCause(cause)) || deps.ecs.mode() !== "live";
|
|
12339
12961
|
const converge = dirty.causes.some((cause) => isConvergeCause(cause));
|
|
12340
12962
|
const settle = dirty.causes.includes("rollback");
|
|
12963
|
+
if (converge || dirty.force) discardHeld(pctx);
|
|
12341
12964
|
reconcile(pctx, {
|
|
12342
12965
|
direct,
|
|
12343
12966
|
force: dirty.force,
|
|
12344
12967
|
converge,
|
|
12345
12968
|
settle
|
|
12346
12969
|
});
|
|
12970
|
+
if (state.warmList.length > 0) state.warmStale = true;
|
|
12347
12971
|
}
|
|
12348
12972
|
state.hints.length = 0;
|
|
12349
12973
|
};
|
|
@@ -12375,7 +12999,10 @@ function createProjectionApi(ctx, deps) {
|
|
|
12375
12999
|
const seed = learnSeed(state, spec);
|
|
12376
13000
|
state.specs.set(spec.name, spec);
|
|
12377
13001
|
reseedViews(state, spec.name, from, seed);
|
|
12378
|
-
if (mounted)
|
|
13002
|
+
if (!mounted) return;
|
|
13003
|
+
if (spec.warm === void 0) forgetWarm(pctx, spec.name);
|
|
13004
|
+
else ensureWarm(state, spec);
|
|
13005
|
+
forceRerun();
|
|
12379
13006
|
},
|
|
12380
13007
|
setLayers: (list) => {
|
|
12381
13008
|
state.layers = Object.freeze(list.map((layer) => ({ ...layer })));
|
|
@@ -12431,7 +13058,10 @@ function createProjectionApi(ctx, deps) {
|
|
|
12431
13058
|
membershipVersion: () => state.membershipVersion,
|
|
12432
13059
|
causeOf: (entity) => state.byEntity.get(entity)?.cause ?? state.leaving.get(entity),
|
|
12433
13060
|
motionsOf: (entity) => runningComponents(state.tracks, entity),
|
|
12434
|
-
entityOf: (projection, key) =>
|
|
13061
|
+
entityOf: (projection, key) => {
|
|
13062
|
+
const entity = state.mounted.get(projection)?.live.get(key)?.entity ?? state.keys.get(projection)?.get(key);
|
|
13063
|
+
return entity === void 0 || state.building?.entities.has(entity) === true || state.warmHeld.has(entity) ? void 0 : entity;
|
|
13064
|
+
},
|
|
12435
13065
|
entitiesOf: (name) => {
|
|
12436
13066
|
const mounted = state.mounted.get(name) ?? state.building?.mounted.get(name);
|
|
12437
13067
|
return mounted === void 0 ? [] : liveEntities(mounted);
|
|
@@ -12465,6 +13095,7 @@ function createProjectionApi(ctx, deps) {
|
|
|
12465
13095
|
key
|
|
12466
13096
|
});
|
|
12467
13097
|
state.sweptDespawns = -1;
|
|
13098
|
+
holdRegistered(state, projection, entity);
|
|
12468
13099
|
return () => {
|
|
12469
13100
|
if (byKey.get(key) === entity) byKey.delete(key);
|
|
12470
13101
|
if (state.keysByEntity.get(entity)?.key === key) state.keysByEntity.delete(entity);
|
|
@@ -12492,11 +13123,11 @@ function createProjectionApi(ctx, deps) {
|
|
|
12492
13123
|
discardBuild(pctx);
|
|
12493
13124
|
},
|
|
12494
13125
|
left: () => {
|
|
12495
|
-
const
|
|
12496
|
-
if (
|
|
12497
|
-
return
|
|
13126
|
+
const budget = frameBudget(state);
|
|
13127
|
+
if (budget === void 0) return Number.POSITIVE_INFINITY;
|
|
13128
|
+
return budget - (ctx.deps.clock.now() - state.frameStart);
|
|
12498
13129
|
},
|
|
12499
|
-
isBuilding: (entity) => state.building?.entities.has(entity) === true,
|
|
13130
|
+
isBuilding: (entity) => state.building?.entities.has(entity) === true || state.warmHeld.has(entity),
|
|
12500
13131
|
onBuild: (check) => {
|
|
12501
13132
|
state.buildChecks.push(check);
|
|
12502
13133
|
return () => {
|
|
@@ -12505,11 +13136,15 @@ function createProjectionApi(ctx, deps) {
|
|
|
12505
13136
|
};
|
|
12506
13137
|
},
|
|
12507
13138
|
adopt: (entity) => {
|
|
12508
|
-
state.building
|
|
13139
|
+
const building = state.building;
|
|
13140
|
+
if (building === void 0) adoptWarm(state, entity);
|
|
13141
|
+
else building.entities.add(entity);
|
|
12509
13142
|
},
|
|
12510
13143
|
startFrame: (now) => {
|
|
12511
|
-
|
|
12512
|
-
|
|
13144
|
+
state.frameStart = now;
|
|
13145
|
+
},
|
|
13146
|
+
stepWarm: () => {
|
|
13147
|
+
stepWarm(pctx);
|
|
12513
13148
|
},
|
|
12514
13149
|
markDirty: (roots, cause) => {
|
|
12515
13150
|
const dirty = state.dirty ?? emptyDirty();
|
|
@@ -12532,6 +13167,7 @@ function createProjectionApi(ctx, deps) {
|
|
|
12532
13167
|
if (state.sweptDespawns !== despawns) {
|
|
12533
13168
|
state.sweptDespawns = despawns;
|
|
12534
13169
|
forgetDeadElements(pctx);
|
|
13170
|
+
forgetDeadHeld(pctx);
|
|
12535
13171
|
}
|
|
12536
13172
|
if (state.owedLoops > 0) startOwedLoops(pctx);
|
|
12537
13173
|
},
|
|
@@ -12546,10 +13182,13 @@ function createProjectionApi(ctx, deps) {
|
|
|
12546
13182
|
ownerLeft: (owner) => {
|
|
12547
13183
|
if (owner.kind !== "projection") return;
|
|
12548
13184
|
const mounted = state.mounted.get(owner.name);
|
|
13185
|
+
const warm = state.warm.get(owner.name);
|
|
12549
13186
|
if (mounted !== void 0) clearMounted(pctx, mounted);
|
|
13187
|
+
if (warm !== void 0) discardWarm(pctx, warm);
|
|
12550
13188
|
},
|
|
12551
13189
|
clear: () => {
|
|
12552
13190
|
discardBuild(pctx);
|
|
13191
|
+
clearWarm(pctx);
|
|
12553
13192
|
for (const mounted of [...state.mounted.values()]) clearMounted(pctx, mounted);
|
|
12554
13193
|
state.mounted.clear();
|
|
12555
13194
|
state.specs.clear();
|
|
@@ -12837,9 +13476,19 @@ function emptyWeakMap$2() {
|
|
|
12837
13476
|
return /* @__PURE__ */ new WeakMap();
|
|
12838
13477
|
}
|
|
12839
13478
|
/**
|
|
13479
|
+
* Creates an empty set. It lives in its own non-exported function because lint rule L5 refuses a
|
|
13480
|
+
* collection built inside an exported declaration.
|
|
13481
|
+
*
|
|
13482
|
+
* @returns An empty set.
|
|
13483
|
+
*/
|
|
13484
|
+
function emptySet$8() {
|
|
13485
|
+
return /* @__PURE__ */ new Set();
|
|
13486
|
+
}
|
|
13487
|
+
/**
|
|
12840
13488
|
* Creates the initial projection state: nothing registered, nothing mounted, no layer list, no
|
|
12841
13489
|
* running track and no driver, so every motion is instant until `anim` installs one. No build
|
|
12842
|
-
* runs: `building` is absent.
|
|
13490
|
+
* runs: `building` is absent. No warm window is held, and none is being built: `warmActive` is
|
|
13491
|
+
* absent. The warm budget starts at two thirds of a 60 Hz frame until a step reads the rate.
|
|
12843
13492
|
*
|
|
12844
13493
|
* @returns The projection branch of the plugin state.
|
|
12845
13494
|
*/
|
|
@@ -12867,7 +13516,13 @@ function createProjectionState() {
|
|
|
12867
13516
|
moving: false,
|
|
12868
13517
|
owedLoops: 0,
|
|
12869
13518
|
sweptDespawns: 0,
|
|
12870
|
-
buildChecks: []
|
|
13519
|
+
buildChecks: [],
|
|
13520
|
+
frameStart: 0,
|
|
13521
|
+
warm: emptyMap$9(),
|
|
13522
|
+
warmList: [],
|
|
13523
|
+
warmHeld: emptySet$8(),
|
|
13524
|
+
warmStale: false,
|
|
13525
|
+
warmBudgetMs: FALLBACK_WARM_MS
|
|
12871
13526
|
};
|
|
12872
13527
|
}
|
|
12873
13528
|
//#endregion
|
|
@@ -25696,6 +26351,8 @@ function destroyPools(state) {
|
|
|
25696
26351
|
}
|
|
25697
26352
|
//#endregion
|
|
25698
26353
|
//#region src/plugins/renderer/sync/held.ts
|
|
26354
|
+
/** The version of a held list a view left: `membershipVersion()` never answers it, so the next pass scans the list. */
|
|
26355
|
+
const RESCAN = -1;
|
|
25699
26356
|
/**
|
|
25700
26357
|
* Tells whether a view is held: its entity belongs to the running build, and it has no parent or its parent is live.
|
|
25701
26358
|
* A building view under a building parent hangs in the parent's tree, which is held as a whole. One set lookup for a
|
|
@@ -25712,7 +26369,9 @@ function holds(sctx, entity, parent) {
|
|
|
25712
26369
|
}
|
|
25713
26370
|
/**
|
|
25714
26371
|
* Holds a view of the build: out of the tree, no orphan, listed once in `heldViews`. A top keeps the name of the layer
|
|
25715
|
-
* it will hang in, which the coming scene may declare only after the commit.
|
|
26372
|
+
* it will hang in, which the coming scene may declare only after the commit. The first top of an empty list stores
|
|
26373
|
+
* world's membership version: it is building now, so only a later move can release it, and the pass is not woken for
|
|
26374
|
+
* a scan that would find nothing.
|
|
25716
26375
|
*
|
|
25717
26376
|
* @param sctx - Domain context of the sync module.
|
|
25718
26377
|
* @param entity - The entity.
|
|
@@ -25726,13 +26385,25 @@ function holdView(sctx, entity, view, layer) {
|
|
|
25726
26385
|
view.layer = layer;
|
|
25727
26386
|
detach$1(view.wrapper ?? view.object);
|
|
25728
26387
|
if (view.held) return;
|
|
26388
|
+
if (held.count === 0) held.version = sctx.ctx.deps.world.projection.membershipVersion();
|
|
25729
26389
|
view.held = true;
|
|
25730
26390
|
held.entities[held.count] = entity;
|
|
25731
26391
|
held.count += 1;
|
|
25732
26392
|
}
|
|
25733
26393
|
/**
|
|
25734
|
-
*
|
|
25735
|
-
*
|
|
26394
|
+
* Notes that a view leaves (its entity despawned, or its view replaced): a held one has the next pass scan the list
|
|
26395
|
+
* and drop its slot, also when world's membership version did not move (a discard of a build whose entities only
|
|
26396
|
+
* `adopt` marked). One field read for a view that is not held.
|
|
26397
|
+
*
|
|
26398
|
+
* @param state - The sync branch of the plugin state.
|
|
26399
|
+
* @param view - The view that leaves.
|
|
26400
|
+
*/
|
|
26401
|
+
function leaveHeld(state, view) {
|
|
26402
|
+
if (view.held) state.heldViews.version = RESCAN;
|
|
26403
|
+
}
|
|
26404
|
+
/**
|
|
26405
|
+
* Forgets the queues of a scene build and the held windows with the tree, on a device loss, a rebuild or a stop: the
|
|
26406
|
+
* views they name are gone, and a rebuild holds every building view again. Works on the state alone.
|
|
25736
26407
|
*
|
|
25737
26408
|
* @param state - The sync branch of the plugin state.
|
|
25738
26409
|
*/
|
|
@@ -29467,6 +30138,7 @@ function dropView(sctx, entity) {
|
|
|
29467
30138
|
if (view === void 0) return;
|
|
29468
30139
|
markView(sctx, entity);
|
|
29469
30140
|
noteLeaving(state, view);
|
|
30141
|
+
leaveHeld(state, view);
|
|
29470
30142
|
sctx.deps.kept.forget(entity);
|
|
29471
30143
|
const host = view.clipped ?? view.wrapper;
|
|
29472
30144
|
if (host !== void 0) detachChildren(sctx, entity, host);
|
|
@@ -30528,7 +31200,8 @@ function layerOf$1(sctx, entity) {
|
|
|
30528
31200
|
/** Views made between two reads of the clock: a read costs more than a small view. */
|
|
30529
31201
|
const CLOCK_EVERY$1 = 8;
|
|
30530
31202
|
/**
|
|
30531
|
-
* Tells whether a scene is being built: `left()` answers a finite number only while a build runs
|
|
31203
|
+
* Tells whether a scene or a warm window is being built: `left()` answers a finite number only while a build runs
|
|
31204
|
+
* or a window is in work. One field read when nothing is built.
|
|
30532
31205
|
*
|
|
30533
31206
|
* @param sctx - Domain context of the sync module.
|
|
30534
31207
|
* @returns True while a build runs.
|
|
@@ -30574,6 +31247,18 @@ function dropAside(state, entity) {
|
|
|
30574
31247
|
if (state.aside.count > 0) state.aside.waiting.delete(entity);
|
|
30575
31248
|
}
|
|
30576
31249
|
/**
|
|
31250
|
+
* Hands a queued entity whose build ended before its view was made to the live pass: it leaves the waiting set, and
|
|
31251
|
+
* joins `added` while it is alive.
|
|
31252
|
+
*
|
|
31253
|
+
* @param sctx - Domain context of the sync module.
|
|
31254
|
+
* @param entity - The entity, no longer building.
|
|
31255
|
+
*/
|
|
31256
|
+
function toLivePass(sctx, entity) {
|
|
31257
|
+
const state = sctx.ctx.state.sync;
|
|
31258
|
+
state.aside.waiting.delete(entity);
|
|
31259
|
+
if (sctx.ctx.deps.world.ecs.ownerOf(entity) !== void 0) state.added.add(entity);
|
|
31260
|
+
}
|
|
31261
|
+
/**
|
|
30577
31262
|
* Makes the view of one queued entity, its queued parent first (spec 16 U2.3: a child made before its parent finds no
|
|
30578
31263
|
* parent view and is detached for good). The entity leaves the waiting set before its parent is made, so a cycle of
|
|
30579
31264
|
* parents ends. A throw costs that entity.
|
|
@@ -30608,7 +31293,7 @@ function makeParentFirst(sctx, entity, report) {
|
|
|
30608
31293
|
function makeAside(sctx, report) {
|
|
30609
31294
|
const state = sctx.ctx.state.sync;
|
|
30610
31295
|
const { aside } = state;
|
|
30611
|
-
const
|
|
31296
|
+
const projection = sctx.ctx.deps.world.projection;
|
|
30612
31297
|
const version = state.passesVersion;
|
|
30613
31298
|
let made = 0;
|
|
30614
31299
|
let check = 1;
|
|
@@ -30617,8 +31302,7 @@ function makeAside(sctx, report) {
|
|
|
30617
31302
|
aside.head += 1;
|
|
30618
31303
|
if (!aside.waiting.has(entity)) continue;
|
|
30619
31304
|
if (!projection.isBuilding(entity)) {
|
|
30620
|
-
|
|
30621
|
-
if (ecs.ownerOf(entity) !== void 0) state.added.add(entity);
|
|
31305
|
+
toLivePass(sctx, entity);
|
|
30622
31306
|
continue;
|
|
30623
31307
|
}
|
|
30624
31308
|
made += makeParentFirst(sctx, entity, report);
|
|
@@ -30647,7 +31331,8 @@ function underStage(node, stage) {
|
|
|
30647
31331
|
}
|
|
30648
31332
|
/**
|
|
30649
31333
|
* The dev check of a build frame: no view of a building entity hangs under the stage, or it would be drawn and hit
|
|
30650
|
-
* before the commit. Named once per build, as `renderer:building-drawn` with the entities. Dev and agent builds only
|
|
31334
|
+
* before the commit. Named once per build, as `renderer:building-drawn` with the entities. Dev and agent builds only,
|
|
31335
|
+
* in frames with aside work: it walks every view and makes a list, so a frame of resting warm windows never runs it.
|
|
30651
31336
|
*
|
|
30652
31337
|
* @param sctx - Domain context of the sync module.
|
|
30653
31338
|
*/
|
|
@@ -30664,7 +31349,9 @@ function checkDrawn(sctx) {
|
|
|
30664
31349
|
}
|
|
30665
31350
|
/**
|
|
30666
31351
|
* The building step of a frame, after the live pass: the views of the aside queue are made under the budget, and while
|
|
30667
|
-
* views wait to be made or
|
|
31352
|
+
* views wait to be made, or held views wait for a build that runs, the next frame is asked for. Held tops of warm
|
|
31353
|
+
* windows at rest wait for no frame: the pass attaches them when world's membership version moves. A few field reads
|
|
31354
|
+
* and no allocation with no build.
|
|
30668
31355
|
*
|
|
30669
31356
|
* @param sctx - Domain context of the sync module.
|
|
30670
31357
|
* @param report - Logs a throw of one entity's work.
|
|
@@ -30673,28 +31360,56 @@ function stepAside(sctx, report) {
|
|
|
30673
31360
|
const state = sctx.ctx.state.sync;
|
|
30674
31361
|
const { aside } = state;
|
|
30675
31362
|
if (aside.made !== 0) aside.made = 0;
|
|
30676
|
-
if (aside.head >= aside.count && state.heldViews.count === 0) return;
|
|
31363
|
+
if (aside.head >= aside.count && (state.heldViews.count === 0 || !buildRuns(sctx))) return;
|
|
30677
31364
|
if (aside.head < aside.count) aside.made = makeAside(sctx, report);
|
|
30678
31365
|
sctx.deps.demand.request();
|
|
30679
31366
|
if (typeof __MOKU_GAME_DEV__ !== "undefined" && __MOKU_GAME_DEV__ || typeof __MOKU_GAME_AGENT__ !== "undefined" && __MOKU_GAME_AGENT__) checkDrawn(sctx);
|
|
30680
31367
|
}
|
|
30681
31368
|
/**
|
|
30682
|
-
* Tells whether held views wait for the pass that attaches them:
|
|
30683
|
-
*
|
|
30684
|
-
*
|
|
31369
|
+
* Tells whether held views may wait for the pass that attaches them: world's membership version moved since the list
|
|
31370
|
+
* was last scanned. A build ends only with such a move (a commit, a discard, the open of a warm window, a held view
|
|
31371
|
+
* dropped), so a list whose version stands holds building views only. Read by `still()`: two field reads.
|
|
30685
31372
|
*
|
|
30686
31373
|
* @param sctx - Domain context of the sync module.
|
|
30687
|
-
* @returns True when the pass has held views to
|
|
31374
|
+
* @returns True when the pass has held views to look at again.
|
|
30688
31375
|
*/
|
|
30689
31376
|
function heldWaiting(sctx) {
|
|
30690
31377
|
const held = sctx.ctx.state.sync.heldViews;
|
|
30691
|
-
return held.count > 0 &&
|
|
31378
|
+
return held.count > 0 && sctx.ctx.deps.world.projection.membershipVersion() !== held.version;
|
|
30692
31379
|
}
|
|
30693
31380
|
/**
|
|
30694
|
-
*
|
|
30695
|
-
*
|
|
30696
|
-
*
|
|
30697
|
-
*
|
|
31381
|
+
* Hands the live pass every queued entity whose build ended before its view was made: a scene build committed, or a
|
|
31382
|
+
* window opened, while views of it still waited aside. The pass that attaches the held top makes them next, parents
|
|
31383
|
+
* first, so the top never hangs on the stage without them. The entities still building stay queued and move to the
|
|
31384
|
+
* front, in their order, with no new array; a slot that waits no more (its entity left) is dropped. One set lookup
|
|
31385
|
+
* per slot, and only after world's membership version moved.
|
|
31386
|
+
*
|
|
31387
|
+
* @param sctx - Domain context of the sync module.
|
|
31388
|
+
*/
|
|
31389
|
+
function releaseAside(sctx) {
|
|
31390
|
+
const aside = sctx.ctx.state.sync.aside;
|
|
31391
|
+
const projection = sctx.ctx.deps.world.projection;
|
|
31392
|
+
let kept = 0;
|
|
31393
|
+
for (let index = aside.head; index < aside.count; index += 1) {
|
|
31394
|
+
const entity = aside.entities[index] ?? 0;
|
|
31395
|
+
if (!aside.waiting.has(entity)) continue;
|
|
31396
|
+
if (projection.isBuilding(entity)) {
|
|
31397
|
+
aside.entities[kept] = entity;
|
|
31398
|
+
kept += 1;
|
|
31399
|
+
} else toLivePass(sctx, entity);
|
|
31400
|
+
}
|
|
31401
|
+
aside.head = 0;
|
|
31402
|
+
aside.count = kept;
|
|
31403
|
+
}
|
|
31404
|
+
/**
|
|
31405
|
+
* The swap: once the membership version moved, every held top that is no longer building is attached in one block, in
|
|
31406
|
+
* the order it was made (parents first), and sorted by the rule of the layer list the pass has just applied: the tops
|
|
31407
|
+
* of a committed scene build, a warm window world shows. The tops still building (a window at rest, a scene still
|
|
31408
|
+
* being built) stay held and move to the front of the list, in their order, with no new array; a slot whose view went
|
|
31409
|
+
* (a discard, a view that left) or hangs elsewhere by now is dropped. The views of an ended build still queued aside
|
|
31410
|
+
* go to `added`, for this same pass: the scene or the window is whole in the frame it is attached. The version is
|
|
31411
|
+
* stored, so the next scan waits for its next move. Called by the pass right after `syncLayers`, before it builds
|
|
31412
|
+
* `added`.
|
|
30698
31413
|
*
|
|
30699
31414
|
* @param sctx - Domain context of the sync module.
|
|
30700
31415
|
*/
|
|
@@ -30702,16 +31417,25 @@ function attachHeld(sctx) {
|
|
|
30702
31417
|
if (!heldWaiting(sctx)) return;
|
|
30703
31418
|
const state = sctx.ctx.state.sync;
|
|
30704
31419
|
const held = state.heldViews;
|
|
31420
|
+
const projection = sctx.ctx.deps.world.projection;
|
|
31421
|
+
let kept = 0;
|
|
30705
31422
|
for (let index = 0; index < held.count; index += 1) {
|
|
30706
31423
|
const entity = held.entities[index] ?? 0;
|
|
30707
31424
|
const view = state.views.get(entity);
|
|
30708
31425
|
if (view === void 0 || !view.held) continue;
|
|
31426
|
+
if (projection.isBuilding(entity)) {
|
|
31427
|
+
held.entities[kept] = entity;
|
|
31428
|
+
kept += 1;
|
|
31429
|
+
continue;
|
|
31430
|
+
}
|
|
30709
31431
|
view.held = false;
|
|
30710
31432
|
attach$1(sctx, entity, view);
|
|
30711
31433
|
resort(sctx, entity, view);
|
|
30712
31434
|
}
|
|
30713
|
-
held.count =
|
|
30714
|
-
|
|
31435
|
+
if (kept !== held.count) held.reported = false;
|
|
31436
|
+
releaseAside(sctx);
|
|
31437
|
+
held.count = kept;
|
|
31438
|
+
held.version = projection.membershipVersion();
|
|
30715
31439
|
}
|
|
30716
31440
|
/**
|
|
30717
31441
|
* Tells whether an entity of a set belongs to the running build.
|
|
@@ -32120,9 +32844,9 @@ function createSyncApi(ctx, deps) {
|
|
|
32120
32844
|
return viewless;
|
|
32121
32845
|
};
|
|
32122
32846
|
/**
|
|
32123
|
-
* The live half of a pass: removed, layers, the held views of a build that ended
|
|
32124
|
-
* invalidated. A despawned entity takes its filter slots with it, also when its view left in an
|
|
32125
|
-
* one keeps them for its next view.
|
|
32847
|
+
* The live half of a pass: removed, layers, the held views of a build that ended and its views still aside, added,
|
|
32848
|
+
* changed, orphans, invalidated. A despawned entity takes its filter slots with it, also when its view left in an
|
|
32849
|
+
* earlier pass; a live one keeps them for its next view.
|
|
32126
32850
|
*/
|
|
32127
32851
|
const livePass = () => {
|
|
32128
32852
|
state.passesVersion += 1;
|
|
@@ -33184,6 +33908,7 @@ function createSyncState(debug) {
|
|
|
33184
33908
|
heldViews: {
|
|
33185
33909
|
entities: [],
|
|
33186
33910
|
count: 0,
|
|
33911
|
+
version: 0,
|
|
33187
33912
|
reported: false
|
|
33188
33913
|
},
|
|
33189
33914
|
leave: {},
|
|
@@ -58643,6 +59368,15 @@ const APPLY_CAP = 100;
|
|
|
58643
59368
|
/** What a parked part holds once it is back in the pool: no nodes and no element, so the pool keeps no tree alive. */
|
|
58644
59369
|
const NO_NODES = [];
|
|
58645
59370
|
/**
|
|
59371
|
+
* Creates the set of the roots whose parts wait. Its own function, because lint rule L5 refuses a
|
|
59372
|
+
* collection built inside an exported declaration.
|
|
59373
|
+
*
|
|
59374
|
+
* @returns An empty set.
|
|
59375
|
+
*/
|
|
59376
|
+
function rootSet() {
|
|
59377
|
+
return /* @__PURE__ */ new Set();
|
|
59378
|
+
}
|
|
59379
|
+
/**
|
|
58646
59380
|
* Tells whether a root has parked parts.
|
|
58647
59381
|
*
|
|
58648
59382
|
* @param root - The root.
|
|
@@ -58679,6 +59413,24 @@ function createParts(ctx, reconcile) {
|
|
|
58679
59413
|
let landed = false;
|
|
58680
59414
|
const parkedPool = [];
|
|
58681
59415
|
const cursorPool = [];
|
|
59416
|
+
const busy = rootSet();
|
|
59417
|
+
/**
|
|
59418
|
+
* Notes whether parts of a root wait now, after its queue or its application changed.
|
|
59419
|
+
*
|
|
59420
|
+
* @param root - The root.
|
|
59421
|
+
*/
|
|
59422
|
+
function track(root) {
|
|
59423
|
+
if (waits(root)) busy.add(root);
|
|
59424
|
+
else busy.delete(root);
|
|
59425
|
+
}
|
|
59426
|
+
/**
|
|
59427
|
+
* Tells whether parts of any root wait: children parked, or an application open.
|
|
59428
|
+
*
|
|
59429
|
+
* @returns True while a build in parts has work left.
|
|
59430
|
+
*/
|
|
59431
|
+
function working() {
|
|
59432
|
+
return busy.size > 0;
|
|
59433
|
+
}
|
|
58682
59434
|
/**
|
|
58683
59435
|
* Starts the frame's reconcile: no element entered, the budget not read, no building unit run.
|
|
58684
59436
|
*/
|
|
@@ -58750,6 +59502,7 @@ function createParts(ctx, reconcile) {
|
|
|
58750
59502
|
part.cause = cause;
|
|
58751
59503
|
root.parked ??= [];
|
|
58752
59504
|
root.parked.push(part);
|
|
59505
|
+
track(root);
|
|
58753
59506
|
}
|
|
58754
59507
|
/**
|
|
58755
59508
|
* Puts a parked part back in the pool, its element and nodes dropped.
|
|
@@ -58798,7 +59551,7 @@ function createParts(ctx, reconcile) {
|
|
|
58798
59551
|
* root's queue.
|
|
58799
59552
|
*/
|
|
58800
59553
|
function drainParked() {
|
|
58801
|
-
if (
|
|
59554
|
+
if (busy.size === 0) return;
|
|
58802
59555
|
for (const root of state.roots.values()) {
|
|
58803
59556
|
const parked = root.parked;
|
|
58804
59557
|
while (parked !== void 0 && parked.length > 0) {
|
|
@@ -58808,6 +59561,7 @@ function createParts(ctx, reconcile) {
|
|
|
58808
59561
|
diffPart(root, part);
|
|
58809
59562
|
recycle(part);
|
|
58810
59563
|
}
|
|
59564
|
+
track(root);
|
|
58811
59565
|
}
|
|
58812
59566
|
}
|
|
58813
59567
|
/**
|
|
@@ -58841,6 +59595,16 @@ function createParts(ctx, reconcile) {
|
|
|
58841
59595
|
const part = parked.pop();
|
|
58842
59596
|
if (part !== void 0) recycle(part);
|
|
58843
59597
|
}
|
|
59598
|
+
dropApplication(root);
|
|
59599
|
+
track(root);
|
|
59600
|
+
}
|
|
59601
|
+
/**
|
|
59602
|
+
* Drops the open application of a root, if it has one, with no element applied: its cursor goes
|
|
59603
|
+
* back to the pool, empty.
|
|
59604
|
+
*
|
|
59605
|
+
* @param root - The root.
|
|
59606
|
+
*/
|
|
59607
|
+
function dropApplication(root) {
|
|
58844
59608
|
const cursor = root.applying;
|
|
58845
59609
|
if (cursor === void 0) return;
|
|
58846
59610
|
while (cursor.stack.length > 0) cursor.stack.pop();
|
|
@@ -58848,6 +59612,30 @@ function createParts(ctx, reconcile) {
|
|
|
58848
59612
|
cursorPool.push(cursor);
|
|
58849
59613
|
}
|
|
58850
59614
|
/**
|
|
59615
|
+
* Finishes the build of a root shown before its parts were done (a warm window opened while it
|
|
59616
|
+
* was built, spec 33 B+D): every parked part is diffed now, whatever the budget, and its children
|
|
59617
|
+
* no longer park, since the root is not built aside any more; an open application is dropped.
|
|
59618
|
+
* The root then asks for a solve, which lays it out and applies it whole, so no half-built frame
|
|
59619
|
+
* is drawn.
|
|
59620
|
+
*
|
|
59621
|
+
* @param root - A root that was built aside and is not any more.
|
|
59622
|
+
* @returns True when parts were left, so the solve of this frame applies the root in one block.
|
|
59623
|
+
*/
|
|
59624
|
+
function finish(root) {
|
|
59625
|
+
if (!waits(root)) return false;
|
|
59626
|
+
const parked = root.parked;
|
|
59627
|
+
while (parked !== void 0 && parked.length > 0) {
|
|
59628
|
+
const part = parked.shift();
|
|
59629
|
+
if (part === void 0) break;
|
|
59630
|
+
diffPart(root, part);
|
|
59631
|
+
recycle(part);
|
|
59632
|
+
}
|
|
59633
|
+
dropApplication(root);
|
|
59634
|
+
track(root);
|
|
59635
|
+
root.needsSolve = true;
|
|
59636
|
+
return true;
|
|
59637
|
+
}
|
|
59638
|
+
/**
|
|
58851
59639
|
* Opens the application of a solved root built aside and applies its first part (spec 33 A6).
|
|
58852
59640
|
*
|
|
58853
59641
|
* @param root - The root built aside.
|
|
@@ -58863,6 +59651,7 @@ function createParts(ctx, reconcile) {
|
|
|
58863
59651
|
cursor.stack.push(element);
|
|
58864
59652
|
root.applying = cursor;
|
|
58865
59653
|
applyPart(root, cursor);
|
|
59654
|
+
track(root);
|
|
58866
59655
|
}
|
|
58867
59656
|
/**
|
|
58868
59657
|
* Applies the next elements of an open application, top-down, parent before children in the
|
|
@@ -58909,6 +59698,7 @@ function createParts(ctx, reconcile) {
|
|
|
58909
59698
|
function closeApplication(root, cursor) {
|
|
58910
59699
|
delete root.applying;
|
|
58911
59700
|
cursorPool.push(cursor);
|
|
59701
|
+
track(root);
|
|
58912
59702
|
landed = true;
|
|
58913
59703
|
for (const host of state.hosts) if (lookup(host)?.root === root.entity) state.risen.add(host);
|
|
58914
59704
|
}
|
|
@@ -58918,7 +59708,7 @@ function createParts(ctx, reconcile) {
|
|
|
58918
59708
|
* here is solved again in the same call when it asks for it.
|
|
58919
59709
|
*/
|
|
58920
59710
|
function applyParts() {
|
|
58921
|
-
if (
|
|
59711
|
+
if (busy.size === 0) return;
|
|
58922
59712
|
for (const root of state.roots.values()) {
|
|
58923
59713
|
const cursor = root.applying;
|
|
58924
59714
|
if (cursor === void 0) continue;
|
|
@@ -58934,9 +59724,11 @@ function createParts(ctx, reconcile) {
|
|
|
58934
59724
|
parks,
|
|
58935
59725
|
park,
|
|
58936
59726
|
waits,
|
|
59727
|
+
working,
|
|
58937
59728
|
drainParked,
|
|
58938
59729
|
holdRoot,
|
|
58939
59730
|
forgetParts,
|
|
59731
|
+
finish,
|
|
58940
59732
|
applyInParts,
|
|
58941
59733
|
applyParts
|
|
58942
59734
|
};
|
|
@@ -59847,6 +60639,11 @@ function createReconciler(ctx, modules, fields) {
|
|
|
59847
60639
|
let rendered = 0;
|
|
59848
60640
|
const isAside = (entity) => ctx.deps.world.projection.isBuilding(entity);
|
|
59849
60641
|
let released = false;
|
|
60642
|
+
let asideSeen = -1;
|
|
60643
|
+
let enteredSeen = -1;
|
|
60644
|
+
let heldEnters = -1;
|
|
60645
|
+
let asideSolved = false;
|
|
60646
|
+
const isAsideScroll = (container) => state.asideRoots > 0 && state.roots.get(container.root)?.aside !== void 0;
|
|
59850
60647
|
const lookWriter = {
|
|
59851
60648
|
pass: 0,
|
|
59852
60649
|
values: {
|
|
@@ -59858,8 +60655,10 @@ function createReconciler(ctx, modules, fields) {
|
|
|
59858
60655
|
others: (element, type, next) => writeOthers(element, next, type)
|
|
59859
60656
|
};
|
|
59860
60657
|
/**
|
|
59861
|
-
* Registers the key of an element under its root, so `
|
|
59862
|
-
* `ui` gave a node of its own, a spacer's, is never registered.
|
|
60658
|
+
* Registers the key of an element under its root, so `find` and `entityOf` answer for it. A key
|
|
60659
|
+
* `ui` gave a node of its own, a spacer's, is never registered. A root built aside or held warm
|
|
60660
|
+
* is not on the screen: `find` leaves it out, and `world`'s `entityOf` answers nothing for an
|
|
60661
|
+
* entity it builds or holds, so a closed window's button is not reached by key (spec 33 B+D).
|
|
59863
60662
|
*
|
|
59864
60663
|
* @param root - The root the element belongs to.
|
|
59865
60664
|
* @param element - The element that entered.
|
|
@@ -59870,6 +60669,16 @@ function createReconciler(ctx, modules, fields) {
|
|
|
59870
60669
|
if (keys.has(element.key)) ctx.log.warn("ui:duplicate-key", { key: element.key });
|
|
59871
60670
|
else keys.set(element.key, element.entity);
|
|
59872
60671
|
state.byKey.set(root.entity, keys);
|
|
60672
|
+
shareKey(root, element);
|
|
60673
|
+
}
|
|
60674
|
+
/**
|
|
60675
|
+
* Registers the key of an element with `world`, so `entityOf` answers for it.
|
|
60676
|
+
*
|
|
60677
|
+
* @param root - The root the element belongs to.
|
|
60678
|
+
* @param element - An element of the root on the screen.
|
|
60679
|
+
*/
|
|
60680
|
+
function shareKey(root, element) {
|
|
60681
|
+
if (element.key === void 0 || isOwnKey(element.key)) return;
|
|
59873
60682
|
element.dropKey = ctx.deps.world.projection.registerKey(root.name, element.key, element.entity);
|
|
59874
60683
|
}
|
|
59875
60684
|
/**
|
|
@@ -60807,7 +61616,7 @@ function createReconciler(ctx, modules, fields) {
|
|
|
60807
61616
|
/**
|
|
60808
61617
|
* Solves one root in a box and applies its rects: a root on the viewport when it is marked, a
|
|
60809
61618
|
* root in a slot also when its slot was resized. A root built aside waits while parts of it wait,
|
|
60810
|
-
* and is applied in parts.
|
|
61619
|
+
* and is applied in parts. A root shown before its parts were done is applied whole and still.
|
|
60811
61620
|
*
|
|
60812
61621
|
* @param root - The root.
|
|
60813
61622
|
* @param box - The viewport, or the slot's content box.
|
|
@@ -60827,8 +61636,12 @@ function createReconciler(ctx, modules, fields) {
|
|
|
60827
61636
|
};
|
|
60828
61637
|
modules.layout.solve(element, box, lookup);
|
|
60829
61638
|
root.needsSolve = false;
|
|
61639
|
+
if (root.aside !== void 0) asideSolved = true;
|
|
60830
61640
|
if (root.aside !== void 0 && isAside(root.entity) && !element.live) parts.applyInParts(root, element, quiet);
|
|
60831
|
-
else
|
|
61641
|
+
else {
|
|
61642
|
+
applyRects(element, quiet || root.still === true);
|
|
61643
|
+
delete root.still;
|
|
61644
|
+
}
|
|
60832
61645
|
return true;
|
|
60833
61646
|
}
|
|
60834
61647
|
/**
|
|
@@ -60893,9 +61706,9 @@ function createReconciler(ctx, modules, fields) {
|
|
|
60893
61706
|
* Keeps an element whose spawn has just been applied: the world calls it from the `Box` hook, at
|
|
60894
61707
|
* the flush of phase `layout`. Its enter hook waits for `playEntered`, so the game's systems see
|
|
60895
61708
|
* the entity first (F48). The hook itself plays at once, so they see the start pose it writes (F49);
|
|
60896
|
-
* `ui.enter` plays it again when one of them changed what it read. An element of a
|
|
60897
|
-
* aside plays nothing here: its enter waits for the swap
|
|
60898
|
-
* point of
|
|
61709
|
+
* `ui.enter` plays it again when one of them changed what it read. An element of a root built
|
|
61710
|
+
* aside or held warm plays nothing here: its enter waits for the swap or the open, and
|
|
61711
|
+
* `poseReleased` plays it at the same point of that frame (spec 31, spec 33 B+D).
|
|
60899
61712
|
*
|
|
60900
61713
|
* @param entity - The entity the `Box` was attached to.
|
|
60901
61714
|
*/
|
|
@@ -60905,7 +61718,7 @@ function createReconciler(ctx, modules, fields) {
|
|
|
60905
61718
|
else entering.list.push(entity);
|
|
60906
61719
|
entering.count += 1;
|
|
60907
61720
|
const element = state.elements.get(entity);
|
|
60908
|
-
if (arrives(element) && !isAside(
|
|
61721
|
+
if (arrives(element) && !isAside(element.root)) modules.layout.pose(element, overlayOf(element) === void 0 ? void 0 : createSpan());
|
|
60909
61722
|
}
|
|
60910
61723
|
/**
|
|
60911
61724
|
* Plays the enter hooks of the elements a committed build released, at the end of the swap
|
|
@@ -60919,7 +61732,7 @@ function createReconciler(ctx, modules, fields) {
|
|
|
60919
61732
|
for (let index = 0; index < entering.count; index += 1) {
|
|
60920
61733
|
const entity = entering.list[index];
|
|
60921
61734
|
const element = entity === void 0 ? void 0 : state.elements.get(entity);
|
|
60922
|
-
if (!arrives(element) || element.posed !== void 0 || isAside(element.
|
|
61735
|
+
if (!arrives(element) || element.posed !== void 0 || isAside(element.root)) continue;
|
|
60923
61736
|
modules.layout.pose(element, overlayOf(element) === void 0 ? void 0 : createSpan());
|
|
60924
61737
|
}
|
|
60925
61738
|
}
|
|
@@ -60927,33 +61740,39 @@ function createReconciler(ctx, modules, fields) {
|
|
|
60927
61740
|
* Plays the enter hooks queued since the last call, in the order the elements came. The `ui.enter`
|
|
60928
61741
|
* system calls it in phase `sync`: after the game's systems, which may have written what a hook
|
|
60929
61742
|
* reads (a list's scroll), and before `renderer.sync`, so an element is never drawn at its rest
|
|
60930
|
-
* pose by mistake. An element despawned in between plays nothing. An element of a
|
|
60931
|
-
* aside stays queued, in its order, and plays in the first call after the swap
|
|
60932
|
-
* enter, posed by `poseReleased` in that frame's solve, its
|
|
60933
|
-
* start in the frame the
|
|
61743
|
+
* pose by mistake. An element despawned in between plays nothing. An element of a root built
|
|
61744
|
+
* aside or held warm stays queued, in its order, and plays in the first call after the swap or
|
|
61745
|
+
* the open (spec 31, spec 33 B+D): its enter, posed by `poseReleased` in that frame's solve, its
|
|
61746
|
+
* loop and the level of an overlay start in the frame the root is first drawn. While nothing was
|
|
61747
|
+
* queued since the last call and no root was released, the queue holds only held enters and is
|
|
61748
|
+
* not walked.
|
|
60934
61749
|
*/
|
|
60935
61750
|
function playEntered() {
|
|
60936
61751
|
const entering = state.entering;
|
|
61752
|
+
const version = ctx.deps.world.projection.membershipVersion();
|
|
61753
|
+
if (entering.count === heldEnters && version === enteredSeen) return;
|
|
60937
61754
|
let held = 0;
|
|
61755
|
+
enteredSeen = version;
|
|
60938
61756
|
for (let index = 0; index < entering.count; index += 1) {
|
|
60939
61757
|
const entity = entering.list[index];
|
|
60940
|
-
|
|
60941
|
-
if (
|
|
61758
|
+
const element = entity === void 0 ? void 0 : state.elements.get(entity);
|
|
61759
|
+
if (entity === void 0 || element === void 0) continue;
|
|
61760
|
+
if (isAside(element.root)) {
|
|
60942
61761
|
entering.list[held] = entity;
|
|
60943
61762
|
held += 1;
|
|
60944
|
-
} else playEnter(
|
|
61763
|
+
} else playEnter(element);
|
|
60945
61764
|
}
|
|
60946
61765
|
entering.count = held;
|
|
61766
|
+
heldEnters = held;
|
|
60947
61767
|
}
|
|
60948
61768
|
/**
|
|
60949
61769
|
* Plays the enter hook of an element whose spawn has been applied, once. A row a range change
|
|
60950
61770
|
* scrolled in is not new: it plays no `enter` hook, only its loop starts.
|
|
60951
61771
|
*
|
|
60952
|
-
* @param
|
|
61772
|
+
* @param element - The element the `Box` was attached to.
|
|
60953
61773
|
*/
|
|
60954
|
-
function playEnter(
|
|
60955
|
-
|
|
60956
|
-
if (element === void 0 || element.entered) return;
|
|
61774
|
+
function playEnter(element) {
|
|
61775
|
+
if (element.entered) return;
|
|
60957
61776
|
element.entered = true;
|
|
60958
61777
|
if (element.scrolledIn) modules.layout.loop(element);
|
|
60959
61778
|
else if (overlayOf(element) === void 0) modules.layout.enter(element);
|
|
@@ -61024,20 +61843,23 @@ function createReconciler(ctx, modules, fields) {
|
|
|
61024
61843
|
}
|
|
61025
61844
|
}
|
|
61026
61845
|
/**
|
|
61027
|
-
* The live scroll containers
|
|
61028
|
-
*
|
|
61029
|
-
*
|
|
61030
|
-
* is
|
|
61846
|
+
* The live scroll containers. Read from the set the enter fills and the exit empties, so an idle
|
|
61847
|
+
* frame walks no other element. A scroll of a root built aside waits while parts of the root wait:
|
|
61848
|
+
* it is settled once the root is whole (spec 33 A7). Without `aside`, the scrolls the frame step
|
|
61849
|
+
* moves with the finger and ranges: a scroll of a root built aside or held warm is left out, as
|
|
61850
|
+
* nobody sees it and no finger reaches it, and it moves from the swap or the open on (spec 33 B+D).
|
|
61031
61851
|
*
|
|
61032
|
-
* @
|
|
61852
|
+
* @param aside - Whether the scrolls of roots built aside or held, once whole, are in the list.
|
|
61853
|
+
* @returns Those live elements whose tag is `scroll`: the reconciler's own list, valid until the
|
|
61033
61854
|
* next call.
|
|
61034
61855
|
*/
|
|
61035
|
-
function scrollContainers() {
|
|
61856
|
+
function scrollContainers(aside) {
|
|
61036
61857
|
while (scrollList.length > 0) scrollList.pop();
|
|
61037
61858
|
for (const entity of state.scrolls) {
|
|
61038
61859
|
const element = state.elements.get(entity);
|
|
61039
61860
|
if (element?.live !== true) continue;
|
|
61040
|
-
if (
|
|
61861
|
+
if (parts.working() && parts.waits(state.roots.get(element.root))) continue;
|
|
61862
|
+
if (!aside && isAsideScroll(element)) continue;
|
|
61041
61863
|
scrollList.push(element);
|
|
61042
61864
|
}
|
|
61043
61865
|
return scrollList;
|
|
@@ -61119,20 +61941,27 @@ function createReconciler(ctx, modules, fields) {
|
|
|
61119
61941
|
}
|
|
61120
61942
|
}
|
|
61121
61943
|
/**
|
|
61122
|
-
* Finds the roots the last scene build committed
|
|
61123
|
-
*
|
|
61124
|
-
*
|
|
61125
|
-
*
|
|
61944
|
+
* Finds the roots the last scene build committed, and the held roots of the warm windows that
|
|
61945
|
+
* opened: a root counted aside that `world` builds or holds no more is released, the slots are
|
|
61946
|
+
* given out again, so a kept host takes its coming guest in the swap frame, and this frame's
|
|
61947
|
+
* solve poses the held enters (spec 31, spec 33 B+D). A root a discard dropped is gone from the
|
|
61948
|
+
* registry and is not counted. The roots are walked only when the membership of the world's
|
|
61949
|
+
* projections moved: every release moves it (a commit, an open, a discard), so windows held warm
|
|
61950
|
+
* and at rest, and a build between two of its moves, cost two numbers a frame. The budget is not
|
|
61951
|
+
* read here: a finite `left()` is a number the heap keeps, every frame of a build.
|
|
61126
61952
|
*/
|
|
61127
61953
|
function settleAside() {
|
|
61128
61954
|
if (state.asideRoots === 0) return;
|
|
61955
|
+
const version = ctx.deps.world.projection.membershipVersion();
|
|
61956
|
+
if (version === asideSeen) return;
|
|
61957
|
+
asideSeen = version;
|
|
61129
61958
|
let left = 0;
|
|
61130
61959
|
let committed = false;
|
|
61131
61960
|
for (const root of state.roots.values()) {
|
|
61132
61961
|
if (root.aside === void 0) continue;
|
|
61133
61962
|
if (isAside(root.entity)) left += 1;
|
|
61134
61963
|
else {
|
|
61135
|
-
|
|
61964
|
+
releaseRoot(root);
|
|
61136
61965
|
committed = true;
|
|
61137
61966
|
}
|
|
61138
61967
|
}
|
|
@@ -61142,6 +61971,17 @@ function createReconciler(ctx, modules, fields) {
|
|
|
61142
61971
|
released = true;
|
|
61143
61972
|
}
|
|
61144
61973
|
/**
|
|
61974
|
+
* Releases a root `world` builds or holds no more. A root shown before its parts were done (a
|
|
61975
|
+
* warm window opened while it was built) has the rest made now, in one block, and is laid out
|
|
61976
|
+
* and applied whole in this frame's solve, with no motion, so no half-built frame is drawn.
|
|
61977
|
+
*
|
|
61978
|
+
* @param root - A root counted aside that `world` builds or holds no more.
|
|
61979
|
+
*/
|
|
61980
|
+
function releaseRoot(root) {
|
|
61981
|
+
if (parts.finish(root)) root.still = true;
|
|
61982
|
+
delete root.aside;
|
|
61983
|
+
}
|
|
61984
|
+
/**
|
|
61145
61985
|
* The part of a scene build `ui` does, which `world` asks through `onBuild` (spec 31): done when no
|
|
61146
61986
|
* root of the build is dirty (its tree not diffed yet, or the layout engine not loaded), has
|
|
61147
61987
|
* parked parts, waits for its solve or is applied in parts (spec 33 A8). A root whose first diff
|
|
@@ -61175,9 +62015,11 @@ function createReconciler(ctx, modules, fields) {
|
|
|
61175
62015
|
reorderRoots();
|
|
61176
62016
|
settlePopups(ctx, state, unmountRoot);
|
|
61177
62017
|
fields.pull();
|
|
61178
|
-
const containers = scrollContainers();
|
|
62018
|
+
const containers = scrollContainers(false);
|
|
62019
|
+
const rangesAside = asideSolved || parts.hasLanded();
|
|
62020
|
+
asideSolved = false;
|
|
61179
62021
|
modules.layout.scroll(containers, lookup, time);
|
|
61180
|
-
range.step(containers);
|
|
62022
|
+
range.step(rangesAside ? scrollContainers(true) : containers);
|
|
61181
62023
|
markResizedTexts(ctx, state, modules.layout);
|
|
61182
62024
|
markResizedIcons(ctx, state, modules.layout);
|
|
61183
62025
|
const viewportChanged = modules.styles.useViewport(ctx.deps.renderer.viewport.size());
|
|
@@ -61228,7 +62070,7 @@ function createReconciler(ctx, modules, fields) {
|
|
|
61228
62070
|
parts.applyParts();
|
|
61229
62071
|
const changed = layOutRoots(viewportBox);
|
|
61230
62072
|
if (changed) ctx.deps.time.wake();
|
|
61231
|
-
if (changed || rendered > 0 || parts.hasLanded()) modules.layout.settleScroll(scrollContainers(), lookup, time);
|
|
62073
|
+
if (changed || rendered > 0 || parts.hasLanded()) modules.layout.settleScroll(scrollContainers(true), lookup, time, isAsideScroll);
|
|
61232
62074
|
rendered = 0;
|
|
61233
62075
|
settleOverlays(ctx, state, modules.layout);
|
|
61234
62076
|
if (state.risen.size > 0) {
|
|
@@ -61816,16 +62658,20 @@ function writeRest(ctx, element, parent) {
|
|
|
61816
62658
|
if (visual !== void 0) projection.setRest(element.entity, visual.component, visual.value);
|
|
61817
62659
|
}
|
|
61818
62660
|
/**
|
|
61819
|
-
* Tells whether an element waits for the swap of a scene `world` builds aside (spec 31)
|
|
61820
|
-
*
|
|
61821
|
-
*
|
|
62661
|
+
* Tells whether an element waits for the swap of a scene `world` builds aside (spec 31), or for the
|
|
62662
|
+
* open of a window held warm (spec 33 B+D): it has not entered, and it or its root belongs to the
|
|
62663
|
+
* build or to the held view. An element a held root makes while no warm work runs is not marked
|
|
62664
|
+
* by `world`; its root is. Its hooks wait for its enter at the swap; a change before it plays no
|
|
62665
|
+
* motion and is written at once, so the enter starts from where it stands.
|
|
61822
62666
|
*
|
|
61823
62667
|
* @param ctx - Domain context of the ui plugin.
|
|
61824
62668
|
* @param element - The element a hook would play on.
|
|
61825
62669
|
* @returns True while its motions are held.
|
|
61826
62670
|
*/
|
|
61827
62671
|
function isHeld(ctx, element) {
|
|
61828
|
-
|
|
62672
|
+
if (element.entered) return false;
|
|
62673
|
+
const projection = ctx.deps.world.projection;
|
|
62674
|
+
return projection.isBuilding(element.entity) || projection.isBuilding(element.root);
|
|
61829
62675
|
}
|
|
61830
62676
|
/**
|
|
61831
62677
|
* Asks the projection for the handle of a ui-owned entity. A foreign owner is an error in the
|
|
@@ -63427,19 +64273,36 @@ function settle(ctx, state, container, content, motion) {
|
|
|
63427
64273
|
show(ctx, state, container, content, motion);
|
|
63428
64274
|
}
|
|
63429
64275
|
/**
|
|
64276
|
+
* Ends a glide at its target at once: the scroll stands where its `offset` prop puts it.
|
|
64277
|
+
*
|
|
64278
|
+
* @param ctx - Domain context of the ui plugin.
|
|
64279
|
+
* @param state - The layout state, which keeps the patches.
|
|
64280
|
+
* @param container - The scroll element.
|
|
64281
|
+
* @param content - Its content element.
|
|
64282
|
+
* @param motion - Its motion, gliding.
|
|
64283
|
+
*/
|
|
64284
|
+
function standAtTarget(ctx, state, container, content, motion) {
|
|
64285
|
+
motion.offset = motion.to;
|
|
64286
|
+
stop(motion);
|
|
64287
|
+
show(ctx, state, container, content, motion);
|
|
64288
|
+
}
|
|
64289
|
+
/**
|
|
63430
64290
|
* Settles every scroll on what the solve and the render of this frame gave it. A scroll the solve
|
|
63431
64291
|
* just spawned takes its place at its `offset` prop. A placed one keeps inside a new range at
|
|
63432
64292
|
* once, a running glide's target too, and glides to a new `offset` prop; the same value on a
|
|
63433
|
-
* re-render does nothing, and a scroll the finger holds only remembers it. A scroll
|
|
63434
|
-
*
|
|
64293
|
+
* re-render does nothing, and a scroll the finger holds only remembers it. A scroll nobody sees
|
|
64294
|
+
* yet (`stands`: a root built aside or held warm) stands at its target at once instead of gliding,
|
|
64295
|
+
* so no glide plays hidden or at its open. A scroll left moving wakes the loop the way
|
|
64296
|
+
* `stepScroll` does: not at a time scale of 0, where it stands.
|
|
63435
64297
|
*
|
|
63436
64298
|
* @param ctx - Domain context of the ui plugin.
|
|
63437
64299
|
* @param state - The layout state, which keeps the patches.
|
|
63438
64300
|
* @param containers - The live scroll elements.
|
|
63439
64301
|
* @param lookup - How a child entity becomes its element.
|
|
63440
64302
|
* @param time - The frame's `Time`.
|
|
64303
|
+
* @param stands - Whether a scroll is not on the screen yet; none for every scroll on it.
|
|
63441
64304
|
*/
|
|
63442
|
-
function settleScroll(ctx, state, containers, lookup, time) {
|
|
64305
|
+
function settleScroll(ctx, state, containers, lookup, time, stands) {
|
|
63443
64306
|
let moving = false;
|
|
63444
64307
|
for (const container of containers) {
|
|
63445
64308
|
const motion = container.scroll;
|
|
@@ -63447,6 +64310,7 @@ function settleScroll(ctx, state, containers, lookup, time) {
|
|
|
63447
64310
|
if (motion === void 0 || content === void 0) continue;
|
|
63448
64311
|
if (motion.placed) settle(ctx, state, container, content, motion);
|
|
63449
64312
|
else place$1(ctx, container, content, motion);
|
|
64313
|
+
if (motion.mode === "glide" && stands?.(container) === true) standAtTarget(ctx, state, container, content, motion);
|
|
63450
64314
|
if (motion.mode !== "still") moving = true;
|
|
63451
64315
|
}
|
|
63452
64316
|
if (moving && time.delta > 0) ctx.deps.time.wake();
|
|
@@ -63784,7 +64648,7 @@ function createLayoutApi(ctx) {
|
|
|
63784
64648
|
},
|
|
63785
64649
|
settled: (element) => canDespawn(element),
|
|
63786
64650
|
scroll: (containers, lookup, time) => stepScroll(ctx, state, containers, lookup, time),
|
|
63787
|
-
settleScroll: (containers, lookup, time) => settleScroll(ctx, state, containers, lookup, time),
|
|
64651
|
+
settleScroll: (containers, lookup, time, stands) => settleScroll(ctx, state, containers, lookup, time, stands),
|
|
63788
64652
|
clampScroll: (container, contentHeight, lookup) => clampScroll(ctx, state, container, contentHeight, lookup),
|
|
63789
64653
|
scrollTo: (container, to, lookup) => scrollTo(ctx, state, container, to, lookup),
|
|
63790
64654
|
windowOf,
|
|
@@ -64339,6 +65203,16 @@ function registerComponents(ctx, jsx) {
|
|
|
64339
65203
|
for (const feature of ctx.deps.flow.features.all()) for (const entry of feature.description.ui ?? []) if (isComponent(entry)) jsx.register(entry);
|
|
64340
65204
|
}
|
|
64341
65205
|
/**
|
|
65206
|
+
* Tells whether a renderer draws the views: one chose a backend at its start. It registers its own
|
|
65207
|
+
* part of a scene build on the same condition, and a scene is built aside only then.
|
|
65208
|
+
*
|
|
65209
|
+
* @param ctx - Domain context of the ui plugin.
|
|
65210
|
+
* @returns True when the renderer draws; false while it is inert or unsupported.
|
|
65211
|
+
*/
|
|
65212
|
+
function drawsViews(ctx) {
|
|
65213
|
+
return ctx.deps.renderer.host.kind() !== "none";
|
|
65214
|
+
}
|
|
65215
|
+
/**
|
|
64342
65216
|
* Opens the two systems of phase `layout`, the system `ui.enter` of phase `sync`, the seven world
|
|
64343
65217
|
* hooks of `Tree`, `Box`, `Pressed` and `PointerOver`, the two that tell the hosting step a view
|
|
64344
65218
|
* lost its `Parent` or its `Held` (a view freed so may hang under its host again), the listener
|
|
@@ -64347,9 +65221,10 @@ function registerComponents(ctx, jsx) {
|
|
|
64347
65221
|
* step, the three tap listeners (the `LocalWrite` patch, the pointer tap that clears the keyboard
|
|
64348
65222
|
* focus, and the tap that starts or ends the editing of a text field), the pointer door that opens
|
|
64349
65223
|
* the keyboard inside the DOM listener, the key listener of the focus and `LocalWrite` as an input
|
|
64350
|
-
* control, so the cursor shows a hand over a local-state button, and
|
|
64351
|
-
* (`onBuild`: the roots built aside are reconciled and solved, spec
|
|
64352
|
-
* tap counter of `DebugTrigger` and its check of a view that takes
|
|
65224
|
+
* control, so the cursor shows a hand over a local-state button, and, with a renderer that draws,
|
|
65225
|
+
* `ui`'s part of a scene build (`onBuild`: the roots built aside are reconciled and solved, spec
|
|
65226
|
+
* 31). On an agent page also the tap counter of `DebugTrigger` and its check of a view that takes
|
|
65227
|
+
* no press.
|
|
64353
65228
|
*
|
|
64354
65229
|
* The `Box` hook plays an element's enter hook and queues it, so the game's systems see its start
|
|
64355
65230
|
* pose (F49); `ui.enter` starts its loop after them and before the frame is drawn, and plays the
|
|
@@ -64381,9 +65256,10 @@ function openRegistrations(ctx, jsx, layout) {
|
|
|
64381
65256
|
})), ecs.onAdded(Tree, (entity) => {
|
|
64382
65257
|
const place = projection.keyOf(entity);
|
|
64383
65258
|
jsx.mountRoot(entity, place?.projection ?? "ui", ecs.get(entity, Layer)?.name ?? "ui");
|
|
64384
|
-
}), ecs.onRemoved(Tree, (entity) => jsx.unmountRoot(entity)), ecs.onAdded(Box, (entity) => jsx.queueEnter(entity)), projection.onConverged(jsx.converged),
|
|
65259
|
+
}), ecs.onRemoved(Tree, (entity) => jsx.unmountRoot(entity)), ecs.onAdded(Box, (entity) => jsx.queueEnter(entity)), projection.onConverged(jsx.converged), ecs.onAdded(Pressed, (entity) => jsx.markPointer(entity, "pressed", true)), ecs.onRemoved(Pressed, (entity) => jsx.markPointer(entity, "pressed", false)), ecs.onAdded(PointerOver, (entity) => jsx.markPointer(entity, "hover", true)), ecs.onRemoved(PointerOver, (entity) => jsx.markPointer(entity, "hover", false)), ecs.onRemoved(Parent, () => hostsMoved(ctx.state.jsx)), ecs.onRemoved(Held, () => hostsMoved(ctx.state.jsx)), ctx.deps.flow.fx.handle("popup", layout.popupHandler(jsx)), ctx.deps.flow.fx.handle("guide", layout.guideHandler()), ctx.deps.flow.fx.onHint((hint) => {
|
|
64385
65260
|
ctx.state.jsx.hints.push(hint);
|
|
64386
65261
|
}), ctx.deps.input.onTap(jsx.applyTap), ctx.deps.input.onTap(() => jsx.blur()), ctx.deps.input.onTap(jsx.tapped), ctx.deps.input.onPointer(jsx.pointer), ctx.deps.input.onKey(jsx.key), ctx.deps.input.controls.add(LocalWrite), () => jsx.releaseHosted(), () => ecs.despawnOwnedBy(UI_OWNER));
|
|
65262
|
+
if (drawsViews(ctx)) ctx.state.layout.cleanups.push(projection.onBuild(jsx.asideBuilt));
|
|
64387
65263
|
if (typeof __MOKU_GAME_AGENT__ !== "undefined" && __MOKU_GAME_AGENT__) ctx.state.layout.cleanups.push(ctx.deps.input.onTap((entity) => debugTap(ctx, entity)), ecs.onAdded(DebugTrigger, (entity) => checkTrigger(ctx, entity)));
|
|
64388
65264
|
}
|
|
64389
65265
|
/**
|