@yft-design/engine 0.0.2 → 0.0.4

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.
@@ -0,0 +1,99 @@
1
+ /**
2
+ * 元素类型规范词表(小写规范形态)+装载期一次性小写化比较键。
3
+ *
4
+ * 双产源域不再逐集合枚举双形态:fabric 基类 toObject 写小写、自定义类
5
+ * toObject 恒大写(classRegistry 亦注册小写兜底旧数据)、PDF producer
6
+ * 场景级 'Path'(批次 357 正名)。历史方案是每族 Set 收双形态——漏一枚
7
+ * 即 buildScene 静默跳过(批次 338 表格线 / 357 path / 360 i-text 事故族)。
8
+ * 现统一为:比较一律走 typeKeyOf(raw)(raw 层,装载/序列化侧)或
9
+ * node.typeKey(节点层,构造期缓存 + set 写 type 重算),集合只收小写。
10
+ *
11
+ * 性能约束(批次 222 先例):帧循环热路径禁止逐比较 toLowerCase 分配
12
+ * 字符串——万级场景每帧万次分配;判定必须消费缓存键。
13
+ *
14
+ * 词表值域与主仓 ElementNames(@/types/elements)收敛:'ArcText'→'arctext'
15
+ * 等小写坍缩后两仓同一套词汇;'IText' 与 'itext' 小写同形坍缩同族。
16
+ * raw.type 原文不被改写(toObject/序列化保原大小写往返)。
17
+ */
18
+ export declare const ElementTypes: {
19
+ readonly TEXTBOX: "textbox";
20
+ readonly TEXT: "text";
21
+ /** fabric IText 基类 toObject 小写(与 INPUTTEXT 'itext' 是两个串) */
22
+ readonly ITEXT: "i-text";
23
+ readonly INPUTTEXT: "itext";
24
+ readonly ARCHTEXT: "archtext";
25
+ readonly WAISTTEXT: "waisttext";
26
+ readonly FLAGTEXT: "flagtext";
27
+ readonly ARCTEXT: "arctext";
28
+ readonly CIRCLETEXT: "circletext";
29
+ readonly SCROLLTEXT: "scrolltext";
30
+ /** 批次 314 图片文字:位图态(raw.renderSrc 在场)按图片口径 */
31
+ readonly TEXTIMAGE: "textimage";
32
+ readonly IMAGE: "image";
33
+ readonly SVGIMAGE: "svgimage";
34
+ readonly CROPIMAGE: "cropimage";
35
+ readonly ECHART: "echart";
36
+ readonly FABRIC_ECHART: "fabricechart";
37
+ readonly QRCODE: "qrcode";
38
+ readonly BARCODE: "barcode";
39
+ readonly MASK: "mask";
40
+ readonly PATH: "path";
41
+ readonly RECT: "rect";
42
+ readonly FABRICRECT: "fabricrect";
43
+ readonly LINE: "line";
44
+ readonly ARROW: "arrow";
45
+ readonly POLYLINE: "polyline";
46
+ readonly POLYGON: "polygon";
47
+ readonly ELLIPSE: "ellipse";
48
+ readonly CIRCLE: "circle";
49
+ readonly TRIANGLE: "triangle";
50
+ readonly TABLE: "table";
51
+ readonly GROUP: "group";
52
+ /** 多选态合成类型(fabric ActiveSelection 序列化形态;主仓 GroupTypeSets 消费) */
53
+ readonly ACTIVE_SELECTION: "activeselection";
54
+ readonly PUZZLE: "puzzle";
55
+ readonly GIF: "gif";
56
+ readonly VIDEO: "video";
57
+ readonly DIMENSION: "dimension";
58
+ readonly REFERENCELINE: "referenceline";
59
+ };
60
+ export type ElementTypeKey = (typeof ElementTypes)[keyof typeof ElementTypes];
61
+ /** raw 层比较键(工厂/装载/序列化侧入口):一次性小写化;非串/缺席返 '' */
62
+ export declare const typeKeyOf: (raw: {
63
+ type?: unknown;
64
+ } | null | undefined) => string;
65
+ /** 文本族:textbox 有固定盒宽换行;itext/text 不换行(宽=最长行);
66
+ * 变形三类型(P4-5a)按 textbox 盒语义排版(warpStrength=0/编辑态走常规管线);
67
+ * 弧形/圆形(P4-5b)按 itext 语义排版(不换行),dims 走 arcLayout 的弧形 bbox;
68
+ * TextImage(批次 314 图片文字):PSD 导入的位图态文本——raw.renderSrc 在场时
69
+ * 渲染走位图 quad(零字体依赖),编辑态/转正后走常规字形管线;
70
+ * 'i-text'(fabric IText 基类 toObject 小写)=旧模板域兜底——漏收=旧模板
71
+ * 文本对象 buildScene 静默跳过(批次 360) */
72
+ export declare const TEXT_TYPES: Set<string>;
73
+ /** 序列化侧图片族(image/svgimage/cropimage/qrcode/barcode/echart 族;
74
+ * 'Image'/'QRCode'/'BarCode'/'FabricEchart' 等大写形态经 typeKeyOf 坍缩) */
75
+ export declare const IMAGE_LIKE_TYPES: Set<string>;
76
+ /** 填充形状族(P3-1 + P3-6a):三角化网格渲染;line/arrow 无填充(描边族属 P3-2)暂不进。
77
+ * 'path' 是 fabric Path/FabricPath 与 PDF producer(批次 357 正名 'Path')双产源的
78
+ * 坍缩形态;'triangle'(fabric Triangle)按 width/height 合成三点多边形(ShapeNode 分支) */
79
+ export declare const SHAPE_TYPES: Set<string>;
80
+ /** 路径族判定(批次 361 惯用法统一):单类型判断一律 `key === ElementTypes.PATH`
81
+ * 直比(单成员集合已退役);SHAPE_TYPES 同步收录 path 供 isShapeType 渲染/
82
+ * 阴影/命中门(SceneRenderer 形状分支按谓词分档,节点在而谓词 miss=不渲染) */
83
+ /** 线族(P3-6b):'Line' fabric toObject 与 'line' 历史小写坍缩同族;arrow/
84
+ * dimension/referenceline 是应用类注册名域(大写形态经 typeKeyOf 坍缩)。
85
+ * x1..y2 为中心相对坐标(calcLinePoints 恒等映射);渲染走描边烘焙(arrow/
86
+ * dimension 含端头/刻度/文本装饰) */
87
+ export declare const LINE_TYPES: Set<string>;
88
+ /** 填充实心族(rect/FabricRect 双产源坍缩) */
89
+ export declare const SOLID_TYPES: Set<string>;
90
+ /** 蒙版族(P4-5b(2/2)):FabricMask.toObject 恒写 'Mask'(classRegistry 亦注册小写 'mask')。
91
+ * 不进 IMAGE_LIKE_TYPES——Mask 的 cropX/cropY 是裁剪态暂存(渲染走 clipX/clipY),
92
+ * 与图片族静态裁剪语义不同,imageCropRect 不适用 */
93
+ export declare const MASK_TYPES: Set<string>;
94
+ /** 拼图(P4-5b(2/2)):FabricPuzzle.toObject 恒写 'Puzzle'(小写兜底) */
95
+ export declare const PUZZLE_TYPES: Set<string>;
96
+ /** 动画族(Phase 4):FabricGIF.toObject 恒写大写 'GIF'(classRegistry 亦注册小写 'gif',兜底旧数据) */
97
+ export declare const GIF_TYPES: Set<string>;
98
+ /** FabricVideo.toObject 恒写 'Video'(小写兜底) */
99
+ export declare const VIDEO_TYPES: Set<string>;
@@ -0,0 +1,119 @@
1
+ /**
2
+ * 元素类型规范词表(小写规范形态)+装载期一次性小写化比较键。
3
+ *
4
+ * 双产源域不再逐集合枚举双形态:fabric 基类 toObject 写小写、自定义类
5
+ * toObject 恒大写(classRegistry 亦注册小写兜底旧数据)、PDF producer
6
+ * 场景级 'Path'(批次 357 正名)。历史方案是每族 Set 收双形态——漏一枚
7
+ * 即 buildScene 静默跳过(批次 338 表格线 / 357 path / 360 i-text 事故族)。
8
+ * 现统一为:比较一律走 typeKeyOf(raw)(raw 层,装载/序列化侧)或
9
+ * node.typeKey(节点层,构造期缓存 + set 写 type 重算),集合只收小写。
10
+ *
11
+ * 性能约束(批次 222 先例):帧循环热路径禁止逐比较 toLowerCase 分配
12
+ * 字符串——万级场景每帧万次分配;判定必须消费缓存键。
13
+ *
14
+ * 词表值域与主仓 ElementNames(@/types/elements)收敛:'ArcText'→'arctext'
15
+ * 等小写坍缩后两仓同一套词汇;'IText' 与 'itext' 小写同形坍缩同族。
16
+ * raw.type 原文不被改写(toObject/序列化保原大小写往返)。
17
+ */
18
+ export const ElementTypes = {
19
+ TEXTBOX: 'textbox',
20
+ TEXT: 'text',
21
+ /** fabric IText 基类 toObject 小写(与 INPUTTEXT 'itext' 是两个串) */
22
+ ITEXT: 'i-text',
23
+ INPUTTEXT: 'itext',
24
+ ARCHTEXT: 'archtext',
25
+ WAISTTEXT: 'waisttext',
26
+ FLAGTEXT: 'flagtext',
27
+ ARCTEXT: 'arctext',
28
+ CIRCLETEXT: 'circletext',
29
+ SCROLLTEXT: 'scrolltext',
30
+ /** 批次 314 图片文字:位图态(raw.renderSrc 在场)按图片口径 */
31
+ TEXTIMAGE: 'textimage',
32
+ IMAGE: 'image',
33
+ SVGIMAGE: 'svgimage',
34
+ CROPIMAGE: 'cropimage',
35
+ ECHART: 'echart',
36
+ FABRIC_ECHART: 'fabricechart',
37
+ QRCODE: 'qrcode',
38
+ BARCODE: 'barcode',
39
+ MASK: 'mask',
40
+ PATH: 'path',
41
+ RECT: 'rect',
42
+ FABRICRECT: 'fabricrect',
43
+ LINE: 'line',
44
+ ARROW: 'arrow',
45
+ POLYLINE: 'polyline',
46
+ POLYGON: 'polygon',
47
+ ELLIPSE: 'ellipse',
48
+ CIRCLE: 'circle',
49
+ TRIANGLE: 'triangle',
50
+ TABLE: 'table',
51
+ GROUP: 'group',
52
+ /** 多选态合成类型(fabric ActiveSelection 序列化形态;主仓 GroupTypeSets 消费) */
53
+ ACTIVE_SELECTION: 'activeselection',
54
+ PUZZLE: 'puzzle',
55
+ GIF: 'gif',
56
+ VIDEO: 'video',
57
+ DIMENSION: 'dimension',
58
+ REFERENCELINE: 'referenceline'
59
+ };
60
+ /** raw 层比较键(工厂/装载/序列化侧入口):一次性小写化;非串/缺席返 '' */
61
+ export const typeKeyOf = (raw) => {
62
+ const t = raw?.type;
63
+ return typeof t === 'string' ? t.toLowerCase() : '';
64
+ };
65
+ /** 文本族:textbox 有固定盒宽换行;itext/text 不换行(宽=最长行);
66
+ * 变形三类型(P4-5a)按 textbox 盒语义排版(warpStrength=0/编辑态走常规管线);
67
+ * 弧形/圆形(P4-5b)按 itext 语义排版(不换行),dims 走 arcLayout 的弧形 bbox;
68
+ * TextImage(批次 314 图片文字):PSD 导入的位图态文本——raw.renderSrc 在场时
69
+ * 渲染走位图 quad(零字体依赖),编辑态/转正后走常规字形管线;
70
+ * 'i-text'(fabric IText 基类 toObject 小写)=旧模板域兜底——漏收=旧模板
71
+ * 文本对象 buildScene 静默跳过(批次 360) */
72
+ export const TEXT_TYPES = new Set([
73
+ ElementTypes.TEXTBOX,
74
+ ElementTypes.INPUTTEXT,
75
+ ElementTypes.ITEXT,
76
+ ElementTypes.TEXT,
77
+ ElementTypes.ARCHTEXT,
78
+ ElementTypes.WAISTTEXT,
79
+ ElementTypes.FLAGTEXT,
80
+ ElementTypes.ARCTEXT,
81
+ ElementTypes.CIRCLETEXT,
82
+ ElementTypes.SCROLLTEXT,
83
+ ElementTypes.TEXTIMAGE
84
+ ]);
85
+ /** 序列化侧图片族(image/svgimage/cropimage/qrcode/barcode/echart 族;
86
+ * 'Image'/'QRCode'/'BarCode'/'FabricEchart' 等大写形态经 typeKeyOf 坍缩) */
87
+ export const IMAGE_LIKE_TYPES = new Set([
88
+ ElementTypes.IMAGE,
89
+ ElementTypes.SVGIMAGE,
90
+ ElementTypes.CROPIMAGE,
91
+ ElementTypes.QRCODE,
92
+ ElementTypes.BARCODE,
93
+ ElementTypes.ECHART,
94
+ ElementTypes.FABRIC_ECHART
95
+ ]);
96
+ /** 填充形状族(P3-1 + P3-6a):三角化网格渲染;line/arrow 无填充(描边族属 P3-2)暂不进。
97
+ * 'path' 是 fabric Path/FabricPath 与 PDF producer(批次 357 正名 'Path')双产源的
98
+ * 坍缩形态;'triangle'(fabric Triangle)按 width/height 合成三点多边形(ShapeNode 分支) */
99
+ export const SHAPE_TYPES = new Set([ElementTypes.ELLIPSE, ElementTypes.CIRCLE, ElementTypes.POLYGON, ElementTypes.POLYLINE, ElementTypes.PATH, ElementTypes.TRIANGLE]);
100
+ /** 路径族判定(批次 361 惯用法统一):单类型判断一律 `key === ElementTypes.PATH`
101
+ * 直比(单成员集合已退役);SHAPE_TYPES 同步收录 path 供 isShapeType 渲染/
102
+ * 阴影/命中门(SceneRenderer 形状分支按谓词分档,节点在而谓词 miss=不渲染) */
103
+ /** 线族(P3-6b):'Line' fabric toObject 与 'line' 历史小写坍缩同族;arrow/
104
+ * dimension/referenceline 是应用类注册名域(大写形态经 typeKeyOf 坍缩)。
105
+ * x1..y2 为中心相对坐标(calcLinePoints 恒等映射);渲染走描边烘焙(arrow/
106
+ * dimension 含端头/刻度/文本装饰) */
107
+ export const LINE_TYPES = new Set([ElementTypes.LINE, ElementTypes.ARROW, ElementTypes.DIMENSION, ElementTypes.REFERENCELINE]);
108
+ /** 填充实心族(rect/FabricRect 双产源坍缩) */
109
+ export const SOLID_TYPES = new Set([ElementTypes.RECT, ElementTypes.FABRICRECT]);
110
+ /** 蒙版族(P4-5b(2/2)):FabricMask.toObject 恒写 'Mask'(classRegistry 亦注册小写 'mask')。
111
+ * 不进 IMAGE_LIKE_TYPES——Mask 的 cropX/cropY 是裁剪态暂存(渲染走 clipX/clipY),
112
+ * 与图片族静态裁剪语义不同,imageCropRect 不适用 */
113
+ export const MASK_TYPES = new Set([ElementTypes.MASK]);
114
+ /** 拼图(P4-5b(2/2)):FabricPuzzle.toObject 恒写 'Puzzle'(小写兜底) */
115
+ export const PUZZLE_TYPES = new Set([ElementTypes.PUZZLE]);
116
+ /** 动画族(Phase 4):FabricGIF.toObject 恒写大写 'GIF'(classRegistry 亦注册小写 'gif',兜底旧数据) */
117
+ export const GIF_TYPES = new Set([ElementTypes.GIF]);
118
+ /** FabricVideo.toObject 恒写 'Video'(小写兜底) */
119
+ export const VIDEO_TYPES = new Set([ElementTypes.VIDEO]);
@@ -1,9 +1,10 @@
1
1
  import { GroupNode, isTextBitmapState, PuzzleNode, TableNode, TextNode } from './scene';
