node-red-contrib-typescript 1.0.1 → 1.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "node-red-contrib-typescript",
3
- "version": "1.0.1",
3
+ "version": "1.0.3",
4
4
  "description": "",
5
5
  "author": "kezziny",
6
6
  "license": "ISC",
@@ -49,10 +49,12 @@
49
49
  }
50
50
 
51
51
  function typescriptLogSubscriptionHandler(event, data) {
52
- console.log(data);
53
52
  if (data.hasOwnProperty("data")) {
54
53
  let node = RED.nodes.node(data.id);
55
54
  typescriptRenderLog(data.id, data.data, node);
55
+ } else {
56
+ let node = RED.nodes.node(data.id);
57
+ typescriptRenderLog(data.id, undefined, node);
56
58
  }
57
59
  }
58
60
 
@@ -6,6 +6,7 @@ module.exports = function(RED) {
6
6
  function TypescriptInstance(config) {
7
7
  RED.nodes.createNode(this,config);
8
8
  var node = this;
9
+
9
10
  node.config = config;
10
11
  node.libs = config.libs;
11
12
  node.modules = config.modules;
@@ -94,6 +95,10 @@ module.exports = function(RED) {
94
95
  }
95
96
  // endregion
96
97
 
98
+ let pendingMessages = [];
99
+ let storeFunction = msg=>pendingMessages.push(msg);
100
+ node.on("input", storeFunction);
101
+
97
102
  node.loading = new Promise((resolve, reject) => {
98
103
  Promise.all(libraryPromises).then(() => {
99
104
  var context = vm.createContext(sandbox);
@@ -127,7 +132,12 @@ module.exports = function(RED) {
127
132
  var iniScript = helper.createScript(node, iniOpt, config.code);
128
133
  context.__initSend__ = function(msgs) { node.send(msgs); };
129
134
  promise = iniScript.runInContext(context, iniOpt)
130
- .then(() => resolve(node))
135
+ .then(() => {
136
+ node.off("input", storeFunction);
137
+ pendingMessages.forEach(msg => node.emit("input", msg));
138
+
139
+ resolve(node);
140
+ })
131
141
  .catch(e => {
132
142
  node.error(e);
133
143
  node.error(e.stack);