@appshell/react 0.1.0 → 0.2.0-alpha.0
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.
- package/CHANGELOG.md +11 -0
- package/README.md +5 -23
- package/__tests__/FederatedComponent.spec.tsx +8 -8
- package/__tests__/ReactHost.spec.tsx +13 -65
- package/__tests__/__snapshots__/ReactHost.spec.tsx.snap +1 -3
- package/__tests__/fixtures/TestGlobalConfig.ts +8 -0
- package/dist/main.js +1 -1
- package/dist/types/config/src/deregister.d.ts +3 -0
- package/dist/types/config/src/deregister.d.ts.map +1 -0
- package/dist/types/config/src/generate.global-config.d.ts +7 -0
- package/dist/types/config/src/generate.global-config.d.ts.map +1 -0
- package/dist/types/config/src/index.d.ts +3 -3
- package/dist/types/config/src/index.d.ts.map +1 -1
- package/dist/types/config/src/mappers/appshell.config.d.ts +2 -2
- package/dist/types/config/src/mappers/appshell.config.d.ts.map +1 -1
- package/dist/types/config/src/register.d.ts +1 -1
- package/dist/types/config/src/register.d.ts.map +1 -1
- package/dist/types/config/src/types.d.ts +16 -0
- package/dist/types/config/src/types.d.ts.map +1 -1
- package/dist/types/config/src/utils/load.d.ts.map +1 -1
- package/dist/types/config/src/utils/loadJson.d.ts +5 -1
- package/dist/types/config/src/utils/loadJson.d.ts.map +1 -1
- package/dist/types/config/src/validators/{appshell.index.d.ts → AppshellGlobalConfigValidator.d.ts} +1 -1
- package/dist/types/config/src/validators/AppshellGlobalConfigValidator.d.ts.map +1 -0
- package/dist/types/config/src/validators/{appshell.config.d.ts → AppshellManifestValidator.d.ts} +1 -1
- package/dist/types/config/src/validators/AppshellManifestValidator.d.ts.map +1 -0
- package/dist/types/config/src/validators/{appshell.metadata.d.ts → AppshellTemplateValidator.d.ts} +1 -1
- package/dist/types/config/src/validators/AppshellTemplateValidator.d.ts.map +1 -0
- package/dist/types/config/src/validators/index.d.ts +3 -5
- package/dist/types/config/src/validators/index.d.ts.map +1 -1
- package/dist/types/loader/src/remoteLoader.d.ts +3 -2
- package/dist/types/loader/src/remoteLoader.d.ts.map +1 -1
- package/dist/types/react/src/components/ReactHost.d.ts +1 -2
- package/dist/types/react/src/components/ReactHost.d.ts.map +1 -1
- package/dist/types/react/src/contexts/GlobalConfigContext.d.ts +11 -0
- package/dist/types/react/src/contexts/GlobalConfigContext.d.ts.map +1 -0
- package/dist/types/react/src/hooks/useGlobalConfig.d.ts +4 -0
- package/dist/types/react/src/hooks/useGlobalConfig.d.ts.map +1 -0
- package/dist/types/react/src/index.d.ts +2 -2
- package/dist/types/react/src/index.d.ts.map +1 -1
- package/package.json +2 -2
- package/src/components/FederatedComponent.tsx +4 -4
- package/src/components/ReactHost.tsx +16 -38
- package/src/contexts/GlobalConfigContext.tsx +17 -0
- package/src/hooks/useGlobalConfig.ts +7 -0
- package/src/index.ts +2 -2
- package/__tests__/fixtures/appshell.index.ts +0 -5
- package/dist/types/config/src/generate.index.d.ts +0 -4
- package/dist/types/config/src/generate.index.d.ts.map +0 -1
- package/dist/types/config/src/generate.metadata.d.ts +0 -4
- package/dist/types/config/src/generate.metadata.d.ts.map +0 -1
- package/dist/types/config/src/validators/appshell.config.d.ts.map +0 -1
- package/dist/types/config/src/validators/appshell.index.d.ts.map +0 -1
- package/dist/types/config/src/validators/appshell.manifest.d.ts +0 -4
- package/dist/types/config/src/validators/appshell.manifest.d.ts.map +0 -1
- package/dist/types/config/src/validators/appshell.metadata.d.ts.map +0 -1
- package/dist/types/config/src/validators/merge.manifests.d.ts +0 -4
- package/dist/types/config/src/validators/merge.manifests.d.ts.map +0 -1
- package/dist/types/react/src/contexts/RegistryContext.d.ts +0 -11
- package/dist/types/react/src/contexts/RegistryContext.d.ts.map +0 -1
- package/dist/types/react/src/hooks/useRegistry.d.ts +0 -4
- package/dist/types/react/src/hooks/useRegistry.d.ts.map +0 -1
- package/src/contexts/RegistryContext.tsx +0 -17
- package/src/hooks/useRegistry.ts +0 -6
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,17 @@
|
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
|
4
4
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
5
|
|
|
6
|
+
# [0.2.0-alpha.0](https://github.com/navaris/appshell/compare/@appshell/react@0.1.0...@appshell/react@0.2.0-alpha.0) (2023-08-23)
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
### Features
|
|
10
|
+
|
|
11
|
+
* consolidate runtime artifacts ([#26](https://github.com/navaris/appshell/issues/26)) ([a29479a](https://github.com/navaris/appshell/commit/a29479a49f0c5ec1273c9f8e4c7384096f2d4ba0))
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
|
|
6
17
|
# [0.1.0](https://github.com/navaris/appshell/compare/@appshell/react@0.1.0-alpha.6...@appshell/react@0.1.0) (2023-07-11)
|
|
7
18
|
|
|
8
19
|
**Note:** Version bump only for package @appshell/react
|
package/README.md
CHANGED
|
@@ -50,42 +50,24 @@ import { FederatedComponent, ManifestProvider } from '@appshell/react';
|
|
|
50
50
|
</App>
|
|
51
51
|
```
|
|
52
52
|
|
|
53
|
-
##
|
|
53
|
+
## useGlobalConfig
|
|
54
54
|
|
|
55
|
-
For access to the
|
|
55
|
+
For access to the global appshell config.
|
|
56
56
|
|
|
57
57
|
```tsx
|
|
58
|
-
import {
|
|
58
|
+
import { GlobalConfigProvider, useGlobalConfig } from '@appshell/react';
|
|
59
59
|
|
|
60
60
|
const MyComponent = () => {
|
|
61
|
-
const
|
|
61
|
+
const config = useGlobalConfig();
|
|
62
62
|
|
|
63
63
|
...
|
|
64
64
|
}
|
|
65
65
|
|
|
66
|
-
<RegistryProvider
|
|
66
|
+
<RegistryProvider config={config}>
|
|
67
67
|
<MyComponent />
|
|
68
68
|
</RegistryProvider>
|
|
69
69
|
```
|
|
70
70
|
|
|
71
|
-
## useMetadata
|
|
72
|
-
|
|
73
|
-
For access to the registry metadata.
|
|
74
|
-
|
|
75
|
-
```tsx
|
|
76
|
-
import { MetadataProvider, useMetadata } from '@appshell/react';
|
|
77
|
-
|
|
78
|
-
const MyComponent = () => {
|
|
79
|
-
const metadata = useMetadata();
|
|
80
|
-
|
|
81
|
-
...
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
<MetadataProvider metadata={metadata}>
|
|
85
|
-
<MyComponent />
|
|
86
|
-
</MetadataProvider>
|
|
87
|
-
```
|
|
88
|
-
|
|
89
71
|
## useManifest
|
|
90
72
|
|
|
91
73
|
For access to the manifest.
|
|
@@ -4,18 +4,18 @@ import '@testing-library/jest-dom';
|
|
|
4
4
|
import { act, render, screen } from '@testing-library/react';
|
|
5
5
|
import React from 'react';
|
|
6
6
|
import FederatedComponent from '../src/components/FederatedComponent';
|
|
7
|
-
import * as
|
|
8
|
-
import index from './fixtures/appshell.index';
|
|
7
|
+
import * as useGlobalConfig from '../src/hooks/useGlobalConfig';
|
|
9
8
|
import manifest from './fixtures/Manifest';
|
|
10
9
|
import TestComponent from './fixtures/TestComponent';
|
|
10
|
+
import config from './fixtures/TestGlobalConfig';
|
|
11
11
|
|
|
12
|
-
jest.mock('../src/hooks/
|
|
12
|
+
jest.mock('../src/hooks/useGlobalConfig');
|
|
13
13
|
|
|
14
14
|
const TestFallback = () => <div>loading...</div>;
|
|
15
15
|
|
|
16
16
|
describe('FederatedComponent', () => {
|
|
17
17
|
it('should match snapshot', async () => {
|
|
18
|
-
jest.spyOn(
|
|
18
|
+
jest.spyOn(useGlobalConfig, 'default').mockReturnValue(config);
|
|
19
19
|
jest.spyOn(remoteLoader, 'default').mockReturnValueOnce(async () => [TestComponent, manifest]);
|
|
20
20
|
|
|
21
21
|
const { container, findByText } = await act(() =>
|
|
@@ -28,18 +28,18 @@ describe('FederatedComponent', () => {
|
|
|
28
28
|
});
|
|
29
29
|
|
|
30
30
|
it('should render fallback while resource is pending', async () => {
|
|
31
|
-
jest.spyOn(
|
|
31
|
+
jest.spyOn(useGlobalConfig, 'default').mockReturnValue(config);
|
|
32
32
|
jest.spyOn(remoteLoader, 'default').mockReturnValueOnce(() => [null, null]);
|
|
33
33
|
|
|
34
34
|
await act(() =>
|
|
35
35
|
render(<FederatedComponent remote="TestModule/TestComponent" fallback={<TestFallback />} />),
|
|
36
36
|
);
|
|
37
37
|
|
|
38
|
-
|
|
38
|
+
expect(screen.getByText(/loading/i)).toBeInTheDocument();
|
|
39
39
|
});
|
|
40
40
|
|
|
41
41
|
it('should render error when resource fails', async () => {
|
|
42
|
-
jest.spyOn(
|
|
42
|
+
jest.spyOn(useGlobalConfig, 'default').mockReturnValue(config);
|
|
43
43
|
jest
|
|
44
44
|
.spyOn(remoteLoader, 'default')
|
|
45
45
|
.mockImplementationOnce(() => new Error('Failed to get resource'));
|
|
@@ -48,6 +48,6 @@ describe('FederatedComponent', () => {
|
|
|
48
48
|
render(<FederatedComponent remote="TestModule/TestComponent" fallback={<TestFallback />} />),
|
|
49
49
|
);
|
|
50
50
|
|
|
51
|
-
|
|
51
|
+
expect(screen.getByText(/Error loading federated component/i)).toBeInTheDocument();
|
|
52
52
|
});
|
|
53
53
|
});
|
|
@@ -23,8 +23,7 @@ jest.mock('../src/components/FederatedComponent', () => ({
|
|
|
23
23
|
}));
|
|
24
24
|
|
|
25
25
|
describe('RenderHost', () => {
|
|
26
|
-
const
|
|
27
|
-
const metadataUrl = 'http://test.com/appshell.metadata.json';
|
|
26
|
+
const configUrl = 'http://test.com/appshell.config.json';
|
|
28
27
|
const remote = 'TestModule/TestComponent';
|
|
29
28
|
|
|
30
29
|
let useState: jest.SpyInstance;
|
|
@@ -33,12 +32,9 @@ describe('RenderHost', () => {
|
|
|
33
32
|
};
|
|
34
33
|
|
|
35
34
|
beforeEach(() => {
|
|
36
|
-
// useEffect = jest.spyOn(React, 'useEffect');
|
|
37
35
|
useState = jest.spyOn(React, 'useState');
|
|
38
36
|
fetch.mockIf(
|
|
39
|
-
(req) =>
|
|
40
|
-
req.url === 'http://test.com/appshell.metadata.json' ||
|
|
41
|
-
req.url === 'http://test.com/appshell.index.json',
|
|
37
|
+
(req) => req.url === 'http://test.com/appshell.config.json',
|
|
42
38
|
() => Promise.resolve({ ok: true, body: JSON.stringify({ test: 'data' }) }),
|
|
43
39
|
);
|
|
44
40
|
});
|
|
@@ -48,86 +44,38 @@ describe('RenderHost', () => {
|
|
|
48
44
|
});
|
|
49
45
|
|
|
50
46
|
it('should match snapshot', async () => {
|
|
51
|
-
mockUseState({
|
|
52
|
-
mockUseState({ metadata: 'bar' });
|
|
47
|
+
mockUseState({ config: 'foo' });
|
|
53
48
|
const { container } = await act(() =>
|
|
54
|
-
render(
|
|
55
|
-
<ReactHost
|
|
56
|
-
indexUrl={indexUrl}
|
|
57
|
-
metadataUrl={metadataUrl}
|
|
58
|
-
remote={remote}
|
|
59
|
-
fallback="Loading"
|
|
60
|
-
/>,
|
|
61
|
-
),
|
|
49
|
+
render(<ReactHost configUrl={configUrl} remote={remote} fallback="Loading" />),
|
|
62
50
|
);
|
|
63
51
|
|
|
64
52
|
expect(container).toMatchSnapshot();
|
|
65
53
|
});
|
|
66
54
|
|
|
67
|
-
it('should render empty when
|
|
55
|
+
it('should render empty when config is pending', async () => {
|
|
68
56
|
mockUseState(undefined);
|
|
69
|
-
mockUseState({ metadata: 'bar' });
|
|
70
57
|
const { container } = render(
|
|
71
|
-
<ReactHost
|
|
72
|
-
indexUrl={indexUrl}
|
|
73
|
-
metadataUrl={metadataUrl}
|
|
74
|
-
remote={remote}
|
|
75
|
-
fallback="Loading"
|
|
76
|
-
/>,
|
|
58
|
+
<ReactHost configUrl={configUrl} remote={remote} fallback="Loading" />,
|
|
77
59
|
);
|
|
78
60
|
|
|
79
61
|
expect(container).toMatchSnapshot();
|
|
80
62
|
});
|
|
81
63
|
|
|
82
|
-
it('should render
|
|
83
|
-
mockUseState({
|
|
84
|
-
|
|
85
|
-
const { container } = render(
|
|
86
|
-
<ReactHost
|
|
87
|
-
indexUrl={indexUrl}
|
|
88
|
-
metadataUrl={metadataUrl}
|
|
89
|
-
remote={remote}
|
|
90
|
-
fallback="Loading"
|
|
91
|
-
/>,
|
|
92
|
-
);
|
|
93
|
-
|
|
94
|
-
expect(container).toMatchSnapshot();
|
|
95
|
-
});
|
|
96
|
-
|
|
97
|
-
it('should render component when index and metadata are available', async () => {
|
|
98
|
-
mockUseState({ index: 'foo' });
|
|
99
|
-
mockUseState({ metadata: 'bar' });
|
|
100
|
-
await act(() =>
|
|
101
|
-
render(
|
|
102
|
-
<ReactHost
|
|
103
|
-
indexUrl={indexUrl}
|
|
104
|
-
metadataUrl={metadataUrl}
|
|
105
|
-
remote={remote}
|
|
106
|
-
fallback="Loading"
|
|
107
|
-
/>,
|
|
108
|
-
),
|
|
109
|
-
);
|
|
64
|
+
it('should render component when config is available', async () => {
|
|
65
|
+
mockUseState({ config: 'foo' });
|
|
66
|
+
await act(() => render(<ReactHost configUrl={configUrl} remote={remote} fallback="Loading" />));
|
|
110
67
|
|
|
111
|
-
|
|
68
|
+
expect(screen.getByText(/test component/i)).toBeInTheDocument();
|
|
112
69
|
});
|
|
113
70
|
|
|
114
71
|
it('should pass props to federated component when available', async () => {
|
|
115
|
-
mockUseState({
|
|
116
|
-
mockUseState({ metadata: 'bar' });
|
|
72
|
+
mockUseState({ config: 'foo' });
|
|
117
73
|
const federatedComponentSpy = jest.spyOn(FederatedComponent, 'default');
|
|
118
74
|
await act(() =>
|
|
119
|
-
render(
|
|
120
|
-
<ReactHost
|
|
121
|
-
indexUrl={indexUrl}
|
|
122
|
-
metadataUrl={metadataUrl}
|
|
123
|
-
remote={remote}
|
|
124
|
-
foo="bar"
|
|
125
|
-
fallback="Loading"
|
|
126
|
-
/>,
|
|
127
|
-
),
|
|
75
|
+
render(<ReactHost configUrl={configUrl} remote={remote} foo="bar" fallback="Loading" />),
|
|
128
76
|
);
|
|
129
77
|
|
|
130
|
-
|
|
78
|
+
expect(screen.getByText(/test component/i)).toBeInTheDocument();
|
|
131
79
|
|
|
132
80
|
expect(federatedComponentSpy).toHaveBeenCalledWith(
|
|
133
81
|
{ fallback: 'Loading', foo: 'bar', remote: 'TestModule/TestComponent' },
|
|
@@ -8,6 +8,4 @@ exports[`RenderHost should match snapshot 1`] = `
|
|
|
8
8
|
</div>
|
|
9
9
|
`;
|
|
10
10
|
|
|
11
|
-
exports[`RenderHost should render empty when
|
|
12
|
-
|
|
13
|
-
exports[`RenderHost should render empty when metadata is pending 1`] = `<div />`;
|
|
11
|
+
exports[`RenderHost should render empty when config is pending 1`] = `<div />`;
|
package/dist/main.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
!function(e,t){if("object"==typeof exports&&"object"==typeof module)module.exports=t(require("react"));else if("function"==typeof define&&define.amd)define(["react"],t);else{var r="object"==typeof exports?t(require("react")):t(e.react);for(var o in r)("object"==typeof exports?exports:e)[o]=r[o]}}(self,(e=>(()=>{"use strict";var t={156:t=>{t.exports=e}},r={};function o(e){var n=r[e];if(void 0!==n)return n.exports;var a=r[e]={exports:{}};return t[e](a,a.exports,o),a.exports}o.n=e=>{var t=e&&e.__esModule?()=>e.default:()=>e;return o.d(t,{a:t}),t},o.d=(e,t)=>{for(var r in t)o.o(t,r)&&!o.o(e,r)&&Object.defineProperty(e,r,{enumerable:!0,get:t[r]})},o.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),o.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},(()=>{o.S={};var e={},t={};o.I=(r,n)=>{n||(n=[]);var a=t[r];if(a||(a=t[r]={}),!(n.indexOf(a)>=0)){if(n.push(a),e[r])return e[r];o.o(o.S,r)||(o.S[r]={}),o.S[r];var
|
|
1
|
+
!function(e,t){if("object"==typeof exports&&"object"==typeof module)module.exports=t(require("react"));else if("function"==typeof define&&define.amd)define(["react"],t);else{var r="object"==typeof exports?t(require("react")):t(e.react);for(var o in r)("object"==typeof exports?exports:e)[o]=r[o]}}(self,(e=>(()=>{"use strict";var t={156:t=>{t.exports=e}},r={};function o(e){var n=r[e];if(void 0!==n)return n.exports;var a=r[e]={exports:{}};return t[e](a,a.exports,o),a.exports}o.n=e=>{var t=e&&e.__esModule?()=>e.default:()=>e;return o.d(t,{a:t}),t},o.d=(e,t)=>{for(var r in t)o.o(t,r)&&!o.o(e,r)&&Object.defineProperty(e,r,{enumerable:!0,get:t[r]})},o.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),o.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},(()=>{o.S={};var e={},t={};o.I=(r,n)=>{n||(n=[]);var a=t[r];if(a||(a=t[r]={}),!(n.indexOf(a)>=0)){if(n.push(a),e[r])return e[r];o.o(o.S,r)||(o.S[r]={}),o.S[r];var c=[];return e[r]=c.length?Promise.all(c).then((()=>e[r]=1)):1}}})();var n={};return(()=>{o.r(n),o.d(n,{FederatedComponent:()=>y,GlobalConfigProvider:()=>u,ManifestProvider:()=>i,MetadataProvider:()=>E,ReactHost:()=>g,jsonResource:()=>j,useGlobalConfig:()=>m,useManifest:()=>$,useMetadata:()=>S});const e=new Set,t=new Set,r=new Map;var a=o(156),c=o.n(a);const s=(0,a.createContext)({remotes:{},modules:{},environment:{}}),i=({manifest:e,children:t})=>c().createElement(s.Provider,{value:e},t),l=(s.Consumer,s),d=(0,a.createContext)({index:{}}),u=({config:e,children:t})=>c().createElement(d.Provider,{value:e},t),f=(d.Consumer,d),m=()=>c().useContext(f),p=({remote:e,reason:t})=>c().createElement("div",{style:{border:"3px solid red"}},c().createElement("h5",null,`Error loading federated component '${e}.'`),c().createElement("span",{style:{fontSize:"1rem"}},t)),h=({remote:n,fallback:s,...l})=>{const d=m(),[u,f]=(0,a.useState)();return(0,a.useEffect)((()=>{let a=!1;const s=(n=>async a=>{let c;const s=n.index[a];if(!s)throw new Error(`Remote resource not found in registry. Expected: ${a}`);try{const n=await(async e=>{if(r.has(e))return r.get(e);r.set(e,void 0);const t=await fetch(e);if(t.ok)return t.json();const o=await t.text();throw new Error(`Failed to get manifest from ${e}. ${o}`)})(s);if(n){r.set(s,n);const i=n.remotes[a];if(window[`__appshell_env__${i.scope}`]=n.environment[i.scope]||{},t.has(i.remoteEntryUrl)||await(async t=>{const r=document.createElement("script");return new Promise(((o,n)=>{e.has(t)?o(!1):(e.add(t),r.src=t,r.type="text/javascript",r.async=!0,r.onload=()=>{console.debug(`Remote entry fetched from '${t}'.`),o(!0)},r.onerror=()=>{const e=`Failed to fetch remote entry from '${t}'.`;console.error(e),n(e)},document.head.appendChild(r))})).finally((()=>{document.head.contains(r)&&document.head.removeChild(r)}))})(i.remoteEntryUrl))return t.add(i.remoteEntryUrl),c=await(async(e,t,r="default")=>{console.debug(`loading federated component: { scope: ${e}, module: ${t}, shareScope: ${r} }`),await o.I(r);const n=window[e];if(!n)throw new Error(`Failed to find module container ${e}`);await n.init(o.S[r]);const a=await n.get(t);if(!a)throw new Error(`Invalid factory produced by container for module ${t}.`);const c=a();return console.debug(`federated component loaded: { scope: ${e}, module: ${t}, shareScope: ${r} }`),c.default})(i.scope,i.module,i.shareScope),[c,n]}return[null,null]}catch(e){throw new Error(`Failed to load component '${a}'. ${e?.toString()}`)}})(d);return a||async function(){try{a=!0,f(void 0);const[e,t]=await s(n);if(!e)return;a=!1,f(c().createElement(i,{manifest:t},c().createElement(e,l)))}catch(e){f(c().createElement(p,{remote:n,reason:`${e}`}))}}(),()=>{a=!1}}),[n,d]),console.debug(`rendering FederatedComponent[${n}], loading=${!u}`),c().createElement(c().Fragment,null,u||s)};h.defaultProps={fallback:void 0};const y=h;function v(){return v=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];for(var o in r)Object.prototype.hasOwnProperty.call(r,o)&&(e[o]=r[o])}return e},v.apply(this,arguments)}const w=({configUrl:e,remote:t,fallback:r,...o})=>{const[n,s]=c().useState();return(0,a.useEffect)((()=>{n||(async()=>{const t=await fetch(e);if(t.ok){const e=await t.json();s(e)}else s({index:{}})})()}),[n,e]),n?c().createElement(u,{config:n},c().createElement(y,v({remote:t,fallback:r},o))):null};w.defaultProps={fallback:void 0};const g=w,b=(0,a.createContext)({}),E=({metata:e,children:t})=>c().createElement(b.Provider,{value:e},t),x=(b.Consumer,b),$=()=>c().useContext(l),S=()=>c().useContext(x),j=e=>{let t,r="pending";const o=fetch(e,{headers:{"Content-Type":"application/json",Accept:"application/json"}}).then((e=>{if(e.ok)return e.json().then((e=>{r="success",t=e}));r="error",t=new Error(`${e.status} ${e.statusText} ${e.url}`)}));return{read(){if("pending"===r)throw o;if("error"===r)throw t;if("success"===r)return t}}}})(),n})()));
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"deregister.d.ts","sourceRoot":"","sources":["../../../../../config/src/deregister.ts"],"names":[],"mappings":"qCAoGkC,MAAM,YAAY,MAAM;AAA1D,wBAeE"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { AppshellGlobalConfig } from './types';
|
|
2
|
+
type GenerateGlobalConfigOptions = {
|
|
3
|
+
insecure: boolean;
|
|
4
|
+
};
|
|
5
|
+
declare const _default: (registries: string[], options?: GenerateGlobalConfigOptions) => Promise<AppshellGlobalConfig>;
|
|
6
|
+
export default _default;
|
|
7
|
+
//# sourceMappingURL=generate.global-config.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"generate.global-config.d.ts","sourceRoot":"","sources":["../../../../../config/src/generate.global-config.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,oBAAoB,EAAE,MAAM,SAAS,CAAC;AAK/C,KAAK,2BAA2B,GAAG;IACjC,QAAQ,EAAE,OAAO,CAAC;CACnB,CAAC;qCAGY,MAAM,EAAE,YACX,2BAA2B,KACnC,QAAQ,oBAAoB,CAAC;AAHhC,wBAuCE"}
|
|
@@ -2,12 +2,12 @@
|
|
|
2
2
|
* @appshell/config package API
|
|
3
3
|
*/
|
|
4
4
|
export { default as configmap } from './configmap';
|
|
5
|
+
export { default as deregister } from './deregister';
|
|
5
6
|
export { default as generateEnv } from './generate.env';
|
|
6
|
-
export { default as
|
|
7
|
+
export { default as generateGlobalConfig } from './generate.global-config';
|
|
7
8
|
export { default as generateManifest } from './generate.manifest';
|
|
8
|
-
export { default as generateMetadata } from './generate.metadata';
|
|
9
9
|
export { default as register } from './register';
|
|
10
|
-
export type { AppshellConfig, AppshellConfigRemote, AppshellIndex, AppshellManifest, AppshellRemote, Metadata, Schema, } from './types';
|
|
10
|
+
export type { AppshellConfig, AppshellConfigRemote, AppshellGlobalConfig, AppshellIndex, AppshellManifest, AppshellRemote, AppshellTemplate, Metadata, Schema, } from './types';
|
|
11
11
|
export * as utils from './utils';
|
|
12
12
|
export * as validators from './validators';
|
|
13
13
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../config/src/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,OAAO,EAAE,OAAO,IAAI,SAAS,EAAE,MAAM,aAAa,CAAC;AACnD,OAAO,EAAE,OAAO,IAAI,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../config/src/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,OAAO,EAAE,OAAO,IAAI,SAAS,EAAE,MAAM,aAAa,CAAC;AACnD,OAAO,EAAE,OAAO,IAAI,UAAU,EAAE,MAAM,cAAc,CAAC;AACrD,OAAO,EAAE,OAAO,IAAI,WAAW,EAAE,MAAM,gBAAgB,CAAC;AACxD,OAAO,EAAE,OAAO,IAAI,oBAAoB,EAAE,MAAM,0BAA0B,CAAC;AAC3E,OAAO,EAAE,OAAO,IAAI,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AAClE,OAAO,EAAE,OAAO,IAAI,QAAQ,EAAE,MAAM,YAAY,CAAC;AACjD,YAAY,EACV,cAAc,EACd,oBAAoB,EACpB,oBAAoB,EACpB,aAAa,EACb,gBAAgB,EAChB,cAAc,EACd,gBAAgB,EAChB,QAAQ,EACR,MAAM,GACP,MAAM,SAAS,CAAC;AACjB,OAAO,KAAK,KAAK,MAAM,SAAS,CAAC;AACjC,OAAO,KAAK,UAAU,MAAM,cAAc,CAAC"}
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export declare const toAppshellManifest: <TMetadata extends Record<string, unknown>>(
|
|
1
|
+
import { AppshellManifest, AppshellTemplate, ConfigMap } from '../types';
|
|
2
|
+
export declare const toAppshellManifest: <TMetadata extends Record<string, unknown>>(template: AppshellTemplate, args: ConfigMap) => AppshellManifest<TMetadata>;
|
|
3
3
|
//# sourceMappingURL=appshell.config.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"appshell.config.d.ts","sourceRoot":"","sources":["../../../../../../config/src/mappers/appshell.config.ts"],"names":[],"mappings":"AAIA,OAAO,
|
|
1
|
+
{"version":3,"file":"appshell.config.d.ts","sourceRoot":"","sources":["../../../../../../config/src/mappers/appshell.config.ts"],"names":[],"mappings":"AAIA,OAAO,EAEL,gBAAgB,EAEhB,gBAAgB,EAChB,SAAS,EACV,MAAM,UAAU,CAAC;AA6DlB,eAAO,MAAM,kBAAkB,wDACnB,gBAAgB,QACpB,SAAS,gCAQhB,CAAC"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import { AppshellManifest } from './types';
|
|
2
|
-
declare const _default: (manifest: AppshellManifest,
|
|
2
|
+
declare const _default: (manifest: AppshellManifest, registryPathOrUrl: string) => Promise<void>;
|
|
3
3
|
export default _default;
|
|
4
4
|
//# sourceMappingURL=register.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"register.d.ts","sourceRoot":"","sources":["../../../../../config/src/register.ts"],"names":[],"mappings":"AAEA,OAAO,
|
|
1
|
+
{"version":3,"file":"register.d.ts","sourceRoot":"","sources":["../../../../../config/src/register.ts"],"names":[],"mappings":"AAEA,OAAO,EAAwB,gBAAgB,EAAmB,MAAM,SAAS,CAAC;mCAclD,gBAAgB,qBAAqB,MAAM;AAA3E,wBAmCE"}
|
|
@@ -11,10 +11,17 @@ export type AppshellConfigRemote<TMetadata = Metadata> = {
|
|
|
11
11
|
metadata: TMetadata;
|
|
12
12
|
};
|
|
13
13
|
export type AppshellConfig<TMetadata = Metadata> = {
|
|
14
|
+
name?: string;
|
|
15
|
+
remotes?: Record<string, AppshellConfigRemote<TMetadata>>;
|
|
16
|
+
environment?: Record<string, unknown>;
|
|
17
|
+
overrides?: AppshellOverrides;
|
|
18
|
+
};
|
|
19
|
+
export type AppshellTemplate<TMetadata = Metadata> = {
|
|
14
20
|
name?: string;
|
|
15
21
|
remotes?: Record<string, AppshellConfigRemote<TMetadata>>;
|
|
16
22
|
module: ModuleFederationPluginOptions;
|
|
17
23
|
environment?: Record<string, unknown>;
|
|
24
|
+
overrides?: AppshellOverrides;
|
|
18
25
|
};
|
|
19
26
|
/** Appshell manifest types */
|
|
20
27
|
export type AppshellRemote<TMetadata = Metadata> = {
|
|
@@ -26,13 +33,22 @@ export type AppshellRemote<TMetadata = Metadata> = {
|
|
|
26
33
|
shareScope?: string;
|
|
27
34
|
metadata: TMetadata;
|
|
28
35
|
};
|
|
36
|
+
export type AppshellOverrides = {
|
|
37
|
+
environment: Record<string, Record<string, string | number | undefined>>;
|
|
38
|
+
};
|
|
29
39
|
export type AppshellManifest<TMetadata = Metadata> = {
|
|
30
40
|
remotes: Record<string, AppshellRemote<TMetadata>>;
|
|
31
41
|
modules: Record<string, ModuleFederationPluginOptions>;
|
|
32
42
|
environment: Record<string, Record<string, string | number | undefined>>;
|
|
43
|
+
overrides?: AppshellOverrides;
|
|
33
44
|
};
|
|
34
45
|
export type AppshellIndex = Record<string, string>;
|
|
35
46
|
export type Metadata = Record<string, unknown>;
|
|
47
|
+
export type AppshellGlobalConfig<TMetadata = Metadata> = {
|
|
48
|
+
index: AppshellIndex;
|
|
49
|
+
metadata?: Record<string, TMetadata>;
|
|
50
|
+
overrides?: AppshellOverrides;
|
|
51
|
+
};
|
|
36
52
|
/**
|
|
37
53
|
* Advanced configuration for modules that should be exposed by this container.
|
|
38
54
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../../config/src/types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,WAAW,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAEpE,MAAM,MAAM,MAAM,GAAG,WAAW,GAAG,WAAW,GAAG,WAAW,CAAC;AAE7D,MAAM,MAAM,eAAe,GAAG;IAC5B,QAAQ,EAAE,CAAC,CAAC,EAAE,GAAG,MAAM,EAAE,CAAC,EAAE,KAAK,IAAI,CAAC;CACvC,CAAC;AAEF,MAAM,MAAM,SAAS,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;AAG/C,MAAM,MAAM,oBAAoB,CAAC,SAAS,GAAG,QAAQ,IAAI;IACvD,EAAE,EAAE,MAAM,CAAC;IACX,GAAG,EAAE,MAAM,CAAC;IACZ,QAAQ,EAAE,MAAM,CAAC;IACjB,QAAQ,EAAE,SAAS,CAAC;CACrB,CAAC;AAEF,MAAM,MAAM,cAAc,CAAC,SAAS,GAAG,QAAQ,IAAI;IACjD,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,oBAAoB,CAAC,SAAS,CAAC,CAAC,CAAC;IAC1D,MAAM,EAAE,6BAA6B,CAAC;IACtC,WAAW,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../../config/src/types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,WAAW,EAAE,WAAW,EAA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U,CAAC,EAAE,MAAM,CAAC;IAEpB;;OAEG;IACH,MAAM,CAAC,EAAE,CAAC,MAAM,GAAG,YAAY,CAAC,EAAE,GAAG,YAAY,CAAC;CACnD"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"load.d.ts","sourceRoot":"","sources":["../../../../../../config/src/utils/load.ts"],"names":[],"mappings":"AAGA;;;;GAIG;AACH,QAAA,MAAM,IAAI,wBAAyB,MAAM,
|
|
1
|
+
{"version":3,"file":"load.d.ts","sourceRoot":"","sources":["../../../../../../config/src/utils/load.ts"],"names":[],"mappings":"AAGA;;;;GAIG;AACH,QAAA,MAAM,IAAI,wBAAyB,MAAM,YAUxC,CAAC;AAEF;;;;GAIG;AACH,eAAO,MAAM,OAAO,sBAAuB,MAAM,EAAE,cAA+C,CAAC;AAEnG,eAAe,IAAI,CAAC"}
|
|
@@ -1,3 +1,7 @@
|
|
|
1
|
-
|
|
1
|
+
type LoadJsonOptions = {
|
|
2
|
+
insecure: boolean;
|
|
3
|
+
target: string | RegExp;
|
|
4
|
+
};
|
|
5
|
+
declare const _default: <T = Record<string, unknown>>(jsonPathOrUrl: string, options?: LoadJsonOptions) => Promise<T[]>;
|
|
2
6
|
export default _default;
|
|
3
7
|
//# sourceMappingURL=loadJson.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"loadJson.d.ts","sourceRoot":"","sources":["../../../../../../config/src/utils/loadJson.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"loadJson.d.ts","sourceRoot":"","sources":["../../../../../../config/src/utils/loadJson.ts"],"names":[],"mappings":"AAOA,KAAK,eAAe,GAAG;IACrB,QAAQ,EAAE,OAAO,CAAC;IAClB,MAAM,EAAE,MAAM,GAAG,MAAM,CAAC;CACzB,CAAC;qEAkCe,MAAM,YACZ,eAAe;AAF1B,wBAUE"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"AppshellGlobalConfigValidator.d.ts","sourceRoot":"","sources":["../../../../../../config/src/validators/AppshellGlobalConfigValidator.ts"],"names":[],"mappings":"AAGA,OAAO,EAAwB,eAAe,EAAE,MAAM,UAAU,CAAC;;AAEjE,wBAKqB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"AppshellManifestValidator.d.ts","sourceRoot":"","sources":["../../../../../../config/src/validators/AppshellManifestValidator.ts"],"names":[],"mappings":"AAMA,OAAO,EAAoB,eAAe,EAAE,MAAM,UAAU,CAAC;;AAyB7D,wBAkBqB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"AppshellTemplateValidator.d.ts","sourceRoot":"","sources":["../../../../../../config/src/validators/AppshellTemplateValidator.ts"],"names":[],"mappings":"AAMA,OAAO,EAAoB,eAAe,EAAE,MAAM,UAAU,CAAC;;AAuB7D,wBAkBqB"}
|
|
@@ -1,6 +1,4 @@
|
|
|
1
|
-
export { default as
|
|
2
|
-
export { default as
|
|
3
|
-
export { default as
|
|
4
|
-
export { default as appshell_metadata } from './appshell.metadata';
|
|
5
|
-
export { default as merge_manifests } from './merge.manifests';
|
|
1
|
+
export { default as AppshellGlobalConfigValidator } from './AppshellGlobalConfigValidator';
|
|
2
|
+
export { default as AppshellManifestValidator } from './AppshellManifestValidator';
|
|
3
|
+
export { default as AppshellTemplateValidator } from './AppshellTemplateValidator';
|
|
6
4
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../../config/src/validators/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,IAAI,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../../config/src/validators/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,IAAI,6BAA6B,EAAE,MAAM,iCAAiC,CAAC;AAC3F,OAAO,EAAE,OAAO,IAAI,yBAAyB,EAAE,MAAM,6BAA6B,CAAC;AACnF,OAAO,EAAE,OAAO,IAAI,yBAAyB,EAAE,MAAM,6BAA6B,CAAC"}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import { type
|
|
2
|
-
|
|
1
|
+
import { type AppshellManifest } from '@appshell/config';
|
|
2
|
+
import { AppshellGlobalConfig } from 'packages/config/src/types';
|
|
3
|
+
declare const _default: (config: AppshellGlobalConfig) => <TComponent>(key: string) => Promise<readonly [TComponent, AppshellManifest<import("@appshell/config").Metadata>] | readonly [null, null]>;
|
|
3
4
|
export default _default;
|
|
4
5
|
//# sourceMappingURL=remoteLoader.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"remoteLoader.d.ts","sourceRoot":"","sources":["../../../../../loader/src/remoteLoader.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,
|
|
1
|
+
{"version":3,"file":"remoteLoader.d.ts","sourceRoot":"","sources":["../../../../../loader/src/remoteLoader.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,gBAAgB,EAAE,MAAM,kBAAkB,CAAC;AACzD,OAAO,EAAE,oBAAoB,EAAE,MAAM,2BAA2B,CAAC;iCAwBzC,oBAAoB,uBAClB,MAAM;AADhC,wBAsCI"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ReactHost.d.ts","sourceRoot":"","sources":["../../../../../src/components/ReactHost.tsx"],"names":[],"mappings":"AAEA,OAAc,EAAE,EAAE,EAAE,SAAS,EAAa,MAAM,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"ReactHost.d.ts","sourceRoot":"","sources":["../../../../../src/components/ReactHost.tsx"],"names":[],"mappings":"AAEA,OAAc,EAAE,EAAE,EAAE,SAAS,EAAa,MAAM,OAAO,CAAC;AAIxD,QAAA,MAAM,SAAS,EAAE,EAAE,CAAC;IAClB,SAAS,EAAE,MAAM,CAAC;IAClB,MAAM,EAAE,MAAM,CAAC;IACf,QAAQ,CAAC,EAAE,SAAS,CAAC;IACrB,CAAC,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC;CACtB,CA6BA,CAAC;AAMF,eAAe,SAAS,CAAC"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { AppshellGlobalConfig } from 'packages/config/src/types';
|
|
2
|
+
import React, { FC, ReactNode } from 'react';
|
|
3
|
+
interface GlobalConfigProviderProps {
|
|
4
|
+
config: AppshellGlobalConfig;
|
|
5
|
+
children: ReactNode;
|
|
6
|
+
}
|
|
7
|
+
export declare const GlobalConfigContext: React.Context<AppshellGlobalConfig<import("packages/config/src/types").Metadata>>;
|
|
8
|
+
export declare const GlobalConfigProvider: FC<GlobalConfigProviderProps>;
|
|
9
|
+
export declare const GlobalConfigConsumer: React.Consumer<AppshellGlobalConfig<import("packages/config/src/types").Metadata>>;
|
|
10
|
+
export default GlobalConfigContext;
|
|
11
|
+
//# sourceMappingURL=GlobalConfigContext.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"GlobalConfigContext.d.ts","sourceRoot":"","sources":["../../../../../src/contexts/GlobalConfigContext.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAE,MAAM,2BAA2B,CAAC;AACjE,OAAO,KAAK,EAAE,EAAiB,EAAE,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAE5D,UAAU,yBAAyB;IACjC,MAAM,EAAE,oBAAoB,CAAC;IAC7B,QAAQ,EAAE,SAAS,CAAC;CACrB;AAED,eAAO,MAAM,mBAAmB,mFAAqD,CAAC;AAEtF,eAAO,MAAM,oBAAoB,EAAE,EAAE,CAAC,yBAAyB,CAE9D,CAAC;AAEF,eAAO,MAAM,oBAAoB,oFAA+B,CAAC;AAEjE,eAAe,mBAAmB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useGlobalConfig.d.ts","sourceRoot":"","sources":["../../../../../src/hooks/useGlobalConfig.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAE,MAAM,2BAA2B,CAAC;8BAK9C,oBAAoB;AAAvC,wBAC8D"}
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
export { default as FederatedComponent } from './components/FederatedComponent';
|
|
2
2
|
export { default as ReactHost } from './components/ReactHost';
|
|
3
|
+
export { GlobalConfigProvider } from './contexts/GlobalConfigContext';
|
|
3
4
|
export { ManifestProvider } from './contexts/ManifestContext';
|
|
4
5
|
export { MetadataProvider } from './contexts/MetadataContext';
|
|
5
|
-
export {
|
|
6
|
+
export { default as useGlobalConfig } from './hooks/useGlobalConfig';
|
|
6
7
|
export { default as useManifest } from './hooks/useManifest';
|
|
7
8
|
export { default as useMetadata } from './hooks/useMetadata';
|
|
8
|
-
export { default as useRegistry } from './hooks/useRegistry';
|
|
9
9
|
export { default as jsonResource } from './resources/jsonResource';
|
|
10
10
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,IAAI,kBAAkB,EAAE,MAAM,iCAAiC,CAAC;AAChF,OAAO,EAAE,OAAO,IAAI,SAAS,EAAE,MAAM,wBAAwB,CAAC;AAC9D,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,IAAI,kBAAkB,EAAE,MAAM,iCAAiC,CAAC;AAChF,OAAO,EAAE,OAAO,IAAI,SAAS,EAAE,MAAM,wBAAwB,CAAC;AAC9D,OAAO,EAAE,oBAAoB,EAAE,MAAM,gCAAgC,CAAC;AACtE,OAAO,EAAE,gBAAgB,EAAE,MAAM,4BAA4B,CAAC;AAC9D,OAAO,EAAE,gBAAgB,EAAE,MAAM,4BAA4B,CAAC;AAC9D,OAAO,EAAE,OAAO,IAAI,eAAe,EAAE,MAAM,yBAAyB,CAAC;AACrE,OAAO,EAAE,OAAO,IAAI,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAC7D,OAAO,EAAE,OAAO,IAAI,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAC7D,OAAO,EAAE,OAAO,IAAI,YAAY,EAAE,MAAM,0BAA0B,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@appshell/react",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.2.0-alpha.0",
|
|
4
4
|
"description": "React utilities for loading federated components",
|
|
5
5
|
"main": "dist/main.js",
|
|
6
6
|
"types": "dist/types/react/src/index.d.ts",
|
|
@@ -28,5 +28,5 @@
|
|
|
28
28
|
"react": "^18.2.0",
|
|
29
29
|
"react-dom": "^18.2.0"
|
|
30
30
|
},
|
|
31
|
-
"gitHead": "
|
|
31
|
+
"gitHead": "a4216a032817193034b208f93ac7109458ef2c06"
|
|
32
32
|
}
|
|
@@ -3,7 +3,7 @@ import { AppshellIndex } from '@appshell/config';
|
|
|
3
3
|
import remoteLoader from '@appshell/loader';
|
|
4
4
|
import React, { ComponentType, ReactElement, ReactNode, useEffect, useState } from 'react';
|
|
5
5
|
import { ManifestProvider } from '../contexts/ManifestContext';
|
|
6
|
-
import
|
|
6
|
+
import useGlobalConfig from '../hooks/useGlobalConfig';
|
|
7
7
|
import LoadingError from './LoadingError';
|
|
8
8
|
|
|
9
9
|
export type ExtendedProps = Record<string, unknown>;
|
|
@@ -24,12 +24,12 @@ const FederatedComponent = <TProps extends ExtendedProps>({
|
|
|
24
24
|
fallback,
|
|
25
25
|
...rest
|
|
26
26
|
}: FederatedComponentProps<TProps>): ReactElement<TProps> => {
|
|
27
|
-
const
|
|
27
|
+
const config = useGlobalConfig();
|
|
28
28
|
const [element, setElement] = useState<ReactElement>();
|
|
29
29
|
|
|
30
30
|
useEffect(() => {
|
|
31
31
|
let active = false;
|
|
32
|
-
const loadComponent = remoteLoader(
|
|
32
|
+
const loadComponent = remoteLoader(config);
|
|
33
33
|
|
|
34
34
|
async function load() {
|
|
35
35
|
try {
|
|
@@ -58,7 +58,7 @@ const FederatedComponent = <TProps extends ExtendedProps>({
|
|
|
58
58
|
active = false;
|
|
59
59
|
};
|
|
60
60
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
61
|
-
}, [remote,
|
|
61
|
+
}, [remote, config]);
|
|
62
62
|
|
|
63
63
|
// eslint-disable-next-line no-console
|
|
64
64
|
console.debug(`rendering FederatedComponent[${remote}], loading=${!element}`);
|
|
@@ -1,64 +1,42 @@
|
|
|
1
1
|
/* eslint-disable react/jsx-props-no-spreading */
|
|
2
|
-
import {
|
|
2
|
+
import { AppshellGlobalConfig } from 'packages/config/src/types';
|
|
3
3
|
import React, { FC, ReactNode, useEffect } from 'react';
|
|
4
|
-
import {
|
|
5
|
-
import { RegistryProvider } from '../contexts/RegistryContext';
|
|
4
|
+
import { GlobalConfigProvider } from '../contexts/GlobalConfigContext';
|
|
6
5
|
import FederatedComponent from './FederatedComponent';
|
|
7
6
|
|
|
8
7
|
const ReactHost: FC<{
|
|
9
|
-
|
|
10
|
-
metadataUrl: string;
|
|
8
|
+
configUrl: string;
|
|
11
9
|
remote: string;
|
|
12
10
|
fallback?: ReactNode;
|
|
13
11
|
[x: string]: unknown;
|
|
14
|
-
}> = ({
|
|
15
|
-
const [
|
|
16
|
-
const [metadata, setMetadata] = React.useState<Metadata>();
|
|
12
|
+
}> = ({ configUrl, remote, fallback, ...rest }) => {
|
|
13
|
+
const [config, setGlobalConfig] = React.useState<AppshellGlobalConfig>();
|
|
17
14
|
|
|
18
15
|
useEffect(() => {
|
|
19
|
-
const
|
|
20
|
-
const res = await fetch(
|
|
16
|
+
const fetchGlobalConfig = async () => {
|
|
17
|
+
const res = await fetch(configUrl);
|
|
21
18
|
|
|
22
19
|
if (res.ok) {
|
|
23
20
|
const data = await res.json();
|
|
24
|
-
|
|
21
|
+
setGlobalConfig(data);
|
|
25
22
|
} else {
|
|
26
|
-
|
|
23
|
+
setGlobalConfig({ index: {} });
|
|
27
24
|
}
|
|
28
25
|
};
|
|
29
26
|
|
|
30
|
-
if (!
|
|
31
|
-
|
|
27
|
+
if (!config) {
|
|
28
|
+
fetchGlobalConfig();
|
|
32
29
|
}
|
|
33
|
-
}, [
|
|
30
|
+
}, [config, configUrl]);
|
|
34
31
|
|
|
35
|
-
|
|
36
|
-
const fetchMetadata = async () => {
|
|
37
|
-
const res = await fetch(metadataUrl);
|
|
38
|
-
|
|
39
|
-
if (res.ok) {
|
|
40
|
-
const data = await res.json();
|
|
41
|
-
setMetadata(data);
|
|
42
|
-
} else {
|
|
43
|
-
setMetadata({});
|
|
44
|
-
}
|
|
45
|
-
};
|
|
46
|
-
|
|
47
|
-
if (!metadata) {
|
|
48
|
-
fetchMetadata();
|
|
49
|
-
}
|
|
50
|
-
}, [metadata, metadataUrl]);
|
|
51
|
-
|
|
52
|
-
if (!index || !metadata) {
|
|
32
|
+
if (!config) {
|
|
53
33
|
return null;
|
|
54
34
|
}
|
|
55
35
|
|
|
56
36
|
return (
|
|
57
|
-
<
|
|
58
|
-
<
|
|
59
|
-
|
|
60
|
-
</MetadataProvider>
|
|
61
|
-
</RegistryProvider>
|
|
37
|
+
<GlobalConfigProvider config={config}>
|
|
38
|
+
<FederatedComponent remote={remote} fallback={fallback} {...rest} />
|
|
39
|
+
</GlobalConfigProvider>
|
|
62
40
|
);
|
|
63
41
|
};
|
|
64
42
|
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { AppshellGlobalConfig } from 'packages/config/src/types';
|
|
2
|
+
import React, { createContext, FC, ReactNode } from 'react';
|
|
3
|
+
|
|
4
|
+
interface GlobalConfigProviderProps {
|
|
5
|
+
config: AppshellGlobalConfig;
|
|
6
|
+
children: ReactNode;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
export const GlobalConfigContext = createContext<AppshellGlobalConfig>({ index: {} });
|
|
10
|
+
|
|
11
|
+
export const GlobalConfigProvider: FC<GlobalConfigProviderProps> = ({ config, children }) => (
|
|
12
|
+
<GlobalConfigContext.Provider value={config}>{children}</GlobalConfigContext.Provider>
|
|
13
|
+
);
|
|
14
|
+
|
|
15
|
+
export const GlobalConfigConsumer = GlobalConfigContext.Consumer;
|
|
16
|
+
|
|
17
|
+
export default GlobalConfigContext;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { AppshellGlobalConfig } from 'packages/config/src/types';
|
|
2
|
+
import React from 'react';
|
|
3
|
+
// eslint-disable-next-line import/no-named-as-default
|
|
4
|
+
import GlobalConfigContext from '../contexts/GlobalConfigContext';
|
|
5
|
+
|
|
6
|
+
export default (): AppshellGlobalConfig =>
|
|
7
|
+
React.useContext<AppshellGlobalConfig>(GlobalConfigContext);
|
package/src/index.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
export { default as FederatedComponent } from './components/FederatedComponent';
|
|
2
2
|
export { default as ReactHost } from './components/ReactHost';
|
|
3
|
+
export { GlobalConfigProvider } from './contexts/GlobalConfigContext';
|
|
3
4
|
export { ManifestProvider } from './contexts/ManifestContext';
|
|
4
5
|
export { MetadataProvider } from './contexts/MetadataContext';
|
|
5
|
-
export {
|
|
6
|
+
export { default as useGlobalConfig } from './hooks/useGlobalConfig';
|
|
6
7
|
export { default as useManifest } from './hooks/useManifest';
|
|
7
8
|
export { default as useMetadata } from './hooks/useMetadata';
|
|
8
|
-
export { default as useRegistry } from './hooks/useRegistry';
|
|
9
9
|
export { default as jsonResource } from './resources/jsonResource';
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"generate.index.d.ts","sourceRoot":"","sources":["../../../../../config/src/generate.index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;qCAKN,MAAM,EAAE,KAAG,QAAQ,aAAa,CAAC;AAAnE,wBAyBE"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"generate.metadata.d.ts","sourceRoot":"","sources":["../../../../../config/src/generate.metadata.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;mEAK6B,MAAM,EAAE;AAAxE,wBAyBE"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"appshell.config.d.ts","sourceRoot":"","sources":["../../../../../../config/src/validators/appshell.config.ts"],"names":[],"mappings":"AAIA,OAAO,EAAkB,eAAe,EAAE,MAAM,UAAU,CAAC;;AAuB3D,wBAkBqB"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"appshell.index.d.ts","sourceRoot":"","sources":["../../../../../../config/src/validators/appshell.index.ts"],"names":[],"mappings":"AAGA,OAAO,EAAiB,eAAe,EAAE,MAAM,UAAU,CAAC;;AAE1D,wBAKqB"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"appshell.manifest.d.ts","sourceRoot":"","sources":["../../../../../../config/src/validators/appshell.manifest.ts"],"names":[],"mappings":"AAIA,OAAO,EAAoB,eAAe,EAAE,MAAM,UAAU,CAAC;;AAyB7D,wBAkBqB"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"appshell.metadata.d.ts","sourceRoot":"","sources":["../../../../../../config/src/validators/appshell.metadata.ts"],"names":[],"mappings":"AAGA,OAAO,EAAiB,eAAe,EAAE,MAAM,UAAU,CAAC;;AAE1D,wBAKqB"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"merge.manifests.d.ts","sourceRoot":"","sources":["../../../../../../config/src/validators/merge.manifests.ts"],"names":[],"mappings":"AAGA,OAAO,EAAoB,eAAe,EAAE,MAAM,UAAU,CAAC;;AAE7D,wBAKqB"}
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import { AppshellIndex } from '@appshell/config';
|
|
2
|
-
import React, { FC, ReactNode } from 'react';
|
|
3
|
-
interface RegistryProviderProps {
|
|
4
|
-
index: AppshellIndex;
|
|
5
|
-
children: ReactNode;
|
|
6
|
-
}
|
|
7
|
-
export declare const RegistryContext: React.Context<AppshellIndex>;
|
|
8
|
-
export declare const RegistryProvider: FC<RegistryProviderProps>;
|
|
9
|
-
export declare const RegistryConsumer: React.Consumer<AppshellIndex>;
|
|
10
|
-
export default RegistryContext;
|
|
11
|
-
//# sourceMappingURL=RegistryContext.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"RegistryContext.d.ts","sourceRoot":"","sources":["../../../../../src/contexts/RegistryContext.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AACjD,OAAO,KAAK,EAAE,EAAiB,EAAE,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAE5D,UAAU,qBAAqB;IAC7B,KAAK,EAAE,aAAa,CAAC;IACrB,QAAQ,EAAE,SAAS,CAAC;CACrB;AAED,eAAO,MAAM,eAAe,8BAAmC,CAAC;AAEhE,eAAO,MAAM,gBAAgB,EAAE,EAAE,CAAC,qBAAqB,CAEtD,CAAC;AAEF,eAAO,MAAM,gBAAgB,+BAA2B,CAAC;AAEzD,eAAe,eAAe,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"useRegistry.d.ts","sourceRoot":"","sources":["../../../../../src/hooks/useRegistry.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;8BAK9B,aAAa;AAAhC,wBAAqF"}
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import { AppshellIndex } from '@appshell/config';
|
|
2
|
-
import React, { createContext, FC, ReactNode } from 'react';
|
|
3
|
-
|
|
4
|
-
interface RegistryProviderProps {
|
|
5
|
-
index: AppshellIndex;
|
|
6
|
-
children: ReactNode;
|
|
7
|
-
}
|
|
8
|
-
|
|
9
|
-
export const RegistryContext = createContext<AppshellIndex>({});
|
|
10
|
-
|
|
11
|
-
export const RegistryProvider: FC<RegistryProviderProps> = ({ index, children }) => (
|
|
12
|
-
<RegistryContext.Provider value={index}>{children}</RegistryContext.Provider>
|
|
13
|
-
);
|
|
14
|
-
|
|
15
|
-
export const RegistryConsumer = RegistryContext.Consumer;
|
|
16
|
-
|
|
17
|
-
export default RegistryContext;
|
package/src/hooks/useRegistry.ts
DELETED
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
import { AppshellIndex } from '@appshell/config';
|
|
2
|
-
import React from 'react';
|
|
3
|
-
// eslint-disable-next-line import/no-named-as-default
|
|
4
|
-
import RegistryContext from '../contexts/RegistryContext';
|
|
5
|
-
|
|
6
|
-
export default (): AppshellIndex => React.useContext<AppshellIndex>(RegistryContext);
|