remote-components 0.2.2 → 0.3.0

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 (51) hide show
  1. package/dist/config/nextjs.cjs +2 -4
  2. package/dist/config/nextjs.cjs.map +1 -1
  3. package/dist/config/nextjs.d.ts +1 -1
  4. package/dist/config/nextjs.js +2 -4
  5. package/dist/config/nextjs.js.map +1 -1
  6. package/dist/host/html.cjs +40 -59
  7. package/dist/host/html.cjs.map +1 -1
  8. package/dist/host/html.js +40 -62
  9. package/dist/host/html.js.map +1 -1
  10. package/dist/host/nextjs/app/client-only.cjs +169 -237
  11. package/dist/host/nextjs/app/client-only.cjs.map +1 -1
  12. package/dist/host/nextjs/app/client-only.js +170 -238
  13. package/dist/host/nextjs/app/client-only.js.map +1 -1
  14. package/dist/host/nextjs/pages.cjs +1 -8
  15. package/dist/host/nextjs/pages.cjs.map +1 -1
  16. package/dist/host/nextjs/pages.js +2 -9
  17. package/dist/host/nextjs/pages.js.map +1 -1
  18. package/dist/host/react.cjs +37 -71
  19. package/dist/host/react.cjs.map +1 -1
  20. package/dist/host/react.js +37 -71
  21. package/dist/host/react.js.map +1 -1
  22. package/dist/internal/host/nextjs/app-client.cjs +3 -8
  23. package/dist/internal/host/nextjs/app-client.cjs.map +1 -1
  24. package/dist/internal/host/nextjs/app-client.js +4 -9
  25. package/dist/internal/host/nextjs/app-client.js.map +1 -1
  26. package/dist/internal/host/nextjs/image-shared.cjs +25 -15
  27. package/dist/internal/host/nextjs/image-shared.cjs.map +1 -1
  28. package/dist/internal/host/nextjs/image-shared.d.ts +19 -6
  29. package/dist/internal/host/nextjs/image-shared.js +24 -14
  30. package/dist/internal/host/nextjs/image-shared.js.map +1 -1
  31. package/dist/internal/host/react/hooks/use-resolve-client-url.cjs +1 -5
  32. package/dist/internal/host/react/hooks/use-resolve-client-url.cjs.map +1 -1
  33. package/dist/internal/host/react/hooks/use-resolve-client-url.d.ts +1 -4
  34. package/dist/internal/host/react/hooks/use-resolve-client-url.js +1 -5
  35. package/dist/internal/host/react/hooks/use-resolve-client-url.js.map +1 -1
  36. package/dist/internal/host/shared/polyfill.cjs +10 -65
  37. package/dist/internal/host/shared/polyfill.cjs.map +1 -1
  38. package/dist/internal/host/shared/polyfill.d.ts +1 -3
  39. package/dist/internal/host/shared/polyfill.js +9 -63
  40. package/dist/internal/host/shared/polyfill.js.map +1 -1
  41. package/dist/internal/host/shared/remote-image-loader.cjs +53 -0
  42. package/dist/internal/host/shared/remote-image-loader.cjs.map +1 -0
  43. package/dist/internal/host/shared/remote-image-loader.d.ts +30 -0
  44. package/dist/internal/host/shared/remote-image-loader.js +29 -0
  45. package/dist/internal/host/shared/remote-image-loader.js.map +1 -0
  46. package/package.json +1 -1
  47. package/dist/internal/host/nextjs/image-impl.cjs +0 -64
  48. package/dist/internal/host/nextjs/image-impl.cjs.map +0 -1
  49. package/dist/internal/host/nextjs/image-impl.d.ts +0 -10
  50. package/dist/internal/host/nextjs/image-impl.js +0 -40
  51. package/dist/internal/host/nextjs/image-impl.js.map +0 -1
@@ -65,9 +65,92 @@ __export(app_client_only_exports, {
65
65
  RemoteComponentsClientProvider: () => RemoteComponentsClientProvider
66
66
  });
67
67
  module.exports = __toCommonJS(app_client_only_exports);
68
- var Image = __toESM(require("next/image"), 1);
69
68
  var import_react5 = require("react");
70
69
 
