@awesome-flow/ecs 0.9.3 → 0.9.4

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,534 @@
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 proxies = Array.from(props.entity.proxies.values()).map((c) => c.values());
131
+ const items = proxies.map((p) => Array.from(p).map((k) => EcsIdGenerator.entityProxy(k))).flat();
132
+ return /* @__PURE__ */ jsxs(Accordion.Item, {
133
+ value: "proxies",
134
+ children: [/* @__PURE__ */ jsx(Accordion.Control, { children: /* @__PURE__ */ jsx(Badge, {
135
+ fullWidth: true,
136
+ variant: "light",
137
+ rightSection: items.length,
138
+ children: "Proxies"
139
+ }) }), /* @__PURE__ */ jsx(Accordion.Panel, { children: /* @__PURE__ */ jsx(Stack, { children: /* @__PURE__ */ jsx(badge_list_default, {
140
+ items,
141
+ badge: { variant: "outline" }
142
+ }) }) })]
143
+ }, "proxies");
144
+ }
145
+ var entity_proxy_list_default = memo(EntityProxyList);
146
+
147
+ //#endregion
148
+ //#region src/components/entity-subscription-list.tsx
299
149
  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";
150
+ const { entityEventsManager } = useContext(EcsFlowContext);
151
+ const subscriptions = entityEventsManager.getSubscriptionsForEntity(props.entity.myProxy);
152
+ return /* @__PURE__ */ jsxs(Accordion.Item, {
153
+ value: "subscriptions",
154
+ children: [/* @__PURE__ */ jsx(Accordion.Control, { children: /* @__PURE__ */ jsx(Badge, {
155
+ fullWidth: true,
156
+ variant: "light",
157
+ rightSection: subscriptions.length,
158
+ children: "Events"
159
+ }) }), /* @__PURE__ */ jsx(Accordion.Panel, { children: /* @__PURE__ */ jsx(Stack, { children: /* @__PURE__ */ jsx(badge_list_default, {
160
+ items: subscriptions,
161
+ badge: { variant: "outline" }
162
+ }) }) })]
163
+ }, "subscriptions");
164
+ }
165
+ var entity_subscription_list_default = memo(EntitySubscriptionList);
166
+
167
+ //#endregion
168
+ //#region src/components/entity-update-counter.tsx
360
169
  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;
170
+ const [, setRefresh] = useState(0);
171
+ const { entityUpdateCounter } = useContext(EcsFlowContext);
172
+ const updates = entityUpdateCounter.getUpdateCount(props.entityUid) || 0;
173
+ const removes = entityUpdateCounter.getRemoveCount(props.entityUid) || 0;
174
+ useEffect(() => {
175
+ const interval = setInterval(() => {
176
+ setRefresh((refresh) => refresh + 1);
177
+ }, 1e3);
178
+ return () => {
179
+ console.log("CLEAR INTERVAL");
180
+ clearInterval(interval);
181
+ };
182
+ }, []);
183
+ return /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsx(Badge, {
184
+ variant: "light",
185
+ children: updates
186
+ }), /* @__PURE__ */ jsx(Badge, {
187
+ variant: "light",
188
+ color: "orange",
189
+ children: removes
190
+ })] });
191
+ }
192
+ var entity_update_counter_default = memo(EntityUpdateCounter);
193
+
194
+ //#endregion
195
+ //#region src/layout/entity-layout.tsx
196
+ function EntityLayout({ entity }) {
197
+ return /* @__PURE__ */ jsxs(Fragment, { children: [
198
+ /* @__PURE__ */ jsxs(Group, { children: [/* @__PURE__ */ jsx(Badge, {
199
+ variant: "outline",
200
+ color: "orange",
201
+ children: entity.myProxy.entityUid
202
+ }), /* @__PURE__ */ jsx(entity_update_counter_default, { entityUid: entity.myProxy.entityUid })] }),
203
+ /* @__PURE__ */ jsx(Divider, { my: 5 }),
204
+ /* @__PURE__ */ jsxs(Accordion, { children: [
205
+ /* @__PURE__ */ jsx(entity_component_list_default, { entity }),
206
+ /* @__PURE__ */ jsx(entity_proxy_list_default, { entity }),
207
+ /* @__PURE__ */ jsx(entity_subscription_list_default, { entity })
208
+ ] })
209
+ ] });
496
210
  }
