total5 0.0.17 → 0.0.18-2

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/bin/total5 CHANGED
@@ -41,7 +41,7 @@ FUNC.help = function() {
41
41
  console.log('bundle <filename> : it makes a bundle from the current directory');
42
42
  console.log('extract <filename> : it extracts a bundle into the current directory');
43
43
  console.log('edit <url?id=project> : it opens remote editing of the current directory with the Total.js Code Editor');
44
- console.log('proxy <server_endpoint> <local_port> : It connects a local port with a remote totaljs proxy server');
44
+ console.log('proxy <server_endpoint> <local_port> : It connects a local port with a remote Total.js proxy server');
45
45
  console.log('8000 : it starts a web server on port "8000" for the current directory');
46
46
  done();
47
47
  };
@@ -243,7 +243,7 @@ FUNC.server = function(port) {
243
243
  };
244
244
 
245
245
  FUNC.proxy = function(endpoint, port) {
246
- require('../proxy').client(endpoint, port);
246
+ PROXYCLIENT(endpoint, port);
247
247
  };
248
248
 
249
249
  FUNC.edit = function(url) {
package/changelog.txt CHANGED
@@ -1,3 +1,13 @@
1
+ ========================
2
+ 0.0.18
3
+ ========================
4
+
5
+ - fixed handling static files
6
+ - added `flow.proxytimeout {Number}` property
7
+ - extended the `message.send(output, data, [clone_data], [check(from, to, output, input)])` method by adding `check` argument
8
+ - extended `LDAP()` options by adding a new option `attributes = { thumbnailPhoto: 'buffer' }` for custom parsing data
9
+ - fixed Flow error handling
10
+
1
11
  ========================
2
12
  0.0.17
3
13
  ========================
package/controller.js CHANGED
@@ -1595,7 +1595,7 @@ function send_file(ctrl, path, ext) {
1595
1595
 
1596
1596
  var loadstats = function(err, stats, cache) {
1597
1597
 
1598
- if (err) {
1598
+ if (err || (cache && cache.size === 0)) {
1599
1599
 
1600
1600
  if (!DEBUG && ctrl.response.cache)
1601
1601
  F.temporary.notfound[ctrl.uri.cache] = true;
@@ -1657,6 +1657,15 @@ function send_file(ctrl, path, ext) {
1657
1657
  if (ctrl.method === 'HEAD') {
1658
1658
  ctrl.res.end();
1659
1659
  } else {
1660
+
1661
+ if (end > cache.size || beg > cache.size) {
1662
+ // Unexpected file problem
1663
+ delete F.temporary.tmp[ctrl.uri.cache];
1664
+ ctrl.destroyed = true;
1665
+ ctrl.req.destroy();
1666
+ return;
1667
+ }
1668
+
1660
1669
  reader = F.Fs.createReadStream(path, { start: beg, end: end });
1661
1670
 
1662
1671
  // Unexpected error
@@ -1,6 +1,6 @@
1
1
  // Total.js FlowStream module
2
2
  // The MIT License
3
- // Copyright 2021-2025 (c) Peter Širka <petersirka@gmail.com>
3
+ // Copyright 2021-2026 (c) Peter Širka <petersirka@gmail.com>
4
4
 
5
5
  'use strict';
6
6
 
@@ -9,7 +9,7 @@ if (!global.F)
9
9
 
10
10
  const W = F.Worker;
11
11
  const Fork = F.Child.fork;
12
- const VERSION = 34;
12
+ const VERSION = 35;
13
13
  const NOTIFYPATH = '/notify/';
14
14
 
15
15
  var isFLOWSTREAMWORKER = false;
@@ -648,6 +648,8 @@ Instance.prototype.reload = function(data) {
648
648
  }
649
649
 
650
650
  PROXIES[data.id] = F.proxy(data.proxypath, data.unixsocket);
651
+ data.proxytimeout && PROXIES[data.id].timeout(data.proxytimeout);
652
+
651
653
  }
652
654
 
653
655
  for (let key in data)
package/flow.js CHANGED
@@ -1,6 +1,6 @@
1
1
  // Total.js Flow module
2
2
  // The MIT License
3
- // Copyright 2023-2025 (c) Peter Širka <petersirka@gmail.com>
3
+ // Copyright 2023-2026 (c) Peter Širka <petersirka@gmail.com>
4
4
 
5
5
  'use strict';
6
6
 
@@ -81,6 +81,7 @@ FS.reload = function(flow, restart = false) {
81
81
  var instance = FS.instances[flow.id];
82
82
  instance.workertype = flow.worker;
83
83
  instance.proxypath = flow.proxypath;
84
+ instance.proxytimeout = flow.proxytimeout;
84
85
 
85
86
  if (restart)
86
87
  instance.restart();
@@ -141,6 +142,7 @@ FS.load = function(flow, callback) {
141
142
  // flow.worker {String/Boolean}
142
143
  // flow.memory {Number}
143
144
  // flow.proxypath {String}
145
+ // flow.proxytimeout {Number}
144
146
 
145
147
  if (FS.instances[flow.id]) {
146
148
  FS.reload(flow);
package/flowstream.js CHANGED
@@ -1,6 +1,6 @@
1
1
  // Total.js FlowStream
2
2
  // The MIT License
3
- // Copyright 2021-2025 (c) Peter Širka <petersirka@gmail.com>
3
+ // Copyright 2021-2026 (c) Peter Širka <petersirka@gmail.com>
4
4
 
5
5
  'use strict';
6
6
 
@@ -350,9 +350,9 @@ function timeouthandler(msg) {
350
350
  msg.end();
351
351
  }
352
352
 
353
- MP.send = function(outputindex, data, clonedata) {
353
+ MP.send = function(outputindex, data, clonedata, check) {
354
354
 
355
- let self = this;
355
+ const self = this;
356
356
 
357
357
  if (clonedata == null)
358
358
  clonedata = self.main.cloning;
@@ -363,7 +363,6 @@ MP.send = function(outputindex, data, clonedata) {
363
363
  return 0;
364
364
  }
365
365
 
366
- let outputs;
367
366
  let count = 0;
368
367
 
369
368
  if (outputindex == null) {
@@ -379,11 +378,8 @@ MP.send = function(outputindex, data, clonedata) {
379
378
  return count;
380
379
  }
381
380
 
382
-
383
- let meta = self.main.meta;
384
- let now = Date.now();
385
-
386
- outputs = self.instance.connections ? (self.instance.connections[outputindex] || F.EMPTYARRAY) : F.EMPTYARRAY;
381
+ const now = Date.now();
382
+ const meta = self.main.meta;
387
383
 
388
384
  if (self.processed === 0) {
389
385
  self.processed = 1;
@@ -406,6 +402,7 @@ MP.send = function(outputindex, data, clonedata) {
406
402
  return count;
407
403
  }
408
404
 
405
+ let outputs = self.instance.connections ? (self.instance.connections[outputindex] || F.EMPTYARRAY) : F.EMPTYARRAY;
409
406
  let tid = self.toid + D + outputindex + (self.color || '');
410
407
 
411
408
  if (self.main.stats.traffic[tid]) {
@@ -425,14 +422,20 @@ MP.send = function(outputindex, data, clonedata) {
425
422
  if (output.disabled || output.paused)
426
423
  continue;
427
424
 
428
- let schema = meta.flow[output.id];
425
+ const schema = meta.flow[output.id];
429
426
  if (schema && (schema.message || schema['message_' + output.index]) && schema.component && schema.ready && self.main.$can(true, output.id, output.index)) {
430
- let next = meta.components[schema.component];
427
+ const next = meta.components[schema.component];
431
428
  if (next && next.connected && !next.isdestroyed && !next.disabled) {
432
429
 
433
430
  if (output.color && self.color && self.color !== output.color)
434
431
  continue;
435
432
 
433
+ if (check) {
434
+ // from, to, output, input
435
+ if (!check(self.to, schema, outputindex, output.index))
436
+ continue;
437
+ }
438
+
436
439
  let inputindex = output.index;
437
440
  let message = self.clone();
438
441
 
@@ -1744,7 +1747,7 @@ function sendmessage(instance, message, event) {
1744
1747
  message.destroy();
1745
1748
 
1746
1749
  } catch (e) {
1747
- instance.main.error(e, 'instance_message', message);
1750
+ instance.main.error(e, 'instance_message', message.fromcomponent);
1748
1751
  message.destroy();
1749
1752
  }
1750
1753
  }
package/index.js CHANGED
@@ -38,7 +38,7 @@ global.DEF = {};
38
38
 
39
39
  F.id = '';
40
40
  F.clusterid = '';
41
- F.is5 = F.version = 5017;
41
+ F.is5 = F.version = 5018;
42
42
  F.isBundle = false;
43
43
  F.isLoaded = false;
44
44
  F.version_header = '5';
package/ldap.js CHANGED
@@ -85,12 +85,13 @@ const TYPES = {
85
85
  Context: 128
86
86
  };
87
87
 
88
- function Reader(buffer, callback) {
88
+ function Reader(buffer, callback, opt) {
89
89
 
90
90
  if (buffer instanceof Array)
91
91
  buffer = Buffer.concat(buffer);
92
92
 
93
- var t = this;
93
+ const t = this;
94
+ t.opt = opt;
94
95
  t.buffer = buffer;
95
96
  t.size = t.buffer.length;
96
97
  t.length = 0;
@@ -99,8 +100,8 @@ function Reader(buffer, callback) {
99
100
  t.callback = callback;
100
101
  }
101
102
 
102
- Reader.parse = function(buffer, callback) {
103
- var reader = new Reader(buffer, callback);
103
+ Reader.parse = function(buffer, callback, opt) {
104
+ const reader = new Reader(buffer, callback, opt);
104
105
  reader.parse();
105
106
  };
106
107
 
@@ -112,11 +113,11 @@ Reader.prototype = {
112
113
 
113
114
  Reader.prototype.readbyte = function(peek) {
114
115
 
115
- var self = this;
116
+ const self = this;
116
117
  if (self.size - self.offset < 1)
117
118
  return null;
118
119
 
119
- var b = self.buffer[self.offset] & 0xff;
120
+ const b = self.buffer[self.offset] & 0xff;
120
121
 
121
122
  if (!peek)
122
123
  self.offset += 1;
@@ -133,15 +134,48 @@ Reader.prototype.readattribute = function(attr) {
133
134
  if (self.peek() === PROTOCOL.LBER_SET) {
134
135
 
135
136
  if (self.readsequence(PROTOCOL.LBER_SET)) {
136
- var end = self.offset + self.length;
137
+ let end = self.offset + self.length;
137
138
  while (self.offset < end) {
138
139
 
139
- var val = self.readstring(TYPES.OctetString, true);
140
+ let val = self.readstring(TYPES.OctetString, true);
141
+ let is = false;
142
+
143
+ if (self.opt.attributes) {
144
+ switch (self.opt.attributes[id]) {
145
+ case 'string':
146
+ val = val.toString('utf8');
147
+ is = true;
148
+ break;
149
+ case 'number':
150
+ val = val.toString('utf8').parseFloat();
151
+ is = true;
152
+ break;
153
+ case 'date':
154
+ val = val.toString('utf8').parseDate();
155
+ is = true;
156
+ break;
157
+ case 'hex':
158
+ case 'ascii':
159
+ case 'base16':
160
+ case 'base32':
161
+ case 'base64':
162
+ case 'utf8':
163
+ val = val.toString(self.opt.attributes[id]);
164
+ is = true;
165
+ break;
166
+ case 'buffer':
167
+ case 'binary':
168
+ is = true;
169
+ break;
170
+ }
171
+ }
140
172
 
141
- if (id === 'objectGUID' || id === 'objectSid')
142
- val = val.toString('hex');
143
- else
144
- val = val.toString('utf8');
173
+ if (!is) {
174
+ if (id === 'objectGUID' || id === 'objectSid')
175
+ val = val.toString('hex');
176
+ else
177
+ val = val.toString('utf8');
178
+ }
145
179
 
146
180
  if (attr[id]) {
147
181
  if (!(attr[id] instanceof Array))
@@ -705,6 +739,7 @@ exports.load = function(opt, callback) {
705
739
  // opt.login {String} required for the "profile" type
706
740
  // opt.dn {String}
707
741
  // opt.noauth {Boolean} true skips auth
742
+ // opt.attributes = { prop1: 'buffer', prop2: 'hex', prop3: 'base64' }; types must be in lower-case
708
743
 
709
744
  if (opt.callback)
710
745
  callback = opt.callback;
@@ -732,7 +767,7 @@ exports.load = function(opt, callback) {
732
767
  Reader.parse(buffer, function(err, response) {
733
768
  callback(err, profile ? (response ? response[0] : null) : response);
734
769
  meta.close();
735
- });
770
+ }, opt);
736
771
  };
737
772
 
738
773
  meta.ondata(function(chunk) {
@@ -753,7 +788,7 @@ exports.load = function(opt, callback) {
753
788
  }
754
789
 
755
790
  auth = false;
756
- });
791
+ }, opt);
757
792
  } else {
758
793
  buffer.push(chunk);
759
794
  timeout && clearTimeout(timeout);
@@ -769,7 +804,7 @@ exports.load = function(opt, callback) {
769
804
  // No emitted any data in "ondata" handler
770
805
  Reader.parse(buffer, function(err) {
771
806
  callback(err, profile ? null : EMPTYARRAY);
772
- });
807
+ }, opt);
773
808
 
774
809
  });
775
810
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "total5",
3
- "version": "0.0.17",
3
+ "version": "0.0.18-2",
4
4
  "description": "Total.js framework v5",
5
5
  "main": "index.js",
6
6
  "directories": {
package/routing.js CHANGED
@@ -1,5 +1,5 @@
1
1
  // The MIT License
2
- // Copyright 2023 (c) Peter Širka <petersirka@gmail.com>
2
+ // Copyright 2023-2026 (c) Peter Širka <petersirka@gmail.com>
3
3
 
4
4
  const NEWLINE = '\r\n';
5
5