@awesome-flow/ecs 0.9.3 → 0.9.5

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/dist/index.js CHANGED
@@ -1,1291 +1,537 @@
1
- // src/abstract/ecs-flow-context.ts
2
- import { createContext } from "react";
3
- var EcsFlowContext = createContext(null);
1
+ import { createContext, memo, useContext, useEffect, useMemo, useState } from "react";
2
+ import { NodeContainer } from "@awesome-flow/core/layout";
3
+ import { Accordion, Badge, Box, Button, Collapse, Divider, Group, Stack, Text, useComputedColorScheme } from "@mantine/core";
4
+ import { useDisclosure } from "@mantine/hooks";
5
+ import { Inspector } from "react-inspector";
6
+ import { Fragment, jsx, jsxs } from "react/jsx-runtime";
7
+ import { SystemType } from "@awesome-ecs/abstract/systems";
8
+ import { Position } from "@xyflow/react";
9
+ import { FlowAutoLayout } from "@awesome-flow/core/canvas";
10
+ import { FlowContext } from "@awesome-flow/core/abstract";
11
+ import { useFlowStore } from "@awesome-flow/core/hooks";
4
12
 
5
- // src/utils/id-generator.ts
13
+ //#region src/abstract/ecs-flow-context.ts
14
+ const EcsFlowContext = createContext(null);
15
+
16
+ //#endregion
17
+ //#region src/utils/id-generator.ts
6
18
  var EcsIdGenerator = class {
7
- static entityProxy(proxy) {
8
- return `${proxy.entityType}:${proxy.entityUid}`;
9
- }
19
+ static entityProxy(proxy) {
20
+ return `${proxy.entityType}:${proxy.entityUid}`;
21
+ }
10
22
  };
11
23
 
12
- // src/abstract/ecs-flow-repository.ts
24
+ //#endregion
25
+ //#region src/abstract/ecs-flow-repository.ts
13
26
  var EcsFlowRepository = class {
14
- nodes;
15
- constructor() {
16
- this.nodes = /* @__PURE__ */ new Map();
17
- }
18
- get sizeNodes() {
19
- return this.nodes.size;
20
- }
21
- addSystemModuleNode(node) {
22
- this.nodes.set(node.data.entityType.toString(), node);
23
- }
24
- getSystemModuleNode(entityType) {
25
- return this.nodes.get(entityType.toString());
26
- }
27
- addEntityNode(node) {
28
- this.nodes.set(EcsIdGenerator.entityProxy(node.data.entity), node);
29
- }
30
- getEntityNode(entity) {
31
- return this.nodes.get(EcsIdGenerator.entityProxy(entity));
32
- }
33
- listAllNodes() {
34
- return Array.from(this.nodes.values());
35
- }
27
+ nodes;
28
+ constructor() {
29
+ this.nodes = new Map();
30
+ }
31
+ get sizeNodes() {
32
+ return this.nodes.size;
33
+ }
34
+ addSystemModuleNode(node) {
35
+ this.nodes.set(node.data.entityType.toString(), node);
36
+ }
37
+ getSystemModuleNode(entityType) {
38
+ return this.nodes.get(entityType.toString());
39
+ }
40
+ addEntityNode(node) {
41
+ this.nodes.set(EcsIdGenerator.entityProxy(node.data.entity), node);
42
+ }
43
+ getEntityNode(entity) {
44
+ return this.nodes.get(EcsIdGenerator.entityProxy(entity));
45
+ }
46
+ listAllNodes() {
47
+ return Array.from(this.nodes.values());
48
+ }
36
49
  };
37
50
 
38
- // src/abstract/handle-types.ts
39
- var EcsHandleDataType = /* @__PURE__ */ ((EcsHandleDataType2) => {
40
- EcsHandleDataType2["proxy"] = "proxy";
41
- EcsHandleDataType2["module"] = "module";
42
- return EcsHandleDataType2;
43
- })(EcsHandleDataType || {});
44
-
45
- // src/nodes/node-entity.tsx
46
- import { c as _c9 } from "react/compiler-runtime";
47
- import { NodeContainer } from "@awesome-flow/core/layout";
48
- import { Badge as Badge7 } from "@mantine/core";
49
- import { useContext as useContext3 } from "react";
51
+ //#endregion
52
+ //#region src/abstract/handle-types.ts
53
+ let EcsHandleDataType = /* @__PURE__ */ function(EcsHandleDataType$1) {
54
+ EcsHandleDataType$1["proxy"] = "proxy";
55
+ EcsHandleDataType$1["module"] = "module";
56
+ return EcsHandleDataType$1;
57
+ }({});
50
58
 
51
- // src/components/formatter-camel-case.tsx
52
- import { c as _c } from "react/compiler-runtime";
53
- import { memo } from "react";
59
+ //#endregion
60
+ //#region src/components/formatter-camel-case.tsx
54
61
  function CamelCaseFormatter(props) {
55
- const $ = _c(2);
56
- let t0;
57
- let t1;
58
- if ($[0] !== props.value) {
59
- t1 = props.value?.toString().replace(/([a-z])([A-Z])/g, "$1 $2");
60
- $[0] = props.value;
61
- $[1] = t1;
62
- } else {
63
- t1 = $[1];
64
- }
65
- t0 = t1;
66
- const value = t0;
67
- return value;
62
+ const value = useMemo(() => props.value?.toString().replace(/([a-z])([A-Z])/g, "$1 $2"), [props.value]);
63
+ return value;
68
64
  }
69
65
  var formatter_camel_case_default = memo(CamelCaseFormatter);
70
66
 
