@appshell/react-shell 1.0.0-alpha.14 → 1.0.0-alpha.15

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.14",
8
+ "buildVersion": "1.0.0-alpha.15",
9
9
  "buildName": "@appshell/react-shell"
10
10
  },
11
11
  "remoteEntry": {
@@ -24,6 +24,26 @@
24
24
  "publicPath": "auto"
25
25
  },
26
26
  "shared": [
27
+ {
28
+ "id": "Appshell:@appshell/runtime",
29
+ "name": "@appshell/runtime",
30
+ "version": "1.0.0-alpha.15",
31
+ "singleton": true,
32
+ "requiredVersion": "^1.0.0-alpha.15",
33
+ "assets": {
34
+ "js": {
35
+ "async": [],
36
+ "sync": [
37
+ "runtime_src_index_ts.js"
38
+ ]
39
+ },
40
+ "css": {
41
+ "async": [],
42
+ "sync": []
43
+ }
44
+ },
45
+ "fallback": ""
46
+ },
27
47
  {
28
48
  "id": "Appshell:react-dom",
29
49
  "name": "react-dom",
@@ -5,7 +5,7 @@
5
5
  "name": "Appshell",
6
6
  "type": "app",
7
7
  "buildInfo": {
8
- "buildVersion": "1.0.0-alpha.14",
8
+ "buildVersion": "1.0.0-alpha.15",
9
9
  "buildName": "@appshell/react-shell"
10
10
  },
11
11
  "remoteEntry": {
@@ -24,6 +24,30 @@
24
24
  "publicPath": "auto"
25
25
  },
26
26
  "shared": [
27
+ {
28
+ "singleton": true,
29
+ "requiredVersion": "^1.0.0-alpha.15",
30
+ "shareScope": "default",
31
+ "name": "@appshell/runtime",
32
+ "version": "1.0.0-alpha.15",
33
+ "eager": false,
34
+ "id": "Appshell:@appshell/runtime",
35
+ "assets": {
36
+ "js": {
37
+ "async": [],
38
+ "sync": [
39
+ "runtime_src_index_ts.js"
40
+ ]
41
+ },
42
+ "css": {
43
+ "async": [],
44
+ "sync": []
45
+ }
46
+ },
47
+ "usedIn": [],
48
+ "usedExports": [],
49
+ "fallback": ""
50
+ },
27
51
  {
28
52
  "singleton": true,
29
53
  "requiredVersion": "18.2.0",
@@ -0,0 +1,150 @@
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 */ MissingVarsError: () => (/* binding */ MissingVarsError),
13
+ /* harmony export */ VarsConflictError: () => (/* binding */ VarsConflictError)
14
+ /* harmony export */ });
15
+ /* eslint-disable max-classes-per-file */
16
+ /**
17
+ * A package asked for vars that were never delivered.
18
+ *
19
+ * Almost always one of three things: the package was loaded outside `remoteLoader`
20
+ * (a test, a storybook, a direct import), the host and the package resolved separate
21
+ * copies of `@appshell/runtime` because one of them failed to declare it as a
22
+ * singleton, or the scope compiled into the package is not the scope the registry
23
+ * knows it by.
24
+ */
25
+ class MissingVarsError extends Error {
26
+ constructor(scope, known) {
27
+ 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.`}`);
28
+ this.name = 'MissingVarsError';
29
+ this.scope = scope;
30
+ }
31
+ }
32
+
33
+ /**
34
+ * Something tried to replace vars that were already delivered for a scope.
35
+ *
36
+ * The first write wins and is final. Within one page load a scope has exactly one
37
+ * vars object — both resolvers read it from the same `composition.vars[scope]` — so a
38
+ * differing second write is a bug or a package reaching for a scope that is not its own,
39
+ * and neither should be applied quietly.
40
+ */
41
+ class VarsConflictError extends Error {
42
+ constructor(scope) {
43
+ super(`Vars for '${scope}' were already delivered and cannot be replaced. ` + `A scope receives its vars once per page load.`);
44
+ this.name = 'VarsConflictError';
45
+ this.scope = scope;
46
+ }
47
+ }
48
+
49
+ /***/ },
50
+
51
+ /***/ "../runtime/src/index.ts"
52
+ /*!*******************************!*\
53
+ !*** ../runtime/src/index.ts ***!
54
+ \*******************************/
55
+ (__unused_webpack_module, __webpack_exports__, __webpack_require__) {
56
+
57
+ __webpack_require__.r(__webpack_exports__);
58
+ /* harmony export */ __webpack_require__.d(__webpack_exports__, {
59
+ /* harmony export */ MissingVarsError: () => (/* reexport safe */ _errors__WEBPACK_IMPORTED_MODULE_0__.MissingVarsError),
60
+ /* harmony export */ VarsConflictError: () => (/* reexport safe */ _errors__WEBPACK_IMPORTED_MODULE_0__.VarsConflictError),
61
+ /* harmony export */ hasVars: () => (/* reexport safe */ _store__WEBPACK_IMPORTED_MODULE_1__.hasVars),
62
+ /* harmony export */ readVars: () => (/* reexport safe */ _store__WEBPACK_IMPORTED_MODULE_1__.readVars),
63
+ /* harmony export */ resetVars: () => (/* reexport safe */ _store__WEBPACK_IMPORTED_MODULE_1__.resetVars),
64
+ /* harmony export */ setVars: () => (/* reexport safe */ _store__WEBPACK_IMPORTED_MODULE_1__.setVars)
65
+ /* harmony export */ });
66
+ /* harmony import */ var _errors__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./errors */ "../runtime/src/errors.ts");
67
+ /* harmony import */ var _store__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./store */ "../runtime/src/store.ts");
68
+
69
+
70
+
71
+ /***/ },
72
+
73
+ /***/ "../runtime/src/store.ts"
74
+ /*!*******************************!*\
75
+ !*** ../runtime/src/store.ts ***!
76
+ \*******************************/
77
+ (__unused_webpack_module, __webpack_exports__, __webpack_require__) {
78
+
79
+ __webpack_require__.r(__webpack_exports__);
80
+ /* harmony export */ __webpack_require__.d(__webpack_exports__, {
81
+ /* harmony export */ hasVars: () => (/* binding */ hasVars),
82
+ /* harmony export */ readVars: () => (/* binding */ readVars),
83
+ /* harmony export */ resetVars: () => (/* binding */ resetVars),
84
+ /* harmony export */ setVars: () => (/* binding */ setVars)
85
+ /* harmony export */ });
86
+ /* harmony import */ var _errors__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./errors */ "../runtime/src/errors.ts");
87
+
88
+ /**
89
+ * One map per page, because this module is a shared singleton. Keyed by federation
90
+ * scope, which is the only identity the host and the package agree on.
91
+ */
92
+ const delivered = new Map();
93
+
94
+ /** Order-independent: vars are flat, one level of string/number/undefined. */
95
+ const same = (a, b) => {
96
+ const keys = new Set([...Object.keys(a), ...Object.keys(b)]);
97
+ return [...keys].every(key => a[key] === b[key]);
98
+ };
99
+
100
+ /**
101
+ * Delivers a scope's vars. Called by `@appshell/loader` immediately before the remote
102
+ * is loaded, so they are in place before the package's modules evaluate.
103
+ *
104
+ * The first write for a scope wins and is frozen. Re-delivering the identical vars is a
105
+ * no-op — the same remote can be mounted more than once — but replacing them throws.
106
+ * That is what keeps one package from overwriting another's: by the time any package
107
+ * evaluates, the host has already written for it.
108
+ *
109
+ * It does not make a scope's vars *private*. Any code on the page can still read another
110
+ * scope by name, and nothing short of a separate realm would change that.
111
+ */
112
+ const setVars = (scope, vars) => {
113
+ const existing = delivered.get(scope);
114
+ if (existing) {
115
+ if (!same(existing, vars)) {
116
+ throw new _errors__WEBPACK_IMPORTED_MODULE_0__.VarsConflictError(scope);
117
+ }
118
+ return;
119
+ }
120
+ delivered.set(scope, Object.freeze({
121
+ ...vars
122
+ }));
123
+ };
124
+
125
+ /**
126
+ * Reads a scope's vars, throwing rather than handing back an empty object — a package
127
+ * that silently renders with no configuration is the failure this replaced.
128
+ *
129
+ * Prefer `getVars()` from `@appshell/vars`, which supplies the scope for you.
130
+ */
131
+ const readVars = scope => {
132
+ const vars = delivered.get(scope);
133
+ if (!vars) {
134
+ throw new _errors__WEBPACK_IMPORTED_MODULE_0__.MissingVarsError(scope, [...delivered.keys()]);
135
+ }
136
+ return vars;
137
+ };
138
+
139
+ /** Whether a scope has been delivered, for callers that want to branch instead of catch. */
140
+ const hasVars = scope => delivered.has(scope);
141
+
142
+ /** Test seam. Not part of the contract a package should build on. */
143
+ const resetVars = () => {
144
+ delivered.clear();
145
+ };
146
+
147
+ /***/ }
148
+
149
+ }]);
150
+ //# 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;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,C;;;;;;;;;;;;;;;;;;;;;ACjD+D;;;;;;;;;;;;;;;;;;;ACAA;AAG/D;AACA;AACA;AACA;AACA,MAAMY,SAAS,GAAG,IAAIC,GAAG,CAAyB,CAAC;;AAEnD;AACA,MAAMC,IAAI,GAAGA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AAS,CAACgB,KAAK,CAAC,CAAC;AACnB,CAAC,C","sources":["webpack://appshell-react-shell/../runtime/src/errors.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","export { MissingVarsError, VarsConflictError } from './errors';\nexport { hasVars, readVars, resetVars, setVars } from './store';\nexport type { Vars } from './types';\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/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","hasVars","readVars","resetVars","setVars","delivered","Map","same","a","b","keys","Set","Object","every","key","vars","existing","get","set","freeze","has","clear"],"sourceRoot":""}