@adobe/uix-host-react 0.10.5 → 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- package/dist/components/ExtensibleWrapper/ExtensibleWrapper.d.ts +33 -0
- package/dist/components/ExtensibleWrapper/ExtensibleWrapper.d.ts.map +1 -0
- package/dist/components/ExtensibleWrapper/ExtensionManagerProvider.d.ts +129 -0
- package/dist/components/ExtensibleWrapper/ExtensionManagerProvider.d.ts.map +1 -0
- package/dist/components/ExtensibleWrapper/ExtensionManagerProvider.test.d.ts +2 -0
- package/dist/components/ExtensibleWrapper/ExtensionManagerProvider.test.d.ts.map +1 -0
- package/dist/components/ExtensibleWrapper/UrlExtensionProvider.d.ts +37 -0
- package/dist/components/ExtensibleWrapper/UrlExtensionProvider.d.ts.map +1 -0
- package/dist/components/ExtensibleWrapper/UrlExtensionProvider.test.d.ts +2 -0
- package/dist/components/ExtensibleWrapper/UrlExtensionProvider.test.d.ts.map +1 -0
- package/dist/components/ExtensibleWrapper/index.d.ts +4 -0
- package/dist/components/ExtensibleWrapper/index.d.ts.map +1 -0
- package/dist/components/index.d.ts +1 -0
- package/dist/components/index.d.ts.map +1 -1
- package/dist/index.js +251 -0
- package/dist/index.js.map +1 -1
- package/package.json +3 -3
- package/src/components/ExtensibleWrapper/ExtensibleWrapper.tsx +133 -0
- package/src/components/ExtensibleWrapper/ExtensionManagerProvider.test.ts +214 -0
- package/src/components/ExtensibleWrapper/ExtensionManagerProvider.ts +324 -0
- package/src/components/ExtensibleWrapper/UrlExtensionProvider.test.ts +119 -0
- package/src/components/ExtensibleWrapper/UrlExtensionProvider.ts +93 -0
- package/src/components/ExtensibleWrapper/index.ts +15 -0
- package/src/components/index.ts +1 -0
@@ -0,0 +1,33 @@
|
|
1
|
+
import type { PropsWithChildren, ReactElement } from "react";
|
2
|
+
import { type HostConfig, type PortOptions, type SharedContextValues } from "@adobe/uix-host";
|
3
|
+
/** @public */
|
4
|
+
export interface ExtensibleDefaultProps extends Omit<HostConfig, "hostName"> {
|
5
|
+
/**
|
6
|
+
* Unique name for identifying this extensible app. May be used as metadata in
|
7
|
+
* extension registry in the future.
|
8
|
+
*/
|
9
|
+
appName?: string;
|
10
|
+
/**
|
11
|
+
* {@inheritDoc HostConfig.guestOptions}
|
12
|
+
*/
|
13
|
+
guestOptions?: PortOptions;
|
14
|
+
/**
|
15
|
+
* {@inheritDoc HostConfig.sharedContext}
|
16
|
+
*/
|
17
|
+
sharedContext?: SharedContextValues;
|
18
|
+
queryString?: string;
|
19
|
+
service: string;
|
20
|
+
extensionPoint: string;
|
21
|
+
version: string;
|
22
|
+
disableExtensionManager?: boolean;
|
23
|
+
authConfig: {
|
24
|
+
imsToken: string;
|
25
|
+
imsOrg: string;
|
26
|
+
apiKey: string;
|
27
|
+
};
|
28
|
+
scope?: Record<string, any>;
|
29
|
+
experienceShellEnvironment?: "prod" | "stage";
|
30
|
+
}
|
31
|
+
export declare const ExtensibleWrapper: ({ appName, children, guestOptions, runtimeContainer, debug, sharedContext, experienceShellEnvironment, queryString, service, extensionPoint, version, disableExtensionManager, authConfig, scope, }: PropsWithChildren<ExtensibleDefaultProps>) => ReactElement;
|
32
|
+
export default ExtensibleWrapper;
|
33
|
+
//# sourceMappingURL=ExtensibleWrapper.d.ts.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"ExtensibleWrapper.d.ts","sourceRoot":"","sources":["../../../src/components/ExtensibleWrapper/ExtensibleWrapper.tsx"],"names":[],"mappings":"AAWA,OAAO,KAAK,EAAE,iBAAiB,EAAE,YAAY,EAAE,MAAM,OAAO,CAAC;AAG7D,OAAO,EAIL,KAAK,UAAU,EACf,KAAK,WAAW,EAChB,KAAK,mBAAmB,EACzB,MAAM,iBAAiB,CAAC;AAQzB,cAAc;AACd,MAAM,WAAW,sBAAuB,SAAQ,IAAI,CAAC,UAAU,EAAE,UAAU,CAAC;IAC1E;;;OAGG;IACH,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB;;OAEG;IACH,YAAY,CAAC,EAAE,WAAW,CAAC;IAC3B;;OAEG;IACH,aAAa,CAAC,EAAE,mBAAmB,CAAC;IACpC,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,OAAO,EAAE,MAAM,CAAC;IAChB,cAAc,EAAE,MAAM,CAAC;IACvB,OAAO,EAAE,MAAM,CAAC;IAChB,uBAAuB,CAAC,EAAE,OAAO,CAAC;IAClC,UAAU,EAAE;QACV,QAAQ,EAAE,MAAM,CAAC;QACjB,MAAM,EAAE,MAAM,CAAC;QACf,MAAM,EAAE,MAAM,CAAC;KAChB,CAAC;IACF,KAAK,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;IAC5B,0BAA0B,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC;CAC/C;AAED,eAAO,MAAM,iBAAiB,wMAe3B,kBAAkB,sBAAsB,CAAC,KAAG,YAyD9C,CAAC;AAEF,eAAe,iBAAiB,CAAC"}
|
@@ -0,0 +1,129 @@
|
|
1
|
+
/*************************************************************************
|
2
|
+
* ADOBE CONFIDENTIAL
|
3
|
+
* ___________________
|
4
|
+
*
|
5
|
+
* Copyright 2024 Adobe
|
6
|
+
* All Rights Reserved.
|
7
|
+
*
|
8
|
+
* NOTICE: All information contained herein is, and remains
|
9
|
+
* the property of Adobe and its suppliers, if any. The intellectual
|
10
|
+
* and technical concepts contained herein are proprietary to Adobe
|
11
|
+
* and its suppliers and are protected by all applicable intellectual
|
12
|
+
* property laws, including trade secret and copyright laws.
|
13
|
+
* Dissemination of this information or reproduction of this material
|
14
|
+
* is strictly forbidden unless prior written permission is obtained
|
15
|
+
* from Adobe.
|
16
|
+
**************************************************************************/
|
17
|
+
import { ExtensionsProvider, InstalledExtensions } from "@adobe/uix-host";
|
18
|
+
declare type ExtensionPoint = {
|
19
|
+
extensionPoint: string;
|
20
|
+
url: string;
|
21
|
+
};
|
22
|
+
export declare type ExtensionManagerExtension = {
|
23
|
+
id: string;
|
24
|
+
name: string;
|
25
|
+
title: string;
|
26
|
+
description: string;
|
27
|
+
status: string;
|
28
|
+
supportEmail: string;
|
29
|
+
extId: string;
|
30
|
+
disabled: boolean;
|
31
|
+
extensionPoints: ExtensionPoint[];
|
32
|
+
scope: Record<string, unknown>;
|
33
|
+
configuration?: Record<string, unknown>;
|
34
|
+
};
|
35
|
+
declare type AuthEMConfig = {
|
36
|
+
schema: "Bearer" | "Basic";
|
37
|
+
imsToken: string;
|
38
|
+
};
|
39
|
+
export interface ExtensionManagerConfig {
|
40
|
+
apiKey: string;
|
41
|
+
auth: AuthEMConfig;
|
42
|
+
service: string;
|
43
|
+
extensionPoint: string;
|
44
|
+
version: string;
|
45
|
+
imsOrg: string;
|
46
|
+
baseUrl: string;
|
47
|
+
scope?: Record<string, string>;
|
48
|
+
}
|
49
|
+
/** Authentication configuration, including IMS Org ID, access token, and API key */
|
50
|
+
export interface AuthConfig {
|
51
|
+
/** IMS Org ID */
|
52
|
+
imsOrg: string;
|
53
|
+
/** Access token for the user */
|
54
|
+
imsToken: string;
|
55
|
+
/** API key */
|
56
|
+
apiKey: string;
|
57
|
+
}
|
58
|
+
/** Discovery configuration, including environment and repo Id */
|
59
|
+
export interface DiscoveryConfig {
|
60
|
+
/** Environment level for backend Extension resolution services */
|
61
|
+
experienceShellEnvironment?: "prod" | "stage";
|
62
|
+
scope?: Record<string, string>;
|
63
|
+
}
|
64
|
+
/** Extension point ID */
|
65
|
+
export interface ExtensionPointId {
|
66
|
+
/** Service name */
|
67
|
+
service: string;
|
68
|
+
/** Extension point name */
|
69
|
+
name: string;
|
70
|
+
/** Extension point version */
|
71
|
+
version: string;
|
72
|
+
}
|
73
|
+
/**
|
74
|
+
* Sets up new ExtensionsProvider with authentication and discovery information needed to fetch the list of
|
75
|
+
* Extensions from AppRegistry and Extension Manager service, along with the query string portion of URL
|
76
|
+
* to extract the information about development Extensions
|
77
|
+
*/
|
78
|
+
export interface ExtensionsProviderConfig {
|
79
|
+
/** Discovery configuration */
|
80
|
+
discoveryConfig: DiscoveryConfig;
|
81
|
+
/** Authentication configuration */
|
82
|
+
authConfig: AuthConfig;
|
83
|
+
/** Extension point ID */
|
84
|
+
extensionPointId: ExtensionPointId;
|
85
|
+
providerConfig: ExtensionProviderConfig;
|
86
|
+
}
|
87
|
+
export interface ExtensionProviderConfig {
|
88
|
+
extensionManagerUrl?: string;
|
89
|
+
appRegistryUrl?: string;
|
90
|
+
disableExtensionManager?: boolean;
|
91
|
+
}
|
92
|
+
export declare const getExtensionRegistryBaseUrl: (environment: "prod" | "stage" | undefined, registry: string | null) => string;
|
93
|
+
export declare const getExtensionManagerBaseUrl: (environment: "prod" | "stage" | undefined, extensionManager: string | null) => string;
|
94
|
+
/**
|
95
|
+
* Extracts programId and envId from the repo value
|
96
|
+
* @param repo - the repo value
|
97
|
+
* @returns object with programId and envId
|
98
|
+
* @ignore
|
99
|
+
*/
|
100
|
+
export declare function extractProgramIdEnvId(repo: string): {
|
101
|
+
programId: string;
|
102
|
+
envId: string;
|
103
|
+
};
|
104
|
+
/**
|
105
|
+
* Builds the URL for fetching extensions from the Extension Manager service
|
106
|
+
* @param config - the Extension Manager configuration
|
107
|
+
* @returns the URL for fetching extensions
|
108
|
+
* @ignore
|
109
|
+
*/
|
110
|
+
export declare function buildExtensionManagerUrl(config: ExtensionManagerConfig): string;
|
111
|
+
/**
|
112
|
+
* @ignore
|
113
|
+
*/
|
114
|
+
export declare function fetchExtensionsFromExtensionManager(config: ExtensionManagerConfig): Promise<ExtensionManagerExtension[]>;
|
115
|
+
/**
|
116
|
+
* Takes an array of extensions from the App Registry, an array of extensions from the Extension Manager, and
|
117
|
+
* merges them into a list of Extensions. If an extension is disabled in the Extension Manager, it is removed from
|
118
|
+
* the list.
|
119
|
+
* Extension list from the App Registry is used as a base.
|
120
|
+
* @ignore
|
121
|
+
*/
|
122
|
+
export declare function mergeExtensions(appRegistryExtensions: InstalledExtensions, extensionManagerExtensions: ExtensionManagerExtension[], extensionPointId: ExtensionPointId): InstalledExtensions;
|
123
|
+
/**
|
124
|
+
* Creates an extension manager extension provider
|
125
|
+
* @ignore
|
126
|
+
*/
|
127
|
+
export declare function createExtensionManagerExtensionsProvider(discoveryConfig: DiscoveryConfig, authConfig: AuthConfig, providerConfig: ExtensionProviderConfig, extensionPointId: ExtensionPointId): ExtensionsProvider;
|
128
|
+
export {};
|
129
|
+
//# sourceMappingURL=ExtensionManagerProvider.d.ts.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"ExtensionManagerProvider.d.ts","sourceRoot":"","sources":["../../../src/components/ExtensibleWrapper/ExtensionManagerProvider.ts"],"names":[],"mappings":"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"}
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"ExtensionManagerProvider.test.d.ts","sourceRoot":"","sources":["../../../src/components/ExtensibleWrapper/ExtensionManagerProvider.test.ts"],"names":[],"mappings":""}
|
@@ -0,0 +1,37 @@
|
|
1
|
+
/*************************************************************************
|
2
|
+
* ADOBE CONFIDENTIAL
|
3
|
+
* ___________________
|
4
|
+
*
|
5
|
+
* Copyright 2024 Adobe
|
6
|
+
* All Rights Reserved.
|
7
|
+
*
|
8
|
+
* NOTICE: All information contained herein is, and remains
|
9
|
+
* the property of Adobe and its suppliers, if any. The intellectual
|
10
|
+
* and technical concepts contained herein are proprietary to Adobe
|
11
|
+
* and its suppliers and are protected by all applicable intellectual
|
12
|
+
* property laws, including trade secret and copyright laws.
|
13
|
+
* Dissemination of this information or reproduction of this material
|
14
|
+
* is strictly forbidden unless prior written permission is obtained
|
15
|
+
* from Adobe.
|
16
|
+
**************************************************************************/
|
17
|
+
import { ExtensionsProvider } from "@adobe/uix-host";
|
18
|
+
import { ExtensionPointId } from "./ExtensionManagerProvider";
|
19
|
+
export interface ExtUrlParams {
|
20
|
+
[key: string]: string;
|
21
|
+
}
|
22
|
+
/**
|
23
|
+
* Extracts extension URLs from the query string
|
24
|
+
* @ignore
|
25
|
+
*/
|
26
|
+
export declare function extractExtUrlParams(queryString: string | undefined): ExtUrlParams;
|
27
|
+
/**
|
28
|
+
* Generates an extension ID from the extension URL
|
29
|
+
* @ignore
|
30
|
+
*/
|
31
|
+
export declare function generateExtensionId(extensionUrl: string): string;
|
32
|
+
/**
|
33
|
+
* Creates an ExtensionsProvider that provides extensions from the URL
|
34
|
+
* @ignore
|
35
|
+
*/
|
36
|
+
export declare function createUrlExtensionsProvider(extensionPointId: ExtensionPointId, queryString: string | undefined): ExtensionsProvider;
|
37
|
+
//# sourceMappingURL=UrlExtensionProvider.d.ts.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"UrlExtensionProvider.d.ts","sourceRoot":"","sources":["../../../src/components/ExtensibleWrapper/UrlExtensionProvider.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;4EAe4E;AAC5E,OAAO,EAAE,kBAAkB,EAAuB,MAAM,iBAAiB,CAAC;AAE1E,OAAO,EAAE,gBAAgB,EAAE,MAAM,4BAA4B,CAAC;AAI9D,MAAM,WAAW,YAAY;IAC3B,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAAC;CACvB;AAED;;;GAGG;AACH,wBAAgB,mBAAmB,CACjC,WAAW,EAAE,MAAM,GAAG,SAAS,GAC9B,YAAY,CAWd;AAED;;;GAGG;AACH,wBAAgB,mBAAmB,CAAC,YAAY,EAAE,MAAM,GAAG,MAAM,CAEhE;AAED;;;GAGG;AACH,wBAAgB,2BAA2B,CACzC,gBAAgB,EAAE,gBAAgB,EAClC,WAAW,EAAE,MAAM,GAAG,SAAS,GAC9B,kBAAkB,CAgCpB"}
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"UrlExtensionProvider.test.d.ts","sourceRoot":"","sources":["../../../src/components/ExtensibleWrapper/UrlExtensionProvider.test.ts"],"names":[],"mappings":""}
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/ExtensibleWrapper/index.ts"],"names":[],"mappings":"AAYA,cAAc,qBAAqB,CAAC;AACpC,cAAc,wBAAwB,CAAC;AACvC,cAAc,4BAA4B,CAAC"}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/components/index.ts"],"names":[],"mappings":"AAYA,cAAc,iBAAiB,CAAC;AAChC,cAAc,mBAAmB,CAAC;AAClC,cAAc,kCAAkC,CAAC"}
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/components/index.ts"],"names":[],"mappings":"AAYA,cAAc,iBAAiB,CAAC;AAChC,cAAc,mBAAmB,CAAC;AAClC,cAAc,kCAAkC,CAAC;AACjD,cAAc,8BAA8B,CAAC"}
|
package/dist/index.js
CHANGED
@@ -192,6 +192,246 @@ var ExtensibleComponentBoundary = ({
|
|
192
192
|
}) => {
|
193
193
|
return /* @__PURE__ */ React__default.default.createElement(ExtensibleComponentBoundaryContext.Provider, { value: extensionPoints }, children);
|
194
194
|
};
|
195
|
+
var EXTENSION_MANAGER_URL_PROD = "https://aemx-mngr.adobe.io";
|
196
|
+
var EXTENSION_MANAGER_URL_STAGE = "https://aemx-mngr-stage.adobe.io";
|
197
|
+
var APP_REGISTRY_URL_PROD = "https://appregistry.adobe.io";
|
198
|
+
var APP_REGISTRY_URL_STAGE = "https://appregistry-stage.adobe.io";
|
199
|
+
var getExtensionRegistryBaseUrl = (environment, registry) => environment === "prod" ? APP_REGISTRY_URL_PROD : registry != null ? registry : APP_REGISTRY_URL_STAGE;
|
200
|
+
var getExtensionManagerBaseUrl = (environment, extensionManager) => environment === "prod" ? EXTENSION_MANAGER_URL_PROD : extensionManager != null ? extensionManager : EXTENSION_MANAGER_URL_STAGE;
|
201
|
+
function extractProgramIdEnvId(repo) {
|
202
|
+
const regex = /p(\d+)-e(\d+)/;
|
203
|
+
const match = regex.exec(repo);
|
204
|
+
if (!match) {
|
205
|
+
throw new Error("Error parsing a repo value");
|
206
|
+
}
|
207
|
+
return {
|
208
|
+
programId: match[1],
|
209
|
+
envId: match[2]
|
210
|
+
};
|
211
|
+
}
|
212
|
+
function buildExtensionManagerUrl(config) {
|
213
|
+
const scope = config.scope ? Object.fromEntries(
|
214
|
+
Object.entries(config.scope).map(([k, v]) => [`scope.${k}`, v])
|
215
|
+
) : {};
|
216
|
+
const extensionPoints = `${config.service}/${config.extensionPoint}/${config.version}`;
|
217
|
+
const queryParams = new URLSearchParams({
|
218
|
+
...scope,
|
219
|
+
extensionPoints
|
220
|
+
});
|
221
|
+
return `${config.baseUrl}/v2/extensions?${queryParams.toString()}`;
|
222
|
+
}
|
223
|
+
async function fetchExtensionsFromExtensionManager(config) {
|
224
|
+
const resp = await fetch(buildExtensionManagerUrl(config), {
|
225
|
+
headers: {
|
226
|
+
Authorization: `Bearer ${config.auth.imsToken}`,
|
227
|
+
"x-api-key": config.apiKey,
|
228
|
+
"x-org-id": config.imsOrg
|
229
|
+
}
|
230
|
+
});
|
231
|
+
if (resp.status !== 200) {
|
232
|
+
throw new Error(
|
233
|
+
`Extension Manager returned non-200 response (${resp.status}): ${await resp.text()}`
|
234
|
+
);
|
235
|
+
}
|
236
|
+
return resp.json();
|
237
|
+
}
|
238
|
+
function mergeExtensions(appRegistryExtensions, extensionManagerExtensions, extensionPointId) {
|
239
|
+
const mergedExtensions = Object.assign(
|
240
|
+
appRegistryExtensions,
|
241
|
+
{}
|
242
|
+
);
|
243
|
+
extensionManagerExtensions.forEach((extension) => {
|
244
|
+
if (extension.disabled) {
|
245
|
+
delete mergedExtensions[extension.name];
|
246
|
+
} else {
|
247
|
+
const extPoint = extension.extensionPoints.find(
|
248
|
+
(_extensionPoint) => _extensionPoint.extensionPoint === `${extensionPointId.service}/${extensionPointId.name}/${extensionPointId.version}`
|
249
|
+
);
|
250
|
+
if (extPoint) {
|
251
|
+
mergedExtensions[extension.name] = {
|
252
|
+
id: extension.name,
|
253
|
+
url: extPoint.url,
|
254
|
+
configuration: extension.configuration,
|
255
|
+
extensionPoints: extension.extensionPoints.map(
|
256
|
+
(point) => point.extensionPoint
|
257
|
+
)
|
258
|
+
};
|
259
|
+
} else {
|
260
|
+
console.warn(
|
261
|
+
`Extension point ${extensionPointId.service}/${extensionPointId.name}/${extensionPointId.version} not found for extension ${extension.name}`
|
262
|
+
);
|
263
|
+
}
|
264
|
+
}
|
265
|
+
});
|
266
|
+
return mergedExtensions;
|
267
|
+
}
|
268
|
+
async function getExtensionManagerExtensions(discoveryConfig, authConfig, providerConfig, extensionPointId) {
|
269
|
+
const config = {
|
270
|
+
apiKey: authConfig.apiKey,
|
271
|
+
auth: {
|
272
|
+
schema: "Bearer",
|
273
|
+
imsToken: authConfig.imsToken
|
274
|
+
},
|
275
|
+
service: extensionPointId.service,
|
276
|
+
extensionPoint: extensionPointId.name,
|
277
|
+
version: extensionPointId.version,
|
278
|
+
imsOrg: authConfig.imsOrg,
|
279
|
+
scope: discoveryConfig.scope
|
280
|
+
};
|
281
|
+
const appRegistryConfig = {
|
282
|
+
...config,
|
283
|
+
baseUrl: getExtensionRegistryBaseUrl(
|
284
|
+
discoveryConfig.experienceShellEnvironment,
|
285
|
+
providerConfig.appRegistryUrl
|
286
|
+
)
|
287
|
+
};
|
288
|
+
const appRegistryExtensionsProvider = uixHost.createExtensionRegistryAsObjectsProvider(appRegistryConfig);
|
289
|
+
const extensionManagerConfiguration = {
|
290
|
+
...config,
|
291
|
+
baseUrl: getExtensionManagerBaseUrl(
|
292
|
+
discoveryConfig.experienceShellEnvironment,
|
293
|
+
providerConfig.extensionManagerUrl
|
294
|
+
)
|
295
|
+
};
|
296
|
+
const [appRegistryExtensions, extensionManagerExtensions] = await Promise.all(
|
297
|
+
[
|
298
|
+
appRegistryExtensionsProvider(),
|
299
|
+
providerConfig.disableExtensionManager ? [] : fetchExtensionsFromExtensionManager(extensionManagerConfiguration)
|
300
|
+
]
|
301
|
+
);
|
302
|
+
if (providerConfig.disableExtensionManager) {
|
303
|
+
return appRegistryExtensions;
|
304
|
+
} else {
|
305
|
+
return mergeExtensions(
|
306
|
+
appRegistryExtensions,
|
307
|
+
extensionManagerExtensions,
|
308
|
+
extensionPointId
|
309
|
+
);
|
310
|
+
}
|
311
|
+
}
|
312
|
+
function createExtensionManagerExtensionsProvider(discoveryConfig, authConfig, providerConfig, extensionPointId) {
|
313
|
+
return () => {
|
314
|
+
return getExtensionManagerExtensions(
|
315
|
+
discoveryConfig,
|
316
|
+
authConfig,
|
317
|
+
providerConfig,
|
318
|
+
extensionPointId
|
319
|
+
);
|
320
|
+
};
|
321
|
+
}
|
322
|
+
|
323
|
+
// src/components/ExtensibleWrapper/UrlExtensionProvider.ts
|
324
|
+
var EXT_PARAM_PREFIX = "ext";
|
325
|
+
function extractExtUrlParams(queryString) {
|
326
|
+
if (!queryString) {
|
327
|
+
return {};
|
328
|
+
}
|
329
|
+
const params = new URLSearchParams(queryString);
|
330
|
+
return Array.from(params.entries()).reduce((extParams, [key, value]) => {
|
331
|
+
if (key === EXT_PARAM_PREFIX || key.startsWith(`${EXT_PARAM_PREFIX}.`)) {
|
332
|
+
extParams[key] = value;
|
333
|
+
}
|
334
|
+
return extParams;
|
335
|
+
}, {});
|
336
|
+
}
|
337
|
+
function generateExtensionId(extensionUrl) {
|
338
|
+
return extensionUrl.replace(/\W/g, "_");
|
339
|
+
}
|
340
|
+
function createUrlExtensionsProvider(extensionPointId, queryString) {
|
341
|
+
const extUrlParams = extractExtUrlParams(queryString);
|
342
|
+
const extensionUrls = Object.keys(extUrlParams).filter(
|
343
|
+
(extParam) => extParam === EXT_PARAM_PREFIX || extParam === `${EXT_PARAM_PREFIX}.${extensionPointId.service}/${extensionPointId.name}/${extensionPointId.version}`
|
344
|
+
).flatMap((extParam) => {
|
345
|
+
const paramValue = extUrlParams[extParam];
|
346
|
+
return Array.isArray(paramValue) ? paramValue : [paramValue];
|
347
|
+
});
|
348
|
+
const installedExtensions = extensionUrls.map((extensionUrl) => {
|
349
|
+
return {
|
350
|
+
id: generateExtensionId(extensionUrl),
|
351
|
+
url: extensionUrl,
|
352
|
+
extensionPoints: [
|
353
|
+
`${extensionPointId.service}/${extensionPointId.name}/${extensionPointId.version}`
|
354
|
+
]
|
355
|
+
};
|
356
|
+
}).reduce((acc, extension) => {
|
357
|
+
acc[extension.id] = extension;
|
358
|
+
return acc;
|
359
|
+
}, {});
|
360
|
+
return async () => installedExtensions;
|
361
|
+
}
|
362
|
+
|
363
|
+
// src/components/ExtensibleWrapper/ExtensibleWrapper.tsx
|
364
|
+
var ExtensibleWrapper = ({
|
365
|
+
appName,
|
366
|
+
children,
|
367
|
+
guestOptions,
|
368
|
+
runtimeContainer,
|
369
|
+
debug,
|
370
|
+
sharedContext,
|
371
|
+
experienceShellEnvironment,
|
372
|
+
queryString,
|
373
|
+
service,
|
374
|
+
extensionPoint,
|
375
|
+
version,
|
376
|
+
disableExtensionManager,
|
377
|
+
authConfig,
|
378
|
+
scope
|
379
|
+
}) => {
|
380
|
+
const defaultExtensionsProvider = React.useMemo(() => {
|
381
|
+
const extensionPointId = {
|
382
|
+
service,
|
383
|
+
name: extensionPoint,
|
384
|
+
version
|
385
|
+
};
|
386
|
+
const params = new URLSearchParams(queryString != null ? queryString : "");
|
387
|
+
const extensionManagerUrlOverride = params.get("em");
|
388
|
+
const appRegistryUrlOverride = params.get("er");
|
389
|
+
const urlExtensionsProvider = createUrlExtensionsProvider(extensionPointId, queryString);
|
390
|
+
const providerConfig = {
|
391
|
+
disableExtensionManager
|
392
|
+
};
|
393
|
+
if (extensionManagerUrlOverride) {
|
394
|
+
providerConfig.extensionManagerUrl = extensionManagerUrlOverride;
|
395
|
+
}
|
396
|
+
if (appRegistryUrlOverride) {
|
397
|
+
providerConfig.appRegistryUrl = appRegistryUrlOverride;
|
398
|
+
}
|
399
|
+
const extensionManagerExtensionsProvider = createExtensionManagerExtensionsProvider(
|
400
|
+
{
|
401
|
+
experienceShellEnvironment,
|
402
|
+
scope
|
403
|
+
},
|
404
|
+
authConfig,
|
405
|
+
providerConfig,
|
406
|
+
extensionPointId
|
407
|
+
);
|
408
|
+
return uixHost.combineExtensionsFromProviders(
|
409
|
+
urlExtensionsProvider,
|
410
|
+
uixHost.mutedProvider(extensionManagerExtensionsProvider)
|
411
|
+
);
|
412
|
+
}, [
|
413
|
+
experienceShellEnvironment,
|
414
|
+
queryString,
|
415
|
+
service,
|
416
|
+
extensionPoint,
|
417
|
+
version,
|
418
|
+
disableExtensionManager,
|
419
|
+
authConfig,
|
420
|
+
scope
|
421
|
+
]);
|
422
|
+
return /* @__PURE__ */ React__default.default.createElement(
|
423
|
+
Extensible,
|
424
|
+
{
|
425
|
+
extensionsProvider: defaultExtensionsProvider,
|
426
|
+
appName,
|
427
|
+
runtimeContainer,
|
428
|
+
debug,
|
429
|
+
guestOptions,
|
430
|
+
sharedContext
|
431
|
+
},
|
432
|
+
children
|
433
|
+
);
|
434
|
+
};
|
195
435
|
var NO_EXTENSIONS = [];
|
196
436
|
function useExtensions(configFactory, deps = []) {
|
197
437
|
const { host, error } = useHost();
|
@@ -292,9 +532,20 @@ function useExtensionListFetched() {
|
|
292
532
|
exports.Extensible = Extensible;
|
293
533
|
exports.ExtensibleComponentBoundary = ExtensibleComponentBoundary;
|
294
534
|
exports.ExtensibleComponentBoundaryContext = ExtensibleComponentBoundaryContext;
|
535
|
+
exports.ExtensibleWrapper = ExtensibleWrapper;
|
295
536
|
exports.ExtensionContext = ExtensionContext;
|
296
537
|
exports.GuestUIFrame = GuestUIFrame;
|
297
538
|
exports.OutsideOfExtensionContextError = OutsideOfExtensionContextError;
|
539
|
+
exports.buildExtensionManagerUrl = buildExtensionManagerUrl;
|
540
|
+
exports.createExtensionManagerExtensionsProvider = createExtensionManagerExtensionsProvider;
|
541
|
+
exports.createUrlExtensionsProvider = createUrlExtensionsProvider;
|
542
|
+
exports.extractExtUrlParams = extractExtUrlParams;
|
543
|
+
exports.extractProgramIdEnvId = extractProgramIdEnvId;
|
544
|
+
exports.fetchExtensionsFromExtensionManager = fetchExtensionsFromExtensionManager;
|
545
|
+
exports.generateExtensionId = generateExtensionId;
|
546
|
+
exports.getExtensionManagerBaseUrl = getExtensionManagerBaseUrl;
|
547
|
+
exports.getExtensionRegistryBaseUrl = getExtensionRegistryBaseUrl;
|
548
|
+
exports.mergeExtensions = mergeExtensions;
|
298
549
|
exports.useExtensionListFetched = useExtensionListFetched;
|
299
550
|
exports.useExtensions = useExtensions;
|
300
551
|
exports.useHost = useHost;
|