remote-components 0.0.34 → 0.0.36
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/html/host.cjs +127 -117
- package/dist/html/host.cjs.map +1 -1
- package/dist/html/host.js +127 -117
- package/dist/html/host.js.map +1 -1
- package/dist/html/remote.cjs +4 -3
- package/dist/html/remote.cjs.map +1 -1
- package/dist/html/remote.js +4 -3
- package/dist/html/remote.js.map +1 -1
- package/dist/internal/next/host/app-router-client.cjs +4 -15
- package/dist/internal/next/host/app-router-client.cjs.map +1 -1
- package/dist/internal/next/host/app-router-client.js +10 -21
- package/dist/internal/next/host/app-router-client.js.map +1 -1
- package/dist/internal/next/host/app-router-compat.cjs.map +1 -1
- package/dist/internal/next/host/app-router-compat.d.ts +1 -1
- package/dist/internal/next/host/app-router-compat.js.map +1 -1
- package/dist/internal/next/remote/render-server.cjs +1 -1
- package/dist/internal/next/remote/render-server.cjs.map +1 -1
- package/dist/internal/next/remote/render-server.js +1 -1
- package/dist/internal/next/remote/render-server.js.map +1 -1
- package/dist/internal/shared/client/polyfill.cjs.map +1 -1
- package/dist/internal/shared/client/polyfill.js.map +1 -1
- package/dist/internal/shared/client/remote-component.cjs +179 -174
- package/dist/internal/shared/client/remote-component.cjs.map +1 -1
- package/dist/internal/shared/client/remote-component.d.ts +23 -23
- package/dist/internal/shared/client/remote-component.js +179 -174
- package/dist/internal/shared/client/remote-component.js.map +1 -1
- package/dist/internal/shared/error.cjs +1 -1
- package/dist/internal/shared/error.cjs.map +1 -1
- package/dist/internal/shared/error.js +1 -1
- package/dist/internal/shared/error.js.map +1 -1
- package/dist/internal/shared/ssr/dom-flight.cjs +7 -3
- package/dist/internal/shared/ssr/dom-flight.cjs.map +1 -1
- package/dist/internal/shared/ssr/dom-flight.js +7 -3
- package/dist/internal/shared/ssr/dom-flight.js.map +1 -1
- package/dist/internal/shared/ssr/fetch-remote-component.cjs +4 -4
- package/dist/internal/shared/ssr/fetch-remote-component.cjs.map +1 -1
- package/dist/internal/shared/ssr/fetch-remote-component.js +5 -5
- package/dist/internal/shared/ssr/fetch-remote-component.js.map +1 -1
- package/dist/next/config.cjs +100 -86
- package/dist/next/config.cjs.map +1 -1
- package/dist/next/config.js +100 -86
- package/dist/next/config.js.map +1 -1
- package/dist/next/host/app-router-server.cjs.map +1 -1
- package/dist/next/host/app-router-server.js +1 -1
- package/dist/next/host/app-router-server.js.map +1 -1
- package/dist/next/host/client/index.cjs +723 -718
- package/dist/next/host/client/index.cjs.map +1 -1
- package/dist/next/host/client/index.js +727 -722
- package/dist/next/host/client/index.js.map +1 -1
- package/dist/next/host/pages-router-server.cjs +4 -4
- package/dist/next/host/pages-router-server.cjs.map +1 -1
- package/dist/next/host/pages-router-server.js +4 -4
- package/dist/next/host/pages-router-server.js.map +1 -1
- package/dist/next/{middleware.cjs → proxy.cjs} +24 -14
- package/dist/next/proxy.cjs.map +1 -0
- package/dist/next/proxy.d.ts +29 -0
- package/dist/next/{middleware.js → proxy.js} +21 -11
- package/dist/next/proxy.js.map +1 -0
- package/dist/react/index.cjs +4 -4
- package/dist/react/index.cjs.map +1 -1
- package/dist/react/index.js +11 -11
- package/dist/react/index.js.map +1 -1
- package/package.json +15 -9
- package/dist/next/middleware.cjs.map +0 -1
- package/dist/next/middleware.d.ts +0 -29
- package/dist/next/middleware.js.map +0 -1
|
@@ -5,226 +5,573 @@ import * as Image from "next/image";
|
|
|
5
5
|
|
|
6
6
|
// src/react/index.tsx
|
|
7
7
|
import {
|
|
8
|
-
|
|
8
|
+
startTransition,
|
|
9
9
|
useEffect,
|
|
10
10
|
useLayoutEffect,
|
|
11
|
-
useRef,
|
|
12
11
|
useMemo,
|
|
13
|
-
|
|
12
|
+
useRef,
|
|
13
|
+
useState
|
|
14
14
|
} from "react";
|
|
15
15
|
import { createPortal } from "react-dom";
|
|
16
16
|
|
|
17
|
-
// src/shared/client/
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
17
|
+
// src/shared/client/apply-origin.ts
|
|
18
|
+
var tagNames = [
|
|
19
|
+
"img",
|
|
20
|
+
"source",
|
|
21
|
+
"video",
|
|
22
|
+
"audio",
|
|
23
|
+
"track",
|
|
24
|
+
"iframe",
|
|
25
|
+
"embed",
|
|
26
|
+
"script",
|
|
27
|
+
"link"
|
|
28
|
+
];
|
|
29
|
+
function applyOriginToNodes(doc, url) {
|
|
30
|
+
if (url.origin !== location.origin) {
|
|
31
|
+
const nodes = doc.querySelectorAll(
|
|
32
|
+
tagNames.map(
|
|
33
|
+
(type) => `${type}[src],${type}[srcset],${type}[href],${type}[imagesrcset]`
|
|
34
|
+
).join(",")
|
|
30
35
|
);
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
ids = modulePaths.filter((p) => p.includes(key));
|
|
36
|
+
nodes.forEach((node) => {
|
|
37
|
+
if (node.hasAttribute("src") && /^[./]+\/?/.test(node.getAttribute("src") ?? "")) {
|
|
38
|
+
node.src = new URL(node.getAttribute("src") ?? "/", url).href;
|
|
35
39
|
}
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
40
|
+
if (node.hasAttribute("href") && /^[./]+\/?/.test(node.getAttribute("href") ?? "")) {
|
|
41
|
+
node.setAttribute(
|
|
42
|
+
"href",
|
|
43
|
+
new URL(node.getAttribute("href") ?? "/", url).href
|
|
44
|
+
);
|
|
45
|
+
}
|
|
46
|
+
if (node.hasAttribute("srcset")) {
|
|
47
|
+
const srcSet = node.getAttribute("srcset")?.split(",").map((entry) => {
|
|
48
|
+
const [urlPart, descriptor] = entry.trim().split(/\s+/);
|
|
49
|
+
if (!urlPart)
|
|
50
|
+
return entry;
|
|
51
|
+
const absoluteUrl = new URL(urlPart, url).href;
|
|
52
|
+
return descriptor ? `${absoluteUrl} ${descriptor}` : absoluteUrl;
|
|
53
|
+
}).join(", ");
|
|
54
|
+
if (srcSet) {
|
|
55
|
+
node.setAttribute("srcset", srcSet);
|
|
45
56
|
}
|
|
46
57
|
}
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
}
|
|
58
|
-
};
|
|
59
|
-
function multipleRemoteComponentsError(url) {
|
|
60
|
-
return new Error(
|
|
61
|
-
`Multiple Remote Components found at "${url}". When a page exposes multiple Remote Components you must specify the "name" prop to select which one to load.`
|
|
62
|
-
);
|
|
63
|
-
}
|
|
64
|
-
function failedToFetchRemoteComponentError(url, error) {
|
|
65
|
-
return new RemoteComponentsError(
|
|
66
|
-
`Failed to fetch Remote Component from "${url}". Is the URL correct and accessible?`,
|
|
67
|
-
{ cause: error instanceof Error ? error : new Error(String(error)) }
|
|
68
|
-
);
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
// src/shared/webpack/next-client-pages-loader.ts
|
|
72
|
-
function nextClientPagesLoader(bundle, route, styleContainer = document.head) {
|
|
73
|
-
const self = globalThis;
|
|
74
|
-
const nextCssOriginal = document.querySelector(
|
|
75
|
-
`[id="__next_css__DO_NOT_USE__"]:not([data-bundle="${bundle}"][data-route="${route}"])`
|
|
76
|
-
);
|
|
77
|
-
if (nextCssOriginal) {
|
|
78
|
-
nextCssOriginal.parentNode?.removeChild(nextCssOriginal);
|
|
79
|
-
}
|
|
80
|
-
const nextCss = document.createElement("noscript");
|
|
81
|
-
nextCss.id = "__next_css__DO_NOT_USE__";
|
|
82
|
-
nextCss.setAttribute("data-bundle", bundle);
|
|
83
|
-
nextCss.setAttribute("data-route", route);
|
|
84
|
-
const nextCssEnd = document.createElement("noscript");
|
|
85
|
-
nextCssEnd.id = "__next_css__DO_NOT_USE_END__";
|
|
86
|
-
nextCssEnd.setAttribute("data-bundle", bundle);
|
|
87
|
-
nextCssEnd.setAttribute("data-route", route);
|
|
88
|
-
document.head.appendChild(nextCssEnd);
|
|
89
|
-
document.head.appendChild(nextCss);
|
|
90
|
-
const componentLoaderChunk = Object.keys(self.__remote_webpack_require__?.[bundle]?.m ?? {}).find(
|
|
91
|
-
(key) => key.includes("/webpack/loaders/next-client-pages-loader.js") && key.includes(`page=${encodeURIComponent(route)}!`)
|
|
92
|
-
) ?? Object.keys(self.__remote_webpack_require__?.[bundle]?.m ?? {}).find(
|
|
93
|
-
(key) => key.includes("/next/dist/client/page-loader.js")
|
|
94
|
-
) ?? self.__remote_webpack_module_map__?.[bundle]?.[Object.keys(self.__remote_webpack_module_map__[bundle] ?? {}).find(
|
|
95
|
-
(key) => key.includes("/webpack/loaders/next-client-pages-loader.js") && key.includes(`page=${encodeURIComponent(route)}!`)
|
|
96
|
-
) ?? Object.keys(self.__remote_webpack_module_map__[bundle] ?? {}).find(
|
|
97
|
-
(key) => key.includes("/next/dist/client/page-loader.js")
|
|
98
|
-
) ?? ""] ?? -1;
|
|
99
|
-
const appLoaderChunk = Object.keys(self.__remote_webpack_require__?.[bundle]?.m ?? {}).find(
|
|
100
|
-
(key) => key.includes("/webpack/loaders/next-client-pages-loader.js") && key.includes(`page=%2F_app`)
|
|
101
|
-
) ?? Object.keys(self.__remote_webpack_require__?.[bundle]?.m ?? {}).find(
|
|
102
|
-
(key) => key.includes("/next/dist/client/page-loader.js")
|
|
103
|
-
) ?? self.__remote_webpack_module_map__?.[bundle]?.[Object.keys(self.__remote_webpack_module_map__[bundle] ?? {}).find(
|
|
104
|
-
(key) => key.includes("/webpack/loaders/next-client-pages-loader.js") && key.includes(`page=%2F_app`)
|
|
105
|
-
) ?? Object.keys(self.__remote_webpack_module_map__[bundle] ?? {}).find(
|
|
106
|
-
(key) => key.includes("/next/dist/client/page-loader.js")
|
|
107
|
-
) ?? ""] ?? -1;
|
|
108
|
-
if (!(componentLoaderChunk && appLoaderChunk)) {
|
|
109
|
-
throw new RemoteComponentsError(
|
|
110
|
-
`Next.js client pages loader not found in bundle "${bundle}".`
|
|
111
|
-
);
|
|
112
|
-
}
|
|
113
|
-
const __NEXT_P_ORIGINAL = self.__NEXT_P;
|
|
114
|
-
const selfOriginal = self;
|
|
115
|
-
delete selfOriginal.__NEXT_P;
|
|
116
|
-
self.__remote_webpack_require__?.[bundle]?.(
|
|
117
|
-
self.__remote_webpack_require__[bundle].type !== "turbopack" ? componentLoaderChunk : `[${bundle}] ${componentLoaderChunk}`
|
|
118
|
-
);
|
|
119
|
-
if (typeof appLoaderChunk === "string" || typeof appLoaderChunk === "number" && appLoaderChunk !== -1) {
|
|
120
|
-
self.__remote_webpack_require__?.[bundle]?.(
|
|
121
|
-
self.__remote_webpack_require__[bundle].type !== "turbopack" ? appLoaderChunk : `[${bundle}] ${appLoaderChunk}`
|
|
122
|
-
);
|
|
123
|
-
}
|
|
124
|
-
if (self.__NEXT_P) {
|
|
125
|
-
const [, componentLoader] = self.__NEXT_P[0] ?? [
|
|
126
|
-
void 0,
|
|
127
|
-
() => ({ default: null })
|
|
128
|
-
];
|
|
129
|
-
const [, appLoader] = self.__NEXT_P[2] ?? [
|
|
130
|
-
void 0,
|
|
131
|
-
() => ({
|
|
132
|
-
default: null
|
|
133
|
-
})
|
|
134
|
-
];
|
|
135
|
-
const { default: Component } = componentLoader();
|
|
136
|
-
const { default: App } = appLoader();
|
|
137
|
-
if (!self.__remote_next_css__) {
|
|
138
|
-
self.__remote_next_css__ = {};
|
|
139
|
-
}
|
|
140
|
-
if (!self.__remote_next_css__[bundle]) {
|
|
141
|
-
const cssRE = /\.s?css$/;
|
|
142
|
-
Object.keys(self.__remote_webpack_require__?.[bundle]?.m ?? {}).filter((id) => cssRE.test(id)).forEach((id) => {
|
|
143
|
-
self.__remote_webpack_require__?.[bundle]?.(id);
|
|
144
|
-
});
|
|
145
|
-
Object.keys(self.__remote_webpack_module_map__?.[bundle] ?? {}).filter((path) => cssRE.test(path)).forEach((path) => {
|
|
146
|
-
const id = self.__remote_webpack_module_map__?.[bundle]?.[path];
|
|
147
|
-
if (id) {
|
|
148
|
-
self.__remote_webpack_require__?.[bundle]?.(id);
|
|
58
|
+
if (node.hasAttribute("imagesrcset")) {
|
|
59
|
+
const srcSet = node.getAttribute("imagesrcset")?.split(",").map((entry) => {
|
|
60
|
+
const [urlPart, descriptor] = entry.trim().split(/\s+/);
|
|
61
|
+
if (!urlPart)
|
|
62
|
+
return entry;
|
|
63
|
+
const absoluteUrl = new URL(urlPart, url).href;
|
|
64
|
+
return descriptor ? `${absoluteUrl} ${descriptor}` : absoluteUrl;
|
|
65
|
+
}).join(", ");
|
|
66
|
+
if (srcSet) {
|
|
67
|
+
node.setAttribute("imagesrcset", srcSet);
|
|
149
68
|
}
|
|
150
|
-
});
|
|
151
|
-
const elements = [];
|
|
152
|
-
let node = nextCss.previousSibling;
|
|
153
|
-
while (node && node !== nextCssEnd) {
|
|
154
|
-
elements.push(node);
|
|
155
|
-
node.remove();
|
|
156
|
-
node = nextCss.previousSibling;
|
|
157
69
|
}
|
|
158
|
-
|
|
159
|
-
}
|
|
160
|
-
if (styleContainer) {
|
|
161
|
-
const elements = self.__remote_next_css__[bundle];
|
|
162
|
-
elements.forEach((el) => {
|
|
163
|
-
styleContainer.appendChild(el.cloneNode(true));
|
|
164
|
-
});
|
|
165
|
-
} else {
|
|
166
|
-
const elements = self.__remote_next_css__[bundle];
|
|
167
|
-
elements.forEach((el) => {
|
|
168
|
-
document.head.appendChild(el);
|
|
169
|
-
});
|
|
170
|
-
}
|
|
171
|
-
delete self.__NEXT_P;
|
|
172
|
-
self.__NEXT_P = __NEXT_P_ORIGINAL;
|
|
173
|
-
if (nextCssOriginal) {
|
|
174
|
-
nextCssOriginal.parentNode?.appendChild(nextCssOriginal);
|
|
175
|
-
}
|
|
176
|
-
nextCss.remove();
|
|
177
|
-
nextCssEnd.remove();
|
|
178
|
-
return { Component, App };
|
|
70
|
+
});
|
|
179
71
|
}
|
|
180
|
-
return { Component: null, App: null };
|
|
181
|
-
}
|
|
182
|
-
|
|
183
|
-
// src/shared/utils/index.ts
|
|
184
|
-
function escapeString(str) {
|
|
185
|
-
return str.replace(/[^a-z0-9]/g, "_");
|
|
186
|
-
}
|
|
187
|
-
var attrToProp = {
|
|
188
|
-
fetchpriority: "fetchPriority",
|
|
189
|
-
crossorigin: "crossOrigin",
|
|
190
|
-
imagesrcset: "imageSrcSet",
|
|
191
|
-
imagesizes: "imageSizes",
|
|
192
|
-
srcset: "srcSet"
|
|
193
|
-
};
|
|
194
|
-
|
|
195
|
-
// src/shared/client/const.ts
|
|
196
|
-
var DEFAULT_ROUTE = "/";
|
|
197
|
-
var RUNTIME_WEBPACK = "webpack";
|
|
198
|
-
var RUNTIME_TURBOPACK = "turbopack";
|
|
199
|
-
var RUNTIME_SCRIPT = "script";
|
|
200
|
-
var REMOTE_COMPONENT_REGEX = /(?<prefix>.*?)\[(?<bundle>[^\]]+)\](?:%20| )(?<id>.+)/;
|
|
201
|
-
function getBundleKey(bundle) {
|
|
202
|
-
return escapeString(bundle);
|
|
203
72
|
}
|
|
204
73
|
|
|
205
|
-
// src/shared/client/
|
|
206
|
-
|
|
74
|
+
// src/shared/client/polyfill.tsx
|
|
75
|
+
import { jsx } from "react/jsx-runtime";
|
|
76
|
+
function applyBundleUrlToSrc(bundle, src) {
|
|
207
77
|
const self = globalThis;
|
|
208
|
-
if (
|
|
209
|
-
|
|
78
|
+
if (self.__remote_bundle_url__?.[bundle]?.origin === location.origin) {
|
|
79
|
+
return src;
|
|
210
80
|
}
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
if (!self.__original_webpack_require__ && !self.__original_webpack_chunk_load__) {
|
|
215
|
-
self.__original_webpack_chunk_load__ = self.__webpack_chunk_load__;
|
|
216
|
-
self.__original_webpack_require__ = self.__webpack_require__;
|
|
217
|
-
}
|
|
218
|
-
self.__webpack_chunk_load__ = createChunkLoader(runtime);
|
|
219
|
-
self.__webpack_require__ = createModuleRequire(runtime);
|
|
220
|
-
self.__webpack_require_type__ = runtime;
|
|
221
|
-
if (self.__remote_webpack_require__ && runtime === RUNTIME_TURBOPACK) {
|
|
222
|
-
const remoteBundle = bundle ?? "default";
|
|
223
|
-
self.__remote_webpack_require__[remoteBundle] = self.__webpack_require__;
|
|
224
|
-
self.__remote_webpack_require__[remoteBundle].type = "turbopack";
|
|
225
|
-
}
|
|
81
|
+
const { assetPrefix, path } = /^(?<assetPrefix>.*?)\/_next\/(?<path>.*)/.exec(src)?.groups ?? {};
|
|
82
|
+
if (!path) {
|
|
83
|
+
return new URL(src, self.__remote_bundle_url__?.[bundle]?.origin).href;
|
|
226
84
|
}
|
|
227
|
-
|
|
85
|
+
return `${self.__remote_bundle_url__?.[bundle]?.origin ?? ""}${assetPrefix}/_next/${path}`;
|
|
86
|
+
}
|
|
87
|
+
function applyBundleUrlToImagePropsSrc(bundle, src) {
|
|
88
|
+
if (typeof src === "string") {
|
|
89
|
+
return applyBundleUrlToSrc(bundle, src);
|
|
90
|
+
}
|
|
91
|
+
const propSrc = src;
|
|
92
|
+
return applyBundleUrlToSrc(bundle, propSrc.src);
|
|
93
|
+
}
|
|
94
|
+
var imageImpl = (bundle) => function RemoteImage({
|
|
95
|
+
fill: _fill,
|
|
96
|
+
loader: _loader,
|
|
97
|
+
quality: _quality,
|
|
98
|
+
priority: _priority,
|
|
99
|
+
loading: _loading,
|
|
100
|
+
placeholder: _placeholder,
|
|
101
|
+
blurDataURL: _blurDataURL,
|
|
102
|
+
unoptimized: _unoptimized,
|
|
103
|
+
overrideSrc: _overrideSrc,
|
|
104
|
+
src,
|
|
105
|
+
...props
|
|
106
|
+
}) {
|
|
107
|
+
const newSrc = applyBundleUrlToImagePropsSrc(
|
|
108
|
+
bundle,
|
|
109
|
+
typeof src === "string" ? src : src.src
|
|
110
|
+
);
|
|
111
|
+
return (
|
|
112
|
+
// eslint-disable-next-line @next/next/no-img-element, jsx-a11y/alt-text
|
|
113
|
+
/* @__PURE__ */ jsx(
|
|
114
|
+
"img",
|
|
115
|
+
{
|
|
116
|
+
decoding: "async",
|
|
117
|
+
style: { color: "transparent" },
|
|
118
|
+
...props,
|
|
119
|
+
src: newSrc,
|
|
120
|
+
suppressHydrationWarning: true
|
|
121
|
+
}
|
|
122
|
+
)
|
|
123
|
+
);
|
|
124
|
+
};
|
|
125
|
+
function sharedPolyfills(shared) {
|
|
126
|
+
const self = globalThis;
|
|
127
|
+
const polyfill = {
|
|
128
|
+
"next/dist/client/components/navigation": self.__remote_component_host_shared_modules__?.["next/navigation"] ?? shared?.["next/navigation"] ?? (() => Promise.resolve({
|
|
129
|
+
useRouter() {
|
|
130
|
+
return {
|
|
131
|
+
push: (routerUrl) => {
|
|
132
|
+
history.pushState({}, "", routerUrl);
|
|
133
|
+
},
|
|
134
|
+
replace: (routerUrl) => {
|
|
135
|
+
history.replaceState({}, "", routerUrl);
|
|
136
|
+
},
|
|
137
|
+
back: () => {
|
|
138
|
+
history.back();
|
|
139
|
+
}
|
|
140
|
+
};
|
|
141
|
+
},
|
|
142
|
+
usePathname() {
|
|
143
|
+
return location.pathname;
|
|
144
|
+
},
|
|
145
|
+
useParams() {
|
|
146
|
+
return {};
|
|
147
|
+
},
|
|
148
|
+
useSearchParams() {
|
|
149
|
+
return new URLSearchParams(location.search);
|
|
150
|
+
},
|
|
151
|
+
useSelectedLayoutSegment() {
|
|
152
|
+
return null;
|
|
153
|
+
},
|
|
154
|
+
useSelectedLayoutSegments() {
|
|
155
|
+
return [];
|
|
156
|
+
},
|
|
157
|
+
__esModule: true
|
|
158
|
+
})),
|
|
159
|
+
"next/dist/client/app-dir/link": self.__remote_component_host_shared_modules__?.["next/link"] ?? shared?.["next/link"] ?? (() => Promise.resolve({
|
|
160
|
+
default: ({
|
|
161
|
+
scroll: _,
|
|
162
|
+
replace,
|
|
163
|
+
prefetch,
|
|
164
|
+
onNavigate,
|
|
165
|
+
children,
|
|
166
|
+
...props
|
|
167
|
+
}) => {
|
|
168
|
+
if (prefetch) {
|
|
169
|
+
console.warn(
|
|
170
|
+
"Next.js Link prefetch is not supported in remote components"
|
|
171
|
+
);
|
|
172
|
+
}
|
|
173
|
+
return /* @__PURE__ */ jsx(
|
|
174
|
+
"a",
|
|
175
|
+
{
|
|
176
|
+
...props,
|
|
177
|
+
href: props.href,
|
|
178
|
+
onClick: (e) => {
|
|
179
|
+
e.preventDefault();
|
|
180
|
+
let preventDefaulted = false;
|
|
181
|
+
e.preventDefault = () => {
|
|
182
|
+
preventDefaulted = true;
|
|
183
|
+
e.defaultPrevented = true;
|
|
184
|
+
};
|
|
185
|
+
if (typeof props.onClick === "function") {
|
|
186
|
+
props.onClick(e);
|
|
187
|
+
}
|
|
188
|
+
onNavigate?.(e);
|
|
189
|
+
if (preventDefaulted) {
|
|
190
|
+
return;
|
|
191
|
+
}
|
|
192
|
+
if (replace) {
|
|
193
|
+
history.replaceState({}, "", props.href);
|
|
194
|
+
} else {
|
|
195
|
+
history.pushState({}, "", props.href);
|
|
196
|
+
}
|
|
197
|
+
},
|
|
198
|
+
suppressHydrationWarning: true,
|
|
199
|
+
children: children ?? null
|
|
200
|
+
}
|
|
201
|
+
);
|
|
202
|
+
},
|
|
203
|
+
useLinkStatus() {
|
|
204
|
+
return { pending: false };
|
|
205
|
+
},
|
|
206
|
+
__esModule: true
|
|
207
|
+
})),
|
|
208
|
+
"next/dist/client/app-dir/form": self.__remote_component_host_shared_modules__?.["next/form"] ?? shared?.["next/form"] ?? (() => Promise.resolve({
|
|
209
|
+
default: () => {
|
|
210
|
+
throw new Error("Next.js <Form> component not implemented");
|
|
211
|
+
},
|
|
212
|
+
__esModule: true
|
|
213
|
+
})),
|
|
214
|
+
"next/dist/client/image-component": self.__remote_component_host_shared_modules__?.["next/image"] ?? shared?.["next/image"] ?? ((bundle) => Promise.resolve({
|
|
215
|
+
Image: imageImpl(bundle),
|
|
216
|
+
__esModule: true
|
|
217
|
+
})),
|
|
218
|
+
"next/image": self.__remote_component_host_shared_modules__?.["next/image"] ?? shared?.["next/image"] ?? ((bundle) => Promise.resolve({
|
|
219
|
+
default: imageImpl(bundle),
|
|
220
|
+
getImageProps: (_imgProps) => {
|
|
221
|
+
throw new Error(
|
|
222
|
+
"Next.js getImageProps() is not implemented in remote components"
|
|
223
|
+
);
|
|
224
|
+
},
|
|
225
|
+
__esModule: true
|
|
226
|
+
})),
|
|
227
|
+
"next/dist/client/script": self.__remote_component_host_shared_modules__?.["next/script"] ?? shared?.["next/script"] ?? (() => Promise.resolve({
|
|
228
|
+
// TODO: implement <Script> component for non-Next.js host applications
|
|
229
|
+
// do not throw an error for now
|
|
230
|
+
default: () => null,
|
|
231
|
+
__esModule: true
|
|
232
|
+
})),
|
|
233
|
+
"next/router": self.__remote_component_host_shared_modules__?.["next/router"] ?? shared?.["next/router"] ?? (() => (
|
|
234
|
+
// TODO: incomplete implementation
|
|
235
|
+
Promise.resolve({
|
|
236
|
+
useRouter() {
|
|
237
|
+
return {
|
|
238
|
+
push: (routerUrl) => {
|
|
239
|
+
history.pushState({}, "", routerUrl);
|
|
240
|
+
},
|
|
241
|
+
replace: (routerUrl) => {
|
|
242
|
+
history.replaceState({}, "", routerUrl);
|
|
243
|
+
},
|
|
244
|
+
back: () => {
|
|
245
|
+
history.back();
|
|
246
|
+
}
|
|
247
|
+
};
|
|
248
|
+
},
|
|
249
|
+
__esModule: true
|
|
250
|
+
})
|
|
251
|
+
)),
|
|
252
|
+
"next/dist/build/polyfills/process": () => Promise.resolve({
|
|
253
|
+
default: {
|
|
254
|
+
env: {
|
|
255
|
+
NODE_ENV: "production"
|
|
256
|
+
}
|
|
257
|
+
},
|
|
258
|
+
__esModule: true
|
|
259
|
+
})
|
|
260
|
+
};
|
|
261
|
+
polyfill["next/navigation"] = polyfill["next/dist/client/components/navigation"];
|
|
262
|
+
polyfill["next/link"] = polyfill["next/dist/client/app-dir/link"];
|
|
263
|
+
polyfill["next/form"] = polyfill["next/dist/client/app-dir/form"];
|
|
264
|
+
polyfill["next/dist/api/image"] = polyfill["next/dist/client/image-component"];
|
|
265
|
+
polyfill["next/script"] = polyfill["next/dist/client/script"];
|
|
266
|
+
return polyfill;
|
|
267
|
+
}
|
|
268
|
+
|
|
269
|
+
// src/shared/error.ts
|
|
270
|
+
var RemoteComponentsError = class extends Error {
|
|
271
|
+
code = "REMOTE_COMPONENTS_ERROR";
|
|
272
|
+
constructor(message, options) {
|
|
273
|
+
super(message, options);
|
|
274
|
+
this.name = "RemoteComponentsError";
|
|
275
|
+
}
|
|
276
|
+
};
|
|
277
|
+
function multipleRemoteComponentsError(url) {
|
|
278
|
+
return new Error(
|
|
279
|
+
`Multiple Remote Components found at "${url}". When a page exposes multiple Remote Components you must specify the "name" prop to select which one to load.`
|
|
280
|
+
);
|
|
281
|
+
}
|
|
282
|
+
function failedToFetchRemoteComponentError(url, error) {
|
|
283
|
+
return new RemoteComponentsError(
|
|
284
|
+
`Failed to fetch Remote Component from "${url}". Is the URL correct and accessible?`,
|
|
285
|
+
{ cause: error instanceof Error ? error : new Error(String(error)) }
|
|
286
|
+
);
|
|
287
|
+
}
|
|
288
|
+
|
|
289
|
+
// src/shared/client/component-loader.ts
|
|
290
|
+
import * as React from "react";
|
|
291
|
+
import * as JSXDevRuntime from "react/jsx-dev-runtime";
|
|
292
|
+
import * as JSXRuntime from "react/jsx-runtime";
|
|
293
|
+
import * as ReactDOM from "react-dom";
|
|
294
|
+
import * as ReactDOMClient from "react-dom/client";
|
|
295
|
+
|
|
296
|
+
// src/shared/webpack/next-client-pages-loader.ts
|
|
297
|
+
function nextClientPagesLoader(bundle, route, styleContainer = document.head) {
|
|
298
|
+
const self = globalThis;
|
|
299
|
+
const nextCssOriginal = document.querySelector(
|
|
300
|
+
`[id="__next_css__DO_NOT_USE__"]:not([data-bundle="${bundle}"][data-route="${route}"])`
|
|
301
|
+
);
|
|
302
|
+
if (nextCssOriginal) {
|
|
303
|
+
nextCssOriginal.parentNode?.removeChild(nextCssOriginal);
|
|
304
|
+
}
|
|
305
|
+
const nextCss = document.createElement("noscript");
|
|
306
|
+
nextCss.id = "__next_css__DO_NOT_USE__";
|
|
307
|
+
nextCss.setAttribute("data-bundle", bundle);
|
|
308
|
+
nextCss.setAttribute("data-route", route);
|
|
309
|
+
const nextCssEnd = document.createElement("noscript");
|
|
310
|
+
nextCssEnd.id = "__next_css__DO_NOT_USE_END__";
|
|
311
|
+
nextCssEnd.setAttribute("data-bundle", bundle);
|
|
312
|
+
nextCssEnd.setAttribute("data-route", route);
|
|
313
|
+
document.head.appendChild(nextCssEnd);
|
|
314
|
+
document.head.appendChild(nextCss);
|
|
315
|
+
const componentLoaderChunk = Object.keys(self.__remote_webpack_require__?.[bundle]?.m ?? {}).find(
|
|
316
|
+
(key) => key.includes("/webpack/loaders/next-client-pages-loader.js") && key.includes(`page=${encodeURIComponent(route)}!`)
|
|
317
|
+
) ?? Object.keys(self.__remote_webpack_require__?.[bundle]?.m ?? {}).find(
|
|
318
|
+
(key) => key.includes("/next/dist/client/page-loader.js")
|
|
319
|
+
) ?? self.__remote_webpack_module_map__?.[bundle]?.[Object.keys(self.__remote_webpack_module_map__[bundle] ?? {}).find(
|
|
320
|
+
(key) => key.includes("/webpack/loaders/next-client-pages-loader.js") && key.includes(`page=${encodeURIComponent(route)}!`)
|
|
321
|
+
) ?? Object.keys(self.__remote_webpack_module_map__[bundle] ?? {}).find(
|
|
322
|
+
(key) => key.includes("/next/dist/client/page-loader.js")
|
|
323
|
+
) ?? ""] ?? -1;
|
|
324
|
+
const appLoaderChunk = Object.keys(self.__remote_webpack_require__?.[bundle]?.m ?? {}).find(
|
|
325
|
+
(key) => key.includes("/webpack/loaders/next-client-pages-loader.js") && key.includes(`page=%2F_app`)
|
|
326
|
+
) ?? Object.keys(self.__remote_webpack_require__?.[bundle]?.m ?? {}).find(
|
|
327
|
+
(key) => key.includes("/next/dist/client/page-loader.js")
|
|
328
|
+
) ?? self.__remote_webpack_module_map__?.[bundle]?.[Object.keys(self.__remote_webpack_module_map__[bundle] ?? {}).find(
|
|
329
|
+
(key) => key.includes("/webpack/loaders/next-client-pages-loader.js") && key.includes(`page=%2F_app`)
|
|
330
|
+
) ?? Object.keys(self.__remote_webpack_module_map__[bundle] ?? {}).find(
|
|
331
|
+
(key) => key.includes("/next/dist/client/page-loader.js")
|
|
332
|
+
) ?? ""] ?? -1;
|
|
333
|
+
if (!(componentLoaderChunk && appLoaderChunk)) {
|
|
334
|
+
throw new RemoteComponentsError(
|
|
335
|
+
`Next.js client pages loader not found in bundle "${bundle}".`
|
|
336
|
+
);
|
|
337
|
+
}
|
|
338
|
+
const __NEXT_P_ORIGINAL = self.__NEXT_P;
|
|
339
|
+
const selfOriginal = self;
|
|
340
|
+
delete selfOriginal.__NEXT_P;
|
|
341
|
+
self.__remote_webpack_require__?.[bundle]?.(
|
|
342
|
+
self.__remote_webpack_require__[bundle].type !== "turbopack" ? componentLoaderChunk : `[${bundle}] ${componentLoaderChunk}`
|
|
343
|
+
);
|
|
344
|
+
if (typeof appLoaderChunk === "string" || typeof appLoaderChunk === "number" && appLoaderChunk !== -1) {
|
|
345
|
+
self.__remote_webpack_require__?.[bundle]?.(
|
|
346
|
+
self.__remote_webpack_require__[bundle].type !== "turbopack" ? appLoaderChunk : `[${bundle}] ${appLoaderChunk}`
|
|
347
|
+
);
|
|
348
|
+
}
|
|
349
|
+
if (self.__NEXT_P) {
|
|
350
|
+
const [, componentLoader] = self.__NEXT_P[0] ?? [
|
|
351
|
+
void 0,
|
|
352
|
+
() => ({ default: null })
|
|
353
|
+
];
|
|
354
|
+
const [, appLoader] = self.__NEXT_P[2] ?? [
|
|
355
|
+
void 0,
|
|
356
|
+
() => ({
|
|
357
|
+
default: null
|
|
358
|
+
})
|
|
359
|
+
];
|
|
360
|
+
const { default: Component } = componentLoader();
|
|
361
|
+
const { default: App } = appLoader();
|
|
362
|
+
if (!self.__remote_next_css__) {
|
|
363
|
+
self.__remote_next_css__ = {};
|
|
364
|
+
}
|
|
365
|
+
if (!self.__remote_next_css__[bundle]) {
|
|
366
|
+
const cssRE = /\.s?css$/;
|
|
367
|
+
Object.keys(self.__remote_webpack_require__?.[bundle]?.m ?? {}).filter((id) => cssRE.test(id)).forEach((id) => {
|
|
368
|
+
self.__remote_webpack_require__?.[bundle]?.(id);
|
|
369
|
+
});
|
|
370
|
+
Object.keys(self.__remote_webpack_module_map__?.[bundle] ?? {}).filter((path) => cssRE.test(path)).forEach((path) => {
|
|
371
|
+
const id = self.__remote_webpack_module_map__?.[bundle]?.[path];
|
|
372
|
+
if (id) {
|
|
373
|
+
self.__remote_webpack_require__?.[bundle]?.(id);
|
|
374
|
+
}
|
|
375
|
+
});
|
|
376
|
+
const elements = [];
|
|
377
|
+
let node = nextCss.previousSibling;
|
|
378
|
+
while (node && node !== nextCssEnd) {
|
|
379
|
+
elements.push(node);
|
|
380
|
+
node.remove();
|
|
381
|
+
node = nextCss.previousSibling;
|
|
382
|
+
}
|
|
383
|
+
self.__remote_next_css__[bundle] = elements;
|
|
384
|
+
}
|
|
385
|
+
if (styleContainer) {
|
|
386
|
+
const elements = self.__remote_next_css__[bundle];
|
|
387
|
+
elements.forEach((el) => {
|
|
388
|
+
styleContainer.appendChild(el.cloneNode(true));
|
|
389
|
+
});
|
|
390
|
+
} else {
|
|
391
|
+
const elements = self.__remote_next_css__[bundle];
|
|
392
|
+
elements.forEach((el) => {
|
|
393
|
+
document.head.appendChild(el);
|
|
394
|
+
});
|
|
395
|
+
}
|
|
396
|
+
delete self.__NEXT_P;
|
|
397
|
+
self.__NEXT_P = __NEXT_P_ORIGINAL;
|
|
398
|
+
if (nextCssOriginal) {
|
|
399
|
+
nextCssOriginal.parentNode?.appendChild(nextCssOriginal);
|
|
400
|
+
}
|
|
401
|
+
nextCss.remove();
|
|
402
|
+
nextCssEnd.remove();
|
|
403
|
+
return { Component, App };
|
|
404
|
+
}
|
|
405
|
+
return { Component: null, App: null };
|
|
406
|
+
}
|
|
407
|
+
|
|
408
|
+
// src/shared/webpack/shared-modules.ts
|
|
409
|
+
function applySharedModules(bundle, resolve) {
|
|
410
|
+
const self = globalThis;
|
|
411
|
+
if (self.__remote_webpack_require__?.[bundle]) {
|
|
412
|
+
const modulePaths = Object.keys(
|
|
413
|
+
self.__remote_webpack_module_map__?.[bundle] ?? self.__remote_webpack_require__[bundle].m ?? {}
|
|
414
|
+
);
|
|
415
|
+
for (const [key, value] of Object.entries(resolve)) {
|
|
416
|
+
let ids = modulePaths.filter((p) => p === key);
|
|
417
|
+
if (ids.length === 0) {
|
|
418
|
+
ids = modulePaths.filter((p) => p.includes(key));
|
|
419
|
+
}
|
|
420
|
+
for (let id of ids) {
|
|
421
|
+
const webpackBundle = self.__remote_webpack_require__[bundle];
|
|
422
|
+
if (webpackBundle.m) {
|
|
423
|
+
if (self.__remote_webpack_module_map__?.[bundle]?.[id]) {
|
|
424
|
+
id = `${self.__remote_webpack_module_map__[bundle][id]}`;
|
|
425
|
+
}
|
|
426
|
+
webpackBundle.m[id] = (module) => {
|
|
427
|
+
module.exports = value;
|
|
428
|
+
};
|
|
429
|
+
}
|
|
430
|
+
}
|
|
431
|
+
}
|
|
432
|
+
}
|
|
433
|
+
}
|
|
434
|
+
|
|
435
|
+
// src/shared/client/rsc.ts
|
|
436
|
+
import { ReadableStream } from "web-streams-polyfill";
|
|
437
|
+
function fixPayload(payload) {
|
|
438
|
+
if (Array.isArray(payload)) {
|
|
439
|
+
if (payload[0] === "$") {
|
|
440
|
+
fixPayload(payload[3]);
|
|
441
|
+
if (payload.length === 4) {
|
|
442
|
+
payload.push(null, null, 1);
|
|
443
|
+
}
|
|
444
|
+
} else {
|
|
445
|
+
for (const item of payload) {
|
|
446
|
+
fixPayload(item);
|
|
447
|
+
}
|
|
448
|
+
}
|
|
449
|
+
} else if (typeof payload === "object" && payload !== null) {
|
|
450
|
+
for (const key in payload) {
|
|
451
|
+
fixPayload(payload[key]);
|
|
452
|
+
}
|
|
453
|
+
}
|
|
454
|
+
}
|
|
455
|
+
function createRSCStream(rscName, data) {
|
|
456
|
+
return new ReadableStream({
|
|
457
|
+
type: "bytes",
|
|
458
|
+
start(controller) {
|
|
459
|
+
const encoder = new TextEncoder();
|
|
460
|
+
const self = globalThis;
|
|
461
|
+
if (data.length > 0) {
|
|
462
|
+
data.forEach((chunk) => {
|
|
463
|
+
const lines = chunk.split("\n");
|
|
464
|
+
for (const line of lines) {
|
|
465
|
+
const match = /\.push\("(?<rsc>.*)"\);$/.exec(line);
|
|
466
|
+
if (match?.groups?.rsc) {
|
|
467
|
+
self[rscName] = self[rscName] ?? [];
|
|
468
|
+
self[rscName].push(JSON.parse(`"${match.groups.rsc}"`));
|
|
469
|
+
}
|
|
470
|
+
}
|
|
471
|
+
});
|
|
472
|
+
}
|
|
473
|
+
const allChunks = (self[rscName] ?? [`0:[null]
|
|
474
|
+
`]).join("");
|
|
475
|
+
self[rscName] = null;
|
|
476
|
+
allChunks.split("\n").forEach((chunk) => {
|
|
477
|
+
if (chunk.length > 0) {
|
|
478
|
+
const { before, id, prefix, payload } = /^(?<before>[^:]*?)?(?<id>[0-9a-zA-Z]+):(?<prefix>[A-Z])?(?<payload>\[.*\])/.exec(
|
|
479
|
+
chunk
|
|
480
|
+
)?.groups ?? {};
|
|
481
|
+
if (payload) {
|
|
482
|
+
const jsonPayload = JSON.parse(payload);
|
|
483
|
+
fixPayload(jsonPayload);
|
|
484
|
+
const reconstruct = `${before ?? ""}${id}:${prefix ?? ""}${JSON.stringify(jsonPayload)}`;
|
|
485
|
+
controller.enqueue(encoder.encode(`${reconstruct}
|
|
486
|
+
`));
|
|
487
|
+
} else {
|
|
488
|
+
controller.enqueue(encoder.encode(`${chunk}
|
|
489
|
+
`));
|
|
490
|
+
}
|
|
491
|
+
} else {
|
|
492
|
+
controller.enqueue(encoder.encode(`${chunk}
|
|
493
|
+
`));
|
|
494
|
+
}
|
|
495
|
+
});
|
|
496
|
+
controller.close();
|
|
497
|
+
}
|
|
498
|
+
});
|
|
499
|
+
}
|
|
500
|
+
|
|
501
|
+
// src/shared/client/script-loader.ts
|
|
502
|
+
async function loadScripts(scripts) {
|
|
503
|
+
await Promise.all(
|
|
504
|
+
scripts.map((script) => {
|
|
505
|
+
return new Promise((resolve, reject) => {
|
|
506
|
+
const newSrc = new URL(
|
|
507
|
+
// remove the remote component bundle name identifier from the script src
|
|
508
|
+
script.src.replace(/\/_next\/\[.+\](?<whitespace>%20| )/, "/_next/"),
|
|
509
|
+
location.origin
|
|
510
|
+
).href;
|
|
511
|
+
const newScript = document.createElement("script");
|
|
512
|
+
newScript.onload = () => {
|
|
513
|
+
resolve();
|
|
514
|
+
};
|
|
515
|
+
newScript.onerror = () => {
|
|
516
|
+
reject(
|
|
517
|
+
new RemoteComponentsError(
|
|
518
|
+
`Failed to load <script src="${script.src}"> for Remote Component. Check the URL is correct.`
|
|
519
|
+
)
|
|
520
|
+
);
|
|
521
|
+
};
|
|
522
|
+
newScript.src = newSrc;
|
|
523
|
+
newScript.async = true;
|
|
524
|
+
document.head.appendChild(newScript);
|
|
525
|
+
});
|
|
526
|
+
})
|
|
527
|
+
);
|
|
528
|
+
}
|
|
529
|
+
|
|
530
|
+
// src/shared/utils/index.ts
|
|
531
|
+
function escapeString(str) {
|
|
532
|
+
return str.replace(/[^a-z0-9]/g, "_");
|
|
533
|
+
}
|
|
534
|
+
var attrToProp = {
|
|
535
|
+
fetchpriority: "fetchPriority",
|
|
536
|
+
crossorigin: "crossOrigin",
|
|
537
|
+
imagesrcset: "imageSrcSet",
|
|
538
|
+
imagesizes: "imageSizes",
|
|
539
|
+
srcset: "srcSet"
|
|
540
|
+
};
|
|
541
|
+
|
|
542
|
+
// src/shared/client/const.ts
|
|
543
|
+
var DEFAULT_ROUTE = "/";
|
|
544
|
+
var RUNTIME_WEBPACK = "webpack";
|
|
545
|
+
var RUNTIME_TURBOPACK = "turbopack";
|
|
546
|
+
var RUNTIME_SCRIPT = "script";
|
|
547
|
+
var REMOTE_COMPONENT_REGEX = /(?<prefix>.*?)\[(?<bundle>[^\]]+)\](?:%20| )(?<id>.+)/;
|
|
548
|
+
function getBundleKey(bundle) {
|
|
549
|
+
return escapeString(bundle);
|
|
550
|
+
}
|
|
551
|
+
|
|
552
|
+
// src/shared/client/webpack-adapter.ts
|
|
553
|
+
async function setupWebpackRuntime(runtime, scripts = [], url = new URL(location.href), bundle, shared = {}, remoteShared = {}) {
|
|
554
|
+
const self = globalThis;
|
|
555
|
+
if (!self.__remote_bundle_url__) {
|
|
556
|
+
self.__remote_bundle_url__ = {};
|
|
557
|
+
}
|
|
558
|
+
self.__remote_bundle_url__[bundle ?? "default"] = url;
|
|
559
|
+
self.__webpack_get_script_filename__ = () => null;
|
|
560
|
+
if (typeof self.__webpack_require__ !== "function" || self.__webpack_require_type__ !== "turbopack") {
|
|
561
|
+
if (!self.__original_webpack_require__ && !self.__original_webpack_chunk_load__) {
|
|
562
|
+
self.__original_webpack_chunk_load__ = self.__webpack_chunk_load__;
|
|
563
|
+
self.__original_webpack_require__ = self.__webpack_require__;
|
|
564
|
+
}
|
|
565
|
+
self.__webpack_chunk_load__ = createChunkLoader(runtime);
|
|
566
|
+
self.__webpack_require__ = createModuleRequire(runtime);
|
|
567
|
+
self.__webpack_require_type__ = runtime;
|
|
568
|
+
if (self.__remote_webpack_require__ && runtime === RUNTIME_TURBOPACK) {
|
|
569
|
+
const remoteBundle = bundle ?? "default";
|
|
570
|
+
self.__remote_webpack_require__[remoteBundle] = self.__webpack_require__;
|
|
571
|
+
self.__remote_webpack_require__[remoteBundle].type = "turbopack";
|
|
572
|
+
}
|
|
573
|
+
}
|
|
574
|
+
if (runtime === RUNTIME_TURBOPACK) {
|
|
228
575
|
await Promise.all(
|
|
229
576
|
scripts.map((script) => {
|
|
230
577
|
if (script.src) {
|
|
@@ -365,7 +712,10 @@ async function handleTurbopackChunk(code, bundle, url) {
|
|
|
365
712
|
function createModuleRequire(runtime) {
|
|
366
713
|
return (id) => {
|
|
367
714
|
const self = globalThis;
|
|
368
|
-
const { bundle, id: moduleId } = id.match(REMOTE_COMPONENT_REGEX)?.groups ?? {
|
|
715
|
+
const { bundle, id: moduleId } = id.match(REMOTE_COMPONENT_REGEX)?.groups ?? {
|
|
716
|
+
bundle: "default",
|
|
717
|
+
id
|
|
718
|
+
};
|
|
369
719
|
const remoteRuntime = self.__remote_webpack_require__?.[bundle ?? "default"] ? self.__remote_webpack_require__[bundle ?? "default"]?.type || "webpack" : runtime;
|
|
370
720
|
try {
|
|
371
721
|
if (remoteRuntime === RUNTIME_WEBPACK && bundle && moduleId) {
|
|
@@ -608,192 +958,97 @@ function handleTurbopackModule(bundle, moduleId, id) {
|
|
|
608
958
|
let mod;
|
|
609
959
|
if (typeof importId === "string") {
|
|
610
960
|
const { exportSource, exportName } = /\s+<export (?<exportSource>.*?) as (?<exportName>.*?)>$/.exec(
|
|
611
|
-
importId
|
|
612
|
-
)?.groups ?? {};
|
|
613
|
-
const normalizedId = importId.replace(
|
|
614
|
-
/\s+<export(?<specifier>.*)>$/,
|
|
615
|
-
""
|
|
616
|
-
);
|
|
617
|
-
mod = self.__webpack_require__?.(
|
|
618
|
-
`[${bundle}] ${normalizedId}`
|
|
619
|
-
);
|
|
620
|
-
if (exportSource && exportName && (exportSource === "*" || typeof mod[exportSource] !== "undefined") && typeof mod[exportName] === "undefined") {
|
|
621
|
-
if (exportSource === "*") {
|
|
622
|
-
mod[exportName] = mod;
|
|
623
|
-
} else {
|
|
624
|
-
mod[exportName] = mod[exportSource];
|
|
625
|
-
}
|
|
626
|
-
}
|
|
627
|
-
} else {
|
|
628
|
-
mod = self.__webpack_require__?.(`[${bundle}] ${importId}`);
|
|
629
|
-
}
|
|
630
|
-
if (typeof mod !== "object") {
|
|
631
|
-
mod = { default: mod };
|
|
632
|
-
} else if (!("default" in mod) && // eslint-disable-next-line @typescript-eslint/no-base-to-string
|
|
633
|
-
mod.toString() !== "[object Module]") {
|
|
634
|
-
try {
|
|
635
|
-
mod.default = mod;
|
|
636
|
-
} catch {
|
|
637
|
-
}
|
|
638
|
-
}
|
|
639
|
-
return mod;
|
|
640
|
-
},
|
|
641
|
-
// require
|
|
642
|
-
r(requireId) {
|
|
643
|
-
return self.__webpack_require__?.(`[${bundle}] ${requireId}`);
|
|
644
|
-
},
|
|
645
|
-
// value exports
|
|
646
|
-
v(value) {
|
|
647
|
-
if (typeof value === "function") {
|
|
648
|
-
exports.default = value((vid) => {
|
|
649
|
-
return self.__webpack_require__?.(`[${bundle}] ${vid}`);
|
|
650
|
-
});
|
|
651
|
-
} else {
|
|
652
|
-
moduleExports.exports = value;
|
|
653
|
-
}
|
|
654
|
-
},
|
|
655
|
-
// async module initializer
|
|
656
|
-
async a(mod) {
|
|
657
|
-
let result;
|
|
658
|
-
await mod(
|
|
659
|
-
() => {
|
|
660
|
-
},
|
|
661
|
-
(value) => result = value
|
|
662
|
-
);
|
|
663
|
-
exports.default = result;
|
|
664
|
-
},
|
|
665
|
-
// async module loader
|
|
666
|
-
async A(Aid) {
|
|
667
|
-
const mod = self.__webpack_require__?.(`[${bundle}] ${Aid}`);
|
|
668
|
-
return mod.default(
|
|
669
|
-
(parentId) => self.__webpack_require__?.(`[${bundle}] ${parentId}`)
|
|
670
|
-
);
|
|
671
|
-
},
|
|
672
|
-
// chunk loader
|
|
673
|
-
l(url) {
|
|
674
|
-
const moduleInitIndex = allModules.indexOf(moduleInit);
|
|
675
|
-
if (moduleInitIndex !== -1) {
|
|
676
|
-
const scriptIndex = allModules.slice(0, moduleInitIndex).findLastIndex((bundleEntry) => bundleEntry instanceof Element);
|
|
677
|
-
if (scriptIndex !== -1) {
|
|
678
|
-
const script = allModules[scriptIndex];
|
|
679
|
-
const scriptSrc = script.getAttribute("data-turbopack-src") || "";
|
|
680
|
-
const nextIndex = scriptSrc.indexOf("/_next");
|
|
681
|
-
const baseUrl = nextIndex !== -1 ? scriptSrc.slice(0, nextIndex) : "";
|
|
682
|
-
const bundleUrl = `[${bundle}] ${baseUrl}/_next/${url}`;
|
|
683
|
-
return self.__webpack_chunk_load__?.(bundleUrl, bundle);
|
|
684
|
-
}
|
|
685
|
-
}
|
|
686
|
-
throw new Error(
|
|
687
|
-
`Failed to load Turbopack chunk "${url}" for module "${id}". Check the URL is correct.`
|
|
688
|
-
);
|
|
689
|
-
},
|
|
690
|
-
// global
|
|
691
|
-
g: self.__remote_components_turbopack_global__[bundle],
|
|
692
|
-
m: moduleExports,
|
|
693
|
-
e: exports
|
|
694
|
-
},
|
|
695
|
-
moduleExports,
|
|
696
|
-
exports
|
|
697
|
-
);
|
|
698
|
-
if (self.__remote_components_turbopack_modules__[bundle][moduleId] !== moduleExports.exports) {
|
|
699
|
-
self.__remote_components_turbopack_modules__[bundle][moduleId] = moduleExports.exports;
|
|
700
|
-
}
|
|
701
|
-
return moduleExports.exports;
|
|
702
|
-
}
|
|
703
|
-
|
|
704
|
-
// src/shared/client/script-loader.ts
|
|
705
|
-
async function loadScripts(scripts) {
|
|
706
|
-
await Promise.all(
|
|
707
|
-
scripts.map((script) => {
|
|
708
|
-
return new Promise((resolve, reject) => {
|
|
709
|
-
const newSrc = new URL(
|
|
710
|
-
// remove the remote component bundle name identifier from the script src
|
|
711
|
-
script.src.replace(/\/_next\/\[.+\](?<whitespace>%20| )/, "/_next/"),
|
|
712
|
-
location.origin
|
|
713
|
-
).href;
|
|
714
|
-
const newScript = document.createElement("script");
|
|
715
|
-
newScript.onload = () => {
|
|
716
|
-
resolve();
|
|
717
|
-
};
|
|
718
|
-
newScript.onerror = () => {
|
|
719
|
-
reject(
|
|
720
|
-
new RemoteComponentsError(
|
|
721
|
-
`Failed to load <script src="${script.src}"> for Remote Component. Check the URL is correct.`
|
|
722
|
-
)
|
|
723
|
-
);
|
|
724
|
-
};
|
|
725
|
-
newScript.src = newSrc;
|
|
726
|
-
newScript.async = true;
|
|
727
|
-
document.head.appendChild(newScript);
|
|
728
|
-
});
|
|
729
|
-
})
|
|
730
|
-
);
|
|
731
|
-
}
|
|
732
|
-
|
|
733
|
-
// src/shared/client/rsc.ts
|
|
734
|
-
import { ReadableStream } from "web-streams-polyfill";
|
|
735
|
-
function fixPayload(payload) {
|
|
736
|
-
if (Array.isArray(payload)) {
|
|
737
|
-
if (payload[0] === "$") {
|
|
738
|
-
fixPayload(payload[3]);
|
|
739
|
-
if (payload.length === 4) {
|
|
740
|
-
payload.push(null, null, 1);
|
|
741
|
-
}
|
|
742
|
-
} else {
|
|
743
|
-
for (const item of payload) {
|
|
744
|
-
fixPayload(item);
|
|
745
|
-
}
|
|
746
|
-
}
|
|
747
|
-
} else if (typeof payload === "object" && payload !== null) {
|
|
748
|
-
for (const key in payload) {
|
|
749
|
-
fixPayload(payload[key]);
|
|
750
|
-
}
|
|
751
|
-
}
|
|
752
|
-
}
|
|
753
|
-
function createRSCStream(rscName, data) {
|
|
754
|
-
return new ReadableStream({
|
|
755
|
-
type: "bytes",
|
|
756
|
-
start(controller) {
|
|
757
|
-
const encoder = new TextEncoder();
|
|
758
|
-
const self = globalThis;
|
|
759
|
-
if (data.length > 0) {
|
|
760
|
-
data.forEach((chunk) => {
|
|
761
|
-
const lines = chunk.split("\n");
|
|
762
|
-
for (const line of lines) {
|
|
763
|
-
const match = /\.push\("(?<rsc>.*)"\);$/.exec(line);
|
|
764
|
-
if (match?.groups?.rsc) {
|
|
765
|
-
self[rscName] = self[rscName] ?? [];
|
|
766
|
-
self[rscName].push(JSON.parse(`"${match.groups.rsc}"`));
|
|
767
|
-
}
|
|
768
|
-
}
|
|
769
|
-
});
|
|
770
|
-
}
|
|
771
|
-
const allChunks = (self[rscName] ?? [`0:[null]
|
|
772
|
-
`]).join("");
|
|
773
|
-
self[rscName] = null;
|
|
774
|
-
allChunks.split("\n").forEach((chunk) => {
|
|
775
|
-
if (chunk.length > 0) {
|
|
776
|
-
const { before, id, prefix, payload } = /^(?<before>[^:]*?)?(?<id>[0-9a-zA-Z]+):(?<prefix>[A-Z])?(?<payload>\[.*\])/.exec(
|
|
777
|
-
chunk
|
|
778
|
-
)?.groups ?? {};
|
|
779
|
-
if (payload) {
|
|
780
|
-
const jsonPayload = JSON.parse(payload);
|
|
781
|
-
fixPayload(jsonPayload);
|
|
782
|
-
const reconstruct = `${before ?? ""}${id}:${prefix ?? ""}${JSON.stringify(jsonPayload)}`;
|
|
783
|
-
controller.enqueue(encoder.encode(`${reconstruct}
|
|
784
|
-
`));
|
|
785
|
-
} else {
|
|
786
|
-
controller.enqueue(encoder.encode(`${chunk}
|
|
787
|
-
`));
|
|
961
|
+
importId
|
|
962
|
+
)?.groups ?? {};
|
|
963
|
+
const normalizedId = importId.replace(
|
|
964
|
+
/\s+<export(?<specifier>.*)>$/,
|
|
965
|
+
""
|
|
966
|
+
);
|
|
967
|
+
mod = self.__webpack_require__?.(
|
|
968
|
+
`[${bundle}] ${normalizedId}`
|
|
969
|
+
);
|
|
970
|
+
if (exportSource && exportName && (exportSource === "*" || typeof mod[exportSource] !== "undefined") && typeof mod[exportName] === "undefined") {
|
|
971
|
+
if (exportSource === "*") {
|
|
972
|
+
mod[exportName] = mod;
|
|
973
|
+
} else {
|
|
974
|
+
mod[exportName] = mod[exportSource];
|
|
975
|
+
}
|
|
788
976
|
}
|
|
789
977
|
} else {
|
|
790
|
-
|
|
791
|
-
`));
|
|
978
|
+
mod = self.__webpack_require__?.(`[${bundle}] ${importId}`);
|
|
792
979
|
}
|
|
793
|
-
|
|
794
|
-
|
|
795
|
-
|
|
796
|
-
|
|
980
|
+
if (typeof mod !== "object") {
|
|
981
|
+
mod = { default: mod };
|
|
982
|
+
} else if (!("default" in mod) && // eslint-disable-next-line @typescript-eslint/no-base-to-string
|
|
983
|
+
mod.toString() !== "[object Module]") {
|
|
984
|
+
try {
|
|
985
|
+
mod.default = mod;
|
|
986
|
+
} catch {
|
|
987
|
+
}
|
|
988
|
+
}
|
|
989
|
+
return mod;
|
|
990
|
+
},
|
|
991
|
+
// require
|
|
992
|
+
r(requireId) {
|
|
993
|
+
return self.__webpack_require__?.(`[${bundle}] ${requireId}`);
|
|
994
|
+
},
|
|
995
|
+
// value exports
|
|
996
|
+
v(value) {
|
|
997
|
+
if (typeof value === "function") {
|
|
998
|
+
exports.default = value((vid) => {
|
|
999
|
+
return self.__webpack_require__?.(`[${bundle}] ${vid}`);
|
|
1000
|
+
});
|
|
1001
|
+
} else {
|
|
1002
|
+
moduleExports.exports = value;
|
|
1003
|
+
}
|
|
1004
|
+
},
|
|
1005
|
+
// async module initializer
|
|
1006
|
+
async a(mod) {
|
|
1007
|
+
let result;
|
|
1008
|
+
await mod(
|
|
1009
|
+
() => {
|
|
1010
|
+
},
|
|
1011
|
+
(value) => result = value
|
|
1012
|
+
);
|
|
1013
|
+
exports.default = result;
|
|
1014
|
+
},
|
|
1015
|
+
// async module loader
|
|
1016
|
+
async A(Aid) {
|
|
1017
|
+
const mod = self.__webpack_require__?.(`[${bundle}] ${Aid}`);
|
|
1018
|
+
return mod.default(
|
|
1019
|
+
(parentId) => self.__webpack_require__?.(`[${bundle}] ${parentId}`)
|
|
1020
|
+
);
|
|
1021
|
+
},
|
|
1022
|
+
// chunk loader
|
|
1023
|
+
l(url) {
|
|
1024
|
+
const moduleInitIndex = allModules.indexOf(moduleInit);
|
|
1025
|
+
if (moduleInitIndex !== -1) {
|
|
1026
|
+
const scriptIndex = allModules.slice(0, moduleInitIndex).findLastIndex((bundleEntry) => bundleEntry instanceof Element);
|
|
1027
|
+
if (scriptIndex !== -1) {
|
|
1028
|
+
const script = allModules[scriptIndex];
|
|
1029
|
+
const scriptSrc = script.getAttribute("data-turbopack-src") || "";
|
|
1030
|
+
const nextIndex = scriptSrc.indexOf("/_next");
|
|
1031
|
+
const baseUrl = nextIndex !== -1 ? scriptSrc.slice(0, nextIndex) : "";
|
|
1032
|
+
const bundleUrl = `[${bundle}] ${baseUrl}/_next/${url}`;
|
|
1033
|
+
return self.__webpack_chunk_load__?.(bundleUrl, bundle);
|
|
1034
|
+
}
|
|
1035
|
+
}
|
|
1036
|
+
throw new Error(
|
|
1037
|
+
`Failed to load Turbopack chunk "${url}" for module "${id}". Check the URL is correct.`
|
|
1038
|
+
);
|
|
1039
|
+
},
|
|
1040
|
+
// global
|
|
1041
|
+
g: self.__remote_components_turbopack_global__[bundle],
|
|
1042
|
+
m: moduleExports,
|
|
1043
|
+
e: exports
|
|
1044
|
+
},
|
|
1045
|
+
moduleExports,
|
|
1046
|
+
exports
|
|
1047
|
+
);
|
|
1048
|
+
if (self.__remote_components_turbopack_modules__[bundle][moduleId] !== moduleExports.exports) {
|
|
1049
|
+
self.__remote_components_turbopack_modules__[bundle][moduleId] = moduleExports.exports;
|
|
1050
|
+
}
|
|
1051
|
+
return moduleExports.exports;
|
|
797
1052
|
}
|
|
798
1053
|
|
|
799
1054
|
// src/shared/client/component-loader.ts
|
|
@@ -868,7 +1123,9 @@ async function loadRemoteComponent({
|
|
|
868
1123
|
component: null,
|
|
869
1124
|
error: new RemoteComponentsError(
|
|
870
1125
|
`Failed to load remote component "${name}".`,
|
|
871
|
-
{
|
|
1126
|
+
{
|
|
1127
|
+
cause: error instanceof Error ? error : new Error(String(error))
|
|
1128
|
+
}
|
|
872
1129
|
)
|
|
873
1130
|
};
|
|
874
1131
|
}
|
|
@@ -904,100 +1161,6 @@ function loadNextPagesComponent(bundle, route, nextData, name, container) {
|
|
|
904
1161
|
return { component };
|
|
905
1162
|
}
|
|
906
1163
|
|
|
907
|
-
// src/shared/client/static-loader.ts
|
|
908
|
-
async function loadStaticRemoteComponent(scripts, url) {
|
|
909
|
-
const self = globalThis;
|
|
910
|
-
if (self.__remote_script_entrypoint_mount__?.[url.href]) {
|
|
911
|
-
self.__remote_script_entrypoint_mount__[url.href] = /* @__PURE__ */ new Set();
|
|
912
|
-
}
|
|
913
|
-
if (self.__remote_script_entrypoint_unmount__?.[url.href]) {
|
|
914
|
-
self.__remote_script_entrypoint_unmount__[url.href] = /* @__PURE__ */ new Set();
|
|
915
|
-
}
|
|
916
|
-
const mountUnmountSets = await Promise.all(
|
|
917
|
-
scripts.map(async (script) => {
|
|
918
|
-
try {
|
|
919
|
-
let src = typeof script.getAttribute === "function" ? script.getAttribute("src") ?? script.src : script.src;
|
|
920
|
-
if (!src && script.textContent) {
|
|
921
|
-
const blob = new Blob(
|
|
922
|
-
[
|
|
923
|
-
script.textContent.replace(
|
|
924
|
-
/import\.meta\.url/g,
|
|
925
|
-
JSON.stringify(url)
|
|
926
|
-
)
|
|
927
|
-
],
|
|
928
|
-
{
|
|
929
|
-
type: "text/javascript"
|
|
930
|
-
}
|
|
931
|
-
);
|
|
932
|
-
src = URL.createObjectURL(blob);
|
|
933
|
-
}
|
|
934
|
-
const mod = await import(
|
|
935
|
-
/* @vite-ignore */
|
|
936
|
-
/* webpackIgnore: true */
|
|
937
|
-
new URL(src, url).href
|
|
938
|
-
);
|
|
939
|
-
if (src.startsWith("blob:")) {
|
|
940
|
-
URL.revokeObjectURL(src);
|
|
941
|
-
}
|
|
942
|
-
if (typeof mod.mount === "function" || typeof mod.default?.mount === "function") {
|
|
943
|
-
if (!self.__remote_script_entrypoint_mount__) {
|
|
944
|
-
self.__remote_script_entrypoint_mount__ = {};
|
|
945
|
-
}
|
|
946
|
-
if (!self.__remote_script_entrypoint_mount__[url.href]) {
|
|
947
|
-
self.__remote_script_entrypoint_mount__[url.href] = /* @__PURE__ */ new Set();
|
|
948
|
-
}
|
|
949
|
-
self.__remote_script_entrypoint_mount__[url.href]?.add(
|
|
950
|
-
mod.mount || mod.default?.mount || (() => {
|
|
951
|
-
})
|
|
952
|
-
);
|
|
953
|
-
}
|
|
954
|
-
if (typeof mod.unmount === "function" || typeof mod.default?.unmount === "function") {
|
|
955
|
-
if (!self.__remote_script_entrypoint_unmount__) {
|
|
956
|
-
self.__remote_script_entrypoint_unmount__ = {};
|
|
957
|
-
}
|
|
958
|
-
if (!self.__remote_script_entrypoint_unmount__[url.href]) {
|
|
959
|
-
self.__remote_script_entrypoint_unmount__[url.href] = /* @__PURE__ */ new Set();
|
|
960
|
-
}
|
|
961
|
-
self.__remote_script_entrypoint_unmount__[url.href]?.add(
|
|
962
|
-
mod.unmount || mod.default?.unmount || (() => {
|
|
963
|
-
})
|
|
964
|
-
);
|
|
965
|
-
}
|
|
966
|
-
return {
|
|
967
|
-
mount: mod.mount || mod.default?.mount,
|
|
968
|
-
unmount: mod.unmount || mod.default?.unmount
|
|
969
|
-
};
|
|
970
|
-
} catch (e) {
|
|
971
|
-
console.error(
|
|
972
|
-
new RemoteComponentsError(
|
|
973
|
-
`Error loading remote component script from "${script.src || url.href}".`,
|
|
974
|
-
{ cause: e }
|
|
975
|
-
)
|
|
976
|
-
);
|
|
977
|
-
return {
|
|
978
|
-
mount: void 0,
|
|
979
|
-
unmount: void 0
|
|
980
|
-
};
|
|
981
|
-
}
|
|
982
|
-
})
|
|
983
|
-
);
|
|
984
|
-
return mountUnmountSets.reduce(
|
|
985
|
-
(acc, { mount, unmount }) => {
|
|
986
|
-
if (typeof mount === "function") {
|
|
987
|
-
acc.mount.add(mount);
|
|
988
|
-
}
|
|
989
|
-
if (typeof unmount === "function") {
|
|
990
|
-
acc.unmount.add(unmount);
|
|
991
|
-
}
|
|
992
|
-
return acc;
|
|
993
|
-
},
|
|
994
|
-
{
|
|
995
|
-
mount: /* @__PURE__ */ new Set(),
|
|
996
|
-
unmount: /* @__PURE__ */ new Set()
|
|
997
|
-
}
|
|
998
|
-
);
|
|
999
|
-
}
|
|
1000
|
-
|
|
1001
1164
|
// src/shared/client/set-attributes-from-props.ts
|
|
1002
1165
|
var DOMAttributeNames = {
|
|
1003
1166
|
acceptCharset: "accept-charset",
|
|
@@ -1020,7 +1183,7 @@ function isBooleanScriptAttribute(attr) {
|
|
|
1020
1183
|
}
|
|
1021
1184
|
function setAttributesFromProps(el, props) {
|
|
1022
1185
|
for (const [p, value] of Object.entries(props)) {
|
|
1023
|
-
if (!Object.
|
|
1186
|
+
if (!Object.hasOwn(props, p))
|
|
1024
1187
|
continue;
|
|
1025
1188
|
if (ignoreProps.includes(p))
|
|
1026
1189
|
continue;
|
|
@@ -1040,256 +1203,98 @@ function setAttributesFromProps(el, props) {
|
|
|
1040
1203
|
}
|
|
1041
1204
|
}
|
|
1042
1205
|
|
|
1043
|
-
// src/shared/client/
|
|
1044
|
-
|
|
1045
|
-
function applyBundleUrlToSrc(bundle, src) {
|
|
1046
|
-
const self = globalThis;
|
|
1047
|
-
if (self.__remote_bundle_url__?.[bundle]?.origin === location.origin) {
|
|
1048
|
-
return src;
|
|
1049
|
-
}
|
|
1050
|
-
const { assetPrefix, path } = /^(?<assetPrefix>.*?)\/_next\/(?<path>.*)/.exec(src)?.groups ?? {};
|
|
1051
|
-
if (!path) {
|
|
1052
|
-
return new URL(src, self.__remote_bundle_url__?.[bundle]?.origin).href;
|
|
1053
|
-
}
|
|
1054
|
-
return `${self.__remote_bundle_url__?.[bundle]?.origin ?? ""}${assetPrefix}/_next/${path}`;
|
|
1055
|
-
}
|
|
1056
|
-
function applyBundleUrlToImagePropsSrc(bundle, src) {
|
|
1057
|
-
if (typeof src === "string") {
|
|
1058
|
-
return applyBundleUrlToSrc(bundle, src);
|
|
1059
|
-
}
|
|
1060
|
-
const propSrc = src;
|
|
1061
|
-
return applyBundleUrlToSrc(bundle, propSrc.src);
|
|
1062
|
-
}
|
|
1063
|
-
var imageImpl = (bundle) => function RemoteImage({
|
|
1064
|
-
fill: _fill,
|
|
1065
|
-
loader: _loader,
|
|
1066
|
-
quality: _quality,
|
|
1067
|
-
priority: _priority,
|
|
1068
|
-
loading: _loading,
|
|
1069
|
-
placeholder: _placeholder,
|
|
1070
|
-
blurDataURL: _blurDataURL,
|
|
1071
|
-
unoptimized: _unoptimized,
|
|
1072
|
-
overrideSrc: _overrideSrc,
|
|
1073
|
-
src,
|
|
1074
|
-
...props
|
|
1075
|
-
}) {
|
|
1076
|
-
const newSrc = applyBundleUrlToImagePropsSrc(
|
|
1077
|
-
bundle,
|
|
1078
|
-
typeof src === "string" ? src : src.src
|
|
1079
|
-
);
|
|
1080
|
-
return (
|
|
1081
|
-
// eslint-disable-next-line @next/next/no-img-element, jsx-a11y/alt-text
|
|
1082
|
-
/* @__PURE__ */ jsx(
|
|
1083
|
-
"img",
|
|
1084
|
-
{
|
|
1085
|
-
decoding: "async",
|
|
1086
|
-
style: { color: "transparent" },
|
|
1087
|
-
...props,
|
|
1088
|
-
src: newSrc,
|
|
1089
|
-
suppressHydrationWarning: true
|
|
1090
|
-
}
|
|
1091
|
-
)
|
|
1092
|
-
);
|
|
1093
|
-
};
|
|
1094
|
-
function sharedPolyfills(shared) {
|
|
1206
|
+
// src/shared/client/static-loader.ts
|
|
1207
|
+
async function loadStaticRemoteComponent(scripts, url) {
|
|
1095
1208
|
const self = globalThis;
|
|
1096
|
-
|
|
1097
|
-
|
|
1098
|
-
|
|
1099
|
-
|
|
1100
|
-
|
|
1101
|
-
|
|
1102
|
-
|
|
1103
|
-
|
|
1104
|
-
|
|
1105
|
-
|
|
1106
|
-
|
|
1107
|
-
|
|
1209
|
+
if (self.__remote_script_entrypoint_mount__?.[url.href]) {
|
|
1210
|
+
self.__remote_script_entrypoint_mount__[url.href] = /* @__PURE__ */ new Set();
|
|
1211
|
+
}
|
|
1212
|
+
if (self.__remote_script_entrypoint_unmount__?.[url.href]) {
|
|
1213
|
+
self.__remote_script_entrypoint_unmount__[url.href] = /* @__PURE__ */ new Set();
|
|
1214
|
+
}
|
|
1215
|
+
const mountUnmountSets = await Promise.all(
|
|
1216
|
+
scripts.map(async (script) => {
|
|
1217
|
+
try {
|
|
1218
|
+
let src = typeof script.getAttribute === "function" ? script.getAttribute("src") ?? script.src : script.src;
|
|
1219
|
+
if (!src && script.textContent) {
|
|
1220
|
+
const blob = new Blob(
|
|
1221
|
+
[
|
|
1222
|
+
script.textContent.replace(
|
|
1223
|
+
/import\.meta\.url/g,
|
|
1224
|
+
JSON.stringify(url)
|
|
1225
|
+
)
|
|
1226
|
+
],
|
|
1227
|
+
{
|
|
1228
|
+
type: "text/javascript"
|
|
1229
|
+
}
|
|
1230
|
+
);
|
|
1231
|
+
src = URL.createObjectURL(blob);
|
|
1232
|
+
}
|
|
1233
|
+
const mod = await import(
|
|
1234
|
+
/* @vite-ignore */
|
|
1235
|
+
/* webpackIgnore: true */
|
|
1236
|
+
new URL(src, url).href
|
|
1237
|
+
);
|
|
1238
|
+
if (src.startsWith("blob:")) {
|
|
1239
|
+
URL.revokeObjectURL(src);
|
|
1240
|
+
}
|
|
1241
|
+
if (typeof mod.mount === "function" || typeof mod.default?.mount === "function") {
|
|
1242
|
+
if (!self.__remote_script_entrypoint_mount__) {
|
|
1243
|
+
self.__remote_script_entrypoint_mount__ = {};
|
|
1108
1244
|
}
|
|
1109
|
-
|
|
1110
|
-
|
|
1111
|
-
|
|
1112
|
-
|
|
1113
|
-
|
|
1114
|
-
|
|
1115
|
-
return {};
|
|
1116
|
-
},
|
|
1117
|
-
useSearchParams() {
|
|
1118
|
-
return new URLSearchParams(location.search);
|
|
1119
|
-
},
|
|
1120
|
-
useSelectedLayoutSegment() {
|
|
1121
|
-
return null;
|
|
1122
|
-
},
|
|
1123
|
-
useSelectedLayoutSegments() {
|
|
1124
|
-
return [];
|
|
1125
|
-
},
|
|
1126
|
-
__esModule: true
|
|
1127
|
-
})),
|
|
1128
|
-
"next/dist/client/app-dir/link": self.__remote_component_host_shared_modules__?.["next/link"] ?? shared?.["next/link"] ?? (() => Promise.resolve({
|
|
1129
|
-
default: ({
|
|
1130
|
-
scroll: _,
|
|
1131
|
-
replace,
|
|
1132
|
-
prefetch,
|
|
1133
|
-
onNavigate,
|
|
1134
|
-
children,
|
|
1135
|
-
...props
|
|
1136
|
-
}) => {
|
|
1137
|
-
if (prefetch) {
|
|
1138
|
-
console.warn(
|
|
1139
|
-
"Next.js Link prefetch is not supported in remote components"
|
|
1245
|
+
if (!self.__remote_script_entrypoint_mount__[url.href]) {
|
|
1246
|
+
self.__remote_script_entrypoint_mount__[url.href] = /* @__PURE__ */ new Set();
|
|
1247
|
+
}
|
|
1248
|
+
self.__remote_script_entrypoint_mount__[url.href]?.add(
|
|
1249
|
+
mod.mount || mod.default?.mount || (() => {
|
|
1250
|
+
})
|
|
1140
1251
|
);
|
|
1141
1252
|
}
|
|
1142
|
-
|
|
1143
|
-
|
|
1144
|
-
|
|
1145
|
-
...props,
|
|
1146
|
-
href: props.href,
|
|
1147
|
-
onClick: (e) => {
|
|
1148
|
-
e.preventDefault();
|
|
1149
|
-
let preventDefaulted = false;
|
|
1150
|
-
e.preventDefault = () => {
|
|
1151
|
-
preventDefaulted = true;
|
|
1152
|
-
e.defaultPrevented = true;
|
|
1153
|
-
};
|
|
1154
|
-
if (typeof props.onClick === "function") {
|
|
1155
|
-
props.onClick(e);
|
|
1156
|
-
}
|
|
1157
|
-
onNavigate?.(e);
|
|
1158
|
-
if (preventDefaulted) {
|
|
1159
|
-
return;
|
|
1160
|
-
}
|
|
1161
|
-
if (replace) {
|
|
1162
|
-
history.replaceState({}, "", props.href);
|
|
1163
|
-
} else {
|
|
1164
|
-
history.pushState({}, "", props.href);
|
|
1165
|
-
}
|
|
1166
|
-
},
|
|
1167
|
-
suppressHydrationWarning: true,
|
|
1168
|
-
children: children ?? null
|
|
1253
|
+
if (typeof mod.unmount === "function" || typeof mod.default?.unmount === "function") {
|
|
1254
|
+
if (!self.__remote_script_entrypoint_unmount__) {
|
|
1255
|
+
self.__remote_script_entrypoint_unmount__ = {};
|
|
1169
1256
|
}
|
|
1170
|
-
|
|
1171
|
-
|
|
1172
|
-
|
|
1173
|
-
|
|
1174
|
-
|
|
1175
|
-
|
|
1176
|
-
|
|
1177
|
-
"next/dist/client/app-dir/form": self.__remote_component_host_shared_modules__?.["next/form"] ?? shared?.["next/form"] ?? (() => Promise.resolve({
|
|
1178
|
-
default: () => {
|
|
1179
|
-
throw new Error("Next.js <Form> component not implemented");
|
|
1180
|
-
},
|
|
1181
|
-
__esModule: true
|
|
1182
|
-
})),
|
|
1183
|
-
"next/dist/client/image-component": self.__remote_component_host_shared_modules__?.["next/image"] ?? shared?.["next/image"] ?? ((bundle) => Promise.resolve({
|
|
1184
|
-
Image: imageImpl(bundle),
|
|
1185
|
-
__esModule: true
|
|
1186
|
-
})),
|
|
1187
|
-
"next/image": self.__remote_component_host_shared_modules__?.["next/image"] ?? shared?.["next/image"] ?? ((bundle) => Promise.resolve({
|
|
1188
|
-
default: imageImpl(bundle),
|
|
1189
|
-
getImageProps: (_imgProps) => {
|
|
1190
|
-
throw new Error(
|
|
1191
|
-
"Next.js getImageProps() is not implemented in remote components"
|
|
1192
|
-
);
|
|
1193
|
-
},
|
|
1194
|
-
__esModule: true
|
|
1195
|
-
})),
|
|
1196
|
-
"next/dist/client/script": self.__remote_component_host_shared_modules__?.["next/script"] ?? shared?.["next/script"] ?? (() => Promise.resolve({
|
|
1197
|
-
// TODO: implement <Script> component for non-Next.js host applications
|
|
1198
|
-
// do not throw an error for now
|
|
1199
|
-
default: () => null,
|
|
1200
|
-
__esModule: true
|
|
1201
|
-
})),
|
|
1202
|
-
"next/router": self.__remote_component_host_shared_modules__?.["next/router"] ?? shared?.["next/router"] ?? (() => (
|
|
1203
|
-
// TODO: incomplete implementation
|
|
1204
|
-
Promise.resolve({
|
|
1205
|
-
useRouter() {
|
|
1206
|
-
return {
|
|
1207
|
-
push: (routerUrl) => {
|
|
1208
|
-
history.pushState({}, "", routerUrl);
|
|
1209
|
-
},
|
|
1210
|
-
replace: (routerUrl) => {
|
|
1211
|
-
history.replaceState({}, "", routerUrl);
|
|
1212
|
-
},
|
|
1213
|
-
back: () => {
|
|
1214
|
-
history.back();
|
|
1215
|
-
}
|
|
1216
|
-
};
|
|
1217
|
-
},
|
|
1218
|
-
__esModule: true
|
|
1219
|
-
})
|
|
1220
|
-
)),
|
|
1221
|
-
"next/dist/build/polyfills/process": () => Promise.resolve({
|
|
1222
|
-
default: {
|
|
1223
|
-
env: {
|
|
1224
|
-
NODE_ENV: "production"
|
|
1257
|
+
if (!self.__remote_script_entrypoint_unmount__[url.href]) {
|
|
1258
|
+
self.__remote_script_entrypoint_unmount__[url.href] = /* @__PURE__ */ new Set();
|
|
1259
|
+
}
|
|
1260
|
+
self.__remote_script_entrypoint_unmount__[url.href]?.add(
|
|
1261
|
+
mod.unmount || mod.default?.unmount || (() => {
|
|
1262
|
+
})
|
|
1263
|
+
);
|
|
1225
1264
|
}
|
|
1226
|
-
|
|
1227
|
-
|
|
1228
|
-
|
|
1229
|
-
|
|
1230
|
-
|
|
1231
|
-
|
|
1232
|
-
|
|
1233
|
-
|
|
1234
|
-
|
|
1235
|
-
|
|
1236
|
-
}
|
|
1237
|
-
|
|
1238
|
-
// src/shared/client/apply-origin.ts
|
|
1239
|
-
var tagNames = [
|
|
1240
|
-
"img",
|
|
1241
|
-
"source",
|
|
1242
|
-
"video",
|
|
1243
|
-
"audio",
|
|
1244
|
-
"track",
|
|
1245
|
-
"iframe",
|
|
1246
|
-
"embed",
|
|
1247
|
-
"script",
|
|
1248
|
-
"link"
|
|
1249
|
-
];
|
|
1250
|
-
function applyOriginToNodes(doc, url) {
|
|
1251
|
-
if (url.origin !== location.origin) {
|
|
1252
|
-
const nodes = doc.querySelectorAll(
|
|
1253
|
-
tagNames.map(
|
|
1254
|
-
(type) => `${type}[src],${type}[srcset],${type}[href],${type}[imagesrcset]`
|
|
1255
|
-
).join(",")
|
|
1256
|
-
);
|
|
1257
|
-
nodes.forEach((node) => {
|
|
1258
|
-
if (node.hasAttribute("src") && /^[./]+\/?/.test(node.getAttribute("src") ?? "")) {
|
|
1259
|
-
node.src = new URL(node.getAttribute("src") ?? "/", url).href;
|
|
1260
|
-
}
|
|
1261
|
-
if (node.hasAttribute("href") && /^[./]+\/?/.test(node.getAttribute("href") ?? "")) {
|
|
1262
|
-
node.setAttribute(
|
|
1263
|
-
"href",
|
|
1264
|
-
new URL(node.getAttribute("href") ?? "/", url).href
|
|
1265
|
+
return {
|
|
1266
|
+
mount: mod.mount || mod.default?.mount,
|
|
1267
|
+
unmount: mod.unmount || mod.default?.unmount
|
|
1268
|
+
};
|
|
1269
|
+
} catch (e) {
|
|
1270
|
+
console.error(
|
|
1271
|
+
new RemoteComponentsError(
|
|
1272
|
+
`Error loading remote component script from "${script.src || url.href}".`,
|
|
1273
|
+
{ cause: e }
|
|
1274
|
+
)
|
|
1265
1275
|
);
|
|
1276
|
+
return {
|
|
1277
|
+
mount: void 0,
|
|
1278
|
+
unmount: void 0
|
|
1279
|
+
};
|
|
1266
1280
|
}
|
|
1267
|
-
|
|
1268
|
-
|
|
1269
|
-
|
|
1270
|
-
|
|
1271
|
-
|
|
1272
|
-
|
|
1273
|
-
return descriptor ? `${absoluteUrl} ${descriptor}` : absoluteUrl;
|
|
1274
|
-
}).join(", ");
|
|
1275
|
-
if (srcSet) {
|
|
1276
|
-
node.setAttribute("srcset", srcSet);
|
|
1277
|
-
}
|
|
1281
|
+
})
|
|
1282
|
+
);
|
|
1283
|
+
return mountUnmountSets.reduce(
|
|
1284
|
+
(acc, { mount, unmount }) => {
|
|
1285
|
+
if (typeof mount === "function") {
|
|
1286
|
+
acc.mount.add(mount);
|
|
1278
1287
|
}
|
|
1279
|
-
if (
|
|
1280
|
-
|
|
1281
|
-
const [urlPart, descriptor] = entry.trim().split(/\s+/);
|
|
1282
|
-
if (!urlPart)
|
|
1283
|
-
return entry;
|
|
1284
|
-
const absoluteUrl = new URL(urlPart, url).href;
|
|
1285
|
-
return descriptor ? `${absoluteUrl} ${descriptor}` : absoluteUrl;
|
|
1286
|
-
}).join(", ");
|
|
1287
|
-
if (srcSet) {
|
|
1288
|
-
node.setAttribute("imagesrcset", srcSet);
|
|
1289
|
-
}
|
|
1288
|
+
if (typeof unmount === "function") {
|
|
1289
|
+
acc.unmount.add(unmount);
|
|
1290
1290
|
}
|
|
1291
|
-
|
|
1292
|
-
|
|
1291
|
+
return acc;
|
|
1292
|
+
},
|
|
1293
|
+
{
|
|
1294
|
+
mount: /* @__PURE__ */ new Set(),
|
|
1295
|
+
unmount: /* @__PURE__ */ new Set()
|
|
1296
|
+
}
|
|
1297
|
+
);
|
|
1293
1298
|
}
|
|
1294
1299
|
|
|
1295
1300
|
// src/shared/ssr/fetch-headers.ts
|