Files
openmotion/docs/brand-kits.md
Tom Huang bc2f449ac3 feat(brand-kit): map catalog artwork sources, improve favicon/cover fetching, and stabilize gallery grid (#689)
* feat(brand-kit): map catalog artwork sources, improve favicon/cover fetching, and stabilize gallery grid

- Add scripts/sync-brand-websites.ts and update library/brand-kits/websites.json
  and catalog.json to map upstream source URLs, same-site coverPages, and pinned
  preview coverImages across the Brand Kit catalog.
- Serve favicon and cover endpoints for every Brand Kit entry via websiteUrl or
  sourceUrl with GitHub origin/repo deduplication, relaxed explicit OG fallback,
  preload/noscript/itemprop/AVIF support, extra favicon fallback paths, and a
  single browser-UA retry only on 403/406 responses.
- Replace initial SVG/initial-letter flashes with shared loading skeletons for
  covers and favicons, lock Brand Kit card geometry to 16:9 inside a row-major
  CSS Grid, and drop offscreen queued artwork loads to prevent layout jitter.
- Update backend/Studio unit tests and Brand Kit documentation.

* fix(brand-kit): address PR #689 review feedback

- Initialize stop before start/release in BrandArtworkImage so the
  no-IntersectionObserver synchronous fallback never hits a TDZ ReferenceError
  or leaks a queue slot; add regression test coverage in BrandKitPage.test.tsx.
- Remove unreachable coverAspect state and onCoverAspect callback in
  TemplateGalleryCard and TemplatePoster.
- Align docs/brand-kits.md and docs/product/architecture.md with the fixed-aspect
  row-major Brand Kit grid and loading skeletons.

---------

Co-authored-by: pftom <pftom@pftomdeMacBook-Pro.local>
Co-authored-by: pftom <pftom@pftomdeMBP.lan>
2026-11-20 11:36:35 +08:00

16 KiB
Raw Permalink Blame History

Brand Kits

Open Brand Kit using the palette beside workspace assets in the top-right header. It extracts a public HTTPS website or imports a curated design system into a local, downloadable Motion Package. Its collections open in the same full-viewport discovery surface as templates, with shared controls and light/dark themes. Loading uses the maintained OpenMotion mark; navigation, content, progress and hover transitions use shared motion tokens and respect reduced motion. Extracted colors and fonts belong to brand content, not application chrome. The editor stays mounted and pauses while the tab is open. ?page=brand-kit opens Official collection by default. Choose My brand kits to see saved kits (kit=mine). A specific saved kit uses kit=<id>, and extraction uses kit=new. Existing kit=official links still open the official collection.

Templates and Brand Kits

Resource Reusable content Preview meaning Agent handoff
Template An editable film or a reference, with its documented structure, animation and pacing Shows that particular film Existing template selection and project workflow
Brand Kit Colors, typography, logos, backgrounds, shapes, component variants, spacing, shadows, materials, context files and brand rules The same 12-second brand-study-v1 film for every kit, with different styling Local Motion Package path or downloaded ZIP; style-only instructions

The fixed showcase demonstrates a title, typography, a palette and a card/CTA. Its timeline, scenes, transitions and sample copy are identical between kits. It is an independent demonstration fixture, not a themed copy of the welcome project's narrative. Its timing is not brand guidance. Copy for Agent and the package's MOTION.md, DESIGN.md, tags and namespaced manifest metadata all state this distinction. Existing project timing remains unchanged unless the user's brief requests a change.

Extract, review and reuse

  1. Enter a public website and choose Extract Brand Kit. The background job moves through reading, measuring, packaging and rendering stages. Progress reports stage milestones, not measured download percentage. Leaving the tab does not cancel the job.
  2. Review the fixed video on the left and the independently scrolling details on the right. Narrow screens stack these surfaces. Close and previous/next controls navigate the saved kits. The inspector retains the Context, Logos, Colors, Text styles, Backgrounds, Shapes and spacing, Components, and Rules and sources sections. Edit brand styles adjusts the name, five color roles, font stacks, corner radius and gradient, then rebuilds the same preview. It does not alter an existing project. Context accepts files/folders and editable brand rules; adding context rebuilds the package without rendering the video again. A website rescan preserves user-added context, the edited name and individually overridden style roles.
  3. Download package downloads a ZIP with the manifest, hashed inventory, design data, source evidence, native HTML showcase, captured assets, available webfonts, notices, poster and successful MP4 preview. The existing toolkit validates the inventory before download becomes available.
  4. Copy for Agent provides the local package directory and an explicit style-only brief. An Agent on the same machine can read it directly; other machines need the downloaded package. Existing OpenMotion creation/edit/revision tools perform any subsequent project work.

Measured styles remain inspectable while a custom preview renders. Official catalogue kits use the bundled animation directly and do not wait for a native video render. The sidebar reports the current stage and offers cancellation. Package and Agent actions enable after packaging completes. Status reads bypass caches, cancel after ten seconds and retry without hiding the last known detail; old requests cannot overwrite state after a mutation. Preview media loading has a fifteen-second foreground timeout with a local retry that does not rerender the package. Native rendering bounds browser startup, font readiness, browser shutdown and the render process.

Extraction failures can be retried. A failed video render keeps the extracted kit and source package usable with an explicit preview recovery action. Cancellation stops the current browser/render process; interrupted jobs are marked failed on restart and are not automatically replayed. Up to five kits may be queued, with one extraction/render pipeline per workspace process. Delete removes the local kit after work stops; downloaded copies and existing projects remain independent.

Official collection

Official collection browses 152 design systems across 22 categories from the pinned OpenDesign catalogue. Brand Kits share the template library’s introductory discovery tile, immersive gallery card, bounded playback, draft filter popover and sorting controls, while using a fixed-aspect-ratio row-major CSS grid so lazy cover loads and pagination never trigger multi-column reflows. Card metadata appears on hover or keyboard focus. Surprise me selects from the currently matching kits; Submit Brand Kit opens the repository contribution guide. New Brand Kit opens website extraction. Closing a detail retains the collection’s search, filters and scroll position; previous/next follows the selected collection order. Brand filters cover category, light/dark appearance and color family; search includes names, descriptions and tags. Categories apply immediately; the filter panel supports draft choices, live match count, per-category clearing and Apply. Selected filters are individually removable. A browsable Community catalogue is not implemented and has no navigation entry.

Cards prefer the corresponding website's Open Graph image (or verified upstream preview image), then Twitter card artwork, then the first suitable website image (including preloaded and <noscript> images). The source row shows the site favicon and domain as a separate link for every kit, using the mapped website or upstream sourceUrl. A verified page on the same brand site can supply the artwork when the homepage is unavailable or omits Open Graph metadata. If remote artwork is unavailable, catalogue cards fall back to a cover drawn from the kit’s name, typography, palette and shapes (style-cover.svg). Saved website kits use the same cover and favicon service, falling back to their captured website screenshot and then their showcase poster. Shared loading skeletons reserve fixed card and avatar geometry while artwork loads so placeholders do not flash before images appear. Videos play on hover or keyboard focus, so browsing keeps the varied website covers visible. Detail playback continues to show the fixed style demonstration. Selecting an official card verifies and packages the local design references and playable showcase source. The initial download contains the editable showcase rather than a newly rendered MP4; existing rendered previews remain playable, and local style edits still render a preview. Selecting the same catalogue revision again opens the existing local copy; edits affect that copy, while the official card remains the original style. Canonical DESIGN.md, tokens.css and manifest.json are copied byte-for-byte with verified hashes, plus source and license notices. The upstream manifest is archived evidence; referenced rich components, webfonts and other optional files are not bundled. Preview fonts use locally available stacks. The full source design and tokens remain available to the Agent beyond the representative preview.

The design-system catalogue is a reviewed source snapshot. Optional discovery artwork is a live network enhancement with offline fallback. Its revision and regeneration command are recorded in the source notice. Upstream CSS is compiled offline during snapshot generation with network and page scripts disabled. The Studio runs only OpenMotion-authored showcase HTML in script-only sandboxed iframes; raw upstream HTML, CSS and scripts never execute in Studio. Offscreen, background and reduced-motion previews stop through the shared gallery playback controller. Local copies and source metadata identify brand-kit and style-only independently of template IDs.

Capture and data boundary

Website extraction runs adapted Hyperframes tokenExtractor and designStyleExtractor browser expressions, pinned with an Apache-2.0 notice. They preserve computed CSS custom properties, weighted color usage, loaded font families, semantic typography levels, spacing and radius scales, shadows, buttons, cards, navigation, badges, metric cells, tabs, gradients (including pseudo-elements), and frosted-glass materials. OpenMotion stores the full measurements as tokens and design alongside the representative showcase style. Old kits and catalogue snapshots without these optional fields remain readable.

OpenMotion corrections preserve alpha and modern CSS color spaces, exclude hidden ancestors, retain equally styled semantic headings, read theme/nested/external custom properties and avoid inventing a spacing base when the observations do not establish one. A bounded scroll activates lazy sections. Logo capture ranks explicit brand/home-link candidates, excludes partner/social/menu elements, deduplicates the pixels and keeps up to six marks. It never copies executable SVG markup. Fetched external stylesheets are parsed in detached CSSOM to recover font faces without applying them to Studio; up to sixteen actually loaded font files retain weight/style and unicode-range descriptors. The viewport screenshot and capture time remain source evidence. Resource limits and incomplete loads appear in collapsed capture notes. These are deterministic observations, not model-based interpretation or proof of brand correctness.

Capture runs in a fresh headless Chromium process with no user profile or login cookies. Public HTTPS requests use bounded, DNS-pinned transport, including redirects and assets; private, loopback and link-local destinations are rejected. When every OS DNS answer belongs to the proxy Fake-IP range 198.18.0.0/15, a bounded Cloudflare DNS-over-HTTPS lookup independently resolves the public hostname through a pinned resolver address with normal TLS verification. Its answers must pass the same public-address checks before connection. Mixed/private answers never receive this fallback. Host resolutions are reused only within that capture. Browser network calls are intercepted; additional connection/worker/frame channels are disabled. Captured HTML/scripts are never copied into the package or rendered in the Studio origin. Package CSS is generated from a validated, limited style vocabulary. Website content is reference data, never instructions. No model provider or paid generation is invoked.

Discovery covers use /motion-api/brand-kits/catalog/<id>/cover and /<id>/cover, resolved only from known catalogue or saved-kit websites. The catalogue also serves a local style-cover.svg so the grid has artwork while website images are loading. The shared cover service follows bounded public HTTPS redirects, prefers OG metadata over Twitter cards, then tries image tags in page order, including responsive and lazy image sources. It checks raster signatures, skips logos and tiny page images, and bounds the time spent on each candidate. Six concurrent workers share a 20-second request budget; successful images are cached for seven days and unavailable covers for one hour under <data-directory>/brand-cover-cache/. Successful cached bytes survive refresh failures. Cover fetching does not run page scripts, block extraction/rendering or modify the style-only package; website artwork is discovery metadata, not an additional motion/style instruction.

Local records and packages live in <data-directory>/brand-kits/<id>/, outside the checkout. Studio uses the same-origin /motion-api/brand-kits collection, /<id> read/update/delete, /<id>/cancel, /<id>/retry, /<id>/context and a manifest-bound file allowlist. Context uploads accept Markdown, text, JSON, PDF, common images, audio and fonts (8 MiB each; 32 files and 32 MiB per kit). Original folder-relative names remain display metadata; generated local names prevent path traversal. Uploaded content is stored as inert attachments, served as forced downloads with sandbox/nosniff headers, hashed into the package inventory, and never executed or automatically parsed into instructions. Removing a context file removes it from subsequent packages. Context data lives outside the replaceable capture directory so a rescan does not erase it. Mutations retain the host's same-origin protection; video reads support byte ranges. There is no cloud sync or automatic template registration.

Automatic style extraction supports public websites. Uploaded brand guides, including PDFs, travel as reference attachments; automatic PDF interpretation, authenticated website capture and hosted model enrichment are not implemented. Dynamic API-only pages, anti-bot challenges, late-loaded content and fonts can reduce extraction quality. Public availability does not grant font/brand redistribution rights; source references and notices travel with the package. Local checks, actual extraction, native rendering, playback and human visual acceptance are separate evidence.

Agent access through MCP

Use openmotion_assets_use with action: "brand_kit" and a brandKit command:

  • { "operation": "catalog", "query": "Hugging Face" } finds official entries; import accepts an exact catalogId. list returns saved kit summaries.
  • { "operation": "create", "url": "https://example.com/", "requestId": "example-brand-01" } queues extraction. Reusing the same key and website returns the same retained kit. Use get with its kitId to follow progress or cancel to stop extraction.
  • Use preview with the kitId to obtain a local Studio link and available media. Use package with the kitId and expectedUpdatedAt from get for the ZIP path and style-only handoff. A handoff ZIP pins the selected revision across later edits. Copy it out of the library if it needs to survive deleting the kit.
  • retry, rescan, edit, context and remove check that same observed revision. edit accepts a name and/or the complete editable style map; context accepts rules, one base64 file upload or a file ID to remove. Read again after BRAND_KIT_CHANGED. Both Studio and MCP use the same local records and file limits.

Acknowledgements

The capture implementation ports Hyperframes' public computed-style extractor and Brand Kit documentation. The token/style browser expressions and their shared types are adapted from that pinned revision; source notice and changes and Apache-2.0 license ship with the application. Storage, context editing, asset capture, package handoff, fixed showcase and Studio integration are OpenMotion implementations. The hosted Brand Kit service and model enrichment are absent from the public upstream tree and are not imported. The native runtime retains its upstream notices. The copied GSAP runtime retains its original copyright/license header and reference; captured brand assets retain their owners' rights.

The curated catalogue preserves OpenDesign at revision 59e4f2ae85de7e7318a5e6bdcf3a34584c4b7582, its Apache-2.0 license and upstream MIT notices in library/brand-kits. Brand names identify style references and do not imply brand endorsement.

Detail presentation

New extraction and saved-kit details use the template detail's media stage and independent information panel. Saved kits share the poster-backed video player, frosted backdrop, round navigation controls, creator/source row, expandable Agent instruction and metadata separators. Style inspection and context editing remain Brand Kit operations. The package and copy actions keep their style-only contract.