2
+ import { ElementTypes } from './elementTypes';
2
3
  import { invert, objectOriginFromCenter, transformPoint } from '../core/mat2d';
3
4
  /** 固定盒宽文本判定(批次 95 双口径:模板/compat 桥恒写 'Textbox' 大写;
4
5
  * 批次 314:转正后的 TextImage(renderSrc 已删)同盒宽语义——位图态不进,
5
6
  * 组改宽按图片口径走 scaleX 分支) */
6
- export const isFixedBoxTextNode = (node) => node instanceof TextNode && (node.raw.type === 'textbox' || node.raw.type === 'Textbox' || (node.raw.type === 'TextImage' && !isTextBitmapState(node)));
7
+ export const isFixedBoxTextNode = (node) => node instanceof TextNode && (node.typeKey === ElementTypes.TEXTBOX || (node.typeKey === ElementTypes.TEXTIMAGE && !isTextBitmapState(node)));
7
8
  /** 手势起点快照(pointerTransform.buildScaleSnapshot 的组分支消费) */
8
9
  export function buildGroupWidthSnapshot(node, sign) {
9
10
  const w = node.dims.x;
@@ -66,15 +66,12 @@ export declare const WORKSPACE_ID = "WorkSpaceDrawType";
66
66
  * 选区;selectable 不随序列化落 raw,引擎按 id 族等价过滤。框选(document.
67
67
  * objectsIntersectingRect)/selectAll/svgExport 整页过滤同源) */
