remote-components 0.0.46 → 0.0.47
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/html/host.cjs +50 -7
- package/dist/html/host.cjs.map +1 -1
- package/dist/html/host.js +50 -7
- package/dist/html/host.js.map +1 -1
- package/dist/html/remote.cjs.map +1 -1
- package/dist/html/remote.js.map +1 -1
- package/dist/internal/next/host/app-router-client.cjs +6 -6
- package/dist/internal/next/host/app-router-client.cjs.map +1 -1
- package/dist/internal/next/host/app-router-client.js +1 -1
- package/dist/internal/next/host/app-router-client.js.map +1 -1
- package/dist/internal/next/host/app-router-compat.cjs +5 -5
- package/dist/internal/next/host/app-router-compat.cjs.map +1 -1
- package/dist/internal/next/host/app-router-compat.js +1 -1
- package/dist/internal/next/host/app-router-compat.js.map +1 -1
- package/dist/internal/shared/client/polyfill.cjs +2 -2
- package/dist/internal/shared/client/polyfill.cjs.map +1 -1
- package/dist/internal/shared/client/polyfill.js +1 -1
- package/dist/internal/shared/client/polyfill.js.map +1 -1
- package/dist/internal/shared/client/remote-component.cjs +32 -1
- package/dist/internal/shared/client/remote-component.cjs.map +1 -1
- package/dist/internal/shared/client/remote-component.js +32 -1
- package/dist/internal/shared/client/remote-component.js.map +1 -1
- package/dist/internal/shared/ssr/fetch-remote-component.cjs +1 -6
- package/dist/internal/shared/ssr/fetch-remote-component.cjs.map +1 -1
- package/dist/internal/shared/ssr/fetch-remote-component.js +1 -6
- package/dist/internal/shared/ssr/fetch-remote-component.js.map +1 -1
- package/dist/internal/shared/ssr/fetch-with-hooks.cjs +9 -2
- package/dist/internal/shared/ssr/fetch-with-hooks.cjs.map +1 -1
- package/dist/internal/shared/ssr/fetch-with-hooks.d.ts +6 -1
- package/dist/internal/shared/ssr/fetch-with-hooks.js +9 -2
- package/dist/internal/shared/ssr/fetch-with-hooks.js.map +1 -1
- package/dist/internal/shared/ssr/fetch-with-protected-rc-fallback.cjs +57 -0
- package/dist/internal/shared/ssr/fetch-with-protected-rc-fallback.cjs.map +1 -0
- package/dist/internal/shared/ssr/fetch-with-protected-rc-fallback.d.ts +11 -0
- package/dist/internal/shared/ssr/fetch-with-protected-rc-fallback.js +32 -0
- package/dist/internal/shared/ssr/fetch-with-protected-rc-fallback.js.map +1 -0
- package/dist/internal/shared/{logger.cjs → utils/logger.cjs} +5 -0
- package/dist/internal/shared/utils/logger.cjs.map +1 -0
- package/dist/internal/shared/{logger.d.ts → utils/logger.d.ts} +3 -2
- package/dist/internal/shared/{logger.js → utils/logger.js} +4 -0
- package/dist/internal/shared/utils/logger.js.map +1 -0
- package/dist/internal/shared/utils.cjs +2 -9
- package/dist/internal/shared/utils.cjs.map +1 -1
- package/dist/internal/shared/utils.d.ts +0 -2
- package/dist/internal/shared/utils.js +1 -5
- package/dist/internal/shared/utils.js.map +1 -1
- package/dist/next/config.cjs.map +1 -1
- package/dist/next/config.js.map +1 -1
- package/dist/next/host/client/index.cjs +51 -17
- package/dist/next/host/client/index.cjs.map +1 -1
- package/dist/next/host/client/index.js +51 -17
- package/dist/next/host/client/index.js.map +1 -1
- package/dist/next/proxy.cjs +128 -19
- package/dist/next/proxy.cjs.map +1 -1
- package/dist/next/proxy.d.ts +34 -6
- package/dist/next/proxy.js +125 -18
- package/dist/next/proxy.js.map +1 -1
- package/dist/react/index.cjs +51 -17
- package/dist/react/index.cjs.map +1 -1
- package/dist/react/index.js +51 -17
- package/dist/react/index.js.map +1 -1
- package/dist/shared/host/proxy.cjs +79 -0
- package/dist/shared/host/proxy.cjs.map +1 -0
- package/dist/shared/host/proxy.d.ts +29 -0
- package/dist/shared/host/proxy.js +54 -0
- package/dist/shared/host/proxy.js.map +1 -0
- package/dist/shared/remote/proxy.cjs +71 -0
- package/dist/shared/remote/proxy.cjs.map +1 -0
- package/dist/shared/remote/proxy.d.ts +38 -0
- package/dist/shared/remote/proxy.js +45 -0
- package/dist/shared/remote/proxy.js.map +1 -0
- package/package.json +10 -1
- package/dist/internal/shared/logger.cjs.map +0 -1
- package/dist/internal/shared/logger.js.map +0 -1
package/dist/react/index.js
CHANGED
|
@@ -95,6 +95,9 @@ function logDebug(location2, message) {
|
|
|
95
95
|
console.debug(`[${PREFIX}:${location2}]: ${message}`);
|
|
96
96
|
}
|
|
97
97
|
}
|
|
98
|
+
function logInfo(location2, message) {
|
|
99
|
+
console.info(`[${PREFIX}:${location2}]: ${message}`);
|
|
100
|
+
}
|
|
98
101
|
function logWarn(location2, message) {
|
|
99
102
|
console.warn(`[${PREFIX}:${location2}]: ${message}`);
|
|
100
103
|
}
|
|
@@ -106,18 +109,6 @@ function logError(location2, message, cause) {
|
|
|
106
109
|
);
|
|
107
110
|
}
|
|
108
111
|
|
|
109
|
-
// src/shared/utils/index.ts
|
|
110
|
-
function escapeString(str) {
|
|
111
|
-
return str.replace(/[^a-z0-9]/g, "_");
|
|
112
|
-
}
|
|
113
|
-
var attrToProp = {
|
|
114
|
-
fetchpriority: "fetchPriority",
|
|
115
|
-
crossorigin: "crossOrigin",
|
|
116
|
-
imagesrcset: "imageSrcSet",
|
|
117
|
-
imagesizes: "imageSizes",
|
|
118
|
-
srcset: "srcSet"
|
|
119
|
-
};
|
|
120
|
-
|
|
121
112
|
// src/shared/client/polyfill.tsx
|
|
122
113
|
import { jsx } from "react/jsx-runtime";
|
|
123
114
|
function applyBundleUrlToSrc(bundle, src) {
|
|
@@ -589,6 +580,46 @@ async function loadScripts(scripts) {
|
|
|
589
580
|
);
|
|
590
581
|
}
|
|
591
582
|
|
|
583
|
+
// src/shared/ssr/fetch-with-protected-rc-fallback.ts
|
|
584
|
+
var RC_PROTECTED_REMOTE_FETCH_PATHNAME = "/rc-fetch-protected-remote";
|
|
585
|
+
async function fetchWithProtectedRcFallback(url, init) {
|
|
586
|
+
try {
|
|
587
|
+
const res = await fetch(url, init);
|
|
588
|
+
return res;
|
|
589
|
+
} catch (error) {
|
|
590
|
+
if (typeof document === "object" && typeof document.location === "object" && document.location.origin !== new URL(url).origin) {
|
|
591
|
+
logInfo(
|
|
592
|
+
"FetchRemoteComponent",
|
|
593
|
+
"Request failed due to CORS, attempting to fetch it via the withRemoteComponentsHost proxy."
|
|
594
|
+
);
|
|
595
|
+
const proxiedRes = await fetch(
|
|
596
|
+
`${RC_PROTECTED_REMOTE_FETCH_PATHNAME}?url=${url}`
|
|
597
|
+
);
|
|
598
|
+
if (proxiedRes.status === 200) {
|
|
599
|
+
return proxiedRes;
|
|
600
|
+
} else {
|
|
601
|
+
logError(
|
|
602
|
+
"FetchRemoteComponent",
|
|
603
|
+
`Could not proxy remote: [response status ${proxiedRes.status}] ${await proxiedRes.text()}`
|
|
604
|
+
);
|
|
605
|
+
}
|
|
606
|
+
}
|
|
607
|
+
throw error;
|
|
608
|
+
}
|
|
609
|
+
}
|
|
610
|
+
|
|
611
|
+
// src/shared/utils/index.ts
|
|
612
|
+
function escapeString(str) {
|
|
613
|
+
return str.replace(/[^a-z0-9]/g, "_");
|
|
614
|
+
}
|
|
615
|
+
var attrToProp = {
|
|
616
|
+
fetchpriority: "fetchPriority",
|
|
617
|
+
crossorigin: "crossOrigin",
|
|
618
|
+
imagesrcset: "imageSrcSet",
|
|
619
|
+
imagesizes: "imageSizes",
|
|
620
|
+
srcset: "srcSet"
|
|
621
|
+
};
|
|
622
|
+
|
|
592
623
|
// src/shared/client/const.ts
|
|
593
624
|
var DEFAULT_ROUTE = "/";
|
|
594
625
|
var RUNTIME_WEBPACK = "webpack";
|
|
@@ -642,7 +673,7 @@ function createChunkLoader(runtime) {
|
|
|
642
673
|
}
|
|
643
674
|
logDebug("ChunkLoader", `Fetching chunk from: "${url}"`);
|
|
644
675
|
self.__remote_components_turbopack_chunk_loader_promise__[url] = new Promise((resolve, reject) => {
|
|
645
|
-
|
|
676
|
+
fetchWithProtectedRcFallback(url).then((res) => res.text()).then((code) => {
|
|
646
677
|
const hasTurbopack = code.includes("globalThis.TURBOPACK") || code.includes("self.TURBOPACK");
|
|
647
678
|
if (hasTurbopack) {
|
|
648
679
|
return handleTurbopackChunk(code, bundle ?? "", url);
|
|
@@ -1540,11 +1571,16 @@ function remoteFetchHeaders() {
|
|
|
1540
1571
|
}
|
|
1541
1572
|
|
|
1542
1573
|
// src/shared/ssr/fetch-with-hooks.ts
|
|
1543
|
-
async function fetchWithHooks(url,
|
|
1574
|
+
async function fetchWithHooks(url, additionalInit, options = {}) {
|
|
1544
1575
|
const { onRequest, onResponse } = options;
|
|
1576
|
+
const init = {
|
|
1577
|
+
method: "GET",
|
|
1578
|
+
headers: remoteFetchHeaders(),
|
|
1579
|
+
...additionalInit
|
|
1580
|
+
};
|
|
1545
1581
|
let res = await onRequest?.(url, init);
|
|
1546
1582
|
if (!res) {
|
|
1547
|
-
res = await
|
|
1583
|
+
res = await fetchWithProtectedRcFallback(url, init);
|
|
1548
1584
|
}
|
|
1549
1585
|
const transformedRes = await onResponse?.(url, res);
|
|
1550
1586
|
if (transformedRes) {
|
|
@@ -1753,8 +1789,6 @@ function RemoteComponent({
|
|
|
1753
1789
|
);
|
|
1754
1790
|
if (!html && src) {
|
|
1755
1791
|
const fetchInit = {
|
|
1756
|
-
method: "GET",
|
|
1757
|
-
headers: remoteFetchHeaders(),
|
|
1758
1792
|
credentials
|
|
1759
1793
|
};
|
|
1760
1794
|
const res = await fetchWithHooks(url, fetchInit, {
|