@openmrs/esm-extensions 4.5.1-pre.804 → 5.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.turbo/turbo-build.log +9 -20
- package/dist/openmrs-esm-extensions.js +2 -1
- package/dist/openmrs-esm-extensions.js.LICENSE.txt +1 -0
- package/dist/openmrs-esm-extensions.js.map +1 -1
- package/package.json +6 -5
- package/src/extensions.ts +3 -3
- package/src/helpers.ts +0 -9
- package/src/render.ts +4 -6
- package/src/store.ts +3 -3
- package/webpack.config.js +2 -5
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@openmrs/esm-extensions",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "5.0.0",
|
|
4
4
|
"license": "MPL-2.0",
|
|
5
5
|
"description": "Coordinates extensions and extension points in the OpenMRS Frontend",
|
|
6
6
|
"browser": "dist/openmrs-esm-extensions.js",
|
|
@@ -9,6 +9,7 @@
|
|
|
9
9
|
"scripts": {
|
|
10
10
|
"test": "jest --config jest.config.js --passWithNoTests",
|
|
11
11
|
"build": "webpack --mode=production",
|
|
12
|
+
"build:development": "webpack --mode development",
|
|
12
13
|
"analyze": "webpack --mode=production --env analyze=true",
|
|
13
14
|
"typescript": "tsc",
|
|
14
15
|
"lint": "eslint src --ext ts,tsx"
|
|
@@ -42,13 +43,13 @@
|
|
|
42
43
|
"single-spa": "5.x"
|
|
43
44
|
},
|
|
44
45
|
"devDependencies": {
|
|
45
|
-
"@openmrs/esm-api": "^
|
|
46
|
-
"@openmrs/esm-config": "^
|
|
47
|
-
"@openmrs/esm-state": "^
|
|
46
|
+
"@openmrs/esm-api": "^5.0.0",
|
|
47
|
+
"@openmrs/esm-config": "^5.0.0",
|
|
48
|
+
"@openmrs/esm-state": "^5.0.0",
|
|
48
49
|
"single-spa": "^5.9.2"
|
|
49
50
|
},
|
|
50
51
|
"dependencies": {
|
|
51
52
|
"lodash-es": "^4.17.21"
|
|
52
53
|
},
|
|
53
|
-
"gitHead": "
|
|
54
|
+
"gitHead": "2de5bf392a036e12c6d48425ff61881be7e32344"
|
|
54
55
|
}
|
package/src/extensions.ts
CHANGED
|
@@ -313,11 +313,13 @@ function getAssignedExtensionsFromSlotData(
|
|
|
313
313
|
);
|
|
314
314
|
const name = getExtensionNameFromId(id);
|
|
315
315
|
const extension = internalState.extensions[name];
|
|
316
|
+
|
|
316
317
|
// if the extension has not been registered yet, do not include it
|
|
317
318
|
if (extension) {
|
|
318
319
|
const requiredPrivileges =
|
|
319
320
|
extensionConfig?.["Display conditions"]?.privileges ??
|
|
320
|
-
extension.privileges
|
|
321
|
+
extension.privileges ??
|
|
322
|
+
[];
|
|
321
323
|
if (
|
|
322
324
|
requiredPrivileges &&
|
|
323
325
|
(typeof requiredPrivileges === "string" ||
|
|
@@ -342,8 +344,6 @@ function getAssignedExtensionsFromSlotData(
|
|
|
342
344
|
moduleName: extension.moduleName,
|
|
343
345
|
config: extensionConfig,
|
|
344
346
|
meta: extension.meta,
|
|
345
|
-
online: extension.online,
|
|
346
|
-
offline: extension.offline,
|
|
347
347
|
});
|
|
348
348
|
}
|
|
349
349
|
}
|
package/src/helpers.ts
CHANGED
|
@@ -13,12 +13,3 @@ export function checkStatusFor(
|
|
|
13
13
|
) {
|
|
14
14
|
return Boolean(status ? online : offline);
|
|
15
15
|
}
|
|
16
|
-
|
|
17
|
-
export function getCustomProps(
|
|
18
|
-
online: boolean | object | undefined,
|
|
19
|
-
offline: boolean | object | undefined
|
|
20
|
-
) {
|
|
21
|
-
const status = navigator.onLine;
|
|
22
|
-
const props = status ? online : offline;
|
|
23
|
-
return typeof props === "object" ? props : {};
|
|
24
|
-
}
|
package/src/render.ts
CHANGED
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
/** @module @category Extension */
|
|
2
|
-
import {
|
|
3
|
-
import { mountRootParcel, Parcel } from "single-spa";
|
|
2
|
+
import { mountRootParcel, Parcel, ParcelConfig } from "single-spa";
|
|
4
3
|
import { getExtensionNameFromId, getExtensionRegistration } from "./extensions";
|
|
5
|
-
import { checkStatus
|
|
4
|
+
import { checkStatus } from "./helpers";
|
|
6
5
|
import { updateInternalExtensionStore } from "./store";
|
|
7
6
|
|
|
8
7
|
export interface CancelLoading {
|
|
@@ -19,7 +18,7 @@ export async function renderExtension(
|
|
|
19
18
|
extensionSlotName: string,
|
|
20
19
|
extensionSlotModuleName: string,
|
|
21
20
|
extensionId: string,
|
|
22
|
-
renderFunction: (
|
|
21
|
+
renderFunction: (application: ParcelConfig) => ParcelConfig = (x) => x,
|
|
23
22
|
additionalProps: Record<string, any> = {}
|
|
24
23
|
): Promise<Parcel | null> {
|
|
25
24
|
const extensionName = getExtensionNameFromId(extensionId);
|
|
@@ -33,7 +32,7 @@ export async function renderExtension(
|
|
|
33
32
|
);
|
|
34
33
|
}
|
|
35
34
|
|
|
36
|
-
const { load,
|
|
35
|
+
const { load, meta, moduleName, online, offline } = extensionRegistration;
|
|
37
36
|
|
|
38
37
|
if (checkStatus(online, offline)) {
|
|
39
38
|
updateInternalExtensionStore((state) => {
|
|
@@ -60,7 +59,6 @@ export async function renderExtension(
|
|
|
60
59
|
|
|
61
60
|
const { default: result, ...lifecycle } = await load();
|
|
62
61
|
parcel = mountRootParcel(renderFunction(result ?? lifecycle), {
|
|
63
|
-
...getCustomProps(online, offline),
|
|
64
62
|
...additionalProps,
|
|
65
63
|
_meta: meta,
|
|
66
64
|
_extensionContext: {
|
package/src/store.ts
CHANGED
|
@@ -18,9 +18,9 @@ export interface ExtensionRegistration {
|
|
|
18
18
|
moduleName: string;
|
|
19
19
|
meta: ExtensionMeta;
|
|
20
20
|
order?: number;
|
|
21
|
-
online?: boolean
|
|
22
|
-
offline?: boolean
|
|
23
|
-
privileges?: string | string
|
|
21
|
+
online?: boolean;
|
|
22
|
+
offline?: boolean;
|
|
23
|
+
privileges?: string | Array<string>;
|
|
24
24
|
}
|
|
25
25
|
|
|
26
26
|
export interface ExtensionInfo extends ExtensionRegistration {
|
package/webpack.config.js
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
const ForkTsCheckerWebpackPlugin = require("fork-ts-checker-webpack-plugin");
|
|
2
|
-
const SystemJSPublicPathWebpackPlugin = require("systemjs-webpack-interop/SystemJSPublicPathWebpackPlugin");
|
|
3
2
|
const { resolve } = require("path");
|
|
4
3
|
const { CleanWebpackPlugin } = require("clean-webpack-plugin");
|
|
5
4
|
const { BundleAnalyzerPlugin } = require("webpack-bundle-analyzer");
|
|
@@ -11,7 +10,7 @@ module.exports = (env) => ({
|
|
|
11
10
|
output: {
|
|
12
11
|
filename: "openmrs-esm-extensions.js",
|
|
13
12
|
path: resolve(__dirname, "dist"),
|
|
14
|
-
|
|
13
|
+
library: { type: "var", name: "_openmrs_esm_extensions" },
|
|
15
14
|
},
|
|
16
15
|
devtool: "source-map",
|
|
17
16
|
module: {
|
|
@@ -19,7 +18,7 @@ module.exports = (env) => ({
|
|
|
19
18
|
{
|
|
20
19
|
test: /\.m?(js|ts|tsx)$/,
|
|
21
20
|
exclude: /node_modules/,
|
|
22
|
-
use: "swc-loader",
|
|
21
|
+
use: "@swc-node/loader",
|
|
23
22
|
},
|
|
24
23
|
],
|
|
25
24
|
},
|
|
@@ -28,14 +27,12 @@ module.exports = (env) => ({
|
|
|
28
27
|
modules: ["node_modules", resolve(__dirname, "node_modules")],
|
|
29
28
|
},
|
|
30
29
|
plugins: [
|
|
31
|
-
new SystemJSPublicPathWebpackPlugin(),
|
|
32
30
|
new CleanWebpackPlugin(),
|
|
33
31
|
new ForkTsCheckerWebpackPlugin(),
|
|
34
32
|
new BundleAnalyzerPlugin({
|
|
35
33
|
analyzerMode: env && env.analyze ? "static" : "disabled",
|
|
36
34
|
}),
|
|
37
35
|
],
|
|
38
|
-
externals: Object.keys(peerDependencies || {}),
|
|
39
36
|
devServer: {
|
|
40
37
|
disableHostCheck: true,
|
|
41
38
|
headers: {
|