@appshell/loader 1.0.0-alpha.0 → 1.0.0-alpha.100

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 (95) 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 +26 -0
  6. package/dist/types/config/src/credentials.d.ts +48 -0
  7. package/dist/types/config/src/generate.manifest.d.ts +30 -2
  8. package/dist/types/config/src/index.d.ts +12 -9
  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 +93 -8
  14. package/dist/types/config/src/sync.d.ts +0 -1
  15. package/dist/types/config/src/tls.d.ts +11 -0
  16. package/dist/types/config/src/types.d.ts +184 -31
  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 +15 -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 +2 -5
  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 -184
  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/deregister.d.ts +0 -3
  48. package/dist/types/config/src/deregister.d.ts.map +0 -1
  49. package/dist/types/config/src/generate.env.d.ts +0 -3
  50. package/dist/types/config/src/generate.env.d.ts.map +0 -1
  51. package/dist/types/config/src/generate.global-config.d.ts +0 -10
  52. package/dist/types/config/src/generate.global-config.d.ts.map +0 -1
  53. package/dist/types/config/src/generate.manifest.d.ts.map +0 -1
  54. package/dist/types/config/src/index.d.ts.map +0 -1
  55. package/dist/types/config/src/mappers/appshell.config.d.ts.map +0 -1
  56. package/dist/types/config/src/outdated.d.ts.map +0 -1
  57. package/dist/types/config/src/publish.d.ts.map +0 -1
  58. package/dist/types/config/src/register.d.ts +0 -4
  59. package/dist/types/config/src/register.d.ts.map +0 -1
  60. package/dist/types/config/src/sync.d.ts.map +0 -1
  61. package/dist/types/config/src/types.d.ts.map +0 -1
  62. package/dist/types/config/src/utils/blur.d.ts.map +0 -1
  63. package/dist/types/config/src/utils/compare.d.ts.map +0 -1
  64. package/dist/types/config/src/utils/config.d.ts.map +0 -1
  65. package/dist/types/config/src/utils/copy.d.ts.map +0 -1
  66. package/dist/types/config/src/utils/index.d.ts.map +0 -1
  67. package/dist/types/config/src/utils/isValidUrl.d.ts +0 -3
  68. package/dist/types/config/src/utils/isValidUrl.d.ts.map +0 -1
  69. package/dist/types/config/src/utils/list.d.ts.map +0 -1
  70. package/dist/types/config/src/utils/load.d.ts.map +0 -1
  71. package/dist/types/config/src/utils/loadJson.d.ts +0 -10
  72. package/dist/types/config/src/utils/loadJson.d.ts.map +0 -1
  73. package/dist/types/config/src/utils/merge.d.ts +0 -4
  74. package/dist/types/config/src/utils/merge.d.ts.map +0 -1
  75. package/dist/types/config/src/validators/AppshellGlobalConfigValidator.d.ts +0 -4
  76. package/dist/types/config/src/validators/AppshellGlobalConfigValidator.d.ts.map +0 -1
  77. package/dist/types/config/src/validators/AppshellManifestValidator.d.ts +0 -4
  78. package/dist/types/config/src/validators/AppshellManifestValidator.d.ts.map +0 -1
  79. package/dist/types/config/src/validators/AppshellTemplateValidator.d.ts.map +0 -1
  80. package/dist/types/config/src/validators/index.d.ts.map +0 -1
  81. package/dist/types/loader/src/fetchDynamicScript.d.ts +0 -3
  82. package/dist/types/loader/src/fetchDynamicScript.d.ts.map +0 -1
  83. package/dist/types/loader/src/index.d.ts.map +0 -1
  84. package/dist/types/loader/src/loadAppshellComponent.d.ts.map +0 -1
  85. package/dist/types/loader/src/remoteLoader.d.ts.map +0 -1
  86. package/dist/types/loader/src/resolvers.d.ts.map +0 -1
  87. package/dist/types/loader/src/types.d.ts.map +0 -1
  88. package/src/fetchDynamicScript.ts +0 -40
  89. package/src/index.ts +0 -7
  90. package/src/loadAppshellComponent.ts +0 -48
  91. package/src/remoteLoader.ts +0 -80
  92. package/src/resolvers.ts +0 -110
  93. package/src/types.ts +0 -10
  94. package/tsconfig.json +0 -7
  95. 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.0",
