node-red-contrib-typescript 1.0.0 → 1.0.1
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/helper.js +17 -3
- package/node-red-contrib-typescript/package.json +1 -1
- package/package.json +1 -1
- package/src/instance/instance.html +12 -11
package/helper.js
CHANGED
|
@@ -52,6 +52,22 @@ function createVMOpt(node, kind) {
|
|
|
52
52
|
return opt;
|
|
53
53
|
}
|
|
54
54
|
|
|
55
|
+
function sendDataToClient2(RED, node, data) {
|
|
56
|
+
try {
|
|
57
|
+
RED.comms.publish(
|
|
58
|
+
"typescript-log-" + node.id,
|
|
59
|
+
{
|
|
60
|
+
id: node.id,
|
|
61
|
+
data: data
|
|
62
|
+
},
|
|
63
|
+
true
|
|
64
|
+
);
|
|
65
|
+
}
|
|
66
|
+
catch (e) {
|
|
67
|
+
console.log(e);
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
|
|
55
71
|
function createSandbox(RED, node) {
|
|
56
72
|
node.outstandingTimers = [];
|
|
57
73
|
node.outstandingIntervals = [];
|
|
@@ -70,9 +86,7 @@ function createSandbox(RED, node) {
|
|
|
70
86
|
name: node.name,
|
|
71
87
|
path: node._path,
|
|
72
88
|
outputCount: node.outputs,
|
|
73
|
-
log:
|
|
74
|
-
node.log.apply(node, arguments);
|
|
75
|
-
},
|
|
89
|
+
log: (data) => sendDataToClient2(RED, node, data),
|
|
76
90
|
error: function() {
|
|
77
91
|
node.error.apply(node, arguments);
|
|
78
92
|
},
|
package/package.json
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
<script type="text/javascript">
|
|
2
|
-
var
|
|
2
|
+
var typescriptRenderLog = function (id, data, node) {
|
|
3
3
|
let $chart = document.getElementById("data-view-output-chart-" + id);
|
|
4
4
|
if (!$chart) {
|
|
5
5
|
const $container = document.getElementById(id)
|
|
@@ -21,12 +21,12 @@
|
|
|
21
21
|
let $text = document.getElementById(`data-view-output-text-${id}`);
|
|
22
22
|
$text.textContent = ''
|
|
23
23
|
let x = ``
|
|
24
|
-
if (data
|
|
24
|
+
if (data === undefined) {
|
|
25
25
|
x = "";
|
|
26
|
-
} else if (typeof data
|
|
27
|
-
x = JSON.stringify(data
|
|
26
|
+
} else if (typeof data == `object`) {
|
|
27
|
+
x = JSON.stringify(data, null, ' ')
|
|
28
28
|
} else {
|
|
29
|
-
x = data
|
|
29
|
+
x = data + ''
|
|
30
30
|
}
|
|
31
31
|
var
|
|
32
32
|
lines = x.split('\n'),
|
|
@@ -37,8 +37,8 @@
|
|
|
37
37
|
let countSpace = value.length - value.trim().length
|
|
38
38
|
tn = document.createTextNode(value);
|
|
39
39
|
ts = document.createElementNS("http://www.w3.org/2000/svg", "tspan");
|
|
40
|
-
ts.setAttribute('dy',
|
|
41
|
-
ts.setAttribute('x', (countSpace * 10) +
|
|
40
|
+
ts.setAttribute('dy', "1.2em");
|
|
41
|
+
ts.setAttribute('x', (countSpace * 10) + 10);
|
|
42
42
|
ts.setAttribute('text-anchor', 'start');
|
|
43
43
|
ts.setAttribute('fill', '#555');
|
|
44
44
|
ts.setAttribute('stroke', 'transparent');
|
|
@@ -48,10 +48,11 @@
|
|
|
48
48
|
});
|
|
49
49
|
}
|
|
50
50
|
|
|
51
|
-
function
|
|
51
|
+
function typescriptLogSubscriptionHandler(event, data) {
|
|
52
|
+
console.log(data);
|
|
52
53
|
if (data.hasOwnProperty("data")) {
|
|
53
54
|
let node = RED.nodes.node(data.id);
|
|
54
|
-
|
|
55
|
+
typescriptRenderLog(data.id, data.data, node);
|
|
55
56
|
}
|
|
56
57
|
}
|
|
57
58
|
|
|
@@ -199,8 +200,8 @@
|
|
|
199
200
|
outputs:1,
|
|
200
201
|
icon: "function.svg",
|
|
201
202
|
label: function () {
|
|
202
|
-
RED.comms.unsubscribe('
|
|
203
|
-
RED.comms.subscribe('
|
|
203
|
+
RED.comms.unsubscribe('typescript-log-' + this.id, typescriptLogSubscriptionHandler);
|
|
204
|
+
RED.comms.subscribe('typescript-log-' + this.id, typescriptLogSubscriptionHandler);
|
|
204
205
|
return this.name || "typescript";
|
|
205
206
|
},
|
|
206
207
|
oneditprepare: function() {
|