@gregoriusrippenstein/node-red-contrib-introspection 0.0.1 → 0.0.3
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 +1 -1
- package/nodes/15-screenshot.html +39 -23
- package/package.json +2 -2
- package/README (Autosaved).md +0 -71
package/README.md
CHANGED
|
@@ -58,7 +58,7 @@ There is a single example flow contained in the package. There are also examples
|
|
|
58
58
|
- [Seeker](https://demo.openmindmap.org/omm/#flow/40ea5f2aea6592ae) - top left and the [Sink](https://demo.openmindmap.org/omm/#flow/459c271a96458c7c) - top right
|
|
59
59
|
- [Screenshot](https://demo.openmindmap.org/omm/#flow/4e2d8c13066b705e) - top left
|
|
60
60
|
|
|
61
|
-
Example screenshot:
|
|
61
|
+
Example screenshot:
|
|
62
62
|
|
|
63
63
|

|
|
64
64
|
|
package/nodes/15-screenshot.html
CHANGED
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
value:"",
|
|
10
10
|
},
|
|
11
11
|
screenshot: {
|
|
12
|
-
value:"
|
|
12
|
+
value:""
|
|
13
13
|
},
|
|
14
14
|
},
|
|
15
15
|
inputs:0,
|
|
@@ -52,14 +52,18 @@
|
|
|
52
52
|
value: $("#node-input-screenshot").val()
|
|
53
53
|
});
|
|
54
54
|
|
|
55
|
-
|
|
56
|
-
'width="' + $($('svg')[0]).attr('width') + '" height="' +
|
|
57
|
-
$($('svg')[0]).attr('height') + '"'
|
|
58
|
-
);
|
|
55
|
+
this.editor.setValue( "Please wait, screenshot being prepared ..." );
|
|
59
56
|
|
|
60
57
|
//
|
|
61
58
|
// begin the SVG conversion code.
|
|
62
59
|
//
|
|
60
|
+
var origSvg = $($('svg')[0]);
|
|
61
|
+
|
|
62
|
+
var hwAttrs = (
|
|
63
|
+
'width="' + origSvg.attr('width') + '" height="' +
|
|
64
|
+
origSvg.attr('height') + '"'
|
|
65
|
+
);
|
|
66
|
+
|
|
63
67
|
var svgHeader = (
|
|
64
68
|
'<?xml version="1.0" standalone="no"?>\r\n' +
|
|
65
69
|
'<svg ' + hwAttrs + ' pointer-events="all" style="cursor: crosshair; '+
|
|
@@ -67,7 +71,7 @@
|
|
|
67
71
|
'xmlns:xlink="http://www.w3.org/1999/xlink">\r\n'
|
|
68
72
|
);
|
|
69
73
|
|
|
70
|
-
var svgBody =
|
|
74
|
+
var svgBody = origSvg.html();
|
|
71
75
|
|
|
72
76
|
var parser = new DOMParser();
|
|
73
77
|
var doc = parser.parseFromString(svgHeader + svgBody + '\r\n</svg>',
|
|
@@ -99,23 +103,28 @@
|
|
|
99
103
|
// Set everything that might have been set via CSS directly on the
|
|
100
104
|
// element. All styling values must be defined as attributes on the
|
|
101
105
|
// SVG element.
|
|
102
|
-
var convertCssToAttr = function( collection ) {
|
|
106
|
+
var convertCssToAttr = function( collection, origElems ) {
|
|
103
107
|
for ( var idx = 0; idx < collection.length; idx++ ) {
|
|
104
108
|
var elem = collection.item(idx);
|
|
105
|
-
|
|
109
|
+
var origElem = origElems[idx];
|
|
110
|
+
|
|
111
|
+
[
|
|
112
|
+
"fill", "stroke"
|
|
113
|
+
].forEach( function(attrname) {
|
|
106
114
|
elem.setAttribute(attrname,
|
|
107
|
-
rgb2hex($(
|
|
108
|
-
$(
|
|
115
|
+
rgb2hex($(origElem).attr(attrname) ||
|
|
116
|
+
$(origElem).css(attrname) ));
|
|
109
117
|
});
|
|
110
118
|
|
|
111
119
|
[
|
|
112
120
|
"stroke-width","fill-opacity","stroke-opacity","opacity"
|
|
113
121
|
].forEach(function(attrname) {
|
|
114
122
|
elem.setAttribute(attrname,
|
|
115
|
-
$(
|
|
123
|
+
$(origElem).attr(attrname) ||
|
|
124
|
+
$(origElem).css(attrname));
|
|
116
125
|
});
|
|
117
126
|
|
|
118
|
-
if ( $(
|
|
127
|
+
if ( $(origElem).hasClass('hide') ) {
|
|
119
128
|
if ( elem.tagName == "g" ) {
|
|
120
129
|
// according to the SVG standard, visibility cannot be applied
|
|
121
130
|
// (or better said: has no effect) on 'g' (group) elements.
|
|
@@ -130,28 +139,35 @@
|
|
|
130
139
|
}
|
|
131
140
|
|
|
132
141
|
// include font details on the text elements.
|
|
133
|
-
var convertFontsToAttr = function( collection ) {
|
|
142
|
+
var convertFontsToAttr = function( collection, origElems ) {
|
|
134
143
|
for ( var idx = 0; idx < collection.length; idx++ ) {
|
|
135
144
|
var elem = collection.item(idx);
|
|
145
|
+
var origElem = origElems[idx];
|
|
146
|
+
|
|
136
147
|
["font-family", "font-size", "font-size-adjust", "font-stretch",
|
|
137
148
|
"font-style", "font-variant", "font-weight"
|
|
138
149
|
].forEach( function(attrname) {
|
|
139
150
|
elem.setAttribute(attrname,
|
|
140
|
-
$(
|
|
151
|
+
$(origElem).attr(attrname) ||
|
|
152
|
+
$(origElem).css(attrname) );
|
|
141
153
|
})
|
|
142
154
|
}
|
|
143
155
|
}
|
|
144
156
|
|
|
145
157
|
// probably missed some elements ...
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
158
|
+
var tagnames = [ "g", "rect", "line", "path", "circle", "image" ];
|
|
159
|
+
tagnames.forEach( function(tagname) {
|
|
160
|
+
convertCssToAttr(doc.getElementsByTagName(tagname),
|
|
161
|
+
origSvg.find(tagname));
|
|
162
|
+
});
|
|
163
|
+
|
|
164
|
+
[ "text" ].forEach( function(tagname) {
|
|
165
|
+
convertCssToAttr(doc.getElementsByTagName(tagname),
|
|
166
|
+
origSvg.find(tagname));
|
|
167
|
+
|
|
168
|
+
convertFontsToAttr(doc.getElementsByTagName(tagname),
|
|
169
|
+
origSvg.find(tagname));
|
|
170
|
+
});
|
|
155
171
|
|
|
156
172
|
// inline image data. Image types supported: Jpeg, Png and Svg.
|
|
157
173
|
var imageColl = doc.getElementsByTagName("image");
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@gregoriusrippenstein/node-red-contrib-introspection",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.3",
|
|
4
4
|
"keywords": [
|
|
5
5
|
"node-red"
|
|
6
6
|
],
|
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
"license": "SEE LICENSE IN https://github.com/gorenje/node-red-contrib-introspection/blob/main/LICENSE",
|
|
9
9
|
"author": "Gerrit Riessen <nodered@spreads-the.love> (https://spread-the.love)",
|
|
10
10
|
"engines": {
|
|
11
|
-
"node": ">=
|
|
11
|
+
"node": ">=6"
|
|
12
12
|
},
|
|
13
13
|
"node-red": {
|
|
14
14
|
"version": ">=2.0.0",
|
package/README (Autosaved).md
DELETED
|
@@ -1,71 +0,0 @@
|
|
|
1
|
-
# Node-RED Introspection Nodes
|
|
2
|
-
|
|
3
|
-
This is a collection of editor-only Node-RED nodes. Editor-only since they do not have any affect nor application on the server side, these nodes solely work within the editor, that is, the browser environment.
|
|
4
|
-
|
|
5
|
-
## Why?
|
|
6
|
-
|
|
7
|
-
The Node-RED editor is a powerful beast with many abilities, why not use them? Why not make use of those possibilities and create a set of introspection nodes, a form of visual linting before deployment. The editor already does syntax checking before deployment, why limit it to just that?
|
|
8
|
-
|
|
9
|
-
I found myself working on various flows and found some particular artistic but I wanted to scale them to poster size, hence I needed an SVG dump. Having not found what I was looking for, I created my own Screenshot node.
|
|
10
|
-
|
|
11
|
-
Orphans node many or many not have their reasons, sometimes nodes aren't meant to be there and can actually be deleted. Either way, nodes that have no connections, either in nor out, *might* no longer be needed. For me, orphan nodes represent commented-out code or code that can't be reached, so they potentially represent nostalgia, a nostalgia for coding ideas that are no longer valid.
|
|
12
|
-
|
|
13
|
-
Sometimes I found myself having extremely complex flows, flows that went over multiple tabs via the link-in/out nodes. I was lost as to how specific nodes were ever reached. The birth of the Sink & Seeker nodes was inevitable.
|
|
14
|
-
|
|
15
|
-
## Nodes
|
|
16
|
-
|
|
17
|
-
All nodes are editor-only which means that are triggered by double clicking on them (once they have been dragged into a flow) to open the tray. The tray then shows the fulfilment of their purpose.
|
|
18
|
-
|
|
19
|
-
There is no need nor requirement to deploy these nodes. Which implies that they also work in read-only mode of Node-RED. Since these nodes only provide information and make no changes, this should not be an issue.
|
|
20
|
-
|
|
21
|
-
### Orphans
|
|
22
|
-
|
|
23
|
-
Drag the Orphan node into a flow, double click and all nodes that have no connections are shown in the tray. Click on a node to highlight its location in the flow.
|
|
24
|
-
|
|
25
|
-
The nodes shown are across all flows and tabs, there is no need to have a Orphans node per flow.
|
|
26
|
-
|
|
27
|
-
### Sink & Seeker
|
|
28
|
-
|
|
29
|
-
Place the sink node at the end of a any flow, the point that needs to be reached. Place the seeker at the starting point. Double click on the seeker to open the tray and all possible paths (if there are any) between it and the sink are shown.
|
|
30
|
-
|
|
31
|
-
Double click on the top-level node and all nodes in the pathway are highlighted. Opening the top-level node shows all nodes along the path. Clicking on a node will highlight that node in flow.
|
|
32
|
-
|
|
33
|
-
### Screenshot
|
|
34
|
-
|
|
35
|
-
Drag the node into a flow, double-click on the node and the tray opens -depending on the size of the flow, this might take a moment. Once the tray is opened, the SVG is shown in the editor window (I took the code from the template node hence the syntax dropdown). Below the editor window is the download button. Pressing that will download the SVG as it is in the editor window, so making changes in that window will be reflected in the downloaded content.
|
|
36
|
-
|
|
37
|
-
The SVG code can also be copied and pasted into something like [drawsvg.org](https://drawsvg.org/drawsvg.html) hence select-all-copy-paste is provide by having the editor window.
|
|
38
|
-
|
|
39
|
-
Improvements over [svgexport.io](https://svgexport.io) browser plugin:
|
|
40
|
-
|
|
41
|
-
- Respects the 'hide' CSS class that is used to hide specific elements, this the svgexport plugin cannot know.
|
|
42
|
-
- Compliments the setting of visibility on the 'g' element with opacity=0. The SVG Standard ignores visibility on 'g' elements but browsers don't seem to care, Inkscape does care.
|
|
43
|
-
- Image data (i.e. icons) is inlined using `data:image/XXXX;base64,` - this is good for things such as Inkscape that can't resolve relative urls. PNG, JPEG and SVG are supported.
|
|
44
|
-
- It also retrieves font details and includes them in the SVG. This makes the font italic, even if it's not the correct font family (because font might not be installed on system).
|
|
45
|
-
|
|
46
|
-
Disappointments:
|
|
47
|
-
|
|
48
|
-
- Font-awesome icons, because they use the font-awesome font, aren't inlined and therefore aren't available in external tools (but are visible if SVG opened in browser). If the font-awesome fonts are installed on the system icons do work in Inkscape.
|
|
49
|
-
- Because a double click is required, any highlights in the workflow are lost (i.e. link-in/out highlights showing the other tab names disappears)
|
|
50
|
-
- Limited testing: on Firefox (on mac), your mileage might vary
|
|
51
|
-
- No error checking - network requests are assumed to work
|
|
52
|
-
|
|
53
|
-
## Examples
|
|
54
|
-
|
|
55
|
-
There is a single example flow contained in the package. There are also examples to be found online:
|
|
56
|
-
|
|
57
|
-
- [Orphans](https://demo.openmindmap.org/omm/#flow/3ebb65fdbecb182e) - node is top left of flow or search for `type:Orphans`
|
|
58
|
-
- [Seeker](https://demo.openmindmap.org/omm/#flow/40ea5f2aea6592ae) - top left and the [Sink](https://demo.openmindmap.org/omm/#flow/459c271a96458c7c) - top right
|
|
59
|
-
- [Screenshot](https://demo.openmindmap.org/omm/#flow/4e2d8c13066b705e) - top left
|
|
60
|
-
|
|
61
|
-
Example screenshot:
|
|
62
|
-
|
|
63
|
-

|
|
64
|
-
|
|
65
|
-
## License
|
|
66
|
-
|
|
67
|
-
[Do whatever but don't do evil](/LICENSE)
|
|
68
|
-
|
|
69
|
-
## Contribution & Ideas
|
|
70
|
-
|
|
71
|
-
Please here at GitHub via issues.
|