70
+ // src/host/shared/remote-image-loader.ts
71
+ function getRemoteBundleOrigin(bundle) {
72
+ const self = globalThis;
73
+ return self.__remote_bundle_url__?.[bundle]?.origin ?? "";
74
+ }
75
+ function createRemoteImageLoader(bundle, resolveClientUrl) {
76
+ const loader = Object.assign(
77
+ ({
78
+ config,
79
+ src,
80
+ width,
81
+ quality
82
+ }) => {
83
+ const q = quality ?? 75;
84
+ const remoteOrigin = getRemoteBundleOrigin(bundle);
85
+ const isCrossOrigin = remoteOrigin && remoteOrigin !== location.origin;
86
+ const basePath = isCrossOrigin ? `${remoteOrigin}${config.path ?? "/_next/image"}` : config.path ?? `${remoteOrigin}/_next/image`;
87
+ const url = `${basePath}?url=${encodeURIComponent(src)}&w=${width}&q=${q}`;
88
+ return resolveClientUrl?.(url) ?? url;
89
+ },
90
+ // Signals to getImgProps that this is a default loader (not a user-defined
91
+ // one), enabling srcSet generation with device/image sizes from the config.
92
+ { __next_img_default: true }
93
+ );
94
+ return loader;
95
+ }
96
+
97
+ // src/runtime/url/resolve-client-url.ts
98
+ function withRemoteSrc(resolveClientUrl, remoteSrc) {
99
+ const remoteOrigin = parseOrigin(remoteSrc);
100
+ return (url) => {
101
+ const urlOrigin = parseOrigin(url);
102
+ if (remoteOrigin && urlOrigin && urlOrigin !== remoteOrigin) {
103
+ return void 0;
104
+ }
105
+ return resolveClientUrl(remoteSrc, url);
106
+ };
107
+ }
108
+ function parseOrigin(url) {
109
+ try {
110
+ return new URL(url).origin;
111
+ } catch {
112
+ return void 0;
113
+ }
114
+ }
115
+
116
+ // src/runtime/url/default-resolve-client-url.ts
117
+ function bindResolveClientUrl(prop, remoteSrc) {
118
+ return prop ? withRemoteSrc(prop, remoteSrc) : void 0;
119
+ }
120
+
121
+ // src/host/nextjs/image-shared.ts
122
+ function resolveForBundle(unbound, bundle) {
123
+ if (!unbound)
124
+ return void 0;
125
+ const self = globalThis;
126
+ const remoteSrc = self.__remote_bundle_url__?.[bundle]?.href ?? "";
127
+ return bindResolveClientUrl(unbound, remoteSrc);
128
+ }
129
+ function createImageLoaderSharedEntries({
130
+ bound,
131
+ unbound
132
+ } = {}) {
133
+ const entry = (bundle) => {
134
+ const resolveClientUrl = bound ?? resolveForBundle(unbound, bundle);
135
+ return Promise.resolve({
136
+ default: createRemoteImageLoader(bundle, resolveClientUrl),
137
+ __esModule: true
138
+ });
139
+ };
140
+ return {
141
+ "next/dist/shared/lib/image-loader": entry,
142
+ "next/dist/esm/shared/lib/image-loader": entry
143
+ };
144
+ }
145
+
146
+ // src/host/nextjs/app-client-only.tsx
147
+ var import_context3 = require("#internal/host/react/context");
148
+
149
+ // src/host/react/index.tsx
150
+ var import_react3 = require("react");
151
+ var import_react_dom = require("react-dom");
152
+ var import_context2 = require("#internal/host/react/context");
153
+
71
154
  // src/utils/logger.ts
72
155
  init_constants();
73
156
 
@@ -214,58 +297,63 @@ function warnCrossOriginFetchError(logLocation, url) {
214
297
  }
215
298
  }
216
299
 
