Skip to content

Import HTML CSS GSAP and anime.js animations into PAGX with html-to-pagx skill and snapshot toolchain.#3508

Open
OnionsYu wants to merge 416 commits into
Tencent:mainfrom
OnionsYu:feature/onionsyu_import_html_animation
Open

Import HTML CSS GSAP and anime.js animations into PAGX with html-to-pagx skill and snapshot toolchain.#3508
OnionsYu wants to merge 416 commits into
Tencent:mainfrom
OnionsYu:feature/onionsyu_import_html_animation

Conversation

@OnionsYu

Copy link
Copy Markdown
Contributor

将 HTML 页面(含 CSS keyframes、GSAP、anime.js 等动画)导入为带动画的 PAGX,并配套提供 html-to-pagx skill 与 html-snapshot 工具链,便于非技术用户从描述或现有网页生成动画 PAGX。

主要变更:

  1. HTML 动画导入器

    • 解析 CSS @Keyframes 与 animation 简写、animation-timing-function、animation-fill-mode、animation-direction、animation-iteration-count、animation-delay 等属性,转换为 PAGX 动画通道。
    • 支持 GSAP 与 anime.js 时间线采样:在浏览器中以前向迭代采样,按通道用 RDP 抽稀,保留缓动曲线同时控制文件大小。
    • 透明度、颜色、变换(含 matrix/matrix3d 平移与缩放/旋转混合)、SVG presentation 属性等关键通道支持。
    • steps() 缓动展开为分步保持帧;reverse 方向同步反转 timing function;fill-mode 在延迟与结束阶段行为正确。
  2. html-snapshot 工具与 npm 包

    • 新增 cli/npm/html-snapshot 与 build/pack 脚本,将 html-snapshot 运行时打入 @libpag/pagx 包,安装后即可使用 pagx import,无需 libpag 源码。
    • 新增 eval-animation 测评:逐帧对比原页面与 PAGX 渲染,输出动画保真度报告与 HTML 回放。
    • 新增 ResourceCache 路由与响应监听,避免重复子资源请求;snapshot 阶段冻结 CSS 解析后的 SVG 属性、物化 ::before/::after 伪元素,提升导入保真度。
  3. html-to-pagx skill

    • 新增 .codebuddy/skills/html-to-pagx 指南与脚本,覆盖 HTML 写法、动画捕获规则与转换流程。
    • pagx skill cli 文档同步更新,补充 render --time 等新参数说明。
  4. CLI 与 spec 文档

    • pagx render 新增 --time,并禁止与 --crop 组合;CommandImport 增加 HTML 子集导入路径。
    • 新增 spec/html_subset.md 及中文版,明确支持的 HTML/CSS 子集与动画规则。
    • resources/html 新增 card/login/tab_bar/table_visual 等示例页面。
  5. 其它修复

    • flex 布局:保留作者指定的 text leaf 宽度;将共享 cross-axis inset 提升为容器 padding;显式 cross 维度时跳过提升以避免 padding 偏移。
    • 边框与渐变:将等宽非对称圆角彩色边框降级为内联 SVG 弧形,纯 CSS ring 类 spinner 可正确导入。
    • 渲染对比:透明 PAGX 在白底合成后再 diff,避免未绘制区域被误报为巨大差异。

OnionsYu added 30 commits June 3, 2026 16:54
…resolved typeface lacks the requested weight or slant."

This reverts commit 630cc34.
…eight and slant survive missing styled faces.
…riting-mode support and new normalization passes.
…rt_html2

# Conflicts:
#	include/pagx/PAGXDocument.h
#	src/pagx/svg/SVGExporter.cpp
…set is preserved under the absolute x and y channel.
…API animations so ease-in-out and cubic-bezier easings reach the snapshot instead of being clobbered to linear.
…acity-zero visibility cull so fade-in subjects survive the snapshot walker.
…le clamping color lerp to keep channels valid.
…HTML import so step animations actually advance instead of holding the start value for the full duration.
…everse and delayed animations capture the base layout position instead of the current animation frame.
…ns no longer show the start keyframe value during the delay or revert correctly when finished.
…r target for HTML color animations so text color keyframes are applied instead of being silently dropped.
…nstances no longer drop out of anime.running and freeze every later frame at the start state.
…and yoyo tweens import as a clean alternating loop.
…imated elements so autoAlpha entrances render.
…resent so GSAP animations preserve their position.
…S animation-direction reverse so ease-in plays as ease-out and steps jump-end as jump-start.
OnionsYu and others added 30 commits July 9, 2026 20:53
…ngth normalization, mask/clip-path handling, inline-SVG currentColor and shared-defs injection, flex inference edge cases, text-fragment whitespace/writing-mode/decoration branches, and HTML transform-pass skeleton/filter paths, raising line coverage of the SVG and HTML importer sources from 84.7% to 92.3%.
…mask> of white stroke shapes plus a masked <foreignObject> whose <div> carries the paint as a CSS gradient) back into native stroked shapes during inline-SVG import, recolouring each mask shape's stroke to a concrete colour sampled from the div background (solid verbatim, gradient sampled to its representative hue over the shape box), because the downstream SVG importer does not understand <foreignObject> and would otherwise paint the masked region opaque black and drop the shape on dark backgrounds, which was erasing the conic-gradient petals in the showcase_mandala pagx_to_html round-trip.
…eStorage.cpp), exercising ParseImageStorageMode aliases and both Embed and External modes end to end, including data-URI/remote/inline skips, relative-path resolution via baseDir/outputDir, absolute and CWD-relative reads, document-dir prefix stripping, co-located cleanup, and the missing-file, create-directory, and copy-file failure paths, raising line coverage of the file from 0% to 99%.
…spec and expand the pagx skill's reference table.

