Write HTML. Render video. Built for agents.
JavaScript aiai-agentsanimationclaude-codeffmpegframeworkgsaphtmlhtml-to-videomcpmotion-graphicspuppeteerrenderingtypescriptvideo-editor
fix(catalog): token-themed component previews no longer render black (#5995)
Miguel Ángelb16d5a70635f
diff --git a/package.json b/package.jsonindex 9bb2b46cef..3e11563ce8 100644--- a/package.json+++ b/package.json@@ -54,7 +54,7 @@"player:perf": "bun run --filter @hyperframes/player perf","format:check": "oxfmt --check .","knip": "knip",- "test:scripts": "node --import tsx --test scripts/animejs-v4-guidance.test.mjs scripts/check-tracked-artifacts.test.mjs scripts/check-registry-set-delta.test.mjs scripts/check-no-main-deletions.test.mjs scripts/check-pr-captures.test.mjs scripts/check-comment-citations.test.mjs scripts/comments-workflow.test.mjs scripts/comment-ratchet.test.mjs scripts/check-docs-snippet-motion.test.mjs scripts/registry-target-paths.test.mjs scripts/check-workspace-contracts.test.mjs scripts/check-media-use-copy-parity.test.mjs scripts/check-svg-sanitize-parity.test.mjs scripts/check-media-use-svg-sanitize-generated.test.mjs scripts/check-package-cycles.test.mjs scripts/check-cli-process-ownership.test.mjs scripts/check-cli-lazy-deps.test.mjs scripts/file-url-paths.test.mjs scripts/check-studio-copy-dashes.test.mjs scripts/check-large-files.test.mjs scripts/package-subpaths.test.mjs scripts/validate-release-channel.test.mjs scripts/clawhub-sync.test.mjs scripts/publish-workflow.test.mjs scripts/pr-edit-concurrency.test.mjs scripts/merge-queue-workflows.test.mjs scripts/install-workspace-dependencies.test.mjs scripts/check-edit-accuracy-filter.test.mjs scripts/edit-accuracy-retry.test.mjs scripts/draft-changelog.test.ts scripts/set-version.test.ts scripts/release-prepare.test.ts scripts/cli-options.test.ts scripts/changelog-weekly.test.ts scripts/claude-plugin-compression.test.ts scripts/catalog-payload-assets.test.ts scripts/host-registry-assets.test.ts scripts/catalog-preview-temp.test.ts scripts/backfill-block-previews.test.ts scripts/catalog-hosted-files.test.ts scripts/player-cdn-pin.test.ts scripts/studio-runtime-smoke.test.mjs scripts/verify-packed-manifests.test.mjs scripts/rewrite-relative-import-extensions.test.mjs scripts/lint-skills.test.mjs scripts/creator-editing-recipes.test.mjs packages/gcp-cloud-run/check-dockerfile-workspaces.test.mjs packages/core/scripts/writeGeneratedFile.test.ts scripts/catalog-publication.test.mjs scripts/ci/resolve-workflow-pr.test.mjs scripts/ci/base-file.test.mjs scripts/check-catalog-source-pr.test.mjs scripts/generate-registry-items.test.ts scripts/catalog-drift.test.ts scripts/catalog-fetch-mirror.test.ts scripts/catalog-script-inlining.test.ts scripts/catalog-detail.test.ts scripts/generate-catalog-pages.test.ts scripts/verify-catalog-payloads.test.ts scripts/registry-skill-files.test.ts scripts/creator-editing-capabilities.test.mjs scripts/generate-catalog-previews.test.ts scripts/registry-primitive-payloads.test.ts registry/components/pan-stations/pan-stations.test.mjs registry/components/filmed-screen/filmed-screen.test.mjs registry/components/echo-smear/echo-smear.test.mjs && vitest run scripts/catalog/ scripts/contrastRatchet.test.ts scripts/generate-catalog-payloads.test.ts",+ "test:scripts": "node --import tsx --test scripts/animejs-v4-guidance.test.mjs scripts/check-tracked-artifacts.test.mjs scripts/check-registry-set-delta.test.mjs scripts/check-no-main-deletions.test.mjs scripts/check-pr-captures.test.mjs scripts/check-comment-citations.test.mjs scripts/comments-workflow.test.mjs scripts/comment-ratchet.test.mjs scripts/check-docs-snippet-motion.test.mjs scripts/registry-target-paths.test.mjs scripts/check-workspace-contracts.test.mjs scripts/check-media-use-copy-parity.test.mjs scripts/check-svg-sanitize-parity.test.mjs scripts/check-media-use-svg-sanitize-generated.test.mjs scripts/check-package-cycles.test.mjs scripts/check-cli-process-ownership.test.mjs scripts/check-cli-lazy-deps.test.mjs scripts/file-url-paths.test.mjs scripts/check-studio-copy-dashes.test.mjs scripts/check-large-files.test.mjs scripts/package-subpaths.test.mjs scripts/validate-release-channel.test.mjs scripts/clawhub-sync.test.mjs scripts/publish-workflow.test.mjs scripts/pr-edit-concurrency.test.mjs scripts/merge-queue-workflows.test.mjs scripts/install-workspace-dependencies.test.mjs scripts/check-edit-accuracy-filter.test.mjs scripts/edit-accuracy-retry.test.mjs scripts/draft-changelog.test.ts scripts/set-version.test.ts scripts/release-prepare.test.ts scripts/cli-options.test.ts scripts/changelog-weekly.test.ts scripts/claude-plugin-compression.test.ts scripts/catalog-payload-assets.test.ts scripts/host-registry-assets.test.ts scripts/catalog-preview-temp.test.ts scripts/backfill-block-previews.test.ts scripts/catalog-hosted-files.test.ts scripts/player-cdn-pin.test.ts scripts/studio-runtime-smoke.test.mjs scripts/verify-packed-manifests.test.mjs scripts/rewrite-relative-import-extensions.test.mjs scripts/lint-skills.test.mjs scripts/creator-editing-recipes.test.mjs packages/gcp-cloud-run/check-dockerfile-workspaces.test.mjs packages/core/scripts/writeGeneratedFile.test.ts scripts/catalog-publication.test.mjs scripts/ci/resolve-workflow-pr.test.mjs scripts/ci/base-file.test.mjs scripts/check-catalog-source-pr.test.mjs scripts/generate-registry-items.test.ts scripts/catalog-drift.test.ts scripts/catalog-fetch-mirror.test.ts scripts/catalog-script-inlining.test.ts scripts/catalog-detail.test.ts scripts/generate-catalog-pages.test.ts scripts/verify-catalog-payloads.test.ts scripts/registry-theme-fallbacks.test.ts scripts/registry-skill-files.test.ts scripts/creator-editing-capabilities.test.mjs scripts/generate-catalog-previews.test.ts scripts/registry-primitive-payloads.test.ts registry/components/pan-stations/pan-stations.test.mjs registry/components/filmed-screen/filmed-screen.test.mjs registry/components/echo-smear/echo-smear.test.mjs && vitest run scripts/catalog/ scripts/contrastRatchet.test.ts scripts/generate-catalog-payloads.test.ts","typecheck:scripts": "tsc --noEmit -p scripts/tsconfig.json","test:skills": "HYPERFRAMES_MEDIA_HOME_REQUIRED=1 node --import ./packages/cli/scripts/test-home.mjs --test 'skills/**/*.test.mjs' 'packages/cli/src/media-use/**/*.test.mjs'","generate:previews": "tsx scripts/generate-template-previews.ts",diff --git a/registry/components/camera-scan-gate/camera-scan-gate.html b/registry/components/camera-scan-gate/camera-scan-gate.htmlindex 176a3cb149..27e924a5e4 100644--- a/registry/components/camera-scan-gate/camera-scan-gate.html+++ b/registry/components/camera-scan-gate/camera-scan-gate.html@@ -15,7 +15,7 @@it for passive camera decoration or a generic loading state.Variables (declared in data-composition-variables below):- - scanColor (string, default "var(--brand)"): any CSS color value used by+ - scanColor (string, default "var(--brand, #22c55e)"): any CSS color value used bythe scan line, lock brackets, and confirmation glow.- targetLabel (string, default "Verified"): label revealed at lock. Emptystring hides the label line entirely.@@ -55,7 +55,7 @@<htmllang="en"data-composition-variables='[- { "id": "scanColor", "type": "string", "role": "style", "label": "Scan color", "description": "Any CSS color value used by the scan line and recognition glow.", "default": "var(--brand)" },+ { "id": "scanColor", "type": "string", "role": "style", "label": "Scan color", "description": "Any CSS color value used by the scan line and recognition glow.", "default": "var(--brand, #22c55e)" },{ "id": "targetLabel", "type": "string", "role": "content", "label": "Target label", "description": "Confirmation label revealed at recognition lock. Blank hides the line.", "default": "Verified" },{ "id": "sweepSpeed", "type": "number", "role": "timing", "label": "Sweep speed", "description": "Speed multiplier for the scan sweep phase only.", "default": 1, "min": 0.8, "max": 1.6, "step": 0.1, "unit": "x" }]'@@ -369,7 +369,7 @@: {};var scanColor =vars.scanColor == null || String(vars.scanColor).trim() === ""- ? "var(--brand)"+ ? "var(--brand, #22c55e)": String(vars.scanColor);var targetLabel = vars.targetLabel == null ? "" : String(vars.targetLabel);var rawSweepSpeed = Number(vars.sweepSpeed);diff --git a/registry/components/camera-scan-gate/registry-item.json b/registry/components/camera-scan-gate/registry-item.jsonindex 020ebcbca8..495d6aa603 100644--- a/registry/components/camera-scan-gate/registry-item.json+++ b/registry/components/camera-scan-gate/registry-item.json@@ -27,7 +27,7 @@"role": "style","label": "Scan color","description": "Any CSS color value used by the scan line and recognition glow.",- "default": "var(--brand)"+ "default": "var(--brand, #22c55e)"},{"id": "targetLabel",diff --git a/registry/components/focus-swap/focus-swap.html b/registry/components/focus-swap/focus-swap.htmlindex 4794462d72..1dc3401f84 100644--- a/registry/components/focus-swap/focus-swap.html+++ b/registry/components/focus-swap/focus-swap.html@@ -64,9 +64,9 @@container-type: size;isolation: isolate;overflow: hidden;- background: var(--bg);- color: var(--fg);- font-family: var(--font-body);+ background: var(--bg, #070a12);+ color: var(--fg, #f8fafc);+ font-family: var(--font-body, Inter, system-ui, sans-serif);}.fs-clip {@@ -96,15 +96,15 @@justify-content: space-between;padding: 5cqh 3.2cqw;overflow: hidden;- border: 0.16cqw solid var(--border);- border-radius: var(--radius);- background: var(--surface);- box-shadow: 0 2.2cqh 5cqh color-mix(in srgb, var(--bg) 72%, transparent);+ border: 0.16cqw solid var(--border, #34405a);+ border-radius: var(--radius, 22px);+ background: var(--surface, #151c2c);+ box-shadow: 0 2.2cqh 5cqh color-mix(in srgb, var(--bg, #070a12) 72%, transparent);transform-origin: center;will-change: transform, filter, opacity;/* Both cards are the same placeholder material. Which one holdsattention is said by blur, scale, and opacity, never by hue. */- --fs-card-accent: color-mix(in srgb, var(--fg) 72%, var(--surface));+ --fs-card-accent: color-mix(in srgb, var(--fg, #f8fafc) 72%, var(--surface, #151c2c));}.fs-card::before {@@ -119,7 +119,7 @@display: flex;align-items: center;justify-content: space-between;- gap: var(--space-2);+ gap: var(--space-2, 16px);}.fs-card-letter {@@ -128,16 +128,16 @@width: 5cqw;aspect-ratio: 1;border-radius: 50%;- background: color-mix(in srgb, var(--fg) 13%, var(--surface));- color: var(--fg);- font-family: var(--font-mono);+ background: color-mix(in srgb, var(--fg, #f8fafc) 13%, var(--surface, #151c2c));+ color: var(--fg, #f8fafc);+ font-family: var(--font-mono, ui-monospace, "SF Mono", Menlo, Consolas, monospace);font-size: 2.3cqw;font-weight: 700;}.fs-status {- color: var(--muted);- font-family: var(--font-mono);+ color: var(--muted, #94a3b8);+ font-family: var(--font-mono, ui-monospace, "SF Mono", Menlo, Consolas, monospace);font-size: 1.25cqw;letter-spacing: 0.12em;text-transform: uppercase;@@ -145,12 +145,12 @@.fs-copy {display: grid;- gap: var(--space-1);+ gap: var(--space-1, 8px);}.fs-title {- color: var(--fg);- font-family: var(--font-display);+ color: var(--fg, #f8fafc);+ font-family: var(--font-display, Inter, system-ui, sans-serif);font-size: 3.4cqw;font-weight: 680;line-height: 1;@@ -158,7 +158,7 @@}.fs-detail {- color: var(--muted);+ color: var(--muted, #94a3b8);font-size: 1.45cqw;line-height: 1.35;}@@ -166,8 +166,8 @@.fs-meter {height: 1.1cqh;overflow: hidden;- border-radius: var(--radius);- background: color-mix(in srgb, var(--border) 60%, transparent);+ border-radius: var(--radius, 22px);+ background: color-mix(in srgb, var(--border, #34405a) 60%, transparent);}.fs-meter-fill {diff --git a/registry/components/stagger-cascade/stagger-cascade.html b/registry/components/stagger-cascade/stagger-cascade.htmlindex 7cc1280734..57a2d24e3e 100644--- a/registry/components/stagger-cascade/stagger-cascade.html+++ b/registry/components/stagger-cascade/stagger-cascade.html@@ -82,8 +82,8 @@container-type: size;isolation: isolate;overflow: hidden;- color: var(--fg);- font-family: var(--font-body);+ color: var(--fg, #f4f7fb);+ font-family: var(--font-body, Inter, system-ui, sans-serif);}.sc-clip {@@ -92,7 +92,7 @@display: grid;place-items: center;overflow: hidden;- background: var(--bg);+ background: var(--bg, #090d16);}.sc-grid {@@ -111,10 +111,10 @@display: grid;place-items: center;overflow: hidden;- border: 0.16cqw solid var(--border);+ border: 0.16cqw solid var(--border, rgba(244, 247, 251, 0.14));border-radius: min(2.4cqw, 4cqh);- background: color-mix(in srgb, var(--surface) 92%, var(--brand));- color: var(--fg);+ background: color-mix(in srgb, var(--surface, #171e2d) 92%, var(--brand, #79a8ff));+ color: var(--fg, #f4f7fb);}.sc-tile::after {@@ -125,17 +125,17 @@bottom: 12%;height: min(0.55cqw, 0.95cqh);border-radius: 50cqw;- background: var(--brand);+ background: var(--brand, #79a8ff);opacity: 0.72;}.sc-tile-index {display: block;- font-family: var(--font-display);+ font-family: var(--font-display, Inter, system-ui, sans-serif);font-size: min(5cqw, 8cqh);font-weight: 700;line-height: 1;- color: var(--fg);+ color: var(--fg, #f4f7fb);}</style>diff --git a/registry/components/store-badge-lockup/store-badge-lockup.html b/registry/components/store-badge-lockup/store-badge-lockup.htmlindex ad55505f2a..503797f84b 100644--- a/registry/components/store-badge-lockup/store-badge-lockup.html+++ b/registry/components/store-badge-lockup/store-badge-lockup.html@@ -64,8 +64,8 @@container-type: size;isolation: isolate;overflow: hidden;- color: var(--fg);- font-family: var(--font-body);+ color: var(--fg, #f7f9fc);+ font-family: var(--font-body, Inter, system-ui, sans-serif);}.sbl-clip {@@ -73,9 +73,9 @@height: 100%;display: grid;place-items: center;- padding: var(--space-3);+ padding: var(--space-3, 4.8cqh);overflow: hidden;- background: var(--bg);+ background: var(--bg, #080b13);}.sbl-lockup {@@ -88,8 +88,8 @@.sbl-headline {margin: 0;max-width: 82cqw;- color: var(--fg);- font-family: var(--font-display);+ color: var(--fg, #f7f9fc);+ font-family: var(--font-display, Inter, system-ui, sans-serif);font-size: min(8.2cqw, 12.5cqh);font-weight: 750;line-height: 1;@@ -104,7 +104,7 @@display: flex;align-items: center;justify-content: center;- gap: var(--space-2);+ gap: var(--space-2, 2.4cqh);}/* EDIT ZONE: both destinations share one badge geometry and one@@ -116,13 +116,13 @@display: grid;grid-template-columns: auto minmax(0, 1fr);align-items: center;- gap: var(--space-1);+ gap: var(--space-1, 1.2cqh);padding: min(2.2cqw, 3.2cqh) min(3cqw, 4.8cqh);- border: 0.16cqh solid var(--border);- border-radius: calc(var(--radius) * 4);- background: var(--surface);- color: var(--fg);- box-shadow: 0 1.5cqh 3.8cqh color-mix(in srgb, var(--bg) 70%, transparent);+ border: 0.16cqh solid var(--border, #3b4659);+ border-radius: calc(var(--radius, 2.4cqh) * 4);+ background: var(--surface, #151c29);+ color: var(--fg, #f7f9fc);+ box-shadow: 0 1.5cqh 3.8cqh color-mix(in srgb, var(--bg, #080b13) 70%, transparent);will-change: transform, opacity;}@@ -132,14 +132,14 @@display: grid;place-items: center;flex: none;- border: 0.16cqh solid color-mix(in srgb, var(--fg) 28%, transparent);- border-radius: calc(var(--radius) * 0.72);- background: color-mix(in srgb, var(--brand) 20%, var(--surface));- color: var(--fg);+ border: 0.16cqh solid color-mix(in srgb, var(--fg, #f7f9fc) 28%, transparent);+ border-radius: calc(var(--radius, 2.4cqh) * 0.72);+ background: color-mix(in srgb, var(--brand, #7c6cff) 20%, var(--surface, #151c29));+ color: var(--fg, #f7f9fc);}.sbl-apple-mark {- font-family: var(--font-display);+ font-family: var(--font-display, Inter, system-ui, sans-serif);font-size: min(3.2cqw, 5.2cqh);font-weight: 800;line-height: 1;@@ -159,8 +159,8 @@}.sbl-microcopy {- color: var(--muted);- font-family: var(--font-body);+ color: var(--muted, #aab4c5);+ font-family: var(--font-body, Inter, system-ui, sans-serif);font-size: min(1.65cqw, 2.65cqh);font-weight: 600;line-height: 1;@@ -169,8 +169,8 @@}.sbl-label {- color: var(--fg);- font-family: var(--font-display);+ color: var(--fg, #f7f9fc);+ font-family: var(--font-display, Inter, system-ui, sans-serif);font-size: min(3.75cqw, 5.8cqh);font-weight: 720;line-height: 1;diff --git a/registry/components/svg-mask-reveal/svg-mask-reveal.html b/registry/components/svg-mask-reveal/svg-mask-reveal.htmlindex 0294d5e3a4..b638be9de9 100644--- a/registry/components/svg-mask-reveal/svg-mask-reveal.html+++ b/registry/components/svg-mask-reveal/svg-mask-reveal.html@@ -80,9 +80,9 @@container-type: size;isolation: isolate;overflow: hidden;- background: var(--bg);- color: var(--fg);- font-family: var(--font-body);+ background: var(--bg, #101d31);+ color: var(--fg, #f8fafc);+ font-family: var(--font-body, Inter, system-ui, sans-serif);}.smr-clip,@@ -109,20 +109,20 @@}.smr-media-start {- stop-color: var(--brand);+ stop-color: var(--brand, #ff7a33);}.smr-media-middle {- stop-color: var(--accent);+ stop-color: var(--accent, #22d3ee);}.smr-media-end {- stop-color: var(--fg);+ stop-color: var(--fg, #f8fafc);}.smr-mask-text {- fill: var(--fg);- font-family: var(--font-display);+ fill: var(--fg, #f8fafc);+ font-family: var(--font-display, Inter, system-ui, sans-serif);font-size: 240px;font-weight: 850;letter-spacing: 0.02em;@@ -135,9 +135,9 @@.smr-outline {fill: none;- stroke: var(--border);+ stroke: var(--border, rgba(248, 250, 252, 0.22));stroke-width: 2;- font-family: var(--font-display);+ font-family: var(--font-display, Inter, system-ui, sans-serif);font-size: 240px;font-weight: 850;letter-spacing: 0.02em;diff --git a/registry/components/testimonial-card/testimonial-card.html b/registry/components/testimonial-card/testimonial-card.htmlindex f8f78769b1..e136bda150 100644--- a/registry/components/testimonial-card/testimonial-card.html+++ b/registry/components/testimonial-card/testimonial-card.html@@ -67,9 +67,9 @@container-type: size;isolation: isolate;overflow: hidden;- background: var(--bg);- color: var(--fg);- font-family: var(--font-body);+ background: var(--bg, #070a12);+ color: var(--fg, #f8fafc);+ font-family: var(--font-body, Inter, system-ui, sans-serif);}.tc-clip {@@ -89,10 +89,10 @@gap: min(4.6cqw, 4.6cqh);padding: min(6.5cqw, 6.5cqh);overflow: hidden;- border: 0.16cqh solid var(--border);- border-radius: var(--radius);- background: var(--surface);- box-shadow: 0 3cqh 8cqh color-mix(in srgb, var(--bg) 68%, transparent);+ border: 0.16cqh solid var(--border, #34405a);+ border-radius: var(--radius, 28px);+ background: var(--surface, #151c2c);+ box-shadow: 0 3cqh 8cqh color-mix(in srgb, var(--bg, #070a12) 68%, transparent);}.tc-proof {@@ -106,8 +106,8 @@align-items: center;gap: min(2cqw, 2cqh);width: max-content;- color: var(--muted);- font-family: var(--font-mono);+ color: var(--muted, #a8b3c7);+ font-family: var(--font-mono, ui-monospace, "SF Mono", Menlo, Consolas, monospace);font-size: min(2.4cqw, 2.4cqh);font-weight: 650;line-height: 1;@@ -116,7 +116,7 @@.tc-stars {position: relative;display: inline-block;- color: var(--muted);+ color: var(--muted, #a8b3c7);font-size: min(3.4cqw, 3.4cqh);letter-spacing: 0.18em;line-height: 1;@@ -130,14 +130,14 @@overflow: hidden;/* The earned portion of the rating is the data. Flat ink over themuted track says it by value, with no second hue. */- color: var(--fg);+ color: var(--fg, #f8fafc);white-space: nowrap;}.tc-quote {margin: 0;- color: var(--fg);- font-family: var(--font-display);+ color: var(--fg, #f8fafc);+ font-family: var(--font-display, Inter, system-ui, sans-serif);font-size: min(5.2cqw, 5.2cqh);font-weight: 650;line-height: 1.23;@@ -160,13 +160,13 @@place-items: center;width: min(8.4cqw, 8.4cqh);aspect-ratio: 1;- border: 0.16cqh solid color-mix(in srgb, var(--fg) 20%, transparent);+ border: 0.16cqh solid color-mix(in srgb, var(--fg, #f8fafc) 20%, transparent);border-radius: 50%;/* Placeholder person: a single (front) avatar circle at L1, withthe initials knocked out in the ground colour. */- background: color-mix(in srgb, var(--fg) 72%, var(--surface));- color: var(--bg);- font-family: var(--font-display);+ background: color-mix(in srgb, var(--fg, #f8fafc) 72%, var(--surface, #151c2c));+ color: var(--bg, #070a12);+ font-family: var(--font-display, Inter, system-ui, sans-serif);font-size: min(2.65cqw, 2.65cqh);font-weight: 780;letter-spacing: 0.03em;@@ -175,8 +175,8 @@.tc-author {min-width: 0;align-self: end;- color: var(--fg);- font-family: var(--font-display);+ color: var(--fg, #f8fafc);+ font-family: var(--font-display, Inter, system-ui, sans-serif);font-size: min(3.2cqw, 3.2cqh);font-weight: 700;line-height: 1.08;@@ -185,7 +185,7 @@.tc-handle {min-width: 0;align-self: start;- color: var(--muted);+ color: var(--muted, #a8b3c7);font-size: min(2.35cqw, 2.35cqh);line-height: 1.15;}diff --git a/registry/components/wordmark-tiles/wordmark-tiles.html b/registry/components/wordmark-tiles/wordmark-tiles.htmlindex 039a63290c..6588862f3a 100644--- a/registry/components/wordmark-tiles/wordmark-tiles.html+++ b/registry/components/wordmark-tiles/wordmark-tiles.html@@ -83,8 +83,8 @@container-type: size;isolation: isolate;overflow: hidden;- color: var(--fg);- font-family: var(--font-body);+ color: var(--fg, #f5f7ff);+ font-family: var(--font-body, Inter, system-ui, sans-serif);}.wt-clip {@@ -93,7 +93,7 @@display: grid;place-items: center;overflow: hidden;- background: var(--bg);+ background: var(--bg, #070a12);}.wt-stage {@@ -113,9 +113,9 @@grid-template-columns: repeat(var(--wt-columns), minmax(0, 1fr));grid-template-rows: repeat(var(--wt-rows), minmax(0, 1fr));overflow: hidden;- border: min(0.12cqw, 0.22cqh) solid var(--border);- border-radius: var(--radius);- background: var(--surface);+ border: min(0.12cqw, 0.22cqh) solid var(--border, rgba(245, 247, 255, 0.14));+ border-radius: var(--radius, 16px);+ background: var(--surface, #151b2b);}.wt-tile {@@ -123,8 +123,8 @@min-width: 0;min-height: 0;overflow: hidden;- box-shadow: inset 0 0 0 min(0.08cqw, 0.14cqh) var(--border);- background: var(--surface);+ box-shadow: inset 0 0 0 min(0.08cqw, 0.14cqh) var(--border, rgba(245, 247, 255, 0.14));+ background: var(--surface, #151b2b);}.wt-noise,@@ -136,20 +136,20 @@}.wt-noise-a {- background: color-mix(in srgb, var(--surface) 64%, var(--muted));+ background: color-mix(in srgb, var(--surface, #151b2b) 64%, var(--muted, #7f8aa3));}.wt-noise-b {- background: color-mix(in srgb, var(--surface) 58%, var(--brand));+ background: color-mix(in srgb, var(--surface, #151b2b) 58%, var(--brand, #7c9dff));}.wt-noise-c {- background: color-mix(in srgb, var(--surface) 56%, var(--accent));+ background: color-mix(in srgb, var(--surface, #151b2b) 56%, var(--accent, #64e2c2));}.wt-resolved {overflow: hidden;- background: color-mix(in srgb, var(--surface) 92%, var(--brand));+ background: color-mix(in srgb, var(--surface, #151b2b) 92%, var(--brand, #7c9dff));}/* Every tile contains one crop of the same stable wordmark surface.@@ -162,8 +162,8 @@height: 48cqh;display: grid;place-items: center;- color: var(--fg);- font-family: var(--font-display);+ color: var(--fg, #f5f7ff);+ font-family: var(--font-display, Inter, system-ui, sans-serif);font-size: var(--wt-font-size);font-weight: 800;line-height: 1;diff --git a/scripts/generate-catalog-previews.test.ts b/scripts/generate-catalog-previews.test.tsindex a843f60c40..5786844ee5 100644--- a/scripts/generate-catalog-previews.test.ts+++ b/scripts/generate-catalog-previews.test.ts@@ -147,3 +147,42 @@ describe("catalog wrapper duration", () => {});}});++describe("catalog snippet wrapper theme", () => {+ it("gives Testimonial Card the tokens and canvas its demo sets", async () => {+ const html = await preparedHtml(+ join(repoRoot, "registry/components/testimonial-card"),+ "testimonial-card.html",+ );+ assert.match(html, /:root \{[^}]*--bg: #070a12;[^}]*--fg: #f8fafc;/);+ assert.match(html, /background: var\(--bg, #0a0a0a\)/);+ });++ it("takes tokens from the mount and its ancestors, nearest last", async () => {+ const sourceDir = mkdtempSync(join(tmpdir(), "catalog-theme-"));+ try {+ writeFileSync(join(sourceDir, "registry-item.json"), "{}");+ writeFileSync(join(sourceDir, "entry.html"), '<div data-composition-id="entry"></div>');+ writeFileSync(+ join(sourceDir, "demo.html"),+ `<!doctype html><html><head><style>+ :root { --bg: #000; --fg: #fff; }+ #root { --bg: #111; }+ .mount { --surface: #222; width: 10px; }+ .other { --fg: #f00; }+ .mount::before { --fg: #0f0; }+ </style></head><body><div id="root">+ <div class="other" data-composition-src="./other.html"></div>+ <div class="mount" style="--border: #333" data-composition-src="./entry.html"></div>+ </div></body></html>`,+ );+ const html = await preparedHtml(sourceDir, "entry.html");+ assert.match(+ html,+ /:root \{ --bg: #000; --fg: #fff; --bg: #111; --surface: #222; --border: #333; \}/,+ );+ } finally {+ rmSync(sourceDir, { recursive: true, force: true });+ }+ });+});diff --git a/scripts/generate-catalog-previews.ts b/scripts/generate-catalog-previews.tsindex 034a73dbeb..0e604c639c 100644--- a/scripts/generate-catalog-previews.ts+++ b/scripts/generate-catalog-previews.ts@@ -255,8 +255,8 @@ export interface PrepareOptions {* into: its root is content with no canvas behind it and no vertical* placement. Mounted into the plain wrapper it lands against white in the* top-left corner and clips. This supplies the part its authored demo would- * have: a dark canvas, the dark theme its own tokens are written against, and- * the component centred with room around it.+ * have: the theme tokens the demo hands its mount, a canvas in the demo's+ * background, and the component centred with room around it.*/uiFragment?: boolean;/**@@ -335,7 +335,7 @@ function readWrapperManifest(tmpDir: string): WrapperManifest {}function wrapperBackground(tags: string[], uiFragment: boolean | undefined): string {- if (uiFragment) return "#0a0a0a";+ if (uiFragment) return "var(--bg, #0a0a0a)";return tags.includes("social") || tags.includes("overlay") ? "#1a1a2e" : "#ffffff";}@@ -361,16 +361,19 @@ interface WrapperSpec {duration: number | null;bgColor: string;uiFragment: boolean | undefined;+ /** Custom property declarations for the wrapper's `:root`. */+ themeTokens: string[];}function renderWrapperHtml(spec: WrapperSpec): string {- const { name, entrySrc, width, height, duration, bgColor, uiFragment } = spec;+ const { name, entrySrc, width, height, duration, bgColor, uiFragment, themeTokens } = spec;// `inset: 0` keeps the mount from shrinking to its content; `center stretch` centres vertically only.const staging = uiFragment? `\n [data-composition-src] { inset: 0; display: grid; place-items: center stretch; box-sizing: border-box; padding: ${Math.round(height / 11)}px; }`: "";const timing = duration === null ? "" : ` data-duration="${duration}"`;const theme = uiFragment ? ' data-hf-theme="dark"' : "";+ const tokens = themeTokens.length > 0 ? `:root { ${themeTokens.join(" ")} } ` : "";return `<!doctype html><html lang="en">@@ -378,7 +381,7 @@ function renderWrapperHtml(spec: WrapperSpec): string {<meta charset="UTF-8" /><meta name="viewport" content="width=${width}, height=${height}" /><script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/gsap.min.js"></script>- <style>* { margin: 0; padding: 0; } html, body { width: ${width}px; height: ${height}px; overflow: hidden; background: ${bgColor}; }${staging}</style>+ <style>${tokens}* { margin: 0; padding: 0; } html, body { width: ${width}px; height: ${height}px; overflow: hidden; background: ${bgColor}; }${staging}</style></head><body><div data-composition-id="preview-root" data-width="${width}" data-height="${height}" data-start="0"${timing}${theme}>@@ -404,6 +407,54 @@ function authoredEntryDuration(html: string): number | null {);}+function flatRules(rules: CSSRuleList | undefined): CSSRule[] {+ return [...(rules ?? [])].flatMap((rule) =>+ "cssRules" in rule ? flatRules((rule as CSSGroupingRule).cssRules) : [rule],+ );+}++function matchesSelector(element: Element, selector: string): boolean {+ try {+ return element.matches(selector);+ } catch {+ // Pseudo-elements and selectors the parser does not know never style the element itself.+ return false;+ }+}++function customProperties(style: CSSStyleDeclaration): string[] {+ return [...Array(style.length).keys()]+ .map((i) => style[i] ?? "")+ .filter((prop) => prop.startsWith("--"))+ .map((prop) => `${prop}: ${style.getPropertyValue(prop).trim()};`);+}++// Custom properties the demo sets on this entry's mount or its ancestors, outermost first so+// the nearest wins: the preview wears the demo's theme, not the snippet's fallbacks.+function demoThemeTokens(tmpDir: string, entryFile: string): string[] {+ const demoPath = join(tmpDir, "demo.html");+ if (!existsSync(demoPath)) return [];+ const document = parseHTMLContent(readFileSync(demoPath, "utf-8"));+ const entryPath = resolve(tmpDir, entryFile);+ const mount = [...document.querySelectorAll("[data-composition-src]")].find(+ (el) => resolve(tmpDir, el.getAttribute("data-composition-src") ?? "") === entryPath,+ );+ if (!mount) return [];++ const rules = [...document.querySelectorAll("style")]+ .flatMap((style) => flatRules((style as HTMLStyleElement).sheet?.cssRules))+ .filter((rule): rule is CSSStyleRule => "selectorText" in rule);+ const lineage: Element[] = [];+ for (let el: Element | null = mount; el; el = el.parentElement) lineage.unshift(el);+ // ponytail: rules on one element apply in source order, not by specificity; no demo relies on it.+ return lineage.flatMap((el) => [+ ...rules+ .filter((rule) => matchesSelector(el, rule.selectorText))+ .flatMap((rule) => customProperties(rule.style)),+ ...customProperties((el as HTMLElement).style),+ ]);+}+function writeWrapperIndex(tmpDir: string,item: CatalogItem,@@ -418,6 +469,7 @@ function writeWrapperIndex(duration: authoredEntryDuration(entryHtml) ?? manifest.duration ?? null,bgColor: wrapperBackground(manifest.tags ?? [], uiFragment),uiFragment,+ themeTokens: uiFragment ? demoThemeTokens(tmpDir, item.entryFile) : [],});writeFileSync(join(tmpDir, "index.html"), wrapper, "utf-8");}diff --git a/scripts/registry-theme-fallbacks.test.ts b/scripts/registry-theme-fallbacks.test.tsnew file mode 100644index 0000000000..51702ba3dd--- /dev/null+++ b/scripts/registry-theme-fallbacks.test.ts@@ -0,0 +1,68 @@+import { globSync, readFileSync } from "node:fs";+import { resolve } from "node:path";+import { describe, it } from "node:test";+import assert from "node:assert/strict";+import { parseHTMLContent } from "../packages/core/src/compiler/htmlDocument.js";++const repoRoot = resolve(import.meta.dirname, "..");+const DECLARATION = /(--[\w-]+)\s*:/g;+const BARE_READ = /var\(\s*(--[\w-]+)\s*\)/g;++function tokenNames(text: string, pattern: RegExp): Set<string> {+ return new Set([...text.matchAll(pattern)].map((m) => m[1] ?? ""));+}++// Every theme pack defines the whole contract (themes/CONTRACT.md), so one pack names it.+const CONTRACT = tokenNames(+ readFileSync(resolve(repoRoot, "themes/neutral.css"), "utf-8"),+ DECLARATION,+);++function dropComments(node: Node): void {+ for (const child of [...node.childNodes]) {+ if (child.nodeType === child.COMMENT_NODE) child.remove();+ else dropComments(child);+ }+}++/** The file with HTML comments removed by the parser, then CSS block and JS line comments. */+function liveSource(html: string): string {+ const document = parseHTMLContent(html);+ dropComments(document);+ return document.documentElement.outerHTML+ .replace(/\/\*[\s\S]*?\*\//g, "")+ .replace(/^\s*\/\/.*$/gm, "");+}++/** Contract tokens the file reads with no fallback and does not declare itself. */+function bareContractTokens(html: string): string[] {+ const live = liveSource(html);+ const declared = tokenNames(live, DECLARATION);+ const read = tokenNames(live, BARE_READ);+ return [...read].filter((token) => CONTRACT.has(token) && !declared.has(token)).sort();+}++describe("registry theme fallbacks", () => {+ it("reads the contract from the theme pack", () => {+ assert.ok(CONTRACT.has("--bg") && CONTRACT.has("--font-display"), [...CONTRACT].join(" "));+ });++ it("flags only a bare contract token the file does not declare", () => {+ assert.deepEqual(bareContractTokens("p { color: var(--fg); background: var(--c) }"), ["--fg"]);+ assert.deepEqual(bareContractTokens("p { color: var(--fg, #fff) }"), []);+ assert.deepEqual(bareContractTokens("#root { --fg: #fff } p { color: var(--fg) }"), []);+ assert.deepEqual(bareContractTokens("/* var(--fg) */ <!-- var(--bg) -->"), []);+ });++ // A theme pack is optional: without one, a bare token resolves to nothing and the item paints+ // black on black, in an install and in the Catalog preview alike.+ it("every registry item reads contract tokens with a fallback", () => {+ const bare: string[] = [];+ for (const file of globSync("registry/{blocks,components}/*/*.html", { cwd: repoRoot })) {+ if (file.endsWith("/demo.html")) continue;+ const tokens = bareContractTokens(readFileSync(resolve(repoRoot, file), "utf-8"));+ if (tokens.length > 0) bare.push(`${file}: ${tokens.join(" ")}`);+ }+ assert.deepEqual(bare, []);+ });+});