@vvfx/ge-ir 0.0.1-beat.2

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.
Files changed (48) hide show
  1. package/LICENSE +22 -0
  2. package/README.md +66 -0
  3. package/dist/ge2ir/converter.d.ts +3 -0
  4. package/dist/ge2ir/index.d.ts +2 -0
  5. package/dist/ge2ir/merge/merge.d.ts +9 -0
  6. package/dist/ge2ir/parsers/animation-parser.d.ts +4 -0
  7. package/dist/ge2ir/parsers/component-parser.d.ts +16 -0
  8. package/dist/ge2ir/parsers/keyframe-parser.d.ts +7 -0
  9. package/dist/ge2ir/parsers/timeline-parser.d.ts +9 -0
  10. package/dist/ge2ir/parsers/transform-parser.d.ts +3 -0
  11. package/dist/ge2ir/pool/pool.d.ts +4 -0
  12. package/dist/ge2ir/reverse/blend-mode.d.ts +2 -0
  13. package/dist/ge2ir/reverse/coordinate.d.ts +1 -0
  14. package/dist/ge2ir/reverse/end-behavior.d.ts +3 -0
  15. package/dist/ge2ir/reverse/timing.d.ts +2 -0
  16. package/dist/ge2ir/scene-reader.d.ts +3 -0
  17. package/dist/ge2ir/types.d.ts +24 -0
  18. package/dist/index.d.ts +17 -0
  19. package/dist/index.js +4812 -0
  20. package/dist/index.js.map +1 -0
  21. package/dist/index.mjs +4790 -0
  22. package/dist/index.mjs.map +1 -0
  23. package/dist/ir2ge/assembly/generator.d.ts +23 -0
  24. package/dist/ir2ge/assembly/scene-assembly.d.ts +11 -0
  25. package/dist/ir2ge/builders/animation.d.ts +4 -0
  26. package/dist/ir2ge/builders/bezier.d.ts +44 -0
  27. package/dist/ir2ge/builders/component.d.ts +13 -0
  28. package/dist/ir2ge/builders/effects.d.ts +9 -0
  29. package/dist/ir2ge/builders/layer.d.ts +5 -0
  30. package/dist/ir2ge/builders/timeline.d.ts +9 -0
  31. package/dist/ir2ge/builders/timing.d.ts +17 -0
  32. package/dist/ir2ge/index.d.ts +14 -0
  33. package/dist/ir2ge/ir/anchor-strategy.d.ts +24 -0
  34. package/dist/ir2ge/ir/layer-dimensions.d.ts +13 -0
  35. package/dist/ir2ge/ir/layer-utils.d.ts +14 -0
  36. package/dist/ir2ge/ir/parent-link.d.ts +15 -0
  37. package/dist/ir2ge/ir/specific.d.ts +14 -0
  38. package/dist/ir2ge/post-process/ge-mask-remap.d.ts +18 -0
  39. package/dist/ir2ge/post-process/index.d.ts +31 -0
  40. package/dist/ir2ge/post-process/mask.d.ts +26 -0
  41. package/dist/ir2ge/post-process/parenting.d.ts +3 -0
  42. package/dist/ir2ge/post-process/visibility.d.ts +26 -0
  43. package/dist/ir2ge/types.d.ts +37 -0
  44. package/dist/ir2ge/utils.d.ts +14 -0
  45. package/dist/shared/coordinate.d.ts +11 -0
  46. package/dist/shared/ge2ir-metadata.d.ts +17 -0
  47. package/dist/shared/types.d.ts +60 -0
  48. package/package.json +42 -0
