remote-components 0.3.4 → 0.3.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/app-63L5THIQ.js +12 -0
- package/dist/app-63L5THIQ.js.map +1 -0
- package/dist/app-A5QE7XRH.cjs +12 -0
- package/dist/app-A5QE7XRH.cjs.map +1 -0
- package/dist/chunk-2VQGCACH.js +190 -0
- package/dist/chunk-2VQGCACH.js.map +1 -0
- package/dist/chunk-42N2ZLE2.js +703 -0
- package/dist/chunk-42N2ZLE2.js.map +1 -0
- package/dist/chunk-6IUP26UK.cjs +57 -0
- package/dist/chunk-6IUP26UK.cjs.map +1 -0
- package/dist/chunk-7MVFHOIP.cjs +60 -0
- package/dist/chunk-7MVFHOIP.cjs.map +1 -0
- package/dist/chunk-CREXMFMF.cjs +155 -0
- package/dist/chunk-CREXMFMF.cjs.map +1 -0
- package/dist/chunk-CTUJSWCM.js +215 -0
- package/dist/chunk-CTUJSWCM.js.map +1 -0
- package/dist/chunk-ENYGL5CO.js +11 -0
- package/dist/chunk-ENYGL5CO.js.map +1 -0
- package/dist/chunk-ER73O65F.cjs +703 -0
- package/dist/chunk-ER73O65F.cjs.map +1 -0
- package/dist/chunk-F44NODUS.cjs +709 -0
- package/dist/chunk-F44NODUS.cjs.map +1 -0
- package/dist/chunk-GAXJTFBV.js +20 -0
- package/dist/chunk-GAXJTFBV.js.map +1 -0
- package/dist/chunk-HNZVEIKN.js +358 -0
- package/dist/chunk-HNZVEIKN.js.map +1 -0
- package/dist/chunk-KE7QPAQ4.cjs +21 -0
- package/dist/chunk-KE7QPAQ4.cjs.map +1 -0
- package/dist/chunk-KEPHL25S.js +60 -0
- package/dist/chunk-KEPHL25S.js.map +1 -0
- package/dist/chunk-KKBEMQU7.cjs +670 -0
- package/dist/chunk-KKBEMQU7.cjs.map +1 -0
- package/dist/chunk-KYJWRZ2B.js +709 -0
- package/dist/chunk-KYJWRZ2B.js.map +1 -0
- package/dist/chunk-N5VQR2PW.cjs +215 -0
- package/dist/chunk-N5VQR2PW.cjs.map +1 -0
- package/dist/chunk-OO4AMJWO.js +155 -0
- package/dist/chunk-OO4AMJWO.js.map +1 -0
- package/dist/chunk-R4QFK5TN.cjs +358 -0
- package/dist/chunk-R4QFK5TN.cjs.map +1 -0
- package/dist/chunk-RUWR74XQ.cjs +152 -0
- package/dist/chunk-RUWR74XQ.cjs.map +1 -0
- package/dist/chunk-S2A4TFLS.js +152 -0
- package/dist/chunk-S2A4TFLS.js.map +1 -0
- package/dist/chunk-SHFJ5OQA.cjs +11 -0
- package/dist/chunk-SHFJ5OQA.cjs.map +1 -0
- package/dist/chunk-TCFLEBQM.cjs +20 -0
- package/dist/chunk-TCFLEBQM.cjs.map +1 -0
- package/dist/chunk-W5ESPGHH.js +670 -0
- package/dist/chunk-W5ESPGHH.js.map +1 -0
- package/dist/chunk-X6YKUJKH.js +21 -0
- package/dist/chunk-X6YKUJKH.js.map +1 -0
- package/dist/chunk-XCFYWSLD.cjs +190 -0
- package/dist/chunk-XCFYWSLD.cjs.map +1 -0
- package/dist/chunk-ZPMTZ3KJ.js +57 -0
- package/dist/chunk-ZPMTZ3KJ.js.map +1 -0
- package/dist/config/nextjs.cjs +76 -351
- package/dist/config/nextjs.cjs.map +1 -1
- package/dist/config/nextjs.js +26 -266
- package/dist/config/nextjs.js.map +1 -1
- package/dist/config/webpack.cjs +12 -240
- package/dist/config/webpack.cjs.map +1 -1
- package/dist/config/webpack.js +6 -207
- package/dist/config/webpack.js.map +1 -1
- package/dist/host/html.cjs +139 -2447
- package/dist/host/html.cjs.map +1 -1
- package/dist/host/html.js +66 -2345
- package/dist/host/html.js.map +1 -1
- package/dist/host/nextjs/app/client-only.cjs +53 -2825
- package/dist/host/nextjs/app/client-only.cjs.map +1 -1
- package/dist/host/nextjs/app/client-only.js +31 -2780
- package/dist/host/nextjs/app/client-only.js.map +1 -1
- package/dist/host/nextjs/app.cjs +34 -2
- package/dist/host/nextjs/app.cjs.map +1 -1
- package/dist/host/nextjs/app.js +35 -3
- package/dist/host/nextjs/app.js.map +1 -1
- package/dist/host/proxy/client.cjs +8 -38
- package/dist/host/proxy/client.cjs.map +1 -1
- package/dist/host/proxy/client.js +4 -7
- package/dist/host/proxy/client.js.map +1 -1
- package/dist/host/proxy.cjs +19 -56
- package/dist/host/proxy.cjs.map +1 -1
- package/dist/host/proxy.js +8 -20
- package/dist/host/proxy.js.map +1 -1
- package/dist/host/react.cjs +17 -2756
- package/dist/host/react.cjs.map +1 -1
- package/dist/host/react.js +13 -2723
- package/dist/host/react.js.map +1 -1
- package/dist/internal/host/nextjs/app-client.cjs +38 -24
- package/dist/internal/host/nextjs/app-client.cjs.map +1 -1
- package/dist/internal/host/nextjs/app-client.js +38 -24
- package/dist/internal/host/nextjs/app-client.js.map +1 -1
- package/dist/internal/host/nextjs/remote-component-links.cjs +24 -13
- package/dist/internal/host/nextjs/remote-component-links.cjs.map +1 -1
- package/dist/internal/host/nextjs/remote-component-links.d.ts +3 -0
- package/dist/internal/host/nextjs/remote-component-links.js +24 -13
- package/dist/internal/host/nextjs/remote-component-links.js.map +1 -1
- package/dist/internal/host/server/fetch-remote-component.cjs +1 -18
- package/dist/internal/host/server/fetch-remote-component.cjs.map +1 -1
- package/dist/internal/host/server/fetch-remote-component.js +1 -18
- package/dist/internal/host/server/fetch-remote-component.js.map +1 -1
- package/dist/internal/host/shared/lifecycle.cjs +69 -0
- package/dist/internal/host/shared/lifecycle.cjs.map +1 -0
- package/dist/internal/host/shared/lifecycle.d.ts +34 -0
- package/dist/internal/host/shared/lifecycle.js +44 -0
- package/dist/internal/host/shared/lifecycle.js.map +1 -0
- package/dist/internal/host/shared/pipeline.cjs +222 -0
- package/dist/internal/host/shared/pipeline.cjs.map +1 -0
- package/dist/internal/host/shared/pipeline.d.ts +153 -0
- package/dist/internal/host/shared/pipeline.js +200 -0
- package/dist/internal/host/shared/pipeline.js.map +1 -0
- package/dist/internal/runtime/loaders/component-loader.cjs +5 -2
- package/dist/internal/runtime/loaders/component-loader.cjs.map +1 -1
- package/dist/internal/runtime/loaders/component-loader.js +5 -2
- package/dist/internal/runtime/loaders/component-loader.js.map +1 -1
- package/dist/internal/runtime/turbopack/patterns.cjs +1 -1
- package/dist/internal/runtime/turbopack/patterns.cjs.map +1 -1
- package/dist/internal/runtime/turbopack/patterns.js +1 -1
- package/dist/internal/runtime/turbopack/patterns.js.map +1 -1
- package/dist/internal/runtime/turbopack/remote-scope-setup.cjs.map +1 -1
- package/dist/internal/runtime/turbopack/remote-scope-setup.js.map +1 -1
- package/dist/internal/runtime/turbopack/remote-scope.cjs +1 -5
- package/dist/internal/runtime/turbopack/remote-scope.cjs.map +1 -1
- package/dist/internal/runtime/turbopack/remote-scope.js +1 -5
- package/dist/internal/runtime/turbopack/remote-scope.js.map +1 -1
- package/dist/internal/utils.cjs +1 -1
- package/dist/internal/utils.cjs.map +1 -1
- package/dist/internal/utils.d.ts +5 -5
- package/dist/internal/utils.js +1 -1
- package/dist/internal/utils.js.map +1 -1
- package/dist/remote/html.cjs +15 -314
- package/dist/remote/html.cjs.map +1 -1
- package/dist/remote/html.js +7 -305
- package/dist/remote/html.js.map +1 -1
- package/dist/remote/middleware.cjs +16 -41
- package/dist/remote/middleware.cjs.map +1 -1
- package/dist/script-6W5JRBZK.cjs +26 -0
- package/dist/script-6W5JRBZK.cjs.map +1 -0
- package/dist/script-IFEBOLIA.js +26 -0
- package/dist/script-IFEBOLIA.js.map +1 -0
- package/dist/static-loader-X4TSF5KW.js +11 -0
- package/dist/static-loader-X4TSF5KW.js.map +1 -0
- package/dist/static-loader-ZYD5BO4D.cjs +11 -0
- package/dist/static-loader-ZYD5BO4D.cjs.map +1 -0
- package/dist/turbopack-NPGO3MWS.js +55 -0
- package/dist/turbopack-NPGO3MWS.js.map +1 -0
- package/dist/turbopack-WRMKPNN4.cjs +55 -0
- package/dist/turbopack-WRMKPNN4.cjs.map +1 -0
- package/dist/webpack-DUBHPYD6.js +92 -0
- package/dist/webpack-DUBHPYD6.js.map +1 -0
- package/dist/webpack-KSCMCL7M.cjs +92 -0
- package/dist/webpack-KSCMCL7M.cjs.map +1 -0
- package/package.json +10 -3
|
@@ -0,0 +1,358 @@
|
|
|
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; }
|
|
2
|
+
|
|
3
|
+
var _chunk7MVFHOIPcjs = require('./chunk-7MVFHOIP.cjs');
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
var _chunkRUWR74XQcjs = require('./chunk-RUWR74XQ.cjs');
|
|
8
|
+
|
|
9
|
+
// src/utils/index.ts
|
|
10
|
+
function escapeString(str) {
|
|
11
|
+
return str.replace(/[^a-z0-9]/g, "_");
|
|
12
|
+
}
|
|
13
|
+
function computeScopedName(name, options) {
|
|
14
|
+
return `${name}_${escapeString(options.remoteHost.toLowerCase())}`;
|
|
15
|
+
}
|
|
16
|
+
var attrToProp = {
|
|
17
|
+
fetchpriority: "fetchPriority",
|
|
18
|
+
crossorigin: "crossOrigin",
|
|
19
|
+
imagesrcset: "imageSrcSet",
|
|
20
|
+
imagesizes: "imageSizes",
|
|
21
|
+
srcset: "srcSet"
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
// src/runtime/constants.ts
|
|
25
|
+
var DEFAULT_BUNDLE_NAME = "__vercel_remote_bundle";
|
|
26
|
+
var DEFAULT_COMPONENT_NAME = "__vercel_remote_component";
|
|
27
|
+
var DEFAULT_ROUTE = "/";
|
|
28
|
+
var RUNTIME_WEBPACK = "webpack";
|
|
29
|
+
var RUNTIME_TURBOPACK = "turbopack";
|
|
30
|
+
var RUNTIME_SCRIPT = "script";
|
|
31
|
+
function getBundleKey(bundle) {
|
|
32
|
+
return escapeString(bundle);
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
// src/runtime/patterns.ts
|
|
36
|
+
var REMOTE_COMPONENT_REGEX = /(?<prefix>.*?)\[(?<bundle>[^\]]+)\](?:%20| )(?<id>.+)/;
|
|
37
|
+
var NEXT_BUNDLE_PATH_RE = /\/_next\/\[.+\](?:%20| )/;
|
|
38
|
+
var DOUBLE_SLASH_RE = /(?<!:)\/\//g;
|
|
39
|
+
function collapseDoubleSlashes(path) {
|
|
40
|
+
return path.replace(DOUBLE_SLASH_RE, "/");
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
// src/runtime/turbopack/remote-scope.ts
|
|
44
|
+
function getRegistry() {
|
|
45
|
+
return _chunk7MVFHOIPcjs.getNamespace.call(void 0, ).scopes;
|
|
46
|
+
}
|
|
47
|
+
function createScope(name, url, runtime, resolveClientUrl) {
|
|
48
|
+
const scopedName = computeScopedName(name, { remoteHost: url.host });
|
|
49
|
+
const globalKey = getBundleKey(scopedName);
|
|
50
|
+
return {
|
|
51
|
+
name,
|
|
52
|
+
scopedName,
|
|
53
|
+
globalKey,
|
|
54
|
+
url,
|
|
55
|
+
runtime,
|
|
56
|
+
resolveClientUrl,
|
|
57
|
+
moduleCache: {},
|
|
58
|
+
sharedModules: {},
|
|
59
|
+
moduleGlobal: {},
|
|
60
|
+
turbopackModules: []
|
|
61
|
+
};
|
|
62
|
+
}
|
|
63
|
+
function registerScope(scope) {
|
|
64
|
+
const registry = getRegistry();
|
|
65
|
+
registry.set(scope.scopedName, scope);
|
|
66
|
+
if (scope.scopedName !== scope.name) {
|
|
67
|
+
const existing = registry.get(scope.name);
|
|
68
|
+
if (existing && existing.scopedName !== scope.scopedName) {
|
|
69
|
+
_chunkRUWR74XQcjs.logWarn.call(void 0,
|
|
70
|
+
"RemoteScope",
|
|
71
|
+
`Plain name "${scope.name}" already registered by scope "${existing.scopedName}" \u2014 overwriting with "${scope.scopedName}". Static hosts will only resolve the latest one.`
|
|
72
|
+
);
|
|
73
|
+
}
|
|
74
|
+
registry.set(scope.name, scope);
|
|
75
|
+
}
|
|
76
|
+
_chunkRUWR74XQcjs.logDebug.call(void 0,
|
|
77
|
+
"RemoteScope",
|
|
78
|
+
`Registered scope "${scope.scopedName}" (${registry.size} total)`
|
|
79
|
+
);
|
|
80
|
+
}
|
|
81
|
+
function getScope(name) {
|
|
82
|
+
return getRegistry().get(name);
|
|
83
|
+
}
|
|
84
|
+
function formatRemoteId(scope, path) {
|
|
85
|
+
return `[${scope.scopedName}] ${path}`;
|
|
86
|
+
}
|
|
87
|
+
function parseRemoteId(id) {
|
|
88
|
+
const groups = _optionalChain([REMOTE_COMPONENT_REGEX, 'access', _2 => _2.exec, 'call', _3 => _3(id), 'optionalAccess', _4 => _4.groups]);
|
|
89
|
+
if (_optionalChain([groups, 'optionalAccess', _5 => _5.bundle]) && groups.id) {
|
|
90
|
+
return {
|
|
91
|
+
bundle: groups.bundle,
|
|
92
|
+
path: groups.id,
|
|
93
|
+
prefix: _nullishCoalesce(groups.prefix, () => ( ""))
|
|
94
|
+
};
|
|
95
|
+
}
|
|
96
|
+
return { bundle: "default", path: id, prefix: "" };
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
// src/host/shared/remote-image-loader.ts
|
|
100
|
+
function createRemoteImageLoader(bundle, resolveClientUrl) {
|
|
101
|
+
const loader = Object.assign(
|
|
102
|
+
({
|
|
103
|
+
config,
|
|
104
|
+
src,
|
|
105
|
+
width,
|
|
106
|
+
quality
|
|
107
|
+
}) => {
|
|
108
|
+
const q = _nullishCoalesce(quality, () => ( 75));
|
|
109
|
+
const remoteOrigin = _nullishCoalesce(_optionalChain([getScope, 'call', _6 => _6(bundle), 'optionalAccess', _7 => _7.url, 'access', _8 => _8.origin]), () => ( ""));
|
|
110
|
+
const isCrossOrigin = remoteOrigin && remoteOrigin !== location.origin;
|
|
111
|
+
const basePath = isCrossOrigin ? `${remoteOrigin}${_nullishCoalesce(config.path, () => ( "/_next/image"))}` : _nullishCoalesce(config.path, () => ( `${remoteOrigin}/_next/image`));
|
|
112
|
+
const url = `${basePath}?url=${encodeURIComponent(src)}&w=${width}&q=${q}`;
|
|
113
|
+
return _nullishCoalesce(_optionalChain([resolveClientUrl, 'optionalCall', _9 => _9(url)]), () => ( url));
|
|
114
|
+
},
|
|
115
|
+
// Signals to getImgProps that this is a default loader (not a user-defined
|
|
116
|
+
// one), enabling srcSet generation with device/image sizes from the config.
|
|
117
|
+
{ __next_img_default: true }
|
|
118
|
+
);
|
|
119
|
+
return loader;
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
// src/host/shared/polyfill.tsx
|
|
123
|
+
var _jsxruntime = require('react/jsx-runtime');
|
|
124
|
+
function sharedPolyfills(shared, resolveClientUrl) {
|
|
125
|
+
const hostShared = _chunk7MVFHOIPcjs.getNamespace.call(void 0, ).hostSharedModules;
|
|
126
|
+
const polyfill = {
|
|
127
|
+
"next/dist/client/components/navigation": _nullishCoalesce(_nullishCoalesce(hostShared["next/navigation"], () => ( _optionalChain([shared, 'optionalAccess', _10 => _10["next/navigation"]]))), () => ( (() => Promise.resolve({
|
|
128
|
+
useRouter() {
|
|
129
|
+
return {
|
|
130
|
+
push: (routerUrl) => {
|
|
131
|
+
history.pushState({}, "", routerUrl);
|
|
132
|
+
},
|
|
133
|
+
replace: (routerUrl) => {
|
|
134
|
+
history.replaceState({}, "", routerUrl);
|
|
135
|
+
},
|
|
136
|
+
back: () => {
|
|
137
|
+
history.back();
|
|
138
|
+
}
|
|
139
|
+
};
|
|
140
|
+
},
|
|
141
|
+
usePathname() {
|
|
142
|
+
return location.pathname;
|
|
143
|
+
},
|
|
144
|
+
useParams() {
|
|
145
|
+
return {};
|
|
146
|
+
},
|
|
147
|
+
useSearchParams() {
|
|
148
|
+
return new URLSearchParams(location.search);
|
|
149
|
+
},
|
|
150
|
+
useSelectedLayoutSegment() {
|
|
151
|
+
return null;
|
|
152
|
+
},
|
|
153
|
+
useSelectedLayoutSegments() {
|
|
154
|
+
return [];
|
|
155
|
+
},
|
|
156
|
+
__esModule: true
|
|
157
|
+
})))),
|
|
158
|
+
"next/dist/client/app-dir/link": _nullishCoalesce(_nullishCoalesce(hostShared["next/link"], () => ( _optionalChain([shared, 'optionalAccess', _11 => _11["next/link"]]))), () => ( (() => Promise.resolve({
|
|
159
|
+
default: ({
|
|
160
|
+
scroll: _,
|
|
161
|
+
replace,
|
|
162
|
+
prefetch,
|
|
163
|
+
onNavigate,
|
|
164
|
+
children,
|
|
165
|
+
...props
|
|
166
|
+
}) => {
|
|
167
|
+
if (prefetch) {
|
|
168
|
+
_chunkRUWR74XQcjs.logWarn.call(void 0,
|
|
169
|
+
"Polyfill",
|
|
170
|
+
"Next.js Link prefetch is not supported in remote components"
|
|
171
|
+
);
|
|
172
|
+
}
|
|
173
|
+
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
174
|
+
"a",
|
|
175
|
+
{
|
|
176
|
+
...props,
|
|
177
|
+
href: props.href,
|
|
178
|
+
onClick: (e) => {
|
|
179
|
+
e.preventDefault();
|
|
180
|
+
let preventDefaulted = false;
|
|
181
|
+
e.preventDefault = () => {
|
|
182
|
+
preventDefaulted = true;
|
|
183
|
+
e.defaultPrevented = true;
|
|
184
|
+
};
|
|
185
|
+
if (typeof props.onClick === "function") {
|
|
186
|
+
props.onClick(e);
|
|
187
|
+
}
|
|
188
|
+
_optionalChain([onNavigate, 'optionalCall', _12 => _12(e)]);
|
|
189
|
+
if (preventDefaulted) {
|
|
190
|
+
return;
|
|
191
|
+
}
|
|
192
|
+
if (replace) {
|
|
193
|
+
history.replaceState({}, "", props.href);
|
|
194
|
+
} else {
|
|
195
|
+
history.pushState({}, "", props.href);
|
|
196
|
+
}
|
|
197
|
+
},
|
|
198
|
+
suppressHydrationWarning: true,
|
|
199
|
+
children: _nullishCoalesce(children, () => ( null))
|
|
200
|
+
}
|
|
201
|
+
);
|
|
202
|
+
},
|
|
203
|
+
useLinkStatus() {
|
|
204
|
+
return { pending: false };
|
|
205
|
+
},
|
|
206
|
+
__esModule: true
|
|
207
|
+
})))),
|
|
208
|
+
"next/dist/client/app-dir/form": _nullishCoalesce(_nullishCoalesce(hostShared["next/form"], () => ( _optionalChain([shared, 'optionalAccess', _13 => _13["next/form"]]))), () => ( (() => Promise.resolve({
|
|
209
|
+
default: () => {
|
|
210
|
+
throw new Error("Next.js <Form> component not implemented");
|
|
211
|
+
},
|
|
212
|
+
__esModule: true
|
|
213
|
+
})))),
|
|
214
|
+
// Instead of replacing next/image entirely, we let the real Next.js Image
|
|
215
|
+
// component load from the remote bundle and only replace its default loader.
|
|
216
|
+
// This gives us full next/image fidelity (fill, priority, srcSet, blur
|
|
217
|
+
// placeholders, error handling) while routing image optimization through the
|
|
218
|
+
// remote app's /_next/image endpoint.
|
|
219
|
+
"next/dist/shared/lib/image-loader": _nullishCoalesce(_nullishCoalesce(hostShared["next/dist/shared/lib/image-loader"], () => ( _optionalChain([shared, 'optionalAccess', _14 => _14["next/dist/shared/lib/image-loader"]]))), () => ( ((bundle) => Promise.resolve({
|
|
220
|
+
default: createRemoteImageLoader(bundle, resolveClientUrl),
|
|
221
|
+
__esModule: true
|
|
222
|
+
})))),
|
|
223
|
+
"next/dist/client/script": _nullishCoalesce(_nullishCoalesce(hostShared["next/script"], () => ( _optionalChain([shared, 'optionalAccess', _15 => _15["next/script"]]))), () => ( (() => Promise.resolve({
|
|
224
|
+
// TODO: implement <Script> component for non-Next.js host applications
|
|
225
|
+
// do not throw an error for now
|
|
226
|
+
default: () => null,
|
|
227
|
+
__esModule: true
|
|
228
|
+
})))),
|
|
229
|
+
"next/router": _nullishCoalesce(_nullishCoalesce(hostShared["next/router"], () => ( _optionalChain([shared, 'optionalAccess', _16 => _16["next/router"]]))), () => ( (() => (
|
|
230
|
+
// TODO: incomplete implementation
|
|
231
|
+
Promise.resolve({
|
|
232
|
+
useRouter() {
|
|
233
|
+
return {
|
|
234
|
+
push: (routerUrl) => {
|
|
235
|
+
history.pushState({}, "", routerUrl);
|
|
236
|
+
},
|
|
237
|
+
replace: (routerUrl) => {
|
|
238
|
+
history.replaceState({}, "", routerUrl);
|
|
239
|
+
},
|
|
240
|
+
back: () => {
|
|
241
|
+
history.back();
|
|
242
|
+
}
|
|
243
|
+
};
|
|
244
|
+
},
|
|
245
|
+
__esModule: true
|
|
246
|
+
})
|
|
247
|
+
)))),
|
|
248
|
+
"next/dist/build/polyfills/process": () => Promise.resolve({
|
|
249
|
+
default: {
|
|
250
|
+
env: {
|
|
251
|
+
NODE_ENV: "production"
|
|
252
|
+
}
|
|
253
|
+
},
|
|
254
|
+
__esModule: true
|
|
255
|
+
})
|
|
256
|
+
};
|
|
257
|
+
polyfill["next/navigation"] = polyfill["next/dist/client/components/navigation"];
|
|
258
|
+
polyfill["next/link"] = polyfill["next/dist/client/app-dir/link"];
|
|
259
|
+
polyfill["next/form"] = polyfill["next/dist/client/app-dir/form"];
|
|
260
|
+
polyfill["next/dist/esm/shared/lib/image-loader"] = polyfill["next/dist/shared/lib/image-loader"];
|
|
261
|
+
polyfill["next/script"] = polyfill["next/dist/client/script"];
|
|
262
|
+
return polyfill;
|
|
263
|
+
}
|
|
264
|
+
|
|
265
|
+
// src/host/shared/shared-module-resolver.ts
|
|
266
|
+
var CORE_REACT_SHARED_KEYS = [
|
|
267
|
+
"react",
|
|
268
|
+
"react/jsx-dev-runtime",
|
|
269
|
+
"react/jsx-runtime",
|
|
270
|
+
"react-dom",
|
|
271
|
+
"react-dom/client"
|
|
272
|
+
];
|
|
273
|
+
var CORE_REACT_PATH_MAP = {
|
|
274
|
+
react: "/react/index.js",
|
|
275
|
+
"react/jsx-dev-runtime": "/react/jsx-dev-runtime.js",
|
|
276
|
+
"react/jsx-runtime": "/react/jsx-runtime.js",
|
|
277
|
+
"react-dom": "/react-dom/index.js",
|
|
278
|
+
"react-dom/client": "/react-dom/client.js"
|
|
279
|
+
};
|
|
280
|
+
var VENDOR_SHARED = Object.fromEntries(
|
|
281
|
+
Object.entries(CORE_REACT_PATH_MAP).filter(([key]) => key !== "react-dom/client").map(([key, path]) => [key, `'${path}'`])
|
|
282
|
+
);
|
|
283
|
+
function buildCoreShared(userShared) {
|
|
284
|
+
return {
|
|
285
|
+
react: async () => (await Promise.resolve().then(() => _interopRequireWildcard(require("react")))).default,
|
|
286
|
+
"react-dom": async () => (await Promise.resolve().then(() => _interopRequireWildcard(require("react-dom")))).default,
|
|
287
|
+
"react/jsx-dev-runtime": async () => (await Promise.resolve().then(() => _interopRequireWildcard(require("react/jsx-dev-runtime")))).default,
|
|
288
|
+
"react/jsx-runtime": async () => (await Promise.resolve().then(() => _interopRequireWildcard(require("react/jsx-runtime")))).default,
|
|
289
|
+
"react-dom/client": async () => (await Promise.resolve().then(() => _interopRequireWildcard(require("react-dom/client")))).default,
|
|
290
|
+
...userShared
|
|
291
|
+
};
|
|
292
|
+
}
|
|
293
|
+
function buildHostShared(userShared, resolveClientUrl, options) {
|
|
294
|
+
const self = globalThis;
|
|
295
|
+
const result = {
|
|
296
|
+
...sharedPolyfills(userShared, resolveClientUrl),
|
|
297
|
+
...self.__remote_component_host_shared_modules__,
|
|
298
|
+
...userShared
|
|
299
|
+
};
|
|
300
|
+
if (_optionalChain([options, 'optionalAccess', _17 => _17.includeRemoteComponentShared])) {
|
|
301
|
+
Object.assign(result, self.__remote_component_shared__);
|
|
302
|
+
}
|
|
303
|
+
return result;
|
|
304
|
+
}
|
|
305
|
+
async function buildWebpackResolve(hostShared, remoteShared, bundle, reactModules, callerTag = "SharedModuleResolver") {
|
|
306
|
+
const resolve = {
|
|
307
|
+
...reactModules,
|
|
308
|
+
...Object.entries(remoteShared).reduce(
|
|
309
|
+
(acc, [key, value]) => {
|
|
310
|
+
if (typeof hostShared[value] !== "undefined") {
|
|
311
|
+
acc[key.replace(/^\(ssr\)\/(?<relative>\.\/)?/, "")] = hostShared[value];
|
|
312
|
+
} else {
|
|
313
|
+
_chunkRUWR74XQcjs.logDebug.call(void 0,
|
|
314
|
+
callerTag,
|
|
315
|
+
`Remote requests "${value}" but host doesn't provide it`
|
|
316
|
+
);
|
|
317
|
+
}
|
|
318
|
+
return acc;
|
|
319
|
+
},
|
|
320
|
+
{}
|
|
321
|
+
)
|
|
322
|
+
};
|
|
323
|
+
await Promise.all(
|
|
324
|
+
Object.entries(resolve).map(async ([key, value]) => {
|
|
325
|
+
if (typeof value === "function") {
|
|
326
|
+
resolve[key] = await value(bundle);
|
|
327
|
+
}
|
|
328
|
+
return Promise.resolve(value);
|
|
329
|
+
})
|
|
330
|
+
);
|
|
331
|
+
return resolve;
|
|
332
|
+
}
|
|
333
|
+
|
|
334
|
+
|
|
335
|
+
|
|
336
|
+
|
|
337
|
+
|
|
338
|
+
|
|
339
|
+
|
|
340
|
+
|
|
341
|
+
|
|
342
|
+
|
|
343
|
+
|
|
344
|
+
|
|
345
|
+
|
|
346
|
+
|
|
347
|
+
|
|
348
|
+
|
|
349
|
+
|
|
350
|
+
|
|
351
|
+
|
|
352
|
+
|
|
353
|
+
|
|
354
|
+
|
|
355
|
+
|
|
356
|
+
|
|
357
|
+
exports.escapeString = escapeString; exports.attrToProp = attrToProp; exports.DEFAULT_BUNDLE_NAME = DEFAULT_BUNDLE_NAME; exports.DEFAULT_COMPONENT_NAME = DEFAULT_COMPONENT_NAME; exports.DEFAULT_ROUTE = DEFAULT_ROUTE; exports.RUNTIME_WEBPACK = RUNTIME_WEBPACK; exports.RUNTIME_TURBOPACK = RUNTIME_TURBOPACK; exports.RUNTIME_SCRIPT = RUNTIME_SCRIPT; exports.REMOTE_COMPONENT_REGEX = REMOTE_COMPONENT_REGEX; exports.NEXT_BUNDLE_PATH_RE = NEXT_BUNDLE_PATH_RE; exports.collapseDoubleSlashes = collapseDoubleSlashes; exports.createScope = createScope; exports.registerScope = registerScope; exports.getScope = getScope; exports.formatRemoteId = formatRemoteId; exports.parseRemoteId = parseRemoteId; exports.createRemoteImageLoader = createRemoteImageLoader; exports.CORE_REACT_SHARED_KEYS = CORE_REACT_SHARED_KEYS; exports.VENDOR_SHARED = VENDOR_SHARED; exports.buildCoreShared = buildCoreShared; exports.buildHostShared = buildHostShared; exports.buildWebpackResolve = buildWebpackResolve;
|
|
358
|
+
//# sourceMappingURL=chunk-R4QFK5TN.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/utils/index.ts","../src/runtime/constants.ts","../src/runtime/patterns.ts","../src/runtime/turbopack/remote-scope.ts","../src/host/shared/remote-image-loader.ts","../src/host/shared/polyfill.tsx","../src/host/shared/shared-module-resolver.ts"],"names":[],"mappings":";;;;;;;;;AAAO,SAAS,aAAa,KAAa;AACxC,SAAO,IAAI,QAAQ,cAAc,GAAG;AACtC;AAaO,SAAS,kBACd,MACA,SACQ;AACR,SAAO,GAAG,QAAQ,aAAa,QAAQ,WAAW,YAAY,CAAC;AACjE;AAEO,IAAM,aAAa;AAAA,EACxB,eAAe;AAAA,EACf,aAAa;AAAA,EACb,aAAa;AAAA,EACb,YAAY;AAAA,EACZ,QAAQ;AACV;;;AC1BO,IAAM,sBAAsB;AAC5B,IAAM,yBAAyB;AAC/B,IAAM,gBAAgB;AAEtB,IAAM,kBAAkB;AACxB,IAAM,oBAAoB;AAC1B,IAAM,iBAAiB;AAEvB,SAAS,aAAa,QAAwB;AACnD,SAAO,aAAa,MAAM;AAC5B;;;ACZO,IAAM,yBACX;AAIK,IAAM,sBAAsB;AAGnC,IAAM,kBAAkB;AACjB,SAAS,sBAAsB,MAAsB;AAC1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AC,KAAK,KAAK,MAAM;AAClD,UAAI,OAAO,UAAU,YAAY;AAC/B,gBAAQ,GAAG,IAAI,MAAM,MAAM,MAAM;AAAA,MACnC;AACA,aAAO,QAAQ,QAAQ,KAAK;AAAA,IAC9B,CAAC;AAAA,EACH;AACA,SAAO;AACT","sourcesContent":["export function escapeString(str: string) {\n return str.replace(/[^a-z0-9]/g, '_');\n}\n\n/**\n * Computes the origin-qualified scoped name for a bundle by appending\n * the escaped host (hostname + port). This ensures the server and client\n * always agree on the scoped name — the server's cross-origin detection\n * (based on deployment URL) can differ from the client's (based on\n * `location.origin`), so the name must not depend on that distinction.\n *\n * Used on both the server (to rewrite RSC flight data) and the client\n * (to create and look up RemoteScopes). Both sides must produce the\n * same value for a given remote.\n */\nexport function computeScopedName(\n name: string,\n options: { remoteHost: string },\n): string {\n return `${name}_${escapeString(options.remoteHost.toLowerCase())}`;\n}\n\nexport const attrToProp = {\n fetchpriority: 'fetchPriority',\n crossorigin: 'crossOrigin',\n imagesrcset: 'imageSrcSet',\n imagesizes: 'imageSizes',\n srcset: 'srcSet',\n} as Record<string, string>;\n","import { escapeString } from '#internal/utils';\n\nexport const DEFAULT_BUNDLE_NAME = '__vercel_remote_bundle';\nexport const DEFAULT_COMPONENT_NAME = '__vercel_remote_component';\nexport const DEFAULT_ROUTE = '/';\n\nexport const RUNTIME_WEBPACK = 'webpack';\nexport const RUNTIME_TURBOPACK = 'turbopack';\nexport const RUNTIME_SCRIPT = 'script';\n\nexport function getBundleKey(bundle: string): string {\n return escapeString(bundle);\n}\n\nexport type Runtime =\n | typeof RUNTIME_WEBPACK\n | typeof RUNTIME_TURBOPACK\n | typeof RUNTIME_SCRIPT;\n","export const REMOTE_COMPONENT_REGEX =\n /(?<prefix>.*?)\\[(?<bundle>[^\\]]+)\\](?:%20| )(?<id>.+)/;\n\n// Matches Next.js bundle-prefixed paths like /_next/[bundle-name] /static/...\n// Used to strip the bundle identifier before loading scripts via the standard /_next/ path.\nexport const NEXT_BUNDLE_PATH_RE = /\\/_next\\/\\[.+\\](?:%20| )/;\n\n/** Collapse duplicate path separators (`//`) while preserving protocol (`://`). */\nconst DOUBLE_SLASH_RE = /(?<!:)\\/\\//g;\nexport function collapseDoubleSlashes(path: string): string {\n return path.replace(DOUBLE_SLASH_RE, '/');\n}\n","import type { InternalResolveClientUrl } from '#internal/host/server/types';\nimport { getBundleKey, type Runtime } from '#internal/runtime/constants';\nimport { getNamespace } from '#internal/runtime/namespace';\nimport { REMOTE_COMPONENT_REGEX } from '#internal/runtime/patterns';\nimport { computeScopedName } from '#internal/utils';\nimport { logDebug, logWarn } from '#internal/utils/logger';\n\n/**\n * Encapsulates all per-remote state so that two remotes sharing the same\n * bundle name but served from different origins never collide.\n *\n * A scope is created once per `setupRemoteScope` call and threaded\n * directly through internal code paths (chunk loading, module resolution,\n * shared modules). Global dispatchers (`__webpack_require__`,\n * `__webpack_chunk_load__`) only exist for external callers (RSC runtime)\n * and resolve the correct scope via the registry.\n */\nexport interface RemoteScope {\n /** Plain bundle name (e.g. \"remote-component-registry\") */\n name: string;\n /** Origin-qualified key — unique even when two remotes share a name */\n scopedName: string;\n /** Escaped key used as suffix for TURBOPACK_ globals */\n globalKey: string;\n /** Base URL for resolving relative chunk paths */\n url: URL;\n /** Bundler runtime type */\n runtime: Runtime;\n /** Proxy callback for routing chunks through the host */\n resolveClientUrl?: InternalResolveClientUrl;\n /** Per-scope cache of executed Turbopack module exports */\n moduleCache: Record<string, unknown>;\n /** Per-scope shared modules provided by the host (React, etc.) */\n sharedModules: Record<string, unknown>;\n /** Per-scope globalThis substitute passed to module initializers as `g` */\n moduleGlobal: Record<string, unknown>;\n /**\n * Webpack's bundle-scoped require function, populated from\n * `__remote_webpack_require__[bundleName]` for webpack remotes.\n * Undefined for turbopack remotes.\n */\n webpackRequire?: ((id: string | number) => unknown) & {\n m?: Record<string | number, (module: { exports: unknown }) => void>;\n type?: string;\n };\n /**\n * Flat array of captured turbopack module entries: [scriptEl, id, factory, ...].\n * Populated by the push interceptor in handleTurbopackChunk. This is the\n * primary source of truth for getTurbopackModules — immune to the turbopack\n * runtime replacing the TURBOPACK global (canary builds use a deferred-loading\n * pattern that swaps the array for an immediate-processing dispatcher).\n */\n turbopackModules: unknown[];\n}\n\nfunction getRegistry(): Map<string, RemoteScope> {\n return getNamespace().scopes;\n}\n\nexport function createScope(\n name: string,\n url: URL,\n runtime: Runtime,\n resolveClientUrl?: InternalResolveClientUrl,\n): RemoteScope {\n const scopedName = computeScopedName(name, { remoteHost: url.host });\n const globalKey = getBundleKey(scopedName);\n return {\n name,\n scopedName,\n globalKey,\n url,\n runtime,\n resolveClientUrl,\n moduleCache: {},\n sharedModules: {},\n moduleGlobal: {},\n turbopackModules: [],\n };\n}\n\nexport function registerScope(scope: RemoteScope): void {\n const registry = getRegistry();\n registry.set(scope.scopedName, scope);\n\n // Also register under the plain name so static/HTML hosts (which don't\n // rewrite RSC chunk IDs) can look up scopes by the unrewritten bundle name.\n if (scope.scopedName !== scope.name) {\n const existing = registry.get(scope.name);\n if (existing && existing.scopedName !== scope.scopedName) {\n logWarn(\n 'RemoteScope',\n `Plain name \"${scope.name}\" already registered by scope \"${existing.scopedName}\" — ` +\n `overwriting with \"${scope.scopedName}\". Static hosts will only resolve the latest one.`,\n );\n }\n registry.set(scope.name, scope);\n }\n\n logDebug(\n 'RemoteScope',\n `Registered scope \"${scope.scopedName}\" (${registry.size} total)`,\n );\n}\n\n/**\n * Resolves a scope by name. Accepts either the scoped name (used by Next.js\n * hosts that rewrite RSC data server-side) or the plain bundle name (used by\n * static/HTML hosts where chunks arrive unrewritten).\n */\nexport function getScope(name: string): RemoteScope | undefined {\n return getRegistry().get(name);\n}\n\n/** Formats a `[scopedName] path` string for use in chunk/module IDs. */\nexport function formatRemoteId(scope: RemoteScope, path: string): string {\n return `[${scope.scopedName}] ${path}`;\n}\n\n/**\n * Parses the `[bundle] path` format used in chunk/module IDs.\n * Uses REMOTE_COMPONENT_REGEX (the same pattern used by the module dispatcher\n * and script loader) so the two parsing paths can never diverge.\n */\nexport function parseRemoteId(id: string): {\n bundle: string;\n path: string;\n prefix: string;\n} {\n const groups = REMOTE_COMPONENT_REGEX.exec(id)?.groups;\n if (groups?.bundle && groups.id) {\n return {\n bundle: groups.bundle,\n path: groups.id,\n prefix: groups.prefix ?? '',\n };\n }\n return { bundle: 'default', path: id, prefix: '' };\n}\n","import { getScope } from '#internal/runtime/turbopack/remote-scope';\nimport type { InternalResolveClientUrl } from '#internal/runtime/url/resolve-client-url';\n\n/**\n * Replacement for `next/dist/shared/lib/image-loader`.\n *\n * Uses `config.path` (which includes the remote's asset prefix, e.g.\n * `/vc-ap-xxx/_next/image`) to generate URLs that match the server-rendered\n * HTML and avoid hydration mismatches. Under the microfrontends proxy these\n * relative paths are routed to the correct app.\n *\n * For cross-origin deployments (standalone host on a different domain),\n * `config.path` is a relative path that would incorrectly resolve to the host\n * origin, so we prefix it with the remote origin to produce an absolute URL\n * pointing at the remote's optimizer.\n *\n * When `resolveClientUrl` is provided (deployment protection), the final URL\n * is routed through the host's proxy.\n */\nexport function createRemoteImageLoader(\n bundle: string,\n resolveClientUrl?: InternalResolveClientUrl,\n) {\n const loader = Object.assign(\n ({\n config,\n src,\n width,\n quality,\n }: {\n config: { path?: string };\n src: string;\n width: number;\n quality?: number;\n }) => {\n const q = quality ?? 75;\n const remoteOrigin = getScope(bundle)?.url.origin ?? '';\n const isCrossOrigin = remoteOrigin && remoteOrigin !== location.origin;\n const basePath = isCrossOrigin\n ? `${remoteOrigin}${config.path ?? '/_next/image'}`\n : (config.path ?? `${remoteOrigin}/_next/image`);\n const url = `${basePath}?url=${encodeURIComponent(src)}&w=${width}&q=${q}`;\n return resolveClientUrl?.(url) ?? url;\n },\n // Signals to getImgProps that this is a default loader (not a user-defined\n // one), enabling srcSet generation with device/image sizes from the config.\n { __next_img_default: true as const },\n );\n return loader;\n}\n","import type { LinkProps } from 'next/link';\nimport { createRemoteImageLoader } from '#internal/host/shared/remote-image-loader';\nimport { getNamespace } from '#internal/runtime/namespace';\nimport type { InternalResolveClientUrl } from '#internal/runtime/url/resolve-client-url';\nimport { logWarn } from '#internal/utils/logger';\n\n// polyfill Next.js App Router client API (minimal)\n// implementations are minimal and do not cover all use cases\n// developer can override these shared modules from configuration\nexport function sharedPolyfills(\n shared?: Record<string, () => Promise<unknown>>,\n resolveClientUrl?: InternalResolveClientUrl,\n) {\n const hostShared = getNamespace().hostSharedModules;\n const polyfill = {\n 'next/dist/client/components/navigation':\n hostShared['next/navigation'] ??\n shared?.['next/navigation'] ??\n (() =>\n Promise.resolve({\n useRouter() {\n return {\n push: (routerUrl: string) => {\n history.pushState({}, '', routerUrl);\n },\n replace: (routerUrl: string) => {\n history.replaceState({}, '', routerUrl);\n },\n back: () => {\n history.back();\n },\n };\n },\n usePathname() {\n return location.pathname;\n },\n useParams() {\n return {};\n },\n useSearchParams() {\n return new URLSearchParams(location.search);\n },\n useSelectedLayoutSegment() {\n return null;\n },\n useSelectedLayoutSegments() {\n return [];\n },\n __esModule: true,\n })),\n 'next/dist/client/app-dir/link':\n hostShared['next/link'] ??\n shared?.['next/link'] ??\n (() =>\n Promise.resolve({\n default: ({\n scroll: _,\n replace,\n prefetch,\n onNavigate,\n children,\n ...props\n }: React.PropsWithChildren<LinkProps>) => {\n if (prefetch) {\n logWarn(\n 'Polyfill',\n 'Next.js Link prefetch is not supported in remote components',\n );\n }\n return (\n <a\n {...props}\n href={props.href as string}\n onClick={(e) => {\n e.preventDefault();\n let preventDefaulted = false;\n e.preventDefault = () => {\n preventDefaulted = true;\n e.defaultPrevented = true;\n };\n if (typeof props.onClick === 'function') {\n props.onClick(e);\n }\n onNavigate?.(e);\n // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition\n if (preventDefaulted) {\n return;\n }\n if (replace) {\n history.replaceState({}, '', props.href as string);\n } else {\n history.pushState({}, '', props.href as string);\n }\n }}\n suppressHydrationWarning\n >\n {children ?? null}\n </a>\n );\n },\n useLinkStatus() {\n return { pending: false };\n },\n __esModule: true,\n })),\n 'next/dist/client/app-dir/form':\n hostShared['next/form'] ??\n shared?.['next/form'] ??\n (() =>\n Promise.resolve({\n default: () => {\n // TODO: implement <Form> component for non-Next.js host applications\n throw new Error('Next.js <Form> component not implemented');\n },\n __esModule: true,\n })),\n // Instead of replacing next/image entirely, we let the real Next.js Image\n // component load from the remote bundle and only replace its default loader.\n // This gives us full next/image fidelity (fill, priority, srcSet, blur\n // placeholders, error handling) while routing image optimization through the\n // remote app's /_next/image endpoint.\n 'next/dist/shared/lib/image-loader':\n hostShared['next/dist/shared/lib/image-loader'] ??\n shared?.['next/dist/shared/lib/image-loader'] ??\n ((bundle: string) =>\n Promise.resolve({\n default: createRemoteImageLoader(bundle, resolveClientUrl),\n __esModule: true,\n })),\n 'next/dist/client/script':\n hostShared['next/script'] ??\n shared?.['next/script'] ??\n (() =>\n Promise.resolve({\n // TODO: implement <Script> component for non-Next.js host applications\n // do not throw an error for now\n default: () => null,\n __esModule: true,\n })),\n 'next/router':\n hostShared['next/router'] ??\n shared?.['next/router'] ??\n (() =>\n // TODO: incomplete implementation\n Promise.resolve({\n useRouter() {\n return {\n push: (routerUrl: string) => {\n history.pushState({}, '', routerUrl);\n },\n replace: (routerUrl: string) => {\n history.replaceState({}, '', routerUrl);\n },\n back: () => {\n history.back();\n },\n };\n },\n __esModule: true,\n })),\n 'next/dist/build/polyfills/process': () =>\n Promise.resolve({\n default: {\n env: {\n NODE_ENV: 'production',\n },\n },\n __esModule: true,\n }),\n } as Record<string, () => Promise<unknown>>;\n\n polyfill['next/navigation'] = polyfill[\n 'next/dist/client/components/navigation'\n ] as () => Promise<unknown>;\n polyfill['next/link'] = polyfill[\n 'next/dist/client/app-dir/link'\n ] as () => Promise<unknown>;\n polyfill['next/form'] = polyfill[\n 'next/dist/client/app-dir/form'\n ] as () => Promise<unknown>;\n polyfill['next/dist/esm/shared/lib/image-loader'] = polyfill[\n 'next/dist/shared/lib/image-loader'\n ] as () => Promise<unknown>;\n polyfill['next/script'] = polyfill[\n 'next/dist/client/script'\n ] as () => Promise<unknown>;\n\n return polyfill;\n}\n","import type { InternalResolveClientUrl } from '#internal/host/server/types';\nimport { sharedPolyfills } from '#internal/host/shared/polyfill';\nimport type { LogLocation } from '#internal/utils/logger';\nimport { logDebug } from '#internal/utils/logger';\n\n/**\n * The core React packages that are always shared between host and remote.\n * These correspond to the `/react/*.js` and `/react-dom/*.js` path keys\n * used in the webpack module resolution map.\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 webpack-style path key.\n * For example, `react` maps to `/react/index.js`.\n */\nexport const CORE_REACT_PATH_MAP: 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 webpack path-key string literals. Derived from CORE_REACT_PATH_MAP\n * but excludes `react-dom/client` to match the existing config behavior.\n */\nexport const VENDOR_SHARED: Record<string, string> = Object.fromEntries(\n Object.entries(CORE_REACT_PATH_MAP)\n .filter(([key]) => key !== 'react-dom/client')\n .map(([key, path]) => [key, `'${path}'`]),\n);\n\ntype SharedModuleFactory = (bundle?: string) => Promise<unknown>;\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 router\n * global). Pass `includeRemoteComponentShared: true` to include it at the end.\n */\nexport function buildHostShared(\n userShared?: Record<string, SharedModuleFactory>,\n resolveClientUrl?: InternalResolveClientUrl,\n options?: { includeRemoteComponentShared?: 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?.includeRemoteComponentShared) {\n Object.assign(result, self.__remote_component_shared__);\n }\n return result;\n}\n\n/**\n * React module instances keyed by their webpack path, e.g.\n * `{ '/react/index.js': React }`. Passed into `buildWebpackResolve` so it\n * can populate the resolve map without importing React itself.\n */\nexport interface ReactModules {\n '/react/index.js': unknown;\n '/react/jsx-dev-runtime.js': unknown;\n '/react/jsx-runtime.js': unknown;\n '/react-dom/index.js': unknown;\n '/react-dom/client.js': unknown;\n}\n\n/**\n * Builds the `resolve` map passed to `applySharedModules` for the webpack\n * runtime. Combines:\n * - Static React module path keys (`/react/index.js`, etc.)\n * - Remote shared modules matched against host shared, with `(ssr)/` prefix stripped\n *\n * After building the map, resolves any factory functions by awaiting them\n * with the given bundle name.\n */\nexport async function buildWebpackResolve(\n hostShared: Record<string, SharedModuleFactory | unknown>,\n remoteShared: Record<string, string | number>,\n bundle: string,\n reactModules: ReactModules,\n callerTag: LogLocation = 'SharedModuleResolver',\n): Promise<Record<string, unknown>> {\n const resolve: Record<string, unknown> = {\n ...reactModules,\n ...Object.entries(remoteShared).reduce<Record<string, unknown>>(\n (acc, [key, value]) => {\n if (typeof hostShared[value] !== 'undefined') {\n acc[key.replace(/^\\(ssr\\)\\/(?<relative>\\.\\/)?/, '')] =\n hostShared[value];\n } else {\n logDebug(\n callerTag,\n `Remote requests \"${value}\" but host doesn't provide it`,\n );\n }\n return acc;\n },\n {},\n ),\n };\n await Promise.all(\n Object.entries(resolve).map(async ([key, value]) => {\n if (typeof value === 'function') {\n resolve[key] = await value(bundle);\n }\n return Promise.resolve(value);\n }),\n );\n return resolve;\n}\n"]}
|
|
@@ -0,0 +1,152 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); 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; } var _class;
|
|
2
|
+
|
|
3
|
+
var _chunkKE7QPAQ4cjs = require('./chunk-KE7QPAQ4.cjs');
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
var _chunkSHFJ5OQAcjs = require('./chunk-SHFJ5OQA.cjs');
|
|
8
|
+
|
|
9
|
+
// src/utils/abort.ts
|
|
10
|
+
function isAbortError(error) {
|
|
11
|
+
if (error instanceof DOMException && error.name === "AbortError") {
|
|
12
|
+
return true;
|
|
13
|
+
}
|
|
14
|
+
if (error !== null && typeof error === "object" && "name" in error && error.name === "AbortError" && "message" in error && typeof error.message === "string") {
|
|
15
|
+
const e = error;
|
|
16
|
+
return typeof e.code === "number" || _optionalChain([e, 'access', _ => _.constructor, 'optionalAccess', _2 => _2.name]) === "DOMException";
|
|
17
|
+
}
|
|
18
|
+
return false;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
// src/utils/error.ts
|
|
22
|
+
var RemoteComponentsError = (_class = class extends Error {
|
|
23
|
+
__init() {this.code = "REMOTE_COMPONENTS_ERROR"}
|
|
24
|
+
constructor(message, options) {
|
|
25
|
+
super(message, options);_class.prototype.__init.call(this);;
|
|
26
|
+
this.name = "RemoteComponentsError";
|
|
27
|
+
}
|
|
28
|
+
}, _class);
|
|
29
|
+
function multipleRemoteComponentsError(url) {
|
|
30
|
+
return new RemoteComponentsError(
|
|
31
|
+
`Multiple Remote Components found at "${url}". When a page exposes multiple Remote Components you must specify the "name" prop to select which one to load.`
|
|
32
|
+
);
|
|
33
|
+
}
|
|
34
|
+
function failedToFetchRemoteComponentError(url, { status, statusText }, help = "Is the URL correct and accessible?") {
|
|
35
|
+
return new RemoteComponentsError(
|
|
36
|
+
`Failed to fetch Remote Component from "${url}". ${help}`,
|
|
37
|
+
{ cause: new Error(`${status} ${statusText}`) }
|
|
38
|
+
);
|
|
39
|
+
}
|
|
40
|
+
async function errorFromFailedFetch(originalUrl, resolvedUrl, res) {
|
|
41
|
+
const isProxied = _chunkKE7QPAQ4cjs.isProxiedUrl.call(void 0, resolvedUrl.href);
|
|
42
|
+
if (isProxied && res) {
|
|
43
|
+
const body = await res.text().catch(() => "");
|
|
44
|
+
return failedProxyFetchError(
|
|
45
|
+
originalUrl,
|
|
46
|
+
resolvedUrl.href,
|
|
47
|
+
res.status,
|
|
48
|
+
body
|
|
49
|
+
);
|
|
50
|
+
}
|
|
51
|
+
const fallback = failedToFetchRemoteComponentError(
|
|
52
|
+
originalUrl,
|
|
53
|
+
_nullishCoalesce(res, () => ( { status: 0, statusText: "No Response" }))
|
|
54
|
+
);
|
|
55
|
+
if (!res)
|
|
56
|
+
return fallback;
|
|
57
|
+
try {
|
|
58
|
+
const body = await res.text();
|
|
59
|
+
const parser = new DOMParser();
|
|
60
|
+
const doc = parser.parseFromString(body, "text/html");
|
|
61
|
+
const errorTemplate = doc.querySelector(
|
|
62
|
+
"template[data-next-error-message]"
|
|
63
|
+
);
|
|
64
|
+
const errorMessage = _optionalChain([errorTemplate, 'optionalAccess', _3 => _3.getAttribute, 'call', _4 => _4("data-next-error-message")]);
|
|
65
|
+
if (errorMessage) {
|
|
66
|
+
const error = new RemoteComponentsError(errorMessage);
|
|
67
|
+
const errorStack = _optionalChain([errorTemplate, 'optionalAccess', _5 => _5.getAttribute, 'call', _6 => _6("data-next-error-stack")]);
|
|
68
|
+
if (errorStack) {
|
|
69
|
+
error.stack = errorStack;
|
|
70
|
+
}
|
|
71
|
+
return error;
|
|
72
|
+
}
|
|
73
|
+
} catch (parseError) {
|
|
74
|
+
if (isAbortError(parseError))
|
|
75
|
+
throw parseError;
|
|
76
|
+
}
|
|
77
|
+
return fallback;
|
|
78
|
+
}
|
|
79
|
+
function failedProxiedAssetError(kind, url, resolvedUrl) {
|
|
80
|
+
return new RemoteComponentsError(
|
|
81
|
+
`Failed to load ${kind} "${url}" via proxy "${resolvedUrl}". Ensure withRemoteComponentsHostProxy middleware is configured, "${_chunkSHFJ5OQAcjs.RC_PROTECTED_REMOTE_FETCH_PATHNAME}" is in the matcher, and the remote URL is included in allowedProxyUrls. See: ${_chunkSHFJ5OQAcjs.CORS_DOCS_URL}`
|
|
82
|
+
);
|
|
83
|
+
}
|
|
84
|
+
function failedProxyFetchError(originalUrl, proxyUrl, status, responseBody) {
|
|
85
|
+
if (status === 404) {
|
|
86
|
+
return new RemoteComponentsError(
|
|
87
|
+
`Could not proxy the request to "${originalUrl}" \u2014 the proxy endpoint "${_chunkSHFJ5OQAcjs.RC_PROTECTED_REMOTE_FETCH_PATHNAME}" returned 404.
|
|
88
|
+
|
|
89
|
+
The host server needs middleware or a route that handles "${_chunkSHFJ5OQAcjs.RC_PROTECTED_REMOTE_FETCH_PATHNAME}".
|
|
90
|
+
|
|
91
|
+
Proxying requires two pieces:
|
|
92
|
+
1. resolveClientUrl={routeThroughHostProxy} on <RemoteComponent>
|
|
93
|
+
2. Middleware or a route for "${_chunkSHFJ5OQAcjs.RC_PROTECTED_REMOTE_FETCH_PATHNAME}" on the host server
|
|
94
|
+
|
|
95
|
+
Docs: ${_chunkSHFJ5OQAcjs.CORS_DOCS_URL}`
|
|
96
|
+
);
|
|
97
|
+
}
|
|
98
|
+
if (status === 403) {
|
|
99
|
+
const detail = responseBody ? ` ${responseBody}` : "";
|
|
100
|
+
return new RemoteComponentsError(
|
|
101
|
+
`Proxied request to "${proxyUrl}" was forbidden.${detail} See: ${_chunkSHFJ5OQAcjs.CORS_DOCS_URL}`
|
|
102
|
+
);
|
|
103
|
+
}
|
|
104
|
+
return new RemoteComponentsError(
|
|
105
|
+
`Proxied request for "${originalUrl}" via "${proxyUrl}" failed with status ${status}. See: ${_chunkSHFJ5OQAcjs.CORS_DOCS_URL}`
|
|
106
|
+
);
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
// src/utils/logger.ts
|
|
110
|
+
var PREFIX = "remote-components";
|
|
111
|
+
var DEBUG = typeof window !== "undefined" && localStorage.getItem("RC_DEBUG") === "true" || typeof process !== "undefined" && process.env.RC_DEBUG === "true";
|
|
112
|
+
function logDebug(location2, message) {
|
|
113
|
+
if (DEBUG) {
|
|
114
|
+
console.debug(`[${PREFIX}:${location2}]: ${message}`);
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
function logWarn(location2, message) {
|
|
118
|
+
console.warn(`[${PREFIX}:${location2}]: ${message}`);
|
|
119
|
+
}
|
|
120
|
+
function logError(location2, message, cause) {
|
|
121
|
+
console.error(
|
|
122
|
+
new RemoteComponentsError(`[${PREFIX}:${location2}]: ${message}`, {
|
|
123
|
+
cause
|
|
124
|
+
})
|
|
125
|
+
);
|
|
126
|
+
}
|
|
127
|
+
function warnCrossOriginFetchError(logLocation, url) {
|
|
128
|
+
try {
|
|
129
|
+
const parsed = typeof url === "string" ? new URL(url) : url;
|
|
130
|
+
if (typeof location === "undefined" || parsed.origin === location.origin) {
|
|
131
|
+
return;
|
|
132
|
+
}
|
|
133
|
+
logWarn(
|
|
134
|
+
logLocation,
|
|
135
|
+
`Failed to fetch cross-origin resource "${parsed.href}". To load assets from a protected deployment, two steps are required: (1) configure withRemoteComponentsHostProxy middleware in your host with the remote URL in allowedProxyUrls, and (2) provide a resolveClientUrl prop that rewrites cross-origin asset URLs to go through the proxy. See: ${_chunkSHFJ5OQAcjs.CORS_DOCS_URL}`
|
|
136
|
+
);
|
|
137
|
+
} catch (e2) {
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
|
|
142
|
+
|
|
143
|
+
|
|
144
|
+
|
|
145
|
+
|
|
146
|
+
|
|
147
|
+
|
|
148
|
+
|
|
149
|
+
|
|
150
|
+
|
|
151
|
+
exports.isAbortError = isAbortError; exports.RemoteComponentsError = RemoteComponentsError; exports.multipleRemoteComponentsError = multipleRemoteComponentsError; exports.errorFromFailedFetch = errorFromFailedFetch; exports.failedProxiedAssetError = failedProxiedAssetError; exports.logDebug = logDebug; exports.logWarn = logWarn; exports.logError = logError; exports.warnCrossOriginFetchError = warnCrossOriginFetchError;
|
|
152
|
+
//# sourceMappingURL=chunk-RUWR74XQ.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/utils/abort.ts","../src/utils/error.ts","../src/utils/logger.ts"],"names":["location"],"mappings":";;;;;;;;;AAIO,SAAS,aAAa,OAAuC;AAClE,MAAI,iBAAiB,gBAAgB,MAAM,SAAS,cAAc;AAChE,WAAO;AAAA,EACT;AAGA,MACE,UAAU,QACV,OAAO,UAAU,YACjB,UAAU,SACV,MAAM,SAAS,gBACf,aAAa,SACb,OAAQ,MAA+B,YAAY,UACnD;AAEA,UAAM,IAAI;AACV,WAAO,OAAO,EAAE,SAAS,YAAY,EAAE,aAAa,SAAS;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A,0CAA0C,OAAO,uSAIvC;AAAA,IACZ;AAAA,EACF,QAAE;AAAA,EAEF;AACF","sourcesContent":["/**\n * Type guard to check if an error is an AbortError.\n * Handles cross-environment differences (Node.js, browsers, JSDOM).\n */\nexport function isAbortError(error: unknown): error is DOMException {\n if (error instanceof DOMException && error.name === 'AbortError') {\n return true;\n }\n\n // Handle Node.js native AbortError which may not be instanceof global DOMException\n if (\n error !== null &&\n typeof error === 'object' &&\n 'name' in error &&\n error.name === 'AbortError' &&\n 'message' in error &&\n typeof (error as { message: unknown }).message === 'string'\n ) {\n // Additional check: verify it has DOMException-like structure\n const e = error as { code?: unknown; constructor?: { name?: string } };\n return typeof e.code === 'number' || e.constructor?.name === 'DOMException';\n }\n\n return false;\n}\n","import { isProxiedUrl } from '#internal/runtime/url/protected-rc-fallback';\nimport { isAbortError } from '#internal/utils/abort';\nimport {\n CORS_DOCS_URL,\n RC_PROTECTED_REMOTE_FETCH_PATHNAME,\n} from '#internal/utils/constants';\n\nexport class RemoteComponentsError extends Error {\n code = 'REMOTE_COMPONENTS_ERROR';\n\n constructor(message: string, options?: { cause?: unknown }) {\n super(message, options);\n this.name = 'RemoteComponentsError';\n }\n}\n\nexport function multipleRemoteComponentsError(url: string | undefined) {\n return new RemoteComponentsError(\n `Multiple Remote Components found at \"${url}\". When a page exposes multiple Remote Components you must specify the \"name\" prop to select which one to load.`,\n );\n}\n\nexport function failedToFetchRemoteComponentError(\n url: string,\n { status, statusText }: { status: number; statusText: string },\n help: string = 'Is the URL correct and accessible?',\n) {\n return new RemoteComponentsError(\n `Failed to fetch Remote Component from \"${url}\". ${help}`,\n { cause: new Error(`${status} ${statusText}`) },\n );\n}\n\nexport async function errorFromFailedFetch(\n originalUrl: string,\n resolvedUrl: URL,\n res: Response | null | undefined,\n): Promise<RemoteComponentsError> {\n const isProxied = isProxiedUrl(resolvedUrl.href);\n\n if (isProxied && res) {\n const body = await res.text().catch(() => '');\n return failedProxyFetchError(\n originalUrl,\n resolvedUrl.href,\n res.status,\n body,\n );\n }\n\n const fallback = failedToFetchRemoteComponentError(\n originalUrl,\n res ?? { status: 0, statusText: 'No Response' },\n );\n\n if (!res) return fallback;\n\n try {\n const body = await res.text();\n const parser = new DOMParser();\n const doc = parser.parseFromString(body, 'text/html');\n const errorTemplate = doc.querySelector(\n 'template[data-next-error-message]',\n );\n const errorMessage = errorTemplate?.getAttribute('data-next-error-message');\n if (errorMessage) {\n const error = new RemoteComponentsError(errorMessage);\n const errorStack = errorTemplate?.getAttribute('data-next-error-stack');\n if (errorStack) {\n error.stack = errorStack;\n }\n return error;\n }\n } catch (parseError) {\n // Re-throw abort errors, ignore parse errors\n if (isAbortError(parseError)) throw parseError;\n }\n\n return fallback;\n}\n\nexport function failedProxiedAssetError(\n kind: 'chunk' | 'script',\n url: string,\n resolvedUrl: string,\n): RemoteComponentsError {\n return new RemoteComponentsError(\n `Failed to load ${kind} \"${url}\" via proxy \"${resolvedUrl}\". ` +\n `Ensure withRemoteComponentsHostProxy middleware is configured, \"${RC_PROTECTED_REMOTE_FETCH_PATHNAME}\" is in the matcher, ` +\n `and the remote URL is included in allowedProxyUrls. ` +\n `See: ${CORS_DOCS_URL}`,\n );\n}\n\nexport function failedProxyFetchError(\n originalUrl: string,\n proxyUrl: string,\n status: number,\n responseBody?: string,\n): RemoteComponentsError {\n if (status === 404) {\n return new RemoteComponentsError(\n `Could not proxy the request to \"${originalUrl}\" — the proxy endpoint \"${RC_PROTECTED_REMOTE_FETCH_PATHNAME}\" returned 404.\\n\\n` +\n `The host server needs middleware or a route that handles \"${RC_PROTECTED_REMOTE_FETCH_PATHNAME}\".\\n\\n` +\n `Proxying requires two pieces:\\n` +\n ` 1. resolveClientUrl={routeThroughHostProxy} on <RemoteComponent>\\n` +\n ` 2. Middleware or a route for \"${RC_PROTECTED_REMOTE_FETCH_PATHNAME}\" on the host server\\n\\n` +\n `Docs: ${CORS_DOCS_URL}`,\n );\n }\n if (status === 403) {\n const detail = responseBody ? ` ${responseBody}` : '';\n return new RemoteComponentsError(\n `Proxied request to \"${proxyUrl}\" was forbidden.${detail} ` +\n `See: ${CORS_DOCS_URL}`,\n );\n }\n return new RemoteComponentsError(\n `Proxied request for \"${originalUrl}\" via \"${proxyUrl}\" failed with status ${status}. ` +\n `See: ${CORS_DOCS_URL}`,\n );\n}\n","import { CORS_DOCS_URL } from '#internal/utils/constants';\nimport { RemoteComponentsError } from '#internal/utils/error';\n\nexport type LogLocation =\n | 'ChunkLoader'\n | 'ChunkDispatcher'\n | 'ComponentLoader'\n | 'ModuleDispatcher'\n | 'RemoteScope'\n | 'SharedModules'\n | 'WebpackRuntime'\n | 'TurbopackModule'\n | 'StaticLoader'\n | 'ScriptLoader'\n | 'Polyfill'\n | 'HtmlRemote'\n | 'HtmlHost'\n | 'Config'\n | 'NextAppRouter'\n | 'NextAppRouterCompat'\n | 'FetchRemoteComponent'\n | 'SharedModuleResolver';\n\nconst PREFIX = 'remote-components';\nconst DEBUG =\n (typeof window !== 'undefined' &&\n localStorage.getItem('RC_DEBUG') === 'true') ||\n (typeof process !== 'undefined' && process.env.RC_DEBUG === 'true');\n\nexport function logDebug(location: LogLocation, message: string) {\n if (DEBUG) {\n // eslint-disable-next-line no-console\n console.debug(`[${PREFIX}:${location}]: ${message}`);\n }\n}\n\nexport function logInfo(location: LogLocation, message: string) {\n // eslint-disable-next-line no-console\n console.info(`[${PREFIX}:${location}]: ${message}`);\n}\n\nexport function logWarn(location: LogLocation, message: string) {\n // eslint-disable-next-line no-console\n console.warn(`[${PREFIX}:${location}]: ${message}`);\n}\n\nexport function logError(\n location: LogLocation,\n message: string,\n cause?: unknown,\n) {\n // eslint-disable-next-line no-console\n console.error(\n new RemoteComponentsError(`[${PREFIX}:${location}]: ${message}`, {\n cause,\n }),\n );\n}\n\n/**\n * Logs a warning when a cross-origin asset request fails, guiding users\n * to configure the proxy middleware and resolveClientUrl on their host.\n */\nexport function warnCrossOriginFetchError(\n logLocation: LogLocation,\n url: string | URL,\n): void {\n try {\n const parsed = typeof url === 'string' ? new URL(url) : url;\n if (typeof location === 'undefined' || parsed.origin === location.origin) {\n return;\n }\n logWarn(\n logLocation,\n `Failed to fetch cross-origin resource \"${parsed.href}\". ` +\n 'To load assets from a protected deployment, two steps are required: ' +\n '(1) configure withRemoteComponentsHostProxy middleware in your host with the remote URL in allowedProxyUrls, ' +\n 'and (2) provide a resolveClientUrl prop that rewrites cross-origin asset URLs to go through the proxy. ' +\n `See: ${CORS_DOCS_URL}`,\n );\n } catch {\n // URL parsing failed — skip the warning\n }\n}\n"]}
|