3
+ "version": "1.0.0-alpha.100",
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": "97ee53524d5c729308f49adca6c613d68a262179"
34
+ "dependencies": {
35
+ "@appshell/runtime": "^1.0.0-alpha.100",
36
+ "@module-federation/enhanced": "^2.8.2"
37
+ },
38
+ "gitHead": "2df8eb5b605b036d36af7e8d3ee2990bc2b63e5e"
28
39
  }
package/CHANGELOG.md DELETED
@@ -1,184 +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.0 (2026-08-18)
7
-
8
- ### Bug Fixes
9
-
10
- - appshell loader override check ([aedda4a](https://github.com/appshell-org/appshell/commit/aedda4abf81560297dce03df09fba68e8785242f))
11
- - configurable api key header support, minor fixes ([2f0bf02](https://github.com/appshell-org/appshell/commit/2f0bf027b92398f91b8e8cbfbf543d61fe37b7a0))
12
- - hot module replacement support, example updates ([a67d230](https://github.com/appshell-org/appshell/commit/a67d2303b40f5911373225cc0b4ccf9b67c33d11))
13
- - registry projection, enable env overwrite, refactor docker workflow, consolidate env names ([33a28fe](https://github.com/appshell-org/appshell/commit/33a28fe76b58e05c5b6b6b33d4b402e52bb29e70))
14
- - rename @appshell/react-federated-component package to @appshell/react ([0b74498](https://github.com/appshell-org/appshell/commit/0b74498bf17ba73db4d936c8a012af1d3b111a28))
15
- - replace config intermediate file with template ([9b79e65](https://github.com/appshell-org/appshell/commit/9b79e65b355686a0cca273c89c7164bb031e8437))
16
- - resolve npm audit vulnerabilities (74 → 4) ([36a2d56](https://github.com/appshell-org/appshell/commit/36a2d56a76dabd55a6886ddb9f020948420fd832))
17
-
18
- ### Features
19
-
20
- - api key support ([9cdcbee](https://github.com/appshell-org/appshell/commit/9cdcbee36e44b8a179b49768d74a25767f1cc5f2))
21
- - 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))
22
- - AppshellComponent impl ([2b82621](https://github.com/appshell-org/appshell/commit/2b82621c13302f790a8e1c457f9a82f39903fc1f))
23
- - **config:** carry the host root and its props in the composition ([ca9ed63](https://github.com/appshell-org/appshell/commit/ca9ed630a5a22cb62d6630b5f191d15c54f1c595))
24
- - consolidate runtime artifacts ([#26](https://github.com/appshell-org/appshell/issues/26)) ([a29479a](https://github.com/appshell-org/appshell/commit/a29479a49f0c5ec1273c9f8e4c7384096f2d4ba0))
25
- - environment variable override for federated components ([#27](https://github.com/appshell-org/appshell/issues/27)) ([d32de0b](https://github.com/appshell-org/appshell/commit/d32de0b0d1cbb1792715e1b363c80ed4600df155))
26
- - foundation refactor wip ([339b930](https://github.com/appshell-org/appshell/commit/339b9306accaa9aba1712f3a0dee6c4cab7ed273))
27
- - **loader:** pin the runtime wire contract and add a resolver chain ([95dbb10](https://github.com/appshell-org/appshell/commit/95dbb10d2bd0a7c2429852839c8be352a2c1bbe8))
28
-
29
- # 0.12.0-alpha.0 (2026-04-20)
30
-
31
- ### Bug Fixes
32
-
33
- - appshell loader override check ([aedda4a](https://github.com/appshell-org/appshell/commit/aedda4abf81560297dce03df09fba68e8785242f))
34
- - configurable api key header support, minor fixes ([2f0bf02](https://github.com/appshell-org/appshell/commit/2f0bf027b92398f91b8e8cbfbf543d61fe37b7a0))
35
- - hot module replacement support, example updates ([a67d230](https://github.com/appshell-org/appshell/commit/a67d2303b40f5911373225cc0b4ccf9b67c33d11))
36
- - registry projection, enable env overwrite, refactor docker workflow, consolidate env names ([33a28fe](https://github.com/appshell-org/appshell/commit/33a28fe76b58e05c5b6b6b33d4b402e52bb29e70))
37
- - rename @appshell/react-federated-component package to @appshell/react ([0b74498](https://github.com/appshell-org/appshell/commit/0b74498bf17ba73db4d936c8a012af1d3b111a28))
38
- - replace config intermediate file with template ([9b79e65](https://github.com/appshell-org/appshell/commit/9b79e65b355686a0cca273c89c7164bb031e8437))
39
- - update repository URLs from navaris/appshell to appshell-org/appshell ([506a90d](https://github.com/appshell-org/appshell/commit/506a90d94a6f6e10f463987d408550f48624bfd0))
40
-
41
- ### Features
42
-
43
- - api key support ([9cdcbee](https://github.com/appshell-org/appshell/commit/9cdcbee36e44b8a179b49768d74a25767f1cc5f2))
44
- - 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))
45
- - AppshellComponent impl ([2b82621](https://github.com/appshell-org/appshell/commit/2b82621c13302f790a8e1c457f9a82f39903fc1f))
46
- - consolidate runtime artifacts ([#26](https://github.com/appshell-org/appshell/issues/26)) ([a29479a](https://github.com/appshell-org/appshell/commit/a29479a49f0c5ec1273c9f8e4c7384096f2d4ba0))
47
- - environment variable override for federated components ([#27](https://github.com/appshell-org/appshell/issues/27)) ([d32de0b](https://github.com/appshell-org/appshell/commit/d32de0b0d1cbb1792715e1b363c80ed4600df155))
48
- - foundation refactor wip ([339b930](https://github.com/appshell-org/appshell/commit/339b9306accaa9aba1712f3a0dee6c4cab7ed273))
49
-
50
- ## [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)
51
-
52
- ### Bug Fixes
53
-
54
- - update repository URLs from navaris/appshell to appshell-org/appshell ([506a90d](https://github.com/appshell-org/appshell/commit/506a90d94a6f6e10f463987d408550f48624bfd0))
55
-
56
- # [0.5.0](https://github.com/navaris/appshell/compare/@appshell/loader@0.4.0...@appshell/loader@0.5.0) (2025-08-12)
57
-
58
- ### Bug Fixes
59
-
60
- - configurable api key header support, minor fixes ([2f0bf02](https://github.com/navaris/appshell/commit/2f0bf027b92398f91b8e8cbfbf543d61fe37b7a0))
61
-
62
- ### Features
63
-
64
- - 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))
65
-
66
- # [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)
67
-
68
- ### Bug Fixes
69
-
70
- - include credentials when fetching the manifests ([4e0ee79](https://github.com/navaris/appshell/commit/4e0ee79b4ba93d34fd6a0e1a5f6bf2fc9f3994cc))
71
-
72
- ### Features
73
-
74
- - 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))
75
-
76
- # [0.4.0](https://github.com/navaris/appshell/compare/@appshell/loader@0.3.0...@appshell/loader@0.4.0) (2024-09-24)
77
-
78
- ### Features
79
-
80
- - api key support ([9cdcbee](https://github.com/navaris/appshell/commit/9cdcbee36e44b8a179b49768d74a25767f1cc5f2))
81
-
82
- # [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)
83
-
84
- ### Features
85
-
86
- - api key support ([8c91e62](https://github.com/navaris/appshell/commit/8c91e6240b3d879af9bdd5949924865da0e0f8a1))
87
-
88
- ## [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)
89
-
90
- ### Bug Fixes
91
-
92
- - bump pipeline ([8bb63bc](https://github.com/navaris/appshell/commit/8bb63bcae1928c01bb6bc853d88010939e686af5))
93
-
94
- # [0.3.0](https://github.com/navaris/appshell/compare/@appshell/loader@0.2.1...@appshell/loader@0.3.0) (2024-01-25)
95
-
96
- ### Features
97
-
98
- - AppshellComponent impl ([2b82621](https://github.com/navaris/appshell/commit/2b82621c13302f790a8e1c457f9a82f39903fc1f))
99
-
100
- ## [0.2.1](https://github.com/navaris/appshell/compare/@appshell/loader@0.2.0...@appshell/loader@0.2.1) (2023-08-29)
101
-
102
- ### Bug Fixes
103
-
104
- - appshell loader override check ([aedda4a](https://github.com/navaris/appshell/commit/aedda4abf81560297dce03df09fba68e8785242f))
105
-
106
- # [0.2.0](https://github.com/navaris/appshell/compare/@appshell/loader@0.2.0-alpha.1...@appshell/loader@0.2.0) (2023-08-28)
107
-
108
- **Note:** Version bump only for package @appshell/loader
109
-
110
- # [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)
111
-
112
- ### Features
113
-
114
- - environment variable override for federated components ([#27](https://github.com/navaris/appshell/issues/27)) ([d32de0b](https://github.com/navaris/appshell/commit/d32de0b0d1cbb1792715e1b363c80ed4600df155))
115
-
116
- # [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)
117
-
118
- ### Features
119
-
120
- - consolidate runtime artifacts ([#26](https://github.com/navaris/appshell/issues/26)) ([a29479a](https://github.com/navaris/appshell/commit/a29479a49f0c5ec1273c9f8e4c7384096f2d4ba0))
121
-
122
- # [0.1.0](https://github.com/navaris/appshell/compare/@appshell/loader@0.1.0-alpha.1...@appshell/loader@0.1.0) (2023-07-11)
123
-
124
- ### Bug Fixes
125
-
126
- - registry projection, enable env overwrite, refactor docker workflow, consolidate env names ([33a28fe](https://github.com/navaris/appshell/commit/33a28fe76b58e05c5b6b6b33d4b402e52bb29e70))
127
- - rename @appshell/react-federated-component package to @appshell/react ([0b74498](https://github.com/navaris/appshell/commit/0b74498bf17ba73db4d936c8a012af1d3b111a28))
128
- - replace config intermediate file with template ([9b79e65](https://github.com/navaris/appshell/commit/9b79e65b355686a0cca273c89c7164bb031e8437))
129
-
130
- # [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)
131
-
132
- ### Features
133
-
134
- - foundation refactor wip ([339b930](https://github.com/navaris/appshell/commit/339b9306accaa9aba1712f3a0dee6c4cab7ed273))
135
-
136
- # [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)
137
-
138
- ### Features
139
-
140
- - registry index ([8e6ee0a](https://github.com/navaris/appshell/commit/8e6ee0a6a377584efa2ee702168025f46108b8c5))
141
-
142
- ## [0.0.3](https://github.com/navaris/appshell/compare/@appshell/loader@0.0.3-alpha.2...@appshell/loader@0.0.3) (2023-06-29)
143
-
144
- **Note:** Version bump only for package @appshell/loader
145
-
146
- ## [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)
147
-
148
- **Note:** Version bump only for package @appshell/loader
149
-
150
- ## [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)
151
-
152
- ### Bug Fixes
153
-
154
- - update npm package visibility ([1ef4119](https://github.com/navaris/appshell/commit/1ef411903dd038dfc781e8ce0700811e5460c903))
155
-
156
- ## [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)
157
-
158
- **Note:** Version bump only for package @appshell/loader
159
-
160
- ## [0.0.2](https://github.com/navaris/appshell/compare/@appshell/loader@0.0.2-alpha.0...@appshell/loader@0.0.2) (2023-06-29)
161
-
162
- **Note:** Version bump only for package @appshell/loader
163
-
164
- ## [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)
165
-
166
- ### Bug Fixes
167
-
168
- - hot module replacement support, example updates ([a67d230](https://github.com/navaris/appshell/commit/a67d2303b40f5911373225cc0b4ccf9b67c33d11))
169
-
170
- =======
171
-
172
- ## 0.0.1 (2023-06-15)
173
-
174
- **Note:** Version bump only for package @appshell/loader
175
-
176
- ## [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)
177
-
178
- ### Bug Fixes
179
-
180
- - hot module replacement support, example updates ([a67d230](https://github.com/navaris/appshell/commit/a67d2303b40f5911373225cc0b4ccf9b67c33d11))
181
-
182
- ## 0.0.1-alpha.0 (2023-03-19)
183
-
184
- **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,3 +0,0 @@
1
- declare const _default: (moduleName: string, registry: string) => Promise<void>;
2
- export default _default;
3
- //# sourceMappingURL=deregister.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"deregister.d.ts","sourceRoot":"","sources":["../../../../../config/src/deregister.ts"],"names":[],"mappings":"qCAoGkC,MAAM,YAAY,MAAM;AAA1D,wBAeE"}
@@ -1,3 +0,0 @@
1
- declare const _default: (prefix?: string) => Promise<Map<string, string | undefined>>;
2
- export default _default;
3
- //# sourceMappingURL=generate.env.d.ts.map