Redirect spec/html_subset.md (and its zh_CN mirror) from the nonexistent references/patterns.md, references/guide.md, and "PAGX guide" pointers to the real spec/pagx_spec.md Container Layout section (and inline the text-decoration/pitfalls notes), and correct the §11 auto-normalization prose to describe autoNormalize/preserveUnknownElements as HTMLImporter::Options fields rather than the nonexistent --html-no-normalize/--html-preserve-unknown CLI flags. Also list resolve and PPTX export in the pagx SKILL.md CLI reference row, add spec/html_subset.md as a listed reference, and broaden the description triggers accordingly.
…port_html_animation

# Conflicts:
#	.codebuddy/skills/pagx/SKILL.md
#	src/pagx/PAGXExporter.cpp
#	test/src/PAGXHTMLImporterTest.cpp
… id export image-storage pass and SVG PPTX exporters into the HTML animation branch.
… runner, mirroring the static eval so animation cases can download external images into a shared content-addressed cache and store images in each .pagx as external files or embedded base64.
…struction and the pagx import CLI options raising line coverage of HTMLInlineSvgEmitter to 99 percent and CommandImport to 52 percent.
…channels the importer already supports, correcting the stale claim that scale/rotate/skew are non-playable and adding the matrix, drop-shadow/blur filter, clip-path morph, animation-fill-mode, steps, and inline-SVG fill/stroke/dashoffset channels, and add the missing section 13 Animation to the Chinese spec.

Co-authored-by: Cursor <cursoragent@cursor.com>
… a main merge, adding shrink-to-fit flex-grow and justify-content tolerance boundary tests, and replacing decimal test values with integers.
…y parsing them with SVGBlendModeFromString (hyphenated CSS keywords such as color-dodge/hard-light/plus-lighter) instead of BlendModeFromString (which only accepts PAGX's camelCase names, so single-word modes worked by coincidence while every multi-word mode silently fell back to Normal), and recover BlendMode::PlusDarker from the exporter's baked pagx_pd_* feImage+feComposite filter marker so the pagx->html->pagx round-trip preserves all blend modes, with new importer tests covering the hyphenated keywords and the plus-darker filter marker.
…rt_html2

# Conflicts:
#	src/pagx/PAGXExporter.cpp
… the locally built pagx directly instead of the html2pagx wrapper, reframing html2pagx as an optional convenience tool.
…tory instead of test/out so CI artifact upload no longer fails on the illegal colon character.
…tandalone workflow into an update-only flow for editing existing PAGX files, and vendor the html_subset spec into the skill so its reference resolves.
…d CLI: correct the HTMLSubsetTransformer header path and rename the AbsoluteToFlexInference pass to HTMLFlexInference in the spec, fix pagx import resolve-failure behavior (aborts without writing) and format inference wording in cli.md, note the render/layout/bounds/export/font-embed resolved-file prerequisite and the verify --json file field, correct the warm-server no-resolve output and the --embed-fonts font guidance to pagx font embed across SKILL/pipeline/authoring-html, and fix the stale off-by-default --html-infer-flex comment on HTMLFlexInferencePass.
…nto feature/onionsyu_import_html_animation

# Conflicts:
#	.codebuddy/skills/pagx/SKILL.md
…rt_html_animation

# Conflicts:
#	.codebuddy/skills/pagx/SKILL.md
#	.codebuddy/skills/pagx/references/authoring-html.md
#	CMakeLists.txt
#	spec/html_subset.md
#	spec/html_subset.zh_CN.md
#	src/cli/CommandImport.cpp
#	src/pagx/html/importer/HTMLCssCascade.cpp
#	src/pagx/html/importer/HTMLCssCascade.h
#	src/pagx/html/importer/HTMLElementEmitter.cpp
#	src/pagx/html/importer/HTMLLayerBuilder.cpp
#	src/pagx/html/importer/HTMLParserContext.cpp
#	src/pagx/html/importer/HTMLParserContext.h
#	src/pagx/html/importer/HTMLStyleCascade.cpp
#	src/pagx/html/importer/HTMLStyleCascade.h
#	src/pagx/html/importer/HTMLSubsetPropertyTable.cpp
#	src/pagx/html/importer/HTMLTransformPasses.cpp
#	src/pagx/html/importer/HTMLValueParser.cpp
#	src/pagx/html/importer/HTMLValueParser.h
#	src/pagx/svg/SVGImporter.cpp
#	src/pagx/utils/StringParser.cpp
#	src/pagx/utils/StringParser.h
#	test/src/PAGXHTMLImporterTest.cpp
#	tools/html-snapshot/README.md
#	tools/html-snapshot/eval/compare.js
#	tools/html-snapshot/html2pagx
#	tools/html-snapshot/lib/batch.ts
#	tools/html-snapshot/lib/browser-engine.ts
#	tools/html-snapshot/lib/browser-snapshot.ts
#	tools/html-snapshot/lib/cli.ts
#	tools/html-snapshot/lib/pipeline.ts
#	tools/html-snapshot/lib/resource-cache.ts
#	tools/html-snapshot/lib/snapshot-runner.ts
#	tools/html-snapshot/snapshot.js
#	tools/html-snapshot/test/browser-engine.test.js
… so the SVG viewBox scale is asserted on the layer matrix and the unsupported-filter warning uses a genuinely unrecognized filter function.
…re helpers for transform matrix filter clip-path and step timing.
…ons in html-snapshot animation-capture.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
… rate, and loop mode into a single Animation so a staggered grid of siblings no longer produces a long run of near-identical Animation blocks.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants