@moku-labs/game 0.15.45 → 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-BaXRIOPU.d.mts → commands-C2-V2uKy.d.mts} +5 -5
- package/dist/control.d.mts +4 -4
- package/dist/{define-uySGnVPX.d.mts → define-NGQXu7Qj.d.mts} +2 -2
- package/dist/{headless-DrlyL0pm.d.mts → headless-DcJCzBkz.d.mts} +1 -1
- package/dist/{index-CRihYJbm.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-CIt0aVFZ.d.mts → runtime--I74mwMY.d.mts} +1 -1
- package/dist/{src-tF21Z_H9.mjs → src-CI77RUzT.mjs} +1044 -157
- package/dist/testing.d.mts +4 -4
- package/dist/testing.mjs +1 -1
- package/dist/{types-B2KkIW4i.d.mts → types-Bc_re3rB.d.mts} +156 -42
- package/dist/{types-CIHizn2J.d.mts → types-CiSVMR89.d.mts} +15 -5
- package/dist/{types-DabD5pC9.d.mts → types-D4Q5MH_l.d.mts} +2 -2
- package/dist/{types-Bf2e_BIs.d.mts → types-RX1bYaqD.d.mts} +2 -2
- package/dist/{types-BAS9CfKx.d.mts → types-dF8Qmn7P.d.mts} +4 -4
- package/dist/{visual-D71Z28Yl.d.mts → visual-wSjsCu_W.d.mts} +6 -6
- package/dist/visual.d.mts +1 -1
- package/llms.txt +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;
|
|
@@ -3071,6 +3071,17 @@ async function effectValue(state, log, descriptor, signal) {
|
|
|
3071
3071
|
}
|
|
3072
3072
|
}
|
|
3073
3073
|
/**
|
|
3074
|
+
* Tells whether an awaited effect resolves at once, without the wait for the next `signals` phase: the `schedule` of
|
|
3075
|
+
* `flow` itself, whose handler only writes the next moment into the clock. A node that arms the clock on its way to a
|
|
3076
|
+
* scene switch (a board's tick) would otherwise cost the player a frame before the switch starts (F61).
|
|
3077
|
+
*
|
|
3078
|
+
* @param descriptor - The awaited descriptor.
|
|
3079
|
+
* @returns True for `schedule`.
|
|
3080
|
+
*/
|
|
3081
|
+
function resolvesAtOnce(descriptor) {
|
|
3082
|
+
return descriptor.kind === "schedule";
|
|
3083
|
+
}
|
|
3084
|
+
/**
|
|
3074
3085
|
* Queues a completion for the `signals` phase. The slot is taken when the effect STARTS, so two
|
|
3075
3086
|
* effects that end in one frame always resume in the order they were started. The queued entry
|
|
3076
3087
|
* removes itself from the queue when it fires.
|
|
@@ -3174,7 +3185,7 @@ function openForAnswers(ctx, gate, descriptor, answers, signal) {
|
|
|
3174
3185
|
* Creates the effects gateway: `handle` registers one handler per kind, `dispatch` delivers
|
|
3175
3186
|
* fire-and-forget, `onHint` listens to the released hints, the internal `run` awaits a descriptor
|
|
3176
3187
|
* (through the gate when it has `answers`), hints are buffered with the transaction and released
|
|
3177
|
-
* after its commit, and completions resolve in start order in the `signals` phase.
|
|
3188
|
+
* after its commit, and completions resolve in start order in the `signals` phase (`schedule` at once).
|
|
3178
3189
|
*
|
|
3179
3190
|
* @param ctx - Domain context of the flow plugin.
|
|
3180
3191
|
* @param deps - Injected sibling APIs.
|
|
@@ -3219,7 +3230,7 @@ function createFxApi(ctx, deps) {
|
|
|
3219
3230
|
if (answers !== void 0) return openForAnswers(ctx, deps.gate, descriptor, answers, signal);
|
|
3220
3231
|
const shown = descriptor.kind === "guide" ? beginGuide(state, signal) : signal;
|
|
3221
3232
|
const work = effectValue(state, ctx.log, descriptor, shown);
|
|
3222
|
-
if (state.mode === "fast" || !ctx.deps.time.isRunning()) return work;
|
|
3233
|
+
if (state.mode === "fast" || !ctx.deps.time.isRunning() || resolvesAtOnce(descriptor)) return work;
|
|
3223
3234
|
return enqueue$2(state, work);
|
|
3224
3235
|
},
|
|
3225
3236
|
buffer: (item) => {
|
|
@@ -9752,8 +9763,9 @@ function registerFeatures(ctx, ecs, projection) {
|
|
|
9752
9763
|
* callback records the frame history before it clears the change sets; in an agent build the
|
|
9753
9764
|
* timing table starts with the page clock of `time` and the `input` callback zeroes it each
|
|
9754
9765
|
* frame. The resource `Now` gets `clock.now()` once here and first thing in every `input`
|
|
9755
|
-
* callback, so every system of a frame reads one moment; a running scene build
|
|
9756
|
-
* 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
|
|
9757
9769
|
* plugin's own API, so it builds its own module objects — they are views on `ctx.state`, which is
|
|
9758
9770
|
* the one place the modules keep their data.
|
|
9759
9771
|
*
|
|
@@ -9777,6 +9789,7 @@ function connectWorld(ctx) {
|
|
|
9777
9789
|
projection.startFrame(now);
|
|
9778
9790
|
worldCtx.state.ecs.timing?.ms.fill(0);
|
|
9779
9791
|
projection.reconcileIfDirty();
|
|
9792
|
+
projection.stepWarm();
|
|
9780
9793
|
ecs.runPhase("input", frame);
|
|
9781
9794
|
}), time.onFrame("animate", (frame) => {
|
|
9782
9795
|
projection.sweep();
|
|
@@ -9790,7 +9803,7 @@ function connectWorld(ctx) {
|
|
|
9790
9803
|
/**
|
|
9791
9804
|
* Empties the world in `onStop`: the frame callbacks and the hint listener are removed, then
|
|
9792
9805
|
* every track, view, queued view, entity and resource is dropped, a running scene build and the
|
|
9793
|
-
* `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.
|
|
9794
9807
|
* No `onRemoved` fires, because `renderer` stopped earlier and destroyed its own objects.
|
|
9795
9808
|
*
|
|
9796
9809
|
* @param state - The plugin state, the only thing a teardown context carries.
|
|
@@ -9818,6 +9831,11 @@ function clearWorld(state) {
|
|
|
9818
9831
|
state.projection.owedLoops = 0;
|
|
9819
9832
|
delete state.projection.building;
|
|
9820
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;
|
|
9821
9839
|
state.ecs.generations.length = 0;
|
|
9822
9840
|
state.ecs.free.length = 0;
|
|
9823
9841
|
state.ecs.owners.clear();
|
|
@@ -10017,7 +10035,8 @@ function startTrack$2(pctx, entity, component, to, options) {
|
|
|
10017
10035
|
entity,
|
|
10018
10036
|
component: component.componentName,
|
|
10019
10037
|
handle,
|
|
10020
|
-
additive: options.additive === true
|
|
10038
|
+
additive: options.additive === true,
|
|
10039
|
+
forever: options.repeat === "forever"
|
|
10021
10040
|
});
|
|
10022
10041
|
return handle;
|
|
10023
10042
|
}
|
|
@@ -10167,6 +10186,8 @@ function diffComponents(rest, next, byIdentity) {
|
|
|
10167
10186
|
}
|
|
10168
10187
|
//#endregion
|
|
10169
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 = [];
|
|
10170
10191
|
/**
|
|
10171
10192
|
* Normalises a caught value into an `Error`, so the log always gets one.
|
|
10172
10193
|
*
|
|
@@ -10255,27 +10276,64 @@ function drawsAtPlace(pctx, view, order) {
|
|
|
10255
10276
|
return view.rest.has(Tree.componentName) && typeof rest === "object" && "value" in rest && rest.value === order;
|
|
10256
10277
|
}
|
|
10257
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
|
+
/**
|
|
10258
10294
|
* Keeps a mounted projection for the scene that comes, as a scene switch does for a projection
|
|
10259
10295
|
* both scenes list: it stays mounted into the new layer list, and its screen roots take the
|
|
10260
10296
|
* `Order` of their place in the new list, on the entity and in the rest pose, so the next node of
|
|
10261
|
-
* a root compares equal and writes none
|
|
10262
|
-
* 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.
|
|
10263
10300
|
*
|
|
10264
10301
|
* @param pctx - Domain context of the projection module.
|
|
10265
10302
|
* @param mounted - The mounted projection the new list names again.
|
|
10266
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.
|
|
10267
10306
|
*/
|
|
10268
|
-
function placeMounted(pctx, mounted, order) {
|
|
10307
|
+
function placeMounted(pctx, mounted, order, held) {
|
|
10269
10308
|
const previous = mounted.order;
|
|
10270
10309
|
mounted.layers = pctx.ctx.state.projection.layers;
|
|
10271
10310
|
if (previous === order) return;
|
|
10272
10311
|
mounted.order = order;
|
|
10273
|
-
for (const view of mounted.live.values())
|
|
10274
|
-
|
|
10275
|
-
|
|
10276
|
-
|
|
10277
|
-
|
|
10278
|
-
|
|
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;
|
|
10279
10337
|
}
|
|
10280
10338
|
/**
|
|
10281
10339
|
* Writes the layer of a view.
|
|
@@ -11301,9 +11359,536 @@ function reseedViews(state, name, from, to) {
|
|
|
11301
11359
|
}
|
|
11302
11360
|
}
|
|
11303
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
|
|
11304
11891
|
//#region src/plugins/world/projection/reconcile.ts
|
|
11305
|
-
/** The components of a view of the build at its spawn: none, so it is flagged before the first `onAdded`. */
|
|
11306
|
-
const NO_COMPONENTS = [];
|
|
11307
11892
|
/**
|
|
11308
11893
|
* Creates the empty set of used hints. It lives in its own non-exported function because lint
|
|
11309
11894
|
* rule L5 refuses a collection built inside an exported declaration.
|
|
@@ -11368,16 +11953,14 @@ function hintFor$1(pctx, projection, key, used) {
|
|
|
11368
11953
|
return hint;
|
|
11369
11954
|
}
|
|
11370
11955
|
/**
|
|
11371
|
-
*
|
|
11372
|
-
*
|
|
11373
|
-
*
|
|
11374
|
-
*
|
|
11375
|
-
* A view of a projection the running build mounts is spawned bare, flagged building, then given
|
|
11376
|
-
* 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.
|
|
11377
11960
|
*
|
|
11378
11961
|
* @param pctx - Domain context of the projection module.
|
|
11379
11962
|
* @param spec - The projection spec.
|
|
11380
|
-
* @param
|
|
11963
|
+
* @param view - The view that came: spawned now, or shown from a warm window.
|
|
11381
11964
|
* @param entry - The key, its item, the peers, the mode and the used hints.
|
|
11382
11965
|
* @param entry.key - The model key.
|
|
11383
11966
|
* @param entry.item - The model item.
|
|
@@ -11385,33 +11968,12 @@ function hintFor$1(pctx, projection, key, used) {
|
|
|
11385
11968
|
* @param entry.direct - Whether the reconcile writes without motions.
|
|
11386
11969
|
* @param entry.used - The hints that reached an entry.
|
|
11387
11970
|
*/
|
|
11388
|
-
function
|
|
11389
|
-
const values = collectView(pctx, spec, entry.item);
|
|
11390
|
-
const state = pctx.ctx.state.projection;
|
|
11391
|
-
const building = state.building;
|
|
11392
|
-
const ecs = pctx.deps.ecs;
|
|
11393
|
-
const owner = {
|
|
11394
|
-
kind: "projection",
|
|
11395
|
-
name: spec.name
|
|
11396
|
-
};
|
|
11397
|
-
const layer = pctx.deps.components.Layer({ name: spec.layer });
|
|
11398
|
-
let entity;
|
|
11399
|
-
if (building?.mounted.get(spec.name) === mounted) {
|
|
11400
|
-
entity = ecs.spawn(owner, NO_COMPONENTS);
|
|
11401
|
-
building.entities.add(entity);
|
|
11402
|
-
ecs.add(entity, layer);
|
|
11403
|
-
for (const value of values.values()) ecs.add(entity, value);
|
|
11404
|
-
} else entity = ecs.spawn(owner, [layer, ...values.values()]);
|
|
11405
|
-
const view = createViewRecord(entity, spec.name, entry.key, entry.item, values, entry.direct ? "mount" : "change");
|
|
11406
|
-
seedMutes(state, spec, entity);
|
|
11407
|
-
mounted.live.set(entry.key, view);
|
|
11408
|
-
state.byEntity.set(entity, view);
|
|
11409
|
-
state.membershipVersion += 1;
|
|
11971
|
+
function playEnter$1(pctx, spec, view, entry) {
|
|
11410
11972
|
const hook = spec.motion?.enter;
|
|
11411
11973
|
const loop = spec.motion?.loop;
|
|
11412
11974
|
if (entry.direct) {
|
|
11413
11975
|
view.loopOwed = true;
|
|
11414
|
-
state.owedLoops += 1;
|
|
11976
|
+
pctx.ctx.state.projection.owedLoops += 1;
|
|
11415
11977
|
return;
|
|
11416
11978
|
}
|
|
11417
11979
|
if (hook === void 0 && loop === void 0) return;
|
|
@@ -11425,6 +11987,68 @@ function enterEntry(pctx, spec, mounted, entry) {
|
|
|
11425
11987
|
playSettle(pctx, view, spec, entry.peers, looseComponents(pctx, view));
|
|
11426
11988
|
}
|
|
11427
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
|
+
/**
|
|
11428
12052
|
* A key whose item is another object than before: structural changes are written, a changed
|
|
11429
12053
|
* component with a hook is handed to it and one without is written directly, then the retarget
|
|
11430
12054
|
* settles what is loose. A view no motion moves after that gets its pending `lift(false)`.
|
|
@@ -11534,9 +12158,11 @@ function reviveEntry(pctx, spec, mounted, view, entry) {
|
|
|
11534
12158
|
*/
|
|
11535
12159
|
function exitEntry(pctx, spec, mounted, view, entry) {
|
|
11536
12160
|
const hook = spec.motion?.exit;
|
|
12161
|
+
const state = pctx.ctx.state.projection;
|
|
11537
12162
|
mounted.live.delete(view.key);
|
|
11538
|
-
|
|
12163
|
+
state.membershipVersion += 1;
|
|
11539
12164
|
view.cause = entry.direct ? "mount" : "change";
|
|
12165
|
+
coolShown(state, spec.name, view);
|
|
11540
12166
|
if (entry.direct || hook === void 0) {
|
|
11541
12167
|
despawnView(pctx, mounted, view);
|
|
11542
12168
|
return;
|
|
@@ -11579,7 +12205,7 @@ function settleUnchanged(pctx, spec, view, entry) {
|
|
|
11579
12205
|
}
|
|
11580
12206
|
/**
|
|
11581
12207
|
* Routes one key of the new state to the entry it belongs to: a live view changes, a queued view
|
|
11582
|
-
* revives, an unknown key enters.
|
|
12208
|
+
* revives, a key a warm window holds is shown, an unknown key enters.
|
|
11583
12209
|
*
|
|
11584
12210
|
* @param pctx - Domain context of the projection module.
|
|
11585
12211
|
* @param spec - The projection spec.
|
|
@@ -11605,7 +12231,9 @@ function applyEntry(pctx, spec, mounted, entry, counts) {
|
|
|
11605
12231
|
}
|
|
11606
12232
|
const queued = mounted.queue.find((view) => view.key === entry.key);
|
|
11607
12233
|
if (queued === void 0) {
|
|
11608
|
-
|
|
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);
|
|
11609
12237
|
counts.entered += 1;
|
|
11610
12238
|
return;
|
|
11611
12239
|
}
|
|
@@ -11973,7 +12601,8 @@ function drawsAlike(before, after, spec) {
|
|
|
11973
12601
|
}
|
|
11974
12602
|
/**
|
|
11975
12603
|
* Unmounts projections: every motion of their views is finished, and the live views and the
|
|
11976
|
-
* 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.
|
|
11977
12606
|
*
|
|
11978
12607
|
* @param pctx - Domain context of the projection module.
|
|
11979
12608
|
* @param names - Names of the projections to unmount.
|
|
@@ -11984,6 +12613,7 @@ function unmountNames(pctx, names) {
|
|
|
11984
12613
|
const mounted = state.mounted.get(name);
|
|
11985
12614
|
if (mounted === void 0) continue;
|
|
11986
12615
|
clearMounted(pctx, mounted);
|
|
12616
|
+
forgetWarm(pctx, name);
|
|
11987
12617
|
state.mounted.delete(name);
|
|
11988
12618
|
}
|
|
11989
12619
|
}
|
|
@@ -12041,7 +12671,8 @@ function mountNames(pctx, names, owner) {
|
|
|
12041
12671
|
/**
|
|
12042
12672
|
* Gives every projection of a list its place under the current layer list: a missing one gets an
|
|
12043
12673
|
* empty record at the `Order` of its place, a kept one mounted under another list takes its new
|
|
12044
|
-
* 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.
|
|
12045
12676
|
*
|
|
12046
12677
|
* @param pctx - Domain context of the projection module.
|
|
12047
12678
|
* @param names - The projection list of the scene.
|
|
@@ -12053,7 +12684,9 @@ function placeNames(pctx, names, owner) {
|
|
|
12053
12684
|
const order = orderIn(names, name);
|
|
12054
12685
|
const mounted = state.mounted.get(name);
|
|
12055
12686
|
if (mounted === void 0) state.mounted.set(name, emptyMounted(owner, order, state.layers));
|
|
12056
|
-
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);
|
|
12057
12690
|
}
|
|
12058
12691
|
}
|
|
12059
12692
|
/**
|
|
@@ -12081,20 +12714,17 @@ function reconcileFresh(pctx, names) {
|
|
|
12081
12714
|
* @param names - The projection list of the coming scene.
|
|
12082
12715
|
* @param layers - The layer list of the coming scene.
|
|
12083
12716
|
* @param owner - Who owns the entities of the projections it mounts.
|
|
12084
|
-
* @param
|
|
12085
|
-
* @
|
|
12086
|
-
* @param timing.now - The game clock at the build start.
|
|
12087
|
-
* @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.
|
|
12088
12719
|
*/
|
|
12089
|
-
function emptyBuilding(names, layers, owner,
|
|
12720
|
+
function emptyBuilding(names, layers, owner, budgetMs) {
|
|
12090
12721
|
return {
|
|
12091
12722
|
names: [...names],
|
|
12092
12723
|
layers,
|
|
12093
12724
|
owner,
|
|
12094
12725
|
mounted: /* @__PURE__ */ new Map(),
|
|
12095
12726
|
entities: /* @__PURE__ */ new Set(),
|
|
12096
|
-
|
|
12097
|
-
budgetMs: timing.budgetMs
|
|
12727
|
+
budgetMs
|
|
12098
12728
|
};
|
|
12099
12729
|
}
|
|
12100
12730
|
/**
|
|
@@ -12136,6 +12766,8 @@ function handBack(pctx, building) {
|
|
|
12136
12766
|
* a mount checks it, against the coming layers; a projection the current scene mounts and the
|
|
12137
12767
|
* coming one declares alike stays as it is, and every other one is mounted aside, direct. A view
|
|
12138
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.
|
|
12139
12771
|
*
|
|
12140
12772
|
* @param pctx - Domain context of the projection module.
|
|
12141
12773
|
* @param names - The projection list of the coming scene.
|
|
@@ -12151,10 +12783,9 @@ function buildNames(pctx, names, owner, layers, budgetMs) {
|
|
|
12151
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.");
|
|
12152
12784
|
const { fresh, again } = sortMount(pctx, names, layers);
|
|
12153
12785
|
if (again.length > 0) return false;
|
|
12154
|
-
|
|
12155
|
-
|
|
12156
|
-
|
|
12157
|
-
});
|
|
12786
|
+
discardActive(pctx);
|
|
12787
|
+
state.frameStart = pctx.ctx.deps.clock.now();
|
|
12788
|
+
const building = emptyBuilding(names, layers, owner, budgetMs);
|
|
12158
12789
|
for (const spec of fresh) building.mounted.set(spec.name, emptyMounted(owner, orderIn(names, spec.name), layers));
|
|
12159
12790
|
state.building = building;
|
|
12160
12791
|
if (fresh.length === 0) return true;
|
|
@@ -12319,6 +12950,8 @@ function createProjectionApi(ctx, deps) {
|
|
|
12319
12950
|
* Reconciles what is dirty. The cause table decides play or direct, whether every live view
|
|
12320
12951
|
* and every element with a recorded rest pose is brought to it (a restore and a load do that),
|
|
12321
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.
|
|
12322
12955
|
*/
|
|
12323
12956
|
const reconcileIfDirty = () => {
|
|
12324
12957
|
const dirty = state.dirty;
|
|
@@ -12327,12 +12960,14 @@ function createProjectionApi(ctx, deps) {
|
|
|
12327
12960
|
const direct = dirty.force || dirty.causes.some((cause) => isDirectCause(cause)) || deps.ecs.mode() !== "live";
|
|
12328
12961
|
const converge = dirty.causes.some((cause) => isConvergeCause(cause));
|
|
12329
12962
|
const settle = dirty.causes.includes("rollback");
|
|
12963
|
+
if (converge || dirty.force) discardHeld(pctx);
|
|
12330
12964
|
reconcile(pctx, {
|
|
12331
12965
|
direct,
|
|
12332
12966
|
force: dirty.force,
|
|
12333
12967
|
converge,
|
|
12334
12968
|
settle
|
|
12335
12969
|
});
|
|
12970
|
+
if (state.warmList.length > 0) state.warmStale = true;
|
|
12336
12971
|
}
|
|
12337
12972
|
state.hints.length = 0;
|
|
12338
12973
|
};
|
|
@@ -12364,7 +12999,10 @@ function createProjectionApi(ctx, deps) {
|
|
|
12364
12999
|
const seed = learnSeed(state, spec);
|
|
12365
13000
|
state.specs.set(spec.name, spec);
|
|
12366
13001
|
reseedViews(state, spec.name, from, seed);
|
|
12367
|
-
if (mounted)
|
|
13002
|
+
if (!mounted) return;
|
|
13003
|
+
if (spec.warm === void 0) forgetWarm(pctx, spec.name);
|
|
13004
|
+
else ensureWarm(state, spec);
|
|
13005
|
+
forceRerun();
|
|
12368
13006
|
},
|
|
12369
13007
|
setLayers: (list) => {
|
|
12370
13008
|
state.layers = Object.freeze(list.map((layer) => ({ ...layer })));
|
|
@@ -12420,7 +13058,10 @@ function createProjectionApi(ctx, deps) {
|
|
|
12420
13058
|
membershipVersion: () => state.membershipVersion,
|
|
12421
13059
|
causeOf: (entity) => state.byEntity.get(entity)?.cause ?? state.leaving.get(entity),
|
|
12422
13060
|
motionsOf: (entity) => runningComponents(state.tracks, entity),
|
|
12423
|
-
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
|
+
},
|
|
12424
13065
|
entitiesOf: (name) => {
|
|
12425
13066
|
const mounted = state.mounted.get(name) ?? state.building?.mounted.get(name);
|
|
12426
13067
|
return mounted === void 0 ? [] : liveEntities(mounted);
|
|
@@ -12454,6 +13095,7 @@ function createProjectionApi(ctx, deps) {
|
|
|
12454
13095
|
key
|
|
12455
13096
|
});
|
|
12456
13097
|
state.sweptDespawns = -1;
|
|
13098
|
+
holdRegistered(state, projection, entity);
|
|
12457
13099
|
return () => {
|
|
12458
13100
|
if (byKey.get(key) === entity) byKey.delete(key);
|
|
12459
13101
|
if (state.keysByEntity.get(entity)?.key === key) state.keysByEntity.delete(entity);
|
|
@@ -12481,11 +13123,11 @@ function createProjectionApi(ctx, deps) {
|
|
|
12481
13123
|
discardBuild(pctx);
|
|
12482
13124
|
},
|
|
12483
13125
|
left: () => {
|
|
12484
|
-
const
|
|
12485
|
-
if (
|
|
12486
|
-
return
|
|
13126
|
+
const budget = frameBudget(state);
|
|
13127
|
+
if (budget === void 0) return Number.POSITIVE_INFINITY;
|
|
13128
|
+
return budget - (ctx.deps.clock.now() - state.frameStart);
|
|
12487
13129
|
},
|
|
12488
|
-
isBuilding: (entity) => state.building?.entities.has(entity) === true,
|
|
13130
|
+
isBuilding: (entity) => state.building?.entities.has(entity) === true || state.warmHeld.has(entity),
|
|
12489
13131
|
onBuild: (check) => {
|
|
12490
13132
|
state.buildChecks.push(check);
|
|
12491
13133
|
return () => {
|
|
@@ -12494,11 +13136,15 @@ function createProjectionApi(ctx, deps) {
|
|
|
12494
13136
|
};
|
|
12495
13137
|
},
|
|
12496
13138
|
adopt: (entity) => {
|
|
12497
|
-
state.building
|
|
13139
|
+
const building = state.building;
|
|
13140
|
+
if (building === void 0) adoptWarm(state, entity);
|
|
13141
|
+
else building.entities.add(entity);
|
|
12498
13142
|
},
|
|
12499
13143
|
startFrame: (now) => {
|
|
12500
|
-
|
|
12501
|
-
|
|
13144
|
+
state.frameStart = now;
|
|
13145
|
+
},
|
|
13146
|
+
stepWarm: () => {
|
|
13147
|
+
stepWarm(pctx);
|
|
12502
13148
|
},
|
|
12503
13149
|
markDirty: (roots, cause) => {
|
|
12504
13150
|
const dirty = state.dirty ?? emptyDirty();
|
|
@@ -12521,6 +13167,7 @@ function createProjectionApi(ctx, deps) {
|
|
|
12521
13167
|
if (state.sweptDespawns !== despawns) {
|
|
12522
13168
|
state.sweptDespawns = despawns;
|
|
12523
13169
|
forgetDeadElements(pctx);
|
|
13170
|
+
forgetDeadHeld(pctx);
|
|
12524
13171
|
}
|
|
12525
13172
|
if (state.owedLoops > 0) startOwedLoops(pctx);
|
|
12526
13173
|
},
|
|
@@ -12535,10 +13182,13 @@ function createProjectionApi(ctx, deps) {
|
|
|
12535
13182
|
ownerLeft: (owner) => {
|
|
12536
13183
|
if (owner.kind !== "projection") return;
|
|
12537
13184
|
const mounted = state.mounted.get(owner.name);
|
|
13185
|
+
const warm = state.warm.get(owner.name);
|
|
12538
13186
|
if (mounted !== void 0) clearMounted(pctx, mounted);
|
|
13187
|
+
if (warm !== void 0) discardWarm(pctx, warm);
|
|
12539
13188
|
},
|
|
12540
13189
|
clear: () => {
|
|
12541
13190
|
discardBuild(pctx);
|
|
13191
|
+
clearWarm(pctx);
|
|
12542
13192
|
for (const mounted of [...state.mounted.values()]) clearMounted(pctx, mounted);
|
|
12543
13193
|
state.mounted.clear();
|
|
12544
13194
|
state.specs.clear();
|
|
@@ -12826,9 +13476,19 @@ function emptyWeakMap$2() {
|
|
|
12826
13476
|
return /* @__PURE__ */ new WeakMap();
|
|
12827
13477
|
}
|
|
12828
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
|
+
/**
|
|
12829
13488
|
* Creates the initial projection state: nothing registered, nothing mounted, no layer list, no
|
|
12830
13489
|
* running track and no driver, so every motion is instant until `anim` installs one. No build
|
|
12831
|
-
* 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.
|
|
12832
13492
|
*
|
|
12833
13493
|
* @returns The projection branch of the plugin state.
|
|
12834
13494
|
*/
|
|
@@ -12856,7 +13516,13 @@ function createProjectionState() {
|
|
|
12856
13516
|
moving: false,
|
|
12857
13517
|
owedLoops: 0,
|
|
12858
13518
|
sweptDespawns: 0,
|
|
12859
|
-
buildChecks: []
|
|
13519
|
+
buildChecks: [],
|
|
13520
|
+
frameStart: 0,
|
|
13521
|
+
warm: emptyMap$9(),
|
|
13522
|
+
warmList: [],
|
|
13523
|
+
warmHeld: emptySet$8(),
|
|
13524
|
+
warmStale: false,
|
|
13525
|
+
warmBudgetMs: FALLBACK_WARM_MS
|
|
12860
13526
|
};
|
|
12861
13527
|
}
|
|
12862
13528
|
//#endregion
|
|
@@ -25685,6 +26351,8 @@ function destroyPools(state) {
|
|
|
25685
26351
|
}
|
|
25686
26352
|
//#endregion
|
|
25687
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;
|
|
25688
26356
|
/**
|
|
25689
26357
|
* Tells whether a view is held: its entity belongs to the running build, and it has no parent or its parent is live.
|
|
25690
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
|
|
@@ -25701,7 +26369,9 @@ function holds(sctx, entity, parent) {
|
|
|
25701
26369
|
}
|
|
25702
26370
|
/**
|
|
25703
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
|
|
25704
|
-
* 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.
|
|
25705
26375
|
*
|
|
25706
26376
|
* @param sctx - Domain context of the sync module.
|
|
25707
26377
|
* @param entity - The entity.
|
|
@@ -25715,13 +26385,25 @@ function holdView(sctx, entity, view, layer) {
|
|
|
25715
26385
|
view.layer = layer;
|
|
25716
26386
|
detach$1(view.wrapper ?? view.object);
|
|
25717
26387
|
if (view.held) return;
|
|
26388
|
+
if (held.count === 0) held.version = sctx.ctx.deps.world.projection.membershipVersion();
|
|
25718
26389
|
view.held = true;
|
|
25719
26390
|
held.entities[held.count] = entity;
|
|
25720
26391
|
held.count += 1;
|
|
25721
26392
|
}
|
|
25722
26393
|
/**
|
|
25723
|
-
*
|
|
25724
|
-
*
|
|
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.
|
|
25725
26407
|
*
|
|
25726
26408
|
* @param state - The sync branch of the plugin state.
|
|
25727
26409
|
*/
|
|
@@ -29456,6 +30138,7 @@ function dropView(sctx, entity) {
|
|
|
29456
30138
|
if (view === void 0) return;
|
|
29457
30139
|
markView(sctx, entity);
|
|
29458
30140
|
noteLeaving(state, view);
|
|
30141
|
+
leaveHeld(state, view);
|
|
29459
30142
|
sctx.deps.kept.forget(entity);
|
|
29460
30143
|
const host = view.clipped ?? view.wrapper;
|
|
29461
30144
|
if (host !== void 0) detachChildren(sctx, entity, host);
|
|
@@ -30517,7 +31200,8 @@ function layerOf$1(sctx, entity) {
|
|
|
30517
31200
|
/** Views made between two reads of the clock: a read costs more than a small view. */
|
|
30518
31201
|
const CLOCK_EVERY$1 = 8;
|
|
30519
31202
|
/**
|
|
30520
|
-
* 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.
|
|
30521
31205
|
*
|
|
30522
31206
|
* @param sctx - Domain context of the sync module.
|
|
30523
31207
|
* @returns True while a build runs.
|
|
@@ -30563,6 +31247,18 @@ function dropAside(state, entity) {
|
|
|
30563
31247
|
if (state.aside.count > 0) state.aside.waiting.delete(entity);
|
|
30564
31248
|
}
|
|
30565
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
|
+
/**
|
|
30566
31262
|
* Makes the view of one queued entity, its queued parent first (spec 16 U2.3: a child made before its parent finds no
|
|
30567
31263
|
* parent view and is detached for good). The entity leaves the waiting set before its parent is made, so a cycle of
|
|
30568
31264
|
* parents ends. A throw costs that entity.
|
|
@@ -30597,7 +31293,7 @@ function makeParentFirst(sctx, entity, report) {
|
|
|
30597
31293
|
function makeAside(sctx, report) {
|
|
30598
31294
|
const state = sctx.ctx.state.sync;
|
|
30599
31295
|
const { aside } = state;
|
|
30600
|
-
const
|
|
31296
|
+
const projection = sctx.ctx.deps.world.projection;
|
|
30601
31297
|
const version = state.passesVersion;
|
|
30602
31298
|
let made = 0;
|
|
30603
31299
|
let check = 1;
|
|
@@ -30606,8 +31302,7 @@ function makeAside(sctx, report) {
|
|
|
30606
31302
|
aside.head += 1;
|
|
30607
31303
|
if (!aside.waiting.has(entity)) continue;
|
|
30608
31304
|
if (!projection.isBuilding(entity)) {
|
|
30609
|
-
|
|
30610
|
-
if (ecs.ownerOf(entity) !== void 0) state.added.add(entity);
|
|
31305
|
+
toLivePass(sctx, entity);
|
|
30611
31306
|
continue;
|
|
30612
31307
|
}
|
|
30613
31308
|
made += makeParentFirst(sctx, entity, report);
|
|
@@ -30636,7 +31331,8 @@ function underStage(node, stage) {
|
|
|
30636
31331
|
}
|
|
30637
31332
|
/**
|
|
30638
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
|
|
30639
|
-
* 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.
|
|
30640
31336
|
*
|
|
30641
31337
|
* @param sctx - Domain context of the sync module.
|
|
30642
31338
|
*/
|
|
@@ -30653,7 +31349,9 @@ function checkDrawn(sctx) {
|
|
|
30653
31349
|
}
|
|
30654
31350
|
/**
|
|
30655
31351
|
* The building step of a frame, after the live pass: the views of the aside queue are made under the budget, and while
|
|
30656
|
-
* 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.
|
|
30657
31355
|
*
|
|
30658
31356
|
* @param sctx - Domain context of the sync module.
|
|
30659
31357
|
* @param report - Logs a throw of one entity's work.
|
|
@@ -30662,28 +31360,56 @@ function stepAside(sctx, report) {
|
|
|
30662
31360
|
const state = sctx.ctx.state.sync;
|
|
30663
31361
|
const { aside } = state;
|
|
30664
31362
|
if (aside.made !== 0) aside.made = 0;
|
|
30665
|
-
if (aside.head >= aside.count && state.heldViews.count === 0) return;
|
|
31363
|
+
if (aside.head >= aside.count && (state.heldViews.count === 0 || !buildRuns(sctx))) return;
|
|
30666
31364
|
if (aside.head < aside.count) aside.made = makeAside(sctx, report);
|
|
30667
31365
|
sctx.deps.demand.request();
|
|
30668
31366
|
if (typeof __MOKU_GAME_DEV__ !== "undefined" && __MOKU_GAME_DEV__ || typeof __MOKU_GAME_AGENT__ !== "undefined" && __MOKU_GAME_AGENT__) checkDrawn(sctx);
|
|
30669
31367
|
}
|
|
30670
31368
|
/**
|
|
30671
|
-
* Tells whether held views wait for the pass that attaches them:
|
|
30672
|
-
*
|
|
30673
|
-
*
|
|
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.
|
|
30674
31372
|
*
|
|
30675
31373
|
* @param sctx - Domain context of the sync module.
|
|
30676
|
-
* @returns True when the pass has held views to
|
|
31374
|
+
* @returns True when the pass has held views to look at again.
|
|
30677
31375
|
*/
|
|
30678
31376
|
function heldWaiting(sctx) {
|
|
30679
31377
|
const held = sctx.ctx.state.sync.heldViews;
|
|
30680
|
-
return held.count > 0 &&
|
|
31378
|
+
return held.count > 0 && sctx.ctx.deps.world.projection.membershipVersion() !== held.version;
|
|
30681
31379
|
}
|
|
30682
31380
|
/**
|
|
30683
|
-
*
|
|
30684
|
-
*
|
|
30685
|
-
*
|
|
30686
|
-
*
|
|
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`.
|
|
30687
31413
|
*
|
|
30688
31414
|
* @param sctx - Domain context of the sync module.
|
|
30689
31415
|
*/
|
|
@@ -30691,16 +31417,25 @@ function attachHeld(sctx) {
|
|
|
30691
31417
|
if (!heldWaiting(sctx)) return;
|
|
30692
31418
|
const state = sctx.ctx.state.sync;
|
|
30693
31419
|
const held = state.heldViews;
|
|
31420
|
+
const projection = sctx.ctx.deps.world.projection;
|
|
31421
|
+
let kept = 0;
|
|
30694
31422
|
for (let index = 0; index < held.count; index += 1) {
|
|
30695
31423
|
const entity = held.entities[index] ?? 0;
|
|
30696
31424
|
const view = state.views.get(entity);
|
|
30697
31425
|
if (view === void 0 || !view.held) continue;
|
|
31426
|
+
if (projection.isBuilding(entity)) {
|
|
31427
|
+
held.entities[kept] = entity;
|
|
31428
|
+
kept += 1;
|
|
31429
|
+
continue;
|
|
31430
|
+
}
|
|
30698
31431
|
view.held = false;
|
|
30699
31432
|
attach$1(sctx, entity, view);
|
|
30700
31433
|
resort(sctx, entity, view);
|
|
30701
31434
|
}
|
|
30702
|
-
held.count =
|
|
30703
|
-
|
|
31435
|
+
if (kept !== held.count) held.reported = false;
|
|
31436
|
+
releaseAside(sctx);
|
|
31437
|
+
held.count = kept;
|
|
31438
|
+
held.version = projection.membershipVersion();
|
|
30704
31439
|
}
|
|
30705
31440
|
/**
|
|
30706
31441
|
* Tells whether an entity of a set belongs to the running build.
|
|
@@ -32109,9 +32844,9 @@ function createSyncApi(ctx, deps) {
|
|
|
32109
32844
|
return viewless;
|
|
32110
32845
|
};
|
|
32111
32846
|
/**
|
|
32112
|
-
* The live half of a pass: removed, layers, the held views of a build that ended
|
|
32113
|
-
* invalidated. A despawned entity takes its filter slots with it, also when its view left in an
|
|
32114
|
-
* 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.
|
|
32115
32850
|
*/
|
|
32116
32851
|
const livePass = () => {
|
|
32117
32852
|
state.passesVersion += 1;
|
|
@@ -33173,6 +33908,7 @@ function createSyncState(debug) {
|
|
|
33173
33908
|
heldViews: {
|
|
33174
33909
|
entities: [],
|
|
33175
33910
|
count: 0,
|
|
33911
|
+
version: 0,
|
|
33176
33912
|
reported: false
|
|
33177
33913
|
},
|
|
33178
33914
|
leave: {},
|
|
@@ -39767,7 +40503,7 @@ function dropBuild(build) {
|
|
|
39767
40503
|
//#endregion
|
|
39768
40504
|
//#region src/plugins/scenes/leave.ts
|
|
39769
40505
|
/**
|
|
39770
|
-
* What a game gets when it writes nothing: black at 45 %,
|
|
40506
|
+
* What a game gets when it writes nothing: black at 45 %, 50 ms in and 150 ms out, the engine's ring once the switch took
|
|
39771
40507
|
* 400 ms. The level under `config.leave`, and where a part written over `false` starts. `index.ts` writes the same
|
|
39772
40508
|
* value inline as the plugin's default config; a test pins the two equal.
|
|
39773
40509
|
*/
|
|
@@ -39775,7 +40511,7 @@ const FALLBACK_LEAVE = Object.freeze({
|
|
|
39775
40511
|
cover: Object.freeze({
|
|
39776
40512
|
color: 0,
|
|
39777
40513
|
alpha: .45,
|
|
39778
|
-
inMs:
|
|
40514
|
+
inMs: 50,
|
|
39779
40515
|
outMs: 150
|
|
39780
40516
|
}),
|
|
39781
40517
|
loader: Object.freeze({ afterMs: 400 })
|
|
@@ -39789,7 +40525,7 @@ const FALLBACK_LEAVE = Object.freeze({
|
|
|
39789
40525
|
* @returns The veil, or `false`.
|
|
39790
40526
|
* @example
|
|
39791
40527
|
* ```ts
|
|
39792
|
-
* coverOver(false, { alpha: 0.6 }); // { color: 0, alpha: 0.6, inMs:
|
|
40528
|
+
* coverOver(false, { alpha: 0.6 }); // { color: 0, alpha: 0.6, inMs: 50, outMs: 150 }
|
|
39793
40529
|
* ```
|
|
39794
40530
|
*/
|
|
39795
40531
|
function coverOver(below, over) {
|
|
@@ -39850,7 +40586,7 @@ function loaderOver(below, over) {
|
|
|
39850
40586
|
* @returns Both parts, each resolved or `false`; `undefined` when both are off.
|
|
39851
40587
|
* @example
|
|
39852
40588
|
* ```ts
|
|
39853
|
-
* leaveOf({ loader: false }, { cover: { alpha: 0.6 } }); // { cover: { color: 0, alpha: 0.6, inMs:
|
|
40589
|
+
* leaveOf({ loader: false }, { cover: { alpha: 0.6 } }); // { cover: { color: 0, alpha: 0.6, inMs: 50, outMs: 150 }, loader: false }
|
|
39854
40590
|
* ```
|
|
39855
40591
|
*/
|
|
39856
40592
|
function leaveOf(config, scene) {
|
|
@@ -40809,7 +41545,7 @@ const scenesPlugin = /*#__PURE__*/ createPlugin$1("scenes", {
|
|
|
40809
41545
|
cover: {
|
|
40810
41546
|
color: 0,
|
|
40811
41547
|
alpha: .45,
|
|
40812
|
-
inMs:
|
|
41548
|
+
inMs: 50,
|
|
40813
41549
|
outMs: 150
|
|
40814
41550
|
},
|
|
40815
41551
|
loader: { afterMs: 400 }
|
|
@@ -58632,6 +59368,15 @@ const APPLY_CAP = 100;
|
|
|
58632
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. */
|
|
58633
59369
|
const NO_NODES = [];
|
|
58634
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
|
+
/**
|
|
58635
59380
|
* Tells whether a root has parked parts.
|
|
58636
59381
|
*
|
|
58637
59382
|
* @param root - The root.
|
|
@@ -58668,6 +59413,24 @@ function createParts(ctx, reconcile) {
|
|
|
58668
59413
|
let landed = false;
|
|
58669
59414
|
const parkedPool = [];
|
|
58670
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
|
+
}
|
|
58671
59434
|
/**
|
|
58672
59435
|
* Starts the frame's reconcile: no element entered, the budget not read, no building unit run.
|
|
58673
59436
|
*/
|
|
@@ -58739,6 +59502,7 @@ function createParts(ctx, reconcile) {
|
|
|
58739
59502
|
part.cause = cause;
|
|
58740
59503
|
root.parked ??= [];
|
|
58741
59504
|
root.parked.push(part);
|
|
59505
|
+
track(root);
|
|
58742
59506
|
}
|
|
58743
59507
|
/**
|
|
58744
59508
|
* Puts a parked part back in the pool, its element and nodes dropped.
|
|
@@ -58787,7 +59551,7 @@ function createParts(ctx, reconcile) {
|
|
|
58787
59551
|
* root's queue.
|
|
58788
59552
|
*/
|
|
58789
59553
|
function drainParked() {
|
|
58790
|
-
if (
|
|
59554
|
+
if (busy.size === 0) return;
|
|
58791
59555
|
for (const root of state.roots.values()) {
|
|
58792
59556
|
const parked = root.parked;
|
|
58793
59557
|
while (parked !== void 0 && parked.length > 0) {
|
|
@@ -58797,6 +59561,7 @@ function createParts(ctx, reconcile) {
|
|
|
58797
59561
|
diffPart(root, part);
|
|
58798
59562
|
recycle(part);
|
|
58799
59563
|
}
|
|
59564
|
+
track(root);
|
|
58800
59565
|
}
|
|
58801
59566
|
}
|
|
58802
59567
|
/**
|
|
@@ -58830,6 +59595,16 @@ function createParts(ctx, reconcile) {
|
|
|
58830
59595
|
const part = parked.pop();
|
|
58831
59596
|
if (part !== void 0) recycle(part);
|
|
58832
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) {
|
|
58833
59608
|
const cursor = root.applying;
|
|
58834
59609
|
if (cursor === void 0) return;
|
|
58835
59610
|
while (cursor.stack.length > 0) cursor.stack.pop();
|
|
@@ -58837,6 +59612,30 @@ function createParts(ctx, reconcile) {
|
|
|
58837
59612
|
cursorPool.push(cursor);
|
|
58838
59613
|
}
|
|
58839
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
|
+
/**
|
|
58840
59639
|
* Opens the application of a solved root built aside and applies its first part (spec 33 A6).
|
|
58841
59640
|
*
|
|
58842
59641
|
* @param root - The root built aside.
|
|
@@ -58852,6 +59651,7 @@ function createParts(ctx, reconcile) {
|
|
|
58852
59651
|
cursor.stack.push(element);
|
|
58853
59652
|
root.applying = cursor;
|
|
58854
59653
|
applyPart(root, cursor);
|
|
59654
|
+
track(root);
|
|
58855
59655
|
}
|
|
58856
59656
|
/**
|
|
58857
59657
|
* Applies the next elements of an open application, top-down, parent before children in the
|
|
@@ -58898,6 +59698,7 @@ function createParts(ctx, reconcile) {
|
|
|
58898
59698
|
function closeApplication(root, cursor) {
|
|
58899
59699
|
delete root.applying;
|
|
58900
59700
|
cursorPool.push(cursor);
|
|
59701
|
+
track(root);
|
|
58901
59702
|
landed = true;
|
|
58902
59703
|
for (const host of state.hosts) if (lookup(host)?.root === root.entity) state.risen.add(host);
|
|
58903
59704
|
}
|
|
@@ -58907,7 +59708,7 @@ function createParts(ctx, reconcile) {
|
|
|
58907
59708
|
* here is solved again in the same call when it asks for it.
|
|
58908
59709
|
*/
|
|
58909
59710
|
function applyParts() {
|
|
58910
|
-
if (
|
|
59711
|
+
if (busy.size === 0) return;
|
|
58911
59712
|
for (const root of state.roots.values()) {
|
|
58912
59713
|
const cursor = root.applying;
|
|
58913
59714
|
if (cursor === void 0) continue;
|
|
@@ -58923,9 +59724,11 @@ function createParts(ctx, reconcile) {
|
|
|
58923
59724
|
parks,
|
|
58924
59725
|
park,
|
|
58925
59726
|
waits,
|
|
59727
|
+
working,
|
|
58926
59728
|
drainParked,
|
|
58927
59729
|
holdRoot,
|
|
58928
59730
|
forgetParts,
|
|
59731
|
+
finish,
|
|
58929
59732
|
applyInParts,
|
|
58930
59733
|
applyParts
|
|
58931
59734
|
};
|
|
@@ -59836,6 +60639,11 @@ function createReconciler(ctx, modules, fields) {
|
|
|
59836
60639
|
let rendered = 0;
|
|
59837
60640
|
const isAside = (entity) => ctx.deps.world.projection.isBuilding(entity);
|
|
59838
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;
|
|
59839
60647
|
const lookWriter = {
|
|
59840
60648
|
pass: 0,
|
|
59841
60649
|
values: {
|
|
@@ -59847,8 +60655,10 @@ function createReconciler(ctx, modules, fields) {
|
|
|
59847
60655
|
others: (element, type, next) => writeOthers(element, next, type)
|
|
59848
60656
|
};
|
|
59849
60657
|
/**
|
|
59850
|
-
* Registers the key of an element under its root, so `
|
|
59851
|
-
* `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).
|
|
59852
60662
|
*
|
|
59853
60663
|
* @param root - The root the element belongs to.
|
|
59854
60664
|
* @param element - The element that entered.
|
|
@@ -59859,6 +60669,16 @@ function createReconciler(ctx, modules, fields) {
|
|
|
59859
60669
|
if (keys.has(element.key)) ctx.log.warn("ui:duplicate-key", { key: element.key });
|
|
59860
60670
|
else keys.set(element.key, element.entity);
|
|
59861
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;
|
|
59862
60682
|
element.dropKey = ctx.deps.world.projection.registerKey(root.name, element.key, element.entity);
|
|
59863
60683
|
}
|
|
59864
60684
|
/**
|
|
@@ -60796,7 +61616,7 @@ function createReconciler(ctx, modules, fields) {
|
|
|
60796
61616
|
/**
|
|
60797
61617
|
* Solves one root in a box and applies its rects: a root on the viewport when it is marked, a
|
|
60798
61618
|
* root in a slot also when its slot was resized. A root built aside waits while parts of it wait,
|
|
60799
|
-
* and is applied in parts.
|
|
61619
|
+
* and is applied in parts. A root shown before its parts were done is applied whole and still.
|
|
60800
61620
|
*
|
|
60801
61621
|
* @param root - The root.
|
|
60802
61622
|
* @param box - The viewport, or the slot's content box.
|
|
@@ -60816,8 +61636,12 @@ function createReconciler(ctx, modules, fields) {
|
|
|
60816
61636
|
};
|
|
60817
61637
|
modules.layout.solve(element, box, lookup);
|
|
60818
61638
|
root.needsSolve = false;
|
|
61639
|
+
if (root.aside !== void 0) asideSolved = true;
|
|
60819
61640
|
if (root.aside !== void 0 && isAside(root.entity) && !element.live) parts.applyInParts(root, element, quiet);
|
|
60820
|
-
else
|
|
61641
|
+
else {
|
|
61642
|
+
applyRects(element, quiet || root.still === true);
|
|
61643
|
+
delete root.still;
|
|
61644
|
+
}
|
|
60821
61645
|
return true;
|
|
60822
61646
|
}
|
|
60823
61647
|
/**
|
|
@@ -60882,9 +61706,9 @@ function createReconciler(ctx, modules, fields) {
|
|
|
60882
61706
|
* Keeps an element whose spawn has just been applied: the world calls it from the `Box` hook, at
|
|
60883
61707
|
* the flush of phase `layout`. Its enter hook waits for `playEntered`, so the game's systems see
|
|
60884
61708
|
* the entity first (F48). The hook itself plays at once, so they see the start pose it writes (F49);
|
|
60885
|
-
* `ui.enter` plays it again when one of them changed what it read. An element of a
|
|
60886
|
-
* aside plays nothing here: its enter waits for the swap
|
|
60887
|
-
* 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).
|
|
60888
61712
|
*
|
|
60889
61713
|
* @param entity - The entity the `Box` was attached to.
|
|
60890
61714
|
*/
|
|
@@ -60894,7 +61718,7 @@ function createReconciler(ctx, modules, fields) {
|
|
|
60894
61718
|
else entering.list.push(entity);
|
|
60895
61719
|
entering.count += 1;
|
|
60896
61720
|
const element = state.elements.get(entity);
|
|
60897
|
-
if (arrives(element) && !isAside(
|
|
61721
|
+
if (arrives(element) && !isAside(element.root)) modules.layout.pose(element, overlayOf(element) === void 0 ? void 0 : createSpan());
|
|
60898
61722
|
}
|
|
60899
61723
|
/**
|
|
60900
61724
|
* Plays the enter hooks of the elements a committed build released, at the end of the swap
|
|
@@ -60908,7 +61732,7 @@ function createReconciler(ctx, modules, fields) {
|
|
|
60908
61732
|
for (let index = 0; index < entering.count; index += 1) {
|
|
60909
61733
|
const entity = entering.list[index];
|
|
60910
61734
|
const element = entity === void 0 ? void 0 : state.elements.get(entity);
|
|
60911
|
-
if (!arrives(element) || element.posed !== void 0 || isAside(element.
|
|
61735
|
+
if (!arrives(element) || element.posed !== void 0 || isAside(element.root)) continue;
|
|
60912
61736
|
modules.layout.pose(element, overlayOf(element) === void 0 ? void 0 : createSpan());
|
|
60913
61737
|
}
|
|
60914
61738
|
}
|
|
@@ -60916,33 +61740,39 @@ function createReconciler(ctx, modules, fields) {
|
|
|
60916
61740
|
* Plays the enter hooks queued since the last call, in the order the elements came. The `ui.enter`
|
|
60917
61741
|
* system calls it in phase `sync`: after the game's systems, which may have written what a hook
|
|
60918
61742
|
* reads (a list's scroll), and before `renderer.sync`, so an element is never drawn at its rest
|
|
60919
|
-
* pose by mistake. An element despawned in between plays nothing. An element of a
|
|
60920
|
-
* aside stays queued, in its order, and plays in the first call after the swap
|
|
60921
|
-
* enter, posed by `poseReleased` in that frame's solve, its
|
|
60922
|
-
* 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.
|
|
60923
61749
|
*/
|
|
60924
61750
|
function playEntered() {
|
|
60925
61751
|
const entering = state.entering;
|
|
61752
|
+
const version = ctx.deps.world.projection.membershipVersion();
|
|
61753
|
+
if (entering.count === heldEnters && version === enteredSeen) return;
|
|
60926
61754
|
let held = 0;
|
|
61755
|
+
enteredSeen = version;
|
|
60927
61756
|
for (let index = 0; index < entering.count; index += 1) {
|
|
60928
61757
|
const entity = entering.list[index];
|
|
60929
|
-
|
|
60930
|
-
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)) {
|
|
60931
61761
|
entering.list[held] = entity;
|
|
60932
61762
|
held += 1;
|
|
60933
|
-
} else playEnter(
|
|
61763
|
+
} else playEnter(element);
|
|
60934
61764
|
}
|
|
60935
61765
|
entering.count = held;
|
|
61766
|
+
heldEnters = held;
|
|
60936
61767
|
}
|
|
60937
61768
|
/**
|
|
60938
61769
|
* Plays the enter hook of an element whose spawn has been applied, once. A row a range change
|
|
60939
61770
|
* scrolled in is not new: it plays no `enter` hook, only its loop starts.
|
|
60940
61771
|
*
|
|
60941
|
-
* @param
|
|
61772
|
+
* @param element - The element the `Box` was attached to.
|
|
60942
61773
|
*/
|
|
60943
|
-
function playEnter(
|
|
60944
|
-
|
|
60945
|
-
if (element === void 0 || element.entered) return;
|
|
61774
|
+
function playEnter(element) {
|
|
61775
|
+
if (element.entered) return;
|
|
60946
61776
|
element.entered = true;
|
|
60947
61777
|
if (element.scrolledIn) modules.layout.loop(element);
|
|
60948
61778
|
else if (overlayOf(element) === void 0) modules.layout.enter(element);
|
|
@@ -61013,20 +61843,23 @@ function createReconciler(ctx, modules, fields) {
|
|
|
61013
61843
|
}
|
|
61014
61844
|
}
|
|
61015
61845
|
/**
|
|
61016
|
-
* The live scroll containers
|
|
61017
|
-
*
|
|
61018
|
-
*
|
|
61019
|
-
* 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).
|
|
61020
61851
|
*
|
|
61021
|
-
* @
|
|
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
|
|
61022
61854
|
* next call.
|
|
61023
61855
|
*/
|
|
61024
|
-
function scrollContainers() {
|
|
61856
|
+
function scrollContainers(aside) {
|
|
61025
61857
|
while (scrollList.length > 0) scrollList.pop();
|
|
61026
61858
|
for (const entity of state.scrolls) {
|
|
61027
61859
|
const element = state.elements.get(entity);
|
|
61028
61860
|
if (element?.live !== true) continue;
|
|
61029
|
-
if (
|
|
61861
|
+
if (parts.working() && parts.waits(state.roots.get(element.root))) continue;
|
|
61862
|
+
if (!aside && isAsideScroll(element)) continue;
|
|
61030
61863
|
scrollList.push(element);
|
|
61031
61864
|
}
|
|
61032
61865
|
return scrollList;
|
|
@@ -61108,20 +61941,27 @@ function createReconciler(ctx, modules, fields) {
|
|
|
61108
61941
|
}
|
|
61109
61942
|
}
|
|
61110
61943
|
/**
|
|
61111
|
-
* Finds the roots the last scene build committed
|
|
61112
|
-
*
|
|
61113
|
-
*
|
|
61114
|
-
*
|
|
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.
|
|
61115
61952
|
*/
|
|
61116
61953
|
function settleAside() {
|
|
61117
61954
|
if (state.asideRoots === 0) return;
|
|
61955
|
+
const version = ctx.deps.world.projection.membershipVersion();
|
|
61956
|
+
if (version === asideSeen) return;
|
|
61957
|
+
asideSeen = version;
|
|
61118
61958
|
let left = 0;
|
|
61119
61959
|
let committed = false;
|
|
61120
61960
|
for (const root of state.roots.values()) {
|
|
61121
61961
|
if (root.aside === void 0) continue;
|
|
61122
61962
|
if (isAside(root.entity)) left += 1;
|
|
61123
61963
|
else {
|
|
61124
|
-
|
|
61964
|
+
releaseRoot(root);
|
|
61125
61965
|
committed = true;
|
|
61126
61966
|
}
|
|
61127
61967
|
}
|
|
@@ -61131,6 +61971,17 @@ function createReconciler(ctx, modules, fields) {
|
|
|
61131
61971
|
released = true;
|
|
61132
61972
|
}
|
|
61133
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
|
+
/**
|
|
61134
61985
|
* The part of a scene build `ui` does, which `world` asks through `onBuild` (spec 31): done when no
|
|
61135
61986
|
* root of the build is dirty (its tree not diffed yet, or the layout engine not loaded), has
|
|
61136
61987
|
* parked parts, waits for its solve or is applied in parts (spec 33 A8). A root whose first diff
|
|
@@ -61164,9 +62015,11 @@ function createReconciler(ctx, modules, fields) {
|
|
|
61164
62015
|
reorderRoots();
|
|
61165
62016
|
settlePopups(ctx, state, unmountRoot);
|
|
61166
62017
|
fields.pull();
|
|
61167
|
-
const containers = scrollContainers();
|
|
62018
|
+
const containers = scrollContainers(false);
|
|
62019
|
+
const rangesAside = asideSolved || parts.hasLanded();
|
|
62020
|
+
asideSolved = false;
|
|
61168
62021
|
modules.layout.scroll(containers, lookup, time);
|
|
61169
|
-
range.step(containers);
|
|
62022
|
+
range.step(rangesAside ? scrollContainers(true) : containers);
|
|
61170
62023
|
markResizedTexts(ctx, state, modules.layout);
|
|
61171
62024
|
markResizedIcons(ctx, state, modules.layout);
|
|
61172
62025
|
const viewportChanged = modules.styles.useViewport(ctx.deps.renderer.viewport.size());
|
|
@@ -61217,7 +62070,7 @@ function createReconciler(ctx, modules, fields) {
|
|
|
61217
62070
|
parts.applyParts();
|
|
61218
62071
|
const changed = layOutRoots(viewportBox);
|
|
61219
62072
|
if (changed) ctx.deps.time.wake();
|
|
61220
|
-
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);
|
|
61221
62074
|
rendered = 0;
|
|
61222
62075
|
settleOverlays(ctx, state, modules.layout);
|
|
61223
62076
|
if (state.risen.size > 0) {
|
|
@@ -61805,16 +62658,20 @@ function writeRest(ctx, element, parent) {
|
|
|
61805
62658
|
if (visual !== void 0) projection.setRest(element.entity, visual.component, visual.value);
|
|
61806
62659
|
}
|
|
61807
62660
|
/**
|
|
61808
|
-
* Tells whether an element waits for the swap of a scene `world` builds aside (spec 31)
|
|
61809
|
-
*
|
|
61810
|
-
*
|
|
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.
|
|
61811
62666
|
*
|
|
61812
62667
|
* @param ctx - Domain context of the ui plugin.
|
|
61813
62668
|
* @param element - The element a hook would play on.
|
|
61814
62669
|
* @returns True while its motions are held.
|
|
61815
62670
|
*/
|
|
61816
62671
|
function isHeld(ctx, element) {
|
|
61817
|
-
|
|
62672
|
+
if (element.entered) return false;
|
|
62673
|
+
const projection = ctx.deps.world.projection;
|
|
62674
|
+
return projection.isBuilding(element.entity) || projection.isBuilding(element.root);
|
|
61818
62675
|
}
|
|
61819
62676
|
/**
|
|
61820
62677
|
* Asks the projection for the handle of a ui-owned entity. A foreign owner is an error in the
|
|
@@ -63416,19 +64273,36 @@ function settle(ctx, state, container, content, motion) {
|
|
|
63416
64273
|
show(ctx, state, container, content, motion);
|
|
63417
64274
|
}
|
|
63418
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
|
+
/**
|
|
63419
64290
|
* Settles every scroll on what the solve and the render of this frame gave it. A scroll the solve
|
|
63420
64291
|
* just spawned takes its place at its `offset` prop. A placed one keeps inside a new range at
|
|
63421
64292
|
* once, a running glide's target too, and glides to a new `offset` prop; the same value on a
|
|
63422
|
-
* re-render does nothing, and a scroll the finger holds only remembers it. A scroll
|
|
63423
|
-
*
|
|
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.
|
|
63424
64297
|
*
|
|
63425
64298
|
* @param ctx - Domain context of the ui plugin.
|
|
63426
64299
|
* @param state - The layout state, which keeps the patches.
|
|
63427
64300
|
* @param containers - The live scroll elements.
|
|
63428
64301
|
* @param lookup - How a child entity becomes its element.
|
|
63429
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.
|
|
63430
64304
|
*/
|
|
63431
|
-
function settleScroll(ctx, state, containers, lookup, time) {
|
|
64305
|
+
function settleScroll(ctx, state, containers, lookup, time, stands) {
|
|
63432
64306
|
let moving = false;
|
|
63433
64307
|
for (const container of containers) {
|
|
63434
64308
|
const motion = container.scroll;
|
|
@@ -63436,6 +64310,7 @@ function settleScroll(ctx, state, containers, lookup, time) {
|
|
|
63436
64310
|
if (motion === void 0 || content === void 0) continue;
|
|
63437
64311
|
if (motion.placed) settle(ctx, state, container, content, motion);
|
|
63438
64312
|
else place$1(ctx, container, content, motion);
|
|
64313
|
+
if (motion.mode === "glide" && stands?.(container) === true) standAtTarget(ctx, state, container, content, motion);
|
|
63439
64314
|
if (motion.mode !== "still") moving = true;
|
|
63440
64315
|
}
|
|
63441
64316
|
if (moving && time.delta > 0) ctx.deps.time.wake();
|
|
@@ -63773,7 +64648,7 @@ function createLayoutApi(ctx) {
|
|
|
63773
64648
|
},
|
|
63774
64649
|
settled: (element) => canDespawn(element),
|
|
63775
64650
|
scroll: (containers, lookup, time) => stepScroll(ctx, state, containers, lookup, time),
|
|
63776
|
-
settleScroll: (containers, lookup, time) => settleScroll(ctx, state, containers, lookup, time),
|
|
64651
|
+
settleScroll: (containers, lookup, time, stands) => settleScroll(ctx, state, containers, lookup, time, stands),
|
|
63777
64652
|
clampScroll: (container, contentHeight, lookup) => clampScroll(ctx, state, container, contentHeight, lookup),
|
|
63778
64653
|
scrollTo: (container, to, lookup) => scrollTo(ctx, state, container, to, lookup),
|
|
63779
64654
|
windowOf,
|
|
@@ -64328,6 +65203,16 @@ function registerComponents(ctx, jsx) {
|
|
|
64328
65203
|
for (const feature of ctx.deps.flow.features.all()) for (const entry of feature.description.ui ?? []) if (isComponent(entry)) jsx.register(entry);
|
|
64329
65204
|
}
|
|
64330
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
|
+
/**
|
|
64331
65216
|
* Opens the two systems of phase `layout`, the system `ui.enter` of phase `sync`, the seven world
|
|
64332
65217
|
* hooks of `Tree`, `Box`, `Pressed` and `PointerOver`, the two that tell the hosting step a view
|
|
64333
65218
|
* lost its `Parent` or its `Held` (a view freed so may hang under its host again), the listener
|
|
@@ -64336,9 +65221,10 @@ function registerComponents(ctx, jsx) {
|
|
|
64336
65221
|
* step, the three tap listeners (the `LocalWrite` patch, the pointer tap that clears the keyboard
|
|
64337
65222
|
* focus, and the tap that starts or ends the editing of a text field), the pointer door that opens
|
|
64338
65223
|
* the keyboard inside the DOM listener, the key listener of the focus and `LocalWrite` as an input
|
|
64339
|
-
* control, so the cursor shows a hand over a local-state button, and
|
|
64340
|
-
* (`onBuild`: the roots built aside are reconciled and solved, spec
|
|
64341
|
-
* 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.
|
|
64342
65228
|
*
|
|
64343
65229
|
* The `Box` hook plays an element's enter hook and queues it, so the game's systems see its start
|
|
64344
65230
|
* pose (F49); `ui.enter` starts its loop after them and before the frame is drawn, and plays the
|
|
@@ -64370,9 +65256,10 @@ function openRegistrations(ctx, jsx, layout) {
|
|
|
64370
65256
|
})), ecs.onAdded(Tree, (entity) => {
|
|
64371
65257
|
const place = projection.keyOf(entity);
|
|
64372
65258
|
jsx.mountRoot(entity, place?.projection ?? "ui", ecs.get(entity, Layer)?.name ?? "ui");
|
|
64373
|
-
}), 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) => {
|
|
64374
65260
|
ctx.state.jsx.hints.push(hint);
|
|
64375
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));
|
|
64376
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)));
|
|
64377
65264
|
}
|
|
64378
65265
|
/**
|
|
@@ -66420,7 +67307,7 @@ function cubicBezier(x1, y1, x2, y2) {
|
|
|
66420
67307
|
* | assets | baseUrl | undefined |
|
|
66421
67308
|
* | assets | io | undefined, the browser fetch and the renderer textures |
|
|
66422
67309
|
* | scenes | buildMs | "auto", two thirds of a frame ((1000 / time.rate().fps) * 2 / 3, 11.1 ms at 60 Hz), read at each build start; a number fixes it |
|
|
66423
|
-
* | scenes | leave | { cover: { color: 0x000000, alpha: 0.45, inMs:
|
|
67310
|
+
* | scenes | leave | { cover: { color: 0x000000, alpha: 0.45, inMs: 50, outMs: 150 }, loader: { afterMs: 400 } }, what a live switch shows over the scene being left: a veil from its start and a loader (the engine's ring, a `texture` or a `projection`) once it took `afterMs`; a scene's `leave` is merged over it field by field, a field left out keeps this default, `false` turns a part or the whole off |
|
|
66424
67311
|
* | anim | maxTracks | 2000 |
|
|
66425
67312
|
* | anim | reducedMotion | false |
|
|
66426
67313
|
* | i18n | locale | "en" |
|