@vectoriox/iox-ui 5.161.0 → 5.163.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.
Files changed (43) hide show
  1. package/actions-core/index.d.ts +171 -3
  2. package/assist-core/index.d.ts +3 -2
  3. package/composite-core/index.d.ts +185 -2
  4. package/design-core/index.d.ts +130 -0
  5. package/fesm2022/vectoriox-iox-ui-actions-core.mjs +243 -2
  6. package/fesm2022/vectoriox-iox-ui-actions-core.mjs.map +1 -1
  7. package/fesm2022/vectoriox-iox-ui-assist-core.mjs +6 -5
  8. package/fesm2022/vectoriox-iox-ui-assist-core.mjs.map +1 -1
  9. package/fesm2022/vectoriox-iox-ui-composite-core.mjs +404 -163
  10. package/fesm2022/vectoriox-iox-ui-composite-core.mjs.map +1 -1
  11. package/fesm2022/vectoriox-iox-ui-design-core.mjs +152 -1
  12. package/fesm2022/vectoriox-iox-ui-design-core.mjs.map +1 -1
  13. package/fesm2022/vectoriox-iox-ui-generation-core.mjs +302 -10
  14. package/fesm2022/vectoriox-iox-ui-generation-core.mjs.map +1 -1
  15. package/fesm2022/vectoriox-iox-ui-harness-core.mjs +140 -1
  16. package/fesm2022/vectoriox-iox-ui-harness-core.mjs.map +1 -1
  17. package/fesm2022/vectoriox-iox-ui-scene-core.mjs +306 -48
  18. package/fesm2022/vectoriox-iox-ui-scene-core.mjs.map +1 -1
  19. package/fesm2022/vectoriox-iox-ui.mjs +383 -10
  20. package/fesm2022/vectoriox-iox-ui.mjs.map +1 -1
  21. package/generation-core/index.d.ts +243 -6
  22. package/harness-core/index.d.ts +132 -2
  23. package/index.d.ts +105 -3
  24. package/package.json +1 -1
  25. package/scene-core/index.d.ts +130 -10
  26. package/src/actions-core/popup-arrival.ts +328 -0
  27. package/src/actions-core/public-api.ts +1 -0
  28. package/src/assist-core/media-generate.ts +6 -5
  29. package/src/composite-core/popup.ts +285 -0
  30. package/src/composite-core/public-api.ts +1 -0
  31. package/src/design-core/flavor-spec.generated.ts +152 -1
  32. package/src/generation-core/ai-run.ts +65 -2
  33. package/src/generation-core/compose-layout.ts +11 -5
  34. package/src/generation-core/pictures.ts +4 -3
  35. package/src/generation-core/site-spec.generated.ts +235 -0
  36. package/src/harness-core/business-types.ts +2 -0
  37. package/src/harness-core/harness-spec.generated.ts +83 -0
  38. package/src/harness-core/popup-stance.ts +111 -0
  39. package/src/harness-core/public-api.ts +1 -0
  40. package/src/scene-core/scene-edit.ts +12 -8
  41. package/src/scene-core/scene.ts +131 -21
  42. package/src/scene-core/scroll-driver.ts +209 -23
  43. package/styles/iox-design.css +121 -2
@@ -38,16 +38,54 @@ declare enum SceneRevealFrom {
38
38
  Start = "start",
39
39
  End = "end"
40
40
  }
41
+ /**
42
+ * How a track runs between two keys (award plan "Reddottours", RT-D1). A scrubbed TRAVEL runs straight, so a layer moves
43
+ * exactly as far as the scroll moves it (theirs is `ease: none`; smoothstep slowed every walk at both ends); a FADE keeps
44
+ * smoothstep, which is what a fade looks right with. A track says its own only when it differs from its property's.
45
+ */
46
+ declare enum SceneEase {
47
+ Linear = "linear",
48
+ Smooth = "smooth"
49
+ }
50
+ /** Each property's ease when its track says none: travel straight, fades and colours smooth. */
51
+ declare const SCENE_TRACK_EASE: Readonly<Record<SceneProp, SceneEase>>;
52
+ /**
53
+ * WHAT a track's 0–1 is measured over (award plan "Reddottours", AW9). A track says its own only when it is not the hold.
54
+ * - Hold: the root's held travel — the stage pinned while the page scrolls the root's extra height (every Scene so far).
55
+ * - Exit: the root's LEAVING, after the hold — from the stage's release until it has gone by its own height (their S1:
56
+ * the held film sinks at 0.4× as the next band rises).
57
+ * - Cross inline / Cross block: the layer's OWN crossing of the stage — 0 as its leading edge enters the stage's far side,
58
+ * 1 as its trailing edge leaves the near side — measured where it stands without its own move, so inside a walking row
59
+ * each picture drifts as IT crosses the screen (their S3, GSAP's `containerAnimation`). Inline follows the reading
60
+ * direction (a walk enters from the end); block enters from below.
61
+ */
62
+ declare enum SceneRange {
63
+ Hold = "hold",
64
+ Exit = "exit",
65
+ CrossInline = "cross-inline",
66
+ CrossBlock = "cross-block"
67
+ }
68
+ /** Where a layer stands on each range at one moment. Hold is the Scene's progress; the others are 0 until measured. */
69
+ interface SceneProgress {
70
+ hold: number;
71
+ exit?: number;
72
+ crossInline?: number;
73
+ crossBlock?: number;
74
+ }
41
75
  /** What a reveal opens from when nobody has said: the page's own direction of travel, upward as it scrolls. */
42
76
  declare const SCENE_REVEAL_DEFAULT = SceneRevealFrom.Bottom;
43
77
  /** One key: at progress `[0]` (0–1) the property holds `[1]`: a number, or a colour for Ground and Ink. */
44
78
  type SceneKey = readonly [number, number | string];
45
79
  interface SceneTrack {
46
80
  prop: SceneProp;
47
- /** Ascending by progress. Between two keys the value eases (smoothstep); outside them it holds the nearest. */
81
+ /** Ascending by progress. Between two keys the value runs by `ease`; outside them it holds the nearest. */
48
82
  keys: ReadonlyArray<SceneKey>;
49
83
  /** A Clip track's direction. */
50
84
  from?: SceneRevealFrom;
85
+ /** How it runs between keys; absent = its property's (`SCENE_TRACK_EASE`). */
86
+ ease?: SceneEase;
87
+ /** What its progress is measured over; absent = the hold. */
88
+ range?: SceneRange;
51
89
  }
