@yft-design/engine 0.0.3 → 0.0.5
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/dist/core/homography.d.ts +55 -0
- package/dist/core/homography.js +123 -0
- package/dist/core/roundedRect.js +6 -5
- package/dist/core/stroke.js +3 -2
- package/dist/export/svgExport.js +32 -35
- package/dist/index.d.ts +5 -0
- package/dist/index.js +8 -0
- package/dist/interact/pathSession.js +5 -5
- package/dist/interact/pointerTransform.js +3 -2
- package/dist/interact/snapGuide.js +2 -1
- package/dist/model/alphaHit.js +2 -1
- package/dist/model/arcLayout.js +4 -3
- package/dist/model/compatObject.d.ts +1 -1
- package/dist/model/compatObject.js +7 -6
- package/dist/model/elementTypes.d.ts +99 -0
- package/dist/model/elementTypes.js +119 -0
- package/dist/model/groupResize.js +2 -1
- package/dist/model/scene.d.ts +13 -24
- package/dist/model/scene.js +52 -61
- package/dist/model/smartObjectBake.d.ts +31 -0
- package/dist/model/smartObjectBake.js +295 -0
- package/dist/render/psdEffectPainter.js +2 -1
- package/dist/render/selectionOverlay.js +14 -7
- package/dist/render/shadowBake.js +2 -1
- package/package.json +1 -1
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 单应性(透视变换)数学——智能对象置入层 quad 专用(批次 363 自主仓
|
|
3
|
+
* extension/object/FabricSmartObject.ts 迁居,逐式 verbatim)。
|
|
4
|
+
*
|
|
5
|
+
* PSD placed layer 的 smartObject 元数据携带 8 元组 quad(nonAffineTransform
|
|
6
|
+
* 优先、transform 兜底),描述子文档在父文档中的四角投射——超出仿射的透视
|
|
7
|
+
* 形变是渲染域词汇:后续 PS 智能对象新形态(变形/网格变换,warpvas 同族)
|
|
8
|
+
* 与 GPU 原生透视渲染(render/,免预光栅的非破坏性编辑)均复用本模块。
|
|
9
|
+
* 纯函数无 DOM,jsdom 可测。
|
|
10
|
+
*/
|
|
11
|
+
/** 平面点(PSD 父文档绝对坐标系或 quad 局部系) */
|
|
12
|
+
export interface SmartObjectPoint {
|
|
13
|
+
x: number;
|
|
14
|
+
y: number;
|
|
15
|
+
}
|
|
16
|
+
/** 置入层四角 quad:tl/tr/br/bl(PSD transform 8 元组按序展开) */
|
|
17
|
+
export interface SmartObjectQuad {
|
|
18
|
+
tl: SmartObjectPoint;
|
|
19
|
+
tr: SmartObjectPoint;
|
|
20
|
+
br: SmartObjectPoint;
|
|
21
|
+
bl: SmartObjectPoint;
|
|
22
|
+
}
|
|
23
|
+
/** 单位正方形 → quad 的单应矩阵(齐次坐标:分母 g·x + h·y + 1) */
|
|
24
|
+
export interface Homography {
|
|
25
|
+
a: number;
|
|
26
|
+
b: number;
|
|
27
|
+
c: number;
|
|
28
|
+
d: number;
|
|
29
|
+
e: number;
|
|
30
|
+
f: number;
|
|
31
|
+
g: number;
|
|
32
|
+
h: number;
|
|
33
|
+
}
|
|
34
|
+
/** PSD 置入层 transform/nonAffineTransform 8 元组 → quad;长度不足或含非有限数判无效(producer 脏数据不进渲染) */
|
|
35
|
+
export declare const getSmartObjectTransformQuad: (transform?: number[]) => SmartObjectQuad | undefined;
|
|
36
|
+
/** quad 的轴对齐外接框(尺寸向上取整,退化零轴钳到 1——光栅画布最小尺寸) */
|
|
37
|
+
export declare const getQuadBounds: (quad: SmartObjectQuad) => {
|
|
38
|
+
minX: number;
|
|
39
|
+
minY: number;
|
|
40
|
+
width: number;
|
|
41
|
+
height: number;
|
|
42
|
+
};
|
|
43
|
+
/** quad 整体平移(投射到 quadBounds 局部系时取负偏移) */
|
|
44
|
+
export declare const offsetQuad: (quad: SmartObjectQuad, offsetX: number, offsetY: number) => SmartObjectQuad;
|
|
45
|
+
/** quad 是否退化成仿射(br ≈ tr + bl − tl,容差 0.01)——仿射走 setTransform 直绘,透视走逐像素反投射 */
|
|
46
|
+
export declare const isAffineQuad: (quad: SmartObjectQuad) => boolean;
|
|
47
|
+
/** 单位正方形 → quad 的单应求解(仿射特例 g=h=0 短路;奇异分母判无效) */
|
|
48
|
+
export declare const getSquareToQuadHomography: (quad: SmartObjectQuad) => Homography | undefined;
|
|
49
|
+
/** 单应正向投射:源平面 (x, y) → 目标平面点(x/y 通常取归一化 [0,1]) */
|
|
50
|
+
export declare const projectPoint: (homography: Homography, x: number, y: number) => {
|
|
51
|
+
x: number;
|
|
52
|
+
y: number;
|
|
53
|
+
};
|
|
54
|
+
/** 单应求逆(行列式/齐次分量退化判无效)——透视光栅逐像素反投射用 */
|
|
55
|
+
export declare const invertHomography: (homography: Homography) => Homography | undefined;
|
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 单应性(透视变换)数学——智能对象置入层 quad 专用(批次 363 自主仓
|
|
3
|
+
* extension/object/FabricSmartObject.ts 迁居,逐式 verbatim)。
|
|
4
|
+
*
|
|
5
|
+
* PSD placed layer 的 smartObject 元数据携带 8 元组 quad(nonAffineTransform
|
|
6
|
+
* 优先、transform 兜底),描述子文档在父文档中的四角投射——超出仿射的透视
|
|
7
|
+
* 形变是渲染域词汇:后续 PS 智能对象新形态(变形/网格变换,warpvas 同族)
|
|
8
|
+
* 与 GPU 原生透视渲染(render/,免预光栅的非破坏性编辑)均复用本模块。
|
|
9
|
+
* 纯函数无 DOM,jsdom 可测。
|
|
10
|
+
*/
|
|
11
|
+
const EPSILON = 0.000001;
|
|
12
|
+
/** PSD 置入层 transform/nonAffineTransform 8 元组 → quad;长度不足或含非有限数判无效(producer 脏数据不进渲染) */
|
|
13
|
+
export const getSmartObjectTransformQuad = (transform) => {
|
|
14
|
+
if (!transform || transform.length < 8 || transform.some((item) => typeof item !== 'number' || !Number.isFinite(item)))
|
|
15
|
+
return undefined;
|
|
16
|
+
return {
|
|
17
|
+
tl: { x: transform[0], y: transform[1] },
|
|
18
|
+
tr: { x: transform[2], y: transform[3] },
|
|
19
|
+
br: { x: transform[4], y: transform[5] },
|
|
20
|
+
bl: { x: transform[6], y: transform[7] }
|
|
21
|
+
};
|
|
22
|
+
};
|
|
23
|
+
/** quad 的轴对齐外接框(尺寸向上取整,退化零轴钳到 1——光栅画布最小尺寸) */
|
|
24
|
+
export const getQuadBounds = (quad) => {
|
|
25
|
+
const points = [quad.tl, quad.tr, quad.br, quad.bl];
|
|
26
|
+
const minX = Math.min(...points.map((point) => point.x));
|
|
27
|
+
const minY = Math.min(...points.map((point) => point.y));
|
|
28
|
+
const maxX = Math.max(...points.map((point) => point.x));
|
|
29
|
+
const maxY = Math.max(...points.map((point) => point.y));
|
|
30
|
+
return {
|
|
31
|
+
minX,
|
|
32
|
+
minY,
|
|
33
|
+
width: Math.max(1, Math.ceil(maxX - minX)),
|
|
34
|
+
height: Math.max(1, Math.ceil(maxY - minY))
|
|
35
|
+
};
|
|
36
|
+
};
|
|
37
|
+
/** quad 整体平移(投射到 quadBounds 局部系时取负偏移) */
|
|
38
|
+
export const offsetQuad = (quad, offsetX, offsetY) => {
|
|
39
|
+
return {
|
|
40
|
+
tl: { x: quad.tl.x + offsetX, y: quad.tl.y + offsetY },
|
|
41
|
+
tr: { x: quad.tr.x + offsetX, y: quad.tr.y + offsetY },
|
|
42
|
+
br: { x: quad.br.x + offsetX, y: quad.br.y + offsetY },
|
|
43
|
+
bl: { x: quad.bl.x + offsetX, y: quad.bl.y + offsetY }
|
|
44
|
+
};
|
|
45
|
+
};
|
|
46
|
+
/** quad 是否退化成仿射(br ≈ tr + bl − tl,容差 0.01)——仿射走 setTransform 直绘,透视走逐像素反投射 */
|
|
47
|
+
export const isAffineQuad = (quad) => {
|
|
48
|
+
const expectedBrX = quad.tr.x + quad.bl.x - quad.tl.x;
|
|
49
|
+
const expectedBrY = quad.tr.y + quad.bl.y - quad.tl.y;
|
|
50
|
+
return Math.abs(expectedBrX - quad.br.x) < 0.01 && Math.abs(expectedBrY - quad.br.y) < 0.01;
|
|
51
|
+
};
|
|
52
|
+
/** 单位正方形 → quad 的单应求解(仿射特例 g=h=0 短路;奇异分母判无效) */
|
|
53
|
+
export const getSquareToQuadHomography = (quad) => {
|
|
54
|
+
const sx = quad.tl.x - quad.tr.x + quad.br.x - quad.bl.x;
|
|
55
|
+
const sy = quad.tl.y - quad.tr.y + quad.br.y - quad.bl.y;
|
|
56
|
+
if (Math.abs(sx) < EPSILON && Math.abs(sy) < EPSILON) {
|
|
57
|
+
return {
|
|
58
|
+
a: quad.tr.x - quad.tl.x,
|
|
59
|
+
b: quad.bl.x - quad.tl.x,
|
|
60
|
+
c: quad.tl.x,
|
|
61
|
+
d: quad.tr.y - quad.tl.y,
|
|
62
|
+
e: quad.bl.y - quad.tl.y,
|
|
63
|
+
f: quad.tl.y,
|
|
64
|
+
g: 0,
|
|
65
|
+
h: 0
|
|
66
|
+
};
|
|
67
|
+
}
|
|
68
|
+
const dx1 = quad.tr.x - quad.br.x;
|
|
69
|
+
const dy1 = quad.tr.y - quad.br.y;
|
|
70
|
+
const dx2 = quad.bl.x - quad.br.x;
|
|
71
|
+
const dy2 = quad.bl.y - quad.br.y;
|
|
72
|
+
const denominator = dx1 * dy2 - dx2 * dy1;
|
|
73
|
+
if (Math.abs(denominator) < EPSILON)
|
|
74
|
+
return undefined;
|
|
75
|
+
const g = (sx * dy2 - dx2 * sy) / denominator;
|
|
76
|
+
const h = (dx1 * sy - sx * dy1) / denominator;
|
|
77
|
+
return {
|
|
78
|
+
a: quad.tr.x - quad.tl.x + g * quad.tr.x,
|
|
79
|
+
b: quad.bl.x - quad.tl.x + h * quad.bl.x,
|
|
80
|
+
c: quad.tl.x,
|
|
81
|
+
d: quad.tr.y - quad.tl.y + g * quad.tr.y,
|
|
82
|
+
e: quad.bl.y - quad.tl.y + h * quad.bl.y,
|
|
83
|
+
f: quad.tl.y,
|
|
84
|
+
g,
|
|
85
|
+
h
|
|
86
|
+
};
|
|
87
|
+
};
|
|
88
|
+
/** 单应正向投射:源平面 (x, y) → 目标平面点(x/y 通常取归一化 [0,1]) */
|
|
89
|
+
export const projectPoint = (homography, x, y) => {
|
|
90
|
+
const denominator = homography.g * x + homography.h * y + 1;
|
|
91
|
+
return {
|
|
92
|
+
x: (homography.a * x + homography.b * y + homography.c) / denominator,
|
|
93
|
+
y: (homography.d * x + homography.e * y + homography.f) / denominator
|
|
94
|
+
};
|
|
95
|
+
};
|
|
96
|
+
/** 单应求逆(行列式/齐次分量退化判无效)——透视光栅逐像素反投射用 */
|
|
97
|
+
export const invertHomography = (homography) => {
|
|
98
|
+
const { a, b, c, d, e, f, g, h } = homography;
|
|
99
|
+
const determinant = a * (e - f * h) - b * (d - f * g) + c * (d * h - e * g);
|
|
100
|
+
if (Math.abs(determinant) < EPSILON)
|
|
101
|
+
return undefined;
|
|
102
|
+
const m00 = (e - f * h) / determinant;
|
|
103
|
+
const m01 = (c * h - b) / determinant;
|
|
104
|
+
const m02 = (b * f - c * e) / determinant;
|
|
105
|
+
const m10 = (f * g - d) / determinant;
|
|
106
|
+
const m11 = (a - c * g) / determinant;
|
|
107
|
+
const m12 = (c * d - a * f) / determinant;
|
|
108
|
+
const m20 = (d * h - e * g) / determinant;
|
|
109
|
+
const m21 = (b * g - a * h) / determinant;
|
|
110
|
+
const m22 = (a * e - b * d) / determinant;
|
|
111
|
+
if (Math.abs(m22) < EPSILON)
|
|
112
|
+
return undefined;
|
|
113
|
+
return {
|
|
114
|
+
a: m00 / m22,
|
|
115
|
+
b: m01 / m22,
|
|
116
|
+
c: m02 / m22,
|
|
117
|
+
d: m10 / m22,
|
|
118
|
+
e: m11 / m22,
|
|
119
|
+
f: m12 / m22,
|
|
120
|
+
g: m20 / m22,
|
|
121
|
+
h: m21 / m22
|
|
122
|
+
};
|
|
123
|
+
};
|
package/dist/core/roundedRect.js
CHANGED
|
@@ -16,9 +16,10 @@
|
|
|
16
16
|
* 贝塞尔的最大偏差 <0.03% r,MSAA 下不可分辨)。
|
|
17
17
|
*/
|
|
18
18
|
/** fabric Rect._render 的圆角贝塞尔常数(1 − 4/3·(√2−1) 的工程截断值) */
|
|
19
|
+
import { ElementTypes, typeKeyOf } from '../model/elementTypes';
|
|
19
20
|
const K_RECT = 1 - 0.5522847498;
|
|
20
|
-
/** FabricRect
|
|
21
|
-
const RADIUS_SOURCED_TYPES = new Set([
|
|
21
|
+
/** FabricRect 族(应用类注册名双档,小写键口径坍缩):radius 视觉系为圆角源 */
|
|
22
|
+
const RADIUS_SOURCED_TYPES = new Set([ElementTypes.FABRICRECT]);
|
|
22
23
|
const numOr = (v, fallback) => (typeof v === 'number' && Number.isFinite(v) ? v : fallback);
|
|
23
24
|
/**
|
|
24
25
|
* FabricRect 族 radius → 本地 rx/ry 反算(fabric render 同式)。radius 非正
|
|
@@ -36,7 +37,7 @@ export const deriveFabricRectRadii = (radius, scaleX, scaleY) => {
|
|
|
36
37
|
* 一致时以 radius 为准(引擎渲染消费位同源,raw 归一只为序列化往返对齐)。
|
|
37
38
|
*/
|
|
38
39
|
export const normalizeFabricRectRadii = (raw) => {
|
|
39
|
-
if (
|
|
40
|
+
if (!RADIUS_SOURCED_TYPES.has(typeKeyOf(raw)))
|
|
40
41
|
return;
|
|
41
42
|
const radii = deriveFabricRectRadii(raw.radius, raw.scaleX, raw.scaleY);
|
|
42
43
|
if (radii) {
|
|
@@ -50,7 +51,7 @@ export const normalizeFabricRectRadii = (raw) => {
|
|
|
50
51
|
* rx/ry 注入 props 一并落 raw。返回是否注入。
|
|
51
52
|
*/
|
|
52
53
|
export const syncFabricRectRadiusProps = (raw, props) => {
|
|
53
|
-
if (
|
|
54
|
+
if (!RADIUS_SOURCED_TYPES.has(typeKeyOf(raw)))
|
|
54
55
|
return false;
|
|
55
56
|
const radiusTouched = 'radius' in props;
|
|
56
57
|
const scaleTouched = 'scaleX' in props || 'scaleY' in props;
|
|
@@ -72,7 +73,7 @@ export const syncFabricRectRadiusProps = (raw, props) => {
|
|
|
72
73
|
export const rectCornerRadii = (raw, width, height) => {
|
|
73
74
|
if (!(width > 0) || !(height > 0))
|
|
74
75
|
return null;
|
|
75
|
-
const radii =
|
|
76
|
+
const radii = RADIUS_SOURCED_TYPES.has(typeKeyOf(raw)) ? deriveFabricRectRadii(raw.radius, raw.scaleX, raw.scaleY) : null;
|
|
76
77
|
const rx0 = radii ? radii.rx : numOr(raw.rx, 0);
|
|
77
78
|
let ry0 = radii ? radii.ry : numOr(raw.ry, 0);
|
|
78
79
|
// fabric Rect._initRxRy 同构:单写 rx 提升 ry=rx(手写/旧档数据常见——
|
package/dist/core/stroke.js
CHANGED
|
@@ -8,6 +8,7 @@
|
|
|
8
8
|
* P3-5b 已做);paintFirst 缺省 'fill'(描边盖填充)。
|
|
9
9
|
*/
|
|
10
10
|
import { parseColor } from './color';
|
|
11
|
+
import { ElementTypes, typeKeyOf } from '../model/elementTypes';
|
|
11
12
|
const JOINS = new Set(['miter', 'round', 'bevel']);
|
|
12
13
|
const CAPS = new Set(['butt', 'round', 'square']);
|
|
13
14
|
/** raw 的 stroke 字段 → 声明;无描边(宽 0/无色)返回 null */
|
|
@@ -32,8 +33,8 @@ export const parseStrokeDecl = (raw) => {
|
|
|
32
33
|
paintFirst: raw.paintFirst === 'stroke' ? 'stroke' : 'fill',
|
|
33
34
|
alignment: raw.strokeAlignment === 'inside' || raw.strokeAlignment === 'outside' ? raw.strokeAlignment : 'center',
|
|
34
35
|
// 应用语义:FabricPath 构造器无条件 this.strokeUniform = true(序列化值也被
|
|
35
|
-
// 覆盖)——Path 节点强制 uniform,对齐 main
|
|
36
|
-
uniform: raw.strokeUniform === true || raw
|
|
36
|
+
// 覆盖)——Path 节点强制 uniform,对齐 main;小写键口径承接历史 'path' 模板
|
|
37
|
+
uniform: raw.strokeUniform === true || typeKeyOf(raw) === ElementTypes.PATH
|
|
37
38
|
};
|
|
38
39
|
};
|
|
39
40
|
/** 描边声明缓存键(烘焙纹理复用) */
|
package/dist/export/svgExport.js
CHANGED
|
@@ -41,29 +41,26 @@ import { parsePathData } from '../core/pathData';
|
|
|
41
41
|
import { computeTableLayout } from '../model/tableLayout';
|
|
42
42
|
import { parsePatternDecl, patternSpaceMatrix } from '../core/pattern';
|
|
43
43
|
import { arcTextKind, computeArcTextLayout } from '../model/arcLayout';
|
|
44
|
-
import { imageCropRect,
|
|
44
|
+
import { imageCropRect, textBitmapFillAlpha, WORKSPACE_IDS } from '../model/scene';
|
|
45
|
+
import { ElementTypes, typeKeyOf, IMAGE_LIKE_TYPES, TEXT_TYPES, SOLID_TYPES, LINE_TYPES, MASK_TYPES } from '../model/elementTypes';
|
|
45
46
|
import { charJitterY, layoutTextbox, verticalAnchorShiftX, verticalAnchorShiftY, verticalCharClass, verticalRenderAdvance } from '../model/textLayout';
|
|
46
47
|
import { planTextHighlight } from '../render/textHighlight';
|
|
47
|
-
// ----
|
|
48
|
-
|
|
49
|
-
const ROUND_TYPES = new Set([
|
|
50
|
-
const TRIANGLE_TYPES = new Set([
|
|
51
|
-
const
|
|
52
|
-
const
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
const
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
const DIMENSION_TYPES = new Set(['dimension', 'Dimension']);
|
|
59
|
-
const GROUP_TYPES = new Set(['group', 'Group', 'Puzzle', 'puzzle']);
|
|
60
|
-
/** 序列化侧图片族 = scene IMAGE_LIKE_TYPES + GIF(SVG 以 <image href> 引用——
|
|
48
|
+
// ---- 类型集(小写键口径,批次 360:家族集合复用 model/elementTypes,细分
|
|
49
|
+
// 子集本地小写化;比较位的 type 一律 typeKeyOf(raw) 派生,双形态就地坍缩) ----
|
|
50
|
+
const ROUND_TYPES = new Set([ElementTypes.ELLIPSE, ElementTypes.CIRCLE]);
|
|
51
|
+
const TRIANGLE_TYPES = new Set([ElementTypes.TRIANGLE]);
|
|
52
|
+
const POLYGON_TYPES = new Set([ElementTypes.POLYGON]);
|
|
53
|
+
const POLYLINE_TYPES = new Set([ElementTypes.POLYLINE]);
|
|
54
|
+
/** 线族装饰(arrow/dimension——端头装饰走 emitLineDecoration 专用 emitter,几何与渲染侧 bakeLineDecoration 同构) */
|
|
55
|
+
const ARROW_TYPES = new Set([ElementTypes.ARROW]);
|
|
56
|
+
const DIMENSION_TYPES = new Set([ElementTypes.DIMENSION]);
|
|
57
|
+
const GROUP_TYPES = new Set([ElementTypes.GROUP, ElementTypes.PUZZLE]);
|
|
58
|
+
/** 序列化侧图片族 = IMAGE_LIKE_TYPES + GIF(SVG 以 <image href> 引用——
|
|
61
59
|
* 动图在支持的查看器播放、静态查看器显首帧;不动 scene 共享集避免
|
|
62
60
|
* AnimatedNode.isImageType 语义牵连。Video 不承接——SVG 规范无视频引用,须
|
|
63
61
|
* 帧位图化(余量登记) */
|
|
64
|
-
const SVG_IMAGE_TYPES = new Set([...IMAGE_LIKE_TYPES,
|
|
65
|
-
const TABLE_TYPES = new Set([
|
|
66
|
-
const MASK_TYPES = new Set(['Mask', 'mask']);
|
|
62
|
+
const SVG_IMAGE_TYPES = new Set([...IMAGE_LIKE_TYPES, ElementTypes.GIF]);
|
|
63
|
+
const TABLE_TYPES = new Set([ElementTypes.TABLE]);
|
|
67
64
|
/** gco → SVG mix-blend-mode 直通白名单(同值域;fabric toSVG 时代同样以平铺/
|
|
68
65
|
* 混合近似承接);白名单外(source-atop 等合成态)继续 skip */
|
|
69
66
|
const BLEND_MODES = new Set([
|
|
@@ -83,21 +80,22 @@ const BLEND_MODES = new Set([
|
|
|
83
80
|
'color',
|
|
84
81
|
'luminosity'
|
|
85
82
|
]);
|
|
86
|
-
/**
|
|
87
|
-
*
|
|
88
|
-
*
|
|
89
|
-
|
|
83
|
+
/** 常规文本族:词表本体复用 elementTypes 的 TEXT_TYPES(含 ScrollText 静态基态
|
|
84
|
+
* 承接、'i-text' 旧模板兜底;ArcText/CircleText 进 emitText 后由 arcTextKind
|
|
85
|
+
* 分派弧形专用 emitter;ArchText/WaistText/FlagText 由 warp 分派变形 emitter)。
|
|
86
|
+
* 序列化侧与场景侧同源,防本地副本成员漂移 */
|
|
90
87
|
/** 变形族判别(render/warpText.warpTextKind 同式——export 不引 render 域,内联):
|
|
91
88
|
* warpStrength=0 的变形族是普通文本(走常规快照路径) */
|
|
92
89
|
const warpKindOf = (raw) => {
|
|
93
90
|
const s = Number(raw.warpStrength) || 0;
|
|
94
91
|
if (!s)
|
|
95
92
|
return null;
|
|
96
|
-
|
|
93
|
+
const t = typeKeyOf(raw);
|
|
94
|
+
if (t === ElementTypes.ARCHTEXT)
|
|
97
95
|
return 'arch';
|
|
98
|
-
if (
|
|
96
|
+
if (t === ElementTypes.WAISTTEXT)
|
|
99
97
|
return 'waist';
|
|
100
|
-
if (
|
|
98
|
+
if (t === ElementTypes.FLAGTEXT)
|
|
101
99
|
return 'flag';
|
|
102
100
|
return null;
|
|
103
101
|
};
|
|
@@ -192,7 +190,7 @@ const commandsToPathD = (commands) => commands
|
|
|
192
190
|
.join(' ')}`)
|
|
193
191
|
.join(' ');
|
|
194
192
|
const shapeGeometry = (raw, width, height) => {
|
|
195
|
-
const type = raw
|
|
193
|
+
const type = typeKeyOf(raw);
|
|
196
194
|
if (SOLID_TYPES.has(type)) {
|
|
197
195
|
const rx = Math.min(num(raw, 'rx', 0), width / 2);
|
|
198
196
|
const ry = Math.min(num(raw, 'ry', 0), height / 2);
|
|
@@ -212,7 +210,7 @@ const shapeGeometry = (raw, width, height) => {
|
|
|
212
210
|
internalTransform: null
|
|
213
211
|
};
|
|
214
212
|
}
|
|
215
|
-
if (
|
|
213
|
+
if (type === ElementTypes.PATH) {
|
|
216
214
|
// 双形态:SVG 串 / fabric toObject 的指令数组(默认模板实测形态)——parsePathData 归一
|
|
217
215
|
const commands = parsePathData(raw.path);
|
|
218
216
|
if (!commands)
|
|
@@ -1349,7 +1347,7 @@ export class SvgExporter {
|
|
|
1349
1347
|
return layoutTextbox(text, baseTextStyle(raw), {
|
|
1350
1348
|
measure: this.layoutMeasure,
|
|
1351
1349
|
// boxWidth 判定与 TextNode.textLayout 同式(弧形/竖排非 textbox 盒)
|
|
1352
|
-
boxWidth: raw
|
|
1350
|
+
boxWidth: typeKeyOf(raw) === ElementTypes.TEXTBOX ? raw.width ?? 0 : null,
|
|
1353
1351
|
styles: stylesArrayToMap(text, raw.styles),
|
|
1354
1352
|
splitByGrapheme: raw.splitByGrapheme === true,
|
|
1355
1353
|
vertical,
|
|
@@ -1442,7 +1440,7 @@ export class SvgExporter {
|
|
|
1442
1440
|
}
|
|
1443
1441
|
/** 单对象内容序列化(不含外层 <g>——由调用方包矩阵/透明度);null = 不支持(已计数) */
|
|
1444
1442
|
emitObjectContent(raw, matrix, width, height) {
|
|
1445
|
-
const type = raw
|
|
1443
|
+
const type = typeKeyOf(raw);
|
|
1446
1444
|
if (GROUP_TYPES.has(type)) {
|
|
1447
1445
|
const children = raw.objects;
|
|
1448
1446
|
if (!Array.isArray(children)) {
|
|
@@ -1472,7 +1470,7 @@ export class SvgExporter {
|
|
|
1472
1470
|
// effects 拦截与 crop 语义;转正态(renderSrc 已删)落下方常规文本族通道。
|
|
1473
1471
|
// renderRect.angle=PSD 文档系轴对齐位图对元素角的逆旋(渲染侧 SceneRenderer
|
|
1474
1472
|
// 同口径——SVG rotate 正向与引擎一致,绕本地位图中心)
|
|
1475
|
-
if (type ===
|
|
1473
|
+
if (type === ElementTypes.TEXTIMAGE && typeof raw.renderSrc === 'string') {
|
|
1476
1474
|
const rect = raw.renderRect;
|
|
1477
1475
|
const w = typeof rect?.w === 'number' && rect.w > 0 ? rect.w : num(raw, 'width', NaN);
|
|
1478
1476
|
const h = typeof rect?.h === 'number' && rect.h > 0 ? rect.h : num(raw, 'height', NaN);
|
|
@@ -1510,7 +1508,7 @@ export class SvgExporter {
|
|
|
1510
1508
|
}
|
|
1511
1509
|
const geometry = shapeGeometry(raw, width, height);
|
|
1512
1510
|
if (!geometry) {
|
|
1513
|
-
this.skip(`type:${type}`);
|
|
1511
|
+
this.skip(`type:${String(raw.type ?? '')}`);
|
|
1514
1512
|
return null;
|
|
1515
1513
|
}
|
|
1516
1514
|
const fill = this.resolvePaint(raw.fill, width, height);
|
|
@@ -1547,13 +1545,12 @@ export class SvgExporter {
|
|
|
1547
1545
|
* (转曲语义只约束模板字体外发)。
|
|
1548
1546
|
*/
|
|
1549
1547
|
emitLineDecoration(raw, isArrow) {
|
|
1550
|
-
const type = typeof raw.type === 'string' ? raw.type : 'line-decoration';
|
|
1551
1548
|
const x1 = num(raw, 'x1', NaN);
|
|
1552
1549
|
const y1 = num(raw, 'y1', NaN);
|
|
1553
1550
|
const x2 = num(raw, 'x2', NaN);
|
|
1554
1551
|
const y2 = num(raw, 'y2', NaN);
|
|
1555
1552
|
if (!Number.isFinite(x1) || !Number.isFinite(y1) || !Number.isFinite(x2) || !Number.isFinite(y2)) {
|
|
1556
|
-
this.skip(`dims-missing:${type}`);
|
|
1553
|
+
this.skip(`dims-missing:${String(raw.type ?? '')}`);
|
|
1557
1554
|
return null;
|
|
1558
1555
|
}
|
|
1559
1556
|
// 线色兜底 #000000(渲染侧同款——线族 stroke 缺省仍画黑,不走形状族 strokeVisible 判定)
|
|
@@ -1659,7 +1656,7 @@ export class SvgExporter {
|
|
|
1659
1656
|
return '';
|
|
1660
1657
|
if (raw.visible === false)
|
|
1661
1658
|
return '';
|
|
1662
|
-
const type = raw
|
|
1659
|
+
const type = typeKeyOf(raw);
|
|
1663
1660
|
// 内容尺寸(矩阵中心换算与几何共用):裁剪图用可见尺寸、图片缺宽回退自然尺寸
|
|
1664
1661
|
let width = num(raw, 'width', NaN);
|
|
1665
1662
|
let height = num(raw, 'height', NaN);
|
|
@@ -1759,7 +1756,7 @@ export class SvgExporter {
|
|
|
1759
1756
|
}
|
|
1760
1757
|
}
|
|
1761
1758
|
if (!Number.isFinite(width) || !Number.isFinite(height)) {
|
|
1762
|
-
this.skip(`dims-missing:${type}`);
|
|
1759
|
+
this.skip(`dims-missing:${String(raw.type ?? '')}`);
|
|
1763
1760
|
return null;
|
|
1764
1761
|
}
|
|
1765
1762
|
const matrix = ownMatrix(raw, width, height);
|
package/dist/index.d.ts
CHANGED
|
@@ -14,6 +14,7 @@ export type { GradientFiller, PatternFiller, TFiller, Control } from './model/fi
|
|
|
14
14
|
export { CompatPoint, Point, type PointLike } from './core/point';
|
|
15
15
|
export { buildEngineShapePath, type EngineShapePathResult } from './model/shapePath';
|
|
16
16
|
export { imageMaskDeclOf, imageMaskOffset, maskOutsideRects, maskPixelsToAlpha, type ImageMaskDecl } from './model/imageMaskBake';
|
|
17
|
+
export { renderPlacedSmartObjectLayer, type SmartObjectPlacedDecl, type SmartObjectRenderOptions, type SmartObjectRenderResult } from './model/smartObjectBake';
|
|
17
18
|
export { attachTableFacade } from './model/tableFacade';
|
|
18
19
|
export { deriveArcCharTransformations } from './model/arcTextTransform';
|
|
19
20
|
export { CompatObject, wrapCompatObject, findParentGroupOf, type CompatObjectContext } from './model/compatObject';
|
|
@@ -25,6 +26,10 @@ export { isCanvasPerfEnabled, markCanvasPerfCounter, recordCanvasPerfDuration }
|
|
|
25
26
|
export { rectCornerRadii } from './core/roundedRect';
|
|
26
27
|
export { parsePsdEffects } from './core/psdEffects';
|
|
27
28
|
export { EngineDocument, type EngineDocumentEvents, type IndexedItem, type SelectionFrame } from './model/document';
|
|
29
|
+
/** 元素类型规范词表(批次 361 主仓同源):小写键 + typeKeyOf 坍缩 + 家族集合——
|
|
30
|
+
* 主仓 @/types/elements 的 ElementNames 即本导出的别名(引擎=渲染权限守门人,
|
|
31
|
+
* 类型词汇的单一事实源在引擎,新增元素类型须先在此登记可渲染) */
|
|
32
|
+
export { ElementTypes, typeKeyOf, TEXT_TYPES, SHAPE_TYPES, LINE_TYPES, PUZZLE_TYPES, GIF_TYPES, VIDEO_TYPES, type ElementTypeKey } from './model/elementTypes';
|
|
28
33
|
export { buildScene, loadImageElement, IMAGE_LIKE_TYPES, SOLID_TYPES, MASK_TYPES, createNode, isTextBitmapState, textBitmapFillAlpha, SceneNode, TextNode, ShapeNode, PathNode, LineNode, GroupNode, MaskNode, PuzzleNode, TableNode, AnimatedNode, type SerializedNode } from './model/scene';
|
|
29
34
|
export { SvgExporter, serializePageToSvg, buildTextGlyphPathData, type SvgPageRequest, type SvgPageOptions, type SvgPageResult, type SvgExporterOptions, type SvgViewBox, type SvgFontResolver, type SvgGlyphFont, type SvgGlyphCommand, type SvgMeasureFn, type SvgTextBitmap, type SvgTextBitmapBaker, type SvgTextBitmapFamily } from './export/svgExport';
|
|
30
35
|
export { parsePathData, getBoundsOfPath, type PathCommand } from './core/pathData';
|
package/dist/index.js
CHANGED
|
@@ -15,6 +15,10 @@ export { buildEngineShapePath } from './model/shapePath';
|
|
|
15
15
|
// image 级图层蒙版烘焙纯函数(批次 103 装载烘焙口径;主仓 PDF worker 导出侧
|
|
16
16
|
// 同式消费——decl 校验/灰度→alpha/offset 回退/矩形外涂黑区,parity 一源)
|
|
17
17
|
export { imageMaskDeclOf, imageMaskOffset, maskOutsideRects, maskPixelsToAlpha } from './model/imageMaskBake';
|
|
18
|
+
// 智能对象置入层透视光栅烘焙(批次 363 自主仓 extension/object/FabricSmartObject.ts 迁居;
|
|
19
|
+
// 主仓 template store 智能对象同步管线消费——parity 一源。后续 PS 智能对象新形态
|
|
20
|
+
// (变形/网格变换)在引擎侧统一承接,GPU 原生透视渲染就绪后经 render/ 落地)
|
|
21
|
+
export { renderPlacedSmartObjectLayer } from './model/smartObjectBake';
|
|
18
22
|
export { attachTableFacade } from './model/tableFacade';
|
|
19
23
|
export { deriveArcCharTransformations } from './model/arcTextTransform';
|
|
20
24
|
export { CompatObject, wrapCompatObject, findParentGroupOf } from './model/compatObject';
|
|
@@ -26,6 +30,10 @@ export { isCanvasPerfEnabled, markCanvasPerfCounter, recordCanvasPerfDuration }
|
|
|
26
30
|
export { rectCornerRadii } from './core/roundedRect';
|
|
27
31
|
export { parsePsdEffects } from './core/psdEffects';
|
|
28
32
|
export { EngineDocument } from './model/document';
|
|
33
|
+
/** 元素类型规范词表(批次 361 主仓同源):小写键 + typeKeyOf 坍缩 + 家族集合——
|
|
34
|
+
* 主仓 @/types/elements 的 ElementNames 即本导出的别名(引擎=渲染权限守门人,
|
|
35
|
+
* 类型词汇的单一事实源在引擎,新增元素类型须先在此登记可渲染) */
|
|
36
|
+
export { ElementTypes, typeKeyOf, TEXT_TYPES, SHAPE_TYPES, LINE_TYPES, PUZZLE_TYPES, GIF_TYPES, VIDEO_TYPES } from './model/elementTypes';
|
|
29
37
|
export { buildScene, loadImageElement, IMAGE_LIKE_TYPES, SOLID_TYPES, MASK_TYPES, createNode, isTextBitmapState, textBitmapFillAlpha, SceneNode, TextNode, ShapeNode, PathNode, LineNode, GroupNode, MaskNode, PuzzleNode, TableNode, AnimatedNode } from './model/scene';
|
|
30
38
|
export { SvgExporter, serializePageToSvg, buildTextGlyphPathData } from './export/svgExport';
|
|
31
39
|
export { parsePathData, getBoundsOfPath } from './core/pathData';
|
|
@@ -24,6 +24,7 @@ import { invert, objectOriginFromCenter, transformPoint } from '../core/mat2d';
|
|
|
24
24
|
import { getBoundsOfPath, parsePathData } from '../core/pathData';
|
|
25
25
|
import { parseColor } from '../core/color';
|
|
26
26
|
import { LineNode } from '../model/scene';
|
|
27
|
+
import { ElementTypes } from '../model/elementTypes';
|
|
27
28
|
import { describePathEdit, describePolyEdit, findInsertCandidate, insertAnchorAt, pathBBoxCenter, polyBBoxCenter, setAnchorType as setAnchorTypeOp, shiftedCenter, writePathCoordinate, writePolyPoint } from '../model/pathEdit';
|
|
28
29
|
import { buildNodeBorderOverlay, lineQuad } from '../render/selectionOverlay';
|
|
29
30
|
/** 锚点/手柄命中半径(屏幕 px;引擎手柄命中惯例同 selectionOverlay.HANDLE_HIT_PX) */
|
|
@@ -57,13 +58,12 @@ const getCircleSprite = () => {
|
|
|
57
58
|
};
|
|
58
59
|
/** 编辑族判定:Path(命令)/ polygon·polyline(points)/ Line(端点);null = 不可编辑 */
|
|
59
60
|
export const pathEditKindOf = (node) => {
|
|
60
|
-
const
|
|
61
|
-
if (
|
|
61
|
+
const t = node.typeKey;
|
|
62
|
+
if (t === ElementTypes.PATH)
|
|
62
63
|
return 'path';
|
|
63
|
-
|
|
64
|
-
if (lower === 'polygon' || lower === 'polyline')
|
|
64
|
+
if (t === ElementTypes.POLYGON || t === ElementTypes.POLYLINE)
|
|
65
65
|
return 'poly';
|
|
66
|
-
if (
|
|
66
|
+
if (t === ElementTypes.LINE)
|
|
67
67
|
return 'line';
|
|
68
68
|
return null;
|
|
69
69
|
};
|
|
@@ -5,6 +5,7 @@
|
|
|
5
5
|
* (原私有方法的 this.host.document),语义逐行不变。
|
|
6
6
|
*/
|
|
7
7
|
import { isTextBitmapState, TextNode } from '../model/scene';
|
|
8
|
+
import { ElementTypes } from '../model/elementTypes';
|
|
8
9
|
import { applyGroupWidthBake, buildGroupWidthSnapshot, isGroupWidthHandleNode } from '../model/groupResize';
|
|
9
10
|
import { invert, objectOriginFromCenter, transformPoint } from '../core/mat2d';
|
|
10
11
|
import { CORNER_HANDLES, deg, handleLocals, pointerLocal, quadCenter, quadDims, rad, solveScales } from './pointerTypes';
|
|
@@ -21,7 +22,7 @@ export function buildScaleSnapshot(node, handle, doc) {
|
|
|
21
22
|
// 批次 314:TextImage 位图态(renderSrc 在场)ml/mr 走通用 scaleX(图片口径
|
|
22
23
|
//——改盒宽对位图无视觉意义,且写 width 会触发转正防线);转正后按盒宽语义
|
|
23
24
|
const textBitmap = isTextBitmapState(node);
|
|
24
|
-
const widthBake = (node.
|
|
25
|
+
const widthBake = (node.typeKey === ElementTypes.TEXTBOX || (node.typeKey === ElementTypes.TEXTIMAGE && !textBitmap)) && (handle === 'ml' || handle === 'mr');
|
|
25
26
|
if (widthBake) {
|
|
26
27
|
a.x = -u.x;
|
|
27
28
|
a.y = -h / 2;
|
|
@@ -268,7 +269,7 @@ export function applyFontBake(doc, s, v) {
|
|
|
268
269
|
};
|
|
269
270
|
// textbox 的盒宽是排版输入必须随 ratio;itext/text 宽=最长行(排版推导),写了也不作数。
|
|
270
271
|
// 双口径同上:大写 'Textbox' 漏判时盒宽不随字号 → 下次排版按旧宽换行(盒宽陈旧回归)
|
|
271
|
-
if (s.node.
|
|
272
|
+
if (s.node.typeKey === ElementTypes.TEXTBOX)
|
|
272
273
|
props.width = Math.max(s.width * ratio, 1);
|
|
273
274
|
// 盒高同随 ratio(fabric changeObjectFontSize 等比分支写 height×ratioY):不写则
|
|
274
275
|
// 序列化旧 height 钉死 TextNode.dims 的盒高下限 max(内容高, raw.height)——字号
|
|
@@ -31,6 +31,7 @@
|
|
|
31
31
|
* 线宽/十字/刻度全部按 zoom 折算成屏幕恒定像素(1/3/8px,main 同值)。
|
|
32
32
|
*/
|
|
33
33
|
import { parseColor } from '../core/color';
|
|
34
|
+
import { ElementTypes } from '../model/elementTypes';
|
|
34
35
|
import { lineQuad, selectionQuadCoords } from '../render/selectionOverlay';
|
|
35
36
|
import { CORNER_HANDLE_LIST, isCornerHandle } from '../model/handles';
|
|
36
37
|
import { buildAxisSortedPoints, buildGapIndex, coordsToPoints, getReferenceSnapPoints, round, snapDraggedElements, snapResizingElements } from '../core/snap';
|
|
@@ -173,7 +174,7 @@ export class SnapGuideController {
|
|
|
173
174
|
registerScaling(node, handle) {
|
|
174
175
|
if (!this.enabled())
|
|
175
176
|
return;
|
|
176
|
-
if (node.
|
|
177
|
+
if (node.typeKey === ElementTypes.CIRCLE)
|
|
177
178
|
return;
|
|
178
179
|
this.clearLines();
|
|
179
180
|
this.activeType = node.raw.type;
|
package/dist/model/alphaHit.js
CHANGED
|
@@ -38,6 +38,7 @@
|
|
|
38
38
|
* = 误透传(点阴影落空),方向比误实心更错。
|
|
39
39
|
*/
|
|
40
40
|
import { ALPHA_HIT_TRANSPARENT_LIMIT, AnimatedNode, GroupNode, IMAGE_LIKE_TYPES, MaskNode, PuzzleNode, TableNode } from './scene';
|
|
41
|
+
import { ElementTypes } from './elementTypes';
|
|
41
42
|
import { parsePsdEffects, psdEffectsKey } from '../core/psdEffects';
|
|
42
43
|
import { bakePsdShadow, bakePsdStrokes } from '../render/imageEffects';
|
|
43
44
|
/** 与 app fabricCanvas.isTransparent / alphaMask 的 alphaChannel > 10 同口径
|
|
@@ -232,7 +233,7 @@ export const isHitTransparent = (node, x, y, ctx) => {
|
|
|
232
233
|
const gco = typeof node.raw.globalCompositeOperation === 'string' ? node.raw.globalCompositeOperation : '';
|
|
233
234
|
if (gco === 'multiply' && !ctx.selection.includes(node))
|
|
234
235
|
return true;
|
|
235
|
-
if (gco && gco !== 'source-over' && node.
|
|
236
|
+
if (gco && gco !== 'source-over' && node.typeKey !== ElementTypes.REFERENCELINE && ctx.hasSelectableBelow())
|
|
236
237
|
return true;
|
|
237
238
|
// 豁免清单(app _checkTransparencyWithCache / _checkTarget):拼图/蒙版/
|
|
238
239
|
// 文本(含 TextImage 位图态——文字元素语义盒内空白属于文字层,用户定义
|
package/dist/model/arcLayout.js
CHANGED
|
@@ -26,6 +26,7 @@
|
|
|
26
26
|
* 分派在效果层之前返回)。
|
|
27
27
|
*/
|
|
28
28
|
import { FONT_SIZE_FRACTION } from './textLayout';
|
|
29
|
+
import { ElementTypes, typeKeyOf } from './elementTypes';
|
|
29
30
|
/** fabric Text 常量同源(ArcText BaseRadius / MIN_TEXT_WIDTH) */
|
|
30
31
|
const BASE_RADIUS = 10000;
|
|
31
32
|
const MIN_TEXT_WIDTH = 2;
|
|
@@ -80,9 +81,9 @@ const sectorBoundingBox = (E, F, C, radius) => {
|
|
|
80
81
|
};
|
|
81
82
|
/** ArcText 类型判定(curvature 任意值都走摆位机——0° 也经 radius=1e5 的近直渲染) */
|
|
82
83
|
export const arcTextKind = (raw) => {
|
|
83
|
-
if (raw
|
|
84
|
+
if (typeKeyOf(raw) === ElementTypes.ARCTEXT)
|
|
84
85
|
return 'arc';
|
|
85
|
-
if (raw
|
|
86
|
+
if (typeKeyOf(raw) === ElementTypes.CIRCLETEXT)
|
|
86
87
|
return 'circle';
|
|
87
88
|
return null;
|
|
88
89
|
};
|
|
@@ -294,7 +295,7 @@ const computeCirclePlacements = (layout, lineHeight, params) => {
|
|
|
294
295
|
/** 弧形/圆形文本统一入口:参数缺省对齐应用类字段默认(curvature 300 /
|
|
295
296
|
* circleSize 40 / startAngle 0 / sweep 360 / eccentricity 0 / normal) */
|
|
296
297
|
export const computeArcTextLayout = (layout, raw, lineHeight) => {
|
|
297
|
-
if (raw
|
|
298
|
+
if (typeKeyOf(raw) === ElementTypes.CIRCLETEXT) {
|
|
298
299
|
return computeCirclePlacements(layout, lineHeight, {
|
|
299
300
|
size: typeof raw.circleSize === 'number' ? raw.circleSize : 40,
|
|
300
301
|
startAngle: typeof raw.circleStartAngle === 'number' ? raw.circleStartAngle : 0,
|
|
@@ -305,7 +305,7 @@ export declare class CompatObject {
|
|
|
305
305
|
* target 不进失效链 */
|
|
306
306
|
get ref(): CompatObject;
|
|
307
307
|
/** 图像族判定:IMAGE_LIKE_TYPES + Mask(ElementMask 面板蒙版源)+ gif/video
|
|
308
|
-
* (AnimatedNode
|
|
308
|
+
* (AnimatedNode 图像管线)。小写键口径(typeKeyOf 坍缩,批次 360) */
|
|
309
309
|
private get isImageLikeNode();
|
|
310
310
|
/** 应用 FabricImage.getSrc 覆写语义:originalSrc 优先(换图后历史快照 before/after
|
|
311
311
|
* 以 originalSrc 判等回放);无则 src。filtered 位不承接(引擎无滤镜后源缓存) */
|
|
@@ -18,6 +18,7 @@
|
|
|
18
18
|
*/
|
|
19
19
|
import { CompatPoint } from '../core/point';
|
|
20
20
|
import { AnimatedNode, GroupNode, IMAGE_LIKE_TYPES, MASK_TYPES, PathNode, PuzzleNode, TableNode, TextNode } from './scene';
|
|
21
|
+
import { ElementTypes, typeKeyOf } from './elementTypes';
|
|
21
22
|
import { anchorStyleAt } from './pathEdit';
|
|
22
23
|
import { parsePathData } from '../core/pathData';
|
|
23
24
|
import { pathEditKindOf } from '../interact/pathSession';
|
|
@@ -141,8 +142,8 @@ export class CompatObject {
|
|
|
141
142
|
return;
|
|
142
143
|
if (props.width < 0)
|
|
143
144
|
return;
|
|
144
|
-
const rawType =
|
|
145
|
-
if (rawType !==
|
|
145
|
+
const rawType = typeKeyOf(this.node.raw);
|
|
146
|
+
if (rawType !== ElementTypes.TEXTBOX)
|
|
146
147
|
return;
|
|
147
148
|
if (arcTextKind(this.node.raw))
|
|
148
149
|
return;
|
|
@@ -345,10 +346,10 @@ export class CompatObject {
|
|
|
345
346
|
// 面板的换图与图源读位。方法存在性=类型判别器(main.ts 背景图/AI 技法/useChat
|
|
346
347
|
// 以 typeof getSrc 判图像族后回落 raw.src),仅图像族暴露——fabric 同款缺席语义 ——
|
|
347
348
|
/** 图像族判定:IMAGE_LIKE_TYPES + Mask(ElementMask 面板蒙版源)+ gif/video
|
|
348
|
-
* (AnimatedNode
|
|
349
|
+
* (AnimatedNode 图像管线)。小写键口径(typeKeyOf 坍缩,批次 360) */
|
|
349
350
|
get isImageLikeNode() {
|
|
350
|
-
const t =
|
|
351
|
-
return IMAGE_LIKE_TYPES.has(t) || MASK_TYPES.has(t) ||
|
|
351
|
+
const t = typeKeyOf(this.node.raw);
|
|
352
|
+
return IMAGE_LIKE_TYPES.has(t) || MASK_TYPES.has(t) || t === ElementTypes.GIF || t === ElementTypes.VIDEO;
|
|
352
353
|
}
|
|
353
354
|
/** 应用 FabricImage.getSrc 覆写语义:originalSrc 优先(换图后历史快照 before/after
|
|
354
355
|
* 以 originalSrc 判等回放);无则 src。filtered 位不承接(引擎无滤镜后源缓存) */
|
|
@@ -1413,7 +1414,7 @@ export class CompatObject {
|
|
|
1413
1414
|
/** clipImage 序列化声明读位(非 Mask 节点/坏声明 null——type 两形态同 isImageLikeNode 口径) */
|
|
1414
1415
|
const clipImageRawOf = (node) => {
|
|
1415
1416
|
const raw = node.raw;
|
|
1416
|
-
if (!MASK_TYPES.has(
|
|
1417
|
+
if (!MASK_TYPES.has(typeKeyOf(raw)))
|
|
1417
1418
|
return null;
|
|
1418
1419
|
const c = raw.clipImage;
|
|
1419
1420
|
if (!c || typeof c !== 'object' || typeof c.src !== 'string')
|