total5 0.0.13 → 0.0.14-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/changelog.txt CHANGED
@@ -1,3 +1,17 @@
1
+ ========================
2
+ 0.0.14
3
+ ========================
4
+
5
+ - fixed loading plugin files (only `.js` files will load)
6
+ - removed loading of `.DS_STORE` files in plugins
7
+ - added watcher for `extensions/*.html` files
8
+ - __breaking change__: the audit logs object has been changed:
9
+ - `username` renamed to `createdby`
10
+ - `schema` renamed to `action`
11
+ - disabled auto-cleaning files in FlowStream workers
12
+ - improved loading static files in release mode
13
+ - added support for `HEAD` method
14
+
1
15
  ========================
2
16
  0.0.13
3
17
  ========================
package/controller.js CHANGED
@@ -1,6 +1,6 @@
1
1
  // Total.js Controller
2
2
  // The MIT License
3
- // Copyright 2023 (c) Peter Širka <petersirka@gmail.com>
3
+ // Copyright 2023-2025 (c) Peter Širka <petersirka@gmail.com>
4
4
 
5
5
  'use strict';
6
6
 
@@ -396,8 +396,12 @@ Controller.prototype.flush = function() {
396
396
  } else {
397
397
  response.headers['content-encoding'] = 'gzip';
398
398
  ctrl.res.writeHead(response.status, response.headers);
399
- ctrl.res.end(buffer, 'utf8');
400
- F.stats.performance.upload += buffer.length / 1024 / 1024;
399
+ if (ctrl.method === 'HEAD') {
400
+ ctrl.res.end();
401
+ } else {
402
+ ctrl.res.end(buffer, 'utf8');
403
+ F.stats.performance.upload += buffer.length / 1024 / 1024;
404
+ }
401
405
  ctrl.free();
402
406
  }
403
407
  });
