total5 0.0.7-3 → 0.0.8-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/api.js CHANGED
@@ -36,9 +36,18 @@ exports.newapi = function(type, callback) {
36
36
 
37
37
  };
38
38
 
39
+ function APIOptions(api) {
40
+ this.api = api;
41
+ this.retries = 0;
42
+ }
43
+
44
+ APIOptions.prototype.retry = function() {
45
+ this.retries++;
46
+ setImmediate(execapi, this.api);
47
+ };
48
+
39
49
  function APICall() {
40
- var t = this;
41
- t.options = {};
50
+ this.options = new APIOptions(this);
42
51
  }
43
52
 
44
53
  const APICallProto = APICall.prototype;
package/changelog.txt CHANGED
@@ -1,3 +1,16 @@
1
+ ========================
2
+ 0.0.8
3
+ ========================
4
+
5
+ - added `opt.retry()` method in to the `API` evaluation
6
+ - improved HTTP cache in debug mode
7
+ - added `Total.edit('socket_url')` for remote editing of source code
8
+ - added support for `scripts` folder
9
+ - added Total.remote('wss_totaljs_code_url') method for remote editing of the source-code
10
+ - added a better support for `*:tagname` prefixes in HTMLParser
11
+ - fixed context in the components
12
+ - fixed URL downloading templates in `TEMPLATE()` method
13
+
1
14
  ========================
2
15
  0.0.7
3
16
  ========================
@@ -11,8 +24,14 @@
11
24
  - added `CONF.mail_from_name {String}` option
12
25
  - improved `$.query` parser
13
26
  - improved `Total.run()` method
14
- - added a new method `NEWCOMPONENT(html, [callback])`
27
+ - added a new method `NEWCOMPONENT(html_or_URL_or_name, [callback])`
15
28
  - it compiles a FlowStream component to a method
29
+ - extended FlowStream by adding support for `input` and `output` Total.js inline schemas
30
+ - fixed memory usage in the Flow in non-worker mode
31
+ - improved Flow error handling
32
+ - improved HTML parser
33
+ - improved `controller.view()` supports calling without arguments
34
+ - extended ViewEngine by adding `view.renderlayout(name, content)` method
16
35
 
17
36
  ========================
18
37
  0.0.6
package/components.js CHANGED
@@ -88,6 +88,7 @@ function Component() {
88
88
  t.variables = t.variables2 = {};
89
89
  t.secrets = {};
90
90
  t.instances = [];
91
+ t.debugger = true;
91
92
  }
92
93
 
