remote-components 0.0.43 → 0.0.45
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/README.md +1 -1
- package/dist/{component-loader-2ca91ad8.d.ts → component-loader-26b1f55e.d.ts} +63 -1
- package/dist/html/host.cjs +25 -19
- package/dist/html/host.cjs.map +1 -1
- package/dist/html/host.js +25 -19
- package/dist/html/host.js.map +1 -1
- package/dist/internal/next/host/app-router-client.d.ts +4 -3
- package/dist/internal/next/remote/render-client.cjs +1 -1
- package/dist/internal/next/remote/render-client.cjs.map +1 -1
- package/dist/internal/next/remote/render-client.js +1 -1
- package/dist/internal/next/remote/render-client.js.map +1 -1
- package/dist/internal/shared/client/remote-component.d.ts +2 -2
- package/dist/internal/shared/ssr/dom-flight.cjs.map +1 -1
- package/dist/internal/shared/ssr/dom-flight.d.ts +2 -39
- package/dist/internal/shared/ssr/dom-flight.js.map +1 -1
- package/dist/internal/shared/ssr/fetch-headers.cjs +4 -6
- package/dist/internal/shared/ssr/fetch-headers.cjs.map +1 -1
- package/dist/internal/shared/ssr/fetch-headers.d.ts +1 -1
- package/dist/internal/shared/ssr/fetch-headers.js +4 -6
- package/dist/internal/shared/ssr/fetch-headers.js.map +1 -1
- package/dist/internal/shared/ssr/fetch-remote-component.cjs +58 -24
- package/dist/internal/shared/ssr/fetch-remote-component.cjs.map +1 -1
- package/dist/internal/shared/ssr/fetch-remote-component.d.ts +9 -37
- package/dist/internal/shared/ssr/fetch-remote-component.js +60 -22
- package/dist/internal/shared/ssr/fetch-remote-component.js.map +1 -1
- package/dist/internal/shared/ssr/fetch-with-hooks.cjs +40 -0
- package/dist/internal/shared/ssr/fetch-with-hooks.cjs.map +1 -0
- package/dist/internal/shared/ssr/fetch-with-hooks.d.ts +40 -0
- package/dist/internal/shared/ssr/fetch-with-hooks.js +16 -0
- package/dist/internal/shared/ssr/fetch-with-hooks.js.map +1 -0
- package/dist/internal/shared/ssr/get-ssr-relative-path-base-url.cjs +6 -0
- package/dist/internal/shared/ssr/get-ssr-relative-path-base-url.cjs.map +1 -1
- package/dist/internal/shared/ssr/get-ssr-relative-path-base-url.d.ts +3 -0
- package/dist/internal/shared/ssr/get-ssr-relative-path-base-url.js +6 -0
- package/dist/internal/shared/ssr/get-ssr-relative-path-base-url.js.map +1 -1
- package/dist/internal/shared/ssr/skeleton.cjs +97 -0
- package/dist/internal/shared/ssr/skeleton.cjs.map +1 -0
- package/dist/internal/shared/ssr/skeleton.d.ts +17 -0
- package/dist/internal/shared/ssr/skeleton.js +72 -0
- package/dist/internal/shared/ssr/skeleton.js.map +1 -0
- package/dist/internal/webpack/next-client-pages-loader.d.ts +3 -3
- package/dist/next/config.cjs +1 -9
- package/dist/next/config.cjs.map +1 -1
- package/dist/next/config.js +1 -9
- package/dist/next/config.js.map +1 -1
- package/dist/next/host/app-router-server.cjs +8 -8
- package/dist/next/host/app-router-server.cjs.map +1 -1
- package/dist/next/host/app-router-server.d.ts +14 -4
- package/dist/next/host/app-router-server.js +8 -8
- package/dist/next/host/app-router-server.js.map +1 -1
- package/dist/next/host/client/index.cjs +29 -12
- package/dist/next/host/client/index.cjs.map +1 -1
- package/dist/next/host/client/index.d.ts +1 -1
- package/dist/next/host/client/index.js +29 -12
- package/dist/next/host/client/index.js.map +1 -1
- package/dist/next/host/pages-router-client.cjs +62 -2
- package/dist/next/host/pages-router-client.cjs.map +1 -1
- package/dist/next/host/pages-router-client.d.ts +27 -1
- package/dist/next/host/pages-router-client.js +63 -3
- package/dist/next/host/pages-router-client.js.map +1 -1
- package/dist/next/host/pages-router-server.cjs +18 -22
- package/dist/next/host/pages-router-server.cjs.map +1 -1
- package/dist/next/host/pages-router-server.d.ts +37 -3
- package/dist/next/host/pages-router-server.js +18 -22
- package/dist/next/host/pages-router-server.js.map +1 -1
- package/dist/next/index.cjs.map +1 -1
- package/dist/next/index.d.ts +2 -1
- package/dist/next/index.js.map +1 -1
- package/dist/react/index.cjs +29 -12
- package/dist/react/index.cjs.map +1 -1
- package/dist/react/index.d.ts +13 -5
- package/dist/react/index.js +29 -12
- package/dist/react/index.js.map +1 -1
- package/dist/shared/host/app.cjs +1 -1
- package/dist/shared/host/app.cjs.map +1 -1
- package/dist/shared/host/app.js +1 -1
- package/dist/shared/host/app.js.map +1 -1
- package/dist/shared/host/pages.cjs +1 -1
- package/dist/shared/host/pages.cjs.map +1 -1
- package/dist/shared/host/pages.js +1 -1
- package/dist/shared/host/pages.js.map +1 -1
- package/dist/shared/remote/app.cjs +1 -1
- package/dist/shared/remote/app.cjs.map +1 -1
- package/dist/shared/remote/app.js +1 -1
- package/dist/shared/remote/app.js.map +1 -1
- package/dist/shared/remote/pages.cjs +1 -1
- package/dist/shared/remote/pages.cjs.map +1 -1
- package/dist/shared/remote/pages.js +1 -1
- package/dist/shared/remote/pages.js.map +1 -1
- package/dist/types-6e4ba234.d.ts +136 -0
- package/package.json +54 -32
- package/dist/types-cbf6c34f.d.ts +0 -9
|
@@ -1453,23 +1453,35 @@ async function loadStaticRemoteComponent(scripts, url) {
|
|
|
1453
1453
|
}
|
|
1454
1454
|
|
|
1455
1455
|
// src/shared/ssr/fetch-headers.ts
|
|
1456
|
-
function remoteFetchHeaders(
|
|
1456
|
+
function remoteFetchHeaders() {
|
|
1457
1457
|
return {
|
|
1458
1458
|
/**
|
|
1459
1459
|
* Authenticates deployment protection for the remote. Needed for SSR and SSG clients.
|
|
1460
|
-
*
|
|
1461
|
-
*
|
|
1460
|
+
* If the remote component uses vercel deployment protection, ensure the host and remote vercel
|
|
1461
|
+
* projects share a common automation bypass secret, and the shared secret is used as the
|
|
1462
|
+
* VERCEL_AUTOMATION_BYPASS_SECRET env var in the host project.
|
|
1462
1463
|
*/
|
|
1463
1464
|
...typeof process === "object" && typeof process.env === "object" && typeof process.env.VERCEL_AUTOMATION_BYPASS_SECRET === "string" ? {
|
|
1464
1465
|
"x-vercel-protection-bypass": process.env.VERCEL_AUTOMATION_BYPASS_SECRET
|
|
1465
1466
|
} : {},
|
|
1466
|
-
...Object.fromEntries(
|
|
1467
|
-
additionalHeaders instanceof Headers ? additionalHeaders.entries() : Object.entries(additionalHeaders ?? {})
|
|
1468
|
-
),
|
|
1469
1467
|
Accept: "text/html"
|
|
1470
1468
|
};
|
|
1471
1469
|
}
|
|
1472
1470
|
|
|
1471
|
+
// src/shared/ssr/fetch-with-hooks.ts
|
|
1472
|
+
async function fetchWithHooks(url, init, options = {}) {
|
|
1473
|
+
const { onRequest, onResponse } = options;
|
|
1474
|
+
let res = await onRequest?.(url, init);
|
|
1475
|
+
if (!res) {
|
|
1476
|
+
res = await fetch(url, init);
|
|
1477
|
+
}
|
|
1478
|
+
const transformedRes = await onResponse?.(url, res);
|
|
1479
|
+
if (transformedRes) {
|
|
1480
|
+
res = transformedRes;
|
|
1481
|
+
}
|
|
1482
|
+
return res;
|
|
1483
|
+
}
|
|
1484
|
+
|
|
1473
1485
|
// src/shared/ssr/get-client-or-server-url.ts
|
|
1474
1486
|
function getClientOrServerUrl(src, serverFallback) {
|
|
1475
1487
|
const fallback = typeof location !== "undefined" ? location.href : serverFallback;
|
|
@@ -1564,12 +1576,13 @@ function RemoteComponent({
|
|
|
1564
1576
|
credentials = "same-origin",
|
|
1565
1577
|
name: nameProp = "__vercel_remote_component",
|
|
1566
1578
|
shared = {},
|
|
1567
|
-
additionalHeaders,
|
|
1568
1579
|
children,
|
|
1569
1580
|
onBeforeLoad,
|
|
1570
1581
|
onLoad,
|
|
1571
1582
|
onError,
|
|
1572
|
-
onChange
|
|
1583
|
+
onChange,
|
|
1584
|
+
onRequest,
|
|
1585
|
+
onResponse
|
|
1573
1586
|
}) {
|
|
1574
1587
|
const instanceId = (0, import_react2.useId)();
|
|
1575
1588
|
const name = (0, import_react2.useMemo)(() => {
|
|
@@ -1673,10 +1686,13 @@ function RemoteComponent({
|
|
|
1673
1686
|
if (!html && src) {
|
|
1674
1687
|
const fetchInit = {
|
|
1675
1688
|
method: "GET",
|
|
1676
|
-
headers: remoteFetchHeaders(
|
|
1689
|
+
headers: remoteFetchHeaders(),
|
|
1677
1690
|
credentials
|
|
1678
1691
|
};
|
|
1679
|
-
const res = await
|
|
1692
|
+
const res = await fetchWithHooks(url, fetchInit, {
|
|
1693
|
+
onRequest,
|
|
1694
|
+
onResponse
|
|
1695
|
+
});
|
|
1680
1696
|
if (!res.ok) {
|
|
1681
1697
|
let error = failedToFetchRemoteComponentError(
|
|
1682
1698
|
url.href,
|
|
@@ -1985,13 +2001,14 @@ function RemoteComponent({
|
|
|
1985
2001
|
name,
|
|
1986
2002
|
shared,
|
|
1987
2003
|
shadowRoot,
|
|
1988
|
-
additionalHeaders,
|
|
1989
2004
|
reset,
|
|
1990
2005
|
id,
|
|
1991
2006
|
onBeforeLoad,
|
|
1992
2007
|
onLoad,
|
|
1993
2008
|
onError,
|
|
1994
|
-
onChange
|
|
2009
|
+
onChange,
|
|
2010
|
+
onRequest,
|
|
2011
|
+
onResponse
|
|
1995
2012
|
]);
|
|
1996
2013
|
if (remoteComponent instanceof Error) {
|
|
1997
2014
|
throw remoteComponent;
|