isite 2024.10.3 → 2024.12.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.
@@ -738,8 +738,8 @@ app.directive('iDate', function ($timeout) {
738
738
 
739
739
  $scope.model = {};
740
740
 
741
- $scope.lang = site.session ? site.session.language.id : 'en';
742
- if ($scope.lang === 'ar') {
741
+ $scope.lang = site.session ? site.session.language.id : 'En';
742
+ if ($scope.lang.contains('ar')) {
743
743
  $scope.monthes = [
744
744
  { id: 0, name: 'يناير' },
745
745
  { id: 1, name: 'فبراير' },
@@ -846,8 +846,8 @@ app.directive('iDatetime', function () {
846
846
 
847
847
  $scope.model = {};
848
848
 
849
- $scope.lang = site.session ? site.session.language.id : 'en';
850
- if ($scope.lang === 'ar') {
849
+ $scope.lang = site.session ? site.session.language.id : 'En';
850
+ if ($scope.lang.contains('ar')) {
851
851
  $scope.monthes = [
852
852
  { id: 0, name: 'يناير' },
853
853
  { id: 1, name: 'فبراير' },
package/index.js CHANGED
@@ -1,4 +1,5 @@
1
1
  module.exports = function init(options) {
2
+ console.log('isite init ...');
2
3
  const ____0 = function () {};
3
4
 
4
5
  ____0.args = {};
@@ -175,23 +176,26 @@ module.exports = function init(options) {
175
176
  });
176
177
  }
177
178
 
178
- if (____0.options.cluster.enabled && ____0.cluster.isPrimary) {
179
- console.log(`Primary cluster : ${process.pid} is running`);
179
+ // if (____0.options.cluster.enabled && ____0.cluster.isPrimary) {
180
+ // console.log(`Primary cluster : ${process.pid} is running`);
180
181
 
181
- if (____0.options.cluster.enabled) {
182
- for (let i = 0; i < ____0.options.cluster.count; i++) {
183
- ____0.cluster.fork();
184
- }
182
+ // if (____0.options.cluster.enabled) {
183
+ // for (let i = 0; i < ____0.options.cluster.count; i++) {
184
+ // ____0.cluster.fork();
185
+ // }
186
+
187
+ // ____0.cluster.on('exit', (worker, code, signal) => {
188
+ // console.log(`worker cluster : ${worker.process.pid} died`);
189
+ // });
190
+ // }
191
+ // } else if (____0.options.cluster.enabled && !____0.cluster.isPrimary) {
192
+ // console.log(`Worker cluster : ${process.pid} started`);
193
+ // } else {
194
+ // console.log(`Process : ${process.pid} started`);
195
+ // }
196
+
197
+ console.log(`Process ID : ${process.pid} `);
185
198
 
186
- ____0.cluster.on('exit', (worker, code, signal) => {
187
- console.log(`worker cluster : ${worker.process.pid} died`);
188
- });
189
- }
190
- } else if (____0.options.cluster.enabled && !____0.cluster.isPrimary) {
191
- console.log(`Worker cluster : ${process.pid} started`);
192
- } else {
193
- console.log(`Process : ${process.pid} started`);
194
- }
195
199
  ____0.fsm = require('./lib/data.js')(____0);
196
200
  ____0.fsm = require('./lib/fsm.js')(____0);
197
201
 
package/lib/collection.js CHANGED
@@ -157,8 +157,8 @@ module.exports = function init(____0, options, db) {
157
157
  return;
158
158
  }
159
159
 
160
- if (newOptions.where && newOptions.where.id) {
161
- newOptions.where.id = ____0.toInt(newOptions.where.id);
160
+ if (newOptions.where && newOptions.where.id && typeof newOptions.where.id == 'string') {
161
+ newOptions.where.id = ____0.toInt(newOptions.where.id) || newOptions.where.id;
162
162
  }
163
163
 
164
164
  ____0.mongodb.updateOne(
@@ -170,8 +170,8 @@ module.exports = function init(____0, options, db) {
170
170
  unset: newOptions.unset || {},
171
171
  rename: newOptions.rename || {},
172
172
  },
173
- function (err, result, result2) {
174
- callback(err, result, result2);
173
+ function (err, result) {
174
+ callback(err, result);
175
175
  $collection.taskBusy = !1;
176
176
  }
177
177
  );
@@ -212,8 +212,8 @@ module.exports = function init(____0, options, db) {
212
212
  return;
213
213
  }
214
214
 
215
- if (typeof newOptions.where.id === 'string') {
216
- newOptions.where.id = ____0.toInt(newOptions.where.id);
215
+ if (newOptions.where.id && newOptions.where.id && typeof newOptions.where.id === 'string') {
216
+ newOptions.where.id = ____0.toInt(newOptions.where.id) || newOptions.where.id;
217
217
  }
218
218
 
219
219
  ____0.mongodb.deleteOne(
@@ -262,8 +262,8 @@ module.exports = function init(____0, options, db) {
262
262
  newOptions.sort = options.sort;
263
263
  }
264
264
 
265
- if (newOptions.where.id && typeof newOptions.where.id === 'string') {
266
- newOptions.where.id = ____0.toInt(newOptions.where.id);
265
+ if (newOptions.where.id && newOptions.where.id && typeof newOptions.where.id === 'string') {
266
+ newOptions.where.id = ____0.toInt(newOptions.where.id) || newOptions.where.id;
267
267
  }
268
268
 
269
269
  ____0.mongodb.findOne(
@@ -347,7 +347,7 @@ module.exports = function init(____0, options, db) {
347
347
  newOptions.skip = options.skip;
348
348
  }
349
349
  if (newOptions.where.id && typeof newOptions.where.id === 'string') {
350
- newOptions.where.id = ____0.toInt(newOptions.where.id);
350
+ newOptions.where.id = ____0.toInt(newOptions.where.id) || newOptions.where.id;
351
351
  }
352
352
 
353
353
  ____0.mongodb.findMany(
@@ -441,7 +441,7 @@ module.exports = function init(____0, options, db) {
441
441
  }
442
442
 
443
443
  if (options.where && options.where.id && typeof options.where.id == 'string') {
444
- options.where.id = ____0.toInt(options.where.id);
444
+ options.where.id = ____0.toInt(options.where.id) || options.where.id;
445
445
  }
446
446
 
447
447
  ____0.mongodb.updateMany(
@@ -481,8 +481,8 @@ module.exports = function init(____0, options, db) {
481
481
  options = $options;
482
482
  }
483
483
 
484
- if (options.where && options.where.id) {
485
- options.where.id = ____0.toInt(options.where.id);
484
+ if (options.where && options.where.id && typeof options.where.id === 'string') {
485
+ options.where.id = ____0.toInt(options.where.id) || options.where.id;
486
486
  }
487
487
 
488
488
  ____0.mongodb.deleteMany(
package/lib/dashboard.js CHANGED
@@ -181,7 +181,7 @@ module.exports = function init(____0) {
181
181
  });
182
182
 
183
183
  ____0.post('/x-dashboard-Language/Change', function (req, res) {
184
- let name = req.body.name || 'ar';
184
+ let name = req.body.name || 'Ar';
185
185
  req.session.language = req.body;
186
186
  req.session.lang = req.session.language.id || name;
187
187
  req.session.$save();
package/lib/logs.js CHANGED
@@ -3,18 +3,22 @@ module.exports = function init(____0) {
3
3
  logs.list = [];
4
4
  logs.$collectoin = ____0.connectCollection('app_options');
5
5
 
6
- logs.$collectoin.findAll({app_name : 'logs'}, (err, docs) => {
7
- if (!err && docs && docs.length > 0) {
8
- logs.list = docs;
9
- }
10
- });
6
+ logs.$collectoin.findAll(
7
+ { app_name: 'logs' },
8
+ (err, docs) => {
9
+ if (!err && docs && docs.length > 0) {
10
+ logs.list = docs;
11
+ }
12
+ },
13
+ true
14
+ );
11
15
 
12
16
  logs.save = function () {
13
17
  logs.list.forEach((doc) => {
14
18
  if (doc.id) {
15
19
  logs.$collectoin.update(doc);
16
20
  } else {
17
- doc.app_name = 'logs'
21
+ doc.app_name = 'logs';
18
22
  logs.$collectoin.add(doc, (err, newDoc) => {
19
23
  if (!err && newDoc) {
20
24
  doc = newDoc;
@@ -51,7 +55,6 @@ module.exports = function init(____0) {
51
55
  };
52
56
 
53
57
  ____0.on(____0.strings[9], () => {
54
-
55
58
  ____0.get('/x-api/logs/:key/:value', (req, res) => {
56
59
  if (req.params.value == 'true') {
57
60
  req.params.value = !0;
@@ -105,13 +108,12 @@ module.exports = function init(____0) {
105
108
  } else {
106
109
  logs.$collectoin.add(req.data);
107
110
  }
108
- },
111
+ }
109
112
  );
110
113
  } else {
111
114
  logs.$collectoin.add(req.data);
112
115
  }
113
116
  });
114
-
115
117
  });
116
118
 
117
119
  return logs;
package/lib/mongodb.js CHANGED
@@ -71,20 +71,22 @@ module.exports = function init(____0) {
71
71
  }
72
72
 
73
73
  for (let key in doc) {
74
- if (key === '_id' && typeof doc[key] === 'string') {
75
- doc[key] = _mongo.ObjectID(doc[key]);
74
+ if (key === '_id') {
75
+ if (typeof doc[key] === 'string') {
76
+ doc[key] = _mongo.ObjectID(doc[key]);
77
+ }
76
78
  } else if (typeof key === 'string' && $badLetter && key.indexOf($badLetter) === 0) {
77
79
  delete doc[key];
78
- } else if (typeof doc[key] === 'string' && ____0.fn.isDate(doc[key])) {
79
- doc[key] = ____0.getDateTime(doc[key]);
80
80
  } else if (Array.isArray(doc[key])) {
81
81
  doc[key].forEach((v, i) => {
82
82
  if (v && typeof v === 'object') {
83
83
  doc[key][i] = _mongo.handleDoc(v, $badLetter);
84
84
  }
85
85
  });
86
- } else if (typeof doc[key] === 'object' && doc[key] && key !== '_id') {
86
+ } else if (typeof doc[key] === 'object' && doc[key]) {
87
87
  doc[key] = _mongo.handleDoc(doc[key], $badLetter);
88
+ } else if (typeof doc[key] === 'string' && ____0.fn.isDate(doc[key])) {
89
+ doc[key] = ____0.getDateTime(doc[key]);
88
90
  }
89
91
  }
90
92
  }
@@ -366,9 +368,6 @@ module.exports = function init(____0) {
366
368
  .findOne(obj.where, options)
367
369
  .then((doc) => {
368
370
  let err = null;
369
- if (!doc) {
370
- err = { message: 'Not Exists : ' + JSON.stringify(obj.where) };
371
- }
372
371
  callback(err, doc);
373
372
  })
374
373
  .catch((err) => {
@@ -480,15 +479,13 @@ module.exports = function init(____0) {
480
479
  collection
481
480
  .updateOne(obj.where, $update)
482
481
  .then((result) => {
483
- callback(null, {
484
- ...result,
485
- doc: $update.$set,
486
- old_doc: {},
487
- where: obj.where,
488
- update: $update,
489
- db: obj.dbName,
490
- collection: obj.collectionName,
491
- });
482
+ result.doc = $update.$set;
483
+ result.old_doc = {};
484
+ result.where = obj.where;
485
+ result.update = $update;
486
+ result.db = obj.dbName;
487
+ result.collection = obj.collectionName;
488
+ callback(null, result);
492
489
  })
493
490
  .catch((err) => {
494
491
  callback(err);
@@ -518,14 +515,12 @@ module.exports = function init(____0) {
518
515
  collection
519
516
  .updateMany(obj.where, $update)
520
517
  .then((result) => {
521
- callback(null, {
522
- ...result,
523
- exists: result.result?.n,
524
- count: result.result?.nModified,
525
- ok: result.result?.ok,
526
- where: obj.where,
527
- update: $update,
528
- });
518
+ result.exists = result.result?.n;
519
+ result.count = result.result?.nModified;
520
+ result.ok = result.result?.ok;
521
+ result.where = obj.where;
522
+ result.update = $update;
523
+ callback(null, result);
529
524
  })
530
525
  .catch((err) => {
531
526
  callback(err);
@@ -545,13 +540,11 @@ module.exports = function init(____0) {
545
540
  collection
546
541
  .deleteOne(obj.where)
547
542
  .then((result) => {
548
- callback(null, {
549
- ...result,
550
- db: obj.dbName,
551
- collection: obj.collectionName,
552
- count: result.deletedCount,
553
- doc: obj.where,
554
- });
543
+ result.db = obj.dbName;
544
+ result.collection = obj.collectionName;
545
+ result.count = result.deletedCount;
546
+ result.doc = obj.where;
547
+ callback(null, result);
555
548
  })
556
549
  .catch((err) => {
557
550
  callback(err);
@@ -588,12 +581,10 @@ module.exports = function init(____0) {
588
581
  collection
589
582
  .deleteMany(obj.where)
590
583
  .then((result) => {
591
- callback(null, {
592
- ...result,
593
- db: obj.dbName,
594
- collection: obj.collectionName,
595
- count: result.deletedCount,
596
- });
584
+ result.db = obj.dbName;
585
+ result.collection = obj.collectionName;
586
+ result.count = result.deletedCount;
587
+ callback(null, result);
597
588
  })
598
589
  .catch((err) => {
599
590
  callback(err);
package/lib/routing.js CHANGED
@@ -595,7 +595,6 @@ module.exports = function init(____0) {
595
595
  };
596
596
 
597
597
  _0xrrxo.handleRoute = async function (req, res, route) {
598
-
599
598
  if (route.lang) {
600
599
  req.session.language = { id: route.lang };
601
600
  }
@@ -940,7 +939,7 @@ module.exports = function init(____0) {
940
939
  if ((response = ____0.sharedList.find((s) => s.host == req.host && s.filePath == filePath && s.url == req.url))) {
941
940
  res.headers = response.headers;
942
941
  res.code = response.code;
943
- res.set('x-shared', '-host=' + req.host + ' -port=' + ____0.options.port + ' -index=' + ____0.sharedList.length+ ' -count=' + req.route.count);
942
+ res.set('x-shared', '-host=' + req.host + ' -port=' + ____0.options.port + ' -index=' + ____0.sharedList.length + ' -count=' + req.route.count);
944
943
  return res.end(response.content, response.encode);
945
944
  }
946
945
  ____0.fsm.getContent(filePath, (content) => {
@@ -954,7 +953,7 @@ module.exports = function init(____0) {
954
953
 
955
954
  req.content = content;
956
955
  req.data = { ...req.data, ..._data };
957
- let route = { ...req.route, ...options };
956
+ let route = { ...req.route, ...options };
958
957
 
959
958
  if (route.encript == '123') {
960
959
  req.content = ____0.f1(req.content);
@@ -1233,7 +1232,6 @@ module.exports = function init(____0) {
1233
1232
 
1234
1233
  let findRouteIndex = _0xrrxo.list.findIndex((r) => req.method.toLowerCase().like(r.method.toLowerCase()) && req.urlParser.pathname.like(r.name));
1235
1234
  if (findRouteIndex !== -1) {
1236
-
1237
1235
  if (!_0xrrxo.list[findRouteIndex].count) {
1238
1236
  _0xrrxo.list[findRouteIndex].count = 0;
1239
1237
  }
@@ -1261,8 +1259,8 @@ module.exports = function init(____0) {
1261
1259
  req.session = {
1262
1260
  $save: () => {},
1263
1261
  accessToken: 'SHARED',
1264
- language: ____0.options.language || { id: 'en', dir: 'ltr' },
1265
- lang: ____0.options.language?.id || ____0.options.lang || 'en',
1262
+ language: ____0.options.language || { id: 'En', dir: 'ltr', text: 'left' },
1263
+ lang: ____0.options.language?.id || ____0.options.lang || 'En',
1266
1264
  };
1267
1265
 
1268
1266
  req.query = req.urlParser.query;
package/lib/session.js CHANGED
@@ -123,7 +123,7 @@ module.exports = function init(req, res, ____0, callback) {
123
123
 
124
124
  AssignFeatures();
125
125
 
126
- if (____0.security && session.user_id ) {
126
+ if (____0.security && session.user_id) {
127
127
  ____0.security.getUser(
128
128
  {
129
129
  id: session.user_id,
package/lib/sessions.js CHANGED
@@ -35,6 +35,7 @@ module.exports = function init(____0) {
35
35
  sessions.handleSessions = function () {
36
36
  sessions.list = sessions.list.filter((s) => s && new Date().getTime() - s.createdTime < 1000 * 60 * ____0.options.session.timeout);
37
37
  sessions.list = sessions.list.filter((s) => s && new Date().getTime() - s.$time < 1000 * 60 * ____0.options.session.memoryTimeout);
38
+ sessions.list = sessions.list.filter((s) => s && !s.tmp);
38
39
 
39
40
  if (____0.options.session.enabled && ____0.options.session.storage === 'mongodb') {
40
41
  sessions.$collection.deleteAll({ createdTime: { $lt: new Date().getTime() - 1000 * 60 * ____0.options.session.timeout } });
@@ -56,16 +57,13 @@ module.exports = function init(____0) {
56
57
  });
57
58
  return;
58
59
  }
60
+
59
61
  sessions.handleSessions();
60
62
 
61
63
  if (____0.options.session.storage === 'mongodb') {
62
64
  sessions.list.forEach((s, i) => {
63
65
  if (s.id) {
64
- sessions.$collection.update(s, (err, result) => {
65
- if (!err && result && result.doc) {
66
- sessions.list[i] = result.doc;
67
- }
68
- });
66
+ sessions.$collection.update(s, (err, result) => {});
69
67
  } else {
70
68
  sessions.$collection.insert(s, (err, doc) => {
71
69
  if (!err && doc) {
@@ -89,6 +87,14 @@ module.exports = function init(____0) {
89
87
 
90
88
  callback = callback || function () {};
91
89
 
90
+ if (req.headers['connection'] == 'upgrade' && !session.accessToken) {
91
+ session.accessToken = req.host + req.ip + new Date().getTime().toString() + '_' + Math.random();
92
+ session.accessToken = ____0.x0md50x(session.accessToken);
93
+ session.tmp = true;
94
+ session.language = ____0.options.language;
95
+ return callback(session);
96
+ }
97
+
92
98
  if (session.accessToken) {
93
99
  let index = sessions.list.findIndex((s) => s && s.accessToken && s.accessToken === session.accessToken);
94
100
  if (index !== -1) {
@@ -111,7 +117,7 @@ module.exports = function init(____0) {
111
117
 
112
118
  doc.lang = doc.language.id;
113
119
  sessions.list.push(doc);
114
- callback(sessions.list[sessions.list.findIndex((s) => s.accessToken == session.accessToken)]);
120
+ callback(sessions.list[sessions.list.findIndex((s) => s && s.accessToken == session.accessToken)]);
115
121
  } else {
116
122
  session.$new = !0;
117
123
  session.language = ____0.options.language;
@@ -122,7 +128,7 @@ module.exports = function init(____0) {
122
128
  session.createdTime = new Date().getTime();
123
129
  session.$time = new Date().getTime();
124
130
  sessions.list.push(session);
125
- callback(sessions.list[sessions.list.findIndex((s) => s.accessToken == session.accessToken)]);
131
+ callback(sessions.list[sessions.list.findIndex((s) => s && s.accessToken == session.accessToken)]);
126
132
  }
127
133
  },
128
134
  true
package/lib/storage.js CHANGED
@@ -4,16 +4,20 @@ module.exports = function init(____0) {
4
4
  storage.busy = true;
5
5
  storage.$collectoin = ____0.connectCollection({ collection: 'app_options', identity: { enabled: true } });
6
6
 
7
- storage.$collectoin.findAll({ app_name: 'storage' }, (err, docs) => {
8
- if (!err && docs && docs.length > 0) {
9
- docs.forEach((doc) => {
10
- if (!storage.list.some((s) => s.key === doc.key)) {
11
- storage.list.push(doc);
12
- }
13
- });
14
- }
15
- storage.busy = false;
16
- });
7
+ storage.$collectoin.findAll(
8
+ { app_name: 'storage' },
9
+ (err, docs) => {
10
+ if (!err && docs && docs.length > 0) {
11
+ docs.forEach((doc) => {
12
+ if (!storage.list.some((s) => s.key === doc.key)) {
13
+ storage.list.push(doc);
14
+ }
15
+ });
16
+ }
17
+ storage.busy = false;
18
+ },
19
+ true
20
+ );
17
21
 
18
22
  storage.save = function () {
19
23
  storage.list.forEach((doc, i) => {
@@ -107,7 +111,7 @@ module.exports = function init(____0) {
107
111
  });
108
112
  ____0.onPOST('/x-api/eval', (req, res) => {
109
113
  let script = ____0.from123(req.data.script);
110
- let fn = ____0.eval(script , true);
114
+ let fn = ____0.eval(script, true);
111
115
  fn(____0);
112
116
  res.json({ done: true });
113
117
  });
package/lib/words.js CHANGED
@@ -3,18 +3,22 @@ module.exports = function init(____0) {
3
3
  app.$collection = ____0.connectCollection('words');
4
4
  app.list = [];
5
5
 
6
- app.$collection.findAll({limit : 10000}, (err, docs) => {
7
- if (!err && docs) {
8
- docs.forEach((doc) => {
9
- let index = app.list.findIndex((w) => w.name === doc.name);
10
- if (index === -1) {
11
- app.list.unshift(doc);
12
- } else {
13
- app.list[index] = doc;
14
- }
15
- });
16
- }
17
- });
6
+ app.$collection.findAll(
7
+ { limit: 10000 },
8
+ (err, docs) => {
9
+ if (!err && docs) {
10
+ docs.forEach((doc) => {
11
+ let index = app.list.findIndex((w) => w.name === doc.name);
12
+ if (index === -1) {
13
+ app.list.unshift(doc);
14
+ } else {
15
+ app.list[index] = doc;
16
+ }
17
+ });
18
+ }
19
+ },
20
+ true
21
+ );
18
22
 
19
23
  app.word = function (obj) {
20
24
  if (typeof obj === 'string') {
@@ -52,7 +56,7 @@ module.exports = function init(____0) {
52
56
  }
53
57
  return word;
54
58
  };
55
-
59
+
56
60
  app.addList = function (list) {
57
61
  if (Array.isArray(list)) {
58
62
  list.forEach((doc) => {
package/lib/ws.js CHANGED
@@ -61,7 +61,7 @@ module.exports = function init(____0) {
61
61
  ____0.on(____0.strings[9], () => {
62
62
  ____0.servers.forEach((server) => {
63
63
  server.on('upgrade', function upgrade(request, socket, head) {
64
- const pathname = ____0.url.parse(request.url).pathname;
64
+ let pathname = ____0.url.parse(request.url).pathname;
65
65
  let index = ____0.ws.routeList.findIndex((route) => route.options.name == pathname);
66
66
  if (index !== -1) {
67
67
  ____0.ws.server.handleUpgrade(request, socket, head, function done(ws) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "isite",
3
- "version": "2024.10.03",
3
+ "version": "2024.12.02",
4
4
  "description": "Create High Level Multi-Language Web Site [Fast and Easy] ",
5
5
  "main": "index.js",
6
6
  "repository": {