93
94
  Component.prototype.service = function(counter) {
@@ -96,23 +97,28 @@ Component.prototype.service = function(counter) {
96
97
  };
97
98
 
98
99
  Component.prototype.status = function(instance, msg) {
99
- console.log('STATUS', this.name, msg);
100
+ if (this.debugger)
101
+ console.log('STATUS', this.name, msg);
100
102
  };
101
103
 
102
104
  Component.prototype.debug = function(instance, msg) {
103
- console.log('DEBUG', this.name + ':', msg);
105
+ if (this.debugger)
106
+ console.log('DEBUG', this.name + ':', msg);
104
107
  };
105
108
 
106
109
  Component.prototype.dashboard = function(instance, msg) {
107
- console.log('DASHBOARD', this.name + ':', msg);
110
+ if (this.debugger)
111
+ console.log('DASHBOARD', this.name + ':', msg);
108
112
  };
109
113
 
110
114
  Component.prototype.throw = function(instance, err) {
111
- console.log('ERROR', this.name + ':', err);
115
+ if (this.debugger)
116
+ console.log('ERROR', this.name + ':', err);
112
117
  };
113
118
 
114
119
  Component.prototype.output = function(instance, response) {
115
- console.log('OUTPUT', this.name + ' | ' + response.output + ':', response.data);
120
+ if (this.debugger)
121
+ console.log('OUTPUT', this.name + ' | ' + response.output + ':', response.data);
116
122
  };
117
123
 
118
124
  Component.prototype.create = function(opt, status) {
@@ -129,6 +135,7 @@ Component.prototype.create = function(opt, status) {
129
135
  }
130
136
 
131
137
  t.instances.push(instance);
138
+ t.onextend && t.onextend(instance);
132
139
  t.make.call(instance, instance, instance.config, status);
133
140
  t.oncreate && setImmediate(() => t.oncreate(instance));
134
141
  return instance;
@@ -166,6 +173,7 @@ Message.prototype.send = function(output, data) {
166
173
  if (data != null)
167
174
  t.data = data;
168
175
  t.output = output;
176
+ t.callback && t.callback(t);
169
177
  t.instance.output && t.instance.output(t);
170
178
  };
171
179
 
@@ -201,19 +209,31 @@ Instance.prototype.remove = function() {
201
209
  t.module.instances.splice(index, 1);
202
210
  };
203
211
 
204
- Instance.prototype.input = function(input, data) {
212
+ Instance.prototype.input = function(input, data, callback) {
205
213
  let t = this;
206
214
  if (t.message) {
215
+
207
216
  let msg = t.newmessage(data);
208
217
  msg.input = input;
218
+ msg.callback = callback;
219
+
220
+ var schema = t.module.inputschemas[input];
221
+ if (schema) {
222
+ let tmp = schema.transform(msg.data);
223
+ msg.data = tmp.response;
224
+ msg.error = tmp.error;
225
+ }
226
+
209
227
  t.message(msg);
228
+ let fn = t['message_' + input];
229
+ fn && fn(msg);
210
230
  }
211
231
  };
212
232
 
213
233
  Instance.prototype.send = function(output, data) {
214
234
  let msg = data instanceof Message ? data : this.newmessage();
215
235
  msg.output = output;
216
- msg.data = data;
236
+ msg.data = data;x
217
237
  msg.send(output);
218
238
  };
219
239
 
@@ -276,6 +296,30 @@ exports.compile = function(html, callback) {
276
296
  })
277
297
  }
278
298
 
299
+ if ((/^http(s)\:\/\//i).test(html)) {
300
+ let opt = {};
301
+ opt.url = html;
302
+ opt.callback = function(err, response) {
303
+ console.log(err, response);
304
+ if (err)
305
+ callback(err);
306
+ else
307
+ exports.compile(response.body, callback);
308
+ };
309
+ REQUEST(opt);
310
+ return;
311
+ }
312
+
313
+ if (!html.includes('<')) {
314
+ F.Fs.readFile(PATH.root('components/' + html + '.html'), 'utf8', function(err, response) {
315
+ if (err)
316
+ callback(err);
317
+ else
318
+ exports.compile(response, callback);
319
+ });
320
+ return;
321
+ }
322
+
279
323
  var meta = html.parseComponent({ readme: '<readme>', settings: '<settings>', css: '<style>', be: '<script total>', be2: '<script node>', js: '<script>', html: '<body>', schema: '<schema>', template: '<template>' });
280
324
  var node = (meta.be || meta.be2 || '').trim().replace(/\n\t/g, '\n');
281
325
 
@@ -311,7 +355,26 @@ exports.compile = function(html, callback) {
311
355
  next();
312
356
  });
313
357
  }, function() {
358
+
359
+ com.inputschemas = {};
360
+ com.outputschemas = {};
361
+
362
+ if (com.inputs) {
363
+ for (let m of com.inputs) {
364
+ if (m.schema)
365
+ com.inputschemas[m.id] = m.schema.toJSONSchema();
366
+ }
367
+ }
368
+
369
+ if (com.outputs) {
370
+ for (let m of com.outputs) {
371
+ if (m.schema)
372
+ com.outputschemas[m.id] = m.schema.toJSONSchema();
373
+ }
374
+ }
375
+
314
376
  com.install && com.install.call(com, com);
377
+
315
378
  callback(null, com);
316
379
  });
317
380
 
