@appshell/react-shell 1.0.0-alpha.8 → 1.0.0-alpha.80

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.
Files changed (38) hide show
  1. package/README.md +33 -26
  2. package/dist/144.js +1 -1
  3. package/dist/466.js +2 -0
  4. package/dist/466.js.LICENSE.txt +9 -0
  5. package/dist/58.js +1 -0
  6. package/dist/630.js +1 -0
  7. package/dist/677.js +1 -0
  8. package/dist/85.js +2 -0
  9. package/dist/85.js.LICENSE.txt +9 -0
  10. package/dist/941.js +1 -0
  11. package/dist/dev/favicon.ico +0 -0
  12. package/dist/dev/logo192.png +0 -0
  13. package/dist/dev/logo512.png +0 -0
  14. package/dist/dev/main.js +8160 -0
  15. package/dist/dev/main.js.map +1 -0
  16. package/dist/dev/manifest.json +25 -0
  17. package/dist/dev/mf-manifest.json +130 -0
  18. package/dist/dev/mf-stats.json +150 -0
  19. package/dist/dev/react_src_index_ts.js +554 -0
  20. package/dist/dev/react_src_index_ts.js.map +1 -0
  21. package/dist/dev/runtime_src_index_ts.js +231 -0
  22. package/dist/dev/runtime_src_index_ts.js.map +1 -0
  23. package/dist/dev/src_bootstrap_tsx.js +768 -0
  24. package/dist/dev/src_bootstrap_tsx.js.map +1 -0
  25. package/dist/dev/vendors-node_modules_react-dom_index_js.js +30577 -0
  26. package/dist/dev/vendors-node_modules_react-dom_index_js.js.map +1 -0
  27. package/dist/dev/vendors-node_modules_react_index_js.js +2771 -0
  28. package/dist/dev/vendors-node_modules_react_index_js.js.map +1 -0
  29. package/dist/dev/vendors-node_modules_react_jsx-runtime_js.js +1345 -0
  30. package/dist/dev/vendors-node_modules_react_jsx-runtime_js.js.map +1 -0
  31. package/dist/main.js +1 -1
  32. package/dist/mf-manifest.json +132 -0
  33. package/dist/mf-stats.json +152 -0
  34. package/package.json +16 -8
  35. package/dist/190.js +0 -1
  36. package/dist/320.js +0 -1
  37. package/dist/48.js +0 -1
  38. package/dist/939.js +0 -1
