total5 0.0.1-1 → 0.0.1-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/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;
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
 
@@ -2521,10 +2523,12 @@ function httptuningperformance(socket) {
2521
2523
  }
2522
2524
 
2523
2525
  process.on('unhandledRejection', function(e) {
2524
- F.error(e, '');
2526
+ F.error(e.stack, '');
2525
2527
  });
2526
2528
 
2529
+ // process.on('uncaughtException', function(e) {
2527
2530
  process.on('uncaughtException', function(e) {
2531
+
2528
2532
  var err = e + '';
2529
2533
  if (err.indexOf('listen EADDRINUSE') !== -1) {
2530
2534
  process.send && process.send('total:eaddrinuse');
@@ -2533,7 +2537,7 @@ process.on('uncaughtException', function(e) {
2533
2537
  return;
2534
2538
  } else if (F.config.$filtererrors && REG_SKIPERRORS.test(err))
2535
2539
  return;
2536
- F.error(e, '');
2540
+ F.error(e.stack, '');
2537
2541
  });
2538
2542
 
2539
2543
  function ping() {
@@ -2653,6 +2657,6 @@ process.on('message', function(msg, h) {
2653
2657
  process.connected && setTimeout(() => process.send('total:init'), 100);
2654
2658
 
2655
2659
  require('./global');
2656
- require('./Tangular');
2660
+ require('./tangular');
2657
2661
 
2658
2662
  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-2",
4
4
  "description": "Total.js framework v5",
5
5
  "main": "index.js",
6
6
  "directories": {
package/querybuilder.js CHANGED
@@ -1093,146 +1093,6 @@ QBP.schema = function(value) {
1093
1093
  return this;
1094
1094
  };
1095
1095
 
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
1096
  QBP.autoquery = function(query, schema, defsort, maxlimit) {
1237
1097
 
1238
1098
  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':