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/html/host.cjs
CHANGED
|
@@ -62,6 +62,9 @@ function logDebug(location2, message) {
|
|
|
62
62
|
console.debug(`[${PREFIX}:${location2}]: ${message}`);
|
|
63
63
|
}
|
|
64
64
|
}
|
|
65
|
+
function logInfo(location2, message) {
|
|
66
|
+
console.info(`[${PREFIX}:${location2}]: ${message}`);
|
|
67
|
+
}
|
|
65
68
|
function logWarn(location2, message) {
|
|
66
69
|
console.warn(`[${PREFIX}:${location2}]: ${message}`);
|
|
67
70
|
}
|
|
@@ -267,6 +270,41 @@ var init_shared_modules = __esm({
|
|
|
267
270
|
}
|
|
268
271
|
});
|
|
269
272
|
|
|
273
|
+
// src/shared/ssr/fetch-with-protected-rc-fallback.ts
|
|
274
|
+
async function fetchWithProtectedRcFallback(url, init) {
|
|
275
|
+
try {
|
|
276
|
+
const res = await fetch(url, init);
|
|
277
|
+
return res;
|
|
278
|
+
} catch (error) {
|
|
279
|
+
if (typeof document === "object" && typeof document.location === "object" && document.location.origin !== new URL(url).origin) {
|
|
280
|
+
logInfo(
|
|
281
|
+
"FetchRemoteComponent",
|
|
282
|
+
"Request failed due to CORS, attempting to fetch it via the withRemoteComponentsHost proxy."
|
|
283
|
+
);
|
|
284
|
+
const proxiedRes = await fetch(
|
|
285
|
+
`${RC_PROTECTED_REMOTE_FETCH_PATHNAME}?url=${url}`
|
|
286
|
+
);
|
|
287
|
+
if (proxiedRes.status === 200) {
|
|
288
|
+
return proxiedRes;
|
|
289
|
+
} else {
|
|
290
|
+
logError(
|
|
291
|
+
"FetchRemoteComponent",
|
|
292
|
+
`Could not proxy remote: [response status ${proxiedRes.status}] ${await proxiedRes.text()}`
|
|
293
|
+
);
|
|
294
|
+
}
|
|
295
|
+
}
|
|
296
|
+
throw error;
|
|
297
|
+
}
|
|
298
|
+
}
|
|
299
|
+
var RC_PROTECTED_REMOTE_FETCH_PATHNAME;
|
|
300
|
+
var init_fetch_with_protected_rc_fallback = __esm({
|
|
301
|
+
"src/shared/ssr/fetch-with-protected-rc-fallback.ts"() {
|
|
302
|
+
"use strict";
|
|
303
|
+
init_logger();
|
|
304
|
+
RC_PROTECTED_REMOTE_FETCH_PATHNAME = "/rc-fetch-protected-remote";
|
|
305
|
+
}
|
|
306
|
+
});
|
|
307
|
+
|
|
270
308
|
// src/shared/utils/index.ts
|
|
271
309
|
function escapeString(str) {
|
|
272
310
|
return str.replace(/[^a-z0-9]/g, "_");
|
|
@@ -274,7 +312,6 @@ function escapeString(str) {
|
|
|
274
312
|
var init_utils = __esm({
|
|
275
313
|
"src/shared/utils/index.ts"() {
|
|
276
314
|
"use strict";
|
|
277
|
-
init_logger();
|
|
278
315
|
}
|
|
279
316
|
});
|
|
280
317
|
|
|
@@ -336,7 +373,7 @@ function createChunkLoader(runtime) {
|
|
|
336
373
|
}
|
|
337
374
|
logDebug("ChunkLoader", `Fetching chunk from: "${url}"`);
|
|
338
375
|
self.__remote_components_turbopack_chunk_loader_promise__[url] = new Promise((resolve, reject) => {
|
|
339
|
-
|
|
376
|
+
fetchWithProtectedRcFallback(url).then((res) => res.text()).then((code) => {
|
|
340
377
|
const hasTurbopack = code.includes("globalThis.TURBOPACK") || code.includes("self.TURBOPACK");
|
|
341
378
|
if (hasTurbopack) {
|
|
342
379
|
return handleTurbopackChunk(code, bundle ?? "", url);
|
|
@@ -489,6 +526,7 @@ var init_chunk_loader = __esm({
|
|
|
489
526
|
"src/shared/client/chunk-loader.ts"() {
|
|
490
527
|
"use strict";
|
|
491
528
|
init_error();
|
|
529
|
+
init_fetch_with_protected_rc_fallback();
|
|
492
530
|
init_logger();
|
|
493
531
|
init_const();
|
|
494
532
|
}
|
|
@@ -1258,7 +1296,7 @@ var import_jsx_runtime, imageImpl;
|
|
|
1258
1296
|
var init_polyfill = __esm({
|
|
1259
1297
|
"src/shared/client/polyfill.tsx"() {
|
|
1260
1298
|
"use strict";
|
|
1261
|
-
|
|
1299
|
+
init_logger();
|
|
1262
1300
|
// eslint-disable-next-line @next/next/no-img-element, jsx-a11y/alt-text
|
|
1263
1301
|
import_jsx_runtime = require("react/jsx-runtime");
|
|
1264
1302
|
imageImpl = (bundle) => function RemoteImage({
|
|
@@ -1663,11 +1701,17 @@ function remoteFetchHeaders() {
|
|
|
1663
1701
|
}
|
|
1664
1702
|
|
|
1665
1703
|
// src/shared/ssr/fetch-with-hooks.ts
|
|
1666
|
-
|
|
1704
|
+
init_fetch_with_protected_rc_fallback();
|
|
1705
|
+
async function fetchWithHooks(url, additionalInit, options = {}) {
|
|
1667
1706
|
const { onRequest, onResponse } = options;
|
|
1707
|
+
const init = {
|
|
1708
|
+
method: "GET",
|
|
1709
|
+
headers: remoteFetchHeaders(),
|
|
1710
|
+
...additionalInit
|
|
1711
|
+
};
|
|
1668
1712
|
let res = await onRequest?.(url, init);
|
|
1669
1713
|
if (!res) {
|
|
1670
|
-
res = await
|
|
1714
|
+
res = await fetchWithProtectedRcFallback(url, init);
|
|
1671
1715
|
}
|
|
1672
1716
|
const transformedRes = await onResponse?.(url, res);
|
|
1673
1717
|
if (transformedRes) {
|
|
@@ -1678,6 +1722,7 @@ async function fetchWithHooks(url, init, options = {}) {
|
|
|
1678
1722
|
|
|
1679
1723
|
// src/html/host/index.tsx
|
|
1680
1724
|
init_utils();
|
|
1725
|
+
init_logger();
|
|
1681
1726
|
|
|
1682
1727
|
// src/html/host/runtime/index.ts
|
|
1683
1728
|
init_error();
|
|
@@ -1819,8 +1864,6 @@ if (typeof HTMLElement !== "undefined") {
|
|
|
1819
1864
|
}
|
|
1820
1865
|
if (!remoteComponentChild && url) {
|
|
1821
1866
|
const fetchInit = {
|
|
1822
|
-
method: "GET",
|
|
1823
|
-
headers: remoteFetchHeaders(),
|
|
1824
1867
|
credentials: this.getAttribute("credentials") || "same-origin"
|
|
1825
1868
|
};
|
|
1826
1869
|
const res = await fetchWithHooks(url, fetchInit, {
|