ice-entity-designer 0.0.16 → 0.0.18

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 (180) hide show
  1. package/LICENSE +21 -21
  2. package/README.md +287 -26
  3. package/dist/index.cjs +30 -0
  4. package/dist/index.mjs +30 -0
  5. package/dist/index.umd.js +10 -5
  6. package/dist/react.cjs +30 -0
  7. package/dist/react.mjs +30 -0
  8. package/dist/types/designer/EntityDesigner.d.mts +102 -0
  9. package/dist/types/designer/EntityDesigner.d.ts +102 -0
  10. package/dist/types/er-component/Entity.d.mts +104 -0
  11. package/dist/types/er-component/Entity.d.ts +104 -62
  12. package/dist/types/er-component/Relation.d.mts +50 -0
  13. package/dist/types/er-component/Relation.d.ts +50 -24
  14. package/dist/types/gl-matrix.d.mts +3273 -0
  15. package/dist/types/gl-matrix.d.ts +3273 -0
  16. package/dist/types/ice-render/FrameManager.d.mts +26 -0
  17. package/dist/types/ice-render/FrameManager.d.ts +26 -0
  18. package/dist/types/ice-render/ICE.d.mts +369 -0
  19. package/dist/types/ice-render/ICE.d.ts +369 -0
  20. package/dist/types/ice-render/a11y/accessibility.d.mts +46 -0
  21. package/dist/types/ice-render/a11y/accessibility.d.ts +46 -0
  22. package/dist/types/ice-render/animation/AnimationManager.d.mts +96 -0
  23. package/dist/types/ice-render/animation/AnimationManager.d.ts +96 -0
  24. package/dist/types/ice-render/animation/Easing.d.mts +33 -0
  25. package/dist/types/ice-render/animation/Easing.d.ts +33 -0
  26. package/dist/types/ice-render/consts/BIG_ZINDEX_NUMBER.d.mts +14 -0
  27. package/dist/types/ice-render/consts/BIG_ZINDEX_NUMBER.d.ts +14 -0
  28. package/dist/types/ice-render/consts/COMPONENT_TYPE_MAPPING.d.mts +45 -0
  29. package/dist/types/ice-render/consts/COMPONENT_TYPE_MAPPING.d.ts +45 -0
  30. package/dist/types/ice-render/consts/DOM_EVENT_MAPPING_CONSTS.d.mts +37 -0
  31. package/dist/types/ice-render/consts/DOM_EVENT_MAPPING_CONSTS.d.ts +37 -0
  32. package/dist/types/ice-render/consts/ICE_EVENT_NAME_CONSTS.d.mts +27 -0
  33. package/dist/types/ice-render/consts/ICE_EVENT_NAME_CONSTS.d.ts +27 -0
  34. package/dist/types/ice-render/control-panel/AlignmentGuideManager.d.mts +92 -0
  35. package/dist/types/ice-render/control-panel/AlignmentGuideManager.d.ts +92 -0
  36. package/dist/types/ice-render/control-panel/ICEControlPanel.d.mts +37 -0
  37. package/dist/types/ice-render/control-panel/ICEControlPanel.d.ts +37 -0
  38. package/dist/types/ice-render/control-panel/ICEControlPanelManager.d.mts +25 -0
  39. package/dist/types/ice-render/control-panel/ICEControlPanelManager.d.ts +25 -0
  40. package/dist/types/ice-render/control-panel/link-controls/LineControlPanel.d.mts +39 -0
  41. package/dist/types/ice-render/control-panel/link-controls/LineControlPanel.d.ts +39 -0
  42. package/dist/types/ice-render/control-panel/transform-controls/ResizeControl.d.mts +38 -0
  43. package/dist/types/ice-render/control-panel/transform-controls/ResizeControl.d.ts +38 -0
  44. package/dist/types/ice-render/control-panel/transform-controls/RotateControl.d.mts +12 -0
  45. package/dist/types/ice-render/control-panel/transform-controls/RotateControl.d.ts +12 -0
  46. package/dist/types/ice-render/control-panel/transform-controls/TransformControlPanel.d.mts +83 -0
  47. package/dist/types/ice-render/control-panel/transform-controls/TransformControlPanel.d.ts +83 -0
  48. package/dist/types/ice-render/control-panel/transform-controls/constraints.d.mts +24 -0
  49. package/dist/types/ice-render/control-panel/transform-controls/constraints.d.ts +24 -0
  50. package/dist/types/ice-render/cross-platform/PolyfillPath2D.d.mts +31 -0
  51. package/dist/types/ice-render/cross-platform/PolyfillPath2D.d.ts +31 -0
  52. package/dist/types/ice-render/cross-platform/root.d.mts +7 -0
  53. package/dist/types/ice-render/cross-platform/root.d.ts +7 -0
  54. package/dist/types/ice-render/event/DOMEventDispatcher.d.mts +68 -0
  55. package/dist/types/ice-render/event/DOMEventDispatcher.d.ts +68 -0
  56. package/dist/types/ice-render/event/DOMEventInterceptor.d.mts +36 -0
  57. package/dist/types/ice-render/event/DOMEventInterceptor.d.ts +36 -0
  58. package/dist/types/ice-render/event/EventBus.d.mts +27 -0
  59. package/dist/types/ice-render/event/EventBus.d.ts +27 -0
  60. package/dist/types/ice-render/event/ICEEvent.d.mts +46 -0
  61. package/dist/types/ice-render/event/ICEEvent.d.ts +46 -0
  62. package/dist/types/ice-render/event/ICEEventTarget.d.mts +106 -0
  63. package/dist/types/ice-render/event/ICEEventTarget.d.ts +106 -0
  64. package/dist/types/ice-render/event/input-normalize.d.mts +75 -0
  65. package/dist/types/ice-render/event/input-normalize.d.ts +75 -0
  66. package/dist/types/ice-render/geometry/GeoLine.d.mts +24 -0
  67. package/dist/types/ice-render/geometry/GeoLine.d.ts +24 -0
  68. package/dist/types/ice-render/geometry/GeoPoint.d.mts +53 -0
  69. package/dist/types/ice-render/geometry/GeoPoint.d.ts +53 -0
  70. package/dist/types/ice-render/geometry/GeoUtil.d.mts +73 -0
  71. package/dist/types/ice-render/geometry/GeoUtil.d.ts +73 -0
  72. package/dist/types/ice-render/geometry/ICEBoundingBox.d.mts +81 -0
  73. package/dist/types/ice-render/geometry/ICEBoundingBox.d.ts +81 -0
  74. package/dist/types/ice-render/graphic/ICEComponent.d.mts +486 -0
  75. package/dist/types/ice-render/graphic/ICEComponent.d.ts +486 -0
  76. package/dist/types/ice-render/graphic/ICEDotPath.d.mts +99 -0
  77. package/dist/types/ice-render/graphic/ICEDotPath.d.ts +99 -0
  78. package/dist/types/ice-render/graphic/ICEImage.d.mts +17 -0
  79. package/dist/types/ice-render/graphic/ICEImage.d.ts +17 -0
  80. package/dist/types/ice-render/graphic/ICEPath.d.mts +39 -0
  81. package/dist/types/ice-render/graphic/ICEPath.d.ts +39 -0
  82. package/dist/types/ice-render/graphic/container/ICEGroup.d.mts +101 -0
  83. package/dist/types/ice-render/graphic/container/ICEGroup.d.ts +101 -0
  84. package/dist/types/ice-render/graphic/link/ICEBezier.d.mts +23 -0
  85. package/dist/types/ice-render/graphic/link/ICEBezier.d.ts +23 -0
  86. package/dist/types/ice-render/graphic/link/ICELinkHook.d.mts +52 -0
  87. package/dist/types/ice-render/graphic/link/ICELinkHook.d.ts +52 -0
  88. package/dist/types/ice-render/graphic/link/ICELinkSlot.d.mts +54 -0
  89. package/dist/types/ice-render/graphic/link/ICELinkSlot.d.ts +54 -0
  90. package/dist/types/ice-render/graphic/link/ICELinkSlotManager.d.mts +28 -0
  91. package/dist/types/ice-render/graphic/link/ICELinkSlotManager.d.ts +28 -0
  92. package/dist/types/ice-render/graphic/link/ICEPolyLine.d.mts +292 -0
  93. package/dist/types/ice-render/graphic/link/ICEPolyLine.d.ts +292 -0
  94. package/dist/types/ice-render/graphic/link/ICEVisioLink.d.mts +163 -0
  95. package/dist/types/ice-render/graphic/link/ICEVisioLink.d.ts +163 -0
  96. package/dist/types/ice-render/graphic/shape/ICECircle.d.mts +19 -0
  97. package/dist/types/ice-render/graphic/shape/ICECircle.d.ts +19 -0
  98. package/dist/types/ice-render/graphic/shape/ICEEllipse.d.mts +29 -0
  99. package/dist/types/ice-render/graphic/shape/ICEEllipse.d.ts +29 -0
  100. package/dist/types/ice-render/graphic/shape/ICEIsogon.d.mts +52 -0
  101. package/dist/types/ice-render/graphic/shape/ICEIsogon.d.ts +52 -0
  102. package/dist/types/ice-render/graphic/shape/ICERect.d.mts +10 -0
  103. package/dist/types/ice-render/graphic/shape/ICERect.d.ts +10 -0
  104. package/dist/types/ice-render/graphic/shape/ICERose.d.mts +41 -0
  105. package/dist/types/ice-render/graphic/shape/ICERose.d.ts +41 -0
  106. package/dist/types/ice-render/graphic/shape/ICEStar.d.mts +45 -0
  107. package/dist/types/ice-render/graphic/shape/ICEStar.d.ts +45 -0
  108. package/dist/types/ice-render/graphic/text/ICEText.d.mts +137 -0
  109. package/dist/types/ice-render/graphic/text/ICEText.d.ts +137 -0
  110. package/dist/types/ice-render/index.d.mts +55 -0
  111. package/dist/types/ice-render/index.d.ts +55 -0
  112. package/dist/types/ice-render/layout/ICEBorderLayout.d.mts +34 -0
  113. package/dist/types/ice-render/layout/ICEBorderLayout.d.ts +34 -0
  114. package/dist/types/ice-render/layout/ICEBoxLayout.d.mts +30 -0
  115. package/dist/types/ice-render/layout/ICEBoxLayout.d.ts +30 -0
  116. package/dist/types/ice-render/layout/ICECardLayout.d.mts +36 -0
  117. package/dist/types/ice-render/layout/ICECardLayout.d.ts +36 -0
  118. package/dist/types/ice-render/layout/ICEFlowLayout.d.mts +31 -0
  119. package/dist/types/ice-render/layout/ICEFlowLayout.d.ts +31 -0
  120. package/dist/types/ice-render/layout/ICEGridLayout.d.mts +33 -0
  121. package/dist/types/ice-render/layout/ICEGridLayout.d.ts +33 -0
  122. package/dist/types/ice-render/layout/ICELayeredLayout.d.mts +49 -0
  123. package/dist/types/ice-render/layout/ICELayeredLayout.d.ts +49 -0
  124. package/dist/types/ice-render/layout/ICELayoutManager.d.mts +33 -0
  125. package/dist/types/ice-render/layout/ICELayoutManager.d.ts +33 -0
  126. package/dist/types/ice-render/layout/ICEOverlayLayout.d.mts +25 -0
  127. package/dist/types/ice-render/layout/ICEOverlayLayout.d.ts +25 -0
  128. package/dist/types/ice-render/persistence/Deserializer.d.mts +43 -0
  129. package/dist/types/ice-render/persistence/Deserializer.d.ts +43 -0
  130. package/dist/types/ice-render/persistence/Serializer.d.mts +35 -0
  131. package/dist/types/ice-render/persistence/Serializer.d.ts +35 -0
  132. package/dist/types/ice-render/plugin/PluginHost.d.mts +86 -0
  133. package/dist/types/ice-render/plugin/PluginHost.d.ts +86 -0
  134. package/dist/types/ice-render/renderer/CanvasRenderer.d.mts +150 -0
  135. package/dist/types/ice-render/renderer/CanvasRenderer.d.ts +150 -0
  136. package/dist/types/ice-render/renderer/ObjectCache.d.mts +79 -0
  137. package/dist/types/ice-render/renderer/ObjectCache.d.ts +79 -0
  138. package/dist/types/ice-render/renderer/dirty-rect-util.d.mts +86 -0
  139. package/dist/types/ice-render/renderer/dirty-rect-util.d.ts +86 -0
  140. package/dist/types/ice-render/theme/ICETheme.d.mts +382 -0
  141. package/dist/types/ice-render/theme/ICETheme.d.ts +382 -0
  142. package/dist/types/ice-render/util/ImageCache.d.mts +19 -0
  143. package/dist/types/ice-render/util/ImageCache.d.ts +19 -0
  144. package/dist/types/ice-render/util/data-util.d.mts +43 -0
  145. package/dist/types/ice-render/util/data-util.d.ts +43 -0
  146. package/dist/types/ice-render/util/gl-matrix-skew.d.mts +14 -0
  147. package/dist/types/ice-render/util/gl-matrix-skew.d.ts +14 -0
  148. package/dist/types/ice-render/util/lang.d.mts +28 -0
  149. package/dist/types/ice-render/util/lang.d.ts +28 -0
  150. package/dist/types/ice-render/util/uuid.d.mts +1 -0
  151. package/dist/types/ice-render/util/uuid.d.ts +1 -0
  152. package/dist/types/index.d.mts +30 -0
  153. package/dist/types/index.d.ts +30 -10
  154. package/dist/types/react/EntityDesignerCanvas.d.mts +12 -0
  155. package/dist/types/react/EntityDesignerCanvas.d.ts +12 -0
  156. package/dist/types/react/context.d.mts +25 -0
  157. package/dist/types/react/context.d.ts +25 -0
  158. package/dist/types/react/index.d.mts +17 -0
  159. package/dist/types/react/index.d.ts +17 -0
  160. package/dist/types/react/session.d.mts +30 -0
  161. package/dist/types/react/session.d.ts +30 -0
  162. package/dist/types/react/types.d.mts +64 -0
  163. package/dist/types/react/types.d.ts +64 -0
  164. package/dist/types/utils/camelcase_util.d.mts +4 -0
  165. package/dist/types/utils/camelcase_util.d.ts +4 -4
  166. package/dist/types/utils/component_type_util.d.mts +4 -0
  167. package/dist/types/utils/component_type_util.d.ts +4 -0
  168. package/dist/types/utils/pluralize_util.d.mts +25 -0
  169. package/dist/types/utils/pluralize_util.d.ts +25 -25
  170. package/dist/types/utils/project_schema.d.mts +27 -0
  171. package/dist/types/utils/project_schema.d.ts +27 -0
  172. package/dist/types/utils/schema_validator.d.mts +10 -0
  173. package/dist/types/utils/schema_validator.d.ts +10 -0
  174. package/dist/types/utils/serialization_util.d.mts +2 -0
  175. package/dist/types/utils/serialization_util.d.ts +2 -2
  176. package/package.json +145 -96
  177. package/react.d.ts +2 -0
  178. package/react.js +3 -0
  179. package/dist/index.cjs.js +0 -25
  180. package/dist/index.js +0 -25
