@appshell/loader 1.0.0-alpha.9 → 1.0.0-alpha.91

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 (97) hide show
  1. package/README.md +19 -21
  2. package/dist/main.js +1 -1
  3. package/dist/types/config/src/axios.d.ts +0 -1
  4. package/dist/types/config/src/configmap.d.ts +0 -1
  5. package/dist/types/config/src/context.d.ts +3 -4
  6. package/dist/types/config/src/credentials.d.ts +35 -3
  7. package/dist/types/config/src/generate.manifest.d.ts +30 -2
  8. package/dist/types/config/src/index.d.ts +9 -10
  9. package/dist/types/config/src/loader.d.ts +18 -0
  10. package/dist/types/config/src/mappers/appshell.config.d.ts +9 -3
  11. package/dist/types/config/src/outdated.d.ts +0 -1
  12. package/dist/types/config/src/package-name.d.ts +20 -0
  13. package/dist/types/config/src/publish.d.ts +89 -7
  14. package/dist/types/config/src/sync.d.ts +0 -1
  15. package/dist/types/config/src/tls.d.ts +23 -0
  16. package/dist/types/config/src/types.d.ts +164 -30
  17. package/dist/types/config/src/utils/blur.d.ts +0 -1
  18. package/dist/types/config/src/utils/compare.d.ts +0 -1
  19. package/dist/types/config/src/utils/config.d.ts +0 -1
  20. package/dist/types/config/src/utils/copy.d.ts +0 -1
  21. package/dist/types/config/src/utils/dump.d.ts +10 -0
  22. package/dist/types/config/src/utils/index.d.ts +1 -4
  23. package/dist/types/config/src/utils/list.d.ts +0 -1
  24. package/dist/types/config/src/utils/load.d.ts +0 -1
  25. package/dist/types/config/src/validators/AppshellTemplateValidator.d.ts +0 -1
  26. package/dist/types/config/src/validators/index.d.ts +0 -3
  27. package/dist/types/loader/src/index.d.ts +0 -1
  28. package/dist/types/loader/src/loadAppshellComponent.d.ts +13 -14
  29. package/dist/types/loader/src/remoteLoader.d.ts +2 -3
  30. package/dist/types/loader/src/resolvers.d.ts +4 -12
  31. package/dist/types/loader/src/types.d.ts +0 -1
  32. package/dist/types/runtime/src/errors.d.ts +32 -0
  33. package/dist/types/runtime/src/identity.d.ts +47 -0
  34. package/dist/types/runtime/src/index.d.ts +6 -0
  35. package/dist/types/runtime/src/store.d.ts +25 -0
  36. package/dist/types/runtime/src/types.d.ts +9 -0
  37. package/dist/types/runtime/src/wire.d.ts +58 -0
  38. package/package.json +15 -4
  39. package/CHANGELOG.md +0 -197
  40. package/__tests__/fetchDynamicScript.spec.ts +0 -44
  41. package/__tests__/fixtures/TestComponent.ts +0 -3
  42. package/__tests__/loadAppshellComponent.spec.ts +0 -102
  43. package/__tests__/remoteLoader.spec.ts +0 -144
  44. package/__tests__/resolvers.spec.ts +0 -128
  45. package/dist/types/config/src/axios.d.ts.map +0 -1
  46. package/dist/types/config/src/configmap.d.ts.map +0 -1
  47. package/dist/types/config/src/context.d.ts.map +0 -1
  48. package/dist/types/config/src/credentials.d.ts.map +0 -1
  49. package/dist/types/config/src/deregister.d.ts +0 -3
  50. package/dist/types/config/src/deregister.d.ts.map +0 -1
  51. package/dist/types/config/src/generate.env.d.ts +0 -3
  52. package/dist/types/config/src/generate.env.d.ts.map +0 -1
  53. package/dist/types/config/src/generate.global-config.d.ts +0 -10
  54. package/dist/types/config/src/generate.global-config.d.ts.map +0 -1
  55. package/dist/types/config/src/generate.manifest.d.ts.map +0 -1
  56. package/dist/types/config/src/index.d.ts.map +0 -1
  57. package/dist/types/config/src/mappers/appshell.config.d.ts.map +0 -1
  58. package/dist/types/config/src/outdated.d.ts.map +0 -1
  59. package/dist/types/config/src/publish.d.ts.map +0 -1
  60. package/dist/types/config/src/register.d.ts +0 -4
  61. package/dist/types/config/src/register.d.ts.map +0 -1
  62. package/dist/types/config/src/sync.d.ts.map +0 -1
  63. package/dist/types/config/src/types.d.ts.map +0 -1
  64. package/dist/types/config/src/utils/blur.d.ts.map +0 -1
  65. package/dist/types/config/src/utils/compare.d.ts.map +0 -1
  66. package/dist/types/config/src/utils/config.d.ts.map +0 -1
  67. package/dist/types/config/src/utils/copy.d.ts.map +0 -1
  68. package/dist/types/config/src/utils/index.d.ts.map +0 -1
  69. package/dist/types/config/src/utils/isValidUrl.d.ts +0 -3
  70. package/dist/types/config/src/utils/isValidUrl.d.ts.map +0 -1
  71. package/dist/types/config/src/utils/list.d.ts.map +0 -1
  72. package/dist/types/config/src/utils/load.d.ts.map +0 -1
  73. package/dist/types/config/src/utils/loadJson.d.ts +0 -10
  74. package/dist/types/config/src/utils/loadJson.d.ts.map +0 -1
  75. package/dist/types/config/src/utils/merge.d.ts +0 -4
  76. package/dist/types/config/src/utils/merge.d.ts.map +0 -1
  77. package/dist/types/config/src/validators/AppshellGlobalConfigValidator.d.ts +0 -4
  78. package/dist/types/config/src/validators/AppshellGlobalConfigValidator.d.ts.map +0 -1
  79. package/dist/types/config/src/validators/AppshellManifestValidator.d.ts +0 -4
  80. package/dist/types/config/src/validators/AppshellManifestValidator.d.ts.map +0 -1
  81. package/dist/types/config/src/validators/AppshellTemplateValidator.d.ts.map +0 -1
  82. package/dist/types/config/src/validators/index.d.ts.map +0 -1
  83. package/dist/types/loader/src/fetchDynamicScript.d.ts +0 -3
  84. package/dist/types/loader/src/fetchDynamicScript.d.ts.map +0 -1
  85. package/dist/types/loader/src/index.d.ts.map +0 -1
  86. package/dist/types/loader/src/loadAppshellComponent.d.ts.map +0 -1
  87. package/dist/types/loader/src/remoteLoader.d.ts.map +0 -1
  88. package/dist/types/loader/src/resolvers.d.ts.map +0 -1
  89. package/dist/types/loader/src/types.d.ts.map +0 -1
  90. package/src/fetchDynamicScript.ts +0 -49
  91. package/src/index.ts +0 -7
  92. package/src/loadAppshellComponent.ts +0 -48
  93. package/src/remoteLoader.ts +0 -80
  94. package/src/resolvers.ts +0 -110
  95. package/src/types.ts +0 -10
  96. package/tsconfig.json +0 -7
  97. package/webpack.config.js +0 -37
