File size: 27,027 Bytes
9713441 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 | import fs from 'node:fs';
import path from 'node:path';
import os from 'node:os';
import { execFile } from 'node:child_process';
import { promisify } from 'node:util';
import type {
FramePresetItem,
SceneBlueprintItem,
MotionRuleItem,
TransitionItem,
RegistryCatalogItem,
} from '@olokaflow/shared';
const execFileAsync = promisify(execFile);
const DEFAULT_SKILLS_ROOT =
process.env.HYPERFRAMES_SKILLS_DIR ||
path.join(os.homedir(), '.gemini', 'config', 'skills');
const PRESETS_DIR = path.join(DEFAULT_SKILLS_ROOT, 'hyperframes-creative', 'frame-presets');
const BLUEPRINTS_DIR = path.join(DEFAULT_SKILLS_ROOT, 'hyperframes-animation', 'blueprints');
const RULES_DIR = path.join(DEFAULT_SKILLS_ROOT, 'hyperframes-animation', 'rules');
const TRANSITIONS_DIR = path.join(DEFAULT_SKILLS_ROOT, 'hyperframes-animation', 'transitions');
// Built-in metadata for the 13 HyperFrames Frame Presets (works even inside Docker without local skill dir)
const BUILTIN_FRAME_PRESETS: FramePresetItem[] = [
{
id: 'blue-professional',
name: 'Blue Professional (Enterprise & SaaS)',
description: 'Nền kem ấm (#fdfae7) kết hợp xanh Cobalt sắc nét (#1e2bfa), Space Grotesk + Be Vietnam Pro, thẻ bo tròn tinh tế.',
colors: { bg: '#fdfae7', primary: '#1e2bfa', text: '#111111', textMuted: '#6b6b6b', cardBg: 'rgba(30,43,250,0.05)', border: 'rgba(30,43,250,0.2)' },
typography: { heading: 'Space Grotesk', body: 'Be Vietnam Pro', mono: 'JetBrains Mono' },
rawYaml: 'colors:\n bg: "#fdfae7"\n primary: "#1e2bfa"\n text: "#111111"',
rawMarkdown: '',
},
{
id: 'blockframe',
name: 'Blockframe (Neobrutalist Bold)',
description: 'Phong cách Neobrutalism độ tương phản cao, viền đen dày 2px, đổ bóng cứng 4px, cực hợp TikTok/Reels công nghệ & GenZ.',
colors: { bg: '#f4f0ea', primary: '#ff4d00', text: '#0d0d0d', textMuted: '#4a4a4a', cardBg: '#ffffff', border: '#0d0d0d' },
typography: { heading: 'Space Grotesk', body: 'Plus Jakarta Sans', mono: 'JetBrains Mono' },
rawYaml: 'colors:\n bg: "#f4f0ea"\n primary: "#ff4d00"\n text: "#0d0d0d"',
rawMarkdown: '',
},
{
id: 'code-editorial',
name: 'Code Editorial (Dark AI & Developer)',
description: 'Nền tối Obsidian (#090d16) chuẩn IDE cao cấp, điểm nhấn xanh lục/tím Neon, hoàn hảo cho giới thiệu AI, phần mềm, API.',
colors: { bg: '#090d16', primary: '#38bdf8', text: '#f8fafc', textMuted: '#94a3b8', cardBg: 'rgba(30,41,59,0.75)', border: 'rgba(56,189,248,0.28)' },
typography: { heading: 'Space Grotesk', body: 'Be Vietnam Pro', mono: 'JetBrains Mono' },
rawYaml: 'colors:\n bg: "#090d16"\n primary: "#38bdf8"\n text: "#f8fafc"',
rawMarkdown: '',
},
{
id: 'biennale-yellow',
name: 'Biennale Yellow (High-Impact Exhibition)',
description: 'Nền vàng nghệ thuật rực rỡ kết hợp chữ đen đậm và điểm nhấn đỏ cam, thu hút sự chú ý ngay từ 0.5 giây đầu tiên.',
colors: { bg: '#ffd600', primary: '#111111', text: '#111111', textMuted: '#333333', cardBg: '#fff8cc', border: '#111111' },
typography: { heading: 'Montserrat', body: 'Be Vietnam Pro', mono: 'JetBrains Mono' },
rawYaml: 'colors:\n bg: "#ffd600"\n primary: "#111111"\n text: "#111111"',
rawMarkdown: '',
},
{
id: 'bold-poster',
name: 'Bold Poster (Kinetic Promo & Ad)',
description: 'Thiết kế áp phích đại tự, tương phản Đỏ Crimson - Đen - Trắng mạnh mẽ cho video bán hàng và khuyến mãi.',
colors: { bg: '#0f0f12', primary: '#ef4444', text: '#ffffff', textMuted: '#a1a1aa', cardBg: '#18181b', border: 'rgba(239,68,68,0.4)' },
typography: { heading: 'Oswald', body: 'Be Vietnam Pro', mono: 'JetBrains Mono' },
rawYaml: 'colors:\n bg: "#0f0f12"\n primary: "#ef4444"\n text: "#ffffff"',
rawMarkdown: '',
},
{
id: 'cobalt-grid',
name: 'Cobalt Grid (FinTech & Data Analytics)',
description: 'Hệ lưới kỹ thuật số màu xanh đêm và lục bảo, chuyên trị biểu đồ tài chính, chứng khoán, B2B và báo cáo dữ liệu.',
colors: { bg: '#061325', primary: '#10b981', text: '#f0fdf4', textMuted: '#94a3b8', cardBg: 'rgba(15,35,66,0.8)', border: 'rgba(16,185,129,0.3)' },
typography: { heading: 'Space Grotesk', body: 'Inter', mono: 'JetBrains Mono' },
rawYaml: 'colors:\n bg: "#061325"\n primary: "#10b981"\n text: "#f0fdf4"',
rawMarkdown: '',
},
{
id: 'coral',
name: 'Coral Lifestyle (E-Commerce, Beauty & Brand)',
description: 'Tông hồng cam san hô (#f43f5e) trên nền sáng tinh khôi, lý tưởng cho mỹ phẩm, thời trang, F&B và thương hiệu tiêu dùng.',
colors: { bg: '#fff5f5', primary: '#e11d48', text: '#1f2937', textMuted: '#6b7280', cardBg: '#ffffff', border: 'rgba(225,29,72,0.18)' },
typography: { heading: 'Playfair Display', body: 'Be Vietnam Pro', mono: 'JetBrains Mono' },
rawYaml: 'colors:\n bg: "#fff5f5"\n primary: "#e11d48"\n text: "#1f2937"',
rawMarkdown: '',
},
{
id: 'editorial-forest',
name: 'Editorial Forest (Luxury, Organic & ESG)',
description: 'Xanh rừng sâu kết hợp vàng đồng sang trọng, phù hợp bất động sản, sức khỏe, dược phẩm, nông nghiệp xanh.',
colors: { bg: '#0c241b', primary: '#eab308', text: '#f7fee7', textMuted: '#a3b8b0', cardBg: 'rgba(20,56,42,0.85)', border: 'rgba(234,179,8,0.3)' },
typography: { heading: 'Playfair Display', body: 'Be Vietnam Pro', mono: 'JetBrains Mono' },
rawYaml: 'colors:\n bg: "#0c241b"\n primary: "#eab308"\n text: "#f7fee7"',
rawMarkdown: '',
},
{
id: 'capsule',
name: 'Capsule Modern (Minimal Apple-Style)',
description: 'Thiết kế tối giản lấy cảm hứng từ Apple keynote với các thẻ viên thuốc (pill), đổ bóng mềm và khoảng thở rộng.',
colors: { bg: '#f5f5f7', primary: '#0071e3', text: '#1d1d1f', textMuted: '#86868b', cardBg: '#ffffff', border: 'rgba(0,0,0,0.08)' },
typography: { heading: 'Plus Jakarta Sans', body: 'Be Vietnam Pro', mono: 'JetBrains Mono' },
rawYaml: 'colors:\n bg: "#f5f5f7"\n primary: "#0071e3"\n text: "#1d1d1f"',
rawMarkdown: '',
},
{
id: 'creative-mode',
name: 'Creative Mode (Vibrant Violet Studio)',
description: 'Tím Violet sáng tạo kết hợp hiệu ứng kính mờ (Glassmorphism) và chuyển sắc sống động.',
colors: { bg: '#0f0720', primary: '#a855f7', text: '#faf5ff', textMuted: '#c084fc', cardBg: 'rgba(38,16,74,0.75)', border: 'rgba(168,85,247,0.35)' },
typography: { heading: 'Plus Jakarta Sans', body: 'Be Vietnam Pro', mono: 'JetBrains Mono' },
rawYaml: 'colors:\n bg: "#0f0720"\n primary: "#a855f7"\n text: "#faf5ff"',
rawMarkdown: '',
},
{
id: 'cartesian',
name: 'Cartesian Blueprint (Engineering & Architecture)',
description: 'Phong cách bản vẽ kỹ thuật với lưới tọa độ mảnh, phông chữ kỹ thuật số và độ chính xác cao.',
colors: { bg: '#0b192c', primary: '#38bdf8', text: '#e2e8f0', textMuted: '#64748b', cardBg: 'rgba(15,35,60,0.8)', border: 'rgba(56,189,248,0.25)' },
typography: { heading: 'Chakra Petch', body: 'Be Vietnam Pro', mono: 'JetBrains Mono' },
rawYaml: 'colors:\n bg: "#0b192c"\n primary: "#38bdf8"\n text: "#e2e8f0"',
rawMarkdown: '',
},
{
id: 'broadside',
name: 'Broadside Newspaper (News & Documentary)',
description: 'Bố cục báo chí chính luận, tiêu đề Serif uy tín, đường kẻ phân cột rõ ràng cho video tin tức & phân tích.',
colors: { bg: '#f9f6f0', primary: '#b91c1c', text: '#171717', textMuted: '#525252', cardBg: '#f0ece1', border: '#262626' },
typography: { heading: 'Playfair Display', body: 'Be Vietnam Pro', mono: 'JetBrains Mono' },
rawYaml: 'colors:\n bg: "#f9f6f0"\n primary: "#b91c1c"\n text: "#171717"',
rawMarkdown: '',
},
{
id: 'daisy-days',
name: 'Daisy Days (Friendly Education & Kids)',
description: 'Màu sắc tươi sáng, thân thiện, bo góc tròn mềm mại cho video giáo dục, hướng dẫn và mẹ & bé.',
colors: { bg: '#fefce8', primary: '#16a34a', text: '#14532d', textMuted: '#4d7c0f', cardBg: '#ffffff', border: 'rgba(22,163,74,0.25)' },
typography: { heading: 'Plus Jakarta Sans', body: 'Be Vietnam Pro', mono: 'JetBrains Mono' },
rawYaml: 'colors:\n bg: "#fefce8"\n primary: "#16a34a"\n text: "#14532d"',
rawMarkdown: '',
},
];
// Built-in metadata for the 22 Scene Blueprints
const BUILTIN_BLUEPRINTS: SceneBlueprintItem[] = [
{
id: 'kinetic-type-beats',
title: 'Kinetic-Type Beats (Nhịp Chữ Động)',
intent: 'Chữ lớn giữa màn hình thay đổi theo từng nhịp câu thoại hoặc bật nẩy (spring-pop) kết hợp điểm nhấn màu.',
rolesServed: ['Hook', 'Problem', 'Product_Intro', 'Benefits', 'CTA'],
durationHint: '3.0–6.0s',
motionVocabulary: 'spring-pop scale, word-by-word reveal, drawn accent underline, bg-invert flip',
ruleMapping: ['kinetic-beat-slam', 'spring-pop-entrance', 'css-marker-patterns'],
rawMarkdown: '',
},
{
id: 'device-surface-showcase',
title: 'Device Surface Showcase (Trình Diễn Sản Phẩm / Giao Diện)',
intent: 'Khung sản phẩm hoặc ảnh chủ đạo nổi bật ở trung tâm với góc nghiêng 3D nhẹ, xung quanh là các nhãn tính năng bật ra theo nhịp.',
rolesServed: ['Product_Intro', 'Key_Feature', 'Benefits'],
durationHint: '4.0–7.0s',
motionVocabulary: '3D perspective tilt, floating callout badges, hero image zoom-settle, glow ring',
ruleMapping: ['3d-camera-flight', 'spring-pop-entrance', 'coordinate-target-zoom'],
rawMarkdown: '',
},
{
id: 'dataviz-countup',
title: 'DataViz Count-Up (Biểu Đồ & Số Liệu Tăng Trưởng)',
intent: 'Con số thống kê nhảy số tự động (count-up) đi kèm thanh biểu đồ tăng trưởng hoặc thẻ so sánh trực quan.',
rolesServed: ['Data_Proof', 'Benefits', 'Social_Proof'],
durationHint: '4.0–6.5s',
motionVocabulary: 'number count-up, bar width grow stagger, metric card highlight, positive badge pulse',
ruleMapping: ['counting-dynamic-scale', 'chart-scrub-readout', 'waterfall-entry'],
rawMarkdown: '',
},
{
id: 'grid-card-assemble',
title: 'Grid Card Assemble (Lưới Thẻ Tính Năng Lắp Ghép)',
intent: '2 đến 4 thẻ thông tin/hình ảnh bay vào lắp ghép thành bố cục Bento Grid hiện đại, lần lượt sáng lên theo lời thoại.',
rolesServed: ['Key_Feature', 'Benefits', 'Social_Proof'],
durationHint: '4.5–7.5s',
motionVocabulary: 'staggered card slide-in, active card spotlight scale, icon badge pop',
ruleMapping: ['waterfall-entry', 'spring-pop-entrance', 'coordinate-target-zoom'],
rawMarkdown: '',
},
{
id: 'comparison-split',
title: 'Comparison Split (So Sánh Trước / Sau hoặc Cũ / Mới)',
intent: 'Chia đôi màn hình đối chiếu rõ rệt giữa Cách Cũ (tối, gạch chéo đỏ) và Giải Pháp Mới (sáng, nổi bật, tích xanh).',
rolesServed: ['Problem', 'Benefits', 'Data_Proof'],
durationHint: '4.5–6.5s',
motionVocabulary: 'split-screen wipe, red cross strike-out vs green check pop, winner card expand',
ruleMapping: ['scale-swap-transition', 'spring-pop-entrance', 'css-marker-patterns'],
rawMarkdown: '',
},
{
id: 'cursor-ui-demo',
title: 'Cursor UI Demo (Mô Phỏng Thao Tác & Phóng To Chi Tiết)',
intent: 'Con trỏ di chuyển thông minh tới điểm nhấn, click tạo sóng (ripple) và phóng cận cảnh vào kết quả.',
rolesServed: ['Key_Feature', 'Product_Intro'],
durationHint: '4.5–7.0s',
motionVocabulary: 'smooth cursor path, click ripple ring, camera target zoom, tooltip reveal',
ruleMapping: ['cursor-click-ripple', 'coordinate-target-zoom', 'context-sensitive-cursor'],
rawMarkdown: '',
},
{
id: 'logo-assemble-lockup',
title: 'Logo Assemble & CTA Lockup (Khóa Thương Hiệu & Kêu Gọi Hành Động)',
intent: 'Logo thương hiệu, ảnh sản phẩm chính chủ và nút CTA hội tụ ở trung tâm với hiệu ứng phát sáng khóa màn hình cuối.',
rolesServed: ['CTA', 'Product_Intro'],
durationHint: '3.5–5.5s',
motionVocabulary: 'logo spring lockup, pulsing CTA pill button, radial glow burst, URL/hotline badge',
ruleMapping: ['spring-pop-entrance', 'particle-burst', 'physics-press-reaction'],
rawMarkdown: '',
},
{
id: 'typewriter-reveal',
title: 'Typewriter Reveal (Gõ Chữ Kịch Tính)',
intent: 'Văn bản hoặc câu hỏi mở đầu được gõ từng ký tự với con trỏ nhấp nháy, sau đó mở bung ra toàn cảnh.',
rolesServed: ['Hook', 'Problem'],
durationHint: '3.5–5.5s',
motionVocabulary: 'char-by-char typing, blinking caret, highlight sweep',
ruleMapping: ['discrete-text-sequence', 'context-sensitive-cursor'],
rawMarkdown: '',
},
{
id: 'camera-journey',
title: 'Camera Journey (Hành Trình Không Gian 3D)',
intent: 'Camera lướt qua các trạm thông tin/hình ảnh có chiều sâu Z-axis tạo cảm giác điện ảnh.',
rolesServed: ['Product_Intro', 'Key_Feature', 'Benefits'],
durationHint: '5.0–8.0s',
motionVocabulary: 'Z-axis dolly, parallax layers, depth-of-field focus shift',
ruleMapping: ['3d-camera-flight', 'depth-of-field-blur'],
rawMarkdown: '',
},
{
id: 'overwhelm-surround',
title: 'Overwhelm Surround (Bủa Vây Vấn Đề -> Giải Giải Pháp)',
intent: 'Các thẻ vấn đề/nỗi đau xuất hiện dồn dập xung quanh rồi bị quét sạch để nhường chỗ cho giải pháp duy nhất.',
rolesServed: ['Problem', 'Hook'],
durationHint: '4.0–6.0s',
motionVocabulary: 'pop-up chaos cards, chromatic glitch shake, clean radial sweep',
ruleMapping: ['chromatic-glitch', 'waterfall-entry', 'scale-swap-transition'],
rawMarkdown: '',
},
{
id: 'prompt-type-submit-generate',
title: 'Prompt Submit & Generate (Nhập Lệnh -> Tạo Kết Quả Tức Thì)',
intent: 'Khung tìm kiếm/nhập lệnh tự gõ nội dung, bấm nút gửi và bung ra kết quả trực quan ngay bên dưới.',
rolesServed: ['Product_Intro', 'Key_Feature'],
durationHint: '4.5–6.5s',
motionVocabulary: 'input typing, button press bounce, result card cascade',
ruleMapping: ['discrete-text-sequence', 'physics-press-reaction', 'waterfall-entry'],
rawMarkdown: '',
},
{
id: 'video-text-pivot',
title: 'Video B-Roll & Kinetic Text Pivot (Kết Hợp Video Thực Tế & Chữ Động)',
intent: 'Phát đoạn video B-roll thực tế trong khung bo tròn hoặc toàn màn hình kết hợp dải tiêu đề động nổi bật.',
rolesServed: ['Hook', 'Product_Intro', 'Key_Feature', 'Social_Proof'],
durationHint: '4.0–7.0s',
motionVocabulary: 'video frame pan/scale, glassmorphic lower-third badge, kinetic title overlay',
ruleMapping: ['spring-pop-entrance', 'coordinate-target-zoom'],
rawMarkdown: '',
},
];
// Built-in Atomic Motion Rules
const BUILTIN_MOTION_RULES: MotionRuleItem[] = [
{
id: 'spring-pop-entrance',
title: 'Spring Pop Entrance',
category: 'Entrance',
summary: 'Hiệu ứng bật nẩy đàn hồi `back.out(1.7)` từ `scale: 0.72, opacity: 0` lên `scale: 1, opacity: 1` trong 0.45s.',
rawMarkdown: 'gsap.fromTo(el, { scale: 0.72, opacity: 0, y: 24 }, { scale: 1, opacity: 1, y: 0, duration: 0.48, ease: "back.out(1.7)" })',
},
{
id: 'waterfall-entry',
title: 'Waterfall Stagger Entry',
category: 'Sequencing',
summary: 'Các thẻ hoặc dòng nội dung trượt lên nối tiếp nhau với `stagger: 0.12` và `power3.out`.',
rawMarkdown: 'gsap.fromTo(cards, { y: 40, opacity: 0 }, { y: 0, opacity: 1, duration: 0.5, stagger: 0.12, ease: "power3.out" })',
},
{
id: 'kinetic-beat-slam',
title: 'Kinetic Beat Slam',
category: 'Typography',
summary: 'Từ khóa chính phóng từ `scale: 1.4, filter: blur(8px)` về `scale: 1, blur(0px)` khớp chính xác với nhịp câu thoại.',
rawMarkdown: 'gsap.fromTo(word, { scale: 1.35, opacity: 0 }, { scale: 1, opacity: 1, duration: 0.35, ease: "expo.out" })',
},
{
id: 'counting-dynamic-scale',
title: 'Counting Dynamic Scale',
category: 'DataViz',
summary: 'Số liệu nhảy tăng dần từ 0 tới giá trị đích kết hợp phóng nhẹ khi chạm đích.',
rawMarkdown: 'gsap.to(counterObj, { val: targetVal, duration: 1.4, ease: "power2.out", onUpdate: () => { el.textContent = Math.round(counterObj.val).toLocaleString(); } })',
},
{
id: '3d-camera-flight',
title: '3D Perspective Camera Flight',
category: 'Camera',
summary: 'Khung hình sản phẩm nghiêng nhẹ trong không gian 3D (`rotateY(-12deg) rotateX(6deg)`) rồi xoay thẳng về chính diện.',
rawMarkdown: 'gsap.fromTo(surface, { rotateY: -14, rotateX: 8, scale: 0.9, opacity: 0 }, { rotateY: 0, rotateX: 0, scale: 1, opacity: 1, duration: 0.85, ease: "power3.out" })',
},
{
id: 'coordinate-target-zoom',
title: 'Coordinate Target Zoom',
category: 'Camera',
summary: 'Phóng cận cảnh mượt mà vào điểm nhấn quan trọng của bức ảnh tham khảo (Ken Burns / Focus Zoom).',
rawMarkdown: 'gsap.fromTo(img, { scale: 1 }, { scale: 1.12, duration: sceneDuration, ease: "sine.inOut" })',
},
{
id: 'cursor-click-ripple',
title: 'Cursor Click & Ripple Ring',
category: 'UI Motion',
summary: 'Con trỏ lướt tới nút bấm, nhấn xuống (`scale: 0.94`) và tỏa vòng sóng tròn lan rộng.',
rawMarkdown: 'tl.to(cursor, { x: targetX, y: targetY, duration: 0.6, ease: "power2.inOut" }).to(btn, { scale: 0.94, duration: 0.1, yoyo: true, repeat: 1 })',
},
{
id: 'chromatic-glitch',
title: 'Chromatic RGB Glitch Shake',
category: 'VFX',
summary: 'Rung lắc nhẹ kèm tách kênh màu đỏ/xanh cho cảnh nêu vấn đề (Problem) hoặc cảnh công nghệ.',
rawMarkdown: 'gsap.fromTo(el, { x: -6, textShadow: "3px 0 #ff0055, -3px 0 #00e5ff" }, { x: 0, textShadow: "0px 0 transparent", duration: 0.35, ease: "rough" })',
},
{
id: 'css-marker-patterns',
title: 'CSS Marker Highlight Sweep',
category: 'Typography',
summary: 'Dải màu đánh dấu hoặc gạch chân vẽ từ trái sang phải (`scaleX: 0 -> 1`) dưới từ khóa quan trọng.',
rawMarkdown: 'gsap.fromTo(marker, { scaleX: 0, transformOrigin: "left center" }, { scaleX: 1, duration: 0.45, ease: "power2.out" })',
},
{
id: 'particle-burst',
title: 'Accent Particle / Glow Burst',
category: 'VFX',
summary: 'Vòng sáng hào quang và các hạt điểm nhấn bung tỏa quanh Logo hoặc sản phẩm ở cảnh kết.',
rawMarkdown: 'gsap.fromTo(glow, { scale: 0.6, opacity: 0 }, { scale: 1.25, opacity: 0.85, duration: 0.9, ease: "sine.out" })',
},
];
// Built-in Registry Blocks & Components
const BUILTIN_REGISTRY_CATALOG: RegistryCatalogItem[] = [
{ name: 'quote-card', kind: 'block', description: 'Thẻ trích dẫn / Hook nổi bật với dấu ngoặc kép lớn và nhãn tác giả/thương hiệu', tags: ['hook', 'quote', 'typography', 'card'] },
{ name: 'app-showcase', kind: 'block', description: 'Khung trình diễn sản phẩm / giao diện ứng dụng hoặc hình ảnh thực tế kèm 3 thẻ tính năng nổi', tags: ['product', 'showcase', 'ui', 'device', 'hero'] },
{ name: 'data-chart', kind: 'block', description: 'Bảng biểu đồ cột tăng trưởng & 3 thẻ chỉ số KPI nhảy số tự động', tags: ['chart', 'data', 'metrics', 'numbers', 'growth'] },
{ name: 'flowchart', kind: 'block', description: 'Sơ đồ quy trình 3 bước trực quan với mũi tên nối động', tags: ['process', 'steps', 'workflow', 'diagram'] },
{ name: 'logo-outro', kind: 'block', description: 'Màn hình kết thúc khóa nhận diện Logo, Slogan, Website/Hotline và nút bấm CTA', tags: ['cta', 'outro', 'logo', 'brand', 'ending'] },
{ name: 'tiktok-follow', kind: 'block', description: 'Nút kêu gọi Follow / Đặt hàng chuẩn giao diện TikTok/Reels với hiệu ứng nhấn', tags: ['tiktok', 'social', 'cta', 'vertical'] },
{ name: 'yt-lower-third', kind: 'block', description: 'Thanh tiêu đề phụ góc dưới (Lower-Third) giới thiệu tên sản phẩm / chuyên gia', tags: ['lower-third', 'banner', 'caption', 'title'] },
{ name: 'caption-clip-wipe', kind: 'component', description: 'Bộ phụ đề Karaoke đồng bộ từng từ (Word-by-word active pill highlight)', tags: ['caption', 'subtitles', 'karaoke', 'voice'] },
{ name: 'grain-overlay', kind: 'component', description: 'Lớp phủ hạt phim điện ảnh tinh tế (Film grain texture)', tags: ['texture', 'film', 'overlay'] },
{ name: 'shimmer-sweep', kind: 'component', description: 'Vệt sáng ánh kim quét qua nút bấm CTA hoặc thẻ sản phẩm cao cấp', tags: ['shimmer', 'glow', 'button', 'luxury'] },
];
// Built-in Transitions
const BUILTIN_TRANSITIONS: TransitionItem[] = [
{
id: 'fade-blur',
name: 'Focus Pull Dissolve',
family: 'css-blur',
description: 'Chuyển cảnh mờ dần kết hợp lấy nét nhẹ mượt mà',
cssOrJsSnippet: 'gsap.fromTo(sceneRoot, { opacity: 0, scale: 1.03 }, { opacity: 1, scale: 1, duration: 0.35, ease: "power2.out" });',
},
{
id: 'push-up',
name: 'Kinetic Vertical Push',
family: 'css-push',
description: 'Cảnh mới trượt nhanh từ dưới lên theo chuẩn lướt TikTok/Reels',
cssOrJsSnippet: 'gsap.fromTo(sceneRoot, { yPercent: 12, opacity: 0 }, { yPercent: 0, opacity: 1, duration: 0.38, ease: "power3.out" });',
},
{
id: 'zoom-through',
name: 'Camera Zoom-Through',
family: 'css-scale',
description: 'Phóng xuyên qua không gian vào cảnh tiếp theo',
cssOrJsSnippet: 'gsap.fromTo(sceneRoot, { scale: 0.88, opacity: 0 }, { scale: 1, opacity: 1, duration: 0.4, ease: "expo.out" });',
},
{
id: 'circle-iris',
name: 'Expanding Circle Iris',
family: 'css-radial',
description: 'Mở vòng tròn từ tâm màn hình ra toàn khung cảnh',
cssOrJsSnippet: 'gsap.fromTo(sceneRoot, { clipPath: "circle(0% at 50% 50%)" }, { clipPath: "circle(150% at 50% 50%)", duration: 0.55, ease: "power3.inOut" });',
},
];
let cachedPresets: FramePresetItem[] | null = null;
let cachedBlueprints: SceneBlueprintItem[] | null = null;
let cachedRules: MotionRuleItem[] | null = null;
export function getFramePresets(): FramePresetItem[] {
if (cachedPresets) return cachedPresets;
const list = [...BUILTIN_FRAME_PRESETS];
try {
if (fs.existsSync(PRESETS_DIR)) {
for (const preset of list) {
const frameMdPath = path.join(PRESETS_DIR, preset.id, 'FRAME.md');
if (fs.existsSync(frameMdPath)) {
const content = fs.readFileSync(frameMdPath, 'utf8');
preset.rawMarkdown = content.slice(0, 4500);
const yamlMatch = content.match(/^---\r?\n([\s\S]*?)\r?\n---/);
if (yamlMatch) {
preset.rawYaml = yamlMatch[1].slice(0, 2500);
}
}
}
}
} catch (err) {
console.warn('[HyperFramesCatalog] Could not read local preset markdown:', err);
}
cachedPresets = list;
return list;
}
export function getFramePresetById(id: string): FramePresetItem {
const presets = getFramePresets();
return presets.find((p) => p.id === id) || presets[0];
}
export function getSceneBlueprints(): SceneBlueprintItem[] {
if (cachedBlueprints) return cachedBlueprints;
const list = [...BUILTIN_BLUEPRINTS];
try {
if (fs.existsSync(BLUEPRINTS_DIR)) {
for (const bp of list) {
const mdPath = path.join(BLUEPRINTS_DIR, `${bp.id}.md`);
if (fs.existsSync(mdPath)) {
bp.rawMarkdown = fs.readFileSync(mdPath, 'utf8').slice(0, 3500);
}
}
}
} catch (err) {
console.warn('[HyperFramesCatalog] Could not read local blueprint markdown:', err);
}
cachedBlueprints = list;
return list;
}
export function getSceneBlueprintById(id: string): SceneBlueprintItem {
const blueprints = getSceneBlueprints();
return blueprints.find((b) => b.id === id) || blueprints[0];
}
export function getMotionRules(): MotionRuleItem[] {
if (cachedRules) return cachedRules;
const list = [...BUILTIN_MOTION_RULES];
try {
if (fs.existsSync(RULES_DIR)) {
for (const rule of list) {
const mdPath = path.join(RULES_DIR, `${rule.id}.md`);
if (fs.existsSync(mdPath)) {
rule.rawMarkdown = fs.readFileSync(mdPath, 'utf8').slice(0, 2200);
}
}
}
} catch {
// Fallback to built-in rules
}
cachedRules = list;
return list;
}
export function getTransitions(): TransitionItem[] {
return BUILTIN_TRANSITIONS;
}
export function getRegistryCatalogItems(): RegistryCatalogItem[] {
return BUILTIN_REGISTRY_CATALOG;
}
/**
* Searches the HyperFrames Registry Catalog (uses on-device CLI if available + built-in ranked matcher).
*/
export async function searchHyperFramesCatalog(query: string): Promise<RegistryCatalogItem[]> {
const q = (query || '').toLowerCase().trim();
if (!q) return BUILTIN_REGISTRY_CATALOG;
// Score built-in items first
const tokens = q.split(/\s+/).filter(Boolean);
const scored = BUILTIN_REGISTRY_CATALOG.map((item) => {
const hay = `${item.name} ${item.description} ${item.tags.join(' ')}`.toLowerCase();
let score = 0;
for (const t of tokens) {
if (hay.includes(t)) score += 10;
}
return { ...item, score };
}).sort((a, b) => (b.score || 0) - (a.score || 0));
try {
const isWin = process.platform === 'win32';
const cmd = isWin ? 'npx.cmd' : 'npx';
const { stdout } = await execFileAsync(
cmd,
['hyperframes', 'catalog', '--query', query, '--on-device', '--json'],
{ timeout: 6000 }
);
const parsed = JSON.parse(stdout);
const items = Array.isArray(parsed) ? parsed : Array.isArray(parsed?.items) ? parsed.items : [];
if (items.length > 0) {
const cliMapped: RegistryCatalogItem[] = items.slice(0, 8).map((it: any) => ({
name: it.name || it.id || 'custom-block',
kind: it.kind === 'component' ? 'component' : 'block',
description: it.description || it.summary || '',
tags: Array.isArray(it.tags) ? it.tags : [],
score: typeof it.score === 'number' ? it.score : 15,
}));
return [...cliMapped, ...scored.slice(0, 4)];
}
} catch {
// Use scored built-in catalog seamlessly
}
return scored;
}
|