@appshell/react-shell 1.0.0-alpha.64 → 1.0.0-alpha.66

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.
@@ -5,7 +5,7 @@
5
5
  "name": "Appshell",
6
6
  "type": "app",
7
7
  "buildInfo": {
8
- "buildVersion": "1.0.0-alpha.64",
8
+ "buildVersion": "1.0.0-alpha.66",
9
9
  "buildName": "@appshell/react-shell"
10
10
  },
11
11
  "remoteEntry": {
@@ -27,15 +27,14 @@
27
27
  {
28
28
  "id": "Appshell:@appshell/react",
29
29
  "name": "@appshell/react",
30
- "version": "1.0.0-alpha.64",
30
+ "version": "1.0.0-alpha.66",
31
31
  "singleton": true,
32
- "requiredVersion": "^1.0.0-alpha.64",
32
+ "requiredVersion": "^1.0.0-alpha.66",
33
33
  "assets": {
34
34
  "js": {
35
35
  "async": [],
36
36
  "sync": [
37
- "react_src_index_ts-_f7a70.js",
38
- "react_src_index_ts-_f7a71.js"
37
+ "react_src_index_ts.js"
39
38
  ]
40
39
  },
41
40
  "css": {
@@ -48,9 +47,9 @@
48
47
  {
49
48
  "id": "Appshell:@appshell/runtime",
50
49
  "name": "@appshell/runtime",
51
- "version": "1.0.0-alpha.64",
50
+ "version": "1.0.0-alpha.66",
52
51
  "singleton": true,
53
- "requiredVersion": "^1.0.0-alpha.64",
52
+ "requiredVersion": "^1.0.0-alpha.66",
54
53
  "assets": {
55
54
  "js": {
56
55
  "async": [],
@@ -5,7 +5,7 @@
5
5
  "name": "Appshell",
6
6
  "type": "app",
7
7
  "buildInfo": {
8
- "buildVersion": "1.0.0-alpha.64",
8
+ "buildVersion": "1.0.0-alpha.66",
9
9
  "buildName": "@appshell/react-shell"
10
10
  },
11
11
  "remoteEntry": {
@@ -26,18 +26,17 @@
26
26
  "shared": [
27
27
  {
28
28
  "singleton": true,
29
- "requiredVersion": "^1.0.0-alpha.64",
29
+ "requiredVersion": "^1.0.0-alpha.66",
30
30
  "shareScope": "default",
31
31
  "name": "@appshell/react",
32
- "version": "1.0.0-alpha.64",
32
+ "version": "1.0.0-alpha.66",
33
33
  "eager": false,
34
34
  "id": "Appshell:@appshell/react",
35
35
  "assets": {
36
36
  "js": {
37
37
  "async": [],
38
38
  "sync": [
39
- "react_src_index_ts-_f7a70.js",
40
- "react_src_index_ts-_f7a71.js"
39
+ "react_src_index_ts.js"
41
40
  ]
42
41
  },
43
42
  "css": {
@@ -51,10 +50,10 @@
51
50
  },
52
51
  {
53
52
  "singleton": true,
54
- "requiredVersion": "^1.0.0-alpha.64",
53
+ "requiredVersion": "^1.0.0-alpha.66",
55
54
  "shareScope": "default",
56
55
  "name": "@appshell/runtime",
57
- "version": "1.0.0-alpha.64",
56
+ "version": "1.0.0-alpha.66",
58
57
  "eager": false,
59
58
  "id": "Appshell:@appshell/runtime",
60
59
  "assets": {
@@ -1,5 +1,5 @@
1
1
  "use strict";
2
- (globalThis["webpackChunkappshell_react_shell"] = globalThis["webpackChunkappshell_react_shell"] || []).push([["react_src_index_ts-_f7a70"],{
2
+ (globalThis["webpackChunkappshell_react_shell"] = globalThis["webpackChunkappshell_react_shell"] || []).push([["react_src_index_ts"],{
3
3
 
4
4
  /***/ "../loader/src/index.ts"
5
5
  /*!******************************!*\
@@ -32,7 +32,8 @@ __webpack_require__.r(__webpack_exports__);
32
32
 
33
33
  __webpack_require__.r(__webpack_exports__);
34
34
  /* harmony export */ __webpack_require__.d(__webpack_exports__, {
35
- /* harmony export */ "default": () => (__WEBPACK_DEFAULT_EXPORT__)
35
+ /* harmony export */ "default": () => (__WEBPACK_DEFAULT_EXPORT__),
36
+ /* harmony export */ load: () => (/* binding */ load)
36
37
  /* harmony export */ });
37
38
  /* harmony import */ var _module_federation_enhanced_runtime__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @module-federation/enhanced/runtime */ "../../node_modules/@module-federation/enhanced/dist/src/runtime.mjs");
38
39
 
@@ -54,7 +55,7 @@ const ensureInitialized = () => {
54
55
  remotes: []
55
56
  });
56
57
  };
57
- /* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (async (scope, module, remoteEntryUrl, shareScope = 'default') => {
58
+ const loadModuleFederation = async (scope, module, remoteEntryUrl, shareScope = 'default') => {
58
59
  // eslint-disable-next-line no-console
59
60
  console.debug(`loading Appshell component: { scope: ${scope}, module: ${module}, shareScope: ${shareScope} }`);
60
61
  ensureInitialized();
@@ -85,8 +86,28 @@ const ensureInitialized = () => {
85
86
  // eslint-disable-next-line no-console
86
87
  console.debug(`Appshell component loaded: { scope: ${scope}, module: ${module}, shareScope: ${shareScope} }`);
87
88
  return Module.default;
88
- });
89
- (Object.getOwnPropertyDescriptor(__WEBPACK_DEFAULT_EXPORT__, "name") || {}).writable || Object.defineProperty(__WEBPACK_DEFAULT_EXPORT__, "name", { value: "default", configurable: true });
89
+ };
90
+
91
+ /**
92
+ * Dispatches on the loader's kind rather than assuming federation.
93
+ *
94
+ * There is one kind today. Naming it is what lets a second — single-spa, import maps —
95
+ * arrive without reinterpreting manifests already published, and what stops federation's
96
+ * vocabulary reading as though it were appshell's.
97
+ */
98
+ const load = async remote => {
99
+ const {
100
+ loader
101
+ } = remote;
102
+ if (loader.kind !== 'ModuleFederation') {
103
+ // Unreachable while one kind exists, and the reason the field is a discriminant: a
104
+ // manifest published under a kind this host cannot load should say so, rather than
105
+ // failing somewhere inside a loader that assumed otherwise.
106
+ throw new Error(`No loader for kind '${loader.kind}'.`);
107
+ }
108
+ return loadModuleFederation(loader.scope, loader.module, remote.remoteEntryUrl, loader.shareScope);
109
+ };
110
+ /* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (load);
90
111
 
91
112
  /***/ },
92
113
 
@@ -130,8 +151,11 @@ __webpack_require__.r(__webpack_exports__);
130
151
  // Before the remote loads, so a package that validates its vars while its modules
131
152
  // evaluate still finds them. `@appshell/runtime` is a shared singleton, so this is
132
153
  // the same store the package reads through `getVars()`.
133
- (0,_appshell_runtime__WEBPACK_IMPORTED_MODULE_0__.setVars)(remote.scope, vars);
134
- const Component = await (0,_loadAppshellComponent__WEBPACK_IMPORTED_MODULE_1__["default"])(remote.scope, remote.module, remote.remoteEntryUrl, remote.shareScope);
154
+ // Vars are keyed by federation scope, which is itself one framework's vocabulary —
155
+ // noted rather than fixed here, since application specs address overrides.vars the
156
+ // same way.
157
+ (0,_appshell_runtime__WEBPACK_IMPORTED_MODULE_0__.setVars)(remote.loader.scope, vars);
158
+ const Component = await (0,_loadAppshellComponent__WEBPACK_IMPORTED_MODULE_1__["default"])(remote);
135
159
  return [Component, remote];
136
160
  } catch (err) {
137
161
  throw failed(err);
@@ -160,7 +184,7 @@ const inlineResolver = composition => async key => {
160
184
  if (!composition || !remote) return undefined;
161
185
  return {
162
186
  remote,
163
- vars: composition.vars[remote.scope] ?? {}
187
+ vars: composition.vars[remote.loader.scope] ?? {}
164
188
  };
165
189
  };
166
190
 
@@ -175,7 +199,7 @@ const registryResolver = (composition, origin = '') => async key => {
175
199
  const remote = await response.json();
176
200
  return {
177
201
  remote,
178
- vars: composition.vars[remote.scope] ?? {}
202
+ vars: composition.vars[remote.loader.scope] ?? {}
179
203
  };
180
204
  };
181
205
  const chainResolvers = (...resolvers) => async key => {
@@ -527,4 +551,4 @@ __webpack_require__.r(__webpack_exports__);
527
551
  /***/ }
528
552
 
529
553
  }]);
530
- //# sourceMappingURL=react_src_index_ts-_f7a70.js.map
554
+ //# sourceMappingURL=react_src_index_ts.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"react_src_index_ts.js","mappings":";;;;;;;;;;;;;;;;;;;AAA0C;AAGd;AACJ;AAExB,iEAAeA,qDAAY,E;;;;;;;;;;;;;;;;ACAkB;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,EA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../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 type { RemoteLoader } from '@appshell/runtime';\nimport {\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\nconst loadModuleFederation = 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\n/**\n * Dispatches on the loader's kind rather than assuming federation.\n *\n * There is one kind today. Naming it is what lets a second — single-spa, import maps —\n * arrive without reinterpreting manifests already published, and what stops federation's\n * vocabulary reading as though it were appshell's.\n */\nexport const load = async <TComponent>(remote: {\n loader: RemoteLoader;\n remoteEntryUrl: string;\n}) => {\n const { loader } = remote;\n\n if (loader.kind !== 'ModuleFederation') {\n // Unreachable while one kind exists, and the reason the field is a discriminant: a\n // manifest published under a kind this host cannot load should say so, rather than\n // failing somewhere inside a loader that assumed otherwise.\n throw new Error(`No loader for kind '${(loader as { kind: string }).kind}'.`);\n }\n\n return loadModuleFederation<TComponent>(\n loader.scope,\n loader.module,\n remote.remoteEntryUrl,\n loader.shareScope,\n );\n};\n\nexport default load;\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 ?? 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 // Vars are keyed by federation scope, which is itself one framework's vocabulary —\n // noted rather than fixed here, since application specs address overrides.vars the\n // same way.\n setVars(remote.loader.scope, vars);\n\n const Component = await loadAppshellComponent<TComponent>(remote);\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.loader.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.loader.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","loadModuleFederation","scope","module","remoteEntryUrl","shareScope","console","debug","has","add","entry","exposed","replace","Module","Error","default","load","remote","loader","kind","setVars","loadAppshellComponent","chainResolvers","inlineResolver","registryResolver","options","composition","window","undefined","__appshell_config__","resolve","resolver","key","failed","err","toString","resolution","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","resolved","Object","values","defaultProps","createContext","RemoteContext","Provider","value","RemoteConsumer","Consumer","React","useContext","useRemote","jsonResource","status","result","suspender","headers","Accept","then","data","statusText","read"],"sourceRoot":""}
@@ -1 +1 @@
1
- {"version":3,"file":"runtime_src_index_ts.js","mappings":";;;;;;;;;;;;;;;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,MAAMA,gBAAgB,SAASC,KAAK,CAAC;EAG1CC,WAAWA,CAACC,KAAa,EAAEC,KAAe,EAAE;IAC1C,KAAK,CACH,+BAA+BD,KAAK,MAClCC,KAAK,CAACC,MAAM,GACR,wBAAwBD,KAAK,CAACE,GAAG,CAAEC,CAAC,IAAK,IAAIA,CAAC,GAAG,CAAC,CAACC,IAAI,CAAC,IAAI,CAAC,gBAAgB,GAC7E,IAAIL,KAAK,0EAA0E,GACnF,iFAAiF,GACjF,yDAAyD,EAEjE,CAAC;IAED,IAAI,CAACM,IAAI,GAAG,kBAAkB;IAC9B,IAAI,CAACN,KAAK,GAAGA,KAAK;EACpB;AACF;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,MAAMO,iBAAiB,SAAST,KAAK,CAAC;EAG3CC,WAAWA,CAACC,KAAa,EAAE;IACzB,KAAK,CACH,aAAaA,KAAK,mDAAmD,GACnE,+CACJ,CAAC;IAED,IAAI,CAACM,IAAI,GAAG,mBAAmB;IAC/B,IAAI,CAACN,KAAK,GAAGA,KAAK;EACpB;AACF;;AAEA;AACA;AACA;AACA;AACO,MAAMQ,iBAAiB,SAASV,KAAK,CAAC;EAC3CC,WAAWA,CAAA,EAAG;IACZ,KAAK,CACH,mFAAmF,GACjF,mFAAmF,GACnF,2EACJ,CAAC;IAED,IAAI,CAACO,IAAI,GAAG,mBAAmB;EACjC;AACF,C;;;;;;;;;;;;;;;ACjEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAKO,MAAMG,SAAmB,GAAG;EAAEC,aAAa,EAAE;AAAM,CAAC;AAQ3D,MAAMC,UAAU,GAAIC,KAAc,IAAwB;EACxD,IAAI,OAAOA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MV,OAAO,GAAGA,CAACzB,KAAa,EAAEoC,IAAU,KAAW;EAC1D,MAAMC,QAAQ,GAAGX,SAAS,CAACY,GAAG,CAACtC,KAAK,CAAC;EAErC,IAAIqC,QAAQ,EAAE;IACZ,IAAI,CAACT,IAAI,CAACS,QAAQ,EAAED,IAAI,CAAC,EAAE;MACzB,MAAM,IAAI7B,sDAAiB,CAACP,KAAK,CAAC;IACpC;IAEA;EACF;EAEA0B,SAAS,CAACa,GAAG,CAACvC,KAAK,EAAEiC,MAAM,CAACO,MAAM,CAAC;IAAE,GAAGJ;EAAK,CAAC,CAAC,CAAC;AAClD,CAAC;;AAED;AACA;AACA;AACA;AACA;AACA;AACO,MAAMb,QAAQ,GAA+BvB,KAAa,IAAY;EAC3E,MAAMoC,IAAI,GAAGV,SAAS,CAACY,GAAG,CAACtC,KAAK,CAAC;EAEjC,IAAI,CAACoC,IAAI,EAAE;IACT,MAAM,IAAIvC,qDAAgB,CAACG,KAAK,EAAE,CAAC,GAAG0B,SAAS,CAACK,IAAI,CAAC,CAAC,CAAC,CAAC;EAC1D;EAEA,OAAOK,IAAI;AACb,CAAC;;AAED;AACO,MAAMd,OAAO,GAAItB,KAAa,IAAc0B,SAAS,CAACe,GAAG,CAACzC,KAAK,CAAC;;AAEvE;AACO,MAAMwB,SAAS,GAAGA,CAAA,KAAY;EACnCE,SAAS,CAACgB,KAAK,CAAC,CAAC;AACnB,CAAC,C","sources":["webpack://appshell-react-shell/../runtime/src/errors.ts","webpack://appshell-react-shell/../runtime/src/identity.ts","webpack://appshell-react-shell/../runtime/src/index.ts","webpack://appshell-react-shell/../runtime/src/store.ts"],"sourcesContent":["/* eslint-disable max-classes-per-file */\n/**\n * A package asked for vars that were never delivered.\n *\n * Almost always one of three things: the package was loaded outside `remoteLoader`\n * (a test, a storybook, a direct import), the host and the package resolved separate\n * copies of `@appshell/runtime` because one of them failed to declare it as a\n * singleton, or the scope compiled into the package is not the scope the registry\n * knows it by.\n */\nexport class MissingVarsError extends Error {\n readonly scope: string;\n\n constructor(scope: string, known: string[]) {\n super(\n `No vars were delivered for '${scope}'. ${\n known.length\n ? `Vars are present for ${known.map((s) => `'${s}'`).join(', ')} — check that ` +\n `'${scope}' matches the module federation name the registry knows this package by.`\n : `Nothing has delivered vars on this page — check that the host and this package ` +\n `both declare '@appshell/runtime' as a shared singleton.`\n }`,\n );\n\n this.name = 'MissingVarsError';\n this.scope = scope;\n }\n}\n\n/**\n * Something tried to replace vars that were already delivered for a scope.\n *\n * The first write wins and is final. Within one page load a scope has exactly one\n * vars object — both resolvers read it from the same `composition.vars[scope]` — so a\n * differing second write is a bug or a package reaching for a scope that is not its own,\n * and neither should be applied quietly.\n */\nexport class VarsConflictError extends Error {\n readonly scope: string;\n\n constructor(scope: string) {\n super(\n `Vars for '${scope}' were already delivered and cannot be replaced. ` +\n `A scope receives its vars once per page load.`,\n );\n\n this.name = 'VarsConflictError';\n this.scope = scope;\n }\n}\n\n/**\n * The package was built without `AppshellPlugin`, so nothing substituted the scope the\n * `@appshell/runtime/vars` accessor needs to know which vars are its own.\n */\nexport class MissingScopeError extends Error {\n constructor() {\n super(\n `Cannot tell which package this is. '@appshell/runtime/vars' needs the scope that ` +\n `AppshellPlugin injects at build time — add it to this package's webpack plugins, ` +\n `or read the store directly with readVars(scope) from '@appshell/runtime'.`,\n );\n\n this.name = 'MissingScopeError';\n }\n}\n","/* eslint-disable no-underscore-dangle, @typescript-eslint/naming-convention */\n/**\n * Who is looking at the page, as the registry was told by the gateway.\n *\n * Unlike vars this is not scope-specific — there is one visitor per page, not one\n * per package — so it lives in the main entry rather than needing the subpath\n * trick `@appshell/runtime/vars` uses to get a per-package scope substituted.\n *\n * It is also not delivered through the vars store, and that is a constraint rather\n * than a preference: `setVars` freezes on first write and throws on replacement,\n * which is what stops one package overwriting another's configuration. Identity\n * changes — sign-in, sign-out, token refresh — so it cannot live behind a\n * write-once door without either breaking that guarantee or never updating.\n */\n\n/**\n * A discriminated union rather than an optional user, so `username` cannot be read\n * without the anonymous case having been handled. The compiler enforces what a\n * convention would only ask for.\n */\nexport type Identity =\n | { authenticated: false }\n | { authenticated: true; subject: string; username: string; roles: string[] };\n\nexport const ANONYMOUS: Identity = { authenticated: false };\n\ndeclare global {\n interface Window {\n __appshell_identity__?: unknown;\n }\n}\n\nconst isIdentity = (value: unknown): value is Identity => {\n if (typeof value !== 'object' || value === null) return false;\n\n const candidate = value as Record<string, unknown>;\n\n if (candidate.authenticated === false) return true;\n\n return (\n candidate.authenticated === true &&\n typeof candidate.subject === 'string' &&\n typeof candidate.username === 'string' &&\n Array.isArray(candidate.roles)\n );\n};\n\n/**\n * The visitor, or the anonymous identity when there is none.\n *\n * Never throws and never returns undefined — an absent or malformed value is\n * anonymous, which is a state every caller already has to handle. That is the\n * opposite of `readVars`, which throws when a scope is missing, and the difference\n * is deliberate: a package with no configuration cannot do its job, while a package\n * with no signed-in user usually can and simply renders differently.\n *\n * This is a typed accessor, not a boundary. The value is inlined into the document\n * and any script on the page can read it directly, exactly as with vars. Treat it\n * as what the server said about the visitor, never as proof of anything: it carries\n * no token and grants nothing. Anything that matters is re-checked server-side.\n */\nexport const getIdentity = (): Identity => {\n if (typeof window === 'undefined') return ANONYMOUS;\n\n const value = window.__appshell_identity__;\n\n return isIdentity(value) ? value : ANONYMOUS;\n};\n","export { MissingScopeError, MissingVarsError, VarsConflictError } from './errors';\nexport { ANONYMOUS, getIdentity } from './identity';\nexport type { Identity } from './identity';\nexport { hasVars, readVars, resetVars, setVars } from './store';\nexport type { Vars } from './types';\nexport type { AppshellIndex, AppshellRemote, Metadata } from './wire';\n","import { MissingVarsError, VarsConflictError } from './errors';\nimport type { Vars } from './types';\n\n/**\n * One map per page, because this module is a shared singleton. Keyed by federation\n * scope, which is the only identity the host and the package agree on.\n */\nconst delivered = new Map<string, Readonly<Vars>>();\n\n/** Order-independent: vars are flat, one level of string/number/undefined. */\nconst same = (a: Vars, b: Vars) => {\n const keys = new Set([...Object.keys(a), ...Object.keys(b)]);\n\n return [...keys].every((key) => a[key] === b[key]);\n};\n\n/**\n * Delivers a scope's vars. Called by `@appshell/loader` immediately before the remote\n * is loaded, so they are in place before the package's modules evaluate.\n *\n * The first write for a scope wins and is frozen. Re-delivering the identical vars is a\n * no-op — the same remote can be mounted more than once — but replacing them throws.\n * That is what keeps one package from overwriting another's: by the time any package\n * evaluates, the host has already written for it.\n *\n * It does not make a scope's vars *private*. Any code on the page can still read another\n * scope by name, and nothing short of a separate realm would change that.\n */\nexport const setVars = (scope: string, vars: Vars): void => {\n const existing = delivered.get(scope);\n\n if (existing) {\n if (!same(existing, vars)) {\n throw new VarsConflictError(scope);\n }\n\n return;\n }\n\n delivered.set(scope, Object.freeze({ ...vars }));\n};\n\n/**\n * Reads a scope's vars, throwing rather than handing back an empty object — a package\n * that silently renders with no configuration is the failure this replaced.\n *\n * Prefer `getVars()` from `@appshell/runtime/vars`, which supplies the scope for you.\n */\nexport const readVars = <TVars extends Vars = Vars>(scope: string): TVars => {\n const vars = delivered.get(scope);\n\n if (!vars) {\n throw new MissingVarsError(scope, [...delivered.keys()]);\n }\n\n return vars as TVars;\n};\n\n/** Whether a scope has been delivered, for callers that want to branch instead of catch. */\nexport const hasVars = (scope: string): boolean => delivered.has(scope);\n\n/** Test seam. Not part of the contract a package should build on. */\nexport const resetVars = (): void => {\n delivered.clear();\n};\n"],"names":["MissingVarsError","Error","constructor","scope","known","length","map","s","join","name","VarsConflictError","MissingScopeError","ANONYMOUS","authenticated","isIdentity","value","candidate","subject","username","Array","isArray","roles","getIdentity","window","__appshell_identity__","hasVars","readVars","resetVars","setVars","delivered","Map","same","a","b","keys","Set","Object","every","key","vars","existing","get","set","freeze","has","clear"],"sourceRoot":""}
1
+ {"version":3,"file":"runtime_src_index_ts.js","mappings":";;;;;;;;;;;;;;;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,MAAMA,gBAAgB,SAASC,KAAK,CAAC;EAG1CC,WAAWA,CAACC,KAAa,E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CAAC,EAAE;MACzB,MAAM,IAAI7B,sDAAiB,CAACP,KAAK,CAAC;IACpC;IAEA;EACF;EAEA0B,SAAS,CAACa,GAAG,CAACvC,KAAK,EAAEiC,MAAM,CAACO,MAAM,CAAC;IAAE,GAAGJ;EAAK,CAAC,CAAC,CAAC;AAClD,CAAC;;AAED;AACA;AACA;AACA;AACA;AACA;AACO,MAAMb,QAAQ,GAA+BvB,KAAa,IAAY;EAC3E,MAAMoC,IAAI,GAAGV,SAAS,CAACY,GAAG,CAACtC,KAAK,CAAC;EAEjC,IAAI,CAACoC,IAAI,EAAE;IACT,MAAM,IAAIvC,qDAAgB,CAACG,KAAK,EAAE,CAAC,GAAG0B,SAAS,CAACK,IAAI,CAAC,CAAC,CAAC,CAAC;EAC1D;EAEA,OAAOK,IAAI;AACb,CAAC;;AAED;AACO,MAAMd,OAAO,GAAItB,KAAa,IAAc0B,SAAS,CAACe,GAAG,CAACzC,KAAK,CAAC;;AAEvE;AACO,MAAMwB,SAAS,GAAGA,CAAA,KAAY;EACnCE,SAAS,CAACgB,KAAK,CAAC,CAAC;AACnB,CAAC,C","sources":["webpack://appshell-react-shell/../runtime/src/errors.ts","webpack://appshell-react-shell/../runtime/src/identity.ts","webpack://appshell-react-shell/../runtime/src/index.ts","webpack://appshell-react-shell/../runtime/src/store.ts"],"sourcesContent":["/* eslint-disable max-classes-per-file */\n/**\n * A package asked for vars that were never delivered.\n *\n * Almost always one of three things: the package was loaded outside `remoteLoader`\n * (a test, a storybook, a direct import), the host and the package resolved separate\n * copies of `@appshell/runtime` because one of them failed to declare it as a\n * singleton, or the scope compiled into the package is not the scope the registry\n * knows it by.\n */\nexport class MissingVarsError extends Error {\n readonly scope: string;\n\n constructor(scope: string, known: string[]) {\n super(\n `No vars were delivered for '${scope}'. ${\n known.length\n ? `Vars are present for ${known.map((s) => `'${s}'`).join(', ')} — check that ` +\n `'${scope}' matches the module federation name the registry knows this package by.`\n : `Nothing has delivered vars on this page — check that the host and this package ` +\n `both declare '@appshell/runtime' as a shared singleton.`\n }`,\n );\n\n this.name = 'MissingVarsError';\n this.scope = scope;\n }\n}\n\n/**\n * Something tried to replace vars that were already delivered for a scope.\n *\n * The first write wins and is final. Within one page load a scope has exactly one\n * vars object — both resolvers read it from the same `composition.vars[scope]` — so a\n * differing second write is a bug or a package reaching for a scope that is not its own,\n * and neither should be applied quietly.\n */\nexport class VarsConflictError extends Error {\n readonly scope: string;\n\n constructor(scope: string) {\n super(\n `Vars for '${scope}' were already delivered and cannot be replaced. ` +\n `A scope receives its vars once per page load.`,\n );\n\n this.name = 'VarsConflictError';\n this.scope = scope;\n }\n}\n\n/**\n * The package was built without `AppshellPlugin`, so nothing substituted the scope the\n * `@appshell/runtime/vars` accessor needs to know which vars are its own.\n */\nexport class MissingScopeError extends Error {\n constructor() {\n super(\n `Cannot tell which package this is. '@appshell/runtime/vars' needs the scope that ` +\n `AppshellPlugin injects at build time — add it to this package's webpack plugins, ` +\n `or read the store directly with readVars(scope) from '@appshell/runtime'.`,\n );\n\n this.name = 'MissingScopeError';\n }\n}\n","/* eslint-disable no-underscore-dangle, @typescript-eslint/naming-convention */\n/**\n * Who is looking at the page, as the registry was told by the gateway.\n *\n * Unlike vars this is not scope-specific — there is one visitor per page, not one\n * per package — so it lives in the main entry rather than needing the subpath\n * trick `@appshell/runtime/vars` uses to get a per-package scope substituted.\n *\n * It is also not delivered through the vars store, and that is a constraint rather\n * than a preference: `setVars` freezes on first write and throws on replacement,\n * which is what stops one package overwriting another's configuration. Identity\n * changes — sign-in, sign-out, token refresh — so it cannot live behind a\n * write-once door without either breaking that guarantee or never updating.\n */\n\n/**\n * A discriminated union rather than an optional user, so `username` cannot be read\n * without the anonymous case having been handled. The compiler enforces what a\n * convention would only ask for.\n */\nexport type Identity =\n | { authenticated: false }\n | { authenticated: true; subject: string; username: string; roles: string[] };\n\nexport const ANONYMOUS: Identity = { authenticated: false };\n\ndeclare global {\n interface Window {\n __appshell_identity__?: unknown;\n }\n}\n\nconst isIdentity = (value: unknown): value is Identity => {\n if (typeof value !== 'object' || value === null) return false;\n\n const candidate = value as Record<string, unknown>;\n\n if (candidate.authenticated === false) return true;\n\n return (\n candidate.authenticated === true &&\n typeof candidate.subject === 'string' &&\n typeof candidate.username === 'string' &&\n Array.isArray(candidate.roles)\n );\n};\n\n/**\n * The visitor, or the anonymous identity when there is none.\n *\n * Never throws and never returns undefined — an absent or malformed value is\n * anonymous, which is a state every caller already has to handle. That is the\n * opposite of `readVars`, which throws when a scope is missing, and the difference\n * is deliberate: a package with no configuration cannot do its job, while a package\n * with no signed-in user usually can and simply renders differently.\n *\n * This is a typed accessor, not a boundary. The value is inlined into the document\n * and any script on the page can read it directly, exactly as with vars. Treat it\n * as what the server said about the visitor, never as proof of anything: it carries\n * no token and grants nothing. Anything that matters is re-checked server-side.\n */\nexport const getIdentity = (): Identity => {\n if (typeof window === 'undefined') return ANONYMOUS;\n\n const value = window.__appshell_identity__;\n\n return isIdentity(value) ? value : ANONYMOUS;\n};\n","export { MissingScopeError, MissingVarsError, VarsConflictError } from './errors';\nexport { ANONYMOUS, getIdentity } from './identity';\nexport type { Identity } from './identity';\nexport { hasVars, readVars, resetVars, setVars } from './store';\nexport type { Vars } from './types';\nexport type {\n AppshellIndex,\n AppshellRemote,\n Metadata,\n ModuleFederationLoader,\n RemoteLoader,\n} from './wire';\n","import { MissingVarsError, VarsConflictError } from './errors';\nimport type { Vars } from './types';\n\n/**\n * One map per page, because this module is a shared singleton. Keyed by federation\n * scope, which is the only identity the host and the package agree on.\n */\nconst delivered = new Map<string, Readonly<Vars>>();\n\n/** Order-independent: vars are flat, one level of string/number/undefined. */\nconst same = (a: Vars, b: Vars) => {\n const keys = new Set([...Object.keys(a), ...Object.keys(b)]);\n\n return [...keys].every((key) => a[key] === b[key]);\n};\n\n/**\n * Delivers a scope's vars. Called by `@appshell/loader` immediately before the remote\n * is loaded, so they are in place before the package's modules evaluate.\n *\n * The first write for a scope wins and is frozen. Re-delivering the identical vars is a\n * no-op — the same remote can be mounted more than once — but replacing them throws.\n * That is what keeps one package from overwriting another's: by the time any package\n * evaluates, the host has already written for it.\n *\n * It does not make a scope's vars *private*. Any code on the page can still read another\n * scope by name, and nothing short of a separate realm would change that.\n */\nexport const setVars = (scope: string, vars: Vars): void => {\n const existing = delivered.get(scope);\n\n if (existing) {\n if (!same(existing, vars)) {\n throw new VarsConflictError(scope);\n }\n\n return;\n }\n\n delivered.set(scope, Object.freeze({ ...vars }));\n};\n\n/**\n * Reads a scope's vars, throwing rather than handing back an empty object — a package\n * that silently renders with no configuration is the failure this replaced.\n *\n * Prefer `getVars()` from `@appshell/runtime/vars`, which supplies the scope for you.\n */\nexport const readVars = <TVars extends Vars = Vars>(scope: string): TVars => {\n const vars = delivered.get(scope);\n\n if (!vars) {\n throw new MissingVarsError(scope, [...delivered.keys()]);\n }\n\n return vars as TVars;\n};\n\n/** Whether a scope has been delivered, for callers that want to branch instead of catch. */\nexport const hasVars = (scope: string): boolean => delivered.has(scope);\n\n/** Test seam. Not part of the contract a package should build on. */\nexport const resetVars = (): void => {\n delivered.clear();\n};\n"],"names":["MissingVarsError","Error","constructor","scope","known","length","map","s","join","name","VarsConflictError","MissingScopeError","ANONYMOUS","authenticated","isIdentity","value","candidate","subject","username","Array","isArray","roles","getIdentity","window","__appshell_identity__","hasVars","readVars","resetVars","setVars","delivered","Map","same","a","b","keys","Set","Object","every","key","vars","existing","get","set","freeze","has","clear"],"sourceRoot":""}