remote-components 0.0.23 → 0.0.25

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.
Files changed (74) hide show
  1. package/dist/html/host.cjs +329 -92
  2. package/dist/html/host.cjs.map +1 -1
  3. package/dist/html/host.js +332 -92
  4. package/dist/html/host.js.map +1 -1
  5. package/dist/internal/next/host/app-router-client.cjs +180 -71
  6. package/dist/internal/next/host/app-router-client.cjs.map +1 -1
  7. package/dist/internal/next/host/app-router-client.js +188 -72
  8. package/dist/internal/next/host/app-router-client.js.map +1 -1
  9. package/dist/internal/next/host/app-router-compat.cjs +114 -0
  10. package/dist/internal/next/host/app-router-compat.cjs.map +1 -0
  11. package/dist/internal/next/host/app-router-compat.d.ts +31 -0
  12. package/dist/internal/next/host/app-router-compat.js +79 -0
  13. package/dist/internal/next/host/app-router-compat.js.map +1 -0
  14. package/dist/internal/next/remote/render-client.cjs +10 -2
  15. package/dist/internal/next/remote/render-client.cjs.map +1 -1
  16. package/dist/internal/next/remote/render-client.js +10 -2
  17. package/dist/internal/next/remote/render-client.js.map +1 -1
  18. package/dist/internal/shared/client/apply-origin.cjs +61 -0
  19. package/dist/internal/shared/client/apply-origin.cjs.map +1 -0
  20. package/dist/internal/shared/client/apply-origin.d.ts +3 -0
  21. package/dist/internal/shared/client/apply-origin.js +37 -0
  22. package/dist/internal/shared/client/apply-origin.js.map +1 -0
  23. package/dist/internal/shared/client/polyfill.cjs +149 -0
  24. package/dist/internal/shared/client/polyfill.cjs.map +1 -0
  25. package/dist/internal/shared/client/polyfill.d.ts +6 -0
  26. package/dist/internal/shared/client/polyfill.js +124 -0
  27. package/dist/internal/shared/client/polyfill.js.map +1 -0
  28. package/dist/internal/shared/client/remote-component.cjs +20 -13
  29. package/dist/internal/shared/client/remote-component.cjs.map +1 -1
  30. package/dist/internal/shared/client/remote-component.d.ts +4 -3
  31. package/dist/internal/shared/client/remote-component.js +20 -13
  32. package/dist/internal/shared/client/remote-component.js.map +1 -1
  33. package/dist/internal/shared/ssr/dom-flight.cjs +40 -0
  34. package/dist/internal/shared/ssr/dom-flight.cjs.map +1 -1
  35. package/dist/internal/shared/ssr/dom-flight.js +40 -0
  36. package/dist/internal/shared/ssr/dom-flight.js.map +1 -1
  37. package/dist/internal/shared/ssr/fetch-remote-component.cjs +1 -1
  38. package/dist/internal/shared/ssr/fetch-remote-component.cjs.map +1 -1
  39. package/dist/internal/shared/ssr/fetch-remote-component.d.ts +6 -0
  40. package/dist/internal/shared/ssr/fetch-remote-component.js +1 -1
  41. package/dist/internal/shared/ssr/fetch-remote-component.js.map +1 -1
  42. package/dist/internal/shared/utils.cjs +31 -0
  43. package/dist/internal/shared/utils.cjs.map +1 -0
  44. package/dist/internal/shared/utils.d.ts +3 -0
  45. package/dist/internal/shared/utils.js +7 -0
  46. package/dist/internal/shared/utils.js.map +1 -0
  47. package/dist/next/config.cjs +50 -28
  48. package/dist/next/config.cjs.map +1 -1
  49. package/dist/next/config.js +50 -28
  50. package/dist/next/config.js.map +1 -1
  51. package/dist/next/host/client/index.cjs +16 -1
  52. package/dist/next/host/client/index.cjs.map +1 -1
  53. package/dist/next/host/client/index.js +16 -1
  54. package/dist/next/host/client/index.js.map +1 -1
  55. package/dist/next/host/pages-router-server.cjs +27 -13
  56. package/dist/next/host/pages-router-server.cjs.map +1 -1
  57. package/dist/next/host/pages-router-server.js +27 -13
  58. package/dist/next/host/pages-router-server.js.map +1 -1
  59. package/dist/next/middleware.cjs +5 -2
  60. package/dist/next/middleware.cjs.map +1 -1
  61. package/dist/next/middleware.d.ts +1 -0
  62. package/dist/next/middleware.js +5 -2
  63. package/dist/next/middleware.js.map +1 -1
  64. package/dist/next/remote/pages-router.cjs +3 -1
  65. package/dist/next/remote/pages-router.cjs.map +1 -1
  66. package/dist/next/remote/pages-router.d.ts +1 -0
  67. package/dist/next/remote/pages-router.js +3 -1
  68. package/dist/next/remote/pages-router.js.map +1 -1
  69. package/dist/react/index.cjs +213 -161
  70. package/dist/react/index.cjs.map +1 -1
  71. package/dist/react/index.d.ts +2 -1
  72. package/dist/react/index.js +202 -150
  73. package/dist/react/index.js.map +1 -1
  74. package/package.json +1 -1
@@ -1,12 +1,22 @@
1
1
  "use client";
2
2
  import { Fragment, jsx, jsxs } from "react/jsx-runtime";
3
- import { useEffect, useState, useLayoutEffect, useRef } from "react";
3
+ import {
4
+ useId,
5
+ useEffect,
6
+ useLayoutEffect,
7
+ useRef,
8
+ useState,
9
+ startTransition
10
+ } from "react";
4
11
  import { createPortal } from "react-dom";
12
+ import * as Image from "next/image";
5
13
  import {
6
14
  loadRemoteComponent,
7
15
  DEFAULT_ROUTE,
8
16
  RUNTIME_WEBPACK
9
17
  } from "#internal/shared/client/remote-component";
