ice-render 1.4.10 → 2.0.0
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/README.md +2 -2
- package/dist/index.cjs +2 -2
- package/dist/index.mjs +2 -2
- package/dist/index.umd.js +2 -2
- package/dist/types/ICE.d.mts +32 -11
- package/dist/types/ICE.d.ts +32 -11
- package/dist/types/consts/COMPONENT_TYPE_MAPPING.d.mts +12 -29
- package/dist/types/consts/COMPONENT_TYPE_MAPPING.d.ts +12 -29
- package/dist/types/index.d.mts +1 -0
- package/dist/types/index.d.ts +1 -0
- package/dist/types/persistence/Serializer.d.mts +9 -0
- package/dist/types/persistence/Serializer.d.ts +9 -0
- package/dist/types/plugin/PluginHost.d.mts +6 -2
- package/dist/types/plugin/PluginHost.d.ts +6 -2
- package/dist/types/util/type-id.d.mts +19 -0
- package/dist/types/util/type-id.d.ts +19 -0
- package/package.json +4 -3
package/dist/types/ICE.d.mts
CHANGED
|
@@ -70,7 +70,14 @@ declare class ICE {
|
|
|
70
70
|
* (见 `addChild` / `addTool` 中的 `__reapplyPreset`)。
|
|
71
71
|
*/
|
|
72
72
|
theme: ICETheme;
|
|
73
|
-
|
|
73
|
+
/**
|
|
74
|
+
* 类型名(canonical typeId,`namespace:Type`)与构造函数之间的映射关系。
|
|
75
|
+
*
|
|
76
|
+
* 序列化时由构造函数反查类型名,反序列化时由类型名取出构造函数。
|
|
77
|
+
* 用**无原型对象**承载:否则 `getType('constructor')` / `getType('toString')`
|
|
78
|
+
* 这类历史脏数据会命中 `Object.prototype` 上的成员,拿到一个非构造函数的东西。
|
|
79
|
+
*/
|
|
80
|
+
typeMapping: Record<string, any>;
|
|
74
81
|
/** 构造函数 → 类型名 的反查表(序列化用)。惰性构建,registerType/init 后失效重建。 */
|
|
75
82
|
private __typeIdMapping;
|
|
76
83
|
renderer: any;
|
|
@@ -170,19 +177,27 @@ declare class ICE {
|
|
|
170
177
|
/**
|
|
171
178
|
* @method registerType 注册组件类型
|
|
172
179
|
*
|
|
173
|
-
* -
|
|
174
|
-
* - ICE 内置的类型已经自动注册,不需要手动注册。
|
|
180
|
+
* 类型标识必须使用 `namespace:Type` 格式(例:`ice-render:Rect`、`my-app:Badge`)。
|
|
175
181
|
*
|
|
176
|
-
*
|
|
177
|
-
*
|
|
182
|
+
* 冲突策略(全部**明确抛错**,绝不静默覆盖):
|
|
183
|
+
* - 同一 typeId + 同一构造函数:幂等,不抛错(多入口 / 热更新会重复调用);
|
|
184
|
+
* - 同一 typeId + 不同构造函数:抛错;
|
|
185
|
+
* - 同一构造函数注册第二个 typeId:抛错(否则 getTypeId 反查歧义,写出哪个名字取决于注册顺序)。
|
|
186
|
+
*
|
|
187
|
+
* 类型名**只有 canonical 一种形式**:引擎不做「旧的无 namespace 类名」兼容
|
|
188
|
+
* (ICE 家族仍在发布初期,用旧的只有自己的示例与测试,直接改名比养一套别名简单)。
|
|
178
189
|
*/
|
|
179
|
-
registerType(
|
|
190
|
+
registerType(typeId: string, Clazz: new (...args: any[]) => any): void;
|
|
191
|
+
/** 是否注册了某个 canonical typeId。 */
|
|
192
|
+
hasType(typeId: string): boolean;
|
|
193
|
+
/** 当前实例的 canonical typeId 列表(快照)。 */
|
|
194
|
+
getRegisteredTypeIds(): string[];
|
|
180
195
|
/**
|
|
181
196
|
* 由构造函数反查稳定的类型名(序列化用)。
|
|
182
197
|
*
|
|
183
|
-
* -
|
|
198
|
+
* - 已注册的类型:返回 canonical typeId(`namespace:Type`,与类的 JS 名解耦,压缩改名不影响已存数据)
|
|
184
199
|
* - 未注册:返回 undefined,调用方回退到 `constructor.name`(保持既有行为)
|
|
185
|
-
* -
|
|
200
|
+
* - 一个构造函数只可能有一个 canonical typeId(重复注册会抛错,见 registerType)
|
|
186
201
|
*/
|
|
187
202
|
getTypeId(Clazz: new (...args: any[]) => any): string | undefined;
|
|
188
203
|
/**
|
|
@@ -229,11 +244,17 @@ declare class ICE {
|
|
|
229
244
|
/** 当前键盘焦点组件(未设置时为 null)。 */
|
|
230
245
|
getFocusedComponent(): any;
|
|
231
246
|
/**
|
|
247
|
+
* 根据类型名取构造函数(反序列化用)。
|
|
248
|
+
*
|
|
249
|
+
* 类型名**只有 canonical 一种形式**(`namespace:Type`):注册表里没有的名字一律返回
|
|
250
|
+
* undefined(`Deserializer` 会把该节点记入 `unknownTypes` 并跳过)。因此引擎不做
|
|
251
|
+
* 「旧的无 namespace 类名」兼容 —— 那是另一条迟早要还的技术债。
|
|
252
|
+
*
|
|
232
253
|
* @method getType 获取组件构造函数
|
|
233
|
-
* @param
|
|
234
|
-
* @returns
|
|
254
|
+
* @param typeId canonical typeId(`namespace:Type`)
|
|
255
|
+
* @returns 构造函数;未注册时返回 undefined
|
|
235
256
|
*/
|
|
236
|
-
getType(
|
|
257
|
+
getType(typeId: string): any;
|
|
237
258
|
/**
|
|
238
259
|
* 加载自定义字体(平台适配):浏览器走 FontFace API,小程序走 wx.loadFont。
|
|
239
260
|
* 加载后,在 ICEText 的 style.fontFamily 里引用该字体名即可。
|
package/dist/types/ICE.d.ts
CHANGED
|
@@ -70,7 +70,14 @@ declare class ICE {
|
|
|
70
70
|
* (见 `addChild` / `addTool` 中的 `__reapplyPreset`)。
|
|
71
71
|
*/
|
|
72
72
|
theme: ICETheme;
|
|
73
|
-
|
|
73
|
+
/**
|
|
74
|
+
* 类型名(canonical typeId,`namespace:Type`)与构造函数之间的映射关系。
|
|
75
|
+
*
|
|
76
|
+
* 序列化时由构造函数反查类型名,反序列化时由类型名取出构造函数。
|
|
77
|
+
* 用**无原型对象**承载:否则 `getType('constructor')` / `getType('toString')`
|
|
78
|
+
* 这类历史脏数据会命中 `Object.prototype` 上的成员,拿到一个非构造函数的东西。
|
|
79
|
+
*/
|
|
80
|
+
typeMapping: Record<string, any>;
|
|
74
81
|
/** 构造函数 → 类型名 的反查表(序列化用)。惰性构建,registerType/init 后失效重建。 */
|
|
75
82
|
private __typeIdMapping;
|
|
76
83
|
renderer: any;
|
|
@@ -170,19 +177,27 @@ declare class ICE {
|
|
|
170
177
|
/**
|
|
171
178
|
* @method registerType 注册组件类型
|
|
172
179
|
*
|
|
173
|
-
* -
|
|
174
|
-
* - ICE 内置的类型已经自动注册,不需要手动注册。
|
|
180
|
+
* 类型标识必须使用 `namespace:Type` 格式(例:`ice-render:Rect`、`my-app:Badge`)。
|
|
175
181
|
*
|
|
176
|
-
*
|
|
177
|
-
*
|
|
182
|
+
* 冲突策略(全部**明确抛错**,绝不静默覆盖):
|
|
183
|
+
* - 同一 typeId + 同一构造函数:幂等,不抛错(多入口 / 热更新会重复调用);
|
|
184
|
+
* - 同一 typeId + 不同构造函数:抛错;
|
|
185
|
+
* - 同一构造函数注册第二个 typeId:抛错(否则 getTypeId 反查歧义,写出哪个名字取决于注册顺序)。
|
|
186
|
+
*
|
|
187
|
+
* 类型名**只有 canonical 一种形式**:引擎不做「旧的无 namespace 类名」兼容
|
|
188
|
+
* (ICE 家族仍在发布初期,用旧的只有自己的示例与测试,直接改名比养一套别名简单)。
|
|
178
189
|
*/
|
|
179
|
-
registerType(
|
|
190
|
+
registerType(typeId: string, Clazz: new (...args: any[]) => any): void;
|
|
191
|
+
/** 是否注册了某个 canonical typeId。 */
|
|
192
|
+
hasType(typeId: string): boolean;
|
|
193
|
+
/** 当前实例的 canonical typeId 列表(快照)。 */
|
|
194
|
+
getRegisteredTypeIds(): string[];
|
|
180
195
|
/**
|
|
181
196
|
* 由构造函数反查稳定的类型名(序列化用)。
|
|
182
197
|
*
|
|
183
|
-
* -
|
|
198
|
+
* - 已注册的类型:返回 canonical typeId(`namespace:Type`,与类的 JS 名解耦,压缩改名不影响已存数据)
|
|
184
199
|
* - 未注册:返回 undefined,调用方回退到 `constructor.name`(保持既有行为)
|
|
185
|
-
* -
|
|
200
|
+
* - 一个构造函数只可能有一个 canonical typeId(重复注册会抛错,见 registerType)
|
|
186
201
|
*/
|
|
187
202
|
getTypeId(Clazz: new (...args: any[]) => any): string | undefined;
|
|
188
203
|
/**
|
|
@@ -229,11 +244,17 @@ declare class ICE {
|
|
|
229
244
|
/** 当前键盘焦点组件(未设置时为 null)。 */
|
|
230
245
|
getFocusedComponent(): any;
|
|
231
246
|
/**
|
|
247
|
+
* 根据类型名取构造函数(反序列化用)。
|
|
248
|
+
*
|
|
249
|
+
* 类型名**只有 canonical 一种形式**(`namespace:Type`):注册表里没有的名字一律返回
|
|
250
|
+
* undefined(`Deserializer` 会把该节点记入 `unknownTypes` 并跳过)。因此引擎不做
|
|
251
|
+
* 「旧的无 namespace 类名」兼容 —— 那是另一条迟早要还的技术债。
|
|
252
|
+
*
|
|
232
253
|
* @method getType 获取组件构造函数
|
|
233
|
-
* @param
|
|
234
|
-
* @returns
|
|
254
|
+
* @param typeId canonical typeId(`namespace:Type`)
|
|
255
|
+
* @returns 构造函数;未注册时返回 undefined
|
|
235
256
|
*/
|
|
236
|
-
getType(
|
|
257
|
+
getType(typeId: string): any;
|
|
237
258
|
/**
|
|
238
259
|
* 加载自定义字体(平台适配):浏览器走 FontFace API,小程序走 wx.loadFont。
|
|
239
260
|
* 加载后,在 ICEText 的 style.fontFamily 里引用该字体名即可。
|
|
@@ -5,41 +5,24 @@
|
|
|
5
5
|
* LICENSE file in the root directory of this source tree.
|
|
6
6
|
*
|
|
7
7
|
*/
|
|
8
|
-
import ICEGroup from '../graphic/container/ICEGroup.mjs';
|
|
9
|
-
import ICEImage from '../graphic/ICEImage.mjs';
|
|
10
|
-
import ICEBezier from '../graphic/link/ICEBezier.mjs';
|
|
11
|
-
import ICEPolyLine from '../graphic/link/ICEPolyLine.mjs';
|
|
12
|
-
import ICEVisioLink from '../graphic/link/ICEVisioLink.mjs';
|
|
13
|
-
import ICECircle from '../graphic/shape/ICECircle.mjs';
|
|
14
|
-
import ICEEllipse from '../graphic/shape/ICEEllipse.mjs';
|
|
15
|
-
import ICEIsogon from '../graphic/shape/ICEIsogon.mjs';
|
|
16
|
-
import ICERect from '../graphic/shape/ICERect.mjs';
|
|
17
|
-
import ICERose from '../graphic/shape/ICERose.mjs';
|
|
18
|
-
import ICEStar from '../graphic/shape/ICEStar.mjs';
|
|
19
|
-
import ICEText from '../graphic/text/ICEText.mjs';
|
|
20
8
|
/**
|
|
21
9
|
* 组件名称和构造函数引用之间的映射关系,把序列化之后的 JSON 字符串重新解析成图形时需要用到此映射关系。
|
|
22
10
|
*
|
|
23
|
-
* key 是**稳定的类型名(typeId
|
|
24
|
-
*
|
|
25
|
-
*
|
|
11
|
+
* key 是**稳定的类型名(typeId)**,格式为 `namespace:Type`,与类的 JS 名解耦:序列化时由构造函数
|
|
12
|
+
* 反查这张表得到 typeId,因此压缩/改名(terser mangle)不会破坏已存数据;只有**未注册**的类型
|
|
13
|
+
* 才回退到 `constructor.name`(此时 `Serializer.unregisteredTypes` 会记录并告警)。
|
|
26
14
|
*
|
|
27
15
|
* 注意:工具层组件(ICELinkSlot / ICELinkHook / 各类 ControlPanel)不进这张表,它们不被序列化。
|
|
28
16
|
*
|
|
29
17
|
* @author 大漠穷秋<damoqiongqiu@126.com>
|
|
30
18
|
*/
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
ICEGroup: typeof ICEGroup;
|
|
41
|
-
ICEVisioLink: typeof ICEVisioLink;
|
|
42
|
-
ICEPolyLine: typeof ICEPolyLine;
|
|
43
|
-
ICEBezier: typeof ICEBezier;
|
|
44
|
-
};
|
|
19
|
+
export interface ComponentTypeEntry {
|
|
20
|
+
typeId: string;
|
|
21
|
+
ctor: any;
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* 内置类型的注册表:typeId 统一为 `ice-render:Type`(引擎自己的 namespace)。
|
|
25
|
+
*/
|
|
26
|
+
export declare const componentTypeEntries: ComponentTypeEntry[];
|
|
27
|
+
declare const componentTypeMap: Record<string, any>;
|
|
45
28
|
export default componentTypeMap;
|
|
@@ -5,41 +5,24 @@
|
|
|
5
5
|
* LICENSE file in the root directory of this source tree.
|
|
6
6
|
*
|
|
7
7
|
*/
|
|
8
|
-
import ICEGroup from '../graphic/container/ICEGroup';
|
|
9
|
-
import ICEImage from '../graphic/ICEImage';
|
|
10
|
-
import ICEBezier from '../graphic/link/ICEBezier';
|
|
11
|
-
import ICEPolyLine from '../graphic/link/ICEPolyLine';
|
|
12
|
-
import ICEVisioLink from '../graphic/link/ICEVisioLink';
|
|
13
|
-
import ICECircle from '../graphic/shape/ICECircle';
|
|
14
|
-
import ICEEllipse from '../graphic/shape/ICEEllipse';
|
|
15
|
-
import ICEIsogon from '../graphic/shape/ICEIsogon';
|
|
16
|
-
import ICERect from '../graphic/shape/ICERect';
|
|
17
|
-
import ICERose from '../graphic/shape/ICERose';
|
|
18
|
-
import ICEStar from '../graphic/shape/ICEStar';
|
|
19
|
-
import ICEText from '../graphic/text/ICEText';
|
|
20
8
|
/**
|
|
21
9
|
* 组件名称和构造函数引用之间的映射关系,把序列化之后的 JSON 字符串重新解析成图形时需要用到此映射关系。
|
|
22
10
|
*
|
|
23
|
-
* key 是**稳定的类型名(typeId
|
|
24
|
-
*
|
|
25
|
-
*
|
|
11
|
+
* key 是**稳定的类型名(typeId)**,格式为 `namespace:Type`,与类的 JS 名解耦:序列化时由构造函数
|
|
12
|
+
* 反查这张表得到 typeId,因此压缩/改名(terser mangle)不会破坏已存数据;只有**未注册**的类型
|
|
13
|
+
* 才回退到 `constructor.name`(此时 `Serializer.unregisteredTypes` 会记录并告警)。
|
|
26
14
|
*
|
|
27
15
|
* 注意:工具层组件(ICELinkSlot / ICELinkHook / 各类 ControlPanel)不进这张表,它们不被序列化。
|
|
28
16
|
*
|
|
29
17
|
* @author 大漠穷秋<damoqiongqiu@126.com>
|
|
30
18
|
*/
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
ICEGroup: typeof ICEGroup;
|
|
41
|
-
ICEVisioLink: typeof ICEVisioLink;
|
|
42
|
-
ICEPolyLine: typeof ICEPolyLine;
|
|
43
|
-
ICEBezier: typeof ICEBezier;
|
|
44
|
-
};
|
|
19
|
+
export interface ComponentTypeEntry {
|
|
20
|
+
typeId: string;
|
|
21
|
+
ctor: any;
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* 内置类型的注册表:typeId 统一为 `ice-render:Type`(引擎自己的 namespace)。
|
|
25
|
+
*/
|
|
26
|
+
export declare const componentTypeEntries: ComponentTypeEntry[];
|
|
27
|
+
declare const componentTypeMap: Record<string, any>;
|
|
45
28
|
export default componentTypeMap;
|
package/dist/types/index.d.mts
CHANGED
|
@@ -55,5 +55,6 @@ export { default as PluginHost } from './plugin/PluginHost.mjs';
|
|
|
55
55
|
export type { ICEPlugin, ICEPluginTool, ICERenderHook, ICERenderFrame } from './plugin/PluginHost.mjs';
|
|
56
56
|
export { default as Serializer, SERIALIZATION_VERSION } from './persistence/Serializer.mjs';
|
|
57
57
|
export { default as Deserializer, SERIALIZATION_MIGRATIONS } from './persistence/Deserializer.mjs';
|
|
58
|
+
export { TYPE_ID_PATTERN, isTypeId, assertTypeId, parseTypeId, makeTypeId } from './util/type-id.mjs';
|
|
58
59
|
export { buildAccessibilityTree } from './a11y/accessibility.mjs';
|
|
59
60
|
export type { ICEAccessibleNode, ICEAccessibleRole, ICEAccessibilityOptions } from './a11y/accessibility.mjs';
|
package/dist/types/index.d.ts
CHANGED
|
@@ -55,5 +55,6 @@ export { default as PluginHost } from './plugin/PluginHost';
|
|
|
55
55
|
export type { ICEPlugin, ICEPluginTool, ICERenderHook, ICERenderFrame } from './plugin/PluginHost';
|
|
56
56
|
export { default as Serializer, SERIALIZATION_VERSION } from './persistence/Serializer';
|
|
57
57
|
export { default as Deserializer, SERIALIZATION_MIGRATIONS } from './persistence/Deserializer';
|
|
58
|
+
export { TYPE_ID_PATTERN, isTypeId, assertTypeId, parseTypeId, makeTypeId } from './util/type-id';
|
|
58
59
|
export { buildAccessibilityTree } from './a11y/accessibility';
|
|
59
60
|
export type { ICEAccessibleNode, ICEAccessibleRole, ICEAccessibilityOptions } from './a11y/accessibility';
|
|
@@ -11,6 +11,15 @@ export declare const SERIALIZATION_VERSION = 1;
|
|
|
11
11
|
*/
|
|
12
12
|
export default class Serializer {
|
|
13
13
|
private ice;
|
|
14
|
+
/**
|
|
15
|
+
* 本次序列化中遇到的、未注册的组件类型名(去重)。
|
|
16
|
+
*
|
|
17
|
+
* 未注册类型只能回退写出 `constructor.name`,而下游打包器会 mangle 类名——写出去的
|
|
18
|
+
* 名字**下次不一定读得回来**。这里记录并告警,让应用层有机会提示用户先
|
|
19
|
+
* `ice.registerType('your-namespace:Type', Type)`。
|
|
20
|
+
*/
|
|
21
|
+
private _unregisteredTypes;
|
|
22
|
+
get unregisteredTypes(): string[];
|
|
14
23
|
constructor(ice: any);
|
|
15
24
|
/**
|
|
16
25
|
* 把对象序列化成 JSON 字符串:
|
|
@@ -11,6 +11,15 @@ export declare const SERIALIZATION_VERSION = 1;
|
|
|
11
11
|
*/
|
|
12
12
|
export default class Serializer {
|
|
13
13
|
private ice;
|
|
14
|
+
/**
|
|
15
|
+
* 本次序列化中遇到的、未注册的组件类型名(去重)。
|
|
16
|
+
*
|
|
17
|
+
* 未注册类型只能回退写出 `constructor.name`,而下游打包器会 mangle 类名——写出去的
|
|
18
|
+
* 名字**下次不一定读得回来**。这里记录并告警,让应用层有机会提示用户先
|
|
19
|
+
* `ice.registerType('your-namespace:Type', Type)`。
|
|
20
|
+
*/
|
|
21
|
+
private _unregisteredTypes;
|
|
22
|
+
get unregisteredTypes(): string[];
|
|
14
23
|
constructor(ice: any);
|
|
15
24
|
/**
|
|
16
25
|
* 把对象序列化成 JSON 字符串:
|
|
@@ -3,7 +3,9 @@
|
|
|
3
3
|
*
|
|
4
4
|
* 设计取向与 09-roadmap 的边界一致——**只提供原语,不做应用层 UX**:
|
|
5
5
|
* - 组件层:插件声明自定义图元类型,宿主代为 `registerType`(因此自动获得
|
|
6
|
-
* 序列化 typeId 反查能力,见 `ICE.getTypeId
|
|
6
|
+
* 序列化 typeId 反查能力,见 `ICE.getTypeId`)。声明键必须是 `namespace:Type`
|
|
7
|
+
* 格式的 canonical typeId;格式非法或与已注册类型冲突时明确抛错,并把插件名
|
|
8
|
+
* 带上(否则插件作者无从判断是哪个插件注册失败)。
|
|
7
9
|
* - 渲染层:插件拿到每帧的绘制回调,在与组件相同的坐标系(世界坐标)下叠加绘制。
|
|
8
10
|
* 局部重绘帧里回调在 clip 之内执行,语义与组件一致(超出脏区域的旧内容不会被擦除也不会被重画;
|
|
9
11
|
* 若插件内容会随时间变化而没有任何组件变脏,引擎本身会因「无脏组件」回退全量,仍然正确)。
|
|
@@ -45,7 +47,9 @@ export interface ICEPluginTool {
|
|
|
45
47
|
export interface ICEPlugin {
|
|
46
48
|
/** 插件唯一名(幂等注册键) */
|
|
47
49
|
name: string;
|
|
48
|
-
/**
|
|
50
|
+
/**
|
|
51
|
+
* 组件层:canonical typeId(`namespace:Type`)→ 构造函数。例:`{ 'my-app:Badge': Badge }`。
|
|
52
|
+
*/
|
|
49
53
|
components?: Record<string, new (...args: any[]) => any>;
|
|
50
54
|
/** 渲染层:每帧绘制回调(世界坐标) */
|
|
51
55
|
render?: ICERenderHook;
|
|
@@ -3,7 +3,9 @@
|
|
|
3
3
|
*
|
|
4
4
|
* 设计取向与 09-roadmap 的边界一致——**只提供原语,不做应用层 UX**:
|
|
5
5
|
* - 组件层:插件声明自定义图元类型,宿主代为 `registerType`(因此自动获得
|
|
6
|
-
* 序列化 typeId 反查能力,见 `ICE.getTypeId
|
|
6
|
+
* 序列化 typeId 反查能力,见 `ICE.getTypeId`)。声明键必须是 `namespace:Type`
|
|
7
|
+
* 格式的 canonical typeId;格式非法或与已注册类型冲突时明确抛错,并把插件名
|
|
8
|
+
* 带上(否则插件作者无从判断是哪个插件注册失败)。
|
|
7
9
|
* - 渲染层:插件拿到每帧的绘制回调,在与组件相同的坐标系(世界坐标)下叠加绘制。
|
|
8
10
|
* 局部重绘帧里回调在 clip 之内执行,语义与组件一致(超出脏区域的旧内容不会被擦除也不会被重画;
|
|
9
11
|
* 若插件内容会随时间变化而没有任何组件变脏,引擎本身会因「无脏组件」回退全量,仍然正确)。
|
|
@@ -45,7 +47,9 @@ export interface ICEPluginTool {
|
|
|
45
47
|
export interface ICEPlugin {
|
|
46
48
|
/** 插件唯一名(幂等注册键) */
|
|
47
49
|
name: string;
|
|
48
|
-
/**
|
|
50
|
+
/**
|
|
51
|
+
* 组件层:canonical typeId(`namespace:Type`)→ 构造函数。例:`{ 'my-app:Badge': Badge }`。
|
|
52
|
+
*/
|
|
49
53
|
components?: Record<string, new (...args: any[]) => any>;
|
|
50
54
|
/** 渲染层:每帧绘制回调(世界坐标) */
|
|
51
55
|
render?: ICERenderHook;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 组件类型标识(typeId)的格式契约。
|
|
3
|
+
*
|
|
4
|
+
* 统一格式:`namespace:Type`
|
|
5
|
+
*
|
|
6
|
+
* - namespace:小写字母开头,只允许小写字母、数字、连字符。
|
|
7
|
+
* - Type:字母或下划线开头,允许字母、数字、下划线、连字符。
|
|
8
|
+
*
|
|
9
|
+
* 例:`ice-render:Rect`、`ice-entity-designer:FlowNode`、
|
|
10
|
+
* `ice-chart:PlotArea`、`my-company:Widget`。
|
|
11
|
+
*/
|
|
12
|
+
export declare const TYPE_ID_PATTERN: RegExp;
|
|
13
|
+
export declare function isTypeId(value: unknown): value is string;
|
|
14
|
+
export declare function assertTypeId(value: unknown, label?: string): asserts value is string;
|
|
15
|
+
export declare function parseTypeId(typeId: string): {
|
|
16
|
+
namespace: string;
|
|
17
|
+
type: string;
|
|
18
|
+
};
|
|
19
|
+
export declare function makeTypeId(namespace: string, type: string): string;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 组件类型标识(typeId)的格式契约。
|
|
3
|
+
*
|
|
4
|
+
* 统一格式:`namespace:Type`
|
|
5
|
+
*
|
|
6
|
+
* - namespace:小写字母开头,只允许小写字母、数字、连字符。
|
|
7
|
+
* - Type:字母或下划线开头,允许字母、数字、下划线、连字符。
|
|
8
|
+
*
|
|
9
|
+
* 例:`ice-render:Rect`、`ice-entity-designer:FlowNode`、
|
|
10
|
+
* `ice-chart:PlotArea`、`my-company:Widget`。
|
|
11
|
+
*/
|
|
12
|
+
export declare const TYPE_ID_PATTERN: RegExp;
|
|
13
|
+
export declare function isTypeId(value: unknown): value is string;
|
|
14
|
+
export declare function assertTypeId(value: unknown, label?: string): asserts value is string;
|
|
15
|
+
export declare function parseTypeId(typeId: string): {
|
|
16
|
+
namespace: string;
|
|
17
|
+
type: string;
|
|
18
|
+
};
|
|
19
|
+
export declare function makeTypeId(namespace: string, type: string): string;
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"author": "大漠穷秋",
|
|
3
3
|
"name": "ice-render",
|
|
4
|
-
"version": "
|
|
4
|
+
"version": "2.0.0",
|
|
5
5
|
"description": "A canvas engine for interactive graphics.",
|
|
6
6
|
"repository": {
|
|
7
7
|
"type": "git",
|
|
@@ -64,7 +64,7 @@
|
|
|
64
64
|
"@commitlint/config-conventional": "17.8.1",
|
|
65
65
|
"@playwright/test": "^1.40.0",
|
|
66
66
|
"@rollup/plugin-babel": "6.1.0",
|
|
67
|
-
"@rollup/plugin-commonjs": "
|
|
67
|
+
"@rollup/plugin-commonjs": "28.0.1",
|
|
68
68
|
"@rollup/plugin-json": "6.1.0",
|
|
69
69
|
"@rollup/plugin-node-resolve": "15.3.1",
|
|
70
70
|
"@rollup/plugin-strip": "3.0.4",
|
|
@@ -73,6 +73,7 @@
|
|
|
73
73
|
"@types/node": "18.19.130",
|
|
74
74
|
"@typescript-eslint/eslint-plugin": "6.21.0",
|
|
75
75
|
"@typescript-eslint/parser": "6.21.0",
|
|
76
|
+
"babel-jest": "29.7.0",
|
|
76
77
|
"eslint": "8.57.1",
|
|
77
78
|
"eslint-config-prettier": "9.1.2",
|
|
78
79
|
"eslint-plugin-jest": "27.9.0",
|
|
@@ -108,7 +109,7 @@
|
|
|
108
109
|
]
|
|
109
110
|
},
|
|
110
111
|
"engines": {
|
|
111
|
-
"npm": ">=
|
|
112
|
+
"npm": ">=9",
|
|
112
113
|
"node": ">=18"
|
|
113
114
|
},
|
|
114
115
|
"license": "MIT",
|