@vanillaskyai/video 0.1.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.
- package/CHANGELOG.md +45 -0
- package/LICENSE +201 -0
- package/PUBLIC-API.md +276 -0
- package/README.md +152 -0
- package/SECURITY.md +22 -0
- package/SUPPORT.md +28 -0
- package/bin/vanillasky.js +3 -0
- package/dist/bg-confetti-WNQXS7ZS.js +89 -0
- package/dist/bg-emoji-ETI47GLS.js +150 -0
- package/dist/bg-media-SVUZAMGX.js +99 -0
- package/dist/brand-message-F3RD4P3P.js +253 -0
- package/dist/builtin-server-F7YXRVCH.js +8 -0
- package/dist/catalog-types-BIhSpOWK.d.ts +74 -0
- package/dist/chart-bar-CNSC7BNK.js +304 -0
- package/dist/chart-counter-MCRHKN77.js +299 -0
- package/dist/chart-progress-ring-RMI4A7ZK.js +296 -0
- package/dist/check-runtime.d.ts +15 -0
- package/dist/check-runtime.js +102 -0
- package/dist/chunk-2E6T633S.js +27 -0
- package/dist/chunk-352ZZCET.js +83 -0
- package/dist/chunk-73NTSFFI.js +81 -0
- package/dist/chunk-A2X45FET.js +46 -0
- package/dist/chunk-ABPKM4GK.js +187 -0
- package/dist/chunk-ABZACD4G.js +216 -0
- package/dist/chunk-BCRUUJ6A.js +756 -0
- package/dist/chunk-CHLGW22F.js +3551 -0
- package/dist/chunk-CJ7F2CE6.js +104 -0
- package/dist/chunk-CR7FE7BW.js +109 -0
- package/dist/chunk-E7CL7UPB.js +109 -0
- package/dist/chunk-EE6PK6XC.js +18 -0
- package/dist/chunk-ERY4S6QV.js +385 -0
- package/dist/chunk-EVG2ZYIY.js +125 -0
- package/dist/chunk-FNAEQ7QO.js +155 -0
- package/dist/chunk-FQ47WXAJ.js +38 -0
- package/dist/chunk-FSG2PYWG.js +336 -0
- package/dist/chunk-GHJEAP4O.js +504 -0
- package/dist/chunk-GRMUV7QY.js +262 -0
- package/dist/chunk-IFOW65Z6.js +205 -0
- package/dist/chunk-IXCUY3B3.js +786 -0
- package/dist/chunk-L5BTTCZV.js +97 -0
- package/dist/chunk-LMG3GHLL.js +107 -0
- package/dist/chunk-OOPIETLW.js +101 -0
- package/dist/chunk-P22HHFDK.js +43 -0
- package/dist/chunk-QAAO7OAY.js +19 -0
- package/dist/chunk-S7HFLYNN.js +35 -0
- package/dist/chunk-SPVTJH3F.js +24 -0
- package/dist/chunk-W2XJKG6C.js +3177 -0
- package/dist/chunk-XB7LH4J2.js +301 -0
- package/dist/chunk-XGRA2MUV.js +242 -0
- package/dist/chunk-XTOXFMLM.js +105 -0
- package/dist/chunk-YC5MFXA5.js +132 -0
- package/dist/cli.d.ts +1 -0
- package/dist/cli.js +1681 -0
- package/dist/compose-video-CN3VSWST.js +13 -0
- package/dist/cta-logo-SVA5GP2A.js +209 -0
- package/dist/cta-media-E7VLLK42.js +215 -0
- package/dist/events-_wfjbmEp.d.ts +81 -0
- package/dist/incoming-call-62MFZL3Z.js +320 -0
- package/dist/index.d.ts +15 -0
- package/dist/index.js +14 -0
- package/dist/infographic-before-after-AXCDAWND.js +460 -0
- package/dist/infographic-feature-list-GW5GUE6O.js +266 -0
- package/dist/infographic-problem-solution-7NURJANA.js +340 -0
- package/dist/infographic-stat-row-J7IZR6ZN.js +241 -0
- package/dist/infographic-steps-VSZM6F5M.js +400 -0
- package/dist/kit-BMNcHqa9.d.ts +79 -0
- package/dist/prompt-input-LOUCRXCY.js +236 -0
- package/dist/react.d.ts +81 -0
- package/dist/react.js +835 -0
- package/dist/reaction-QG4CYZLQ.js +119 -0
- package/dist/server.d.ts +141 -0
- package/dist/server.js +498 -0
- package/dist/showcase-code-RUTFZR3H.js +351 -0
- package/dist/showcase-phone-6CP6XEU5.js +272 -0
- package/dist/showcase-terminal-MGAEQWPR.js +306 -0
- package/dist/showcase-web-Y4W2HVRJ.js +390 -0
- package/dist/social-conversation-75SD2637.js +695 -0
- package/dist/social-milestone-XI2QE5BO.js +292 -0
- package/dist/social-notification-2UOHQCUY.js +244 -0
- package/dist/social-review-stack-FDYZGZTJ.js +239 -0
- package/dist/social-testimonial-OQ7N52GJ.js +284 -0
- package/dist/social-tweet-5OLCNPPC.js +295 -0
- package/dist/state-DZcKuS32.d.ts +3 -0
- package/dist/system-prompt-A6UXNTPK.js +8 -0
- package/dist/template-catalog.d.ts +24 -0
- package/dist/template-catalog.js +6 -0
- package/dist/templates.d.ts +25 -0
- package/dist/templates.js +19 -0
- package/dist/test.d.ts +149 -0
- package/dist/test.js +272 -0
- package/dist/text-stream-6XHC7J47.js +10 -0
- package/dist/types-B-PZR6G_.d.ts +208 -0
- package/dist/validate-T7GBU2YF.js +8 -0
- package/docs/agent-integration.md +39 -0
- package/docs/architecture.md +84 -0
- package/docs/branding-and-personalization.md +87 -0
- package/docs/concepts.md +106 -0
- package/docs/custom-templates.md +329 -0
- package/docs/customization.md +141 -0
- package/docs/errors.md +70 -0
- package/docs/getting-started.md +111 -0
- package/docs/input-and-first-scene.md +41 -0
- package/docs/integrate-nextjs.md +79 -0
- package/docs/media-and-audio.md +69 -0
- package/docs/motion-and-effects.md +107 -0
- package/docs/persistence.md +95 -0
- package/docs/production.md +122 -0
- package/docs/prompt-and-input.md +185 -0
- package/docs/provider-integration.md +115 -0
- package/docs/reference/protocol.md +96 -0
- package/docs/reference/provider-adapters.md +158 -0
- package/docs/responsive-orientation.md +37 -0
- package/docs/security.md +38 -0
- package/docs/streaming-protocol.md +15 -0
- package/docs/testing.md +137 -0
- package/docs/use-cases.md +59 -0
- package/examples/custom-template/README.md +19 -0
- package/examples/custom-template/minimal-text.tsx +82 -0
- package/examples/custom-template/structured-data.tsx +104 -0
- package/examples/custom-template/supplied-media.tsx +92 -0
- package/examples/nextjs-quickstart/.env.example +2 -0
- package/examples/nextjs-quickstart/README.md +22 -0
- package/examples/nextjs-quickstart/next-env.d.ts +4 -0
- package/examples/nextjs-quickstart/package.json +24 -0
- package/examples/nextjs-quickstart/src/app/api/video/route.ts +22 -0
- package/examples/nextjs-quickstart/src/app/layout.tsx +5 -0
- package/examples/nextjs-quickstart/src/app/page.tsx +31 -0
- package/examples/nextjs-quickstart/tsconfig.json +26 -0
- package/package.json +167 -0
- package/registry/items/backgrounds.json +52 -0
- package/registry/items/barChart.json +237 -0
- package/registry/items/beforeAfter.json +180 -0
- package/registry/items/bigNumber.json +225 -0
- package/registry/items/brandMessage.json +158 -0
- package/registry/items/cardList.json +206 -0
- package/registry/items/chatMessenger.json +151 -0
- package/registry/items/chatWhatsapp.json +151 -0
- package/registry/items/codeEditor.json +184 -0
- package/registry/items/confetti.json +107 -0
- package/registry/items/ctaLogo.json +160 -0
- package/registry/items/ctaMedia.json +193 -0
- package/registry/items/emojiBurst.json +101 -0
- package/registry/items/incomingCall.json +170 -0
- package/registry/items/media.json +179 -0
- package/registry/items/milestone.json +205 -0
- package/registry/items/motion.json +45 -0
- package/registry/items/notification.json +182 -0
- package/registry/items/phoneMockup.json +254 -0
- package/registry/items/problemSolution.json +186 -0
- package/registry/items/progressRing.json +199 -0
- package/registry/items/promptInput.json +148 -0
- package/registry/items/reaction.json +170 -0
- package/registry/items/reviewStack.json +224 -0
- package/registry/items/steps.json +207 -0
- package/registry/items/template-context.json +31 -0
- package/registry/items/terminal.json +212 -0
- package/registry/items/testimonial.json +164 -0
- package/registry/items/theme.json +47 -0
- package/registry/items/tripleStats.json +228 -0
- package/registry/items/tweet.json +203 -0
- package/registry/items/typography.json +47 -0
- package/registry/items/webMockup.json +273 -0
|
@@ -0,0 +1,199 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "https://ui.shadcn.com/schema/registry-item.json",
|
|
3
|
+
"name": "progressRing",
|
|
4
|
+
"type": "registry:block",
|
|
5
|
+
"title": "Progress ring",
|
|
6
|
+
"description": "An animated circular progress value with headline and label.",
|
|
7
|
+
"dependencies": [
|
|
8
|
+
"react"
|
|
9
|
+
],
|
|
10
|
+
"registryDependencies": [
|
|
11
|
+
"@vanillasky/backgrounds",
|
|
12
|
+
"@vanillasky/motion",
|
|
13
|
+
"@vanillasky/theme",
|
|
14
|
+
"@vanillasky/typography",
|
|
15
|
+
"@vanillasky/template-context"
|
|
16
|
+
],
|
|
17
|
+
"files": [
|
|
18
|
+
{
|
|
19
|
+
"path": "src/visual-system/scene-templates/chart-progress-ring.tsx",
|
|
20
|
+
"type": "registry:component",
|
|
21
|
+
"target": "vanillasky/scene-templates/chart-progress-ring.tsx",
|
|
22
|
+
"content": "/**\n * chart-progress-ring — circular progress indicator with text overlay.\n *\n * Large ring that fills from 0 to the target percentage as progress advances.\n * Big number in the center of the ring counts up to the value.\n * TextOverlay in the top 35% carries a message above the ring.\n * Label fades up below the ring after the draw is underway — same\n * uppercase caption treatment as chart-counter's label.\n */\nimport type { SceneTemplateProps } from \"./types\";\nimport { resolveTokens } from \"../theme\";\nimport { TemplateText } from \"./template-text\";\nimport { TOP_TEXT_AREA_RATIO } from \"../backgrounds\";\nimport { ProgressRing } from \"../primitives/charts/ProgressRing\";\nimport { SceneBackground, getMediaBackgroundProps } from \"./scene-background\";\n\n// ─── Component ──────────────────────────────────────────────────\n\nexport const ChartProgressRingTemplate: React.FC<SceneTemplateProps> = ({\n variables,\n style,\n progress,\n motionProgress = progress,\n beatIntensity,\n width,\n height,\n safeZone,\n sceneDuration,\n backgroundEffect,\n isPlaying = true,\n}) => {\n const { primary, foreground, font } = resolveTokens(style);\n const chartColor = primary;\n const textColor = foreground;\n const textsRaw = String(variables.texts || \"\");\n\n const parsedValue = Number(variables.value);\n const targetValue = Math.max(0, Math.min(100, Number.isFinite(parsedValue) ? parsedValue : 75));\n const parsedDecimalPlaces = Number(variables.decimalPlaces);\n const decimalPlaces = Number.isFinite(parsedDecimalPlaces)\n ? Math.max(0, Math.min(2, Math.trunc(parsedDecimalPlaces)))\n : undefined;\n const unit = String(variables.unit ?? \"%\");\n const label = String(variables.label ?? \"\");\n\n return (\n <div\n style={{\n width,\n height,\n backgroundColor: \"#000\",\n position: \"relative\",\n overflow: \"hidden\",\n fontFamily: font,\n }}\n >\n {/* [slot: background] */}\n <SceneBackground\n style={style}\n progress={progress}\n sceneDuration={sceneDuration}\n width={width}\n height={height}\n {...getMediaBackgroundProps(variables)}\n backgroundEffect={backgroundEffect}\n seed={textsRaw}\n isPlaying={isPlaying}\n beatIntensity={beatIntensity}\n />\n\n {/* [slot: caption] */}\n <div style={{ position: \"absolute\", top: 0, left: 0, right: 0, height: height * TOP_TEXT_AREA_RATIO, overflow: \"visible\" }}>\n <TemplateText\n motionProgress={motionProgress}\n typeTreatment={resolveTokens(style).preset.type}\n archetype=\"subtle\"\n text={String(variables.texts ?? \"\")}\n progress={progress}\n sceneDuration={sceneDuration ?? 3}\n width={width}\n height={height}\n position=\"top\"\n sizeRole=\"headline\"\n safeZone={safeZone}\n font={font}\n color={textColor}\n beatIntensity={beatIntensity}\n />\n </div>\n\n {/* [slot: hero] */}\n <ProgressRing\n progress={progress}\n motionProgress={motionProgress}\n targetValue={targetValue}\n decimalPlaces={decimalPlaces}\n unit={unit}\n chartColor={chartColor}\n textColor={textColor}\n label={label}\n font={font}\n width={width}\n height={height}\n beatIntensity={beatIntensity}\n />\n\n </div>\n );\n};\n"
|
|
23
|
+
},
|
|
24
|
+
{
|
|
25
|
+
"path": "src/visual-system/scene-templates/scene-background.tsx",
|
|
26
|
+
"type": "registry:component",
|
|
27
|
+
"target": "vanillasky/scene-templates/scene-background.tsx",
|
|
28
|
+
"content": "/**\n * SceneBackground — shared backdrop component for any scene template that\n * wants to support both a brand-color gradient and stock media (Pexels\n * photo / video) as an alternate atmosphere.\n *\n * Usage:\n * <SceneBackground\n * style={style}\n * progress={progress}\n * sceneDuration={sceneDuration}\n * width={width}\n * height={height}\n * mediaUrl={String(variables.mediaUrl || \"\")}\n * mediaType={String(variables.mediaType || \"auto\")}\n * seed={String(variables.texts || \"\")}\n * isPlaying={isPlaying}\n * />\n * ... template's content layered on top\n *\n * Behavior:\n * - Brand gradient is the always-on backdrop (uses BrandGradientOverlay).\n * - When mediaUrl is set and mediaType isn't \"gradient\", the photo/video\n * covers the gradient. Vignette + bottom-half darken give the content\n * contrast against busy footage.\n * - mediaType=\"gradient\" deliberately ignores mediaUrl and renders only\n * the brand gradient. First-class atmospheric mode.\n * - When mediaUrl is empty / 404s / Pexels search returned nothing,\n * gradient shows through cleanly (matches every other gradient-backed\n * template).\n *\n * Extracted from bg-media.tsx so any template can compose it. bg-media\n * now uses this component too — its \"media is the scene\" identity comes\n * from how it positions the title (centered, full-frame), not from\n * duplicated render logic.\n */\n\nimport React, { useEffect, useRef } from \"react\";\nimport type { TemplateStyle } from \"../template-context\";\nimport { BrandGradientOverlay } from \"../backgrounds\";\nimport { getBackgroundTransform } from \"../backgrounds\";\n\nconst VIDEO_EXTENSIONS = [\".mp4\", \".webm\", \".mov\", \".m4v\", \".avi\"];\n\nfunction isVideoUrl(url: string): boolean {\n try {\n const pathname = new URL(url).pathname.toLowerCase();\n return VIDEO_EXTENSIONS.some((ext) => pathname.endsWith(ext));\n } catch {\n const lower = url.toLowerCase();\n return VIDEO_EXTENSIONS.some((ext) => lower.endsWith(ext));\n }\n}\n\nexport type ResolvedMediaType = \"photo\" | \"video\" | \"gradient\";\n\nexport type MediaPosition = \"center\" | \"top\" | \"bottom\" | \"left\" | \"right\";\nexport type MediaTreatment = \"subtle\" | \"cinematic\" | \"text-safe\";\n\nconst MEDIA_POSITIONS: Record<MediaPosition, string> = {\n center: \"center center\",\n top: \"center top\",\n bottom: \"center bottom\",\n left: \"left center\",\n right: \"right center\",\n};\n\nexport function resolveMediaPosition(value: string): string {\n return MEDIA_POSITIONS[value as MediaPosition] ?? MEDIA_POSITIONS.center;\n}\n\nexport function resolveMediaTreatment(value: string): MediaTreatment {\n return value === \"subtle\" || value === \"text-safe\" ? value : \"cinematic\";\n}\n\nexport interface MediaTreatmentLayer {\n id: \"vignette\" | \"full-wash\" | \"center-scrim\" | \"bottom-scrim\";\n background: string;\n style?: React.CSSProperties;\n}\n\n/** Export-safe contrast recipes. Overlays only: SVG capture cannot rely on CSS filters. */\nexport function getMediaTreatmentLayers(value: string): MediaTreatmentLayer[] {\n const treatment = resolveMediaTreatment(value);\n const vignette: MediaTreatmentLayer = {\n id: \"vignette\",\n background:\n treatment === \"subtle\"\n ? \"radial-gradient(ellipse at center, transparent 45%, rgba(0,0,0,0.28) 100%)\"\n : \"radial-gradient(ellipse at center, transparent 30%, rgba(0,0,0,0.55) 80%, rgba(0,0,0,0.75) 100%)\",\n };\n if (treatment === \"subtle\") return [vignette];\n\n const cinematic: MediaTreatmentLayer[] = [\n vignette,\n {\n id: \"center-scrim\",\n background:\n treatment === \"text-safe\"\n ? \"radial-gradient(ellipse 90% 56% at 50% 50%, rgba(0,0,0,0.36) 0%, rgba(0,0,0,0.18) 55%, transparent 84%)\"\n : \"radial-gradient(ellipse 85% 50% at 50% 50%, rgba(0,0,0,0.22) 0%, rgba(0,0,0,0.10) 50%, transparent 80%)\",\n },\n {\n id: \"bottom-scrim\",\n background:\n treatment === \"text-safe\"\n ? \"linear-gradient(to top, rgba(0,0,0,0.68) 0%, transparent 100%)\"\n : \"linear-gradient(to top, rgba(0,0,0,0.5) 0%, transparent 100%)\",\n style: { top: \"55%\" },\n },\n ];\n\n if (treatment === \"text-safe\") {\n cinematic.splice(1, 0, {\n id: \"full-wash\",\n background: \"rgba(0,0,0,0.30)\",\n });\n }\n return cinematic;\n}\n\nexport function resolveMediaType(\n mediaType: string,\n mediaUrl: string,\n): ResolvedMediaType {\n if (mediaType === \"gradient\") return \"gradient\";\n if (mediaType === \"video\") return \"video\";\n if (mediaType === \"photo\") return \"photo\";\n // \"auto\" — detect from URL extension\n return mediaUrl && isVideoUrl(mediaUrl) ? \"video\" : \"photo\";\n}\n\nexport function getMediaBackgroundProps(variables: Record<string, unknown>) {\n return {\n mediaUrl: String(variables.mediaUrl || \"\"),\n mediaType: String(variables.mediaType || \"auto\"),\n mediaPoster: String(variables.mediaPoster || \"\"),\n mediaPosition: String(variables.mediaPosition || \"center\"),\n mediaTreatment: String(variables.mediaTreatment || \"cinematic\"),\n };\n}\n\nexport interface SceneBackgroundProps {\n style: TemplateStyle;\n progress: number;\n sceneDuration?: number;\n width: number;\n height: number;\n mediaUrl?: string;\n mediaType?: string;\n /** Still image URL shown while the <video> backdrop decodes its first\n * frame. Without it the element renders transparent during the\n * ~50–400ms decode window and the gradient flashes through. */\n mediaPoster?: string;\n /** Cover-crop focal anchor. Keeps the important edge/subject visible. */\n mediaPosition?: string;\n /** Overlay recipe: subtle, cinematic, or stronger text-safe contrast. */\n mediaTreatment?: string;\n /** Background motion effect (drift / pulse / Ken Burns). Applied to the photo/video. */\n backgroundEffect?: string;\n /** Stable seed for the gradient breathing animation. Pass the scene's\n * text content (or any stable string) — it's hashed deterministically. */\n seed?: number | string;\n /** Pause video when preview is paused. Defaults to true (export path). */\n isPlaying?: boolean;\n beatIntensity?: number;\n}\n\nexport const SceneBackground: React.FC<SceneBackgroundProps> = ({\n style,\n progress,\n sceneDuration,\n width: _width, // accepted for symmetry; not currently used in render\n height: _height,\n mediaUrl = \"\",\n mediaType = \"auto\",\n mediaPoster,\n mediaPosition = \"center\",\n mediaTreatment = \"cinematic\",\n backgroundEffect,\n seed,\n isPlaying = true,\n beatIntensity = 0,\n}) => {\n void _width;\n void _height;\n const resolved = resolveMediaType(mediaType, mediaUrl);\n const showMedia = resolved !== \"gradient\" && !!mediaUrl;\n const resolvedPosition = resolveMediaPosition(mediaPosition);\n const resolvedTreatment = resolveMediaTreatment(mediaTreatment);\n const treatmentLayers = getMediaTreatmentLayers(resolvedTreatment);\n\n const gradSeed =\n typeof seed === \"number\"\n ? seed\n : typeof seed === \"string\"\n ? seed.split(\"\").reduce((acc, c) => acc + c.charCodeAt(0), 0)\n : 0;\n\n const bgTransform = getBackgroundTransform(\n backgroundEffect,\n progress,\n beatIntensity,\n );\n\n // Video playback control — same pause/seek logic bg-media used pre-extract.\n const videoRef = useRef<HTMLVideoElement>(null);\n const lastProgress = useRef(progress);\n const videoStarted = useRef(false);\n\n useEffect(() => {\n const vid = videoRef.current;\n if (!vid) return;\n if (!isPlaying) {\n vid.pause();\n videoStarted.current = false;\n return;\n }\n const progressChanged = Math.abs(progress - lastProgress.current) > 0.001;\n lastProgress.current = progress;\n if (progressChanged && !videoStarted.current) {\n vid.playbackRate = 1;\n vid.currentTime = 0;\n vid.play().catch(() => {});\n videoStarted.current = true;\n } else if (!progressChanged && videoStarted.current) {\n vid.pause();\n videoStarted.current = false;\n }\n }, [progress, isPlaying]);\n\n // Release the decoder on unmount. Without this, iOS Safari keeps the\n // video's decoder buffer alive after the React node is gone — each\n // scene transition (or play/pause/play cycle that remounts the active\n // scene) leaks one decoder, eventually crossing the renderer's memory\n // ceiling and triggering \"A problem repeatedly occurred.\" Same recipe\n // as #409's CanvasPreview preload cleanup: pause → clear src → load().\n // Capture the ref at mount-time so the cleanup uses the same node we\n // mounted (the ref's .current is stale by unmount).\n useEffect(() => {\n const vid = videoRef.current;\n return () => {\n if (!vid) return;\n vid.pause();\n vid.removeAttribute(\"src\");\n vid.load();\n };\n }, []);\n\n return (\n <>\n <BrandGradientOverlay\n style={style}\n progress={progress}\n sceneDuration={sceneDuration}\n seed={gradSeed}\n />\n\n {showMedia &&\n (resolved === \"video\" ? (\n <video\n ref={videoRef}\n src={mediaUrl}\n // Poster paints during the decode window so the user sees the\n // (still) first frame instead of a transparent <video> letting\n // the brand gradient show through. Pexels returns a thumbnail\n // image alongside each video; fillPexelsUrls stores it in\n // `variables.mediaPoster`. Layered defense alongside preload=\"auto\"\n // below: on desktop the byte preloader makes decode fast, on\n // mobile (where the preloader skips video pre-mounting to dodge\n // the iOS Safari memory crash) the poster is the primary shield.\n poster={mediaPoster || undefined}\n muted\n loop\n playsInline\n // preload=\"auto\" — without it, browsers default to \"metadata\":\n // they only load the container/dimensions, not the byte stream\n // needed to decode frames. The element then renders transparent\n // until the first decoded frame arrives, letting the brand\n // gradient flash through whenever a scene mid-playback transitions\n // to a media backdrop. The parent preloader caches the bytes, but\n // decoder state is per-element, so the active mount still has to\n // decode the first frame; \"auto\" kicks that work off the instant\n // the element mounts.\n preload=\"auto\"\n data-media-position={mediaPosition}\n style={{\n position: \"absolute\",\n inset: 0,\n width: \"100%\",\n height: \"100%\",\n objectFit: \"cover\",\n objectPosition: resolvedPosition,\n transform: bgTransform.transform,\n transformOrigin: bgTransform.transformOrigin,\n }}\n />\n ) : (\n <div\n data-media-position={mediaPosition}\n style={{\n position: \"absolute\",\n inset: 0,\n transform: bgTransform.transform,\n transformOrigin: bgTransform.transformOrigin,\n backgroundImage: `url(${mediaUrl})`,\n backgroundSize: \"cover\",\n backgroundPosition: resolvedPosition,\n }}\n />\n ))}\n\n {showMedia &&\n treatmentLayers.map((layer) => (\n <div\n key={layer.id}\n data-media-treatment={resolvedTreatment}\n data-media-overlay={layer.id}\n style={{\n position: \"absolute\",\n inset: 0,\n background: layer.background,\n pointerEvents: \"none\",\n ...layer.style,\n }}\n />\n ))}\n </>\n );\n};\n"
|
|
29
|
+
},
|
|
30
|
+
{
|
|
31
|
+
"path": "src/visual-system/primitives/charts/ProgressRing.tsx",
|
|
32
|
+
"type": "registry:component",
|
|
33
|
+
"target": "vanillasky/primitives/charts/ProgressRing.tsx",
|
|
34
|
+
"content": "/**\n * ProgressRing\n *\n * Circular progress ring fills 0→targetValue over scene progress 0.05–0.75,\n * with the value counting up in the center. Subtle radial glow behind the\n * ring uses chartColor. Beat pulse on stroke width.\n *\n * chart-progress-ring.tsx is refactored to consume this; both paths render\n * byte-identical DOM.\n */\n\nimport { interpolate } from \"../../motion\";\nimport { withOpacity } from \"../../theme\";\nimport { getResponsiveFontSize, stripPipe } from \"../../typography\";\nimport { TOKEN_DEFAULTS } from \"../../theme\";\n\n// ─── Typed component (direct use from templates) ────────────────\n\nexport interface ProgressRingProps {\n progress: number;\n motionProgress?: number;\n /** Target percentage (0-100) the ring fills to */\n targetValue: number;\n /** Optional source precision override, including meaningful trailing zeros. */\n decimalPlaces?: number;\n /** Suffix after the number (e.g. \"%\", \"x\") */\n unit?: string;\n /** Ring stroke + accent color (e.g. \"#00e5a0\"). Default \"#ffffff\". */\n chartColor?: string;\n /** Center number color. Default \"#ffffff\". */\n textColor?: string;\n /** Optional caption below the ring. */\n label?: string;\n /** Font used by the caption. */\n font?: string;\n /** Frame width */\n width: number;\n /** Frame height */\n height: number;\n /** Beat pulse 0→1 */\n beatIntensity?: number;\n}\n\nexport const ProgressRing: React.FC<ProgressRingProps> = ({\n progress,\n motionProgress = progress,\n targetValue,\n decimalPlaces,\n unit = \"%\",\n chartColor = \"#ffffff\",\n textColor = \"#ffffff\",\n label: rawLabel = \"\",\n font = TOKEN_DEFAULTS.font,\n width,\n height,\n beatIntensity = 0,\n}) => {\n const s = Math.min(width, height) / 1080;\n const label = stripPipe(String(rawLabel || \"\"));\n\n // Ring geometry\n const radius = Math.min(width, height) * 0.2;\n const circumference = 2 * Math.PI * radius;\n const cx = width / 2;\n const cy = height / 2;\n const strokeW = 34 * s;\n\n // Fill animation\n const fillPercent = interpolate(progress, [0.05, 0.75], [0, targetValue], {\n extrapolateLeft: \"clamp\",\n extrapolateRight: \"clamp\",\n });\n const dashOffset = circumference * (1 - fillPercent / 100);\n // Fractional targets keep their precision (2.5 → \"2.5\", 99.9 → \"99.9\",\n // 99.97 → \"99.97\" — never round up to a lying \"100.0\"); integer targets\n // stay clean (\"80\"). Decimal count follows the target, capped at 2.\n const targetDecimals = Number.isFinite(decimalPlaces)\n ? Math.max(0, Math.min(2, Math.trunc(decimalPlaces ?? 0)))\n : Number.isInteger(targetValue)\n ? 0\n : Math.min(2, (String(targetValue).split(\".\")[1] || \"1\").length);\n const displayNumber = targetDecimals === 0\n ? String(Math.round(fillPercent))\n : fillPercent.toFixed(targetDecimals);\n const targetDisplayNumber = targetDecimals === 0\n ? String(Math.round(targetValue))\n : targetValue.toFixed(targetDecimals);\n const semanticValueIsTransient = displayNumber !== targetDisplayNumber;\n const beatStroke = strokeW + beatIntensity * 4 * s;\n const labelFontSize = getResponsiveFontSize(label, width, \"subtitle\", height) * 1.3;\n const labelOpacity = interpolate(motionProgress, [0.35, 0.55], [0, 1], {\n extrapolateLeft: \"clamp\",\n extrapolateRight: \"clamp\",\n });\n const labelRise = interpolate(motionProgress, [0.35, 0.55], [16 * s, 0], {\n extrapolateLeft: \"clamp\",\n extrapolateRight: \"clamp\",\n });\n\n return (\n <>\n {/* Subtle radial glow behind ring */}\n <div\n style={{\n position: \"absolute\",\n top: cy - radius * 1.2,\n left: cx - radius * 1.2,\n width: radius * 2.4,\n height: radius * 2.4,\n borderRadius: \"50%\",\n background: `radial-gradient(circle at 50% 50%, ${withOpacity(chartColor, 0.08)} 0%, transparent 70%)`,\n pointerEvents: \"none\",\n }}\n />\n\n <svg\n viewBox={`0 0 ${width} ${height}`}\n style={{\n position: \"absolute\",\n inset: 0,\n width,\n height,\n }}\n >\n {/* Background track ring */}\n <circle\n cx={cx}\n cy={cy}\n r={radius}\n fill=\"none\"\n stroke={withOpacity(chartColor, 0.1)}\n strokeWidth={strokeW}\n />\n {/* Animated fill ring */}\n <circle\n cx={cx}\n cy={cy}\n r={radius}\n fill=\"none\"\n stroke={chartColor}\n strokeWidth={beatStroke}\n strokeLinecap=\"round\"\n strokeDasharray={circumference}\n strokeDashoffset={dashOffset}\n transform={`rotate(-90, ${cx}, ${cy})`}\n style={{ transition: \"none\" }}\n />\n </svg>\n\n {/* Number in center of ring */}\n <div\n data-transition-semantic={semanticValueIsTransient ? \"transient\" : undefined}\n style={{\n position: \"absolute\",\n left: cx - radius,\n top: cy - radius,\n width: radius * 2,\n height: radius * 2,\n display: \"flex\",\n alignItems: \"center\",\n justifyContent: \"center\",\n pointerEvents: \"none\",\n ...(semanticValueIsTransient\n ? { visibility: \"var(--vanillasky-transition-semantic-visibility,visible)\" as React.CSSProperties[\"visibility\"] }\n : {}),\n }}\n >\n <span\n style={{\n fontSize: 120 * s,\n fontWeight: 800,\n color: textColor,\n lineHeight: 1,\n }}\n >\n {displayNumber}\n </span>\n <span\n style={{\n fontSize: 56 * s,\n fontWeight: 700,\n color: chartColor,\n marginLeft: 4 * s,\n }}\n >\n {unit}\n </span>\n </div>\n\n {label && (\n <div\n style={{\n position: \"absolute\",\n top: cy + radius + 48 * s,\n left: 0,\n right: 0,\n display: \"flex\",\n justifyContent: \"center\",\n pointerEvents: \"none\",\n }}\n >\n <div\n style={{\n fontSize: labelFontSize,\n color: withOpacity(textColor, 0.6),\n textTransform: \"uppercase\",\n letterSpacing: 2 * s,\n textAlign: \"center\",\n maxWidth: \"80%\",\n opacity: labelOpacity,\n transform: `translateY(${labelRise}px)`,\n fontFamily: font,\n }}\n >\n {label}\n </div>\n </div>\n )}\n </>\n );\n};\n"
|
|
35
|
+
},
|
|
36
|
+
{
|
|
37
|
+
"path": "src/visual-system/scene-templates/template-text.tsx",
|
|
38
|
+
"type": "registry:component",
|
|
39
|
+
"target": "vanillasky/scene-templates/template-text.tsx",
|
|
40
|
+
"content": "/**\n * TemplateText — unified text component for scene templates.\n *\n * Replaces the per-template hand-rolled text rendering with a single component\n * that owns: archetype motion lifecycle (entrance + hold + exit), font sizing,\n * position, beat pulse, and safe zone.\n *\n * Each template declares its constraints (position + sizeRole) at the call site;\n * the user/AI picks the archetype. Templates that can only show text at the top\n * just always pass position=\"top\".\n *\n * Example — a data template (caption above a chart):\n *\n * <TemplateText\n * archetype={textArchetype}\n * text={variables.title}\n * progress={progress}\n * sceneDuration={sceneDuration}\n * width={width}\n * height={height}\n * position=\"top\"\n * sizeRole=\"caption\"\n * />\n *\n * Example — a media template (full-frame headline):\n *\n * <TemplateText\n * archetype={textArchetype}\n * text={variables.headline}\n * progress={progress}\n * sceneDuration={sceneDuration}\n * width={width}\n * height={height}\n * position=\"center\"\n * sizeRole=\"headline\"\n * beatIntensity={beatIntensity}\n * />\n *\n * Note: `textArchetype` is destructured from props (a scene-level\n * field on `SceneTemplateProps`), NOT read from `variables`. Copying\n * the wrong pattern silently no-ops — the executor routes\n * `setSceneVariable(\"textArchetype\", ...)` to the scene-level field,\n * never into variables, so `variables.textArchetype` is always\n * undefined.\n */\n\nimport {\n renderArchetype,\n normalizeArchetype,\n type TextArchetype,\n type ArchetypeRender,\n} from \"../typography\";\nimport type { TypeTreatment } from \"../theme\";\nimport { renderWithEmoji, planTypewriterEmoji } from \"../emoji/emoji-text\";\nimport { Emoji } from \"../emoji\";\n\nexport type TextPosition = \"top\" | \"center\" | \"bottom\";\nexport type TextSizeRole = \"headline\" | \"caption\" | \"label\";\n\nexport interface SafeZone {\n top: number;\n right: number;\n bottom: number;\n left: number;\n}\n\nexport interface TemplateTextProps {\n archetype: TextArchetype;\n text: string;\n /** Scene progress 0→1. */\n progress: number;\n /** Presentation clock; VideoFrame keeps it on the complete scene timeline. */\n motionProgress?: number;\n /** Scene duration in seconds — drives entrance/exit phase scaling. */\n sceneDuration: number;\n /** Frame width in pixels (1080 in production, smaller in previews). */\n width: number;\n /** Frame height in pixels (1920 in production). */\n height: number;\n /** Where the text box sits in the frame. Templates declare this. */\n position?: TextPosition;\n /** Size envelope. Templates declare this. */\n sizeRole?: TextSizeRole;\n /** Preset type treatment — weight/tracking/size/case shift from style.preset. */\n typeTreatment?: TypeTreatment;\n /** Padding from frame edges. Defaults to a 24px box. */\n safeZone?: SafeZone;\n /** Font family. */\n font?: string;\n /** Fill color. */\n color?: string;\n /** Beat intensity 0→1 (currently unused — kept for forward compat). */\n beatIntensity?: number;\n}\n\nconst DEFAULT_SAFE_ZONE: SafeZone = { top: 24, right: 24, bottom: 24, left: 24 };\nconst DEFAULT_FONT =\n \"ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif\";\n\n// ─── Typography constants ───────────────────────────────────────\n// All em-based so they scale with font size and behave consistently across\n// font families. Values from print/motion-design conventions:\n//\n// - Big text (display/headline) gets TIGHTER tracking and TIGHTER leading.\n// -0.022em (≈ -2.2%) is the sweet spot for 48–88px headlines on most\n// sans-serifs (Inter, Helvetica, SF Pro, Manrope, Geist).\n// - Word-spacing kept subtle (≤0.08em). CSS word-spacing is ADDITIVE on\n// top of the natural space char, so what looks like \"a touch of\n// rhythm\" in print becomes a visible double-gap on 80px motion\n// headlines (especially under wordStagger, where each word renders\n// as an inline-block and the gap between them is preserved). Old\n// values (0.16/0.18/0.22 em) added ~13–18px per gap on display\n// type — the \"too much space between words\" symptom.\n// - Line-height 1.1 for headlines, 1.5 for body — Bringhurst-aligned ratios.\n// - kern + liga always on so any font's pair-kerning and ligatures fire\n// consistently (works across Inter, Manrope, SF, IBM Plex, etc.).\nconst TYPO = {\n headline: {\n letterSpacing: \"-0.022em\",\n wordSpacing: \"0.04em\",\n lineHeight: 1.1,\n },\n caption: {\n letterSpacing: \"-0.012em\",\n wordSpacing: \"0.06em\",\n lineHeight: 1.25,\n },\n label: {\n letterSpacing: \"-0.005em\",\n wordSpacing: \"0.10em\",\n lineHeight: 1.4,\n },\n};\nconst FONT_FEATURES = '\"kern\" 1, \"liga\" 1';\n\n// Drop shadow tuned to give crisp edges on retina without muddying text on\n// saturated gradients. Earlier two-layer shadow (1px tight + 16px wide) cast\n// dark halos that made gradient-backed text look smudged. A single barely-\n// there shadow is enough for edge definition; bg-media adds its own dark\n// scrim for legibility over photos, so we don't need to compensate here.\nfunction dropShadowFor(textColor: string): string {\n const dark = isLikelyDark(textColor);\n const tone = dark ? \"rgba(255,255,255,0.15)\" : \"rgba(0,0,0,0.2)\";\n return `0 1px 2px ${tone}`;\n}\n\nfunction isLikelyDark(color: string): boolean {\n // Crude luminance check — handles #rrggbb and #rgb. Anything we can't parse\n // (named colors, rgb()) defaults to \"not dark\" so the heavier shadow shows.\n const m = color.replace(\"#\", \"\");\n if (m.length === 3) {\n const r = parseInt(m[0] + m[0], 16);\n const g = parseInt(m[1] + m[1], 16);\n const b = parseInt(m[2] + m[2], 16);\n return (r * 299 + g * 587 + b * 114) / 1000 < 128;\n }\n if (m.length === 6) {\n const r = parseInt(m.slice(0, 2), 16);\n const g = parseInt(m.slice(2, 4), 16);\n const b = parseInt(m.slice(4, 6), 16);\n return (r * 299 + g * 587 + b * 114) / 1000 < 128;\n }\n return false;\n}\n// ─── Font sizing matrix ─────────────────────────────────────────\n// Mirrors what production templates actually render today, ported from:\n// - text-overlay.tsx (headline: 80/64/48 × s_min by char count)\n// - infographic-steps.tsx (caption: ~44 × s_min capped by layout)\n\n/**\n * Compute heroWord font size for a single word. Each active word fills its\n * own moment — trailer convention. Center can go large (480ref cap); top\n * stays inside the top zone height so it doesn't crash into the animation\n * or data viz below.\n */\nfunction computeHeroFontSize(\n wordChars: number,\n position: TextPosition,\n width: number,\n height: number,\n safeZone: SafeZone,\n): number {\n const chars = Math.max(wordChars, 1);\n const s_min = Math.min(width, height) / 1080;\n const widthBudget = (width - safeZone.left - safeZone.right) * 0.92;\n const pxPerChar = 0.58; // bold sans-serif approximation\n const widthCap = widthBudget / (chars * pxPerChar);\n\n if (position === \"center\") {\n return Math.min(480 * s_min, widthCap);\n }\n\n // Top/bottom: keep the word inside its zone (~28% of frame height) with\n // 80% headroom for entrance overshoot + breathe. Reference target 220ref\n // so even short words stay big without overflowing the zone.\n const heightCap = height * 0.28 * 0.8;\n return Math.min(220 * s_min, widthCap, heightCap);\n}\n\n/**\n * Smooth interpolation between max and min font size based on character count.\n * Avoids the visible \"jump\" you get from bucket boundaries when copy length\n * crosses a threshold (e.g., 25→26 chars dropping headline from 80px to 64px).\n *\n * Exported so templates that lay out their own text can match the headline\n * curve instead of inventing their own bucketed scaling.\n *\n * Returns size at 1080-reference scale; caller multiplies by s_min.\n */\nexport function smoothSize(chars: number, maxChars: number, max: number, min: number): number {\n const t = Math.max(0, Math.min(1, chars / maxChars));\n // Slight curve so short text stays at maxSize longer before scaling down.\n const eased = t * t;\n return max - (max - min) * eased;\n}\n\nfunction computeFontSize(\n archetype: TextArchetype,\n text: string,\n role: TextSizeRole,\n position: TextPosition,\n width: number,\n height: number,\n safeZone: SafeZone,\n): { fontSize: number; fontWeight: number } {\n const s_min = Math.min(width, height) / 1080;\n\n // heroWord container fontSize uses the longest word as a safe fallback. The\n // ACTIVE-word size is recomputed per-render in the \"hero\" render branch\n // (via computeHeroFontSize) so each word fills its own moment optimally —\n // trailer convention.\n if (archetype === \"heroWord\") {\n const longestChars = text\n .split(/\\s+/)\n .filter(Boolean)\n .reduce((m, w) => Math.max(m, w.length), 1);\n return {\n fontSize: computeHeroFontSize(longestChars, position, width, height, safeZone),\n fontWeight: 800,\n };\n }\n\n const chars = text.length;\n\n // Smooth scaling, minimums set so even long copy stays readable in production\n // (1080 reference). Numbers tuned to match — but improve on — the previous\n // bucketed system.\n if (role === \"headline\") {\n // Floor 60 (was 48) — matches the typography guideline \"Titles/headlines\n // 60-86px at 1080\" and lifts long-copy headlines off the body-text floor\n // that left ProblemSolution-shaped statements feeling small. Max held at\n // 88 so short, punchy headlines still fill the frame.\n const refSize = smoothSize(chars, /* maxChars */ 70, /* max */ 88, /* min */ 60);\n return { fontSize: refSize * s_min, fontWeight: 700 };\n }\n\n if (role === \"caption\") {\n const refSize = smoothSize(chars, 80, 48, 32);\n return { fontSize: refSize * s_min, fontWeight: 600 };\n }\n\n // label\n const refSize = smoothSize(chars, 80, 34, 24);\n return { fontSize: refSize * s_min, fontWeight: 500 };\n}\n\n// ─── Positioning ───────────────────────────────────────────────\n\nfunction positionStyle(\n position: TextPosition,\n height: number,\n safeZone: SafeZone,\n): React.CSSProperties {\n switch (position) {\n case \"top\":\n return {\n top: safeZone.top + height * 0.06,\n height: height * 0.28,\n alignItems: \"flex-start\",\n };\n case \"bottom\":\n return {\n bottom: safeZone.bottom + height * 0.06,\n height: height * 0.28,\n alignItems: \"flex-end\",\n };\n case \"center\":\n default:\n return {\n top: 0,\n bottom: 0,\n alignItems: \"center\",\n };\n }\n}\n\n// ─── Component ─────────────────────────────────────────────────\n\nexport const TemplateText: React.FC<TemplateTextProps> = ({\n archetype: archetypeRaw,\n text: textRaw,\n progress,\n motionProgress = progress,\n sceneDuration,\n width,\n height,\n position = \"center\",\n sizeRole = \"headline\",\n typeTreatment,\n safeZone = DEFAULT_SAFE_ZONE,\n font = DEFAULT_FONT,\n color = \"#FFFFFF\",\n beatIntensity = 0,\n}) => {\n // Defensive coerce: TemplateText is downstream of ~16 templates that pass\n // their own `variables.X` strings. If any one of them passes undefined\n // (missing variable on a freshly added scene, stale saved config, custom\n // template not setting a field), the unguarded `.split` / `.length` calls\n // below crash the entire preview. Treat undefined/non-string as\n // empty so a single bad scene doesn't take everything down. Warn in dev\n // so the upstream gap still surfaces.\n const textSafe = typeof textRaw === \"string\" ? textRaw : \"\";\n const isDevelopment = (import.meta as ImportMeta & { env?: { DEV?: boolean } }).env?.DEV;\n if (textRaw !== undefined && typeof textRaw !== \"string\" && isDevelopment) {\n console.warn(\"[TemplateText] received non-string text:\", textRaw);\n }\n // `|` is the AI's explicit line-break convention for headline copy\n // (\"Built for speed.|Designed for you.\"). Convert centrally so EVERY\n // template that renders text through TemplateText honors it — bg-media\n // used to convert locally while confetti/emojiBurst/etc. rendered the\n // pipe literally. Whitespace around the pipe is trimmed so spaced and\n // unspaced pipes produce identical output. The container's\n // `white-space: pre-line` renders the resulting `\\n` as a hard break.\n // Templates that legitimately render pipes (code, terminal commands)\n // don't flow through TemplateText, so they're unaffected.\n const text = textSafe.replace(/\\s*\\|\\s*/g, \"\\n\");\n // Normalize the archetype prop so unknown names fall back safely.\n const archetype = normalizeArchetype(archetypeRaw);\n const scale = Math.min(width, height) / 1080;\n // Motion pacing applies at every size role — a calm video should ease its\n // captions in too, not just its headlines. (The rest of the treatment is\n // headline-only; see `tt` below.)\n const result: ArchetypeRender = renderArchetype(\n archetype,\n progress,\n scale,\n text,\n sceneDuration,\n typeTreatment?.phaseScale ?? 1,\n motionProgress,\n );\n const { fontSize, fontWeight } = computeFontSize(\n archetype,\n text,\n sizeRole,\n position,\n width,\n height,\n safeZone,\n );\n\n // beatIntensity reserved for future use; currently a no-op on text body.\n void beatIntensity;\n\n const baseTypo = TYPO[sizeRole];\n // Preset type treatment. Absent (or the default preset's zero-deltas) leaves\n // every value exactly as it was, so unpresetted configs are unaffected.\n const tt = sizeRole === \"headline\" ? typeTreatment : undefined;\n // Only rewrite a value the preset actually changes — reformatting\n // letterSpacing with a zero delta would alter the emitted string (and every\n // stability snapshot) without changing the render.\n const typo = tt\n ? {\n ...baseTypo,\n ...(tt.trackingDeltaEm !== 0\n ? {\n letterSpacing: `${Number(\n (parseFloat(baseTypo.letterSpacing) + tt.trackingDeltaEm).toFixed(4),\n )}em`,\n }\n : {}),\n ...(tt.transform ? { textTransform: tt.transform } : {}),\n }\n : baseTypo;\n const presetWeight = tt ? Math.min(900, Math.max(100, fontWeight + tt.weightDelta)) : fontWeight;\n const presetSize = tt ? fontSize * tt.sizeScale : fontSize;\n const textShadow = dropShadowFor(color);\n\n const containerStyle: React.CSSProperties = {\n position: \"absolute\",\n left: 0,\n right: 0,\n display: \"flex\",\n justifyContent: \"center\",\n padding: `0 ${safeZone.right}px 0 ${safeZone.left}px`,\n color,\n fontFamily: font,\n fontWeight: presetWeight,\n fontSize: presetSize,\n textAlign: \"center\",\n pointerEvents: \"none\",\n fontFeatureSettings: FONT_FEATURES,\n textRendering: \"optimizeLegibility\",\n WebkitFontSmoothing: \"antialiased\",\n MozOsxFontSmoothing: \"grayscale\",\n // Respect explicit newlines — the centralized `|` → `\\n` conversion\n // above (and callers passing real newlines) rely on this. Multiple\n // spaces still collapse normally; only `\\n` and CRLF break.\n whiteSpace: \"pre-line\",\n ...(textShadow ? { textShadow } : {}),\n ...typo,\n ...positionStyle(position, height, safeZone),\n };\n\n if (result.kind === \"block\") {\n return (\n <div style={containerStyle}>\n <div\n style={{\n opacity: result.block.opacity,\n transform: `${result.block.transform}`,\n // Inherit letter-spacing from the container's typography defaults\n // unless the archetype explicitly overrides (e.g., for animated tracking).\n ...(result.block.letterSpacing ? { letterSpacing: result.block.letterSpacing } : {}),\n ...(result.block.willChange ? { willChange: result.block.willChange } : {}),\n maxWidth: \"85%\",\n }}\n >\n {renderWithEmoji(result.text, fontSize)}\n </div>\n </div>\n );\n }\n\n if (result.kind === \"typewriter\") {\n // Render every character as its own span so the FULL TEXT always sets the\n // layout — wrapping is decided by the complete string, not the typed\n // prefix. The cursor is overlaid with position:absolute from the last\n // typed char so it doesn't break the word it's inside.\n const chars = text.split(\"\");\n // Map cluster-start code-unit indices → full emoji graphemes so emoji use\n // the native font even in the per-char typewriter reveal. Indexing\n // stays on text.length (UTF-16 units) so result.visibleChars / charExits\n // line up exactly; continuation units of a cluster render nothing.\n const emojiPlan = planTypewriterEmoji(text);\n const cursorBar = {\n position: \"absolute\" as const,\n width: \"0.08em\",\n height: \"0.88em\",\n background: \"currentColor\",\n borderRadius: \"0.01em\",\n pointerEvents: \"none\" as const,\n };\n return (\n <div style={containerStyle}>\n <div\n style={{\n opacity: result.opacity,\n maxWidth: \"85%\",\n whiteSpace: \"pre-wrap\",\n position: \"relative\",\n }}\n >\n {chars.map((ch, i) => {\n const isTyped = i < result.visibleChars;\n const isLastTyped = i === result.visibleChars - 1;\n const anchorCursor = isLastTyped && result.cursor;\n const charExit = result.charExits?.[i];\n const baseOpacity = isTyped ? 1 : 0;\n const finalOpacity = baseOpacity * (charExit?.opacity ?? 1);\n // During exit the per-char span needs inline-block so translateX\n // takes effect; whiteSpace: pre keeps space chars from collapsing.\n const exitStyle = charExit\n ? {\n display: \"inline-block\" as const,\n transform: `translateX(${charExit.translateX}px)`,\n whiteSpace: \"pre\" as const,\n }\n : null;\n // Emoji handling: a cluster-start unit renders the full grapheme;\n // its continuation units render nothing.\n const emojiChar = emojiPlan?.starts.get(i);\n if (emojiPlan?.covered.has(i)) return null;\n return (\n <span\n key={i}\n style={{\n opacity: finalOpacity,\n position: anchorCursor ? \"relative\" : \"static\",\n ...(exitStyle ?? {}),\n }}\n >\n {emojiChar ? <Emoji char={emojiChar} size={fontSize} /> : ch}\n {anchorCursor && (\n <span\n aria-hidden\n style={{\n ...cursorBar,\n left: \"100%\",\n top: \"0.08em\",\n marginLeft: \"0.12em\",\n }}\n />\n )}\n </span>\n );\n })}\n {result.visibleChars === 0 && result.cursor && (\n <span\n aria-hidden\n style={{\n ...cursorBar,\n left: 0,\n top: \"0.08em\",\n }}\n />\n )}\n </div>\n </div>\n );\n }\n\n if (result.kind === \"words\") {\n // Render words inline-block with REAL space chars between them — word\n // spacing inherits from the container's typography defaults, matching\n // every other archetype's wrap behavior.\n return (\n <div style={containerStyle}>\n <div\n style={{\n opacity: result.blockOpacity,\n transform: `${result.blockTransform} `,\n maxWidth: \"85%\",\n }}\n >\n {result.words.map((w, i) => (\n <span key={i}>\n <span\n style={{\n display: \"inline-block\",\n opacity: w.style.opacity,\n transform: w.style.transform,\n }}\n >\n {renderWithEmoji(w.text, fontSize)}\n </span>\n {i < result.words.length - 1 ? \" \" : \"\"}\n </span>\n ))}\n </div>\n </div>\n );\n }\n\n if (result.kind === \"hero\") {\n // Per-word sizing: each active word fills its own moment optimally.\n const perWordFontSize = computeHeroFontSize(\n result.word.length,\n position,\n width,\n height,\n safeZone,\n );\n // Fixed-height slot so words of different sizes don't jump vertically.\n // Slot is the max possible hero size for this position; lineHeight: 1 on\n // the inner word locks the glyph box to the font height so flex-center\n // lands the glyph at the same Y for every word.\n const slotHeight =\n position === \"center\" ? 480 * scale : Math.min(220 * scale, height * 0.28 * 0.8);\n return (\n <div style={{ ...containerStyle, fontSize: perWordFontSize }}>\n <div\n style={{\n height: slotHeight,\n display: \"flex\",\n alignItems: \"center\",\n justifyContent: \"center\",\n }}\n >\n <div\n style={{\n opacity: result.opacity,\n transform: `${result.transform} `,\n lineHeight: 1,\n ...(result.letterSpacing ? { letterSpacing: result.letterSpacing } : {}),\n }}\n >\n {renderWithEmoji(result.word, perWordFontSize)}\n </div>\n </div>\n </div>\n );\n }\n\n return null;\n};\n"
|
|
41
|
+
},
|
|
42
|
+
{
|
|
43
|
+
"path": "src/visual-system/emoji/index.tsx",
|
|
44
|
+
"type": "registry:component",
|
|
45
|
+
"target": "vanillasky/emoji/index.tsx",
|
|
46
|
+
"content": "import * as React from \"react\";\n\nconst NATIVE_EMOJI_FONT = \"Apple Color Emoji,Segoe UI Emoji,Noto Color Emoji,sans-serif\";\nconst NATIVE_EMOJI = /\\p{Emoji_Presentation}|\\p{Regional_Indicator}|\\u{FE0F}|\\u{20E3}/u;\n\n/** True for emoji-presentation graphemes, not plain symbols such as ★ or ✓. */\nexport function isNativeEmoji(char: string): boolean {\n return NATIVE_EMOJI.test(char);\n}\n\nexport interface EmojiProps {\n /** The emoji character or grapheme cluster, e.g. \"🎉\" or \"👩💻\". */\n char: string;\n /** Font size in px. */\n size: number;\n /** vertical-align for inline flow. Defaults to a glyph-like baseline nudge. */\n verticalAlign?: React.CSSProperties[\"verticalAlign\"];\n /** Extra styles merged onto the native emoji span. */\n style?: React.CSSProperties;\n}\n\n/** Render emoji with the viewer's OS font while preserving text-style symbols. */\nexport const Emoji: React.FC<EmojiProps> = ({ char, size, verticalAlign = \"-0.15em\", style }) => {\n const nativeEmoji = isNativeEmoji(char);\n return (\n <span\n role={nativeEmoji ? \"img\" : undefined}\n aria-label={nativeEmoji ? char : undefined}\n style={{\n ...(nativeEmoji ? { fontFamily: NATIVE_EMOJI_FONT } : {}),\n fontSize: size,\n lineHeight: 1,\n display: \"inline-block\",\n verticalAlign,\n ...style,\n }}\n >\n {char}\n </span>\n );\n};\n"
|
|
47
|
+
},
|
|
48
|
+
{
|
|
49
|
+
"path": "src/visual-system/emoji/emoji-text.tsx",
|
|
50
|
+
"type": "registry:component",
|
|
51
|
+
"target": "vanillasky/emoji/emoji-text.tsx",
|
|
52
|
+
"content": "/**\n * EmojiText / renderWithEmoji — split a string into text runs + emoji runs,\n * rendering each emoji with the viewer's native emoji font while leaving\n * everything else as plain text.\n *\n * Segmentation: grapheme clusters via Intl.Segmenter so ZWJ sequences\n * (👩💻) and skin-tone modifiers (👍🏽) stay single units. Adjacent emoji\n * clusters each render as their own span in sequence.\n */\n\nimport * as React from \"react\";\nimport { Emoji, isNativeEmoji } from \"./index\";\n\n/** Split text into grapheme clusters (ZWJ + skin-tone safe). */\nfunction toGraphemes(text: string): string[] {\n const Seg = (Intl as unknown as { Segmenter?: typeof Intl.Segmenter }).Segmenter;\n if (Seg) {\n const seg = new Seg(undefined, { granularity: \"grapheme\" });\n const out: string[] = [];\n for (const { segment } of seg.segment(text)) out.push(segment);\n return out;\n }\n // Fallback: code-point spread. Won't keep ZWJ/skin-tone as single units, so\n // those land as separate clusters. Modern browsers all have Segmenter.\n return Array.from(text);\n}\n\nexport interface RenderWithEmojiOptions {\n /** vertical-align passed to each <Emoji>. */\n verticalAlign?: React.CSSProperties[\"verticalAlign\"];\n /** Extra style merged onto each emoji span. */\n emojiStyle?: React.CSSProperties;\n}\n\n/**\n * Split `text` into an array of React nodes — plain-text strings interleaved\n * with <Emoji> spans for every emoji cluster. Returns a single-element\n * `[text]` fast-path when there are no emoji (the common case), so\n * non-emoji text pays ~one regex test.\n *\n * @param text the string to render\n * @param fontSizePx surrounding font size in px (emoji box = this size)\n */\nexport function renderWithEmoji(\n text: string,\n fontSizePx: number,\n opts?: RenderWithEmojiOptions,\n): React.ReactNode[] {\n if (!text) return [text];\n // Cheap bail-out: if the whole string has no emoji-range codepoint, return\n // it untouched (no segmentation, no array churn) — the hot path for the vast\n // majority of titles/bodies.\n if (!isNativeEmoji(text)) return [text];\n\n const clusters = toGraphemes(text);\n const nodes: React.ReactNode[] = [];\n let textBuf = \"\";\n let key = 0;\n\n const flushText = () => {\n if (textBuf) {\n nodes.push(textBuf);\n textBuf = \"\";\n }\n };\n\n for (const cluster of clusters) {\n if (isNativeEmoji(cluster)) {\n flushText();\n nodes.push(\n <Emoji\n key={`e${key++}`}\n char={cluster}\n size={fontSizePx}\n verticalAlign={opts?.verticalAlign}\n style={opts?.emojiStyle}\n />,\n );\n } else {\n textBuf += cluster;\n }\n }\n flushText();\n return nodes;\n}\n\n/**\n * Per-code-unit emoji plan for the typewriter archetype, which reveals text\n * one UTF-16 code unit at a time and indexes by `text.length`. We can't just\n * call renderWithEmoji there (it would re-segment and desync the visibleChars\n * counter), so this maps each cluster's START code-unit index to the full emoji\n * and marks the cluster's CONTINUATION indices as covered (render nothing for\n * them — the start index's span already contains the whole cluster).\n *\n * Returns null when the text contains no emoji (the common case),\n * so the typewriter render keeps its plain per-char path.\n */\nexport interface EmojiTypewriterPlan {\n /** code-unit index → full emoji cluster char (cluster start). */\n starts: Map<number, string>;\n /** code-unit indices that are continuations of a cluster (render nothing). */\n covered: Set<number>;\n}\n\nexport function planTypewriterEmoji(text: string): EmojiTypewriterPlan | null {\n if (!text || !isNativeEmoji(text)) return null;\n const starts = new Map<number, string>();\n const covered = new Set<number>();\n let idx = 0;\n let found = false;\n for (const cluster of toGraphemes(text)) {\n const len = cluster.length; // UTF-16 code units\n if (isNativeEmoji(cluster)) {\n found = true;\n // Store the WHOLE cluster char (not just the start unit) so callers can\n // pass it straight to <Emoji> without splitting a grapheme cluster.\n starts.set(idx, cluster);\n for (let k = 1; k < len; k++) covered.add(idx + k);\n }\n idx += len;\n }\n return found ? { starts, covered } : null;\n}\n\nexport interface EmojiTextProps {\n /** The text to render with emoji in the native operating-system font. */\n children: string;\n /** Surrounding font size in px — sizes each emoji to match a glyph. */\n fontSize: number;\n verticalAlign?: React.CSSProperties[\"verticalAlign\"];\n emojiStyle?: React.CSSProperties;\n}\n\n/**\n * Inline wrapper around renderWithEmoji. Renders a React.Fragment of text +\n * emoji spans. Use where a component currently renders a raw `{text}`\n * child and you have the surrounding font size in px.\n */\nexport const EmojiText: React.FC<EmojiTextProps> = ({\n children,\n fontSize,\n verticalAlign,\n emojiStyle,\n}) => {\n const text = typeof children === \"string\" ? children : \"\";\n return <>{renderWithEmoji(text, fontSize, { verticalAlign, emojiStyle })}</>;\n};\n"
|
|
53
|
+
},
|
|
54
|
+
{
|
|
55
|
+
"path": "src/visual-system/scene-templates/types.ts",
|
|
56
|
+
"type": "registry:lib",
|
|
57
|
+
"target": "vanillasky/scene-templates/types.ts",
|
|
58
|
+
"content": "/**\n * Scene template types.\n *\n * A template is a reusable React component that defines how a scene looks.\n * It declares the variables an editor or model may provide\n * and receives universal settings as props.\n *\n * Templates are searchable by AI via description, category, jobs, register,\n * and useWhen guidance.\n * The variable schema enables any LLM to fill in template variables via JSON.\n */\n\nimport type { ResolvedTokens } from \"../theme\";\nimport type { SafeZone, TemplateStyle } from \"../template-context\";\n\n/**\n * Props passed to every scene template component.\n *\n * All animation must be driven by `progress` (0→1). No CSS animations,\n * no Framer Motion, no requestAnimationFrame. Use interpolate/spring\n * from animation-utils.ts.\n *\n * Scale factor: use `Math.min(width, height) / 1080` — normalizes to\n * the short edge so visuals are consistent across portrait and landscape.\n */\nexport interface SceneTemplateProps {\n variables: Record<string, unknown>;\n style: TemplateStyle;\n /** 0→1 through the scene's duration */\n progress: number;\n /** Presentation clock. Active templates receive the same complete 0→1 timeline as progress. */\n motionProgress?: number;\n /** 0→1 beat pulse intensity */\n beatIntensity: number;\n /** 1080 (portrait) or 1920 (landscape) */\n width: number;\n /** 1920 (portrait) or 1080 (landscape) */\n height: number;\n /** Video-level default text effect (for templates that opt in via usesGlobalTextEffect) */\n textArchetype?: string;\n /** How text leaves the scene (fade / shrink / pop / blur-scale). Falls back to a sensible default per textArchetype when undefined. */\n /** Video-level default background effect (for templates that opt in via usesGlobalBackgroundEffect) */\n backgroundEffect?: string;\n /** Platform-aware safe zone insets in pixels — use for text placement */\n safeZone: SafeZone;\n /** Scene duration in seconds — use for time-based (not progress-based) animations */\n sceneDuration?: number;\n /**\n * Brand tokens already resolved from `style`. Built-in templates import\n * resolveTokens directly; an ejected `custom_*` scene can't import anything,\n * so without this it has no way to reach the same values and ends up\n * hardcoding white, black and shadows — the body then looks generic next to\n * a frame that IS using the brand.\n */\n tokens?: ResolvedTokens;\n /**\n * True when the preview player is actively advancing progress; false when paused.\n * Templates that play HTML5 <video> elements should pause them when this is false.\n * Undefined (export capture path) is treated as true.\n */\n isPlaying?: boolean;\n}\n"
|
|
59
|
+
}
|
|
60
|
+
],
|
|
61
|
+
"meta": {
|
|
62
|
+
"vanillasky": {
|
|
63
|
+
"layer": "template",
|
|
64
|
+
"tier": "free",
|
|
65
|
+
"register": "motion-led",
|
|
66
|
+
"jobs": [
|
|
67
|
+
"proof"
|
|
68
|
+
],
|
|
69
|
+
"useWhen": "An exact percentage represents completion, readiness, health, adoption, or goal progress.",
|
|
70
|
+
"textCanvas": "tight",
|
|
71
|
+
"minDuration": 2,
|
|
72
|
+
"preferredDuration": 3.5,
|
|
73
|
+
"schema": {
|
|
74
|
+
"type": "object",
|
|
75
|
+
"properties": {
|
|
76
|
+
"texts": {
|
|
77
|
+
"type": "string",
|
|
78
|
+
"title": "Text",
|
|
79
|
+
"description": "Concise title shown above the ring (48 characters maximum).",
|
|
80
|
+
"minLength": 1,
|
|
81
|
+
"maxLength": 48,
|
|
82
|
+
"default": "Almost there."
|
|
83
|
+
},
|
|
84
|
+
"value": {
|
|
85
|
+
"type": "number",
|
|
86
|
+
"title": "Value",
|
|
87
|
+
"description": "Percentage value 0-100",
|
|
88
|
+
"default": 75
|
|
89
|
+
},
|
|
90
|
+
"decimalPlaces": {
|
|
91
|
+
"type": "number",
|
|
92
|
+
"title": "Decimal places",
|
|
93
|
+
"description": "Optional display precision; when omitted, precision is inferred from the value"
|
|
94
|
+
},
|
|
95
|
+
"label": {
|
|
96
|
+
"type": "string",
|
|
97
|
+
"title": "Label",
|
|
98
|
+
"description": "Short label shown below the ring (32 characters maximum).",
|
|
99
|
+
"minLength": 1,
|
|
100
|
+
"maxLength": 32,
|
|
101
|
+
"default": "Complete"
|
|
102
|
+
},
|
|
103
|
+
"unit": {
|
|
104
|
+
"type": "string",
|
|
105
|
+
"title": "Unit",
|
|
106
|
+
"description": "Compact suffix after the number (e.g. %, x, k; 3 characters maximum).",
|
|
107
|
+
"maxLength": 3,
|
|
108
|
+
"default": "%"
|
|
109
|
+
},
|
|
110
|
+
"mediaUrl": {
|
|
111
|
+
"type": "string",
|
|
112
|
+
"title": "Background media",
|
|
113
|
+
"description": "Optional photo or video URL behind this scene. When set, replaces the brand gradient.",
|
|
114
|
+
"format": "uri",
|
|
115
|
+
"default": ""
|
|
116
|
+
},
|
|
117
|
+
"mediaKeyword": {
|
|
118
|
+
"type": "string",
|
|
119
|
+
"title": "Background search keyword",
|
|
120
|
+
"description": "2-4 word English term for Pexels stock-footage search (auto-fills mediaUrl).",
|
|
121
|
+
"format": "stock-media-keyword",
|
|
122
|
+
"default": ""
|
|
123
|
+
},
|
|
124
|
+
"mediaType": {
|
|
125
|
+
"type": "string",
|
|
126
|
+
"title": "Background media type",
|
|
127
|
+
"description": "auto detects photo/video from URL. 'gradient' is a deliberate mode — atmospheric brand-color scene with no stock footage.",
|
|
128
|
+
"enum": [
|
|
129
|
+
"auto",
|
|
130
|
+
"photo",
|
|
131
|
+
"video",
|
|
132
|
+
"gradient"
|
|
133
|
+
],
|
|
134
|
+
"default": "auto"
|
|
135
|
+
},
|
|
136
|
+
"mediaPoster": {
|
|
137
|
+
"type": "string",
|
|
138
|
+
"title": "Background poster image",
|
|
139
|
+
"description": "Still image URL shown while a video backdrop is decoding its first frame. Auto-filled from Pexels' thumbnail when fillPexelsUrls sets a video mediaUrl. Hides the gradient flash that would otherwise appear in the ~50–400ms gap between a <video> mounting and decoding its first frame.",
|
|
140
|
+
"format": "uri",
|
|
141
|
+
"default": ""
|
|
142
|
+
},
|
|
143
|
+
"mediaPosition": {
|
|
144
|
+
"type": "string",
|
|
145
|
+
"title": "Background focal position",
|
|
146
|
+
"description": "Controls which part of a photo or video stays visible when cover-cropped. Pick the subject's side or vertical anchor after inspecting the frame.",
|
|
147
|
+
"enum": [
|
|
148
|
+
"center",
|
|
149
|
+
"top",
|
|
150
|
+
"bottom",
|
|
151
|
+
"left",
|
|
152
|
+
"right"
|
|
153
|
+
],
|
|
154
|
+
"default": "center"
|
|
155
|
+
},
|
|
156
|
+
"mediaTreatment": {
|
|
157
|
+
"type": "string",
|
|
158
|
+
"title": "Background contrast treatment",
|
|
159
|
+
"description": "subtle preserves a visual hero; cinematic adds balanced contrast; text-safe adds a stronger wash for copy-heavy scenes.",
|
|
160
|
+
"enum": [
|
|
161
|
+
"subtle",
|
|
162
|
+
"cinematic",
|
|
163
|
+
"text-safe"
|
|
164
|
+
],
|
|
165
|
+
"default": "cinematic"
|
|
166
|
+
}
|
|
167
|
+
},
|
|
168
|
+
"required": [
|
|
169
|
+
"texts",
|
|
170
|
+
"value",
|
|
171
|
+
"label"
|
|
172
|
+
],
|
|
173
|
+
"additionalProperties": false,
|
|
174
|
+
"x-vanillasky": {
|
|
175
|
+
"requiresStat": true,
|
|
176
|
+
"allowsStockMedia": true
|
|
177
|
+
}
|
|
178
|
+
},
|
|
179
|
+
"label": "Progress ring",
|
|
180
|
+
"description": "An animated circular progress value with headline and label.",
|
|
181
|
+
"family": "Data & metrics",
|
|
182
|
+
"avoidWhen": "The percentage is a generic uplift or reduction rather than progress toward a bounded whole.",
|
|
183
|
+
"usesGlobalTextEffect": false,
|
|
184
|
+
"usesGlobalTransition": true,
|
|
185
|
+
"usesGlobalBackgroundEffect": true,
|
|
186
|
+
"timing": {
|
|
187
|
+
"contentFields": [
|
|
188
|
+
"texts",
|
|
189
|
+
"label"
|
|
190
|
+
],
|
|
191
|
+
"contentUnit": "words"
|
|
192
|
+
},
|
|
193
|
+
"transitionTiming": {
|
|
194
|
+
"entryReadyProgress": 0.2,
|
|
195
|
+
"holdProgress": 0.7
|
|
196
|
+
}
|
|
197
|
+
}
|
|
198
|
+
}
|
|
199
|
+
}
|
|
@@ -0,0 +1,148 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "https://ui.shadcn.com/schema/registry-item.json",
|
|
3
|
+
"name": "promptInput",
|
|
4
|
+
"type": "registry:block",
|
|
5
|
+
"title": "Prompt input",
|
|
6
|
+
"description": "An AI prompt pill expands and types a user instruction over a branded background.",
|
|
7
|
+
"dependencies": [
|
|
8
|
+
"react"
|
|
9
|
+
],
|
|
10
|
+
"registryDependencies": [
|
|
11
|
+
"@vanillasky/backgrounds",
|
|
12
|
+
"@vanillasky/motion",
|
|
13
|
+
"@vanillasky/theme",
|
|
14
|
+
"@vanillasky/typography",
|
|
15
|
+
"@vanillasky/template-context"
|
|
16
|
+
],
|
|
17
|
+
"files": [
|
|
18
|
+
{
|
|
19
|
+
"path": "src/visual-system/scene-templates/prompt-input.tsx",
|
|
20
|
+
"type": "registry:component",
|
|
21
|
+
"target": "vanillasky/scene-templates/prompt-input.tsx",
|
|
22
|
+
"content": "/**\n * prompt-input — AI prompt-field demo, centered.\n *\n * A small pill with an AI-sparkles icon springs in, expands horizontally\n * into a full-width prompt bar, then types out a sample prompt character\n * by character. Use to showcase HOW a user prompts the product — the\n * prompt UX itself becomes the focal element. Pairs with any modern\n * \"ask the AI\" / \"describe what you want\" / \"type your prompt\" affordance.\n *\n * Centered on a solid background (or media if the user sets one). No\n * other text — the prompt form is the entire scene.\n */\n\nimport * as React from \"react\";\nimport type { SceneTemplateProps } from \"./types\";\nimport { SceneBackground, getMediaBackgroundProps } from \"./scene-background\";\nimport { stripPipe } from \"../typography\";\nimport { PromptInputPill } from \"../primitives/typography/PromptInputPill\";\nimport { resolveTokens } from \"../theme\";\n\nexport const PromptInputTemplate: React.FC<SceneTemplateProps> = ({\n variables,\n style,\n progress,\n beatIntensity,\n width,\n height,\n sceneDuration,\n isPlaying = true,\n backgroundEffect,\n}) => {\n const { font } = resolveTokens(style);\n\n const promptText = stripPipe(String(variables.promptText || \"Make a launch video for our app\"));\n const pillBg = \"#FFFFFF\";\n const pillTextColor = \"#374151\";\n const seed = promptText.split(\"\").reduce((acc, c) => acc + c.charCodeAt(0), 0);\n\n return (\n <div\n style={{\n width,\n height,\n position: \"relative\",\n overflow: \"hidden\",\n backgroundColor: \"#000\",\n fontFamily: font,\n }}\n >\n {/* [slot: background] Gradient / media backdrop */}\n <SceneBackground\n style={style}\n progress={progress}\n sceneDuration={sceneDuration}\n width={width}\n height={height}\n {...getMediaBackgroundProps(variables)}\n backgroundEffect={backgroundEffect}\n seed={seed}\n isPlaying={isPlaying}\n beatIntensity={beatIntensity}\n />\n\n {/* [slot: hero] Centered pill — PromptInputPill primitive (typed\n prompt is the content; no separate caption slot) */}\n <PromptInputPill\n progress={progress}\n sceneDuration={sceneDuration ?? 4}\n promptText={promptText}\n pillBg={pillBg}\n pillTextColor={pillTextColor}\n width={width}\n height={height}\n />\n </div>\n );\n};\n"
|
|
23
|
+
},
|
|
24
|
+
{
|
|
25
|
+
"path": "src/visual-system/primitives/typography/PromptInputPill.tsx",
|
|
26
|
+
"type": "registry:component",
|
|
27
|
+
"target": "vanillasky/primitives/typography/PromptInputPill.tsx",
|
|
28
|
+
"content": "/**\n * PromptInputPill\n *\n * AI prompt-bar focal element: pill scales in as a small circle (icon only),\n * expands horizontally to full width, then typewrites a sample prompt\n * character-by-character. Sparkles icon on the left, blinking cursor at the\n * end of the typed text.\n *\n * prompt-input.tsx consumes this component so both paths share one\n * implementation.\n *\n * Two surfaces:\n * 1. <PromptInputPill {...typedProps} /> — direct use from templates\n * 2. Registered primitive — used by custom scenes via composition JSON\n */\n\nimport * as React from \"react\";\nimport { interpolate, spring, SPRING_BOUNCY, SPRING_SMOOTH } from \"../../motion\";\nimport { stripPipe } from \"../../typography\";\n\nconst CLAMP = {\n extrapolateLeft: \"clamp\" as const,\n extrapolateRight: \"clamp\" as const,\n};\n\n// ─── Sparkles icon (lifted verbatim from prompt-input) ───────────\n\nconst SparklesIcon: React.FC<{ size: number; gradientId: string }> = ({ size, gradientId }) => (\n <svg width={size} height={size} viewBox=\"0 0 16 16\" fill=\"none\">\n <defs>\n <linearGradient id={gradientId} x1=\"0%\" y1=\"0%\" x2=\"100%\" y2=\"100%\">\n <stop offset=\"0%\" stopColor=\"#7C3AED\" />\n <stop offset=\"50%\" stopColor=\"#3B82F6\" />\n <stop offset=\"100%\" stopColor=\"#06B6D4\" />\n </linearGradient>\n </defs>\n <path\n d=\"M7.657 6.247c.11-.33.576-.33.686 0l.645 1.937a2.89 2.89 0 0 0 1.829 1.828l1.936.645c.33.11.33.576 0 .686l-1.937.645a2.89 2.89 0 0 0-1.828 1.829l-.645 1.936a.361.361 0 0 1-.686 0l-.645-1.937a2.89 2.89 0 0 0-1.828-1.828l-1.937-.645a.361.361 0 0 1 0-.686l1.937-.645a2.89 2.89 0 0 0 1.828-1.828zM3.794 1.148a.217.217 0 0 1 .412 0l.387 1.162c.173.518.579.924 1.097 1.097l1.162.387a.217.217 0 0 1 0 .412l-1.162.387A1.73 1.73 0 0 0 4.593 5.69l-.387 1.162a.217.217 0 0 1-.412 0L3.407 5.69A1.73 1.73 0 0 0 2.31 4.593l-1.162-.387a.217.217 0 0 1 0-.412l1.162-.387A1.73 1.73 0 0 0 3.407 2.31zM10.863.099a.145.145 0 0 1 .274 0l.258.774c.115.346.386.617.732.732l.774.258a.145.145 0 0 1 0 .274l-.774.258a1.16 1.16 0 0 0-.732.732l-.258.774a.145.145 0 0 1-.274 0l-.258-.774a1.16 1.16 0 0 0-.732-.732L9.1 2.137a.145.145 0 0 1 0-.274l.774-.258c.346-.115.617-.386.732-.732z\"\n fill={`url(#${gradientId})`}\n />\n </svg>\n);\n\n// ─── Typed component (direct use from templates) ────────────────\n\nexport interface PromptInputPillProps {\n progress: number;\n sceneDuration: number;\n /** Prompt text typed into the pill */\n promptText: string;\n /** Pill background color (default #FFFFFF) */\n pillBg?: string;\n /** Color of the typed text (default #374151 — Tailwind gray-700) */\n pillTextColor?: string;\n /** Frame width */\n width: number;\n /** Frame height */\n height: number;\n}\n\nexport const PromptInputPill: React.FC<PromptInputPillProps> = ({\n progress,\n sceneDuration,\n promptText: rawText,\n pillBg = \"#FFFFFF\",\n pillTextColor = \"#374151\",\n width,\n height,\n}) => {\n const dim = Math.min(width, height);\n const promptText = stripPipe(rawText || \"\");\n const seed = promptText.split(\"\").reduce((acc, c) => acc + c.charCodeAt(0), 0);\n\n // Sizing — verbatim from prompt-input\n const pillHeight = dim * 0.13;\n const pillTargetWidth = Math.min(width * 0.86, dim * 0.95);\n const pillCircleWidth = pillHeight;\n const pillRadius = pillHeight / 2;\n const iconSize = pillHeight * 0.46;\n const padLeft = pillHeight * 0.30;\n const fontSizeDefault = pillHeight * 0.42;\n const availableTextWidth = pillTargetWidth - padLeft * 3 - iconSize;\n const naturalTextWidth = promptText.length * fontSizeDefault * 0.55 * 1.06;\n // Allow shrink down to 0.45× — the prior 0.6 floor wasn't aggressive\n // enough for unexpectedly long prompts and left them hard-clipped at\n // the right edge of the pill (stress test caught a 130-char prompt\n // overflowing). 0.45 keeps text readable even after shrink. The pill\n // body has overflow: hidden so anything that still doesn't fit clips\n // cleanly instead of running past the pill border.\n const shrinkFactor =\n naturalTextWidth > availableTextWidth\n ? Math.max(0.45, availableTextWidth / naturalTextWidth)\n : 1;\n const fontSize = fontSizeDefault * shrinkFactor;\n\n // Reveal sequence — verbatim from prompt-input\n const enterSpring = spring(\n interpolate(progress, [0, 0.10], [0, 1], CLAMP),\n SPRING_BOUNCY,\n );\n const enterScale = 0.7 + 0.3 * enterSpring;\n const enterOpacity = interpolate(progress, [0, 0.08], [0, 1], CLAMP);\n\n const widthProgress = spring(\n interpolate(progress, [0.10, 0.30], [0, 1], CLAMP),\n SPRING_SMOOTH,\n );\n const pillWidth = pillCircleWidth + (pillTargetWidth - pillCircleWidth) * widthProgress;\n\n const typeStart = 0.30;\n const typeEnd = 0.68;\n const charsRevealed = Math.max(\n 0,\n Math.floor(\n interpolate(progress, [typeStart, typeEnd], [0, promptText.length], CLAMP),\n ),\n );\n const visibleText = promptText.slice(0, charsRevealed);\n\n const realT = progress * sceneDuration;\n const cursorVisible =\n progress >= typeStart * 0.9 && Math.sin(realT * Math.PI * 2.4) > 0;\n\n return (\n <div\n style={{\n position: \"absolute\",\n top: \"50%\",\n left: \"50%\",\n transform: `translate(-50%, -50%) scale(${enterScale})`,\n opacity: enterOpacity,\n }}\n >\n <div\n style={{\n width: pillWidth,\n height: pillHeight,\n backgroundColor: pillBg,\n borderRadius: pillRadius,\n display: \"flex\",\n alignItems: \"center\",\n paddingLeft: padLeft,\n paddingRight: padLeft,\n // Clip at the pill border — even after the 0.45× shrink floor,\n // pathologically long prompts can still exceed the pill width.\n // Clipping at the rounded border looks cleaner than letting text\n // bleed past the right edge.\n overflow: \"hidden\",\n boxShadow: [\n `inset 0 ${1 * (dim / 1080)}px 0 rgba(255,255,255,0.85)`,\n `0 ${8 * (dim / 1080)}px ${24 * (dim / 1080)}px ${-8 * (dim / 1080)}px rgba(110,80,200,0.10)`,\n `0 ${2 * (dim / 1080)}px ${8 * (dim / 1080)}px ${-4 * (dim / 1080)}px rgba(0,0,0,0.05)`,\n ].join(\", \"),\n whiteSpace: \"nowrap\",\n }}\n >\n <div\n style={{\n flexShrink: 0,\n display: \"flex\",\n alignItems: \"center\",\n justifyContent: \"center\",\n width: iconSize,\n height: iconSize,\n }}\n >\n <SparklesIcon size={iconSize} gradientId={`prompt-input-grad-${seed}`} />\n </div>\n <div\n style={{\n marginLeft: padLeft,\n fontSize,\n lineHeight: 1.4,\n color: pillTextColor,\n fontWeight: 500,\n letterSpacing: -0.5,\n minWidth: 0,\n display: \"flex\",\n alignItems: \"center\",\n }}\n >\n <span>{visibleText}</span>\n <span\n style={{\n display: \"inline-block\",\n width: fontSize * 0.06,\n height: fontSize * 0.95,\n backgroundColor: pillTextColor,\n marginLeft: fontSize * 0.08,\n opacity: cursorVisible ? 0.85 : 0,\n borderRadius: fontSize * 0.03,\n }}\n />\n </div>\n </div>\n </div>\n );\n};\n"
|
|
29
|
+
},
|
|
30
|
+
{
|
|
31
|
+
"path": "src/visual-system/scene-templates/scene-background.tsx",
|
|
32
|
+
"type": "registry:component",
|
|
33
|
+
"target": "vanillasky/scene-templates/scene-background.tsx",
|
|
34
|
+
"content": "/**\n * SceneBackground — shared backdrop component for any scene template that\n * wants to support both a brand-color gradient and stock media (Pexels\n * photo / video) as an alternate atmosphere.\n *\n * Usage:\n * <SceneBackground\n * style={style}\n * progress={progress}\n * sceneDuration={sceneDuration}\n * width={width}\n * height={height}\n * mediaUrl={String(variables.mediaUrl || \"\")}\n * mediaType={String(variables.mediaType || \"auto\")}\n * seed={String(variables.texts || \"\")}\n * isPlaying={isPlaying}\n * />\n * ... template's content layered on top\n *\n * Behavior:\n * - Brand gradient is the always-on backdrop (uses BrandGradientOverlay).\n * - When mediaUrl is set and mediaType isn't \"gradient\", the photo/video\n * covers the gradient. Vignette + bottom-half darken give the content\n * contrast against busy footage.\n * - mediaType=\"gradient\" deliberately ignores mediaUrl and renders only\n * the brand gradient. First-class atmospheric mode.\n * - When mediaUrl is empty / 404s / Pexels search returned nothing,\n * gradient shows through cleanly (matches every other gradient-backed\n * template).\n *\n * Extracted from bg-media.tsx so any template can compose it. bg-media\n * now uses this component too — its \"media is the scene\" identity comes\n * from how it positions the title (centered, full-frame), not from\n * duplicated render logic.\n */\n\nimport React, { useEffect, useRef } from \"react\";\nimport type { TemplateStyle } from \"../template-context\";\nimport { BrandGradientOverlay } from \"../backgrounds\";\nimport { getBackgroundTransform } from \"../backgrounds\";\n\nconst VIDEO_EXTENSIONS = [\".mp4\", \".webm\", \".mov\", \".m4v\", \".avi\"];\n\nfunction isVideoUrl(url: string): boolean {\n try {\n const pathname = new URL(url).pathname.toLowerCase();\n return VIDEO_EXTENSIONS.some((ext) => pathname.endsWith(ext));\n } catch {\n const lower = url.toLowerCase();\n return VIDEO_EXTENSIONS.some((ext) => lower.endsWith(ext));\n }\n}\n\nexport type ResolvedMediaType = \"photo\" | \"video\" | \"gradient\";\n\nexport type MediaPosition = \"center\" | \"top\" | \"bottom\" | \"left\" | \"right\";\nexport type MediaTreatment = \"subtle\" | \"cinematic\" | \"text-safe\";\n\nconst MEDIA_POSITIONS: Record<MediaPosition, string> = {\n center: \"center center\",\n top: \"center top\",\n bottom: \"center bottom\",\n left: \"left center\",\n right: \"right center\",\n};\n\nexport function resolveMediaPosition(value: string): string {\n return MEDIA_POSITIONS[value as MediaPosition] ?? MEDIA_POSITIONS.center;\n}\n\nexport function resolveMediaTreatment(value: string): MediaTreatment {\n return value === \"subtle\" || value === \"text-safe\" ? value : \"cinematic\";\n}\n\nexport interface MediaTreatmentLayer {\n id: \"vignette\" | \"full-wash\" | \"center-scrim\" | \"bottom-scrim\";\n background: string;\n style?: React.CSSProperties;\n}\n\n/** Export-safe contrast recipes. Overlays only: SVG capture cannot rely on CSS filters. */\nexport function getMediaTreatmentLayers(value: string): MediaTreatmentLayer[] {\n const treatment = resolveMediaTreatment(value);\n const vignette: MediaTreatmentLayer = {\n id: \"vignette\",\n background:\n treatment === \"subtle\"\n ? \"radial-gradient(ellipse at center, transparent 45%, rgba(0,0,0,0.28) 100%)\"\n : \"radial-gradient(ellipse at center, transparent 30%, rgba(0,0,0,0.55) 80%, rgba(0,0,0,0.75) 100%)\",\n };\n if (treatment === \"subtle\") return [vignette];\n\n const cinematic: MediaTreatmentLayer[] = [\n vignette,\n {\n id: \"center-scrim\",\n background:\n treatment === \"text-safe\"\n ? \"radial-gradient(ellipse 90% 56% at 50% 50%, rgba(0,0,0,0.36) 0%, rgba(0,0,0,0.18) 55%, transparent 84%)\"\n : \"radial-gradient(ellipse 85% 50% at 50% 50%, rgba(0,0,0,0.22) 0%, rgba(0,0,0,0.10) 50%, transparent 80%)\",\n },\n {\n id: \"bottom-scrim\",\n background:\n treatment === \"text-safe\"\n ? \"linear-gradient(to top, rgba(0,0,0,0.68) 0%, transparent 100%)\"\n : \"linear-gradient(to top, rgba(0,0,0,0.5) 0%, transparent 100%)\",\n style: { top: \"55%\" },\n },\n ];\n\n if (treatment === \"text-safe\") {\n cinematic.splice(1, 0, {\n id: \"full-wash\",\n background: \"rgba(0,0,0,0.30)\",\n });\n }\n return cinematic;\n}\n\nexport function resolveMediaType(\n mediaType: string,\n mediaUrl: string,\n): ResolvedMediaType {\n if (mediaType === \"gradient\") return \"gradient\";\n if (mediaType === \"video\") return \"video\";\n if (mediaType === \"photo\") return \"photo\";\n // \"auto\" — detect from URL extension\n return mediaUrl && isVideoUrl(mediaUrl) ? \"video\" : \"photo\";\n}\n\nexport function getMediaBackgroundProps(variables: Record<string, unknown>) {\n return {\n mediaUrl: String(variables.mediaUrl || \"\"),\n mediaType: String(variables.mediaType || \"auto\"),\n mediaPoster: String(variables.mediaPoster || \"\"),\n mediaPosition: String(variables.mediaPosition || \"center\"),\n mediaTreatment: String(variables.mediaTreatment || \"cinematic\"),\n };\n}\n\nexport interface SceneBackgroundProps {\n style: TemplateStyle;\n progress: number;\n sceneDuration?: number;\n width: number;\n height: number;\n mediaUrl?: string;\n mediaType?: string;\n /** Still image URL shown while the <video> backdrop decodes its first\n * frame. Without it the element renders transparent during the\n * ~50–400ms decode window and the gradient flashes through. */\n mediaPoster?: string;\n /** Cover-crop focal anchor. Keeps the important edge/subject visible. */\n mediaPosition?: string;\n /** Overlay recipe: subtle, cinematic, or stronger text-safe contrast. */\n mediaTreatment?: string;\n /** Background motion effect (drift / pulse / Ken Burns). Applied to the photo/video. */\n backgroundEffect?: string;\n /** Stable seed for the gradient breathing animation. Pass the scene's\n * text content (or any stable string) — it's hashed deterministically. */\n seed?: number | string;\n /** Pause video when preview is paused. Defaults to true (export path). */\n isPlaying?: boolean;\n beatIntensity?: number;\n}\n\nexport const SceneBackground: React.FC<SceneBackgroundProps> = ({\n style,\n progress,\n sceneDuration,\n width: _width, // accepted for symmetry; not currently used in render\n height: _height,\n mediaUrl = \"\",\n mediaType = \"auto\",\n mediaPoster,\n mediaPosition = \"center\",\n mediaTreatment = \"cinematic\",\n backgroundEffect,\n seed,\n isPlaying = true,\n beatIntensity = 0,\n}) => {\n void _width;\n void _height;\n const resolved = resolveMediaType(mediaType, mediaUrl);\n const showMedia = resolved !== \"gradient\" && !!mediaUrl;\n const resolvedPosition = resolveMediaPosition(mediaPosition);\n const resolvedTreatment = resolveMediaTreatment(mediaTreatment);\n const treatmentLayers = getMediaTreatmentLayers(resolvedTreatment);\n\n const gradSeed =\n typeof seed === \"number\"\n ? seed\n : typeof seed === \"string\"\n ? seed.split(\"\").reduce((acc, c) => acc + c.charCodeAt(0), 0)\n : 0;\n\n const bgTransform = getBackgroundTransform(\n backgroundEffect,\n progress,\n beatIntensity,\n );\n\n // Video playback control — same pause/seek logic bg-media used pre-extract.\n const videoRef = useRef<HTMLVideoElement>(null);\n const lastProgress = useRef(progress);\n const videoStarted = useRef(false);\n\n useEffect(() => {\n const vid = videoRef.current;\n if (!vid) return;\n if (!isPlaying) {\n vid.pause();\n videoStarted.current = false;\n return;\n }\n const progressChanged = Math.abs(progress - lastProgress.current) > 0.001;\n lastProgress.current = progress;\n if (progressChanged && !videoStarted.current) {\n vid.playbackRate = 1;\n vid.currentTime = 0;\n vid.play().catch(() => {});\n videoStarted.current = true;\n } else if (!progressChanged && videoStarted.current) {\n vid.pause();\n videoStarted.current = false;\n }\n }, [progress, isPlaying]);\n\n // Release the decoder on unmount. Without this, iOS Safari keeps the\n // video's decoder buffer alive after the React node is gone — each\n // scene transition (or play/pause/play cycle that remounts the active\n // scene) leaks one decoder, eventually crossing the renderer's memory\n // ceiling and triggering \"A problem repeatedly occurred.\" Same recipe\n // as #409's CanvasPreview preload cleanup: pause → clear src → load().\n // Capture the ref at mount-time so the cleanup uses the same node we\n // mounted (the ref's .current is stale by unmount).\n useEffect(() => {\n const vid = videoRef.current;\n return () => {\n if (!vid) return;\n vid.pause();\n vid.removeAttribute(\"src\");\n vid.load();\n };\n }, []);\n\n return (\n <>\n <BrandGradientOverlay\n style={style}\n progress={progress}\n sceneDuration={sceneDuration}\n seed={gradSeed}\n />\n\n {showMedia &&\n (resolved === \"video\" ? (\n <video\n ref={videoRef}\n src={mediaUrl}\n // Poster paints during the decode window so the user sees the\n // (still) first frame instead of a transparent <video> letting\n // the brand gradient show through. Pexels returns a thumbnail\n // image alongside each video; fillPexelsUrls stores it in\n // `variables.mediaPoster`. Layered defense alongside preload=\"auto\"\n // below: on desktop the byte preloader makes decode fast, on\n // mobile (where the preloader skips video pre-mounting to dodge\n // the iOS Safari memory crash) the poster is the primary shield.\n poster={mediaPoster || undefined}\n muted\n loop\n playsInline\n // preload=\"auto\" — without it, browsers default to \"metadata\":\n // they only load the container/dimensions, not the byte stream\n // needed to decode frames. The element then renders transparent\n // until the first decoded frame arrives, letting the brand\n // gradient flash through whenever a scene mid-playback transitions\n // to a media backdrop. The parent preloader caches the bytes, but\n // decoder state is per-element, so the active mount still has to\n // decode the first frame; \"auto\" kicks that work off the instant\n // the element mounts.\n preload=\"auto\"\n data-media-position={mediaPosition}\n style={{\n position: \"absolute\",\n inset: 0,\n width: \"100%\",\n height: \"100%\",\n objectFit: \"cover\",\n objectPosition: resolvedPosition,\n transform: bgTransform.transform,\n transformOrigin: bgTransform.transformOrigin,\n }}\n />\n ) : (\n <div\n data-media-position={mediaPosition}\n style={{\n position: \"absolute\",\n inset: 0,\n transform: bgTransform.transform,\n transformOrigin: bgTransform.transformOrigin,\n backgroundImage: `url(${mediaUrl})`,\n backgroundSize: \"cover\",\n backgroundPosition: resolvedPosition,\n }}\n />\n ))}\n\n {showMedia &&\n treatmentLayers.map((layer) => (\n <div\n key={layer.id}\n data-media-treatment={resolvedTreatment}\n data-media-overlay={layer.id}\n style={{\n position: \"absolute\",\n inset: 0,\n background: layer.background,\n pointerEvents: \"none\",\n ...layer.style,\n }}\n />\n ))}\n </>\n );\n};\n"
|
|
35
|
+
},
|
|
36
|
+
{
|
|
37
|
+
"path": "src/visual-system/scene-templates/types.ts",
|
|
38
|
+
"type": "registry:lib",
|
|
39
|
+
"target": "vanillasky/scene-templates/types.ts",
|
|
40
|
+
"content": "/**\n * Scene template types.\n *\n * A template is a reusable React component that defines how a scene looks.\n * It declares the variables an editor or model may provide\n * and receives universal settings as props.\n *\n * Templates are searchable by AI via description, category, jobs, register,\n * and useWhen guidance.\n * The variable schema enables any LLM to fill in template variables via JSON.\n */\n\nimport type { ResolvedTokens } from \"../theme\";\nimport type { SafeZone, TemplateStyle } from \"../template-context\";\n\n/**\n * Props passed to every scene template component.\n *\n * All animation must be driven by `progress` (0→1). No CSS animations,\n * no Framer Motion, no requestAnimationFrame. Use interpolate/spring\n * from animation-utils.ts.\n *\n * Scale factor: use `Math.min(width, height) / 1080` — normalizes to\n * the short edge so visuals are consistent across portrait and landscape.\n */\nexport interface SceneTemplateProps {\n variables: Record<string, unknown>;\n style: TemplateStyle;\n /** 0→1 through the scene's duration */\n progress: number;\n /** Presentation clock. Active templates receive the same complete 0→1 timeline as progress. */\n motionProgress?: number;\n /** 0→1 beat pulse intensity */\n beatIntensity: number;\n /** 1080 (portrait) or 1920 (landscape) */\n width: number;\n /** 1920 (portrait) or 1080 (landscape) */\n height: number;\n /** Video-level default text effect (for templates that opt in via usesGlobalTextEffect) */\n textArchetype?: string;\n /** How text leaves the scene (fade / shrink / pop / blur-scale). Falls back to a sensible default per textArchetype when undefined. */\n /** Video-level default background effect (for templates that opt in via usesGlobalBackgroundEffect) */\n backgroundEffect?: string;\n /** Platform-aware safe zone insets in pixels — use for text placement */\n safeZone: SafeZone;\n /** Scene duration in seconds — use for time-based (not progress-based) animations */\n sceneDuration?: number;\n /**\n * Brand tokens already resolved from `style`. Built-in templates import\n * resolveTokens directly; an ejected `custom_*` scene can't import anything,\n * so without this it has no way to reach the same values and ends up\n * hardcoding white, black and shadows — the body then looks generic next to\n * a frame that IS using the brand.\n */\n tokens?: ResolvedTokens;\n /**\n * True when the preview player is actively advancing progress; false when paused.\n * Templates that play HTML5 <video> elements should pause them when this is false.\n * Undefined (export capture path) is treated as true.\n */\n isPlaying?: boolean;\n}\n"
|
|
41
|
+
}
|
|
42
|
+
],
|
|
43
|
+
"meta": {
|
|
44
|
+
"vanillasky": {
|
|
45
|
+
"layer": "template",
|
|
46
|
+
"tier": "free",
|
|
47
|
+
"register": "card-led",
|
|
48
|
+
"jobs": [
|
|
49
|
+
"setup",
|
|
50
|
+
"proof"
|
|
51
|
+
],
|
|
52
|
+
"useWhen": "Prompting, asking an AI, or describing an intended result is central to the product workflow.",
|
|
53
|
+
"textCanvas": "open",
|
|
54
|
+
"minDuration": 2.5,
|
|
55
|
+
"preferredDuration": 4,
|
|
56
|
+
"schema": {
|
|
57
|
+
"type": "object",
|
|
58
|
+
"properties": {
|
|
59
|
+
"promptText": {
|
|
60
|
+
"type": "string",
|
|
61
|
+
"title": "Prompt text",
|
|
62
|
+
"description": "Example prompt that types into the AI prompt bar. Use 3-7 words and at most 40 characters so the full prompt stays legible in both orientations (e.g. 'Make a launch video for our app').",
|
|
63
|
+
"minLength": 1,
|
|
64
|
+
"maxLength": 40,
|
|
65
|
+
"default": "Make a launch video for our app"
|
|
66
|
+
},
|
|
67
|
+
"mediaUrl": {
|
|
68
|
+
"type": "string",
|
|
69
|
+
"title": "Background media",
|
|
70
|
+
"description": "Optional photo or video URL behind this scene. When set, replaces the brand gradient.",
|
|
71
|
+
"format": "uri",
|
|
72
|
+
"default": ""
|
|
73
|
+
},
|
|
74
|
+
"mediaKeyword": {
|
|
75
|
+
"type": "string",
|
|
76
|
+
"title": "Background search keyword",
|
|
77
|
+
"description": "2-4 word English term for Pexels stock-footage search (auto-fills mediaUrl).",
|
|
78
|
+
"format": "stock-media-keyword",
|
|
79
|
+
"default": ""
|
|
80
|
+
},
|
|
81
|
+
"mediaType": {
|
|
82
|
+
"type": "string",
|
|
83
|
+
"title": "Background media type",
|
|
84
|
+
"description": "auto detects photo/video from URL. 'gradient' is a deliberate mode — atmospheric brand-color scene with no stock footage.",
|
|
85
|
+
"enum": [
|
|
86
|
+
"auto",
|
|
87
|
+
"photo",
|
|
88
|
+
"video",
|
|
89
|
+
"gradient"
|
|
90
|
+
],
|
|
91
|
+
"default": "auto"
|
|
92
|
+
},
|
|
93
|
+
"mediaPoster": {
|
|
94
|
+
"type": "string",
|
|
95
|
+
"title": "Background poster image",
|
|
96
|
+
"description": "Still image URL shown while a video backdrop is decoding its first frame. Auto-filled from Pexels' thumbnail when fillPexelsUrls sets a video mediaUrl. Hides the gradient flash that would otherwise appear in the ~50–400ms gap between a <video> mounting and decoding its first frame.",
|
|
97
|
+
"format": "uri",
|
|
98
|
+
"default": ""
|
|
99
|
+
},
|
|
100
|
+
"mediaPosition": {
|
|
101
|
+
"type": "string",
|
|
102
|
+
"title": "Background focal position",
|
|
103
|
+
"description": "Controls which part of a photo or video stays visible when cover-cropped. Pick the subject's side or vertical anchor after inspecting the frame.",
|
|
104
|
+
"enum": [
|
|
105
|
+
"center",
|
|
106
|
+
"top",
|
|
107
|
+
"bottom",
|
|
108
|
+
"left",
|
|
109
|
+
"right"
|
|
110
|
+
],
|
|
111
|
+
"default": "center"
|
|
112
|
+
},
|
|
113
|
+
"mediaTreatment": {
|
|
114
|
+
"type": "string",
|
|
115
|
+
"title": "Background contrast treatment",
|
|
116
|
+
"description": "subtle preserves a visual hero; cinematic adds balanced contrast; text-safe adds a stronger wash for copy-heavy scenes.",
|
|
117
|
+
"enum": [
|
|
118
|
+
"subtle",
|
|
119
|
+
"cinematic",
|
|
120
|
+
"text-safe"
|
|
121
|
+
],
|
|
122
|
+
"default": "cinematic"
|
|
123
|
+
}
|
|
124
|
+
},
|
|
125
|
+
"required": [
|
|
126
|
+
"promptText"
|
|
127
|
+
],
|
|
128
|
+
"additionalProperties": false,
|
|
129
|
+
"x-vanillasky": {
|
|
130
|
+
"allowsStockMedia": true
|
|
131
|
+
}
|
|
132
|
+
},
|
|
133
|
+
"label": "Prompt input",
|
|
134
|
+
"description": "An AI prompt pill expands and types a user instruction over a branded background.",
|
|
135
|
+
"family": "Product showcase",
|
|
136
|
+
"avoidWhen": "The product is not prompt-driven or the source provides no meaningful prompt to demonstrate.",
|
|
137
|
+
"usesGlobalTextEffect": false,
|
|
138
|
+
"usesGlobalTransition": false,
|
|
139
|
+
"usesGlobalBackgroundEffect": true,
|
|
140
|
+
"timing": {
|
|
141
|
+
"contentFields": [
|
|
142
|
+
"promptText"
|
|
143
|
+
],
|
|
144
|
+
"contentUnit": "characters"
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
}
|