From b39a1542f21d2933dc308d6265b7f7b0ac4546a4 Mon Sep 17 00:00:00 2001 From: Bob Lee Date: Tue, 17 Nov 2026 11:36:58 +0800 Subject: [PATCH] feat(visual-skin): simplify package limits and support MP4 surface backdrops --- docs/features/visual-skin-packs.md | 24 ++- .../references/authoring-template.md | 2 +- .../references/contract.md | 26 +-- .../scripts/visual-skin.mjs | 11 +- .../scripts/visual-skin.test.mjs | 22 +++ .../application/AppearanceSettingsPage.scss | 11 ++ src/web-ui/src/app/styles/visual-skin.scss | 16 ++ .../VisualSkinConfigSection.test.tsx | 32 ++++ .../components/VisualSkinConfigSection.tsx | 49 +++++- .../visual-skin/archive.test.ts | 56 +++---- .../src/infrastructure/visual-skin/archive.ts | 47 ++++-- .../visual-skin/asset-resources.ts | 13 +- .../src/infrastructure/visual-skin/index.ts | 1 + .../src/infrastructure/visual-skin/parser.ts | 31 ++-- .../infrastructure/visual-skin/part-paint.ts | 1 + .../visual-skin/runtime.regression.test.ts | 3 +- .../src/infrastructure/visual-skin/runtime.ts | 81 +++++++++- .../src/infrastructure/visual-skin/types.ts | 3 +- .../visual-skin/validator.test.ts | 11 +- .../infrastructure/visual-skin/validator.ts | 33 +++- .../visual-skin/video-backdrop.test.ts | 152 ++++++++++++++++++ 21 files changed, 513 insertions(+), 112 deletions(-) create mode 100644 src/web-ui/src/infrastructure/visual-skin/video-backdrop.test.ts diff --git a/docs/features/visual-skin-packs.md b/docs/features/visual-skin-packs.md index 29fdf8d13c..4a4afe8c35 100644 --- a/docs/features/visual-skin-packs.md +++ b/docs/features/visual-skin-packs.md @@ -69,7 +69,7 @@ The importer accepts two package forms: - **Canonical JSON** uses `manifest`, `modes`, `assets`, `components`, and `surfaces`. JSON assets must be embedded as base64 data URLs. - **ZIP** may contain a canonical `skin.json` with declared package-relative - image assets. The importer also accepts the multi-file entrypoint format + image or MP4 video assets. The importer also accepts the multi-file entrypoint format (`format: openbitfun-visual-skin`), resolving its token/asset/slot/recipe files into canonical fields. New Skill output uses the canonical format directly to avoid authoring fields that the conversion does not project. @@ -78,16 +78,24 @@ The runtime accepts the public token contract from `@openbitfun/theme-openbitfun` and `@openbitfun/design-tokens`, named visual slots, component recipes, interaction states, and surface profiles. It validates identifiers, exact public token names (without aliases), asset MIME types, data URLs, package-relative paths, -archive size, and undeclared files before persisting a package. ZIP directory -metadata is checked before extraction (96 entries including directories, -16 MiB per entry, 416 MiB total); manifest/entrypoint reads additionally have a -512 KiB limit. Extraction uses a bounded streaming sink, cancellation, and CRC -validation. Actual output is bounded as well as declared sizes, and each asset -is extracted once. Packages cannot +and undeclared files before persisting a package. The only size limit is +**128 MiB per file** (including `skin.json`); entry count, package size and +total expanded size are not limited. ZIP directory metadata is checked before +extraction. Extraction uses a bounded streaming sink, cancellation, and CRC +validation. Actual output is bounded by the per-file limit as well as the +declared size, and each asset is extracted once. Assets are kept in memory as +base64 data URLs, so very large assets cost far more memory than their file size. + +Assets may be PNG, JPEG, WebP, SVG or `video/mp4`. An MP4 is valid only as a +surface `backgroundAssetId` (or the preview): the runtime mounts it as a muted, +looping `