@appshell/loader 1.0.0-alpha.8 → 1.0.0-alpha.81

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 (96) 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 +0 -2
  7. package/dist/types/config/src/generate.manifest.d.ts +30 -2
  8. package/dist/types/config/src/index.d.ts +7 -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/publish.d.ts +79 -5
  13. package/dist/types/config/src/sync.d.ts +0 -1
  14. package/dist/types/config/src/tls.d.ts +23 -0
  15. package/dist/types/config/src/types.d.ts +164 -30
  16. package/dist/types/config/src/utils/blur.d.ts +0 -1
  17. package/dist/types/config/src/utils/compare.d.ts +0 -1
  18. package/dist/types/config/src/utils/config.d.ts +0 -1
  19. package/dist/types/config/src/utils/copy.d.ts +0 -1
  20. package/dist/types/config/src/utils/dump.d.ts +10 -0
  21. package/dist/types/config/src/utils/index.d.ts +1 -4
  22. package/dist/types/config/src/utils/list.d.ts +0 -1
  23. package/dist/types/config/src/utils/load.d.ts +0 -1
  24. package/dist/types/config/src/validators/AppshellTemplateValidator.d.ts +0 -1
  25. package/dist/types/config/src/validators/index.d.ts +0 -3
  26. package/dist/types/loader/src/index.d.ts +0 -1
  27. package/dist/types/loader/src/loadAppshellComponent.d.ts +13 -14
  28. package/dist/types/loader/src/remoteLoader.d.ts +2 -3
  29. package/dist/types/loader/src/resolvers.d.ts +4 -12
  30. package/dist/types/loader/src/types.d.ts +0 -1
  31. package/dist/types/runtime/src/errors.d.ts +32 -0
  32. package/dist/types/runtime/src/identity.d.ts +47 -0
  33. package/dist/types/runtime/src/index.d.ts +6 -0
  34. package/dist/types/runtime/src/store.d.ts +25 -0
  35. package/dist/types/runtime/src/types.d.ts +9 -0
  36. package/dist/types/runtime/src/wire.d.ts +58 -0
  37. package/package.json +15 -4
  38. package/CHANGELOG.md +0 -191
  39. package/__tests__/fetchDynamicScript.spec.ts +0 -44
  40. package/__tests__/fixtures/TestComponent.ts +0 -3
  41. package/__tests__/loadAppshellComponent.spec.ts +0 -102
  42. package/__tests__/remoteLoader.spec.ts +0 -144
  43. package/__tests__/resolvers.spec.ts +0 -128
  44. package/dist/types/config/src/axios.d.ts.map +0 -1
  45. package/dist/types/config/src/configmap.d.ts.map +0 -1
  46. package/dist/types/config/src/context.d.ts.map +0 -1
  47. package/dist/types/config/src/credentials.d.ts.map +0 -1
  48. package/dist/types/config/src/deregister.d.ts +0 -3
  49. package/dist/types/config/src/deregister.d.ts.map +0 -1
  50. package/dist/types/config/src/generate.env.d.ts +0 -3
  51. package/dist/types/config/src/generate.env.d.ts.map +0 -1
  52. package/dist/types/config/src/generate.global-config.d.ts +0 -10
  53. package/dist/types/config/src/generate.global-config.d.ts.map +0 -1
  54. package/dist/types/config/src/generate.manifest.d.ts.map +0 -1
  55. package/dist/types/config/src/index.d.ts.map +0 -1
  56. package/dist/types/config/src/mappers/appshell.config.d.ts.map +0 -1
  57. package/dist/types/config/src/outdated.d.ts.map +0 -1
  58. package/dist/types/config/src/publish.d.ts.map +0 -1
  59. package/dist/types/config/src/register.d.ts +0 -4
  60. package/dist/types/config/src/register.d.ts.map +0 -1
  61. package/dist/types/config/src/sync.d.ts.map +0 -1
  62. package/dist/types/config/src/types.d.ts.map +0 -1
  63. package/dist/types/config/src/utils/blur.d.ts.map +0 -1
  64. package/dist/types/config/src/utils/compare.d.ts.map +0 -1
  65. package/dist/types/config/src/utils/config.d.ts.map +0 -1
  66. package/dist/types/config/src/utils/copy.d.ts.map +0 -1
  67. package/dist/types/config/src/utils/index.d.ts.map +0 -1
  68. package/dist/types/config/src/utils/isValidUrl.d.ts +0 -3
  69. package/dist/types/config/src/utils/isValidUrl.d.ts.map +0 -1
  70. package/dist/types/config/src/utils/list.d.ts.map +0 -1
  71. package/dist/types/config/src/utils/load.d.ts.map +0 -1
  72. package/dist/types/config/src/utils/loadJson.d.ts +0 -10
  73. package/dist/types/config/src/utils/loadJson.d.ts.map +0 -1
  74. package/dist/types/config/src/utils/merge.d.ts +0 -4
  75. package/dist/types/config/src/utils/merge.d.ts.map +0 -1
  76. package/dist/types/config/src/validators/AppshellGlobalConfigValidator.d.ts +0 -4
  77. package/dist/types/config/src/validators/AppshellGlobalConfigValidator.d.ts.map +0 -1
  78. package/dist/types/config/src/validators/AppshellManifestValidator.d.ts +0 -4
  79. package/dist/types/config/src/validators/AppshellManifestValidator.d.ts.map +0 -1
  80. package/dist/types/config/src/validators/AppshellTemplateValidator.d.ts.map +0 -1
  81. package/dist/types/config/src/validators/index.d.ts.map +0 -1
  82. package/dist/types/loader/src/fetchDynamicScript.d.ts +0 -3
  83. package/dist/types/loader/src/fetchDynamicScript.d.ts.map +0 -1
  84. package/dist/types/loader/src/index.d.ts.map +0 -1
  85. package/dist/types/loader/src/loadAppshellComponent.d.ts.map +0 -1
  86. package/dist/types/loader/src/remoteLoader.d.ts.map +0 -1
  87. package/dist/types/loader/src/resolvers.d.ts.map +0 -1
  88. package/dist/types/loader/src/types.d.ts.map +0 -1
  89. package/src/fetchDynamicScript.ts +0 -40
  90. package/src/index.ts +0 -7
  91. package/src/loadAppshellComponent.ts +0 -48
  92. package/src/remoteLoader.ts +0 -80
  93. package/src/resolvers.ts +0 -110
  94. package/src/types.ts +0 -10
  95. package/tsconfig.json +0 -7
  96. package/webpack.config.js +0 -37
