cloudflare-next-intl 0.9.59 → 0.9.61
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.
|
@@ -41,15 +41,34 @@ export default function HelperScript() {
|
|
|
41
41
|
// against the tree and every removeChild/insertBefore throws,
|
|
42
42
|
// which crashes it into the very error UI this is hiding.
|
|
43
43
|
var overlayId = 'cfni-stale-deploy-overlay';
|
|
44
|
+
var overlayStyleId = 'cfni-stale-deploy-style';
|
|
44
45
|
var overlayWanted = false;
|
|
45
46
|
function showOverlay() {
|
|
46
47
|
overlayWanted = true;
|
|
47
48
|
try {
|
|
49
|
+
// A chunk can fail while the parser is still inside
|
|
50
|
+
// <head>, before <body> or the error UI exist. A style
|
|
51
|
+
// rule can be installed right then and applies to
|
|
52
|
+
// whatever the parser produces next, so the error UI
|
|
53
|
+
// never gets a frame; the spinner is appended once
|
|
54
|
+
// there is a <body> to hold it.
|
|
55
|
+
if (!document.getElementById(overlayStyleId)) {
|
|
56
|
+
var st = document.createElement('style');
|
|
57
|
+
st.id = overlayStyleId;
|
|
58
|
+
st.textContent = [
|
|
59
|
+
'html,body{background:#ffffff !important}',
|
|
60
|
+
'body>*:not(#' + overlayId + '){visibility:hidden !important}',
|
|
61
|
+
// Until <body> exists there is nowhere to put
|
|
62
|
+
// the spinner element, and a blank screen reads
|
|
63
|
+
// as a hang. A pseudo-element needs no host, so
|
|
64
|
+
// it covers that gap and steps aside as soon as
|
|
65
|
+
// the real overlay is in the document.
|
|
66
|
+
'html:not(:has(#' + overlayId + '))::after{content:"";position:fixed;top:50%;left:50%;width:2.25rem;height:2.25rem;margin:-1.125rem 0 0 -1.125rem;border:0.1875rem solid #e5e7eb;border-top-color:#17181b;border-radius:50%;animation:cfni-spin 0.8s linear infinite;z-index:2147483647}',
|
|
67
|
+
'@keyframes cfni-spin{to{transform:rotate(360deg)}}'
|
|
68
|
+
].join('');
|
|
69
|
+
(document.head || document.documentElement).appendChild(st);
|
|
70
|
+
}
|
|
48
71
|
if (document.getElementById(overlayId)) return;
|
|
49
|
-
// This script runs from <head>, and a chunk can fail
|
|
50
|
-
// before the parser has opened <body>. An element
|
|
51
|
-
// appended to <html> at that point is discarded, so the
|
|
52
|
-
// error UI would paint uncovered until the reload.
|
|
53
72
|
if (!document.body) {
|
|
54
73
|
document.addEventListener('DOMContentLoaded', function() {
|
|
55
74
|
if (overlayWanted) showOverlay();
|
|
@@ -153,6 +172,12 @@ export default function HelperScript() {
|
|
|
153
172
|
var sameOrigin = false;
|
|
154
173
|
try { sameOrigin = new URL(src, window.location.href).origin === window.location.origin; } catch (err2) { return; }
|
|
155
174
|
if (!sameOrigin) return;
|
|
175
|
+
// Cloudflare serves its bot-challenge scripts from the
|
|
176
|
+
// site's own origin, so they pass the same-origin test
|
|
177
|
+
// while having nothing to do with the build. Probing
|
|
178
|
+
// one never yields JavaScript and a failed challenge
|
|
179
|
+
// cannot break the module graph.
|
|
180
|
+
try { if (new URL(src, window.location.href).pathname.indexOf('/cdn-cgi/') === 0) return; } catch (err3) { return; }
|
|
156
181
|
if (!probeUrl) probeUrl = src;
|
|
157
182
|
recover('chunk resource failed to load: ' + src, 'resource-error');
|
|
158
183
|
} catch (err) {}
|