remote-components 0.0.43 → 0.0.44
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/{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 +1 -1
- 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.d.ts +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 +14 -23
- package/dist/internal/shared/ssr/fetch-remote-component.cjs.map +1 -1
- package/dist/internal/shared/ssr/fetch-remote-component.d.ts +5 -9
- package/dist/internal/shared/ssr/fetch-remote-component.js +13 -21
- 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 +39 -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.map +1 -1
- package/dist/internal/shared/ssr/get-ssr-relative-path-base-url.js.map +1 -1
- 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 +7 -8
- package/dist/next/host/app-router-server.cjs.map +1 -1
- package/dist/next/host/app-router-server.d.ts +13 -4
- package/dist/next/host/app-router-server.js +7 -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 +26 -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 +36 -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 +1 -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-2ab78f67.d.ts +71 -0
- package/package.json +54 -32
- package/dist/types-cbf6c34f.d.ts +0 -9
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
2
|
import * as react from 'react';
|
|
3
3
|
import { RemoteComponentProps } from '../../../react/index.js';
|
|
4
|
-
import '../../../component-loader-
|
|
4
|
+
import '../../../component-loader-26b1f55e.js';
|
|
5
5
|
|
|
6
6
|
/**
|
|
7
7
|
* RemoteComponent - Client-side component for rendering remote components
|
|
@@ -1428,23 +1428,35 @@ async function loadStaticRemoteComponent(scripts, url) {
|
|
|
1428
1428
|
}
|
|
1429
1429
|
|
|
1430
1430
|
// src/shared/ssr/fetch-headers.ts
|
|
1431
|
-
function remoteFetchHeaders(
|
|
1431
|
+
function remoteFetchHeaders() {
|
|
1432
1432
|
return {
|
|
1433
1433
|
/**
|
|
1434
1434
|
* Authenticates deployment protection for the remote. Needed for SSR and SSG clients.
|
|
1435
|
-
*
|
|
1436
|
-
*
|
|
1435
|
+
* If the remote component uses vercel deployment protection, ensure the host and remote vercel
|
|
1436
|
+
* projects share a common automation bypass secret, and the shared secret is used as the
|
|
1437
|
+
* VERCEL_AUTOMATION_BYPASS_SECRET env var in the host project.
|
|
1437
1438
|
*/
|
|
1438
1439
|
...typeof process === "object" && typeof process.env === "object" && typeof process.env.VERCEL_AUTOMATION_BYPASS_SECRET === "string" ? {
|
|
1439
1440
|
"x-vercel-protection-bypass": process.env.VERCEL_AUTOMATION_BYPASS_SECRET
|
|
1440
1441
|
} : {},
|
|
1441
|
-
...Object.fromEntries(
|
|
1442
|
-
additionalHeaders instanceof Headers ? additionalHeaders.entries() : Object.entries(additionalHeaders ?? {})
|
|
1443
|
-
),
|
|
1444
1442
|
Accept: "text/html"
|
|
1445
1443
|
};
|
|
1446
1444
|
}
|
|
1447
1445
|
|
|
1446
|
+
// src/shared/ssr/fetch-with-hooks.ts
|
|
1447
|
+
async function fetchWithHooks(url, init, options = {}) {
|
|
1448
|
+
const { onRequest, onResponse } = options;
|
|
1449
|
+
let res = await onRequest?.(url, init);
|
|
1450
|
+
if (!res) {
|
|
1451
|
+
res = await fetch(url, init);
|
|
1452
|
+
}
|
|
1453
|
+
const transformedRes = await onResponse?.(url, res);
|
|
1454
|
+
if (transformedRes) {
|
|
1455
|
+
res = transformedRes;
|
|
1456
|
+
}
|
|
1457
|
+
return res;
|
|
1458
|
+
}
|
|
1459
|
+
|
|
1448
1460
|
// src/shared/ssr/get-client-or-server-url.ts
|
|
1449
1461
|
function getClientOrServerUrl(src, serverFallback) {
|
|
1450
1462
|
const fallback = typeof location !== "undefined" ? location.href : serverFallback;
|
|
@@ -1536,12 +1548,13 @@ function RemoteComponent({
|
|
|
1536
1548
|
credentials = "same-origin",
|
|
1537
1549
|
name: nameProp = "__vercel_remote_component",
|
|
1538
1550
|
shared = {},
|
|
1539
|
-
additionalHeaders,
|
|
1540
1551
|
children,
|
|
1541
1552
|
onBeforeLoad,
|
|
1542
1553
|
onLoad,
|
|
1543
1554
|
onError,
|
|
1544
|
-
onChange
|
|
1555
|
+
onChange,
|
|
1556
|
+
onRequest,
|
|
1557
|
+
onResponse
|
|
1545
1558
|
}) {
|
|
1546
1559
|
const instanceId = useId();
|
|
1547
1560
|
const name = useMemo(() => {
|
|
@@ -1645,10 +1658,13 @@ function RemoteComponent({
|
|
|
1645
1658
|
if (!html && src) {
|
|
1646
1659
|
const fetchInit = {
|
|
1647
1660
|
method: "GET",
|
|
1648
|
-
headers: remoteFetchHeaders(
|
|
1661
|
+
headers: remoteFetchHeaders(),
|
|
1649
1662
|
credentials
|
|
1650
1663
|
};
|
|
1651
|
-
const res = await
|
|
1664
|
+
const res = await fetchWithHooks(url, fetchInit, {
|
|
1665
|
+
onRequest,
|
|
1666
|
+
onResponse
|
|
1667
|
+
});
|
|
1652
1668
|
if (!res.ok) {
|
|
1653
1669
|
let error = failedToFetchRemoteComponentError(
|
|
1654
1670
|
url.href,
|
|
@@ -1958,13 +1974,14 @@ function RemoteComponent({
|
|
|
1958
1974
|
name,
|
|
1959
1975
|
shared,
|
|
1960
1976
|
shadowRoot,
|
|
1961
|
-
additionalHeaders,
|
|
1962
1977
|
reset,
|
|
1963
1978
|
id,
|
|
1964
1979
|
onBeforeLoad,
|
|
1965
1980
|
onLoad,
|
|
1966
1981
|
onError,
|
|
1967
|
-
onChange
|
|
1982
|
+
onChange,
|
|
1983
|
+
onRequest,
|
|
1984
|
+
onResponse
|
|
1968
1985
|
]);
|
|
1969
1986
|
if (remoteComponent instanceof Error) {
|
|
1970
1987
|
throw remoteComponent;
|