497
211
  var entity_layout_default = EntityLayout;
498
212
 
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;
213
+ //#endregion
214
+ //#region src/nodes/node-entity.tsx
215
+ function EntityNode({ id, data, selected, type }) {
216
+ const { entityRepository } = useContext(EcsFlowContext);
217
+ const entity = useMemo(() => entityRepository.get(data.entity), [data.entity, entityRepository]);
218
+ return /* @__PURE__ */ jsx(NodeContainer, {
219
+ id,
220
+ selected,
221
+ data,
222
+ title: /* @__PURE__ */ jsx(Badge, {
223
+ fullWidth: true,
224
+ variant: "transparent",
225
+ children: /* @__PURE__ */ jsx(formatter_camel_case_default, { value: entity.myProxy.entityType })
226
+ }),
227
+ type,
228
+ children: /* @__PURE__ */ jsx(entity_layout_default, { entity })
229
+ });
554
230
  }
555
231
  var node_entity_default = EntityNode;
556
232
 
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";
233
+ //#endregion
234
+ //#region src/components/pipeline-middleware-list.tsx
572
235
  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;
236
+ let middleware = [];
237
+ if (props.pipeline) middleware = props.pipeline["middleware"];
238
+ const components = middleware.map((m) => {
239
+ return m.name || m.constructor.name;
240
+ });
241
+ return /* @__PURE__ */ jsxs(Accordion.Item, {
242
+ value: props.label,
243
+ children: [/* @__PURE__ */ jsx(Accordion.Control, { children: /* @__PURE__ */ jsx(Badge, {
244
+ fullWidth: true,
245
+ variant: "light",
246
+ rightSection: components.length,
247
+ children: props.label
248
+ }) }), /* @__PURE__ */ jsx(Accordion.Panel, { children: /* @__PURE__ */ jsx(Stack, { children: /* @__PURE__ */ jsx(badge_list_default, {
249
+ items: components,
250
+ badge: { variant: "outline" }
251
+ }) }) })]
252
+ }, props.label);
637
253
  }
638
254
  var pipeline_middleware_list_default = PipelineMiddlewareList;
639
255
 
640
- // src/layout/systems-module-layout.tsx
641
- import { Fragment as Fragment3, jsx as jsx11, jsxs as jsxs8 } from "react/jsx-runtime";
256
+ //#endregion
257
+ //#region src/layout/systems-module-layout.tsx
642
258
  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;
259
+ const { module } = props;
260
+ const runtimeContext = module["runtimeContext"];
261
+ const { systemContext } = runtimeContext;
262
+ const { status } = useMemo(() => {
263
+ return systemContext.runtime;
264
+ }, [systemContext.runtime]);
265
+ const init = runtimeContext.systemPipelines.get(SystemType.initialize);
266
+ const update = runtimeContext.systemPipelines.get(SystemType.update);
267
+ const render = runtimeContext.systemPipelines.get(SystemType.render);
268
+ const sync = runtimeContext.systemPipelines.get(SystemType.sync);
269
+ return /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsxs(Text, { children: ["Status: ", status] }), /* @__PURE__ */ jsxs(Accordion, { children: [
270
+ init && /* @__PURE__ */ jsx(pipeline_middleware_list_default, {
271
+ pipeline: init,
272
+ label: "Initialize"
273
+ }),
274
+ update && /* @__PURE__ */ jsx(pipeline_middleware_list_default, {
275
+ pipeline: update,
276
+ label: "Update"
277
+ }),
278
+ render && /* @__PURE__ */ jsx(pipeline_middleware_list_default, {
279
+ pipeline: render,
280
+ label: "Render"
281
+ }),
282
+ sync && /* @__PURE__ */ jsx(pipeline_middleware_list_default, {
283
+ pipeline: sync,
284
+ label: "Sync"
285
+ })
286
+ ] })] });
764
287
  }