68
68
  export declare const WORKSPACE_IDS: Set<string>;
69
- /** fabric 原生 toObject 恒写类名首字母大写('Image');小写为历史/种子口径兜底 */
70
- export declare const IMAGE_LIKE_TYPES: Set<string>;
71
- export declare const SOLID_TYPES: Set<string>;
72
- /** 文本族:textbox 有固定盒宽换行;itext/text 不换行(宽=最长行);
73
- * 变形三类型(P4-5a)按 textbox 盒语义排版(warpStrength=0/编辑态走常规管线);
74
- * 弧形/圆形(P4-5b)按 itext 语义排版(不换行),dims 走 arcLayout 的弧形 bbox;
75
- * TextImage(批次 314 图片文字):PSD 导入的位图态文本——raw.renderSrc 在场时
76
- * 渲染走位图 quad(零字体依赖),编辑态/转正后走常规字形管线 */
77
- export declare const TEXT_TYPES: Set<string>;
69
+ /** 元素类型词表与家族集合(小写规范形态)统一收口 model/elementTypes——
70
+ * 双产源域(fabric 基类 toObject 小写/自定义类 toObject 恒大写/PDF producer
71
+ * 'Path')不再逐集合枚举双形态,比较一律走 typeKeyOf(raw)/node.typeKey,
72
+ * 漏枚举=buildScene 静默跳过的事故族(338/357/360)就此根绝;产源注释
73
+ * 与家族语义见该模块。此处 re-export 维持既有消费面导入路径不变 */
74
+ export { ElementTypes, typeKeyOf, TEXT_TYPES, IMAGE_LIKE_TYPES, SOLID_TYPES, SHAPE_TYPES, LINE_TYPES, MASK_TYPES, PUZZLE_TYPES, GIF_TYPES, VIDEO_TYPES } from './elementTypes';
78
75
  /** 批次 314 图片文字:TextImage 位图态判定(raw.renderSrc 在场)——渲染/命中/
79
76
  * 手柄/组语义全按图片口径(缩放手势走 scale、不做文本烘焙);转正(renderSrc
80
77
  * 删除)后按文本口径(盒宽/字号烘焙、组改宽回流) */
