@gregoriusrippenstein/node-red-contrib-introspection 0.6.11 → 0.6.12
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 +1 -1
- package/plugins/sidebar.html +82 -4
package/package.json
CHANGED
package/plugins/sidebar.html
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
(function() {
|
|
3
3
|
var globalRefToSvgData;
|
|
4
4
|
|
|
5
|
-
let obfuscateHelpers={getFlowDataFromCurrentWorkspace:e=>{var e=e||RED.workspaces.active(),t=RED.nodes.groups(e),e=(t=(t=t.concat(RED.nodes.junctions(e))).concat(RED.nodes.filterNodes({z:e})),RED.nodes.eachConfig(function(e){e.z===RED.workspaces.active()&&!1===e._def.hasUsers&&t.push(e)}),RED.nodes.workspace(e)||RED.nodes.subflow(e));return t.unshift(e),RED.nodes.createExportableNodeSet(t)},openImportDialog:e=>{RED.clipboard.import();let t=e;setTimeout(()=>{$("#red-ui-clipboard-dialog-import-text").val(JSON.stringify(t)).trigger("paste")},300)}};function obfuscatieCurrentFlow(t){let a=obfuscateHelpers.getFlowDataFromCurrentWorkspace(),l=(t.remove_groups&&(a=a.filter(e=>"group"!=e.type)).forEach(e=>{delete e.g}),{}),r={},p={},f={},
|
|
5
|
+
let obfuscateHelpers={getFlowDataFromCurrentWorkspace:e=>{var e=e||RED.workspaces.active(),t=RED.nodes.groups(e),e=(t=(t=t.concat(RED.nodes.junctions(e))).concat(RED.nodes.filterNodes({z:e})),RED.nodes.eachConfig(function(e){e.z===RED.workspaces.active()&&!1===e._def.hasUsers&&t.push(e)}),RED.nodes.workspace(e)||RED.nodes.subflow(e));return t.unshift(e),RED.nodes.createExportableNodeSet(t)},openImportDialog:e=>{RED.clipboard.import();let t=e;setTimeout(()=>{$("#red-ui-clipboard-dialog-import-text").val(JSON.stringify(t)).trigger("paste")},300)}};function obfuscatieCurrentFlow(t){let a=obfuscateHelpers.getFlowDataFromCurrentWorkspace(),l=(t.remove_groups&&(a=a.filter(e=>"group"!=e.type)).forEach(e=>{delete e.g}),{}),r={},p={},f={},s=[],d={},o={};if(a.forEach(e=>{"subflow"==(l[e.id]=e).type&&(o[e.id]=e),"junction"==e.type&&(r[e.id]=e),"link out"==e.type&&(f[e.id]=e),"link in"==e.type&&(p[e.id]=e),"link call"==e.type&&s.push(e.id),"catch"==e.type&&(d[e.id]=(e.wires||[])[0]||[])}),t.remove_junctions&&(Object.keys(r).forEach(n=>{let s=r[n];o[s.z]||a.forEach(t=>{for(let e=0;e<(t.wires||[]).length;e++){var r=t.wires[e].indexOf(n);-1<r&&(t.wires[e].splice(r,1),t.wires[e].push(...s.wires[0]))}})}),a=a.filter(e=>!("junction"==e.type&&!o[e.z]))),t.remove_linkout_nodes||t.remove_linkcall_nodes){let n=[],r=[],u=[],i=(t.remove_linkout_nodes&&!t.copy_linkin_nodes&&Object.keys(f).forEach(s=>{var e=f[s],t=e.links||[];t.reduce((e,t)=>e&&!!p[t],!0)&&"return"!=e.mode&&(n.push(s),t.forEach(n=>{a.forEach(t=>{for(let e=0;e<(t.wires||[]).length;e++){var r=t.wires[e].indexOf(s);-1<r&&(t.wires[e].splice(r,1),t.wires[e].push(...p[n].wires[0]))}})}))}),(s,e)=>{if(!e)return!1;let t=[],o=[],r=[];function u(e){if(r.indexOf(e.id)<0)switch(r.push(e.id),t.push(e),e.type){case"link out":if("return"!=e.mode)throw"not handable";break;case"link call":throw"unhandled";default:RED.nodes.getNodeLinks(e).forEach(function(e){u(e.target)})}}try{RED.nodes.getNodeLinks(e).forEach(function(e){u(e.target),o.push(e.target.id)});if(Object.keys(d).forEach(e=>{((t,e)=>{try{return e.map(e=>e.id).forEach(e=>{if(t.includes(e))throw"yes"}),!1}catch(e){return!0}})(d[e],t)&&t.push(l[e])}),0==t.length)return!1;let r={};var i=t[0];let n={x:s.x-i.x,y:s.y-i.y};var a=t.map(e=>{var t=structuredClone(l[e.id]);return t||console.log("WARNING: nodeid not found",[e.id,l[e.id]]),t.id=RED.nodes.id(),t.x+=n.x,t.y+=n.y,r[e.id]=t});return a.forEach(e=>{"catch"==e.type&&Array.isArray(e.scope)&&(e.scope=e.scope.map(e=>{var t=r[e];return t&&t.id||e})),e.wires&&(e.wires=e.wires.map(e=>e.map(e=>{var t=r[e];return t&&"link out"==t.type?[...s.wires[0],(t||{}).id||e]:(t||{}).id||e}).flat()))}),{nodes:a.filter(e=>"link out"!=e.type),entryNodes:o.map(e=>r[e])}}catch(e){return!1}});t.remove_linkout_nodes&&t.copy_linkin_nodes&&Object.keys(f).forEach(o=>{let r=f[o];var e=r.links||[];"return"!=r.mode&&(e=e.map(e=>{var t=p[e],t=i(r,t);if(t)return[e,t]})).reduce((e,t)=>e&&!!t,!0)&&(n.push(o),e.forEach(([,s])=>{a.forEach(t=>{for(let e=0;e<(t.wires||[]).length;e++){var r,n=t.wires[e].indexOf(o);-1<n&&(r=s.entryNodes.map(e=>e.id),t.wires[e].splice(n,1),t.wires[e].push(...r),u.push(...s.nodes))}})}))}),t.remove_linkcall_nodes&&s.forEach(s=>{var e=l[s],t=p[e.links[0]];let o=i(e,t);t&&o&&(r.push(e.id),a.forEach(t=>{for(let e=0;e<(t.wires||[]).length;e++){var r,n=t.wires[e].indexOf(s);-1<n&&(r=o.entryNodes.map(e=>e.id),t.wires[e].splice(n,1),t.wires[e].push(...r),u.push(...o.nodes))}}))}),(a=a.filter(e=>n.indexOf(e.id)<0&&r.indexOf(e.id)<0)).push(...u)}if((a=t.remove_debugs?a.filter(e=>"debug"!=e.type&&"comment"!=e.type):a).forEach(e=>{t.name&&(e.name=RED.nodes.id()),t.shrink_node&&(e.l=!1),t.info&&(e.info="",delete e.outputLabels,delete e.inputLabels),t.add_license&&(t.append_license?e.info=(e.info||"")+"\n---\n\n"+t.license_text:e.info=t.license_text),t.position&&(e.x=150,e.y=150),t.remove_icons&&delete e.icon}),t.replace_switch){let n=(t,r)=>{for(let e=0;e<r.rules.length;e++){var n=r.rules[e];if("nnull"==n.t)t.push("if ( _propValue != null ) { _returnValue.push(msg) ; return node.send(_returnValue) } else { _returnValue.push(undefined) }");else if("null"==n.t)t.push("if ( _propValue == null ) { _returnValue.push(msg) ; return node.send(_returnValue) } else { _returnValue.push(undefined) }");else if("eq"==n.t&&"str"==n.vt){s=n.v;s=btoa(encodeURIComponent(s).replace(/%([0-9A-F]{2})/g,function(e,t){return String.fromCharCode("0x"+t)}));t.push("if ( _propValue === Buffer.from('"+s+"', 'base64').toString('utf-8') ) { _returnValue.push(msg) ; return node.send(_returnValue) } else { _returnValue.push(undefined) }")}else if("gt"==n.t&&"num"==n.vt)t.push("if ( _propValue > "+n.v+" ) { _returnValue.push(msg) ; return node.send(_returnValue) } else { _returnValue.push(undefined) }");else if("eq"==n.t&&"num"==n.vt)t.push("if ( _propValue == "+n.v+" ) { _returnValue.push(msg) ; return node.send(_returnValue) } else { _returnValue.push(undefined) }");else if("empty"==n.t)t.push('let p = _propValue ; if ( (Array.isArray(p) && p.length == 0) || ((typeof p === "object") && p != null && Object.keys(p).length == 0) || ((typeof p === "string") && p.length == 0) ) { _returnValue.push(msg) ; return node.send(_returnValue) } else { _returnValue.push(undefined) }');else if("nempty"==n.t)t.push('let p = _propValue ; if ( (Array.isArray(p) && p.length > 0) || ((typeof p === "object") && p != null && Object.keys(p).length > 0) || ((typeof p === "string") && p.length > 0) ) { _returnValue.push(msg) ; return node.send(_returnValue) } else { _returnValue.push(undefined) }');else{if("else"!=n.t)throw"unhandled";t.push("_returnValue.push(msg)","return node.send(_returnValue)")}}var s};a=a.map(t=>{if("switch"!=t.type)return t;var e={id:t.id,name:t.name,type:"function",x:t.x,y:t.y,func:"",outputs:t.outputs,timeout:"",noerr:0,initialize:"",finalize:"",libs:[{var:"process",module:"process"},{var:"jsonata",module:"jsonata"}],wires:t.wires};t.hasOwnProperty("z")&&(e.z=t.z),t.hasOwnProperty("l")&&(e.l=t.l);try{var r=[];if(t.checkAll)throw"unhandled";if("msg"==t.propertyType)r.push("((msg,node) => {","let _propValue = undefined","try { _propValue = RED.util.getMessageProperty(msg, '"+t.property+"') } catch (ex) {}","let _returnValue = []"),n(r,t),r.push("})(msg,node);");else{if("jsonata"!=t.propertyType)throw"unhandled";r.push("jsonata('"+t.property+"').evaluate(msg).then(_propValue => {","let _returnValue = []"),n(r,t),r.push("})")}return e.func=r.join("\n"),e}catch(e){return t}})}if(t.replace_change){let s=e=>btoa(encodeURIComponent(e).replace(/%([0-9A-F]{2})/g,function(e,t){return String.fromCharCode("0x"+t)}));a=a.map(t=>{if("change"!=t.type)return t;var e={id:t.id,name:t.name,type:"function",x:t.x,y:t.y,func:"",outputs:1,timeout:"",noerr:0,initialize:"",finalize:"",libs:[{var:"process",module:"process"},{var:"jsonata",module:"jsonata"}],wires:t.wires};t.hasOwnProperty("z")&&(e.z=t.z),t.hasOwnProperty("l")&&(e.l=t.l);try{var r=["(async (msg,node) => {","let __s = RED.util.setMessageProperty","let __g = RED.util.getMessageProperty"];for(let e=0;e<t.rules.length;e++){var n=t.rules[e];if("set"==n.t){if(n.dc)throw"unhandled";if("msg"==n.pt&&"str"==n.tot)r.push("__s(msg,'"+n.p+"', Buffer.from('"+s(n.to)+"', 'base64').toString('utf-8') )");else if("msg"==n.pt&&"bool"==n.tot)r.push("__s(msg,'"+n.p+"', "+n.to+")");else if("msg"==n.pt&&"num"==n.tot)r.push("__s(msg,'"+n.p+"', Number(Buffer.from('"+s(n.to)+"', 'base64').toString('utf-8')))");else if("msg"==n.pt&&"json"==n.tot)r.push("__s(msg,'"+n.p+"', JSON.parse(Buffer.from('"+s(n.to)+"', 'base64').toString('utf-8')))");else if("msg"==n.pt&&"msg"==n.tot)r.push("try { __s(msg,'"+n.p+"', __g(msg, '"+n.to+"')) } catch (ex) {}");else if("msg"==n.pt&&"env"==n.tot)r.push("__s(msg,'"+n.p+"', process.env['"+n.to+"'])");else{if("msg"!=n.pt||"jsonata"!=n.tot||!n.to.startsWith("/* @obfuscate-safe */"))throw"unhandlable";r.push("__s(msg,'"+n.p+"', await jsonata(Buffer.from('"+s(n.to)+"', 'base64').toString('utf-8')).evaluate(msg) )")}}else{if("delete"!=n.t||"msg"!=n.pt)throw"unhandlable";r.push("delete msg."+n.p)}}return r.push("node.send(msg) })(msg,node);"),e.func=r.join("\n"),e}catch(e){return console.log(e),t}})}if(t.javascript){let r={},t=[];a.forEach(e=>{"javascript"!=(r[e.id]=e).format&&"function"!=e.type&&"css"!=e.format&&"json"!=e.format||t.push(e)});var e={parse:{bare_returns:!0,expression:!1},compress:{},mangle:{reserved:["$","export","require"]},output:null,sourceMap:null,nameCache:null,toplevel:!1,warnings:!1},u={compatibility:"*",level:2};$.ajax({url:"ClientCode/"+RED.nodes.id()+"/ugify",type:"POST",contentType:"application/json; charset=utf-8",data:JSON.stringify({nodes:t,jscfg:e,csscfg:u}),success:function(e){e.forEach(e=>{var t=r[e.id];e._error&&console.log("ERROR NODE",e),"function"==t.type?t.func=e.func:"javascript"!=t.format&&"css"!=t.format&&"json"!=t.format||(t.template=e.template)}),obfuscateHelpers.openImportDialog(a)},error:function(e,t,r){RED.notify("ClientCode Communcation Failure: "+n.id+": "+t,{type:"error",timeout:3e3})}})}else obfuscateHelpers.openImportDialog(a)}
|
|
6
6
|
|
|
7
7
|
function setupTreelist(){var e=collectOrphans();if(0==e.length){RED.notify("No Orphans Found",{type:"warning",timeout:2e3});try{$("#node-input-orphan-target-container-div").treeList("empty")}catch(e){}}else{try{$("#node-input-orphan-target-container-div").treeList("empty")}catch(e){$("#node-input-orphan-target-container-div").css({width:"100%",height:"calc(100%)"}).treeList({multi:!1}).on("treelistitemmouseover",function(e,t){}).on("treelistitemmouseout",function(e,t){}).on("treelistselect",function(e,t){t.node&&(RED.workspaces.show(t.node.z,!1,!1,!0),RED.view.reveal(t.node.id,!0),RED.view.redraw())}).on("treelistconfirm",function(e,t){var n;t.node&&(n=t.node.id,setTimeout(()=>{var e=RED.nodes.node(n);e&&(RED.view.reveal(e.id),RED.view.select(e.id),RED.editor.edit(e)),n==RED.workspaces.active()&&RED.workspaces.edit()},50))}),$("#node-input-orphan-target-filter").show();var n=$("#node-input-orphan-target-filter").searchBox({style:"compact",delay:300,change:function(){var e,t=$(this).val().trim().toLowerCase();""===t?($("#node-input-orphan-target-container-div").treeList("filter",null),n.searchBox("count","")):(e=$("#node-input-orphan-target-container-div").treeList("filter",function(e){return-1<e.label.toLowerCase().indexOf(t)||-1<e.node.type.toLowerCase().indexOf(t)}),n.searchBox("count",e+" / "+$("#node-input-orphan-target-container-div").treeList("data").length))}})}$("#node-input-orphan-target-container-div").treeList("data",e.sort((e,t)=>e.node.z>t.node.z))}}function collectOrphans(){const t=new Set;var n=[],i=(RED.nodes.eachLink(e=>{t.add(e.source),t.add(e.target)}),RED.nodes.eachNode(e=>{t.has(e)||n.push(e)}),[]),r={};return n.forEach(function(e){var t=RED.nodes.getType(e.type);if(t){var n=t.label,n=("function"==typeof n?n.call(e):n)||"",o=e.type;if(0===o.indexOf("subflow:"))return}t&&n||(n=e.type),r[e.id]={node:e,label:n,sublabel:o,selected:!1,checkbox:!1},i.push(r[e.id])}),i}
|
|
8
8
|
|
|
@@ -83,6 +83,7 @@
|
|
|
83
83
|
replace_change: $('#node-input-obfuscate-replace-change').is(":checked"),
|
|
84
84
|
|
|
85
85
|
add_license: $('#node-input-obfuscate-add-license-text').is(":checked"),
|
|
86
|
+
append_license: $('#node-input-obfuscate-append-license-text').is(":checked"),
|
|
86
87
|
license_text: $('#node-input-obfuscate-license-text').val(),
|
|
87
88
|
})
|
|
88
89
|
})
|
|
@@ -98,7 +99,13 @@
|
|
|
98
99
|
$('#node-screenshot-capture-btn').on("click", function (e) {
|
|
99
100
|
if ( e ) { e.preventDefault() }
|
|
100
101
|
|
|
101
|
-
$('#node-input-screenshot-svgcontainer').html( "
|
|
102
|
+
$('#node-input-screenshot-svgcontainer').html( "" );
|
|
103
|
+
|
|
104
|
+
RED.notify(
|
|
105
|
+
"Please wait, screenshot being prepared ...", {
|
|
106
|
+
type: "success"
|
|
107
|
+
}
|
|
108
|
+
);
|
|
102
109
|
|
|
103
110
|
generatorFunctionForVersion(RED)( (svgdata) => {
|
|
104
111
|
$('#node-input-screenshot-svgcontainer').html(svgdata);
|
|
@@ -109,6 +116,60 @@
|
|
|
109
116
|
});
|
|
110
117
|
})
|
|
111
118
|
|
|
119
|
+
$('#node-screenshot-post-svg-to-endpoint').on('click', (e) => {
|
|
120
|
+
if (e) { e.preventDefault(); }
|
|
121
|
+
let postEndpoint = $('#node-input-svgpost-endpoint').val() || "/screenshot"
|
|
122
|
+
|
|
123
|
+
RED.notify(
|
|
124
|
+
"Posting to endpoint ...", {
|
|
125
|
+
type: "success"
|
|
126
|
+
}
|
|
127
|
+
);
|
|
128
|
+
|
|
129
|
+
$.ajax({
|
|
130
|
+
type: "POST",
|
|
131
|
+
url: postEndpoint,
|
|
132
|
+
dataType: "application/json;charset=utf-8",
|
|
133
|
+
data: {
|
|
134
|
+
d: globalRefToSvgData
|
|
135
|
+
},
|
|
136
|
+
complete: (obj) => {
|
|
137
|
+
switch( obj.status ) {
|
|
138
|
+
case 413:
|
|
139
|
+
// apiMaxLength in the settings.js is set to 5mb by default,
|
|
140
|
+
// if svg larger than that, need to increase the limit.
|
|
141
|
+
// Provide a hint to that setting in the error message.
|
|
142
|
+
RED.notify(
|
|
143
|
+
"Screenshot too large, increase apiMaxLength in settings.js.", {
|
|
144
|
+
type: "error"
|
|
145
|
+
}
|
|
146
|
+
);
|
|
147
|
+
break;
|
|
148
|
+
case 404:
|
|
149
|
+
// Http-in POST node is missing
|
|
150
|
+
RED.notify(
|
|
151
|
+
"Missing http-in node: method: POST, path: " + postEndpoint, {
|
|
152
|
+
type: "error"
|
|
153
|
+
}
|
|
154
|
+
);
|
|
155
|
+
break;
|
|
156
|
+
case 200:
|
|
157
|
+
RED.notify("Screenshot successfully posted", {
|
|
158
|
+
type: "success"
|
|
159
|
+
});
|
|
160
|
+
break;
|
|
161
|
+
default:
|
|
162
|
+
RED.notify(
|
|
163
|
+
"Screenshot failed: " + obj.statusText + " " + obj.status, {
|
|
164
|
+
type: "error"
|
|
165
|
+
}
|
|
166
|
+
);
|
|
167
|
+
};
|
|
168
|
+
},
|
|
169
|
+
});
|
|
170
|
+
|
|
171
|
+
})
|
|
172
|
+
|
|
112
173
|
// handle the download button under the editor window.
|
|
113
174
|
$('#node-screenshot-download-svg').on("click", function (e) {
|
|
114
175
|
if (e) { e.preventDefault(); }
|
|
@@ -180,6 +241,10 @@
|
|
|
180
241
|
<div class="form-row">
|
|
181
242
|
<div class="col-100">
|
|
182
243
|
|
|
244
|
+
<div class="form-row" style="margin-left: 10px; margin-top: 30px;">
|
|
245
|
+
Step 1: Capture a screen shot, Step 2: download it, copy it or post off.
|
|
246
|
+
</div>
|
|
247
|
+
|
|
183
248
|
<div class="form-row" style="margin-left: 10px; margin-top: 30px;">
|
|
184
249
|
<button type="button" id="node-screenshot-capture-btn"
|
|
185
250
|
class="red-ui-button red-ui-button-large"><i class="fa fa-camera"></i> Capture</button>
|
|
@@ -194,6 +259,17 @@
|
|
|
194
259
|
style="min-height: 300px; height: 450px; overflow: hidden; margin-left: 10px; margin-right: 15px; border: 1px rgb(196, 196, 196) solid; border-radius: 5px;">
|
|
195
260
|
<div id="node-input-screenshot-svgcontainer"></div>
|
|
196
261
|
</div>
|
|
262
|
+
|
|
263
|
+
<div class="form-row" style="margin-left: 10px; margin-top: 30px;">
|
|
264
|
+
<label for="node-input-svgpost-endpoint">
|
|
265
|
+
<i class="fa fa-send-o"></i>
|
|
266
|
+
<span>Post Endpoint</span>
|
|
267
|
+
</label>
|
|
268
|
+
<input type="text" id="node-input-svgpost-endpoint" placeholder="/screenshot" style="width: 40% !important;">
|
|
269
|
+
<button type="button" id="node-screenshot-post-svg-to-endpoint"
|
|
270
|
+
class="red-ui-button red-ui-button-large"><i class="fa fa-send-o"></i> Post to Endpoint</button>
|
|
271
|
+
</div>
|
|
272
|
+
|
|
197
273
|
</div>
|
|
198
274
|
</div>
|
|
199
275
|
</div>
|
|
@@ -360,8 +436,10 @@
|
|
|
360
436
|
</div>
|
|
361
437
|
|
|
362
438
|
<div id="node-input-obfuscate-add-license-text-row" class="form-row" style="margin-left: 10px; display: none;">
|
|
363
|
-
<
|
|
364
|
-
|
|
439
|
+
<label for="node-input-obfuscate-append-license-text">
|
|
440
|
+
<span>Append to info?</span>
|
|
441
|
+
</label>
|
|
442
|
+
<input type="checkbox" id="node-input-obfuscate-append-license-text" style="display:inline-block; width:15px; vertical-align:baseline;"> <textarea id="node-input-obfuscate-license-text" placeholder="License Text"></textarea>
|
|
365
443
|
</div>
|
|
366
444
|
|
|
367
445
|
<div class="form-row">
|