package/package.json CHANGED
@@ -1,10 +1,13 @@
1
1
  {
2
2
  "name": "@appshell/loader",
3
- "version": "1.0.0-alpha.9",
3
+ "version": "1.0.0-alpha.91",
4
4
  "description": "Utility for loading Appshell components",
5
5
  "main": "dist/main.js",
6
6
  "types": "dist/loader/src/index.d.ts",
7
- "repository": "https://github.com/appshell-org/appshell.git",
7
+ "repository": {
8
+ "type": "git",
9
+ "url": "git+https://github.com/appshellhq/appshell.git"
10
+ },
8
11
  "author": "Robert Hamilton <rh@navaris.com>",
9
12
  "publishConfig": {
10
13
  "access": "public",
@@ -16,13 +19,21 @@
16
19
  "clean": "rm -rf dist",
17
20
  "prebuild": "npm run clean",
18
21
  "start": "webpack --watch --mode development && npm run build:types",
19
- "stats": "webpack --json > stats.json"
22
+ "stats": "webpack --json > stats.json",
23
+ "typecheck": "tsc --noEmit"
20
24
  },
25
+ "files": [
26
+ "dist"
27
+ ],
21
28
  "keywords": [
22
29
  "module federation",
23
30
  "micro-frontends",
24
31
  "appshell"
25
32
  ],
26
33
  "license": "MIT",
27
- "gitHead": "dd1cd33cf2f014563438d29a004ce7939e65dacb"
34
+ "dependencies": {
35
+ "@appshell/runtime": "^1.0.0-alpha.91",
36
+ "@module-federation/enhanced": "^2.8.2"
37
+ },
38
+ "gitHead": "beb3e1dc02a4c32424f163da35e9ce43ee3bdb82"
28
39
  }
