remote-components 0.4.12 → 0.4.14
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/{chunk-CLO56ON2.js → chunk-EIEIT5PG.js} +82 -4
- package/dist/chunk-EIEIT5PG.js.map +1 -0
- package/dist/{chunk-BEGVH64U.js → chunk-GG32LZD3.js} +2 -2
- package/dist/{chunk-SULMNRMJ.cjs → chunk-JKDPK6L5.cjs} +23 -23
- package/dist/{chunk-XWRB6CEA.cjs → chunk-MAVMKFFL.cjs} +3 -3
- package/dist/{chunk-RZGFQTX6.js → chunk-PNKSHWZ3.js} +8 -8
- package/dist/{chunk-HXCW3WDT.cjs → chunk-T2JJIQUJ.cjs} +25 -25
- package/dist/{chunk-TGE3K3TR.cjs → chunk-TIS6PXSQ.cjs} +18 -18
- package/dist/{chunk-YSJ4FKGI.cjs → chunk-WCZKEWRM.cjs} +97 -19
- package/dist/chunk-WCZKEWRM.cjs.map +1 -0
- package/dist/{chunk-3PR3SWYZ.js → chunk-WWHNG5YP.js} +38 -3
- package/dist/chunk-WWHNG5YP.js.map +1 -0
- package/dist/{chunk-M6ACTSVB.js → chunk-XLGLCKZZ.js} +2 -2
- package/dist/{chunk-24LEEDHP.js → chunk-YKCU7RFM.js} +3 -3
- package/dist/{chunk-6PZEDIAK.cjs → chunk-ZPJ5J24T.cjs} +47 -12
- package/dist/chunk-ZPJ5J24T.cjs.map +1 -0
- package/dist/config/nextjs.cjs +10 -10
- package/dist/config/nextjs.js +7 -7
- package/dist/config/tailwind.cjs +53 -0
- package/dist/config/tailwind.cjs.map +1 -0
- package/dist/config/tailwind.d.ts +21 -0
- package/dist/config/tailwind.js +53 -0
- package/dist/config/tailwind.js.map +1 -0
- package/dist/host/html.cjs +20 -20
- package/dist/host/html.js +8 -8
- package/dist/host/nextjs/app/client-only.cjs +21 -12
- package/dist/host/nextjs/app/client-only.cjs.map +1 -1
- package/dist/host/nextjs/app/client-only.js +18 -9
- package/dist/host/nextjs/app/client-only.js.map +1 -1
- package/dist/host/nextjs/app.cjs +2 -0
- package/dist/host/nextjs/app.cjs.map +1 -1
- package/dist/host/nextjs/app.js +2 -0
- package/dist/host/nextjs/app.js.map +1 -1
- package/dist/host/nextjs/pages.cjs +14 -7
- package/dist/host/nextjs/pages.cjs.map +1 -1
- package/dist/host/nextjs/pages.d.ts +2 -0
- package/dist/host/nextjs/pages.js +14 -7
- package/dist/host/nextjs/pages.js.map +1 -1
- package/dist/host/react.cjs +8 -8
- package/dist/host/react.js +7 -7
- package/dist/internal/host/nextjs/app-client.cjs +15 -6
- package/dist/internal/host/nextjs/app-client.cjs.map +1 -1
- package/dist/internal/host/nextjs/app-client.d.ts +3 -2
- package/dist/internal/host/nextjs/app-client.js +15 -6
- package/dist/internal/host/nextjs/app-client.js.map +1 -1
- package/dist/internal/host/nextjs/dom-flight.cjs +1 -0
- package/dist/internal/host/nextjs/dom-flight.cjs.map +1 -1
- package/dist/internal/host/nextjs/dom-flight.d.ts +1 -0
- package/dist/internal/host/nextjs/dom-flight.js +1 -0
- package/dist/internal/host/nextjs/dom-flight.js.map +1 -1
- package/dist/internal/host/nextjs/image-shared.cjs +11 -2
- package/dist/internal/host/nextjs/image-shared.cjs.map +1 -1
- package/dist/internal/host/nextjs/image-shared.d.ts +3 -1
- package/dist/internal/host/nextjs/image-shared.js +11 -2
- package/dist/internal/host/nextjs/image-shared.js.map +1 -1
- package/dist/internal/host/server/fetch-remote-component.cjs +58 -3
- package/dist/internal/host/server/fetch-remote-component.cjs.map +1 -1
- package/dist/internal/host/server/fetch-remote-component.d.ts +1 -0
- package/dist/internal/host/server/fetch-remote-component.js +61 -3
- package/dist/internal/host/server/fetch-remote-component.js.map +1 -1
- package/dist/internal/host/server/types.cjs.map +1 -1
- package/dist/internal/host/server/types.d.ts +2 -0
- package/dist/internal/host/shared/next-image-deployment-id.cjs +50 -0
- package/dist/internal/host/shared/next-image-deployment-id.cjs.map +1 -0
- package/dist/internal/host/shared/next-image-deployment-id.d.ts +14 -0
- package/dist/internal/host/shared/next-image-deployment-id.js +25 -0
- package/dist/internal/host/shared/next-image-deployment-id.js.map +1 -0
- package/dist/internal/host/shared/pipeline.d.ts +2 -1
- package/dist/internal/host/shared/remote-image-loader.cjs +16 -2
- package/dist/internal/host/shared/remote-image-loader.cjs.map +1 -1
- package/dist/internal/host/shared/remote-image-loader.d.ts +2 -1
- package/dist/internal/host/shared/remote-image-loader.js +19 -2
- package/dist/internal/host/shared/remote-image-loader.js.map +1 -1
- package/dist/internal/runtime/html/parse-remote-html.d.ts +1 -0
- package/dist/internal/runtime/loaders/component-loader.d.ts +2 -1
- package/dist/remote/react/utils/portal.cjs +58 -0
- package/dist/remote/react/utils/portal.cjs.map +1 -0
- package/dist/remote/react/utils/portal.d.ts +12 -0
- package/dist/remote/react/utils/portal.js +58 -0
- package/dist/remote/react/utils/portal.js.map +1 -0
- package/dist/{server-handoff-9e905049.d.ts → server-handoff-006f9cb5.d.ts} +2 -0
- package/dist/{turbopack-43N2UJNN.js → turbopack-HK7DVYUG.js} +4 -4
- package/dist/{turbopack-5VGMYUL4.cjs → turbopack-YZOIO55D.cjs} +11 -11
- package/dist/{webpack-LXE2UWTA.js → webpack-2HP73JL7.js} +4 -4
- package/dist/{webpack-FSN5UBA2.cjs → webpack-W2MODB73.cjs} +11 -11
- package/package.json +18 -1
- package/dist/chunk-3PR3SWYZ.js.map +0 -1
- package/dist/chunk-6PZEDIAK.cjs.map +0 -1
- package/dist/chunk-CLO56ON2.js.map +0 -1
- package/dist/chunk-YSJ4FKGI.cjs.map +0 -1
- /package/dist/{chunk-BEGVH64U.js.map → chunk-GG32LZD3.js.map} +0 -0
- /package/dist/{chunk-SULMNRMJ.cjs.map → chunk-JKDPK6L5.cjs.map} +0 -0
- /package/dist/{chunk-XWRB6CEA.cjs.map → chunk-MAVMKFFL.cjs.map} +0 -0
- /package/dist/{chunk-RZGFQTX6.js.map → chunk-PNKSHWZ3.js.map} +0 -0
- /package/dist/{chunk-HXCW3WDT.cjs.map → chunk-T2JJIQUJ.cjs.map} +0 -0
- /package/dist/{chunk-TGE3K3TR.cjs.map → chunk-TIS6PXSQ.cjs.map} +0 -0
- /package/dist/{chunk-M6ACTSVB.js.map → chunk-XLGLCKZZ.js.map} +0 -0
- /package/dist/{chunk-24LEEDHP.js.map → chunk-YKCU7RFM.js.map} +0 -0
- /package/dist/{turbopack-43N2UJNN.js.map → turbopack-HK7DVYUG.js.map} +0 -0
- /package/dist/{turbopack-5VGMYUL4.cjs.map → turbopack-YZOIO55D.cjs.map} +0 -0
- /package/dist/{webpack-LXE2UWTA.js.map → webpack-2HP73JL7.js.map} +0 -0
- /package/dist/{webpack-FSN5UBA2.cjs.map → webpack-W2MODB73.cjs.map} +0 -0
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
interface NextImageDeploymentId {
|
|
2
|
+
src: string;
|
|
3
|
+
deploymentId: string;
|
|
4
|
+
}
|
|
5
|
+
declare function isNextDeploymentAssetSrc(src: string | null): src is string;
|
|
6
|
+
declare function extractDeploymentIdFromSrc(src: string): {
|
|
7
|
+
deploymentId: undefined;
|
|
8
|
+
src: string;
|
|
9
|
+
} | {
|
|
10
|
+
deploymentId: string;
|
|
11
|
+
src: string;
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
export { NextImageDeploymentId, extractDeploymentIdFromSrc, isNextDeploymentAssetSrc };
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
function isNextDeploymentAssetSrc(src) {
|
|
2
|
+
return typeof src === "string" && src.startsWith("/") && !src.startsWith("//");
|
|
3
|
+
}
|
|
4
|
+
function extractDeploymentIdFromSrc(src) {
|
|
5
|
+
const queryIndex = src.indexOf("?");
|
|
6
|
+
if (queryIndex === -1) {
|
|
7
|
+
return { deploymentId: void 0, src };
|
|
8
|
+
}
|
|
9
|
+
const params = new URLSearchParams(src.slice(queryIndex + 1));
|
|
10
|
+
const deploymentId = params.get("dpl") || void 0;
|
|
11
|
+
if (!deploymentId) {
|
|
12
|
+
return { deploymentId: void 0, src };
|
|
13
|
+
}
|
|
14
|
+
params.delete("dpl");
|
|
15
|
+
const remaining = params.toString();
|
|
16
|
+
return {
|
|
17
|
+
deploymentId,
|
|
18
|
+
src: `${src.slice(0, queryIndex)}${remaining ? `?${remaining}` : ""}`
|
|
19
|
+
};
|
|
20
|
+
}
|
|
21
|
+
export {
|
|
22
|
+
extractDeploymentIdFromSrc,
|
|
23
|
+
isNextDeploymentAssetSrc
|
|
24
|
+
};
|
|
25
|
+
//# sourceMappingURL=next-image-deployment-id.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../src/host/shared/next-image-deployment-id.ts"],"sourcesContent":["export interface NextImageDeploymentId {\n src: string;\n deploymentId: string;\n}\n\nexport function isNextDeploymentAssetSrc(src: string | null): src is string {\n return (\n typeof src === 'string' && src.startsWith('/') && !src.startsWith('//')\n );\n}\n\nexport function extractDeploymentIdFromSrc(src: string) {\n const queryIndex = src.indexOf('?');\n if (queryIndex === -1) {\n return { deploymentId: undefined, src };\n }\n\n const params = new URLSearchParams(src.slice(queryIndex + 1));\n const deploymentId = params.get('dpl') || undefined;\n if (!deploymentId) {\n return { deploymentId: undefined, src };\n }\n\n params.delete('dpl');\n const remaining = params.toString();\n return {\n deploymentId,\n src: `${src.slice(0, queryIndex)}${remaining ? `?${remaining}` : ''}`,\n };\n}\n"],"mappings":"AAKO,SAAS,yBAAyB,KAAmC;AAC1E,SACE,OAAO,QAAQ,YAAY,IAAI,WAAW,GAAG,KAAK,CAAC,IAAI,WAAW,IAAI;AAE1E;AAEO,SAAS,2BAA2B,KAAa;AACtD,QAAM,aAAa,IAAI,QAAQ,GAAG;AAClC,MAAI,eAAe,IAAI;AACrB,WAAO,EAAE,cAAc,QAAW,IAAI;AAAA,EACxC;AAEA,QAAM,SAAS,IAAI,gBAAgB,IAAI,MAAM,aAAa,CAAC,CAAC;AAC5D,QAAM,eAAe,OAAO,IAAI,KAAK,KAAK;AAC1C,MAAI,CAAC,cAAc;AACjB,WAAO,EAAE,cAAc,QAAW,IAAI;AAAA,EACxC;AAEA,SAAO,OAAO,KAAK;AACnB,QAAM,YAAY,OAAO,SAAS;AAClC,SAAO;AAAA,IACL;AAAA,IACA,KAAK,GAAG,IAAI,MAAM,GAAG,UAAU,IAAI,YAAY,IAAI,cAAc;AAAA,EACnE;AACF;","names":[]}
|
|
@@ -2,13 +2,14 @@ import { RemoteSharedModules } from './shared-broker.js';
|
|
|
2
2
|
import { RemoteComponentMetadata } from '../../runtime/metadata.js';
|
|
3
3
|
import { ScriptDescriptor } from './asset-descriptors.js';
|
|
4
4
|
import { InternalResolveClientUrl } from '../../runtime/url/resolve-client-url.js';
|
|
5
|
-
import { a as ConsumeLoaderPayload } from '../../../server-handoff-
|
|
5
|
+
import { a as ConsumeLoaderPayload } from '../../../server-handoff-006f9cb5.js';
|
|
6
6
|
import { ParsedRemoteComponent } from '../../runtime/html/parse-remote-html.js';
|
|
7
7
|
import { M as MountOrUnmountFunction } from '../../../types-bd7be268.js';
|
|
8
8
|
import '../../utils/logger.js';
|
|
9
9
|
import 'react';
|
|
10
10
|
import './config.js';
|
|
11
11
|
import './fetch-interceptors.js';
|
|
12
|
+
import './next-image-deployment-id.js';
|
|
12
13
|
import '../server/types.js';
|
|
13
14
|
import '../nextjs/dom-flight.js';
|
|
14
15
|
import 'parse5/dist/tree-adapters/default';
|
|
@@ -21,8 +21,15 @@ __export(remote_image_loader_exports, {
|
|
|
21
21
|
createRemoteImageLoader: () => createRemoteImageLoader
|
|
22
22
|
});
|
|
23
23
|
module.exports = __toCommonJS(remote_image_loader_exports);
|
|
24
|
+
var import_next_image_deployment_id = require("#internal/host/shared/next-image-deployment-id");
|
|
24
25
|
var import_remote_scope = require("#internal/runtime/turbopack/remote-scope");
|
|
25
|
-
function createRemoteImageLoader(bundle, resolveClientUrl) {
|
|
26
|
+
function createRemoteImageLoader(bundle, resolveClientUrl, ssrImageDeploymentIds) {
|
|
27
|
+
const ssrImageDeploymentIdMap = ssrImageDeploymentIds ? new Map(
|
|
28
|
+
ssrImageDeploymentIds.map(({ src, deploymentId }) => [
|
|
29
|
+
src,
|
|
30
|
+
deploymentId
|
|
31
|
+
])
|
|
32
|
+
) : void 0;
|
|
26
33
|
const loader = Object.assign(
|
|
27
34
|
({
|
|
28
35
|
config,
|
|
@@ -34,7 +41,14 @@ function createRemoteImageLoader(bundle, resolveClientUrl) {
|
|
|
34
41
|
const remoteOrigin = (0, import_remote_scope.getScope)(bundle)?.url.origin ?? "";
|
|
35
42
|
const isCrossOrigin = remoteOrigin && remoteOrigin !== location.origin;
|
|
36
43
|
const basePath = isCrossOrigin ? `${remoteOrigin}${config.path ?? "/_next/image"}` : config.path ?? `${remoteOrigin}/_next/image`;
|
|
37
|
-
|
|
44
|
+
if (!(0, import_next_image_deployment_id.isNextDeploymentAssetSrc)(src)) {
|
|
45
|
+
const url2 = `${basePath}?url=${encodeURIComponent(src)}&w=${width}&q=${q}`;
|
|
46
|
+
return resolveClientUrl?.(url2) ?? url2;
|
|
47
|
+
}
|
|
48
|
+
const extracted = (0, import_next_image_deployment_id.extractDeploymentIdFromSrc)(src);
|
|
49
|
+
const deploymentId = extracted.deploymentId ?? ssrImageDeploymentIdMap?.get(extracted.src);
|
|
50
|
+
const deploymentParam = deploymentId ? `&dpl=${encodeURIComponent(deploymentId)}` : "";
|
|
51
|
+
const url = `${basePath}?url=${encodeURIComponent(extracted.src)}&w=${width}&q=${q}${deploymentParam}`;
|
|
38
52
|
return resolveClientUrl?.(url) ?? url;
|
|
39
53
|
},
|
|
40
54
|
// Signals to getImgProps that this is a default loader (not a user-defined
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/host/shared/remote-image-loader.ts"],"sourcesContent":["import { getScope } from '#internal/runtime/turbopack/remote-scope';\nimport type { InternalResolveClientUrl } from '#internal/runtime/url/resolve-client-url';\n\n/**\n * Replacement for `next/dist/shared/lib/image-loader`.\n *\n * Uses `config.path` (which includes the remote's asset prefix, e.g.\n * `/vc-ap-xxx/_next/image`) to generate URLs that match the server-rendered\n * HTML and avoid hydration mismatches. Under the microfrontends proxy these\n * relative paths are routed to the correct app.\n *\n * For cross-origin deployments (standalone host on a different domain),\n * `config.path` is a relative path that would incorrectly resolve to the host\n * origin, so we prefix it with the remote origin to produce an absolute URL\n * pointing at the remote's optimizer.\n *\n * When `resolveClientUrl` is provided (deployment protection), the final URL\n * is routed through the host's proxy.\n */\nexport function createRemoteImageLoader(\n bundle: string,\n resolveClientUrl?: InternalResolveClientUrl,\n) {\n const loader = Object.assign(\n ({\n config,\n src,\n width,\n quality,\n }: {\n config: { path?: string };\n src: string;\n width: number;\n quality?: number;\n }) => {\n const q = quality ?? 75;\n const remoteOrigin = getScope(bundle)?.url.origin ?? '';\n const isCrossOrigin = remoteOrigin && remoteOrigin !== location.origin;\n const basePath = isCrossOrigin\n ? `${remoteOrigin}${config.path ?? '/_next/image'}`\n : (config.path ?? `${remoteOrigin}/_next/image`);\n const url = `${basePath}?url=${encodeURIComponent(src)}&w=${width}&q=${q}`;\n return resolveClientUrl?.(url) ?? url;\n },\n // Signals to getImgProps that this is a default loader (not a user-defined\n // one), enabling srcSet generation with device/image sizes from the config.\n { __next_img_default: true as const },\n );\n return loader;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,0BAAyB;AAmBlB,SAAS,wBACd,QACA,kBACA;AACA,QAAM,SAAS,OAAO;AAAA,IACpB,CAAC;AAAA,MACC;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,IACF,MAKM;AACJ,YAAM,IAAI,WAAW;AACrB,YAAM,mBAAe,8BAAS,MAAM,GAAG,IAAI,UAAU;AACrD,YAAM,gBAAgB,gBAAgB,iBAAiB,SAAS;AAChE,YAAM,WAAW,gBACb,GAAG,eAAe,OAAO,QAAQ,mBAChC,OAAO,QAAQ,GAAG;
|
|
1
|
+
{"version":3,"sources":["../../../../src/host/shared/remote-image-loader.ts"],"sourcesContent":["import {\n extractDeploymentIdFromSrc,\n isNextDeploymentAssetSrc,\n type NextImageDeploymentId,\n} from '#internal/host/shared/next-image-deployment-id';\nimport { getScope } from '#internal/runtime/turbopack/remote-scope';\nimport type { InternalResolveClientUrl } from '#internal/runtime/url/resolve-client-url';\n\n/**\n * Replacement for `next/dist/shared/lib/image-loader`.\n *\n * Uses `config.path` (which includes the remote's asset prefix, e.g.\n * `/vc-ap-xxx/_next/image`) to generate URLs that match the server-rendered\n * HTML and avoid hydration mismatches. Under the microfrontends proxy these\n * relative paths are routed to the correct app.\n *\n * For cross-origin deployments (standalone host on a different domain),\n * `config.path` is a relative path that would incorrectly resolve to the host\n * origin, so we prefix it with the remote origin to produce an absolute URL\n * pointing at the remote's optimizer.\n *\n * When `resolveClientUrl` is provided (deployment protection), the final URL\n * is routed through the host's proxy.\n */\nexport function createRemoteImageLoader(\n bundle: string,\n resolveClientUrl?: InternalResolveClientUrl,\n ssrImageDeploymentIds?: readonly NextImageDeploymentId[],\n) {\n const ssrImageDeploymentIdMap = ssrImageDeploymentIds\n ? new Map(\n ssrImageDeploymentIds.map(({ src, deploymentId }) => [\n src,\n deploymentId,\n ]),\n )\n : undefined;\n const loader = Object.assign(\n ({\n config,\n src,\n width,\n quality,\n }: {\n config: { path?: string };\n src: string;\n width: number;\n quality?: number;\n }) => {\n const q = quality ?? 75;\n const remoteOrigin = getScope(bundle)?.url.origin ?? '';\n const isCrossOrigin = remoteOrigin && remoteOrigin !== location.origin;\n const basePath = isCrossOrigin\n ? `${remoteOrigin}${config.path ?? '/_next/image'}`\n : (config.path ?? `${remoteOrigin}/_next/image`);\n\n if (!isNextDeploymentAssetSrc(src)) {\n const url = `${basePath}?url=${encodeURIComponent(src)}&w=${width}&q=${q}`;\n return resolveClientUrl?.(url) ?? url;\n }\n\n const extracted = extractDeploymentIdFromSrc(src);\n const deploymentId =\n extracted.deploymentId ?? ssrImageDeploymentIdMap?.get(extracted.src);\n const deploymentParam = deploymentId\n ? `&dpl=${encodeURIComponent(deploymentId)}`\n : '';\n const url = `${basePath}?url=${encodeURIComponent(extracted.src)}&w=${width}&q=${q}${deploymentParam}`;\n return resolveClientUrl?.(url) ?? url;\n },\n // Signals to getImgProps that this is a default loader (not a user-defined\n // one), enabling srcSet generation with device/image sizes from the config.\n { __next_img_default: true as const },\n );\n return loader;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,sCAIO;AACP,0BAAyB;AAmBlB,SAAS,wBACd,QACA,kBACA,uBACA;AACA,QAAM,0BAA0B,wBAC5B,IAAI;AAAA,IACF,sBAAsB,IAAI,CAAC,EAAE,KAAK,aAAa,MAAM;AAAA,MACnD;AAAA,MACA;AAAA,IACF,CAAC;AAAA,EACH,IACA;AACJ,QAAM,SAAS,OAAO;AAAA,IACpB,CAAC;AAAA,MACC;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,IACF,MAKM;AACJ,YAAM,IAAI,WAAW;AACrB,YAAM,mBAAe,8BAAS,MAAM,GAAG,IAAI,UAAU;AACrD,YAAM,gBAAgB,gBAAgB,iBAAiB,SAAS;AAChE,YAAM,WAAW,gBACb,GAAG,eAAe,OAAO,QAAQ,mBAChC,OAAO,QAAQ,GAAG;AAEvB,UAAI,KAAC,0DAAyB,GAAG,GAAG;AAClC,cAAMA,OAAM,GAAG,gBAAgB,mBAAmB,GAAG,OAAO,WAAW;AACvE,eAAO,mBAAmBA,IAAG,KAAKA;AAAA,MACpC;AAEA,YAAM,gBAAY,4DAA2B,GAAG;AAChD,YAAM,eACJ,UAAU,gBAAgB,yBAAyB,IAAI,UAAU,GAAG;AACtE,YAAM,kBAAkB,eACpB,QAAQ,mBAAmB,YAAY,MACvC;AACJ,YAAM,MAAM,GAAG,gBAAgB,mBAAmB,UAAU,GAAG,OAAO,WAAW,IAAI;AACrF,aAAO,mBAAmB,GAAG,KAAK;AAAA,IACpC;AAAA;AAAA;AAAA,IAGA,EAAE,oBAAoB,KAAc;AAAA,EACtC;AACA,SAAO;AACT;","names":["url"]}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { NextImageDeploymentId } from './next-image-deployment-id.js';
|
|
1
2
|
import { InternalResolveClientUrl } from '../../runtime/url/resolve-client-url.js';
|
|
2
3
|
|
|
3
4
|
/**
|
|
@@ -16,7 +17,7 @@ import { InternalResolveClientUrl } from '../../runtime/url/resolve-client-url.j
|
|
|
16
17
|
* When `resolveClientUrl` is provided (deployment protection), the final URL
|
|
17
18
|
* is routed through the host's proxy.
|
|
18
19
|
*/
|
|
19
|
-
declare function createRemoteImageLoader(bundle: string, resolveClientUrl?: InternalResolveClientUrl): (({ config, src, width, quality, }: {
|
|
20
|
+
declare function createRemoteImageLoader(bundle: string, resolveClientUrl?: InternalResolveClientUrl, ssrImageDeploymentIds?: readonly NextImageDeploymentId[]): (({ config, src, width, quality, }: {
|
|
20
21
|
config: {
|
|
21
22
|
path?: string;
|
|
22
23
|
};
|
|
@@ -1,5 +1,15 @@
|
|
|
1
|
+
import {
|
|
2
|
+
extractDeploymentIdFromSrc,
|
|
3
|
+
isNextDeploymentAssetSrc
|
|
4
|
+
} from "#internal/host/shared/next-image-deployment-id";
|
|
1
5
|
import { getScope } from "#internal/runtime/turbopack/remote-scope";
|
|
2
|
-
function createRemoteImageLoader(bundle, resolveClientUrl) {
|
|
6
|
+
function createRemoteImageLoader(bundle, resolveClientUrl, ssrImageDeploymentIds) {
|
|
7
|
+
const ssrImageDeploymentIdMap = ssrImageDeploymentIds ? new Map(
|
|
8
|
+
ssrImageDeploymentIds.map(({ src, deploymentId }) => [
|
|
9
|
+
src,
|
|
10
|
+
deploymentId
|
|
11
|
+
])
|
|
12
|
+
) : void 0;
|
|
3
13
|
const loader = Object.assign(
|
|
4
14
|
({
|
|
5
15
|
config,
|
|
@@ -11,7 +21,14 @@ function createRemoteImageLoader(bundle, resolveClientUrl) {
|
|
|
11
21
|
const remoteOrigin = getScope(bundle)?.url.origin ?? "";
|
|
12
22
|
const isCrossOrigin = remoteOrigin && remoteOrigin !== location.origin;
|
|
13
23
|
const basePath = isCrossOrigin ? `${remoteOrigin}${config.path ?? "/_next/image"}` : config.path ?? `${remoteOrigin}/_next/image`;
|
|
14
|
-
|
|
24
|
+
if (!isNextDeploymentAssetSrc(src)) {
|
|
25
|
+
const url2 = `${basePath}?url=${encodeURIComponent(src)}&w=${width}&q=${q}`;
|
|
26
|
+
return resolveClientUrl?.(url2) ?? url2;
|
|
27
|
+
}
|
|
28
|
+
const extracted = extractDeploymentIdFromSrc(src);
|
|
29
|
+
const deploymentId = extracted.deploymentId ?? ssrImageDeploymentIdMap?.get(extracted.src);
|
|
30
|
+
const deploymentParam = deploymentId ? `&dpl=${encodeURIComponent(deploymentId)}` : "";
|
|
31
|
+
const url = `${basePath}?url=${encodeURIComponent(extracted.src)}&w=${width}&q=${q}${deploymentParam}`;
|
|
15
32
|
return resolveClientUrl?.(url) ?? url;
|
|
16
33
|
},
|
|
17
34
|
// Signals to getImgProps that this is a default loader (not a user-defined
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/host/shared/remote-image-loader.ts"],"sourcesContent":["import { getScope } from '#internal/runtime/turbopack/remote-scope';\nimport type { InternalResolveClientUrl } from '#internal/runtime/url/resolve-client-url';\n\n/**\n * Replacement for `next/dist/shared/lib/image-loader`.\n *\n * Uses `config.path` (which includes the remote's asset prefix, e.g.\n * `/vc-ap-xxx/_next/image`) to generate URLs that match the server-rendered\n * HTML and avoid hydration mismatches. Under the microfrontends proxy these\n * relative paths are routed to the correct app.\n *\n * For cross-origin deployments (standalone host on a different domain),\n * `config.path` is a relative path that would incorrectly resolve to the host\n * origin, so we prefix it with the remote origin to produce an absolute URL\n * pointing at the remote's optimizer.\n *\n * When `resolveClientUrl` is provided (deployment protection), the final URL\n * is routed through the host's proxy.\n */\nexport function createRemoteImageLoader(\n bundle: string,\n resolveClientUrl?: InternalResolveClientUrl,\n) {\n const loader = Object.assign(\n ({\n config,\n src,\n width,\n quality,\n }: {\n config: { path?: string };\n src: string;\n width: number;\n quality?: number;\n }) => {\n const q = quality ?? 75;\n const remoteOrigin = getScope(bundle)?.url.origin ?? '';\n const isCrossOrigin = remoteOrigin && remoteOrigin !== location.origin;\n const basePath = isCrossOrigin\n ? `${remoteOrigin}${config.path ?? '/_next/image'}`\n : (config.path ?? `${remoteOrigin}/_next/image`);\n const url = `${basePath}?url=${encodeURIComponent(src)}&w=${width}&q=${q}`;\n return resolveClientUrl?.(url) ?? url;\n },\n // Signals to getImgProps that this is a default loader (not a user-defined\n // one), enabling srcSet generation with device/image sizes from the config.\n { __next_img_default: true as const },\n );\n return loader;\n}\n"],"mappings":"AAAA,SAAS,gBAAgB;AAmBlB,SAAS,wBACd,QACA,kBACA;AACA,QAAM,SAAS,OAAO;AAAA,IACpB,CAAC;AAAA,MACC;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,IACF,MAKM;AACJ,YAAM,IAAI,WAAW;AACrB,YAAM,eAAe,SAAS,MAAM,GAAG,IAAI,UAAU;AACrD,YAAM,gBAAgB,gBAAgB,iBAAiB,SAAS;AAChE,YAAM,WAAW,gBACb,GAAG,eAAe,OAAO,QAAQ,mBAChC,OAAO,QAAQ,GAAG;
|
|
1
|
+
{"version":3,"sources":["../../../../src/host/shared/remote-image-loader.ts"],"sourcesContent":["import {\n extractDeploymentIdFromSrc,\n isNextDeploymentAssetSrc,\n type NextImageDeploymentId,\n} from '#internal/host/shared/next-image-deployment-id';\nimport { getScope } from '#internal/runtime/turbopack/remote-scope';\nimport type { InternalResolveClientUrl } from '#internal/runtime/url/resolve-client-url';\n\n/**\n * Replacement for `next/dist/shared/lib/image-loader`.\n *\n * Uses `config.path` (which includes the remote's asset prefix, e.g.\n * `/vc-ap-xxx/_next/image`) to generate URLs that match the server-rendered\n * HTML and avoid hydration mismatches. Under the microfrontends proxy these\n * relative paths are routed to the correct app.\n *\n * For cross-origin deployments (standalone host on a different domain),\n * `config.path` is a relative path that would incorrectly resolve to the host\n * origin, so we prefix it with the remote origin to produce an absolute URL\n * pointing at the remote's optimizer.\n *\n * When `resolveClientUrl` is provided (deployment protection), the final URL\n * is routed through the host's proxy.\n */\nexport function createRemoteImageLoader(\n bundle: string,\n resolveClientUrl?: InternalResolveClientUrl,\n ssrImageDeploymentIds?: readonly NextImageDeploymentId[],\n) {\n const ssrImageDeploymentIdMap = ssrImageDeploymentIds\n ? new Map(\n ssrImageDeploymentIds.map(({ src, deploymentId }) => [\n src,\n deploymentId,\n ]),\n )\n : undefined;\n const loader = Object.assign(\n ({\n config,\n src,\n width,\n quality,\n }: {\n config: { path?: string };\n src: string;\n width: number;\n quality?: number;\n }) => {\n const q = quality ?? 75;\n const remoteOrigin = getScope(bundle)?.url.origin ?? '';\n const isCrossOrigin = remoteOrigin && remoteOrigin !== location.origin;\n const basePath = isCrossOrigin\n ? `${remoteOrigin}${config.path ?? '/_next/image'}`\n : (config.path ?? `${remoteOrigin}/_next/image`);\n\n if (!isNextDeploymentAssetSrc(src)) {\n const url = `${basePath}?url=${encodeURIComponent(src)}&w=${width}&q=${q}`;\n return resolveClientUrl?.(url) ?? url;\n }\n\n const extracted = extractDeploymentIdFromSrc(src);\n const deploymentId =\n extracted.deploymentId ?? ssrImageDeploymentIdMap?.get(extracted.src);\n const deploymentParam = deploymentId\n ? `&dpl=${encodeURIComponent(deploymentId)}`\n : '';\n const url = `${basePath}?url=${encodeURIComponent(extracted.src)}&w=${width}&q=${q}${deploymentParam}`;\n return resolveClientUrl?.(url) ?? url;\n },\n // Signals to getImgProps that this is a default loader (not a user-defined\n // one), enabling srcSet generation with device/image sizes from the config.\n { __next_img_default: true as const },\n );\n return loader;\n}\n"],"mappings":"AAAA;AAAA,EACE;AAAA,EACA;AAAA,OAEK;AACP,SAAS,gBAAgB;AAmBlB,SAAS,wBACd,QACA,kBACA,uBACA;AACA,QAAM,0BAA0B,wBAC5B,IAAI;AAAA,IACF,sBAAsB,IAAI,CAAC,EAAE,KAAK,aAAa,MAAM;AAAA,MACnD;AAAA,MACA;AAAA,IACF,CAAC;AAAA,EACH,IACA;AACJ,QAAM,SAAS,OAAO;AAAA,IACpB,CAAC;AAAA,MACC;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,IACF,MAKM;AACJ,YAAM,IAAI,WAAW;AACrB,YAAM,eAAe,SAAS,MAAM,GAAG,IAAI,UAAU;AACrD,YAAM,gBAAgB,gBAAgB,iBAAiB,SAAS;AAChE,YAAM,WAAW,gBACb,GAAG,eAAe,OAAO,QAAQ,mBAChC,OAAO,QAAQ,GAAG;AAEvB,UAAI,CAAC,yBAAyB,GAAG,GAAG;AAClC,cAAMA,OAAM,GAAG,gBAAgB,mBAAmB,GAAG,OAAO,WAAW;AACvE,eAAO,mBAAmBA,IAAG,KAAKA;AAAA,MACpC;AAEA,YAAM,YAAY,2BAA2B,GAAG;AAChD,YAAM,eACJ,UAAU,gBAAgB,yBAAyB,IAAI,UAAU,GAAG;AACtE,YAAM,kBAAkB,eACpB,QAAQ,mBAAmB,YAAY,MACvC;AACJ,YAAM,MAAM,GAAG,gBAAgB,mBAAmB,UAAU,GAAG,OAAO,WAAW,IAAI;AACrF,aAAO,mBAAmB,GAAG,KAAK;AAAA,IACpC;AAAA;AAAA;AAAA,IAGA,EAAE,oBAAoB,KAAc;AAAA,EACtC;AACA,SAAO;AACT;","names":["url"]}
|
|
@@ -4,6 +4,7 @@ import { RemoteComponentMetadata } from '../metadata.js';
|
|
|
4
4
|
import '../../host/nextjs/dom-flight.js';
|
|
5
5
|
import 'parse5/dist/tree-adapters/default';
|
|
6
6
|
import '../../host/shared/asset-descriptors.js';
|
|
7
|
+
import '../../host/shared/next-image-deployment-id.js';
|
|
7
8
|
import '../url/resolve-client-url.js';
|
|
8
9
|
import '../../utils/logger.js';
|
|
9
10
|
|
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
import { RemoteSharedModules } from '../../host/shared/shared-broker.js';
|
|
2
2
|
import { InternalResolveClientUrl } from '../url/resolve-client-url.js';
|
|
3
|
-
import { a as ConsumeLoaderPayload } from '../../../server-handoff-
|
|
3
|
+
import { a as ConsumeLoaderPayload } from '../../../server-handoff-006f9cb5.js';
|
|
4
4
|
import { L as LoaderResult } from '../../../types-bd7be268.js';
|
|
5
5
|
import '../../utils/logger.js';
|
|
6
6
|
import 'react';
|
|
7
7
|
import '../../host/shared/asset-descriptors.js';
|
|
8
8
|
import '../../host/shared/config.js';
|
|
9
9
|
import '../../host/shared/fetch-interceptors.js';
|
|
10
|
+
import '../../host/shared/next-image-deployment-id.js';
|
|
10
11
|
import '../metadata.js';
|
|
11
12
|
import '../turbopack/remote-scope.js';
|
|
12
13
|
import '../constants.js';
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } }"use client";
|
|
2
|
+
|
|
3
|
+
// src/remote/react/utils/portal.tsx
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
var _react = require('react');
|
|
8
|
+
var _reactdom = require('react-dom');
|
|
9
|
+
var _jsxruntime = require('react/jsx-runtime');
|
|
10
|
+
var DEFAULT_PORTAL_CONTAINER_NAME = "default";
|
|
11
|
+
function useRemotePortalContainer(anchorRef, options = {}) {
|
|
12
|
+
const [container, setContainer] = _react.useState.call(void 0, null);
|
|
13
|
+
const anchor = anchorRef.current;
|
|
14
|
+
const containerName = _nullishCoalesce(options.name, () => ( DEFAULT_PORTAL_CONTAINER_NAME));
|
|
15
|
+
_react.useLayoutEffect.call(void 0, () => {
|
|
16
|
+
if (!anchor) {
|
|
17
|
+
return;
|
|
18
|
+
}
|
|
19
|
+
const ownerDocument = anchor.ownerDocument;
|
|
20
|
+
const root = anchor.getRootNode();
|
|
21
|
+
if (typeof ShadowRoot !== "undefined" && root instanceof ShadowRoot) {
|
|
22
|
+
const existingContainer = Array.from(
|
|
23
|
+
root.querySelectorAll(
|
|
24
|
+
"[data-remote-components-portal-container]"
|
|
25
|
+
)
|
|
26
|
+
).find(
|
|
27
|
+
(element) => element.getAttribute("data-remote-components-portal-container") === containerName
|
|
28
|
+
);
|
|
29
|
+
if (existingContainer) {
|
|
30
|
+
setContainer(existingContainer);
|
|
31
|
+
return;
|
|
32
|
+
}
|
|
33
|
+
const shadowContainer = ownerDocument.createElement("div");
|
|
34
|
+
shadowContainer.setAttribute(
|
|
35
|
+
"data-remote-components-portal-container",
|
|
36
|
+
containerName
|
|
37
|
+
);
|
|
38
|
+
root.appendChild(shadowContainer);
|
|
39
|
+
setContainer(shadowContainer);
|
|
40
|
+
return;
|
|
41
|
+
}
|
|
42
|
+
setContainer(ownerDocument.body);
|
|
43
|
+
}, [anchor, containerName]);
|
|
44
|
+
return container;
|
|
45
|
+
}
|
|
46
|
+
function RemotePortal({ children, name }) {
|
|
47
|
+
const [anchor, setAnchor] = _react.useState.call(void 0, null);
|
|
48
|
+
const container = useRemotePortalContainer({ current: anchor }, { name });
|
|
49
|
+
return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _jsxruntime.Fragment, { children: [
|
|
50
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { hidden: true, ref: setAnchor, "data-remote-components-portal-anchor": "" }),
|
|
51
|
+
container ? _reactdom.createPortal.call(void 0, children, container) : null
|
|
52
|
+
] });
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
|
|
56
|
+
|
|
57
|
+
exports.RemotePortal = RemotePortal; exports.useRemotePortalContainer = useRemotePortalContainer;
|
|
58
|
+
//# sourceMappingURL=portal.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../src/remote/react/utils/portal.tsx"],"names":[],"mappings":";;;AAEA;AAAA,EAGE;AAAA,EACA;AAAA,OACK;AACP,SAAS,oBAAoB;AAiEzB,mBACE,KADF;AAvDJ,IAAM,gCAAgC;AAE/B,SAAS,yBACd,WACA,UAA2C,CAAC,GACxB;AACpB,QAAM,CAAC,WAAW,YAAY,IAAI,SAA6B,IAAI;AACnE,QAAM,SAAS,UAAU;AACzB,QAAM,gBAAgB,QAAQ,QAAQ;AAEtC,kBAAgB,MAAM;AACpB,QAAI,CAAC,QAAQ;AACX;AAAA,IACF;AAEA,UAAM,gBAAgB,OAAO;AAC7B,UAAM,OAAO,OAAO,YAAY;AAEhC,QAAI,OAAO,eAAe,eAAe,gBAAgB,YAAY;AACnE,YAAM,oBAAoB,MAAM;AAAA,QAC9B,KAAK;AAAA,UACH;AAAA,QACF;AAAA,MACF,EAAE;AAAA,QACA,CAAC,YACC,QAAQ,aAAa,yCAAyC,MAC9D;AAAA,MACJ;AAEA,UAAI,mBAAmB;AACrB,qBAAa,iBAAiB;AAC9B;AAAA,MACF;AAEA,YAAM,kBAAkB,cAAc,cAAc,KAAK;AACzD,sBAAgB;AAAA,QACd;AAAA,QACA;AAAA,MACF;AACA,WAAK,YAAY,eAAe;AAChC,mBAAa,eAAe;AAC5B;AAAA,IACF;AAEA,iBAAa,cAAc,IAAI;AAAA,EACjC,GAAG,CAAC,QAAQ,aAAa,CAAC;AAE1B,SAAO;AACT;AAEO,SAAS,aAAa,EAAE,UAAU,KAAK,GAAiC;AAC7E,QAAM,CAAC,QAAQ,SAAS,IAAI,SAAiC,IAAI;AACjE,QAAM,YAAY,yBAAyB,EAAE,SAAS,OAAO,GAAG,EAAE,KAAK,CAAC;AAExE,SACE,iCACE;AAAA,wBAAC,UAAK,QAAM,MAAC,KAAK,WAAW,wCAAqC,IAAG;AAAA,IACpE,YAAY,aAAa,UAAU,SAAS,IAAI;AAAA,KACnD;AAEJ","sourcesContent":["'use client';\n\nimport {\n type ReactNode,\n type RefObject,\n useLayoutEffect,\n useState,\n} from 'react';\nimport { createPortal } from 'react-dom';\n\nexport interface UseRemotePortalContainerOptions {\n name?: string;\n}\n\nexport interface RemotePortalProps extends UseRemotePortalContainerOptions {\n children: ReactNode;\n}\n\nconst DEFAULT_PORTAL_CONTAINER_NAME = 'default';\n\nexport function useRemotePortalContainer(\n anchorRef: RefObject<Element | null>,\n options: UseRemotePortalContainerOptions = {},\n): HTMLElement | null {\n const [container, setContainer] = useState<HTMLElement | null>(null);\n const anchor = anchorRef.current;\n const containerName = options.name ?? DEFAULT_PORTAL_CONTAINER_NAME;\n\n useLayoutEffect(() => {\n if (!anchor) {\n return;\n }\n\n const ownerDocument = anchor.ownerDocument;\n const root = anchor.getRootNode();\n\n if (typeof ShadowRoot !== 'undefined' && root instanceof ShadowRoot) {\n const existingContainer = Array.from(\n root.querySelectorAll<HTMLElement>(\n '[data-remote-components-portal-container]',\n ),\n ).find(\n (element) =>\n element.getAttribute('data-remote-components-portal-container') ===\n containerName,\n );\n\n if (existingContainer) {\n setContainer(existingContainer);\n return;\n }\n\n const shadowContainer = ownerDocument.createElement('div');\n shadowContainer.setAttribute(\n 'data-remote-components-portal-container',\n containerName,\n );\n root.appendChild(shadowContainer);\n setContainer(shadowContainer);\n return;\n }\n\n setContainer(ownerDocument.body);\n }, [anchor, containerName]);\n\n return container;\n}\n\nexport function RemotePortal({ children, name }: RemotePortalProps): ReactNode {\n const [anchor, setAnchor] = useState<HTMLSpanElement | null>(null);\n const container = useRemotePortalContainer({ current: anchor }, { name });\n\n return (\n <>\n <span hidden ref={setAnchor} data-remote-components-portal-anchor=\"\" />\n {container ? createPortal(children, container) : null}\n </>\n );\n}\n"]}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { ReactNode, RefObject } from 'react';
|
|
2
|
+
|
|
3
|
+
interface UseRemotePortalContainerOptions {
|
|
4
|
+
name?: string;
|
|
5
|
+
}
|
|
6
|
+
interface RemotePortalProps extends UseRemotePortalContainerOptions {
|
|
7
|
+
children: ReactNode;
|
|
8
|
+
}
|
|
9
|
+
declare function useRemotePortalContainer(anchorRef: RefObject<Element | null>, options?: UseRemotePortalContainerOptions): HTMLElement | null;
|
|
10
|
+
declare function RemotePortal({ children, name }: RemotePortalProps): ReactNode;
|
|
11
|
+
|
|
12
|
+
export { RemotePortal, RemotePortalProps, UseRemotePortalContainerOptions, useRemotePortalContainer };
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
// src/remote/react/utils/portal.tsx
|
|
4
|
+
import {
|
|
5
|
+
useLayoutEffect,
|
|
6
|
+
useState
|
|
7
|
+
} from "react";
|
|
8
|
+
import { createPortal } from "react-dom";
|
|
9
|
+
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
10
|
+
var DEFAULT_PORTAL_CONTAINER_NAME = "default";
|
|
11
|
+
function useRemotePortalContainer(anchorRef, options = {}) {
|
|
12
|
+
const [container, setContainer] = useState(null);
|
|
13
|
+
const anchor = anchorRef.current;
|
|
14
|
+
const containerName = options.name ?? DEFAULT_PORTAL_CONTAINER_NAME;
|
|
15
|
+
useLayoutEffect(() => {
|
|
16
|
+
if (!anchor) {
|
|
17
|
+
return;
|
|
18
|
+
}
|
|
19
|
+
const ownerDocument = anchor.ownerDocument;
|
|
20
|
+
const root = anchor.getRootNode();
|
|
21
|
+
if (typeof ShadowRoot !== "undefined" && root instanceof ShadowRoot) {
|
|
22
|
+
const existingContainer = Array.from(
|
|
23
|
+
root.querySelectorAll(
|
|
24
|
+
"[data-remote-components-portal-container]"
|
|
25
|
+
)
|
|
26
|
+
).find(
|
|
27
|
+
(element) => element.getAttribute("data-remote-components-portal-container") === containerName
|
|
28
|
+
);
|
|
29
|
+
if (existingContainer) {
|
|
30
|
+
setContainer(existingContainer);
|
|
31
|
+
return;
|
|
32
|
+
}
|
|
33
|
+
const shadowContainer = ownerDocument.createElement("div");
|
|
34
|
+
shadowContainer.setAttribute(
|
|
35
|
+
"data-remote-components-portal-container",
|
|
36
|
+
containerName
|
|
37
|
+
);
|
|
38
|
+
root.appendChild(shadowContainer);
|
|
39
|
+
setContainer(shadowContainer);
|
|
40
|
+
return;
|
|
41
|
+
}
|
|
42
|
+
setContainer(ownerDocument.body);
|
|
43
|
+
}, [anchor, containerName]);
|
|
44
|
+
return container;
|
|
45
|
+
}
|
|
46
|
+
function RemotePortal({ children, name }) {
|
|
47
|
+
const [anchor, setAnchor] = useState(null);
|
|
48
|
+
const container = useRemotePortalContainer({ current: anchor }, { name });
|
|
49
|
+
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
50
|
+
/* @__PURE__ */ jsx("span", { hidden: true, ref: setAnchor, "data-remote-components-portal-anchor": "" }),
|
|
51
|
+
container ? createPortal(children, container) : null
|
|
52
|
+
] });
|
|
53
|
+
}
|
|
54
|
+
export {
|
|
55
|
+
RemotePortal,
|
|
56
|
+
useRemotePortalContainer
|
|
57
|
+
};
|
|
58
|
+
//# sourceMappingURL=portal.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../src/remote/react/utils/portal.tsx"],"sourcesContent":["'use client';\n\nimport {\n type ReactNode,\n type RefObject,\n useLayoutEffect,\n useState,\n} from 'react';\nimport { createPortal } from 'react-dom';\n\nexport interface UseRemotePortalContainerOptions {\n name?: string;\n}\n\nexport interface RemotePortalProps extends UseRemotePortalContainerOptions {\n children: ReactNode;\n}\n\nconst DEFAULT_PORTAL_CONTAINER_NAME = 'default';\n\nexport function useRemotePortalContainer(\n anchorRef: RefObject<Element | null>,\n options: UseRemotePortalContainerOptions = {},\n): HTMLElement | null {\n const [container, setContainer] = useState<HTMLElement | null>(null);\n const anchor = anchorRef.current;\n const containerName = options.name ?? DEFAULT_PORTAL_CONTAINER_NAME;\n\n useLayoutEffect(() => {\n if (!anchor) {\n return;\n }\n\n const ownerDocument = anchor.ownerDocument;\n const root = anchor.getRootNode();\n\n if (typeof ShadowRoot !== 'undefined' && root instanceof ShadowRoot) {\n const existingContainer = Array.from(\n root.querySelectorAll<HTMLElement>(\n '[data-remote-components-portal-container]',\n ),\n ).find(\n (element) =>\n element.getAttribute('data-remote-components-portal-container') ===\n containerName,\n );\n\n if (existingContainer) {\n setContainer(existingContainer);\n return;\n }\n\n const shadowContainer = ownerDocument.createElement('div');\n shadowContainer.setAttribute(\n 'data-remote-components-portal-container',\n containerName,\n );\n root.appendChild(shadowContainer);\n setContainer(shadowContainer);\n return;\n }\n\n setContainer(ownerDocument.body);\n }, [anchor, containerName]);\n\n return container;\n}\n\nexport function RemotePortal({ children, name }: RemotePortalProps): ReactNode {\n const [anchor, setAnchor] = useState<HTMLSpanElement | null>(null);\n const container = useRemotePortalContainer({ current: anchor }, { name });\n\n return (\n <>\n <span hidden ref={setAnchor} data-remote-components-portal-anchor=\"\" />\n {container ? createPortal(children, container) : null}\n </>\n );\n}\n"],"mappings":";;;AAEA;AAAA,EAGE;AAAA,EACA;AAAA,OACK;AACP,SAAS,oBAAoB;AAiEzB,mBACE,KADF;AAvDJ,IAAM,gCAAgC;AAE/B,SAAS,yBACd,WACA,UAA2C,CAAC,GACxB;AACpB,QAAM,CAAC,WAAW,YAAY,IAAI,SAA6B,IAAI;AACnE,QAAM,SAAS,UAAU;AACzB,QAAM,gBAAgB,QAAQ,QAAQ;AAEtC,kBAAgB,MAAM;AACpB,QAAI,CAAC,QAAQ;AACX;AAAA,IACF;AAEA,UAAM,gBAAgB,OAAO;AAC7B,UAAM,OAAO,OAAO,YAAY;AAEhC,QAAI,OAAO,eAAe,eAAe,gBAAgB,YAAY;AACnE,YAAM,oBAAoB,MAAM;AAAA,QAC9B,KAAK;AAAA,UACH;AAAA,QACF;AAAA,MACF,EAAE;AAAA,QACA,CAAC,YACC,QAAQ,aAAa,yCAAyC,MAC9D;AAAA,MACJ;AAEA,UAAI,mBAAmB;AACrB,qBAAa,iBAAiB;AAC9B;AAAA,MACF;AAEA,YAAM,kBAAkB,cAAc,cAAc,KAAK;AACzD,sBAAgB;AAAA,QACd;AAAA,QACA;AAAA,MACF;AACA,WAAK,YAAY,eAAe;AAChC,mBAAa,eAAe;AAC5B;AAAA,IACF;AAEA,iBAAa,cAAc,IAAI;AAAA,EACjC,GAAG,CAAC,QAAQ,aAAa,CAAC;AAE1B,SAAO;AACT;AAEO,SAAS,aAAa,EAAE,UAAU,KAAK,GAAiC;AAC7E,QAAM,CAAC,QAAQ,SAAS,IAAI,SAAiC,IAAI;AACjE,QAAM,YAAY,yBAAyB,EAAE,SAAS,OAAO,GAAG,EAAE,KAAK,CAAC;AAExE,SACE,iCACE;AAAA,wBAAC,UAAK,QAAM,MAAC,KAAK,WAAW,wCAAqC,IAAG;AAAA,IACpE,YAAY,aAAa,UAAU,SAAS,IAAI;AAAA,KACnD;AAEJ;","names":[]}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
2
|
import { ScriptDescriptor, LinkDescriptor } from './internal/host/shared/asset-descriptors.js';
|
|
3
3
|
import { ShadowDomConfig } from './internal/host/shared/config.js';
|
|
4
|
+
import { NextImageDeploymentId } from './internal/host/shared/next-image-deployment-id.js';
|
|
4
5
|
import { RemoteSharedModules } from './internal/host/shared/shared-broker.js';
|
|
5
6
|
import { RemoteComponentMetadata } from './internal/runtime/metadata.js';
|
|
6
7
|
|
|
@@ -41,6 +42,7 @@ interface ConsumeServerData extends ConsumeLoaderPayload, ShadowDomConfig {
|
|
|
41
42
|
serverUrl: string;
|
|
42
43
|
links?: LinkDescriptor[];
|
|
43
44
|
type?: RemoteComponentMetadata['type'];
|
|
45
|
+
ssrImageDeploymentIds?: NextImageDeploymentId[];
|
|
44
46
|
children: React.ReactNode;
|
|
45
47
|
}
|
|
46
48
|
|
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
import {
|
|
2
2
|
setupRemoteScope
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-YKCU7RFM.js";
|
|
4
4
|
import {
|
|
5
5
|
applySharedModules,
|
|
6
6
|
initializeSharedModules,
|
|
7
7
|
nextClientPagesLoader
|
|
8
|
-
} from "./chunk-
|
|
8
|
+
} from "./chunk-GG32LZD3.js";
|
|
9
9
|
import {
|
|
10
10
|
buildCoreShared,
|
|
11
11
|
buildHostShared
|
|
12
|
-
} from "./chunk-
|
|
12
|
+
} from "./chunk-WWHNG5YP.js";
|
|
13
13
|
import "./chunk-D5GNZB6O.js";
|
|
14
14
|
import "./chunk-STIJO4AG.js";
|
|
15
15
|
import "./chunk-ULXU6XWH.js";
|
|
@@ -53,4 +53,4 @@ async function turbopackRuntime(url, bundle, shared, remoteShared, resolveClient
|
|
|
53
53
|
export {
|
|
54
54
|
turbopackRuntime
|
|
55
55
|
};
|
|
56
|
-
//# sourceMappingURL=turbopack-
|
|
56
|
+
//# sourceMappingURL=turbopack-HK7DVYUG.js.map
|
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { newObj[key] = obj[key]; } } } newObj.default = obj; return newObj; } } function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } }
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var _chunkTIS6PXSQcjs = require('./chunk-TIS6PXSQ.cjs');
|
|
4
4
|
|
|
5
5
|
|
|
6
6
|
|
|
7
7
|
|
|
8
|
-
var
|
|
8
|
+
var _chunkJKDPK6L5cjs = require('./chunk-JKDPK6L5.cjs');
|
|
9
9
|
|
|
10
10
|
|
|
11
11
|
|
|
12
|
-
var
|
|
12
|
+
var _chunkZPJ5J24Tcjs = require('./chunk-ZPJ5J24T.cjs');
|
|
13
13
|
require('./chunk-Z2SLBFQL.cjs');
|
|
14
14
|
require('./chunk-5KTAEO52.cjs');
|
|
15
15
|
require('./chunk-BBXVML3D.cjs');
|
|
@@ -19,15 +19,15 @@ require('./chunk-SHFJ5OQA.cjs');
|
|
|
19
19
|
// src/host/html/runtime/turbopack.ts
|
|
20
20
|
async function turbopackRuntime(url, bundle, shared, remoteShared, resolveClientUrl) {
|
|
21
21
|
const self = globalThis;
|
|
22
|
-
const hostShared =
|
|
22
|
+
const hostShared = _chunkZPJ5J24Tcjs.buildHostShared.call(void 0, shared, resolveClientUrl, {
|
|
23
23
|
includePagesClientSharedGlobal: true
|
|
24
24
|
});
|
|
25
|
-
await
|
|
25
|
+
await _chunkTIS6PXSQcjs.setupRemoteScope.call(void 0, "turbopack", [], url, bundle, resolveClientUrl);
|
|
26
26
|
const {
|
|
27
27
|
default: { createFromReadableStream }
|
|
28
28
|
} = await Promise.resolve().then(() => _interopRequireWildcard(require("react-server-dom-webpack/client.browser")));
|
|
29
29
|
async function preloadScripts(scripts, __) {
|
|
30
|
-
const scope = await
|
|
30
|
+
const scope = await _chunkTIS6PXSQcjs.setupRemoteScope.call(void 0,
|
|
31
31
|
"turbopack",
|
|
32
32
|
scripts.map((script) => ({
|
|
33
33
|
src: script.getAttribute("src") || script.getAttribute("data-src") || script.src
|
|
@@ -36,21 +36,21 @@ async function turbopackRuntime(url, bundle, shared, remoteShared, resolveClient
|
|
|
36
36
|
bundle,
|
|
37
37
|
resolveClientUrl
|
|
38
38
|
);
|
|
39
|
-
await
|
|
39
|
+
await _chunkJKDPK6L5cjs.initializeSharedModules.call(void 0,
|
|
40
40
|
scope,
|
|
41
|
-
|
|
41
|
+
_chunkZPJ5J24Tcjs.buildCoreShared.call(void 0, hostShared),
|
|
42
42
|
_nullishCoalesce(remoteShared, () => ( {}))
|
|
43
43
|
);
|
|
44
44
|
}
|
|
45
45
|
return {
|
|
46
46
|
self,
|
|
47
47
|
createFromReadableStream,
|
|
48
|
-
applySharedModules:
|
|
49
|
-
nextClientPagesLoader:
|
|
48
|
+
applySharedModules: _chunkJKDPK6L5cjs.applySharedModules,
|
|
49
|
+
nextClientPagesLoader: _chunkJKDPK6L5cjs.nextClientPagesLoader,
|
|
50
50
|
preloadScripts
|
|
51
51
|
};
|
|
52
52
|
}
|
|
53
53
|
|
|
54
54
|
|
|
55
55
|
exports.turbopackRuntime = turbopackRuntime;
|
|
56
|
-
//# sourceMappingURL=turbopack-
|
|
56
|
+
//# sourceMappingURL=turbopack-YZOIO55D.cjs.map
|
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
import {
|
|
2
2
|
loadScripts
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-XLGLCKZZ.js";
|
|
4
4
|
import {
|
|
5
5
|
applySharedModules,
|
|
6
6
|
buildWebpackResolve,
|
|
7
7
|
nextClientPagesLoader
|
|
8
|
-
} from "./chunk-
|
|
8
|
+
} from "./chunk-GG32LZD3.js";
|
|
9
9
|
import {
|
|
10
10
|
NEXT_BUNDLE_PATH_RE,
|
|
11
11
|
buildHostShared
|
|
12
|
-
} from "./chunk-
|
|
12
|
+
} from "./chunk-WWHNG5YP.js";
|
|
13
13
|
import "./chunk-D5GNZB6O.js";
|
|
14
14
|
import "./chunk-STIJO4AG.js";
|
|
15
15
|
import {
|
|
@@ -92,4 +92,4 @@ async function webpackRuntime(bundle, shared, remoteShared, resolveClientUrl) {
|
|
|
92
92
|
export {
|
|
93
93
|
webpackRuntime
|
|
94
94
|
};
|
|
95
|
-
//# sourceMappingURL=webpack-
|
|
95
|
+
//# sourceMappingURL=webpack-2HP73JL7.js.map
|
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { newObj[key] = obj[key]; } } } newObj.default = obj; return newObj; } } function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var _chunkMAVMKFFLcjs = require('./chunk-MAVMKFFL.cjs');
|
|
4
4
|
|
|
5
5
|
|
|
6
6
|
|
|
7
7
|
|
|
8
|
-
var
|
|
8
|
+
var _chunkJKDPK6L5cjs = require('./chunk-JKDPK6L5.cjs');
|
|
9
9
|
|
|
10
10
|
|
|
11
11
|
|
|
12
|
-
var
|
|
12
|
+
var _chunkZPJ5J24Tcjs = require('./chunk-ZPJ5J24T.cjs');
|
|
13
13
|
require('./chunk-Z2SLBFQL.cjs');
|
|
14
14
|
require('./chunk-5KTAEO52.cjs');
|
|
15
15
|
|
|
@@ -58,15 +58,15 @@ async function webpackRuntime(bundle, shared, remoteShared, resolveClientUrl) {
|
|
|
58
58
|
return [];
|
|
59
59
|
return [
|
|
60
60
|
{
|
|
61
|
-
src: new URL(scriptSrc.replace(
|
|
61
|
+
src: new URL(scriptSrc.replace(_chunkZPJ5J24Tcjs.NEXT_BUNDLE_PATH_RE, "/_next/"), url).href
|
|
62
62
|
}
|
|
63
63
|
];
|
|
64
64
|
});
|
|
65
|
-
await
|
|
66
|
-
const hostShared =
|
|
65
|
+
await _chunkMAVMKFFLcjs.loadScripts.call(void 0, scriptSrcs, resolveClientUrl);
|
|
66
|
+
const hostShared = _chunkZPJ5J24Tcjs.buildHostShared.call(void 0, shared, resolveClientUrl, {
|
|
67
67
|
includePagesClientSharedGlobal: true
|
|
68
68
|
});
|
|
69
|
-
const resolve = await
|
|
69
|
+
const resolve = await _chunkJKDPK6L5cjs.buildWebpackResolve.call(void 0,
|
|
70
70
|
hostShared,
|
|
71
71
|
_nullishCoalesce(remoteShared, () => ( {})),
|
|
72
72
|
remoteBundle,
|
|
@@ -79,17 +79,17 @@ async function webpackRuntime(bundle, shared, remoteShared, resolveClientUrl) {
|
|
|
79
79
|
},
|
|
80
80
|
"WebpackRuntime"
|
|
81
81
|
);
|
|
82
|
-
|
|
82
|
+
_chunkJKDPK6L5cjs.applySharedModules.call(void 0, remoteBundle, resolve);
|
|
83
83
|
}
|
|
84
84
|
return {
|
|
85
85
|
self,
|
|
86
86
|
createFromReadableStream,
|
|
87
|
-
applySharedModules:
|
|
88
|
-
nextClientPagesLoader:
|
|
87
|
+
applySharedModules: _chunkJKDPK6L5cjs.applySharedModules,
|
|
88
|
+
nextClientPagesLoader: _chunkJKDPK6L5cjs.nextClientPagesLoader,
|
|
89
89
|
preloadScripts
|
|
90
90
|
};
|
|
91
91
|
}
|
|
92
92
|
|
|
93
93
|
|
|
94
94
|
exports.webpackRuntime = webpackRuntime;
|
|
95
|
-
//# sourceMappingURL=webpack-
|
|
95
|
+
//# sourceMappingURL=webpack-W2MODB73.cjs.map
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "remote-components",
|
|
3
|
-
"version": "0.4.
|
|
3
|
+
"version": "0.4.14",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "Compose remote components at runtime between microfrontends applications.",
|
|
6
6
|
"keywords": [
|
|
@@ -86,11 +86,21 @@
|
|
|
86
86
|
"require": "./dist/remote/html.cjs",
|
|
87
87
|
"default": "./dist/remote/html.js"
|
|
88
88
|
},
|
|
89
|
+
"./remote/react/utils/portal": {
|
|
90
|
+
"import": "./dist/remote/react/utils/portal.js",
|
|
91
|
+
"require": "./dist/remote/react/utils/portal.cjs",
|
|
92
|
+
"default": "./dist/remote/react/utils/portal.js"
|
|
93
|
+
},
|
|
89
94
|
"./config/nextjs": {
|
|
90
95
|
"import": "./dist/config/nextjs.js",
|
|
91
96
|
"require": "./dist/config/nextjs.cjs",
|
|
92
97
|
"default": "./dist/config/nextjs.js"
|
|
93
98
|
},
|
|
99
|
+
"./config/tailwind": {
|
|
100
|
+
"import": "./dist/config/tailwind.js",
|
|
101
|
+
"require": "./dist/config/tailwind.cjs",
|
|
102
|
+
"default": "./dist/config/tailwind.js"
|
|
103
|
+
},
|
|
94
104
|
"./config/webpack": {
|
|
95
105
|
"import": "./dist/config/webpack.js",
|
|
96
106
|
"require": "./dist/config/webpack.cjs",
|
|
@@ -159,9 +169,15 @@
|
|
|
159
169
|
"remote/html": [
|
|
160
170
|
"./dist/remote/html.d.ts"
|
|
161
171
|
],
|
|
172
|
+
"remote/react/utils/portal": [
|
|
173
|
+
"./dist/remote/react/utils/portal.d.ts"
|
|
174
|
+
],
|
|
162
175
|
"config/nextjs": [
|
|
163
176
|
"./dist/config/nextjs.d.ts"
|
|
164
177
|
],
|
|
178
|
+
"config/tailwind": [
|
|
179
|
+
"./dist/config/tailwind.d.ts"
|
|
180
|
+
],
|
|
165
181
|
"config/webpack": [
|
|
166
182
|
"./dist/config/webpack.d.ts"
|
|
167
183
|
],
|
|
@@ -210,6 +226,7 @@
|
|
|
210
226
|
"@types/react-dom": "^19.2.3",
|
|
211
227
|
"jsdom": "^26.0.0",
|
|
212
228
|
"next": "^16.1.3",
|
|
229
|
+
"postcss": "^8",
|
|
213
230
|
"react": "^19.2.3",
|
|
214
231
|
"react-dom": "^19.2.3",
|
|
215
232
|
"ts-json-schema-generator": "^1.1.2",
|