52
90
  /** What a node carries (both a builder node and a saved one). */
53
91
  interface SceneNodeSource {
@@ -85,6 +123,12 @@ declare const SLIDER_SCROLL_STEP_SCREENS = 0.55;
85
123
  declare function heldProgress(p: number, n: number): number;
86
124
  /** At or under this stage width a layer plays its phone tracks. The `mobile` breakpoint's width. */
87
125
  declare const SCENE_PHONE_MAX_WIDTH = 767;
126
+ /** How a track runs between its keys. */
127
+ declare const trackEase: (track: Pick<SceneTrack, "prop" | "ease">) => SceneEase;
128
+ /** What a track's progress is measured over. */
129
+ declare const trackRange: (track: Pick<SceneTrack, "range">) => SceneRange;
130
+ /** A track the hold drives (every authored track): what the timeline edits. */
131
+ declare const isHoldTrack: (track: Pick<SceneTrack, "range">) => boolean;
88
132
  /**
89
133
  * The tracks a saved value really holds: unknown properties, bad keys and colours that are not colours are dropped,
90
134
  * keys sorted by progress, a track left with no key dropped. Never throws on what a page document holds.
@@ -95,13 +139,21 @@ declare function normalizeTracks(tracks: unknown): SceneTrack[];
95
139
  * clipReveal action. `clip-path` has no logical sides, so Start and End take the direction from `inlineSign`.
96
140
  */
97
141
  declare function revealClipPath(showing: number, from?: SceneRevealFrom, inlineSign?: 1 | -1): string;
98
- /** A numeric track's value at progress `p`. */
142
+ /** A numeric track's value at progress `p` (eased smoothstep unless `ease` says otherwise — `trackValueAt` reads the track's). */
99
143
  declare function valueAt(keys: ReadonlyArray<SceneKey>, p: number, ease?: (t: number) => number): number;
100
144
  /**
101
145
  * A colour track's value at progress `p`. Mixed by the browser, never computed here, so a design token stays a live
102
146
  * reference (a re-theme reaches a Scene, as it reaches every saved page) and the path is perceptual.
103
147
  */
104
- declare function colourAt(keys: ReadonlyArray<SceneKey>, p: number): string;
148
+ declare function colourAt(keys: ReadonlyArray<SceneKey>, p: number, ease?: (t: number) => number): string;
149
+ /** A numeric track's value at progress `p`, run by its own ease. */
150
+ declare function trackValueAt(track: SceneTrack, p: number): number;
151
+ /** A colour track's value at progress `p`, run by its own ease. */
152
+ declare function trackColourAt(track: SceneTrack, p: number): string;
153
+ /** Where a track stands: the progress of its own range. A bare number is the hold (and 0 on every other range). */
154
+ declare function trackProgress(track: Pick<SceneTrack, 'range'>, p: number | SceneProgress): number;
155
+ /** True when a layer has a track measured over its own crossing: the driver measures where it stands. */
156
+ declare function crossesStage(tracks: ReadonlyArray<SceneTrack>): boolean;
105
157
  interface SceneFrameOptions {
106
158
  /** -1 when the stage reads right-to-left: the inline axis mirrors. */
107
159
  inlineSign?: 1 | -1;
@@ -110,16 +162,16 @@ interface SceneFrameOptions {
110
162
  * A layer's frame at progress `p`. Lengths are container-query units, so one frame is right at any width, under any
111
163
  * canvas zoom, on the server and with no measuring: the stage is the size container (`iox-design.css`).
112
164
  */
113
- declare function sceneFrame(tracks: ReadonlyArray<SceneTrack>, p: number, options?: SceneFrameOptions): SceneFrame;
165
+ declare function sceneFrame(tracks: ReadonlyArray<SceneTrack>, p: number | SceneProgress, options?: SceneFrameOptions): SceneFrame;
114
166
  /** How far an unlit word still shows: readable as a shape, plainly not yet said. */
115
167
  declare const SCENE_WORD_DIM = 0.16;
116
168
  /** How many of a layer's words are lit at `p`, in %; null when it has no such track. */
117
- declare function sceneWordsLit(tracks: ReadonlyArray<SceneTrack>, p: number): number | null;
169
+ declare function sceneWordsLit(tracks: ReadonlyArray<SceneTrack>, p: number | SceneProgress): number | null;
118
170
  /**
119
171
  * How far a layer's pictures have played at `p`, in %; null when it has no such track. A film runs straight between its
120
- * keys, where everything else eases: eased over a 20-screen Scene it would crawl for its first screens and rush the middle.
172
+ * keys (its property's ease): eased over a 20-screen Scene it would crawl for its first screens and rush the middle.
121
173
  */
122
- declare function scenePlayed(tracks: ReadonlyArray<SceneTrack>, p: number): number | null;
174
+ declare function scenePlayed(tracks: ReadonlyArray<SceneTrack>, p: number | SceneProgress): number | null;
123
175
  /** Word `index` of `count`, with `lit` % lit: words light one after the other, each easing in as the last finishes. */
124
176
  declare function sceneWordOpacity(index: number, count: number, lit: number): number;
125
177
  /** A frame as kebab-case style declarations, for a string renderer. */
@@ -424,7 +476,11 @@ declare function lightMotionWanted(host?: LightHost | null | undefined): boolean
424
476
  * canvas's zoom the same rectangle divides by the same zoom, and the answer is the same at any scale.
425
477
  *
426
478
  * - The value is DAMPED: the scroll stops and the page settles a moment later. This is much of the prototype's weight,
427
- * and why this is not a CSS scroll timeline, which cannot do it.
479
+ * and why this is not a CSS scroll timeline, which cannot do it. Smoothed ONCE (award plan "Reddottours", RT-D2): while
480
+ * Lenis is smoothing the page's scroll, the driver FOLLOWS it with no damping of its own (`follow`) — a second damping
481
+ * on top made every picture trail the hand — and reads it where Lenis has it, not on the whole pixel the browser keeps
482
+ * (a film turns that pixel into a visible step, vectoriox/iox-ui#140). A scroll Lenis does not smooth (a jump, the
483
+ * keyboard, the scroll bar) is damped as on a page the browser scrolls natively, and so is the canvas (it pins).
428
484
  * - The live site pins with `position: sticky`, on the compositor. The canvas cannot (its page never scrolls itself,
429
485
  * its Lenis scrolls a wrapper around a zoomed frame), so `pin` holds the stage there with `translate` instead.
430
486
  * `translate`, not `transform`: a Stage may carry tracks of its own.
@@ -432,11 +488,42 @@ declare function lightMotionWanted(host?: LightHost | null | undefined): boolean
432
488
  * - Reads come first in a frame and writes after, and a write only ever touches compositor properties.
433
489
  */
434
490
  declare const SCENE_DAMPING = 9;
491
+ /** The class Lenis keeps on the element it scrolls only while it is SMOOTHING a scroll (a jump, the keyboard and the scroll
492
+ * bar are not smoothed): what a driver with no named scroller reads. */
493
+ declare const LENIS_SMOOTH_CLASS = "lenis-smooth";
435
494
  /**
436
495
  * Dispatched (bubbling) by something the driver plays that arrived after the driver last looked — a Swiper booted on a
437
496
  * slider's stage. Never a DOM `scroll`: nothing that follows the driver may dispatch one (SC2).
438
497
  */
439
498
  declare const SCENE_WAKE_EVENT = "iox-scene-wake";
499
+ /**
500
+ * The page's smooth scroller as the driver reads it — a Lenis instance is one as it is: whether it is smoothing a scroll
501
+ * right now, where it has the page (`scroll`, unrounded) and where the browser drew it (`actualScroll`, on a whole pixel).
502
+ */
503
+ interface SmoothScroller {
504
+ readonly isSmooth: boolean;
505
+ readonly scroll: number;
506
+ readonly actualScroll: number;
507
+ }
508
+ /**
509
+ * Name (or, with null, forget) the scroller that smooths a window's DOCUMENT — the iox-ui page scroller does, when it
510
+ * starts Lenis on the document. Every driver on that window reads it; a scroller of a wrapper is never named here.
511
+ */
512
+ declare function setPageScroller(host: Window, scroller: SmoothScroller | null): void;
513
+ /** The scroller named for a window's document, if any. */
514
+ declare function pageScroller(host: Window): SmoothScroller | null;
515
+ /**
516
+ * Page px the scroller has the page past where the browser drew it (its whole pixel): what a driver adds back, so a film
517
+ * never steps by the page's pixels. Read while smoothing AND after: a smoothing ends on its own unrounded value, and the
518
+ * film rests there rather than stepping back onto the pixel. 0 with no scroller, or a gap larger than rounding makes.
519
+ */
520
+ declare function scrollSubpixel(scroller: SmoothScroller | null): number;
521
+ /**
522
+ * One frame of a driver that FOLLOWS an already smoothed scroll (RT-D2): the scroll's own move since the last frame is
523
+ * taken whole, and only a gap left from before (a damped jump the smoothing then continued) is damped away. With no gap
524
+ * it stands exactly on the scroll; it never snaps across one.
525
+ */
526
+ declare function followToward(current: number, previousTarget: number, target: number, seconds: number, rate?: number): number;
440
527
  /** One frame of the damping: frame-rate independent, so 60 Hz and 120 Hz settle in the same time. */
441
528
  declare function dampToward(current: number, target: number, seconds: number, rate?: number): number;
442
529
  /** Where a root stands: scrolled `local` page px into its `travel`. `zoom` undoes the canvas's scale. */
@@ -444,6 +531,23 @@ declare function sceneScrollState(rootTop: number, originTop: number, zoom: numb
444
531
  local: number;
445
532
  progress: number;
446
533
  };
534
+ /** Page px a root has been scrolled past its hold's start, from 0 up to `distance` (its hold and its leaving). */
535
+ declare function sceneScrollAlong(rootTop: number, originTop: number, zoom: number, distance: number): number;
536
+ /** How far through a crossing: `entered` px of `span` (the stage's size plus the layer's), clamped 0–1. */
537
+ declare function crossingOf(entered: number, span: number): number;
538
+ /**
539
+ * An element's box on screen without its OWN transform: the box of the nearest ancestor that draws one (it carries every
540
+ * move above it, a walking row's included — a host the component path renders with `display: contents` draws none) plus
541
+ * where the layout places the element inside it. Null when its place cannot be read (no such ancestor, not laid out).
542
+ */
543
+ declare function unmovedBox(el: HTMLElement): {
544
+ left: number;
545
+ top: number;
546
+ right: number;
547
+ bottom: number;
548
+ width: number;
549
+ height: number;
550
+ } | null;
447
551
  interface ScrollDriverOptions {
448
552
  /** Hold the stage with `translate` (the canvas). The live site's stage is sticky and needs nothing. */
449
553
  pin?: boolean;
@@ -452,6 +556,13 @@ interface ScrollDriverOptions {
452
556
  /** Follow what changes inside a root: tracks edited, layers added (the canvas). */
453
557
  observe?: boolean;
454
558
  damping?: number;
559
+ /**
560
+ * Follow the scroll, with no damping of its own (RT-D2): true when something already smooths the scroll the driver
561
+ * reads. A function is asked on every frame. Absent: true while the page's scroller (`setPageScroller`; else a Lenis
562
+ * marking the document's root `LENIS_SMOOTH_CLASS`) is SMOOTHING a scroll and the driver does not `pin` — a jump, the
563
+ * keyboard and the scroll bar are not smoothed by Lenis, and the canvas keeps its damping.
564
+ */
565
+ follow?: boolean | (() => boolean);
455
566
  /** Called after every frame it writes, outside any framework's zone (the canvas's selection box follows on it). */
456
567
  onFrame?: (root: HTMLElement, state: SceneFrameState) => void;
457
568
  /** The part of the screen the page is seen through, when that is not the window (the canvas's scroller). Links only. */
@@ -551,6 +662,15 @@ declare class ScrollDriver {
551
662
  private remeasureAll;
552
663
  private measure;
553
664
  private readonly tick;
665
+ /** True when the scroll the driver reads is being smoothed right now: it follows it (RT-D2). */
666
+ private following;
667
+ private scroller;
668
+ /**
669
+ * Where each crossing layer of a Scene stands in its crossing of the stage. Its box is read WITHOUT its own move (its
670
+ * parent's box, which carries a walking row's move, plus its offset in it), so what it is moved by never feeds back into
671
+ * how far it is moved. True when any of them moved since the last frame.
672
+ */
673
+ private readCrossings;
554
674
  /** The part of the page on screen: the host's own, or the window. */
555
675
  private viewBox;
556
676
  private readLink;
@@ -698,5 +818,5 @@ interface TextScrub {
698
818
  */
699
819
  declare function scrubTextReveal(el: HTMLElement, by: TextRevealBy, look?: TextRevealLook, easing?: string): TextScrub | null;
700
820
 
701
- export { LETTER_PIECE_CAP, LIGHT_UP_PIECE_CAP, LetterRefusal, PARALLAX_DEPTH_DEFAULT, PARALLAX_PHONE_FACTOR, PARALLAX_REST_DEFAULT, PARALLAX_SPEED, PROGRESS_BAR_FRAMES, ParallaxDepth, ParallaxPhone, REVEAL_PIECE_CAP, SCENE_BUDGET, SCENE_DAMPING, SCENE_FILM_SMOOTH, SCENE_FLOW_RULES, SCENE_LENGTH, SCENE_MAX_SCREENS, SCENE_MIN_SCREENS, SCENE_PHONE_LENGTH, SCENE_PHONE_MAX_WIDTH, SCENE_REDUCED_MOTION_CSS, SCENE_REVEAL_DEFAULT, SCENE_STAGE_HEIGHT, SCENE_TRACK_DEFS, SCENE_WAKE_EVENT, SCENE_WORDS, SCENE_WORD_DIM, SCROLL_RANGE_DEFAULT, SCRUB_PIECES_IN_FLIGHT, SLIDER_HOLD_SHARE, SLIDER_SCROLL_STEP_SCREENS, SceneAttribute, SceneProp, SceneRevealFrom, ScrollActionKind, ScrollDriver, ScrollPlay, ScrollRange, TextRevealBy, TextRevealLook, applySceneFirstFrame, attachSceneRoots, attachScenes, buildSceneRecipe, colourAt, dampToward, gentleFrames, heldProgress, layoutBoxOnScreen, letterCount, letterRefusalOf, lettersSplittable, lightMotionWanted, lineIndexes, movedSceneKey, normalizeParallaxDepth, normalizeParallaxPhone, normalizeScrollRange, normalizeTracks, outermostNodeOf, parallaxFrames, parallaxOffset, parallaxRest, parallaxShift, playTextReveal, rangeDistance, rangeEnds, rangeProgress, revealClipPath, revealStagger, sceneBudget, sceneColourKeyAt, sceneDisplayValue, sceneFilmDensity, sceneFirstFrame, sceneFrame, sceneFrameDeclarations, sceneHasKeyAt, sceneHeightForScreens, sceneKeyPosition, sceneLayersOf, sceneNodeAttributes, scenePlayed, sceneRevealFromOf, sceneRootOnPath, sceneRootsIn, sceneScreensOf, sceneScrollState, sceneTrackDef, sceneTrackSpan, sceneWordOpacity, sceneWordsLit, scenesIn, scrollPlayFor, scrubPieceProgress, scrubTextReveal, splitForReveal, splitText, syncSceneAttributes, textPieces, textRevealByOf, textRevealLookOf, valueAt, withSceneKey, withScenePlayback, withSceneRevealFrom, withoutSceneKey, withoutScenePlayback };
702
- export type { RevealSplit, SceneBudget, SceneFilmDensity, SceneFrame, SceneFrameOptions, SceneFrameState, SceneKey, SceneLayerNode, SceneNodeSource, SceneTrack, SceneTrackDef, SceneTreeNode, SceneWords, ScrollBox, ScrollDriverOptions, ScrollLink, ScrollLinkGeometry, ScrollMotionEnv, SplitText, SplitTextOptions, TextPiece, TextScrub };
821
+ export { LENIS_SMOOTH_CLASS, LETTER_PIECE_CAP, LIGHT_UP_PIECE_CAP, LetterRefusal, PARALLAX_DEPTH_DEFAULT, PARALLAX_PHONE_FACTOR, PARALLAX_REST_DEFAULT, PARALLAX_SPEED, PROGRESS_BAR_FRAMES, ParallaxDepth, ParallaxPhone, REVEAL_PIECE_CAP, SCENE_BUDGET, SCENE_DAMPING, SCENE_FILM_SMOOTH, SCENE_FLOW_RULES, SCENE_LENGTH, SCENE_MAX_SCREENS, SCENE_MIN_SCREENS, SCENE_PHONE_LENGTH, SCENE_PHONE_MAX_WIDTH, SCENE_REDUCED_MOTION_CSS, SCENE_REVEAL_DEFAULT, SCENE_STAGE_HEIGHT, SCENE_TRACK_DEFS, SCENE_TRACK_EASE, SCENE_WAKE_EVENT, SCENE_WORDS, SCENE_WORD_DIM, SCROLL_RANGE_DEFAULT, SCRUB_PIECES_IN_FLIGHT, SLIDER_HOLD_SHARE, SLIDER_SCROLL_STEP_SCREENS, SceneAttribute, SceneEase, SceneProp, SceneRange, SceneRevealFrom, ScrollActionKind, ScrollDriver, ScrollPlay, ScrollRange, TextRevealBy, TextRevealLook, applySceneFirstFrame, attachSceneRoots, attachScenes, buildSceneRecipe, colourAt, crossesStage, crossingOf, dampToward, followToward, gentleFrames, heldProgress, isHoldTrack, layoutBoxOnScreen, letterCount, letterRefusalOf, lettersSplittable, lightMotionWanted, lineIndexes, movedSceneKey, normalizeParallaxDepth, normalizeParallaxPhone, normalizeScrollRange, normalizeTracks, outermostNodeOf, pageScroller, parallaxFrames, parallaxOffset, parallaxRest, parallaxShift, playTextReveal, rangeDistance, rangeEnds, rangeProgress, revealClipPath, revealStagger, sceneBudget, sceneColourKeyAt, sceneDisplayValue, sceneFilmDensity, sceneFirstFrame, sceneFrame, sceneFrameDeclarations, sceneHasKeyAt, sceneHeightForScreens, sceneKeyPosition, sceneLayersOf, sceneNodeAttributes, scenePlayed, sceneRevealFromOf, sceneRootOnPath, sceneRootsIn, sceneScreensOf, sceneScrollAlong, sceneScrollState, sceneTrackDef, sceneTrackSpan, sceneWordOpacity, sceneWordsLit, scenesIn, scrollPlayFor, scrollSubpixel, scrubPieceProgress, scrubTextReveal, setPageScroller, splitForReveal, splitText, syncSceneAttributes, textPieces, textRevealByOf, textRevealLookOf, trackColourAt, trackEase, trackProgress, trackRange, trackValueAt, unmovedBox, valueAt, withSceneKey, withScenePlayback, withSceneRevealFrom, withoutSceneKey, withoutScenePlayback };
822
+ export type { RevealSplit, SceneBudget, SceneFilmDensity, SceneFrame, SceneFrameOptions, SceneFrameState, SceneKey, SceneLayerNode, SceneNodeSource, SceneProgress, SceneTrack, SceneTrackDef, SceneTreeNode, SceneWords, ScrollBox, ScrollDriverOptions, ScrollLink, ScrollLinkGeometry, ScrollMotionEnv, SmoothScroller, SplitText, SplitTextOptions, TextPiece, TextScrub };
@@ -0,0 +1,328 @@
1
+ import { CHECKOUT_PATH } from '@vectoriox/iox-ui/commerce-core';
2
+ import {
3
+ POPUP_KIND_ARRIVAL, POPUP_KIND_MIX, PopupAgain, PopupArrive, PopupForm, popupFormOf, PopupKind, PopupTrait,
4
+ } from '@vectoriox/iox-ui/composite-core';
5
+ import { ACCOUNT_PATH } from '@vectoriox/iox-ui/identity-core';
6
+
7
+ /**
8
+ * WHEN A SELF-ARRIVING OVERLAY MAY SHOW (popups-plan.md §4–§5, PU-D4…PU-D9, PU-D17) — the ONE planner. The engine's runtime
9
+ * only reports state and obeys; the builder's canvas never asks it (a popup never arrives on the canvas, PU-D14).
10
+ *
11
+ * overlayTurn(state) → 'preloader' | 'consent' | 'popup:<id>' | 'none'
12
+ * 1. a first visit's preloader is showing → nothing else
13
+ * 2. the consent debt is unpaid → the banner only (a popup never opens over or before it)
14
+ * 3. any dialog, drawer, cart, sign-in or lightbox is open → wait
15
+ * 4. the route is quiet → no popup
16
+ * 5. a popup already arrived in this page view → no second one
17
+ * 6. otherwise the first DUE popup (page before global, then tree order) → its clock starts NOW
18
+ *
19
+ * A popup's clock starts when its TURN starts — `time` counts from then, `scroll` needs a scroll after it. The consent
20
+ * banner's own arrival (AW2 `arrive.delay`: the first scroll or 6 s) is planned here too (`planConsentArrival`), so every
21
+ * self-arriving overlay has one arrival rule. Memory (PU-D6/PU-D7): localStorage, no identifier, never sent — Necessary.
22
+ * Pure and framework-free: no DOM, no clock (`now` is passed in).
23
+ *
24
+ * The numbers are the contract's (layout.mjs POPUP `rules`; generation-core's popup spec holds them equal).
25
+ */
26
+
27
+ /** POPUP `rules` — mirrored, held equal to the contract by generation-core's spec. */
28
+ export const POPUP_RULES = Object.freeze({
29
+ minSeconds: 3,
30
+ scrollScreens: 0.5,
31
+ timeSeconds: 8,
32
+ leavingAfterSeconds: 10,
33
+ phoneLeavingSeconds: 25,
34
+ phoneMaxHeight: 0.3,
35
+ memoryDays: 30,
36
+ reducedFadeMs: 200,
37
+ exitRatio: 0.55,
38
+ durationByAnimated: Object.freeze({ still: 200, subtle: 350, standard: 450, lively: 550, expressive: 600 }),
39
+ quietRoutes: Object.freeze(['checkout', 'order', 'account', 'sign-in', 'legal', 'not-found', 'recover', 'unsubscribe']),
40
+ });
41
+
42
+ /** AW2 (CONSENT `rules.delayMs`): the banner's `arrive.delay` — the first scroll, or this many ms. */
43
+ export const CONSENT_DELAY_MS = 6000;
44
+
45
+ // ── the order ─────────────────────────────────────────────────────────────────────────────────────────────────────────
46
+
47
+ export enum OverlayTurnKind {
48
+ Preloader = 'preloader',
49
+ Consent = 'consent',
50
+ None = 'none',
51
+ }
52
+
53
+ /** `popup:<id>` — the popup whose clock runs now. */
54
+ export type OverlayTurn = OverlayTurnKind | `popup:${string}`;
55
+
56
+ export const POPUP_TURN_PREFIX = 'popup:';
57
+
58
+ export interface OverlayState {
59
+ /** A first visit's preloader is on screen (AW5). */
60
+ preloaderShowing: boolean;
61
+ /** The consent banner is owed (consent-core `needsPrompt`) — paid by the visitor's decision. */
62
+ consentOwed: boolean;
63
+ /** A dialog, drawer, cart, sign-in or lightbox is open (a popup never opens over it). */
64
+ otherOverlayOpen: boolean;
65
+ /** The page is a quiet route (`isQuietRoute`). */
66
+ quietRoute: boolean;
67
+ /** A popup already arrived in this page view. */
68
+ popupArrivedThisView: boolean;
69
+ /** The popups that are DUE (`popupDue`), page popups first, then globals, each in tree order. */
70
+ due: ReadonlyArray<string>;
71
+ }
72
+
73
+ /** Whose turn it is (§4b). */
74
+ export function overlayTurn(state: OverlayState): OverlayTurn {
75
+ if (state.preloaderShowing) return OverlayTurnKind.Preloader;
76
+ if (state.consentOwed) return OverlayTurnKind.Consent;
77
+ if (state.otherOverlayOpen || state.quietRoute || state.popupArrivedThisView) return OverlayTurnKind.None;
78
+ const first = state.due[0];
79
+ return first ? `${POPUP_TURN_PREFIX}${first}` : OverlayTurnKind.None;
80
+ }
81
+
82
+ /** The popup id of a turn, or null. */
83
+ export function popupOfTurn(turn: OverlayTurn): string | null {
84
+ return turn.startsWith(POPUP_TURN_PREFIX) ? turn.slice(POPUP_TURN_PREFIX.length) : null;
85
+ }
86
+
87
+ // ── quiet routes ──────────────────────────────────────────────────────────────────────────────────────────────────────
88
+
89
+ export interface RouteInfo {
90
+ /** The page's app path, without the org label (`/checkout/r/abc`, `/menu`). */
91
+ path: string;
92
+ /** The page is a stamped legal page (LEGAL kinds — found by its kind). */
93
+ legal?: boolean;
94
+ /** The 404 page. */
95
+ notFound?: boolean;
96
+ }
97
+
98
+ /** The first path segments that are quiet: commerce's fixed checkout (its order, recover and unsubscribe links live under
99
+ * it) and the buyer's account (where a buyer signs in). */
100
+ const QUIET_SEGMENTS: ReadonlyArray<string> = [CHECKOUT_PATH, ACCOUNT_PATH];
101
+
102
+ /** PU-D9: a popup never arrives here. */
103
+ export function isQuietRoute(route: RouteInfo): boolean {
104
+ if (route.legal || route.notFound) return true;
105
+ const first = (route.path ?? '').split('?')[0].split('#')[0].split('/').filter(Boolean)[0] ?? '';
106
+ return QUIET_SEGMENTS.includes(first.toLowerCase());
107
+ }
108
+
109
+ // ── arrival ───────────────────────────────────────────────────────────────────────────────────────────────────────────
110
+
111
+ /** The trigger a planned arrival waits on. `now` = at once (the consent banner's `arrive.load`); `never` = only a button. */
112
+ export enum ArrivalTrigger {
113
+ Now = 'now',
114
+ Scroll = 'scroll',
115
+ Time = 'time',
116
+ ScrollOrTime = 'scrollOrTime',
117
+ Never = 'never',
118
+ }
119
+
120
+ export interface ArrivalPlan {
121
+ trigger: ArrivalTrigger;
122
+ /** A share of the FIRST screen the visitor scrolls (0 = any real scroll). */
123
+ screens: number | null;
124
+ /** A share of the whole PAGE scrolled, instead of screens. */
125
+ pageShare: number | null;
126
+ /** Visible seconds on the page, counted from the turn's start. */
127
+ seconds: number | null;
128
+ }
129
+
130
+ /** What the runtime measures, from the moment the turn started. */
131
+ export interface ArrivalProgress {
132
+ /** The visitor's own scroll since the turn started, px (a programmatic scroll is never counted). */
133
+ scrolledPx: number;
134
+ /** The page's current scroll position, px — for a page share. */
135
+ scrollY: number;
136
+ viewportHeight: number;
137
+ pageHeight: number;
138
+ /** Seconds the tab was visible since the turn started. */
139
+ visibleSeconds: number;
140
+ }
141
+
142
+ export interface ArrivalEnv {
143
+ /** `(hover: hover) and (pointer: fine)` — a laptop's mouse. */
144
+ finePointer: boolean;
145
+ }
146
+
147
+ const num = (v: unknown): number | null => {
148
+ const n = typeof v === 'number' ? v : typeof v === 'string' && v.trim() ? Number(v) : NaN;
149
+ return Number.isFinite(n) && n >= 0 ? n : null;
150
+ };
151
+
152
+ /**
153
+ * A popup's arrival from its traits (PU-D5): its kind's defaults where a trait is unset; `time` never under 3 s; `leaving`
154
+ * — until PU2b draws it — and on a phone always, arrives by time (`phoneLeavingSeconds`); `button` never arrives by itself.
155
+ */
156
+ export function planPopupArrival(get: (name: string) => unknown, _env: ArrivalEnv): ArrivalPlan {
157
+ const kind = (Object.values(PopupKind) as string[]).includes(String(get(PopupTrait.Kind))) ? get(PopupTrait.Kind) as PopupKind : PopupKind.Offer;
158
+ const defaults = POPUP_KIND_ARRIVAL[kind];
159
+ const asked = String(get(PopupTrait.Arrive) ?? '');
160
+ const arrive = (Object.values(PopupArrive) as string[]).includes(asked) ? asked as PopupArrive : POPUP_KIND_MIX[kind].arrive;
161
+ const pageShare = num(get(PopupTrait.PageShare)) ?? (num(get(PopupTrait.Screens)) === null ? defaults.pageShare ?? null : null);
162
+ const screens = pageShare !== null ? null : num(get(PopupTrait.Screens)) ?? defaults.screens ?? POPUP_RULES.scrollScreens;
163
+ const seconds = (fallback: number) => Math.max(POPUP_RULES.minSeconds, num(get(PopupTrait.Seconds)) ?? defaults.seconds ?? fallback);
164
+ switch (arrive) {
165
+ case PopupArrive.Button: return { trigger: ArrivalTrigger.Never, screens: null, pageShare: null, seconds: null };
166
+ case PopupArrive.Scroll: return { trigger: ArrivalTrigger.Scroll, screens, pageShare, seconds: null };
167
+ case PopupArrive.Time: return { trigger: ArrivalTrigger.Time, screens: null, pageShare: null, seconds: seconds(POPUP_RULES.timeSeconds) };
168
+ // PU2b draws `leaving` for a fine pointer; until then — and on a phone, always — it arrives by time.
169
+ case PopupArrive.Leaving: return { trigger: ArrivalTrigger.Time, screens: null, pageShare: null, seconds: Math.max(POPUP_RULES.minSeconds, POPUP_RULES.phoneLeavingSeconds) };
170
+ default: return { trigger: ArrivalTrigger.ScrollOrTime, screens, pageShare, seconds: seconds(POPUP_RULES.timeSeconds) };
171
+ }
172
+ }
173
+
174
+ /** AW2 / PU-D17: the consent banner's arrival — `load` at once, `delay` on the first real scroll or after 6 s. */
175
+ export function planConsentArrival(arrive: 'load' | 'delay' | string | null | undefined): ArrivalPlan {
176
+ return arrive === 'delay'
177
+ ? { trigger: ArrivalTrigger.ScrollOrTime, screens: 0, pageShare: null, seconds: CONSENT_DELAY_MS / 1000 }
178
+ : { trigger: ArrivalTrigger.Now, screens: null, pageShare: null, seconds: null };
179
+ }
180
+
181
+ function scrolledEnough(plan: ArrivalPlan, p: ArrivalProgress): boolean {
182
+ if (!(p.scrolledPx > 0)) return false; // a real scroll, after the turn started
183
+ if (plan.pageShare !== null) {
184
+ const room = p.pageHeight - p.viewportHeight;
185
+ return room <= 0 || p.scrollY / room >= plan.pageShare;
186
+ }
187
+ return p.scrolledPx >= (plan.screens ?? 0) * p.viewportHeight;
188
+ }
189
+
190
+ /** True once the planned arrival has happened. */
191
+ export function arrivalFired(plan: ArrivalPlan, p: ArrivalProgress): boolean {
192
+ switch (plan.trigger) {
193
+ case ArrivalTrigger.Now: return true;
194
+ case ArrivalTrigger.Never: return false;
195
+ case ArrivalTrigger.Scroll: return scrolledEnough(plan, p);
196
+ case ArrivalTrigger.Time: return p.visibleSeconds >= (plan.seconds ?? Infinity);
197
+ default: return scrolledEnough(plan, p) || p.visibleSeconds >= (plan.seconds ?? Infinity);
198
+ }
199
+ }
200
+
201
+ // ── memory (PU-D6, PU-D7) ─────────────────────────────────────────────────────────────────────────────────────────────
202
+
203
+ /** What a browser remembers of one popup. `v` the popup's version when it was closed; `acted` = followed or sent. */
204
+ export interface PopupMemory {
205
+ v: number;
206
+ closedAt: number;
207
+ acted: boolean;
208
+ }
209
+
210
+ export const POPUP_MEMORY_PREFIX = 'iox-popup';
211
+
212
+ /** `iox-popup:<site scope>:<popup node id>` — no identifier of the visitor. */
213
+ export function popupMemoryKey(scope: string, popupId: string): string {
214
+ return `${POPUP_MEMORY_PREFIX}:${scope || '-'}:${popupId}`;
215
+ }
216
+
217
+ /** Where it is kept: `visit` → the tab's session; `days` / `once` → the browser. The runtime falls back to the session,
218
+ * then to this page view, when one is refused. */
219
+ export enum PopupMemoryStore {
220
+ Local = 'local',
221
+ Session = 'session',
222
+ }
223
+
224
+ export function popupMemoryStore(again: unknown): PopupMemoryStore {
225
+ return again === PopupAgain.Visit ? PopupMemoryStore.Session : PopupMemoryStore.Local;
226
+ }
227
+
228
+ export function encodePopupMemory(memory: PopupMemory): string {
229
+ return JSON.stringify({ v: memory.v, closedAt: memory.closedAt, acted: memory.acted });
230
+ }
231
+
232
+ /** Tolerant: anything that is not a well-formed memory reads as none (a browser holding garbage still gets the popup). */
233
+ export function decodePopupMemory(raw: string | null | undefined): PopupMemory | null {
234
+ if (!raw) return null;
235
+ try {
236
+ const o = JSON.parse(raw) as Partial<PopupMemory> | null;
237
+ if (!o || typeof o !== 'object') return null;
238
+ const v = Number(o.v), closedAt = Number(o.closedAt);
239
+ if (!Number.isFinite(v) || !Number.isFinite(closedAt) || closedAt < 0) return null;
240
+ return { v, closedAt, acted: o.acted === true };
241
+ } catch {
242
+ return null;
243
+ }
244
+ }
245
+
246
+ /** A popup's version (`popupVersion`, default 1). */
247
+ export function popupVersionOf(get: (name: string) => unknown): number {
248
+ const n = num(get(PopupTrait.Version));
249
+ return n !== null && n >= 1 ? Math.floor(n) : 1;
250
+ }
251
+
252
+ const DAY_MS = 86_400_000;
253
+
254
+ /** True while a remembered close keeps the popup away (any version older than the popup's is forgotten). */
255
+ export function memoryKeepsAway(memory: PopupMemory | null, get: (name: string) => unknown, now: number): boolean {
256
+ if (!memory || memory.v < popupVersionOf(get)) return false;
257
+ if (memory.acted) return true; // never again after the visitor acts — until the owner changes it
258
+ const again = String(get(PopupTrait.Again) ?? '') || POPUP_KIND_MIX[(get(PopupTrait.Kind) as PopupKind) ?? PopupKind.Offer]?.again;
259
+ if (again === PopupAgain.Once || again === PopupAgain.Visit) return true; // a visit's memory dies with the session
260
+ const days = num(get(PopupTrait.Days)) ?? POPUP_RULES.memoryDays;
261
+ return now - memory.closedAt < days * DAY_MS;
262
+ }
263
+
264
+ // ── dates (PU-D18) ────────────────────────────────────────────────────────────────────────────────────────────────────
265
+
266
+ /** The visitor's day, `YYYY-MM-DD`, on THEIR clock (never UTC — a popup "until 30 November" ends at their midnight). */
267
+ export function visitorDay(now: Date): string {
268
+ const p = (n: number) => String(n).padStart(2, '0');
269
+ return `${now.getFullYear()}-${p(now.getMonth() + 1)}-${p(now.getDate())}`;
270
+ }
271
+
272
+ const DAY_RE = /^\d{4}-\d{2}-\d{2}$/;
273
+
274
+ /** Inside its dates (whole days, both ends included); no dates = always. A malformed date is ignored. */
275
+ export function popupWithinDates(get: (name: string) => unknown, now: Date): boolean {
276
+ const day = visitorDay(now);
277
+ const from = String(get(PopupTrait.ShowFrom) ?? '').trim(), until = String(get(PopupTrait.ShowUntil) ?? '').trim();
278
+ if (DAY_RE.test(from) && day < from) return false;
279
+ if (DAY_RE.test(until) && day > until) return false;
280
+ return true;
281
+ }
282
+
283
+ /** Ended: its last day is past (the engine leaves it out of the raw SSR; Home warns). Days compare on the given clock. */
284
+ export function popupEnded(get: (name: string) => unknown, now: Date): boolean {
285
+ const until = String(get(PopupTrait.ShowUntil) ?? '').trim();
286
+ return DAY_RE.test(until) && visitorDay(now) > until;
287
+ }
288
+
289
+ // ── due ───────────────────────────────────────────────────────────────────────────────────────────────────────────────
290
+
291
+ export enum PopupNotDue {
292
+ /** Only a button opens it. */
293
+ Button = 'button',
294
+ /** Outside its dates. */
295
+ Dates = 'dates',
296
+ /** A remembered close (or the visitor acted). */
297
+ Memory = 'memory',
298
+ }
299
+
300
+ /** May this popup arrive by itself now? null = due; else why not. */
301
+ export function popupDue(get: (name: string) => unknown, memory: PopupMemory | null, now: Date): PopupNotDue | null {
302
+ if (String(get(PopupTrait.Arrive) ?? '') === PopupArrive.Button) return PopupNotDue.Button;
303
+ if (!popupWithinDates(get, now)) return PopupNotDue.Dates;
304
+ if (memoryKeepsAway(memory, get, now.getTime())) return PopupNotDue.Memory;
305
+ return null;
306
+ }
307
+
308
+ // ── presentation ──────────────────────────────────────────────────────────────────────────────────────────────────────
309
+
310
+ /** How it opens on THIS device (PU-D2, PU-D10): `centred` is a modal on a laptop only — on a phone it is the corner card. */
311
+ export function popupFormOn(get: (name: string) => unknown, env: { phone: boolean }): PopupForm {
312
+ const form = popupFormOf(get(PopupTrait.Kind), get(PopupTrait.Form));
313
+ return env.phone && form === PopupForm.Centred ? PopupForm.Corner : form;
314
+ }
315
+
316
+ /** The How animated levels (the look's `animate`), stillest first. */
317
+ export type AnimateLevel = keyof typeof POPUP_RULES.durationByAnimated;
318
+
319
+ /** §6: the factor the `popup-dur-*` tokens are scaled by for the look's How animated (the token holds Standard). */
320
+ export function popupMotionScale(level: string | null | undefined): number {
321
+ const table = POPUP_RULES.durationByAnimated as Readonly<Record<string, number>>;
322
+ return Math.round(((table[level ?? ''] ?? table['standard']) / table['standard']) * 1000) / 1000;
323
+ }
324
+
325
+ /** Still moves nothing: the popup fades (§6). */
326
+ export function popupFadesOnly(level: string | null | undefined): boolean {
327
+ return level === 'still';
328
+ }
@@ -15,3 +15,4 @@ export * from './dialog-opener';
15
15
  export * from './popover-opener';
16
16
  export * from './dialog-motion';
17
17
  export * from './reveal-origin';
18
+ export * from './popup-arrival';
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  AiEntitlementsView, AiFeature, AiModelEntry, AiRefusal, AiRefusalCode, AiStep, AiTokenPrice, ArtDirection, PICTURE_ASPECTS, PictureReview, WordsArea,
3
- AI_STEP_FEATURE, aiModelStep, aiRefusalNext, artDirectionPreamble, creditsOfUsd, emptyAreaPhrase, estimateStepCredits, frameWords, modelCanDo, pictureReviewPasses,
3
+ AI_STEP_FEATURE, aiModelStep, aiRefusalNext, artDirectionPreamble, creditsOfUsd, emptyAreaPhrase, estimateStepCredits, frameWords, modelCanDo, pictureReviewPasses, typicalStepTokens,
4
4
  } from '@vectoriox/iox-ui/generation-core';
5
5
 
6
6
  /**
@@ -247,10 +247,11 @@ export interface GenerateEstimate {
247
247
  /**
248
248
  * The cost shown under the box (A-D15: the owner chooses the cost): every candidate is made once and looked at once.
249
249
  * Unlike a site build's pictures (`estimatePictures`) there is NO second try in it — a candidate the review says no to
250
- * is kept and marked, and the owner decides whether to press again.
250
+ * is kept and marked, and the owner decides whether to press again. `model` = the picture model the press runs on: one
251
+ * picture is counted as its maker bills it at most (`pictureTokensFor`, iox-ui#138); absent, as the step's default model.
251
252
  */
252
- export function estimateGenerate(count: number, prices: { readonly image: AiTokenPrice; readonly review: AiTokenPrice }): GenerateEstimate {
253
- const picture = estimateStepCredits(GENERATE_STEPS.picture, prices.image);
253
+ export function estimateGenerate(count: number, prices: { readonly image: AiTokenPrice; readonly review: AiTokenPrice }, model?: string | null): GenerateEstimate {
254
+ const picture = estimateStepCredits(GENERATE_STEPS.picture, prices.image, typicalStepTokens(GENERATE_STEPS.picture, undefined, model));
254
255
  const review = estimateStepCredits(GENERATE_STEPS.review, prices.review);
255
256
  const n = Math.max(0, Math.floor(count));
256
257
  return { count: n, picture, review, each: creditsOfUsd((picture + review) / 100), total: creditsOfUsd((n * (picture + review)) / 100) };
@@ -274,7 +275,7 @@ export function generateModelChoices(models: ReadonlyArray<AiModelEntry>, review
274
275
  const step = aiModelStep(GENERATE_STEPS.picture); // the vetted list names the step whose model this runs on
275
276
  return models
276
277
  .filter(m => !m.retired && m.steps.includes(step) && modelCanDo(m, step))
277
- .map(m => ({ id: m.id, label: m.label, recommended: !!m.recommendedFor?.includes(step), each: m.price ? estimateGenerate(1, { image: m.price, review }).each : null }))
278
+ .map(m => ({ id: m.id, label: m.label, recommended: !!m.recommendedFor?.includes(step), each: m.price ? estimateGenerate(1, { image: m.price, review }, m.id).each : null }))
278
279
  .sort((a, b) => Number(b.recommended) - Number(a.recommended));
279
280
  }
280
281