ice-render 1.0.4 → 1.0.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (145) hide show
  1. package/LICENSE +0 -0
  2. package/README.md +229 -141
  3. package/dist/THIRD-PARTY-NOTICES.txt +32 -0
  4. package/dist/index.cjs +30 -0
  5. package/dist/index.mjs +30 -0
  6. package/dist/index.umd.js +6 -1
  7. package/dist/types/FrameManager.d.mts +26 -0
  8. package/dist/types/FrameManager.d.ts +26 -26
  9. package/dist/types/ICE.d.mts +369 -0
  10. package/dist/types/ICE.d.ts +369 -107
  11. package/dist/types/a11y/accessibility.d.mts +46 -0
  12. package/dist/types/a11y/accessibility.d.ts +46 -0
  13. package/dist/types/animation/AnimationManager.d.mts +96 -0
  14. package/dist/types/animation/AnimationManager.d.ts +96 -25
  15. package/dist/types/animation/Easing.d.mts +33 -0
  16. package/dist/types/animation/Easing.d.ts +33 -32
  17. package/dist/types/consts/BIG_ZINDEX_NUMBER.d.mts +14 -0
  18. package/dist/types/consts/BIG_ZINDEX_NUMBER.d.ts +14 -14
  19. package/dist/types/consts/COMPONENT_TYPE_MAPPING.d.mts +45 -0
  20. package/dist/types/consts/COMPONENT_TYPE_MAPPING.d.ts +45 -36
  21. package/dist/types/consts/DOM_EVENT_MAPPING_CONSTS.d.mts +37 -0
  22. package/dist/types/consts/DOM_EVENT_MAPPING_CONSTS.d.ts +37 -19
  23. package/dist/types/consts/ICE_EVENT_NAME_CONSTS.d.mts +27 -0
  24. package/dist/types/consts/ICE_EVENT_NAME_CONSTS.d.ts +27 -20
  25. package/dist/types/control-panel/AlignmentGuideManager.d.mts +92 -0
  26. package/dist/types/control-panel/AlignmentGuideManager.d.ts +92 -0
  27. package/dist/types/control-panel/ICEControlPanel.d.mts +37 -0
  28. package/dist/types/control-panel/ICEControlPanel.d.ts +37 -37
  29. package/dist/types/control-panel/ICEControlPanelManager.d.mts +25 -0
  30. package/dist/types/control-panel/ICEControlPanelManager.d.ts +25 -23
  31. package/dist/types/control-panel/link-controls/LineControlPanel.d.mts +39 -0
  32. package/dist/types/control-panel/link-controls/LineControlPanel.d.ts +39 -39
  33. package/dist/types/control-panel/transform-controls/ResizeControl.d.mts +38 -0
  34. package/dist/types/control-panel/transform-controls/ResizeControl.d.ts +38 -38
  35. package/dist/types/control-panel/transform-controls/RotateControl.d.mts +12 -0
  36. package/dist/types/control-panel/transform-controls/RotateControl.d.ts +12 -12
  37. package/dist/types/control-panel/transform-controls/TransformControlPanel.d.mts +83 -0
  38. package/dist/types/control-panel/transform-controls/TransformControlPanel.d.ts +83 -74
  39. package/dist/types/control-panel/transform-controls/constraints.d.mts +24 -0
  40. package/dist/types/control-panel/transform-controls/constraints.d.ts +24 -0
  41. package/dist/types/cross-platform/PolyfillPath2D.d.mts +31 -0
  42. package/dist/types/cross-platform/PolyfillPath2D.d.ts +31 -0
  43. package/dist/types/cross-platform/root.d.mts +7 -0
  44. package/dist/types/cross-platform/root.d.ts +7 -2
  45. package/dist/types/event/DOMEventDispatcher.d.mts +68 -0
  46. package/dist/types/event/DOMEventDispatcher.d.ts +68 -29
  47. package/dist/types/event/DOMEventInterceptor.d.mts +36 -0
  48. package/dist/types/event/DOMEventInterceptor.d.ts +36 -7
  49. package/dist/types/event/EventBus.d.mts +27 -0
  50. package/dist/types/event/EventBus.d.ts +27 -27
  51. package/dist/types/event/ICEEvent.d.mts +46 -0
  52. package/dist/types/event/ICEEvent.d.ts +46 -46
  53. package/dist/types/event/ICEEventTarget.d.mts +106 -0
  54. package/dist/types/event/ICEEventTarget.d.ts +106 -106
  55. package/dist/types/event/input-normalize.d.mts +75 -0
  56. package/dist/types/event/input-normalize.d.ts +75 -0
  57. package/dist/types/geometry/GeoLine.d.mts +24 -0
  58. package/dist/types/geometry/GeoLine.d.ts +24 -23
  59. package/dist/types/geometry/GeoPoint.d.mts +53 -0
  60. package/dist/types/geometry/GeoPoint.d.ts +53 -66
  61. package/dist/types/geometry/GeoUtil.d.mts +73 -0
  62. package/dist/types/geometry/GeoUtil.d.ts +73 -37
  63. package/dist/types/geometry/ICEBoundingBox.d.mts +81 -0
  64. package/dist/types/geometry/ICEBoundingBox.d.ts +81 -81
  65. package/dist/types/graphic/ICEComponent.d.mts +436 -0
  66. package/dist/types/graphic/ICEComponent.d.ts +436 -264
  67. package/dist/types/graphic/ICEDotPath.d.mts +99 -0
  68. package/dist/types/graphic/ICEDotPath.d.ts +99 -63
  69. package/dist/types/graphic/ICEImage.d.mts +17 -0
  70. package/dist/types/graphic/ICEImage.d.ts +17 -17
  71. package/dist/types/graphic/ICEPath.d.mts +39 -0
  72. package/dist/types/graphic/ICEPath.d.ts +39 -36
  73. package/dist/types/graphic/container/ICEGroup.d.mts +101 -0
  74. package/dist/types/graphic/container/ICEGroup.d.ts +101 -53
  75. package/dist/types/graphic/link/ICEBezier.d.mts +23 -0
  76. package/dist/types/graphic/link/ICEBezier.d.ts +23 -15
  77. package/dist/types/graphic/link/ICELinkHook.d.mts +52 -0
  78. package/dist/types/graphic/link/ICELinkHook.d.ts +52 -52
  79. package/dist/types/graphic/link/ICELinkSlot.d.mts +54 -0
  80. package/dist/types/graphic/link/ICELinkSlot.d.ts +54 -46
  81. package/dist/types/graphic/link/ICELinkSlotManager.d.mts +28 -0
  82. package/dist/types/graphic/link/ICELinkSlotManager.d.ts +28 -28
  83. package/dist/types/graphic/link/ICEPolyLine.d.mts +292 -0
  84. package/dist/types/graphic/link/ICEPolyLine.d.ts +292 -219
  85. package/dist/types/graphic/link/ICEVisioLink.d.mts +163 -0
  86. package/dist/types/graphic/link/ICEVisioLink.d.ts +163 -129
  87. package/dist/types/graphic/shape/ICECircle.d.mts +19 -0
  88. package/dist/types/graphic/shape/ICECircle.d.ts +19 -19
  89. package/dist/types/graphic/shape/ICEEllipse.d.mts +29 -0
  90. package/dist/types/graphic/shape/ICEEllipse.d.ts +29 -23
  91. package/dist/types/graphic/shape/ICEIsogon.d.mts +52 -0
  92. package/dist/types/graphic/shape/ICEIsogon.d.ts +52 -52
  93. package/dist/types/graphic/shape/ICERect.d.mts +10 -0
  94. package/dist/types/graphic/shape/ICERect.d.ts +10 -17
  95. package/dist/types/graphic/shape/ICERose.d.mts +41 -0
  96. package/dist/types/graphic/shape/ICERose.d.ts +41 -41
  97. package/dist/types/graphic/shape/ICEStar.d.mts +45 -0
  98. package/dist/types/graphic/shape/ICEStar.d.ts +45 -45
  99. package/dist/types/graphic/text/ICEText.d.mts +137 -0
  100. package/dist/types/graphic/text/ICEText.d.ts +137 -65
  101. package/dist/types/index.d.mts +55 -0
  102. package/dist/types/index.d.ts +55 -41
  103. package/dist/types/layout/ICEBorderLayout.d.mts +34 -0
  104. package/dist/types/layout/ICEBorderLayout.d.ts +34 -0
  105. package/dist/types/layout/ICEBoxLayout.d.mts +30 -0
  106. package/dist/types/layout/ICEBoxLayout.d.ts +30 -0
  107. package/dist/types/layout/ICECardLayout.d.mts +36 -0
  108. package/dist/types/layout/ICECardLayout.d.ts +36 -0
  109. package/dist/types/layout/ICEFlowLayout.d.mts +31 -0
  110. package/dist/types/layout/ICEFlowLayout.d.ts +31 -0
  111. package/dist/types/layout/ICEGridLayout.d.mts +33 -0
  112. package/dist/types/layout/ICEGridLayout.d.ts +33 -0
  113. package/dist/types/layout/ICELayeredLayout.d.mts +49 -0
  114. package/dist/types/layout/ICELayeredLayout.d.ts +49 -0
  115. package/dist/types/layout/ICELayoutManager.d.mts +33 -0
  116. package/dist/types/layout/ICELayoutManager.d.ts +33 -0
  117. package/dist/types/layout/ICEOverlayLayout.d.mts +25 -0
  118. package/dist/types/layout/ICEOverlayLayout.d.ts +25 -0
  119. package/dist/types/persistence/Deserializer.d.mts +43 -0
  120. package/dist/types/persistence/Deserializer.d.ts +43 -14
  121. package/dist/types/persistence/Serializer.d.mts +35 -0
  122. package/dist/types/persistence/Serializer.d.ts +35 -26
  123. package/dist/types/plugin/PluginHost.d.mts +86 -0
  124. package/dist/types/plugin/PluginHost.d.ts +86 -0
  125. package/dist/types/renderer/CanvasRenderer.d.mts +150 -0
  126. package/dist/types/renderer/CanvasRenderer.d.ts +150 -22
  127. package/dist/types/renderer/ObjectCache.d.mts +79 -0
  128. package/dist/types/renderer/ObjectCache.d.ts +79 -0
  129. package/dist/types/renderer/dirty-rect-util.d.mts +86 -0
  130. package/dist/types/renderer/dirty-rect-util.d.ts +86 -0
  131. package/dist/types/theme/ICETheme.d.mts +382 -0
  132. package/dist/types/theme/ICETheme.d.ts +382 -0
  133. package/dist/types/util/ImageCache.d.mts +19 -0
  134. package/dist/types/util/ImageCache.d.ts +19 -19
  135. package/dist/types/util/data-util.d.mts +43 -0
  136. package/dist/types/util/data-util.d.ts +43 -19
  137. package/dist/types/util/gl-matrix-skew.d.mts +14 -0
  138. package/dist/types/util/gl-matrix-skew.d.ts +14 -14
  139. package/dist/types/util/lang.d.mts +28 -0
  140. package/dist/types/util/lang.d.ts +28 -0
  141. package/dist/types/util/uuid.d.mts +1 -0
  142. package/dist/types/util/uuid.d.ts +1 -1
  143. package/package.json +118 -81
  144. package/dist/index.cjs.js +0 -25
  145. package/dist/index.js +0 -25