package/CHANGELOG.md DELETED
@@ -1,197 +0,0 @@
1
- # Change Log
2
-
3
- All notable changes to this project will be documented in this file.
4
- See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5
-
6
- # [1.0.0-alpha.9](https://github.com/appshell-org/appshell/compare/v1.0.0-alpha.8...v1.0.0-alpha.9) (2026-08-19)
7
-
8
- ### Bug Fixes
9
-
10
- - **example:** resolve CSP/module-federation issues blocking local dev ([f8de4e1](https://github.com/appshell-org/appshell/commit/f8de4e1cfe495a7d4ae8e6374189384847c21309))
11
-
12
- # [1.0.0-alpha.8](https://github.com/appshell-org/appshell/compare/v1.0.0-alpha.7...v1.0.0-alpha.8) (2026-08-19)
13
-
14
- **Note:** Version bump only for package @appshell/loader
15
-
16
- # [1.0.0-alpha.7](https://github.com/appshell-org/appshell/compare/v1.0.0-alpha.6...v1.0.0-alpha.7) (2026-08-18)
17
-
18
- **Note:** Version bump only for package @appshell/loader
19
-
20
- **Note:** Version bump only for package @appshell/loader
21
-
22
- # [1.0.0-alpha.6](https://github.com/appshell-org/appshell/compare/v1.0.0-alpha.5...v1.0.0-alpha.6) (2026-08-18)
23
-
24
- **Note:** Version bump only for package @appshell/loader
25
-
26
- # [1.0.0-alpha.5](https://github.com/appshell-org/appshell/compare/v1.0.0-alpha.4...v1.0.0-alpha.5) (2026-08-18)
27
-
28
- **Note:** Version bump only for package @appshell/loader
29
-
30
- **Note:** Version bump only for package @appshell/loader
31
-
32
- # [1.0.0-alpha.4](https://github.com/appshell-org/appshell/compare/v1.0.0-alpha.3...v1.0.0-alpha.4) (2026-08-18)
33
-
34
- **Note:** Version bump only for package @appshell/loader
35
-
36
- **Note:** Version bump only for package @appshell/loader
37
-
38
- # [1.0.0-alpha.3](https://github.com/appshell-org/appshell/compare/v1.0.0-alpha.2...v1.0.0-alpha.3) (2026-08-18)
39
-
40
- **Note:** Version bump only for package @appshell/loader
41
-
42
- # 0.12.0-alpha.0 (2026-04-20)
43
-
44
- ### Bug Fixes
45
-
46
- - appshell loader override check ([aedda4a](https://github.com/appshell-org/appshell/commit/aedda4abf81560297dce03df09fba68e8785242f))
47
- - configurable api key header support, minor fixes ([2f0bf02](https://github.com/appshell-org/appshell/commit/2f0bf027b92398f91b8e8cbfbf543d61fe37b7a0))
48
- - hot module replacement support, example updates ([a67d230](https://github.com/appshell-org/appshell/commit/a67d2303b40f5911373225cc0b4ccf9b67c33d11))
49
- - registry projection, enable env overwrite, refactor docker workflow, consolidate env names ([33a28fe](https://github.com/appshell-org/appshell/commit/33a28fe76b58e05c5b6b6b33d4b402e52bb29e70))
50
- - rename @appshell/react-federated-component package to @appshell/react ([0b74498](https://github.com/appshell-org/appshell/commit/0b74498bf17ba73db4d936c8a012af1d3b111a28))
51
- - replace config intermediate file with template ([9b79e65](https://github.com/appshell-org/appshell/commit/9b79e65b355686a0cca273c89c7164bb031e8437))
52
- - update repository URLs from navaris/appshell to appshell-org/appshell ([506a90d](https://github.com/appshell-org/appshell/commit/506a90d94a6f6e10f463987d408550f48624bfd0))
53
-
54
- ### Features
55
-
56
- - api key support ([9cdcbee](https://github.com/appshell-org/appshell/commit/9cdcbee36e44b8a179b49768d74a25767f1cc5f2))
57
- - appshell cli api key support, init sync and outdated commands ([#6](https://github.com/appshell-org/appshell/issues/6)) ([acc5fa2](https://github.com/appshell-org/appshell/commit/acc5fa234f91a167038161d5080481c43f8eb8b4))
58
- - AppshellComponent impl ([2b82621](https://github.com/appshell-org/appshell/commit/2b82621c13302f790a8e1c457f9a82f39903fc1f))
59
- - consolidate runtime artifacts ([#26](https://github.com/appshell-org/appshell/issues/26)) ([a29479a](https://github.com/appshell-org/appshell/commit/a29479a49f0c5ec1273c9f8e4c7384096f2d4ba0))
60
- - environment variable override for federated components ([#27](https://github.com/appshell-org/appshell/issues/27)) ([d32de0b](https://github.com/appshell-org/appshell/commit/d32de0b0d1cbb1792715e1b363c80ed4600df155))
61
- - foundation refactor wip ([339b930](https://github.com/appshell-org/appshell/commit/339b9306accaa9aba1712f3a0dee6c4cab7ed273))
62
-
63
- ## [0.5.1-alpha.0](https://github.com/appshell-org/appshell/compare/@appshell/loader@0.5.0...@appshell/loader@0.5.1-alpha.0) (2026-04-20)
64
-
65
- ### Bug Fixes
66
-
67
- - update repository URLs from navaris/appshell to appshell-org/appshell ([506a90d](https://github.com/appshell-org/appshell/commit/506a90d94a6f6e10f463987d408550f48624bfd0))
68
-
69
- # [0.5.0](https://github.com/navaris/appshell/compare/@appshell/loader@0.4.0...@appshell/loader@0.5.0) (2025-08-12)
70
-
71
- ### Bug Fixes
72
-
73
- - configurable api key header support, minor fixes ([2f0bf02](https://github.com/navaris/appshell/commit/2f0bf027b92398f91b8e8cbfbf543d61fe37b7a0))
74
-
75
- ### Features
76
-
77
- - appshell cli api key support, init sync and outdated commands ([#6](https://github.com/navaris/appshell/issues/6)) ([acc5fa2](https://github.com/navaris/appshell/commit/acc5fa234f91a167038161d5080481c43f8eb8b4))
78
-
79
- # [0.5.0-alpha.0](https://github.com/navaris/appshell/compare/@appshell/loader@0.4.0...@appshell/loader@0.5.0-alpha.0) (2025-08-10)
80
-
81
- ### Bug Fixes
82
-
83
- - include credentials when fetching the manifests ([4e0ee79](https://github.com/navaris/appshell/commit/4e0ee79b4ba93d34fd6a0e1a5f6bf2fc9f3994cc))
84
-
85
- ### Features
86
-
87
- - appshell cli api key support, init sync and outdated commands ([#6](https://github.com/navaris/appshell/issues/6)) ([acc5fa2](https://github.com/navaris/appshell/commit/acc5fa234f91a167038161d5080481c43f8eb8b4))
88
-
89
- # [0.4.0](https://github.com/navaris/appshell/compare/@appshell/loader@0.3.0...@appshell/loader@0.4.0) (2024-09-24)
90
-
91
- ### Features
92
-
93
- - api key support ([9cdcbee](https://github.com/navaris/appshell/commit/9cdcbee36e44b8a179b49768d74a25767f1cc5f2))
94
-
95
- # [0.4.0-alpha.0](https://github.com/navaris/appshell/compare/@appshell/loader@0.3.1-alpha.0...@appshell/loader@0.4.0-alpha.0) (2024-09-05)
96
-
97
- ### Features
98
-
99
- - api key support ([8c91e62](https://github.com/navaris/appshell/commit/8c91e6240b3d879af9bdd5949924865da0e0f8a1))
100
-
101
- ## [0.3.1-alpha.0](https://github.com/navaris/appshell/compare/@appshell/loader@0.3.0...@appshell/loader@0.3.1-alpha.0) (2024-08-31)
102
-
103
- ### Bug Fixes
104
-
105
- - bump pipeline ([8bb63bc](https://github.com/navaris/appshell/commit/8bb63bcae1928c01bb6bc853d88010939e686af5))
106
-
107
- # [0.3.0](https://github.com/navaris/appshell/compare/@appshell/loader@0.2.1...@appshell/loader@0.3.0) (2024-01-25)
108
-
109
- ### Features
110
-
111
- - AppshellComponent impl ([2b82621](https://github.com/navaris/appshell/commit/2b82621c13302f790a8e1c457f9a82f39903fc1f))
112
-
113
- ## [0.2.1](https://github.com/navaris/appshell/compare/@appshell/loader@0.2.0...@appshell/loader@0.2.1) (2023-08-29)
114
-
115
- ### Bug Fixes
116
-
117
- - appshell loader override check ([aedda4a](https://github.com/navaris/appshell/commit/aedda4abf81560297dce03df09fba68e8785242f))
118
-
119
- # [0.2.0](https://github.com/navaris/appshell/compare/@appshell/loader@0.2.0-alpha.1...@appshell/loader@0.2.0) (2023-08-28)
120
-
121
- **Note:** Version bump only for package @appshell/loader
122
-
123
- # [0.2.0-alpha.1](https://github.com/navaris/appshell/compare/@appshell/loader@0.2.0-alpha.0...@appshell/loader@0.2.0-alpha.1) (2023-08-28)
124
-
125
- ### Features
126
-
127
- - environment variable override for federated components ([#27](https://github.com/navaris/appshell/issues/27)) ([d32de0b](https://github.com/navaris/appshell/commit/d32de0b0d1cbb1792715e1b363c80ed4600df155))
128
-
129
- # [0.2.0-alpha.0](https://github.com/navaris/appshell/compare/@appshell/loader@0.1.0...@appshell/loader@0.2.0-alpha.0) (2023-08-23)
130
-
131
- ### Features
132
-
133
- - consolidate runtime artifacts ([#26](https://github.com/navaris/appshell/issues/26)) ([a29479a](https://github.com/navaris/appshell/commit/a29479a49f0c5ec1273c9f8e4c7384096f2d4ba0))
134
-
135
- # [0.1.0](https://github.com/navaris/appshell/compare/@appshell/loader@0.1.0-alpha.1...@appshell/loader@0.1.0) (2023-07-11)
136
-
137
- ### Bug Fixes
138
-
139
- - registry projection, enable env overwrite, refactor docker workflow, consolidate env names ([33a28fe](https://github.com/navaris/appshell/commit/33a28fe76b58e05c5b6b6b33d4b402e52bb29e70))
140
- - rename @appshell/react-federated-component package to @appshell/react ([0b74498](https://github.com/navaris/appshell/commit/0b74498bf17ba73db4d936c8a012af1d3b111a28))
141
- - replace config intermediate file with template ([9b79e65](https://github.com/navaris/appshell/commit/9b79e65b355686a0cca273c89c7164bb031e8437))
142
-
143
- # [0.1.0-alpha.1](https://github.com/navaris/appshell/compare/@appshell/loader@0.0.3...@appshell/loader@0.1.0-alpha.1) (2023-07-05)
144
-
145
- ### Features
146
-
147
- - foundation refactor wip ([339b930](https://github.com/navaris/appshell/commit/339b9306accaa9aba1712f3a0dee6c4cab7ed273))
148
-
149
- # [0.1.0-alpha.0](https://github.com/navaris/appshell/compare/@appshell/loader@0.0.3...@appshell/loader@0.1.0-alpha.0) (2023-07-05)
150
-
151
- ### Features
152
-
153
- - registry index ([8e6ee0a](https://github.com/navaris/appshell/commit/8e6ee0a6a377584efa2ee702168025f46108b8c5))
154
-
155
- ## [0.0.3](https://github.com/navaris/appshell/compare/@appshell/loader@0.0.3-alpha.2...@appshell/loader@0.0.3) (2023-06-29)
156
-
157
- **Note:** Version bump only for package @appshell/loader
158
-
159
- ## [0.0.3-alpha.2](https://github.com/navaris/appshell/compare/@appshell/loader@0.0.2...@appshell/loader@0.0.3-alpha.2) (2023-06-29)
160
-
161
- **Note:** Version bump only for package @appshell/loader
162
-
163
- ## [0.0.3-alpha.1](https://github.com/navaris/appshell/compare/@appshell/loader@0.0.3-alpha.0...@appshell/loader@0.0.3-alpha.1) (2023-06-29)
164
-
165
- ### Bug Fixes
166
-
167
- - update npm package visibility ([1ef4119](https://github.com/navaris/appshell/commit/1ef411903dd038dfc781e8ce0700811e5460c903))
168
-
169
- ## [0.0.3-alpha.0](https://github.com/navaris/appshell/compare/@appshell/loader@0.0.2-alpha.0...@appshell/loader@0.0.3-alpha.0) (2023-06-29)
170
-
171
- **Note:** Version bump only for package @appshell/loader
172
-
173
- ## [0.0.2](https://github.com/navaris/appshell/compare/@appshell/loader@0.0.2-alpha.0...@appshell/loader@0.0.2) (2023-06-29)
174
-
175
- **Note:** Version bump only for package @appshell/loader
176
-
177
- ## [0.0.2-alpha.0](https://github.com/navaris/appshell/compare/@appshell/loader@0.0.1...@appshell/loader@0.0.2-alpha.0) (2023-06-15)
178
-
179
- ### Bug Fixes
180
-
181
- - hot module replacement support, example updates ([a67d230](https://github.com/navaris/appshell/commit/a67d2303b40f5911373225cc0b4ccf9b67c33d11))
182
-
183
- =======
184
-
185
- ## 0.0.1 (2023-06-15)
186
-
187
- **Note:** Version bump only for package @appshell/loader
188
-
189
- ## [0.0.1-alpha.1](https://github.com/navaris/appshell/compare/@appshell/loader@0.0.1-alpha.0...@appshell/loader@0.0.1-alpha.1) (2023-06-15)
190
-
191
- ### Bug Fixes
192
-
193
- - hot module replacement support, example updates ([a67d230](https://github.com/navaris/appshell/commit/a67d2303b40f5911373225cc0b4ccf9b67c33d11))
194
-
195
- ## 0.0.1-alpha.0 (2023-03-19)
196
-
197
- **Note:** Version bump only for package @appshell/loader
@@ -1,44 +0,0 @@
1
- /** @jest-environment jsdom */
2
- import { fireEvent } from '@testing-library/react';
3
- import fetchDynamicScript from '../src/fetchDynamicScript';
4
-
5
- const mockHead = (event: string) => {
6
- const appendChildSpy = jest.spyOn(document.head, 'appendChild').mockImplementation((element) => {
7
- fireEvent(element, new Event(event));
8
- return element;
9
- });
10
- const removeChildSpy = jest.spyOn(document.head, 'removeChild').mockReturnThis();
11
- const containsSpy = jest.spyOn(document.head, 'contains').mockReturnValue(true);
12
-
13
- return [appendChildSpy, removeChildSpy, containsSpy];
14
- };
15
-
16
- describe('fetchDynamicScript', () => {
17
- afterEach(() => {
18
- jest.resetAllMocks();
19
- });
20
-
21
- it('should successfully resolve when valid script url is provided', async () => {
22
- mockHead('load');
23
- const url = 'http://test.com/1/somescript.js';
24
- const success = await fetchDynamicScript(url);
25
-
26
- expect(success).toBe(true);
27
- });
28
-
29
- it('should reject when fetching the script results in an error', async () => {
30
- mockHead('error');
31
- const url = 'http://test.com/2/somescript.js';
32
-
33
- await expect(fetchDynamicScript(url)).rejects.toMatch(/Failed to fetch remote entry/i);
34
- });
35
-
36
- it('should cleanup script tags when finished', async () => {
37
- const [appendChildSpy, removeChildSpy] = mockHead('load');
38
- const url = 'http://test.com/3/somescript.js';
39
- await fetchDynamicScript(url);
40
-
41
- expect(appendChildSpy).toHaveBeenCalled();
42
- expect(removeChildSpy).toHaveBeenCalled();
43
- });
44
- });
@@ -1,3 +0,0 @@
1
- const TestComponent = () => 'test component';
2
-
3
- export default TestComponent;
@@ -1,102 +0,0 @@
1
- /** @jest-environment jsdom */
2
- /* eslint-disable no-underscore-dangle */
3
- import loadAppshellComponent from '../src/loadAppshellComponent';
4
- import { ModuleContainer, ShareScope } from '../src/types';
5
-
6
- type ComponentType = () => string;
7
-
8
- const TestComponent = () => 'test component';
9
- const mockModule = {
10
- './TestComponent': {
11
- get: jest.fn(),
12
- from: '',
13
- eager: false,
14
- },
15
- };
16
- const scopes: Record<string, ShareScope<ComponentType>> = {
17
- default: {
18
- TestModule: mockModule,
19
- },
20
- test_scope: {
21
- TestModule2: mockModule,
22
- },
23
- no_factory: {
24
- TestModule3: mockModule,
25
- },
26
- };
27
- const containers: Record<string, Record<string, ModuleContainer<ComponentType>>> = {
28
- default: {
29
- TestModule: {
30
- init: jest.fn(),
31
- get: jest.fn().mockReturnValue(() => ({
32
- default: TestComponent,
33
- })),
34
- },
35
- },
36
- test_scope: {
37
- TestModule2: {
38
- init: jest.fn(),
39
- get: jest.fn().mockReturnValue(() => ({
40
- test_scope: TestComponent,
41
- })),
42
- },
43
- },
44
- no_factory: {
45
- TestModule3: {
46
- init: jest.fn(),
47
- get: jest.fn().mockReturnValue(undefined),
48
- },
49
- },
50
- };
51
-
52
- describe('loadAppshellComponent', () => {
53
- beforeEach(() => {
54
- window.__webpack_init_sharing__ = jest.fn(async (shareScope: string) => {
55
- // eslint-disable-next-line @typescript-eslint/dot-notation
56
- Object.entries(containers[shareScope] || {}).forEach(([key, module]) => {
57
- window[key] = module;
58
- });
59
- window.__webpack_share_scopes__ = {};
60
- window.__webpack_share_scopes__[shareScope] = scopes[shareScope];
61
- });
62
- });
63
-
64
- afterEach(() => {
65
- Object.values(window.__webpack_share_scopes__ || {})
66
- .flatMap((val) => Object.keys(val || {}))
67
- .forEach((key) => {
68
- delete window[key];
69
- });
70
- window.__webpack_share_scopes__ = {};
71
- });
72
-
73
- it('should load the Appshell component from the default scope', async () => {
74
- const scope = 'TestModule';
75
- const module = './TestComponent';
76
- const shareScope = undefined;
77
-
78
- const Component = await loadAppshellComponent<ComponentType>(scope, module, shareScope);
79
-
80
- expect(Component).toBe(TestComponent);
81
- });
82
-
83
- it('should throw if the share scope does not exist', async () => {
84
- const scope = 'TestModule';
85
- const module = './TestComponent';
86
- const shareScope = 'does_not_exist';
87
-
88
- await expect(loadAppshellComponent<ComponentType>(scope, module, shareScope)).rejects.toThrow(
89
- /Failed to find module container/i,
90
- );
91
- });
92
-
93
- it('should throw if the module factory does not exist', async () => {
94
- const scope = 'TestModule3';
95
- const module = './TestComponent';
96
- const shareScope = 'no_factory';
97
-
98
- await expect(loadAppshellComponent<ComponentType>(scope, module, shareScope)).rejects.toThrow(
99
- /Invalid factory produced/i,
100
- );
101
- });
102
- });
@@ -1,144 +0,0 @@
1
- /** @jest-environment jsdom */
2
- import { AppshellGlobalConfig, AppshellManifest } from '@appshell/config';
3
- import fetch, { enableFetchMocks } from 'jest-fetch-mock';
4
- import * as fetchDynamicScript from '../src/fetchDynamicScript';
5
- import * as loadAppshellComponent from '../src/loadAppshellComponent';
6
- import remoteLoader from '../src/remoteLoader';
7
-
8
- enableFetchMocks();
9
-
10
- jest.mock('../src/fetchDynamicScript');
11
- jest.mock('../src/loadAppshellComponent');
12
-
13
- describe('remoteLoader', () => {
14
- const manifest: AppshellManifest = {
15
- remotes: {
16
- 'TestModule/TestComponent': {
17
- id: 'test-component',
18
- scope: 'TestModule',
19
- module: './TestComponent',
20
- manifestUrl: 'http://test.com/appshell.manifest.json',
21
- remoteEntryUrl: 'http://test.com/remoteEntry.js',
22
- metadata: {},
23
- },
24
- },
25
- modules: {},
26
- environment: {
27
- TestModule: {
28
- ENV_VAR_A: 'Original value for A',
29
- },
30
- },
31
- };
32
- const config: AppshellGlobalConfig = {
33
- index: {
34
- 'TestModule/TestComponent': 'http://test.com/appshell.manifest.json',
35
- },
36
- metadata: {},
37
- overrides: {
38
- environment: {
39
- TestModule: {
40
- ENV_VAR_A: 'New value for A',
41
- },
42
- },
43
- },
44
- };
45
-
46
- beforeEach(() => {
47
- fetch.mockIf('http://test.com/appshell.manifest.json', () =>
48
- Promise.resolve({ ok: true, body: JSON.stringify(manifest) }),
49
- );
50
- });
51
-
52
- it('should return the Appshell component if it is found in the registry', async () => {
53
- const ExpectedComponent = () => 'test component';
54
- jest.spyOn(fetchDynamicScript, 'default').mockReturnValueOnce(Promise.resolve(true));
55
- jest
56
- .spyOn(loadAppshellComponent, 'default')
57
- .mockResolvedValue(Promise.resolve(ExpectedComponent));
58
-
59
- const loadRemote = remoteLoader(config);
60
- const [ActualComponent, actualManifest] = await loadRemote('TestModule/TestComponent');
61
-
62
- expect(ActualComponent).toEqual(ExpectedComponent);
63
- expect(actualManifest).toEqual(manifest);
64
- });
65
-
66
- it('should not fetch remote entry more than once', async () => {
67
- const ExpectedComponent = () => 'test component';
68
- const fetchDynamicScriptSpy = jest
69
- .spyOn(fetchDynamicScript, 'default')
70
- .mockReturnValueOnce(Promise.resolve(true));
71
- jest
72
- .spyOn(loadAppshellComponent, 'default')
73
- .mockResolvedValue(Promise.resolve(ExpectedComponent));
74
-
75
- const loadRemote = remoteLoader(config);
76
-
77
- await loadRemote('TestModule/TestComponent');
78
- await loadRemote('TestModule/TestComponent');
79
- await loadRemote('TestModule/TestComponent');
80
-
81
- expect(fetchDynamicScriptSpy).toHaveBeenCalledTimes(1);
82
- });
83
-
84
- it('should apply overridden environment values', async () => {
85
- const ExpectedComponent = () => 'test component';
86
- jest.spyOn(fetchDynamicScript, 'default').mockReturnValueOnce(Promise.resolve(true));
87
- jest
88
- .spyOn(loadAppshellComponent, 'default')
89
- .mockResolvedValue(Promise.resolve(ExpectedComponent));
90
-
91
- const loadRemote = remoteLoader(config);
92
-
93
- await loadRemote('TestModule/TestComponent');
94
-
95
- // eslint-disable-next-line no-underscore-dangle
96
- expect(window.__appshell_env__TestModule).toMatchObject({ ENV_VAR_A: 'New value for A' });
97
- });
98
-
99
- it('should throw if remote key is not found in the registry', async () => {
100
- const ExpectedComponent = () => 'test component';
101
- jest.spyOn(loadAppshellComponent, 'default').mockResolvedValue(ExpectedComponent);
102
-
103
- const loadRemote = remoteLoader(config);
104
-
105
- await expect(loadRemote('TestModule/DoesNotExist')).rejects.toThrow(
106
- /Remote resource not found in registry/i,
107
- );
108
- });
109
-
110
- it('should throw if load Appshell component fails', async () => {
111
- jest.spyOn(fetchDynamicScript, 'default').mockReturnValueOnce(Promise.resolve(true));
112
- jest.spyOn(loadAppshellComponent, 'default').mockRejectedValue(new Error('failed'));
113
-
114
- const loadRemote = remoteLoader(config);
115
-
116
- await expect(loadRemote('TestModule/TestComponent')).rejects.toThrow(
117
- /Failed to load component/i,
118
- );
119
- });
120
-
121
- it('should load from an inlined composition without fetching a manifest', async () => {
122
- const ExpectedComponent = () => 'test component';
123
- jest.spyOn(fetchDynamicScript, 'default').mockReturnValueOnce(Promise.resolve(true));
124
- jest.spyOn(loadAppshellComponent, 'default').mockResolvedValue(ExpectedComponent);
125
- fetch.resetMocks();
126
-
127
- const loadRemote = remoteLoader(config, {
128
- composition: {
129
- environmentId: 'acme/dev',
130
- revision: 1,
131
- index: config.index,
132
- remotes: manifest.remotes,
133
- environment: { TestModule: { ENV_VAR_A: 'Composed value for A' } },
134
- },
135
- });
136
- const [ActualComponent, actualManifest] = await loadRemote('TestModule/TestComponent');
137
-
138
- expect(fetch).not.toHaveBeenCalled();
139
- expect(ActualComponent).toEqual(ExpectedComponent);
140
- expect(actualManifest?.modules).toEqual({});
141
- // eslint-disable-next-line no-underscore-dangle
142
- expect(window.__appshell_env__TestModule).toEqual({ ENV_VAR_A: 'Composed value for A' });
143
- });
144
- });
@@ -1,128 +0,0 @@
1
- /** @jest-environment jsdom */
2
- import { AppshellComposition, AppshellGlobalConfig, AppshellManifest } from '@appshell/config';
3
- import fetch, { enableFetchMocks } from 'jest-fetch-mock';
4
- import {
5
- chainResolvers,
6
- inlineResolver,
7
- legacyManifestResolver,
8
- registryResolver,
9
- } from '../src/resolvers';
10
-
11
- enableFetchMocks();
12
-
13
- const MANIFEST_URL = 'http://test.com/appshell.manifest.json';
14
- const KEY = 'TestModule/TestComponent';
15
-
16
- const manifest: AppshellManifest = {
17
- remotes: {
18
- [KEY]: {
19
- id: 'test-component',
20
- scope: 'TestModule',
21
- module: './TestComponent',
22
- manifestUrl: MANIFEST_URL,
23
- remoteEntryUrl: 'http://test.com/remoteEntry.js',
24
- metadata: { title: 'Test' },
25
- },
26
- },
27
- modules: { TestModule: { name: 'TestModule' } },
28
- environment: { TestModule: { ENV_VAR_A: 'Original value for A' } },
29
- };
30
-
31
- const config: AppshellGlobalConfig = { index: { [KEY]: MANIFEST_URL } };
32
-
33
- const composition: AppshellComposition = {
34
- environmentId: 'acme/dev',
35
- revision: 7,
36
- index: config.index,
37
- remotes: manifest.remotes,
38
- environment: manifest.environment,
39
- };
40
-
41
- beforeEach(() => {
42
- fetch.resetMocks();
43
- });
44
-
45
- describe('inlineResolver', () => {
46
- it('resolves without any network call', async () => {
47
- const resolution = await inlineResolver(composition)(KEY);
48
-
49
- expect(fetch).not.toHaveBeenCalled();
50
- expect(resolution?.remote).toEqual(manifest.remotes[KEY]);
51
- expect(resolution?.environment).toEqual({ ENV_VAR_A: 'Original value for A' });
52
- });
53
-
54
- it('yields to the next resolver when the key is absent', async () => {
55
- await expect(inlineResolver(composition)('Other/Key')).resolves.toBeUndefined();
56
- await expect(inlineResolver(undefined)(KEY)).resolves.toBeUndefined();
57
- });
58
-
59
- // Locks the claim that the synthesized manifest is a drop-in for `ManifestProvider`.
60
- it('synthesizes a manifest matching the legacy one apart from modules', async () => {
61
- fetch.mockResponseOnce(JSON.stringify(manifest));
62
-
63
- const legacy = await legacyManifestResolver(config)(KEY);
64
- const inline = await inlineResolver(composition)(KEY);
65
-
66
- expect(inline?.manifest).toEqual({ ...legacy?.manifest, modules: {} });
67
- expect(inline?.environment).toEqual(legacy?.environment);
68
- });
69
- });
70
-
71
- describe('legacyManifestResolver', () => {
72
- it('merges environment overrides client side, because no server did', async () => {
73
- fetch.mockResponseOnce(JSON.stringify(manifest));
74
-
75
- const resolution = await legacyManifestResolver({
76
- ...config,
77
- overrides: { environment: { TestModule: { ENV_VAR_A: 'New value for A' } } },
78
- })(KEY);
79
-
80
- expect(resolution?.environment).toEqual({ ENV_VAR_A: 'New value for A' });
81
- });
82
-
83
- it('fetches each manifest only once', async () => {
84
- fetch.mockResponse(JSON.stringify(manifest));
85
- const resolve = legacyManifestResolver(config);
86
-
87
- await resolve(KEY);
88
- await resolve(KEY);
89
-
90
- expect(fetch).toHaveBeenCalledTimes(1);
91
- });
92
- });
93
-
94
- describe('registryResolver', () => {
95
- it('fetches a remote activated after the page was served', async () => {
96
- const added = { ...manifest.remotes[KEY], scope: 'LateModule', module: './Late' };
97
- fetch.mockResponseOnce(JSON.stringify(added));
98
-
99
- const resolution = await registryResolver(composition, 'http://registry')('LateModule/Late');
100
-
101
- expect(fetch).toHaveBeenCalledWith(
102
- 'http://registry/v1/environments/acme/dev/remotes/LateModule/Late',
103
- expect.anything(),
104
- );
105
- expect(resolution?.remote).toEqual(added);
106
- });
107
-
108
- it('yields to the next resolver when the registry has no such remote', async () => {
109
- fetch.mockResponseOnce('', { status: 404 });
110
-
111
- await expect(registryResolver(composition)('Nope/Nope')).resolves.toBeUndefined();
112
- });
113
- });
114
-
115
- describe('chainResolvers', () => {
116
- it('returns the first resolution and stops', async () => {
117
- const second = jest.fn();
118
- const resolve = chainResolvers(inlineResolver(composition), second);
119
-
120
- await resolve(KEY);
121
-
122
- expect(second).not.toHaveBeenCalled();
123
- });
124
-
125
- it('resolves undefined when no resolver matches', async () => {
126
- await expect(chainResolvers()('Nope/Nope')).resolves.toBeUndefined();
127
- });
128
- });
@@ -1 +0,0 @@
1
- {"version":3,"file":"axios.d.ts","sourceRoot":"","sources":["../../../../../config/src/axios.ts"],"names":[],"mappings":";AAEA,wBAA8B"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"configmap.d.ts","sourceRoot":"","sources":["../../../../../config/src/configmap.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,cAAc,EAAE,SAAS,EAAE,MAAM,SAAS,CAAC;;YA0BrC,CAAC,SAAS,MAAM,OAAO,CAAC,aAAa,SAAS,KAAG,CAAC;qBAuBzC,cAAc;;AAEtC,wBAGE"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"context.d.ts","sourceRoot":"","sources":["../../../../../config/src/context.ts"],"names":[],"mappings":"AAKA,MAAM,MAAM,eAAe,GAAG;IAC5B,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,yCAAyC;IACzC,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,OAAO,EAAE,MAAM,CAAC;IAChB,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB,CAAC;AAaF;;;;;GAKG;AACH,eAAO,MAAM,cAAc,QAAO,eAQjC,CAAC;AAEF;;;GAGG;AACH,eAAO,MAAM,gBAAgB,QAAO;IAAE,QAAQ,CAAC,EAAE,MAAM,CAAC;IAAC,WAAW,CAAC,EAAE,MAAM,CAAA;CAK5E,CAAC"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"credentials.d.ts","sourceRoot":"","sources":["../../../../../config/src/credentials.ts"],"names":[],"mappings":"AAKA,MAAM,MAAM,UAAU,GAAG;IACvB,WAAW,EAAE,MAAM,CAAC;IACpB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,0BAA0B;IAC1B,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB,CAAC;AAKF,eAAO,MAAM,eAAe,cAC6D,CAAC;AAqB1F,eAAO,MAAM,cAAc,aAAc,MAAM,cAAc,UAAU,SAEtE,CAAC;AAEF,eAAO,MAAM,eAAe,aAAc,MAAM,SAI/C,CAAC;AAEF;;;GAGG;AACH,eAAO,MAAM,YAAY,aAAc,MAAM,KAAG,MAAM,GAAG,SAexD,CAAC;AAEF,eAAO,MAAM,YAAY,aAAc,MAAM,KAAG,MAO/C,CAAC"}