71
- // src/layout/entity-layout.tsx
72
- import { c as _c8 } from "react/compiler-runtime";
73
- import { Accordion as Accordion4, Badge as Badge6, Divider, Group } from "@mantine/core";
74
-
75
- // src/components/entity-component-list.tsx
76
- import { c as _c4 } from "react/compiler-runtime";
77
- import { Accordion, Badge, Stack } from "@mantine/core";
78
- import { memo as memo4 } from "react";
79
-
80
- // src/components/entity-component-inspector.tsx
81
- import { c as _c3 } from "react/compiler-runtime";
82
- import { Box, Button, Collapse } from "@mantine/core";
83
- import { useDisclosure } from "@mantine/hooks";
84
- import { memo as memo3 } from "react";
85
-
86
- // src/components/object-inspector.tsx
87
- import { c as _c2 } from "react/compiler-runtime";
88
- import { useComputedColorScheme } from "@mantine/core";
89
- import { memo as memo2 } from "react";
90
- import { Inspector } from "react-inspector";
91
- import { jsx } from "react/jsx-runtime";
67
+ //#endregion
68
+ //#region src/components/object-inspector.tsx
92
69
  function ObjectInspector(props) {
93
- const $ = _c2(3);
94
- const colorScheme = useComputedColorScheme();
95
- let t0;
96
- t0 = colorScheme === "dark" ? "chromeDark" : "chromeLight";
97
- const theme = t0;
98
- let t1;
99
- if ($[0] !== props.data || $[1] !== theme) {
100
- t1 = /* @__PURE__ */ jsx(Inspector, { table: false, theme, data: props.data });
101
- $[0] = props.data;
102
- $[1] = theme;
103
- $[2] = t1;
104
- } else {
105
- t1 = $[2];
106
- }
107
- return t1;
108
- }
109
- var object_inspector_default = memo2(ObjectInspector);
110
-
111
- // src/components/entity-component-inspector.tsx
112
- import { jsx as jsx2, jsxs } from "react/jsx-runtime";
70
+ const colorScheme = useComputedColorScheme();
71
+ const theme = useMemo(() => colorScheme === "dark" ? "chromeDark" : "chromeLight", [colorScheme]);
72
+ return /* @__PURE__ */ jsx(Inspector, {
73
+ table: false,
74
+ theme,
75
+ data: props.data
76
+ });
77
+ }
78
+ var object_inspector_default = memo(ObjectInspector);
79
+
80
+ //#endregion
81
+ //#region src/components/entity-component-inspector.tsx
113
82
  function EntityComponentInspector(props) {
114
- const $ = _c3(13);
115
- const [opened, t0] = useDisclosure(false);
116
- const {
117
- toggle
118
- } = t0;
119
- let t1;
120
- t1 = opened ? "light" : "indigo";
121
- const buttonColor = t1;
122
- let t2;
123
- if ($[0] !== buttonColor || $[1] !== props.component.componentType || $[2] !== toggle) {
124
- t2 = /* @__PURE__ */ jsx2(Button, { variant: "outline", size: "xs", onClick: toggle, color: buttonColor, fullWidth: true, children: props.component.componentType });
125
- $[0] = buttonColor;
126
- $[1] = props.component.componentType;
127
- $[2] = toggle;
128
- $[3] = t2;
129
- } else {
130
- t2 = $[3];
131
- }
132
- let t3;
133
- if ($[4] !== opened || $[5] !== props.component) {
134
- t3 = opened && /* @__PURE__ */ jsx2(object_inspector_default, { data: props.component });
135
- $[4] = opened;
136
- $[5] = props.component;
137
- $[6] = t3;
138
- } else {
139
- t3 = $[6];
140
- }
141
- let t4;
142
- if ($[7] !== opened || $[8] !== t3) {
143
- t4 = /* @__PURE__ */ jsx2(Collapse, { in: opened, children: t3 });
144
- $[7] = opened;
145
- $[8] = t3;
146
- $[9] = t4;
147
- } else {
148
- t4 = $[9];
149
- }
150
- let t5;
151
- if ($[10] !== t2 || $[11] !== t4) {
152
- t5 = /* @__PURE__ */ jsxs(Box, { children: [
153
- t2,
154
- t4
155
- ] });
156
- $[10] = t2;
157
- $[11] = t4;
158
- $[12] = t5;
159
- } else {
160
- t5 = $[12];
161
- }
162
- return t5;
163
- }
164
- var entity_component_inspector_default = memo3(EntityComponentInspector);
165
-
166
- // src/components/entity-component-list.tsx
167
- import { jsx as jsx3, jsxs as jsxs2 } from "react/jsx-runtime";
83
+ const [opened, { toggle }] = useDisclosure(false);
84
+ const buttonColor = useMemo(() => opened ? "light" : "indigo", [opened]);
85
+ return /* @__PURE__ */ jsxs(Box, { children: [/* @__PURE__ */ jsx(Button, {
86
+ variant: "outline",
87
+ size: "xs",
88
+ onClick: toggle,
89
+ color: buttonColor,
90
+ fullWidth: true,
91
+ children: props.component.componentType
92
+ }), /* @__PURE__ */ jsx(Collapse, {
93
+ in: opened,
94
+ children: opened && /* @__PURE__ */ jsx(object_inspector_default, { data: props.component })
95
+ })] });
96
+ }
97
+ var entity_component_inspector_default = memo(EntityComponentInspector);
98
+
99
+ //#endregion
100
+ //#region src/components/entity-component-list.tsx
168
101
  function EntityComponentList(props) {
169
- const $ = _c4(9);
170
- let t0;
171
- if ($[0] !== props.entity.components) {
172
- t0 = Array.from(props.entity.components.values());
173
- $[0] = props.entity.components;
174
- $[1] = t0;
175
- } else {
176
- t0 = $[1];
177
- }
178
- const components = t0;
179
- let t1;
180
- if ($[2] !== components.length) {
181
- t1 = /* @__PURE__ */ jsx3(Accordion.Control, { children: /* @__PURE__ */ jsx3(Badge, { fullWidth: true, variant: "light", rightSection: components.length, children: "Components" }) });
182
- $[2] = components.length;
183
- $[3] = t1;
184
- } else {
185
- t1 = $[3];
186
- }
187
- let t2;
188
- if ($[4] !== components) {
189
- t2 = /* @__PURE__ */ jsx3(Accordion.Panel, { children: /* @__PURE__ */ jsx3(Stack, { children: components.map(_temp) }) });
190
- $[4] = components;
191
- $[5] = t2;
192
- } else {
193
- t2 = $[5];
194
- }
195
- let t3;
196
- if ($[6] !== t1 || $[7] !== t2) {
197
- t3 = /* @__PURE__ */ jsxs2(Accordion.Item, { value: "components", children: [
198
- t1,
199
- t2
200
- ] }, "components");
201
- $[6] = t1;
202
- $[7] = t2;
203
- $[8] = t3;
204
- } else {
205
- t3 = $[8];
206
- }
207
- return t3;
208
- }
209
- function _temp(c, i) {
210
- return /* @__PURE__ */ jsx3(entity_component_inspector_default, { component: c }, i);
211
- }
212
- var entity_component_list_default = memo4(EntityComponentList);
213
-
214
- // src/components/entity-proxy-list.tsx
215
- import { c as _c5 } from "react/compiler-runtime";
216
- import { Accordion as Accordion2, Badge as Badge3, Stack as Stack2 } from "@mantine/core";
217
- import { memo as memo6 } from "react";
218
-
219
- // src/components/badge-list.tsx
220
- import { Badge as Badge2 } from "@mantine/core";
221
- import { memo as memo5 } from "react";
222
- import { jsx as jsx4 } from "react/jsx-runtime";
102
+ const components = Array.from(props.entity.components.values());
103
+ return /* @__PURE__ */ jsxs(Accordion.Item, {
104
+ value: "components",
105
+ children: [/* @__PURE__ */ jsx(Accordion.Control, { children: /* @__PURE__ */ jsx(Badge, {
106
+ fullWidth: true,
107
+ variant: "light",
108
+ rightSection: components.length,
109
+ children: "Components"
110
+ }) }), /* @__PURE__ */ jsx(Accordion.Panel, { children: /* @__PURE__ */ jsx(Stack, { children: components.map((c, i) => /* @__PURE__ */ jsx(entity_component_inspector_default, { component: c }, i)) }) })]
111
+ }, "components");
112
+ }
113
+ var entity_component_list_default = memo(EntityComponentList);
114
+
115
+ //#endregion
116
+ //#region src/components/badge-list.tsx
223
117
  function BadgeList(props) {
224
- return props.items.map((value, i) => {
225
- return /* @__PURE__ */ jsx4(Badge2, { ...props.badge || [], children: /* @__PURE__ */ jsx4(formatter_camel_case_default, { value }) }, i);
226
- });
118
+ return props.items.map((value, i) => {
119
+ return /* @__PURE__ */ jsx(Badge, {
120
+ ...props.badge || [],
121
+ children: /* @__PURE__ */ jsx(formatter_camel_case_default, { value })
122
+ }, i);
123
+ });
227
124
  }
228
- var badge_list_default = memo5(BadgeList);
125
+ var badge_list_default = memo(BadgeList);
229
126
 