@@ -0,0 +1,33 @@
1
+ /**
2
+ * Copyright (c) 2022 大漠穷秋.
3
+ *
4
+ * This source code is licensed under the MIT license found in the
5
+ * LICENSE file in the root directory of this source tree.
6
+ *
7
+ */
8
+ import type ICEGroup from '../graphic/container/ICEGroup.mjs';
9
+ import ICELayoutManager from './ICELayoutManager.mjs';
10
+ /**
11
+ * @class ICEGridLayout 网格布局
12
+ *
13
+ * 对齐 Java Swing 的 GridLayout:把容器分成 cols 列,子组件按「行优先」依次填入网格。
14
+ * 每行高度取该行最高子组件,行间 gapY 间距,列间 gapX 间距。
15
+ *
16
+ * @author 大漠穷秋<damoqiongqiu@126.com>
17
+ */
18
+ declare class ICEGridLayout extends ICELayoutManager {
19
+ private cols;
20
+ private gapX;
21
+ private gapY;
22
+ constructor(props?: {
23
+ cols?: number;
24
+ gapX?: number;
25
+ gapY?: number;
26
+ });
27
+ /**
28
+ * @overwrite
29
+ * 按「行优先」把子组件填入 cols 列网格。
30
+ */
31
+ layoutContainer(container: ICEGroup): void;
32
+ }
33
+ export default ICEGridLayout;
@@ -0,0 +1,33 @@
1
+ /**
2
+ * Copyright (c) 2022 大漠穷秋.
3
+ *
4
+ * This source code is licensed under the MIT license found in the
5
+ * LICENSE file in the root directory of this source tree.
6
+ *
7
+ */
8
+ import type ICEGroup from '../graphic/container/ICEGroup';
9
+ import ICELayoutManager from './ICELayoutManager';
10
+ /**
11
+ * @class ICEGridLayout 网格布局
12
+ *
13
+ * 对齐 Java Swing 的 GridLayout:把容器分成 cols 列,子组件按「行优先」依次填入网格。
14
+ * 每行高度取该行最高子组件,行间 gapY 间距,列间 gapX 间距。
15
+ *
16
+ * @author 大漠穷秋<damoqiongqiu@126.com>
17
+ */
18
+ declare class ICEGridLayout extends ICELayoutManager {
19
+ private cols;
20
+ private gapX;
21
+ private gapY;
22
+ constructor(props?: {
23
+ cols?: number;
24
+ gapX?: number;
25
+ gapY?: number;
26
+ });
27
+ /**
28
+ * @overwrite
29
+ * 按「行优先」把子组件填入 cols 列网格。
30
+ */
31
+ layoutContainer(container: ICEGroup): void;
32
+ }
33
+ export default ICEGridLayout;
@@ -0,0 +1,49 @@
1
+ /**
2
+ * Copyright (c) 2022 大漠穷秋.
3
+ *
4
+ * This source code is licensed under the MIT license found in the
5
+ * LICENSE file in the root directory of this source tree.
6
+ *
7
+ */
8
+ import type ICEGroup from '../graphic/container/ICEGroup.mjs';
9
+ import ICELayoutManager from './ICELayoutManager.mjs';
10
+ /**
11
+ * @class ICELayeredLayout 分层图布局(dagre 式)
12
+ *
13
+ * 用于「图」场景(节点 + 边,如流程图/ER 图),借鉴 dagre 的分层布局思想:
14
+ * 1. 拓扑分层(最长路径法):有向边总是从低层指向高层,源在左、汇在右;
15
+ * 2. 层内排序(重心法):迭代调整每层节点顺序,减少边交叉;
16
+ * 3. 算坐标:层号 → left,层内序号 → top(LR 方向)。
17
+ *
18
+ * 与 Swing 的「容器布局」(Flow/Grid/Border)不同,本类面向「图」,作为策略框架里的一个特殊实现。
19
+ *
20
+ * @author 大漠穷秋<damoqiongqiu@126.com>
21
+ */
22
+ declare class ICELayeredLayout extends ICELayoutManager {
23
+ private gapX;
24
+ private gapY;
25
+ constructor(props?: {
26
+ gapX?: number;
27
+ gapY?: number;
28
+ });
29
+ /**
30
+ * @overwrite
31
+ * 读容器里的节点(非连线组件)+ 边(ICEPolyLine 的 links),分层布局后 setState 落位。
32
+ */
33
+ layoutContainer(container: ICEGroup): void;
34
+ /**
35
+ * 拓扑分层(最长路径法):rank = 所有前驱的最大 rank + 1;无前驱为 0。
36
+ * 用 visiting 集合处理有向环。
37
+ */
38
+ private assignRanks;
39
+ /**
40
+ * 层内排序(重心法):迭代把每层节点按「下一层邻居的平均 order」排序,减少边交叉。
41
+ */
42
+ private assignOrders;
43
+ /**
44
+ * 算坐标(LR 方向):rank 递增 → left 递增;层内按 order 垂直排列。
45
+ * 节点落位后,把每条边(连线)的端点对齐到源/目标节点的插槽(全局坐标)。
46
+ */
47
+ private assignCoords;
48
+ }
49
+ export default ICELayeredLayout;
@@ -0,0 +1,49 @@
1
+ /**
2
+ * Copyright (c) 2022 大漠穷秋.
3
+ *
4
+ * This source code is licensed under the MIT license found in the
5
+ * LICENSE file in the root directory of this source tree.
6
+ *
7
+ */
8
+ import type ICEGroup from '../graphic/container/ICEGroup';
9
+ import ICELayoutManager from './ICELayoutManager';
10
+ /**
11
+ * @class ICELayeredLayout 分层图布局(dagre 式)
12
+ *
13
+ * 用于「图」场景(节点 + 边,如流程图/ER 图),借鉴 dagre 的分层布局思想:
14
+ * 1. 拓扑分层(最长路径法):有向边总是从低层指向高层,源在左、汇在右;
15
+ * 2. 层内排序(重心法):迭代调整每层节点顺序,减少边交叉;
16
+ * 3. 算坐标:层号 → left,层内序号 → top(LR 方向)。
17
+ *
18
+ * 与 Swing 的「容器布局」(Flow/Grid/Border)不同,本类面向「图」,作为策略框架里的一个特殊实现。
19
+ *
20
+ * @author 大漠穷秋<damoqiongqiu@126.com>
21
+ */
22
+ declare class ICELayeredLayout extends ICELayoutManager {
23
+ private gapX;
24
+ private gapY;
25
+ constructor(props?: {
26
+ gapX?: number;
27
+ gapY?: number;
28
+ });
29
+ /**
30
+ * @overwrite
31
+ * 读容器里的节点(非连线组件)+ 边(ICEPolyLine 的 links),分层布局后 setState 落位。
32
+ */
33
+ layoutContainer(container: ICEGroup): void;
34
+ /**
35
+ * 拓扑分层(最长路径法):rank = 所有前驱的最大 rank + 1;无前驱为 0。
36
+ * 用 visiting 集合处理有向环。
37
+ */
38
+ private assignRanks;
39
+ /**
40
+ * 层内排序(重心法):迭代把每层节点按「下一层邻居的平均 order」排序,减少边交叉。
41
+ */
42
+ private assignOrders;
43
+ /**
44
+ * 算坐标(LR 方向):rank 递增 → left 递增;层内按 order 垂直排列。
45
+ * 节点落位后,把每条边(连线)的端点对齐到源/目标节点的插槽(全局坐标)。
46
+ */
47
+ private assignCoords;
48
+ }
49
+ export default ICELayeredLayout;
@@ -0,0 +1,33 @@
1
+ /**
2
+ * Copyright (c) 2022 大漠穷秋.
3
+ *
4
+ * This source code is licensed under the MIT license found in the
5
+ * LICENSE file in the root directory of this source tree.
6
+ *
7
+ */
8
+ import type ICEGroup from '../graphic/container/ICEGroup.mjs';
9
+ /**
10
+ * @class ICELayoutManager 布局管理器(抽象基类)
11
+ *
12
+ * 借鉴 Java Swing 的 LayoutManager 设计思想——**策略模式**:
13
+ * - 组件(ICEComponent)只负责「画自己」,不碰布局;
14
+ * - 容器(ICEGroup)只负责「持有子组件」,通过 setLayout() 持有布局策略;
15
+ * - 布局管理器(本类及其子类)只负责「摆位置」。
16
+ *
17
+ * 核心只有一个方法 layoutContainer(container):给定容器,计算并设置所有子组件的位置/尺寸。
18
+ *
19
+ * @author 大漠穷秋<damoqiongqiu@126.com>
20
+ */
21
+ declare abstract class ICELayoutManager {
22
+ /**
23
+ * 布局容器:计算并设置所有子组件的位置/尺寸。
24
+ * @param container 目标容器(ICEGroup)
25
+ */
26
+ abstract layoutContainer(container: ICEGroup): void;
27
+ /**
28
+ * 计算容器内内容的「首选尺寸」(可选,默认 [0,0])。
29
+ * 子类可按需覆盖。
30
+ */
31
+ getPreferredSize(container: ICEGroup): [number, number];
32
+ }
33
+ export default ICELayoutManager;
@@ -0,0 +1,33 @@
1
+ /**
2
+ * Copyright (c) 2022 大漠穷秋.
3
+ *
4
+ * This source code is licensed under the MIT license found in the
5
+ * LICENSE file in the root directory of this source tree.
6
+ *
7
+ */
8
+ import type ICEGroup from '../graphic/container/ICEGroup';
9
+ /**
10
+ * @class ICELayoutManager 布局管理器(抽象基类)
11
+ *
12
+ * 借鉴 Java Swing 的 LayoutManager 设计思想——**策略模式**:
13
+ * - 组件(ICEComponent)只负责「画自己」,不碰布局;
14
+ * - 容器(ICEGroup)只负责「持有子组件」,通过 setLayout() 持有布局策略;
15
+ * - 布局管理器(本类及其子类)只负责「摆位置」。
16
+ *
17
+ * 核心只有一个方法 layoutContainer(container):给定容器,计算并设置所有子组件的位置/尺寸。
18
+ *
19
+ * @author 大漠穷秋<damoqiongqiu@126.com>
20
+ */
21
+ declare abstract class ICELayoutManager {
22
+ /**
23
+ * 布局容器:计算并设置所有子组件的位置/尺寸。
24
+ * @param container 目标容器(ICEGroup)
25
+ */
26
+ abstract layoutContainer(container: ICEGroup): void;
27
+ /**
28
+ * 计算容器内内容的「首选尺寸」(可选,默认 [0,0])。
29
+ * 子类可按需覆盖。
30
+ */
31
+ getPreferredSize(container: ICEGroup): [number, number];
32
+ }
33
+ export default ICELayoutManager;
@@ -0,0 +1,25 @@
1
+ /**
2
+ * Copyright (c) 2022 大漠穷秋.
3
+ *
4
+ * This source code is licensed under the MIT license found in the
5
+ * LICENSE file in the root directory of this source tree.
6
+ *
7
+ */
8
+ import type ICEGroup from '../graphic/container/ICEGroup.mjs';
9
+ import ICELayoutManager from './ICELayoutManager.mjs';
10
+ /**
11
+ * @class ICEOverlayLayout 叠加布局
12
+ *
13
+ * 对齐 Java Swing 的 OverlayLayout:所有子组件叠放在同一位置(左上角)。
14
+ * 可用于做图层叠加效果。
15
+ *
16
+ * @author 大漠穷秋<damoqiongqiu@126.com>
17
+ */
18
+ declare class ICEOverlayLayout extends ICELayoutManager {
19
+ /**
20
+ * @overwrite
21
+ * 所有子组件叠放到容器左上角。
22
+ */
23
+ layoutContainer(container: ICEGroup): void;
24
+ }
25
+ export default ICEOverlayLayout;
@@ -0,0 +1,25 @@
1
+ /**
2
+ * Copyright (c) 2022 大漠穷秋.
3
+ *
4
+ * This source code is licensed under the MIT license found in the
5
+ * LICENSE file in the root directory of this source tree.
6
+ *
7
+ */
8
+ import type ICEGroup from '../graphic/container/ICEGroup';
9
+ import ICELayoutManager from './ICELayoutManager';
10
+ /**
11
+ * @class ICEOverlayLayout 叠加布局
12
+ *
13
+ * 对齐 Java Swing 的 OverlayLayout:所有子组件叠放在同一位置(左上角)。
14
+ * 可用于做图层叠加效果。
15
+ *
16
+ * @author 大漠穷秋<damoqiongqiu@126.com>
17
+ */
18
+ declare class ICEOverlayLayout extends ICELayoutManager {
19
+ /**
20
+ * @overwrite
21
+ * 所有子组件叠放到容器左上角。
22
+ */
23
+ layoutContainer(container: ICEGroup): void;
24
+ }
25
+ export default ICEOverlayLayout;
@@ -0,0 +1,43 @@
1
+ /**
2
+ * 序列化格式迁移表:`to` 为目标版本,按升序执行。
3
+ *
4
+ * 需要变更数据格式时,把 SERIALIZATION_VERSION 加 1 并在此追加一条迁移:
5
+ * `SERIALIZATION_MIGRATIONS.push({ to: 2, run: (json) => { ...改写 json 结构... } });`
6
+ * 当前版本为 1,尚无迁移(仅保留机制与回归用例)。
7
+ */
8
+ export declare const SERIALIZATION_MIGRATIONS: Array<{
9
+ to: number;
10
+ run: (jsonObj: any) => void;
11
+ }>;
12
+ /**
13
+ * @class Deserializer
14
+ *
15
+ * 把 JSON 字符串反解析成图形。
16
+ *
17
+ * @author 大漠穷秋<damoqiongqiu@126.com>
18
+ */
19
+ export default class Deserializer {
20
+ private ice;
21
+ constructor(ice: any);
22
+ /** 本次反序列化中遇到的、未注册的组件类型名(去重)。供应用层提示用户 registerType 后重载。 */
23
+ private _unknownTypes;
24
+ get unknownTypes(): string[];
25
+ fromJSONObject(jsonObj: any): void;
26
+ fromJSONString(jsonStr: string): void;
27
+ /**
28
+ * 版本迁移钩子:当序列化格式版本变化时,在此处按版本逐级升级数据结构。
29
+ * 当前版本为 {@link SERIALIZATION_VERSION},低于该版本的旧数据在此迁移。
30
+ */
31
+ private migrate;
32
+ /**
33
+ * 递归反序列化。
34
+ *
35
+ * 容错:遇到未注册的类型时**跳过该节点(含其子树)并记录**,而不是抛错终止整图加载
36
+ * (旧实现直接 `new undefined(...)` 抛 TypeError,一个未知组件会导致整份数据打不开)。
37
+ * 注意:生产构建会用 rollup-plugin-strip 去掉 console.*,因此告警也可能消失;
38
+ * 应用层应以 `deserializer.unknownTypes` 为准做提示。
39
+ *
40
+ * @returns 创建出的实例;跳过时返回 null
41
+ */
42
+ private decodeRecursively;
43
+ }
@@ -1,14 +1,43 @@
1
- /**
2
- * @class Deserializer
3
- *
4
- * JSON 字符串反解析成图形。
5
- *
6
- * @author 大漠穷秋<damoqiongqiu@126.com>
7
- */
8
- export default class Deserializer {
9
- private ice;
10
- constructor(ice: any);
11
- fromJSONObject(jsonObj: any): void;
12
- fromJSONString(jsonStr: string): void;
13
- private decodeRecursively;
14
- }
1
+ /**
2
+ * 序列化格式迁移表:`to` 为目标版本,按升序执行。
3
+ *
4
+ * 需要变更数据格式时,把 SERIALIZATION_VERSION 加 1 并在此追加一条迁移:
5
+ * `SERIALIZATION_MIGRATIONS.push({ to: 2, run: (json) => { ...改写 json 结构... } });`
6
+ * 当前版本为 1,尚无迁移(仅保留机制与回归用例)。
7
+ */
8
+ export declare const SERIALIZATION_MIGRATIONS: Array<{
9
+ to: number;
10
+ run: (jsonObj: any) => void;
11
+ }>;
12
+ /**
13
+ * @class Deserializer
14
+ *
15
+ * 把 JSON 字符串反解析成图形。
16
+ *
17
+ * @author 大漠穷秋<damoqiongqiu@126.com>
18
+ */
19
+ export default class Deserializer {
20
+ private ice;
21
+ constructor(ice: any);
22
+ /** 本次反序列化中遇到的、未注册的组件类型名(去重)。供应用层提示用户 registerType 后重载。 */
23
+ private _unknownTypes;
24
+ get unknownTypes(): string[];
25
+ fromJSONObject(jsonObj: any): void;
26
+ fromJSONString(jsonStr: string): void;
27
+ /**
28
+ * 版本迁移钩子:当序列化格式版本变化时,在此处按版本逐级升级数据结构。
29
+ * 当前版本为 {@link SERIALIZATION_VERSION},低于该版本的旧数据在此迁移。
30
+ */
31
+ private migrate;
32
+ /**
33
+ * 递归反序列化。
34
+ *
35
+ * 容错:遇到未注册的类型时**跳过该节点(含其子树)并记录**,而不是抛错终止整图加载
36
+ * (旧实现直接 `new undefined(...)` 抛 TypeError,一个未知组件会导致整份数据打不开)。
37
+ * 注意:生产构建会用 rollup-plugin-strip 去掉 console.*,因此告警也可能消失;
38
+ * 应用层应以 `deserializer.unknownTypes` 为准做提示。
39
+ *
40
+ * @returns 创建出的实例;跳过时返回 null
41
+ */
42
+ private decodeRecursively;
43
+ }
@@ -0,0 +1,35 @@
1
+ /**
2
+ * 序列化格式版本号。数据结构发生变化时递增,并在 Deserializer 中做对应迁移。
3
+ */
4
+ export declare const SERIALIZATION_VERSION = 1;
5
+ /**
6
+ * @class Serializer
7
+ *
8
+ * 把图形序列化成 JSON 字符串。
9
+ *
10
+ * @author 大漠穷秋<damoqiongqiu@126.com>
11
+ */
12
+ export default class Serializer {
13
+ private ice;
14
+ constructor(ice: any);
15
+ /**
16
+ * 把对象序列化成 JSON 字符串:
17
+ * - 容器型组件需要负责子节点的序列化操作
18
+ * - 如果组件不需要序列化,需要返回 null
19
+ * @returns Object
20
+ */
21
+ toJSONString(): string;
22
+ /**
23
+ * 把对象序列化成 JSON 对象:
24
+ * - 容器型组件需要负责子节点的序列化操作
25
+ * - 如果组件不需要序列化,需要返回 null
26
+ * @returns Object
27
+ */
28
+ toJSONObject(): object;
29
+ private encodeRecursively;
30
+ /**
31
+ * 只序列化用户数据,排除运行时缓存/计算值(linearMatrix/composedMatrix/localOrigin/
32
+ * absoluteOrigin/dots/textHeight 等)。
33
+ */
34
+ private pickSerializableState;
35
+ }
@@ -1,26 +1,35 @@
1
- /**
2
- * @class Serializer
3
- *
4
- * 把图形序列化成 JSON 字符串。
5
- *
6
- * @author 大漠穷秋<damoqiongqiu@126.com>
7
- */
8
- export default class Serializer {
9
- private ice;
10
- constructor(ice: any);
11
- /**
12
- * 把对象序列化成 JSON 字符串:
13
- * - 容器型组件需要负责子节点的序列化操作
14
- * - 如果组件不需要序列化,需要返回 null
15
- * @returns Object
16
- */
17
- toJSONString(): string;
18
- /**
19
- * 把对象序列化成 JSON 对象:
20
- * - 容器型组件需要负责子节点的序列化操作
21
- * - 如果组件不需要序列化,需要返回 null
22
- * @returns Object
23
- */
24
- toJSONObject(): object;
25
- private encodeRecursively;
26
- }
1
+ /**
2
+ * 序列化格式版本号。数据结构发生变化时递增,并在 Deserializer 中做对应迁移。
3
+ */
4
+ export declare const SERIALIZATION_VERSION = 1;
5
+ /**
6
+ * @class Serializer
7
+ *
8
+ * 把图形序列化成 JSON 字符串。
9
+ *
10
+ * @author 大漠穷秋<damoqiongqiu@126.com>
11
+ */
12
+ export default class Serializer {
13
+ private ice;
14
+ constructor(ice: any);
15
+ /**
16
+ * 把对象序列化成 JSON 字符串:
17
+ * - 容器型组件需要负责子节点的序列化操作
18
+ * - 如果组件不需要序列化,需要返回 null
19
+ * @returns Object
20
+ */
21
+ toJSONString(): string;
22
+ /**
23
+ * 把对象序列化成 JSON 对象:
24
+ * - 容器型组件需要负责子节点的序列化操作
25
+ * - 如果组件不需要序列化,需要返回 null
26
+ * @returns Object
27
+ */
28
+ toJSONObject(): object;
29
+ private encodeRecursively;
30
+ /**
31
+ * 只序列化用户数据,排除运行时缓存/计算值(linearMatrix/composedMatrix/localOrigin/
32
+ * absoluteOrigin/dots/textHeight 等)。
33
+ */
34
+ private pickSerializableState;
35
+ }
@@ -0,0 +1,86 @@
1
+ /**
2
+ * 插件宿主:为引擎提供「组件 / 渲染 / 交互工具」三层注册点。
3
+ *
4
+ * 设计取向与 09-roadmap 的边界一致——**只提供原语,不做应用层 UX**:
5
+ * - 组件层:插件声明自定义图元类型,宿主代为 `registerType`(因此自动获得
6
+ * 序列化 typeId 反查能力,见 `ICE.getTypeId`)。
7
+ * - 渲染层:插件拿到每帧的绘制回调,在与组件相同的坐标系(世界坐标)下叠加绘制。
8
+ * 局部重绘帧里回调在 clip 之内执行,语义与组件一致(超出脏区域的旧内容不会被擦除也不会被重画;
9
+ * 若插件内容会随时间变化而没有任何组件变脏,引擎本身会因「无脏组件」回退全量,仍然正确)。
10
+ * - 交互工具层:插件按 `match(component)` 声明自己的工具组件;宿主复用既有 `toolNodes`
11
+ * 机制做 add/remove,`exclusive` 为真时禁用内置变换/连线面板。
12
+ *
13
+ * 生命周期:`ICE.use(plugin)` 幂等(按 `name` 去重)→ 调用 `setup(ice)`;
14
+ * `ICE.unuse(name)` → 调用 `teardown(ice)` 并撤销该插件注册的工具与渲染回调。
15
+ * 类型注册(`components`)在 unuse 后**保留**——反序列化仍可能依赖它,且撤销类型会让已存数据失效。
16
+ *
17
+ * @author 大漠穷秋<damoqiongqiu@126.com>
18
+ */
19
+ export interface ICERenderFrame {
20
+ ctx: any;
21
+ /** 当前渲染模式 */
22
+ mode: 'full' | 'dirty-rect';
23
+ /** 局部重绘时的脏区域(世界坐标 [minX,minY,maxX,maxY]);全量帧为 null */
24
+ region: number[] | null;
25
+ /** 画布尺寸(设备像素) */
26
+ width: number;
27
+ height: number;
28
+ }
29
+ export type ICERenderHook = (frame: ICERenderFrame) => void;
30
+ export interface ICEPluginTool {
31
+ /** 插件内唯一 id(用于幂等注册与撤销) */
32
+ id: string;
33
+ /** 该工具是否应作用于当前选中的组件 */
34
+ match: (component: any, ice: any) => boolean;
35
+ /** 创建工具组件(会被加到 ICE.toolNodes,不参与序列化) */
36
+ create: () => any;
37
+ /**
38
+ * 命中时是否屏蔽内置变换/连线面板。
39
+ * 默认 false(叠加在内置面板之上);为 true 时内置面板会被禁用,避免与插件工具重叠。
40
+ */
41
+ exclusive?: boolean;
42
+ /** 可选:目标组件变化时回调(同一工具实例被复用,避免每次选中都重建) */
43
+ onTargetChange?: (tool: any, component: any) => void;
44
+ }
45
+ export interface ICEPlugin {
46
+ /** 插件唯一名(幂等注册键) */
47
+ name: string;
48
+ /** 组件层:typeId → 构造函数 */
49
+ components?: Record<string, new (...args: any[]) => any>;
50
+ /** 渲染层:每帧绘制回调(世界坐标) */
51
+ render?: ICERenderHook;
52
+ /** 交互工具层 */
53
+ tools?: ICEPluginTool[];
54
+ /** 注册时调用(可在此绑定事件、注册主题等) */
55
+ setup?: (ice: any) => void;
56
+ /** 注销时调用(应释放自己申请的资源) */
57
+ teardown?: (ice: any) => void;
58
+ }
59
+ export default class PluginHost {
60
+ private ice;
61
+ private plugins;
62
+ /** 渲染回调,按注册顺序调用 */
63
+ private renderHooks;
64
+ private tools;
65
+ constructor(ice: any);
66
+ /** 已注册插件名(只读快照) */
67
+ get names(): string[];
68
+ has(name: string): boolean;
69
+ hasRenderHooks(): boolean;
70
+ /** 幂等注册:同名插件重复 use 直接返回 false(不重复 setup) */
71
+ use(plugin: ICEPlugin): boolean;
72
+ /** 注销插件:撤销其渲染回调与工具,并调用 teardown(类型注册保留) */
73
+ unuse(name: string): boolean;
74
+ /** 渲染钩子:由 CanvasRenderer 在绘制完组件与工具后调用(世界坐标、clip 之内) */
75
+ invokeRenderHooks(frame: ICERenderFrame): void;
76
+ /**
77
+ * 选中变化时同步插件工具:命中的挂上、失配的摘下。
78
+ * @returns 是否存在「排他」工具命中(命中时调用方应禁用内置面板)
79
+ */
80
+ syncTools(component: any): boolean;
81
+ /** 全部摘下(如 clearAll 时) */
82
+ detachAllTools(): void;
83
+ private detachTool;
84
+ /** destroy 时清空(不调用 teardown,交由 ICE.destroy 统一处理) */
85
+ clear(): void;
86
+ }
@@ -0,0 +1,86 @@
1
+ /**
2
+ * 插件宿主:为引擎提供「组件 / 渲染 / 交互工具」三层注册点。
3
+ *
4
+ * 设计取向与 09-roadmap 的边界一致——**只提供原语,不做应用层 UX**:
5
+ * - 组件层:插件声明自定义图元类型,宿主代为 `registerType`(因此自动获得
6
+ * 序列化 typeId 反查能力,见 `ICE.getTypeId`)。
7
+ * - 渲染层:插件拿到每帧的绘制回调,在与组件相同的坐标系(世界坐标)下叠加绘制。
8
+ * 局部重绘帧里回调在 clip 之内执行,语义与组件一致(超出脏区域的旧内容不会被擦除也不会被重画;
9
+ * 若插件内容会随时间变化而没有任何组件变脏,引擎本身会因「无脏组件」回退全量,仍然正确)。
10
+ * - 交互工具层:插件按 `match(component)` 声明自己的工具组件;宿主复用既有 `toolNodes`
11
+ * 机制做 add/remove,`exclusive` 为真时禁用内置变换/连线面板。
12
+ *
13
+ * 生命周期:`ICE.use(plugin)` 幂等(按 `name` 去重)→ 调用 `setup(ice)`;
14
+ * `ICE.unuse(name)` → 调用 `teardown(ice)` 并撤销该插件注册的工具与渲染回调。
15
+ * 类型注册(`components`)在 unuse 后**保留**——反序列化仍可能依赖它,且撤销类型会让已存数据失效。
16
+ *
17
+ * @author 大漠穷秋<damoqiongqiu@126.com>
18
+ */
19
+ export interface ICERenderFrame {
20
+ ctx: any;
21
+ /** 当前渲染模式 */
22
+ mode: 'full' | 'dirty-rect';
23
+ /** 局部重绘时的脏区域(世界坐标 [minX,minY,maxX,maxY]);全量帧为 null */
24
+ region: number[] | null;
25
+ /** 画布尺寸(设备像素) */
26
+ width: number;
27
+ height: number;
28
+ }
29
+ export type ICERenderHook = (frame: ICERenderFrame) => void;
30
+ export interface ICEPluginTool {
31
+ /** 插件内唯一 id(用于幂等注册与撤销) */
32
+ id: string;
33
+ /** 该工具是否应作用于当前选中的组件 */
34
+ match: (component: any, ice: any) => boolean;
35
+ /** 创建工具组件(会被加到 ICE.toolNodes,不参与序列化) */
36
+ create: () => any;
37
+ /**
38
+ * 命中时是否屏蔽内置变换/连线面板。
39
+ * 默认 false(叠加在内置面板之上);为 true 时内置面板会被禁用,避免与插件工具重叠。
40
+ */
41
+ exclusive?: boolean;
42
+ /** 可选:目标组件变化时回调(同一工具实例被复用,避免每次选中都重建) */
43
+ onTargetChange?: (tool: any, component: any) => void;
44
+ }
45
+ export interface ICEPlugin {
46
+ /** 插件唯一名(幂等注册键) */
47
+ name: string;
48
+ /** 组件层:typeId → 构造函数 */
49
+ components?: Record<string, new (...args: any[]) => any>;
50
+ /** 渲染层:每帧绘制回调(世界坐标) */
51
+ render?: ICERenderHook;
52
+ /** 交互工具层 */
53
+ tools?: ICEPluginTool[];
54
+ /** 注册时调用(可在此绑定事件、注册主题等) */
55
+ setup?: (ice: any) => void;
56
+ /** 注销时调用(应释放自己申请的资源) */
57
+ teardown?: (ice: any) => void;
58
+ }
59
+ export default class PluginHost {
60
+ private ice;
61
+ private plugins;
62
+ /** 渲染回调,按注册顺序调用 */
63
+ private renderHooks;
64
+ private tools;
65
+ constructor(ice: any);
66
+ /** 已注册插件名(只读快照) */
67
+ get names(): string[];
68
+ has(name: string): boolean;
69
+ hasRenderHooks(): boolean;
70
+ /** 幂等注册:同名插件重复 use 直接返回 false(不重复 setup) */
71
+ use(plugin: ICEPlugin): boolean;
72
+ /** 注销插件:撤销其渲染回调与工具,并调用 teardown(类型注册保留) */
73
+ unuse(name: string): boolean;
74
+ /** 渲染钩子:由 CanvasRenderer 在绘制完组件与工具后调用(世界坐标、clip 之内) */
75
+ invokeRenderHooks(frame: ICERenderFrame): void;
76
+ /**
77
+ * 选中变化时同步插件工具:命中的挂上、失配的摘下。
78
+ * @returns 是否存在「排他」工具命中(命中时调用方应禁用内置面板)
79
+ */
80
+ syncTools(component: any): boolean;
81
+ /** 全部摘下(如 clearAll 时) */
82
+ detachAllTools(): void;
83
+ private detachTool;
84
+ /** destroy 时清空(不调用 teardown,交由 ICE.destroy 统一处理) */
85
+ clear(): void;
86
+ }