@moku-labs/game 0.15.129 → 0.15.131
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/app/page.d.mts +1 -1
- package/dist/app/page.mjs +1 -1
- package/dist/app/system.d.mts +3 -3
- package/dist/app.d.mts +3 -3
- package/dist/app.mjs +1 -1
- package/dist/assets.d.mts +1 -1
- package/dist/{commands-jELzVfPE.d.mts → commands-CzYKkdEO.d.mts} +5 -5
- package/dist/control.d.mts +4 -4
- package/dist/{define-CZ20Hsdi.d.mts → define-DR2SWS9E.d.mts} +2 -2
- package/dist/{headless-C0pK21sO.d.mts → headless-ffgavU3Y.d.mts} +1 -1
- package/dist/{index-C7v9DY3u.d.mts → index-C_Ej5JkQ.d.mts} +40 -4
- package/dist/index.d.mts +4 -4
- package/dist/index.mjs +1 -1
- package/dist/inspect.d.mts +9 -6
- package/dist/inspect.mjs +1 -1
- package/dist/jsx-dev-runtime.d.mts +1 -1
- package/dist/jsx-runtime.d.mts +1 -1
- package/dist/{runtime-CcNv443E.d.mts → runtime-wGL7TbEs.d.mts} +1 -1
- package/dist/{sources-CuG-Vma9.mjs → sources-D9Fk3Z4d.mjs} +45 -4
- package/dist/{src-Qxb4bwE4.mjs → src-BM3N5FXk.mjs} +430 -121
- package/dist/testing.d.mts +4 -4
- package/dist/testing.mjs +1 -1
- package/dist/{types-lV0kgldJ.d.mts → types-Bl-YjAnU.d.mts} +49 -9
- package/dist/{types-DvKiF3cX.d.mts → types-CYjnhoB9.d.mts} +2 -2
- package/dist/{types-BzBlqS6J.d.mts → types-DCtlPrmc.d.mts} +4 -4
- package/dist/{types-D_OXtHWf.d.mts → types-DNmg5EAM.d.mts} +37 -2
- package/dist/{types-ZH5oxtNb.d.mts → types-DU-RYYj0.d.mts} +126 -7
- package/dist/{visual-CmuxTTYx.d.mts → visual-CLR_C--i.d.mts} +6 -6
- package/dist/visual.d.mts +1 -1
- package/dist/visual.mjs +1 -1
- package/llms.txt +2 -2
- package/package.json +1 -1
|
@@ -790,7 +790,7 @@ function askedOf(rate) {
|
|
|
790
790
|
* @param rate - The rate, its mode, its reason, the display and the governor.
|
|
791
791
|
* @returns A fresh frozen snapshot.
|
|
792
792
|
*/
|
|
793
|
-
function snapshotOf(rate) {
|
|
793
|
+
function snapshotOf$1(rate) {
|
|
794
794
|
const { governor } = rate;
|
|
795
795
|
const { hz } = rate.display;
|
|
796
796
|
const asked = askedOf(rate);
|
|
@@ -830,7 +830,7 @@ function createRateState(config) {
|
|
|
830
830
|
...parts,
|
|
831
831
|
drawnNow: false,
|
|
832
832
|
probedNow: false,
|
|
833
|
-
snapshot: snapshotOf(parts),
|
|
833
|
+
snapshot: snapshotOf$1(parts),
|
|
834
834
|
native: void 0
|
|
835
835
|
};
|
|
836
836
|
}
|
|
@@ -1021,7 +1021,7 @@ function switchRate(ctx, to, scale, mode, reason, at) {
|
|
|
1021
1021
|
rate.scale = scale;
|
|
1022
1022
|
rate.mode = mode;
|
|
1023
1023
|
rate.reason = reason;
|
|
1024
|
-
rate.snapshot = snapshotOf(rate);
|
|
1024
|
+
rate.snapshot = snapshotOf$1(rate);
|
|
1025
1025
|
ctx.emit("time:rate", {
|
|
1026
1026
|
from,
|
|
1027
1027
|
to,
|
|
@@ -1070,7 +1070,7 @@ function applyThermal(ctx, g) {
|
|
|
1070
1070
|
function noteThermal(ctx, g, status) {
|
|
1071
1071
|
if (status === null || status === g.thermal) return;
|
|
1072
1072
|
g.thermal = status;
|
|
1073
|
-
ctx.state.rate.snapshot = snapshotOf(ctx.state.rate);
|
|
1073
|
+
ctx.state.rate.snapshot = snapshotOf$1(ctx.state.rate);
|
|
1074
1074
|
applyThermal(ctx, g);
|
|
1075
1075
|
}
|
|
1076
1076
|
/**
|
|
@@ -1100,7 +1100,7 @@ function learnDisplay(ctx, hz, at) {
|
|
|
1100
1100
|
const first = display.hz === null;
|
|
1101
1101
|
display.hz = hz;
|
|
1102
1102
|
if (g !== void 0) g.ladder = ladderOf(hz, ctx.config.maxFps, g.floor);
|
|
1103
|
-
rate.snapshot = snapshotOf(rate);
|
|
1103
|
+
rate.snapshot = snapshotOf$1(rate);
|
|
1104
1104
|
if (g === void 0 || rate.mode !== "auto") return;
|
|
1105
1105
|
if (!g.ladder.includes(rate.fps)) switchRate(ctx, g.ladder.find((step) => step <= rate.fps) ?? g.ladder.at(-1) ?? rate.fps, rate.scale, "auto", "display", at);
|
|
1106
1106
|
if (first) applyThermal(ctx, g);
|
|
@@ -1353,7 +1353,7 @@ function allowScale(rate, floor) {
|
|
|
1353
1353
|
const lowest = g.scales.at(-1) ?? 1;
|
|
1354
1354
|
if (rate.scale < lowest) {
|
|
1355
1355
|
rate.scale = lowest;
|
|
1356
|
-
rate.snapshot = snapshotOf(rate);
|
|
1356
|
+
rate.snapshot = snapshotOf$1(rate);
|
|
1357
1357
|
}
|
|
1358
1358
|
return rate.snapshot;
|
|
1359
1359
|
}
|
|
@@ -10534,7 +10534,8 @@ function startTrack$2(pctx, entity, component, to, options) {
|
|
|
10534
10534
|
component: component.componentName,
|
|
10535
10535
|
handle,
|
|
10536
10536
|
additive: options.additive === true,
|
|
10537
|
-
forever: options.repeat === "forever"
|
|
10537
|
+
forever: options.repeat === "forever",
|
|
10538
|
+
label: options.label
|
|
10538
10539
|
});
|
|
10539
10540
|
return handle;
|
|
10540
10541
|
}
|
|
@@ -10620,6 +10621,23 @@ function runningComponents(tracks, entity) {
|
|
|
10620
10621
|
}
|
|
10621
10622
|
return names;
|
|
10622
10623
|
}
|
|
10624
|
+
/**
|
|
10625
|
+
* The labels of the running tracks on one entity, in track order, each once. A track without a
|
|
10626
|
+
* label adds none. It only reads: an ended track is skipped, not forgotten.
|
|
10627
|
+
*
|
|
10628
|
+
* @param tracks - The tracks the projection started.
|
|
10629
|
+
* @param entity - The entity to ask about.
|
|
10630
|
+
* @returns A new array of labels.
|
|
10631
|
+
*/
|
|
10632
|
+
function runningLabels(tracks, entity) {
|
|
10633
|
+
const labels = [];
|
|
10634
|
+
for (const track of tracks) {
|
|
10635
|
+
if (track.entity !== entity) continue;
|
|
10636
|
+
if (track.label === void 0 || labels.includes(track.label)) continue;
|
|
10637
|
+
if (track.handle.active()) labels.push(track.label);
|
|
10638
|
+
}
|
|
10639
|
+
return labels;
|
|
10640
|
+
}
|
|
10623
10641
|
//#endregion
|
|
10624
10642
|
//#region src/plugins/world/projection/diff.ts
|
|
10625
10643
|
/**
|
|
@@ -11010,7 +11028,8 @@ function createViewHandle(pctx, view, peers) {
|
|
|
11010
11028
|
additive: options.additive ?? false,
|
|
11011
11029
|
...options.segments === void 0 ? {} : { segments: options.segments },
|
|
11012
11030
|
...options.repeat === void 0 ? {} : { repeat: options.repeat },
|
|
11013
|
-
...options.reduced === void 0 ? {} : { reduced: options.reduced }
|
|
11031
|
+
...options.reduced === void 0 ? {} : { reduced: options.reduced },
|
|
11032
|
+
...options.label === void 0 ? {} : { label: options.label }
|
|
11014
11033
|
}),
|
|
11015
11034
|
toRest: (component, options) => {
|
|
11016
11035
|
const target = view.rest.get(component.componentName);
|
|
@@ -11022,7 +11041,8 @@ function createViewHandle(pctx, view, peers) {
|
|
|
11022
11041
|
ease: options?.ease ?? "out",
|
|
11023
11042
|
delayMs: options?.delayMs ?? 0,
|
|
11024
11043
|
additive: false,
|
|
11025
|
-
...options?.reduced === void 0 ? {} : { reduced: options.reduced }
|
|
11044
|
+
...options?.reduced === void 0 ? {} : { reduced: options.reduced },
|
|
11045
|
+
...options?.label === void 0 ? {} : { label: options.label }
|
|
11026
11046
|
});
|
|
11027
11047
|
},
|
|
11028
11048
|
all: (handles) => {
|
|
@@ -13964,6 +13984,7 @@ function createProjectionApi(ctx, deps) {
|
|
|
13964
13984
|
membershipVersion: () => state.membershipVersion,
|
|
13965
13985
|
causeOf: (entity) => state.byEntity.get(entity)?.cause ?? state.leaving.get(entity),
|
|
13966
13986
|
motionsOf: (entity) => runningComponents(state.tracks, entity),
|
|
13987
|
+
motionIdsOf: (entity) => runningLabels(state.tracks, entity),
|
|
13967
13988
|
entityOf: (projection, key) => {
|
|
13968
13989
|
const entity = state.mounted.get(projection)?.live.get(key)?.entity ?? state.keys.get(projection)?.get(key);
|
|
13969
13990
|
return entity === void 0 || state.building?.entities.has(entity) === true || state.warmHeld.has(entity) ? void 0 : entity;
|
|
@@ -14227,6 +14248,7 @@ function exposeProjection(projection) {
|
|
|
14227
14248
|
membershipVersion: projection.membershipVersion,
|
|
14228
14249
|
causeOf: projection.causeOf,
|
|
14229
14250
|
motionsOf: projection.motionsOf,
|
|
14251
|
+
motionIdsOf: projection.motionIdsOf,
|
|
14230
14252
|
entityOf: projection.entityOf,
|
|
14231
14253
|
entitiesOf: projection.entitiesOf,
|
|
14232
14254
|
setDriver: projection.setDriver,
|
|
@@ -40245,6 +40267,160 @@ function loopBlocksSequence(step) {
|
|
|
40245
40267
|
}
|
|
40246
40268
|
}
|
|
40247
40269
|
//#endregion
|
|
40270
|
+
//#region src/plugins/anim/state.ts
|
|
40271
|
+
/**
|
|
40272
|
+
* Creates one empty table. It lives in its own non-exported function because lint rule L5 refuses
|
|
40273
|
+
* a collection built inside an exported declaration.
|
|
40274
|
+
*
|
|
40275
|
+
* @returns An empty map.
|
|
40276
|
+
*/
|
|
40277
|
+
function emptyMap$5() {
|
|
40278
|
+
return /* @__PURE__ */ new Map();
|
|
40279
|
+
}
|
|
40280
|
+
/**
|
|
40281
|
+
* Creates the empty listener set of `onMark`, for the same reason as `emptyMap`.
|
|
40282
|
+
*
|
|
40283
|
+
* @returns An empty set.
|
|
40284
|
+
*/
|
|
40285
|
+
function emptySet$3() {
|
|
40286
|
+
return /* @__PURE__ */ new Set();
|
|
40287
|
+
}
|
|
40288
|
+
/**
|
|
40289
|
+
* Makes the 16 records of the ring of ended timelines, once, so an end only overwrites them.
|
|
40290
|
+
*
|
|
40291
|
+
* @returns Sixteen blank records.
|
|
40292
|
+
*/
|
|
40293
|
+
function blankRing() {
|
|
40294
|
+
const ring = [];
|
|
40295
|
+
for (let index = 0; index < 16; index++) ring.push({
|
|
40296
|
+
timeline: 0,
|
|
40297
|
+
animation: "",
|
|
40298
|
+
startFrame: 0,
|
|
40299
|
+
endFrame: 0,
|
|
40300
|
+
reason: "ended"
|
|
40301
|
+
});
|
|
40302
|
+
return ring;
|
|
40303
|
+
}
|
|
40304
|
+
/**
|
|
40305
|
+
* Creates the initial anim state: an empty track table, the empty field bookkeeping of the
|
|
40306
|
+
* retarget policy and the offsets accumulator, no timeline (and a ring of 16 blank records for the
|
|
40307
|
+
* ended ones), no animation and no frame loop, and reduced motion at its configured start value.
|
|
40308
|
+
*
|
|
40309
|
+
* @param ctx - Minimal context.
|
|
40310
|
+
* @param ctx.config - Resolved plugin config.
|
|
40311
|
+
* @returns The plugin state.
|
|
40312
|
+
*/
|
|
40313
|
+
function createAnimState(ctx) {
|
|
40314
|
+
return {
|
|
40315
|
+
tracks: emptyMap$5(),
|
|
40316
|
+
trackList: [],
|
|
40317
|
+
nextId: 1,
|
|
40318
|
+
owner: emptyMap$5(),
|
|
40319
|
+
offsets: emptyMap$5(),
|
|
40320
|
+
bases: emptyMap$5(),
|
|
40321
|
+
additive: emptyMap$5(),
|
|
40322
|
+
timelines: emptyMap$5(),
|
|
40323
|
+
timelineList: [],
|
|
40324
|
+
ended: blankRing(),
|
|
40325
|
+
endedNext: 0,
|
|
40326
|
+
endedCount: 0,
|
|
40327
|
+
registry: emptyMap$5(),
|
|
40328
|
+
markListeners: emptySet$3(),
|
|
40329
|
+
frame: 0,
|
|
40330
|
+
overMaxTracks: false,
|
|
40331
|
+
reducedMotion: ctx.config.reducedMotion,
|
|
40332
|
+
removeDriver: void 0,
|
|
40333
|
+
offFrame: void 0,
|
|
40334
|
+
offPlay: void 0,
|
|
40335
|
+
finishAll: void 0,
|
|
40336
|
+
frameLoops: emptyMap$5(),
|
|
40337
|
+
framesHeld: emptyMap$5(),
|
|
40338
|
+
frameMutes: emptyMap$5(),
|
|
40339
|
+
offFrames: [],
|
|
40340
|
+
loopsHeld: void 0,
|
|
40341
|
+
warnedLoops: emptySet$3()
|
|
40342
|
+
};
|
|
40343
|
+
}
|
|
40344
|
+
//#endregion
|
|
40345
|
+
//#region src/plugins/anim/timeline/ring.ts
|
|
40346
|
+
/**
|
|
40347
|
+
* @file anim/timeline — the ring of the last 16 ended timelines and the snapshot `timelines()`
|
|
40348
|
+
* answers. The ring is written in place at every end, so an end allocates no record; the snapshot
|
|
40349
|
+
* builds new plain objects for a reader and is never on the frame path.
|
|
40350
|
+
*/
|
|
40351
|
+
/**
|
|
40352
|
+
* Writes one end into the next slot of the ring, in place, and moves the ring on. The record that
|
|
40353
|
+
* was there is overwritten, so the 17th end evicts the oldest.
|
|
40354
|
+
*
|
|
40355
|
+
* @param state - The anim state that holds the ring.
|
|
40356
|
+
* @param running - The timeline that ended.
|
|
40357
|
+
* @param reason - How it ended.
|
|
40358
|
+
*/
|
|
40359
|
+
function recordEnd(state, running, reason) {
|
|
40360
|
+
const record = state.ended[state.endedNext];
|
|
40361
|
+
if (record === void 0) return;
|
|
40362
|
+
record.timeline = running.id;
|
|
40363
|
+
record.animation = running.animation;
|
|
40364
|
+
record.startFrame = running.startFrame;
|
|
40365
|
+
record.endFrame = state.frame;
|
|
40366
|
+
record.reason = reason;
|
|
40367
|
+
state.endedNext = (state.endedNext + 1) % 16;
|
|
40368
|
+
state.endedCount = Math.min(16, state.endedCount + 1);
|
|
40369
|
+
}
|
|
40370
|
+
/**
|
|
40371
|
+
* Resets the ring to empty. The 16 records stay allocated and are reused by the next ends.
|
|
40372
|
+
*
|
|
40373
|
+
* @param state - The anim state that holds the ring.
|
|
40374
|
+
*/
|
|
40375
|
+
function resetRing(state) {
|
|
40376
|
+
state.endedNext = 0;
|
|
40377
|
+
state.endedCount = 0;
|
|
40378
|
+
}
|
|
40379
|
+
/**
|
|
40380
|
+
* Describes one running timeline for a reader: new arrays for the entities and the marks, the
|
|
40381
|
+
* slots by reference.
|
|
40382
|
+
*
|
|
40383
|
+
* @param running - The running timeline.
|
|
40384
|
+
* @returns A plain object a caller may keep.
|
|
40385
|
+
*/
|
|
40386
|
+
function infoOf(running) {
|
|
40387
|
+
return {
|
|
40388
|
+
timeline: running.id,
|
|
40389
|
+
animation: running.animation,
|
|
40390
|
+
startFrame: running.startFrame,
|
|
40391
|
+
slots: running.slots,
|
|
40392
|
+
entities: [...running.entities],
|
|
40393
|
+
marks: [...running.marks]
|
|
40394
|
+
};
|
|
40395
|
+
}
|
|
40396
|
+
/**
|
|
40397
|
+
* Reads what plays now and the ring of what ended, for `timelines()`.
|
|
40398
|
+
*
|
|
40399
|
+
* @param state - The anim state.
|
|
40400
|
+
* @returns The running timelines in start order and the ended ones, oldest first.
|
|
40401
|
+
*/
|
|
40402
|
+
function snapshotOf(state) {
|
|
40403
|
+
const running = [];
|
|
40404
|
+
for (const timeline of state.timelineList) if (!timeline.ended) running.push(infoOf(timeline));
|
|
40405
|
+
const ended = [];
|
|
40406
|
+
const first = (state.endedNext - state.endedCount + 16) % 16;
|
|
40407
|
+
for (let offset = 0; offset < state.endedCount; offset++) {
|
|
40408
|
+
const record = state.ended[(first + offset) % 16];
|
|
40409
|
+
if (record === void 0) continue;
|
|
40410
|
+
ended.push({
|
|
40411
|
+
timeline: record.timeline,
|
|
40412
|
+
animation: record.animation,
|
|
40413
|
+
startFrame: record.startFrame,
|
|
40414
|
+
endFrame: record.endFrame,
|
|
40415
|
+
reason: record.reason
|
|
40416
|
+
});
|
|
40417
|
+
}
|
|
40418
|
+
return {
|
|
40419
|
+
running,
|
|
40420
|
+
ended
|
|
40421
|
+
};
|
|
40422
|
+
}
|
|
40423
|
+
//#endregion
|
|
40248
40424
|
//#region src/plugins/anim/timeline/play.ts
|
|
40249
40425
|
/**
|
|
40250
40426
|
* @file anim/timeline — one running timeline: the bookkeeping around a cursor. It builds the step
|
|
@@ -40337,21 +40513,30 @@ function cursorCtxOf(rt, running) {
|
|
|
40337
40513
|
}
|
|
40338
40514
|
/**
|
|
40339
40515
|
* Ends one timeline exactly once: it leaves the table, `Animation` is counted down on every
|
|
40340
|
-
* entity it named, every entity it spawned is despawned,
|
|
40341
|
-
* cancelled, and `done` resolves.
|
|
40516
|
+
* entity it named, every entity it spawned is despawned, the end is written into the ring of
|
|
40517
|
+
* `timelines()`, `anim:finished` is emitted (`anim:cancelled` for a cancel), and `done` resolves.
|
|
40342
40518
|
*
|
|
40343
40519
|
* @param actx - Domain context of the anim plugin.
|
|
40344
40520
|
* @param running - The running timeline.
|
|
40345
|
-
* @param
|
|
40521
|
+
* @param reason - How it ends: its tree ran through, `finish()` ended it, or `cancel()` did.
|
|
40346
40522
|
*/
|
|
40347
|
-
function endTimeline(actx, running,
|
|
40523
|
+
function endTimeline(actx, running, reason) {
|
|
40348
40524
|
if (running.ended) return;
|
|
40349
40525
|
running.ended = true;
|
|
40350
40526
|
actx.state.timelines.delete(running.id);
|
|
40351
40527
|
for (const entity of running.entities) countPlaying(actx.deps.world.ecs, entity, -1);
|
|
40352
40528
|
for (const entity of running.spawned.values()) actx.deps.world.ecs.despawn(entity);
|
|
40353
40529
|
running.spawned.clear();
|
|
40354
|
-
|
|
40530
|
+
recordEnd(actx.state, running, reason);
|
|
40531
|
+
if (reason === "cancelled") actx.emit("anim:cancelled", {
|
|
40532
|
+
animation: running.animation,
|
|
40533
|
+
timeline: running.id
|
|
40534
|
+
});
|
|
40535
|
+
else actx.emit("anim:finished", {
|
|
40536
|
+
animation: running.animation,
|
|
40537
|
+
timeline: running.id,
|
|
40538
|
+
reason
|
|
40539
|
+
});
|
|
40355
40540
|
running.resolve();
|
|
40356
40541
|
}
|
|
40357
40542
|
/**
|
|
@@ -40402,6 +40587,8 @@ function startTimeline(actx, rt, definition, slots) {
|
|
|
40402
40587
|
const running = {
|
|
40403
40588
|
id,
|
|
40404
40589
|
animation: definition.id,
|
|
40590
|
+
slots,
|
|
40591
|
+
startFrame: actx.state.frame,
|
|
40405
40592
|
cursor,
|
|
40406
40593
|
marks,
|
|
40407
40594
|
entities,
|
|
@@ -40420,16 +40607,20 @@ function startTimeline(actx, rt, definition, slots) {
|
|
|
40420
40607
|
actx.state.timelines.set(id, running);
|
|
40421
40608
|
actx.state.timelineList.push(running);
|
|
40422
40609
|
rt.wake();
|
|
40610
|
+
actx.emit("anim:started", {
|
|
40611
|
+
animation: definition.id,
|
|
40612
|
+
timeline: id
|
|
40613
|
+
});
|
|
40423
40614
|
return {
|
|
40424
40615
|
finish: () => {
|
|
40425
40616
|
if (running.ended) return;
|
|
40426
40617
|
finishCursor(cursorCtxOf(rt, running), cursor);
|
|
40427
|
-
endTimeline(actx, running,
|
|
40618
|
+
endTimeline(actx, running, "finished");
|
|
40428
40619
|
},
|
|
40429
40620
|
cancel: () => {
|
|
40430
40621
|
if (running.ended) return;
|
|
40431
40622
|
cancelCursor(cursorCtxOf(rt, running), cursor);
|
|
40432
|
-
endTimeline(actx, running,
|
|
40623
|
+
endTimeline(actx, running, "cancelled");
|
|
40433
40624
|
},
|
|
40434
40625
|
active: () => !running.ended,
|
|
40435
40626
|
done,
|
|
@@ -40450,7 +40641,7 @@ function advanceTimelines(actx, rt, deltaMs) {
|
|
|
40450
40641
|
const running = list[index];
|
|
40451
40642
|
if (running === void 0 || running.ended) continue;
|
|
40452
40643
|
advanceCursor(cursorCtxOf(rt, running), running.cursor, deltaMs);
|
|
40453
|
-
if (running.cursor.ended) endTimeline(actx, running,
|
|
40644
|
+
if (running.cursor.ended) endTimeline(actx, running, "ended");
|
|
40454
40645
|
}
|
|
40455
40646
|
dropEnded(list);
|
|
40456
40647
|
}
|
|
@@ -40468,7 +40659,7 @@ function finishAllTimelines(actx, rt) {
|
|
|
40468
40659
|
const running = list[index];
|
|
40469
40660
|
if (running === void 0 || running.ended) continue;
|
|
40470
40661
|
finishCursor(cursorCtxOf(rt, running), running.cursor);
|
|
40471
|
-
endTimeline(actx, running,
|
|
40662
|
+
endTimeline(actx, running, "finished");
|
|
40472
40663
|
}
|
|
40473
40664
|
dropEnded(list);
|
|
40474
40665
|
}
|
|
@@ -41871,6 +42062,7 @@ function stopAnim(state) {
|
|
|
41871
42062
|
state.additive.clear();
|
|
41872
42063
|
state.timelines.clear();
|
|
41873
42064
|
state.timelineList.length = 0;
|
|
42065
|
+
resetRing(state);
|
|
41874
42066
|
state.registry.clear();
|
|
41875
42067
|
state.markListeners.clear();
|
|
41876
42068
|
state.overMaxTracks = false;
|
|
@@ -41883,7 +42075,7 @@ function stopAnim(state) {
|
|
|
41883
42075
|
* from a node are the same timeline.
|
|
41884
42076
|
*/
|
|
41885
42077
|
/**
|
|
41886
|
-
* Creates the anim API: `app.anim.play`, `finishAll`, `active`, `onMark`, `reducedMotion`,
|
|
42078
|
+
* Creates the anim API: `app.anim.play`, `finishAll`, `active`, `timelines`, `onMark`, `reducedMotion`,
|
|
41887
42079
|
* `setReducedMotion` and `replace`.
|
|
41888
42080
|
*
|
|
41889
42081
|
* @param ctx - Kernel context of the anim plugin.
|
|
@@ -41896,6 +42088,7 @@ function createAnimApi(ctx) {
|
|
|
41896
42088
|
play: (animation, slots) => startTimeline(actx, rt, animation, slots),
|
|
41897
42089
|
finishAll: () => finishAllAnim(actx, rt),
|
|
41898
42090
|
active: () => actx.state.tracks.size,
|
|
42091
|
+
timelines: () => snapshotOf(actx.state),
|
|
41899
42092
|
onMark: (fn) => {
|
|
41900
42093
|
actx.state.markListeners.add(fn);
|
|
41901
42094
|
return () => {
|
|
@@ -41912,62 +42105,6 @@ function createAnimApi(ctx) {
|
|
|
41912
42105
|
}
|
|
41913
42106
|
};
|
|
41914
42107
|
}
|
|
41915
|
-
//#endregion
|
|
41916
|
-
//#region src/plugins/anim/state.ts
|
|
41917
|
-
/**
|
|
41918
|
-
* Creates one empty table. It lives in its own non-exported function because lint rule L5 refuses
|
|
41919
|
-
* a collection built inside an exported declaration.
|
|
41920
|
-
*
|
|
41921
|
-
* @returns An empty map.
|
|
41922
|
-
*/
|
|
41923
|
-
function emptyMap$5() {
|
|
41924
|
-
return /* @__PURE__ */ new Map();
|
|
41925
|
-
}
|
|
41926
|
-
/**
|
|
41927
|
-
* Creates the empty listener set of `onMark`, for the same reason as `emptyMap`.
|
|
41928
|
-
*
|
|
41929
|
-
* @returns An empty set.
|
|
41930
|
-
*/
|
|
41931
|
-
function emptySet$3() {
|
|
41932
|
-
return /* @__PURE__ */ new Set();
|
|
41933
|
-
}
|
|
41934
|
-
/**
|
|
41935
|
-
* Creates the initial anim state: an empty track table, the empty field bookkeeping of the
|
|
41936
|
-
* retarget policy and the offsets accumulator, no timeline, no animation and no frame loop, and
|
|
41937
|
-
* reduced motion at its configured start value.
|
|
41938
|
-
*
|
|
41939
|
-
* @param ctx - Minimal context.
|
|
41940
|
-
* @param ctx.config - Resolved plugin config.
|
|
41941
|
-
* @returns The plugin state.
|
|
41942
|
-
*/
|
|
41943
|
-
function createAnimState(ctx) {
|
|
41944
|
-
return {
|
|
41945
|
-
tracks: emptyMap$5(),
|
|
41946
|
-
trackList: [],
|
|
41947
|
-
nextId: 1,
|
|
41948
|
-
owner: emptyMap$5(),
|
|
41949
|
-
offsets: emptyMap$5(),
|
|
41950
|
-
bases: emptyMap$5(),
|
|
41951
|
-
additive: emptyMap$5(),
|
|
41952
|
-
timelines: emptyMap$5(),
|
|
41953
|
-
timelineList: [],
|
|
41954
|
-
registry: emptyMap$5(),
|
|
41955
|
-
markListeners: emptySet$3(),
|
|
41956
|
-
frame: 0,
|
|
41957
|
-
overMaxTracks: false,
|
|
41958
|
-
reducedMotion: ctx.config.reducedMotion,
|
|
41959
|
-
removeDriver: void 0,
|
|
41960
|
-
offFrame: void 0,
|
|
41961
|
-
offPlay: void 0,
|
|
41962
|
-
finishAll: void 0,
|
|
41963
|
-
frameLoops: emptyMap$5(),
|
|
41964
|
-
framesHeld: emptyMap$5(),
|
|
41965
|
-
frameMutes: emptyMap$5(),
|
|
41966
|
-
offFrames: [],
|
|
41967
|
-
loopsHeld: void 0,
|
|
41968
|
-
warnedLoops: emptySet$3()
|
|
41969
|
-
};
|
|
41970
|
-
}
|
|
41971
42108
|
/**
|
|
41972
42109
|
* Anim plugin: `app.anim.play(animation, slots)`, `app.anim.finishAll()`,
|
|
41973
42110
|
* `app.anim.setReducedMotion(on)`.
|
|
@@ -42002,7 +42139,9 @@ const animPlugin = /*#__PURE__*/ createPlugin$1("anim", {
|
|
|
42002
42139
|
},
|
|
42003
42140
|
events: (register) => register.map({
|
|
42004
42141
|
"anim:mark": "A mark of a timeline was reached",
|
|
42005
|
-
"anim:
|
|
42142
|
+
"anim:started": "A timeline started",
|
|
42143
|
+
"anim:cancelled": "A timeline was cancelled",
|
|
42144
|
+
"anim:finished": "A timeline ended by itself or was finished early"
|
|
42006
42145
|
}),
|
|
42007
42146
|
createState: createAnimState,
|
|
42008
42147
|
api: createAnimApi,
|
|
@@ -43273,7 +43412,8 @@ function bundleKeys(state, bundle) {
|
|
|
43273
43412
|
}
|
|
43274
43413
|
/**
|
|
43275
43414
|
* Tells whether the budget must leave a loaded bundle alone by the state alone: pinned, permanent, named by the
|
|
43276
|
-
* mounted, a leaving or the coming scene, in the preload queue, held after a reload,
|
|
43415
|
+
* mounted, a leaving or the coming scene, in the preload queue, held after a reload, rested on through `ready`, or the
|
|
43416
|
+
* `except` of the pass.
|
|
43277
43417
|
*
|
|
43278
43418
|
* @param state - The plugin state.
|
|
43279
43419
|
* @param name - Name of the bundle.
|
|
@@ -43282,12 +43422,12 @@ function bundleKeys(state, bundle) {
|
|
|
43282
43422
|
* @returns True when it may not go.
|
|
43283
43423
|
*/
|
|
43284
43424
|
function keptByState(state, name, entry, except) {
|
|
43285
|
-
return name === except || state.pinned.has(name) || isPermanent(entry.tier) || state.reloadHeld.has(name) || state.sceneNamed.includes(name) || state.sceneLeaving.includes(name) || state.sceneComing.includes(name) || state.queue?.bundles.includes(name) === true;
|
|
43425
|
+
return name === except || state.pinned.has(name) || isPermanent(entry.tier) || state.reloadHeld.has(name) || state.readyWaiting.has(name) || state.sceneNamed.includes(name) || state.sceneLeaving.includes(name) || state.sceneComing.includes(name) || state.queue?.bundles.includes(name) === true;
|
|
43286
43426
|
}
|
|
43287
43427
|
/**
|
|
43288
43428
|
* Picks the bundle that leaves next: the loaded one with the smallest use counter that is not
|
|
43289
43429
|
* pinned, not named by the mounted, a leaving or the coming scene, not permanent, not in the preload queue, not held
|
|
43290
|
-
* after a reload, not `except` and drawn by no view (`renderer.sync.textures.used`, asked last: it walks the keys).
|
|
43430
|
+
* after a reload, not rested on through `ready`, not `except` and drawn by no view (`renderer.sync.textures.used`, asked last: it walks the keys).
|
|
43291
43431
|
* Its `release` is not read: a `"leave"` bundle is a candidate like any other.
|
|
43292
43432
|
*
|
|
43293
43433
|
* @param ctx - Domain context of the plugin.
|
|
@@ -43478,7 +43618,8 @@ function featuresOnStack(ctx) {
|
|
|
43478
43618
|
* Tells whether a bundle must stay where the game stands now: it is pinned (a bundle of the node
|
|
43479
43619
|
* entered last), the mounted scene names it (the last list `sceneBundles` received), the scene
|
|
43480
43620
|
* being built names it (the last list `sceneComing` received), a leaving scene named it and its
|
|
43481
|
-
* elements still play their exit,
|
|
43621
|
+
* elements still play their exit, a node rests on it through `ready` (F190), its feature is in
|
|
43622
|
+
* `onStack`, or its tier is permanent.
|
|
43482
43623
|
*
|
|
43483
43624
|
* @param ctx - Domain context of the plugin.
|
|
43484
43625
|
* @param name - Name of the bundle.
|
|
@@ -43488,7 +43629,7 @@ function featuresOnStack(ctx) {
|
|
|
43488
43629
|
*/
|
|
43489
43630
|
function isHeld$1(ctx, name, entry, onStack) {
|
|
43490
43631
|
const state = ctx.state;
|
|
43491
|
-
return state.pinned.has(name) || state.sceneNamed.includes(name) || state.sceneLeaving.includes(name) || state.sceneComing.includes(name) || onStack.has(entry.feature) || isPermanent(entry.tier);
|
|
43632
|
+
return state.pinned.has(name) || state.sceneNamed.includes(name) || state.sceneLeaving.includes(name) || state.sceneComing.includes(name) || state.readyWaiting.has(name) || onStack.has(entry.feature) || isPermanent(entry.tier);
|
|
43492
43633
|
}
|
|
43493
43634
|
/**
|
|
43494
43635
|
* Unloads every loaded `"leave"` bundle nobody holds any more, with the reason `"leave"`. A
|
|
@@ -44139,11 +44280,27 @@ async function warmForReady(ctx, bundle) {
|
|
|
44139
44280
|
}
|
|
44140
44281
|
}
|
|
44141
44282
|
/**
|
|
44283
|
+
* Ages the bundles nodes rest on through `ready` by one live rest (F190). The rest a node waits on
|
|
44284
|
+
* is the first: the bundle stays held through it, so the node that asks again finds it. A bundle
|
|
44285
|
+
* no `ready` asked for again by its second rest is let go, because the node it was asked for was
|
|
44286
|
+
* left another way (Back): from then on the budget and the `"leave"` release may take it again.
|
|
44287
|
+
* Called by the `flow:rest` hook of a live rest, before its budget pass.
|
|
44288
|
+
*
|
|
44289
|
+
* @param state - The plugin state.
|
|
44290
|
+
*/
|
|
44291
|
+
function ageReadyWaiting(state) {
|
|
44292
|
+
for (const [name, rests] of state.readyWaiting) if (rests >= 1) state.readyWaiting.delete(name);
|
|
44293
|
+
else state.readyWaiting.set(name, rests + 1);
|
|
44294
|
+
}
|
|
44295
|
+
/**
|
|
44142
44296
|
* The handler of the `ready` effect (F52). Headless it answers `true` before any name check, as the
|
|
44143
44297
|
* `load` effect does. Every bundle there: `true`, and nothing is posted. Otherwise it starts the
|
|
44144
44298
|
* warm of each bundle that is not there, answers `false`, and posts `{ type: "ready" }` into
|
|
44145
44299
|
* `flow.inbox` once all of them settled. The posting does not wait on the node's signal: the warm
|
|
44146
|
-
* is shared work, and the inbox keeps only the latest `ready`.
|
|
44300
|
+
* is shared work, and the inbox keeps only the latest `ready`. A bundle it answers `false` for is
|
|
44301
|
+
* rested on (`readyWaiting`) until a `ready` finds it there: neither the budget nor the `"leave"`
|
|
44302
|
+
* release of the rest in between takes it, else the node that asks again finds it gone and the two
|
|
44303
|
+
* nodes cycle forever (F190). `ageReadyWaiting` ends the hold of one nobody asks for again.
|
|
44147
44304
|
*
|
|
44148
44305
|
* @param ctx - Domain context of the plugin.
|
|
44149
44306
|
* @param bundles - The bundle names of the descriptor.
|
|
@@ -44155,6 +44312,8 @@ function answerReady(ctx, bundles) {
|
|
|
44155
44312
|
if (state.io === void 0) return true;
|
|
44156
44313
|
for (const name of bundles) if (state.manifest.bundles[name] === void 0) throw unknownBundle(name);
|
|
44157
44314
|
const missing = bundles.filter((name) => !isThere(state, name));
|
|
44315
|
+
for (const name of bundles) if (missing.includes(name)) state.readyWaiting.set(name, 0);
|
|
44316
|
+
else state.readyWaiting.delete(name);
|
|
44158
44317
|
if (missing.length === 0) return true;
|
|
44159
44318
|
Promise.all(missing.map((name) => warmForReady(ctx, name))).then(() => ctx.deps.flow.inbox.post({ type: "ready" }));
|
|
44160
44319
|
return false;
|
|
@@ -44389,6 +44548,7 @@ function releaseAll(state) {
|
|
|
44389
44548
|
state.keysOf.clear();
|
|
44390
44549
|
state.budgetUnloaded.clear();
|
|
44391
44550
|
state.reloadHeld.clear();
|
|
44551
|
+
state.readyWaiting.clear();
|
|
44392
44552
|
state.thrashWarned.clear();
|
|
44393
44553
|
state.scenes.clear();
|
|
44394
44554
|
state.featureOfFlow.clear();
|
|
@@ -45174,6 +45334,7 @@ function createHandlers$5(ctx, reload) {
|
|
|
45174
45334
|
if (live) {
|
|
45175
45335
|
assets.state.restPending = true;
|
|
45176
45336
|
assets.state.restedLive = true;
|
|
45337
|
+
ageReadyWaiting(assets.state);
|
|
45177
45338
|
}
|
|
45178
45339
|
assets.state.budgetUnloaded.clear();
|
|
45179
45340
|
enforceBudget(assets);
|
|
@@ -45236,6 +45397,7 @@ function createAssetsState() {
|
|
|
45236
45397
|
keysOf: emptyMap$3(),
|
|
45237
45398
|
budgetUnloaded: emptySet$2(),
|
|
45238
45399
|
reloadHeld: emptySet$2(),
|
|
45400
|
+
readyWaiting: emptyMap$3(),
|
|
45239
45401
|
thrashWarned: emptySet$2(),
|
|
45240
45402
|
scenes: emptyMap$3(),
|
|
45241
45403
|
featureOfFlow: emptyMap$3(),
|
|
@@ -65205,9 +65367,47 @@ function textStyleOf(element, shownStyleOf) {
|
|
|
65205
65367
|
return namedKeyOf(element.style, element.node.props.style);
|
|
65206
65368
|
}
|
|
65207
65369
|
/**
|
|
65370
|
+
* The id of the motion an element was given: the `id` of its `motion` prop when that is an object
|
|
65371
|
+
* with a string `id`, which `defineMotion({ id })` sets.
|
|
65372
|
+
*
|
|
65373
|
+
* @param element - The element to read.
|
|
65374
|
+
* @returns The id, or `undefined` for an element without a motion and for a motion without an id.
|
|
65375
|
+
*/
|
|
65376
|
+
function motionIdOf(element) {
|
|
65377
|
+
const motion = element.node.props.motion;
|
|
65378
|
+
if (typeof motion !== "object" || motion === null) return void 0;
|
|
65379
|
+
return "id" in motion && typeof motion.id === "string" ? motion.id : void 0;
|
|
65380
|
+
}
|
|
65381
|
+
/**
|
|
65382
|
+
* Where a scroll stands and how it rests: the values `ScrollState` carries (the offset in whole
|
|
65383
|
+
* units, `max`, whether it moves), all 0 and false until the first solve placed it, with its axis
|
|
65384
|
+
* and the stops of its `snap` prop a release would use.
|
|
65385
|
+
*
|
|
65386
|
+
* @param element - The element to read.
|
|
65387
|
+
* @param stopsOf - Reads the stops of a `snap` prop; none in a read without a layout, which leaves `snap` out.
|
|
65388
|
+
* @returns The scroll record, or `undefined` for an element that is no scroll.
|
|
65389
|
+
*/
|
|
65390
|
+
function scrollOf(element, stopsOf) {
|
|
65391
|
+
const motion = element.scroll;
|
|
65392
|
+
if (motion === void 0) return void 0;
|
|
65393
|
+
const max = motion.placed ? motion.max : 0;
|
|
65394
|
+
const shown = {
|
|
65395
|
+
axis: motion.axis,
|
|
65396
|
+
offset: motion.placed ? Math.round(motion.offset) : 0,
|
|
65397
|
+
max,
|
|
65398
|
+
moving: motion.placed && motion.mode !== "still"
|
|
65399
|
+
};
|
|
65400
|
+
const snap = stopsOf?.(element.node.props.snap, max);
|
|
65401
|
+
return snap === void 0 ? shown : {
|
|
65402
|
+
...shown,
|
|
65403
|
+
snap
|
|
65404
|
+
};
|
|
65405
|
+
}
|
|
65406
|
+
/**
|
|
65208
65407
|
* Turns one element and its subtree into snapshot nodes. The rect is natural; a fitted element
|
|
65209
65408
|
* adds the scale it is drawn at; a text adds the words it draws and the style key of a keyed
|
|
65210
|
-
* text; a text field adds its value; a windowed scroll adds its window
|
|
65409
|
+
* text; a text field adds its value; a windowed scroll adds its window; an element with a
|
|
65410
|
+
* motion id adds it, a scroll adds where it stands and its snap stops. The spacers of a windowed
|
|
65211
65411
|
* scroll are left out: its content lists the live rows. The rects of a root laid out in a slot are
|
|
65212
65412
|
* in the slot's units: `place` maps them into root coordinates.
|
|
65213
65413
|
*
|
|
@@ -65215,14 +65415,15 @@ function textStyleOf(element, shownStyleOf) {
|
|
|
65215
65415
|
* @param element - The element to read.
|
|
65216
65416
|
* @param resolvedOf - Reads the resolved string of a text entity; none in a read without a world.
|
|
65217
65417
|
* @param shownStyleOf - Reads `Text.style` of a text entity; none in a read without a world.
|
|
65418
|
+
* @param stopsOf - Reads the stops of a `snap` prop; none in a read without a layout.
|
|
65218
65419
|
* @param place - Maps a rect of a slotted root into root coordinates; none for a root on the viewport.
|
|
65219
65420
|
* @returns The node, with its children in child order.
|
|
65220
65421
|
*/
|
|
65221
|
-
function nodeOf(state, element, resolvedOf, shownStyleOf, place) {
|
|
65422
|
+
function nodeOf(state, element, resolvedOf, shownStyleOf, stopsOf, place) {
|
|
65222
65423
|
const children = [];
|
|
65223
65424
|
for (const child of element.children) {
|
|
65224
65425
|
const childElement = state.elements.get(child);
|
|
65225
|
-
if (childElement !== void 0 && !isOwnKey(childElement.key)) children.push(nodeOf(state, childElement, resolvedOf, shownStyleOf, place));
|
|
65426
|
+
if (childElement !== void 0 && !isOwnKey(childElement.key)) children.push(nodeOf(state, childElement, resolvedOf, shownStyleOf, stopsOf, place));
|
|
65226
65427
|
}
|
|
65227
65428
|
const node = {
|
|
65228
65429
|
key: element.key,
|
|
@@ -65261,10 +65462,20 @@ function nodeOf(state, element, resolvedOf, shownStyleOf, place) {
|
|
|
65261
65462
|
}
|
|
65262
65463
|
};
|
|
65263
65464
|
const local = element.instance === void 0 ? void 0 : state.instances.get(element.instance)?.local;
|
|
65264
|
-
|
|
65465
|
+
const located = local === void 0 ? windowed : {
|
|
65265
65466
|
...windowed,
|
|
65266
65467
|
local: { ...local }
|
|
65267
65468
|
};
|
|
65469
|
+
const motion = motionIdOf(element);
|
|
65470
|
+
const motioned = motion === void 0 ? located : {
|
|
65471
|
+
...located,
|
|
65472
|
+
motion
|
|
65473
|
+
};
|
|
65474
|
+
const scroll = scrollOf(element, stopsOf);
|
|
65475
|
+
return scroll === void 0 ? motioned : {
|
|
65476
|
+
...motioned,
|
|
65477
|
+
scroll
|
|
65478
|
+
};
|
|
65268
65479
|
}
|
|
65269
65480
|
/**
|
|
65270
65481
|
* Every mounted root in the order a reader meets them: the popup roots first, the highest `Order`
|
|
@@ -65317,17 +65528,18 @@ function placeOf(root, slotPose) {
|
|
|
65317
65528
|
* @param slotPose - The root pose of a slot, `rootPoseOf` of `renderer`; none in a read without a world.
|
|
65318
65529
|
* @param isAside - Whether an entity belongs to the scene `world` builds aside: such a root is not read.
|
|
65319
65530
|
* @param shownStyleOf - Reads `Text.style` of an entity; none in a read without a world.
|
|
65531
|
+
* @param stopsOf - `stopsOf` of the layout module, which clamps the `snap` stops of a scroll; none in a read without a layout.
|
|
65320
65532
|
* @returns One root node, or every root under a `screen` node.
|
|
65321
65533
|
* @example
|
|
65322
65534
|
* ```ts
|
|
65323
65535
|
* readTree({ roots: new Map(), elements: new Map() } as unknown as JsxState).type; // "screen"
|
|
65324
65536
|
* ```
|
|
65325
65537
|
*/
|
|
65326
|
-
function readTree(state, layers = [], resolvedOf, slotPose, isAside, shownStyleOf) {
|
|
65538
|
+
function readTree(state, layers = [], resolvedOf, slotPose, isAside, shownStyleOf, stopsOf) {
|
|
65327
65539
|
const nodes = [];
|
|
65328
65540
|
for (const root of sortedRoots(state, layers, isAside)) {
|
|
65329
65541
|
const element = root.element === void 0 ? void 0 : state.elements.get(root.element);
|
|
65330
|
-
if (element !== void 0) nodes.push(nodeOf(state, element, resolvedOf, shownStyleOf, placeOf(root, slotPose)));
|
|
65542
|
+
if (element !== void 0) nodes.push(nodeOf(state, element, resolvedOf, shownStyleOf, stopsOf, placeOf(root, slotPose)));
|
|
65331
65543
|
}
|
|
65332
65544
|
const single = nodes.length === 1 ? nodes[0] : void 0;
|
|
65333
65545
|
if (single !== void 0) return single;
|
|
@@ -66054,6 +66266,21 @@ function reducedOption(reduced) {
|
|
|
66054
66266
|
return reduced === "keep" ? { reduced } : {};
|
|
66055
66267
|
}
|
|
66056
66268
|
/**
|
|
66269
|
+
* The `label` field of the options a motion starts a track with: written only when the motion has
|
|
66270
|
+
* an id, so a motion without one starts its tracks with the options it always had.
|
|
66271
|
+
*
|
|
66272
|
+
* @param label - The label `defineMotion` built from its id, or `undefined`.
|
|
66273
|
+
* @returns `{ label }`, or an empty object.
|
|
66274
|
+
* @example
|
|
66275
|
+
* ```ts
|
|
66276
|
+
* labelOption("hud.card.enter"); // { label: "hud.card.enter" }
|
|
66277
|
+
* labelOption(undefined); // {}
|
|
66278
|
+
* ```
|
|
66279
|
+
*/
|
|
66280
|
+
function labelOption(label) {
|
|
66281
|
+
return label === void 0 ? {} : { label };
|
|
66282
|
+
}
|
|
66283
|
+
/**
|
|
66057
66284
|
* Checks one keyframe track at definition time: it has a key, every `at` lies in 0..1 and each
|
|
66058
66285
|
* key comes after the one before.
|
|
66059
66286
|
*
|
|
@@ -66246,9 +66473,10 @@ function lastValues(segments) {
|
|
|
66246
66473
|
* @param keys - The keys of the track.
|
|
66247
66474
|
* @param ms - The length of the whole track.
|
|
66248
66475
|
* @param reduced - What reduced motion does to the walk.
|
|
66476
|
+
* @param label - The label of the track, when the motion has an id.
|
|
66249
66477
|
* @returns The motion, or `undefined` when no key names the lane.
|
|
66250
66478
|
*/
|
|
66251
|
-
function enterLane(view, lane, keys, ms, reduced) {
|
|
66479
|
+
function enterLane(view, lane, keys, ms, reduced, label) {
|
|
66252
66480
|
const segments = segmentsOf(lane, keys);
|
|
66253
66481
|
const named = lastValues(segments);
|
|
66254
66482
|
const rest = {};
|
|
@@ -66268,7 +66496,8 @@ function enterLane(view, lane, keys, ms, reduced) {
|
|
|
66268
66496
|
ms,
|
|
66269
66497
|
ease: KEY_EASE,
|
|
66270
66498
|
segments,
|
|
66271
|
-
...reducedOption(reduced)
|
|
66499
|
+
...reducedOption(reduced),
|
|
66500
|
+
...labelOption(label)
|
|
66272
66501
|
});
|
|
66273
66502
|
}
|
|
66274
66503
|
/**
|
|
@@ -66280,9 +66509,10 @@ function enterLane(view, lane, keys, ms, reduced) {
|
|
|
66280
66509
|
* @param keys - The keys of the track.
|
|
66281
66510
|
* @param ms - The length of the whole track.
|
|
66282
66511
|
* @param reduced - What reduced motion does to the walk.
|
|
66512
|
+
* @param label - The label of the track, when the motion has an id.
|
|
66283
66513
|
* @returns The motion, or `undefined` when no key names the lane.
|
|
66284
66514
|
*/
|
|
66285
|
-
function exitLane(view, lane, keys, ms, reduced) {
|
|
66515
|
+
function exitLane(view, lane, keys, ms, reduced, label) {
|
|
66286
66516
|
const segments = segmentsOf(lane, keys);
|
|
66287
66517
|
const target = lastValues(segments);
|
|
66288
66518
|
if (Object.keys(target).length === 0) return void 0;
|
|
@@ -66290,7 +66520,8 @@ function exitLane(view, lane, keys, ms, reduced) {
|
|
|
66290
66520
|
ms,
|
|
66291
66521
|
ease: KEY_EASE,
|
|
66292
66522
|
segments,
|
|
66293
|
-
...reducedOption(reduced)
|
|
66523
|
+
...reducedOption(reduced),
|
|
66524
|
+
...labelOption(label)
|
|
66294
66525
|
});
|
|
66295
66526
|
}
|
|
66296
66527
|
/**
|
|
@@ -66351,9 +66582,10 @@ function loopLanesOf(view) {
|
|
|
66351
66582
|
* @param keys - The checked keys of the loop.
|
|
66352
66583
|
* @param ms - The length of one cycle.
|
|
66353
66584
|
* @param reduced - Whether reduced motion holds the loop on its first key or lets it walk.
|
|
66585
|
+
* @param label - The label of the track, when the motion has an id.
|
|
66354
66586
|
* @returns The handle of the walk, or `undefined` when the lane moves nothing.
|
|
66355
66587
|
*/
|
|
66356
|
-
function loopLane(view, lane, keys, ms, reduced) {
|
|
66588
|
+
function loopLane(view, lane, keys, ms, reduced, label) {
|
|
66357
66589
|
const segments = segmentsOf(lane, keys);
|
|
66358
66590
|
const target = lastValues(segments);
|
|
66359
66591
|
const first = segments[0];
|
|
@@ -66368,7 +66600,8 @@ function loopLane(view, lane, keys, ms, reduced) {
|
|
|
66368
66600
|
additive: true,
|
|
66369
66601
|
repeat: "forever",
|
|
66370
66602
|
segments,
|
|
66371
|
-
...reducedOption(reduced)
|
|
66603
|
+
...reducedOption(reduced),
|
|
66604
|
+
...labelOption(label)
|
|
66372
66605
|
});
|
|
66373
66606
|
}
|
|
66374
66607
|
/**
|
|
@@ -66381,12 +66614,13 @@ function loopLane(view, lane, keys, ms, reduced) {
|
|
|
66381
66614
|
* @param ms - The length of one cycle: `loop.ms`, or `transition.ms` when it is left out.
|
|
66382
66615
|
* @param reduced - `loop.reduced`: `"cut"` holds the loop on its first key under reduced motion,
|
|
66383
66616
|
* `"keep"` lets it walk.
|
|
66617
|
+
* @param label - The label every walk carries (`<id>.loop`), when the motion has an id.
|
|
66384
66618
|
* @returns One motion over every walk; it never ends on its own.
|
|
66385
66619
|
*/
|
|
66386
|
-
function playLoop(view, keys, ms, reduced) {
|
|
66620
|
+
function playLoop(view, keys, ms, reduced, label) {
|
|
66387
66621
|
const walks = [];
|
|
66388
66622
|
for (const lane of loopLanesOf(view)) {
|
|
66389
|
-
const walk = loopLane(view, lane, keys, ms, reduced);
|
|
66623
|
+
const walk = loopLane(view, lane, keys, ms, reduced, label);
|
|
66390
66624
|
if (walk !== void 0) walks.push(walk);
|
|
66391
66625
|
}
|
|
66392
66626
|
return view.all(walks);
|
|
@@ -66400,11 +66634,12 @@ function playLoop(view, keys, ms, reduced) {
|
|
|
66400
66634
|
* @param direction - `"enter"` walks first key → rest, `"exit"` walks rest → last key.
|
|
66401
66635
|
* @param reduced - `transition.reduced`: `"cut"` lands the walk at once under reduced motion,
|
|
66402
66636
|
* `"keep"` plays it at its length.
|
|
66637
|
+
* @param label - The label every walk carries (`<id>.enter` or `<id>.exit`), when the motion has an id.
|
|
66403
66638
|
* @returns One motion over every lane.
|
|
66404
66639
|
*/
|
|
66405
|
-
function playKeyframes(view, keys, ms, direction, reduced) {
|
|
66640
|
+
function playKeyframes(view, keys, ms, direction, reduced, label) {
|
|
66406
66641
|
const walk = direction === "enter" ? enterLane : exitLane;
|
|
66407
|
-
return view.all(lanesOf(view).map((lane) => walk(view, lane, keys, ms, reduced)));
|
|
66642
|
+
return view.all(lanesOf(view).map((lane) => walk(view, lane, keys, ms, reduced, label)));
|
|
66408
66643
|
}
|
|
66409
66644
|
//#endregion
|
|
66410
66645
|
//#region src/plugins/anim/motion.ts
|
|
@@ -66500,6 +66735,18 @@ function checkChoices(spec) {
|
|
|
66500
66735
|
}
|
|
66501
66736
|
}
|
|
66502
66737
|
/**
|
|
66738
|
+
* Checks the `id` of a motion: absent, or a string with a character in it. A plain JavaScript
|
|
66739
|
+
* caller can pass any value.
|
|
66740
|
+
*
|
|
66741
|
+
* @param spec - What `defineMotion` was given.
|
|
66742
|
+
* @throws {Error} When `id` is given and is not a non-empty string.
|
|
66743
|
+
*/
|
|
66744
|
+
function checkId(spec) {
|
|
66745
|
+
const id = spec.id;
|
|
66746
|
+
if (id === void 0 || typeof id === "string" && id !== "") return;
|
|
66747
|
+
throw new Error("[game] defineMotion: id must be a non-empty string.\n Give the motion an id such as \"hud.card\", or leave it out.");
|
|
66748
|
+
}
|
|
66749
|
+
/**
|
|
66503
66750
|
* Checks a motion at definition time: every keyframe track, no name that is both a state and a
|
|
66504
66751
|
* track, an `on.enter` / `on.exit` that names one of them, and the words of `when` and `reduced`.
|
|
66505
66752
|
*
|
|
@@ -66507,6 +66754,7 @@ function checkChoices(spec) {
|
|
|
66507
66754
|
* @throws {Error} With the name or the value at fault, in the house format.
|
|
66508
66755
|
*/
|
|
66509
66756
|
function checkMotion$1(spec) {
|
|
66757
|
+
checkId(spec);
|
|
66510
66758
|
checkChoices(spec);
|
|
66511
66759
|
for (const [name, keys] of Object.entries(spec.keyframes ?? {})) {
|
|
66512
66760
|
checkTrack(name, keys);
|
|
@@ -66521,20 +66769,41 @@ function checkMotion$1(spec) {
|
|
|
66521
66769
|
}
|
|
66522
66770
|
}
|
|
66523
66771
|
/**
|
|
66772
|
+
* Builds the labels of a motion from its id.
|
|
66773
|
+
*
|
|
66774
|
+
* @param id - The id of the motion, if it has one.
|
|
66775
|
+
* @returns The four labels, or `undefined` for a motion without an id.
|
|
66776
|
+
* @example
|
|
66777
|
+
* ```ts
|
|
66778
|
+
* labelsOf("hud.card")?.enter; // "hud.card.enter"
|
|
66779
|
+
* labelsOf(undefined); // undefined
|
|
66780
|
+
* ```
|
|
66781
|
+
*/
|
|
66782
|
+
function labelsOf(id) {
|
|
66783
|
+
if (id === void 0) return void 0;
|
|
66784
|
+
return {
|
|
66785
|
+
enter: `${id}.enter`,
|
|
66786
|
+
exit: `${id}.exit`,
|
|
66787
|
+
loop: `${id}.loop`,
|
|
66788
|
+
change: `${id}.change`
|
|
66789
|
+
};
|
|
66790
|
+
}
|
|
66791
|
+
/**
|
|
66524
66792
|
* What plays the name `on` gave a hook: a state is reached with tweens, a keyframe track is walked.
|
|
66525
66793
|
*
|
|
66526
66794
|
* @param spec - What `defineMotion` was given, already checked.
|
|
66527
66795
|
* @param hook - Which hook to build.
|
|
66528
66796
|
* @param transition - The resolved transition.
|
|
66797
|
+
* @param label - The label of the hook's tracks, when the motion has an id.
|
|
66529
66798
|
* @returns The player, or `undefined` when `on` names nothing for it.
|
|
66530
66799
|
*/
|
|
66531
|
-
function playerOf(spec, hook, transition) {
|
|
66800
|
+
function playerOf(spec, hook, transition, label) {
|
|
66532
66801
|
const name = spec.on[hook];
|
|
66533
66802
|
if (name === void 0) return void 0;
|
|
66534
66803
|
const state = ownEntry(spec.states, name);
|
|
66535
|
-
if (state !== void 0) return hook === "enter" ? (view) => playEnter(view, state, transition) : (view) => playExit(view, state, transition);
|
|
66804
|
+
if (state !== void 0) return hook === "enter" ? (view) => playEnter(view, state, transition, label) : (view) => playExit(view, state, transition, label);
|
|
66536
66805
|
const keys = ownEntry(spec.keyframes, name);
|
|
66537
|
-
return keys === void 0 ? void 0 : (view) => playKeyframes(view, keys, transition.ms, hook, transition.reduced);
|
|
66806
|
+
return keys === void 0 ? void 0 : (view) => playKeyframes(view, keys, transition.ms, hook, transition.reduced, label);
|
|
66538
66807
|
}
|
|
66539
66808
|
/**
|
|
66540
66809
|
* Builds the enter or exit hook for the name `on` gave it. A motion that plays only for changes
|
|
@@ -66545,10 +66814,11 @@ function playerOf(spec, hook, transition) {
|
|
|
66545
66814
|
* @param hook - Which hook to build.
|
|
66546
66815
|
* @param transition - The resolved transition.
|
|
66547
66816
|
* @param when - When the hook plays.
|
|
66817
|
+
* @param label - The label of the hook's tracks, when the motion has an id.
|
|
66548
66818
|
* @returns The hook, or `undefined` when `on` names nothing for it.
|
|
66549
66819
|
*/
|
|
66550
|
-
function hookOf(spec, hook, transition, when) {
|
|
66551
|
-
const play = playerOf(spec, hook, transition);
|
|
66820
|
+
function hookOf(spec, hook, transition, when, label) {
|
|
66821
|
+
const play = playerOf(spec, hook, transition, label);
|
|
66552
66822
|
if (play === void 0) return void 0;
|
|
66553
66823
|
return (view, _item, _hint, cause) => when === "change" && cause === "mount" ? void 0 : play(view);
|
|
66554
66824
|
}
|
|
@@ -66615,11 +66885,13 @@ function recordJson(record) {
|
|
|
66615
66885
|
* `printOf` reads it; a loop whose keys hold a function ease carries none.
|
|
66616
66886
|
*
|
|
66617
66887
|
* @param loop - The resolved loop, if any.
|
|
66888
|
+
* @param label - The label of the loop's tracks, when the motion has an id. It is not part of the
|
|
66889
|
+
* fingerprint: two loops of equal data are equal under any id.
|
|
66618
66890
|
* @returns The hook, or `undefined` when the motion names no loop.
|
|
66619
66891
|
*/
|
|
66620
|
-
function loopHook(loop) {
|
|
66892
|
+
function loopHook(loop, label) {
|
|
66621
66893
|
if (loop === void 0) return void 0;
|
|
66622
|
-
const hook = (view) => playLoop(view, loop.keys, loop.ms, loop.reduced);
|
|
66894
|
+
const hook = (view) => playLoop(view, loop.keys, loop.ms, loop.reduced, label);
|
|
66623
66895
|
const print = stableJson({
|
|
66624
66896
|
keys: loop.keys,
|
|
66625
66897
|
ms: loop.ms,
|
|
@@ -66654,12 +66926,13 @@ function printOf(hook) {
|
|
|
66654
66926
|
* @param view - The view handle the hook was given.
|
|
66655
66927
|
* @param state - The named pose.
|
|
66656
66928
|
* @param transition - How long the way home takes.
|
|
66929
|
+
* @param label - The label of the tracks, when the motion has an id.
|
|
66657
66930
|
* @returns One motion over every component the pose names.
|
|
66658
66931
|
*/
|
|
66659
|
-
function playEnter(view, state, transition) {
|
|
66932
|
+
function playEnter(view, state, transition, label) {
|
|
66660
66933
|
const poses = posesOf(state);
|
|
66661
66934
|
for (const [component, fields] of poses) view.set(component, fields);
|
|
66662
|
-
return view.all(poses.map(([component]) => view.toRest(component, trackOptionsOf(transition))));
|
|
66935
|
+
return view.all(poses.map(([component]) => view.toRest(component, trackOptionsOf(transition, label))));
|
|
66663
66936
|
}
|
|
66664
66937
|
/**
|
|
66665
66938
|
* The exit hook: the element tweens into the named pose and its rest pose is left alone, so the
|
|
@@ -66668,28 +66941,32 @@ function playEnter(view, state, transition) {
|
|
|
66668
66941
|
* @param view - The view handle the hook was given.
|
|
66669
66942
|
* @param state - The named pose.
|
|
66670
66943
|
* @param transition - How long the way out takes.
|
|
66944
|
+
* @param label - The label of the tracks, when the motion has an id.
|
|
66671
66945
|
* @returns One motion over every component the pose names.
|
|
66672
66946
|
*/
|
|
66673
|
-
function playExit(view, state, transition) {
|
|
66947
|
+
function playExit(view, state, transition, label) {
|
|
66674
66948
|
const poses = posesOf(state);
|
|
66675
|
-
return view.all(poses.map(([component, fields]) => view.tween(component, fields, trackOptionsOf(transition))));
|
|
66949
|
+
return view.all(poses.map(([component, fields]) => view.tween(component, fields, trackOptionsOf(transition, label))));
|
|
66676
66950
|
}
|
|
66677
66951
|
/**
|
|
66678
66952
|
* The options a transition starts a track with: its length and curve, and `reduced` only for a
|
|
66679
|
-
* kept track, so a cut track starts with the options it always had
|
|
66953
|
+
* kept track, so a cut track starts with the options it always had, and `label` only for a motion
|
|
66954
|
+
* with an id.
|
|
66680
66955
|
*
|
|
66681
66956
|
* @param transition - The resolved transition.
|
|
66957
|
+
* @param label - The label of the track, when the motion has an id.
|
|
66682
66958
|
* @returns The track options.
|
|
66683
66959
|
* @example
|
|
66684
66960
|
* ```ts
|
|
66685
|
-
* trackOptionsOf({ ms: 150, ease: "out", reduced: "cut" }); // { ms: 150, ease: "out" }
|
|
66961
|
+
* trackOptionsOf({ ms: 150, ease: "out", reduced: "cut" }, "hud.card.enter"); // { ms: 150, ease: "out", label: "hud.card.enter" }
|
|
66686
66962
|
* ```
|
|
66687
66963
|
*/
|
|
66688
|
-
function trackOptionsOf(transition) {
|
|
66964
|
+
function trackOptionsOf(transition, label) {
|
|
66689
66965
|
return {
|
|
66690
66966
|
ms: transition.ms,
|
|
66691
66967
|
ease: transition.ease,
|
|
66692
|
-
...reducedOption(transition.reduced)
|
|
66968
|
+
...reducedOption(transition.reduced),
|
|
66969
|
+
...labelOption(label)
|
|
66693
66970
|
};
|
|
66694
66971
|
}
|
|
66695
66972
|
/**
|
|
@@ -66697,14 +66974,15 @@ function trackOptionsOf(transition) {
|
|
|
66697
66974
|
*
|
|
66698
66975
|
* @param names - The component names `on.change` listed.
|
|
66699
66976
|
* @param transition - How long the way home takes.
|
|
66977
|
+
* @param label - The label of the tracks, when the motion has an id.
|
|
66700
66978
|
* @returns The change table, keyed by component name.
|
|
66701
66979
|
*/
|
|
66702
|
-
function changeHooks(names, transition) {
|
|
66980
|
+
function changeHooks(names, transition, label) {
|
|
66703
66981
|
const hooks = {};
|
|
66704
66982
|
for (const name of names) {
|
|
66705
66983
|
const component = componentByName(name);
|
|
66706
66984
|
if (component === void 0) continue;
|
|
66707
|
-
hooks[name] = (view) => view.toRest(component, trackOptionsOf(transition));
|
|
66985
|
+
hooks[name] = (view) => view.toRest(component, trackOptionsOf(transition, label));
|
|
66708
66986
|
}
|
|
66709
66987
|
return hooks;
|
|
66710
66988
|
}
|
|
@@ -66724,7 +67002,8 @@ function changeHooks(names, transition) {
|
|
|
66724
67002
|
* `world` applies.
|
|
66725
67003
|
* @throws {Error} When a track is invalid, a name is both a state and a track, `on` names
|
|
66726
67004
|
* neither, `loop.track` names no track, `loop.ms` is not a finite number above 0, the loop
|
|
66727
|
-
* ends somewhere else than it starts,
|
|
67005
|
+
* ends somewhere else than it starts, `id` is given and is not a non-empty string, or `when` or a
|
|
67006
|
+
* `reduced` is not one of its words.
|
|
66728
67007
|
* @example
|
|
66729
67008
|
* ```ts
|
|
66730
67009
|
* const buttonMotion = defineMotion({
|
|
@@ -66741,6 +67020,14 @@ function changeHooks(names, transition) {
|
|
|
66741
67020
|
* when: "change"
|
|
66742
67021
|
* });
|
|
66743
67022
|
* // a scene mount shows it at rest; a commit that adds it grows it in over 220 ms
|
|
67023
|
+
*
|
|
67024
|
+
* const hudCard = defineMotion({
|
|
67025
|
+
* id: "hud.card",
|
|
67026
|
+
* states: { small: { Transform: { scale: 0.8 } } },
|
|
67027
|
+
* on: { enter: "small", change: ["Transform"] }
|
|
67028
|
+
* });
|
|
67029
|
+
* hudCard.id; // "hud.card"
|
|
67030
|
+
* // its enter track is labelled "hud.card.enter", its change track "hud.card.change"
|
|
66744
67031
|
* ```
|
|
66745
67032
|
*/
|
|
66746
67033
|
function defineMotion(spec) {
|
|
@@ -66751,15 +67038,17 @@ function defineMotion(spec) {
|
|
|
66751
67038
|
reduced: spec.transition?.reduced ?? "cut"
|
|
66752
67039
|
};
|
|
66753
67040
|
const when = spec.when ?? "always";
|
|
66754
|
-
const
|
|
66755
|
-
const
|
|
66756
|
-
const
|
|
67041
|
+
const labels = labelsOf(spec.id);
|
|
67042
|
+
const enter = hookOf(spec, "enter", transition, when, labels?.enter);
|
|
67043
|
+
const loop = loopHook(loopOf(spec, transition.ms), labels?.loop);
|
|
67044
|
+
const exit = hookOf(spec, "exit", transition, when, labels?.exit);
|
|
66757
67045
|
const changed = spec.on.change ?? [];
|
|
66758
67046
|
return {
|
|
67047
|
+
...spec.id === void 0 ? {} : { id: spec.id },
|
|
66759
67048
|
...enter === void 0 ? {} : { enter },
|
|
66760
67049
|
...loop === void 0 ? {} : { loop },
|
|
66761
67050
|
...exit === void 0 ? {} : { exit },
|
|
66762
|
-
...changed.length === 0 ? {} : { change: changeHooks(changed, transition) }
|
|
67051
|
+
...changed.length === 0 ? {} : { change: changeHooks(changed, transition, labels?.change) }
|
|
66763
67052
|
};
|
|
66764
67053
|
}
|
|
66765
67054
|
//#endregion
|
|
@@ -70617,7 +70906,7 @@ function createJsxApi(ctx, modules) {
|
|
|
70617
70906
|
}
|
|
70618
70907
|
};
|
|
70619
70908
|
return {
|
|
70620
|
-
tree: () => readTree(state, layerNames(), resolvedOf, (slot) => rootPoseOf(ctx.deps.world.ecs, slot), isAside, shownStyleOf),
|
|
70909
|
+
tree: () => readTree(state, layerNames(), resolvedOf, (slot) => rootPoseOf(ctx.deps.world.ecs, slot), isAside, shownStyleOf, modules.layout.stopsOf),
|
|
70621
70910
|
find,
|
|
70622
70911
|
lint: () => runLint(ctx),
|
|
70623
70912
|
fill: (key, value) => {
|
|
@@ -72645,6 +72934,25 @@ function nearestStop(snap, offset, max, fallback) {
|
|
|
72645
72934
|
return nearest;
|
|
72646
72935
|
}
|
|
72647
72936
|
/**
|
|
72937
|
+
* The stops a scroll's `snap` prop names, as a release uses them: numbers only, each kept inside 0
|
|
72938
|
+
* to `max`, in prop order. A `NaN` and a stop that is no number are left out; `Infinity` is kept
|
|
72939
|
+
* clamped to `max`, so every stop is finite and no `null` reaches a reader's JSON.
|
|
72940
|
+
*
|
|
72941
|
+
* @param snap - The `snap` prop of the scroll, any value.
|
|
72942
|
+
* @param max - The largest offset.
|
|
72943
|
+
* @returns The stops, or `undefined` when the prop is no array or no numeric stop remains.
|
|
72944
|
+
* @example
|
|
72945
|
+
* ```ts
|
|
72946
|
+
* stopsOf([-10, 318, Number.NaN, "end", 500, Infinity], 390); // [0, 318, 390, 390]
|
|
72947
|
+
* ```
|
|
72948
|
+
*/
|
|
72949
|
+
function stopsOf(snap, max) {
|
|
72950
|
+
if (!Array.isArray(snap)) return void 0;
|
|
72951
|
+
const stops = [];
|
|
72952
|
+
for (const candidate of snap) if (typeof candidate === "number" && !Number.isNaN(candidate)) stops.push(within(candidate, max));
|
|
72953
|
+
return stops.length === 0 ? void 0 : stops;
|
|
72954
|
+
}
|
|
72955
|
+
/**
|
|
72648
72956
|
* Stops a scroll where it stands.
|
|
72649
72957
|
*
|
|
72650
72958
|
* @param motion - Its motion.
|
|
@@ -73455,6 +73763,7 @@ function createLayoutApi(ctx) {
|
|
|
73455
73763
|
clampScroll: (container, contentHeight, lookup) => clampScroll(ctx, state, container, contentHeight, lookup),
|
|
73456
73764
|
scrollTo: (container, to, lookup) => scrollTo(ctx, state, container, to, lookup),
|
|
73457
73765
|
windowOf,
|
|
73766
|
+
stopsOf,
|
|
73458
73767
|
popupHandler: (jsx) => createPopupHandler(ctx, state, jsx),
|
|
73459
73768
|
guideHandler: () => createGuideHandler(ctx),
|
|
73460
73769
|
counters: () => ({
|