230
- // src/components/entity-proxy-list.tsx
231
- import { jsx as jsx5, jsxs as jsxs3 } from "react/jsx-runtime";
127
+ //#endregion
128
+ //#region src/components/entity-proxy-list.tsx
232
129
  function EntityProxyList(props) {
233
- const $ = _c5(10);
234
- let t0;
235
- if ($[0] !== props.entity.proxies) {
236
- const proxies = Array.from(props.entity.proxies.values()).map(_temp4);
237
- t0 = proxies.map(_temp3).flat();
238
- $[0] = props.entity.proxies;
239
- $[1] = t0;
240
- } else {
241
- t0 = $[1];
242
- }
243
- const items = t0;
244
- let t1;
245
- if ($[2] !== items.length) {
246
- t1 = /* @__PURE__ */ jsx5(Accordion2.Control, { children: /* @__PURE__ */ jsx5(Badge3, { fullWidth: true, variant: "light", rightSection: items.length, children: "Proxies" }) });
247
- $[2] = items.length;
248
- $[3] = t1;
249
- } else {
250
- t1 = $[3];
251
- }
252
- let t2;
253
- if ($[4] === Symbol.for("react.memo_cache_sentinel")) {
254
- t2 = {
255
- variant: "outline"
256
- };
257
- $[4] = t2;
258
- } else {
259
- t2 = $[4];
260
- }
261
- let t3;
262
- if ($[5] !== items) {
263
- t3 = /* @__PURE__ */ jsx5(Accordion2.Panel, { children: /* @__PURE__ */ jsx5(Stack2, { children: /* @__PURE__ */ jsx5(badge_list_default, { items, badge: t2 }) }) });
264
- $[5] = items;
265
- $[6] = t3;
266
- } else {
267
- t3 = $[6];
268
- }
269
- let t4;
270
- if ($[7] !== t1 || $[8] !== t3) {
271
- t4 = /* @__PURE__ */ jsxs3(Accordion2.Item, { value: "proxies", children: [
272
- t1,
273
- t3
274
- ] }, "proxies");
275
- $[7] = t1;
276
- $[8] = t3;
277
- $[9] = t4;
278
- } else {
279
- t4 = $[9];
280
- }
281
- return t4;
282
- }
283
- function _temp3(p) {
284
- return Array.from(p).map(_temp2);
285
- }
286
- function _temp2(k) {
287
- return EcsIdGenerator.entityProxy(k);
288
- }
289
- function _temp4(c) {
290
- return c.values();
291
- }
292
- var entity_proxy_list_default = memo6(EntityProxyList);
293
-
294
- // src/components/entity-subscription-list.tsx
295
- import { c as _c6 } from "react/compiler-runtime";
296
- import { Accordion as Accordion3, Badge as Badge4, Stack as Stack3 } from "@mantine/core";
297
- import { memo as memo7, useContext } from "react";
298
- import { jsx as jsx6, jsxs as jsxs4 } from "react/jsx-runtime";
130
+ const { entityProxyRepository } = useContext(EcsFlowContext);
131
+ const proxies = Array.from(entityProxyRepository.getAll(props.entity.myProxy).values()).flat();
132
+ const items = proxies.map((p) => EcsIdGenerator.entityProxy(p));
133
+ return /* @__PURE__ */ jsxs(Accordion.Item, {
134
+ value: "proxies",
135
+ children: [/* @__PURE__ */ jsx(Accordion.Control, { children: /* @__PURE__ */ jsx(Badge, {
136
+ fullWidth: true,
137
+ variant: "light",
138
+ rightSection: items.length,
139
+ children: "Proxies"
140
+ }) }), /* @__PURE__ */ jsx(Accordion.Panel, { children: /* @__PURE__ */ jsx(Stack, { children: /* @__PURE__ */ jsx(badge_list_default, {
141
+ items,
142
+ badge: { variant: "outline" }
143
+ }) }) })]
144
+ }, "proxies");
145
+ }
146
+ var entity_proxy_list_default = memo(EntityProxyList);
147
+
148
+ //#endregion
149
+ //#region src/components/entity-subscription-list.tsx
299
150
  function EntitySubscriptionList(props) {
300
- const $ = _c6(11);
301
- const {
302
- entityEventsManager
303
- } = useContext(EcsFlowContext);
304
- let t0;
305
- if ($[0] !== entityEventsManager || $[1] !== props.entity.myProxy) {
306
- t0 = entityEventsManager.getSubscriptionsForEntity(props.entity.myProxy);
307
- $[0] = entityEventsManager;
308
- $[1] = props.entity.myProxy;
309
- $[2] = t0;
310
- } else {
311
- t0 = $[2];
312
- }
313
- const subscriptions = t0;
314
- let t1;
315
- if ($[3] !== subscriptions.length) {
316
- t1 = /* @__PURE__ */ jsx6(Accordion3.Control, { children: /* @__PURE__ */ jsx6(Badge4, { fullWidth: true, variant: "light", rightSection: subscriptions.length, children: "Events" }) });
317
- $[3] = subscriptions.length;
318
- $[4] = t1;
319
- } else {
320
- t1 = $[4];
321
- }
322
- let t2;
323
- if ($[5] === Symbol.for("react.memo_cache_sentinel")) {
324
- t2 = {
325
- variant: "outline"
326
- };
327
- $[5] = t2;
328
- } else {
329
- t2 = $[5];
330
- }
331
- let t3;
332
- if ($[6] !== subscriptions) {
333
- t3 = /* @__PURE__ */ jsx6(Accordion3.Panel, { children: /* @__PURE__ */ jsx6(Stack3, { children: /* @__PURE__ */ jsx6(badge_list_default, { items: subscriptions, badge: t2 }) }) });
334
- $[6] = subscriptions;
335
- $[7] = t3;
336
- } else {
337
- t3 = $[7];
338
- }
339
- let t4;
340
- if ($[8] !== t1 || $[9] !== t3) {
341
- t4 = /* @__PURE__ */ jsxs4(Accordion3.Item, { value: "subscriptions", children: [
342
- t1,
343
- t3
344
- ] }, "subscriptions");
345
- $[8] = t1;
346
- $[9] = t3;
347
- $[10] = t4;
348
- } else {
349
- t4 = $[10];
350
- }
351
- return t4;
352
- }
353
- var entity_subscription_list_default = memo7(EntitySubscriptionList);
354
-
355
- // src/components/entity-update-counter.tsx
356
- import { c as _c7 } from "react/compiler-runtime";
357
- import { Badge as Badge5 } from "@mantine/core";
358
- import { memo as memo8, useContext as useContext2, useEffect, useState } from "react";
359
- import { Fragment, jsx as jsx7, jsxs as jsxs5 } from "react/jsx-runtime";
151
+ const { entityEventsManager } = useContext(EcsFlowContext);
152
+ const subscriptions = entityEventsManager.getSubscriptionsForEntity(props.entity.myProxy);
153
+ return /* @__PURE__ */ jsxs(Accordion.Item, {
154
+ value: "subscriptions",
155
+ children: [/* @__PURE__ */ jsx(Accordion.Control, { children: /* @__PURE__ */ jsx(Badge, {
156
+ fullWidth: true,
157
+ variant: "light",
158
+ rightSection: subscriptions.length,
159
+ children: "Events"
160
+ }) }), /* @__PURE__ */ jsx(Accordion.Panel, { children: /* @__PURE__ */ jsx(Stack, { children: /* @__PURE__ */ jsx(badge_list_default, {
161
+ items: subscriptions,
162
+ badge: { variant: "outline" }
163
+ }) }) })]
164
+ }, "subscriptions");
165
+ }
166
+ var entity_subscription_list_default = memo(EntitySubscriptionList);
167
+
168
+ //#endregion
169
+ //#region src/components/entity-update-counter.tsx
360
170
  function EntityUpdateCounter(props) {
361
- const $ = _c7(16);
362
- const [, setRefresh] = useState(0);
363
- const {
364
- entityUpdateCounter
365
- } = useContext2(EcsFlowContext);
366
- let t0;
367
- if ($[0] !== entityUpdateCounter || $[1] !== props.entityUid) {
368
- t0 = entityUpdateCounter.getUpdateCount(props.entityUid) || 0;
369
- $[0] = entityUpdateCounter;
370
- $[1] = props.entityUid;
371
- $[2] = t0;
372
- } else {
373
- t0 = $[2];
374
- }
375
- const updates = t0;
376
- let t1;
377
- if ($[3] !== entityUpdateCounter || $[4] !== props.entityUid) {
378
- t1 = entityUpdateCounter.getRemoveCount(props.entityUid) || 0;
379
- $[3] = entityUpdateCounter;
380
- $[4] = props.entityUid;
381
- $[5] = t1;
382
- } else {
383
- t1 = $[5];
384
- }
385
- const removes = t1;
386
- let t2;
387
- if ($[6] !== setRefresh) {
388
- t2 = () => {
389
- const interval = setInterval(() => {
390
- setRefresh(_temp5);
391
- }, 1e3);
392
- return () => {
393
- console.log("CLEAR INTERVAL");
394
- clearInterval(interval);
395
- };
396
- };
397
- $[6] = setRefresh;
398
- $[7] = t2;
399
- } else {
400
- t2 = $[7];
401
- }
402
- let t3;
403
- if ($[8] === Symbol.for("react.memo_cache_sentinel")) {
404
- t3 = [];
405
- $[8] = t3;
406
- } else {
407
- t3 = $[8];
408
- }
409
- useEffect(t2, t3);
410
- let t4;
411
- if ($[9] !== updates) {
412
- t4 = /* @__PURE__ */ jsx7(Badge5, { variant: "light", children: updates });
413
- $[9] = updates;
414
- $[10] = t4;
415
- } else {
416
- t4 = $[10];
417
- }
418
- let t5;
419
- if ($[11] !== removes) {
420
- t5 = /* @__PURE__ */ jsx7(Badge5, { variant: "light", color: "orange", children: removes });
421
- $[11] = removes;
422
- $[12] = t5;
423
- } else {
424
- t5 = $[12];
425
- }
426
- let t6;
427
- if ($[13] !== t4 || $[14] !== t5) {
428
- t6 = /* @__PURE__ */ jsxs5(Fragment, { children: [
429
- t4,
430
- t5
431
- ] });
432
- $[13] = t4;
433
- $[14] = t5;
434
- $[15] = t6;
435
- } else {
436
- t6 = $[15];
437
- }
438
- return t6;
439
- }
440
- function _temp5(refresh) {
441
- return refresh + 1;
442
- }
443
- var entity_update_counter_default = memo8(EntityUpdateCounter);
444
-
445
- // src/layout/entity-layout.tsx
446
- import { Fragment as Fragment2, jsx as jsx8, jsxs as jsxs6 } from "react/jsx-runtime";
447
- function EntityLayout(t0) {
448
- const $ = _c8(8);
449
- const {
450
- entity
451
- } = t0;
452
- let t1;
453
- if ($[0] !== entity.myProxy.entityUid) {
454
- t1 = /* @__PURE__ */ jsxs6(Group, { children: [
455
- /* @__PURE__ */ jsx8(Badge6, { variant: "outline", color: "orange", children: entity.myProxy.entityUid }),
456
- /* @__PURE__ */ jsx8(entity_update_counter_default, { entityUid: entity.myProxy.entityUid })
457
- ] });
458
- $[0] = entity.myProxy.entityUid;
459
- $[1] = t1;
460
- } else {
461
- t1 = $[1];
462
- }
463
- let t2;
464
- if ($[2] === Symbol.for("react.memo_cache_sentinel")) {
465
- t2 = /* @__PURE__ */ jsx8(Divider, { my: 5 });
466
- $[2] = t2;
467
- } else {
468
- t2 = $[2];
469
- }
470
- let t3;
471
- if ($[3] !== entity) {
472
- t3 = /* @__PURE__ */ jsxs6(Accordion4, { children: [
473
- /* @__PURE__ */ jsx8(entity_component_list_default, { entity }),
474
- /* @__PURE__ */ jsx8(entity_proxy_list_default, { entity }),
475
- /* @__PURE__ */ jsx8(entity_subscription_list_default, { entity })
476
- ] });
477
- $[3] = entity;
478
- $[4] = t3;
479
- } else {
480
- t3 = $[4];
481
- }
482
- let t4;
483
- if ($[5] !== t1 || $[6] !== t3) {
484
- t4 = /* @__PURE__ */ jsxs6(Fragment2, { children: [
485
- t1,
486
- t2,
487
- t3
488
- ] });
489
- $[5] = t1;
490
- $[6] = t3;
491
- $[7] = t4;
492
- } else {
493
- t4 = $[7];
494
- }
495
- return t4;
171
+ const [, setRefresh] = useState(0);
172
+ const { entityUpdateCounter } = useContext(EcsFlowContext);
173
+ const updates = entityUpdateCounter.getUpdateCount(props.entityUid) || 0;
174
+ const removes = entityUpdateCounter.getRemoveCount(props.entityUid) || 0;
175
+ useEffect(() => {
176
+ const interval = setInterval(() => {
177
+ setRefresh((refresh) => refresh + 1);
178
+ }, 1e3);
179
+ return () => {
180
+ console.log("CLEAR INTERVAL");
181
+ clearInterval(interval);
182
+ };
183
+ }, []);
184
+ return /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsx(Badge, {
185
+ variant: "light",
186
+ children: updates
187
+ }), /* @__PURE__ */ jsx(Badge, {
188
+ variant: "light",
189
+ color: "orange",
190
+ children: removes
191
+ })] });
192
+ }
193
+ var entity_update_counter_default = memo(EntityUpdateCounter);
194
+
195
+ //#endregion
196
+ //#region src/layout/entity-layout.tsx
197
+ function EntityLayout({ entity }) {
198
+ return /* @__PURE__ */ jsxs(Fragment, { children: [
199
+ /* @__PURE__ */ jsxs(Group, { children: [/* @__PURE__ */ jsx(Badge, {
200
+ variant: "outline",
201
+ color: "orange",
202
+ children: entity.myProxy.entityUid
203
+ }), /* @__PURE__ */ jsx(entity_update_counter_default, { entityUid: entity.myProxy.entityUid })] }),
204
+ /* @__PURE__ */ jsx(Divider, { my: 5 }),
205
+ /* @__PURE__ */ jsxs(Accordion, { children: [
206
+ /* @__PURE__ */ jsx(entity_component_list_default, { entity }),
207
+ /* @__PURE__ */ jsx(entity_proxy_list_default, { entity }),
208
+ /* @__PURE__ */ jsx(entity_subscription_list_default, { entity })
209
+ ] })
210
+ ] });
496
211
  }
