@appshell/loader 0.12.0 → 1.0.0-alpha.8
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 +25 -16
- package/README.md +21 -0
- package/__tests__/remoteLoader.spec.ts +24 -0
- package/__tests__/resolvers.spec.ts +128 -0
- package/dist/main.js +1 -1
- package/dist/types/config/src/context.d.ts +23 -0
- package/dist/types/config/src/context.d.ts.map +1 -0
- package/dist/types/config/src/credentials.d.ts +16 -0
- package/dist/types/config/src/credentials.d.ts.map +1 -0
- package/dist/types/config/src/index.d.ts +7 -1
- package/dist/types/config/src/index.d.ts.map +1 -1
- package/dist/types/config/src/publish.d.ts +29 -0
- package/dist/types/config/src/publish.d.ts.map +1 -0
- package/dist/types/config/src/sync.d.ts.map +1 -1
- package/dist/types/config/src/types.d.ts +24 -0
- package/dist/types/config/src/types.d.ts.map +1 -1
- package/dist/types/loader/src/index.d.ts +2 -0
- package/dist/types/loader/src/index.d.ts.map +1 -1
- package/dist/types/loader/src/remoteLoader.d.ts +13 -3
- package/dist/types/loader/src/remoteLoader.d.ts.map +1 -1
- package/dist/types/loader/src/resolvers.d.ts +20 -0
- package/dist/types/loader/src/resolvers.d.ts.map +1 -0
- package/package.json +2 -2
- package/src/index.ts +2 -0
- package/src/remoteLoader.ts +57 -48
- package/src/resolvers.ts +110 -0
package/CHANGELOG.md
CHANGED
|
@@ -3,26 +3,35 @@
|
|
|
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.
|
|
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
7
|
|
|
8
|
-
|
|
8
|
+
**Note:** Version bump only for package @appshell/loader
|
|
9
9
|
|
|
10
|
-
|
|
11
|
-
- configurable api key header support, minor fixes ([2f0bf02](https://github.com/appshell-org/appshell/commit/2f0bf027b92398f91b8e8cbfbf543d61fe37b7a0))
|
|
12
|
-
- hot module replacement support, example updates ([a67d230](https://github.com/appshell-org/appshell/commit/a67d2303b40f5911373225cc0b4ccf9b67c33d11))
|
|
13
|
-
- registry projection, enable env overwrite, refactor docker workflow, consolidate env names ([33a28fe](https://github.com/appshell-org/appshell/commit/33a28fe76b58e05c5b6b6b33d4b402e52bb29e70))
|
|
14
|
-
- rename @appshell/react-federated-component package to @appshell/react ([0b74498](https://github.com/appshell-org/appshell/commit/0b74498bf17ba73db4d936c8a012af1d3b111a28))
|
|
15
|
-
- replace config intermediate file with template ([9b79e65](https://github.com/appshell-org/appshell/commit/9b79e65b355686a0cca273c89c7164bb031e8437))
|
|
16
|
-
- resolve npm audit vulnerabilities (74 → 4) ([36a2d56](https://github.com/appshell-org/appshell/commit/36a2d56a76dabd55a6886ddb9f020948420fd832))
|
|
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)
|
|
17
11
|
|
|
18
|
-
|
|
12
|
+
**Note:** Version bump only for package @appshell/loader
|
|
19
13
|
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
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
|
|
26
35
|
|
|
27
36
|
# 0.12.0-alpha.0 (2026-04-20)
|
|
28
37
|
|
package/README.md
CHANGED
|
@@ -55,6 +55,27 @@ render(<Component />);
|
|
|
55
55
|
appshell generate global-config --registry appshell_registry_path
|
|
56
56
|
```
|
|
57
57
|
|
|
58
|
+
## How a remote is resolved
|
|
59
|
+
|
|
60
|
+
The loader walks a chain of resolvers and uses the first one that answers:
|
|
61
|
+
|
|
62
|
+
| Resolver | Source | When it answers |
|
|
63
|
+
| ------------------------ | ----------------------------------------------------- | -------------------------------------------------------------------------- |
|
|
64
|
+
| `inlineResolver` | `window.__appshell_config__` | The registry served the page and inlined the composition. No network call. |
|
|
65
|
+
| `registryResolver` | `GET /v1/environments/:id/remotes/:key` | The remote was activated after this page was served. |
|
|
66
|
+
| `legacyManifestResolver` | `index[key]` → the app's own `appshell.manifest.json` | Pre-registry hosts. |
|
|
67
|
+
|
|
68
|
+
Environment variables reach `window.__appshell_env__<scope>` already merged with the
|
|
69
|
+
environment's overrides when a composition is present, because the registry does that
|
|
70
|
+
merge server side. The legacy resolver still merges in the browser, since in that mode
|
|
71
|
+
no server has.
|
|
72
|
+
|
|
73
|
+
You can bypass the chain entirely, which is mainly useful for tests and embedders:
|
|
74
|
+
|
|
75
|
+
```ts
|
|
76
|
+
const load = componentLoader(config, { resolver: myResolver });
|
|
77
|
+
```
|
|
78
|
+
|
|
58
79
|
**Do you have any framework specific loaders?**
|
|
59
80
|
|
|
60
81
|
> See [@appshell/react](https://www.npmjs.com/package/@appshell/react) for a `React` loader.
|
|
@@ -117,4 +117,28 @@ describe('remoteLoader', () => {
|
|
|
117
117
|
/Failed to load component/i,
|
|
118
118
|
);
|
|
119
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
|
+
});
|
|
120
144
|
});
|
|
@@ -0,0 +1,128 @@
|
|
|
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
|
+
});
|
package/dist/main.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
!function(e,t){if("object"==typeof exports&&"object"==typeof module)module.exports=t();else if("function"==typeof define&&define.amd)define([],t);else{var
|
|
1
|
+
!function(e,t){if("object"==typeof exports&&"object"==typeof module)module.exports=t();else if("function"==typeof define&&define.amd)define([],t);else{var n=t();for(var o in n)("object"==typeof exports?exports:e)[o]=n[o]}}(self,(()=>(()=>{"use strict";var e={d:(t,n)=>{for(var o in n)e.o(n,o)&&!e.o(t,o)&&Object.defineProperty(t,o,{enumerable:!0,get:n[o]})},o:(e,t)=>Object.prototype.hasOwnProperty.call(e,t),r:e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})}};(()=>{e.S={};var t={},n={};e.I=(o,r)=>{r||(r=[]);var a=n[o];if(a||(a=n[o]={}),!(r.indexOf(a)>=0)){if(r.push(a),t[o])return t[o];e.o(e.S,o)||(e.S[o]={}),e.S[o];var i=[];return t[o]=i.length?Promise.all(i).then((()=>t[o]=1)):1}}})();var t={};e.r(t),e.d(t,{chainResolvers:()=>l,default:()=>m,inlineResolver:()=>i,legacyManifestResolver:()=>s,registryResolver:()=>c});const n=new Set,o=async e=>{const t=document.createElement("script");return new Promise(((o,r)=>{n.has(e)?o(!1):(n.add(e),t.src=e,t.type="text/javascript",t.async=!0,t.onload=()=>{console.debug(`Remote entry fetched from '${e}'.`),o(!0)},t.onerror=()=>{const t=`Failed to fetch remote entry from '${e}'.`;console.error(t),n.delete(e),r(t)},document.head.appendChild(t))})).finally((()=>{document.head.contains(t)&&document.head.removeChild(t)}))};(Object.getOwnPropertyDescriptor(o,"name")||{}).writable||Object.defineProperty(o,"name",{value:"default",configurable:!0});const r=async(t,n,o="default")=>{console.debug(`loading Appshell component: { scope: ${t}, module: ${n}, shareScope: ${o} }`),await e.I(o);const r=window[t];if(!r)throw new Error(`Failed to find module container ${t}`);await r.init(e.S[o]);const a=await r.get(n);if(!a)throw new Error(`Invalid factory produced by container for module ${n}.`);const i=a();return console.debug(`Appshell component loaded: { scope: ${t}, module: ${n}, shareScope: ${o} }`),i.default};(Object.getOwnPropertyDescriptor(r,"name")||{}).writable||Object.defineProperty(r,"name",{value:"default",configurable:!0});const a=(e,t)=>({remotes:t,environment:e.environment,modules:{}}),i=e=>async t=>{const n=e?.remotes[t];if(e&&n)return{remote:n,environment:e.environment[n.scope]??{},manifest:a(e,e.remotes)}},c=(e,t="")=>async n=>{if(!e)return;const o=`${t}/v1/environments/${e.environmentId}/remotes/${n}`,r=await fetch(o,{credentials:"include"});if(!r.ok)return;const i=await r.json();return{remote:i,environment:e.environment[i.scope]??{},manifest:a(e,{[n]:i})}},s=e=>{const t=new Map;return async n=>{const o=e.index?.[n];if(!o)return;const r=await(e=>{const n=t.get(e);if(n)return n;const o=fetch(e,{credentials:"include"}).then((async t=>{if(!t.ok)throw new Error(`Failed to get manifest from ${e}. ${await t.text()}`);return t.json()}));return t.set(e,o),o})(o),a=r?.remotes[n];return a?{remote:a,environment:{...r.environment[a.scope]??{},...e.overrides?.environment?.[a.scope]??{}},manifest:r}:void 0}},l=(...e)=>async t=>{for(const n of e){const e=await n(t);if(e)return e}},d=new Set,f=(e,t={})=>{const n=t.composition??("undefined"==typeof window?void 0:window.__appshell_config__),a=t.resolver??l(i(n),c(n),s(e));return async e=>{const t=t=>new Error(`Failed to load component '${e}'. ${t?.toString()}`);let n;try{n=await a(e)}catch(e){throw t(e)}if(!n)throw new Error(`Remote resource not found in registry. Expected: ${e}`);const{remote:i,environment:c,manifest:s}=n;try{return window[`__appshell_env__${i.scope}`]=c,d.has(i.remoteEntryUrl)||await o(i.remoteEntryUrl)?(d.add(i.remoteEntryUrl),[await r(i.scope,i.module,i.shareScope),s]):[null,null]}catch(e){throw t(e)}}};(Object.getOwnPropertyDescriptor(f,"name")||{}).writable||Object.defineProperty(f,"name",{value:"default",configurable:!0});const m=f;return t})()));
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
export type AppshellContext = {
|
|
2
|
+
registry?: string;
|
|
3
|
+
/** Activation target as `scope/name`. */
|
|
4
|
+
environment?: string;
|
|
5
|
+
scopeId: string;
|
|
6
|
+
token?: string;
|
|
7
|
+
};
|
|
8
|
+
/**
|
|
9
|
+
* The registry, environment, and token a developer is working against, resolved
|
|
10
|
+
* the way the CLI resolves them: env var, then `~/.appshell/config`, then a
|
|
11
|
+
* default. This lets the webpack plugin defer to `appshell config set` and
|
|
12
|
+
* `appshell login` instead of requiring per-project configuration.
|
|
13
|
+
*/
|
|
14
|
+
export declare const resolveContext: () => AppshellContext;
|
|
15
|
+
/**
|
|
16
|
+
* What `~/.appshell/config` alone declares, so a caller can warn when an env var
|
|
17
|
+
* or an explicit option points somewhere other than the developer's CLI context.
|
|
18
|
+
*/
|
|
19
|
+
export declare const persistedContext: () => {
|
|
20
|
+
registry?: string;
|
|
21
|
+
environment?: string;
|
|
22
|
+
};
|
|
23
|
+
//# sourceMappingURL=context.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
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"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
export type Credential = {
|
|
2
|
+
accessToken: string;
|
|
3
|
+
refreshToken?: string;
|
|
4
|
+
/** Epoch milliseconds. */
|
|
5
|
+
expiresAt?: number;
|
|
6
|
+
};
|
|
7
|
+
export declare const credentialsPath: () => string;
|
|
8
|
+
export declare const saveCredential: (registry: string, credential: Credential) => void;
|
|
9
|
+
export declare const clearCredential: (registry: string) => void;
|
|
10
|
+
/**
|
|
11
|
+
* APPSHELL_TOKEN wins so CI never depends on a writable home directory.
|
|
12
|
+
* Expired tokens are treated as absent; refresh is the caller's concern.
|
|
13
|
+
*/
|
|
14
|
+
export declare const resolveToken: (registry: string) => string | undefined;
|
|
15
|
+
export declare const requireToken: (registry: string) => string;
|
|
16
|
+
//# sourceMappingURL=credentials.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
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"}
|
|
@@ -2,14 +2,20 @@
|
|
|
2
2
|
* @appshell/config package API
|
|
3
3
|
*/
|
|
4
4
|
export { default as configmap } from './configmap';
|
|
5
|
+
export { persistedContext, resolveContext } from './context';
|
|
6
|
+
export type { AppshellContext } from './context';
|
|
7
|
+
export { clearCredential, credentialsPath, requireToken, resolveToken, saveCredential, } from './credentials';
|
|
8
|
+
export type { Credential } from './credentials';
|
|
5
9
|
export { default as deregister } from './deregister';
|
|
6
10
|
export { default as generateEnv } from './generate.env';
|
|
7
11
|
export { default as generateGlobalConfig } from './generate.global-config';
|
|
8
12
|
export { default as generateManifest } from './generate.manifest';
|
|
9
13
|
export { default as outdated } from './outdated';
|
|
14
|
+
export { activate, publish } from './publish';
|
|
15
|
+
export type { PublishOptions, PublishResult } from './publish';
|
|
10
16
|
export { default as register } from './register';
|
|
11
17
|
export { default as sync } from './sync';
|
|
12
|
-
export type { AppshellConfig, AppshellConfigRemote, AppshellGlobalConfig, AppshellIndex, AppshellManifest, AppshellRemote, AppshellTemplate, ComparisonResult, ComparisonResults, ComparisonTarget, Metadata, ModuleFederationPluginOptions, PackageSpec, Schema, SharedModuleSpec, } from './types';
|
|
18
|
+
export type { AppshellComposition, AppshellConfig, AppshellConfigRemote, AppshellGlobalConfig, AppshellIndex, AppshellManifest, AppshellRemote, AppshellTemplate, ComparisonResult, ComparisonResults, ComparisonTarget, Metadata, ModuleFederationPluginOptions, PackageSpec, ResolvedRemote, Schema, SharedModuleSpec, } from './types';
|
|
13
19
|
export * as utils from './utils';
|
|
14
20
|
export * as validators from './validators';
|
|
15
21
|
//# 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,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,OAAO,EAAE,OAAO,IAAI,QAAQ,EAAE,MAAM,YAAY,CAAC;AACjD,OAAO,EAAE,OAAO,IAAI,IAAI,EAAE,MAAM,QAAQ,CAAC;AACzC,YAAY,EACV,cAAc,EACd,oBAAoB,EACpB,oBAAoB,EACpB,aAAa,EACb,gBAAgB,EAChB,cAAc,EACd,gBAAgB,EAChB,gBAAgB,EAChB,iBAAiB,EACjB,gBAAgB,EAChB,QAAQ,EACR,6BAA6B,EAC7B,WAAW,EACX,MAAM,EACN,gBAAgB,GACjB,MAAM,SAAS,CAAC;AACjB,OAAO,KAAK,KAAK,MAAM,SAAS,CAAC;AACjC,OAAO,KAAK,UAAU,MAAM,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AAC;AACjB,OAAO,KAAK,KAAK,MAAM,SAAS,CAAC;AACjC,OAAO,KAAK,UAAU,MAAM,cAAc,CAAC"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { AppshellManifest, Metadata } from './types';
|
|
2
|
+
export type PublishOptions = {
|
|
3
|
+
registry: string;
|
|
4
|
+
token?: string;
|
|
5
|
+
name: string;
|
|
6
|
+
version: string;
|
|
7
|
+
manifest: AppshellManifest;
|
|
8
|
+
visibility?: 'public' | 'private';
|
|
9
|
+
metadata?: Metadata;
|
|
10
|
+
/** Ask the registry to overwrite an existing version whose content differs. */
|
|
11
|
+
force?: boolean;
|
|
12
|
+
};
|
|
13
|
+
export type PublishResult = {
|
|
14
|
+
/** `scope/name@version`. The scope comes from the token, not the caller. */
|
|
15
|
+
id: string;
|
|
16
|
+
created: boolean;
|
|
17
|
+
};
|
|
18
|
+
/**
|
|
19
|
+
* Publishing the same content twice is a no-op; publishing different content
|
|
20
|
+
* under a version that already exists is rejected by the registry, unless
|
|
21
|
+
* `force` is set and the registry is configured to honor it (dev registries).
|
|
22
|
+
*/
|
|
23
|
+
export declare const publish: ({ registry, token, name, version, manifest, visibility, metadata, force, }: PublishOptions) => Promise<PublishResult>;
|
|
24
|
+
/**
|
|
25
|
+
* Activating a newer version of an already active app upgrades it in place.
|
|
26
|
+
* @param environment `scope/name`
|
|
27
|
+
*/
|
|
28
|
+
export declare const activate: (registry: string, environment: string, appId: string, token?: string) => Promise<void>;
|
|
29
|
+
//# sourceMappingURL=publish.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"publish.d.ts","sourceRoot":"","sources":["../../../../../config/src/publish.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,gBAAgB,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AAErD,MAAM,MAAM,cAAc,GAAG;IAC3B,QAAQ,EAAE,MAAM,CAAC;IACjB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,CAAC;IAChB,QAAQ,EAAE,gBAAgB,CAAC;IAC3B,UAAU,CAAC,EAAE,QAAQ,GAAG,SAAS,CAAC;IAClC,QAAQ,CAAC,EAAE,QAAQ,CAAC;IACpB,+EAA+E;IAC/E,KAAK,CAAC,EAAE,OAAO,CAAC;CACjB,CAAC;AAEF,MAAM,MAAM,aAAa,GAAG;IAC1B,4EAA4E;IAC5E,EAAE,EAAE,MAAM,CAAC;IACX,OAAO,EAAE,OAAO,CAAC;CAClB,CAAC;AAmBF;;;;GAIG;AACH,eAAO,MAAM,OAAO,+EASjB,cAAc,KAAG,OAAO,CAAC,aAAa,CAYxC,CAAC;AAEF;;;GAGG;AACH,eAAO,MAAM,QAAQ,aACT,MAAM,eACH,MAAM,SACZ,MAAM,UACL,MAAM,KACb,OAAO,CAAC,IAAI,CAgBd,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sync.d.ts","sourceRoot":"","sources":["../../../../../config/src/sync.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,gBAAgB,EAAE,MAAM,SAAS,CAAC;AAE3C,MAAM,MAAM,kBAAkB,GAAG,SAAS,GAAG,QAAQ,CAAC;AACtD,MAAM,MAAM,cAAc,GAAG,KAAK,GAAG,MAAM,CAAC;AAE5C,eAAO,MAAM,mBAAmB,cAAe,gBAAgB,EAAE,SAuBhE,CAAC;AAEF,eAAO,MAAM,gBAAgB,eACf,MAAM,YACR,MAAM,YACN,MAAM,EAAE,kBACF,KAAK,GAAG,MAAM,
|
|
1
|
+
{"version":3,"file":"sync.d.ts","sourceRoot":"","sources":["../../../../../config/src/sync.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,gBAAgB,EAAE,MAAM,SAAS,CAAC;AAE3C,MAAM,MAAM,kBAAkB,GAAG,SAAS,GAAG,QAAQ,CAAC;AACtD,MAAM,MAAM,cAAc,GAAG,KAAK,GAAG,MAAM,CAAC;AAE5C,eAAO,MAAM,mBAAmB,cAAe,gBAAgB,EAAE,SAuBhE,CAAC;AAEF,eAAO,MAAM,gBAAgB,eACf,MAAM,YACR,MAAM,YACN,MAAM,EAAE,kBACF,KAAK,GAAG,MAAM,kBAkC/B,CAAC;AAEF,eAAO,MAAM,gBAAgB,cAChB,gBAAgB,EAAE,EAAE,sBACX,kBAAkB,aAmBvC,CAAC;AAEF,eAAO,MAAM,kBAAkB,cAAe,MAAM,CAAC,MAAM,EAAE,gBAAgB,CAAC,yBACQ,CAAC;AAEvF,eAAO,MAAM,mBAAmB,cAAe,MAAM,CAAC,MAAM,EAAE,gBAAgB,CAAC,yBACQ,CAAC;AAExF,eAAO,MAAM,qBAAqB,cAAe,MAAM,CAAC,MAAM,EAAE,gBAAgB,CAAC,yBACQ,CAAC;AAE1F;;;;;;;;GAQG;qCAEW,MAAM,YACR,MAAM,aACL,MAAM,CAAC,MAAM,EAAE,gBAAgB,CAAC,uBACvB,kBAAkB,mBACtB,cAAc;AALhC,wBA6BE"}
|
|
@@ -46,6 +46,10 @@ export type ComparisonTarget = {
|
|
|
46
46
|
export type CliConfig = Record<string, string> & {
|
|
47
47
|
apiKey: string;
|
|
48
48
|
registry: string;
|
|
49
|
+
environment: string;
|
|
50
|
+
scopeId: string;
|
|
51
|
+
authIssuer: string;
|
|
52
|
+
clientId: string;
|
|
49
53
|
};
|
|
50
54
|
export type AppshellConfigRemote<TMetadata = Metadata> = {
|
|
51
55
|
id: string;
|
|
@@ -92,6 +96,26 @@ export type AppshellGlobalConfig<TMetadata = Metadata> = {
|
|
|
92
96
|
metadata?: Record<string, TMetadata>;
|
|
93
97
|
overrides?: AppshellOverrides;
|
|
94
98
|
};
|
|
99
|
+
/** An `AppshellRemote` the registry already resolved, so the browser needs no manifest fetch. */
|
|
100
|
+
export type ResolvedRemote<TMetadata = Metadata> = AppshellRemote<TMetadata>;
|
|
101
|
+
/**
|
|
102
|
+
* The wire contract for `window.__appshell_config__`. Deliberately not an
|
|
103
|
+
* `AppshellManifest`: that is a build artifact, and reusing it left it unclear
|
|
104
|
+
* which fields the browser actually needs. `modules` is build-time webpack
|
|
105
|
+
* config and never crosses the wire; `environment` arrives already merged with
|
|
106
|
+
* the environment's overrides, leaving the browser only local overrides to apply.
|
|
107
|
+
*/
|
|
108
|
+
export type AppshellComposition<TMetadata = Metadata> = {
|
|
109
|
+
/** `scope/name` — makes the payload self-describing for fetch-on-miss and for `env diff`. */
|
|
110
|
+
environmentId: string;
|
|
111
|
+
revision: number;
|
|
112
|
+
/** The remote key the host mounts at the root, and the props it is given. */
|
|
113
|
+
root: string;
|
|
114
|
+
rootProps: Record<string, unknown>;
|
|
115
|
+
index: AppshellIndex;
|
|
116
|
+
remotes: Record<string, ResolvedRemote<TMetadata>>;
|
|
117
|
+
environment: Record<string, Record<string, string | number | undefined>>;
|
|
118
|
+
};
|
|
95
119
|
/**
|
|
96
120
|
* Advanced configuration for modules that should be exposed by this container.
|
|
97
121
|
*/
|
|
@@ -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;AAE/C,MAAM,MAAM,WAAW,GAAG;IACxB,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,CAAC;IAChB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,CAAC,EAAE;QAAE,CAA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AU,CAAC,EAAE,MAAM,CAAC;CACrB;AAED;;GAEG;AACH,MAAM,WAAW,aAAa;IAC5B,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,GAAG,aAAa,GAAG,MAAM,EAAE,CAAC;CACpD;AAED,MAAM,WAAW,6BAA6B;IAC5C;;OAEG;IACH,OAAO,CAAC,EAAE,CAAC,MAAM,GAAG,aAAa,CAAC,EAAE,GAAG,aAAa,CAAC;IAErD;;OAEG;IACH,QAAQ,CAAC,EAAE,MAAM,CAAC;IAElB;;OAEG;IACH,OAAO,CAAC,EAAE,cAAc,CAAC;IAEzB;;OAEG;IACH,IAAI,CAAC,EAAE,MAAM,CAAC;IAEd;;OAEG;IACH,UAAU,CAAC,EACP,QAAQ,GACR,KAAK,GACL,QAAQ,GACR,QAAQ,GACR,MAAM,GACN,QAAQ,GACR,MAAM,GACN,QAAQ,GACR,UAAU,GACV,WAAW,GACX,iBAAiB,GACjB,iBAAiB,GACjB,KAAK,GACL,aAAa,GACb,KAAK,GACL,MAAM,GACN,OAAO,GACP,QAAQ,GACR,SAAS,GACT,QAAQ,GACR,eAAe,CAAC;IAEpB;;OAEG;IACH,OAAO,CAAC,EAAE,CAAC,MAAM,GAAG,aAAa,CAAC,EAAE,GAAG,aAAa,CAAC;IAErD;;OAEG;IACH,OAAO,CAAC,EAAE,MAAM,GAAG,KAAK,CAAC;IAEzB;;OAEG;IACH,UAAU,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":"index.d.ts","sourceRoot":"","sources":["../../../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,YAAY,MAAM,gBAAgB,CAAC;AAE1C,cAAc,SAAS,CAAC;AAExB,eAAe,YAAY,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,YAAY,MAAM,gBAAgB,CAAC;AAE1C,YAAY,EAAE,mBAAmB,EAAE,MAAM,gBAAgB,CAAC;AAC1D,cAAc,aAAa,CAAC;AAC5B,cAAc,SAAS,CAAC;AAExB,eAAe,YAAY,CAAC"}
|
|
@@ -1,5 +1,15 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
declare
|
|
1
|
+
import type { AppshellComposition, AppshellGlobalConfig } from '@appshell/config';
|
|
2
|
+
import { type RemoteResolver } from './resolvers';
|
|
3
|
+
declare global {
|
|
4
|
+
interface Window {
|
|
5
|
+
__appshell_config__?: AppshellComposition;
|
|
6
|
+
}
|
|
7
|
+
}
|
|
8
|
+
export type RemoteLoaderOptions = {
|
|
9
|
+
composition?: AppshellComposition;
|
|
10
|
+
/** Replaces the resolver chain outright; a seam for tests and embedders. */
|
|
11
|
+
resolver?: RemoteResolver;
|
|
12
|
+
};
|
|
13
|
+
declare const _default: (config: AppshellGlobalConfig, options?: RemoteLoaderOptions) => <TComponent>(key: string) => Promise<readonly [null, null] | readonly [Awaited<TComponent>, import("@appshell/config").AppshellManifest]>;
|
|
4
14
|
export default _default;
|
|
5
15
|
//# sourceMappingURL=remoteLoader.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"remoteLoader.d.ts","sourceRoot":"","sources":["../../../../src/remoteLoader.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"remoteLoader.d.ts","sourceRoot":"","sources":["../../../../src/remoteLoader.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,mBAAmB,EAAE,oBAAoB,EAAE,MAAM,kBAAkB,CAAC;AAGlF,OAAO,EAKL,KAAK,cAAc,EACpB,MAAM,aAAa,CAAC;AAIrB,OAAO,CAAC,MAAM,CAAC;IACb,UAAU,MAAM;QACd,mBAAmB,CAAC,EAAE,mBAAmB,CAAC;KAC3C;CACF;AAED,MAAM,MAAM,mBAAmB,GAAG;IAChC,WAAW,CAAC,EAAE,mBAAmB,CAAC;IAClC,4EAA4E;IAC5E,QAAQ,CAAC,EAAE,cAAc,CAAC;CAC3B,CAAC;iCAEsB,oBAAoB,YAAW,mBAAmB,MAY1D,UAAU,OAAO,MAAM;AAZvC,wBAqDE"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import type { AppshellComposition, AppshellGlobalConfig, AppshellManifest, ResolvedRemote } from '@appshell/config';
|
|
2
|
+
export type RemoteResolution = {
|
|
3
|
+
remote: ResolvedRemote;
|
|
4
|
+
/** Already merged with the environment's overrides — nothing left for the browser to layer on. */
|
|
5
|
+
environment: Record<string, string | number | undefined>;
|
|
6
|
+
/** Back-compat payload for `ManifestProvider`; synthesized when the source was a composition. */
|
|
7
|
+
manifest: AppshellManifest;
|
|
8
|
+
};
|
|
9
|
+
export type RemoteResolver = (key: string) => Promise<RemoteResolution | undefined>;
|
|
10
|
+
/** The registry inlined the composition into the page, so no network call is needed. */
|
|
11
|
+
export declare const inlineResolver: (composition?: AppshellComposition) => RemoteResolver;
|
|
12
|
+
/** Fetch-on-miss: covers an app activated after this page was served. */
|
|
13
|
+
export declare const registryResolver: (composition?: AppshellComposition, origin?: string) => RemoteResolver;
|
|
14
|
+
/**
|
|
15
|
+
* Pre-registry hosts: follow `index[key]` to the app's own manifest. The override
|
|
16
|
+
* merge stays here because in this mode no server has done it.
|
|
17
|
+
*/
|
|
18
|
+
export declare const legacyManifestResolver: (config: AppshellGlobalConfig) => RemoteResolver;
|
|
19
|
+
export declare const chainResolvers: (...resolvers: RemoteResolver[]) => RemoteResolver;
|
|
20
|
+
//# sourceMappingURL=resolvers.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"resolvers.d.ts","sourceRoot":"","sources":["../../../../src/resolvers.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,mBAAmB,EACnB,oBAAoB,EACpB,gBAAgB,EAChB,cAAc,EACf,MAAM,kBAAkB,CAAC;AAE1B,MAAM,MAAM,gBAAgB,GAAG;IAC7B,MAAM,EAAE,cAAc,CAAC;IACvB,kGAAkG;IAClG,WAAW,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAAC,CAAC;IACzD,iGAAiG;IACjG,QAAQ,EAAE,gBAAgB,CAAC;CAC5B,CAAC;AAEF,MAAM,MAAM,cAAc,GAAG,CAAC,GAAG,EAAE,MAAM,KAAK,OAAO,CAAC,gBAAgB,GAAG,SAAS,CAAC,CAAC;AAQpF,wFAAwF;AACxF,eAAO,MAAM,cAAc,iBACV,mBAAmB,KAAG,cAUpC,CAAC;AAEJ,yEAAyE;AACzE,eAAO,MAAM,gBAAgB,iBACZ,mBAAmB,sBAAgB,cAejD,CAAC;AAEJ;;;GAGG;AACH,eAAO,MAAM,sBAAsB,WAAY,oBAAoB,KAAG,cAoCrE,CAAC;AAEF,eAAO,MAAM,cAAc,iBACV,cAAc,EAAE,KAAG,cAUjC,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@appshell/loader",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "1.0.0-alpha.8",
|
|
4
4
|
"description": "Utility for loading Appshell components",
|
|
5
5
|
"main": "dist/main.js",
|
|
6
6
|
"types": "dist/loader/src/index.d.ts",
|
|
@@ -24,5 +24,5 @@
|
|
|
24
24
|
"appshell"
|
|
25
25
|
],
|
|
26
26
|
"license": "MIT",
|
|
27
|
-
"gitHead": "
|
|
27
|
+
"gitHead": "ced8839a7c8423ad723fb32f9388e0e3d15951eb"
|
|
28
28
|
}
|
package/src/index.ts
CHANGED
package/src/remoteLoader.ts
CHANGED
|
@@ -1,71 +1,80 @@
|
|
|
1
1
|
/* eslint-disable no-underscore-dangle */
|
|
2
|
-
import {
|
|
3
|
-
import { AppshellGlobalConfig } from 'packages/config/src/types';
|
|
2
|
+
import type { AppshellComposition, AppshellGlobalConfig } from '@appshell/config';
|
|
4
3
|
import fetchDynamicScript from './fetchDynamicScript';
|
|
5
4
|
import loadAppshellComponent from './loadAppshellComponent';
|
|
5
|
+
import {
|
|
6
|
+
chainResolvers,
|
|
7
|
+
inlineResolver,
|
|
8
|
+
legacyManifestResolver,
|
|
9
|
+
registryResolver,
|
|
10
|
+
type RemoteResolver,
|
|
11
|
+
} from './resolvers';
|
|
6
12
|
|
|
7
13
|
const fetchedScriptCache = new Set<string>();
|
|
8
|
-
const fetchedManifestCache = new Map<string, AppshellManifest | undefined>();
|
|
9
14
|
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
15
|
+
declare global {
|
|
16
|
+
interface Window {
|
|
17
|
+
__appshell_config__?: AppshellComposition;
|
|
13
18
|
}
|
|
19
|
+
}
|
|
14
20
|
|
|
15
|
-
|
|
21
|
+
export type RemoteLoaderOptions = {
|
|
22
|
+
composition?: AppshellComposition;
|
|
23
|
+
/** Replaces the resolver chain outright; a seam for tests and embedders. */
|
|
24
|
+
resolver?: RemoteResolver;
|
|
25
|
+
};
|
|
16
26
|
|
|
17
|
-
|
|
27
|
+
export default (config: AppshellGlobalConfig, options: RemoteLoaderOptions = {}) => {
|
|
28
|
+
const composition =
|
|
29
|
+
options.composition ?? (typeof window === 'undefined' ? undefined : window.__appshell_config__);
|
|
18
30
|
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
31
|
+
const resolve =
|
|
32
|
+
options.resolver ??
|
|
33
|
+
chainResolvers(
|
|
34
|
+
inlineResolver(composition),
|
|
35
|
+
registryResolver(composition),
|
|
36
|
+
legacyManifestResolver(config),
|
|
37
|
+
);
|
|
22
38
|
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
};
|
|
39
|
+
return async <TComponent>(key: string) => {
|
|
40
|
+
const failed = (err: unknown) =>
|
|
41
|
+
new Error(`Failed to load component '${key}'. ${err?.toString()}`);
|
|
42
|
+
|
|
43
|
+
let resolution;
|
|
44
|
+
try {
|
|
45
|
+
resolution = await resolve(key);
|
|
46
|
+
} catch (err) {
|
|
47
|
+
throw failed(err);
|
|
48
|
+
}
|
|
26
49
|
|
|
27
|
-
|
|
28
|
-
async <TComponent>(key: string) => {
|
|
29
|
-
let Component: TComponent;
|
|
30
|
-
const manifestUrl = config.index[key];
|
|
31
|
-
if (!manifestUrl) {
|
|
50
|
+
if (!resolution) {
|
|
32
51
|
throw new Error(`Remote resource not found in registry. Expected: ${key}`);
|
|
33
52
|
}
|
|
34
53
|
|
|
54
|
+
const { remote, environment, manifest } = resolution;
|
|
55
|
+
|
|
35
56
|
try {
|
|
36
|
-
|
|
57
|
+
window[`__appshell_env__${remote.scope}`] = environment;
|
|
37
58
|
|
|
38
|
-
|
|
39
|
-
|
|
59
|
+
const loaded =
|
|
60
|
+
fetchedScriptCache.has(remote.remoteEntryUrl) ||
|
|
61
|
+
(await fetchDynamicScript(remote.remoteEntryUrl));
|
|
40
62
|
|
|
41
|
-
|
|
63
|
+
if (!loaded) {
|
|
64
|
+
return [null, null] as const;
|
|
65
|
+
}
|
|
42
66
|
|
|
43
|
-
|
|
44
|
-
const overrides =
|
|
45
|
-
(config.overrides?.environment && config.overrides?.environment[remote.scope]) || {};
|
|
46
|
-
window[`__appshell_env__${remote.scope}`] = {
|
|
47
|
-
...environment,
|
|
48
|
-
...overrides,
|
|
49
|
-
};
|
|
67
|
+
fetchedScriptCache.add(remote.remoteEntryUrl);
|
|
50
68
|
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
Component = await loadAppshellComponent<TComponent>(
|
|
57
|
-
remote.scope,
|
|
58
|
-
remote.module,
|
|
59
|
-
remote.shareScope,
|
|
60
|
-
);
|
|
69
|
+
const Component = await loadAppshellComponent<TComponent>(
|
|
70
|
+
remote.scope,
|
|
71
|
+
remote.module,
|
|
72
|
+
remote.shareScope,
|
|
73
|
+
);
|
|
61
74
|
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
return [null, null] as const;
|
|
67
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
68
|
-
} catch (err: any) {
|
|
69
|
-
throw new Error(`Failed to load component '${key}'. ${err?.toString()}`);
|
|
75
|
+
return [Component, manifest] as const;
|
|
76
|
+
} catch (err) {
|
|
77
|
+
throw failed(err);
|
|
70
78
|
}
|
|
71
79
|
};
|
|
80
|
+
};
|
package/src/resolvers.ts
ADDED
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
import type {
|
|
2
|
+
AppshellComposition,
|
|
3
|
+
AppshellGlobalConfig,
|
|
4
|
+
AppshellManifest,
|
|
5
|
+
ResolvedRemote,
|
|
6
|
+
} from '@appshell/config';
|
|
7
|
+
|
|
8
|
+
export type RemoteResolution = {
|
|
9
|
+
remote: ResolvedRemote;
|
|
10
|
+
/** Already merged with the environment's overrides — nothing left for the browser to layer on. */
|
|
11
|
+
environment: Record<string, string | number | undefined>;
|
|
12
|
+
/** Back-compat payload for `ManifestProvider`; synthesized when the source was a composition. */
|
|
13
|
+
manifest: AppshellManifest;
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
export type RemoteResolver = (key: string) => Promise<RemoteResolution | undefined>;
|
|
17
|
+
|
|
18
|
+
const manifestOf = (composition: AppshellComposition, remotes: AppshellManifest['remotes']) => ({
|
|
19
|
+
remotes,
|
|
20
|
+
environment: composition.environment,
|
|
21
|
+
modules: {},
|
|
22
|
+
});
|
|
23
|
+
|
|
24
|
+
/** The registry inlined the composition into the page, so no network call is needed. */
|
|
25
|
+
export const inlineResolver =
|
|
26
|
+
(composition?: AppshellComposition): RemoteResolver =>
|
|
27
|
+
async (key) => {
|
|
28
|
+
const remote = composition?.remotes[key];
|
|
29
|
+
if (!composition || !remote) return undefined;
|
|
30
|
+
|
|
31
|
+
return {
|
|
32
|
+
remote,
|
|
33
|
+
environment: composition.environment[remote.scope] ?? {},
|
|
34
|
+
manifest: manifestOf(composition, composition.remotes),
|
|
35
|
+
};
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
/** Fetch-on-miss: covers an app activated after this page was served. */
|
|
39
|
+
export const registryResolver =
|
|
40
|
+
(composition?: AppshellComposition, origin = ''): RemoteResolver =>
|
|
41
|
+
async (key) => {
|
|
42
|
+
if (!composition) return undefined;
|
|
43
|
+
|
|
44
|
+
const url = `${origin}/v1/environments/${composition.environmentId}/remotes/${key}`;
|
|
45
|
+
const response = await fetch(url, { credentials: 'include' });
|
|
46
|
+
if (!response.ok) return undefined;
|
|
47
|
+
|
|
48
|
+
const remote: ResolvedRemote = await response.json();
|
|
49
|
+
|
|
50
|
+
return {
|
|
51
|
+
remote,
|
|
52
|
+
environment: composition.environment[remote.scope] ?? {},
|
|
53
|
+
manifest: manifestOf(composition, { [key]: remote }),
|
|
54
|
+
};
|
|
55
|
+
};
|
|
56
|
+
|
|
57
|
+
/**
|
|
58
|
+
* Pre-registry hosts: follow `index[key]` to the app's own manifest. The override
|
|
59
|
+
* merge stays here because in this mode no server has done it.
|
|
60
|
+
*/
|
|
61
|
+
export const legacyManifestResolver = (config: AppshellGlobalConfig): RemoteResolver => {
|
|
62
|
+
const cache = new Map<string, Promise<AppshellManifest>>();
|
|
63
|
+
|
|
64
|
+
const fetchManifest = (url: string) => {
|
|
65
|
+
const cached = cache.get(url);
|
|
66
|
+
if (cached) return cached;
|
|
67
|
+
|
|
68
|
+
const pending = fetch(url, { credentials: 'include' }).then(async (response) => {
|
|
69
|
+
if (!response.ok) {
|
|
70
|
+
throw new Error(`Failed to get manifest from ${url}. ${await response.text()}`);
|
|
71
|
+
}
|
|
72
|
+
return response.json() as Promise<AppshellManifest>;
|
|
73
|
+
});
|
|
74
|
+
|
|
75
|
+
cache.set(url, pending);
|
|
76
|
+
|
|
77
|
+
return pending;
|
|
78
|
+
};
|
|
79
|
+
|
|
80
|
+
return async (key) => {
|
|
81
|
+
const manifestUrl = config.index?.[key];
|
|
82
|
+
if (!manifestUrl) return undefined;
|
|
83
|
+
|
|
84
|
+
const manifest = await fetchManifest(manifestUrl);
|
|
85
|
+
const remote = manifest?.remotes[key];
|
|
86
|
+
if (!remote) return undefined;
|
|
87
|
+
|
|
88
|
+
return {
|
|
89
|
+
remote,
|
|
90
|
+
environment: {
|
|
91
|
+
...(manifest.environment[remote.scope] ?? {}),
|
|
92
|
+
...(config.overrides?.environment?.[remote.scope] ?? {}),
|
|
93
|
+
},
|
|
94
|
+
manifest,
|
|
95
|
+
};
|
|
96
|
+
};
|
|
97
|
+
};
|
|
98
|
+
|
|
99
|
+
export const chainResolvers =
|
|
100
|
+
(...resolvers: RemoteResolver[]): RemoteResolver =>
|
|
101
|
+
async (key) => {
|
|
102
|
+
// eslint-disable-next-line no-restricted-syntax
|
|
103
|
+
for (const resolve of resolvers) {
|
|
104
|
+
// eslint-disable-next-line no-await-in-loop
|
|
105
|
+
const resolution = await resolve(key);
|
|
106
|
+
if (resolution) return resolution;
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
return undefined;
|
|
110
|
+
};
|