@appshell/react-shell 1.0.0-alpha.33 → 1.0.0-alpha.35
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/466.js +2 -0
- package/dist/466.js.LICENSE.txt +9 -0
- package/dist/58.js +1 -1
- package/dist/630.js +1 -1
- package/dist/677.js +1 -1
- package/dist/85.js +2 -0
- package/dist/85.js.LICENSE.txt +9 -0
- package/dist/dev/main.js +30 -11
- package/dist/dev/main.js.map +1 -1
- package/dist/dev/mf-manifest.json +25 -5
- package/dist/dev/mf-stats.json +29 -5
- package/dist/dev/react_src_index_ts-_f7a70.js +32 -17
- package/dist/dev/react_src_index_ts-_f7a70.js.map +1 -1
- package/dist/dev/react_src_index_ts-_f7a71.js +32 -17
- package/dist/dev/react_src_index_ts-_f7a71.js.map +1 -1
- package/dist/dev/src_bootstrap_tsx.js +9 -4
- package/dist/dev/src_bootstrap_tsx.js.map +1 -1
- package/dist/dev/vendors-node_modules_react_jsx-runtime_js.js +1345 -0
- package/dist/dev/vendors-node_modules_react_jsx-runtime_js.js.map +1 -0
- package/dist/main.js +1 -1
- package/dist/mf-manifest.json +25 -4
- package/dist/mf-stats.json +29 -4
- package/package.json +3 -3
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
"name": "Appshell",
|
|
6
6
|
"type": "app",
|
|
7
7
|
"buildInfo": {
|
|
8
|
-
"buildVersion": "1.0.0-alpha.
|
|
8
|
+
"buildVersion": "1.0.0-alpha.35",
|
|
9
9
|
"buildName": "@appshell/react-shell"
|
|
10
10
|
},
|
|
11
11
|
"remoteEntry": {
|
|
@@ -27,9 +27,9 @@
|
|
|
27
27
|
{
|
|
28
28
|
"id": "Appshell:@appshell/react",
|
|
29
29
|
"name": "@appshell/react",
|
|
30
|
-
"version": "1.0.0-alpha.
|
|
30
|
+
"version": "1.0.0-alpha.35",
|
|
31
31
|
"singleton": true,
|
|
32
|
-
"requiredVersion": "^1.0.0-alpha.
|
|
32
|
+
"requiredVersion": "^1.0.0-alpha.35",
|
|
33
33
|
"assets": {
|
|
34
34
|
"js": {
|
|
35
35
|
"async": [],
|
|
@@ -48,9 +48,9 @@
|
|
|
48
48
|
{
|
|
49
49
|
"id": "Appshell:@appshell/runtime",
|
|
50
50
|
"name": "@appshell/runtime",
|
|
51
|
-
"version": "1.0.0-alpha.
|
|
51
|
+
"version": "1.0.0-alpha.35",
|
|
52
52
|
"singleton": true,
|
|
53
|
-
"requiredVersion": "^1.0.0-alpha.
|
|
53
|
+
"requiredVersion": "^1.0.0-alpha.35",
|
|
54
54
|
"assets": {
|
|
55
55
|
"js": {
|
|
56
56
|
"async": [],
|
|
@@ -85,6 +85,26 @@
|
|
|
85
85
|
},
|
|
86
86
|
"fallback": ""
|
|
87
87
|
},
|
|
88
|
+
{
|
|
89
|
+
"id": "Appshell:react/jsx-runtime",
|
|
90
|
+
"name": "react/jsx-runtime",
|
|
91
|
+
"version": "18.2.0",
|
|
92
|
+
"singleton": true,
|
|
93
|
+
"requiredVersion": "18.2.0",
|
|
94
|
+
"assets": {
|
|
95
|
+
"js": {
|
|
96
|
+
"async": [],
|
|
97
|
+
"sync": [
|
|
98
|
+
"vendors-node_modules_react_jsx-runtime_js.js"
|
|
99
|
+
]
|
|
100
|
+
},
|
|
101
|
+
"css": {
|
|
102
|
+
"async": [],
|
|
103
|
+
"sync": []
|
|
104
|
+
}
|
|
105
|
+
},
|
|
106
|
+
"fallback": ""
|
|
107
|
+
},
|
|
88
108
|
{
|
|
89
109
|
"id": "Appshell:react",
|
|
90
110
|
"name": "react",
|
package/dist/dev/mf-stats.json
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
"name": "Appshell",
|
|
6
6
|
"type": "app",
|
|
7
7
|
"buildInfo": {
|
|
8
|
-
"buildVersion": "1.0.0-alpha.
|
|
8
|
+
"buildVersion": "1.0.0-alpha.35",
|
|
9
9
|
"buildName": "@appshell/react-shell"
|
|
10
10
|
},
|
|
11
11
|
"remoteEntry": {
|
|
@@ -26,10 +26,10 @@
|
|
|
26
26
|
"shared": [
|
|
27
27
|
{
|
|
28
28
|
"singleton": true,
|
|
29
|
-
"requiredVersion": "^1.0.0-alpha.
|
|
29
|
+
"requiredVersion": "^1.0.0-alpha.35",
|
|
30
30
|
"shareScope": "default",
|
|
31
31
|
"name": "@appshell/react",
|
|
32
|
-
"version": "1.0.0-alpha.
|
|
32
|
+
"version": "1.0.0-alpha.35",
|
|
33
33
|
"eager": false,
|
|
34
34
|
"id": "Appshell:@appshell/react",
|
|
35
35
|
"assets": {
|
|
@@ -51,10 +51,10 @@
|
|
|
51
51
|
},
|
|
52
52
|
{
|
|
53
53
|
"singleton": true,
|
|
54
|
-
"requiredVersion": "^1.0.0-alpha.
|
|
54
|
+
"requiredVersion": "^1.0.0-alpha.35",
|
|
55
55
|
"shareScope": "default",
|
|
56
56
|
"name": "@appshell/runtime",
|
|
57
|
-
"version": "1.0.0-alpha.
|
|
57
|
+
"version": "1.0.0-alpha.35",
|
|
58
58
|
"eager": false,
|
|
59
59
|
"id": "Appshell:@appshell/runtime",
|
|
60
60
|
"assets": {
|
|
@@ -97,6 +97,30 @@
|
|
|
97
97
|
"usedExports": [],
|
|
98
98
|
"fallback": ""
|
|
99
99
|
},
|
|
100
|
+
{
|
|
101
|
+
"singleton": true,
|
|
102
|
+
"requiredVersion": "18.2.0",
|
|
103
|
+
"shareScope": "default",
|
|
104
|
+
"name": "react/jsx-runtime",
|
|
105
|
+
"version": "18.2.0",
|
|
106
|
+
"eager": false,
|
|
107
|
+
"id": "Appshell:react/jsx-runtime",
|
|
108
|
+
"assets": {
|
|
109
|
+
"js": {
|
|
110
|
+
"async": [],
|
|
111
|
+
"sync": [
|
|
112
|
+
"vendors-node_modules_react_jsx-runtime_js.js"
|
|
113
|
+
]
|
|
114
|
+
},
|
|
115
|
+
"css": {
|
|
116
|
+
"async": [],
|
|
117
|
+
"sync": []
|
|
118
|
+
}
|
|
119
|
+
},
|
|
120
|
+
"usedIn": [],
|
|
121
|
+
"usedExports": [],
|
|
122
|
+
"fallback": ""
|
|
123
|
+
},
|
|
100
124
|
{
|
|
101
125
|
"singleton": true,
|
|
102
126
|
"requiredVersion": "18.2.0",
|
|
@@ -211,21 +211,25 @@ __webpack_require__.r(__webpack_exports__);
|
|
|
211
211
|
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
|
|
212
212
|
/* harmony export */ "default": () => (__WEBPACK_DEFAULT_EXPORT__)
|
|
213
213
|
/* harmony export */ });
|
|
214
|
-
/* harmony import */ var
|
|
215
|
-
/* harmony import */ var
|
|
214
|
+
/* harmony import */ var react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! react/jsx-runtime */ "webpack/sharing/consume/default/react/jsx-runtime/react/jsx-runtime");
|
|
215
|
+
/* harmony import */ var react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__);
|
|
216
216
|
|
|
217
217
|
const LoadingError = ({
|
|
218
218
|
remote,
|
|
219
219
|
reason
|
|
220
|
-
}) => /*#__PURE__*/
|
|
220
|
+
}) => /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsxs)("div", {
|
|
221
221
|
style: {
|
|
222
222
|
border: '3px solid red'
|
|
223
|
-
}
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
223
|
+
},
|
|
224
|
+
children: [/*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx)("h5", {
|
|
225
|
+
children: `Error loading Appshell component '${remote}.'`
|
|
226
|
+
}), /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx)("span", {
|
|
227
|
+
style: {
|
|
228
|
+
fontSize: '1rem'
|
|
229
|
+
},
|
|
230
|
+
children: reason
|
|
231
|
+
})]
|
|
232
|
+
});
|
|
229
233
|
/* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (LoadingError);
|
|
230
234
|
|
|
231
235
|
/***/ },
|
|
@@ -245,6 +249,8 @@ __webpack_require__.r(__webpack_exports__);
|
|
|
245
249
|
/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(react__WEBPACK_IMPORTED_MODULE_1__);
|
|
246
250
|
/* harmony import */ var _contexts_RemoteContext__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../contexts/RemoteContext */ "../react/src/contexts/RemoteContext.tsx");
|
|
247
251
|
/* harmony import */ var _LoadingError__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./LoadingError */ "../react/src/components/LoadingError.tsx");
|
|
252
|
+
/* harmony import */ var react_jsx_runtime__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! react/jsx-runtime */ "webpack/sharing/consume/default/react/jsx-runtime/react/jsx-runtime");
|
|
253
|
+
/* harmony import */ var react_jsx_runtime__WEBPACK_IMPORTED_MODULE_4___default = /*#__PURE__*/__webpack_require__.n(react_jsx_runtime__WEBPACK_IMPORTED_MODULE_4__);
|
|
248
254
|
/* eslint-disable react/jsx-props-no-spreading */
|
|
249
255
|
|
|
250
256
|
|
|
@@ -283,12 +289,15 @@ const RemoteSlot = ({
|
|
|
283
289
|
if (disposed || !Component) {
|
|
284
290
|
return;
|
|
285
291
|
}
|
|
286
|
-
setElement(/*#__PURE__*/
|
|
287
|
-
remote: resolved
|
|
288
|
-
|
|
292
|
+
setElement(/*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_4__.jsx)(_contexts_RemoteContext__WEBPACK_IMPORTED_MODULE_2__.RemoteProvider, {
|
|
293
|
+
remote: resolved,
|
|
294
|
+
children: /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_4__.jsx)(Component, {
|
|
295
|
+
...rest
|
|
296
|
+
})
|
|
297
|
+
}));
|
|
289
298
|
} catch (err) {
|
|
290
299
|
if (!disposed) {
|
|
291
|
-
setElement(/*#__PURE__*/
|
|
300
|
+
setElement(/*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_4__.jsx)(_LoadingError__WEBPACK_IMPORTED_MODULE_3__["default"], {
|
|
292
301
|
remote: remote,
|
|
293
302
|
reason: `${err}`
|
|
294
303
|
}));
|
|
@@ -306,7 +315,9 @@ const RemoteSlot = ({
|
|
|
306
315
|
// eslint-disable-next-line no-console
|
|
307
316
|
console.debug(`rendering RemoteSlot[${remote}], loading=${!element}`);
|
|
308
317
|
// eslint-disable-next-line react/jsx-no-useless-fragment
|
|
309
|
-
return /*#__PURE__*/
|
|
318
|
+
return /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_4__.jsx)(react_jsx_runtime__WEBPACK_IMPORTED_MODULE_4__.Fragment, {
|
|
319
|
+
children: element || fallback
|
|
320
|
+
});
|
|
310
321
|
};
|
|
311
322
|
RemoteSlot.defaultProps = {
|
|
312
323
|
fallback: undefined
|
|
@@ -330,14 +341,18 @@ __webpack_require__.r(__webpack_exports__);
|
|
|
330
341
|
/* harmony export */ });
|
|
331
342
|
/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! react */ "webpack/sharing/consume/default/react/react");
|
|
332
343
|
/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(react__WEBPACK_IMPORTED_MODULE_0__);
|
|
344
|
+
/* harmony import */ var react_jsx_runtime__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! react/jsx-runtime */ "webpack/sharing/consume/default/react/jsx-runtime/react/jsx-runtime");
|
|
345
|
+
/* harmony import */ var react_jsx_runtime__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(react_jsx_runtime__WEBPACK_IMPORTED_MODULE_1__);
|
|
346
|
+
|
|
333
347
|
|
|
334
348
|
const RemoteContext = /*#__PURE__*/(0,react__WEBPACK_IMPORTED_MODULE_0__.createContext)(undefined);
|
|
335
349
|
const RemoteProvider = ({
|
|
336
350
|
remote,
|
|
337
351
|
children
|
|
338
|
-
}) => /*#__PURE__*/
|
|
339
|
-
value: remote
|
|
340
|
-
|
|
352
|
+
}) => /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_1__.jsx)(RemoteContext.Provider, {
|
|
353
|
+
value: remote,
|
|
354
|
+
children: children
|
|
355
|
+
});
|
|
341
356
|
RemoteProvider.defaultProps = {
|
|
342
357
|
remote: undefined
|
|
343
358
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"react_src_index_ts-_f7a70.js","mappings":";;;;;;;;;;;;;;;;;;;AAA0C;AAGd;AACJ;AAExB,iEAAeA,qDAAY,E;;;;;;;;;;;;;;;ACDkB;AAE7C,MAAMK,SAAS,GAAG,UAAU;;AAE5B;AACA,IAAIC,WAAW,GAAG,KAAK;AACvB,MAAMC,gBAAgB,GAAG,IAAIC,GAAG,CAAS,CAAC;AAE1C,MAAMC,iBAAiB,GAAGA,CAAA,KAAM;EAC9B,IAAIH,WAAW,EAAE;EACjBA,WAAW,GAAG,IAAI;;EAElB;EACA;EACA;EACA,IAAIL,gFAAW,CAAC,CAAC,EAAE;EAEnBC,yEAAI,CAAC;IAAEQ,IAAI,EAAEL,SAAS;IAAEM,OAAO,EAAE;EAAG,CAAC,CAAC;AACxC,CAAC;AAED,iEAAe,OACbC,KAAa,EACbC,MAAc,EACdC,cAAsB,EACtBC,UAAU,GAAG,SAAS,KACnB;EACH;EACAC,OAAO,CAACC,KAAK,CACX,wCAAwCL,KAAK,aAAaC,MAAM,iBAAiBE,UAAU,IAC7F,CAAC;EAEDN,iBAAiB,CAAC,CAAC;;EAEnB;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA,IAAI,CAACF,gBAAgB,CAACW,GAAG,CAACN,KAAK,CAAC,EAA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AAK,SAAS,EAAE;QAC/B,OAAOC,MAAM;MACf;MAEA,OAAOvD,SAAS;IAClB;EACF,CAAC;AACH,CAAC;AAAA,4L;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AClCuD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;ACAd","sources":["webpack://appshell-react-shell/../loader/src/index.ts","webpack://appshell-react-shell/../loader/src/loadAppshellComponent.ts","webpack://appshell-react-shell/../loader/src/remoteLoader.ts","webpack://appshell-react-shell/../loader/src/resolvers.ts","webpack://appshell-react-shell/../loader/src/types.ts","webpack://appshell-react-shell/../react/src/components/LoadingError.tsx","webpack://appshell-react-shell/../react/src/components/RemoteSlot.tsx","webpack://appshell-react-shell/../react/src/contexts/RemoteContext.tsx","webpack://appshell-react-shell/../react/src/hooks/useRemote.ts","webpack://appshell-react-shell/../react/src/index.ts","webpack://appshell-react-shell/../react/src/resources/jsonResource.ts","webpack://appshell-react-shell/../../node_modules/@module-federation/enhanced/dist/src/runtime.mjs","webpack://appshell-react-shell/../../node_modules/@module-federation/runtime-tools/dist/runtime.js"],"sourcesContent":["import remoteLoader from './remoteLoader';\n\nexport type { RemoteLoaderOptions } from './remoteLoader';\nexport * from './resolvers';\nexport * from './types';\n\nexport default remoteLoader;\n","import {\n getInstance,\n init,\n loadRemote,\n registerRemotes,\n} from '@module-federation/enhanced/runtime';\n\nconst HOST_NAME = 'Appshell';\n\n// The runtime instance and each remote's registration only need to happen once per page load.\nlet initialized = false;\nconst registeredScopes = new Set<string>();\n\nconst ensureInitialized = () => {\n if (initialized) return;\n initialized = true;\n\n // A host that ships its own ModuleFederationPlugin (e.g. @appshell/react-shell) already\n // created the global federation instance during its own bootstrap. Re-calling `init()`\n // with a different name throws (#RUNTIME-010), so reuse whatever instance already exists.\n if (getInstance()) return;\n\n init({ name: HOST_NAME, remotes: [] });\n};\n\nexport default async <TComponent>(\n scope: string,\n module: string,\n remoteEntryUrl: string,\n shareScope = 'default',\n) => {\n // eslint-disable-next-line no-console\n console.debug(\n `loading Appshell component: { scope: ${scope}, module: ${module}, shareScope: ${shareScope} }`,\n );\n\n ensureInitialized();\n\n // Registered exactly once, and never re-registered or cache-busted afterwards.\n //\n // A remote served by a dev server updates itself: its `remoteEntry` already carries\n // webpack's HMR runtime and a dev-server client, so an edit is applied in place\n // behind a container identity that does not move. Re-registering the same scope, or\n // appending a cache-busting query to its entry, changes that identity and the\n // `publicPath` derived from it mid-flight, which strands the `*.hot-update.json` and\n // `*.hot-update.js` requests the remote is midway through making.\n if (!registeredScopes.has(scope)) {\n registeredScopes.add(scope);\n registerRemotes([{ name: scope, entry: remoteEntryUrl }]);\n }\n\n // Federation ids drop the leading `./` that `exposes` keys use.\n const exposed = module.replace(/^\\.\\//, '');\n const Module = await loadRemote<{ default: TComponent }>(`${scope}/${exposed}`);\n\n if (!Module) {\n throw new Error(`Failed to find module container ${scope}`);\n }\n\n // eslint-disable-next-line no-console\n console.debug(\n `Appshell component loaded: { scope: ${scope}, module: ${module}, shareScope: ${shareScope} }`,\n );\n\n return Module.default;\n};\n","/* eslint-disable no-underscore-dangle */\nimport type { AppshellComposition } from '@appshell/config';\nimport { setVars } from '@appshell/runtime';\nimport loadAppshellComponent from './loadAppshellComponent';\nimport { chainResolvers, inlineResolver, registryResolver, type RemoteResolver } from './resolvers';\n\ndeclare global {\n interface Window {\n __appshell_config__?: AppshellComposition;\n }\n}\n\nexport type RemoteLoaderOptions = {\n composition?: AppshellComposition;\n /** Replaces the resolver chain outright; a seam for tests and embedders. */\n resolver?: RemoteResolver;\n};\n\nexport default (options: RemoteLoaderOptions = {}) => {\n const composition =\n options.composition ?? (typeof window === 'undefined' ? undefined : window.__appshell_config__);\n\n const resolve =\n options.resolver ??\n chainResolvers(inlineResolver(composition), registryResolver(composition));\n\n return async <TComponent>(key: string) => {\n const failed = (err: unknown) =>\n new Error(`Failed to load component '${key}'. ${err?.toString()}`);\n\n let resolution;\n try {\n resolution = await resolve(key);\n } catch (err) {\n throw failed(err);\n }\n\n if (!resolution) {\n throw new Error(`Remote resource not found in registry. Expected: ${key}`);\n }\n\n const { remote, vars } = resolution;\n\n try {\n // Before the remote loads, so a package that validates its vars while its modules\n // evaluate still finds them. `@appshell/runtime` is a shared singleton, so this is\n // the same store the package reads through `getVars()`.\n setVars(remote.scope, vars);\n\n const Component = await loadAppshellComponent<TComponent>(\n remote.scope,\n remote.module,\n remote.remoteEntryUrl,\n remote.shareScope,\n );\n\n return [Component, remote] as const;\n } catch (err) {\n throw failed(err);\n }\n };\n};\n","import type { AppshellComposition, ResolvedRemote } from '@appshell/config';\n\nexport type RemoteResolution = {\n remote: ResolvedRemote;\n /** Already merged with the application's overrides — nothing left for the browser to layer on. */\n vars: Record<string, string | number | undefined>;\n};\n\nexport type RemoteResolver = (key: string) => Promise<RemoteResolution | undefined>;\n\n/** The registry inlined the composition into the page, so no network call is needed. */\nexport const inlineResolver =\n (composition?: AppshellComposition): RemoteResolver =>\n async (key) => {\n const remote = composition?.remotes[key];\n if (!composition || !remote) return undefined;\n\n return {\n remote,\n vars: composition.vars[remote.scope] ?? {},\n };\n };\n\n/** Fetch-on-miss: covers a package activated after this page was served. */\nexport const registryResolver =\n (composition?: AppshellComposition, origin = ''): RemoteResolver =>\n async (key) => {\n if (!composition) return undefined;\n\n const url = `${origin}/v1/applications/${composition.applicationId}/remotes/${key}`;\n const response = await fetch(url, { credentials: 'include' });\n if (!response.ok) return undefined;\n\n const remote: ResolvedRemote = await response.json();\n\n return {\n remote,\n vars: composition.vars[remote.scope] ?? {},\n };\n };\n\nexport const chainResolvers =\n (...resolvers: RemoteResolver[]): RemoteResolver =>\n async (key) => {\n // eslint-disable-next-line no-restricted-syntax\n for (const resolve of resolvers) {\n // eslint-disable-next-line no-await-in-loop\n const resolution = await resolve(key);\n if (resolution) return resolution;\n }\n\n return undefined;\n };\n","// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport type ShareScope<TComponent = any> = Record<\n string,\n Record<string, { loaded?: 1; get: () => Promise<TComponent>; from: string; eager: boolean }>\n>;\n\nexport interface ModuleContainer<TComponent> {\n init(shareScope: ShareScope<TComponent>): Promise<void>;\n get(module: string): Promise<() => Record<string, TComponent>>;\n}\n","import React, { FC } from 'react';\n\ntype ErrorProps = {\n remote: string;\n reason: string;\n};\n\nconst LoadingError: FC<ErrorProps> = ({ remote, reason }) => (\n <div style={{ border: '3px solid red' }}>\n <h5>{`Error loading Appshell component '${remote}.'`}</h5>\n <span style={{ fontSize: '1rem' }}>{reason}</span>\n </div>\n);\n\nexport default LoadingError;\n","/* eslint-disable react/jsx-props-no-spreading */\nimport remoteLoader from '@appshell/loader';\nimport React, { ComponentType, ReactElement, ReactNode, useEffect, useState } from 'react';\nimport { RemoteProvider } from '../contexts/RemoteContext';\nimport LoadingError from './LoadingError';\n\nexport type ExtendedProps = Record<string, unknown>;\n\n// eslint-disable-next-line @typescript-eslint/no-unnecessary-type-constraint\nexport type RemoteSlotProps<TProps extends ExtendedProps = ExtendedProps> = {\n remote: string;\n fallback?: ReactNode;\n} & TProps;\n\n/**\n * Loads a remote once and leaves it alone.\n *\n * Keeping a remote current while it is being developed is not this component's job.\n * A remote served by a dev server ships webpack's HMR runtime and a dev-server client\n * inside its own `remoteEntry`, so it applies its own edits in place and React Fast\n * Refresh swaps the component implementations underneath this tree — no reload, and no\n * remount that would discard state this component never owned.\n *\n * Watching the remote's socket from here and reloading the page was strictly worse: it\n * raced the remote's own update, and it threw away the entire composed app to deliver a\n * change to one subtree. When webpack genuinely cannot apply an update, the remote's own\n * client still falls back to a full reload — which is the right place for that decision,\n * because it is the only side that knows whether the update applied.\n */\nconst RemoteSlot = <TProps extends ExtendedProps>({\n remote,\n fallback,\n ...rest\n}: RemoteSlotProps<TProps>): ReactElement<TProps> => {\n const [element, setElement] = useState<ReactElement>();\n\n useEffect(() => {\n let disposed = false;\n const loadComponent = remoteLoader();\n\n async function load() {\n try {\n const [Component, resolved] = await loadComponent<ComponentType>(remote);\n\n if (disposed || !Component) {\n return;\n }\n\n setElement(\n <RemoteProvider remote={resolved}>\n <Component {...rest} />\n </RemoteProvider>,\n );\n } catch (err) {\n if (!disposed) {\n setElement(<LoadingError remote={remote} reason={`${err}`} />);\n }\n }\n }\n\n setElement(undefined);\n load();\n\n return () => {\n disposed = true;\n };\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [remote, ...Object.values(rest)]);\n\n // eslint-disable-next-line no-console\n console.debug(`rendering RemoteSlot[${remote}], loading=${!element}`);\n // eslint-disable-next-line react/jsx-no-useless-fragment\n return <>{element || fallback}</>;\n};\n\nRemoteSlot.defaultProps = {\n fallback: undefined,\n};\n\nexport default RemoteSlot;\n","import { AppshellRemote } from '@appshell/config';\nimport type { FC, ReactNode } from 'react';\nimport React, { createContext } from 'react';\n\ninterface RemoteProviderProps {\n remote?: AppshellRemote;\n children: ReactNode;\n}\n\nexport const RemoteContext = createContext<AppshellRemote | undefined>(undefined);\n\nexport const RemoteProvider: FC<RemoteProviderProps> = ({ remote, children }) => (\n <RemoteContext.Provider value={remote}>{children}</RemoteContext.Provider>\n);\n\nRemoteProvider.defaultProps = {\n remote: undefined,\n};\n\nexport const RemoteConsumer = RemoteContext.Consumer;\n\nexport default RemoteContext;\n","import { AppshellRemote } from '@appshell/config';\nimport React from 'react';\n// eslint-disable-next-line import/no-named-as-default\nimport RemoteContext from '../contexts/RemoteContext';\n\n/** The remote backing the nearest `RemoteSlot` — it already knows its own key. */\nexport default (): AppshellRemote | undefined => React.useContext(RemoteContext);\n","/*\n * The wire types, re-exported so a React package needs one dependency rather than two\n * to type what RemoteSlot hands it.\n */\nexport type { AppshellIndex, AppshellRemote, Metadata } from '@appshell/runtime';\nexport { default as RemoteSlot } from './components/RemoteSlot';\nexport { RemoteProvider } from './contexts/RemoteContext';\nexport { default as useRemote } from './hooks/useRemote';\nexport { default as jsonResource } from './resources/jsonResource';\n","export default <TResource>(url: string) => {\n let status = 'pending';\n let result: TResource | Error;\n const suspender = fetch(url, {\n headers: {\n 'Content-Type': 'application/json',\n Accept: 'application/json',\n },\n // eslint-disable-next-line consistent-return\n }).then((response) => {\n if (response.ok) {\n return response.json().then((data) => {\n status = 'success';\n result = data;\n });\n }\n status = 'error';\n result = new Error(`${response.status} ${response.statusText} ${response.url}`);\n });\n\n return {\n read() {\n if (status === 'pending') {\n // eslint-disable-next-line @typescript-eslint/no-throw-literal\n throw suspender as Promise<TResource>;\n } else if (status === 'error') {\n throw result as Error;\n } else if (status === 'success') {\n return result;\n }\n\n return undefined;\n },\n };\n};\n","export * from \"@module-federation/runtime-tools/runtime\"\n\nexport { };","export * from \"@module-federation/runtime\"\n\nexport { };"],"names":["remoteLoader","getInstance","init","loadRemote","registerRemotes","HOST_NAME","initialized","registeredScopes","Set","ensureInitialized","name","remotes","scope","module","remoteEntryUrl","shareScope","console","debug","has","add","entry","exposed","replace","Module","Error","default","setVars","loadAppshellComponent","chainResolvers","inlineResolver","registryResolver","options","composition","window","undefined","__appshell_config__","resolve","resolver","key","failed","err","toString","resolution","remote","vars","Component","origin","url","applicationId","response","fetch","credentials","ok","json","resolvers","React","LoadingError","reason","createElement","style","border","fontSize","useEffect","useState","RemoteProvider","RemoteSlot","fallback","rest","element","setElement","disposed","loadComponent","load","resolved","Object","values","Fragment","defaultProps","createContext","RemoteContext","children","Provider","value","RemoteConsumer","Consumer","useContext","useRemote","jsonResource","status","result","suspender","headers","Accept","then","data","statusText","read"],"sourceRoot":""}
|
|
1
|
+
{"version":3,"file":"react_src_index_ts-_f7a70.js","mappings":";;;;;;;;;;;;;;;;;;;AAA0C;AAGd;AACJ;AAExB,iEAAeA,qDAAY,E;;;;;;;;;;;;;;;ACDkB;AAE7C,MAAMK,SAAS,GAAG,UAAU;;AAE5B;AACA,IAAIC,WAAW,GAAG,KAAK;AACvB,MAAMC,gBAAgB,GAAG,IAAIC,GAAG,CAAS,CAAC;AAE1C,MAAMC,iBAAiB,GAAGA,CAAA,KAAM;EAC9B,IAAIH,WAAW,EAAE;EACjBA,WAAW,GAAG,IAA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,CAACC,IAAI,CAAE/C,QAAQ,IAAK;IACpB,IAAIA,QAAQ,CAACG,EAAE,EAAE;MACf,OAAOH,QAAQ,CAACI,IAAI,CAAC,CAAC,CAAC2C,IAAI,CAAEC,IAAI,IAAK;QACpCN,MAAM,GAAG,SAAS;QAClBC,MAAM,GAAGK,IAAI;MACf,CAAC,CAAC;IACJ;IACAN,MAAM,GAAG,OAAO;IAChBC,MAAM,GAAG,IAAIpE,KAAK,CAAC,GAAGyB,QAAQ,CAAC0C,MAAM,IAAI1C,QAAQ,CAACiD,UAAU,IAAIjD,QAAQ,CAACF,GAAG,EAAE,CAAC;EACjF,CAAC,CAAC;EAEF,OAAO;IACLoD,IAAIA,CAAA,EAAG;MACL,IAAIR,MAAM,KAAK,SAAS,EAAE;QACxB;QACA,MAAME,SAAS;MACjB,CAAC,MAAM,IAAIF,MAAM,KAAK,OAAO,EAAE;QAC7B,MAAMC,MAAM;MACd,CAAC,MAAM,IAAID,MAAM,KAAK,SAAS,EAAE;QAC/B,OAAOC,MAAM;MACf;MAEA,OAAO1D,SAAS;IAClB;EACF,CAAC;AACH,CAAC;AAAA,4L;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AClCuD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;ACAd","sources":["webpack://appshell-react-shell/../loader/src/index.ts","webpack://appshell-react-shell/../loader/src/loadAppshellComponent.ts","webpack://appshell-react-shell/../loader/src/remoteLoader.ts","webpack://appshell-react-shell/../loader/src/resolvers.ts","webpack://appshell-react-shell/../loader/src/types.ts","webpack://appshell-react-shell/../react/src/components/LoadingError.tsx","webpack://appshell-react-shell/../react/src/components/RemoteSlot.tsx","webpack://appshell-react-shell/../react/src/contexts/RemoteContext.tsx","webpack://appshell-react-shell/../react/src/hooks/useRemote.ts","webpack://appshell-react-shell/../react/src/index.ts","webpack://appshell-react-shell/../react/src/resources/jsonResource.ts","webpack://appshell-react-shell/../../node_modules/@module-federation/enhanced/dist/src/runtime.mjs","webpack://appshell-react-shell/../../node_modules/@module-federation/runtime-tools/dist/runtime.js"],"sourcesContent":["import remoteLoader from './remoteLoader';\n\nexport type { RemoteLoaderOptions } from './remoteLoader';\nexport * from './resolvers';\nexport * from './types';\n\nexport default remoteLoader;\n","import {\n getInstance,\n init,\n loadRemote,\n registerRemotes,\n} from '@module-federation/enhanced/runtime';\n\nconst HOST_NAME = 'Appshell';\n\n// The runtime instance and each remote's registration only need to happen once per page load.\nlet initialized = false;\nconst registeredScopes = new Set<string>();\n\nconst ensureInitialized = () => {\n if (initialized) return;\n initialized = true;\n\n // A host that ships its own ModuleFederationPlugin (e.g. @appshell/react-shell) already\n // created the global federation instance during its own bootstrap. Re-calling `init()`\n // with a different name throws (#RUNTIME-010), so reuse whatever instance already exists.\n if (getInstance()) return;\n\n init({ name: HOST_NAME, remotes: [] });\n};\n\nexport default async <TComponent>(\n scope: string,\n module: string,\n remoteEntryUrl: string,\n shareScope = 'default',\n) => {\n // eslint-disable-next-line no-console\n console.debug(\n `loading Appshell component: { scope: ${scope}, module: ${module}, shareScope: ${shareScope} }`,\n );\n\n ensureInitialized();\n\n // Registered exactly once, and never re-registered or cache-busted afterwards.\n //\n // A remote served by a dev server updates itself: its `remoteEntry` already carries\n // webpack's HMR runtime and a dev-server client, so an edit is applied in place\n // behind a container identity that does not move. Re-registering the same scope, or\n // appending a cache-busting query to its entry, changes that identity and the\n // `publicPath` derived from it mid-flight, which strands the `*.hot-update.json` and\n // `*.hot-update.js` requests the remote is midway through making.\n if (!registeredScopes.has(scope)) {\n registeredScopes.add(scope);\n registerRemotes([{ name: scope, entry: remoteEntryUrl }]);\n }\n\n // Federation ids drop the leading `./` that `exposes` keys use.\n const exposed = module.replace(/^\\.\\//, '');\n const Module = await loadRemote<{ default: TComponent }>(`${scope}/${exposed}`);\n\n if (!Module) {\n throw new Error(`Failed to find module container ${scope}`);\n }\n\n // eslint-disable-next-line no-console\n console.debug(\n `Appshell component loaded: { scope: ${scope}, module: ${module}, shareScope: ${shareScope} }`,\n );\n\n return Module.default;\n};\n","/* eslint-disable no-underscore-dangle */\nimport type { AppshellComposition } from '@appshell/config';\nimport { setVars } from '@appshell/runtime';\nimport loadAppshellComponent from './loadAppshellComponent';\nimport { chainResolvers, inlineResolver, registryResolver, type RemoteResolver } from './resolvers';\n\ndeclare global {\n interface Window {\n __appshell_config__?: AppshellComposition;\n }\n}\n\nexport type RemoteLoaderOptions = {\n composition?: AppshellComposition;\n /** Replaces the resolver chain outright; a seam for tests and embedders. */\n resolver?: RemoteResolver;\n};\n\nexport default (options: RemoteLoaderOptions = {}) => {\n const composition =\n options.composition ?? (typeof window === 'undefined' ? undefined : window.__appshell_config__);\n\n const resolve =\n options.resolver ??\n chainResolvers(inlineResolver(composition), registryResolver(composition));\n\n return async <TComponent>(key: string) => {\n const failed = (err: unknown) =>\n new Error(`Failed to load component '${key}'. ${err?.toString()}`);\n\n let resolution;\n try {\n resolution = await resolve(key);\n } catch (err) {\n throw failed(err);\n }\n\n if (!resolution) {\n throw new Error(`Remote resource not found in registry. Expected: ${key}`);\n }\n\n const { remote, vars } = resolution;\n\n try {\n // Before the remote loads, so a package that validates its vars while its modules\n // evaluate still finds them. `@appshell/runtime` is a shared singleton, so this is\n // the same store the package reads through `getVars()`.\n setVars(remote.scope, vars);\n\n const Component = await loadAppshellComponent<TComponent>(\n remote.scope,\n remote.module,\n remote.remoteEntryUrl,\n remote.shareScope,\n );\n\n return [Component, remote] as const;\n } catch (err) {\n throw failed(err);\n }\n };\n};\n","import type { AppshellComposition, ResolvedRemote } from '@appshell/config';\n\nexport type RemoteResolution = {\n remote: ResolvedRemote;\n /** Already merged with the application's overrides — nothing left for the browser to layer on. */\n vars: Record<string, string | number | undefined>;\n};\n\nexport type RemoteResolver = (key: string) => Promise<RemoteResolution | undefined>;\n\n/** The registry inlined the composition into the page, so no network call is needed. */\nexport const inlineResolver =\n (composition?: AppshellComposition): RemoteResolver =>\n async (key) => {\n const remote = composition?.remotes[key];\n if (!composition || !remote) return undefined;\n\n return {\n remote,\n vars: composition.vars[remote.scope] ?? {},\n };\n };\n\n/** Fetch-on-miss: covers a package activated after this page was served. */\nexport const registryResolver =\n (composition?: AppshellComposition, origin = ''): RemoteResolver =>\n async (key) => {\n if (!composition) return undefined;\n\n const url = `${origin}/v1/applications/${composition.applicationId}/remotes/${key}`;\n const response = await fetch(url, { credentials: 'include' });\n if (!response.ok) return undefined;\n\n const remote: ResolvedRemote = await response.json();\n\n return {\n remote,\n vars: composition.vars[remote.scope] ?? {},\n };\n };\n\nexport const chainResolvers =\n (...resolvers: RemoteResolver[]): RemoteResolver =>\n async (key) => {\n // eslint-disable-next-line no-restricted-syntax\n for (const resolve of resolvers) {\n // eslint-disable-next-line no-await-in-loop\n const resolution = await resolve(key);\n if (resolution) return resolution;\n }\n\n return undefined;\n };\n","// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport type ShareScope<TComponent = any> = Record<\n string,\n Record<string, { loaded?: 1; get: () => Promise<TComponent>; from: string; eager: boolean }>\n>;\n\nexport interface ModuleContainer<TComponent> {\n init(shareScope: ShareScope<TComponent>): Promise<void>;\n get(module: string): Promise<() => Record<string, TComponent>>;\n}\n","import { FC } from 'react';\n\ntype ErrorProps = {\n remote: string;\n reason: string;\n};\n\nconst LoadingError: FC<ErrorProps> = ({ remote, reason }) => (\n <div style={{ border: '3px solid red' }}>\n <h5>{`Error loading Appshell component '${remote}.'`}</h5>\n <span style={{ fontSize: '1rem' }}>{reason}</span>\n </div>\n);\n\nexport default LoadingError;\n","/* eslint-disable react/jsx-props-no-spreading */\nimport remoteLoader from '@appshell/loader';\nimport { ComponentType, ReactElement, ReactNode, useEffect, useState } from 'react';\nimport { RemoteProvider } from '../contexts/RemoteContext';\nimport LoadingError from './LoadingError';\n\nexport type ExtendedProps = Record<string, unknown>;\n\n// eslint-disable-next-line @typescript-eslint/no-unnecessary-type-constraint\nexport type RemoteSlotProps<TProps extends ExtendedProps = ExtendedProps> = {\n remote: string;\n fallback?: ReactNode;\n} & TProps;\n\n/**\n * Loads a remote once and leaves it alone.\n *\n * Keeping a remote current while it is being developed is not this component's job.\n * A remote served by a dev server ships webpack's HMR runtime and a dev-server client\n * inside its own `remoteEntry`, so it applies its own edits in place and React Fast\n * Refresh swaps the component implementations underneath this tree — no reload, and no\n * remount that would discard state this component never owned.\n *\n * Watching the remote's socket from here and reloading the page was strictly worse: it\n * raced the remote's own update, and it threw away the entire composed app to deliver a\n * change to one subtree. When webpack genuinely cannot apply an update, the remote's own\n * client still falls back to a full reload — which is the right place for that decision,\n * because it is the only side that knows whether the update applied.\n */\nconst RemoteSlot = <TProps extends ExtendedProps>({\n remote,\n fallback,\n ...rest\n}: RemoteSlotProps<TProps>): ReactElement<TProps> => {\n const [element, setElement] = useState<ReactElement>();\n\n useEffect(() => {\n let disposed = false;\n const loadComponent = remoteLoader();\n\n async function load() {\n try {\n const [Component, resolved] = await loadComponent<ComponentType>(remote);\n\n if (disposed || !Component) {\n return;\n }\n\n setElement(\n <RemoteProvider remote={resolved}>\n <Component {...rest} />\n </RemoteProvider>,\n );\n } catch (err) {\n if (!disposed) {\n setElement(<LoadingError remote={remote} reason={`${err}`} />);\n }\n }\n }\n\n setElement(undefined);\n load();\n\n return () => {\n disposed = true;\n };\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [remote, ...Object.values(rest)]);\n\n // eslint-disable-next-line no-console\n console.debug(`rendering RemoteSlot[${remote}], loading=${!element}`);\n // eslint-disable-next-line react/jsx-no-useless-fragment\n return <>{element || fallback}</>;\n};\n\nRemoteSlot.defaultProps = {\n fallback: undefined,\n};\n\nexport default RemoteSlot;\n","import { AppshellRemote } from '@appshell/config';\nimport type { FC, ReactNode } from 'react';\nimport { createContext } from 'react';\n\ninterface RemoteProviderProps {\n remote?: AppshellRemote;\n children: ReactNode;\n}\n\nexport const RemoteContext = createContext<AppshellRemote | undefined>(undefined);\n\nexport const RemoteProvider: FC<RemoteProviderProps> = ({ remote, children }) => (\n <RemoteContext.Provider value={remote}>{children}</RemoteContext.Provider>\n);\n\nRemoteProvider.defaultProps = {\n remote: undefined,\n};\n\nexport const RemoteConsumer = RemoteContext.Consumer;\n\nexport default RemoteContext;\n","import { AppshellRemote } from '@appshell/config';\nimport React from 'react';\n// eslint-disable-next-line import/no-named-as-default\nimport RemoteContext from '../contexts/RemoteContext';\n\n/** The remote backing the nearest `RemoteSlot` — it already knows its own key. */\nexport default (): AppshellRemote | undefined => React.useContext(RemoteContext);\n","/*\n * The wire types, re-exported so a React package needs one dependency rather than two\n * to type what RemoteSlot hands it.\n */\nexport type { AppshellIndex, AppshellRemote, Metadata } from '@appshell/runtime';\nexport { default as RemoteSlot } from './components/RemoteSlot';\nexport { RemoteProvider } from './contexts/RemoteContext';\nexport { default as useRemote } from './hooks/useRemote';\nexport { default as jsonResource } from './resources/jsonResource';\n","export default <TResource>(url: string) => {\n let status = 'pending';\n let result: TResource | Error;\n const suspender = fetch(url, {\n headers: {\n 'Content-Type': 'application/json',\n Accept: 'application/json',\n },\n // eslint-disable-next-line consistent-return\n }).then((response) => {\n if (response.ok) {\n return response.json().then((data) => {\n status = 'success';\n result = data;\n });\n }\n status = 'error';\n result = new Error(`${response.status} ${response.statusText} ${response.url}`);\n });\n\n return {\n read() {\n if (status === 'pending') {\n // eslint-disable-next-line @typescript-eslint/no-throw-literal\n throw suspender as Promise<TResource>;\n } else if (status === 'error') {\n throw result as Error;\n } else if (status === 'success') {\n return result;\n }\n\n return undefined;\n },\n };\n};\n","export * from \"@module-federation/runtime-tools/runtime\"\n\nexport { };","export * from \"@module-federation/runtime\"\n\nexport { };"],"names":["remoteLoader","getInstance","init","loadRemote","registerRemotes","HOST_NAME","initialized","registeredScopes","Set","ensureInitialized","name","remotes","scope","module","remoteEntryUrl","shareScope","console","debug","has","add","entry","exposed","replace","Module","Error","default","setVars","loadAppshellComponent","chainResolvers","inlineResolver","registryResolver","options","composition","window","undefined","__appshell_config__","resolve","resolver","key","failed","err","toString","resolution","remote","vars","Component","origin","url","applicationId","response","fetch","credentials","ok","json","resolvers","LoadingError","reason","_jsxs","style","border","children","_jsx","fontSize","useEffect","useState","RemoteProvider","jsx","Fragment","_Fragment","RemoteSlot","fallback","rest","element","setElement","disposed","loadComponent","load","resolved","Object","values","defaultProps","createContext","RemoteContext","Provider","value","RemoteConsumer","Consumer","React","useContext","useRemote","jsonResource","status","result","suspender","headers","Accept","then","data","statusText","read"],"sourceRoot":""}
|
|
@@ -211,21 +211,25 @@ __webpack_require__.r(__webpack_exports__);
|
|
|
211
211
|
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
|
|
212
212
|
/* harmony export */ "default": () => (__WEBPACK_DEFAULT_EXPORT__)
|
|
213
213
|
/* harmony export */ });
|
|
214
|
-
/* harmony import */ var
|
|
215
|
-
/* harmony import */ var
|
|
214
|
+
/* harmony import */ var react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! react/jsx-runtime */ "webpack/sharing/consume/default/react/jsx-runtime/react/jsx-runtime");
|
|
215
|
+
/* harmony import */ var react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__);
|
|
216
216
|
|
|
217
217
|
const LoadingError = ({
|
|
218
218
|
remote,
|
|
219
219
|
reason
|
|
220
|
-
}) => /*#__PURE__*/
|
|
220
|
+
}) => /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsxs)("div", {
|
|
221
221
|
style: {
|
|
222
222
|
border: '3px solid red'
|
|
223
|
-
}
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
223
|
+
},
|
|
224
|
+
children: [/*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx)("h5", {
|
|
225
|
+
children: `Error loading Appshell component '${remote}.'`
|
|
226
|
+
}), /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx)("span", {
|
|
227
|
+
style: {
|
|
228
|
+
fontSize: '1rem'
|
|
229
|
+
},
|
|
230
|
+
children: reason
|
|
231
|
+
})]
|
|
232
|
+
});
|
|
229
233
|
/* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (LoadingError);
|
|
230
234
|
|
|
231
235
|
/***/ },
|
|
@@ -245,6 +249,8 @@ __webpack_require__.r(__webpack_exports__);
|
|
|
245
249
|
/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(react__WEBPACK_IMPORTED_MODULE_1__);
|
|
246
250
|
/* harmony import */ var _contexts_RemoteContext__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../contexts/RemoteContext */ "../react/src/contexts/RemoteContext.tsx");
|
|
247
251
|
/* harmony import */ var _LoadingError__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./LoadingError */ "../react/src/components/LoadingError.tsx");
|
|
252
|
+
/* harmony import */ var react_jsx_runtime__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! react/jsx-runtime */ "webpack/sharing/consume/default/react/jsx-runtime/react/jsx-runtime");
|
|
253
|
+
/* harmony import */ var react_jsx_runtime__WEBPACK_IMPORTED_MODULE_4___default = /*#__PURE__*/__webpack_require__.n(react_jsx_runtime__WEBPACK_IMPORTED_MODULE_4__);
|
|
248
254
|
/* eslint-disable react/jsx-props-no-spreading */
|
|
249
255
|
|
|
250
256
|
|
|
@@ -283,12 +289,15 @@ const RemoteSlot = ({
|
|
|
283
289
|
if (disposed || !Component) {
|
|
284
290
|
return;
|
|
285
291
|
}
|
|
286
|
-
setElement(/*#__PURE__*/
|
|
287
|
-
remote: resolved
|
|
288
|
-
|
|
292
|
+
setElement(/*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_4__.jsx)(_contexts_RemoteContext__WEBPACK_IMPORTED_MODULE_2__.RemoteProvider, {
|
|
293
|
+
remote: resolved,
|
|
294
|
+
children: /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_4__.jsx)(Component, {
|
|
295
|
+
...rest
|
|
296
|
+
})
|
|
297
|
+
}));
|
|
289
298
|
} catch (err) {
|
|
290
299
|
if (!disposed) {
|
|
291
|
-
setElement(/*#__PURE__*/
|
|
300
|
+
setElement(/*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_4__.jsx)(_LoadingError__WEBPACK_IMPORTED_MODULE_3__["default"], {
|
|
292
301
|
remote: remote,
|
|
293
302
|
reason: `${err}`
|
|
294
303
|
}));
|
|
@@ -306,7 +315,9 @@ const RemoteSlot = ({
|
|
|
306
315
|
// eslint-disable-next-line no-console
|
|
307
316
|
console.debug(`rendering RemoteSlot[${remote}], loading=${!element}`);
|
|
308
317
|
// eslint-disable-next-line react/jsx-no-useless-fragment
|
|
309
|
-
return /*#__PURE__*/
|
|
318
|
+
return /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_4__.jsx)(react_jsx_runtime__WEBPACK_IMPORTED_MODULE_4__.Fragment, {
|
|
319
|
+
children: element || fallback
|
|
320
|
+
});
|
|
310
321
|
};
|
|
311
322
|
RemoteSlot.defaultProps = {
|
|
312
323
|
fallback: undefined
|
|
@@ -330,14 +341,18 @@ __webpack_require__.r(__webpack_exports__);
|
|
|
330
341
|
/* harmony export */ });
|
|
331
342
|
/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! react */ "webpack/sharing/consume/default/react/react");
|
|
332
343
|
/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(react__WEBPACK_IMPORTED_MODULE_0__);
|
|
344
|
+
/* harmony import */ var react_jsx_runtime__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! react/jsx-runtime */ "webpack/sharing/consume/default/react/jsx-runtime/react/jsx-runtime");
|
|
345
|
+
/* harmony import */ var react_jsx_runtime__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(react_jsx_runtime__WEBPACK_IMPORTED_MODULE_1__);
|
|
346
|
+
|
|
333
347
|
|
|
334
348
|
const RemoteContext = /*#__PURE__*/(0,react__WEBPACK_IMPORTED_MODULE_0__.createContext)(undefined);
|
|
335
349
|
const RemoteProvider = ({
|
|
336
350
|
remote,
|
|
337
351
|
children
|
|
338
|
-
}) => /*#__PURE__*/
|
|
339
|
-
value: remote
|
|
340
|
-
|
|
352
|
+
}) => /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_1__.jsx)(RemoteContext.Provider, {
|
|
353
|
+
value: remote,
|
|
354
|
+
children: children
|
|
355
|
+
});
|
|
341
356
|
RemoteProvider.defaultProps = {
|
|
342
357
|
remote: undefined
|
|
343
358
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"react_src_index_ts-_f7a71.js","mappings":";;;;;;;;;;;;;;;;;;;AAA0C;AAGd;AACJ;AAExB,iEAAeA,qDAAY,E;;;;;;;;;;;;;;;ACDkB;AAE7C,MAAMK,SAAS,GAAG,UAAU;;AAE5B;AACA,IAAIC,WAAW,GAAG,KAAK;AACvB,MAAMC,gBAAgB,GAAG,IAAIC,GAAG,CAAS,CAAC;AAE1C,MAAMC,iBAAiB,GAAGA,CAAA,KAAM;EAC9B,IAAIH,WAAW,EAAE;EACjBA,WAAW,GAAG,IAAI;;EAElB;EACA;EACA;EACA,IAAIL,gFAAW,CAAC,CAAC,EAAE;EAEnBC,yEAAI,CAAC;IAAEQ,IAAI,EAAEL,SAAS;IAAEM,OAAO,EAAE;EAAG,CAAC,CAAC;AACxC,CAAC;AAED,iEAAe,OACbC,KAAa,EACbC,MAAc,EACdC,cAAsB,EACtBC,UAAU,GAAG,SAAS,KACnB;EACH;EACAC,OAAO,CAACC,KAAK,CACX,wCAAwCL,KAAK,aAAaC,MAAM,iBAAiBE,UAAU,IAC7F,CAAC;EAE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E;QACxB;QACA,MAAME,SAAS;MACjB,CAAC,MAAM,IAAIF,MAAM,KAAK,OAAO,EAAE;QAC7B,MAAMC,MAAM;MACd,CAAC,MAAM,IAAID,MAAM,KAAK,SAAS,EAAE;QAC/B,OAAOC,MAAM;MACf;MAEA,OAAOvD,SAAS;IAClB;EACF,CAAC;AACH,CAAC;AAAA,4L;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AClCuD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;ACAd","sources":["webpack://appshell-react-shell/../loader/src/index.ts","webpack://appshell-react-shell/../loader/src/loadAppshellComponent.ts","webpack://appshell-react-shell/../loader/src/remoteLoader.ts","webpack://appshell-react-shell/../loader/src/resolvers.ts","webpack://appshell-react-shell/../react/src/components/LoadingError.tsx","webpack://appshell-react-shell/../react/src/components/RemoteSlot.tsx","webpack://appshell-react-shell/../react/src/contexts/RemoteContext.tsx","webpack://appshell-react-shell/../react/src/hooks/useRemote.ts","webpack://appshell-react-shell/../react/src/index.ts","webpack://appshell-react-shell/../react/src/resources/jsonResource.ts","webpack://appshell-react-shell/../../node_modules/@module-federation/enhanced/dist/src/runtime.mjs","webpack://appshell-react-shell/../../node_modules/@module-federation/runtime-tools/dist/runtime.js"],"sourcesContent":["import remoteLoader from './remoteLoader';\n\nexport type { RemoteLoaderOptions } from './remoteLoader';\nexport * from './resolvers';\nexport * from './types';\n\nexport default remoteLoader;\n","import {\n getInstance,\n init,\n loadRemote,\n registerRemotes,\n} from '@module-federation/enhanced/runtime';\n\nconst HOST_NAME = 'Appshell';\n\n// The runtime instance and each remote's registration only need to happen once per page load.\nlet initialized = false;\nconst registeredScopes = new Set<string>();\n\nconst ensureInitialized = () => {\n if (initialized) return;\n initialized = true;\n\n // A host that ships its own ModuleFederationPlugin (e.g. @appshell/react-shell) already\n // created the global federation instance during its own bootstrap. Re-calling `init()`\n // with a different name throws (#RUNTIME-010), so reuse whatever instance already exists.\n if (getInstance()) return;\n\n init({ name: HOST_NAME, remotes: [] });\n};\n\nexport default async <TComponent>(\n scope: string,\n module: string,\n remoteEntryUrl: string,\n shareScope = 'default',\n) => {\n // eslint-disable-next-line no-console\n console.debug(\n `loading Appshell component: { scope: ${scope}, module: ${module}, shareScope: ${shareScope} }`,\n );\n\n ensureInitialized();\n\n // Registered exactly once, and never re-registered or cache-busted afterwards.\n //\n // A remote served by a dev server updates itself: its `remoteEntry` already carries\n // webpack's HMR runtime and a dev-server client, so an edit is applied in place\n // behind a container identity that does not move. Re-registering the same scope, or\n // appending a cache-busting query to its entry, changes that identity and the\n // `publicPath` derived from it mid-flight, which strands the `*.hot-update.json` and\n // `*.hot-update.js` requests the remote is midway through making.\n if (!registeredScopes.has(scope)) {\n registeredScopes.add(scope);\n registerRemotes([{ name: scope, entry: remoteEntryUrl }]);\n }\n\n // Federation ids drop the leading `./` that `exposes` keys use.\n const exposed = module.replace(/^\\.\\//, '');\n const Module = await loadRemote<{ default: TComponent }>(`${scope}/${exposed}`);\n\n if (!Module) {\n throw new Error(`Failed to find module container ${scope}`);\n }\n\n // eslint-disable-next-line no-console\n console.debug(\n `Appshell component loaded: { scope: ${scope}, module: ${module}, shareScope: ${shareScope} }`,\n );\n\n return Module.default;\n};\n","/* eslint-disable no-underscore-dangle */\nimport type { AppshellComposition } from '@appshell/config';\nimport { setVars } from '@appshell/runtime';\nimport loadAppshellComponent from './loadAppshellComponent';\nimport { chainResolvers, inlineResolver, registryResolver, type RemoteResolver } from './resolvers';\n\ndeclare global {\n interface Window {\n __appshell_config__?: AppshellComposition;\n }\n}\n\nexport type RemoteLoaderOptions = {\n composition?: AppshellComposition;\n /** Replaces the resolver chain outright; a seam for tests and embedders. */\n resolver?: RemoteResolver;\n};\n\nexport default (options: RemoteLoaderOptions = {}) => {\n const composition =\n options.composition ?? (typeof window === 'undefined' ? undefined : window.__appshell_config__);\n\n const resolve =\n options.resolver ??\n chainResolvers(inlineResolver(composition), registryResolver(composition));\n\n return async <TComponent>(key: string) => {\n const failed = (err: unknown) =>\n new Error(`Failed to load component '${key}'. ${err?.toString()}`);\n\n let resolution;\n try {\n resolution = await resolve(key);\n } catch (err) {\n throw failed(err);\n }\n\n if (!resolution) {\n throw new Error(`Remote resource not found in registry. Expected: ${key}`);\n }\n\n const { remote, vars } = resolution;\n\n try {\n // Before the remote loads, so a package that validates its vars while its modules\n // evaluate still finds them. `@appshell/runtime` is a shared singleton, so this is\n // the same store the package reads through `getVars()`.\n setVars(remote.scope, vars);\n\n const Component = await loadAppshellComponent<TComponent>(\n remote.scope,\n remote.module,\n remote.remoteEntryUrl,\n remote.shareScope,\n );\n\n return [Component, remote] as const;\n } catch (err) {\n throw failed(err);\n }\n };\n};\n","import type { AppshellComposition, ResolvedRemote } from '@appshell/config';\n\nexport type RemoteResolution = {\n remote: ResolvedRemote;\n /** Already merged with the application's overrides — nothing left for the browser to layer on. */\n vars: Record<string, string | number | undefined>;\n};\n\nexport type RemoteResolver = (key: string) => Promise<RemoteResolution | undefined>;\n\n/** The registry inlined the composition into the page, so no network call is needed. */\nexport const inlineResolver =\n (composition?: AppshellComposition): RemoteResolver =>\n async (key) => {\n const remote = composition?.remotes[key];\n if (!composition || !remote) return undefined;\n\n return {\n remote,\n vars: composition.vars[remote.scope] ?? {},\n };\n };\n\n/** Fetch-on-miss: covers a package activated after this page was served. */\nexport const registryResolver =\n (composition?: AppshellComposition, origin = ''): RemoteResolver =>\n async (key) => {\n if (!composition) return undefined;\n\n const url = `${origin}/v1/applications/${composition.applicationId}/remotes/${key}`;\n const response = await fetch(url, { credentials: 'include' });\n if (!response.ok) return undefined;\n\n const remote: ResolvedRemote = await response.json();\n\n return {\n remote,\n vars: composition.vars[remote.scope] ?? {},\n };\n };\n\nexport const chainResolvers =\n (...resolvers: RemoteResolver[]): RemoteResolver =>\n async (key) => {\n // eslint-disable-next-line no-restricted-syntax\n for (const resolve of resolvers) {\n // eslint-disable-next-line no-await-in-loop\n const resolution = await resolve(key);\n if (resolution) return resolution;\n }\n\n return undefined;\n };\n","import React, { FC } from 'react';\n\ntype ErrorProps = {\n remote: string;\n reason: string;\n};\n\nconst LoadingError: FC<ErrorProps> = ({ remote, reason }) => (\n <div style={{ border: '3px solid red' }}>\n <h5>{`Error loading Appshell component '${remote}.'`}</h5>\n <span style={{ fontSize: '1rem' }}>{reason}</span>\n </div>\n);\n\nexport default LoadingError;\n","/* eslint-disable react/jsx-props-no-spreading */\nimport remoteLoader from '@appshell/loader';\nimport React, { ComponentType, ReactElement, ReactNode, useEffect, useState } from 'react';\nimport { RemoteProvider } from '../contexts/RemoteContext';\nimport LoadingError from './LoadingError';\n\nexport type ExtendedProps = Record<string, unknown>;\n\n// eslint-disable-next-line @typescript-eslint/no-unnecessary-type-constraint\nexport type RemoteSlotProps<TProps extends ExtendedProps = ExtendedProps> = {\n remote: string;\n fallback?: ReactNode;\n} & TProps;\n\n/**\n * Loads a remote once and leaves it alone.\n *\n * Keeping a remote current while it is being developed is not this component's job.\n * A remote served by a dev server ships webpack's HMR runtime and a dev-server client\n * inside its own `remoteEntry`, so it applies its own edits in place and React Fast\n * Refresh swaps the component implementations underneath this tree — no reload, and no\n * remount that would discard state this component never owned.\n *\n * Watching the remote's socket from here and reloading the page was strictly worse: it\n * raced the remote's own update, and it threw away the entire composed app to deliver a\n * change to one subtree. When webpack genuinely cannot apply an update, the remote's own\n * client still falls back to a full reload — which is the right place for that decision,\n * because it is the only side that knows whether the update applied.\n */\nconst RemoteSlot = <TProps extends ExtendedProps>({\n remote,\n fallback,\n ...rest\n}: RemoteSlotProps<TProps>): ReactElement<TProps> => {\n const [element, setElement] = useState<ReactElement>();\n\n useEffect(() => {\n let disposed = false;\n const loadComponent = remoteLoader();\n\n async function load() {\n try {\n const [Component, resolved] = await loadComponent<ComponentType>(remote);\n\n if (disposed || !Component) {\n return;\n }\n\n setElement(\n <RemoteProvider remote={resolved}>\n <Component {...rest} />\n </RemoteProvider>,\n );\n } catch (err) {\n if (!disposed) {\n setElement(<LoadingError remote={remote} reason={`${err}`} />);\n }\n }\n }\n\n setElement(undefined);\n load();\n\n return () => {\n disposed = true;\n };\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [remote, ...Object.values(rest)]);\n\n // eslint-disable-next-line no-console\n console.debug(`rendering RemoteSlot[${remote}], loading=${!element}`);\n // eslint-disable-next-line react/jsx-no-useless-fragment\n return <>{element || fallback}</>;\n};\n\nRemoteSlot.defaultProps = {\n fallback: undefined,\n};\n\nexport default RemoteSlot;\n","import { AppshellRemote } from '@appshell/config';\nimport type { FC, ReactNode } from 'react';\nimport React, { createContext } from 'react';\n\ninterface RemoteProviderProps {\n remote?: AppshellRemote;\n children: ReactNode;\n}\n\nexport const RemoteContext = createContext<AppshellRemote | undefined>(undefined);\n\nexport const RemoteProvider: FC<RemoteProviderProps> = ({ remote, children }) => (\n <RemoteContext.Provider value={remote}>{children}</RemoteContext.Provider>\n);\n\nRemoteProvider.defaultProps = {\n remote: undefined,\n};\n\nexport const RemoteConsumer = RemoteContext.Consumer;\n\nexport default RemoteContext;\n","import { AppshellRemote } from '@appshell/config';\nimport React from 'react';\n// eslint-disable-next-line import/no-named-as-default\nimport RemoteContext from '../contexts/RemoteContext';\n\n/** The remote backing the nearest `RemoteSlot` — it already knows its own key. */\nexport default (): AppshellRemote | undefined => React.useContext(RemoteContext);\n","/*\n * The wire types, re-exported so a React package needs one dependency rather than two\n * to type what RemoteSlot hands it.\n */\nexport type { AppshellIndex, AppshellRemote, Metadata } from '@appshell/runtime';\nexport { default as RemoteSlot } from './components/RemoteSlot';\nexport { RemoteProvider } from './contexts/RemoteContext';\nexport { default as useRemote } from './hooks/useRemote';\nexport { default as jsonResource } from './resources/jsonResource';\n","export default <TResource>(url: string) => {\n let status = 'pending';\n let result: TResource | Error;\n const suspender = fetch(url, {\n headers: {\n 'Content-Type': 'application/json',\n Accept: 'application/json',\n },\n // eslint-disable-next-line consistent-return\n }).then((response) => {\n if (response.ok) {\n return response.json().then((data) => {\n status = 'success';\n result = data;\n });\n }\n status = 'error';\n result = new Error(`${response.status} ${response.statusText} ${response.url}`);\n });\n\n return {\n read() {\n if (status === 'pending') {\n // eslint-disable-next-line @typescript-eslint/no-throw-literal\n throw suspender as Promise<TResource>;\n } else if (status === 'error') {\n throw result as Error;\n } else if (status === 'success') {\n return result;\n }\n\n return undefined;\n },\n };\n};\n","export * from \"@module-federation/runtime-tools/runtime\"\n\nexport { };","export * from \"@module-federation/runtime\"\n\nexport { };"],"names":["remoteLoader","getInstance","init","loadRemote","registerRemotes","HOST_NAME","initialized","registeredScopes","Set","ensureInitialized","name","remotes","scope","module","remoteEntryUrl","shareScope","console","debug","has","add","entry","exposed","replace","Module","Error","default","setVars","loadAppshellComponent","chainResolvers","inlineResolver","registryResolver","options","composition","window","undefined","__appshell_config__","resolve","resolver","key","failed","err","toString","resolution","remote","vars","Component","origin","url","applicationId","response","fetch","credentials","ok","json","resolvers","React","LoadingError","reason","createElement","style","border","fontSize","useEffect","useState","RemoteProvider","RemoteSlot","fallback","rest","element","setElement","disposed","loadComponent","load","resolved","Object","values","Fragment","defaultProps","createContext","RemoteContext","children","Provider","value","RemoteConsumer","Consumer","useContext","useRemote","jsonResource","status","result","suspender","headers","Accept","then","data","statusText","read"],"sourceRoot":""}
|
|
1
|
+
{"version":3,"file":"react_src_index_ts-_f7a71.js","mappings":";;;;;;;;;;;;;;;;;;;AAA0C;AAGd;AACJ;AAExB,iEAAeA,qDAAY,E;;;;;;;;;;;;;;;ACDkB;AAE7C,MAAMK,SAAS,GAAG,UAAU;;AAE5B;AACA,IAAIC,WAAW,GAAG,KAAK;AACvB,MAAMC,gBAAgB,GAAG,IAAIC,GAAG,CAAS,CAAC;AAE1C,MAAMC,iBAAiB,GAAGA,CAAA,KAAM;EAC9B,IAAIH,WAAW,EAAE;EACjBA,WAAW,GAAG,IAAI;;EAElB;EACA;EACA;EACA,IAAIL,gFAAW,CAAC,CAAC,EAAE;EAEnBC,yEAAI,CAAC;IAAEQ,IAAI,EAAEL,SAAS;IAAEM,OAAO,EA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2C,IAAI,CAAEC,IAAI,IAAK;QACpCN,MAAM,GAAG,SAAS;QAClBC,MAAM,GAAGK,IAAI;MACf,CAAC,CAAC;IACJ;IACAN,MAAM,GAAG,OAAO;IAChBC,MAAM,GAAG,IAAIpE,KAAK,CAAC,GAAGyB,QAAQ,CAAC0C,MAAM,IAAI1C,QAAQ,CAACiD,UAAU,IAAIjD,QAAQ,CAACF,GAAG,EAAE,CAAC;EACjF,CAAC,CAAC;EAEF,OAAO;IACLoD,IAAIA,CAAA,EAAG;MACL,IAAIR,MAAM,KAAK,SAAS,EAAE;QACxB;QACA,MAAME,SAAS;MACjB,CAAC,MAAM,IAAIF,MAAM,KAAK,OAAO,EAAE;QAC7B,MAAMC,MAAM;MACd,CAAC,MAAM,IAAID,MAAM,KAAK,SAAS,EAAE;QAC/B,OAAOC,MAAM;MACf;MAEA,OAAO1D,SAAS;IAClB;EACF,CAAC;AACH,CAAC;AAAA,4L;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AClCuD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;ACAd","sources":["webpack://appshell-react-shell/../loader/src/index.ts","webpack://appshell-react-shell/../loader/src/loadAppshellComponent.ts","webpack://appshell-react-shell/../loader/src/remoteLoader.ts","webpack://appshell-react-shell/../loader/src/resolvers.ts","webpack://appshell-react-shell/../react/src/components/LoadingError.tsx","webpack://appshell-react-shell/../react/src/components/RemoteSlot.tsx","webpack://appshell-react-shell/../react/src/contexts/RemoteContext.tsx","webpack://appshell-react-shell/../react/src/hooks/useRemote.ts","webpack://appshell-react-shell/../react/src/index.ts","webpack://appshell-react-shell/../react/src/resources/jsonResource.ts","webpack://appshell-react-shell/../../node_modules/@module-federation/enhanced/dist/src/runtime.mjs","webpack://appshell-react-shell/../../node_modules/@module-federation/runtime-tools/dist/runtime.js"],"sourcesContent":["import remoteLoader from './remoteLoader';\n\nexport type { RemoteLoaderOptions } from './remoteLoader';\nexport * from './resolvers';\nexport * from './types';\n\nexport default remoteLoader;\n","import {\n getInstance,\n init,\n loadRemote,\n registerRemotes,\n} from '@module-federation/enhanced/runtime';\n\nconst HOST_NAME = 'Appshell';\n\n// The runtime instance and each remote's registration only need to happen once per page load.\nlet initialized = false;\nconst registeredScopes = new Set<string>();\n\nconst ensureInitialized = () => {\n if (initialized) return;\n initialized = true;\n\n // A host that ships its own ModuleFederationPlugin (e.g. @appshell/react-shell) already\n // created the global federation instance during its own bootstrap. Re-calling `init()`\n // with a different name throws (#RUNTIME-010), so reuse whatever instance already exists.\n if (getInstance()) return;\n\n init({ name: HOST_NAME, remotes: [] });\n};\n\nexport default async <TComponent>(\n scope: string,\n module: string,\n remoteEntryUrl: string,\n shareScope = 'default',\n) => {\n // eslint-disable-next-line no-console\n console.debug(\n `loading Appshell component: { scope: ${scope}, module: ${module}, shareScope: ${shareScope} }`,\n );\n\n ensureInitialized();\n\n // Registered exactly once, and never re-registered or cache-busted afterwards.\n //\n // A remote served by a dev server updates itself: its `remoteEntry` already carries\n // webpack's HMR runtime and a dev-server client, so an edit is applied in place\n // behind a container identity that does not move. Re-registering the same scope, or\n // appending a cache-busting query to its entry, changes that identity and the\n // `publicPath` derived from it mid-flight, which strands the `*.hot-update.json` and\n // `*.hot-update.js` requests the remote is midway through making.\n if (!registeredScopes.has(scope)) {\n registeredScopes.add(scope);\n registerRemotes([{ name: scope, entry: remoteEntryUrl }]);\n }\n\n // Federation ids drop the leading `./` that `exposes` keys use.\n const exposed = module.replace(/^\\.\\//, '');\n const Module = await loadRemote<{ default: TComponent }>(`${scope}/${exposed}`);\n\n if (!Module) {\n throw new Error(`Failed to find module container ${scope}`);\n }\n\n // eslint-disable-next-line no-console\n console.debug(\n `Appshell component loaded: { scope: ${scope}, module: ${module}, shareScope: ${shareScope} }`,\n );\n\n return Module.default;\n};\n","/* eslint-disable no-underscore-dangle */\nimport type { AppshellComposition } from '@appshell/config';\nimport { setVars } from '@appshell/runtime';\nimport loadAppshellComponent from './loadAppshellComponent';\nimport { chainResolvers, inlineResolver, registryResolver, type RemoteResolver } from './resolvers';\n\ndeclare global {\n interface Window {\n __appshell_config__?: AppshellComposition;\n }\n}\n\nexport type RemoteLoaderOptions = {\n composition?: AppshellComposition;\n /** Replaces the resolver chain outright; a seam for tests and embedders. */\n resolver?: RemoteResolver;\n};\n\nexport default (options: RemoteLoaderOptions = {}) => {\n const composition =\n options.composition ?? (typeof window === 'undefined' ? undefined : window.__appshell_config__);\n\n const resolve =\n options.resolver ??\n chainResolvers(inlineResolver(composition), registryResolver(composition));\n\n return async <TComponent>(key: string) => {\n const failed = (err: unknown) =>\n new Error(`Failed to load component '${key}'. ${err?.toString()}`);\n\n let resolution;\n try {\n resolution = await resolve(key);\n } catch (err) {\n throw failed(err);\n }\n\n if (!resolution) {\n throw new Error(`Remote resource not found in registry. Expected: ${key}`);\n }\n\n const { remote, vars } = resolution;\n\n try {\n // Before the remote loads, so a package that validates its vars while its modules\n // evaluate still finds them. `@appshell/runtime` is a shared singleton, so this is\n // the same store the package reads through `getVars()`.\n setVars(remote.scope, vars);\n\n const Component = await loadAppshellComponent<TComponent>(\n remote.scope,\n remote.module,\n remote.remoteEntryUrl,\n remote.shareScope,\n );\n\n return [Component, remote] as const;\n } catch (err) {\n throw failed(err);\n }\n };\n};\n","import type { AppshellComposition, ResolvedRemote } from '@appshell/config';\n\nexport type RemoteResolution = {\n remote: ResolvedRemote;\n /** Already merged with the application's overrides — nothing left for the browser to layer on. */\n vars: Record<string, string | number | undefined>;\n};\n\nexport type RemoteResolver = (key: string) => Promise<RemoteResolution | undefined>;\n\n/** The registry inlined the composition into the page, so no network call is needed. */\nexport const inlineResolver =\n (composition?: AppshellComposition): RemoteResolver =>\n async (key) => {\n const remote = composition?.remotes[key];\n if (!composition || !remote) return undefined;\n\n return {\n remote,\n vars: composition.vars[remote.scope] ?? {},\n };\n };\n\n/** Fetch-on-miss: covers a package activated after this page was served. */\nexport const registryResolver =\n (composition?: AppshellComposition, origin = ''): RemoteResolver =>\n async (key) => {\n if (!composition) return undefined;\n\n const url = `${origin}/v1/applications/${composition.applicationId}/remotes/${key}`;\n const response = await fetch(url, { credentials: 'include' });\n if (!response.ok) return undefined;\n\n const remote: ResolvedRemote = await response.json();\n\n return {\n remote,\n vars: composition.vars[remote.scope] ?? {},\n };\n };\n\nexport const chainResolvers =\n (...resolvers: RemoteResolver[]): RemoteResolver =>\n async (key) => {\n // eslint-disable-next-line no-restricted-syntax\n for (const resolve of resolvers) {\n // eslint-disable-next-line no-await-in-loop\n const resolution = await resolve(key);\n if (resolution) return resolution;\n }\n\n return undefined;\n };\n","import { FC } from 'react';\n\ntype ErrorProps = {\n remote: string;\n reason: string;\n};\n\nconst LoadingError: FC<ErrorProps> = ({ remote, reason }) => (\n <div style={{ border: '3px solid red' }}>\n <h5>{`Error loading Appshell component '${remote}.'`}</h5>\n <span style={{ fontSize: '1rem' }}>{reason}</span>\n </div>\n);\n\nexport default LoadingError;\n","/* eslint-disable react/jsx-props-no-spreading */\nimport remoteLoader from '@appshell/loader';\nimport { ComponentType, ReactElement, ReactNode, useEffect, useState } from 'react';\nimport { RemoteProvider } from '../contexts/RemoteContext';\nimport LoadingError from './LoadingError';\n\nexport type ExtendedProps = Record<string, unknown>;\n\n// eslint-disable-next-line @typescript-eslint/no-unnecessary-type-constraint\nexport type RemoteSlotProps<TProps extends ExtendedProps = ExtendedProps> = {\n remote: string;\n fallback?: ReactNode;\n} & TProps;\n\n/**\n * Loads a remote once and leaves it alone.\n *\n * Keeping a remote current while it is being developed is not this component's job.\n * A remote served by a dev server ships webpack's HMR runtime and a dev-server client\n * inside its own `remoteEntry`, so it applies its own edits in place and React Fast\n * Refresh swaps the component implementations underneath this tree — no reload, and no\n * remount that would discard state this component never owned.\n *\n * Watching the remote's socket from here and reloading the page was strictly worse: it\n * raced the remote's own update, and it threw away the entire composed app to deliver a\n * change to one subtree. When webpack genuinely cannot apply an update, the remote's own\n * client still falls back to a full reload — which is the right place for that decision,\n * because it is the only side that knows whether the update applied.\n */\nconst RemoteSlot = <TProps extends ExtendedProps>({\n remote,\n fallback,\n ...rest\n}: RemoteSlotProps<TProps>): ReactElement<TProps> => {\n const [element, setElement] = useState<ReactElement>();\n\n useEffect(() => {\n let disposed = false;\n const loadComponent = remoteLoader();\n\n async function load() {\n try {\n const [Component, resolved] = await loadComponent<ComponentType>(remote);\n\n if (disposed || !Component) {\n return;\n }\n\n setElement(\n <RemoteProvider remote={resolved}>\n <Component {...rest} />\n </RemoteProvider>,\n );\n } catch (err) {\n if (!disposed) {\n setElement(<LoadingError remote={remote} reason={`${err}`} />);\n }\n }\n }\n\n setElement(undefined);\n load();\n\n return () => {\n disposed = true;\n };\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [remote, ...Object.values(rest)]);\n\n // eslint-disable-next-line no-console\n console.debug(`rendering RemoteSlot[${remote}], loading=${!element}`);\n // eslint-disable-next-line react/jsx-no-useless-fragment\n return <>{element || fallback}</>;\n};\n\nRemoteSlot.defaultProps = {\n fallback: undefined,\n};\n\nexport default RemoteSlot;\n","import { AppshellRemote } from '@appshell/config';\nimport type { FC, ReactNode } from 'react';\nimport { createContext } from 'react';\n\ninterface RemoteProviderProps {\n remote?: AppshellRemote;\n children: ReactNode;\n}\n\nexport const RemoteContext = createContext<AppshellRemote | undefined>(undefined);\n\nexport const RemoteProvider: FC<RemoteProviderProps> = ({ remote, children }) => (\n <RemoteContext.Provider value={remote}>{children}</RemoteContext.Provider>\n);\n\nRemoteProvider.defaultProps = {\n remote: undefined,\n};\n\nexport const RemoteConsumer = RemoteContext.Consumer;\n\nexport default RemoteContext;\n","import { AppshellRemote } from '@appshell/config';\nimport React from 'react';\n// eslint-disable-next-line import/no-named-as-default\nimport RemoteContext from '../contexts/RemoteContext';\n\n/** The remote backing the nearest `RemoteSlot` — it already knows its own key. */\nexport default (): AppshellRemote | undefined => React.useContext(RemoteContext);\n","/*\n * The wire types, re-exported so a React package needs one dependency rather than two\n * to type what RemoteSlot hands it.\n */\nexport type { AppshellIndex, AppshellRemote, Metadata } from '@appshell/runtime';\nexport { default as RemoteSlot } from './components/RemoteSlot';\nexport { RemoteProvider } from './contexts/RemoteContext';\nexport { default as useRemote } from './hooks/useRemote';\nexport { default as jsonResource } from './resources/jsonResource';\n","export default <TResource>(url: string) => {\n let status = 'pending';\n let result: TResource | Error;\n const suspender = fetch(url, {\n headers: {\n 'Content-Type': 'application/json',\n Accept: 'application/json',\n },\n // eslint-disable-next-line consistent-return\n }).then((response) => {\n if (response.ok) {\n return response.json().then((data) => {\n status = 'success';\n result = data;\n });\n }\n status = 'error';\n result = new Error(`${response.status} ${response.statusText} ${response.url}`);\n });\n\n return {\n read() {\n if (status === 'pending') {\n // eslint-disable-next-line @typescript-eslint/no-throw-literal\n throw suspender as Promise<TResource>;\n } else if (status === 'error') {\n throw result as Error;\n } else if (status === 'success') {\n return result;\n }\n\n return undefined;\n },\n };\n};\n","export * from \"@module-federation/runtime-tools/runtime\"\n\nexport { };","export * from \"@module-federation/runtime\"\n\nexport { };"],"names":["remoteLoader","getInstance","init","loadRemote","registerRemotes","HOST_NAME","initialized","registeredScopes","Set","ensureInitialized","name","remotes","scope","module","remoteEntryUrl","shareScope","console","debug","has","add","entry","exposed","replace","Module","Error","default","setVars","loadAppshellComponent","chainResolvers","inlineResolver","registryResolver","options","composition","window","undefined","__appshell_config__","resolve","resolver","key","failed","err","toString","resolution","remote","vars","Component","origin","url","applicationId","response","fetch","credentials","ok","json","resolvers","LoadingError","reason","_jsxs","style","border","children","_jsx","fontSize","useEffect","useState","RemoteProvider","jsx","Fragment","_Fragment","RemoteSlot","fallback","rest","element","setElement","disposed","loadComponent","load","resolved","Object","values","defaultProps","createContext","RemoteContext","Provider","value","RemoteConsumer","Consumer","React","useContext","useRemote","jsonResource","status","result","suspender","headers","Accept","then","data","statusText","read"],"sourceRoot":""}
|
|
@@ -15,7 +15,8 @@ __webpack_require__.r(__webpack_exports__);
|
|
|
15
15
|
/* harmony import */ var _overlayBadge__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./overlayBadge */ "./src/overlayBadge.ts");
|
|
16
16
|
/* harmony import */ var _reset_css__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./reset.css */ "./src/reset.css");
|
|
17
17
|
/* harmony import */ var _splash__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./splash */ "./src/splash.ts");
|
|
18
|
-
|
|
18
|
+
/* harmony import */ var react_jsx_runtime__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! react/jsx-runtime */ "webpack/sharing/consume/default/react/jsx-runtime/react/jsx-runtime");
|
|
19
|
+
/* harmony import */ var react_jsx_runtime__WEBPACK_IMPORTED_MODULE_6___default = /*#__PURE__*/__webpack_require__.n(react_jsx_runtime__WEBPACK_IMPORTED_MODULE_6__);
|
|
19
20
|
/* eslint-disable react/jsx-props-no-spreading */
|
|
20
21
|
|
|
21
22
|
|
|
@@ -23,6 +24,7 @@ function _extends() { return _extends = Object.assign ? Object.assign.bind() : f
|
|
|
23
24
|
|
|
24
25
|
|
|
25
26
|
|
|
27
|
+
|
|
26
28
|
const container = document.getElementById('root');
|
|
27
29
|
const root = (0,react_dom_client__WEBPACK_IMPORTED_MODULE_2__.createRoot)(container);
|
|
28
30
|
|
|
@@ -41,9 +43,12 @@ const props = composition.rootProps;
|
|
|
41
43
|
// the registry served — it has to be, because the thing being waited for is the package's
|
|
42
44
|
// own code, and this bundle is fetched before it. All the shell does is take it away.
|
|
43
45
|
(0,_splash__WEBPACK_IMPORTED_MODULE_5__["default"])(container);
|
|
44
|
-
root.render(/*#__PURE__*/
|
|
45
|
-
|
|
46
|
-
|
|
46
|
+
root.render(/*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_6__.jsx)((react__WEBPACK_IMPORTED_MODULE_1___default().StrictMode), {
|
|
47
|
+
children: /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_6__.jsx)(_appshell_react__WEBPACK_IMPORTED_MODULE_0__.RemoteSlot, {
|
|
48
|
+
remote: remote,
|
|
49
|
+
...props
|
|
50
|
+
})
|
|
51
|
+
}));
|
|
47
52
|
|
|
48
53
|
/***/ },
|
|
49
54
|
|