cloudflare-next-intl 0.9.59 → 0.9.60

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,24 @@ 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 = 'html{background:#ffffff !important}body>*:not(#' + overlayId + '){visibility:hidden !important}';
59
+ (document.head || document.documentElement).appendChild(st);
60
+ }
48
61
  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
62
  if (!document.body) {
54
63
  document.addEventListener('DOMContentLoaded', function() {
55
64
  if (overlayWanted) showOverlay();
@@ -153,6 +162,12 @@ export default function HelperScript() {
153
162
  var sameOrigin = false;
154
163
  try { sameOrigin = new URL(src, window.location.href).origin === window.location.origin; } catch (err2) { return; }
155
164
  if (!sameOrigin) return;
165
+ // Cloudflare serves its bot-challenge scripts from the
166
+ // site's own origin, so they pass the same-origin test
167
+ // while having nothing to do with the build. Probing
168
+ // one never yields JavaScript and a failed challenge
169
+ // cannot break the module graph.
170
+ try { if (new URL(src, window.location.href).pathname.indexOf('/cdn-cgi/') === 0) return; } catch (err3) { return; }
156
171
  if (!probeUrl) probeUrl = src;
157
172
  recover('chunk resource failed to load: ' + src, 'resource-error');
158
173
  } catch (err) {}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cloudflare-next-intl",
3
- "version": "0.9.59",
3
+ "version": "0.9.60",
4
4
  "description": "Optimized Next Intl Package Special for App Router and Cloudflare",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",