497
212
  var entity_layout_default = EntityLayout;
498
213
 
499
- // src/nodes/node-entity.tsx
500
- import { jsx as jsx9 } from "react/jsx-runtime";
501
- function EntityNode(t0) {
502
- const $ = _c9(14);
503
- const {
504
- id,
505
- data,
506
- selected,
507
- type
508
- } = t0;
509
- const {
510
- entityRepository
511
- } = useContext3(EcsFlowContext);
512
- let t1;
513
- let t2;
514
- if ($[0] !== data.entity || $[1] !== entityRepository) {
515
- t2 = entityRepository.get(data.entity);
516
- $[0] = data.entity;
517
- $[1] = entityRepository;
518
- $[2] = t2;
519
- } else {
520
- t2 = $[2];
521
- }
522
- t1 = t2;
523
- const entity = t1;
524
- let t3;
525
- if ($[3] !== entity.myProxy.entityType) {
526
- t3 = /* @__PURE__ */ jsx9(Badge7, { fullWidth: true, variant: "transparent", children: /* @__PURE__ */ jsx9(formatter_camel_case_default, { value: entity.myProxy.entityType }) });
527
- $[3] = entity.myProxy.entityType;
528
- $[4] = t3;
529
- } else {
530
- t3 = $[4];
531
- }
532
- let t4;
533
- if ($[5] !== entity) {
534
- t4 = /* @__PURE__ */ jsx9(entity_layout_default, { entity });
535
- $[5] = entity;
536
- $[6] = t4;
537
- } else {
538
- t4 = $[6];
539
- }
540
- let t5;
541
- if ($[7] !== data || $[8] !== id || $[9] !== selected || $[10] !== t3 || $[11] !== t4 || $[12] !== type) {
542
- t5 = /* @__PURE__ */ jsx9(NodeContainer, { id, selected, data, title: t3, type, children: t4 });
543
- $[7] = data;
544
- $[8] = id;
545
- $[9] = selected;
546
- $[10] = t3;
547
- $[11] = t4;
548
- $[12] = type;
549
- $[13] = t5;
550
- } else {
551
- t5 = $[13];
552
- }
553
- return t5;
214
+ //#endregion
215
+ //#region src/nodes/node-entity.tsx
216
+ function EntityNode({ id, data, selected, type }) {
217
+ const { entityRepository } = useContext(EcsFlowContext);
218
+ const entity = useMemo(() => entityRepository.get(data.entity), [data.entity, entityRepository]);
219
+ return /* @__PURE__ */ jsx(NodeContainer, {
220
+ id,
221
+ selected,
222
+ data,
223
+ title: /* @__PURE__ */ jsx(Badge, {
224
+ fullWidth: true,
225
+ variant: "transparent",
226
+ children: /* @__PURE__ */ jsx(formatter_camel_case_default, { value: entity.myProxy.entityType })
227
+ }),
228
+ type,
229
+ children: /* @__PURE__ */ jsx(entity_layout_default, { entity })
230
+ });
554
231
  }
555
232
  var node_entity_default = EntityNode;
556
233
 
557
- // src/nodes/node-systems-module.tsx
558
- import { c as _c12 } from "react/compiler-runtime";
559
- import { NodeContainer as NodeContainer2 } from "@awesome-flow/core/layout";
560
- import { Badge as Badge9 } from "@mantine/core";
561
- import { useContext as useContext4 } from "react";
562
-
563
- // src/layout/systems-module-layout.tsx
564
- import { c as _c11 } from "react/compiler-runtime";
565
- import { SystemType } from "@awesome-ecs/abstract/systems";
566
- import { Accordion as Accordion6, Text } from "@mantine/core";
567
-
568
- // src/components/pipeline-middleware-list.tsx
569
- import { c as _c10 } from "react/compiler-runtime";
570
- import { Accordion as Accordion5, Badge as Badge8, Stack as Stack4 } from "@mantine/core";
571
- import { jsx as jsx10, jsxs as jsxs7 } from "react/jsx-runtime";
234
+ //#endregion
235
+ //#region src/components/pipeline-middleware-list.tsx
572
236
  function PipelineMiddlewareList(props) {
573
- const $ = _c10(13);
574
- let t0;
575
- if ($[0] === Symbol.for("react.memo_cache_sentinel")) {
576
- t0 = [];
577
- $[0] = t0;
578
- } else {
579
- t0 = $[0];
580
- }
581
- let middleware = t0;
582
- if (props.pipeline) {
583
- middleware = props.pipeline.middleware;
584
- }
585
- let t1;
586
- if ($[1] !== middleware) {
587
- t1 = middleware.map(_temp6);
588
- $[1] = middleware;
589
- $[2] = t1;
590
- } else {
591
- t1 = $[2];
592
- }
593
- const components = t1;
594
- let t2;
595
- if ($[3] !== components.length || $[4] !== props.label) {
596
- t2 = /* @__PURE__ */ jsx10(Accordion5.Control, { children: /* @__PURE__ */ jsx10(Badge8, { fullWidth: true, variant: "light", rightSection: components.length, children: props.label }) });
597
- $[3] = components.length;
598
- $[4] = props.label;
599
- $[5] = t2;
600
- } else {
601
- t2 = $[5];
602
- }
603
- let t3;
604
- if ($[6] === Symbol.for("react.memo_cache_sentinel")) {
605
- t3 = {
606
- variant: "outline"
607
- };
608
- $[6] = t3;
609
- } else {
610
- t3 = $[6];
611
- }
612
- let t4;
613
- if ($[7] !== components) {
614
- t4 = /* @__PURE__ */ jsx10(Accordion5.Panel, { children: /* @__PURE__ */ jsx10(Stack4, { children: /* @__PURE__ */ jsx10(badge_list_default, { items: components, badge: t3 }) }) });
615
- $[7] = components;
616
- $[8] = t4;
617
- } else {
618
- t4 = $[8];
619
- }
620
- let t5;
621
- if ($[9] !== props.label || $[10] !== t2 || $[11] !== t4) {
622
- t5 = /* @__PURE__ */ jsxs7(Accordion5.Item, { value: props.label, children: [
623
- t2,
624
- t4
625
- ] }, props.label);
626
- $[9] = props.label;
627
- $[10] = t2;
628
- $[11] = t4;
629
- $[12] = t5;
630
- } else {
631
- t5 = $[12];
632
- }
633
- return t5;
634
- }
635
- function _temp6(m) {
636
- return m.name || m.constructor.name;
237
+ let middleware = [];
238
+ if (props.pipeline) middleware = props.pipeline["middleware"];
239
+ const components = middleware.map((m) => {
240
+ return m.name || m.constructor.name;
241
+ });
242
+ return /* @__PURE__ */ jsxs(Accordion.Item, {
243
+ value: props.label,
244
+ children: [/* @__PURE__ */ jsx(Accordion.Control, { children: /* @__PURE__ */ jsx(Badge, {
245
+ fullWidth: true,
246
+ variant: "light",
247
+ rightSection: components.length,
248
+ children: props.label
249
+ }) }), /* @__PURE__ */ jsx(Accordion.Panel, { children: /* @__PURE__ */ jsx(Stack, { children: /* @__PURE__ */ jsx(badge_list_default, {
250
+ items: components,
251
+ badge: { variant: "outline" }
252
+ }) }) })]
253
+ }, props.label);
637
254
  }
638
255
  var pipeline_middleware_list_default = PipelineMiddlewareList;
639
256
 
640
- // src/layout/systems-module-layout.tsx
641
- import { Fragment as Fragment3, jsx as jsx11, jsxs as jsxs8 } from "react/jsx-runtime";
257
+ //#endregion
258
+ //#region src/layout/systems-module-layout.tsx
642
259
  function SystemsModuleLayout(props) {
643
- const $ = _c11(26);
644
- const {
645
- module
646
- } = props;
647
- const runtimeContext = module.runtimeContext;
648
- const {
649
- systemContext
650
- } = runtimeContext;
651
- let t0;
652
- t0 = systemContext.runtime;
653
- const {
654
- status
655
- } = t0;
656
- let t1;
657
- if ($[0] !== runtimeContext.systemPipelines) {
658
- t1 = runtimeContext.systemPipelines.get(SystemType.initialize);
659
- $[0] = runtimeContext.systemPipelines;
660
- $[1] = t1;
661
- } else {
662
- t1 = $[1];
663
- }
664
- const init = t1;
665
- let t2;
666
- if ($[2] !== runtimeContext.systemPipelines) {
667
- t2 = runtimeContext.systemPipelines.get(SystemType.update);
668
- $[2] = runtimeContext.systemPipelines;
669
- $[3] = t2;
670
- } else {
671
- t2 = $[3];
672
- }
673
- const update = t2;
674
- let t3;
675
- if ($[4] !== runtimeContext.systemPipelines) {
676
- t3 = runtimeContext.systemPipelines.get(SystemType.render);
677
- $[4] = runtimeContext.systemPipelines;
678
- $[5] = t3;
679
- } else {
680
- t3 = $[5];
681
- }
682
- const render = t3;
683
- let t4;
684
- if ($[6] !== runtimeContext.systemPipelines) {
685
- t4 = runtimeContext.systemPipelines.get(SystemType.sync);
686
- $[6] = runtimeContext.systemPipelines;
687
- $[7] = t4;
688
- } else {
689
- t4 = $[7];
690
- }
691
- const sync = t4;
692
- let t5;
693
- if ($[8] !== status) {
694
- t5 = /* @__PURE__ */ jsxs8(Text, { children: [
695
- "Status: ",
696
- status
697
- ] });
698
- $[8] = status;
699
- $[9] = t5;
700
- } else {
701
- t5 = $[9];
702
- }
703
- let t6;
704
- if ($[10] !== init) {
705
- t6 = init && /* @__PURE__ */ jsx11(pipeline_middleware_list_default, { pipeline: init, label: "Initialize" });
706
- $[10] = init;
707
- $[11] = t6;
708
- } else {
709
- t6 = $[11];
710
- }
711
- let t7;
712
- if ($[12] !== update) {
713
- t7 = update && /* @__PURE__ */ jsx11(pipeline_middleware_list_default, { pipeline: update, label: "Update" });
714
- $[12] = update;
715
- $[13] = t7;
716
- } else {
717
- t7 = $[13];
718
- }
719
- let t8;
720
- if ($[14] !== render) {
721
- t8 = render && /* @__PURE__ */ jsx11(pipeline_middleware_list_default, { pipeline: render, label: "Render" });
722
- $[14] = render;
723
- $[15] = t8;
724
- } else {
725
- t8 = $[15];
726
- }
727
- let t9;
728
- if ($[16] !== sync) {
729
- t9 = sync && /* @__PURE__ */ jsx11(pipeline_middleware_list_default, { pipeline: sync, label: "Sync" });
730
- $[16] = sync;
731
- $[17] = t9;
732
- } else {
733
- t9 = $[17];
734
- }
735
- let t10;
736
- if ($[18] !== t6 || $[19] !== t7 || $[20] !== t8 || $[21] !== t9) {
737
- t10 = /* @__PURE__ */ jsxs8(Accordion6, { children: [
738
- t6,
739
- t7,
740
- t8,
741
- t9
742
- ] });
743
- $[18] = t6;
744
- $[19] = t7;
745
- $[20] = t8;
746
- $[21] = t9;
747
- $[22] = t10;
748
- } else {
749
- t10 = $[22];
750
- }
751
- let t11;
752
- if ($[23] !== t10 || $[24] !== t5) {
753
- t11 = /* @__PURE__ */ jsxs8(Fragment3, { children: [
754
- t5,
755
- t10
756
- ] });
757
- $[23] = t10;
758
- $[24] = t5;
759
- $[25] = t11;
760
- } else {
761
- t11 = $[25];
762
- }
763
- return t11;
260
+ const { module } = props;
261
+ const runtimeContext = module["runtimeContext"];
262
+ const { systemContext } = runtimeContext;
263
+ const { status } = useMemo(() => {
264
+ return systemContext.runtime;
265
+ }, [systemContext.runtime]);
266
+ const init = runtimeContext.systemPipelines.get(SystemType.initialize);
267
+ const update = runtimeContext.systemPipelines.get(SystemType.update);
268
+ const render = runtimeContext.systemPipelines.get(SystemType.render);
269
+ const sync = runtimeContext.systemPipelines.get(SystemType.sync);
270
+ return /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsxs(Text, { children: ["Status: ", status] }), /* @__PURE__ */ jsxs(Accordion, { children: [
271
+ init && /* @__PURE__ */ jsx(pipeline_middleware_list_default, {
272
+ pipeline: init,
273
+ label: "Initialize"
274
+ }),
275
+ update && /* @__PURE__ */ jsx(pipeline_middleware_list_default, {
276
+ pipeline: update,
277
+ label: "Update"
278
+ }),
279
+ render && /* @__PURE__ */ jsx(pipeline_middleware_list_default, {
280
+ pipeline: render,
281
+ label: "Render"
282
+ }),
283
+ sync && /* @__PURE__ */ jsx(pipeline_middleware_list_default, {
284
+ pipeline: sync,
285
+ label: "Sync"
286
+ })
287
+ ] })] });
764
288
  }