@@ -0,0 +1,102 @@
1
+ import type { ICE } from '../ice-render/index.mjs';
2
+ import { validateSchema } from '../utils/schema_validator.mjs';
3
+ /** 载入快照时被跳过的节点明细(typeId 未注册) */
4
+ export declare type ProjectLoadSkippedNode = {
5
+ /** 该节点所在的数组 */
6
+ bucket: 'entities' | 'relations';
7
+ /** 该节点在数组中的下标 */
8
+ index: number;
9
+ /** 快照里声明的类型标识 */
10
+ typeId: string;
11
+ /** 快照里的节点 id(若存在),便于定位数据问题 */
12
+ id?: string;
13
+ };
14
+ /** loadProject() 的载入报告 */
15
+ export declare type ProjectLoadReport = {
16
+ /** 是否真的发生了一次项目替换(空值 / 非项目快照为 false) */
17
+ loaded: boolean;
18
+ /** 实际创建出的实体数量 */
19
+ entities: number;
20
+ /** 实际创建出的关系数量 */
21
+ relations: number;
22
+ /** 因未注册被跳过的类型(去重),语义同引擎 `deserializer.unknownTypes` */
23
+ unknownTypes: string[];
24
+ /** 被跳过的节点明细 */
25
+ skipped: ProjectLoadSkippedNode[];
26
+ };
27
+ /**
28
+ * EntityDesigner 是 Entity / Relation 之上的轻量应用层。
29
+ *
30
+ * 它不替代 ICE,也不重复实现底层图元;只负责把 ER 设计器最常用的交互闭环串起来:
31
+ * 选择、创建、更新、删除、关系连接、Schema 输出。
32
+ */
33
+ export default class EntityDesigner {
34
+ ice: ICE;
35
+ selectedId: string | null;
36
+ /** 变更订阅者:任何会改变模型的操作完成后都会被通知(React 绑定层用它驱动 onChange) */
37
+ private __changeListeners;
38
+ private __mousedownHandler;
39
+ private __undoStack;
40
+ private __redoStack;
41
+ private __historyEnabled;
42
+ private __maxHistory;
43
+ constructor(ice: ICE);
44
+ get entities(): any[];
45
+ get relations(): any[];
46
+ get selected(): any;
47
+ select(id: string | null): this;
48
+ createEntity(props?: any): any;
49
+ createRelation(props?: any): any;
50
+ updateEntity(id: string, patch: any): any;
51
+ updateRelation(id: string, patch: any): any;
52
+ removeComponent(id: string): void;
53
+ toSchemaObject(): object;
54
+ toSchemaString(): string;
55
+ validate(): ReturnType<typeof validateSchema>;
56
+ serializeProject(): string;
57
+ /**
58
+ * 载入项目快照(整体替换当前项目)。
59
+ *
60
+ * 节点按 `typeId` 分派构造:typeId 已注册 → 用注册的构造函数创建(下游二次开发
61
+ * 注册的领域图元同样适用);未注册 → **跳过该节点并记录**,不会导致整份数据打不开,
62
+ * 与引擎 `Deserializer` 的容错语义一致。旧快照没有 typeId 时,按所在数组
63
+ * (entities / relations)归位。
64
+ *
65
+ * @throws 快照结构非法或 schemaVersion 不兼容时抛错;此时当前项目与历史栈都不会被改动。
66
+ * @returns 载入报告(创建数量、被跳过的未知类型)
67
+ */
68
+ loadProject(json: string): ProjectLoadReport;
69
+ private __componentBaseSnapshot;
70
+ private __entitySnapshot;
71
+ private __slotPoint;
72
+ private __relationSnapshot;
73
+ /**
74
+ * 解析并校验快照。
75
+ *
76
+ * @returns 合法快照对象;对于「压根不是项目快照」的输入(例如 `{"nope":true}`)返回 null,
77
+ * 保持历史行为:静默忽略而不是抛错。结构非法时抛错,由调用方决定如何呈现。
78
+ */
79
+ private __parseProject;
80
+ private __applyProject;
81
+ /** typeId 优先;缺省时按所在数组归位(兼容没有 typeId 的旧快照) */
82
+ private __resolveTypeId;
83
+ /** 由 typeId 反查构造函数:优先问 ICE 的注册表(与引擎反序列化一致) */
84
+ private __resolveComponentClass;
85
+ private __recordUnknownType;
86
+ private __applySnapshot;
87
+ private __applyHistorySnapshot;
88
+ canUndo(): boolean;
89
+ canRedo(): boolean;
90
+ captureHistory(): void;
91
+ undo(): void;
92
+ redo(): void;
93
+ /**
94
+ * 订阅模型变更。任何改变模型的操作(增删改 / 载入 / undo / redo)完成后会被通知,
95
+ * 回调参数是当前项目的序列化快照(与 serializeProject() 一致)。
96
+ * @returns 取消订阅函数
97
+ */
98
+ subscribe(listener: (snapshot: string) => void): () => void;
99
+ private __emitChange;
100
+ dispose(): void;
101
+ private __handleMouseDown;
102
+ }
@@ -0,0 +1,102 @@
1
+ import type { ICE } from '../ice-render/index';
2
+ import { validateSchema } from '../utils/schema_validator';
3
+ /** 载入快照时被跳过的节点明细(typeId 未注册) */
4
+ export declare type ProjectLoadSkippedNode = {
5
+ /** 该节点所在的数组 */
6
+ bucket: 'entities' | 'relations';
7
+ /** 该节点在数组中的下标 */
8
+ index: number;
9
+ /** 快照里声明的类型标识 */
10
+ typeId: string;
11
+ /** 快照里的节点 id(若存在),便于定位数据问题 */
12
+ id?: string;
13
+ };
14
+ /** loadProject() 的载入报告 */
15
+ export declare type ProjectLoadReport = {
16
+ /** 是否真的发生了一次项目替换(空值 / 非项目快照为 false) */
17
+ loaded: boolean;
18
+ /** 实际创建出的实体数量 */
19
+ entities: number;
20
+ /** 实际创建出的关系数量 */
21
+ relations: number;
22
+ /** 因未注册被跳过的类型(去重),语义同引擎 `deserializer.unknownTypes` */
23
+ unknownTypes: string[];
24
+ /** 被跳过的节点明细 */
25
+ skipped: ProjectLoadSkippedNode[];
26
+ };
27
+ /**
28
+ * EntityDesigner 是 Entity / Relation 之上的轻量应用层。
29
+ *
30
+ * 它不替代 ICE,也不重复实现底层图元;只负责把 ER 设计器最常用的交互闭环串起来:
31
+ * 选择、创建、更新、删除、关系连接、Schema 输出。
32
+ */
33
+ export default class EntityDesigner {
34
+ ice: ICE;
35
+ selectedId: string | null;
36
+ /** 变更订阅者:任何会改变模型的操作完成后都会被通知(React 绑定层用它驱动 onChange) */
37
+ private __changeListeners;
38
+ private __mousedownHandler;
39
+ private __undoStack;
40
+ private __redoStack;
41
+ private __historyEnabled;
42
+ private __maxHistory;
43
+ constructor(ice: ICE);
44
+ get entities(): any[];
45
+ get relations(): any[];
46
+ get selected(): any;
47
+ select(id: string | null): this;
48
+ createEntity(props?: any): any;
49
+ createRelation(props?: any): any;
50
+ updateEntity(id: string, patch: any): any;
51
+ updateRelation(id: string, patch: any): any;
52
+ removeComponent(id: string): void;
53
+ toSchemaObject(): object;
54
+ toSchemaString(): string;
55
+ validate(): ReturnType<typeof validateSchema>;
56
+ serializeProject(): string;
57
+ /**
58
+ * 载入项目快照(整体替换当前项目)。
59
+ *
60
+ * 节点按 `typeId` 分派构造:typeId 已注册 → 用注册的构造函数创建(下游二次开发
61
+ * 注册的领域图元同样适用);未注册 → **跳过该节点并记录**,不会导致整份数据打不开,
62
+ * 与引擎 `Deserializer` 的容错语义一致。旧快照没有 typeId 时,按所在数组
63
+ * (entities / relations)归位。
64
+ *
65
+ * @throws 快照结构非法或 schemaVersion 不兼容时抛错;此时当前项目与历史栈都不会被改动。
66
+ * @returns 载入报告(创建数量、被跳过的未知类型)
67
+ */
68
+ loadProject(json: string): ProjectLoadReport;
69
+ private __componentBaseSnapshot;
70
+ private __entitySnapshot;
71
+ private __slotPoint;
72
+ private __relationSnapshot;
73
+ /**
74
+ * 解析并校验快照。
75
+ *
76
+ * @returns 合法快照对象;对于「压根不是项目快照」的输入(例如 `{"nope":true}`)返回 null,
77
+ * 保持历史行为:静默忽略而不是抛错。结构非法时抛错,由调用方决定如何呈现。
78
+ */
79
+ private __parseProject;
80
+ private __applyProject;
81
+ /** typeId 优先;缺省时按所在数组归位(兼容没有 typeId 的旧快照) */
82
+ private __resolveTypeId;
83
+ /** 由 typeId 反查构造函数:优先问 ICE 的注册表(与引擎反序列化一致) */
84
+ private __resolveComponentClass;
85
+ private __recordUnknownType;
86
+ private __applySnapshot;
87
+ private __applyHistorySnapshot;
88
+ canUndo(): boolean;
89
+ canRedo(): boolean;
90
+ captureHistory(): void;
91
+ undo(): void;
92
+ redo(): void;
93
+ /**
94
+ * 订阅模型变更。任何改变模型的操作(增删改 / 载入 / undo / redo)完成后会被通知,
95
+ * 回调参数是当前项目的序列化快照(与 serializeProject() 一致)。
96
+ * @returns 取消订阅函数
97
+ */
98
+ subscribe(listener: (snapshot: string) => void): () => void;
99
+ private __emitChange;
100
+ dispose(): void;
101
+ private __handleMouseDown;
102
+ }
@@ -0,0 +1,104 @@
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 { ICEGroup, ICEPolyLine, ICERect, ICEText } from '../ice-render/index.mjs';
9
+ export declare type EntityField = {
10
+ name: string;
11
+ type?: string;
12
+ length?: number | string;
13
+ primary?: boolean;
14
+ foreignKey?: boolean;
15
+ generated?: boolean;
16
+ autoIncrement?: boolean;
17
+ nullable?: boolean;
18
+ unique?: boolean;
19
+ default?: any;
20
+ comment?: string;
21
+ index?: boolean;
22
+ };
23
+ /**
24
+ * @class Entity 实体
25
+ *
26
+ * 所有参数按照 typeorm 要求的格式传入。
27
+ *
28
+ * @see https://typeorm.io/#/separating-entity-definition
29
+ * @author 大漠穷秋<damoqiongqiu@126.com>
30
+ */
31
+ export default class Entity extends ICEGroup {
32
+ /**
33
+ * 稳定的类型标识。
34
+ *
35
+ * 判型与序列化都用它,**不要用 `constructor.name`** —— 下游打包器会 mangle 类名
36
+ * (实测 webpack 生产构建下 Entity → `Dr`),基于类名的判断会静默失效。
37
+ * 属性名默认不会被压缩,子类也会继承这个值。
38
+ */
39
+ static readonly typeId = "Entity";
40
+ protected entityNameComponent: ICEText;
41
+ protected headerBackgroundComponent: ICERect;
42
+ protected deviderLine: ICEPolyLine;
43
+ protected entityFieldsComponent: Array<ICEText>;
44
+ constructor(props: any);
45
+ protected static arrangeParam(props: any): any;
46
+ /**
47
+ * @method syncEntityNameAndFields 同步实体名称和字段
48
+ * 实体名称和字段随时可能发生变化,当变化发生时,会把原有的实体名称和字段全部删除,然后重新创建新的实例。
49
+ * 此方法会在 constructor 和 setState 中被调用。
50
+ * @see setState
51
+ */
52
+ protected syncEntityNameAndFields(): void;
53
+ /**
54
+ * 把字段信息格式化成画布上的可读文本。
55
+ * 常见 ER 工具会展示 PK/FK/UQ/AI/NN 等约束标记,这里做轻量实现。
56
+ */
57
+ protected fieldDisplay(field: EntityField): {
58
+ text: string;
59
+ };
60
+ /**
61
+ * @overwrite
62
+ * @method calcComponentParams
63
+ *
64
+ * @see ICEComponent.calcComponentParams
65
+ * @author 大漠穷秋<damoqiongqiu@126.com>
66
+ */
67
+ protected calcComponentParams(): {
68
+ width: any;
69
+ height: number;
70
+ };
71
+ /**
72
+ * 实体类的 JSON 格式描述,与 type-orm 规定的格式对应
73
+ *
74
+ * {
75
+ * name: "category",
76
+ * columns: {
77
+ * id: {
78
+ * type: Number,
79
+ * primary: true,
80
+ * generated: true
81
+ * },
82
+ * name: {
83
+ * type: String
84
+ * }
85
+ * }
86
+ * }
87
+ *
88
+ * @see https://orkhan.gitbook.io/typeorm/docs/separating-entity-definition
89
+ */
90
+ toEntityObject(): any;
91
+ setState(newState: any): void;
92
+ /**
93
+ * 追加字段,方便应用层以命令式方式维护实体结构。
94
+ */
95
+ addField(field: EntityField): this;
96
+ /**
97
+ * 按字段名删除字段。
98
+ */
99
+ removeField(name: string): this;
100
+ /**
101
+ * 全量替换字段列表。
102
+ */
103
+ setFields(fields: EntityField[]): this;
104
+ }
@@ -1,62 +1,104 @@
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 { ICEGroup, ICEPolyLine, ICEText } from 'ice-render';
9
- /**
10
- * @class Entity 实体
11
- *
12
- * 所有参数按照 typeorm 要求的格式传入。
13
- *
14
- * @see https://typeorm.io/#/separating-entity-definition
15
- * @author 大漠穷秋<damoqiongqiu@126.com>
16
- */
17
- export default class Entity extends ICEGroup {
18
- protected entityNameComponent: ICEText;
19
- protected deviderLine: ICEPolyLine;
20
- protected entityFieldsComponent: Array<ICEText>;
21
- constructor(props: any);
22
- protected static arrangeParam(props: any): any;
23
- /**
24
- * @method syncEntityNameAndFields 同步实体名称和字段
25
- * 实体名称和字段随时可能发生变化,当变化发生时,会把原有的实体名称和字段全部删除,然后重新创建新的实例。
26
- * 此方法会在 constructor 和 setState 中被调用。
27
- * @see setState
28
- */
29
- protected syncEntityNameAndFields(): void;
30
- /**
31
- * @overwrite
32
- * @method calcComponentParams
33
- *
34
- * @see ICEComponent.calcComponentParams
35
- * @author 大漠穷秋<damoqiongqiu@126.com>
36
- */
37
- protected calcComponentParams(): {
38
- width: any;
39
- height: number;
40
- };
41
- /**
42
- * 实体类的 JSON 格式描述,与 type-orm 规定的格式对应
43
- *
44
- * {
45
- * name: "category",
46
- * columns: {
47
- * id: {
48
- * type: Number,
49
- * primary: true,
50
- * generated: true
51
- * },
52
- * name: {
53
- * type: String
54
- * }
55
- * }
56
- * }
57
- *
58
- * @see https://orkhan.gitbook.io/typeorm/docs/separating-entity-definition
59
- */
60
- toEntityObject(): any;
61
- setState(newState: any): void;
62
- }
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 { ICEGroup, ICEPolyLine, ICERect, ICEText } from '../ice-render/index';
9
+ export declare type EntityField = {
10
+ name: string;
11
+ type?: string;
12
+ length?: number | string;
13
+ primary?: boolean;
14
+ foreignKey?: boolean;
15
+ generated?: boolean;
16
+ autoIncrement?: boolean;
17
+ nullable?: boolean;
18
+ unique?: boolean;
19
+ default?: any;
20
+ comment?: string;
21
+ index?: boolean;
22
+ };
23
+ /**
24
+ * @class Entity 实体
25
+ *
26
+ * 所有参数按照 typeorm 要求的格式传入。
27
+ *
28
+ * @see https://typeorm.io/#/separating-entity-definition
29
+ * @author 大漠穷秋<damoqiongqiu@126.com>
30
+ */
31
+ export default class Entity extends ICEGroup {
32
+ /**
33
+ * 稳定的类型标识。
34
+ *
35
+ * 判型与序列化都用它,**不要用 `constructor.name`** —— 下游打包器会 mangle 类名
36
+ * (实测 webpack 生产构建下 Entity → `Dr`),基于类名的判断会静默失效。
37
+ * 属性名默认不会被压缩,子类也会继承这个值。
38
+ */
39
+ static readonly typeId = "Entity";
40
+ protected entityNameComponent: ICEText;
41
+ protected headerBackgroundComponent: ICERect;
42
+ protected deviderLine: ICEPolyLine;
43
+ protected entityFieldsComponent: Array<ICEText>;
44
+ constructor(props: any);
45
+ protected static arrangeParam(props: any): any;
46
+ /**
47
+ * @method syncEntityNameAndFields 同步实体名称和字段
48
+ * 实体名称和字段随时可能发生变化,当变化发生时,会把原有的实体名称和字段全部删除,然后重新创建新的实例。
49
+ * 此方法会在 constructor 和 setState 中被调用。
50
+ * @see setState
51
+ */
52
+ protected syncEntityNameAndFields(): void;
53
+ /**
54
+ * 把字段信息格式化成画布上的可读文本。
55
+ * 常见 ER 工具会展示 PK/FK/UQ/AI/NN 等约束标记,这里做轻量实现。
56
+ */
57
+ protected fieldDisplay(field: EntityField): {
58
+ text: string;
59
+ };
60
+ /**
61
+ * @overwrite
62
+ * @method calcComponentParams
63
+ *
64
+ * @see ICEComponent.calcComponentParams
65
+ * @author 大漠穷秋<damoqiongqiu@126.com>
66
+ */
67
+ protected calcComponentParams(): {
68
+ width: any;
69
+ height: number;
70
+ };
71
+ /**
72
+ * 实体类的 JSON 格式描述,与 type-orm 规定的格式对应
73
+ *
74
+ * {
75
+ * name: "category",
76
+ * columns: {
77
+ * id: {
78
+ * type: Number,
79
+ * primary: true,
80
+ * generated: true
81
+ * },
82
+ * name: {
83
+ * type: String
84
+ * }
85
+ * }
86
+ * }
87
+ *
88
+ * @see https://orkhan.gitbook.io/typeorm/docs/separating-entity-definition
89
+ */
90
+ toEntityObject(): any;
91
+ setState(newState: any): void;
92
+ /**
93
+ * 追加字段,方便应用层以命令式方式维护实体结构。
94
+ */
95
+ addField(field: EntityField): this;
96
+ /**
97
+ * 按字段名删除字段。
98
+ */
99
+ removeField(name: string): this;
100
+ /**
101
+ * 全量替换字段列表。
102
+ */
103
+ setFields(fields: EntityField[]): this;
104
+ }
@@ -0,0 +1,50 @@
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 { ICEVisioLink } from '../ice-render/index.mjs';
9
+ /**
10
+ * @class Relation
11
+ *
12
+ * 用来描述实体类之间的关系,外观是一条带箭头的连接线。
13
+ * 所有参数按照 typeorm 要求的格式传入。
14
+ *
15
+ * @see https://typeorm.io/#/separating-entity-definition
16
+ * @author 大漠穷秋<damoqiongqiu@126.com>
17
+ */
18
+ export default class Relation extends ICEVisioLink {
19
+ /**
20
+ * 稳定的类型标识。判型与序列化都用它,**不要用 `constructor.name`** ——
21
+ * 下游打包会 mangle 类名(实测 webpack 生产构建下 Relation → `Br`),基于类名的判断会静默失效。
22
+ */
23
+ static readonly typeId = "Relation";
24
+ constructor(props?: any);
25
+ /**
26
+ * 根据关系类型推断箭头方向,默认指向 FK 所在的一端。
27
+ */
28
+ static defaultArrow(relationType: string): string;
29
+ /**
30
+ * 兼容语义化的连接点写法:top/right/bottom/left/center -> T/R/B/L/C。
31
+ * 内核 ICELinkSlot 使用单字母标识,这里让应用层可以用更直观的单词。
32
+ */
33
+ private static normalizeLinks;
34
+ /**
35
+ * 允许应用层覆盖两端的基数写法,例如 sourceCardinality: '0..1'。
36
+ */
37
+ static cardinalityLabel(relationType: string, props?: any): string;
38
+ /**
39
+ * 在基数之外把 onDelete / onUpdate 语义显示到连线标签上,便于评审 schema。
40
+ */
41
+ static composeLabel(props: any, relationType: string): string;
42
+ /**
43
+ * 根据当前关系参数重新计算标签,忽略已有的 label,供属性面板实时更新使用。
44
+ */
45
+ static buildLabel(props: any, relationType: string): string;
46
+ /**
47
+ * 实体类的 JSON 格式描述,与 type-orm 规定的格式对应
48
+ */
49
+ toEntityObject(): any;
50
+ }
@@ -1,24 +1,50 @@
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 { ICEVisioLink } from 'ice-render';
9
- /**
10
- * @class Relation
11
- *
12
- * 用来描述实体类之间的关系,外观是一条带箭头的连接线。
13
- * 所有参数按照 typeorm 要求的格式传入。
14
- *
15
- * @see https://typeorm.io/#/separating-entity-definition
16
- * @author 大漠穷秋<damoqiongqiu@126.com>
17
- */
18
- export default class Relation extends ICEVisioLink {
19
- constructor(props: any);
20
- /**
21
- * 实体类的 JSON 格式描述,与 type-orm 规定的格式对应
22
- */
23
- toEntityObject(): any;
24
- }
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 { ICEVisioLink } from '../ice-render/index';
9
+ /**
10
+ * @class Relation
11
+ *
12
+ * 用来描述实体类之间的关系,外观是一条带箭头的连接线。
13
+ * 所有参数按照 typeorm 要求的格式传入。
14
+ *
15
+ * @see https://typeorm.io/#/separating-entity-definition
16
+ * @author 大漠穷秋<damoqiongqiu@126.com>
17
+ */
18
+ export default class Relation extends ICEVisioLink {
19
+ /**
20
+ * 稳定的类型标识。判型与序列化都用它,**不要用 `constructor.name`** ——
21
+ * 下游打包会 mangle 类名(实测 webpack 生产构建下 Relation → `Br`),基于类名的判断会静默失效。
22
+ */
23
+ static readonly typeId = "Relation";
24
+ constructor(props?: any);
25
+ /**
26
+ * 根据关系类型推断箭头方向,默认指向 FK 所在的一端。
27
+ */
28
+ static defaultArrow(relationType: string): string;
29
+ /**
30
+ * 兼容语义化的连接点写法:top/right/bottom/left/center -> T/R/B/L/C。
31
+ * 内核 ICELinkSlot 使用单字母标识,这里让应用层可以用更直观的单词。
32
+ */
33
+ private static normalizeLinks;
34
+ /**
35
+ * 允许应用层覆盖两端的基数写法,例如 sourceCardinality: '0..1'。
36
+ */
37
+ static cardinalityLabel(relationType: string, props?: any): string;
38
+ /**
39
+ * 在基数之外把 onDelete / onUpdate 语义显示到连线标签上,便于评审 schema。
40
+ */
41
+ static composeLabel(props: any, relationType: string): string;
42
+ /**
43
+ * 根据当前关系参数重新计算标签,忽略已有的 label,供属性面板实时更新使用。
44
+ */
45
+ static buildLabel(props: any, relationType: string): string;
46
+ /**
47
+ * 实体类的 JSON 格式描述,与 type-orm 规定的格式对应
48
+ */
49
+ toEntityObject(): any;
50
+ }