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.
- package/LICENSE +0 -0
- package/README.md +229 -141
- package/dist/THIRD-PARTY-NOTICES.txt +32 -0
- package/dist/index.cjs +30 -0
- package/dist/index.mjs +30 -0
- package/dist/index.umd.js +6 -1
- package/dist/types/FrameManager.d.mts +26 -0
- package/dist/types/FrameManager.d.ts +26 -26
- package/dist/types/ICE.d.mts +369 -0
- package/dist/types/ICE.d.ts +369 -107
- package/dist/types/a11y/accessibility.d.mts +46 -0
- package/dist/types/a11y/accessibility.d.ts +46 -0
- package/dist/types/animation/AnimationManager.d.mts +96 -0
- package/dist/types/animation/AnimationManager.d.ts +96 -25
- package/dist/types/animation/Easing.d.mts +33 -0
- package/dist/types/animation/Easing.d.ts +33 -32
- package/dist/types/consts/BIG_ZINDEX_NUMBER.d.mts +14 -0
- package/dist/types/consts/BIG_ZINDEX_NUMBER.d.ts +14 -14
- package/dist/types/consts/COMPONENT_TYPE_MAPPING.d.mts +45 -0
- package/dist/types/consts/COMPONENT_TYPE_MAPPING.d.ts +45 -36
- package/dist/types/consts/DOM_EVENT_MAPPING_CONSTS.d.mts +37 -0
- package/dist/types/consts/DOM_EVENT_MAPPING_CONSTS.d.ts +37 -19
- package/dist/types/consts/ICE_EVENT_NAME_CONSTS.d.mts +27 -0
- package/dist/types/consts/ICE_EVENT_NAME_CONSTS.d.ts +27 -20
- package/dist/types/control-panel/AlignmentGuideManager.d.mts +92 -0
- package/dist/types/control-panel/AlignmentGuideManager.d.ts +92 -0
- package/dist/types/control-panel/ICEControlPanel.d.mts +37 -0
- package/dist/types/control-panel/ICEControlPanel.d.ts +37 -37
- package/dist/types/control-panel/ICEControlPanelManager.d.mts +25 -0
- package/dist/types/control-panel/ICEControlPanelManager.d.ts +25 -23
- package/dist/types/control-panel/link-controls/LineControlPanel.d.mts +39 -0
- package/dist/types/control-panel/link-controls/LineControlPanel.d.ts +39 -39
- package/dist/types/control-panel/transform-controls/ResizeControl.d.mts +38 -0
- package/dist/types/control-panel/transform-controls/ResizeControl.d.ts +38 -38
- package/dist/types/control-panel/transform-controls/RotateControl.d.mts +12 -0
- package/dist/types/control-panel/transform-controls/RotateControl.d.ts +12 -12
- package/dist/types/control-panel/transform-controls/TransformControlPanel.d.mts +83 -0
- package/dist/types/control-panel/transform-controls/TransformControlPanel.d.ts +83 -74
- package/dist/types/control-panel/transform-controls/constraints.d.mts +24 -0
- package/dist/types/control-panel/transform-controls/constraints.d.ts +24 -0
- package/dist/types/cross-platform/PolyfillPath2D.d.mts +31 -0
- package/dist/types/cross-platform/PolyfillPath2D.d.ts +31 -0
- package/dist/types/cross-platform/root.d.mts +7 -0
- package/dist/types/cross-platform/root.d.ts +7 -2
- package/dist/types/event/DOMEventDispatcher.d.mts +68 -0
- package/dist/types/event/DOMEventDispatcher.d.ts +68 -29
- package/dist/types/event/DOMEventInterceptor.d.mts +36 -0
- package/dist/types/event/DOMEventInterceptor.d.ts +36 -7
- package/dist/types/event/EventBus.d.mts +27 -0
- package/dist/types/event/EventBus.d.ts +27 -27
- package/dist/types/event/ICEEvent.d.mts +46 -0
- package/dist/types/event/ICEEvent.d.ts +46 -46
- package/dist/types/event/ICEEventTarget.d.mts +106 -0
- package/dist/types/event/ICEEventTarget.d.ts +106 -106
- package/dist/types/event/input-normalize.d.mts +75 -0
- package/dist/types/event/input-normalize.d.ts +75 -0
- package/dist/types/geometry/GeoLine.d.mts +24 -0
- package/dist/types/geometry/GeoLine.d.ts +24 -23
- package/dist/types/geometry/GeoPoint.d.mts +53 -0
- package/dist/types/geometry/GeoPoint.d.ts +53 -66
- package/dist/types/geometry/GeoUtil.d.mts +73 -0
- package/dist/types/geometry/GeoUtil.d.ts +73 -37
- package/dist/types/geometry/ICEBoundingBox.d.mts +81 -0
- package/dist/types/geometry/ICEBoundingBox.d.ts +81 -81
- package/dist/types/graphic/ICEComponent.d.mts +436 -0
- package/dist/types/graphic/ICEComponent.d.ts +436 -264
- package/dist/types/graphic/ICEDotPath.d.mts +99 -0
- package/dist/types/graphic/ICEDotPath.d.ts +99 -63
- package/dist/types/graphic/ICEImage.d.mts +17 -0
- package/dist/types/graphic/ICEImage.d.ts +17 -17
- package/dist/types/graphic/ICEPath.d.mts +39 -0
- package/dist/types/graphic/ICEPath.d.ts +39 -36
- package/dist/types/graphic/container/ICEGroup.d.mts +101 -0
- package/dist/types/graphic/container/ICEGroup.d.ts +101 -53
- package/dist/types/graphic/link/ICEBezier.d.mts +23 -0
- package/dist/types/graphic/link/ICEBezier.d.ts +23 -15
- package/dist/types/graphic/link/ICELinkHook.d.mts +52 -0
- package/dist/types/graphic/link/ICELinkHook.d.ts +52 -52
- package/dist/types/graphic/link/ICELinkSlot.d.mts +54 -0
- package/dist/types/graphic/link/ICELinkSlot.d.ts +54 -46
- package/dist/types/graphic/link/ICELinkSlotManager.d.mts +28 -0
- package/dist/types/graphic/link/ICELinkSlotManager.d.ts +28 -28
- package/dist/types/graphic/link/ICEPolyLine.d.mts +292 -0
- package/dist/types/graphic/link/ICEPolyLine.d.ts +292 -219
- package/dist/types/graphic/link/ICEVisioLink.d.mts +163 -0
- package/dist/types/graphic/link/ICEVisioLink.d.ts +163 -129
- package/dist/types/graphic/shape/ICECircle.d.mts +19 -0
- package/dist/types/graphic/shape/ICECircle.d.ts +19 -19
- package/dist/types/graphic/shape/ICEEllipse.d.mts +29 -0
- package/dist/types/graphic/shape/ICEEllipse.d.ts +29 -23
- package/dist/types/graphic/shape/ICEIsogon.d.mts +52 -0
- package/dist/types/graphic/shape/ICEIsogon.d.ts +52 -52
- package/dist/types/graphic/shape/ICERect.d.mts +10 -0
- package/dist/types/graphic/shape/ICERect.d.ts +10 -17
- package/dist/types/graphic/shape/ICERose.d.mts +41 -0
- package/dist/types/graphic/shape/ICERose.d.ts +41 -41
- package/dist/types/graphic/shape/ICEStar.d.mts +45 -0
- package/dist/types/graphic/shape/ICEStar.d.ts +45 -45
- package/dist/types/graphic/text/ICEText.d.mts +137 -0
- package/dist/types/graphic/text/ICEText.d.ts +137 -65
- package/dist/types/index.d.mts +55 -0
- package/dist/types/index.d.ts +55 -41
- package/dist/types/layout/ICEBorderLayout.d.mts +34 -0
- package/dist/types/layout/ICEBorderLayout.d.ts +34 -0
- package/dist/types/layout/ICEBoxLayout.d.mts +30 -0
- package/dist/types/layout/ICEBoxLayout.d.ts +30 -0
- package/dist/types/layout/ICECardLayout.d.mts +36 -0
- package/dist/types/layout/ICECardLayout.d.ts +36 -0
- package/dist/types/layout/ICEFlowLayout.d.mts +31 -0
- package/dist/types/layout/ICEFlowLayout.d.ts +31 -0
- package/dist/types/layout/ICEGridLayout.d.mts +33 -0
- package/dist/types/layout/ICEGridLayout.d.ts +33 -0
- package/dist/types/layout/ICELayeredLayout.d.mts +49 -0
- package/dist/types/layout/ICELayeredLayout.d.ts +49 -0
- package/dist/types/layout/ICELayoutManager.d.mts +33 -0
- package/dist/types/layout/ICELayoutManager.d.ts +33 -0
- package/dist/types/layout/ICEOverlayLayout.d.mts +25 -0
- package/dist/types/layout/ICEOverlayLayout.d.ts +25 -0
- package/dist/types/persistence/Deserializer.d.mts +43 -0
- package/dist/types/persistence/Deserializer.d.ts +43 -14
- package/dist/types/persistence/Serializer.d.mts +35 -0
- package/dist/types/persistence/Serializer.d.ts +35 -26
- package/dist/types/plugin/PluginHost.d.mts +86 -0
- package/dist/types/plugin/PluginHost.d.ts +86 -0
- package/dist/types/renderer/CanvasRenderer.d.mts +150 -0
- package/dist/types/renderer/CanvasRenderer.d.ts +150 -22
- package/dist/types/renderer/ObjectCache.d.mts +79 -0
- package/dist/types/renderer/ObjectCache.d.ts +79 -0
- package/dist/types/renderer/dirty-rect-util.d.mts +86 -0
- package/dist/types/renderer/dirty-rect-util.d.ts +86 -0
- package/dist/types/theme/ICETheme.d.mts +382 -0
- package/dist/types/theme/ICETheme.d.ts +382 -0
- package/dist/types/util/ImageCache.d.mts +19 -0
- package/dist/types/util/ImageCache.d.ts +19 -19
- package/dist/types/util/data-util.d.mts +43 -0
- package/dist/types/util/data-util.d.ts +43 -19
- package/dist/types/util/gl-matrix-skew.d.mts +14 -0
- package/dist/types/util/gl-matrix-skew.d.ts +14 -14
- package/dist/types/util/lang.d.mts +28 -0
- package/dist/types/util/lang.d.ts +28 -0
- package/dist/types/util/uuid.d.mts +1 -0
- package/dist/types/util/uuid.d.ts +1 -1
- package/package.json +118 -81
- package/dist/index.cjs.js +0 -25
- package/dist/index.js +0 -25
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @singleton
|
|
3
|
+
* @class FrameManager 帧频控制器
|
|
4
|
+
*
|
|
5
|
+
* - 全局单例,请勿创建多个实例。
|
|
6
|
+
* - 在同一个 window/global 中,只有一个 FrameManager ,也就是说 FrameManager 是跨 ICE 实例共享的。
|
|
7
|
+
* - FrameManager 只负责把 window/global 上的 requestAnimationFrame 回调函数转换成 ICE_EVENT_NAME_CONSTS.ICE_FRAME_EVENT 事件,然后在所有事件总线上进行触发。
|
|
8
|
+
* - FrameManager 只触发事件,不进行渲染,渲染操作由对应的 Render 完成。
|
|
9
|
+
* - FrameManager 与 EventBus 之间是一对多的关系,一个 FrameManager 上可以注册多个事件总线,因为同一个页面上可能会存在多幅画面。
|
|
10
|
+
*
|
|
11
|
+
* @see ICE
|
|
12
|
+
* @author 大漠穷秋<damoqiongqiu@126.com>
|
|
13
|
+
*/
|
|
14
|
+
declare const FrameManager: {
|
|
15
|
+
evtBuses: any[];
|
|
16
|
+
stopped: boolean;
|
|
17
|
+
frameCallback: () => void;
|
|
18
|
+
start: () => void;
|
|
19
|
+
stop: () => void;
|
|
20
|
+
/**
|
|
21
|
+
* @method registerEvtBus 注册事件总线
|
|
22
|
+
*/
|
|
23
|
+
registerEvtBus: (evtBus: any) => void;
|
|
24
|
+
delEvtBus: (evtBus: any) => void;
|
|
25
|
+
};
|
|
26
|
+
export default FrameManager;
|
|
@@ -1,26 +1,26 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @singleton
|
|
3
|
-
* @class FrameManager 帧频控制器
|
|
4
|
-
*
|
|
5
|
-
* - 全局单例,请勿创建多个实例。
|
|
6
|
-
* - 在同一个 window/global 中,只有一个 FrameManager ,也就是说 FrameManager 是跨 ICE 实例共享的。
|
|
7
|
-
* - FrameManager 只负责把 window/global 上的 requestAnimationFrame 回调函数转换成 ICE_EVENT_NAME_CONSTS.ICE_FRAME_EVENT 事件,然后在所有事件总线上进行触发。
|
|
8
|
-
* - FrameManager 只触发事件,不进行渲染,渲染操作由对应的 Render 完成。
|
|
9
|
-
* - FrameManager 与 EventBus 之间是一对多的关系,一个 FrameManager 上可以注册多个事件总线,因为同一个页面上可能会存在多幅画面。
|
|
10
|
-
*
|
|
11
|
-
* @see ICE
|
|
12
|
-
* @author 大漠穷秋<damoqiongqiu@126.com>
|
|
13
|
-
*/
|
|
14
|
-
declare const FrameManager: {
|
|
15
|
-
evtBuses: any[];
|
|
16
|
-
stopped: boolean;
|
|
17
|
-
frameCallback: () => void;
|
|
18
|
-
start: () => void;
|
|
19
|
-
stop: () => void;
|
|
20
|
-
/**
|
|
21
|
-
* @method registerEvtBus 注册事件总线
|
|
22
|
-
*/
|
|
23
|
-
|
|
24
|
-
delEvtBus: (evtBus: any) => void;
|
|
25
|
-
};
|
|
26
|
-
export default FrameManager;
|
|
1
|
+
/**
|
|
2
|
+
* @singleton
|
|
3
|
+
* @class FrameManager 帧频控制器
|
|
4
|
+
*
|
|
5
|
+
* - 全局单例,请勿创建多个实例。
|
|
6
|
+
* - 在同一个 window/global 中,只有一个 FrameManager ,也就是说 FrameManager 是跨 ICE 实例共享的。
|
|
7
|
+
* - FrameManager 只负责把 window/global 上的 requestAnimationFrame 回调函数转换成 ICE_EVENT_NAME_CONSTS.ICE_FRAME_EVENT 事件,然后在所有事件总线上进行触发。
|
|
8
|
+
* - FrameManager 只触发事件,不进行渲染,渲染操作由对应的 Render 完成。
|
|
9
|
+
* - FrameManager 与 EventBus 之间是一对多的关系,一个 FrameManager 上可以注册多个事件总线,因为同一个页面上可能会存在多幅画面。
|
|
10
|
+
*
|
|
11
|
+
* @see ICE
|
|
12
|
+
* @author 大漠穷秋<damoqiongqiu@126.com>
|
|
13
|
+
*/
|
|
14
|
+
declare const FrameManager: {
|
|
15
|
+
evtBuses: any[];
|
|
16
|
+
stopped: boolean;
|
|
17
|
+
frameCallback: () => void;
|
|
18
|
+
start: () => void;
|
|
19
|
+
stop: () => void;
|
|
20
|
+
/**
|
|
21
|
+
* @method registerEvtBus 注册事件总线
|
|
22
|
+
*/
|
|
23
|
+
registerEvtBus: (evtBus: any) => void;
|
|
24
|
+
delEvtBus: (evtBus: any) => void;
|
|
25
|
+
};
|
|
26
|
+
export default FrameManager;
|
|
@@ -0,0 +1,369 @@
|
|
|
1
|
+
import AnimationManager from './animation/AnimationManager.mjs';
|
|
2
|
+
import ICEControlPanelManager from './control-panel/ICEControlPanelManager.mjs';
|
|
3
|
+
import AlignmentGuideManager from './control-panel/AlignmentGuideManager.mjs';
|
|
4
|
+
import DOMEventDispatcher from './event/DOMEventDispatcher.mjs';
|
|
5
|
+
import EventBus from './event/EventBus.mjs';
|
|
6
|
+
import ICEComponent from './graphic/ICEComponent.mjs';
|
|
7
|
+
import ICELinkSlotManager from './graphic/link/ICELinkSlotManager.mjs';
|
|
8
|
+
import Deserializer from './persistence/Deserializer.mjs';
|
|
9
|
+
import Serializer from './persistence/Serializer.mjs';
|
|
10
|
+
import PluginHost, { ICEPlugin } from './plugin/PluginHost.mjs';
|
|
11
|
+
import { ICEAccessibleNode, ICEAccessibilityOptions } from './a11y/accessibility.mjs';
|
|
12
|
+
import ImageCache from './util/ImageCache.mjs';
|
|
13
|
+
import { ICETheme, ICESemanticTheme } from './theme/ICETheme.mjs';
|
|
14
|
+
/**
|
|
15
|
+
* @class ICE
|
|
16
|
+
*
|
|
17
|
+
* - ICE 是整个引擎的主入口类。
|
|
18
|
+
* - 同一个 canvas 标签上只能初始化一个 ICE 实例。
|
|
19
|
+
* - 同一个页面上可以存在多幅图。
|
|
20
|
+
*
|
|
21
|
+
* @author 大漠穷秋<damoqiongqiu@126.com>
|
|
22
|
+
*/
|
|
23
|
+
declare class ICE {
|
|
24
|
+
childNodes: any[];
|
|
25
|
+
toolNodes: any[];
|
|
26
|
+
private __childSet;
|
|
27
|
+
private __toolSet;
|
|
28
|
+
evtBus: EventBus;
|
|
29
|
+
root: any;
|
|
30
|
+
canvasEl: any;
|
|
31
|
+
ctx: any;
|
|
32
|
+
canvasWidth: number;
|
|
33
|
+
canvasHeight: number;
|
|
34
|
+
canvasBoundingClientRect: any;
|
|
35
|
+
/** 视口变换(视图缩放/平移):屏幕 = 世界 * scale + translate。默认单位视口,不影响既有行为。 */
|
|
36
|
+
viewport: {
|
|
37
|
+
scale: number;
|
|
38
|
+
tx: number;
|
|
39
|
+
ty: number;
|
|
40
|
+
};
|
|
41
|
+
/**
|
|
42
|
+
* 设备像素比。默认 1(不改变既有行为)。
|
|
43
|
+
*
|
|
44
|
+
* 传 >1 时(`ICE.init(el, { dpr: 2 })`):引擎把 canvas 的 backing store 放大到 cssSize*dpr,
|
|
45
|
+
* 渲染变换乘以 dpr,从而在高分屏上不发虚。**交互侧(命中/拖拽/吸附)仍用 CSS 像素语义**,
|
|
46
|
+
* 因为鼠标/触摸坐标本身就是 CSS 像素,所以 screenToWorld 不参与 dpr。
|
|
47
|
+
*/
|
|
48
|
+
dpr: number;
|
|
49
|
+
/** 渲染用视口缓存(= dpr · viewport),避免每组件每帧分配对象。 */
|
|
50
|
+
private __renderVp;
|
|
51
|
+
/**
|
|
52
|
+
* canvas 内容盒(绘制区)相对视口的偏移与尺寸。
|
|
53
|
+
*
|
|
54
|
+
* `getBoundingClientRect()` 返回的是 **border-box**,而 canvas 的绘制区是**内容盒**:
|
|
55
|
+
* 画布带 border / padding 时,若直接用 rect.left/top 换算鼠标坐标会整体偏移(差一个边框宽),
|
|
56
|
+
* backing store 尺寸也会被边框撑大。这里在刷新 rect 时一并读取 computedStyle 补偿。
|
|
57
|
+
*/
|
|
58
|
+
private __contentBox;
|
|
59
|
+
selectionList: Array<any>;
|
|
60
|
+
/** 插件宿主:组件 / 渲染 / 交互工具三层注册点,见 `src/plugin/PluginHost.ts`。 */
|
|
61
|
+
plugins: PluginHost;
|
|
62
|
+
/**
|
|
63
|
+
* 当前实例持有的主题(**实例级**,互不污染)。
|
|
64
|
+
*
|
|
65
|
+
* 初始值取模块级默认主题;`setTheme()` 只改本实例。
|
|
66
|
+
* 组件构造时若用了 `preset`,会在加入本实例时按这里的主题重新解析一次
|
|
67
|
+
* (见 `addChild` / `addTool` 中的 `__reapplyPreset`)。
|
|
68
|
+
*/
|
|
69
|
+
theme: ICETheme;
|
|
70
|
+
typeMapping: {};
|
|
71
|
+
/** 构造函数 → 类型名 的反查表(序列化用)。惰性构建,registerType/init 后失效重建。 */
|
|
72
|
+
private __typeIdMapping;
|
|
73
|
+
renderer: any;
|
|
74
|
+
animationManager: AnimationManager;
|
|
75
|
+
eventDispatcher: DOMEventDispatcher;
|
|
76
|
+
controlPanelManager: ICEControlPanelManager;
|
|
77
|
+
alignmentGuide: AlignmentGuideManager;
|
|
78
|
+
linkSlotManager: ICELinkSlotManager;
|
|
79
|
+
serializer: Serializer;
|
|
80
|
+
deserializer: Deserializer;
|
|
81
|
+
imageCache: ImageCache;
|
|
82
|
+
private __dirty;
|
|
83
|
+
constructor();
|
|
84
|
+
/** 是否已经完成初始化(用于 init 幂等 / destroy 配对) */
|
|
85
|
+
private __initialized;
|
|
86
|
+
/**
|
|
87
|
+
* 从 init 入参解析出 canvas 元素。
|
|
88
|
+
* 支持:HTMLCanvasElement、CanvasRenderingContext2D;解析不出则返回 null。
|
|
89
|
+
*/
|
|
90
|
+
private __resolveCanvasEl;
|
|
91
|
+
/**
|
|
92
|
+
* @param ctx DOM id、HTMLCanvasElement 或 CanvasRenderingContext2D
|
|
93
|
+
* @param options 渲染配置。renderMode: 'dirty-rect'(默认) | 'full'
|
|
94
|
+
*
|
|
95
|
+
* 幂等:同一个 ICE 实例重复 init 到同一个 canvas 时直接返回自身。
|
|
96
|
+
* React StrictMode 下 effect 会被执行两次,幂等可以避免重复挂载 Manager / 重复绑定全局事件。
|
|
97
|
+
* 若要换一个 canvas,请先调用 destroy()。
|
|
98
|
+
*/
|
|
99
|
+
init(ctx: any, options?: {
|
|
100
|
+
renderMode?: 'full' | 'dirty-rect';
|
|
101
|
+
dpr?: number;
|
|
102
|
+
}): this;
|
|
103
|
+
/**
|
|
104
|
+
* @method destroy 销毁当前实例
|
|
105
|
+
*
|
|
106
|
+
* 与 init() 配对:停止所有 Manager、解绑 canvas 上的原生事件、注销全局事件总线(FrameManager / DOMEventInterceptor 都是全局单例,必须显式注销)。
|
|
107
|
+
* 销毁之后可以再次 init(例如 React 组件重新挂载),不会累积监听或帧循环。
|
|
108
|
+
*/
|
|
109
|
+
destroy(): void;
|
|
110
|
+
/**
|
|
111
|
+
* @method addChild
|
|
112
|
+
* 添加交互工具组件。
|
|
113
|
+
* 工具组件不触发事件,不产生动画效果。
|
|
114
|
+
* @param {ICEComponent} tool
|
|
115
|
+
*/
|
|
116
|
+
addTool(tool: ICEComponent): void;
|
|
117
|
+
/**
|
|
118
|
+
* @methos removeTool
|
|
119
|
+
* 删除交互工具组件。
|
|
120
|
+
* 工具组件不触发事件,不产生动画效果。
|
|
121
|
+
* @param tool
|
|
122
|
+
*/
|
|
123
|
+
removeTool(tool: ICEComponent): void;
|
|
124
|
+
/**
|
|
125
|
+
*
|
|
126
|
+
* 调用 ICE.addChild() 方法,会直接把对象画在 canvas 上。
|
|
127
|
+
* 如果需要在容器中画组件,参见 @see ICEGroup.addChild() 方法
|
|
128
|
+
*
|
|
129
|
+
* @param component
|
|
130
|
+
*/
|
|
131
|
+
addChild(component: any, markDirty?: boolean): void;
|
|
132
|
+
addChildren(arr: Array<ICEComponent>): void;
|
|
133
|
+
removeChild(component: ICEComponent, markDirty?: boolean): void;
|
|
134
|
+
removeChildren(arr: Array<ICEComponent>): void;
|
|
135
|
+
clearAll(): void;
|
|
136
|
+
/**
|
|
137
|
+
* 按 id 查找组件。
|
|
138
|
+
*
|
|
139
|
+
* 查找范围:**先查顶层 `childNodes`**(同 id 时顶层优先,保持既有优先级),再深度优先递归整棵
|
|
140
|
+
* 子树。「连线连接嵌套子组件」依赖本方法(`ICEPolyLine.syncConnections` → 本方法)。
|
|
141
|
+
*
|
|
142
|
+
* **工具层 `toolNodes` 不参与查找**:工具是 UI 覆盖层(变换/连线手柄等),不应成为连线端点。
|
|
143
|
+
*
|
|
144
|
+
* 历史:早期只搜第一层,嵌套场景连线会静默失效;中途曾尝试放开递归但被回退 ——
|
|
145
|
+
* 当时表现为 `dirty-rect-pixel` 富场景 step1 约 900 px 差异,看起来像「连线端点推导与局部重绘
|
|
146
|
+
* 冲突」,实际根因是**折线的包围盒是退化的**(`state.width ≈ 0`),导致 dirty-rect 按快照盒
|
|
147
|
+
* 挑选重画对象时漏掉折线(擦除区域内的折线笔迹丢失)。该根因已修(见 `ICEComponent.__localBox`
|
|
148
|
+
* 与 `ICEPolyLine.calcComponentParams`),因此递归可以放开。
|
|
149
|
+
*/
|
|
150
|
+
findComponent(id: string): any;
|
|
151
|
+
/** 深度优先查找子树(不含工具层)。 */
|
|
152
|
+
private __findComponentInTree;
|
|
153
|
+
set dirty(flag: boolean);
|
|
154
|
+
get dirty(): boolean;
|
|
155
|
+
/**
|
|
156
|
+
* @method registerType 注册组件类型
|
|
157
|
+
*
|
|
158
|
+
* - 需要在反序列化之前调用,否则无法反序列化。
|
|
159
|
+
* - ICE 内置的类型已经自动注册,不需要手动注册。
|
|
160
|
+
*
|
|
161
|
+
* @param className
|
|
162
|
+
* @param Clazz
|
|
163
|
+
*/
|
|
164
|
+
registerType(className: string, Clazz: new (...args: any[]) => any): void;
|
|
165
|
+
/**
|
|
166
|
+
* 由构造函数反查稳定的类型名(序列化用)。
|
|
167
|
+
*
|
|
168
|
+
* - 已注册的类型:返回注册名(与类的 JS 名解耦,压缩改名不影响已存数据)
|
|
169
|
+
* - 未注册:返回 undefined,调用方回退到 `constructor.name`(保持既有行为)
|
|
170
|
+
* - 同一个构造函数注册了多个名字时,**先注册的优先**(内置类型因此不会被别名顶掉)
|
|
171
|
+
*/
|
|
172
|
+
getTypeId(Clazz: new (...args: any[]) => any): string | undefined;
|
|
173
|
+
/**
|
|
174
|
+
* 注册插件(幂等:同名插件重复调用直接返回,不重复 setup)。
|
|
175
|
+
*
|
|
176
|
+
* 插件可提供三层扩展点:`components`(自定义图元类型)、`render`(每帧绘制回调)、
|
|
177
|
+
* `tools`(按选中组件匹配的交互工具)。详见 `src/plugin/PluginHost.ts`。
|
|
178
|
+
*
|
|
179
|
+
* @returns 是否本次真的注册(同名已存在时为 false)
|
|
180
|
+
*/
|
|
181
|
+
use(plugin: ICEPlugin): boolean;
|
|
182
|
+
/**
|
|
183
|
+
* 注销插件:撤销其渲染回调与交互工具,并调用 `teardown`。
|
|
184
|
+
* 注意:`components` 里注册的类型**保留**(反序列化可能仍依赖,且撤销会让已存数据失效)。
|
|
185
|
+
*/
|
|
186
|
+
unuse(name: string): boolean;
|
|
187
|
+
/** 已注册插件名(只读快照)。 */
|
|
188
|
+
getPlugins(): string[];
|
|
189
|
+
/**
|
|
190
|
+
* 更新选中集合的**统一入口**:写 `selectionList` 并同步插件工具。
|
|
191
|
+
* 约定:目前插件工具按「首个选中组件」匹配(引擎当前也仅支持单选)。
|
|
192
|
+
*
|
|
193
|
+
* @returns 是否有「排他」插件工具命中 —— 调用方据此禁用内置变换/连线面板
|
|
194
|
+
*/
|
|
195
|
+
setSelection(components: Array<any> | any | null): boolean;
|
|
196
|
+
/**
|
|
197
|
+
* 无障碍:取「可访问节点快照」,供应用层渲染隐藏 DOM 镜像(screen reader / 键盘导航)。
|
|
198
|
+
*
|
|
199
|
+
* 引擎**不**自建 DOM 镜像层 —— 镜像的 DOM 结构、ARIA 属性、文案与焦点环高度依赖具体产品语义。
|
|
200
|
+
* 引擎负责给出:id / 角色建议 / 可读名称 / **屏幕坐标盒(CSS 像素)** / 层级 / tab 顺序 / 选中态;
|
|
201
|
+
* 应用层据此渲染 `<div role="img" aria-label=... style="position:absolute; ...">` 之类的镜像元素,
|
|
202
|
+
* 并用 `setFocusedComponent()` 把 DOM 焦点映射回组件。
|
|
203
|
+
*
|
|
204
|
+
* 不含未上屏(无有效变换矩阵)的组件,也不会修改任何组件 state。
|
|
205
|
+
*/
|
|
206
|
+
getAccessibilityTree(options?: ICEAccessibilityOptions): ICEAccessibleNode[];
|
|
207
|
+
/**
|
|
208
|
+
* 设置键盘事件的焦点组件(无障碍 / 键盘导航原语)。
|
|
209
|
+
*
|
|
210
|
+
* 未设置时维持既有行为:键盘事件派发给「上次点击命中的组件」。
|
|
211
|
+
* 传入 id 字符串或组件实例;传 null / undefined 清除焦点。
|
|
212
|
+
*/
|
|
213
|
+
setFocusedComponent(component: any | string | null): this;
|
|
214
|
+
/** 当前键盘焦点组件(未设置时为 null)。 */
|
|
215
|
+
getFocusedComponent(): any;
|
|
216
|
+
/**
|
|
217
|
+
* @method getType 获取组件构造函数
|
|
218
|
+
* @param className
|
|
219
|
+
* @returns
|
|
220
|
+
*/
|
|
221
|
+
getType(className: string): any;
|
|
222
|
+
/**
|
|
223
|
+
* 加载自定义字体(平台适配):浏览器走 FontFace API,小程序走 wx.loadFont。
|
|
224
|
+
* 加载后,在 ICEText 的 style.fontFamily 里引用该字体名即可。
|
|
225
|
+
* @param family 字体族名(如 'MyFont')
|
|
226
|
+
* @param source 字体源(浏览器为 url/二进制,小程序为本地文件路径)
|
|
227
|
+
*/
|
|
228
|
+
loadFont(family: string, source: string): Promise<any>;
|
|
229
|
+
/**
|
|
230
|
+
* 切换主题(string 按名切换 / object 浅合并 semantic),预设样式(preset)会自动跟随主题变量。
|
|
231
|
+
* 热切换:已渲染的组件里用了 preset 的会重新 resolve(用户显式传的样式优先)。
|
|
232
|
+
*/
|
|
233
|
+
setTheme(theme: string | Partial<ICESemanticTheme>): this;
|
|
234
|
+
/**
|
|
235
|
+
* 设置视口(视图缩放 + 平移)。
|
|
236
|
+
*
|
|
237
|
+
* 屏幕坐标 = 世界坐标 * scale + translate。这是「视图缩放」,不改变任何组件的 state,
|
|
238
|
+
* 只影响渲染结果与命中检测的坐标换算。视口变化会让渲染器回退一次全量重绘并重建快照。
|
|
239
|
+
*/
|
|
240
|
+
setViewport(scale: number, tx?: number, ty?: number): this;
|
|
241
|
+
/** 屏幕坐标(canvas 像素)→ 世界坐标(受视口逆变换)。 */
|
|
242
|
+
screenToWorld(sx: number, sy: number): [number, number];
|
|
243
|
+
/** 世界坐标 → 屏幕坐标(canvas 像素)。 */
|
|
244
|
+
worldToScreen(wx: number, wy: number): [number, number];
|
|
245
|
+
/**
|
|
246
|
+
* 刷新 canvas 的 getBoundingClientRect 缓存并返回。
|
|
247
|
+
*
|
|
248
|
+
* 输入事件用它把屏幕坐标换算成 canvas 内坐标;页面滚动 / 布局变化后必须刷新,
|
|
249
|
+
* 否则命中检测会整体偏移(旧实现只在 init 时取一次,滚动后即失效)。
|
|
250
|
+
* 高频的移动类事件复用缓存,见 DOMEventDispatcher.__resolveCanvasRect。
|
|
251
|
+
*/
|
|
252
|
+
/**
|
|
253
|
+
* 渲染用视口 = dpr · viewport(仅「往画布上画」这一侧需要乘 dpr)。
|
|
254
|
+
* dpr === 1 时**直接返回 viewport 本身**:零分配、且与既有行为逐字节一致。
|
|
255
|
+
*/
|
|
256
|
+
getRenderViewport(): {
|
|
257
|
+
scale: number;
|
|
258
|
+
tx: number;
|
|
259
|
+
ty: number;
|
|
260
|
+
};
|
|
261
|
+
/**
|
|
262
|
+
* 把 canvas 的 backing store 放大到 cssSize * dpr,并把 CSS 尺寸固定为逻辑尺寸。
|
|
263
|
+
* 只有传了 dpr>1 才会调用。
|
|
264
|
+
*/
|
|
265
|
+
private __applyDevicePixelRatio;
|
|
266
|
+
updateCanvasBoundingRect(): any;
|
|
267
|
+
/**
|
|
268
|
+
* 读取 canvas 内容盒:把 border-box 的 rect 补偿成「绘制区」的偏移与尺寸。
|
|
269
|
+
* 无 getComputedStyle 的运行时(如小程序)补偿为 0,退回 rect 原值。
|
|
270
|
+
*/
|
|
271
|
+
private __readContentBox;
|
|
272
|
+
/**
|
|
273
|
+
* 供输入派发器做坐标换算的矩形:**内容盒左上角**。
|
|
274
|
+
* 这样 `clientX - left` 就落在绘制区坐标里,与旧实现(offsetX)语义一致,不受 border/padding 影响。
|
|
275
|
+
*/
|
|
276
|
+
getInputRect(): any;
|
|
277
|
+
/**
|
|
278
|
+
* 以屏幕点为锚点缩放视口(滚轮缩放 / 双指缩放可用的引擎原语)。
|
|
279
|
+
*
|
|
280
|
+
* 保持锚点下的世界坐标在缩放前后落在同一屏幕位置:先取锚点对应的世界坐标,
|
|
281
|
+
* 换算新 scale 后反解 translate。只改视口状态,**不修改任何组件的 state**
|
|
282
|
+
* (与 setViewport 同一约束)。
|
|
283
|
+
*
|
|
284
|
+
* 用法(应用层接滚轮,一行即可):
|
|
285
|
+
* ```js
|
|
286
|
+
* ice.evtBus.on('wheel', (e) => {
|
|
287
|
+
* ice.zoomAt(e.offsetX, e.offsetY, e.deltaY < 0 ? 1.1 : 1 / 1.1);
|
|
288
|
+
* });
|
|
289
|
+
* ```
|
|
290
|
+
*
|
|
291
|
+
* @param screenX 锚点屏幕 x(canvas 像素,通常是鼠标 / 触摸位置)
|
|
292
|
+
* @param screenY 锚点屏幕 y
|
|
293
|
+
* @param factor 缩放倍数,>1 放大、<1 缩小;非正数或非有限值直接忽略
|
|
294
|
+
* @param minScale 最小 scale(默认 0.05)
|
|
295
|
+
* @param maxScale 最大 scale(默认 20)
|
|
296
|
+
*/
|
|
297
|
+
zoomAt(screenX: number, screenY: number, factor: number, minScale?: number, maxScale?: number): this;
|
|
298
|
+
/**
|
|
299
|
+
* 命中检测:屏幕坐标(canvas 像素)→ 命中的最上层可交互组件;无命中返回 null。
|
|
300
|
+
* 供应用层做「空白处拖拽平移 / 点击命中」等视口交互。
|
|
301
|
+
*/
|
|
302
|
+
hitTest(sx: number, sy: number): any;
|
|
303
|
+
/**
|
|
304
|
+
* 注册命名主题(运行时注入,如多品牌 / 多租户 / 暗色主题)。
|
|
305
|
+
*/
|
|
306
|
+
registerTheme(name: string, theme: ICETheme): this;
|
|
307
|
+
/**
|
|
308
|
+
* 获取当前主题对象({ base, semantic })。返回的是**本实例**的主题。
|
|
309
|
+
*/
|
|
310
|
+
getTheme(): ICETheme;
|
|
311
|
+
/**
|
|
312
|
+
* 遍历组件树,对每个用了 preset 的组件重新 resolve preset(主题热切换)。
|
|
313
|
+
*/
|
|
314
|
+
private __reapplyPresets;
|
|
315
|
+
/**
|
|
316
|
+
* 创建线性渐变对象,供组件 style.fillStyle/strokeStyle 使用。
|
|
317
|
+
* 用法:const g = ice.createLinearGradient(0,0,100,0); g.addColorStop(0,'red'); g.addColorStop(1,'blue');
|
|
318
|
+
* new ICERect({ style: { fillStyle: g } })
|
|
319
|
+
*/
|
|
320
|
+
createLinearGradient(x0: number, y0: number, x1: number, y1: number): any;
|
|
321
|
+
/**
|
|
322
|
+
* 创建径向(圆形)渐变对象。
|
|
323
|
+
*/
|
|
324
|
+
createRadialGradient(x0: number, y0: number, r0: number, x1: number, y1: number, r1: number): any;
|
|
325
|
+
/**
|
|
326
|
+
* 创建锥形渐变(较新 API,Chrome 99+),不支持的环境返回 null。
|
|
327
|
+
*/
|
|
328
|
+
createConicGradient(startAngle: number, x: number, y: number): any;
|
|
329
|
+
/**
|
|
330
|
+
* 创建图案填充(用图片平铺),供 style.fillStyle/strokeStyle 使用。
|
|
331
|
+
* @param image 图片源(HTMLImageElement/canvas 等)
|
|
332
|
+
* @param repetition 'repeat'|'repeat-x'|'repeat-y'|'no-repeat'
|
|
333
|
+
*/
|
|
334
|
+
createPattern(image: any, repetition: string): any;
|
|
335
|
+
/**
|
|
336
|
+
* 读取画布指定区域的像素数据(取色、滤镜、橡皮擦等)。
|
|
337
|
+
*/
|
|
338
|
+
getImageData(x: number, y: number, w: number, h: number): any;
|
|
339
|
+
/**
|
|
340
|
+
* 写入像素数据到画布。
|
|
341
|
+
*/
|
|
342
|
+
putImageData(imageData: any, x: number, y: number): void;
|
|
343
|
+
createImageData(w: number, h: number): any;
|
|
344
|
+
/**
|
|
345
|
+
* 把画布导出为 dataURL(默认 PNG)。type 如 'image/png'/'image/jpeg',quality 0~1(jpeg)。
|
|
346
|
+
*/
|
|
347
|
+
toDataURL(type?: string, quality?: number): string;
|
|
348
|
+
/**
|
|
349
|
+
* 把画布导出为 Blob(回调接收)。
|
|
350
|
+
*/
|
|
351
|
+
toBlob(callback: (blob: Blob | null) => void, type?: string, quality?: number): void;
|
|
352
|
+
/**
|
|
353
|
+
* 把对象序列化成 JSON 字符串:
|
|
354
|
+
* - 容器型组件需要负责子节点的序列化操作
|
|
355
|
+
* - 如果组件不需要序列化,需要返回 null
|
|
356
|
+
* @returns Object
|
|
357
|
+
*/
|
|
358
|
+
toJSONString(): string;
|
|
359
|
+
/**
|
|
360
|
+
* 把对象序列化成 JSON 对象:
|
|
361
|
+
* - 容器型组件需要负责子节点的序列化操作
|
|
362
|
+
* - 如果组件不需要序列化,需要返回 null
|
|
363
|
+
* @returns Object
|
|
364
|
+
*/
|
|
365
|
+
toJSONObject(): object;
|
|
366
|
+
fromJSONObject(jsonObject: any): void;
|
|
367
|
+
fromJSONString(jsonStr: string): void;
|
|
368
|
+
}
|
|
369
|
+
export default ICE;
|