Files
hyperframes/docs/public/catalog/blocks/code-snippet-apple-terminal-basic.json
Miguel Ángel 536165b6ef feat(catalog): play the real composition on catalog pages (#3168)
* feat(catalog): play the real composition on catalog pages

Catalog previews were uploaded MP4s, published by hand to the CDN. Each page
now embeds the composition itself, running in <hyperframes-player>, so a
preview is the block rather than a recording of it.

The composition is delivered as JSON under docs/public/catalog, and the player
is mounted inside an iframe. Both are forced: the docs host publishes only JSON
and images out of docs/public, and its MDX renderer strips unknown custom
elements, so a player written into the page never reaches the DOM and an .html
payload 404s in production.

Assets are inlined as data URIs, which sidesteps the file-type restriction for
fonts, scripts and models alike. 164 of 168 items build a payload; the rest
keep their MP4 and say so.

* chore: rebuild docs preview

* chore: route isolation probe

* chore: drop the route isolation probe page

* chore: probe which asset types the docs host publishes

* refactor(catalog): host preview assets instead of inlining them

Fonts were being base64'd into every payload that used them, so a handful of
files cost tens of megabytes in the repository to say the same thing over and
over. Assets are now written once, content-addressed, under
docs/public/catalog/assets and linked.

Which types can be hosted was settled by fetching one file of each from a
deployed preview: woff2, wav, mp4, svg and the image formats are published,
glb is not. Types the host drops still travel inside the payload, because a
link that 404s is worse than a larger payload.

Also fixes the four type errors the scripts typecheck caught, all of them
unchecked index access on a split() result.

* refactor(catalog): share preview assets instead of repeating them

* style: format the asset module
2026-08-10 17:54:48 -04:00

1 line
7.4 KiB
JSON
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
{"html":"<!doctype html>\n<html lang=\"en\">\n <head>\n <meta charset=\"UTF-8\" />\n <meta name=\"viewport\" content=\"width=1920, height=1080\" />\n <title>Apple Terminal Basic</title>\n <style>\n html,\n body {\n margin: 0;\n padding: 0;\n width: 1920px;\n height: 1080px;\n overflow: hidden;\n background: #ececec;\n font-family: \"SF Mono\", Menlo, Monaco, Consolas, \"Courier New\", monospace;\n }\n\n #scene {\n width: 1920px;\n height: 1080px;\n position: relative;\n display: flex;\n align-items: center;\n justify-content: center;\n background: linear-gradient(135deg, #e8e8e8 0%, #d8d8d8 100%);\n }\n\n .terminal-window {\n width: 1400px;\n height: 700px;\n border-radius: 10px;\n overflow: hidden;\n box-shadow:\n 0 30px 80px rgba(0, 0, 0, 0.25),\n 0 10px 30px rgba(0, 0, 0, 0.15);\n display: flex;\n flex-direction: column;\n }\n\n .titlebar {\n height: 38px;\n background: #ececec;\n display: flex;\n align-items: center;\n padding: 0 14px;\n gap: 0;\n flex-shrink: 0;\n border-bottom: 1px solid #d0d0d0;\n position: relative;\n }\n\n .traffic-lights {\n display: flex;\n gap: 8px;\n align-items: center;\n }\n\n .traffic-lights span {\n width: 13px;\n height: 13px;\n border-radius: 50%;\n display: inline-block;\n }\n\n .traffic-lights .close {\n background: #ff5f57;\n border: 1px solid #e0443e;\n }\n\n .traffic-lights .minimize {\n background: #ffbd2e;\n border: 1px solid #dfa123;\n }\n\n .traffic-lights .fullscreen {\n background: #28c840;\n border: 1px solid #1aab29;\n }\n\n .window-title {\n position: absolute;\n left: 50%;\n transform: translateX(-50%);\n font-size: 13px;\n color: #333333;\n font-family: -apple-system, BlinkMacSystemFont, \"SF Pro Text\", sans-serif;\n font-weight: 500;\n letter-spacing: -0.1px;\n }\n\n .terminal-canvas {\n flex: 1;\n background: #ffffff;\n padding: 18px 20px;\n overflow: hidden;\n font-size: 14px;\n line-height: 1.6;\n color: #000000;\n }\n\n .output-lines {\n margin-bottom: 4px;\n }\n\n .output-line {\n display: block;\n white-space: pre;\n opacity: 0;\n color: #000000;\n }\n\n .output-line.bold {\n font-weight: bold;\n color: #000000;\n }\n\n .input-line {\n display: flex;\n align-items: center;\n white-space: pre;\n }\n\n .prompt {\n color: #000000;\n font-weight: bold;\n user-select: none;\n }\n\n .typed-command {\n color: #000000;\n }\n\n .cursor-block {\n display: inline-block;\n width: 9px;\n height: 16px;\n background: #000000;\n vertical-align: text-bottom;\n margin-left: 1px;\n }\n </style>\n </head>\n <body>\n <div\n id=\"scene\"\n data-composition-id=\"code-snippet-apple-terminal-basic\"\n data-width=\"1920\"\n data-height=\"1080\"\n >\n <div class=\"terminal-window\">\n <div class=\"titlebar\">\n <div class=\"traffic-lights\">\n <span class=\"close\"></span>\n <span class=\"minimize\"></span>\n <span class=\"fullscreen\"></span>\n </div>\n <span class=\"window-title\">bash — 80×24</span>\n </div>\n <div class=\"terminal-canvas\">\n <div class=\"output-lines\">\n <span class=\"output-line\">Last login: Mon Jun 2 09:14:22 on ttys001</span>\n <span class=\"output-line\">total 48</span>\n <span class=\"output-line bold\">drwxr-xr-x 8 user staff 256 Jun 2 09:10 .</span>\n <span class=\"output-line\">drwxr-xr-x 42 user staff 1344 Jun 1 18:22 ..</span>\n <span class=\"output-line\">-rw-r--r-- 1 user staff 872 May 30 14:05 README.md</span>\n <span class=\"output-line bold\">drwxr-xr-x 5 user staff 160 Jun 2 09:10 dist</span>\n <span class=\"output-line bold\"\n >drwxr-xr-x 12 user staff 384 Jun 2 09:10 node_modules</span\n >\n <span class=\"output-line\">-rw-r--r-- 1 user staff 1204 Jun 2 09:08 package.json</span>\n <span class=\"output-line bold\">drwxr-xr-x 6 user staff 192 Jun 2 09:10 src</span>\n <span class=\"output-line\">-rw-r--r-- 1 user staff 348 May 29 11:42 tsconfig.json</span>\n </div>\n <div class=\"input-line\">\n <span class=\"prompt\">user@Mac ~ % </span><span class=\"typed-command\"></span\n ><span class=\"cursor-block\"></span>\n </div>\n </div>\n </div>\n </div>\n\n <script src=\"https://cdn.jsdelivr.net/npm/gsap@3.14.2/dist/gsap.min.js\"></script>\n <script>\n window.__timelines = window.__timelines || {};\n\n const command = \"ls -la\";\n const typedEl = document.querySelector(\".typed-command\");\n const cursorEl = document.querySelector(\".cursor-block\");\n const outputLines = document.querySelectorAll(\".output-line\");\n\n const tl = gsap.timeline({ paused: true });\n\n // Phase 1 (00.5s): hold on empty prompt\n tl.set(typedEl, { text: \"\" }, 0);\n\n // Phase 2 (0.52s): type command char by char\n const charDuration = 1.5 / command.length;\n command.split(\"\").forEach((char, i) => {\n tl.add(\n () => {\n typedEl.textContent = command.slice(0, i + 1);\n },\n 0.5 + i * charDuration,\n );\n });\n\n // Phase 3 (2.2s): hide cursor, show first output line (login message)\n tl.set(cursorEl, { opacity: 0 }, 2.2);\n tl.set(outputLines[0], { opacity: 1 }, 2.3);\n\n // Phase 4 (2.5s): clear command, show ls output line by line\n tl.add(() => {\n typedEl.textContent = \"\";\n }, 2.5);\n\n outputLines.forEach((line, i) => {\n if (i === 0) return; // already shown\n tl.set(line, { opacity: 1 }, 2.8 + i * 0.08);\n });\n\n // Phase 5 (4s): new prompt with blinking cursor\n tl.add(() => {\n const inputLine = document.querySelector(\".input-line\");\n const newPrompt = document.createElement(\"div\");\n newPrompt.className = \"input-line\";\n newPrompt.innerHTML =\n '<span class=\"prompt\">user@Mac ~ % </span><span class=\"typed-command\"></span><span class=\"cursor-block\" id=\"final-cursor\"></span>';\n inputLine.style.display = \"none\";\n inputLine.parentNode.appendChild(newPrompt);\n }, 4.0);\n\n // Phase 6 (4.210s): blink cursor 3 times then stop\n const blinkTimes = [4.2, 4.6, 5.0, 5.4, 5.8, 6.2];\n blinkTimes.forEach((t, i) => {\n tl.add(() => {\n const fc = document.getElementById(\"final-cursor\");\n if (fc) fc.style.opacity = i % 2 === 0 ? \"0\" : \"1\";\n }, t);\n });\n tl.add(() => {\n const fc = document.getElementById(\"final-cursor\");\n if (fc) fc.style.opacity = \"1\";\n }, 6.6);\n\n window.__timelines[\"code-snippet-apple-terminal-basic\"] = tl;\n </script>\n </body>\n</html>\n"}