@vanillaskyai/video 0.8.8 → 0.10.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 (173) hide show
  1. package/CHANGELOG.md +42 -0
  2. package/PUBLIC-API.md +5 -8
  3. package/dist/{builtin-server-CUYPIDE7.js → builtin-server-W4PLJUZ5.js} +2 -2
  4. package/dist/{catalog-types-BIhSpOWK.d.ts → catalog-types-WTbLP6Jh.d.ts} +5 -1
  5. package/dist/chapter-title-YRLIQY3V.js +7 -0
  6. package/dist/check-runtime.js +5 -14
  7. package/dist/{chunk-AITKH6QT.js → chunk-2HFO22K2.js} +15 -40
  8. package/dist/chunk-4YM2M62S.js +13 -0
  9. package/dist/chunk-4ZJLPHBV.js +684 -0
  10. package/dist/chunk-77VY4O7A.js +390 -0
  11. package/dist/{chunk-MMUXVA47.js → chunk-7M56IUUX.js} +9 -8
  12. package/dist/chunk-7NZOMTAL.js +63 -0
  13. package/dist/{chunk-2DOLF4QN.js → chunk-AUPC6MDK.js} +12 -14
  14. package/dist/{chunk-352ZZCET.js → chunk-EGVQODKU.js} +2 -2
  15. package/dist/{chunk-2USVB3CY.js → chunk-ELVOT2FQ.js} +284 -177
  16. package/dist/chunk-EWWCQFTI.js +18 -0
  17. package/dist/{chunk-KT3M7KDL.js → chunk-HKUI5BTB.js} +3 -3
  18. package/dist/chunk-IIN5M5HW.js +697 -0
  19. package/dist/{chunk-LMG3GHLL.js → chunk-IQMYK5DX.js} +29 -3
  20. package/dist/{chunk-OWBT45EN.js → chunk-IR44XKBI.js} +1 -1
  21. package/dist/{chunk-MXZSDGZQ.js → chunk-NMFDC2W2.js} +4 -6
  22. package/dist/{chunk-5SLENAJW.js → chunk-PAJ44TFW.js} +1 -2
  23. package/dist/{chunk-L7QGGKJ2.js → chunk-PDQFQIQW.js} +1 -1
  24. package/dist/{chunk-WJ6FLKNC.js → chunk-R3XAOMKP.js} +14 -0
  25. package/dist/{chunk-2OKB27TG.js → chunk-RXTN2CW6.js} +2 -2
  26. package/dist/{chunk-XWWLKRNU.js → chunk-TVIU23OM.js} +38 -49
  27. package/dist/chunk-XX4GXKTX.js +35 -0
  28. package/dist/chunk-Z67Q5KUW.js +16 -0
  29. package/dist/{chunk-3VRMKFM7.js → chunk-ZDJNFA52.js} +11 -24
  30. package/dist/cinema-media-C7OUPNSH.js +12 -0
  31. package/dist/cli.js +18 -9
  32. package/dist/comparison-GNZOR7MF.js +37 -0
  33. package/dist/compose-video-TBFTONUC.js +12 -0
  34. package/dist/editorial-timeline-EMV5335S.js +43 -0
  35. package/dist/{events-BQ6z264n.d.ts → events-B4YCc4vc.d.ts} +1 -1
  36. package/dist/index.d.ts +4 -6
  37. package/dist/index.js +3 -7
  38. package/dist/key-figure-P37VK425.js +30 -0
  39. package/dist/{kit-tQnCPMOM.d.ts → kit-DrRpdn0p.d.ts} +2 -2
  40. package/dist/mobile-message-OF7T62B7.js +50 -0
  41. package/dist/quote-T6WYLN7A.js +33 -0
  42. package/dist/react.d.ts +21 -11
  43. package/dist/react.js +585 -826
  44. package/dist/scene-video-backdrop-PCTARAAJ.js +7 -0
  45. package/dist/server.d.ts +7 -8
  46. package/dist/server.js +179 -84
  47. package/dist/{system-prompt-RRXIWDDD.js → system-prompt-SYRT5DWM.js} +1 -1
  48. package/dist/template-catalog.d.ts +392 -16
  49. package/dist/template-catalog.js +1 -1
  50. package/dist/templates.d.ts +5 -5
  51. package/dist/test.d.ts +3 -3
  52. package/dist/test.js +18 -18
  53. package/dist/text-stream-LD364KBI.js +9 -0
  54. package/dist/{types-DWFO6qca.d.ts → types-CdBmNTGD.d.ts} +1 -1
  55. package/dist/{types-CEh9eUFu.d.ts → types-DdZw4GRQ.d.ts} +17 -48
  56. package/dist/validate-4OUD2CLX.js +10 -0
  57. package/docs/architecture.md +1 -1
  58. package/docs/concepts.md +1 -1
  59. package/docs/custom-templates.md +13 -28
  60. package/docs/customization.md +11 -59
  61. package/docs/getting-started.md +2 -2
  62. package/docs/immersive-interface.md +3 -4
  63. package/docs/maintainers/cinematic-migration.md +38 -0
  64. package/docs/media-and-audio.md +14 -14
  65. package/docs/motion-and-effects.md +6 -14
  66. package/docs/persistence.md +3 -3
  67. package/docs/production.md +11 -9
  68. package/docs/provider-integration.md +9 -16
  69. package/docs/reference/design-system.html +1 -1
  70. package/docs/reference/protocol.md +14 -4
  71. package/docs/testing.md +1 -1
  72. package/package.json +6 -3
  73. package/registry/items/backgrounds.json +1 -1
  74. package/registry/items/chapterTitle.json +80 -0
  75. package/registry/items/cinemaMedia.json +136 -0
  76. package/registry/items/comparison.json +168 -0
  77. package/registry/items/editorialTimeline.json +172 -0
  78. package/registry/items/keyFigure.json +162 -0
  79. package/registry/items/mobileMessage.json +153 -0
  80. package/registry/items/quote.json +161 -0
  81. package/registry/items/template-context.json +1 -1
  82. package/registry/items/theme.json +1 -1
  83. package/starters/video-chat/README.md +24 -26
  84. package/starters/video-chat/package.json +1 -1
  85. package/starters/video-chat/providers/video.ts +6 -5
  86. package/starters/video-chat/stock.ts +35 -151
  87. package/styles/fonts/OFL.txt +93 -0
  88. package/styles/fonts/manifest.json +66 -0
  89. package/styles/fonts/roboto-v51-cyrillic-ext.woff2 +0 -0
  90. package/styles/fonts/roboto-v51-cyrillic.woff2 +0 -0
  91. package/styles/fonts/roboto-v51-greek-ext.woff2 +0 -0
  92. package/styles/fonts/roboto-v51-greek.woff2 +0 -0
  93. package/styles/fonts/roboto-v51-latin-ext.woff2 +0 -0
  94. package/styles/fonts/roboto-v51-latin.woff2 +0 -0
  95. package/styles/fonts/roboto-v51-math.woff2 +0 -0
  96. package/styles/fonts/roboto-v51-symbols.woff2 +0 -0
  97. package/styles/fonts/roboto-v51-vietnamese.woff2 +0 -0
  98. package/styles/fonts/roboto.css +91 -0
  99. package/styles/video-chat.css +30 -22
  100. package/dist/bg-confetti-HITCGLGD.js +0 -89
  101. package/dist/bg-emoji-VU4UZYZN.js +0 -150
  102. package/dist/bg-media-L34PDQXJ.js +0 -106
  103. package/dist/brand-message-FUJ4STFO.js +0 -256
  104. package/dist/chart-bar-EGPHJATL.js +0 -310
  105. package/dist/chart-counter-5FFWQNZO.js +0 -306
  106. package/dist/chart-progress-ring-JMXQLMLC.js +0 -302
  107. package/dist/chunk-4UNKZEAT.js +0 -3575
  108. package/dist/chunk-5CDAM24P.js +0 -31
  109. package/dist/chunk-AOWSXU2K.js +0 -18
  110. package/dist/chunk-CJ7F2CE6.js +0 -104
  111. package/dist/chunk-FRN6WKHA.js +0 -185
  112. package/dist/chunk-G5JPHBX7.js +0 -336
  113. package/dist/chunk-L5BTTCZV.js +0 -97
  114. package/dist/chunk-P22HHFDK.js +0 -43
  115. package/dist/chunk-PP3MCPN4.js +0 -1998
  116. package/dist/chunk-QAAO7OAY.js +0 -19
  117. package/dist/chunk-S7HFLYNN.js +0 -35
  118. package/dist/chunk-W3VDIBGR.js +0 -217
  119. package/dist/chunk-XGRA2MUV.js +0 -242
  120. package/dist/chunk-XTOXFMLM.js +0 -105
  121. package/dist/chunk-YJJC4N4D.js +0 -761
  122. package/dist/compose-video-2NFH4DZY.js +0 -13
  123. package/dist/cta-logo-YR7LYUR5.js +0 -212
  124. package/dist/cta-media-DQJBKUO2.js +0 -221
  125. package/dist/incoming-call-54KQ7O5A.js +0 -323
  126. package/dist/infographic-before-after-ROS52GOW.js +0 -460
  127. package/dist/infographic-feature-list-E7MGUDAN.js +0 -272
  128. package/dist/infographic-problem-solution-3S6NGO5N.js +0 -343
  129. package/dist/infographic-stat-row-SYB7AB7H.js +0 -247
  130. package/dist/infographic-steps-KCE6JWE2.js +0 -406
  131. package/dist/prompt-input-MHX4O42G.js +0 -239
  132. package/dist/reaction-SLEGR3BE.js +0 -122
  133. package/dist/scene-video-backdrop-XFPX4O3I.js +0 -10
  134. package/dist/showcase-code-2HLAVKBM.js +0 -357
  135. package/dist/showcase-phone-Q4HEO4LH.js +0 -278
  136. package/dist/showcase-terminal-DL45LUFG.js +0 -312
  137. package/dist/showcase-web-2QZO73FZ.js +0 -396
  138. package/dist/social-conversation-75SD2637.js +0 -695
  139. package/dist/social-milestone-GEFUQSBF.js +0 -296
  140. package/dist/social-notification-FJ5VHVLK.js +0 -247
  141. package/dist/social-review-stack-KXQCKFRP.js +0 -242
  142. package/dist/social-testimonial-JZ7CHC7S.js +0 -287
  143. package/dist/social-tweet-UCDXM25F.js +0 -298
  144. package/dist/text-stream-54LXABJW.js +0 -10
  145. package/dist/validate-T7GBU2YF.js +0 -8
  146. package/registry/items/barChart.json +0 -245
  147. package/registry/items/beforeAfter.json +0 -180
  148. package/registry/items/bigNumber.json +0 -232
  149. package/registry/items/brandMessage.json +0 -164
  150. package/registry/items/cardList.json +0 -214
  151. package/registry/items/chatMessenger.json +0 -151
  152. package/registry/items/chatWhatsapp.json +0 -151
  153. package/registry/items/codeEditor.json +0 -191
  154. package/registry/items/confetti.json +0 -107
  155. package/registry/items/ctaLogo.json +0 -167
  156. package/registry/items/ctaMedia.json +0 -200
  157. package/registry/items/emojiBurst.json +0 -101
  158. package/registry/items/incomingCall.json +0 -177
  159. package/registry/items/media.json +0 -187
  160. package/registry/items/milestone.json +0 -212
  161. package/registry/items/notification.json +0 -189
  162. package/registry/items/phoneMockup.json +0 -261
  163. package/registry/items/problemSolution.json +0 -193
  164. package/registry/items/progressRing.json +0 -206
  165. package/registry/items/promptInput.json +0 -155
  166. package/registry/items/reaction.json +0 -176
  167. package/registry/items/reviewStack.json +0 -231
  168. package/registry/items/steps.json +0 -215
  169. package/registry/items/terminal.json +0 -219
  170. package/registry/items/testimonial.json +0 -171
  171. package/registry/items/tripleStats.json +0 -235
  172. package/registry/items/tweet.json +0 -210
  173. package/registry/items/webMockup.json +0 -280
