@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
@@ -1,7 +1,7 @@
1
1
  import { SceneRole } from '@vectoriox/iox-ui/composite-core';
2
2
  import { FILM_SMOOTH_PER_SCREEN } from '@vectoriox/iox-ui/media-core';
3
3
 
4
- import { normalizeTracks, SCENE_REVEAL_DEFAULT, SceneKey, SceneNodeSource, SceneProp, SceneRevealFrom, SceneTrack, valueAt } from './scene';
4
+ import { isHoldTrack, normalizeTracks, SCENE_REVEAL_DEFAULT, SceneKey, SceneNodeSource, SceneProp, SceneRevealFrom, SceneTrack, trackValueAt } from './scene';
5
5
 
6
6
  /**
7
7
  * Authoring a Scene (premium-sites plan §5b, SC2): the decisions the builder's timeline and its panel share, so neither
@@ -57,7 +57,9 @@ export function sceneTrackDef(prop: SceneProp): SceneTrackDef {
57
57
  return DEF_BY_PROP.get(prop)!;
58
58
  }
59
59
 
60
- const trackOf = (tracks: ReadonlyArray<SceneTrack>, prop: SceneProp): SceneTrack | undefined => tracks.find(t => t.prop === prop);
60
+ /** The track the timeline edits: the HOLD's (an exit or a crossing track is the composer's, kept as it is). */
61
+ const isEdited = (t: SceneTrack, prop: SceneProp): boolean => t.prop === prop && isHoldTrack(t);
62
+ const trackOf = (tracks: ReadonlyArray<SceneTrack>, prop: SceneProp): SceneTrack | undefined => tracks.find(t => isEdited(t, prop));
61
63
  const samePosition = (a: number, b: number): boolean => sceneKeyPosition(a) === sceneKeyPosition(b);
62
64
  const roundTo = (value: number, places = 4): number => Number(value.toFixed(places));
63
65
 
