total5 0.0.1-1 → 0.0.1-3

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
@@ -1121,7 +1121,7 @@ exports.newaction = function(name, obj) {
1121
1121
 
1122
1122
  if (obj.route) {
1123
1123
  if (obj.route.indexOf('-->') === -1)
1124
- obj.route = obj.route + ' ' + (obj.input ? '+' : '-') + obj.$url + ' * --> ' + name;
1124
+ obj.route = obj.route + ' ' + (obj.input ? '+' : '-') + obj.$url + ' --> ' + name;
1125
1125
  var flags = null;
1126
1126
  if (obj.encrypt)
1127
1127
  flags = '@encrypt';
package/controller.js CHANGED
@@ -691,8 +691,7 @@ Controller.prototype.resume = function() {
691
691
  if (ctrl.isfile) {
692
692
 
693
693
  var path = ctrl.uri.key;
694
-
695
- if (path[0] === '_') {
694
+ if (path[1] === '_') {
696
695
 
697
696
  let tmp = path.substring(1);
698
697
  let index = tmp.indexOf('/', 1);
@@ -701,7 +700,7 @@ Controller.prototype.resume = function() {
701
700
  return;
702
701
  }
703
702
 
704
- path = F.path.plugins(tmp.substring(0, index) + '/public/' + tmp.substring(index + 2));
703
+ path = F.path.root('plugins/' + tmp.substring(1, index) + '/public/' + tmp.substring(index + 1));
705
704
  } else
706
705
  path = F.path.public(path.substring(1));
707
706
 
package/global.js CHANGED
@@ -25,6 +25,7 @@ global.CRON = F.cron;
25
25
  global.UID = F.uid;
26
26
  global.MEMORIZE = F.memorize;
27
27
  global.AUDIT = F.audit;
28
+ global.TRANSLATE = F.translate;
28
29
  global.DATA = new F.TQueryBuilder.Controller(true);
29
30
  global.DB = () => new F.TQueryBuilder.Controller();
30
31
  global.CACHE = F.cache;
@@ -102,6 +103,7 @@ global.REQUEST = F.TUtils.request;
102
103
  global.HASH = (val, type) => val.hash(type ? type : true);
103
104
  global.DIFFARR = F.TUtils.diffarr;
104
105
  global.CLONE = F.TUtils.clone;
106
+ global.COPY = F.TUtils.copy;
105
107
 
106
108
  // TMS
107
109
  global.SUBSCRIBE = F.TTMS.subscribe;
package/index.js CHANGED
@@ -808,6 +808,8 @@ F.load = async function(types, callback) {
808
808
  case 'plugins':
809
809
  tmp = require(file.filename);
810
810
  F.plugins[file.id] = tmp;
811
+ if (!tmp.id)
812
+ tmp.id = file.id;
811
813
  tmp.install && tmp.install();
812
814
  break;
813
815
 
@@ -1259,7 +1261,7 @@ F.logger = function(enable) {
1259
1261
  };
1260
1262
 
1261
1263
 
1262
- F.componentator = function(name, components, removeprev) {
1264
+ F.componentator = function(name, components, removeprev = true) {
1263
1265
 
1264
1266
  var meta = {};
1265
1267
 
@@ -1584,10 +1586,8 @@ F.service = function(count) {
1584
1586
  }
1585
1587
 
1586
1588
  // Update expires date
1587
- if (count % 60 === 0) {
1589
+ if (count % 60 === 0)
1588
1590
  F.config.$httpexpire = NOW.add('y', 1).toUTCString();
1589
- F.TImages.clear();
1590
- }
1591
1591
 
1592
1592
  if (count % F.config.$tmsclearblocked === 0)
1593
1593
  F.temporary.tmsblocked = {};
@@ -2521,10 +2521,12 @@ function httptuningperformance(socket) {
2521
2521
  }
2522
2522
 
2523
2523
  process.on('unhandledRejection', function(e) {
2524
- F.error(e, '');
2524
+ F.error(e.stack, '');
2525
2525
  });
2526
2526
 
2527
+ // process.on('uncaughtException', function(e) {
2527
2528
  process.on('uncaughtException', function(e) {
2529
+
2528
2530
  var err = e + '';
2529
2531
  if (err.indexOf('listen EADDRINUSE') !== -1) {
2530
2532
  process.send && process.send('total:eaddrinuse');
@@ -2533,7 +2535,7 @@ process.on('uncaughtException', function(e) {
2533
2535
  return;
2534
2536
  } else if (F.config.$filtererrors && REG_SKIPERRORS.test(err))
2535
2537
  return;
2536
- F.error(e, '');
2538
+ F.error(e.stack, '');
2537
2539
  });
2538
2540
 
2539
2541
  function ping() {
@@ -2653,6 +2655,9 @@ process.on('message', function(msg, h) {
2653
2655
  process.connected && setTimeout(() => process.send('total:init'), 100);
2654
2656
 
2655
2657
  require('./global');
2656
- require('./Tangular');
2658
+ require('./tangular');
2659
+
2660
+ // Init directories
2661
+ F.dir();
2657
2662
 
2658
2663
  module.exports = F;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "total5",
3
- "version": "0.0.1-1",
3
+ "version": "0.0.1-3",
4
4
  "description": "Total.js framework v5",
5
5
  "main": "index.js",
6
6
  "directories": {
package/querybuilder.js CHANGED
@@ -155,7 +155,7 @@ CTP.next = function(t) {
155
155
 
156
156
  CTP.callback = function($) {
157
157
  var t = this;
158
- t.$callback = typeof($) === 'function' ? $ : $.callback;
158
+ t.$callback = typeof($) === 'function' ? $ : $.callback();
159
159
  return t;
160
160
  };
161
161
 
@@ -380,7 +380,6 @@ CTP.command = function(table, name) {
380
380
  };
381
381
 
382
382
  DBP.evaluate = function(err, response) {
383
-
384
383
  var t = this;
385
384
 
386
385
  if (t.options.first && response instanceof Array)
@@ -501,7 +500,7 @@ QBP.set = function(name) {
501
500
 
502
501
  QBP.callback = function($) {
503
502
  var t = this;
504
- t.main.callback = typeof($) === 'function' ? $ : $.callback;
503
+ t.main.callback = typeof($) === 'function' ? $ : $.callback();
505
504
  return t;
506
505
  };
507
506
 
@@ -1093,146 +1092,6 @@ QBP.schema = function(value) {
1093
1092
  return this;
1094
1093
  };
1095
1094
 
1096
- QBP.autofill = function($, allowedfields, skipfilter, defsort, maxlimit) {
1097
-
1098
- if (typeof(defsort) === 'number') {
1099
- maxlimit = defsort;
1100
- defsort = null;
1101
- }
1102
-
1103
- var t = this;
1104
- var query = $.query || $.options;
1105
- var schema = $.schema;
1106
- var skipped;
1107
- var allowed;
1108
- var key;
1109
- var tmp;
1110
-
1111
- if (skipfilter) {
1112
- key = 'NDB_' + skipfilter;
1113
- skipped = F.temporary.querybuilders[key];
1114
- if (!skipped) {
1115
- tmp = skipfilter.split(',').trim();
1116
- var obj = {};
1117
- for (var i = 0; i < tmp.length; i++)
1118
- obj[tmp[i]] = 1;
1119
- skipped = F.temporary.querybuilders[key] = obj;
1120
- }
1121
- }
1122
-
1123
- if (allowedfields) {
1124
- key = 'NDB_' + allowedfields;
1125
- allowed = F.temporary.querybuilders[key];
1126
- if (!allowed) {
1127
- var obj = {};
1128
- var arr = [];
1129
- var filter = [];
1130
- tmp = allowedfields.split(',').trim();
1131
- for (var i = 0; i < tmp.length; i++) {
1132
- var k = tmp[i].split(':').trim();
1133
- obj[k[0]] = 1;
1134
- arr.push(k[0]);
1135
- k[1] && filter.push({ name: k[0], type: (k[1] || '').toLowerCase() });
1136
- }
1137
- allowed = F.temporary.querybuilders[key] = { keys: arr, meta: obj, filter: filter };
1138
- }
1139
- }
1140
-
1141
- var fields = query.fields;
1142
- var fieldscount = 0;
1143
- var newfields = [];
1144
-
1145
- if (fields) {
1146
- fields = fields.replace(REG_FIELDS_CLEANER, '').split(',');
1147
- for (var i = 0; i < fields.length; i++) {
1148
- var field = fields[i];
1149
- if (allowed && allowed.meta[field]) {
1150
- newfields.push(field);
1151
- fieldscount++;
1152
- } else if (schema.schema[field]) {
1153
- if (skipped && skipped[field])
1154
- continue;
1155
- newfields.push(field);
1156
- fieldscount++;
1157
- }
1158
- }
1159
- }
1160
-
1161
- if (!fieldscount) {
1162
- if (allowed) {
1163
- for (var item of allowed.keys)
1164
- newfields.push(item);
1165
- }
1166
- if (schema.fields) {
1167
- for (var item of schema.fields) {
1168
- if (skipped && skipped[item])
1169
- continue;
1170
- newfields.push(item);
1171
- }
1172
- }
1173
- }
1174
-
1175
- if (allowed && allowed.filter) {
1176
- for (var item of allowed.filter)
1177
- t.gridfilter(item.name, query, item.type);
1178
- }
1179
-
1180
- if (schema.fields) {
1181
- for (var name of schema.fields) {
1182
- if ((!skipped || !skipped[name]) && query[name]) {
1183
- var field = schema.schema[name];
1184
- var type = String;
1185
- switch (field.type) {
1186
- case 2:
1187
- type = Number;
1188
- break;
1189
- case 4:
1190
- type = Boolean;
1191
- break;
1192
- case 5:
1193
- type = Date;
1194
- break;
1195
- }
1196
- t.gridfilter(name, query, type);
1197
- }
1198
- }
1199
- }
1200
-
1201
- if (query.sort) {
1202
-
1203
- var sort = query.sort.split(',');
1204
- var sortvalue = '';
1205
-
1206
- for (var item of sort) {
1207
-
1208
- var index = item.lastIndexOf('_');
1209
- var name = index > 1 ? item.substring(0, index) : item;
1210
-
1211
- if (skipped && skipped[name])
1212
- continue;
1213
-
1214
- if (allowed) {
1215
- if (!allowed.meta[name] && !schema.schema[name])
1216
- continue;
1217
- } else if (!schema.schema[name])
1218
- continue;
1219
-
1220
- sortvalue += (sortvalue ? ',' : '') + item;
1221
- }
1222
-
1223
- if (!sortvalue && defsort)
1224
- sortvalue = defsort;
1225
-
1226
- if (sortvalue)
1227
- t.gridsort(sortvalue);
1228
-
1229
- } else if (defsort)
1230
- t.gridsort(defsort);
1231
-
1232
- t.paginate(query.page, query.limit, maxlimit || 50);
1233
- return t;
1234
- };
1235
-
1236
1095
  QBP.autoquery = function(query, schema, defsort, maxlimit) {
1237
1096
 
1238
1097
  var t = this;
package/routing.js CHANGED
@@ -1,4 +1,3 @@
1
- // Total.js Routing
2
1
  // The MIT License
3
2
  // Copyright 2023 (c) Peter Širka <petersirka@gmail.com>
4
3
 
@@ -140,6 +139,9 @@ function Route(url, action, size) {
140
139
  if (index != -1)
141
140
  t.url.splice(index, 1);
142
141
 
142
+ if (!t.url.length)
143
+ t.url[0] = '/';
144
+
143
145
  url = url.replace(/<\d+[mb|gb|kb|b|m|s|h]+/gi, function(text) {
144
146
  parseSizeTimeout(t, text.substring(1));
145
147
  return '';
package/todo.txt CHANGED
@@ -4,4 +4,8 @@
4
4
  - autoquery
5
5
 
6
6
  - CSRF tokeny
7
- - encryption/decryption
7
+ - encryption/decryption
8
+
9
+ ---
10
+
11
+ CHECK WINDOWS PLUGINS STATIC FILES
package/utils.js CHANGED
@@ -88,6 +88,9 @@ exports.noop = function() {};
88
88
 
89
89
  exports.parseConfig = function(value) {
90
90
 
91
+ if (!value)
92
+ return {};
93
+
91
94
  if (typeof(value) === 'string') {
92
95
 
93
96
  var lines = value.split('\n');
@@ -126,6 +129,13 @@ exports.parseConfig = function(value) {
126
129
  return exports.parseConfig(response);
127
130
  }
128
131
 
132
+ if (!(value instanceof Array)) {
133
+ let tmp = [];
134
+ for (let key in value)
135
+ tmp.push({ id: key, value: value[key] });
136
+ value = tmp;
137
+ }
138
+
129
139
  var cfg = {};
130
140
  var generated = [];
131
141
 
package/viewengine.js CHANGED
@@ -258,7 +258,7 @@ exports.compile = function(name, content, debug = true) {
258
258
  if (!debug)
259
259
  builder = builder.replace(/(\+\$EMPTY\+)/g, '+').replace(/(\$output=\$EMPTY\+)/g, '$output=').replace(/(\$output\+=\$EMPTY\+)/g, '$output+=').replace(/(\}\$output\+=\$EMPTY)/g, '}').replace(/(\{\$output\+=\$EMPTY;)/g, '{').replace(/(\+\$EMPTY\+)/g, '+').replace(/(>'\+'<)/g, '><').replace(/'\+'/g, '');
260
260
 
261
- var fn = ('(function(self){var model=self.model;var ctrl=self.controller;var query=ctrl?.query || EMPTYOBJECT,repository=self.repository,controller=self.controller,files=ctrl?.files || EMPTYARRAY,user=ctrl?.user,session=ctrl?.session,body=ctrl?.body,language=ctrl?.language || \'\'' + (isCookie ? ',cookie=name=>ctrl?ctrl.cookie(name):\'\'' : '') + ';' + (nocompressHTML ? 'if(ctrl)ctrl.response.minify=false;' : '') + builder + ';return $output;})');
261
+ var fn = ('(function(self){var model=self.model;var config=F.config;var ctrl=self.controller;var query=ctrl?.query || EMPTYOBJECT,repository=self.repository,controller=self.controller,files=ctrl?.files || EMPTYARRAY,user=ctrl?.user,session=ctrl?.session,body=ctrl?.body,language=ctrl?.language || \'\'' + (isCookie ? ',cookie=name=>ctrl?ctrl.cookie(name):\'\'' : '') + ';' + (nocompressHTML ? 'if(ctrl)ctrl.response.minify=false;' : '') + builder + ';return $output;})');
262
262
  try {
263
263
  fn = eval(fn);
264
264
  } catch (e) {
@@ -332,6 +332,7 @@ function prepare(command, dynamicCommand, functions) {
332
332
  return '\'' + (r ? r.substring(0, r.length - 1) : r) + '\'';
333
333
 
334
334
  case 'CONF':
335
+ case 'config':
335
336
  case 'controller':
336
337
  case 'FUNC':
337
338
  case 'MAIN':