package/controller.js CHANGED
@@ -15,6 +15,7 @@ const CHECK_COMPRESSION = { 'text/plain': true, 'text/javascript': true, 'text/c
15
15
  const CHECK_CHARSET = { 'text/plain': true, 'text/javascript': true, 'text/css': true, 'text/jsx': true, 'application/javascript': true, 'application/x-javascript': true, 'application/json': true, 'text/xml': true, 'text/x-markdown': true, 'text/html': true, 'application/x-ijsnb+json': true, 'application/x-ipynb+json': true };
16
16
  const CHECK_NOCACHE = { zip: 1, rar: 1 };
17
17
  const CHECK_MIN = /(\.|-|@)min/i;
18
+ const CHECK_CACHEDEBUG = { html: 1, js: 1, css: 1 };
18
19
 
19
20
  const GZIP_FILE = { memLevel: 9 };
20
21
  const GZIP_STREAM = { memLevel: 1 };
@@ -64,7 +65,7 @@ function Controller(req, res) {
64
65
 
65
66
  ctrl.response = {
66
67
  status: 200,
67
- cache: global.DEBUG != true,
68
+ cache: !global.DEBUG || !CHECK_CACHEDEBUG[ctrl.ext],
68
69
  minify: true,
69
70
  // minifyjson: false
70
71
  // encrypt: false
@@ -466,13 +467,17 @@ Controller.prototype.layout = function(name) {
466
467
  Controller.prototype.view = function(name, model) {
467
468
 
468
469
  var ctrl = this;
470
+ var view = new F.TViewEngine.View(ctrl);
471
+
472
+ if (!name)
473
+ return view;
469
474
 
470
475
  if (ctrl.destroyed)
471
476
  return;
472
477
 
473
- var view = new F.TViewEngine.View(ctrl);
474
478
  ctrl.response.layout && view.layout(ctrl.response.layout);
475
479
  setImmediate(renderview, view, name, model);
480
+
476
481
  return view;
477
482
  };
478
483
 
package/edit.js CHANGED
@@ -9,7 +9,15 @@ const VERSION = 1;
9
9
  const HEADER = '> Total.js Code Editor';
10
10
  const DIVIDER = '----------------------------------------------------';
11
11
 
12
- exports.init = function(url) {
12
+ var DIRECTORY = '';
13
+
14
+ function makepath(path) {
15
+ return path ? F.path.$join(DIRECTORY, path) : DIRECTORY;
16
+ }
17
+
18
+ exports.init = function(url, dir) {
19
+
20
+ DIRECTORY = dir || F.directory;
13
21
 
14
22
  var client = F.websocketclient();
15
23
 
@@ -188,7 +196,7 @@ function mkdir(path, callback) {
188
196
  }
189
197
 
190
198
  function browse($, model) {
191
- var path = F.path.root();
199
+ var path = makepath();
192
200
  var m = (model.data || '{}').parseJSON() || EMPTYARRAY;
193
201
  var skip = m.skip ? new RegExp(m.skip) : null;
194
202
  var validator;
@@ -217,7 +225,7 @@ function browse($, model) {
217
225
  }
218
226
 
219
227
  function log($, model) {
220
- var filename = F.Path.normalize(F.path.root(model.path));
228
+ var filename = F.Path.normalize(makepath(model.path));
221
229
  F.Fs.stat(filename, function(err, stats) {
222
230
  if (stats) {
223
231
  var start = stats.size - (1024 * 4); // Max. 4 kB
@@ -234,13 +242,13 @@ function log($, model) {
234
242
  }
235
243
 
236
244
  function clearlog($, model) {
237
- var filename = F.path.root(model.path);
245
+ var filename = makepath(model.path);
238
246
  F.Fs.truncate(filename, NOOP);
239
247
  $.success();
240
248
  }
241
249
 
242
250
  function load($, model) {
243
- var filename = F.Path.normalize(F.path.root(model.path));
251
+ var filename = F.Path.normalize(makepath(model.path));
244
252
  F.Fs.readFile(filename, function(err, data) {
245
253
 
246
254
  if (err) {
@@ -276,7 +284,7 @@ function restart($) {
276
284
  function save($, model) {
277
285
 
278
286
  // Tries to create a folder
279
- var filename = F.path.root(model.path);
287
+ var filename = makepath(model.path);
280
288
  var name = F.TUtils.getName(model.path);
281
289
  var directory = F.Path.normalize(filename.substring(0, filename.length - name.length));
282
290
 
@@ -291,7 +299,7 @@ function save($, model) {
291
299
  }
292
300
 
293
301
  function remove($, model) {
294
- var filename = F.Path.normalize(F.path.root(model.path));
302
+ var filename = F.Path.normalize(makepath(model.path));
295
303
  try {
296
304
  var stats = F.Fs.lstatSync(filename);
297
305
  if (stats.isFile()) {
@@ -308,12 +316,12 @@ function remove($, model) {
308
316
  }
309
317
 
310
318
  function info($, model) {
311
- var filename = F.Path.normalize(F.path.root(model.path));
319
+ var filename = F.Path.normalize(makepath(model.path));
312
320
  F.Fs.lstat(filename, $.callback);
313
321
  }
314
322
 
315
323
  function download($, model) {
316
- var filename = F.Path.normalize(F.path.root(model.path));
324
+ var filename = F.Path.normalize(makepath(model.path));
317
325
  var ext = F.TUtils.getExtension(model.path);
318
326
  F.Fs.lstat(filename, function(err, stats) {
319
327
  if (err || stats.isDirectory() || stats.isSocket()) {
@@ -342,7 +350,7 @@ function download($, model) {
342
350
  }
343
351
 
344
352
  function send($, model) {
345
- var filename = F.Path.normalize(F.path.root(model.path));
353
+ var filename = F.Path.normalize(makepath(model.path));
346
354
  F.Fs.fstat(filename, function() {
347
355
  var opt = {};
348
356
  opt.method = 'GET';
@@ -354,7 +362,7 @@ function send($, model) {
354
362
  }
355
363
 
356
364
  function customimport($, model) {
357
- var filename = F.Path.normalize(F.path.root(model.path));
365
+ var filename = F.Path.normalize(makepath(model.path));
358
366
  DOWNLOAD(model.data, filename, $.done());
359
367
  }
360
368
 
@@ -370,8 +378,8 @@ function rename($, model) {
370
378
 
371
379
  data = data.response;
372
380
 
373
- data.newpath = F.Path.normalize(F.path.root(data.newpath));
374
- data.oldpath = F.Path.normalize(F.path.root(data.oldpath));
381
+ data.newpath = F.Path.normalize(makepath(data.newpath));
382
+ data.oldpath = F.Path.normalize(makepath(data.oldpath));
375
383
 
376
384
  mkdir(F.Path.dirname(data.newpath), function() {
377
385
  F.Fs.rename(data.oldpath, data.newpath, $.done());
@@ -385,7 +393,7 @@ function create($, model) {
385
393
  // model.data.clone {String}
386
394
  // model.data.folder {Boolean}
387
395
 
388
- var filename = F.Path.normalize(F.path.root(model.path));
396
+ var filename = F.Path.normalize(makepath(model.path));
389
397
  var data = (model.data || '{}').parseJSON();
390
398
 
391
399
  F.Fs.lstat(filename, function(err) {
@@ -395,14 +403,14 @@ function create($, model) {
395
403
  // we can continue
396
404
  if (data.folder) {
397
405
  if (model.clone)
398
- F.Fs.cp(F.Path.normalize(F.path.root(data.clone)), filename, { recursive: true, force: true }, $.done());
406
+ F.Fs.cp(F.Path.normalize(makepath(data.clone)), filename, { recursive: true, force: true }, $.done());
399
407
  else
400
408
  mkdir(filename, $.done());
401
409
  } else {
402
410
  var name = F.TUtils.getName(filename);
403
411
  mkdir(filename.substring(0, filename.length - name.length), function() {
404
412
  if (data.clone)
405
- F.Fs.copyFile(F.Path.normalize(F.path.root(data.clone)), filename, $.done());
413
+ F.Fs.copyFile(F.Path.normalize(makepath(data.clone)), filename, $.done());
406
414
  else
407
415
  F.Fs.writeFile(filename, '', $.done());
408
416
  });
@@ -414,8 +422,8 @@ function create($, model) {
414
422
 
415
423
  function upload($, model) {
416
424
  var name = F.TUtils.getName(model.path);
417
- var filename = F.Path.normalize(F.path.root(model.path));
418
- var directory = F.Path.normalize(F.path.root(model.path.substring(0, model.length - name.length)));
425
+ var filename = F.Path.normalize(makepath(model.path));
426
+ var directory = F.Path.normalize(makepath(model.path.substring(0, model.length - name.length)));
419
427
  mkdir(directory, function() {
420
428
  decodedata(model, function(err, buffer) {
421
429
  if (err)
@@ -427,7 +435,7 @@ function upload($, model) {
427
435
  }
428
436
 
429
437
  function modify($, model) {
430
- var filename = F.path.root(model.path);
438
+ var filename = makepath(model.path);
431
439
  var dt = new Date();
432
440
  F.Fs.utimes(filename, dt, dt, NOOP);
433
441
  $.success();
@@ -1320,7 +1320,7 @@ function init_current(meta, callback, nested) {
1320
1320
 
1321
1321
  if (instance) {
1322
1322
  if (typeof(instance) === 'string') {
1323
- if (source === 'add') {
1323
+ if (source === 'add' || source === 'register') {
1324
1324
  componentid = instance;
1325
1325
  F.error(err, 'FlowStream | register component | ' + instance);
1326
1326
  } else if (meta.design[instance]) {
@@ -1339,9 +1339,6 @@ function init_current(meta, callback, nested) {
1339
1339
  } else if (source === 'instance_make') {
1340
1340
  instanceid = instance.id;
1341
1341
  componentid = instance.component;
1342
- } else if (source === 'register') {
1343
- instanceid = '';
1344
- componentid = instance;
1345
1342
  } else {
1346
1343
  instanceid = instance.id;
1347
1344
  componentid = instance.module.id;
@@ -1449,9 +1446,11 @@ function init_current(meta, callback, nested) {
1449
1446
  } else if (source === 'register') {
1450
1447
  instanceid = '';
1451
1448
  componentid = instance;
1449
+ } else if (source === 'add') {
1450
+ componentid = instance;
1452
1451
  } else {
1453
1452
  instanceid = instance.id;
1454
- componentid = instance.module.id;
1453
+ componentid = instance.module ? instance.module.id : null;
1455
1454
  }
1456
1455
  }
1457
1456
 
@@ -2461,6 +2460,8 @@ function MAKEFLOWSTREAM(meta) {
2461
2460
  minutes = stats.minutes;
2462
2461
  if (isFLOWSTREAMWORKER)
2463
2462
  memory = process.memoryUsage().heapUsed;
2463
+ else if (F.consumption.memory)
2464
+ memory = F.consumption.memory * 1024 * 1024;
2464
2465
  }
2465
2466
 
2466
2467
  flow.stats.memory = memory;
package/flow.js CHANGED
@@ -16,7 +16,6 @@ FS.worker = false;
16
16
  FS.instances = {};
17
17
  FS.onerror = function(err, source, id, componentid, stack) {
18
18
 
19
- throw new Error('FET');
20
19
  var flow = FS.db[this.id];
21
20
  var empty = '---';
22
21
  var output = '';
package/flowstream.js CHANGED
@@ -305,10 +305,8 @@ function variables(str, data, encoding) {
305
305
 
306
306
  var customencoding = typeof(encoding) === 'function';
307
307
 
308
- if (!val && data != null && typeof(data) === 'object') {
309
- var nested = key.indexOf('.') !== -1;
310
- val = nested ? F.TUtils.get(data, key) : data[key];
311
- }
308
+ if (!val && data != null && typeof(data) === 'object')
309
+ val = key.includes('.') ? F.TUtils.get(data, key) : data[key];
312
310
 
313
311
  if (customencoding) {
314
312
 
@@ -353,7 +351,7 @@ function timeouthandler(msg) {
353
351
 
354
352
  MP.send = function(outputindex, data, clonedata) {
355
353
 
356
- var self = this;
354
+ let self = this;
357
355
 
358
356
  if (clonedata == null)
359
357
  clonedata = self.main.cloning;
@@ -364,13 +362,13 @@ MP.send = function(outputindex, data, clonedata) {
364
362
  return 0;
365
363
  }
366
364
 
367
- var outputs;
368
- var count = 0;
365
+ let outputs;
366
+ let count = 0;
369
367
 
370
368
  if (outputindex == null) {
371
369
 
372
370
  if (self.instance.connections) {
373
- for (var key in self.instance.connections)
371
+ for (let key in self.instance.connections)
374
372
  count += self.send(key);
375
373
  }
376
374
 
@@ -381,8 +379,8 @@ MP.send = function(outputindex, data, clonedata) {
381
379
  }
382
380
 
383
381
 
384
- var meta = self.main.meta;
385
- var now = Date.now();
382
+ let meta = self.main.meta;
383
+ let now = Date.now();
386
384
 
387
385
  outputs = self.instance.connections ? (self.instance.connections[outputindex] || F.EMPTYARRAY) : F.EMPTYARRAY;
388
386
 
@@ -407,7 +405,7 @@ MP.send = function(outputindex, data, clonedata) {
407
405
  return count;
408
406
  }
409
407
 
410
- var tid = self.toid + D + outputindex + (self.color || '');
408
+ let tid = self.toid + D + outputindex + (self.color || '');
411
409
 
412
410
  if (self.main.stats.traffic[tid]) {
413
411
  self.main.stats.traffic[tid]++;
@@ -419,29 +417,30 @@ MP.send = function(outputindex, data, clonedata) {
419
417
  if (self.transformation === '1')
420
418
  self.transformation = '_' + tid;
421
419
 
422
- for (var i = 0; i < outputs.length; i++) {
423
- var output = outputs[i];
420
+ for (let i = 0; i < outputs.length; i++) {
421
+
422
+ let output = outputs[i];
424
423
 
425
424
  if (output.disabled || output.paused)
426
425
  continue;
427
426
 
428
- var schema = meta.flow[output.id];
427
+ let schema = meta.flow[output.id];
429
428
  if (schema && (schema.message || schema['message_' + output.index]) && schema.component && schema.ready && self.main.$can(true, output.id, output.index)) {
430
- var next = meta.components[schema.component];
429
+ let next = meta.components[schema.component];
431
430
  if (next && next.connected && !next.isdestroyed && !next.disabled) {
432
431
 
433
432
  if (output.color && self.color && self.color !== output.color)
434
433
  continue;
435
434
 
436
- var inputindex = output.index;
437
- var message = self.clone();
435
+ let inputindex = output.index;
436
+ let message = self.clone();
438
437
 
439
438
  if (data != undefined)
440
439
  message.data = data;
441
440
 
442
441
  if (clonedata && message.data && typeof(message.data) === 'object') {
443
442
  if (message.data instanceof Buffer) {
444
- var buf = Buffer.alloc(message.data.length);
443
+ let buf = Buffer.alloc(message.data.length);
445
444
  buf.copy(message.data);
446
445
  message.data = buf;
447
446
  } else
@@ -462,6 +461,13 @@ MP.send = function(outputindex, data, clonedata) {
462
461
  message.ts = now;
463
462
  message.color = output.color;
464
463
 
464
+ let ti = schema.inputschemas[message.input];
465
+ if (ti && ti.schema) {
466
+ let tmp = ti.schema.transform(typeof(message.data) === 'object' ? message.data : {});
467
+ message.data = tmp.response;
468
+ message.error = tmp.error;
469
+ }
470
+
465
471
  if (self.$timeout)
466
472
  message.$timeoutid = setTimeout(timeouthandler, self.$timeout, message);
467
473
 
@@ -1140,6 +1146,13 @@ FP.ontrigger = function(outputindex, data, controller, events) {
1140
1146
  message.cache = target.cache;
1141
1147
  message.processed = 0;
1142
1148
 
1149
+ let ti = target.inputschemas[message.input];
1150
+ if (ti && ti.schema) {
1151
+ let tmp = ti.schema.transform(message.data);
1152
+ message.data = tmp.response;
1153
+ message.error = tmp.error;
1154
+ }
1155
+
1143
1156
  target.stats.pending++;
1144
1157
  target.stats.input++;
1145
1158
  schema.stats.output++;
@@ -1193,6 +1206,7 @@ FP.reconfigure = function(id, config, rewrite) {
1193
1206
  self.onreconfigure && self.onreconfigure(instance);
1194
1207
  self.$events.configure && self.emit('configure', instance);
1195
1208
  }
1209
+
1196
1210
  return !!instance;
1197
1211
  };
1198
1212
 
@@ -1605,6 +1619,28 @@ FP.initcomponent = function(key, component) {
1605
1619
  instance.replace = variables;
1606
1620
  instance.instances = self.meta.flow;
1607
1621
  instance.components = self.meta.components;
1622
+ instance.inputschemas = {};
1623
+ instance.outputschemas = {};
1624
+
1625
+ // Due to inline data schemas
1626
+ if (component.inputs) {
1627
+ for (let m of component.inputs) {
1628
+ let tmp = CLONE(m);
1629
+ instance.inputschemas[m.id] = tmp;
1630
+ if (tmp.schema)
1631
+ tmp.schema = tmp.schema.toJSONSchema();
1632
+ }
1633
+ }
1634
+
1635
+ // Due to inline data schemas
1636
+ if (component.outputs) {
1637
+ for (let m in component.outputs) {
1638
+ let tmp = CLONE(m);
1639
+ instance.outputschemas[m.id] = tmp;
1640
+ if (tmp.schema)
1641
+ tmp.schema = tmp.schema.toJSONSchema();
1642
+ }
1643
+ }
1608
1644
 
1609
1645
  self.onconnect && self.onconnect(instance);
1610
1646
  self.$events.connect && self.emit('connect', instance);
package/htmlparser.js CHANGED
@@ -71,8 +71,13 @@ function parseRule(selector, output) {
71
71
  if (selector[selector.length - 1] === ':') {
72
72
  rule.prefix = selector.toUpperCase();
73
73
  rule.tagName = '';
74
- } else
74
+ } else {
75
+ if (selector.substring(0, 2) === '*:') {
76
+ rule.prefix = '*';
77
+ selector = selector.substring(2);
78
+ }
75
79
  rule.tagName = selector[0] === '*' ? '' : selector.toUpperCase();
80
+ }
76
81
 
77
82
  return rule;
78
83
  }
@@ -170,11 +175,21 @@ HTMLElement.prototype.find = function(selector, reverse) {
170
175
 
171
176
  var skip = false;
172
177
 
173
- if (rule.tagName && rule.tagName !== node.tagName)
174
- skip = true;
178
+ if (rule.prefix === '*') {
179
+
180
+ var tagName = node.tagName;
181
+ if (node.prefix)
182
+ tagName = tagName.substring(node.prefix.length);
175
183
 
176
- if (rule.prefix && rule.prefix !== node.prefix)
177
- skip = true;
184
+ if (tagName !== rule.tagName)
185
+ skip = true;
186
+
187
+ } else {
188
+ if (rule.tagName && rule.tagName !== node.tagName)
189
+ skip = true;
190
+ if (rule.prefix && rule.prefix !== node.prefix)
191
+ skip = true;
192
+ }
178
193
 
179
194
  if (rule.attrs.length && !skip) {
180
195
  for (var attr of rule.attrs) {
@@ -561,7 +576,15 @@ function parseHTML(html, trim, onerror, isxml) {
561
576
  }
562
577
 
563
578
  var tag = node;
564
- var index = tag.indexOf(' ');
579
+ var index = -1;
580
+
581
+ for (let i = 0; i < tag.length; i++) {
582
+ let c = tag[i];
583
+ if (c === '\n' || c === ' ' || c === '/' || c === '>') {
584
+ index = i;
585
+ break;
586
+ }
587
+ }
565
588
 
566
589
  if (index > 0) {
567
590
  tag = tag.substring(0, index);
@@ -597,9 +620,14 @@ function parseHTML(html, trim, onerror, isxml) {
597
620
  case 'BR':
598
621
  case 'HR':
599
622
  case 'IMG':
623
+ case 'INPUT':
600
624
  case 'META':
601
625
  case 'LINK':
602
- case 'INPUT':
626
+ case 'SOURCE':
627
+ case 'AREA':
628
+ case 'COL':
629
+ case 'EMBED':
630
+ case 'TRACK':
603
631
  dom.unpair = true;
604
632
  return str;
605
633
  }
@@ -677,4 +705,4 @@ function parseHTML(html, trim, onerror, isxml) {
677
705
  return dom;
678
706
  }
679
707
 
680
- exports.parseHTML = parseHTML;
708
+ exports.parseHTML = parseHTML;
package/index.js CHANGED
@@ -36,7 +36,7 @@ global.DEF = {};
36
36
 
37
37
  F.id = '';
38
38
  F.clusterid = '';
39
- F.is5 = F.version = 5007;
39
+ F.is5 = F.version = 5008;
40
40
  F.isBundle = false;
41
41
  F.isLoaded = false;
42
42
  F.version_header = '5';
@@ -221,6 +221,7 @@ global.DEF = {};
221
221
  F.path = {};
222
222
  F.path.root = path => path ? F.path.$join(F.directory, path) : F.directory;
223
223
  F.path.logs = path => path ? F.path.$join(F.temporary.directories.logs, path) : F.temporary.directories.logs;
224
+ F.path.scripts = path => path ? F.path.$join(F.temporary.directories.scripts, path) : F.temporary.directories.scripts;
224
225
  F.path.public = path => path ? F.path.$join(F.temporary.directories.public, path) : F.temporary.directories.public;
225
226
  F.path.private = path => path ? F.path.$join(F.temporary.directories.private, path) : F.temporary.directories.private;
226
227
  F.path.databases = path => path ? F.path.$join(F.temporary.directories.databases, path) : F.temporary.directories.databases;
@@ -791,7 +792,7 @@ F.load = async function(types, callback) {
791
792
  }
792
793
  }
793
794
 
794
- let loader = ['modules', 'actions', 'schemas', 'models', 'definitions', 'controllers', 'middleware', 'sources'];
795
+ let loader = ['modules', 'actions', 'schemas', 'models', 'definitions', 'controllers', 'middleware', 'sources', 'scripts'];
795
796
  var files = [];
796
797
  var tmp;
797
798
 
@@ -2567,7 +2568,7 @@ F.dir = function(val) {
2567
2568
  if (val)
2568
2569
  F.directory = val;
2569
2570
 
2570
- var dirs = ['public', 'tmp', 'logs', 'databases', 'controllers', 'resources', 'plugins', 'modules', 'views', 'definitions', 'schemas', 'models', 'flowstreams', 'bundles', 'actions', 'extensions', 'source', 'services', 'updates', 'templates', 'private'];
2571
+ var dirs = ['public', 'tmp', 'logs', 'databases', 'controllers', 'resources', 'plugins', 'modules', 'views', 'definitions', 'schemas', 'models', 'flowstreams', 'bundles', 'actions', 'extensions', 'source', 'services', 'updates', 'templates', 'private', 'scripts'];
2571
2572
 
2572
2573
  for (let dir of dirs) {
2573
2574
  let cfg = F.config['$dir' + dir];
@@ -2640,6 +2641,10 @@ F.htmlmail = function(email, subject, body, language, callback) {
2640
2641
  return F.def.onMail(email, subject, body, callback);
2641
2642
  };
2642
2643
 
2644
+ F.remote = function(url, dir) {
2645
+ require('./edit').init(url, dir);
2646
+ };
2647
+
2643
2648
  F.readfile = function(path, type = null) {
2644
2649
  return new Promise(resolve => F.Fs.readFile(path, type, (err, response) => err ? resolve(null) : resolve(response)));
2645
2650
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "total5",
3
- "version": "0.0.7-3",
3
+ "version": "0.0.8-1",
4
4
  "description": "Total.js framework v5",
5
5
  "main": "index.js",
6
6
  "directories": {
package/templates.js CHANGED
@@ -35,7 +35,7 @@ exports.render = function(body, model, $) {
35
35
  var opt = {};
36
36
  opt.url = body;
37
37
  opt.method = 'GET';
38
- opt.$ = function(err, response) {
38
+ opt.callback = function(err, response) {
39
39
 
40
40
  if (err) {
41
41
  if ($ && $.invalid)
package/viewengine.js CHANGED
@@ -873,12 +873,21 @@ View.prototype.set = function() {
873
873
  return '';
874
874
  };
875
875
 
876
+ View.prototype.renderlayout = function(name, content) {
877
+ let self = this;
878
+ self.output = content;
879
+ self.islayout = true;
880
+ content = self.render(self.repository.layout);
881
+ self.islayout = false;
882
+ return content;
883
+ };
884
+
876
885
  View.prototype.render = function(name, model, ispartial = false) {
877
886
 
878
- var self = this;
879
- var key = name + '_' + self.language;
880
- var fn = F.temporary.views[key];
881
- var content;
887
+ let self = this;
888
+ let key = name + '_' + self.language;
889
+ let fn = F.temporary.views[key];
890
+ let content;
882
891
 
883
892
  self.model = model;
884
893
 
@@ -897,6 +906,7 @@ View.prototype.render = function(name, model, ispartial = false) {
897
906
  self.output = content;
898
907
  self.islayout = true;
899
908
  content = self.render(self.repository.layout);
909
+ self.islayout = false;
900
910
  }
901
911
 
902
912
  return content;