300
+ // src/host/server/fetch-headers.ts
301
+ function remoteFetchHeaders() {
302
+ return {
303
+ /**
304
+ * Authenticates deployment protection for the remote. Needed for SSR and SSG clients.
305
+ * If the remote component uses vercel deployment protection, ensure the host and remote vercel
306
+ * projects share a common automation bypass secret, and the shared secret is used as the
307
+ * VERCEL_AUTOMATION_BYPASS_SECRET env var in the host project.
308
+ */
309
+ ...typeof process === "object" && typeof process.env === "object" && typeof process.env.VERCEL_AUTOMATION_BYPASS_SECRET === "string" ? {
310
+ "x-vercel-protection-bypass": process.env.VERCEL_AUTOMATION_BYPASS_SECRET
311
+ } : {},
312
+ Accept: "text/html"
313
+ };
314
+ }
315
+
316
+ // src/host/server/fetch-with-hooks.ts
317
+ async function fetchWithWarning(url, init) {
318
+ try {
319
+ return await fetch(url, init);
320
+ } catch (error) {
321
+ warnCrossOriginFetchError("FetchRemoteComponent", url);
322
+ throw error;
323
+ }
324
+ }
325
+ async function fetchWithHooks(url, additionalInit, options = {}) {
326
+ const {
327
+ onRequest,
328
+ onResponse,
329
+ abortController = new AbortController()
330
+ } = options;
331
+ const signal = abortController.signal;
332
+ const hookOptions = {
333
+ signal,
334
+ abort: (reason) => abortController.abort(reason)
335
+ };
336
+ const init = {
337
+ method: "GET",
338
+ headers: remoteFetchHeaders(),
339
+ signal,
340
+ ...additionalInit
341
+ };
342
+ const res = await onRequest?.(url, init, hookOptions) ?? await fetchWithWarning(url, init);
343
+ return await onResponse?.(url, res, hookOptions) ?? res;
344
+ }
345
+
346
+ // src/host/server/get-client-or-server-url.ts
347
+ function getClientOrServerUrl(src, serverFallback) {
348
+ const fallback = typeof location !== "undefined" ? location.href : serverFallback;
349
+ if (!src) {
350
+ return new URL(fallback);
351
+ }
352
+ return typeof src === "string" ? new URL(src, fallback) : src;
353
+ }
354
+
217
355
  // src/host/shared/polyfill.tsx
218
- var import_jsx_runtime = (
219
- // eslint-disable-next-line @next/next/no-img-element, jsx-a11y/alt-text
220
- require("react/jsx-runtime")
221
- );
222
- function applyBundleUrlToSrc(bundle, src) {
223
- const self = globalThis;
224
- if (self.__remote_bundle_url__?.[bundle]?.origin === location.origin) {
225
- return src;
226
- }
227
- const { assetPrefix, path } = /^(?<assetPrefix>.*?)\/_next\/(?<path>.*)/.exec(src)?.groups ?? {};
228
- if (!path) {
229
- return new URL(src, self.__remote_bundle_url__?.[bundle]?.origin).href;
230
- }
231
- return `${self.__remote_bundle_url__?.[bundle]?.origin ?? ""}${assetPrefix}/_next/${path}`;
232
- }
233
- function applyBundleUrlToImagePropsSrc(bundle, src) {
234
- if (typeof src === "string") {
235
- return applyBundleUrlToSrc(bundle, src);
236
- }
237
- const propSrc = src;
238
- return applyBundleUrlToSrc(bundle, propSrc.src);
239
- }
240
- var imageImpl = (bundle, resolveClientUrl) => function RemoteImage({
241
- fill: _fill,
242
- loader: _loader,
243
- quality: _quality,
244
- priority: _priority,
245
- loading: _loading,
246
- placeholder: _placeholder,
247
- blurDataURL: _blurDataURL,
248
- unoptimized: _unoptimized,
249
- overrideSrc: _overrideSrc,
250
- src,
251
- ...props
252
- }) {
253
- const newSrc = applyBundleUrlToImagePropsSrc(
254
- bundle,
255
- typeof src === "string" ? src : src.src
256
- );
257
- const proxiedSrc = resolveClientUrl?.(newSrc) ?? newSrc;
258
- return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
259
- "img",
260
- {
261
- decoding: "async",
262
- style: { color: "transparent" },
263
- ...props,
264
- src: proxiedSrc,
265
- suppressHydrationWarning: true
266
- }
267
- );
268
- };
356
+ var import_jsx_runtime = require("react/jsx-runtime");
269
357
  function sharedPolyfills(shared2, resolveClientUrl) {
270
358
  const self = globalThis;
271
359
  const polyfill = {
@@ -356,17 +444,13 @@ function sharedPolyfills(shared2, resolveClientUrl) {
356
444
  },
357
445
  __esModule: true
358
446
  })),