@@ -1,761 +0,0 @@
1
- import {
2
- Emoji,
3
- planTypewriterEmoji,
4
- renderWithEmoji
5
- } from "./chunk-L5BTTCZV.js";
6
- import {
7
- Easing,
8
- SPRING_CRISP,
9
- interpolate,
10
- spring
11
- } from "./chunk-XTOXFMLM.js";
12
- import {
13
- MEDIA_TEXT_SHADOW
14
- } from "./chunk-XWWLKRNU.js";
15
-
16
- // src/visual-system/scene-templates/text-archetypes.ts
17
- var TEXT_ARCHETYPES = [
18
- "subtle",
19
- "typewriter",
20
- "wordStagger",
21
- "slam",
22
- "cinematic",
23
- "heroWord"
24
- ];
25
- function normalizeArchetype(input) {
26
- if (typeof input !== "string" || input.length === 0) return "subtle";
27
- if (TEXT_ARCHETYPES.includes(input)) return input;
28
- return "subtle";
29
- }
30
- var ARCHETYPE_SPECS = {
31
- subtle: {
32
- name: "subtle",
33
- description: "Quiet caption. Visual is the star, text supports.",
34
- entrance: 0.5,
35
- exit: 0.7,
36
- allowedCanvas: ["tight", "open"],
37
- roles: ["body", "closer"],
38
- sizeRange: [0.7, 1],
39
- minDuration: 1.5,
40
- maxDuration: 5
41
- },
42
- typewriter: {
43
- name: "typewriter",
44
- description: "Char-by-char reveal with blinking cursor. Slide-left cascade exit, top line first.",
45
- entrance: 1.2,
46
- exit: 0.85,
47
- allowedCanvas: ["tight", "open"],
48
- roles: ["body", "hook"],
49
- sizeRange: [0.8, 1],
50
- minDuration: 1.8,
51
- maxDuration: 6
52
- },
53
- wordStagger: {
54
- name: "wordStagger",
55
- description: "Sequential word build with active-word focus. Slide-left cascade exit, top line first.",
56
- entrance: 1.4,
57
- exit: 0.7,
58
- allowedCanvas: ["tight", "open"],
59
- roles: ["body"],
60
- sizeRange: [0.8, 1],
61
- minDuration: 1.8,
62
- maxDuration: 6
63
- },
64
- slam: {
65
- name: "slam",
66
- description: "In-place impact with violent squash-and-stretch, frame shake, and letter crunch.",
67
- entrance: 0.5,
68
- exit: 0.5,
69
- allowedCanvas: ["tight", "open"],
70
- roles: ["hook", "body"],
71
- sizeRange: [0.9, 1.2],
72
- minDuration: 1.2,
73
- maxDuration: 4
74
- },
75
- cinematic: {
76
- name: "cinematic",
77
- description: "Trailer FlyIn from depth \u2192 recedes back into background.",
78
- entrance: 0.7,
79
- exit: 0.8,
80
- allowedCanvas: ["open"],
81
- roles: ["hook", "body", "closer"],
82
- sizeRange: [0.9, 1.1],
83
- minDuration: 1.8,
84
- maxDuration: 6
85
- },
86
- heroWord: {
87
- name: "heroWord",
88
- description: "Single word fills frame. Simple fast exit so words get the most time.",
89
- entrance: 0.35,
90
- exit: 0.25,
91
- allowedCanvas: ["open"],
92
- roles: ["hook", "body", "closer"],
93
- sizeRange: [2, 3],
94
- minDuration: 1,
95
- maxDuration: 5
96
- }
97
- };
98
- var ENTRANCE_START = 0.02;
99
- var ENTRANCE_PHASE_CAP = 0.4;
100
- var EXIT_PHASE_CAP = 0.4;
101
- function computePhases(spec, sceneDuration, progress, phaseScale = 1) {
102
- const entrancePhase = Math.min(ENTRANCE_PHASE_CAP, spec.entrance * phaseScale / sceneDuration);
103
- const exitPhase = Math.min(EXIT_PHASE_CAP, spec.exit * phaseScale / sceneDuration);
104
- const exitStart = 1 - exitPhase;
105
- return { entrancePhase, exitPhase, exitStart, inExit: progress >= exitStart };
106
- }
107
- function rawEntrance(progress, entrancePhase, startAt = ENTRANCE_START) {
108
- return interpolate(progress, [startAt, startAt + entrancePhase], [0, 1], {
109
- extrapolateLeft: "clamp",
110
- extrapolateRight: "clamp"
111
- });
112
- }
113
- function rawExit(progress, exitStart) {
114
- if (progress < exitStart) return 0;
115
- return interpolate(progress, [exitStart, 1], [0, 1], {
116
- extrapolateLeft: "clamp",
117
- extrapolateRight: "clamp"
118
- });
119
- }
120
- function holdT(progress, entrancePhase, exitStart, startAt = ENTRANCE_START) {
121
- const holdStart = startAt + entrancePhase;
122
- if (progress < holdStart || progress > exitStart || exitStart <= holdStart) return 0;
123
- return (progress - holdStart) / (exitStart - holdStart);
124
- }
125
- function breathe(t, magnitude, cycles = 1) {
126
- return Math.sin(t * Math.PI * 2 * cycles) * magnitude / 2;
127
- }
128
- function renderArchetype(archetypeRaw, progress, scale, text, sceneDuration, phaseScale = 1, motionProgress = progress) {
129
- const archetype = normalizeArchetype(archetypeRaw);
130
- const spec = ARCHETYPE_SPECS[archetype];
131
- const phases = computePhases(spec, sceneDuration, motionProgress, phaseScale);
132
- const presentationProgress = Math.max(progress, motionProgress);
133
- switch (archetype) {
134
- case "subtle":
135
- return renderSubtle(motionProgress, scale, text, phases);
136
- case "typewriter":
137
- return renderTypewriter(presentationProgress, motionProgress, scale, text, phases, sceneDuration);
138
- case "wordStagger":
139
- return renderWordStagger(presentationProgress, motionProgress, scale, text, sceneDuration);
140
- case "slam":
141
- return renderSlam(motionProgress, scale, text, phases);
142
- case "cinematic":
143
- return renderCinematic(motionProgress, scale, text, phases);
144
- case "heroWord":
145
- return renderHeroWord(presentationProgress, motionProgress, text, phases);
146
- }
147
- }
148
- function renderSubtle(progress, _scale, text, phases) {
149
- const raw = rawEntrance(progress, phases.entrancePhase);
150
- const ex = rawExit(progress, phases.exitStart);
151
- const opacityIn = Easing.out(Easing.cubic)(raw);
152
- const opacityOut = 1 - Easing.in(Easing.cubic)(ex);
153
- const opacity = opacityIn * (phases.inExit ? opacityOut : 1);
154
- return {
155
- kind: "block",
156
- block: {
157
- opacity,
158
- transform: "none"
159
- },
160
- text
161
- };
162
- }
163
- function renderTypewriter(progress, motionProgress, scale, text, phases, sceneDuration) {
164
- const raw = rawEntrance(progress, phases.entrancePhase);
165
- const visibleChars = Math.max(0, Math.floor(raw * text.length));
166
- const seconds = progress * sceneDuration;
167
- const cursorOn = Math.sin(seconds * Math.PI * 3) > 0;
168
- const stillTyping = visibleChars < text.length;
169
- const opacityIn = Math.min(1, raw * 8);
170
- const cursor = cursorOn && (stillTyping || !phases.inExit && opacityIn > 0.5);
171
- let charExits;
172
- if (phases.inExit && text.length > 0) {
173
- const STAGGER_OUT = 0.025;
174
- const PER_CHAR_OUT = 0.3;
175
- const SLIDE_LEFT_DISTANCE = 350 * scale;
176
- const actualExitSec = phases.exitPhase * sceneDuration;
177
- const idealExitSec = (text.length - 1) * STAGGER_OUT + PER_CHAR_OUT;
178
- const outScale = Math.min(1, actualExitSec / idealExitSec);
179
- const stagOutNorm = STAGGER_OUT * outScale / sceneDuration;
180
- const perCharOutNorm = PER_CHAR_OUT * outScale / sceneDuration;
181
- charExits = Array.from({ length: text.length }, (_, i) => {
182
- const charExitStart = phases.exitStart + i * stagOutNorm;
183
- const charExitEnd = charExitStart + perCharOutNorm;
184
- const charExitRaw = interpolate(motionProgress, [charExitStart, charExitEnd], [0, 1], {
185
- extrapolateLeft: "clamp",
186
- extrapolateRight: "clamp"
187
- });
188
- const charExitEased = Easing.in(Easing.cubic)(charExitRaw);
189
- return {
190
- opacity: 1 - charExitEased,
191
- translateX: -charExitEased * SLIDE_LEFT_DISTANCE
192
- };
193
- });
194
- }
195
- return {
196
- kind: "typewriter",
197
- visibleChars,
198
- cursor,
199
- opacity: opacityIn,
200
- transform: "none",
201
- charExits
202
- };
203
- }
204
- function renderWordStagger(progress, motionProgress, scale, text, sceneDuration) {
205
- const words = text.split(/\s+/).filter(Boolean);
206
- const wordCount = Math.max(words.length, 1);
207
- const STAGGER_MIN = 0.28;
208
- const STAGGER_MAX = 0.45;
209
- const PER_WORD_ANIM = 0.5;
210
- const minEntrance = (wordCount - 1) * STAGGER_MIN + PER_WORD_ANIM;
211
- const TARGET_ENTRANCE_FRACTION = 0.55;
212
- const targetEntrance = sceneDuration * TARGET_ENTRANCE_FRACTION;
213
- const exitSec = ARCHETYPE_SPECS.wordStagger.exit;
214
- const minHold = 0.5;
215
- const maxEntrance = Math.max(0.6, sceneDuration - exitSec - minHold);
216
- let entranceSec = Math.min(maxEntrance, Math.max(minEntrance, targetEntrance));
217
- if (wordCount > 1) {
218
- const impliedStagger = (entranceSec - PER_WORD_ANIM) / (wordCount - 1);
219
- if (impliedStagger > STAGGER_MAX) {
220
- entranceSec = (wordCount - 1) * STAGGER_MAX + PER_WORD_ANIM;
221
- }
222
- }
223
- const entrancePhase = entranceSec / sceneDuration;
224
- const exitPhase = Math.min(0.4, exitSec / sceneDuration);
225
- const exitStart = 1 - exitPhase;
226
- const staggerIn = wordCount > 1 ? (entranceSec - PER_WORD_ANIM) / (wordCount - 1) / sceneDuration : 0;
227
- const wordEntranceDur = PER_WORD_ANIM / sceneDuration;
228
- const STAGGER_OUT = 0.06;
229
- const PER_WORD_OUT = 0.32;
230
- const SLIDE_LEFT_DISTANCE = 350 * scale;
231
- const actualExitSec = exitPhase * sceneDuration;
232
- const idealExitSec = (wordCount - 1) * STAGGER_OUT + PER_WORD_OUT;
233
- const outScale = Math.min(1, actualExitSec / idealExitSec);
234
- const stagOutNorm = STAGGER_OUT * outScale / sceneDuration;
235
- const perWordOutNorm = PER_WORD_OUT * outScale / sceneDuration;
236
- const ht = holdT(motionProgress, entrancePhase, exitStart);
237
- const ACTIVE_DIM = 0.85;
238
- const perWord = words.map((w, i) => {
239
- const wordStart = ENTRANCE_START + i * staggerIn;
240
- const wordEnd = wordStart + wordEntranceDur;
241
- const wordRaw = interpolate(progress, [wordStart, wordEnd], [0, 1], {
242
- extrapolateLeft: "clamp",
243
- extrapolateRight: "clamp"
244
- });
245
- const sp = spring(wordRaw, SPRING_CRISP);
246
- const yIn = interpolate(sp, [0, 1], [55 * scale, 0]);
247
- const rotIn = interpolate(sp, [0, 1], [-3, 0]);
248
- const opacityIn = Math.min(1, wordRaw * 7);
249
- const yBreathe = breathe(ht, 1 * scale, 1) * Math.cos(i / wordCount * Math.PI);
250
- let dimProgress = 0;
251
- if (i < words.length - 1) {
252
- const nextStart = ENTRANCE_START + (i + 1) * staggerIn;
253
- const SNAP_RAMP = 0.02;
254
- dimProgress = interpolate(progress, [nextStart, nextStart + SNAP_RAMP], [0, 1], {
255
- extrapolateLeft: "clamp",
256
- extrapolateRight: "clamp"
257
- });
258
- }
259
- const focusOpacity = 1 - dimProgress * (1 - ACTIVE_DIM);
260
- const wordExitStart = exitStart + i * stagOutNorm;
261
- const wordExitEnd = wordExitStart + perWordOutNorm;
262
- const wordExitRaw = interpolate(motionProgress, [wordExitStart, wordExitEnd], [0, 1], {
263
- extrapolateLeft: "clamp",
264
- extrapolateRight: "clamp"
265
- });
266
- const wordExitEased = Easing.in(Easing.cubic)(wordExitRaw);
267
- const exitX = -wordExitEased * SLIDE_LEFT_DISTANCE;
268
- const isExiting = wordExitRaw > 0;
269
- const opacity = opacityIn * focusOpacity * (1 - wordExitEased);
270
- const y = yIn + (isExiting ? 0 : yBreathe);
271
- const rot = isExiting ? 0 : rotIn;
272
- return {
273
- text: w,
274
- style: {
275
- opacity,
276
- transform: `translate(${exitX}px, ${y}px) rotate(${rot}deg)`
277
- }
278
- };
279
- });
280
- return {
281
- kind: "words",
282
- words: perWord,
283
- blockOpacity: 1,
284
- blockTransform: "none"
285
- };
286
- }
287
- function renderSlam(progress, scale, text, phases) {
288
- const raw = rawEntrance(progress, phases.entrancePhase);
289
- const ex = rawExit(progress, phases.exitStart);
290
- const ht = holdT(progress, phases.entrancePhase, phases.exitStart);
291
- const sxIn = interpolate(raw, [0, 0.3, 0.45, 0.6, 1], [0.92, 1.22, 0.94, 1.02, 1]);
292
- const syIn = interpolate(raw, [0, 0.3, 0.45, 0.6, 1], [1.18, 0.74, 1.12, 0.99, 1]);
293
- const rotIn = interpolate(raw, [0, 0.3, 0.45, 1], [-1.5, 0, 0.8, 0]);
294
- const lsInEm = interpolate(raw, [0, 0.2, 0.3, 0.45, 1], [0, -0.04, -0.06, 0, 0]);
295
- const shakeWindow = Math.max(0, 1 - Math.max(0, raw - 0.3) / 0.2);
296
- const shakeX = Math.sin(raw * 70) * 14 * scale * shakeWindow;
297
- const shakeY = Math.cos(raw * 80) * 10 * scale * shakeWindow;
298
- const opacityIn = Math.min(1, raw * 8);
299
- const sBreathe = 1 + breathe(ht, 8e-3, 1);
300
- const easedExit = Easing.in(Easing.exp)(ex);
301
- const sOut = interpolate(easedExit, [0, 1], [1, 0.85]);
302
- const opacityOut = interpolate(ex, [0, 0.55, 1], [1, 0.8, 0], {
303
- extrapolateLeft: "clamp",
304
- extrapolateRight: "clamp"
305
- });
306
- const sx = phases.inExit ? sOut : sxIn * sBreathe;
307
- const sy = phases.inExit ? sOut : syIn * sBreathe;
308
- const tx = phases.inExit ? 0 : shakeX;
309
- const ty = phases.inExit ? 0 : shakeY;
310
- const rot = phases.inExit ? 0 : rotIn;
311
- const ls = phases.inExit ? 0 : lsInEm;
312
- const opacity = opacityIn * (phases.inExit ? opacityOut : 1);
313
- return {
314
- kind: "block",
315
- block: {
316
- opacity,
317
- transform: `translate(${tx}px, ${ty}px) rotate(${rot}deg) scale(${sx}, ${sy})`,
318
- letterSpacing: `${ls}em`
319
- },
320
- text
321
- };
322
- }
323
- function renderCinematic(progress, scale, text, phases) {
324
- const raw = rawEntrance(progress, phases.entrancePhase);
325
- const ex = rawExit(progress, phases.exitStart);
326
- const easedIn = Easing.out(Easing.circle)(raw);
327
- const sIn = interpolate(easedIn, [0, 1], [3, 1]);
328
- const yIn = interpolate(easedIn, [0, 1], [18 * scale, 0]);
329
- const opacityIn = interpolate(raw, [0, 0.4], [0, 1], {
330
- extrapolateLeft: "clamp",
331
- extrapolateRight: "clamp"
332
- });
333
- const easedExit = Easing.in(Easing.exp)(ex);
334
- const sOut = interpolate(easedExit, [0, 1], [1, 0.4]);
335
- const yOut = interpolate(easedExit, [0, 1], [0, -10 * scale]);
336
- const opacityOut = interpolate(ex, [0, 0.5, 1], [1, 0.85, 0], {
337
- extrapolateLeft: "clamp",
338
- extrapolateRight: "clamp"
339
- });
340
- const s = phases.inExit ? sOut : sIn;
341
- const y = phases.inExit ? yOut : yIn;
342
- const opacity = opacityIn * (phases.inExit ? opacityOut : 1);
343
- return {
344
- kind: "block",
345
- block: {
346
- opacity,
347
- transform: `translateY(${y}px) scale(${s})`,
348
- willChange: "transform, opacity"
349
- },
350
- text
351
- };
352
- }
353
- function renderHeroWord(progress, motionProgress, text, phases) {
354
- const words = text.split(/\s+/).filter(Boolean);
355
- if (words.length === 0) {
356
- return { kind: "hero", word: "", index: 0, total: 0, opacity: 0, transform: "scale(1)" };
357
- }
358
- const sequenceStart = ENTRANCE_START + phases.entrancePhase * 0.2;
359
- const sequenceEnd = phases.exitStart;
360
- const sequenceDur = Math.max(0.01, sequenceEnd - sequenceStart);
361
- const localProgress = Math.max(0, Math.min(0.999, (progress - sequenceStart) / sequenceDur));
362
- const idx = Math.min(words.length - 1, Math.floor(localProgress / (1 / words.length)));
363
- const local = localProgress * words.length - idx;
364
- const isLast = idx === words.length - 1;
365
- const ENTER_FRAC = 0.28;
366
- const HOLD_FRAC = 0.55;
367
- const HANDOFF_FRAC = 0.85;
368
- let scale;
369
- let opacity;
370
- if (local < ENTER_FRAC) {
371
- const entRaw = local / ENTER_FRAC;
372
- const sp = spring(entRaw, SPRING_CRISP);
373
- scale = sp < 0.7 ? interpolate(sp, [0, 0.7], [0.5, 1.06]) : interpolate(sp, [0.7, 1], [1.06, 1]);
374
- opacity = Math.min(1, entRaw * 6);
375
- } else if (local < HOLD_FRAC) {
376
- const ht = (local - ENTER_FRAC) / (HOLD_FRAC - ENTER_FRAC);
377
- scale = 1 + breathe(ht, 0.01, 1);
378
- opacity = 1;
379
- } else if (local < HANDOFF_FRAC && !isLast) {
380
- const handoffRaw = (local - HOLD_FRAC) / (HANDOFF_FRAC - HOLD_FRAC);
381
- scale = interpolate(handoffRaw, [0, 1], [1, 1.04]);
382
- opacity = handoffRaw < 0.3 ? 1 : interpolate(handoffRaw, [0.3, 1], [1, 0]);
383
- } else if (!isLast) {
384
- scale = 1.04;
385
- opacity = 0;
386
- } else {
387
- scale = 1;
388
- opacity = 1;
389
- }
390
- if (isLast && phases.inExit) {
391
- const ex = rawExit(motionProgress, phases.exitStart);
392
- const easedExit = Easing.in(Easing.cubic)(ex);
393
- scale = interpolate(easedExit, [0, 1], [1, 1.08]);
394
- opacity = 1 - easedExit;
395
- }
396
- return {
397
- kind: "hero",
398
- word: words[idx],
399
- index: idx,
400
- total: words.length,
401
- opacity,
402
- transform: `scale(${scale})`
403
- };
404
- }
405
-
406
- // src/visual-system/scene-templates/template-text.tsx
407
- import { jsx, jsxs } from "react/jsx-runtime";
408
- var DEFAULT_SAFE_ZONE = { top: 24, right: 24, bottom: 24, left: 24 };
409
- var DEFAULT_FONT = "ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif";
410
- var TYPO = {
411
- headline: {
412
- letterSpacing: "-0.022em",
413
- wordSpacing: "0.04em",
414
- lineHeight: 1.1
415
- },
416
- caption: {
417
- letterSpacing: "-0.012em",
418
- wordSpacing: "0.06em",
419
- lineHeight: 1.25
420
- },
421
- label: {
422
- letterSpacing: "-0.005em",
423
- wordSpacing: "0.10em",
424
- lineHeight: 1.4
425
- }
426
- };
427
- var FONT_FEATURES = '"kern" 1, "liga" 1';
428
- function dropShadowFor(textColor) {
429
- const dark = isLikelyDark(textColor);
430
- const tone = dark ? "rgba(255,255,255,0.15)" : "rgba(0,0,0,0.2)";
431
- return `0 1px 2px ${tone}`;
432
- }
433
- function isLikelyDark(color) {
434
- const m = color.replace("#", "");
435
- if (m.length === 3) {
436
- const r = parseInt(m[0] + m[0], 16);
437
- const g = parseInt(m[1] + m[1], 16);
438
- const b = parseInt(m[2] + m[2], 16);
439
- return (r * 299 + g * 587 + b * 114) / 1e3 < 128;
440
- }
441
- if (m.length === 6) {
442
- const r = parseInt(m.slice(0, 2), 16);
443
- const g = parseInt(m.slice(2, 4), 16);
444
- const b = parseInt(m.slice(4, 6), 16);
445
- return (r * 299 + g * 587 + b * 114) / 1e3 < 128;
446
- }
447
- return false;
448
- }
449
- function computeHeroFontSize(wordChars, position, width, height, safeZone) {
450
- const chars = Math.max(wordChars, 1);
451
- const s_min = Math.min(width, height) / 1080;
452
- const widthBudget = (width - safeZone.left - safeZone.right) * 0.92;
453
- const pxPerChar = 0.58;
454
- const widthCap = widthBudget / (chars * pxPerChar);
455
- if (position === "center") {
456
- return Math.min(480 * s_min, widthCap);
457
- }
458
- const heightCap = height * 0.28 * 0.8;
459
- return Math.min(220 * s_min, widthCap, heightCap);
460
- }
461
- function smoothSize(chars, maxChars, max, min) {
462
- const t = Math.max(0, Math.min(1, chars / maxChars));
463
- const eased = t * t;
464
- return max - (max - min) * eased;
465
- }
466
- function computeFontSize(archetype, text, role, position, width, height, safeZone) {
467
- const s_min = Math.min(width, height) / 1080;
468
- if (archetype === "heroWord") {
469
- const longestChars = text.split(/\s+/).filter(Boolean).reduce((m, w) => Math.max(m, w.length), 1);
470
- return {
471
- fontSize: computeHeroFontSize(longestChars, position, width, height, safeZone),
472
- fontWeight: 800
473
- };
474
- }
475
- const chars = text.length;
476
- if (role === "headline") {
477
- const refSize2 = smoothSize(
478
- chars,
479
- /* maxChars */
480
- 70,
481
- /* max */
482
- 88,
483
- /* min */
484
- 60
485
- );
486
- return { fontSize: refSize2 * s_min, fontWeight: 700 };
487
- }
488
- if (role === "caption") {
489
- const refSize2 = smoothSize(chars, 80, 48, 32);
490
- return { fontSize: refSize2 * s_min, fontWeight: 600 };
491
- }
492
- const refSize = smoothSize(chars, 80, 34, 24);
493
- return { fontSize: refSize * s_min, fontWeight: 500 };
494
- }
495
- function positionStyle(position, height, safeZone) {
496
- switch (position) {
497
- case "top":
498
- return {
499
- top: safeZone.top + height * 0.06,
500
- height: height * 0.28,
501
- alignItems: "flex-start"
502
- };
503
- case "bottom":
504
- return {
505
- bottom: safeZone.bottom + height * 0.06,
506
- height: height * 0.28,
507
- alignItems: "flex-end"
508
- };
509
- case "center":
510
- default:
511
- return {
512
- top: 0,
513
- bottom: 0,
514
- alignItems: "center"
515
- };
516
- }
517
- }
518
- var TemplateText = ({
519
- archetype: archetypeRaw,
520
- text: textRaw,
521
- progress,
522
- motionProgress = progress,
523
- sceneDuration,
524
- width,
525
- height,
526
- position = "center",
527
- sizeRole = "headline",
528
- typeTreatment,
529
- safeZone = DEFAULT_SAFE_ZONE,
530
- font = DEFAULT_FONT,
531
- color = "#FFFFFF",
532
- beatIntensity = 0,
533
- overMedia = false
534
- }) => {
535
- const textSafe = typeof textRaw === "string" ? textRaw : "";
536
- const isDevelopment = import.meta.env?.DEV;
537
- if (textRaw !== void 0 && typeof textRaw !== "string" && isDevelopment) {
538
- console.warn("[TemplateText] received non-string text:", textRaw);
539
- }
540
- const text = textSafe.replace(/\s*\|\s*/g, "\n");
541
- const archetype = normalizeArchetype(archetypeRaw);
542
- const scale = Math.min(width, height) / 1080;
543
- const result = renderArchetype(
544
- archetype,
545
- progress,
546
- scale,
547
- text,
548
- sceneDuration,
549
- typeTreatment?.phaseScale ?? 1,
550
- motionProgress
551
- );
552
- const { fontSize, fontWeight } = computeFontSize(
553
- archetype,
554
- text,
555
- sizeRole,
556
- position,
557
- width,
558
- height,
559
- safeZone
560
- );
561
- void beatIntensity;
562
- const baseTypo = TYPO[sizeRole];
563
- const tt = sizeRole === "headline" ? typeTreatment : void 0;
564
- const typo = tt ? {
565
- ...baseTypo,
566
- ...tt.trackingDeltaEm !== 0 ? {
567
- letterSpacing: `${Number(
568
- (parseFloat(baseTypo.letterSpacing) + tt.trackingDeltaEm).toFixed(4)
569
- )}em`
570
- } : {},
571
- ...tt.transform ? { textTransform: tt.transform } : {}
572
- } : baseTypo;
573
- const presetWeight = tt ? Math.min(900, Math.max(100, fontWeight + tt.weightDelta)) : fontWeight;
574
- const presetSize = tt ? fontSize * tt.sizeScale : fontSize;
575
- const overMediaColor = overMedia && isLikelyDark(color) ? "#FFFFFF" : color;
576
- const textShadow = overMedia ? MEDIA_TEXT_SHADOW : dropShadowFor(color);
577
- const containerStyle = {
578
- position: "absolute",
579
- left: 0,
580
- right: 0,
581
- display: "flex",
582
- justifyContent: "center",
583
- padding: `0 ${safeZone.right}px 0 ${safeZone.left}px`,
584
- color: overMediaColor,
585
- fontFamily: font,
586
- fontWeight: presetWeight,
587
- fontSize: presetSize,
588
- textAlign: "center",
589
- pointerEvents: "none",
590
- fontFeatureSettings: FONT_FEATURES,
591
- textRendering: "optimizeLegibility",
592
- WebkitFontSmoothing: "antialiased",
593
- MozOsxFontSmoothing: "grayscale",
594
- // Respect explicit newlines — the centralized `|` → `\n` conversion
595
- // above (and callers passing real newlines) rely on this. Multiple
596
- // spaces still collapse normally; only `\n` and CRLF break.
597
- whiteSpace: "pre-line",
598
- ...textShadow ? { textShadow } : {},
599
- ...typo,
600
- ...positionStyle(position, height, safeZone)
601
- };
602
- if (result.kind === "block") {
603
- return /* @__PURE__ */ jsx("div", { style: containerStyle, children: /* @__PURE__ */ jsx(
604
- "div",
605
- {
606
- style: {
607
- opacity: result.block.opacity,
608
- transform: `${result.block.transform}`,
609
- // Inherit letter-spacing from the container's typography defaults
610
- // unless the archetype explicitly overrides (e.g., for animated tracking).
611
- ...result.block.letterSpacing ? { letterSpacing: result.block.letterSpacing } : {},
612
- ...result.block.willChange ? { willChange: result.block.willChange } : {},
613
- maxWidth: "85%"
614
- },
615
- children: renderWithEmoji(result.text, fontSize)
616
- }
617
- ) });
618
- }
619
- if (result.kind === "typewriter") {
620
- const chars = text.split("");
621
- const emojiPlan = planTypewriterEmoji(text);
622
- const cursorBar = {
623
- position: "absolute",
624
- width: "0.08em",
625
- height: "0.88em",
626
- background: "currentColor",
627
- borderRadius: "0.01em",
628
- pointerEvents: "none"
629
- };
630
- return /* @__PURE__ */ jsx("div", { style: containerStyle, children: /* @__PURE__ */ jsxs(
631
- "div",
632
- {
633
- style: {
634
- opacity: result.opacity,
635
- maxWidth: "85%",
636
- whiteSpace: "pre-wrap",
637
- position: "relative"
638
- },
639
- children: [
640
- chars.map((ch, i) => {
641
- const isTyped = i < result.visibleChars;
642
- const isLastTyped = i === result.visibleChars - 1;
643
- const anchorCursor = isLastTyped && result.cursor;
644
- const charExit = result.charExits?.[i];
645
- const baseOpacity = isTyped ? 1 : 0;
646
- const finalOpacity = baseOpacity * (charExit?.opacity ?? 1);
647
- const exitStyle = charExit ? {
648
- display: "inline-block",
649
- transform: `translateX(${charExit.translateX}px)`,
650
- whiteSpace: "pre"
651
- } : null;
652
- const emojiChar = emojiPlan?.starts.get(i);
653
- if (emojiPlan?.covered.has(i)) return null;
654
- return /* @__PURE__ */ jsxs(
655
- "span",
656
- {
657
- style: {
658
- opacity: finalOpacity,
659
- position: anchorCursor ? "relative" : "static",
660
- ...exitStyle ?? {}
661
- },
662
- children: [
663
- emojiChar ? /* @__PURE__ */ jsx(Emoji, { char: emojiChar, size: fontSize }) : ch,
664
- anchorCursor && /* @__PURE__ */ jsx(
665
- "span",
666
- {
667
- "aria-hidden": true,
668
- style: {
669
- ...cursorBar,
670
- left: "100%",
671
- top: "0.08em",
672
- marginLeft: "0.12em"
673
- }
674
- }
675
- )
676
- ]
677
- },
678
- i
679
- );
680
- }),
681
- result.visibleChars === 0 && result.cursor && /* @__PURE__ */ jsx(
682
- "span",
683
- {
684
- "aria-hidden": true,
685
- style: {
686
- ...cursorBar,
687
- left: 0,
688
- top: "0.08em"
689
- }
690
- }
691
- )
692
- ]
693
- }
694
- ) });
695
- }
696
- if (result.kind === "words") {
697
- return /* @__PURE__ */ jsx("div", { style: containerStyle, children: /* @__PURE__ */ jsx(
698
- "div",
699
- {
700
- style: {
701
- opacity: result.blockOpacity,
702
- transform: `${result.blockTransform} `,
703
- maxWidth: "85%"
704
- },
705
- children: result.words.map((w, i) => /* @__PURE__ */ jsxs("span", { children: [
706
- /* @__PURE__ */ jsx(
707
- "span",
708
- {
709
- style: {
710
- display: "inline-block",
711
- opacity: w.style.opacity,
712
- transform: w.style.transform
713
- },
714
- children: renderWithEmoji(w.text, fontSize)
715
- }
716
- ),
717
- i < result.words.length - 1 ? " " : ""
718
- ] }, i))
719
- }
720
- ) });
721
- }
722
- if (result.kind === "hero") {
723
- const perWordFontSize = computeHeroFontSize(
724
- result.word.length,
725
- position,
726
- width,
727
- height,
728
- safeZone
729
- );
730
- const slotHeight = position === "center" ? 480 * scale : Math.min(220 * scale, height * 0.28 * 0.8);
731
- return /* @__PURE__ */ jsx("div", { style: { ...containerStyle, fontSize: perWordFontSize }, children: /* @__PURE__ */ jsx(
732
- "div",
733
- {
734
- style: {
735
- height: slotHeight,
736
- display: "flex",
737
- alignItems: "center",
738
- justifyContent: "center"
739
- },
740
- children: /* @__PURE__ */ jsx(
741
- "div",
742
- {
743
- style: {
744
- opacity: result.opacity,
745
- transform: `${result.transform} `,
746
- lineHeight: 1,
747
- ...result.letterSpacing ? { letterSpacing: result.letterSpacing } : {}
748
- },
749
- children: renderWithEmoji(result.word, perWordFontSize)
750
- }
751
- )
752
- }
753
- ) });
754
- }
755
- return null;
756
- };
757
-
758
- export {
759
- smoothSize,
760
- TemplateText
761
- };