765
289
  var systems_module_layout_default = SystemsModuleLayout;
766
290
 
767
- // src/nodes/node-systems-module.tsx
768
- import { jsx as jsx12 } from "react/jsx-runtime";
769
- function SystemsModuleNode(t0) {
770
- const $ = _c12(15);
771
- const {
772
- id,
773
- data,
774
- selected,
775
- type
776
- } = t0;
777
- const {
778
- systemsModuleRepository
779
- } = useContext4(EcsFlowContext);
780
- let t1;
781
- if ($[0] !== data.entityType || $[1] !== systemsModuleRepository) {
782
- t1 = systemsModuleRepository.get(data.entityType);
783
- $[0] = data.entityType;
784
- $[1] = systemsModuleRepository;
785
- $[2] = t1;
786
- } else {
787
- t1 = $[2];
788
- }
789
- const module = t1;
790
- let t2;
791
- if ($[3] !== data.entityType) {
792
- t2 = /* @__PURE__ */ jsx12(Badge9, { fullWidth: true, color: "indigo", variant: "transparent", children: /* @__PURE__ */ jsx12(formatter_camel_case_default, { value: data.entityType }) });
793
- $[3] = data.entityType;
794
- $[4] = t2;
795
- } else {
796
- t2 = $[4];
797
- }
798
- let t3;
799
- if ($[5] !== data.entityType || $[6] !== module) {
800
- t3 = /* @__PURE__ */ jsx12(systems_module_layout_default, { type: data.entityType, module });
801
- $[5] = data.entityType;
802
- $[6] = module;
803
- $[7] = t3;
804
- } else {
805
- t3 = $[7];
806
- }
807
- let t4;
808
- if ($[8] !== data || $[9] !== id || $[10] !== selected || $[11] !== t2 || $[12] !== t3 || $[13] !== type) {
809
- t4 = /* @__PURE__ */ jsx12(NodeContainer2, { id, selected, data, title: t2, type, children: t3 });
810
- $[8] = data;
811
- $[9] = id;
812
- $[10] = selected;
813
- $[11] = t2;
814
- $[12] = t3;
815
- $[13] = type;
816
- $[14] = t4;
817
- } else {
818
- t4 = $[14];
819
- }
820
- return t4;
291
+ //#endregion
292
+ //#region src/nodes/node-systems-module.tsx
293
+ function SystemsModuleNode({ id, data, selected, type }) {
294
+ const { systemsModuleRepository } = useContext(EcsFlowContext);
295
+ const module = systemsModuleRepository.get(data.entityType);
296
+ return /* @__PURE__ */ jsx(NodeContainer, {
297
+ id,
298
+ selected,
299
+ data,
300
+ title: /* @__PURE__ */ jsx(Badge, {
301
+ fullWidth: true,
302
+ color: "indigo",
303
+ variant: "transparent",
304
+ children: /* @__PURE__ */ jsx(formatter_camel_case_default, { value: data.entityType })
305
+ }),
306
+ type,
307
+ children: /* @__PURE__ */ jsx(systems_module_layout_default, {
308
+ type: data.entityType,
309
+ module
310
+ })
311
+ });
821
312
  }
822
313
  var node_systems_module_default = SystemsModuleNode;
823
314
 
824
- // src/templates/template-entity-node.ts
825
- import { Position } from "@xyflow/react";
826
-
827
- // src/abstract/templates.ts
828
- var EcsTemplateGroup = /* @__PURE__ */ ((EcsTemplateGroup2) => {
829
- EcsTemplateGroup2["ecs"] = "ECS";
830
- return EcsTemplateGroup2;
831
- })(EcsTemplateGroup || {});
315
+ //#endregion
316
+ //#region src/abstract/templates.ts
317
+ let EcsTemplateGroup = /* @__PURE__ */ function(EcsTemplateGroup$1) {
318
+ EcsTemplateGroup$1["ecs"] = "ECS";
319
+ return EcsTemplateGroup$1;
320
+ }({});
832
321
 
833
- // src/templates/template-entity-node.ts
322
+ //#endregion
323
+ //#region src/templates/template-entity-node.ts
834
324
  var EntityNodeTemplate = class {
835
- template = {
836
- type: "entity-node" /* entity */,
837
- group: "ECS" /* ecs */,
838
- data: {
839
- title: "Entity",
840
- entity: null
841
- },
842
- handles: [
843
- {
844
- dataType: "proxy" /* proxy */,
845
- position: Position.Left,
846
- connection: "target",
847
- disabled: true
848
- },
849
- {
850
- dataType: "proxy" /* proxy */,
851
- position: Position.Right,
852
- connection: "source",
853
- disabled: true
854
- }
855
- ]
856
- };
325
+ template = {
326
+ type: EcsNodeType.entity,
327
+ group: EcsTemplateGroup.ecs,
328
+ data: {
329
+ title: "Entity",
330
+ entity: null
331
+ },
332
+ handles: [{
333
+ dataType: EcsHandleDataType.proxy,
334
+ position: Position.Left,
335
+ connection: "target",
336
+ disabled: true
337
+ }, {
338
+ dataType: EcsHandleDataType.proxy,
339
+ position: Position.Right,
340
+ connection: "source",
341
+ disabled: true
342
+ }]
343
+ };
857
344
  };
858
345
 
859
- // src/templates/template-systems-module.ts
860
- import { Position as Position2 } from "@xyflow/react";
346
+ //#endregion
347
+ //#region src/templates/template-systems-module.ts
861
348
  var SystemsModuleNodeTemplate = class {
862
- template = {
863
- type: "systems-module-node" /* systemsModule */,
864
- group: "ECS" /* ecs */,
865
- data: {
866
- title: "Systems Module",
867
- entityType: null
868
- },
869
- handles: [
870
- {
871
- dataType: "module" /* module */,
872
- position: Position2.Left,
873
- connection: "target",
874
- disabled: true
875
- }
876
- ]
877
- };
349
+ template = {
350
+ type: EcsNodeType.systemsModule,
351
+ group: EcsTemplateGroup.ecs,
352
+ data: {
353
+ title: "Systems Module",
354
+ entityType: null
355
+ },
356
+ handles: [{
357
+ dataType: EcsHandleDataType.module,
358
+ position: Position.Left,
359
+ connection: "target",
360
+ disabled: true
361
+ }]
362
+ };
878
363
  };
879
364
 
880
- // src/abstract/node-types.ts
881
- var EcsNodeType = /* @__PURE__ */ ((EcsNodeType2) => {
882
- EcsNodeType2["systemsModule"] = "systems-module-node";
883
- EcsNodeType2["entity"] = "entity-node";
884
- return EcsNodeType2;
885
- })(EcsNodeType || {});
886
- var ecsNodeTypes = {
887
- ["systems-module-node" /* systemsModule */]: node_systems_module_default,
888
- ["entity-node" /* entity */]: node_entity_default
365
+ //#endregion
366
+ //#region src/abstract/node-types.ts
367
+ let EcsNodeType = /* @__PURE__ */ function(EcsNodeType$1) {
368
+ EcsNodeType$1["systemsModule"] = "systems-module-node";
369
+ EcsNodeType$1["entity"] = "entity-node";
370
+ return EcsNodeType$1;
371
+ }({});
372
+ const ecsNodeTypes = {
373
+ [EcsNodeType.systemsModule]: node_systems_module_default,
374
+ [EcsNodeType.entity]: node_entity_default
889
375
  };
890
- var ecsNodeTemplates = {
891
- ["entity-node" /* entity */]: new EntityNodeTemplate(),
892
- ["systems-module-node" /* systemsModule */]: new SystemsModuleNodeTemplate()
376
+ const ecsNodeTemplates = {
377
+ [EcsNodeType.entity]: new EntityNodeTemplate(),
378
+ [EcsNodeType.systemsModule]: new SystemsModuleNodeTemplate()
893
379
  };
894
380
 
895
- // src/flow/flow-ecs-state.tsx
896
- import { c as _c17 } from "react/compiler-runtime";
897
- import { FlowAutoLayout } from "@awesome-flow/core/canvas";
898
- import { memo as memo9, useContext as useContext9, useEffect as useEffect6, useState as useState3 } from "react";
899
-
900
- // src/flow/flow-ecs-entities.tsx
901
- import { c as _c15 } from "react/compiler-runtime";
902
- import { FlowContext } from "@awesome-flow/core/abstract";
903
- import { useFlowStore as useFlowStore3 } from "@awesome-flow/core/hooks";
904
- import { useContext as useContext7, useEffect as useEffect4, useState as useState2 } from "react";
905
-
906
- // src/flow/flow-ecs-edge-modules.tsx
907
- import { c as _c13 } from "react/compiler-runtime";
908
- import { useFlowStore } from "@awesome-flow/core/hooks";
909
- import { useContext as useContext5, useEffect as useEffect2 } from "react";
910
- import { Fragment as Fragment4, jsx as jsx13 } from "react/jsx-runtime";
381
+ //#endregion
382
+ //#region src/flow/flow-ecs-edge-modules.tsx
911
383
  function FlowEcsEdgeModules(props) {
912
- const $ = _c13(7);
913
- const {
914
- nodesToConnect
915
- } = props;
916
- const onConnect = useFlowStore(_temp7);
917
- const {
918
- ecsFlowRepository,
919
- entityRepository
920
- } = useContext5(EcsFlowContext);
921
- let t0;
922
- let t1;
923
- if ($[0] !== ecsFlowRepository || $[1] !== entityRepository || $[2] !== nodesToConnect || $[3] !== onConnect) {
924
- t0 = () => {
925
- for (const node of nodesToConnect) {
926
- const sourceHandle = node.data.handles.find(_temp22);
927
- const entity = entityRepository.get(node.data.entity);
928
- const systemModule = ecsFlowRepository.getSystemModuleNode(entity.myProxy.entityType);
929
- const targetHandle = systemModule?.data.handles.find(_temp32);
930
- if (targetHandle) {
931
- onConnect({
932
- source: node.id,
933
- target: systemModule.id,
934
- sourceHandle: sourceHandle.handleId,
935
- targetHandle: targetHandle.handleId
936
- });
937
- }
938
- }
939
- };
940
- t1 = [nodesToConnect, ecsFlowRepository, entityRepository, onConnect];
941
- $[0] = ecsFlowRepository;
942
- $[1] = entityRepository;
943
- $[2] = nodesToConnect;
944
- $[3] = onConnect;
945
- $[4] = t0;
946
- $[5] = t1;
947
- } else {
948
- t0 = $[4];
949
- t1 = $[5];
950
- }
951
- useEffect2(t0, t1);
952
- let t2;
953
- if ($[6] === Symbol.for("react.memo_cache_sentinel")) {
954
- t2 = /* @__PURE__ */ jsx13(Fragment4, {});
955
- $[6] = t2;
956
- } else {
957
- t2 = $[6];
958
- }
959
- return t2;
960
- }
961
- function _temp32(h_0) {
962
- return h_0.connection === "target";
963
- }
964
- function _temp22(h) {
965
- return h.connection === "source";
966
- }
967
- function _temp7(state) {
968
- return state.onConnect;
384
+ const { nodesToConnect } = props;
385
+ const onConnect = useFlowStore((state) => state.onConnect);
386
+ const { ecsFlowRepository, entityRepository } = useContext(EcsFlowContext);
387
+ useEffect(() => {
388
+ for (const node of nodesToConnect) {
389
+ const sourceHandle = node.data.handles.find((h) => h.connection === "source");
390
+ const entity = entityRepository.get(node.data.entity);
391
+ const systemModule = ecsFlowRepository.getSystemModuleNode(entity.myProxy.entityType);
392
+ const targetHandle = systemModule?.data.handles.find((h) => h.connection === "target");
393
+ if (targetHandle) onConnect({
394
+ source: node.id,
395
+ target: systemModule.id,
396
+ sourceHandle: sourceHandle.handleId,
397
+ targetHandle: targetHandle.handleId
398
+ });
399
+ }
400
+ }, [
401
+ nodesToConnect,
402
+ ecsFlowRepository,
403
+ entityRepository,
404
+ onConnect
405
+ ]);
406
+ return /* @__PURE__ */ jsx(Fragment, {});
969
407
  }
970
408
  var flow_ecs_edge_modules_default = FlowEcsEdgeModules;
971
409
 
972
- // src/flow/flow-ecs-edge-proxies.tsx
973
- import { c as _c14 } from "react/compiler-runtime";
974
- import { useFlowStore as useFlowStore2 } from "@awesome-flow/core/hooks";
975
- import { useContext as useContext6, useEffect as useEffect3 } from "react";
976
- import { Fragment as Fragment5, jsx as jsx14 } from "react/jsx-runtime";
410
+ //#endregion
411
+ //#region src/flow/flow-ecs-edge-proxies.tsx
977
412
  function FlowEcsEdgeProxies(props) {
978
- const $ = _c14(7);
979
- const {
980
- nodesToConnect
981
- } = props;
982
- const onConnect = useFlowStore2(_temp8);
983
- const {
984
- ecsFlowRepository,
985
- entityRepository
986
- } = useContext6(EcsFlowContext);
987
- let t0;
988
- let t1;
989
- if ($[0] !== ecsFlowRepository || $[1] !== entityRepository || $[2] !== nodesToConnect || $[3] !== onConnect) {
990
- t0 = () => {
991
- for (const node of nodesToConnect) {
992
- const sourceHandle = node.data.handles.find(_temp23);
993
- const entity = entityRepository.get(node.data.entity);
994
- for (const [, proxyMap] of entity.proxies) {
995
- for (const proxy of proxyMap.values()) {
996
- const proxyNode = ecsFlowRepository.getEntityNode(proxy);
997
- if (proxyNode) {
998
- const targetHandle = proxyNode.data.handles.find(_temp33);
999
- onConnect({
1000
- source: node.id,
1001
- target: proxyNode.id,
1002
- sourceHandle: sourceHandle.handleId,
1003
- targetHandle: targetHandle.handleId
1004
- });
1005
- }
1006
- }
1007
- }
1008
- }
1009
- };
1010
- t1 = [nodesToConnect, ecsFlowRepository, entityRepository, onConnect];
1011
- $[0] = ecsFlowRepository;
1012
- $[1] = entityRepository;
1013
- $[2] = nodesToConnect;
1014
- $[3] = onConnect;
1015
- $[4] = t0;
1016
- $[5] = t1;
1017
- } else {
1018
- t0 = $[4];
1019
- t1 = $[5];
1020
- }
1021
- useEffect3(t0, t1);
1022
- let t2;
1023
- if ($[6] === Symbol.for("react.memo_cache_sentinel")) {
1024
- t2 = /* @__PURE__ */ jsx14(Fragment5, {});
1025
- $[6] = t2;
1026
- } else {
1027
- t2 = $[6];
1028
- }
1029
- return t2;
1030
- }
1031
- function _temp33(h_0) {
1032
- return h_0.connection === "target";
1033
- }
1034
- function _temp23(h) {
1035
- return h.connection === "source";
1036
- }
1037
- function _temp8(state) {
1038
- return state.onConnect;
413
+ const { nodesToConnect } = props;
414
+ const onConnect = useFlowStore((state) => state.onConnect);
415
+ const { ecsFlowRepository, entityProxyRepository, entityRepository } = useContext(EcsFlowContext);
416
+ useEffect(() => {
417
+ for (const node of nodesToConnect) {
418
+ const sourceHandle = node.data.handles.find((h) => h.connection === "source");
419
+ const entity = entityRepository.get(node.data.entity);
420
+ const proxies = Array.from(entityProxyRepository.getAll(entity.myProxy).values()).flat();
421
+ for (const proxy of proxies) {
422
+ const proxyNode = ecsFlowRepository.getEntityNode(proxy);
423
+ if (proxyNode) {
424
+ const targetHandle = proxyNode.data.handles.find((h) => h.connection === "target");
425
+ onConnect({
426
+ source: node.id,
427
+ target: proxyNode.id,
428
+ sourceHandle: sourceHandle.handleId,
429
+ targetHandle: targetHandle.handleId
430
+ });
431
+ }
432
+ }
433
+ }
434
+ }, [
435
+ nodesToConnect,
436
+ ecsFlowRepository,
437
+ entityRepository,
438
+ entityProxyRepository,
439
+ onConnect
440
+ ]);
441
+ return /* @__PURE__ */ jsx(Fragment, {});
1039
442
  }
1040
443
  var flow_ecs_edge_proxies_default = FlowEcsEdgeProxies;
1041
444
 
1042
- // src/flow/flow-ecs-entities.tsx
1043
- import { Fragment as Fragment6, jsx as jsx15, jsxs as jsxs9 } from "react/jsx-runtime";
445
+ //#endregion
446
+ //#region src/flow/flow-ecs-entities.tsx
1044
447
  function FlowEcsEntities() {
1045
- const $ = _c15(9);
1046
- const {
1047
- nodeFactory
1048
- } = useContext7(FlowContext);
1049
- const addNodes = useFlowStore3(_temp9);
1050
- const {
1051
- ecsFlowRepository,
1052
- entityRepository
1053
- } = useContext7(EcsFlowContext);
1054
- let t0;
1055
- if ($[0] === Symbol.for("react.memo_cache_sentinel")) {
1056
- t0 = [];
1057
- $[0] = t0;
1058
- } else {
1059
- t0 = $[0];
1060
- }
1061
- const [entityNodes, setEntityNodes] = useState2(t0);
1062
- let t1;
1063
- let t2;
1064
- if ($[1] !== addNodes || $[2] !== ecsFlowRepository || $[3] !== entityRepository || $[4] !== nodeFactory) {
1065
- t1 = () => {
1066
- const entities = entityRepository.listAll();
1067
- const nodes = [];
1068
- for (const entity of entities) {
1069
- if (ecsFlowRepository.getEntityNode(entity.myProxy)) {
1070
- continue;
1071
- }
1072
- const node = nodeFactory.createNodeFromType("entity-node" /* entity */);
1073
- node.data.entity = entity.myProxy;
1074
- node.position = {
1075
- x: 0,
1076
- y: 0
1077
- };
1078
- ecsFlowRepository.addEntityNode(node);
1079
- nodes.push(node);
1080
- }
1081
- setEntityNodes(nodes);
1082
- addNodes(nodes);
1083
- };
1084
- t2 = [entityRepository, entityRepository.size, ecsFlowRepository, nodeFactory, addNodes];
1085
- $[1] = addNodes;
1086
- $[2] = ecsFlowRepository;
1087
- $[3] = entityRepository;
1088
- $[4] = nodeFactory;
1089
- $[5] = t1;
1090
- $[6] = t2;
1091
- } else {
1092
- t1 = $[5];
1093
- t2 = $[6];
1094
- }
1095
- useEffect4(t1, t2);
1096
- let t3;
1097
- if ($[7] !== entityNodes) {
1098
- t3 = /* @__PURE__ */ jsxs9(Fragment6, { children: [
1099
- /* @__PURE__ */ jsx15(flow_ecs_edge_proxies_default, { nodesToConnect: entityNodes }),
1100
- /* @__PURE__ */ jsx15(flow_ecs_edge_modules_default, { nodesToConnect: entityNodes })
1101
- ] });
1102
- $[7] = entityNodes;
1103
- $[8] = t3;
1104
- } else {
1105
- t3 = $[8];
1106
- }
1107
- return t3;
1108
- }
1109
- function _temp9(state) {
1110
- return state.addNodes;
448
+ const { nodeFactory } = useContext(FlowContext);
449
+ const addNodes = useFlowStore((state) => state.addNodes);
450
+ const { ecsFlowRepository, entityRepository } = useContext(EcsFlowContext);
451
+ const [entityNodes, setEntityNodes] = useState([]);
452
+ useEffect(() => {
453
+ const entities = entityRepository.listAll();
454
+ const nodes = [];
455
+ for (const entity of entities) {
456
+ if (ecsFlowRepository.getEntityNode(entity.myProxy)) continue;
457
+ const node = nodeFactory.createNodeFromType(EcsNodeType.entity);
458
+ node.data.entity = entity.myProxy;
459
+ node.position = {
460
+ x: 0,
461
+ y: 0
462
+ };
463
+ ecsFlowRepository.addEntityNode(node);
464
+ nodes.push(node);
465
+ }
466
+ setEntityNodes(nodes);
467
+ addNodes(nodes);
468
+ }, [
469
+ entityRepository,
470
+ entityRepository.size,
471
+ ecsFlowRepository,
472
+ nodeFactory,
473
+ addNodes
474
+ ]);
475
+ return /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsx(flow_ecs_edge_proxies_default, { nodesToConnect: entityNodes }), /* @__PURE__ */ jsx(flow_ecs_edge_modules_default, { nodesToConnect: entityNodes })] });
1111
476
  }