765
288
  var systems_module_layout_default = SystemsModuleLayout;
766
289
 
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;
290
+ //#endregion
291
+ //#region src/nodes/node-systems-module.tsx
292
+ function SystemsModuleNode({ id, data, selected, type }) {
293
+ const { systemsModuleRepository } = useContext(EcsFlowContext);
294
+ const module = systemsModuleRepository.get(data.entityType);
295
+ return /* @__PURE__ */ jsx(NodeContainer, {
296
+ id,
297
+ selected,
298
+ data,
299
+ title: /* @__PURE__ */ jsx(Badge, {
300
+ fullWidth: true,
301
+ color: "indigo",
302
+ variant: "transparent",
303
+ children: /* @__PURE__ */ jsx(formatter_camel_case_default, { value: data.entityType })
304
+ }),
305
+ type,
306
+ children: /* @__PURE__ */ jsx(systems_module_layout_default, {
307
+ type: data.entityType,
308
+ module
309
+ })
310
+ });
821
311
  }
822
312
  var node_systems_module_default = SystemsModuleNode;
823
313
 
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 || {});
314
+ //#endregion
315
+ //#region src/abstract/templates.ts
316
+ let EcsTemplateGroup = /* @__PURE__ */ function(EcsTemplateGroup$1) {
317
+ EcsTemplateGroup$1["ecs"] = "ECS";
318
+ return EcsTemplateGroup$1;
319
+ }({});
832
320
 
833
- // src/templates/template-entity-node.ts
321
+ //#endregion
322
+ //#region src/templates/template-entity-node.ts
834
323
  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
- };
324
+ template = {
325
+ type: EcsNodeType.entity,
326
+ group: EcsTemplateGroup.ecs,
327
+ data: {
328
+ title: "Entity",
329
+ entity: null
330
+ },
331
+ handles: [{
332
+ dataType: EcsHandleDataType.proxy,
333
+ position: Position.Left,
334
+ connection: "target",
335
+ disabled: true
336
+ }, {
337
+ dataType: EcsHandleDataType.proxy,
338
+ position: Position.Right,
339
+ connection: "source",
340
+ disabled: true
341
+ }]
342
+ };
857
343
  };
858
344
 
859
- // src/templates/template-systems-module.ts
860
- import { Position as Position2 } from "@xyflow/react";
345
+ //#endregion
346
+ //#region src/templates/template-systems-module.ts
861
347
  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
- };
348
+ template = {
349
+ type: EcsNodeType.systemsModule,
350
+ group: EcsTemplateGroup.ecs,
351
+ data: {
352
+ title: "Systems Module",
353
+ entityType: null
354
+ },
355
+ handles: [{
356
+ dataType: EcsHandleDataType.module,
357
+ position: Position.Left,
358
+ connection: "target",
359
+ disabled: true
360
+ }]
361
+ };
878
362
  };
879
363
 
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
364
+ //#endregion
365
+ //#region src/abstract/node-types.ts
366
+ let EcsNodeType = /* @__PURE__ */ function(EcsNodeType$1) {
367
+ EcsNodeType$1["systemsModule"] = "systems-module-node";
368
+ EcsNodeType$1["entity"] = "entity-node";
369
+ return EcsNodeType$1;
370
+ }({});
371
+ const ecsNodeTypes = {
372
+ [EcsNodeType.systemsModule]: node_systems_module_default,
373
+ [EcsNodeType.entity]: node_entity_default
889
374
  };