@@ -88,14 +85,6 @@ export declare const isTextBitmapState: (node: SceneNode) => boolean;
88
85
  export declare const textBitmapFillAlpha: (raw: {
89
86
  fill?: unknown;
90
87
  } | Record<string, unknown>) => number;
91
- /** 填充形状族(P3-1 + P3-6a):三角化网格渲染;line/arrow 无填充(描边族属 P3-2)暂不进。
92
- * 'Path' 是 fabric Path/FabricPath 的 toObject type(classRegistry 注册名);
93
- * 'triangle'(fabric Triangle)按 width/height 合成三点多边形(ShapeNode 分支) */
94
- export declare const SHAPE_TYPES: Set<string>;
95
- /** 线族(P3-6b):'Line' 是 fabric toObject type;arrow/Dimension/ReferenceLine 是应用类注册名。
96
- * x1..y2 为中心相对坐标(calcLinePoints 恒等映射);渲染走描边烘焙(arrow/Dimension
97
- * 含端头/刻度/文本装饰) */
98
- export declare const LINE_TYPES: Set<string>;
99
88
  /** 参考线(批次 72):视口横贯的引导 chrome——fabric 侧画在工作区遮罩之上的
100
89
  * overlay 通道(fabricCanvas._renderWorkspaceOverlay),引擎同相位走
101
90
  * frameOverlay(SceneRenderer 跳过——±999999 的线超 bakeNodeStroke 8192
@@ -112,12 +101,6 @@ export declare const isReferenceLineNode: (node: SceneNode) => boolean;
112
101
  * axis:'horizontal' = 横线(at 为场景 y)/ 'vertical' = 竖线(at 为场景 x)
113
102
  */
114
103
  export declare const createReferenceLineRaw: (axis: "horizontal" | "vertical", at: number) => SerializedNode;