package/LICENSE ADDED
@@ -0,0 +1,22 @@
1
+ MIT LICENSE
2
+
3
+ Copyright (c) 2019-present Ant Group Co., Ltd. https://www.antgroup.com/
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,66 @@
1
+ # @vvfx/ge-ir
2
+
3
+ > 内部转换包。统一承载 Galacean Effects JSONScene 与 `@vvfx/animation-ir`
4
+ > 之间的双向转换能力,供 monorepo 内的 `lottie2ge`、`dsl2ge`、调试页面等链路复用。
5
+
6
+ ## 能力范围
7
+
8
+ ```
9
+ JSONScene ── convertGEToIR ──> IRComposition ── convertIRToGE ──> JSONScene
10
+ @vvfx/animation-ir
11
+ ```
12
+
13
+ 本包不定义 IR 数据模型;`@vvfx/animation-ir` 仍是 IR 类型和校验逻辑的唯一真源。
14
+
15
+ ## 主要 API
16
+
17
+ ```ts
18
+ import { convertGEToIR, convertIRToGE } from '@vvfx/ge-ir';
19
+
20
+ const ir = convertGEToIR(scene, { frameRate: 30 });
21
+ const roundTrippedScene = convertIRToGE(ir);
22
+ ```
23
+
24
+ - `convertIRToGE(ir, duration?)`:IR -> GE JSONScene。
25
+ - `convertGEToIR(scene, options)`:GE JSONScene -> IRComposition。
26
+ - `GE2IROptions`:当前包含 `frameRate`。
27
+ - `JSONScene` / `DataPath`:从 `@galacean/effects-specification` 透出,方便 sibling 包消费。
28
+
29
+ ## 共享契约
30
+
31
+ `src/shared/coordinate.ts` 是正反向坐标换算的共同真源:
32
+
33
+ - `DEFAULT_CAMERA_Z`
34
+ - `DEFAULT_CAMERA_FOV`
35
+ - `DEFAULT_CLIP_MODE`
36
+ - `get2dTo3dRatio`
37
+ - `convert2dTo3dPoint`
38
+
39
+ `src/shared/ge2ir-metadata.ts` 是 round-trip passthrough metadata 的共同真源。`ge2ir`
40
+ 写入 `layer.metadata.ge2ir`,`ir2ge` 在生成 GE 时读取并复用原始 GE 动画和 mask 信息。
41
+
42
+ 当前支持的 metadata keys:
43
+
44
+ - `positionOverLifetime`
45
+ - `rotationOverLifetime`
46
+ - `sizeOverLifetime`
47
+ - `colorOverLifetime`
48
+ - `geComponentId`
49
+ - `geMask`
50
+
51
+ `src/shared/types.ts` 放置不属于单一方向的 GE wire/pool 基础结构:
52
+
53
+ - `GERecord`
54
+ - `GEDataPath`
55
+ - `GEPoolIndex`
56
+ - `GETransform`
57
+ - `GEItem`
58
+ - `ECSCollector`
59
+
60
+ ## 稳定性分层
61
+
62
+ `src/index.ts` 按三层导出:
63
+
64
+ - 公开/主链路:`convertIRToGE`、`convertGEToIR`、基础类型。
65
+ - sibling 包 API:`readLottieSpecific`、`isTransformOnlyParentLink`、部分 GE 处理中间类型。
66
+ - debug internals:bezier/timeline/post-process/utils 等调试链路会用到的内部符号。
@@ -0,0 +1,3 @@
1
+ import type { IRComposition } from '@vvfx/animation-ir';
2
+ import type { GE2IROptions } from './types';
3
+ export declare function convertGEToIR(scene: Record<string, unknown>, options: GE2IROptions): IRComposition;
@@ -0,0 +1,2 @@
1
+ export { convertGEToIR } from './converter';
2
+ export type { GE2IROptions } from './types';
@@ -0,0 +1,9 @@
1
+ import type { IRLayerNode } from '@vvfx/animation-ir';
2
+ import type { GESceneContext } from '../types';
3
+ export interface RawLayerDescriptor {
4
+ itemId: string;
5
+ item: Record<string, unknown>;
6
+ layer: IRLayerNode;
7
+ }
8
+ export declare function mergeNullSpritePairs(descriptors: RawLayerDescriptor[], ctx: GESceneContext): RawLayerDescriptor[];
9
+ export declare function resolveHierarchy(descriptors: RawLayerDescriptor[], ctx: GESceneContext): void;
@@ -0,0 +1,4 @@
1
+ import type { IRAnimatedProperty, IRTransformChannels } from '@vvfx/animation-ir';
2
+ import type { GESceneContext } from '../types';
3
+ export declare function parseTransformAnimation(asset: Record<string, unknown>, startFrame: number, endFrame: number, ctx: GESceneContext): Partial<IRTransformChannels>;
4
+ export declare function parseOpacityAnimation(asset: Record<string, unknown>, startFrame: number, endFrame: number): IRAnimatedProperty<number> | undefined;
@@ -0,0 +1,16 @@
1
+ import type { IRAssetReference, IRBlendMode, IRColor, IRShapeData, IRTextData } from '@vvfx/animation-ir';
2
+ import type { GESceneContext } from '../types';
3
+ export interface ComponentData {
4
+ type: 'image' | 'solid' | 'text' | 'shape';
5
+ asset?: IRAssetReference;
6
+ solidColor?: IRColor;
7
+ text?: IRTextData;
8
+ shapes?: IRShapeData[];
9
+ blendMode?: IRBlendMode;
10
+ anchorScale?: [number, number];
11
+ /** Original GE component id — rendezvous key for cross-component references (masks). */
12
+ geComponentId?: string;
13
+ /** Raw GE component-level `mask` object (source: {isMask:true,...}, target: {isMask:false,reference,inverted}). */
14
+ rawMask?: Record<string, unknown>;
15
+ }
16
+ export declare function parseComponent(item: Record<string, unknown>, ctx: GESceneContext): ComponentData | undefined;
@@ -0,0 +1,7 @@
1
+ import type { IRBezierHandle, IRKeyframe } from '@vvfx/animation-ir';
2
+ export declare function parseBezierKeyframes(curves: unknown[], startFrame: number, endFrame: number): IRKeyframe<number>[];
3
+ export declare function parsePositionTimingKeyframes(curves: unknown[], startFrame: number, endFrame: number): Array<{
4
+ t: number;
5
+ outTangent?: IRBezierHandle;
6
+ inTangent?: IRBezierHandle;
7
+ }>;
@@ -0,0 +1,9 @@
1
+ import type { GESceneContext } from '../types';
2
+ export interface TimelineData {
3
+ delay: number;
4
+ duration: number;
5
+ endBehavior: number;
6
+ transformAsset?: Record<string, unknown>;
7
+ spriteColorAsset?: Record<string, unknown>;
8
+ }
9
+ export declare function parseTimeline(itemId: string, ctx: GESceneContext): TimelineData | undefined;
@@ -0,0 +1,3 @@
1
+ import type { IRTransformChannels } from '@vvfx/animation-ir';
2
+ import type { GESceneContext } from '../types';
3
+ export declare function parseStaticTransform(itemTransform: Record<string, unknown>, ctx: GESceneContext): Partial<IRTransformChannels>;
@@ -0,0 +1,4 @@
1
+ import type { GEPoolIndex, GERecord } from '../../shared/types';
2
+ export declare function buildPoolIndex(pool: GERecord[] | undefined): GEPoolIndex;
3
+ export declare function resolveDataPath(pool: GEPoolIndex, ref: unknown): GERecord | undefined;
4
+ export declare function resolveDataPathId(ref: unknown): string | undefined;
@@ -0,0 +1,2 @@
1
+ import type { IRBlendMode as IRBlendModeType } from '@vvfx/animation-ir';
2
+ export declare function reverseBlendMode(geCode: number | undefined): IRBlendModeType | undefined;
@@ -0,0 +1 @@
1
+ export declare function convert3dTo2dPoint(x: number, y: number, z: number, width: number, height: number): [number, number, number];
@@ -0,0 +1,3 @@
1
+ import type { IREndBehavior as IREndBehaviorType } from '@vvfx/animation-ir';
2
+ export declare function reverseEndBehavior(geBehavior: number | undefined): IREndBehaviorType | undefined;
3
+ export declare function reverseCompositionEndBehavior(geBehavior: number | undefined): IREndBehaviorType | undefined;
@@ -0,0 +1,2 @@
1
+ import type { IRTimeContext } from '@vvfx/animation-ir';
2
+ export declare function reverseLayerTiming(delay: number, duration: number, frameRate: number): IRTimeContext;
@@ -0,0 +1,3 @@
1
+ import type { GE2IROptions, GESceneContext } from './types';
2
+ export declare function buildSceneContext(scene: Record<string, unknown>, options: GE2IROptions): GESceneContext;
3
+ export declare function getCompositionItemIds(scene: Record<string, unknown>): string[];
@@ -0,0 +1,24 @@
1
+ import type { IRColor, IREndBehavior } from '@vvfx/animation-ir';
2
+ import type { GEPoolIndex } from '../shared/types';
3
+ export interface GE2IROptions {
4
+ frameRate: number;
5
+ }
6
+ export type { GE2IRPassthroughMetadata } from '../shared/ge2ir-metadata';
7
+ export interface GESceneContext {
8
+ width: number;
9
+ height: number;
10
+ frameRate: number;
11
+ ratio: number;
12
+ duration: number;
13
+ inPoint: number;
14
+ outPoint: number;
15
+ compositionName: string;
16
+ endBehavior?: IREndBehavior;
17
+ backgroundColor?: IRColor;
18
+ itemById: GEPoolIndex;
19
+ componentById: GEPoolIndex;
20
+ miscById: GEPoolIndex;
21
+ imageById: GEPoolIndex;
22
+ textureById: GEPoolIndex;
23
+ itemIdToTrackId: Map<string, string>;
24
+ }
@@ -0,0 +1,17 @@
1
+ export { convertIRToGE } from './ir2ge/assembly/generator';
2
+ export { convertGEToIR } from './ge2ir/converter';
3
+ export type { GE2IROptions } from './ge2ir/types';
4
+ export type { DataPath, JSONScene } from '@galacean/effects-specification';
5
+ export { readLottieSpecific } from './ir2ge/ir/specific';
6
+ export type { LottieLayerSpecific } from './ir2ge/ir/specific';
7
+ export { isTransformOnlyParentLink } from './ir2ge/ir/parent-link';
8
+ export type { ECSCollector, GEDataPath, GEItem, GEPoolIndex, GERecord, GETransform } from './shared/types';
9
+ export type { ProcessedItem, TransformAnimation } from './ir2ge/types';
10
+ export { DEFAULT_CAMERA_Z, DEFAULT_CAMERA_FOV, DEFAULT_CLIP_MODE, get2dTo3dRatio, convert2dTo3dPoint, } from './shared/coordinate';
11
+ export type { GE2IRPassthroughMetadata } from './shared/ge2ir-metadata';
12
+ export { assembleScene } from './ir2ge/assembly/scene-assembly';
13
+ export { estimateTextWidth, roundNumber, lerp, createId, toDataPath } from './ir2ge/utils';
14
+ export { irScalarKeyframesToGE, irVectorKeyframesToGE, irPositionKeyframesToGE, shouldUseKeyframeMode, } from './ir2ge/builders/bezier';
15
+ export type { IRToGETimeContext, IRPositionGEResult } from './ir2ge/builders/bezier';
16
+ export { buildTimelineTracks } from './ir2ge/builders/timeline';
17
+ export { normalizeChildVisibilityByParentDelays } from './ir2ge/post-process/visibility';