@vectoriox/iox-ui 5.160.0 → 5.162.0

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.
@@ -1130,6 +1130,21 @@ export const SPEC_TIERS = {
1130
1130
  "type": "duration",
1131
1131
  "default": "220ms"
1132
1132
  },
1133
+ {
1134
+ "name": "popup-inset",
1135
+ "type": "size",
1136
+ "default": "24px"
1137
+ },
1138
+ {
1139
+ "name": "popup-dur-in",
1140
+ "type": "duration",
1141
+ "default": "450ms"
1142
+ },
1143
+ {
1144
+ "name": "popup-dur-out",
1145
+ "type": "duration",
1146
+ "default": "250ms"
1147
+ },
1133
1148
  {
1134
1149
  "name": "dialog-edge",
1135
1150
  "type": "color",
@@ -1809,7 +1824,9 @@ export const SPEC_AXES = {
1809
1824
  "sheet-dur-in": "0ms",
1810
1825
  "sheet-dur-out": "0ms",
1811
1826
  "toast-dur-in": "0ms",
1812
- "toast-dur-out": "0ms"
1827
+ "toast-dur-out": "0ms",
1828
+ "popup-dur-in": "0ms",
1829
+ "popup-dur-out": "0ms"
1813
1830
  },
1814
1831
  "snappy": {
1815
1832
  "label": "Snappy",
@@ -1833,6 +1850,8 @@ export const SPEC_AXES = {
1833
1850
  "sheet-dur-out": "240ms",
1834
1851
  "toast-dur-in": "320ms",
1835
1852
  "toast-dur-out": "180ms",
1853
+ "popup-dur-in": "360ms",
1854
+ "popup-dur-out": "200ms",
1836
1855
  "ease-pop": "cubic-bezier(0.34, 1.56, 0.64, 1)"
1837
1856
  },
1838
1857
  "standard": {
@@ -1857,6 +1876,8 @@ export const SPEC_AXES = {
1857
1876
  "sheet-dur-out": "280ms",
1858
1877
  "toast-dur-in": "400ms",
1859
1878
  "toast-dur-out": "220ms",
1879
+ "popup-dur-in": "450ms",
1880
+ "popup-dur-out": "250ms",
1860
1881
  "ease-pop": "cubic-bezier(0.34, 1.56, 0.64, 1)"
1861
1882
  },
1862
1883
  "calm": {
@@ -1881,6 +1902,8 @@ export const SPEC_AXES = {
1881
1902
  "sheet-dur-out": "340ms",
1882
1903
  "toast-dur-in": "480ms",
1883
1904
  "toast-dur-out": "280ms",
1905
+ "popup-dur-in": "560ms",
1906
+ "popup-dur-out": "310ms",
1884
1907
  "ease-pop": "cubic-bezier(0.34, 1.56, 0.64, 1)"
1885
1908
  },
1886
1909
  "lively": {
@@ -1905,6 +1928,8 @@ export const SPEC_AXES = {
1905
1928
  "sheet-dur-out": "280ms",
1906
1929
  "toast-dur-in": "400ms",
1907
1930
  "toast-dur-out": "220ms",
1931
+ "popup-dur-in": "450ms",
1932
+ "popup-dur-out": "250ms",
1908
1933
  "ease-pop": "cubic-bezier(0.34, 1.56, 0.64, 1)"
1909
1934
  }
1910
1935
  },
@@ -7720,6 +7745,27 @@ export const SPEC_FLAVOR_PACKS = [
7720
7745
  "group": "components",
7721
7746
  "value": "220ms"
7722
7747
  },
7748
+ {
7749
+ "name": "popup-inset",
7750
+ "tier": "component",
7751
+ "type": "size",
7752
+ "group": "components",
7753
+ "value": "24px"
7754
+ },
7755
+ {
7756
+ "name": "popup-dur-in",
7757
+ "tier": "component",
7758
+ "type": "duration",
7759
+ "group": "components",
7760
+ "value": "450ms"
7761
+ },
7762
+ {
7763
+ "name": "popup-dur-out",
7764
+ "tier": "component",
7765
+ "type": "duration",
7766
+ "group": "components",
7767
+ "value": "250ms"
7768
+ },
7723
7769
  {
7724
7770
  "name": "dialog-edge",
7725
7771
  "tier": "component",
@@ -10154,6 +10200,27 @@ export const SPEC_FLAVOR_PACKS = [
10154
10200
  "group": "components",
10155
10201
  "value": "280ms"
10156
10202
  },
10203
+ {
10204
+ "name": "popup-inset",
10205
+ "tier": "component",
10206
+ "type": "size",
10207
+ "group": "components",
10208
+ "value": "24px"
10209
+ },
10210
+ {
10211
+ "name": "popup-dur-in",
10212
+ "tier": "component",
10213
+ "type": "duration",
10214
+ "group": "components",
10215
+ "value": "560ms"
10216
+ },
10217
+ {
10218
+ "name": "popup-dur-out",
10219
+ "tier": "component",
10220
+ "type": "duration",
10221
+ "group": "components",
10222
+ "value": "310ms"
10223
+ },
10157
10224
  {
10158
10225
  "name": "dialog-edge",
10159
10226
  "tier": "component",
@@ -12594,6 +12661,27 @@ export const SPEC_FLAVOR_PACKS = [
12594
12661
  "group": "components",
12595
12662
  "value": "220ms"
12596
12663
  },
12664
+ {
12665
+ "name": "popup-inset",
12666
+ "tier": "component",
12667
+ "type": "size",
12668
+ "group": "components",
12669
+ "value": "24px"
12670
+ },
12671
+ {
12672
+ "name": "popup-dur-in",
12673
+ "tier": "component",
12674
+ "type": "duration",
12675
+ "group": "components",
12676
+ "value": "450ms"
12677
+ },
12678
+ {
12679
+ "name": "popup-dur-out",
12680
+ "tier": "component",
12681
+ "type": "duration",
12682
+ "group": "components",
12683
+ "value": "250ms"
12684
+ },
12597
12685
  {
12598
12686
  "name": "dialog-edge",
12599
12687
  "tier": "component",
@@ -15058,6 +15146,27 @@ export const SPEC_FLAVOR_PACKS = [
15058
15146
  "group": "components",
15059
15147
  "value": "220ms"
15060
15148
  },
15149
+ {
15150
+ "name": "popup-inset",
15151
+ "tier": "component",
15152
+ "type": "size",
15153
+ "group": "components",
15154
+ "value": "24px"
15155
+ },
15156
+ {
15157
+ "name": "popup-dur-in",
15158
+ "tier": "component",
15159
+ "type": "duration",
15160
+ "group": "components",
15161
+ "value": "450ms"
15162
+ },
15163
+ {
15164
+ "name": "popup-dur-out",
15165
+ "tier": "component",
15166
+ "type": "duration",
15167
+ "group": "components",
15168
+ "value": "250ms"
15169
+ },
15061
15170
  {
15062
15171
  "name": "dialog-edge",
15063
15172
  "tier": "component",
@@ -17503,6 +17612,27 @@ export const SPEC_FLAVOR_PACKS = [
17503
17612
  "group": "components",
17504
17613
  "value": "220ms"
17505
17614
  },
17615
+ {
17616
+ "name": "popup-inset",
17617
+ "tier": "component",
17618
+ "type": "size",
17619
+ "group": "components",
17620
+ "value": "24px"
17621
+ },
17622
+ {
17623
+ "name": "popup-dur-in",
17624
+ "tier": "component",
17625
+ "type": "duration",
17626
+ "group": "components",
17627
+ "value": "450ms"
17628
+ },
17629
+ {
17630
+ "name": "popup-dur-out",
17631
+ "tier": "component",
17632
+ "type": "duration",
17633
+ "group": "components",
17634
+ "value": "250ms"
17635
+ },
17506
17636
  {
17507
17637
  "name": "dialog-edge",
17508
17638
  "tier": "component",
@@ -19944,6 +20074,27 @@ export const SPEC_FLAVOR_PACKS = [
19944
20074
  "group": "components",
19945
20075
  "value": "180ms"
19946
20076
  },
20077
+ {
20078
+ "name": "popup-inset",
20079
+ "tier": "component",
20080
+ "type": "size",
20081
+ "group": "components",
20082
+ "value": "24px"
20083
+ },
20084
+ {
20085
+ "name": "popup-dur-in",
20086
+ "tier": "component",
20087
+ "type": "duration",
20088
+ "group": "components",
20089
+ "value": "360ms"
20090
+ },
20091
+ {
20092
+ "name": "popup-dur-out",
20093
+ "tier": "component",
20094
+ "type": "duration",
20095
+ "group": "components",
20096
+ "value": "200ms"
20097
+ },
19947
20098
  {
19948
20099
  "name": "dialog-edge",
19949
20100
  "tier": "component",
@@ -4,6 +4,7 @@ import { VideoMode, VideoSource } from '@vectoriox/iox-ui/media-core';
4
4
 
5
5
  import { composeListFrame, LayoutListBinding } from './compose-layout';
6
6
  import { composePresetForm } from './compose-site';
7
+ import { freeNodeId } from './free-render-check';
7
8
  import { freeStyleToSlots } from './free-slots';
8
9
  import { FREE_BUILDER_TYPE, FreeLayer, FreeNode, FreeNodeType, FreePage, FreeStyle, FreeTrigger } from './free-wire';
9
10
  import { LAYOUT_BEAT_DELAY, LAYOUT_DEPTH_ON_PHONE, LAYOUT_EASING, LAYOUT_PACE, LAYOUT_RISE, LayoutEase, LayoutPace, LayoutRole, LayoutSite } from './layout-language';
@@ -57,7 +58,7 @@ interface Ctx {
57
58
  ids: Set<string>;
58
59
  }
59
60
 
60
- const idOf = (ctx: Ctx, id: string) => `${ctx.o.owner}-${id}`;
61
+ const idOf = (ctx: Ctx, id: string) => freeNodeId(ctx.o.owner, id);
61
62
 
62
63
  /** A free page's sections, one stamped root each (a ready-made place stamped with its pattern, the rest as model-laid). */
63
64
  export function composeFreePage(page: FreePage, options: ComposeFreeOptions): SerializedNode[] {
@@ -5,7 +5,7 @@ import {
5
5
  } from '@vectoriox/iox-ui/composite-core';
6
6
 
7
7
  import { ColorScheme, DesignChoices, LIST_MIX_PROP, LinkType, scrubOfChoices, setColorScheme, SPEC_AXES } from '@vectoriox/iox-ui/design-core';
8
- import { TextRevealBy } from '@vectoriox/iox-ui/scene-core';
8
+ import { SCENE_TRACK_EASE, SceneEase, SceneProp, TextRevealBy } from '@vectoriox/iox-ui/scene-core';
9
9
  import { FORM_AFTER_SEND_TRAIT, FormAfterSend, FormPresetId } from '@vectoriox/iox-ui/forms-core';
10
10
  import { composeNavHeader, composePresetForm } from './compose-site';
11
11
  import { drawnHeaderMix, headerMixOfNavKind } from './header-mix';
@@ -50,7 +50,8 @@ export enum LayoutGapCode {
50
50
  Blur = 'blur',
51
51
  /** M8-G3: `scaleIn` / `pop` start at the product's 0.8, not 0.95 / 0.9, and `pop` has no overshoot. */
52
52
  ScaleIn = 'scale-in',
53
- /** M8-G4: a held layer's keys ease one way (smoothstep), whatever the layout's ease. */
53
+ /** M8-G4: a held layer's keys run straight (travel) or smooth (a fade) — an `out` or `drawer` ease is drawn as its
54
+ * property's (award plan "Reddottours", RT-D1: travel linear, fades smooth; `linear` / `inOut` are drawn as asked). */
54
55
  TrackEase = 'track-ease',
55
56
  /** M8-G5: a depth glides at the product's one speed (no per-look scale), and a picture's own drift inside its frame
56
57
  * is a fixed over-scale. */
@@ -520,7 +521,10 @@ function depthInteraction(nodeId: string, depth: string): unknown {
520
521
 
521
522
  const TRACK_REST: Readonly<Record<string, number>> = { x: 0, y: 0, scale: 1, rotate: 0, opacity: 1, clip: 100, words: 100 };
522
523
 
523
- interface SceneTrackOut { prop: string; keys: Array<[number, number]>; from?: string }
524
+ interface SceneTrackOut { prop: string; keys: Array<[number, number]>; from?: string; ease?: SceneEase }
525
+
526
+ /** The layout's eases the product's tracks can run (RT-D1); anything else is drawn as the property's own. */
527
+ const TRACK_EASE: Readonly<Partial<Record<LayoutEase, SceneEase>>> = { [LayoutEase.Linear]: SceneEase.Linear, [LayoutEase.InOut]: SceneEase.Smooth };
524
528
 
525
529
  /** A layout track as a scene-core track: lengths move from the layer's own box to the stage's (cqw / cqh). */
526
530
  function sceneTrackOf(t: LayoutTrack, l: LayoutLayer, rows: number, ctx: Ctx, path: string): SceneTrackOut | null {
@@ -529,13 +533,16 @@ function sceneTrackOf(t: LayoutTrack, l: LayoutLayer, rows: number, ctx: Ctx, pa
529
533
  gap(ctx, LayoutGapCode.Blur, path, 'a blur track is dropped');
530
534
  return null;
531
535
  }
532
- if (t.ease && t.ease !== LayoutEase.InOut) gap(ctx, LayoutGapCode.TrackEase, path, `${t.prop} eases (smoothstep), not ${t.ease}`);
536
+ const own = SCENE_TRACK_EASE[t.prop as SceneProp];
537
+ const ease = t.ease ? TRACK_EASE[t.ease as LayoutEase] : undefined;
538
+ if (t.ease && !ease) gap(ctx, LayoutGapCode.TrackEase, path, `${t.prop} runs ${own === SceneEase.Linear ? 'straight' : 'smooth (smoothstep)'}, not ${t.ease}`);
533
539
  let scale = 1;
534
540
  if (t.prop === LayoutTrackProp.X) scale = (l.col[1] - l.col[0]) / GRID_COLUMNS;
535
541
  if (t.prop === LayoutTrackProp.Y) scale = (l.row[1] - l.row[0]) / rows;
536
542
  const round = (v: number) => Math.round(v * scale * 100) / 100;
537
543
  const track: SceneTrackOut = { prop: t.prop, keys: [[a, round(Number(t.from))], [b, round(Number(t.to))]] };
538
544
  if (t.prop === LayoutTrackProp.Clip) track.from = LayoutSide.Bottom;
545
+ if (ease && ease !== own) track.ease = ease;
539
546
  return track;
540
547
  }
541
548
 
@@ -1646,7 +1653,6 @@ function composeSection(s: LayoutSection, si: number, prevGround: string | null,
1646
1653
  phone(wide, { width: FULL, ...phoneStack(si === 0) });
1647
1654
  wide.sceneTracks = [{ prop: 'x', keys: [[0, 0], [1, -(track - 1) * 100]] }];
1648
1655
  wide.scenePhoneTracks = [{ prop: 'x', keys: [[0, 0]] }];
1649
- gap(ctx, LayoutGapCode.TrackEase, `sections[${si}]`, 'the sideways travel eases (smoothstep), not linear');
1650
1656
  wide.children = layers;
1651
1657
  stage.children = [wide];
1652
1658
  }
@@ -0,0 +1,88 @@
1
+ import { FreeNode, FreeNodeType, FreePage, FreeTrigger, FreeWalked, walkFree } from './free-wire';
2
+ import { layerMetricsOf, LAYOUT_VIEWPORTS, LayoutViewport, MeasuredLayer, MeasuredLayout } from './layout-render-check';
3
+
4
+ /**
5
+ * THE RENDER CHECK OF A FREE PAGE (award plan §11.4, FS3, R-H5) — the browser half, beside `measureLayout`. A free page
6
+ * (or ONE free signature section) is stamped by `composeFreePage` / `composeFreeSection` and drawn as the build will draw
7
+ * it; this reads its rendered word boxes into the SAME `MeasuredLayout` the composed page's check posts, with each layer's
8
+ * path the free tree's own (`sections[0].children[1]`), so `judgeLayoutRender` says an issue where the free judge would,
9
+ * and the free repair and fall back read it as they read the static judge's.
10
+ */
11
+
12
+ /** Where a free answer stands on a stamped page — ONE rule for the stamp and the check. */
13
+ export interface FreeStamped {
14
+ /** The page key (a free page), or `<page key>-<its place>` (a signature section: its root IS this id). */
15
+ owner: string;
16
+ /** A signature section: the answer's one Section is stamped under `owner` itself. */
17
+ section?: boolean;
18
+ }
19
+
20
+ /** The id a free node is stamped under: `<owner>-<the answer's id>` (unique on the site). */
21
+ export const freeNodeId = (owner: string, id: string): string => `${owner}-${id}`;
22
+
23
+ /** The id a free node is stamped under, a signature section's root being its owner (`composeFreeSection`). */
24
+ export function freeStampedId(at: FreeStamped, node: Pick<FreeNode, 'id' | 'type'>, depth: number): string {
25
+ return at.section && depth === 0 && node.type === FreeNodeType.Section ? at.owner : freeNodeId(at.owner, node.id);
26
+ }
27
+
28
+ /** Where a signature section of page `pageKey` at plan place `at` is stamped (`composeSite`'s section id). */
29
+ export const freeSectionOwner = (pageKey: string, at: number): FreeStamped => ({ owner: `${pageKey}-${at}`, section: true });
30
+
31
+ /** What the check calls each free node (a word kind where it carries words — the layout check's names). */
32
+ const FREE_KIND: Readonly<Record<FreeNodeType, string>> = {
33
+ [FreeNodeType.Section]: 'section',
34
+ [FreeNodeType.Container]: 'container',
35
+ [FreeNodeType.Heading]: 'heading',
36
+ [FreeNodeType.Text]: 'text',
37
+ [FreeNodeType.Button]: 'button',
38
+ [FreeNodeType.Image]: 'photo',
39
+ [FreeNodeType.Video]: 'video',
40
+ [FreeNodeType.Slot]: 'slot',
41
+ };
42
+
43
+ const PARALLAX = 'parallax';
44
+ const DEPTHS: ReadonlyArray<'back' | 'front'> = ['back', 'front'];
45
+
46
+ /** The depth a node glides at: its own parallax, else the nearest moving holder's (its words move with it). */
47
+ function depthOf(w: FreeWalked): 'back' | 'front' | undefined {
48
+ for (const n of [w.node, ...[...w.up].reverse()]) {
49
+ const m = n.move;
50
+ if (m?.trigger !== FreeTrigger.Scroll || m.action !== PARALLAX) continue;
51
+ const d = m.params?.['depth'] as 'back' | 'front' | undefined;
52
+ return d && DEPTHS.includes(d) ? d : undefined;
53
+ }
54
+ return undefined;
55
+ }
56
+
57
+ /**
58
+ * In the browser: a stamped free page's (or signature section's) nodes as rendered under `root`, in the root's own
59
+ * coordinates — every node with a box, its words where it carries any. A place the fall back gave the plan back
60
+ * (`readyMade`) is measured as a section and nothing in it (its nodes are the pattern's, judged where the pattern was).
61
+ * Run with the page at rest (scrolled to its top, entrances settled).
62
+ */
63
+ export function measureFree(root: Element, page: Pick<FreePage, 'sections'>, at: FreeStamped, viewport: `${LayoutViewport}`): MeasuredLayout {
64
+ const metrics = layerMetricsOf(root);
65
+ const find = (id: string) => root.querySelector(`.iox-node-${id}`);
66
+ const sections = page.sections.map(s => {
67
+ const el = find(freeStampedId(at, s, 0));
68
+ const r = el ? metrics.box(el) : { l: 0, t: 0, r: 0, b: 0 };
69
+ return { top: r.t, height: r.b - r.t, held: false };
70
+ });
71
+ const layers: MeasuredLayer[] = [];
72
+ for (const w of walkFree(page.sections.filter(s => !s.readyMade))) {
73
+ // A walk over the model's sections only: its section index is the answer's place among them, put back here.
74
+ const place = page.sections.indexOf(w.up[0] ?? w.node);
75
+ const path = w.path.replace(/^sections\[\d+\]/, `sections[${place}]`);
76
+ const el = find(freeStampedId(at, w.node, w.up.length));
77
+ if (!el) continue;
78
+ const kind = FREE_KIND[w.node.type];
79
+ const depth = depthOf(w);
80
+ layers.push({
81
+ // A signature section never opens its page (`signatureAt` skips the opening): the first screen is not its to hold.
82
+ ...metrics.layer(el, kind), path, section: place, role: at.section ? '' : w.node.role ?? '', bleed: false, scrim: false, track: false,
83
+ ...(w.node.type === FreeNodeType.Image && w.node.src ? { photo: w.node.src } : {}),
84
+ ...(depth ? { depth } : {}),
85
+ });
86
+ }
87
+ return { viewport, width: metrics.width, height: LAYOUT_VIEWPORTS[viewport].height, scrollWidth: metrics.scrollWidth, sections, layers };
88
+ }
@@ -68,19 +68,58 @@ const textOf = (el: Element) => String(el.textContent ?? '').trim();
68
68
  /** A layer node's class (`iox-node-<id>`) — what both renderers put on every node. */
69
69
  export const layoutNodeClass = (prefix: string, i: number, j?: number) => `iox-node-${prefix}-s${i}${j === undefined ? '' : `-l${j}`}`;
70
70
 
71
+ /** What the render check reads of one rendered node — ONE reader for the composed page and the free page. */
72
+ export interface LayerMetrics {
73
+ /** The root's width, and its own scroll width (wider: the page scrolls sideways). */
74
+ width: number;
75
+ scrollWidth: number;
76
+ /** An element's box in the root's coordinates. */
77
+ box(el: Element): LayoutRect;
78
+ /** A node's box, its words (a text's line boxes, a button's box — when it carries words of a word `kind`), z and type. */
79
+ layer(el: Element, kind: string): Pick<MeasuredLayer, 'kind' | 'z' | 'box' | 'words' | 'size' | 'weight' | 'color'>;
80
+ }
81
+
82
+ /** In the browser: the reader of the nodes rendered under `root`, in the root's own coordinates. */
83
+ export function layerMetricsOf(root: Element): LayerMetrics {
84
+ const origin = root.getBoundingClientRect();
85
+ const rel = (r: DOMRect | { left: number; top: number; right: number; bottom: number }): LayoutRect => ({ l: r.left - origin.left, t: r.top - origin.top, r: r.right - origin.left, b: r.bottom - origin.top });
86
+ const doc = root.ownerDocument;
87
+ const view = doc.defaultView;
88
+ return {
89
+ width: root.clientWidth || origin.width,
90
+ scrollWidth: root.scrollWidth || origin.width,
91
+ box: el => rel(el.getBoundingClientRect()),
92
+ layer: (el, kind) => {
93
+ const style = view?.getComputedStyle(el);
94
+ const box = rel(el.getBoundingClientRect());
95
+ let words: LayoutRect | null = null;
96
+ if (WORD_KINDS.has(kind) && textOf(el)) {
97
+ if (kind === 'button') words = box;
98
+ else {
99
+ const range = doc.createRange();
100
+ range.selectNodeContents(el);
101
+ const tight = typeof range.getBoundingClientRect === 'function' ? range.getBoundingClientRect() : null;
102
+ words = tight && tight.width > 0 ? rel(tight) : box;
103
+ }
104
+ }
105
+ return {
106
+ kind, z: Number(style?.zIndex) || 0, box, words,
107
+ size: parseFloat(style?.fontSize ?? '') || 16, weight: Number(style?.fontWeight) || 400, color: style?.color ?? '',
108
+ };
109
+ },
110
+ };
111
+ }
112
+
71
113
  /**
72
114
  * In the browser: the composed page's layers as rendered under `root` (the offscreen render, `prefix` its node id prefix),
73
115
  * in the root's own coordinates. Run with the page at rest (scrolled to its top, entrances settled).
74
116
  */
75
117
  export function measureLayout(root: Element, page: Pick<LayoutPage, 'sections'>, prefix: string, viewport: `${LayoutViewport}`): MeasuredLayout {
76
- const origin = root.getBoundingClientRect();
77
- const rel = (r: DOMRect | { left: number; top: number; right: number; bottom: number }): LayoutRect => ({ l: r.left - origin.left, t: r.top - origin.top, r: r.right - origin.left, b: r.bottom - origin.top });
78
- const doc = root.ownerDocument;
79
- const view = doc.defaultView;
118
+ const metrics = layerMetricsOf(root);
80
119
  const find = (cls: string) => root.querySelector(`.${cls}`);
81
120
  const sections = page.sections.map((s, i) => {
82
121
  const el = find(layoutNodeClass(prefix, i));
83
- const r = el ? rel(el.getBoundingClientRect()) : { l: 0, t: 0, r: 0, b: 0 };
122
+ const r = el ? metrics.box(el) : { l: 0, t: 0, r: 0, b: 0 };
84
123
  return { top: r.t, height: r.b - r.t, held: !!s.pin };
85
124
  });
86
125
  const layers: MeasuredLayer[] = [];
@@ -90,28 +129,16 @@ export function measureLayout(root: Element, page: Pick<LayoutPage, 'sections'>,
90
129
  const depth = layoutGlideDepth(s, l);
91
130
  const spans = s.pin && viewport === LayoutViewport.Desktop ? layerShownSpans(l) : null;
92
131
  const shown = spans && !(spans.length === 1 && spans[0][0] === 0 && spans[0][1] === 1) ? spans : null;
93
- const style = view?.getComputedStyle(el);
94
- const box = rel(el.getBoundingClientRect());
95
- let words: LayoutRect | null = null;
96
- if (WORD_KINDS.has(l.kind) && textOf(el)) {
97
- if (l.kind === 'button') words = box;
98
- else {
99
- const range = doc.createRange();
100
- range.selectNodeContents(el);
101
- const tight = typeof range.getBoundingClientRect === 'function' ? range.getBoundingClientRect() : null;
102
- words = tight && tight.width > 0 ? rel(tight) : box;
103
- }
104
- }
105
132
  layers.push({
106
- path: `sections[${i}].layers[${j}]`, section: i, kind: l.kind, role: l.role ?? '', bleed: !!l.bleed && l.bleed !== 'none', scrim: !!l.scrim,
107
- track: (s.track ?? 0) > 1, z: Number(style?.zIndex) || 0, box, words,
108
- size: parseFloat(style?.fontSize ?? '') || 16, weight: Number(style?.fontWeight) || 400, color: style?.color ?? '',
133
+ ...metrics.layer(el, l.kind),
134
+ path: `sections[${i}].layers[${j}]`, section: i, role: l.role ?? '', bleed: !!l.bleed && l.bleed !== 'none', scrim: !!l.scrim,
135
+ track: (s.track ?? 0) > 1,
109
136
  ...(l.kind === 'photo' && l.photo?.id ? { photo: l.photo.id } : {}),
110
137
  ...(depth ? { depth } : {}),
111
138
  ...(shown ? { shown } : {}),
112
139
  });
113
140
  }));
114
- return { viewport, width: root.clientWidth || origin.width, height: LAYOUT_VIEWPORTS[viewport].height, scrollWidth: root.scrollWidth || origin.width, sections, layers };
141
+ return { viewport, width: metrics.width, height: LAYOUT_VIEWPORTS[viewport].height, scrollWidth: metrics.scrollWidth, sections, layers };
115
142
  }
116
143
 
117
144
  const area = (r: LayoutRect) => Math.max(0, r.r - r.l) * Math.max(0, r.b - r.t);
@@ -65,6 +65,7 @@ export * from './check-free';
65
65
  export * from './free-fallback';
66
66
  export * from './free-slots';
67
67
  export * from './compose-free';
68
+ export * from './free-render-check';
68
69
  export * from './prompt-limits';
69
70
  export * from './layout-photos';
70
71
  export * from './photo-inventory';