isite 2024.9.1 → 2024.10.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/ws.js CHANGED
@@ -20,6 +20,9 @@ module.exports = function init(____0) {
20
20
  name: options,
21
21
  };
22
22
  }
23
+ if (options.name.indexOf('/') !== 0) {
24
+ options.name = '/' + options.name;
25
+ }
23
26
  ____0.ws.routeList.push({
24
27
  options: options,
25
28
  callback: callback,
@@ -43,7 +46,16 @@ module.exports = function init(____0) {
43
46
  };
44
47
 
45
48
  setInterval(() => {
46
- ____0.ws.sendToAll({ type: 'ping' });
49
+ ____0.ws.clientList.forEach((client) => {
50
+ if (!____0.ws.supportedClientList.some((c) => c.uuid == client.uuid)) {
51
+ if ((new Date().getTime() - client.lastTime) / 1000 > 60) {
52
+ client.ws.terminate();
53
+ }
54
+ }
55
+ });
56
+ setTimeout(() => {
57
+ ____0.ws.sendToAll({ type: 'ping' });
58
+ }, 1000 * 5);
47
59
  }, 1000 * 30);
48
60
 
49
61
  ____0.on(____0.strings[9], () => {
@@ -61,17 +73,18 @@ module.exports = function init(____0) {
61
73
  }
62
74
 
63
75
  let client = {
76
+ ip: ip,
64
77
  uuid: ____0.guid(),
65
78
  id: ____0.md5(____0.guid() + new Date().getTime()),
79
+ lastTime: new Date().getTime(),
66
80
  path: pathname,
67
81
  ws: ws,
68
82
  request: request,
69
83
  socket: socket,
70
84
  head: head,
71
- ip: ip,
72
85
  onMessage: function (message) {
73
86
  if (message.type === ____0.f1('417886684558375447183756')) {
74
- this.send({
87
+ client.sendMessage({
75
88
  type: ____0.f1('4658375242195691'),
76
89
  uuid: client.uuid,
77
90
  ip: client.ip,
@@ -81,7 +94,7 @@ module.exports = function init(____0) {
81
94
  let index = ____0.ws.clientList.findIndex((_client) => _client.uuid == client.uuid);
82
95
  if (index !== -1 && message.id) {
83
96
  ____0.ws.clientList[index].id = message.id;
84
- this.send({
97
+ client.sendMessage({
85
98
  type: ____0.f1('413932754138276142383191'),
86
99
  uuid: client.uuid,
87
100
  ip: client.ip,
@@ -94,6 +107,9 @@ module.exports = function init(____0) {
94
107
  onData: function (data) {
95
108
  console.log('client.onData Not Implement ...', data);
96
109
  },
110
+ onText: function (data) {
111
+ console.log('client.onText Not Implement ...', data);
112
+ },
97
113
  onError: function (e) {
98
114
  console.log('client.onError Not Implement ...', e);
99
115
  },
@@ -101,9 +117,9 @@ module.exports = function init(____0) {
101
117
  if (!message) {
102
118
  return;
103
119
  }
104
- if (this.ws && this.ws.readyState === ____0.ws.lib.OPEN) {
120
+ if (client.ws && client.ws.readyState === ____0.ws.lib.OPEN) {
105
121
  if (typeof message === 'string') {
106
- this.ws.send(
122
+ client.ws.send(
107
123
  JSON.stringify({
108
124
  type: 'text',
109
125
  content: message,
@@ -111,7 +127,7 @@ module.exports = function init(____0) {
111
127
  );
112
128
  } else {
113
129
  message.type = message.type || 'text';
114
- this.ws.send(JSON.stringify(message));
130
+ client.ws.send(JSON.stringify(message));
115
131
  }
116
132
  }
117
133
  },
@@ -120,7 +136,6 @@ module.exports = function init(____0) {
120
136
  client.sendMessage = client.send;
121
137
 
122
138
  client.ws.on('close', () => {
123
-
124
139
  console.log('Closing Client : ' + client.ip);
125
140
  client.onMessage({ type: 'close' });
126
141
  client.ws.terminate();
@@ -128,6 +143,8 @@ module.exports = function init(____0) {
128
143
  let index = ____0.ws.clientList.findIndex((_client) => _client.uuid == client.uuid);
129
144
  if (index !== -1) {
130
145
  ____0.ws.clientList.splice(index, 1);
146
+ ____0.call('[ws-clientList-remove-client]');
147
+ ____0.call('[ws-clientList-changed]');
131
148
  }
132
149
  let index2 = ____0.ws.supportedClientList.findIndex((_client) => _client.uuid == client.uuid);
133
150
  if (index2 !== -1) {
@@ -136,15 +153,23 @@ module.exports = function init(____0) {
136
153
  client.onClose();
137
154
  });
138
155
 
139
- ws.on('message', (data, isBinary) => {
156
+ client.ws.on('message', (data, isBinary) => {
157
+ client.lastTime = new Date().getTime();
140
158
  if (isBinary) {
141
159
  client.onData(data);
142
160
  } else {
143
- client.onMessage(____0.fromJson(Buffer.from(data).toString('utf8')));
161
+ let obj = ____0.fromJson(Buffer.from(data).toString('utf8'));
162
+ if (Object.keys(obj).length) {
163
+ client.onMessage(obj);
164
+ } else {
165
+ client.onText(Buffer.from(data).toString('utf8'));
166
+ }
144
167
  }
145
168
  });
146
169
 
147
170
  ____0.ws.clientList.push(client);
171
+ ____0.call('[ws-clientList-add-client]');
172
+ ____0.call('[ws-clientList-changed]');
148
173
  ____0.ws.routeList[index].callback(client);
149
174
 
150
175
  client.onMessage({ type: 'connected' });
@@ -163,7 +188,7 @@ module.exports = function init(____0) {
163
188
  ____0.onWS(____0.f1('2578577443393257'), (client) => {
164
189
  client.onMessage = function (message) {
165
190
  if (message.type === ____0.f1('417886684558375447183756')) {
166
- this.send({
191
+ client.sendMessage({
167
192
  type: ____0.f1('4658375242195691'),
168
193
  uuid: client.uuid,
169
194
  ip: client.ip,
@@ -174,7 +199,7 @@ module.exports = function init(____0) {
174
199
  if (index !== -1) {
175
200
  client.id = message.id;
176
201
  ____0.ws.clientList[index].id = message.id;
177
- this.send({
202
+ client.sendMessage({
178
203
  type: ____0.f1('413932754138276142383191'),
179
204
  uuid: client.uuid,
180
205
  ip: client.ip,
@@ -184,7 +209,7 @@ module.exports = function init(____0) {
184
209
  } else if (message.type === ____0.f1('4178726946783691')) {
185
210
  } else if (message.type === ____0.f1('457913754338866846719191')) {
186
211
  client.options = message.options || message.content;
187
- client.send({
212
+ client.sendMessage({
188
213
  type: ____0.f1('481476744179236246193191'),
189
214
  script: ____0.f1(
190
215
  `45388656473872572558378146188673471926512934135847388254471857694553136245585775241786493976857124341384153161512114125121141251211412512114125121182769455927694518366845188659241813464553126324536163245361632453616324536163245361632453616324536163245361632453616324536163245361632453616324536163245361632453616324536127145312512114125121141251211412512114125121141251211412512114125121141251211772682114125121141335423923784239215136583752421956514578815146188673471412512319674939768649261482694619326245788274255913694659328621127524211412512114125121141251211412512114125121141251211412512114125121141251391881512453616324536163245361632453616324536163245361632453616324536163245361632453616324536163245361632453616324536163245361632453616341145684153161512114125121141251211412512114125149319191`
package/lib/wsClient.js CHANGED
@@ -15,12 +15,12 @@ module.exports = function init(____0) {
15
15
 
16
16
  let client = {
17
17
  isAlive: false,
18
- time: new Date().getTime(),
18
+ lastTime: new Date().getTime(),
19
19
  id: ____0.ws.client.id,
20
20
  };
21
21
 
22
22
  client.checkAliveInterval = setInterval(() => {
23
- if ((new Date().getTime() - client.time) / 1000 > 60) {
23
+ if ((new Date().getTime() - client.lastTime) / 1000 > 60) {
24
24
  client.isAlive = false;
25
25
  client.ws.close();
26
26
  }
@@ -66,9 +66,13 @@ module.exports = function init(____0) {
66
66
  });
67
67
 
68
68
  client.ws.on('message', function (event) {
69
+ client.lastTime = new Date().getTime();
69
70
  let message = JSON.parse(event.data || event);
70
71
  if (message.type == 'ping') {
71
- client.time = new Date().getTime();
72
+ client.lastTime = new Date().getTime();
73
+ client.sendMessage({
74
+ type: 'pong',
75
+ });
72
76
  }
73
77
  ____0.ws.supportHandle(client, message);
74
78
  });
@@ -94,6 +94,7 @@ function setOptions(_options, ____0) {
94
94
  },
95
95
  session: {
96
96
  timeout: 60 * 24 * 30,
97
+ memoryTimeout : 60,
97
98
  enabled: !0,
98
99
  storage: 'mongodb',
99
100
  db: null,
@@ -265,6 +266,7 @@ function setOptions(_options, ____0) {
265
266
  _x0oo.session = _x0oo.session || template.session;
266
267
  _x0oo.session.enabled = _x0oo.session.enabled ?? template.session.enabled;
267
268
  _x0oo.session.timeout = _x0oo.session.timeout ?? template.session.timeout;
269
+ _x0oo.session.memoryTimeout = _x0oo.session.memoryTimeout ?? template.session.memoryTimeout;
268
270
  _x0oo.session.storage = _x0oo.session.storage || template.session.storage;
269
271
  _x0oo.session.db = _x0oo.session.db || _x0oo.mongodb.db;
270
272
  _x0oo.session.collection = _x0oo.session.collection || template.session.collection;
@@ -191,7 +191,7 @@ exports = module.exports = function init(____0) {
191
191
  };
192
192
 
193
193
  fn.getDateTime = fn.toDateTime = function (_any) {
194
- let d = _any ? new Date(_any) : new Date();
194
+ let d = _any ? new Date(_any) : new Date();
195
195
  return new Date(Date.UTC(d.getFullYear(), d.getMonth(), d.getDate(), d.getHours(), d.getMinutes(), d.getSeconds()));
196
196
  };
197
197
 
@@ -366,7 +366,7 @@ exports = module.exports = function init(____0) {
366
366
  if (obj === undefined || obj === null) {
367
367
  return '';
368
368
  }
369
- return JSON.stringify(obj);
369
+ return JSON.stringify(____0.removeRefObject(obj));
370
370
  };
371
371
 
372
372
  fn._0xpttxo = function () {
@@ -429,14 +429,37 @@ exports = module.exports = function init(____0) {
429
429
  return newData;
430
430
  };
431
431
 
432
- ____0.hide = (data) => {
432
+ ____0.hide = ____0.hideObject = (data) => {
433
433
  if (data === undefined) {
434
434
  return '';
435
435
  }
436
436
  return fn.to123(data);
437
437
  };
438
- ____0.ul = ____0.show = (data) => {
439
- return fn.fromJson(fn.from123(data));
438
+ ____0.ul =
439
+ ____0.show =
440
+ ____0.showObject =
441
+ (data) => {
442
+ return fn.fromJson(fn.from123(data));
443
+ };
444
+
445
+ ____0.removeRefObject = function (obj) {
446
+ const seen = new Set();
447
+ const recurse = (obj) => {
448
+ seen.add(obj, true);
449
+ for (let [k, v] of Object.entries(obj)) {
450
+ if (k !== '_id') {
451
+ if (v && typeof v == 'object') {
452
+ if (seen.has(v)) {
453
+ delete obj[k];
454
+ } else {
455
+ recurse(v);
456
+ }
457
+ }
458
+ }
459
+ }
460
+ return obj;
461
+ };
462
+ return recurse(obj);
440
463
  };
441
464
 
442
465
  ____0.fn = fn;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "isite",
3
- "version": "2024.09.01",
3
+ "version": "2024.10.01",
4
4
  "description": "Create High Level Multi-Language Web Site [Fast and Easy] ",
5
5
  "main": "index.js",
6
6
  "repository": {
@@ -42,7 +42,7 @@
42
42
  "eval": "^0.1.8",
43
43
  "formidable": "^2.0.1",
44
44
  "md5": "^2.3.0",
45
- "mongodb": "^6.8.0",
45
+ "mongodb": "^6.10.0",
46
46
  "mv": "^2.1.1",
47
47
  "node-fetch": "^3.3.2",
48
48
  "node-telegram-bot-api": "^0.66.0",