@flowgram-vue/core 0.2.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.
Files changed (133) hide show
  1. package/LICENSE +22 -0
  2. package/dist/index.cjs +0 -0
  3. package/dist/index.cjs.map +1 -0
  4. package/dist/index.d.ts +1 -0
  5. package/dist/index.js +0 -0
  6. package/dist/index.js.map +1 -0
  7. package/package.json +63 -0
  8. package/src/common/config-entity.ts +80 -0
  9. package/src/common/entity-data.ts +171 -0
  10. package/src/common/entity-manager-contribution.ts +12 -0
  11. package/src/common/entity-manager.ts +475 -0
  12. package/src/common/entity.ts +482 -0
  13. package/src/common/index.ts +22 -0
  14. package/src/common/playground-context.ts +35 -0
  15. package/src/common/playground-decorator-helper.ts +113 -0
  16. package/src/common/playground-decorators.ts +85 -0
  17. package/src/common/playground-schedule.ts +30 -0
  18. package/src/common/protect-wheel-area.ts +11 -0
  19. package/src/common/schema/index.ts +14 -0
  20. package/src/common/schema/node.ts +15 -0
  21. package/src/common/schema/opacity-schema.ts +19 -0
  22. package/src/common/schema/origin-schema.ts +35 -0
  23. package/src/common/schema/position-schema.ts +35 -0
  24. package/src/common/schema/rotation-schema.ts +19 -0
  25. package/src/common/schema/scale-schema.ts +35 -0
  26. package/src/common/schema/size-schema.ts +42 -0
  27. package/src/common/schema/skew-schema.ts +35 -0
  28. package/src/common/schema/transform-schema.ts +613 -0
  29. package/src/common/utils/bounds.spec.ts +229 -0
  30. package/src/common/utils/bounds.ts +176 -0
  31. package/src/common/utils/index.ts +6 -0
  32. package/src/composables/index.ts +16 -0
  33. package/src/composables/use-config-entity.ts +31 -0
  34. package/src/composables/use-entities.ts +26 -0
  35. package/src/composables/use-entity-data-from-context.ts +34 -0
  36. package/src/composables/use-entity-from-context.ts +31 -0
  37. package/src/composables/use-listen-events.ts +22 -0
  38. package/src/composables/use-playground-container.ts +16 -0
  39. package/src/composables/use-playground-context.ts +15 -0
  40. package/src/composables/use-playground-drag.ts +31 -0
  41. package/src/composables/use-playground.ts +16 -0
  42. package/src/composables/use-refresh.ts +6 -0
  43. package/src/composables/use-service.ts +17 -0
  44. package/src/core/index.ts +8 -0
  45. package/src/core/layer/config/editor-state-config-entity.ts +180 -0
  46. package/src/core/layer/config/index.ts +7 -0
  47. package/src/core/layer/config/playground-config-entity.ts +604 -0
  48. package/src/core/layer/index.ts +8 -0
  49. package/src/core/layer/layer.ts +248 -0
  50. package/src/core/layer/playground-layer.ts +547 -0
  51. package/src/core/pipeline/index.ts +10 -0
  52. package/src/core/pipeline/pipeline-entities-selector.ts +200 -0
  53. package/src/core/pipeline/pipeline-entities.ts +230 -0
  54. package/src/core/pipeline/pipeline-registry.ts +344 -0
  55. package/src/core/pipeline/pipeline-renderer.ts +248 -0
  56. package/src/core/pipeline/pipeline-vue-utils.ts +96 -0
  57. package/src/core/pipeline/pipeline.ts +28 -0
  58. package/src/core/utils/index.ts +12 -0
  59. package/src/core/utils/inject-provider-decorators.ts +27 -0
  60. package/src/core/utils/lazy-inject-decorators.ts +38 -0
  61. package/src/core/utils/mouse-touch-event.ts +120 -0
  62. package/src/core/utils/playground-drag.ts +511 -0
  63. package/src/core/utils/playground-gesture.spec.ts +135 -0
  64. package/src/core/utils/playground-gesture.ts +118 -0
  65. package/src/core/utils/tween.ts +156 -0
  66. package/src/core/utils/use-gesture/core/Controller.ts +212 -0
  67. package/src/core/utils/use-gesture/core/EventStore.ts +46 -0
  68. package/src/core/utils/use-gesture/core/TimeoutStore.ts +28 -0
  69. package/src/core/utils/use-gesture/core/actions.ts +63 -0
  70. package/src/core/utils/use-gesture/core/config/commonConfigResolver.ts +86 -0
  71. package/src/core/utils/use-gesture/core/config/coordinatesConfigResolver.ts +48 -0
  72. package/src/core/utils/use-gesture/core/config/dragConfigResolver.ts +140 -0
  73. package/src/core/utils/use-gesture/core/config/hoverConfigResolver.ts +11 -0
  74. package/src/core/utils/use-gesture/core/config/moveConfigResolver.ts +11 -0
  75. package/src/core/utils/use-gesture/core/config/pinchConfigResolver.ts +59 -0
  76. package/src/core/utils/use-gesture/core/config/resolver.ts +70 -0
  77. package/src/core/utils/use-gesture/core/config/scrollConfigResolver.ts +8 -0
  78. package/src/core/utils/use-gesture/core/config/sharedConfigResolver.ts +28 -0
  79. package/src/core/utils/use-gesture/core/config/support.ts +52 -0
  80. package/src/core/utils/use-gesture/core/config/wheelConfigResolver.ts +8 -0
  81. package/src/core/utils/use-gesture/core/engines/CoordinatesEngine.ts +78 -0
  82. package/src/core/utils/use-gesture/core/engines/DragEngine.ts +403 -0
  83. package/src/core/utils/use-gesture/core/engines/Engine.ts +406 -0
  84. package/src/core/utils/use-gesture/core/engines/HoverEngine.ts +43 -0
  85. package/src/core/utils/use-gesture/core/engines/MoveEngine.ts +52 -0
  86. package/src/core/utils/use-gesture/core/engines/PinchEngine.ts +345 -0
  87. package/src/core/utils/use-gesture/core/engines/ScrollEngine.ts +42 -0
  88. package/src/core/utils/use-gesture/core/engines/WheelEngine.ts +48 -0
  89. package/src/core/utils/use-gesture/core/index.ts +7 -0
  90. package/src/core/utils/use-gesture/core/parser.ts +92 -0
  91. package/src/core/utils/use-gesture/core/types/action.ts +19 -0
  92. package/src/core/utils/use-gesture/core/types/config.ts +255 -0
  93. package/src/core/utils/use-gesture/core/types/handlers.ts +73 -0
  94. package/src/core/utils/use-gesture/core/types/index.ts +11 -0
  95. package/src/core/utils/use-gesture/core/types/internalConfig.ts +80 -0
  96. package/src/core/utils/use-gesture/core/types/state.ts +275 -0
  97. package/src/core/utils/use-gesture/core/types/utils.ts +204 -0
  98. package/src/core/utils/use-gesture/core/types.ts +8 -0
  99. package/src/core/utils/use-gesture/core/utils/events.ts +158 -0
  100. package/src/core/utils/use-gesture/core/utils/fn.ts +32 -0
  101. package/src/core/utils/use-gesture/core/utils/maths.ts +63 -0
  102. package/src/core/utils/use-gesture/core/utils/state.ts +24 -0
  103. package/src/core/utils/use-gesture/core/utils.ts +8 -0
  104. package/src/core/utils/use-gesture/index.ts +6 -0
  105. package/src/core/utils/use-gesture/vanilla/DragGesture.ts +27 -0
  106. package/src/core/utils/use-gesture/vanilla/Gesture.ts +45 -0
  107. package/src/core/utils/use-gesture/vanilla/HoverGesture.ts +27 -0
  108. package/src/core/utils/use-gesture/vanilla/MoveGesture.ts +27 -0
  109. package/src/core/utils/use-gesture/vanilla/PinchGesture.ts +27 -0
  110. package/src/core/utils/use-gesture/vanilla/Recognizer.ts +43 -0
  111. package/src/core/utils/use-gesture/vanilla/ScrollGesture.ts +27 -0
  112. package/src/core/utils/use-gesture/vanilla/WheelGesture.ts +27 -0
  113. package/src/core/utils/use-gesture/vanilla/createGesture.ts +18 -0
  114. package/src/core/utils/use-gesture/vanilla/index.ts +18 -0
  115. package/src/env.d.ts +10 -0
  116. package/src/index.ts +17 -0
  117. package/src/playground-config.ts +70 -0
  118. package/src/playground-container.ts +129 -0
  119. package/src/playground-contribution.ts +81 -0
  120. package/src/playground-mock-tools.ts +143 -0
  121. package/src/playground.ts +401 -0
  122. package/src/plugin/index.ts +6 -0
  123. package/src/plugin/plugin.ts +226 -0
  124. package/src/services/clipboard-service.ts +40 -0
  125. package/src/services/context-menu-service.ts +25 -0
  126. package/src/services/index.ts +10 -0
  127. package/src/services/logger-service.ts +49 -0
  128. package/src/services/selection-service.ts +54 -0
  129. package/src/services/storage-service.ts +65 -0
  130. package/src/vue/index.ts +8 -0
  131. package/src/vue/playground-vue-context.ts +22 -0
  132. package/src/vue/playground-vue-provider.ts +115 -0
  133. package/src/vue/playground-vue-renderer.vue +44 -0
