@appshell/react 1.0.0-alpha.14 → 1.0.0-alpha.16

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 (86) hide show
  1. package/CHANGELOG.md +11 -0
  2. package/README.md +36 -49
  3. package/__tests__/{AppshellComponent.spec.tsx → RemoteSlot.spec.tsx} +6 -13
  4. package/__tests__/__snapshots__/{AppshellComponent.spec.tsx.snap → RemoteSlot.spec.tsx.snap} +1 -1
  5. package/__tests__/fixtures/Manifest.ts +1 -1
  6. package/dist/main.js +1 -1
  7. package/dist/types/config/src/context.d.ts +3 -3
  8. package/dist/types/config/src/credentials.d.ts +0 -1
  9. package/dist/types/config/src/credentials.d.ts.map +1 -1
  10. package/dist/types/config/src/index.d.ts +2 -6
  11. package/dist/types/config/src/index.d.ts.map +1 -1
  12. package/dist/types/config/src/publish.d.ts +3 -3
  13. package/dist/types/config/src/publish.d.ts.map +1 -1
  14. package/dist/types/config/src/types.d.ts +9 -14
  15. package/dist/types/config/src/types.d.ts.map +1 -1
  16. package/dist/types/config/src/utils/index.d.ts +0 -3
  17. package/dist/types/config/src/utils/index.d.ts.map +1 -1
  18. package/dist/types/config/src/validators/index.d.ts +0 -2
  19. package/dist/types/config/src/validators/index.d.ts.map +1 -1
  20. package/dist/types/loader/src/remoteLoader.d.ts +2 -3
  21. package/dist/types/loader/src/remoteLoader.d.ts.map +1 -1
  22. package/dist/types/loader/src/resolvers.d.ts +4 -11
  23. package/dist/types/loader/src/resolvers.d.ts.map +1 -1
  24. package/dist/types/react/src/components/{AppshellComponent.d.ts → RemoteSlot.d.ts} +5 -21
  25. package/dist/types/react/src/components/RemoteSlot.d.ts.map +1 -0
  26. package/dist/types/react/src/hooks/useRemote.d.ts +1 -1
  27. package/dist/types/react/src/hooks/useRemote.d.ts.map +1 -1
  28. package/dist/types/react/src/index.d.ts +1 -8
  29. package/dist/types/react/src/index.d.ts.map +1 -1
  30. package/dist/types/runtime/src/errors.d.ts +26 -0
  31. package/dist/types/runtime/src/errors.d.ts.map +1 -0
  32. package/dist/types/runtime/src/index.d.ts +4 -0
  33. package/dist/types/runtime/src/index.d.ts.map +1 -0
  34. package/dist/types/runtime/src/store.d.ts +26 -0
  35. package/dist/types/runtime/src/store.d.ts.map +1 -0
  36. package/dist/types/runtime/src/types.d.ts +10 -0
  37. package/dist/types/runtime/src/types.d.ts.map +1 -0
  38. package/package.json +9 -3
  39. package/src/components/{AppshellComponent.tsx → RemoteSlot.tsx} +12 -29
  40. package/src/hooks/useRemote.ts +1 -1
  41. package/src/index.ts +1 -8
  42. package/webpack.config.js +3 -0
  43. package/__tests__/ManifestContext.spec.tsx +0 -50
  44. package/__tests__/ReactHost.spec.tsx +0 -136
  45. package/__tests__/__snapshots__/ReactHost.spec.tsx.snap +0 -11
  46. package/__tests__/fixtures/TestGlobalConfig.ts +0 -8
  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/register.d.ts +0 -4
  54. package/dist/types/config/src/register.d.ts.map +0 -1
  55. package/dist/types/config/src/utils/isValidUrl.d.ts +0 -3
  56. package/dist/types/config/src/utils/isValidUrl.d.ts.map +0 -1
  57. package/dist/types/config/src/utils/loadJson.d.ts +0 -10
  58. package/dist/types/config/src/utils/loadJson.d.ts.map +0 -1
  59. package/dist/types/config/src/utils/merge.d.ts +0 -4
  60. package/dist/types/config/src/utils/merge.d.ts.map +0 -1
  61. package/dist/types/config/src/validators/AppshellGlobalConfigValidator.d.ts +0 -4
  62. package/dist/types/config/src/validators/AppshellGlobalConfigValidator.d.ts.map +0 -1
  63. package/dist/types/config/src/validators/AppshellManifestValidator.d.ts +0 -4
  64. package/dist/types/config/src/validators/AppshellManifestValidator.d.ts.map +0 -1
  65. package/dist/types/react/src/components/AppshellComponent.d.ts.map +0 -1
  66. package/dist/types/react/src/components/ReactHost.d.ts +0 -9
  67. package/dist/types/react/src/components/ReactHost.d.ts.map +0 -1
  68. package/dist/types/react/src/contexts/GlobalConfigContext.d.ts +0 -11
  69. package/dist/types/react/src/contexts/GlobalConfigContext.d.ts.map +0 -1
  70. package/dist/types/react/src/contexts/ManifestContext.d.ts +0 -12
  71. package/dist/types/react/src/contexts/ManifestContext.d.ts.map +0 -1
  72. package/dist/types/react/src/contexts/MetadataContext.d.ts +0 -11
  73. package/dist/types/react/src/contexts/MetadataContext.d.ts.map +0 -1
  74. package/dist/types/react/src/hooks/useGlobalConfig.d.ts +0 -4
  75. package/dist/types/react/src/hooks/useGlobalConfig.d.ts.map +0 -1
  76. package/dist/types/react/src/hooks/useManifest.d.ts +0 -4
  77. package/dist/types/react/src/hooks/useManifest.d.ts.map +0 -1
  78. package/dist/types/react/src/hooks/useMetadata.d.ts +0 -4
  79. package/dist/types/react/src/hooks/useMetadata.d.ts.map +0 -1
  80. package/src/components/ReactHost.tsx +0 -55
  81. package/src/contexts/GlobalConfigContext.tsx +0 -17
  82. package/src/contexts/ManifestContext.tsx +0 -40
  83. package/src/contexts/MetadataContext.tsx +0 -17
  84. package/src/hooks/useGlobalConfig.ts +0 -7
  85. package/src/hooks/useManifest.ts +0 -7
  86. package/src/hooks/useMetadata.ts +0 -6
