@moku-labs/game 0.15.95 → 0.15.97
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-DcGoU3wp.d.mts → commands-DQXSQB_C.d.mts} +5 -5
- package/dist/control.d.mts +4 -4
- package/dist/{define-CZ1_l9Hn.d.mts → define-hPbGjPAY.d.mts} +2 -2
- package/dist/{headless-9UyUfvF5.d.mts → headless-Co3SEFi5.d.mts} +1 -1
- package/dist/{index-B8XphAxo.d.mts → index-U_AN5j0L.d.mts} +5 -4
- package/dist/index.d.mts +4 -4
- package/dist/index.mjs +2 -2
- package/dist/inspect.d.mts +6 -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-DsAz7KUU.d.mts → runtime-B69fIYx_.d.mts} +1 -1
- package/dist/{sources-DIl02J8z.mjs → sources-Cqqz-0-b.mjs} +1 -1
- package/dist/{src-D-i4qig2.mjs → src-C32BYdgi.mjs} +724 -158
- package/dist/testing.d.mts +4 -4
- package/dist/testing.mjs +1 -1
- package/dist/{types-B-n_yE-i.d.mts → types-BE6tcAFX.d.mts} +2 -2
- package/dist/{types-0QTB6RV7.d.mts → types-Brsj29M-.d.mts} +4 -4
- package/dist/{types-Dhnc_iQk.d.mts → types-Cffn9Rbm.d.mts} +13 -6
- package/dist/{types-D8tWWOCK.d.mts → types-L3E-YS4N.d.mts} +46 -3
- package/dist/{types-CenejHAB.d.mts → types-qCcSw8YI.d.mts} +48 -12
- package/dist/{visual-B0ZwgkDL.d.mts → visual-72OVwKM4.d.mts} +6 -6
- package/dist/{visual-Cl7Q7pO9.mjs → visual-DhqD6W3v.mjs} +15 -5
- package/dist/visual.d.mts +1 -1
- package/dist/visual.mjs +1 -1
- package/llms.txt +4 -4
- package/package.json +1 -1
|
@@ -2,7 +2,7 @@ import { t as __exportAll } from "./rolldown-runtime-D7D4PA-g.mjs";
|
|
|
2
2
|
import { r as systemSource, t as memory } from "./memory-CWlqhS7l.mjs";
|
|
3
3
|
import { a as finishDrafts, i as enableDraftPatches, n as deepFreeze$1, o as openDrafts, r as dropDrafts } from "./drafts-BawpSaVp.mjs";
|
|
4
4
|
import { _ as compact, c as collectFlows, d as findNode, f as framePath, g as slotNames, h as restlessCapOf, i as servePaused, l as describeGraph, m as isRestCheckpoint, n as captureFrame, o as epochOf, p as graphHash, r as serveCaptures, s as pageNow$1, t as cancelCaptures, v as pushEntry } from "./capture-BtS6_oWr.mjs";
|
|
5
|
-
import { $ as Shape, A as Countdown, B as isLeaving, C as uiFor, D as isTextFormat, E as formatBound, G as rootPoseInto, H as parentOf$1, J as HudPart, K as rootPoseOf, L as readStyle, N as builtInStyles, O as unitOf, Q as Parent, R as textFor, U as poseUnder, V as localPoseOf, W as rootPointOf, X as Overlay, Y as NineSlice, Z as OverlayLevel, _ as LocalWrite, a as fieldsLeftAlone, at as Exiting, b as UI_OWNER, c as namesFormat, ct as Order, d as visualOf$1, et as Sprite, f as visualRectOf, ft as resource, g as Escapable, h as DebugTrigger, ht as tag, i as drawnRect, j as Text, k as wholeValue, l as restValueOf, lt as Tree, m as Covered, mt as systemsFor, n as CONTENT$1, nt as arcDefaults, o as fitScaleOf, ot as Layer, p as Box, pt as system, q as Display, r as bindOf, rt as componentsFor, s as livePatch, st as Now, tt as Transform, u as samePose, ut as component, v as Scroll, x as UiCounters, y as ScrollState, z as applyPose } from "./visual-
|
|
5
|
+
import { $ as Shape, A as Countdown, B as isLeaving, C as uiFor, D as isTextFormat, E as formatBound, G as rootPoseInto, H as parentOf$1, J as HudPart, K as rootPoseOf, L as readStyle, N as builtInStyles, O as unitOf, Q as Parent, R as textFor, U as poseUnder, V as localPoseOf, W as rootPointOf, X as Overlay, Y as NineSlice, Z as OverlayLevel, _ as LocalWrite, a as fieldsLeftAlone, at as Exiting, b as UI_OWNER, c as namesFormat, ct as Order, d as visualOf$1, et as Sprite, f as visualRectOf, ft as resource, g as Escapable, h as DebugTrigger, ht as tag, i as drawnRect, j as Text, k as wholeValue, l as restValueOf, lt as Tree, m as Covered, mt as systemsFor, n as CONTENT$1, nt as arcDefaults, o as fitScaleOf, ot as Layer, p as Box, pt as system, q as Display, r as bindOf, rt as componentsFor, s as livePatch, st as Now, tt as Transform, u as samePose, ut as component, v as Scroll, x as UiCounters, y as ScrollState, z as applyPose } from "./visual-DhqD6W3v.mjs";
|
|
6
6
|
import { a as isDev } from "./dev-BNndV-hU.mjs";
|
|
7
7
|
import { n as isComponentDefinition } from "./component-DGg5DqKK.mjs";
|
|
8
8
|
import { n as flatten } from "./flatten-nUX9PpGo.mjs";
|
|
@@ -31164,7 +31164,12 @@ function createRange$1(owner) {
|
|
|
31164
31164
|
* @returns The layer name, or `undefined` for a node that is no layer container.
|
|
31165
31165
|
*/
|
|
31166
31166
|
function layerNameOf$1(state, node) {
|
|
31167
|
-
|
|
31167
|
+
const list = state.layerList;
|
|
31168
|
+
if (list === void 0) return void 0;
|
|
31169
|
+
for (let index = 0; index < list.length; index += 1) {
|
|
31170
|
+
const name = list[index]?.name;
|
|
31171
|
+
if (name !== void 0 && state.layers.get(name)?.container === node) return name;
|
|
31172
|
+
}
|
|
31168
31173
|
}
|
|
31169
31174
|
/**
|
|
31170
31175
|
* Adds or removes a reason on one node of a range: a view's top, a layer container, or an engine object (a lower
|
|
@@ -31218,50 +31223,103 @@ function isPicture(sctx, node) {
|
|
|
31218
31223
|
*/
|
|
31219
31224
|
function computeRange(sctx, owner, root) {
|
|
31220
31225
|
const { wantEntries: entries, wantOthers: others, wantSet: set } = sctx.ctx.state.sync.overlay;
|
|
31221
|
-
entries.length =
|
|
31222
|
-
|
|
31223
|
-
|
|
31224
|
-
|
|
31225
|
-
|
|
31226
|
-
|
|
31227
|
-
|
|
31226
|
+
entries.length = rootsBelow(sctx, owner, lowerLayers(sctx, owner, root));
|
|
31227
|
+
fillSet(set, entries);
|
|
31228
|
+
let count = 0;
|
|
31229
|
+
for (const child of root.children) if (!set.has(child) && child !== owner.container) count = writeAt$1(others, count, child);
|
|
31230
|
+
for (const child of owner.container.children) if (!set.has(child) && !isPicture(sctx, child)) count = writeAt$1(others, count, child);
|
|
31231
|
+
others.length = count;
|
|
31232
|
+
}
|
|
31233
|
+
/**
|
|
31234
|
+
* Writes a node at a place of a reused list, only when another stands there.
|
|
31235
|
+
*
|
|
31236
|
+
* @param list - The list.
|
|
31237
|
+
* @param at - The place, at most its length.
|
|
31238
|
+
* @param node - The node.
|
|
31239
|
+
* @returns The next place.
|
|
31240
|
+
*/
|
|
31241
|
+
function writeAt$1(list, at, node) {
|
|
31242
|
+
if (list[at] !== node) list[at] = node;
|
|
31243
|
+
return at + 1;
|
|
31228
31244
|
}
|
|
31229
31245
|
/**
|
|
31230
|
-
*
|
|
31246
|
+
* Writes the layer containers below the owner's layer at the start of the wanted entries, bottom first.
|
|
31231
31247
|
*
|
|
31232
31248
|
* @param sctx - Domain context of the sync module.
|
|
31233
31249
|
* @param owner - The owner overlay.
|
|
31234
31250
|
* @param root - The stage root of `sync`.
|
|
31251
|
+
* @returns How many were written.
|
|
31235
31252
|
*/
|
|
31236
31253
|
function lowerLayers(sctx, owner, root) {
|
|
31237
31254
|
const state = sctx.ctx.state.sync;
|
|
31238
|
-
const
|
|
31239
|
-
|
|
31240
|
-
|
|
31241
|
-
|
|
31242
|
-
|
|
31243
|
-
|
|
31244
|
-
|
|
31255
|
+
const entries = state.overlay.wantEntries;
|
|
31256
|
+
const list = state.layerList;
|
|
31257
|
+
let count = 0;
|
|
31258
|
+
if (list === void 0) return count;
|
|
31259
|
+
for (let index = 0; index < owner.layerIndex && index < list.length; index += 1) {
|
|
31260
|
+
const name = list[index]?.name;
|
|
31261
|
+
const container = name === void 0 ? void 0 : state.layers.get(name)?.container;
|
|
31262
|
+
if (container?.parent === root) count = writeAt$1(entries, count, container);
|
|
31245
31263
|
}
|
|
31264
|
+
return count;
|
|
31265
|
+
}
|
|
31266
|
+
/**
|
|
31267
|
+
* Tells whether a node is the HUD render layer of an overlay (`hud: "under"`): never part of a range, so the HUD it
|
|
31268
|
+
* draws is never in a picture (U3).
|
|
31269
|
+
*
|
|
31270
|
+
* @param order - The overlays, bottom first.
|
|
31271
|
+
* @param node - A child of a layer container.
|
|
31272
|
+
* @returns True for the render layer of a known overlay.
|
|
31273
|
+
*/
|
|
31274
|
+
function isUnderLayer(order, node) {
|
|
31275
|
+
for (const record of order) if (record.under === node) return true;
|
|
31276
|
+
return false;
|
|
31246
31277
|
}
|
|
31247
31278
|
/**
|
|
31248
|
-
*
|
|
31249
|
-
* wanted entries; its own dim and every picture left out.
|
|
31279
|
+
* Writes the children of the owner's layer container drawn before its root (rank: depth, then insertion) into the
|
|
31280
|
+
* wanted entries after the lower layers; its own dim, every HUD render layer and every picture left out.
|
|
31250
31281
|
*
|
|
31251
31282
|
* @param sctx - Domain context of the sync module.
|
|
31252
31283
|
* @param owner - The owner overlay.
|
|
31284
|
+
* @param from - How many entries the lower layers wrote.
|
|
31285
|
+
* @returns How many entries there are now.
|
|
31253
31286
|
*/
|
|
31254
|
-
function rootsBelow(sctx, owner) {
|
|
31255
|
-
const { wantEntries: entries,
|
|
31287
|
+
function rootsBelow(sctx, owner, from) {
|
|
31288
|
+
const { wantEntries: entries, order } = sctx.ctx.state.sync.overlay;
|
|
31256
31289
|
const depth = owner.object.zIndex;
|
|
31290
|
+
const children = owner.container.children;
|
|
31257
31291
|
const at = owner.container.getChildIndex(owner.object);
|
|
31258
|
-
|
|
31259
|
-
|
|
31260
|
-
|
|
31261
|
-
|
|
31262
|
-
|
|
31263
|
-
|
|
31292
|
+
let count = from;
|
|
31293
|
+
let index = -1;
|
|
31294
|
+
for (const child of children) {
|
|
31295
|
+
index += 1;
|
|
31296
|
+
if (child === owner.dim || isUnderLayer(order, child) || isPicture(sctx, child)) continue;
|
|
31297
|
+
if (child.zIndex < depth || child.zIndex === depth && index < at) count = writeAt$1(entries, count, child);
|
|
31264
31298
|
}
|
|
31299
|
+
return count;
|
|
31300
|
+
}
|
|
31301
|
+
/**
|
|
31302
|
+
* Tells whether a set holds every node of a list.
|
|
31303
|
+
*
|
|
31304
|
+
* @param set - The set.
|
|
31305
|
+
* @param nodes - The nodes.
|
|
31306
|
+
* @returns True when none is missing.
|
|
31307
|
+
*/
|
|
31308
|
+
function holdsAll(set, nodes) {
|
|
31309
|
+
for (const node of nodes) if (!set.has(node)) return false;
|
|
31310
|
+
return true;
|
|
31311
|
+
}
|
|
31312
|
+
/**
|
|
31313
|
+
* Makes a set hold exactly these nodes, writing nothing when it does already: V8 gives a set a new table at every
|
|
31314
|
+
* `clear()`, and the step runs every frame.
|
|
31315
|
+
*
|
|
31316
|
+
* @param set - The set.
|
|
31317
|
+
* @param nodes - The nodes, each once.
|
|
31318
|
+
*/
|
|
31319
|
+
function fillSet(set, nodes) {
|
|
31320
|
+
if (set.size === nodes.length && holdsAll(set, nodes)) return;
|
|
31321
|
+
if (set.size > 0) set.clear();
|
|
31322
|
+
for (const node of nodes) set.add(node);
|
|
31265
31323
|
}
|
|
31266
31324
|
/**
|
|
31267
31325
|
* Tells whether two node lists are the same, in order.
|
|
@@ -31272,7 +31330,7 @@ function rootsBelow(sctx, owner) {
|
|
|
31272
31330
|
*/
|
|
31273
31331
|
function sameList$1(left, right) {
|
|
31274
31332
|
if (left.length !== right.length) return false;
|
|
31275
|
-
for (
|
|
31333
|
+
for (let index = 0; index < left.length; index += 1) if (right[index] !== left[index]) return false;
|
|
31276
31334
|
return true;
|
|
31277
31335
|
}
|
|
31278
31336
|
/**
|
|
@@ -31439,11 +31497,25 @@ function keepWanted(sctx, range) {
|
|
|
31439
31497
|
* @param from - The list wanted now.
|
|
31440
31498
|
*/
|
|
31441
31499
|
function copyInto(into, from) {
|
|
31442
|
-
for (
|
|
31500
|
+
for (let index = 0; index < from.length; index += 1) {
|
|
31501
|
+
const node = from[index];
|
|
31502
|
+
if (node !== void 0 && into[index] !== node) into[index] = node;
|
|
31503
|
+
}
|
|
31443
31504
|
into.length = from.length;
|
|
31444
31505
|
}
|
|
31445
31506
|
/**
|
|
31446
|
-
* The
|
|
31507
|
+
* The node the picture of an owner's range stands right before: its HUD render layer, so a HUD drawn there lies over
|
|
31508
|
+
* the picture and under the dim; else its dim; else its root.
|
|
31509
|
+
*
|
|
31510
|
+
* @param owner - The owner overlay.
|
|
31511
|
+
* @returns The node.
|
|
31512
|
+
*/
|
|
31513
|
+
function pictureBefore(owner) {
|
|
31514
|
+
return owner.under ?? owner.dim ?? owner.object;
|
|
31515
|
+
}
|
|
31516
|
+
/**
|
|
31517
|
+
* The range handed to `kept`: the wanted lists and the slot right before the owner's HUD render layer, its dim, or its
|
|
31518
|
+
* root.
|
|
31447
31519
|
*
|
|
31448
31520
|
* @param sctx - Domain context of the sync module.
|
|
31449
31521
|
* @param owner - The owner overlay.
|
|
@@ -31457,7 +31529,7 @@ function keptRangeOf(sctx, owner) {
|
|
|
31457
31529
|
others: overlay.wantOthers,
|
|
31458
31530
|
slot: {
|
|
31459
31531
|
container: owner.container,
|
|
31460
|
-
before: owner
|
|
31532
|
+
before: pictureBefore(owner)
|
|
31461
31533
|
}
|
|
31462
31534
|
};
|
|
31463
31535
|
}
|
|
@@ -31485,7 +31557,7 @@ function handOver$1(sctx, range, owner, root) {
|
|
|
31485
31557
|
range.kept = true;
|
|
31486
31558
|
range.refused = false;
|
|
31487
31559
|
range.othersStale = false;
|
|
31488
|
-
range.before = owner
|
|
31560
|
+
range.before = pictureBefore(owner);
|
|
31489
31561
|
range.blurred = measureBlurred(sctx, sctx.ctx.state.sync.overlay.wantSet, root);
|
|
31490
31562
|
return true;
|
|
31491
31563
|
}
|
|
@@ -31522,6 +31594,21 @@ function noteFallback(sctx, owner, what) {
|
|
|
31522
31594
|
});
|
|
31523
31595
|
}
|
|
31524
31596
|
/**
|
|
31597
|
+
* Tells whether the whole reasons of a frame hold one of these. Pure.
|
|
31598
|
+
*
|
|
31599
|
+
* @param wholes - The whole-frame reasons of this decision.
|
|
31600
|
+
* @param reasons - The reasons looked for.
|
|
31601
|
+
* @returns True when one is there.
|
|
31602
|
+
* @example
|
|
31603
|
+
* ```ts
|
|
31604
|
+
* wholeAmong(new Set(["layers", "resize"]), ["resize", "restore", "debug"]); // true
|
|
31605
|
+
* ```
|
|
31606
|
+
*/
|
|
31607
|
+
function wholeAmong(wholes, reasons) {
|
|
31608
|
+
for (const reason of reasons) if (wholes.has(reason)) return true;
|
|
31609
|
+
return false;
|
|
31610
|
+
}
|
|
31611
|
+
/**
|
|
31525
31612
|
* The retake rules of a held picture whose lists stand (O8.3, O8.4): the catch-up of held loops, a mark in the range
|
|
31526
31613
|
* (live after three frames in a row), the screen changed whole, and the landing and the first exit frame with a loop
|
|
31527
31614
|
* held. Others that changed are handed over with the next retake.
|
|
@@ -31531,15 +31618,13 @@ function noteFallback(sctx, owner, what) {
|
|
|
31531
31618
|
* @param owner - The owner overlay.
|
|
31532
31619
|
* @param root - The stage root.
|
|
31533
31620
|
* @param context - The frame: its whole reasons and whether the others changed.
|
|
31534
|
-
* @param context.wholes - The whole-frame reasons of this decision.
|
|
31535
|
-
* @param context.othersChanged - True when the others differ from the last frame.
|
|
31536
31621
|
* @returns The reason the entries carry now: `"freeze"`, or none when the range went live.
|
|
31537
31622
|
*/
|
|
31538
31623
|
function stepKept(sctx, range, owner, root, context) {
|
|
31539
31624
|
if (context.othersChanged) range.othersStale = true;
|
|
31540
31625
|
const owed = retakeOwed(sctx, range, owner, root);
|
|
31541
31626
|
if (owed === "live") return void 0;
|
|
31542
|
-
if (owed === "none" &&
|
|
31627
|
+
if (owed === "none" && wholeAmong(context.wholes, RETAKE_WHOLES)) retake(sctx, range, owner, root);
|
|
31543
31628
|
if (range.touched && (owner.turned === "shown" || owner.turned === "exiting")) range.catchUp = true;
|
|
31544
31629
|
return range.kept ? "freeze" : void 0;
|
|
31545
31630
|
}
|
|
@@ -31579,11 +31664,7 @@ function retakeOwed(sctx, range, owner, root) {
|
|
|
31579
31664
|
* @param range - The range of this owner, counters reset when it is new.
|
|
31580
31665
|
* @param owner - The owner overlay.
|
|
31581
31666
|
* @param root - The stage root.
|
|
31582
|
-
* @param context - What changed since the last frame.
|
|
31583
|
-
* @param context.fresh - The owner is new, or was covering until now.
|
|
31584
|
-
* @param context.entriesChanged - The entries differ from the last frame.
|
|
31585
|
-
* @param context.othersChanged - The others differ from the last frame.
|
|
31586
|
-
* @param context.wholes - The whole-frame reasons of this decision.
|
|
31667
|
+
* @param context - What changed since the last frame: a new owner, new entries or others, the whole reasons.
|
|
31587
31668
|
* @returns `"freeze"` when a picture holds the range, none when it is drawn live.
|
|
31588
31669
|
*/
|
|
31589
31670
|
function stepFreeze(sctx, range, owner, root, context) {
|
|
@@ -31697,19 +31778,19 @@ function stepRange(sctx, wholes) {
|
|
|
31697
31778
|
}
|
|
31698
31779
|
if (fresh) freshRange(range, owner.entity, sameOwner && held !== void 0 && mode === "freeze");
|
|
31699
31780
|
range.mode = mode;
|
|
31700
|
-
const
|
|
31701
|
-
|
|
31702
|
-
|
|
31703
|
-
|
|
31704
|
-
|
|
31705
|
-
|
|
31781
|
+
const { step } = overlay;
|
|
31782
|
+
step.fresh = fresh;
|
|
31783
|
+
step.entriesChanged = entriesChanged;
|
|
31784
|
+
step.othersChanged = othersChanged;
|
|
31785
|
+
step.wholes = wholes;
|
|
31786
|
+
const to = mode === "cover" ? "cover" : stepFreeze(sctx, range, owner, root, step);
|
|
31706
31787
|
if (mode === "cover") range.kept = false;
|
|
31707
31788
|
writeReasons(sctx, range, from, to);
|
|
31708
31789
|
keepWanted(sctx, range);
|
|
31709
31790
|
range.reason = to;
|
|
31710
31791
|
overlay.active = range;
|
|
31711
31792
|
if (held !== void 0 && (held !== owner.entity || !range.kept)) sctx.deps.kept.release(held);
|
|
31712
|
-
const before = owner
|
|
31793
|
+
const before = pictureBefore(owner);
|
|
31713
31794
|
if (range.kept && range.before !== before) {
|
|
31714
31795
|
sctx.deps.kept.move(owner.entity, {
|
|
31715
31796
|
container: owner.container,
|
|
@@ -31759,7 +31840,8 @@ function rangeHolds(state, entity) {
|
|
|
31759
31840
|
//#endregion
|
|
31760
31841
|
//#region src/plugins/renderer/sync/overlay-state.ts
|
|
31761
31842
|
/**
|
|
31762
|
-
* Destroys the dims the records hold, once each, and drops the references
|
|
31843
|
+
* Destroys the dims and the HUD render layers the records hold, once each, and drops the references; a render layer
|
|
31844
|
+
* lets go of what it holds first, so the HUD layer container is left attached to nothing (U5).
|
|
31763
31845
|
*
|
|
31764
31846
|
* @param overlay - The overlay state.
|
|
31765
31847
|
*/
|
|
@@ -31768,12 +31850,19 @@ function destroyDims(overlay) {
|
|
|
31768
31850
|
if (record.dim !== void 0 && !record.dim.destroyed) record.dim.destroy();
|
|
31769
31851
|
record.dim = void 0;
|
|
31770
31852
|
record.sized = false;
|
|
31853
|
+
if (record.under !== void 0) {
|
|
31854
|
+
record.under.detachAll();
|
|
31855
|
+
if (!record.under.destroyed) record.under.destroy();
|
|
31856
|
+
}
|
|
31857
|
+
record.under = void 0;
|
|
31771
31858
|
}
|
|
31859
|
+
overlay.held = void 0;
|
|
31860
|
+
overlay.heldBy = void 0;
|
|
31772
31861
|
}
|
|
31773
31862
|
/**
|
|
31774
|
-
* Forgets what the step applied to a tree that goes (a rebuild, a lost device): the dims, the
|
|
31775
|
-
* The records stay, so the next step finds the overlays again in the new
|
|
31776
|
-
* and the layers it hid are new, so nothing is cleared on them.
|
|
31863
|
+
* Forgets what the step applied to a tree that goes (a rebuild, a lost device): the dims, the HUD render layers and
|
|
31864
|
+
* the HUD they held, the range and the tap set. The records stay, so the next step finds the overlays again in the new
|
|
31865
|
+
* tree and takes their ranges anew; the views and the layers it hid are new, so nothing is cleared on them.
|
|
31777
31866
|
*
|
|
31778
31867
|
* @param state - The sync state.
|
|
31779
31868
|
*/
|
|
@@ -31789,10 +31878,12 @@ function forgetOverlays(state) {
|
|
|
31789
31878
|
overlay.range.kept = false;
|
|
31790
31879
|
}
|
|
31791
31880
|
overlay.offTops.clear();
|
|
31881
|
+
overlay.offList.length = 0;
|
|
31792
31882
|
overlay.order.length = 0;
|
|
31793
31883
|
}
|
|
31794
31884
|
/**
|
|
31795
|
-
* Forgets every overlay at stop: dims destroyed, records, ranges, taps, events and the watched
|
|
31885
|
+
* Forgets every overlay at stop: dims and HUD render layers destroyed, records, ranges, taps, events and the watched
|
|
31886
|
+
* entities cleared.
|
|
31796
31887
|
*
|
|
31797
31888
|
* @param state - The sync state.
|
|
31798
31889
|
*/
|
|
@@ -34555,7 +34646,8 @@ function walkChildren(sctx, walk, container, depth, steps) {
|
|
|
34555
34646
|
/**
|
|
34556
34647
|
* Walks every view under the walk's point, topmost first: the layers from the last one of the
|
|
34557
34648
|
* scene's list, inside a layer by draw order from the top. Nothing while inert or before the scene
|
|
34558
|
-
* declared its layers. A layer that hangs under no root, or that is hidden, holds no hit
|
|
34649
|
+
* declared its layers. A layer that hangs under no root, or that is hidden, holds no hit, and neither does the HUD
|
|
34650
|
+
* layer while an overlay draws it under its dim.
|
|
34559
34651
|
*
|
|
34560
34652
|
* @param sctx - Domain context of the sync module.
|
|
34561
34653
|
* @param walk - The walk.
|
|
@@ -34569,7 +34661,7 @@ function walkLayers(sctx, walk) {
|
|
|
34569
34661
|
for (let index = list.length - 1; index >= 0; index -= 1) {
|
|
34570
34662
|
const name = list[index]?.name;
|
|
34571
34663
|
const container = name === void 0 ? void 0 : state.layers.get(name)?.container;
|
|
34572
|
-
if (container === void 0) continue;
|
|
34664
|
+
if (container === void 0 || container === state.overlay.held) continue;
|
|
34573
34665
|
const alpha = effectiveAlpha(container, root, state.overlay.offTops);
|
|
34574
34666
|
const steps = stepsToRoot(container, root);
|
|
34575
34667
|
if (alpha === 0 || steps >= MAX_DEPTH$6) continue;
|
|
@@ -35294,8 +35386,44 @@ function lookDim(sctx, record, dim) {
|
|
|
35294
35386
|
}
|
|
35295
35387
|
}
|
|
35296
35388
|
/**
|
|
35389
|
+
* Makes the render layer an overlay with `hud: "under"` draws the HUD layer in: never a view, nothing attached yet.
|
|
35390
|
+
*
|
|
35391
|
+
* @param pixi - The Pixi module.
|
|
35392
|
+
* @param entity - The marked entity, for the label.
|
|
35393
|
+
* @returns The render layer.
|
|
35394
|
+
*/
|
|
35395
|
+
function makeUnder(pixi, entity) {
|
|
35396
|
+
const under = new pixi.RenderLayer();
|
|
35397
|
+
under.label = `overlay-hud:${entity}`;
|
|
35398
|
+
return under;
|
|
35399
|
+
}
|
|
35400
|
+
/**
|
|
35401
|
+
* Places an overlay's HUD render layer immediately before its dim, at the dim's depth, as the dim is placed before the
|
|
35402
|
+
* root: what it draws lies under the dim, and a picture of the range stands right before it. A move marks the whole
|
|
35403
|
+
* frame: the layer has no entity.
|
|
35404
|
+
*
|
|
35405
|
+
* @param sctx - Domain context of the sync module.
|
|
35406
|
+
* @param record - The overlay.
|
|
35407
|
+
* @param under - Its render layer.
|
|
35408
|
+
* @param dim - Its dim, placed already.
|
|
35409
|
+
*/
|
|
35410
|
+
function placeUnder(sctx, record, under, dim) {
|
|
35411
|
+
const { container } = record;
|
|
35412
|
+
const at = container.getChildIndex(dim);
|
|
35413
|
+
if (under.parent !== container || container.children[at - 1] !== under) {
|
|
35414
|
+
sctx.deps.demand.whole("overlay");
|
|
35415
|
+
under.removeFromParent();
|
|
35416
|
+
container.addChildAt(under, container.getChildIndex(dim));
|
|
35417
|
+
}
|
|
35418
|
+
if (under.zIndex !== dim.zIndex) {
|
|
35419
|
+
sctx.deps.demand.whole("overlay");
|
|
35420
|
+
under.zIndex = dim.zIndex;
|
|
35421
|
+
}
|
|
35422
|
+
}
|
|
35423
|
+
/**
|
|
35297
35424
|
* The dims of every overlay with a dim above 0: made once, placed under the root, sized to the canvas (again after a
|
|
35298
|
-
* resize, a resolution change or a restore), and their look written
|
|
35425
|
+
* resize, a resolution change or a restore), and their look written; the HUD render layer of one with `hud: "under"`
|
|
35426
|
+
* made with its dim and placed right under it (U1). A dim of 0 makes neither (U6).
|
|
35299
35427
|
*
|
|
35300
35428
|
* @param sctx - Domain context of the sync module.
|
|
35301
35429
|
* @param wholes - The whole-frame reasons of this decision.
|
|
@@ -35313,10 +35441,112 @@ function stepDims(sctx, wholes) {
|
|
|
35313
35441
|
placeDim(sctx, record, record.dim);
|
|
35314
35442
|
if (resized || !record.sized) sizeDim(sctx, record, record.dim);
|
|
35315
35443
|
lookDim(sctx, record, record.dim);
|
|
35444
|
+
if (needsUnder(record)) record.under = makeUnder(pixi, record.entity);
|
|
35445
|
+
if (record.under !== void 0) placeUnder(sctx, record, record.under, record.dim);
|
|
35446
|
+
}
|
|
35447
|
+
}
|
|
35448
|
+
/**
|
|
35449
|
+
* Tells whether an overlay wants a HUD render layer it does not have yet: `hud: "under"` with a dim above 0 (U1, U6).
|
|
35450
|
+
*
|
|
35451
|
+
* @param record - The overlay.
|
|
35452
|
+
* @returns True when the layer is to be made.
|
|
35453
|
+
*/
|
|
35454
|
+
function needsUnder(record) {
|
|
35455
|
+
return record.under === void 0 && record.value.hud === "under" && record.value.dim > 0;
|
|
35456
|
+
}
|
|
35457
|
+
/**
|
|
35458
|
+
* Tells whether an overlay holds the HUD under its dim now, if nothing above it does: its render layer is made, it says
|
|
35459
|
+
* `hud: "under"`, and its dim and its level are above 0.
|
|
35460
|
+
*
|
|
35461
|
+
* @param record - The overlay.
|
|
35462
|
+
* @returns True when it can hold the HUD.
|
|
35463
|
+
*/
|
|
35464
|
+
function isUnderHolder(record) {
|
|
35465
|
+
const { value } = record;
|
|
35466
|
+
return record.under !== void 0 && value.hud === "under" && value.dim > 0 && record.level > 0;
|
|
35467
|
+
}
|
|
35468
|
+
/**
|
|
35469
|
+
* The render layer the HUD layer is drawn in now (U2): the topmost overlay with `hud: "under"`, a dim above 0 and a
|
|
35470
|
+
* level above 0, looked for from the top down to the overlay that owns the range. One under that owner holds nothing:
|
|
35471
|
+
* it lies in the owner's picture, which would cover a HUD drawn under it.
|
|
35472
|
+
*
|
|
35473
|
+
* @param order - The overlays, bottom first, their modes decided.
|
|
35474
|
+
* @returns The holder's render layer, or `undefined` while the HUD draws in its own place above the overlays.
|
|
35475
|
+
*/
|
|
35476
|
+
function holderOf(order) {
|
|
35477
|
+
for (let index = order.length - 1; index >= 0; index -= 1) {
|
|
35478
|
+
const record = order[index];
|
|
35479
|
+
if (record === void 0) continue;
|
|
35480
|
+
if (isUnderHolder(record)) return record.under;
|
|
35481
|
+
if (record.mode !== "live") return void 0;
|
|
35316
35482
|
}
|
|
35317
35483
|
}
|
|
35318
35484
|
/**
|
|
35319
|
-
*
|
|
35485
|
+
* Lets the HUD layer container go from the render layer that holds it, so it draws in its own place again. Only a
|
|
35486
|
+
* container still attached there is detached: Pixi already let go of one that left its parent.
|
|
35487
|
+
*
|
|
35488
|
+
* @param sctx - Domain context of the sync module.
|
|
35489
|
+
*/
|
|
35490
|
+
function letGoHud(sctx) {
|
|
35491
|
+
const overlay = sctx.ctx.state.sync.overlay;
|
|
35492
|
+
const { held, heldBy } = overlay;
|
|
35493
|
+
overlay.held = void 0;
|
|
35494
|
+
overlay.heldBy = void 0;
|
|
35495
|
+
if (held === void 0 || heldBy === void 0) return;
|
|
35496
|
+
if (held.parentRenderLayer === heldBy) heldBy.detach(held);
|
|
35497
|
+
sctx.deps.demand.whole("overlay");
|
|
35498
|
+
}
|
|
35499
|
+
/**
|
|
35500
|
+
* Hands the HUD layer container to the overlay that holds it under its dim this frame, or back to its own place (U2):
|
|
35501
|
+
* the old holder lets it go before the new one takes it, and either marks the whole frame. A frame where nothing
|
|
35502
|
+
* changed compares references and writes nothing. The HUD is held only while its container hangs in the stage root,
|
|
35503
|
+
* in the one render group of the layers.
|
|
35504
|
+
*
|
|
35505
|
+
* @param sctx - Domain context of the sync module.
|
|
35506
|
+
*/
|
|
35507
|
+
function stepHold(sctx) {
|
|
35508
|
+
const state = sctx.ctx.state.sync;
|
|
35509
|
+
const overlay = state.overlay;
|
|
35510
|
+
const name = state.hudLayer;
|
|
35511
|
+
const container = name === void 0 ? void 0 : state.layers.get(name)?.container;
|
|
35512
|
+
const holder = container !== void 0 && container.parent === state.root ? holderOf(overlay.order) : void 0;
|
|
35513
|
+
const unchanged = holder === overlay.heldBy && container === overlay.held && container?.parentRenderLayer === holder;
|
|
35514
|
+
if (holder === void 0 && overlay.heldBy === void 0) return;
|
|
35515
|
+
if (unchanged) return;
|
|
35516
|
+
letGoHud(sctx);
|
|
35517
|
+
if (holder === void 0 || container === void 0) return;
|
|
35518
|
+
holder.attach(container);
|
|
35519
|
+
overlay.held = container;
|
|
35520
|
+
overlay.heldBy = holder;
|
|
35521
|
+
sctx.deps.demand.whole("overlay");
|
|
35522
|
+
}
|
|
35523
|
+
/**
|
|
35524
|
+
* Destroys an overlay's HUD render layer, the HUD let go first when it holds it, so nothing is left attached (U5).
|
|
35525
|
+
*
|
|
35526
|
+
* @param sctx - Domain context of the sync module.
|
|
35527
|
+
* @param record - The overlay.
|
|
35528
|
+
*/
|
|
35529
|
+
function dropUnder(sctx, record) {
|
|
35530
|
+
const { under } = record;
|
|
35531
|
+
if (under === void 0) return;
|
|
35532
|
+
if (sctx.ctx.state.sync.overlay.heldBy === under) letGoHud(sctx);
|
|
35533
|
+
sctx.deps.demand.whole("overlay");
|
|
35534
|
+
under.detachAll();
|
|
35535
|
+
if (!under.destroyed) under.destroy();
|
|
35536
|
+
record.under = void 0;
|
|
35537
|
+
}
|
|
35538
|
+
/**
|
|
35539
|
+
* Destroys the HUD render layer of every overlay, for new layers: the next step of the frame makes them again where
|
|
35540
|
+
* the records hang now (U5).
|
|
35541
|
+
*
|
|
35542
|
+
* @param sctx - Domain context of the sync module.
|
|
35543
|
+
*/
|
|
35544
|
+
function dropUnders(sctx) {
|
|
35545
|
+
for (const record of sctx.ctx.state.sync.overlay.records.values()) dropUnder(sctx, record);
|
|
35546
|
+
}
|
|
35547
|
+
/**
|
|
35548
|
+
* Whether one overlay keeps a HUD part shown: 1 for `hud: "all"` and `"under"` (the whole HUD stays, under the dim), 0
|
|
35549
|
+
* for `"none"`, and whether its list holds the key.
|
|
35320
35550
|
*
|
|
35321
35551
|
* @param record - The overlay.
|
|
35322
35552
|
* @param key - The part's key.
|
|
@@ -35324,7 +35554,7 @@ function stepDims(sctx, wholes) {
|
|
|
35324
35554
|
*/
|
|
35325
35555
|
function keeps(record, key) {
|
|
35326
35556
|
const { hud } = record.value;
|
|
35327
|
-
if (hud === "all") return 1;
|
|
35557
|
+
if (hud === "all" || hud === "under") return 1;
|
|
35328
35558
|
if (hud === "none") return 0;
|
|
35329
35559
|
return hud.includes(key) ? 1 : 0;
|
|
35330
35560
|
}
|
|
@@ -35354,18 +35584,37 @@ function targetOf$3(order, key) {
|
|
|
35354
35584
|
return target;
|
|
35355
35585
|
}
|
|
35356
35586
|
/**
|
|
35357
|
-
* Tells whether
|
|
35587
|
+
* Tells whether a set holds exactly the nodes of a list: as many, and every one of them.
|
|
35358
35588
|
*
|
|
35359
|
-
* @param
|
|
35360
|
-
* @param
|
|
35361
|
-
* @returns True when they are
|
|
35589
|
+
* @param list - The nodes, each once.
|
|
35590
|
+
* @param set - The set.
|
|
35591
|
+
* @returns True when they are the same nodes.
|
|
35362
35592
|
*/
|
|
35363
|
-
function
|
|
35364
|
-
if (
|
|
35365
|
-
for (const node of
|
|
35593
|
+
function holdsSame(list, set) {
|
|
35594
|
+
if (list.length !== set.size) return false;
|
|
35595
|
+
for (const node of list) if (!set.has(node)) return false;
|
|
35366
35596
|
return true;
|
|
35367
35597
|
}
|
|
35368
35598
|
/**
|
|
35599
|
+
* Makes the tap set hold the faded tops of this frame, the first `count` of `offList`, only when they differ from it:
|
|
35600
|
+
* the set is built aside and swapped in, so a frame where nothing changed clears nothing (V8 gives a set a new table at
|
|
35601
|
+
* every `clear()`, and the step runs every frame).
|
|
35602
|
+
*
|
|
35603
|
+
* @param sctx - Domain context of the sync module.
|
|
35604
|
+
* @param count - How many tops `offList` holds this frame.
|
|
35605
|
+
*/
|
|
35606
|
+
function keepOff(sctx, count) {
|
|
35607
|
+
const overlay = sctx.ctx.state.sync.overlay;
|
|
35608
|
+
const { offList } = overlay;
|
|
35609
|
+
offList.length = count;
|
|
35610
|
+
if (holdsSame(offList, overlay.offTops)) return;
|
|
35611
|
+
const next = overlay.nextOff;
|
|
35612
|
+
if (next.size > 0) next.clear();
|
|
35613
|
+
for (const top of offList) next.add(top);
|
|
35614
|
+
overlay.nextOff = overlay.offTops;
|
|
35615
|
+
overlay.offTops = next;
|
|
35616
|
+
}
|
|
35617
|
+
/**
|
|
35369
35618
|
* Logs one warning of a part once, in dev builds.
|
|
35370
35619
|
*
|
|
35371
35620
|
* @param sctx - Domain context of the sync module.
|
|
@@ -35399,7 +35648,8 @@ function stepParts(sctx) {
|
|
|
35399
35648
|
const settling = heldWaiting(sctx);
|
|
35400
35649
|
const ecs = sctx.ctx.deps.world.ecs;
|
|
35401
35650
|
const projection = sctx.ctx.deps.world.projection;
|
|
35402
|
-
|
|
35651
|
+
const { offList } = overlay;
|
|
35652
|
+
let count = 0;
|
|
35403
35653
|
for (const entity of overlay.parts) {
|
|
35404
35654
|
const view = state.views.get(entity);
|
|
35405
35655
|
if (view === void 0) continue;
|
|
@@ -35411,13 +35661,13 @@ function stepParts(sctx) {
|
|
|
35411
35661
|
}
|
|
35412
35662
|
const factor = factorOf(overlay.order, key);
|
|
35413
35663
|
applyHud(sctx, entity, view, factor);
|
|
35414
|
-
if (factor < 1 || targetOf$3(overlay.order, key) < 1)
|
|
35415
|
-
|
|
35416
|
-
|
|
35417
|
-
|
|
35418
|
-
|
|
35419
|
-
overlay.offTops = next;
|
|
35664
|
+
if (factor < 1 || targetOf$3(overlay.order, key) < 1) {
|
|
35665
|
+
const top = view.wrapper ?? view.object;
|
|
35666
|
+
if (offList[count] !== top) offList[count] = top;
|
|
35667
|
+
count += 1;
|
|
35668
|
+
}
|
|
35420
35669
|
}
|
|
35670
|
+
keepOff(sctx, count);
|
|
35421
35671
|
}
|
|
35422
35672
|
//#endregion
|
|
35423
35673
|
//#region src/plugins/renderer/sync/overlay.ts
|
|
@@ -35459,8 +35709,8 @@ function isKeyList(value) {
|
|
|
35459
35709
|
}
|
|
35460
35710
|
/**
|
|
35461
35711
|
* Copies the marker into the record's own value, clamped (O1): `dim` into [0, 1], `fade` to 0 or more, an unknown
|
|
35462
|
-
* `cover` as `"none"`, a `hud` that is not `"all"`, `"none"` or a key list as `"all"`, a `hold` that is no
|
|
35463
|
-
* `false`; one dev warning per field.
|
|
35712
|
+
* `cover` as `"none"`, a `hud` that is not `"all"`, `"none"`, `"under"` or a key list as `"all"`, a `hold` that is no
|
|
35713
|
+
* boolean as `false`; one dev warning per field.
|
|
35464
35714
|
*
|
|
35465
35715
|
* @param sctx - Domain context of the sync module.
|
|
35466
35716
|
* @param entity - The marked entity.
|
|
@@ -35471,7 +35721,7 @@ function clampInto(sctx, entity, into, raw) {
|
|
|
35471
35721
|
const dim = Number.isFinite(raw.dim) ? Math.min(1, Math.max(0, raw.dim)) : 0;
|
|
35472
35722
|
const fade = Number.isFinite(raw.fade) ? Math.max(0, raw.fade) : 0;
|
|
35473
35723
|
const cover = raw.cover === "opaque" ? "opaque" : "none";
|
|
35474
|
-
const hud = raw.hud === "all" || raw.hud === "none" || isKeyList(raw.hud) ? raw.hud : "all";
|
|
35724
|
+
const hud = raw.hud === "all" || raw.hud === "none" || raw.hud === "under" || isKeyList(raw.hud) ? raw.hud : "all";
|
|
35475
35725
|
const hold = raw.hold === true;
|
|
35476
35726
|
if (dim !== raw.dim) warnOnce$4(sctx, "renderer:overlay-value", entity, { field: "dim" });
|
|
35477
35727
|
if (fade !== raw.fade) warnOnce$4(sctx, "renderer:overlay-value", entity, { field: "fade" });
|
|
@@ -35502,29 +35752,37 @@ function rootOf(sctx, entity) {
|
|
|
35502
35752
|
}
|
|
35503
35753
|
return current;
|
|
35504
35754
|
}
|
|
35755
|
+
/** The layer list of a scene that declared none: no array made per frame. */
|
|
35756
|
+
const NO_LAYERS = [];
|
|
35505
35757
|
/**
|
|
35506
|
-
*
|
|
35758
|
+
* The index in the scene's list of the layer a root's top hangs in.
|
|
35507
35759
|
*
|
|
35508
|
-
* @param
|
|
35760
|
+
* @param state - The sync state.
|
|
35761
|
+
* @param list - The scene's layers.
|
|
35509
35762
|
* @param container - The parent of the root's top.
|
|
35510
|
-
* @returns The
|
|
35763
|
+
* @returns The index, or -1 for an orphan.
|
|
35511
35764
|
*/
|
|
35512
|
-
function
|
|
35513
|
-
|
|
35514
|
-
|
|
35515
|
-
|
|
35516
|
-
|
|
35517
|
-
for (const [index, spec] of list.entries()) {
|
|
35518
|
-
if (spec.above === "overlays") hud = index;
|
|
35519
|
-
if (container !== null && state.layers.get(spec.name)?.container === container) found = {
|
|
35520
|
-
name: spec.name,
|
|
35521
|
-
index
|
|
35522
|
-
};
|
|
35765
|
+
function layerIndexOf(state, list, container) {
|
|
35766
|
+
if (container === null) return -1;
|
|
35767
|
+
for (let index = 0; index < list.length; index += 1) {
|
|
35768
|
+
const name = list[index]?.name;
|
|
35769
|
+
if (name !== void 0 && state.layers.get(name)?.container === container) return index;
|
|
35523
35770
|
}
|
|
35524
|
-
return
|
|
35525
|
-
|
|
35526
|
-
|
|
35527
|
-
|
|
35771
|
+
return -1;
|
|
35772
|
+
}
|
|
35773
|
+
/**
|
|
35774
|
+
* The index of the HUD layer in a scene's list. Pure.
|
|
35775
|
+
*
|
|
35776
|
+
* @param list - The scene's layers.
|
|
35777
|
+
* @returns The index of the layer above the overlays, -1 without one.
|
|
35778
|
+
* @example
|
|
35779
|
+
* ```ts
|
|
35780
|
+
* hudIndexOf([{ name: "scene", sort: "none" }, { name: "hud", sort: "none", above: "overlays" }]); // 1
|
|
35781
|
+
* ```
|
|
35782
|
+
*/
|
|
35783
|
+
function hudIndexOf$1(list) {
|
|
35784
|
+
for (let index = 0; index < list.length; index += 1) if (list[index]?.above === "overlays") return index;
|
|
35785
|
+
return -1;
|
|
35528
35786
|
}
|
|
35529
35787
|
/**
|
|
35530
35788
|
* A new record for an overlay that appeared this frame.
|
|
@@ -35549,6 +35807,7 @@ function createRecord(entity, object, container) {
|
|
|
35549
35807
|
turned: void 0,
|
|
35550
35808
|
mode: "live",
|
|
35551
35809
|
dim: void 0,
|
|
35810
|
+
under: void 0,
|
|
35552
35811
|
sized: false,
|
|
35553
35812
|
seen: false,
|
|
35554
35813
|
news: "open"
|
|
@@ -35590,10 +35849,13 @@ function seeOverlay(sctx, entity) {
|
|
|
35590
35849
|
const raw = ecs.get(entity, Overlay);
|
|
35591
35850
|
if (view === void 0 || raw === void 0) return;
|
|
35592
35851
|
const object = view.wrapper ?? view.object;
|
|
35593
|
-
const
|
|
35594
|
-
|
|
35595
|
-
|
|
35596
|
-
|
|
35852
|
+
const list = state.layerList ?? NO_LAYERS;
|
|
35853
|
+
const index = layerIndexOf(state, list, object.parent);
|
|
35854
|
+
const layer = list[index];
|
|
35855
|
+
if (layer === void 0 || object.parent === null) return;
|
|
35856
|
+
const hud = hudIndexOf$1(list);
|
|
35857
|
+
if (hud !== -1 && index >= hud) {
|
|
35858
|
+
warnOnce$4(sctx, "renderer:overlay-above-hud", entity, { layer: layer.name });
|
|
35597
35859
|
return;
|
|
35598
35860
|
}
|
|
35599
35861
|
const known = state.overlay.records.get(entity);
|
|
@@ -35605,8 +35867,8 @@ function seeOverlay(sctx, entity) {
|
|
|
35605
35867
|
record.top = top;
|
|
35606
35868
|
record.object = object;
|
|
35607
35869
|
record.container = object.parent;
|
|
35608
|
-
record.layer =
|
|
35609
|
-
record.layerIndex =
|
|
35870
|
+
record.layer = layer.name;
|
|
35871
|
+
record.layerIndex = index;
|
|
35610
35872
|
record.level = Math.min(1, Math.max(0, level?.level ?? 0));
|
|
35611
35873
|
const turned = known === void 0 || phase === record.phase ? void 0 : phase;
|
|
35612
35874
|
record.turned = turned;
|
|
@@ -35633,12 +35895,14 @@ function note(sctx, record, what, mode) {
|
|
|
35633
35895
|
});
|
|
35634
35896
|
}
|
|
35635
35897
|
/**
|
|
35636
|
-
* Drops a record whose entity lost `Overlay` or its view: its dim
|
|
35898
|
+
* Drops a record whose entity lost `Overlay` or its view: its dim and its HUD render layer go in this frame, the HUD
|
|
35899
|
+
* let go first when it held it, `"gone"` is noted.
|
|
35637
35900
|
*
|
|
35638
35901
|
* @param sctx - Domain context of the sync module.
|
|
35639
35902
|
* @param record - The overlay that left.
|
|
35640
35903
|
*/
|
|
35641
35904
|
function dropRecord(sctx, record) {
|
|
35905
|
+
dropUnder(sctx, record);
|
|
35642
35906
|
if (record.dim !== void 0) {
|
|
35643
35907
|
sctx.deps.demand.whole("overlay");
|
|
35644
35908
|
if (!record.dim.destroyed) record.dim.destroy();
|
|
@@ -35660,15 +35924,16 @@ function compareRank(left, right) {
|
|
|
35660
35924
|
return left.container.getChildIndex(left.object) - right.container.getChildIndex(right.object);
|
|
35661
35925
|
}
|
|
35662
35926
|
/**
|
|
35663
|
-
* Fills `order` with the records bottom first: an insertion sort on the reused array
|
|
35927
|
+
* Fills `order` with the records bottom first: an insertion sort on the reused array, written in place and cut to the
|
|
35928
|
+
* count (V8 gives an array set to length 0 a new backing store at the next write).
|
|
35664
35929
|
*
|
|
35665
35930
|
* @param overlay - The overlay state.
|
|
35666
35931
|
*/
|
|
35667
35932
|
function sortOrder(overlay) {
|
|
35668
35933
|
const { order } = overlay;
|
|
35669
|
-
|
|
35934
|
+
let count = 0;
|
|
35670
35935
|
for (const record of overlay.records.values()) {
|
|
35671
|
-
let at =
|
|
35936
|
+
let at = count;
|
|
35672
35937
|
while (at > 0) {
|
|
35673
35938
|
const before = order[at - 1];
|
|
35674
35939
|
if (before === void 0 || compareRank(before, record) <= 0) break;
|
|
@@ -35676,7 +35941,9 @@ function sortOrder(overlay) {
|
|
|
35676
35941
|
at -= 1;
|
|
35677
35942
|
}
|
|
35678
35943
|
order[at] = record;
|
|
35944
|
+
count += 1;
|
|
35679
35945
|
}
|
|
35946
|
+
order.length = count;
|
|
35680
35947
|
}
|
|
35681
35948
|
/**
|
|
35682
35949
|
* The alpha a set of filters multiplies by: every enabled `AlphaFilter` among them.
|
|
@@ -35766,8 +36033,9 @@ function overlaysIdle(overlay) {
|
|
|
35766
36033
|
}
|
|
35767
36034
|
/**
|
|
35768
36035
|
* The overlay step of the render phase (the body of `SyncInternal.stepOverlays`): the records, their order and modes,
|
|
35769
|
-
* the dims, the range with its reasons and its picture,
|
|
35770
|
-
*
|
|
36036
|
+
* the dims and their HUD render layers, the range with its reasons and its picture, the overlay that holds the HUD
|
|
36037
|
+
* under its dim, and the HUD parts, in that order. New layers let the range and the HUD go first; both are built again
|
|
36038
|
+
* from the new layers in the same step.
|
|
35771
36039
|
*
|
|
35772
36040
|
* @param sctx - Domain context of the sync module.
|
|
35773
36041
|
*/
|
|
@@ -35777,7 +36045,10 @@ function stepOverlays(sctx) {
|
|
|
35777
36045
|
if (state.root === void 0 || overlaysIdle(overlay)) return;
|
|
35778
36046
|
const wholes = sctx.deps.demand.wholes();
|
|
35779
36047
|
if (overlay.flipped.size > 0) overlay.flipped.clear();
|
|
35780
|
-
if (wholes.has("layers"))
|
|
36048
|
+
if (wholes.has("layers")) {
|
|
36049
|
+
clearRange(sctx);
|
|
36050
|
+
dropUnders(sctx);
|
|
36051
|
+
}
|
|
35781
36052
|
for (const record of overlay.records.values()) record.seen = false;
|
|
35782
36053
|
for (const entity of overlay.entities) seeOverlay(sctx, entity);
|
|
35783
36054
|
for (const record of overlay.records.values()) if (!record.seen) dropRecord(sctx, record);
|
|
@@ -35789,6 +36060,7 @@ function stepOverlays(sctx) {
|
|
|
35789
36060
|
if (record.news !== void 0) note(sctx, record, record.news, modeReported(overlay, record));
|
|
35790
36061
|
record.news = void 0;
|
|
35791
36062
|
}
|
|
36063
|
+
stepHold(sctx);
|
|
35792
36064
|
stepParts(sctx);
|
|
35793
36065
|
overlay.left = false;
|
|
35794
36066
|
}
|
|
@@ -37352,6 +37624,8 @@ function createOverlayState() {
|
|
|
37352
37624
|
active: void 0,
|
|
37353
37625
|
range: void 0,
|
|
37354
37626
|
offTops: emptySet$4(),
|
|
37627
|
+
held: void 0,
|
|
37628
|
+
heldBy: void 0,
|
|
37355
37629
|
warned: emptySet$4(),
|
|
37356
37630
|
events: [],
|
|
37357
37631
|
wantEntries: [],
|
|
@@ -37359,6 +37633,13 @@ function createOverlayState() {
|
|
|
37359
37633
|
wantSet: emptySet$4(),
|
|
37360
37634
|
flipped: emptySet$4(),
|
|
37361
37635
|
nextOff: emptySet$4(),
|
|
37636
|
+
offList: [],
|
|
37637
|
+
step: {
|
|
37638
|
+
fresh: false,
|
|
37639
|
+
entriesChanged: false,
|
|
37640
|
+
othersChanged: false,
|
|
37641
|
+
wholes: emptySet$4()
|
|
37642
|
+
},
|
|
37362
37643
|
left: false,
|
|
37363
37644
|
bounds: void 0
|
|
37364
37645
|
};
|
|
@@ -46753,11 +47034,35 @@ function resetSession(state) {
|
|
|
46753
47034
|
session.type = "auto";
|
|
46754
47035
|
} catch {}
|
|
46755
47036
|
}
|
|
47037
|
+
/**
|
|
47038
|
+
* Tells whether the screen takes touches: iOS and iPadOS answer at least 1, Safari on a Mac 0.
|
|
47039
|
+
*
|
|
47040
|
+
* @returns True when the runtime reports a touch point.
|
|
47041
|
+
*/
|
|
47042
|
+
function hasTouch() {
|
|
47043
|
+
if (typeof globalThis.navigator === "undefined") return false;
|
|
47044
|
+
return (globalThis.navigator.maxTouchPoints ?? 0) > 0;
|
|
47045
|
+
}
|
|
47046
|
+
/**
|
|
47047
|
+
* Writes one type on the session the plugin holds. A setter that throws changes nothing: the
|
|
47048
|
+
* renewal goes on with the session as it is.
|
|
47049
|
+
*
|
|
47050
|
+
* @param state - The plugin state, which holds the session.
|
|
47051
|
+
* @param type - What to write, `"auto"` to lift the override.
|
|
47052
|
+
*/
|
|
47053
|
+
function writeSession(state, type) {
|
|
47054
|
+
const session = state.session;
|
|
47055
|
+
if (session === void 0) return;
|
|
47056
|
+
try {
|
|
47057
|
+
session.type = type;
|
|
47058
|
+
} catch {}
|
|
47059
|
+
}
|
|
46756
47060
|
//#endregion
|
|
46757
47061
|
//#region src/plugins/audio/unlock.ts
|
|
46758
47062
|
/**
|
|
46759
|
-
* @file audio plugin — the unlock: the
|
|
46760
|
-
* context suspended and lets it run on a user gesture, so two
|
|
47063
|
+
* @file audio plugin — the unlock: with the renewal of `context.ts`, the only file that touches
|
|
47064
|
+
* `window`. A browser starts an audio context suspended and lets it run on a user gesture, so two
|
|
47065
|
+
* listeners wait for the first one.
|
|
46761
47066
|
* They sit on `window`, not on the canvas: the gesture may as well be a button of the game's
|
|
46762
47067
|
* loading page, which `input` never sees. A shell that asks for no gesture, such as a native
|
|
46763
47068
|
* webview with the requirement switched off, lets the context run at once. So the plugin also
|
|
@@ -46767,8 +47072,8 @@ function resetSession(state) {
|
|
|
46767
47072
|
const UNLOCK_EVENTS = ["pointerdown", "touchend"];
|
|
46768
47073
|
/**
|
|
46769
47074
|
* Reacts to a resume that went through, of a gesture or of the start attempt. The context is
|
|
46770
|
-
* unlocked only when it really runs
|
|
46771
|
-
* declared while it was locked start here. A context that still does not run drops the sounds:
|
|
47075
|
+
* unlocked only when it really runs, and only then do the listeners come off; the sounds fired
|
|
47076
|
+
* during the resume and the track a scene declared while it was locked start here. A context that still does not run drops the sounds:
|
|
46772
47077
|
* the next gesture is a new moment. A gesture and the start attempt that settle together both
|
|
46773
47078
|
* come here, and the music still starts once: a track that is on its way or already plays is not
|
|
46774
47079
|
* started again. A later gesture on an unlocked context tries a remembered track again.
|
|
@@ -46784,6 +47089,7 @@ function onResumed(ctx) {
|
|
|
46784
47089
|
return;
|
|
46785
47090
|
}
|
|
46786
47091
|
state.unlocked = true;
|
|
47092
|
+
removeUnlock(state);
|
|
46787
47093
|
drainSfx(ctx);
|
|
46788
47094
|
const remembered = state.music;
|
|
46789
47095
|
if (remembered === void 0 || isMusicPlaying(state)) return;
|
|
@@ -46804,9 +47110,10 @@ function drainSfx(ctx) {
|
|
|
46804
47110
|
for (const request of queued) playRequest(ctx, request);
|
|
46805
47111
|
}
|
|
46806
47112
|
/**
|
|
46807
|
-
* Asks the context to run and marks it `resuming` until the answer comes.
|
|
46808
|
-
*
|
|
46809
|
-
* gesture
|
|
47113
|
+
* Asks the context to run and marks it `resuming` until the answer comes. The listeners go back on
|
|
47114
|
+
* before the resume: while iOS keeps the audio session away, WebKit holds this promise pending, and
|
|
47115
|
+
* the next gesture must try again (F146). A browser that refuses says so once in the log, drops the
|
|
47116
|
+
* sounds that waited and keeps the listeners.
|
|
46810
47117
|
*
|
|
46811
47118
|
* @param ctx - Domain context of the plugin.
|
|
46812
47119
|
*/
|
|
@@ -46814,6 +47121,7 @@ function resumeContext(ctx) {
|
|
|
46814
47121
|
const context = ctx.state.context;
|
|
46815
47122
|
if (context === void 0) return;
|
|
46816
47123
|
ctx.state.resuming = true;
|
|
47124
|
+
installUnlock(ctx);
|
|
46817
47125
|
context.resume().then(() => {
|
|
46818
47126
|
onResumed(ctx);
|
|
46819
47127
|
}, () => {
|
|
@@ -46902,10 +47210,158 @@ function removeUnlock(state) {
|
|
|
46902
47210
|
state.unlock = void 0;
|
|
46903
47211
|
}
|
|
46904
47212
|
//#endregion
|
|
47213
|
+
//#region src/plugins/audio/context.ts
|
|
47214
|
+
/**
|
|
47215
|
+
* @file audio plugin — the one context of the app: making it, and renewing it after a return from
|
|
47216
|
+
* the background on iOS (F149).
|
|
47217
|
+
*
|
|
47218
|
+
* With the `ambient` session, a short trip to the background leaves WebKit silent for good. iOS
|
|
47219
|
+
* deactivates the session, WebKit drops iOS's end of the interruption as spurious and keeps its
|
|
47220
|
+
* cached "active" flag, so it never asks iOS again. Only a closed last context resets the flag:
|
|
47221
|
+
* the renewal lifts the session override, closes the context, writes the session again and makes
|
|
47222
|
+
* a new context, which activates the session for real.
|
|
47223
|
+
*
|
|
47224
|
+
* The timing comes from the iPhone logs. `visibilitychange` fires about 0.3–0.7 s before iOS makes
|
|
47225
|
+
* the app active, and iOS refuses an activation before that, with no retry (build 9). So the
|
|
47226
|
+
* renewal waits a second after the return (build 10, proven on two iPhones), or runs at the first
|
|
47227
|
+
* touch that comes sooner: a touch reaches only an active app. On a healthy session the renewal
|
|
47228
|
+
* costs the sounds in flight and starts the music again.
|
|
47229
|
+
*/
|
|
47230
|
+
/** How long the renewal waits after the return, in real milliseconds. */
|
|
47231
|
+
const RENEW_DELAY_MS = 1e3;
|
|
47232
|
+
/** The gestures that renew at once: the app is active when a touch arrives. */
|
|
47233
|
+
const RENEW_EVENTS = ["pointerdown", "touchend"];
|
|
47234
|
+
/**
|
|
47235
|
+
* Makes the one context of the app: the configured factory, the browser's own constructor, or
|
|
47236
|
+
* nothing at all, which is a headless run. A renewal calls it again.
|
|
47237
|
+
*
|
|
47238
|
+
* @param config - The resolved plugin config.
|
|
47239
|
+
* @returns The context, or `undefined` where the runtime has no WebAudio.
|
|
47240
|
+
*/
|
|
47241
|
+
function createContext(config) {
|
|
47242
|
+
if (config.context !== void 0) return config.context();
|
|
47243
|
+
const browserContext = globalThis.AudioContext;
|
|
47244
|
+
return typeof browserContext === "function" ? new browserContext() : void 0;
|
|
47245
|
+
}
|
|
47246
|
+
/**
|
|
47247
|
+
* Tells whether a return from the background renews the context: a context exists, WebKit took
|
|
47248
|
+
* the session override, the session is not `"playback"` (iOS keeps that one active in the
|
|
47249
|
+
* background), and the screen takes touches, which leaves Safari on a Mac out.
|
|
47250
|
+
*
|
|
47251
|
+
* @param ctx - Domain context of the plugin.
|
|
47252
|
+
* @returns True on iOS and iPadOS with an `ambient` or `auto` session.
|
|
47253
|
+
*/
|
|
47254
|
+
function canRenew(ctx) {
|
|
47255
|
+
const state = ctx.state;
|
|
47256
|
+
return state.context !== void 0 && state.session !== void 0 && ctx.config.session !== "playback" && hasTouch();
|
|
47257
|
+
}
|
|
47258
|
+
/**
|
|
47259
|
+
* Schedules the renewal after a return from the background: a second later, or at the first
|
|
47260
|
+
* touch before that. A second return replaces the renewal that waits.
|
|
47261
|
+
*
|
|
47262
|
+
* @param ctx - Domain context of the plugin.
|
|
47263
|
+
*/
|
|
47264
|
+
function scheduleRenewal(ctx) {
|
|
47265
|
+
const state = ctx.state;
|
|
47266
|
+
if (!canRenew(ctx)) return;
|
|
47267
|
+
cancelRenewal(state);
|
|
47268
|
+
/**
|
|
47269
|
+
* Cancels what waits and renews. The timer and the first touch both come here; the first wins.
|
|
47270
|
+
*/
|
|
47271
|
+
const renew = () => {
|
|
47272
|
+
cancelRenewal(state);
|
|
47273
|
+
renewContext(ctx);
|
|
47274
|
+
};
|
|
47275
|
+
const timer = setTimeout(renew, RENEW_DELAY_MS);
|
|
47276
|
+
const target = typeof globalThis.window === "undefined" ? void 0 : globalThis.window;
|
|
47277
|
+
if (target !== void 0) for (const type of RENEW_EVENTS) target.addEventListener(type, renew, {
|
|
47278
|
+
once: true,
|
|
47279
|
+
passive: true
|
|
47280
|
+
});
|
|
47281
|
+
state.renewal = () => {
|
|
47282
|
+
clearTimeout(timer);
|
|
47283
|
+
if (target === void 0) return;
|
|
47284
|
+
for (const type of RENEW_EVENTS) target.removeEventListener(type, renew);
|
|
47285
|
+
};
|
|
47286
|
+
}
|
|
47287
|
+
/**
|
|
47288
|
+
* Cancels the renewal that waits: the game went to the background again, or the app stops. A
|
|
47289
|
+
* renewal that already runs goes on.
|
|
47290
|
+
*
|
|
47291
|
+
* @param state - The plugin state.
|
|
47292
|
+
*/
|
|
47293
|
+
function cancelRenewal(state) {
|
|
47294
|
+
state.renewal?.();
|
|
47295
|
+
state.renewal = void 0;
|
|
47296
|
+
}
|
|
47297
|
+
/**
|
|
47298
|
+
* Drops every sound of the old context and keeps the music key: the track that plays, or the
|
|
47299
|
+
* switch on its way. A decode still running on the old context may reject when it closes; such a
|
|
47300
|
+
* key is forgotten, so its next play decodes again.
|
|
47301
|
+
*
|
|
47302
|
+
* @param state - The plugin state.
|
|
47303
|
+
*/
|
|
47304
|
+
function dropInFlight(state) {
|
|
47305
|
+
const key = state.musicPending?.key ?? state.music?.key;
|
|
47306
|
+
stopMusic(state);
|
|
47307
|
+
stopAllNamed(state);
|
|
47308
|
+
for (const entry of state.retiring) disposeStream(state, entry.stream);
|
|
47309
|
+
state.pendingSfx.clear();
|
|
47310
|
+
if (key !== void 0) state.music = {
|
|
47311
|
+
key,
|
|
47312
|
+
gain: void 0,
|
|
47313
|
+
source: void 0,
|
|
47314
|
+
stream: void 0
|
|
47315
|
+
};
|
|
47316
|
+
for (const [decodedKey, pending] of state.decoded) pending.catch(() => {
|
|
47317
|
+
if (state.decoded.get(decodedKey) === pending) state.decoded.delete(decodedKey);
|
|
47318
|
+
});
|
|
47319
|
+
}
|
|
47320
|
+
/**
|
|
47321
|
+
* Renews the context: the old one goes with every sound in it, the session is written again, and
|
|
47322
|
+
* a new context gets the graph at the same volumes and the unlock. The decoded buffers stay, an
|
|
47323
|
+
* AudioBuffer is bound to no context. The unlock starts the remembered music once the new context
|
|
47324
|
+
* runs. While the old context closes the plugin is headless: a sound is dropped and a music switch
|
|
47325
|
+
* is remembered. A stop, or a newer renewal, during the close makes this one end there.
|
|
47326
|
+
*
|
|
47327
|
+
* @param ctx - Domain context of the plugin.
|
|
47328
|
+
*/
|
|
47329
|
+
async function renewContext(ctx) {
|
|
47330
|
+
const state = ctx.state;
|
|
47331
|
+
const old = state.context;
|
|
47332
|
+
if (old === void 0) return;
|
|
47333
|
+
const token = {};
|
|
47334
|
+
state.renewing = token;
|
|
47335
|
+
removeUnlock(state);
|
|
47336
|
+
dropInFlight(state);
|
|
47337
|
+
state.context = void 0;
|
|
47338
|
+
state.unlocked = false;
|
|
47339
|
+
state.resuming = false;
|
|
47340
|
+
writeSession(state, "auto");
|
|
47341
|
+
await old.close().catch(ignoreFailure);
|
|
47342
|
+
if (state.renewing !== token) return;
|
|
47343
|
+
state.renewing = void 0;
|
|
47344
|
+
writeSession(state, ctx.config.session);
|
|
47345
|
+
const fresh = createContext(ctx.config);
|
|
47346
|
+
if (fresh === void 0 || fresh === old) {
|
|
47347
|
+
ctx.log.warn("audio: no new context after the return, the sound stays off");
|
|
47348
|
+
return;
|
|
47349
|
+
}
|
|
47350
|
+
state.context = fresh;
|
|
47351
|
+
state.buses = buildGraph(fresh, state.buses);
|
|
47352
|
+
applyAllGains(state);
|
|
47353
|
+
startUnlock(ctx);
|
|
47354
|
+
}
|
|
47355
|
+
/**
|
|
47356
|
+
* Swallows a close that failed. A context the browser already tore down is gone either way, and
|
|
47357
|
+
* neither a teardown nor a renewal has anybody to report it to.
|
|
47358
|
+
*/
|
|
47359
|
+
function ignoreFailure() {}
|
|
47360
|
+
//#endregion
|
|
46905
47361
|
//#region src/plugins/audio/lifecycle.ts
|
|
46906
47362
|
/**
|
|
46907
|
-
* @file audio plugin — lifecycle: the dependency resolution, the
|
|
46908
|
-
* graph and its unlock, and the teardown that frees exactly what was opened.
|
|
47363
|
+
* @file audio plugin — lifecycle: the dependency resolution, the start that puts the context of
|
|
47364
|
+
* `context.ts` in with its graph and its unlock, and the teardown that frees exactly what was opened.
|
|
46909
47365
|
*/
|
|
46910
47366
|
/**
|
|
46911
47367
|
* Resolves the dependency APIs `flow`, `assets`, `model` and `time` with `ctx.require`.
|
|
@@ -46936,27 +47392,10 @@ function withDeps$4(ctx) {
|
|
|
46936
47392
|
};
|
|
46937
47393
|
}
|
|
46938
47394
|
/**
|
|
46939
|
-
* Swallows a close that failed. A context the browser already tore down is gone either way, and
|
|
46940
|
-
* a teardown has nobody left to report to.
|
|
46941
|
-
*/
|
|
46942
|
-
function ignoreFailure() {}
|
|
46943
|
-
/**
|
|
46944
|
-
* Makes the one context of the app: the configured factory, the browser's own constructor, or
|
|
46945
|
-
* nothing at all, which is a headless run.
|
|
46946
|
-
*
|
|
46947
|
-
* @param config - The resolved plugin config.
|
|
46948
|
-
* @returns The context, or `undefined` where the runtime has no WebAudio.
|
|
46949
|
-
*/
|
|
46950
|
-
function createContext(config) {
|
|
46951
|
-
if (config.context !== void 0) return config.context();
|
|
46952
|
-
const browserContext = globalThis.AudioContext;
|
|
46953
|
-
return typeof browserContext === "function" ? new browserContext() : void 0;
|
|
46954
|
-
}
|
|
46955
|
-
/**
|
|
46956
47395
|
* Starts the plugin in `onStart`: the audio session first, before any sound exists, then the
|
|
46957
|
-
* three effect handlers, then the context with its graph and its unlock. The unlock asks the
|
|
46958
|
-
* run at once: a shell that lets audio play is unlocked with no touch, and a browser
|
|
46959
|
-
* gesture gets the two listeners. The handlers are registered even headless, so a node that
|
|
47396
|
+
* three effect handlers, then the context with its graph and its unlock. The unlock asks the
|
|
47397
|
+
* context to run at once: a shell that lets audio play is unlocked with no touch, and a browser
|
|
47398
|
+
* that wants a gesture gets the two listeners. The handlers are registered even headless, so a node that
|
|
46960
47399
|
* awaits a sound resolves in plain Bun exactly as it does in a browser.
|
|
46961
47400
|
*
|
|
46962
47401
|
* @param ctx - Kernel context of the audio plugin.
|
|
@@ -46976,16 +47415,18 @@ function startAudio(ctx) {
|
|
|
46976
47415
|
}
|
|
46977
47416
|
/**
|
|
46978
47417
|
* Frees everything `onStart` opened: the three handler registrations, the two window listeners,
|
|
46979
|
-
* the music track, every named sound, every streamed track still
|
|
46980
|
-
* journal, the audio session and the context itself. The tracks are
|
|
46981
|
-
*
|
|
46982
|
-
* teardown.
|
|
47418
|
+
* a renewal that waits or runs, the music track, every named sound, every streamed track still
|
|
47419
|
+
* fading with its timer, the journal, the audio session and the context itself. The tracks are
|
|
47420
|
+
* freed before the close, while their nodes can still disconnect. A browser caps how many
|
|
47421
|
+
* contexts a page may hold, so the close is the point of this teardown.
|
|
46983
47422
|
*
|
|
46984
47423
|
* @param state - The plugin state, all a teardown context carries.
|
|
46985
47424
|
* @returns A promise that resolves when the context is closed.
|
|
46986
47425
|
*/
|
|
46987
47426
|
async function stopAudio(state) {
|
|
46988
47427
|
for (const remove of state.removers.splice(0)) remove();
|
|
47428
|
+
cancelRenewal(state);
|
|
47429
|
+
state.renewing = void 0;
|
|
46989
47430
|
removeUnlock(state);
|
|
46990
47431
|
stopMusic(state);
|
|
46991
47432
|
stopAllNamed(state);
|
|
@@ -47040,20 +47481,46 @@ function read$1(ctx, volumes) {
|
|
|
47040
47481
|
}
|
|
47041
47482
|
}
|
|
47042
47483
|
/**
|
|
47484
|
+
* Tells whether the OS stopped a context: suspended, or Safari's `"interrupted"`.
|
|
47485
|
+
*
|
|
47486
|
+
* @param context - The audio context of this app.
|
|
47487
|
+
* @returns True when the context waits for a resume.
|
|
47488
|
+
*/
|
|
47489
|
+
function isSilenced(context) {
|
|
47490
|
+
return context.state === "suspended" || context.state === "interrupted";
|
|
47491
|
+
}
|
|
47492
|
+
/**
|
|
47043
47493
|
* Resumes a context the OS silenced while the game was away. Safari leaves it `"interrupted"`
|
|
47044
|
-
* after a call
|
|
47494
|
+
* after a call, a screenshot or Control Center, and WebKit may hold this resume pending for as
|
|
47495
|
+
* long as iOS keeps the audio session (F146). So the unlock listeners go on before the resume and
|
|
47496
|
+
* come off only once the context runs: until then every touch tries again.
|
|
47045
47497
|
*
|
|
47046
47498
|
* @param ctx - Domain context of the plugin.
|
|
47047
47499
|
*/
|
|
47048
47500
|
function resumeAfterPause(ctx) {
|
|
47049
|
-
const
|
|
47050
|
-
|
|
47051
|
-
if (context
|
|
47052
|
-
|
|
47501
|
+
const state = ctx.state;
|
|
47502
|
+
const context = state.context;
|
|
47503
|
+
if (context === void 0 || !state.unlocked || !isSilenced(context)) return;
|
|
47504
|
+
installUnlock(ctx);
|
|
47505
|
+
context.resume().then(() => {
|
|
47506
|
+
if (state.context === context && context.state === "running") removeUnlock(state);
|
|
47507
|
+
}, () => {
|
|
47053
47508
|
installUnlock(ctx);
|
|
47054
47509
|
});
|
|
47055
47510
|
}
|
|
47056
47511
|
/**
|
|
47512
|
+
* Follows the `"background"` reason of the pause: its push cancels a renewal that waits, its pop
|
|
47513
|
+
* schedules one (F149). Any other reason leaves the context alone.
|
|
47514
|
+
*
|
|
47515
|
+
* @param ctx - Domain context of the plugin.
|
|
47516
|
+
* @param payload - What changed on the pause stack.
|
|
47517
|
+
*/
|
|
47518
|
+
function followBackground(ctx, payload) {
|
|
47519
|
+
if (payload.reason !== "background") return;
|
|
47520
|
+
if (payload.action === "push") cancelRenewal(ctx.state);
|
|
47521
|
+
else scheduleRenewal(ctx);
|
|
47522
|
+
}
|
|
47523
|
+
/**
|
|
47057
47524
|
* Forgets the decoded buffer and the one warning of every key named. A key that is no sound is in
|
|
47058
47525
|
* neither, so it costs nothing. A source that is playing holds its own buffer and plays on.
|
|
47059
47526
|
*
|
|
@@ -47110,7 +47577,8 @@ function createHandlers$3(ctx) {
|
|
|
47110
47577
|
/**
|
|
47111
47578
|
* Holds every bus at zero while the game is paused and puts the volumes back when it is not.
|
|
47112
47579
|
* The stored volumes and mutes are untouched, so nothing is lost over a pause. A streamed
|
|
47113
|
-
* track is paused once the gains are at zero and plays again when the pause ends.
|
|
47580
|
+
* track is paused once the gains are at zero and plays again when the pause ends. On iOS the
|
|
47581
|
+
* return from the background also schedules the renewal of the context.
|
|
47114
47582
|
*
|
|
47115
47583
|
* @param payload - What changed on the pause stack.
|
|
47116
47584
|
*/
|
|
@@ -47123,6 +47591,7 @@ function createHandlers$3(ctx) {
|
|
|
47123
47591
|
resumeAfterPause(audioCtx);
|
|
47124
47592
|
resumeMusic(audioCtx);
|
|
47125
47593
|
}
|
|
47594
|
+
followBackground(audioCtx, payload);
|
|
47126
47595
|
},
|
|
47127
47596
|
/**
|
|
47128
47597
|
* Drops the decoded sounds of a bundle that left. A source that is playing keeps its buffer
|
|
@@ -47233,6 +47702,8 @@ function createAudioState(ctx) {
|
|
|
47233
47702
|
music: void 0,
|
|
47234
47703
|
musicPending: void 0,
|
|
47235
47704
|
unlock: void 0,
|
|
47705
|
+
renewal: void 0,
|
|
47706
|
+
renewing: void 0,
|
|
47236
47707
|
removers: [],
|
|
47237
47708
|
session: void 0,
|
|
47238
47709
|
retiring: emptyRetiring(),
|
|
@@ -57686,6 +58157,10 @@ const TOKENS = /(\n| +)/;
|
|
|
57686
58157
|
const HYPHEN_BREAKS = /(?<=[^\-\u2010][-\u2010])(?=[^\-\u2010\d])/;
|
|
57687
58158
|
/** The soft hyphen: a break the text allows, drawn as `-` only when the line breaks there. */
|
|
57688
58159
|
const SOFT_HYPHEN = "";
|
|
58160
|
+
/** The most lines a balanced style evens out; a longer block keeps its greedy lines, as Chrome. */
|
|
58161
|
+
const BALANCE_MAX_LINES = 6;
|
|
58162
|
+
/** How many halvings the search for the balanced width takes: 2⁻¹⁶ of the range is left. */
|
|
58163
|
+
const BALANCE_STEPS = 16;
|
|
57689
58164
|
/**
|
|
57690
58165
|
* Tells whether a value is a plain record, so its fields can be read one by one.
|
|
57691
58166
|
*
|
|
@@ -57923,19 +58398,32 @@ function measureRun(run, style, tables, options) {
|
|
|
57923
58398
|
return width;
|
|
57924
58399
|
}
|
|
57925
58400
|
/**
|
|
58401
|
+
* Tells whether a glyph piece may join the last run of a line: both glyphs, with the same bold,
|
|
58402
|
+
* italic and colour. An icon never merges.
|
|
58403
|
+
*
|
|
58404
|
+
* @param last - The last run of the line, if any.
|
|
58405
|
+
* @param piece - The glyph piece to append.
|
|
58406
|
+
* @returns True when the piece's text may be added to `last`.
|
|
58407
|
+
*/
|
|
58408
|
+
function canMerge(last, piece) {
|
|
58409
|
+
return last?.kind === "text" && last.bold === piece.bold && last.italic === piece.italic && last.color === piece.color;
|
|
58410
|
+
}
|
|
58411
|
+
/**
|
|
57926
58412
|
* Appends a piece to a line, merging glyphs into the last run when both are glyphs with the same
|
|
57927
|
-
* flags. An icon is always a run of its own.
|
|
58413
|
+
* flags. An icon is always a run of its own. A glyph piece is pushed as a copy, so the merge
|
|
58414
|
+
* writes into the line's own run and never into the token the piece came from: a balanced style
|
|
58415
|
+
* runs the wrap pass over the same tokens more than once.
|
|
57928
58416
|
*
|
|
57929
58417
|
* @param runs - The runs of the line so far.
|
|
57930
58418
|
* @param piece - The piece to append.
|
|
57931
58419
|
*/
|
|
57932
58420
|
function appendRun(runs, piece) {
|
|
57933
58421
|
const last = runs.at(-1);
|
|
57934
|
-
if (piece.kind === "text" && last
|
|
58422
|
+
if (piece.kind === "text" && canMerge(last, piece)) {
|
|
57935
58423
|
last.text += piece.text;
|
|
57936
58424
|
return;
|
|
57937
58425
|
}
|
|
57938
|
-
runs.push(piece);
|
|
58426
|
+
runs.push(piece.kind === "text" ? { ...piece } : piece);
|
|
57939
58427
|
}
|
|
57940
58428
|
/**
|
|
57941
58429
|
* Lays runs out with no wrapping: one line per `\n` segment.
|
|
@@ -58188,22 +58676,23 @@ function placeWord(builder, token, pending, wrap, metrics) {
|
|
|
58188
58676
|
else breakWord(builder, token, wrap, metrics);
|
|
58189
58677
|
}
|
|
58190
58678
|
/**
|
|
58191
|
-
* Lays
|
|
58192
|
-
* joins two parts and at a soft hyphen; a word wider than the wrap breaks
|
|
58679
|
+
* Lays tokens out into lines no wider than the wrap: the greedy pass. Words break between them,
|
|
58680
|
+
* after a hyphen that joins two parts and at a soft hyphen; a word wider than the wrap breaks
|
|
58681
|
+
* between its glyphs. The tokens are read and never changed, so the pass may run on them again.
|
|
58193
58682
|
*
|
|
58194
|
-
* @param
|
|
58683
|
+
* @param tokens - The tokens of the block.
|
|
58195
58684
|
* @param metrics - The style, the tables and the warning.
|
|
58196
58685
|
* @param wrap - The wrap width in reference pixels.
|
|
58197
58686
|
* @returns The lines, each with its width.
|
|
58198
58687
|
*/
|
|
58199
|
-
function
|
|
58688
|
+
function wrapTokens(tokens, metrics, wrap) {
|
|
58200
58689
|
const builder = {
|
|
58201
58690
|
lines: [],
|
|
58202
58691
|
runs: [],
|
|
58203
58692
|
width: 0
|
|
58204
58693
|
};
|
|
58205
58694
|
let pending;
|
|
58206
|
-
for (const token of
|
|
58695
|
+
for (const token of tokens) {
|
|
58207
58696
|
if (token.kind === "break") {
|
|
58208
58697
|
commit(builder);
|
|
58209
58698
|
pending = void 0;
|
|
@@ -58224,6 +58713,59 @@ function layoutWrapped(runs, metrics, wrap) {
|
|
|
58224
58713
|
return builder.lines;
|
|
58225
58714
|
}
|
|
58226
58715
|
/**
|
|
58716
|
+
* The narrowest line a word may stand on whole: the widest word with the `-` a break after it
|
|
58717
|
+
* draws. Below it a word breaks between its glyphs or its hyphen stands past the line.
|
|
58718
|
+
*
|
|
58719
|
+
* @param tokens - The tokens of the block.
|
|
58720
|
+
* @returns The width in reference pixels; 0 for a block with no word.
|
|
58721
|
+
* @example
|
|
58722
|
+
* ```ts
|
|
58723
|
+
* widestWord([{ kind: "word", runs: [], width: 80, tail: 0 }]); // 80
|
|
58724
|
+
* ```
|
|
58725
|
+
*/
|
|
58726
|
+
function widestWord(tokens) {
|
|
58727
|
+
let widest = 0;
|
|
58728
|
+
for (const token of tokens) if (token.kind === "word") widest = Math.max(widest, token.width + token.tail);
|
|
58729
|
+
return widest;
|
|
58730
|
+
}
|
|
58731
|
+
/**
|
|
58732
|
+
* Evens the greedy lines of a balanced style: the narrowest width in `[widest word, wrap]` that
|
|
58733
|
+
* keeps their number, found in 16 halvings, and the lines at that width. A block of one line or of
|
|
58734
|
+
* more than six, or with a word that does not fit the wrap whole, keeps its greedy lines.
|
|
58735
|
+
*
|
|
58736
|
+
* @param tokens - The tokens of the block, as the greedy pass read them.
|
|
58737
|
+
* @param greedy - The greedy lines at the wrap.
|
|
58738
|
+
* @param metrics - The style, the tables and the warning.
|
|
58739
|
+
* @param wrap - The wrap width in reference pixels.
|
|
58740
|
+
* @returns The balanced lines, or the greedy ones.
|
|
58741
|
+
*/
|
|
58742
|
+
function balanceLines(tokens, greedy, metrics, wrap) {
|
|
58743
|
+
const count = greedy.length;
|
|
58744
|
+
let low = widestWord(tokens);
|
|
58745
|
+
let high = wrap;
|
|
58746
|
+
if (count < 2 || count > BALANCE_MAX_LINES || low >= high) return greedy;
|
|
58747
|
+
for (let step = 0; step < BALANCE_STEPS; step += 1) {
|
|
58748
|
+
const middle = (low + high) / 2;
|
|
58749
|
+
if (wrapTokens(tokens, metrics, middle).length <= count) high = middle;
|
|
58750
|
+
else low = middle;
|
|
58751
|
+
}
|
|
58752
|
+
return high === wrap ? greedy : wrapTokens(tokens, metrics, high);
|
|
58753
|
+
}
|
|
58754
|
+
/**
|
|
58755
|
+
* Lays runs out into lines no wider than the wrap, evened out when the style balances. The tokens
|
|
58756
|
+
* are made once; the balance runs the wrap pass on them again.
|
|
58757
|
+
*
|
|
58758
|
+
* @param runs - The runs of the block.
|
|
58759
|
+
* @param metrics - The style, the tables and the warning.
|
|
58760
|
+
* @param wrap - The wrap width in reference pixels.
|
|
58761
|
+
* @returns The lines, each with its width.
|
|
58762
|
+
*/
|
|
58763
|
+
function layoutWrapped(runs, metrics, wrap) {
|
|
58764
|
+
const tokens = tokenise(runs, metrics.style, metrics.tables, metrics.options);
|
|
58765
|
+
const greedy = wrapTokens(tokens, metrics, wrap);
|
|
58766
|
+
return metrics.style.balance === true ? balanceLines(tokens, greedy, metrics, wrap) : greedy;
|
|
58767
|
+
}
|
|
58768
|
+
/**
|
|
58227
58769
|
* Wraps the caller's warning so one key is reported once per layout.
|
|
58228
58770
|
*
|
|
58229
58771
|
* @param options - What the caller passed.
|
|
@@ -69638,6 +70180,15 @@ function askedOffsetOf(container) {
|
|
|
69638
70180
|
return typeof offset === "number" && Number.isFinite(offset) ? offset : 0;
|
|
69639
70181
|
}
|
|
69640
70182
|
/**
|
|
70183
|
+
* Whether the scroll's last render asks a new `offset` prop to stand there at once.
|
|
70184
|
+
*
|
|
70185
|
+
* @param container - The scroll element.
|
|
70186
|
+
* @returns True when its `jump` prop is true.
|
|
70187
|
+
*/
|
|
70188
|
+
function jumpsOf(container) {
|
|
70189
|
+
return container.node.props.jump === true;
|
|
70190
|
+
}
|
|
70191
|
+
/**
|
|
69641
70192
|
* The `snap` prop of the scroll's last render.
|
|
69642
70193
|
*
|
|
69643
70194
|
* @param container - The scroll element.
|
|
@@ -70011,9 +70562,27 @@ function place$1(ctx, container, content, motion) {
|
|
|
70011
70562
|
ecs.add(content.entity, Transform(pose));
|
|
70012
70563
|
}
|
|
70013
70564
|
/**
|
|
70565
|
+
* Takes a new `offset` prop: with `jump` the scroll stands at it at once and stops, without it
|
|
70566
|
+
* glides there; either way it follows the prop from then on. A scroll the finger holds only
|
|
70567
|
+
* remembers it.
|
|
70568
|
+
*
|
|
70569
|
+
* @param motion - The motion of the scroll, its range already the one of this solve.
|
|
70570
|
+
* @param container - The scroll element.
|
|
70571
|
+
* @param asked - The new `offset` prop, from the start.
|
|
70572
|
+
*/
|
|
70573
|
+
function followOffset(motion, container, asked) {
|
|
70574
|
+
if (motion.mode === "held") return;
|
|
70575
|
+
if (jumpsOf(container)) {
|
|
70576
|
+
motion.offset = within(asked, motion.max);
|
|
70577
|
+
stop(motion);
|
|
70578
|
+
} else glideTo(motion, asked);
|
|
70579
|
+
motion.atProp = true;
|
|
70580
|
+
}
|
|
70581
|
+
/**
|
|
70014
70582
|
* Settles a placed scroll on what the solve and the render of this frame gave it: a new range at
|
|
70015
|
-
* once, then a glide to a new `offset` prop, which the scroll follows from then on.
|
|
70016
|
-
*
|
|
70583
|
+
* once, then a glide to a new `offset` prop, which the scroll follows from then on. With `jump` it
|
|
70584
|
+
* stands at the new prop at once instead, in the solve that gave the content its new rects, and a
|
|
70585
|
+
* glide the new range re-aimed stops. A scroll the finger holds only remembers the prop.
|
|
70017
70586
|
*
|
|
70018
70587
|
* @param ctx - Domain context of the ui plugin.
|
|
70019
70588
|
* @param state - The layout state, which keeps the patches.
|
|
@@ -70026,10 +70595,7 @@ function settle(ctx, state, container, content, motion) {
|
|
|
70026
70595
|
const asked = askedOffsetOf(container);
|
|
70027
70596
|
if (asked !== motion.seen) {
|
|
70028
70597
|
motion.seen = asked;
|
|
70029
|
-
|
|
70030
|
-
glideTo(motion, asked);
|
|
70031
|
-
motion.atProp = true;
|
|
70032
|
-
}
|
|
70598
|
+
followOffset(motion, container, asked);
|
|
70033
70599
|
}
|
|
70034
70600
|
show(ctx, state, container, content, motion);
|
|
70035
70601
|
}
|