890
- var ecsNodeTemplates = {
891
- ["entity-node" /* entity */]: new EntityNodeTemplate(),
892
- ["systems-module-node" /* systemsModule */]: new SystemsModuleNodeTemplate()
375
+ const ecsNodeTemplates = {
376
+ [EcsNodeType.entity]: new EntityNodeTemplate(),
377
+ [EcsNodeType.systemsModule]: new SystemsModuleNodeTemplate()
893
378
  };
894
379
 
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";
380
+ //#endregion
381
+ //#region src/flow/flow-ecs-edge-modules.tsx
911
382
  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;
383
+ const { nodesToConnect } = props;
384
+ const onConnect = useFlowStore((state) => state.onConnect);
385
+ const { ecsFlowRepository, entityRepository } = useContext(EcsFlowContext);
386
+ useEffect(() => {
387
+ for (const node of nodesToConnect) {
388
+ const sourceHandle = node.data.handles.find((h) => h.connection === "source");
389
+ const entity = entityRepository.get(node.data.entity);
390
+ const systemModule = ecsFlowRepository.getSystemModuleNode(entity.myProxy.entityType);
391
+ const targetHandle = systemModule?.data.handles.find((h) => h.connection === "target");
392
+ if (targetHandle) onConnect({
393
+ source: node.id,
394
+ target: systemModule.id,
395
+ sourceHandle: sourceHandle.handleId,
396
+ targetHandle: targetHandle.handleId
397
+ });
398
+ }
399
+ }, [
400
+ nodesToConnect,
401
+ ecsFlowRepository,
402
+ entityRepository,
403
+ onConnect
404
+ ]);
405
+ return /* @__PURE__ */ jsx(Fragment, {});
969
406
  }
970
407
  var flow_ecs_edge_modules_default = FlowEcsEdgeModules;
971
408
 
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";
409
+ //#endregion
410
+ //#region src/flow/flow-ecs-edge-proxies.tsx
977
411
  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;
412
+ const { nodesToConnect } = props;
413
+ const onConnect = useFlowStore((state) => state.onConnect);
414
+ const { ecsFlowRepository, entityRepository } = useContext(EcsFlowContext);
415
+ useEffect(() => {
416
+ for (const node of nodesToConnect) {
417
+ const sourceHandle = node.data.handles.find((h) => h.connection === "source");
418
+ const entity = entityRepository.get(node.data.entity);
419
+ for (const [, proxyMap] of entity.proxies) for (const proxy of proxyMap.values()) {
420
+ const proxyNode = ecsFlowRepository.getEntityNode(proxy);
421
+ if (proxyNode) {
422
+ const targetHandle = proxyNode.data.handles.find((h) => h.connection === "target");
423
+ onConnect({
424
+ source: node.id,
425
+ target: proxyNode.id,
426
+ sourceHandle: sourceHandle.handleId,
427
+ targetHandle: targetHandle.handleId
428
+ });
429
+ }
430
+ }
431
+ }
432
+ }, [
433
+ nodesToConnect,
434
+ ecsFlowRepository,
435
+ entityRepository,
436
+ onConnect
437
+ ]);
438
+ return /* @__PURE__ */ jsx(Fragment, {});
1039
439
  }
1040
440
  var flow_ecs_edge_proxies_default = FlowEcsEdgeProxies;
1041
441
 
1042
- // src/flow/flow-ecs-entities.tsx
1043
- import { Fragment as Fragment6, jsx as jsx15, jsxs as jsxs9 } from "react/jsx-runtime";
442
+ //#endregion
443
+ //#region src/flow/flow-ecs-entities.tsx
1044
444
  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;
