@leofcoin/chain 1.7.107 â 1.7.108
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/exports/browser/chain.js +53 -19
- package/exports/chain.js +29 -14
- package/package.json +6 -6
package/exports/browser/chain.js
CHANGED
|
@@ -1390,6 +1390,10 @@ function requireIdentifiers () {
|
|
|
1390
1390
|
|
|
1391
1391
|
const numeric = /^[0-9]+$/;
|
|
1392
1392
|
const compareIdentifiers = (a, b) => {
|
|
1393
|
+
if (typeof a === 'number' && typeof b === 'number') {
|
|
1394
|
+
return a === b ? 0 : a < b ? -1 : 1
|
|
1395
|
+
}
|
|
1396
|
+
|
|
1393
1397
|
const anum = numeric.test(a);
|
|
1394
1398
|
const bnum = numeric.test(b);
|
|
1395
1399
|
|
|
@@ -1532,11 +1536,25 @@ function requireSemver$1 () {
|
|
|
1532
1536
|
other = new SemVer(other, this.options);
|
|
1533
1537
|
}
|
|
1534
1538
|
|
|
1535
|
-
|
|
1536
|
-
|
|
1537
|
-
|
|
1538
|
-
|
|
1539
|
-
|
|
1539
|
+
if (this.major < other.major) {
|
|
1540
|
+
return -1
|
|
1541
|
+
}
|
|
1542
|
+
if (this.major > other.major) {
|
|
1543
|
+
return 1
|
|
1544
|
+
}
|
|
1545
|
+
if (this.minor < other.minor) {
|
|
1546
|
+
return -1
|
|
1547
|
+
}
|
|
1548
|
+
if (this.minor > other.minor) {
|
|
1549
|
+
return 1
|
|
1550
|
+
}
|
|
1551
|
+
if (this.patch < other.patch) {
|
|
1552
|
+
return -1
|
|
1553
|
+
}
|
|
1554
|
+
if (this.patch > other.patch) {
|
|
1555
|
+
return 1
|
|
1556
|
+
}
|
|
1557
|
+
return 0
|
|
1540
1558
|
}
|
|
1541
1559
|
|
|
1542
1560
|
comparePre (other) {
|
|
@@ -2557,6 +2575,7 @@ function requireRange () {
|
|
|
2557
2575
|
// already replaced the hyphen ranges
|
|
2558
2576
|
// turn into a set of JUST comparators.
|
|
2559
2577
|
const parseComparator = (comp, options) => {
|
|
2578
|
+
comp = comp.replace(re[t.BUILD], '');
|
|
2560
2579
|
debug('comp', comp, options);
|
|
2561
2580
|
comp = replaceCarets(comp, options);
|
|
2562
2581
|
debug('caret', comp);
|
|
@@ -5317,6 +5336,7 @@ class ConnectionMonitor {
|
|
|
5317
5336
|
#reconnectDelay = 5000;
|
|
5318
5337
|
#healthCheckInterval = 60000;
|
|
5319
5338
|
#version;
|
|
5339
|
+
#lastHealthCheckAt = 0;
|
|
5320
5340
|
// event handlers to remove later
|
|
5321
5341
|
#onOnline = null;
|
|
5322
5342
|
#onVisibilityChange = null;
|
|
@@ -5347,13 +5367,13 @@ class ConnectionMonitor {
|
|
|
5347
5367
|
void this.#restoreNetwork();
|
|
5348
5368
|
};
|
|
5349
5369
|
window.addEventListener('online', this.#onOnline);
|
|
5350
|
-
|
|
5351
|
-
|
|
5352
|
-
|
|
5353
|
-
|
|
5354
|
-
|
|
5355
|
-
|
|
5356
|
-
|
|
5370
|
+
this.#onVisibilityChange = () => {
|
|
5371
|
+
if (document.visibilityState === 'visible') {
|
|
5372
|
+
console.log('đĄ Visibility regained â attempting restore');
|
|
5373
|
+
void this.#restoreNetwork();
|
|
5374
|
+
}
|
|
5375
|
+
};
|
|
5376
|
+
document.addEventListener('visibilitychange', this.#onVisibilityChange);
|
|
5357
5377
|
}
|
|
5358
5378
|
if (typeof process !== 'undefined' && typeof process.on === 'function') {
|
|
5359
5379
|
this.#onSigcont = () => {
|
|
@@ -5367,6 +5387,8 @@ class ConnectionMonitor {
|
|
|
5367
5387
|
// ignore if not supported
|
|
5368
5388
|
}
|
|
5369
5389
|
}
|
|
5390
|
+
// prime last check timestamp and start periodic checks
|
|
5391
|
+
this.#lastHealthCheckAt = Date.now();
|
|
5370
5392
|
this.#checkInterval = setInterval(() => {
|
|
5371
5393
|
this.#healthCheck();
|
|
5372
5394
|
}, this.#healthCheckInterval);
|
|
@@ -5402,16 +5424,28 @@ class ConnectionMonitor {
|
|
|
5402
5424
|
console.log('âšī¸ Connection monitor stopped');
|
|
5403
5425
|
}
|
|
5404
5426
|
async #healthCheck() {
|
|
5427
|
+
const now = Date.now();
|
|
5428
|
+
const expectedNext = this.#lastHealthCheckAt + this.#healthCheckInterval;
|
|
5429
|
+
const drift = now - expectedNext;
|
|
5430
|
+
this.#lastHealthCheckAt = now;
|
|
5431
|
+
// Detect large timer drift (common after sleep) and proactively attempt restore
|
|
5432
|
+
if (drift > 5000) {
|
|
5433
|
+
console.log(`â° Detected timer drift of ${drift}ms (likely system sleep) â attempting restore`);
|
|
5434
|
+
// Fire and forget; normal reconnection/backoff still applies below
|
|
5435
|
+
void this.#restoreNetwork();
|
|
5436
|
+
}
|
|
5405
5437
|
const connectedPeers = this.connectedPeers;
|
|
5406
5438
|
const compatiblePeers = this.compatiblePeers;
|
|
5407
5439
|
console.log(`đ Health check: ${connectedPeers.length} connected, ${compatiblePeers.length} compatible`);
|
|
5408
|
-
//
|
|
5409
|
-
|
|
5410
|
-
|
|
5411
|
-
|
|
5412
|
-
|
|
5413
|
-
|
|
5414
|
-
|
|
5440
|
+
// If we have no connections or none are compatible, try to reconnect
|
|
5441
|
+
if (connectedPeers.length === 0) {
|
|
5442
|
+
console.warn('â ī¸ No peer connections detected â attempting reconnection');
|
|
5443
|
+
await this.#attemptReconnection();
|
|
5444
|
+
}
|
|
5445
|
+
else if (compatiblePeers.length === 0) {
|
|
5446
|
+
console.warn('â ī¸ No compatible peers found â attempting reconnection');
|
|
5447
|
+
await this.#attemptReconnection();
|
|
5448
|
+
}
|
|
5415
5449
|
// Publish connection status
|
|
5416
5450
|
globalThis.pubsub?.publish('connection-status', {
|
|
5417
5451
|
connected: connectedPeers.length,
|
package/exports/chain.js
CHANGED
|
@@ -1463,6 +1463,7 @@ class ConnectionMonitor {
|
|
|
1463
1463
|
#reconnectDelay = 5000;
|
|
1464
1464
|
#healthCheckInterval = 60000;
|
|
1465
1465
|
#version;
|
|
1466
|
+
#lastHealthCheckAt = 0;
|
|
1466
1467
|
// event handlers to remove later
|
|
1467
1468
|
#onOnline = null;
|
|
1468
1469
|
#onVisibilityChange = null;
|
|
@@ -1493,13 +1494,13 @@ class ConnectionMonitor {
|
|
|
1493
1494
|
void this.#restoreNetwork();
|
|
1494
1495
|
};
|
|
1495
1496
|
window.addEventListener('online', this.#onOnline);
|
|
1496
|
-
|
|
1497
|
-
|
|
1498
|
-
|
|
1499
|
-
|
|
1500
|
-
|
|
1501
|
-
|
|
1502
|
-
|
|
1497
|
+
this.#onVisibilityChange = () => {
|
|
1498
|
+
if (document.visibilityState === 'visible') {
|
|
1499
|
+
console.log('đĄ Visibility regained â attempting restore');
|
|
1500
|
+
void this.#restoreNetwork();
|
|
1501
|
+
}
|
|
1502
|
+
};
|
|
1503
|
+
document.addEventListener('visibilitychange', this.#onVisibilityChange);
|
|
1503
1504
|
}
|
|
1504
1505
|
if (typeof process !== 'undefined' && typeof process.on === 'function') {
|
|
1505
1506
|
this.#onSigcont = () => {
|
|
@@ -1513,6 +1514,8 @@ class ConnectionMonitor {
|
|
|
1513
1514
|
// ignore if not supported
|
|
1514
1515
|
}
|
|
1515
1516
|
}
|
|
1517
|
+
// prime last check timestamp and start periodic checks
|
|
1518
|
+
this.#lastHealthCheckAt = Date.now();
|
|
1516
1519
|
this.#checkInterval = setInterval(() => {
|
|
1517
1520
|
this.#healthCheck();
|
|
1518
1521
|
}, this.#healthCheckInterval);
|
|
@@ -1548,16 +1551,28 @@ class ConnectionMonitor {
|
|
|
1548
1551
|
console.log('âšī¸ Connection monitor stopped');
|
|
1549
1552
|
}
|
|
1550
1553
|
async #healthCheck() {
|
|
1554
|
+
const now = Date.now();
|
|
1555
|
+
const expectedNext = this.#lastHealthCheckAt + this.#healthCheckInterval;
|
|
1556
|
+
const drift = now - expectedNext;
|
|
1557
|
+
this.#lastHealthCheckAt = now;
|
|
1558
|
+
// Detect large timer drift (common after sleep) and proactively attempt restore
|
|
1559
|
+
if (drift > 5000) {
|
|
1560
|
+
console.log(`â° Detected timer drift of ${drift}ms (likely system sleep) â attempting restore`);
|
|
1561
|
+
// Fire and forget; normal reconnection/backoff still applies below
|
|
1562
|
+
void this.#restoreNetwork();
|
|
1563
|
+
}
|
|
1551
1564
|
const connectedPeers = this.connectedPeers;
|
|
1552
1565
|
const compatiblePeers = this.compatiblePeers;
|
|
1553
1566
|
console.log(`đ Health check: ${connectedPeers.length} connected, ${compatiblePeers.length} compatible`);
|
|
1554
|
-
//
|
|
1555
|
-
|
|
1556
|
-
|
|
1557
|
-
|
|
1558
|
-
|
|
1559
|
-
|
|
1560
|
-
|
|
1567
|
+
// If we have no connections or none are compatible, try to reconnect
|
|
1568
|
+
if (connectedPeers.length === 0) {
|
|
1569
|
+
console.warn('â ī¸ No peer connections detected â attempting reconnection');
|
|
1570
|
+
await this.#attemptReconnection();
|
|
1571
|
+
}
|
|
1572
|
+
else if (compatiblePeers.length === 0) {
|
|
1573
|
+
console.warn('â ī¸ No compatible peers found â attempting reconnection');
|
|
1574
|
+
await this.#attemptReconnection();
|
|
1575
|
+
}
|
|
1561
1576
|
// Publish connection status
|
|
1562
1577
|
globalThis.pubsub?.publish('connection-status', {
|
|
1563
1578
|
connected: connectedPeers.length,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@leofcoin/chain",
|
|
3
|
-
"version": "1.7.
|
|
3
|
+
"version": "1.7.108",
|
|
4
4
|
"description": "Official javascript implementation",
|
|
5
5
|
"private": false,
|
|
6
6
|
"exports": {
|
|
@@ -49,13 +49,13 @@
|
|
|
49
49
|
"author": "",
|
|
50
50
|
"license": "MIT",
|
|
51
51
|
"devDependencies": {
|
|
52
|
-
"@rollup/plugin-commonjs": "^28.0.
|
|
52
|
+
"@rollup/plugin-commonjs": "^28.0.8",
|
|
53
53
|
"@rollup/plugin-json": "^6.1.0",
|
|
54
|
-
"@rollup/plugin-node-resolve": "^16.0.
|
|
54
|
+
"@rollup/plugin-node-resolve": "^16.0.3",
|
|
55
55
|
"@rollup/plugin-typescript": "^12.1.4",
|
|
56
|
-
"@types/semver": "^7.7.
|
|
56
|
+
"@types/semver": "^7.7.1",
|
|
57
57
|
"@vandeurenglenn/debug": "^1.2.6",
|
|
58
|
-
"rollup": "^4.
|
|
58
|
+
"rollup": "^4.52.4",
|
|
59
59
|
"rollup-plugin-modify": "^3.0.0",
|
|
60
60
|
"tape": "^5.9.0",
|
|
61
61
|
"tslib": "^2.8.1"
|
|
@@ -75,6 +75,6 @@
|
|
|
75
75
|
"@leofcoin/workers": "^1.5.27",
|
|
76
76
|
"@vandeurenglenn/base58": "^1.1.9",
|
|
77
77
|
"@vandeurenglenn/easy-worker": "^1.0.2",
|
|
78
|
-
"semver": "^7.7.
|
|
78
|
+
"semver": "^7.7.3"
|
|
79
79
|
}
|
|
80
80
|
}
|