total5 0.0.6-7 → 0.0.6-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/builders.js CHANGED
@@ -1328,9 +1328,11 @@ ActionCaller.prototype.exec = function() {
1328
1328
  }
1329
1329
  };
1330
1330
 
1331
- if (action.user && !$.user) {
1332
- $.invalid(401);
1333
- return;
1331
+ if (action.user != null) {
1332
+ if ((action.user && !$.user) || (!action.user && $.user)) {
1333
+ $.invalid(401);
1334
+ return;
1335
+ }
1334
1336
  }
1335
1337
 
1336
1338
  if (action.sa) {
package/changelog.txt CHANGED
@@ -28,6 +28,11 @@
28
28
  - fixed parsing unpair XML elements in the `HTMLParser`
29
29
  - improved Markdown parser
30
30
  - added a test functionality for testing Flow components
31
+ - added `F.extend(prototype, name, fn)` for extending Total.js prototypes
32
+ - fixed assigning the `name` field in FlowStream
33
+ - fixed prerendering UI after manual using `Flow.add()` method
34
+ - added `Array.group(key)` method
35
+ - fixed `HTMLParser` by [Marek Mraz](https://github.com/Mrazbb)
31
36
 
32
37
  ========================
33
38
  0.0.5
@@ -502,8 +502,13 @@ Instance.prototype.add = function(id, body, callback) {
502
502
  if (callback)
503
503
  CALLBACKS[callbackid] = { id: self.flow.id, callback: callback };
504
504
  self.flow.postMessage2({ TYPE: 'stream/add', id: id, data: body, callbackid: callbackid });
505
- } else
506
- self.flow.add(id, body, callback, ASFILES);
505
+ } else {
506
+ self.flow.add(id, body, function(err) {
507
+ callback && callback(err);
508
+ self.flow.redraw();
509
+ self.flow.save();
510
+ }, ASFILES);
511
+ }
507
512
  return self;
508
513
  };
509
514
 
@@ -1006,6 +1011,7 @@ function init_current(meta, callback, nested) {
1006
1011
  }
1007
1012
  }
1008
1013
 
1014
+ flow.name = meta.name || meta.id;
1009
1015
  flow.env = meta.env;
1010
1016
  flow.origin = meta.origin;
1011
1017
  flow.proxypath = meta.proxypath || '';
@@ -1221,6 +1227,7 @@ function init_current(meta, callback, nested) {
1221
1227
  msg.error = err ? err.toString() : null;
1222
1228
  if (msg.callbackid !== -1)
1223
1229
  Parent.postMessage(msg);
1230
+ flow.redraw();
1224
1231
  flow.save();
1225
1232
  }, ASFILES);
1226
1233
  break;
