total5 0.0.7 → 0.0.8-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/api.js +11 -2
- package/builders.js +1 -1
- package/changelog.txt +14 -0
- package/components.js +5 -5
- package/controller.js +2 -1
- package/edit.js +27 -19
- package/htmlparser.js +43 -14
- package/index.js +8 -3
- package/package.json +1 -1
- package/templates.js +1 -1
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
|
-
|
|
41
|
-
t.options = {};
|
|
50
|
+
this.options = new APIOptions(this);
|
|
42
51
|
}
|
|
43
52
|
|
|
44
53
|
const APICallProto = APICall.prototype;
|
package/builders.js
CHANGED
package/changelog.txt
CHANGED
|
@@ -1,3 +1,17 @@
|
|
|
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
|
+
- fixed parsing of unpaired elements in HTMLParser
|
|
14
|
+
|
|
1
15
|
========================
|
|
2
16
|
0.0.7
|
|
3
17
|
========================
|
package/components.js
CHANGED
|
@@ -97,27 +97,27 @@ Component.prototype.service = function(counter) {
|
|
|
97
97
|
};
|
|
98
98
|
|
|
99
99
|
Component.prototype.status = function(instance, msg) {
|
|
100
|
-
if (
|
|
100
|
+
if (this.debugger)
|
|
101
101
|
console.log('STATUS', this.name, msg);
|
|
102
102
|
};
|
|
103
103
|
|
|
104
104
|
Component.prototype.debug = function(instance, msg) {
|
|
105
|
-
if (
|
|
105
|
+
if (this.debugger)
|
|
106
106
|
console.log('DEBUG', this.name + ':', msg);
|
|
107
107
|
};
|
|
108
108
|
|
|
109
109
|
Component.prototype.dashboard = function(instance, msg) {
|
|
110
|
-
if (
|
|
110
|
+
if (this.debugger)
|
|
111
111
|
console.log('DASHBOARD', this.name + ':', msg);
|
|
112
112
|
};
|
|
113
113
|
|
|
114
114
|
Component.prototype.throw = function(instance, err) {
|
|
115
|
-
if (
|
|
115
|
+
if (this.debugger)
|
|
116
116
|
console.log('ERROR', this.name + ':', err);
|
|
117
117
|
};
|
|
118
118
|
|
|
119
119
|
Component.prototype.output = function(instance, response) {
|
|
120
|
-
if (
|
|
120
|
+
if (this.debugger)
|
|
121
121
|
console.log('OUTPUT', this.name + ' | ' + response.output + ':', response.data);
|
|
122
122
|
};
|
|
123
123
|
|
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
|
|
68
|
+
cache: !global.DEBUG || !CHECK_CACHEDEBUG[ctrl.ext],
|
|
68
69
|
minify: true,
|
|
69
70
|
// minifyjson: false
|
|
70
71
|
// encrypt: false
|
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
|
-
|
|
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 =
|
|
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(
|
|
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 =
|
|
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(
|
|
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 =
|
|
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(
|
|
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(
|
|
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(
|
|
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(
|
|
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(
|
|
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(
|
|
374
|
-
data.oldpath = F.Path.normalize(
|
|
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(
|
|
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(
|
|
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(
|
|
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(
|
|
418
|
-
var directory = F.Path.normalize(
|
|
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 =
|
|
438
|
+
var filename = makepath(model.path);
|
|
431
439
|
var dt = new Date();
|
|
432
440
|
F.Fs.utimes(filename, dt, dt, NOOP);
|
|
433
441
|
$.success();
|
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.
|
|
174
|
-
|
|
178
|
+
if (rule.prefix === '*') {
|
|
179
|
+
|
|
180
|
+
var tagName = node.tagName;
|
|
181
|
+
if (node.prefix)
|
|
182
|
+
tagName = tagName.substring(node.prefix.length);
|
|
183
|
+
|
|
184
|
+
if (tagName !== rule.tagName)
|
|
185
|
+
skip = true;
|
|
175
186
|
|
|
176
|
-
|
|
177
|
-
|
|
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) {
|
|
@@ -535,7 +550,6 @@ function parseHTML(html, trim, onerror, isxml) {
|
|
|
535
550
|
return '';
|
|
536
551
|
}
|
|
537
552
|
|
|
538
|
-
|
|
539
553
|
if (beg > 0) {
|
|
540
554
|
tmp = str.substring(0, beg);
|
|
541
555
|
|
|
@@ -602,12 +616,6 @@ function parseHTML(html, trim, onerror, isxml) {
|
|
|
602
616
|
return str;
|
|
603
617
|
} else {
|
|
604
618
|
switch (dom.tagName) {
|
|
605
|
-
case 'BR':
|
|
606
|
-
case 'HR':
|
|
607
|
-
case 'IMG':
|
|
608
|
-
case 'INPUT':
|
|
609
|
-
case 'META':
|
|
610
|
-
case 'LINK':
|
|
611
619
|
case 'SOURCE':
|
|
612
620
|
case 'AREA':
|
|
613
621
|
case 'COL':
|
|
@@ -628,6 +636,26 @@ function parseHTML(html, trim, onerror, isxml) {
|
|
|
628
636
|
break;
|
|
629
637
|
|
|
630
638
|
beg = str.indexOf(tagBeg, pos);
|
|
639
|
+
|
|
640
|
+
if (beg !== -1) {
|
|
641
|
+
|
|
642
|
+
// another one with the same type
|
|
643
|
+
// check unpair
|
|
644
|
+
|
|
645
|
+
let posend = str.indexOf('>', beg + tagBeg.length);
|
|
646
|
+
if (posend === -1) {
|
|
647
|
+
// tag is not closed
|
|
648
|
+
return '';
|
|
649
|
+
}
|
|
650
|
+
|
|
651
|
+
if (str[posend - 1] === '/') {
|
|
652
|
+
// unpair
|
|
653
|
+
pos = posend + 1;
|
|
654
|
+
continue;
|
|
655
|
+
}
|
|
656
|
+
|
|
657
|
+
}
|
|
658
|
+
|
|
631
659
|
end = str.indexOf(tagEnd, pos);
|
|
632
660
|
|
|
633
661
|
// Fallback for the non-exists end tag
|
|
@@ -656,7 +684,8 @@ function parseHTML(html, trim, onerror, isxml) {
|
|
|
656
684
|
}
|
|
657
685
|
|
|
658
686
|
var inner = str.substring(0, pos - tagEnd.length);
|
|
659
|
-
|
|
687
|
+
|
|
688
|
+
if (inner.indexOf('<') === -1 || (!isxml && (/\<(script|style|template)/).test(tag))) {
|
|
660
689
|
if (trim)
|
|
661
690
|
inner = inner.trim();
|
|
662
691
|
if (inner)
|
|
@@ -690,4 +719,4 @@ function parseHTML(html, trim, onerror, isxml) {
|
|
|
690
719
|
return dom;
|
|
691
720
|
}
|
|
692
721
|
|
|
693
|
-
exports.parseHTML = parseHTML;
|
|
722
|
+
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 =
|
|
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