@awesome-flow/ecs 0.7.1 → 0.9.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +524 -1
- package/dist/index.js +524 -1
- package/package.json +24 -18
package/dist/index.cjs
CHANGED
|
@@ -1 +1,524 @@
|
|
|
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;
|
|
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;// src/abstract/ecs-flow-context.ts
|
|
2
|
+
var _react = require('react');
|
|
3
|
+
var EcsFlowContext = _react.createContext.call(void 0, null);
|
|
4
|
+
|
|
5
|
+
// src/utils/id-generator.ts
|
|
6
|
+
var EcsIdGenerator = class {
|
|
7
|
+
static entityProxy(proxy) {
|
|
8
|
+
return `${proxy.entityType}:${proxy.entityUid}`;
|
|
9
|
+
}
|
|
10
|
+
};
|
|
11
|
+
|
|
12
|
+
// src/abstract/ecs-flow-repository.ts
|
|
13
|
+
var EcsFlowRepository = class {
|
|
14
|
+
|
|
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
|
+
}
|
|
36
|
+
};
|
|
37
|
+
|
|
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
|
+
var _layout = require('@awesome-flow/core/layout');
|
|
47
|
+
var _core = require('@mantine/core');
|
|
48
|
+
|
|
49
|
+
|
|
50
|
+
// src/components/formatter-camel-case.tsx
|
|
51
|
+
|
|
52
|
+
function CamelCaseFormatter(props) {
|
|
53
|
+
const value = _react.useMemo.call(void 0,
|
|
54
|
+
() => _optionalChain([props, 'access', _ => _.value, 'optionalAccess', _2 => _2.toString, 'call', _3 => _3(), 'access', _4 => _4.replace, 'call', _5 => _5(/([a-z])([A-Z])/g, "$1 $2")]),
|
|
55
|
+
[props.value]
|
|
56
|
+
);
|
|
57
|
+
return value;
|
|
58
|
+
}
|
|
59
|
+
var formatter_camel_case_default = _react.memo.call(void 0, CamelCaseFormatter);
|
|
60
|
+
|
|
61
|
+
// src/layout/entity-layout.tsx
|
|
62
|
+
|
|
63
|
+
|
|
64
|
+
// src/components/entity-component-list.tsx
|
|
65
|
+
|
|
66
|
+
|
|
67
|
+
|
|
68
|
+
// src/components/entity-component-inspector.tsx
|
|
69
|
+
|
|
70
|
+
var _hooks = require('@mantine/hooks');
|
|
71
|
+
|
|
72
|
+
|
|
73
|
+
// src/components/object-inspector.tsx
|
|
74
|
+
|
|
75
|
+
|
|
76
|
+
var _reactinspector = require('react-inspector');
|
|
77
|
+
var _jsxruntime = require('react/jsx-runtime');
|
|
78
|
+
function ObjectInspector(props) {
|
|
79
|
+
const colorScheme = _core.useComputedColorScheme.call(void 0, );
|
|
80
|
+
const theme = _react.useMemo.call(void 0,
|
|
81
|
+
() => colorScheme === "dark" ? "chromeDark" : "chromeLight",
|
|
82
|
+
[colorScheme]
|
|
83
|
+
);
|
|
84
|
+
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _reactinspector.Inspector, { table: false, theme, data: props.data });
|
|
85
|
+
}
|
|
86
|
+
var object_inspector_default = _react.memo.call(void 0, ObjectInspector);
|
|
87
|
+
|
|
88
|
+
// src/components/entity-component-inspector.tsx
|
|
89
|
+
|
|
90
|
+
function EntityComponentInspector(props) {
|
|
91
|
+
const [opened, { toggle }] = _hooks.useDisclosure.call(void 0, false);
|
|
92
|
+
const buttonColor = _react.useMemo.call(void 0, () => opened ? "light" : "indigo", [opened]);
|
|
93
|
+
return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _core.Box, { children: [
|
|
94
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _core.Button, { variant: "outline", size: "xs", onClick: toggle, color: buttonColor, fullWidth: true, children: props.component.componentType }),
|
|
95
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _core.Collapse, { in: opened, children: opened && /* @__PURE__ */ _jsxruntime.jsx.call(void 0, object_inspector_default, { data: props.component }) })
|
|
96
|
+
] });
|
|
97
|
+
}
|
|
98
|
+
var entity_component_inspector_default = _react.memo.call(void 0, EntityComponentInspector);
|
|
99
|
+
|
|
100
|
+
// src/components/entity-component-list.tsx
|
|
101
|
+
|
|
102
|
+
function EntityComponentList(props) {
|
|
103
|
+
const components = Array.from(props.entity.components.values());
|
|
104
|
+
return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _core.Accordion.Item, { value: "components", children: [
|
|
105
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _core.Accordion.Control, { children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _core.Badge, { fullWidth: true, variant: "light", rightSection: components.length, children: "Components" }) }),
|
|
106
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _core.Accordion.Panel, { children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _core.Stack, { children: components.map((c, i) => /* @__PURE__ */ _jsxruntime.jsx.call(void 0, entity_component_inspector_default, { component: c }, i)) }) })
|
|
107
|
+
] }, "components");
|
|
108
|
+
}
|
|
109
|
+
var entity_component_list_default = _react.memo.call(void 0, EntityComponentList);
|
|
110
|
+
|
|
111
|
+
// src/components/entity-proxy-list.tsx
|
|
112
|
+
|
|
113
|
+
|
|
114
|
+
|
|
115
|
+
// src/components/badge-list.tsx
|
|
116
|
+
|
|
117
|
+
|
|
118
|
+
|
|
119
|
+
function BadgeList(props) {
|
|
120
|
+
return props.items.map((value, i) => {
|
|
121
|
+
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _core.Badge, { ...props.badge || [], children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, formatter_camel_case_default, { value }) }, i);
|
|
122
|
+
});
|
|
123
|
+
}
|
|
124
|
+
var badge_list_default = _react.memo.call(void 0, BadgeList);
|
|
125
|
+
|
|
126
|
+
// src/components/entity-proxy-list.tsx
|
|
127
|
+
|
|
128
|
+
function EntityProxyList(props) {
|
|
129
|
+
const proxies = Array.from(props.entity.proxies.values()).map((c) => c.values());
|
|
130
|
+
const items = proxies.map((p) => Array.from(p).map((k) => EcsIdGenerator.entityProxy(k))).flat();
|
|
131
|
+
return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _core.Accordion.Item, { value: "proxies", children: [
|
|
132
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _core.Accordion.Control, { children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _core.Badge, { fullWidth: true, variant: "light", rightSection: items.length, children: "Proxies" }) }),
|
|
133
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _core.Accordion.Panel, { children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _core.Stack, { children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, badge_list_default, { items, badge: { variant: "outline" } }) }) })
|
|
134
|
+
] }, "proxies");
|
|
135
|
+
}
|
|
136
|
+
var entity_proxy_list_default = _react.memo.call(void 0, EntityProxyList);
|
|
137
|
+
|
|
138
|
+
// src/components/entity-subscription-list.tsx
|
|
139
|
+
|
|
140
|
+
|
|
141
|
+
|
|
142
|
+
function EntitySubscriptionList(props) {
|
|
143
|
+
const { entityEventsManager } = _react.useContext.call(void 0, EcsFlowContext);
|
|
144
|
+
const subscriptions = entityEventsManager.getSubscriptionsForEntity(props.entity.myProxy);
|
|
145
|
+
return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _core.Accordion.Item, { value: "subscriptions", children: [
|
|
146
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _core.Accordion.Control, { children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _core.Badge, { fullWidth: true, variant: "light", rightSection: subscriptions.length, children: "Events" }) }),
|
|
147
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _core.Accordion.Panel, { children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _core.Stack, { children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, badge_list_default, { items: subscriptions, badge: { variant: "outline" } }) }) })
|
|
148
|
+
] }, "subscriptions");
|
|
149
|
+
}
|
|
150
|
+
var entity_subscription_list_default = _react.memo.call(void 0, EntitySubscriptionList);
|
|
151
|
+
|
|
152
|
+
// src/components/entity-update-counter.tsx
|
|
153
|
+
|
|
154
|
+
|
|
155
|
+
|
|
156
|
+
function EntityUpdateCounter(props) {
|
|
157
|
+
const [, setRefresh] = _react.useState.call(void 0, 0);
|
|
158
|
+
const { entityUpdateCounter } = _react.useContext.call(void 0, EcsFlowContext);
|
|
159
|
+
const updates = entityUpdateCounter.getUpdateCount(props.entityUid) || 0;
|
|
160
|
+
const removes = entityUpdateCounter.getRemoveCount(props.entityUid) || 0;
|
|
161
|
+
_react.useEffect.call(void 0, () => {
|
|
162
|
+
const interval = setInterval(() => {
|
|
163
|
+
setRefresh((refresh) => refresh + 1);
|
|
164
|
+
}, 1e3);
|
|
165
|
+
return () => {
|
|
166
|
+
console.log("CLEAR INTERVAL");
|
|
167
|
+
clearInterval(interval);
|
|
168
|
+
};
|
|
169
|
+
}, []);
|
|
170
|
+
return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _jsxruntime.Fragment, { children: [
|
|
171
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _core.Badge, { variant: "light", children: updates }),
|
|
172
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _core.Badge, { variant: "light", color: "orange", children: removes })
|
|
173
|
+
] });
|
|
174
|
+
}
|
|
175
|
+
var entity_update_counter_default = _react.memo.call(void 0, EntityUpdateCounter);
|
|
176
|
+
|
|
177
|
+
// src/layout/entity-layout.tsx
|
|
178
|
+
|
|
179
|
+
function EntityLayout({ entity }) {
|
|
180
|
+
return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _jsxruntime.Fragment, { children: [
|
|
181
|
+
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _core.Group, { children: [
|
|
182
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _core.Badge, { variant: "outline", color: "orange", children: entity.myProxy.entityUid }),
|
|
183
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, entity_update_counter_default, { entityUid: entity.myProxy.entityUid })
|
|
184
|
+
] }),
|
|
185
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _core.Divider, { my: 5 }),
|
|
186
|
+
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _core.Accordion, { children: [
|
|
187
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, entity_component_list_default, { entity }),
|
|
188
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, entity_proxy_list_default, { entity }),
|
|
189
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, entity_subscription_list_default, { entity })
|
|
190
|
+
] })
|
|
191
|
+
] });
|
|
192
|
+
}
|
|
193
|
+
var entity_layout_default = EntityLayout;
|
|
194
|
+
|
|
195
|
+
// src/nodes/node-entity.tsx
|
|
196
|
+
|
|
197
|
+
function EntityNode({ id, data, selected, type }) {
|
|
198
|
+
const { entityRepository } = _react.useContext.call(void 0, EcsFlowContext);
|
|
199
|
+
const entity = _react.useMemo.call(void 0, () => entityRepository.get(data.entity), [data.entity]);
|
|
200
|
+
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
201
|
+
_layout.NodeContainer,
|
|
202
|
+
{
|
|
203
|
+
id,
|
|
204
|
+
selected,
|
|
205
|
+
data,
|
|
206
|
+
title: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _core.Badge, { fullWidth: true, variant: "transparent", children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, formatter_camel_case_default, { value: entity.myProxy.entityType }) }),
|
|
207
|
+
type,
|
|
208
|
+
children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, entity_layout_default, { entity })
|
|
209
|
+
}
|
|
210
|
+
);
|
|
211
|
+
}
|
|
212
|
+
var node_entity_default = EntityNode;
|
|
213
|
+
|
|
214
|
+
// src/nodes/node-systems-module.tsx
|
|
215
|
+
|
|
216
|
+
|
|
217
|
+
|
|
218
|
+
|
|
219
|
+
// src/layout/systems-module-layout.tsx
|
|
220
|
+
var _systems = require('@awesome-ecs/abstract/systems');
|
|
221
|
+
|
|
222
|
+
|
|
223
|
+
|
|
224
|
+
// src/components/pipeline-middleware-list.tsx
|
|
225
|
+
|
|
226
|
+
|
|
227
|
+
function PipelineMiddlewareList(props) {
|
|
228
|
+
let middleware = [];
|
|
229
|
+
if (props.pipeline) {
|
|
230
|
+
middleware = props.pipeline["middleware"];
|
|
231
|
+
}
|
|
232
|
+
const components = middleware.map((m) => {
|
|
233
|
+
return m.name || m.constructor.name;
|
|
234
|
+
});
|
|
235
|
+
return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _core.Accordion.Item, { value: props.label, children: [
|
|
236
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _core.Accordion.Control, { children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _core.Badge, { fullWidth: true, variant: "light", rightSection: components.length, children: props.label }) }),
|
|
237
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _core.Accordion.Panel, { children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _core.Stack, { children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, badge_list_default, { items: components, badge: { variant: "outline" } }) }) })
|
|
238
|
+
] }, props.label);
|
|
239
|
+
}
|
|
240
|
+
var pipeline_middleware_list_default = PipelineMiddlewareList;
|
|
241
|
+
|
|
242
|
+
// src/layout/systems-module-layout.tsx
|
|
243
|
+
|
|
244
|
+
function SystemsModuleLayout(props) {
|
|
245
|
+
const { module } = props;
|
|
246
|
+
const runtimeContext = module["runtimeContext"];
|
|
247
|
+
const { systemContext } = runtimeContext;
|
|
248
|
+
const { status } = _react.useMemo.call(void 0, () => {
|
|
249
|
+
return systemContext.runtime;
|
|
250
|
+
}, [systemContext.runtime.status]);
|
|
251
|
+
const init = runtimeContext.systemPipelines.get(_systems.SystemType.initialize);
|
|
252
|
+
const update = runtimeContext.systemPipelines.get(_systems.SystemType.update);
|
|
253
|
+
const render = runtimeContext.systemPipelines.get(_systems.SystemType.render);
|
|
254
|
+
const sync = runtimeContext.systemPipelines.get(_systems.SystemType.sync);
|
|
255
|
+
return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _jsxruntime.Fragment, { children: [
|
|
256
|
+
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _core.Text, { children: [
|
|
257
|
+
"Status: ",
|
|
258
|
+
status
|
|
259
|
+
] }),
|
|
260
|
+
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _core.Accordion, { children: [
|
|
261
|
+
init && /* @__PURE__ */ _jsxruntime.jsx.call(void 0, pipeline_middleware_list_default, { pipeline: init, label: "Initialize" }),
|
|
262
|
+
update && /* @__PURE__ */ _jsxruntime.jsx.call(void 0, pipeline_middleware_list_default, { pipeline: update, label: "Update" }),
|
|
263
|
+
render && /* @__PURE__ */ _jsxruntime.jsx.call(void 0, pipeline_middleware_list_default, { pipeline: render, label: "Render" }),
|
|
264
|
+
sync && /* @__PURE__ */ _jsxruntime.jsx.call(void 0, pipeline_middleware_list_default, { pipeline: sync, label: "Sync" })
|
|
265
|
+
] })
|
|
266
|
+
] });
|
|
267
|
+
}
|
|
268
|
+
var systems_module_layout_default = SystemsModuleLayout;
|
|
269
|
+
|
|
270
|
+
// src/nodes/node-systems-module.tsx
|
|
271
|
+
|
|
272
|
+
function SystemsModuleNode({ id, data, selected, type }) {
|
|
273
|
+
const { systemsModuleRepository } = _react.useContext.call(void 0, EcsFlowContext);
|
|
274
|
+
const module = systemsModuleRepository.get(data.entityType);
|
|
275
|
+
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
276
|
+
_layout.NodeContainer,
|
|
277
|
+
{
|
|
278
|
+
id,
|
|
279
|
+
selected,
|
|
280
|
+
data,
|
|
281
|
+
title: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _core.Badge, { fullWidth: true, color: "indigo", variant: "transparent", children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, formatter_camel_case_default, { value: data.entityType }) }),
|
|
282
|
+
type,
|
|
283
|
+
children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, systems_module_layout_default, { type: data.entityType, module })
|
|
284
|
+
}
|
|
285
|
+
);
|
|
286
|
+
}
|
|
287
|
+
var node_systems_module_default = SystemsModuleNode;
|
|
288
|
+
|
|
289
|
+
// src/templates/template-entity-node.ts
|
|
290
|
+
var _react3 = require('@xyflow/react');
|
|
291
|
+
|
|
292
|
+
// src/abstract/templates.ts
|
|
293
|
+
var EcsTemplateGroup = /* @__PURE__ */ ((EcsTemplateGroup2) => {
|
|
294
|
+
EcsTemplateGroup2["ecs"] = "ECS";
|
|
295
|
+
return EcsTemplateGroup2;
|
|
296
|
+
})(EcsTemplateGroup || {});
|
|
297
|
+
|
|
298
|
+
// src/templates/template-entity-node.ts
|
|
299
|
+
var EntityNodeTemplate = (_class = class {constructor() { _class.prototype.__init.call(this); }
|
|
300
|
+
__init() {this.template = {
|
|
301
|
+
type: "entity-node" /* entity */,
|
|
302
|
+
group: "ECS" /* ecs */,
|
|
303
|
+
data: {
|
|
304
|
+
title: "Entity",
|
|
305
|
+
entity: null
|
|
306
|
+
},
|
|
307
|
+
handles: [
|
|
308
|
+
{
|
|
309
|
+
dataType: "proxy" /* proxy */,
|
|
310
|
+
position: _react3.Position.Left,
|
|
311
|
+
connection: "target",
|
|
312
|
+
disabled: true
|
|
313
|
+
},
|
|
314
|
+
{
|
|
315
|
+
dataType: "proxy" /* proxy */,
|
|
316
|
+
position: _react3.Position.Right,
|
|
317
|
+
connection: "source",
|
|
318
|
+
disabled: true
|
|
319
|
+
}
|
|
320
|
+
]
|
|
321
|
+
}}
|
|
322
|
+
}, _class);
|
|
323
|
+
|
|
324
|
+
// src/templates/template-systems-module.ts
|
|
325
|
+
|
|
326
|
+
var SystemsModuleNodeTemplate = (_class2 = class {constructor() { _class2.prototype.__init2.call(this); }
|
|
327
|
+
__init2() {this.template = {
|
|
328
|
+
type: "systems-module-node" /* systemsModule */,
|
|
329
|
+
group: "ECS" /* ecs */,
|
|
330
|
+
data: {
|
|
331
|
+
title: "Systems Module",
|
|
332
|
+
entityType: null
|
|
333
|
+
},
|
|
334
|
+
handles: [
|
|
335
|
+
{
|
|
336
|
+
dataType: "module" /* module */,
|
|
337
|
+
position: _react3.Position.Left,
|
|
338
|
+
connection: "target",
|
|
339
|
+
disabled: true
|
|
340
|
+
}
|
|
341
|
+
]
|
|
342
|
+
}}
|
|
343
|
+
}, _class2);
|
|
344
|
+
|
|
345
|
+
// src/abstract/node-types.ts
|
|
346
|
+
var EcsNodeType = /* @__PURE__ */ ((EcsNodeType2) => {
|
|
347
|
+
EcsNodeType2["systemsModule"] = "systems-module-node";
|
|
348
|
+
EcsNodeType2["entity"] = "entity-node";
|
|
349
|
+
return EcsNodeType2;
|
|
350
|
+
})(EcsNodeType || {});
|
|
351
|
+
var ecsNodeTypes = {
|
|
352
|
+
["systems-module-node" /* systemsModule */]: node_systems_module_default,
|
|
353
|
+
["entity-node" /* entity */]: node_entity_default
|
|
354
|
+
};
|
|
355
|
+
var ecsNodeTemplates = {
|
|
356
|
+
["entity-node" /* entity */]: new EntityNodeTemplate(),
|
|
357
|
+
["systems-module-node" /* systemsModule */]: new SystemsModuleNodeTemplate()
|
|
358
|
+
};
|
|
359
|
+
|
|
360
|
+
// src/flow/flow-ecs-state.tsx
|
|
361
|
+
var _canvas = require('@awesome-flow/core/canvas');
|
|
362
|
+
|
|
363
|
+
|
|
364
|
+
// src/flow/flow-ecs-entities.tsx
|
|
365
|
+
var _abstract = require('@awesome-flow/core/abstract');
|
|
366
|
+
var _hooks3 = require('@awesome-flow/core/hooks');
|
|
367
|
+
|
|
368
|
+
|
|
369
|
+
// src/flow/flow-ecs-edge-modules.tsx
|
|
370
|
+
|
|
371
|
+
|
|
372
|
+
|
|
373
|
+
function FlowEcsEdgeModules(props) {
|
|
374
|
+
const { nodesToConnect } = props;
|
|
375
|
+
const onConnect = _hooks3.useFlowStore.call(void 0, (state) => state.onConnect);
|
|
376
|
+
const { ecsFlowRepository, entityRepository } = _react.useContext.call(void 0, EcsFlowContext);
|
|
377
|
+
_react.useEffect.call(void 0, () => {
|
|
378
|
+
for (const node of nodesToConnect) {
|
|
379
|
+
const sourceHandle = node.data.handles.find((h) => h.connection === "source");
|
|
380
|
+
const entity = entityRepository.get(node.data.entity);
|
|
381
|
+
const systemModule = ecsFlowRepository.getSystemModuleNode(entity.myProxy.entityType);
|
|
382
|
+
const targetHandle = _optionalChain([systemModule, 'optionalAccess', _6 => _6.data, 'access', _7 => _7.handles, 'access', _8 => _8.find, 'call', _9 => _9((h) => h.connection === "target")]);
|
|
383
|
+
if (targetHandle) {
|
|
384
|
+
onConnect({
|
|
385
|
+
source: node.id,
|
|
386
|
+
target: systemModule.id,
|
|
387
|
+
sourceHandle: sourceHandle.id,
|
|
388
|
+
targetHandle: targetHandle.id
|
|
389
|
+
});
|
|
390
|
+
}
|
|
391
|
+
}
|
|
392
|
+
}, [nodesToConnect]);
|
|
393
|
+
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _jsxruntime.Fragment, {});
|
|
394
|
+
}
|
|
395
|
+
var flow_ecs_edge_modules_default = FlowEcsEdgeModules;
|
|
396
|
+
|
|
397
|
+
// src/flow/flow-ecs-edge-proxies.tsx
|
|
398
|
+
|
|
399
|
+
|
|
400
|
+
|
|
401
|
+
function FlowEcsEdgeProxies(props) {
|
|
402
|
+
const { nodesToConnect } = props;
|
|
403
|
+
const onConnect = _hooks3.useFlowStore.call(void 0, (state) => state.onConnect);
|
|
404
|
+
const { ecsFlowRepository, entityRepository } = _react.useContext.call(void 0, EcsFlowContext);
|
|
405
|
+
_react.useEffect.call(void 0, () => {
|
|
406
|
+
for (const node of nodesToConnect) {
|
|
407
|
+
const sourceHandle = node.data.handles.find((h) => h.connection === "source");
|
|
408
|
+
const entity = entityRepository.get(node.data.entity);
|
|
409
|
+
for (const [, proxyMap] of entity.proxies) {
|
|
410
|
+
for (const proxy of proxyMap.values()) {
|
|
411
|
+
const proxyNode = ecsFlowRepository.getEntityNode(proxy);
|
|
412
|
+
if (proxyNode) {
|
|
413
|
+
const targetHandle = proxyNode.data.handles.find((h) => h.connection === "target");
|
|
414
|
+
onConnect({
|
|
415
|
+
source: node.id,
|
|
416
|
+
target: proxyNode.id,
|
|
417
|
+
sourceHandle: sourceHandle.id,
|
|
418
|
+
targetHandle: targetHandle.id
|
|
419
|
+
});
|
|
420
|
+
}
|
|
421
|
+
}
|
|
422
|
+
}
|
|
423
|
+
}
|
|
424
|
+
}, [nodesToConnect]);
|
|
425
|
+
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _jsxruntime.Fragment, {});
|
|
426
|
+
}
|
|
427
|
+
var flow_ecs_edge_proxies_default = FlowEcsEdgeProxies;
|
|
428
|
+
|
|
429
|
+
// src/flow/flow-ecs-entities.tsx
|
|
430
|
+
|
|
431
|
+
function FlowEcsEntities() {
|
|
432
|
+
const { nodeFactory } = _react.useContext.call(void 0, _abstract.FlowContext);
|
|
433
|
+
const addNodes = _hooks3.useFlowStore.call(void 0, (state) => state.addNodes);
|
|
434
|
+
const { ecsFlowRepository, entityRepository } = _react.useContext.call(void 0, EcsFlowContext);
|
|
435
|
+
const [entityNodes, setEntityNodes] = _react.useState.call(void 0, []);
|
|
436
|
+
_react.useEffect.call(void 0, () => {
|
|
437
|
+
const entities = entityRepository.listAll();
|
|
438
|
+
const nodes = [];
|
|
439
|
+
for (const entity of entities) {
|
|
440
|
+
if (ecsFlowRepository.getEntityNode(entity.myProxy)) {
|
|
441
|
+
continue;
|
|
442
|
+
}
|
|
443
|
+
const node = nodeFactory.createNodeFromType("entity-node" /* entity */);
|
|
444
|
+
node.data.entity = entity.myProxy;
|
|
445
|
+
node.position = { x: 0, y: 0 };
|
|
446
|
+
ecsFlowRepository.addEntityNode(node);
|
|
447
|
+
nodes.push(node);
|
|
448
|
+
}
|
|
449
|
+
setEntityNodes(nodes);
|
|
450
|
+
addNodes(nodes);
|
|
451
|
+
}, [entityRepository.size]);
|
|
452
|
+
return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _jsxruntime.Fragment, { children: [
|
|
453
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, flow_ecs_edge_proxies_default, { nodesToConnect: entityNodes }),
|
|
454
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, flow_ecs_edge_modules_default, { nodesToConnect: entityNodes })
|
|
455
|
+
] });
|
|
456
|
+
}
|
|
457
|
+
var flow_ecs_entities_default = FlowEcsEntities;
|
|
458
|
+
|
|
459
|
+
// src/flow/flow-ecs-modules.tsx
|
|
460
|
+
|
|
461
|
+
|
|
462
|
+
|
|
463
|
+
|
|
464
|
+
function FlowEcsModules() {
|
|
465
|
+
const { nodeFactory } = _react.useContext.call(void 0, _abstract.FlowContext);
|
|
466
|
+
const addNodes = _hooks3.useFlowStore.call(void 0, (state) => state.addNodes);
|
|
467
|
+
const { ecsFlowRepository, systemsModuleRepository } = _react.useContext.call(void 0, EcsFlowContext);
|
|
468
|
+
_react.useEffect.call(void 0, () => {
|
|
469
|
+
const modules = Array.from(systemsModuleRepository.list()).filter((m) => !!m);
|
|
470
|
+
const keys = Array.from(modules.values()).map((v) => v[0]);
|
|
471
|
+
const nodesToAdd = [];
|
|
472
|
+
for (const element of keys) {
|
|
473
|
+
if (ecsFlowRepository.getSystemModuleNode(element)) {
|
|
474
|
+
continue;
|
|
475
|
+
}
|
|
476
|
+
const node = nodeFactory.createNodeFromType("systems-module-node" /* systemsModule */);
|
|
477
|
+
node.data.entityType = element;
|
|
478
|
+
node.position = { x: 0, y: 0 };
|
|
479
|
+
ecsFlowRepository.addSystemModuleNode(node);
|
|
480
|
+
nodesToAdd.push(node);
|
|
481
|
+
}
|
|
482
|
+
if (nodesToAdd.length) {
|
|
483
|
+
addNodes(nodesToAdd);
|
|
484
|
+
}
|
|
485
|
+
}, [systemsModuleRepository.size]);
|
|
486
|
+
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _jsxruntime.Fragment, {});
|
|
487
|
+
}
|
|
488
|
+
var flow_ecs_modules_default = FlowEcsModules;
|
|
489
|
+
|
|
490
|
+
// src/flow/flow-ecs-state.tsx
|
|
491
|
+
|
|
492
|
+
function FlowEcsState(props) {
|
|
493
|
+
const [, setUpdates] = _react.useState.call(void 0, 0);
|
|
494
|
+
const [refreshLayout, setRefreshLayout] = _react.useState.call(void 0, false);
|
|
495
|
+
const { ecsFlowRepository } = _react.useContext.call(void 0, EcsFlowContext);
|
|
496
|
+
_react.useEffect.call(void 0, () => {
|
|
497
|
+
setRefreshLayout(true);
|
|
498
|
+
}, [ecsFlowRepository.sizeNodes]);
|
|
499
|
+
_react.useEffect.call(void 0, () => {
|
|
500
|
+
setInterval(() => {
|
|
501
|
+
setUpdates((updates) => updates + 1);
|
|
502
|
+
}, 1e3);
|
|
503
|
+
}, []);
|
|
504
|
+
return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _jsxruntime.Fragment, { children: [
|
|
505
|
+
props.showSystemModules && /* @__PURE__ */ _jsxruntime.jsx.call(void 0, flow_ecs_modules_default, {}),
|
|
506
|
+
props.showEntities && /* @__PURE__ */ _jsxruntime.jsx.call(void 0, flow_ecs_entities_default, {}),
|
|
507
|
+
props.autoLayout && /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _canvas.FlowAutoLayout, { refreshLayout })
|
|
508
|
+
] });
|
|
509
|
+
}
|
|
510
|
+
var flow_ecs_state_default = _react.memo.call(void 0, FlowEcsState);
|
|
511
|
+
|
|
512
|
+
|
|
513
|
+
|
|
514
|
+
|
|
515
|
+
|
|
516
|
+
|
|
517
|
+
|
|
518
|
+
|
|
519
|
+
|
|
520
|
+
|
|
521
|
+
|
|
522
|
+
|
|
523
|
+
|
|
524
|
+
exports.EcsFlowContext = EcsFlowContext; exports.EcsFlowRepository = EcsFlowRepository; exports.EcsHandleDataType = EcsHandleDataType; exports.EcsNodeType = EcsNodeType; exports.EcsTemplateGroup = EcsTemplateGroup; exports.EntityNode = node_entity_default; exports.EntityNodeTemplate = EntityNodeTemplate; exports.FlowEcsState = flow_ecs_state_default; exports.SystemsModuleNode = node_systems_module_default; exports.SystemsModuleNodeTemplate = SystemsModuleNodeTemplate; exports.ecsNodeTemplates = ecsNodeTemplates; exports.ecsNodeTypes = ecsNodeTypes;
|
package/dist/index.js
CHANGED
|
@@ -1 +1,524 @@
|
|
|
1
|
-
import{createContext as pt}from"react";var s=pt(null);var y=class{static entityProxy(t){return`${t.entityType}:${t.entityUid}`}};var W=class{nodes;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||{});import{NodeContainer as so}from"@awesome-flow/core/layout";import{Badge as mo}from"@mantine/core";import{useContext as ao,useMemo as po}from"react";import{memo as lt,useMemo as yt}from"react";function ct(o){return yt(()=>o.value?.toString().replace(/([a-z])([A-Z])/g,"$1 $2"),[o.value])}var c=lt(ct);import{Accordion as to,Badge as oo,Divider as eo,Group as no}from"@mantine/core";import{Accordion as R,Badge as Tt,Stack as vt}from"@mantine/core";import{memo as Rt}from"react";import{Box as Ct,Button as Pt,Collapse as St}from"@mantine/core";import{useDisclosure as It}from"@mantine/hooks";import{memo as Mt,useMemo as wt}from"react";import{useComputedColorScheme as ut}from"@mantine/core";import{memo as ft,useMemo as Et}from"react";import{Inspector as xt}from"react-inspector";import{jsx as Nt}from"react/jsx-runtime";function gt(o){let t=ut(),e=Et(()=>t==="dark"?"chromeDark":"chromeLight",[t]);return Nt(xt,{table:!1,theme:e,data:o.data})}var G=ft(gt);import{jsx as v,jsxs as ht}from"react/jsx-runtime";function Ft(o){let[t,{toggle:e}]=It(!1),n=wt(()=>t?"light":"indigo",[t]);return ht(Ct,{children:[v(Pt,{variant:"outline",size:"xs",onClick:e,color:n,fullWidth:!0,children:o.component.componentType}),v(St,{in:t,children:t&&v(G,{data:o.component})})]})}var O=Mt(Ft);import{jsx as E,jsxs as bt}from"react/jsx-runtime";function Lt(o){let t=Array.from(o.entity.components.values());return bt(R.Item,{value:"components",children:[E(R.Control,{children:E(Tt,{fullWidth:!0,variant:"light",rightSection:t.length,children:"Components"})}),E(R.Panel,{children:E(vt,{children:t.map((e,n)=>E(O,{component:e},n))})})]},"components")}var $=Rt(Lt);import{Accordion as L,Badge as Ut,Stack as kt}from"@mantine/core";import{memo as zt}from"react";import{Badge as At}from"@mantine/core";import{memo as Bt}from"react";import{jsx as V}from"react/jsx-runtime";function Dt(o){return o.items.map((t,e)=>V(At,{...o.badge||[],children:V(c,{value:t})},e))}var u=Bt(Dt);import{jsx as x,jsxs as Wt}from"react/jsx-runtime";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 Wt(L.Item,{value:"proxies",children:[x(L.Control,{children:x(Ut,{fullWidth:!0,variant:"light",rightSection:e.length,children:"Proxies"})}),x(L.Panel,{children:x(kt,{children:x(u,{items:e,badge:{variant:"outline"}})})})]},"proxies")}var Z=zt(Ht);import{Accordion as b,Badge as Gt,Stack as Ot}from"@mantine/core";import{memo as $t,useContext as Vt}from"react";import{jsx as g,jsxs as qt}from"react/jsx-runtime";function Zt(o){let{entityEventsManager:t}=Vt(s),e=t.getSubscriptionsForEntity(o.entity.myProxy);return qt(b.Item,{value:"subscriptions",children:[g(b.Control,{children:g(Gt,{fullWidth:!0,variant:"light",rightSection:e.length,children:"Events"})}),g(b.Panel,{children:g(Ot,{children:g(u,{items:e,badge:{variant:"outline"}})})})]},"subscriptions")}var q=$t(Zt);import{Badge as J}from"@mantine/core";import{memo as Jt,useContext as Kt,useEffect as Qt,useState as Xt}from"react";import{Fragment as _t,jsx as K,jsxs as jt}from"react/jsx-runtime";function Yt(o){let[,t]=Xt(0),{entityUpdateCounter:e}=Kt(s),n=e.getUpdateCount(o.entityUid)||0,i=e.getRemoveCount(o.entityUid)||0;return Qt(()=>{let r=setInterval(()=>{t(a=>a+1)},1e3);return()=>{console.log("CLEAR INTERVAL"),clearInterval(r)}},[]),jt(_t,{children:[K(J,{variant:"light",children:n}),K(J,{variant:"light",color:"orange",children:i})]})}var Q=Jt(Yt);import{Fragment as io,jsx as f,jsxs as A}from"react/jsx-runtime";function ro({entity:o}){return A(io,{children:[A(no,{children:[f(oo,{variant:"outline",color:"orange",children:o.myProxy.entityUid}),f(Q,{entityUid:o.myProxy.entityUid})]}),f(eo,{my:5}),A(to,{children:[f($,{entity:o}),f(Z,{entity:o}),f(q,{entity:o})]})]})}var X=ro;import{jsx as S}from"react/jsx-runtime";function lo({id:o,data:t,selected:e,type:n}){let{entityRepository:i}=ao(s),r=po(()=>i.get(t.entity),[t.entity]);return S(so,{id:o,selected:e,data:t,title:S(mo,{fullWidth:!0,variant:"transparent",children:S(c,{value:r.myProxy.entityType})}),type:n,children:S(X,{entity:r})})}var B=lo;import{NodeContainer as Po}from"@awesome-flow/core/layout";import{Badge as So}from"@mantine/core";import{useContext as Io}from"react";import{SystemType as I}from"@awesome-ecs/abstract/systems";import{Accordion as Eo,Text as xo}from"@mantine/core";import{useMemo as go}from"react";import{Accordion as D,Badge as yo,Stack as co}from"@mantine/core";import{jsx as N,jsxs as fo}from"react/jsx-runtime";function uo(o){let t=[];o.pipeline&&(t=o.pipeline.middleware);let e=t.map(n=>n.name||n.constructor.name);return fo(D.Item,{value:o.label,children:[N(D.Control,{children:N(yo,{fullWidth:!0,variant:"light",rightSection:e.length,children:o.label})}),N(D.Panel,{children:N(co,{children:N(u,{items:e,badge:{variant:"outline"}})})})]},o.label)}var C=uo;import{Fragment as Co,jsx as M,jsxs as U}from"react/jsx-runtime";function No(o){let{module:t}=o,e=t.runtimeContext,{systemContext:n}=e,{status:i}=go(()=>n.runtime,[n.runtime.status]),r=e.systemPipelines.get(I.initialize),a=e.systemPipelines.get(I.update),m=e.systemPipelines.get(I.render),d=e.systemPipelines.get(I.sync);return U(Co,{children:[U(xo,{children:["Status: ",i]}),U(Eo,{children:[r&&M(C,{pipeline:r,label:"Initialize"}),a&&M(C,{pipeline:a,label:"Update"}),m&&M(C,{pipeline:m,label:"Render"}),d&&M(C,{pipeline:d,label:"Sync"})]})]})}var Y=No;import{jsx as w}from"react/jsx-runtime";function Mo({id:o,data:t,selected:e,type:n}){let{systemsModuleRepository:i}=Io(s),r=i.get(t.entityType);return w(Po,{id:o,selected:e,data:t,title:w(So,{fullWidth:!0,color:"indigo",variant:"transparent",children:w(c,{value:t.entityType})}),type:n,children:w(Y,{type:t.entityType,module:r})})}var k=Mo;import{Position as _}from"@xyflow/react";var z=(t=>(t.ecs="ECS",t))(z||{});var F=class{template={type:"entity-node",group:"ECS",data:{title:"Entity",entity:null},handles:[{dataType:"proxy",position:_.Left,connection:"target",disabled:!0},{dataType:"proxy",position:_.Right,connection:"source",disabled:!0}]}};import{Position as wo}from"@xyflow/react";var h=class{template={type:"systems-module-node",group:"ECS",data:{title:"Systems Module",entityType:null},handles:[{dataType:"module",position:wo.Left,connection:"target",disabled:!0}]}};var P=(e=>(e.systemsModule="systems-module-node",e.entity="entity-node",e))(P||{}),Kn={"systems-module-node":k,"entity-node":B},Qn={"entity-node":new F,"systems-module-node":new h};import{FlowAutoLayout as Yo}from"@awesome-flow/core/canvas";import{memo as _o,useContext as jo,useEffect as st,useState as mt}from"react";import{FlowContext as zo}from"@awesome-flow/core/abstract";import{useFlowStore as Ho}from"@awesome-flow/core/hooks";import{useContext as ot,useEffect as Wo,useState as Go}from"react";import{useFlowStore as Fo}from"@awesome-flow/core/hooks";import{useContext as ho,useEffect as To}from"react";import{Fragment as Ro,jsx as Lo}from"react/jsx-runtime";function vo(o){let{nodesToConnect:t}=o,e=Fo(r=>r.onConnect),{ecsFlowRepository:n,entityRepository:i}=ho(s);return To(()=>{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=d?.data.handles.find(l=>l.connection==="target");p&&e({source:r.id,target:d.id,sourceHandle:a.id,targetHandle:p.id})}},[t]),Lo(Ro,{})}var j=vo;import{useFlowStore as bo}from"@awesome-flow/core/hooks";import{useContext as Ao,useEffect as Bo}from"react";import{Fragment as Uo,jsx as ko}from"react/jsx-runtime";function Do(o){let{nodesToConnect:t}=o,e=bo(r=>r.onConnect),{ecsFlowRepository:n,entityRepository:i}=Ao(s);return Bo(()=>{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]),ko(Uo,{})}var tt=Do;import{Fragment as $o,jsx as et,jsxs as Vo}from"react/jsx-runtime";function Oo(){let{nodeFactory:o}=ot(zo),t=Ho(a=>a.addNodes),{ecsFlowRepository:e,entityRepository:n}=ot(s),[i,r]=Go([]);return Wo(()=>{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]),Vo($o,{children:[et(tt,{nodesToConnect:i}),et(j,{nodesToConnect:i})]})}var nt=Oo;import{FlowContext as Zo}from"@awesome-flow/core/abstract";import{useFlowStore as qo}from"@awesome-flow/core/hooks";import{useContext as rt,useEffect as Jo}from"react";import{Fragment as Qo,jsx as Xo}from"react/jsx-runtime";function Ko(){let{nodeFactory:o}=rt(Zo),t=qo(i=>i.addNodes),{ecsFlowRepository:e,systemsModuleRepository:n}=rt(s);return Jo(()=>{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]),Xo(Qo,{})}var it=Ko;import{Fragment as ee,jsx as H,jsxs as ne}from"react/jsx-runtime";function te(o){let[,t]=mt(0),[e,n]=mt(!1),{ecsFlowRepository:i}=jo(s);return st(()=>{n(!0)},[i.sizeNodes]),st(()=>{setInterval(()=>{t(r=>r+1)},1e3)},[]),ne(ee,{children:[o.showSystemModules&&H(it,{}),o.showEntities&&H(nt,{}),o.autoLayout&&H(Yo,{refreshLayout:e})]})}var oe=_o(te);export{s as EcsFlowContext,W as EcsFlowRepository,T as EcsHandleDataType,P as EcsNodeType,z as EcsTemplateGroup,B as EntityNode,F as EntityNodeTemplate,oe as FlowEcsState,k as SystemsModuleNode,h as SystemsModuleNodeTemplate,Qn as ecsNodeTemplates,Kn as ecsNodeTypes};
|
|
1
|
+
// src/abstract/ecs-flow-context.ts
|
|
2
|
+
import { createContext } from "react";
|
|
3
|
+
var EcsFlowContext = createContext(null);
|
|
4
|
+
|
|
5
|
+
// src/utils/id-generator.ts
|
|
6
|
+
var EcsIdGenerator = class {
|
|
7
|
+
static entityProxy(proxy) {
|
|
8
|
+
return `${proxy.entityType}:${proxy.entityUid}`;
|
|
9
|
+
}
|
|
10
|
+
};
|
|
11
|
+
|
|
12
|
+
// src/abstract/ecs-flow-repository.ts
|
|
13
|
+
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
|
+
}
|
|
36
|
+
};
|
|
37
|
+
|
|
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 { NodeContainer } from "@awesome-flow/core/layout";
|
|
47
|
+
import { Badge as Badge7 } from "@mantine/core";
|
|
48
|
+
import { useContext as useContext3, useMemo as useMemo4 } from "react";
|
|
49
|
+
|
|
50
|
+
// src/components/formatter-camel-case.tsx
|
|
51
|
+
import { memo, useMemo } from "react";
|
|
52
|
+
function CamelCaseFormatter(props) {
|
|
53
|
+
const value = useMemo(
|
|
54
|
+
() => props.value?.toString().replace(/([a-z])([A-Z])/g, "$1 $2"),
|
|
55
|
+
[props.value]
|
|
56
|
+
);
|
|
57
|
+
return value;
|
|
58
|
+
}
|
|
59
|
+
var formatter_camel_case_default = memo(CamelCaseFormatter);
|
|
60
|
+
|
|
61
|
+
// src/layout/entity-layout.tsx
|
|
62
|
+
import { Accordion as Accordion4, Badge as Badge6, Divider, Group } from "@mantine/core";
|
|
63
|
+
|
|
64
|
+
// src/components/entity-component-list.tsx
|
|
65
|
+
import { Accordion, Badge, Stack } from "@mantine/core";
|
|
66
|
+
import { memo as memo4 } from "react";
|
|
67
|
+
|
|
68
|
+
// src/components/entity-component-inspector.tsx
|
|
69
|
+
import { Box, Button, Collapse } from "@mantine/core";
|
|
70
|
+
import { useDisclosure } from "@mantine/hooks";
|
|
71
|
+
import { memo as memo3, useMemo as useMemo3 } from "react";
|
|
72
|
+
|
|
73
|
+
// src/components/object-inspector.tsx
|
|
74
|
+
import { useComputedColorScheme } from "@mantine/core";
|
|
75
|
+
import { memo as memo2, useMemo as useMemo2 } from "react";
|
|
76
|
+
import { Inspector } from "react-inspector";
|
|
77
|
+
import { jsx } from "react/jsx-runtime";
|
|
78
|
+
function ObjectInspector(props) {
|
|
79
|
+
const colorScheme = useComputedColorScheme();
|
|
80
|
+
const theme = useMemo2(
|
|
81
|
+
() => colorScheme === "dark" ? "chromeDark" : "chromeLight",
|
|
82
|
+
[colorScheme]
|
|
83
|
+
);
|
|
84
|
+
return /* @__PURE__ */ jsx(Inspector, { table: false, theme, data: props.data });
|
|
85
|
+
}
|
|
86
|
+
var object_inspector_default = memo2(ObjectInspector);
|
|
87
|
+
|
|
88
|
+
// src/components/entity-component-inspector.tsx
|
|
89
|
+
import { jsx as jsx2, jsxs } from "react/jsx-runtime";
|
|
90
|
+
function EntityComponentInspector(props) {
|
|
91
|
+
const [opened, { toggle }] = useDisclosure(false);
|
|
92
|
+
const buttonColor = useMemo3(() => opened ? "light" : "indigo", [opened]);
|
|
93
|
+
return /* @__PURE__ */ jsxs(Box, { children: [
|
|
94
|
+
/* @__PURE__ */ jsx2(Button, { variant: "outline", size: "xs", onClick: toggle, color: buttonColor, fullWidth: true, children: props.component.componentType }),
|
|
95
|
+
/* @__PURE__ */ jsx2(Collapse, { in: opened, children: opened && /* @__PURE__ */ jsx2(object_inspector_default, { data: props.component }) })
|
|
96
|
+
] });
|
|
97
|
+
}
|
|
98
|
+
var entity_component_inspector_default = memo3(EntityComponentInspector);
|
|
99
|
+
|
|
100
|
+
// src/components/entity-component-list.tsx
|
|
101
|
+
import { jsx as jsx3, jsxs as jsxs2 } from "react/jsx-runtime";
|
|
102
|
+
function EntityComponentList(props) {
|
|
103
|
+
const components = Array.from(props.entity.components.values());
|
|
104
|
+
return /* @__PURE__ */ jsxs2(Accordion.Item, { value: "components", children: [
|
|
105
|
+
/* @__PURE__ */ jsx3(Accordion.Control, { children: /* @__PURE__ */ jsx3(Badge, { fullWidth: true, variant: "light", rightSection: components.length, children: "Components" }) }),
|
|
106
|
+
/* @__PURE__ */ jsx3(Accordion.Panel, { children: /* @__PURE__ */ jsx3(Stack, { children: components.map((c, i) => /* @__PURE__ */ jsx3(entity_component_inspector_default, { component: c }, i)) }) })
|
|
107
|
+
] }, "components");
|
|
108
|
+
}
|
|
109
|
+
var entity_component_list_default = memo4(EntityComponentList);
|
|
110
|
+
|
|
111
|
+
// src/components/entity-proxy-list.tsx
|
|
112
|
+
import { Accordion as Accordion2, Badge as Badge3, Stack as Stack2 } from "@mantine/core";
|
|
113
|
+
import { memo as memo6 } from "react";
|
|
114
|
+
|
|
115
|
+
// src/components/badge-list.tsx
|
|
116
|
+
import { Badge as Badge2 } from "@mantine/core";
|
|
117
|
+
import { memo as memo5 } from "react";
|
|
118
|
+
import { jsx as jsx4 } from "react/jsx-runtime";
|
|
119
|
+
function BadgeList(props) {
|
|
120
|
+
return props.items.map((value, i) => {
|
|
121
|
+
return /* @__PURE__ */ jsx4(Badge2, { ...props.badge || [], children: /* @__PURE__ */ jsx4(formatter_camel_case_default, { value }) }, i);
|
|
122
|
+
});
|
|
123
|
+
}
|
|
124
|
+
var badge_list_default = memo5(BadgeList);
|
|
125
|
+
|
|
126
|
+
// src/components/entity-proxy-list.tsx
|
|
127
|
+
import { jsx as jsx5, jsxs as jsxs3 } from "react/jsx-runtime";
|
|
128
|
+
function EntityProxyList(props) {
|
|
129
|
+
const proxies = Array.from(props.entity.proxies.values()).map((c) => c.values());
|
|
130
|
+
const items = proxies.map((p) => Array.from(p).map((k) => EcsIdGenerator.entityProxy(k))).flat();
|
|
131
|
+
return /* @__PURE__ */ jsxs3(Accordion2.Item, { value: "proxies", children: [
|
|
132
|
+
/* @__PURE__ */ jsx5(Accordion2.Control, { children: /* @__PURE__ */ jsx5(Badge3, { fullWidth: true, variant: "light", rightSection: items.length, children: "Proxies" }) }),
|
|
133
|
+
/* @__PURE__ */ jsx5(Accordion2.Panel, { children: /* @__PURE__ */ jsx5(Stack2, { children: /* @__PURE__ */ jsx5(badge_list_default, { items, badge: { variant: "outline" } }) }) })
|
|
134
|
+
] }, "proxies");
|
|
135
|
+
}
|
|
136
|
+
var entity_proxy_list_default = memo6(EntityProxyList);
|
|
137
|
+
|
|
138
|
+
// src/components/entity-subscription-list.tsx
|
|
139
|
+
import { Accordion as Accordion3, Badge as Badge4, Stack as Stack3 } from "@mantine/core";
|
|
140
|
+
import { memo as memo7, useContext } from "react";
|
|
141
|
+
import { jsx as jsx6, jsxs as jsxs4 } from "react/jsx-runtime";
|
|
142
|
+
function EntitySubscriptionList(props) {
|
|
143
|
+
const { entityEventsManager } = useContext(EcsFlowContext);
|
|
144
|
+
const subscriptions = entityEventsManager.getSubscriptionsForEntity(props.entity.myProxy);
|
|
145
|
+
return /* @__PURE__ */ jsxs4(Accordion3.Item, { value: "subscriptions", children: [
|
|
146
|
+
/* @__PURE__ */ jsx6(Accordion3.Control, { children: /* @__PURE__ */ jsx6(Badge4, { fullWidth: true, variant: "light", rightSection: subscriptions.length, children: "Events" }) }),
|
|
147
|
+
/* @__PURE__ */ jsx6(Accordion3.Panel, { children: /* @__PURE__ */ jsx6(Stack3, { children: /* @__PURE__ */ jsx6(badge_list_default, { items: subscriptions, badge: { variant: "outline" } }) }) })
|
|
148
|
+
] }, "subscriptions");
|
|
149
|
+
}
|
|
150
|
+
var entity_subscription_list_default = memo7(EntitySubscriptionList);
|
|
151
|
+
|
|
152
|
+
// src/components/entity-update-counter.tsx
|
|
153
|
+
import { Badge as Badge5 } from "@mantine/core";
|
|
154
|
+
import { memo as memo8, useContext as useContext2, useEffect, useState } from "react";
|
|
155
|
+
import { Fragment, jsx as jsx7, jsxs as jsxs5 } from "react/jsx-runtime";
|
|
156
|
+
function EntityUpdateCounter(props) {
|
|
157
|
+
const [, setRefresh] = useState(0);
|
|
158
|
+
const { entityUpdateCounter } = useContext2(EcsFlowContext);
|
|
159
|
+
const updates = entityUpdateCounter.getUpdateCount(props.entityUid) || 0;
|
|
160
|
+
const removes = entityUpdateCounter.getRemoveCount(props.entityUid) || 0;
|
|
161
|
+
useEffect(() => {
|
|
162
|
+
const interval = setInterval(() => {
|
|
163
|
+
setRefresh((refresh) => refresh + 1);
|
|
164
|
+
}, 1e3);
|
|
165
|
+
return () => {
|
|
166
|
+
console.log("CLEAR INTERVAL");
|
|
167
|
+
clearInterval(interval);
|
|
168
|
+
};
|
|
169
|
+
}, []);
|
|
170
|
+
return /* @__PURE__ */ jsxs5(Fragment, { children: [
|
|
171
|
+
/* @__PURE__ */ jsx7(Badge5, { variant: "light", children: updates }),
|
|
172
|
+
/* @__PURE__ */ jsx7(Badge5, { variant: "light", color: "orange", children: removes })
|
|
173
|
+
] });
|
|
174
|
+
}
|
|
175
|
+
var entity_update_counter_default = memo8(EntityUpdateCounter);
|
|
176
|
+
|
|
177
|
+
// src/layout/entity-layout.tsx
|
|
178
|
+
import { Fragment as Fragment2, jsx as jsx8, jsxs as jsxs6 } from "react/jsx-runtime";
|
|
179
|
+
function EntityLayout({ entity }) {
|
|
180
|
+
return /* @__PURE__ */ jsxs6(Fragment2, { children: [
|
|
181
|
+
/* @__PURE__ */ jsxs6(Group, { children: [
|
|
182
|
+
/* @__PURE__ */ jsx8(Badge6, { variant: "outline", color: "orange", children: entity.myProxy.entityUid }),
|
|
183
|
+
/* @__PURE__ */ jsx8(entity_update_counter_default, { entityUid: entity.myProxy.entityUid })
|
|
184
|
+
] }),
|
|
185
|
+
/* @__PURE__ */ jsx8(Divider, { my: 5 }),
|
|
186
|
+
/* @__PURE__ */ jsxs6(Accordion4, { children: [
|
|
187
|
+
/* @__PURE__ */ jsx8(entity_component_list_default, { entity }),
|
|
188
|
+
/* @__PURE__ */ jsx8(entity_proxy_list_default, { entity }),
|
|
189
|
+
/* @__PURE__ */ jsx8(entity_subscription_list_default, { entity })
|
|
190
|
+
] })
|
|
191
|
+
] });
|
|
192
|
+
}
|
|
193
|
+
var entity_layout_default = EntityLayout;
|
|
194
|
+
|
|
195
|
+
// src/nodes/node-entity.tsx
|
|
196
|
+
import { jsx as jsx9 } from "react/jsx-runtime";
|
|
197
|
+
function EntityNode({ id, data, selected, type }) {
|
|
198
|
+
const { entityRepository } = useContext3(EcsFlowContext);
|
|
199
|
+
const entity = useMemo4(() => entityRepository.get(data.entity), [data.entity]);
|
|
200
|
+
return /* @__PURE__ */ jsx9(
|
|
201
|
+
NodeContainer,
|
|
202
|
+
{
|
|
203
|
+
id,
|
|
204
|
+
selected,
|
|
205
|
+
data,
|
|
206
|
+
title: /* @__PURE__ */ jsx9(Badge7, { fullWidth: true, variant: "transparent", children: /* @__PURE__ */ jsx9(formatter_camel_case_default, { value: entity.myProxy.entityType }) }),
|
|
207
|
+
type,
|
|
208
|
+
children: /* @__PURE__ */ jsx9(entity_layout_default, { entity })
|
|
209
|
+
}
|
|
210
|
+
);
|
|
211
|
+
}
|
|
212
|
+
var node_entity_default = EntityNode;
|
|
213
|
+
|
|
214
|
+
// src/nodes/node-systems-module.tsx
|
|
215
|
+
import { NodeContainer as NodeContainer2 } from "@awesome-flow/core/layout";
|
|
216
|
+
import { Badge as Badge9 } from "@mantine/core";
|
|
217
|
+
import { useContext as useContext4 } from "react";
|
|
218
|
+
|
|
219
|
+
// src/layout/systems-module-layout.tsx
|
|
220
|
+
import { SystemType } from "@awesome-ecs/abstract/systems";
|
|
221
|
+
import { Accordion as Accordion6, Text } from "@mantine/core";
|
|
222
|
+
import { useMemo as useMemo5 } from "react";
|
|
223
|
+
|
|
224
|
+
// src/components/pipeline-middleware-list.tsx
|
|
225
|
+
import { Accordion as Accordion5, Badge as Badge8, Stack as Stack4 } from "@mantine/core";
|
|
226
|
+
import { jsx as jsx10, jsxs as jsxs7 } from "react/jsx-runtime";
|
|
227
|
+
function PipelineMiddlewareList(props) {
|
|
228
|
+
let middleware = [];
|
|
229
|
+
if (props.pipeline) {
|
|
230
|
+
middleware = props.pipeline["middleware"];
|
|
231
|
+
}
|
|
232
|
+
const components = middleware.map((m) => {
|
|
233
|
+
return m.name || m.constructor.name;
|
|
234
|
+
});
|
|
235
|
+
return /* @__PURE__ */ jsxs7(Accordion5.Item, { value: props.label, children: [
|
|
236
|
+
/* @__PURE__ */ jsx10(Accordion5.Control, { children: /* @__PURE__ */ jsx10(Badge8, { fullWidth: true, variant: "light", rightSection: components.length, children: props.label }) }),
|
|
237
|
+
/* @__PURE__ */ jsx10(Accordion5.Panel, { children: /* @__PURE__ */ jsx10(Stack4, { children: /* @__PURE__ */ jsx10(badge_list_default, { items: components, badge: { variant: "outline" } }) }) })
|
|
238
|
+
] }, props.label);
|
|
239
|
+
}
|
|
240
|
+
var pipeline_middleware_list_default = PipelineMiddlewareList;
|
|
241
|
+
|
|
242
|
+
// src/layout/systems-module-layout.tsx
|
|
243
|
+
import { Fragment as Fragment3, jsx as jsx11, jsxs as jsxs8 } from "react/jsx-runtime";
|
|
244
|
+
function SystemsModuleLayout(props) {
|
|
245
|
+
const { module } = props;
|
|
246
|
+
const runtimeContext = module["runtimeContext"];
|
|
247
|
+
const { systemContext } = runtimeContext;
|
|
248
|
+
const { status } = useMemo5(() => {
|
|
249
|
+
return systemContext.runtime;
|
|
250
|
+
}, [systemContext.runtime.status]);
|
|
251
|
+
const init = runtimeContext.systemPipelines.get(SystemType.initialize);
|
|
252
|
+
const update = runtimeContext.systemPipelines.get(SystemType.update);
|
|
253
|
+
const render = runtimeContext.systemPipelines.get(SystemType.render);
|
|
254
|
+
const sync = runtimeContext.systemPipelines.get(SystemType.sync);
|
|
255
|
+
return /* @__PURE__ */ jsxs8(Fragment3, { children: [
|
|
256
|
+
/* @__PURE__ */ jsxs8(Text, { children: [
|
|
257
|
+
"Status: ",
|
|
258
|
+
status
|
|
259
|
+
] }),
|
|
260
|
+
/* @__PURE__ */ jsxs8(Accordion6, { children: [
|
|
261
|
+
init && /* @__PURE__ */ jsx11(pipeline_middleware_list_default, { pipeline: init, label: "Initialize" }),
|
|
262
|
+
update && /* @__PURE__ */ jsx11(pipeline_middleware_list_default, { pipeline: update, label: "Update" }),
|
|
263
|
+
render && /* @__PURE__ */ jsx11(pipeline_middleware_list_default, { pipeline: render, label: "Render" }),
|
|
264
|
+
sync && /* @__PURE__ */ jsx11(pipeline_middleware_list_default, { pipeline: sync, label: "Sync" })
|
|
265
|
+
] })
|
|
266
|
+
] });
|
|
267
|
+
}
|
|
268
|
+
var systems_module_layout_default = SystemsModuleLayout;
|
|
269
|
+
|
|
270
|
+
// src/nodes/node-systems-module.tsx
|
|
271
|
+
import { jsx as jsx12 } from "react/jsx-runtime";
|
|
272
|
+
function SystemsModuleNode({ id, data, selected, type }) {
|
|
273
|
+
const { systemsModuleRepository } = useContext4(EcsFlowContext);
|
|
274
|
+
const module = systemsModuleRepository.get(data.entityType);
|
|
275
|
+
return /* @__PURE__ */ jsx12(
|
|
276
|
+
NodeContainer2,
|
|
277
|
+
{
|
|
278
|
+
id,
|
|
279
|
+
selected,
|
|
280
|
+
data,
|
|
281
|
+
title: /* @__PURE__ */ jsx12(Badge9, { fullWidth: true, color: "indigo", variant: "transparent", children: /* @__PURE__ */ jsx12(formatter_camel_case_default, { value: data.entityType }) }),
|
|
282
|
+
type,
|
|
283
|
+
children: /* @__PURE__ */ jsx12(systems_module_layout_default, { type: data.entityType, module })
|
|
284
|
+
}
|
|
285
|
+
);
|
|
286
|
+
}
|
|
287
|
+
var node_systems_module_default = SystemsModuleNode;
|
|
288
|
+
|
|
289
|
+
// src/templates/template-entity-node.ts
|
|
290
|
+
import { Position } from "@xyflow/react";
|
|
291
|
+
|
|
292
|
+
// src/abstract/templates.ts
|
|
293
|
+
var EcsTemplateGroup = /* @__PURE__ */ ((EcsTemplateGroup2) => {
|
|
294
|
+
EcsTemplateGroup2["ecs"] = "ECS";
|
|
295
|
+
return EcsTemplateGroup2;
|
|
296
|
+
})(EcsTemplateGroup || {});
|
|
297
|
+
|
|
298
|
+
// src/templates/template-entity-node.ts
|
|
299
|
+
var EntityNodeTemplate = class {
|
|
300
|
+
template = {
|
|
301
|
+
type: "entity-node" /* entity */,
|
|
302
|
+
group: "ECS" /* ecs */,
|
|
303
|
+
data: {
|
|
304
|
+
title: "Entity",
|
|
305
|
+
entity: null
|
|
306
|
+
},
|
|
307
|
+
handles: [
|
|
308
|
+
{
|
|
309
|
+
dataType: "proxy" /* proxy */,
|
|
310
|
+
position: Position.Left,
|
|
311
|
+
connection: "target",
|
|
312
|
+
disabled: true
|
|
313
|
+
},
|
|
314
|
+
{
|
|
315
|
+
dataType: "proxy" /* proxy */,
|
|
316
|
+
position: Position.Right,
|
|
317
|
+
connection: "source",
|
|
318
|
+
disabled: true
|
|
319
|
+
}
|
|
320
|
+
]
|
|
321
|
+
};
|
|
322
|
+
};
|
|
323
|
+
|
|
324
|
+
// src/templates/template-systems-module.ts
|
|
325
|
+
import { Position as Position2 } from "@xyflow/react";
|
|
326
|
+
var SystemsModuleNodeTemplate = class {
|
|
327
|
+
template = {
|
|
328
|
+
type: "systems-module-node" /* systemsModule */,
|
|
329
|
+
group: "ECS" /* ecs */,
|
|
330
|
+
data: {
|
|
331
|
+
title: "Systems Module",
|
|
332
|
+
entityType: null
|
|
333
|
+
},
|
|
334
|
+
handles: [
|
|
335
|
+
{
|
|
336
|
+
dataType: "module" /* module */,
|
|
337
|
+
position: Position2.Left,
|
|
338
|
+
connection: "target",
|
|
339
|
+
disabled: true
|
|
340
|
+
}
|
|
341
|
+
]
|
|
342
|
+
};
|
|
343
|
+
};
|
|
344
|
+
|
|
345
|
+
// src/abstract/node-types.ts
|
|
346
|
+
var EcsNodeType = /* @__PURE__ */ ((EcsNodeType2) => {
|
|
347
|
+
EcsNodeType2["systemsModule"] = "systems-module-node";
|
|
348
|
+
EcsNodeType2["entity"] = "entity-node";
|
|
349
|
+
return EcsNodeType2;
|
|
350
|
+
})(EcsNodeType || {});
|
|
351
|
+
var ecsNodeTypes = {
|
|
352
|
+
["systems-module-node" /* systemsModule */]: node_systems_module_default,
|
|
353
|
+
["entity-node" /* entity */]: node_entity_default
|
|
354
|
+
};
|
|
355
|
+
var ecsNodeTemplates = {
|
|
356
|
+
["entity-node" /* entity */]: new EntityNodeTemplate(),
|
|
357
|
+
["systems-module-node" /* systemsModule */]: new SystemsModuleNodeTemplate()
|
|
358
|
+
};
|
|
359
|
+
|
|
360
|
+
// src/flow/flow-ecs-state.tsx
|
|
361
|
+
import { FlowAutoLayout } from "@awesome-flow/core/canvas";
|
|
362
|
+
import { memo as memo9, useContext as useContext9, useEffect as useEffect6, useState as useState3 } from "react";
|
|
363
|
+
|
|
364
|
+
// src/flow/flow-ecs-entities.tsx
|
|
365
|
+
import { FlowContext } from "@awesome-flow/core/abstract";
|
|
366
|
+
import { useFlowStore as useFlowStore3 } from "@awesome-flow/core/hooks";
|
|
367
|
+
import { useContext as useContext7, useEffect as useEffect4, useState as useState2 } from "react";
|
|
368
|
+
|
|
369
|
+
// src/flow/flow-ecs-edge-modules.tsx
|
|
370
|
+
import { useFlowStore } from "@awesome-flow/core/hooks";
|
|
371
|
+
import { useContext as useContext5, useEffect as useEffect2 } from "react";
|
|
372
|
+
import { Fragment as Fragment4, jsx as jsx13 } from "react/jsx-runtime";
|
|
373
|
+
function FlowEcsEdgeModules(props) {
|
|
374
|
+
const { nodesToConnect } = props;
|
|
375
|
+
const onConnect = useFlowStore((state) => state.onConnect);
|
|
376
|
+
const { ecsFlowRepository, entityRepository } = useContext5(EcsFlowContext);
|
|
377
|
+
useEffect2(() => {
|
|
378
|
+
for (const node of nodesToConnect) {
|
|
379
|
+
const sourceHandle = node.data.handles.find((h) => h.connection === "source");
|
|
380
|
+
const entity = entityRepository.get(node.data.entity);
|
|
381
|
+
const systemModule = ecsFlowRepository.getSystemModuleNode(entity.myProxy.entityType);
|
|
382
|
+
const targetHandle = systemModule?.data.handles.find((h) => h.connection === "target");
|
|
383
|
+
if (targetHandle) {
|
|
384
|
+
onConnect({
|
|
385
|
+
source: node.id,
|
|
386
|
+
target: systemModule.id,
|
|
387
|
+
sourceHandle: sourceHandle.id,
|
|
388
|
+
targetHandle: targetHandle.id
|
|
389
|
+
});
|
|
390
|
+
}
|
|
391
|
+
}
|
|
392
|
+
}, [nodesToConnect]);
|
|
393
|
+
return /* @__PURE__ */ jsx13(Fragment4, {});
|
|
394
|
+
}
|
|
395
|
+
var flow_ecs_edge_modules_default = FlowEcsEdgeModules;
|
|
396
|
+
|
|
397
|
+
// src/flow/flow-ecs-edge-proxies.tsx
|
|
398
|
+
import { useFlowStore as useFlowStore2 } from "@awesome-flow/core/hooks";
|
|
399
|
+
import { useContext as useContext6, useEffect as useEffect3 } from "react";
|
|
400
|
+
import { Fragment as Fragment5, jsx as jsx14 } from "react/jsx-runtime";
|
|
401
|
+
function FlowEcsEdgeProxies(props) {
|
|
402
|
+
const { nodesToConnect } = props;
|
|
403
|
+
const onConnect = useFlowStore2((state) => state.onConnect);
|
|
404
|
+
const { ecsFlowRepository, entityRepository } = useContext6(EcsFlowContext);
|
|
405
|
+
useEffect3(() => {
|
|
406
|
+
for (const node of nodesToConnect) {
|
|
407
|
+
const sourceHandle = node.data.handles.find((h) => h.connection === "source");
|
|
408
|
+
const entity = entityRepository.get(node.data.entity);
|
|
409
|
+
for (const [, proxyMap] of entity.proxies) {
|
|
410
|
+
for (const proxy of proxyMap.values()) {
|
|
411
|
+
const proxyNode = ecsFlowRepository.getEntityNode(proxy);
|
|
412
|
+
if (proxyNode) {
|
|
413
|
+
const targetHandle = proxyNode.data.handles.find((h) => h.connection === "target");
|
|
414
|
+
onConnect({
|
|
415
|
+
source: node.id,
|
|
416
|
+
target: proxyNode.id,
|
|
417
|
+
sourceHandle: sourceHandle.id,
|
|
418
|
+
targetHandle: targetHandle.id
|
|
419
|
+
});
|
|
420
|
+
}
|
|
421
|
+
}
|
|
422
|
+
}
|
|
423
|
+
}
|
|
424
|
+
}, [nodesToConnect]);
|
|
425
|
+
return /* @__PURE__ */ jsx14(Fragment5, {});
|
|
426
|
+
}
|
|
427
|
+
var flow_ecs_edge_proxies_default = FlowEcsEdgeProxies;
|
|
428
|
+
|
|
429
|
+
// src/flow/flow-ecs-entities.tsx
|
|
430
|
+
import { Fragment as Fragment6, jsx as jsx15, jsxs as jsxs9 } from "react/jsx-runtime";
|
|
431
|
+
function FlowEcsEntities() {
|
|
432
|
+
const { nodeFactory } = useContext7(FlowContext);
|
|
433
|
+
const addNodes = useFlowStore3((state) => state.addNodes);
|
|
434
|
+
const { ecsFlowRepository, entityRepository } = useContext7(EcsFlowContext);
|
|
435
|
+
const [entityNodes, setEntityNodes] = useState2([]);
|
|
436
|
+
useEffect4(() => {
|
|
437
|
+
const entities = entityRepository.listAll();
|
|
438
|
+
const nodes = [];
|
|
439
|
+
for (const entity of entities) {
|
|
440
|
+
if (ecsFlowRepository.getEntityNode(entity.myProxy)) {
|
|
441
|
+
continue;
|
|
442
|
+
}
|
|
443
|
+
const node = nodeFactory.createNodeFromType("entity-node" /* entity */);
|
|
444
|
+
node.data.entity = entity.myProxy;
|
|
445
|
+
node.position = { x: 0, y: 0 };
|
|
446
|
+
ecsFlowRepository.addEntityNode(node);
|
|
447
|
+
nodes.push(node);
|
|
448
|
+
}
|
|
449
|
+
setEntityNodes(nodes);
|
|
450
|
+
addNodes(nodes);
|
|
451
|
+
}, [entityRepository.size]);
|
|
452
|
+
return /* @__PURE__ */ jsxs9(Fragment6, { children: [
|
|
453
|
+
/* @__PURE__ */ jsx15(flow_ecs_edge_proxies_default, { nodesToConnect: entityNodes }),
|
|
454
|
+
/* @__PURE__ */ jsx15(flow_ecs_edge_modules_default, { nodesToConnect: entityNodes })
|
|
455
|
+
] });
|
|
456
|
+
}
|
|
457
|
+
var flow_ecs_entities_default = FlowEcsEntities;
|
|
458
|
+
|
|
459
|
+
// src/flow/flow-ecs-modules.tsx
|
|
460
|
+
import { FlowContext as FlowContext2 } from "@awesome-flow/core/abstract";
|
|
461
|
+
import { useFlowStore as useFlowStore4 } from "@awesome-flow/core/hooks";
|
|
462
|
+
import { useContext as useContext8, useEffect as useEffect5 } from "react";
|
|
463
|
+
import { Fragment as Fragment7, jsx as jsx16 } from "react/jsx-runtime";
|
|
464
|
+
function FlowEcsModules() {
|
|
465
|
+
const { nodeFactory } = useContext8(FlowContext2);
|
|
466
|
+
const addNodes = useFlowStore4((state) => state.addNodes);
|
|
467
|
+
const { ecsFlowRepository, systemsModuleRepository } = useContext8(EcsFlowContext);
|
|
468
|
+
useEffect5(() => {
|
|
469
|
+
const modules = Array.from(systemsModuleRepository.list()).filter((m) => !!m);
|
|
470
|
+
const keys = Array.from(modules.values()).map((v) => v[0]);
|
|
471
|
+
const nodesToAdd = [];
|
|
472
|
+
for (const element of keys) {
|
|
473
|
+
if (ecsFlowRepository.getSystemModuleNode(element)) {
|
|
474
|
+
continue;
|
|
475
|
+
}
|
|
476
|
+
const node = nodeFactory.createNodeFromType("systems-module-node" /* systemsModule */);
|
|
477
|
+
node.data.entityType = element;
|
|
478
|
+
node.position = { x: 0, y: 0 };
|
|
479
|
+
ecsFlowRepository.addSystemModuleNode(node);
|
|
480
|
+
nodesToAdd.push(node);
|
|
481
|
+
}
|
|
482
|
+
if (nodesToAdd.length) {
|
|
483
|
+
addNodes(nodesToAdd);
|
|
484
|
+
}
|
|
485
|
+
}, [systemsModuleRepository.size]);
|
|
486
|
+
return /* @__PURE__ */ jsx16(Fragment7, {});
|
|
487
|
+
}
|
|
488
|
+
var flow_ecs_modules_default = FlowEcsModules;
|
|
489
|
+
|
|
490
|
+
// src/flow/flow-ecs-state.tsx
|
|
491
|
+
import { Fragment as Fragment8, jsx as jsx17, jsxs as jsxs10 } from "react/jsx-runtime";
|
|
492
|
+
function FlowEcsState(props) {
|
|
493
|
+
const [, setUpdates] = useState3(0);
|
|
494
|
+
const [refreshLayout, setRefreshLayout] = useState3(false);
|
|
495
|
+
const { ecsFlowRepository } = useContext9(EcsFlowContext);
|
|
496
|
+
useEffect6(() => {
|
|
497
|
+
setRefreshLayout(true);
|
|
498
|
+
}, [ecsFlowRepository.sizeNodes]);
|
|
499
|
+
useEffect6(() => {
|
|
500
|
+
setInterval(() => {
|
|
501
|
+
setUpdates((updates) => updates + 1);
|
|
502
|
+
}, 1e3);
|
|
503
|
+
}, []);
|
|
504
|
+
return /* @__PURE__ */ jsxs10(Fragment8, { children: [
|
|
505
|
+
props.showSystemModules && /* @__PURE__ */ jsx17(flow_ecs_modules_default, {}),
|
|
506
|
+
props.showEntities && /* @__PURE__ */ jsx17(flow_ecs_entities_default, {}),
|
|
507
|
+
props.autoLayout && /* @__PURE__ */ jsx17(FlowAutoLayout, { refreshLayout })
|
|
508
|
+
] });
|
|
509
|
+
}
|
|
510
|
+
var flow_ecs_state_default = memo9(FlowEcsState);
|
|
511
|
+
export {
|
|
512
|
+
EcsFlowContext,
|
|
513
|
+
EcsFlowRepository,
|
|
514
|
+
EcsHandleDataType,
|
|
515
|
+
EcsNodeType,
|
|
516
|
+
EcsTemplateGroup,
|
|
517
|
+
node_entity_default as EntityNode,
|
|
518
|
+
EntityNodeTemplate,
|
|
519
|
+
flow_ecs_state_default as FlowEcsState,
|
|
520
|
+
node_systems_module_default as SystemsModuleNode,
|
|
521
|
+
SystemsModuleNodeTemplate,
|
|
522
|
+
ecsNodeTemplates,
|
|
523
|
+
ecsNodeTypes
|
|
524
|
+
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@awesome-flow/ecs",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.9.0",
|
|
4
4
|
"description": "The ECS package for Awesome Flow. Provides basic components to map Awesome ECS objects.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"scripts": {
|
|
@@ -12,24 +12,30 @@
|
|
|
12
12
|
"ts:watch": "npx tsc --noEmit --incremental --watch"
|
|
13
13
|
},
|
|
14
14
|
"dependencies": {
|
|
15
|
-
"@awesome-
|
|
15
|
+
"@awesome-ecs/abstract": "^0.20.2",
|
|
16
|
+
"@awesome-ecs/core": "^0.20.2",
|
|
17
|
+
"@awesome-flow/core": "^0.9.0",
|
|
18
|
+
"react-inspector": "^6.0.2"
|
|
16
19
|
},
|
|
17
20
|
"peerDependencies": {
|
|
18
|
-
"@
|
|
19
|
-
"@
|
|
20
|
-
"@
|
|
21
|
-
"@
|
|
22
|
-
"@
|
|
23
|
-
"
|
|
24
|
-
"
|
|
25
|
-
"
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
"
|
|
29
|
-
"
|
|
30
|
-
"react
|
|
31
|
-
"
|
|
32
|
-
"
|
|
21
|
+
"@mantine/core": ">=7.13.2",
|
|
22
|
+
"@mantine/hooks": ">=7.13.2",
|
|
23
|
+
"@tabler/icons-react": ">=3.19.0",
|
|
24
|
+
"@xyflow/react": ">=12.3.4",
|
|
25
|
+
"@xyflow/system": ">=0.0.45",
|
|
26
|
+
"react": ">=18.3.1",
|
|
27
|
+
"react-dom": ">=18.3.1",
|
|
28
|
+
"zustand": ">=4.5.5"
|
|
29
|
+
},
|
|
30
|
+
"devDependencies": {
|
|
31
|
+
"@mantine/core": "^7.15.1",
|
|
32
|
+
"@mantine/hooks": "^7.15.1",
|
|
33
|
+
"@tabler/icons-react": "^3.24.0",
|
|
34
|
+
"@xyflow/react": "^12.3.6",
|
|
35
|
+
"@xyflow/system": "^0.0.47",
|
|
36
|
+
"react": "^19.0.0",
|
|
37
|
+
"react-dom": "^19.0.0",
|
|
38
|
+
"zustand": "^5.0.2"
|
|
33
39
|
},
|
|
34
40
|
"exports": {
|
|
35
41
|
".": {
|
|
@@ -70,5 +76,5 @@
|
|
|
70
76
|
"url": "https://github.com/privatebytes/awesome-flow/issues"
|
|
71
77
|
},
|
|
72
78
|
"homepage": "https://github.com/privatebytes/awesome-flow#readme",
|
|
73
|
-
"gitHead": "
|
|
79
|
+
"gitHead": "0f8899f4a093f997ae64eefab07dcc39396bef51"
|
|
74
80
|
}
|