@@ -1,50 +0,0 @@
1
- /** @jest-environment jsdom */
2
- import '@testing-library/jest-dom';
3
- import { render, screen } from '@testing-library/react';
4
- import React from 'react';
5
- import { ManifestProvider } from '../src/contexts/ManifestContext';
6
- import useManifest from '../src/hooks/useManifest';
7
- import manifest from './fixtures/Manifest';
8
- import TestComponent from './fixtures/TestComponent';
9
-
10
- const ComponentUsingManifest = () => {
11
- const res = useManifest();
12
-
13
- return <div>{JSON.stringify(res.remotes)}</div>;
14
- };
15
-
16
- describe('ManifestProvider', () => {
17
- it('should render children', async () => {
18
- render(
19
- <ManifestProvider manifest={manifest}>
20
- <TestComponent />
21
- </ManifestProvider>,
22
- );
23
-
24
- await expect(screen.getByText(/test component/i)).toBeInTheDocument();
25
- });
26
-
27
- it('should make the manifest context available', async () => {
28
- render(
29
- <ManifestProvider manifest={manifest}>
30
- <ComponentUsingManifest />
31
- </ManifestProvider>,
32
- );
33
-
34
- await expect(screen.getByText(/TestModule\/TestComponent/i)).toBeInTheDocument();
35
- });
36
-
37
- it('should warn when a consumer reads the deprecated modules field', () => {
38
- const warn = jest.spyOn(console, 'warn').mockImplementation(() => {});
39
- const ComponentUsingModules = () => <div>{Object.keys(useManifest().modules).length}</div>;
40
-
41
- render(
42
- <ManifestProvider manifest={manifest}>
43
- <ComponentUsingModules />
44
- </ManifestProvider>,
45
- );
46
-
47
- expect(warn).toHaveBeenCalledWith(expect.stringMatching(/modules is deprecated/i));
48
- warn.mockRestore();
49
- });
50
- });
@@ -1,136 +0,0 @@
1
- /** @jest-environment jsdom */
2
- import '@testing-library/jest-dom';
3
- import { act, render, screen } from '@testing-library/react';
4
- import fetch, { enableFetchMocks } from 'jest-fetch-mock';
5
- import React from 'react';
6
- import * as AppshellComponent from '../src/components/AppshellComponent';
7
- import ReactHost from '../src/components/ReactHost';
8
-
9
- enableFetchMocks();
10
-
11
- jest.mock('@appshell/core', () => ({
12
- APPSHELL_ENV: {
13
- APPSHELL_REGISTRY: 'appshell_registry',
14
- APPSHELL_PUBLIC_URL: 'http://test.com',
15
- APPSHELL_ROOT: 'TestModule/TestComponent',
16
- APPSHELL_ROOT_PROPS: '{"foo":"bar"}',
17
- },
18
- }));
19
-
20
- jest.mock('../src/components/AppshellComponent', () => ({
21
- __esModule: true,
22
- default: () => <div>test component</div>,
23
- }));
24
-
25
- describe('RenderHost', () => {
26
- const configUrl = 'http://test.com/appshell.config.json';
27
- const remote = 'TestModule/TestComponent';
28
-
29
- let useState: jest.SpyInstance;
30
- const mockUseState = (val) => {
31
- useState.mockImplementationOnce(() => [val, () => {}]);
32
- };
33
-
34
- beforeEach(() => {
35
- useState = jest.spyOn(React, 'useState');
36
- fetch.mockIf(
37
- (req) => req.url === 'http://test.com/appshell.config.json',
38
- () => Promise.resolve({ ok: true, body: JSON.stringify({ test: 'data' }) }),
39
- );
40
- });
41
-
42
- afterEach(() => {
43
- useState.mockReset();
44
- });
45
-
46
- it('should match snapshot', async () => {
47
- mockUseState({ config: 'foo' });
48
- const { container } = await act(() =>
49
- render(<ReactHost configUrl={configUrl} remote={remote} fallback="Loading" />),
50
- );
51
-
52
- expect(container).toMatchSnapshot();
53
- });
54
-
55
- it('should render empty when config is pending', async () => {
56
- mockUseState(undefined);
57
- const { container } = render(
58
- <ReactHost configUrl={configUrl} remote={remote} fallback="Loading" />,
59
- );
60
-
61
- expect(container).toMatchSnapshot();
62
- });
63
-
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" />));
67
-
68
- expect(screen.getByText(/test component/i)).toBeInTheDocument();
69
- });
70
-
71
- it('should pass props to Appshell component when available', async () => {
72
- mockUseState({ config: 'foo' });
73
- const appshellComponentSpy = jest.spyOn(AppshellComponent, 'default');
74
- await act(() =>
75
- render(<ReactHost configUrl={configUrl} remote={remote} foo="bar" fallback="Loading" />),
76
- );
77
-
78
- expect(screen.getByText(/test component/i)).toBeInTheDocument();
79
-
80
- expect(appshellComponentSpy).toHaveBeenCalledWith(
81
- { fallback: 'Loading', foo: 'bar', remote: 'TestModule/TestComponent' },
82
- {},
83
- );
84
- });
85
-
86
- describe('when the registry inlined the composition', () => {
87
- afterEach(() => {
88
- delete window.__appshell_config__;
89
- });
90
-
91
- const inline = (index = { 'TestModule/TestComponent': 'http://test.com/manifest.json' }) => {
92
- window.__appshell_config__ = {
93
- environmentId: 'acme/prod',
94
- revision: 1,
95
- root: remote,
96
- rootProps: {},
97
- index,
98
- remotes: {},
99
- environment: {},
100
- };
101
- };
102
-
103
- it('should render without fetching a config', async () => {
104
- inline();
105
- useState.mockRestore();
106
- fetch.resetMocks();
107
-
108
- await act(() => render(<ReactHost remote={remote} fallback="Loading" />));
109
-
110
- expect(screen.getByText(/test component/i)).toBeInTheDocument();
111
- expect(fetch).not.toHaveBeenCalled();
112
- });
113
-
114
- it('should prefer the inlined config over a configUrl', async () => {
115
- inline();
116
- useState.mockRestore();
117
- fetch.resetMocks();
118
-
119
- await act(() =>
120
- render(<ReactHost configUrl={configUrl} remote={remote} fallback="Loading" />),
121
- );
122
-
123
- expect(fetch).not.toHaveBeenCalled();
124
- });
125
- });
126
-
127
- it('should render with an empty index when neither a config nor a url is available', async () => {
128
- useState.mockRestore();
129
- fetch.resetMocks();
130
-
131
- await act(() => render(<ReactHost remote={remote} fallback="Loading" />));
132
-
133
- expect(screen.getByText(/test component/i)).toBeInTheDocument();
134
- expect(fetch).not.toHaveBeenCalled();
135
- });
136
- });
@@ -1,11 +0,0 @@
1
- // Jest Snapshot v1, https://goo.gl/fbAQLP
2
-
3
- exports[`RenderHost should match snapshot 1`] = `
4
- <div>
5
- <div>
6
- test component
7
- </div>
8
- </div>
9
- `;
10
-
11
- exports[`RenderHost should render empty when config is pending 1`] = `<div />`;
@@ -1,8 +0,0 @@
1
- import { AppshellGlobalConfig } from '@appshell/config';
2
-
3
- export default {
4
- index: {
5
- 'TestModule/TestComponent': 'fixtures/appshell.manifest.json',
6
- },
7
- metadata: {},
8
- } as AppshellGlobalConfig;
@@ -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,4 +0,0 @@
1
- import { AppshellManifest } from './types';
2
- declare const _default: (manifest: AppshellManifest, registryPathOrUrl: string, allowOverrides?: boolean) => Promise<void>;
3
- export default _default;
4
- //# sourceMappingURL=register.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"register.d.ts","sourceRoot":"","sources":["../../../../../config/src/register.ts"],"names":[],"mappings":"AAEA,OAAO,EAAwB,gBAAgB,EAAmB,MAAM,SAAS,CAAC;mCAetE,gBAAgB,qBACP,MAAM;AAF3B,wBA2CE"}
@@ -1,3 +0,0 @@
1
- declare const _default: (urlString: string) => boolean;
2
- export default _default;
3
- //# sourceMappingURL=isValidUrl.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"isValidUrl.d.ts","sourceRoot":"","sources":["../../../../../../config/src/utils/isValidUrl.ts"],"names":[],"mappings":"oCAA2B,MAAM;AAAjC,wBAME"}
@@ -1,10 +0,0 @@
1
- type LoadJsonOptions = {
2
- insecure: boolean;
3
- target: string | RegExp;
4
- apiKey?: string;
5
- apiKeyHeader?: string;
6
- proxyUrl?: string;
7
- };
8
- declare const _default: <T = Record<string, unknown>>(jsonPathOrUrl: string, options?: LoadJsonOptions) => Promise<T[]>;
9
- export default _default;
10
- //# sourceMappingURL=loadJson.d.ts.map
@@ -1 +0,0 @@
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;IACxB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB,CAAC;yBAsDoB,CAAC,2CACN,MAAM,YACZ,eAAe,KAOvB,OAAO,CAAC,CAAC,EAAE,CAAC;AATf,wBAqBE"}
@@ -1,4 +0,0 @@
1
- import { ConfigValidator } from '../types';
2
- declare const _default: <TSchema>(validator: ConfigValidator, ...documents: TSchema[]) => TSchema;
3
- export default _default;
4
- //# sourceMappingURL=merge.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"merge.d.ts","sourceRoot":"","sources":["../../../../../../config/src/utils/merge.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,eAAe,EAAE,MAAM,UAAU,CAAC;yBAU3B,OAAO,aAAa,eAAe,gBAAgB,OAAO,EAAE;AAA5E,wBAiBE"}
@@ -1,4 +0,0 @@
1
- import { ConfigValidator } from '../types';
2
- declare const _default: ConfigValidator;
3
- export default _default;
4
- //# sourceMappingURL=AppshellGlobalConfigValidator.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"AppshellGlobalConfigValidator.d.ts","sourceRoot":"","sources":["../../../../../../config/src/validators/AppshellGlobalConfigValidator.ts"],"names":[],"mappings":"AAGA,OAAO,EAAwB,eAAe,EAAE,MAAM,UAAU,CAAC;wBAO5D,eAAe;AALpB,wBAKqB"}
@@ -1,4 +0,0 @@
1
- import { ConfigValidator } from '../types';
2
- declare const _default: ConfigValidator;
3
- export default _default;
4
- //# sourceMappingURL=AppshellManifestValidator.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"AppshellManifestValidator.d.ts","sourceRoot":"","sources":["../../../../../../config/src/validators/AppshellManifestValidator.ts"],"names":[],"mappings":"AAMA,OAAO,EAAoB,eAAe,EAAgB,MAAM,UAAU,CAAC;wBA0EtE,eAAe;AAtBpB,wBAsBqB"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"AppshellComponent.d.ts","sourceRoot":"","sources":["../../../../../src/components/AppshellComponent.tsx"],"names":[],"mappings":"AACA,OAAO,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AAEjD,OAAc,EAAiB,YAAY,EAAE,SAAS,EAAuB,MAAM,OAAO,CAAC;AAM3F,MAAM,MAAM,aAAa,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;AAEpD,OAAO,CAAC,MAAM,CAAC;IACb,UAAU,MAAM;QACd,kBAAkB,EAAE,aAAa,CAAC;KACnC;CACF;AAED,MAAM,MAAM,sBAAsB,CAAC,MAAM,SAAS,aAAa,GAAG,aAAa,IAAI;IACjF,MAAM,EAAE,MAAM,CAAC;IACf,QAAQ,CAAC,EAAE,SAAS,CAAC;CACtB,GAAG,MAAM,CAAC;AAEX;;;;;;;;;;;;;;GAcG;AACH,QAAA,MAAM,iBAAiB;KAAI,MAAM,SAAS,aAAa,iCAIpD,sBAAsB,CAAC,MAAM,CAAC,GAAG,YAAY,CAAC,MAAM,CAAC;;;;CA2CvD,CAAC;AAMF,eAAe,iBAAiB,CAAC;AAEjC;;;GAGG;AACH,eAAO,MAAM,kBAAkB;KA3DJ,MAAM,SAAS,aAAa,iCAIpD,sBAAsB,CAAC,MAAM,CAAC,GAAG,YAAY,CAAC,MAAM,CAAC;;;;CAuDL,CAAC"}
@@ -1,9 +0,0 @@
1
- import { FC, ReactNode } from 'react';
2
- declare const ReactHost: FC<{
3
- configUrl?: string;
4
- remote: string;
5
- fallback?: ReactNode;
6
- [x: string]: unknown;
7
- }>;
8
- export default ReactHost;
9
- //# sourceMappingURL=ReactHost.d.ts.map
@@ -1 +0,0 @@
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;AAUxD,QAAA,MAAM,SAAS,EAAE,EAAE,CAAC;IAClB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,MAAM,EAAE,MAAM,CAAC;IACf,QAAQ,CAAC,EAAE,SAAS,CAAC;IACrB,CAAC,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC;CACtB,CA8BA,CAAC;AAOF,eAAe,SAAS,CAAC"}
@@ -1,11 +0,0 @@
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>;
8
- export declare const GlobalConfigProvider: FC<GlobalConfigProviderProps>;
9
- export declare const GlobalConfigConsumer: React.Consumer<AppshellGlobalConfig>;
10
- export default GlobalConfigContext;
11
- //# sourceMappingURL=GlobalConfigContext.d.ts.map
@@ -1 +0,0 @@
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,qCAAqD,CAAC;AAEtF,eAAO,MAAM,oBAAoB,EAAE,EAAE,CAAC,yBAAyB,CAE9D,CAAC;AAEF,eAAO,MAAM,oBAAoB,sCAA+B,CAAC;AAEjE,eAAe,mBAAmB,CAAC"}
@@ -1,12 +0,0 @@
1
- import { AppshellManifest } from '@appshell/config';
2
- import type { FC, ReactNode } from 'react';
3
- import React from 'react';
4
- interface ManifestProviderProps {
5
- manifest: AppshellManifest;
6
- children: ReactNode;
7
- }
8
- export declare const ManifestContext: React.Context<AppshellManifest>;
9
- export declare const ManifestProvider: FC<ManifestProviderProps>;
10
- export declare const ManifestConsumer: React.Consumer<AppshellManifest>;
11
- export default ManifestContext;
12
- //# sourceMappingURL=ManifestContext.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"ManifestContext.d.ts","sourceRoot":"","sources":["../../../../../src/contexts/ManifestContext.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAC;AACpD,OAAO,KAAK,EAAE,EAAE,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAC3C,OAAO,KAAiC,MAAM,OAAO,CAAC;AAEtD,UAAU,qBAAqB;IAC7B,QAAQ,EAAE,gBAAgB,CAAC;IAC3B,QAAQ,EAAE,SAAS,CAAC;CACrB;AAED,eAAO,MAAM,eAAe,iCAI1B,CAAC;AAkBH,eAAO,MAAM,gBAAgB,EAAE,EAAE,CAAC,qBAAqB,CAItD,CAAC;AAEF,eAAO,MAAM,gBAAgB,kCAA2B,CAAC;AAEzD,eAAe,eAAe,CAAC"}
@@ -1,11 +0,0 @@
1
- import { Metadata } from '@appshell/config';
2
- import React, { FC, ReactNode } from 'react';
3
- interface MetadataProviderProps {
4
- metata: Metadata;
5
- children: ReactNode;
6
- }
7
- export declare const MetadataContext: React.Context<Metadata>;
8
- export declare const MetadataProvider: FC<MetadataProviderProps>;
9
- export declare const MetadataConsumer: React.Consumer<Metadata>;
10
- export default MetadataContext;
11
- //# sourceMappingURL=MetadataContext.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"MetadataContext.d.ts","sourceRoot":"","sources":["../../../../../src/contexts/MetadataContext.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAC5C,OAAO,KAAK,EAAE,EAAiB,EAAE,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAE5D,UAAU,qBAAqB;IAC7B,MAAM,EAAE,QAAQ,CAAC;IACjB,QAAQ,EAAE,SAAS,CAAC;CACrB;AAED,eAAO,MAAM,eAAe,yBAA8B,CAAC;AAE3D,eAAO,MAAM,gBAAgB,EAAE,EAAE,CAAC,qBAAqB,CAEtD,CAAC;AAEF,eAAO,MAAM,gBAAgB,0BAA2B,CAAC;AAEzD,eAAe,eAAe,CAAC"}
@@ -1,4 +0,0 @@
1
- import { AppshellGlobalConfig } from 'packages/config/src/types';
2
- declare const _default: () => AppshellGlobalConfig;
3
- export default _default;
4
- //# sourceMappingURL=useGlobalConfig.d.ts.map
@@ -1 +0,0 @@
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,4 +0,0 @@
1
- import { AppshellManifest } from '@appshell/config';
2
- declare const _default: () => AppshellManifest;
3
- export default _default;
4
- //# sourceMappingURL=useManifest.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"useManifest.d.ts","sourceRoot":"","sources":["../../../../../src/hooks/useManifest.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAC;8BAMjC,gBAAgB;AAAnC,wBAA2F"}
@@ -1,4 +0,0 @@
1
- import { Metadata } from '@appshell/config';
2
- declare const _default: () => Metadata;
3
- export default _default;
4
- //# sourceMappingURL=useMetadata.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"useMetadata.d.ts","sourceRoot":"","sources":["../../../../../src/hooks/useMetadata.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;8BAKzB,QAAQ;AAA3B,wBAA2E"}
@@ -1,55 +0,0 @@
1
- /* eslint-disable react/jsx-props-no-spreading */
2
- import { AppshellGlobalConfig } from 'packages/config/src/types';
3
- import React, { FC, ReactNode, useEffect } from 'react';
4
- import { GlobalConfigProvider } from '../contexts/GlobalConfigContext';
5
- import AppshellComponent from './AppshellComponent';
6
-
7
- /** The registry inlines the composition, so a shell it served needs no config fetch. */
8
- const inlinedConfig = (): AppshellGlobalConfig | undefined => {
9
- const composition = typeof window === 'undefined' ? undefined : window.__appshell_config__;
10
- return composition && { index: composition.index };
11
- };
12
-
13
- const ReactHost: FC<{
14
- configUrl?: string;
15
- remote: string;
16
- fallback?: ReactNode;
17
- [x: string]: unknown;
18
- }> = ({ configUrl, remote, fallback, ...rest }) => {
19
- const [config, setGlobalConfig] = React.useState<AppshellGlobalConfig | undefined>(inlinedConfig);
20
-
21
- useEffect(() => {
22
- if (config) {
23
- return;
24
- }
25
-
26
- if (!configUrl) {
27
- setGlobalConfig({ index: {} });
28
- return;
29
- }
30
-
31
- const fetchGlobalConfig = async () => {
32
- const res = await fetch(configUrl);
33
- setGlobalConfig(res.ok ? await res.json() : { index: {} });
34
- };
35
-
36
- fetchGlobalConfig();
37
- }, [config, configUrl]);
38
-
39
- if (!config) {
40
- return null;
41
- }
42
-
43
- return (
44
- <GlobalConfigProvider config={config}>
45
- <AppshellComponent remote={remote} fallback={fallback} {...rest} />
46
- </GlobalConfigProvider>
47
- );
48
- };
49
-
50
- ReactHost.defaultProps = {
51
- configUrl: undefined,
52
- fallback: undefined,
53
- };
54
-
55
- export default ReactHost;
@@ -1,17 +0,0 @@
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;
@@ -1,40 +0,0 @@
1
- import { AppshellManifest } from '@appshell/config';
2
- import type { FC, ReactNode } from 'react';
3
- import React, { createContext, useMemo } from 'react';
4
-
5
- interface ManifestProviderProps {
6
- manifest: AppshellManifest;
7
- children: ReactNode;
8
- }
9
-
10
- export const ManifestContext = createContext<AppshellManifest>({
11
- remotes: {},
12
- modules: {},
13
- environment: {},
14
- });
15
-
16
- // `modules` is build-time webpack config that the browser has no use for, and it is
17
- // the bulkiest field to inline. Warn for one release to find any consumer still on it.
18
- const deprecateModules = (manifest: AppshellManifest): AppshellManifest =>
19
- new Proxy(manifest, {
20
- get(target, property, receiver) {
21
- if (property === 'modules') {
22
- // eslint-disable-next-line no-console
23
- console.warn(
24
- 'useManifest().modules is deprecated and will be removed. It is build-time webpack config; use useRemote() for what the browser needs. Please open an issue at github.com/appshell-org/appshell if you rely on it.',
25
- );
26
- }
27
-
28
- return Reflect.get(target, property, receiver);
29
- },
30
- });
31
-
32
- export const ManifestProvider: FC<ManifestProviderProps> = ({ manifest, children }) => {
33
- const value = useMemo(() => deprecateModules(manifest), [manifest]);
34
-
35
- return <ManifestContext.Provider value={value}>{children}</ManifestContext.Provider>;
36
- };
37
-
38
- export const ManifestConsumer = ManifestContext.Consumer;
39
-
40
- export default ManifestContext;
@@ -1,17 +0,0 @@
1
- import { Metadata } from '@appshell/config';
2
- import React, { createContext, FC, ReactNode } from 'react';
3
-
4
- interface MetadataProviderProps {
5
- metata: Metadata;
6
- children: ReactNode;
7
- }
8
-
9
- export const MetadataContext = createContext<Metadata>({});
10
-
11
- export const MetadataProvider: FC<MetadataProviderProps> = ({ metata, children }) => (
12
- <MetadataContext.Provider value={metata}>{children}</MetadataContext.Provider>
13
- );
14
-
15
- export const MetadataConsumer = MetadataContext.Consumer;
16
-
17
- export default MetadataContext;
@@ -1,7 +0,0 @@
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);
@@ -1,7 +0,0 @@
1
- import { AppshellManifest } from '@appshell/config';
2
- import React from 'react';
3
-
4
- // eslint-disable-next-line import/no-named-as-default
5
- import ManifestContext from '../contexts/ManifestContext';
6
-
7
- export default (): AppshellManifest => React.useContext<AppshellManifest>(ManifestContext);
@@ -1,6 +0,0 @@
1
- import { Metadata } from '@appshell/config';
2
- import React from 'react';
3
- // eslint-disable-next-line import/no-named-as-default
4
- import MetadataContext from '../contexts/MetadataContext';
5
-
6
- export default (): Metadata => React.useContext<Metadata>(MetadataContext);