@@ -0,0 +1,475 @@
1
+ /**
2
+ * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates
3
+ * SPDX-License-Identifier: MIT
4
+ */
5
+
6
+ import { inject, injectable, interfaces, multiInject, optional, postConstruct } from 'inversify';
7
+ import { Disposable, DisposableCollection, Emitter } from '@flowgram-vue/utils';
8
+
9
+ import { PlaygroundSchedule } from './playground-schedule';
10
+ import {
11
+ injectPlaygroundContext,
12
+ PlaygroundContainerFactory,
13
+ PlaygroundContext,
14
+ } from './playground-context';
15
+ import { EntityManagerContribution } from './entity-manager-contribution';
16
+ import { ConfigEntity } from './config-entity';
17
+ // import { AbleManager } from './able-manager';
18
+ import type {
19
+ Entity,
20
+ EntityData,
21
+ EntityDataInjector,
22
+ EntityDataRegistry,
23
+ EntityJSON,
24
+ EntityOpts,
25
+ EntityRegistry,
26
+ } from '.';
27
+
28
+ /**
29
+ * 让 entity 可以注入到类中
30
+ *
31
+ * @example
32
+ * ```
33
+ * class SomeClass {
34
+ * @inject(PlaygroundConfigEntity) playgroundConfig: PlaygroundConfigEntity
35
+ * }
36
+ * ```
37
+ * @param bind
38
+ * @param entityRegistry
39
+ */
40
+ export function bindConfigEntity(bind: interfaces.Bind, entityRegistry: EntityRegistry): void {
41
+ bind(entityRegistry)
42
+ .toDynamicValue(
43
+ ctx =>
44
+ ctx.container.get<EntityManager>(EntityManager)!.createEntity(entityRegistry)! as never,
45
+ )
46
+ .inSingletonScope();
47
+ }
48
+
49
+ /**
50
+ * TODO registry 改成 decorator
51
+ * Entity 管理器,全局唯一
52
+ */
53
+ @injectable()
54
+ export class EntityManager implements Disposable {
55
+ readonly toDispose = new DisposableCollection();
56
+
57
+ protected onEntityChangeEmitter = new Emitter<string>();
58
+
59
+ protected onEntityLifeCycleEmitter = new Emitter<{
60
+ type: 'add' | 'update' | 'delete';
61
+ entity: Entity;
62
+ }>();
63
+
64
+ protected onEntityDataChangeEmitter = new Emitter<{
65
+ entityType: string;
66
+ entityDataType: string;
67
+ }>();
68
+
69
+ /**
70
+ * Entity 的类缓存,便于在 fromJSON 时候查询对应的类
71
+ */
72
+ protected registryMap: Map<string, EntityRegistry> = new Map();
73
+
74
+ /**
75
+ * Entity 数据类缓存,便于 fromJSON 使用
76
+ */
77
+ protected dataRegistryMap: Map<string, EntityDataRegistry> = new Map();
78
+
79
+ /**
80
+ * Entity 数据类依赖注入器,可用于在EntityData构造器中注入第三方模块
81
+ */
82
+ protected dataInjectorMap: Map<string, EntityDataInjector> = new Map();
83
+
84
+ /**
85
+ * Entity 的所有实例缓存
86
+ */
87
+ protected entityInstanceMap: Map<string, Entity> = new Map(); // By entity id
88
+
89
+ /**
90
+ * entity 全局版本更新
91
+ * @protected
92
+ */
93
+ protected entityVersionMap: Map<string, number> = new Map();
94
+
95
+ /**
96
+ * data 全局版本更新
97
+ * @protected
98
+ */
99
+ protected entityDataVersionMap: Map<string, number> = new Map();
100
+
101
+ /**
102
+ * Entity 的实例按类型缓存,便于查询优化
103
+ */
104
+ protected entityInstanceMapByType: Map<string, Entity[]> = new Map(); // By entity type
105
+
106
+ /**
107
+ * 所有配置实体的缓存
108
+ */
109
+ protected configEntities: Map<string, ConfigEntity> = new Map();
110
+
111
+ /**
112
+ * 当对应的实体类型变化后触发
113
+ */
114
+ readonly onEntityChange = this.onEntityChangeEmitter.event;
115
+
116
+ /**
117
+ * entity data 数据变化
118
+ */
119
+ readonly onEntityDataChange = this.onEntityDataChangeEmitter.event;
120
+
121
+ /**
122
+ * Entity 生命周期变化
123
+ */
124
+ readonly onEntityLifeCycleChange = this.onEntityLifeCycleEmitter.event;
125
+
126
+ @multiInject(EntityManagerContribution)
127
+ @optional()
128
+ contributions: EntityManagerContribution[];
129
+
130
+ @injectPlaygroundContext() context: PlaygroundContext;
131
+
132
+ @inject(PlaygroundContainerFactory) @optional() protected containerFactory:
133
+ | PlaygroundContainerFactory
134
+ | undefined;
135
+
136
+ /**
137
+ * 暂停触发实体类型变化
138
+ */
139
+ changeEntityLocked = false;
140
+
141
+ constructor() {
142
+ this.toDispose.pushAll([this.onEntityChangeEmitter, this.schedule]);
143
+ }
144
+
145
+ @postConstruct()
146
+ init() {
147
+ this.contributions.forEach(contrib => contrib.registerEntityManager?.(this));
148
+ }
149
+
150
+ /**
151
+ * 创建实体
152
+ */
153
+ createEntity<T extends Entity>(
154
+ Registry: EntityRegistry,
155
+ opts?: Omit<T['__opts_type__'], 'entityManager'>,
156
+ ): T {
157
+ if (!Registry.type) {
158
+ throw new Error(`[EntityManager] createEntity need a type: ${Registry}`);
159
+ }
160
+ // this.registerEntity(Registry);
161
+ // ConfigEntity 默认为单例
162
+ if (this.configEntities.has(Registry.type)) {
163
+ return this.configEntities.get(Registry.type) as any;
164
+ }
165
+ const entityOpts: EntityOpts = {
166
+ entityManager: this,
167
+ savedInManager: true,
168
+ ...opts,
169
+ };
170
+ const entity = new Registry(entityOpts) as T;
171
+ if (entityOpts.savedInManager) {
172
+ this.saveEntity(entity);
173
+ }
174
+ return entity;
175
+ }
176
+
177
+ isConfigEntity(type: string): boolean {
178
+ return this.configEntities.has(type);
179
+ }
180
+
181
+ /**
182
+ * 批量删除实体
183
+ */
184
+ removeEntities(Registry: EntityRegistry): void {
185
+ for (const e of this.getEntities(Registry).values()) {
186
+ e.dispose();
187
+ }
188
+ }
189
+
190
+ removeEntityById(id: string): boolean {
191
+ const entity = this.getEntityById(id);
192
+ if (entity) {
193
+ entity.dispose();
194
+ return true;
195
+ }
196
+ return false;
197
+ }
198
+
199
+ /**
200
+ * 触发实体 reset
201
+ * @param registry
202
+ */
203
+ resetEntities(registry: EntityRegistry): void {
204
+ const entities = this.getEntities(registry);
205
+ entities.forEach(entity => {
206
+ entity.reset();
207
+ });
208
+ }
209
+
210
+ resetEntity(registry: EntityRegistry, autoCreate?: boolean): void {
211
+ const entity = this.getEntity(registry, autoCreate);
212
+ entity?.reset();
213
+ }
214
+
215
+ updateConfigEntity<E extends ConfigEntity>(
216
+ registry: EntityRegistry,
217
+ config: Partial<E['config']>,
218
+ ): void {
219
+ const entity = this.configEntities.get(registry.type);
220
+ if (entity) {
221
+ entity.updateConfig(config);
222
+ }
223
+ }
224
+
225
+ /**
226
+ * @param type
227
+ */
228
+ getRegistryByType(type: string): EntityRegistry | undefined {
229
+ return this.registryMap.get(type);
230
+ }
231
+
232
+ registerEntity(Registry: EntityRegistry): void {
233
+ if (!Registry.type) throw new Error(`Registry entity need a type: ${Registry.name}`);
234
+ const oldRegistry = this.registryMap.get(Registry.type);
235
+ if (oldRegistry) {
236
+ if (oldRegistry !== Registry) {
237
+ throw new Error(`Entity registry ${Registry.type} need a new type`);
238
+ }
239
+ return;
240
+ }
241
+ this.registryMap.set(Registry.type, Registry);
242
+ }
243
+
244
+ registerEntityData(Registry: EntityDataRegistry, injector?: EntityDataInjector): void {
245
+ if (!Registry.type) throw new Error(`Registry entity data need a type: ${Registry.name}`);
246
+ const oldRegistry = this.dataRegistryMap.get(Registry.type);
247
+ if (!oldRegistry) {
248
+ this.dataRegistryMap.set(Registry.type, Registry);
249
+ // if (oldRegistry !== Registry) {
250
+ // throw new Error(`Entity data registry ${Registry.type} need a new type`)
251
+ // }
252
+ // return
253
+ }
254
+
255
+ const oldInjector = this.dataInjectorMap.get(Registry.type);
256
+ if (!oldInjector && injector) {
257
+ this.dataInjectorMap.set(Registry.type, injector);
258
+ }
259
+ }
260
+
261
+ getDataRegistryByType(type: string): EntityDataRegistry | undefined {
262
+ return this.dataRegistryMap.get(type);
263
+ }
264
+
265
+ getEntityById<T extends Entity>(id: string): T | undefined {
266
+ return this.entityInstanceMap.get(id) as T;
267
+ }
268
+
269
+ /**
270
+ * @param autoCreate 是否要自动创建,默认 false
271
+ */
272
+ getEntity<T extends Entity>(registry: EntityRegistry, autoCreate?: boolean): T | undefined {
273
+ const entity = this.getEntities<T>(registry)[0];
274
+ if (!entity && autoCreate) {
275
+ return this.createEntity<T>(registry);
276
+ }
277
+ return entity;
278
+ }
279
+
280
+ getEntities<T extends Entity>(registry: EntityRegistry): T[] {
281
+ // 获取当前 entities 的快照
282
+ return (this.entityInstanceMapByType.get(registry.type) as T[]) || [];
283
+ }
284
+
285
+ // getEntitiesByAble<T extends Entity>(registry: AbleRegistry): T[] {
286
+ // return this.ableManager.getEntitiesByAble<T>(registry);
287
+ // }
288
+ //
289
+ // getEntitiesByAbles<T extends Entity>(...registries: AbleRegistry[]): T[] {
290
+ // return this.ableManager.getEntitiesByAbles<T>(...registries);
291
+ // }
292
+ //
293
+ // getEntityByAble<T extends Entity>(registry: AbleRegistry): T | undefined {
294
+ // return this.ableManager.getEntityByAble<T>(registry);
295
+ // }
296
+
297
+ getEntityDatas<T extends EntityData>(
298
+ entityRegistry: EntityRegistry,
299
+ dataRegistry: EntityDataRegistry<T>,
300
+ ): T[] {
301
+ return this.getEntities<any>(entityRegistry)
302
+ .map((e: Entity) => e.getData<T>(dataRegistry))
303
+ .filter(d => !!d) as T[];
304
+ }
305
+
306
+ hasEntity(registry: EntityRegistry): boolean {
307
+ return !!this.getEntity(registry);
308
+ }
309
+
310
+ /**
311
+ * 只存储 config 数据,忽略动态数据
312
+ */
313
+ storeState({ configOnly = true }: { configOnly?: boolean } = {}): EntityJSON[] {
314
+ const data: EntityJSON[] = [];
315
+ for (const e of this.entityInstanceMap.values()) {
316
+ if ((!configOnly || e instanceof ConfigEntity) && e.toJSON) {
317
+ if (e.toJSON) {
318
+ const d = e.toJSON();
319
+ if (d) {
320
+ data.push(d);
321
+ }
322
+ }
323
+ }
324
+ }
325
+ return data;
326
+ }
327
+
328
+ restoreState(data: EntityJSON[]): void {
329
+ if (!data || !Array.isArray(data)) return;
330
+ data.forEach((s: EntityJSON) => {
331
+ if (!s || !s.type || !s.id) return;
332
+ const register = this.getRegistryByType(s.type);
333
+ // 如果没有注册,则忽略掉
334
+ if (!register) {
335
+ console.warn(`Playground entity registry lost: ${s.type}`);
336
+ return;
337
+ }
338
+ const entity = this.createEntity(register, {
339
+ id: s.id,
340
+ });
341
+ if (entity.fromJSON) {
342
+ entity.fromJSON(s);
343
+ }
344
+ });
345
+ }
346
+
347
+ protected saveEntity(entity: Entity): void {
348
+ const { id } = entity;
349
+ // 无法重复创建
350
+ if (id && this.entityInstanceMap.has(id)) {
351
+ console.error(`Entity ${entity.type} ${id} is created before`);
352
+ return;
353
+ }
354
+
355
+ this.entityInstanceMap.set(entity.id, entity);
356
+ let entities = this.entityInstanceMapByType.get(entity.type);
357
+ if (!entities) {
358
+ entities = [];
359
+ this.entityInstanceMapByType.set(entity.type, entities);
360
+ }
361
+ if (entity instanceof ConfigEntity) {
362
+ this.configEntities.set(entity.type, entity);
363
+ }
364
+ entities.push(entity);
365
+ entity.onEntityChange(entity => {
366
+ this.fireEntityChanged(entity);
367
+ this.fireEntityLifeCycleChanged({ type: 'update', entity });
368
+ });
369
+ entity.onDataChange(e => {
370
+ this.fireEntityDataChanged(entity.type, e.data.type);
371
+ });
372
+ entity.toDispose.push(
373
+ Disposable.create(() => {
374
+ this.removeEntity(entity);
375
+ this.fireEntityLifeCycleChanged({ type: 'delete', entity });
376
+ }),
377
+ );
378
+ entity
379
+ .getDefaultDataRegistries()
380
+ .forEach(registry => this.fireEntityDataChanged(entity.type, registry.type));
381
+ this.fireEntityChanged(entity);
382
+ this.fireEntityLifeCycleChanged({ type: 'add', entity });
383
+ }
384
+
385
+ protected removeEntity(entity: Entity): void {
386
+ if (this.entityInstanceMap.has(entity.id) && this.entityInstanceMapByType.has(entity.type)) {
387
+ const entities = this.entityInstanceMapByType.get(entity.type)!;
388
+ const index = entities.indexOf(entity);
389
+ if (index !== -1) {
390
+ this.entityInstanceMapByType.set(
391
+ entity.type,
392
+ entities.filter(e => e !== entity),
393
+ );
394
+ this.entityInstanceMap.delete(entity.id);
395
+
396
+ if (this.configEntities.has(entity.type)) {
397
+ this.configEntities.delete(entity.type);
398
+ }
399
+
400
+ this.fireEntityChanged(entity);
401
+ }
402
+ }
403
+ }
404
+
405
+ /**
406
+ * 重制所有 entity 为初始化状态
407
+ */
408
+ reset(): void {
409
+ for (const entity of this.entityInstanceMap.values()) {
410
+ entity.reset();
411
+ }
412
+ }
413
+
414
+ private schedule = new PlaygroundSchedule();
415
+
416
+ fireEntityChanged = (entity: Entity | string) => {
417
+ const entityType = typeof entity === 'string' ? entity : entity.type;
418
+ let version = this.entityVersionMap.get(entityType) || 0;
419
+ /* istanbul ignore next */
420
+ if (version === Number.MAX_SAFE_INTEGER) {
421
+ version = 0;
422
+ }
423
+ this.entityVersionMap.set(entityType, version + 1);
424
+ if (this.changeEntityLocked) return;
425
+ this.schedule.push(entityType, () => {
426
+ this.onEntityChangeEmitter.fire(entityType);
427
+ });
428
+ };
429
+
430
+ fireEntityDataChanged = (entityType: string, entityDataType: string) => {
431
+ let version = this.entityDataVersionMap.get(entityDataType) || 0;
432
+ /* istanbul ignore next */
433
+ if (version === Number.MAX_SAFE_INTEGER) {
434
+ version = 0;
435
+ }
436
+ this.entityDataVersionMap.set(entityDataType, version + 1);
437
+ this.schedule.push(`${entityType}/${entityDataType}`, () => {
438
+ this.onEntityDataChangeEmitter.fire({ entityType, entityDataType });
439
+ });
440
+ };
441
+
442
+ fireEntityLifeCycleChanged = ({
443
+ type,
444
+ entity,
445
+ }: {
446
+ type: 'add' | 'update' | 'delete';
447
+ entity: Entity;
448
+ }) => {
449
+ this.schedule.push(`${type}/${entity.id}`, () => {
450
+ this.onEntityLifeCycleEmitter.fire({ type, entity });
451
+ });
452
+ };
453
+
454
+ getEntityVersion(registry: EntityRegistry | string): number {
455
+ return this.entityVersionMap.get(typeof registry === 'string' ? registry : registry.type) || 0;
456
+ }
457
+
458
+ getEntityDataVersion(registry: EntityDataRegistry | string): number {
459
+ return (
460
+ this.entityDataVersionMap.get(typeof registry === 'string' ? registry : registry.type) || 0
461
+ );
462
+ }
463
+
464
+ dispose(): void {
465
+ this.toDispose.dispose();
466
+ }
467
+
468
+ getDataInjector(registry: EntityDataRegistry | string) {
469
+ return this.dataInjectorMap.get(typeof registry === 'string' ? registry : registry.type);
470
+ }
471
+
472
+ getService<T>(identifier: interfaces.ServiceIdentifier<T>): T {
473
+ return this.containerFactory?.get<T>(identifier) as T;
474
+ }
475
+ }