1112
477
  var flow_ecs_entities_default = FlowEcsEntities;
1113
478
 
1114
- // src/flow/flow-ecs-modules.tsx
1115
- import { c as _c16 } from "react/compiler-runtime";
1116
- import { FlowContext as FlowContext2 } from "@awesome-flow/core/abstract";
1117
- import { useFlowStore as useFlowStore4 } from "@awesome-flow/core/hooks";
1118
- import { useContext as useContext8, useEffect as useEffect5 } from "react";
1119
- import { Fragment as Fragment7, jsx as jsx16 } from "react/jsx-runtime";
479
+ //#endregion
480
+ //#region src/flow/flow-ecs-modules.tsx
1120
481
  function FlowEcsModules() {
1121
- const $ = _c16(7);
1122
- const {
1123
- nodeFactory
1124
- } = useContext8(FlowContext2);
1125
- const addNodes = useFlowStore4(_temp10);
1126
- const {
1127
- ecsFlowRepository,
1128
- systemsModuleRepository
1129
- } = useContext8(EcsFlowContext);
1130
- let t0;
1131
- let t1;
1132
- if ($[0] !== addNodes || $[1] !== ecsFlowRepository || $[2] !== nodeFactory || $[3] !== systemsModuleRepository) {
1133
- t0 = () => {
1134
- const modules = Array.from(systemsModuleRepository.list()).filter(_temp24);
1135
- const keys = Array.from(modules.values()).map(_temp34);
1136
- const nodesToAdd = [];
1137
- for (const element of keys) {
1138
- if (ecsFlowRepository.getSystemModuleNode(element)) {
1139
- continue;
1140
- }
1141
- const node = nodeFactory.createNodeFromType("systems-module-node" /* systemsModule */);
1142
- node.data.entityType = element;
1143
- node.position = {
1144
- x: 0,
1145
- y: 0
1146
- };
1147
- ecsFlowRepository.addSystemModuleNode(node);
1148
- nodesToAdd.push(node);
1149
- }
1150
- if (nodesToAdd.length) {
1151
- addNodes(nodesToAdd);
1152
- }
1153
- };
1154
- t1 = [nodeFactory, addNodes, ecsFlowRepository, ecsFlowRepository.sizeNodes, systemsModuleRepository, systemsModuleRepository.size];
1155
- $[0] = addNodes;
1156
- $[1] = ecsFlowRepository;
1157
- $[2] = nodeFactory;
1158
- $[3] = systemsModuleRepository;
1159
- $[4] = t0;
1160
- $[5] = t1;
1161
- } else {
1162
- t0 = $[4];
1163
- t1 = $[5];
1164
- }
1165
- useEffect5(t0, t1);
1166
- let t2;
1167
- if ($[6] === Symbol.for("react.memo_cache_sentinel")) {
1168
- t2 = /* @__PURE__ */ jsx16(Fragment7, {});
1169
- $[6] = t2;
1170
- } else {
1171
- t2 = $[6];
1172
- }
1173
- return t2;
1174
- }
1175
- function _temp34(v) {
1176
- return v[0];
1177
- }
1178
- function _temp24(m) {
1179
- return !!m;
1180
- }
1181
- function _temp10(state) {
1182
- return state.addNodes;
482
+ const { nodeFactory } = useContext(FlowContext);
483
+ const addNodes = useFlowStore((state) => state.addNodes);
484
+ const { ecsFlowRepository, systemsModuleRepository } = useContext(EcsFlowContext);
485
+ useEffect(() => {
486
+ const modules = Array.from(systemsModuleRepository.list()).filter((m) => !!m);
487
+ const keys = Array.from(modules.values()).map((v) => v[0]);
488
+ const nodesToAdd = [];
489
+ for (const element of keys) {
490
+ if (ecsFlowRepository.getSystemModuleNode(element)) continue;
491
+ const node = nodeFactory.createNodeFromType(EcsNodeType.systemsModule);
492
+ node.data.entityType = element;
493
+ node.position = {
494
+ x: 0,
495
+ y: 0
496
+ };
497
+ ecsFlowRepository.addSystemModuleNode(node);
498
+ nodesToAdd.push(node);
499
+ }
500
+ if (nodesToAdd.length) addNodes(nodesToAdd);
501
+ }, [
502
+ nodeFactory,
503
+ addNodes,
504
+ ecsFlowRepository,
505
+ ecsFlowRepository.sizeNodes,
506
+ systemsModuleRepository,
507
+ systemsModuleRepository.size
508
+ ]);
509
+ return /* @__PURE__ */ jsx(Fragment, {});
1183
510
  }
