sp-svg-diagram 0.1.5 → 0.1.6

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/README.md ADDED
@@ -0,0 +1,23 @@
1
+ SVG Diagram
2
+ ===========
3
+
4
+ ## Overview
5
+
6
+ A library for rendering diagrams to SVG. This library does not provide any automatic layout for nodes and edges.
7
+
8
+ ## Documentation
9
+
10
+ * [Documentation](https://cyberzhg.github.io/SVGDiagram/)
11
+ * [Installation](https://cyberzhg.github.io/SVGDiagram/install.html)
12
+ * [Basic Concepts](https://cyberzhg.github.io/SVGDiagram/concept.html)
13
+ * [Diagram Attributes](https://cyberzhg.github.io/SVGDiagram/diagram_attr.html)
14
+ * [Node Attributes](https://cyberzhg.github.io/SVGDiagram/node_attr.html)
15
+ * [Edge Attributes](https://cyberzhg.github.io/SVGDiagram/edge_attr.html)
16
+ * [Subgraph Attributes](https://cyberzhg.github.io/SVGDiagram/subgraph_attr.html)
17
+
18
+ ## Example
19
+
20
+ ![](https://raw.githubusercontent.com/CyberZHG/SVGDiagram/main/docs/images/example_pentagon.svg)
21
+ ![](https://raw.githubusercontent.com/CyberZHG/SVGDiagram/main/docs/images/example_pentagram.svg)
22
+ ![](https://raw.githubusercontent.com/CyberZHG/SVGDiagram/main/docs/images/example_sequential.svg)
23
+ ![](https://raw.githubusercontent.com/CyberZHG/SVGDiagram/main/docs/images/example_subgraph.svg)
package/index.js CHANGED
@@ -3,7 +3,39 @@ import SVGDiagramWASMModule from './wasm/SVGDiagramWASM.js';
3
3
  import { writeFile } from 'fs/promises';
4
4
 
5
5
  const SVGDiagramWASM = await SVGDiagramWASMModule();
6
+
7
+ /**
8
+ * This function is only for testing.
9
+ *
10
+ * @param {string} expected
11
+ * @param {string} actual
12
+ * @return {boolean} Whether the two SVG strings are equivalent.
13
+ */
6
14
  const _compareSVG = SVGDiagramWASM._compareSVG;
15
+ /**
16
+ * Create an SVGNode.
17
+ *
18
+ * @param {string} nodeID - An unique node ID.
19
+ *
20
+ * @returns {SVGNode} An SVGNode instance.
21
+ */
22
+ const createSVGNode = SVGDiagramWASM.createSVGNode;
23
+ /**
24
+ * Create an SVGEdge.
25
+ *
26
+ * @param {string} edgeID - An unique edge ID.
27
+ *
28
+ * @returns {SVGEdge} An SVGEdge instance.
29
+ */
30
+ const createSVGEdge = SVGDiagramWASM.createSVGEdge;
31
+ /**
32
+ * Create an SVGGraph.
33
+ *
34
+ * @param {string} graphID - An unique graph ID.
35
+ *
36
+ * @returns {SVGGraph} An SVGGraph instance.
37
+ */
38
+ const createSVGGraph = SVGDiagramWASM.createSVGGraph;
7
39
  const SVGDiagram = SVGDiagramWASM.SVGDiagram;
8
40
  const SVGNode = SVGDiagramWASM.SVGNode;
9
41
  const SVGEdge = SVGDiagramWASM.SVGEdge;
@@ -22,8 +54,38 @@ SVGEdge.ARROW_NONE = SVGDiagramWASM.ARROW_SHAPE_NONE;
22
54
  SVGEdge.ARROW_NORMAL = SVGDiagramWASM.ARROW_SHAPE_NORMAL;
23
55
  SVGEdge.ARROW_EMPTY = SVGDiagramWASM.ARROW_SHAPE_EMPTY;
24
56
 
57
+ /**
58
+ * Set the arrow shape at the end point.
59
+ *
60
+ * @param {string} arrowShape - Arrow shape from SVGEdge.ARROW_*
61
+ */
62
+ SVGEdge.prototype.setArrowHead = function (arrowShape = SVGEdge.ARROW_NORMAL) {
63
+ this._setArrowHead(arrowShape);
64
+ };
65
+ /**
66
+ * Set the arrow shape at the start point.
67
+ *
68
+ * @param {string} arrowShape - Arrow shape from SVGEdge.ARROW_*
69
+ */
70
+ SVGEdge.prototype.setArrowTail = function (arrowShape = SVGEdge.ARROW_NORMAL) {
71
+ this._setArrowTail(arrowShape);
72
+ };
73
+ /**
74
+ * Generate SVG and save to a local file.
75
+ *
76
+ * @param {string} file_path - Output file path.
77
+ */
25
78
  SVGDiagram.prototype.toSVG = async function(file_path) {
26
79
  await writeFile(file_path, this.render());
27
80
  };
28
81
 
29
- export { _compareSVG, SVGDiagram, SVGNode, SVGEdge, SVGGraph };
82
+ export {
83
+ _compareSVG,
84
+ createSVGNode,
85
+ createSVGEdge,
86
+ createSVGGraph,
87
+ SVGDiagram,
88
+ SVGNode,
89
+ SVGEdge,
90
+ SVGGraph,
91
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "sp-svg-diagram",
3
- "version": "0.1.5",
3
+ "version": "0.1.6",
4
4
  "type": "module",
5
5
  "main": "index.js",
6
6
  "files": [
Binary file