@@ -410,7 +414,10 @@ Controller.prototype.flush = function() {
410
414
 
411
415
  try {
412
416
  ctrl.res.writeHead(response.status, response.headers);
413
- ctrl.res.end(buffer);
417
+ if (ctrl.method === 'HEAD')
418
+ ctrl.res.end();
419
+ else
420
+ ctrl.res.end(buffer);
414
421
  } finally {
415
422
  ctrl.free();
416
423
  }
@@ -891,11 +898,12 @@ Controller.prototype.autoclear = function(value) {
891
898
 
892
899
  Controller.prototype.resume = function() {
893
900
 
894
- var ctrl = this;
901
+ let ctrl = this;
895
902
 
896
903
  if (ctrl.isfile) {
897
904
 
898
- var path = ctrl.uri.key;
905
+ let path = ctrl.uri.key;
906
+
899
907
  if (CONF.$root)
900
908
  path = path.substring(CONF.$root.length - 1);
901
909
 
@@ -1379,12 +1387,24 @@ function send_html(ctrl, path) {
1379
1387
  return;
1380
1388
  }
1381
1389
 
1390
+ if (!DEBUG) {
1391
+ if (F.temporary.files[ctrl.uri.cache]) {
1392
+ F.temporary.files[ctrl.uri.cache].push(ctrl);
1393
+ return;
1394
+ }
1395
+ F.temporary.files[ctrl.uri.cache] = [];
1396
+ }
1397
+
1382
1398
  readfile(path, function(err, output) {
1383
1399
 
1384
1400
  if (err) {
1385
1401
 
1386
- if (!DEBUG)
1402
+ if (!DEBUG) {
1387
1403
  F.temporary.notfound[ctrl.uri.cache] = 1;
1404
+ for (let $ of F.temporary.files[ctrl.uri.cache])
1405
+ $.fallback(404);
1406
+ delete F.temporary.files[ctrl.uri.cache];
1407
+ }
1388
1408
 
1389
1409
  ctrl.fallback(404);
1390
1410
  return;
@@ -1405,12 +1425,18 @@ function send_html(ctrl, path) {
1405
1425
  let filename = F.path.tmp(F.clusterid + ctrl.uri.cache.substring(1).replace(REG_FILETMP, '-') + '-min.html');
1406
1426
  F.Fs.writeFile(filename, output.body, function(err) {
1407
1427
  if (err) {
1428
+ err = err.toString();
1408
1429
  F.temporary.notfound[ctrl.uri.cache] = 1;
1409
- ctrl.fallback(404, err.toString());
1430
+ ctrl.fallback(404, err);
1431
+ for (let $ of F.temporary.files[ctrl.uri.cache])
1432
+ $.fallback(404, err);
1410
1433
  } else {
1411
1434
  F.temporary.minified[ctrl.uri.cache] = filename;
1412
1435
  send_file(ctrl, filename, 'html');
1436
+ for (let $ of F.temporary.files[ctrl.uri.cache])
1437
+ send_file($, filename, 'html');
1413
1438
  }
1439
+ delete F.temporary.files[ctrl.uri.cache];
1414
1440
  });
1415
1441
  }
1416
1442
  });
@@ -1429,12 +1455,24 @@ function send_css(ctrl, path) {
1429
1455
  return;
1430
1456
  }
1431
1457
 
1458
+ if (!DEBUG) {
1459
+ if (F.temporary.files[ctrl.uri.cache]) {
1460
+ F.temporary.files[ctrl.uri.cache].push(ctrl);
1461
+ return;
1462
+ } else
1463
+ F.temporary.files[ctrl.uri.cache] = [];
1464
+ }
1465
+
1432
1466
  readfile(path, function(err, output) {
1433
1467
 
1434
1468
  if (err) {
1435
1469
 
1436
- if (!DEBUG)
1470
+ if (!DEBUG) {
1471
+ for (let $ of F.temporary.files[ctrl.uri.cache])
1472
+ $.fallback(404);
1473
+ delete F.temporary.files[ctrl.uri.cache];
1437
1474
  F.temporary.notfound[ctrl.uri.cache] = 1;
1475
+ }
1438
1476
 
1439
1477
  ctrl.fallback(404);
1440
1478
  return;
@@ -1454,11 +1492,17 @@ function send_css(ctrl, path) {
1454
1492
  F.Fs.writeFile(filename, output.body, function(err) {
1455
1493
  if (err) {
1456
1494
  F.temporary.notfound[ctrl.uri.cache] = 1;
1457
- ctrl.fallback(404, err.toString());
1495
+ err = err.toString();
1496
+ ctrl.fallback(404, err);
1497
+ for (let $ of F.temporary.files[ctrl.uri.cache])
1498
+ $.fallback(404, err);
1458
1499
  } else {
1459
1500
  F.temporary.minified[ctrl.uri.cache] = filename;
1460
1501
  send_file(ctrl, filename, 'css');
1502
+ for (let $ of F.temporary.files[ctrl.uri.cache])
1503
+ send_file($, filename, 'css');
1461
1504
  }
1505
+ delete F.temporary.files[ctrl.uri.cache];
1462
1506
  });
1463
1507
  }
1464
1508
  });
@@ -1477,12 +1521,24 @@ function send_js(ctrl, path) {
1477
1521
  return;
1478
1522
  }
1479
1523
 
1524
+ if (!DEBUG) {
1525
+ if (F.temporary.files[ctrl.uri.cache]) {
1526
+ F.temporary.files[ctrl.uri.cache].push(ctrl);
1527
+ return;
1528
+ } else
1529
+ F.temporary.files[ctrl.uri.cache] = [];
1530
+ }
1531
+
1480
1532
  readfile(path, function(err, output) {
1481
1533
 
1482
1534
  if (err) {
1483
1535
 
1484
- if (!DEBUG)
1536
+ if (!DEBUG) {
1537
+ for (let $ of F.temporary.files[ctrl.uri.cache])
1538
+ $.fallback(404);
1539
+ delete F.temporary.files[ctrl.uri.cache];
1485
1540
  F.temporary.notfound[ctrl.uri.cache] = 1;
1541
+ }
1486
1542
 
1487
1543
  ctrl.fallback(404);
1488
1544
  return;
@@ -1502,11 +1558,17 @@ function send_js(ctrl, path) {
1502
1558
  F.Fs.writeFile(filename, output.body, function(err) {
1503
1559
  if (err) {
1504
1560
  F.temporary.notfound[ctrl.uri.cache] = 1;
1505
- ctrl.fallback(404, err.toString());
1561
+ err = err.toString();
1562
+ ctrl.fallback(404, err);
1563
+ for (let $ of F.temporary.files[ctrl.uri.cache])
1564
+ $.fallback(404, err);
1506
1565
  } else {
1507
1566
  F.temporary.minified[ctrl.uri.cache] = filename;
1508
1567
  send_file(ctrl, filename, 'js');
1568
+ for (let $ of F.temporary.files[ctrl.uri.cache])
1569
+ send_file($, filename, 'js');
1509
1570
  }
1571
+ delete F.temporary.files[ctrl.uri.cache];
1510
1572
  });
1511
1573
  }
1512
1574
  });
@@ -1520,7 +1582,7 @@ function send_file(ctrl, path, ext) {
1520
1582
  return;
1521
1583
  }
1522
1584
 
1523
- var cache = F.temporary.tmp[ctrl.uri.cache];
1585
+ let cache = F.temporary.tmp[ctrl.uri.cache];
1524
1586
 
1525
1587
  // HTTP Cache
1526
1588
  if (ctrl.response.cache && cache && ctrl.notmodified(cache.date))
@@ -1592,9 +1654,14 @@ function send_file(ctrl, path, ext) {
1592
1654
  ctrl.response.headers['content-length'] = (end - beg) + 1;
1593
1655
  ctrl.response.headers['content-range'] = 'bytes ' + beg + '-' + end + '/' + cache.size;
1594
1656
  ctrl.res.writeHead(206, ctrl.response.headers);
1595
- reader = F.Fs.createReadStream(path, { start: beg, end: end });
1596
- reader.pipe(ctrl.res);
1597
- F.stats.response.streaming++;
1657
+
1658
+ if (ctrl.method === 'HEAD') {
1659
+ ctrl.res.end();
1660
+ } else {
1661
+ reader = F.Fs.createReadStream(path, { start: beg, end: end });
1662
+ reader.pipe(ctrl.res);
1663
+ F.stats.response.streaming++;
1664
+ }
1598
1665
 
1599
1666
  } else {
1600
1667
 
@@ -1605,12 +1672,15 @@ function send_file(ctrl, path, ext) {
1605
1672
 
1606
1673
  ctrl.res.writeHead(ctrl.response.status, ctrl.response.headers);
1607
1674
 
1608
- if (compress)
1609
- reader.pipe(F.Zlib.createGzip(GZIP_FILE)).pipe(ctrl.res);
1610
- else
1611
- reader.pipe(ctrl.res);
1612
-
1613
- F.stats.response.file++;
1675
+ if (ctrl.method === 'HEAD') {
1676
+ ctrl.res.end();
1677
+ } else {
1678
+ if (compress)
1679
+ reader.pipe(F.Zlib.createGzip(GZIP_FILE)).pipe(ctrl.res);
1680
+ else
1681
+ reader.pipe(ctrl.res);
1682
+ F.stats.response.file++;
1683
+ }
1614
1684
  }
1615
1685
  };
1616
1686
 
package/debug.js CHANGED
@@ -74,7 +74,7 @@ function runwatching() {
74
74
  const REG_FILES = /(config|bundles\.debug|\.js|\.ts|\.flow|\.py|\.resource)+$/i;
75
75
  const REG_PUBLIC = /\/public\//i;
76
76
  const REG_INDEX = new RegExp(FILENAME.replace(/\.js$/, '') + '_.*?\\.js$');
77
- const REG_EXTENSION = /\.(js|ts|py|resource|package|bundle|build|flow|url)$/i;
77
+ const REG_EXTENSION = /\.(js|ts|py|resource|package|bundle|build|flow|url|html)$/i;
78
78
  const REG_RELOAD = /\.(js|ts|py|css|html|htm|jpg|png|gif|ico|svg|webp|resource)$/i;
79
79
  const isRELOAD = !!options.livereload;
80
80
  const SPEED = isRELOAD ? 1000 : 1500;
@@ -1,6 +1,6 @@
1
1
  // Total.js FlowStream module
2
2
  // The MIT License
3
- // Copyright 2021-2023 (c) Peter Širka <petersirka@gmail.com>
3
+ // Copyright 2021-2025 (c) Peter Širka <petersirka@gmail.com>
4
4
 
5
5
  'use strict';
6
6
 
@@ -1004,11 +1004,11 @@ function init_current(meta, callback, nested) {
1004
1004
  if (meta.unixsocket && meta.proxypath) {
1005
1005
  if (!F.isWindows)
1006
1006
  F.Fs.unlink(meta.unixsocket, NOOP);
1007
- F.http({ load: 'none', unixsocket: meta.unixsocket, config: { $stats: false, $sourcemap: false }});
1007
+ F.http({ load: 'none', unixsocket: meta.unixsocket, clear: false, config: { $stats: false, $sourcemap: false }});
1008
1008
  } else {
1009
1009
  F.config.$sourcemap = false;
1010
1010
  F.config.$stats = false;
1011
- F.load('none');
1011
+ F.load('none', null, false);
1012
1012
  }
1013
1013
  }
1014
1014
 
package/http.js CHANGED
@@ -20,13 +20,6 @@ exports.listen = function(req, res) {
20
20
 
21
21
  F.stats.request.request++;
22
22
 
23
- // Not supported
24
- if (req.method === 'HEAD') {
25
- F.stats.request.blocked++;
26
- req.destroy();
27
- return;
28
- }
29
-
30
23
  var ctrl = new F.TController.Controller(req, res);
31
24
 
32
25
  if (F.paused.length) {
package/index.js CHANGED
@@ -1,6 +1,6 @@
1
1
  // Total.js framework
2
2
  // The MIT License
3
- // Copyright 2012-2023 (c) Peter Širka <petersirka@gmail.com>
3
+ // Copyright 2012-2025 (c) Peter Širka <petersirka@gmail.com>
4
4
 
5
5
  'use strict';
6
6
 
@@ -36,7 +36,7 @@ global.DEF = {};
36
36
 
37
37
  F.id = '';
38
38
  F.clusterid = '';
39
- F.is5 = F.version = 5013;
39
+ F.is5 = F.version = 5014;
40
40
  F.isBundle = false;
41
41
  F.isLoaded = false;
42
42
  F.version_header = '5';
@@ -106,6 +106,7 @@ global.DEF = {};
106
106
  versions: {},
107
107
  dependencies: {}, // temporary for module dependencies
108
108
  other: {},
109
+ files: {},
109
110
  cryptokeys: {}, // for crypto keys
110
111
  internal: {}, // controllers/modules names for the routing
111
112
  ready: {},
@@ -743,7 +744,7 @@ F.auth = function(fn) {
743
744
  F.def.onAuthorize = fn;
744
745
  };
745
746
 
746
- F.load = async function(types, callback) {
747
+ F.load = async function(types, callback, clear = true) {
747
748
 
748
749
  if (!types)
749
750
  types = '';
@@ -753,14 +754,16 @@ F.load = async function(types, callback) {
753
754
  F.dir();
754
755
 
755
756
  await F.TBundles.extract();
756
- await F.clear(true);
757
+
758
+ if (clear)
759
+ await F.clear(true);
757
760
 
758
761
  process.send && process.send('total:ready');
759
762
 
760
763
  if (typeof(types) === 'string')
761
764
  types = types.split(',').trim();
762
765
 
763
- var list = async (path, extension = 'js') => new Promise(resolve => F.TUtils.ls(path, files => resolve(files), (path, isdir) => isdir ? true : (path.indexOf('-bk') === -1 && path.indexOf('_bk') === -1 && F.TUtils.getExtension(path) === extension)));
766
+ var list = async (path, extension = 'js') => new Promise(resolve => F.TUtils.ls(path, files => resolve(files), (path, isdir) => isdir ? true : (!path.includes('-bk') && !path.includes('_bk') && F.TUtils.getExtension(path) === extension)));
764
767
  var read = async (path) => new Promise(resolve => F.Fs.readFile(path, 'utf8', (err, response) => resolve(response ? response : '')));
765
768
 
766
769
  var update = function(type, arr) {
@@ -827,7 +830,7 @@ F.load = async function(types, callback) {
827
830
 
828
831
  for (let plugin of tmp) {
829
832
 
830
- if (plugin.indexOf('-bk') !== -1 || plugin.indexOf('_bk') !== -1)
833
+ if (plugin.includes('-bk') || plugin.includes('_bk') || plugin.toLowerCase().includes('ds_store'))
831
834
  continue;
832
835
 
833
836
  files.push({ id: F.TUtils.getName(plugin).replace(/\.js$/, ''), type: 'plugins', filename: F.path.directory('plugins', plugin + '/index.js') });
@@ -900,9 +903,10 @@ F.load = async function(types, callback) {
900
903
  F.stats.compilation = Date.now() - beg;
901
904
  F.stats.compiled = files.length;
902
905
  F.isLoaded = true;
906
+
903
907
  DEBUG && F.TSourceMap.refresh();
904
- callback && callback();
905
908
 
909
+ callback && callback();
906
910
  F.emit('ready');
907
911
  F.emit('load');
908
912
  };
@@ -1167,6 +1171,7 @@ F.loadservices = function() {
1167
1171
  F.internal.interval = setInterval(function() {
1168
1172
 
1169
1173
  F.internal.ticks++;
1174
+
1170
1175
  global.NOW = new Date();
1171
1176
 
1172
1177
  for (let key in F.flowstreams) {
@@ -1249,7 +1254,7 @@ F.http = function(opt) {
1249
1254
  F.loadconfig(cfg);
1250
1255
  }
1251
1256
 
1252
- F.load(opt.load || opt.type || '', () => F.httpload(opt));
1257
+ F.load(opt.load || opt.type || '', () => F.httpload(opt), opt.clear);
1253
1258
  };
1254
1259
 
1255
1260
  F.httpload = function(opt) {
@@ -1872,12 +1877,11 @@ F.clear = function(init = true, callback) {
1872
1877
  F.TUtils.ls(dir, function(files, directories) {
1873
1878
 
1874
1879
  if (init) {
1875
- var arr = [];
1880
+ let arr = [];
1876
1881
  for (let file of files) {
1877
- var filename = file.substring(dir.length);
1882
+ let filename = file.substring(dir.length);
1878
1883
  if (plus && !filename.startsWith(plus))
1879
1884
  continue;
1880
-
1881
1885
  if (filename.indexOf('/') === -1 && !filename.endsWith('.cache'))
1882
1886
  arr.push(file);
1883
1887
  }
@@ -2047,7 +2051,7 @@ F.audit = function(name, $, message, type) {
2047
2051
 
2048
2052
  if ($.user) {
2049
2053
  data.userid = $.user.id;
2050
- data.username = $.user.name || $.user.nick || $.user.alias;
2054
+ data.createdby = $.user.name || $.user.nick || $.user.alias;
2051
2055
  }
2052
2056
 
2053
2057
  if ($.controller) {
@@ -2063,7 +2067,7 @@ F.audit = function(name, $, message, type) {
2063
2067
  data.type = type || 'info';
2064
2068
 
2065
2069
  if ($.id)
2066
- data.schema = $.id;
2070
+ data.action = $.id;
2067
2071
 
2068
2072
  if ($.model)
2069
2073
  data.data = JSON.stringify({ params: $.params, query: $.query, model: $.model }, auditjsonserialization);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "total5",
3
- "version": "0.0.13",
3
+ "version": "0.0.14-2",
4
4
  "description": "Total.js framework v5",
5
5
  "main": "index.js",
6
6
  "directories": {