1184
511
  var flow_ecs_modules_default = FlowEcsModules;
1185
512
 
1186
- // src/flow/flow-ecs-state.tsx
1187
- import { Fragment as Fragment8, jsx as jsx17, jsxs as jsxs10 } from "react/jsx-runtime";
513
+ //#endregion
514
+ //#region src/flow/flow-ecs-state.tsx
1188
515
  function FlowEcsState(props) {
1189
- const $ = _c17(17);
1190
- const [, setUpdates] = useState3(0);
1191
- const [refreshLayout, setRefreshLayout] = useState3(false);
1192
- const {
1193
- ecsFlowRepository
1194
- } = useContext9(EcsFlowContext);
1195
- let t0;
1196
- if ($[0] === Symbol.for("react.memo_cache_sentinel")) {
1197
- t0 = () => {
1198
- setRefreshLayout(true);
1199
- };
1200
- $[0] = t0;
1201
- } else {
1202
- t0 = $[0];
1203
- }
1204
- let t1;
1205
- if ($[1] !== ecsFlowRepository.sizeNodes) {
1206
- t1 = [ecsFlowRepository.sizeNodes];
1207
- $[1] = ecsFlowRepository.sizeNodes;
1208
- $[2] = t1;
1209
- } else {
1210
- t1 = $[2];
1211
- }
1212
- useEffect6(t0, t1);
1213
- let t2;
1214
- if ($[3] !== setUpdates) {
1215
- t2 = () => {
1216
- setInterval(() => {
1217
- setUpdates(_temp11);
1218
- }, 1e3);
1219
- };
1220
- $[3] = setUpdates;
1221
- $[4] = t2;
1222
- } else {
1223
- t2 = $[4];
1224
- }
1225
- let t3;
1226
- if ($[5] === Symbol.for("react.memo_cache_sentinel")) {
1227
- t3 = [];
1228
- $[5] = t3;
1229
- } else {
1230
- t3 = $[5];
1231
- }
1232
- useEffect6(t2, t3);
1233
- let t4;
1234
- if ($[6] !== props.showSystemModules) {
1235
- t4 = props.showSystemModules && /* @__PURE__ */ jsx17(flow_ecs_modules_default, {});
1236
- $[6] = props.showSystemModules;
1237
- $[7] = t4;
1238
- } else {
1239
- t4 = $[7];
1240
- }
1241
- let t5;
1242
- if ($[8] !== props.showEntities) {
1243
- t5 = props.showEntities && /* @__PURE__ */ jsx17(flow_ecs_entities_default, {});
1244
- $[8] = props.showEntities;
1245
- $[9] = t5;
1246
- } else {
1247
- t5 = $[9];
1248
- }
1249
- let t6;
1250
- if ($[10] !== props.autoLayout || $[11] !== refreshLayout) {
1251
- t6 = props.autoLayout && /* @__PURE__ */ jsx17(FlowAutoLayout, { refreshLayout });
1252
- $[10] = props.autoLayout;
1253
- $[11] = refreshLayout;
1254
- $[12] = t6;
1255
- } else {
1256
- t6 = $[12];
1257
- }
1258
- let t7;
1259
- if ($[13] !== t4 || $[14] !== t5 || $[15] !== t6) {
1260
- t7 = /* @__PURE__ */ jsxs10(Fragment8, { children: [
1261
- t4,
1262
- t5,
1263
- t6
1264
- ] });
1265
- $[13] = t4;
1266
- $[14] = t5;
1267
- $[15] = t6;
1268
- $[16] = t7;
1269
- } else {
1270
- t7 = $[16];
1271
- }
1272
- return t7;
1273
- }
1274
- function _temp11(updates) {
1275
- return updates + 1;
1276
- }
1277
- var flow_ecs_state_default = memo9(FlowEcsState);
1278
- export {
1279
- EcsFlowContext,
1280
- EcsFlowRepository,
1281
- EcsHandleDataType,
1282
- EcsNodeType,
1283
- EcsTemplateGroup,
1284
- node_entity_default as EntityNode,
1285
- EntityNodeTemplate,
1286
- flow_ecs_state_default as FlowEcsState,
1287
- node_systems_module_default as SystemsModuleNode,
1288
- SystemsModuleNodeTemplate,
1289
- ecsNodeTemplates,
1290
- ecsNodeTypes
1291
- };
516
+ const [, setUpdates] = useState(0);
517
+ const [refreshLayout, setRefreshLayout] = useState(false);
518
+ const { ecsFlowRepository } = useContext(EcsFlowContext);
519
+ useEffect(() => {
520
+ setRefreshLayout(true);
521
+ }, [ecsFlowRepository.sizeNodes]);
522
+ useEffect(() => {
523
+ setInterval(() => {
524
+ setUpdates((updates) => updates + 1);
525
+ }, 1e3);
526
+ }, []);
527
+ return /* @__PURE__ */ jsxs(Fragment, { children: [
528
+ props.showSystemModules && /* @__PURE__ */ jsx(flow_ecs_modules_default, {}),
529
+ props.showEntities && /* @__PURE__ */ jsx(flow_ecs_entities_default, {}),
530
+ props.autoLayout && /* @__PURE__ */ jsx(FlowAutoLayout, { refreshLayout })
531
+ ] });
532
+ }
533
+ var flow_ecs_state_default = memo(FlowEcsState);
534
+
535
+ //#endregion
536
+ export { EcsFlowContext, EcsFlowRepository, EcsHandleDataType, EcsNodeType, EcsTemplateGroup, node_entity_default as EntityNode, EntityNodeTemplate, flow_ecs_state_default as FlowEcsState, node_systems_module_default as SystemsModuleNode, SystemsModuleNodeTemplate, ecsNodeTemplates, ecsNodeTypes };
537
+ //# sourceMappingURL=index.js.map