remote-components 0.4.9 → 0.4.10
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/{chunk-6NUHDFSH.js → chunk-3PR3SWYZ.js} +2 -2
- package/dist/{chunk-6NUHDFSH.js.map → chunk-3PR3SWYZ.js.map} +1 -1
- package/dist/{chunk-SELGX4Y2.cjs → chunk-6PZEDIAK.cjs} +2 -2
- package/dist/{chunk-SELGX4Y2.cjs.map → chunk-6PZEDIAK.cjs.map} +1 -1
- package/dist/{chunk-X6SKTJ5N.js → chunk-GR5FN73U.js} +3 -3
- package/dist/{chunk-EZG36EB4.cjs → chunk-HZP4FWPG.cjs} +22 -22
- package/dist/{chunk-ZJW3GQTP.js → chunk-M6ACTSVB.js} +2 -2
- package/dist/{chunk-4XWEMPKO.js → chunk-N6AJM72A.js} +5 -5
- package/dist/{chunk-XPMI4K3U.cjs → chunk-OSSMJQFE.cjs} +19 -19
- package/dist/{chunk-6NAV4SCF.cjs → chunk-PCHSF5LH.cjs} +23 -23
- package/dist/{chunk-T6E2WPAB.js → chunk-RHRDUJ3K.js} +3 -3
- package/dist/{chunk-J42V6HSP.cjs → chunk-RZ224NSH.cjs} +18 -18
- package/dist/{chunk-JYGC7T6L.js → chunk-VFK4HGZT.js} +2 -2
- package/dist/{chunk-VB64GQX7.cjs → chunk-XWRB6CEA.cjs} +3 -3
- package/dist/config/nextjs.cjs +5 -5
- package/dist/config/nextjs.js +1 -1
- package/dist/host/html.cjs +19 -19
- package/dist/host/html.js +7 -7
- package/dist/host/nextjs/app/client-only.cjs +11 -11
- package/dist/host/nextjs/app/client-only.js +6 -6
- package/dist/host/nextjs/pages/client-only.cjs +42 -24
- package/dist/host/nextjs/pages/client-only.cjs.map +1 -1
- package/dist/host/nextjs/pages/client-only.d.ts +1 -1
- package/dist/host/nextjs/pages/client-only.js +42 -24
- package/dist/host/nextjs/pages/client-only.js.map +1 -1
- package/dist/host/react.cjs +7 -7
- package/dist/host/react.js +6 -6
- package/dist/internal/host/shared/shared-module-resolver.cjs +1 -1
- package/dist/internal/host/shared/shared-module-resolver.cjs.map +1 -1
- package/dist/internal/host/shared/shared-module-resolver.d.ts +4 -3
- package/dist/internal/host/shared/shared-module-resolver.js +1 -1
- package/dist/internal/host/shared/shared-module-resolver.js.map +1 -1
- package/dist/{turbopack-WAERWSWW.js → turbopack-6BSS3SYN.js} +5 -5
- package/dist/turbopack-6BSS3SYN.js.map +1 -0
- package/dist/{turbopack-6BXAJGS5.cjs → turbopack-UMJ7SLJL.cjs} +12 -12
- package/dist/{turbopack-6BXAJGS5.cjs.map → turbopack-UMJ7SLJL.cjs.map} +1 -1
- package/dist/{webpack-ZYOBNVFE.js → webpack-4QYGIVE6.js} +7 -5
- package/dist/webpack-4QYGIVE6.js.map +1 -0
- package/dist/{webpack-VTSF2B2G.cjs → webpack-65BVWX2U.cjs} +13 -11
- package/dist/{webpack-ZYOBNVFE.js.map → webpack-65BVWX2U.cjs.map} +1 -1
- package/package.json +1 -1
- package/dist/turbopack-WAERWSWW.js.map +0 -1
- package/dist/webpack-VTSF2B2G.cjs.map +0 -1
- /package/dist/{chunk-X6SKTJ5N.js.map → chunk-GR5FN73U.js.map} +0 -0
- /package/dist/{chunk-EZG36EB4.cjs.map → chunk-HZP4FWPG.cjs.map} +0 -0
- /package/dist/{chunk-ZJW3GQTP.js.map → chunk-M6ACTSVB.js.map} +0 -0
- /package/dist/{chunk-4XWEMPKO.js.map → chunk-N6AJM72A.js.map} +0 -0
- /package/dist/{chunk-XPMI4K3U.cjs.map → chunk-OSSMJQFE.cjs.map} +0 -0
- /package/dist/{chunk-6NAV4SCF.cjs.map → chunk-PCHSF5LH.cjs.map} +0 -0
- /package/dist/{chunk-T6E2WPAB.js.map → chunk-RHRDUJ3K.js.map} +0 -0
- /package/dist/{chunk-J42V6HSP.cjs.map → chunk-RZ224NSH.cjs.map} +0 -0
- /package/dist/{chunk-JYGC7T6L.js.map → chunk-VFK4HGZT.js.map} +0 -0
- /package/dist/{chunk-VB64GQX7.cjs.map → chunk-XWRB6CEA.cjs.map} +0 -0
package/dist/host/html.cjs
CHANGED
|
@@ -7,16 +7,16 @@
|
|
|
7
7
|
|
|
8
8
|
|
|
9
9
|
|
|
10
|
-
var
|
|
11
|
-
require('../chunk-
|
|
12
|
-
require('../chunk-
|
|
13
|
-
require('../chunk-
|
|
10
|
+
var _chunkHZP4FWPGcjs = require('../chunk-HZP4FWPG.cjs');
|
|
11
|
+
require('../chunk-XWRB6CEA.cjs');
|
|
12
|
+
require('../chunk-RZ224NSH.cjs');
|
|
13
|
+
require('../chunk-PCHSF5LH.cjs');
|
|
14
14
|
require('../chunk-3AX5WLZD.cjs');
|
|
15
15
|
|
|
16
16
|
|
|
17
17
|
|
|
18
18
|
|
|
19
|
-
var
|
|
19
|
+
var _chunk6PZEDIAKcjs = require('../chunk-6PZEDIAK.cjs');
|
|
20
20
|
|
|
21
21
|
|
|
22
22
|
var _chunkZ2SLBFQLcjs = require('../chunk-Z2SLBFQL.cjs');
|
|
@@ -125,10 +125,10 @@ async function getRuntime(type, url, bundle, shared, remoteShared, resolveClient
|
|
|
125
125
|
};
|
|
126
126
|
}
|
|
127
127
|
if (type === "webpack") {
|
|
128
|
-
const { webpackRuntime } = await Promise.resolve().then(() => _interopRequireWildcard(require("../webpack-
|
|
128
|
+
const { webpackRuntime } = await Promise.resolve().then(() => _interopRequireWildcard(require("../webpack-65BVWX2U.cjs")));
|
|
129
129
|
return webpackRuntime(bundle, shared, remoteShared, resolveClientUrl);
|
|
130
130
|
} else if (type === "turbopack") {
|
|
131
|
-
const { turbopackRuntime } = await Promise.resolve().then(() => _interopRequireWildcard(require("../turbopack-
|
|
131
|
+
const { turbopackRuntime } = await Promise.resolve().then(() => _interopRequireWildcard(require("../turbopack-UMJ7SLJL.cjs")));
|
|
132
132
|
return turbopackRuntime(
|
|
133
133
|
url,
|
|
134
134
|
bundle,
|
|
@@ -149,15 +149,15 @@ async function getRuntime(type, url, bundle, shared, remoteShared, resolveClient
|
|
|
149
149
|
var _jsxruntime = require('react/jsx-runtime');
|
|
150
150
|
if (typeof HTMLElement !== "undefined") {
|
|
151
151
|
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); }
|
|
152
|
-
__init() {this.name =
|
|
153
|
-
__init2() {this.bundle =
|
|
152
|
+
__init() {this.name = _chunk6PZEDIAKcjs.DEFAULT_COMPONENT_NAME}
|
|
153
|
+
__init2() {this.bundle = _chunk6PZEDIAKcjs.DEFAULT_BUNDLE_NAME}
|
|
154
154
|
|
|
155
155
|
__init3() {this.__next = null}
|
|
156
156
|
__init4() {this.fouc = null}
|
|
157
|
-
__init5() {this.hostState =
|
|
157
|
+
__init5() {this.hostState = _chunkHZP4FWPGcjs.createHostState.call(void 0, )}
|
|
158
158
|
__init6() {this.root = null}
|
|
159
159
|
|
|
160
|
-
__init7() {this.emitter =
|
|
160
|
+
__init7() {this.emitter = _chunkHZP4FWPGcjs.makeEventEmitter.call(void 0, this)}
|
|
161
161
|
|
|
162
162
|
|
|
163
163
|
|
|
@@ -279,10 +279,10 @@ if (typeof HTMLElement !== "undefined") {
|
|
|
279
279
|
let url = null;
|
|
280
280
|
let html = this.innerHTML;
|
|
281
281
|
if (src) {
|
|
282
|
-
url =
|
|
283
|
-
this.name =
|
|
282
|
+
url = _chunkHZP4FWPGcjs.getClientOrServerUrl.call(void 0, src, window.location.href);
|
|
283
|
+
this.name = _chunkHZP4FWPGcjs.resolveNameFromSrc.call(void 0, src, this.name);
|
|
284
284
|
}
|
|
285
|
-
const resolveClientUrl = url ?
|
|
285
|
+
const resolveClientUrl = url ? _chunkHZP4FWPGcjs.bindResolveClientUrl.call(void 0, this.resolveClientUrl, url.href) : void 0;
|
|
286
286
|
if (!remoteComponentChild && url) {
|
|
287
287
|
const fetchInit = {
|
|
288
288
|
credentials: this.credentials || "same-origin"
|
|
@@ -293,7 +293,7 @@ if (typeof HTMLElement !== "undefined") {
|
|
|
293
293
|
);
|
|
294
294
|
let res;
|
|
295
295
|
try {
|
|
296
|
-
res = await
|
|
296
|
+
res = await _chunkHZP4FWPGcjs.fetchWithHooks.call(void 0, resolvedUrl, fetchInit, {
|
|
297
297
|
onRequest: this.onRequest,
|
|
298
298
|
onResponse: this.onResponse,
|
|
299
299
|
abortController: this.hostState.abortController
|
|
@@ -320,7 +320,7 @@ if (typeof HTMLElement !== "undefined") {
|
|
|
320
320
|
}
|
|
321
321
|
}
|
|
322
322
|
const effectiveUrl = _nullishCoalesce(url, () => ( new URL(window.location.href)));
|
|
323
|
-
const { doc, parsed } =
|
|
323
|
+
const { doc, parsed } = _chunkHZP4FWPGcjs.preparePipeline.call(void 0, {
|
|
324
324
|
html,
|
|
325
325
|
name: this.name,
|
|
326
326
|
url: effectiveUrl,
|
|
@@ -553,9 +553,9 @@ if (typeof HTMLElement !== "undefined") {
|
|
|
553
553
|
};
|
|
554
554
|
if (rsc) {
|
|
555
555
|
_optionalChain([rsc, 'access', _62 => _62.parentElement, 'optionalAccess', _63 => _63.removeChild, 'call', _64 => _64(rsc)]);
|
|
556
|
-
const rscName = `__remote_component_rsc_${
|
|
556
|
+
const rscName = `__remote_component_rsc_${_chunk6PZEDIAKcjs.escapeString.call(void 0,
|
|
557
557
|
url.href
|
|
558
|
-
)}_${
|
|
558
|
+
)}_${_chunk6PZEDIAKcjs.escapeString.call(void 0, this.name)}`;
|
|
559
559
|
const rscClone = document.createElement("script");
|
|
560
560
|
rscClone.id = `${rscName}_rsc`;
|
|
561
561
|
rscClone.textContent = _nullishCoalesce(_optionalChain([rsc, 'access', _65 => _65.textContent, 'optionalAccess', _66 => _66.replace, 'call', _67 => _67(
|
|
@@ -568,7 +568,7 @@ if (typeof HTMLElement !== "undefined") {
|
|
|
568
568
|
name,
|
|
569
569
|
initial
|
|
570
570
|
}) => {
|
|
571
|
-
const stream =
|
|
571
|
+
const stream = _chunkHZP4FWPGcjs.createRSCStream.call(void 0,
|
|
572
572
|
rscName,
|
|
573
573
|
_nullishCoalesce(self[rscName], () => ( [`0:[null]
|
|
574
574
|
`]))
|
package/dist/host/html.js
CHANGED
|
@@ -7,16 +7,16 @@ import {
|
|
|
7
7
|
makeEventEmitter,
|
|
8
8
|
preparePipeline,
|
|
9
9
|
resolveNameFromSrc
|
|
10
|
-
} from "../chunk-
|
|
11
|
-
import "../chunk-
|
|
12
|
-
import "../chunk-
|
|
13
|
-
import "../chunk-
|
|
10
|
+
} from "../chunk-N6AJM72A.js";
|
|
11
|
+
import "../chunk-M6ACTSVB.js";
|
|
12
|
+
import "../chunk-GR5FN73U.js";
|
|
13
|
+
import "../chunk-VFK4HGZT.js";
|
|
14
14
|
import "../chunk-LEKG4YWI.js";
|
|
15
15
|
import {
|
|
16
16
|
DEFAULT_BUNDLE_NAME,
|
|
17
17
|
DEFAULT_COMPONENT_NAME,
|
|
18
18
|
escapeString
|
|
19
|
-
} from "../chunk-
|
|
19
|
+
} from "../chunk-3PR3SWYZ.js";
|
|
20
20
|
import {
|
|
21
21
|
getNamespace
|
|
22
22
|
} from "../chunk-D5GNZB6O.js";
|
|
@@ -125,10 +125,10 @@ async function getRuntime(type, url, bundle, shared, remoteShared, resolveClient
|
|
|
125
125
|
};
|
|
126
126
|
}
|
|
127
127
|
if (type === "webpack") {
|
|
128
|
-
const { webpackRuntime } = await import("../webpack-
|
|
128
|
+
const { webpackRuntime } = await import("../webpack-4QYGIVE6.js");
|
|
129
129
|
return webpackRuntime(bundle, shared, remoteShared, resolveClientUrl);
|
|
130
130
|
} else if (type === "turbopack") {
|
|
131
|
-
const { turbopackRuntime } = await import("../turbopack-
|
|
131
|
+
const { turbopackRuntime } = await import("../turbopack-6BSS3SYN.js");
|
|
132
132
|
return turbopackRuntime(
|
|
133
133
|
url,
|
|
134
134
|
bundle,
|
|
@@ -1,19 +1,19 @@
|
|
|
1
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; }"use client";
|
|
2
2
|
|
|
3
3
|
|
|
4
|
-
var
|
|
4
|
+
var _chunkOSSMJQFEcjs = require('../../../chunk-OSSMJQFE.cjs');
|
|
5
5
|
|
|
6
6
|
|
|
7
|
-
var
|
|
8
|
-
require('../../../chunk-
|
|
9
|
-
require('../../../chunk-
|
|
10
|
-
require('../../../chunk-
|
|
7
|
+
var _chunkHZP4FWPGcjs = require('../../../chunk-HZP4FWPG.cjs');
|
|
8
|
+
require('../../../chunk-XWRB6CEA.cjs');
|
|
9
|
+
require('../../../chunk-RZ224NSH.cjs');
|
|
10
|
+
require('../../../chunk-PCHSF5LH.cjs');
|
|
11
11
|
require('../../../chunk-3AX5WLZD.cjs');
|
|
12
12
|
require('../../../chunk-N3SQTOSE.cjs');
|
|
13
13
|
|
|
14
14
|
|
|
15
15
|
|
|
16
|
-
var
|
|
16
|
+
var _chunk6PZEDIAKcjs = require('../../../chunk-6PZEDIAK.cjs');
|
|
17
17
|
require('../../../chunk-Z2SLBFQL.cjs');
|
|
18
18
|
require('../../../chunk-5KTAEO52.cjs');
|
|
19
19
|
|
|
@@ -31,8 +31,8 @@ var _react = require('react');
|
|
|
31
31
|
function resolveForBundle(unbound, bundle) {
|
|
32
32
|
if (!unbound)
|
|
33
33
|
return void 0;
|
|
34
|
-
const remoteSrc = _nullishCoalesce(_optionalChain([
|
|
35
|
-
return
|
|
34
|
+
const remoteSrc = _nullishCoalesce(_optionalChain([_chunk6PZEDIAKcjs.getScope.call(void 0, bundle), 'optionalAccess', _2 => _2.url, 'access', _3 => _3.href]), () => ( ""));
|
|
35
|
+
return _chunkHZP4FWPGcjs.bindResolveClientUrl.call(void 0, unbound, remoteSrc);
|
|
36
36
|
}
|
|
37
37
|
function createImageLoaderSharedEntries({
|
|
38
38
|
bound,
|
|
@@ -41,13 +41,13 @@ function createImageLoaderSharedEntries({
|
|
|
41
41
|
const loaderEntry = (bundle) => {
|
|
42
42
|
const resolveClientUrl = _nullishCoalesce(bound, () => ( resolveForBundle(unbound, bundle)));
|
|
43
43
|
return Promise.resolve({
|
|
44
|
-
default:
|
|
44
|
+
default: _chunk6PZEDIAKcjs.createRemoteImageLoader.call(void 0, bundle, resolveClientUrl),
|
|
45
45
|
__esModule: true
|
|
46
46
|
});
|
|
47
47
|
};
|
|
48
48
|
const imageEntry = async (bundle) => {
|
|
49
49
|
const resolveClientUrl = _nullishCoalesce(bound, () => ( resolveForBundle(unbound, bundle)));
|
|
50
|
-
const rawLoader =
|
|
50
|
+
const rawLoader = _chunk6PZEDIAKcjs.createRemoteImageLoader.call(void 0, bundle, resolveClientUrl);
|
|
51
51
|
const remoteLoader = Object.assign(
|
|
52
52
|
(p) => rawLoader({ ...p, config: { path: "/_next/image" } }),
|
|
53
53
|
{ __next_img_default: true }
|
|
@@ -191,7 +191,7 @@ function ConsumeRemoteComponent2(props) {
|
|
|
191
191
|
return _nullishCoalesce(props.children, () => ( null));
|
|
192
192
|
}
|
|
193
193
|
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
194
|
-
|
|
194
|
+
_chunkOSSMJQFEcjs.ConsumeRemoteComponent,
|
|
195
195
|
{
|
|
196
196
|
...props,
|
|
197
197
|
shared: sharedModules(props.shared, props.resolveClientUrl)
|
|
@@ -1,19 +1,19 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import {
|
|
3
3
|
ConsumeRemoteComponent
|
|
4
|
-
} from "../../../chunk-
|
|
4
|
+
} from "../../../chunk-RHRDUJ3K.js";
|
|
5
5
|
import {
|
|
6
6
|
bindResolveClientUrl
|
|
7
|
-
} from "../../../chunk-
|
|
8
|
-
import "../../../chunk-
|
|
9
|
-
import "../../../chunk-
|
|
10
|
-
import "../../../chunk-
|
|
7
|
+
} from "../../../chunk-N6AJM72A.js";
|
|
8
|
+
import "../../../chunk-M6ACTSVB.js";
|
|
9
|
+
import "../../../chunk-GR5FN73U.js";
|
|
10
|
+
import "../../../chunk-VFK4HGZT.js";
|
|
11
11
|
import "../../../chunk-LEKG4YWI.js";
|
|
12
12
|
import "../../../chunk-RHGEBXPL.js";
|
|
13
13
|
import {
|
|
14
14
|
createRemoteImageLoader,
|
|
15
15
|
getScope
|
|
16
|
-
} from "../../../chunk-
|
|
16
|
+
} from "../../../chunk-3PR3SWYZ.js";
|
|
17
17
|
import "../../../chunk-D5GNZB6O.js";
|
|
18
18
|
import "../../../chunk-STIJO4AG.js";
|
|
19
19
|
import {
|
|
@@ -34,6 +34,9 @@ module.exports = __toCommonJS(pages_client_exports);
|
|
|
34
34
|
var import_jsx_runtime = require("react/jsx-runtime");
|
|
35
35
|
var import_react = require("react");
|
|
36
36
|
var import_pages = require("#remote-components/host/defaults/pages");
|
|
37
|
+
function isPromiseLikeShared(value) {
|
|
38
|
+
return typeof value === "object" && value !== null && "then" in value && typeof value.then === "function";
|
|
39
|
+
}
|
|
37
40
|
function ConsumeRemoteComponent({
|
|
38
41
|
src,
|
|
39
42
|
children,
|
|
@@ -43,27 +46,51 @@ function ConsumeRemoteComponent({
|
|
|
43
46
|
onLoad,
|
|
44
47
|
onRequest,
|
|
45
48
|
onResponse,
|
|
46
|
-
resolveClientUrl
|
|
49
|
+
resolveClientUrl,
|
|
50
|
+
shared: sharedProp
|
|
47
51
|
}) {
|
|
48
52
|
const elementRef = (0, import_react.useRef)(null);
|
|
53
|
+
const onErrorRef = (0, import_react.useRef)(onError);
|
|
54
|
+
onErrorRef.current = onError;
|
|
49
55
|
(0, import_react.useEffect)(() => {
|
|
56
|
+
let cancelled = false;
|
|
50
57
|
const self = globalThis;
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
58
|
+
const syncElement = async () => {
|
|
59
|
+
try {
|
|
60
|
+
const userShared = isPromiseLikeShared(sharedProp) ? await sharedProp : sharedProp;
|
|
61
|
+
if (cancelled)
|
|
62
|
+
return;
|
|
63
|
+
self.__remote_component_shared__ = {
|
|
64
|
+
...import_pages.shared,
|
|
65
|
+
...userShared
|
|
66
|
+
};
|
|
67
|
+
await import("remote-components/host/html");
|
|
68
|
+
if (cancelled)
|
|
69
|
+
return;
|
|
70
|
+
const element = elementRef.current;
|
|
71
|
+
if (!element)
|
|
72
|
+
return;
|
|
73
|
+
element.onRequest = onRequest;
|
|
74
|
+
element.onResponse = onResponse;
|
|
75
|
+
element.resolveClientUrl = resolveClientUrl;
|
|
76
|
+
if (element.getAttribute("src") !== src) {
|
|
77
|
+
element.setAttribute("src", src);
|
|
78
|
+
}
|
|
79
|
+
} catch (error) {
|
|
80
|
+
if (!cancelled) {
|
|
81
|
+
onErrorRef.current?.(error);
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
};
|
|
85
|
+
void syncElement();
|
|
86
|
+
return () => {
|
|
87
|
+
cancelled = true;
|
|
88
|
+
};
|
|
89
|
+
}, [src, onRequest, onResponse, resolveClientUrl, sharedProp]);
|
|
54
90
|
(0, import_react.useEffect)(() => {
|
|
55
91
|
const element = elementRef.current;
|
|
56
92
|
if (!element)
|
|
57
93
|
return;
|
|
58
|
-
if (onRequest) {
|
|
59
|
-
element.onRequest = onRequest;
|
|
60
|
-
}
|
|
61
|
-
if (onResponse) {
|
|
62
|
-
element.onResponse = onResponse;
|
|
63
|
-
}
|
|
64
|
-
if (resolveClientUrl !== void 0) {
|
|
65
|
-
element.resolveClientUrl = resolveClientUrl;
|
|
66
|
-
}
|
|
67
94
|
const handleBeforeLoad = (e) => {
|
|
68
95
|
const customEvent = e;
|
|
69
96
|
onBeforeLoad?.(customEvent.src ?? src);
|
|
@@ -103,17 +130,8 @@ function ConsumeRemoteComponent({
|
|
|
103
130
|
if (onChange)
|
|
104
131
|
element.removeEventListener("change", handleChange);
|
|
105
132
|
};
|
|
106
|
-
}, [
|
|
107
|
-
|
|
108
|
-
onBeforeLoad,
|
|
109
|
-
onChange,
|
|
110
|
-
onError,
|
|
111
|
-
onLoad,
|
|
112
|
-
onRequest,
|
|
113
|
-
onResponse,
|
|
114
|
-
resolveClientUrl
|
|
115
|
-
]);
|
|
116
|
-
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)("remote-component", { ref: elementRef, src, children });
|
|
133
|
+
}, [src, onBeforeLoad, onChange, onError, onLoad]);
|
|
134
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)("remote-component", { ref: elementRef, children });
|
|
117
135
|
}
|
|
118
136
|
// Annotate the CommonJS export names for ESM import in node:
|
|
119
137
|
0 && (module.exports = {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/host/nextjs/pages-client.tsx"],"sourcesContent":["import { useEffect, useRef } from 'react';\nimport type { ConsumeRemoteComponentConfig } from '#internal/host/shared/config';\nimport type {\n OnRequestHook,\n OnResponseHook,\n} from '#internal/host/shared/fetch-interceptors';\nimport type { ResolveClientUrl } from '#internal/runtime/url/resolve-client-url';\nimport { shared } from '#remote-components/host/defaults/pages';\n\n// patch react/jsx-runtime to support the remote-component custom element\ndeclare module 'react/jsx-runtime' {\n // eslint-disable-next-line @typescript-eslint/no-namespace\n export namespace JSX {\n interface IntrinsicElements {\n 'remote-component': {\n src?: string;\n ref?: React.Ref<HTMLElement>;\n children: React.ReactNode;\n };\n }\n }\n}\n\n// Extend HTMLElement to include onRequest/onResponse/resolveClientUrl properties from the custom element\ninterface RemoteComponentElement extends HTMLElement {\n onRequest?: OnRequestHook;\n onResponse?: OnResponseHook;\n resolveClientUrl?: ResolveClientUrl;\n}\n\n/**\n * Props for the Pages Router client-side remote component wrapper.\n *\n * Extends {@link ConsumeRemoteComponentConfig}. The `src` prop is required since\n * the client always needs a source URL to load from.\n */\nexport interface ConsumeRemoteComponentProps\n extends ConsumeRemoteComponentConfig {\n /** The source URL of the remote component. Required for client-side loading. */\n src: string;\n /** Loading fallback content displayed while the remote component is being fetched. */\n children?: React.ReactNode;\n}\n\nexport function ConsumeRemoteComponent({\n src,\n children,\n onBeforeLoad,\n onChange,\n onError,\n onLoad,\n onRequest,\n onResponse,\n resolveClientUrl,\n}: ConsumeRemoteComponentProps) {\n const elementRef = useRef<RemoteComponentElement>(null);\n\n useEffect(() => {\n const self = globalThis as typeof globalThis & {\n __remote_component_shared__?:
|
|
1
|
+
{"version":3,"sources":["../../../../src/host/nextjs/pages-client.tsx"],"sourcesContent":["import { useEffect, useRef } from 'react';\nimport type { ConsumeRemoteComponentConfig } from '#internal/host/shared/config';\nimport type {\n OnRequestHook,\n OnResponseHook,\n} from '#internal/host/shared/fetch-interceptors';\nimport type { SharedModuleFactory } from '#internal/host/shared/shared-broker';\nimport type { ResolveClientUrl } from '#internal/runtime/url/resolve-client-url';\nimport { shared } from '#remote-components/host/defaults/pages';\n\n// patch react/jsx-runtime to support the remote-component custom element\ndeclare module 'react/jsx-runtime' {\n // eslint-disable-next-line @typescript-eslint/no-namespace\n export namespace JSX {\n interface IntrinsicElements {\n 'remote-component': {\n src?: string;\n ref?: React.Ref<HTMLElement>;\n children: React.ReactNode;\n };\n }\n }\n}\n\n// Extend HTMLElement to include onRequest/onResponse/resolveClientUrl properties from the custom element\ninterface RemoteComponentElement extends HTMLElement {\n onRequest?: OnRequestHook;\n onResponse?: OnResponseHook;\n resolveClientUrl?: ResolveClientUrl;\n}\n\ntype SharedModules = Record<string, SharedModuleFactory>;\n\nfunction isPromiseLikeShared(\n value: ConsumeRemoteComponentProps['shared'],\n): value is Promise<SharedModules> {\n return (\n typeof value === 'object' &&\n value !== null &&\n 'then' in value &&\n typeof (value as Promise<SharedModules>).then === 'function'\n );\n}\n\n/**\n * Props for the Pages Router client-side remote component wrapper.\n *\n * Extends {@link ConsumeRemoteComponentConfig}. The `src` prop is required since\n * the client always needs a source URL to load from.\n */\nexport interface ConsumeRemoteComponentProps\n extends ConsumeRemoteComponentConfig {\n /** The source URL of the remote component. Required for client-side loading. */\n src: string;\n /** Loading fallback content displayed while the remote component is being fetched. */\n children?: React.ReactNode;\n}\n\nexport function ConsumeRemoteComponent({\n src,\n children,\n onBeforeLoad,\n onChange,\n onError,\n onLoad,\n onRequest,\n onResponse,\n resolveClientUrl,\n shared: sharedProp,\n}: ConsumeRemoteComponentProps) {\n const elementRef = useRef<RemoteComponentElement>(null);\n const onErrorRef = useRef(onError);\n onErrorRef.current = onError;\n\n useEffect(() => {\n let cancelled = false;\n const self = globalThis as typeof globalThis & {\n __remote_component_shared__?: SharedModules;\n };\n\n const syncElement = async () => {\n try {\n const userShared = isPromiseLikeShared(sharedProp)\n ? await sharedProp\n : sharedProp;\n if (cancelled) return;\n\n // eslint-disable-next-line camelcase\n self.__remote_component_shared__ = {\n ...shared,\n ...userShared,\n };\n await import('remote-components/host/html');\n if (cancelled) return;\n\n const element = elementRef.current;\n if (!element) return;\n\n // Assign instance properties before setting src; the custom element\n // starts loading as soon as the src attribute changes.\n element.onRequest = onRequest;\n element.onResponse = onResponse;\n element.resolveClientUrl = resolveClientUrl;\n\n if (element.getAttribute('src') !== src) {\n element.setAttribute('src', src);\n }\n } catch (error) {\n if (!cancelled) {\n onErrorRef.current?.(error);\n }\n }\n };\n\n void syncElement();\n\n return () => {\n cancelled = true;\n };\n }, [src, onRequest, onResponse, resolveClientUrl, sharedProp]);\n\n useEffect(() => {\n const element = elementRef.current;\n if (!element) return;\n\n // Set up event listeners for lifecycle hooks\n const handleBeforeLoad = (e: Event) => {\n const customEvent = e as CustomEvent & { src?: string };\n onBeforeLoad?.(customEvent.src ?? src);\n };\n const handleLoad = (e: Event) => {\n const customEvent = e as CustomEvent & { src?: string };\n onLoad?.(customEvent.src ?? src);\n };\n const handleError = (e: Event) => {\n const customEvent = e as CustomEvent & { error?: unknown };\n onError?.(customEvent.error);\n };\n const handleChange = (e: Event) => {\n const customEvent = e as CustomEvent & {\n previousSrc?: string | null;\n nextSrc?: string | null;\n previousName?: string;\n nextName?: string;\n };\n onChange?.({\n previousSrc: customEvent.previousSrc ?? null,\n nextSrc: customEvent.nextSrc ?? null,\n previousName: customEvent.previousName,\n nextName: customEvent.nextName,\n });\n };\n\n if (onBeforeLoad) element.addEventListener('beforeload', handleBeforeLoad);\n if (onLoad) element.addEventListener('load', handleLoad);\n if (onError) element.addEventListener('error', handleError);\n if (onChange) element.addEventListener('change', handleChange);\n\n return () => {\n if (onBeforeLoad)\n element.removeEventListener('beforeload', handleBeforeLoad);\n if (onLoad) element.removeEventListener('load', handleLoad);\n if (onError) element.removeEventListener('error', handleError);\n if (onChange) element.removeEventListener('change', handleChange);\n };\n }, [src, onBeforeLoad, onChange, onError, onLoad]);\n\n return <remote-component ref={elementRef}>{children}</remote-component>;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAuKS;AAvKT,mBAAkC;AAQlC,mBAAuB;AAyBvB,SAAS,oBACP,OACiC;AACjC,SACE,OAAO,UAAU,YACjB,UAAU,QACV,UAAU,SACV,OAAQ,MAAiC,SAAS;AAEtD;AAgBO,SAAS,uBAAuB;AAAA,EACrC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA,QAAQ;AACV,GAAgC;AAC9B,QAAM,iBAAa,qBAA+B,IAAI;AACtD,QAAM,iBAAa,qBAAO,OAAO;AACjC,aAAW,UAAU;AAErB,8BAAU,MAAM;AACd,QAAI,YAAY;AAChB,UAAM,OAAO;AAIb,UAAM,cAAc,YAAY;AAC9B,UAAI;AACF,cAAM,aAAa,oBAAoB,UAAU,IAC7C,MAAM,aACN;AACJ,YAAI;AAAW;AAGf,aAAK,8BAA8B;AAAA,UACjC,GAAG;AAAA,UACH,GAAG;AAAA,QACL;AACA,cAAM,OAAO,6BAA6B;AAC1C,YAAI;AAAW;AAEf,cAAM,UAAU,WAAW;AAC3B,YAAI,CAAC;AAAS;AAId,gBAAQ,YAAY;AACpB,gBAAQ,aAAa;AACrB,gBAAQ,mBAAmB;AAE3B,YAAI,QAAQ,aAAa,KAAK,MAAM,KAAK;AACvC,kBAAQ,aAAa,OAAO,GAAG;AAAA,QACjC;AAAA,MACF,SAAS,OAAP;AACA,YAAI,CAAC,WAAW;AACd,qBAAW,UAAU,KAAK;AAAA,QAC5B;AAAA,MACF;AAAA,IACF;AAEA,SAAK,YAAY;AAEjB,WAAO,MAAM;AACX,kBAAY;AAAA,IACd;AAAA,EACF,GAAG,CAAC,KAAK,WAAW,YAAY,kBAAkB,UAAU,CAAC;AAE7D,8BAAU,MAAM;AACd,UAAM,UAAU,WAAW;AAC3B,QAAI,CAAC;AAAS;AAGd,UAAM,mBAAmB,CAAC,MAAa;AACrC,YAAM,cAAc;AACpB,qBAAe,YAAY,OAAO,GAAG;AAAA,IACvC;AACA,UAAM,aAAa,CAAC,MAAa;AAC/B,YAAM,cAAc;AACpB,eAAS,YAAY,OAAO,GAAG;AAAA,IACjC;AACA,UAAM,cAAc,CAAC,MAAa;AAChC,YAAM,cAAc;AACpB,gBAAU,YAAY,KAAK;AAAA,IAC7B;AACA,UAAM,eAAe,CAAC,MAAa;AACjC,YAAM,cAAc;AAMpB,iBAAW;AAAA,QACT,aAAa,YAAY,eAAe;AAAA,QACxC,SAAS,YAAY,WAAW;AAAA,QAChC,cAAc,YAAY;AAAA,QAC1B,UAAU,YAAY;AAAA,MACxB,CAAC;AAAA,IACH;AAEA,QAAI;AAAc,cAAQ,iBAAiB,cAAc,gBAAgB;AACzE,QAAI;AAAQ,cAAQ,iBAAiB,QAAQ,UAAU;AACvD,QAAI;AAAS,cAAQ,iBAAiB,SAAS,WAAW;AAC1D,QAAI;AAAU,cAAQ,iBAAiB,UAAU,YAAY;AAE7D,WAAO,MAAM;AACX,UAAI;AACF,gBAAQ,oBAAoB,cAAc,gBAAgB;AAC5D,UAAI;AAAQ,gBAAQ,oBAAoB,QAAQ,UAAU;AAC1D,UAAI;AAAS,gBAAQ,oBAAoB,SAAS,WAAW;AAC7D,UAAI;AAAU,gBAAQ,oBAAoB,UAAU,YAAY;AAAA,IAClE;AAAA,EACF,GAAG,CAAC,KAAK,cAAc,UAAU,SAAS,MAAM,CAAC;AAEjD,SAAO,4CAAC,sBAAiB,KAAK,YAAa,UAAS;AACtD;","names":[]}
|
|
@@ -26,6 +26,6 @@ interface ConsumeRemoteComponentProps extends ConsumeRemoteComponentConfig {
|
|
|
26
26
|
/** Loading fallback content displayed while the remote component is being fetched. */
|
|
27
27
|
children?: React.ReactNode;
|
|
28
28
|
}
|
|
29
|
-
declare function ConsumeRemoteComponent({ src, children, onBeforeLoad, onChange, onError, onLoad, onRequest, onResponse, resolveClientUrl, }: ConsumeRemoteComponentProps): react_jsx_runtime.JSX.Element;
|
|
29
|
+
declare function ConsumeRemoteComponent({ src, children, onBeforeLoad, onChange, onError, onLoad, onRequest, onResponse, resolveClientUrl, shared: sharedProp, }: ConsumeRemoteComponentProps): react_jsx_runtime.JSX.Element;
|
|
30
30
|
|
|
31
31
|
export { ConsumeRemoteComponent, ConsumeRemoteComponentProps };
|
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
import { jsx } from "react/jsx-runtime";
|
|
2
2
|
import { useEffect, useRef } from "react";
|
|
3
3
|
import { shared } from "#remote-components/host/defaults/pages";
|
|
4
|
+
function isPromiseLikeShared(value) {
|
|
5
|
+
return typeof value === "object" && value !== null && "then" in value && typeof value.then === "function";
|
|
6
|
+
}
|
|
4
7
|
function ConsumeRemoteComponent({
|
|
5
8
|
src,
|
|
6
9
|
children,
|
|
@@ -10,27 +13,51 @@ function ConsumeRemoteComponent({
|
|
|
10
13
|
onLoad,
|
|
11
14
|
onRequest,
|
|
12
15
|
onResponse,
|
|
13
|
-
resolveClientUrl
|
|
16
|
+
resolveClientUrl,
|
|
17
|
+
shared: sharedProp
|
|
14
18
|
}) {
|
|
15
19
|
const elementRef = useRef(null);
|
|
20
|
+
const onErrorRef = useRef(onError);
|
|
21
|
+
onErrorRef.current = onError;
|
|
16
22
|
useEffect(() => {
|
|
23
|
+
let cancelled = false;
|
|
17
24
|
const self = globalThis;
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
25
|
+
const syncElement = async () => {
|
|
26
|
+
try {
|
|
27
|
+
const userShared = isPromiseLikeShared(sharedProp) ? await sharedProp : sharedProp;
|
|
28
|
+
if (cancelled)
|
|
29
|
+
return;
|
|
30
|
+
self.__remote_component_shared__ = {
|
|
31
|
+
...shared,
|
|
32
|
+
...userShared
|
|
33
|
+
};
|
|
34
|
+
await import("remote-components/host/html");
|
|
35
|
+
if (cancelled)
|
|
36
|
+
return;
|
|
37
|
+
const element = elementRef.current;
|
|
38
|
+
if (!element)
|
|
39
|
+
return;
|
|
40
|
+
element.onRequest = onRequest;
|
|
41
|
+
element.onResponse = onResponse;
|
|
42
|
+
element.resolveClientUrl = resolveClientUrl;
|
|
43
|
+
if (element.getAttribute("src") !== src) {
|
|
44
|
+
element.setAttribute("src", src);
|
|
45
|
+
}
|
|
46
|
+
} catch (error) {
|
|
47
|
+
if (!cancelled) {
|
|
48
|
+
onErrorRef.current?.(error);
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
};
|
|
52
|
+
void syncElement();
|
|
53
|
+
return () => {
|
|
54
|
+
cancelled = true;
|
|
55
|
+
};
|
|
56
|
+
}, [src, onRequest, onResponse, resolveClientUrl, sharedProp]);
|
|
21
57
|
useEffect(() => {
|
|
22
58
|
const element = elementRef.current;
|
|
23
59
|
if (!element)
|
|
24
60
|
return;
|
|
25
|
-
if (onRequest) {
|
|
26
|
-
element.onRequest = onRequest;
|
|
27
|
-
}
|
|
28
|
-
if (onResponse) {
|
|
29
|
-
element.onResponse = onResponse;
|
|
30
|
-
}
|
|
31
|
-
if (resolveClientUrl !== void 0) {
|
|
32
|
-
element.resolveClientUrl = resolveClientUrl;
|
|
33
|
-
}
|
|
34
61
|
const handleBeforeLoad = (e) => {
|
|
35
62
|
const customEvent = e;
|
|
36
63
|
onBeforeLoad?.(customEvent.src ?? src);
|
|
@@ -70,17 +97,8 @@ function ConsumeRemoteComponent({
|
|
|
70
97
|
if (onChange)
|
|
71
98
|
element.removeEventListener("change", handleChange);
|
|
72
99
|
};
|
|
73
|
-
}, [
|
|
74
|
-
|
|
75
|
-
onBeforeLoad,
|
|
76
|
-
onChange,
|
|
77
|
-
onError,
|
|
78
|
-
onLoad,
|
|
79
|
-
onRequest,
|
|
80
|
-
onResponse,
|
|
81
|
-
resolveClientUrl
|
|
82
|
-
]);
|
|
83
|
-
return /* @__PURE__ */ jsx("remote-component", { ref: elementRef, src, children });
|
|
100
|
+
}, [src, onBeforeLoad, onChange, onError, onLoad]);
|
|
101
|
+
return /* @__PURE__ */ jsx("remote-component", { ref: elementRef, children });
|
|
84
102
|
}
|
|
85
103
|
export {
|
|
86
104
|
ConsumeRemoteComponent
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/host/nextjs/pages-client.tsx"],"sourcesContent":["import { useEffect, useRef } from 'react';\nimport type { ConsumeRemoteComponentConfig } from '#internal/host/shared/config';\nimport type {\n OnRequestHook,\n OnResponseHook,\n} from '#internal/host/shared/fetch-interceptors';\nimport type { ResolveClientUrl } from '#internal/runtime/url/resolve-client-url';\nimport { shared } from '#remote-components/host/defaults/pages';\n\n// patch react/jsx-runtime to support the remote-component custom element\ndeclare module 'react/jsx-runtime' {\n // eslint-disable-next-line @typescript-eslint/no-namespace\n export namespace JSX {\n interface IntrinsicElements {\n 'remote-component': {\n src?: string;\n ref?: React.Ref<HTMLElement>;\n children: React.ReactNode;\n };\n }\n }\n}\n\n// Extend HTMLElement to include onRequest/onResponse/resolveClientUrl properties from the custom element\ninterface RemoteComponentElement extends HTMLElement {\n onRequest?: OnRequestHook;\n onResponse?: OnResponseHook;\n resolveClientUrl?: ResolveClientUrl;\n}\n\n/**\n * Props for the Pages Router client-side remote component wrapper.\n *\n * Extends {@link ConsumeRemoteComponentConfig}. The `src` prop is required since\n * the client always needs a source URL to load from.\n */\nexport interface ConsumeRemoteComponentProps\n extends ConsumeRemoteComponentConfig {\n /** The source URL of the remote component. Required for client-side loading. */\n src: string;\n /** Loading fallback content displayed while the remote component is being fetched. */\n children?: React.ReactNode;\n}\n\nexport function ConsumeRemoteComponent({\n src,\n children,\n onBeforeLoad,\n onChange,\n onError,\n onLoad,\n onRequest,\n onResponse,\n resolveClientUrl,\n}: ConsumeRemoteComponentProps) {\n const elementRef = useRef<RemoteComponentElement>(null);\n\n useEffect(() => {\n const self = globalThis as typeof globalThis & {\n __remote_component_shared__?:
|
|
1
|
+
{"version":3,"sources":["../../../../src/host/nextjs/pages-client.tsx"],"sourcesContent":["import { useEffect, useRef } from 'react';\nimport type { ConsumeRemoteComponentConfig } from '#internal/host/shared/config';\nimport type {\n OnRequestHook,\n OnResponseHook,\n} from '#internal/host/shared/fetch-interceptors';\nimport type { SharedModuleFactory } from '#internal/host/shared/shared-broker';\nimport type { ResolveClientUrl } from '#internal/runtime/url/resolve-client-url';\nimport { shared } from '#remote-components/host/defaults/pages';\n\n// patch react/jsx-runtime to support the remote-component custom element\ndeclare module 'react/jsx-runtime' {\n // eslint-disable-next-line @typescript-eslint/no-namespace\n export namespace JSX {\n interface IntrinsicElements {\n 'remote-component': {\n src?: string;\n ref?: React.Ref<HTMLElement>;\n children: React.ReactNode;\n };\n }\n }\n}\n\n// Extend HTMLElement to include onRequest/onResponse/resolveClientUrl properties from the custom element\ninterface RemoteComponentElement extends HTMLElement {\n onRequest?: OnRequestHook;\n onResponse?: OnResponseHook;\n resolveClientUrl?: ResolveClientUrl;\n}\n\ntype SharedModules = Record<string, SharedModuleFactory>;\n\nfunction isPromiseLikeShared(\n value: ConsumeRemoteComponentProps['shared'],\n): value is Promise<SharedModules> {\n return (\n typeof value === 'object' &&\n value !== null &&\n 'then' in value &&\n typeof (value as Promise<SharedModules>).then === 'function'\n );\n}\n\n/**\n * Props for the Pages Router client-side remote component wrapper.\n *\n * Extends {@link ConsumeRemoteComponentConfig}. The `src` prop is required since\n * the client always needs a source URL to load from.\n */\nexport interface ConsumeRemoteComponentProps\n extends ConsumeRemoteComponentConfig {\n /** The source URL of the remote component. Required for client-side loading. */\n src: string;\n /** Loading fallback content displayed while the remote component is being fetched. */\n children?: React.ReactNode;\n}\n\nexport function ConsumeRemoteComponent({\n src,\n children,\n onBeforeLoad,\n onChange,\n onError,\n onLoad,\n onRequest,\n onResponse,\n resolveClientUrl,\n shared: sharedProp,\n}: ConsumeRemoteComponentProps) {\n const elementRef = useRef<RemoteComponentElement>(null);\n const onErrorRef = useRef(onError);\n onErrorRef.current = onError;\n\n useEffect(() => {\n let cancelled = false;\n const self = globalThis as typeof globalThis & {\n __remote_component_shared__?: SharedModules;\n };\n\n const syncElement = async () => {\n try {\n const userShared = isPromiseLikeShared(sharedProp)\n ? await sharedProp\n : sharedProp;\n if (cancelled) return;\n\n // eslint-disable-next-line camelcase\n self.__remote_component_shared__ = {\n ...shared,\n ...userShared,\n };\n await import('remote-components/host/html');\n if (cancelled) return;\n\n const element = elementRef.current;\n if (!element) return;\n\n // Assign instance properties before setting src; the custom element\n // starts loading as soon as the src attribute changes.\n element.onRequest = onRequest;\n element.onResponse = onResponse;\n element.resolveClientUrl = resolveClientUrl;\n\n if (element.getAttribute('src') !== src) {\n element.setAttribute('src', src);\n }\n } catch (error) {\n if (!cancelled) {\n onErrorRef.current?.(error);\n }\n }\n };\n\n void syncElement();\n\n return () => {\n cancelled = true;\n };\n }, [src, onRequest, onResponse, resolveClientUrl, sharedProp]);\n\n useEffect(() => {\n const element = elementRef.current;\n if (!element) return;\n\n // Set up event listeners for lifecycle hooks\n const handleBeforeLoad = (e: Event) => {\n const customEvent = e as CustomEvent & { src?: string };\n onBeforeLoad?.(customEvent.src ?? src);\n };\n const handleLoad = (e: Event) => {\n const customEvent = e as CustomEvent & { src?: string };\n onLoad?.(customEvent.src ?? src);\n };\n const handleError = (e: Event) => {\n const customEvent = e as CustomEvent & { error?: unknown };\n onError?.(customEvent.error);\n };\n const handleChange = (e: Event) => {\n const customEvent = e as CustomEvent & {\n previousSrc?: string | null;\n nextSrc?: string | null;\n previousName?: string;\n nextName?: string;\n };\n onChange?.({\n previousSrc: customEvent.previousSrc ?? null,\n nextSrc: customEvent.nextSrc ?? null,\n previousName: customEvent.previousName,\n nextName: customEvent.nextName,\n });\n };\n\n if (onBeforeLoad) element.addEventListener('beforeload', handleBeforeLoad);\n if (onLoad) element.addEventListener('load', handleLoad);\n if (onError) element.addEventListener('error', handleError);\n if (onChange) element.addEventListener('change', handleChange);\n\n return () => {\n if (onBeforeLoad)\n element.removeEventListener('beforeload', handleBeforeLoad);\n if (onLoad) element.removeEventListener('load', handleLoad);\n if (onError) element.removeEventListener('error', handleError);\n if (onChange) element.removeEventListener('change', handleChange);\n };\n }, [src, onBeforeLoad, onChange, onError, onLoad]);\n\n return <remote-component ref={elementRef}>{children}</remote-component>;\n}\n"],"mappings":"AAuKS;AAvKT,SAAS,WAAW,cAAc;AAQlC,SAAS,cAAc;AAyBvB,SAAS,oBACP,OACiC;AACjC,SACE,OAAO,UAAU,YACjB,UAAU,QACV,UAAU,SACV,OAAQ,MAAiC,SAAS;AAEtD;AAgBO,SAAS,uBAAuB;AAAA,EACrC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA,QAAQ;AACV,GAAgC;AAC9B,QAAM,aAAa,OAA+B,IAAI;AACtD,QAAM,aAAa,OAAO,OAAO;AACjC,aAAW,UAAU;AAErB,YAAU,MAAM;AACd,QAAI,YAAY;AAChB,UAAM,OAAO;AAIb,UAAM,cAAc,YAAY;AAC9B,UAAI;AACF,cAAM,aAAa,oBAAoB,UAAU,IAC7C,MAAM,aACN;AACJ,YAAI;AAAW;AAGf,aAAK,8BAA8B;AAAA,UACjC,GAAG;AAAA,UACH,GAAG;AAAA,QACL;AACA,cAAM,OAAO,6BAA6B;AAC1C,YAAI;AAAW;AAEf,cAAM,UAAU,WAAW;AAC3B,YAAI,CAAC;AAAS;AAId,gBAAQ,YAAY;AACpB,gBAAQ,aAAa;AACrB,gBAAQ,mBAAmB;AAE3B,YAAI,QAAQ,aAAa,KAAK,MAAM,KAAK;AACvC,kBAAQ,aAAa,OAAO,GAAG;AAAA,QACjC;AAAA,MACF,SAAS,OAAP;AACA,YAAI,CAAC,WAAW;AACd,qBAAW,UAAU,KAAK;AAAA,QAC5B;AAAA,MACF;AAAA,IACF;AAEA,SAAK,YAAY;AAEjB,WAAO,MAAM;AACX,kBAAY;AAAA,IACd;AAAA,EACF,GAAG,CAAC,KAAK,WAAW,YAAY,kBAAkB,UAAU,CAAC;AAE7D,YAAU,MAAM;AACd,UAAM,UAAU,WAAW;AAC3B,QAAI,CAAC;AAAS;AAGd,UAAM,mBAAmB,CAAC,MAAa;AACrC,YAAM,cAAc;AACpB,qBAAe,YAAY,OAAO,GAAG;AAAA,IACvC;AACA,UAAM,aAAa,CAAC,MAAa;AAC/B,YAAM,cAAc;AACpB,eAAS,YAAY,OAAO,GAAG;AAAA,IACjC;AACA,UAAM,cAAc,CAAC,MAAa;AAChC,YAAM,cAAc;AACpB,gBAAU,YAAY,KAAK;AAAA,IAC7B;AACA,UAAM,eAAe,CAAC,MAAa;AACjC,YAAM,cAAc;AAMpB,iBAAW;AAAA,QACT,aAAa,YAAY,eAAe;AAAA,QACxC,SAAS,YAAY,WAAW;AAAA,QAChC,cAAc,YAAY;AAAA,QAC1B,UAAU,YAAY;AAAA,MACxB,CAAC;AAAA,IACH;AAEA,QAAI;AAAc,cAAQ,iBAAiB,cAAc,gBAAgB;AACzE,QAAI;AAAQ,cAAQ,iBAAiB,QAAQ,UAAU;AACvD,QAAI;AAAS,cAAQ,iBAAiB,SAAS,WAAW;AAC1D,QAAI;AAAU,cAAQ,iBAAiB,UAAU,YAAY;AAE7D,WAAO,MAAM;AACX,UAAI;AACF,gBAAQ,oBAAoB,cAAc,gBAAgB;AAC5D,UAAI;AAAQ,gBAAQ,oBAAoB,QAAQ,UAAU;AAC1D,UAAI;AAAS,gBAAQ,oBAAoB,SAAS,WAAW;AAC7D,UAAI;AAAU,gBAAQ,oBAAoB,UAAU,YAAY;AAAA,IAClE;AAAA,EACF,GAAG,CAAC,KAAK,cAAc,UAAU,SAAS,MAAM,CAAC;AAEjD,SAAO,oBAAC,sBAAiB,KAAK,YAAa,UAAS;AACtD;","names":[]}
|
package/dist/host/react.cjs
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
"use strict";Object.defineProperty(exports, "__esModule", {value: true});
|
|
2
2
|
|
|
3
3
|
|
|
4
|
-
var
|
|
5
|
-
require('../chunk-
|
|
6
|
-
require('../chunk-
|
|
7
|
-
require('../chunk-
|
|
8
|
-
require('../chunk-
|
|
4
|
+
var _chunkOSSMJQFEcjs = require('../chunk-OSSMJQFE.cjs');
|
|
5
|
+
require('../chunk-HZP4FWPG.cjs');
|
|
6
|
+
require('../chunk-XWRB6CEA.cjs');
|
|
7
|
+
require('../chunk-RZ224NSH.cjs');
|
|
8
|
+
require('../chunk-PCHSF5LH.cjs');
|
|
9
9
|
require('../chunk-3AX5WLZD.cjs');
|
|
10
10
|
require('../chunk-N3SQTOSE.cjs');
|
|
11
|
-
require('../chunk-
|
|
11
|
+
require('../chunk-6PZEDIAK.cjs');
|
|
12
12
|
require('../chunk-Z2SLBFQL.cjs');
|
|
13
13
|
require('../chunk-5KTAEO52.cjs');
|
|
14
14
|
require('../chunk-BBXVML3D.cjs');
|
|
@@ -18,5 +18,5 @@ require('../chunk-SHFJ5OQA.cjs');
|
|
|
18
18
|
|
|
19
19
|
|
|
20
20
|
|
|
21
|
-
exports.ConsumeRemoteComponent =
|
|
21
|
+
exports.ConsumeRemoteComponent = _chunkOSSMJQFEcjs.ConsumeRemoteComponent; exports.useRemoteNavigate = _chunkOSSMJQFEcjs.useRemoteNavigate;
|
|
22
22
|
//# sourceMappingURL=react.cjs.map
|
package/dist/host/react.js
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
import {
|
|
2
2
|
ConsumeRemoteComponent,
|
|
3
3
|
useRemoteNavigate
|
|
4
|
-
} from "../chunk-
|
|
5
|
-
import "../chunk-
|
|
6
|
-
import "../chunk-
|
|
7
|
-
import "../chunk-
|
|
8
|
-
import "../chunk-
|
|
4
|
+
} from "../chunk-RHRDUJ3K.js";
|
|
5
|
+
import "../chunk-N6AJM72A.js";
|
|
6
|
+
import "../chunk-M6ACTSVB.js";
|
|
7
|
+
import "../chunk-GR5FN73U.js";
|
|
8
|
+
import "../chunk-VFK4HGZT.js";
|
|
9
9
|
import "../chunk-LEKG4YWI.js";
|
|
10
10
|
import "../chunk-RHGEBXPL.js";
|
|
11
|
-
import "../chunk-
|
|
11
|
+
import "../chunk-3PR3SWYZ.js";
|
|
12
12
|
import "../chunk-D5GNZB6O.js";
|
|
13
13
|
import "../chunk-STIJO4AG.js";
|
|
14
14
|
import "../chunk-ULXU6XWH.js";
|
|
@@ -70,7 +70,7 @@ function buildHostShared(userShared, resolveClientUrl, options) {
|
|
|
70
70
|
...self.__remote_component_host_shared_modules__,
|
|
71
71
|
...userShared
|
|
72
72
|
};
|
|
73
|
-
if (options?.
|
|
73
|
+
if (options?.includePagesClientSharedGlobal) {
|
|
74
74
|
Object.assign(result, self.__remote_component_shared__);
|
|
75
75
|
}
|
|
76
76
|
return result;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/host/shared/shared-module-resolver.ts"],"sourcesContent":["import type { InternalResolveClientUrl } from '#internal/host/server/types';\nimport { sharedPolyfills } from '#internal/host/shared/polyfill';\nimport type { SharedModuleFactory } from '#internal/host/shared/shared-broker';\n\n/**\n * The core React packages that are always shared between host and remote.\n */\nexport const CORE_REACT_SHARED_KEYS = [\n 'react',\n 'react/jsx-dev-runtime',\n 'react/jsx-runtime',\n 'react-dom',\n 'react-dom/client',\n] as const;\n\n/**\n * Maps each core React package to its shared-module manifest ID.\n * These IDs are emitted into sharedManifest for the default React entries.\n * For example, `react` maps to `/react/index.js`.\n */\nexport const CORE_REACT_SHARED_MODULE_IDS: Record<string, string> = {\n react: '/react/index.js',\n 'react/jsx-dev-runtime': '/react/jsx-dev-runtime.js',\n 'react/jsx-runtime': '/react/jsx-runtime.js',\n 'react-dom': '/react-dom/index.js',\n 'react-dom/client': '/react-dom/client.js',\n};\n\n/**\n * The vendorShared record used by the Next.js config to map React packages\n * to their shared-module ID string literals. Derived from\n * CORE_REACT_SHARED_MODULE_IDS but excludes `react-dom/client` to match the\n * existing config behavior.\n */\nexport const VENDOR_SHARED: Record<string, string> = Object.fromEntries(\n Object.entries(CORE_REACT_SHARED_MODULE_IDS)\n .filter(([key]) => key !== 'react-dom/client')\n .map(([key, path]) => [key, `'${path}'`]),\n);\n\n/**\n * Builds the `coreShared` map for the Turbopack runtime's\n * `initializeSharedModules`. Each entry is an async factory that dynamically\n * imports the corresponding React package. User-provided shared modules\n * override core entries (e.g. to supply a pinned React version).\n */\nexport function buildCoreShared(\n userShared?: Record<string, SharedModuleFactory>,\n): Record<string, SharedModuleFactory> {\n return {\n react: async () => (await import('react')).default,\n 'react-dom': async () => (await import('react-dom')).default,\n 'react/jsx-dev-runtime': async () =>\n (await import('react/jsx-dev-runtime')).default,\n 'react/jsx-runtime': async () =>\n (await import('react/jsx-runtime')).default,\n 'react-dom/client': async () => (await import('react-dom/client')).default,\n ...userShared,\n };\n}\n\ninterface HostSharedGlobals {\n __remote_component_host_shared_modules__?: Record<\n string,\n SharedModuleFactory\n >;\n __remote_component_shared__?: Record<string, SharedModuleFactory>;\n}\n\n/**\n * Builds the merged host shared modules map with a consistent merge priority:\n * 1. Polyfills (lowest priority — fallback implementations)\n * 2. Global host shared modules (`__remote_component_host_shared_modules__`)\n * 3. User-provided shared modules (highest priority — explicit overrides)\n *\n * Some callers also include `__remote_component_shared__
|
|
1
|
+
{"version":3,"sources":["../../../../src/host/shared/shared-module-resolver.ts"],"sourcesContent":["import type { InternalResolveClientUrl } from '#internal/host/server/types';\nimport { sharedPolyfills } from '#internal/host/shared/polyfill';\nimport type { SharedModuleFactory } from '#internal/host/shared/shared-broker';\n\n/**\n * The core React packages that are always shared between host and remote.\n */\nexport const CORE_REACT_SHARED_KEYS = [\n 'react',\n 'react/jsx-dev-runtime',\n 'react/jsx-runtime',\n 'react-dom',\n 'react-dom/client',\n] as const;\n\n/**\n * Maps each core React package to its shared-module manifest ID.\n * These IDs are emitted into sharedManifest for the default React entries.\n * For example, `react` maps to `/react/index.js`.\n */\nexport const CORE_REACT_SHARED_MODULE_IDS: Record<string, string> = {\n react: '/react/index.js',\n 'react/jsx-dev-runtime': '/react/jsx-dev-runtime.js',\n 'react/jsx-runtime': '/react/jsx-runtime.js',\n 'react-dom': '/react-dom/index.js',\n 'react-dom/client': '/react-dom/client.js',\n};\n\n/**\n * The vendorShared record used by the Next.js config to map React packages\n * to their shared-module ID string literals. Derived from\n * CORE_REACT_SHARED_MODULE_IDS but excludes `react-dom/client` to match the\n * existing config behavior.\n */\nexport const VENDOR_SHARED: Record<string, string> = Object.fromEntries(\n Object.entries(CORE_REACT_SHARED_MODULE_IDS)\n .filter(([key]) => key !== 'react-dom/client')\n .map(([key, path]) => [key, `'${path}'`]),\n);\n\n/**\n * Builds the `coreShared` map for the Turbopack runtime's\n * `initializeSharedModules`. Each entry is an async factory that dynamically\n * imports the corresponding React package. User-provided shared modules\n * override core entries (e.g. to supply a pinned React version).\n */\nexport function buildCoreShared(\n userShared?: Record<string, SharedModuleFactory>,\n): Record<string, SharedModuleFactory> {\n return {\n react: async () => (await import('react')).default,\n 'react-dom': async () => (await import('react-dom')).default,\n 'react/jsx-dev-runtime': async () =>\n (await import('react/jsx-dev-runtime')).default,\n 'react/jsx-runtime': async () =>\n (await import('react/jsx-runtime')).default,\n 'react-dom/client': async () => (await import('react-dom/client')).default,\n ...userShared,\n };\n}\n\ninterface HostSharedGlobals {\n __remote_component_host_shared_modules__?: Record<\n string,\n SharedModuleFactory\n >;\n __remote_component_shared__?: Record<string, SharedModuleFactory>;\n}\n\n/**\n * Builds the merged host shared modules map with a consistent merge priority:\n * 1. Polyfills (lowest priority — fallback implementations)\n * 2. Global host shared modules (`__remote_component_host_shared_modules__`)\n * 3. User-provided shared modules (highest priority — explicit overrides)\n *\n * Some callers also include `__remote_component_shared__`, the Pages\n * client-only shared global. Pass `includePagesClientSharedGlobal: true` to\n * include it at the end.\n */\nexport function buildHostShared(\n userShared?: Record<string, SharedModuleFactory>,\n resolveClientUrl?: InternalResolveClientUrl,\n options?: { includePagesClientSharedGlobal?: boolean },\n): Record<string, SharedModuleFactory> {\n const self = globalThis as typeof globalThis & HostSharedGlobals;\n const result: Record<string, SharedModuleFactory> = {\n ...sharedPolyfills(userShared, resolveClientUrl),\n ...self.__remote_component_host_shared_modules__,\n ...userShared,\n };\n if (options?.includePagesClientSharedGlobal) {\n Object.assign(result, self.__remote_component_shared__);\n }\n return result;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AACA,sBAAgC;AAMzB,MAAM,yBAAyB;AAAA,EACpC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF;AAOO,MAAM,+BAAuD;AAAA,EAClE,OAAO;AAAA,EACP,yBAAyB;AAAA,EACzB,qBAAqB;AAAA,EACrB,aAAa;AAAA,EACb,oBAAoB;AACtB;AAQO,MAAM,gBAAwC,OAAO;AAAA,EAC1D,OAAO,QAAQ,4BAA4B,EACxC,OAAO,CAAC,CAAC,GAAG,MAAM,QAAQ,kBAAkB,EAC5C,IAAI,CAAC,CAAC,KAAK,IAAI,MAAM,CAAC,KAAK,IAAI,OAAO,CAAC;AAC5C;AAQO,SAAS,gBACd,YACqC;AACrC,SAAO;AAAA,IACL,OAAO,aAAa,MAAM,OAAO,OAAO,GAAG;AAAA,IAC3C,aAAa,aAAa,MAAM,OAAO,WAAW,GAAG;AAAA,IACrD,yBAAyB,aACtB,MAAM,OAAO,uBAAuB,GAAG;AAAA,IAC1C,qBAAqB,aAClB,MAAM,OAAO,mBAAmB,GAAG;AAAA,IACtC,oBAAoB,aAAa,MAAM,OAAO,kBAAkB,GAAG;AAAA,IACnE,GAAG;AAAA,EACL;AACF;AAoBO,SAAS,gBACd,YACA,kBACA,SACqC;AACrC,QAAM,OAAO;AACb,QAAM,SAA8C;AAAA,IAClD,OAAG,iCAAgB,YAAY,gBAAgB;AAAA,IAC/C,GAAG,KAAK;AAAA,IACR,GAAG;AAAA,EACL;AACA,MAAI,SAAS,gCAAgC;AAC3C,WAAO,OAAO,QAAQ,KAAK,2BAA2B;AAAA,EACxD;AACA,SAAO;AACT;","names":[]}
|
|
@@ -32,11 +32,12 @@ declare function buildCoreShared(userShared?: Record<string, SharedModuleFactory
|
|
|
32
32
|
* 2. Global host shared modules (`__remote_component_host_shared_modules__`)
|
|
33
33
|
* 3. User-provided shared modules (highest priority — explicit overrides)
|
|
34
34
|
*
|
|
35
|
-
* Some callers also include `__remote_component_shared__
|
|
36
|
-
* global
|
|
35
|
+
* Some callers also include `__remote_component_shared__`, the Pages
|
|
36
|
+
* client-only shared global. Pass `includePagesClientSharedGlobal: true` to
|
|
37
|
+
* include it at the end.
|
|
37
38
|
*/
|
|
38
39
|
declare function buildHostShared(userShared?: Record<string, SharedModuleFactory>, resolveClientUrl?: InternalResolveClientUrl, options?: {
|
|
39
|
-
|
|
40
|
+
includePagesClientSharedGlobal?: boolean;
|
|
40
41
|
}): Record<string, SharedModuleFactory>;
|
|
41
42
|
|
|
42
43
|
export { CORE_REACT_SHARED_KEYS, CORE_REACT_SHARED_MODULE_IDS, VENDOR_SHARED, buildCoreShared, buildHostShared };
|
|
@@ -33,7 +33,7 @@ function buildHostShared(userShared, resolveClientUrl, options) {
|
|
|
33
33
|
...self.__remote_component_host_shared_modules__,
|
|
34
34
|
...userShared
|
|
35
35
|
};
|
|
36
|
-
if (options?.
|
|
36
|
+
if (options?.includePagesClientSharedGlobal) {
|
|
37
37
|
Object.assign(result, self.__remote_component_shared__);
|
|
38
38
|
}
|
|
39
39
|
return result;
|