waengine 1.7.4 → 1.7.5
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/FEATURES.md +463 -8
- package/README.md +2 -2
- package/package.json +3 -3
- package/src/auth-recovery.js +272 -0
- package/src/client.js +31 -1
- package/src/connection-recovery.js +252 -0
- package/src/cross-platform.js +669 -2
- package/src/index.js +6 -1
- package/src/mobile-support.js +0 -0
- package/src/qr.js +85 -9
- package/src/resource-manager.js +282 -0
- package/src/session-manager.js +21 -2
- package/src/stability-manager.js +0 -0
package/src/cross-platform.js
CHANGED
|
@@ -1,5 +1,8 @@
|
|
|
1
1
|
import { getStorage } from "./storage.js";
|
|
2
2
|
import crypto from 'crypto';
|
|
3
|
+
import os from 'os';
|
|
4
|
+
import fs from 'fs';
|
|
5
|
+
import path from 'path';
|
|
3
6
|
|
|
4
7
|
export class CrossPlatformIntegration {
|
|
5
8
|
constructor(client) {
|
|
@@ -9,21 +12,685 @@ export class CrossPlatformIntegration {
|
|
|
9
12
|
this.webhooks = new Map();
|
|
10
13
|
this.apiEndpoints = new Map();
|
|
11
14
|
this.syncQueue = [];
|
|
15
|
+
this.deviceInfo = null;
|
|
16
|
+
this.environmentInfo = null;
|
|
12
17
|
|
|
13
18
|
this.initializePlatforms();
|
|
19
|
+
this.detectEnvironment();
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
// ===== ENVIRONMENT DETECTION =====
|
|
23
|
+
|
|
24
|
+
detectEnvironment() {
|
|
25
|
+
const platform = os.platform();
|
|
26
|
+
const arch = os.arch();
|
|
27
|
+
const release = os.release();
|
|
28
|
+
const userAgent = process.env.USER_AGENT || '';
|
|
29
|
+
const terminalApp = process.env.TERM_PROGRAM || process.env.TERMINAL_EMULATOR || '';
|
|
30
|
+
|
|
31
|
+
this.environmentInfo = {
|
|
32
|
+
platform,
|
|
33
|
+
arch,
|
|
34
|
+
release,
|
|
35
|
+
userAgent,
|
|
36
|
+
terminalApp,
|
|
37
|
+
isTermux: this.isTermux(),
|
|
38
|
+
isAndroid: this.isAndroid(),
|
|
39
|
+
isIOS: this.isIOS(),
|
|
40
|
+
isMobile: this.isMobile(),
|
|
41
|
+
isDocker: this.isDocker(),
|
|
42
|
+
isWSL: this.isWSL(),
|
|
43
|
+
isReplit: this.isReplit(),
|
|
44
|
+
isGitpod: this.isGitpod(),
|
|
45
|
+
isCodespaces: this.isCodespaces(),
|
|
46
|
+
isHeroku: this.isHeroku(),
|
|
47
|
+
isVercel: this.isVercel(),
|
|
48
|
+
isNetlify: this.isNetlify(),
|
|
49
|
+
isRailway: this.isRailway(),
|
|
50
|
+
isRender: this.isRender(),
|
|
51
|
+
capabilities: this.detectCapabilities()
|
|
52
|
+
};
|
|
53
|
+
|
|
54
|
+
this.deviceInfo = {
|
|
55
|
+
type: this.getDeviceType(),
|
|
56
|
+
os: this.getOSInfo(),
|
|
57
|
+
runtime: this.getRuntimeInfo(),
|
|
58
|
+
network: this.getNetworkInfo(),
|
|
59
|
+
storage: this.getStorageInfo(),
|
|
60
|
+
display: this.getDisplayInfo()
|
|
61
|
+
};
|
|
62
|
+
|
|
63
|
+
console.log(`🌍 WAEngine detected: ${this.environmentInfo.platform} on ${this.deviceInfo.type}`);
|
|
64
|
+
this.optimizeForEnvironment();
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
// ===== ENVIRONMENT DETECTION METHODS =====
|
|
68
|
+
|
|
69
|
+
isTermux() {
|
|
70
|
+
return process.env.PREFIX?.includes('com.termux') ||
|
|
71
|
+
fs.existsSync('/data/data/com.termux') ||
|
|
72
|
+
process.env.TERMUX_VERSION !== undefined;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
isAndroid() {
|
|
76
|
+
return this.isTermux() ||
|
|
77
|
+
process.env.ANDROID_ROOT !== undefined ||
|
|
78
|
+
process.env.ANDROID_DATA !== undefined ||
|
|
79
|
+
os.platform() === 'android';
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
isIOS() {
|
|
83
|
+
return process.env.IPHONEOS_DEPLOYMENT_TARGET !== undefined ||
|
|
84
|
+
process.platform === 'darwin' && process.env.SIMULATOR_DEVICE_NAME !== undefined;
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
isMobile() {
|
|
88
|
+
return this.isAndroid() || this.isIOS();
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
isDocker() {
|
|
92
|
+
return fs.existsSync('/.dockerenv') ||
|
|
93
|
+
process.env.DOCKER_CONTAINER === 'true';
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
isWSL() {
|
|
97
|
+
return process.env.WSL_DISTRO_NAME !== undefined ||
|
|
98
|
+
os.release().toLowerCase().includes('microsoft');
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
isReplit() {
|
|
102
|
+
return process.env.REPL_ID !== undefined ||
|
|
103
|
+
process.env.REPLIT_DB_URL !== undefined;
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
isGitpod() {
|
|
107
|
+
return process.env.GITPOD_WORKSPACE_ID !== undefined;
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
isCodespaces() {
|
|
111
|
+
return process.env.CODESPACES === 'true';
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
isHeroku() {
|
|
115
|
+
return process.env.DYNO !== undefined;
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
isVercel() {
|
|
119
|
+
return process.env.VERCEL === '1';
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
isNetlify() {
|
|
123
|
+
return process.env.NETLIFY === 'true';
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
isRailway() {
|
|
127
|
+
return process.env.RAILWAY_ENVIRONMENT !== undefined;
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
isRender() {
|
|
131
|
+
return process.env.RENDER === 'true';
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
// ===== DEVICE TYPE DETECTION =====
|
|
135
|
+
|
|
136
|
+
getDeviceType() {
|
|
137
|
+
if (this.isTermux()) return 'termux';
|
|
138
|
+
if (this.isAndroid()) return 'android';
|
|
139
|
+
if (this.isIOS()) return 'ios';
|
|
140
|
+
if (this.isDocker()) return 'docker';
|
|
141
|
+
if (this.isWSL()) return 'wsl';
|
|
142
|
+
if (this.isReplit()) return 'replit';
|
|
143
|
+
if (this.isGitpod()) return 'gitpod';
|
|
144
|
+
if (this.isCodespaces()) return 'codespaces';
|
|
145
|
+
if (this.isHeroku()) return 'heroku';
|
|
146
|
+
if (this.isVercel()) return 'vercel';
|
|
147
|
+
if (this.isNetlify()) return 'netlify';
|
|
148
|
+
if (this.isRailway()) return 'railway';
|
|
149
|
+
if (this.isRender()) return 'render';
|
|
150
|
+
|
|
151
|
+
const platform = os.platform();
|
|
152
|
+
switch (platform) {
|
|
153
|
+
case 'win32': return 'windows';
|
|
154
|
+
case 'darwin': return 'macos';
|
|
155
|
+
case 'linux': return 'linux';
|
|
156
|
+
case 'freebsd': return 'freebsd';
|
|
157
|
+
case 'openbsd': return 'openbsd';
|
|
158
|
+
case 'sunos': return 'solaris';
|
|
159
|
+
default: return 'unknown';
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
getOSInfo() {
|
|
164
|
+
return {
|
|
165
|
+
platform: os.platform(),
|
|
166
|
+
arch: os.arch(),
|
|
167
|
+
release: os.release(),
|
|
168
|
+
version: os.version?.() || 'unknown',
|
|
169
|
+
hostname: os.hostname(),
|
|
170
|
+
uptime: os.uptime(),
|
|
171
|
+
loadavg: os.loadavg(),
|
|
172
|
+
totalmem: os.totalmem(),
|
|
173
|
+
freemem: os.freemem(),
|
|
174
|
+
cpus: os.cpus().length
|
|
175
|
+
};
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
getRuntimeInfo() {
|
|
179
|
+
return {
|
|
180
|
+
node: process.version,
|
|
181
|
+
v8: process.versions.v8,
|
|
182
|
+
platform: process.platform,
|
|
183
|
+
arch: process.arch,
|
|
184
|
+
pid: process.pid,
|
|
185
|
+
ppid: process.ppid,
|
|
186
|
+
cwd: process.cwd(),
|
|
187
|
+
execPath: process.execPath,
|
|
188
|
+
argv: process.argv,
|
|
189
|
+
env: {
|
|
190
|
+
NODE_ENV: process.env.NODE_ENV,
|
|
191
|
+
PATH: process.env.PATH?.split(path.delimiter).length || 0,
|
|
192
|
+
SHELL: process.env.SHELL,
|
|
193
|
+
TERM: process.env.TERM,
|
|
194
|
+
USER: process.env.USER || process.env.USERNAME
|
|
195
|
+
}
|
|
196
|
+
};
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
getNetworkInfo() {
|
|
200
|
+
const interfaces = os.networkInterfaces();
|
|
201
|
+
const networks = [];
|
|
202
|
+
|
|
203
|
+
Object.entries(interfaces).forEach(([name, addrs]) => {
|
|
204
|
+
addrs?.forEach(addr => {
|
|
205
|
+
if (!addr.internal) {
|
|
206
|
+
networks.push({
|
|
207
|
+
interface: name,
|
|
208
|
+
family: addr.family,
|
|
209
|
+
address: addr.address,
|
|
210
|
+
netmask: addr.netmask,
|
|
211
|
+
mac: addr.mac
|
|
212
|
+
});
|
|
213
|
+
}
|
|
214
|
+
});
|
|
215
|
+
});
|
|
216
|
+
|
|
217
|
+
return {
|
|
218
|
+
interfaces: Object.keys(interfaces),
|
|
219
|
+
networks,
|
|
220
|
+
hasInternet: networks.length > 0
|
|
221
|
+
};
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
getStorageInfo() {
|
|
225
|
+
try {
|
|
226
|
+
const stats = fs.statSync(process.cwd());
|
|
227
|
+
return {
|
|
228
|
+
cwd: process.cwd(),
|
|
229
|
+
writable: true, // Simplified check
|
|
230
|
+
available: true,
|
|
231
|
+
type: 'filesystem'
|
|
232
|
+
};
|
|
233
|
+
} catch (error) {
|
|
234
|
+
return {
|
|
235
|
+
cwd: process.cwd(),
|
|
236
|
+
writable: false,
|
|
237
|
+
available: false,
|
|
238
|
+
type: 'unknown',
|
|
239
|
+
error: error.message
|
|
240
|
+
};
|
|
241
|
+
}
|
|
242
|
+
}
|
|
243
|
+
|
|
244
|
+
getDisplayInfo() {
|
|
245
|
+
const columns = process.stdout.columns || 80;
|
|
246
|
+
const rows = process.stdout.rows || 24;
|
|
247
|
+
|
|
248
|
+
return {
|
|
249
|
+
terminal: {
|
|
250
|
+
columns,
|
|
251
|
+
rows,
|
|
252
|
+
colorDepth: process.stdout.getColorDepth?.() || 1,
|
|
253
|
+
isTTY: process.stdout.isTTY,
|
|
254
|
+
hasColors: process.stdout.hasColors?.() || false
|
|
255
|
+
},
|
|
256
|
+
environment: {
|
|
257
|
+
DISPLAY: process.env.DISPLAY,
|
|
258
|
+
TERM: process.env.TERM,
|
|
259
|
+
COLORTERM: process.env.COLORTERM,
|
|
260
|
+
TERM_PROGRAM: process.env.TERM_PROGRAM
|
|
261
|
+
}
|
|
262
|
+
};
|
|
263
|
+
}
|
|
264
|
+
|
|
265
|
+
// ===== CAPABILITY DETECTION =====
|
|
266
|
+
|
|
267
|
+
detectCapabilities() {
|
|
268
|
+
const caps = {
|
|
269
|
+
// Basic capabilities
|
|
270
|
+
filesystem: true,
|
|
271
|
+
network: true,
|
|
272
|
+
crypto: true,
|
|
273
|
+
|
|
274
|
+
// Display capabilities
|
|
275
|
+
terminal: process.stdout.isTTY,
|
|
276
|
+
colors: process.stdout.hasColors?.() || false,
|
|
277
|
+
unicode: this.supportsUnicode(),
|
|
278
|
+
|
|
279
|
+
// QR Code capabilities
|
|
280
|
+
qrTerminal: this.supportsTerminalQR(),
|
|
281
|
+
qrBrowser: this.supportsBrowserQR(),
|
|
282
|
+
qrFile: true,
|
|
283
|
+
|
|
284
|
+
// Media capabilities
|
|
285
|
+
sharp: this.supportsSharp(),
|
|
286
|
+
canvas: this.supportsCanvas(),
|
|
287
|
+
|
|
288
|
+
// Platform-specific
|
|
289
|
+
notifications: this.supportsNotifications(),
|
|
290
|
+
clipboard: this.supportsClipboard(),
|
|
291
|
+
|
|
292
|
+
// Network capabilities
|
|
293
|
+
http: true,
|
|
294
|
+
websockets: true,
|
|
295
|
+
|
|
296
|
+
// Storage capabilities
|
|
297
|
+
localStorage: true,
|
|
298
|
+
sessionStorage: false,
|
|
299
|
+
|
|
300
|
+
// Mobile-specific
|
|
301
|
+
vibration: this.isMobile(),
|
|
302
|
+
orientation: this.isMobile(),
|
|
303
|
+
|
|
304
|
+
// Cloud platform capabilities
|
|
305
|
+
serverless: this.isServerless(),
|
|
306
|
+
persistent: this.isPersistent()
|
|
307
|
+
};
|
|
308
|
+
|
|
309
|
+
return caps;
|
|
310
|
+
}
|
|
311
|
+
|
|
312
|
+
supportsUnicode() {
|
|
313
|
+
const term = process.env.TERM || '';
|
|
314
|
+
const lang = process.env.LANG || '';
|
|
315
|
+
|
|
316
|
+
return term.includes('256') ||
|
|
317
|
+
term.includes('color') ||
|
|
318
|
+
lang.includes('UTF-8') ||
|
|
319
|
+
this.isTermux();
|
|
320
|
+
}
|
|
321
|
+
|
|
322
|
+
supportsTerminalQR() {
|
|
323
|
+
return process.stdout.isTTY &&
|
|
324
|
+
(process.stdout.columns || 80) >= 40 &&
|
|
325
|
+
(process.stdout.rows || 24) >= 20;
|
|
326
|
+
}
|
|
327
|
+
|
|
328
|
+
supportsBrowserQR() {
|
|
329
|
+
// Check if we can open browsers
|
|
330
|
+
if (this.isTermux()) return true; // Termux can open browsers
|
|
331
|
+
if (this.isWSL()) return true; // WSL can open Windows browsers
|
|
332
|
+
if (this.isReplit() || this.isGitpod() || this.isCodespaces()) return true; // Cloud IDEs
|
|
333
|
+
|
|
334
|
+
const platform = os.platform();
|
|
335
|
+
return platform === 'win32' || platform === 'darwin' || platform === 'linux';
|
|
336
|
+
}
|
|
337
|
+
|
|
338
|
+
supportsSharp() {
|
|
339
|
+
try {
|
|
340
|
+
require.resolve('sharp');
|
|
341
|
+
return true;
|
|
342
|
+
} catch {
|
|
343
|
+
return false;
|
|
344
|
+
}
|
|
345
|
+
}
|
|
346
|
+
|
|
347
|
+
supportsCanvas() {
|
|
348
|
+
try {
|
|
349
|
+
require.resolve('canvas');
|
|
350
|
+
return true;
|
|
351
|
+
} catch {
|
|
352
|
+
return false;
|
|
353
|
+
}
|
|
354
|
+
}
|
|
355
|
+
|
|
356
|
+
supportsNotifications() {
|
|
357
|
+
return !this.isServerless() &&
|
|
358
|
+
(os.platform() === 'win32' || os.platform() === 'darwin' || os.platform() === 'linux');
|
|
359
|
+
}
|
|
360
|
+
|
|
361
|
+
supportsClipboard() {
|
|
362
|
+
return !this.isServerless() && this.supportsNotifications();
|
|
363
|
+
}
|
|
364
|
+
|
|
365
|
+
isServerless() {
|
|
366
|
+
return this.isVercel() || this.isNetlify() ||
|
|
367
|
+
process.env.AWS_LAMBDA_FUNCTION_NAME !== undefined ||
|
|
368
|
+
process.env.FUNCTION_NAME !== undefined;
|
|
369
|
+
}
|
|
370
|
+
|
|
371
|
+
isPersistent() {
|
|
372
|
+
return !this.isServerless() &&
|
|
373
|
+
!this.isReplit() &&
|
|
374
|
+
!this.isGitpod() &&
|
|
375
|
+
!this.isCodespaces();
|
|
376
|
+
}
|
|
377
|
+
|
|
378
|
+
// ===== ENVIRONMENT OPTIMIZATION =====
|
|
379
|
+
|
|
380
|
+
optimizeForEnvironment() {
|
|
381
|
+
const deviceType = this.deviceInfo.type;
|
|
382
|
+
const caps = this.environmentInfo.capabilities;
|
|
383
|
+
|
|
384
|
+
// Termux-specific optimizations
|
|
385
|
+
if (deviceType === 'termux') {
|
|
386
|
+
this.optimizeForTermux();
|
|
387
|
+
}
|
|
388
|
+
|
|
389
|
+
// Android-specific optimizations
|
|
390
|
+
if (this.isAndroid()) {
|
|
391
|
+
this.optimizeForAndroid();
|
|
392
|
+
}
|
|
393
|
+
|
|
394
|
+
// iOS-specific optimizations
|
|
395
|
+
if (this.isIOS()) {
|
|
396
|
+
this.optimizeForIOS();
|
|
397
|
+
}
|
|
398
|
+
|
|
399
|
+
// Cloud platform optimizations
|
|
400
|
+
if (this.isServerless()) {
|
|
401
|
+
this.optimizeForServerless();
|
|
402
|
+
}
|
|
403
|
+
|
|
404
|
+
// Container optimizations
|
|
405
|
+
if (this.isDocker()) {
|
|
406
|
+
this.optimizeForDocker();
|
|
407
|
+
}
|
|
408
|
+
|
|
409
|
+
// Low-resource optimizations
|
|
410
|
+
if (this.isLowResource()) {
|
|
411
|
+
this.optimizeForLowResource();
|
|
412
|
+
}
|
|
413
|
+
|
|
414
|
+
console.log(`⚡ Optimized for ${deviceType} environment`);
|
|
415
|
+
}
|
|
416
|
+
|
|
417
|
+
optimizeForTermux() {
|
|
418
|
+
// Termux-specific settings
|
|
419
|
+
process.env.TERMUX_OPTIMIZED = 'true';
|
|
420
|
+
|
|
421
|
+
// Use Termux-specific paths
|
|
422
|
+
const termuxPaths = {
|
|
423
|
+
storage: '/data/data/com.termux/files/home/storage',
|
|
424
|
+
shared: '/storage/emulated/0',
|
|
425
|
+
downloads: '/storage/emulated/0/Download'
|
|
426
|
+
};
|
|
427
|
+
|
|
428
|
+
// Set QR mode to terminal (browsers work but terminal is faster)
|
|
429
|
+
this.setQRMode('terminal');
|
|
430
|
+
|
|
431
|
+
// Enable Android-specific features
|
|
432
|
+
this.enableAndroidFeatures();
|
|
433
|
+
|
|
434
|
+
console.log('🤖 Termux optimizations applied');
|
|
435
|
+
}
|
|
436
|
+
|
|
437
|
+
optimizeForAndroid() {
|
|
438
|
+
// Android-specific settings
|
|
439
|
+
process.env.ANDROID_OPTIMIZED = 'true';
|
|
440
|
+
|
|
441
|
+
// Use Android paths
|
|
442
|
+
const androidPaths = {
|
|
443
|
+
external: '/sdcard',
|
|
444
|
+
downloads: '/sdcard/Download',
|
|
445
|
+
documents: '/sdcard/Documents'
|
|
446
|
+
};
|
|
447
|
+
|
|
448
|
+
// Enable mobile features
|
|
449
|
+
this.enableMobileFeatures();
|
|
450
|
+
|
|
451
|
+
console.log('📱 Android optimizations applied');
|
|
452
|
+
}
|
|
453
|
+
|
|
454
|
+
optimizeForIOS() {
|
|
455
|
+
// iOS-specific settings
|
|
456
|
+
process.env.IOS_OPTIMIZED = 'true';
|
|
457
|
+
|
|
458
|
+
// Enable mobile features
|
|
459
|
+
this.enableMobileFeatures();
|
|
460
|
+
|
|
461
|
+
console.log('🍎 iOS optimizations applied');
|
|
462
|
+
}
|
|
463
|
+
|
|
464
|
+
optimizeForServerless() {
|
|
465
|
+
// Serverless optimizations
|
|
466
|
+
process.env.SERVERLESS_OPTIMIZED = 'true';
|
|
467
|
+
|
|
468
|
+
// Disable persistent features
|
|
469
|
+
this.disablePersistentFeatures();
|
|
470
|
+
|
|
471
|
+
// Use memory storage
|
|
472
|
+
this.useMemoryStorage();
|
|
473
|
+
|
|
474
|
+
console.log('☁️ Serverless optimizations applied');
|
|
475
|
+
}
|
|
476
|
+
|
|
477
|
+
optimizeForDocker() {
|
|
478
|
+
// Docker optimizations
|
|
479
|
+
process.env.DOCKER_OPTIMIZED = 'true';
|
|
480
|
+
|
|
481
|
+
// Use container-friendly settings
|
|
482
|
+
this.setQRMode('terminal');
|
|
483
|
+
|
|
484
|
+
console.log('🐳 Docker optimizations applied');
|
|
485
|
+
}
|
|
486
|
+
|
|
487
|
+
optimizeForLowResource() {
|
|
488
|
+
// Low resource optimizations
|
|
489
|
+
process.env.LOW_RESOURCE = 'true';
|
|
490
|
+
|
|
491
|
+
// Reduce memory usage
|
|
492
|
+
this.reduceMemoryUsage();
|
|
493
|
+
|
|
494
|
+
// Disable heavy features
|
|
495
|
+
this.disableHeavyFeatures();
|
|
496
|
+
|
|
497
|
+
console.log('💾 Low resource optimizations applied');
|
|
498
|
+
}
|
|
499
|
+
|
|
500
|
+
// ===== FEATURE ENABLERS =====
|
|
501
|
+
|
|
502
|
+
enableAndroidFeatures() {
|
|
503
|
+
// Enable Android-specific features
|
|
504
|
+
this.androidFeatures = {
|
|
505
|
+
intentSupport: true,
|
|
506
|
+
notificationSupport: true,
|
|
507
|
+
fileSystemAccess: true,
|
|
508
|
+
cameraAccess: false, // Requires permissions
|
|
509
|
+
locationAccess: false // Requires permissions
|
|
510
|
+
};
|
|
511
|
+
}
|
|
512
|
+
|
|
513
|
+
enableMobileFeatures() {
|
|
514
|
+
// Enable mobile-specific features
|
|
515
|
+
this.mobileFeatures = {
|
|
516
|
+
touchOptimized: true,
|
|
517
|
+
batteryAware: true,
|
|
518
|
+
networkAware: true,
|
|
519
|
+
orientationSupport: true
|
|
520
|
+
};
|
|
521
|
+
}
|
|
522
|
+
|
|
523
|
+
disablePersistentFeatures() {
|
|
524
|
+
// Disable features that require persistence
|
|
525
|
+
this.persistentFeatures = {
|
|
526
|
+
fileStorage: false,
|
|
527
|
+
sessionPersistence: false,
|
|
528
|
+
cachePersistence: false
|
|
529
|
+
};
|
|
530
|
+
}
|
|
531
|
+
|
|
532
|
+
useMemoryStorage() {
|
|
533
|
+
// Use in-memory storage for serverless
|
|
534
|
+
this.storageMode = 'memory';
|
|
535
|
+
}
|
|
536
|
+
|
|
537
|
+
reduceMemoryUsage() {
|
|
538
|
+
// Reduce memory usage
|
|
539
|
+
this.memoryOptimizations = {
|
|
540
|
+
smallCache: true,
|
|
541
|
+
lazyLoading: true,
|
|
542
|
+
garbageCollection: true
|
|
543
|
+
};
|
|
544
|
+
}
|
|
545
|
+
|
|
546
|
+
disableHeavyFeatures() {
|
|
547
|
+
// Disable resource-intensive features
|
|
548
|
+
this.heavyFeatures = {
|
|
549
|
+
imageProcessing: false,
|
|
550
|
+
videoProcessing: false,
|
|
551
|
+
largeFileSupport: false
|
|
552
|
+
};
|
|
553
|
+
}
|
|
554
|
+
|
|
555
|
+
// ===== QR CODE OPTIMIZATION =====
|
|
556
|
+
|
|
557
|
+
setQRMode(mode) {
|
|
558
|
+
this.qrMode = mode;
|
|
559
|
+
process.env.QR_MODE = mode;
|
|
560
|
+
}
|
|
561
|
+
|
|
562
|
+
getOptimalQRMode() {
|
|
563
|
+
const caps = this.environmentInfo.capabilities;
|
|
564
|
+
|
|
565
|
+
if (this.isTermux()) return 'terminal';
|
|
566
|
+
if (this.isDocker()) return 'terminal';
|
|
567
|
+
if (this.isServerless()) return 'file';
|
|
568
|
+
if (caps.qrBrowser) return 'browser';
|
|
569
|
+
if (caps.qrTerminal) return 'terminal';
|
|
570
|
+
return 'file';
|
|
571
|
+
}
|
|
572
|
+
|
|
573
|
+
// ===== RESOURCE DETECTION =====
|
|
574
|
+
|
|
575
|
+
isLowResource() {
|
|
576
|
+
const totalMem = os.totalmem();
|
|
577
|
+
const freeMem = os.freemem();
|
|
578
|
+
const cpus = os.cpus().length;
|
|
579
|
+
|
|
580
|
+
// Consider low resource if:
|
|
581
|
+
// - Less than 1GB total memory
|
|
582
|
+
// - Less than 512MB free memory
|
|
583
|
+
// - Single core CPU
|
|
584
|
+
return totalMem < 1024 * 1024 * 1024 ||
|
|
585
|
+
freeMem < 512 * 1024 * 1024 ||
|
|
586
|
+
cpus === 1;
|
|
14
587
|
}
|
|
15
588
|
|
|
16
589
|
// ===== PLATFORM INITIALIZATION =====
|
|
17
590
|
|
|
18
591
|
initializePlatforms() {
|
|
19
|
-
// Supported platforms
|
|
592
|
+
// Supported platforms - MASSIVELY EXPANDED
|
|
20
593
|
this.supportedPlatforms = [
|
|
594
|
+
// Messaging platforms
|
|
21
595
|
'telegram', 'discord', 'slack', 'teams', 'facebook',
|
|
22
|
-
'instagram', 'twitter', 'email', 'sms', 'web'
|
|
596
|
+
'instagram', 'twitter', 'email', 'sms', 'web',
|
|
597
|
+
|
|
598
|
+
// Mobile platforms
|
|
599
|
+
'android', 'ios', 'termux', 'ish', 'acode',
|
|
600
|
+
|
|
601
|
+
// Cloud platforms
|
|
602
|
+
'replit', 'gitpod', 'codespaces', 'codesandbox',
|
|
603
|
+
'heroku', 'vercel', 'netlify', 'railway', 'render',
|
|
604
|
+
|
|
605
|
+
// Container platforms
|
|
606
|
+
'docker', 'kubernetes', 'podman',
|
|
607
|
+
|
|
608
|
+
// Desktop platforms
|
|
609
|
+
'windows', 'macos', 'linux', 'freebsd',
|
|
610
|
+
|
|
611
|
+
// Development platforms
|
|
612
|
+
'vscode', 'atom', 'sublime', 'vim', 'emacs',
|
|
613
|
+
|
|
614
|
+
// Terminal platforms
|
|
615
|
+
'bash', 'zsh', 'fish', 'powershell', 'cmd',
|
|
616
|
+
|
|
617
|
+
// Web platforms
|
|
618
|
+
'chrome', 'firefox', 'safari', 'edge', 'opera',
|
|
619
|
+
|
|
620
|
+
// IoT platforms
|
|
621
|
+
'raspberry-pi', 'arduino', 'esp32',
|
|
622
|
+
|
|
623
|
+
// Gaming platforms
|
|
624
|
+
'steam', 'epic', 'origin', 'uplay',
|
|
625
|
+
|
|
626
|
+
// Streaming platforms
|
|
627
|
+
'twitch', 'youtube', 'obs'
|
|
23
628
|
];
|
|
24
629
|
|
|
25
630
|
// Load existing platform configurations
|
|
26
631
|
this.loadPlatformConfigs();
|
|
632
|
+
|
|
633
|
+
// Auto-detect available platforms
|
|
634
|
+
this.autoDetectPlatforms();
|
|
635
|
+
}
|
|
636
|
+
|
|
637
|
+
autoDetectPlatforms() {
|
|
638
|
+
const detected = [];
|
|
639
|
+
|
|
640
|
+
// Detect current environment
|
|
641
|
+
const deviceType = this.getDeviceType();
|
|
642
|
+
if (this.supportedPlatforms.includes(deviceType)) {
|
|
643
|
+
detected.push(deviceType);
|
|
644
|
+
}
|
|
645
|
+
|
|
646
|
+
// Detect available browsers
|
|
647
|
+
const browsers = this.detectBrowsers();
|
|
648
|
+
detected.push(...browsers);
|
|
649
|
+
|
|
650
|
+
// Detect terminal
|
|
651
|
+
const terminal = this.detectTerminal();
|
|
652
|
+
if (terminal) detected.push(terminal);
|
|
653
|
+
|
|
654
|
+
// Detect development environment
|
|
655
|
+
const devEnv = this.detectDevelopmentEnvironment();
|
|
656
|
+
if (devEnv) detected.push(devEnv);
|
|
657
|
+
|
|
658
|
+
console.log(`🔍 Auto-detected platforms: ${detected.join(', ')}`);
|
|
659
|
+
return detected;
|
|
660
|
+
}
|
|
661
|
+
|
|
662
|
+
detectBrowsers() {
|
|
663
|
+
const browsers = [];
|
|
664
|
+
const userAgent = process.env.USER_AGENT || '';
|
|
665
|
+
|
|
666
|
+
if (userAgent.includes('Chrome')) browsers.push('chrome');
|
|
667
|
+
if (userAgent.includes('Firefox')) browsers.push('firefox');
|
|
668
|
+
if (userAgent.includes('Safari')) browsers.push('safari');
|
|
669
|
+
if (userAgent.includes('Edge')) browsers.push('edge');
|
|
670
|
+
|
|
671
|
+
return browsers;
|
|
672
|
+
}
|
|
673
|
+
|
|
674
|
+
detectTerminal() {
|
|
675
|
+
const term = process.env.TERM_PROGRAM || process.env.TERMINAL_EMULATOR || '';
|
|
676
|
+
|
|
677
|
+
if (term.includes('bash')) return 'bash';
|
|
678
|
+
if (term.includes('zsh')) return 'zsh';
|
|
679
|
+
if (term.includes('fish')) return 'fish';
|
|
680
|
+
if (process.env.PSModulePath) return 'powershell';
|
|
681
|
+
if (process.platform === 'win32') return 'cmd';
|
|
682
|
+
|
|
683
|
+
return null;
|
|
684
|
+
}
|
|
685
|
+
|
|
686
|
+
detectDevelopmentEnvironment() {
|
|
687
|
+
if (process.env.VSCODE_PID) return 'vscode';
|
|
688
|
+
if (process.env.ATOM_HOME) return 'atom';
|
|
689
|
+
if (process.env.SUBLIME_TEXT) return 'sublime';
|
|
690
|
+
if (process.env.VIM) return 'vim';
|
|
691
|
+
if (process.env.EMACS) return 'emacs';
|
|
692
|
+
|
|
693
|
+
return null;
|
|
27
694
|
}
|
|
28
695
|
|
|
29
696
|
loadPlatformConfigs() {
|
package/src/index.js
CHANGED
|
@@ -9,11 +9,16 @@ export { Scheduler } from "./scheduler.js";
|
|
|
9
9
|
export { StickerCreator } from "./sticker-creator.js";
|
|
10
10
|
export { PluginManager } from "./plugin-manager-fixed.js";
|
|
11
11
|
export { EasyBot, createBot, createMultiBot, quickBot, bot, multiBot } from "./easy-bot.js";
|
|
12
|
-
export { generateQRCode } from "./qr.js";
|
|
12
|
+
export { generateQRCode, scheduleQRCleanup, resetQRStatus } from "./qr.js";
|
|
13
13
|
export { Message } from "./message.js";
|
|
14
14
|
export { ConsoleLogger, logger } from "./console-logger.js";
|
|
15
15
|
export { ErrorHandler, defaultErrorHandler } from "./error-handler.js";
|
|
16
16
|
|
|
17
|
+
// ===== ULTRA-ROBUSTE RECOVERY SYSTEME - NEU v2.0.0! =====
|
|
18
|
+
export { ConnectionRecovery } from "./connection-recovery.js";
|
|
19
|
+
export { AuthRecovery } from "./auth-recovery.js";
|
|
20
|
+
export { ResourceManager, globalResourceManager } from "./resource-manager.js";
|
|
21
|
+
|
|
17
22
|
// ===== ADVANCED FEATURES EXPORTS - NEU! =====
|
|
18
23
|
export {
|
|
19
24
|
AdvancedMessage,
|
|
File without changes
|