remote-components 0.3.4 → 0.3.6
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/app-63L5THIQ.js +12 -0
- package/dist/app-63L5THIQ.js.map +1 -0
- package/dist/app-A5QE7XRH.cjs +12 -0
- package/dist/app-A5QE7XRH.cjs.map +1 -0
- package/dist/chunk-2VQGCACH.js +190 -0
- package/dist/chunk-2VQGCACH.js.map +1 -0
- package/dist/chunk-42N2ZLE2.js +703 -0
- package/dist/chunk-42N2ZLE2.js.map +1 -0
- package/dist/chunk-6IUP26UK.cjs +57 -0
- package/dist/chunk-6IUP26UK.cjs.map +1 -0
- package/dist/chunk-7MVFHOIP.cjs +60 -0
- package/dist/chunk-7MVFHOIP.cjs.map +1 -0
- package/dist/chunk-CREXMFMF.cjs +155 -0
- package/dist/chunk-CREXMFMF.cjs.map +1 -0
- package/dist/chunk-CTUJSWCM.js +215 -0
- package/dist/chunk-CTUJSWCM.js.map +1 -0
- package/dist/chunk-ENYGL5CO.js +11 -0
- package/dist/chunk-ENYGL5CO.js.map +1 -0
- package/dist/chunk-ER73O65F.cjs +703 -0
- package/dist/chunk-ER73O65F.cjs.map +1 -0
- package/dist/chunk-F44NODUS.cjs +709 -0
- package/dist/chunk-F44NODUS.cjs.map +1 -0
- package/dist/chunk-GAXJTFBV.js +20 -0
- package/dist/chunk-GAXJTFBV.js.map +1 -0
- package/dist/chunk-HNZVEIKN.js +358 -0
- package/dist/chunk-HNZVEIKN.js.map +1 -0
- package/dist/chunk-KE7QPAQ4.cjs +21 -0
- package/dist/chunk-KE7QPAQ4.cjs.map +1 -0
- package/dist/chunk-KEPHL25S.js +60 -0
- package/dist/chunk-KEPHL25S.js.map +1 -0
- package/dist/chunk-KKBEMQU7.cjs +670 -0
- package/dist/chunk-KKBEMQU7.cjs.map +1 -0
- package/dist/chunk-KYJWRZ2B.js +709 -0
- package/dist/chunk-KYJWRZ2B.js.map +1 -0
- package/dist/chunk-N5VQR2PW.cjs +215 -0
- package/dist/chunk-N5VQR2PW.cjs.map +1 -0
- package/dist/chunk-OO4AMJWO.js +155 -0
- package/dist/chunk-OO4AMJWO.js.map +1 -0
- package/dist/chunk-R4QFK5TN.cjs +358 -0
- package/dist/chunk-R4QFK5TN.cjs.map +1 -0
- package/dist/chunk-RUWR74XQ.cjs +152 -0
- package/dist/chunk-RUWR74XQ.cjs.map +1 -0
- package/dist/chunk-S2A4TFLS.js +152 -0
- package/dist/chunk-S2A4TFLS.js.map +1 -0
- package/dist/chunk-SHFJ5OQA.cjs +11 -0
- package/dist/chunk-SHFJ5OQA.cjs.map +1 -0
- package/dist/chunk-TCFLEBQM.cjs +20 -0
- package/dist/chunk-TCFLEBQM.cjs.map +1 -0
- package/dist/chunk-W5ESPGHH.js +670 -0
- package/dist/chunk-W5ESPGHH.js.map +1 -0
- package/dist/chunk-X6YKUJKH.js +21 -0
- package/dist/chunk-X6YKUJKH.js.map +1 -0
- package/dist/chunk-XCFYWSLD.cjs +190 -0
- package/dist/chunk-XCFYWSLD.cjs.map +1 -0
- package/dist/chunk-ZPMTZ3KJ.js +57 -0
- package/dist/chunk-ZPMTZ3KJ.js.map +1 -0
- package/dist/config/nextjs.cjs +76 -351
- package/dist/config/nextjs.cjs.map +1 -1
- package/dist/config/nextjs.js +26 -266
- package/dist/config/nextjs.js.map +1 -1
- package/dist/config/webpack.cjs +12 -240
- package/dist/config/webpack.cjs.map +1 -1
- package/dist/config/webpack.js +6 -207
- package/dist/config/webpack.js.map +1 -1
- package/dist/host/html.cjs +139 -2447
- package/dist/host/html.cjs.map +1 -1
- package/dist/host/html.js +66 -2345
- package/dist/host/html.js.map +1 -1
- package/dist/host/nextjs/app/client-only.cjs +53 -2825
- package/dist/host/nextjs/app/client-only.cjs.map +1 -1
- package/dist/host/nextjs/app/client-only.js +31 -2780
- package/dist/host/nextjs/app/client-only.js.map +1 -1
- package/dist/host/nextjs/app.cjs +34 -2
- package/dist/host/nextjs/app.cjs.map +1 -1
- package/dist/host/nextjs/app.js +35 -3
- package/dist/host/nextjs/app.js.map +1 -1
- package/dist/host/proxy/client.cjs +8 -38
- package/dist/host/proxy/client.cjs.map +1 -1
- package/dist/host/proxy/client.js +4 -7
- package/dist/host/proxy/client.js.map +1 -1
- package/dist/host/proxy.cjs +19 -56
- package/dist/host/proxy.cjs.map +1 -1
- package/dist/host/proxy.js +8 -20
- package/dist/host/proxy.js.map +1 -1
- package/dist/host/react.cjs +17 -2756
- package/dist/host/react.cjs.map +1 -1
- package/dist/host/react.js +13 -2723
- package/dist/host/react.js.map +1 -1
- package/dist/internal/host/nextjs/app-client.cjs +38 -24
- package/dist/internal/host/nextjs/app-client.cjs.map +1 -1
- package/dist/internal/host/nextjs/app-client.js +38 -24
- package/dist/internal/host/nextjs/app-client.js.map +1 -1
- package/dist/internal/host/nextjs/remote-component-links.cjs +24 -13
- package/dist/internal/host/nextjs/remote-component-links.cjs.map +1 -1
- package/dist/internal/host/nextjs/remote-component-links.d.ts +3 -0
- package/dist/internal/host/nextjs/remote-component-links.js +24 -13
- package/dist/internal/host/nextjs/remote-component-links.js.map +1 -1
- package/dist/internal/host/server/fetch-remote-component.cjs +1 -18
- package/dist/internal/host/server/fetch-remote-component.cjs.map +1 -1
- package/dist/internal/host/server/fetch-remote-component.js +1 -18
- package/dist/internal/host/server/fetch-remote-component.js.map +1 -1
- package/dist/internal/host/shared/lifecycle.cjs +69 -0
- package/dist/internal/host/shared/lifecycle.cjs.map +1 -0
- package/dist/internal/host/shared/lifecycle.d.ts +34 -0
- package/dist/internal/host/shared/lifecycle.js +44 -0
- package/dist/internal/host/shared/lifecycle.js.map +1 -0
- package/dist/internal/host/shared/pipeline.cjs +222 -0
- package/dist/internal/host/shared/pipeline.cjs.map +1 -0
- package/dist/internal/host/shared/pipeline.d.ts +153 -0
- package/dist/internal/host/shared/pipeline.js +200 -0
- package/dist/internal/host/shared/pipeline.js.map +1 -0
- package/dist/internal/runtime/loaders/component-loader.cjs +5 -2
- package/dist/internal/runtime/loaders/component-loader.cjs.map +1 -1
- package/dist/internal/runtime/loaders/component-loader.js +5 -2
- package/dist/internal/runtime/loaders/component-loader.js.map +1 -1
- package/dist/internal/runtime/turbopack/patterns.cjs +1 -1
- package/dist/internal/runtime/turbopack/patterns.cjs.map +1 -1
- package/dist/internal/runtime/turbopack/patterns.js +1 -1
- package/dist/internal/runtime/turbopack/patterns.js.map +1 -1
- package/dist/internal/runtime/turbopack/remote-scope-setup.cjs.map +1 -1
- package/dist/internal/runtime/turbopack/remote-scope-setup.js.map +1 -1
- package/dist/internal/runtime/turbopack/remote-scope.cjs +1 -5
- package/dist/internal/runtime/turbopack/remote-scope.cjs.map +1 -1
- package/dist/internal/runtime/turbopack/remote-scope.js +1 -5
- package/dist/internal/runtime/turbopack/remote-scope.js.map +1 -1
- package/dist/internal/utils.cjs +1 -1
- package/dist/internal/utils.cjs.map +1 -1
- package/dist/internal/utils.d.ts +5 -5
- package/dist/internal/utils.js +1 -1
- package/dist/internal/utils.js.map +1 -1
- package/dist/remote/html.cjs +15 -314
- package/dist/remote/html.cjs.map +1 -1
- package/dist/remote/html.js +7 -305
- package/dist/remote/html.js.map +1 -1
- package/dist/remote/middleware.cjs +16 -41
- package/dist/remote/middleware.cjs.map +1 -1
- package/dist/script-6W5JRBZK.cjs +26 -0
- package/dist/script-6W5JRBZK.cjs.map +1 -0
- package/dist/script-IFEBOLIA.js +26 -0
- package/dist/script-IFEBOLIA.js.map +1 -0
- package/dist/static-loader-X4TSF5KW.js +11 -0
- package/dist/static-loader-X4TSF5KW.js.map +1 -0
- package/dist/static-loader-ZYD5BO4D.cjs +11 -0
- package/dist/static-loader-ZYD5BO4D.cjs.map +1 -0
- package/dist/turbopack-NPGO3MWS.js +55 -0
- package/dist/turbopack-NPGO3MWS.js.map +1 -0
- package/dist/turbopack-WRMKPNN4.cjs +55 -0
- package/dist/turbopack-WRMKPNN4.cjs.map +1 -0
- package/dist/webpack-DUBHPYD6.js +92 -0
- package/dist/webpack-DUBHPYD6.js.map +1 -0
- package/dist/webpack-KSCMCL7M.cjs +92 -0
- package/dist/webpack-KSCMCL7M.cjs.map +1 -0
- package/package.json +10 -3
package/dist/host/html.cjs
CHANGED
|
@@ -1,2329 +1,40 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __create = Object.create;
|
|
3
|
-
var __defProp = Object.defineProperty;
|
|
4
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
-
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
-
var __esm = (fn, res) => function __init() {
|
|
9
|
-
return fn && (res = (0, fn[__getOwnPropNames(fn)[0]])(fn = 0)), res;
|
|
10
|
-
};
|
|
11
|
-
var __export = (target, all) => {
|
|
12
|
-
for (var name in all)
|
|
13
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
14
|
-
};
|
|
15
|
-
var __copyProps = (to, from, except, desc) => {
|
|
16
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
17
|
-
for (let key of __getOwnPropNames(from))
|
|
18
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
19
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
20
|
-
}
|
|
21
|
-
return to;
|
|
22
|
-
};
|
|
23
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
24
|
-
// If the importer is in node compatibility mode or this is not an ESM
|
|
25
|
-
// file that has been converted to a CommonJS file using a Babel-
|
|
26
|
-
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
27
|
-
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
28
|
-
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
29
|
-
mod
|
|
30
|
-
));
|
|
31
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
32
|
-
|
|
33
|
-
// src/utils/constants.ts
|
|
34
|
-
var RC_PROTECTED_REMOTE_FETCH_PATHNAME, CORS_DOCS_URL;
|
|
35
|
-
var init_constants = __esm({
|
|
36
|
-
"src/utils/constants.ts"() {
|
|
37
|
-
"use strict";
|
|
38
|
-
RC_PROTECTED_REMOTE_FETCH_PATHNAME = "/rc-fetch-protected-remote";
|
|
39
|
-
CORS_DOCS_URL = "https://vercel.com/docs/remote-components/concepts/cors-external-urls#accessing-cross-site-protected-remote-components";
|
|
40
|
-
}
|
|
41
|
-
});
|
|
42
|
-
|
|
43
|
-
// src/runtime/url/protected-rc-fallback.ts
|
|
44
|
-
function isProxiedUrl(url) {
|
|
45
|
-
try {
|
|
46
|
-
return new URL(url, location.href).pathname === RC_PROTECTED_REMOTE_FETCH_PATHNAME;
|
|
47
|
-
} catch {
|
|
48
|
-
return false;
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
var init_protected_rc_fallback = __esm({
|
|
52
|
-
"src/runtime/url/protected-rc-fallback.ts"() {
|
|
53
|
-
"use strict";
|
|
54
|
-
init_constants();
|
|
55
|
-
}
|
|
56
|
-
});
|
|
57
|
-
|
|
58
|
-
// src/utils/abort.ts
|
|
59
|
-
function isAbortError(error) {
|
|
60
|
-
if (error instanceof DOMException && error.name === "AbortError") {
|
|
61
|
-
return true;
|
|
62
|
-
}
|
|
63
|
-
if (error !== null && typeof error === "object" && "name" in error && error.name === "AbortError" && "message" in error && typeof error.message === "string") {
|
|
64
|
-
const e = error;
|
|
65
|
-
return typeof e.code === "number" || e.constructor?.name === "DOMException";
|
|
66
|
-
}
|
|
67
|
-
return false;
|
|
68
|
-
}
|
|
69
|
-
var init_abort = __esm({
|
|
70
|
-
"src/utils/abort.ts"() {
|
|
71
|
-
"use strict";
|
|
72
|
-
}
|
|
73
|
-
});
|
|
74
|
-
|
|
75
|
-
// src/utils/error.ts
|
|
76
|
-
function multipleRemoteComponentsError(url) {
|
|
77
|
-
return new RemoteComponentsError(
|
|
78
|
-
`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.`
|
|
79
|
-
);
|
|
80
|
-
}
|
|
81
|
-
function failedToFetchRemoteComponentError(url, { status, statusText }, help = "Is the URL correct and accessible?") {
|
|
82
|
-
return new RemoteComponentsError(
|
|
83
|
-
`Failed to fetch Remote Component from "${url}". ${help}`,
|
|
84
|
-
{ cause: new Error(`${status} ${statusText}`) }
|
|
85
|
-
);
|
|
86
|
-
}
|
|
87
|
-
async function errorFromFailedFetch(originalUrl, resolvedUrl, res) {
|
|
88
|
-
const isProxied = isProxiedUrl(resolvedUrl.href);
|
|
89
|
-
if (isProxied && res) {
|
|
90
|
-
const body = await res.text().catch(() => "");
|
|
91
|
-
return failedProxyFetchError(
|
|
92
|
-
originalUrl,
|
|
93
|
-
resolvedUrl.href,
|
|
94
|
-
res.status,
|
|
95
|
-
body
|
|
96
|
-
);
|
|
97
|
-
}
|
|
98
|
-
const fallback = failedToFetchRemoteComponentError(
|
|
99
|
-
originalUrl,
|
|
100
|
-
res ?? { status: 0, statusText: "No Response" }
|
|
101
|
-
);
|
|
102
|
-
if (!res)
|
|
103
|
-
return fallback;
|
|
104
|
-
try {
|
|
105
|
-
const body = await res.text();
|
|
106
|
-
const parser = new DOMParser();
|
|
107
|
-
const doc = parser.parseFromString(body, "text/html");
|
|
108
|
-
const errorTemplate = doc.querySelector(
|
|
109
|
-
"template[data-next-error-message]"
|
|
110
|
-
);
|
|
111
|
-
const errorMessage = errorTemplate?.getAttribute("data-next-error-message");
|
|
112
|
-
if (errorMessage) {
|
|
113
|
-
const error = new RemoteComponentsError(errorMessage);
|
|
114
|
-
const errorStack = errorTemplate?.getAttribute("data-next-error-stack");
|
|
115
|
-
if (errorStack) {
|
|
116
|
-
error.stack = errorStack;
|
|
117
|
-
}
|
|
118
|
-
return error;
|
|
119
|
-
}
|
|
120
|
-
} catch (parseError) {
|
|
121
|
-
if (isAbortError(parseError))
|
|
122
|
-
throw parseError;
|
|
123
|
-
}
|
|
124
|
-
return fallback;
|
|
125
|
-
}
|
|
126
|
-
function failedProxiedAssetError(kind, url, resolvedUrl) {
|
|
127
|
-
return new RemoteComponentsError(
|
|
128
|
-
`Failed to load ${kind} "${url}" via proxy "${resolvedUrl}". Ensure withRemoteComponentsHostProxy middleware is configured, "${RC_PROTECTED_REMOTE_FETCH_PATHNAME}" is in the matcher, and the remote URL is included in allowedProxyUrls. See: ${CORS_DOCS_URL}`
|
|
129
|
-
);
|
|
130
|
-
}
|
|
131
|
-
function failedProxyFetchError(originalUrl, proxyUrl, status, responseBody) {
|
|
132
|
-
if (status === 404) {
|
|
133
|
-
return new RemoteComponentsError(
|
|
134
|
-
`Could not proxy the request to "${originalUrl}" \u2014 the proxy endpoint "${RC_PROTECTED_REMOTE_FETCH_PATHNAME}" returned 404.
|
|
135
|
-
|
|
136
|
-
The host server needs middleware or a route that handles "${RC_PROTECTED_REMOTE_FETCH_PATHNAME}".
|
|
137
|
-
|
|
138
|
-
Proxying requires two pieces:
|
|
139
|
-
1. resolveClientUrl={routeThroughHostProxy} on <RemoteComponent>
|
|
140
|
-
2. Middleware or a route for "${RC_PROTECTED_REMOTE_FETCH_PATHNAME}" on the host server
|
|
141
|
-
|
|
142
|
-
Docs: ${CORS_DOCS_URL}`
|
|
143
|
-
);
|
|
144
|
-
}
|
|
145
|
-
if (status === 403) {
|
|
146
|
-
const detail = responseBody ? ` ${responseBody}` : "";
|
|
147
|
-
return new RemoteComponentsError(
|
|
148
|
-
`Proxied request to "${proxyUrl}" was forbidden.${detail} See: ${CORS_DOCS_URL}`
|
|
149
|
-
);
|
|
150
|
-
}
|
|
151
|
-
return new RemoteComponentsError(
|
|
152
|
-
`Proxied request for "${originalUrl}" via "${proxyUrl}" failed with status ${status}. See: ${CORS_DOCS_URL}`
|
|
153
|
-
);
|
|
154
|
-
}
|
|
155
|
-
var RemoteComponentsError;
|
|
156
|
-
var init_error = __esm({
|
|
157
|
-
"src/utils/error.ts"() {
|
|
158
|
-
"use strict";
|
|
159
|
-
init_protected_rc_fallback();
|
|
160
|
-
init_abort();
|
|
161
|
-
init_constants();
|
|
162
|
-
RemoteComponentsError = class extends Error {
|
|
163
|
-
code = "REMOTE_COMPONENTS_ERROR";
|
|
164
|
-
constructor(message, options) {
|
|
165
|
-
super(message, options);
|
|
166
|
-
this.name = "RemoteComponentsError";
|
|
167
|
-
}
|
|
168
|
-
};
|
|
169
|
-
}
|
|
170
|
-
});
|
|
171
|
-
|
|
172
|
-
// src/utils/logger.ts
|
|
173
|
-
function logDebug(location2, message) {
|
|
174
|
-
if (DEBUG) {
|
|
175
|
-
console.debug(`[${PREFIX}:${location2}]: ${message}`);
|
|
176
|
-
}
|
|
177
|
-
}
|
|
178
|
-
function logWarn(location2, message) {
|
|
179
|
-
console.warn(`[${PREFIX}:${location2}]: ${message}`);
|
|
180
|
-
}
|
|
181
|
-
function logError(location2, message, cause) {
|
|
182
|
-
console.error(
|
|
183
|
-
new RemoteComponentsError(`[${PREFIX}:${location2}]: ${message}`, {
|
|
184
|
-
cause
|
|
185
|
-
})
|
|
186
|
-
);
|
|
187
|
-
}
|
|
188
|
-
function warnCrossOriginFetchError(logLocation, url) {
|
|
189
|
-
try {
|
|
190
|
-
const parsed = typeof url === "string" ? new URL(url) : url;
|
|
191
|
-
if (typeof location === "undefined" || parsed.origin === location.origin) {
|
|
192
|
-
return;
|
|
193
|
-
}
|
|
194
|
-
logWarn(
|
|
195
|
-
logLocation,
|
|
196
|
-
`Failed to fetch cross-origin resource "${parsed.href}". To load assets from a protected deployment, two steps are required: (1) configure withRemoteComponentsHostProxy middleware in your host with the remote URL in allowedProxyUrls, and (2) provide a resolveClientUrl prop that rewrites cross-origin asset URLs to go through the proxy. See: ${CORS_DOCS_URL}`
|
|
197
|
-
);
|
|
198
|
-
} catch {
|
|
199
|
-
}
|
|
200
|
-
}
|
|
201
|
-
var PREFIX, DEBUG;
|
|
202
|
-
var init_logger = __esm({
|
|
203
|
-
"src/utils/logger.ts"() {
|
|
204
|
-
"use strict";
|
|
205
|
-
init_constants();
|
|
206
|
-
init_error();
|
|
207
|
-
PREFIX = "remote-components";
|
|
208
|
-
DEBUG = typeof window !== "undefined" && localStorage.getItem("RC_DEBUG") === "true" || typeof process !== "undefined" && process.env.RC_DEBUG === "true";
|
|
209
|
-
}
|
|
210
|
-
});
|
|
211
|
-
|
|
212
|
-
// src/utils/index.ts
|
|
213
|
-
function escapeString(str) {
|
|
214
|
-
return str.replace(/[^a-z0-9]/g, "_");
|
|
215
|
-
}
|
|
216
|
-
function computeScopedName(name, options) {
|
|
217
|
-
return options.isCrossOrigin ? `${name}_${escapeString(options.remoteHost.toLowerCase())}` : name;
|
|
218
|
-
}
|
|
219
|
-
var init_utils = __esm({
|
|
220
|
-
"src/utils/index.ts"() {
|
|
221
|
-
"use strict";
|
|
222
|
-
}
|
|
223
|
-
});
|
|
224
|
-
|
|
225
|
-
// src/runtime/constants.ts
|
|
226
|
-
function getBundleKey(bundle) {
|
|
227
|
-
return escapeString(bundle);
|
|
228
|
-
}
|
|
229
|
-
var DEFAULT_BUNDLE_NAME, DEFAULT_COMPONENT_NAME, DEFAULT_ROUTE, RUNTIME_WEBPACK, RUNTIME_TURBOPACK, RUNTIME_SCRIPT;
|
|
230
|
-
var init_constants2 = __esm({
|
|
231
|
-
"src/runtime/constants.ts"() {
|
|
232
|
-
"use strict";
|
|
233
|
-
init_utils();
|
|
234
|
-
DEFAULT_BUNDLE_NAME = "__vercel_remote_bundle";
|
|
235
|
-
DEFAULT_COMPONENT_NAME = "__vercel_remote_component";
|
|
236
|
-
DEFAULT_ROUTE = "/";
|
|
237
|
-
RUNTIME_WEBPACK = "webpack";
|
|
238
|
-
RUNTIME_TURBOPACK = "turbopack";
|
|
239
|
-
RUNTIME_SCRIPT = "script";
|
|
240
|
-
}
|
|
241
|
-
});
|
|
242
|
-
|
|
243
|
-
// src/runtime/namespace.ts
|
|
244
|
-
function getNamespace() {
|
|
245
|
-
const g = globalThis;
|
|
246
|
-
const existing = g.__remote_components__;
|
|
247
|
-
if (existing) {
|
|
248
|
-
return existing;
|
|
249
|
-
}
|
|
250
|
-
const ns = {
|
|
251
|
-
scopes: /* @__PURE__ */ new Map(),
|
|
252
|
-
chunkCache: {},
|
|
253
|
-
mountFns: {},
|
|
254
|
-
unmountFns: {},
|
|
255
|
-
bundleUrls: {},
|
|
256
|
-
moduleRegistry: {},
|
|
257
|
-
dispatcherRuntime: void 0,
|
|
258
|
-
hostSharedModules: {},
|
|
259
|
-
cssCache: {},
|
|
260
|
-
shadowRoots: {}
|
|
261
|
-
};
|
|
262
|
-
const nsRecord = ns;
|
|
263
|
-
for (const { global, prop } of LEGACY_ALIASES) {
|
|
264
|
-
const legacyValue = g[global];
|
|
265
|
-
if (legacyValue != null) {
|
|
266
|
-
nsRecord[prop] = legacyValue;
|
|
267
|
-
}
|
|
268
|
-
g[global] = ns[prop];
|
|
269
|
-
}
|
|
270
|
-
const gRecord = g;
|
|
271
|
-
for (const key of Object.keys(gRecord)) {
|
|
272
|
-
if (key.startsWith(SHADOW_ROOT_PREFIX)) {
|
|
273
|
-
const suffix = key.slice(SHADOW_ROOT_PREFIX.length);
|
|
274
|
-
ns.shadowRoots[suffix] = gRecord[key];
|
|
275
|
-
delete gRecord[key];
|
|
276
|
-
}
|
|
277
|
-
}
|
|
278
|
-
g.__remote_components__ = ns;
|
|
279
|
-
return ns;
|
|
280
|
-
}
|
|
281
|
-
var SHADOW_ROOT_PREFIX, LEGACY_ALIASES;
|
|
282
|
-
var init_namespace = __esm({
|
|
283
|
-
"src/runtime/namespace.ts"() {
|
|
284
|
-
"use strict";
|
|
285
|
-
SHADOW_ROOT_PREFIX = "__remote_components_shadowroot_";
|
|
286
|
-
LEGACY_ALIASES = [
|
|
287
|
-
{ global: "__remote_component_scopes__", prop: "scopes" },
|
|
288
|
-
{
|
|
289
|
-
global: "__remote_components_turbopack_chunk_loader_promise__",
|
|
290
|
-
prop: "chunkCache"
|
|
291
|
-
},
|
|
292
|
-
{ global: "__remote_script_entrypoint_mount__", prop: "mountFns" },
|
|
293
|
-
{ global: "__remote_script_entrypoint_unmount__", prop: "unmountFns" },
|
|
294
|
-
{ global: "__remote_bundle_url__", prop: "bundleUrls" },
|
|
295
|
-
{ global: "__rc_module_registry__", prop: "moduleRegistry" },
|
|
296
|
-
{
|
|
297
|
-
global: "__remote_component_host_shared_modules__",
|
|
298
|
-
prop: "hostSharedModules"
|
|
299
|
-
},
|
|
300
|
-
{ global: "__remote_next_css__", prop: "cssCache" }
|
|
301
|
-
];
|
|
302
|
-
}
|
|
303
|
-
});
|
|
304
|
-
|
|
305
|
-
// src/runtime/patterns.ts
|
|
306
|
-
function collapseDoubleSlashes(path) {
|
|
307
|
-
return path.replace(DOUBLE_SLASH_RE, "/");
|
|
308
|
-
}
|
|
309
|
-
var REMOTE_COMPONENT_REGEX, NEXT_BUNDLE_PATH_RE, DOUBLE_SLASH_RE;
|
|
310
|
-
var init_patterns = __esm({
|
|
311
|
-
"src/runtime/patterns.ts"() {
|
|
312
|
-
"use strict";
|
|
313
|
-
REMOTE_COMPONENT_REGEX = /(?<prefix>.*?)\[(?<bundle>[^\]]+)\](?:%20| )(?<id>.+)/;
|
|
314
|
-
NEXT_BUNDLE_PATH_RE = /\/_next\/\[.+\](?:%20| )/;
|
|
315
|
-
DOUBLE_SLASH_RE = /(?<!:)\/\//g;
|
|
316
|
-
}
|
|
317
|
-
});
|
|
318
|
-
|
|
319
|
-
// src/runtime/turbopack/remote-scope.ts
|
|
320
|
-
function getRegistry() {
|
|
321
|
-
return getNamespace().scopes;
|
|
322
|
-
}
|
|
323
|
-
function createScope(name, url, runtime, resolveClientUrl) {
|
|
324
|
-
const isCrossOrigin = url.origin !== location.origin;
|
|
325
|
-
const scopedName = computeScopedName(name, {
|
|
326
|
-
remoteHost: url.host,
|
|
327
|
-
isCrossOrigin
|
|
328
|
-
});
|
|
329
|
-
const globalKey = getBundleKey(scopedName);
|
|
330
|
-
return {
|
|
331
|
-
name,
|
|
332
|
-
scopedName,
|
|
333
|
-
globalKey,
|
|
334
|
-
url,
|
|
335
|
-
runtime,
|
|
336
|
-
resolveClientUrl,
|
|
337
|
-
moduleCache: {},
|
|
338
|
-
sharedModules: {},
|
|
339
|
-
moduleGlobal: {},
|
|
340
|
-
turbopackModules: []
|
|
341
|
-
};
|
|
342
|
-
}
|
|
343
|
-
function registerScope(scope) {
|
|
344
|
-
const registry = getRegistry();
|
|
345
|
-
registry.set(scope.scopedName, scope);
|
|
346
|
-
if (scope.scopedName !== scope.name) {
|
|
347
|
-
const existing = registry.get(scope.name);
|
|
348
|
-
if (existing && existing.scopedName !== scope.scopedName) {
|
|
349
|
-
logWarn(
|
|
350
|
-
"RemoteScope",
|
|
351
|
-
`Plain name "${scope.name}" already registered by scope "${existing.scopedName}" \u2014 overwriting with "${scope.scopedName}". Static hosts will only resolve the latest one.`
|
|
352
|
-
);
|
|
353
|
-
}
|
|
354
|
-
registry.set(scope.name, scope);
|
|
355
|
-
}
|
|
356
|
-
logDebug(
|
|
357
|
-
"RemoteScope",
|
|
358
|
-
`Registered scope "${scope.scopedName}" (${registry.size} total)`
|
|
359
|
-
);
|
|
360
|
-
}
|
|
361
|
-
function getScope(name) {
|
|
362
|
-
return getRegistry().get(name);
|
|
363
|
-
}
|
|
364
|
-
function formatRemoteId(scope, path) {
|
|
365
|
-
return `[${scope.scopedName}] ${path}`;
|
|
366
|
-
}
|
|
367
|
-
function parseRemoteId(id) {
|
|
368
|
-
const groups = REMOTE_COMPONENT_REGEX.exec(id)?.groups;
|
|
369
|
-
if (groups?.bundle && groups.id) {
|
|
370
|
-
return {
|
|
371
|
-
bundle: groups.bundle,
|
|
372
|
-
path: groups.id,
|
|
373
|
-
prefix: groups.prefix ?? ""
|
|
374
|
-
};
|
|
375
|
-
}
|
|
376
|
-
return { bundle: "default", path: id, prefix: "" };
|
|
377
|
-
}
|
|
378
|
-
var init_remote_scope = __esm({
|
|
379
|
-
"src/runtime/turbopack/remote-scope.ts"() {
|
|
380
|
-
"use strict";
|
|
381
|
-
init_constants2();
|
|
382
|
-
init_namespace();
|
|
383
|
-
init_patterns();
|
|
384
|
-
init_utils();
|
|
385
|
-
init_logger();
|
|
386
|
-
}
|
|
387
|
-
});
|
|
388
|
-
|
|
389
|
-
// src/config/webpack/apply-shared-modules.ts
|
|
390
|
-
function applySharedModules(bundle, resolve) {
|
|
391
|
-
logDebug(
|
|
392
|
-
"SharedModules",
|
|
393
|
-
`applySharedModules called for bundle: "${bundle}"`
|
|
394
|
-
);
|
|
395
|
-
logDebug(
|
|
396
|
-
"SharedModules",
|
|
397
|
-
`Shared modules to resolve: ${Object.keys(resolve)}`
|
|
398
|
-
);
|
|
399
|
-
const self = globalThis;
|
|
400
|
-
const scope = getScope(bundle);
|
|
401
|
-
const webpackBundle = scope?.webpackRequire ?? self.__remote_webpack_require__?.[bundle];
|
|
402
|
-
if (webpackBundle) {
|
|
403
|
-
const modulePaths = Object.keys(
|
|
404
|
-
self.__remote_webpack_module_map__?.[bundle] ?? webpackBundle.m ?? {}
|
|
405
|
-
);
|
|
406
|
-
logDebug(
|
|
407
|
-
"SharedModules",
|
|
408
|
-
`Available module paths for bundle "${bundle}": ${modulePaths}`
|
|
409
|
-
);
|
|
410
|
-
for (const [key, value] of Object.entries(resolve)) {
|
|
411
|
-
const exactIds = modulePaths.filter((p) => p === key);
|
|
412
|
-
const ids = exactIds.length > 0 ? exactIds : modulePaths.filter((p) => p.includes(key));
|
|
413
|
-
if (ids.length === 0) {
|
|
414
|
-
logDebug(
|
|
415
|
-
"SharedModules",
|
|
416
|
-
`No matching module path found for shared module "${key}"`
|
|
417
|
-
);
|
|
418
|
-
}
|
|
419
|
-
for (const id of ids) {
|
|
420
|
-
if (webpackBundle.m) {
|
|
421
|
-
const resolvedId = self.__remote_webpack_module_map__?.[bundle]?.[id] ? `${self.__remote_webpack_module_map__[bundle][id]}` : id;
|
|
422
|
-
if (resolvedId !== id) {
|
|
423
|
-
logDebug(
|
|
424
|
-
"SharedModules",
|
|
425
|
-
`Mapped module id: "${id}" -> "${resolvedId}"`
|
|
426
|
-
);
|
|
427
|
-
}
|
|
428
|
-
webpackBundle.m[resolvedId] = (module2) => {
|
|
429
|
-
module2.exports = value;
|
|
430
|
-
};
|
|
431
|
-
} else {
|
|
432
|
-
logWarn(
|
|
433
|
-
"SharedModules",
|
|
434
|
-
`webpackBundle.m is not available for bundle "${bundle}" \u2014 ${DEDUPLICATION_SKIPPED}`
|
|
435
|
-
);
|
|
436
|
-
}
|
|
437
|
-
}
|
|
438
|
-
}
|
|
439
|
-
} else {
|
|
440
|
-
logWarn(
|
|
441
|
-
"SharedModules",
|
|
442
|
-
`No webpack require found for bundle "${bundle}" \u2014 ${DEDUPLICATION_SKIPPED}`
|
|
443
|
-
);
|
|
444
|
-
logDebug(
|
|
445
|
-
"SharedModules",
|
|
446
|
-
`Available bundles: ${Object.keys(self.__remote_webpack_require__ ?? {})}`
|
|
447
|
-
);
|
|
448
|
-
}
|
|
449
|
-
}
|
|
450
|
-
var DEDUPLICATION_SKIPPED;
|
|
451
|
-
var init_apply_shared_modules = __esm({
|
|
452
|
-
"src/config/webpack/apply-shared-modules.ts"() {
|
|
453
|
-
"use strict";
|
|
454
|
-
init_remote_scope();
|
|
455
|
-
init_logger();
|
|
456
|
-
DEDUPLICATION_SKIPPED = "shared module deduplication skipped. The remote may load its own copy of shared dependencies.";
|
|
457
|
-
}
|
|
458
|
-
});
|
|
459
|
-
|
|
460
|
-
// src/config/webpack/next-client-pages-loader.ts
|
|
461
|
-
function nextClientPagesLoader(bundle, route, styleContainer = document.head) {
|
|
462
|
-
const self = globalThis;
|
|
463
|
-
const nextCssOriginal = document.querySelector(
|
|
464
|
-
`[id="__next_css__DO_NOT_USE__"]:not([data-bundle="${bundle}"][data-route="${route}"])`
|
|
465
|
-
);
|
|
466
|
-
if (nextCssOriginal) {
|
|
467
|
-
nextCssOriginal.parentNode?.removeChild(nextCssOriginal);
|
|
468
|
-
}
|
|
469
|
-
const nextCss = document.createElement("noscript");
|
|
470
|
-
nextCss.id = "__next_css__DO_NOT_USE__";
|
|
471
|
-
nextCss.setAttribute("data-bundle", bundle);
|
|
472
|
-
nextCss.setAttribute("data-route", route);
|
|
473
|
-
const nextCssEnd = document.createElement("noscript");
|
|
474
|
-
nextCssEnd.id = "__next_css__DO_NOT_USE_END__";
|
|
475
|
-
nextCssEnd.setAttribute("data-bundle", bundle);
|
|
476
|
-
nextCssEnd.setAttribute("data-route", route);
|
|
477
|
-
document.head.appendChild(nextCssEnd);
|
|
478
|
-
document.head.appendChild(nextCss);
|
|
479
|
-
const componentLoaderChunk = Object.keys(self.__remote_webpack_require__?.[bundle]?.m ?? {}).find(
|
|
480
|
-
(key) => key.includes("/webpack/loaders/next-client-pages-loader.js") && key.includes(`page=${encodeURIComponent(route)}!`)
|
|
481
|
-
) ?? Object.keys(self.__remote_webpack_require__?.[bundle]?.m ?? {}).find(
|
|
482
|
-
(key) => key.includes("/next/dist/client/page-loader.js")
|
|
483
|
-
) ?? self.__remote_webpack_module_map__?.[bundle]?.[Object.keys(self.__remote_webpack_module_map__[bundle] ?? {}).find(
|
|
484
|
-
(key) => key.includes("/webpack/loaders/next-client-pages-loader.js") && key.includes(`page=${encodeURIComponent(route)}!`)
|
|
485
|
-
) ?? Object.keys(self.__remote_webpack_module_map__[bundle] ?? {}).find(
|
|
486
|
-
(key) => key.includes("/next/dist/client/page-loader.js")
|
|
487
|
-
) ?? ""] ?? -1;
|
|
488
|
-
const appLoaderChunk = Object.keys(self.__remote_webpack_require__?.[bundle]?.m ?? {}).find(
|
|
489
|
-
(key) => key.includes("/webpack/loaders/next-client-pages-loader.js") && key.includes(`page=%2F_app`)
|
|
490
|
-
) ?? Object.keys(self.__remote_webpack_require__?.[bundle]?.m ?? {}).find(
|
|
491
|
-
(key) => key.includes("/next/dist/client/page-loader.js")
|
|
492
|
-
) ?? self.__remote_webpack_module_map__?.[bundle]?.[Object.keys(self.__remote_webpack_module_map__[bundle] ?? {}).find(
|
|
493
|
-
(key) => key.includes("/webpack/loaders/next-client-pages-loader.js") && key.includes(`page=%2F_app`)
|
|
494
|
-
) ?? Object.keys(self.__remote_webpack_module_map__[bundle] ?? {}).find(
|
|
495
|
-
(key) => key.includes("/next/dist/client/page-loader.js")
|
|
496
|
-
) ?? ""] ?? -1;
|
|
497
|
-
if (!(componentLoaderChunk && appLoaderChunk)) {
|
|
498
|
-
throw new RemoteComponentsError(
|
|
499
|
-
`Next.js client pages loader not found in bundle "${bundle}".`
|
|
500
|
-
);
|
|
501
|
-
}
|
|
502
|
-
const __NEXT_P_ORIGINAL = self.__NEXT_P;
|
|
503
|
-
const selfOriginal = self;
|
|
504
|
-
delete selfOriginal.__NEXT_P;
|
|
505
|
-
self.__remote_webpack_require__?.[bundle]?.(
|
|
506
|
-
self.__remote_webpack_require__[bundle].type !== "turbopack" ? componentLoaderChunk : `[${bundle}] ${componentLoaderChunk}`
|
|
507
|
-
);
|
|
508
|
-
if (typeof appLoaderChunk === "string" || typeof appLoaderChunk === "number" && appLoaderChunk !== -1) {
|
|
509
|
-
self.__remote_webpack_require__?.[bundle]?.(
|
|
510
|
-
self.__remote_webpack_require__[bundle].type !== "turbopack" ? appLoaderChunk : `[${bundle}] ${appLoaderChunk}`
|
|
511
|
-
);
|
|
512
|
-
}
|
|
513
|
-
if (self.__NEXT_P) {
|
|
514
|
-
const [, componentLoader] = self.__NEXT_P[0] ?? [
|
|
515
|
-
void 0,
|
|
516
|
-
() => ({ default: null })
|
|
517
|
-
];
|
|
518
|
-
const [, appLoader] = self.__NEXT_P[2] ?? [
|
|
519
|
-
void 0,
|
|
520
|
-
() => ({
|
|
521
|
-
default: null
|
|
522
|
-
})
|
|
523
|
-
];
|
|
524
|
-
const { default: Component } = componentLoader();
|
|
525
|
-
const { default: App } = appLoader();
|
|
526
|
-
const cssCache = getNamespace().cssCache;
|
|
527
|
-
if (!cssCache[bundle]) {
|
|
528
|
-
const cssRE = /\.s?css$/;
|
|
529
|
-
Object.keys(self.__remote_webpack_require__?.[bundle]?.m ?? {}).filter((id) => cssRE.test(id)).forEach((id) => {
|
|
530
|
-
self.__remote_webpack_require__?.[bundle]?.(id);
|
|
531
|
-
});
|
|
532
|
-
Object.keys(self.__remote_webpack_module_map__?.[bundle] ?? {}).filter((path) => cssRE.test(path)).forEach((path) => {
|
|
533
|
-
const id = self.__remote_webpack_module_map__?.[bundle]?.[path];
|
|
534
|
-
if (id) {
|
|
535
|
-
self.__remote_webpack_require__?.[bundle]?.(id);
|
|
536
|
-
}
|
|
537
|
-
});
|
|
538
|
-
const elements = [];
|
|
539
|
-
let node = nextCss.previousSibling;
|
|
540
|
-
while (node && node !== nextCssEnd) {
|
|
541
|
-
elements.push(node);
|
|
542
|
-
node.remove();
|
|
543
|
-
node = nextCss.previousSibling;
|
|
544
|
-
}
|
|
545
|
-
cssCache[bundle] = elements;
|
|
546
|
-
}
|
|
547
|
-
if (styleContainer) {
|
|
548
|
-
const elements = cssCache[bundle];
|
|
549
|
-
elements.forEach((el) => {
|
|
550
|
-
styleContainer.appendChild(el.cloneNode(true));
|
|
551
|
-
});
|
|
552
|
-
} else {
|
|
553
|
-
const elements = cssCache[bundle];
|
|
554
|
-
elements.forEach((el) => {
|
|
555
|
-
document.head.appendChild(el);
|
|
556
|
-
});
|
|
557
|
-
}
|
|
558
|
-
delete self.__NEXT_P;
|
|
559
|
-
self.__NEXT_P = __NEXT_P_ORIGINAL;
|
|
560
|
-
if (nextCssOriginal) {
|
|
561
|
-
nextCssOriginal.parentNode?.appendChild(nextCssOriginal);
|
|
562
|
-
}
|
|
563
|
-
nextCss.remove();
|
|
564
|
-
nextCssEnd.remove();
|
|
565
|
-
return { Component, App };
|
|
566
|
-
}
|
|
567
|
-
return { Component: null, App: null };
|
|
568
|
-
}
|
|
569
|
-
var init_next_client_pages_loader = __esm({
|
|
570
|
-
"src/config/webpack/next-client-pages-loader.ts"() {
|
|
571
|
-
"use strict";
|
|
572
|
-
init_namespace();
|
|
573
|
-
init_error();
|
|
574
|
-
}
|
|
575
|
-
});
|
|
576
|
-
|
|
577
|
-
// src/host/shared/remote-image-loader.ts
|
|
578
|
-
function createRemoteImageLoader(bundle, resolveClientUrl) {
|
|
579
|
-
const loader = Object.assign(
|
|
580
|
-
({
|
|
581
|
-
config,
|
|
582
|
-
src,
|
|
583
|
-
width,
|
|
584
|
-
quality
|
|
585
|
-
}) => {
|
|
586
|
-
const q = quality ?? 75;
|
|
587
|
-
const remoteOrigin = getScope(bundle)?.url.origin ?? "";
|
|
588
|
-
const isCrossOrigin = remoteOrigin && remoteOrigin !== location.origin;
|
|
589
|
-
const basePath = isCrossOrigin ? `${remoteOrigin}${config.path ?? "/_next/image"}` : config.path ?? `${remoteOrigin}/_next/image`;
|
|
590
|
-
const url = `${basePath}?url=${encodeURIComponent(src)}&w=${width}&q=${q}`;
|
|
591
|
-
return resolveClientUrl?.(url) ?? url;
|
|
592
|
-
},
|
|
593
|
-
// Signals to getImgProps that this is a default loader (not a user-defined
|
|
594
|
-
// one), enabling srcSet generation with device/image sizes from the config.
|
|
595
|
-
{ __next_img_default: true }
|
|
596
|
-
);
|
|
597
|
-
return loader;
|
|
598
|
-
}
|
|
599
|
-
var init_remote_image_loader = __esm({
|
|
600
|
-
"src/host/shared/remote-image-loader.ts"() {
|
|
601
|
-
"use strict";
|
|
602
|
-
init_remote_scope();
|
|
603
|
-
}
|
|
604
|
-
});
|
|
605
|
-
|
|
606
|
-
// src/host/shared/polyfill.tsx
|
|
607
|
-
function sharedPolyfills(shared, resolveClientUrl) {
|
|
608
|
-
const hostShared = getNamespace().hostSharedModules;
|
|
609
|
-
const polyfill = {
|
|
610
|
-
"next/dist/client/components/navigation": hostShared["next/navigation"] ?? shared?.["next/navigation"] ?? (() => Promise.resolve({
|
|
611
|
-
useRouter() {
|
|
612
|
-
return {
|
|
613
|
-
push: (routerUrl) => {
|
|
614
|
-
history.pushState({}, "", routerUrl);
|
|
615
|
-
},
|
|
616
|
-
replace: (routerUrl) => {
|
|
617
|
-
history.replaceState({}, "", routerUrl);
|
|
618
|
-
},
|
|
619
|
-
back: () => {
|
|
620
|
-
history.back();
|
|
621
|
-
}
|
|
622
|
-
};
|
|
623
|
-
},
|
|
624
|
-
usePathname() {
|
|
625
|
-
return location.pathname;
|
|
626
|
-
},
|
|
627
|
-
useParams() {
|
|
628
|
-
return {};
|
|
629
|
-
},
|
|
630
|
-
useSearchParams() {
|
|
631
|
-
return new URLSearchParams(location.search);
|
|
632
|
-
},
|
|
633
|
-
useSelectedLayoutSegment() {
|
|
634
|
-
return null;
|
|
635
|
-
},
|
|
636
|
-
useSelectedLayoutSegments() {
|
|
637
|
-
return [];
|
|
638
|
-
},
|
|
639
|
-
__esModule: true
|
|
640
|
-
})),
|
|
641
|
-
"next/dist/client/app-dir/link": hostShared["next/link"] ?? shared?.["next/link"] ?? (() => Promise.resolve({
|
|
642
|
-
default: ({
|
|
643
|
-
scroll: _,
|
|
644
|
-
replace,
|
|
645
|
-
prefetch,
|
|
646
|
-
onNavigate,
|
|
647
|
-
children,
|
|
648
|
-
...props
|
|
649
|
-
}) => {
|
|
650
|
-
if (prefetch) {
|
|
651
|
-
logWarn(
|
|
652
|
-
"Polyfill",
|
|
653
|
-
"Next.js Link prefetch is not supported in remote components"
|
|
654
|
-
);
|
|
655
|
-
}
|
|
656
|
-
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
657
|
-
"a",
|
|
658
|
-
{
|
|
659
|
-
...props,
|
|
660
|
-
href: props.href,
|
|
661
|
-
onClick: (e) => {
|
|
662
|
-
e.preventDefault();
|
|
663
|
-
let preventDefaulted = false;
|
|
664
|
-
e.preventDefault = () => {
|
|
665
|
-
preventDefaulted = true;
|
|
666
|
-
e.defaultPrevented = true;
|
|
667
|
-
};
|
|
668
|
-
if (typeof props.onClick === "function") {
|
|
669
|
-
props.onClick(e);
|
|
670
|
-
}
|
|
671
|
-
onNavigate?.(e);
|
|
672
|
-
if (preventDefaulted) {
|
|
673
|
-
return;
|
|
674
|
-
}
|
|
675
|
-
if (replace) {
|
|
676
|
-
history.replaceState({}, "", props.href);
|
|
677
|
-
} else {
|
|
678
|
-
history.pushState({}, "", props.href);
|
|
679
|
-
}
|
|
680
|
-
},
|
|
681
|
-
suppressHydrationWarning: true,
|
|
682
|
-
children: children ?? null
|
|
683
|
-
}
|
|
684
|
-
);
|
|
685
|
-
},
|
|
686
|
-
useLinkStatus() {
|
|
687
|
-
return { pending: false };
|
|
688
|
-
},
|
|
689
|
-
__esModule: true
|
|
690
|
-
})),
|
|
691
|
-
"next/dist/client/app-dir/form": hostShared["next/form"] ?? shared?.["next/form"] ?? (() => Promise.resolve({
|
|
692
|
-
default: () => {
|
|
693
|
-
throw new Error("Next.js <Form> component not implemented");
|
|
694
|
-
},
|
|
695
|
-
__esModule: true
|
|
696
|
-
})),
|
|
697
|
-
// Instead of replacing next/image entirely, we let the real Next.js Image
|
|
698
|
-
// component load from the remote bundle and only replace its default loader.
|
|
699
|
-
// This gives us full next/image fidelity (fill, priority, srcSet, blur
|
|
700
|
-
// placeholders, error handling) while routing image optimization through the
|
|
701
|
-
// remote app's /_next/image endpoint.
|
|
702
|
-
"next/dist/shared/lib/image-loader": hostShared["next/dist/shared/lib/image-loader"] ?? shared?.["next/dist/shared/lib/image-loader"] ?? ((bundle) => Promise.resolve({
|
|
703
|
-
default: createRemoteImageLoader(bundle, resolveClientUrl),
|
|
704
|
-
__esModule: true
|
|
705
|
-
})),
|
|
706
|
-
"next/dist/client/script": hostShared["next/script"] ?? shared?.["next/script"] ?? (() => Promise.resolve({
|
|
707
|
-
// TODO: implement <Script> component for non-Next.js host applications
|
|
708
|
-
// do not throw an error for now
|
|
709
|
-
default: () => null,
|
|
710
|
-
__esModule: true
|
|
711
|
-
})),
|
|
712
|
-
"next/router": hostShared["next/router"] ?? shared?.["next/router"] ?? (() => (
|
|
713
|
-
// TODO: incomplete implementation
|
|
714
|
-
Promise.resolve({
|
|
715
|
-
useRouter() {
|
|
716
|
-
return {
|
|
717
|
-
push: (routerUrl) => {
|
|
718
|
-
history.pushState({}, "", routerUrl);
|
|
719
|
-
},
|
|
720
|
-
replace: (routerUrl) => {
|
|
721
|
-
history.replaceState({}, "", routerUrl);
|
|
722
|
-
},
|
|
723
|
-
back: () => {
|
|
724
|
-
history.back();
|
|
725
|
-
}
|
|
726
|
-
};
|
|
727
|
-
},
|
|
728
|
-
__esModule: true
|
|
729
|
-
})
|
|
730
|
-
)),
|
|
731
|
-
"next/dist/build/polyfills/process": () => Promise.resolve({
|
|
732
|
-
default: {
|
|
733
|
-
env: {
|
|
734
|
-
NODE_ENV: "production"
|
|
735
|
-
}
|
|
736
|
-
},
|
|
737
|
-
__esModule: true
|
|
738
|
-
})
|
|
739
|
-
};
|
|
740
|
-
polyfill["next/navigation"] = polyfill["next/dist/client/components/navigation"];
|
|
741
|
-
polyfill["next/link"] = polyfill["next/dist/client/app-dir/link"];
|
|
742
|
-
polyfill["next/form"] = polyfill["next/dist/client/app-dir/form"];
|
|
743
|
-
polyfill["next/dist/esm/shared/lib/image-loader"] = polyfill["next/dist/shared/lib/image-loader"];
|
|
744
|
-
polyfill["next/script"] = polyfill["next/dist/client/script"];
|
|
745
|
-
return polyfill;
|
|
746
|
-
}
|
|
747
|
-
var import_jsx_runtime;
|
|
748
|
-
var init_polyfill = __esm({
|
|
749
|
-
"src/host/shared/polyfill.tsx"() {
|
|
750
|
-
"use strict";
|
|
751
|
-
init_remote_image_loader();
|
|
752
|
-
init_namespace();
|
|
753
|
-
init_logger();
|
|
754
|
-
import_jsx_runtime = require("react/jsx-runtime");
|
|
755
|
-
}
|
|
756
|
-
});
|
|
757
|
-
|
|
758
|
-
// src/host/shared/shared-module-resolver.ts
|
|
759
|
-
function buildCoreShared(userShared) {
|
|
760
|
-
return {
|
|
761
|
-
react: async () => (await import("react")).default,
|
|
762
|
-
"react-dom": async () => (await import("react-dom")).default,
|
|
763
|
-
"react/jsx-dev-runtime": async () => (await import("react/jsx-dev-runtime")).default,
|
|
764
|
-
"react/jsx-runtime": async () => (await import("react/jsx-runtime")).default,
|
|
765
|
-
"react-dom/client": async () => (await import("react-dom/client")).default,
|
|
766
|
-
...userShared
|
|
767
|
-
};
|
|
768
|
-
}
|
|
769
|
-
function buildHostShared(userShared, resolveClientUrl, options) {
|
|
770
|
-
const self = globalThis;
|
|
771
|
-
const result = {
|
|
772
|
-
...sharedPolyfills(userShared, resolveClientUrl),
|
|
773
|
-
...self.__remote_component_host_shared_modules__,
|
|
774
|
-
...userShared
|
|
775
|
-
};
|
|
776
|
-
if (options?.includeRemoteComponentShared) {
|
|
777
|
-
Object.assign(result, self.__remote_component_shared__);
|
|
778
|
-
}
|
|
779
|
-
return result;
|
|
780
|
-
}
|
|
781
|
-
async function buildWebpackResolve(hostShared, remoteShared, bundle, reactModules, callerTag = "SharedModuleResolver") {
|
|
782
|
-
const resolve = {
|
|
783
|
-
...reactModules,
|
|
784
|
-
...Object.entries(remoteShared).reduce(
|
|
785
|
-
(acc, [key, value]) => {
|
|
786
|
-
if (typeof hostShared[value] !== "undefined") {
|
|
787
|
-
acc[key.replace(/^\(ssr\)\/(?<relative>\.\/)?/, "")] = hostShared[value];
|
|
788
|
-
} else {
|
|
789
|
-
logDebug(
|
|
790
|
-
callerTag,
|
|
791
|
-
`Remote requests "${value}" but host doesn't provide it`
|
|
792
|
-
);
|
|
793
|
-
}
|
|
794
|
-
return acc;
|
|
795
|
-
},
|
|
796
|
-
{}
|
|
797
|
-
)
|
|
798
|
-
};
|
|
799
|
-
await Promise.all(
|
|
800
|
-
Object.entries(resolve).map(async ([key, value]) => {
|
|
801
|
-
if (typeof value === "function") {
|
|
802
|
-
resolve[key] = await value(bundle);
|
|
803
|
-
}
|
|
804
|
-
return Promise.resolve(value);
|
|
805
|
-
})
|
|
806
|
-
);
|
|
807
|
-
return resolve;
|
|
808
|
-
}
|
|
809
|
-
var CORE_REACT_PATH_MAP, VENDOR_SHARED;
|
|
810
|
-
var init_shared_module_resolver = __esm({
|
|
811
|
-
"src/host/shared/shared-module-resolver.ts"() {
|
|
812
|
-
"use strict";
|
|
813
|
-
init_polyfill();
|
|
814
|
-
init_logger();
|
|
815
|
-
CORE_REACT_PATH_MAP = {
|
|
816
|
-
react: "/react/index.js",
|
|
817
|
-
"react/jsx-dev-runtime": "/react/jsx-dev-runtime.js",
|
|
818
|
-
"react/jsx-runtime": "/react/jsx-runtime.js",
|
|
819
|
-
"react-dom": "/react-dom/index.js",
|
|
820
|
-
"react-dom/client": "/react-dom/client.js"
|
|
821
|
-
};
|
|
822
|
-
VENDOR_SHARED = Object.fromEntries(
|
|
823
|
-
Object.entries(CORE_REACT_PATH_MAP).filter(([key]) => key !== "react-dom/client").map(([key, path]) => [key, `'${path}'`])
|
|
824
|
-
);
|
|
825
|
-
}
|
|
826
|
-
});
|
|
827
|
-
|
|
828
|
-
// src/runtime/loaders/script-loader.ts
|
|
829
|
-
async function loadScripts(scripts, resolveClientUrl) {
|
|
830
|
-
await Promise.all(
|
|
831
|
-
scripts.map((script) => {
|
|
832
|
-
return new Promise((resolve, reject) => {
|
|
833
|
-
const newSrc = new URL(
|
|
834
|
-
// remove the remote component bundle name identifier from the script src
|
|
835
|
-
script.src.replace(NEXT_BUNDLE_PATH_RE, "/_next/"),
|
|
836
|
-
location.origin
|
|
837
|
-
).href;
|
|
838
|
-
const resolvedSrc = resolveClientUrl?.(newSrc) ?? newSrc;
|
|
839
|
-
const alreadyLoaded = Array.from(
|
|
840
|
-
document.querySelectorAll("script[src]")
|
|
841
|
-
).some((s) => s.src === resolvedSrc);
|
|
842
|
-
if (alreadyLoaded) {
|
|
843
|
-
resolve();
|
|
844
|
-
return;
|
|
845
|
-
}
|
|
846
|
-
const newScript = document.createElement("script");
|
|
847
|
-
newScript.onload = () => resolve();
|
|
848
|
-
newScript.onerror = () => {
|
|
849
|
-
const isProxied = isProxiedUrl(resolvedSrc);
|
|
850
|
-
if (isProxied) {
|
|
851
|
-
reject(failedProxiedAssetError("script", newSrc, resolvedSrc));
|
|
852
|
-
} else {
|
|
853
|
-
warnCrossOriginFetchError("ScriptLoader", newSrc);
|
|
854
|
-
reject(
|
|
855
|
-
new RemoteComponentsError(
|
|
856
|
-
`Failed to load <script src="${newSrc}"> for Remote Component. Check the URL is correct.`
|
|
857
|
-
)
|
|
858
|
-
);
|
|
859
|
-
}
|
|
860
|
-
};
|
|
861
|
-
newScript.src = resolvedSrc;
|
|
862
|
-
newScript.async = true;
|
|
863
|
-
document.head.appendChild(newScript);
|
|
864
|
-
});
|
|
865
|
-
})
|
|
866
|
-
);
|
|
867
|
-
}
|
|
868
|
-
var init_script_loader = __esm({
|
|
869
|
-
"src/runtime/loaders/script-loader.ts"() {
|
|
870
|
-
"use strict";
|
|
871
|
-
init_patterns();
|
|
872
|
-
init_protected_rc_fallback();
|
|
873
|
-
init_error();
|
|
874
|
-
init_logger();
|
|
875
|
-
}
|
|
876
|
-
});
|
|
877
|
-
|
|
878
|
-
// src/host/html/runtime/webpack.ts
|
|
879
|
-
var webpack_exports = {};
|
|
880
|
-
__export(webpack_exports, {
|
|
881
|
-
webpackRuntime: () => webpackRuntime
|
|
882
|
-
});
|
|
883
|
-
async function webpackRuntime(bundle, shared, remoteShared, resolveClientUrl) {
|
|
884
|
-
const self = globalThis;
|
|
885
|
-
if (!self.__DISABLE_WEBPACK_EXEC__) {
|
|
886
|
-
self.__DISABLE_WEBPACK_EXEC__ = {};
|
|
887
|
-
}
|
|
888
|
-
self.__DISABLE_WEBPACK_EXEC__[bundle] = true;
|
|
889
|
-
if (typeof self.__webpack_require__ !== "function" && self.__webpack_require_type__ !== "turbopack") {
|
|
890
|
-
self.__webpack_require__ = (remoteId) => {
|
|
891
|
-
const re = /\[(?<bundle>[^\]]+)\] (?<id>.*)/;
|
|
892
|
-
const match = re.exec(remoteId);
|
|
893
|
-
const remoteBundle = match?.groups?.bundle;
|
|
894
|
-
const id = match?.groups?.id;
|
|
895
|
-
if (!(id && remoteBundle)) {
|
|
896
|
-
throw new RemoteComponentsError(
|
|
897
|
-
`Remote Component module "${remoteId}" not found. Did you forget to wrap the Next.js config with \`withRemoteComponentsConfig\` on both host and remote?`
|
|
898
|
-
);
|
|
899
|
-
}
|
|
900
|
-
if (typeof self.__remote_webpack_require__?.[remoteBundle] !== "function") {
|
|
901
|
-
throw new RemoteComponentsError(
|
|
902
|
-
`Remote Components are not available in "${remoteBundle}". Did you forget to wrap the Next.js config with \`withRemoteComponentsConfig\` on both host and remote?`
|
|
903
|
-
);
|
|
904
|
-
}
|
|
905
|
-
return self.__remote_webpack_require__[remoteBundle](id);
|
|
906
|
-
};
|
|
907
|
-
self.__webpack_chunk_load__ = () => {
|
|
908
|
-
return Promise.resolve([]);
|
|
909
|
-
};
|
|
910
|
-
}
|
|
911
|
-
const {
|
|
912
|
-
default: { createFromReadableStream }
|
|
913
|
-
} = await import("react-server-dom-webpack/client.browser");
|
|
914
|
-
async function preloadScripts(scripts, url, remoteBundle, _) {
|
|
915
|
-
const scriptSrcs = scripts.flatMap((script) => {
|
|
916
|
-
const scriptSrc = script.getAttribute("src") || script.getAttribute("data-src");
|
|
917
|
-
script.parentElement?.removeChild(script);
|
|
918
|
-
if (!scriptSrc)
|
|
919
|
-
return [];
|
|
920
|
-
return [
|
|
921
|
-
{
|
|
922
|
-
src: new URL(scriptSrc.replace(NEXT_BUNDLE_PATH_RE, "/_next/"), url).href
|
|
923
|
-
}
|
|
924
|
-
];
|
|
925
|
-
});
|
|
926
|
-
await loadScripts(scriptSrcs, resolveClientUrl);
|
|
927
|
-
const hostShared = buildHostShared(shared, resolveClientUrl);
|
|
928
|
-
const resolve = await buildWebpackResolve(
|
|
929
|
-
hostShared,
|
|
930
|
-
remoteShared ?? {},
|
|
931
|
-
remoteBundle,
|
|
932
|
-
{
|
|
933
|
-
"/react/index.js": (await import("react")).default,
|
|
934
|
-
"/react/jsx-dev-runtime.js": (await import("react/jsx-dev-runtime")).default,
|
|
935
|
-
"/react/jsx-runtime.js": (await import("react/jsx-runtime")).default,
|
|
936
|
-
"/react-dom/index.js": (await import("react-dom")).default,
|
|
937
|
-
"/react-dom/client.js": (await import("react-dom/client")).default
|
|
938
|
-
},
|
|
939
|
-
"WebpackRuntime"
|
|
940
|
-
);
|
|
941
|
-
applySharedModules(remoteBundle, resolve);
|
|
942
|
-
}
|
|
943
|
-
return {
|
|
944
|
-
self,
|
|
945
|
-
createFromReadableStream,
|
|
946
|
-
applySharedModules,
|
|
947
|
-
nextClientPagesLoader,
|
|
948
|
-
preloadScripts
|
|
949
|
-
};
|
|
950
|
-
}
|
|
951
|
-
var init_webpack = __esm({
|
|
952
|
-
"src/host/html/runtime/webpack.ts"() {
|
|
953
|
-
"use strict";
|
|
954
|
-
init_apply_shared_modules();
|
|
955
|
-
init_next_client_pages_loader();
|
|
956
|
-
init_shared_module_resolver();
|
|
957
|
-
init_script_loader();
|
|
958
|
-
init_patterns();
|
|
959
|
-
init_error();
|
|
960
|
-
}
|
|
961
|
-
});
|
|
962
|
-
|
|
963
|
-
// src/runtime/turbopack/patterns.ts
|
|
964
|
-
function stripQuotes(value) {
|
|
965
|
-
if (value.startsWith('"') && value.endsWith('"')) {
|
|
966
|
-
return value.slice(1, -1);
|
|
967
|
-
}
|
|
968
|
-
return value;
|
|
969
|
-
}
|
|
970
|
-
function extractGroup(re, input, group) {
|
|
971
|
-
const raw = re.exec(input)?.groups?.[group];
|
|
972
|
-
return raw ? stripQuotes(raw) : void 0;
|
|
973
|
-
}
|
|
974
|
-
var MODULE_ID_PATTERN, REMOTE_SHARED_MARKER_RE, REMOTE_SHARED_ASSIGNMENT_RE, ASYNC_MODULE_LOADER_RE, ASYNC_MODULE_CALLBACK_RE, TURBOPACK_GLOBAL_RE;
|
|
975
|
-
var init_patterns2 = __esm({
|
|
976
|
-
"src/runtime/turbopack/patterns.ts"() {
|
|
977
|
-
"use strict";
|
|
978
|
-
MODULE_ID_PATTERN = '"[^"]+"|[0-9]+';
|
|
979
|
-
REMOTE_SHARED_MARKER_RE = /(?:self|[a-z])\.TURBOPACK_REMOTE_SHARED/;
|
|
980
|
-
REMOTE_SHARED_ASSIGNMENT_RE = new RegExp(
|
|
981
|
-
`\\.TURBOPACK_REMOTE_SHARED\\s*=\\s*await (?:__turbopack_context__|[a-z])\\.A\\((?<sharedModuleId>${MODULE_ID_PATTERN})\\)`
|
|
982
|
-
);
|
|
983
|
-
ASYNC_MODULE_LOADER_RE = new RegExp(
|
|
984
|
-
`(?:__turbopack_context__|e)\\.A\\((?<asyncSharedModuleId>${MODULE_ID_PATTERN})\\)`
|
|
985
|
-
);
|
|
986
|
-
ASYNC_MODULE_CALLBACK_RE = new RegExp(
|
|
987
|
-
`(?:parentImport|[a-z])\\((?<sharedModuleId>${MODULE_ID_PATTERN})\\)`
|
|
988
|
-
);
|
|
989
|
-
TURBOPACK_GLOBAL_RE = /(?:globalThis|self)\s*(?:\.TURBOPACK|\[\s*["']TURBOPACK["']\s*\])/;
|
|
990
|
-
}
|
|
991
|
-
});
|
|
992
|
-
|
|
993
|
-
// src/runtime/turbopack/chunk-loader.ts
|
|
994
|
-
function loadChunkWithScope(scope, chunkId) {
|
|
995
|
-
logDebug(
|
|
996
|
-
"ChunkLoader",
|
|
997
|
-
`loadChunkWithScope: "${chunkId}" (scope: "${scope.scopedName}")`
|
|
998
|
-
);
|
|
999
|
-
const self = globalThis;
|
|
1000
|
-
const ns = getNamespace();
|
|
1001
|
-
const { bundle, path, prefix } = parseRemoteId(chunkId);
|
|
1002
|
-
const remoteRuntime = self.__remote_webpack_require__?.[bundle ?? "default"] ? self.__remote_webpack_require__[bundle ?? "default"]?.type || "webpack" : scope.runtime;
|
|
1003
|
-
if (remoteRuntime === RUNTIME_WEBPACK) {
|
|
1004
|
-
return Promise.resolve(void 0);
|
|
1005
|
-
}
|
|
1006
|
-
const rawPath = path ? collapseDoubleSlashes(`${prefix}${path}`) : "/";
|
|
1007
|
-
const url = new URL(rawPath, scope.url).href;
|
|
1008
|
-
if (url.endsWith(".css")) {
|
|
1009
|
-
return;
|
|
1010
|
-
}
|
|
1011
|
-
if (ns.chunkCache[url]) {
|
|
1012
|
-
logDebug("ChunkLoader", `Cache hit for "${chunkId}" (url="${url}")`);
|
|
1013
|
-
return ns.chunkCache[url];
|
|
1014
|
-
}
|
|
1015
|
-
const resolvedUrl = scope.resolveClientUrl?.(url) ?? url;
|
|
1016
|
-
if (resolvedUrl !== url) {
|
|
1017
|
-
logDebug("ChunkLoader", `Proxied chunk URL: "${url}" \u2192 "${resolvedUrl}"`);
|
|
1018
|
-
}
|
|
1019
|
-
ns.chunkCache[url] = new Promise((resolve, reject) => {
|
|
1020
|
-
fetch(resolvedUrl).then((res) => res.text()).then((code) => {
|
|
1021
|
-
const hasTurbopack = TURBOPACK_GLOBAL_RE.test(code);
|
|
1022
|
-
if (hasTurbopack) {
|
|
1023
|
-
return handleTurbopackChunk(code, scope, url);
|
|
1024
|
-
}
|
|
1025
|
-
}).then(resolve).catch((error) => {
|
|
1026
|
-
const isProxied = isProxiedUrl(resolvedUrl);
|
|
1027
|
-
if (isProxied) {
|
|
1028
|
-
reject(failedProxiedAssetError("chunk", url, resolvedUrl));
|
|
1029
|
-
} else {
|
|
1030
|
-
warnCrossOriginFetchError("ChunkLoader", url);
|
|
1031
|
-
reject(error);
|
|
1032
|
-
}
|
|
1033
|
-
});
|
|
1034
|
-
});
|
|
1035
|
-
return ns.chunkCache[url];
|
|
1036
|
-
}
|
|
1037
|
-
function createChunkDispatcher() {
|
|
1038
|
-
return function __chunk_dispatcher__(chunkId, scriptBundle) {
|
|
1039
|
-
logDebug("ChunkDispatcher", `Dispatching chunk: "${chunkId}"`);
|
|
1040
|
-
const { bundle } = parseRemoteId(chunkId);
|
|
1041
|
-
const bundleName = bundle || scriptBundle || "default";
|
|
1042
|
-
const scope = getScope(bundleName);
|
|
1043
|
-
logDebug(
|
|
1044
|
-
"ChunkDispatcher",
|
|
1045
|
-
`Scope resolution: bundle="${bundleName}", scope=${scope?.scopedName ?? "null"}`
|
|
1046
|
-
);
|
|
1047
|
-
if (!scope) {
|
|
1048
|
-
logWarn("ChunkDispatcher", `No scope found for bundle "${bundleName}"`);
|
|
1049
|
-
return Promise.resolve(void 0);
|
|
1050
|
-
}
|
|
1051
|
-
return loadChunkWithScope(scope, chunkId);
|
|
1052
|
-
};
|
|
1053
|
-
}
|
|
1054
|
-
async function handleTurbopackChunk(code, scope, url) {
|
|
1055
|
-
if (/importScripts\(\.\.\.self.TURBOPACK_NEXT_CHUNK_URLS/.test(code)) {
|
|
1056
|
-
const preloadLinks = document.querySelectorAll(
|
|
1057
|
-
`link[rel="preload"][href="${new URL(url).pathname}"]`
|
|
1058
|
-
);
|
|
1059
|
-
preloadLinks.forEach((preloadLink) => preloadLink.remove());
|
|
1060
|
-
return;
|
|
1061
|
-
}
|
|
1062
|
-
const self = globalThis;
|
|
1063
|
-
const { globalKey } = scope;
|
|
1064
|
-
const transformedCode = code.replace(
|
|
1065
|
-
/globalThis\[\s*["']TURBOPACK["']\s*\]/g,
|
|
1066
|
-
`globalThis["TURBOPACK_${globalKey}"]`
|
|
1067
|
-
).replace(
|
|
1068
|
-
/self\[\s*["']TURBOPACK["']\s*\]/g,
|
|
1069
|
-
`self["TURBOPACK_${globalKey}"]`
|
|
1070
|
-
).replace(/globalThis\.TURBOPACK/g, `globalThis.TURBOPACK_${globalKey}`).replace(/self\.TURBOPACK(?!_)/g, `self.TURBOPACK_${globalKey}`).replace(
|
|
1071
|
-
/TURBOPACK_WORKER_LOCATION/g,
|
|
1072
|
-
`TURBOPACK_WORKER_LOCATION_${globalKey}`
|
|
1073
|
-
).replace(
|
|
1074
|
-
/TURBOPACK_NEXT_CHUNK_URLS/g,
|
|
1075
|
-
`TURBOPACK_NEXT_CHUNK_URLS_${globalKey}`
|
|
1076
|
-
).replace(
|
|
1077
|
-
/TURBOPACK_CHUNK_UPDATE_LISTENERS/g,
|
|
1078
|
-
`TURBOPACK_CHUNK_UPDATE_LISTENERS_${globalKey}`
|
|
1079
|
-
).replace(/__next_require__/g, `__${globalKey}_next_require__`).replace(
|
|
1080
|
-
/\/\/# sourceMappingURL=(?<name>.+)(?<optional>\._)?\.js\.map/g,
|
|
1081
|
-
`//# sourceMappingURL=${new URL(".", new URL(url, scope.url)).href}$1$2.js.map`
|
|
1082
|
-
);
|
|
1083
|
-
if (!self[`TURBOPACK_${globalKey}`]) {
|
|
1084
|
-
const wrapPush = (target) => {
|
|
1085
|
-
const originalPush = target.push;
|
|
1086
|
-
if (typeof originalPush !== "function")
|
|
1087
|
-
return target;
|
|
1088
|
-
target.push = (...items) => {
|
|
1089
|
-
for (const item of items) {
|
|
1090
|
-
if (Array.isArray(item)) {
|
|
1091
|
-
for (const entry of item) {
|
|
1092
|
-
scope.turbopackModules.push(entry);
|
|
1093
|
-
}
|
|
1094
|
-
} else {
|
|
1095
|
-
scope.turbopackModules.push(item);
|
|
1096
|
-
}
|
|
1097
|
-
}
|
|
1098
|
-
return originalPush.apply(target, items);
|
|
1099
|
-
};
|
|
1100
|
-
return target;
|
|
1101
|
-
};
|
|
1102
|
-
const globalProp = `TURBOPACK_${globalKey}`;
|
|
1103
|
-
let currentValue = wrapPush([]);
|
|
1104
|
-
Object.defineProperty(self, globalProp, {
|
|
1105
|
-
get() {
|
|
1106
|
-
return currentValue;
|
|
1107
|
-
},
|
|
1108
|
-
set(newValue) {
|
|
1109
|
-
if (newValue && typeof newValue === "object") {
|
|
1110
|
-
wrapPush(newValue);
|
|
1111
|
-
}
|
|
1112
|
-
currentValue = newValue;
|
|
1113
|
-
},
|
|
1114
|
-
configurable: true,
|
|
1115
|
-
enumerable: true
|
|
1116
|
-
});
|
|
1117
|
-
}
|
|
1118
|
-
await new Promise((scriptResolve, scriptReject) => {
|
|
1119
|
-
const blob = new Blob([transformedCode], {
|
|
1120
|
-
type: "application/javascript; charset=UTF-8"
|
|
1121
|
-
});
|
|
1122
|
-
const scriptUrl = URL.createObjectURL(blob);
|
|
1123
|
-
const script = document.createElement("script");
|
|
1124
|
-
script.setAttribute("data-turbopack-src", url);
|
|
1125
|
-
script.src = scriptUrl;
|
|
1126
|
-
script.async = true;
|
|
1127
|
-
script.onload = () => {
|
|
1128
|
-
URL.revokeObjectURL(scriptUrl);
|
|
1129
|
-
scriptResolve(void 0);
|
|
1130
|
-
script.remove();
|
|
1131
|
-
};
|
|
1132
|
-
script.onerror = () => {
|
|
1133
|
-
URL.revokeObjectURL(scriptUrl);
|
|
1134
|
-
scriptReject(
|
|
1135
|
-
new RemoteComponentsError(
|
|
1136
|
-
`Failed to load <script src="${script.src}"> for Remote Component. Check the URL is correct.`
|
|
1137
|
-
)
|
|
1138
|
-
);
|
|
1139
|
-
script.remove();
|
|
1140
|
-
};
|
|
1141
|
-
document.head.appendChild(script);
|
|
1142
|
-
});
|
|
1143
|
-
const chunkLists = self[`TURBOPACK_${globalKey}_CHUNK_LISTS`];
|
|
1144
|
-
const loadChunkPromises = [];
|
|
1145
|
-
while (chunkLists?.length) {
|
|
1146
|
-
const { chunks } = chunkLists.shift() ?? { chunks: [] };
|
|
1147
|
-
if (chunks.length > 0) {
|
|
1148
|
-
for (const id of chunks) {
|
|
1149
|
-
const baseUrl = url.slice(0, url.indexOf("/_next"));
|
|
1150
|
-
const chunkLoadResult = loadChunkWithScope(
|
|
1151
|
-
scope,
|
|
1152
|
-
formatRemoteId(scope, `${baseUrl}/_next/${id}`)
|
|
1153
|
-
);
|
|
1154
|
-
if (chunkLoadResult) {
|
|
1155
|
-
loadChunkPromises.push(chunkLoadResult);
|
|
1156
|
-
}
|
|
1157
|
-
}
|
|
1158
|
-
}
|
|
1159
|
-
}
|
|
1160
|
-
if (loadChunkPromises.length > 0) {
|
|
1161
|
-
await Promise.all(loadChunkPromises);
|
|
1162
|
-
}
|
|
1163
|
-
}
|
|
1164
|
-
var init_chunk_loader = __esm({
|
|
1165
|
-
"src/runtime/turbopack/chunk-loader.ts"() {
|
|
1166
|
-
"use strict";
|
|
1167
|
-
init_constants2();
|
|
1168
|
-
init_namespace();
|
|
1169
|
-
init_patterns();
|
|
1170
|
-
init_protected_rc_fallback();
|
|
1171
|
-
init_error();
|
|
1172
|
-
init_logger();
|
|
1173
|
-
init_patterns2();
|
|
1174
|
-
init_remote_scope();
|
|
1175
|
-
}
|
|
1176
|
-
});
|
|
1177
|
-
|
|
1178
|
-
// src/runtime/turbopack/shared-modules.ts
|
|
1179
|
-
function getTurbopackModules(scope) {
|
|
1180
|
-
if (scope.turbopackModules.length > 0) {
|
|
1181
|
-
return scope.turbopackModules;
|
|
1182
|
-
}
|
|
1183
|
-
const self = globalThis;
|
|
1184
|
-
const raw = self[`TURBOPACK_${scope.globalKey}`];
|
|
1185
|
-
if (!raw)
|
|
1186
|
-
return void 0;
|
|
1187
|
-
if (Array.isArray(raw)) {
|
|
1188
|
-
return raw.flat();
|
|
1189
|
-
}
|
|
1190
|
-
return Object.entries(raw).flat();
|
|
1191
|
-
}
|
|
1192
|
-
async function initializeSharedModules(scope, hostShared = {}, remoteShared = {}) {
|
|
1193
|
-
const allModules = getTurbopackModules(scope);
|
|
1194
|
-
logDebug(
|
|
1195
|
-
"SharedModules",
|
|
1196
|
-
`initializeSharedModules: scope="${scope.scopedName}", allModules=${allModules ? allModules.length : "null"}, hostShared=[${Object.keys(hostShared).join(", ")}], remoteShared=${JSON.stringify(remoteShared)}`
|
|
1197
|
-
);
|
|
1198
|
-
let sharedModuleInitializer = null;
|
|
1199
|
-
if (allModules) {
|
|
1200
|
-
const sharedModuleInitializerIndex = allModules.findIndex((idOrFunc) => {
|
|
1201
|
-
if (typeof idOrFunc !== "function") {
|
|
1202
|
-
return false;
|
|
1203
|
-
}
|
|
1204
|
-
const funcCode = idOrFunc.toString();
|
|
1205
|
-
return REMOTE_SHARED_MARKER_RE.test(funcCode);
|
|
1206
|
-
});
|
|
1207
|
-
if (sharedModuleInitializerIndex > 0) {
|
|
1208
|
-
const sharedModuleInitializerCode = allModules[sharedModuleInitializerIndex].toString();
|
|
1209
|
-
const sharedModuleInitializerId = allModules[sharedModuleInitializerIndex - 1];
|
|
1210
|
-
const sharedModuleId = extractGroup(
|
|
1211
|
-
REMOTE_SHARED_ASSIGNMENT_RE,
|
|
1212
|
-
sharedModuleInitializerCode,
|
|
1213
|
-
"sharedModuleId"
|
|
1214
|
-
);
|
|
1215
|
-
if (sharedModuleId) {
|
|
1216
|
-
const { default: sharedModuleInitializerInstance } = handleTurbopackModule(
|
|
1217
|
-
scope,
|
|
1218
|
-
sharedModuleId,
|
|
1219
|
-
formatRemoteId(scope, String(sharedModuleInitializerId))
|
|
1220
|
-
);
|
|
1221
|
-
sharedModuleInitializer = sharedModuleInitializerInstance;
|
|
1222
|
-
}
|
|
1223
|
-
}
|
|
1224
|
-
if (sharedModuleInitializer) {
|
|
1225
|
-
const { shared } = await sharedModuleInitializer;
|
|
1226
|
-
const sharedModuleIds = extractSharedModuleIds(shared, scope);
|
|
1227
|
-
logDebug(
|
|
1228
|
-
"SharedModules",
|
|
1229
|
-
`Resolved shared modules for scope="${scope.scopedName}": ${JSON.stringify(sharedModuleIds)}`
|
|
1230
|
-
);
|
|
1231
|
-
return Promise.all(
|
|
1232
|
-
Object.entries(sharedModuleIds).map(async ([id, module2]) => {
|
|
1233
|
-
if (hostShared[module2]) {
|
|
1234
|
-
scope.sharedModules[id] = await hostShared[module2](scope.name);
|
|
1235
|
-
} else {
|
|
1236
|
-
logError(
|
|
1237
|
-
"SharedModules",
|
|
1238
|
-
`Host shared module "${module2}" not found for ID ${id}. ${DEDUPLICATION_WARNING}`
|
|
1239
|
-
);
|
|
1240
|
-
}
|
|
1241
|
-
})
|
|
1242
|
-
);
|
|
1243
|
-
}
|
|
1244
|
-
logWarn(
|
|
1245
|
-
"SharedModules",
|
|
1246
|
-
`No shared module initializer found in bundle for scope="${scope.scopedName}" \u2014 falling back to remoteShared mapping`
|
|
1247
|
-
);
|
|
1248
|
-
} else {
|
|
1249
|
-
logWarn(
|
|
1250
|
-
"SharedModules",
|
|
1251
|
-
`No TURBOPACK modules found for scope="${scope.scopedName}" (TURBOPACK_${scope.globalKey} is empty)`
|
|
1252
|
-
);
|
|
1253
|
-
}
|
|
1254
|
-
return Promise.all(
|
|
1255
|
-
Object.entries(remoteShared).map(async ([id, module2]) => {
|
|
1256
|
-
if (hostShared[module2]) {
|
|
1257
|
-
const normalizedId = id.replace("[app-ssr]", "[app-client]");
|
|
1258
|
-
scope.sharedModules[normalizedId] = await hostShared[module2](
|
|
1259
|
-
scope.name
|
|
1260
|
-
);
|
|
1261
|
-
} else {
|
|
1262
|
-
logError(
|
|
1263
|
-
"SharedModules",
|
|
1264
|
-
`Shared module "${module2}" not found for "${scope.name}". ${DEDUPLICATION_WARNING}`
|
|
1265
|
-
);
|
|
1266
|
-
}
|
|
1267
|
-
})
|
|
1268
|
-
);
|
|
1269
|
-
}
|
|
1270
|
-
function extractSharedModuleIds(shared, scope) {
|
|
1271
|
-
return Object.entries(shared).filter(([, value]) => typeof value === "function").reduce((acc, [key, value]) => {
|
|
1272
|
-
const asyncSharedModuleId = extractGroup(
|
|
1273
|
-
ASYNC_MODULE_LOADER_RE,
|
|
1274
|
-
value.toString(),
|
|
1275
|
-
"asyncSharedModuleId"
|
|
1276
|
-
);
|
|
1277
|
-
if (asyncSharedModuleId) {
|
|
1278
|
-
const asyncSharedModule = findModuleInit(
|
|
1279
|
-
getTurbopackModules(scope),
|
|
1280
|
-
asyncSharedModuleId
|
|
1281
|
-
);
|
|
1282
|
-
if (asyncSharedModule) {
|
|
1283
|
-
const sharedModuleId = extractGroup(
|
|
1284
|
-
ASYNC_MODULE_CALLBACK_RE,
|
|
1285
|
-
asyncSharedModule.toString(),
|
|
1286
|
-
"sharedModuleId"
|
|
1287
|
-
);
|
|
1288
|
-
acc[sharedModuleId ?? asyncSharedModuleId] = key.replace(
|
|
1289
|
-
"__remote_shared_module_",
|
|
1290
|
-
""
|
|
1291
|
-
);
|
|
1292
|
-
}
|
|
1293
|
-
}
|
|
1294
|
-
return acc;
|
|
1295
|
-
}, {});
|
|
1296
|
-
}
|
|
1297
|
-
function getSharedModule(scope, id) {
|
|
1298
|
-
const idStr = String(id);
|
|
1299
|
-
if (scope.sharedModules[idStr] !== void 0) {
|
|
1300
|
-
return scope.sharedModules[idStr];
|
|
1301
|
-
}
|
|
1302
|
-
for (const [key, value] of Object.entries(scope.sharedModules)) {
|
|
1303
|
-
if (typeof value !== "undefined" && idStr !== key && idStr.endsWith(key)) {
|
|
1304
|
-
return value;
|
|
1305
|
-
}
|
|
1306
|
-
}
|
|
1307
|
-
return null;
|
|
1308
|
-
}
|
|
1309
|
-
var DEDUPLICATION_WARNING;
|
|
1310
|
-
var init_shared_modules = __esm({
|
|
1311
|
-
"src/runtime/turbopack/shared-modules.ts"() {
|
|
1312
|
-
"use strict";
|
|
1313
|
-
init_logger();
|
|
1314
|
-
init_module();
|
|
1315
|
-
init_patterns2();
|
|
1316
|
-
init_remote_scope();
|
|
1317
|
-
DEDUPLICATION_WARNING = "This module will not be deduplicated \u2014 the remote may load its own copy, which can cause duplicate instance errors (e.g. invalid hook calls if React is loaded twice).";
|
|
1318
|
-
}
|
|
1319
|
-
});
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { newObj[key] = obj[key]; } } } newObj.default = obj; return newObj; } } function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }
|
|
1320
2
|
|
|
1321
|
-
// src/runtime/turbopack/module.ts
|
|
1322
|
-
function requireModule(scope, moduleId, fullId) {
|
|
1323
|
-
const idStr = String(moduleId);
|
|
1324
|
-
if (scope.moduleCache[idStr])
|
|
1325
|
-
return scope.moduleCache[idStr];
|
|
1326
|
-
const sharedModule = getSharedModule(scope, moduleId);
|
|
1327
|
-
if (sharedModule)
|
|
1328
|
-
return sharedModule;
|
|
1329
|
-
return handleTurbopackModule(
|
|
1330
|
-
scope,
|
|
1331
|
-
idStr,
|
|
1332
|
-
fullId ?? formatRemoteId(scope, idStr)
|
|
1333
|
-
);
|
|
1334
|
-
}
|
|
1335
|
-
function handleTurbopackModule(scope, moduleId, id) {
|
|
1336
|
-
if (scope.moduleCache[moduleId]) {
|
|
1337
|
-
return scope.moduleCache[moduleId];
|
|
1338
|
-
}
|
|
1339
|
-
const modules = getTurbopackModules(scope);
|
|
1340
|
-
if (!modules) {
|
|
1341
|
-
logError(
|
|
1342
|
-
"TurbopackModule",
|
|
1343
|
-
`TURBOPACK_${scope.globalKey} is undefined (scope: "${scope.scopedName}")`
|
|
1344
|
-
);
|
|
1345
|
-
}
|
|
1346
|
-
const moduleInit = findModuleInit(modules, moduleId);
|
|
1347
|
-
const exports = {};
|
|
1348
|
-
const moduleExports = { exports };
|
|
1349
|
-
if (typeof moduleInit !== "function") {
|
|
1350
|
-
throw new Error(
|
|
1351
|
-
`Module ${id} not found in bundle ${scope.name} with id ${moduleId}`
|
|
1352
|
-
);
|
|
1353
|
-
}
|
|
1354
|
-
scope.moduleCache[moduleId] = moduleExports.exports;
|
|
1355
|
-
moduleInit(
|
|
1356
|
-
createTurbopackContext(
|
|
1357
|
-
scope,
|
|
1358
|
-
exports,
|
|
1359
|
-
moduleExports,
|
|
1360
|
-
modules,
|
|
1361
|
-
moduleInit,
|
|
1362
|
-
id
|
|
1363
|
-
),
|
|
1364
|
-
moduleExports,
|
|
1365
|
-
exports
|
|
1366
|
-
);
|
|
1367
|
-
if (scope.moduleCache[moduleId] !== moduleExports.exports) {
|
|
1368
|
-
scope.moduleCache[moduleId] = moduleExports.exports;
|
|
1369
|
-
}
|
|
1370
|
-
return moduleExports.exports;
|
|
1371
|
-
}
|
|
1372
|
-
function findModuleInit(modules, moduleId) {
|
|
1373
|
-
if (!modules || typeof modules !== "object")
|
|
1374
|
-
return;
|
|
1375
|
-
if (!Array.isArray(modules)) {
|
|
1376
|
-
const key = moduleId in modules ? moduleId : Object.keys(modules).find((k) => k.startsWith(moduleId));
|
|
1377
|
-
return key !== void 0 ? modules[key] : void 0;
|
|
1378
|
-
}
|
|
1379
|
-
const flat = modules.flat();
|
|
1380
|
-
let idx = flat.findIndex((e) => String(e) === String(moduleId));
|
|
1381
|
-
if (idx < 0) {
|
|
1382
|
-
idx = flat.findIndex(
|
|
1383
|
-
(e) => typeof e === "string" && e.startsWith(moduleId)
|
|
1384
|
-
);
|
|
1385
|
-
}
|
|
1386
|
-
if (idx >= 0) {
|
|
1387
|
-
return flat.slice(idx + 1).find((e) => typeof e === "function");
|
|
1388
|
-
}
|
|
1389
|
-
for (const entry of flat) {
|
|
1390
|
-
if (!entry || typeof entry !== "object")
|
|
1391
|
-
continue;
|
|
1392
|
-
const obj = entry;
|
|
1393
|
-
if (moduleId in obj)
|
|
1394
|
-
return obj[moduleId];
|
|
1395
|
-
const prefixKey = Object.keys(obj).find((k) => k.startsWith(moduleId));
|
|
1396
|
-
if (prefixKey)
|
|
1397
|
-
return obj[prefixKey];
|
|
1398
|
-
}
|
|
1399
|
-
return void 0;
|
|
1400
|
-
}
|
|
1401
|
-
function createTurbopackContext(scope, exports, moduleExports, modules, moduleInit, id) {
|
|
1402
|
-
const scopedRequire = (moduleId) => requireModule(scope, moduleId, formatRemoteId(scope, String(moduleId)));
|
|
1403
|
-
return {
|
|
1404
|
-
// HMR not implemented for Remote Components
|
|
1405
|
-
k: {
|
|
1406
|
-
register() {
|
|
1407
|
-
},
|
|
1408
|
-
registerExports() {
|
|
1409
|
-
},
|
|
1410
|
-
signature() {
|
|
1411
|
-
return (fn) => fn;
|
|
1412
|
-
}
|
|
1413
|
-
},
|
|
1414
|
-
// ESM exports setup
|
|
1415
|
-
s(bindings, esmId) {
|
|
1416
|
-
let mod = exports;
|
|
1417
|
-
if (typeof esmId === "string" || typeof esmId === "number") {
|
|
1418
|
-
if (!scope.moduleCache[esmId]) {
|
|
1419
|
-
scope.moduleCache[esmId] = {};
|
|
1420
|
-
}
|
|
1421
|
-
mod = scope.moduleCache[esmId];
|
|
1422
|
-
}
|
|
1423
|
-
Object.defineProperty(mod, "__esModule", { value: true });
|
|
1424
|
-
if (Array.isArray(bindings)) {
|
|
1425
|
-
let i = 0;
|
|
1426
|
-
while (i < bindings.length) {
|
|
1427
|
-
const propName = bindings[i++];
|
|
1428
|
-
const tagOrFunc = bindings[i++];
|
|
1429
|
-
if (typeof tagOrFunc === "number") {
|
|
1430
|
-
Object.defineProperty(mod, propName, {
|
|
1431
|
-
value: bindings[i++],
|
|
1432
|
-
enumerable: true,
|
|
1433
|
-
writable: false
|
|
1434
|
-
});
|
|
1435
|
-
} else {
|
|
1436
|
-
const getterFn = tagOrFunc;
|
|
1437
|
-
if (typeof bindings[i] === "function") {
|
|
1438
|
-
const setterFn = bindings[i++];
|
|
1439
|
-
Object.defineProperty(mod, propName, {
|
|
1440
|
-
get: getterFn,
|
|
1441
|
-
set: setterFn,
|
|
1442
|
-
enumerable: true
|
|
1443
|
-
});
|
|
1444
|
-
} else {
|
|
1445
|
-
Object.defineProperty(mod, propName, {
|
|
1446
|
-
get: getterFn,
|
|
1447
|
-
enumerable: true
|
|
1448
|
-
});
|
|
1449
|
-
}
|
|
1450
|
-
}
|
|
1451
|
-
}
|
|
1452
|
-
}
|
|
1453
|
-
},
|
|
1454
|
-
// import — resolves directly via scope, no global dispatch
|
|
1455
|
-
i(importId) {
|
|
1456
|
-
let mod;
|
|
1457
|
-
if (typeof importId === "string") {
|
|
1458
|
-
const { exportSource, exportName } = /\s+<export (?<exportSource>.*?) as (?<exportName>.*?)>$/.exec(
|
|
1459
|
-
importId
|
|
1460
|
-
)?.groups ?? {};
|
|
1461
|
-
const normalizedId = importId.replace(
|
|
1462
|
-
/\s+<export(?<specifier>.*)>$/,
|
|
1463
|
-
""
|
|
1464
|
-
);
|
|
1465
|
-
mod = scopedRequire(normalizedId);
|
|
1466
|
-
if (mod && exportSource && exportName && (exportSource === "*" || typeof mod[exportSource] !== "undefined") && typeof mod[exportName] === "undefined") {
|
|
1467
|
-
if (exportSource === "*") {
|
|
1468
|
-
mod[exportName] = mod;
|
|
1469
|
-
} else {
|
|
1470
|
-
mod[exportName] = mod[exportSource];
|
|
1471
|
-
}
|
|
1472
|
-
}
|
|
1473
|
-
} else {
|
|
1474
|
-
mod = scopedRequire(importId);
|
|
1475
|
-
}
|
|
1476
|
-
if (typeof mod !== "object" || mod === null) {
|
|
1477
|
-
mod = { default: mod };
|
|
1478
|
-
} else if (!("default" in mod) && // ES module namespace objects have a null prototype, so calling
|
|
1479
|
-
// mod.toString() directly throws. Use Object.prototype.toString
|
|
1480
|
-
// to safely detect them.
|
|
1481
|
-
Object.prototype.toString.call(mod) !== "[object Module]") {
|
|
1482
|
-
try {
|
|
1483
|
-
mod.default = mod;
|
|
1484
|
-
} catch {
|
|
1485
|
-
}
|
|
1486
|
-
}
|
|
1487
|
-
return mod;
|
|
1488
|
-
},
|
|
1489
|
-
// require — resolves directly via scope
|
|
1490
|
-
r(requireId) {
|
|
1491
|
-
return scopedRequire(requireId);
|
|
1492
|
-
},
|
|
1493
|
-
// value exports
|
|
1494
|
-
v(value) {
|
|
1495
|
-
if (typeof value === "function") {
|
|
1496
|
-
exports.default = value((vid) => scopedRequire(vid));
|
|
1497
|
-
} else {
|
|
1498
|
-
moduleExports.exports = value;
|
|
1499
|
-
}
|
|
1500
|
-
},
|
|
1501
|
-
// async module initializer
|
|
1502
|
-
async a(mod) {
|
|
1503
|
-
let result;
|
|
1504
|
-
await mod(
|
|
1505
|
-
() => {
|
|
1506
|
-
},
|
|
1507
|
-
(value) => result = value
|
|
1508
|
-
);
|
|
1509
|
-
exports.default = result;
|
|
1510
|
-
},
|
|
1511
|
-
// async module loader — resolves directly via scope
|
|
1512
|
-
async A(Aid) {
|
|
1513
|
-
const mod = scopedRequire(Aid);
|
|
1514
|
-
return mod.default((parentId) => scopedRequire(parentId));
|
|
1515
|
-
},
|
|
1516
|
-
// dynamic import tracking — no-op for remote components
|
|
1517
|
-
j() {
|
|
1518
|
-
},
|
|
1519
|
-
// chunk loader — loads directly via scope, no global dispatch
|
|
1520
|
-
l(url) {
|
|
1521
|
-
const flatModules = Array.isArray(modules) ? modules : [];
|
|
1522
|
-
const moduleInitIndex = flatModules.indexOf(moduleInit);
|
|
1523
|
-
if (moduleInitIndex !== -1) {
|
|
1524
|
-
const scriptIndex = flatModules.slice(0, moduleInitIndex).findLastIndex((bundleEntry) => bundleEntry instanceof Element);
|
|
1525
|
-
if (scriptIndex !== -1) {
|
|
1526
|
-
const script = flatModules[scriptIndex];
|
|
1527
|
-
const scriptSrc = script.getAttribute("data-turbopack-src") || "";
|
|
1528
|
-
const nextIndex = scriptSrc.indexOf("/_next");
|
|
1529
|
-
const baseUrl = nextIndex !== -1 ? scriptSrc.slice(0, nextIndex) : "";
|
|
1530
|
-
const chunkUrl = `${baseUrl}/_next/${url}`;
|
|
1531
|
-
return loadChunkWithScope(scope, formatRemoteId(scope, chunkUrl));
|
|
1532
|
-
}
|
|
1533
|
-
}
|
|
1534
|
-
throw new Error(
|
|
1535
|
-
`Failed to load Turbopack chunk "${url}" for module "${id}". Check the URL is correct.`
|
|
1536
|
-
);
|
|
1537
|
-
},
|
|
1538
|
-
// globalThis substitute shared across all modules in this scope
|
|
1539
|
-
g: scope.moduleGlobal,
|
|
1540
|
-
m: moduleExports,
|
|
1541
|
-
e: exports
|
|
1542
|
-
};
|
|
1543
|
-
}
|
|
1544
|
-
var init_module = __esm({
|
|
1545
|
-
"src/runtime/turbopack/module.ts"() {
|
|
1546
|
-
"use strict";
|
|
1547
|
-
init_logger();
|
|
1548
|
-
init_chunk_loader();
|
|
1549
|
-
init_remote_scope();
|
|
1550
|
-
init_shared_modules();
|
|
1551
|
-
}
|
|
1552
|
-
});
|
|
1553
3
|
|
|
1554
|
-
// src/runtime/turbopack/remote-scope-setup.ts
|
|
1555
|
-
async function setupRemoteScope(runtime, scripts = [], url = new URL(location.href), bundle, resolveClientUrl) {
|
|
1556
|
-
const self = globalThis;
|
|
1557
|
-
const ns = getNamespace();
|
|
1558
|
-
const bundleName = bundle ?? "default";
|
|
1559
|
-
const existingScope = getScope(bundleName);
|
|
1560
|
-
if (existingScope && existingScope.url.origin === url.origin) {
|
|
1561
|
-
logDebug(
|
|
1562
|
-
"WebpackRuntime",
|
|
1563
|
-
`Reusing scope "${existingScope.scopedName}" (turbopackModules=${existingScope.turbopackModules.length})`
|
|
1564
|
-
);
|
|
1565
|
-
existingScope.resolveClientUrl = resolveClientUrl;
|
|
1566
|
-
if (runtime === RUNTIME_TURBOPACK) {
|
|
1567
|
-
await Promise.allSettled(
|
|
1568
|
-
scripts.map(
|
|
1569
|
-
(script) => script.src ? loadChunkWithScope(existingScope, script.src) : Promise.resolve(void 0)
|
|
1570
|
-
)
|
|
1571
|
-
);
|
|
1572
|
-
}
|
|
1573
|
-
return existingScope;
|
|
1574
|
-
}
|
|
1575
|
-
const scope = createScope(bundleName, url, runtime, resolveClientUrl);
|
|
1576
|
-
registerScope(scope);
|
|
1577
|
-
if (runtime === RUNTIME_WEBPACK && self.__remote_webpack_require__?.[bundleName]) {
|
|
1578
|
-
scope.webpackRequire = self.__remote_webpack_require__[bundleName];
|
|
1579
|
-
}
|
|
1580
|
-
ns.bundleUrls[bundleName] = url;
|
|
1581
|
-
if (scope.scopedName !== bundleName) {
|
|
1582
|
-
ns.bundleUrls[scope.scopedName] = url;
|
|
1583
|
-
}
|
|
1584
|
-
self.__webpack_get_script_filename__ = () => null;
|
|
1585
|
-
const willCreateDispatchers = typeof self.__webpack_require__ !== "function" || ns.dispatcherRuntime !== "turbopack";
|
|
1586
|
-
if (willCreateDispatchers) {
|
|
1587
|
-
if (!self.__original_webpack_require__ && !self.__original_webpack_chunk_load__) {
|
|
1588
|
-
self.__original_webpack_chunk_load__ = self.__webpack_chunk_load__;
|
|
1589
|
-
self.__original_webpack_require__ = self.__webpack_require__;
|
|
1590
|
-
}
|
|
1591
|
-
self.__webpack_chunk_load__ = createChunkDispatcher();
|
|
1592
|
-
self.__webpack_require__ = createModuleDispatcher(runtime);
|
|
1593
|
-
ns.dispatcherRuntime = runtime;
|
|
1594
|
-
self.__webpack_require_type__ = runtime;
|
|
1595
|
-
if (self.__remote_webpack_require__ && runtime === RUNTIME_TURBOPACK) {
|
|
1596
|
-
self.__remote_webpack_require__[bundleName] = self.__webpack_require__;
|
|
1597
|
-
self.__remote_webpack_require__[bundleName].type = "turbopack";
|
|
1598
|
-
}
|
|
1599
|
-
}
|
|
1600
|
-
if (self.__remote_webpack_require__?.[bundleName] && scope.scopedName !== bundleName) {
|
|
1601
|
-
self.__remote_webpack_require__[scope.scopedName] = self.__remote_webpack_require__[bundleName];
|
|
1602
|
-
}
|
|
1603
|
-
if (runtime === RUNTIME_TURBOPACK) {
|
|
1604
|
-
const results = await Promise.allSettled(
|
|
1605
|
-
scripts.map((script) => {
|
|
1606
|
-
if (script.src) {
|
|
1607
|
-
return loadChunkWithScope(scope, script.src);
|
|
1608
|
-
}
|
|
1609
|
-
return Promise.resolve(void 0);
|
|
1610
|
-
})
|
|
1611
|
-
);
|
|
1612
|
-
for (const result of results) {
|
|
1613
|
-
if (result.status === "rejected") {
|
|
1614
|
-
logWarn(
|
|
1615
|
-
"WebpackRuntime",
|
|
1616
|
-
`Initial chunk load failed: ${String(result.reason)}`
|
|
1617
|
-
);
|
|
1618
|
-
}
|
|
1619
|
-
}
|
|
1620
|
-
}
|
|
1621
|
-
return scope;
|
|
1622
|
-
}
|
|
1623
|
-
function createModuleDispatcher(runtime) {
|
|
1624
|
-
return (id) => {
|
|
1625
|
-
const self = globalThis;
|
|
1626
|
-
const { bundle, id: moduleId } = id.match(REMOTE_COMPONENT_REGEX)?.groups ?? {
|
|
1627
|
-
bundle: "default",
|
|
1628
|
-
id
|
|
1629
|
-
};
|
|
1630
|
-
const bundleName = bundle ?? "default";
|
|
1631
|
-
const remoteRuntime = self.__remote_webpack_require__?.[bundleName] ? self.__remote_webpack_require__[bundleName]?.type || "webpack" : runtime;
|
|
1632
|
-
logDebug(
|
|
1633
|
-
"ModuleDispatcher",
|
|
1634
|
-
`Resolving "${id}" (bundle: "${bundleName}", runtime: "${remoteRuntime}")`
|
|
1635
|
-
);
|
|
1636
|
-
try {
|
|
1637
|
-
if (remoteRuntime === RUNTIME_WEBPACK && bundle && moduleId) {
|
|
1638
|
-
const scope2 = getScope(bundle);
|
|
1639
|
-
if (scope2?.webpackRequire)
|
|
1640
|
-
return scope2.webpackRequire(moduleId);
|
|
1641
|
-
return self.__remote_webpack_require__?.[bundle]?.(moduleId);
|
|
1642
|
-
}
|
|
1643
|
-
const scope = getScope(bundleName);
|
|
1644
|
-
if (scope) {
|
|
1645
|
-
return requireModule(scope, moduleId ?? id, id);
|
|
1646
|
-
}
|
|
1647
|
-
throw new Error(
|
|
1648
|
-
`Module "${id}" not found \u2014 no scope for bundle "${bundleName}".`
|
|
1649
|
-
);
|
|
1650
|
-
} catch (requireError) {
|
|
1651
|
-
logWarn(
|
|
1652
|
-
"ModuleDispatcher",
|
|
1653
|
-
`Module require failed: ${String(requireError)}`
|
|
1654
|
-
);
|
|
1655
|
-
if (typeof self.__original_webpack_require__ !== "function") {
|
|
1656
|
-
throw new RemoteComponentsError(
|
|
1657
|
-
`Module "${id}" not found in remote component bundle "${bundleName}".`,
|
|
1658
|
-
{
|
|
1659
|
-
cause: requireError instanceof Error ? requireError : void 0
|
|
1660
|
-
}
|
|
1661
|
-
);
|
|
1662
|
-
}
|
|
1663
|
-
try {
|
|
1664
|
-
logDebug(
|
|
1665
|
-
"ModuleDispatcher",
|
|
1666
|
-
"Falling back to original webpack require"
|
|
1667
|
-
);
|
|
1668
|
-
return self.__original_webpack_require__(id);
|
|
1669
|
-
} catch (originalError) {
|
|
1670
|
-
throw new RemoteComponentsError(
|
|
1671
|
-
`Module "${id}" not found in remote component bundle "${bundleName}".`,
|
|
1672
|
-
{ cause: originalError instanceof Error ? originalError : void 0 }
|
|
1673
|
-
);
|
|
1674
|
-
}
|
|
1675
|
-
}
|
|
1676
|
-
};
|
|
1677
|
-
}
|
|
1678
|
-
var init_remote_scope_setup = __esm({
|
|
1679
|
-
"src/runtime/turbopack/remote-scope-setup.ts"() {
|
|
1680
|
-
"use strict";
|
|
1681
|
-
init_constants2();
|
|
1682
|
-
init_namespace();
|
|
1683
|
-
init_patterns();
|
|
1684
|
-
init_error();
|
|
1685
|
-
init_logger();
|
|
1686
|
-
init_chunk_loader();
|
|
1687
|
-
init_module();
|
|
1688
|
-
init_remote_scope();
|
|
1689
|
-
}
|
|
1690
|
-
});
|
|
1691
4
|
|
|
1692
|
-
// src/host/html/runtime/turbopack.ts
|
|
1693
|
-
var turbopack_exports = {};
|
|
1694
|
-
__export(turbopack_exports, {
|
|
1695
|
-
turbopackRuntime: () => turbopackRuntime
|
|
1696
|
-
});
|
|
1697
|
-
async function turbopackRuntime(url, bundle, shared, remoteShared, resolveClientUrl) {
|
|
1698
|
-
const self = globalThis;
|
|
1699
|
-
const hostShared = buildHostShared(shared, resolveClientUrl, {
|
|
1700
|
-
includeRemoteComponentShared: true
|
|
1701
|
-
});
|
|
1702
|
-
await setupRemoteScope("turbopack", [], url, bundle, resolveClientUrl);
|
|
1703
|
-
const {
|
|
1704
|
-
default: { createFromReadableStream }
|
|
1705
|
-
} = await import("react-server-dom-webpack/client.browser");
|
|
1706
|
-
async function preloadScripts(scripts, __) {
|
|
1707
|
-
const scope = await setupRemoteScope(
|
|
1708
|
-
"turbopack",
|
|
1709
|
-
scripts.map((script) => ({
|
|
1710
|
-
src: script.getAttribute("src") || script.getAttribute("data-src") || script.src
|
|
1711
|
-
})),
|
|
1712
|
-
url,
|
|
1713
|
-
bundle,
|
|
1714
|
-
resolveClientUrl
|
|
1715
|
-
);
|
|
1716
|
-
await initializeSharedModules(
|
|
1717
|
-
scope,
|
|
1718
|
-
buildCoreShared(hostShared),
|
|
1719
|
-
remoteShared ?? {}
|
|
1720
|
-
);
|
|
1721
|
-
}
|
|
1722
|
-
return {
|
|
1723
|
-
self,
|
|
1724
|
-
createFromReadableStream,
|
|
1725
|
-
applySharedModules,
|
|
1726
|
-
nextClientPagesLoader,
|
|
1727
|
-
preloadScripts
|
|
1728
|
-
};
|
|
1729
|
-
}
|
|
1730
|
-
var init_turbopack = __esm({
|
|
1731
|
-
"src/host/html/runtime/turbopack.ts"() {
|
|
1732
|
-
"use strict";
|
|
1733
|
-
init_apply_shared_modules();
|
|
1734
|
-
init_next_client_pages_loader();
|
|
1735
|
-
init_shared_module_resolver();
|
|
1736
|
-
init_remote_scope_setup();
|
|
1737
|
-
init_shared_modules();
|
|
1738
|
-
}
|
|
1739
|
-
});
|
|
1740
5
|
|
|
1741
|
-
// src/runtime/loaders/static-loader.ts
|
|
1742
|
-
async function importViaCallback(absoluteSrc, resolveClientUrl) {
|
|
1743
|
-
const resolvedUrl = resolveClientUrl(absoluteSrc) ?? absoluteSrc;
|
|
1744
|
-
const fetchUrl = new URL(resolvedUrl, location.href).href;
|
|
1745
|
-
const response = await fetch(fetchUrl);
|
|
1746
|
-
if (!response.ok)
|
|
1747
|
-
throw new Error(`Proxied fetch failed: ${response.status}`);
|
|
1748
|
-
const content = (await response.text()).replace(/import\.meta\.url/g, JSON.stringify(absoluteSrc)).replace(
|
|
1749
|
-
/\b(from|import)\s*(["'])(\.\.?\/[^"']+)\2/g,
|
|
1750
|
-
(_, keyword, quote, relativePath) => {
|
|
1751
|
-
const absoluteImportUrl = new URL(relativePath, absoluteSrc).href;
|
|
1752
|
-
const resolvedImportUrl = new URL(
|
|
1753
|
-
resolveClientUrl(absoluteImportUrl) ?? absoluteImportUrl,
|
|
1754
|
-
location.href
|
|
1755
|
-
).href;
|
|
1756
|
-
return `${keyword} ${quote}${resolvedImportUrl}${quote}`;
|
|
1757
|
-
}
|
|
1758
|
-
);
|
|
1759
|
-
const moduleBlobUrl = URL.createObjectURL(
|
|
1760
|
-
new Blob([content], { type: "text/javascript" })
|
|
1761
|
-
);
|
|
1762
|
-
const wrapperContent = [
|
|
1763
|
-
`import*as m from${JSON.stringify(moduleBlobUrl)};`,
|
|
1764
|
-
`globalThis.__rc_module_registry__=globalThis.__rc_module_registry__||{};`,
|
|
1765
|
-
`globalThis.__rc_module_registry__[${JSON.stringify(absoluteSrc)}]=m;`
|
|
1766
|
-
].join("");
|
|
1767
|
-
const wrapperBlobUrl = URL.createObjectURL(
|
|
1768
|
-
new Blob([wrapperContent], { type: "text/javascript" })
|
|
1769
|
-
);
|
|
1770
|
-
const scriptEl = document.createElement("script");
|
|
1771
|
-
scriptEl.type = "module";
|
|
1772
|
-
scriptEl.src = wrapperBlobUrl;
|
|
1773
|
-
try {
|
|
1774
|
-
await new Promise((resolve, reject) => {
|
|
1775
|
-
scriptEl.onload = () => resolve();
|
|
1776
|
-
scriptEl.onerror = () => reject(new Error(`Failed to load module for ${absoluteSrc}`));
|
|
1777
|
-
document.head.appendChild(scriptEl);
|
|
1778
|
-
});
|
|
1779
|
-
} finally {
|
|
1780
|
-
scriptEl.remove();
|
|
1781
|
-
URL.revokeObjectURL(moduleBlobUrl);
|
|
1782
|
-
URL.revokeObjectURL(wrapperBlobUrl);
|
|
1783
|
-
}
|
|
1784
|
-
const registry = getNamespace().moduleRegistry;
|
|
1785
|
-
const mod = registry[absoluteSrc] ?? {};
|
|
1786
|
-
delete registry[absoluteSrc];
|
|
1787
|
-
return mod;
|
|
1788
|
-
}
|
|
1789
|
-
async function importDirectly(absoluteSrc) {
|
|
1790
|
-
try {
|
|
1791
|
-
return await import(
|
|
1792
|
-
/* @vite-ignore */
|
|
1793
|
-
/* webpackIgnore: true */
|
|
1794
|
-
absoluteSrc
|
|
1795
|
-
);
|
|
1796
|
-
} catch (importError) {
|
|
1797
|
-
if (!absoluteSrc.startsWith("blob:")) {
|
|
1798
|
-
warnCrossOriginFetchError("StaticLoader", absoluteSrc);
|
|
1799
|
-
}
|
|
1800
|
-
throw importError;
|
|
1801
|
-
}
|
|
1802
|
-
}
|
|
1803
|
-
function resolveScriptSrc(script, url) {
|
|
1804
|
-
const rawSrc = typeof script.getAttribute === "function" ? script.getAttribute("src") ?? script.src : script.src;
|
|
1805
|
-
if (!rawSrc && script.textContent) {
|
|
1806
|
-
return URL.createObjectURL(
|
|
1807
|
-
new Blob(
|
|
1808
|
-
[script.textContent.replace(/import\.meta\.url/g, JSON.stringify(url))],
|
|
1809
|
-
{ type: "text/javascript" }
|
|
1810
|
-
)
|
|
1811
|
-
);
|
|
1812
|
-
}
|
|
1813
|
-
return rawSrc;
|
|
1814
|
-
}
|
|
1815
|
-
async function loadStaticRemoteComponent(scripts, url, resolveClientUrl) {
|
|
1816
|
-
const ns = getNamespace();
|
|
1817
|
-
if (ns.mountFns[url.href]) {
|
|
1818
|
-
ns.mountFns[url.href] = /* @__PURE__ */ new Set();
|
|
1819
|
-
}
|
|
1820
|
-
if (ns.unmountFns[url.href]) {
|
|
1821
|
-
ns.unmountFns[url.href] = /* @__PURE__ */ new Set();
|
|
1822
|
-
}
|
|
1823
|
-
const mountUnmountSets = await Promise.all(
|
|
1824
|
-
scripts.map(async (script) => {
|
|
1825
|
-
try {
|
|
1826
|
-
const src = resolveScriptSrc(script, url);
|
|
1827
|
-
const absoluteSrc = new URL(src, url).href;
|
|
1828
|
-
const mod = resolveClientUrl ? await importViaCallback(absoluteSrc, resolveClientUrl) : await importDirectly(absoluteSrc);
|
|
1829
|
-
if (src.startsWith("blob:")) {
|
|
1830
|
-
URL.revokeObjectURL(src);
|
|
1831
|
-
}
|
|
1832
|
-
if (typeof mod.mount === "function" || typeof mod.default?.mount === "function") {
|
|
1833
|
-
if (!ns.mountFns[url.href]) {
|
|
1834
|
-
ns.mountFns[url.href] = /* @__PURE__ */ new Set();
|
|
1835
|
-
}
|
|
1836
|
-
ns.mountFns[url.href]?.add(
|
|
1837
|
-
mod.mount || mod.default?.mount || (() => {
|
|
1838
|
-
})
|
|
1839
|
-
);
|
|
1840
|
-
}
|
|
1841
|
-
if (typeof mod.unmount === "function" || typeof mod.default?.unmount === "function") {
|
|
1842
|
-
if (!ns.unmountFns[url.href]) {
|
|
1843
|
-
ns.unmountFns[url.href] = /* @__PURE__ */ new Set();
|
|
1844
|
-
}
|
|
1845
|
-
ns.unmountFns[url.href]?.add(
|
|
1846
|
-
mod.unmount || mod.default?.unmount || (() => {
|
|
1847
|
-
})
|
|
1848
|
-
);
|
|
1849
|
-
}
|
|
1850
|
-
return {
|
|
1851
|
-
mount: mod.mount || mod.default?.mount,
|
|
1852
|
-
unmount: mod.unmount || mod.default?.unmount
|
|
1853
|
-
};
|
|
1854
|
-
} catch (e) {
|
|
1855
|
-
logError(
|
|
1856
|
-
"StaticLoader",
|
|
1857
|
-
`Error loading remote component script from "${script.src || url.href}".`,
|
|
1858
|
-
e
|
|
1859
|
-
);
|
|
1860
|
-
return {
|
|
1861
|
-
mount: void 0,
|
|
1862
|
-
unmount: void 0
|
|
1863
|
-
};
|
|
1864
|
-
}
|
|
1865
|
-
})
|
|
1866
|
-
);
|
|
1867
|
-
return mountUnmountSets.reduce(
|
|
1868
|
-
(acc, { mount, unmount }) => {
|
|
1869
|
-
if (typeof mount === "function") {
|
|
1870
|
-
acc.mount.add(mount);
|
|
1871
|
-
}
|
|
1872
|
-
if (typeof unmount === "function") {
|
|
1873
|
-
acc.unmount.add(unmount);
|
|
1874
|
-
}
|
|
1875
|
-
return acc;
|
|
1876
|
-
},
|
|
1877
|
-
{
|
|
1878
|
-
mount: /* @__PURE__ */ new Set(),
|
|
1879
|
-
unmount: /* @__PURE__ */ new Set()
|
|
1880
|
-
}
|
|
1881
|
-
);
|
|
1882
|
-
}
|
|
1883
|
-
var init_static_loader = __esm({
|
|
1884
|
-
"src/runtime/loaders/static-loader.ts"() {
|
|
1885
|
-
"use strict";
|
|
1886
|
-
init_namespace();
|
|
1887
|
-
init_logger();
|
|
1888
|
-
}
|
|
1889
|
-
});
|
|
1890
6
|
|
|
1891
|
-
// src/host/html/runtime/script.ts
|
|
1892
|
-
var script_exports = {};
|
|
1893
|
-
__export(script_exports, {
|
|
1894
|
-
scriptRuntime: () => scriptRuntime
|
|
1895
|
-
});
|
|
1896
|
-
function scriptRuntime(resolveClientUrl) {
|
|
1897
|
-
const self = globalThis;
|
|
1898
|
-
return {
|
|
1899
|
-
self,
|
|
1900
|
-
createFromReadableStream: () => Promise.resolve(null),
|
|
1901
|
-
applySharedModules: () => Promise.resolve(),
|
|
1902
|
-
nextClientPagesLoader: () => ({
|
|
1903
|
-
Component: null,
|
|
1904
|
-
App: null
|
|
1905
|
-
}),
|
|
1906
|
-
preloadScripts: (scripts, url) => loadStaticRemoteComponent(scripts, url, resolveClientUrl)
|
|
1907
|
-
};
|
|
1908
|
-
}
|
|
1909
|
-
var init_script = __esm({
|
|
1910
|
-
"src/host/html/runtime/script.ts"() {
|
|
1911
|
-
"use strict";
|
|
1912
|
-
init_static_loader();
|
|
1913
|
-
}
|
|
1914
|
-
});
|
|
1915
7
|
|
|
1916
|
-
// src/host/html/index.tsx
|
|
1917
|
-
var html_exports = {};
|
|
1918
|
-
__export(html_exports, {
|
|
1919
|
-
registerSharedModules: () => registerSharedModules
|
|
1920
|
-
});
|
|
1921
|
-
module.exports = __toCommonJS(html_exports);
|
|
1922
|
-
var import_react = require("react");
|
|
1923
|
-
var import_client = require("react-dom/client");
|
|
1924
8
|
|
|
1925
|
-
// src/host/server/fetch-with-hooks.ts
|
|
1926
|
-
init_logger();
|
|
1927
9
|
|
|
1928
|
-
|
|
1929
|
-
|
|
1930
|
-
|
|
1931
|
-
|
|
1932
|
-
|
|
1933
|
-
* If the remote component uses vercel deployment protection, ensure the host and remote vercel
|
|
1934
|
-
* projects share a common automation bypass secret, and the shared secret is used as the
|
|
1935
|
-
* VERCEL_AUTOMATION_BYPASS_SECRET env var in the host project.
|
|
1936
|
-
*/
|
|
1937
|
-
...typeof process === "object" && typeof process.env === "object" && typeof process.env.VERCEL_AUTOMATION_BYPASS_SECRET === "string" ? {
|
|
1938
|
-
"x-vercel-protection-bypass": process.env.VERCEL_AUTOMATION_BYPASS_SECRET
|
|
1939
|
-
} : {},
|
|
1940
|
-
Accept: "text/html"
|
|
1941
|
-
};
|
|
1942
|
-
}
|
|
10
|
+
var _chunkER73O65Fcjs = require('../chunk-ER73O65F.cjs');
|
|
11
|
+
require('../chunk-6IUP26UK.cjs');
|
|
12
|
+
require('../chunk-F44NODUS.cjs');
|
|
13
|
+
require('../chunk-XCFYWSLD.cjs');
|
|
14
|
+
require('../chunk-CREXMFMF.cjs');
|
|
1943
15
|
|
|
1944
|
-
// src/host/server/fetch-with-hooks.ts
|
|
1945
|
-
async function fetchWithWarning(url, init) {
|
|
1946
|
-
try {
|
|
1947
|
-
return await fetch(url, init);
|
|
1948
|
-
} catch (error) {
|
|
1949
|
-
warnCrossOriginFetchError("FetchRemoteComponent", url);
|
|
1950
|
-
throw error;
|
|
1951
|
-
}
|
|
1952
|
-
}
|
|
1953
|
-
async function fetchWithHooks(url, additionalInit, options = {}) {
|
|
1954
|
-
const {
|
|
1955
|
-
onRequest,
|
|
1956
|
-
onResponse,
|
|
1957
|
-
abortController = new AbortController()
|
|
1958
|
-
} = options;
|
|
1959
|
-
const signal = abortController.signal;
|
|
1960
|
-
const hookOptions = {
|
|
1961
|
-
signal,
|
|
1962
|
-
abort: (reason) => abortController.abort(reason)
|
|
1963
|
-
};
|
|
1964
|
-
const init = {
|
|
1965
|
-
method: "GET",
|
|
1966
|
-
headers: remoteFetchHeaders(),
|
|
1967
|
-
signal,
|
|
1968
|
-
...additionalInit
|
|
1969
|
-
};
|
|
1970
|
-
const res = await onRequest?.(url, init, hookOptions) ?? await fetchWithWarning(url, init);
|
|
1971
|
-
return await onResponse?.(url, res, hookOptions) ?? res;
|
|
1972
|
-
}
|
|
1973
|
-
|
|
1974
|
-
// src/host/server/get-client-or-server-url.ts
|
|
1975
|
-
function getClientOrServerUrl(src, serverFallback) {
|
|
1976
|
-
const fallback = typeof location !== "undefined" ? location.href : serverFallback;
|
|
1977
|
-
if (!src) {
|
|
1978
|
-
return new URL(fallback);
|
|
1979
|
-
}
|
|
1980
|
-
return typeof src === "string" ? new URL(src, fallback) : src;
|
|
1981
|
-
}
|
|
1982
|
-
|
|
1983
|
-
// src/host/shared/state.ts
|
|
1984
|
-
function createHostState() {
|
|
1985
|
-
return {
|
|
1986
|
-
stage: "idle",
|
|
1987
|
-
prevSrc: void 0,
|
|
1988
|
-
prevUrl: void 0,
|
|
1989
|
-
prevName: void 0,
|
|
1990
|
-
prevIsRemoteComponent: false,
|
|
1991
|
-
abortController: void 0
|
|
1992
|
-
};
|
|
1993
|
-
}
|
|
1994
16
|
|
|
1995
|
-
// src/host/utils/resolve-name-from-src.ts
|
|
1996
|
-
function resolveNameFromSrc(src, defaultName) {
|
|
1997
|
-
if (!src) {
|
|
1998
|
-
return defaultName;
|
|
1999
|
-
}
|
|
2000
|
-
const hash = typeof src === "string" ? src : src.hash;
|
|
2001
|
-
const hashIndex = hash.indexOf("#");
|
|
2002
|
-
if (hashIndex < 0) {
|
|
2003
|
-
return defaultName;
|
|
2004
|
-
}
|
|
2005
|
-
const name = hash.slice(hashIndex + 1);
|
|
2006
|
-
return name || defaultName;
|
|
2007
|
-
}
|
|
2008
17
|
|
|
2009
|
-
// src/host/html/index.tsx
|
|
2010
|
-
init_constants2();
|
|
2011
18
|
|
|
2012
|
-
|
|
2013
|
-
var ORIGIN_REWRITE_TAGS = [
|
|
2014
|
-
"img",
|
|
2015
|
-
"source",
|
|
2016
|
-
"video",
|
|
2017
|
-
"audio",
|
|
2018
|
-
"track",
|
|
2019
|
-
"iframe",
|
|
2020
|
-
"embed",
|
|
2021
|
-
"script",
|
|
2022
|
-
"link"
|
|
2023
|
-
];
|
|
2024
|
-
var ID_SUFFIX_RSC = "_rsc";
|
|
2025
|
-
var ID_SUFFIX_SSR = "_ssr";
|
|
2026
|
-
var ID_SUFFIX_SHARED = "_shared";
|
|
2027
|
-
var DATA_BUNDLE = "data-bundle";
|
|
2028
|
-
var DATA_ROUTE = "data-route";
|
|
2029
|
-
var DATA_RUNTIME = "data-runtime";
|
|
2030
|
-
var DATA_TYPE = "data-type";
|
|
2031
|
-
var DATA_SRC = "data-src";
|
|
2032
|
-
var DATA_REMOTE_COMPONENTS_SHARED = "data-remote-components-shared";
|
|
2033
|
-
var TAG_REMOTE_COMPONENT = "remote-component";
|
|
2034
|
-
var NEXT_DATA_ID = "__NEXT_DATA__";
|
|
2035
|
-
var REMOTE_NEXT_DATA_ID = "__REMOTE_NEXT_DATA__";
|
|
2036
|
-
var NEXT_CONTAINER_ID = "__next";
|
|
19
|
+
var _chunkR4QFK5TNcjs = require('../chunk-R4QFK5TN.cjs');
|
|
2037
20
|
|
|
2038
|
-
// src/runtime/html/rewrite-srcset.ts
|
|
2039
|
-
function rewriteSrcset(srcset, base, resolve) {
|
|
2040
|
-
return srcset.split(",").map((entry) => {
|
|
2041
|
-
const [url, descriptor] = entry.trim().split(/\s+/);
|
|
2042
|
-
if (!url)
|
|
2043
|
-
return entry;
|
|
2044
|
-
const absoluteUrl = new URL(url, base).href;
|
|
2045
|
-
const resolvedUrl = resolve ? resolve(absoluteUrl) : absoluteUrl;
|
|
2046
|
-
return descriptor ? `${resolvedUrl} ${descriptor}` : resolvedUrl;
|
|
2047
|
-
}).join(", ");
|
|
2048
|
-
}
|
|
2049
21
|
|
|
2050
|
-
|
|
2051
|
-
function applyOriginToNodes(doc, url, resolveClientUrl) {
|
|
2052
|
-
if (url.origin !== location.origin) {
|
|
2053
|
-
const nodes = doc.querySelectorAll(
|
|
2054
|
-
ORIGIN_REWRITE_TAGS.map(
|
|
2055
|
-
(type) => `${type}[src],${type}[srcset],${type}[href],${type}[imagesrcset]`
|
|
2056
|
-
).join(",")
|
|
2057
|
-
);
|
|
2058
|
-
nodes.forEach((node) => {
|
|
2059
|
-
if (node.hasAttribute("src") && /^[./]+\/?/.test(node.getAttribute("src") ?? "")) {
|
|
2060
|
-
const absoluteSrc = new URL(node.getAttribute("src") ?? "/", url).href;
|
|
2061
|
-
const isScript = node.tagName.toLowerCase() === "script";
|
|
2062
|
-
node.src = isScript ? absoluteSrc : resolveClientUrl?.(absoluteSrc) ?? absoluteSrc;
|
|
2063
|
-
}
|
|
2064
|
-
if (node.hasAttribute("href") && /^[./]+\/?/.test(node.getAttribute("href") ?? "")) {
|
|
2065
|
-
const absoluteHref = new URL(node.getAttribute("href") ?? "/", url).href;
|
|
2066
|
-
node.setAttribute(
|
|
2067
|
-
"href",
|
|
2068
|
-
resolveClientUrl?.(absoluteHref) ?? absoluteHref
|
|
2069
|
-
);
|
|
2070
|
-
}
|
|
2071
|
-
if (node.hasAttribute("srcset")) {
|
|
2072
|
-
const raw = node.getAttribute("srcset");
|
|
2073
|
-
if (raw) {
|
|
2074
|
-
const resolve = resolveClientUrl ? (abs) => resolveClientUrl(abs) ?? abs : void 0;
|
|
2075
|
-
node.setAttribute("srcset", rewriteSrcset(raw, url, resolve));
|
|
2076
|
-
}
|
|
2077
|
-
}
|
|
2078
|
-
if (node.hasAttribute("imagesrcset")) {
|
|
2079
|
-
const raw = node.getAttribute("imagesrcset");
|
|
2080
|
-
if (raw) {
|
|
2081
|
-
const resolve = resolveClientUrl ? (abs) => resolveClientUrl(abs) ?? abs : void 0;
|
|
2082
|
-
node.setAttribute("imagesrcset", rewriteSrcset(raw, url, resolve));
|
|
2083
|
-
}
|
|
2084
|
-
}
|
|
2085
|
-
});
|
|
2086
|
-
}
|
|
2087
|
-
}
|
|
2088
|
-
|
|
2089
|
-
// src/runtime/html/parse-remote-html.ts
|
|
2090
|
-
init_constants2();
|
|
2091
|
-
|
|
2092
|
-
// src/runtime/metadata.ts
|
|
2093
|
-
init_constants2();
|
|
2094
|
-
var VALID_RUNTIMES = /* @__PURE__ */ new Set(["webpack", "turbopack", "script"]);
|
|
2095
|
-
var VALID_TYPES = /* @__PURE__ */ new Set([
|
|
2096
|
-
"nextjs",
|
|
2097
|
-
"remote-component",
|
|
2098
|
-
"unknown"
|
|
2099
|
-
]);
|
|
2100
|
-
function isRuntime(value) {
|
|
2101
|
-
return VALID_RUNTIMES.has(value);
|
|
2102
|
-
}
|
|
2103
|
-
function isComponentType(value) {
|
|
2104
|
-
return VALID_TYPES.has(value);
|
|
2105
|
-
}
|
|
2106
|
-
function toRuntime(value) {
|
|
2107
|
-
return value && isRuntime(value) ? value : "webpack";
|
|
2108
|
-
}
|
|
2109
|
-
function toComponentType(value) {
|
|
2110
|
-
return value && isComponentType(value) ? value : "unknown";
|
|
2111
|
-
}
|
|
2112
|
-
function buildMetadata(attrs, url) {
|
|
2113
|
-
const id = attrs.id || DEFAULT_COMPONENT_NAME;
|
|
2114
|
-
const bundle = attrs.bundle || process.env.NEXT_PUBLIC_MFE_CURRENT_APPLICATION || DEFAULT_BUNDLE_NAME;
|
|
2115
|
-
return {
|
|
2116
|
-
name: attrs.name || id.replace(/_ssr$/, ""),
|
|
2117
|
-
bundle,
|
|
2118
|
-
route: attrs.route || url.pathname || DEFAULT_ROUTE,
|
|
2119
|
-
runtime: toRuntime(attrs.runtime),
|
|
2120
|
-
id,
|
|
2121
|
-
type: toComponentType(attrs.type)
|
|
2122
|
-
};
|
|
2123
|
-
}
|
|
22
|
+
var _chunk7MVFHOIPcjs = require('../chunk-7MVFHOIP.cjs');
|
|
2124
23
|
|
|
2125
|
-
// src/runtime/html/parse-remote-html.ts
|
|
2126
|
-
init_error();
|
|
2127
|
-
function validateSingleComponent(doc, name, url) {
|
|
2128
|
-
if (doc.querySelectorAll(`div[${DATA_BUNDLE}][${DATA_ROUTE}]`).length > 1 && !doc.querySelector(
|
|
2129
|
-
`div[${DATA_BUNDLE}][${DATA_ROUTE}][id^="${name}"]`
|
|
2130
|
-
) || doc.querySelectorAll(`${TAG_REMOTE_COMPONENT}:not([src])`).length > 1 && !doc.querySelector(`${TAG_REMOTE_COMPONENT}[name="${name}"]`)) {
|
|
2131
|
-
throw multipleRemoteComponentsError(url);
|
|
2132
|
-
}
|
|
2133
|
-
}
|
|
2134
|
-
function findComponentElement(doc, name) {
|
|
2135
|
-
return doc.querySelector(`div[${DATA_BUNDLE}][${DATA_ROUTE}][id^="${name}"]`) ?? doc.querySelector(`div[${DATA_BUNDLE}][${DATA_ROUTE}]`) ?? doc.querySelector(`div#${NEXT_CONTAINER_ID}`) ?? doc.querySelector(`${TAG_REMOTE_COMPONENT}[name="${name}"]:not([src])`) ?? doc.querySelector(`${TAG_REMOTE_COMPONENT}:not([src])`);
|
|
2136
|
-
}
|
|
2137
|
-
function parseNextData(doc) {
|
|
2138
|
-
return JSON.parse(
|
|
2139
|
-
(doc.querySelector(`#${NEXT_DATA_ID}`) ?? doc.querySelector(`#${REMOTE_NEXT_DATA_ID}`))?.textContent ?? "null"
|
|
2140
|
-
);
|
|
2141
|
-
}
|
|
2142
|
-
function resolveComponentName(component, nextData, fallbackName) {
|
|
2143
|
-
const isRemoteComponent = component?.tagName.toLowerCase() === TAG_REMOTE_COMPONENT;
|
|
2144
|
-
const name = component?.getAttribute("id")?.replace(new RegExp(`${ID_SUFFIX_SSR}$`), "") || isRemoteComponent && component?.getAttribute("name") || (nextData ? "__next" : fallbackName);
|
|
2145
|
-
return { name, isRemoteComponent };
|
|
2146
|
-
}
|
|
2147
|
-
function extractRemoteShared(doc, name, nextData) {
|
|
2148
|
-
const remoteSharedEl = doc.querySelector(
|
|
2149
|
-
`#${name}${ID_SUFFIX_SHARED}[${DATA_REMOTE_COMPONENTS_SHARED}]`
|
|
2150
|
-
);
|
|
2151
|
-
const remoteShared = nextData?.props.__REMOTE_COMPONENT__?.shared ?? (JSON.parse(remoteSharedEl?.textContent ?? "{}") ?? {});
|
|
2152
|
-
remoteSharedEl?.remove();
|
|
2153
|
-
return remoteShared;
|
|
2154
|
-
}
|
|
2155
|
-
function validateComponentFound(component, rsc, nextData, isRemoteComponent, url, name) {
|
|
2156
|
-
if (!component || !(rsc || nextData || isRemoteComponent)) {
|
|
2157
|
-
throw new RemoteComponentsError(
|
|
2158
|
-
`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>?`
|
|
2159
|
-
);
|
|
2160
|
-
}
|
|
2161
|
-
}
|
|
2162
|
-
function extractLinks(doc, component) {
|
|
2163
|
-
return Array.from(doc.querySelectorAll("link[href]")).filter(
|
|
2164
|
-
(link) => !component.contains(link)
|
|
2165
|
-
);
|
|
2166
|
-
}
|
|
2167
|
-
function extractScripts(doc, component, isRemoteComponent) {
|
|
2168
|
-
return Array.from(
|
|
2169
|
-
(isRemoteComponent ? component : doc).querySelectorAll(
|
|
2170
|
-
`script[src],script[${DATA_SRC}]`
|
|
2171
|
-
)
|
|
2172
|
-
);
|
|
2173
|
-
}
|
|
2174
|
-
function parseRemoteComponentDocument(doc, name, url) {
|
|
2175
|
-
validateSingleComponent(doc, name, url.href);
|
|
2176
|
-
const component = findComponentElement(doc, name);
|
|
2177
|
-
const nextData = parseNextData(doc);
|
|
2178
|
-
const { name: resolvedName, isRemoteComponent } = resolveComponentName(
|
|
2179
|
-
component,
|
|
2180
|
-
nextData,
|
|
2181
|
-
name
|
|
2182
|
-
);
|
|
2183
|
-
const rsc = doc.querySelector(`#${resolvedName}${ID_SUFFIX_RSC}`);
|
|
2184
|
-
const metadata = buildMetadata(
|
|
2185
|
-
{
|
|
2186
|
-
name: resolvedName,
|
|
2187
|
-
bundle: component?.getAttribute(DATA_BUNDLE) || nextData?.props.__REMOTE_COMPONENT__?.bundle,
|
|
2188
|
-
route: component?.getAttribute(DATA_ROUTE) ?? nextData?.page,
|
|
2189
|
-
runtime: component?.getAttribute(DATA_RUNTIME) ?? nextData?.props.__REMOTE_COMPONENT__?.runtime ?? RUNTIME_SCRIPT,
|
|
2190
|
-
id: component?.getAttribute("id"),
|
|
2191
|
-
type: component?.getAttribute(DATA_TYPE)
|
|
2192
|
-
},
|
|
2193
|
-
url
|
|
2194
|
-
);
|
|
2195
|
-
const remoteShared = extractRemoteShared(doc, resolvedName, nextData);
|
|
2196
|
-
validateComponentFound(
|
|
2197
|
-
component,
|
|
2198
|
-
rsc,
|
|
2199
|
-
nextData,
|
|
2200
|
-
isRemoteComponent,
|
|
2201
|
-
url.href,
|
|
2202
|
-
resolvedName
|
|
2203
|
-
);
|
|
2204
|
-
const links = extractLinks(doc, component);
|
|
2205
|
-
const scripts = extractScripts(doc, component, isRemoteComponent);
|
|
2206
|
-
return {
|
|
2207
|
-
component,
|
|
2208
|
-
name: resolvedName,
|
|
2209
|
-
isRemoteComponent,
|
|
2210
|
-
metadata,
|
|
2211
|
-
nextData,
|
|
2212
|
-
rsc,
|
|
2213
|
-
remoteShared,
|
|
2214
|
-
links,
|
|
2215
|
-
scripts
|
|
2216
|
-
};
|
|
2217
|
-
}
|
|
2218
24
|
|
|
2219
|
-
// src/host/html/index.tsx
|
|
2220
|
-
init_namespace();
|
|
2221
25
|
|
|
2222
|
-
// src/runtime/rsc.ts
|
|
2223
|
-
var import_web_streams_polyfill = require("web-streams-polyfill");
|
|
2224
|
-
function fixPayload(payload) {
|
|
2225
|
-
if (Array.isArray(payload)) {
|
|
2226
|
-
if (payload[0] === "$") {
|
|
2227
|
-
fixPayload(payload[3]);
|
|
2228
|
-
if (payload.length === 4) {
|
|
2229
|
-
payload.push(null, null, 1);
|
|
2230
|
-
}
|
|
2231
|
-
} else {
|
|
2232
|
-
for (const item of payload) {
|
|
2233
|
-
fixPayload(item);
|
|
2234
|
-
}
|
|
2235
|
-
}
|
|
2236
|
-
} else if (typeof payload === "object" && payload !== null) {
|
|
2237
|
-
for (const key in payload) {
|
|
2238
|
-
fixPayload(payload[key]);
|
|
2239
|
-
}
|
|
2240
|
-
}
|
|
2241
|
-
}
|
|
2242
|
-
function buildRSCChunks(rscName, data) {
|
|
2243
|
-
const chunks = [];
|
|
2244
|
-
for (const chunk of data) {
|
|
2245
|
-
for (const line of chunk.split("\n")) {
|
|
2246
|
-
const match = /\.push\("(?<rsc>.*)"\);$/.exec(line);
|
|
2247
|
-
if (match?.groups?.rsc) {
|
|
2248
|
-
chunks.push(JSON.parse(`"${match.groups.rsc}"`));
|
|
2249
|
-
}
|
|
2250
|
-
}
|
|
2251
|
-
}
|
|
2252
|
-
return chunks;
|
|
2253
|
-
}
|
|
2254
|
-
function createRSCStream(rscName, data) {
|
|
2255
|
-
return new import_web_streams_polyfill.ReadableStream({
|
|
2256
|
-
type: "bytes",
|
|
2257
|
-
start(controller) {
|
|
2258
|
-
const encoder = new TextEncoder();
|
|
2259
|
-
const self = globalThis;
|
|
2260
|
-
if (data.length > 0) {
|
|
2261
|
-
const parsed = buildRSCChunks(rscName, data);
|
|
2262
|
-
if (parsed.length > 0) {
|
|
2263
|
-
self[rscName] = self[rscName] ?? [];
|
|
2264
|
-
self[rscName].push(...parsed);
|
|
2265
|
-
}
|
|
2266
|
-
}
|
|
2267
|
-
const allChunks = (self[rscName] ?? [`0:[null]
|
|
2268
|
-
`]).join("");
|
|
2269
|
-
self[rscName] = null;
|
|
2270
|
-
allChunks.split("\n").forEach((chunk) => {
|
|
2271
|
-
if (chunk.length > 0) {
|
|
2272
|
-
const { before, id, prefix, payload } = /^(?<before>[^:]*?)?(?<id>[0-9a-zA-Z]+):(?<prefix>[A-Z])?(?<payload>\[.*\])/.exec(
|
|
2273
|
-
chunk
|
|
2274
|
-
)?.groups ?? {};
|
|
2275
|
-
if (payload) {
|
|
2276
|
-
const jsonPayload = JSON.parse(payload);
|
|
2277
|
-
fixPayload(jsonPayload);
|
|
2278
|
-
const reconstruct = `${before ?? ""}${id}:${prefix ?? ""}${JSON.stringify(jsonPayload)}`;
|
|
2279
|
-
controller.enqueue(encoder.encode(`${reconstruct}
|
|
2280
|
-
`));
|
|
2281
|
-
} else {
|
|
2282
|
-
controller.enqueue(encoder.encode(`${chunk}
|
|
2283
|
-
`));
|
|
2284
|
-
}
|
|
2285
|
-
} else {
|
|
2286
|
-
controller.enqueue(encoder.encode(`${chunk}
|
|
2287
|
-
`));
|
|
2288
|
-
}
|
|
2289
|
-
});
|
|
2290
|
-
controller.close();
|
|
2291
|
-
}
|
|
2292
|
-
});
|
|
2293
|
-
}
|
|
2294
26
|
|
|
2295
|
-
// src/runtime/url/resolve-client-url.ts
|
|
2296
|
-
function withRemoteSrc(resolveClientUrl, remoteSrc) {
|
|
2297
|
-
const remoteOrigin = parseOrigin(remoteSrc);
|
|
2298
|
-
return (url) => {
|
|
2299
|
-
const urlOrigin = parseOrigin(url);
|
|
2300
|
-
if (remoteOrigin && urlOrigin && urlOrigin !== remoteOrigin) {
|
|
2301
|
-
return void 0;
|
|
2302
|
-
}
|
|
2303
|
-
return resolveClientUrl(remoteSrc, url);
|
|
2304
|
-
};
|
|
2305
|
-
}
|
|
2306
|
-
function parseOrigin(url) {
|
|
2307
|
-
try {
|
|
2308
|
-
return new URL(url).origin;
|
|
2309
|
-
} catch {
|
|
2310
|
-
return void 0;
|
|
2311
|
-
}
|
|
2312
|
-
}
|
|
2313
27
|
|
|
2314
|
-
|
|
2315
|
-
|
|
2316
|
-
|
|
2317
|
-
|
|
28
|
+
var _chunkRUWR74XQcjs = require('../chunk-RUWR74XQ.cjs');
|
|
29
|
+
require('../chunk-TCFLEBQM.cjs');
|
|
30
|
+
require('../chunk-KE7QPAQ4.cjs');
|
|
31
|
+
require('../chunk-SHFJ5OQA.cjs');
|
|
2318
32
|
|
|
2319
33
|
// src/host/html/index.tsx
|
|
2320
|
-
|
|
2321
|
-
|
|
2322
|
-
init_error();
|
|
2323
|
-
init_logger();
|
|
34
|
+
var _react = require('react');
|
|
35
|
+
var _client = require('react-dom/client');
|
|
2324
36
|
|
|
2325
37
|
// src/host/html/attach-styles.ts
|
|
2326
|
-
init_error();
|
|
2327
38
|
async function attachStyles({
|
|
2328
39
|
doc,
|
|
2329
40
|
component,
|
|
@@ -2345,9 +56,9 @@ async function attachStyles({
|
|
|
2345
56
|
link.onerror = null;
|
|
2346
57
|
link.remove();
|
|
2347
58
|
}
|
|
2348
|
-
abortReject
|
|
59
|
+
_optionalChain([abortReject, 'optionalCall', _2 => _2(new DOMException("Aborted", "AbortError"))]);
|
|
2349
60
|
};
|
|
2350
|
-
signal
|
|
61
|
+
_optionalChain([signal, 'optionalAccess', _3 => _3.addEventListener, 'call', _4 => _4("abort", abortHandler, { once: true })]);
|
|
2351
62
|
try {
|
|
2352
63
|
await Promise.all(
|
|
2353
64
|
Array.from(links).filter((link) => !component.contains(link)).map((link) => {
|
|
@@ -2357,7 +68,7 @@ async function attachStyles({
|
|
|
2357
68
|
if (link.rel === "stylesheet") {
|
|
2358
69
|
newLink.onload = () => resolve();
|
|
2359
70
|
newLink.onerror = () => reject(
|
|
2360
|
-
new RemoteComponentsError(
|
|
71
|
+
new (0, _chunkRUWR74XQcjs.RemoteComponentsError)(
|
|
2361
72
|
`Failed to load <link href="${link.href}"> for Remote Component. Check the URL is correct.`
|
|
2362
73
|
)
|
|
2363
74
|
);
|
|
@@ -2369,11 +80,11 @@ async function attachStyles({
|
|
|
2369
80
|
if (attr.name === "href") {
|
|
2370
81
|
const absoluteHref = new URL(
|
|
2371
82
|
attr.value,
|
|
2372
|
-
baseUrl
|
|
83
|
+
_nullishCoalesce(baseUrl, () => ( location.origin))
|
|
2373
84
|
).href;
|
|
2374
85
|
newLink.setAttribute(
|
|
2375
86
|
attr.name,
|
|
2376
|
-
resolveClientUrl
|
|
87
|
+
_nullishCoalesce(_optionalChain([resolveClientUrl, 'optionalCall', _5 => _5(absoluteHref)]), () => ( absoluteHref))
|
|
2377
88
|
);
|
|
2378
89
|
} else {
|
|
2379
90
|
newLink.setAttribute(attr.name, attr.value);
|
|
@@ -2385,28 +96,27 @@ async function attachStyles({
|
|
|
2385
96
|
remoteComponentSrc
|
|
2386
97
|
);
|
|
2387
98
|
}
|
|
2388
|
-
root
|
|
99
|
+
_optionalChain([root, 'optionalAccess', _6 => _6.appendChild, 'call', _7 => _7(newLink)]);
|
|
2389
100
|
return Promise.race([loadPromise, abortPromise]);
|
|
2390
101
|
})
|
|
2391
102
|
);
|
|
2392
103
|
} finally {
|
|
2393
|
-
signal
|
|
104
|
+
_optionalChain([signal, 'optionalAccess', _8 => _8.removeEventListener, 'call', _9 => _9("abort", abortHandler)]);
|
|
2394
105
|
}
|
|
2395
106
|
const styles = doc.querySelectorAll("style");
|
|
2396
107
|
for (const style of styles) {
|
|
2397
|
-
if (style.parentElement
|
|
108
|
+
if (_optionalChain([style, 'access', _10 => _10.parentElement, 'optionalAccess', _11 => _11.tagName, 'access', _12 => _12.toLowerCase, 'call', _13 => _13()]) === "head") {
|
|
2398
109
|
const newStyle = document.createElement("style");
|
|
2399
110
|
newStyle.textContent = style.textContent;
|
|
2400
111
|
if (remoteComponentSrc) {
|
|
2401
112
|
newStyle.setAttribute("data-remote-component-src", remoteComponentSrc);
|
|
2402
113
|
}
|
|
2403
|
-
root
|
|
114
|
+
_optionalChain([root, 'optionalAccess', _14 => _14.appendChild, 'call', _15 => _15(newStyle)]);
|
|
2404
115
|
}
|
|
2405
116
|
}
|
|
2406
117
|
}
|
|
2407
118
|
|
|
2408
119
|
// src/host/html/runtime/index.ts
|
|
2409
|
-
init_error();
|
|
2410
120
|
async function getRuntime(type, url, bundle, shared, remoteShared, resolveClientUrl) {
|
|
2411
121
|
if (typeof globalThis.process === "undefined") {
|
|
2412
122
|
globalThis.process = {
|
|
@@ -2414,11 +124,11 @@ async function getRuntime(type, url, bundle, shared, remoteShared, resolveClient
|
|
|
2414
124
|
};
|
|
2415
125
|
}
|
|
2416
126
|
if (type === "webpack") {
|
|
2417
|
-
const { webpackRuntime
|
|
2418
|
-
return
|
|
127
|
+
const { webpackRuntime } = await Promise.resolve().then(() => _interopRequireWildcard(require("../webpack-KSCMCL7M.cjs")));
|
|
128
|
+
return webpackRuntime(bundle, shared, remoteShared, resolveClientUrl);
|
|
2419
129
|
} else if (type === "turbopack") {
|
|
2420
|
-
const { turbopackRuntime
|
|
2421
|
-
return
|
|
130
|
+
const { turbopackRuntime } = await Promise.resolve().then(() => _interopRequireWildcard(require("../turbopack-WRMKPNN4.cjs")));
|
|
131
|
+
return turbopackRuntime(
|
|
2422
132
|
url,
|
|
2423
133
|
bundle,
|
|
2424
134
|
shared,
|
|
@@ -2426,32 +136,33 @@ async function getRuntime(type, url, bundle, shared, remoteShared, resolveClient
|
|
|
2426
136
|
resolveClientUrl
|
|
2427
137
|
);
|
|
2428
138
|
} else if (type === "script") {
|
|
2429
|
-
const { scriptRuntime
|
|
2430
|
-
return
|
|
139
|
+
const { scriptRuntime } = await Promise.resolve().then(() => _interopRequireWildcard(require("../script-6W5JRBZK.cjs")));
|
|
140
|
+
return scriptRuntime(resolveClientUrl);
|
|
2431
141
|
}
|
|
2432
|
-
throw new RemoteComponentsError(
|
|
142
|
+
throw new (0, _chunkRUWR74XQcjs.RemoteComponentsError)(
|
|
2433
143
|
`Remote Components runtime "${type}" is not supported. Supported runtimes are "webpack", "turbopack", and "script".`
|
|
2434
144
|
);
|
|
2435
145
|
}
|
|
2436
146
|
|
|
2437
147
|
// src/host/html/index.tsx
|
|
2438
|
-
var
|
|
148
|
+
var _jsxruntime = require('react/jsx-runtime');
|
|
2439
149
|
if (typeof HTMLElement !== "undefined") {
|
|
2440
|
-
class RemoteComponent extends HTMLElement {
|
|
2441
|
-
name = DEFAULT_COMPONENT_NAME
|
|
2442
|
-
bundle = DEFAULT_BUNDLE_NAME
|
|
2443
|
-
|
|
2444
|
-
__next = null
|
|
2445
|
-
fouc = null
|
|
2446
|
-
hostState = createHostState()
|
|
2447
|
-
root = null
|
|
2448
|
-
|
|
2449
|
-
|
|
2450
|
-
|
|
2451
|
-
|
|
150
|
+
class RemoteComponent extends HTMLElement {constructor(...args) { super(...args); RemoteComponent.prototype.__init.call(this);RemoteComponent.prototype.__init2.call(this);RemoteComponent.prototype.__init3.call(this);RemoteComponent.prototype.__init4.call(this);RemoteComponent.prototype.__init5.call(this);RemoteComponent.prototype.__init6.call(this);RemoteComponent.prototype.__init7.call(this); }
|
|
151
|
+
__init() {this.name = _chunkR4QFK5TNcjs.DEFAULT_COMPONENT_NAME}
|
|
152
|
+
__init2() {this.bundle = _chunkR4QFK5TNcjs.DEFAULT_BUNDLE_NAME}
|
|
153
|
+
|
|
154
|
+
__init3() {this.__next = null}
|
|
155
|
+
__init4() {this.fouc = null}
|
|
156
|
+
__init5() {this.hostState = _chunkER73O65Fcjs.createHostState.call(void 0, )}
|
|
157
|
+
__init6() {this.root = null}
|
|
158
|
+
|
|
159
|
+
__init7() {this.emitter = _chunkER73O65Fcjs.makeEventEmitter.call(void 0, this)}
|
|
160
|
+
|
|
161
|
+
|
|
162
|
+
|
|
2452
163
|
// -- ConsumeServerConfig property accessors (attribute-reflected) --
|
|
2453
164
|
get src() {
|
|
2454
|
-
return this.getAttribute("src")
|
|
165
|
+
return _nullishCoalesce(this.getAttribute("src"), () => ( void 0));
|
|
2455
166
|
}
|
|
2456
167
|
set src(value) {
|
|
2457
168
|
if (value == null) {
|
|
@@ -2496,22 +207,15 @@ if (typeof HTMLElement !== "undefined") {
|
|
|
2496
207
|
static get observedAttributes() {
|
|
2497
208
|
return ["src", "name", "mode"];
|
|
2498
209
|
}
|
|
2499
|
-
dispatchLifecycleEvent(type, detail) {
|
|
2500
|
-
const event = new Event(type, { bubbles: true, composed: true });
|
|
2501
|
-
if (detail) {
|
|
2502
|
-
Object.assign(event, detail);
|
|
2503
|
-
}
|
|
2504
|
-
this.dispatchEvent(event);
|
|
2505
|
-
}
|
|
2506
210
|
attributeChangedCallback(name, oldValue, newValue) {
|
|
2507
211
|
if ((name === "src" || name === "name") && oldValue !== newValue) {
|
|
2508
212
|
if (this.src) {
|
|
2509
213
|
this.load().catch((e) => {
|
|
2510
|
-
if (isAbortError(e)) {
|
|
214
|
+
if (_chunkRUWR74XQcjs.isAbortError.call(void 0, e)) {
|
|
2511
215
|
return;
|
|
2512
216
|
}
|
|
2513
|
-
logError("HtmlHost", "Error loading remote component.", e);
|
|
2514
|
-
this.
|
|
217
|
+
_chunkRUWR74XQcjs.logError.call(void 0, "HtmlHost", "Error loading remote component.", e);
|
|
218
|
+
this.emitter.error(e, this.src);
|
|
2515
219
|
this.hostState.stage = "error";
|
|
2516
220
|
});
|
|
2517
221
|
}
|
|
@@ -2524,11 +228,11 @@ if (typeof HTMLElement !== "undefined") {
|
|
|
2524
228
|
});
|
|
2525
229
|
this.root = newRoot;
|
|
2526
230
|
this.load().catch((e) => {
|
|
2527
|
-
if (isAbortError(e)) {
|
|
231
|
+
if (_chunkRUWR74XQcjs.isAbortError.call(void 0, e)) {
|
|
2528
232
|
return;
|
|
2529
233
|
}
|
|
2530
|
-
logError("HtmlHost", "Error reloading remote component.", e);
|
|
2531
|
-
this.
|
|
234
|
+
_chunkRUWR74XQcjs.logError.call(void 0, "HtmlHost", "Error reloading remote component.", e);
|
|
235
|
+
this.emitter.error(e, this.src);
|
|
2532
236
|
});
|
|
2533
237
|
}
|
|
2534
238
|
}
|
|
@@ -2539,7 +243,7 @@ if (typeof HTMLElement !== "undefined") {
|
|
|
2539
243
|
});
|
|
2540
244
|
});
|
|
2541
245
|
if (this.hostState.stage === "loading") {
|
|
2542
|
-
this.hostState.abortController
|
|
246
|
+
_optionalChain([this, 'access', _16 => _16.hostState, 'access', _17 => _17.abortController, 'optionalAccess', _18 => _18.abort, 'call', _19 => _19()]);
|
|
2543
247
|
this.hostState.stage = "idle";
|
|
2544
248
|
if (this.root && !this.reactRoot) {
|
|
2545
249
|
this.root.innerHTML = "";
|
|
@@ -2562,50 +266,50 @@ if (typeof HTMLElement !== "undefined") {
|
|
|
2562
266
|
const signal = this.hostState.abortController.signal;
|
|
2563
267
|
const isCurrentLoad = () => !signal.aborted && this.src === src;
|
|
2564
268
|
const abandonLoad = () => {
|
|
2565
|
-
if (this.hostState.abortController
|
|
269
|
+
if (_optionalChain([this, 'access', _20 => _20.hostState, 'access', _21 => _21.abortController, 'optionalAccess', _22 => _22.signal]) === signal && this.hostState.stage === "loading") {
|
|
2566
270
|
this.hostState.stage = "idle";
|
|
2567
271
|
}
|
|
2568
272
|
};
|
|
2569
|
-
this.
|
|
273
|
+
this.emitter.beforeLoad(_nullishCoalesce(src, () => ( "")));
|
|
2570
274
|
const remoteComponentChild = this.querySelector("div#__REMOTE_COMPONENT__") || this.querySelector("div[data-bundle][data-route]");
|
|
2571
275
|
if (!src && !remoteComponentChild) {
|
|
2572
|
-
throw new RemoteComponentsError('"src" attribute is required');
|
|
276
|
+
throw new (0, _chunkRUWR74XQcjs.RemoteComponentsError)('"src" attribute is required');
|
|
2573
277
|
}
|
|
2574
278
|
let url = null;
|
|
2575
279
|
let html = this.innerHTML;
|
|
2576
280
|
if (src) {
|
|
2577
|
-
url = getClientOrServerUrl(src, window.location.href);
|
|
2578
|
-
this.name = resolveNameFromSrc(src, this.name);
|
|
281
|
+
url = _chunkER73O65Fcjs.getClientOrServerUrl.call(void 0, src, window.location.href);
|
|
282
|
+
this.name = _chunkER73O65Fcjs.resolveNameFromSrc.call(void 0, src, this.name);
|
|
2579
283
|
}
|
|
2580
|
-
const resolveClientUrl = url ? bindResolveClientUrl(this.resolveClientUrl, url.href) : void 0;
|
|
284
|
+
const resolveClientUrl = url ? _chunkER73O65Fcjs.bindResolveClientUrl.call(void 0, this.resolveClientUrl, url.href) : void 0;
|
|
2581
285
|
if (!remoteComponentChild && url) {
|
|
2582
286
|
const fetchInit = {
|
|
2583
287
|
credentials: this.credentials || "same-origin"
|
|
2584
288
|
};
|
|
2585
289
|
const resolvedUrl = new URL(
|
|
2586
|
-
resolveClientUrl
|
|
290
|
+
_nullishCoalesce(_optionalChain([resolveClientUrl, 'optionalCall', _23 => _23(url.href)]), () => ( url.href)),
|
|
2587
291
|
window.location.href
|
|
2588
292
|
);
|
|
2589
293
|
let res;
|
|
2590
294
|
try {
|
|
2591
|
-
res = await fetchWithHooks(resolvedUrl, fetchInit, {
|
|
295
|
+
res = await _chunkER73O65Fcjs.fetchWithHooks.call(void 0, resolvedUrl, fetchInit, {
|
|
2592
296
|
onRequest: this.onRequest,
|
|
2593
297
|
onResponse: this.onResponse,
|
|
2594
298
|
abortController: this.hostState.abortController
|
|
2595
299
|
});
|
|
2596
300
|
} catch (e) {
|
|
2597
|
-
if (isAbortError(e)) {
|
|
301
|
+
if (_chunkRUWR74XQcjs.isAbortError.call(void 0, e)) {
|
|
2598
302
|
return abandonLoad();
|
|
2599
303
|
}
|
|
2600
304
|
throw e;
|
|
2601
305
|
}
|
|
2602
306
|
if (!res || !res.ok) {
|
|
2603
|
-
throw await errorFromFailedFetch(url.href, resolvedUrl, res);
|
|
307
|
+
throw await _chunkRUWR74XQcjs.errorFromFailedFetch.call(void 0, url.href, resolvedUrl, res);
|
|
2604
308
|
}
|
|
2605
309
|
try {
|
|
2606
310
|
html = await res.text();
|
|
2607
311
|
} catch (e) {
|
|
2608
|
-
if (isAbortError(e)) {
|
|
312
|
+
if (_chunkRUWR74XQcjs.isAbortError.call(void 0, e)) {
|
|
2609
313
|
return abandonLoad();
|
|
2610
314
|
}
|
|
2611
315
|
throw e;
|
|
@@ -2614,13 +318,14 @@ if (typeof HTMLElement !== "undefined") {
|
|
|
2614
318
|
return abandonLoad();
|
|
2615
319
|
}
|
|
2616
320
|
}
|
|
2617
|
-
const
|
|
2618
|
-
const doc =
|
|
2619
|
-
|
|
2620
|
-
|
|
2621
|
-
|
|
2622
|
-
|
|
2623
|
-
|
|
321
|
+
const effectiveUrl = _nullishCoalesce(url, () => ( new URL(window.location.href)));
|
|
322
|
+
const { doc, parsed } = _chunkER73O65Fcjs.preparePipeline.call(void 0, {
|
|
323
|
+
html,
|
|
324
|
+
name: this.name,
|
|
325
|
+
url: effectiveUrl,
|
|
326
|
+
shared: {},
|
|
327
|
+
resolveClientUrl
|
|
328
|
+
});
|
|
2624
329
|
const {
|
|
2625
330
|
component,
|
|
2626
331
|
name: resolvedName,
|
|
@@ -2638,7 +343,7 @@ if (typeof HTMLElement !== "undefined") {
|
|
|
2638
343
|
this.name = resolvedName;
|
|
2639
344
|
this.bundle = parsedMetadata.bundle;
|
|
2640
345
|
if (url) {
|
|
2641
|
-
getNamespace().bundleUrls[this.bundle] = url;
|
|
346
|
+
_chunk7MVFHOIPcjs.getNamespace.call(void 0, ).bundleUrls[this.bundle] = url;
|
|
2642
347
|
}
|
|
2643
348
|
const metadataEl = document.createElement("script");
|
|
2644
349
|
metadataEl.type = "application/json";
|
|
@@ -2650,27 +355,22 @@ if (typeof HTMLElement !== "undefined") {
|
|
|
2650
355
|
runtime: parsedMetadata.runtime
|
|
2651
356
|
};
|
|
2652
357
|
metadataEl.textContent = JSON.stringify(metadataObj);
|
|
2653
|
-
if (this.previousElementSibling
|
|
2654
|
-
this.previousElementSibling
|
|
2655
|
-
}
|
|
2656
|
-
this.parentElement?.insertBefore(metadataEl, this);
|
|
2657
|
-
if ("__remote_components_missing_shared__" in remoteShared) {
|
|
2658
|
-
throw new RemoteComponentsError(
|
|
2659
|
-
remoteShared.__remote_components_missing_shared__
|
|
2660
|
-
);
|
|
358
|
+
if (_optionalChain([this, 'access', _24 => _24.previousElementSibling, 'optionalAccess', _25 => _25.getAttribute, 'call', _26 => _26("data-remote-component")]) !== null) {
|
|
359
|
+
_optionalChain([this, 'access', _27 => _27.previousElementSibling, 'optionalAccess', _28 => _28.remove, 'call', _29 => _29()]);
|
|
2661
360
|
}
|
|
361
|
+
_optionalChain([this, 'access', _30 => _30.parentElement, 'optionalAccess', _31 => _31.insertBefore, 'call', _32 => _32(metadataEl, this)]);
|
|
2662
362
|
if (this.hostState.prevIsRemoteComponent) {
|
|
2663
363
|
if (this.hostState.prevUrl) {
|
|
2664
364
|
const prevUrl = this.hostState.prevUrl;
|
|
2665
|
-
const nsUnmount = getNamespace();
|
|
365
|
+
const nsUnmount = _chunk7MVFHOIPcjs.getNamespace.call(void 0, );
|
|
2666
366
|
if (nsUnmount.unmountFns[prevUrl.href]) {
|
|
2667
367
|
await Promise.all(
|
|
2668
|
-
Array.from(nsUnmount.unmountFns[prevUrl.href]
|
|
368
|
+
Array.from(_nullishCoalesce(nsUnmount.unmountFns[prevUrl.href], () => ( []))).map(
|
|
2669
369
|
async (unmount) => {
|
|
2670
370
|
try {
|
|
2671
371
|
await unmount(this.root);
|
|
2672
372
|
} catch (e) {
|
|
2673
|
-
logError(
|
|
373
|
+
_chunkRUWR74XQcjs.logError.call(void 0,
|
|
2674
374
|
"HtmlHost",
|
|
2675
375
|
`Error while calling unmount() for Remote Component from ${prevUrl.href}.`,
|
|
2676
376
|
e
|
|
@@ -2687,14 +387,14 @@ if (typeof HTMLElement !== "undefined") {
|
|
|
2687
387
|
this.root.innerHTML = "";
|
|
2688
388
|
}
|
|
2689
389
|
if (this.hostState.prevSrc !== void 0) {
|
|
2690
|
-
this.
|
|
2691
|
-
previousSrc: this.hostState.prevSrc,
|
|
2692
|
-
nextSrc: src,
|
|
390
|
+
this.emitter.change({
|
|
391
|
+
previousSrc: _nullishCoalesce(this.hostState.prevSrc, () => ( null)),
|
|
392
|
+
nextSrc: _nullishCoalesce(src, () => ( null)),
|
|
2693
393
|
previousName: this.hostState.prevName,
|
|
2694
394
|
nextName: this.name
|
|
2695
395
|
});
|
|
2696
396
|
}
|
|
2697
|
-
this.hostState.prevUrl =
|
|
397
|
+
this.hostState.prevUrl = effectiveUrl;
|
|
2698
398
|
this.hostState.prevIsRemoteComponent = isRemoteComponent;
|
|
2699
399
|
this.hostState.prevSrc = src;
|
|
2700
400
|
this.hostState.prevName = this.name;
|
|
@@ -2707,9 +407,9 @@ if (typeof HTMLElement !== "undefined") {
|
|
|
2707
407
|
links,
|
|
2708
408
|
signal: void 0,
|
|
2709
409
|
// Effects run after load, no abort needed
|
|
2710
|
-
baseUrl: url
|
|
410
|
+
baseUrl: _optionalChain([url, 'optionalAccess', _33 => _33.href]),
|
|
2711
411
|
remoteComponentSrc,
|
|
2712
|
-
root: this.root
|
|
412
|
+
root: _nullishCoalesce(this.root, () => ( null)),
|
|
2713
413
|
resolveClientUrl
|
|
2714
414
|
});
|
|
2715
415
|
if (!this.reactRoot) {
|
|
@@ -2718,7 +418,7 @@ if (typeof HTMLElement !== "undefined") {
|
|
|
2718
418
|
component,
|
|
2719
419
|
links,
|
|
2720
420
|
signal,
|
|
2721
|
-
baseUrl: url
|
|
421
|
+
baseUrl: _optionalChain([url, 'optionalAccess', _34 => _34.href]),
|
|
2722
422
|
remoteComponentSrc,
|
|
2723
423
|
root: this.root,
|
|
2724
424
|
resolveClientUrl
|
|
@@ -2727,11 +427,6 @@ if (typeof HTMLElement !== "undefined") {
|
|
|
2727
427
|
return abandonLoad();
|
|
2728
428
|
}
|
|
2729
429
|
}
|
|
2730
|
-
applyOriginToNodes(
|
|
2731
|
-
doc,
|
|
2732
|
-
url ?? new URL(window.location.href),
|
|
2733
|
-
resolveClientUrl
|
|
2734
|
-
);
|
|
2735
430
|
if (!this.reactRoot) {
|
|
2736
431
|
Array.from(component.children).forEach((el) => {
|
|
2737
432
|
if (!isRemoteComponent && el.tagName.toLowerCase() === "script") {
|
|
@@ -2740,11 +435,11 @@ if (typeof HTMLElement !== "undefined") {
|
|
|
2740
435
|
if (attr.name === "src") {
|
|
2741
436
|
const absoluteSrc = new URL(
|
|
2742
437
|
attr.value,
|
|
2743
|
-
url
|
|
438
|
+
_nullishCoalesce(url, () => ( window.location.origin))
|
|
2744
439
|
).href;
|
|
2745
440
|
newScript.setAttribute(
|
|
2746
441
|
attr.name,
|
|
2747
|
-
resolveClientUrl
|
|
442
|
+
_nullishCoalesce(_optionalChain([resolveClientUrl, 'optionalCall', _35 => _35(absoluteSrc)]), () => ( absoluteSrc))
|
|
2748
443
|
);
|
|
2749
444
|
} else {
|
|
2750
445
|
newScript.setAttribute(attr.name, attr.value);
|
|
@@ -2757,7 +452,7 @@ if (typeof HTMLElement !== "undefined") {
|
|
|
2757
452
|
remoteComponentSrc
|
|
2758
453
|
);
|
|
2759
454
|
}
|
|
2760
|
-
this.root
|
|
455
|
+
_optionalChain([this, 'access', _36 => _36.root, 'optionalAccess', _37 => _37.appendChild, 'call', _38 => _38(newScript)]);
|
|
2761
456
|
} else {
|
|
2762
457
|
const newEl = el.cloneNode(true);
|
|
2763
458
|
for (const attr of el.attributes) {
|
|
@@ -2765,16 +460,16 @@ if (typeof HTMLElement !== "undefined") {
|
|
|
2765
460
|
newEl.setAttribute(attr.name, attr.value);
|
|
2766
461
|
}
|
|
2767
462
|
}
|
|
2768
|
-
this.root
|
|
463
|
+
_optionalChain([this, 'access', _39 => _39.root, 'optionalAccess', _40 => _40.appendChild, 'call', _41 => _41(newEl)]);
|
|
2769
464
|
}
|
|
2770
465
|
});
|
|
2771
466
|
}
|
|
2772
467
|
for (const el of removable) {
|
|
2773
|
-
el.parentElement
|
|
468
|
+
_optionalChain([el, 'access', _42 => _42.parentElement, 'optionalAccess', _43 => _43.removeChild, 'call', _44 => _44(el)]);
|
|
2774
469
|
}
|
|
2775
|
-
this.fallbackSlot
|
|
470
|
+
_optionalChain([this, 'access', _45 => _45.fallbackSlot, 'optionalAccess', _46 => _46.remove, 'call', _47 => _47()]);
|
|
2776
471
|
const applyReset = () => {
|
|
2777
|
-
if (this.reset && !this.root
|
|
472
|
+
if (this.reset && !_optionalChain([this, 'access', _48 => _48.root, 'optionalAccess', _49 => _49.querySelector, 'call', _50 => _50("link[data-remote-components-reset]")])) {
|
|
2778
473
|
const allInitial = document.createElement("link");
|
|
2779
474
|
allInitial.setAttribute("data-remote-components-reset", "");
|
|
2780
475
|
const css = `:host { all: initial; }`;
|
|
@@ -2791,9 +486,9 @@ if (typeof HTMLElement !== "undefined") {
|
|
|
2791
486
|
URL.revokeObjectURL(allInitialHref);
|
|
2792
487
|
allInitial.removeAttribute("onload");
|
|
2793
488
|
};
|
|
2794
|
-
this.root
|
|
2795
|
-
} else if (!this.reset && this.root
|
|
2796
|
-
this.root.querySelector("link[data-remote-components-reset]")
|
|
489
|
+
_optionalChain([this, 'access', _51 => _51.root, 'optionalAccess', _52 => _52.prepend, 'call', _53 => _53(allInitial)]);
|
|
490
|
+
} else if (!this.reset && _optionalChain([this, 'access', _54 => _54.root, 'optionalAccess', _55 => _55.querySelector, 'call', _56 => _56("link[data-remote-components-reset]")])) {
|
|
491
|
+
_optionalChain([this, 'access', _57 => _57.root, 'access', _58 => _58.querySelector, 'call', _59 => _59("link[data-remote-components-reset]"), 'optionalAccess', _60 => _60.remove, 'call', _61 => _61()]);
|
|
2797
492
|
}
|
|
2798
493
|
};
|
|
2799
494
|
if (!this.reactRoot) {
|
|
@@ -2802,18 +497,18 @@ if (typeof HTMLElement !== "undefined") {
|
|
|
2802
497
|
const {
|
|
2803
498
|
self,
|
|
2804
499
|
createFromReadableStream,
|
|
2805
|
-
nextClientPagesLoader
|
|
500
|
+
nextClientPagesLoader,
|
|
2806
501
|
preloadScripts
|
|
2807
502
|
} = await getRuntime(
|
|
2808
503
|
metadataObj.runtime,
|
|
2809
|
-
|
|
504
|
+
effectiveUrl,
|
|
2810
505
|
this.bundle,
|
|
2811
506
|
{
|
|
2812
|
-
react: async () => (await
|
|
2813
|
-
"react/jsx-dev-runtime": async () => (await
|
|
2814
|
-
"react/jsx-runtime": async () => (await
|
|
2815
|
-
"react-dom": async () => (await
|
|
2816
|
-
"react-dom/client": async () => (await
|
|
507
|
+
react: async () => (await Promise.resolve().then(() => _interopRequireWildcard(require("react")))).default,
|
|
508
|
+
"react/jsx-dev-runtime": async () => (await Promise.resolve().then(() => _interopRequireWildcard(require("react/jsx-dev-runtime")))).default,
|
|
509
|
+
"react/jsx-runtime": async () => (await Promise.resolve().then(() => _interopRequireWildcard(require("react/jsx-runtime")))).default,
|
|
510
|
+
"react-dom": async () => (await Promise.resolve().then(() => _interopRequireWildcard(require("react-dom")))).default,
|
|
511
|
+
"react-dom/client": async () => (await Promise.resolve().then(() => _interopRequireWildcard(require("react-dom/client")))).default
|
|
2817
512
|
},
|
|
2818
513
|
remoteShared,
|
|
2819
514
|
resolveClientUrl
|
|
@@ -2826,7 +521,7 @@ if (typeof HTMLElement !== "undefined") {
|
|
|
2826
521
|
);
|
|
2827
522
|
if (!url) {
|
|
2828
523
|
url = new URL(
|
|
2829
|
-
component.getAttribute("data-route")
|
|
524
|
+
_nullishCoalesce(component.getAttribute("data-route"), () => ( "/")),
|
|
2830
525
|
window.location.href
|
|
2831
526
|
);
|
|
2832
527
|
}
|
|
@@ -2856,30 +551,30 @@ if (typeof HTMLElement !== "undefined") {
|
|
|
2856
551
|
}
|
|
2857
552
|
};
|
|
2858
553
|
if (rsc) {
|
|
2859
|
-
rsc.parentElement
|
|
2860
|
-
const rscName = `__remote_component_rsc_${escapeString(
|
|
554
|
+
_optionalChain([rsc, 'access', _62 => _62.parentElement, 'optionalAccess', _63 => _63.removeChild, 'call', _64 => _64(rsc)]);
|
|
555
|
+
const rscName = `__remote_component_rsc_${_chunkR4QFK5TNcjs.escapeString.call(void 0,
|
|
2861
556
|
url.href
|
|
2862
|
-
)}_${escapeString(this.name)}`;
|
|
557
|
+
)}_${_chunkR4QFK5TNcjs.escapeString.call(void 0, this.name)}`;
|
|
2863
558
|
const rscClone = document.createElement("script");
|
|
2864
559
|
rscClone.id = `${rscName}_rsc`;
|
|
2865
|
-
rscClone.textContent = rsc.textContent
|
|
560
|
+
rscClone.textContent = _nullishCoalesce(_optionalChain([rsc, 'access', _65 => _65.textContent, 'optionalAccess', _66 => _66.replace, 'call', _67 => _67(
|
|
2866
561
|
new RegExp(`self\\["${this.name}"\\]`, "g"),
|
|
2867
562
|
`self["${rscName}"]`
|
|
2868
|
-
)
|
|
563
|
+
)]), () => ( ""));
|
|
2869
564
|
document.body.appendChild(rscClone);
|
|
2870
565
|
let cache;
|
|
2871
566
|
const RemoteComponentFromReadableStream = ({
|
|
2872
567
|
name,
|
|
2873
568
|
initial
|
|
2874
569
|
}) => {
|
|
2875
|
-
const stream = createRSCStream(
|
|
570
|
+
const stream = _chunkER73O65Fcjs.createRSCStream.call(void 0,
|
|
2876
571
|
rscName,
|
|
2877
|
-
self[rscName]
|
|
2878
|
-
`]
|
|
572
|
+
_nullishCoalesce(self[rscName], () => ( [`0:[null]
|
|
573
|
+
`]))
|
|
2879
574
|
);
|
|
2880
|
-
const Component = cache
|
|
2881
|
-
(cache = createFromReadableStream(stream));
|
|
2882
|
-
(0,
|
|
575
|
+
const Component = _nullishCoalesce(cache, () => ( // cache the component to avoid reloading the RSC flight data
|
|
576
|
+
(cache = createFromReadableStream(stream))));
|
|
577
|
+
_react.useLayoutEffect.call(void 0, () => {
|
|
2883
578
|
if (self[name]) {
|
|
2884
579
|
delete self[name];
|
|
2885
580
|
}
|
|
@@ -2891,21 +586,21 @@ if (typeof HTMLElement !== "undefined") {
|
|
|
2891
586
|
applyReset();
|
|
2892
587
|
if (!initial) {
|
|
2893
588
|
doAttachStyles().catch((e) => {
|
|
2894
|
-
logError("HtmlHost", "Error attaching styles.", e);
|
|
589
|
+
_chunkRUWR74XQcjs.logError.call(void 0, "HtmlHost", "Error attaching styles.", e);
|
|
2895
590
|
});
|
|
2896
591
|
}
|
|
2897
592
|
if (isCurrentLoad()) {
|
|
2898
593
|
this.hostState.stage = "loaded";
|
|
2899
594
|
}
|
|
2900
|
-
this.
|
|
595
|
+
this.emitter.load(_nullishCoalesce(this.src, () => ( "")));
|
|
2901
596
|
}, [initial, name]);
|
|
2902
597
|
return Component;
|
|
2903
598
|
};
|
|
2904
599
|
if (this.reactRoot) {
|
|
2905
600
|
const root = this.reactRoot;
|
|
2906
|
-
(0,
|
|
601
|
+
_react.startTransition.call(void 0, () => {
|
|
2907
602
|
root.render(
|
|
2908
|
-
/* @__PURE__ */ (0,
|
|
603
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
2909
604
|
RemoteComponentFromReadableStream,
|
|
2910
605
|
{
|
|
2911
606
|
initial: false,
|
|
@@ -2916,41 +611,39 @@ if (typeof HTMLElement !== "undefined") {
|
|
|
2916
611
|
});
|
|
2917
612
|
return;
|
|
2918
613
|
}
|
|
2919
|
-
this.reactRoot = (0,
|
|
614
|
+
this.reactRoot = _client.hydrateRoot.call(void 0,
|
|
2920
615
|
// hydrateRoot expects a document or element, but it works for the shadow DOM too
|
|
2921
616
|
// @ts-expect-error support for shadow DOM
|
|
2922
617
|
this.root,
|
|
2923
|
-
/* @__PURE__ */ (0,
|
|
618
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, RemoteComponentFromReadableStream, { initial: true, name: this.name })
|
|
2924
619
|
);
|
|
2925
620
|
} else if (nextData) {
|
|
2926
|
-
const { Component, App } =
|
|
621
|
+
const { Component, App } = nextClientPagesLoader(
|
|
2927
622
|
this.bundle,
|
|
2928
|
-
nextData.page
|
|
623
|
+
_nullishCoalesce(nextData.page, () => ( "/")),
|
|
2929
624
|
this.root
|
|
2930
625
|
);
|
|
2931
626
|
if (Component) {
|
|
2932
627
|
const RemoteComponentFromNext = ((NextApp, NextComponent, remoteComponent = this) => function RemoteComponentNext({ initial }) {
|
|
2933
|
-
(0,
|
|
628
|
+
_react.useLayoutEffect.call(void 0, () => {
|
|
2934
629
|
doCleanup();
|
|
2935
630
|
if (!initial) {
|
|
2936
631
|
applyReset();
|
|
2937
632
|
doAttachStyles().catch((e) => {
|
|
2938
|
-
logError("HtmlHost", "Error attaching styles.", e);
|
|
633
|
+
_chunkRUWR74XQcjs.logError.call(void 0, "HtmlHost", "Error attaching styles.", e);
|
|
2939
634
|
});
|
|
2940
635
|
}
|
|
2941
636
|
if (isCurrentLoad()) {
|
|
2942
637
|
remoteComponent.hostState.stage = "loaded";
|
|
2943
638
|
}
|
|
2944
|
-
remoteComponent.
|
|
2945
|
-
src: remoteComponent.src
|
|
2946
|
-
});
|
|
639
|
+
remoteComponent.emitter.load(_nullishCoalesce(remoteComponent.src, () => ( "")));
|
|
2947
640
|
}, [initial, remoteComponent]);
|
|
2948
|
-
return NextApp ? /* @__PURE__ */ (0,
|
|
641
|
+
return NextApp ? /* @__PURE__ */ _jsxruntime.jsx.call(void 0, NextApp, { Component: NextComponent, ...nextData.props }) : /* @__PURE__ */ _jsxruntime.jsx.call(void 0, NextComponent, { ...nextData.props });
|
|
2949
642
|
})(App, Component, this);
|
|
2950
643
|
if (this.reactRoot) {
|
|
2951
644
|
const root = this.reactRoot;
|
|
2952
|
-
(0,
|
|
2953
|
-
root.render(/* @__PURE__ */ (0,
|
|
645
|
+
_react.startTransition.call(void 0, () => {
|
|
646
|
+
root.render(/* @__PURE__ */ _jsxruntime.jsx.call(void 0, RemoteComponentFromNext, { initial: false }));
|
|
2954
647
|
doCleanup();
|
|
2955
648
|
if (isCurrentLoad()) {
|
|
2956
649
|
this.hostState.stage = "loaded";
|
|
@@ -2958,24 +651,24 @@ if (typeof HTMLElement !== "undefined") {
|
|
|
2958
651
|
});
|
|
2959
652
|
return;
|
|
2960
653
|
}
|
|
2961
|
-
this.reactRoot = (0,
|
|
654
|
+
this.reactRoot = _client.hydrateRoot.call(void 0,
|
|
2962
655
|
// hydrateRoot expects a document or element, but it works for the shadow DOM too
|
|
2963
656
|
// @ts-expect-error support for shadow DOM
|
|
2964
657
|
this.root,
|
|
2965
|
-
/* @__PURE__ */ (0,
|
|
658
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, RemoteComponentFromNext, { initial: true })
|
|
2966
659
|
);
|
|
2967
660
|
}
|
|
2968
661
|
if (this.fouc) {
|
|
2969
662
|
this.root.removeChild(this.fouc);
|
|
2970
663
|
}
|
|
2971
|
-
} else if (getNamespace().mountFns[url.href]) {
|
|
664
|
+
} else if (_chunk7MVFHOIPcjs.getNamespace.call(void 0, ).mountFns[url.href]) {
|
|
2972
665
|
await Promise.all(
|
|
2973
|
-
Array.from(getNamespace().mountFns[url.href]
|
|
666
|
+
Array.from(_nullishCoalesce(_chunk7MVFHOIPcjs.getNamespace.call(void 0, ).mountFns[url.href], () => ( []))).map(
|
|
2974
667
|
async (mount) => {
|
|
2975
668
|
try {
|
|
2976
669
|
await mount(this.root);
|
|
2977
670
|
} catch (e) {
|
|
2978
|
-
logError(
|
|
671
|
+
_chunkRUWR74XQcjs.logError.call(void 0,
|
|
2979
672
|
"HtmlHost",
|
|
2980
673
|
`Error while calling mount() for Remote Component from ${url.href}.`,
|
|
2981
674
|
e
|
|
@@ -2984,9 +677,9 @@ if (typeof HTMLElement !== "undefined") {
|
|
|
2984
677
|
}
|
|
2985
678
|
)
|
|
2986
679
|
);
|
|
2987
|
-
this.
|
|
680
|
+
this.emitter.load(_nullishCoalesce(this.src, () => ( "")));
|
|
2988
681
|
} else {
|
|
2989
|
-
this.
|
|
682
|
+
this.emitter.load(_nullishCoalesce(this.src, () => ( "")));
|
|
2990
683
|
}
|
|
2991
684
|
if (isCurrentLoad()) {
|
|
2992
685
|
this.hostState.stage = "loaded";
|
|
@@ -2996,13 +689,12 @@ if (typeof HTMLElement !== "undefined") {
|
|
|
2996
689
|
customElements.define("remote-component", RemoteComponent);
|
|
2997
690
|
}
|
|
2998
691
|
function registerSharedModules(modules = {}) {
|
|
2999
|
-
const ns = getNamespace();
|
|
692
|
+
const ns = _chunk7MVFHOIPcjs.getNamespace.call(void 0, );
|
|
3000
693
|
Object.entries(modules).forEach(([key, value]) => {
|
|
3001
694
|
ns.hostSharedModules[key] = value;
|
|
3002
695
|
});
|
|
3003
696
|
}
|
|
3004
|
-
|
|
3005
|
-
|
|
3006
|
-
|
|
3007
|
-
});
|
|
697
|
+
|
|
698
|
+
|
|
699
|
+
exports.registerSharedModules = registerSharedModules;
|
|
3008
700
|
//# sourceMappingURL=html.cjs.map
|