@moku-labs/game 0.15.103 → 0.15.105
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-TSyhs2-E.d.mts → commands-DW0HRGor.d.mts} +5 -5
- package/dist/control.d.mts +4 -4
- package/dist/{define-DNF9A0ce.d.mts → define-DnQHkikh.d.mts} +2 -2
- package/dist/{headless-CEG1oR5D.d.mts → headless-DDAKncmX.d.mts} +1 -1
- package/dist/{index-DDZ9K9qO.d.mts → index-DuPTdMhJ.d.mts} +20 -9
- package/dist/index.d.mts +5 -5
- 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-CcHPrVBm.d.mts → runtime-RUEeOVCg.d.mts} +1 -1
- package/dist/{sources-BJyIJf_X.mjs → sources-JeKXYU_y.mjs} +1 -1
- package/dist/{src-DVJ0d04R.mjs → src-DnqlJ1XY.mjs} +1454 -601
- package/dist/testing.d.mts +4 -4
- package/dist/testing.mjs +1 -1
- package/dist/{types-C1B7-x7p.d.mts → types-BFWYGikY.d.mts} +191 -36
- package/dist/{types-CMag4vDu.d.mts → types-COMxJbej.d.mts} +4 -4
- package/dist/{types-C612npUH.d.mts → types-Ca0PmSri.d.mts} +2 -2
- package/dist/{types-BvgY7Ncf.d.mts → types-CpoZ-UDH.d.mts} +5 -3
- package/dist/{types-Ce5W0gZe.d.mts → types-KRAWEuUs.d.mts} +15 -2
- package/dist/{visual-DhqD6W3v.mjs → visual-fyUJwUJf.mjs} +163 -4
- package/dist/{visual-PsEr2KD-.d.mts → visual-pvIoUjpL.d.mts} +6 -6
- package/dist/visual.d.mts +1 -1
- package/dist/visual.mjs +1 -1
- package/llms.txt +1 -1
- package/package.json +2 -2
|
@@ -2,7 +2,7 @@ import { t as __exportAll } from "./rolldown-runtime-D7D4PA-g.mjs";
|
|
|
2
2
|
import { i as systemSource, r as MAX_TIMER_MS, t as memory } from "./memory-DeD9wis6.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
|
|
5
|
+
import { $ as Parent, A as Countdown, B as applyPose, C as uiFor, D as isTextFormat, E as formatBound, G as rootPointOf, H as localPoseOf, J as Display, K as rootPoseInto, N as boldLookOf, O as unitOf, P as builtInStyles, Q as OverlayLevel, R as readStyle, U as parentOf$1, V as isLeaving, W as poseUnder, X as NineSlice, Y as HudPart, Z as Overlay, _ as LocalWrite, a as fieldsLeftAlone, b as UI_OWNER, c as namesFormat, ct as Now, d as visualOf$1, dt as component, et as Shape, f as visualRectOf, g as Escapable, gt as tag, h as DebugTrigger, ht as systemsFor, i as drawnRect, it as componentsFor, j as Text, k as wholeValue, l as restValueOf, lt as Order, m as Covered, mt as system, n as CONTENT$1, nt as Transform, o as fitScaleOf, ot as Exiting, p as Box, pt as resource, q as rootPoseOf, r as bindOf, rt as arcDefaults, s as livePatch, st as Layer, tt as Sprite, u as samePose, ut as Tree, v as Scroll, x as UiCounters, y as ScrollState, z as textFor } from "./visual-fyUJwUJf.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";
|
|
@@ -17757,19 +17757,17 @@ function endLoan(inputs) {
|
|
|
17757
17757
|
inputs?.hold(void 0);
|
|
17758
17758
|
}
|
|
17759
17759
|
/**
|
|
17760
|
-
* The first enabled slot of a stack, when it reads
|
|
17760
|
+
* The inputs of the first enabled slot of a stack, when it reads any: the seam stage 2 keeps (OQ23-5). The seam itself,
|
|
17761
|
+
* no object around it: a shaded frame of a view whose filter reads inputs asks twice.
|
|
17761
17762
|
*
|
|
17762
17763
|
* @param slots - The record's slots.
|
|
17763
|
-
* @returns The
|
|
17764
|
+
* @returns The seam, or `undefined`.
|
|
17764
17765
|
*/
|
|
17765
17766
|
function firstInputs(slots) {
|
|
17766
17767
|
for (let index = 0; index < slots.length; index += 1) {
|
|
17767
17768
|
const slot = slots[index];
|
|
17768
17769
|
if (slot === void 0 || !slot.filter.enabled) continue;
|
|
17769
|
-
return slot.inputs
|
|
17770
|
-
slot,
|
|
17771
|
-
inputs: slot.inputs
|
|
17772
|
-
};
|
|
17770
|
+
return slot.inputs;
|
|
17773
17771
|
}
|
|
17774
17772
|
}
|
|
17775
17773
|
/**
|
|
@@ -17922,7 +17920,7 @@ function sizeTargets(kctx, pixi, record, scales, padding) {
|
|
|
17922
17920
|
* Stage 2, the pre-pass result of the first enabled filter with inputs (spec 24 B3.9): the keeper's stand-in is
|
|
17923
17921
|
* rendered over the picture, its apply draws the chain into engine targets; the version is read after the draw, a
|
|
17924
17922
|
* scale that changed inside it resizes the targets and draws once more; the filter then holds the results. An empty
|
|
17925
|
-
* chain holds nothing.
|
|
17923
|
+
* chain holds nothing. Whatever it draws, no stage 3 drew over it yet (`heldPlaced`).
|
|
17926
17924
|
*
|
|
17927
17925
|
* @param kctx - The kept context.
|
|
17928
17926
|
* @param pixi - The module that draws.
|
|
@@ -17936,6 +17934,7 @@ function sizeTargets(kctx, pixi, record, scales, padding) {
|
|
|
17936
17934
|
function renderStage2(kctx, pixi, matrices, record, context) {
|
|
17937
17935
|
const { inputs, resolution, padding } = context;
|
|
17938
17936
|
const scales = scalesOf(inputs);
|
|
17937
|
+
record.heldPlaced = false;
|
|
17939
17938
|
if (record.s2Of !== inputs) endLoan(record.s2Of);
|
|
17940
17939
|
record.s2Of = inputs;
|
|
17941
17940
|
if (scales === void 0) {
|
|
@@ -18000,7 +17999,8 @@ function readsPlace(record) {
|
|
|
18000
17999
|
/**
|
|
18001
18000
|
* Stage 3, the filter output: the stand-in, carrying the record's filters, is rendered at `M3 = translate(Ps, Ps)`
|
|
18002
18001
|
* into the output texture. A placed filter's origin gets the picture's canvas origin first, `O + Δ`; a local one
|
|
18003
|
-
* writes nothing.
|
|
18002
|
+
* writes nothing. A render over held results places them (`heldPlaced`): the filter's apply inside it wrote each
|
|
18003
|
+
* input's scale and clamp for them, which a mesh of the record reads as they stand. A render that failed placed nothing.
|
|
18004
18004
|
*
|
|
18005
18005
|
* @param kctx - The kept context.
|
|
18006
18006
|
* @param pixi - The module that draws.
|
|
@@ -18020,7 +18020,9 @@ function renderStage3(kctx, pixi, matrices, record, now) {
|
|
|
18020
18020
|
const Ps = key[KEY.Ps] ?? 0;
|
|
18021
18021
|
if (readsPlace(record)) setOrigins(record.slots, (key[KEY.X0] ?? 0) - Ps + now.tx - (key[KEY.tx] ?? 0), (key[KEY.Y0] ?? 0) - Ps + now.ty - (key[KEY.ty] ?? 0));
|
|
18022
18022
|
matrices.m3.set(1, 0, 0, 1, Ps, Ps);
|
|
18023
|
-
|
|
18023
|
+
const rendered = kctx.host.renderTo(standIn, output, matrices.m3, true);
|
|
18024
|
+
record.heldPlaced = rendered && record.s2Of !== void 0;
|
|
18025
|
+
if (!rendered) return false;
|
|
18024
18026
|
key[KEY.r] = now.r;
|
|
18025
18027
|
key[KEY.P] = now.P;
|
|
18026
18028
|
key[KEY.s3Tx] = now.tx;
|
|
@@ -18416,6 +18418,110 @@ function flushRanges(kctx) {
|
|
|
18416
18418
|
state.drawnPictures += range.sprite === void 0 ? 0 : 1;
|
|
18417
18419
|
}
|
|
18418
18420
|
}
|
|
18421
|
+
/**
|
|
18422
|
+
* One vector of the group, over an array the caller keeps.
|
|
18423
|
+
*
|
|
18424
|
+
* @param value - The array.
|
|
18425
|
+
* @returns The uniform.
|
|
18426
|
+
*/
|
|
18427
|
+
function vector(value) {
|
|
18428
|
+
return {
|
|
18429
|
+
value,
|
|
18430
|
+
type: "vec4<f32>"
|
|
18431
|
+
};
|
|
18432
|
+
}
|
|
18433
|
+
/**
|
|
18434
|
+
* The group of the numbers a filter pass hands a body, under the names Pixi's filter system fills, and the arrays it
|
|
18435
|
+
* reads, typed. Static: a group that is not is uploaded on every draw, and a shaded view changes these only when it
|
|
18436
|
+
* moves or its picture changes size.
|
|
18437
|
+
*
|
|
18438
|
+
* @param pixi - The module that draws.
|
|
18439
|
+
* @returns The group, zeros, and its vectors.
|
|
18440
|
+
*/
|
|
18441
|
+
function filterGlobals(pixi) {
|
|
18442
|
+
const vectors = {
|
|
18443
|
+
uInputSize: /* @__PURE__ */ new Float32Array(4),
|
|
18444
|
+
uInputPixel: /* @__PURE__ */ new Float32Array(4),
|
|
18445
|
+
uInputClamp: /* @__PURE__ */ new Float32Array(4),
|
|
18446
|
+
uOutputFrame: /* @__PURE__ */ new Float32Array(4),
|
|
18447
|
+
uGlobalFrame: /* @__PURE__ */ new Float32Array(4),
|
|
18448
|
+
uOutputTexture: /* @__PURE__ */ new Float32Array(4)
|
|
18449
|
+
};
|
|
18450
|
+
return {
|
|
18451
|
+
group: new pixi.UniformGroup({
|
|
18452
|
+
uInputSize: vector(vectors.uInputSize),
|
|
18453
|
+
uInputPixel: vector(vectors.uInputPixel),
|
|
18454
|
+
uInputClamp: vector(vectors.uInputClamp),
|
|
18455
|
+
uOutputFrame: vector(vectors.uOutputFrame),
|
|
18456
|
+
uGlobalFrame: vector(vectors.uGlobalFrame),
|
|
18457
|
+
uOutputTexture: vector(vectors.uOutputTexture)
|
|
18458
|
+
}, { isStatic: true }),
|
|
18459
|
+
vectors
|
|
18460
|
+
};
|
|
18461
|
+
}
|
|
18462
|
+
/**
|
|
18463
|
+
* The unit square of a quad program, its uvs over the whole texture: the mesh's scale gives it its size.
|
|
18464
|
+
*
|
|
18465
|
+
* @param pixi - The module that draws.
|
|
18466
|
+
* @returns A new geometry.
|
|
18467
|
+
*/
|
|
18468
|
+
function unitQuad(pixi) {
|
|
18469
|
+
return new pixi.MeshGeometry({
|
|
18470
|
+
positions: new Float32Array([
|
|
18471
|
+
0,
|
|
18472
|
+
0,
|
|
18473
|
+
1,
|
|
18474
|
+
0,
|
|
18475
|
+
1,
|
|
18476
|
+
1,
|
|
18477
|
+
0,
|
|
18478
|
+
1
|
|
18479
|
+
]),
|
|
18480
|
+
uvs: new Float32Array([
|
|
18481
|
+
0,
|
|
18482
|
+
0,
|
|
18483
|
+
1,
|
|
18484
|
+
0,
|
|
18485
|
+
1,
|
|
18486
|
+
1,
|
|
18487
|
+
0,
|
|
18488
|
+
1
|
|
18489
|
+
]),
|
|
18490
|
+
indices: new Uint32Array([
|
|
18491
|
+
0,
|
|
18492
|
+
1,
|
|
18493
|
+
2,
|
|
18494
|
+
0,
|
|
18495
|
+
2,
|
|
18496
|
+
3
|
|
18497
|
+
])
|
|
18498
|
+
});
|
|
18499
|
+
}
|
|
18500
|
+
/**
|
|
18501
|
+
* The shader of a quad over a texture. `fu` is left out for a filter that binds none: Pixi throws on an undefined
|
|
18502
|
+
* resource. Each input the quad names gets that texture too, its sampler that texture's style, until the kept cache
|
|
18503
|
+
* binds the held result there (`shade.ts`): Pixi builds a group only of what is bound, and a draw over a hole throws.
|
|
18504
|
+
*
|
|
18505
|
+
* @param pixi - The module that draws.
|
|
18506
|
+
* @param quad - The slot's quad.
|
|
18507
|
+
* @param gfu - The global filter uniforms.
|
|
18508
|
+
* @param source - The texture it reads.
|
|
18509
|
+
* @returns The shader.
|
|
18510
|
+
*/
|
|
18511
|
+
function quadShader(pixi, quad, gfu, source) {
|
|
18512
|
+
const { program, fu, inputNames = [] } = quad;
|
|
18513
|
+
const resources = {
|
|
18514
|
+
gfu,
|
|
18515
|
+
uTexture: source,
|
|
18516
|
+
uSampler: source.style
|
|
18517
|
+
};
|
|
18518
|
+
if (fu !== void 0) resources.fu = fu;
|
|
18519
|
+
for (const [index, name] of inputNames.entries()) resources[name] = index % 2 === 0 ? source : source.style;
|
|
18520
|
+
return new pixi.Shader({
|
|
18521
|
+
gpuProgram: program,
|
|
18522
|
+
resources
|
|
18523
|
+
});
|
|
18524
|
+
}
|
|
18419
18525
|
//#endregion
|
|
18420
18526
|
//#region src/plugins/renderer/kept/drawn-bounds.ts
|
|
18421
18527
|
/** Every flag of a node's display status: visible, renderable, not culled (Pixi's `localDisplayStatus`). */
|
|
@@ -18533,110 +18639,6 @@ function drawnBounds(pixi, top) {
|
|
|
18533
18639
|
addDrawn$1(pixi, top, into, 0, top);
|
|
18534
18640
|
return into;
|
|
18535
18641
|
}
|
|
18536
|
-
/**
|
|
18537
|
-
* One vector of the group, over an array the caller keeps.
|
|
18538
|
-
*
|
|
18539
|
-
* @param value - The array.
|
|
18540
|
-
* @returns The uniform.
|
|
18541
|
-
*/
|
|
18542
|
-
function vector(value) {
|
|
18543
|
-
return {
|
|
18544
|
-
value,
|
|
18545
|
-
type: "vec4<f32>"
|
|
18546
|
-
};
|
|
18547
|
-
}
|
|
18548
|
-
/**
|
|
18549
|
-
* The group of the numbers a filter pass hands a body, under the names Pixi's filter system fills, and the arrays it
|
|
18550
|
-
* reads, typed. Static: a group that is not is uploaded on every draw, and a shaded view changes these only when it
|
|
18551
|
-
* moves or its picture changes size.
|
|
18552
|
-
*
|
|
18553
|
-
* @param pixi - The module that draws.
|
|
18554
|
-
* @returns The group, zeros, and its vectors.
|
|
18555
|
-
*/
|
|
18556
|
-
function filterGlobals(pixi) {
|
|
18557
|
-
const vectors = {
|
|
18558
|
-
uInputSize: /* @__PURE__ */ new Float32Array(4),
|
|
18559
|
-
uInputPixel: /* @__PURE__ */ new Float32Array(4),
|
|
18560
|
-
uInputClamp: /* @__PURE__ */ new Float32Array(4),
|
|
18561
|
-
uOutputFrame: /* @__PURE__ */ new Float32Array(4),
|
|
18562
|
-
uGlobalFrame: /* @__PURE__ */ new Float32Array(4),
|
|
18563
|
-
uOutputTexture: /* @__PURE__ */ new Float32Array(4)
|
|
18564
|
-
};
|
|
18565
|
-
return {
|
|
18566
|
-
group: new pixi.UniformGroup({
|
|
18567
|
-
uInputSize: vector(vectors.uInputSize),
|
|
18568
|
-
uInputPixel: vector(vectors.uInputPixel),
|
|
18569
|
-
uInputClamp: vector(vectors.uInputClamp),
|
|
18570
|
-
uOutputFrame: vector(vectors.uOutputFrame),
|
|
18571
|
-
uGlobalFrame: vector(vectors.uGlobalFrame),
|
|
18572
|
-
uOutputTexture: vector(vectors.uOutputTexture)
|
|
18573
|
-
}, { isStatic: true }),
|
|
18574
|
-
vectors
|
|
18575
|
-
};
|
|
18576
|
-
}
|
|
18577
|
-
/**
|
|
18578
|
-
* The unit square of a quad program, its uvs over the whole texture: the mesh's scale gives it its size.
|
|
18579
|
-
*
|
|
18580
|
-
* @param pixi - The module that draws.
|
|
18581
|
-
* @returns A new geometry.
|
|
18582
|
-
*/
|
|
18583
|
-
function unitQuad(pixi) {
|
|
18584
|
-
return new pixi.MeshGeometry({
|
|
18585
|
-
positions: new Float32Array([
|
|
18586
|
-
0,
|
|
18587
|
-
0,
|
|
18588
|
-
1,
|
|
18589
|
-
0,
|
|
18590
|
-
1,
|
|
18591
|
-
1,
|
|
18592
|
-
0,
|
|
18593
|
-
1
|
|
18594
|
-
]),
|
|
18595
|
-
uvs: new Float32Array([
|
|
18596
|
-
0,
|
|
18597
|
-
0,
|
|
18598
|
-
1,
|
|
18599
|
-
0,
|
|
18600
|
-
1,
|
|
18601
|
-
1,
|
|
18602
|
-
0,
|
|
18603
|
-
1
|
|
18604
|
-
]),
|
|
18605
|
-
indices: new Uint32Array([
|
|
18606
|
-
0,
|
|
18607
|
-
1,
|
|
18608
|
-
2,
|
|
18609
|
-
0,
|
|
18610
|
-
2,
|
|
18611
|
-
3
|
|
18612
|
-
])
|
|
18613
|
-
});
|
|
18614
|
-
}
|
|
18615
|
-
/**
|
|
18616
|
-
* The shader of a quad over a texture. `fu` is left out for a filter that binds none: Pixi throws on an undefined
|
|
18617
|
-
* resource.
|
|
18618
|
-
*
|
|
18619
|
-
* @param pixi - The module that draws.
|
|
18620
|
-
* @param quad - The slot's quad.
|
|
18621
|
-
* @param gfu - The global filter uniforms.
|
|
18622
|
-
* @param source - The texture it reads.
|
|
18623
|
-
* @returns The shader.
|
|
18624
|
-
*/
|
|
18625
|
-
function quadShader(pixi, quad, gfu, source) {
|
|
18626
|
-
const { program, fu } = quad;
|
|
18627
|
-
const texture = {
|
|
18628
|
-
gfu,
|
|
18629
|
-
uTexture: source,
|
|
18630
|
-
uSampler: source.style
|
|
18631
|
-
};
|
|
18632
|
-
return new pixi.Shader({
|
|
18633
|
-
gpuProgram: program,
|
|
18634
|
-
resources: fu === void 0 ? texture : {
|
|
18635
|
-
...texture,
|
|
18636
|
-
fu
|
|
18637
|
-
}
|
|
18638
|
-
});
|
|
18639
|
-
}
|
|
18640
18642
|
//#endregion
|
|
18641
18643
|
//#region src/plugins/renderer/kept/shade.ts
|
|
18642
18644
|
/**
|
|
@@ -18646,7 +18648,8 @@ function quadShader(pixi, quad, gfu, source) {
|
|
|
18646
18648
|
* Ps)` with no filter, one pass only when the picture, the padding or the resolution changed; a new number is drawn by
|
|
18647
18649
|
* the mesh with no pass at all. The renderer holds no shader text: `effects` hands a built program over the slot. The
|
|
18648
18650
|
* policy of the mode, when it is entered and left, lives in `record.ts`; this file holds what is made, bound and freed.
|
|
18649
|
-
* The filter's uniform group is the instance's own, read by the mesh as it stands.
|
|
18651
|
+
* The filter's uniform group is the instance's own, read by the mesh as it stands. A filter that reads inputs binds the
|
|
18652
|
+
* record's held stage 2 results under the names its quad gives (F126 stage 4).
|
|
18650
18653
|
*/
|
|
18651
18654
|
/** The numbers `renderShade` wants in the group this frame, in the order of `writeGlobals`. One array: it allocates nothing. */
|
|
18652
18655
|
const WANTED = /* @__PURE__ */ new Float32Array(24);
|
|
@@ -18810,6 +18813,27 @@ function rebuildShader(pixi, shade, quad, source) {
|
|
|
18810
18813
|
old.destroy();
|
|
18811
18814
|
}
|
|
18812
18815
|
/**
|
|
18816
|
+
* Binds the record's held stage 2 results under the names of each input the quad gives, its texture then its sampler,
|
|
18817
|
+
* written only where they differ: a write Pixi takes as a change of the group, which it builds again. An input with no
|
|
18818
|
+
* result held binds the texture the shader reads (`shade.source`): the mesh never holds a released one, which is
|
|
18819
|
+
* destroyed. Indexed, allocates nothing.
|
|
18820
|
+
*
|
|
18821
|
+
* @param shade - The shade, its shader on the slot's quad and its source the output's.
|
|
18822
|
+
* @param record - The record.
|
|
18823
|
+
*/
|
|
18824
|
+
function bindHeld(shade, record) {
|
|
18825
|
+
const names = shade.quad.inputNames;
|
|
18826
|
+
if (names === void 0) return;
|
|
18827
|
+
const { resources } = shade.shader;
|
|
18828
|
+
for (let input = 0; 2 * input + 1 < names.length; input += 1) {
|
|
18829
|
+
const texture = names[2 * input];
|
|
18830
|
+
const sampler = names[2 * input + 1];
|
|
18831
|
+
const source = record.s2[input]?.source ?? shade.source;
|
|
18832
|
+
if (texture !== void 0 && resources[texture] !== source) resources[texture] = source;
|
|
18833
|
+
if (sampler !== void 0 && resources[sampler] !== source.style) resources[sampler] = source.style;
|
|
18834
|
+
}
|
|
18835
|
+
}
|
|
18836
|
+
/**
|
|
18813
18837
|
* Copies a vector of `WANTED` into the group where it differs. Both sides are 32-bit numbers: a double would differ from
|
|
18814
18838
|
* its stored value in every frame, and the group would be uploaded in every frame.
|
|
18815
18839
|
*
|
|
@@ -18908,10 +18932,10 @@ function copyPadded(kctx, pixi, matrices, record, output) {
|
|
|
18908
18932
|
}
|
|
18909
18933
|
/**
|
|
18910
18934
|
* The frame of a shaded record: stage 3 for the mesh. The output at its size, the shader on the slot's quad and on that
|
|
18911
|
-
* texture, the padded picture copied when `s1`, the padding or the resolution
|
|
18912
|
-
* uniforms, then `keptOrigin` at 0: in the mode the place is in `uOutputFrame.xy`,
|
|
18913
|
-
* the frame answer the same. The keys stage 3 writes. A new number needs none of
|
|
18914
|
-
* uniform group. Allocates nothing while the size stands.
|
|
18935
|
+
* texture, the held results of its inputs bound, the padded picture copied when `s1`, the padding or the resolution
|
|
18936
|
+
* changed (one pass, counted), the global uniforms, then `keptOrigin` at 0: in the mode the place is in `uOutputFrame.xy`,
|
|
18937
|
+
* so `canvasPixel` and a body that reads the frame answer the same. The keys stage 3 writes. A new number needs none of
|
|
18938
|
+
* it: the mesh reads the instance's own uniform group. Allocates nothing while the size stands.
|
|
18915
18939
|
*
|
|
18916
18940
|
* @param kctx - The kept context.
|
|
18917
18941
|
* @param pixi - The module that draws.
|
|
@@ -18938,6 +18962,7 @@ function renderShade(kctx, pixi, matrices, record, now) {
|
|
|
18938
18962
|
shade.source = source;
|
|
18939
18963
|
shade.copied = -1;
|
|
18940
18964
|
}
|
|
18965
|
+
bindHeld(shade, record);
|
|
18941
18966
|
const resized = source.pixelWidth !== shade.copiedWidth || source.pixelHeight !== shade.copiedHeight;
|
|
18942
18967
|
if ((shade.copied !== record.s1Version || resized) && !copyPadded(kctx, pixi, matrices, record, output)) return false;
|
|
18943
18968
|
writeGlobals(kctx, record, shade, source, now);
|
|
@@ -19327,10 +19352,10 @@ function drawsDirect(stack) {
|
|
|
19327
19352
|
}
|
|
19328
19353
|
/**
|
|
19329
19354
|
* Tells whether the record being stepped may draw through its filter's own body (F126 stage 2): on WebGPU, one enabled
|
|
19330
|
-
* filter with a quad,
|
|
19331
|
-
* not fit: stage 3 draws `F(A·x)` in stack order, the mesh would draw `A·F(x)`,
|
|
19332
|
-
* the picture would pop at every entry. A top that blends otherwise never gets
|
|
19333
|
-
* destroyed with a parent around it has nothing left to draw on. Allocates nothing.
|
|
19355
|
+
* filter with a quad, on `"inherit"`, at the canvas resolution, not drawn direct, and inputs its mesh may bind
|
|
19356
|
+
* (`inputsFit`). An `Alpha` beside it does not fit: stage 3 draws `F(A·x)` in stack order, the mesh would draw `A·F(x)`,
|
|
19357
|
+
* and for a body that is not alpha-linear the picture would pop at every entry. A top that blends otherwise never gets
|
|
19358
|
+
* here: `pictureWhy` refuses it. A mesh destroyed with a parent around it has nothing left to draw on. Allocates nothing.
|
|
19334
19359
|
*
|
|
19335
19360
|
* @param kctx - The kept context.
|
|
19336
19361
|
* @param record - The record.
|
|
@@ -19341,10 +19366,32 @@ function shadeFits(kctx, record, stack) {
|
|
|
19341
19366
|
if (kctx.host.kind() !== "webgpu" || stack.enabled !== 1) return false;
|
|
19342
19367
|
if (stack.rs !== NOW.r || drawsDirect(stack)) return false;
|
|
19343
19368
|
const slot = enabledSlot(record.slots);
|
|
19344
|
-
const
|
|
19345
|
-
|
|
19369
|
+
const quad = slot?.quad;
|
|
19370
|
+
if (slot === void 0 || quad === void 0) return false;
|
|
19371
|
+
const followsCanvas = slot.filter.resolution === "inherit";
|
|
19346
19372
|
const meshStands = !record.shaded || record.shade?.mesh.destroyed !== true;
|
|
19347
|
-
return
|
|
19373
|
+
return followsCanvas && meshStands && inputsFit(record, slot, quad);
|
|
19374
|
+
}
|
|
19375
|
+
/**
|
|
19376
|
+
* Tells whether the inputs of a record's one enabled filter let its mesh draw (F126 stage 4). A filter with none fits
|
|
19377
|
+
* while its quad names none: a game's own slot has no inputs, and names on its quad would bind results nobody drew. One
|
|
19378
|
+
* with inputs fits while its quad names two per input, the record holds a result of each, drawn by this seam over the
|
|
19379
|
+
* picture and the chain as they are (`chainOwed`, which refuses another seam too), and stage 3 drew over them last
|
|
19380
|
+
* (`heldPlaced`): the mesh reads the scale and clamp of each input as stage 3 left them. A body that reads the screen
|
|
19381
|
+
* does not fit with inputs: a change of its chain would leave the mesh for stage 3, which reads the picture's target.
|
|
19382
|
+
* Allocates nothing.
|
|
19383
|
+
*
|
|
19384
|
+
* @param record - The record.
|
|
19385
|
+
* @param slot - Its one enabled slot.
|
|
19386
|
+
* @param quad - The slot's quad.
|
|
19387
|
+
* @returns True when they fit.
|
|
19388
|
+
*/
|
|
19389
|
+
function inputsFit(record, slot, quad) {
|
|
19390
|
+
const { inputs } = slot;
|
|
19391
|
+
const names = quad.inputNames?.length ?? 0;
|
|
19392
|
+
if (inputs === void 0) return names === 0;
|
|
19393
|
+
if (record.category === "screen" || names !== 2 * inputs.count) return false;
|
|
19394
|
+
return record.s2.length === inputs.count && record.heldPlaced && !chainOwed(record, inputs);
|
|
19348
19395
|
}
|
|
19349
19396
|
/**
|
|
19350
19397
|
* Tells whether a take the budget refused still does not fit (P6.3); the pool's bytes are the take's to have (F119).
|
|
@@ -19642,6 +19689,7 @@ function createRecord$1(kctx, pixi, entity, view, slots, category) {
|
|
|
19642
19689
|
s2InputsVersion: 0,
|
|
19643
19690
|
s2PictureVersion: 0,
|
|
19644
19691
|
s2Of: void 0,
|
|
19692
|
+
heldPlaced: false,
|
|
19645
19693
|
dirtyS1: true,
|
|
19646
19694
|
dirtyS2: false,
|
|
19647
19695
|
dirtyS3: false,
|
|
@@ -19813,9 +19861,9 @@ function neededBytes(record, now, box) {
|
|
|
19813
19861
|
const { w1, h1, Ps } = box;
|
|
19814
19862
|
let bytes = textureBytes(w1, h1, now.rs);
|
|
19815
19863
|
if (!drawsDirect(now)) bytes += textureBytes(w1 + 2 * Ps, h1 + 2 * Ps, now.r);
|
|
19816
|
-
const
|
|
19817
|
-
if (
|
|
19818
|
-
const scale =
|
|
19864
|
+
const inputs = firstInputs(record.slots);
|
|
19865
|
+
if (inputs !== void 0) for (let index = 0; index < inputs.count; index += 1) {
|
|
19866
|
+
const scale = inputs.scaleOf(index) ?? 0;
|
|
19819
19867
|
bytes += textureBytes(w1 + 2 * now.P, h1 + 2 * now.P, now.rs * scale);
|
|
19820
19868
|
}
|
|
19821
19869
|
return bytes;
|
|
@@ -19996,7 +20044,9 @@ function isEmptyBounds(bounds) {
|
|
|
19996
20044
|
/**
|
|
19997
20045
|
* Renders the stages of a take whose keys are written: the subtree picture, the pre-pass results of the first filter
|
|
19998
20046
|
* with inputs, the filter output; the budget counts the textures after. A live view whose take failed draws live
|
|
19999
|
-
* again: its filters go back on its top.
|
|
20047
|
+
* again: its filters go back on its top. A record on its mesh whose filter reads inputs leaves it after stage 2 and
|
|
20048
|
+
* draws stage 3 over the new results: the mesh would read their scale and clamp before any stage 3 wrote them. The
|
|
20049
|
+
* next frame's refresh puts one that may draw no other way back on the mesh.
|
|
20000
20050
|
*
|
|
20001
20051
|
* @param kctx - The kept context.
|
|
20002
20052
|
* @param pixi - The module that draws.
|
|
@@ -20009,7 +20059,7 @@ function isEmptyBounds(bounds) {
|
|
|
20009
20059
|
function renderStages(kctx, pixi, matrices, record, view, now) {
|
|
20010
20060
|
const live = record.mode === "live";
|
|
20011
20061
|
if (live) handFilters(kctx, pixi, record, view);
|
|
20012
|
-
const
|
|
20062
|
+
const inputs = firstInputs(record.slots);
|
|
20013
20063
|
let ok = renderStage1(kctx, pixi, matrices, record);
|
|
20014
20064
|
if (drawsDirect(now)) {
|
|
20015
20065
|
goDirect(kctx, record);
|
|
@@ -20019,12 +20069,13 @@ function renderStages(kctx, pixi, matrices, record, view, now) {
|
|
|
20019
20069
|
}
|
|
20020
20070
|
record.direct = false;
|
|
20021
20071
|
meshForTake(kctx, pixi, record, ok);
|
|
20022
|
-
if (ok &&
|
|
20023
|
-
inputs
|
|
20072
|
+
if (ok && inputs !== void 0) renderStage2(kctx, pixi, matrices, record, {
|
|
20073
|
+
inputs,
|
|
20024
20074
|
resolution: now.r,
|
|
20025
20075
|
padding: now.P
|
|
20026
20076
|
});
|
|
20027
20077
|
else if (record.s2Of !== void 0) releaseInputs(kctx, record);
|
|
20078
|
+
if (record.shaded && !shadeFits(kctx, record, now)) leaveShade(record);
|
|
20028
20079
|
if (record.shaded) record.shadedAt = kctx.state.frame;
|
|
20029
20080
|
ok = ok && (record.shaded ? renderShade : renderStage3)(kctx, pixi, matrices, record, now);
|
|
20030
20081
|
account(kctx, record);
|
|
@@ -20087,7 +20138,8 @@ function goDirect(kctx, record) {
|
|
|
20087
20138
|
record.direct = true;
|
|
20088
20139
|
}
|
|
20089
20140
|
/**
|
|
20090
|
-
* Ends the loan of stage 2 when the first filter with inputs left the stack: the results are destroyed
|
|
20141
|
+
* Ends the loan of stage 2 when the first filter with inputs left the stack: the results are destroyed, and nothing is
|
|
20142
|
+
* placed any more.
|
|
20091
20143
|
*
|
|
20092
20144
|
* @param kctx - The kept context.
|
|
20093
20145
|
* @param record - The record.
|
|
@@ -20095,6 +20147,7 @@ function goDirect(kctx, record) {
|
|
|
20095
20147
|
function releaseInputs(kctx, record) {
|
|
20096
20148
|
endLoan(record.s2Of);
|
|
20097
20149
|
record.s2Of = void 0;
|
|
20150
|
+
record.heldPlaced = false;
|
|
20098
20151
|
for (const target of record.s2.splice(0)) dropTexture(kctx, target);
|
|
20099
20152
|
}
|
|
20100
20153
|
/**
|
|
@@ -20692,7 +20745,7 @@ function outputOwed(record, hold) {
|
|
|
20692
20745
|
* @returns The `OWED`.
|
|
20693
20746
|
*/
|
|
20694
20747
|
function stagesOwed(record, hold) {
|
|
20695
|
-
const inputs = firstInputs(record.slots)
|
|
20748
|
+
const inputs = firstInputs(record.slots);
|
|
20696
20749
|
if (inputs !== void 0 && chainOwed(record, inputs)) return OWED.chain;
|
|
20697
20750
|
return inputs === void 0 && record.s2Of !== void 0 || outputOwed(record, hold) ? OWED.output : OWED.none;
|
|
20698
20751
|
}
|
|
@@ -20718,7 +20771,9 @@ function refresh$1(kctx, pixi, matrices, record, view, hold) {
|
|
|
20718
20771
|
}
|
|
20719
20772
|
/**
|
|
20720
20773
|
* Redoes what a record that does not draw direct owes, on its mesh when it is shaded or goes on it now: a stack that
|
|
20721
|
-
* stopped fitting leaves and owes stage 3, one at rest may leave, and what is left is today's tail of stage 2 and 3.
|
|
20774
|
+
* stopped fitting leaves and owes stage 3, one at rest may leave, and what is left is today's tail of stage 2 and 3. A
|
|
20775
|
+
* shaded record whose filter's chain is owed no longer fits: it leaves and draws stages 2 and 3 on its sprite, and comes
|
|
20776
|
+
* back by the count of its outputs.
|
|
20722
20777
|
*
|
|
20723
20778
|
* @param kctx - The kept context.
|
|
20724
20779
|
* @param pixi - The module that draws.
|
|
@@ -20741,7 +20796,7 @@ function refreshOutput(kctx, pixi, matrices, record, view, hold) {
|
|
|
20741
20796
|
retakeOrGoLive(kctx, pixi, matrices, record, view, why);
|
|
20742
20797
|
return true;
|
|
20743
20798
|
}
|
|
20744
|
-
const inputs = firstInputs(record.slots)
|
|
20799
|
+
const inputs = firstInputs(record.slots);
|
|
20745
20800
|
if (inputs === void 0 && record.s2Of !== void 0) releaseInputs(kctx, record);
|
|
20746
20801
|
record.direct = false;
|
|
20747
20802
|
if (!unfit && enterShadeWhenDue(kctx, pixi, record, owed, fits)) {
|
|
@@ -45112,7 +45167,7 @@ function enteredCover(cover, enter) {
|
|
|
45112
45167
|
* lookOf({ texture: "ui.loader.ring", projection: "loading" }); // { projection: "loading" }
|
|
45113
45168
|
* ```
|
|
45114
45169
|
*/
|
|
45115
|
-
function lookOf(loader) {
|
|
45170
|
+
function lookOf$1(loader) {
|
|
45116
45171
|
if (loader.projection !== void 0) return { projection: loader.projection };
|
|
45117
45172
|
if (loader.texture !== void 0) return { texture: loader.texture };
|
|
45118
45173
|
return {};
|
|
@@ -45138,7 +45193,7 @@ function loaderOver(below, over) {
|
|
|
45138
45193
|
const named = over.texture !== void 0 || over.projection !== void 0;
|
|
45139
45194
|
const merged = {
|
|
45140
45195
|
afterMs: over.afterMs ?? base.afterMs,
|
|
45141
|
-
...lookOf(named ? over : base)
|
|
45196
|
+
...lookOf$1(named ? over : base)
|
|
45142
45197
|
};
|
|
45143
45198
|
const holdMs = over.holdMs ?? base.holdMs ?? 0;
|
|
45144
45199
|
if (holdMs > 0) merged.holdMs = holdMs;
|
|
@@ -48088,20 +48143,23 @@ function uniformStruct(uniforms, group = 1) {
|
|
|
48088
48143
|
return `struct FilterUniforms {\n${uniforms.map((uniform) => ` ${uniform.name}: ${uniform.type},\n`).join("")}};\n\n@group(${group}) @binding(0) var<uniform> fu: FilterUniforms;\n`;
|
|
48089
48144
|
}
|
|
48090
48145
|
/**
|
|
48091
|
-
* The engine's half of each input: the texture and the sampler in
|
|
48092
|
-
* reads the input at the body's uv, its scale and its clamp applied.
|
|
48146
|
+
* The engine's half of each input: the texture and the sampler in the group of `fu`, after it (input `k` at bindings
|
|
48147
|
+
* `1 + 2k` and `2 + 2k`), and the function that reads the input at the body's uv, its scale and its clamp applied.
|
|
48148
|
+
* Nothing without inputs.
|
|
48093
48149
|
*
|
|
48094
48150
|
* @param inputs - The inputs in declaration order.
|
|
48151
|
+
* @param group - The bind group of `fu` and the inputs: 1 in a filter's source, 3 in a quad program's.
|
|
48095
48152
|
* @returns The WGSL lines, or `""`.
|
|
48096
48153
|
* @example
|
|
48097
48154
|
* ```ts
|
|
48098
|
-
* const soft = { name: "soft", from: "input", texture: "
|
|
48155
|
+
* const soft = { name: "soft", from: "input", texture: "softTexture", sampler: "softSampler", sample: "sampleSoft", scale: { name: "softScale", type: "vec2<f32>", form: "vector", size: 2 }, clamp: { name: "softClamp", type: "vec4<f32>", form: "vector", size: 4 }, stages: [], chain: () => [] } as const;
|
|
48099
48156
|
*
|
|
48100
48157
|
* inputBindings([soft]).includes("fn sampleSoft(uv: vec2<f32>) -> vec4<f32>"); // true
|
|
48158
|
+
* inputBindings([soft], 3).startsWith("@group(3) @binding(1) var softTexture: texture_2d<f32>;"); // true
|
|
48101
48159
|
* ```
|
|
48102
48160
|
*/
|
|
48103
|
-
function inputBindings(inputs) {
|
|
48104
|
-
return inputs.map((input, index) => `@group(
|
|
48161
|
+
function inputBindings(inputs, group = 1) {
|
|
48162
|
+
return inputs.map((input, index) => `@group(${group}) @binding(${1 + 2 * index}) var ${input.texture}: texture_2d<f32>;\n@group(${group}) @binding(${2 + 2 * index}) var ${input.sampler}: sampler;\n\nfn ${input.sample}(uv: vec2<f32>) -> vec4<f32> {\n return textureSampleLevel(${input.texture}, ${input.sampler}, clamp(uv * gfu.uInputSize.xy * fu.${input.scale.name}, fu.${input.clamp.name}.xy, fu.${input.clamp.name}.zw), 0.0);\n}
|
|
48105
48163
|
|
|
48106
48164
|
`).join("");
|
|
48107
48165
|
}
|
|
@@ -48258,26 +48316,36 @@ function quadBody(wgsl) {
|
|
|
48258
48316
|
return found === 1 && !QUAD_REFUSED.test(wgsl.replaceAll(COMMENT$1, "")) ? rewritten : void 0;
|
|
48259
48317
|
}
|
|
48260
48318
|
/**
|
|
48261
|
-
* The quad program of a filter: the head of the mesh, the uniform struct at group 3 (the uniforms, then the
|
|
48262
|
-
* `keptOrigin` of a body that calls `canvasPixel`, as `assemble` lists
|
|
48263
|
-
* member for member: a shader that asks for more than the group holds
|
|
48264
|
-
* error, a blank view with nothing in the logs),
|
|
48319
|
+
* The quad program of a filter: the head of the mesh, the uniform struct at group 3 (the uniforms, then the scale and
|
|
48320
|
+
* the clamp of each input, then the engine's `keptOrigin` of a body that calls `canvasPixel`, as `assemble` lists
|
|
48321
|
+
* them, so the struct matches the instance's group member for member: a shader that asks for more than the group holds
|
|
48322
|
+
* fails only as an asynchronous GPU validation error, a blank view with nothing in the logs), each input's texture and
|
|
48323
|
+
* sampler at group 3 after `fu` with its `sample<Name>` helper (the renderer binds the held chain results there), the
|
|
48324
|
+
* `canvasPixel` helper, the body as `filterBody`, the entry point. Without inputs the text is the one of a filter that
|
|
48325
|
+
* reads none.
|
|
48265
48326
|
*
|
|
48266
48327
|
* @param uniforms - The uniforms in declaration order.
|
|
48267
48328
|
* @param body - The fragment body the game wrote.
|
|
48268
48329
|
* @param origin - The `keptOrigin` uniform, for a body that calls `canvasPixel`.
|
|
48330
|
+
* @param inputs - The inputs in declaration order, each starting from the view's own input; none by default.
|
|
48269
48331
|
* @returns The WGSL source of both stages, or `undefined` for a body the rewrite does not fit.
|
|
48270
48332
|
* @example
|
|
48271
48333
|
* ```ts
|
|
48272
48334
|
* assembleQuad([], "@fragment fn mainFragment(@location(0) uv: vec2<f32>) -> @location(0) vec4<f32> { return vec4<f32>(uv, 0.0, 1.0); }")?.includes("fn filterBody(uv: vec2<f32>) -> vec4<f32>"); // true
|
|
48273
48335
|
* assembleQuad([], "@fragment fn mainFragment(@builtin(position) at: vec4<f32>) -> @location(0) vec4<f32> { return at; }"); // undefined
|
|
48336
|
+
* assembleQuad(Bloom.filter.uniforms, BLOOM_WGSL, undefined, Bloom.filter.inputs)?.includes("@group(3) @binding(2) var brightSampler: sampler;"); // true
|
|
48274
48337
|
* ```
|
|
48275
48338
|
*/
|
|
48276
|
-
function assembleQuad(uniforms, body, origin) {
|
|
48339
|
+
function assembleQuad(uniforms, body, origin, inputs = []) {
|
|
48277
48340
|
const rewritten = quadBody(body);
|
|
48278
48341
|
if (rewritten === void 0) return void 0;
|
|
48279
|
-
const struct = uniformStruct(
|
|
48280
|
-
|
|
48342
|
+
const struct = uniformStruct([
|
|
48343
|
+
...uniforms,
|
|
48344
|
+
...inputs.flatMap((input) => [input.scale, input.clamp]),
|
|
48345
|
+
...origin === void 0 ? [] : [origin]
|
|
48346
|
+
], 3);
|
|
48347
|
+
const helper = origin === void 0 ? "" : CANVAS_PIXEL;
|
|
48348
|
+
return `${QUAD_HEADER}${struct}${inputBindings(inputs, 3)}${helper}${rewritten}${QUAD_TAIL}`;
|
|
48281
48349
|
}
|
|
48282
48350
|
//#endregion
|
|
48283
48351
|
//#region src/plugins/effects/filters/glsl.ts
|
|
@@ -48980,7 +49048,7 @@ function defineFilter(id, spec) {
|
|
|
48980
49048
|
id,
|
|
48981
49049
|
source: assemble(uniforms, inputs, spec.wgsl, origin, backdrop),
|
|
48982
49050
|
glsl: assembleGlsl(uniforms, inputs, spec.glsl, origin, backdrop),
|
|
48983
|
-
quadSource: inputs.
|
|
49051
|
+
quadSource: !backdrop && inputs.every((input) => input.from === "input") ? assembleQuad(uniforms, spec.wgsl, origin, inputs) : void 0,
|
|
48984
49052
|
uniforms,
|
|
48985
49053
|
passes,
|
|
48986
49054
|
padding,
|
|
@@ -50638,21 +50706,34 @@ function createStandIn(ectx, pixi, kind, value) {
|
|
|
50638
50706
|
*
|
|
50639
50707
|
* @param pixi - The module the renderer loaded.
|
|
50640
50708
|
* @param definition - A definition whose check answered ok.
|
|
50641
|
-
* @param program - The quad program of a kind that hands one over, drawn with the probe's own uniform group
|
|
50709
|
+
* @param program - The quad program of a kind that hands one over, drawn with the probe's own uniform group and the
|
|
50710
|
+
* names of its inputs.
|
|
50642
50711
|
* @returns The probe's filter, its quad and its teardown.
|
|
50643
50712
|
*/
|
|
50644
50713
|
function createWarmFilter(pixi, definition, program) {
|
|
50645
50714
|
const body = createOurs(pixi, definition, PROBE_VALUE);
|
|
50715
|
+
const quad = program === void 0 ? void 0 : {
|
|
50716
|
+
program,
|
|
50717
|
+
fu: body.group,
|
|
50718
|
+
inputNames: quadInputNames(definition)
|
|
50719
|
+
};
|
|
50646
50720
|
return {
|
|
50647
50721
|
filter: body.filter,
|
|
50648
|
-
quad
|
|
50649
|
-
program,
|
|
50650
|
-
fu: body.group
|
|
50651
|
-
},
|
|
50722
|
+
quad,
|
|
50652
50723
|
destroy: () => destroyBody(body)
|
|
50653
50724
|
};
|
|
50654
50725
|
}
|
|
50655
50726
|
/**
|
|
50727
|
+
* The resource names a quad binds the held result of each input under: its texture, then its sampler, in declaration
|
|
50728
|
+
* order. Made once with the quad object it goes on, never per frame.
|
|
50729
|
+
*
|
|
50730
|
+
* @param definition - The definition.
|
|
50731
|
+
* @returns The names; empty for a definition without inputs.
|
|
50732
|
+
*/
|
|
50733
|
+
function quadInputNames(definition) {
|
|
50734
|
+
return definition.inputs.flatMap((input) => [input.texture, input.sampler]);
|
|
50735
|
+
}
|
|
50736
|
+
/**
|
|
50656
50737
|
* Compares a vector uniform with a list of numbers element by element and writes the elements that
|
|
50657
50738
|
* differ: the indices `set(vector.slice(0, size))` would write, without the slice.
|
|
50658
50739
|
*
|
|
@@ -51848,7 +51929,7 @@ function quadProgramFor(ectx, pixi, instance) {
|
|
|
51848
51929
|
}
|
|
51849
51930
|
/**
|
|
51850
51931
|
* What an instance's slot carries for the quad, one object for the instance's life: the renderer builds its shader
|
|
51851
|
-
* again for another one.
|
|
51932
|
+
* again for another one. It names each input the mesh binds a held chain result under (none for a filter without).
|
|
51852
51933
|
*
|
|
51853
51934
|
* @param ectx - Domain context of the effects plugin.
|
|
51854
51935
|
* @param pixi - The module the renderer loaded.
|
|
@@ -51861,7 +51942,8 @@ function quadOf(ectx, pixi, instance) {
|
|
|
51861
51942
|
if (program === void 0) return void 0;
|
|
51862
51943
|
instance.quad ??= {
|
|
51863
51944
|
program,
|
|
51864
|
-
fu: instance.group
|
|
51945
|
+
fu: instance.group,
|
|
51946
|
+
inputNames: quadInputNames(instance.definition)
|
|
51865
51947
|
};
|
|
51866
51948
|
return instance.quad;
|
|
51867
51949
|
}
|
|
@@ -54439,9 +54521,54 @@ function isElementNode(value) {
|
|
|
54439
54521
|
return typeof value === "object" && value !== null && "type" in value && "props" in value && "children" in value;
|
|
54440
54522
|
}
|
|
54441
54523
|
/**
|
|
54524
|
+
* Escapes every `<` of a text parameter the way the tag pass of `text` reads a literal `<`, so a
|
|
54525
|
+
* player's name is never markup. A text without `<` comes back as the same string. It is the twin
|
|
54526
|
+
* of `escapeTags` in `text/tags.ts` (`i18n` sits below `text` and cannot import it): a change
|
|
54527
|
+
* edits both, and `tests/integration/escape-params.test.ts` holds them together.
|
|
54528
|
+
*
|
|
54529
|
+
* @param text - The parameter read as text.
|
|
54530
|
+
* @returns The text with every `<` written as `\<`.
|
|
54531
|
+
* @example
|
|
54532
|
+
* ```ts
|
|
54533
|
+
* escapeTags("<b>x"); // "\\<b>x"
|
|
54534
|
+
* ```
|
|
54535
|
+
*/
|
|
54536
|
+
function escapeTags$1(text) {
|
|
54537
|
+
return text.includes("<") ? text.replaceAll("<", String.raw`\<`) : text;
|
|
54538
|
+
}
|
|
54539
|
+
/**
|
|
54540
|
+
* Tells whether one item of a list parameter is a string with a `<` in it.
|
|
54541
|
+
*
|
|
54542
|
+
* @param item - The item.
|
|
54543
|
+
* @returns True when the item needs escaping.
|
|
54544
|
+
* @example
|
|
54545
|
+
* ```ts
|
|
54546
|
+
* hasTag("<b>Ann"); // true
|
|
54547
|
+
* ```
|
|
54548
|
+
*/
|
|
54549
|
+
function hasTag(item) {
|
|
54550
|
+
return typeof item === "string" && item.includes("<");
|
|
54551
|
+
}
|
|
54552
|
+
/**
|
|
54553
|
+
* Escapes every `<` of every string item of a list parameter, so a name in a list is never
|
|
54554
|
+
* markup either. A list with no `<` in any item comes back as the same array.
|
|
54555
|
+
*
|
|
54556
|
+
* @param items - The list parameter.
|
|
54557
|
+
* @returns The items, every `<` written as `\<`.
|
|
54558
|
+
* @example
|
|
54559
|
+
* ```ts
|
|
54560
|
+
* escapeItems(["<b>Ann", "Bob"]); // ["\\<b>Ann", "Bob"]
|
|
54561
|
+
* ```
|
|
54562
|
+
*/
|
|
54563
|
+
function escapeItems(items) {
|
|
54564
|
+
for (const item of items) if (hasTag(item)) return items.map((each) => escapeTags$1(each));
|
|
54565
|
+
return items;
|
|
54566
|
+
}
|
|
54567
|
+
/**
|
|
54442
54568
|
* One plain argument of a compiled message as a part: an element node keeps its place in the
|
|
54443
54569
|
* sentence, a list goes through `Intl.ListFormat` and a number through `Intl.NumberFormat` of the
|
|
54444
|
-
* kit's locale, anything else is read as text.
|
|
54570
|
+
* kit's locale, anything else is read as text. Every `<` of a text or of a list item is escaped
|
|
54571
|
+
* as `\<`, so the tag pass of `text` never reads a parameter as markup. A generated `strings.<locale>.ts` imports it as
|
|
54445
54572
|
* `argument` for a message with `{name}`.
|
|
54446
54573
|
*
|
|
54447
54574
|
* @param value - The parameter of the message.
|
|
@@ -54449,18 +54576,23 @@ function isElementNode(value) {
|
|
|
54449
54576
|
* @returns The part.
|
|
54450
54577
|
* @example
|
|
54451
54578
|
* ```ts
|
|
54452
|
-
* // A compiled module written by hand, the shape `moku-game keys` writes for "Host: {name}"
|
|
54579
|
+
* // A compiled module written by hand, the shape `moku-game keys` writes for "Host: {name}",
|
|
54580
|
+
* // registered as the strings of `en`; `coin` is an icon element a game builds.
|
|
54453
54581
|
* const lobby: I18n.CompiledMessages = {
|
|
54454
54582
|
* "lobby.host": (p, intl) => [{ kind: "text", text: "Host: " }, messageArgument(p.name, intl)]
|
|
54455
54583
|
* };
|
|
54584
|
+
* const coin: ElementNode = { type: "icon", props: { name: "hud.coin" }, children: [] };
|
|
54456
54585
|
* app.i18n.plain(tr("lobby.host", { name: ["Ann", "Bob", "Cy"] })); // "Host: Ann, Bob, and Cy"
|
|
54457
54586
|
* app.i18n.format(tr("lobby.host", { name: coin })); // [{ kind: "text", text: "Host: " }, { kind: "element", node: coin }]
|
|
54587
|
+
* app.i18n.format(tr("lobby.host", { name: "<b>x" })); // [{ kind: "text", text: "Host: \\<b>x" }]
|
|
54588
|
+
* app.i18n.plain(tr("lobby.host", { name: "<b>x" })); // "Host: <b>x"
|
|
54589
|
+
* app.i18n.format(tr("lobby.host", { name: ["<b>Ann", "Bob"] })); // [{ kind: "text", text: "Host: \\<b>Ann and Bob" }]
|
|
54458
54590
|
* ```
|
|
54459
54591
|
*/
|
|
54460
54592
|
function messageArgument(value, intl) {
|
|
54461
54593
|
if (Array.isArray(value)) return {
|
|
54462
54594
|
kind: "text",
|
|
54463
|
-
text: intl.list().format(value)
|
|
54595
|
+
text: intl.list().format(escapeItems(value))
|
|
54464
54596
|
};
|
|
54465
54597
|
if (typeof value === "number") return {
|
|
54466
54598
|
kind: "text",
|
|
@@ -54472,7 +54604,7 @@ function messageArgument(value, intl) {
|
|
|
54472
54604
|
};
|
|
54473
54605
|
return {
|
|
54474
54606
|
kind: "text",
|
|
54475
|
-
text: String(value)
|
|
54607
|
+
text: escapeTags$1(String(value))
|
|
54476
54608
|
};
|
|
54477
54609
|
}
|
|
54478
54610
|
/**
|
|
@@ -54791,6 +54923,20 @@ function formatIn(ctx, message, locale) {
|
|
|
54791
54923
|
return mergeParts(compiled(message.params ?? {}, kitOf(ctx.state, target)));
|
|
54792
54924
|
}
|
|
54793
54925
|
/**
|
|
54926
|
+
* Joins the text parts of a sentence, elements dropped, and reads every `\<` as the `<` it
|
|
54927
|
+
* escapes, so plain text shows a parameter as the player wrote it.
|
|
54928
|
+
*
|
|
54929
|
+
* @param parts - What `formatIn` answered.
|
|
54930
|
+
* @returns The sentence as text.
|
|
54931
|
+
* @example
|
|
54932
|
+
* ```ts
|
|
54933
|
+
* plainOf([{ kind: "text", text: "Host: \\<b>x" }]); // "Host: <b>x"
|
|
54934
|
+
* ```
|
|
54935
|
+
*/
|
|
54936
|
+
function plainOf$1(parts) {
|
|
54937
|
+
return parts.map((part) => part.kind === "text" ? part.text : "").join("").replaceAll(String.raw`\<`, "<");
|
|
54938
|
+
}
|
|
54939
|
+
/**
|
|
54794
54940
|
* Switches the current locale on the queue: load what is lazy (the modules of the held bundles
|
|
54795
54941
|
* included), set the locale, send the event.
|
|
54796
54942
|
*
|
|
@@ -54898,7 +55044,7 @@ function createI18nApi(ctx) {
|
|
|
54898
55044
|
locale: () => ctx.state.locale,
|
|
54899
55045
|
setLocale: (locale) => setLocale(ctx, locale),
|
|
54900
55046
|
format: (message, locale) => formatIn(ctx, message, locale),
|
|
54901
|
-
plain: (message) => formatIn(ctx, message)
|
|
55047
|
+
plain: (message) => plainOf$1(formatIn(ctx, message)),
|
|
54902
55048
|
has: (key) => resolve$1(ctx.state, key, ctx.state.locale, ctx.config.fallback) !== void 0,
|
|
54903
55049
|
isKey: (value) => isKnownKey(ctx.state, ctx.config.fallback, value),
|
|
54904
55050
|
duration: (ms, style = "short") => kitOf(ctx.state, ctx.state.locale).duration({
|
|
@@ -58282,11 +58428,443 @@ const platformPlugin = /*#__PURE__*/ createPlugin$1("platform", {
|
|
|
58282
58428
|
onStop: ({ state }) => stopPlatform(state)
|
|
58283
58429
|
});
|
|
58284
58430
|
//#endregion
|
|
58431
|
+
//#region src/plugins/text/lines.ts
|
|
58432
|
+
/** Line height of a style whose font is not loaded, as a share of the style size. */
|
|
58433
|
+
const FALLBACK_LINE = 1.2;
|
|
58434
|
+
/** Baseline of a font that names none, or of a style whose font is not loaded, as a share of the size. */
|
|
58435
|
+
const FALLBACK_BASE = .8;
|
|
58436
|
+
/**
|
|
58437
|
+
* The look one run measures and draws in, one of the objects already stored: the style its span
|
|
58438
|
+
* borrows (the paragraph's when it is in none, or in one of a key no style has), or the bold look
|
|
58439
|
+
* of that style for a `<b>` run when the style has `boldStyle`. Silent: the layout warns of an
|
|
58440
|
+
* unknown key once per string.
|
|
58441
|
+
*
|
|
58442
|
+
* @param paragraph - The style of the label.
|
|
58443
|
+
* @param run - The run.
|
|
58444
|
+
* @param styles - The style table, by name; left out, every span is the paragraph's.
|
|
58445
|
+
* @param looks - The bold looks, by the style they belong to.
|
|
58446
|
+
* @returns The look of the run.
|
|
58447
|
+
* @example
|
|
58448
|
+
* ```ts
|
|
58449
|
+
* const run: Run = { kind: "icon", key: "hud.coin", span: "price.22" };
|
|
58450
|
+
*
|
|
58451
|
+
* lookOf(bodyStyle, run, new Map([["price.22", priceStyle]]), new Map()); // priceStyle
|
|
58452
|
+
* ```
|
|
58453
|
+
*/
|
|
58454
|
+
function lookOf(paragraph, run, styles, looks) {
|
|
58455
|
+
const own = (run.span === void 0 ? void 0 : styles?.get(run.span)) ?? paragraph;
|
|
58456
|
+
if (run.kind === "icon" || !run.bold) return own;
|
|
58457
|
+
return looks?.get(own) ?? own;
|
|
58458
|
+
}
|
|
58459
|
+
/**
|
|
58460
|
+
* The look of a run under the style table and the bold looks a layout was handed.
|
|
58461
|
+
*
|
|
58462
|
+
* @param style - The style of the label.
|
|
58463
|
+
* @param run - The run.
|
|
58464
|
+
* @param options - What the layout was handed.
|
|
58465
|
+
* @returns The look of the run.
|
|
58466
|
+
*/
|
|
58467
|
+
function lookIn(style, run, options) {
|
|
58468
|
+
return lookOf(style, run, options.styles, options.looks);
|
|
58469
|
+
}
|
|
58470
|
+
/**
|
|
58471
|
+
* The font one run is drawn with: the bold or italic font when its look names it, else the
|
|
58472
|
+
* font of the look.
|
|
58473
|
+
*
|
|
58474
|
+
* @param style - The look of the run: the style of the label, or what `lookOf` answered.
|
|
58475
|
+
* @param run - The run to draw.
|
|
58476
|
+
* @returns The asset key of the font.
|
|
58477
|
+
* @example
|
|
58478
|
+
* ```ts
|
|
58479
|
+
* const run: TextRun = {
|
|
58480
|
+
* kind: "text", text: "a", bold: true, italic: false, color: undefined, span: undefined
|
|
58481
|
+
* };
|
|
58482
|
+
*
|
|
58483
|
+
* fontOfRun(bodyStyle, run); // "ui.font-body": the body style names no bold font, so the bold is synthetic
|
|
58484
|
+
* ```
|
|
58485
|
+
*/
|
|
58486
|
+
function fontOfRun(style, run) {
|
|
58487
|
+
if (run.bold && style.bold !== void 0) return style.bold;
|
|
58488
|
+
if (run.italic && style.italic !== void 0) return style.italic;
|
|
58489
|
+
return style.font;
|
|
58490
|
+
}
|
|
58491
|
+
/**
|
|
58492
|
+
* The font whose metrics a run stands in its line by. A run in a look of its own, a span's style or
|
|
58493
|
+
* a bold look of `boldStyle`, stands by the font its glyphs are drawn with (the bold or italic one
|
|
58494
|
+
* when the look names it). A run in the paragraph's look, a plain `<b>` or `<i>` included, stands
|
|
58495
|
+
* by the paragraph's own font, as every label did before runs had looks. An icon stands by the
|
|
58496
|
+
* font of its look.
|
|
58497
|
+
*
|
|
58498
|
+
* @param paragraph - The style of the label.
|
|
58499
|
+
* @param look - The look of the run, what `lookOf` answered.
|
|
58500
|
+
* @param run - The run.
|
|
58501
|
+
* @returns The asset key of the font.
|
|
58502
|
+
* @example
|
|
58503
|
+
* ```ts
|
|
58504
|
+
* const body = builtInStyles({ body: "ui.font-body", digits: "ui.font-digits" }).body;
|
|
58505
|
+
* const row = { ...body, bold: "ui.font-bold" };
|
|
58506
|
+
* const bold: Run = { kind: "text", text: "1", bold: true, italic: false, color: undefined, span: undefined };
|
|
58507
|
+
*
|
|
58508
|
+
* metricsFontOf(row, row, bold); // "ui.font-body": a plain <b> keeps the paragraph's line
|
|
58509
|
+
* metricsFontOf(row, { ...row, size: 16 }, bold); // "ui.font-bold": a look of its own stands by its font
|
|
58510
|
+
* ```
|
|
58511
|
+
*/
|
|
58512
|
+
function metricsFontOf(paragraph, look, run) {
|
|
58513
|
+
return run.kind === "icon" || look === paragraph ? look.font : fontOfRun(look, run);
|
|
58514
|
+
}
|
|
58515
|
+
/**
|
|
58516
|
+
* The height of one line of a style: `lineHeight × size` when the style names its line, else the
|
|
58517
|
+
* line of the font at the style size, its own font unless another is named.
|
|
58518
|
+
*
|
|
58519
|
+
* @param style - The style of the label, or the look of a run.
|
|
58520
|
+
* @param tables - The advance tables that are loaded.
|
|
58521
|
+
* @param font - The font whose line it is: what `metricsFontOf` answers for a run.
|
|
58522
|
+
* @returns The line height in reference pixels.
|
|
58523
|
+
* @example
|
|
58524
|
+
* ```ts
|
|
58525
|
+
* lineHeightOf(bodyStyle, new Map()); // 38.4: 1.2 em of a 32 px style with no font loaded
|
|
58526
|
+
* ```
|
|
58527
|
+
*/
|
|
58528
|
+
function lineHeightOf(style, tables, font = style.font) {
|
|
58529
|
+
return style.lineHeight === void 0 ? fontLineOf(style, tables, font) : style.lineHeight * style.size;
|
|
58530
|
+
}
|
|
58531
|
+
/**
|
|
58532
|
+
* The height of one line of a font at the style size, whatever line the style names: what the
|
|
58533
|
+
* glyphs are drawn into, so the gap to `lineHeightOf` is the leading.
|
|
58534
|
+
*
|
|
58535
|
+
* @param style - The style of the label, or the look of a run.
|
|
58536
|
+
* @param tables - The advance tables that are loaded.
|
|
58537
|
+
* @param font - The font whose line it is; the style's own when left out.
|
|
58538
|
+
* @returns The font's line height in reference pixels.
|
|
58539
|
+
* @example
|
|
58540
|
+
* ```ts
|
|
58541
|
+
* fontLineOf({ ...bodyStyle, lineHeight: 1.5 }, new Map()); // 38.4: the font's 1.2 em, not 48
|
|
58542
|
+
* ```
|
|
58543
|
+
*/
|
|
58544
|
+
function fontLineOf(style, tables, font = style.font) {
|
|
58545
|
+
const table = tables.get(font);
|
|
58546
|
+
return table === void 0 ? FALLBACK_LINE * style.size : table.lineHeight * (style.size / table.size);
|
|
58547
|
+
}
|
|
58548
|
+
/**
|
|
58549
|
+
* How far the baseline sits below the top of a font's line: the `base` of the font at the style
|
|
58550
|
+
* size, or 0.8 em while the font is not loaded.
|
|
58551
|
+
*
|
|
58552
|
+
* @param style - The look of a run.
|
|
58553
|
+
* @param tables - The advance tables that are loaded.
|
|
58554
|
+
* @param font - The font the run is drawn with; the style's own when left out.
|
|
58555
|
+
* @returns The ascent in reference pixels.
|
|
58556
|
+
* @example
|
|
58557
|
+
* ```ts
|
|
58558
|
+
* ascentOf(bodyStyle, new Map()); // 25.6: 0.8 em of a 32 px style with no font loaded
|
|
58559
|
+
* ```
|
|
58560
|
+
*/
|
|
58561
|
+
function ascentOf(style, tables, font = style.font) {
|
|
58562
|
+
const table = tables.get(font);
|
|
58563
|
+
return table === void 0 ? FALLBACK_BASE * style.size : table.base * (style.size / table.size);
|
|
58564
|
+
}
|
|
58565
|
+
/**
|
|
58566
|
+
* Half the leading of a style: how far below the top of its line its font's line starts, as CSS
|
|
58567
|
+
* centres the glyphs in a line taller or shorter than the font's.
|
|
58568
|
+
*
|
|
58569
|
+
* @param style - The look of a run.
|
|
58570
|
+
* @param tables - The advance tables that are loaded.
|
|
58571
|
+
* @param font - The font the run is drawn with; the style's own when left out.
|
|
58572
|
+
* @returns The half-leading in reference pixels; below 0 in a line shorter than the font's.
|
|
58573
|
+
* @example
|
|
58574
|
+
* ```ts
|
|
58575
|
+
* leadingOf({ ...bodyStyle, lineHeight: 2 }, new Map()); // 12.8: (64 - 38.4) / 2
|
|
58576
|
+
* ```
|
|
58577
|
+
*/
|
|
58578
|
+
function leadingOf(style, tables, font = style.font) {
|
|
58579
|
+
return (lineHeightOf(style, tables, font) - fontLineOf(style, tables, font)) / 2;
|
|
58580
|
+
}
|
|
58581
|
+
/**
|
|
58582
|
+
* Writes the line box of every line, as CSS builds it: each run stands in the line of its look,
|
|
58583
|
+
* the line of its metrics font (`metricsFontOf`) centred in it, and its baseline that font's
|
|
58584
|
+
* `ascent` below that line's top. Every line holds a strut too, an empty piece of the paragraph's
|
|
58585
|
+
* look, so a line is never shorter than the paragraph's line and its baseline never higher. The
|
|
58586
|
+
* baseline of the line is the lowest of them, and the line reaches as far below it as the deepest.
|
|
58587
|
+
* A line no run reaches past the strut, a line of the paragraph's look and an empty one included,
|
|
58588
|
+
* is exactly the paragraph's line, to the last bit.
|
|
58589
|
+
*
|
|
58590
|
+
* @param lines - The lines of the block.
|
|
58591
|
+
* @param style - The style of the label.
|
|
58592
|
+
* @param tables - The advance tables that are loaded.
|
|
58593
|
+
* @param options - The styles and bold looks a run may take.
|
|
58594
|
+
*/
|
|
58595
|
+
function boxLines(lines, style, tables, options) {
|
|
58596
|
+
const strutRaise = leadingOf(style, tables) + ascentOf(style, tables);
|
|
58597
|
+
const strutBox = lineHeightOf(style, tables);
|
|
58598
|
+
const strutBelow = strutBox - strutRaise;
|
|
58599
|
+
for (const line of lines) {
|
|
58600
|
+
let above = strutRaise;
|
|
58601
|
+
let below = strutBelow;
|
|
58602
|
+
for (const run of line.runs) {
|
|
58603
|
+
const look = lookIn(style, run, options);
|
|
58604
|
+
const font = metricsFontOf(style, look, run);
|
|
58605
|
+
const raise = leadingOf(look, tables, font) + ascentOf(look, tables, font);
|
|
58606
|
+
above = Math.max(above, raise);
|
|
58607
|
+
below = Math.max(below, lineHeightOf(look, tables, font) - raise);
|
|
58608
|
+
}
|
|
58609
|
+
const strutOnly = above === strutRaise && below === strutBelow;
|
|
58610
|
+
line.baseline = strutOnly ? strutRaise : above;
|
|
58611
|
+
line.height = strutOnly ? strutBox : above + below;
|
|
58612
|
+
}
|
|
58613
|
+
}
|
|
58614
|
+
/**
|
|
58615
|
+
* The height of a block: the sum of its lines, or the count times the line when every line is
|
|
58616
|
+
* as high, which is to the last bit what a block of one look measured before lines had boxes.
|
|
58617
|
+
*
|
|
58618
|
+
* @param lines - The lines, their boxes written.
|
|
58619
|
+
* @returns The height in reference pixels.
|
|
58620
|
+
* @example
|
|
58621
|
+
* ```ts
|
|
58622
|
+
* blockHeight([{ runs: [], width: 0, height: 40, baseline: 32 }]); // 40
|
|
58623
|
+
* ```
|
|
58624
|
+
*/
|
|
58625
|
+
function blockHeight(lines) {
|
|
58626
|
+
const first = lines[0]?.height ?? 0;
|
|
58627
|
+
let sum = 0;
|
|
58628
|
+
let even = true;
|
|
58629
|
+
for (const line of lines) {
|
|
58630
|
+
sum += line.height;
|
|
58631
|
+
even &&= line.height === first;
|
|
58632
|
+
}
|
|
58633
|
+
return even ? lines.length * first : sum;
|
|
58634
|
+
}
|
|
58635
|
+
//#endregion
|
|
58636
|
+
//#region src/plugins/text/tags.ts
|
|
58637
|
+
/** Matches an opening colour tag. Six hex digits: `#rgb` is not accepted. */
|
|
58638
|
+
const COLOR_TAG = /^color=#([\da-f]{6})$/i;
|
|
58639
|
+
/** Matches an inline icon tag, which has no closing tag. */
|
|
58640
|
+
const ICON_TAG = /^icon=(\S+)$/;
|
|
58641
|
+
/** Matches an opening span tag. The key is unquoted: `style="x"` is not this grammar. */
|
|
58642
|
+
const SPAN_TAG = /^span style=([^\s"']+)$/;
|
|
58643
|
+
/**
|
|
58644
|
+
* Reads an opening tag.
|
|
58645
|
+
*
|
|
58646
|
+
* @param body - What stood between the angle brackets.
|
|
58647
|
+
* @returns The tag, or `undefined` when it is not one this grammar knows.
|
|
58648
|
+
* @example
|
|
58649
|
+
* ```ts
|
|
58650
|
+
* openTag("color=#ff0000"); // { name: "color", color: 16711680, span: undefined }
|
|
58651
|
+
* ```
|
|
58652
|
+
*/
|
|
58653
|
+
function openTag(body) {
|
|
58654
|
+
if (body === "b" || body === "i") return {
|
|
58655
|
+
name: body,
|
|
58656
|
+
color: void 0,
|
|
58657
|
+
span: void 0
|
|
58658
|
+
};
|
|
58659
|
+
const span = SPAN_TAG.exec(body);
|
|
58660
|
+
if (span !== null) return {
|
|
58661
|
+
name: "span",
|
|
58662
|
+
color: void 0,
|
|
58663
|
+
span: span[1]
|
|
58664
|
+
};
|
|
58665
|
+
const colour = COLOR_TAG.exec(body);
|
|
58666
|
+
if (colour === null) return void 0;
|
|
58667
|
+
return {
|
|
58668
|
+
name: "color",
|
|
58669
|
+
color: Number.parseInt(colour[1] ?? "0", 16),
|
|
58670
|
+
span: void 0
|
|
58671
|
+
};
|
|
58672
|
+
}
|
|
58673
|
+
/**
|
|
58674
|
+
* The key of the innermost open span: a nested span wins over the one around it.
|
|
58675
|
+
*
|
|
58676
|
+
* @param stack - The tags that are open.
|
|
58677
|
+
* @returns The style key, or `undefined` outside a span.
|
|
58678
|
+
* @example
|
|
58679
|
+
* ```ts
|
|
58680
|
+
* spanOf([{ name: "span", color: undefined, span: "price.22" }]); // "price.22"
|
|
58681
|
+
* ```
|
|
58682
|
+
*/
|
|
58683
|
+
function spanOf(stack) {
|
|
58684
|
+
let span;
|
|
58685
|
+
for (const open of stack) if (open.name === "span") span = open.span;
|
|
58686
|
+
return span;
|
|
58687
|
+
}
|
|
58688
|
+
/**
|
|
58689
|
+
* Tells whether two glyph runs are drawn in the same look: the same bold, italic, colour and span.
|
|
58690
|
+
* Only then may their text be one run: the parse, the layout and the draw all ask this.
|
|
58691
|
+
*
|
|
58692
|
+
* @param first - One glyph run.
|
|
58693
|
+
* @param second - The other.
|
|
58694
|
+
* @returns True when nothing but the text tells them apart.
|
|
58695
|
+
*/
|
|
58696
|
+
function sameLook(first, second) {
|
|
58697
|
+
return first.bold === second.bold && first.italic === second.italic && first.color === second.color && first.span === second.span;
|
|
58698
|
+
}
|
|
58699
|
+
/**
|
|
58700
|
+
* Appends text to the runs, merging it into the last one when it is in the same look.
|
|
58701
|
+
*
|
|
58702
|
+
* @param runs - The runs built so far.
|
|
58703
|
+
* @param text - The characters to append.
|
|
58704
|
+
* @param stack - The tags that are open around them.
|
|
58705
|
+
*/
|
|
58706
|
+
function pushText(runs, text, stack) {
|
|
58707
|
+
let color;
|
|
58708
|
+
for (const open of stack) if (open.name === "color") color = open.color;
|
|
58709
|
+
const piece = {
|
|
58710
|
+
kind: "text",
|
|
58711
|
+
text,
|
|
58712
|
+
bold: stack.some((open) => open.name === "b"),
|
|
58713
|
+
italic: stack.some((open) => open.name === "i"),
|
|
58714
|
+
color,
|
|
58715
|
+
span: spanOf(stack)
|
|
58716
|
+
};
|
|
58717
|
+
const last = runs.at(-1);
|
|
58718
|
+
if (last?.kind === "text" && sameLook(last, piece)) {
|
|
58719
|
+
last.text += text;
|
|
58720
|
+
return;
|
|
58721
|
+
}
|
|
58722
|
+
runs.push(piece);
|
|
58723
|
+
}
|
|
58724
|
+
/**
|
|
58725
|
+
* Reports one source string once, whatever is wrong with it.
|
|
58726
|
+
*
|
|
58727
|
+
* @param state - The parse in progress.
|
|
58728
|
+
* @param message - The log event.
|
|
58729
|
+
* @param tag - The tag that was wrong.
|
|
58730
|
+
*/
|
|
58731
|
+
function complain(state, message, tag) {
|
|
58732
|
+
if (state.warned) return;
|
|
58733
|
+
state.warned = true;
|
|
58734
|
+
state.warn(`tag:${state.source}`, message, {
|
|
58735
|
+
tag,
|
|
58736
|
+
text: state.source
|
|
58737
|
+
});
|
|
58738
|
+
}
|
|
58739
|
+
/**
|
|
58740
|
+
* Writes what was read so far into a run.
|
|
58741
|
+
*
|
|
58742
|
+
* @param state - The parse in progress.
|
|
58743
|
+
*/
|
|
58744
|
+
function flush(state) {
|
|
58745
|
+
if (state.buffer.length === 0) return;
|
|
58746
|
+
pushText(state.runs, state.buffer, state.stack);
|
|
58747
|
+
state.buffer = "";
|
|
58748
|
+
}
|
|
58749
|
+
/**
|
|
58750
|
+
* Applies one tag: an icon run, an opening tag, a matching close, or, when it is none of those,
|
|
58751
|
+
* literal text and one warning.
|
|
58752
|
+
*
|
|
58753
|
+
* @param state - The parse in progress.
|
|
58754
|
+
* @param body - What stood between the angle brackets.
|
|
58755
|
+
*/
|
|
58756
|
+
function applyTag(state, body) {
|
|
58757
|
+
const icon = ICON_TAG.exec(body);
|
|
58758
|
+
if (icon !== null) {
|
|
58759
|
+
flush(state);
|
|
58760
|
+
state.runs.push({
|
|
58761
|
+
kind: "icon",
|
|
58762
|
+
key: icon[1] ?? "",
|
|
58763
|
+
span: spanOf(state.stack)
|
|
58764
|
+
});
|
|
58765
|
+
return;
|
|
58766
|
+
}
|
|
58767
|
+
const open = openTag(body);
|
|
58768
|
+
if (open !== void 0) {
|
|
58769
|
+
flush(state);
|
|
58770
|
+
state.stack.push(open);
|
|
58771
|
+
return;
|
|
58772
|
+
}
|
|
58773
|
+
const closes = body.startsWith("/");
|
|
58774
|
+
const at = closes ? state.stack.map((entry) => entry.name).lastIndexOf(body.slice(1)) : -1;
|
|
58775
|
+
if (at !== -1) {
|
|
58776
|
+
flush(state);
|
|
58777
|
+
state.stack.splice(at, 1);
|
|
58778
|
+
return;
|
|
58779
|
+
}
|
|
58780
|
+
complain(state, closes ? "text: stray closing tag" : "text: unknown tag", body);
|
|
58781
|
+
state.buffer += `<${body}>`;
|
|
58782
|
+
}
|
|
58783
|
+
/**
|
|
58784
|
+
* Tells whether the character at an index starts the escape `\<`, a literal `<`.
|
|
58785
|
+
*
|
|
58786
|
+
* @param source - The resolved string.
|
|
58787
|
+
* @param index - Where the parse stands.
|
|
58788
|
+
* @returns True for a backslash right before a `<`.
|
|
58789
|
+
* @example
|
|
58790
|
+
* ```ts
|
|
58791
|
+
* isEscape(String.raw`a\<b`, 1); // true
|
|
58792
|
+
* ```
|
|
58793
|
+
*/
|
|
58794
|
+
function isEscape(source, index) {
|
|
58795
|
+
return source[index] === "\\" && source[index + 1] === "<";
|
|
58796
|
+
}
|
|
58797
|
+
/**
|
|
58798
|
+
* Writes a plain string so the grammar reads it as exactly these characters: every `<` becomes
|
|
58799
|
+
* the escape `\<`. A string without `<` comes back as it is. A typed field value goes through it.
|
|
58800
|
+
*
|
|
58801
|
+
* @param text - The plain string.
|
|
58802
|
+
* @returns The string `parseTags` reads as one run of the same characters.
|
|
58803
|
+
* @example
|
|
58804
|
+
* ```ts
|
|
58805
|
+
* escapeTags("<b>x"); // "\\<b>x"
|
|
58806
|
+
* ```
|
|
58807
|
+
*/
|
|
58808
|
+
function escapeTags(text) {
|
|
58809
|
+
return text.includes("<") ? text.replaceAll("<", String.raw`\<`) : text;
|
|
58810
|
+
}
|
|
58811
|
+
/**
|
|
58812
|
+
* Turns a resolved string into runs of glyphs and inline icons. Everything the grammar does not
|
|
58813
|
+
* know stays visible: the tag is kept as literal text and the source is reported once. A run in a
|
|
58814
|
+
* `<span style=KEY>` carries `KEY`; whether a style has that key is the layout's question.
|
|
58815
|
+
*
|
|
58816
|
+
* @param source - The resolved string, as it was written or formatted.
|
|
58817
|
+
* @param warn - Called at most once per source, with the key `tag:<source>`.
|
|
58818
|
+
* @returns The runs, in reading order, with equal neighbours merged.
|
|
58819
|
+
* @example
|
|
58820
|
+
* ```ts
|
|
58821
|
+
* parseTags("<b>a</b><span style=price.22>b</span>", () => undefined);
|
|
58822
|
+
* // [{ kind: "text", text: "a", bold: true, italic: false, color: undefined, span: undefined },
|
|
58823
|
+
* // { kind: "text", text: "b", bold: false, italic: false, color: undefined, span: "price.22" }]
|
|
58824
|
+
* ```
|
|
58825
|
+
*/
|
|
58826
|
+
function parseTags(source, warn) {
|
|
58827
|
+
const state = {
|
|
58828
|
+
source,
|
|
58829
|
+
runs: [],
|
|
58830
|
+
stack: [],
|
|
58831
|
+
buffer: "",
|
|
58832
|
+
warned: false,
|
|
58833
|
+
warn
|
|
58834
|
+
};
|
|
58835
|
+
let index = 0;
|
|
58836
|
+
while (index < source.length) {
|
|
58837
|
+
if (isEscape(source, index)) {
|
|
58838
|
+
state.buffer += "<";
|
|
58839
|
+
index += 2;
|
|
58840
|
+
continue;
|
|
58841
|
+
}
|
|
58842
|
+
const char = source[index] ?? "";
|
|
58843
|
+
const close = char === "<" ? source.indexOf(">", index + 1) : -1;
|
|
58844
|
+
if (close === -1) {
|
|
58845
|
+
state.buffer += char;
|
|
58846
|
+
index += 1;
|
|
58847
|
+
continue;
|
|
58848
|
+
}
|
|
58849
|
+
applyTag(state, source.slice(index + 1, close));
|
|
58850
|
+
index = close + 1;
|
|
58851
|
+
}
|
|
58852
|
+
flush(state);
|
|
58853
|
+
if (state.stack.length > 0) complain(state, "text: unclosed tag", state.stack[0]?.name ?? "");
|
|
58854
|
+
return state.runs;
|
|
58855
|
+
}
|
|
58856
|
+
//#endregion
|
|
58285
58857
|
//#region src/plugins/text/measure.ts
|
|
58858
|
+
/**
|
|
58859
|
+
* @file text plugin — the measurement. A `.fnt` becomes an advance table, runs become lines, and
|
|
58860
|
+
* a block becomes a size in reference pixels. Pure and canvas-free: the same numbers on a screen
|
|
58861
|
+
* and in plain Bun, which is what keeps `ui.layout` honest. A character the font has no glyph for
|
|
58862
|
+
* measures 0 wide, because Pixi draws nothing for it. Every run measures in its look: the
|
|
58863
|
+
* paragraph's style, the style its `<span>` borrows, or the bold look of either; and every line is
|
|
58864
|
+
* a CSS line box, as high as its looks need, all of them on one baseline.
|
|
58865
|
+
*/
|
|
58286
58866
|
/** Advance of a glyph no table knows, as a share of the style size. */
|
|
58287
58867
|
const FALLBACK_ADVANCE = .6;
|
|
58288
|
-
/** Line height of a style whose font is not loaded, as a share of the style size. */
|
|
58289
|
-
const FALLBACK_LINE = 1.2;
|
|
58290
58868
|
/**
|
|
58291
58869
|
* How much wider than its box a line of a `"box"` style may be. `ui` lays a text out in whole units
|
|
58292
58870
|
* and rounds its measure with this tolerance, so a line that adds up to a hair over a whole unit
|
|
@@ -58377,14 +58955,30 @@ function readJson(fnt) {
|
|
|
58377
58955
|
if (!isRecord$1(data) || !isRecord$1(data.info) || !Array.isArray(data.chars)) return void 0;
|
|
58378
58956
|
const size = Math.abs(numberOf(data.info.size) ?? 0);
|
|
58379
58957
|
if (size <= 0) return void 0;
|
|
58380
|
-
const common = isRecord$1(data.common) ?
|
|
58958
|
+
const common = isRecord$1(data.common) ? data.common : {};
|
|
58959
|
+
const lineHeight = numberOf(common.lineHeight) ?? 0;
|
|
58381
58960
|
return {
|
|
58382
58961
|
size,
|
|
58383
|
-
lineHeight:
|
|
58962
|
+
lineHeight: lineHeight > 0 ? lineHeight : size,
|
|
58963
|
+
base: baseOf(numberOf(common.base), size),
|
|
58384
58964
|
advances: readChars(data.chars)
|
|
58385
58965
|
};
|
|
58386
58966
|
}
|
|
58387
58967
|
/**
|
|
58968
|
+
* The baseline a file names, or 0.8 of its size when it names none above 0.
|
|
58969
|
+
*
|
|
58970
|
+
* @param base - The `base` of the file's `common` block, as it was read.
|
|
58971
|
+
* @param size - The export size of the font.
|
|
58972
|
+
* @returns How far the baseline sits below the top of a line, at the export size.
|
|
58973
|
+
* @example
|
|
58974
|
+
* ```ts
|
|
58975
|
+
* baseOf(undefined, 40); // 32
|
|
58976
|
+
* ```
|
|
58977
|
+
*/
|
|
58978
|
+
function baseOf(base, size) {
|
|
58979
|
+
return base !== void 0 && base > 0 ? base : FALLBACK_BASE * size;
|
|
58980
|
+
}
|
|
58981
|
+
/**
|
|
58388
58982
|
* Creates the empty glyph table. Its own function because lint rule L5 refuses a collection built
|
|
58389
58983
|
* inside an exported declaration.
|
|
58390
58984
|
*
|
|
@@ -58415,6 +59009,7 @@ function readXml(fnt) {
|
|
|
58415
59009
|
const size = Math.abs(attribute(fnt, /<info[^>]*\ssize="(-?\d+)"/) ?? 0);
|
|
58416
59010
|
if (size <= 0) return void 0;
|
|
58417
59011
|
const lineHeight = attribute(fnt, /<common[^>]*\slineHeight="(-?\d+)"/) ?? 0;
|
|
59012
|
+
const base = attribute(fnt, /<common[^>]*\sbase="(-?\d+)"/);
|
|
58418
59013
|
const advances = emptyAdvances();
|
|
58419
59014
|
for (const match of fnt.matchAll(/<char\s(?:[^>"]|"[^"]*")*>/g)) {
|
|
58420
59015
|
const tag = match[0];
|
|
@@ -58426,6 +59021,7 @@ function readXml(fnt) {
|
|
|
58426
59021
|
return {
|
|
58427
59022
|
size,
|
|
58428
59023
|
lineHeight: lineHeight > 0 ? lineHeight : size,
|
|
59024
|
+
base: baseOf(base, size),
|
|
58429
59025
|
advances
|
|
58430
59026
|
};
|
|
58431
59027
|
}
|
|
@@ -58435,12 +59031,12 @@ function readXml(fnt) {
|
|
|
58435
59031
|
*
|
|
58436
59032
|
* @param fnt - The `.fnt` file as text, in BMFont XML or BMFont JSON.
|
|
58437
59033
|
* @param key - The asset key of the font, for the error.
|
|
58438
|
-
* @returns The export size, the line height and one advance per character.
|
|
59034
|
+
* @returns The export size, the line height, the baseline and one advance per character.
|
|
58439
59035
|
* @throws {Error} When the file is in neither format.
|
|
58440
59036
|
* @example
|
|
58441
59037
|
* ```ts
|
|
58442
|
-
* parseAdvances('{"info":{"size":32},"common":{"lineHeight":40},"chars":[]}', "ui.font-body");
|
|
58443
|
-
* // { size: 32, lineHeight: 40, advances: Map(0) }
|
|
59038
|
+
* parseAdvances('{"info":{"size":32},"common":{"lineHeight":40,"base":30},"chars":[]}', "ui.font-body");
|
|
59039
|
+
* // { size: 32, lineHeight: 40, base: 30, advances: Map(0) }
|
|
58444
59040
|
* ```
|
|
58445
59041
|
*/
|
|
58446
59042
|
function parseAdvances(fnt, key) {
|
|
@@ -58449,60 +59045,11 @@ function parseAdvances(fnt, key) {
|
|
|
58449
59045
|
return table;
|
|
58450
59046
|
}
|
|
58451
59047
|
/**
|
|
58452
|
-
* The font one run is drawn with: the bold or italic font when the style names it, else the
|
|
58453
|
-
* font of the style.
|
|
58454
|
-
*
|
|
58455
|
-
* @param style - The style of the label.
|
|
58456
|
-
* @param run - The run to draw.
|
|
58457
|
-
* @returns The asset key of the font.
|
|
58458
|
-
* @example
|
|
58459
|
-
* ```ts
|
|
58460
|
-
* fontOfRun(bodyStyle, { kind: "text", text: "a", bold: true, italic: false, color: undefined });
|
|
58461
|
-
* // "ui.font-body": the body style names no bold font, so the bold is synthetic
|
|
58462
|
-
* ```
|
|
58463
|
-
*/
|
|
58464
|
-
function fontOfRun(style, run) {
|
|
58465
|
-
if (run.bold && style.bold !== void 0) return style.bold;
|
|
58466
|
-
if (run.italic && style.italic !== void 0) return style.italic;
|
|
58467
|
-
return style.font;
|
|
58468
|
-
}
|
|
58469
|
-
/**
|
|
58470
|
-
* The height of one line of a style: `lineHeight × size` when the style names its line, else the
|
|
58471
|
-
* line of its own font.
|
|
58472
|
-
*
|
|
58473
|
-
* @param style - The style of the label.
|
|
58474
|
-
* @param tables - The advance tables that are loaded.
|
|
58475
|
-
* @returns The line height in reference pixels.
|
|
58476
|
-
* @example
|
|
58477
|
-
* ```ts
|
|
58478
|
-
* lineHeightOf(bodyStyle, new Map()); // 38.4: 1.2 em of a 32 px style with no font loaded
|
|
58479
|
-
* ```
|
|
58480
|
-
*/
|
|
58481
|
-
function lineHeightOf(style, tables) {
|
|
58482
|
-
return style.lineHeight === void 0 ? fontLineOf(style, tables) : style.lineHeight * style.size;
|
|
58483
|
-
}
|
|
58484
|
-
/**
|
|
58485
|
-
* The height of one line of a style's own font, whatever line the style names: what the glyphs
|
|
58486
|
-
* are drawn into, so the gap to `lineHeightOf` is the leading.
|
|
58487
|
-
*
|
|
58488
|
-
* @param style - The style of the label.
|
|
58489
|
-
* @param tables - The advance tables that are loaded.
|
|
58490
|
-
* @returns The font's line height in reference pixels.
|
|
58491
|
-
* @example
|
|
58492
|
-
* ```ts
|
|
58493
|
-
* fontLineOf({ ...bodyStyle, lineHeight: 1.5 }, new Map()); // 38.4: the font's 1.2 em, not 48
|
|
58494
|
-
* ```
|
|
58495
|
-
*/
|
|
58496
|
-
function fontLineOf(style, tables) {
|
|
58497
|
-
const table = tables.get(style.font);
|
|
58498
|
-
return table === void 0 ? FALLBACK_LINE * style.size : table.lineHeight * (style.size / table.size);
|
|
58499
|
-
}
|
|
58500
|
-
/**
|
|
58501
59048
|
* The width of one character, letter spacing included. A character the loaded font has no glyph
|
|
58502
59049
|
* for is 0 wide, spacing and all: Pixi skips it when it lays the run out and draws nothing.
|
|
58503
59050
|
*
|
|
58504
59051
|
* @param char - The character.
|
|
58505
|
-
* @param style - The
|
|
59052
|
+
* @param style - The look of the run.
|
|
58506
59053
|
* @param fontKey - The font of the run.
|
|
58507
59054
|
* @param tables - The advance tables that are loaded.
|
|
58508
59055
|
* @param options - Where a warning goes.
|
|
@@ -58524,35 +59071,37 @@ function advanceOf(char, style, fontKey, tables, options) {
|
|
|
58524
59071
|
return 0;
|
|
58525
59072
|
}
|
|
58526
59073
|
/**
|
|
58527
|
-
* The width of one run: the advances of its glyphs, or a square at the line
|
|
59074
|
+
* The width of one run in its look: the advances of its glyphs, or a square at the line of the
|
|
59075
|
+
* look for an icon.
|
|
58528
59076
|
*
|
|
58529
59077
|
* @param run - The run to measure.
|
|
58530
59078
|
* @param style - The style of the label.
|
|
58531
59079
|
* @param tables - The advance tables that are loaded.
|
|
58532
|
-
* @param options - Where a warning goes.
|
|
59080
|
+
* @param options - Where a warning goes, and the styles and bold looks a run may take.
|
|
58533
59081
|
* @returns The width in reference pixels.
|
|
58534
59082
|
* @example
|
|
58535
59083
|
* ```ts
|
|
58536
|
-
* measureRun({ kind: "icon", key: "hud.coin" }, bodyStyle, new Map(), options); // 38.4
|
|
59084
|
+
* measureRun({ kind: "icon", key: "hud.coin", span: undefined }, bodyStyle, new Map(), options); // 38.4
|
|
58537
59085
|
* ```
|
|
58538
59086
|
*/
|
|
58539
59087
|
function measureRun(run, style, tables, options) {
|
|
58540
|
-
|
|
58541
|
-
|
|
59088
|
+
const look = lookIn(style, run, options);
|
|
59089
|
+
if (run.kind === "icon") return lineHeightOf(look, tables) + look.letterSpacing;
|
|
59090
|
+
const fontKey = fontOfRun(look, run);
|
|
58542
59091
|
let width = 0;
|
|
58543
|
-
for (const char of run.text) width += advanceOf(char,
|
|
59092
|
+
for (const char of run.text) width += advanceOf(char, look, fontKey, tables, options);
|
|
58544
59093
|
return width;
|
|
58545
59094
|
}
|
|
58546
59095
|
/**
|
|
58547
59096
|
* Tells whether a glyph piece may join the last run of a line: both glyphs, with the same bold,
|
|
58548
|
-
* italic and
|
|
59097
|
+
* italic, colour and span. An icon never merges.
|
|
58549
59098
|
*
|
|
58550
59099
|
* @param last - The last run of the line, if any.
|
|
58551
59100
|
* @param piece - The glyph piece to append.
|
|
58552
59101
|
* @returns True when the piece's text may be added to `last`.
|
|
58553
59102
|
*/
|
|
58554
59103
|
function canMerge(last, piece) {
|
|
58555
|
-
return last?.kind === "text" && last
|
|
59104
|
+
return last?.kind === "text" && sameLook(last, piece);
|
|
58556
59105
|
}
|
|
58557
59106
|
/**
|
|
58558
59107
|
* Appends a piece to a line, merging glyphs into the last run when both are glyphs with the same
|
|
@@ -58572,7 +59121,42 @@ function appendRun(runs, piece) {
|
|
|
58572
59121
|
runs.push(piece.kind === "text" ? { ...piece } : piece);
|
|
58573
59122
|
}
|
|
58574
59123
|
/**
|
|
58575
|
-
*
|
|
59124
|
+
* Creates one line whose box is not measured yet: `boxLines` writes its height and baseline.
|
|
59125
|
+
*
|
|
59126
|
+
* @param runs - The runs of the line.
|
|
59127
|
+
* @param width - How wide they are, the indent of the first line included.
|
|
59128
|
+
* @returns The line.
|
|
59129
|
+
* @example
|
|
59130
|
+
* ```ts
|
|
59131
|
+
* openLine([], 0); // { runs: [], width: 0, height: 0, baseline: 0 }
|
|
59132
|
+
* ```
|
|
59133
|
+
*/
|
|
59134
|
+
function openLine(runs, width) {
|
|
59135
|
+
return {
|
|
59136
|
+
runs,
|
|
59137
|
+
width,
|
|
59138
|
+
height: 0,
|
|
59139
|
+
baseline: 0
|
|
59140
|
+
};
|
|
59141
|
+
}
|
|
59142
|
+
/**
|
|
59143
|
+
* The width of a line with the indent it starts at: the first line of a block that holds a run is
|
|
59144
|
+
* as wide as its runs plus the indent, every other line as its runs.
|
|
59145
|
+
*
|
|
59146
|
+
* @param runs - The runs of the line.
|
|
59147
|
+
* @param width - How wide they are.
|
|
59148
|
+
* @param indent - The indent the line starts at: `textIndent` on the first line, else 0.
|
|
59149
|
+
* @returns The width of the line.
|
|
59150
|
+
* @example
|
|
59151
|
+
* ```ts
|
|
59152
|
+
* indentedWidth([], 0, 20); // 0: an empty first line takes no indent
|
|
59153
|
+
* ```
|
|
59154
|
+
*/
|
|
59155
|
+
function indentedWidth(runs, width, indent) {
|
|
59156
|
+
return runs.length > 0 ? indent + width : width;
|
|
59157
|
+
}
|
|
59158
|
+
/**
|
|
59159
|
+
* Lays runs out with no wrapping: one line per `\n` segment, the first one shifted by the indent.
|
|
58576
59160
|
*
|
|
58577
59161
|
* @param runs - The runs of the block.
|
|
58578
59162
|
* @param style - The style of the label.
|
|
@@ -58585,10 +59169,8 @@ function layoutFixed(runs, style, tables, options) {
|
|
|
58585
59169
|
let current = [];
|
|
58586
59170
|
let width = 0;
|
|
58587
59171
|
const push = () => {
|
|
58588
|
-
lines.
|
|
58589
|
-
|
|
58590
|
-
width
|
|
58591
|
-
});
|
|
59172
|
+
const indent = lines.length === 0 ? style.textIndent ?? 0 : 0;
|
|
59173
|
+
lines.push(openLine(current, indentedWidth(current, width, indent)));
|
|
58592
59174
|
current = [];
|
|
58593
59175
|
width = 0;
|
|
58594
59176
|
};
|
|
@@ -58743,17 +59325,15 @@ function pushSoft(tokens, hyphen, metrics) {
|
|
|
58743
59325
|
});
|
|
58744
59326
|
}
|
|
58745
59327
|
/**
|
|
58746
|
-
* Closes the open line and starts a new one.
|
|
59328
|
+
* Closes the open line and starts a new one at the edge.
|
|
58747
59329
|
*
|
|
58748
59330
|
* @param builder - The lines built so far.
|
|
58749
59331
|
*/
|
|
58750
59332
|
function commit(builder) {
|
|
58751
|
-
builder.lines.push(
|
|
58752
|
-
runs: builder.runs,
|
|
58753
|
-
width: builder.width
|
|
58754
|
-
});
|
|
59333
|
+
builder.lines.push(openLine(builder.runs, indentedWidth(builder.runs, builder.width, builder.indent)));
|
|
58755
59334
|
builder.runs = [];
|
|
58756
59335
|
builder.width = 0;
|
|
59336
|
+
builder.indent = 0;
|
|
58757
59337
|
}
|
|
58758
59338
|
/**
|
|
58759
59339
|
* Puts a whole token on the open line.
|
|
@@ -58773,7 +59353,8 @@ function add(builder, token) {
|
|
|
58773
59353
|
* @returns The pieces, in reading order.
|
|
58774
59354
|
* @example
|
|
58775
59355
|
* ```ts
|
|
58776
|
-
* glyphsOf({ kind: "icon", key: "hud.coin"
|
|
59356
|
+
* glyphsOf({ kind: "icon", key: "hud.coin", span: undefined });
|
|
59357
|
+
* // [{ kind: "icon", key: "hud.coin", span: undefined }]
|
|
58777
59358
|
* ```
|
|
58778
59359
|
*/
|
|
58779
59360
|
function glyphsOf(run) {
|
|
@@ -58784,7 +59365,20 @@ function glyphsOf(run) {
|
|
|
58784
59365
|
}));
|
|
58785
59366
|
}
|
|
58786
59367
|
/**
|
|
58787
|
-
*
|
|
59368
|
+
* Tells whether a piece of this width no longer fits on the open line: the line holds something
|
|
59369
|
+
* already, and its indent, its runs and the piece stand past the wrap. The first piece of a line
|
|
59370
|
+
* always fits, so a glyph wider than the wrap gets a line of its own.
|
|
59371
|
+
*
|
|
59372
|
+
* @param builder - The lines built so far.
|
|
59373
|
+
* @param width - The width of the piece.
|
|
59374
|
+
* @param wrap - The wrap width in reference pixels.
|
|
59375
|
+
* @returns True when the piece goes to the next line.
|
|
59376
|
+
*/
|
|
59377
|
+
function overflows(builder, width, wrap) {
|
|
59378
|
+
return builder.runs.length > 0 && builder.indent + builder.width + width > wrap;
|
|
59379
|
+
}
|
|
59380
|
+
/**
|
|
59381
|
+
* Places a word that is wider than the room of its line, glyph by glyph. An icon is one glyph.
|
|
58788
59382
|
*
|
|
58789
59383
|
* @param builder - The lines built so far.
|
|
58790
59384
|
* @param token - The word to break.
|
|
@@ -58794,7 +59388,7 @@ function glyphsOf(run) {
|
|
|
58794
59388
|
function breakWord(builder, token, wrap, metrics) {
|
|
58795
59389
|
for (const part of token.runs) for (const piece of glyphsOf(part)) {
|
|
58796
59390
|
const glyph = measureRun(piece, metrics.style, metrics.tables, metrics.options);
|
|
58797
|
-
if (builder
|
|
59391
|
+
if (overflows(builder, glyph, wrap)) commit(builder);
|
|
58798
59392
|
appendRun(builder.runs, piece);
|
|
58799
59393
|
builder.width += glyph;
|
|
58800
59394
|
}
|
|
@@ -58802,8 +59396,9 @@ function breakWord(builder, token, wrap, metrics) {
|
|
|
58802
59396
|
/**
|
|
58803
59397
|
* Places one word: on the open line when it still fits there with the spaces before it and the
|
|
58804
59398
|
* hyphen a break after it would draw, on the next one when it does not, and glyph by glyph when
|
|
58805
|
-
* it fits on no line at all
|
|
58806
|
-
*
|
|
59399
|
+
* it fits on no line at all, or as the first word of a block not in the room its indent leaves. A
|
|
59400
|
+
* break inside a word stands before it with no width: the line ends there with the `-` of a soft
|
|
59401
|
+
* hyphen, and the word goes on with nothing between when it fits.
|
|
58807
59402
|
*
|
|
58808
59403
|
* @param builder - The lines built so far.
|
|
58809
59404
|
* @param token - The word to place.
|
|
@@ -58814,11 +59409,11 @@ function breakWord(builder, token, wrap, metrics) {
|
|
|
58814
59409
|
function placeWord(builder, token, pending, wrap, metrics) {
|
|
58815
59410
|
const space = pending?.kind === "space" ? pending : void 0;
|
|
58816
59411
|
const lead = space?.width ?? 0;
|
|
58817
|
-
if (builder.runs.length > 0 && builder.width + lead + token.width + token.tail > wrap) {
|
|
59412
|
+
if (builder.runs.length > 0 && builder.indent + builder.width + lead + token.width + token.tail > wrap) {
|
|
58818
59413
|
if (pending?.kind === "soft") add(builder, pending);
|
|
58819
59414
|
commit(builder);
|
|
58820
59415
|
} else if (space !== void 0) add(builder, space);
|
|
58821
|
-
if (token.width <= wrap) add(builder, token);
|
|
59416
|
+
if (builder.indent + token.width <= wrap) add(builder, token);
|
|
58822
59417
|
else breakWord(builder, token, wrap, metrics);
|
|
58823
59418
|
}
|
|
58824
59419
|
/**
|
|
@@ -58835,7 +59430,8 @@ function wrapTokens(tokens, metrics, wrap) {
|
|
|
58835
59430
|
const builder = {
|
|
58836
59431
|
lines: [],
|
|
58837
59432
|
runs: [],
|
|
58838
|
-
width: 0
|
|
59433
|
+
width: 0,
|
|
59434
|
+
indent: metrics.style.textIndent ?? 0
|
|
58839
59435
|
};
|
|
58840
59436
|
let pending;
|
|
58841
59437
|
for (const token of tokens) {
|
|
@@ -58875,9 +59471,42 @@ function widestWord(tokens) {
|
|
|
58875
59471
|
return widest;
|
|
58876
59472
|
}
|
|
58877
59473
|
/**
|
|
59474
|
+
* The narrowest line the first word of a block stands on whole after the indent: the word, the
|
|
59475
|
+
* `-` a break after it draws, and the indent. 0 for a block whose first line holds no word.
|
|
59476
|
+
*
|
|
59477
|
+
* @param tokens - The tokens of the block.
|
|
59478
|
+
* @param indent - The `textIndent` of the style.
|
|
59479
|
+
* @returns The width in reference pixels.
|
|
59480
|
+
* @example
|
|
59481
|
+
* ```ts
|
|
59482
|
+
* firstWord([{ kind: "word", runs: [], width: 50, tail: 0 }], 45); // 95
|
|
59483
|
+
* ```
|
|
59484
|
+
*/
|
|
59485
|
+
function firstWord(tokens, indent) {
|
|
59486
|
+
for (const token of tokens) {
|
|
59487
|
+
if (token.kind === "break") return 0;
|
|
59488
|
+
if (token.kind === "word") return token.width + token.tail + indent;
|
|
59489
|
+
}
|
|
59490
|
+
return 0;
|
|
59491
|
+
}
|
|
59492
|
+
/**
|
|
59493
|
+
* Tells whether a block of this many lines is evened out: 2 to 6, as Chrome.
|
|
59494
|
+
*
|
|
59495
|
+
* @param count - The number of greedy lines.
|
|
59496
|
+
* @returns True when the balance searches a narrower width.
|
|
59497
|
+
* @example
|
|
59498
|
+
* ```ts
|
|
59499
|
+
* isBalanced(7); // false: past six lines a block keeps its greedy lines
|
|
59500
|
+
* ```
|
|
59501
|
+
*/
|
|
59502
|
+
function isBalanced(count) {
|
|
59503
|
+
return count >= 2 && count <= BALANCE_MAX_LINES;
|
|
59504
|
+
}
|
|
59505
|
+
/**
|
|
58878
59506
|
* Evens the greedy lines of a balanced style: the narrowest width in `[widest word, wrap]` that
|
|
58879
|
-
* keeps their number, found in 16 halvings, and the lines at that width.
|
|
58880
|
-
*
|
|
59507
|
+
* keeps their number, found in 16 halvings, and the lines at that width. The first word stands
|
|
59508
|
+
* whole after the indent at every width tried. A block of one line or of more than six, or with
|
|
59509
|
+
* a word that does not fit the wrap whole, keeps its greedy lines.
|
|
58881
59510
|
*
|
|
58882
59511
|
* @param tokens - The tokens of the block, as the greedy pass read them.
|
|
58883
59512
|
* @param greedy - The greedy lines at the wrap.
|
|
@@ -58887,9 +59516,10 @@ function widestWord(tokens) {
|
|
|
58887
59516
|
*/
|
|
58888
59517
|
function balanceLines(tokens, greedy, metrics, wrap) {
|
|
58889
59518
|
const count = greedy.length;
|
|
58890
|
-
|
|
59519
|
+
if (!isBalanced(count)) return greedy;
|
|
59520
|
+
let low = Math.max(widestWord(tokens), firstWord(tokens, metrics.style.textIndent ?? 0));
|
|
58891
59521
|
let high = wrap;
|
|
58892
|
-
if (
|
|
59522
|
+
if (low >= high) return greedy;
|
|
58893
59523
|
for (let step = 0; step < BALANCE_STEPS; step += 1) {
|
|
58894
59524
|
const middle = (low + high) / 2;
|
|
58895
59525
|
if (wrapTokens(tokens, metrics, middle).length <= count) high = middle;
|
|
@@ -58919,11 +59549,14 @@ function layoutWrapped(runs, metrics, wrap) {
|
|
|
58919
59549
|
*/
|
|
58920
59550
|
function onceOnly(options) {
|
|
58921
59551
|
const seen = emptyKeys();
|
|
58922
|
-
return {
|
|
58923
|
-
|
|
58924
|
-
|
|
58925
|
-
|
|
58926
|
-
|
|
59552
|
+
return {
|
|
59553
|
+
...options,
|
|
59554
|
+
warn: (key, message, data) => {
|
|
59555
|
+
if (seen.has(key)) return;
|
|
59556
|
+
seen.add(key);
|
|
59557
|
+
options.warn(key, message, data);
|
|
59558
|
+
}
|
|
59559
|
+
};
|
|
58927
59560
|
}
|
|
58928
59561
|
/**
|
|
58929
59562
|
* Creates the empty key set of one layout, for the same reason as `emptyAdvances`.
|
|
@@ -58951,21 +59584,22 @@ function wrapOf(style, box) {
|
|
|
58951
59584
|
return box > 0 ? box + BOX_SLACK : void 0;
|
|
58952
59585
|
}
|
|
58953
59586
|
/**
|
|
58954
|
-
* Lays a block of runs out: the lines, the width of the widest one and the total
|
|
58955
|
-
* alignment of the style changes nothing here; it moves the lines when they are
|
|
58956
|
-
* with `wrap: "box"` wraps at `box`, the width `ui` laid its text element out at,
|
|
58957
|
-
* without one; any other style ignores `box`.
|
|
59587
|
+
* Lays a block of runs out: the lines with their boxes, the width of the widest one and the total
|
|
59588
|
+
* height. The alignment of the style changes nothing here; it moves the lines when they are
|
|
59589
|
+
* drawn. A style with `wrap: "box"` wraps at `box`, the width `ui` laid its text element out at,
|
|
59590
|
+
* and is one line without one; any other style ignores `box`. `options` carries the style table
|
|
59591
|
+
* and the bold looks a run in a span or in `<b>` takes its look from.
|
|
58958
59592
|
*
|
|
58959
59593
|
* @param runs - What `parseTags` made of the resolved string.
|
|
58960
59594
|
* @param style - The style of the label.
|
|
58961
59595
|
* @param tables - The advance tables that are loaded, by font key.
|
|
58962
|
-
* @param options - Where a warning goes.
|
|
59596
|
+
* @param options - Where a warning goes, and the styles and bold looks a run may take.
|
|
58963
59597
|
* @param box - The width a `"box"` style wraps at, in reference pixels; 0 for none.
|
|
58964
59598
|
* @returns The lines and the size of the block in reference pixels.
|
|
58965
59599
|
* @example
|
|
58966
59600
|
* ```ts
|
|
58967
59601
|
* layoutRuns([], bodyStyle, new Map(), { warn: () => undefined });
|
|
58968
|
-
* // { lines: [{ runs: [], width: 0 }], width: 0, height: 38.4 }
|
|
59602
|
+
* // { lines: [{ runs: [], width: 0, height: 38.4, baseline: 25.6 }], width: 0, height: 38.4 }
|
|
58969
59603
|
* ```
|
|
58970
59604
|
*/
|
|
58971
59605
|
function layoutRuns(runs, style, tables, options, box = 0) {
|
|
@@ -58976,167 +59610,14 @@ function layoutRuns(runs, style, tables, options, box = 0) {
|
|
|
58976
59610
|
tables,
|
|
58977
59611
|
options: once
|
|
58978
59612
|
}, wrap);
|
|
59613
|
+
boxLines(lines, style, tables, once);
|
|
58979
59614
|
let width = 0;
|
|
58980
59615
|
for (const line of lines) width = Math.max(width, line.width);
|
|
58981
59616
|
return {
|
|
58982
59617
|
lines,
|
|
58983
59618
|
width,
|
|
58984
|
-
height: lines
|
|
58985
|
-
};
|
|
58986
|
-
}
|
|
58987
|
-
//#endregion
|
|
58988
|
-
//#region src/plugins/text/tags.ts
|
|
58989
|
-
/** Matches an opening colour tag. Six hex digits: `#rgb` is not accepted. */
|
|
58990
|
-
const COLOR_TAG = /^color=#([\da-f]{6})$/i;
|
|
58991
|
-
/** Matches an inline icon tag, which has no closing tag. */
|
|
58992
|
-
const ICON_TAG = /^icon=(\S+)$/;
|
|
58993
|
-
/**
|
|
58994
|
-
* Reads an opening tag.
|
|
58995
|
-
*
|
|
58996
|
-
* @param body - What stood between the angle brackets.
|
|
58997
|
-
* @returns The tag, or `undefined` when it is not one this grammar knows.
|
|
58998
|
-
* @example
|
|
58999
|
-
* ```ts
|
|
59000
|
-
* openTag("color=#ff0000"); // { name: "color", color: 16711680 }
|
|
59001
|
-
* ```
|
|
59002
|
-
*/
|
|
59003
|
-
function openTag(body) {
|
|
59004
|
-
if (body === "b" || body === "i") return {
|
|
59005
|
-
name: body,
|
|
59006
|
-
color: void 0
|
|
59007
|
-
};
|
|
59008
|
-
const colour = COLOR_TAG.exec(body);
|
|
59009
|
-
if (colour === null) return void 0;
|
|
59010
|
-
return {
|
|
59011
|
-
name: "color",
|
|
59012
|
-
color: Number.parseInt(colour[1] ?? "0", 16)
|
|
59013
|
-
};
|
|
59014
|
-
}
|
|
59015
|
-
/**
|
|
59016
|
-
* Appends text to the runs, merging it into the last one when the flags are the same.
|
|
59017
|
-
*
|
|
59018
|
-
* @param runs - The runs built so far.
|
|
59019
|
-
* @param text - The characters to append.
|
|
59020
|
-
* @param stack - The tags that are open around them.
|
|
59021
|
-
*/
|
|
59022
|
-
function pushText(runs, text, stack) {
|
|
59023
|
-
let color;
|
|
59024
|
-
for (const open of stack) if (open.name === "color") color = open.color;
|
|
59025
|
-
const piece = {
|
|
59026
|
-
kind: "text",
|
|
59027
|
-
text,
|
|
59028
|
-
bold: stack.some((open) => open.name === "b"),
|
|
59029
|
-
italic: stack.some((open) => open.name === "i"),
|
|
59030
|
-
color
|
|
59031
|
-
};
|
|
59032
|
-
const last = runs.at(-1);
|
|
59033
|
-
if (last !== void 0 && last.kind === "text" && last.bold === piece.bold && last.italic === piece.italic && last.color === piece.color) {
|
|
59034
|
-
last.text += text;
|
|
59035
|
-
return;
|
|
59036
|
-
}
|
|
59037
|
-
runs.push(piece);
|
|
59038
|
-
}
|
|
59039
|
-
/**
|
|
59040
|
-
* Reports one source string once, whatever is wrong with it.
|
|
59041
|
-
*
|
|
59042
|
-
* @param state - The parse in progress.
|
|
59043
|
-
* @param message - The log event.
|
|
59044
|
-
* @param tag - The tag that was wrong.
|
|
59045
|
-
*/
|
|
59046
|
-
function complain(state, message, tag) {
|
|
59047
|
-
if (state.warned) return;
|
|
59048
|
-
state.warned = true;
|
|
59049
|
-
state.warn(`tag:${state.source}`, message, {
|
|
59050
|
-
tag,
|
|
59051
|
-
text: state.source
|
|
59052
|
-
});
|
|
59053
|
-
}
|
|
59054
|
-
/**
|
|
59055
|
-
* Writes what was read so far into a run.
|
|
59056
|
-
*
|
|
59057
|
-
* @param state - The parse in progress.
|
|
59058
|
-
*/
|
|
59059
|
-
function flush(state) {
|
|
59060
|
-
if (state.buffer.length === 0) return;
|
|
59061
|
-
pushText(state.runs, state.buffer, state.stack);
|
|
59062
|
-
state.buffer = "";
|
|
59063
|
-
}
|
|
59064
|
-
/**
|
|
59065
|
-
* Applies one tag: an icon run, an opening tag, a matching close, or, when it is none of those,
|
|
59066
|
-
* literal text and one warning.
|
|
59067
|
-
*
|
|
59068
|
-
* @param state - The parse in progress.
|
|
59069
|
-
* @param body - What stood between the angle brackets.
|
|
59070
|
-
*/
|
|
59071
|
-
function applyTag(state, body) {
|
|
59072
|
-
const icon = ICON_TAG.exec(body);
|
|
59073
|
-
if (icon !== null) {
|
|
59074
|
-
flush(state);
|
|
59075
|
-
state.runs.push({
|
|
59076
|
-
kind: "icon",
|
|
59077
|
-
key: icon[1] ?? ""
|
|
59078
|
-
});
|
|
59079
|
-
return;
|
|
59080
|
-
}
|
|
59081
|
-
const open = openTag(body);
|
|
59082
|
-
if (open !== void 0) {
|
|
59083
|
-
flush(state);
|
|
59084
|
-
state.stack.push(open);
|
|
59085
|
-
return;
|
|
59086
|
-
}
|
|
59087
|
-
const closes = body.startsWith("/");
|
|
59088
|
-
const at = closes ? state.stack.map((entry) => entry.name).lastIndexOf(body.slice(1)) : -1;
|
|
59089
|
-
if (at !== -1) {
|
|
59090
|
-
flush(state);
|
|
59091
|
-
state.stack.splice(at, 1);
|
|
59092
|
-
return;
|
|
59093
|
-
}
|
|
59094
|
-
complain(state, closes ? "text: stray closing tag" : "text: unknown tag", body);
|
|
59095
|
-
state.buffer += `<${body}>`;
|
|
59096
|
-
}
|
|
59097
|
-
/**
|
|
59098
|
-
* Turns a resolved string into runs of glyphs and inline icons. Everything the grammar does not
|
|
59099
|
-
* know stays visible: the tag is kept as literal text and the source is reported once.
|
|
59100
|
-
*
|
|
59101
|
-
* @param source - The resolved string, as it was written or formatted.
|
|
59102
|
-
* @param warn - Called at most once per source, with the key `tag:<source>`.
|
|
59103
|
-
* @returns The runs, in reading order, with equal neighbours merged.
|
|
59104
|
-
* @example
|
|
59105
|
-
* ```ts
|
|
59106
|
-
* parseTags("<b>a</b>b", () => undefined);
|
|
59107
|
-
* // [{ kind: "text", text: "a", bold: true, italic: false, color: undefined },
|
|
59108
|
-
* // { kind: "text", text: "b", bold: false, italic: false, color: undefined }]
|
|
59109
|
-
* ```
|
|
59110
|
-
*/
|
|
59111
|
-
function parseTags(source, warn) {
|
|
59112
|
-
const state = {
|
|
59113
|
-
source,
|
|
59114
|
-
runs: [],
|
|
59115
|
-
stack: [],
|
|
59116
|
-
buffer: "",
|
|
59117
|
-
warned: false,
|
|
59118
|
-
warn
|
|
59619
|
+
height: blockHeight(lines)
|
|
59119
59620
|
};
|
|
59120
|
-
let index = 0;
|
|
59121
|
-
while (index < source.length) {
|
|
59122
|
-
const char = source[index] ?? "";
|
|
59123
|
-
if (char === "\\" && source[index + 1] === "<") {
|
|
59124
|
-
state.buffer += "<";
|
|
59125
|
-
index += 2;
|
|
59126
|
-
continue;
|
|
59127
|
-
}
|
|
59128
|
-
const close = char === "<" ? source.indexOf(">", index + 1) : -1;
|
|
59129
|
-
if (close === -1) {
|
|
59130
|
-
state.buffer += char;
|
|
59131
|
-
index += 1;
|
|
59132
|
-
continue;
|
|
59133
|
-
}
|
|
59134
|
-
applyTag(state, source.slice(index + 1, close));
|
|
59135
|
-
index = close + 1;
|
|
59136
|
-
}
|
|
59137
|
-
flush(state);
|
|
59138
|
-
if (state.stack.length > 0) complain(state, "text: unclosed tag", state.stack[0]?.name ?? "");
|
|
59139
|
-
return state.runs;
|
|
59140
59621
|
}
|
|
59141
59622
|
//#endregion
|
|
59142
59623
|
//#region src/plugins/text/resolve.ts
|
|
@@ -59146,13 +59627,17 @@ const CACHE_SEPARATOR = String.fromCodePoint(0);
|
|
|
59146
59627
|
const CACHE_LIMIT = 1024;
|
|
59147
59628
|
/** How every inline icon tag starts. A resolved text without it holds no icon. */
|
|
59148
59629
|
const ICON_OPEN = "<icon=";
|
|
59630
|
+
/** How every span tag starts. A resolved text without it holds no span. */
|
|
59631
|
+
const SPAN_OPEN = "<span";
|
|
59632
|
+
/** How every bold tag starts. A resolved text without it holds no bold run. */
|
|
59633
|
+
const BOLD_OPEN = "<b>";
|
|
59149
59634
|
/** The name the system is registered under; it shows up in a world error message. */
|
|
59150
59635
|
const TEXT_SYSTEM_NAME = "text.resolve";
|
|
59151
59636
|
/**
|
|
59152
59637
|
* Writes one dev warning per key. Every warning of this plugin goes through here, so a font, a
|
|
59153
59638
|
* style, a glyph or a bad tag is reported once and never floods a frame.
|
|
59154
59639
|
*
|
|
59155
|
-
* @param ctx -
|
|
59640
|
+
* @param ctx - Kernel or domain context of the text plugin.
|
|
59156
59641
|
* @param key - What makes this warning unique.
|
|
59157
59642
|
* @param message - The log event.
|
|
59158
59643
|
* @param data - What to log with it.
|
|
@@ -59165,7 +59650,7 @@ function warnOnce(ctx, key, message, data) {
|
|
|
59165
59650
|
/**
|
|
59166
59651
|
* The warning the pure modules are handed, bound to this app's `warned` set.
|
|
59167
59652
|
*
|
|
59168
|
-
* @param ctx -
|
|
59653
|
+
* @param ctx - Kernel or domain context of the text plugin.
|
|
59169
59654
|
* @returns A warning that repeats nothing.
|
|
59170
59655
|
*/
|
|
59171
59656
|
function warnFor(ctx) {
|
|
@@ -59196,9 +59681,42 @@ function wrapsAtBox(ctx, styleName) {
|
|
|
59196
59681
|
return (ctx.state.styles.get(styleName) ?? ctx.state.styles.get("body"))?.wrap === "box";
|
|
59197
59682
|
}
|
|
59198
59683
|
/**
|
|
59684
|
+
* What the pure layout and the draw are handed: the warning, the style table a span borrows its
|
|
59685
|
+
* look from, and the bold looks. Built once per domain context, so a draw builds none.
|
|
59686
|
+
*
|
|
59687
|
+
* @param ctx - Kernel context of the text plugin.
|
|
59688
|
+
* @returns The layout options of this app.
|
|
59689
|
+
*/
|
|
59690
|
+
function layoutOptionsOf(ctx) {
|
|
59691
|
+
return {
|
|
59692
|
+
warn: warnFor(ctx),
|
|
59693
|
+
styles: ctx.state.styles,
|
|
59694
|
+
looks: ctx.state.looks
|
|
59695
|
+
};
|
|
59696
|
+
}
|
|
59697
|
+
/**
|
|
59698
|
+
* Reports the first span of a resolved string whose key no style has, once per string. Such a
|
|
59699
|
+
* run is laid out and drawn in the look of the paragraph.
|
|
59700
|
+
*
|
|
59701
|
+
* @param ctx - Domain context of the text plugin.
|
|
59702
|
+
* @param resolved - The tagged string.
|
|
59703
|
+
* @param runs - What `parseTags` made of it.
|
|
59704
|
+
*/
|
|
59705
|
+
function warnUnknownSpan(ctx, resolved, runs) {
|
|
59706
|
+
for (const run of runs) {
|
|
59707
|
+
if (run.span === void 0 || ctx.state.styles.has(run.span)) continue;
|
|
59708
|
+
warnOnce(ctx, `span:${resolved}`, "text: unknown span style", {
|
|
59709
|
+
style: run.span,
|
|
59710
|
+
text: resolved
|
|
59711
|
+
});
|
|
59712
|
+
return;
|
|
59713
|
+
}
|
|
59714
|
+
}
|
|
59715
|
+
/**
|
|
59199
59716
|
* The layout of one resolved string in one style, from the cache or freshly laid out. The cache
|
|
59200
59717
|
* is what makes `measure` cheap enough for `ui` to ask per invalidation. A `"box"` style with a
|
|
59201
|
-
* box is cached per width too; any other style ignores the box and keeps one layout.
|
|
59718
|
+
* box is cached per width too; any other style ignores the box and keeps one layout. A span whose
|
|
59719
|
+
* key no style has is reported here, where the string is in hand, once per string.
|
|
59202
59720
|
*
|
|
59203
59721
|
* @param ctx - Domain context of the text plugin.
|
|
59204
59722
|
* @param resolved - The tagged string.
|
|
@@ -59211,16 +59729,28 @@ function layoutFor(ctx, resolved, styleName, box = 0) {
|
|
|
59211
59729
|
const key = width > 0 ? `${styleName}${CACHE_SEPARATOR}${width}${CACHE_SEPARATOR}${resolved}` : `${styleName}${CACHE_SEPARATOR}${resolved}`;
|
|
59212
59730
|
const hit = ctx.state.cache.get(key);
|
|
59213
59731
|
if (hit !== void 0) return hit;
|
|
59214
|
-
const
|
|
59215
|
-
const
|
|
59216
|
-
if (
|
|
59217
|
-
|
|
59218
|
-
|
|
59219
|
-
}
|
|
59220
|
-
ctx.state.cache.set(key, layout);
|
|
59732
|
+
const options = ctx.layoutOptions;
|
|
59733
|
+
const runs = parseTags(resolved, options.warn);
|
|
59734
|
+
if (resolved.includes(SPAN_OPEN)) warnUnknownSpan(ctx, resolved, runs);
|
|
59735
|
+
const layout = layoutRuns(runs, styleOf$1(ctx, styleName), ctx.state.tables, options, width);
|
|
59736
|
+
keepLayout(ctx.state.cache, key, layout);
|
|
59221
59737
|
return layout;
|
|
59222
59738
|
}
|
|
59223
59739
|
/**
|
|
59740
|
+
* Keeps a fresh layout in the cache, the oldest one dropped first when the cache is full.
|
|
59741
|
+
*
|
|
59742
|
+
* @param cache - The layout cache of the plugin.
|
|
59743
|
+
* @param key - The style, the box and the string the layout is for.
|
|
59744
|
+
* @param layout - The layout.
|
|
59745
|
+
*/
|
|
59746
|
+
function keepLayout(cache, key, layout) {
|
|
59747
|
+
if (cache.size >= CACHE_LIMIT) {
|
|
59748
|
+
const oldest = cache.keys().next().value;
|
|
59749
|
+
if (oldest !== void 0) cache.delete(oldest);
|
|
59750
|
+
}
|
|
59751
|
+
cache.set(key, layout);
|
|
59752
|
+
}
|
|
59753
|
+
/**
|
|
59224
59754
|
* Whether the font of a style has a glyph for one character, the lookup Pixi draws by: a
|
|
59225
59755
|
* character the font lacks is drawn as nothing and measures 0 wide. While the font is not loaded
|
|
59226
59756
|
* every character counts, as the fallback measures it.
|
|
@@ -59501,20 +60031,63 @@ function boxMoved(ctx, seen, text) {
|
|
|
59501
60031
|
return false;
|
|
59502
60032
|
}
|
|
59503
60033
|
/**
|
|
59504
|
-
*
|
|
60034
|
+
* Drops every cached layout and moves the epoch, so a layout a label kept is stale too. Every
|
|
60035
|
+
* place that throws the layouts away goes through here.
|
|
60036
|
+
*
|
|
60037
|
+
* @param state - The plugin state.
|
|
60038
|
+
*/
|
|
60039
|
+
function dropLayouts(state) {
|
|
60040
|
+
state.cache.clear();
|
|
60041
|
+
state.epoch += 1;
|
|
60042
|
+
}
|
|
60043
|
+
/**
|
|
60044
|
+
* Lays out what a label shows and keeps its measured size and that layout, with what it was laid
|
|
60045
|
+
* out from, so the draw of the label in the same frame takes it. Both records are made once per
|
|
60046
|
+
* label, then overwritten in place.
|
|
59505
60047
|
*
|
|
59506
60048
|
* @param ctx - Domain context of the text plugin.
|
|
59507
60049
|
* @param entity - The entity.
|
|
59508
|
-
* @param
|
|
60050
|
+
* @param resolved - The string the label shows now.
|
|
60051
|
+
* @param style - The style name it shows it in.
|
|
60052
|
+
* @param box - The box of its `Text`.
|
|
59509
60053
|
*/
|
|
59510
|
-
function keepSize(ctx, entity,
|
|
60054
|
+
function keepSize(ctx, entity, resolved, style, box) {
|
|
60055
|
+
const layout = layoutFor(ctx, resolved, style, box);
|
|
59511
60056
|
const size = ctx.state.measured.get(entity);
|
|
59512
|
-
if (size === void 0)
|
|
59513
|
-
|
|
60057
|
+
if (size === void 0) ctx.state.measured.set(entity, sizeOf(layout));
|
|
60058
|
+
else {
|
|
60059
|
+
size.width = layout.width;
|
|
60060
|
+
size.height = layout.height;
|
|
60061
|
+
}
|
|
60062
|
+
const shown = ctx.state.shown.get(entity);
|
|
60063
|
+
if (shown === void 0) {
|
|
60064
|
+
ctx.state.shown.set(entity, {
|
|
60065
|
+
resolved,
|
|
60066
|
+
style,
|
|
60067
|
+
box,
|
|
60068
|
+
epoch: ctx.state.epoch,
|
|
60069
|
+
layout
|
|
60070
|
+
});
|
|
59514
60071
|
return;
|
|
59515
60072
|
}
|
|
59516
|
-
|
|
59517
|
-
|
|
60073
|
+
shown.resolved = resolved;
|
|
60074
|
+
shown.style = style;
|
|
60075
|
+
shown.box = box;
|
|
60076
|
+
shown.epoch = ctx.state.epoch;
|
|
60077
|
+
shown.layout = layout;
|
|
60078
|
+
}
|
|
60079
|
+
/**
|
|
60080
|
+
* The layout of a value a label shows: the one the text step kept for its entity when it was laid
|
|
60081
|
+
* out from the same string, style and box under the same cache epoch, else from the cache.
|
|
60082
|
+
*
|
|
60083
|
+
* @param ctx - Domain context of the text plugin.
|
|
60084
|
+
* @param entity - The entity of the label, when the draw knows it.
|
|
60085
|
+
* @param value - The component value to draw.
|
|
60086
|
+
* @returns The layout.
|
|
60087
|
+
*/
|
|
60088
|
+
function shownLayoutOf(ctx, entity, value) {
|
|
60089
|
+
const shown = entity === void 0 ? void 0 : ctx.state.shown.get(entity);
|
|
60090
|
+
return shown !== void 0 && shown.epoch === ctx.state.epoch && shown.resolved === value.resolved && shown.style === value.style && shown.box === value.box ? shown.layout : layoutFor(ctx, value.resolved, value.style, value.box);
|
|
59518
60091
|
}
|
|
59519
60092
|
/**
|
|
59520
60093
|
* Tells whether a bound label already shows what its value would build: the same unit, style and
|
|
@@ -59545,14 +60118,27 @@ function isShown(seen, text, unit, worded, frame) {
|
|
|
59545
60118
|
function showBound(ctx, entity, text, next, value, style = text.style) {
|
|
59546
60119
|
const restyled = style !== text.style;
|
|
59547
60120
|
const changed = restyled || next !== text.resolved;
|
|
59548
|
-
if (changed)
|
|
59549
|
-
|
|
59550
|
-
|
|
59551
|
-
|
|
59552
|
-
|
|
59553
|
-
|
|
59554
|
-
|
|
59555
|
-
|
|
60121
|
+
if (changed) writeBound(ctx, entity, text, next, value, restyled ? style : void 0);
|
|
60122
|
+
if (changed || !ctx.state.measured.has(entity)) keepSize(ctx, entity, next, style, text.box);
|
|
60123
|
+
}
|
|
60124
|
+
/**
|
|
60125
|
+
* Writes the new string of a bound label, its new style when a named format picked another, and
|
|
60126
|
+
* for a countdown the time left.
|
|
60127
|
+
*
|
|
60128
|
+
* @param ctx - Domain context of the text plugin.
|
|
60129
|
+
* @param entity - The entity.
|
|
60130
|
+
* @param text - Its component value.
|
|
60131
|
+
* @param next - The string the label shows now.
|
|
60132
|
+
* @param value - The bound number, the time left for a countdown.
|
|
60133
|
+
* @param style - The style a named format picked, when it is another than `Text.style`.
|
|
60134
|
+
*/
|
|
60135
|
+
function writeBound(ctx, entity, text, next, value, style) {
|
|
60136
|
+
ctx.deps.world.ecs.set(entity, Text, style === void 0 ? { resolved: next } : {
|
|
60137
|
+
resolved: next,
|
|
60138
|
+
style
|
|
60139
|
+
});
|
|
60140
|
+
if (value === void 0 || text.bind === void 0 || !isCountdownLeft(text.bind)) return;
|
|
60141
|
+
ctx.deps.world.ecs.set(entity, Countdown, { left: value });
|
|
59556
60142
|
}
|
|
59557
60143
|
/**
|
|
59558
60144
|
* Writes the string a bound label already shows once more, and measures it again. A mark on a
|
|
@@ -59566,7 +60152,7 @@ function showBound(ctx, entity, text, next, value, style = text.style) {
|
|
|
59566
60152
|
*/
|
|
59567
60153
|
function showAgain(ctx, entity, text) {
|
|
59568
60154
|
ctx.deps.world.ecs.set(entity, Text, { resolved: text.resolved });
|
|
59569
|
-
keepSize(ctx, entity,
|
|
60155
|
+
keepSize(ctx, entity, text.resolved, text.style, text.box);
|
|
59570
60156
|
}
|
|
59571
60157
|
/**
|
|
59572
60158
|
* Reports a bound label whose style is not a digits style, once per style. An unknown style name
|
|
@@ -59617,9 +60203,9 @@ function stepBound(ctx, entity, text, bind, frame) {
|
|
|
59617
60203
|
}
|
|
59618
60204
|
/**
|
|
59619
60205
|
* One frame of a label whose bind names a format a feature registered. Its unit is the whole value.
|
|
59620
|
-
* While
|
|
59621
|
-
* is not called, a
|
|
59622
|
-
* written only when it differs. The format picks the style, so no style is checked for digits. A
|
|
60206
|
+
* While the whole value, the locale, the bind and the style stand still, the frame only reads and
|
|
60207
|
+
* compares: the format is not called, even for a marked label, and nothing is kept. Else the
|
|
60208
|
+
* format is asked once, and its answer is written only when it differs. The format picks the style, so no style is checked for digits. A
|
|
59623
60209
|
* bound field that holds no number shows nothing, as under a built-in format.
|
|
59624
60210
|
*
|
|
59625
60211
|
* @param ctx - Domain context of the text plugin.
|
|
@@ -59659,9 +60245,9 @@ function stepNamed(ctx, entity, text, bind, format, value, frame) {
|
|
|
59659
60245
|
* @param marked - Whether the label was marked this frame.
|
|
59660
60246
|
*/
|
|
59661
60247
|
function standStill(ctx, entity, text, seen, marked) {
|
|
60248
|
+
if (!marked && !boxMoved(ctx, seen, text)) return;
|
|
59662
60249
|
if (marked) showAgain(ctx, entity, text);
|
|
59663
|
-
else
|
|
59664
|
-
else return;
|
|
60250
|
+
else keepSize(ctx, entity, text.resolved, text.style, text.box);
|
|
59665
60251
|
seen.box = text.box;
|
|
59666
60252
|
}
|
|
59667
60253
|
/**
|
|
@@ -59695,7 +60281,7 @@ function stepText(ctx, entity, text, frame) {
|
|
|
59695
60281
|
return;
|
|
59696
60282
|
}
|
|
59697
60283
|
if (!isStale(ctx, entity, text, frame)) return;
|
|
59698
|
-
keepSize(ctx, entity,
|
|
60284
|
+
keepSize(ctx, entity, resolveContent(ctx, entity, text), text.style, text.box);
|
|
59699
60285
|
ctx.state.dirty.delete(entity);
|
|
59700
60286
|
remember(ctx, entity, text, frame);
|
|
59701
60287
|
}
|
|
@@ -59869,10 +60455,11 @@ function markDirty(ctx, keep = () => true) {
|
|
|
59869
60455
|
return marked;
|
|
59870
60456
|
}
|
|
59871
60457
|
/**
|
|
59872
|
-
* Tells whether a label is drawn with one of the asset keys: a font its style names,
|
|
59873
|
-
* icon of its resolved text
|
|
59874
|
-
*
|
|
59875
|
-
*
|
|
60458
|
+
* Tells whether a label is drawn with one of the asset keys: a font its style names, an inline
|
|
60459
|
+
* icon of its resolved text, or the font a run of it draws with in its look, a span's or a bold
|
|
60460
|
+
* one. The text is read through the tag grammar, the way it is drawn, so an escaped `\<icon=…>`
|
|
60461
|
+
* is text and not an icon. A text that holds no icon, no span and, for a style with `boldStyle`,
|
|
60462
|
+
* no bold tag is not read: most labels have none, and this runs for every label of a swap.
|
|
59876
60463
|
*
|
|
59877
60464
|
* @param ctx - Domain context of the text plugin.
|
|
59878
60465
|
* @param text - The component value of the label.
|
|
@@ -59886,8 +60473,24 @@ function drawsWith(ctx, text, keys) {
|
|
|
59886
60473
|
style.bold,
|
|
59887
60474
|
style.italic
|
|
59888
60475
|
].some((font) => font !== void 0 && keys.includes(font))) return true;
|
|
59889
|
-
|
|
59890
|
-
|
|
60476
|
+
const resolved = text.resolved;
|
|
60477
|
+
if (!(style.boldStyle !== void 0 && resolved.includes(BOLD_OPEN)) && !resolved.includes(ICON_OPEN) && !resolved.includes(SPAN_OPEN)) return false;
|
|
60478
|
+
return parseTags(resolved, ctx.layoutOptions.warn).some((run) => runDrawsWith(ctx, style, run, keys));
|
|
60479
|
+
}
|
|
60480
|
+
/**
|
|
60481
|
+
* Tells whether one run is drawn with one of the asset keys: an icon of that key, or glyphs in a
|
|
60482
|
+
* font of that key in the look of the run.
|
|
60483
|
+
*
|
|
60484
|
+
* @param ctx - Domain context of the text plugin.
|
|
60485
|
+
* @param style - The style of the label.
|
|
60486
|
+
* @param run - One run of its text.
|
|
60487
|
+
* @param keys - The asset keys to look for.
|
|
60488
|
+
* @returns True when the run draws with one of `keys`.
|
|
60489
|
+
*/
|
|
60490
|
+
function runDrawsWith(ctx, style, run, keys) {
|
|
60491
|
+
if (run.kind === "icon") return keys.includes(run.key);
|
|
60492
|
+
const look = lookIn(style, run, ctx.layoutOptions);
|
|
60493
|
+
return keys.includes(fontOfRun(look, run));
|
|
59891
60494
|
}
|
|
59892
60495
|
/**
|
|
59893
60496
|
* Forgets an entity whose `Text` left. Works on the state alone, because it is also what the
|
|
@@ -59899,6 +60502,7 @@ function drawsWith(ctx, text, keys) {
|
|
|
59899
60502
|
function forgetText(state, entity) {
|
|
59900
60503
|
state.seen.delete(entity);
|
|
59901
60504
|
state.measured.delete(entity);
|
|
60505
|
+
state.shown.delete(entity);
|
|
59902
60506
|
state.dirty.delete(entity);
|
|
59903
60507
|
}
|
|
59904
60508
|
//#endregion
|
|
@@ -59982,7 +60586,7 @@ function releaseFonts(ctx, keys) {
|
|
|
59982
60586
|
* @param ctx - Domain context of the text plugin.
|
|
59983
60587
|
*/
|
|
59984
60588
|
function refresh(ctx) {
|
|
59985
|
-
ctx.state
|
|
60589
|
+
dropLayouts(ctx.state);
|
|
59986
60590
|
markDirty(ctx);
|
|
59987
60591
|
}
|
|
59988
60592
|
/**
|
|
@@ -60047,29 +60651,51 @@ function reinstallFonts(ctx, fonts, reload) {
|
|
|
60047
60651
|
*/
|
|
60048
60652
|
function applyReplaced(ctx, keys, reload = reloadPage) {
|
|
60049
60653
|
const fonts = keys.filter((key) => ctx.state.fontKeys.has(key));
|
|
60050
|
-
if (fonts.length > 0) ctx.state
|
|
60654
|
+
if (fonts.length > 0) dropLayouts(ctx.state);
|
|
60051
60655
|
if (!reinstallFonts(ctx, fonts, reload)) return;
|
|
60052
60656
|
if (markDirty(ctx, (text) => drawsWith(ctx, text, keys)) === 0) return;
|
|
60053
60657
|
ctx.state.generation += 1;
|
|
60054
60658
|
}
|
|
60055
60659
|
/**
|
|
60056
|
-
*
|
|
60660
|
+
* The width the lines of a block align in, and its anchor moves by: the widest line, or for a
|
|
60661
|
+
* `"box"` style laid out at a box the box when it is wider (F153). `measure` answers the widest
|
|
60662
|
+
* line either way.
|
|
60057
60663
|
*
|
|
60058
60664
|
* @param style - The style of the label.
|
|
60059
|
-
* @param layout - The block
|
|
60665
|
+
* @param layout - The laid-out block.
|
|
60666
|
+
* @param box - The box the label was laid out at; 0 for none.
|
|
60667
|
+
* @returns The width in reference pixels.
|
|
60668
|
+
* @example
|
|
60669
|
+
* ```ts
|
|
60670
|
+
* alignWidthOf({ ...bodyStyle, wrap: "box" }, { lines: [], width: 200, height: 0 }, 300); // 300
|
|
60671
|
+
* ```
|
|
60672
|
+
*/
|
|
60673
|
+
function alignWidthOf(style, layout, box) {
|
|
60674
|
+
return style.wrap === "box" && box > 0 ? Math.max(layout.width, box) : layout.width;
|
|
60675
|
+
}
|
|
60676
|
+
/**
|
|
60677
|
+
* Where a line starts inside the width the block aligns in. The first line of an indented block
|
|
60678
|
+
* counts its indent in its width, so it aligns in the room after the indent.
|
|
60679
|
+
*
|
|
60680
|
+
* @param style - The style of the label.
|
|
60681
|
+
* @param width - The width the block aligns in.
|
|
60060
60682
|
* @param line - The line.
|
|
60061
60683
|
* @returns The offset in reference pixels.
|
|
60684
|
+
* @example
|
|
60685
|
+
* ```ts
|
|
60686
|
+
* alignOffset({ ...bodyStyle, align: "center" }, 300, { runs: [], width: 200, height: 0, baseline: 0 }); // 50
|
|
60687
|
+
* ```
|
|
60062
60688
|
*/
|
|
60063
|
-
function alignOffset(style,
|
|
60689
|
+
function alignOffset(style, width, line) {
|
|
60064
60690
|
if (style.align === "left") return 0;
|
|
60065
|
-
const slack =
|
|
60691
|
+
const slack = width - line.width;
|
|
60066
60692
|
return style.align === "center" ? slack / 2 : slack;
|
|
60067
60693
|
}
|
|
60068
60694
|
/**
|
|
60069
|
-
* The rings of copies one run is drawn over, bottom first: the outline of a stroked
|
|
60070
|
-
* synthetic bold in the fill when the
|
|
60695
|
+
* The rings of copies one run is drawn over, bottom first: the outline of a stroked look, then the
|
|
60696
|
+
* synthetic bold in the fill when the look names no bold font.
|
|
60071
60697
|
*
|
|
60072
|
-
* @param style - The
|
|
60698
|
+
* @param style - The look of the run.
|
|
60073
60699
|
* @param run - The run to draw.
|
|
60074
60700
|
* @param fill - The colour the run is filled with.
|
|
60075
60701
|
* @returns The rings, none for a plain run.
|
|
@@ -60111,34 +60737,35 @@ function iconTexture(ctx, pixi, run) {
|
|
|
60111
60737
|
return ctx.deps.assets.texture(run.key) ?? pixi.Texture.EMPTY;
|
|
60112
60738
|
}
|
|
60113
60739
|
/**
|
|
60114
|
-
* Sizes the sprite of one inline icon square at the line
|
|
60740
|
+
* Sizes the sprite of one inline icon square at the line of its look and puts it where the icon
|
|
60115
60741
|
* starts.
|
|
60116
60742
|
*
|
|
60117
60743
|
* @param ctx - Domain context of the text plugin.
|
|
60118
60744
|
* @param sprite - The sprite of the icon.
|
|
60119
|
-
* @param style - The
|
|
60120
|
-
* @param
|
|
60745
|
+
* @param style - The look of the icon.
|
|
60746
|
+
* @param x - Where the icon starts across, in the local space of the block.
|
|
60747
|
+
* @param y - Where it starts down.
|
|
60121
60748
|
*/
|
|
60122
|
-
function placeIcon(ctx, sprite, style,
|
|
60749
|
+
function placeIcon(ctx, sprite, style, x, y) {
|
|
60123
60750
|
const side = lineHeightOf(style, ctx.state.tables);
|
|
60124
60751
|
sprite.width = side;
|
|
60125
60752
|
sprite.height = side;
|
|
60126
|
-
sprite.x =
|
|
60127
|
-
sprite.y =
|
|
60753
|
+
sprite.x = x;
|
|
60754
|
+
sprite.y = y;
|
|
60128
60755
|
}
|
|
60129
60756
|
/**
|
|
60130
|
-
* Builds the sprite of one inline icon, square at the line
|
|
60757
|
+
* Builds the sprite of one inline icon, square at the line of its look.
|
|
60131
60758
|
*
|
|
60132
60759
|
* @param ctx - Domain context of the text plugin.
|
|
60133
60760
|
* @param pixi - The Pixi module the renderer loaded.
|
|
60134
60761
|
* @param run - The icon to draw.
|
|
60135
|
-
* @param style - The
|
|
60762
|
+
* @param style - The look of the icon.
|
|
60136
60763
|
* @param at - Where the icon starts, in the local space of the block.
|
|
60137
60764
|
* @returns The sprite.
|
|
60138
60765
|
*/
|
|
60139
60766
|
function buildIcon(ctx, pixi, run, style, at) {
|
|
60140
60767
|
const sprite = new pixi.Sprite(iconTexture(ctx, pixi, run));
|
|
60141
|
-
placeIcon(ctx, sprite, style, at);
|
|
60768
|
+
placeIcon(ctx, sprite, style, at.x, at.y);
|
|
60142
60769
|
return sprite;
|
|
60143
60770
|
}
|
|
60144
60771
|
/**
|
|
@@ -60147,7 +60774,7 @@ function buildIcon(ctx, pixi, run, style, at) {
|
|
|
60147
60774
|
*
|
|
60148
60775
|
* @param pixi - The Pixi module the renderer loaded.
|
|
60149
60776
|
* @param run - The glyphs to draw.
|
|
60150
|
-
* @param style - The
|
|
60777
|
+
* @param style - The look of the run.
|
|
60151
60778
|
* @param fill - The colour of the glyphs.
|
|
60152
60779
|
* @param at - Where the run starts, in the local space of the block.
|
|
60153
60780
|
* @returns The display object.
|
|
@@ -60173,8 +60800,8 @@ function buildGlyphs(pixi, run, style, fill, at) {
|
|
|
60173
60800
|
*
|
|
60174
60801
|
* @param pixi - The Pixi module the renderer loaded.
|
|
60175
60802
|
* @param run - The glyphs that cast the shadow.
|
|
60176
|
-
* @param style - The
|
|
60177
|
-
* @param shadow - The shadow of the
|
|
60803
|
+
* @param style - The look of the run.
|
|
60804
|
+
* @param shadow - The shadow of the look.
|
|
60178
60805
|
* @param at - Where the run starts, in the local space of the block.
|
|
60179
60806
|
* @returns The display object, to be drawn under the run.
|
|
60180
60807
|
*/
|
|
@@ -60217,7 +60844,7 @@ function ringSpots(ring, at) {
|
|
|
60217
60844
|
*
|
|
60218
60845
|
* @param pixi - The Pixi module the renderer loaded.
|
|
60219
60846
|
* @param run - The glyphs the ring surrounds.
|
|
60220
|
-
* @param style - The
|
|
60847
|
+
* @param style - The look of the run.
|
|
60221
60848
|
* @param ring - The width and colour of the ring.
|
|
60222
60849
|
* @param at - Where the run starts, in the local space of the block.
|
|
60223
60850
|
* @returns The copies, to be drawn under the run.
|
|
@@ -60230,32 +60857,13 @@ function buildRing(pixi, run, style, ring, at) {
|
|
|
60230
60857
|
});
|
|
60231
60858
|
}
|
|
60232
60859
|
/**
|
|
60233
|
-
* Where every object of one glyph run sits, in the order `buildRun` adds them: its shadow, the
|
|
60234
|
-
* copies of its rings, then the run itself.
|
|
60235
|
-
*
|
|
60236
|
-
* @param style - The style of the label.
|
|
60237
|
-
* @param run - The glyph run.
|
|
60238
|
-
* @param at - Where the run starts, in the local space of the block.
|
|
60239
|
-
* @returns One point per object.
|
|
60240
|
-
*/
|
|
60241
|
-
function glyphSpots(style, run, at) {
|
|
60242
|
-
const shadow = style.shadow;
|
|
60243
|
-
const spots = shadow === void 0 ? [] : [{
|
|
60244
|
-
x: at.x + shadow.dx,
|
|
60245
|
-
y: at.y + shadow.dy
|
|
60246
|
-
}];
|
|
60247
|
-
for (const ring of ringsOf(style, run, run.color ?? style.fill)) spots.push(...ringSpots(ring, at));
|
|
60248
|
-
spots.push(at);
|
|
60249
|
-
return spots;
|
|
60250
|
-
}
|
|
60251
|
-
/**
|
|
60252
60860
|
* Builds the Pixi objects of one run, bottom first: an icon is one sprite, and a glyph run is its
|
|
60253
|
-
* shadow when
|
|
60861
|
+
* shadow when its look has one, its outline and synthetic bold rings, then the glyphs.
|
|
60254
60862
|
*
|
|
60255
60863
|
* @param ctx - Domain context of the text plugin.
|
|
60256
60864
|
* @param pixi - The Pixi module the renderer loaded.
|
|
60257
60865
|
* @param run - The run to draw.
|
|
60258
|
-
* @param style - The
|
|
60866
|
+
* @param style - The look of the run.
|
|
60259
60867
|
* @param at - Where the run starts, in the local space of the block.
|
|
60260
60868
|
* @returns The display objects in drawing order.
|
|
60261
60869
|
*/
|
|
@@ -60282,53 +60890,143 @@ function isOutsideLayout(ctx, style, value) {
|
|
|
60282
60890
|
return (value.box ?? 0) <= 0 && value.resolved !== "" && !ctx.state.laidOut.has(value.style);
|
|
60283
60891
|
}
|
|
60284
60892
|
/**
|
|
60285
|
-
* The style
|
|
60286
|
-
*
|
|
60287
|
-
*
|
|
60893
|
+
* The style one component value is drawn in. A `"box"` style wraps at the box `ui` wrote; with
|
|
60894
|
+
* none it is one line, and a dev warning says so once per style unless a layout measured that
|
|
60895
|
+
* style at a width (a label that fits its row).
|
|
60288
60896
|
*
|
|
60289
60897
|
* @param ctx - Domain context of the text plugin.
|
|
60290
60898
|
* @param value - The component value.
|
|
60291
|
-
* @returns
|
|
60899
|
+
* @returns The style.
|
|
60292
60900
|
*/
|
|
60293
|
-
function
|
|
60901
|
+
function drawnStyleOf(ctx, value) {
|
|
60294
60902
|
const style = styleOf$1(ctx, value.style);
|
|
60295
60903
|
if (isOutsideLayout(ctx, style, value)) warnOnce(ctx, `wrap-box:${value.style}`, "text: wrap \"box\" outside layout", { style: value.style });
|
|
60904
|
+
return style;
|
|
60905
|
+
}
|
|
60906
|
+
/**
|
|
60907
|
+
* The style and the laid-out block of one component value, under the generation of this moment:
|
|
60908
|
+
* what a new container is filled from.
|
|
60909
|
+
*
|
|
60910
|
+
* @param ctx - Domain context of the text plugin.
|
|
60911
|
+
* @param value - The component value.
|
|
60912
|
+
* @param entity - The entity the label sits on, when the draw knows it.
|
|
60913
|
+
* @returns What the container is filled from.
|
|
60914
|
+
*/
|
|
60915
|
+
function labelOf(ctx, value, entity) {
|
|
60296
60916
|
return {
|
|
60297
|
-
style,
|
|
60298
|
-
layout:
|
|
60299
|
-
generation: ctx.state.generation
|
|
60917
|
+
style: drawnStyleOf(ctx, value),
|
|
60918
|
+
layout: shownLayoutOf(ctx, entity, value),
|
|
60919
|
+
generation: ctx.state.generation,
|
|
60920
|
+
entity
|
|
60300
60921
|
};
|
|
60301
60922
|
}
|
|
60302
60923
|
/**
|
|
60303
|
-
*
|
|
60304
|
-
*
|
|
60305
|
-
*
|
|
60924
|
+
* The width of one run of a laid-out block: measured on its first draw and kept for the run.
|
|
60925
|
+
*
|
|
60926
|
+
* @param ctx - Domain context of the text plugin.
|
|
60927
|
+
* @param run - A run of a cached layout.
|
|
60928
|
+
* @param style - The style of the label.
|
|
60929
|
+
* @returns The width in reference pixels.
|
|
60930
|
+
*/
|
|
60931
|
+
function widthOfRun(ctx, run, style) {
|
|
60932
|
+
const kept = ctx.state.runWidths.get(run);
|
|
60933
|
+
if (kept !== void 0) return kept;
|
|
60934
|
+
const width = measureRun(run, style, ctx.state.tables, ctx.layoutOptions);
|
|
60935
|
+
ctx.state.runWidths.set(run, width);
|
|
60936
|
+
return width;
|
|
60937
|
+
}
|
|
60938
|
+
/**
|
|
60939
|
+
* Calls `visit` with every run of a laid-out block, its look and where it starts, anchored by the
|
|
60940
|
+
* component, line after line. The line of a run's look stands so that the run's baseline is the
|
|
60941
|
+
* line's: a run of glyphs starts half its leading below the top of that line, so the glyphs sit in
|
|
60942
|
+
* the middle of a line taller or shorter than the font's, and an icon starts on the line it fills.
|
|
60943
|
+
* A run in a look of its own stands by the font it is drawn with, one in the paragraph's look by
|
|
60944
|
+
* the paragraph's font (`metricsFontOf`). In a line no run reaches past the paragraph's line every
|
|
60945
|
+
* run of the paragraph's look starts on the top of the line, as before lines had boxes. The first
|
|
60946
|
+
* line starts after the indent.
|
|
60306
60947
|
*
|
|
60307
60948
|
* @param ctx - Domain context of the text plugin.
|
|
60308
60949
|
* @param label - The style and the laid-out block.
|
|
60309
|
-
* @param
|
|
60310
|
-
* @param visit - Called once per run, in reading order
|
|
60950
|
+
* @param value - The component value: its anchor, and the box it was laid out at.
|
|
60951
|
+
* @param visit - Called once per run, in reading order: a module function, so no draw builds a
|
|
60952
|
+
* closure; it reaches the container through `state.cursor`.
|
|
60311
60953
|
*/
|
|
60312
|
-
function eachRun(ctx, label,
|
|
60954
|
+
function eachRun(ctx, label, value, visit) {
|
|
60313
60955
|
const { style, layout } = label;
|
|
60314
|
-
const
|
|
60315
|
-
const
|
|
60316
|
-
const
|
|
60317
|
-
const
|
|
60318
|
-
|
|
60956
|
+
const tables = ctx.state.tables;
|
|
60957
|
+
const options = ctx.layoutOptions;
|
|
60958
|
+
const at = ctx.state.cursor.at;
|
|
60959
|
+
const width = alignWidthOf(style, layout, value.box ?? 0);
|
|
60960
|
+
const left = -value.anchor.x * width;
|
|
60961
|
+
let top = -value.anchor.y * layout.height;
|
|
60962
|
+
let indent = style.textIndent ?? 0;
|
|
60319
60963
|
for (const line of layout.lines) {
|
|
60320
|
-
let x = left + alignOffset(style,
|
|
60964
|
+
let x = left + alignOffset(style, width, line) + indent;
|
|
60321
60965
|
for (const run of line.runs) {
|
|
60322
|
-
|
|
60323
|
-
|
|
60324
|
-
|
|
60325
|
-
|
|
60326
|
-
|
|
60966
|
+
const look = lookIn(style, run, options);
|
|
60967
|
+
const font = metricsFontOf(style, look, run);
|
|
60968
|
+
const leading = leadingOf(look, tables, font);
|
|
60969
|
+
const lift = line.baseline - (leading + ascentOf(look, tables, font));
|
|
60970
|
+
at[0] = x;
|
|
60971
|
+
at[1] = run.kind === "text" ? top + lift + leading : top + lift;
|
|
60972
|
+
visit(ctx, run, look);
|
|
60973
|
+
x += widthOfRun(ctx, run, style);
|
|
60327
60974
|
}
|
|
60328
|
-
|
|
60975
|
+
top += line.height;
|
|
60976
|
+
indent = 0;
|
|
60329
60977
|
}
|
|
60330
60978
|
}
|
|
60331
60979
|
/**
|
|
60980
|
+
* Points the draw cursor at a container before a fill or a retext walks its runs.
|
|
60981
|
+
*
|
|
60982
|
+
* @param ctx - Domain context of the text plugin.
|
|
60983
|
+
* @param pixi - The Pixi module the renderer loaded.
|
|
60984
|
+
* @param container - The container of this label.
|
|
60985
|
+
* @returns The cursor, at the first child.
|
|
60986
|
+
*/
|
|
60987
|
+
function openCursor(ctx, pixi, container) {
|
|
60988
|
+
const cursor = ctx.state.cursor;
|
|
60989
|
+
cursor.container = container;
|
|
60990
|
+
cursor.pixi = pixi;
|
|
60991
|
+
cursor.index = 0;
|
|
60992
|
+
return cursor;
|
|
60993
|
+
}
|
|
60994
|
+
/**
|
|
60995
|
+
* Lets the draw cursor go of its container, so the state holds no Pixi object between draws.
|
|
60996
|
+
*
|
|
60997
|
+
* @param cursor - The cursor of the plugin.
|
|
60998
|
+
*/
|
|
60999
|
+
function closeCursor(cursor) {
|
|
61000
|
+
cursor.container = void 0;
|
|
61001
|
+
cursor.pixi = void 0;
|
|
61002
|
+
}
|
|
61003
|
+
/**
|
|
61004
|
+
* Tells whether the draw cursor points at a container, as it does inside a fill or a retext.
|
|
61005
|
+
*
|
|
61006
|
+
* @param cursor - The cursor of the plugin.
|
|
61007
|
+
* @returns True when a container and the Pixi module are set.
|
|
61008
|
+
*/
|
|
61009
|
+
function isOpen(cursor) {
|
|
61010
|
+
return cursor.container !== void 0 && cursor.pixi !== void 0;
|
|
61011
|
+
}
|
|
61012
|
+
/**
|
|
61013
|
+
* Builds the objects of one run into the container of the cursor.
|
|
61014
|
+
*
|
|
61015
|
+
* @param ctx - Domain context of the text plugin.
|
|
61016
|
+
* @param run - The run; where it starts is in `state.cursor.at`.
|
|
61017
|
+
* @param look - The look of the run.
|
|
61018
|
+
*/
|
|
61019
|
+
function fillRun(ctx, run, look) {
|
|
61020
|
+
const cursor = ctx.state.cursor;
|
|
61021
|
+
if (!isOpen(cursor)) return;
|
|
61022
|
+
const { container, pixi, at } = cursor;
|
|
61023
|
+
const spot = {
|
|
61024
|
+
x: at[0] ?? 0,
|
|
61025
|
+
y: at[1] ?? 0
|
|
61026
|
+
};
|
|
61027
|
+
for (const object of buildRun(ctx, pixi, run, look, spot)) container.addChild(object);
|
|
61028
|
+
}
|
|
61029
|
+
/**
|
|
60332
61030
|
* Fills a container with the objects of every run of the laid-out block, anchored by the
|
|
60333
61031
|
* component, and remembers what it was filled from. A shadow sits in the same container as its
|
|
60334
61032
|
* run, so it follows every update, reflow and destroy of it.
|
|
@@ -60340,40 +61038,122 @@ function eachRun(ctx, label, anchor, visit) {
|
|
|
60340
61038
|
* @param label - Its style and laid-out block.
|
|
60341
61039
|
*/
|
|
60342
61040
|
function fill(ctx, pixi, container, value, label) {
|
|
60343
|
-
|
|
60344
|
-
|
|
60345
|
-
|
|
61041
|
+
const cursor = openCursor(ctx, pixi, container);
|
|
61042
|
+
eachRun(ctx, label, value, fillRun);
|
|
61043
|
+
closeCursor(cursor);
|
|
60346
61044
|
ctx.state.drawn.set(container, label);
|
|
60347
61045
|
}
|
|
60348
61046
|
/**
|
|
60349
61047
|
* Tells whether two runs are drawn with the same objects: an icon of the same key, or glyphs with
|
|
60350
|
-
* the same bold, italic and colour. Only the text of a glyph run may
|
|
61048
|
+
* the same bold, italic and colour, both in the same span. Only the text of a glyph run may
|
|
61049
|
+
* differ: a run of another span is in another look, with other fonts and copies.
|
|
60351
61050
|
*
|
|
60352
61051
|
* @param first - One run.
|
|
60353
61052
|
* @param second - The other, or nothing.
|
|
60354
61053
|
* @returns True when the objects of `first` can draw `second`.
|
|
60355
61054
|
*/
|
|
60356
61055
|
function sameObjects(first, second) {
|
|
60357
|
-
if (second === void 0 || first.kind !== second.kind) return false;
|
|
61056
|
+
if (second === void 0 || first.kind !== second.kind || first.span !== second.span) return false;
|
|
60358
61057
|
if (first.kind === "icon") return second.kind === "icon" && first.key === second.key;
|
|
60359
61058
|
return second.kind === "text" && first.bold === second.bold && first.italic === second.italic && first.color === second.color;
|
|
60360
61059
|
}
|
|
60361
61060
|
/**
|
|
60362
|
-
* Tells whether two
|
|
61061
|
+
* Tells whether two lines hold the same runs, one by one.
|
|
61062
|
+
*
|
|
61063
|
+
* @param drawn - A line the container was filled from.
|
|
61064
|
+
* @param next - The line at its place now, if any.
|
|
61065
|
+
* @returns True when the objects of `drawn` can draw `next`.
|
|
61066
|
+
*/
|
|
61067
|
+
function sameLine(drawn, next) {
|
|
61068
|
+
if (next === void 0 || drawn.runs.length !== next.runs.length) return false;
|
|
61069
|
+
for (let at = 0; at < drawn.runs.length; at += 1) {
|
|
61070
|
+
const run = drawn.runs[at];
|
|
61071
|
+
if (run === void 0 || !sameObjects(run, next.runs[at])) return false;
|
|
61072
|
+
}
|
|
61073
|
+
return true;
|
|
61074
|
+
}
|
|
61075
|
+
/**
|
|
61076
|
+
* Tells whether two laid-out blocks have the same lines, each with the same runs. Index loops: an
|
|
61077
|
+
* update of a ticking label asks this every time and builds nothing.
|
|
60363
61078
|
*
|
|
60364
61079
|
* @param drawn - The block the container was filled from.
|
|
60365
61080
|
* @param next - The block to draw now.
|
|
60366
61081
|
* @returns True when the objects of `drawn` can draw `next`.
|
|
60367
61082
|
*/
|
|
60368
61083
|
function sameShape(drawn, next) {
|
|
60369
|
-
|
|
60370
|
-
|
|
60371
|
-
|
|
60372
|
-
|
|
61084
|
+
if (drawn.lines.length !== next.lines.length) return false;
|
|
61085
|
+
for (let index = 0; index < drawn.lines.length; index += 1) {
|
|
61086
|
+
const line = drawn.lines[index];
|
|
61087
|
+
if (line === void 0 || !sameLine(line, next.lines[index])) return false;
|
|
61088
|
+
}
|
|
61089
|
+
return true;
|
|
61090
|
+
}
|
|
61091
|
+
/**
|
|
61092
|
+
* Writes the text of a glyph run into the next child of the cursor and moves it to a spot.
|
|
61093
|
+
*
|
|
61094
|
+
* @param cursor - The draw cursor, its container set.
|
|
61095
|
+
* @param container - The container of the cursor.
|
|
61096
|
+
* @param text - The glyphs of the run.
|
|
61097
|
+
* @param x - The spot across.
|
|
61098
|
+
* @param y - The spot down.
|
|
61099
|
+
*/
|
|
61100
|
+
function moveCopy(cursor, container, text, x, y) {
|
|
61101
|
+
const glyphs = container.getChildAt(cursor.index);
|
|
61102
|
+
glyphs.text = text;
|
|
61103
|
+
glyphs.x = x;
|
|
61104
|
+
glyphs.y = y;
|
|
61105
|
+
cursor.index += 1;
|
|
61106
|
+
}
|
|
61107
|
+
/**
|
|
61108
|
+
* Moves the copies of one ring around a run, in the order `ringSpots` placed them.
|
|
61109
|
+
*
|
|
61110
|
+
* @param cursor - The draw cursor, its container set.
|
|
61111
|
+
* @param container - The container of the cursor.
|
|
61112
|
+
* @param text - The glyphs of the run.
|
|
61113
|
+
* @param width - The radius of the ring.
|
|
61114
|
+
* @param x - Where the run starts across.
|
|
61115
|
+
* @param y - Where it starts down.
|
|
61116
|
+
*/
|
|
61117
|
+
function moveRing(cursor, container, text, width, x, y) {
|
|
61118
|
+
const count = copiesFor(width);
|
|
61119
|
+
for (let index = 0; index < count; index += 1) {
|
|
61120
|
+
const angle = index / count * Math.PI * 2;
|
|
61121
|
+
moveCopy(cursor, container, text, x + Math.cos(angle) * width, y + Math.sin(angle) * width);
|
|
61122
|
+
}
|
|
61123
|
+
}
|
|
61124
|
+
/**
|
|
61125
|
+
* Writes a new block's run into the objects already in the container, in the order `buildRun`
|
|
61126
|
+
* added them: an icon's texture, size and spot; a glyph run's shadow, outline ring, synthetic bold
|
|
61127
|
+
* ring and glyphs, each with the new text at its spot. Walks the spots by index, so it builds
|
|
61128
|
+
* nothing.
|
|
61129
|
+
*
|
|
61130
|
+
* @param ctx - Domain context of the text plugin.
|
|
61131
|
+
* @param run - The run; where it starts is in `state.cursor.at`.
|
|
61132
|
+
* @param look - The look of the run.
|
|
61133
|
+
*/
|
|
61134
|
+
function retextRun(ctx, run, look) {
|
|
61135
|
+
const cursor = ctx.state.cursor;
|
|
61136
|
+
if (!isOpen(cursor)) return;
|
|
61137
|
+
const { container, pixi } = cursor;
|
|
61138
|
+
const x = cursor.at[0] ?? 0;
|
|
61139
|
+
const y = cursor.at[1] ?? 0;
|
|
61140
|
+
if (run.kind === "icon") {
|
|
61141
|
+
const sprite = container.getChildAt(cursor.index);
|
|
61142
|
+
sprite.texture = iconTexture(ctx, pixi, run);
|
|
61143
|
+
placeIcon(ctx, sprite, look, x, y);
|
|
61144
|
+
cursor.index += 1;
|
|
61145
|
+
return;
|
|
61146
|
+
}
|
|
61147
|
+
const shadow = look.shadow;
|
|
61148
|
+
if (shadow !== void 0) moveCopy(cursor, container, run.text, x + shadow.dx, y + shadow.dy);
|
|
61149
|
+
if (look.strokeWidth > 0) moveRing(cursor, container, run.text, look.strokeWidth, x, y);
|
|
61150
|
+
if (run.bold && look.bold === void 0) moveRing(cursor, container, run.text, look.size / SYNTHETIC_BOLD, x, y);
|
|
61151
|
+
moveCopy(cursor, container, run.text, x, y);
|
|
60373
61152
|
}
|
|
60374
61153
|
/**
|
|
60375
61154
|
* Writes a new block into the objects already in the container, in the order `fill` added them:
|
|
60376
|
-
* the text and the spots of every glyph object, the texture, size and spot of every icon.
|
|
61155
|
+
* the text and the spots of every glyph object, the texture, size and spot of every icon. The
|
|
61156
|
+
* label record is the drawn one, its layout already written.
|
|
60377
61157
|
*
|
|
60378
61158
|
* @param ctx - Domain context of the text plugin.
|
|
60379
61159
|
* @param pixi - The Pixi module the renderer loaded.
|
|
@@ -60382,24 +61162,9 @@ function sameShape(drawn, next) {
|
|
|
60382
61162
|
* @param label - Its style and laid-out block, of the same shape as the drawn one.
|
|
60383
61163
|
*/
|
|
60384
61164
|
function retext(ctx, pixi, container, value, label) {
|
|
60385
|
-
|
|
60386
|
-
eachRun(ctx, label, value
|
|
60387
|
-
|
|
60388
|
-
const sprite = container.getChildAt(index);
|
|
60389
|
-
sprite.texture = iconTexture(ctx, pixi, run);
|
|
60390
|
-
placeIcon(ctx, sprite, label.style, at);
|
|
60391
|
-
index += 1;
|
|
60392
|
-
return;
|
|
60393
|
-
}
|
|
60394
|
-
for (const spot of glyphSpots(label.style, run, at)) {
|
|
60395
|
-
const glyphs = container.getChildAt(index);
|
|
60396
|
-
glyphs.text = run.text;
|
|
60397
|
-
glyphs.x = spot.x;
|
|
60398
|
-
glyphs.y = spot.y;
|
|
60399
|
-
index += 1;
|
|
60400
|
-
}
|
|
60401
|
-
});
|
|
60402
|
-
ctx.state.drawn.set(container, label);
|
|
61165
|
+
const cursor = openCursor(ctx, pixi, container);
|
|
61166
|
+
eachRun(ctx, label, value, retextRun);
|
|
61167
|
+
closeCursor(cursor);
|
|
60403
61168
|
}
|
|
60404
61169
|
/**
|
|
60405
61170
|
* Tells whether two anchors are the same point.
|
|
@@ -60416,7 +61181,9 @@ function samePoint(first, second) {
|
|
|
60416
61181
|
* was last updated with, drawn with the style object that is current and under the generation
|
|
60417
61182
|
* that is current, and for a `"box"` style at the same box. A replaced style is a new object under
|
|
60418
61183
|
* the same name. A font or an icon a dev hot swap replaced moves the generation, because the
|
|
60419
|
-
* objects hold textures that are destroyed
|
|
61184
|
+
* objects hold textures that are destroyed, and so does a styles swap, because a span or a bold
|
|
61185
|
+
* look of the label may have changed under a style that stood. The box of any other style changes
|
|
61186
|
+
* nothing drawn.
|
|
60420
61187
|
*
|
|
60421
61188
|
* @param ctx - Domain context of the text plugin.
|
|
60422
61189
|
* @param container - The container of this label.
|
|
@@ -60432,9 +61199,10 @@ function isCurrent(ctx, container, previous, next) {
|
|
|
60432
61199
|
/**
|
|
60433
61200
|
* Draws a changed value into a container that holds a label already. A ticking counter keeps its
|
|
60434
61201
|
* objects: with the same style object, the same generation, the same anchor and the same lines
|
|
60435
|
-
* and runs, the new text and spots are written into them
|
|
60436
|
-
*
|
|
60437
|
-
*
|
|
61202
|
+
* and runs, the new text and spots are written into them and the new layout into the drawn
|
|
61203
|
+
* record, so the update builds nothing. Anything else frees the children and fills the container
|
|
61204
|
+
* again. A label of an older generation is always filled again: writing the string it shows
|
|
61205
|
+
* already into a `BitmapText` rebuilds no glyph.
|
|
60438
61206
|
*
|
|
60439
61207
|
* @param ctx - Domain context of the text plugin.
|
|
60440
61208
|
* @param pixi - The Pixi module the renderer loaded.
|
|
@@ -60444,16 +61212,24 @@ function isCurrent(ctx, container, previous, next) {
|
|
|
60444
61212
|
*/
|
|
60445
61213
|
function redraw(ctx, pixi, container, previous, next) {
|
|
60446
61214
|
const drawn = ctx.state.drawn.get(container);
|
|
60447
|
-
const
|
|
60448
|
-
|
|
60449
|
-
|
|
61215
|
+
const style = drawnStyleOf(ctx, next);
|
|
61216
|
+
const layout = shownLayoutOf(ctx, drawn?.entity, next);
|
|
61217
|
+
const generation = ctx.state.generation;
|
|
61218
|
+
if (drawn?.style === style && drawn.generation === generation && samePoint(previous.anchor, next.anchor) && sameShape(drawn.layout, layout)) {
|
|
61219
|
+
drawn.layout = layout;
|
|
61220
|
+
retext(ctx, pixi, container, next, drawn);
|
|
60450
61221
|
return;
|
|
60451
61222
|
}
|
|
60452
61223
|
for (const child of container.removeChildren()) child.destroy({
|
|
60453
61224
|
children: true,
|
|
60454
61225
|
texture: false
|
|
60455
61226
|
});
|
|
60456
|
-
fill(ctx, pixi, container, next,
|
|
61227
|
+
fill(ctx, pixi, container, next, {
|
|
61228
|
+
style,
|
|
61229
|
+
layout,
|
|
61230
|
+
generation,
|
|
61231
|
+
entity: drawn?.entity
|
|
61232
|
+
});
|
|
60457
61233
|
}
|
|
60458
61234
|
/**
|
|
60459
61235
|
* How a `Text` becomes Pixi objects. The renderer parents, orders and frees the container like a
|
|
@@ -60467,12 +61243,12 @@ function redraw(ctx, pixi, container, previous, next) {
|
|
|
60467
61243
|
*/
|
|
60468
61244
|
function createTextAdapter(ctx) {
|
|
60469
61245
|
return {
|
|
60470
|
-
create: (value) => {
|
|
61246
|
+
create: (value, entity) => {
|
|
60471
61247
|
const pixi = ctx.deps.renderer.host.pixi();
|
|
60472
61248
|
if (pixi === void 0) return void 0;
|
|
60473
61249
|
const container = new pixi.Container();
|
|
60474
61250
|
container.alpha = value.alpha;
|
|
60475
|
-
fill(ctx, pixi, container, value, labelOf(ctx, value));
|
|
61251
|
+
fill(ctx, pixi, container, value, labelOf(ctx, value, entity));
|
|
60476
61252
|
return container;
|
|
60477
61253
|
},
|
|
60478
61254
|
update: (object, previous, next) => {
|
|
@@ -60535,7 +61311,8 @@ function resolveDeps$1(ctx) {
|
|
|
60535
61311
|
};
|
|
60536
61312
|
}
|
|
60537
61313
|
/**
|
|
60538
|
-
* Builds the domain context the API, the hooks and the frame step share
|
|
61314
|
+
* Builds the domain context the API, the hooks and the frame step share, with the layout options
|
|
61315
|
+
* every layout and draw reads, made here once.
|
|
60539
61316
|
*
|
|
60540
61317
|
* @param ctx - Kernel context of the text plugin.
|
|
60541
61318
|
* @returns The domain context of the text plugin.
|
|
@@ -60543,7 +61320,8 @@ function resolveDeps$1(ctx) {
|
|
|
60543
61320
|
function withDeps$1(ctx) {
|
|
60544
61321
|
return {
|
|
60545
61322
|
...ctx,
|
|
60546
|
-
deps: resolveDeps$1(ctx)
|
|
61323
|
+
deps: resolveDeps$1(ctx),
|
|
61324
|
+
layoutOptions: layoutOptionsOf(ctx)
|
|
60547
61325
|
};
|
|
60548
61326
|
}
|
|
60549
61327
|
/**
|
|
@@ -60556,6 +61334,20 @@ function isStyleMap(entry) {
|
|
|
60556
61334
|
return typeof entry === "object" && entry !== null && "kind" in entry && entry.kind === "textStyles" && "map" in entry && typeof entry.map === "object" && entry.map !== null;
|
|
60557
61335
|
}
|
|
60558
61336
|
/**
|
|
61337
|
+
* Refuses a style name a second feature defines. A built-in name is free: a feature may
|
|
61338
|
+
* override it.
|
|
61339
|
+
*
|
|
61340
|
+
* @param state - The plugin state, its owners so far.
|
|
61341
|
+
* @param name - The style name.
|
|
61342
|
+
* @param feature - The feature that defines it now.
|
|
61343
|
+
* @throws {Error} When another feature defined the name already.
|
|
61344
|
+
*/
|
|
61345
|
+
function checkOwner(state, name, feature) {
|
|
61346
|
+
const owner = state.styleOwner.get(name);
|
|
61347
|
+
if (owner === void 0 || owner === BUILT_IN) return;
|
|
61348
|
+
throw new Error(`[game] Text style "${name}" is defined by features "${owner}" and "${feature}".\n Keep it in one feature or rename one of them.`);
|
|
61349
|
+
}
|
|
61350
|
+
/**
|
|
60559
61351
|
* Fills the style table: the two built-ins first, then the styles of every feature in feature
|
|
60560
61352
|
* order. A feature may override a built-in; two features may not share a name.
|
|
60561
61353
|
*
|
|
@@ -60571,8 +61363,7 @@ function buildStyles(ctx) {
|
|
|
60571
61363
|
const entry = feature.description.textStyles;
|
|
60572
61364
|
if (!isStyleMap(entry)) continue;
|
|
60573
61365
|
for (const [name, value] of Object.entries(entry.map)) {
|
|
60574
|
-
|
|
60575
|
-
if (owner !== void 0 && owner !== BUILT_IN) throw new Error(`[game] Text style "${name}" is defined by features "${owner}" and "${feature.name}".\n Keep it in one feature or rename one of them.`);
|
|
61366
|
+
checkOwner(ctx.state, name, feature.name);
|
|
60576
61367
|
const style = readStyle(name, value);
|
|
60577
61368
|
if (style === void 0) continue;
|
|
60578
61369
|
ctx.state.styles.set(name, style);
|
|
@@ -60581,6 +61372,16 @@ function buildStyles(ctx) {
|
|
|
60581
61372
|
}
|
|
60582
61373
|
}
|
|
60583
61374
|
/**
|
|
61375
|
+
* Builds the bold look of every style that has `boldStyle`, and forgets the looks of styles that
|
|
61376
|
+
* are gone: a hot swap replaces the style objects the looks are keyed by.
|
|
61377
|
+
*
|
|
61378
|
+
* @param state - The plugin state, its style table filled.
|
|
61379
|
+
*/
|
|
61380
|
+
function buildLooks(state) {
|
|
61381
|
+
state.looks.clear();
|
|
61382
|
+
for (const style of state.styles.values()) if (style.boldStyle !== void 0) state.looks.set(style, boldLookOf(style, style.boldStyle));
|
|
61383
|
+
}
|
|
61384
|
+
/**
|
|
60584
61385
|
* Tells whether a feature entry is a format map `text` can read.
|
|
60585
61386
|
*
|
|
60586
61387
|
* @param entry - What the feature put under its `textFormats` key.
|
|
@@ -60632,8 +61433,8 @@ function buildFormats(ctx) {
|
|
|
60632
61433
|
}
|
|
60633
61434
|
}
|
|
60634
61435
|
/**
|
|
60635
|
-
* Collects every font a style can draw with: the two of the config, then the regular, bold
|
|
60636
|
-
* italic font of every registered style.
|
|
61436
|
+
* Collects every font a style can draw with: the two of the config, then the regular, bold,
|
|
61437
|
+
* italic and `boldStyle` font of every registered style.
|
|
60637
61438
|
*
|
|
60638
61439
|
* @param ctx - Domain context of the text plugin.
|
|
60639
61440
|
*/
|
|
@@ -60644,13 +61445,15 @@ function collectFonts(ctx) {
|
|
|
60644
61445
|
ctx.state.fontKeys.add(style.font);
|
|
60645
61446
|
if (style.bold !== void 0) ctx.state.fontKeys.add(style.bold);
|
|
60646
61447
|
if (style.italic !== void 0) ctx.state.fontKeys.add(style.italic);
|
|
61448
|
+
if (style.boldStyle?.font !== void 0) ctx.state.fontKeys.add(style.boldStyle.font);
|
|
60647
61449
|
}
|
|
60648
61450
|
}
|
|
60649
61451
|
/**
|
|
60650
61452
|
* Writes the styles of a saved styles file over the table: a known name keeps its owner, a new
|
|
60651
|
-
* name is added. Then the fonts of the new styles are read,
|
|
60652
|
-
* styles are dropped,
|
|
60653
|
-
*
|
|
61453
|
+
* name is added, and the bold looks are built again. Then the fonts of the new styles are read,
|
|
61454
|
+
* the layouts measured with the old styles are dropped, every label is marked and the generation
|
|
61455
|
+
* moves, so the next frame lays every label out again and the display adapter builds it again: a
|
|
61456
|
+
* label whose own style stood still may draw a span or a bold look that changed.
|
|
60654
61457
|
*
|
|
60655
61458
|
* @param ctx - Domain context of the text plugin.
|
|
60656
61459
|
* @param styles - What `defineTextStyles` returned in the saved module.
|
|
@@ -60662,9 +61465,11 @@ function replaceStyles(ctx, styles) {
|
|
|
60662
61465
|
ctx.state.styles.set(name, style);
|
|
60663
61466
|
if (!ctx.state.styleOwner.has(name)) ctx.state.styleOwner.set(name, HOT_SWAP);
|
|
60664
61467
|
}
|
|
61468
|
+
buildLooks(ctx.state);
|
|
60665
61469
|
collectFonts(ctx);
|
|
60666
61470
|
installFonts(ctx);
|
|
60667
|
-
ctx.state
|
|
61471
|
+
dropLayouts(ctx.state);
|
|
61472
|
+
ctx.state.generation += 1;
|
|
60668
61473
|
markDirty(ctx);
|
|
60669
61474
|
ctx.deps.time.wake();
|
|
60670
61475
|
}
|
|
@@ -60685,6 +61490,7 @@ function startText(ctx) {
|
|
|
60685
61490
|
const ecs = tctx.deps.world.ecs;
|
|
60686
61491
|
const frame = createTextFrame(tctx);
|
|
60687
61492
|
buildStyles(tctx);
|
|
61493
|
+
buildLooks(tctx.state);
|
|
60688
61494
|
buildFormats(tctx);
|
|
60689
61495
|
collectFonts(tctx);
|
|
60690
61496
|
tctx.state.removers.push(ecs.system(createTextSystem(tctx, frame)), tctx.deps.time.onFrame("layout", () => resolveAdded(tctx, frame)), ecs.onAdded(Text, (entity) => noteAdded(tctx, entity)), ecs.onRemoved(Text, (entity) => {
|
|
@@ -60703,6 +61509,7 @@ function stopText(state) {
|
|
|
60703
61509
|
for (const off of state.removers) off();
|
|
60704
61510
|
state.removers.length = 0;
|
|
60705
61511
|
state.styles.clear();
|
|
61512
|
+
state.looks.clear();
|
|
60706
61513
|
state.styleOwner.clear();
|
|
60707
61514
|
state.formats.clear();
|
|
60708
61515
|
state.formatOwner.clear();
|
|
@@ -60712,7 +61519,9 @@ function stopText(state) {
|
|
|
60712
61519
|
state.seen.clear();
|
|
60713
61520
|
state.bindTypes.clear();
|
|
60714
61521
|
state.measured.clear();
|
|
60715
|
-
state
|
|
61522
|
+
dropLayouts(state);
|
|
61523
|
+
state.shown.clear();
|
|
61524
|
+
closeCursor(state.cursor);
|
|
60716
61525
|
state.dirty.clear();
|
|
60717
61526
|
state.added.length = 0;
|
|
60718
61527
|
state.rewrite.length = 0;
|
|
@@ -60819,7 +61628,7 @@ function createHandlers(ctx, reload) {
|
|
|
60819
61628
|
"i18n:locale-changed": (_payload) => {
|
|
60820
61629
|
const tctx = domain();
|
|
60821
61630
|
markDirty(tctx, (label) => typeof label.content !== "string");
|
|
60822
|
-
tctx.state
|
|
61631
|
+
dropLayouts(tctx.state);
|
|
60823
61632
|
tctx.deps.time.wake();
|
|
60824
61633
|
}
|
|
60825
61634
|
};
|
|
@@ -60859,6 +61668,7 @@ function emptyWeakMap() {
|
|
|
60859
61668
|
function createTextState$1() {
|
|
60860
61669
|
return {
|
|
60861
61670
|
styles: emptyMap$2(),
|
|
61671
|
+
looks: emptyMap$2(),
|
|
60862
61672
|
styleOwner: emptyMap$2(),
|
|
60863
61673
|
formats: emptyMap$2(),
|
|
60864
61674
|
formatOwner: emptyMap$2(),
|
|
@@ -60869,6 +61679,15 @@ function createTextState$1() {
|
|
|
60869
61679
|
bindTypes: emptyMap$2(),
|
|
60870
61680
|
measured: emptyMap$2(),
|
|
60871
61681
|
cache: emptyMap$2(),
|
|
61682
|
+
epoch: 0,
|
|
61683
|
+
shown: emptyMap$2(),
|
|
61684
|
+
cursor: {
|
|
61685
|
+
container: void 0,
|
|
61686
|
+
pixi: void 0,
|
|
61687
|
+
index: 0,
|
|
61688
|
+
at: /* @__PURE__ */ new Float64Array(2)
|
|
61689
|
+
},
|
|
61690
|
+
runWidths: emptyWeakMap(),
|
|
60872
61691
|
drawn: emptyWeakMap(),
|
|
60873
61692
|
dirty: emptySet$1(),
|
|
60874
61693
|
added: [],
|
|
@@ -61222,6 +62041,10 @@ function rectOfTargets(ctx, to) {
|
|
|
61222
62041
|
//#endregion
|
|
61223
62042
|
//#region src/plugins/ui/jsx/field-layout.ts
|
|
61224
62043
|
/**
|
|
62044
|
+
* @file ui/jsx — where the parts of a text field go, and how far the keyboard lifts it. Pure: the
|
|
62045
|
+
* mirror, the measured prefixes and the box in, numbers out. No ctx, no state, no DOM.
|
|
62046
|
+
*/
|
|
62047
|
+
/**
|
|
61225
62048
|
* The four edges of a resolved padding.
|
|
61226
62049
|
*
|
|
61227
62050
|
* @param padding - One number for every edge, the edges a style names, or nothing.
|
|
@@ -61449,6 +62272,18 @@ function insetOf(viewport) {
|
|
|
61449
62272
|
function liftOf(input) {
|
|
61450
62273
|
return Math.max(0, input.fieldBottom + input.margin - (input.innerHeight - input.inset));
|
|
61451
62274
|
}
|
|
62275
|
+
/**
|
|
62276
|
+
* A typed value as `text` takes it: plain text, where `<` is never markup. It is `text`'s own
|
|
62277
|
+
* `escapeTags`, so a field writes a `<` the way the tag grammar reads a literal one; a value
|
|
62278
|
+
* without one is handed as it is. Only the string for `text` changes, never the indices of the
|
|
62279
|
+
* caret and the selection.
|
|
62280
|
+
*
|
|
62281
|
+
* @example
|
|
62282
|
+
* ```ts
|
|
62283
|
+
* literalText("<b>x"); // "\\<b>x"
|
|
62284
|
+
* ```
|
|
62285
|
+
*/
|
|
62286
|
+
const literalText = escapeTags;
|
|
61452
62287
|
/** A high surrogate: the first half of a character outside the Basic Multilingual Plane. */
|
|
61453
62288
|
const OPEN_SURROGATE = /[\uD800-\uDBFF]$/;
|
|
61454
62289
|
/**
|
|
@@ -61979,6 +62814,8 @@ const KINDS = [
|
|
|
61979
62814
|
const PLACEHOLDER_ALPHA = .5;
|
|
61980
62815
|
/** The separator between the inputs of a field's fingerprint. */
|
|
61981
62816
|
const FIELD_SEPARATOR = "\0";
|
|
62817
|
+
/** What a fingerprint holds for an input the field has not: no mirror, no composing range. */
|
|
62818
|
+
const NO_INPUT = "-";
|
|
61982
62819
|
/**
|
|
61983
62820
|
* Reads the props of an `input` tag.
|
|
61984
62821
|
*
|
|
@@ -62098,7 +62935,8 @@ function boxPart(box, fill, alpha) {
|
|
|
62098
62935
|
* The component values of the four parts of a laid-out field.
|
|
62099
62936
|
*
|
|
62100
62937
|
* @param layout - Where the parts go.
|
|
62101
|
-
* @param content - What the text part draws: the value, or the placeholder at half
|
|
62938
|
+
* @param content - What the text part draws: the value as plain text, or the placeholder at half
|
|
62939
|
+
* alpha.
|
|
62102
62940
|
* @param textStyle - The text style of the field.
|
|
62103
62941
|
* @param look - The caret, selection and underline look of the config.
|
|
62104
62942
|
* @returns The values, per part.
|
|
@@ -62117,6 +62955,33 @@ function partValues(layout, content, textStyle, look) {
|
|
|
62117
62955
|
};
|
|
62118
62956
|
}
|
|
62119
62957
|
/**
|
|
62958
|
+
* Where a rect of reference units is on the page: its rect in screen px, and its bottom edge as
|
|
62959
|
+
* the viewport maps it, which the keyboard lift is measured from.
|
|
62960
|
+
*
|
|
62961
|
+
* @param viewport - The viewport of the renderer.
|
|
62962
|
+
* @param drawn - The rect in reference units.
|
|
62963
|
+
* @returns The rect in screen px and its bottom.
|
|
62964
|
+
*/
|
|
62965
|
+
function screenRectOf(viewport, drawn) {
|
|
62966
|
+
const topLeft = viewport.toScreen({
|
|
62967
|
+
x: drawn.x,
|
|
62968
|
+
y: drawn.y
|
|
62969
|
+
});
|
|
62970
|
+
const bottomRight = viewport.toScreen({
|
|
62971
|
+
x: drawn.x + drawn.w,
|
|
62972
|
+
y: drawn.y + drawn.h
|
|
62973
|
+
});
|
|
62974
|
+
return {
|
|
62975
|
+
rect: {
|
|
62976
|
+
x: topLeft.x,
|
|
62977
|
+
y: topLeft.y,
|
|
62978
|
+
w: bottomRight.x - topLeft.x,
|
|
62979
|
+
h: bottomRight.y - topLeft.y
|
|
62980
|
+
},
|
|
62981
|
+
bottom: bottomRight.y
|
|
62982
|
+
};
|
|
62983
|
+
}
|
|
62984
|
+
/**
|
|
62120
62985
|
* A cheap fingerprint of what a field is laid out from: the selection and the composing range
|
|
62121
62986
|
* while it is edited, the box, the padding, the text style, the placeholder and the value. The
|
|
62122
62987
|
* value goes last, so no character of it can shift another input.
|
|
@@ -62129,9 +62994,9 @@ function partValues(layout, content, textStyle, look) {
|
|
|
62129
62994
|
* @returns The fingerprint.
|
|
62130
62995
|
*/
|
|
62131
62996
|
function inputsOf(field, element, mirror, composing, value) {
|
|
62997
|
+
const selection = mirror === void 0 ? NO_INPUT : `${mirror.selectionStart},${mirror.selectionEnd},${mirror.direction}`;
|
|
62998
|
+
const range = composing === void 0 ? NO_INPUT : `${composing.start},${composing.end}`;
|
|
62132
62999
|
const pad = paddingOf(element.style.padding);
|
|
62133
|
-
const selection = mirror === void 0 ? "-" : `${mirror.selectionStart},${mirror.selectionEnd},${mirror.direction}`;
|
|
62134
|
-
const range = composing === void 0 ? "-" : `${composing.start},${composing.end}`;
|
|
62135
63000
|
const box = `${element.rect.w},${element.rect.h},${pad.top},${pad.right},${pad.bottom},${pad.left}`;
|
|
62136
63001
|
const placeholder = JSON.stringify(field.placeholder ?? "");
|
|
62137
63002
|
return [
|
|
@@ -62484,7 +63349,7 @@ function createFields(ctx, links) {
|
|
|
62484
63349
|
lineHeight: measure("").height,
|
|
62485
63350
|
caretWidth: look.caretWidth,
|
|
62486
63351
|
underline: look.composingUnderline,
|
|
62487
|
-
prefix: (piece) => measure(piece).width,
|
|
63352
|
+
prefix: (piece) => measure(literalText(piece)).width,
|
|
62488
63353
|
hasGlyph: (char) => ctx.deps.text.hasGlyph(char, field.textStyle)
|
|
62489
63354
|
});
|
|
62490
63355
|
}
|
|
@@ -62499,7 +63364,7 @@ function createFields(ctx, links) {
|
|
|
62499
63364
|
*/
|
|
62500
63365
|
function drawField(field, layout, value, inputs) {
|
|
62501
63366
|
const look = ctx.config.textInput;
|
|
62502
|
-
const content = layout.content === "placeholder" ? field.placeholder ?? "" : value;
|
|
63367
|
+
const content = layout.content === "placeholder" ? field.placeholder ?? "" : literalText(value);
|
|
62503
63368
|
const values = partValues(layout, content, field.textStyle, look);
|
|
62504
63369
|
const drawn = JSON.stringify({
|
|
62505
63370
|
layout,
|
|
@@ -62583,24 +63448,10 @@ function createFields(ctx, links) {
|
|
|
62583
63448
|
return;
|
|
62584
63449
|
}
|
|
62585
63450
|
const viewport = ctx.deps.renderer.viewport;
|
|
62586
|
-
const
|
|
62587
|
-
const topLeft = viewport.toScreen({
|
|
62588
|
-
x: drawn.x,
|
|
62589
|
-
y: drawn.y
|
|
62590
|
-
});
|
|
62591
|
-
const bottomRight = viewport.toScreen({
|
|
62592
|
-
x: drawn.x + drawn.w,
|
|
62593
|
-
y: drawn.y + drawn.h
|
|
62594
|
-
});
|
|
62595
|
-
const rect = {
|
|
62596
|
-
x: topLeft.x,
|
|
62597
|
-
y: topLeft.y,
|
|
62598
|
-
w: bottomRight.x - topLeft.x,
|
|
62599
|
-
h: bottomRight.y - topLeft.y
|
|
62600
|
-
};
|
|
63451
|
+
const { rect, bottom } = screenRectOf(viewport, rootRectOf(ctx, state, field, lookup));
|
|
62601
63452
|
const keyboard = text.keyboard;
|
|
62602
63453
|
keyboard.lift = keyboard.inset <= 0 ? 0 : liftOf({
|
|
62603
|
-
fieldBottom:
|
|
63454
|
+
fieldBottom: bottom,
|
|
62604
63455
|
margin: ctx.config.textInput.keyboardMargin,
|
|
62605
63456
|
innerHeight: keyboard.innerHeight,
|
|
62606
63457
|
inset: keyboard.inset
|
|
@@ -74767,8 +75618,9 @@ const BloomBlur = /*#__PURE__*/ defineFilter("effects.bloomBlur", {
|
|
|
74767
75618
|
/**
|
|
74768
75619
|
* @file effects/set — `Bloom`: light around the bright parts of a view. The one member with a chain: its input `bright`
|
|
74769
75620
|
* is the view's light above `threshold`, cut and boxed down to ¼ (⅛ for a wide radius) in one pass and blurred there in
|
|
74770
|
-
* one more; the body adds it back by `strength`. 3 passes at any radius and resolution. A
|
|
74771
|
-
* quad
|
|
75621
|
+
* one more; the body adds it back by `strength`. 3 passes at any radius and resolution. A change of `strength` rides
|
|
75622
|
+
* the view's quad over the held chain result on WebGPU; one of `threshold` or `radius` runs the chain again and redraws
|
|
75623
|
+
* the kept picture's filter (stage 3).
|
|
74772
75624
|
*/
|
|
74773
75625
|
/** The most texels the blur's sigma may reach: past it the rings stand too far apart on the boxed-down light. */
|
|
74774
75626
|
const MAX_SIGMA = 8;
|
|
@@ -74860,9 +75712,10 @@ function bloomChain(value, context) {
|
|
|
74860
75712
|
* (over the A26's screen its passes fill 1.9 Mpx a frame at 2.625). List it in a feature's `filters`, as a game's own
|
|
74861
75713
|
* filter. It reads a second texture drawn by a chain of two stages, the light cut and boxed down to ¼ (⅛ when the
|
|
74862
75714
|
* radius is over 8 texels at ¼: radius 16 at the phone's 2.625, 32 at 2) and blurred there: 3 passes at any radius.
|
|
74863
|
-
* A still view is kept as a picture
|
|
74864
|
-
*
|
|
74865
|
-
*
|
|
75715
|
+
* A still view is kept as a picture. A `strength` tween leaves the chain as it was: on WebGPU the view draws on its own
|
|
75716
|
+
* quad over the held chain result, no pass of its own, and on WebGL it redraws the picture's filter, 3 passes. A
|
|
75717
|
+
* `threshold` or `radius` tween runs the chain again too, in every frame it moves. Past a sigma of 8 texels at ⅛ the
|
|
75718
|
+
* bloom stops widening.
|
|
74866
75719
|
*
|
|
74867
75720
|
* @example
|
|
74868
75721
|
* ```ts
|