@vvfx/svg2ir 0.0.0-stage → 0.0.1-beta.0
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/LICENSE +22 -0
- package/README.md +179 -2
- package/dist/common/errors.d.ts +33 -0
- package/dist/common/types.d.ts +89 -0
- package/dist/convert.d.ts +19 -0
- package/dist/debug.d.ts +8 -0
- package/dist/helper.d.ts +5 -0
- package/dist/index.d.ts +14 -0
- package/dist/index.js +16013 -0
- package/dist/index.js.map +1 -0
- package/dist/index.mjs +16008 -0
- package/dist/index.mjs.map +1 -0
- package/dist/node.d.ts +1 -0
- package/dist/node.js +16030 -0
- package/dist/node.js.map +1 -0
- package/dist/node.mjs +16025 -0
- package/dist/node.mjs.map +1 -0
- package/dist/parse-svg/bridge.d.ts +10 -0
- package/dist/parse-svg/node.d.ts +3 -0
- package/dist/parse-svg/read-presentation-attribute.d.ts +5 -0
- package/dist/parse-svg/svg-parser.d.ts +46 -0
- package/dist/svg-preserved-data.d.ts +78 -0
- package/dist/svg2ge-adapter/assemble.d.ts +5 -0
- package/dist/svg2ge-adapter/convert.d.ts +5 -0
- package/dist/svg2ge-adapter/converter/animation.d.ts +10 -0
- package/dist/svg2ge-adapter/converter/data-path.d.ts +6 -0
- package/dist/svg2ge-adapter/normalize-shape-animation.d.ts +2 -0
- package/dist/svg2ge-adapter/post-process/apply-fonts.d.ts +6 -0
- package/dist/svg2ge-adapter/post-process/apply-shape-geometry-animation.d.ts +4 -0
- package/dist/svg2ge-adapter/post-process/apply-shape-paint-animation.d.ts +4 -0
- package/dist/svg2ge-adapter/post-process/paint-animation-sampling.d.ts +13 -0
- package/dist/svg2ge-adapter/post-process/restore-gradient-uv.d.ts +3 -0
- package/dist/svg2ge-adapter/post-process/rewrite-text-components.d.ts +13 -0
- package/dist/svg2ge-adapter/pre-process.d.ts +7 -0
- package/dist/svg2ge-adapter/types.d.ts +11 -0
- package/dist/svg2ir/assemble.d.ts +9 -0
- package/dist/svg2ir/convert-arc.d.ts +10 -0
- package/dist/svg2ir/convert.d.ts +21 -0
- package/dist/svg2ir/converter/clip/apply-mask.d.ts +4 -0
- package/dist/svg2ir/converter/clip/build-clip-mask.d.ts +35 -0
- package/dist/svg2ir/converter/clip/collect-geometry.d.ts +32 -0
- package/dist/svg2ir/converter/clip/warn-unsupported.d.ts +7 -0
- package/dist/svg2ir/converter/diagnostics/collect-warnings.d.ts +6 -0
- package/dist/svg2ir/converter/diagnostics/inspect-filter.d.ts +4 -0
- package/dist/svg2ir/converter/diagnostics/warn-unsupported.d.ts +8 -0
- package/dist/svg2ir/converter/image/parse-image.d.ts +14 -0
- package/dist/svg2ir/converter/layers/build-layers.d.ts +8 -0
- package/dist/svg2ir/converter/layers/conversion-session.d.ts +161 -0
- package/dist/svg2ir/converter/layers/convert-group-element.d.ts +3 -0
- package/dist/svg2ir/converter/layers/convert-image-element.d.ts +3 -0
- package/dist/svg2ir/converter/layers/convert-shape-element.d.ts +3 -0
- package/dist/svg2ir/converter/layers/convert-text-element.d.ts +3 -0
- package/dist/svg2ir/converter/layers/convert-use-element.d.ts +3 -0
- package/dist/svg2ir/converter/layers/element-categories.d.ts +2 -0
- package/dist/svg2ir/converter/layers/registry.d.ts +4 -0
- package/dist/svg2ir/converter/paint/resolve-gradient.d.ts +29 -0
- package/dist/svg2ir/converter/shape/convert-annulus.d.ts +10 -0
- package/dist/svg2ir/converter/shape/parse-dash.d.ts +23 -0
- package/dist/svg2ir/converter/shape/parse-shape-element.d.ts +4 -0
- package/dist/svg2ir/converter/shape/parse-shape-primitives.d.ts +15 -0
- package/dist/svg2ir/converter/smil/apply-opacity-composition.d.ts +6 -0
- package/dist/svg2ir/converter/smil/apply-transform-animation.d.ts +14 -0
- package/dist/svg2ir/converter/smil/apply-transform-composition.d.ts +4 -0
- package/dist/svg2ir/converter/smil/build-keyframes.d.ts +10 -0
- package/dist/svg2ir/converter/smil/collect-geometry-animation.d.ts +7 -0
- package/dist/svg2ir/converter/smil/inspect-animation.d.ts +6 -0
- package/dist/svg2ir/converter/smil/parse-motion.d.ts +4 -0
- package/dist/svg2ir/converter/smil/parse-paint-animation.d.ts +13 -0
- package/dist/svg2ir/converter/smil/parse-shape-animation.d.ts +4 -0
- package/dist/svg2ir/converter/smil/parse-timeline.d.ts +4 -0
- package/dist/svg2ir/converter/smil/resolve-animation-target.d.ts +4 -0
- package/dist/svg2ir/converter/smil/sample-composition-frames.d.ts +42 -0
- package/dist/svg2ir/converter/smil/scan-duration.d.ts +4 -0
- package/dist/svg2ir/converter/smil/timeline-schedule.d.ts +17 -0
- package/dist/svg2ir/converter/smil/timeline-values.d.ts +20 -0
- package/dist/svg2ir/converter/smil/types.d.ts +129 -0
- package/dist/svg2ir/converter/switch-branch.d.ts +3 -0
- package/dist/svg2ir/converter/text/build-per-line-text-layers.d.ts +11 -0
- package/dist/svg2ir/converter/text/build-single-text-layer.d.ts +11 -0
- package/dist/svg2ir/converter/text/build-split-text-layers.d.ts +11 -0
- package/dist/svg2ir/converter/text/build-vertical-text-layers.d.ts +10 -0
- package/dist/svg2ir/converter/text/font-metrics.d.ts +53 -0
- package/dist/svg2ir/converter/text/inspect-content.d.ts +42 -0
- package/dist/svg2ir/converter/text/parse.d.ts +10 -0
- package/dist/svg2ir/converter/text/text-layout.d.ts +29 -0
- package/dist/svg2ir/converter/transform/build-transform.d.ts +15 -0
- package/dist/svg2ir/converter/use/collect-group-use-instances.d.ts +16 -0
- package/dist/svg2ir/converter/use/expand-use.d.ts +31 -0
- package/dist/svg2ir/css-named-colors.d.ts +1 -0
- package/dist/svg2ir/index.d.ts +2 -0
- package/dist/svg2ir/map-color.d.ts +3 -0
- package/dist/svg2ir/matrix.d.ts +67 -0
- package/dist/svg2ir/normalize-path.d.ts +52 -0
- package/dist/svg2ir/read-attributes.d.ts +12 -0
- package/dist/svg2layers-adapter/assemble.d.ts +8 -0
- package/dist/svg2layers-adapter/convert.d.ts +4 -0
- package/dist/svg2layers-adapter/converter/diagnostics/collect-warnings.d.ts +10 -0
- package/dist/svg2layers-adapter/converter/image/convert-image-layer.d.ts +5 -0
- package/dist/svg2layers-adapter/converter/layers/build-layers.d.ts +3 -0
- package/dist/svg2layers-adapter/converter/layers/conversion-session.d.ts +14 -0
- package/dist/svg2layers-adapter/converter/layers/registry.d.ts +9 -0
- package/dist/svg2layers-adapter/converter/layers/resolve-visual-state.d.ts +4 -0
- package/dist/svg2layers-adapter/converter/text/convert-text-layer.d.ts +5 -0
- package/dist/svg2layers-adapter/converter/text/parse-text-runs.d.ts +11 -0
- package/dist/svg2layers-adapter/converter/text/text-layout.d.ts +9 -0
- package/dist/svg2layers-adapter/converter/transform/build-transform.d.ts +8 -0
- package/dist/svg2layers-adapter/matrix.d.ts +16 -0
- package/dist/svg2layers-adapter/post-process/inline-image-resources.d.ts +3 -0
- package/dist/svg2layers-adapter/types.d.ts +61 -0
- package/package.json +61 -3
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type EditableSVG from './svg-parser';
|
|
2
|
+
export type EditableSVGConstructor = typeof EditableSVG;
|
|
3
|
+
/**
|
|
4
|
+
* 将浏览器 ESM/CJS 互操作和 Node CJS 入口统一为同一个构造器。
|
|
5
|
+
* parser 只依赖这个边界,不依赖具体模块系统的默认导出形式。
|
|
6
|
+
*/
|
|
7
|
+
export declare function resolveEditableSVGConstructor(moduleValue: unknown): EditableSVGConstructor;
|
|
8
|
+
/** 配置 Node 发行入口使用的构造器。 */
|
|
9
|
+
export declare function setEditableSVGConstructor(constructor: EditableSVGConstructor): void;
|
|
10
|
+
export declare function createEditableSVG(...args: ConstructorParameters<EditableSVGConstructor>): EditableSVG;
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
/** 读取 SVG presentation attribute,inline style 的同名属性优先。 */
|
|
2
|
+
export declare function readPresentationAttribute(node: {
|
|
3
|
+
getAttribute?: (name: string) => string | null;
|
|
4
|
+
} | null | undefined, attributeName: string): string | null;
|
|
5
|
+
export declare function readInlineStyleProperty(style: string | null, propertyName: string): string | null;
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 只读 SVG 解析器。svg2ir 用它把 SVG 字符串解析成可查询/可读属性的 svg.js 文档树,
|
|
3
|
+
* 再在其上做 SVG→IR 转换;不涉及任何 SVG 编辑/约束/布局能力。
|
|
4
|
+
*
|
|
5
|
+
* 提供的能力(对齐 svg2ir 实际消费的读切片):
|
|
6
|
+
* - 构造:SVG 字符串 → svg.js 文档树;对每个 <text> 规整 dx/dy→x/y、补 fill 兜底
|
|
7
|
+
* - getAttr:带 SVG 继承的属性读取(沿父 <g> 上溯,id/svg 根终止,font-size 数值化)
|
|
8
|
+
* - stringify:序列化回 SVG 字符串(清临时属性 + 去 svg.js 内部标记)
|
|
9
|
+
* - find/findOne/attr/node:透出 svg.js 原生查询与根节点
|
|
10
|
+
*
|
|
11
|
+
* 底层复用 @svgdotjs/svg.js。本模块只封装 svg2ir 依赖的读语义,不含处理容错的全部角落。
|
|
12
|
+
*/
|
|
13
|
+
import { type Svg as SVGDocument, type Element as SVGElementNode } from '@svgdotjs/svg.js';
|
|
14
|
+
export type { Svg as SVGDocument, Element as SVGElementNode } from '@svgdotjs/svg.js';
|
|
15
|
+
interface ParseableSVGOptions {
|
|
16
|
+
/** SVG 解析器构造选项。 */
|
|
17
|
+
[key: string]: unknown;
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* 只读 SVG 解析器。读切片语义:
|
|
21
|
+
* - 构造时对每个 <text> 规整:text 级 dx/dy 烘焙进 x/y(清掉 dx/dy);无 fill 时沿父继承/从首个 tspan 提/兜底 #000。
|
|
22
|
+
* - getAttr 沿父链继承上溯(SVG CSS 式),id 与已到 svg 根终止,font-size 含 px 时数值化。
|
|
23
|
+
* - stringify 用 svg.js 序列化,清临时属性 + 去 svgjs:data。
|
|
24
|
+
*/
|
|
25
|
+
export default class ParseableSVG {
|
|
26
|
+
readonly svg: SVGDocument;
|
|
27
|
+
constructor(svgStr: string, _options?: ParseableSVGOptions);
|
|
28
|
+
/**
|
|
29
|
+
* 读属性,带 SVG 继承。元素自身无值时沿 parent() 上溯;id 与已到 svg 根终止返回 null;
|
|
30
|
+
* font-size 含 px 时数值化为 number。propagation=false 时不上溯。
|
|
31
|
+
*/
|
|
32
|
+
getAttr(element: SVGElementNode, attributeName: string, propagation?: boolean): string | number | null;
|
|
33
|
+
/**
|
|
34
|
+
* 构造时对每个 <text> 规整属性。
|
|
35
|
+
* - text 级 dx/dy 烘焙进 x/y,并移除 dx/dy
|
|
36
|
+
* - text 自身无 fill 时沿父继承/从首个 tspan 提/兜底 #000
|
|
37
|
+
* svg2ir 解析依赖这段规整,故无条件执行。
|
|
38
|
+
*/
|
|
39
|
+
private initTexts;
|
|
40
|
+
/** 读数值属性(string 去 px 转 number,非数/空返 0)。 */
|
|
41
|
+
private getNumAttr;
|
|
42
|
+
/** 序列化回 SVG 字符串:清 data-tmp- 临时属性 + 去 svg.js 内部 svgjs:data 标记。 */
|
|
43
|
+
stringify(): string;
|
|
44
|
+
}
|
|
45
|
+
/** SVG parser 的包内类型别名,运行时与类型均指向 ParseableSVG。 */
|
|
46
|
+
export { ParseableSVG as EditableSVG };
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
import type { IRAnimatedProperty, IRBezierPath, IRColor, IRVec3 } from '@vvfx/animation-ir';
|
|
2
|
+
/** SVG 富文本单个片段的保留数据。 */
|
|
3
|
+
export interface SVGPreservedTextSpan {
|
|
4
|
+
text: string;
|
|
5
|
+
fontSize?: string;
|
|
6
|
+
color?: string;
|
|
7
|
+
bold?: boolean;
|
|
8
|
+
italic?: boolean;
|
|
9
|
+
newLine: boolean;
|
|
10
|
+
dx?: number;
|
|
11
|
+
dxRaw?: string;
|
|
12
|
+
dy?: number;
|
|
13
|
+
dyRaw?: string;
|
|
14
|
+
}
|
|
15
|
+
/** SVG 文本层在核心 IR 之外保留的富文本数据。 */
|
|
16
|
+
export interface SVGPreservedTextData {
|
|
17
|
+
spans: SVGPreservedTextSpan[];
|
|
18
|
+
fontFamily: string;
|
|
19
|
+
fontWeight: number;
|
|
20
|
+
fontStyle: 'normal' | 'italic' | 'oblique';
|
|
21
|
+
isPathText: boolean;
|
|
22
|
+
deltaWyForRich?: number;
|
|
23
|
+
}
|
|
24
|
+
/** SVG paint 动画在核心 IR 之外保留的数据。 */
|
|
25
|
+
export type SVGPreservedPaintAnimation = {
|
|
26
|
+
kind: 'context';
|
|
27
|
+
staticElementOpacity: number;
|
|
28
|
+
layerOpacityMultiplier: number;
|
|
29
|
+
paintOpacity: {
|
|
30
|
+
fill: number;
|
|
31
|
+
stroke: number;
|
|
32
|
+
};
|
|
33
|
+
solidColorAlpha: {
|
|
34
|
+
fill: number;
|
|
35
|
+
stroke: number;
|
|
36
|
+
};
|
|
37
|
+
gradientStopColorAlpha: {
|
|
38
|
+
fill: number[];
|
|
39
|
+
stroke: number[];
|
|
40
|
+
};
|
|
41
|
+
geometryScale?: IRAnimatedProperty<IRVec3>;
|
|
42
|
+
} | {
|
|
43
|
+
kind: 'opacity';
|
|
44
|
+
target: 'fill' | 'stroke';
|
|
45
|
+
opacity: IRAnimatedProperty<number>;
|
|
46
|
+
alphaBase: number;
|
|
47
|
+
} | {
|
|
48
|
+
kind: 'solid-color';
|
|
49
|
+
target: 'fill' | 'stroke';
|
|
50
|
+
color: IRAnimatedProperty<IRColor>;
|
|
51
|
+
} | {
|
|
52
|
+
kind: 'gradient-stop-color';
|
|
53
|
+
target: 'fill' | 'stroke';
|
|
54
|
+
paintIndex: number;
|
|
55
|
+
stopIndex: number;
|
|
56
|
+
color: IRAnimatedProperty<IRColor>;
|
|
57
|
+
} | {
|
|
58
|
+
kind: 'stroke-width';
|
|
59
|
+
width: IRAnimatedProperty<number>;
|
|
60
|
+
};
|
|
61
|
+
/** SVG 形状路径的动画时间线。 */
|
|
62
|
+
export interface SVGPreservedShapeAnimation {
|
|
63
|
+
keyframes: Array<{
|
|
64
|
+
time: number;
|
|
65
|
+
paths: IRBezierPath[];
|
|
66
|
+
}>;
|
|
67
|
+
}
|
|
68
|
+
/** GE Runtime 可加载的 SVG 字体定义。 */
|
|
69
|
+
export interface SVGFontDefinition {
|
|
70
|
+
fontFamily: string;
|
|
71
|
+
fontURL: string;
|
|
72
|
+
}
|
|
73
|
+
/** SVG parser 输出、GE 和静态分层适配阶段消费的旁路数据。 */
|
|
74
|
+
export interface SVGPreservedData {
|
|
75
|
+
textDataByLayerId: Map<string, SVGPreservedTextData>;
|
|
76
|
+
paintAnimationsByLayerId: Map<string, SVGPreservedPaintAnimation[]>;
|
|
77
|
+
shapeAnimationsByLayerId?: Map<string, SVGPreservedShapeAnimation>;
|
|
78
|
+
}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { type ConvertResult } from '../common/types';
|
|
2
|
+
import type { SVGPreservedData } from '../svg-preserved-data';
|
|
3
|
+
import type { SVGToGEOptions, SVGToGEResult } from './types';
|
|
4
|
+
/** 从已解析的 IR 和 SVG 保留数据生成 GE 场景。 */
|
|
5
|
+
export declare function assembleSVGGE(parsed: ConvertResult, options?: SVGToGEOptions, preservedData?: SVGPreservedData): SVGToGEResult;
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { SVGSource } from '../common/types';
|
|
2
|
+
import type { SVGPreservedData } from '../svg-preserved-data';
|
|
3
|
+
import type { SVGToGEOptions, SVGToGEResult } from './types';
|
|
4
|
+
/** SVG→GE 显式入口。传入 preservedData 时应用 SVG 专属后处理。 */
|
|
5
|
+
export declare function convertSVGToGE(source: SVGSource, options?: SVGToGEOptions, preservedData?: SVGPreservedData): SVGToGEResult;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/** 将 IR 动画关键帧编码为 Effects Bezier 曲线。 */
|
|
2
|
+
import type { IRAnimatedProperty } from '@vvfx/animation-ir';
|
|
3
|
+
import { type BezierKeyframeValue } from '@galacean/effects-specification';
|
|
4
|
+
/** 与 ge-ir IRToGETimeContext 同构的图层可见帧区间。 */
|
|
5
|
+
export interface IRToGETimeContext {
|
|
6
|
+
startFrame: number;
|
|
7
|
+
endFrame: number;
|
|
8
|
+
}
|
|
9
|
+
/** 把 1D 动画属性编码为 Effects BezierKeyframeValue 曲线(单维外层数组)。 */
|
|
10
|
+
export declare function convertIRScalarKeyframesToGE(property: IRAnimatedProperty<number>, timeContext: IRToGETimeContext): BezierKeyframeValue[][] | undefined;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
/** SVG 专属 Effects 转换使用的 DataPath 和实体 ID 辅助。 */
|
|
2
|
+
import type { DataPath } from '@galacean/effects-specification';
|
|
3
|
+
/** 生成 32 位十六进制 Effects 实体 ID(与 ge-ir createId 同构)。 */
|
|
4
|
+
export declare function createId(): string;
|
|
5
|
+
/** 把 ID 包装成 Effects DataPath 引用。 */
|
|
6
|
+
export declare function toDataPath(id: string): DataPath;
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { IRScene } from '@vvfx/animation-ir';
|
|
2
|
+
import { type JSONScene } from '@galacean/effects-specification';
|
|
3
|
+
import type { SVGPreservedShapeAnimation } from '../../svg-preserved-data';
|
|
4
|
+
export declare function applyShapeGeometryAnimations(scene: JSONScene, ir: IRScene, animationsByLayerId: ReadonlyMap<string, SVGPreservedShapeAnimation> | undefined): void;
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { IRScene } from '@vvfx/animation-ir';
|
|
2
|
+
import { type JSONScene } from '@galacean/effects-specification';
|
|
3
|
+
import type { SVGPreservedPaintAnimation } from '../../svg-preserved-data';
|
|
4
|
+
export declare function applyShapePaintAnimation(scene: JSONScene, ir: IRScene, paintAnimationByLayerIndex: ReadonlyMap<string, readonly SVGPreservedPaintAnimation[]>): void;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* SVG paint animation 的时间采样逻辑。
|
|
3
|
+
*
|
|
4
|
+
* 该模块只根据 IR animated property 计算指定帧的值,不直接修改 Effects scene。
|
|
5
|
+
*/
|
|
6
|
+
import type { IRAnimatedProperty, IRColor, IRVec3 } from '@vvfx/animation-ir';
|
|
7
|
+
export declare function sampleScalarProperty(property: IRAnimatedProperty<number>, frame: number): number;
|
|
8
|
+
export declare function sampleVectorProperty(property: Extract<IRAnimatedProperty<IRVec3>, {
|
|
9
|
+
type: 'keyframed';
|
|
10
|
+
}>, frame: number): IRVec3;
|
|
11
|
+
export declare function sampleColorProperty(property: Extract<IRAnimatedProperty<IRColor>, {
|
|
12
|
+
type: 'keyframed';
|
|
13
|
+
}>, frame: number): IRColor;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 将 Effects TextComponent 转换为 RichTextComponent,并将逐段样式编码为 markup。
|
|
3
|
+
* 文本尺寸字段和 textPath 标记保留在 Effects 场景中。
|
|
4
|
+
*/
|
|
5
|
+
import { type JSONScene } from '@galacean/effects-specification';
|
|
6
|
+
import type { SVGPreservedTextData } from '../../svg-preserved-data';
|
|
7
|
+
interface RewriteTextComponentsToRichTextInput {
|
|
8
|
+
textDataByLayerId: ReadonlyMap<string, SVGPreservedTextData>;
|
|
9
|
+
itemLayerIds: Readonly<Record<string, string>>;
|
|
10
|
+
}
|
|
11
|
+
/** 按 IR Layer ID 应用 SVG 富文本保留数据。 */
|
|
12
|
+
export declare function rewriteTextComponentsToRichText(scene: JSONScene, input: RewriteTextComponentsToRichTextInput): void;
|
|
13
|
+
export {};
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { IRScene } from '@vvfx/animation-ir';
|
|
2
|
+
import type { SVGPreservedPaintAnimation, SVGPreservedShapeAnimation } from '../svg-preserved-data';
|
|
3
|
+
export declare function applyShapeAnimationBasePaths(ir: IRScene, animationsByLayerId: ReadonlyMap<string, SVGPreservedShapeAnimation> | undefined): void;
|
|
4
|
+
/** convertIRToGE 用 IR 副本展开 hold 过渡点,result.ir 仍保留解析原始关键帧。 */
|
|
5
|
+
export declare function expandIRHoldTransitions(ir: IRScene): IRScene;
|
|
6
|
+
/** applyShapePaintAnimation 消费的 paint 动画属性同样展开 hold 过渡点(内部 sink,不外露)。 */
|
|
7
|
+
export declare function expandPaintAnimationHoldKeyframes(map: Map<string, SVGPreservedPaintAnimation[]>): void;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { JSONScene } from '@galacean/effects-specification';
|
|
2
|
+
import type { ConvertOptions, SVG2IRWarning } from '../common/types';
|
|
3
|
+
import type { SVGFontDefinition } from '../svg-preserved-data';
|
|
4
|
+
export interface SVGToGEOptions extends ConvertOptions {
|
|
5
|
+
fonts?: readonly SVGFontDefinition[];
|
|
6
|
+
}
|
|
7
|
+
export interface SVGToGEResult {
|
|
8
|
+
/** 由 convertIRToGE 生成并可选经过 SVG 专属适配的 Effects JSONScene。 */
|
|
9
|
+
data: JSONScene;
|
|
10
|
+
warnings: SVG2IRWarning[];
|
|
11
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { type IRScene } from '@vvfx/animation-ir';
|
|
2
|
+
import type { ConvertOptions } from '../common/types';
|
|
3
|
+
import type { SVGPreservedPaintAnimation, SVGPreservedShapeAnimation, SVGPreservedTextData } from '../svg-preserved-data';
|
|
4
|
+
export interface ParseSVGToIROptions extends ConvertOptions {
|
|
5
|
+
textDataCollector?: Map<string, SVGPreservedTextData>;
|
|
6
|
+
paintAnimationsCollector?: Map<string, SVGPreservedPaintAnimation[]>;
|
|
7
|
+
shapeAnimationCollector?: Map<string, SVGPreservedShapeAnimation>;
|
|
8
|
+
}
|
|
9
|
+
export declare function parseSVGToIRScene(svgString: string, options?: ParseSVGToIROptions): IRScene;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* SVG 圆弧到三次 Bezier 的转换。
|
|
3
|
+
*
|
|
4
|
+
* path 命令归一化只消费 `arcToCubics`,具体圆弧几何和细分规则集中在这里。
|
|
5
|
+
*/
|
|
6
|
+
/** 椭圆弧(轴对齐,xAxisRotation=0)→多段三次贝塞尔。
|
|
7
|
+
* 已正确支持 rx==ry 的圆角矩形/圆形弧(largeArc/sweep 语义完整);
|
|
8
|
+
* 当前无法稳定映射的椭圆弧会退化为直线。
|
|
9
|
+
*/
|
|
10
|
+
export declare function arcToCubics(x0: number, y0: number, rx: number, ry: number, x1: number, y1: number, largeArc: boolean, sweep: boolean, arcSegmentAngle?: number): number[][];
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import type { ConvertOptions, ConvertResult, SVGSource } from '../common/types';
|
|
2
|
+
import type { SVGPreservedData, SVGPreservedPaintAnimation, SVGPreservedShapeAnimation, SVGPreservedTextData } from '../svg-preserved-data';
|
|
3
|
+
interface SVGPreservedDataCollectors {
|
|
4
|
+
textDataByLayerId: Map<string, SVGPreservedTextData>;
|
|
5
|
+
paintAnimationsByLayerId: Map<string, SVGPreservedPaintAnimation[]>;
|
|
6
|
+
shapeAnimationsByLayerId: Map<string, SVGPreservedShapeAnimation>;
|
|
7
|
+
}
|
|
8
|
+
/**
|
|
9
|
+
* 把 SVG 转为 Animation IR。Effects lowering 由 `convertSVGToGE` 负责。
|
|
10
|
+
*
|
|
11
|
+
* 该函数是 SVG→IR 的底层入口,供 Effects 转换器和 IR 测试复用。
|
|
12
|
+
*/
|
|
13
|
+
export declare function convertSVGToIR(source: SVGSource, options?: ConvertOptions): ConvertResult;
|
|
14
|
+
export type SplitSVGOptions = ConvertOptions;
|
|
15
|
+
export interface SplitSVGResult extends ConvertResult {
|
|
16
|
+
preservedData: SVGPreservedData;
|
|
17
|
+
}
|
|
18
|
+
/** Convert SVG to IR and retain the GE-side data needed for source-specific lowering. */
|
|
19
|
+
export declare function splitSVG(source: SVGSource, options?: SplitSVGOptions): SplitSVGResult;
|
|
20
|
+
export declare function parseSVGToIRWithPreservedData(source: SVGSource, options?: ConvertOptions, collectors?: SVGPreservedDataCollectors): ConvertResult;
|
|
21
|
+
export {};
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type EditableSVG from '../../../parse-svg/svg-parser';
|
|
2
|
+
import type { Element } from '@svgdotjs/svg.js';
|
|
3
|
+
import type { IRLayer, IRMask } from '@vvfx/animation-ir';
|
|
4
|
+
export declare function applyClipMask<T extends IRLayer>(es: EditableSVG, el: Element, layer: T, clipMasks: Map<string, IRMask>): T;
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* SVG <clipPath> → IRMask(挂到被裁图层的 mask 字段)。
|
|
3
|
+
*
|
|
4
|
+
* IR 只负责把 mask 几何挂到被裁图层;IR→Effects 的结构组装由 `@vvfx/ge-ir` 负责。
|
|
5
|
+
*
|
|
6
|
+
* 收集 clipPath 内所有形状几何,合并成一个 IRBezierPath(多 subpath 并集语义)的 points/handles。
|
|
7
|
+
* clipPath 内 path/polygon/polyline/rect 可直接收集,circle/ellipse 使用 cubic 圆弧;
|
|
8
|
+
* clip-rule even-odd/nonzero 不处理;IR mask 使用默认规则。
|
|
9
|
+
*
|
|
10
|
+
* 被裁元素通过 clip-path="url(#id)" 引用,svg2ir 扫描时把对应 IRMask 挂到该元素图层。
|
|
11
|
+
*/
|
|
12
|
+
import type EditableSVG from '../../../parse-svg/svg-parser';
|
|
13
|
+
import type { Element as SVGElementNode } from '@svgdotjs/svg.js';
|
|
14
|
+
import type { IRMask } from '@vvfx/animation-ir';
|
|
15
|
+
/**
|
|
16
|
+
* 从 clipPath/mask 元素合并所有子形状几何 → IRMask{path}(当前合并为单点集)。
|
|
17
|
+
*
|
|
18
|
+
* 支持子元素为直接形状(rect/circle/path...)或 `<use href="#shapeId">` 引用声明区形状。
|
|
19
|
+
*
|
|
20
|
+
* **坐标基准(mask 真正的坑)**:SVG mask content 在 `maskContentUnits=userSpaceOnUse`(默认)下,
|
|
21
|
+
* "userSpace" = **mask 元素所在的 userSpace**——即 mask 元素自身 transform + 祖先 `<g>` transform
|
|
22
|
+
* 累乘后的空间。mask 与被裁 `<image>` 可能位于同一个带 transform 的 `<g>` 里,故 content
|
|
23
|
+
* 形状的 (0,0) 是 g 局部原点,需要累计 g 的 transform 才能得到 SVG 绝对坐标。clipPath 通常位于
|
|
24
|
+
* defs 中并直接使用文档坐标,因此保持局部坐标;mask 则累计其宿主变换后再与被裁图层对齐。
|
|
25
|
+
*/
|
|
26
|
+
export declare function buildClipMask(es: EditableSVG, clipPathEl: SVGElementNode, rootEl?: SVGElementNode, applyAncestorTransform?: boolean, applyShapeOwnTransform?: boolean): IRMask | null;
|
|
27
|
+
/**
|
|
28
|
+
* 构建 `<g mask="url(#X)">` 的组级 mask。
|
|
29
|
+
* mask 坐标与子代使用同一 comp-absolute 坐标系;定义几何先在局部收集,
|
|
30
|
+
* 再叠加宿主 g 的祖先变换和自身 transform。解析不到 mask 或没有形状时返回 null。
|
|
31
|
+
*/
|
|
32
|
+
export declare function buildGroupMaskForG(es: EditableSVG, gEl: SVGElementNode, rootEl: SVGElementNode): IRMask | null;
|
|
33
|
+
/** 按 id 查 DOM element。优先全文档 ownerDocument.getElementById(被引用形状常在别处 <defs>,
|
|
34
|
+
* 不在 mask/clipPath 子树内,querySelector 限子树会漏);fallback querySelector 子树 + rootEl 查。 */
|
|
35
|
+
export declare function findById(el: SVGElementNode, id: string): globalThis.Element | null;
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import type { IRBezierPath } from '@vvfx/animation-ir';
|
|
2
|
+
import { type SVGMatrix } from '../../matrix';
|
|
3
|
+
type MaskPoint = {
|
|
4
|
+
x: number;
|
|
5
|
+
y: number;
|
|
6
|
+
};
|
|
7
|
+
export interface MaskGeometry {
|
|
8
|
+
paths: IRBezierPath[];
|
|
9
|
+
}
|
|
10
|
+
/** 把单个 SVG 形状转换为一个或多个独立 mask 轮廓,并保留曲线控制柄。 */
|
|
11
|
+
export declare function collectShapeGeometry(el: {
|
|
12
|
+
node: globalThis.Element;
|
|
13
|
+
}, tag: string, geometry: MaskGeometry, applyShapeOwnTransform?: boolean): void;
|
|
14
|
+
export declare function transformVector(matrix: SVGMatrix, vector: MaskPoint): MaskPoint;
|
|
15
|
+
type MaskPolygon = Array<{
|
|
16
|
+
x: number;
|
|
17
|
+
y: number;
|
|
18
|
+
}>;
|
|
19
|
+
/** 多边形是否为轴对齐矩形(4 个角,边与坐标轴平行)。 */
|
|
20
|
+
export declare function isAxisAlignedRect(pts: MaskPolygon, eps?: number): boolean;
|
|
21
|
+
/** mask pts 的轴对齐 bbox 是否罩住 shapeBbox(每边余 eps)。非轴对齐 mask 不在此判(走 pointInPolygon)。 */
|
|
22
|
+
export declare function rangeCovers(pts: MaskPolygon, bbox: {
|
|
23
|
+
minX: number;
|
|
24
|
+
minY: number;
|
|
25
|
+
maxX: number;
|
|
26
|
+
maxY: number;
|
|
27
|
+
}, eps: number): boolean;
|
|
28
|
+
/** 判断 rebase 后的 mask 尺寸是否明显偏离被裁区域。 */
|
|
29
|
+
export declare function maskSizeAbnormal(pts: MaskPolygon, w: number, h: number): boolean;
|
|
30
|
+
/** 判断 mask 是否完全覆盖被裁区域。矩形使用 bbox,其他形状检查区域四角。 */
|
|
31
|
+
export declare function maskCoversFull(pts: MaskPolygon, w: number, h: number): boolean;
|
|
32
|
+
export {};
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { Element as SVGElementNode } from '@svgdotjs/svg.js';
|
|
2
|
+
import { type SVG2IRWarning } from '../../../common/types';
|
|
3
|
+
/**
|
|
4
|
+
* 报告 IR mask 无法保留的 SVG clip/mask 语义。
|
|
5
|
+
* 几何路径本身仍然支持;warning 用于显式说明坐标或 alpha 语义的降级。
|
|
6
|
+
*/
|
|
7
|
+
export declare function warnUnsupportedClipMaskFeatures(el: SVGElementNode, tag: 'clippath' | 'mask', emit: (warning: SVG2IRWarning) => void, strict: boolean): void;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { SVG2IRWarning, SVG2IRWarningCode } from '../../../common/types';
|
|
2
|
+
export declare function collectWarning(emit: (w: SVG2IRWarning) => void, code: SVG2IRWarningCode, message: string, elementSelector: string | undefined, strict: boolean | undefined): void;
|
|
3
|
+
/** 元素定位提示:tag#id 或 tag:nth。供 warning 的 elementSelector 用。 */
|
|
4
|
+
export declare function describeElement(el: {
|
|
5
|
+
node?: Element | null;
|
|
6
|
+
}): string | undefined;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type EditableSVG from '../../../parse-svg/svg-parser';
|
|
2
|
+
import type { Element } from '@svgdotjs/svg.js';
|
|
3
|
+
import type { SVG2IRWarning, SVG2IRWarningCode } from '../../../common/types';
|
|
4
|
+
/** 检查图层属性并报告无法写入 IR 的 SVG 特性。 */
|
|
5
|
+
export declare function warnUnsupportedAttributes(es: EditableSVG, el: Element, tag: string, emit: (w: SVG2IRWarning) => void, strict: boolean, idEls: ReadonlyMap<string, Element>, flattenGradientToSolid?: boolean, dashSynthesized?: boolean): void;
|
|
6
|
+
export declare function warnGradAttr(es: EditableSVG, gradEl: Element, gradTag: string, attr: string, refTag: string, emit: (w: SVG2IRWarning) => void, strict: boolean, selector: string | undefined): void;
|
|
7
|
+
export declare function warnAttr(es: EditableSVG, el: Element, tag: string, attr: string, noneDefault: string, code: SVG2IRWarningCode, msg: string, emit: (w: SVG2IRWarning) => void, strict: boolean, selector: string | undefined): void;
|
|
8
|
+
export declare function warnTextPaintDropped(es: EditableSVG, el: Element, selector: string | undefined, emit: (w: SVG2IRWarning) => void, strict: boolean): void;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 将 SVG image 元素解析为 IR image layer 和 image asset。
|
|
3
|
+
*/
|
|
4
|
+
import type EditableSVG from '../../../parse-svg/svg-parser';
|
|
5
|
+
import type { Element } from '@svgdotjs/svg.js';
|
|
6
|
+
import { type IRImageAsset, type IRImageLayer } from '@vvfx/animation-ir';
|
|
7
|
+
/** 解析 image 图层和对应资源;图层标识由图层转换器补齐。 */
|
|
8
|
+
export declare function parseImageLayer(es: EditableSVG, el: Element, imageNaturalSizes?: ReadonlyMap<string, {
|
|
9
|
+
width: number;
|
|
10
|
+
height: number;
|
|
11
|
+
}>, resourceBaseUrl?: string): {
|
|
12
|
+
layer: Omit<IRImageLayer, 'id' | 'name' | 'time'>;
|
|
13
|
+
asset: IRImageAsset;
|
|
14
|
+
} | null;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { IRAsset, IRLayer } from '@vvfx/animation-ir';
|
|
2
|
+
import type EditableSVG from '../../../parse-svg/svg-parser';
|
|
3
|
+
import { type SVGLayerBuildOptions } from './conversion-session';
|
|
4
|
+
export type { SVGLayerBuildOptions } from './conversion-session';
|
|
5
|
+
export declare function buildSVGLayers(es: EditableSVG, options: SVGLayerBuildOptions): {
|
|
6
|
+
layers: IRLayer[];
|
|
7
|
+
assets: IRAsset[];
|
|
8
|
+
};
|
|
@@ -0,0 +1,161 @@
|
|
|
1
|
+
import type EditableSVG from '../../../parse-svg/svg-parser';
|
|
2
|
+
import type { Element } from '@svgdotjs/svg.js';
|
|
3
|
+
import type { IRAsset, IRLayer, IRMask, IRShape, IRTextContent } from '@vvfx/animation-ir';
|
|
4
|
+
import type { SVG2IRWarning } from '../../../common/types';
|
|
5
|
+
import type { SVGPreservedPaintAnimation, SVGPreservedShapeAnimation, SVGPreservedTextData } from '../../../svg-preserved-data';
|
|
6
|
+
/** 构造 layer 转换会话所需的输入。 */
|
|
7
|
+
export interface SVGLayerBuildOptions {
|
|
8
|
+
frameRate: number;
|
|
9
|
+
durationSeconds: number;
|
|
10
|
+
emit: (warning: SVG2IRWarning) => void;
|
|
11
|
+
strict: boolean;
|
|
12
|
+
width: number;
|
|
13
|
+
height: number;
|
|
14
|
+
textDataByLayerId?: Map<string, SVGPreservedTextData>;
|
|
15
|
+
measureText?: (fontDesc: string, text: string) => {
|
|
16
|
+
width: number;
|
|
17
|
+
};
|
|
18
|
+
imageNaturalSizes?: Map<string, {
|
|
19
|
+
width: number;
|
|
20
|
+
height: number;
|
|
21
|
+
}>;
|
|
22
|
+
resourceBaseUrl?: string;
|
|
23
|
+
smilDurationSink?: {
|
|
24
|
+
value: number;
|
|
25
|
+
};
|
|
26
|
+
paintAnimationsByLayerId?: Map<string, SVGPreservedPaintAnimation[]>;
|
|
27
|
+
shapeAnimationsByLayerId?: Map<string, SVGPreservedShapeAnimation>;
|
|
28
|
+
}
|
|
29
|
+
/** 各元素转换器共享的只读环境。 */
|
|
30
|
+
export interface SVGConversionEnvironment {
|
|
31
|
+
readonly es: EditableSVG;
|
|
32
|
+
readonly rootEl: Element;
|
|
33
|
+
readonly frameRate: number;
|
|
34
|
+
readonly durationSeconds: number;
|
|
35
|
+
readonly outFrame: number;
|
|
36
|
+
readonly emit: (warning: SVG2IRWarning) => void;
|
|
37
|
+
readonly strict: boolean;
|
|
38
|
+
readonly width: number;
|
|
39
|
+
readonly height: number;
|
|
40
|
+
readonly compCenterX: number;
|
|
41
|
+
readonly compCenterY: number;
|
|
42
|
+
readonly smilDurationSink?: {
|
|
43
|
+
value: number;
|
|
44
|
+
};
|
|
45
|
+
}
|
|
46
|
+
/** SVG 文档索引。 */
|
|
47
|
+
export interface SVGElementLookup {
|
|
48
|
+
readonly idEls: ReadonlyMap<string, Element>;
|
|
49
|
+
readonly idShapes: ReadonlyMap<string, IRShape>;
|
|
50
|
+
readonly idGroups: ReadonlyMap<string, Element>;
|
|
51
|
+
readonly idSymbols: ReadonlyMap<string, Element>;
|
|
52
|
+
readonly idImages: ReadonlyMap<string, Element>;
|
|
53
|
+
readonly symbolShapesById: ReadonlyMap<string, Array<{
|
|
54
|
+
element: Element;
|
|
55
|
+
shape: IRShape;
|
|
56
|
+
}>>;
|
|
57
|
+
readonly idTextEls: ReadonlyMap<string, Element>;
|
|
58
|
+
readonly idTextPureUse: ReadonlySet<string>;
|
|
59
|
+
}
|
|
60
|
+
/** 图层转换器可写入的输出接口。 */
|
|
61
|
+
export interface LayerOutput {
|
|
62
|
+
allocateLayerIndex: () => number;
|
|
63
|
+
peekLayerIndex: () => number;
|
|
64
|
+
appendLayer: (layer: IRLayer, element: Element, applyElementClip?: boolean) => void;
|
|
65
|
+
appendAsset: (asset: IRAsset) => void;
|
|
66
|
+
registerTextFontAsset: (content: IRTextContent, info: SVGPreservedTextData) => void;
|
|
67
|
+
}
|
|
68
|
+
/** 单次 SVG 转换的完整状态。 */
|
|
69
|
+
export interface SVGConversionSession extends SVGConversionEnvironment, SVGElementLookup, LayerOutput {
|
|
70
|
+
readonly all: Element[];
|
|
71
|
+
readonly clipMasks: ReadonlyMap<string, IRMask>;
|
|
72
|
+
readonly groupMaskGNodeToIndex: Map<globalThis.Element, number>;
|
|
73
|
+
readonly layers: IRLayer[];
|
|
74
|
+
readonly assets: IRAsset[];
|
|
75
|
+
readonly textDataByLayerId?: Map<string, SVGPreservedTextData>;
|
|
76
|
+
readonly measureText?: (fontDesc: string, text: string) => {
|
|
77
|
+
width: number;
|
|
78
|
+
};
|
|
79
|
+
readonly imageNaturalSizes?: Map<string, {
|
|
80
|
+
width: number;
|
|
81
|
+
height: number;
|
|
82
|
+
}>;
|
|
83
|
+
readonly resourceBaseUrl?: string;
|
|
84
|
+
readonly paintAnimationsByLayerId?: Map<string, SVGPreservedPaintAnimation[]>;
|
|
85
|
+
readonly shapeAnimationsByLayerId?: Map<string, SVGPreservedShapeAnimation>;
|
|
86
|
+
readonly isDeclarationContext: (element: Element) => boolean;
|
|
87
|
+
readonly nearestMaskedGroupAncestor: (element: Element) => number | undefined;
|
|
88
|
+
readonly withGroupParent: <T extends IRLayer>(layer: T, element: Element) => T;
|
|
89
|
+
readonly warnReferencedClipMaskFeatures: (element: Element) => void;
|
|
90
|
+
}
|
|
91
|
+
/** Shape 元素转换所需的上下文。 */
|
|
92
|
+
export interface ShapeConversionContext extends SVGConversionEnvironment {
|
|
93
|
+
readonly idEls: ReadonlyMap<string, Element>;
|
|
94
|
+
readonly allocateLayerIndex: () => number;
|
|
95
|
+
readonly appendLayer: (layer: IRLayer, element: Element, applyElementClip?: boolean) => void;
|
|
96
|
+
readonly paintAnimationsByLayerId?: Map<string, SVGPreservedPaintAnimation[]>;
|
|
97
|
+
readonly shapeAnimationsByLayerId?: Map<string, SVGPreservedShapeAnimation>;
|
|
98
|
+
}
|
|
99
|
+
/** Text 元素转换所需的上下文。 */
|
|
100
|
+
export interface TextConversionContext extends SVGConversionEnvironment {
|
|
101
|
+
readonly idEls: ReadonlyMap<string, Element>;
|
|
102
|
+
readonly measureText?: (fontDesc: string, text: string) => {
|
|
103
|
+
width: number;
|
|
104
|
+
};
|
|
105
|
+
readonly textDataByLayerId?: Map<string, SVGPreservedTextData>;
|
|
106
|
+
readonly allocateLayerIndex: () => number;
|
|
107
|
+
readonly peekLayerIndex: () => number;
|
|
108
|
+
readonly appendLayer: (layer: IRLayer, element: Element, applyElementClip?: boolean) => void;
|
|
109
|
+
readonly registerTextFontAsset: (content: IRTextContent, info: SVGPreservedTextData) => void;
|
|
110
|
+
}
|
|
111
|
+
/** Image 元素转换所需的上下文。 */
|
|
112
|
+
export interface ImageConversionContext extends SVGConversionEnvironment {
|
|
113
|
+
readonly idEls: ReadonlyMap<string, Element>;
|
|
114
|
+
readonly imageNaturalSizes?: ReadonlyMap<string, {
|
|
115
|
+
width: number;
|
|
116
|
+
height: number;
|
|
117
|
+
}>;
|
|
118
|
+
readonly resourceBaseUrl?: string;
|
|
119
|
+
readonly allocateLayerIndex: () => number;
|
|
120
|
+
readonly appendLayer: (layer: IRLayer, element: Element, applyElementClip?: boolean) => void;
|
|
121
|
+
readonly appendAsset: (asset: IRAsset) => void;
|
|
122
|
+
}
|
|
123
|
+
/** Use / symbol 元素转换所需的上下文。 */
|
|
124
|
+
export interface UseConversionContext extends SVGConversionEnvironment {
|
|
125
|
+
readonly idEls: ReadonlyMap<string, Element>;
|
|
126
|
+
readonly idShapes: ReadonlyMap<string, IRShape>;
|
|
127
|
+
readonly idGroups: ReadonlyMap<string, Element>;
|
|
128
|
+
readonly idSymbols: ReadonlyMap<string, Element>;
|
|
129
|
+
readonly idImages: ReadonlyMap<string, Element>;
|
|
130
|
+
readonly symbolShapesById: ReadonlyMap<string, Array<{
|
|
131
|
+
element: Element;
|
|
132
|
+
shape: IRShape;
|
|
133
|
+
}>>;
|
|
134
|
+
readonly idTextEls: ReadonlyMap<string, Element>;
|
|
135
|
+
readonly idTextPureUse: ReadonlySet<string>;
|
|
136
|
+
readonly allocateLayerIndex: () => number;
|
|
137
|
+
readonly peekLayerIndex: () => number;
|
|
138
|
+
readonly appendLayer: (layer: IRLayer, element: Element, applyElementClip?: boolean) => void;
|
|
139
|
+
readonly registerTextFontAsset: (content: IRTextContent, info: SVGPreservedTextData) => void;
|
|
140
|
+
readonly textDataByLayerId?: Map<string, SVGPreservedTextData>;
|
|
141
|
+
readonly measureText?: (fontDesc: string, text: string) => {
|
|
142
|
+
width: number;
|
|
143
|
+
};
|
|
144
|
+
readonly imageNaturalSizes?: ReadonlyMap<string, {
|
|
145
|
+
width: number;
|
|
146
|
+
height: number;
|
|
147
|
+
}>;
|
|
148
|
+
readonly resourceBaseUrl?: string;
|
|
149
|
+
readonly appendAsset: (asset: IRAsset) => void;
|
|
150
|
+
}
|
|
151
|
+
/** Group 元素转换所需的上下文。 */
|
|
152
|
+
export interface GroupConversionContext extends SVGConversionEnvironment {
|
|
153
|
+
readonly idEls: ReadonlyMap<string, Element>;
|
|
154
|
+
readonly groupMaskGNodeToIndex: Map<globalThis.Element, number>;
|
|
155
|
+
readonly allocateLayerIndex: () => number;
|
|
156
|
+
readonly appendLayer: (layer: IRLayer, element: Element, applyElementClip?: boolean) => void;
|
|
157
|
+
}
|
|
158
|
+
export declare function createSVGConversionSession(es: EditableSVG, options: SVGLayerBuildOptions): SVGConversionSession;
|
|
159
|
+
export declare function createSVGConversionEnvironment(session: SVGConversionSession): SVGConversionEnvironment;
|
|
160
|
+
export declare function createSVGElementLookup(session: SVGConversionSession): SVGElementLookup;
|
|
161
|
+
export declare function createLayerOutput(session: SVGConversionSession): LayerOutput;
|