@vvfx/lottie2ir 0.0.1-beta.10 → 0.0.1-beta.12

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -1,19 +1,21 @@
1
1
  # @vvfx/lottie2ir
2
2
 
3
+ English | [简体中文](./README-zh_CN.md)
4
+
3
5
  Lottie to Animation IR converter.
4
6
 
5
7
  ## Contents
6
8
 
7
9
  - [Install](#install)
8
10
  - [Usage](#usage)
11
+ - [Input capabilities](#input-capabilities)
9
12
  - [API](#api)
10
13
  - [Project structure](#project-structure)
11
- - [Contributing](#contributing)
12
14
  - [License](#license)
13
15
 
14
16
  ## Install
15
17
 
16
- Node.js 22 or later is required.
18
+ Node.js 24 or later is required.
17
19
 
18
20
  ```bash
19
21
  pnpm add @vvfx/lottie2ir
@@ -45,6 +47,43 @@ const extracted = await extractLottieFromZip(zipArrayBuffer);
45
47
  const result = convertLottieToIR(extracted.json, { zipResources: extracted });
46
48
  ```
47
49
 
50
+ ## Input capabilities
51
+
52
+ This matrix describes Lottie import into Animation IR. Supported means the listed subset is converted; partial means
53
+ some values are approximated or omitted. GE export through `@vvfx/ge-ir` has additional limits.
54
+
55
+ | Capability | Status | Behavior |
56
+ | --- | --- | --- |
57
+ | JSON object / string | Supported | Requires valid frame rate, canvas size, and in/out points. |
58
+ | ZIP input | Supported | Extracts JSON and supported image/font files; ZIP entries become Data URLs. |
59
+ | Layers and hierarchy | Supported | Precomp, solid, image, null, shape, and text layers; parent references. |
60
+ | Precomp timing | Partial | Start and stretch are mapped; invalid stretch uses `1` with a warning. |
61
+ | Transform keyframes | Partial | Position, rotation, scale, and opacity; animated anchors use the first value. |
62
+ | Separated position | Partial | Incompatible axis timelines are sampled at combined keyframe times, with a warning. |
63
+ | Shape geometry and paint | Partial | Paths, rectangles, ellipses, stars, polygons, fills, and strokes. |
64
+ | Animated gradients | Partial | Only the first keyframe is retained; a warning is returned. |
65
+ | Shape modifiers | Unsupported | Trim, repeater, merge, and other unsupported operators are omitted with warnings. |
66
+ | Authored masks | Partial | Ordered closed static paths, full opacity, add/subtract/intersect, and inversion. |
67
+ | Track mattes | Partial | Alpha/luminance and inversion enter IR; GE export cannot lower luminance mattes. |
68
+ | Text | Partial | First Text Document only. Static filled point-text glyphs become vector shapes; font-based text may use estimated bounds and fallback fonts. |
69
+ | Resource loading | Partial | Resolves URLs or ZIP data; conversion does not fetch external images or fonts. |
70
+ | Expressions, effects, 3D | Unsupported | No expression evaluator, general effect pipeline, or 3D scene conversion. |
71
+
72
+ Inspect `result.diagnostics`: examples include `LOTTIE_UNSUPPORTED_LAYER_TYPE`, `LOTTIE_UNSUPPORTED_SHAPE_FEATURE`,
73
+ `LOTTIE_UNSUPPORTED_MASK`, `LOTTIE_ANIMATED_ANCHOR_FALLBACK`, and `LOTTIE_ANIMATED_GRADIENT_FALLBACK`.
74
+ Masks retain source order in `layer.masks[]`. A stack containing animated, open, non-opaque, or unsupported entries
75
+ is dropped as a whole with `LOTTIE_UNSUPPORTED_MASK`. GE export has separate limits on Add unions.
76
+ Embedded `chars` preserve glyph contours, advance widths, tracking, alignment, and line spacing as IR Shape layers.
77
+ These layers retain their transforms and parenting but are no longer editable text. Missing glyphs, paragraph boxes,
78
+ strokes, animated glyphs, and unsupported outline operators fall back to font-based text with
79
+ `LOTTIE_UNSUPPORTED_TEXT_GLYPHS`.
80
+ Duplicate layer indices produce `LOTTIE_DUPLICATE_LAYER_INDEX`; parent references retain lottie-web's source-order
81
+ transform multiplication through private null layers, without changing the visible parents.
82
+ Children active outside an ancestor's visibility interval also use independent transform nodes, so the ancestor's
83
+ animation continues to affect them while its own content keeps its authored display interval.
84
+ Text animation and unrecognized fields do not all have dedicated diagnostics; an empty array does not prove fidelity.
85
+ Invalid JSON, ZIP parsing, conversion, or IR validation failures throw `LottieConverterError`.
86
+
48
87
  ## API
49
88
 
50
89
  ### `convertLottieToIR(input, options?)`
@@ -76,16 +115,6 @@ src/
76
115
  └── index.ts # Stable public entry
77
116
  ```
78
117
 
79
- ## Contributing
80
-
81
- Use repository issues for questions and bug reports. Pull requests are welcome. Run the following checks after changing
82
- conversion behavior:
83
-
84
- ```bash
85
- pnpm --filter @vvfx/lottie2ir test
86
- pnpm --filter @vvfx/lottie2ir build
87
- ```
88
-
89
118
  ## License
90
119
 
91
120
  [MIT](./LICENSE) © 2019-present Ant Group Co., Ltd.
@@ -1,5 +1,5 @@
1
1
  import type { ConversionDiagnostic } from '@vvfx/animation-ir/adapter';
2
- type LottieDiagnosticCode = 'unsupported-layer-type' | 'unsupported-shape-type' | 'unsupported-shape-feature' | 'unsupported-mask' | 'unsupported-track-matte' | 'missing-font' | 'missing-image-asset' | 'missing-text-data' | 'invalid-stretch-ratio' | 'separated-position-fallback' | 'animated-anchor-fallback' | 'animated-gradient-fallback';
2
+ type LottieDiagnosticCode = 'unsupported-layer-type' | 'unsupported-shape-type' | 'unsupported-shape-feature' | 'unsupported-mask' | 'unsupported-track-matte' | 'missing-font' | 'missing-image-asset' | 'missing-text-data' | 'invalid-stretch-ratio' | 'separated-position-fallback' | 'animated-anchor-fallback' | 'animated-gradient-fallback' | 'duplicate-layer-index' | 'unsupported-text-glyphs';
3
3
  interface CreateLottieDiagnosticOptions {
4
4
  code: LottieDiagnosticCode;
5
5
  message: string;
@@ -1,6 +1,7 @@
1
1
  import { type IRLayer, type IRLayerMatte } from '@vvfx/animation-ir';
2
+ import type { Text } from '@lottie-animation-community/lottie-types';
2
3
  import type { ConversionDiagnostic } from '@vvfx/animation-ir/adapter';
3
- import type { LottieImageAsset, LottiePrecompAsset, LottieVisualLayer } from '../common/conversion-types';
4
+ import type { LottieFont, LottieImageAsset, LottiePrecompAsset, LottieVisualLayer } from '../common/conversion-types';
4
5
  interface CompositionFrameRange {
5
6
  inPoint: number;
6
7
  outPoint: number;
@@ -14,6 +15,8 @@ interface ConvertLottieLayerOptions {
14
15
  compositionRange: CompositionFrameRange;
15
16
  precompCompositionId?: string;
16
17
  fontAssetIdByName: ReadonlyMap<string, string>;
18
+ fonts: LottieFont[];
19
+ chars?: Text.CharacterData[];
17
20
  }
18
21
  interface ConvertLottieLayerResult {
19
22
  layer: IRLayer;
@@ -1,8 +1,8 @@
1
1
  import { type IRMask } from '@vvfx/animation-ir';
2
2
  interface LottieMaskConversion {
3
- mask?: IRMask;
3
+ masks: IRMask[];
4
4
  unsupportedFeatures: string[];
5
5
  }
6
- /** Converts one supported authored Mask and reports features that prevent conversion. */
7
- export declare function convertLottieMask(maskInfo: unknown): LottieMaskConversion;
6
+ /** Converts the ordered authored Mask stack and reports features that prevent conversion. */
7
+ export declare function convertLottieMasks(maskInfo: unknown): LottieMaskConversion;
8
8
  export {};
@@ -0,0 +1,5 @@
1
+ import type { IRShape } from '@vvfx/animation-ir';
2
+ import type { Text } from '@lottie-animation-community/lottie-types';
3
+ import type { LottieFont, LottieVisualLayer } from '../common/conversion-types';
4
+ /** Embedded glyph paths use 100-unit font coordinates, independent of the exported font size. */
5
+ export declare function convertLottieTextGlyphs(layer: LottieVisualLayer, fonts: LottieFont[], chars: Text.CharacterData[]): IRShape[] | undefined;