remote-components 0.2.2 → 0.3.1
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/config/nextjs.cjs +2 -4
- package/dist/config/nextjs.cjs.map +1 -1
- package/dist/config/nextjs.d.ts +1 -1
- package/dist/config/nextjs.js +2 -4
- package/dist/config/nextjs.js.map +1 -1
- package/dist/host/html.cjs +128 -112
- package/dist/host/html.cjs.map +1 -1
- package/dist/host/html.js +128 -115
- package/dist/host/html.js.map +1 -1
- package/dist/host/nextjs/app/client-only.cjs +233 -259
- package/dist/host/nextjs/app/client-only.cjs.map +1 -1
- package/dist/host/nextjs/app/client-only.js +234 -260
- package/dist/host/nextjs/app/client-only.js.map +1 -1
- package/dist/host/nextjs/app.cjs +5 -6
- package/dist/host/nextjs/app.cjs.map +1 -1
- package/dist/host/nextjs/app.js +5 -6
- package/dist/host/nextjs/app.js.map +1 -1
- package/dist/host/nextjs/pages.cjs +7 -19
- package/dist/host/nextjs/pages.cjs.map +1 -1
- package/dist/host/nextjs/pages.js +11 -20
- package/dist/host/nextjs/pages.js.map +1 -1
- package/dist/host/react.cjs +101 -93
- package/dist/host/react.cjs.map +1 -1
- package/dist/host/react.js +101 -93
- package/dist/host/react.js.map +1 -1
- package/dist/internal/host/nextjs/app-client.cjs +3 -8
- package/dist/internal/host/nextjs/app-client.cjs.map +1 -1
- package/dist/internal/host/nextjs/app-client.js +4 -9
- package/dist/internal/host/nextjs/app-client.js.map +1 -1
- package/dist/internal/host/nextjs/dom-flight.cjs +16 -7
- package/dist/internal/host/nextjs/dom-flight.cjs.map +1 -1
- package/dist/internal/host/nextjs/dom-flight.d.ts +2 -2
- package/dist/internal/host/nextjs/dom-flight.js +16 -7
- package/dist/internal/host/nextjs/dom-flight.js.map +1 -1
- package/dist/internal/host/nextjs/image-shared.cjs +25 -15
- package/dist/internal/host/nextjs/image-shared.cjs.map +1 -1
- package/dist/internal/host/nextjs/image-shared.d.ts +19 -6
- package/dist/internal/host/nextjs/image-shared.js +24 -14
- package/dist/internal/host/nextjs/image-shared.js.map +1 -1
- package/dist/internal/host/react/hooks/use-resolve-client-url.cjs +1 -5
- package/dist/internal/host/react/hooks/use-resolve-client-url.cjs.map +1 -1
- package/dist/internal/host/react/hooks/use-resolve-client-url.d.ts +1 -4
- package/dist/internal/host/react/hooks/use-resolve-client-url.js +1 -5
- package/dist/internal/host/react/hooks/use-resolve-client-url.js.map +1 -1
- package/dist/internal/host/server/fetch-remote-component.cjs +164 -149
- package/dist/internal/host/server/fetch-remote-component.cjs.map +1 -1
- package/dist/internal/host/server/fetch-remote-component.js +166 -149
- package/dist/internal/host/server/fetch-remote-component.js.map +1 -1
- package/dist/internal/host/shared/polyfill.cjs +10 -65
- package/dist/internal/host/shared/polyfill.cjs.map +1 -1
- package/dist/internal/host/shared/polyfill.d.ts +1 -3
- package/dist/internal/host/shared/polyfill.js +9 -63
- package/dist/internal/host/shared/polyfill.js.map +1 -1
- package/dist/internal/host/shared/remote-image-loader.cjs +53 -0
- package/dist/internal/host/shared/remote-image-loader.cjs.map +1 -0
- package/dist/internal/host/shared/remote-image-loader.d.ts +30 -0
- package/dist/internal/host/shared/remote-image-loader.js +29 -0
- package/dist/internal/host/shared/remote-image-loader.js.map +1 -0
- package/dist/internal/runtime/constants.cjs +6 -6
- package/dist/internal/runtime/constants.cjs.map +1 -1
- package/dist/internal/runtime/constants.d.ts +3 -3
- package/dist/internal/runtime/constants.js +4 -4
- package/dist/internal/runtime/constants.js.map +1 -1
- package/dist/internal/runtime/html/parse-remote-html.cjs +11 -15
- package/dist/internal/runtime/html/parse-remote-html.cjs.map +1 -1
- package/dist/internal/runtime/html/parse-remote-html.d.ts +2 -12
- package/dist/internal/runtime/html/parse-remote-html.js +17 -15
- package/dist/internal/runtime/html/parse-remote-html.js.map +1 -1
- package/dist/internal/runtime/loaders/script-loader.cjs +2 -2
- package/dist/internal/runtime/loaders/script-loader.cjs.map +1 -1
- package/dist/internal/runtime/loaders/script-loader.js +1 -1
- package/dist/internal/runtime/loaders/script-loader.js.map +1 -1
- package/dist/internal/runtime/metadata.cjs +42 -0
- package/dist/internal/runtime/metadata.cjs.map +1 -1
- package/dist/internal/runtime/metadata.d.ts +21 -1
- package/dist/internal/runtime/metadata.js +38 -0
- package/dist/internal/runtime/metadata.js.map +1 -1
- package/dist/internal/runtime/patterns.cjs +38 -0
- package/dist/internal/runtime/patterns.cjs.map +1 -0
- package/dist/internal/runtime/patterns.d.ts +5 -0
- package/dist/internal/runtime/patterns.js +12 -0
- package/dist/internal/runtime/patterns.js.map +1 -0
- package/dist/internal/runtime/turbopack/chunk-loader.cjs +4 -3
- package/dist/internal/runtime/turbopack/chunk-loader.cjs.map +1 -1
- package/dist/internal/runtime/turbopack/chunk-loader.js +1 -1
- package/dist/internal/runtime/turbopack/chunk-loader.js.map +1 -1
- package/dist/internal/runtime/turbopack/webpack-runtime.cjs +11 -2
- package/dist/internal/runtime/turbopack/webpack-runtime.cjs.map +1 -1
- package/dist/internal/runtime/turbopack/webpack-runtime.js +10 -2
- package/dist/internal/runtime/turbopack/webpack-runtime.js.map +1 -1
- package/dist/remote/nextjs/app.cjs +2 -1
- package/dist/remote/nextjs/app.cjs.map +1 -1
- package/dist/remote/nextjs/app.js +2 -1
- package/dist/remote/nextjs/app.js.map +1 -1
- package/package.json +1 -1
- package/dist/internal/host/nextjs/image-impl.cjs +0 -64
- package/dist/internal/host/nextjs/image-impl.cjs.map +0 -1
- package/dist/internal/host/nextjs/image-impl.d.ts +0 -10
- package/dist/internal/host/nextjs/image-impl.js +0 -40
- 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
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
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/
|
|
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 {
|
|
@@ -550,12 +534,12 @@ var attrToProp = {
|
|
|
550
534
|
};
|
|
551
535
|
|
|
552
536
|
// src/runtime/constants.ts
|
|
537
|
+
var DEFAULT_BUNDLE_NAME = "__vercel_remote_bundle";
|
|
538
|
+
var DEFAULT_COMPONENT_NAME = "__vercel_remote_component";
|
|
553
539
|
var DEFAULT_ROUTE = "/";
|
|
554
540
|
var RUNTIME_WEBPACK = "webpack";
|
|
555
541
|
var RUNTIME_TURBOPACK = "turbopack";
|
|
556
542
|
var RUNTIME_SCRIPT = "script";
|
|
557
|
-
var REMOTE_COMPONENT_REGEX = /(?<prefix>.*?)\[(?<bundle>[^\]]+)\](?:%20| )(?<id>.+)/;
|
|
558
|
-
var NEXT_BUNDLE_PATH_RE = /\/_next\/\[.+\](?:%20| )/;
|
|
559
543
|
function getBundleKey(bundle) {
|
|
560
544
|
return escapeString(bundle);
|
|
561
545
|
}
|
|
@@ -622,6 +606,38 @@ function applyOriginToNodes(doc, url, resolveClientUrl) {
|
|
|
622
606
|
}
|
|
623
607
|
}
|
|
624
608
|
|
|
609
|
+
// src/runtime/metadata.ts
|
|
610
|
+
var VALID_RUNTIMES = /* @__PURE__ */ new Set(["webpack", "turbopack", "script"]);
|
|
611
|
+
var VALID_TYPES = /* @__PURE__ */ new Set([
|
|
612
|
+
"nextjs",
|
|
613
|
+
"remote-component",
|
|
614
|
+
"unknown"
|
|
615
|
+
]);
|
|
616
|
+
function isRuntime(value) {
|
|
617
|
+
return VALID_RUNTIMES.has(value);
|
|
618
|
+
}
|
|
619
|
+
function isComponentType(value) {
|
|
620
|
+
return VALID_TYPES.has(value);
|
|
621
|
+
}
|
|
622
|
+
function toRuntime(value) {
|
|
623
|
+
return value && isRuntime(value) ? value : "webpack";
|
|
624
|
+
}
|
|
625
|
+
function toComponentType(value) {
|
|
626
|
+
return value && isComponentType(value) ? value : "unknown";
|
|
627
|
+
}
|
|
628
|
+
function buildMetadata(attrs, url) {
|
|
629
|
+
const id = attrs.id || DEFAULT_COMPONENT_NAME;
|
|
630
|
+
const bundle = attrs.bundle || process.env.NEXT_PUBLIC_MFE_CURRENT_APPLICATION || DEFAULT_BUNDLE_NAME;
|
|
631
|
+
return {
|
|
632
|
+
name: attrs.name || id.replace(/_ssr$/, ""),
|
|
633
|
+
bundle,
|
|
634
|
+
route: attrs.route || url.pathname || DEFAULT_ROUTE,
|
|
635
|
+
runtime: toRuntime(attrs.runtime),
|
|
636
|
+
id,
|
|
637
|
+
type: toComponentType(attrs.type)
|
|
638
|
+
};
|
|
639
|
+
}
|
|
640
|
+
|
|
625
641
|
// src/runtime/html/parse-remote-html.ts
|
|
626
642
|
function validateSingleComponent(doc, name, url) {
|
|
627
643
|
if (doc.querySelectorAll("div[data-bundle][data-route]").length > 1 && !doc.querySelector(`div[data-bundle][data-route][id^="${name}"]`) || doc.querySelectorAll("remote-component:not([src])").length > 1 && !doc.querySelector(`remote-component[name="${name}"]`)) {
|
|
@@ -641,14 +657,6 @@ function resolveComponentName(component, nextData, fallbackName) {
|
|
|
641
657
|
const name = component?.getAttribute("id")?.replace(/_ssr$/, "") || isRemoteComponent && component?.getAttribute("name") || (nextData ? "__next" : fallbackName);
|
|
642
658
|
return { name, isRemoteComponent };
|
|
643
659
|
}
|
|
644
|
-
function extractComponentMetadata(component, nextData, name, url) {
|
|
645
|
-
return {
|
|
646
|
-
name,
|
|
647
|
-
bundle: component?.getAttribute("data-bundle") || nextData?.props.__REMOTE_COMPONENT__?.bundle || "default",
|
|
648
|
-
route: component?.getAttribute("data-route") ?? nextData?.page ?? (url.pathname || DEFAULT_ROUTE),
|
|
649
|
-
runtime: component?.getAttribute("data-runtime") ?? (nextData?.props.__REMOTE_COMPONENT__?.runtime || RUNTIME_SCRIPT)
|
|
650
|
-
};
|
|
651
|
-
}
|
|
652
660
|
function extractRemoteShared(doc, name, nextData) {
|
|
653
661
|
const remoteSharedEl = doc.querySelector(
|
|
654
662
|
`#${name}_shared[data-remote-components-shared]`
|
|
@@ -660,7 +668,7 @@ function extractRemoteShared(doc, name, nextData) {
|
|
|
660
668
|
function validateComponentFound(component, rsc, nextData, isRemoteComponent, url, name) {
|
|
661
669
|
if (!component || !(rsc || nextData || isRemoteComponent)) {
|
|
662
670
|
throw new RemoteComponentsError(
|
|
663
|
-
`Remote Component not found on ${url}.${name !==
|
|
671
|
+
`Remote Component not found on ${url}.${name !== DEFAULT_COMPONENT_NAME ? ` The name for the <RemoteComponent> is "${name}". Check <RemoteComponent> usage.` : ""} Did you forget to wrap the content in <RemoteComponent>?`
|
|
664
672
|
);
|
|
665
673
|
}
|
|
666
674
|
}
|
|
@@ -686,10 +694,15 @@ function parseRemoteComponentDocument(doc, name, url) {
|
|
|
686
694
|
name
|
|
687
695
|
);
|
|
688
696
|
const rsc = doc.querySelector(`#${resolvedName}_rsc`);
|
|
689
|
-
const metadata =
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
|
|
697
|
+
const metadata = buildMetadata(
|
|
698
|
+
{
|
|
699
|
+
name: resolvedName,
|
|
700
|
+
bundle: component?.getAttribute("data-bundle") || nextData?.props.__REMOTE_COMPONENT__?.bundle,
|
|
701
|
+
route: component?.getAttribute("data-route") ?? nextData?.page,
|
|
702
|
+
runtime: component?.getAttribute("data-runtime") ?? nextData?.props.__REMOTE_COMPONENT__?.runtime ?? RUNTIME_SCRIPT,
|
|
703
|
+
id: component?.getAttribute("id"),
|
|
704
|
+
type: component?.getAttribute("data-type")
|
|
705
|
+
},
|
|
693
706
|
url
|
|
694
707
|
);
|
|
695
708
|
const remoteShared = extractRemoteShared(doc, resolvedName, nextData);
|
|
@@ -1005,6 +1018,14 @@ function createRSCStream(rscName, data) {
|
|
|
1005
1018
|
});
|
|
1006
1019
|
}
|
|
1007
1020
|
|
|
1021
|
+
// src/runtime/patterns.ts
|
|
1022
|
+
var REMOTE_COMPONENT_REGEX = /(?<prefix>.*?)\[(?<bundle>[^\]]+)\](?:%20| )(?<id>.+)/;
|
|
1023
|
+
var NEXT_BUNDLE_PATH_RE = /\/_next\/\[.+\](?:%20| )/;
|
|
1024
|
+
var DOUBLE_SLASH_RE = /(?<!:)\/\//g;
|
|
1025
|
+
function collapseDoubleSlashes(path) {
|
|
1026
|
+
return path.replace(DOUBLE_SLASH_RE, "/");
|
|
1027
|
+
}
|
|
1028
|
+
|
|
1008
1029
|
// src/runtime/turbopack/patterns.ts
|
|
1009
1030
|
var REMOTE_SHARED_MARKER_RE = /(?:self|[a-z])\.TURBOPACK_REMOTE_SHARED/;
|
|
1010
1031
|
var REMOTE_SHARED_ASSIGNMENT_RE = /\.TURBOPACK_REMOTE_SHARED=await (?:__turbopack_context__|[a-z])\.A\((?<sharedModuleId>[0-9]+)\)/;
|
|
@@ -1594,7 +1615,7 @@ async function setupWebpackRuntime(runtime, scripts = [], url = new URL(location
|
|
|
1594
1615
|
}
|
|
1595
1616
|
}
|
|
1596
1617
|
if (runtime === RUNTIME_TURBOPACK) {
|
|
1597
|
-
await Promise.
|
|
1618
|
+
const results = await Promise.allSettled(
|
|
1598
1619
|
scripts.map((script) => {
|
|
1599
1620
|
if (script.src) {
|
|
1600
1621
|
return self.__webpack_chunk_load__?.(script.src, bundle);
|
|
@@ -1602,6 +1623,14 @@ async function setupWebpackRuntime(runtime, scripts = [], url = new URL(location
|
|
|
1602
1623
|
return Promise.resolve(void 0);
|
|
1603
1624
|
})
|
|
1604
1625
|
);
|
|
1626
|
+
for (const result of results) {
|
|
1627
|
+
if (result.status === "rejected") {
|
|
1628
|
+
logWarn(
|
|
1629
|
+
"WebpackRuntime",
|
|
1630
|
+
`Initial chunk load failed: ${String(result.reason)}`
|
|
1631
|
+
);
|
|
1632
|
+
}
|
|
1633
|
+
}
|
|
1605
1634
|
}
|
|
1606
1635
|
const coreShared = {
|
|
1607
1636
|
react: async () => (await import("react")).default,
|
|
@@ -1989,40 +2018,10 @@ async function loadStaticRemoteComponent(scripts, url, resolveClientUrl) {
|
|
|
1989
2018
|
// src/host/react/hooks/use-resolve-client-url.ts
|
|
1990
2019
|
var import_react = require("react");
|
|
1991
2020
|
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
2021
|
function useResolveClientUrl(prop, urlHref) {
|
|
2019
2022
|
const { resolveClientUrl: contextValue } = (0, import_context.useRemoteComponentsContext)();
|
|
2020
2023
|
const raw = prop ?? contextValue;
|
|
2021
|
-
|
|
2022
|
-
() => bindResolveClientUrl(raw, urlHref),
|
|
2023
|
-
[raw, urlHref]
|
|
2024
|
-
);
|
|
2025
|
-
return { bound, raw };
|
|
2024
|
+
return (0, import_react.useMemo)(() => bindResolveClientUrl(raw, urlHref), [raw, urlHref]);
|
|
2026
2025
|
}
|
|
2027
2026
|
|
|
2028
2027
|
// src/host/react/hooks/use-shadow-root.ts
|
|
@@ -2088,7 +2087,7 @@ function getRemoteComponentHtml(html) {
|
|
|
2088
2087
|
return ssrRemoteComponentContainer.innerHTML;
|
|
2089
2088
|
}
|
|
2090
2089
|
const remoteComponentContainer = temp.querySelectorAll(
|
|
2091
|
-
`div[data-bundle][data-route][data-runtime][id^="
|
|
2090
|
+
`div[data-bundle][data-route][data-runtime][id^="${DEFAULT_COMPONENT_NAME}"],div[data-bundle][data-route],div#__next,remote-component:not([src])`
|
|
2092
2091
|
);
|
|
2093
2092
|
if (remoteComponentContainer.length > 0) {
|
|
2094
2093
|
return `${Array.from(temp.querySelectorAll("link,script")).map((link) => link.outerHTML).join("")}${Array.from(remoteComponentContainer).map((container) => container.outerHTML).join("")}`;
|
|
@@ -2097,7 +2096,7 @@ function getRemoteComponentHtml(html) {
|
|
|
2097
2096
|
}
|
|
2098
2097
|
|
|
2099
2098
|
// src/host/react/index.tsx
|
|
2100
|
-
var
|
|
2099
|
+
var import_jsx_runtime2 = (
|
|
2101
2100
|
// TODO: remove wrapper div by converting HTML to RSC or React tree
|
|
2102
2101
|
require("react/jsx-runtime")
|
|
2103
2102
|
);
|
|
@@ -2108,7 +2107,7 @@ function ConsumeRemoteComponent({
|
|
|
2108
2107
|
mode = "open",
|
|
2109
2108
|
reset,
|
|
2110
2109
|
credentials: credentialsProp,
|
|
2111
|
-
name: nameProp =
|
|
2110
|
+
name: nameProp = DEFAULT_COMPONENT_NAME,
|
|
2112
2111
|
shared: sharedProp,
|
|
2113
2112
|
children,
|
|
2114
2113
|
onBeforeLoad,
|
|
@@ -2131,10 +2130,7 @@ function ConsumeRemoteComponent({
|
|
|
2131
2130
|
null
|
|
2132
2131
|
);
|
|
2133
2132
|
const url = (0, import_react3.useMemo)(() => getClientOrServerUrl(src, DUMMY_FALLBACK), [src]);
|
|
2134
|
-
const
|
|
2135
|
-
resolveClientUrlProp,
|
|
2136
|
-
url.href
|
|
2137
|
-
);
|
|
2133
|
+
const resolveClientUrl = useResolveClientUrl(resolveClientUrlProp, url.href);
|
|
2138
2134
|
const id = url.origin === (typeof location !== "undefined" ? location.origin : DUMMY_FALLBACK) ? url.pathname : url.href;
|
|
2139
2135
|
const keySuffix = `${escapeString(id)}_${escapeString(
|
|
2140
2136
|
data?.name ?? name
|
|
@@ -2407,7 +2403,7 @@ function ConsumeRemoteComponent({
|
|
|
2407
2403
|
onLoad?.(src);
|
|
2408
2404
|
} else if (isolate === false) {
|
|
2409
2405
|
setRemoteComponent(
|
|
2410
|
-
/* @__PURE__ */ (0,
|
|
2406
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
2411
2407
|
"div",
|
|
2412
2408
|
{
|
|
2413
2409
|
dangerouslySetInnerHTML: { __html: component.innerHTML },
|
|
@@ -2450,10 +2446,7 @@ function ConsumeRemoteComponent({
|
|
|
2450
2446
|
};
|
|
2451
2447
|
return {
|
|
2452
2448
|
src: new URL(
|
|
2453
|
-
`${prefix ?? ""}${path}
|
|
2454
|
-
/(?<char>[^:])(?<double>\/\/)/g,
|
|
2455
|
-
"$1/"
|
|
2456
|
-
),
|
|
2449
|
+
collapseDoubleSlashes(`${prefix ?? ""}${path}`),
|
|
2457
2450
|
url
|
|
2458
2451
|
).href
|
|
2459
2452
|
};
|
|
@@ -2520,13 +2513,13 @@ function ConsumeRemoteComponent({
|
|
|
2520
2513
|
if (remoteComponent instanceof Error) {
|
|
2521
2514
|
throw remoteComponent;
|
|
2522
2515
|
}
|
|
2523
|
-
const metadataJson = /* @__PURE__ */ (0,
|
|
2516
|
+
const metadataJson = /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("script", { "data-remote-component": true, type: "application/json", children: JSON.stringify({
|
|
2524
2517
|
name: data?.name || name,
|
|
2525
2518
|
bundle: data?.bundle || "default",
|
|
2526
2519
|
route: data?.route || DEFAULT_ROUTE,
|
|
2527
2520
|
runtime: hostStateRef.current.prevIsRemoteComponent ? RUNTIME_SCRIPT : data?.runtime || RUNTIME_WEBPACK
|
|
2528
2521
|
}) });
|
|
2529
|
-
const resetStyle = reset ? /* @__PURE__ */ (0,
|
|
2522
|
+
const resetStyle = reset ? /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("style", { "data-remote-components-reset": "react", children: `:host { all: initial; }` }) : null;
|
|
2530
2523
|
const linksToRender = data?.links?.map((link) => /* @__PURE__ */ (0, import_react4.createElement)(
|
|
2531
2524
|
"link",
|
|
2532
2525
|
{
|
|
@@ -2535,7 +2528,7 @@ function ConsumeRemoteComponent({
|
|
|
2535
2528
|
key: JSON.stringify(link)
|
|
2536
2529
|
}
|
|
2537
2530
|
)) || null;
|
|
2538
|
-
const componentToRender = /* @__PURE__ */ (0,
|
|
2531
|
+
const componentToRender = /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(import_jsx_runtime2.Fragment, { children: [
|
|
2539
2532
|
resetStyle,
|
|
2540
2533
|
linksToRender,
|
|
2541
2534
|
remoteComponent ?? children
|
|
@@ -2573,9 +2566,9 @@ function ConsumeRemoteComponent({
|
|
|
2573
2566
|
if (shadowRemoteComponentHtml) {
|
|
2574
2567
|
shadowRemoteComponentHtml.remove();
|
|
2575
2568
|
}
|
|
2576
|
-
return /* @__PURE__ */ (0,
|
|
2569
|
+
return /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(import_jsx_runtime2.Fragment, { children: [
|
|
2577
2570
|
metadataJson,
|
|
2578
|
-
/* @__PURE__ */ (0,
|
|
2571
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(
|
|
2579
2572
|
"div",
|
|
2580
2573
|
{
|
|
2581
2574
|
"data-remote-component-id": `shadowroot_${keySuffix}`,
|
|
@@ -2584,8 +2577,8 @@ function ConsumeRemoteComponent({
|
|
|
2584
2577
|
children: [
|
|
2585
2578
|
typeof document === "undefined" ? (
|
|
2586
2579
|
// eslint-disable-next-line react/no-unknown-property
|
|
2587
|
-
/* @__PURE__ */ (0,
|
|
2588
|
-
typeof document === "undefined" ? /* @__PURE__ */ (0,
|
|
2580
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("template", { shadowrootmode: mode, children: [
|
|
2581
|
+
typeof document === "undefined" ? /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
2589
2582
|
"div",
|
|
2590
2583
|
{
|
|
2591
2584
|
dangerouslySetInnerHTML: {
|
|
@@ -2607,12 +2600,12 @@ function ConsumeRemoteComponent({
|
|
|
2607
2600
|
] })
|
|
2608
2601
|
) : null,
|
|
2609
2602
|
shadowRoot && remoteComponent ? (0, import_react_dom.createPortal)(
|
|
2610
|
-
/* @__PURE__ */ (0,
|
|
2611
|
-
/* @__PURE__ */ (0,
|
|
2603
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(import_jsx_runtime2.Fragment, { children: [
|
|
2604
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)("template", { id: `${name}_start` }),
|
|
2612
2605
|
resetStyle,
|
|
2613
2606
|
linksToRender,
|
|
2614
2607
|
remoteComponent,
|
|
2615
|
-
/* @__PURE__ */ (0,
|
|
2608
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)("template", { id: `${name}_end`, ref: endTemplateRef })
|
|
2616
2609
|
] }),
|
|
2617
2610
|
shadowRoot
|
|
2618
2611
|
) : null
|
|
@@ -2622,11 +2615,11 @@ function ConsumeRemoteComponent({
|
|
|
2622
2615
|
] });
|
|
2623
2616
|
}
|
|
2624
2617
|
htmlRef.current = null;
|
|
2625
|
-
return /* @__PURE__ */ (0,
|
|
2626
|
-
/* @__PURE__ */ (0,
|
|
2618
|
+
return /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(import_jsx_runtime2.Fragment, { children: [
|
|
2619
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)("template", { id: `${name}_start` }),
|
|
2627
2620
|
metadataJson,
|
|
2628
2621
|
componentToRender,
|
|
2629
|
-
/* @__PURE__ */ (0,
|
|
2622
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)("template", { id: `${name}_end`, ref: endTemplateRef })
|
|
2630
2623
|
] });
|
|
2631
2624
|
}
|
|
2632
2625
|
|
|
@@ -2695,25 +2688,8 @@ var routerImpl = async () => {
|
|
|
2695
2688
|
});
|
|
2696
2689
|
};
|
|
2697
2690
|
|
|
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
2691
|
// src/host/nextjs/app-client-only.tsx
|
|
2716
|
-
var
|
|
2692
|
+
var import_jsx_runtime3 = require("react/jsx-runtime");
|
|
2717
2693
|
async function tryImportShared() {
|
|
2718
2694
|
try {
|
|
2719
2695
|
const { shared: shared2 } = await Promise.resolve().then(() => (init_app(), app_exports));
|
|
@@ -2730,9 +2706,7 @@ var sharedModules = async (userShared, resolveClientUrl) => {
|
|
|
2730
2706
|
return {
|
|
2731
2707
|
...resolvedShared,
|
|
2732
2708
|
"next/router": routerImpl,
|
|
2733
|
-
...
|
|
2734
|
-
(bundle) => imageImpl2(Image.default, bundle ?? "default", resolveClientUrl)
|
|
2735
|
-
),
|
|
2709
|
+
...createImageLoaderSharedEntries({ unbound: resolveClientUrl }),
|
|
2736
2710
|
...resolvedUserShared
|
|
2737
2711
|
};
|
|
2738
2712
|
};
|
|
@@ -2746,7 +2720,7 @@ function RemoteComponentsClientProvider({
|
|
|
2746
2720
|
() => sharedModules(shared2, resolveClientUrl),
|
|
2747
2721
|
[shared2, resolveClientUrl]
|
|
2748
2722
|
);
|
|
2749
|
-
return /* @__PURE__ */ (0,
|
|
2723
|
+
return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
|
|
2750
2724
|
import_context3.RemoteComponentsContext,
|
|
2751
2725
|
{
|
|
2752
2726
|
value: { shared: mergedShared, resolveClientUrl, ...props },
|
|
@@ -2758,7 +2732,7 @@ function ConsumeRemoteComponent2(props) {
|
|
|
2758
2732
|
if (typeof props.src !== "string" && !(props.src instanceof URL)) {
|
|
2759
2733
|
return props.children ?? null;
|
|
2760
2734
|
}
|
|
2761
|
-
return /* @__PURE__ */ (0,
|
|
2735
|
+
return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
|
|
2762
2736
|
ConsumeRemoteComponent,
|
|
2763
2737
|
{
|
|
2764
2738
|
...props,
|