remote-components 0.3.3 → 0.3.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/config/nextjs.cjs +86 -37
- package/dist/config/nextjs.cjs.map +1 -1
- package/dist/config/nextjs.js +86 -37
- package/dist/config/nextjs.js.map +1 -1
- package/dist/config/webpack.cjs +5 -1
- package/dist/config/webpack.cjs.map +1 -1
- package/dist/config/webpack.js +5 -1
- package/dist/config/webpack.js.map +1 -1
- package/dist/host/html.cjs +524 -338
- package/dist/host/html.cjs.map +1 -1
- package/dist/host/html.js +524 -338
- package/dist/host/html.js.map +1 -1
- package/dist/host/nextjs/app/client-only.cjs +462 -259
- package/dist/host/nextjs/app/client-only.cjs.map +1 -1
- package/dist/host/nextjs/app/client-only.js +436 -233
- package/dist/host/nextjs/app/client-only.js.map +1 -1
- package/dist/host/react.cjs +403 -228
- package/dist/host/react.cjs.map +1 -1
- package/dist/host/react.js +403 -228
- package/dist/host/react.js.map +1 -1
- package/dist/internal/config/webpack/apply-shared-modules.cjs +6 -4
- package/dist/internal/config/webpack/apply-shared-modules.cjs.map +1 -1
- package/dist/internal/config/webpack/apply-shared-modules.js +6 -4
- package/dist/internal/config/webpack/apply-shared-modules.js.map +1 -1
- package/dist/internal/config/webpack/next-client-pages-loader.cjs +6 -7
- package/dist/internal/config/webpack/next-client-pages-loader.cjs.map +1 -1
- package/dist/internal/config/webpack/next-client-pages-loader.js +6 -7
- package/dist/internal/config/webpack/next-client-pages-loader.js.map +1 -1
- package/dist/internal/host/nextjs/app-client.cjs +4 -3
- package/dist/internal/host/nextjs/app-client.cjs.map +1 -1
- package/dist/internal/host/nextjs/app-client.js +4 -3
- package/dist/internal/host/nextjs/app-client.js.map +1 -1
- package/dist/internal/host/nextjs/dom-flight.cjs +19 -39
- package/dist/internal/host/nextjs/dom-flight.cjs.map +1 -1
- package/dist/internal/host/nextjs/dom-flight.js +31 -39
- package/dist/internal/host/nextjs/dom-flight.js.map +1 -1
- package/dist/internal/host/nextjs/image-shared.cjs +39 -3
- package/dist/internal/host/nextjs/image-shared.cjs.map +1 -1
- package/dist/internal/host/nextjs/image-shared.d.ts +5 -10
- package/dist/internal/host/nextjs/image-shared.js +29 -3
- package/dist/internal/host/nextjs/image-shared.js.map +1 -1
- package/dist/internal/host/server/fetch-remote-component.cjs +2 -1
- package/dist/internal/host/server/fetch-remote-component.cjs.map +1 -1
- package/dist/internal/host/server/fetch-remote-component.js +2 -1
- package/dist/internal/host/server/fetch-remote-component.js.map +1 -1
- package/dist/internal/host/shared/polyfill.cjs +8 -7
- package/dist/internal/host/shared/polyfill.cjs.map +1 -1
- package/dist/internal/host/shared/polyfill.js +8 -7
- package/dist/internal/host/shared/polyfill.js.map +1 -1
- package/dist/internal/host/shared/shared-module-resolver.cjs +117 -0
- package/dist/internal/host/shared/shared-module-resolver.cjs.map +1 -0
- package/dist/internal/host/shared/shared-module-resolver.d.ts +64 -0
- package/dist/internal/host/shared/shared-module-resolver.js +78 -0
- package/dist/internal/host/shared/shared-module-resolver.js.map +1 -0
- package/dist/internal/remote/nextjs/next-internals.cjs +53 -0
- package/dist/internal/remote/nextjs/next-internals.cjs.map +1 -0
- package/dist/internal/remote/nextjs/next-internals.d.ts +42 -0
- package/dist/internal/remote/nextjs/next-internals.js +26 -0
- package/dist/internal/remote/nextjs/next-internals.js.map +1 -0
- package/dist/internal/runtime/html/apply-origin.cjs +11 -32
- package/dist/internal/runtime/html/apply-origin.cjs.map +1 -1
- package/dist/internal/runtime/html/apply-origin.js +11 -32
- package/dist/internal/runtime/html/apply-origin.js.map +1 -1
- package/dist/internal/runtime/html/html-spec.cjs +78 -0
- package/dist/internal/runtime/html/html-spec.cjs.map +1 -0
- package/dist/internal/runtime/html/html-spec.d.ts +23 -0
- package/dist/internal/runtime/html/html-spec.js +41 -0
- package/dist/internal/runtime/html/html-spec.js.map +1 -0
- package/dist/internal/runtime/html/parse-remote-html.cjs +15 -12
- package/dist/internal/runtime/html/parse-remote-html.cjs.map +1 -1
- package/dist/internal/runtime/html/parse-remote-html.js +29 -12
- package/dist/internal/runtime/html/parse-remote-html.js.map +1 -1
- package/dist/internal/runtime/html/rewrite-srcset.cjs +38 -0
- package/dist/internal/runtime/html/rewrite-srcset.cjs.map +1 -0
- package/dist/internal/runtime/html/rewrite-srcset.d.ts +12 -0
- package/dist/internal/runtime/html/rewrite-srcset.js +14 -0
- package/dist/internal/runtime/html/rewrite-srcset.js.map +1 -0
- package/dist/internal/runtime/loaders/component-loader.cjs +25 -44
- package/dist/internal/runtime/loaders/component-loader.cjs.map +1 -1
- package/dist/internal/runtime/loaders/component-loader.d.ts +3 -1
- package/dist/internal/runtime/loaders/component-loader.js +28 -44
- package/dist/internal/runtime/loaders/component-loader.js.map +1 -1
- package/dist/internal/runtime/loaders/static-loader.cjs +15 -21
- package/dist/internal/runtime/loaders/static-loader.cjs.map +1 -1
- package/dist/internal/runtime/loaders/static-loader.d.ts +3 -1
- package/dist/internal/runtime/loaders/static-loader.js +15 -21
- package/dist/internal/runtime/loaders/static-loader.js.map +1 -1
- package/dist/internal/runtime/namespace.cjs +82 -0
- package/dist/internal/runtime/namespace.cjs.map +1 -0
- package/dist/internal/runtime/namespace.d.ts +5 -0
- package/dist/internal/runtime/namespace.js +58 -0
- package/dist/internal/runtime/namespace.js.map +1 -0
- package/dist/internal/runtime/rsc-imports.cjs +86 -0
- package/dist/internal/runtime/rsc-imports.cjs.map +1 -0
- package/dist/internal/runtime/rsc-imports.d.ts +39 -0
- package/dist/internal/runtime/rsc-imports.js +50 -0
- package/dist/internal/runtime/rsc-imports.js.map +1 -0
- package/dist/internal/runtime/rsc-runtime.cjs +17 -0
- package/dist/internal/runtime/rsc-runtime.cjs.map +1 -0
- package/dist/internal/runtime/rsc-runtime.d.ts +37 -0
- package/dist/internal/runtime/rsc-runtime.js +1 -0
- package/dist/internal/runtime/rsc-runtime.js.map +1 -0
- package/dist/internal/runtime/rsc.cjs +23 -12
- package/dist/internal/runtime/rsc.cjs.map +1 -1
- package/dist/internal/runtime/rsc.d.ts +19 -2
- package/dist/internal/runtime/rsc.js +20 -11
- package/dist/internal/runtime/rsc.js.map +1 -1
- package/dist/internal/runtime/turbopack/chunk-loader.cjs +53 -35
- package/dist/internal/runtime/turbopack/chunk-loader.cjs.map +1 -1
- package/dist/internal/runtime/turbopack/chunk-loader.d.ts +1 -1
- package/dist/internal/runtime/turbopack/chunk-loader.js +53 -35
- package/dist/internal/runtime/turbopack/chunk-loader.js.map +1 -1
- package/dist/internal/runtime/turbopack/module.cjs +17 -4
- package/dist/internal/runtime/turbopack/module.cjs.map +1 -1
- package/dist/internal/runtime/turbopack/module.d.ts +23 -1
- package/dist/internal/runtime/turbopack/module.js +16 -4
- package/dist/internal/runtime/turbopack/module.js.map +1 -1
- package/dist/internal/runtime/turbopack/patterns.cjs +26 -10
- package/dist/internal/runtime/turbopack/patterns.cjs.map +1 -1
- package/dist/internal/runtime/turbopack/patterns.d.ts +44 -49
- package/dist/internal/runtime/turbopack/patterns.js +23 -7
- package/dist/internal/runtime/turbopack/patterns.js.map +1 -1
- package/dist/internal/runtime/turbopack/{webpack-runtime.cjs → remote-scope-setup.cjs} +35 -32
- package/dist/internal/runtime/turbopack/remote-scope-setup.cjs.map +1 -0
- package/dist/internal/runtime/turbopack/remote-scope-setup.d.ts +25 -0
- package/dist/internal/runtime/turbopack/{webpack-runtime.js → remote-scope-setup.js} +36 -19
- package/dist/internal/runtime/turbopack/remote-scope-setup.js.map +1 -0
- package/dist/internal/runtime/turbopack/remote-scope.cjs +4 -6
- package/dist/internal/runtime/turbopack/remote-scope.cjs.map +1 -1
- package/dist/internal/runtime/turbopack/remote-scope.d.ts +20 -1
- package/dist/internal/runtime/turbopack/remote-scope.js +4 -6
- package/dist/internal/runtime/turbopack/remote-scope.js.map +1 -1
- package/dist/internal/runtime/turbopack/shared-modules.cjs +21 -15
- package/dist/internal/runtime/turbopack/shared-modules.cjs.map +1 -1
- package/dist/internal/runtime/turbopack/shared-modules.d.ts +9 -2
- package/dist/internal/runtime/turbopack/shared-modules.js +24 -18
- package/dist/internal/runtime/turbopack/shared-modules.js.map +1 -1
- package/dist/internal/runtime/types.cjs.map +1 -1
- package/dist/internal/runtime/types.d.ts +5 -41
- package/dist/internal/utils/logger.cjs +1 -1
- package/dist/internal/utils/logger.cjs.map +1 -1
- package/dist/internal/utils/logger.d.ts +2 -2
- package/dist/internal/utils/logger.js +1 -1
- package/dist/internal/utils/logger.js.map +1 -1
- package/dist/remote/html.cjs +78 -22
- package/dist/remote/html.cjs.map +1 -1
- package/dist/remote/html.js +78 -22
- package/dist/remote/html.js.map +1 -1
- package/dist/remote/nextjs/app.cjs +14 -55
- package/dist/remote/nextjs/app.cjs.map +1 -1
- package/dist/remote/nextjs/app.js +24 -45
- package/dist/remote/nextjs/app.js.map +1 -1
- package/dist/types-59251814.d.ts +94 -0
- package/package.json +1 -1
- package/dist/internal/runtime/turbopack/webpack-runtime.cjs.map +0 -1
- package/dist/internal/runtime/turbopack/webpack-runtime.d.ts +0 -23
- package/dist/internal/runtime/turbopack/webpack-runtime.js.map +0 -1
package/dist/host/html.js
CHANGED
|
@@ -183,7 +183,7 @@ var init_logger = __esm({
|
|
|
183
183
|
init_constants();
|
|
184
184
|
init_error();
|
|
185
185
|
PREFIX = "remote-components";
|
|
186
|
-
DEBUG = typeof window !== "undefined" && localStorage.getItem("RC_DEBUG") === "true";
|
|
186
|
+
DEBUG = typeof window !== "undefined" && localStorage.getItem("RC_DEBUG") === "true" || typeof process !== "undefined" && process.env.RC_DEBUG === "true";
|
|
187
187
|
}
|
|
188
188
|
});
|
|
189
189
|
|
|
@@ -218,6 +218,152 @@ var init_constants2 = __esm({
|
|
|
218
218
|
}
|
|
219
219
|
});
|
|
220
220
|
|
|
221
|
+
// src/runtime/namespace.ts
|
|
222
|
+
function getNamespace() {
|
|
223
|
+
const g = globalThis;
|
|
224
|
+
const existing = g.__remote_components__;
|
|
225
|
+
if (existing) {
|
|
226
|
+
return existing;
|
|
227
|
+
}
|
|
228
|
+
const ns = {
|
|
229
|
+
scopes: /* @__PURE__ */ new Map(),
|
|
230
|
+
chunkCache: {},
|
|
231
|
+
mountFns: {},
|
|
232
|
+
unmountFns: {},
|
|
233
|
+
bundleUrls: {},
|
|
234
|
+
moduleRegistry: {},
|
|
235
|
+
dispatcherRuntime: void 0,
|
|
236
|
+
hostSharedModules: {},
|
|
237
|
+
cssCache: {},
|
|
238
|
+
shadowRoots: {}
|
|
239
|
+
};
|
|
240
|
+
const nsRecord = ns;
|
|
241
|
+
for (const { global, prop } of LEGACY_ALIASES) {
|
|
242
|
+
const legacyValue = g[global];
|
|
243
|
+
if (legacyValue != null) {
|
|
244
|
+
nsRecord[prop] = legacyValue;
|
|
245
|
+
}
|
|
246
|
+
g[global] = ns[prop];
|
|
247
|
+
}
|
|
248
|
+
const gRecord = g;
|
|
249
|
+
for (const key of Object.keys(gRecord)) {
|
|
250
|
+
if (key.startsWith(SHADOW_ROOT_PREFIX)) {
|
|
251
|
+
const suffix = key.slice(SHADOW_ROOT_PREFIX.length);
|
|
252
|
+
ns.shadowRoots[suffix] = gRecord[key];
|
|
253
|
+
delete gRecord[key];
|
|
254
|
+
}
|
|
255
|
+
}
|
|
256
|
+
g.__remote_components__ = ns;
|
|
257
|
+
return ns;
|
|
258
|
+
}
|
|
259
|
+
var SHADOW_ROOT_PREFIX, LEGACY_ALIASES;
|
|
260
|
+
var init_namespace = __esm({
|
|
261
|
+
"src/runtime/namespace.ts"() {
|
|
262
|
+
"use strict";
|
|
263
|
+
SHADOW_ROOT_PREFIX = "__remote_components_shadowroot_";
|
|
264
|
+
LEGACY_ALIASES = [
|
|
265
|
+
{ global: "__remote_component_scopes__", prop: "scopes" },
|
|
266
|
+
{
|
|
267
|
+
global: "__remote_components_turbopack_chunk_loader_promise__",
|
|
268
|
+
prop: "chunkCache"
|
|
269
|
+
},
|
|
270
|
+
{ global: "__remote_script_entrypoint_mount__", prop: "mountFns" },
|
|
271
|
+
{ global: "__remote_script_entrypoint_unmount__", prop: "unmountFns" },
|
|
272
|
+
{ global: "__remote_bundle_url__", prop: "bundleUrls" },
|
|
273
|
+
{ global: "__rc_module_registry__", prop: "moduleRegistry" },
|
|
274
|
+
{
|
|
275
|
+
global: "__remote_component_host_shared_modules__",
|
|
276
|
+
prop: "hostSharedModules"
|
|
277
|
+
},
|
|
278
|
+
{ global: "__remote_next_css__", prop: "cssCache" }
|
|
279
|
+
];
|
|
280
|
+
}
|
|
281
|
+
});
|
|
282
|
+
|
|
283
|
+
// src/runtime/patterns.ts
|
|
284
|
+
function collapseDoubleSlashes(path) {
|
|
285
|
+
return path.replace(DOUBLE_SLASH_RE, "/");
|
|
286
|
+
}
|
|
287
|
+
var REMOTE_COMPONENT_REGEX, NEXT_BUNDLE_PATH_RE, DOUBLE_SLASH_RE;
|
|
288
|
+
var init_patterns = __esm({
|
|
289
|
+
"src/runtime/patterns.ts"() {
|
|
290
|
+
"use strict";
|
|
291
|
+
REMOTE_COMPONENT_REGEX = /(?<prefix>.*?)\[(?<bundle>[^\]]+)\](?:%20| )(?<id>.+)/;
|
|
292
|
+
NEXT_BUNDLE_PATH_RE = /\/_next\/\[.+\](?:%20| )/;
|
|
293
|
+
DOUBLE_SLASH_RE = /(?<!:)\/\//g;
|
|
294
|
+
}
|
|
295
|
+
});
|
|
296
|
+
|
|
297
|
+
// src/runtime/turbopack/remote-scope.ts
|
|
298
|
+
function getRegistry() {
|
|
299
|
+
return getNamespace().scopes;
|
|
300
|
+
}
|
|
301
|
+
function createScope(name, url, runtime, resolveClientUrl) {
|
|
302
|
+
const isCrossOrigin = url.origin !== location.origin;
|
|
303
|
+
const scopedName = computeScopedName(name, {
|
|
304
|
+
remoteHost: url.host,
|
|
305
|
+
isCrossOrigin
|
|
306
|
+
});
|
|
307
|
+
const globalKey = getBundleKey(scopedName);
|
|
308
|
+
return {
|
|
309
|
+
name,
|
|
310
|
+
scopedName,
|
|
311
|
+
globalKey,
|
|
312
|
+
url,
|
|
313
|
+
runtime,
|
|
314
|
+
resolveClientUrl,
|
|
315
|
+
moduleCache: {},
|
|
316
|
+
sharedModules: {},
|
|
317
|
+
moduleGlobal: {},
|
|
318
|
+
turbopackModules: []
|
|
319
|
+
};
|
|
320
|
+
}
|
|
321
|
+
function registerScope(scope) {
|
|
322
|
+
const registry = getRegistry();
|
|
323
|
+
registry.set(scope.scopedName, scope);
|
|
324
|
+
if (scope.scopedName !== scope.name) {
|
|
325
|
+
const existing = registry.get(scope.name);
|
|
326
|
+
if (existing && existing.scopedName !== scope.scopedName) {
|
|
327
|
+
logWarn(
|
|
328
|
+
"RemoteScope",
|
|
329
|
+
`Plain name "${scope.name}" already registered by scope "${existing.scopedName}" \u2014 overwriting with "${scope.scopedName}". Static hosts will only resolve the latest one.`
|
|
330
|
+
);
|
|
331
|
+
}
|
|
332
|
+
registry.set(scope.name, scope);
|
|
333
|
+
}
|
|
334
|
+
logDebug(
|
|
335
|
+
"RemoteScope",
|
|
336
|
+
`Registered scope "${scope.scopedName}" (${registry.size} total)`
|
|
337
|
+
);
|
|
338
|
+
}
|
|
339
|
+
function getScope(name) {
|
|
340
|
+
return getRegistry().get(name);
|
|
341
|
+
}
|
|
342
|
+
function formatRemoteId(scope, path) {
|
|
343
|
+
return `[${scope.scopedName}] ${path}`;
|
|
344
|
+
}
|
|
345
|
+
function parseRemoteId(id) {
|
|
346
|
+
const groups = REMOTE_COMPONENT_REGEX.exec(id)?.groups;
|
|
347
|
+
if (groups?.bundle && groups.id) {
|
|
348
|
+
return {
|
|
349
|
+
bundle: groups.bundle,
|
|
350
|
+
path: groups.id,
|
|
351
|
+
prefix: groups.prefix ?? ""
|
|
352
|
+
};
|
|
353
|
+
}
|
|
354
|
+
return { bundle: "default", path: id, prefix: "" };
|
|
355
|
+
}
|
|
356
|
+
var init_remote_scope = __esm({
|
|
357
|
+
"src/runtime/turbopack/remote-scope.ts"() {
|
|
358
|
+
"use strict";
|
|
359
|
+
init_constants2();
|
|
360
|
+
init_namespace();
|
|
361
|
+
init_patterns();
|
|
362
|
+
init_utils();
|
|
363
|
+
init_logger();
|
|
364
|
+
}
|
|
365
|
+
});
|
|
366
|
+
|
|
221
367
|
// src/config/webpack/apply-shared-modules.ts
|
|
222
368
|
function applySharedModules(bundle, resolve) {
|
|
223
369
|
logDebug(
|
|
@@ -229,13 +375,15 @@ function applySharedModules(bundle, resolve) {
|
|
|
229
375
|
`Shared modules to resolve: ${Object.keys(resolve)}`
|
|
230
376
|
);
|
|
231
377
|
const self = globalThis;
|
|
232
|
-
|
|
378
|
+
const scope = getScope(bundle);
|
|
379
|
+
const webpackBundle = scope?.webpackRequire ?? self.__remote_webpack_require__?.[bundle];
|
|
380
|
+
if (webpackBundle) {
|
|
233
381
|
const modulePaths = Object.keys(
|
|
234
|
-
self.__remote_webpack_module_map__?.[bundle] ??
|
|
382
|
+
self.__remote_webpack_module_map__?.[bundle] ?? webpackBundle.m ?? {}
|
|
235
383
|
);
|
|
236
384
|
logDebug(
|
|
237
385
|
"SharedModules",
|
|
238
|
-
`Available module paths
|
|
386
|
+
`Available module paths for bundle "${bundle}": ${modulePaths}`
|
|
239
387
|
);
|
|
240
388
|
for (const [key, value] of Object.entries(resolve)) {
|
|
241
389
|
const exactIds = modulePaths.filter((p) => p === key);
|
|
@@ -247,7 +395,6 @@ function applySharedModules(bundle, resolve) {
|
|
|
247
395
|
);
|
|
248
396
|
}
|
|
249
397
|
for (const id of ids) {
|
|
250
|
-
const webpackBundle = self.__remote_webpack_require__[bundle];
|
|
251
398
|
if (webpackBundle.m) {
|
|
252
399
|
const resolvedId = self.__remote_webpack_module_map__?.[bundle]?.[id] ? `${self.__remote_webpack_module_map__[bundle][id]}` : id;
|
|
253
400
|
if (resolvedId !== id) {
|
|
@@ -282,6 +429,7 @@ var DEDUPLICATION_SKIPPED;
|
|
|
282
429
|
var init_apply_shared_modules = __esm({
|
|
283
430
|
"src/config/webpack/apply-shared-modules.ts"() {
|
|
284
431
|
"use strict";
|
|
432
|
+
init_remote_scope();
|
|
285
433
|
init_logger();
|
|
286
434
|
DEDUPLICATION_SKIPPED = "shared module deduplication skipped. The remote may load its own copy of shared dependencies.";
|
|
287
435
|
}
|
|
@@ -353,10 +501,8 @@ function nextClientPagesLoader(bundle, route, styleContainer = document.head) {
|
|
|
353
501
|
];
|
|
354
502
|
const { default: Component } = componentLoader();
|
|
355
503
|
const { default: App } = appLoader();
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
}
|
|
359
|
-
if (!self.__remote_next_css__[bundle]) {
|
|
504
|
+
const cssCache = getNamespace().cssCache;
|
|
505
|
+
if (!cssCache[bundle]) {
|
|
360
506
|
const cssRE = /\.s?css$/;
|
|
361
507
|
Object.keys(self.__remote_webpack_require__?.[bundle]?.m ?? {}).filter((id) => cssRE.test(id)).forEach((id) => {
|
|
362
508
|
self.__remote_webpack_require__?.[bundle]?.(id);
|
|
@@ -374,15 +520,15 @@ function nextClientPagesLoader(bundle, route, styleContainer = document.head) {
|
|
|
374
520
|
node.remove();
|
|
375
521
|
node = nextCss.previousSibling;
|
|
376
522
|
}
|
|
377
|
-
|
|
523
|
+
cssCache[bundle] = elements;
|
|
378
524
|
}
|
|
379
525
|
if (styleContainer) {
|
|
380
|
-
const elements =
|
|
526
|
+
const elements = cssCache[bundle];
|
|
381
527
|
elements.forEach((el) => {
|
|
382
528
|
styleContainer.appendChild(el.cloneNode(true));
|
|
383
529
|
});
|
|
384
530
|
} else {
|
|
385
|
-
const elements =
|
|
531
|
+
const elements = cssCache[bundle];
|
|
386
532
|
elements.forEach((el) => {
|
|
387
533
|
document.head.appendChild(el);
|
|
388
534
|
});
|
|
@@ -401,96 +547,11 @@ function nextClientPagesLoader(bundle, route, styleContainer = document.head) {
|
|
|
401
547
|
var init_next_client_pages_loader = __esm({
|
|
402
548
|
"src/config/webpack/next-client-pages-loader.ts"() {
|
|
403
549
|
"use strict";
|
|
550
|
+
init_namespace();
|
|
404
551
|
init_error();
|
|
405
552
|
}
|
|
406
553
|
});
|
|
407
554
|
|
|
408
|
-
// src/runtime/patterns.ts
|
|
409
|
-
function collapseDoubleSlashes(path) {
|
|
410
|
-
return path.replace(DOUBLE_SLASH_RE, "/");
|
|
411
|
-
}
|
|
412
|
-
var REMOTE_COMPONENT_REGEX, NEXT_BUNDLE_PATH_RE, DOUBLE_SLASH_RE;
|
|
413
|
-
var init_patterns = __esm({
|
|
414
|
-
"src/runtime/patterns.ts"() {
|
|
415
|
-
"use strict";
|
|
416
|
-
REMOTE_COMPONENT_REGEX = /(?<prefix>.*?)\[(?<bundle>[^\]]+)\](?:%20| )(?<id>.+)/;
|
|
417
|
-
NEXT_BUNDLE_PATH_RE = /\/_next\/\[.+\](?:%20| )/;
|
|
418
|
-
DOUBLE_SLASH_RE = /(?<!:)\/\//g;
|
|
419
|
-
}
|
|
420
|
-
});
|
|
421
|
-
|
|
422
|
-
// src/runtime/turbopack/remote-scope.ts
|
|
423
|
-
function getRegistry() {
|
|
424
|
-
const self = globalThis;
|
|
425
|
-
if (!self.__remote_component_scopes__) {
|
|
426
|
-
self.__remote_component_scopes__ = /* @__PURE__ */ new Map();
|
|
427
|
-
}
|
|
428
|
-
return self.__remote_component_scopes__;
|
|
429
|
-
}
|
|
430
|
-
function createScope(name, url, runtime, resolveClientUrl) {
|
|
431
|
-
const isCrossOrigin = url.origin !== location.origin;
|
|
432
|
-
const scopedName = computeScopedName(name, {
|
|
433
|
-
remoteHost: url.host,
|
|
434
|
-
isCrossOrigin
|
|
435
|
-
});
|
|
436
|
-
const globalKey = getBundleKey(scopedName);
|
|
437
|
-
return {
|
|
438
|
-
name,
|
|
439
|
-
scopedName,
|
|
440
|
-
globalKey,
|
|
441
|
-
url,
|
|
442
|
-
runtime,
|
|
443
|
-
resolveClientUrl,
|
|
444
|
-
moduleCache: {},
|
|
445
|
-
sharedModules: {},
|
|
446
|
-
moduleGlobal: {}
|
|
447
|
-
};
|
|
448
|
-
}
|
|
449
|
-
function registerScope(scope) {
|
|
450
|
-
const registry = getRegistry();
|
|
451
|
-
registry.set(scope.scopedName, scope);
|
|
452
|
-
if (scope.scopedName !== scope.name) {
|
|
453
|
-
const existing = registry.get(scope.name);
|
|
454
|
-
if (existing && existing.scopedName !== scope.scopedName) {
|
|
455
|
-
logWarn(
|
|
456
|
-
"RemoteScope",
|
|
457
|
-
`Plain name "${scope.name}" already registered by scope "${existing.scopedName}" \u2014 overwriting with "${scope.scopedName}". Static hosts will only resolve the latest one.`
|
|
458
|
-
);
|
|
459
|
-
}
|
|
460
|
-
registry.set(scope.name, scope);
|
|
461
|
-
}
|
|
462
|
-
logDebug(
|
|
463
|
-
"RemoteScope",
|
|
464
|
-
`Registered scope "${scope.scopedName}" (${registry.size} total)`
|
|
465
|
-
);
|
|
466
|
-
}
|
|
467
|
-
function getScope(name) {
|
|
468
|
-
return getRegistry().get(name);
|
|
469
|
-
}
|
|
470
|
-
function formatRemoteId(scope, path) {
|
|
471
|
-
return `[${scope.scopedName}] ${path}`;
|
|
472
|
-
}
|
|
473
|
-
function parseRemoteId(id) {
|
|
474
|
-
const groups = REMOTE_COMPONENT_REGEX.exec(id)?.groups;
|
|
475
|
-
if (groups?.bundle && groups.id) {
|
|
476
|
-
return {
|
|
477
|
-
bundle: groups.bundle,
|
|
478
|
-
path: groups.id,
|
|
479
|
-
prefix: groups.prefix ?? ""
|
|
480
|
-
};
|
|
481
|
-
}
|
|
482
|
-
return { bundle: "default", path: id, prefix: "" };
|
|
483
|
-
}
|
|
484
|
-
var init_remote_scope = __esm({
|
|
485
|
-
"src/runtime/turbopack/remote-scope.ts"() {
|
|
486
|
-
"use strict";
|
|
487
|
-
init_constants2();
|
|
488
|
-
init_patterns();
|
|
489
|
-
init_utils();
|
|
490
|
-
init_logger();
|
|
491
|
-
}
|
|
492
|
-
});
|
|
493
|
-
|
|
494
555
|
// src/host/shared/remote-image-loader.ts
|
|
495
556
|
function createRemoteImageLoader(bundle, resolveClientUrl) {
|
|
496
557
|
const loader = Object.assign(
|
|
@@ -523,9 +584,9 @@ var init_remote_image_loader = __esm({
|
|
|
523
584
|
// src/host/shared/polyfill.tsx
|
|
524
585
|
import { jsx } from "react/jsx-runtime";
|
|
525
586
|
function sharedPolyfills(shared, resolveClientUrl) {
|
|
526
|
-
const
|
|
587
|
+
const hostShared = getNamespace().hostSharedModules;
|
|
527
588
|
const polyfill = {
|
|
528
|
-
"next/dist/client/components/navigation":
|
|
589
|
+
"next/dist/client/components/navigation": hostShared["next/navigation"] ?? shared?.["next/navigation"] ?? (() => Promise.resolve({
|
|
529
590
|
useRouter() {
|
|
530
591
|
return {
|
|
531
592
|
push: (routerUrl) => {
|
|
@@ -556,7 +617,7 @@ function sharedPolyfills(shared, resolveClientUrl) {
|
|
|
556
617
|
},
|
|
557
618
|
__esModule: true
|
|
558
619
|
})),
|
|
559
|
-
"next/dist/client/app-dir/link":
|
|
620
|
+
"next/dist/client/app-dir/link": hostShared["next/link"] ?? shared?.["next/link"] ?? (() => Promise.resolve({
|
|
560
621
|
default: ({
|
|
561
622
|
scroll: _,
|
|
562
623
|
replace,
|
|
@@ -606,7 +667,7 @@ function sharedPolyfills(shared, resolveClientUrl) {
|
|
|
606
667
|
},
|
|
607
668
|
__esModule: true
|
|
608
669
|
})),
|
|
609
|
-
"next/dist/client/app-dir/form":
|
|
670
|
+
"next/dist/client/app-dir/form": hostShared["next/form"] ?? shared?.["next/form"] ?? (() => Promise.resolve({
|
|
610
671
|
default: () => {
|
|
611
672
|
throw new Error("Next.js <Form> component not implemented");
|
|
612
673
|
},
|
|
@@ -617,17 +678,17 @@ function sharedPolyfills(shared, resolveClientUrl) {
|
|
|
617
678
|
// This gives us full next/image fidelity (fill, priority, srcSet, blur
|
|
618
679
|
// placeholders, error handling) while routing image optimization through the
|
|
619
680
|
// remote app's /_next/image endpoint.
|
|
620
|
-
"next/dist/shared/lib/image-loader":
|
|
681
|
+
"next/dist/shared/lib/image-loader": hostShared["next/dist/shared/lib/image-loader"] ?? shared?.["next/dist/shared/lib/image-loader"] ?? ((bundle) => Promise.resolve({
|
|
621
682
|
default: createRemoteImageLoader(bundle, resolveClientUrl),
|
|
622
683
|
__esModule: true
|
|
623
684
|
})),
|
|
624
|
-
"next/dist/client/script":
|
|
685
|
+
"next/dist/client/script": hostShared["next/script"] ?? shared?.["next/script"] ?? (() => Promise.resolve({
|
|
625
686
|
// TODO: implement <Script> component for non-Next.js host applications
|
|
626
687
|
// do not throw an error for now
|
|
627
688
|
default: () => null,
|
|
628
689
|
__esModule: true
|
|
629
690
|
})),
|
|
630
|
-
"next/router":
|
|
691
|
+
"next/router": hostShared["next/router"] ?? shared?.["next/router"] ?? (() => (
|
|
631
692
|
// TODO: incomplete implementation
|
|
632
693
|
Promise.resolve({
|
|
633
694
|
useRouter() {
|
|
@@ -666,10 +727,81 @@ var init_polyfill = __esm({
|
|
|
666
727
|
"src/host/shared/polyfill.tsx"() {
|
|
667
728
|
"use strict";
|
|
668
729
|
init_remote_image_loader();
|
|
730
|
+
init_namespace();
|
|
669
731
|
init_logger();
|
|
670
732
|
}
|
|
671
733
|
});
|
|
672
734
|
|
|
735
|
+
// src/host/shared/shared-module-resolver.ts
|
|
736
|
+
function buildCoreShared(userShared) {
|
|
737
|
+
return {
|
|
738
|
+
react: async () => (await import("react")).default,
|
|
739
|
+
"react-dom": async () => (await import("react-dom")).default,
|
|
740
|
+
"react/jsx-dev-runtime": async () => (await import("react/jsx-dev-runtime")).default,
|
|
741
|
+
"react/jsx-runtime": async () => (await import("react/jsx-runtime")).default,
|
|
742
|
+
"react-dom/client": async () => (await import("react-dom/client")).default,
|
|
743
|
+
...userShared
|
|
744
|
+
};
|
|
745
|
+
}
|
|
746
|
+
function buildHostShared(userShared, resolveClientUrl, options) {
|
|
747
|
+
const self = globalThis;
|
|
748
|
+
const result = {
|
|
749
|
+
...sharedPolyfills(userShared, resolveClientUrl),
|
|
750
|
+
...self.__remote_component_host_shared_modules__,
|
|
751
|
+
...userShared
|
|
752
|
+
};
|
|
753
|
+
if (options?.includeRemoteComponentShared) {
|
|
754
|
+
Object.assign(result, self.__remote_component_shared__);
|
|
755
|
+
}
|
|
756
|
+
return result;
|
|
757
|
+
}
|
|
758
|
+
async function buildWebpackResolve(hostShared, remoteShared, bundle, reactModules, callerTag = "SharedModuleResolver") {
|
|
759
|
+
const resolve = {
|
|
760
|
+
...reactModules,
|
|
761
|
+
...Object.entries(remoteShared).reduce(
|
|
762
|
+
(acc, [key, value]) => {
|
|
763
|
+
if (typeof hostShared[value] !== "undefined") {
|
|
764
|
+
acc[key.replace(/^\(ssr\)\/(?<relative>\.\/)?/, "")] = hostShared[value];
|
|
765
|
+
} else {
|
|
766
|
+
logDebug(
|
|
767
|
+
callerTag,
|
|
768
|
+
`Remote requests "${value}" but host doesn't provide it`
|
|
769
|
+
);
|
|
770
|
+
}
|
|
771
|
+
return acc;
|
|
772
|
+
},
|
|
773
|
+
{}
|
|
774
|
+
)
|
|
775
|
+
};
|
|
776
|
+
await Promise.all(
|
|
777
|
+
Object.entries(resolve).map(async ([key, value]) => {
|
|
778
|
+
if (typeof value === "function") {
|
|
779
|
+
resolve[key] = await value(bundle);
|
|
780
|
+
}
|
|
781
|
+
return Promise.resolve(value);
|
|
782
|
+
})
|
|
783
|
+
);
|
|
784
|
+
return resolve;
|
|
785
|
+
}
|
|
786
|
+
var CORE_REACT_PATH_MAP, VENDOR_SHARED;
|
|
787
|
+
var init_shared_module_resolver = __esm({
|
|
788
|
+
"src/host/shared/shared-module-resolver.ts"() {
|
|
789
|
+
"use strict";
|
|
790
|
+
init_polyfill();
|
|
791
|
+
init_logger();
|
|
792
|
+
CORE_REACT_PATH_MAP = {
|
|
793
|
+
react: "/react/index.js",
|
|
794
|
+
"react/jsx-dev-runtime": "/react/jsx-dev-runtime.js",
|
|
795
|
+
"react/jsx-runtime": "/react/jsx-runtime.js",
|
|
796
|
+
"react-dom": "/react-dom/index.js",
|
|
797
|
+
"react-dom/client": "/react-dom/client.js"
|
|
798
|
+
};
|
|
799
|
+
VENDOR_SHARED = Object.fromEntries(
|
|
800
|
+
Object.entries(CORE_REACT_PATH_MAP).filter(([key]) => key !== "react-dom/client").map(([key, path]) => [key, `'${path}'`])
|
|
801
|
+
);
|
|
802
|
+
}
|
|
803
|
+
});
|
|
804
|
+
|
|
673
805
|
// src/runtime/loaders/script-loader.ts
|
|
674
806
|
async function loadScripts(scripts, resolveClientUrl) {
|
|
675
807
|
await Promise.all(
|
|
@@ -769,34 +901,19 @@ async function webpackRuntime(bundle, shared, remoteShared, resolveClientUrl) {
|
|
|
769
901
|
];
|
|
770
902
|
});
|
|
771
903
|
await loadScripts(scriptSrcs, resolveClientUrl);
|
|
772
|
-
const hostShared =
|
|
773
|
-
|
|
774
|
-
|
|
775
|
-
|
|
776
|
-
|
|
777
|
-
|
|
778
|
-
|
|
779
|
-
|
|
780
|
-
|
|
781
|
-
|
|
782
|
-
|
|
783
|
-
|
|
784
|
-
|
|
785
|
-
if (typeof hostShared[value] !== "undefined") {
|
|
786
|
-
acc[key.replace(/^\(ssr\)\/(?<relative>\.\/)?/, "")] = hostShared[value];
|
|
787
|
-
}
|
|
788
|
-
return acc;
|
|
789
|
-
},
|
|
790
|
-
{}
|
|
791
|
-
)
|
|
792
|
-
};
|
|
793
|
-
await Promise.all(
|
|
794
|
-
Object.entries(resolve).map(async ([key, value]) => {
|
|
795
|
-
if (typeof value === "function") {
|
|
796
|
-
resolve[key] = await value(remoteBundle);
|
|
797
|
-
}
|
|
798
|
-
return Promise.resolve(value);
|
|
799
|
-
})
|
|
904
|
+
const hostShared = buildHostShared(shared, resolveClientUrl);
|
|
905
|
+
const resolve = await buildWebpackResolve(
|
|
906
|
+
hostShared,
|
|
907
|
+
remoteShared ?? {},
|
|
908
|
+
remoteBundle,
|
|
909
|
+
{
|
|
910
|
+
"/react/index.js": (await import("react")).default,
|
|
911
|
+
"/react/jsx-dev-runtime.js": (await import("react/jsx-dev-runtime")).default,
|
|
912
|
+
"/react/jsx-runtime.js": (await import("react/jsx-runtime")).default,
|
|
913
|
+
"/react-dom/index.js": (await import("react-dom")).default,
|
|
914
|
+
"/react-dom/client.js": (await import("react-dom/client")).default
|
|
915
|
+
},
|
|
916
|
+
"WebpackRuntime"
|
|
800
917
|
);
|
|
801
918
|
applySharedModules(remoteBundle, resolve);
|
|
802
919
|
}
|
|
@@ -813,7 +930,7 @@ var init_webpack = __esm({
|
|
|
813
930
|
"use strict";
|
|
814
931
|
init_apply_shared_modules();
|
|
815
932
|
init_next_client_pages_loader();
|
|
816
|
-
|
|
933
|
+
init_shared_module_resolver();
|
|
817
934
|
init_script_loader();
|
|
818
935
|
init_patterns();
|
|
819
936
|
init_error();
|
|
@@ -821,15 +938,31 @@ var init_webpack = __esm({
|
|
|
821
938
|
});
|
|
822
939
|
|
|
823
940
|
// src/runtime/turbopack/patterns.ts
|
|
824
|
-
|
|
941
|
+
function stripQuotes(value) {
|
|
942
|
+
if (value.startsWith('"') && value.endsWith('"')) {
|
|
943
|
+
return value.slice(1, -1);
|
|
944
|
+
}
|
|
945
|
+
return value;
|
|
946
|
+
}
|
|
947
|
+
function extractGroup(re, input, group) {
|
|
948
|
+
const raw = re.exec(input)?.groups?.[group];
|
|
949
|
+
return raw ? stripQuotes(raw) : void 0;
|
|
950
|
+
}
|
|
951
|
+
var MODULE_ID_PATTERN, REMOTE_SHARED_MARKER_RE, REMOTE_SHARED_ASSIGNMENT_RE, ASYNC_MODULE_LOADER_RE, ASYNC_MODULE_CALLBACK_RE, TURBOPACK_GLOBAL_RE;
|
|
825
952
|
var init_patterns2 = __esm({
|
|
826
953
|
"src/runtime/turbopack/patterns.ts"() {
|
|
827
954
|
"use strict";
|
|
955
|
+
MODULE_ID_PATTERN = '"[^"]+"|[0-9]+';
|
|
828
956
|
REMOTE_SHARED_MARKER_RE = /(?:self|[a-z])\.TURBOPACK_REMOTE_SHARED/;
|
|
829
|
-
REMOTE_SHARED_ASSIGNMENT_RE =
|
|
830
|
-
|
|
831
|
-
|
|
832
|
-
|
|
957
|
+
REMOTE_SHARED_ASSIGNMENT_RE = new RegExp(
|
|
958
|
+
`\\.TURBOPACK_REMOTE_SHARED\\s*=\\s*await (?:__turbopack_context__|[a-z])\\.A\\((?<sharedModuleId>${MODULE_ID_PATTERN})\\)`
|
|
959
|
+
);
|
|
960
|
+
ASYNC_MODULE_LOADER_RE = new RegExp(
|
|
961
|
+
`(?:__turbopack_context__|e)\\.A\\((?<asyncSharedModuleId>${MODULE_ID_PATTERN})\\)`
|
|
962
|
+
);
|
|
963
|
+
ASYNC_MODULE_CALLBACK_RE = new RegExp(
|
|
964
|
+
`(?:parentImport|[a-z])\\((?<sharedModuleId>${MODULE_ID_PATTERN})\\)`
|
|
965
|
+
);
|
|
833
966
|
TURBOPACK_GLOBAL_RE = /(?:globalThis|self)\s*(?:\.TURBOPACK|\[\s*["']TURBOPACK["']\s*\])/;
|
|
834
967
|
}
|
|
835
968
|
});
|
|
@@ -841,6 +974,7 @@ function loadChunkWithScope(scope, chunkId) {
|
|
|
841
974
|
`loadChunkWithScope: "${chunkId}" (scope: "${scope.scopedName}")`
|
|
842
975
|
);
|
|
843
976
|
const self = globalThis;
|
|
977
|
+
const ns = getNamespace();
|
|
844
978
|
const { bundle, path, prefix } = parseRemoteId(chunkId);
|
|
845
979
|
const remoteRuntime = self.__remote_webpack_require__?.[bundle ?? "default"] ? self.__remote_webpack_require__[bundle ?? "default"]?.type || "webpack" : scope.runtime;
|
|
846
980
|
if (remoteRuntime === RUNTIME_WEBPACK) {
|
|
@@ -851,35 +985,31 @@ function loadChunkWithScope(scope, chunkId) {
|
|
|
851
985
|
if (url.endsWith(".css")) {
|
|
852
986
|
return;
|
|
853
987
|
}
|
|
854
|
-
if (
|
|
855
|
-
|
|
856
|
-
|
|
857
|
-
if (self.__remote_components_turbopack_chunk_loader_promise__[url]) {
|
|
858
|
-
return self.__remote_components_turbopack_chunk_loader_promise__[url];
|
|
988
|
+
if (ns.chunkCache[url]) {
|
|
989
|
+
logDebug("ChunkLoader", `Cache hit for "${chunkId}" (url="${url}")`);
|
|
990
|
+
return ns.chunkCache[url];
|
|
859
991
|
}
|
|
860
992
|
const resolvedUrl = scope.resolveClientUrl?.(url) ?? url;
|
|
861
993
|
if (resolvedUrl !== url) {
|
|
862
994
|
logDebug("ChunkLoader", `Proxied chunk URL: "${url}" \u2192 "${resolvedUrl}"`);
|
|
863
995
|
}
|
|
864
|
-
|
|
865
|
-
(
|
|
866
|
-
|
|
867
|
-
|
|
868
|
-
|
|
869
|
-
|
|
870
|
-
|
|
871
|
-
|
|
872
|
-
|
|
873
|
-
|
|
874
|
-
|
|
875
|
-
|
|
876
|
-
|
|
877
|
-
|
|
878
|
-
|
|
879
|
-
|
|
880
|
-
|
|
881
|
-
);
|
|
882
|
-
return self.__remote_components_turbopack_chunk_loader_promise__[url];
|
|
996
|
+
ns.chunkCache[url] = new Promise((resolve, reject) => {
|
|
997
|
+
fetch(resolvedUrl).then((res) => res.text()).then((code) => {
|
|
998
|
+
const hasTurbopack = TURBOPACK_GLOBAL_RE.test(code);
|
|
999
|
+
if (hasTurbopack) {
|
|
1000
|
+
return handleTurbopackChunk(code, scope, url);
|
|
1001
|
+
}
|
|
1002
|
+
}).then(resolve).catch((error) => {
|
|
1003
|
+
const isProxied = isProxiedUrl(resolvedUrl);
|
|
1004
|
+
if (isProxied) {
|
|
1005
|
+
reject(failedProxiedAssetError("chunk", url, resolvedUrl));
|
|
1006
|
+
} else {
|
|
1007
|
+
warnCrossOriginFetchError("ChunkLoader", url);
|
|
1008
|
+
reject(error);
|
|
1009
|
+
}
|
|
1010
|
+
});
|
|
1011
|
+
});
|
|
1012
|
+
return ns.chunkCache[url];
|
|
883
1013
|
}
|
|
884
1014
|
function createChunkDispatcher() {
|
|
885
1015
|
return function __chunk_dispatcher__(chunkId, scriptBundle) {
|
|
@@ -928,19 +1058,39 @@ async function handleTurbopackChunk(code, scope, url) {
|
|
|
928
1058
|
`//# sourceMappingURL=${new URL(".", new URL(url, scope.url)).href}$1$2.js.map`
|
|
929
1059
|
);
|
|
930
1060
|
if (!self[`TURBOPACK_${globalKey}`]) {
|
|
931
|
-
const
|
|
932
|
-
|
|
933
|
-
|
|
934
|
-
|
|
935
|
-
|
|
936
|
-
|
|
937
|
-
|
|
1061
|
+
const wrapPush = (target) => {
|
|
1062
|
+
const originalPush = target.push;
|
|
1063
|
+
if (typeof originalPush !== "function")
|
|
1064
|
+
return target;
|
|
1065
|
+
target.push = (...items) => {
|
|
1066
|
+
for (const item of items) {
|
|
1067
|
+
if (Array.isArray(item)) {
|
|
1068
|
+
for (const entry of item) {
|
|
1069
|
+
scope.turbopackModules.push(entry);
|
|
1070
|
+
}
|
|
1071
|
+
} else {
|
|
1072
|
+
scope.turbopackModules.push(item);
|
|
1073
|
+
}
|
|
938
1074
|
}
|
|
939
|
-
return
|
|
940
|
-
}
|
|
941
|
-
|
|
1075
|
+
return originalPush.apply(target, items);
|
|
1076
|
+
};
|
|
1077
|
+
return target;
|
|
942
1078
|
};
|
|
943
|
-
|
|
1079
|
+
const globalProp = `TURBOPACK_${globalKey}`;
|
|
1080
|
+
let currentValue = wrapPush([]);
|
|
1081
|
+
Object.defineProperty(self, globalProp, {
|
|
1082
|
+
get() {
|
|
1083
|
+
return currentValue;
|
|
1084
|
+
},
|
|
1085
|
+
set(newValue) {
|
|
1086
|
+
if (newValue && typeof newValue === "object") {
|
|
1087
|
+
wrapPush(newValue);
|
|
1088
|
+
}
|
|
1089
|
+
currentValue = newValue;
|
|
1090
|
+
},
|
|
1091
|
+
configurable: true,
|
|
1092
|
+
enumerable: true
|
|
1093
|
+
});
|
|
944
1094
|
}
|
|
945
1095
|
await new Promise((scriptResolve, scriptReject) => {
|
|
946
1096
|
const blob = new Blob([transformedCode], {
|
|
@@ -992,6 +1142,7 @@ var init_chunk_loader = __esm({
|
|
|
992
1142
|
"src/runtime/turbopack/chunk-loader.ts"() {
|
|
993
1143
|
"use strict";
|
|
994
1144
|
init_constants2();
|
|
1145
|
+
init_namespace();
|
|
995
1146
|
init_patterns();
|
|
996
1147
|
init_protected_rc_fallback();
|
|
997
1148
|
init_error();
|
|
@@ -1003,13 +1154,13 @@ var init_chunk_loader = __esm({
|
|
|
1003
1154
|
|
|
1004
1155
|
// src/runtime/turbopack/shared-modules.ts
|
|
1005
1156
|
function getTurbopackModules(scope) {
|
|
1157
|
+
if (scope.turbopackModules.length > 0) {
|
|
1158
|
+
return scope.turbopackModules;
|
|
1159
|
+
}
|
|
1006
1160
|
const self = globalThis;
|
|
1007
1161
|
const raw = self[`TURBOPACK_${scope.globalKey}`];
|
|
1008
1162
|
if (!raw)
|
|
1009
1163
|
return void 0;
|
|
1010
|
-
if (typeof raw === "object" && "__chunks__" in raw) {
|
|
1011
|
-
return raw.__chunks__.flat();
|
|
1012
|
-
}
|
|
1013
1164
|
if (Array.isArray(raw)) {
|
|
1014
1165
|
return raw.flat();
|
|
1015
1166
|
}
|
|
@@ -1033,7 +1184,11 @@ async function initializeSharedModules(scope, hostShared = {}, remoteShared = {}
|
|
|
1033
1184
|
if (sharedModuleInitializerIndex > 0) {
|
|
1034
1185
|
const sharedModuleInitializerCode = allModules[sharedModuleInitializerIndex].toString();
|
|
1035
1186
|
const sharedModuleInitializerId = allModules[sharedModuleInitializerIndex - 1];
|
|
1036
|
-
const
|
|
1187
|
+
const sharedModuleId = extractGroup(
|
|
1188
|
+
REMOTE_SHARED_ASSIGNMENT_RE,
|
|
1189
|
+
sharedModuleInitializerCode,
|
|
1190
|
+
"sharedModuleId"
|
|
1191
|
+
);
|
|
1037
1192
|
if (sharedModuleId) {
|
|
1038
1193
|
const { default: sharedModuleInitializerInstance } = handleTurbopackModule(
|
|
1039
1194
|
scope,
|
|
@@ -1091,20 +1246,22 @@ async function initializeSharedModules(scope, hostShared = {}, remoteShared = {}
|
|
|
1091
1246
|
}
|
|
1092
1247
|
function extractSharedModuleIds(shared, scope) {
|
|
1093
1248
|
return Object.entries(shared).filter(([, value]) => typeof value === "function").reduce((acc, [key, value]) => {
|
|
1094
|
-
const
|
|
1249
|
+
const asyncSharedModuleId = extractGroup(
|
|
1250
|
+
ASYNC_MODULE_LOADER_RE,
|
|
1251
|
+
value.toString(),
|
|
1252
|
+
"asyncSharedModuleId"
|
|
1253
|
+
);
|
|
1095
1254
|
if (asyncSharedModuleId) {
|
|
1096
|
-
const
|
|
1097
|
-
|
|
1098
|
-
|
|
1099
|
-
const asyncSharedModuleIdIndex = turbopackModules.indexOf(
|
|
1100
|
-
asyncSharedModuleIdNumber
|
|
1255
|
+
const asyncSharedModule = findModuleInit(
|
|
1256
|
+
getTurbopackModules(scope),
|
|
1257
|
+
asyncSharedModuleId
|
|
1101
1258
|
);
|
|
1102
|
-
if (asyncSharedModuleIdIndex !== -1 && typeof turbopackModules[asyncSharedModuleIdIndex + 1] === "function") {
|
|
1103
|
-
asyncSharedModule = turbopackModules[asyncSharedModuleIdIndex + 1];
|
|
1104
|
-
}
|
|
1105
1259
|
if (asyncSharedModule) {
|
|
1106
|
-
const
|
|
1107
|
-
|
|
1260
|
+
const sharedModuleId = extractGroup(
|
|
1261
|
+
ASYNC_MODULE_CALLBACK_RE,
|
|
1262
|
+
asyncSharedModule.toString(),
|
|
1263
|
+
"sharedModuleId"
|
|
1264
|
+
);
|
|
1108
1265
|
acc[sharedModuleId ?? asyncSharedModuleId] = key.replace(
|
|
1109
1266
|
"__remote_shared_module_",
|
|
1110
1267
|
""
|
|
@@ -1206,9 +1363,17 @@ function findModuleInit(modules, moduleId) {
|
|
|
1206
1363
|
if (idx >= 0) {
|
|
1207
1364
|
return flat.slice(idx + 1).find((e) => typeof e === "function");
|
|
1208
1365
|
}
|
|
1209
|
-
|
|
1210
|
-
|
|
1211
|
-
|
|
1366
|
+
for (const entry of flat) {
|
|
1367
|
+
if (!entry || typeof entry !== "object")
|
|
1368
|
+
continue;
|
|
1369
|
+
const obj = entry;
|
|
1370
|
+
if (moduleId in obj)
|
|
1371
|
+
return obj[moduleId];
|
|
1372
|
+
const prefixKey = Object.keys(obj).find((k) => k.startsWith(moduleId));
|
|
1373
|
+
if (prefixKey)
|
|
1374
|
+
return obj[prefixKey];
|
|
1375
|
+
}
|
|
1376
|
+
return void 0;
|
|
1212
1377
|
}
|
|
1213
1378
|
function createTurbopackContext(scope, exports, moduleExports, modules, moduleInit, id) {
|
|
1214
1379
|
const scopedRequire = (moduleId) => requireModule(scope, moduleId, formatRemoteId(scope, String(moduleId)));
|
|
@@ -1287,7 +1452,10 @@ function createTurbopackContext(scope, exports, moduleExports, modules, moduleIn
|
|
|
1287
1452
|
}
|
|
1288
1453
|
if (typeof mod !== "object" || mod === null) {
|
|
1289
1454
|
mod = { default: mod };
|
|
1290
|
-
} else if (!("default" in mod) &&
|
|
1455
|
+
} else if (!("default" in mod) && // ES module namespace objects have a null prototype, so calling
|
|
1456
|
+
// mod.toString() directly throws. Use Object.prototype.toString
|
|
1457
|
+
// to safely detect them.
|
|
1458
|
+
Object.prototype.toString.call(mod) !== "[object Module]") {
|
|
1291
1459
|
try {
|
|
1292
1460
|
mod.default = mod;
|
|
1293
1461
|
} catch {
|
|
@@ -1360,21 +1528,38 @@ var init_module = __esm({
|
|
|
1360
1528
|
}
|
|
1361
1529
|
});
|
|
1362
1530
|
|
|
1363
|
-
// src/runtime/turbopack/
|
|
1364
|
-
async function
|
|
1531
|
+
// src/runtime/turbopack/remote-scope-setup.ts
|
|
1532
|
+
async function setupRemoteScope(runtime, scripts = [], url = new URL(location.href), bundle, resolveClientUrl) {
|
|
1365
1533
|
const self = globalThis;
|
|
1534
|
+
const ns = getNamespace();
|
|
1366
1535
|
const bundleName = bundle ?? "default";
|
|
1536
|
+
const existingScope = getScope(bundleName);
|
|
1537
|
+
if (existingScope && existingScope.url.origin === url.origin) {
|
|
1538
|
+
logDebug(
|
|
1539
|
+
"WebpackRuntime",
|
|
1540
|
+
`Reusing scope "${existingScope.scopedName}" (turbopackModules=${existingScope.turbopackModules.length})`
|
|
1541
|
+
);
|
|
1542
|
+
existingScope.resolveClientUrl = resolveClientUrl;
|
|
1543
|
+
if (runtime === RUNTIME_TURBOPACK) {
|
|
1544
|
+
await Promise.allSettled(
|
|
1545
|
+
scripts.map(
|
|
1546
|
+
(script) => script.src ? loadChunkWithScope(existingScope, script.src) : Promise.resolve(void 0)
|
|
1547
|
+
)
|
|
1548
|
+
);
|
|
1549
|
+
}
|
|
1550
|
+
return existingScope;
|
|
1551
|
+
}
|
|
1367
1552
|
const scope = createScope(bundleName, url, runtime, resolveClientUrl);
|
|
1368
1553
|
registerScope(scope);
|
|
1369
|
-
if (
|
|
1370
|
-
|
|
1554
|
+
if (runtime === RUNTIME_WEBPACK && self.__remote_webpack_require__?.[bundleName]) {
|
|
1555
|
+
scope.webpackRequire = self.__remote_webpack_require__[bundleName];
|
|
1371
1556
|
}
|
|
1372
|
-
|
|
1557
|
+
ns.bundleUrls[bundleName] = url;
|
|
1373
1558
|
if (scope.scopedName !== bundleName) {
|
|
1374
|
-
|
|
1559
|
+
ns.bundleUrls[scope.scopedName] = url;
|
|
1375
1560
|
}
|
|
1376
1561
|
self.__webpack_get_script_filename__ = () => null;
|
|
1377
|
-
const willCreateDispatchers = typeof self.__webpack_require__ !== "function" ||
|
|
1562
|
+
const willCreateDispatchers = typeof self.__webpack_require__ !== "function" || ns.dispatcherRuntime !== "turbopack";
|
|
1378
1563
|
if (willCreateDispatchers) {
|
|
1379
1564
|
if (!self.__original_webpack_require__ && !self.__original_webpack_chunk_load__) {
|
|
1380
1565
|
self.__original_webpack_chunk_load__ = self.__webpack_chunk_load__;
|
|
@@ -1382,6 +1567,7 @@ async function setupWebpackRuntime(runtime, scripts = [], url = new URL(location
|
|
|
1382
1567
|
}
|
|
1383
1568
|
self.__webpack_chunk_load__ = createChunkDispatcher();
|
|
1384
1569
|
self.__webpack_require__ = createModuleDispatcher(runtime);
|
|
1570
|
+
ns.dispatcherRuntime = runtime;
|
|
1385
1571
|
self.__webpack_require_type__ = runtime;
|
|
1386
1572
|
if (self.__remote_webpack_require__ && runtime === RUNTIME_TURBOPACK) {
|
|
1387
1573
|
self.__remote_webpack_require__[bundleName] = self.__webpack_require__;
|
|
@@ -1409,15 +1595,7 @@ async function setupWebpackRuntime(runtime, scripts = [], url = new URL(location
|
|
|
1409
1595
|
}
|
|
1410
1596
|
}
|
|
1411
1597
|
}
|
|
1412
|
-
|
|
1413
|
-
react: async () => (await import("react")).default,
|
|
1414
|
-
"react-dom": async () => (await import("react-dom")).default,
|
|
1415
|
-
"react/jsx-dev-runtime": async () => (await import("react/jsx-dev-runtime")).default,
|
|
1416
|
-
"react/jsx-runtime": async () => (await import("react/jsx-runtime")).default,
|
|
1417
|
-
"react-dom/client": async () => (await import("react-dom/client")).default,
|
|
1418
|
-
...shared
|
|
1419
|
-
};
|
|
1420
|
-
await initializeSharedModules(scope, coreShared, remoteShared);
|
|
1598
|
+
return scope;
|
|
1421
1599
|
}
|
|
1422
1600
|
function createModuleDispatcher(runtime) {
|
|
1423
1601
|
return (id) => {
|
|
@@ -1434,6 +1612,9 @@ function createModuleDispatcher(runtime) {
|
|
|
1434
1612
|
);
|
|
1435
1613
|
try {
|
|
1436
1614
|
if (remoteRuntime === RUNTIME_WEBPACK && bundle && moduleId) {
|
|
1615
|
+
const scope2 = getScope(bundle);
|
|
1616
|
+
if (scope2?.webpackRequire)
|
|
1617
|
+
return scope2.webpackRequire(moduleId);
|
|
1437
1618
|
return self.__remote_webpack_require__?.[bundle]?.(moduleId);
|
|
1438
1619
|
}
|
|
1439
1620
|
const scope = getScope(bundleName);
|
|
@@ -1471,17 +1652,17 @@ function createModuleDispatcher(runtime) {
|
|
|
1471
1652
|
}
|
|
1472
1653
|
};
|
|
1473
1654
|
}
|
|
1474
|
-
var
|
|
1475
|
-
"src/runtime/turbopack/
|
|
1655
|
+
var init_remote_scope_setup = __esm({
|
|
1656
|
+
"src/runtime/turbopack/remote-scope-setup.ts"() {
|
|
1476
1657
|
"use strict";
|
|
1477
1658
|
init_constants2();
|
|
1659
|
+
init_namespace();
|
|
1478
1660
|
init_patterns();
|
|
1479
1661
|
init_error();
|
|
1480
1662
|
init_logger();
|
|
1481
1663
|
init_chunk_loader();
|
|
1482
1664
|
init_module();
|
|
1483
1665
|
init_remote_scope();
|
|
1484
|
-
init_shared_modules();
|
|
1485
1666
|
}
|
|
1486
1667
|
});
|
|
1487
1668
|
|
|
@@ -1492,36 +1673,28 @@ __export(turbopack_exports, {
|
|
|
1492
1673
|
});
|
|
1493
1674
|
async function turbopackRuntime(url, bundle, shared, remoteShared, resolveClientUrl) {
|
|
1494
1675
|
const self = globalThis;
|
|
1495
|
-
const hostShared = {
|
|
1496
|
-
|
|
1497
|
-
|
|
1498
|
-
|
|
1499
|
-
...self.__remote_component_shared__
|
|
1500
|
-
};
|
|
1501
|
-
await setupWebpackRuntime(
|
|
1502
|
-
"turbopack",
|
|
1503
|
-
[],
|
|
1504
|
-
url,
|
|
1505
|
-
bundle,
|
|
1506
|
-
hostShared,
|
|
1507
|
-
remoteShared,
|
|
1508
|
-
resolveClientUrl
|
|
1509
|
-
);
|
|
1676
|
+
const hostShared = buildHostShared(shared, resolveClientUrl, {
|
|
1677
|
+
includeRemoteComponentShared: true
|
|
1678
|
+
});
|
|
1679
|
+
await setupRemoteScope("turbopack", [], url, bundle, resolveClientUrl);
|
|
1510
1680
|
const {
|
|
1511
1681
|
default: { createFromReadableStream }
|
|
1512
1682
|
} = await import("react-server-dom-webpack/client.browser");
|
|
1513
|
-
function preloadScripts(scripts, __) {
|
|
1514
|
-
|
|
1683
|
+
async function preloadScripts(scripts, __) {
|
|
1684
|
+
const scope = await setupRemoteScope(
|
|
1515
1685
|
"turbopack",
|
|
1516
1686
|
scripts.map((script) => ({
|
|
1517
1687
|
src: script.getAttribute("src") || script.getAttribute("data-src") || script.src
|
|
1518
1688
|
})),
|
|
1519
1689
|
url,
|
|
1520
1690
|
bundle,
|
|
1521
|
-
hostShared,
|
|
1522
|
-
remoteShared,
|
|
1523
1691
|
resolveClientUrl
|
|
1524
1692
|
);
|
|
1693
|
+
await initializeSharedModules(
|
|
1694
|
+
scope,
|
|
1695
|
+
buildCoreShared(hostShared),
|
|
1696
|
+
remoteShared ?? {}
|
|
1697
|
+
);
|
|
1525
1698
|
}
|
|
1526
1699
|
return {
|
|
1527
1700
|
self,
|
|
@@ -1536,8 +1709,9 @@ var init_turbopack = __esm({
|
|
|
1536
1709
|
"use strict";
|
|
1537
1710
|
init_apply_shared_modules();
|
|
1538
1711
|
init_next_client_pages_loader();
|
|
1539
|
-
|
|
1540
|
-
|
|
1712
|
+
init_shared_module_resolver();
|
|
1713
|
+
init_remote_scope_setup();
|
|
1714
|
+
init_shared_modules();
|
|
1541
1715
|
}
|
|
1542
1716
|
});
|
|
1543
1717
|
|
|
@@ -1584,10 +1758,9 @@ async function importViaCallback(absoluteSrc, resolveClientUrl) {
|
|
|
1584
1758
|
URL.revokeObjectURL(moduleBlobUrl);
|
|
1585
1759
|
URL.revokeObjectURL(wrapperBlobUrl);
|
|
1586
1760
|
}
|
|
1587
|
-
const registry =
|
|
1588
|
-
const mod = registry
|
|
1589
|
-
|
|
1590
|
-
delete registry[absoluteSrc];
|
|
1761
|
+
const registry = getNamespace().moduleRegistry;
|
|
1762
|
+
const mod = registry[absoluteSrc] ?? {};
|
|
1763
|
+
delete registry[absoluteSrc];
|
|
1591
1764
|
return mod;
|
|
1592
1765
|
}
|
|
1593
1766
|
async function importDirectly(absoluteSrc) {
|
|
@@ -1617,12 +1790,12 @@ function resolveScriptSrc(script, url) {
|
|
|
1617
1790
|
return rawSrc;
|
|
1618
1791
|
}
|
|
1619
1792
|
async function loadStaticRemoteComponent(scripts, url, resolveClientUrl) {
|
|
1620
|
-
const
|
|
1621
|
-
if (
|
|
1622
|
-
|
|
1793
|
+
const ns = getNamespace();
|
|
1794
|
+
if (ns.mountFns[url.href]) {
|
|
1795
|
+
ns.mountFns[url.href] = /* @__PURE__ */ new Set();
|
|
1623
1796
|
}
|
|
1624
|
-
if (
|
|
1625
|
-
|
|
1797
|
+
if (ns.unmountFns[url.href]) {
|
|
1798
|
+
ns.unmountFns[url.href] = /* @__PURE__ */ new Set();
|
|
1626
1799
|
}
|
|
1627
1800
|
const mountUnmountSets = await Promise.all(
|
|
1628
1801
|
scripts.map(async (script) => {
|
|
@@ -1634,25 +1807,19 @@ async function loadStaticRemoteComponent(scripts, url, resolveClientUrl) {
|
|
|
1634
1807
|
URL.revokeObjectURL(src);
|
|
1635
1808
|
}
|
|
1636
1809
|
if (typeof mod.mount === "function" || typeof mod.default?.mount === "function") {
|
|
1637
|
-
if (!
|
|
1638
|
-
|
|
1810
|
+
if (!ns.mountFns[url.href]) {
|
|
1811
|
+
ns.mountFns[url.href] = /* @__PURE__ */ new Set();
|
|
1639
1812
|
}
|
|
1640
|
-
|
|
1641
|
-
self.__remote_script_entrypoint_mount__[url.href] = /* @__PURE__ */ new Set();
|
|
1642
|
-
}
|
|
1643
|
-
self.__remote_script_entrypoint_mount__[url.href]?.add(
|
|
1813
|
+
ns.mountFns[url.href]?.add(
|
|
1644
1814
|
mod.mount || mod.default?.mount || (() => {
|
|
1645
1815
|
})
|
|
1646
1816
|
);
|
|
1647
1817
|
}
|
|
1648
1818
|
if (typeof mod.unmount === "function" || typeof mod.default?.unmount === "function") {
|
|
1649
|
-
if (!
|
|
1650
|
-
|
|
1651
|
-
}
|
|
1652
|
-
if (!self.__remote_script_entrypoint_unmount__[url.href]) {
|
|
1653
|
-
self.__remote_script_entrypoint_unmount__[url.href] = /* @__PURE__ */ new Set();
|
|
1819
|
+
if (!ns.unmountFns[url.href]) {
|
|
1820
|
+
ns.unmountFns[url.href] = /* @__PURE__ */ new Set();
|
|
1654
1821
|
}
|
|
1655
|
-
|
|
1822
|
+
ns.unmountFns[url.href]?.add(
|
|
1656
1823
|
mod.unmount || mod.default?.unmount || (() => {
|
|
1657
1824
|
})
|
|
1658
1825
|
);
|
|
@@ -1693,6 +1860,7 @@ async function loadStaticRemoteComponent(scripts, url, resolveClientUrl) {
|
|
|
1693
1860
|
var init_static_loader = __esm({
|
|
1694
1861
|
"src/runtime/loaders/static-loader.ts"() {
|
|
1695
1862
|
"use strict";
|
|
1863
|
+
init_namespace();
|
|
1696
1864
|
init_logger();
|
|
1697
1865
|
}
|
|
1698
1866
|
});
|
|
@@ -1813,8 +1981,8 @@ function resolveNameFromSrc(src, defaultName) {
|
|
|
1813
1981
|
// src/host/html/index.tsx
|
|
1814
1982
|
init_constants2();
|
|
1815
1983
|
|
|
1816
|
-
// src/runtime/html/
|
|
1817
|
-
var
|
|
1984
|
+
// src/runtime/html/html-spec.ts
|
|
1985
|
+
var ORIGIN_REWRITE_TAGS = [
|
|
1818
1986
|
"img",
|
|
1819
1987
|
"source",
|
|
1820
1988
|
"video",
|
|
@@ -1825,10 +1993,37 @@ var tagNames = [
|
|
|
1825
1993
|
"script",
|
|
1826
1994
|
"link"
|
|
1827
1995
|
];
|
|
1996
|
+
var ID_SUFFIX_RSC = "_rsc";
|
|
1997
|
+
var ID_SUFFIX_SSR = "_ssr";
|
|
1998
|
+
var ID_SUFFIX_SHARED = "_shared";
|
|
1999
|
+
var DATA_BUNDLE = "data-bundle";
|
|
2000
|
+
var DATA_ROUTE = "data-route";
|
|
2001
|
+
var DATA_RUNTIME = "data-runtime";
|
|
2002
|
+
var DATA_TYPE = "data-type";
|
|
2003
|
+
var DATA_SRC = "data-src";
|
|
2004
|
+
var DATA_REMOTE_COMPONENTS_SHARED = "data-remote-components-shared";
|
|
2005
|
+
var TAG_REMOTE_COMPONENT = "remote-component";
|
|
2006
|
+
var NEXT_DATA_ID = "__NEXT_DATA__";
|
|
2007
|
+
var REMOTE_NEXT_DATA_ID = "__REMOTE_NEXT_DATA__";
|
|
2008
|
+
var NEXT_CONTAINER_ID = "__next";
|
|
2009
|
+
|
|
2010
|
+
// src/runtime/html/rewrite-srcset.ts
|
|
2011
|
+
function rewriteSrcset(srcset, base, resolve) {
|
|
2012
|
+
return srcset.split(",").map((entry) => {
|
|
2013
|
+
const [url, descriptor] = entry.trim().split(/\s+/);
|
|
2014
|
+
if (!url)
|
|
2015
|
+
return entry;
|
|
2016
|
+
const absoluteUrl = new URL(url, base).href;
|
|
2017
|
+
const resolvedUrl = resolve ? resolve(absoluteUrl) : absoluteUrl;
|
|
2018
|
+
return descriptor ? `${resolvedUrl} ${descriptor}` : resolvedUrl;
|
|
2019
|
+
}).join(", ");
|
|
2020
|
+
}
|
|
2021
|
+
|
|
2022
|
+
// src/runtime/html/apply-origin.ts
|
|
1828
2023
|
function applyOriginToNodes(doc, url, resolveClientUrl) {
|
|
1829
2024
|
if (url.origin !== location.origin) {
|
|
1830
2025
|
const nodes = doc.querySelectorAll(
|
|
1831
|
-
|
|
2026
|
+
ORIGIN_REWRITE_TAGS.map(
|
|
1832
2027
|
(type) => `${type}[src],${type}[srcset],${type}[href],${type}[imagesrcset]`
|
|
1833
2028
|
).join(",")
|
|
1834
2029
|
);
|
|
@@ -1846,29 +2041,17 @@ function applyOriginToNodes(doc, url, resolveClientUrl) {
|
|
|
1846
2041
|
);
|
|
1847
2042
|
}
|
|
1848
2043
|
if (node.hasAttribute("srcset")) {
|
|
1849
|
-
const
|
|
1850
|
-
|
|
1851
|
-
|
|
1852
|
-
|
|
1853
|
-
const absoluteUrl = new URL(urlPart, url).href;
|
|
1854
|
-
const resolvedUrl = resolveClientUrl?.(absoluteUrl) ?? absoluteUrl;
|
|
1855
|
-
return descriptor ? `${resolvedUrl} ${descriptor}` : resolvedUrl;
|
|
1856
|
-
}).join(", ");
|
|
1857
|
-
if (srcSet) {
|
|
1858
|
-
node.setAttribute("srcset", srcSet);
|
|
2044
|
+
const raw = node.getAttribute("srcset");
|
|
2045
|
+
if (raw) {
|
|
2046
|
+
const resolve = resolveClientUrl ? (abs) => resolveClientUrl(abs) ?? abs : void 0;
|
|
2047
|
+
node.setAttribute("srcset", rewriteSrcset(raw, url, resolve));
|
|
1859
2048
|
}
|
|
1860
2049
|
}
|
|
1861
2050
|
if (node.hasAttribute("imagesrcset")) {
|
|
1862
|
-
const
|
|
1863
|
-
|
|
1864
|
-
|
|
1865
|
-
|
|
1866
|
-
const absoluteUrl = new URL(urlPart, url).href;
|
|
1867
|
-
const resolvedUrl = resolveClientUrl?.(absoluteUrl) ?? absoluteUrl;
|
|
1868
|
-
return descriptor ? `${resolvedUrl} ${descriptor}` : resolvedUrl;
|
|
1869
|
-
}).join(", ");
|
|
1870
|
-
if (srcSet) {
|
|
1871
|
-
node.setAttribute("imagesrcset", srcSet);
|
|
2051
|
+
const raw = node.getAttribute("imagesrcset");
|
|
2052
|
+
if (raw) {
|
|
2053
|
+
const resolve = resolveClientUrl ? (abs) => resolveClientUrl(abs) ?? abs : void 0;
|
|
2054
|
+
node.setAttribute("imagesrcset", rewriteSrcset(raw, url, resolve));
|
|
1872
2055
|
}
|
|
1873
2056
|
}
|
|
1874
2057
|
});
|
|
@@ -1914,26 +2097,28 @@ function buildMetadata(attrs, url) {
|
|
|
1914
2097
|
// src/runtime/html/parse-remote-html.ts
|
|
1915
2098
|
init_error();
|
|
1916
2099
|
function validateSingleComponent(doc, name, url) {
|
|
1917
|
-
if (doc.querySelectorAll(
|
|
2100
|
+
if (doc.querySelectorAll(`div[${DATA_BUNDLE}][${DATA_ROUTE}]`).length > 1 && !doc.querySelector(
|
|
2101
|
+
`div[${DATA_BUNDLE}][${DATA_ROUTE}][id^="${name}"]`
|
|
2102
|
+
) || doc.querySelectorAll(`${TAG_REMOTE_COMPONENT}:not([src])`).length > 1 && !doc.querySelector(`${TAG_REMOTE_COMPONENT}[name="${name}"]`)) {
|
|
1918
2103
|
throw multipleRemoteComponentsError(url);
|
|
1919
2104
|
}
|
|
1920
2105
|
}
|
|
1921
2106
|
function findComponentElement(doc, name) {
|
|
1922
|
-
return doc.querySelector(`div[
|
|
2107
|
+
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])`);
|
|
1923
2108
|
}
|
|
1924
2109
|
function parseNextData(doc) {
|
|
1925
2110
|
return JSON.parse(
|
|
1926
|
-
(doc.querySelector(
|
|
2111
|
+
(doc.querySelector(`#${NEXT_DATA_ID}`) ?? doc.querySelector(`#${REMOTE_NEXT_DATA_ID}`))?.textContent ?? "null"
|
|
1927
2112
|
);
|
|
1928
2113
|
}
|
|
1929
2114
|
function resolveComponentName(component, nextData, fallbackName) {
|
|
1930
|
-
const isRemoteComponent = component?.tagName.toLowerCase() ===
|
|
1931
|
-
const name = component?.getAttribute("id")?.replace(
|
|
2115
|
+
const isRemoteComponent = component?.tagName.toLowerCase() === TAG_REMOTE_COMPONENT;
|
|
2116
|
+
const name = component?.getAttribute("id")?.replace(new RegExp(`${ID_SUFFIX_SSR}$`), "") || isRemoteComponent && component?.getAttribute("name") || (nextData ? "__next" : fallbackName);
|
|
1932
2117
|
return { name, isRemoteComponent };
|
|
1933
2118
|
}
|
|
1934
2119
|
function extractRemoteShared(doc, name, nextData) {
|
|
1935
2120
|
const remoteSharedEl = doc.querySelector(
|
|
1936
|
-
`#${name}
|
|
2121
|
+
`#${name}${ID_SUFFIX_SHARED}[${DATA_REMOTE_COMPONENTS_SHARED}]`
|
|
1937
2122
|
);
|
|
1938
2123
|
const remoteShared = nextData?.props.__REMOTE_COMPONENT__?.shared ?? (JSON.parse(remoteSharedEl?.textContent ?? "{}") ?? {});
|
|
1939
2124
|
remoteSharedEl?.remove();
|
|
@@ -1954,7 +2139,7 @@ function extractLinks(doc, component) {
|
|
|
1954
2139
|
function extractScripts(doc, component, isRemoteComponent) {
|
|
1955
2140
|
return Array.from(
|
|
1956
2141
|
(isRemoteComponent ? component : doc).querySelectorAll(
|
|
1957
|
-
|
|
2142
|
+
`script[src],script[${DATA_SRC}]`
|
|
1958
2143
|
)
|
|
1959
2144
|
);
|
|
1960
2145
|
}
|
|
@@ -1967,15 +2152,15 @@ function parseRemoteComponentDocument(doc, name, url) {
|
|
|
1967
2152
|
nextData,
|
|
1968
2153
|
name
|
|
1969
2154
|
);
|
|
1970
|
-
const rsc = doc.querySelector(`#${resolvedName}
|
|
2155
|
+
const rsc = doc.querySelector(`#${resolvedName}${ID_SUFFIX_RSC}`);
|
|
1971
2156
|
const metadata = buildMetadata(
|
|
1972
2157
|
{
|
|
1973
2158
|
name: resolvedName,
|
|
1974
|
-
bundle: component?.getAttribute(
|
|
1975
|
-
route: component?.getAttribute(
|
|
1976
|
-
runtime: component?.getAttribute(
|
|
2159
|
+
bundle: component?.getAttribute(DATA_BUNDLE) || nextData?.props.__REMOTE_COMPONENT__?.bundle,
|
|
2160
|
+
route: component?.getAttribute(DATA_ROUTE) ?? nextData?.page,
|
|
2161
|
+
runtime: component?.getAttribute(DATA_RUNTIME) ?? nextData?.props.__REMOTE_COMPONENT__?.runtime ?? RUNTIME_SCRIPT,
|
|
1977
2162
|
id: component?.getAttribute("id"),
|
|
1978
|
-
type: component?.getAttribute(
|
|
2163
|
+
type: component?.getAttribute(DATA_TYPE)
|
|
1979
2164
|
},
|
|
1980
2165
|
url
|
|
1981
2166
|
);
|
|
@@ -2003,6 +2188,9 @@ function parseRemoteComponentDocument(doc, name, url) {
|
|
|
2003
2188
|
};
|
|
2004
2189
|
}
|
|
2005
2190
|
|
|
2191
|
+
// src/host/html/index.tsx
|
|
2192
|
+
init_namespace();
|
|
2193
|
+
|
|
2006
2194
|
// src/runtime/rsc.ts
|
|
2007
2195
|
import { ReadableStream } from "web-streams-polyfill";
|
|
2008
2196
|
function fixPayload(payload) {
|
|
@@ -2023,6 +2211,18 @@ function fixPayload(payload) {
|
|
|
2023
2211
|
}
|
|
2024
2212
|
}
|
|
2025
2213
|
}
|
|
2214
|
+
function buildRSCChunks(rscName, data) {
|
|
2215
|
+
const chunks = [];
|
|
2216
|
+
for (const chunk of data) {
|
|
2217
|
+
for (const line of chunk.split("\n")) {
|
|
2218
|
+
const match = /\.push\("(?<rsc>.*)"\);$/.exec(line);
|
|
2219
|
+
if (match?.groups?.rsc) {
|
|
2220
|
+
chunks.push(JSON.parse(`"${match.groups.rsc}"`));
|
|
2221
|
+
}
|
|
2222
|
+
}
|
|
2223
|
+
}
|
|
2224
|
+
return chunks;
|
|
2225
|
+
}
|
|
2026
2226
|
function createRSCStream(rscName, data) {
|
|
2027
2227
|
return new ReadableStream({
|
|
2028
2228
|
type: "bytes",
|
|
@@ -2030,16 +2230,11 @@ function createRSCStream(rscName, data) {
|
|
|
2030
2230
|
const encoder = new TextEncoder();
|
|
2031
2231
|
const self = globalThis;
|
|
2032
2232
|
if (data.length > 0) {
|
|
2033
|
-
data
|
|
2034
|
-
|
|
2035
|
-
|
|
2036
|
-
|
|
2037
|
-
|
|
2038
|
-
self[rscName] = self[rscName] ?? [];
|
|
2039
|
-
self[rscName].push(JSON.parse(`"${match.groups.rsc}"`));
|
|
2040
|
-
}
|
|
2041
|
-
}
|
|
2042
|
-
});
|
|
2233
|
+
const parsed = buildRSCChunks(rscName, data);
|
|
2234
|
+
if (parsed.length > 0) {
|
|
2235
|
+
self[rscName] = self[rscName] ?? [];
|
|
2236
|
+
self[rscName].push(...parsed);
|
|
2237
|
+
}
|
|
2043
2238
|
}
|
|
2044
2239
|
const allChunks = (self[rscName] ?? [`0:[null]
|
|
2045
2240
|
`]).join("");
|
|
@@ -2415,11 +2610,7 @@ if (typeof HTMLElement !== "undefined") {
|
|
|
2415
2610
|
this.name = resolvedName;
|
|
2416
2611
|
this.bundle = parsedMetadata.bundle;
|
|
2417
2612
|
if (url) {
|
|
2418
|
-
|
|
2419
|
-
if (!self2.__remote_bundle_url__) {
|
|
2420
|
-
self2.__remote_bundle_url__ = {};
|
|
2421
|
-
}
|
|
2422
|
-
self2.__remote_bundle_url__[this.bundle] = url;
|
|
2613
|
+
getNamespace().bundleUrls[this.bundle] = url;
|
|
2423
2614
|
}
|
|
2424
2615
|
const metadataEl = document.createElement("script");
|
|
2425
2616
|
metadataEl.type = "application/json";
|
|
@@ -2443,22 +2634,22 @@ if (typeof HTMLElement !== "undefined") {
|
|
|
2443
2634
|
if (this.hostState.prevIsRemoteComponent) {
|
|
2444
2635
|
if (this.hostState.prevUrl) {
|
|
2445
2636
|
const prevUrl = this.hostState.prevUrl;
|
|
2446
|
-
const
|
|
2447
|
-
if (
|
|
2637
|
+
const nsUnmount = getNamespace();
|
|
2638
|
+
if (nsUnmount.unmountFns[prevUrl.href]) {
|
|
2448
2639
|
await Promise.all(
|
|
2449
|
-
Array.from(
|
|
2450
|
-
|
|
2451
|
-
|
|
2452
|
-
|
|
2453
|
-
|
|
2454
|
-
|
|
2455
|
-
|
|
2456
|
-
|
|
2457
|
-
|
|
2458
|
-
|
|
2459
|
-
|
|
2640
|
+
Array.from(nsUnmount.unmountFns[prevUrl.href] ?? []).map(
|
|
2641
|
+
async (unmount) => {
|
|
2642
|
+
try {
|
|
2643
|
+
await unmount(this.root);
|
|
2644
|
+
} catch (e) {
|
|
2645
|
+
logError(
|
|
2646
|
+
"HtmlHost",
|
|
2647
|
+
`Error while calling unmount() for Remote Component from ${prevUrl.href}.`,
|
|
2648
|
+
e
|
|
2649
|
+
);
|
|
2650
|
+
}
|
|
2460
2651
|
}
|
|
2461
|
-
|
|
2652
|
+
)
|
|
2462
2653
|
);
|
|
2463
2654
|
if (!isCurrentLoad()) {
|
|
2464
2655
|
return abandonLoad();
|
|
@@ -2749,21 +2940,21 @@ if (typeof HTMLElement !== "undefined") {
|
|
|
2749
2940
|
if (this.fouc) {
|
|
2750
2941
|
this.root.removeChild(this.fouc);
|
|
2751
2942
|
}
|
|
2752
|
-
} else if (
|
|
2943
|
+
} else if (getNamespace().mountFns[url.href]) {
|
|
2753
2944
|
await Promise.all(
|
|
2754
|
-
Array.from(
|
|
2755
|
-
|
|
2756
|
-
|
|
2757
|
-
|
|
2758
|
-
|
|
2759
|
-
|
|
2760
|
-
|
|
2761
|
-
|
|
2762
|
-
|
|
2763
|
-
|
|
2764
|
-
|
|
2945
|
+
Array.from(getNamespace().mountFns[url.href] ?? []).map(
|
|
2946
|
+
async (mount) => {
|
|
2947
|
+
try {
|
|
2948
|
+
await mount(this.root);
|
|
2949
|
+
} catch (e) {
|
|
2950
|
+
logError(
|
|
2951
|
+
"HtmlHost",
|
|
2952
|
+
`Error while calling mount() for Remote Component from ${url.href}.`,
|
|
2953
|
+
e
|
|
2954
|
+
);
|
|
2955
|
+
}
|
|
2765
2956
|
}
|
|
2766
|
-
|
|
2957
|
+
)
|
|
2767
2958
|
);
|
|
2768
2959
|
this.dispatchLifecycleEvent("load", { src: this.src });
|
|
2769
2960
|
} else {
|
|
@@ -2777,14 +2968,9 @@ if (typeof HTMLElement !== "undefined") {
|
|
|
2777
2968
|
customElements.define("remote-component", RemoteComponent);
|
|
2778
2969
|
}
|
|
2779
2970
|
function registerSharedModules(modules = {}) {
|
|
2780
|
-
const
|
|
2781
|
-
if (!self.__remote_component_host_shared_modules__) {
|
|
2782
|
-
self.__remote_component_host_shared_modules__ = {};
|
|
2783
|
-
}
|
|
2971
|
+
const ns = getNamespace();
|
|
2784
2972
|
Object.entries(modules).forEach(([key, value]) => {
|
|
2785
|
-
|
|
2786
|
-
self.__remote_component_host_shared_modules__[key] = value;
|
|
2787
|
-
}
|
|
2973
|
+
ns.hostSharedModules[key] = value;
|
|
2788
2974
|
});
|
|
2789
2975
|
}
|
|
2790
2976
|
export {
|