115
- /** 蒙版族(P4-5b(2/2)):FabricMask.toObject 恒写 'Mask'(classRegistry 亦注册小写 'mask')。
116
- * 不进 IMAGE_LIKE_TYPES——Mask 的 cropX/cropY 是裁剪态暂存(渲染走 clipX/clipY),
117
- * 与图片族静态裁剪语义不同,imageCropRect 不适用 */
118
- export declare const MASK_TYPES: Set<string>;
119
- /** 拼图(P4-5b(2/2)):FabricPuzzle.toObject 恒写 'Puzzle'(小写兜底) */
120
- export declare const PUZZLE_TYPES: Set<string>;
121
104
  export declare class SceneNode {
122
105
  readonly raw: SerializedNode;
123
106
  /** 合成节点标记(运行时位,不进 raw/序列化):节点由宿主侧以其他节点为源派生
@@ -144,6 +127,10 @@ export declare class SceneNode {
144
127
  * 基态恢复天然干净),null = 基态。生效汇聚点 transformProps/renderOpacity */
145
128
  private _animationOverride;
146
129
  constructor(raw: SerializedNode);
130
+ /** 类型比较键缓存(批次 360,全类型比较消费;set 写 type 时重算) */
131
+ private _typeKey;
132
+ /** 小写规范类型键(ElementTypes 口径)——类型比较一律经此,禁裸比 raw.type */
133
+ get typeKey(): string;
147
134
  /** 参考线判定缓存(批次 222,帧循环消费;set 写 type 时重算) */
148
135
  private _isReferenceLine;
149
136
  get isReferenceLine(): boolean;
@@ -985,7 +972,9 @@ export declare class PuzzleNode extends GroupNode {
985
972
  * (应用侧无此组合),不在此列。
986
973
  */
987
974
  export declare const imageCropRect: (raw: SerializedNode) => SourceRect | null;
988
- /** 节点工厂(buildScene 与 GroupNode 递归共用);未识别类型返回 null */
975
+ /** 节点工厂(buildScene 与 GroupNode 递归共用);未识别类型返回 null。
976
+ * 类型分派一律走 typeKeyOf 小写键(批次 360)——大写 toObject/小写历史/
977
+ * producer 'Path' 双产源统一坍缩承接,Table/Group 等单形态枚举位同口径 */
989
978
  export declare const createNode: (raw: SerializedNode) => SceneNode | null;
990
979
  export declare const buildScene: (objects: SerializedNode[]) => {
991
980
  nodes: SceneNode[];
@@ -47,19 +47,13 @@ export const WORKSPACE_ID = 'WorkSpaceDrawType';
47
47
  * 选区;selectable 不随序列化落 raw,引擎按 id 族等价过滤。框选(document.
48
48
  * objectsIntersectingRect)/selectAll/svgExport 整页过滤同源) */
49
49
  export const WORKSPACE_IDS = new Set(['WorkSpaceDrawType', 'WorkSpaceClipType', 'WorkSpaceSafeType', 'WorkSpaceMaskType', 'WorkSpaceLineType', 'WorkSpaceShadowType']);
50
- /** fabric 原生 toObject 恒写类名首字母大写('Image');小写为历史/种子口径兜底 */
51
- export const IMAGE_LIKE_TYPES = new Set(['image', 'Image', 'svgimage', 'cropimage', 'qrcode', 'QRCode', 'barcode', 'BarCode', 'echart', 'FabricEchart']);
52
- /** 动画族(Phase 4):FabricGIF.toObject 恒写大写 'GIF'(classRegistry 亦注册小写 'gif',兜底旧数据) */
53
- const GIF_TYPES = new Set(['GIF', 'gif']);
54
- /** FabricVideo.toObject 恒写 'Video'(小写兜底) */
55
- const VIDEO_TYPES = new Set(['Video', 'video']);
56
- export const SOLID_TYPES = new Set(['rect', 'Rect', 'fabricrect', 'FabricRect']);
57
- /** 文本族:textbox 有固定盒宽换行;itext/text 不换行(宽=最长行);
58
- * 变形三类型(P4-5a)按 textbox 盒语义排版(warpStrength=0/编辑态走常规管线);
59
- * 弧形/圆形(P4-5b)按 itext 语义排版(不换行),dims 走 arcLayout 的弧形 bbox;
60
- * TextImage(批次 314 图片文字):PSD 导入的位图态文本——raw.renderSrc 在场时
61
- * 渲染走位图 quad(零字体依赖),编辑态/转正后走常规字形管线 */
62
- export const TEXT_TYPES = new Set(['textbox', 'Textbox', 'itext', 'IText', 'text', 'Text', 'ArchText', 'WaistText', 'FlagText', 'ArcText', 'CircleText', 'ScrollText', 'scrollText', 'TextImage']);
50
+ /** 元素类型词表与家族集合(小写规范形态)统一收口 model/elementTypes——
51
+ * 双产源域(fabric 基类 toObject 小写/自定义类 toObject 恒大写/PDF producer
52
+ * 'Path')不再逐集合枚举双形态,比较一律走 typeKeyOf(raw)/node.typeKey,
53
+ * 漏枚举=buildScene 静默跳过的事故族(338/357/360)就此根绝;产源注释
54
+ * 与家族语义见该模块。此处 re-export 维持既有消费面导入路径不变 */
55
+ export { ElementTypes, typeKeyOf, TEXT_TYPES, IMAGE_LIKE_TYPES, SOLID_TYPES, SHAPE_TYPES, LINE_TYPES, MASK_TYPES, PUZZLE_TYPES, GIF_TYPES, VIDEO_TYPES } from './elementTypes';
56
+ import { ElementTypes, GIF_TYPES, VIDEO_TYPES, typeKeyOf, TEXT_TYPES, IMAGE_LIKE_TYPES, SOLID_TYPES, SHAPE_TYPES, LINE_TYPES, MASK_TYPES, PUZZLE_TYPES } from './elementTypes';
63
57
  /** 批次 314 图片文字:TextImage 位图态判定(raw.renderSrc 在场)——渲染/命中/
64
58
  * 手柄/组语义全按图片口径(缩放手势走 scale、不做文本烘焙);转正(renderSrc
65
59
  * 删除)后按文本口径(盒宽/字号烘焙、组改宽回流) */
@@ -76,14 +70,6 @@ export const textBitmapFillAlpha = (raw) => {
76
70
  return 1;
77
71
  return Math.max(0, Math.min(1, parseColor(fill)[3]));
78
72
  };
79
- /** 填充形状族(P3-1 + P3-6a):三角化网格渲染;line/arrow 无填充(描边族属 P3-2)暂不进。
80
- * 'Path' 是 fabric Path/FabricPath 的 toObject type(classRegistry 注册名);
81
- * 'triangle'(fabric Triangle)按 width/height 合成三点多边形(ShapeNode 分支) */
82
- export const SHAPE_TYPES = new Set(['ellipse', 'Ellipse', 'circle', 'Circle', 'polygon', 'Polygon', 'polyline', 'Polyline', 'Path', 'triangle', 'Triangle']);
83
- /** 线族(P3-6b):'Line' 是 fabric toObject type;arrow/Dimension/ReferenceLine 是应用类注册名。
84
- * x1..y2 为中心相对坐标(calcLinePoints 恒等映射);渲染走描边烘焙(arrow/Dimension
85
- * 含端头/刻度/文本装饰) */
86
- export const LINE_TYPES = new Set(['Line', 'arrow', 'Dimension', 'ReferenceLine']);
87
73
  /**
88
74
  * 纯姿态键(批次 221):只参与矩阵合成(origin/scale/skew/flip/rotate/translate),
89
75
  * 不改变任何本地几何/网格/路径轮廓/文本排版/填充语义。多选拖拽每 pointermove
@@ -196,12 +182,6 @@ export const createReferenceLineRaw = (axis, at) => ({
196
182
  lockMovementY: axis === 'vertical',
197
183
  hoverCursor: axis === 'horizontal' ? 'ns-resize' : 'ew-resize'
198
184
  });
199
- /** 蒙版族(P4-5b(2/2)):FabricMask.toObject 恒写 'Mask'(classRegistry 亦注册小写 'mask')。
200
- * 不进 IMAGE_LIKE_TYPES——Mask 的 cropX/cropY 是裁剪态暂存(渲染走 clipX/clipY),
201
- * 与图片族静态裁剪语义不同,imageCropRect 不适用 */
202
- export const MASK_TYPES = new Set(['Mask', 'mask']);
203
- /** 拼图(P4-5b(2/2)):FabricPuzzle.toObject 恒写 'Puzzle'(小写兜底) */
204
- export const PUZZLE_TYPES = new Set(['Puzzle', 'puzzle']);
205
185
  /** 序列化往返保留的字段(与 src/configs/canvas 的 propertiesToInclude 白名单对齐的核心子集) */
206
186
  const OWN_KEYS = [
207
187
  'type',
@@ -258,8 +238,17 @@ export class SceneNode {
258
238
  // FabricRect 族圆角源归一(批次 98):radius>0 时反算本地 rx/ry——fabric
259
239
  // render 每帧同式覆写,手写数据 radius/rx 不一致以 radius 为准
260
240
  normalizeFabricRectRadii(this.raw);
241
+ // 类型比较键(批次 360):构造期一次性小写化(帧循环热路径禁逐比较
242
+ // toLowerCase 分配——批次 222 先例);raw.type 原文不改写,toObject 往返保原大小写
243
+ this._typeKey = typeKeyOf(this.raw);
261
244
  // 参考线判定预计算(批次 222):type 构造后不变(set 带 type 键重算)
262
- this._isReferenceLine = typeof raw.type === 'string' && raw.type.toLowerCase() === 'referenceline';
245
+ this._isReferenceLine = this._typeKey === ElementTypes.REFERENCELINE;
246
+ }
247
+ /** 类型比较键缓存(批次 360,全类型比较消费;set 写 type 时重算) */
248
+ _typeKey;
249
+ /** 小写规范类型键(ElementTypes 口径)——类型比较一律经此,禁裸比 raw.type */
250
+ get typeKey() {
251
+ return this._typeKey;
263
252
  }
264
253
  /** 参考线判定缓存(批次 222,帧循环消费;set 写 type 时重算) */
265
254
  _isReferenceLine;
@@ -311,8 +300,10 @@ export class SceneNode {
311
300
  this._fillPaint = undefined;
312
301
  this._strokeDecl = undefined;
313
302
  }
314
- if ('type' in props && typeof props.type === 'string')
315
- this._isReferenceLine = props.type.toLowerCase() === 'referenceline';
303
+ if ('type' in props) {
304
+ this._typeKey = typeKeyOf(props);
305
+ this._isReferenceLine = this._typeKey === ElementTypes.REFERENCELINE;
306
+ }
316
307
  this._renderNotify?.();
317
308
  }
318
309
  /** 动画覆写写入(P5-6 播放器逐帧调用;null 清除回基态)。矩阵/aCoords/
@@ -327,22 +318,22 @@ export class SceneNode {
327
318
  return typeof this.raw.id === 'string' ? this.raw.id : '';
328
319
  }
329
320
  get isImageType() {
330
- return IMAGE_LIKE_TYPES.has(this.raw.type);
321
+ return IMAGE_LIKE_TYPES.has(this.typeKey);
331
322
  }
332
323
  get isMaskType() {
333
- return MASK_TYPES.has(this.raw.type);
324
+ return MASK_TYPES.has(this.typeKey);
334
325
  }
335
326
  get isSolidType() {
336
- return SOLID_TYPES.has(this.raw.type);
327
+ return SOLID_TYPES.has(this.typeKey);
337
328
  }
338
329
  get isTextType() {
339
- return TEXT_TYPES.has(this.raw.type);
330
+ return TEXT_TYPES.has(this.typeKey);
340
331
  }
341
332
  get isLineType() {
342
- return LINE_TYPES.has(this.raw.type);
333
+ return LINE_TYPES.has(this.typeKey);
343
334
  }
344
335
  get isShapeType() {
345
- return SHAPE_TYPES.has(this.raw.type);
336
+ return SHAPE_TYPES.has(this.typeKey);
346
337
  }
347
338
  get visible() {
348
339
  return this.raw.visible !== false;
@@ -729,7 +720,7 @@ export class TextNode extends SceneNode {
729
720
  if (!this._layout) {
730
721
  const raw = this.raw;
731
722
  this._layout = layoutTextbox(raw.text ?? '', this.textStyle, {
732
- boxWidth: raw.type === 'textbox' || raw.type === 'Textbox' || raw.type === 'TextImage' ? raw.width ?? 0 : null,
723
+ boxWidth: typeKeyOf(raw) === ElementTypes.TEXTBOX || typeKeyOf(raw) === ElementTypes.TEXTIMAGE ? raw.width ?? 0 : null,
733
724
  styles: raw.styles,
734
725
  splitByGrapheme: raw.splitByGrapheme === true,
735
726
  vertical: raw.vertical === true,
@@ -1077,7 +1068,7 @@ export class ShapeNode extends SceneNode {
1077
1068
  }
1078
1069
  /** 形状族类型归一:椭圆/圆几何分支按小写比对(toObject 恒写注册名,大小写混档) */
1079
1070
  get shapeKind() {
1080
- return typeof this.raw.type === 'string' ? this.raw.type.toLowerCase() : '';
1071
+ return this.typeKey;
1081
1072
  }
1082
1073
  /** 三角化网格(懒构建;退化形状返回 null,渲染与命中按空处理) */
1083
1074
  get shapeMesh() {
@@ -1255,8 +1246,8 @@ export const LINE_STROKE_HIT_TOLERANCE = 8;
1255
1246
  * dimension 是引擎超集(app 未列——其同为细杆元素且引擎已有端刻/文本框
1256
1247
  * 装饰命中,方向=更易选中)。ReferenceLine 排除(辅助层自有拖拽交互)。 */
1257
1248
  export const isStrokeLineNode = (node) => {
1258
- const t = typeof node.raw.type === 'string' ? node.raw.type.toLowerCase() : '';
1259
- if (t === 'line' || t === 'arrow' || t === 'dimension' || t === 'polyline')
1249
+ const t = node.typeKey;
1250
+ if (t === ElementTypes.LINE || t === ElementTypes.ARROW || t === ElementTypes.DIMENSION || t === ElementTypes.POLYLINE)
1260
1251
  return true;
1261
1252
  // 形状/Path 填充有效透明(批次 345;旧判据只认空串/'transparent' 字串):
1262
1253
  // 命中退化为描边带 → 索引框按命中带外扩,带外命中不被预筛滤掉
@@ -1489,7 +1480,7 @@ export class LineNode extends SceneNode {
1489
1480
  if (Math.hypot(local.x - px, local.y - py) <= r)
1490
1481
  return true;
1491
1482
  // 装饰命中扩展:类型键小写归一(批次46 勘注——raw 两形态并存)
1492
- const rawType = typeof this.raw.type === 'string' ? this.raw.type.toLowerCase() : '';
1483
+ const rawType = this.typeKey;
1493
1484
  if (rawType === 'arrow')
1494
1485
  return arrowHeadHit(this.raw, local, p);
1495
1486
  if (rawType === 'dimension')
@@ -2281,13 +2272,10 @@ export class MaskNode extends SceneNode {
2281
2272
  clipDynamicVersion = 0;
2282
2273
  /** clipImage 是否动态源(Video/GIF;序列化 type 口径同应用 getIsDynamicElement) */
2283
2274
  get clipDynamicKind() {
2284
- const t = this.clipImageRaw?.type;
2285
- if (typeof t !== 'string')
2286
- return null;
2287
- const lower = t.toLowerCase();
2288
- if (lower === 'video')
2275
+ const t = typeKeyOf(this.clipImageRaw);
2276
+ if (t === ElementTypes.VIDEO)
2289
2277
  return 'video';
2290
- if (lower === 'gif')
2278
+ if (t === ElementTypes.GIF)
2291
2279
  return 'gif';
2292
2280
  return null;
2293
2281
  }
@@ -2753,7 +2741,7 @@ export class PuzzleNode extends GroupNode {
2753
2741
  * (应用侧无此组合),不在此列。
2754
2742
  */
2755
2743
  export const imageCropRect = (raw) => {
2756
- if (!IMAGE_LIKE_TYPES.has(raw.type))
2744
+ if (!IMAGE_LIKE_TYPES.has(typeKeyOf(raw)))
2757
2745
  return null;
2758
2746
  const cropX = Number(raw.cropX) || 0;
2759
2747
  const cropY = Number(raw.cropY) || 0;
@@ -2769,33 +2757,36 @@ export const imageCropRect = (raw) => {
2769
2757
  sh: Math.max(0, visible ? raw.height : raw.height - cropY)
2770
2758
  };
2771
2759
  };
2772
- /** 节点工厂(buildScene 与 GroupNode 递归共用);未识别类型返回 null */
2760
+ /** 节点工厂(buildScene 与 GroupNode 递归共用);未识别类型返回 null。
2761
+ * 类型分派一律走 typeKeyOf 小写键(批次 360)——大写 toObject/小写历史/
2762
+ * producer 'Path' 双产源统一坍缩承接,Table/Group 等单形态枚举位同口径 */
2773
2763
  export const createNode = (raw) => {
2774
2764
  if (!raw || typeof raw.type !== 'string')
2775
2765
  return null;
2776
- if (raw.type === 'Table')
2766
+ const t = typeKeyOf(raw);
2767
+ if (t === ElementTypes.TABLE)
2777
2768
  return new TableNode(raw, createNode);
2778
- if (PUZZLE_TYPES.has(raw.type))
2769
+ if (PUZZLE_TYPES.has(t))
2779
2770
  return new PuzzleNode(raw, createNode);
2780
- if (MASK_TYPES.has(raw.type) && typeof raw.src === 'string')
2771
+ if (MASK_TYPES.has(t) && typeof raw.src === 'string')
2781
2772
  return new MaskNode(raw);
2782
- if (raw.type === 'Group' || raw.type === 'group')
2773
+ if (t === ElementTypes.GROUP)
2783
2774
  return new GroupNode(raw, createNode);
2784
- if (GIF_TYPES.has(raw.type) && typeof raw.src === 'string')
2775
+ if (GIF_TYPES.has(t) && typeof raw.src === 'string')
2785
2776
  return new AnimatedNode(raw, 'gif');
2786
- if (VIDEO_TYPES.has(raw.type) && typeof raw.src === 'string')
2777
+ if (VIDEO_TYPES.has(t) && typeof raw.src === 'string')
2787
2778
  return new AnimatedNode(raw, 'video');
2788
- if (IMAGE_LIKE_TYPES.has(raw.type) && typeof raw.src === 'string')
2779
+ if (IMAGE_LIKE_TYPES.has(t) && typeof raw.src === 'string')
2789
2780
  return new SceneNode(raw);
2790
- if (SOLID_TYPES.has(raw.type))
2781
+ if (SOLID_TYPES.has(t))
2791
2782
  return new SceneNode(raw);
2792
- if (TEXT_TYPES.has(raw.type) && typeof raw.text === 'string')
2783
+ if (TEXT_TYPES.has(t) && typeof raw.text === 'string')
2793
2784
  return new TextNode(raw);
2794
- if (raw.type === 'Path')
2785
+ if (t === ElementTypes.PATH)
2795
2786
  return new PathNode(raw);
2796
- if (LINE_TYPES.has(raw.type))
2787
+ if (LINE_TYPES.has(t))
2797
2788
  return new LineNode(raw);
2798
- if (SHAPE_TYPES.has(raw.type))
2789
+ if (SHAPE_TYPES.has(t))
2799
2790
  return new ShapeNode(raw);
2800
2791
  return null;
2801
2792
  };
@@ -41,6 +41,9 @@ export interface FrameOverlayInput {
41
41
  /** 旋转手势覆盖态(pointer 手势期写宿主 rotateDrag 转发):mtr 冻结位 +
42
42
  * 角度气泡中心——null = 非旋转手势期,常规手柄布局 */
43
43
  rotate?: RotateGestureOverlay | null;
44
+ /** 移动端控件面(批次 354):true 时单选常规族选区右中出移动图标柄
45
+ * (fabric moveControls 的 move 控件——app fabricConf hasMobile 门引擎面) */
46
+ mobileControls?: boolean;
44
47
  /** 标尺参数(P5-3;null = 关);referenceLine=拖拽中的线位气泡态(批次 72) */
45
48
  ruler: {
46
49
  vpt: Mat;
@@ -69,7 +69,7 @@ export const buildFrameOverlay = (input) => {
69
69
  ? buildMarqueeOverlay(marquee, zoom)
70
70
  : maskEditPuzzle?.editingMask
71
71
  ? buildPuzzleMaskEditOverlay(maskEditPuzzle, zoom, rotate)
72
- : buildSelectionOverlay(doc, zoom, rotate);
72
+ : buildSelectionOverlay(doc, zoom, rotate, input.mobileControls === true);
73
73
  // 组内子文本编辑中:顶组虚线框保持可见(app renderTopGroupControls 在编辑态
74
74
  // 仍绘制——activeObject 仍在组内;守卫用「编辑节点=单选组后代」不依赖
75
75
  // activeGroupChild(enterEditing 直入路径不设激活子))
@@ -57,6 +57,9 @@ export interface OverlayTailHost {
57
57
  y: number;
58
58
  };
59
59
  } | null;
60
+ /** 移动端控件面(批次 354):EngineCanvasOptions.mobileControls 直通——选区
61
+ * 右中移动图标柄(渲染/命中共源,pointer 侧读 PointerHost.mobileControls) */
62
+ readonly mobileControls: boolean;
60
63
  readonly rulerVisible: boolean;
61
64
  readonly referenceLineDrag: {
62
65
  axis: 'horizontal' | 'vertical';
@@ -71,6 +71,7 @@ export function finishFrameOverlay(host) {
71
71
  cellEditOverlayOnly: editingNode !== null && host.tableCellEditing.isOverlay(editingNode),
72
72
  snapOverlay: host.snapGuide.buildOverlay(host.zoom),
73
73
  rotate: host.rotateDrag,
74
+ mobileControls: host.mobileControls,
74
75
  ruler: host.rulerVisible ? { vpt: host.vpt, cssWidth: host.cssWidth, cssHeight: host.cssHeight, referenceLine: host.referenceLineDrag } : null
75
76
  });
76
77
  pushOverlayAndContinue(host, overlay);
@@ -19,6 +19,7 @@ import { parsePsdEffects, psdEffectsKey } from '../core/psdEffects';
19
19
  import { composeMatrix, multiply } from '../core/mat2d';
20
20
  import { isGpuPsdFillEnabled, isGpuPsdShadowEnabled } from '../engineFlag';
21
21
  import { AnimatedNode, MaskNode, TextNode, isTextBitmapState } from '../model/scene';
22
+ import { ElementTypes } from '../model/elementTypes';
22
23
  import { pickZoomBucket } from './GlyphAtlas';
23
24
  import { bakePathEffectShadow, bakePsdShadow, bakePsdSolidFill, bakePsdStrokes, buildTextEffectSource, strokeSupersampleCap, imageFiltersSig } from './imageEffects';
24
25
  import { createTexture2D } from './textureUpload';
@@ -100,7 +101,7 @@ export class PsdEffectPainter {
100
101
  // Mask PSD effects(B1(余) 收尾片):drawShadows/drawFills/drawStrokes 的
101
102
  // 蒙版链——投影垫底(形状源)、填充/描边盖合成层(应用 render() 覆写序)
102
103
  const isMaskFx = node instanceof MaskNode;
103
- if (!node.isImageType && node.raw.type !== 'Path' && !isTextFx && !isMaskFx)
104
+ if (!node.isImageType && node.typeKey !== ElementTypes.PATH && !isTextFx && !isMaskFx)
104
105
  return;
105
106
  if (phase === 'above' && !node.isImageType && !isTextFx && !isMaskFx)
106
107
  return;