359
- "next/dist/client/image-component": self.__remote_component_host_shared_modules__?.["next/image"] ?? shared2?.["next/image"] ?? ((bundle) => Promise.resolve({
360
- Image: imageImpl(bundle, resolveClientUrl),
361
- __esModule: true
362
- })),
363
- "next/image": self.__remote_component_host_shared_modules__?.["next/image"] ?? shared2?.["next/image"] ?? ((bundle) => Promise.resolve({
364
- default: imageImpl(bundle, resolveClientUrl),
365
- getImageProps: (_imgProps) => {
366
- throw new Error(
367
- "Next.js getImageProps() is not implemented in remote components"
368
- );
369
- },
447
+ // Instead of replacing next/image entirely, we let the real Next.js Image
448
+ // component load from the remote bundle and only replace its default loader.
449
+ // This gives us full next/image fidelity (fill, priority, srcSet, blur
450
+ // placeholders, error handling) while routing image optimization through the
451
+ // remote app's /_next/image endpoint.
452
+ "next/dist/shared/lib/image-loader": self.__remote_component_host_shared_modules__?.["next/dist/shared/lib/image-loader"] ?? shared2?.["next/dist/shared/lib/image-loader"] ?? ((bundle) => Promise.resolve({
453
+ default: createRemoteImageLoader(bundle, resolveClientUrl),
370
454
  __esModule: true
371
455
  })),
372
456
  "next/dist/client/script": self.__remote_component_host_shared_modules__?.["next/script"] ?? shared2?.["next/script"] ?? (() => Promise.resolve({
@@ -406,111 +490,11 @@ function sharedPolyfills(shared2, resolveClientUrl) {
406
490
  polyfill["next/navigation"] = polyfill["next/dist/client/components/navigation"];
407
491
  polyfill["next/link"] = polyfill["next/dist/client/app-dir/link"];
408
492
  polyfill["next/form"] = polyfill["next/dist/client/app-dir/form"];
409
- polyfill["next/dist/api/image"] = polyfill["next/dist/client/image-component"];
493
+ polyfill["next/dist/esm/shared/lib/image-loader"] = polyfill["next/dist/shared/lib/image-loader"];
410
494
  polyfill["next/script"] = polyfill["next/dist/client/script"];
411
495
  return polyfill;
412
496
  }
413
497
 
414
- // src/host/nextjs/image-impl.tsx
415
- var import_jsx_runtime2 = require("react/jsx-runtime");
416
- var getBundleUrl = (bundle) => globalThis.__remote_bundle_url__?.[bundle];
417
- function createRemoteLoader(bundle, resolveClientUrl) {
418
- return ({ src, width, quality }) => {
419
- const bundleUrl = getBundleUrl(bundle);
420
- const origin = bundleUrl?.origin ?? "";
421
- let imageUrl = src;
422
- try {
423
- const parsed = new URL(src);
424
- if (origin && parsed.origin === origin) {
425
- imageUrl = parsed.pathname + parsed.search;
426
- }
427
- } catch {
428
- }
429
- const { assetPrefix } = /^(?<assetPrefix>.*?)\/_next\//.exec(imageUrl)?.groups ?? {};
430
- const url = `${origin}${assetPrefix ?? ""}/_next/image?url=${encodeURIComponent(imageUrl)}&w=${width}&q=${quality ?? 75}`;
431
- const remoteSrc = bundleUrl?.href ?? url;
432
- return resolveClientUrl?.(remoteSrc, url) ?? url;
433
- };
434
- }
435
- function imageImpl2(ImageComponent, bundle, resolveClientUrl, useRemoteLoader) {
436
- const remoteLoader = useRemoteLoader ? createRemoteLoader(bundle, resolveClientUrl) : void 0;
437
- const component = function RemoteImage(props) {
438
- if (remoteLoader) {
439
- return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(ImageComponent, { loader: remoteLoader, ...props });
440
- }
441
- const rawSrc = applyBundleUrlToImagePropsSrc(bundle, props.src);
442
- const bundleUrl = getBundleUrl(bundle);
443
- const remoteSrc = bundleUrl?.href ?? rawSrc;
444
- const src = resolveClientUrl?.(remoteSrc, rawSrc) ?? rawSrc;
445
- return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(ImageComponent, { ...props, src });
446
- };
447
- component.default = component;
448
- return component;
449
- }
450
-
451
- // src/host/nextjs/app-client-only.tsx
452
- var import_context3 = require("#internal/host/react/context");
453
-
454
- // src/host/react/index.tsx
455
- var import_react3 = require("react");
456
- var import_react_dom = require("react-dom");
457
- var import_context2 = require("#internal/host/react/context");
458
-
459
- // src/host/server/fetch-headers.ts
460
- function remoteFetchHeaders() {
461
- return {
462
- /**
463
- * Authenticates deployment protection for the remote. Needed for SSR and SSG clients.
464
- * If the remote component uses vercel deployment protection, ensure the host and remote vercel
465
- * projects share a common automation bypass secret, and the shared secret is used as the
466
- * VERCEL_AUTOMATION_BYPASS_SECRET env var in the host project.
467
- */
468
- ...typeof process === "object" && typeof process.env === "object" && typeof process.env.VERCEL_AUTOMATION_BYPASS_SECRET === "string" ? {
469
- "x-vercel-protection-bypass": process.env.VERCEL_AUTOMATION_BYPASS_SECRET
470
- } : {},
471
- Accept: "text/html"
472
- };
473
- }
474
-
475
- // src/host/server/fetch-with-hooks.ts
476
- async function fetchWithWarning(url, init) {
477
- try {
478
- return await fetch(url, init);
479
- } catch (error) {
480
- warnCrossOriginFetchError("FetchRemoteComponent", url);
481
- throw error;
482
- }
483
- }
484
- async function fetchWithHooks(url, additionalInit, options = {}) {
485
- const {
486
- onRequest,
487
- onResponse,
488
- abortController = new AbortController()
489
- } = options;
490
- const signal = abortController.signal;
491
- const hookOptions = {
492
- signal,
493
- abort: (reason) => abortController.abort(reason)
494
- };
495
- const init = {
496
- method: "GET",
497
- headers: remoteFetchHeaders(),
498
- signal,
499
- ...additionalInit
500
- };
501
- const res = await onRequest?.(url, init, hookOptions) ?? await fetchWithWarning(url, init);
502
- return await onResponse?.(url, res, hookOptions) ?? res;
503
- }
504
-
505
- // src/host/server/get-client-or-server-url.ts
506
- function getClientOrServerUrl(src, serverFallback) {
507
- const fallback = typeof location !== "undefined" ? location.href : serverFallback;
508
- if (!src) {
509
- return new URL(fallback);
510
- }
511
- return typeof src === "string" ? new URL(src, fallback) : src;
512
- }
513
-
514
498
  // src/host/shared/state.ts
515
499
  function createHostState() {
516
500
  return {
@@ -1989,40 +1973,10 @@ async function loadStaticRemoteComponent(scripts, url, resolveClientUrl) {
1989
1973
  // src/host/react/hooks/use-resolve-client-url.ts
1990
1974
  var import_react = require("react");
1991
1975
  var import_context = require("#internal/host/react/context");
1992
-
1993
- // src/runtime/url/resolve-client-url.ts
1994
- function withRemoteSrc(resolveClientUrl, remoteSrc) {
1995
- const remoteOrigin = parseOrigin(remoteSrc);
1996
- return (url) => {
1997
- const urlOrigin = parseOrigin(url);
1998
- if (remoteOrigin && urlOrigin && urlOrigin !== remoteOrigin) {
1999
- return void 0;
2000
- }
2001
- return resolveClientUrl(remoteSrc, url);
2002
- };
2003
- }
2004
- function parseOrigin(url) {
2005
- try {
2006
- return new URL(url).origin;
2007
- } catch {
2008
- return void 0;
2009
- }
2010
- }
2011
-
2012
- // src/runtime/url/default-resolve-client-url.ts
2013
- function bindResolveClientUrl(prop, remoteSrc) {
2014
- return prop ? withRemoteSrc(prop, remoteSrc) : void 0;
2015
- }
2016
-
2017
- // src/host/react/hooks/use-resolve-client-url.ts
2018
1976
  function useResolveClientUrl(prop, urlHref) {
2019
1977
  const { resolveClientUrl: contextValue } = (0, import_context.useRemoteComponentsContext)();
2020
1978
  const raw = prop ?? contextValue;
2021
- const bound = (0, import_react.useMemo)(
2022
- () => bindResolveClientUrl(raw, urlHref),
2023
- [raw, urlHref]
2024
- );
2025
- return { bound, raw };
1979
+ return (0, import_react.useMemo)(() => bindResolveClientUrl(raw, urlHref), [raw, urlHref]);
2026
1980
  }
2027
1981
 
2028
1982
  // src/host/react/hooks/use-shadow-root.ts
@@ -2097,7 +2051,7 @@ function getRemoteComponentHtml(html) {
2097
2051
  }
2098
2052
 
2099
2053
  // src/host/react/index.tsx
2100
- var import_jsx_runtime3 = (
2054
+ var import_jsx_runtime2 = (
2101
2055
  // TODO: remove wrapper div by converting HTML to RSC or React tree
2102
2056
  require("react/jsx-runtime")
2103
2057
  );
@@ -2131,10 +2085,7 @@ function ConsumeRemoteComponent({
2131
2085
  null
2132
2086
  );
2133
2087
  const url = (0, import_react3.useMemo)(() => getClientOrServerUrl(src, DUMMY_FALLBACK), [src]);
2134
- const { bound: resolveClientUrl } = useResolveClientUrl(
2135
- resolveClientUrlProp,
2136
- url.href
2137
- );
2088
+ const resolveClientUrl = useResolveClientUrl(resolveClientUrlProp, url.href);
2138
2089
  const id = url.origin === (typeof location !== "undefined" ? location.origin : DUMMY_FALLBACK) ? url.pathname : url.href;
2139
2090
  const keySuffix = `${escapeString(id)}_${escapeString(
2140
2091
  data?.name ?? name
@@ -2407,7 +2358,7 @@ function ConsumeRemoteComponent({
2407
2358
  onLoad?.(src);
2408
2359
  } else if (isolate === false) {
2409
2360
  setRemoteComponent(
2410
- /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
2361
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
2411
2362
  "div",
2412
2363
  {
2413
2364
  dangerouslySetInnerHTML: { __html: component.innerHTML },
@@ -2520,13 +2471,13 @@ function ConsumeRemoteComponent({
2520
2471
  if (remoteComponent instanceof Error) {
2521
2472
  throw remoteComponent;
2522
2473
  }
2523
- const metadataJson = /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("script", { "data-remote-component": true, type: "application/json", children: JSON.stringify({
2474
+ const metadataJson = /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("script", { "data-remote-component": true, type: "application/json", children: JSON.stringify({
2524
2475
  name: data?.name || name,
2525
2476
  bundle: data?.bundle || "default",
2526
2477
  route: data?.route || DEFAULT_ROUTE,
2527
2478
  runtime: hostStateRef.current.prevIsRemoteComponent ? RUNTIME_SCRIPT : data?.runtime || RUNTIME_WEBPACK
2528
2479
  }) });
2529
- const resetStyle = reset ? /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("style", { "data-remote-components-reset": "react", children: `:host { all: initial; }` }) : null;
2480
+ const resetStyle = reset ? /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("style", { "data-remote-components-reset": "react", children: `:host { all: initial; }` }) : null;
2530
2481
  const linksToRender = data?.links?.map((link) => /* @__PURE__ */ (0, import_react4.createElement)(
2531
2482
  "link",
2532
2483
  {
@@ -2535,7 +2486,7 @@ function ConsumeRemoteComponent({
2535
2486
  key: JSON.stringify(link)
2536
2487
  }
2537
2488
  )) || null;
2538
- const componentToRender = /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(import_jsx_runtime3.Fragment, { children: [
2489
+ const componentToRender = /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(import_jsx_runtime2.Fragment, { children: [
2539
2490
  resetStyle,
2540
2491
  linksToRender,
2541
2492
  remoteComponent ?? children
@@ -2573,9 +2524,9 @@ function ConsumeRemoteComponent({
2573
2524
  if (shadowRemoteComponentHtml) {
2574
2525
  shadowRemoteComponentHtml.remove();
2575
2526
  }
2576
- return /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(import_jsx_runtime3.Fragment, { children: [
2527
+ return /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(import_jsx_runtime2.Fragment, { children: [
2577
2528
  metadataJson,
2578
- /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(
2529
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(
2579
2530
  "div",
2580
2531
  {
2581
2532
  "data-remote-component-id": `shadowroot_${keySuffix}`,
@@ -2584,8 +2535,8 @@ function ConsumeRemoteComponent({
2584
2535
  children: [
2585
2536
  typeof document === "undefined" ? (
2586
2537
  // eslint-disable-next-line react/no-unknown-property
2587
- /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("template", { shadowrootmode: mode, children: [
2588
- typeof document === "undefined" ? /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
2538
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("template", { shadowrootmode: mode, children: [
2539
+ typeof document === "undefined" ? /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
2589
2540
  "div",
2590
2541
  {
2591
2542
  dangerouslySetInnerHTML: {
@@ -2607,12 +2558,12 @@ function ConsumeRemoteComponent({
2607
2558
  ] })
2608
2559
  ) : null,
2609
2560
  shadowRoot && remoteComponent ? (0, import_react_dom.createPortal)(
2610
- /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(import_jsx_runtime3.Fragment, { children: [
2611
- /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("template", { id: `${name}_start` }),
2561
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(import_jsx_runtime2.Fragment, { children: [
2562
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("template", { id: `${name}_start` }),
2612
2563
  resetStyle,
2613
2564
  linksToRender,
2614
2565
  remoteComponent,
2615
- /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("template", { id: `${name}_end`, ref: endTemplateRef })
2566
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("template", { id: `${name}_end`, ref: endTemplateRef })
2616
2567
  ] }),
2617
2568
  shadowRoot
2618
2569
  ) : null
@@ -2622,11 +2573,11 @@ function ConsumeRemoteComponent({
2622
2573
  ] });
2623
2574
  }
2624
2575
  htmlRef.current = null;
2625
- return /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(import_jsx_runtime3.Fragment, { children: [
2626
- /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("template", { id: `${name}_start` }),
2576
+ return /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(import_jsx_runtime2.Fragment, { children: [
2577
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("template", { id: `${name}_start` }),
2627
2578
  metadataJson,
2628
2579
  componentToRender,
2629
- /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("template", { id: `${name}_end`, ref: endTemplateRef })
2580
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("template", { id: `${name}_end`, ref: endTemplateRef })
2630
2581
  ] });
2631
2582
  }
2632
2583
 
@@ -2695,25 +2646,8 @@ var routerImpl = async () => {
2695
2646
  });
2696
2647
  };
2697
2648
 
2698
- // src/host/nextjs/image-shared.ts
2699
- function createNextImageSharedEntries(getWrappedImage, options) {
2700
- const entries = {
2701
- "next/image": (bundle) => Promise.resolve(getWrappedImage(bundle)),
2702
- "next/dist/client/image-component": (bundle) => Promise.resolve({
2703
- Image: getWrappedImage(bundle)
2704
- })
2705
- };
2706
- if (options?.getImageProps) {
2707
- entries["next/dist/api/image"] = (bundle) => Promise.resolve({
2708
- default: getWrappedImage(bundle),
2709
- getImageProps: options.getImageProps
2710
- });
2711
- }
2712
- return entries;
2713
- }
2714
-
2715
2649
  // src/host/nextjs/app-client-only.tsx
2716
- var import_jsx_runtime4 = require("react/jsx-runtime");
2650
+ var import_jsx_runtime3 = require("react/jsx-runtime");
2717
2651
  async function tryImportShared() {
2718
2652
  try {
2719
2653
  const { shared: shared2 } = await Promise.resolve().then(() => (init_app(), app_exports));
@@ -2730,9 +2664,7 @@ var sharedModules = async (userShared, resolveClientUrl) => {
2730
2664
  return {
2731
2665
  ...resolvedShared,
2732
2666
  "next/router": routerImpl,
2733
- ...createNextImageSharedEntries(
2734
- (bundle) => imageImpl2(Image.default, bundle ?? "default", resolveClientUrl)
2735
- ),
2667
+ ...createImageLoaderSharedEntries({ unbound: resolveClientUrl }),
2736
2668
  ...resolvedUserShared
2737
2669
  };
2738
2670
  };
@@ -2746,7 +2678,7 @@ function RemoteComponentsClientProvider({
2746
2678
  () => sharedModules(shared2, resolveClientUrl),
2747
2679
  [shared2, resolveClientUrl]
2748
2680
  );
2749
- return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
2681
+ return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
2750
2682
  import_context3.RemoteComponentsContext,
2751
2683
  {
2752
2684
  value: { shared: mergedShared, resolveClientUrl, ...props },
@@ -2758,7 +2690,7 @@ function ConsumeRemoteComponent2(props) {
2758
2690
  if (typeof props.src !== "string" && !(props.src instanceof URL)) {
2759
2691
  return props.children ?? null;
2760
2692
  }
2761
- return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
2693
+ return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
2762
2694
  ConsumeRemoteComponent,
2763
2695
  {
2764
2696
  ...props,