remote-components 0.0.47 → 0.0.49
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-26b1f55e.d.ts → component-loader-1838f572.d.ts} +62 -8
- package/dist/html/host.cjs +165 -70
- package/dist/html/host.cjs.map +1 -1
- package/dist/html/host.js +165 -70
- package/dist/html/host.js.map +1 -1
- package/dist/internal/next/host/app-router-client.cjs +13 -50
- package/dist/internal/next/host/app-router-client.cjs.map +1 -1
- package/dist/internal/next/host/app-router-client.d.ts +1 -1
- package/dist/internal/next/host/app-router-client.js +14 -51
- package/dist/internal/next/host/app-router-client.js.map +1 -1
- package/dist/internal/next/host/remote-component-links.cjs +96 -0
- package/dist/internal/next/host/remote-component-links.cjs.map +1 -0
- package/dist/internal/next/host/remote-component-links.d.ts +25 -0
- package/dist/internal/next/host/remote-component-links.js +72 -0
- package/dist/internal/next/host/remote-component-links.js.map +1 -0
- package/dist/internal/shared/client/remote-component.cjs +17 -1
- package/dist/internal/shared/client/remote-component.cjs.map +1 -1
- package/dist/internal/shared/client/remote-component.d.ts +2 -2
- package/dist/internal/shared/client/remote-component.js +17 -1
- package/dist/internal/shared/client/remote-component.js.map +1 -1
- package/dist/internal/shared/ssr/dom-flight.d.ts +1 -1
- package/dist/internal/shared/ssr/fetch-remote-component.d.ts +1 -1
- package/dist/internal/shared/ssr/fetch-with-hooks.cjs +13 -3
- package/dist/internal/shared/ssr/fetch-with-hooks.cjs.map +1 -1
- package/dist/internal/shared/ssr/fetch-with-hooks.d.ts +24 -13
- package/dist/internal/shared/ssr/fetch-with-hooks.js +13 -3
- package/dist/internal/shared/ssr/fetch-with-hooks.js.map +1 -1
- package/dist/internal/shared/ssr/fetch-with-protected-rc-fallback.cjs +6 -1
- package/dist/internal/shared/ssr/fetch-with-protected-rc-fallback.cjs.map +1 -1
- package/dist/internal/shared/ssr/fetch-with-protected-rc-fallback.d.ts +3 -0
- package/dist/internal/shared/ssr/fetch-with-protected-rc-fallback.js +6 -1
- package/dist/internal/shared/ssr/fetch-with-protected-rc-fallback.js.map +1 -1
- package/dist/internal/shared/utils/abort.cjs +38 -0
- package/dist/internal/shared/utils/abort.cjs.map +1 -0
- package/dist/internal/shared/utils/abort.d.ts +7 -0
- package/dist/internal/shared/utils/abort.js +14 -0
- package/dist/internal/shared/utils/abort.js.map +1 -0
- package/dist/next/config.cjs +4 -2
- package/dist/next/config.cjs.map +1 -1
- package/dist/next/config.js +4 -2
- package/dist/next/config.js.map +1 -1
- package/dist/next/host/app-router-server.d.ts +1 -1
- package/dist/next/host/client/index.cjs +41 -8
- 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 +41 -8
- package/dist/next/host/client/index.js.map +1 -1
- package/dist/next/host/pages-router-client.d.ts +1 -1
- package/dist/next/host/pages-router-server.d.ts +1 -1
- package/dist/next/index.d.ts +1 -1
- package/dist/next/proxy.cjs.map +1 -1
- package/dist/next/proxy.js.map +1 -1
- package/dist/react/index.cjs +41 -8
- package/dist/react/index.cjs.map +1 -1
- package/dist/react/index.d.ts +2 -1
- package/dist/react/index.js +41 -8
- package/dist/react/index.js.map +1 -1
- package/dist/{types-6e4ba234.d.ts → types-cbe44b51.d.ts} +61 -7
- package/dist/webpack.cjs +274 -0
- package/dist/webpack.cjs.map +1 -0
- package/dist/webpack.d.ts +14 -0
- package/dist/webpack.js +247 -0
- package/dist/webpack.js.map +1 -0
- package/package.json +9 -1
package/dist/react/index.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
|
-
import { L as LoadRemoteComponentProps, O as OnRequestHook, a as OnResponseHook } from '../component-loader-
|
|
2
|
+
import { L as LoadRemoteComponentProps, O as OnRequestHook, a as OnResponseHook } from '../component-loader-1838f572.js';
|
|
3
|
+
export { H as HookOptions } from '../component-loader-1838f572.js';
|
|
3
4
|
import 'react';
|
|
4
5
|
|
|
5
6
|
declare module 'react/jsx-runtime' {
|
package/dist/react/index.js
CHANGED
|
@@ -580,6 +580,18 @@ async function loadScripts(scripts) {
|
|
|
580
580
|
);
|
|
581
581
|
}
|
|
582
582
|
|
|
583
|
+
// src/shared/utils/abort.ts
|
|
584
|
+
function isAbortError(error) {
|
|
585
|
+
if (error instanceof DOMException && error.name === "AbortError") {
|
|
586
|
+
return true;
|
|
587
|
+
}
|
|
588
|
+
if (error !== null && typeof error === "object" && "name" in error && error.name === "AbortError" && "message" in error && typeof error.message === "string") {
|
|
589
|
+
const e = error;
|
|
590
|
+
return typeof e.code === "number" || e.constructor?.name === "DOMException";
|
|
591
|
+
}
|
|
592
|
+
return false;
|
|
593
|
+
}
|
|
594
|
+
|
|
583
595
|
// src/shared/ssr/fetch-with-protected-rc-fallback.ts
|
|
584
596
|
var RC_PROTECTED_REMOTE_FETCH_PATHNAME = "/rc-fetch-protected-remote";
|
|
585
597
|
async function fetchWithProtectedRcFallback(url, init) {
|
|
@@ -587,13 +599,17 @@ async function fetchWithProtectedRcFallback(url, init) {
|
|
|
587
599
|
const res = await fetch(url, init);
|
|
588
600
|
return res;
|
|
589
601
|
} catch (error) {
|
|
602
|
+
if (isAbortError(error)) {
|
|
603
|
+
throw error;
|
|
604
|
+
}
|
|
590
605
|
if (typeof document === "object" && typeof document.location === "object" && document.location.origin !== new URL(url).origin) {
|
|
591
606
|
logInfo(
|
|
592
607
|
"FetchRemoteComponent",
|
|
593
608
|
"Request failed due to CORS, attempting to fetch it via the withRemoteComponentsHost proxy."
|
|
594
609
|
);
|
|
595
610
|
const proxiedRes = await fetch(
|
|
596
|
-
`${RC_PROTECTED_REMOTE_FETCH_PATHNAME}?url=${url}
|
|
611
|
+
`${RC_PROTECTED_REMOTE_FETCH_PATHNAME}?url=${url}`,
|
|
612
|
+
init?.signal ? { signal: init.signal } : void 0
|
|
597
613
|
);
|
|
598
614
|
if (proxiedRes.status === 200) {
|
|
599
615
|
return proxiedRes;
|
|
@@ -1572,17 +1588,27 @@ function remoteFetchHeaders() {
|
|
|
1572
1588
|
|
|
1573
1589
|
// src/shared/ssr/fetch-with-hooks.ts
|
|
1574
1590
|
async function fetchWithHooks(url, additionalInit, options = {}) {
|
|
1575
|
-
const {
|
|
1591
|
+
const {
|
|
1592
|
+
onRequest,
|
|
1593
|
+
onResponse,
|
|
1594
|
+
abortController = new AbortController()
|
|
1595
|
+
} = options;
|
|
1596
|
+
const signal = abortController.signal;
|
|
1597
|
+
const hookOptions = {
|
|
1598
|
+
signal,
|
|
1599
|
+
abort: (reason) => abortController.abort(reason)
|
|
1600
|
+
};
|
|
1576
1601
|
const init = {
|
|
1577
1602
|
method: "GET",
|
|
1578
1603
|
headers: remoteFetchHeaders(),
|
|
1604
|
+
signal,
|
|
1579
1605
|
...additionalInit
|
|
1580
1606
|
};
|
|
1581
|
-
let res = await onRequest?.(url, init);
|
|
1607
|
+
let res = await onRequest?.(url, init, hookOptions);
|
|
1582
1608
|
if (!res) {
|
|
1583
1609
|
res = await fetchWithProtectedRcFallback(url, init);
|
|
1584
1610
|
}
|
|
1585
|
-
const transformedRes = await onResponse?.(url, res);
|
|
1611
|
+
const transformedRes = await onResponse?.(url, res, hookOptions);
|
|
1586
1612
|
if (transformedRes) {
|
|
1587
1613
|
res = transformedRes;
|
|
1588
1614
|
}
|
|
@@ -1791,14 +1817,16 @@ function RemoteComponent({
|
|
|
1791
1817
|
const fetchInit = {
|
|
1792
1818
|
credentials
|
|
1793
1819
|
};
|
|
1820
|
+
const abortController = new AbortController();
|
|
1794
1821
|
const res = await fetchWithHooks(url, fetchInit, {
|
|
1795
1822
|
onRequest,
|
|
1796
|
-
onResponse
|
|
1823
|
+
onResponse,
|
|
1824
|
+
abortController
|
|
1797
1825
|
});
|
|
1798
|
-
if (!res.ok) {
|
|
1826
|
+
if (!res || !res.ok) {
|
|
1799
1827
|
let error = failedToFetchRemoteComponentError(
|
|
1800
1828
|
url.href,
|
|
1801
|
-
res
|
|
1829
|
+
res ?? new Response(null, { status: 0 })
|
|
1802
1830
|
);
|
|
1803
1831
|
try {
|
|
1804
1832
|
const body = await res.text();
|
|
@@ -1819,7 +1847,9 @@ function RemoteComponent({
|
|
|
1819
1847
|
error.stack = errorStack;
|
|
1820
1848
|
}
|
|
1821
1849
|
}
|
|
1822
|
-
} catch {
|
|
1850
|
+
} catch (parseError) {
|
|
1851
|
+
if (isAbortError(parseError))
|
|
1852
|
+
throw parseError;
|
|
1823
1853
|
}
|
|
1824
1854
|
throw error;
|
|
1825
1855
|
}
|
|
@@ -2091,6 +2121,9 @@ function RemoteComponent({
|
|
|
2091
2121
|
}
|
|
2092
2122
|
}
|
|
2093
2123
|
} catch (error) {
|
|
2124
|
+
if (isAbortError(error)) {
|
|
2125
|
+
return;
|
|
2126
|
+
}
|
|
2094
2127
|
setRemoteComponent(error);
|
|
2095
2128
|
onError?.(error);
|
|
2096
2129
|
}
|