@moku-labs/game 0.15.162 → 0.15.164
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-Gi8RMNnU.d.mts → commands-D5MG6t52.d.mts} +5 -5
- package/dist/control.d.mts +4 -4
- package/dist/{define-DSOTwTUY.d.mts → define-SHySD9Bw.d.mts} +2 -2
- package/dist/{headless-PANjNy6-.d.mts → headless-8XrFW9w1.d.mts} +1 -1
- package/dist/{index-CbMDaUan.d.mts → index-HsOHfkao.d.mts} +12 -12
- 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-CkJJvWKb.d.mts → runtime-JG7kE0RP.d.mts} +1 -1
- package/dist/{src-mZkN8URR.mjs → src-CUi3Ytta.mjs} +924 -265
- package/dist/testing.d.mts +4 -4
- package/dist/testing.mjs +1 -1
- package/dist/{types-DTkhpupa.d.mts → types-B93wB7Sh.d.mts} +4 -2
- package/dist/{types-BuN6rLDs.d.mts → types-BEEPI3F3.d.mts} +2 -2
- package/dist/{types-DkQbqqw0.d.mts → types-CZguGD6b.d.mts} +4 -4
- package/dist/{types-CPiWOiSc.d.mts → types-Cs3a-2Km.d.mts} +1881 -39
- package/dist/types-VZL87Yhu.d.mts +1841 -0
- package/dist/{visual-nAxiy1aK.d.mts → visual-BrvFv5pU.d.mts} +5 -6
- package/dist/visual.d.mts +1 -1
- package/llms.txt +1 -1
- package/package.json +3 -3
- package/dist/types-D8D2ZtEi.d.mts +0 -3632
|
@@ -3339,7 +3339,9 @@ function beginGuide(state, signal) {
|
|
|
3339
3339
|
* gate opened. The spread keeps a payload-less answer without a `payload` key, and `at` replaces
|
|
3340
3340
|
* one a caller put on the answer. In live mode the handler is called as well: it only shows the UI,
|
|
3341
3341
|
* the answer comes through the gate, so its failure is logged and does not block the node. Its
|
|
3342
|
-
* signal ends with the answer — that is how the popup layer knows to unmount what it showed.
|
|
3342
|
+
* signal ends with the answer — that is how the popup layer knows to unmount what it showed. In
|
|
3343
|
+
* fast mode the call waits in `state.unshown` until the answer: when the mode goes back to live
|
|
3344
|
+
* first (a walk rests at this gate), `setMode` shows the popup then.
|
|
3343
3345
|
*
|
|
3344
3346
|
* @param ctx - Domain context of the flow plugin.
|
|
3345
3347
|
* @param gate - Internal gate API.
|
|
@@ -3349,13 +3351,23 @@ function beginGuide(state, signal) {
|
|
|
3349
3351
|
* @returns The answer the gate accepted, with the moment it arrived.
|
|
3350
3352
|
*/
|
|
3351
3353
|
function openForAnswers(ctx, gate, descriptor, answers, signal) {
|
|
3354
|
+
const state = ctx.state.fx;
|
|
3352
3355
|
const answered = gate.open({ allowed: answers }).then((answer) => ({
|
|
3353
3356
|
...answer,
|
|
3354
3357
|
at: ctx.deps.clock.now()
|
|
3355
3358
|
}));
|
|
3356
|
-
if (ctx.state.fx.mode !== "live") return answered;
|
|
3357
3359
|
const shown = childOf$1(signal);
|
|
3358
|
-
|
|
3360
|
+
/**
|
|
3361
|
+
* Calls the handler with the signal that ends with the answer.
|
|
3362
|
+
*/
|
|
3363
|
+
const show = () => {
|
|
3364
|
+
invoke(state, ctx.log, descriptor, shown.signal);
|
|
3365
|
+
};
|
|
3366
|
+
if (state.mode === "live") show();
|
|
3367
|
+
else if (!shown.signal.aborted) state.unshown = show;
|
|
3368
|
+
shown.signal.addEventListener("abort", () => {
|
|
3369
|
+
if (state.unshown === show) state.unshown = void 0;
|
|
3370
|
+
});
|
|
3359
3371
|
return answered.finally(() => {
|
|
3360
3372
|
shown.abort();
|
|
3361
3373
|
});
|
|
@@ -3438,7 +3450,11 @@ function createFxApi(ctx, deps) {
|
|
|
3438
3450
|
for (const controller of shown) controller.abort();
|
|
3439
3451
|
},
|
|
3440
3452
|
setMode: (mode) => {
|
|
3453
|
+
const unshown = state.unshown;
|
|
3441
3454
|
state.mode = mode;
|
|
3455
|
+
if (mode !== "live" || unshown === void 0) return;
|
|
3456
|
+
state.unshown = void 0;
|
|
3457
|
+
unshown();
|
|
3442
3458
|
}
|
|
3443
3459
|
};
|
|
3444
3460
|
}
|
|
@@ -7167,7 +7183,8 @@ async function playRoute(ctx, modules, route, running) {
|
|
|
7167
7183
|
* after the switch, so it never starts live and never shows its popup. The mode of the caller
|
|
7168
7184
|
* is put back afterwards, also when the bookmark is refused or a step rejects, and a
|
|
7169
7185
|
* substitution the route never reached is disarmed: it must not skip a sub-flow in the live play
|
|
7170
|
-
* that follows. Back in live mode, the guide of the node the walk ends at is shown
|
|
7186
|
+
* that follows. Back in live mode, the guide of the node the walk ends at is shown, and `fx`
|
|
7187
|
+
* shows the popup whose gate the walk rests at.
|
|
7171
7188
|
*
|
|
7172
7189
|
* @param ctx - Domain context of the flow plugin.
|
|
7173
7190
|
* @param modules - Injected sibling APIs: features, fx, gate, inbox.
|
|
@@ -7612,6 +7629,7 @@ function createFxState() {
|
|
|
7612
7629
|
hintListeners: [],
|
|
7613
7630
|
settled: [],
|
|
7614
7631
|
guides: [],
|
|
7632
|
+
unshown: void 0,
|
|
7615
7633
|
mode: "live"
|
|
7616
7634
|
};
|
|
7617
7635
|
}
|
|
@@ -29652,9 +29670,12 @@ function isDrawn(view, root) {
|
|
|
29652
29670
|
function passesOf(slots) {
|
|
29653
29671
|
let passes = 0;
|
|
29654
29672
|
let enabled = false;
|
|
29655
|
-
for (
|
|
29656
|
-
|
|
29657
|
-
enabled
|
|
29673
|
+
for (let index = 0; index < slots.length; index += 1) {
|
|
29674
|
+
const slot = slots[index];
|
|
29675
|
+
if (slot?.filter.enabled) {
|
|
29676
|
+
passes += slot.passes;
|
|
29677
|
+
enabled = true;
|
|
29678
|
+
}
|
|
29658
29679
|
}
|
|
29659
29680
|
return enabled ? 1 + passes : 0;
|
|
29660
29681
|
}
|
|
@@ -29675,7 +29696,9 @@ function addFiltered(slots, entity) {
|
|
|
29675
29696
|
const { sync, kept } = walk$1;
|
|
29676
29697
|
if (sync === void 0 || kept === void 0 || sync.root === void 0) return;
|
|
29677
29698
|
const cache = sync.passes;
|
|
29678
|
-
for (
|
|
29699
|
+
for (let index = 0; index < slots.length; index += 1) {
|
|
29700
|
+
const slot = slots[index];
|
|
29701
|
+
if (slot === void 0) continue;
|
|
29679
29702
|
cache.filters[cache.count] = slot.filter;
|
|
29680
29703
|
cache.enabled[cache.count] = slot.filter.enabled;
|
|
29681
29704
|
cache.count += 1;
|
|
@@ -32446,7 +32469,7 @@ const DOUBLE_SEED$1 = .5;
|
|
|
32446
32469
|
* (`position.x = x`) takes the number as an argument, and a double handed to a call that is not inlined is boxed: 16 B
|
|
32447
32470
|
* a frame, whether it is inlined or not depends on the optimizer's budget (`transition.perf.ts`).
|
|
32448
32471
|
*/
|
|
32449
|
-
const AT = {
|
|
32472
|
+
const AT$1 = {
|
|
32450
32473
|
x: DOUBLE_SEED$1,
|
|
32451
32474
|
y: DOUBLE_SEED$1
|
|
32452
32475
|
};
|
|
@@ -32746,8 +32769,8 @@ function paintSprite(sprite, picture, playing, screen) {
|
|
|
32746
32769
|
const eased = EASED[0] ?? 0;
|
|
32747
32770
|
const { transition } = playing;
|
|
32748
32771
|
if (sprite.texture !== picture) sprite.texture = picture;
|
|
32749
|
-
AT.x = screen.x;
|
|
32750
|
-
AT.y = screen.y;
|
|
32772
|
+
AT$1.x = screen.x;
|
|
32773
|
+
AT$1.y = screen.y;
|
|
32751
32774
|
SCALED.x = screen.width / picture.width;
|
|
32752
32775
|
SCALED.y = screen.height / picture.height;
|
|
32753
32776
|
if (transition.kind !== "slide") {
|
|
@@ -32758,15 +32781,15 @@ function paintSprite(sprite, picture, playing, screen) {
|
|
|
32758
32781
|
sprite.alpha = 1;
|
|
32759
32782
|
switch (transition.to) {
|
|
32760
32783
|
case "left":
|
|
32761
|
-
AT.x = screen.x - eased * screen.width;
|
|
32784
|
+
AT$1.x = screen.x - eased * screen.width;
|
|
32762
32785
|
break;
|
|
32763
32786
|
case "right":
|
|
32764
|
-
AT.x = screen.x + eased * screen.width;
|
|
32787
|
+
AT$1.x = screen.x + eased * screen.width;
|
|
32765
32788
|
break;
|
|
32766
32789
|
case "up":
|
|
32767
|
-
AT.y = screen.y - eased * screen.height;
|
|
32790
|
+
AT$1.y = screen.y - eased * screen.height;
|
|
32768
32791
|
break;
|
|
32769
|
-
case "down": AT.y = screen.y + eased * screen.height;
|
|
32792
|
+
case "down": AT$1.y = screen.y + eased * screen.height;
|
|
32770
32793
|
}
|
|
32771
32794
|
placeAt(sprite);
|
|
32772
32795
|
}
|
|
@@ -32777,7 +32800,7 @@ function paintSprite(sprite, picture, playing, screen) {
|
|
|
32777
32800
|
* @param shown - The sprite or the mesh.
|
|
32778
32801
|
*/
|
|
32779
32802
|
function placeAt(shown) {
|
|
32780
|
-
shown.position.copyFrom(AT);
|
|
32803
|
+
shown.position.copyFrom(AT$1);
|
|
32781
32804
|
shown.scale.copyFrom(SCALED);
|
|
32782
32805
|
}
|
|
32783
32806
|
/**
|
|
@@ -32986,8 +33009,8 @@ function paintMesh(sctx, pixi, objects, playing, screen) {
|
|
|
32986
33009
|
}
|
|
32987
33010
|
const { mesh } = picture;
|
|
32988
33011
|
if (mesh.shader !== shader) mesh.shader = shader;
|
|
32989
|
-
AT.x = screen.x;
|
|
32990
|
-
AT.y = screen.y;
|
|
33012
|
+
AT$1.x = screen.x;
|
|
33013
|
+
AT$1.y = screen.y;
|
|
32991
33014
|
SCALED.x = screen.width;
|
|
32992
33015
|
SCALED.y = screen.height;
|
|
32993
33016
|
placeAt(mesh);
|
|
@@ -38353,7 +38376,10 @@ function keeps(record, key) {
|
|
|
38353
38376
|
*/
|
|
38354
38377
|
function factorOf(order, key) {
|
|
38355
38378
|
let factor = 1;
|
|
38356
|
-
for (
|
|
38379
|
+
for (let index = 0; index < order.length; index += 1) {
|
|
38380
|
+
const record = order[index];
|
|
38381
|
+
if (record !== void 0) factor += (keeps(record, key) - factor) * record.level;
|
|
38382
|
+
}
|
|
38357
38383
|
return factor;
|
|
38358
38384
|
}
|
|
38359
38385
|
/**
|
|
@@ -38365,7 +38391,10 @@ function factorOf(order, key) {
|
|
|
38365
38391
|
*/
|
|
38366
38392
|
function targetOf$3(order, key) {
|
|
38367
38393
|
let target = 1;
|
|
38368
|
-
for (
|
|
38394
|
+
for (let index = 0; index < order.length; index += 1) {
|
|
38395
|
+
const record = order[index];
|
|
38396
|
+
if (record !== void 0 && record.phase !== "exiting") target = keeps(record, key);
|
|
38397
|
+
}
|
|
38369
38398
|
return target;
|
|
38370
38399
|
}
|
|
38371
38400
|
/**
|
|
@@ -38377,7 +38406,9 @@ function targetOf$3(order, key) {
|
|
|
38377
38406
|
* @returns True when a tap does not reach the part.
|
|
38378
38407
|
*/
|
|
38379
38408
|
function inertOf(order, key) {
|
|
38380
|
-
for (
|
|
38409
|
+
for (let index = 0; index < order.length; index += 1) {
|
|
38410
|
+
const record = order[index];
|
|
38411
|
+
if (record === void 0) continue;
|
|
38381
38412
|
const { hud, hudInert } = record.value;
|
|
38382
38413
|
if (!hudInert || hud === "none" || hud === "under") continue;
|
|
38383
38414
|
if (hud === "all" || hud.includes(key)) return true;
|
|
@@ -38393,7 +38424,10 @@ function inertOf(order, key) {
|
|
|
38393
38424
|
*/
|
|
38394
38425
|
function holdsSame(list, set) {
|
|
38395
38426
|
if (list.length !== set.size) return false;
|
|
38396
|
-
for (
|
|
38427
|
+
for (let index = 0; index < list.length; index += 1) {
|
|
38428
|
+
const node = list[index];
|
|
38429
|
+
if (node !== void 0 && !set.has(node)) return false;
|
|
38430
|
+
}
|
|
38397
38431
|
return true;
|
|
38398
38432
|
}
|
|
38399
38433
|
/**
|
|
@@ -38411,7 +38445,10 @@ function keepOff(sctx, count) {
|
|
|
38411
38445
|
if (holdsSame(offList, overlay.offTops)) return;
|
|
38412
38446
|
const next = overlay.nextOff;
|
|
38413
38447
|
if (next.size > 0) next.clear();
|
|
38414
|
-
for (
|
|
38448
|
+
for (let index = 0; index < offList.length; index += 1) {
|
|
38449
|
+
const top = offList[index];
|
|
38450
|
+
if (top !== void 0) next.add(top);
|
|
38451
|
+
}
|
|
38415
38452
|
overlay.nextOff = overlay.offTops;
|
|
38416
38453
|
overlay.offTops = next;
|
|
38417
38454
|
}
|
|
@@ -38433,6 +38470,41 @@ function warnOutside(sctx, entity, key) {
|
|
|
38433
38470
|
key
|
|
38434
38471
|
});
|
|
38435
38472
|
}
|
|
38473
|
+
/** What the walk of the HUD parts reads, set before the walk: one at a time, no closure per frame. */
|
|
38474
|
+
const partsWalk = {
|
|
38475
|
+
sctx: void 0,
|
|
38476
|
+
hud: void 0,
|
|
38477
|
+
settling: false,
|
|
38478
|
+
count: 0
|
|
38479
|
+
};
|
|
38480
|
+
/**
|
|
38481
|
+
* Steps one HUD part of the walk: judged against the HUD layer, faded by the factor of the overlays, and noted in the
|
|
38482
|
+
* list of the tops that take no tap when it fades, is going to fade, or is kept by an inert overlay.
|
|
38483
|
+
*
|
|
38484
|
+
* @param entity - The part.
|
|
38485
|
+
*/
|
|
38486
|
+
function stepPart(entity) {
|
|
38487
|
+
const { sctx, hud, settling } = partsWalk;
|
|
38488
|
+
if (sctx === void 0) return;
|
|
38489
|
+
const state = sctx.ctx.state.sync;
|
|
38490
|
+
const overlay = state.overlay;
|
|
38491
|
+
const view = state.views.get(entity);
|
|
38492
|
+
if (view === void 0) return;
|
|
38493
|
+
const key = sctx.ctx.deps.world.ecs.get(entity, HudPart)?.key ?? "";
|
|
38494
|
+
if (hud === void 0 || layerOf$1(sctx, entity) !== hud) {
|
|
38495
|
+
if (!(settling || sctx.ctx.deps.world.projection.isBuilding(entity))) warnOutside(sctx, entity, key);
|
|
38496
|
+
applyHud(sctx, entity, view, 1);
|
|
38497
|
+
return;
|
|
38498
|
+
}
|
|
38499
|
+
const factor = factorOf(overlay.order, key);
|
|
38500
|
+
applyHud(sctx, entity, view, factor);
|
|
38501
|
+
if (factor < 1 || targetOf$3(overlay.order, key) < 1 || inertOf(overlay.order, key)) {
|
|
38502
|
+
const top = view.wrapper ?? view.object;
|
|
38503
|
+
const { offList } = overlay;
|
|
38504
|
+
if (offList[partsWalk.count] !== top) offList[partsWalk.count] = top;
|
|
38505
|
+
partsWalk.count += 1;
|
|
38506
|
+
}
|
|
38507
|
+
}
|
|
38436
38508
|
/**
|
|
38437
38509
|
* The HUD parts: every part of the HUD layer is drawn with the factor of the overlays' levels of this frame, and the
|
|
38438
38510
|
* parts leaving or not fully back take no tap, and the parts an inert overlay keeps shown take no tap either. A part
|
|
@@ -38446,29 +38518,14 @@ function stepParts(sctx) {
|
|
|
38446
38518
|
const state = sctx.ctx.state.sync;
|
|
38447
38519
|
const overlay = state.overlay;
|
|
38448
38520
|
if (overlay.parts.size === 0 && overlay.offTops.size === 0) return;
|
|
38449
|
-
|
|
38450
|
-
|
|
38451
|
-
|
|
38452
|
-
|
|
38453
|
-
|
|
38454
|
-
|
|
38455
|
-
|
|
38456
|
-
|
|
38457
|
-
if (view === void 0) continue;
|
|
38458
|
-
const key = ecs.get(entity, HudPart)?.key ?? "";
|
|
38459
|
-
if (hud === void 0 || layerOf$1(sctx, entity) !== hud) {
|
|
38460
|
-
if (!(settling || projection.isBuilding(entity))) warnOutside(sctx, entity, key);
|
|
38461
|
-
applyHud(sctx, entity, view, 1);
|
|
38462
|
-
continue;
|
|
38463
|
-
}
|
|
38464
|
-
const factor = factorOf(overlay.order, key);
|
|
38465
|
-
applyHud(sctx, entity, view, factor);
|
|
38466
|
-
if (factor < 1 || targetOf$3(overlay.order, key) < 1 || inertOf(overlay.order, key)) {
|
|
38467
|
-
const top = view.wrapper ?? view.object;
|
|
38468
|
-
if (offList[count] !== top) offList[count] = top;
|
|
38469
|
-
count += 1;
|
|
38470
|
-
}
|
|
38471
|
-
}
|
|
38521
|
+
partsWalk.sctx = sctx;
|
|
38522
|
+
partsWalk.hud = state.hudLayer;
|
|
38523
|
+
partsWalk.settling = heldWaiting(sctx);
|
|
38524
|
+
partsWalk.count = 0;
|
|
38525
|
+
overlay.parts.forEach(stepPart);
|
|
38526
|
+
const count = partsWalk.count;
|
|
38527
|
+
partsWalk.sctx = void 0;
|
|
38528
|
+
partsWalk.hud = void 0;
|
|
38472
38529
|
keepOff(sctx, count);
|
|
38473
38530
|
}
|
|
38474
38531
|
//#endregion
|
|
@@ -39839,10 +39896,10 @@ const NONE = {
|
|
|
39839
39896
|
* The sizes of the probes: the public contract. A page, a game or the native shell sets `--moku-safe-*`; the editor sets
|
|
39840
39897
|
* `--moku-device-safe-*` from its device preset, which a page's own value still overrides.
|
|
39841
39898
|
*/
|
|
39842
|
-
const TOP = "var(--moku-safe-top, var(--moku-device-safe-top, env(safe-area-inset-top, 0px)))";
|
|
39843
|
-
const RIGHT = "var(--moku-safe-right, var(--moku-device-safe-right, env(safe-area-inset-right, 0px)))";
|
|
39844
|
-
const BOTTOM = "var(--moku-safe-bottom, var(--moku-device-safe-bottom, env(safe-area-inset-bottom, 0px)))";
|
|
39845
|
-
const LEFT = "var(--moku-safe-left, var(--moku-device-safe-left, env(safe-area-inset-left, 0px)))";
|
|
39899
|
+
const TOP$1 = "var(--moku-safe-top, var(--moku-device-safe-top, env(safe-area-inset-top, 0px)))";
|
|
39900
|
+
const RIGHT$1 = "var(--moku-safe-right, var(--moku-device-safe-right, env(safe-area-inset-right, 0px)))";
|
|
39901
|
+
const BOTTOM$1 = "var(--moku-safe-bottom, var(--moku-device-safe-bottom, env(safe-area-inset-bottom, 0px)))";
|
|
39902
|
+
const LEFT$1 = "var(--moku-safe-left, var(--moku-device-safe-left, env(safe-area-inset-left, 0px)))";
|
|
39846
39903
|
/**
|
|
39847
39904
|
* Reads one CSS length in pixels.
|
|
39848
39905
|
*
|
|
@@ -39899,12 +39956,12 @@ function createSafeAreaProbes() {
|
|
|
39899
39956
|
const { document } = globalThis;
|
|
39900
39957
|
return {
|
|
39901
39958
|
start: createProbe(document, "start", {
|
|
39902
|
-
width: LEFT,
|
|
39903
|
-
height: TOP
|
|
39959
|
+
width: LEFT$1,
|
|
39960
|
+
height: TOP$1
|
|
39904
39961
|
}),
|
|
39905
39962
|
end: createProbe(document, "end", {
|
|
39906
|
-
width: RIGHT,
|
|
39907
|
-
height: BOTTOM
|
|
39963
|
+
width: RIGHT$1,
|
|
39964
|
+
height: BOTTOM$1
|
|
39908
39965
|
})
|
|
39909
39966
|
};
|
|
39910
39967
|
}
|
|
@@ -42604,6 +42661,55 @@ function sumOffsets(actx, key) {
|
|
|
42604
42661
|
return cellValue(SUM);
|
|
42605
42662
|
}
|
|
42606
42663
|
//#endregion
|
|
42664
|
+
//#region src/plugins/anim/tween/slots.ts
|
|
42665
|
+
/** Bytes of one double. */
|
|
42666
|
+
const DOUBLE = 8;
|
|
42667
|
+
/** The cells of the clock: running time and normalised time. */
|
|
42668
|
+
const CLOCK_CELLS = 2;
|
|
42669
|
+
/** How many arrays of doubles follow the clock (`targets`, `starts`, `values`, `seen`). */
|
|
42670
|
+
const DOUBLE_ARRAYS = 4;
|
|
42671
|
+
/** How many arrays of bytes follow the doubles (`live`, `moved`, `colors`, `partialMoved`). */
|
|
42672
|
+
const BYTE_ARRAYS = 4;
|
|
42673
|
+
/**
|
|
42674
|
+
* Cuts the nine typed arrays of a track out of one buffer: the arrays of doubles first, so each
|
|
42675
|
+
* starts on an aligned offset, then the arrays of bytes. `live` starts at 1 and `seen` at `NaN`,
|
|
42676
|
+
* the rest at 0.
|
|
42677
|
+
*
|
|
42678
|
+
* @param count - How many slots the track has.
|
|
42679
|
+
* @returns The nine views, all over the same `ArrayBuffer`.
|
|
42680
|
+
* @example
|
|
42681
|
+
* ```ts
|
|
42682
|
+
* const cells = slotCellsOf(2);
|
|
42683
|
+
* cells.targets.buffer === cells.live.buffer; // true
|
|
42684
|
+
* cells.targets.length; // 2
|
|
42685
|
+
* ```
|
|
42686
|
+
*/
|
|
42687
|
+
function slotCellsOf(count) {
|
|
42688
|
+
const doubleBytes = (CLOCK_CELLS + DOUBLE_ARRAYS * count) * DOUBLE;
|
|
42689
|
+
const buffer = new ArrayBuffer(doubleBytes + BYTE_ARRAYS * count);
|
|
42690
|
+
const step = count * DOUBLE;
|
|
42691
|
+
const live = new Uint8Array(buffer, doubleBytes, count).fill(1);
|
|
42692
|
+
const targetsAt = 16;
|
|
42693
|
+
const startsAt = targetsAt + step;
|
|
42694
|
+
const valuesAt = startsAt + step;
|
|
42695
|
+
const seenAt = valuesAt + step;
|
|
42696
|
+
const movedAt = doubleBytes + count;
|
|
42697
|
+
const colorsAt = movedAt + count;
|
|
42698
|
+
const partialAt = colorsAt + count;
|
|
42699
|
+
const seen = new Float64Array(buffer, seenAt, count).fill(NaN);
|
|
42700
|
+
return {
|
|
42701
|
+
clock: new Float64Array(buffer, 0, CLOCK_CELLS),
|
|
42702
|
+
targets: new Float64Array(buffer, targetsAt, count),
|
|
42703
|
+
starts: new Float64Array(buffer, startsAt, count),
|
|
42704
|
+
values: new Float64Array(buffer, valuesAt, count),
|
|
42705
|
+
seen,
|
|
42706
|
+
live,
|
|
42707
|
+
moved: new Uint8Array(buffer, movedAt, count),
|
|
42708
|
+
colors: new Uint8Array(buffer, colorsAt, count),
|
|
42709
|
+
partialMoved: new Uint8Array(buffer, partialAt, count)
|
|
42710
|
+
};
|
|
42711
|
+
}
|
|
42712
|
+
//#endregion
|
|
42607
42713
|
//#region src/plugins/anim/tween/advance.ts
|
|
42608
42714
|
/**
|
|
42609
42715
|
* @file anim/tween — the one track table: starting a track, the retarget policy per field, the
|
|
@@ -43063,28 +43169,27 @@ function endTrack(actx, track) {
|
|
|
43063
43169
|
function dropField(actx, track, field) {
|
|
43064
43170
|
delete track.to[field];
|
|
43065
43171
|
track.live[track.names.indexOf(field)] = 0;
|
|
43172
|
+
track.kept -= 1;
|
|
43066
43173
|
track.patch = { ...track.to };
|
|
43067
|
-
if (
|
|
43174
|
+
if (track.kept === 0) endTrack(actx, track);
|
|
43068
43175
|
}
|
|
43069
43176
|
/**
|
|
43070
|
-
* Books every field of an absolute track and cancels the older owner of each, field by field
|
|
43177
|
+
* Books every field of an absolute track and cancels the older owner of each, field by field: the
|
|
43178
|
+
* older owner drops the field as the walk reaches it, and ends with its last one.
|
|
43071
43179
|
*
|
|
43072
43180
|
* @param actx - Domain context of the anim plugin.
|
|
43073
43181
|
* @param track - The new absolute track.
|
|
43074
43182
|
*/
|
|
43075
43183
|
function claimFields(actx, track) {
|
|
43076
|
-
const
|
|
43077
|
-
for (
|
|
43078
|
-
const
|
|
43184
|
+
const { names, slotKeys } = track;
|
|
43185
|
+
for (let slot = 0; slot < names.length; slot++) {
|
|
43186
|
+
const field = names[slot] ?? "";
|
|
43187
|
+
const key = slotKeys[slot] ?? "";
|
|
43079
43188
|
const ownerId = actx.state.owner.get(key);
|
|
43080
43189
|
const older = ownerId === void 0 ? void 0 : actx.state.tracks.get(ownerId);
|
|
43081
43190
|
actx.state.owner.set(key, track.id);
|
|
43082
|
-
if (older !== void 0)
|
|
43083
|
-
older,
|
|
43084
|
-
field
|
|
43085
|
-
});
|
|
43191
|
+
if (older !== void 0) dropField(actx, older, field);
|
|
43086
43192
|
}
|
|
43087
|
-
for (const entry of taken) dropField(actx, entry.older, entry.field);
|
|
43088
43193
|
}
|
|
43089
43194
|
/**
|
|
43090
43195
|
* Reports once each time the table grows past `maxTracks`, so a leak is visible in development
|
|
@@ -43140,6 +43245,24 @@ function targetOf$1(to, segments) {
|
|
|
43140
43245
|
return Object.assign(target, to);
|
|
43141
43246
|
}
|
|
43142
43247
|
/**
|
|
43248
|
+
* The typed arrays of a new track, over one buffer, with the target and the colour flag of each
|
|
43249
|
+
* slot written in.
|
|
43250
|
+
*
|
|
43251
|
+
* @param component - The component the track writes.
|
|
43252
|
+
* @param names - The target fields in slot order.
|
|
43253
|
+
* @param target - The target record the track owns.
|
|
43254
|
+
* @returns The nine views of the track.
|
|
43255
|
+
*/
|
|
43256
|
+
function cellsOf(component, names, target) {
|
|
43257
|
+
const cells = slotCellsOf(names.length);
|
|
43258
|
+
for (let slot = 0; slot < names.length; slot++) {
|
|
43259
|
+
const field = names[slot] ?? "";
|
|
43260
|
+
cells.targets[slot] = target[field] ?? 0;
|
|
43261
|
+
cells.colors[slot] = isColorField(component, field) ? 1 : 0;
|
|
43262
|
+
}
|
|
43263
|
+
return cells;
|
|
43264
|
+
}
|
|
43265
|
+
/**
|
|
43143
43266
|
* Tells whether a field sizes a built-in visual: a loop of it may bring the view onto the screen. Pure.
|
|
43144
43267
|
*
|
|
43145
43268
|
* @param field - A field of a Sprite, a NineSlice or a Shape.
|
|
@@ -43224,17 +43347,11 @@ function startTrack$1(actx, entity, component, to, options, muted, driven = fals
|
|
|
43224
43347
|
ms: instant ? 0 : options.ms,
|
|
43225
43348
|
ease: options.ease ?? "out",
|
|
43226
43349
|
delayMs: instant ? 0 : options.delayMs ?? 0,
|
|
43227
|
-
|
|
43350
|
+
...cellsOf(component, names, target),
|
|
43228
43351
|
begun: false,
|
|
43229
43352
|
names,
|
|
43353
|
+
kept: names.length,
|
|
43230
43354
|
slotKeys: names.map((field) => keys[field] ?? ""),
|
|
43231
|
-
targets: Float64Array.from(names, (field) => target[field] ?? 0),
|
|
43232
|
-
starts: new Float64Array(names.length),
|
|
43233
|
-
live: new Uint8Array(names.length).fill(1),
|
|
43234
|
-
moved: new Uint8Array(names.length),
|
|
43235
|
-
values: new Float64Array(names.length),
|
|
43236
|
-
colors: Uint8Array.from(names, (field) => isColorField(component, field) ? 1 : 0),
|
|
43237
|
-
seen: new Float64Array(names.length).fill(NaN),
|
|
43238
43355
|
muted,
|
|
43239
43356
|
additive: options.additive === true,
|
|
43240
43357
|
driven,
|
|
@@ -43247,8 +43364,7 @@ function startTrack$1(actx, entity, component, to, options, muted, driven = fals
|
|
|
43247
43364
|
keep,
|
|
43248
43365
|
reveals: revealsOf(component, target),
|
|
43249
43366
|
patch: { ...target },
|
|
43250
|
-
partial: void 0
|
|
43251
|
-
partialMoved: new Uint8Array(names.length)
|
|
43367
|
+
partial: void 0
|
|
43252
43368
|
};
|
|
43253
43369
|
actx.state.nextId += 1;
|
|
43254
43370
|
if (track.ended) return track;
|
|
@@ -64214,7 +64330,7 @@ function dropLayouts(state) {
|
|
|
64214
64330
|
* @param style - The style name it shows it in.
|
|
64215
64331
|
* @param box - The box of its `Text`.
|
|
64216
64332
|
*/
|
|
64217
|
-
function keepSize(ctx, entity, resolved, style, box) {
|
|
64333
|
+
function keepSize$1(ctx, entity, resolved, style, box) {
|
|
64218
64334
|
const layout = layoutFor(ctx, resolved, style, box);
|
|
64219
64335
|
const size = ctx.state.measured.get(entity);
|
|
64220
64336
|
if (size === void 0) ctx.state.measured.set(entity, sizeOf(layout));
|
|
@@ -64282,7 +64398,7 @@ function showBound(ctx, entity, text, next, value, style = text.style) {
|
|
|
64282
64398
|
const restyled = style !== text.style;
|
|
64283
64399
|
const changed = restyled || next !== text.resolved;
|
|
64284
64400
|
if (changed) writeBound(ctx, entity, text, next, value, restyled ? style : void 0);
|
|
64285
|
-
if (changed || !ctx.state.measured.has(entity)) keepSize(ctx, entity, next, style, text.box);
|
|
64401
|
+
if (changed || !ctx.state.measured.has(entity)) keepSize$1(ctx, entity, next, style, text.box);
|
|
64286
64402
|
}
|
|
64287
64403
|
/**
|
|
64288
64404
|
* Writes the new string of a bound label, its new style when a named format picked another, and
|
|
@@ -64315,7 +64431,7 @@ function writeBound(ctx, entity, text, next, value, style) {
|
|
|
64315
64431
|
*/
|
|
64316
64432
|
function showAgain(ctx, entity, text) {
|
|
64317
64433
|
ctx.deps.world.ecs.set(entity, Text, { resolved: text.resolved });
|
|
64318
|
-
keepSize(ctx, entity, text.resolved, text.style, text.box);
|
|
64434
|
+
keepSize$1(ctx, entity, text.resolved, text.style, text.box);
|
|
64319
64435
|
}
|
|
64320
64436
|
/**
|
|
64321
64437
|
* Reports a bound label whose style is not a digits style, once per style. An unknown style name
|
|
@@ -64410,7 +64526,7 @@ function stepNamed(ctx, entity, text, bind, format, value, frame) {
|
|
|
64410
64526
|
function standStill(ctx, entity, text, seen, marked) {
|
|
64411
64527
|
if (!marked && !boxMoved(ctx, seen, text)) return;
|
|
64412
64528
|
if (marked) showAgain(ctx, entity, text);
|
|
64413
|
-
else keepSize(ctx, entity, text.resolved, text.style, text.box);
|
|
64529
|
+
else keepSize$1(ctx, entity, text.resolved, text.style, text.box);
|
|
64414
64530
|
seen.box = text.box;
|
|
64415
64531
|
}
|
|
64416
64532
|
/**
|
|
@@ -64444,7 +64560,7 @@ function stepText(ctx, entity, text, frame) {
|
|
|
64444
64560
|
return;
|
|
64445
64561
|
}
|
|
64446
64562
|
if (!isStale(ctx, entity, text, frame)) return;
|
|
64447
|
-
keepSize(ctx, entity, resolveContent(ctx, entity, text), text.style, text.box);
|
|
64563
|
+
keepSize$1(ctx, entity, resolveContent(ctx, entity, text), text.style, text.box);
|
|
64448
64564
|
ctx.state.dirty.delete(entity);
|
|
64449
64565
|
remember(ctx, entity, text, frame);
|
|
64450
64566
|
}
|
|
@@ -66717,10 +66833,51 @@ const NO_HOSTS = Object.freeze([]);
|
|
|
66717
66833
|
*/
|
|
66718
66834
|
function isNameList(value) {
|
|
66719
66835
|
if (!Array.isArray(value)) return false;
|
|
66720
|
-
for (
|
|
66836
|
+
for (let index = 0; index < value.length; index += 1) if (typeof value[index] !== "string") return false;
|
|
66721
66837
|
return true;
|
|
66722
66838
|
}
|
|
66723
66839
|
/**
|
|
66840
|
+
* The walks of the hosting step over the host set and the hosted views: a callback each, made
|
|
66841
|
+
* once per jsx state, and the fields the walk under way reads and answers. A `for…of` over a set
|
|
66842
|
+
* or a map builds an iterator and its results while the code runs unoptimized (F230 U3).
|
|
66843
|
+
*
|
|
66844
|
+
* @param state - The jsx state the walks belong to.
|
|
66845
|
+
* @returns The walks.
|
|
66846
|
+
*/
|
|
66847
|
+
function createHostWalk(state) {
|
|
66848
|
+
const walk = {
|
|
66849
|
+
ctx: void 0,
|
|
66850
|
+
name: "",
|
|
66851
|
+
owner: void 0,
|
|
66852
|
+
owners: (host) => {
|
|
66853
|
+
if (walk.owner !== void 0) return;
|
|
66854
|
+
const element = liveHost(state, host);
|
|
66855
|
+
if (element !== void 0 && hostsOf(element.node).includes(walk.name)) walk.owner = host;
|
|
66856
|
+
},
|
|
66857
|
+
hosting: (host) => {
|
|
66858
|
+
const element = liveHost(state, host);
|
|
66859
|
+
if (element !== void 0 && walk.ctx !== void 0) hostNames(walk.ctx, state, element);
|
|
66860
|
+
},
|
|
66861
|
+
releasing: (host, view) => {
|
|
66862
|
+
const ctx = walk.ctx;
|
|
66863
|
+
if (ctx === void 0 || stillHosts(ctx, state, view, host)) return;
|
|
66864
|
+
state.hosted.delete(view);
|
|
66865
|
+
unparent(ctx, view, host);
|
|
66866
|
+
}
|
|
66867
|
+
};
|
|
66868
|
+
return walk;
|
|
66869
|
+
}
|
|
66870
|
+
/**
|
|
66871
|
+
* The walks of one jsx state, made at their first use.
|
|
66872
|
+
*
|
|
66873
|
+
* @param state - The jsx state.
|
|
66874
|
+
* @returns Its walks.
|
|
66875
|
+
*/
|
|
66876
|
+
function walkOf(state) {
|
|
66877
|
+
state.hostWalk ??= createHostWalk(state);
|
|
66878
|
+
return state.hostWalk;
|
|
66879
|
+
}
|
|
66880
|
+
/**
|
|
66724
66881
|
* The projection names an element hosts. Allocates nothing: the prop itself, or one shared
|
|
66725
66882
|
* empty list.
|
|
66726
66883
|
*
|
|
@@ -66790,10 +66947,11 @@ function liveHost(state, host) {
|
|
|
66790
66947
|
* @returns The owning host, `undefined` when no live host names the projection.
|
|
66791
66948
|
*/
|
|
66792
66949
|
function ownerOf(state, name) {
|
|
66793
|
-
|
|
66794
|
-
|
|
66795
|
-
|
|
66796
|
-
|
|
66950
|
+
const walk = walkOf(state);
|
|
66951
|
+
walk.name = name;
|
|
66952
|
+
walk.owner = void 0;
|
|
66953
|
+
state.hosts.forEach(walk.owners);
|
|
66954
|
+
return walk.owner;
|
|
66797
66955
|
}
|
|
66798
66956
|
/**
|
|
66799
66957
|
* Gives the host as parent to every view of one projection that has no parent and is not held
|
|
@@ -66811,7 +66969,10 @@ function parentViews(ctx, state, name, host) {
|
|
|
66811
66969
|
const ecs = ctx.deps.world.ecs;
|
|
66812
66970
|
const projection = ctx.deps.world.projection;
|
|
66813
66971
|
const aside = projection.isBuilding(host);
|
|
66814
|
-
|
|
66972
|
+
const views = projection.entitiesOf(name);
|
|
66973
|
+
for (let index = 0; index < views.length; index += 1) {
|
|
66974
|
+
const view = views[index];
|
|
66975
|
+
if (view === void 0) continue;
|
|
66815
66976
|
if (ecs.has(view, Held) || projection.isBuilding(view) !== aside) continue;
|
|
66816
66977
|
if (ecs.has(view, Parent) && !state.released.has(view)) continue;
|
|
66817
66978
|
ecs.add(view, Parent({ entity: host }));
|
|
@@ -66873,10 +67034,9 @@ function hostViews(ctx, state, only) {
|
|
|
66873
67034
|
state.membershipSeen = membership;
|
|
66874
67035
|
releaseLeft(ctx, state);
|
|
66875
67036
|
}
|
|
66876
|
-
|
|
66877
|
-
|
|
66878
|
-
|
|
66879
|
-
}
|
|
67037
|
+
const walk = walkOf(state);
|
|
67038
|
+
walk.ctx = ctx;
|
|
67039
|
+
(only ?? state.hosts).forEach(walk.hosting);
|
|
66880
67040
|
}
|
|
66881
67041
|
/**
|
|
66882
67042
|
* Takes the parent back from every hosted view its host no longer holds: the view falls back to
|
|
@@ -66887,12 +67047,9 @@ function hostViews(ctx, state, only) {
|
|
|
66887
67047
|
*/
|
|
66888
67048
|
function releaseLeft(ctx, state) {
|
|
66889
67049
|
if (state.released.size > 0) state.released.clear();
|
|
66890
|
-
|
|
66891
|
-
|
|
66892
|
-
|
|
66893
|
-
state.hosted.delete(view);
|
|
66894
|
-
unparent(ctx, view, host);
|
|
66895
|
-
}
|
|
67050
|
+
const walk = walkOf(state);
|
|
67051
|
+
walk.ctx = ctx;
|
|
67052
|
+
state.hosted.forEach(walk.releasing);
|
|
66896
67053
|
}
|
|
66897
67054
|
/**
|
|
66898
67055
|
* Hosts the views of every projection a live host names and owns; a name listed twice counts once.
|
|
@@ -68982,15 +69139,33 @@ function waits$1(state, root) {
|
|
|
68982
69139
|
return (root.popup?.released === true || root.covered) && !state.removing.has(root.entity);
|
|
68983
69140
|
}
|
|
68984
69141
|
/**
|
|
69142
|
+
* The walk of the popup step over the roots: its callback made once per jsx state.
|
|
69143
|
+
*
|
|
69144
|
+
* @param state - The jsx state the walk belongs to.
|
|
69145
|
+
* @returns The walk.
|
|
69146
|
+
*/
|
|
69147
|
+
function createPopupWalk(state) {
|
|
69148
|
+
const walk = {
|
|
69149
|
+
found: false,
|
|
69150
|
+
waiting: (root) => {
|
|
69151
|
+
if (!walk.found && waits$1(state, root)) walk.found = true;
|
|
69152
|
+
}
|
|
69153
|
+
};
|
|
69154
|
+
return walk;
|
|
69155
|
+
}
|
|
69156
|
+
/**
|
|
68985
69157
|
* Tells whether any root waits for the settle step. Allocates nothing, so a frame without a
|
|
68986
|
-
* released or covered popup costs one scan.
|
|
69158
|
+
* released or covered popup costs one scan: a callback made once, no iterator (F230 U3).
|
|
68987
69159
|
*
|
|
68988
69160
|
* @param state - The jsx state.
|
|
68989
69161
|
* @returns True when at least one root waits.
|
|
68990
69162
|
*/
|
|
68991
69163
|
function anyWaits(state) {
|
|
68992
|
-
|
|
68993
|
-
|
|
69164
|
+
state.popupWalk ??= createPopupWalk(state);
|
|
69165
|
+
const walk = state.popupWalk;
|
|
69166
|
+
walk.found = false;
|
|
69167
|
+
state.roots.forEach(walk.waiting);
|
|
69168
|
+
return walk.found;
|
|
68994
69169
|
}
|
|
68995
69170
|
/**
|
|
68996
69171
|
* The step at the top of every reconcile: released popup roots leave once the flow rests, the
|
|
@@ -71169,8 +71344,14 @@ function sameList(left, right) {
|
|
|
71169
71344
|
* ```
|
|
71170
71345
|
*/
|
|
71171
71346
|
function sameFieldsDeep(left, right) {
|
|
71172
|
-
|
|
71173
|
-
|
|
71347
|
+
let count = 0;
|
|
71348
|
+
for (const key in left) {
|
|
71349
|
+
if (!Object.hasOwn(left, key)) continue;
|
|
71350
|
+
if (!Object.hasOwn(right, key) || !sameValue(left[key], right[key])) return false;
|
|
71351
|
+
count += 1;
|
|
71352
|
+
}
|
|
71353
|
+
for (const key in right) if (Object.hasOwn(right, key)) count -= 1;
|
|
71354
|
+
return count === 0;
|
|
71174
71355
|
}
|
|
71175
71356
|
/**
|
|
71176
71357
|
* Tells whether two prop values say the same. Plain objects and arrays are compared by value,
|
|
@@ -71531,7 +71712,11 @@ const WRITTEN = [
|
|
|
71531
71712
|
* ```
|
|
71532
71713
|
*/
|
|
71533
71714
|
function writesSame(previous, next) {
|
|
71534
|
-
|
|
71715
|
+
for (let index = 0; index < WRITTEN.length; index += 1) {
|
|
71716
|
+
const name = WRITTEN[index] ?? "";
|
|
71717
|
+
if (!sameValue(previous.props[name], next.props[name])) return false;
|
|
71718
|
+
}
|
|
71719
|
+
return true;
|
|
71535
71720
|
}
|
|
71536
71721
|
/**
|
|
71537
71722
|
* The children one element is diffed against. A scroll container holds exactly one of them: the
|
|
@@ -71572,6 +71757,58 @@ function childrenOf(node, slots, axis = "y") {
|
|
|
71572
71757
|
function identityOf(parentIdentity, node, index) {
|
|
71573
71758
|
return `${parentIdentity}|${node.key ?? `${node.type}@${index}`}|${node.type}`;
|
|
71574
71759
|
}
|
|
71760
|
+
/** The char code of `|`, the separator of an identity. */
|
|
71761
|
+
const BAR = 124;
|
|
71762
|
+
/** The char code of `@`, between the type and the index of an unkeyed name. */
|
|
71763
|
+
const AT = 64;
|
|
71764
|
+
/** The char code of `0`. */
|
|
71765
|
+
const ZERO = 48;
|
|
71766
|
+
/**
|
|
71767
|
+
* Tells whether an identity is the one `identityOf` builds for a node, without building it: the
|
|
71768
|
+
* parent identity, `|`, the key or the type, `@` and the index, `|`, the type, compared in place.
|
|
71769
|
+
*
|
|
71770
|
+
* @param identity - The identity an element keeps.
|
|
71771
|
+
* @param parentIdentity - The identity of the parent element.
|
|
71772
|
+
* @param node - The node being placed.
|
|
71773
|
+
* @param index - Its position among its siblings.
|
|
71774
|
+
* @returns True when `identityOf(parentIdentity, node, index)` equals `identity`.
|
|
71775
|
+
* @example
|
|
71776
|
+
* ```ts
|
|
71777
|
+
* isIdentityOf("0|row@2|row", "0", { type: "row", props: {}, children: [] }, 2); // true
|
|
71778
|
+
* ```
|
|
71779
|
+
*/
|
|
71780
|
+
function isIdentityOf(identity, parentIdentity, node, index) {
|
|
71781
|
+
const type = node.type;
|
|
71782
|
+
const head = parentIdentity.length + 1;
|
|
71783
|
+
const tail = identity.length - type.length - 1;
|
|
71784
|
+
if (!(tail >= head && identity.startsWith(parentIdentity) && identity.charCodeAt(head - 1) === BAR && identity.charCodeAt(tail) === BAR && identity.endsWith(type))) return false;
|
|
71785
|
+
if (node.key !== void 0) return tail - head === node.key.length && identity.startsWith(node.key, head);
|
|
71786
|
+
const at = head + type.length;
|
|
71787
|
+
if (!identity.startsWith(type, head) || identity.charCodeAt(at) !== AT) return false;
|
|
71788
|
+
let digit = tail - 1;
|
|
71789
|
+
let rest = index;
|
|
71790
|
+
do {
|
|
71791
|
+
const last = rest % 10;
|
|
71792
|
+
if (digit <= at || identity.charCodeAt(digit) !== ZERO + last) return false;
|
|
71793
|
+
rest = (rest - last) / 10;
|
|
71794
|
+
digit -= 1;
|
|
71795
|
+
} while (rest > 0);
|
|
71796
|
+
return digit === at;
|
|
71797
|
+
}
|
|
71798
|
+
/**
|
|
71799
|
+
* The identity of a node placed where an element stood: the element's own string when it is the
|
|
71800
|
+
* one `identityOf` would build, so an element that stayed concatenates nothing; else a new one.
|
|
71801
|
+
*
|
|
71802
|
+
* @param parentIdentity - The identity of the parent element.
|
|
71803
|
+
* @param node - The node being placed.
|
|
71804
|
+
* @param index - Its position among its siblings.
|
|
71805
|
+
* @param old - The element that stood at that place at the last diff, if any.
|
|
71806
|
+
* @returns The identity.
|
|
71807
|
+
*/
|
|
71808
|
+
function identityAt(parentIdentity, node, index, old) {
|
|
71809
|
+
if (old !== void 0 && isIdentityOf(old.identity, parentIdentity, node, index)) return old.identity;
|
|
71810
|
+
return identityOf(parentIdentity, node, index);
|
|
71811
|
+
}
|
|
71575
71812
|
/**
|
|
71576
71813
|
* Gives the subtree of a component the key the component tag carried, so the element is
|
|
71577
71814
|
* addressable under the name the markup wrote.
|
|
@@ -71886,6 +72123,46 @@ function entitySet(entities) {
|
|
|
71886
72123
|
return new Set(entities);
|
|
71887
72124
|
}
|
|
71888
72125
|
/**
|
|
72126
|
+
* Tells whether the entities a diff placed are a child list as it stands: the same entities in the
|
|
72127
|
+
* same order.
|
|
72128
|
+
*
|
|
72129
|
+
* @param placed - The entities of this render, a scratch buffer.
|
|
72130
|
+
* @param count - How many of them this render placed.
|
|
72131
|
+
* @param children - The child list of the last diff.
|
|
72132
|
+
* @returns True when the list stays.
|
|
72133
|
+
*/
|
|
72134
|
+
function sameEntities(placed, count, children) {
|
|
72135
|
+
if (count !== children.length) return false;
|
|
72136
|
+
for (let index = 0; index < count; index += 1) if (placed[index] !== children[index]) return false;
|
|
72137
|
+
return true;
|
|
72138
|
+
}
|
|
72139
|
+
/**
|
|
72140
|
+
* The change record a reconciler writes every compare into, before its first compare.
|
|
72141
|
+
*
|
|
72142
|
+
* @returns A record with no flag set and an empty style.
|
|
72143
|
+
*/
|
|
72144
|
+
function emptyChange() {
|
|
72145
|
+
return {
|
|
72146
|
+
is: {
|
|
72147
|
+
pressed: false,
|
|
72148
|
+
hover: false,
|
|
72149
|
+
focus: false,
|
|
72150
|
+
disabled: false,
|
|
72151
|
+
active: false,
|
|
72152
|
+
selected: false,
|
|
72153
|
+
covered: false
|
|
72154
|
+
},
|
|
72155
|
+
style: {},
|
|
72156
|
+
rowHeight: void 0,
|
|
72157
|
+
resolved: false,
|
|
72158
|
+
moved: false,
|
|
72159
|
+
measures: false,
|
|
72160
|
+
keepsText: false,
|
|
72161
|
+
keepsKey: false,
|
|
72162
|
+
unchanged: false
|
|
72163
|
+
};
|
|
72164
|
+
}
|
|
72165
|
+
/**
|
|
71889
72166
|
* Collects the identities of the children of one render. Its own function, because lint rule L5
|
|
71890
72167
|
* refuses a collection built inside an exported declaration.
|
|
71891
72168
|
*
|
|
@@ -71981,6 +72258,35 @@ function createReconciler(ctx, modules, fields) {
|
|
|
71981
72258
|
whole: (element, value) => writeValue(element, value),
|
|
71982
72259
|
others: (element, type, next) => writeOthers(element, next, type)
|
|
71983
72260
|
};
|
|
72261
|
+
const change = emptyChange();
|
|
72262
|
+
let expandedNode;
|
|
72263
|
+
let expandedInstance;
|
|
72264
|
+
const identityStack = [];
|
|
72265
|
+
const entityStack = [];
|
|
72266
|
+
let depth = 0;
|
|
72267
|
+
let viewportMoved = false;
|
|
72268
|
+
let dirtyCount = 0;
|
|
72269
|
+
let pendingCount = 0;
|
|
72270
|
+
let scrollsAside = false;
|
|
72271
|
+
const listDirty = (root) => {
|
|
72272
|
+
if (state.removing.has(root.entity)) return;
|
|
72273
|
+
if (viewportMoved) root.needsSolve = true;
|
|
72274
|
+
else if (!root.dirty) return;
|
|
72275
|
+
dirtyList[dirtyCount] = root;
|
|
72276
|
+
dirtyCount += 1;
|
|
72277
|
+
};
|
|
72278
|
+
const notePending = (root) => {
|
|
72279
|
+
const waits = root.element !== void 0 && lookup(root.element) !== void 0 && (root.needsSolve || root.slot !== void 0);
|
|
72280
|
+
root.pending = waits;
|
|
72281
|
+
if (waits) pendingCount += 1;
|
|
72282
|
+
};
|
|
72283
|
+
const listScroll = (entity) => {
|
|
72284
|
+
const element = state.elements.get(entity);
|
|
72285
|
+
if (element?.live !== true) return;
|
|
72286
|
+
if (parts.working() && parts.waits(state.roots.get(element.root))) return;
|
|
72287
|
+
if (!scrollsAside && isAsideScroll(element)) return;
|
|
72288
|
+
scrollList.push(element);
|
|
72289
|
+
};
|
|
71984
72290
|
/**
|
|
71985
72291
|
* Registers the key of an element under its root, so `find` and `entityOf` answer for it. A key
|
|
71986
72292
|
* `ui` gave a node of its own, a spacer's, is never registered. A root built aside or held warm
|
|
@@ -72375,10 +72681,12 @@ function createReconciler(ctx, modules, fields) {
|
|
|
72375
72681
|
function compare(root, element, node) {
|
|
72376
72682
|
const previous = element.node;
|
|
72377
72683
|
const parent = parentOf(element);
|
|
72378
|
-
const
|
|
72379
|
-
|
|
72380
|
-
|
|
72381
|
-
|
|
72684
|
+
const declared = node.props.state;
|
|
72685
|
+
const kept = element.is;
|
|
72686
|
+
const is = kept.covered === root.covered && kept.disabled === (declared?.disabled === true) && kept.active === (declared?.active === true) && kept.selected === (declared?.selected === true) ? kept : isFlagsOf(node, {
|
|
72687
|
+
pressed: kept.pressed,
|
|
72688
|
+
hover: kept.hover,
|
|
72689
|
+
focus: kept.focus,
|
|
72382
72690
|
covered: root.covered
|
|
72383
72691
|
});
|
|
72384
72692
|
const rowHeight = range.rowHeightOf(parent, node);
|
|
@@ -72388,17 +72696,16 @@ function createReconciler(ctx, modules, fields) {
|
|
|
72388
72696
|
const style = keepsStyle ? element.style : styleFor(parent, node, is);
|
|
72389
72697
|
const sameContent = sameValue(previous.props.content, node.props.content);
|
|
72390
72698
|
const keepsKey = namedKeyOf(element.style, previous.props.style) === namedKeyOf(style, node.props.style);
|
|
72391
|
-
|
|
72392
|
-
|
|
72393
|
-
|
|
72394
|
-
|
|
72395
|
-
|
|
72396
|
-
|
|
72397
|
-
|
|
72398
|
-
|
|
72399
|
-
|
|
72400
|
-
|
|
72401
|
-
};
|
|
72699
|
+
change.is = is;
|
|
72700
|
+
change.style = style;
|
|
72701
|
+
change.rowHeight = rowHeight;
|
|
72702
|
+
change.resolved = !keepsStyle;
|
|
72703
|
+
change.moved = !keepsStyle && modules.layout.affectsRect(element.style, style);
|
|
72704
|
+
change.measures = !stands || !sameStyle || !sameContent;
|
|
72705
|
+
change.keepsText = sameStyle && sameContent && sameValue(previous.props.bind, node.props.bind);
|
|
72706
|
+
change.keepsKey = keepsKey;
|
|
72707
|
+
change.unchanged = keepsStyle && sameContent && writesSame(previous, node);
|
|
72708
|
+
return change;
|
|
72402
72709
|
}
|
|
72403
72710
|
/**
|
|
72404
72711
|
* Writes what a patch changed on one element: its style onto the layout node when a rect or a
|
|
@@ -72410,15 +72717,16 @@ function createReconciler(ctx, modules, fields) {
|
|
|
72410
72717
|
* @param change - What the patch found.
|
|
72411
72718
|
*/
|
|
72412
72719
|
function rewrite(root, element, change) {
|
|
72413
|
-
const
|
|
72720
|
+
const { moved, keepsText, keepsKey } = change;
|
|
72721
|
+
const applies = moved || change.measures;
|
|
72414
72722
|
if (change.resolved || applies) state.styled += 1;
|
|
72415
72723
|
if (applies) {
|
|
72416
72724
|
modules.layout.applyStyle(element);
|
|
72417
72725
|
root.needsSolve = true;
|
|
72418
72726
|
}
|
|
72419
72727
|
if (!element.live) return;
|
|
72420
|
-
writeLive(element,
|
|
72421
|
-
if (!
|
|
72728
|
+
writeLive(element, keepsText, keepsKey);
|
|
72729
|
+
if (!moved) modules.layout.repose(element, parentRect(element), false, hintOf(state, element));
|
|
72422
72730
|
}
|
|
72423
72731
|
/**
|
|
72424
72732
|
* Updates one live element from its new node. An element whose description says what it said is
|
|
@@ -72439,11 +72747,12 @@ function createReconciler(ctx, modules, fields) {
|
|
|
72439
72747
|
checkWindow(node);
|
|
72440
72748
|
warnAxis(element, node);
|
|
72441
72749
|
const change = compare(root, element, node);
|
|
72750
|
+
const { unchanged, rowHeight } = change;
|
|
72442
72751
|
const motion = node.props.motion;
|
|
72443
72752
|
const loopChanged = !sameLoop(element.motion?.loop, motion?.loop);
|
|
72444
72753
|
const motionChanged = motion !== element.motion;
|
|
72445
72754
|
if (typeof __MOKU_GAME_DEV__ !== "undefined" && __MOKU_GAME_DEV__) countRebuild(element, element.motion?.loop, motion?.loop);
|
|
72446
|
-
if (!
|
|
72755
|
+
if (!unchanged) delete element.basis;
|
|
72447
72756
|
element.node = node;
|
|
72448
72757
|
element.is = change.is;
|
|
72449
72758
|
element.style = change.style;
|
|
@@ -72452,11 +72761,11 @@ function createReconciler(ctx, modules, fields) {
|
|
|
72452
72761
|
trackHost(state, element);
|
|
72453
72762
|
if (element.type === "input") fields.patch(element);
|
|
72454
72763
|
if (loopChanged && element.entered) modules.layout.loop(element);
|
|
72455
|
-
if (!
|
|
72764
|
+
if (!unchanged) {
|
|
72456
72765
|
rewrite(root, element, change);
|
|
72457
72766
|
element.basis = {
|
|
72458
72767
|
epoch: state.epoch,
|
|
72459
|
-
rowHeight
|
|
72768
|
+
rowHeight
|
|
72460
72769
|
};
|
|
72461
72770
|
}
|
|
72462
72771
|
if (typeof __MOKU_GAME_DEV__ !== "undefined" && __MOKU_GAME_DEV__ && motionChanged && element.live) warnIdleChanges(ctx, element);
|
|
@@ -72498,24 +72807,23 @@ function createReconciler(ctx, modules, fields) {
|
|
|
72498
72807
|
}
|
|
72499
72808
|
/**
|
|
72500
72809
|
* Expands a component node with its instance, so the view runs with the local state of that
|
|
72501
|
-
* identity.
|
|
72810
|
+
* identity. The subtree to place goes to `expandedNode`, the instance it belongs to to
|
|
72811
|
+
* `expandedInstance`: no object is built, and the caller reads both before it places anything.
|
|
72502
72812
|
*
|
|
72503
72813
|
* @param node - The node the markup wrote.
|
|
72504
72814
|
* @param identity - Its identity.
|
|
72505
|
-
* @returns The subtree to place and the instance it belongs to.
|
|
72506
72815
|
*/
|
|
72507
72816
|
function expand(node, identity) {
|
|
72508
72817
|
const definition = state.components.get(node.type);
|
|
72509
|
-
if (definition === void 0)
|
|
72510
|
-
node
|
|
72511
|
-
|
|
72512
|
-
|
|
72818
|
+
if (definition === void 0) {
|
|
72819
|
+
expandedNode = node;
|
|
72820
|
+
expandedInstance = void 0;
|
|
72821
|
+
return;
|
|
72822
|
+
}
|
|
72513
72823
|
const instance = instanceFor(state, identity, definition, node.props);
|
|
72514
72824
|
instance.dirty = false;
|
|
72515
|
-
|
|
72516
|
-
|
|
72517
|
-
instance: identity
|
|
72518
|
-
};
|
|
72825
|
+
expandedNode = runView(ctx, definition, instance, node.key);
|
|
72826
|
+
expandedInstance = identity;
|
|
72519
72827
|
}
|
|
72520
72828
|
/**
|
|
72521
72829
|
* Places one node: enter, patch, or exit and enter when the element at its identity is another
|
|
@@ -72532,10 +72840,11 @@ function createReconciler(ctx, modules, fields) {
|
|
|
72532
72840
|
* @returns The entity of the element, or `undefined` when a component view threw.
|
|
72533
72841
|
*/
|
|
72534
72842
|
function diffNode(root, parent, node, index, identity, instance) {
|
|
72535
|
-
|
|
72536
|
-
const view =
|
|
72537
|
-
const
|
|
72538
|
-
const
|
|
72843
|
+
expand(node, identity);
|
|
72844
|
+
const view = expandedNode;
|
|
72845
|
+
const expansion = expandedInstance;
|
|
72846
|
+
const owner = expansion ?? instance;
|
|
72847
|
+
const effective = view !== void 0 && expansion !== void 0 ? withKey(view, node.key) : view;
|
|
72539
72848
|
if (effective === void 0) return state.byIdentity.get(identity);
|
|
72540
72849
|
const existing = state.byIdentity.get(identity);
|
|
72541
72850
|
const element = existing === void 0 ? void 0 : state.elements.get(existing);
|
|
@@ -72569,22 +72878,67 @@ function createReconciler(ctx, modules, fields) {
|
|
|
72569
72878
|
* @param instance - The identity of the nearest component instance.
|
|
72570
72879
|
*/
|
|
72571
72880
|
function diffChildren(root, parent, nodes, instance) {
|
|
72572
|
-
const
|
|
72573
|
-
|
|
72574
|
-
|
|
72575
|
-
|
|
72576
|
-
|
|
72577
|
-
|
|
72881
|
+
const level = depth;
|
|
72882
|
+
depth += 1;
|
|
72883
|
+
try {
|
|
72884
|
+
diffChildrenAt(root, parent, nodes, instance, level);
|
|
72885
|
+
} finally {
|
|
72886
|
+
depth = level;
|
|
72887
|
+
}
|
|
72888
|
+
}
|
|
72889
|
+
/**
|
|
72890
|
+
* The diff of `diffChildren` on the scratch buffers of one depth: the identities of this render
|
|
72891
|
+
* and the entities they placed, counted, so an element whose children stayed builds no array, no
|
|
72892
|
+
* set and no string, and keeps its child list.
|
|
72893
|
+
*
|
|
72894
|
+
* @param root - The root being reconciled.
|
|
72895
|
+
* @param parent - The element whose children are diffed.
|
|
72896
|
+
* @param nodes - The children of this render.
|
|
72897
|
+
* @param instance - The identity of the nearest component instance.
|
|
72898
|
+
* @param level - The depth whose buffers this diff uses.
|
|
72899
|
+
*/
|
|
72900
|
+
function diffChildrenAt(root, parent, nodes, instance, level) {
|
|
72901
|
+
const identities = identityStack[level] ?? [];
|
|
72902
|
+
const placed = entityStack[level] ?? [];
|
|
72903
|
+
const before = parent.children;
|
|
72904
|
+
identityStack[level] = identities;
|
|
72905
|
+
entityStack[level] = placed;
|
|
72906
|
+
for (let index = 0; index < nodes.length; index += 1) {
|
|
72907
|
+
const node = nodes[index];
|
|
72908
|
+
const old = before[index];
|
|
72909
|
+
if (node === void 0) continue;
|
|
72910
|
+
identities[index] = identityAt(parent.identity, node, index, old === void 0 ? void 0 : state.elements.get(old));
|
|
72578
72911
|
}
|
|
72912
|
+
leaveOut(parent, identities, nodes.length);
|
|
72913
|
+
let count = 0;
|
|
72914
|
+
for (let index = 0; index < nodes.length; index += 1) {
|
|
72915
|
+
const node = nodes[index];
|
|
72916
|
+
if (node === void 0) continue;
|
|
72917
|
+
const identity = identities[index] ?? identityOf(parent.identity, node, index);
|
|
72918
|
+
const entity = diffNode(root, parent, node, index, identity, instance);
|
|
72919
|
+
if (entity === void 0) continue;
|
|
72920
|
+
placed[count] = entity;
|
|
72921
|
+
count += 1;
|
|
72922
|
+
}
|
|
72923
|
+
if (sameEntities(placed, count, parent.children)) return;
|
|
72924
|
+
commitChildren(root, parent, placed.slice(0, count));
|
|
72925
|
+
}
|
|
72926
|
+
/**
|
|
72927
|
+
* Makes a changed list of children the parent's: an old child no entity of this render took leaves,
|
|
72928
|
+
* the new ones are drawn in the order of the render and laid out again, and the root solves again.
|
|
72929
|
+
*
|
|
72930
|
+
* @param root - The root being reconciled.
|
|
72931
|
+
* @param parent - The element whose children changed.
|
|
72932
|
+
* @param next - The entities of this render, in markup order.
|
|
72933
|
+
*/
|
|
72934
|
+
function commitChildren(root, parent, next) {
|
|
72579
72935
|
const kept = entitySet(next);
|
|
72580
72936
|
for (const old of parent.children) {
|
|
72581
72937
|
if (kept.has(old) || state.exiting.has(old)) continue;
|
|
72582
72938
|
const element = state.elements.get(old);
|
|
72583
72939
|
if (element !== void 0) removeChild(parent, element);
|
|
72584
72940
|
}
|
|
72585
|
-
const same = next.length === parent.children.length && next.every((entity, index) => parent.children[index] === entity);
|
|
72586
72941
|
parent.children = next;
|
|
72587
|
-
if (same) return;
|
|
72588
72942
|
placeChildren(parent, next);
|
|
72589
72943
|
modules.layout.place(parent, next.map((entity) => state.elements.get(entity)).filter((element) => isElement(element)));
|
|
72590
72944
|
root.needsSolve = true;
|
|
@@ -72630,14 +72984,18 @@ function createReconciler(ctx, modules, fields) {
|
|
|
72630
72984
|
* starts, and everything under it plays its own, before a new child enters.
|
|
72631
72985
|
*
|
|
72632
72986
|
* @param parent - The element whose children are diffed.
|
|
72633
|
-
* @param identities - The identities of the children of this render, in markup order
|
|
72987
|
+
* @param identities - The identities of the children of this render, in markup order; a scratch
|
|
72988
|
+
* buffer, of which the first `count` are this render's.
|
|
72989
|
+
* @param count - How many children this render has.
|
|
72634
72990
|
*/
|
|
72635
|
-
function leaveOut(parent, identities) {
|
|
72991
|
+
function leaveOut(parent, identities, count) {
|
|
72636
72992
|
let listed;
|
|
72637
|
-
|
|
72638
|
-
|
|
72639
|
-
|
|
72640
|
-
|
|
72993
|
+
const children = parent.children;
|
|
72994
|
+
for (let index = 0; index < children.length; index += 1) {
|
|
72995
|
+
const old = children[index];
|
|
72996
|
+
const element = old === void 0 ? void 0 : state.elements.get(old);
|
|
72997
|
+
if (element === void 0 || index < count && identities[index] === element.identity) continue;
|
|
72998
|
+
listed ??= identitySet(identities.slice(0, count));
|
|
72641
72999
|
if (!listed.has(element.identity)) removeChild(parent, element);
|
|
72642
73000
|
}
|
|
72643
73001
|
}
|
|
@@ -73025,13 +73383,9 @@ function createReconciler(ctx, modules, fields) {
|
|
|
73025
73383
|
* @returns How many roots wait.
|
|
73026
73384
|
*/
|
|
73027
73385
|
function pendingRoots() {
|
|
73028
|
-
|
|
73029
|
-
|
|
73030
|
-
|
|
73031
|
-
root.pending = waits;
|
|
73032
|
-
if (waits) count += 1;
|
|
73033
|
-
}
|
|
73034
|
-
return count;
|
|
73386
|
+
pendingCount = 0;
|
|
73387
|
+
state.roots.forEach(notePending);
|
|
73388
|
+
return pendingCount;
|
|
73035
73389
|
}
|
|
73036
73390
|
/**
|
|
73037
73391
|
* The box a root in a slot is solved in: the slot's content box, once the slot's own root needs
|
|
@@ -73300,10 +73654,10 @@ function createReconciler(ctx, modules, fields) {
|
|
|
73300
73654
|
* @param root - The root to reconcile.
|
|
73301
73655
|
*/
|
|
73302
73656
|
function reconcileRoot(root) {
|
|
73303
|
-
const identity = identityOf(String(root.entity), root.tree, 0);
|
|
73304
73657
|
const first = root.element === void 0;
|
|
73305
73658
|
if (first) root.cause ??= ctx.deps.world.projection.causeOf(root.entity) ?? "change";
|
|
73306
73659
|
const previous = root.element === void 0 ? void 0 : lookup(root.element);
|
|
73660
|
+
const identity = identityAt(String(root.entity), root.tree, 0, previous);
|
|
73307
73661
|
if (previous !== void 0 && previous.identity !== identity) exitElement(previous, "change");
|
|
73308
73662
|
state.building = first ? root.cause : "change";
|
|
73309
73663
|
try {
|
|
@@ -73325,13 +73679,8 @@ function createReconciler(ctx, modules, fields) {
|
|
|
73325
73679
|
*/
|
|
73326
73680
|
function scrollContainers(aside) {
|
|
73327
73681
|
while (scrollList.length > 0) scrollList.pop();
|
|
73328
|
-
|
|
73329
|
-
|
|
73330
|
-
if (element?.live !== true) continue;
|
|
73331
|
-
if (parts.working() && parts.waits(state.roots.get(element.root))) continue;
|
|
73332
|
-
if (!aside && isAsideScroll(element)) continue;
|
|
73333
|
-
scrollList.push(element);
|
|
73334
|
-
}
|
|
73682
|
+
scrollsAside = aside;
|
|
73683
|
+
state.scrolls.forEach(listScroll);
|
|
73335
73684
|
return scrollList;
|
|
73336
73685
|
}
|
|
73337
73686
|
/**
|
|
@@ -73346,15 +73695,10 @@ function createReconciler(ctx, modules, fields) {
|
|
|
73346
73695
|
const root = state.roots.get(entity);
|
|
73347
73696
|
if (root !== void 0 && !state.removing.has(entity)) root.dirty = true;
|
|
73348
73697
|
}
|
|
73349
|
-
|
|
73350
|
-
|
|
73351
|
-
|
|
73352
|
-
|
|
73353
|
-
else if (!root.dirty) continue;
|
|
73354
|
-
dirtyList[count] = root;
|
|
73355
|
-
count += 1;
|
|
73356
|
-
}
|
|
73357
|
-
return count;
|
|
73698
|
+
dirtyCount = 0;
|
|
73699
|
+
viewportMoved = viewportChanged;
|
|
73700
|
+
state.roots.forEach(listDirty);
|
|
73701
|
+
return dirtyCount;
|
|
73358
73702
|
}
|
|
73359
73703
|
/**
|
|
73360
73704
|
* Takes the order the projection wrote on a root's entity (spec 16 U1.6) and gives it to the
|
|
@@ -73904,6 +74248,44 @@ const LAYOUT_FIELDS = [
|
|
|
73904
74248
|
"right",
|
|
73905
74249
|
"bottom"
|
|
73906
74250
|
];
|
|
74251
|
+
const FLEX_DIRECTION = 0;
|
|
74252
|
+
const FLEX_WRAP = 1;
|
|
74253
|
+
const JUSTIFY = 2;
|
|
74254
|
+
const ALIGN_ITEMS = 3;
|
|
74255
|
+
const ALIGN_SELF = 4;
|
|
74256
|
+
const GROW = 5;
|
|
74257
|
+
const SHRINK = 6;
|
|
74258
|
+
const ASPECT = 7;
|
|
74259
|
+
const OVERFLOW = 8;
|
|
74260
|
+
const POSITION_TYPE = 9;
|
|
74261
|
+
const GAP = 10;
|
|
74262
|
+
/** The first padding length; the edges follow in the order top, right, bottom, left. */
|
|
74263
|
+
const PADDING = 12;
|
|
74264
|
+
/** The first margin length, in the same edge order. */
|
|
74265
|
+
const MARGIN = 20;
|
|
74266
|
+
const WIDTH = 28;
|
|
74267
|
+
const HEIGHT = 30;
|
|
74268
|
+
const MIN_WIDTH = 32;
|
|
74269
|
+
const MIN_HEIGHT = 34;
|
|
74270
|
+
const MAX_WIDTH = 36;
|
|
74271
|
+
const MAX_HEIGHT = 38;
|
|
74272
|
+
const LEFT = 40;
|
|
74273
|
+
const TOP = 42;
|
|
74274
|
+
const RIGHT = 44;
|
|
74275
|
+
const BOTTOM = 46;
|
|
74276
|
+
/** Slots of a kept record. */
|
|
74277
|
+
const SLOTS = 48;
|
|
74278
|
+
/**
|
|
74279
|
+
* The kind of a length a number writes, and of an unset length (its number `NaN`). It is 0, so a
|
|
74280
|
+
* new record holds it in every kind slot: the gap, the edges and the positions only ever take it.
|
|
74281
|
+
*/
|
|
74282
|
+
const POINT = 0;
|
|
74283
|
+
/** The kind of a length a percent string writes. */
|
|
74284
|
+
const PERCENT = 1;
|
|
74285
|
+
/** The kind of a length `"auto"` writes; its number is `NaN`. */
|
|
74286
|
+
const AUTO = 2;
|
|
74287
|
+
/** The kind a staged extent takes when the style writes nothing for it. Never kept. */
|
|
74288
|
+
const SKIP = -1;
|
|
73907
74289
|
/**
|
|
73908
74290
|
* Tells whether two resolved styles would give the same rect.
|
|
73909
74291
|
*
|
|
@@ -73921,6 +74303,266 @@ function layoutChanged(first, second) {
|
|
|
73921
74303
|
return false;
|
|
73922
74304
|
}
|
|
73923
74305
|
/**
|
|
74306
|
+
* Reads what a node Yoga just made holds into a kept record: the enums and the flex factors through
|
|
74307
|
+
* their getters, once. A length is not read: its getter answers a `Value` object, so it starts
|
|
74308
|
+
* as Yoga's unset one, a point of `NaN`. The aspect ratio starts as one no style writes, so the
|
|
74309
|
+
* first write of every node calls `setAspectRatio`: the `isDirty()` of a node that never had
|
|
74310
|
+
* it called allocates 64 B a call (measured, `anchor.perf.ts`; a ratio of `NaN` does not cure it).
|
|
74311
|
+
*
|
|
74312
|
+
* @param yoga - The loaded Yoga module.
|
|
74313
|
+
* @returns The record of a fresh node.
|
|
74314
|
+
*/
|
|
74315
|
+
function readFresh(yoga) {
|
|
74316
|
+
const node = yoga.Node.create();
|
|
74317
|
+
const fresh = new Float64Array(SLOTS);
|
|
74318
|
+
fresh[FLEX_DIRECTION] = node.getFlexDirection();
|
|
74319
|
+
fresh[FLEX_WRAP] = node.getFlexWrap();
|
|
74320
|
+
fresh[JUSTIFY] = node.getJustifyContent();
|
|
74321
|
+
fresh[ALIGN_ITEMS] = node.getAlignItems();
|
|
74322
|
+
fresh[ALIGN_SELF] = node.getAlignSelf();
|
|
74323
|
+
fresh[GROW] = node.getFlexGrow();
|
|
74324
|
+
fresh[SHRINK] = node.getFlexShrink();
|
|
74325
|
+
fresh[OVERFLOW] = node.getOverflow();
|
|
74326
|
+
fresh[POSITION_TYPE] = node.getPositionType();
|
|
74327
|
+
node.free();
|
|
74328
|
+
for (let slot = 11; slot < SLOTS; slot += 2) fresh[slot] = NaN;
|
|
74329
|
+
fresh[ASPECT] = Number.NEGATIVE_INFINITY;
|
|
74330
|
+
return fresh;
|
|
74331
|
+
}
|
|
74332
|
+
/**
|
|
74333
|
+
* Builds the tables a style write reads for one loaded Yoga module: the enum of every word a style
|
|
74334
|
+
* names, what a fresh node holds, read once from a node made for it, and the record a write stages
|
|
74335
|
+
* its numbers in.
|
|
74336
|
+
*
|
|
74337
|
+
* @param yoga - The loaded Yoga module.
|
|
74338
|
+
* @returns The tables.
|
|
74339
|
+
*/
|
|
74340
|
+
function styleTablesOf(yoga) {
|
|
74341
|
+
return {
|
|
74342
|
+
yoga,
|
|
74343
|
+
justify: {
|
|
74344
|
+
start: yoga.JUSTIFY_FLEX_START,
|
|
74345
|
+
center: yoga.JUSTIFY_CENTER,
|
|
74346
|
+
end: yoga.JUSTIFY_FLEX_END,
|
|
74347
|
+
between: yoga.JUSTIFY_SPACE_BETWEEN,
|
|
74348
|
+
around: yoga.JUSTIFY_SPACE_AROUND,
|
|
74349
|
+
evenly: yoga.JUSTIFY_SPACE_EVENLY
|
|
74350
|
+
},
|
|
74351
|
+
align: {
|
|
74352
|
+
start: yoga.ALIGN_FLEX_START,
|
|
74353
|
+
center: yoga.ALIGN_CENTER,
|
|
74354
|
+
end: yoga.ALIGN_FLEX_END,
|
|
74355
|
+
stretch: yoga.ALIGN_STRETCH
|
|
74356
|
+
},
|
|
74357
|
+
alignSelf: {
|
|
74358
|
+
auto: yoga.ALIGN_AUTO,
|
|
74359
|
+
start: yoga.ALIGN_FLEX_START,
|
|
74360
|
+
center: yoga.ALIGN_CENTER,
|
|
74361
|
+
end: yoga.ALIGN_FLEX_END,
|
|
74362
|
+
stretch: yoga.ALIGN_STRETCH
|
|
74363
|
+
},
|
|
74364
|
+
overflow: {
|
|
74365
|
+
visible: yoga.OVERFLOW_VISIBLE,
|
|
74366
|
+
hidden: yoga.OVERFLOW_HIDDEN,
|
|
74367
|
+
scroll: yoga.OVERFLOW_SCROLL
|
|
74368
|
+
},
|
|
74369
|
+
fresh: readFresh(yoga),
|
|
74370
|
+
staged: new Float64Array(SLOTS)
|
|
74371
|
+
};
|
|
74372
|
+
}
|
|
74373
|
+
/**
|
|
74374
|
+
* The kept record of a node Yoga just made: a copy of what the tables read off a fresh node.
|
|
74375
|
+
*
|
|
74376
|
+
* @param tables - The tables of the loaded Yoga module.
|
|
74377
|
+
* @returns A record of its own.
|
|
74378
|
+
*/
|
|
74379
|
+
function freshKept(tables) {
|
|
74380
|
+
return new Float64Array(tables.fresh);
|
|
74381
|
+
}
|
|
74382
|
+
/**
|
|
74383
|
+
* Notes a width and a height written onto a node outside a style write, as the anchor pass sizes
|
|
74384
|
+
* the tree of an anchor, so a later style write that sets them back is not skipped.
|
|
74385
|
+
*
|
|
74386
|
+
* @param kept - The node's kept record; none for a node `ui` did not make.
|
|
74387
|
+
* @param size - The width and the height written, in points. Read here, not handed over as two
|
|
74388
|
+
* numbers: a fractional number passed to a call V8 does not inline is boxed.
|
|
74389
|
+
* @param size.w - The width.
|
|
74390
|
+
* @param size.h - The height.
|
|
74391
|
+
*/
|
|
74392
|
+
function keepSize(kept, size) {
|
|
74393
|
+
if (kept === void 0) return;
|
|
74394
|
+
kept[WIDTH] = POINT;
|
|
74395
|
+
kept[29] = size.w;
|
|
74396
|
+
kept[HEIGHT] = POINT;
|
|
74397
|
+
kept[31] = size.h;
|
|
74398
|
+
}
|
|
74399
|
+
/**
|
|
74400
|
+
* Whether an enum must be written, and keeps it when it must. With no record every value is
|
|
74401
|
+
* written, as before the records.
|
|
74402
|
+
*
|
|
74403
|
+
* @param kept - The node's kept record.
|
|
74404
|
+
* @param slot - The enum's slot.
|
|
74405
|
+
* @param value - The enum of this write.
|
|
74406
|
+
* @returns True when the setter must be called.
|
|
74407
|
+
*/
|
|
74408
|
+
function enumMoved(kept, slot, value) {
|
|
74409
|
+
if (kept === void 0) return true;
|
|
74410
|
+
if (kept[slot] === value) return false;
|
|
74411
|
+
kept[slot] = value;
|
|
74412
|
+
return true;
|
|
74413
|
+
}
|
|
74414
|
+
/**
|
|
74415
|
+
* Whether a staged number must be written, and keeps it when it must: it differs from the kept
|
|
74416
|
+
* one unless both are equal or both unset (`NaN`).
|
|
74417
|
+
*
|
|
74418
|
+
* @param kept - The node's kept record.
|
|
74419
|
+
* @param staged - The staged values of this write.
|
|
74420
|
+
* @param slot - The number's slot.
|
|
74421
|
+
* @returns True when the setter must be called.
|
|
74422
|
+
*/
|
|
74423
|
+
function numberMoved(kept, staged, slot) {
|
|
74424
|
+
if (kept === void 0) return true;
|
|
74425
|
+
const before = kept[slot];
|
|
74426
|
+
const after = staged[slot];
|
|
74427
|
+
if (before === after || Number.isNaN(before) && Number.isNaN(after)) return false;
|
|
74428
|
+
kept[slot] = after ?? NaN;
|
|
74429
|
+
return true;
|
|
74430
|
+
}
|
|
74431
|
+
/**
|
|
74432
|
+
* Whether a staged length must be written, and keeps it when it must: its kind and its number
|
|
74433
|
+
* both stand, or it is staged as nothing to write.
|
|
74434
|
+
*
|
|
74435
|
+
* @param kept - The node's kept record.
|
|
74436
|
+
* @param staged - The staged values of this write.
|
|
74437
|
+
* @param slot - The length's first slot.
|
|
74438
|
+
* @returns True when the setter must be called.
|
|
74439
|
+
*/
|
|
74440
|
+
function lengthMoved(kept, staged, slot) {
|
|
74441
|
+
const kind = staged[slot];
|
|
74442
|
+
if (kind === SKIP) return false;
|
|
74443
|
+
if (kept === void 0) return true;
|
|
74444
|
+
if (kept[slot] === kind && !numberMoved(kept, staged, slot + 1)) return false;
|
|
74445
|
+
kept[slot] = kind ?? POINT;
|
|
74446
|
+
kept[slot + 1] = staged[slot + 1] ?? NaN;
|
|
74447
|
+
return true;
|
|
74448
|
+
}
|
|
74449
|
+
/** Where each edge's number sits from the first slot of a padding or margin (a kind comes first). */
|
|
74450
|
+
const EDGE_TOP_AT = 1;
|
|
74451
|
+
const EDGE_RIGHT_AT = 3;
|
|
74452
|
+
const EDGE_BOTTOM_AT = 5;
|
|
74453
|
+
const EDGE_LEFT_AT = 7;
|
|
74454
|
+
/**
|
|
74455
|
+
* Stages the four edges of a padding or margin given per edge; an edge it leaves out is unset.
|
|
74456
|
+
*
|
|
74457
|
+
* @param staged - The staged values of this write.
|
|
74458
|
+
* @param slot - The first slot of the four lengths.
|
|
74459
|
+
* @param edges - The edges.
|
|
74460
|
+
* @param edges.top - The top edge.
|
|
74461
|
+
* @param edges.right - The right edge.
|
|
74462
|
+
* @param edges.bottom - The bottom edge.
|
|
74463
|
+
* @param edges.left - The left edge.
|
|
74464
|
+
*/
|
|
74465
|
+
function stageSides(staged, slot, edges) {
|
|
74466
|
+
staged[slot + EDGE_TOP_AT] = edges.top ?? NaN;
|
|
74467
|
+
staged[slot + EDGE_RIGHT_AT] = edges.right ?? NaN;
|
|
74468
|
+
staged[slot + EDGE_BOTTOM_AT] = edges.bottom ?? NaN;
|
|
74469
|
+
staged[slot + EDGE_LEFT_AT] = edges.left ?? NaN;
|
|
74470
|
+
}
|
|
74471
|
+
/**
|
|
74472
|
+
* Stages an extent that is not a number: a percent string, `"auto"`, or nothing. `undefined`
|
|
74473
|
+
* writes nothing, and so does `"auto"` on a min or max extent.
|
|
74474
|
+
*
|
|
74475
|
+
* @param staged - The staged values of this write.
|
|
74476
|
+
* @param slot - The extent's first slot.
|
|
74477
|
+
* @param value - What the style carries.
|
|
74478
|
+
* @param autoSkips - Whether `"auto"` writes nothing here.
|
|
74479
|
+
*/
|
|
74480
|
+
function stageWord(staged, slot, value, autoSkips) {
|
|
74481
|
+
if (value === void 0 || autoSkips && value === "auto") staged[slot] = SKIP;
|
|
74482
|
+
else if (value === "auto") {
|
|
74483
|
+
staged[slot] = AUTO;
|
|
74484
|
+
staged[slot + 1] = NaN;
|
|
74485
|
+
} else {
|
|
74486
|
+
staged[slot] = value.endsWith("%") ? PERCENT : POINT;
|
|
74487
|
+
staged[slot + 1] = Number.parseFloat(value);
|
|
74488
|
+
}
|
|
74489
|
+
}
|
|
74490
|
+
/**
|
|
74491
|
+
* Stages the edges of the padding and the margin.
|
|
74492
|
+
*
|
|
74493
|
+
* @param staged - The staged values of this write.
|
|
74494
|
+
* @param style - The resolved style.
|
|
74495
|
+
*/
|
|
74496
|
+
function stageEdges(staged, style) {
|
|
74497
|
+
const { padding, margin } = style;
|
|
74498
|
+
if (typeof padding === "object") stageSides(staged, PADDING, padding);
|
|
74499
|
+
else {
|
|
74500
|
+
const all = padding ?? NaN;
|
|
74501
|
+
staged[13] = all;
|
|
74502
|
+
staged[15] = all;
|
|
74503
|
+
staged[17] = all;
|
|
74504
|
+
staged[19] = all;
|
|
74505
|
+
}
|
|
74506
|
+
if (typeof margin === "object") stageSides(staged, MARGIN, margin);
|
|
74507
|
+
else {
|
|
74508
|
+
const all = margin ?? NaN;
|
|
74509
|
+
staged[21] = all;
|
|
74510
|
+
staged[23] = all;
|
|
74511
|
+
staged[25] = all;
|
|
74512
|
+
staged[27] = all;
|
|
74513
|
+
}
|
|
74514
|
+
}
|
|
74515
|
+
/**
|
|
74516
|
+
* Stages the six extents and the aspect ratio. A number is staged here, where it is read; a word by
|
|
74517
|
+
* `stageWord`.
|
|
74518
|
+
*
|
|
74519
|
+
* @param staged - The staged values of this write.
|
|
74520
|
+
* @param style - The resolved style.
|
|
74521
|
+
*/
|
|
74522
|
+
function stageExtents(staged, style) {
|
|
74523
|
+
const { width, height, minWidth, minHeight, maxWidth, maxHeight } = style;
|
|
74524
|
+
if (typeof width === "number") {
|
|
74525
|
+
staged[WIDTH] = POINT;
|
|
74526
|
+
staged[29] = width;
|
|
74527
|
+
} else stageWord(staged, WIDTH, width, false);
|
|
74528
|
+
if (typeof height === "number") {
|
|
74529
|
+
staged[HEIGHT] = POINT;
|
|
74530
|
+
staged[31] = height;
|
|
74531
|
+
} else stageWord(staged, HEIGHT, height, false);
|
|
74532
|
+
if (typeof minWidth === "number") {
|
|
74533
|
+
staged[MIN_WIDTH] = POINT;
|
|
74534
|
+
staged[33] = minWidth;
|
|
74535
|
+
} else stageWord(staged, MIN_WIDTH, minWidth, true);
|
|
74536
|
+
if (typeof minHeight === "number") {
|
|
74537
|
+
staged[MIN_HEIGHT] = POINT;
|
|
74538
|
+
staged[35] = minHeight;
|
|
74539
|
+
} else stageWord(staged, MIN_HEIGHT, minHeight, true);
|
|
74540
|
+
if (typeof maxWidth === "number") {
|
|
74541
|
+
staged[MAX_WIDTH] = POINT;
|
|
74542
|
+
staged[37] = maxWidth;
|
|
74543
|
+
} else stageWord(staged, MAX_WIDTH, maxWidth, true);
|
|
74544
|
+
if (typeof maxHeight === "number") {
|
|
74545
|
+
staged[MAX_HEIGHT] = POINT;
|
|
74546
|
+
staged[39] = maxHeight;
|
|
74547
|
+
} else stageWord(staged, MAX_HEIGHT, maxHeight, true);
|
|
74548
|
+
staged[ASPECT] = style.aspect ?? NaN;
|
|
74549
|
+
}
|
|
74550
|
+
/**
|
|
74551
|
+
* Stages the numbers of the flow and position groups: gap, grow, shrink and the four positions.
|
|
74552
|
+
*
|
|
74553
|
+
* @param staged - The staged values of this write.
|
|
74554
|
+
* @param style - The resolved style.
|
|
74555
|
+
*/
|
|
74556
|
+
function stageFlowAndPosition(staged, style) {
|
|
74557
|
+
staged[11] = style.gap ?? 0;
|
|
74558
|
+
staged[GROW] = style.grow ?? 0;
|
|
74559
|
+
staged[SHRINK] = style.shrink ?? 0;
|
|
74560
|
+
staged[41] = style.left ?? NaN;
|
|
74561
|
+
staged[43] = style.top ?? NaN;
|
|
74562
|
+
staged[45] = style.right ?? NaN;
|
|
74563
|
+
staged[47] = style.bottom ?? NaN;
|
|
74564
|
+
}
|
|
74565
|
+
/**
|
|
73924
74566
|
* Reads one edge of a padding or margin.
|
|
73925
74567
|
*
|
|
73926
74568
|
* @param edges - What the resolved style carries.
|
|
@@ -73935,127 +74577,121 @@ function edge(edges, edge) {
|
|
|
73935
74577
|
/**
|
|
73936
74578
|
* Writes the flow group onto a node.
|
|
73937
74579
|
*
|
|
73938
|
-
* @param
|
|
74580
|
+
* @param tables - The tables of the loaded Yoga module, its numbers staged.
|
|
73939
74581
|
* @param node - The node of the element.
|
|
73940
74582
|
* @param style - The resolved style.
|
|
73941
74583
|
* @param column - Whether the tag lays its children out in a column.
|
|
74584
|
+
* @param kept - The node's kept record.
|
|
74585
|
+
*/
|
|
74586
|
+
function applyFlow(tables, node, style, column, kept) {
|
|
74587
|
+
const { yoga, staged } = tables;
|
|
74588
|
+
const direction = (style.direction ?? (column ? "column" : "row")) === "row" ? yoga.FLEX_DIRECTION_ROW : yoga.FLEX_DIRECTION_COLUMN;
|
|
74589
|
+
const wrap = style.wrap === true ? yoga.WRAP_WRAP : yoga.WRAP_NO_WRAP;
|
|
74590
|
+
const justify = tables.justify[style.justify ?? "start"];
|
|
74591
|
+
const align = tables.align[style.align ?? "stretch"];
|
|
74592
|
+
const alignSelf = tables.alignSelf[style.alignSelf ?? "auto"];
|
|
74593
|
+
if (enumMoved(kept, FLEX_DIRECTION, direction)) node.setFlexDirection(direction);
|
|
74594
|
+
if (enumMoved(kept, FLEX_WRAP, wrap)) node.setFlexWrap(wrap);
|
|
74595
|
+
if (enumMoved(kept, JUSTIFY, justify)) node.setJustifyContent(justify);
|
|
74596
|
+
if (enumMoved(kept, ALIGN_ITEMS, align)) node.setAlignItems(align);
|
|
74597
|
+
if (enumMoved(kept, ALIGN_SELF, alignSelf)) node.setAlignSelf(alignSelf);
|
|
74598
|
+
if (lengthMoved(kept, staged, GAP)) node.setGap(yoga.GUTTER_ALL, style.gap ?? 0);
|
|
74599
|
+
if (numberMoved(kept, staged, GROW)) node.setFlexGrow(style.grow ?? 0);
|
|
74600
|
+
if (numberMoved(kept, staged, SHRINK)) node.setFlexShrink(style.shrink ?? 0);
|
|
74601
|
+
}
|
|
74602
|
+
/**
|
|
74603
|
+
* Writes the padding and the margin of one edge.
|
|
74604
|
+
*
|
|
74605
|
+
* @param node - The node of the element.
|
|
74606
|
+
* @param style - The resolved style.
|
|
74607
|
+
* @param kept - The node's kept record.
|
|
74608
|
+
* @param staged - The staged values of this write.
|
|
74609
|
+
* @param side - The edge, by name.
|
|
74610
|
+
* @param index - Its place in the order top, right, bottom, left.
|
|
74611
|
+
* @param which - The edge, as Yoga names it.
|
|
73942
74612
|
*/
|
|
73943
|
-
function
|
|
73944
|
-
|
|
73945
|
-
|
|
73946
|
-
|
|
73947
|
-
|
|
73948
|
-
|
|
73949
|
-
|
|
73950
|
-
end: yoga.JUSTIFY_FLEX_END,
|
|
73951
|
-
between: yoga.JUSTIFY_SPACE_BETWEEN,
|
|
73952
|
-
around: yoga.JUSTIFY_SPACE_AROUND,
|
|
73953
|
-
evenly: yoga.JUSTIFY_SPACE_EVENLY
|
|
73954
|
-
}[style.justify ?? "start"]);
|
|
73955
|
-
node.setAlignItems({
|
|
73956
|
-
start: yoga.ALIGN_FLEX_START,
|
|
73957
|
-
center: yoga.ALIGN_CENTER,
|
|
73958
|
-
end: yoga.ALIGN_FLEX_END,
|
|
73959
|
-
stretch: yoga.ALIGN_STRETCH
|
|
73960
|
-
}[style.align ?? "stretch"]);
|
|
73961
|
-
node.setAlignSelf({
|
|
73962
|
-
auto: yoga.ALIGN_AUTO,
|
|
73963
|
-
start: yoga.ALIGN_FLEX_START,
|
|
73964
|
-
center: yoga.ALIGN_CENTER,
|
|
73965
|
-
end: yoga.ALIGN_FLEX_END,
|
|
73966
|
-
stretch: yoga.ALIGN_STRETCH
|
|
73967
|
-
}[style.alignSelf ?? "auto"]);
|
|
73968
|
-
node.setGap(yoga.GUTTER_ALL, style.gap ?? 0);
|
|
73969
|
-
node.setFlexGrow(style.grow ?? 0);
|
|
73970
|
-
node.setFlexShrink(style.shrink ?? 0);
|
|
73971
|
-
}
|
|
73972
|
-
/**
|
|
73973
|
-
* Writes one extent through the right setter: `"auto"`, a percent string and a number are three
|
|
73974
|
-
* different Yoga calls.
|
|
74613
|
+
function applyEdge(node, style, kept, staged, side, index, which) {
|
|
74614
|
+
if (lengthMoved(kept, staged, PADDING + index * 2)) node.setPadding(which, edge(style.padding, side));
|
|
74615
|
+
if (lengthMoved(kept, staged, MARGIN + index * 2)) node.setMargin(which, edge(style.margin, side));
|
|
74616
|
+
}
|
|
74617
|
+
/**
|
|
74618
|
+
* Writes the six extents through the right setter: `"auto"`, a percent string and a number are
|
|
74619
|
+
* three different Yoga calls. An extent staged as nothing to write is left alone.
|
|
73975
74620
|
*
|
|
73976
74621
|
* @param node - The node of the element.
|
|
73977
|
-
* @param
|
|
73978
|
-
* @param
|
|
74622
|
+
* @param style - The resolved style.
|
|
74623
|
+
* @param kept - The node's kept record.
|
|
74624
|
+
* @param staged - The staged values of this write.
|
|
73979
74625
|
*/
|
|
73980
|
-
function
|
|
73981
|
-
|
|
73982
|
-
if (
|
|
73983
|
-
|
|
73984
|
-
|
|
73985
|
-
|
|
73986
|
-
|
|
73987
|
-
|
|
73988
|
-
case "minHeight":
|
|
73989
|
-
node.setMinHeight(value);
|
|
73990
|
-
break;
|
|
73991
|
-
case "maxWidth":
|
|
73992
|
-
node.setMaxWidth(value);
|
|
73993
|
-
break;
|
|
73994
|
-
default: node.setMaxHeight(value);
|
|
73995
|
-
}
|
|
74626
|
+
function applyExtents(node, style, kept, staged) {
|
|
74627
|
+
const { width, height, minWidth, minHeight, maxWidth, maxHeight } = style;
|
|
74628
|
+
if (lengthMoved(kept, staged, WIDTH)) node.setWidth(width);
|
|
74629
|
+
if (lengthMoved(kept, staged, HEIGHT)) node.setHeight(height);
|
|
74630
|
+
if (minWidth !== "auto" && lengthMoved(kept, staged, MIN_WIDTH)) node.setMinWidth(minWidth);
|
|
74631
|
+
if (minHeight !== "auto" && lengthMoved(kept, staged, MIN_HEIGHT)) node.setMinHeight(minHeight);
|
|
74632
|
+
if (maxWidth !== "auto" && lengthMoved(kept, staged, MAX_WIDTH)) node.setMaxWidth(maxWidth);
|
|
74633
|
+
if (maxHeight !== "auto" && lengthMoved(kept, staged, MAX_HEIGHT)) node.setMaxHeight(maxHeight);
|
|
73996
74634
|
}
|
|
73997
74635
|
/**
|
|
73998
74636
|
* Writes the box group onto a node.
|
|
73999
74637
|
*
|
|
74000
|
-
* @param
|
|
74638
|
+
* @param tables - The tables of the loaded Yoga module, its numbers staged.
|
|
74001
74639
|
* @param node - The node of the element.
|
|
74002
74640
|
* @param style - The resolved style.
|
|
74641
|
+
* @param kept - The node's kept record.
|
|
74003
74642
|
*/
|
|
74004
|
-
function applyBox(
|
|
74005
|
-
const
|
|
74006
|
-
|
|
74007
|
-
|
|
74008
|
-
|
|
74009
|
-
|
|
74010
|
-
|
|
74011
|
-
|
|
74012
|
-
|
|
74013
|
-
|
|
74014
|
-
}
|
|
74015
|
-
applyExtent(node, "width", style.width);
|
|
74016
|
-
applyExtent(node, "height", style.height);
|
|
74017
|
-
applyExtent(node, "minWidth", style.minWidth);
|
|
74018
|
-
applyExtent(node, "minHeight", style.minHeight);
|
|
74019
|
-
applyExtent(node, "maxWidth", style.maxWidth);
|
|
74020
|
-
applyExtent(node, "maxHeight", style.maxHeight);
|
|
74021
|
-
node.setAspectRatio(style.aspect);
|
|
74022
|
-
node.setOverflow({
|
|
74023
|
-
visible: yoga.OVERFLOW_VISIBLE,
|
|
74024
|
-
hidden: yoga.OVERFLOW_HIDDEN,
|
|
74025
|
-
scroll: yoga.OVERFLOW_SCROLL
|
|
74026
|
-
}[style.overflow ?? "visible"]);
|
|
74643
|
+
function applyBox(tables, node, style, kept) {
|
|
74644
|
+
const { yoga, staged } = tables;
|
|
74645
|
+
const overflow = tables.overflow[style.overflow ?? "visible"];
|
|
74646
|
+
applyEdge(node, style, kept, staged, "top", 0, yoga.EDGE_TOP);
|
|
74647
|
+
applyEdge(node, style, kept, staged, "right", 1, yoga.EDGE_RIGHT);
|
|
74648
|
+
applyEdge(node, style, kept, staged, "bottom", 2, yoga.EDGE_BOTTOM);
|
|
74649
|
+
applyEdge(node, style, kept, staged, "left", 3, yoga.EDGE_LEFT);
|
|
74650
|
+
applyExtents(node, style, kept, staged);
|
|
74651
|
+
if (numberMoved(kept, staged, ASPECT)) node.setAspectRatio(style.aspect);
|
|
74652
|
+
if (enumMoved(kept, OVERFLOW, overflow)) node.setOverflow(overflow);
|
|
74027
74653
|
}
|
|
74028
74654
|
/**
|
|
74029
74655
|
* Writes the position group onto a node. A child of a `stack` is absolute unless it says
|
|
74030
74656
|
* otherwise, which is what makes a stack a stack. A fitted element is absolute too: it keeps its
|
|
74031
74657
|
* own size and never stretches its parent, and the solve centres it in the parent's content box.
|
|
74032
74658
|
*
|
|
74033
|
-
* @param
|
|
74659
|
+
* @param tables - The tables of the loaded Yoga module, its numbers staged.
|
|
74034
74660
|
* @param node - The node of the element.
|
|
74035
74661
|
* @param style - The resolved style.
|
|
74036
74662
|
* @param stacked - Whether the parent tag is a `stack`.
|
|
74663
|
+
* @param kept - The node's kept record.
|
|
74037
74664
|
*/
|
|
74038
|
-
function applyPosition(
|
|
74039
|
-
const
|
|
74040
|
-
|
|
74041
|
-
|
|
74042
|
-
node.setPosition(yoga.
|
|
74043
|
-
node.setPosition(yoga.
|
|
74044
|
-
node.setPosition(yoga.
|
|
74665
|
+
function applyPosition(tables, node, style, stacked, kept) {
|
|
74666
|
+
const { yoga, staged } = tables;
|
|
74667
|
+
const type = style.position === "absolute" || style.fit === "contain" || stacked && style.position === void 0 ? yoga.POSITION_TYPE_ABSOLUTE : yoga.POSITION_TYPE_RELATIVE;
|
|
74668
|
+
if (enumMoved(kept, POSITION_TYPE, type)) node.setPositionType(type);
|
|
74669
|
+
if (lengthMoved(kept, staged, LEFT)) node.setPosition(yoga.EDGE_LEFT, style.left);
|
|
74670
|
+
if (lengthMoved(kept, staged, TOP)) node.setPosition(yoga.EDGE_TOP, style.top);
|
|
74671
|
+
if (lengthMoved(kept, staged, RIGHT)) node.setPosition(yoga.EDGE_RIGHT, style.right);
|
|
74672
|
+
if (lengthMoved(kept, staged, BOTTOM)) node.setPosition(yoga.EDGE_BOTTOM, style.bottom);
|
|
74045
74673
|
}
|
|
74046
74674
|
/**
|
|
74047
|
-
* Writes one resolved style onto one Yoga node.
|
|
74675
|
+
* Writes one resolved style onto one Yoga node. With the node's kept record, a setter is called
|
|
74676
|
+
* only for a value that differs from the one the record keeps, and the record takes what was
|
|
74677
|
+
* written; without one, every setter is called. The order of the calls is the order of the groups:
|
|
74678
|
+
* flow, box (each edge's padding then margin, the extents, the ratio, the overflow), position.
|
|
74048
74679
|
*
|
|
74049
74680
|
* @param yoga - The loaded Yoga module.
|
|
74050
74681
|
* @param node - The node of the element.
|
|
74051
74682
|
* @param style - The resolved style.
|
|
74052
74683
|
* @param tag - The intrinsic tag, which decides the default direction.
|
|
74053
74684
|
* @param parentTag - The tag of the parent, which decides whether children stack.
|
|
74685
|
+
* @param kept - The node's kept record, made with the node; none writes every value.
|
|
74686
|
+
* @param tables - The tables of the loaded module; built for this call when none is given.
|
|
74054
74687
|
*/
|
|
74055
|
-
function applyStyleToNode(yoga, node, style, tag, parentTag) {
|
|
74056
|
-
|
|
74057
|
-
|
|
74058
|
-
|
|
74688
|
+
function applyStyleToNode(yoga, node, style, tag, parentTag, kept, tables = styleTablesOf(yoga)) {
|
|
74689
|
+
stageEdges(tables.staged, style);
|
|
74690
|
+
stageExtents(tables.staged, style);
|
|
74691
|
+
stageFlowAndPosition(tables.staged, style);
|
|
74692
|
+
applyFlow(tables, node, style, tag !== "row", kept);
|
|
74693
|
+
applyBox(tables, node, style, kept);
|
|
74694
|
+
applyPosition(tables, node, style, parentTag === "stack", kept);
|
|
74059
74695
|
}
|
|
74060
74696
|
//#endregion
|
|
74061
74697
|
//#region src/plugins/ui/layout/motion.ts
|
|
@@ -74625,7 +75261,21 @@ function liftRest(ctx, element, units) {
|
|
|
74625
75261
|
//#endregion
|
|
74626
75262
|
//#region src/plugins/ui/layout/nodes.ts
|
|
74627
75263
|
/**
|
|
74628
|
-
*
|
|
75264
|
+
* The style tables of the loaded module, built the first time a node of it is made.
|
|
75265
|
+
*
|
|
75266
|
+
* @param state - The layout state.
|
|
75267
|
+
* @param yoga - The loaded Yoga module.
|
|
75268
|
+
* @returns The tables.
|
|
75269
|
+
*/
|
|
75270
|
+
function tablesOf(state, yoga) {
|
|
75271
|
+
const tables = state.tables;
|
|
75272
|
+
if (tables !== void 0 && tables.yoga === yoga) return tables;
|
|
75273
|
+
const built = styleTablesOf(yoga);
|
|
75274
|
+
state.tables = built;
|
|
75275
|
+
return built;
|
|
75276
|
+
}
|
|
75277
|
+
/**
|
|
75278
|
+
* Creates the node of an element and counts it, with the kept record of a fresh node.
|
|
74629
75279
|
*
|
|
74630
75280
|
* @param state - The layout state.
|
|
74631
75281
|
* @param element - The element that entered.
|
|
@@ -74637,6 +75287,7 @@ function createNode(state, element) {
|
|
|
74637
75287
|
if (existing !== void 0) return existing;
|
|
74638
75288
|
const node = state.yoga.Node.create();
|
|
74639
75289
|
state.byEntity.set(element.entity, node);
|
|
75290
|
+
state.kept.set(node, freshKept(tablesOf(state, state.yoga)));
|
|
74640
75291
|
state.nodes += 1;
|
|
74641
75292
|
return node;
|
|
74642
75293
|
}
|
|
@@ -74664,6 +75315,7 @@ function freeNode(state, element) {
|
|
|
74664
75315
|
detachNode(state, element);
|
|
74665
75316
|
node.setMeasureFunc(null);
|
|
74666
75317
|
node.free();
|
|
75318
|
+
state.kept.delete(node);
|
|
74667
75319
|
state.byEntity.delete(element.entity);
|
|
74668
75320
|
state.nodes -= 1;
|
|
74669
75321
|
}
|
|
@@ -76617,7 +77269,7 @@ function writeStyle(state, source, element) {
|
|
|
76617
77269
|
const node = state.byEntity.get(element.entity);
|
|
76618
77270
|
if (node === void 0 || state.yoga === void 0) return;
|
|
76619
77271
|
const tag = element.scroll?.axis === "x" ? "row" : element.type;
|
|
76620
|
-
applyStyleToNode(state.yoga, node, element.style, tag, element.parentType);
|
|
77272
|
+
applyStyleToNode(state.yoga, node, element.style, tag, element.parentType, state.kept.get(node), state.tables);
|
|
76621
77273
|
installMeasure(state, node, element, source);
|
|
76622
77274
|
}
|
|
76623
77275
|
/**
|
|
@@ -76637,7 +77289,9 @@ function createLayoutApi(ctx) {
|
|
|
76637
77289
|
};
|
|
76638
77290
|
return {
|
|
76639
77291
|
load: async () => {
|
|
76640
|
-
|
|
77292
|
+
const yoga = await loadYogaModule();
|
|
77293
|
+
state.yoga = yoga;
|
|
77294
|
+
state.tables = styleTablesOf(yoga);
|
|
76641
77295
|
},
|
|
76642
77296
|
loaded: () => state.yoga !== void 0,
|
|
76643
77297
|
attach: (element) => {
|
|
@@ -77160,6 +77814,7 @@ function createAnchorPass(ctx, jsx) {
|
|
|
77160
77814
|
if (yoga === void 0 || node === void 0) return;
|
|
77161
77815
|
node.setWidth(element.rect.w);
|
|
77162
77816
|
node.setHeight(element.rect.h);
|
|
77817
|
+
keepSize(layout.kept.get(node), element.rect);
|
|
77163
77818
|
node.calculateLayout(element.rect.w, element.rect.h, yoga.DIRECTION_LTR);
|
|
77164
77819
|
layout.solves += 1;
|
|
77165
77820
|
placeUnder(element);
|
|
@@ -78181,8 +78836,10 @@ function stopUi(state) {
|
|
|
78181
78836
|
node.free();
|
|
78182
78837
|
}
|
|
78183
78838
|
state.layout.byEntity.clear();
|
|
78839
|
+
state.layout.kept.clear();
|
|
78184
78840
|
state.layout.nodes = 0;
|
|
78185
78841
|
state.layout.yoga = void 0;
|
|
78842
|
+
state.layout.tables = void 0;
|
|
78186
78843
|
state.layout.scrolling = void 0;
|
|
78187
78844
|
state.layout.scrollSamples = 0;
|
|
78188
78845
|
state.layout.iconLine = void 0;
|
|
@@ -78555,6 +79212,8 @@ function createLayoutState() {
|
|
|
78555
79212
|
return {
|
|
78556
79213
|
yoga: void 0,
|
|
78557
79214
|
byEntity: emptyMap(),
|
|
79215
|
+
tables: void 0,
|
|
79216
|
+
kept: emptyMap(),
|
|
78558
79217
|
nodes: 0,
|
|
78559
79218
|
measured: 0,
|
|
78560
79219
|
solves: 0,
|