package/CHANGELOG.md DELETED
@@ -1,191 +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.8](https://github.com/appshell-org/appshell/compare/v1.0.0-alpha.7...v1.0.0-alpha.8) (2026-08-19)
7
-
8
- **Note:** Version bump only for package @appshell/loader
9
-
10
- # [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)
11
-
12
- **Note:** Version bump only for package @appshell/loader
13
-
14
- **Note:** Version bump only for package @appshell/loader
15
-
16
- # [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)
17
-
18
- **Note:** Version bump only for package @appshell/loader
19
-
20
- # [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)
21
-
22
- **Note:** Version bump only for package @appshell/loader
23
-
24
- **Note:** Version bump only for package @appshell/loader
25
-
26
- # [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)
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.3](https://github.com/appshell-org/appshell/compare/v1.0.0-alpha.2...v1.0.0-alpha.3) (2026-08-18)
33
-
34
- **Note:** Version bump only for package @appshell/loader
35
-
36
- # 0.12.0-alpha.0 (2026-04-20)
37
-
38
- ### Bug Fixes
39
-
40
- - appshell loader override check ([aedda4a](https://github.com/appshell-org/appshell/commit/aedda4abf81560297dce03df09fba68e8785242f))
41
- - configurable api key header support, minor fixes ([2f0bf02](https://github.com/appshell-org/appshell/commit/2f0bf027b92398f91b8e8cbfbf543d61fe37b7a0))
42
- - hot module replacement support, example updates ([a67d230](https://github.com/appshell-org/appshell/commit/a67d2303b40f5911373225cc0b4ccf9b67c33d11))
43
- - registry projection, enable env overwrite, refactor docker workflow, consolidate env names ([33a28fe](https://github.com/appshell-org/appshell/commit/33a28fe76b58e05c5b6b6b33d4b402e52bb29e70))
44
- - rename @appshell/react-federated-component package to @appshell/react ([0b74498](https://github.com/appshell-org/appshell/commit/0b74498bf17ba73db4d936c8a012af1d3b111a28))
45
- - replace config intermediate file with template ([9b79e65](https://github.com/appshell-org/appshell/commit/9b79e65b355686a0cca273c89c7164bb031e8437))
46
- - update repository URLs from navaris/appshell to appshell-org/appshell ([506a90d](https://github.com/appshell-org/appshell/commit/506a90d94a6f6e10f463987d408550f48624bfd0))
47
-
48
- ### Features
49
-
50
- - api key support ([9cdcbee](https://github.com/appshell-org/appshell/commit/9cdcbee36e44b8a179b49768d74a25767f1cc5f2))
51
- - 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))
52
- - AppshellComponent impl ([2b82621](https://github.com/appshell-org/appshell/commit/2b82621c13302f790a8e1c457f9a82f39903fc1f))
53
- - consolidate runtime artifacts ([#26](https://github.com/appshell-org/appshell/issues/26)) ([a29479a](https://github.com/appshell-org/appshell/commit/a29479a49f0c5ec1273c9f8e4c7384096f2d4ba0))
54
- - environment variable override for federated components ([#27](https://github.com/appshell-org/appshell/issues/27)) ([d32de0b](https://github.com/appshell-org/appshell/commit/d32de0b0d1cbb1792715e1b363c80ed4600df155))
55
- - foundation refactor wip ([339b930](https://github.com/appshell-org/appshell/commit/339b9306accaa9aba1712f3a0dee6c4cab7ed273))
56
-
57
- ## [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)
58
-
59
- ### Bug Fixes
60
-
61
- - update repository URLs from navaris/appshell to appshell-org/appshell ([506a90d](https://github.com/appshell-org/appshell/commit/506a90d94a6f6e10f463987d408550f48624bfd0))
62
-
63
- # [0.5.0](https://github.com/navaris/appshell/compare/@appshell/loader@0.4.0...@appshell/loader@0.5.0) (2025-08-12)
64
-
65
- ### Bug Fixes
66
-
67
- - configurable api key header support, minor fixes ([2f0bf02](https://github.com/navaris/appshell/commit/2f0bf027b92398f91b8e8cbfbf543d61fe37b7a0))
68
-
69
- ### Features
70
-
71
- - 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))
72
-
73
- # [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)
74
-
75
- ### Bug Fixes
76
-
77
- - include credentials when fetching the manifests ([4e0ee79](https://github.com/navaris/appshell/commit/4e0ee79b4ba93d34fd6a0e1a5f6bf2fc9f3994cc))
78
-
79
- ### Features
80
-
81
- - 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))
82
-
83
- # [0.4.0](https://github.com/navaris/appshell/compare/@appshell/loader@0.3.0...@appshell/loader@0.4.0) (2024-09-24)
84
-
85
- ### Features
86
-
87
- - api key support ([9cdcbee](https://github.com/navaris/appshell/commit/9cdcbee36e44b8a179b49768d74a25767f1cc5f2))
88
-
89
- # [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)
90
-
91
- ### Features
92
-
93
- - api key support ([8c91e62](https://github.com/navaris/appshell/commit/8c91e6240b3d879af9bdd5949924865da0e0f8a1))
94
-
95
- ## [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)
96
-
97
- ### Bug Fixes
98
-
99
- - bump pipeline ([8bb63bc](https://github.com/navaris/appshell/commit/8bb63bcae1928c01bb6bc853d88010939e686af5))
100
-
101
- # [0.3.0](https://github.com/navaris/appshell/compare/@appshell/loader@0.2.1...@appshell/loader@0.3.0) (2024-01-25)
102
-
103
- ### Features
104
-
105
- - AppshellComponent impl ([2b82621](https://github.com/navaris/appshell/commit/2b82621c13302f790a8e1c457f9a82f39903fc1f))
106
-
107
- ## [0.2.1](https://github.com/navaris/appshell/compare/@appshell/loader@0.2.0...@appshell/loader@0.2.1) (2023-08-29)
108
-
109
- ### Bug Fixes
110
-
111
- - appshell loader override check ([aedda4a](https://github.com/navaris/appshell/commit/aedda4abf81560297dce03df09fba68e8785242f))
112
-
113
- # [0.2.0](https://github.com/navaris/appshell/compare/@appshell/loader@0.2.0-alpha.1...@appshell/loader@0.2.0) (2023-08-28)
114
-
115
- **Note:** Version bump only for package @appshell/loader
116
-
117
- # [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)
118
-
119
- ### Features
120
-
121
- - environment variable override for federated components ([#27](https://github.com/navaris/appshell/issues/27)) ([d32de0b](https://github.com/navaris/appshell/commit/d32de0b0d1cbb1792715e1b363c80ed4600df155))
122
-
123
- # [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)
124
-
125
- ### Features
126
-
127
- - consolidate runtime artifacts ([#26](https://github.com/navaris/appshell/issues/26)) ([a29479a](https://github.com/navaris/appshell/commit/a29479a49f0c5ec1273c9f8e4c7384096f2d4ba0))
128
-
129
- # [0.1.0](https://github.com/navaris/appshell/compare/@appshell/loader@0.1.0-alpha.1...@appshell/loader@0.1.0) (2023-07-11)
130
-
131
- ### Bug Fixes
132
-
133
- - registry projection, enable env overwrite, refactor docker workflow, consolidate env names ([33a28fe](https://github.com/navaris/appshell/commit/33a28fe76b58e05c5b6b6b33d4b402e52bb29e70))
134
- - rename @appshell/react-federated-component package to @appshell/react ([0b74498](https://github.com/navaris/appshell/commit/0b74498bf17ba73db4d936c8a012af1d3b111a28))
135
- - replace config intermediate file with template ([9b79e65](https://github.com/navaris/appshell/commit/9b79e65b355686a0cca273c89c7164bb031e8437))
136
-
137
- # [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)
138
-
139
- ### Features
140
-
141
- - foundation refactor wip ([339b930](https://github.com/navaris/appshell/commit/339b9306accaa9aba1712f3a0dee6c4cab7ed273))
142
-
143
- # [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)
144
-
145
- ### Features
146
-
147
- - registry index ([8e6ee0a](https://github.com/navaris/appshell/commit/8e6ee0a6a377584efa2ee702168025f46108b8c5))
148
-
149
- ## [0.0.3](https://github.com/navaris/appshell/compare/@appshell/loader@0.0.3-alpha.2...@appshell/loader@0.0.3) (2023-06-29)
150
-
151
- **Note:** Version bump only for package @appshell/loader
152
-
153
- ## [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)
154
-
155
- **Note:** Version bump only for package @appshell/loader
156
-
157
- ## [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)
158
-
159
- ### Bug Fixes
160
-
161
- - update npm package visibility ([1ef4119](https://github.com/navaris/appshell/commit/1ef411903dd038dfc781e8ce0700811e5460c903))
162
-
163
- ## [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)
164
-
165
- **Note:** Version bump only for package @appshell/loader
166
-
167
- ## [0.0.2](https://github.com/navaris/appshell/compare/@appshell/loader@0.0.2-alpha.0...@appshell/loader@0.0.2) (2023-06-29)
168
-
169
- **Note:** Version bump only for package @appshell/loader
170
-
171
- ## [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)
172
-
173
- ### Bug Fixes
174
-
175
- - hot module replacement support, example updates ([a67d230](https://github.com/navaris/appshell/commit/a67d2303b40f5911373225cc0b4ccf9b67c33d11))
176
-
177
- =======
178
-
179
- ## 0.0.1 (2023-06-15)
180
-
181
- **Note:** Version bump only for package @appshell/loader
182
-
183
- ## [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)
184
-
185
- ### Bug Fixes
186
-
187
- - hot module replacement support, example updates ([a67d230](https://github.com/navaris/appshell/commit/a67d2303b40f5911373225cc0b4ccf9b67c33d11))
188
-
189
- ## 0.0.1-alpha.0 (2023-03-19)
190
-
191
- **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"}
@@ -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
@@ -1 +0,0 @@
1
- {"version":3,"file":"generate.env.d.ts","sourceRoot":"","sources":["../../../../../config/src/generate.env.ts"],"names":[],"mappings":";AAGA,wBAuBK"}
@@ -1,10 +0,0 @@
1
- import { AppshellGlobalConfig } from './types';
2
- type GenerateGlobalConfigOptions = {
3
- insecure: boolean;
4
- apiKey?: string;
5
- apiKeyHeader?: string;
6
- proxyUrl?: string;
7
- };
8
- declare const _default: (registries: string[], options?: GenerateGlobalConfigOptions) => Promise<AppshellGlobalConfig>;
9
- export default _default;
10
- //# sourceMappingURL=generate.global-config.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"generate.global-config.d.ts","sourceRoot":"","sources":["../../../../../config/src/generate.global-config.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,oBAAoB,EAAE,MAAM,SAAS,CAAC;AAK/C,KAAK,2BAA2B,GAAG;IACjC,QAAQ,EAAE,OAAO,CAAC;IAClB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB,CAAC;qCAGY,MAAM,EAAE,YACX,2BAA2B,KACnC,OAAO,CAAC,oBAAoB,CAAC;AAHhC,wBA8CE"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"generate.manifest.d.ts","sourceRoot":"","sources":["../../../../../config/src/generate.manifest.ts"],"names":[],"mappings":"AAOA;;;;GAIG;yBACmB,SAAS,SAAS,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,gBAAgB,MAAM;AAArF,wBAaE"}