@awesome-flow/ecs 0.6.0 → 0.7.1
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.cjs +1 -564
- package/dist/index.d.cts +8 -8
- package/dist/index.d.ts +8 -8
- package/dist/index.js +1 -527
- package/package.json +8 -7
- package/dist/index.cjs.map +0 -1
- package/dist/index.js.map +0 -1
package/dist/index.cjs
CHANGED
|
@@ -1,564 +1 @@
|
|
|
1
|
-
var __defProp = Object.defineProperty;
|
|
2
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
-
var __export = (target, all) => {
|
|
6
|
-
for (var name in all)
|
|
7
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
8
|
-
};
|
|
9
|
-
var __copyProps = (to, from, except, desc) => {
|
|
10
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
11
|
-
for (let key of __getOwnPropNames(from))
|
|
12
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
13
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
14
|
-
}
|
|
15
|
-
return to;
|
|
16
|
-
};
|
|
17
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
18
|
-
|
|
19
|
-
// src/index.ts
|
|
20
|
-
var src_exports = {};
|
|
21
|
-
__export(src_exports, {
|
|
22
|
-
EcsFlowContext: () => EcsFlowContext,
|
|
23
|
-
EcsFlowRepository: () => EcsFlowRepository,
|
|
24
|
-
EcsHandleDataType: () => EcsHandleDataType,
|
|
25
|
-
EcsNodeType: () => EcsNodeType,
|
|
26
|
-
EcsTemplateGroup: () => EcsTemplateGroup,
|
|
27
|
-
EntityNode: () => node_entity_default,
|
|
28
|
-
EntityNodeTemplate: () => EntityNodeTemplate,
|
|
29
|
-
FlowEcsState: () => flow_ecs_state_default,
|
|
30
|
-
SystemsModuleNode: () => node_systems_module_default,
|
|
31
|
-
SystemsModuleNodeTemplate: () => SystemsModuleNodeTemplate,
|
|
32
|
-
ecsNodeTemplates: () => ecsNodeTemplates,
|
|
33
|
-
ecsNodeTypes: () => ecsNodeTypes
|
|
34
|
-
});
|
|
35
|
-
module.exports = __toCommonJS(src_exports);
|
|
36
|
-
|
|
37
|
-
// src/abstract/ecs-flow-context.ts
|
|
38
|
-
var import_react = require("react");
|
|
39
|
-
var EcsFlowContext = (0, import_react.createContext)(null);
|
|
40
|
-
|
|
41
|
-
// src/utils/id-generator.ts
|
|
42
|
-
var EcsIdGenerator = class {
|
|
43
|
-
static entityProxy(proxy) {
|
|
44
|
-
return `${proxy.entityType}:${proxy.entityUid}`;
|
|
45
|
-
}
|
|
46
|
-
};
|
|
47
|
-
|
|
48
|
-
// src/abstract/ecs-flow-repository.ts
|
|
49
|
-
var EcsFlowRepository = class {
|
|
50
|
-
nodes;
|
|
51
|
-
constructor() {
|
|
52
|
-
this.nodes = /* @__PURE__ */ new Map();
|
|
53
|
-
}
|
|
54
|
-
get sizeNodes() {
|
|
55
|
-
return this.nodes.size;
|
|
56
|
-
}
|
|
57
|
-
addSystemModuleNode(node) {
|
|
58
|
-
this.nodes.set(node.data.entityType.toString(), node);
|
|
59
|
-
}
|
|
60
|
-
getSystemModuleNode(entityType) {
|
|
61
|
-
return this.nodes.get(entityType.toString());
|
|
62
|
-
}
|
|
63
|
-
addEntityNode(node) {
|
|
64
|
-
this.nodes.set(EcsIdGenerator.entityProxy(node.data.entity), node);
|
|
65
|
-
}
|
|
66
|
-
getEntityNode(entity) {
|
|
67
|
-
return this.nodes.get(EcsIdGenerator.entityProxy(entity));
|
|
68
|
-
}
|
|
69
|
-
listAllNodes() {
|
|
70
|
-
return Array.from(this.nodes.values());
|
|
71
|
-
}
|
|
72
|
-
};
|
|
73
|
-
|
|
74
|
-
// src/abstract/handle-types.ts
|
|
75
|
-
var EcsHandleDataType = /* @__PURE__ */ ((EcsHandleDataType2) => {
|
|
76
|
-
EcsHandleDataType2["proxy"] = "proxy";
|
|
77
|
-
EcsHandleDataType2["module"] = "module";
|
|
78
|
-
return EcsHandleDataType2;
|
|
79
|
-
})(EcsHandleDataType || {});
|
|
80
|
-
|
|
81
|
-
// src/nodes/node-systems-module.tsx
|
|
82
|
-
var import_layout = require("@awesome-flow/core/layout");
|
|
83
|
-
var import_react5 = require("react");
|
|
84
|
-
var import_core4 = require("@mantine/core");
|
|
85
|
-
|
|
86
|
-
// src/layout/systems-module-layout.tsx
|
|
87
|
-
var import_systems = require("@awesome-ecs/abstract/systems");
|
|
88
|
-
var import_core3 = require("@mantine/core");
|
|
89
|
-
var import_react4 = require("react");
|
|
90
|
-
|
|
91
|
-
// src/components/pipeline-middleware-list.tsx
|
|
92
|
-
var import_core2 = require("@mantine/core");
|
|
93
|
-
|
|
94
|
-
// src/components/badge-list.tsx
|
|
95
|
-
var import_core = require("@mantine/core");
|
|
96
|
-
var import_react3 = require("react");
|
|
97
|
-
|
|
98
|
-
// src/components/formatter-camel-case.tsx
|
|
99
|
-
var import_react2 = require("react");
|
|
100
|
-
function CamelCaseFormatter(props) {
|
|
101
|
-
const value = (0, import_react2.useMemo)(
|
|
102
|
-
() => props.value?.toString().replace(/([a-z])([A-Z])/g, "$1 $2"),
|
|
103
|
-
[props.value]
|
|
104
|
-
);
|
|
105
|
-
return value;
|
|
106
|
-
}
|
|
107
|
-
var formatter_camel_case_default = (0, import_react2.memo)(CamelCaseFormatter);
|
|
108
|
-
|
|
109
|
-
// src/components/badge-list.tsx
|
|
110
|
-
var import_jsx_runtime = require("react/jsx-runtime");
|
|
111
|
-
function BadgeList(props) {
|
|
112
|
-
return props.items.map((value, i) => {
|
|
113
|
-
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_core.Badge, { ...props.badge || [], children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(formatter_camel_case_default, { value }) }, i);
|
|
114
|
-
});
|
|
115
|
-
}
|
|
116
|
-
var badge_list_default = (0, import_react3.memo)(BadgeList);
|
|
117
|
-
|
|
118
|
-
// src/components/pipeline-middleware-list.tsx
|
|
119
|
-
var import_jsx_runtime2 = require("react/jsx-runtime");
|
|
120
|
-
function PipelineMiddlewareList(props) {
|
|
121
|
-
let middleware = [];
|
|
122
|
-
if (props.pipeline) {
|
|
123
|
-
middleware = props.pipeline["middleware"];
|
|
124
|
-
}
|
|
125
|
-
const components = middleware.map((m) => {
|
|
126
|
-
return m.name || m.constructor.name;
|
|
127
|
-
});
|
|
128
|
-
return /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(import_core2.Accordion.Item, { value: props.label, children: [
|
|
129
|
-
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_core2.Accordion.Control, { children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_core2.Badge, { fullWidth: true, variant: "light", rightSection: components.length, children: props.label }) }),
|
|
130
|
-
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_core2.Accordion.Panel, { children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_core2.Stack, { children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(badge_list_default, { items: components, badge: { variant: "outline" } }) }) })
|
|
131
|
-
] }, props.label);
|
|
132
|
-
}
|
|
133
|
-
var pipeline_middleware_list_default = PipelineMiddlewareList;
|
|
134
|
-
|
|
135
|
-
// src/layout/systems-module-layout.tsx
|
|
136
|
-
var import_jsx_runtime3 = require("react/jsx-runtime");
|
|
137
|
-
function SystemsModuleLayout(props) {
|
|
138
|
-
const { module: module2 } = props;
|
|
139
|
-
const runtimeContext = module2["runtimeContext"];
|
|
140
|
-
const { systemContext } = runtimeContext;
|
|
141
|
-
const { status } = (0, import_react4.useMemo)(() => {
|
|
142
|
-
return systemContext.runtime;
|
|
143
|
-
}, [systemContext.runtime.status]);
|
|
144
|
-
const init = runtimeContext.systemPipelines.get(import_systems.SystemType.initialize);
|
|
145
|
-
const update = runtimeContext.systemPipelines.get(import_systems.SystemType.update);
|
|
146
|
-
const render = runtimeContext.systemPipelines.get(import_systems.SystemType.render);
|
|
147
|
-
const sync = runtimeContext.systemPipelines.get(import_systems.SystemType.sync);
|
|
148
|
-
return /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(import_jsx_runtime3.Fragment, { children: [
|
|
149
|
-
/* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(import_core3.Text, { children: [
|
|
150
|
-
"Status: ",
|
|
151
|
-
status
|
|
152
|
-
] }),
|
|
153
|
-
/* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(import_core3.Accordion, { children: [
|
|
154
|
-
init && /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(pipeline_middleware_list_default, { pipeline: init, label: "Initialize" }),
|
|
155
|
-
update && /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(pipeline_middleware_list_default, { pipeline: update, label: "Update" }),
|
|
156
|
-
render && /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(pipeline_middleware_list_default, { pipeline: render, label: "Render" }),
|
|
157
|
-
sync && /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(pipeline_middleware_list_default, { pipeline: sync, label: "Sync" })
|
|
158
|
-
] })
|
|
159
|
-
] });
|
|
160
|
-
}
|
|
161
|
-
var systems_module_layout_default = SystemsModuleLayout;
|
|
162
|
-
|
|
163
|
-
// src/nodes/node-systems-module.tsx
|
|
164
|
-
var import_jsx_runtime4 = require("react/jsx-runtime");
|
|
165
|
-
function SystemsModuleNode({ id, data, selected, type }) {
|
|
166
|
-
const { systemsModuleRepository } = (0, import_react5.useContext)(EcsFlowContext);
|
|
167
|
-
const module2 = systemsModuleRepository.get(data.entityType);
|
|
168
|
-
return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
|
|
169
|
-
import_layout.NodeContainer,
|
|
170
|
-
{
|
|
171
|
-
id,
|
|
172
|
-
selected,
|
|
173
|
-
data,
|
|
174
|
-
title: /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(import_core4.Badge, { fullWidth: true, color: "indigo", variant: "transparent", children: /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(formatter_camel_case_default, { value: data.entityType }) }),
|
|
175
|
-
type,
|
|
176
|
-
children: /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(systems_module_layout_default, { type: data.entityType, module: module2 })
|
|
177
|
-
}
|
|
178
|
-
);
|
|
179
|
-
}
|
|
180
|
-
var node_systems_module_default = SystemsModuleNode;
|
|
181
|
-
|
|
182
|
-
// src/nodes/node-entity.tsx
|
|
183
|
-
var import_layout2 = require("@awesome-flow/core/layout");
|
|
184
|
-
var import_core12 = require("@mantine/core");
|
|
185
|
-
var import_react12 = require("react");
|
|
186
|
-
|
|
187
|
-
// src/layout/entity-layout.tsx
|
|
188
|
-
var import_core11 = require("@mantine/core");
|
|
189
|
-
|
|
190
|
-
// src/components/entity-component-list.tsx
|
|
191
|
-
var import_core7 = require("@mantine/core");
|
|
192
|
-
var import_react8 = require("react");
|
|
193
|
-
|
|
194
|
-
// src/components/entity-component-inspector.tsx
|
|
195
|
-
var import_core6 = require("@mantine/core");
|
|
196
|
-
var import_react7 = require("react");
|
|
197
|
-
var import_hooks = require("@mantine/hooks");
|
|
198
|
-
|
|
199
|
-
// src/components/object-inspector.tsx
|
|
200
|
-
var import_core5 = require("@mantine/core");
|
|
201
|
-
var import_react6 = require("react");
|
|
202
|
-
var import_react_inspector = require("react-inspector");
|
|
203
|
-
var import_jsx_runtime5 = require("react/jsx-runtime");
|
|
204
|
-
function ObjectInspector(props) {
|
|
205
|
-
const colorScheme = (0, import_core5.useComputedColorScheme)();
|
|
206
|
-
const theme = (0, import_react6.useMemo)(
|
|
207
|
-
() => colorScheme === "dark" ? "chromeDark" : "chromeLight",
|
|
208
|
-
[colorScheme]
|
|
209
|
-
);
|
|
210
|
-
return /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_react_inspector.Inspector, { table: false, theme, data: props.data });
|
|
211
|
-
}
|
|
212
|
-
var object_inspector_default = (0, import_react6.memo)(ObjectInspector);
|
|
213
|
-
|
|
214
|
-
// src/components/entity-component-inspector.tsx
|
|
215
|
-
var import_jsx_runtime6 = require("react/jsx-runtime");
|
|
216
|
-
function EntityComponentInspector(props) {
|
|
217
|
-
const [opened, { toggle }] = (0, import_hooks.useDisclosure)(false);
|
|
218
|
-
const buttonColor = (0, import_react7.useMemo)(() => opened ? "light" : "indigo", [opened]);
|
|
219
|
-
return /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(import_core6.Box, { children: [
|
|
220
|
-
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)(import_core6.Button, { variant: "outline", size: "xs", onClick: toggle, color: buttonColor, fullWidth: true, children: props.component.componentType }),
|
|
221
|
-
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)(import_core6.Collapse, { in: opened, children: opened && /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(object_inspector_default, { data: props.component }) })
|
|
222
|
-
] });
|
|
223
|
-
}
|
|
224
|
-
var entity_component_inspector_default = (0, import_react7.memo)(EntityComponentInspector);
|
|
225
|
-
|
|
226
|
-
// src/components/entity-component-list.tsx
|
|
227
|
-
var import_jsx_runtime7 = require("react/jsx-runtime");
|
|
228
|
-
function EntityComponentList(props) {
|
|
229
|
-
const components = Array.from(props.entity.components.values());
|
|
230
|
-
return /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(import_core7.Accordion.Item, { value: "components", children: [
|
|
231
|
-
/* @__PURE__ */ (0, import_jsx_runtime7.jsx)(import_core7.Accordion.Control, { children: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(import_core7.Badge, { fullWidth: true, variant: "light", rightSection: components.length, children: "Components" }) }),
|
|
232
|
-
/* @__PURE__ */ (0, import_jsx_runtime7.jsx)(import_core7.Accordion.Panel, { children: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(import_core7.Stack, { children: components.map((c, i) => /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(entity_component_inspector_default, { component: c }, i)) }) })
|
|
233
|
-
] }, "components");
|
|
234
|
-
}
|
|
235
|
-
var entity_component_list_default = (0, import_react8.memo)(EntityComponentList);
|
|
236
|
-
|
|
237
|
-
// src/components/entity-proxy-list.tsx
|
|
238
|
-
var import_core8 = require("@mantine/core");
|
|
239
|
-
var import_react9 = require("react");
|
|
240
|
-
var import_jsx_runtime8 = require("react/jsx-runtime");
|
|
241
|
-
function EntityProxyList(props) {
|
|
242
|
-
const proxies = Array.from(props.entity.proxies.values()).map((c) => c.values());
|
|
243
|
-
const items = proxies.map((p) => Array.from(p).map((k) => EcsIdGenerator.entityProxy(k))).flat();
|
|
244
|
-
return /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(import_core8.Accordion.Item, { value: "proxies", children: [
|
|
245
|
-
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)(import_core8.Accordion.Control, { children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(import_core8.Badge, { fullWidth: true, variant: "light", rightSection: items.length, children: "Proxies" }) }),
|
|
246
|
-
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)(import_core8.Accordion.Panel, { children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(import_core8.Stack, { children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(badge_list_default, { items, badge: { variant: "outline" } }) }) })
|
|
247
|
-
] }, "proxies");
|
|
248
|
-
}
|
|
249
|
-
var entity_proxy_list_default = (0, import_react9.memo)(EntityProxyList);
|
|
250
|
-
|
|
251
|
-
// src/components/entity-subscription-list.tsx
|
|
252
|
-
var import_core9 = require("@mantine/core");
|
|
253
|
-
var import_react10 = require("react");
|
|
254
|
-
var import_jsx_runtime9 = require("react/jsx-runtime");
|
|
255
|
-
function EntitySubscriptionList(props) {
|
|
256
|
-
const { entityEventsManager } = (0, import_react10.useContext)(EcsFlowContext);
|
|
257
|
-
const subscriptions = entityEventsManager.getSubscriptionsForEntity(props.entity.myProxy);
|
|
258
|
-
return /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)(import_core9.Accordion.Item, { value: "subscriptions", children: [
|
|
259
|
-
/* @__PURE__ */ (0, import_jsx_runtime9.jsx)(import_core9.Accordion.Control, { children: /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(import_core9.Badge, { fullWidth: true, variant: "light", rightSection: subscriptions.length, children: "Events" }) }),
|
|
260
|
-
/* @__PURE__ */ (0, import_jsx_runtime9.jsx)(import_core9.Accordion.Panel, { children: /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(import_core9.Stack, { children: /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(badge_list_default, { items: subscriptions, badge: { variant: "outline" } }) }) })
|
|
261
|
-
] }, "subscriptions");
|
|
262
|
-
}
|
|
263
|
-
var entity_subscription_list_default = (0, import_react10.memo)(EntitySubscriptionList);
|
|
264
|
-
|
|
265
|
-
// src/components/entity-update-counter.tsx
|
|
266
|
-
var import_core10 = require("@mantine/core");
|
|
267
|
-
var import_react11 = require("react");
|
|
268
|
-
var import_jsx_runtime10 = require("react/jsx-runtime");
|
|
269
|
-
function EntityUpdateCounter(props) {
|
|
270
|
-
const [, setRefresh] = (0, import_react11.useState)(0);
|
|
271
|
-
const { entityUpdateCounter } = (0, import_react11.useContext)(EcsFlowContext);
|
|
272
|
-
const updates = entityUpdateCounter.getUpdateCount(props.entityUid) || 0;
|
|
273
|
-
const removes = entityUpdateCounter.getRemoveCount(props.entityUid) || 0;
|
|
274
|
-
(0, import_react11.useEffect)(() => {
|
|
275
|
-
const interval = setInterval(() => {
|
|
276
|
-
setRefresh((refresh) => refresh + 1);
|
|
277
|
-
}, 1e3);
|
|
278
|
-
return () => {
|
|
279
|
-
console.log("CLEAR INTERVAL");
|
|
280
|
-
clearInterval(interval);
|
|
281
|
-
};
|
|
282
|
-
}, []);
|
|
283
|
-
return /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)(import_jsx_runtime10.Fragment, { children: [
|
|
284
|
-
/* @__PURE__ */ (0, import_jsx_runtime10.jsx)(import_core10.Badge, { variant: "light", children: updates }),
|
|
285
|
-
/* @__PURE__ */ (0, import_jsx_runtime10.jsx)(import_core10.Badge, { variant: "light", color: "orange", children: removes })
|
|
286
|
-
] });
|
|
287
|
-
}
|
|
288
|
-
var entity_update_counter_default = (0, import_react11.memo)(EntityUpdateCounter);
|
|
289
|
-
|
|
290
|
-
// src/layout/entity-layout.tsx
|
|
291
|
-
var import_jsx_runtime11 = require("react/jsx-runtime");
|
|
292
|
-
function EntityLayout({ entity }) {
|
|
293
|
-
return /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)(import_jsx_runtime11.Fragment, { children: [
|
|
294
|
-
/* @__PURE__ */ (0, import_jsx_runtime11.jsxs)(import_core11.Group, { children: [
|
|
295
|
-
/* @__PURE__ */ (0, import_jsx_runtime11.jsx)(import_core11.Badge, { variant: "outline", color: "orange", children: entity.myProxy.entityUid }),
|
|
296
|
-
/* @__PURE__ */ (0, import_jsx_runtime11.jsx)(entity_update_counter_default, { entityUid: entity.myProxy.entityUid })
|
|
297
|
-
] }),
|
|
298
|
-
/* @__PURE__ */ (0, import_jsx_runtime11.jsx)(import_core11.Divider, { my: 5 }),
|
|
299
|
-
/* @__PURE__ */ (0, import_jsx_runtime11.jsxs)(import_core11.Accordion, { children: [
|
|
300
|
-
/* @__PURE__ */ (0, import_jsx_runtime11.jsx)(entity_component_list_default, { entity }),
|
|
301
|
-
/* @__PURE__ */ (0, import_jsx_runtime11.jsx)(entity_proxy_list_default, { entity }),
|
|
302
|
-
/* @__PURE__ */ (0, import_jsx_runtime11.jsx)(entity_subscription_list_default, { entity })
|
|
303
|
-
] })
|
|
304
|
-
] });
|
|
305
|
-
}
|
|
306
|
-
var entity_layout_default = EntityLayout;
|
|
307
|
-
|
|
308
|
-
// src/nodes/node-entity.tsx
|
|
309
|
-
var import_jsx_runtime12 = require("react/jsx-runtime");
|
|
310
|
-
function EntityNode({ id, data, selected, type }) {
|
|
311
|
-
const { entityRepository } = (0, import_react12.useContext)(EcsFlowContext);
|
|
312
|
-
const entity = (0, import_react12.useMemo)(() => entityRepository.get(data.entity), [data.entity]);
|
|
313
|
-
return /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
|
|
314
|
-
import_layout2.NodeContainer,
|
|
315
|
-
{
|
|
316
|
-
id,
|
|
317
|
-
selected,
|
|
318
|
-
data,
|
|
319
|
-
title: /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(import_core12.Badge, { fullWidth: true, variant: "transparent", children: /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(formatter_camel_case_default, { value: entity.myProxy.entityType }) }),
|
|
320
|
-
type,
|
|
321
|
-
children: /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(entity_layout_default, { entity })
|
|
322
|
-
}
|
|
323
|
-
);
|
|
324
|
-
}
|
|
325
|
-
var node_entity_default = EntityNode;
|
|
326
|
-
|
|
327
|
-
// src/templates/template-entity-node.ts
|
|
328
|
-
var import_react13 = require("@xyflow/react");
|
|
329
|
-
|
|
330
|
-
// src/abstract/templates.ts
|
|
331
|
-
var EcsTemplateGroup = /* @__PURE__ */ ((EcsTemplateGroup2) => {
|
|
332
|
-
EcsTemplateGroup2["ecs"] = "ECS";
|
|
333
|
-
return EcsTemplateGroup2;
|
|
334
|
-
})(EcsTemplateGroup || {});
|
|
335
|
-
|
|
336
|
-
// src/templates/template-entity-node.ts
|
|
337
|
-
var EntityNodeTemplate = class {
|
|
338
|
-
template = {
|
|
339
|
-
type: "entity-node" /* entity */,
|
|
340
|
-
group: "ECS" /* ecs */,
|
|
341
|
-
data: {
|
|
342
|
-
title: "Entity",
|
|
343
|
-
entity: null
|
|
344
|
-
},
|
|
345
|
-
handles: [
|
|
346
|
-
{
|
|
347
|
-
dataType: "proxy" /* proxy */,
|
|
348
|
-
position: import_react13.Position.Left,
|
|
349
|
-
connection: "target",
|
|
350
|
-
disabled: true
|
|
351
|
-
},
|
|
352
|
-
{
|
|
353
|
-
dataType: "proxy" /* proxy */,
|
|
354
|
-
position: import_react13.Position.Right,
|
|
355
|
-
connection: "source",
|
|
356
|
-
disabled: true
|
|
357
|
-
}
|
|
358
|
-
]
|
|
359
|
-
};
|
|
360
|
-
};
|
|
361
|
-
|
|
362
|
-
// src/templates/template-systems-module.ts
|
|
363
|
-
var import_react14 = require("@xyflow/react");
|
|
364
|
-
var SystemsModuleNodeTemplate = class {
|
|
365
|
-
template = {
|
|
366
|
-
type: "systems-module-node" /* systemsModule */,
|
|
367
|
-
group: "ECS" /* ecs */,
|
|
368
|
-
data: {
|
|
369
|
-
title: "Systems Module",
|
|
370
|
-
entityType: null
|
|
371
|
-
},
|
|
372
|
-
handles: [
|
|
373
|
-
{
|
|
374
|
-
dataType: "module" /* module */,
|
|
375
|
-
position: import_react14.Position.Left,
|
|
376
|
-
connection: "target",
|
|
377
|
-
disabled: true
|
|
378
|
-
}
|
|
379
|
-
]
|
|
380
|
-
};
|
|
381
|
-
};
|
|
382
|
-
|
|
383
|
-
// src/abstract/node-types.ts
|
|
384
|
-
var EcsNodeType = /* @__PURE__ */ ((EcsNodeType2) => {
|
|
385
|
-
EcsNodeType2["systemsModule"] = "systems-module-node";
|
|
386
|
-
EcsNodeType2["entity"] = "entity-node";
|
|
387
|
-
return EcsNodeType2;
|
|
388
|
-
})(EcsNodeType || {});
|
|
389
|
-
var ecsNodeTypes = {
|
|
390
|
-
["systems-module-node" /* systemsModule */]: node_systems_module_default,
|
|
391
|
-
["entity-node" /* entity */]: node_entity_default
|
|
392
|
-
};
|
|
393
|
-
var ecsNodeTemplates = {
|
|
394
|
-
["entity-node" /* entity */]: new EntityNodeTemplate(),
|
|
395
|
-
["systems-module-node" /* systemsModule */]: new SystemsModuleNodeTemplate()
|
|
396
|
-
};
|
|
397
|
-
|
|
398
|
-
// src/flow/flow-ecs-state.tsx
|
|
399
|
-
var import_react19 = require("react");
|
|
400
|
-
|
|
401
|
-
// src/flow/flow-ecs-entities.tsx
|
|
402
|
-
var import_abstract = require("@awesome-flow/core/abstract");
|
|
403
|
-
var import_react17 = require("react");
|
|
404
|
-
var import_hooks4 = require("@awesome-flow/core/hooks");
|
|
405
|
-
|
|
406
|
-
// src/flow/flow-ecs-edge-proxies.tsx
|
|
407
|
-
var import_react15 = require("react");
|
|
408
|
-
var import_hooks2 = require("@awesome-flow/core/hooks");
|
|
409
|
-
var import_jsx_runtime13 = require("react/jsx-runtime");
|
|
410
|
-
function FlowEcsEdgeProxies(props) {
|
|
411
|
-
const { nodesToConnect } = props;
|
|
412
|
-
const onConnect = (0, import_hooks2.useFlowStore)((state) => state.onConnect);
|
|
413
|
-
const { ecsFlowRepository, entityRepository } = (0, import_react15.useContext)(EcsFlowContext);
|
|
414
|
-
(0, import_react15.useEffect)(() => {
|
|
415
|
-
for (const node of nodesToConnect) {
|
|
416
|
-
const sourceHandle = node.data.handles.find((h) => h.connection === "source");
|
|
417
|
-
const entity = entityRepository.get(node.data.entity);
|
|
418
|
-
for (const [, proxyMap] of entity.proxies) {
|
|
419
|
-
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.id,
|
|
427
|
-
targetHandle: targetHandle.id
|
|
428
|
-
});
|
|
429
|
-
}
|
|
430
|
-
}
|
|
431
|
-
}
|
|
432
|
-
}
|
|
433
|
-
}, [nodesToConnect]);
|
|
434
|
-
return /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(import_jsx_runtime13.Fragment, {});
|
|
435
|
-
}
|
|
436
|
-
var flow_ecs_edge_proxies_default = FlowEcsEdgeProxies;
|
|
437
|
-
|
|
438
|
-
// src/flow/flow-ecs-edge-modules.tsx
|
|
439
|
-
var import_react16 = require("react");
|
|
440
|
-
var import_hooks3 = require("@awesome-flow/core/hooks");
|
|
441
|
-
var import_jsx_runtime14 = require("react/jsx-runtime");
|
|
442
|
-
function FlowEcsEdgeModules(props) {
|
|
443
|
-
const { nodesToConnect } = props;
|
|
444
|
-
const onConnect = (0, import_hooks3.useFlowStore)((state) => state.onConnect);
|
|
445
|
-
const { ecsFlowRepository, entityRepository } = (0, import_react16.useContext)(EcsFlowContext);
|
|
446
|
-
(0, import_react16.useEffect)(() => {
|
|
447
|
-
for (const node of nodesToConnect) {
|
|
448
|
-
const sourceHandle = node.data.handles.find((h) => h.connection === "source");
|
|
449
|
-
const entity = entityRepository.get(node.data.entity);
|
|
450
|
-
const systemModule = ecsFlowRepository.getSystemModuleNode(entity.myProxy.entityType);
|
|
451
|
-
const targetHandle = systemModule?.data.handles.find((h) => h.connection === "target");
|
|
452
|
-
if (targetHandle) {
|
|
453
|
-
onConnect({
|
|
454
|
-
source: node.id,
|
|
455
|
-
target: systemModule.id,
|
|
456
|
-
sourceHandle: sourceHandle.id,
|
|
457
|
-
targetHandle: targetHandle.id
|
|
458
|
-
});
|
|
459
|
-
}
|
|
460
|
-
}
|
|
461
|
-
}, [nodesToConnect]);
|
|
462
|
-
return /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(import_jsx_runtime14.Fragment, {});
|
|
463
|
-
}
|
|
464
|
-
var flow_ecs_edge_modules_default = FlowEcsEdgeModules;
|
|
465
|
-
|
|
466
|
-
// src/flow/flow-ecs-entities.tsx
|
|
467
|
-
var import_jsx_runtime15 = require("react/jsx-runtime");
|
|
468
|
-
function FlowEcsEntities() {
|
|
469
|
-
const { nodeFactory } = (0, import_react17.useContext)(import_abstract.FlowContext);
|
|
470
|
-
const addNodes = (0, import_hooks4.useFlowStore)((state) => state.addNodes);
|
|
471
|
-
const { ecsFlowRepository, entityRepository } = (0, import_react17.useContext)(EcsFlowContext);
|
|
472
|
-
const [entityNodes, setEntityNodes] = (0, import_react17.useState)([]);
|
|
473
|
-
(0, import_react17.useEffect)(() => {
|
|
474
|
-
const entities = entityRepository.listAll();
|
|
475
|
-
const nodes = [];
|
|
476
|
-
for (const entity of entities) {
|
|
477
|
-
if (ecsFlowRepository.getEntityNode(entity.myProxy)) {
|
|
478
|
-
continue;
|
|
479
|
-
}
|
|
480
|
-
const node = nodeFactory.createNodeFromType("entity-node" /* entity */);
|
|
481
|
-
node.data.entity = entity.myProxy;
|
|
482
|
-
node.position = { x: 0, y: 0 };
|
|
483
|
-
ecsFlowRepository.addEntityNode(node);
|
|
484
|
-
nodes.push(node);
|
|
485
|
-
}
|
|
486
|
-
setEntityNodes(nodes);
|
|
487
|
-
addNodes(nodes);
|
|
488
|
-
}, [entityRepository.size]);
|
|
489
|
-
return /* @__PURE__ */ (0, import_jsx_runtime15.jsxs)(import_jsx_runtime15.Fragment, { children: [
|
|
490
|
-
/* @__PURE__ */ (0, import_jsx_runtime15.jsx)(flow_ecs_edge_proxies_default, { nodesToConnect: entityNodes }),
|
|
491
|
-
/* @__PURE__ */ (0, import_jsx_runtime15.jsx)(flow_ecs_edge_modules_default, { nodesToConnect: entityNodes })
|
|
492
|
-
] });
|
|
493
|
-
}
|
|
494
|
-
var flow_ecs_entities_default = FlowEcsEntities;
|
|
495
|
-
|
|
496
|
-
// src/flow/flow-ecs-modules.tsx
|
|
497
|
-
var import_react18 = require("react");
|
|
498
|
-
var import_abstract2 = require("@awesome-flow/core/abstract");
|
|
499
|
-
var import_hooks5 = require("@awesome-flow/core/hooks");
|
|
500
|
-
var import_jsx_runtime16 = require("react/jsx-runtime");
|
|
501
|
-
function FlowEcsModules() {
|
|
502
|
-
const { nodeFactory } = (0, import_react18.useContext)(import_abstract2.FlowContext);
|
|
503
|
-
const addNodes = (0, import_hooks5.useFlowStore)((state) => state.addNodes);
|
|
504
|
-
const { ecsFlowRepository, systemsModuleRepository } = (0, import_react18.useContext)(EcsFlowContext);
|
|
505
|
-
(0, import_react18.useEffect)(() => {
|
|
506
|
-
const modules = Array.from(systemsModuleRepository.list()).filter((m) => !!m);
|
|
507
|
-
const keys = Array.from(modules.values()).map((v) => v[0]);
|
|
508
|
-
const nodesToAdd = [];
|
|
509
|
-
for (const element of keys) {
|
|
510
|
-
if (ecsFlowRepository.getSystemModuleNode(element)) {
|
|
511
|
-
continue;
|
|
512
|
-
}
|
|
513
|
-
const node = nodeFactory.createNodeFromType("systems-module-node" /* systemsModule */);
|
|
514
|
-
node.data.entityType = element;
|
|
515
|
-
node.position = { x: 0, y: 0 };
|
|
516
|
-
ecsFlowRepository.addSystemModuleNode(node);
|
|
517
|
-
nodesToAdd.push(node);
|
|
518
|
-
}
|
|
519
|
-
if (nodesToAdd.length) {
|
|
520
|
-
addNodes(nodesToAdd);
|
|
521
|
-
}
|
|
522
|
-
}, [systemsModuleRepository.size]);
|
|
523
|
-
return /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(import_jsx_runtime16.Fragment, {});
|
|
524
|
-
}
|
|
525
|
-
var flow_ecs_modules_default = FlowEcsModules;
|
|
526
|
-
|
|
527
|
-
// src/flow/flow-ecs-state.tsx
|
|
528
|
-
var import_canvas = require("@awesome-flow/core/canvas");
|
|
529
|
-
var import_jsx_runtime17 = require("react/jsx-runtime");
|
|
530
|
-
function FlowEcsState(props) {
|
|
531
|
-
const [, setUpdates] = (0, import_react19.useState)(0);
|
|
532
|
-
const [refreshLayout, setRefreshLayout] = (0, import_react19.useState)(false);
|
|
533
|
-
const { ecsFlowRepository } = (0, import_react19.useContext)(EcsFlowContext);
|
|
534
|
-
(0, import_react19.useEffect)(() => {
|
|
535
|
-
setRefreshLayout(true);
|
|
536
|
-
}, [ecsFlowRepository.sizeNodes]);
|
|
537
|
-
(0, import_react19.useEffect)(() => {
|
|
538
|
-
setInterval(() => {
|
|
539
|
-
setUpdates((updates) => updates + 1);
|
|
540
|
-
}, 1e3);
|
|
541
|
-
}, []);
|
|
542
|
-
return /* @__PURE__ */ (0, import_jsx_runtime17.jsxs)(import_jsx_runtime17.Fragment, { children: [
|
|
543
|
-
props.showSystemModules && /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(flow_ecs_modules_default, {}),
|
|
544
|
-
props.showEntities && /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(flow_ecs_entities_default, {}),
|
|
545
|
-
props.autoLayout && /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(import_canvas.FlowAutoLayout, { refreshLayout })
|
|
546
|
-
] });
|
|
547
|
-
}
|
|
548
|
-
var flow_ecs_state_default = (0, import_react19.memo)(FlowEcsState);
|
|
549
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
550
|
-
0 && (module.exports = {
|
|
551
|
-
EcsFlowContext,
|
|
552
|
-
EcsFlowRepository,
|
|
553
|
-
EcsHandleDataType,
|
|
554
|
-
EcsNodeType,
|
|
555
|
-
EcsTemplateGroup,
|
|
556
|
-
EntityNode,
|
|
557
|
-
EntityNodeTemplate,
|
|
558
|
-
FlowEcsState,
|
|
559
|
-
SystemsModuleNode,
|
|
560
|
-
SystemsModuleNodeTemplate,
|
|
561
|
-
ecsNodeTemplates,
|
|
562
|
-
ecsNodeTypes
|
|
563
|
-
});
|
|
564
|
-
//# sourceMappingURL=index.cjs.map
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; } var _class; var _class2;var _react = require('react');var s=_react.createContext.call(void 0, null);var y=class{static entityProxy(t){return`${t.entityType}:${t.entityUid}`}};var W=class{constructor(){this.nodes=new Map}get sizeNodes(){return this.nodes.size}addSystemModuleNode(t){this.nodes.set(t.data.entityType.toString(),t)}getSystemModuleNode(t){return this.nodes.get(t.toString())}addEntityNode(t){this.nodes.set(y.entityProxy(t.data.entity),t)}getEntityNode(t){return this.nodes.get(y.entityProxy(t))}listAllNodes(){return Array.from(this.nodes.values())}};var T=(e=>(e.proxy="proxy",e.module="module",e))(T||{});var _layout = require('@awesome-flow/core/layout');var _core = require('@mantine/core');function ct(o){return _react.useMemo.call(void 0, ()=>_optionalChain([o, 'access', _2 => _2.value, 'optionalAccess', _3 => _3.toString, 'call', _4 => _4(), 'access', _5 => _5.replace, 'call', _6 => _6(/([a-z])([A-Z])/g,"$1 $2")]),[o.value])}var c=_react.memo.call(void 0, ct);var _hooks = require('@mantine/hooks');var _reactinspector = require('react-inspector');var _jsxruntime = require('react/jsx-runtime');function gt(o){let t=_core.useComputedColorScheme.call(void 0, ),e=_react.useMemo.call(void 0, ()=>t==="dark"?"chromeDark":"chromeLight",[t]);return _jsxruntime.jsx.call(void 0, _reactinspector.Inspector,{table:!1,theme:e,data:o.data})}var G=_react.memo.call(void 0, gt);function Ft(o){let[t,{toggle:e}]=_hooks.useDisclosure.call(void 0, !1),n=_react.useMemo.call(void 0, ()=>t?"light":"indigo",[t]);return _jsxruntime.jsxs.call(void 0, _core.Box,{children:[_jsxruntime.jsx.call(void 0, _core.Button,{variant:"outline",size:"xs",onClick:e,color:n,fullWidth:!0,children:o.component.componentType}),_jsxruntime.jsx.call(void 0, _core.Collapse,{in:t,children:t&&_jsxruntime.jsx.call(void 0, G,{data:o.component})})]})}var O=_react.memo.call(void 0, Ft);function Lt(o){let t=Array.from(o.entity.components.values());return _jsxruntime.jsxs.call(void 0, _core.Accordion.Item,{value:"components",children:[_jsxruntime.jsx.call(void 0, _core.Accordion.Control,{children:_jsxruntime.jsx.call(void 0, _core.Badge,{fullWidth:!0,variant:"light",rightSection:t.length,children:"Components"})}),_jsxruntime.jsx.call(void 0, _core.Accordion.Panel,{children:_jsxruntime.jsx.call(void 0, _core.Stack,{children:t.map((e,n)=>_jsxruntime.jsx.call(void 0, O,{component:e},n))})})]},"components")}var $=_react.memo.call(void 0, Lt);function Dt(o){return o.items.map((t,e)=>_jsxruntime.jsx.call(void 0, _core.Badge,{...o.badge||[],children:_jsxruntime.jsx.call(void 0, c,{value:t})},e))}var u=_react.memo.call(void 0, Dt);function Ht(o){let e=Array.from(o.entity.proxies.values()).map(n=>n.values()).map(n=>Array.from(n).map(i=>y.entityProxy(i))).flat();return _jsxruntime.jsxs.call(void 0, _core.Accordion.Item,{value:"proxies",children:[_jsxruntime.jsx.call(void 0, _core.Accordion.Control,{children:_jsxruntime.jsx.call(void 0, _core.Badge,{fullWidth:!0,variant:"light",rightSection:e.length,children:"Proxies"})}),_jsxruntime.jsx.call(void 0, _core.Accordion.Panel,{children:_jsxruntime.jsx.call(void 0, _core.Stack,{children:_jsxruntime.jsx.call(void 0, u,{items:e,badge:{variant:"outline"}})})})]},"proxies")}var Z=_react.memo.call(void 0, Ht);function Zt(o){let{entityEventsManager:t}=_react.useContext.call(void 0, s),e=t.getSubscriptionsForEntity(o.entity.myProxy);return _jsxruntime.jsxs.call(void 0, _core.Accordion.Item,{value:"subscriptions",children:[_jsxruntime.jsx.call(void 0, _core.Accordion.Control,{children:_jsxruntime.jsx.call(void 0, _core.Badge,{fullWidth:!0,variant:"light",rightSection:e.length,children:"Events"})}),_jsxruntime.jsx.call(void 0, _core.Accordion.Panel,{children:_jsxruntime.jsx.call(void 0, _core.Stack,{children:_jsxruntime.jsx.call(void 0, u,{items:e,badge:{variant:"outline"}})})})]},"subscriptions")}var q=_react.memo.call(void 0, Zt);function Yt(o){let[,t]=_react.useState.call(void 0, 0),{entityUpdateCounter:e}=_react.useContext.call(void 0, s),n=e.getUpdateCount(o.entityUid)||0,i=e.getRemoveCount(o.entityUid)||0;return _react.useEffect.call(void 0, ()=>{let r=setInterval(()=>{t(a=>a+1)},1e3);return()=>{console.log("CLEAR INTERVAL"),clearInterval(r)}},[]),_jsxruntime.jsxs.call(void 0, _jsxruntime.Fragment,{children:[_jsxruntime.jsx.call(void 0, _core.Badge,{variant:"light",children:n}),_jsxruntime.jsx.call(void 0, _core.Badge,{variant:"light",color:"orange",children:i})]})}var Q=_react.memo.call(void 0, Yt);function ro({entity:o}){return _jsxruntime.jsxs.call(void 0, _jsxruntime.Fragment,{children:[_jsxruntime.jsxs.call(void 0, _core.Group,{children:[_jsxruntime.jsx.call(void 0, _core.Badge,{variant:"outline",color:"orange",children:o.myProxy.entityUid}),_jsxruntime.jsx.call(void 0, Q,{entityUid:o.myProxy.entityUid})]}),_jsxruntime.jsx.call(void 0, _core.Divider,{my:5}),_jsxruntime.jsxs.call(void 0, _core.Accordion,{children:[_jsxruntime.jsx.call(void 0, $,{entity:o}),_jsxruntime.jsx.call(void 0, Z,{entity:o}),_jsxruntime.jsx.call(void 0, q,{entity:o})]})]})}var X=ro;function lo({id:o,data:t,selected:e,type:n}){let{entityRepository:i}=_react.useContext.call(void 0, s),r=_react.useMemo.call(void 0, ()=>i.get(t.entity),[t.entity]);return _jsxruntime.jsx.call(void 0, _layout.NodeContainer,{id:o,selected:e,data:t,title:_jsxruntime.jsx.call(void 0, _core.Badge,{fullWidth:!0,variant:"transparent",children:_jsxruntime.jsx.call(void 0, c,{value:r.myProxy.entityType})}),type:n,children:_jsxruntime.jsx.call(void 0, X,{entity:r})})}var B=lo;var _systems = require('@awesome-ecs/abstract/systems');function uo(o){let t=[];o.pipeline&&(t=o.pipeline.middleware);let e=t.map(n=>n.name||n.constructor.name);return _jsxruntime.jsxs.call(void 0, _core.Accordion.Item,{value:o.label,children:[_jsxruntime.jsx.call(void 0, _core.Accordion.Control,{children:_jsxruntime.jsx.call(void 0, _core.Badge,{fullWidth:!0,variant:"light",rightSection:e.length,children:o.label})}),_jsxruntime.jsx.call(void 0, _core.Accordion.Panel,{children:_jsxruntime.jsx.call(void 0, _core.Stack,{children:_jsxruntime.jsx.call(void 0, u,{items:e,badge:{variant:"outline"}})})})]},o.label)}var C=uo;function No(o){let{module:t}=o,e=t.runtimeContext,{systemContext:n}=e,{status:i}=_react.useMemo.call(void 0, ()=>n.runtime,[n.runtime.status]),r=e.systemPipelines.get(_systems.SystemType.initialize),a=e.systemPipelines.get(_systems.SystemType.update),m=e.systemPipelines.get(_systems.SystemType.render),d=e.systemPipelines.get(_systems.SystemType.sync);return _jsxruntime.jsxs.call(void 0, _jsxruntime.Fragment,{children:[_jsxruntime.jsxs.call(void 0, _core.Text,{children:["Status: ",i]}),_jsxruntime.jsxs.call(void 0, _core.Accordion,{children:[r&&_jsxruntime.jsx.call(void 0, C,{pipeline:r,label:"Initialize"}),a&&_jsxruntime.jsx.call(void 0, C,{pipeline:a,label:"Update"}),m&&_jsxruntime.jsx.call(void 0, C,{pipeline:m,label:"Render"}),d&&_jsxruntime.jsx.call(void 0, C,{pipeline:d,label:"Sync"})]})]})}var Y=No;function Mo({id:o,data:t,selected:e,type:n}){let{systemsModuleRepository:i}=_react.useContext.call(void 0, s),r=i.get(t.entityType);return _jsxruntime.jsx.call(void 0, _layout.NodeContainer,{id:o,selected:e,data:t,title:_jsxruntime.jsx.call(void 0, _core.Badge,{fullWidth:!0,color:"indigo",variant:"transparent",children:_jsxruntime.jsx.call(void 0, c,{value:t.entityType})}),type:n,children:_jsxruntime.jsx.call(void 0, Y,{type:t.entityType,module:r})})}var k=Mo;var _react3 = require('@xyflow/react');var z=(t=>(t.ecs="ECS",t))(z||{});var F= (_class =class{constructor() { _class.prototype.__init.call(this); }__init() {this.template={type:"entity-node",group:"ECS",data:{title:"Entity",entity:null},handles:[{dataType:"proxy",position:_react3.Position.Left,connection:"target",disabled:!0},{dataType:"proxy",position:_react3.Position.Right,connection:"source",disabled:!0}]}}}, _class);var h= (_class2 =class{constructor() { _class2.prototype.__init2.call(this); }__init2() {this.template={type:"systems-module-node",group:"ECS",data:{title:"Systems Module",entityType:null},handles:[{dataType:"module",position:_react3.Position.Left,connection:"target",disabled:!0}]}}}, _class2);var P=(e=>(e.systemsModule="systems-module-node",e.entity="entity-node",e))(P||{}),Kn= exports.ecsNodeTypes ={"systems-module-node":k,"entity-node":B},Qn= exports.ecsNodeTemplates ={"entity-node":new F,"systems-module-node":new h};var _canvas = require('@awesome-flow/core/canvas');var _abstract = require('@awesome-flow/core/abstract');var _hooks3 = require('@awesome-flow/core/hooks');function vo(o){let{nodesToConnect:t}=o,e=_hooks3.useFlowStore.call(void 0, r=>r.onConnect),{ecsFlowRepository:n,entityRepository:i}=_react.useContext.call(void 0, s);return _react.useEffect.call(void 0, ()=>{for(let r of t){let a=r.data.handles.find(l=>l.connection==="source"),m=i.get(r.data.entity),d=n.getSystemModuleNode(m.myProxy.entityType),p=_optionalChain([d, 'optionalAccess', _7 => _7.data, 'access', _8 => _8.handles, 'access', _9 => _9.find, 'call', _10 => _10(l=>l.connection==="target")]);p&&e({source:r.id,target:d.id,sourceHandle:a.id,targetHandle:p.id})}},[t]),_jsxruntime.jsx.call(void 0, _jsxruntime.Fragment,{})}var j=vo;function Do(o){let{nodesToConnect:t}=o,e=_hooks3.useFlowStore.call(void 0, r=>r.onConnect),{ecsFlowRepository:n,entityRepository:i}=_react.useContext.call(void 0, s);return _react.useEffect.call(void 0, ()=>{for(let r of t){let a=r.data.handles.find(d=>d.connection==="source"),m=i.get(r.data.entity);for(let[,d]of m.proxies)for(let p of d.values()){let l=n.getEntityNode(p);if(l){let dt=l.data.handles.find(at=>at.connection==="target");e({source:r.id,target:l.id,sourceHandle:a.id,targetHandle:dt.id})}}}},[t]),_jsxruntime.jsx.call(void 0, _jsxruntime.Fragment,{})}var tt=Do;function Oo(){let{nodeFactory:o}=_react.useContext.call(void 0, _abstract.FlowContext),t=_hooks3.useFlowStore.call(void 0, a=>a.addNodes),{ecsFlowRepository:e,entityRepository:n}=_react.useContext.call(void 0, s),[i,r]=_react.useState.call(void 0, []);return _react.useEffect.call(void 0, ()=>{let a=n.listAll(),m=[];for(let d of a){if(e.getEntityNode(d.myProxy))continue;let p=o.createNodeFromType("entity-node");p.data.entity=d.myProxy,p.position={x:0,y:0},e.addEntityNode(p),m.push(p)}r(m),t(m)},[n.size]),_jsxruntime.jsxs.call(void 0, _jsxruntime.Fragment,{children:[_jsxruntime.jsx.call(void 0, tt,{nodesToConnect:i}),_jsxruntime.jsx.call(void 0, j,{nodesToConnect:i})]})}var nt=Oo;function Ko(){let{nodeFactory:o}=_react.useContext.call(void 0, _abstract.FlowContext),t=_hooks3.useFlowStore.call(void 0, i=>i.addNodes),{ecsFlowRepository:e,systemsModuleRepository:n}=_react.useContext.call(void 0, s);return _react.useEffect.call(void 0, ()=>{let i=Array.from(n.list()).filter(m=>!!m),r=Array.from(i.values()).map(m=>m[0]),a=[];for(let m of r){if(e.getSystemModuleNode(m))continue;let d=o.createNodeFromType("systems-module-node");d.data.entityType=m,d.position={x:0,y:0},e.addSystemModuleNode(d),a.push(d)}a.length&&t(a)},[n.size]),_jsxruntime.jsx.call(void 0, _jsxruntime.Fragment,{})}var it=Ko;function te(o){let[,t]=_react.useState.call(void 0, 0),[e,n]=_react.useState.call(void 0, !1),{ecsFlowRepository:i}=_react.useContext.call(void 0, s);return _react.useEffect.call(void 0, ()=>{n(!0)},[i.sizeNodes]),_react.useEffect.call(void 0, ()=>{setInterval(()=>{t(r=>r+1)},1e3)},[]),_jsxruntime.jsxs.call(void 0, _jsxruntime.Fragment,{children:[o.showSystemModules&&_jsxruntime.jsx.call(void 0, it,{}),o.showEntities&&_jsxruntime.jsx.call(void 0, nt,{}),o.autoLayout&&_jsxruntime.jsx.call(void 0, _canvas.FlowAutoLayout,{refreshLayout:e})]})}var oe=_react.memo.call(void 0, te);exports.EcsFlowContext = s; exports.EcsFlowRepository = W; exports.EcsHandleDataType = T; exports.EcsNodeType = P; exports.EcsTemplateGroup = z; exports.EntityNode = B; exports.EntityNodeTemplate = F; exports.FlowEcsState = oe; exports.SystemsModuleNode = k; exports.SystemsModuleNodeTemplate = h; exports.ecsNodeTemplates = Qn; exports.ecsNodeTypes = Kn;
|
package/dist/index.d.cts
CHANGED
|
@@ -1,11 +1,16 @@
|
|
|
1
1
|
import * as react from 'react';
|
|
2
|
-
import { EntityTypeUid, IEntityProxy,
|
|
2
|
+
import { EntityUid, EntityTypeUid, IEntityProxy, IEntityRepository } from '@awesome-ecs/abstract/entities';
|
|
3
3
|
import { ISystemsModuleRepository } from '@awesome-ecs/abstract/systems';
|
|
4
4
|
import { EntityEventsManager } from '@awesome-ecs/core/entities';
|
|
5
5
|
import { Node, NodeProps } from '@xyflow/react';
|
|
6
6
|
import { BasicNodeData, ITemplateFactory, NodeTemplate } from '@awesome-flow/core/abstract';
|
|
7
7
|
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
8
8
|
|
|
9
|
+
interface IEntityUpdateCounter {
|
|
10
|
+
getUpdateCount(entityUid: EntityUid): number;
|
|
11
|
+
getRemoveCount(entityUid: EntityUid): number;
|
|
12
|
+
}
|
|
13
|
+
|
|
9
14
|
type SystemsModuleNodeData = BasicNodeData & {
|
|
10
15
|
entityType: EntityTypeUid;
|
|
11
16
|
};
|
|
@@ -24,11 +29,6 @@ declare class EcsFlowRepository {
|
|
|
24
29
|
listAllNodes(): Node[];
|
|
25
30
|
}
|
|
26
31
|
|
|
27
|
-
interface IEntityUpdateCounter {
|
|
28
|
-
getUpdateCount(entityUid: EntityUid): number;
|
|
29
|
-
getRemoveCount(entityUid: EntityUid): number;
|
|
30
|
-
}
|
|
31
|
-
|
|
32
32
|
type EcsFlowContextProps = {
|
|
33
33
|
ecsFlowRepository: EcsFlowRepository;
|
|
34
34
|
entityRepository: IEntityRepository;
|
|
@@ -43,10 +43,10 @@ declare enum EcsHandleDataType {
|
|
|
43
43
|
module = "module"
|
|
44
44
|
}
|
|
45
45
|
|
|
46
|
-
declare function SystemsModuleNode({ id, data, selected, type }: NodeProps<Node<SystemsModuleNodeData>>): react_jsx_runtime.JSX.Element;
|
|
47
|
-
|
|
48
46
|
declare function EntityNode({ id, data, selected, type }: NodeProps<Node<EntityNodeData>>): react_jsx_runtime.JSX.Element;
|
|
49
47
|
|
|
48
|
+
declare function SystemsModuleNode({ id, data, selected, type }: NodeProps<Node<SystemsModuleNodeData>>): react_jsx_runtime.JSX.Element;
|
|
49
|
+
|
|
50
50
|
declare class EntityNodeTemplate implements ITemplateFactory {
|
|
51
51
|
readonly template: NodeTemplate<EntityNodeData>;
|
|
52
52
|
}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,11 +1,16 @@
|
|
|
1
1
|
import * as react from 'react';
|
|
2
|
-
import { EntityTypeUid, IEntityProxy,
|
|
2
|
+
import { EntityUid, EntityTypeUid, IEntityProxy, IEntityRepository } from '@awesome-ecs/abstract/entities';
|
|
3
3
|
import { ISystemsModuleRepository } from '@awesome-ecs/abstract/systems';
|
|
4
4
|
import { EntityEventsManager } from '@awesome-ecs/core/entities';
|
|
5
5
|
import { Node, NodeProps } from '@xyflow/react';
|
|
6
6
|
import { BasicNodeData, ITemplateFactory, NodeTemplate } from '@awesome-flow/core/abstract';
|
|
7
7
|
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
8
8
|
|
|
9
|
+
interface IEntityUpdateCounter {
|
|
10
|
+
getUpdateCount(entityUid: EntityUid): number;
|
|
11
|
+
getRemoveCount(entityUid: EntityUid): number;
|
|
12
|
+
}
|
|
13
|
+
|
|
9
14
|
type SystemsModuleNodeData = BasicNodeData & {
|
|
10
15
|
entityType: EntityTypeUid;
|
|
11
16
|
};
|
|
@@ -24,11 +29,6 @@ declare class EcsFlowRepository {
|
|
|
24
29
|
listAllNodes(): Node[];
|
|
25
30
|
}
|
|
26
31
|
|
|
27
|
-
interface IEntityUpdateCounter {
|
|
28
|
-
getUpdateCount(entityUid: EntityUid): number;
|
|
29
|
-
getRemoveCount(entityUid: EntityUid): number;
|
|
30
|
-
}
|
|
31
|
-
|
|
32
32
|
type EcsFlowContextProps = {
|
|
33
33
|
ecsFlowRepository: EcsFlowRepository;
|
|
34
34
|
entityRepository: IEntityRepository;
|
|
@@ -43,10 +43,10 @@ declare enum EcsHandleDataType {
|
|
|
43
43
|
module = "module"
|
|
44
44
|
}
|
|
45
45
|
|
|
46
|
-
declare function SystemsModuleNode({ id, data, selected, type }: NodeProps<Node<SystemsModuleNodeData>>): react_jsx_runtime.JSX.Element;
|
|
47
|
-
|
|
48
46
|
declare function EntityNode({ id, data, selected, type }: NodeProps<Node<EntityNodeData>>): react_jsx_runtime.JSX.Element;
|
|
49
47
|
|
|
48
|
+
declare function SystemsModuleNode({ id, data, selected, type }: NodeProps<Node<SystemsModuleNodeData>>): react_jsx_runtime.JSX.Element;
|
|
49
|
+
|
|
50
50
|
declare class EntityNodeTemplate implements ITemplateFactory {
|
|
51
51
|
readonly template: NodeTemplate<EntityNodeData>;
|
|
52
52
|
}
|