remote-components 0.0.30 → 0.0.31
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/component-loader-e5513139.d.ts +76 -0
- package/dist/html/host.cjs +154 -50
- package/dist/html/host.cjs.map +1 -1
- package/dist/html/host.js +154 -50
- package/dist/html/host.js.map +1 -1
- package/dist/internal/next/remote/render-client.cjs +7 -3
- package/dist/internal/next/remote/render-client.cjs.map +1 -1
- package/dist/internal/next/remote/render-client.d.ts +2 -1
- package/dist/internal/next/remote/render-client.js +5 -2
- package/dist/internal/next/remote/render-client.js.map +1 -1
- package/dist/internal/shared/client/remote-component.cjs +154 -50
- package/dist/internal/shared/client/remote-component.cjs.map +1 -1
- package/dist/internal/shared/client/remote-component.d.ts +3 -74
- package/dist/internal/shared/client/remote-component.js +154 -50
- package/dist/internal/shared/client/remote-component.js.map +1 -1
- package/dist/next/config.cjs +0 -2
- package/dist/next/config.cjs.map +1 -1
- package/dist/next/config.js +0 -2
- package/dist/next/config.js.map +1 -1
- package/dist/next/host/client/index.cjs +1685 -10
- package/dist/next/host/client/index.cjs.map +1 -1
- package/dist/next/host/client/index.d.ts +38 -5
- package/dist/next/host/client/index.js +1690 -10
- package/dist/next/host/client/index.js.map +1 -1
- package/package.json +1 -1
package/dist/html/host.js
CHANGED
|
@@ -190,19 +190,6 @@ async function setupWebpackRuntime(runtime, scripts = [], url = new URL(location
|
|
|
190
190
|
}
|
|
191
191
|
self.__remote_bundle_url__[bundle ?? "default"] = url;
|
|
192
192
|
self.__webpack_get_script_filename__ = () => null;
|
|
193
|
-
await initializeSharedModules(
|
|
194
|
-
bundle ?? "default",
|
|
195
|
-
// include all core modules as shared
|
|
196
|
-
{
|
|
197
|
-
react: async () => (await import("react")).default,
|
|
198
|
-
"react-dom": async () => (await import("react-dom")).default,
|
|
199
|
-
"react/jsx-dev-runtime": async () => (await import("react/jsx-dev-runtime")).default,
|
|
200
|
-
"react/jsx-runtime": async () => (await import("react/jsx-runtime")).default,
|
|
201
|
-
"react-dom/client": async () => (await import("react-dom/client")).default,
|
|
202
|
-
...shared
|
|
203
|
-
},
|
|
204
|
-
remoteShared
|
|
205
|
-
);
|
|
206
193
|
if (typeof self.__webpack_require__ !== "function" || self.__webpack_require_type__ !== "turbopack") {
|
|
207
194
|
if (!self.__original_webpack_require__ && !self.__original_webpack_chunk_load__) {
|
|
208
195
|
self.__original_webpack_chunk_load__ = self.__webpack_chunk_load__;
|
|
@@ -227,6 +214,19 @@ async function setupWebpackRuntime(runtime, scripts = [], url = new URL(location
|
|
|
227
214
|
})
|
|
228
215
|
);
|
|
229
216
|
}
|
|
217
|
+
await initializeSharedModules(
|
|
218
|
+
bundle ?? "default",
|
|
219
|
+
// include all core modules as shared
|
|
220
|
+
{
|
|
221
|
+
react: async () => (await import("react")).default,
|
|
222
|
+
"react-dom": async () => (await import("react-dom")).default,
|
|
223
|
+
"react/jsx-dev-runtime": async () => (await import("react/jsx-dev-runtime")).default,
|
|
224
|
+
"react/jsx-runtime": async () => (await import("react/jsx-runtime")).default,
|
|
225
|
+
"react-dom/client": async () => (await import("react-dom/client")).default,
|
|
226
|
+
...shared
|
|
227
|
+
},
|
|
228
|
+
remoteShared
|
|
229
|
+
);
|
|
230
230
|
}
|
|
231
231
|
function createChunkLoader(runtime) {
|
|
232
232
|
return function __turbopack_chunk_load__(chunkId, scriptBundle) {
|
|
@@ -304,6 +304,7 @@ async function handleTurbopackChunk(code, bundle, url) {
|
|
|
304
304
|
});
|
|
305
305
|
const scriptUrl = URL.createObjectURL(blob);
|
|
306
306
|
const script = document.createElement("script");
|
|
307
|
+
script.setAttribute("data-turbopack-src", url);
|
|
307
308
|
script.src = scriptUrl;
|
|
308
309
|
script.async = true;
|
|
309
310
|
script.onload = () => {
|
|
@@ -378,17 +379,84 @@ function createModuleRequire(runtime) {
|
|
|
378
379
|
}
|
|
379
380
|
};
|
|
380
381
|
}
|
|
381
|
-
function initializeSharedModules(bundle,
|
|
382
|
+
async function initializeSharedModules(bundle, hostShared = {}, remoteShared = {}) {
|
|
382
383
|
const self = globalThis;
|
|
383
384
|
self.__remote_shared_modules__ = self.__remote_shared_modules__ ?? {};
|
|
384
385
|
if (!self.__remote_shared_modules__[bundle]) {
|
|
385
386
|
self.__remote_shared_modules__[bundle] = {};
|
|
386
387
|
}
|
|
388
|
+
const bundleKey = getBundleKey(bundle);
|
|
389
|
+
const modules = self[`TURBOPACK_${bundleKey}`];
|
|
390
|
+
let sharedModuleInitializer = null;
|
|
391
|
+
if (modules && Array.isArray(modules)) {
|
|
392
|
+
const allModules = modules.flat();
|
|
393
|
+
const sharedModuleInitializerIndex = allModules.findIndex((idOrFunc) => {
|
|
394
|
+
if (typeof idOrFunc !== "function") {
|
|
395
|
+
return false;
|
|
396
|
+
}
|
|
397
|
+
const funcCode = idOrFunc.toString();
|
|
398
|
+
return /[a-z]\.TURBOPACK_REMOTE_SHARED/.test(funcCode);
|
|
399
|
+
});
|
|
400
|
+
if (sharedModuleInitializerIndex > 0) {
|
|
401
|
+
const sharedModuleInitializerCode = allModules[sharedModuleInitializerIndex].toString();
|
|
402
|
+
const sharedModuleInitializerId = allModules[sharedModuleInitializerIndex - 1];
|
|
403
|
+
const { sharedModuleId } = /\.TURBOPACK_REMOTE_SHARED=await e\.A\((?<sharedModuleId>[0-9]+)\)/.exec(
|
|
404
|
+
sharedModuleInitializerCode
|
|
405
|
+
)?.groups ?? {};
|
|
406
|
+
if (sharedModuleId) {
|
|
407
|
+
const { default: sharedModuleInitializerInstance } = handleTurbopackModule(
|
|
408
|
+
bundle,
|
|
409
|
+
sharedModuleId,
|
|
410
|
+
`[${bundle}] ${sharedModuleInitializerId}`
|
|
411
|
+
);
|
|
412
|
+
sharedModuleInitializer = sharedModuleInitializerInstance;
|
|
413
|
+
}
|
|
414
|
+
}
|
|
415
|
+
if (sharedModuleInitializer) {
|
|
416
|
+
const { shared } = await sharedModuleInitializer;
|
|
417
|
+
const sharedModuleIds = Object.entries(shared).filter(([, value]) => typeof value === "function").reduce((acc, [key, value]) => {
|
|
418
|
+
const { asyncSharedModuleId } = /e\.A\((?<asyncSharedModuleId>[0-9]+)\)/.exec(value.toString())?.groups ?? {};
|
|
419
|
+
if (asyncSharedModuleId) {
|
|
420
|
+
const asyncSharedModuleIdNumber = Number(asyncSharedModuleId);
|
|
421
|
+
let asyncSharedModule;
|
|
422
|
+
const newAllModules = self[`TURBOPACK_${bundleKey}`]?.flat() ?? [];
|
|
423
|
+
const asyncSharedModuleIdIndex = newAllModules.indexOf(
|
|
424
|
+
asyncSharedModuleIdNumber
|
|
425
|
+
);
|
|
426
|
+
if (asyncSharedModuleIdIndex !== -1 && typeof newAllModules[asyncSharedModuleIdIndex + 1] === "function") {
|
|
427
|
+
asyncSharedModule = newAllModules[asyncSharedModuleIdIndex + 1];
|
|
428
|
+
}
|
|
429
|
+
if (asyncSharedModule) {
|
|
430
|
+
const asyncSharedModuleCode = asyncSharedModule.toString();
|
|
431
|
+
const { sharedModuleId } = /e=>{e\.v\(e=>Promise\.resolve\(\)\.then\(\(\)=>e\((?<sharedModuleId>[0-9]+)\)\)\)}/.exec(
|
|
432
|
+
asyncSharedModuleCode
|
|
433
|
+
)?.groups ?? /e=>{e\.v\(t=>Promise\.all\(\["[^"]+"\].map\(t=>e\.l\(t\)\)\)\.then\(\(\)=>t\((?<sharedModuleId>[0-9]+)\)\)\)}/.exec(
|
|
434
|
+
asyncSharedModuleCode
|
|
435
|
+
)?.groups ?? {};
|
|
436
|
+
acc[sharedModuleId ?? asyncSharedModuleId] = key.replace(
|
|
437
|
+
"__remote_shared_module_",
|
|
438
|
+
""
|
|
439
|
+
);
|
|
440
|
+
}
|
|
441
|
+
}
|
|
442
|
+
return acc;
|
|
443
|
+
}, {});
|
|
444
|
+
return Promise.all(
|
|
445
|
+
Object.entries(sharedModuleIds).map(async ([id, module]) => {
|
|
446
|
+
if (self.__remote_shared_modules__?.[bundle]) {
|
|
447
|
+
if (hostShared[module]) {
|
|
448
|
+
self.__remote_shared_modules__[bundle][id] = await hostShared[module](bundle);
|
|
449
|
+
}
|
|
450
|
+
}
|
|
451
|
+
})
|
|
452
|
+
);
|
|
453
|
+
}
|
|
454
|
+
}
|
|
387
455
|
return Promise.all(
|
|
388
456
|
Object.entries(remoteShared).map(async ([id, module]) => {
|
|
389
457
|
if (self.__remote_shared_modules__?.[bundle]) {
|
|
390
|
-
if (
|
|
391
|
-
self.__remote_shared_modules__[bundle][id.replace("[app-ssr]", "[app-client]")] = await
|
|
458
|
+
if (hostShared[module]) {
|
|
459
|
+
self.__remote_shared_modules__[bundle][id.replace("[app-ssr]", "[app-client]")] = await hostShared[module](bundle);
|
|
392
460
|
} else {
|
|
393
461
|
console.error(`Shared module "${module}" not found for "${bundle}".`);
|
|
394
462
|
}
|
|
@@ -412,28 +480,25 @@ function handleTurbopackModule(bundle, moduleId, id) {
|
|
|
412
480
|
const bundleKey = getBundleKey(bundle);
|
|
413
481
|
const modules = self[`TURBOPACK_${bundleKey}`];
|
|
414
482
|
let moduleInit;
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
)
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
moduleInit = mod[index];
|
|
428
|
-
break;
|
|
429
|
-
}
|
|
430
|
-
} else {
|
|
431
|
-
const map = mod[1];
|
|
432
|
-
if (moduleId in map) {
|
|
433
|
-
moduleInit = map[moduleId];
|
|
434
|
-
break;
|
|
483
|
+
const allModules = modules?.flat() ?? [];
|
|
484
|
+
if (typeof allModules[1] === "string" || typeof allModules[1] === "number") {
|
|
485
|
+
const normalizedId = /^[0-9]+$/.test(moduleId) ? Number(moduleId) : moduleId;
|
|
486
|
+
let moduleIdIndex = allModules.indexOf(normalizedId);
|
|
487
|
+
if (moduleIdIndex === -1) {
|
|
488
|
+
moduleIdIndex = allModules.findIndex(
|
|
489
|
+
(bundleEntry) => typeof bundleEntry === "string" && bundleEntry.startsWith(moduleId) || bundleEntry === normalizedId
|
|
490
|
+
);
|
|
491
|
+
}
|
|
492
|
+
if (moduleIdIndex !== -1) {
|
|
493
|
+
while (typeof allModules[moduleIdIndex] !== "function" && moduleIdIndex < allModules.length) {
|
|
494
|
+
moduleIdIndex++;
|
|
435
495
|
}
|
|
496
|
+
moduleInit = allModules[moduleIdIndex];
|
|
436
497
|
}
|
|
498
|
+
} else {
|
|
499
|
+
moduleInit = allModules.find(
|
|
500
|
+
(bundleEntry) => typeof bundleEntry === "object" && bundleEntry !== null && moduleId in bundleEntry
|
|
501
|
+
)?.[moduleId];
|
|
437
502
|
}
|
|
438
503
|
const exports = {};
|
|
439
504
|
const moduleExports = { exports };
|
|
@@ -473,6 +538,7 @@ function handleTurbopackModule(bundle, moduleId, id) {
|
|
|
473
538
|
};
|
|
474
539
|
}
|
|
475
540
|
},
|
|
541
|
+
// define exports
|
|
476
542
|
s(m) {
|
|
477
543
|
let mod = m;
|
|
478
544
|
if (Array.isArray(m)) {
|
|
@@ -496,18 +562,29 @@ function handleTurbopackModule(bundle, moduleId, id) {
|
|
|
496
562
|
exportNames.add(key);
|
|
497
563
|
}
|
|
498
564
|
},
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
565
|
+
// import ESM
|
|
566
|
+
i(importId) {
|
|
567
|
+
let mod;
|
|
568
|
+
if (typeof importId === "string") {
|
|
569
|
+
const { exportSource, exportName } = /\s+<export (?<exportSource>.*?) as (?<exportName>.*?)>$/.exec(
|
|
570
|
+
importId
|
|
571
|
+
)?.groups ?? {};
|
|
572
|
+
const normalizedId = importId.replace(
|
|
573
|
+
/\s+<export(?<specifier>.*)>$/,
|
|
574
|
+
""
|
|
575
|
+
);
|
|
576
|
+
mod = self.__webpack_require__?.(
|
|
577
|
+
`[${bundle}] ${normalizedId}`
|
|
578
|
+
);
|
|
579
|
+
if (exportSource && exportName && (exportSource === "*" || typeof mod[exportSource] !== "undefined") && typeof mod[exportName] === "undefined") {
|
|
580
|
+
if (exportSource === "*") {
|
|
581
|
+
mod[exportName] = mod;
|
|
582
|
+
} else {
|
|
583
|
+
mod[exportName] = mod[exportSource];
|
|
584
|
+
}
|
|
510
585
|
}
|
|
586
|
+
} else {
|
|
587
|
+
mod = self.__webpack_require__?.(`[${bundle}] ${importId}`);
|
|
511
588
|
}
|
|
512
589
|
if (!("default" in mod) && mod.toString() !== "[object Module]") {
|
|
513
590
|
try {
|
|
@@ -517,12 +594,21 @@ function handleTurbopackModule(bundle, moduleId, id) {
|
|
|
517
594
|
}
|
|
518
595
|
return mod;
|
|
519
596
|
},
|
|
520
|
-
|
|
521
|
-
|
|
597
|
+
// require
|
|
598
|
+
r(requireId) {
|
|
599
|
+
return self.__webpack_require__?.(`[${bundle}] ${requireId}`);
|
|
522
600
|
},
|
|
601
|
+
// value exports
|
|
523
602
|
v(value) {
|
|
524
|
-
|
|
603
|
+
if (typeof value === "function") {
|
|
604
|
+
exports.default = value((vid) => {
|
|
605
|
+
return self.__webpack_require__?.(`[${bundle}] ${vid}`);
|
|
606
|
+
});
|
|
607
|
+
} else {
|
|
608
|
+
exports.default = value;
|
|
609
|
+
}
|
|
525
610
|
},
|
|
611
|
+
// async module initializer
|
|
526
612
|
async a(mod) {
|
|
527
613
|
let result;
|
|
528
614
|
await mod(
|
|
@@ -532,12 +618,30 @@ function handleTurbopackModule(bundle, moduleId, id) {
|
|
|
532
618
|
);
|
|
533
619
|
exports.default = result;
|
|
534
620
|
},
|
|
621
|
+
// async module loader
|
|
535
622
|
async A(Aid) {
|
|
536
623
|
const mod = self.__webpack_require__?.(`[${bundle}] ${Aid}`);
|
|
537
624
|
return mod.default(
|
|
538
625
|
(parentId) => self.__webpack_require__?.(`[${bundle}] ${parentId}`)
|
|
539
626
|
);
|
|
540
627
|
},
|
|
628
|
+
// chunk loader
|
|
629
|
+
l(url) {
|
|
630
|
+
const moduleInitIndex = allModules.indexOf(moduleInit);
|
|
631
|
+
if (moduleInitIndex !== -1) {
|
|
632
|
+
const scriptIndex = allModules.slice(0, moduleInitIndex).findLastIndex((bundleEntry) => bundleEntry instanceof Element);
|
|
633
|
+
if (scriptIndex !== -1) {
|
|
634
|
+
const script = allModules[scriptIndex];
|
|
635
|
+
const scriptSrc = script.getAttribute("data-turbopack-src") || "";
|
|
636
|
+
const nextIndex = scriptSrc.indexOf("/_next");
|
|
637
|
+
const baseUrl = nextIndex !== -1 ? scriptSrc.slice(0, nextIndex) : "";
|
|
638
|
+
const bundleUrl = `[${bundle}] ${baseUrl}/_next/${url}`;
|
|
639
|
+
return self.__webpack_chunk_load__?.(bundleUrl, bundle);
|
|
640
|
+
}
|
|
641
|
+
}
|
|
642
|
+
throw new Error(`Failed to load chunk ${url} for module ${id}`);
|
|
643
|
+
},
|
|
644
|
+
// global
|
|
541
645
|
g: self.__remote_components_turbopack_global__[bundle],
|
|
542
646
|
m: moduleExports,
|
|
543
647
|
e: exports
|