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
|
@@ -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-1838f572.js';
|
|
5
5
|
|
|
6
6
|
/**
|
|
7
7
|
* RemoteComponent - Client-side component for rendering remote components
|
|
@@ -585,6 +585,18 @@ async function loadScripts(scripts) {
|
|
|
585
585
|
);
|
|
586
586
|
}
|
|
587
587
|
|
|
588
|
+
// src/shared/utils/abort.ts
|
|
589
|
+
function isAbortError(error) {
|
|
590
|
+
if (error instanceof DOMException && error.name === "AbortError") {
|
|
591
|
+
return true;
|
|
592
|
+
}
|
|
593
|
+
if (error !== null && typeof error === "object" && "name" in error && error.name === "AbortError" && "message" in error && typeof error.message === "string") {
|
|
594
|
+
const e = error;
|
|
595
|
+
return typeof e.code === "number" || e.constructor?.name === "DOMException";
|
|
596
|
+
}
|
|
597
|
+
return false;
|
|
598
|
+
}
|
|
599
|
+
|
|
588
600
|
// src/shared/ssr/fetch-with-protected-rc-fallback.ts
|
|
589
601
|
var RC_PROTECTED_REMOTE_FETCH_PATHNAME = "/rc-fetch-protected-remote";
|
|
590
602
|
async function fetchWithProtectedRcFallback(url, init) {
|
|
@@ -592,13 +604,17 @@ async function fetchWithProtectedRcFallback(url, init) {
|
|
|
592
604
|
const res = await fetch(url, init);
|
|
593
605
|
return res;
|
|
594
606
|
} catch (error) {
|
|
607
|
+
if (isAbortError(error)) {
|
|
608
|
+
throw error;
|
|
609
|
+
}
|
|
595
610
|
if (typeof document === "object" && typeof document.location === "object" && document.location.origin !== new URL(url).origin) {
|
|
596
611
|
logInfo(
|
|
597
612
|
"FetchRemoteComponent",
|
|
598
613
|
"Request failed due to CORS, attempting to fetch it via the withRemoteComponentsHost proxy."
|
|
599
614
|
);
|
|
600
615
|
const proxiedRes = await fetch(
|
|
601
|
-
`${RC_PROTECTED_REMOTE_FETCH_PATHNAME}?url=${url}
|
|
616
|
+
`${RC_PROTECTED_REMOTE_FETCH_PATHNAME}?url=${url}`,
|
|
617
|
+
init?.signal ? { signal: init.signal } : void 0
|
|
602
618
|
);
|
|
603
619
|
if (proxiedRes.status === 200) {
|
|
604
620
|
return proxiedRes;
|
|
@@ -1577,17 +1593,27 @@ function remoteFetchHeaders() {
|
|
|
1577
1593
|
|
|
1578
1594
|
// src/shared/ssr/fetch-with-hooks.ts
|
|
1579
1595
|
async function fetchWithHooks(url, additionalInit, options = {}) {
|
|
1580
|
-
const {
|
|
1596
|
+
const {
|
|
1597
|
+
onRequest,
|
|
1598
|
+
onResponse,
|
|
1599
|
+
abortController = new AbortController()
|
|
1600
|
+
} = options;
|
|
1601
|
+
const signal = abortController.signal;
|
|
1602
|
+
const hookOptions = {
|
|
1603
|
+
signal,
|
|
1604
|
+
abort: (reason) => abortController.abort(reason)
|
|
1605
|
+
};
|
|
1581
1606
|
const init = {
|
|
1582
1607
|
method: "GET",
|
|
1583
1608
|
headers: remoteFetchHeaders(),
|
|
1609
|
+
signal,
|
|
1584
1610
|
...additionalInit
|
|
1585
1611
|
};
|
|
1586
|
-
let res = await onRequest?.(url, init);
|
|
1612
|
+
let res = await onRequest?.(url, init, hookOptions);
|
|
1587
1613
|
if (!res) {
|
|
1588
1614
|
res = await fetchWithProtectedRcFallback(url, init);
|
|
1589
1615
|
}
|
|
1590
|
-
const transformedRes = await onResponse?.(url, res);
|
|
1616
|
+
const transformedRes = await onResponse?.(url, res, hookOptions);
|
|
1591
1617
|
if (transformedRes) {
|
|
1592
1618
|
res = transformedRes;
|
|
1593
1619
|
}
|
|
@@ -1796,14 +1822,16 @@ function RemoteComponent({
|
|
|
1796
1822
|
const fetchInit = {
|
|
1797
1823
|
credentials
|
|
1798
1824
|
};
|
|
1825
|
+
const abortController = new AbortController();
|
|
1799
1826
|
const res = await fetchWithHooks(url, fetchInit, {
|
|
1800
1827
|
onRequest,
|
|
1801
|
-
onResponse
|
|
1828
|
+
onResponse,
|
|
1829
|
+
abortController
|
|
1802
1830
|
});
|
|
1803
|
-
if (!res.ok) {
|
|
1831
|
+
if (!res || !res.ok) {
|
|
1804
1832
|
let error = failedToFetchRemoteComponentError(
|
|
1805
1833
|
url.href,
|
|
1806
|
-
res
|
|
1834
|
+
res ?? new Response(null, { status: 0 })
|
|
1807
1835
|
);
|
|
1808
1836
|
try {
|
|
1809
1837
|
const body = await res.text();
|
|
@@ -1824,7 +1852,9 @@ function RemoteComponent({
|
|
|
1824
1852
|
error.stack = errorStack;
|
|
1825
1853
|
}
|
|
1826
1854
|
}
|
|
1827
|
-
} catch {
|
|
1855
|
+
} catch (parseError) {
|
|
1856
|
+
if (isAbortError(parseError))
|
|
1857
|
+
throw parseError;
|
|
1828
1858
|
}
|
|
1829
1859
|
throw error;
|
|
1830
1860
|
}
|
|
@@ -2096,6 +2126,9 @@ function RemoteComponent({
|
|
|
2096
2126
|
}
|
|
2097
2127
|
}
|
|
2098
2128
|
} catch (error) {
|
|
2129
|
+
if (isAbortError(error)) {
|
|
2130
|
+
return;
|
|
2131
|
+
}
|
|
2099
2132
|
setRemoteComponent(error);
|
|
2100
2133
|
onError?.(error);
|
|
2101
2134
|
}
|