@@ -65,7 +67,7 @@ const roundTo = (value: number, places = 4): number => Number(value.toFixed(plac
65
67
  export function sceneDisplayValue(tracks: ReadonlyArray<SceneTrack>, prop: SceneProp, p: number): number {
66
68
  const def = sceneTrackDef(prop);
67
69
  const track = trackOf(tracks, prop);
68
- return roundTo((track ? valueAt(track.keys, p) : def.rest) * def.factor, 2);
70
+ return roundTo((track ? trackValueAt(track, p) : def.rest) * def.factor, 2);
69
71
  }
70
72
 
71
73
  /**
@@ -90,12 +92,14 @@ function storedValue(def: SceneTrackDef, value: number | string): number | strin
90
92
  }
91
93
 
92
94
  function replaceTrack(tracks: ReadonlyArray<SceneTrack>, prop: SceneProp, keys: ReadonlyArray<SceneKey>): SceneTrack[] {
93
- const rest = tracks.filter(t => t.prop !== prop);
95
+ const rest = tracks.filter(t => !isEdited(t, prop));
94
96
  if (!keys.length) return rest;
95
- const at = tracks.findIndex(t => t.prop === prop);
97
+ const at = tracks.findIndex(t => isEdited(t, prop));
96
98
  const next = [...rest];
97
99
  const from = prop === SceneProp.Clip ? { from: tracks[at]?.from ?? SCENE_REVEAL_DEFAULT } : {};
98
- next.splice(at < 0 ? rest.length : at, 0, { prop, ...from, keys });
100
+ // Its own ease stays with it: new keys never change how the track runs between them.
101
+ const ease = tracks[at]?.ease ? { ease: tracks[at].ease } : {};
102
+ next.splice(at < 0 ? rest.length : at, 0, { prop, ...from, ...ease, keys });
99
103
  return next;
100
104
  }
101
105
 
@@ -110,7 +114,7 @@ export function sceneRevealFromOf(tracks: ReadonlyArray<SceneTrack>): SceneRevea
110
114
  */
111
115
  export function withSceneRevealFrom(tracks: ReadonlyArray<SceneTrack>, from: SceneRevealFrom, p: number): SceneTrack[] {
112
116
  if (!trackOf(tracks, SceneProp.Clip)) return [...tracks, { prop: SceneProp.Clip, from, keys: [[sceneKeyPosition(p), sceneTrackDef(SceneProp.Clip).rest]] }];
113
- return tracks.map(track => (track.prop === SceneProp.Clip ? { ...track, from } : track));
117
+ return tracks.map(track => (isEdited(track, SceneProp.Clip) ? { ...track, from } : track));
114
118
  }
115
119
 
116
120
  /**
@@ -124,7 +128,7 @@ export function withScenePlayback(tracks: ReadonlyArray<SceneTrack>): SceneTrack
124
128
 
125
129
  /** Stop playing a layer's pictures. */
126
130
  export function withoutScenePlayback(tracks: ReadonlyArray<SceneTrack>): SceneTrack[] {
127
- return tracks.filter(track => track.prop !== SceneProp.Play);
131
+ return tracks.filter(track => !isEdited(track, SceneProp.Play));
128
132
  }
129
133
 
130
134
  /**
@@ -42,6 +42,55 @@ export enum SceneRevealFrom {
42
42
  End = 'end',
43
43
  }
44
44
 
45
+ /**
46
+ * How a track runs between two keys (award plan "Reddottours", RT-D1). A scrubbed TRAVEL runs straight, so a layer moves
47
+ * exactly as far as the scroll moves it (theirs is `ease: none`; smoothstep slowed every walk at both ends); a FADE keeps
48
+ * smoothstep, which is what a fade looks right with. A track says its own only when it differs from its property's.
49
+ */
50
+ export enum SceneEase {
51
+ Linear = 'linear',
52
+ Smooth = 'smooth',
53
+ }
54
+
55
+ /** Each property's ease when its track says none: travel straight, fades and colours smooth. */
56
+ export const SCENE_TRACK_EASE: Readonly<Record<SceneProp, SceneEase>> = {
57
+ [SceneProp.X]: SceneEase.Linear,
58
+ [SceneProp.Y]: SceneEase.Linear,
59
+ [SceneProp.Scale]: SceneEase.Linear,
60
+ [SceneProp.Rotate]: SceneEase.Linear,
61
+ [SceneProp.Clip]: SceneEase.Linear,
62
+ [SceneProp.Play]: SceneEase.Linear,
63
+ [SceneProp.Opacity]: SceneEase.Smooth,
64
+ [SceneProp.Words]: SceneEase.Smooth,
65
+ [SceneProp.Ground]: SceneEase.Smooth,
66
+ [SceneProp.Ink]: SceneEase.Smooth,
67
+ };
68
+
69
+ /**
70
+ * 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.
71
+ * - Hold: the root's held travel — the stage pinned while the page scrolls the root's extra height (every Scene so far).
72
+ * - Exit: the root's LEAVING, after the hold — from the stage's release until it has gone by its own height (their S1:
73
+ * the held film sinks at 0.4× as the next band rises).
74
+ * - Cross inline / Cross block: the layer's OWN crossing of the stage — 0 as its leading edge enters the stage's far side,
75
+ * 1 as its trailing edge leaves the near side — measured where it stands without its own move, so inside a walking row
76
+ * each picture drifts as IT crosses the screen (their S3, GSAP's `containerAnimation`). Inline follows the reading
77
+ * direction (a walk enters from the end); block enters from below.
78
+ */
79
+ export enum SceneRange {
80
+ Hold = 'hold',
81
+ Exit = 'exit',
82
+ CrossInline = 'cross-inline',
83
+ CrossBlock = 'cross-block',
84
+ }
85
+
86
+ /** Where a layer stands on each range at one moment. Hold is the Scene's progress; the others are 0 until measured. */
87
+ export interface SceneProgress {
88
+ hold: number;
89
+ exit?: number;
90
+ crossInline?: number;
91
+ crossBlock?: number;
92
+ }
93
+
45
94
  /** What a reveal opens from when nobody has said: the page's own direction of travel, upward as it scrolls. */
46
95
  export const SCENE_REVEAL_DEFAULT = SceneRevealFrom.Bottom;
47
96
 
@@ -50,10 +99,14 @@ export type SceneKey = readonly [number, number | string];
50
99
 
51
100
  export interface SceneTrack {
52
101
  prop: SceneProp;
53
- /** Ascending by progress. Between two keys the value eases (smoothstep); outside them it holds the nearest. */
102
+ /** Ascending by progress. Between two keys the value runs by `ease`; outside them it holds the nearest. */
54
103
  keys: ReadonlyArray<SceneKey>;
55
104
  /** A Clip track's direction. */
56
105
  from?: SceneRevealFrom;
106
+ /** How it runs between keys; absent = its property's (`SCENE_TRACK_EASE`). */
107
+ ease?: SceneEase;
108
+ /** What its progress is measured over; absent = the hold. */
109
+ range?: SceneRange;
57
110
  }
58
111
 
59
112
  /** What a node carries (both a builder node and a saved one). */
@@ -114,6 +167,15 @@ const COLOUR = /^(#[0-9a-f]{3,8}|(rgb|hsl)a?\([\d\s.,%/]+\)|var\(--iox-[\w-]+\))
114
167
  const COLOUR_PROPS: ReadonlySet<SceneProp> = new Set([SceneProp.Ground, SceneProp.Ink]);
115
168
  const ALL_PROPS: ReadonlySet<string> = new Set(Object.values(SceneProp));
116
169
  const REVEAL_FROMS: ReadonlySet<string> = new Set(Object.values(SceneRevealFrom));
170
+ const EASES: ReadonlySet<string> = new Set(Object.values(SceneEase));
171
+ const RANGES: ReadonlySet<string> = new Set(Object.values(SceneRange));
172
+
173
+ /** How a track runs between its keys. */
174
+ export const trackEase = (track: Pick<SceneTrack, 'prop' | 'ease'>): SceneEase => track.ease ?? SCENE_TRACK_EASE[track.prop];
175
+ /** What a track's progress is measured over. */
176
+ export const trackRange = (track: Pick<SceneTrack, 'range'>): SceneRange => track.range ?? SceneRange.Hold;
177
+ /** A track the hold drives (every authored track): what the timeline edits. */
178
+ export const isHoldTrack = (track: Pick<SceneTrack, 'range'>): boolean => trackRange(track) === SceneRange.Hold;
117
179
  const PERCENT = 100;
118
180
  const clampPercent = (v: number): number => Math.min(PERCENT, Math.max(0, v));
119
181
 
@@ -139,7 +201,14 @@ export function normalizeTracks(tracks: unknown): SceneTrack[] {
139
201
  .slice()
140
202
  .sort((a, b) => a[0] - b[0]);
141
203
  if (!keys.length) continue;
142
- out.push(prop === SceneProp.Clip ? clipTrack(keys, (track as SceneTrack).from) : { prop, keys });
204
+ const base: SceneTrack = prop === SceneProp.Clip ? clipTrack(keys, (track as SceneTrack).from) : { prop, keys };
205
+ // Kept only where they say something: a track at its property's ease and on the hold reads as it always did.
206
+ const { ease, range } = track as SceneTrack;
207
+ out.push({
208
+ ...base,
209
+ ...(typeof ease === 'string' && EASES.has(ease) && ease !== SCENE_TRACK_EASE[prop as SceneProp] ? { ease } : {}),
210
+ ...(typeof range === 'string' && RANGES.has(range) && range !== SceneRange.Hold ? { range } : {}),
211
+ });
143
212
  }
144
213
  return out;
145
214
  }
@@ -169,6 +238,7 @@ export function revealClipPath(showing: number, from: SceneRevealFrom = SCENE_RE
169
238
  }
170
239
 
171
240
  const linear = (t: number): number => t;
241
+ const EASE_FN: Readonly<Record<SceneEase, (t: number) => number>> = { [SceneEase.Linear]: linear, [SceneEase.Smooth]: smoothstep };
172
242
 
173
243
  /** The two keys around `p` and how far between them it has come. */
174
244
  function span(keys: ReadonlyArray<SceneKey>, p: number, ease: (t: number) => number = smoothstep): { a: SceneKey; b: SceneKey; f: number } {
@@ -186,7 +256,7 @@ function span(keys: ReadonlyArray<SceneKey>, p: number, ease: (t: number) => num
186
256
  return { a: last, b: last, f: 0 };
187
257
  }
188
258
 
189
- /** A numeric track's value at progress `p`. */
259
+ /** A numeric track's value at progress `p` (eased smoothstep unless `ease` says otherwise — `trackValueAt` reads the track's). */
190
260
  export function valueAt(keys: ReadonlyArray<SceneKey>, p: number, ease?: (t: number) => number): number {
191
261
  if (!keys.length) return 0;
192
262
  const { a, b, f } = span(keys, p, ease);
@@ -198,14 +268,42 @@ export function valueAt(keys: ReadonlyArray<SceneKey>, p: number, ease?: (t: num
198
268
  * A colour track's value at progress `p`. Mixed by the browser, never computed here, so a design token stays a live
199
269
  * reference (a re-theme reaches a Scene, as it reaches every saved page) and the path is perceptual.
200
270
  */
201
- export function colourAt(keys: ReadonlyArray<SceneKey>, p: number): string {
271
+ export function colourAt(keys: ReadonlyArray<SceneKey>, p: number, ease?: (t: number) => number): string {
202
272
  if (!keys.length) return '';
203
- const { a, b, f } = span(keys, p);
273
+ const { a, b, f } = span(keys, p, ease);
204
274
  if (f <= 0 || a === b) return String(a[1]);
205
275
  if (f >= 1) return String(b[1]);
206
276
  return `color-mix(in oklab, ${a[1]} ${round((1 - f) * 100)}%, ${b[1]})`;
207
277
  }
208
278
 
279
+ /** A numeric track's value at progress `p`, run by its own ease. */
280
+ export function trackValueAt(track: SceneTrack, p: number): number {
281
+ return valueAt(track.keys, p, EASE_FN[trackEase(track)]);
282
+ }
283
+
284
+ /** A colour track's value at progress `p`, run by its own ease. */
285
+ export function trackColourAt(track: SceneTrack, p: number): string {
286
+ return colourAt(track.keys, p, EASE_FN[trackEase(track)]);
287
+ }
288
+
289
+ const RANGE_KEY: Readonly<Record<SceneRange, keyof SceneProgress>> = {
290
+ [SceneRange.Hold]: 'hold',
291
+ [SceneRange.Exit]: 'exit',
292
+ [SceneRange.CrossInline]: 'crossInline',
293
+ [SceneRange.CrossBlock]: 'crossBlock',
294
+ };
295
+
296
+ /** Where a track stands: the progress of its own range. A bare number is the hold (and 0 on every other range). */
297
+ export function trackProgress(track: Pick<SceneTrack, 'range'>, p: number | SceneProgress): number {
298
+ if (typeof p === 'number') return trackRange(track) === SceneRange.Hold ? p : 0;
299
+ return p[RANGE_KEY[trackRange(track)]] ?? 0;
300
+ }
301
+
302
+ /** True when a layer has a track measured over its own crossing: the driver measures where it stands. */
303
+ export function crossesStage(tracks: ReadonlyArray<SceneTrack>): boolean {
304
+ return tracks.some(t => t.range === SceneRange.CrossInline || t.range === SceneRange.CrossBlock);
305
+ }
306
+
209
307
  export interface SceneFrameOptions {
210
308
  /** -1 when the stage reads right-to-left: the inline axis mirrors. */
211
309
  inlineSign?: 1 | -1;
@@ -218,22 +316,34 @@ const TRANSFORM_REST: Readonly<Partial<Record<SceneProp, number>>> = { [ScenePro
218
316
  * A layer's frame at progress `p`. Lengths are container-query units, so one frame is right at any width, under any
219
317
  * canvas zoom, on the server and with no measuring: the stage is the size container (`iox-design.css`).
220
318
  */
221
- export function sceneFrame(tracks: ReadonlyArray<SceneTrack>, p: number, options: SceneFrameOptions = {}): SceneFrame {
319
+ export function sceneFrame(tracks: ReadonlyArray<SceneTrack>, p: number | SceneProgress, options: SceneFrameOptions = {}): SceneFrame {
222
320
  const frame: SceneFrame = {};
321
+ // Per property and range, the last track wins (as one list always read). Across ranges they compose: a hold that
322
+ // carries a layer and an exit that sinks it add their moves, and their scales and opacities multiply.
323
+ const byRange = new Map<string, { prop: SceneProp; value: number | string; from?: SceneRevealFrom }>();
324
+ for (const track of tracks) {
325
+ const at = trackProgress(track, p);
326
+ const value = COLOUR_PROPS.has(track.prop) ? trackColourAt(track, at) : trackValueAt(track, at);
327
+ byRange.set(`${track.prop}|${trackRange(track)}`, { prop: track.prop, value, from: track.from });
328
+ }
223
329
  const moves: Partial<Record<SceneProp, number>> = {};
224
- for (const { prop, keys, from } of tracks) {
225
- if (prop in TRANSFORM_REST) moves[prop] = valueAt(keys, p);
226
- else if (prop === SceneProp.Opacity) {
227
- const opacity = clamp01(valueAt(keys, p));
228
- frame.opacity = String(opacity);
229
- frame.pointerEvents = opacity > 0 ? '' : 'none';
330
+ let opacity: number | null = null;
331
+ for (const { prop, value, from } of byRange.values()) {
332
+ if (prop in TRANSFORM_REST) {
333
+ const v = Number(value);
334
+ moves[prop] = prop === SceneProp.Scale ? (moves[prop] ?? 1) * v : (moves[prop] ?? 0) + v;
230
335
  }
231
- else if (prop === SceneProp.Clip) frame.clipPath = revealClipPath(valueAt(keys, p), from ?? SceneRevealFrom.Centre, options.inlineSign ?? 1);
232
- else if (prop === SceneProp.Ground) frame.backgroundColor = colourAt(keys, p);
233
- else if (prop === SceneProp.Ink) frame.color = colourAt(keys, p);
336
+ else if (prop === SceneProp.Opacity) opacity = (opacity ?? 1) * clamp01(Number(value));
337
+ else if (prop === SceneProp.Clip) frame.clipPath = revealClipPath(Number(value), from ?? SceneRevealFrom.Centre, options.inlineSign ?? 1);
338
+ else if (prop === SceneProp.Ground) frame.backgroundColor = String(value);
339
+ else if (prop === SceneProp.Ink) frame.color = String(value);
340
+ }
341
+ if (opacity !== null) {
342
+ frame.opacity = String(round(opacity));
343
+ frame.pointerEvents = opacity > 0 ? '' : 'none';
234
344
  }
235
345
  if (Object.keys(moves).length) {
236
- const value = (prop: SceneProp): number => moves[prop] ?? TRANSFORM_REST[prop]!;
346
+ const value = (prop: SceneProp): number => round(moves[prop] ?? TRANSFORM_REST[prop]!);
237
347
  const x = round(value(SceneProp.X) * (options.inlineSign ?? 1));
238
348
  frame.transform = `translate3d(${x}cqw, ${value(SceneProp.Y)}cqh, 0) rotate(${value(SceneProp.Rotate)}deg) scale(${value(SceneProp.Scale)})`;
239
349
  }
@@ -244,18 +354,18 @@ export function sceneFrame(tracks: ReadonlyArray<SceneTrack>, p: number, options
244
354
  export const SCENE_WORD_DIM = 0.16;
245
355
 
246
356
  /** How many of a layer's words are lit at `p`, in %; null when it has no such track. */
247
- export function sceneWordsLit(tracks: ReadonlyArray<SceneTrack>, p: number): number | null {
357
+ export function sceneWordsLit(tracks: ReadonlyArray<SceneTrack>, p: number | SceneProgress): number | null {
248
358
  const track = tracks.find(t => t.prop === SceneProp.Words);
249
- return track ? clampPercent(valueAt(track.keys, p)) : null;
359
+ return track ? clampPercent(trackValueAt(track, trackProgress(track, p))) : null;
250
360
  }
251
361
 
252
362
  /**
253
363
  * How far a layer's pictures have played at `p`, in %; null when it has no such track. A film runs straight between its
254
- * keys, where everything else eases: eased over a 20-screen Scene it would crawl for its first screens and rush the middle.
364
+ * keys (its property's ease): eased over a 20-screen Scene it would crawl for its first screens and rush the middle.
255
365
  */
256
- export function scenePlayed(tracks: ReadonlyArray<SceneTrack>, p: number): number | null {
366
+ export function scenePlayed(tracks: ReadonlyArray<SceneTrack>, p: number | SceneProgress): number | null {
257
367
  const track = tracks.find(t => t.prop === SceneProp.Play);
258
- return track ? clampPercent(valueAt(track.keys, p, linear)) : null;
368
+ return track ? clampPercent(trackValueAt(track, trackProgress(track, p))) : null;
259
369
  }
260
370
 
261
371
  /** Word `index` of `count`, with `lit` % lit: words light one after the other, each easing in as the last finishes. */