total5 0.0.17-8 → 0.0.17-9
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/.zed/tasks.json +0 -0
- package/changelog.txt +2 -0
- package/flowstream.js +78 -71
- package/package.json +1 -1
package/.zed/tasks.json
ADDED
|
File without changes
|
package/changelog.txt
CHANGED
|
@@ -21,6 +21,8 @@
|
|
|
21
21
|
- added a new property `flow.instance.repo = {}` for storing additional data for Flow node instances
|
|
22
22
|
- fixed `Utils.filestreamer()` method
|
|
23
23
|
- improved `Utils.filestreamer()` method by adding percentage
|
|
24
|
+
- fixed sending data to all outputs `$.send(null, [data])` in the FlowStream
|
|
25
|
+
- fixed sending data to all outputs `instance.send(null, [data])` in the FlowStream
|
|
24
26
|
|
|
25
27
|
========================
|
|
26
28
|
0.0.16
|
package/flowstream.js
CHANGED
|
@@ -77,10 +77,10 @@ MP.emit = function(name, a, b, c, d, e, f, g) {
|
|
|
77
77
|
if (!self.$events)
|
|
78
78
|
return self;
|
|
79
79
|
|
|
80
|
-
|
|
80
|
+
const evt = self.$events[name];
|
|
81
81
|
if (evt) {
|
|
82
82
|
|
|
83
|
-
|
|
83
|
+
let clean = false;
|
|
84
84
|
|
|
85
85
|
for (var e of evt) {
|
|
86
86
|
if (e.once)
|
|
@@ -89,7 +89,7 @@ MP.emit = function(name, a, b, c, d, e, f, g) {
|
|
|
89
89
|
}
|
|
90
90
|
|
|
91
91
|
if (clean) {
|
|
92
|
-
|
|
92
|
+
let index = 0;
|
|
93
93
|
while (true) {
|
|
94
94
|
if (!evt[index])
|
|
95
95
|
break;
|
|
@@ -116,12 +116,12 @@ MP.emit2 = function(name, a, b, c, d, e, f, g) {
|
|
|
116
116
|
if (!self.$events)
|
|
117
117
|
return self;
|
|
118
118
|
|
|
119
|
-
|
|
119
|
+
const evt = self.$events[name];
|
|
120
120
|
if (evt) {
|
|
121
121
|
|
|
122
|
-
|
|
122
|
+
let clean = false;
|
|
123
123
|
|
|
124
|
-
for (
|
|
124
|
+
for (let e of evt) {
|
|
125
125
|
if (e.cloned < self.cloned) {
|
|
126
126
|
if (e.once)
|
|
127
127
|
clean = true;
|
|
@@ -130,9 +130,9 @@ MP.emit2 = function(name, a, b, c, d, e, f, g) {
|
|
|
130
130
|
}
|
|
131
131
|
|
|
132
132
|
if (clean) {
|
|
133
|
-
|
|
133
|
+
let index = 0;
|
|
134
134
|
while (true) {
|
|
135
|
-
|
|
135
|
+
let e = evt[index];
|
|
136
136
|
if (!e)
|
|
137
137
|
break;
|
|
138
138
|
if (e.cloned < self.cloned) {
|
|
@@ -151,10 +151,10 @@ MP.emit2 = function(name, a, b, c, d, e, f, g) {
|
|
|
151
151
|
};
|
|
152
152
|
|
|
153
153
|
MP.on = function(name, fn, once) {
|
|
154
|
-
|
|
154
|
+
const self = this;
|
|
155
155
|
if (!self.$events)
|
|
156
156
|
self.$events = {};
|
|
157
|
-
|
|
157
|
+
const obj = { cloned: self.cloned, fn: fn, once: once };
|
|
158
158
|
if (self.$events[name])
|
|
159
159
|
self.$events[name].push(obj);
|
|
160
160
|
else
|
|
@@ -167,7 +167,7 @@ MP.once = function(name, fn) {
|
|
|
167
167
|
};
|
|
168
168
|
|
|
169
169
|
MP.off = function(name, fn) {
|
|
170
|
-
|
|
170
|
+
const self = this;
|
|
171
171
|
|
|
172
172
|
if (!name) {
|
|
173
173
|
delete self.$events;
|
|
@@ -175,7 +175,7 @@ MP.off = function(name, fn) {
|
|
|
175
175
|
}
|
|
176
176
|
|
|
177
177
|
if (self.$events) {
|
|
178
|
-
|
|
178
|
+
let evt = self.$events[name];
|
|
179
179
|
if (evt) {
|
|
180
180
|
if (fn) {
|
|
181
181
|
evt = evt.remove(n => n.fn === fn);
|
|
@@ -189,8 +189,9 @@ MP.off = function(name, fn) {
|
|
|
189
189
|
|
|
190
190
|
MP.clone = function() {
|
|
191
191
|
|
|
192
|
-
|
|
193
|
-
|
|
192
|
+
const self = this;
|
|
193
|
+
const obj = new Message();
|
|
194
|
+
|
|
194
195
|
obj.previd = self.id;
|
|
195
196
|
obj.$events = self.$events;
|
|
196
197
|
obj.duration = self.duration;
|
|
@@ -218,9 +219,9 @@ MP.clone = function() {
|
|
|
218
219
|
obj.ref = self.ref;
|
|
219
220
|
|
|
220
221
|
if (obj.$events && obj.$events.timeout) {
|
|
221
|
-
|
|
222
|
+
let index = 0;
|
|
222
223
|
while (true) {
|
|
223
|
-
|
|
224
|
+
let e = obj.$events.timeout[index];
|
|
224
225
|
if (e) {
|
|
225
226
|
if ((e.cloned + 1) < obj.cloned)
|
|
226
227
|
obj.$events.timeout.splice(index, 1);
|
|
@@ -263,9 +264,9 @@ MP.throw = function(a, b, c, d) {
|
|
|
263
264
|
function variables(str, data, encoding) {
|
|
264
265
|
|
|
265
266
|
if (typeof(str) === 'object') {
|
|
266
|
-
|
|
267
|
-
for (
|
|
268
|
-
|
|
267
|
+
const obj = {};
|
|
268
|
+
for (let key in str) {
|
|
269
|
+
let val = str[key];
|
|
269
270
|
if (typeof(val) === 'string')
|
|
270
271
|
obj[key] = variables.call(this, val, data, encoding);
|
|
271
272
|
else
|
|
@@ -277,16 +278,16 @@ function variables(str, data, encoding) {
|
|
|
277
278
|
if (typeof(str) !== 'string' || str.indexOf('{') === -1)
|
|
278
279
|
return str;
|
|
279
280
|
|
|
280
|
-
|
|
281
|
+
const main = this.main ? this.main : this;
|
|
281
282
|
|
|
282
283
|
if (data == null || data == true)
|
|
283
284
|
data = this;
|
|
284
285
|
|
|
285
286
|
return str.replace(REG_ARGS, function(text) {
|
|
286
287
|
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
288
|
+
const l = text[1] === '{' ? 2 : 1;
|
|
289
|
+
const key = text.substring(l, text.length - l).trim();
|
|
290
|
+
let val = null;
|
|
290
291
|
|
|
291
292
|
if (main.variables)
|
|
292
293
|
val = main.variables[key];
|
|
@@ -303,7 +304,7 @@ function variables(str, data, encoding) {
|
|
|
303
304
|
val = val.substring(0, val.length - 1);
|
|
304
305
|
}
|
|
305
306
|
|
|
306
|
-
|
|
307
|
+
const customencoding = typeof(encoding) === 'function';
|
|
307
308
|
|
|
308
309
|
if (!val && data != null && typeof(data) === 'object')
|
|
309
310
|
val = key.includes('.') ? F.TUtils.get(data, key) : data[key];
|
|
@@ -369,7 +370,7 @@ MP.send = function(outputindex, data, clonedata) {
|
|
|
369
370
|
|
|
370
371
|
if (self.instance.connections) {
|
|
371
372
|
for (let key in self.instance.connections)
|
|
372
|
-
count += self.send(key);
|
|
373
|
+
count += self.send(key, data, clonedata);
|
|
373
374
|
}
|
|
374
375
|
|
|
375
376
|
if (!count)
|
|
@@ -781,7 +782,7 @@ FP.inc = function(num) {
|
|
|
781
782
|
|
|
782
783
|
FP.cleanforce = function() {
|
|
783
784
|
|
|
784
|
-
|
|
785
|
+
const self = this;
|
|
785
786
|
|
|
786
787
|
if (self.cleantimeout) {
|
|
787
788
|
clearTimeout(self.cleantimeout);
|
|
@@ -791,21 +792,21 @@ FP.cleanforce = function() {
|
|
|
791
792
|
if (!self.meta)
|
|
792
793
|
return self;
|
|
793
794
|
|
|
794
|
-
for (
|
|
795
|
+
for (let key in self.meta.flow) {
|
|
795
796
|
if (!BLACKLISTID[key]) {
|
|
796
|
-
|
|
797
|
+
const instance = self.meta.flow[key];
|
|
797
798
|
if (instance.connections) {
|
|
798
799
|
|
|
799
|
-
for (
|
|
800
|
+
for (let key2 in instance.connections) {
|
|
800
801
|
|
|
801
|
-
|
|
802
|
-
|
|
802
|
+
const conns = instance.connections[key2];
|
|
803
|
+
const rem = {};
|
|
803
804
|
|
|
804
|
-
for (
|
|
805
|
+
for (let conn of conns) {
|
|
805
806
|
if (conn) {
|
|
806
|
-
|
|
807
|
+
const target = self.meta.flow[conn.id];
|
|
807
808
|
if (target) {
|
|
808
|
-
|
|
809
|
+
let com = self.meta.components[target.component];
|
|
809
810
|
if (com) {
|
|
810
811
|
if (self.strict) {
|
|
811
812
|
if (target.inputs) {
|
|
@@ -821,7 +822,7 @@ FP.cleanforce = function() {
|
|
|
821
822
|
}
|
|
822
823
|
}
|
|
823
824
|
|
|
824
|
-
|
|
825
|
+
const arr = conns.remove(c => c == null || rem[c.id] === 1);
|
|
825
826
|
if (arr.length)
|
|
826
827
|
instance.connections[key2] = arr;
|
|
827
828
|
else
|
|
@@ -831,10 +832,10 @@ FP.cleanforce = function() {
|
|
|
831
832
|
}
|
|
832
833
|
}
|
|
833
834
|
|
|
834
|
-
|
|
835
|
+
const paused = self.meta.flow.paused;
|
|
835
836
|
if (paused) {
|
|
836
|
-
for (
|
|
837
|
-
|
|
837
|
+
for (let key in paused) {
|
|
838
|
+
const arr = key.split(D);
|
|
838
839
|
// arr[0] type
|
|
839
840
|
// arr[1] id
|
|
840
841
|
// arr[2] index
|
|
@@ -987,7 +988,6 @@ function newmiddleware(callback) {
|
|
|
987
988
|
return self;
|
|
988
989
|
}
|
|
989
990
|
|
|
990
|
-
|
|
991
991
|
function newmessage(data) {
|
|
992
992
|
var self = this;
|
|
993
993
|
var msg = new Message();
|
|
@@ -1047,40 +1047,48 @@ FP.ontrigger = function(outputindex, data, controller, events) {
|
|
|
1047
1047
|
|
|
1048
1048
|
// this == instance
|
|
1049
1049
|
|
|
1050
|
-
|
|
1051
|
-
|
|
1052
|
-
|
|
1050
|
+
const schema = this;
|
|
1051
|
+
const self = schema.main;
|
|
1052
|
+
let count = 0;
|
|
1053
1053
|
|
|
1054
1054
|
if (self.paused)
|
|
1055
1055
|
return count;
|
|
1056
1056
|
|
|
1057
1057
|
if (schema && schema.ready && schema.component && schema.connections) {
|
|
1058
|
-
|
|
1058
|
+
|
|
1059
|
+
const instance = self.meta.components[schema.component];
|
|
1060
|
+
|
|
1061
|
+
if (outputindex == null) {
|
|
1062
|
+
for (let key in schema.connections)
|
|
1063
|
+
count += schema.send(key, data, controller, events);
|
|
1064
|
+
return count;
|
|
1065
|
+
}
|
|
1066
|
+
|
|
1059
1067
|
if (instance && instance.connected && !instance.disabled && self.$can(false, schema.id, outputindex)) {
|
|
1060
|
-
|
|
1068
|
+
const conn = schema.connections[outputindex];
|
|
1061
1069
|
if (conn && conn.length) {
|
|
1062
1070
|
|
|
1063
|
-
|
|
1064
|
-
for (
|
|
1071
|
+
const ts = Date.now();
|
|
1072
|
+
for (let i = 0; i < conn.length; i++) {
|
|
1065
1073
|
|
|
1066
|
-
|
|
1067
|
-
|
|
1074
|
+
const m = conn[i];
|
|
1075
|
+
const target = self.meta.flow[m.id];
|
|
1068
1076
|
|
|
1069
1077
|
if (!target || (!target.message && !target['message_' + m.index]) || !self.$can(true, m.id, m.index))
|
|
1070
1078
|
continue;
|
|
1071
1079
|
|
|
1072
|
-
|
|
1080
|
+
const com = self.meta.components[target.component];
|
|
1073
1081
|
if (!com)
|
|
1074
1082
|
continue;
|
|
1075
1083
|
|
|
1076
1084
|
if (target.isdestroyed || (data && data.instance && data.instance.isdestroyed))
|
|
1077
1085
|
continue;
|
|
1078
1086
|
|
|
1079
|
-
|
|
1087
|
+
const ismessage = data instanceof Message;
|
|
1080
1088
|
if (ismessage && m.color && data.color && data.color !== m.color)
|
|
1081
1089
|
continue;
|
|
1082
1090
|
|
|
1083
|
-
|
|
1091
|
+
let message = ismessage ? data.clone() : new Message();
|
|
1084
1092
|
|
|
1085
1093
|
if (ismessage) {
|
|
1086
1094
|
|
|
@@ -1396,7 +1404,7 @@ FP.use = function(schema, callback, reinit) {
|
|
|
1396
1404
|
|
|
1397
1405
|
FP._use = function(schema, callback, reinit, insert) {
|
|
1398
1406
|
|
|
1399
|
-
|
|
1407
|
+
let self = this;
|
|
1400
1408
|
|
|
1401
1409
|
if (self.loading) {
|
|
1402
1410
|
setTimeout(use, 200, self, schema, callback, reinit, insert);
|
|
@@ -1409,7 +1417,7 @@ FP._use = function(schema, callback, reinit, insert) {
|
|
|
1409
1417
|
schema = F.TUtils.clone(schema);
|
|
1410
1418
|
|
|
1411
1419
|
if (typeof(callback) === 'boolean') {
|
|
1412
|
-
|
|
1420
|
+
let tmp = reinit;
|
|
1413
1421
|
reinit = callback;
|
|
1414
1422
|
callback = tmp;
|
|
1415
1423
|
}
|
|
@@ -1418,12 +1426,12 @@ FP._use = function(schema, callback, reinit, insert) {
|
|
|
1418
1426
|
// schema.COMPONENT_ID.config = {};
|
|
1419
1427
|
// schema.COMPONENT_ID.connections = { '0': [{ id: 'COMPONENT_ID', index: '2' }] }
|
|
1420
1428
|
|
|
1421
|
-
|
|
1429
|
+
const err = new F.ErrorBuilder();
|
|
1422
1430
|
|
|
1423
1431
|
if (schema) {
|
|
1424
1432
|
|
|
1425
|
-
|
|
1426
|
-
|
|
1433
|
+
const keys = Object.keys(schema);
|
|
1434
|
+
const ts = Date.now();
|
|
1427
1435
|
|
|
1428
1436
|
if (!insert) {
|
|
1429
1437
|
if (self.meta.flow.paused)
|
|
@@ -1445,9 +1453,9 @@ FP._use = function(schema, callback, reinit, insert) {
|
|
|
1445
1453
|
return;
|
|
1446
1454
|
}
|
|
1447
1455
|
|
|
1448
|
-
|
|
1449
|
-
|
|
1450
|
-
|
|
1456
|
+
const current = self.meta.flow[key];
|
|
1457
|
+
const instance = schema[key];
|
|
1458
|
+
const component = instance.component ? self.meta.components[instance.component] : null;
|
|
1451
1459
|
|
|
1452
1460
|
// Component not found
|
|
1453
1461
|
if (!component) {
|
|
@@ -1469,11 +1477,11 @@ FP._use = function(schema, callback, reinit, insert) {
|
|
|
1469
1477
|
return;
|
|
1470
1478
|
}
|
|
1471
1479
|
|
|
1472
|
-
|
|
1480
|
+
const fi = self.meta.flow[key];
|
|
1473
1481
|
|
|
1474
1482
|
if (!fi || reinit) {
|
|
1475
1483
|
self.meta.flow[key] = instance;
|
|
1476
|
-
|
|
1484
|
+
let tmp = self.initcomponent(key, component);
|
|
1477
1485
|
if (tmp) {
|
|
1478
1486
|
tmp.ts = ts;
|
|
1479
1487
|
tmp.newbie = true;
|
|
@@ -1506,9 +1514,9 @@ FP._use = function(schema, callback, reinit, insert) {
|
|
|
1506
1514
|
}, function() {
|
|
1507
1515
|
|
|
1508
1516
|
if (!insert) {
|
|
1509
|
-
for (
|
|
1517
|
+
for (let key in self.meta.flow) {
|
|
1510
1518
|
if (!BLACKLISTID[key]) {
|
|
1511
|
-
|
|
1519
|
+
const instance = self.meta.flow[key];
|
|
1512
1520
|
if (instance.ts !== ts) {
|
|
1513
1521
|
instance.ready = false;
|
|
1514
1522
|
instance.isdestroyed = true;
|
|
@@ -1526,8 +1534,8 @@ FP._use = function(schema, callback, reinit, insert) {
|
|
|
1526
1534
|
}
|
|
1527
1535
|
}
|
|
1528
1536
|
|
|
1529
|
-
for (
|
|
1530
|
-
|
|
1537
|
+
for (let key in self.meta.flow) {
|
|
1538
|
+
const instance = self.meta.flow[key];
|
|
1531
1539
|
if (instance.newbie) {
|
|
1532
1540
|
if (instance.init) {
|
|
1533
1541
|
try {
|
|
@@ -1548,7 +1556,6 @@ FP._use = function(schema, callback, reinit, insert) {
|
|
|
1548
1556
|
}
|
|
1549
1557
|
|
|
1550
1558
|
self.inc(-1);
|
|
1551
|
-
|
|
1552
1559
|
self.cleanforce();
|
|
1553
1560
|
self.$events.schema && self.emit('schema', self.meta.flow);
|
|
1554
1561
|
callback && callback(err.length ? err : null);
|
|
@@ -1566,8 +1573,8 @@ FP._use = function(schema, callback, reinit, insert) {
|
|
|
1566
1573
|
|
|
1567
1574
|
FP.initcomponent = function(key, component) {
|
|
1568
1575
|
|
|
1569
|
-
|
|
1570
|
-
|
|
1576
|
+
const self = this;
|
|
1577
|
+
const instance = self.meta.flow[key];
|
|
1571
1578
|
|
|
1572
1579
|
if (instance.ready) {
|
|
1573
1580
|
|
|
@@ -1599,7 +1606,7 @@ FP.initcomponent = function(key, component) {
|
|
|
1599
1606
|
delete instance.options;
|
|
1600
1607
|
}
|
|
1601
1608
|
|
|
1602
|
-
|
|
1609
|
+
let tmp = component.config;
|
|
1603
1610
|
if (tmp)
|
|
1604
1611
|
instance.config = instance.config ? F.TUtils.extend(F.TUtils.clone(tmp), instance.config) : F.TUtils.clone(tmp);
|
|
1605
1612
|
|
|
@@ -1888,10 +1895,10 @@ FP.find = function(id) {
|
|
|
1888
1895
|
};
|
|
1889
1896
|
|
|
1890
1897
|
FP.send = function(path, body) {
|
|
1891
|
-
|
|
1898
|
+
const self = this;
|
|
1892
1899
|
if (!self.paused && self.meta && self.meta.flow) {
|
|
1893
1900
|
path = path.split(D);
|
|
1894
|
-
|
|
1901
|
+
const instance = self.meta.flow[path[0]];
|
|
1895
1902
|
if (instance)
|
|
1896
1903
|
instance.send(path[1], body);
|
|
1897
1904
|
return !!instance;
|