@@ -1607,6 +1614,7 @@ function init_worker(meta, type, callback) {
1607
1614
  break;
1608
1615
 
1609
1616
  case 'stream/save':
1617
+ worker.$schema.name = msg.data.name;
1610
1618
  worker.$schema.components = msg.data.components;
1611
1619
  worker.$schema.design = msg.data.design;
1612
1620
  worker.$schema.variables = msg.data.variables;
@@ -2707,6 +2715,7 @@ function MAKEFLOWSTREAM(meta) {
2707
2715
 
2708
2716
  flow.proxy.refreshmeta = function() {
2709
2717
 
2718
+ flow.name = flow.$schema.name || flow.$schema.id;
2710
2719
  flow.origin = flow.$schema.origin;
2711
2720
  flow.proxypath = flow.$schema.proxypath || '';
2712
2721
 
package/flowstream.js CHANGED
@@ -2061,4 +2061,7 @@ exports.create = function(id, errorhandler) {
2061
2061
  let flowstream = new FlowStream(id, errorhandler);
2062
2062
  F.flowstreams[id] = flowstream;
2063
2063
  return flowstream;
2064
- };
2064
+ };
2065
+
2066
+ exports.Message = Message;
2067
+ exports.FlowStream = FlowStream.prototype;
package/htmlparser.js CHANGED
@@ -485,9 +485,18 @@ function removeComments(html) {
485
485
  return html;
486
486
  }
487
487
 
488
+ var CC = 0;
489
+
488
490
  function parseHTML(html, trim, onerror, isxml) {
489
491
 
490
492
  var makeText = function(parent, str) {
493
+
494
+ if (str === 'hello world 5')
495
+ CC++;
496
+
497
+ if (CC === 2)
498
+ throw new Error('FET');
499
+
491
500
  var obj = new HTMLElement();
492
501
  obj.xml = isxml;
493
502
  obj.tagName = 'TEXT';
@@ -658,8 +667,9 @@ function parseHTML(html, trim, onerror, isxml) {
658
667
  if (str && str.indexOf('<') === -1) {
659
668
  if (trim)
660
669
  str = str.trim();
661
- if (str)
662
- parent.children.push(makeText(parent, str));
670
+
671
+ // Commented because it inserts the same textContent twice
672
+ // str && parent.children.push(makeText(parent, str));
663
673
  }
664
674
 
665
675
  return str;
package/http.js CHANGED
@@ -4,8 +4,6 @@
4
4
 
5
5
  'use strict';
6
6
 
7
- const TController = require('./controller');
8
-
9
7
  exports.listen = function(req, res) {
10
8
 
11
9
  // req.ip
@@ -29,7 +27,7 @@ exports.listen = function(req, res) {
29
27
  return;
30
28
  }
31
29
 
32
- var ctrl = new TController.Controller(req, res);
30
+ var ctrl = new F.TController.Controller(req, res);
33
31
 
34
32
  if (F.paused.length) {
35
33
  ctrl.fallback(999);
package/index.js CHANGED
@@ -2397,6 +2397,59 @@ F.backup = function(filename, files, callback, filter) {
2397
2397
  });
2398
2398
  };
2399
2399
 
2400
+ F.extend = function(proto, name, fn) {
2401
+
2402
+ let target = null;
2403
+
2404
+ switch(proto.toLowerCase().replace(/\-\_\s/g, '')) {
2405
+ case '$':
2406
+ case 'options':
2407
+ target = F.TBuilders.Options;
2408
+ break;
2409
+ case 'error':
2410
+ case 'errorbuilder':
2411
+ target = F.TBuilders.ErrorBuilder;
2412
+ break;
2413
+ case 'controller':
2414
+ target = [F.TController.Controller, F.TWebSocket.Controller];
2415
+ break;
2416
+ case 'flowstream':
2417
+ target = F.TFlowStream.FlowStream;
2418
+ break;
2419
+ case 'mail':
2420
+ case 'email':
2421
+ target = F.TMail.Message;
2422
+ break;
2423
+ case 'restbuilder':
2424
+ target = F.TBuilders.RESTBuilder;
2425
+ break;
2426
+ case 'message':
2427
+ case 'flowstreammessage':
2428
+ target = F.TFlowStream.Message;
2429
+ break;
2430
+ case 'view':
2431
+ case 'viewengine':
2432
+ target = F.TViewEngine.View;
2433
+ break;
2434
+ case 'querybuilder':
2435
+ target = T.TQueryBuilder.QueryBuilder;
2436
+ break;
2437
+ case 'database':
2438
+ target = T.TQueryBuilder.Controller;
2439
+ break;
2440
+ }
2441
+
2442
+ if (target) {
2443
+ if (target instanceof Array) {
2444
+ for (let m of target)
2445
+ m.prototype[name] = fn;
2446
+ } else
2447
+ target.prototype[name] = fn;
2448
+ return true;
2449
+ }
2450
+
2451
+ };
2452
+
2400
2453
  F.restart = function() {
2401
2454
  process.send && process.send('total:restart');
2402
2455
  };
@@ -2748,6 +2801,7 @@ process.on('message', function(msg, h) {
2748
2801
  F.TUtils = require('./utils');
2749
2802
  F.TRouting = require('./routing');
2750
2803
  F.TBuilders = require('./builders');
2804
+ F.TController = require('./controller');
2751
2805
  F.TViewEngine = require('./viewengine');
2752
2806
  F.TMinificators = require('./minificators');
2753
2807
  F.TWebSocket = require('./websocket');
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "total5",
3
- "version": "0.0.6-7",
3
+ "version": "0.0.6-9",
4
4
  "description": "Total.js framework v5",
5
5
  "main": "index.js",
6
6
  "directories": {
package/utils.js CHANGED
@@ -4416,6 +4416,36 @@ function filesizehelper(number, count) {
4416
4416
 
4417
4417
  var AP = Array.prototype;
4418
4418
 
4419
+ AP.group = function(name) {
4420
+
4421
+ let groups = {};
4422
+
4423
+ for (let m of this) {
4424
+ let key = m[name];
4425
+
4426
+ if (key != null)
4427
+ key = key.toString();
4428
+ else
4429
+ key = '__';
4430
+
4431
+ let tmp = groups[key];
4432
+ if (tmp)
4433
+ tmp.push(m);
4434
+ else
4435
+ groups[key] = [m];
4436
+ }
4437
+
4438
+ let output = [];
4439
+
4440
+ for (let key in groups) {
4441
+ let id = key === '__' ? '' : key;
4442
+ output.push({ name: id, items: groups[key] });
4443
+ }
4444
+
4445
+ output.quicksort('name');
4446
+ return output;
4447
+ };
4448
+
4419
4449
  AP.take = function(count) {
4420
4450
  var arr = [];
4421
4451
  var self = this;
package/websocket.js CHANGED
@@ -1960,4 +1960,6 @@ exports.createclient = function(callback) {
1960
1960
  var client = new WebSocketClient();
1961
1961
  callback && callback(client);
1962
1962
  return client;
1963
- };
1963
+ };
1964
+
1965
+ exports.Controller = Controller;