18
+ import { imageImpl, routerImpl } from "#internal/next/host/app-router-compat";
19
+ import { escapeString } from "#internal/shared/utils";
10
20
  async function tryImportShared() {
11
21
  try {
12
22
  const { shared } = await import("@remote-components/shared/host/app");
@@ -31,12 +41,14 @@ function RemoteComponentClient({
31
41
  reset,
32
42
  children
33
43
  }) {
44
+ const remoteComponentId = useId();
34
45
  const [component, setComponent] = useState(null);
35
46
  const metadataRef = useRef({
36
47
  name,
37
48
  bundle,
38
49
  route,
39
- url
50
+ url,
51
+ loading: false
40
52
  });
41
53
  if (component instanceof Error) {
42
54
  throw component;
@@ -45,15 +57,30 @@ function RemoteComponentClient({
45
57
  // we don't use the provided static HTML
46
58
  // to mitigate layout shift when loading CSS using JavaScript on the client
47
59
  nextData?.buildId !== "development";
48
- const [shadowRoot, setShadowRoot] = useState(null);
60
+ const self = globalThis;
61
+ const shadowRootKey = `__remote_components_shadowroot_${escapeString(new URL(url).href)}_${escapeString(name)}`;
62
+ const shadowContainerRef = useRef(
63
+ typeof document === "undefined" ? null : document.querySelector(
64
+ `[data-remote-component-id="shadowroot_${remoteComponentId}"]`
65
+ )
66
+ );
67
+ const shadowRootRef = useRef(
68
+ self[shadowRootKey] ?? shadowContainerRef.current?.shadowRoot ?? null
69
+ );
70
+ const ssrShadowRootContentRef = useRef(
71
+ shadowRootRef.current?.querySelectorAll("*") ?? null
72
+ );
73
+ const ssrLinksStylesRef = useRef([]);
74
+ if (self[shadowRootKey] && shadowRootRef.current) {
75
+ self[shadowRootKey] = null;
76
+ }
49
77
  useLayoutEffect(() => {
50
- if (isolate !== false && typeof document !== "undefined" && !shadowRoot) {
78
+ if (!shadowContainerRef.current || shadowContainerRef.current !== shadowRootRef.current?.host) {
79
+ shadowRootRef.current = null;
80
+ }
81
+ if (isolate !== false && typeof document !== "undefined" && !shadowRootRef.current) {
51
82
  let shadowRootElement = null;
52
- const element = document.getElementById(
53
- `shadowroot_${new URL(url).href.replace(/[^a-z0-9]/g, "_")}_${name.replace(/[^a-z0-9]/g, "_")}`
54
- );
55
- const self = globalThis;
56
- const shadowRootKey = `__remote_components_shadowroot_${new URL(url).href.replace(/[^a-z0-9]/g, "_")}_${name.replace(/[^a-z0-9]/g, "_")}`;
83
+ const element = shadowContainerRef.current;
57
84
  shadowRootElement = self[shadowRootKey] ?? element?.shadowRoot ?? null;
58
85
  self[shadowRootKey] = null;
59
86
  if (!shadowRootElement && element) {
@@ -63,51 +90,100 @@ function RemoteComponentClient({
63
90
  }
64
91
  }
65
92
  if (shadowRootElement) {
66
- shadowRootElement.querySelectorAll("*:not(link)").forEach((node) => {
67
- node.remove();
93
+ shadowRootRef.current = shadowRootElement;
94
+ }
95
+ }
96
+ if (shadowRootRef.current && ssrShadowRootContentRef.current && !shouldUseChildren) {
97
+ ssrShadowRootContentRef.current.forEach((node) => {
98
+ if (node.nodeName !== "LINK" && node.nodeName !== "STYLE") {
99
+ node.parentNode?.removeChild(node);
100
+ } else {
101
+ ssrLinksStylesRef.current.push(
102
+ node
103
+ );
104
+ }
105
+ });
106
+ ssrShadowRootContentRef.current = null;
107
+ }
108
+ if (ssrLinksStylesRef.current.length > 0 && shadowRootRef.current) {
109
+ const waitForLoad = shadowRootRef.current.querySelectorAll("link[data-wait]");
110
+ if (waitForLoad.length > 0) {
111
+ Promise.all(
112
+ Array.from(waitForLoad).map(
113
+ (link) => new Promise((resolve) => {
114
+ link.addEventListener("load", () => resolve());
115
+ link.addEventListener("error", () => resolve());
116
+ })
117
+ )
118
+ ).then(() => {
119
+ waitForLoad.forEach((el) => {
120
+ el.removeAttribute("data-wait");
121
+ });
122
+ ssrLinksStylesRef.current.forEach((el) => {
123
+ el.parentNode?.removeChild(el);
124
+ });
125
+ ssrLinksStylesRef.current = [];
126
+ }).catch((e) => {
127
+ console.error(e);
68
128
  });
69
- setShadowRoot(shadowRootElement);
70
129
  }
71
130
  }
72
- }, [name, isolate, shadowRoot, links, url, mode]);
131
+ }, [
132
+ name,
133
+ isolate,
134
+ links,
135
+ url,
136
+ mode,
137
+ self,
138
+ shadowRootKey,
139
+ shouldUseChildren,
140
+ remoteComponentId
141
+ ]);
73
142
  useEffect(() => {
74
- let mounted = true;
75
- if (!component && (isolate === false || shadowRoot) || metadataRef.current.url !== url || metadataRef.current.name !== name || metadataRef.current.bundle !== bundle || metadataRef.current.route !== route) {
76
- metadataRef.current = {
77
- name,
78
- bundle,
79
- route,
80
- url
81
- };
82
- loadRemoteComponent({
83
- url: new URL(url, location.origin),
84
- name,
85
- bundle,
86
- route,
87
- runtime,
88
- data,
89
- nextData,
90
- scripts,
91
- shared: tryImportShared(),
92
- remoteShared,
93
- container: shadowRoot
94
- }).then((result) => {
95
- if (mounted) {
143
+ startTransition(async () => {
144
+ try {
145
+ if (!metadataRef.current.loading && !component && (isolate === false || shadowRootRef.current) || metadataRef.current.url !== url || metadataRef.current.name !== name || metadataRef.current.bundle !== bundle || metadataRef.current.route !== route) {
146
+ metadataRef.current = {
147
+ name,
148
+ bundle,
149
+ route,
150
+ url,
151
+ loading: true
152
+ };
153
+ const rscName = `__remote_components_rsc_${escapeString(new URL(url).href)}_${escapeString(name)}`;
154
+ const result = await loadRemoteComponent({
155
+ url: new URL(url, location.origin),
156
+ name,
157
+ bundle,
158
+ route,
159
+ runtime,
160
+ rscName,
161
+ data,
162
+ nextData,
163
+ scripts,
164
+ shared: (async () => {
165
+ return {
166
+ "next/router": routerImpl,
167
+ ...await tryImportShared(),
168
+ "next/image": () => Promise.resolve(imageImpl(Image.default, bundle)),
169
+ "next/dist/client/image-component": () => Promise.resolve({ Image: imageImpl(Image.default, bundle) })
170
+ };
171
+ })(),
172
+ remoteShared,
173
+ container: shadowRootRef.current
174
+ });
175
+ metadataRef.current.loading = false;
96
176
  if (result.error) {
97
177
  setComponent(result.error);
98
178
  } else {
99
179
  setComponent(result.component);
100
180
  }
101
181
  }
102
- }).catch((error) => {
103
- if (mounted) {
104
- setComponent(error);
105
- }
106
- });
107
- }
108
- return () => {
109
- mounted = false;
110
- };
182
+ } catch (error) {
183
+ metadataRef.current.loading = false;
184
+ setComponent(error);
185
+ }
186
+ });
111
187
  }, [
112
188
  url,
113
189
  component,
@@ -121,30 +197,75 @@ function RemoteComponentClient({
121
197
  remoteShared,
122
198
  children,
123
199
  links,
124
- isolate,
125
- shadowRoot
200
+ isolate
126
201
  ]);
127
- const resetStyle = reset ? /* @__PURE__ */ jsx("style", { "data-remote-components-reset": true, children: `:host { all: initial; }` }) : null;
128
- let componentToRender = /* @__PURE__ */ jsx(Fragment, { children: shouldUseChildren ? children : component });
129
- let linksToRender = links.map((link) => /* @__PURE__ */ jsx(
130
- "link",
131
- {
132
- as: link.as,
133
- href: new URL(link.href, url || location.origin).href,
134
- rel: link.rel
135
- },
136
- `${link.href}_${link.rel}`
137
- ));
202
+ if (nextData?.buildId === "development" && shadowRootRef.current && isolate !== false && reset && !shadowRootRef.current.querySelector("[data-remote-components-reset]")) {
203
+ const style = document.createElement("style");
204
+ style.setAttribute("data-remote-components-reset", "");
205
+ style.textContent = `:host { all: initial; }`;
206
+ shadowRootRef.current.insertBefore(style, shadowRootRef.current.firstChild);
207
+ } else if (shadowRootRef.current && isolate !== false && !reset && shadowRootRef.current.querySelector("[data-remote-components-reset]")) {
208
+ const style = shadowRootRef.current.querySelector(
209
+ "[data-remote-components-reset]"
210
+ );
211
+ if (style && shadowRootRef.current.firstChild !== style) {
212
+ shadowRootRef.current.removeChild(style);
213
+ }
214
+ }
215
+ const linksToRender = /* @__PURE__ */ jsxs(Fragment, { children: [
216
+ (!nextData || nextData.buildId !== "development") && isolate !== false && reset ? /* @__PURE__ */ jsx("style", { "data-remote-components-reset": "", children: `:host { all: initial; }` }) : null,
217
+ links.map((link) => /* @__PURE__ */ jsx(
218
+ "link",
219
+ {
220
+ ...Object.entries(link).reduce(
221
+ (acc, [key, value]) => {
222
+ if (key !== "href" && key !== "precedence" && typeof value === "string") {
223
+ acc[key] = value;
224
+ }
225
+ return acc;
226
+ },
227
+ {}
228
+ ),
229
+ "data-wait": link.rel === "stylesheet" && link.href ? "" : void 0,
230
+ href: new URL(link.href, url).href
231
+ },
232
+ JSON.stringify(link)
233
+ )),
234
+ links.filter((link) => link.rel === "stylesheet").map((link) => /* @__PURE__ */ jsx(
235
+ "link",
236
+ {
237
+ ...Object.entries(link).reduce(
238
+ (acc, [key, value]) => {
239
+ if (key !== "href" && key !== "precedence" && typeof value === "string") {
240
+ acc[key] = value;
241
+ }
242
+ return acc;
243
+ },
244
+ {}
245
+ ),
246
+ as: "style",
247
+ fetchPriority: "high",
248
+ href: new URL(link.href, url).href,
249
+ precedence: bundle,
250
+ rel: "preload"
251
+ },
252
+ JSON.stringify(link)
253
+ ))
254
+ ] });
255
+ let componentToRender = shouldUseChildren ? /* @__PURE__ */ jsx(Fragment, { children }) : component;
138
256
  if (isolate !== false) {
139
257
  componentToRender = /* @__PURE__ */ jsxs(
140
258
  "div",
141
259
  {
142
- id: `shadowroot_${new URL(url).href.replace(/[^a-z0-9]/g, "_")}_${name.replace(/[^a-z0-9]/g, "_")}`,
260
+ "data-remote-component-id": `shadowroot_${remoteComponentId}`,
261
+ "data-remote-component-isolation-root": "",
262
+ id: `shadowroot_${name}`,
263
+ ref: shadowContainerRef,
143
264
  children: [
144
265
  typeof document === "undefined" ? (
145
266
  // eslint-disable-next-line react/no-unknown-property
146
267
  /* @__PURE__ */ jsxs("template", { shadowrootmode: mode, children: [
147
- /* @__PURE__ */ jsx(
268
+ mode === "closed" ? /* @__PURE__ */ jsx(
148
269
  "div",
149
270
  {
150
271
  dangerouslySetInnerHTML: {
@@ -153,42 +274,37 @@ function RemoteComponentClient({
153
274
  src="data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///ywAAAAAAQABAAACAUwAOw=="
154
275
  onload="(function(el){
155
276
  const root = el.getRootNode();
156
- globalThis.__remote_components_shadowroot_${new URL(url).href.replace(/[^a-z0-9]/g, "_")}_${name.replace(/[^a-z0-9]/g, "_")} = root;
277
+ globalThis.__remote_components_shadowroot_${escapeString(new URL(url).href)}_${escapeString(name)} = root;
157
278
  el.parentElement.remove();
158
279
  })(this)"
159
280
  />`
160
281
  }
161
282
  }
162
- ),
163
- resetStyle,
283
+ ) : null,
164
284
  linksToRender,
165
- componentToRender
285
+ shouldUseChildren ? children : null
166
286
  ] })
167
287
  ) : null,
168
- shadowRoot ? createPortal(
169
- shadowRoot.querySelectorAll("link").length !== links.length ? /* @__PURE__ */ jsxs(Fragment, { children: [
170
- resetStyle,
288
+ typeof document !== "undefined" && shadowRootRef.current && !shouldUseChildren ? createPortal(
289
+ /* @__PURE__ */ jsxs(Fragment, { children: [
171
290
  linksToRender,
172
291
  componentToRender
173
- ] }) : /* @__PURE__ */ jsxs(Fragment, { children: [
174
- resetStyle,
175
- componentToRender
176
292
  ] }),
177
- shadowRoot
293
+ shadowRootRef.current
178
294
  ) : null
179
295
  ]
180
296
  }
181
297
  );
182
- linksToRender = null;
183
298
  }
184
299
  return /* @__PURE__ */ jsxs(Fragment, { children: [
300
+ isolate === false ? /* @__PURE__ */ jsx("template", { id: `${name}_start` }) : null,
185
301
  /* @__PURE__ */ jsx("script", { "data-remote-component": true, type: "application/json", children: JSON.stringify({
186
302
  name,
187
303
  bundle,
188
304
  route,
189
305
  runtime
190
306
  }) }),
191
- linksToRender,
307
+ isolate === false ? linksToRender : null,
192
308
  componentToRender,
193
309
  nextData ? /* @__PURE__ */ jsx(
194
310
  "script",
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../src/next/host/app-router-client.tsx"],"sourcesContent":["'use client';\n\nimport { useEffect, useState, useLayoutEffect, useRef } from 'react';\nimport { createPortal } from 'react-dom';\nimport {\n loadRemoteComponent,\n DEFAULT_ROUTE,\n RUNTIME_WEBPACK,\n} from '#internal/shared/client/remote-component';\nimport type { RemoteComponentProps } from '#internal/shared/client/remote-component';\n\n// patch react/jsx-runtime to support the shadowrootmode attribute on template elements\ndeclare module 'react/jsx-runtime' {\n // eslint-disable-next-line @typescript-eslint/no-namespace\n export namespace JSX {\n interface IntrinsicElements {\n template: {\n shadowrootmode?: 'open' | 'closed';\n id?: string;\n ref?: React.Ref<HTMLTemplateElement>;\n dangerouslySetInnerHTML?: {\n __html: string;\n };\n children?: React.ReactNode;\n };\n }\n }\n}\n\n// import { shared } from '@remote-components/shared/host';\nasync function tryImportShared() {\n try {\n const { shared } = await import('@remote-components/shared/host/app');\n return shared;\n } catch {\n return {};\n }\n}\n\n/**\n * RemoteComponentClient - Main component for rendering remote components\n *\n * This component handles the loading and rendering of remote microfrontends.\n * It supports both RSC (React Server Components) and Next.js Pages Router based components.\n */\nexport function RemoteComponentClient({\n url,\n name,\n bundle,\n route = DEFAULT_ROUTE,\n runtime = RUNTIME_WEBPACK,\n data,\n nextData,\n scripts = [],\n links = [],\n remoteShared = {},\n isolate,\n mode = 'open',\n reset,\n children,\n}: RemoteComponentProps) {\n const [component, setComponent] = useState<React.ReactNode | Error>(null);\n const metadataRef = useRef<{\n name: string;\n bundle: string;\n route: string;\n url: string;\n }>({\n name,\n bundle,\n route,\n url,\n });\n\n // Handle errors by re-throwing them\n if (component instanceof Error) {\n throw component;\n }\n\n // determine whether to use children or loaded component\n const shouldUseChildren =\n (!component ||\n (component &&\n !nextData &&\n typeof (component as unknown as Promise<unknown>).then !==\n 'function')) &&\n // if the remote Next.js Pages Router application is in development mode\n // we don't use the provided static HTML\n // to mitigate layout shift when loading CSS using JavaScript on the client\n nextData?.buildId !== 'development';\n\n const [shadowRoot, setShadowRoot] = useState<ShadowRoot | null>(null);\n\n useLayoutEffect(() => {\n if (isolate !== false && typeof document !== 'undefined' && !shadowRoot) {\n let shadowRootElement: ShadowRoot | null = null;\n const element = document.getElementById(\n `shadowroot_${new URL(url).href.replace(/[^a-z0-9]/g, '_')}_${name.replace(/[^a-z0-9]/g, '_')}`,\n );\n const self = globalThis as Record<\n `__remote_components_shadowroot_${string}`,\n ShadowRoot | null\n >;\n const shadowRootKey =\n `__remote_components_shadowroot_${new URL(url).href.replace(/[^a-z0-9]/g, '_')}_${name.replace(/[^a-z0-9]/g, '_')}` as const;\n shadowRootElement = self[shadowRootKey] ?? element?.shadowRoot ?? null;\n self[shadowRootKey] = null;\n\n if (!shadowRootElement && element) {\n // create a shadow root if it doesn't exist\n // this is a fallback for browsers that don't support declarative shadow DOM\n try {\n shadowRootElement = element.attachShadow({ mode });\n } catch {\n // do nothing if attachShadow fails because of existing shadow root\n }\n }\n\n if (shadowRootElement) {\n // remove all nodes from the shadow root except links\n shadowRootElement.querySelectorAll('*:not(link)').forEach((node) => {\n node.remove();\n });\n setShadowRoot(shadowRootElement);\n }\n }\n }, [name, isolate, shadowRoot, links, url, mode]);\n\n useEffect(() => {\n let mounted = true;\n\n // if we have a component, we don't need to load it again\n if (\n (!component && (isolate === false || shadowRoot)) ||\n metadataRef.current.url !== url ||\n metadataRef.current.name !== name ||\n metadataRef.current.bundle !== bundle ||\n metadataRef.current.route !== route\n ) {\n metadataRef.current = {\n name,\n bundle,\n route,\n url,\n };\n loadRemoteComponent({\n url: new URL(url, location.origin),\n name,\n bundle,\n route,\n runtime,\n data,\n nextData,\n scripts,\n shared: tryImportShared(),\n remoteShared,\n container: shadowRoot,\n })\n .then((result) => {\n if (mounted) {\n if (result.error) {\n setComponent(result.error);\n } else {\n setComponent(result.component);\n }\n }\n })\n .catch((error: Error) => {\n if (mounted) {\n setComponent(error);\n }\n });\n }\n\n return () => {\n mounted = false;\n };\n }, [\n url,\n component,\n name,\n bundle,\n route,\n runtime,\n scripts,\n data,\n nextData,\n remoteShared,\n children,\n links,\n isolate,\n shadowRoot,\n ]);\n\n const resetStyle = reset ? (\n <style data-remote-components-reset>{`:host { all: initial; }`}</style>\n ) : null;\n let componentToRender = (\n <>{shouldUseChildren ? children : (component as React.ReactNode)}</>\n );\n let linksToRender: React.ReactNode[] | null = links.map((link) => (\n <link\n as={link.as as string}\n href={new URL(link.href as string, url || location.origin).href}\n key={`${link.href as string}_${link.rel}`}\n rel={link.rel as string}\n />\n ));\n\n if (isolate !== false) {\n componentToRender = (\n <div\n id={`shadowroot_${new URL(url).href.replace(/[^a-z0-9]/g, '_')}_${name.replace(/[^a-z0-9]/g, '_')}`}\n >\n {typeof document === 'undefined' ? (\n // eslint-disable-next-line react/no-unknown-property\n <template shadowrootmode={mode}>\n <div\n dangerouslySetInnerHTML={{\n __html: `<img\n alt=\"\" decoding=\"async\" style=\"display:none\"\n src=\"data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///ywAAAAAAQABAAACAUwAOw==\"\n onload=\"(function(el){\n const root = el.getRootNode();\n globalThis.__remote_components_shadowroot_${new URL(url).href.replace(/[^a-z0-9]/g, '_')}_${name.replace(/[^a-z0-9]/g, '_')} = root;\n el.parentElement.remove();\n })(this)\"\n />`,\n }}\n />\n {resetStyle}\n {linksToRender}\n {componentToRender}\n </template>\n ) : null}\n {shadowRoot\n ? createPortal(\n shadowRoot.querySelectorAll('link').length !== links.length ? (\n <>\n {resetStyle}\n {linksToRender}\n {componentToRender}\n </>\n ) : (\n <>\n {resetStyle}\n {componentToRender}\n </>\n ),\n shadowRoot,\n )\n : null}\n </div>\n );\n linksToRender = null;\n }\n\n return (\n <>\n <script data-remote-component type=\"application/json\">\n {JSON.stringify({\n name,\n bundle,\n route,\n runtime,\n })}\n </script>\n {linksToRender}\n {componentToRender}\n {nextData ? (\n <script\n id={`${bundle}_${route.replace(/[^a-zA-Z0-9]+/g, '_')}${name}_next_data`}\n type=\"application/json\"\n >\n {JSON.stringify(nextData)}\n </script>\n ) : null}\n {isolate === false ? <template id={`${name}_end`} /> : null}\n </>\n );\n}\n"],"mappings":";AAmMI,SAGA,UAHA,KAqBM,YArBN;AAjMJ,SAAS,WAAW,UAAU,iBAAiB,cAAc;AAC7D,SAAS,oBAAoB;AAC7B;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,OACK;AAsBP,eAAe,kBAAkB;AAC/B,MAAI;AACF,UAAM,EAAE,OAAO,IAAI,MAAM,OAAO,oCAAoC;AACpE,WAAO;AAAA,EACT,QAAE;AACA,WAAO,CAAC;AAAA,EACV;AACF;AAQO,SAAS,sBAAsB;AAAA,EACpC;AAAA,EACA;AAAA,EACA;AAAA,EACA,QAAQ;AAAA,EACR,UAAU;AAAA,EACV;AAAA,EACA;AAAA,EACA,UAAU,CAAC;AAAA,EACX,QAAQ,CAAC;AAAA,EACT,eAAe,CAAC;AAAA,EAChB;AAAA,EACA,OAAO;AAAA,EACP;AAAA,EACA;AACF,GAAyB;AACvB,QAAM,CAAC,WAAW,YAAY,IAAI,SAAkC,IAAI;AACxE,QAAM,cAAc,OAKjB;AAAA,IACD;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACF,CAAC;AAGD,MAAI,qBAAqB,OAAO;AAC9B,UAAM;AAAA,EACR;AAGA,QAAM,qBACH,CAAC,aACC,aACC,CAAC,YACD,OAAQ,UAA0C,SAChD;AAAA;AAAA;AAAA,EAIN,UAAU,YAAY;AAExB,QAAM,CAAC,YAAY,aAAa,IAAI,SAA4B,IAAI;AAEpE,kBAAgB,MAAM;AACpB,QAAI,YAAY,SAAS,OAAO,aAAa,eAAe,CAAC,YAAY;AACvE,UAAI,oBAAuC;AAC3C,YAAM,UAAU,SAAS;AAAA,QACvB,cAAc,IAAI,IAAI,GAAG,EAAE,KAAK,QA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;AAAA,YACE,WAAW,iBAAiB,MAAM,EAAE,WAAW,MAAM,SACnD,iCACG;AAAA;AAAA,cACA;AAAA,cACA;AAAA,eACH,IAEA,iCACG;AAAA;AAAA,cACA;AAAA,eACH;AAAA,YAEF;AAAA,UACF,IACA;AAAA;AAAA;AAAA,IACN;AAEF,oBAAgB;AAAA,EAClB;AAEA,SACE,iCACE;AAAA,wBAAC,YAAO,yBAAqB,MAAC,MAAK,oBAChC,eAAK,UAAU;AAAA,MACd;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,IACF,CAAC,GACH;AAAA,IACC;AAAA,IACA;AAAA,IACA,WACC;AAAA,MAAC;AAAA;AAAA,QACC,IAAI,GAAG,UAAU,MAAM,QAAQ,kBAAkB,GAAG,IAAI;AAAA,QACxD,MAAK;AAAA,QAEJ,eAAK,UAAU,QAAQ;AAAA;AAAA,IAC1B,IACE;AAAA,IACH,YAAY,QAAQ,oBAAC,cAAS,IAAI,GAAG,YAAY,IAAK;AAAA,KACzD;AAEJ;","names":[]}
1
+ {"version":3,"sources":["../../../../src/next/host/app-router-client.tsx"],"sourcesContent":["'use client';\n\nimport {\n useId,\n useEffect,\n useLayoutEffect,\n useRef,\n useState,\n startTransition,\n} from 'react';\nimport { createPortal } from 'react-dom';\nimport * as Image from 'next/image';\nimport {\n loadRemoteComponent,\n DEFAULT_ROUTE,\n RUNTIME_WEBPACK,\n} from '#internal/shared/client/remote-component';\nimport type { RemoteComponentProps } from '#internal/shared/client/remote-component';\nimport { imageImpl, routerImpl } from '#internal/next/host/app-router-compat';\nimport { escapeString } from '#internal/shared/utils';\n\n// patch react/jsx-runtime to support the shadowrootmode attribute on template elements\ndeclare module 'react/jsx-runtime' {\n // eslint-disable-next-line @typescript-eslint/no-namespace\n export namespace JSX {\n interface IntrinsicElements {\n template: {\n shadowrootmode?: 'open' | 'closed';\n id?: string;\n ref?: React.Ref<HTMLTemplateElement>;\n dangerouslySetInnerHTML?: {\n __html: string;\n };\n children?: React.ReactNode;\n };\n }\n }\n}\n\n// import { shared } from '@remote-components/shared/host';\nasync function tryImportShared() {\n try {\n const { shared } = await import('@remote-components/shared/host/app');\n return shared;\n } catch {\n return {};\n }\n}\n\n/**\n * RemoteComponentClient - Main component for rendering remote components\n *\n * This component handles the loading and rendering of remote microfrontends.\n * It supports both RSC (React Server Components) and Next.js Pages Router based components.\n */\nexport function RemoteComponentClient({\n url,\n name,\n bundle,\n route = DEFAULT_ROUTE,\n runtime = RUNTIME_WEBPACK,\n data,\n nextData,\n scripts = [],\n links = [],\n remoteShared = {},\n isolate,\n mode = 'open',\n reset,\n children,\n}: RemoteComponentProps) {\n const remoteComponentId = useId();\n const [component, setComponent] = useState<React.ReactNode | Error>(null);\n const metadataRef = useRef<{\n name: string;\n bundle: string;\n route: string;\n url: string;\n loading: boolean;\n }>({\n name,\n bundle,\n route,\n url,\n loading: false,\n });\n\n // Handle errors by re-throwing them\n if (component instanceof Error) {\n throw component;\n }\n\n // determine whether to use children or loaded component\n const shouldUseChildren =\n (!component ||\n (component &&\n !nextData &&\n typeof (component as unknown as Promise<unknown>).then !==\n 'function')) &&\n // if the remote Next.js Pages Router application is in development mode\n // we don't use the provided static HTML\n // to mitigate layout shift when loading CSS using JavaScript on the client\n nextData?.buildId !== 'development';\n\n const self = globalThis as Record<\n `__remote_components_shadowroot_${string}`,\n ShadowRoot | null\n > &\n Record<`__remote_components_container_${string}`, HTMLDivElement | null>;\n const shadowRootKey =\n `__remote_components_shadowroot_${escapeString(new URL(url).href)}_${escapeString(name)}` as const;\n const shadowContainerRef = useRef<HTMLDivElement | null>(\n typeof document === 'undefined'\n ? null\n : document.querySelector(\n `[data-remote-component-id=\"shadowroot_${remoteComponentId}\"]`,\n ),\n );\n const shadowRootRef = useRef<ShadowRoot | null>(\n self[shadowRootKey] ?? shadowContainerRef.current?.shadowRoot ?? null,\n );\n const ssrShadowRootContentRef = useRef<NodeListOf<ChildNode> | null>(\n shadowRootRef.current?.querySelectorAll('*') ?? null,\n );\n const ssrLinksStylesRef = useRef<(HTMLLinkElement | HTMLStyleElement)[]>([]);\n\n if (self[shadowRootKey] && shadowRootRef.current) {\n self[shadowRootKey] = null;\n }\n\n useLayoutEffect(() => {\n if (\n !shadowContainerRef.current ||\n shadowContainerRef.current !== shadowRootRef.current?.host\n ) {\n shadowRootRef.current = null;\n }\n\n if (\n isolate !== false &&\n typeof document !== 'undefined' &&\n !shadowRootRef.current\n ) {\n let shadowRootElement: ShadowRoot | null = null;\n const element = shadowContainerRef.current;\n\n shadowRootElement = self[shadowRootKey] ?? element?.shadowRoot ?? null;\n self[shadowRootKey] = null;\n\n if (!shadowRootElement && element) {\n // create a shadow root if it doesn't exist\n // this is a fallback for browsers that don't support declarative shadow DOM\n try {\n shadowRootElement = element.attachShadow({ mode });\n } catch {\n // do nothing if attachShadow fails because of existing shadow root\n }\n }\n\n if (shadowRootElement) {\n shadowRootRef.current = shadowRootElement;\n }\n }\n\n if (\n shadowRootRef.current &&\n ssrShadowRootContentRef.current &&\n !shouldUseChildren\n ) {\n // remove all nodes from the shadow root except links\n ssrShadowRootContentRef.current.forEach((node) => {\n if (node.nodeName !== 'LINK' && node.nodeName !== 'STYLE') {\n node.parentNode?.removeChild(node);\n } else {\n ssrLinksStylesRef.current.push(\n node as HTMLLinkElement | HTMLStyleElement,\n );\n }\n });\n ssrShadowRootContentRef.current = null;\n }\n\n if (ssrLinksStylesRef.current.length > 0 && shadowRootRef.current) {\n const waitForLoad =\n shadowRootRef.current.querySelectorAll('link[data-wait]');\n if (waitForLoad.length > 0) {\n Promise.all(\n Array.from(waitForLoad).map(\n (link) =>\n new Promise<void>((resolve) => {\n link.addEventListener('load', () => resolve());\n link.addEventListener('error', () => resolve());\n }),\n ),\n )\n .then(() => {\n waitForLoad.forEach((el) => {\n el.removeAttribute('data-wait');\n });\n\n // remove SSR injected styles and links\n ssrLinksStylesRef.current.forEach((el) => {\n el.parentNode?.removeChild(el);\n });\n ssrLinksStylesRef.current = [];\n })\n .catch((e) => {\n // eslint-disable-next-line no-console\n console.error(e);\n });\n }\n }\n }, [\n name,\n isolate,\n links,\n url,\n mode,\n self,\n shadowRootKey,\n shouldUseChildren,\n remoteComponentId,\n ]);\n\n useEffect(() => {\n startTransition(async () => {\n try {\n // if we have a component, we don't need to load it again\n if (\n (!metadataRef.current.loading &&\n !component &&\n (isolate === false || shadowRootRef.current)) ||\n metadataRef.current.url !== url ||\n metadataRef.current.name !== name ||\n metadataRef.current.bundle !== bundle ||\n metadataRef.current.route !== route\n ) {\n metadataRef.current = {\n name,\n bundle,\n route,\n url,\n loading: true,\n };\n const rscName = `__remote_components_rsc_${escapeString(new URL(url).href)}_${escapeString(name)}`;\n const result = await loadRemoteComponent({\n url: new URL(url, location.origin),\n name,\n bundle,\n route,\n runtime,\n rscName,\n data,\n nextData,\n scripts,\n shared: (async () => {\n return {\n 'next/router': routerImpl,\n ...(await tryImportShared()),\n 'next/image': () =>\n Promise.resolve(imageImpl(Image.default, bundle)),\n 'next/dist/client/image-component': () =>\n Promise.resolve({ Image: imageImpl(Image.default, bundle) }),\n };\n })(),\n remoteShared,\n container: shadowRootRef.current,\n });\n metadataRef.current.loading = false;\n if (result.error) {\n setComponent(result.error);\n } else {\n setComponent(result.component);\n }\n }\n } catch (error: unknown) {\n metadataRef.current.loading = false;\n setComponent(error as Error);\n }\n });\n }, [\n url,\n component,\n name,\n bundle,\n route,\n runtime,\n scripts,\n data,\n nextData,\n remoteShared,\n children,\n links,\n isolate,\n ]);\n\n if (\n nextData?.buildId === 'development' &&\n shadowRootRef.current &&\n isolate !== false &&\n reset &&\n !shadowRootRef.current.querySelector('[data-remote-components-reset]')\n ) {\n // inject reset styles into the shadow root\n const style = document.createElement('style');\n style.setAttribute('data-remote-components-reset', '');\n style.textContent = `:host { all: initial; }`;\n shadowRootRef.current.insertBefore(style, shadowRootRef.current.firstChild);\n } else if (\n shadowRootRef.current &&\n isolate !== false &&\n !reset &&\n shadowRootRef.current.querySelector('[data-remote-components-reset]')\n ) {\n // ensure reset styles are the first child in the shadow root\n const style = shadowRootRef.current.querySelector(\n '[data-remote-components-reset]',\n );\n if (style && shadowRootRef.current.firstChild !== style) {\n shadowRootRef.current.removeChild(style);\n }\n }\n\n const linksToRender = (\n <>\n {(!nextData || nextData.buildId !== 'development') &&\n isolate !== false &&\n reset ? (\n <style data-remote-components-reset=\"\">{`:host { all: initial; }`}</style>\n ) : null}\n {links.map((link) => (\n <link\n key={JSON.stringify(link)}\n {...Object.entries(link).reduce<Record<string, string>>(\n (acc, [key, value]) => {\n if (\n key !== 'href' &&\n key !== 'precedence' &&\n typeof value === 'string'\n ) {\n acc[key] = value;\n }\n return acc;\n },\n {},\n )}\n data-wait={link.rel === 'stylesheet' && link.href ? '' : undefined}\n href={new URL(link.href as string, url).href}\n />\n ))}\n {links\n .filter((link) => link.rel === 'stylesheet')\n .map((link) => (\n <link\n key={JSON.stringify(link)}\n {...Object.entries(link).reduce<Record<string, string>>(\n (acc, [key, value]) => {\n if (\n key !== 'href' &&\n key !== 'precedence' &&\n typeof value === 'string'\n ) {\n acc[key] = value;\n }\n return acc;\n },\n {},\n )}\n as=\"style\"\n fetchPriority=\"high\"\n href={new URL(link.href as string, url).href}\n precedence={bundle}\n rel=\"preload\"\n />\n ))}\n </>\n );\n\n let componentToRender = shouldUseChildren ? (\n <>{children}</>\n ) : (\n (component as React.ReactNode)\n );\n\n if (isolate !== false) {\n componentToRender = (\n <div\n data-remote-component-id={`shadowroot_${remoteComponentId}`}\n data-remote-component-isolation-root=\"\"\n id={`shadowroot_${name}`}\n ref={shadowContainerRef}\n >\n {typeof document === 'undefined' ? (\n // eslint-disable-next-line react/no-unknown-property\n <template shadowrootmode={mode}>\n {mode === 'closed' ? (\n <div\n dangerouslySetInnerHTML={{\n __html: `<img\n alt=\"\" decoding=\"async\" style=\"display:none\"\n src=\"data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///ywAAAAAAQABAAACAUwAOw==\"\n onload=\"(function(el){\n const root = el.getRootNode();\n globalThis.__remote_components_shadowroot_${escapeString(new URL(url).href)}_${escapeString(name)} = root;\n el.parentElement.remove();\n })(this)\"\n />`,\n }}\n />\n ) : null}\n {linksToRender}\n {shouldUseChildren ? children : null}\n </template>\n ) : null}\n {typeof document !== 'undefined' &&\n shadowRootRef.current &&\n !shouldUseChildren\n ? createPortal(\n <>\n {linksToRender}\n {componentToRender}\n </>,\n shadowRootRef.current,\n )\n : null}\n </div>\n );\n }\n\n return (\n <>\n {isolate === false ? <template id={`${name}_start`} /> : null}\n <script data-remote-component type=\"application/json\">\n {JSON.stringify({\n name,\n bundle,\n route,\n runtime,\n })}\n </script>\n {isolate === false ? linksToRender : null}\n {componentToRender}\n {nextData ? (\n <script\n id={`${bundle}_${route.replace(/[^a-zA-Z0-9]+/g, '_')}${name}_next_data`}\n type=\"application/json\"\n >\n {JSON.stringify(nextData)}\n </script>\n ) : null}\n {isolate === false ? <template id={`${name}_end`} /> : null}\n </>\n );\n}\n"],"mappings":";AAoUI,mBAII,KAJJ;AAlUJ;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AACP,SAAS,oBAAoB;AAC7B,YAAY,WAAW;AACvB;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,OACK;AAEP,SAAS,WAAW,kBAAkB;AACtC,SAAS,oBAAoB;AAqB7B,eAAe,kBAAkB;AAC/B,MAAI;AACF,UAAM,EAAE,OAAO,IAAI,MAAM,OAAO,oCAAoC;AACpE,WAAO;AAAA,EACT,QAAE;AACA,WAAO,CAAC;AAAA,EACV;AACF;AAQO,SAAS,sBAAsB;AAAA,EACpC;AAAA,EACA;AAAA,EACA;AAAA,EACA,QAAQ;AAAA,EACR,UAAU;AAAA,EACV;AAAA,EACA;AAAA,EACA,UAAU,CAAC;AAAA,EACX,QAAQ,CAAC;AAAA,EACT,eAAe,CAAC;AAAA,EAChB;AAAA,EACA,OAAO;AAAA,EACP;AAAA,EACA;AACF,GAAy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A,MACA;AAAA,MACA;AAAA,MACA;AAAA,IACF,CAAC,GACH;AAAA,IACC,YAAY,QAAQ,gBAAgB;AAAA,IACpC;AAAA,IACA,WACC;AAAA,MAAC;AAAA;AAAA,QACC,IAAI,GAAG,UAAU,MAAM,QAAQ,kBAAkB,GAAG,IAAI;AAAA,QACxD,MAAK;AAAA,QAEJ,eAAK,UAAU,QAAQ;AAAA;AAAA,IAC1B,IACE;AAAA,IACH,YAAY,QAAQ,oBAAC,cAAS,IAAI,GAAG,YAAY,IAAK;AAAA,KACzD;AAEJ;","names":[]}
@@ -0,0 +1,114 @@
1
+ "use strict";
2
+ var __create = Object.create;
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __getProtoOf = Object.getPrototypeOf;
7
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
8
+ var __export = (target, all) => {
9
+ for (var name in all)
10
+ __defProp(target, name, { get: all[name], enumerable: true });
11
+ };
12
+ var __copyProps = (to, from, except, desc) => {
13
+ if (from && typeof from === "object" || typeof from === "function") {
14
+ for (let key of __getOwnPropNames(from))
15
+ if (!__hasOwnProp.call(to, key) && key !== except)
16
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
17
+ }
18
+ return to;
19
+ };
20
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
+ // If the importer is in node compatibility mode or this is not an ESM
22
+ // file that has been converted to a CommonJS file using a Babel-
23
+ // compatible transform (i.e. "__esModule" has not been set), then set
24
+ // "default" to the CommonJS "module.exports" for node compatibility.
25
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
26
+ mod
27
+ ));
28
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
+ var app_router_compat_exports = {};
30
+ __export(app_router_compat_exports, {
31
+ imageImpl: () => imageImpl,
32
+ routerImpl: () => routerImpl
33
+ });
34
+ module.exports = __toCommonJS(app_router_compat_exports);
35
+ var import_jsx_runtime = require("react/jsx-runtime");
36
+ var import_navigation = require("next/navigation");
37
+ var import_polyfill = require("#internal/shared/client/polyfill");
38
+ function imageImpl(ImageComponent, bundle) {
39
+ const component = function RemoteImage(props) {
40
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
41
+ ImageComponent,
42
+ {
43
+ ...props,
44
+ src: (0, import_polyfill.applyBundleUrlToImagePropsSrc)(bundle, props.src)
45
+ }
46
+ );
47
+ };
48
+ component.default = component;
49
+ return component;
50
+ }
51
+ const routerImpl = async () => {
52
+ const { useRouter } = await import("next/navigation");
53
+ return Promise.resolve({
54
+ useRouter: () => {
55
+ const router = useRouter();
56
+ const pathname = (0, import_navigation.usePathname)();
57
+ const searchParams = (0, import_navigation.useSearchParams)();
58
+ const query = Object.fromEntries(searchParams.entries());
59
+ return {
60
+ pathname,
61
+ query,
62
+ asPath: searchParams.toString() ? `${pathname}?${searchParams.toString()}` : pathname,
63
+ push: (href, _, options) => {
64
+ router.push(href, options);
65
+ return Promise.resolve(true);
66
+ },
67
+ replace: (href, _, options) => {
68
+ router.replace(href, options);
69
+ return Promise.resolve(true);
70
+ },
71
+ refresh: () => Promise.resolve(router.refresh()),
72
+ prefetch: async () => {
73
+ console.warn(
74
+ "You are using router.prefetch() in a remote component loaded in the Next.js App Router. prefetch() is a no-op in the App Router."
75
+ );
76
+ return Promise.resolve();
77
+ },
78
+ back: () => {
79
+ if (typeof window !== "undefined") {
80
+ window.history.back();
81
+ }
82
+ },
83
+ reload: () => {
84
+ router.refresh();
85
+ },
86
+ beforePopState: () => {
87
+ },
88
+ events: {
89
+ on: () => {
90
+ console.warn(
91
+ "You are using router.events.on() in a remote component loaded in the Next.js App Router. events.on() is a no-op in the App Router."
92
+ );
93
+ },
94
+ off: () => {
95
+ console.warn(
96
+ "You are using router.events.off() in a remote component loaded in the Next.js App Router. events.off() is a no-op in the App Router."
97
+ );
98
+ },
99
+ emit: () => {
100
+ console.warn(
101
+ "You are using router.events.emit() in a remote component loaded in the Next.js App Router. events.emit() is a no-op in the App Router."
102
+ );
103
+ }
104
+ }
105
+ };
106
+ }
107
+ });
108
+ };
109
+ // Annotate the CommonJS export names for ESM import in node:
110
+ 0 && (module.exports = {
111
+ imageImpl,
112
+ routerImpl
113
+ });
114
+ //# sourceMappingURL=app-router-compat.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../../src/next/host/app-router-compat.tsx"],"sourcesContent":["import type { default as ImageComponentType, ImageProps } from 'next/image';\nimport { usePathname, useSearchParams } from 'next/navigation';\nimport type { NavigateOptions } from 'next/dist/shared/lib/app-router-context.shared-runtime';\nimport { applyBundleUrlToImagePropsSrc } from '#internal/shared/client/polyfill';\n\nexport function imageImpl(\n ImageComponent: typeof ImageComponentType,\n bundle: string,\n) {\n const component = function RemoteImage(props: ImageProps) {\n return (\n <ImageComponent\n {...props}\n src={applyBundleUrlToImagePropsSrc(bundle, props.src)}\n />\n );\n };\n component.default = component;\n return component;\n}\n\nexport const routerImpl = async () => {\n const { useRouter } = await import('next/navigation');\n return Promise.resolve({\n useRouter: () => {\n const router = useRouter();\n const pathname = usePathname();\n const searchParams = useSearchParams();\n const query = Object.fromEntries(searchParams.entries());\n return {\n pathname,\n query,\n asPath: searchParams.toString()\n ? `${pathname}?${searchParams.toString()}`\n : pathname,\n push: (href: string, _: string, options?: NavigateOptions) => {\n router.push(href, options);\n return Promise.resolve(true);\n },\n replace: (href: string, _: string, options?: NavigateOptions) => {\n router.replace(href, options);\n return Promise.resolve(true);\n },\n refresh: () => Promise.resolve(router.refresh()),\n prefetch: async () => {\n // eslint-disable-next-line no-console\n console.warn(\n 'You are using router.prefetch() in a remote component loaded in the Next.js App Router. prefetch() is a no-op in the App Router.',\n );\n return Promise.resolve();\n },\n back: () => {\n // there's no back() in the App Router\n if (typeof window !== 'undefined') {\n window.history.back();\n }\n },\n reload: () => {\n router.refresh();\n },\n beforePopState: () => {\n // there's no beforePopState() in the App Router\n },\n events: {\n on: () => {\n // there's no router.events in the App Router\n // eslint-disable-next-line no-console\n console.warn(\n 'You are using router.events.on() in a remote component loaded in the Next.js App Router. events.on() is a no-op in the App Router.',\n );\n },\n off: () => {\n // there's no router.events in the App Router\n // eslint-disable-next-line no-console\n console.warn(\n 'You are using router.events.off() in a remote component loaded in the Next.js App Router. events.off() is a no-op in the App Router.',\n );\n },\n emit: () => {\n // there's no router.events in the App Router\n // eslint-disable-next-line no-console\n console.warn(\n 'You are using router.events.emit() in a remote component loaded in the Next.js App Router. events.emit() is a no-op in the App Router.',\n );\n },\n },\n };\n },\n });\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAWM;AAVN,wBAA6C;AAE7C,sBAA8C;AAEvC,SAAS,UACd,gBACA,QACA;AACA,QAAM,YAAY,SAAS,YAAY,OAAmB;AACxD,WACE;AAAA,MAAC;AAAA;AAAA,QACE,GAAG;AAAA,QACJ,SAAK,+CAA8B,QAAQ,MAAM,GAAG;AAAA;AAAA,IACtD;AAAA,EAEJ;AACA,YAAU,UAAU;AACpB,SAAO;AACT;AAEO,MAAM,aAAa,YAAY;AACpC,QAAM,EAAE,UAAU,IAAI,MAAM,OAAO,iBAAiB;AACpD,SAAO,QAAQ,QAAQ;AAAA,IACrB,WAAW,MAAM;AACf,YAAM,SAAS,UAAU;AACzB,YAAM,eAAW,+BAAY;AAC7B,YAAM,mBAAe,mCAAgB;AACrC,YAAM,QAAQ,OAAO,YAAY,aAAa,QAAQ,CAAC;AACvD,aAAO;AAAA,QACL;AAAA,QACA;AAAA,QACA,QAAQ,aAAa,SAAS,IAC1B,GAAG,YAAY,aAAa,SAAS,MACrC;AAAA,QACJ,MAAM,CAAC,MAAc,GAAW,YAA8B;AAC5D,iBAAO,KAAK,MAAM,OAAO;AACzB,iBAAO,QAAQ,QAAQ,IAAI;AAAA,QAC7B;AAAA,QACA,SAAS,CAAC,MAAc,GAAW,YAA8B;AAC/D,iBAAO,QAAQ,MAAM,OAAO;AAC5B,iBAAO,QAAQ,QAAQ,IAAI;AAAA,QAC7B;AAAA,QACA,SAAS,MAAM,QAAQ,QAAQ,OAAO,QAAQ,CAAC;AAAA,QAC/C,UAAU,YAAY;AAEpB,kBAAQ;AAAA,YACN;AAAA,UACF;AACA,iBAAO,QAAQ,QAAQ;AAAA,QACzB;AAAA,QACA,MAAM,MAAM;AAEV,cAAI,OAAO,WAAW,aAAa;AACjC,mBAAO,QAAQ,KAAK;AAAA,UACtB;AAAA,QACF;AAAA,QACA,QAAQ,MAAM;AACZ,iBAAO,QAAQ;AAAA,QACjB;AAAA,QACA,gBAAgB,MAAM;AAAA,QAEtB;AAAA,QACA,QAAQ;AAAA,UACN,IAAI,MAAM;AAGR,oBAAQ;AAAA,cACN;AAAA,YACF;AAAA,UACF;AAAA,UACA,KAAK,MAAM;AAGT,oBAAQ;AAAA,cACN;AAAA,YACF;AAAA,UACF;AAAA,UACA,MAAM,MAAM;AAGV,oBAAQ;AAAA,cACN;AAAA,YACF;AAAA,UACF;AAAA,QACF;AAAA,MACF;AAAA,IACF;AAAA,EACF,CAAC;AACH;","names":[]}
@@ -0,0 +1,31 @@
1
+ import * as react_jsx_runtime from 'react/jsx-runtime';
2
+ import ImageComponentType, { ImageProps } from 'next/image';
3
+ import { NavigateOptions } from 'next/dist/shared/lib/app-router-context.shared-runtime';
4
+
5
+ declare function imageImpl(ImageComponent: typeof ImageComponentType, bundle: string): {
6
+ (props: ImageProps): react_jsx_runtime.JSX.Element;
7
+ default: /*elided*/ any;
8
+ };
9
+ declare const routerImpl: () => Promise<{
10
+ useRouter: () => {
11
+ pathname: string;
12
+ query: {
13
+ [k: string]: string;
14
+ };
15
+ asPath: string;
16
+ push: (href: string, _: string, options?: NavigateOptions) => Promise<boolean>;
17
+ replace: (href: string, _: string, options?: NavigateOptions) => Promise<boolean>;
18
+ refresh: () => Promise<void>;
19
+ prefetch: () => Promise<void>;
20
+ back: () => void;
21
+ reload: () => void;
22
+ beforePopState: () => void;
23
+ events: {
24
+ on: () => void;
25
+ off: () => void;
26
+ emit: () => void;
27
+ };
28
+ };
29
+ }>;
30
+
31
+ export { imageImpl, routerImpl };