445
+ const { nodeFactory } = useContext(FlowContext);
446
+ const addNodes = useFlowStore((state) => state.addNodes);
447
+ const { ecsFlowRepository, entityRepository } = useContext(EcsFlowContext);
448
+ const [entityNodes, setEntityNodes] = useState([]);
449
+ useEffect(() => {
450
+ const entities = entityRepository.listAll();
451
+ const nodes = [];
452
+ for (const entity of entities) {
453
+ if (ecsFlowRepository.getEntityNode(entity.myProxy)) continue;
454
+ const node = nodeFactory.createNodeFromType(EcsNodeType.entity);
455
+ node.data.entity = entity.myProxy;
456
+ node.position = {
457
+ x: 0,
458
+ y: 0
459
+ };
460
+ ecsFlowRepository.addEntityNode(node);
461
+ nodes.push(node);
462
+ }
463
+ setEntityNodes(nodes);
464
+ addNodes(nodes);
465
+ }, [
466
+ entityRepository,
467
+ entityRepository.size,
468
+ ecsFlowRepository,
469
+ nodeFactory,
470
+ addNodes
471
+ ]);
472
+ return /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsx(flow_ecs_edge_proxies_default, { nodesToConnect: entityNodes }), /* @__PURE__ */ jsx(flow_ecs_edge_modules_default, { nodesToConnect: entityNodes })] });
1111
473
  }
1112
474
  var flow_ecs_entities_default = FlowEcsEntities;
1113
475
 
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";
476
+ //#endregion
477
+ //#region src/flow/flow-ecs-modules.tsx
1120
478
  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;
479
+ const { nodeFactory } = useContext(FlowContext);
480
+ const addNodes = useFlowStore((state) => state.addNodes);
481
+ const { ecsFlowRepository, systemsModuleRepository } = useContext(EcsFlowContext);
482
+ useEffect(() => {
483
+ const modules = Array.from(systemsModuleRepository.list()).filter((m) => !!m);
484
+ const keys = Array.from(modules.values()).map((v) => v[0]);
485
+ const nodesToAdd = [];
486
+ for (const element of keys) {
487
+ if (ecsFlowRepository.getSystemModuleNode(element)) continue;
488
+ const node = nodeFactory.createNodeFromType(EcsNodeType.systemsModule);
489
+ node.data.entityType = element;
490
+ node.position = {
491
+ x: 0,
492
+ y: 0
493
+ };
494
+ ecsFlowRepository.addSystemModuleNode(node);
495
+ nodesToAdd.push(node);
496
+ }
497
+ if (nodesToAdd.length) addNodes(nodesToAdd);
498
+ }, [
499
+ nodeFactory,
500
+ addNodes,
501
+ ecsFlowRepository,
502
+ ecsFlowRepository.sizeNodes,
503
+ systemsModuleRepository,
504
+ systemsModuleRepository.size
505
+ ]);
506
+ return /* @__PURE__ */ jsx(Fragment, {});
1183
507
  }
1184
508
  var flow_ecs_modules_default = FlowEcsModules;
1185
509
 
1186
- // src/flow/flow-ecs-state.tsx
1187
- import { Fragment as Fragment8, jsx as jsx17, jsxs as jsxs10 } from "react/jsx-runtime";
510
+ //#endregion
511
+ //#region src/flow/flow-ecs-state.tsx
1188
512
  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
- };
513
+ const [, setUpdates] = useState(0);
514
+ const [refreshLayout, setRefreshLayout] = useState(false);
515
+ const { ecsFlowRepository } = useContext(EcsFlowContext);
516
+ useEffect(() => {
517
+ setRefreshLayout(true);
518
+ }, [ecsFlowRepository.sizeNodes]);
519
+ useEffect(() => {
520
+ setInterval(() => {
521
+ setUpdates((updates) => updates + 1);
522
+ }, 1e3);
523
+ }, []);
524
+ return /* @__PURE__ */ jsxs(Fragment, { children: [
525
+ props.showSystemModules && /* @__PURE__ */ jsx(flow_ecs_modules_default, {}),
526
+ props.showEntities && /* @__PURE__ */ jsx(flow_ecs_entities_default, {}),
527
+ props.autoLayout && /* @__PURE__ */ jsx(FlowAutoLayout, { refreshLayout })
528
+ ] });
529
+ }
530
+ var flow_ecs_state_default = memo(FlowEcsState);
531
+
532
+ //#endregion
533
+ 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 };
534
+ //# sourceMappingURL=index.js.map