@absolutejs/beacon 0.6.14 → 0.6.15
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/dist/index.js +40 -8
- package/dist/index.js.map +3 -3
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -416,10 +416,26 @@ var shortUrl = (url) => {
|
|
|
416
416
|
return url.slice(0, SHORT_URL_MAX);
|
|
417
417
|
}
|
|
418
418
|
};
|
|
419
|
+
var BFCACHE_LOCATION_MAX = 240;
|
|
420
|
+
var bfcacheLocation = (value) => {
|
|
421
|
+
if (typeof value !== "string" || value === "")
|
|
422
|
+
return;
|
|
423
|
+
try {
|
|
424
|
+
const parsed = new URL(value, location.href);
|
|
425
|
+
if (parsed.protocol !== "http:" && parsed.protocol !== "https:") {
|
|
426
|
+
return;
|
|
427
|
+
}
|
|
428
|
+
return `${parsed.origin}${normalizeSignalIdentityPart(parsed.pathname)}`.slice(0, BFCACHE_LOCATION_MAX);
|
|
429
|
+
} catch {
|
|
430
|
+
return;
|
|
431
|
+
}
|
|
432
|
+
};
|
|
419
433
|
var UUID_PATH_SEGMENT = /\b[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}\b/giu;
|
|
420
434
|
var LONG_IDENTIFIER_SEGMENT = /\b(?:[0-9a-f]{16,}|\d{8,})\b/giu;
|
|
421
435
|
var VOLATILE_SIGNAL_TAGS = new Set([
|
|
422
436
|
"actionId",
|
|
437
|
+
"blockerLocations",
|
|
438
|
+
"blockerScope",
|
|
423
439
|
"closeCount",
|
|
424
440
|
"currentRelease",
|
|
425
441
|
"durationMs",
|
|
@@ -1437,24 +1453,40 @@ var createBeacon = (options) => {
|
|
|
1437
1453
|
const navigation = performance.getEntriesByType("navigation")[0];
|
|
1438
1454
|
if (navigation?.type === "back_forward" && navigation.notRestoredReasons != null) {
|
|
1439
1455
|
const reasons = new Set;
|
|
1440
|
-
const
|
|
1456
|
+
const blockers = [];
|
|
1457
|
+
const visit = (node, depth = 0) => {
|
|
1441
1458
|
if (node === null || typeof node !== "object")
|
|
1442
1459
|
return;
|
|
1443
1460
|
const detail = node;
|
|
1444
|
-
|
|
1445
|
-
|
|
1446
|
-
|
|
1461
|
+
const nodeReasons = (detail.reasons ?? []).map((reason) => reason.reason).filter((reason) => typeof reason === "string" && reason !== "masked").slice(0, 10);
|
|
1462
|
+
for (const reason of nodeReasons)
|
|
1463
|
+
reasons.add(reason);
|
|
1464
|
+
if (nodeReasons.length > 0 && blockers.length < 10) {
|
|
1465
|
+
const location2 = bfcacheLocation(detail.url ?? detail.src);
|
|
1466
|
+
blockers.push({
|
|
1467
|
+
depth,
|
|
1468
|
+
...location2 === undefined ? {} : { location: location2 },
|
|
1469
|
+
reasons: nodeReasons
|
|
1470
|
+
});
|
|
1447
1471
|
}
|
|
1448
1472
|
for (const child of detail.children ?? [])
|
|
1449
|
-
visit(child);
|
|
1473
|
+
visit(child, depth + 1);
|
|
1450
1474
|
};
|
|
1451
1475
|
visit(navigation.notRestoredReasons);
|
|
1452
|
-
const reasonList = [...reasons].
|
|
1476
|
+
const reasonList = [...reasons].slice(0, 10);
|
|
1453
1477
|
if (reasonList.length > 0) {
|
|
1478
|
+
const hasTopDocumentBlocker = blockers.some((blocker) => blocker.depth === 0);
|
|
1479
|
+
const hasChildFrameBlocker = blockers.some((blocker) => blocker.depth > 0);
|
|
1480
|
+
const blockerScope = hasTopDocumentBlocker && hasChildFrameBlocker ? "mixed" : hasChildFrameBlocker ? "child-frame" : "top-document";
|
|
1481
|
+
const blockerLocations = [
|
|
1482
|
+
...new Set(blockers.map((blocker) => blocker.location).filter((value) => value !== undefined))
|
|
1483
|
+
].slice(0, 10);
|
|
1454
1484
|
emitSignal(`Back-forward cache blocked — ${reasonList.join(", ")} — ${shortUrl(location.href)}`, {
|
|
1485
|
+
...blockerLocations.length === 0 ? {} : { blockerLocations: blockerLocations.join(",") },
|
|
1486
|
+
blockerScope,
|
|
1455
1487
|
reasons: reasonList.join(","),
|
|
1456
1488
|
signal: BEACON_SIGNAL.BFCACHE_BLOCKED
|
|
1457
|
-
});
|
|
1489
|
+
}, undefined, { bfcacheBlockers: blockers });
|
|
1458
1490
|
}
|
|
1459
1491
|
}
|
|
1460
1492
|
}
|
|
@@ -3755,5 +3787,5 @@ export {
|
|
|
3755
3787
|
BEACON_ATTRIBUTE
|
|
3756
3788
|
};
|
|
3757
3789
|
|
|
3758
|
-
//# debugId=
|
|
3790
|
+
//# debugId=DFFE57CC9874C7F464756E2164756E21
|
|
3759
3791
|
//# sourceMappingURL=index.js.map
|