@@ -0,0 +1,231 @@
1
+ "use strict";
2
+ (globalThis["webpackChunkappshell_react_shell"] = globalThis["webpackChunkappshell_react_shell"] || []).push([["runtime_src_index_ts"],{
3
+
4
+ /***/ "../runtime/src/errors.ts"
5
+ /*!********************************!*\
6
+ !*** ../runtime/src/errors.ts ***!
7
+ \********************************/
8
+ (__unused_webpack_module, __webpack_exports__, __webpack_require__) {
9
+
10
+ __webpack_require__.r(__webpack_exports__);
11
+ /* harmony export */ __webpack_require__.d(__webpack_exports__, {
12
+ /* harmony export */ MissingScopeError: () => (/* binding */ MissingScopeError),
13
+ /* harmony export */ MissingVarsError: () => (/* binding */ MissingVarsError),
14
+ /* harmony export */ VarsConflictError: () => (/* binding */ VarsConflictError)
15
+ /* harmony export */ });
16
+ /* eslint-disable max-classes-per-file */
17
+ /**
18
+ * A package asked for vars that were never delivered.
19
+ *
20
+ * Almost always one of three things: the package was loaded outside `remoteLoader`
21
+ * (a test, a storybook, a direct import), the host and the package resolved separate
22
+ * copies of `@appshell/runtime` because one of them failed to declare it as a
23
+ * singleton, or the scope compiled into the package is not the scope the registry
24
+ * knows it by.
25
+ */
26
+ class MissingVarsError extends Error {
27
+ constructor(scope, known) {
28
+ super(`No vars were delivered for '${scope}'. ${known.length ? `Vars are present for ${known.map(s => `'${s}'`).join(', ')} — check that ` + `'${scope}' matches the module federation name the registry knows this package by.` : `Nothing has delivered vars on this page — check that the host and this package ` + `both declare '@appshell/runtime' as a shared singleton.`}`);
29
+ this.name = 'MissingVarsError';
30
+ this.scope = scope;
31
+ }
32
+ }
33
+
34
+ /**
35
+ * Something tried to replace vars that were already delivered for a scope.
36
+ *
37
+ * The first write wins and is final. Within one page load a scope has exactly one
38
+ * vars object — both resolvers read it from the same `composition.vars[scope]` — so a
39
+ * differing second write is a bug or a package reaching for a scope that is not its own,
40
+ * and neither should be applied quietly.
41
+ */
42
+ class VarsConflictError extends Error {
43
+ constructor(scope) {
44
+ super(`Vars for '${scope}' were already delivered and cannot be replaced. ` + `A scope receives its vars once per page load.`);
45
+ this.name = 'VarsConflictError';
46
+ this.scope = scope;
47
+ }
48
+ }
49
+
50
+ /**
51
+ * The package was built without `AppshellPlugin`, so nothing substituted the scope the
52
+ * `@appshell/runtime/vars` accessor needs to know which vars are its own.
53
+ */
54
+ class MissingScopeError extends Error {
55
+ constructor() {
56
+ super(`Cannot tell which package this is. '@appshell/runtime/vars' needs the scope that ` + `AppshellPlugin injects at build time — add it to this package's webpack plugins, ` + `or read the store directly with readVars(scope) from '@appshell/runtime'.`);
57
+ this.name = 'MissingScopeError';
58
+ }
59
+ }
60
+
61
+ /***/ },
62
+
63
+ /***/ "../runtime/src/identity.ts"
64
+ /*!**********************************!*\
65
+ !*** ../runtime/src/identity.ts ***!
66
+ \**********************************/
67
+ (__unused_webpack_module, __webpack_exports__, __webpack_require__) {
68
+
69
+ __webpack_require__.r(__webpack_exports__);
70
+ /* harmony export */ __webpack_require__.d(__webpack_exports__, {
71
+ /* harmony export */ ANONYMOUS: () => (/* binding */ ANONYMOUS),
72
+ /* harmony export */ getIdentity: () => (/* binding */ getIdentity)
73
+ /* harmony export */ });
74
+ /* eslint-disable no-underscore-dangle, @typescript-eslint/naming-convention */
75
+ /**
76
+ * Who is looking at the page, as the registry was told by the gateway.
77
+ *
78
+ * Unlike vars this is not scope-specific — there is one visitor per page, not one
79
+ * per package — so it lives in the main entry rather than needing the subpath
80
+ * trick `@appshell/runtime/vars` uses to get a per-package scope substituted.
81
+ *
82
+ * It is also not delivered through the vars store, and that is a constraint rather
83
+ * than a preference: `setVars` freezes on first write and throws on replacement,
84
+ * which is what stops one package overwriting another's configuration. Identity
85
+ * changes — sign-in, sign-out, token refresh — so it cannot live behind a
86
+ * write-once door without either breaking that guarantee or never updating.
87
+ */
88
+
89
+ /**
90
+ * A discriminated union rather than an optional user, so `username` cannot be read
91
+ * without the anonymous case having been handled. The compiler enforces what a
92
+ * convention would only ask for.
93
+ */
94
+
95
+ const ANONYMOUS = {
96
+ authenticated: false
97
+ };
98
+ const isIdentity = value => {
99
+ if (typeof value !== 'object' || value === null) return false;
100
+ const candidate = value;
101
+ if (candidate.authenticated === false) return true;
102
+ return candidate.authenticated === true && typeof candidate.subject === 'string' && typeof candidate.username === 'string' && Array.isArray(candidate.roles);
103
+ };
104
+
105
+ /**
106
+ * The visitor, or the anonymous identity when there is none.
107
+ *
108
+ * Never throws and never returns undefined — an absent or malformed value is
109
+ * anonymous, which is a state every caller already has to handle. That is the
110
+ * opposite of `readVars`, which throws when a scope is missing, and the difference
111
+ * is deliberate: a package with no configuration cannot do its job, while a package
112
+ * with no signed-in user usually can and simply renders differently.
113
+ *
114
+ * This is a typed accessor, not a boundary. The value is inlined into the document
115
+ * and any script on the page can read it directly, exactly as with vars. Treat it
116
+ * as what the server said about the visitor, never as proof of anything: it carries
117
+ * no token and grants nothing. Anything that matters is re-checked server-side.
118
+ */
119
+ const getIdentity = () => {
120
+ if (typeof window === 'undefined') return ANONYMOUS;
121
+ const value = window.__appshell_identity__;
122
+ return isIdentity(value) ? value : ANONYMOUS;
123
+ };
124
+
125
+ /***/ },
126
+
127
+ /***/ "../runtime/src/index.ts"
128
+ /*!*******************************!*\
129
+ !*** ../runtime/src/index.ts ***!
130
+ \*******************************/
131
+ (__unused_webpack_module, __webpack_exports__, __webpack_require__) {
132
+
133
+ __webpack_require__.r(__webpack_exports__);
134
+ /* harmony export */ __webpack_require__.d(__webpack_exports__, {
135
+ /* harmony export */ ANONYMOUS: () => (/* reexport safe */ _identity__WEBPACK_IMPORTED_MODULE_1__.ANONYMOUS),
136
+ /* harmony export */ MissingScopeError: () => (/* reexport safe */ _errors__WEBPACK_IMPORTED_MODULE_0__.MissingScopeError),
137
+ /* harmony export */ MissingVarsError: () => (/* reexport safe */ _errors__WEBPACK_IMPORTED_MODULE_0__.MissingVarsError),
138
+ /* harmony export */ VarsConflictError: () => (/* reexport safe */ _errors__WEBPACK_IMPORTED_MODULE_0__.VarsConflictError),
139
+ /* harmony export */ getIdentity: () => (/* reexport safe */ _identity__WEBPACK_IMPORTED_MODULE_1__.getIdentity),
140
+ /* harmony export */ hasVars: () => (/* reexport safe */ _store__WEBPACK_IMPORTED_MODULE_2__.hasVars),
141
+ /* harmony export */ readVars: () => (/* reexport safe */ _store__WEBPACK_IMPORTED_MODULE_2__.readVars),
142
+ /* harmony export */ resetVars: () => (/* reexport safe */ _store__WEBPACK_IMPORTED_MODULE_2__.resetVars),
143
+ /* harmony export */ setVars: () => (/* reexport safe */ _store__WEBPACK_IMPORTED_MODULE_2__.setVars)
144
+ /* harmony export */ });
145
+ /* harmony import */ var _errors__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./errors */ "../runtime/src/errors.ts");
146
+ /* harmony import */ var _identity__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./identity */ "../runtime/src/identity.ts");
147
+ /* harmony import */ var _store__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./store */ "../runtime/src/store.ts");
148
+
149
+
150
+
151
+
152
+ /***/ },
153
+
154
+ /***/ "../runtime/src/store.ts"
155
+ /*!*******************************!*\
156
+ !*** ../runtime/src/store.ts ***!
157
+ \*******************************/
158
+ (__unused_webpack_module, __webpack_exports__, __webpack_require__) {
159
+
160
+ __webpack_require__.r(__webpack_exports__);
161
+ /* harmony export */ __webpack_require__.d(__webpack_exports__, {
162
+ /* harmony export */ hasVars: () => (/* binding */ hasVars),
163
+ /* harmony export */ readVars: () => (/* binding */ readVars),
164
+ /* harmony export */ resetVars: () => (/* binding */ resetVars),
165
+ /* harmony export */ setVars: () => (/* binding */ setVars)
166
+ /* harmony export */ });
167
+ /* harmony import */ var _errors__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./errors */ "../runtime/src/errors.ts");
168
+
169
+ /**
170
+ * One map per page, because this module is a shared singleton. Keyed by federation
171
+ * scope, which is the only identity the host and the package agree on.
172
+ */
173
+ const delivered = new Map();
174
+
175
+ /** Order-independent: vars are flat, one level of string/number/undefined. */
176
+ const same = (a, b) => {
177
+ const keys = new Set([...Object.keys(a), ...Object.keys(b)]);
178
+ return [...keys].every(key => a[key] === b[key]);
179
+ };
180
+
181
+ /**
182
+ * Delivers a scope's vars. Called by `@appshell/loader` immediately before the remote
183
+ * is loaded, so they are in place before the package's modules evaluate.
184
+ *
185
+ * The first write for a scope wins and is frozen. Re-delivering the identical vars is a
186
+ * no-op — the same remote can be mounted more than once — but replacing them throws.
187
+ * That is what keeps one package from overwriting another's: by the time any package
188
+ * evaluates, the host has already written for it.
189
+ *
190
+ * It does not make a scope's vars *private*. Any code on the page can still read another
191
+ * scope by name, and nothing short of a separate realm would change that.
192
+ */
193
+ const setVars = (scope, vars) => {
194
+ const existing = delivered.get(scope);
195
+ if (existing) {
196
+ if (!same(existing, vars)) {
197
+ throw new _errors__WEBPACK_IMPORTED_MODULE_0__.VarsConflictError(scope);
198
+ }
199
+ return;
200
+ }
201
+ delivered.set(scope, Object.freeze({
202
+ ...vars
203
+ }));
204
+ };
205
+
206
+ /**
207
+ * Reads a scope's vars, throwing rather than handing back an empty object — a package
208
+ * that silently renders with no configuration is the failure this replaced.
209
+ *
210
+ * Prefer `getVars()` from `@appshell/runtime/vars`, which supplies the scope for you.
211
+ */
212
+ const readVars = scope => {
213
+ const vars = delivered.get(scope);
214
+ if (!vars) {
215
+ throw new _errors__WEBPACK_IMPORTED_MODULE_0__.MissingVarsError(scope, [...delivered.keys()]);
216
+ }
217
+ return vars;
218
+ };
219
+
220
+ /** Whether a scope has been delivered, for callers that want to branch instead of catch. */
221
+ const hasVars = scope => delivered.has(scope);
222
+
223
+ /** Test seam. Not part of the contract a package should build on. */
224
+ const resetVars = () => {
225
+ delivered.clear();
226
+ };
227
+
228
+ /***/ }
229
+
230
+ }]);
231
+ //# sourceMappingURL=runtime_src_index_ts.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"runtime_src_index_ts.js","mappings":";;;;;;;;;;;;;;;AAAA;AACA;AACA;AACA;AACA;AAC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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 {\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":""}