@woosh/meep-engine 2.119.97 → 2.119.99

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/package.json CHANGED
@@ -5,7 +5,7 @@
5
5
  "description": "Fully featured ECS game engine written in JavaScript",
6
6
  "type": "module",
7
7
  "author": "Alexander Goldring",
8
- "version": "2.119.97",
8
+ "version": "2.119.99",
9
9
  "main": "build/meep.module.js",
10
10
  "module": "build/meep.module.js",
11
11
  "exports": {
@@ -1 +1 @@
1
- {"version":3,"file":"convert_node_graph_to_dot_string.d.ts","sourceRoot":"","sources":["../../../../../../src/core/model/node-graph/util/convert_node_graph_to_dot_string.js"],"names":[],"mappings":"AAEA;;;;GAIG;AACH,4DAHW,SAAS,GACP,MAAM,CA6DlB"}
1
+ {"version":3,"file":"convert_node_graph_to_dot_string.d.ts","sourceRoot":"","sources":["../../../../../../src/core/model/node-graph/util/convert_node_graph_to_dot_string.js"],"names":[],"mappings":"AA6BA;;;;GAIG;AACH,4DAHW,SAAS,GACP,MAAM,CAiDlB"}
@@ -1,11 +1,38 @@
1
1
  import LineBuilder from "../../../codegen/LineBuilder.js";
2
2
 
3
+ /**
4
+ *
5
+ * @param {number} id
6
+ * @returns {string}
7
+ */
8
+ function encode_node(id) {
9
+ return `n${id}`;
10
+ }
11
+
12
+ /**
13
+ *
14
+ * @param {number} id
15
+ * @returns {string}
16
+ */
17
+ function encode_port(id) {
18
+ return `p${id}`;
19
+ }
20
+
21
+ /**
22
+ *
23
+ * @param {NodeInstancePortReference} source
24
+ * @returns {string}
25
+ */
26
+ function encode_endpoint(source) {
27
+ return `${encode_node(source.instance.id)}:${encode_port(source.port.id)}`;
28
+ }
29
+
3
30
  /**
4
31
  * Creates a Graphviz diagram from a node graph
5
32
  * @param {NodeGraph} graph
6
33
  * @returns {string}
7
34
  */
8
- export function convert_node_graph_to_dot_string({graph}){
35
+ export function convert_node_graph_to_dot_string({ graph }) {
9
36
  // see https://stackoverflow.com/questions/7922960/block-diagram-layout-with-dot-graphviz
10
37
 
11
38
  const lb = new LineBuilder();
@@ -16,26 +43,13 @@ export function convert_node_graph_to_dot_string({graph}){
16
43
  lb.add('graph [rankdir = LR];')
17
44
  lb.add('node[shape=record];')
18
45
 
19
- function nodeId(index) {
20
- return `n${index}`;
21
- }
22
-
23
- /**
24
- *
25
- * @param index
26
- * @returns {string}
27
- */
28
- function portId(index){
29
- return `p${index}`;
30
- }
31
-
32
46
  /**
33
47
  *
34
48
  * @param {NodeInstancePortReference[]} endpoints
35
49
  * @returns {string}
36
50
  */
37
- function portBlock(endpoints){
38
- return `{${endpoints.map(e => `<${portId(e.port.id)}>${e.port.name}`).join("|")}}`;
51
+ function portBlock(endpoints) {
52
+ return `{${endpoints.map(e => `<${encode_port(e.port.id)}>${e.port.name}`).join("|")}}`;
39
53
  }
40
54
 
41
55
  // populate nodes
@@ -46,7 +60,7 @@ export function convert_node_graph_to_dot_string({graph}){
46
60
  const inputs = portBlock(node.inEndpoints);
47
61
  const outputs = portBlock(node.outEndpoints);
48
62
 
49
- lb.add(`${nodeId(node.id)}[label="${inputs}|${node.description.name}/${node.id}|${outputs}"];`)
63
+ lb.add(`${encode_node(node.id)}[label="{ ${inputs}|${node.description.name}/${node.id}|${outputs} }"];`)
50
64
  }
51
65
 
52
66
  // populate connections
@@ -56,7 +70,8 @@ export function convert_node_graph_to_dot_string({graph}){
56
70
 
57
71
  const source = connection.source;
58
72
  const target = connection.target;
59
- lb.add(`${nodeId(source.instance.id)}:${portId(source.port.id)} -> ${nodeId(source.instance.id)}:${portId(source.port.id)};`);
73
+
74
+ lb.add(`${encode_endpoint(source)} -> ${encode_endpoint(target)};`);
60
75
  }
61
76
 
62
77
  lb.dedent();