isite 2025.1.20 → 2025.7.1

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/lib/fsm.js CHANGED
@@ -1,492 +1,495 @@
1
1
  module.exports = function init(____0) {
2
- const fsm = function () {};
3
- const fs = require('fs');
4
-
5
- ____0.on('0x0000', (_) => {
6
- if (!_) {
7
- fsm.list = [];
8
- }
9
- });
10
-
11
- fsm.dir = ____0.dir;
12
- fsm.list = [];
13
-
14
- fsm.isFileExistsSync = (path) => {
15
- return fsm.list.some((f) => f.path === path) || fs.existsSync(path);
16
- };
17
-
18
- fsm.isFileExists = (path, callback) => {
19
- if (callback) {
20
- callback(fsm.isFileExistsSync(path));
21
- }
22
- };
23
-
24
- fsm.statSync = function (path) {
25
- if (fsm.isFileExistsSync(path)) {
26
- return fs.statSync(path);
27
- }
28
- };
29
-
30
- fsm.stat = function (path, callback) {
31
- if (callback) {
32
- callback(fsm.statSync(path));
33
- }
34
- };
35
-
36
- fsm.createDirSync = fsm.mkdirSync = function (path) {
37
- try {
38
- fs.mkdirSync(path);
39
- return !0;
40
- } catch (error) {
41
- return !1;
42
- }
43
- };
44
-
45
- fsm.createDir = fsm.mkDir = (dir, callback) => {
46
- callback = callback || function () {};
47
-
48
- fs.exists(____0.path.dirname(dir), (ok) => {
49
- if (ok) {
50
- fs.mkdir(dir, (err) => {
51
- callback(err, dir);
52
- });
53
- } else {
54
- let parentDir = ____0.path.dirname(dir);
55
- fsm.mkDir(parentDir, () => {
56
- fs.mkdir(dir, (err) => {
57
- callback(err, dir);
58
- });
59
- });
60
- }
2
+ const fsm = function () {};
3
+ const fs = require('fs');
4
+
5
+ ____0.on('0x0000', (_) => {
6
+ if (!_) {
7
+ fsm.list = [];
8
+ }
61
9
  });
62
- };
63
-
64
- fsm.removeFileSync = fsm.deleteFileSync = function (path) {
65
- if (fs.existsSync(path)) {
66
- return fs.unlinkSync(path);
67
- }
68
- return null;
69
- };
70
-
71
- fsm.removeFile = fsm.deleteFile = function (path, callback) {
72
- callback =
73
- callback ||
74
- function (err) {
75
- if (err) {
76
- ____0.log(err);
10
+
11
+ fsm.dir = ____0.dir;
12
+ fsm.list = [];
13
+
14
+ fsm.isFileExistsSync = (path) => {
15
+ return fsm.list.some((f) => f.path === path) || fs.existsSync(path);
16
+ };
17
+
18
+ fsm.isFileExists = (path, callback) => {
19
+ if (callback) {
20
+ callback(fsm.isFileExistsSync(path));
77
21
  }
78
- };
22
+ };
79
23
 
80
- fsm.isFileExists(path, (yes) => {
81
- if (yes) {
82
- fs.unlink(path, (err) => {
83
- callback(err);
84
- });
85
- } else {
86
- callback({
87
- message: path + ' :: Error Deleting :: file not exists',
24
+ fsm.statSync = function (path) {
25
+ if (fsm.isFileExistsSync(path)) {
26
+ return fs.statSync(path);
27
+ }
28
+ };
29
+
30
+ fsm.stat = function (path, callback) {
31
+ if (callback) {
32
+ callback(fsm.statSync(path));
33
+ }
34
+ };
35
+
36
+ fsm.createDirSync = fsm.mkdirSync = function (path) {
37
+ try {
38
+ fs.mkdirSync(path);
39
+ return !0;
40
+ } catch (error) {
41
+ return !1;
42
+ }
43
+ };
44
+
45
+ fsm.createDir = fsm.mkDir = (dir, callback) => {
46
+ callback = callback || function () {};
47
+
48
+ fs.exists(____0.path.dirname(dir), (ok) => {
49
+ if (ok) {
50
+ fs.mkdir(dir, (err) => {
51
+ callback(err, dir);
52
+ });
53
+ } else {
54
+ let parentDir = ____0.path.dirname(dir);
55
+ fsm.mkDir(parentDir, () => {
56
+ fs.mkdir(dir, (err) => {
57
+ callback(err, dir);
58
+ });
59
+ });
60
+ }
88
61
  });
89
- }
90
- });
91
- };
92
-
93
- fsm.writeFileSync = function (path, data, encode, callback) {
94
- callback =
95
- callback ||
96
- function (err) {
97
- if (err) {
98
- ____0.log(err);
62
+ };
63
+
64
+ fsm.removeFileSync = fsm.deleteFileSync = function (path) {
65
+ if (fs.existsSync(path)) {
66
+ return fs.unlinkSync(path);
99
67
  }
100
- };
101
-
102
- try {
103
- let path2 = path + '.isite-backup';
104
- fsm.deleteFileSync(path2);
105
- fs.writeFileSync(path2, data, {
106
- encoding: encode || 'utf8',
107
- });
108
- fsm.deleteFileSync(path);
109
- fs.renameSync(path2, path);
110
- fsm.deleteFileSync(path2);
111
- callback(null, path);
112
- } catch (err) {
113
- callback(err);
114
- }
115
- };
116
-
117
- fsm.writeFile = function (path, data, callback) {
118
- setTimeout(() => {
119
- fsm.writeFileSync(path, data, null, callback);
120
- }, 100);
121
- };
122
-
123
- fsm.getFilePath = function (name) {
124
- if (____0.isFileExistsSync(name)) {
125
- return name;
126
- }
127
-
128
- let path = null;
129
-
130
- if (!path || !____0.isFileExistsSync(path)) {
131
- let arr = name.split('/');
132
- if (arr.length === 1) {
133
- path = ____0.path.join(____0.path.dirname(____0.dir), ____0.path.extname(arr[0]).replace('.', ''), arr[0]);
134
- } else if (arr.length === 2) {
135
- path = ____0.path.join(____0.path.dirname(____0.dir), ____0.path.extname(arr[1]).replace('.', ''), arr[0], arr[1]);
136
- } else if (arr.length === 3) {
137
- path = ____0.path.join(____0.path.dirname(____0.dir), ____0.path.extname(arr[2]).replace('.', ''), arr[0], arr[1], arr[2]);
138
- }
139
- }
140
-
141
- if (!____0.isFileExistsSync(path)) {
142
- let arr = name.split('/');
143
- if (arr.length === 2) {
144
- path = ____0.path.join(____0.path.dirname(____0.cwd), 'apps', arr[0], 'site_files', ____0.path.extname(arr[1]).replace('.', ''), arr[1]);
145
- } else if (arr.length === 3) {
146
- path = ____0.path.join(____0.path.dirname(____0.cwd), 'apps', arr[0], 'site_files', ____0.path.extname(arr[2]).replace('.', ''), arr[1], arr[2]);
147
- }
148
- }
149
-
150
- if (!____0.isFileExistsSync(path) && ____0.apps) {
151
- let arr = name.split('/');
152
- if (arr.length > 1) {
153
- ____0.apps.forEach((ap) => {
154
- if (arr.length === 2 && ap.name == arr[0]) {
155
- path = ____0.path.join(ap.path, 'site_files', ____0.path.extname(arr[1]).replace('.', ''), arr[1]);
156
- } else if (arr.length === 2 && ap.name2 == arr[0]) {
157
- path = ____0.path.join(ap.path, 'site_files', ____0.path.extname(arr[1]).replace('.', ''), arr[1]);
158
- } else if (arr.length === 3 && ap.name == arr[0]) {
159
- path = ____0.path.join(ap.path, 'site_files', ____0.path.extname(arr[2]).replace('.', ''), arr[1], arr[2]);
160
- }
68
+ return null;
69
+ };
70
+
71
+ fsm.removeFile = fsm.deleteFile = function (path, callback) {
72
+ callback =
73
+ callback ||
74
+ function (err) {
75
+ if (err) {
76
+ ____0.log(err);
77
+ }
78
+ };
79
+
80
+ fsm.isFileExists(path, (yes) => {
81
+ if (yes) {
82
+ fs.unlink(path, (err) => {
83
+ callback(err);
84
+ });
85
+ } else {
86
+ callback({
87
+ message: path + ' :: Error Deleting :: file not exists',
88
+ });
89
+ }
161
90
  });
162
- }
163
- }
164
-
165
- if (!____0.isFileExistsSync(path)) {
166
- // ____0.log(name, 'PATH NOT EXISTS fsm.getFilePath()');
167
- return null;
168
- }
169
-
170
- return path;
171
- };
172
-
173
- fsm.off = function (path) {
174
- if (!path) {
175
- return false;
176
- }
177
- if (path && Array.isArray(path)) {
178
- path.forEach((p) => {
179
- fsm.off(p);
180
- });
181
- return;
182
- }
183
- if (typeof path === 'object') {
184
- path = path.path;
185
- }
186
-
187
- path = fsm.getFilePath(path) || path;
188
-
189
- if (path && typeof path == 'string') {
190
- for (let i = fsm.list.length; i--; ) {
191
- if (fsm.list[i] && fsm.list[i].path.like(path)) {
192
- fsm.list.splice(i, 1);
91
+ };
92
+
93
+ fsm.writeFileSync = function (path, data, encode, callback) {
94
+ callback =
95
+ callback ||
96
+ function (err) {
97
+ if (err) {
98
+ ____0.log(err);
99
+ }
100
+ };
101
+
102
+ try {
103
+ let path2 = path + '.isite-backup';
104
+ fsm.deleteFileSync(path2);
105
+ fs.writeFileSync(path2, data, {
106
+ encoding: encode || 'utf8',
107
+ });
108
+ fsm.deleteFileSync(path);
109
+ fs.renameSync(path2, path);
110
+ fsm.deleteFileSync(path2);
111
+ callback(null, path);
112
+ } catch (err) {
113
+ callback(err);
193
114
  }
194
- }
195
- }
196
-
197
- return true;
198
- };
199
-
200
- fsm.readFileStream = function (path) {
201
- var readerStream = fs.createReadStream(path);
202
- readerStream.setEncoding(____0.fn.getFileEncode(path));
203
- return readerStream;
204
- };
205
-
206
- fsm.readFileRaw = function (path, callback) {
207
- var data = '';
208
- var readerStream = fsm.readFileStream(path);
209
- readerStream.on('data', function (chunk) {
210
- data += chunk;
211
- });
115
+ };
212
116
 
213
- readerStream.on('end', function () {
214
- callback(data);
215
- });
117
+ fsm.writeFile = function (path, data, callback) {
118
+ setTimeout(() => {
119
+ fsm.writeFileSync(path, data, null, callback);
120
+ }, 100);
121
+ };
216
122
 
217
- readerStream.on('error', function (err) {
218
- console.log(err.stack);
219
- });
220
- };
221
-
222
- fsm.readFileNow = function (path, callback) {
223
- fsm.readFileRaw(path, (data) => {
224
- path = path.replace('.isite-backup', '');
225
- if (data) {
226
- let file = {
227
- path: path,
228
- content: data,
229
- count: 1,
230
- stat: fsm.statSync(path),
231
- time: new Date().getTime(),
232
- };
233
-
234
- file.json = function (callback) {
235
- try {
236
- if (!file.isJson) {
237
- file.content = JSON.parse(file.content);
238
- file.isJson = true;
123
+ fsm.getFilePath = function (name) {
124
+ if (____0.isFileExistsSync(name)) {
125
+ return name;
126
+ }
127
+
128
+ let path = null;
129
+
130
+ if (!path || !____0.isFileExistsSync(path)) {
131
+ let arr = name.split('/');
132
+ if (arr.length === 1) {
133
+ path = ____0.path.join(____0.path.dirname(____0.dir), ____0.path.extname(arr[0]).replace('.', ''), arr[0]);
134
+ } else if (arr.length === 2) {
135
+ path = ____0.path.join(____0.path.dirname(____0.dir), ____0.path.extname(arr[1]).replace('.', ''), arr[0], arr[1]);
136
+ } else if (arr.length === 3) {
137
+ path = ____0.path.join(____0.path.dirname(____0.dir), ____0.path.extname(arr[2]).replace('.', ''), arr[0], arr[1], arr[2]);
239
138
  }
240
- } catch (error) {
241
- file.error = error;
242
- console.log(error);
243
- }
244
- if (callback) {
245
- callback(file);
246
- } else {
247
- return file;
248
- }
249
- };
250
- fsm.list.push(file);
251
- if (callback) {
252
- callback(null, file);
253
139
  }
254
- } else {
255
- callback({
256
- message: path + ' :: Error Read File Not Exists',
140
+
141
+ if (!____0.isFileExistsSync(path)) {
142
+ let arr = name.split('/');
143
+ if (arr.length === 2) {
144
+ path = ____0.path.join(____0.path.dirname(____0.cwd), 'apps', arr[0], 'site_files', ____0.path.extname(arr[1]).replace('.', ''), arr[1]);
145
+ } else if (arr.length === 3) {
146
+ path = ____0.path.join(____0.path.dirname(____0.cwd), 'apps', arr[0], 'site_files', ____0.path.extname(arr[2]).replace('.', ''), arr[1], arr[2]);
147
+ }
148
+ }
149
+
150
+ if (!____0.isFileExistsSync(path) && ____0.apps) {
151
+ let arr = name.split('/');
152
+ if (arr.length > 1) {
153
+ ____0.apps.forEach((ap) => {
154
+ if (arr.length === 2 && ap.name == arr[0]) {
155
+ path = ____0.path.join(ap.path, 'site_files', ____0.path.extname(arr[1]).replace('.', ''), arr[1]);
156
+ } else if (arr.length === 2 && ap.name2 == arr[0]) {
157
+ path = ____0.path.join(ap.path, 'site_files', ____0.path.extname(arr[1]).replace('.', ''), arr[1]);
158
+ } else if (arr.length === 3 && ap.name == arr[0]) {
159
+ path = ____0.path.join(ap.path, 'site_files', ____0.path.extname(arr[2]).replace('.', ''), arr[1], arr[2]);
160
+ }
161
+ });
162
+ }
163
+ }
164
+
165
+ if (!____0.isFileExistsSync(path)) {
166
+ // ____0.log(name, 'PATH NOT EXISTS fsm.getFilePath()');
167
+ return null;
168
+ }
169
+
170
+ return path;
171
+ };
172
+
173
+ fsm.off = function (path) {
174
+ if (!path) {
175
+ return false;
176
+ }
177
+ if (path && Array.isArray(path)) {
178
+ path.forEach((p) => {
179
+ fsm.off(p);
180
+ });
181
+ return;
182
+ }
183
+ if (typeof path === 'object') {
184
+ path = path.path;
185
+ }
186
+
187
+ path = fsm.getFilePath(path) || path;
188
+
189
+ if (path && typeof path == 'string') {
190
+ for (let i = fsm.list.length; i--; ) {
191
+ if (fsm.list[i] && fsm.list[i].path.like(path)) {
192
+ fsm.list.splice(i, 1);
193
+ }
194
+ }
195
+ }
196
+
197
+ return true;
198
+ };
199
+
200
+ fsm.readFileStream = function (path) {
201
+ var readerStream = fs.createReadStream(path);
202
+ readerStream.setEncoding(____0.fn.getFileEncode(path));
203
+ return readerStream;
204
+ };
205
+
206
+ fsm.readFileRaw = function (path, callback) {
207
+ var data = '';
208
+ var readerStream = fsm.readFileStream(path);
209
+ readerStream.on('data', function (chunk) {
210
+ data += chunk;
257
211
  });
258
- }
259
- });
260
- };
261
212
 
262
- fsm.readFile = function (path, callback) {
263
- path = fsm.getFilePath(path);
213
+ readerStream.on('end', function () {
214
+ callback(data);
215
+ });
264
216
 
265
- if (!path) {
266
- if (callback) {
267
- callback({
268
- message: path + ' :: Error Read File Not Exists',
217
+ readerStream.on('error', function (err) {
218
+ console.log(err.stack);
269
219
  });
270
- }
271
- }
272
-
273
- let index = fsm.list.findIndex((f) => f.path == path);
274
- if (index !== -1) {
275
- fsm.list[index].count++;
276
- fsm.list[index].time = new Date().getTime();
277
- if (callback) {
278
- callback(null, fsm.list[index]);
279
- }
280
- return;
281
- }
282
-
283
- if (fsm.isFileExistsSync(path)) {
284
- fsm.readFileNow(path, callback);
285
- } else if (fsm.isFileExistsSync(path + '.isite-backup')) {
286
- fsm.readFileNow(path + '.isite-backup', callback);
287
- } else {
288
- if (callback) {
289
- callback({
290
- message: path + ' :: Error Read File Not Exists',
220
+ };
221
+
222
+ fsm.readFileNow = function (path, callback) {
223
+ fsm.readFileRaw(path, (data) => {
224
+ path = path.replace('.isite-backup', '');
225
+ if (data) {
226
+ let file = {
227
+ path: path,
228
+ content: data,
229
+ count: 1,
230
+ stat: fsm.statSync(path),
231
+ time: new Date().getTime(),
232
+ };
233
+
234
+ file.json = function (callback) {
235
+ try {
236
+ if (!file.isJson) {
237
+ file.content = JSON.parse(file.content);
238
+ file.isJson = true;
239
+ }
240
+ } catch (error) {
241
+ file.error = error;
242
+ console.log(error);
243
+ }
244
+ if (callback) {
245
+ callback(file);
246
+ } else {
247
+ return file;
248
+ }
249
+ };
250
+ fsm.list.push(file);
251
+ if (callback) {
252
+ callback(null, file);
253
+ }
254
+ } else {
255
+ callback({
256
+ message: path + ' :: Error Read File Not Exists',
257
+ });
258
+ }
291
259
  });
292
- }
293
- }
294
- };
295
-
296
- fsm.readFileSyncRaw = function (path) {
297
- return fs.readFileSync(path, ____0.fn.getFileEncode(path));
298
- };
299
- fsm.readFileSync = function (path) {
300
- path = fsm.getFilePath(path);
301
-
302
- if (!path) {
303
- return '';
304
- }
305
-
306
- let index = fsm.list.findIndex((f) => f.path == path);
307
- if (index !== -1) {
308
- fsm.list[index].count++;
309
- fsm.list[index].time = new Date().getTime();
310
- return fsm.list[index].content;
311
- }
312
-
313
- if (fsm.isFileExistsSync(path)) {
314
- let file = {
315
- path: path,
316
- content: fsm.readFileSyncRaw(path),
317
- count: 1,
318
- stat: fsm.statSync(path),
319
- time: new Date().getTime(),
320
- };
321
- fsm.list.push(file);
322
-
323
- return file.content;
324
- } else if (fsm.isFileExistsSync(path + '.isite-backup')) {
325
- let file = {
326
- path: path,
327
- content: fsm.readFileSyncRaw(path + '.isite-backup'),
328
- count: 1,
329
- stat: fsm.statSync(path + '.isite-backup'),
330
- time: new Date().getTime(),
331
- };
332
- fsm.list.push(file);
333
-
334
- return file.content;
335
- }
336
- return '';
337
- };
338
-
339
- fsm.readFiles = function (paths, callback) {
340
- callback = callback || function () {};
341
- var content = '';
342
- for (var index = 0; index < paths.length; index++) {
343
- let p = paths[index];
344
- let exists = !1;
345
- for (let i = 0; i < fsm.list.length; i++) {
346
- let file = fsm.list[i];
347
- if (file.path == p) {
348
- content += file.content;
349
- file.count++;
350
- exists = !0;
260
+ };
261
+
262
+ fsm.readFile = function (path, callback) {
263
+ path = fsm.getFilePath(path);
264
+
265
+ if (!path) {
266
+ if (callback) {
267
+ callback({
268
+ message: path + ' :: Error Read File Not Exists',
269
+ });
270
+ }
351
271
  }
352
- }
353
- if (!exists) {
354
- data = fsm.readFileSync(p);
355
- content += data;
356
- }
357
- }
358
- callback(null, content);
359
- };
360
-
361
- fsm.isImage = function (extname) {
362
- if (extname.contains('png|jpg|jpeg|bmp|ico|webp|gif')) {
363
- return true;
364
- }
365
- return false;
366
- };
367
-
368
- fsm.getContent = function (name, callback) {
369
- callback = callback || function () {};
370
- let extname = ____0.path.extname(name).replace('.', '');
371
- if (fsm.isImage(extname)) {
372
- extname = 'images';
373
- }
374
-
375
- let path = name;
376
-
377
- if (!____0.isFileExistsSync(path)) {
378
- path = ____0.path.join(____0.dir, extname, name);
379
- }
380
-
381
- if (!____0.isFileExistsSync(path)) {
382
- let arr = name.split('/');
383
- if (arr.length === 2) {
384
- let extname = ____0.path.extname(arr[1]).replace('.', '');
385
- if (fsm.isImage(extname)) {
386
- extname = 'images';
272
+
273
+ let index = fsm.list.findIndex((f) => f.path == path);
274
+ if (index !== -1) {
275
+ fsm.list[index].count++;
276
+ fsm.list[index].time = new Date().getTime();
277
+ if (callback) {
278
+ callback(null, fsm.list[index]);
279
+ }
280
+ return;
387
281
  }
388
- path = ____0.path.join(____0.path.dirname(____0.dir), 'apps', arr[0], 'site_files', extname, arr[1]);
389
- } else if (arr.length === 3) {
390
- let extname = ____0.path.extname(arr[2]).replace('.', '');
391
- if (fsm.isImage(extname)) {
392
- extname = 'images';
282
+
283
+ if (fsm.isFileExistsSync(path)) {
284
+ fsm.readFileNow(path, callback);
285
+ } else if (fsm.isFileExistsSync(path + '.isite-backup')) {
286
+ fsm.readFileNow(path + '.isite-backup', callback);
287
+ } else {
288
+ if (callback) {
289
+ callback({
290
+ message: path + ' :: Error Read File Not Exists',
291
+ });
292
+ }
393
293
  }
394
- path = ____0.path.join(____0.path.dirname(____0.dir), 'apps', arr[0], 'site_files', extname, arr[1], arr[2]);
395
- }
396
- }
397
-
398
- if (!____0.isFileExistsSync(path)) {
399
- let arr = name.split('/');
400
- if (arr.length > 1) {
401
- ____0.apps.forEach((ap) => {
402
- if (arr.length === 2 && ap.name == arr[0]) {
403
- let extname = ____0.path.extname(arr[1]).replace('.', '');
404
- if (fsm.isImage(extname)) {
405
- extname = 'images';
294
+ };
295
+
296
+ fsm.readFileSyncRaw = function (path) {
297
+ return fs.readFileSync(path, ____0.fn.getFileEncode(path));
298
+ };
299
+ fsm.readFileSync = function (path) {
300
+ path = fsm.getFilePath(path);
301
+
302
+ if (!path) {
303
+ return '';
304
+ }
305
+
306
+ let index = fsm.list.findIndex((f) => f.path == path);
307
+ if (index !== -1) {
308
+ fsm.list[index].count++;
309
+ fsm.list[index].time = new Date().getTime();
310
+ return fsm.list[index].content;
311
+ }
312
+
313
+ if (fsm.isFileExistsSync(path)) {
314
+ let file = {
315
+ path: path,
316
+ content: fsm.readFileSyncRaw(path),
317
+ count: 1,
318
+ stat: fsm.statSync(path),
319
+ time: new Date().getTime(),
320
+ };
321
+ fsm.list.push(file);
322
+
323
+ return file.content;
324
+ } else if (fsm.isFileExistsSync(path + '.isite-backup')) {
325
+ let file = {
326
+ path: path,
327
+ content: fsm.readFileSyncRaw(path + '.isite-backup'),
328
+ count: 1,
329
+ stat: fsm.statSync(path + '.isite-backup'),
330
+ time: new Date().getTime(),
331
+ };
332
+ fsm.list.push(file);
333
+
334
+ return file.content;
335
+ }
336
+ return '';
337
+ };
338
+
339
+ fsm.readFiles = function (paths, callback) {
340
+ callback = callback || function () {};
341
+ var content = '';
342
+ for (var index = 0; index < paths.length; index++) {
343
+ let p = paths[index];
344
+ let exists = !1;
345
+ for (let i = 0; i < fsm.list.length; i++) {
346
+ let file = fsm.list[i];
347
+ if (file.path == p) {
348
+ content += file.content;
349
+ file.count++;
350
+ exists = !0;
351
+ }
352
+ }
353
+ if (!exists) {
354
+ data = fsm.readFileSync(p);
355
+ content += data;
406
356
  }
407
- path = ____0.path.join(ap.path, 'site_files', extname, arr[1]);
408
- } else if (arr.length === 2 && ap.name2 == arr[0]) {
409
- let extname = ____0.path.extname(arr[1]).replace('.', '');
410
- if (fsm.isImage(extname)) {
411
- extname = 'images';
357
+ }
358
+ callback(null, content);
359
+ };
360
+
361
+ fsm.isImage = function (extname) {
362
+ if (extname.contains('png|jpg|jpeg|bmp|ico|webp|gif')) {
363
+ return true;
364
+ }
365
+ return false;
366
+ };
367
+
368
+ fsm.getContent = function (name, callback) {
369
+ callback = callback || function () {};
370
+ let extname = ____0.path.extname(name).replace('.', '');
371
+ if (fsm.isImage(extname)) {
372
+ extname = 'images';
373
+ }
374
+
375
+ let path = name;
376
+
377
+ if (!____0.isFileExistsSync(path)) {
378
+ path = ____0.path.join(____0.dir, extname, name);
379
+ }
380
+
381
+ if (!____0.isFileExistsSync(path)) {
382
+ let arr = name.split('/');
383
+ if (arr.length === 2) {
384
+ let extname = ____0.path.extname(arr[1]).replace('.', '');
385
+ if (fsm.isImage(extname)) {
386
+ extname = 'images';
387
+ }
388
+ path = ____0.path.join(____0.path.dirname(____0.dir), 'apps', arr[0], 'site_files', extname, arr[1]);
389
+ } else if (arr.length === 3) {
390
+ let extname = ____0.path.extname(arr[2]).replace('.', '');
391
+ if (fsm.isImage(extname)) {
392
+ extname = 'images';
393
+ }
394
+ path = ____0.path.join(____0.path.dirname(____0.dir), 'apps', arr[0], 'site_files', extname, arr[1], arr[2]);
412
395
  }
413
- path = ____0.path.join(ap.path, 'site_files', extname, arr[1]);
414
- } else if (arr.length === 3 && ap.name == arr[0]) {
415
- let extname = ____0.path.extname(arr[2]).replace('.', '');
416
- if (fsm.isImage(extname)) {
417
- extname = 'images';
396
+ }
397
+
398
+ if (!____0.isFileExistsSync(path)) {
399
+ let arr = name.split('/');
400
+ if (arr.length > 1) {
401
+ ____0.apps.forEach((ap) => {
402
+ if (arr.length === 2 && ap.name == arr[0]) {
403
+ let extname = ____0.path.extname(arr[1]).replace('.', '');
404
+ if (fsm.isImage(extname)) {
405
+ extname = 'images';
406
+ }
407
+ path = ____0.path.join(ap.path, 'site_files', extname, arr[1]);
408
+ } else if (arr.length === 2 && ap.name2 == arr[0]) {
409
+ let extname = ____0.path.extname(arr[1]).replace('.', '');
410
+ if (fsm.isImage(extname)) {
411
+ extname = 'images';
412
+ }
413
+ path = ____0.path.join(ap.path, 'site_files', extname, arr[1]);
414
+ } else if (arr.length === 3 && ap.name == arr[0]) {
415
+ let extname = ____0.path.extname(arr[2]).replace('.', '');
416
+ if (fsm.isImage(extname)) {
417
+ extname = 'images';
418
+ }
419
+ path = ____0.path.join(ap.path, 'site_files', extname, arr[1], arr[2]);
420
+ }
421
+ });
418
422
  }
419
- path = ____0.path.join(ap.path, 'site_files', extname, arr[1], arr[2]);
420
- }
423
+ }
424
+
425
+ if (!____0.isFileExistsSync(path)) {
426
+ ____0.log(path, 'PATH NOT EXISTS fsm.getContent()');
427
+ callback('');
428
+ return '';
429
+ }
430
+
431
+ let txt = ____0.readFileSync(path);
432
+ callback(txt);
433
+ return txt;
434
+ };
435
+
436
+ fsm.css = function (name, callback) {
437
+ callback = callback || function () {};
438
+ fsm.readFile(fsm.dir + '/css/' + name + '.css', function (err, data, file) {
439
+ callback(err, data, file);
421
440
  });
422
- }
423
- }
424
-
425
- if (!____0.isFileExistsSync(path)) {
426
- ____0.log(path, 'PATH NOT EXISTS fsm.getContent()');
427
- callback('');
428
- return '';
429
- }
430
-
431
- let txt = ____0.readFileSync(path);
432
- callback(txt);
433
- return txt;
434
- };
435
-
436
- fsm.css = function (name, callback) {
437
- callback = callback || function () {};
438
- fsm.readFile(fsm.dir + '/css/' + name + '.css', function (err, data, file) {
439
- callback(err, data, file);
440
- });
441
- };
441
+ };
442
442
 
443
- fsm.js = function (name, callback) {
444
- callback = callback || function () {};
445
- fsm.readFile(fsm.dir + '/js/' + name + '.js', function (err, data, file) {
446
- callback(err, data, file);
447
- });
448
- };
443
+ fsm.js = function (name, callback) {
444
+ callback = callback || function () {};
445
+ fsm.readFile(fsm.dir + '/js/' + name + '.js', function (err, data, file) {
446
+ callback(err, data, file);
447
+ });
448
+ };
449
449
 
450
- fsm.html = function (name, callback) {
451
- callback = callback || function () {};
452
- fsm.readFile(fsm.dir + '/html/' + name + '.html', function (err, data, file) {
453
- callback(err, data, file);
454
- });
455
- };
450
+ fsm.html = function (name, callback) {
451
+ callback = callback || function () {};
452
+ fsm.readFile(fsm.dir + '/html/' + name + '.html', function (err, data, file) {
453
+ callback(err, data, file);
454
+ });
455
+ };
456
456
 
457
- fsm.json = function (name, callback) {
458
- callback = callback || function () {};
459
- fsm.readFile(fsm.dir + '/json/' + name + '.json', function (err, data, file) {
460
- callback(err, data, file);
461
- });
462
- };
457
+ fsm.json = function (name, callback) {
458
+ callback = callback || function () {};
459
+ fsm.readFile(fsm.dir + '/json/' + name + '.json', function (err, data, file) {
460
+ callback(err, data, file);
461
+ });
462
+ };
463
463
 
464
- fsm.xml = function (name, callback) {
465
- callback = callback || function () {};
466
- fsm.readFile(fsm.dir + '/xml/' + name + '.xml', function (err, data, file) {
467
- callback(err, data, file);
468
- });
469
- };
470
-
471
- fsm.downloadFile = function (path, req, res) {
472
- fsm.stat(path, (err, stats) => {
473
- if (!err) {
474
- res.writeHead(200, {
475
- 'Content-Type': ____0.fn.contentType(path),
476
- 'Content-Length': stats.size,
477
- 'Content-Disposition': 'attachment; filename=' + ____0.path.basename(path),
464
+ fsm.xml = function (name, callback) {
465
+ callback = callback || function () {};
466
+ fsm.readFile(fsm.dir + '/xml/' + name + '.xml', function (err, data, file) {
467
+ callback(err, data, file);
478
468
  });
479
- var readStream = fs.createReadStream(path);
480
- readStream.pipe(res);
481
- } else {
482
- res.error();
483
- }
484
- });
485
- };
469
+ };
470
+
471
+ fsm.downloadFile = function (path, req, res) {
472
+ try {
473
+ let stats = fsm.statSync(path);
474
+ if (stats) {
475
+ res.writeHead(200, {
476
+ 'Content-Type': ____0.fn.contentType(path),
477
+ 'Content-Length': stats.size,
478
+ 'Content-Disposition': 'attachment; filename=' + ____0.path.basename(path),
479
+ });
480
+ var readStream = fs.createReadStream(path);
481
+ readStream.pipe(res);
482
+ } else {
483
+ res.error();
484
+ }
485
+ } catch (error) {
486
+ res.error();
487
+ }
488
+ };
486
489
 
487
- fsm.download = function (name, req, res) {
488
- return fsm.downloadFile(fsm.dir + '/downloads/' + name, req, res);
489
- };
490
+ fsm.download = function (name, req, res) {
491
+ return fsm.downloadFile(fsm.dir + '/downloads/' + name, req, res);
492
+ };
490
493
 
491
- return fsm;
494
+ return fsm;
492
495
  };
package/lib/parser.js CHANGED
@@ -81,7 +81,8 @@ module.exports = function init(req, res, ____0, route) {
81
81
  }
82
82
  }
83
83
 
84
- return out || '';
84
+
85
+ return out ?? '';
85
86
  }
86
87
 
87
88
  function renderUser(v) {
@@ -306,6 +307,17 @@ module.exports = function init(req, res, ____0, route) {
306
307
  name = name.replace('#', '');
307
308
  }
308
309
 
310
+ if (!path || !____0.isFileExistsSync(path)) {
311
+ let arr = name.split('/');
312
+ if (arr.length === 1) {
313
+ path = ____0.path.join(route.parserDir, 'site_files', ____0.path.extname(arr[0]).replace('.', ''), arr[0]);
314
+ } else if (arr.length === 2) {
315
+ path = ____0.path.join(route.parserDir, 'site_files', ____0.path.extname(arr[1]).replace('.', ''), arr[0], arr[1]);
316
+ } else if (arr.length === 3) {
317
+ path = ____0.path.join(route.parserDir, 'site_files', ____0.path.extname(arr[2]).replace('.', ''), arr[0], arr[1], arr[2]);
318
+ }
319
+ }
320
+
309
321
  if (!path || !____0.isFileExistsSync(path)) {
310
322
  let arr = name.split('/');
311
323
  if (arr.length === 1) {
@@ -420,7 +432,7 @@ module.exports = function init(req, res, ____0, route) {
420
432
  v = v[p[2]];
421
433
  }
422
434
 
423
- _html = _html.replace(matches[i], v || '');
435
+ _html = _html.replace(matches[i], v ?? '');
424
436
  }
425
437
  }
426
438
  let $2 = ____0.$.load(_html);
@@ -506,7 +518,7 @@ module.exports = function init(req, res, ____0, route) {
506
518
  if (p.length > 2 && v) {
507
519
  v = v[p[2]];
508
520
  }
509
- _html = _html.replace(matches[i], v || '');
521
+ _html = _html.replace(matches[i], v ?? '');
510
522
  }
511
523
  }
512
524
  let $2 = ____0.$.load(_html);
package/lib/session.js CHANGED
@@ -69,6 +69,7 @@ module.exports = function init(req, res, ____0, callback) {
69
69
  if (req.headers['x-browser']) {
70
70
  req.features.push('browser.social');
71
71
  req.features.push('browser.') + req.headers['x-browser'].split('.')[0];
72
+ req.browserID = req.headers['x-browser'];
72
73
  }
73
74
 
74
75
  if (req.headers['user-agent']) {
@@ -145,7 +146,7 @@ module.exports = function init(req, res, ____0, callback) {
145
146
  callback(session);
146
147
  session.$save();
147
148
  }
148
- }
149
+ },
149
150
  );
150
151
  } else if (session.user) {
151
152
  ____0.security.getUser(
@@ -167,7 +168,7 @@ module.exports = function init(req, res, ____0, callback) {
167
168
  callback(session);
168
169
  session.$save();
169
170
  }
170
- }
171
+ },
171
172
  );
172
173
  } else {
173
174
  callback(session);
package/lib/sessions.js CHANGED
@@ -33,9 +33,8 @@ module.exports = function init(____0) {
33
33
  };
34
34
 
35
35
  sessions.handleSessions = function () {
36
- sessions.list = sessions.list.filter((s) => s && new Date().getTime() - s.createdTime < 1000 * 60 * ____0.options.session.timeout);
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);
36
+ sessions.list = sessions.list.filter((s) => s && (s.user_id || new Date().getTime() - s.createdTime < 1000 * 60 * ____0.options.session.timeout));
37
+ sessions.list = sessions.list.filter((s) => s && (s.user_id || new Date().getTime() - s.$time < 1000 * 60 * ____0.options.session.memoryTimeout));
39
38
 
40
39
  if (____0.options.session.enabled && ____0.options.session.storage === 'mongodb') {
41
40
  sessions.$collection.deleteAll({ createdTime: { $lt: new Date().getTime() - 1000 * 60 * ____0.options.session.timeout } });
@@ -87,15 +86,6 @@ module.exports = function init(____0) {
87
86
 
88
87
  callback = callback || function () {};
89
88
 
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
- // session.$new = !0;
96
- // return callback(session);
97
- // }
98
-
99
89
  if (session.accessToken) {
100
90
  let index = sessions.list.findIndex((s) => s && s.accessToken && s.accessToken == session.accessToken);
101
91
  if (index !== -1) {
@@ -131,7 +121,7 @@ module.exports = function init(____0) {
131
121
  callback(sessions.list[sessions.list.findIndex((s) => s && s.accessToken == session.accessToken)]);
132
122
  }
133
123
  },
134
- true
124
+ true,
135
125
  );
136
126
  } else {
137
127
  session.$new = !0;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "isite",
3
- "version": "2025.01.20",
3
+ "version": "2025.07.01",
4
4
  "description": "Create High Level Multi-Language Web Site [Fast and Easy] ",
5
5
  "main": "index.js",
6
6
  "repository": {