@openmrs/esm-routes 6.3.1-pre.2961 → 6.3.1-pre.2986
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/.swcrc +16 -0
- package/.turbo/turbo-build.log +3 -13
- package/dist/constants.d.ts +1 -0
- package/dist/constants.js +1 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.js +3 -0
- package/dist/loaders/app.d.ts +40 -0
- package/dist/loaders/app.js +82 -0
- package/dist/loaders/components.d.ts +37 -0
- package/dist/loaders/components.js +194 -0
- package/dist/loaders/helpers.d.ts +3 -0
- package/dist/loaders/helpers.js +15 -0
- package/dist/loaders/index.d.ts +3 -0
- package/dist/loaders/index.js +3 -0
- package/dist/loaders/pages.d.ts +20 -0
- package/dist/loaders/pages.js +179 -0
- package/dist/public.d.ts +3 -0
- package/dist/public.js +3 -0
- package/dist/routes.d.ts +46 -0
- package/dist/routes.js +125 -0
- package/package.json +30 -17
- package/src/routes.test.ts +4 -2
- package/tsconfig.build.json +9 -0
- package/tsconfig.json +3 -23
- package/vitest.config.ts +8 -0
- package/dist/openmrs-esm-utils.js +0 -2
- package/dist/openmrs-esm-utils.js.map +0 -1
- package/jest.config.js +0 -13
- package/webpack.config.js +0 -42
package/.swcrc
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "https://swc.rs/schema.json",
|
|
3
|
+
"exclude": [".*\\.test\\..*", "setup-tests\\..*"],
|
|
4
|
+
"module": {
|
|
5
|
+
"type": "es6",
|
|
6
|
+
"resolveFully": true
|
|
7
|
+
},
|
|
8
|
+
"jsc": {
|
|
9
|
+
"parser": {
|
|
10
|
+
"syntax": "typescript",
|
|
11
|
+
"tsx": false
|
|
12
|
+
},
|
|
13
|
+
"target": "es2020",
|
|
14
|
+
"baseUrl": "src"
|
|
15
|
+
}
|
|
16
|
+
}
|
package/.turbo/turbo-build.log
CHANGED
|
@@ -1,13 +1,3 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
built modules 40.4 KiB [built]
|
|
5
|
-
modules by path external "@openmrs/ 210 bytes
|
|
6
|
-
external "@openmrs/esm-utils" 42 bytes [built] [code generated]
|
|
7
|
-
external "@openmrs/esm-dynamic-loading" 42 bytes [built] [code generated]
|
|
8
|
-
external "@openmrs/esm-config" 42 bytes [built] [code generated]
|
|
9
|
-
external "@openmrs/esm-feature-flags" 42 bytes [built] [code generated]
|
|
10
|
-
external "@openmrs/esm-extensions" 42 bytes [built] [code generated]
|
|
11
|
-
./src/index.ts + 7 modules 40.2 KiB [built] [code generated]
|
|
12
|
-
external "single-spa" 42 bytes [built] [code generated]
|
|
13
|
-
webpack 5.88.0 compiled successfully in 9884 ms
|
|
1
|
+
[0] Successfully compiled: 9 files with swc (177.22ms)
|
|
2
|
+
[0] swc --strip-leading-paths src -d dist exited with code 0
|
|
3
|
+
[1] tsc --project tsconfig.build.json exited with code 0
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const localStorageRoutesPrefix = "openmrs-routes:";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export const localStorageRoutesPrefix = 'openmrs-routes:';
|
package/dist/index.d.ts
ADDED
package/dist/index.js
ADDED
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { type LifeCycles } from 'single-spa';
|
|
2
|
+
type Module = Omit<Record<string, () => LifeCycles | Promise<LifeCycles>>, 'startupApp'> & {
|
|
3
|
+
startupApp?: () => unknown;
|
|
4
|
+
};
|
|
5
|
+
/**
|
|
6
|
+
* This function creates a loader function suitable for use in either a single-spa
|
|
7
|
+
* application or parcel.
|
|
8
|
+
*
|
|
9
|
+
* The returned function is lazy and ensures that the appropriate module is loaded,
|
|
10
|
+
* that the module's `startupApp()` is called before the component is loaded. It
|
|
11
|
+
* then calls the component function, which should return either a single-spa
|
|
12
|
+
* {@link LifeCycles} object or a {@link Promise} that will resolve to such an object.
|
|
13
|
+
*
|
|
14
|
+
* React-based pages or extensions should generally use the framework's
|
|
15
|
+
* `getAsyncLifecycle()` or `getSyncLifecycle()` functions.
|
|
16
|
+
*
|
|
17
|
+
* @param routesAppName The app name of the routes.json file defining the component to load
|
|
18
|
+
*
|
|
19
|
+
* @param fullComponentName The name of the component to load. Note that this can optionally
|
|
20
|
+
* include the appName to load the component from (in the format `${appName}#${componentName}`),
|
|
21
|
+
* or omitted to implicitly use routesAppName
|
|
22
|
+
*
|
|
23
|
+
*/
|
|
24
|
+
export declare function getLoader(routesAppName: string, fullComponentName: string): () => Promise<LifeCycles>;
|
|
25
|
+
/**
|
|
26
|
+
* This function can be used to manually initialize an application without waiting for the
|
|
27
|
+
* framework to load it. This can sometimes be helpful if the framework doesn't load code
|
|
28
|
+
* at the point you think is appropriate.
|
|
29
|
+
*
|
|
30
|
+
* This will ensure that the module is available and that it's `startupApp()` function (if
|
|
31
|
+
* any) will be called. Note that these are only guaranteed to be complete once the Promise
|
|
32
|
+
* returned from the function completes.
|
|
33
|
+
*
|
|
34
|
+
* @param appName The name of the app to initialize
|
|
35
|
+
* @param module The loaded code module, if available; if this parameter is omitted, this
|
|
36
|
+
* function will load it.
|
|
37
|
+
* @returns a Promise which completes once the app has been loaded and initialized
|
|
38
|
+
*/
|
|
39
|
+
export declare function initializeApp(appName: string, module?: Module): Promise<void>;
|
|
40
|
+
export {};
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
import { importDynamic } from "@openmrs/esm-dynamic-loading";
|
|
2
|
+
import { registerModuleLoad } from "@openmrs/esm-config";
|
|
3
|
+
import { emptyLifecycle } from "./helpers.js";
|
|
4
|
+
/**
|
|
5
|
+
* @internal
|
|
6
|
+
*
|
|
7
|
+
* Used internally to track which apps have had their `startupApp()` initializer called
|
|
8
|
+
*
|
|
9
|
+
* Values are promises to support asynchronous loading of the same app multiple times
|
|
10
|
+
*/ const initializedApps = new Map();
|
|
11
|
+
/**
|
|
12
|
+
* This function creates a loader function suitable for use in either a single-spa
|
|
13
|
+
* application or parcel.
|
|
14
|
+
*
|
|
15
|
+
* The returned function is lazy and ensures that the appropriate module is loaded,
|
|
16
|
+
* that the module's `startupApp()` is called before the component is loaded. It
|
|
17
|
+
* then calls the component function, which should return either a single-spa
|
|
18
|
+
* {@link LifeCycles} object or a {@link Promise} that will resolve to such an object.
|
|
19
|
+
*
|
|
20
|
+
* React-based pages or extensions should generally use the framework's
|
|
21
|
+
* `getAsyncLifecycle()` or `getSyncLifecycle()` functions.
|
|
22
|
+
*
|
|
23
|
+
* @param routesAppName The app name of the routes.json file defining the component to load
|
|
24
|
+
*
|
|
25
|
+
* @param fullComponentName The name of the component to load. Note that this can optionally
|
|
26
|
+
* include the appName to load the component from (in the format `${appName}#${componentName}`),
|
|
27
|
+
* or omitted to implicitly use routesAppName
|
|
28
|
+
*
|
|
29
|
+
*/ export function getLoader(routesAppName, fullComponentName) {
|
|
30
|
+
return async ()=>{
|
|
31
|
+
const poundIndex = fullComponentName.indexOf('#');
|
|
32
|
+
const isNamespaced = poundIndex >= 0;
|
|
33
|
+
const appName = isNamespaced ? fullComponentName.substring(0, poundIndex) : routesAppName;
|
|
34
|
+
const componentName = isNamespaced ? fullComponentName.substring(poundIndex + 1) : fullComponentName;
|
|
35
|
+
const module = await importDynamic(appName);
|
|
36
|
+
if (module && Object.hasOwn(module, componentName) && typeof module[componentName] === 'function') {
|
|
37
|
+
return initializeApp(appName, module).then(()=>module[componentName]());
|
|
38
|
+
} else {
|
|
39
|
+
if (!module) {
|
|
40
|
+
console.warn(`Unknown app ${appName} for ${fullComponentName} defined in ${routesAppName}'s routes.json`);
|
|
41
|
+
} else if (module && Object.hasOwn(module, componentName)) {
|
|
42
|
+
console.warn(`The export ${fullComponentName}, defined in ${routesAppName}'s routes.json, is not a function`);
|
|
43
|
+
} else {
|
|
44
|
+
console.warn(`${appName} does not define a component called "${componentName}", referenced in ${routesAppName}'s routes.json. This cannot be loaded.`);
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
return emptyLifecycle;
|
|
48
|
+
};
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* This function can be used to manually initialize an application without waiting for the
|
|
52
|
+
* framework to load it. This can sometimes be helpful if the framework doesn't load code
|
|
53
|
+
* at the point you think is appropriate.
|
|
54
|
+
*
|
|
55
|
+
* This will ensure that the module is available and that it's `startupApp()` function (if
|
|
56
|
+
* any) will be called. Note that these are only guaranteed to be complete once the Promise
|
|
57
|
+
* returned from the function completes.
|
|
58
|
+
*
|
|
59
|
+
* @param appName The name of the app to initialize
|
|
60
|
+
* @param module The loaded code module, if available; if this parameter is omitted, this
|
|
61
|
+
* function will load it.
|
|
62
|
+
* @returns a Promise which completes once the app has been loaded and initialized
|
|
63
|
+
*/ export async function initializeApp(appName, module) {
|
|
64
|
+
if (!(appName in initializedApps)) {
|
|
65
|
+
let _module = module ?? await importDynamic(appName);
|
|
66
|
+
await (initializedApps[appName] = new Promise((resolve, reject)=>{
|
|
67
|
+
if (Object.hasOwn(_module, 'startupApp')) {
|
|
68
|
+
const startup = _module['startupApp'];
|
|
69
|
+
if (typeof startup === 'function') {
|
|
70
|
+
return Promise.resolve(startup()).then(()=>{
|
|
71
|
+
registerModuleLoad(appName);
|
|
72
|
+
resolve(null);
|
|
73
|
+
}).catch(reject);
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
registerModuleLoad(appName);
|
|
77
|
+
resolve(null);
|
|
78
|
+
}));
|
|
79
|
+
} else {
|
|
80
|
+
await initializedApps[appName];
|
|
81
|
+
}
|
|
82
|
+
}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { type FeatureFlagDefinition, type ExtensionDefinition, type ModalDefinition, type WorkspaceDefinition, type WorkspaceGroupDefinition } from '@openmrs/esm-globals';
|
|
2
|
+
/**
|
|
3
|
+
* This function registers an extension definition with the framework and will
|
|
4
|
+
* attach the extension to any configured slots.
|
|
5
|
+
*
|
|
6
|
+
* @param appName The name of the app containing this extension
|
|
7
|
+
* @param extension An object that describes the extension, derived from `routes.json`
|
|
8
|
+
*/
|
|
9
|
+
export declare function tryRegisterExtension(appName: string, extension: ExtensionDefinition): void;
|
|
10
|
+
/**
|
|
11
|
+
* This function registers a modal definition with the framework so that it can be launched.
|
|
12
|
+
*
|
|
13
|
+
* @param appName The name of the app defining this modal
|
|
14
|
+
* @param modal An object that describes the modal, derived from `routes.json`
|
|
15
|
+
*/
|
|
16
|
+
export declare function tryRegisterModal(appName: string, modal: ModalDefinition): void;
|
|
17
|
+
/**
|
|
18
|
+
* This function registers a workspace definition with the framework so that it can be launched.
|
|
19
|
+
*
|
|
20
|
+
* @param appName The name of the app defining this workspace
|
|
21
|
+
* @param workspace An object that describes the workspace, derived from `routes.json`
|
|
22
|
+
*/
|
|
23
|
+
export declare function tryRegisterWorkspace(appName: string, workspace: WorkspaceDefinition): void;
|
|
24
|
+
/**
|
|
25
|
+
* This function registers a workspace group definition with the framework so that it can be launched.
|
|
26
|
+
*
|
|
27
|
+
* @param appName The name of the app defining this workspace
|
|
28
|
+
* @param workspace An object that describes the workspace, derived from `routes.json`
|
|
29
|
+
*/
|
|
30
|
+
export declare function tryRegisterWorkspaceGroup(appName: string, workspaceGroup: WorkspaceGroupDefinition): void;
|
|
31
|
+
/**
|
|
32
|
+
* This function registers a feature flag definition with the framework.
|
|
33
|
+
*
|
|
34
|
+
* @param appName The name of the app defining this feature flag
|
|
35
|
+
* @param featureFlag An object that describes the feature flag, derived from `routes.json`
|
|
36
|
+
*/
|
|
37
|
+
export declare function tryRegisterFeatureFlag(appName: string, featureFlag: FeatureFlagDefinition): void;
|
|
@@ -0,0 +1,194 @@
|
|
|
1
|
+
import { attach, registerExtension, registerModal, registerWorkspace, registerWorkspaceGroup } from "@openmrs/esm-extensions";
|
|
2
|
+
import { getLoader } from "./app.js";
|
|
3
|
+
import { registerFeatureFlag } from "@openmrs/esm-feature-flags";
|
|
4
|
+
/**
|
|
5
|
+
* This function registers an extension definition with the framework and will
|
|
6
|
+
* attach the extension to any configured slots.
|
|
7
|
+
*
|
|
8
|
+
* @param appName The name of the app containing this extension
|
|
9
|
+
* @param extension An object that describes the extension, derived from `routes.json`
|
|
10
|
+
*/ export function tryRegisterExtension(appName, extension) {
|
|
11
|
+
const name = extension.name;
|
|
12
|
+
if (!name) {
|
|
13
|
+
console.error(`An extension definition in ${appName} is missing an name and thus cannot be
|
|
14
|
+
registered. To fix this, ensure that you define the "name" field inside the
|
|
15
|
+
extension definition.`, extension);
|
|
16
|
+
return;
|
|
17
|
+
}
|
|
18
|
+
if (extension.slots && extension.slot) {
|
|
19
|
+
console.warn(`The extension ${name} from ${appName} declares both a 'slots' property and
|
|
20
|
+
a 'slot' property. Only the 'slots' property will be honored.`);
|
|
21
|
+
}
|
|
22
|
+
const slots = extension.slots ? extension.slots : extension.slot ? [
|
|
23
|
+
extension.slot
|
|
24
|
+
] : [];
|
|
25
|
+
if (!extension.component && !extension.load) {
|
|
26
|
+
console.error(`The extension ${name} from ${appName} is missing a 'component' entry and thus cannot be registered.
|
|
27
|
+
To fix this, ensure that you define a 'component' field inside the extension definition.`, extension);
|
|
28
|
+
return;
|
|
29
|
+
}
|
|
30
|
+
let loader = undefined;
|
|
31
|
+
if (extension.component) {
|
|
32
|
+
loader = getLoader(appName, extension.component);
|
|
33
|
+
} else if (extension.load) {
|
|
34
|
+
if (typeof extension.load !== 'function') {
|
|
35
|
+
console.error(`The extension ${name} from ${appName} declares a 'load' property that is not a function. This is not
|
|
36
|
+
supported, so the extension will not be loaded.`);
|
|
37
|
+
return;
|
|
38
|
+
}
|
|
39
|
+
loader = extension.load;
|
|
40
|
+
}
|
|
41
|
+
if (loader) {
|
|
42
|
+
registerExtension({
|
|
43
|
+
name,
|
|
44
|
+
load: loader,
|
|
45
|
+
meta: extension.meta || {},
|
|
46
|
+
order: extension.order,
|
|
47
|
+
moduleName: appName,
|
|
48
|
+
privileges: extension.privileges,
|
|
49
|
+
online: extension.online ?? true,
|
|
50
|
+
offline: extension.offline ?? false,
|
|
51
|
+
featureFlag: extension.featureFlag
|
|
52
|
+
});
|
|
53
|
+
}
|
|
54
|
+
for (const slot of slots){
|
|
55
|
+
attach(slot, name);
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* This function registers a modal definition with the framework so that it can be launched.
|
|
60
|
+
*
|
|
61
|
+
* @param appName The name of the app defining this modal
|
|
62
|
+
* @param modal An object that describes the modal, derived from `routes.json`
|
|
63
|
+
*/ export function tryRegisterModal(appName, modal) {
|
|
64
|
+
const name = modal.name;
|
|
65
|
+
if (!name) {
|
|
66
|
+
console.error(`A modal definition in ${appName} is missing an name and thus cannot be
|
|
67
|
+
registered. To fix this, ensure that you define the "name" field inside the
|
|
68
|
+
modal definition.`, modal);
|
|
69
|
+
return;
|
|
70
|
+
}
|
|
71
|
+
if (!modal.component && !modal.load) {
|
|
72
|
+
console.error(`The modal ${name} from ${appName} is missing a 'component' entry and thus cannot be registered.
|
|
73
|
+
To fix this, ensure that you define a 'component' field inside the modal definition.`, modal);
|
|
74
|
+
return;
|
|
75
|
+
}
|
|
76
|
+
let loader = undefined;
|
|
77
|
+
if (modal.component) {
|
|
78
|
+
loader = getLoader(appName, modal.component);
|
|
79
|
+
} else if (modal.load) {
|
|
80
|
+
if (typeof modal.load !== 'function') {
|
|
81
|
+
console.error(`The modal ${name} from ${appName} declares a 'load' property that is not a function. This is not
|
|
82
|
+
supported, so the modal will not be loaded.`);
|
|
83
|
+
return;
|
|
84
|
+
}
|
|
85
|
+
loader = modal.load;
|
|
86
|
+
}
|
|
87
|
+
if (loader) {
|
|
88
|
+
registerModal({
|
|
89
|
+
name,
|
|
90
|
+
load: loader,
|
|
91
|
+
moduleName: appName
|
|
92
|
+
});
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
/**
|
|
96
|
+
* This function registers a workspace definition with the framework so that it can be launched.
|
|
97
|
+
*
|
|
98
|
+
* @param appName The name of the app defining this workspace
|
|
99
|
+
* @param workspace An object that describes the workspace, derived from `routes.json`
|
|
100
|
+
*/ export function tryRegisterWorkspace(appName, workspace) {
|
|
101
|
+
const name = workspace.name;
|
|
102
|
+
if (!name) {
|
|
103
|
+
console.error(`A workspace definition in ${appName} is missing a name and thus cannot be registered.
|
|
104
|
+
To fix this, ensure that you define the "name" field inside the workspace definition.`, workspace);
|
|
105
|
+
return;
|
|
106
|
+
}
|
|
107
|
+
const title = workspace.title;
|
|
108
|
+
if (!title) {
|
|
109
|
+
console.error(`A workspace definition in ${appName} is missing a title and thus cannot be registered.
|
|
110
|
+
To fix this, ensure that you define the "title" field inside the workspace definition.`, workspace);
|
|
111
|
+
return;
|
|
112
|
+
}
|
|
113
|
+
if (!workspace.component && !workspace.load) {
|
|
114
|
+
console.error(`The workspace ${name} from ${appName} is missing a 'component' entry and thus cannot be registered.
|
|
115
|
+
To fix this, ensure that you define a 'component' field inside the workspace definition.`, workspace);
|
|
116
|
+
return;
|
|
117
|
+
}
|
|
118
|
+
let loader = undefined;
|
|
119
|
+
if (workspace.component) {
|
|
120
|
+
loader = getLoader(appName, workspace.component);
|
|
121
|
+
} else if (workspace.load) {
|
|
122
|
+
if (typeof workspace.load !== 'function') {
|
|
123
|
+
console.error(`The workspace ${name} from ${appName} declares a 'load' property that is not a function. This is not
|
|
124
|
+
supported, so the workspace will not be loaded.`);
|
|
125
|
+
return;
|
|
126
|
+
}
|
|
127
|
+
loader = workspace.load;
|
|
128
|
+
}
|
|
129
|
+
if (loader) {
|
|
130
|
+
registerWorkspace({
|
|
131
|
+
name,
|
|
132
|
+
title,
|
|
133
|
+
load: loader,
|
|
134
|
+
moduleName: appName,
|
|
135
|
+
type: workspace.type,
|
|
136
|
+
canHide: workspace.canHide,
|
|
137
|
+
canMaximize: workspace.canMaximize,
|
|
138
|
+
width: workspace.width,
|
|
139
|
+
preferredWindowSize: workspace.preferredWindowSize,
|
|
140
|
+
groups: workspace.groups
|
|
141
|
+
});
|
|
142
|
+
}
|
|
143
|
+
for (const group of workspace.groups || []){
|
|
144
|
+
registerWorkspaceGroup({
|
|
145
|
+
name: group,
|
|
146
|
+
members: [
|
|
147
|
+
name
|
|
148
|
+
]
|
|
149
|
+
});
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
/**
|
|
153
|
+
* This function registers a workspace group definition with the framework so that it can be launched.
|
|
154
|
+
*
|
|
155
|
+
* @param appName The name of the app defining this workspace
|
|
156
|
+
* @param workspace An object that describes the workspace, derived from `routes.json`
|
|
157
|
+
*/ export function tryRegisterWorkspaceGroup(appName, workspaceGroup) {
|
|
158
|
+
const name = workspaceGroup.name;
|
|
159
|
+
if (!name) {
|
|
160
|
+
console.error(`A workspace group definition in ${appName} is missing a name and thus cannot be registered.
|
|
161
|
+
To fix this, ensure that you define the "name" field inside the workspace definition.`, workspaceGroup);
|
|
162
|
+
return;
|
|
163
|
+
}
|
|
164
|
+
registerWorkspaceGroup({
|
|
165
|
+
name,
|
|
166
|
+
members: workspaceGroup.members ?? []
|
|
167
|
+
});
|
|
168
|
+
}
|
|
169
|
+
/**
|
|
170
|
+
* This function registers a feature flag definition with the framework.
|
|
171
|
+
*
|
|
172
|
+
* @param appName The name of the app defining this feature flag
|
|
173
|
+
* @param featureFlag An object that describes the feature flag, derived from `routes.json`
|
|
174
|
+
*/ export function tryRegisterFeatureFlag(appName, featureFlag) {
|
|
175
|
+
const name = featureFlag.flagName;
|
|
176
|
+
if (!name) {
|
|
177
|
+
console.error(`A feature flag definition in ${appName} is missing a name and thus cannot be registered.
|
|
178
|
+
To fix this, ensure that you define the "name" field inside the feature flag definition.`, featureFlag);
|
|
179
|
+
return;
|
|
180
|
+
}
|
|
181
|
+
const label = featureFlag.label;
|
|
182
|
+
if (!label) {
|
|
183
|
+
console.error(`A feature flag definition in ${appName} is missing a description and thus cannot be registered.
|
|
184
|
+
To fix this, ensure that you define the "label" field inside the feature flag definition.`, featureFlag);
|
|
185
|
+
return;
|
|
186
|
+
}
|
|
187
|
+
const description = featureFlag.description;
|
|
188
|
+
if (!description) {
|
|
189
|
+
console.error(`A feature flag definition in ${appName} is missing a description and thus cannot be registered.
|
|
190
|
+
To fix this, ensure that you define the "description" field inside the feature flag definition.`, featureFlag);
|
|
191
|
+
return;
|
|
192
|
+
}
|
|
193
|
+
registerFeatureFlag(featureFlag.flagName, featureFlag.label, featureFlag.description);
|
|
194
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
export const emptyLifecycle = {
|
|
2
|
+
bootstrap () {
|
|
3
|
+
return Promise.resolve();
|
|
4
|
+
},
|
|
5
|
+
mount () {
|
|
6
|
+
return Promise.resolve();
|
|
7
|
+
},
|
|
8
|
+
unmount () {
|
|
9
|
+
return Promise.resolve();
|
|
10
|
+
}
|
|
11
|
+
};
|
|
12
|
+
export function routeRegex(regex, location) {
|
|
13
|
+
const result = regex.test(location.pathname.replace(window.getOpenmrsSpaBase(), ''));
|
|
14
|
+
return result;
|
|
15
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { type OpenmrsAppRoutes } from '@openmrs/esm-globals';
|
|
2
|
+
/**
|
|
3
|
+
* This is the main entry-point for registering an app with the app shell.
|
|
4
|
+
* Each app has a name and should have a `routes.json` file that defines it's
|
|
5
|
+
* associated routes.
|
|
6
|
+
*
|
|
7
|
+
* @param appName The name of the application, e.g. `@openmrs/esm-my-app`
|
|
8
|
+
* @param routes A Javascript object that corresponds to the app's routes.json`
|
|
9
|
+
* definition.
|
|
10
|
+
*/
|
|
11
|
+
export declare function registerApp(appName: string, routes: OpenmrsAppRoutes): void;
|
|
12
|
+
/**
|
|
13
|
+
* This is called by the app shell once all route entries have been processed.
|
|
14
|
+
* This actually registers the pages with the application. This function is
|
|
15
|
+
* necessary to ensure that pages are rendered in the DOM according to their
|
|
16
|
+
* order definition, especially because certain pages _must_ be first in the DOM.
|
|
17
|
+
*
|
|
18
|
+
* Each page is rendered into a div with an appropriate name.
|
|
19
|
+
*/
|
|
20
|
+
export declare function finishRegisteringAllApps(): void;
|
|
@@ -0,0 +1,179 @@
|
|
|
1
|
+
import { pathToActiveWhen, registerApplication } from "single-spa";
|
|
2
|
+
import { registerModuleWithConfigSystem } from "@openmrs/esm-config";
|
|
3
|
+
import { getFeatureFlag } from "@openmrs/esm-feature-flags";
|
|
4
|
+
import { routeRegex } from "./helpers.js";
|
|
5
|
+
import { getLoader } from "./app.js";
|
|
6
|
+
import { tryRegisterExtension, tryRegisterFeatureFlag, tryRegisterModal, tryRegisterWorkspace, tryRegisterWorkspaceGroup } from "./components.js";
|
|
7
|
+
// this is the global holder of all pages registered in the app
|
|
8
|
+
const pages = [];
|
|
9
|
+
/**
|
|
10
|
+
* This takes a page's route definitions and returns a single-spa
|
|
11
|
+
* activityFn which returns true when the page matches the current
|
|
12
|
+
* route and false if it does not.
|
|
13
|
+
*
|
|
14
|
+
* @param route A string or regexp that matches the location when the
|
|
15
|
+
* page should be displayed, a boolean constant, or an array of such
|
|
16
|
+
* strings, regexps, and booleans
|
|
17
|
+
* @returns An activityFn suitable to use for a single-spa application
|
|
18
|
+
*/ function getActivityFn(route) {
|
|
19
|
+
if (Array.isArray(route)) {
|
|
20
|
+
const activators = route.map(getActivityFn);
|
|
21
|
+
return (location)=>activators.some((activator)=>activator(location));
|
|
22
|
+
} else if (typeof route === 'string') {
|
|
23
|
+
return pathToActiveWhen(window.getOpenmrsSpaBase() + route);
|
|
24
|
+
} else if (route instanceof RegExp) {
|
|
25
|
+
return (location)=>routeRegex(route, location);
|
|
26
|
+
} else {
|
|
27
|
+
return ()=>route;
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* For pages, we also add support for rendered them based on online and offline mode as well as
|
|
32
|
+
* any feature flags.
|
|
33
|
+
*
|
|
34
|
+
* By default, we assume that all pages should be rendered when online, but only rendered
|
|
35
|
+
* offline if specifically configured to do so.
|
|
36
|
+
*
|
|
37
|
+
* @param activityFn A standard single-spa activityFn such as that returned by {@link getActivityFn()}
|
|
38
|
+
* @param pageDefinition The RegisteredPageDefinition object for this page
|
|
39
|
+
* @returns An activityFn suitable to use for a single-spa application
|
|
40
|
+
*/ function wrapPageActivityFn(activityFn, { online, offline, featureFlag }) {
|
|
41
|
+
if (window.offlineEnabled) {
|
|
42
|
+
return (location)=>{
|
|
43
|
+
// basically, if the page should only work online and we're offline or if the
|
|
44
|
+
// page should only work offline and we're online, defaulting to always rendering
|
|
45
|
+
// the page
|
|
46
|
+
if (!(navigator.onLine && (online ?? true) || !navigator.onLine && (offline ?? false))) {
|
|
47
|
+
return false;
|
|
48
|
+
}
|
|
49
|
+
if (featureFlag) {
|
|
50
|
+
if (!getFeatureFlag(featureFlag)) {
|
|
51
|
+
return false;
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
return activityFn(location);
|
|
55
|
+
};
|
|
56
|
+
} else {
|
|
57
|
+
return activityFn;
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* This is the main entry-point for registering an app with the app shell.
|
|
62
|
+
* Each app has a name and should have a `routes.json` file that defines it's
|
|
63
|
+
* associated routes.
|
|
64
|
+
*
|
|
65
|
+
* @param appName The name of the application, e.g. `@openmrs/esm-my-app`
|
|
66
|
+
* @param routes A Javascript object that corresponds to the app's routes.json`
|
|
67
|
+
* definition.
|
|
68
|
+
*/ export function registerApp(appName, routes) {
|
|
69
|
+
if (appName && routes && typeof routes === 'object') {
|
|
70
|
+
registerModuleWithConfigSystem(appName);
|
|
71
|
+
const availableExtensions = routes.extensions ?? [];
|
|
72
|
+
const availableModals = routes.modals ?? [];
|
|
73
|
+
const availableWorkspaces = routes.workspaces ?? [];
|
|
74
|
+
const availableWorkspaceGroups = routes.workspaceGroups ?? [];
|
|
75
|
+
const availableFeatureFlags = routes.featureFlags ?? [];
|
|
76
|
+
routes.pages?.forEach((p)=>{
|
|
77
|
+
if (p && typeof p === 'object' && Object.hasOwn(p, 'component') && (Object.hasOwn(p, 'route') || Object.hasOwn(p, 'routeRegex') || Object.hasOwn(p, 'routes'))) {
|
|
78
|
+
pages.push({
|
|
79
|
+
...p,
|
|
80
|
+
order: p.order ?? Number.MAX_SAFE_INTEGER,
|
|
81
|
+
appName
|
|
82
|
+
});
|
|
83
|
+
} else {
|
|
84
|
+
console.warn(`A page for ${appName} could not be registered as it does not appear to have the required properties`, p);
|
|
85
|
+
}
|
|
86
|
+
});
|
|
87
|
+
availableExtensions.forEach((ext)=>{
|
|
88
|
+
if (ext && typeof ext === 'object' && Object.hasOwn(ext, 'name') && Object.hasOwn(ext, 'component')) {
|
|
89
|
+
tryRegisterExtension(appName, ext);
|
|
90
|
+
} else {
|
|
91
|
+
console.warn(`An extension for ${appName} could not be registered as it does not appear to have the required properties`, ext);
|
|
92
|
+
}
|
|
93
|
+
});
|
|
94
|
+
availableModals.forEach((modal)=>{
|
|
95
|
+
if (modal && typeof modal === 'object' && Object.hasOwn(modal, 'name') && Object.hasOwn(modal, 'component')) {
|
|
96
|
+
tryRegisterModal(appName, modal);
|
|
97
|
+
} else {
|
|
98
|
+
console.warn(`A modal for ${appName} could not be registered as it does not appear to have the required properties`, modal);
|
|
99
|
+
}
|
|
100
|
+
});
|
|
101
|
+
availableWorkspaces.forEach((workspace)=>{
|
|
102
|
+
if (workspace && typeof workspace === 'object' && Object.hasOwn(workspace, 'name') && Object.hasOwn(workspace, 'component')) {
|
|
103
|
+
tryRegisterWorkspace(appName, workspace);
|
|
104
|
+
} else {
|
|
105
|
+
console.warn(`A workspace for ${appName} could not be registered as it does not appear to have the required properties`, workspace);
|
|
106
|
+
}
|
|
107
|
+
});
|
|
108
|
+
availableWorkspaceGroups.forEach((workspaceGroup)=>{
|
|
109
|
+
if (workspaceGroup && typeof workspaceGroup === 'object' && Object.hasOwn(workspaceGroup, 'name')) {
|
|
110
|
+
tryRegisterWorkspaceGroup(appName, workspaceGroup);
|
|
111
|
+
} else {
|
|
112
|
+
console.warn(`A workspace group for ${appName} could not be registered as it does not appear to have the required properties`, workspaceGroup);
|
|
113
|
+
}
|
|
114
|
+
});
|
|
115
|
+
availableFeatureFlags.forEach((featureFlag)=>{
|
|
116
|
+
if (featureFlag && typeof featureFlag === 'object' && Object.hasOwn(featureFlag, 'flagName')) {
|
|
117
|
+
tryRegisterFeatureFlag(appName, featureFlag);
|
|
118
|
+
} else {
|
|
119
|
+
console.warn(`A feature flag for ${appName} could not be registered as it does not appear to have the required properties`, featureFlag);
|
|
120
|
+
}
|
|
121
|
+
});
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
/**
|
|
125
|
+
* This is called by the app shell once all route entries have been processed.
|
|
126
|
+
* This actually registers the pages with the application. This function is
|
|
127
|
+
* necessary to ensure that pages are rendered in the DOM according to their
|
|
128
|
+
* order definition, especially because certain pages _must_ be first in the DOM.
|
|
129
|
+
*
|
|
130
|
+
* Each page is rendered into a div with an appropriate name.
|
|
131
|
+
*/ export function finishRegisteringAllApps() {
|
|
132
|
+
pages.sort((a, b)=>{
|
|
133
|
+
let sort = a.order - b.order;
|
|
134
|
+
if (sort != 0) {
|
|
135
|
+
return sort;
|
|
136
|
+
}
|
|
137
|
+
return a.appName.localeCompare(b.appName, 'en');
|
|
138
|
+
});
|
|
139
|
+
// Create a div for each page. This ensures their DOM order.
|
|
140
|
+
// If we don't do this, Single-SPA 5 will create the DOM element only once
|
|
141
|
+
// the page becomes active, which makes it impossible to guarantee order.
|
|
142
|
+
let appIndices = new Map();
|
|
143
|
+
for (let page of pages){
|
|
144
|
+
if (!appIndices.has(page.appName)) {
|
|
145
|
+
appIndices.set(page.appName, 0);
|
|
146
|
+
} else {
|
|
147
|
+
appIndices.set(page.appName, appIndices.get(page.appName) + 1);
|
|
148
|
+
}
|
|
149
|
+
const index = appIndices.get(page.appName);
|
|
150
|
+
const name = `${page.appName}-page-${index}`;
|
|
151
|
+
const div = document.createElement('div');
|
|
152
|
+
div.id = `single-spa-application:${name}`;
|
|
153
|
+
document.body.appendChild(div);
|
|
154
|
+
tryRegisterPage(name, page);
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
/**
|
|
158
|
+
* This function converts each page definition into a single-spa application
|
|
159
|
+
* if that's possible. After this point, pages are rendered using single-spa's
|
|
160
|
+
* routing logic.
|
|
161
|
+
*
|
|
162
|
+
* @param appName The name of the app containing this page
|
|
163
|
+
* @param page An object that describes the page, derived from `routes.json`
|
|
164
|
+
*/ function tryRegisterPage(appName, page) {
|
|
165
|
+
const route = typeof page.route !== 'undefined' ? page.route : typeof page.routeRegex !== 'undefined' ? new RegExp(page.routeRegex) : false;
|
|
166
|
+
if (route === false) {
|
|
167
|
+
console.warn(`A registered page definition is missing a route and thus cannot be registered.
|
|
168
|
+
To fix this, ensure that you define the "route" (or alternatively the "routeRegex") field inside the extension definition.`, appName);
|
|
169
|
+
return;
|
|
170
|
+
}
|
|
171
|
+
if (!page.component) {
|
|
172
|
+
console.warn(`A registered page definition is missing a component and thus cannot be registered.
|
|
173
|
+
To fix this, ensure that you define the "component" field inside the page definition.`, appName);
|
|
174
|
+
return;
|
|
175
|
+
}
|
|
176
|
+
const activityFn = wrapPageActivityFn(getActivityFn(route), page);
|
|
177
|
+
const loader = getLoader(page.appName, page.component);
|
|
178
|
+
registerApplication(appName, loader, activityFn);
|
|
179
|
+
}
|
package/dist/public.d.ts
ADDED
package/dist/public.js
ADDED
package/dist/routes.d.ts
ADDED
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
/** @module @category Routes Utilities */
|
|
2
|
+
import type { OpenmrsAppRoutes, OpenmrsRoutes } from '@openmrs/esm-globals';
|
|
3
|
+
/**
|
|
4
|
+
* Used to add a route override to local storage. These are read as the routes registry
|
|
5
|
+
* is assembled, so the app must be reloaded for new overrides to take effect.
|
|
6
|
+
*
|
|
7
|
+
* @internal
|
|
8
|
+
* @param moduleName The name of the module the routes are for
|
|
9
|
+
* @param routes Either an {@link OpenmrsAppRoutes} object, a string that represents a JSON
|
|
10
|
+
* version of an {@link OpenmrsAppRoutes} object or a string or URL that resolves to a
|
|
11
|
+
* JSON document that represents an {@link OpenmrsAppRoutes} object
|
|
12
|
+
*/
|
|
13
|
+
export declare function addRoutesOverride(moduleName: string, routes: OpenmrsAppRoutes | string | URL): void;
|
|
14
|
+
/**
|
|
15
|
+
* Used to remove an existing routes override from local storage. These are read as the routes registry
|
|
16
|
+
* is assembled, so the app must be reloaded for removed override to be removed.
|
|
17
|
+
*
|
|
18
|
+
* @internal
|
|
19
|
+
* @param moduleName The module to remove the overrides for
|
|
20
|
+
*/
|
|
21
|
+
export declare function removeRoutesOverride(moduleName: string): void;
|
|
22
|
+
/**
|
|
23
|
+
* Used to remove all existing routes overrides from local storage. These are read as the routes registry
|
|
24
|
+
* is assembled, so the app must be reloaded for the removed overrides to appear to be removed.
|
|
25
|
+
*
|
|
26
|
+
* @internal
|
|
27
|
+
*/
|
|
28
|
+
export declare function resetAllRoutesOverrides(): void;
|
|
29
|
+
/**
|
|
30
|
+
* Simple type-predicate to ensure that the value can be treated as an OpenmrsAppRoutes
|
|
31
|
+
* object.
|
|
32
|
+
*
|
|
33
|
+
* @internal
|
|
34
|
+
* @param routes the object to check to see if it is an OpenmrsAppRoutes object
|
|
35
|
+
* @returns true if the routes value is an OpenmrsAppRoutes
|
|
36
|
+
*/
|
|
37
|
+
export declare function isOpenmrsAppRoutes(routes: OpenmrsAppRoutes | unknown): routes is OpenmrsAppRoutes;
|
|
38
|
+
/**
|
|
39
|
+
* Simple type-predicate to ensure that the value can be treated as an OpenmrsRoutes
|
|
40
|
+
* object.
|
|
41
|
+
*
|
|
42
|
+
* @internal
|
|
43
|
+
* @param routes the object to check to see if it is an OpenmrsRoutes object
|
|
44
|
+
* @returns true if the routes value is an OpenmrsRoutes
|
|
45
|
+
*/
|
|
46
|
+
export declare function isOpenmrsRoutes(routes: OpenmrsRoutes | unknown): routes is OpenmrsRoutes;
|
package/dist/routes.js
ADDED
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
/** @module @category Routes Utilities */ import { canAccessStorage } from "@openmrs/esm-utils";
|
|
2
|
+
import { localStorageRoutesPrefix } from "./constants.js";
|
|
3
|
+
const isEnabled = canAccessStorage();
|
|
4
|
+
/**
|
|
5
|
+
* Used to add a route override to local storage. These are read as the routes registry
|
|
6
|
+
* is assembled, so the app must be reloaded for new overrides to take effect.
|
|
7
|
+
*
|
|
8
|
+
* @internal
|
|
9
|
+
* @param moduleName The name of the module the routes are for
|
|
10
|
+
* @param routes Either an {@link OpenmrsAppRoutes} object, a string that represents a JSON
|
|
11
|
+
* version of an {@link OpenmrsAppRoutes} object or a string or URL that resolves to a
|
|
12
|
+
* JSON document that represents an {@link OpenmrsAppRoutes} object
|
|
13
|
+
*/ export function addRoutesOverride(moduleName, routes) {
|
|
14
|
+
if (!isEnabled) {
|
|
15
|
+
return;
|
|
16
|
+
}
|
|
17
|
+
if (typeof routes === 'string') {
|
|
18
|
+
if (routes.startsWith('http')) {
|
|
19
|
+
return addRouteOverrideInternal(moduleName, routes);
|
|
20
|
+
} else {
|
|
21
|
+
try {
|
|
22
|
+
const maybeRoutes = JSON.parse(routes);
|
|
23
|
+
if (isOpenmrsAppRoutes(maybeRoutes)) {
|
|
24
|
+
return addRouteOverrideInternal(moduleName, maybeRoutes);
|
|
25
|
+
} else {
|
|
26
|
+
console.error(`The supplied routes for ${moduleName} is not a valid OpenmrsAppRoutes object`, routes);
|
|
27
|
+
}
|
|
28
|
+
} catch (e) {
|
|
29
|
+
console.error(`Could not add routes override for ${moduleName}: `, e);
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
} else if (routes instanceof URL) {
|
|
33
|
+
return addRouteOverrideInternal(moduleName, routes.toString());
|
|
34
|
+
} else if (isOpenmrsAppRoutes(routes)) {
|
|
35
|
+
return addRouteOverrideInternal(moduleName, routes);
|
|
36
|
+
}
|
|
37
|
+
console.error(`Override for ${moduleName} is not in a valid format. Expected either a Javascript Object, a JSON string of a Javascript object, or a URL`, routes);
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* Used to remove an existing routes override from local storage. These are read as the routes registry
|
|
41
|
+
* is assembled, so the app must be reloaded for removed override to be removed.
|
|
42
|
+
*
|
|
43
|
+
* @internal
|
|
44
|
+
* @param moduleName The module to remove the overrides for
|
|
45
|
+
*/ export function removeRoutesOverride(moduleName) {
|
|
46
|
+
if (!isEnabled) {
|
|
47
|
+
return;
|
|
48
|
+
}
|
|
49
|
+
const key = localStorageRoutesPrefix + moduleName;
|
|
50
|
+
localStorage.removeItem(key);
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* Used to remove all existing routes overrides from local storage. These are read as the routes registry
|
|
54
|
+
* is assembled, so the app must be reloaded for the removed overrides to appear to be removed.
|
|
55
|
+
*
|
|
56
|
+
* @internal
|
|
57
|
+
*/ export function resetAllRoutesOverrides() {
|
|
58
|
+
if (!isEnabled) {
|
|
59
|
+
return;
|
|
60
|
+
}
|
|
61
|
+
const localStorage1 = window.localStorage;
|
|
62
|
+
for(let i = 0; i < localStorage1.length; i++){
|
|
63
|
+
const key = localStorage1.key(i);
|
|
64
|
+
if (key?.startsWith(localStorageRoutesPrefix)) {
|
|
65
|
+
localStorage1.removeItem(key);
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
function addRouteOverrideInternal(moduleName, routes) {
|
|
70
|
+
const key = localStorageRoutesPrefix + moduleName;
|
|
71
|
+
localStorage.setItem(key, JSON.stringify(routes));
|
|
72
|
+
}
|
|
73
|
+
/**
|
|
74
|
+
* Simple type-predicate to ensure that the value can be treated as an OpenmrsAppRoutes
|
|
75
|
+
* object.
|
|
76
|
+
*
|
|
77
|
+
* @internal
|
|
78
|
+
* @param routes the object to check to see if it is an OpenmrsAppRoutes object
|
|
79
|
+
* @returns true if the routes value is an OpenmrsAppRoutes
|
|
80
|
+
*/ export function isOpenmrsAppRoutes(routes) {
|
|
81
|
+
if (routes && typeof routes === 'object') {
|
|
82
|
+
const hasOwnProperty = Object.prototype.hasOwnProperty;
|
|
83
|
+
// we cast maybeRoutes as OpenmrsAppRoutes mainly so we can refer to the properties it should
|
|
84
|
+
// have without repeated casts
|
|
85
|
+
const maybeRoutes = routes;
|
|
86
|
+
if (hasOwnProperty.call(routes, 'pages')) {
|
|
87
|
+
if (!Boolean(maybeRoutes.pages) || !Array.isArray(maybeRoutes.pages)) {
|
|
88
|
+
return false;
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
if (hasOwnProperty.call(routes, 'extensions')) {
|
|
92
|
+
if (!Boolean(maybeRoutes.extensions) || !Array.isArray(maybeRoutes.extensions)) {
|
|
93
|
+
return false;
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
if (hasOwnProperty.call(routes, 'workspaces')) {
|
|
97
|
+
if (!Boolean(maybeRoutes.workspaces) || !Array.isArray(maybeRoutes.workspaces)) {
|
|
98
|
+
return false;
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
if (hasOwnProperty.call(routes, 'modals')) {
|
|
102
|
+
if (!Boolean(maybeRoutes.modals) || !Array.isArray(maybeRoutes.modals)) {
|
|
103
|
+
return false;
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
// Notice that we're essentially testing for things that cannot be treated as an OpenmrsAppRoutes
|
|
107
|
+
// object. This is because a completely empty object is a valid OpenmrsAppRoutes object.
|
|
108
|
+
return true;
|
|
109
|
+
}
|
|
110
|
+
return false;
|
|
111
|
+
}
|
|
112
|
+
/**
|
|
113
|
+
* Simple type-predicate to ensure that the value can be treated as an OpenmrsRoutes
|
|
114
|
+
* object.
|
|
115
|
+
*
|
|
116
|
+
* @internal
|
|
117
|
+
* @param routes the object to check to see if it is an OpenmrsRoutes object
|
|
118
|
+
* @returns true if the routes value is an OpenmrsRoutes
|
|
119
|
+
*/ export function isOpenmrsRoutes(routes) {
|
|
120
|
+
if (routes && typeof routes === 'object') {
|
|
121
|
+
const maybeRoutes = routes;
|
|
122
|
+
return Object.entries(maybeRoutes).every(([key, value])=>typeof key === 'string' && isOpenmrsAppRoutes(value));
|
|
123
|
+
}
|
|
124
|
+
return false;
|
|
125
|
+
}
|
package/package.json
CHANGED
|
@@ -1,19 +1,25 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@openmrs/esm-routes",
|
|
3
|
-
"version": "6.3.1-pre.
|
|
3
|
+
"version": "6.3.1-pre.2986",
|
|
4
4
|
"license": "MPL-2.0",
|
|
5
5
|
"description": "Utilities for working with the routes registry",
|
|
6
|
-
"
|
|
7
|
-
"
|
|
6
|
+
"type": "module",
|
|
7
|
+
"module": "dist/index.js",
|
|
8
|
+
"types": "dist/index.d.ts",
|
|
9
|
+
"exports": {
|
|
10
|
+
".": {
|
|
11
|
+
"types": "./src/index.ts",
|
|
12
|
+
"default": "./dist/index.js"
|
|
13
|
+
}
|
|
14
|
+
},
|
|
8
15
|
"source": true,
|
|
9
16
|
"sideEffects": false,
|
|
10
17
|
"scripts": {
|
|
11
|
-
"test": "cross-env TZ=UTC
|
|
12
|
-
"test:watch": "cross-env TZ=UTC
|
|
13
|
-
"build": "
|
|
14
|
-
"build:development": "
|
|
15
|
-
"
|
|
16
|
-
"typescript": "tsc",
|
|
18
|
+
"test": "cross-env TZ=UTC vitest run --passWithNoTests",
|
|
19
|
+
"test:watch": "cross-env TZ=UTC vitest watch --passWithNoTests",
|
|
20
|
+
"build": "rimraf dist && concurrently \"swc --strip-leading-paths src -d dist\" \"tsc --project tsconfig.build.json\"",
|
|
21
|
+
"build:development": "rimraf dist && concurrently \"swc --strip-leading-paths src -d dist\" \"tsc --project tsconfig.build.json\"",
|
|
22
|
+
"typescript": "tsc --project tsconfig.build.json",
|
|
17
23
|
"lint": "eslint src --ext ts,tsx"
|
|
18
24
|
},
|
|
19
25
|
"keywords": [
|
|
@@ -48,14 +54,21 @@
|
|
|
48
54
|
"single-spa": "6.x"
|
|
49
55
|
},
|
|
50
56
|
"devDependencies": {
|
|
51
|
-
"@openmrs/esm-config": "6.3.1-pre.
|
|
52
|
-
"@openmrs/esm-dynamic-loading": "6.3.1-pre.
|
|
53
|
-
"@openmrs/esm-extensions": "6.3.1-pre.
|
|
54
|
-
"@openmrs/esm-feature-flags": "6.3.1-pre.
|
|
55
|
-
"@openmrs/esm-globals": "6.3.1-pre.
|
|
56
|
-
"@openmrs/esm-utils": "6.3.1-pre.
|
|
57
|
-
"
|
|
58
|
-
"
|
|
57
|
+
"@openmrs/esm-config": "6.3.1-pre.2986",
|
|
58
|
+
"@openmrs/esm-dynamic-loading": "6.3.1-pre.2986",
|
|
59
|
+
"@openmrs/esm-extensions": "6.3.1-pre.2986",
|
|
60
|
+
"@openmrs/esm-feature-flags": "6.3.1-pre.2986",
|
|
61
|
+
"@openmrs/esm-globals": "6.3.1-pre.2986",
|
|
62
|
+
"@openmrs/esm-utils": "6.3.1-pre.2986",
|
|
63
|
+
"@swc/cli": "^0.7.7",
|
|
64
|
+
"@swc/core": "^1.11.29",
|
|
65
|
+
"concurrently": "^9.1.2",
|
|
66
|
+
"cross-env": "^7.0.3",
|
|
67
|
+
"happy-dom": "^17.4.7",
|
|
68
|
+
"rimraf": "^6.0.1",
|
|
69
|
+
"single-spa": "^6.0.3",
|
|
70
|
+
"vitest": "^3.1.4",
|
|
71
|
+
"vitest-fetch-mock": "^0.4.5"
|
|
59
72
|
},
|
|
60
73
|
"stableVersion": "6.3.0"
|
|
61
74
|
}
|
package/src/routes.test.ts
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
1
|
+
import createFetchMock from 'vitest-fetch-mock';
|
|
2
|
+
import { beforeEach, describe, expect, it, vi } from 'vitest';
|
|
3
|
+
|
|
4
|
+
createFetchMock(vi).enableMocks();
|
|
3
5
|
|
|
4
6
|
import { addRoutesOverride, isOpenmrsAppRoutes } from './routes';
|
|
5
7
|
|
package/tsconfig.json
CHANGED
|
@@ -1,25 +1,5 @@
|
|
|
1
1
|
{
|
|
2
|
-
"
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
"target": "es2015",
|
|
6
|
-
"allowSyntheticDefaultImports": true,
|
|
7
|
-
"jsx": "react",
|
|
8
|
-
"strictNullChecks": true,
|
|
9
|
-
"moduleResolution": "node",
|
|
10
|
-
"declaration": true,
|
|
11
|
-
"declarationDir": "dist",
|
|
12
|
-
"emitDeclarationOnly": true,
|
|
13
|
-
"lib": [
|
|
14
|
-
"dom",
|
|
15
|
-
"es5",
|
|
16
|
-
"scripthost",
|
|
17
|
-
"es2015",
|
|
18
|
-
"es2015.promise",
|
|
19
|
-
"es2016.array.include",
|
|
20
|
-
"es2018",
|
|
21
|
-
"esnext"
|
|
22
|
-
]
|
|
23
|
-
},
|
|
24
|
-
"include": ["src/**/*"]
|
|
2
|
+
"$schema": "https://json.schemastore.org/tsconfig.json",
|
|
3
|
+
"extends": "../tsconfig.json",
|
|
4
|
+
"include": ["src/**/*.ts*"]
|
|
25
5
|
}
|
package/vitest.config.ts
ADDED
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
System.register(["@openmrs/esm-dynamic-loading","@openmrs/esm-config","single-spa","@openmrs/esm-feature-flags","@openmrs/esm-extensions","@openmrs/esm-utils"],(function(e,n){var t={},o={},r={},i={},a={},s={};return{setters:[function(e){t.importDynamic=e.importDynamic},function(e){o.registerModuleLoad=e.registerModuleLoad,o.registerModuleWithConfigSystem=e.registerModuleWithConfigSystem},function(e){r.pathToActiveWhen=e.pathToActiveWhen,r.registerApplication=e.registerApplication},function(e){i.getFeatureFlag=e.getFeatureFlag,i.registerFeatureFlag=e.registerFeatureFlag},function(e){a.attach=e.attach,a.registerExtension=e.registerExtension,a.registerModal=e.registerModal,a.registerWorkspace=e.registerWorkspace,a.registerWorkspaceGroup=e.registerWorkspaceGroup},function(e){s.canAccessStorage=e.canAccessStorage}],execute:function(){e((()=>{"use strict";var e={824:e=>{e.exports=o},758:e=>{e.exports=t},45:e=>{e.exports=a},708:e=>{e.exports=i},618:e=>{e.exports=s},645:e=>{e.exports=r}},n={};function c(t){var o=n[t];if(void 0!==o)return o.exports;var r=n[t]={exports:{}};return e[t](r,r.exports,c),r.exports}c.d=(e,n)=>{for(var t in n)c.o(n,t)&&!c.o(e,t)&&Object.defineProperty(e,t,{enumerable:!0,get:n[t]})},c.o=(e,n)=>Object.prototype.hasOwnProperty.call(e,n),c.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})};var l={};return(()=>{c.r(l),c.d(l,{addRoutesOverride:()=>S,finishRegisteringAllApps:()=>O,initializeApp:()=>f,isOpenmrsAppRoutes:()=>E,isOpenmrsRoutes:()=>N,localStorageRoutesPrefix:()=>e,registerApp:()=>w,removeRoutesOverride:()=>T,resetAllRoutesOverrides:()=>k,tryRegisterExtension:()=>g});var e="openmrs-routes:",n=c(758),t=c(824),o={bootstrap:function(){return Promise.resolve()},mount:function(){return Promise.resolve()},unmount:function(){return Promise.resolve()}};function r(e,n,t,o,r,i,a){try{var s=e[i](a),c=s.value}catch(e){return void t(e)}s.done?n(c):Promise.resolve(c).then(o,r)}function i(e){return function(){var n=this,t=arguments;return new Promise((function(o,i){var a=e.apply(n,t);function s(e){r(a,o,i,s,c,"next",e)}function c(e){r(a,o,i,s,c,"throw",e)}s(void 0)}))}}function a(e,n){var t,o,r,i,a={label:0,sent:function(){if(1&r[0])throw r[1];return r[1]},trys:[],ops:[]};return i={next:s(0),throw:s(1),return:s(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function s(i){return function(s){return function(i){if(t)throw new TypeError("Generator is already executing.");for(;a;)try{if(t=1,o&&(r=2&i[0]?o.return:i[0]?o.throw||((r=o.return)&&r.call(o),0):o.next)&&!(r=r.call(o,i[1])).done)return r;switch(o=0,r&&(i=[2&i[0],r.value]),i[0]){case 0:case 1:r=i;break;case 4:return a.label++,{value:i[1],done:!1};case 5:a.label++,o=i[1],i=[0];continue;case 7:i=a.ops.pop(),a.trys.pop();continue;default:if(!((r=(r=a.trys).length>0&&r[r.length-1])||6!==i[0]&&2!==i[0])){a=0;continue}if(3===i[0]&&(!r||i[1]>r[0]&&i[1]<r[3])){a.label=i[1];break}if(6===i[0]&&a.label<r[1]){a.label=r[1],r=i;break}if(r&&a.label<r[2]){a.label=r[2],a.ops.push(i);break}r[2]&&a.ops.pop(),a.trys.pop();continue}i=n.call(e,a)}catch(e){i=[6,e],o=0}finally{t=r=0}if(5&i[0])throw i[1];return{value:i[0]?i[1]:void 0,done:!0}}([i,s])}}}var s=new Map;function u(e,t){return i((function(){var r,i,s,c,l;return a(this,(function(a){switch(a.label){case 0:return r=t.indexOf("#"),s=(i=r>=0)?t.substring(0,r):e,c=i?t.substring(r+1):t,[4,(0,n.importDynamic)(s)];case 1:return(l=a.sent())&&Object.hasOwn(l,c)&&"function"==typeof l[c]?[2,f(s,l).then((function(){return l[c]()}))]:(l?l&&Object.hasOwn(l,c)?console.warn("The export ".concat(t,", defined in ").concat(e,"'s routes.json, is not a function")):console.warn("".concat(s,' does not define a component called "').concat(c,'", referenced in ').concat(e,"'s routes.json. This cannot be loaded.")):console.warn("Unknown app ".concat(s," for ").concat(t," defined in ").concat(e,"'s routes.json")),[2,o])}}))}))}function f(e,n){return p.apply(this,arguments)}function p(){return(p=i((function(e,o){var r,i;return a(this,(function(a){switch(a.label){case 0:return e in s?[3,5]:null==o?[3,1]:(i=o,[3,3]);case 1:return[4,(0,n.importDynamic)(e)];case 2:i=a.sent(),a.label=3;case 3:return r=i,[4,s[e]=new Promise((function(n,o){if(Object.hasOwn(r,"startupApp")){var i=r.startupApp;if("function"==typeof i)return Promise.resolve(i()).then((function(){(0,t.registerModuleLoad)(e),n(null)})).catch(o)}(0,t.registerModuleLoad)(e),n(null)}))];case 4:return a.sent(),[3,7];case 5:return[4,s[e]];case 6:a.sent(),a.label=7;case 7:return[2]}}))}))).apply(this,arguments)}var d=c(645),h=c(708),m=c(45);function g(e,n){var t=n.name;if(t){n.slots&&n.slot&&console.warn("The extension ".concat(t," from ").concat(e," declares both a 'slots' property and\na 'slot' property. Only the 'slots' property will be honored."));var o=n.slots?n.slots:n.slot?[n.slot]:[];if(n.component||n.load){var r,i,a=void 0;if(n.component)a=u(e,n.component);else if(n.load){if("function"!=typeof n.load)return void console.error("The extension ".concat(t," from ").concat(e," declares a 'load' property that is not a function. This is not\nsupported, so the extension will not be loaded."));a=n.load}a&&(0,m.registerExtension)({name:t,load:a,meta:n.meta||{},order:n.order,moduleName:e,privileges:n.privileges,online:null===(r=n.online)||void 0===r||r,offline:null!==(i=n.offline)&&void 0!==i&&i,featureFlag:n.featureFlag});var s=!0,c=!1,l=void 0;try{for(var f,p=o[Symbol.iterator]();!(s=(f=p.next()).done);s=!0){var d=f.value;(0,m.attach)(d,t)}}catch(e){c=!0,l=e}finally{try{s||null==p.return||p.return()}finally{if(c)throw l}}}else console.error("The extension ".concat(t," from ").concat(e," is missing a 'component' entry and thus cannot be registered.\nTo fix this, ensure that you define a 'component' field inside the extension definition."),n)}else console.error("An extension definition in ".concat(e,' is missing an name and thus cannot be\nregistered. To fix this, ensure that you define the "name" field inside the\nextension definition.'),n)}function y(e,n,t){return n in e?Object.defineProperty(e,n,{value:t,enumerable:!0,configurable:!0,writable:!0}):e[n]=t,e}var v=[];function b(e){if(Array.isArray(e)){var n=e.map(b);return function(e){return n.some((function(n){return n(e)}))}}return"string"==typeof e?(0,d.pathToActiveWhen)(window.getOpenmrsSpaBase()+e):(t=e,(null!=(o=RegExp)&&"undefined"!=typeof Symbol&&o[Symbol.hasInstance]?o[Symbol.hasInstance](t):t instanceof o)?function(n){return function(e,n){return e.test(n.pathname.replace(window.getOpenmrsSpaBase(),""))}(e,n)}:function(){return e});var t,o}function w(e,n){if(e&&n&&"object"==typeof n){var o,r;(0,t.registerModuleWithConfigSystem)(e);var i,a,s,c,l=null!==(r=n.extensions)&&void 0!==r?r:[],f=null!==(i=n.modals)&&void 0!==i?i:[],p=null!==(a=n.workspaces)&&void 0!==a?a:[],d=null!==(s=n.workspaceGroups)&&void 0!==s?s:[],b=null!==(c=n.featureFlags)&&void 0!==c?c:[];null===(o=n.pages)||void 0===o||o.forEach((function(n){var t,o,r;n&&"object"==typeof n&&Object.hasOwn(n,"component")&&(Object.hasOwn(n,"route")||Object.hasOwn(n,"routeRegex")||Object.hasOwn(n,"routes"))?v.push((o=function(e){for(var n=1;n<arguments.length;n++){var t=null!=arguments[n]?arguments[n]:{},o=Object.keys(t);"function"==typeof Object.getOwnPropertySymbols&&(o=o.concat(Object.getOwnPropertySymbols(t).filter((function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable})))),o.forEach((function(n){y(e,n,t[n])}))}return e}({},n),r=null!=(r={order:null!==(t=n.order)&&void 0!==t?t:Number.MAX_SAFE_INTEGER,appName:e})?r:{},Object.getOwnPropertyDescriptors?Object.defineProperties(o,Object.getOwnPropertyDescriptors(r)):function(e,n){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(e);t.push.apply(t,o)}return t}(Object(r)).forEach((function(e){Object.defineProperty(o,e,Object.getOwnPropertyDescriptor(r,e))})),o)):console.warn("A page for ".concat(e," could not be registered as it does not appear to have the required properties"),n)})),l.forEach((function(n){n&&"object"==typeof n&&Object.hasOwn(n,"name")&&Object.hasOwn(n,"component")?g(e,n):console.warn("An extension for ".concat(e," could not be registered as it does not appear to have the required properties"),n)})),f.forEach((function(n){n&&"object"==typeof n&&Object.hasOwn(n,"name")&&Object.hasOwn(n,"component")?function(e,n){var t=n.name;if(t)if(n.component||n.load){var o=void 0;if(n.component)o=u(e,n.component);else if(n.load){if("function"!=typeof n.load)return void console.error("The modal ".concat(t," from ").concat(e," declares a 'load' property that is not a function. This is not\nsupported, so the modal will not be loaded."));o=n.load}o&&(0,m.registerModal)({name:t,load:o,moduleName:e})}else console.error("The modal ".concat(t," from ").concat(e," is missing a 'component' entry and thus cannot be registered.\nTo fix this, ensure that you define a 'component' field inside the modal definition."),n);else console.error("A modal definition in ".concat(e,' is missing an name and thus cannot be\nregistered. To fix this, ensure that you define the "name" field inside the\nmodal definition.'),n)}(e,n):console.warn("A modal for ".concat(e," could not be registered as it does not appear to have the required properties"),n)})),p.forEach((function(n){n&&"object"==typeof n&&Object.hasOwn(n,"name")&&Object.hasOwn(n,"component")?function(e,n){var t=n.name;if(t){var o=n.title;if(o)if(n.component||n.load){var r=void 0;if(n.component)r=u(e,n.component);else if(n.load){if("function"!=typeof n.load)return void console.error("The workspace ".concat(t," from ").concat(e," declares a 'load' property that is not a function. This is not\nsupported, so the workspace will not be loaded."));r=n.load}r&&(0,m.registerWorkspace)({name:t,title:o,load:r,moduleName:e,type:n.type,canHide:n.canHide,canMaximize:n.canMaximize,width:n.width,preferredWindowSize:n.preferredWindowSize,groups:n.groups});var i=!0,a=!1,s=void 0;try{for(var c,l=(n.groups||[])[Symbol.iterator]();!(i=(c=l.next()).done);i=!0){var f=c.value;(0,m.registerWorkspaceGroup)({name:f,members:[t]})}}catch(e){a=!0,s=e}finally{try{i||null==l.return||l.return()}finally{if(a)throw s}}}else console.error("The workspace ".concat(t," from ").concat(e," is missing a 'component' entry and thus cannot be registered.\nTo fix this, ensure that you define a 'component' field inside the workspace definition."),n);else console.error("A workspace definition in ".concat(e,' is missing a title and thus cannot be registered.\nTo fix this, ensure that you define the "title" field inside the workspace definition.'),n)}else console.error("A workspace definition in ".concat(e,' is missing a name and thus cannot be registered.\nTo fix this, ensure that you define the "name" field inside the workspace definition.'),n)}(e,n):console.warn("A workspace for ".concat(e," could not be registered as it does not appear to have the required properties"),n)})),d.forEach((function(n){n&&"object"==typeof n&&Object.hasOwn(n,"name")?function(e,n){var t,o=n.name;o?(0,m.registerWorkspaceGroup)({name:o,members:null!==(t=n.members)&&void 0!==t?t:[]}):console.error("A workspace group definition in ".concat(e,' is missing a name and thus cannot be registered.\nTo fix this, ensure that you define the "name" field inside the workspace definition.'),n)}(e,n):console.warn("A workspace group for ".concat(e," could not be registered as it does not appear to have the required properties"),n)})),b.forEach((function(n){n&&"object"==typeof n&&Object.hasOwn(n,"flagName")?function(e,n){n.flagName?n.label?n.description?(0,h.registerFeatureFlag)(n.flagName,n.label,n.description):console.error("A feature flag definition in ".concat(e,' is missing a description and thus cannot be registered.\nTo fix this, ensure that you define the "description" field inside the feature flag definition.'),n):console.error("A feature flag definition in ".concat(e,' is missing a description and thus cannot be registered.\nTo fix this, ensure that you define the "label" field inside the feature flag definition.'),n):console.error("A feature flag definition in ".concat(e,' is missing a name and thus cannot be registered.\nTo fix this, ensure that you define the "name" field inside the feature flag definition.'),n)}(e,n):console.warn("A feature flag for ".concat(e," could not be registered as it does not appear to have the required properties"),n)}))}}function O(){v.sort((function(e,n){var t=e.order-n.order;return 0!=t?t:e.appName.localeCompare(n.appName,"en")}));var e=new Map,n=!0,t=!1,o=void 0;try{for(var r,i=v[Symbol.iterator]();!(n=(r=i.next()).done);n=!0){var a=r.value;e.has(a.appName)?e.set(a.appName,e.get(a.appName)+1):e.set(a.appName,0);var s=e.get(a.appName),c="".concat(a.appName,"-page-").concat(s),l=document.createElement("div");l.id="single-spa-application:".concat(c),document.body.appendChild(l),x(c,a)}}catch(e){t=!0,o=e}finally{try{n||null==i.return||i.return()}finally{if(t)throw o}}}function x(e,n){var t=void 0!==n.route?n.route:void 0!==n.routeRegex&&new RegExp(n.routeRegex);if(!1!==t)if(n.component){var o=function(e,n){var t=n.online,o=n.offline,r=n.featureFlag;return window.offlineEnabled?function(n){return!!(navigator.onLine&&(null==t||t)||!navigator.onLine&&null!=o&&o)&&!(r&&!(0,h.getFeatureFlag)(r))&&e(n)}:e}(b(t),n),r=u(n.appName,n.component);(0,d.registerApplication)(e,r,o)}else console.warn('A registered page definition is missing a component and thus cannot be registered.\nTo fix this, ensure that you define the "component" field inside the page definition.',e);else console.warn('A registered page definition is missing a route and thus cannot be registered.\nTo fix this, ensure that you define the "route" (or alternatively the "routeRegex") field inside the extension definition.',e)}function j(e,n){(null==n||n>e.length)&&(n=e.length);for(var t=0,o=new Array(n);t<n;t++)o[t]=e[t];return o}var A=(0,c(618).canAccessStorage)();function S(e,n){if(A){if("string"==typeof n){if(n.startsWith("http"))return P(e,n);try{var t=JSON.parse(n);if(E(t))return P(e,t);console.error("The supplied routes for ".concat(e," is not a valid OpenmrsAppRoutes object"),n)}catch(n){console.error("Could not add routes override for ".concat(e,": "),n)}}else{if(o=n,null!=(r=URL)&&"undefined"!=typeof Symbol&&r[Symbol.hasInstance]?r[Symbol.hasInstance](o):o instanceof r)return P(e,n.toString());if(E(n))return P(e,n)}var o,r;console.error("Override for ".concat(e," is not in a valid format. Expected either a Javascript Object, a JSON string of a Javascript object, or a URL"),n)}}function T(n){if(A){var t=e+n;localStorage.removeItem(t)}}function k(){if(A)for(var n=window.localStorage,t=0;t<n.length;t++){var o=n.key(t);(null==o?void 0:o.startsWith(e))&&n.removeItem(o)}}function P(n,t){var o=e+n;localStorage.setItem(o,JSON.stringify(t))}function E(e){if(e&&"object"==typeof e){var n=Object.prototype.hasOwnProperty,t=e;return!!((!n.call(e,"pages")||Boolean(t.pages)&&Array.isArray(t.pages))&&(!n.call(e,"extensions")||Boolean(t.extensions)&&Array.isArray(t.extensions))&&(!n.call(e,"workspaces")||Boolean(t.workspaces)&&Array.isArray(t.workspaces))&&(!n.call(e,"modals")||Boolean(t.modals)&&Array.isArray(t.modals)))}return!1}function N(e){if(e&&"object"==typeof e){var n=e;return Object.entries(n).every((function(e){var n,t,o=(t=2,function(e){if(Array.isArray(e))return e}(n=e)||function(e,n){var t=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=t){var o,r,i=[],a=!0,s=!1;try{for(t=t.call(e);!(a=(o=t.next()).done)&&(i.push(o.value),!n||i.length!==n);a=!0);}catch(e){s=!0,r=e}finally{try{a||null==t.return||t.return()}finally{if(s)throw r}}return i}}(n,t)||function(e,n){if(e){if("string"==typeof e)return j(e,n);var t=Object.prototype.toString.call(e).slice(8,-1);return"Object"===t&&e.constructor&&(t=e.constructor.name),"Map"===t||"Set"===t?Array.from(t):"Arguments"===t||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t)?j(e,n):void 0}}(n,t)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()),r=o[0],i=o[1];return"string"==typeof r&&E(i)}))}return!1}})(),l})())}}}));
|
|
2
|
-
//# sourceMappingURL=openmrs-esm-utils.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"openmrs-esm-utils.js","mappings":"62BAAAA,EAAOC,QAAUC,C,UCAjBF,EAAOC,QAAUE,C,SCAjBH,EAAOC,QAAUG,C,UCAjBJ,EAAOC,QAAUI,C,UCAjBL,EAAOC,QAAUK,C,UCAjBN,EAAOC,QAAUM,C,GCCbC,EAA2B,CAAC,EAGhC,SAASC,EAAoBC,GAE5B,IAAIC,EAAeH,EAAyBE,GAC5C,QAAqBE,IAAjBD,EACH,OAAOA,EAAaV,QAGrB,IAAID,EAASQ,EAAyBE,GAAY,CAGjDT,QAAS,CAAC,GAOX,OAHAY,EAAoBH,GAAUV,EAAQA,EAAOC,QAASQ,GAG/CT,EAAOC,OACf,CCrBAQ,EAAoBK,EAAI,CAACb,EAASc,KACjC,IAAI,IAAIC,KAAOD,EACXN,EAAoBQ,EAAEF,EAAYC,KAASP,EAAoBQ,EAAEhB,EAASe,IAC5EE,OAAOC,eAAelB,EAASe,EAAK,CAAEI,YAAY,EAAMC,IAAKN,EAAWC,IAE1E,ECNDP,EAAoBQ,EAAI,CAACK,EAAKC,IAAUL,OAAOM,UAAUC,eAAeC,KAAKJ,EAAKC,GCClFd,EAAoBkB,EAAK1B,IACH,oBAAX2B,QAA0BA,OAAOC,aAC1CX,OAAOC,eAAelB,EAAS2B,OAAOC,YAAa,CAAEC,MAAO,WAE7DZ,OAAOC,eAAelB,EAAS,aAAc,CAAE6B,OAAO,GAAO,E,oSCLvD,IAAMC,EAA2B,kB,kBCE3BC,EAAoC,CAC/CC,UAAAA,WACE,OAAOC,QAAQC,SAC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Y1F,WAK5DrD,EAAeC,KAAKwE,EAAQ,eACzBqF,QAAQf,EAAYnE,aAAgBpB,MAAMC,QAAQsF,EAAYnE,gBAKjE5E,EAAeC,KAAKwE,EAAQ,eACzBqF,QAAQf,EAAY/D,aAAgBxB,MAAMC,QAAQsF,EAAY/D,gBAKjEhF,EAAeC,KAAKwE,EAAQ,WACzBqF,QAAQf,EAAYjE,SAAYtB,MAAMC,QAAQsF,EAAYjE,SAQnE,CAEA,OAAO,CACT,CAUO,SAASiF,EAAgBtF,GAC9B,GAAIA,GAA4B,iBAAXA,EAAqB,CACxC,IAAMsE,EAActE,EAEpB,OAAOhF,OAAOuK,QAAQjB,GAAakB,OAAM,Y,g1BAAE1K,EAAAA,EAAAA,GAAKc,EAAAA,EAAAA,G,MAA0B,iBAARd,GAAoB2J,EAAmB7I,E,GAC3G,CAEA,OAAO,CACT,C","sources":["webpack://@openmrs/esm-routes/external system \"@openmrs/esm-config\"","webpack://@openmrs/esm-routes/external system \"@openmrs/esm-dynamic-loading\"","webpack://@openmrs/esm-routes/external system \"@openmrs/esm-extensions\"","webpack://@openmrs/esm-routes/external system \"@openmrs/esm-feature-flags\"","webpack://@openmrs/esm-routes/external system \"@openmrs/esm-utils\"","webpack://@openmrs/esm-routes/external system \"single-spa\"","webpack://@openmrs/esm-routes/webpack/bootstrap","webpack://@openmrs/esm-routes/webpack/runtime/define property getters","webpack://@openmrs/esm-routes/webpack/runtime/hasOwnProperty shorthand","webpack://@openmrs/esm-routes/webpack/runtime/make namespace object","webpack://@openmrs/esm-routes/./src/constants.ts","webpack://@openmrs/esm-routes/./src/loaders/helpers.ts","webpack://@openmrs/esm-routes/./src/loaders/app.ts","webpack://@openmrs/esm-routes/./src/loaders/components.ts","webpack://@openmrs/esm-routes/./src/loaders/pages.ts","webpack://@openmrs/esm-routes/./src/routes.ts"],"sourcesContent":["module.exports = __WEBPACK_EXTERNAL_MODULE__824__;","module.exports = __WEBPACK_EXTERNAL_MODULE__758__;","module.exports = __WEBPACK_EXTERNAL_MODULE__45__;","module.exports = __WEBPACK_EXTERNAL_MODULE__708__;","module.exports = __WEBPACK_EXTERNAL_MODULE__618__;","module.exports = __WEBPACK_EXTERNAL_MODULE__645__;","// The module cache\nvar __webpack_module_cache__ = {};\n\n// The require function\nfunction __webpack_require__(moduleId) {\n\t// Check if module is in cache\n\tvar cachedModule = __webpack_module_cache__[moduleId];\n\tif (cachedModule !== undefined) {\n\t\treturn cachedModule.exports;\n\t}\n\t// Create a new module (and put it into the cache)\n\tvar module = __webpack_module_cache__[moduleId] = {\n\t\t// no module.id needed\n\t\t// no module.loaded needed\n\t\texports: {}\n\t};\n\n\t// Execute the module function\n\t__webpack_modules__[moduleId](module, module.exports, __webpack_require__);\n\n\t// Return the exports of the module\n\treturn module.exports;\n}\n\n","// define getter functions for harmony exports\n__webpack_require__.d = (exports, definition) => {\n\tfor(var key in definition) {\n\t\tif(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {\n\t\t\tObject.defineProperty(exports, key, { enumerable: true, get: definition[key] });\n\t\t}\n\t}\n};","__webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))","// define __esModule on exports\n__webpack_require__.r = (exports) => {\n\tif(typeof Symbol !== 'undefined' && Symbol.toStringTag) {\n\t\tObject.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });\n\t}\n\tObject.defineProperty(exports, '__esModule', { value: true });\n};","export const localStorageRoutesPrefix = 'openmrs-routes:';\n","import { type LifeCycles } from 'single-spa';\n\nexport const emptyLifecycle: LifeCycles<never> = {\n bootstrap() {\n return Promise.resolve();\n },\n mount() {\n return Promise.resolve();\n },\n unmount() {\n return Promise.resolve();\n },\n};\n\nexport function routeRegex(regex: RegExp, location: Location) {\n const result = regex.test(location.pathname.replace(window.getOpenmrsSpaBase(), ''));\n return result;\n}\n","import { importDynamic } from '@openmrs/esm-dynamic-loading';\nimport { registerModuleLoad } from '@openmrs/esm-config';\nimport { type LifeCycles } from 'single-spa';\nimport { emptyLifecycle } from './helpers';\n\n// Couldn't figure out how to express this as an interface\ntype Module = Omit<Record<string, () => LifeCycles | Promise<LifeCycles>>, 'startupApp'> & {\n startupApp?: () => unknown;\n};\n\n/**\n * @internal\n *\n * Used internally to track which apps have had their `startupApp()` initializer called\n *\n * Values are promises to support asynchronous loading of the same app multiple times\n */\nconst initializedApps = new Map<string, Promise<unknown>>();\n\n/**\n * This function creates a loader function suitable for use in either a single-spa\n * application or parcel.\n *\n * The returned function is lazy and ensures that the appropriate module is loaded,\n * that the module's `startupApp()` is called before the component is loaded. It\n * then calls the component function, which should return either a single-spa\n * {@link LifeCycles} object or a {@link Promise} that will resolve to such an object.\n *\n * React-based pages or extensions should generally use the framework's\n * `getAsyncLifecycle()` or `getSyncLifecycle()` functions.\n *\n * @param routesAppName The app name of the routes.json file defining the component to load\n *\n * @param fullComponentName The name of the component to load. Note that this can optionally\n * include the appName to load the component from (in the format `${appName}#${componentName}`),\n * or omitted to implicitly use routesAppName\n *\n */\nexport function getLoader(routesAppName: string, fullComponentName: string): () => Promise<LifeCycles> {\n return async () => {\n const poundIndex = fullComponentName.indexOf('#');\n const isNamespaced = poundIndex >= 0;\n const appName = isNamespaced ? fullComponentName.substring(0, poundIndex) : routesAppName;\n const componentName = isNamespaced ? fullComponentName.substring(poundIndex + 1) : fullComponentName;\n\n const module = await importDynamic<Module>(appName);\n\n if (module && Object.hasOwn(module, componentName) && typeof module[componentName] === 'function') {\n return initializeApp(appName, module).then(() => module[componentName]());\n } else {\n if (!module) {\n console.warn(`Unknown app ${appName} for ${fullComponentName} defined in ${routesAppName}'s routes.json`);\n } else if (module && Object.hasOwn(module, componentName)) {\n console.warn(`The export ${fullComponentName}, defined in ${routesAppName}'s routes.json, is not a function`);\n } else {\n console.warn(\n `${appName} does not define a component called \"${componentName}\", referenced in ${routesAppName}'s routes.json. This cannot be loaded.`,\n );\n }\n }\n\n return emptyLifecycle;\n };\n}\n\n/**\n * This function can be used to manually initialize an application without waiting for the\n * framework to load it. This can sometimes be helpful if the framework doesn't load code\n * at the point you think is appropriate.\n *\n * This will ensure that the module is available and that it's `startupApp()` function (if\n * any) will be called. Note that these are only guaranteed to be complete once the Promise\n * returned from the function completes.\n *\n * @param appName The name of the app to initialize\n * @param module The loaded code module, if available; if this parameter is omitted, this\n * function will load it.\n * @returns a Promise which completes once the app has been loaded and initialized\n */\nexport async function initializeApp(appName: string, module?: Module) {\n if (!(appName in initializedApps)) {\n let _module: Module = module ?? (await importDynamic<Module>(appName));\n\n await (initializedApps[appName] = new Promise((resolve, reject) => {\n if (Object.hasOwn(_module, 'startupApp')) {\n const startup = _module['startupApp'];\n if (typeof startup === 'function') {\n return Promise.resolve(startup())\n .then(() => {\n registerModuleLoad(appName);\n resolve(null);\n })\n .catch(reject);\n }\n }\n\n registerModuleLoad(appName);\n resolve(null);\n }));\n } else {\n await initializedApps[appName];\n }\n}\n","import {\n attach,\n type ExtensionRegistration,\n registerExtension,\n registerModal,\n registerWorkspace,\n registerWorkspaceGroup,\n} from '@openmrs/esm-extensions';\nimport {\n type FeatureFlagDefinition,\n type ExtensionDefinition,\n type ModalDefinition,\n type WorkspaceDefinition,\n type WorkspaceGroupDefinition,\n} from '@openmrs/esm-globals';\nimport { getLoader } from './app';\nimport { registerFeatureFlag } from '@openmrs/esm-feature-flags';\n\n/**\n * This function registers an extension definition with the framework and will\n * attach the extension to any configured slots.\n *\n * @param appName The name of the app containing this extension\n * @param extension An object that describes the extension, derived from `routes.json`\n */\nexport function tryRegisterExtension(appName: string, extension: ExtensionDefinition) {\n const name = extension.name;\n if (!name) {\n console.error(\n `An extension definition in ${appName} is missing an name and thus cannot be\nregistered. To fix this, ensure that you define the \"name\" field inside the\nextension definition.`,\n extension,\n );\n return;\n }\n\n if (extension.slots && extension.slot) {\n console.warn(\n `The extension ${name} from ${appName} declares both a 'slots' property and\na 'slot' property. Only the 'slots' property will be honored.`,\n );\n }\n const slots = extension.slots ? extension.slots : extension.slot ? [extension.slot] : [];\n\n if (!extension.component && !extension.load) {\n console.error(\n `The extension ${name} from ${appName} is missing a 'component' entry and thus cannot be registered.\nTo fix this, ensure that you define a 'component' field inside the extension definition.`,\n extension,\n );\n return;\n }\n\n let loader: ExtensionRegistration['load'] | undefined = undefined;\n if (extension.component) {\n loader = getLoader(appName, extension.component);\n } else if (extension.load) {\n if (typeof extension.load !== 'function') {\n console.error(\n `The extension ${name} from ${appName} declares a 'load' property that is not a function. This is not\nsupported, so the extension will not be loaded.`,\n );\n return;\n }\n loader = extension.load;\n }\n\n if (loader) {\n registerExtension({\n name,\n load: loader,\n meta: extension.meta || {},\n order: extension.order,\n moduleName: appName,\n privileges: extension.privileges,\n online: extension.online ?? true,\n offline: extension.offline ?? false,\n featureFlag: extension.featureFlag,\n });\n }\n\n for (const slot of slots) {\n attach(slot, name);\n }\n}\n\n/**\n * This function registers a modal definition with the framework so that it can be launched.\n *\n * @param appName The name of the app defining this modal\n * @param modal An object that describes the modal, derived from `routes.json`\n */\nexport function tryRegisterModal(appName: string, modal: ModalDefinition) {\n const name = modal.name;\n if (!name) {\n console.error(\n `A modal definition in ${appName} is missing an name and thus cannot be\nregistered. To fix this, ensure that you define the \"name\" field inside the\nmodal definition.`,\n modal,\n );\n return;\n }\n\n if (!modal.component && !modal.load) {\n console.error(\n `The modal ${name} from ${appName} is missing a 'component' entry and thus cannot be registered.\nTo fix this, ensure that you define a 'component' field inside the modal definition.`,\n modal,\n );\n return;\n }\n\n let loader: ExtensionRegistration['load'] | undefined = undefined;\n if (modal.component) {\n loader = getLoader(appName, modal.component);\n } else if (modal.load) {\n if (typeof modal.load !== 'function') {\n console.error(\n `The modal ${name} from ${appName} declares a 'load' property that is not a function. This is not\nsupported, so the modal will not be loaded.`,\n );\n return;\n }\n loader = modal.load;\n }\n\n if (loader) {\n registerModal({\n name,\n load: loader,\n moduleName: appName,\n });\n }\n}\n\n/**\n * This function registers a workspace definition with the framework so that it can be launched.\n *\n * @param appName The name of the app defining this workspace\n * @param workspace An object that describes the workspace, derived from `routes.json`\n */\nexport function tryRegisterWorkspace(appName: string, workspace: WorkspaceDefinition) {\n const name = workspace.name;\n if (!name) {\n console.error(\n `A workspace definition in ${appName} is missing a name and thus cannot be registered.\nTo fix this, ensure that you define the \"name\" field inside the workspace definition.`,\n workspace,\n );\n return;\n }\n\n const title = workspace.title;\n if (!title) {\n console.error(\n `A workspace definition in ${appName} is missing a title and thus cannot be registered.\nTo fix this, ensure that you define the \"title\" field inside the workspace definition.`,\n workspace,\n );\n return;\n }\n\n if (!workspace.component && !workspace.load) {\n console.error(\n `The workspace ${name} from ${appName} is missing a 'component' entry and thus cannot be registered.\nTo fix this, ensure that you define a 'component' field inside the workspace definition.`,\n workspace,\n );\n return;\n }\n\n let loader: ExtensionRegistration['load'] | undefined = undefined;\n if (workspace.component) {\n loader = getLoader(appName, workspace.component);\n } else if (workspace.load) {\n if (typeof workspace.load !== 'function') {\n console.error(\n `The workspace ${name} from ${appName} declares a 'load' property that is not a function. This is not\nsupported, so the workspace will not be loaded.`,\n );\n return;\n }\n loader = workspace.load;\n }\n\n if (loader) {\n registerWorkspace({\n name,\n title,\n load: loader,\n moduleName: appName,\n type: workspace.type,\n canHide: workspace.canHide,\n canMaximize: workspace.canMaximize,\n width: workspace.width,\n preferredWindowSize: workspace.preferredWindowSize,\n groups: workspace.groups,\n });\n }\n\n for (const group of workspace.groups || []) {\n registerWorkspaceGroup({\n name: group,\n members: [name],\n });\n }\n}\n\n/**\n * This function registers a workspace group definition with the framework so that it can be launched.\n *\n * @param appName The name of the app defining this workspace\n * @param workspace An object that describes the workspace, derived from `routes.json`\n */\nexport function tryRegisterWorkspaceGroup(appName: string, workspaceGroup: WorkspaceGroupDefinition) {\n const name = workspaceGroup.name;\n if (!name) {\n console.error(\n `A workspace group definition in ${appName} is missing a name and thus cannot be registered.\nTo fix this, ensure that you define the \"name\" field inside the workspace definition.`,\n workspaceGroup,\n );\n return;\n }\n\n registerWorkspaceGroup({\n name,\n members: workspaceGroup.members ?? [],\n });\n}\n\n/**\n * This function registers a feature flag definition with the framework.\n *\n * @param appName The name of the app defining this feature flag\n * @param featureFlag An object that describes the feature flag, derived from `routes.json`\n */\nexport function tryRegisterFeatureFlag(appName: string, featureFlag: FeatureFlagDefinition) {\n const name = featureFlag.flagName;\n if (!name) {\n console.error(\n `A feature flag definition in ${appName} is missing a name and thus cannot be registered.\nTo fix this, ensure that you define the \"name\" field inside the feature flag definition.`,\n featureFlag,\n );\n return;\n }\n\n const label = featureFlag.label;\n if (!label) {\n console.error(\n `A feature flag definition in ${appName} is missing a description and thus cannot be registered.\nTo fix this, ensure that you define the \"label\" field inside the feature flag definition.`,\n featureFlag,\n );\n return;\n }\n\n const description = featureFlag.description;\n if (!description) {\n console.error(\n `A feature flag definition in ${appName} is missing a description and thus cannot be registered.\nTo fix this, ensure that you define the \"description\" field inside the feature flag definition.`,\n featureFlag,\n );\n return;\n }\n\n registerFeatureFlag(featureFlag.flagName, featureFlag.label, featureFlag.description);\n}\n","import { type ActivityFn, pathToActiveWhen, registerApplication } from 'single-spa';\nimport { registerModuleWithConfigSystem } from '@openmrs/esm-config';\nimport {\n type WorkspaceGroupDefinition,\n type ExtensionDefinition,\n type FeatureFlagDefinition,\n type ModalDefinition,\n type OpenmrsAppRoutes,\n type RegisteredPageDefinition,\n type RouteDefinition,\n type WorkspaceDefinition,\n} from '@openmrs/esm-globals';\nimport { getFeatureFlag } from '@openmrs/esm-feature-flags';\nimport { routeRegex } from './helpers';\nimport { getLoader } from './app';\nimport {\n tryRegisterExtension,\n tryRegisterFeatureFlag,\n tryRegisterModal,\n tryRegisterWorkspace,\n tryRegisterWorkspaceGroup,\n} from './components';\n\n// this is the global holder of all pages registered in the app\nconst pages: Array<RegisteredPageDefinition> = [];\n\n/**\n * This takes a page's route definitions and returns a single-spa\n * activityFn which returns true when the page matches the current\n * route and false if it does not.\n *\n * @param route A string or regexp that matches the location when the\n * page should be displayed, a boolean constant, or an array of such\n * strings, regexps, and booleans\n * @returns An activityFn suitable to use for a single-spa application\n */\nfunction getActivityFn(route: RouteDefinition | Array<RouteDefinition>): ActivityFn {\n if (Array.isArray(route)) {\n const activators = route.map(getActivityFn);\n return (location) => activators.some((activator) => activator(location));\n } else if (typeof route === 'string') {\n return pathToActiveWhen(window.getOpenmrsSpaBase() + route);\n } else if (route instanceof RegExp) {\n return (location) => routeRegex(route, location);\n } else {\n return () => route;\n }\n}\n\n/**\n * For pages, we also add support for rendered them based on online and offline mode as well as\n * any feature flags.\n *\n * By default, we assume that all pages should be rendered when online, but only rendered\n * offline if specifically configured to do so.\n *\n * @param activityFn A standard single-spa activityFn such as that returned by {@link getActivityFn()}\n * @param pageDefinition The RegisteredPageDefinition object for this page\n * @returns An activityFn suitable to use for a single-spa application\n */\nfunction wrapPageActivityFn(\n activityFn: ActivityFn,\n { online, offline, featureFlag }: RegisteredPageDefinition,\n): ActivityFn {\n if (window.offlineEnabled) {\n return (location) => {\n // basically, if the page should only work online and we're offline or if the\n // page should only work offline and we're online, defaulting to always rendering\n // the page\n if (!((navigator.onLine && (online ?? true)) || (!navigator.onLine && (offline ?? false)))) {\n return false;\n }\n\n if (featureFlag) {\n if (!getFeatureFlag(featureFlag)) {\n return false;\n }\n }\n\n return activityFn(location);\n };\n } else {\n return activityFn;\n }\n}\n\n/**\n * This is the main entry-point for registering an app with the app shell.\n * Each app has a name and should have a `routes.json` file that defines it's\n * associated routes.\n *\n * @param appName The name of the application, e.g. `@openmrs/esm-my-app`\n * @param routes A Javascript object that corresponds to the app's routes.json`\n * definition.\n */\nexport function registerApp(appName: string, routes: OpenmrsAppRoutes) {\n if (appName && routes && typeof routes === 'object') {\n registerModuleWithConfigSystem(appName);\n\n const availableExtensions: Array<ExtensionDefinition> = routes.extensions ?? [];\n const availableModals: Array<ModalDefinition> = routes.modals ?? [];\n const availableWorkspaces: Array<WorkspaceDefinition> = routes.workspaces ?? [];\n const availableWorkspaceGroups: Array<WorkspaceGroupDefinition> = routes.workspaceGroups ?? [];\n const availableFeatureFlags: Array<FeatureFlagDefinition> = routes.featureFlags ?? [];\n\n routes.pages?.forEach((p) => {\n if (\n p &&\n typeof p === 'object' &&\n Object.hasOwn(p, 'component') &&\n (Object.hasOwn(p, 'route') || Object.hasOwn(p, 'routeRegex') || Object.hasOwn(p, 'routes'))\n ) {\n pages.push({\n ...p,\n order: p.order ?? Number.MAX_SAFE_INTEGER,\n appName,\n });\n } else {\n console.warn(\n `A page for ${appName} could not be registered as it does not appear to have the required properties`,\n p,\n );\n }\n });\n\n availableExtensions.forEach((ext) => {\n if (ext && typeof ext === 'object' && Object.hasOwn(ext, 'name') && Object.hasOwn(ext, 'component')) {\n tryRegisterExtension(appName, ext);\n } else {\n console.warn(\n `An extension for ${appName} could not be registered as it does not appear to have the required properties`,\n ext,\n );\n }\n });\n\n availableModals.forEach((modal) => {\n if (modal && typeof modal === 'object' && Object.hasOwn(modal, 'name') && Object.hasOwn(modal, 'component')) {\n tryRegisterModal(appName, modal);\n } else {\n console.warn(\n `A modal for ${appName} could not be registered as it does not appear to have the required properties`,\n modal,\n );\n }\n });\n\n availableWorkspaces.forEach((workspace) => {\n if (\n workspace &&\n typeof workspace === 'object' &&\n Object.hasOwn(workspace, 'name') &&\n Object.hasOwn(workspace, 'component')\n ) {\n tryRegisterWorkspace(appName, workspace);\n } else {\n console.warn(\n `A workspace for ${appName} could not be registered as it does not appear to have the required properties`,\n workspace,\n );\n }\n });\n\n availableWorkspaceGroups.forEach((workspaceGroup) => {\n if (workspaceGroup && typeof workspaceGroup === 'object' && Object.hasOwn(workspaceGroup, 'name')) {\n tryRegisterWorkspaceGroup(appName, workspaceGroup);\n } else {\n console.warn(\n `A workspace group for ${appName} could not be registered as it does not appear to have the required properties`,\n workspaceGroup,\n );\n }\n });\n\n availableFeatureFlags.forEach((featureFlag) => {\n if (featureFlag && typeof featureFlag === 'object' && Object.hasOwn(featureFlag, 'flagName')) {\n tryRegisterFeatureFlag(appName, featureFlag);\n } else {\n console.warn(\n `A feature flag for ${appName} could not be registered as it does not appear to have the required properties`,\n featureFlag,\n );\n }\n });\n }\n}\n\n/**\n * This is called by the app shell once all route entries have been processed.\n * This actually registers the pages with the application. This function is\n * necessary to ensure that pages are rendered in the DOM according to their\n * order definition, especially because certain pages _must_ be first in the DOM.\n *\n * Each page is rendered into a div with an appropriate name.\n */\nexport function finishRegisteringAllApps() {\n pages.sort((a, b) => {\n let sort = a.order - b.order;\n if (sort != 0) {\n return sort;\n }\n return a.appName.localeCompare(b.appName, 'en');\n });\n\n // Create a div for each page. This ensures their DOM order.\n // If we don't do this, Single-SPA 5 will create the DOM element only once\n // the page becomes active, which makes it impossible to guarantee order.\n let appIndices = new Map();\n for (let page of pages) {\n if (!appIndices.has(page.appName)) {\n appIndices.set(page.appName, 0);\n } else {\n appIndices.set(page.appName, appIndices.get(page.appName) + 1);\n }\n const index = appIndices.get(page.appName);\n\n const name = `${page.appName}-page-${index}`;\n const div = document.createElement('div');\n div.id = `single-spa-application:${name}`;\n document.body.appendChild(div);\n tryRegisterPage(name, page);\n }\n}\n\n/**\n * This function converts each page definition into a single-spa application\n * if that's possible. After this point, pages are rendered using single-spa's\n * routing logic.\n *\n * @param appName The name of the app containing this page\n * @param page An object that describes the page, derived from `routes.json`\n */\nfunction tryRegisterPage(appName: string, page: RegisteredPageDefinition) {\n const route =\n typeof page.route !== 'undefined'\n ? page.route\n : typeof page.routeRegex !== 'undefined'\n ? new RegExp(page.routeRegex)\n : false;\n\n if (route === false) {\n console.warn(\n `A registered page definition is missing a route and thus cannot be registered.\nTo fix this, ensure that you define the \"route\" (or alternatively the \"routeRegex\") field inside the extension definition.`,\n appName,\n );\n return;\n }\n\n if (!page.component) {\n console.warn(\n `A registered page definition is missing a component and thus cannot be registered.\nTo fix this, ensure that you define the \"component\" field inside the page definition.`,\n appName,\n );\n return;\n }\n\n const activityFn = wrapPageActivityFn(getActivityFn(route), page);\n const loader = getLoader(page.appName, page.component);\n registerApplication(appName, loader, activityFn);\n}\n","/** @module @category Routes Utilities */\nimport type { OpenmrsAppRoutes, OpenmrsRoutes } from '@openmrs/esm-globals';\nimport { canAccessStorage } from '@openmrs/esm-utils';\nimport { localStorageRoutesPrefix } from './constants';\n\nconst isEnabled = canAccessStorage();\n\n/**\n * Used to add a route override to local storage. These are read as the routes registry\n * is assembled, so the app must be reloaded for new overrides to take effect.\n *\n * @internal\n * @param moduleName The name of the module the routes are for\n * @param routes Either an {@link OpenmrsAppRoutes} object, a string that represents a JSON\n * version of an {@link OpenmrsAppRoutes} object or a string or URL that resolves to a\n * JSON document that represents an {@link OpenmrsAppRoutes} object\n */\nexport function addRoutesOverride(moduleName: string, routes: OpenmrsAppRoutes | string | URL) {\n if (!isEnabled) {\n return;\n }\n\n if (typeof routes === 'string') {\n if (routes.startsWith('http')) {\n return addRouteOverrideInternal(moduleName, routes);\n } else {\n try {\n const maybeRoutes = JSON.parse(routes);\n if (isOpenmrsAppRoutes(maybeRoutes)) {\n return addRouteOverrideInternal(moduleName, maybeRoutes);\n } else {\n console.error(`The supplied routes for ${moduleName} is not a valid OpenmrsAppRoutes object`, routes);\n }\n } catch (e) {\n console.error(`Could not add routes override for ${moduleName}: `, e);\n }\n }\n } else if (routes instanceof URL) {\n return addRouteOverrideInternal(moduleName, routes.toString());\n } else if (isOpenmrsAppRoutes(routes)) {\n return addRouteOverrideInternal(moduleName, routes);\n }\n\n console.error(\n `Override for ${moduleName} is not in a valid format. Expected either a Javascript Object, a JSON string of a Javascript object, or a URL`,\n routes,\n );\n}\n\n/**\n * Used to remove an existing routes override from local storage. These are read as the routes registry\n * is assembled, so the app must be reloaded for removed override to be removed.\n *\n * @internal\n * @param moduleName The module to remove the overrides for\n */\nexport function removeRoutesOverride(moduleName: string) {\n if (!isEnabled) {\n return;\n }\n\n const key = localStorageRoutesPrefix + moduleName;\n localStorage.removeItem(key);\n}\n\n/**\n * Used to remove all existing routes overrides from local storage. These are read as the routes registry\n * is assembled, so the app must be reloaded for the removed overrides to appear to be removed.\n *\n * @internal\n */\nexport function resetAllRoutesOverrides() {\n if (!isEnabled) {\n return;\n }\n\n const localStorage = window.localStorage;\n for (let i = 0; i < localStorage.length; i++) {\n const key = localStorage.key(i);\n if (key?.startsWith(localStorageRoutesPrefix)) {\n localStorage.removeItem(key);\n }\n }\n}\n\nfunction addRouteOverrideInternal(moduleName: string, routes: OpenmrsAppRoutes | string) {\n const key = localStorageRoutesPrefix + moduleName;\n localStorage.setItem(key, JSON.stringify(routes));\n}\n\n/**\n * Simple type-predicate to ensure that the value can be treated as an OpenmrsAppRoutes\n * object.\n *\n * @internal\n * @param routes the object to check to see if it is an OpenmrsAppRoutes object\n * @returns true if the routes value is an OpenmrsAppRoutes\n */\nexport function isOpenmrsAppRoutes(routes: OpenmrsAppRoutes | unknown): routes is OpenmrsAppRoutes {\n if (routes && typeof routes === 'object') {\n const hasOwnProperty = Object.prototype.hasOwnProperty;\n // we cast maybeRoutes as OpenmrsAppRoutes mainly so we can refer to the properties it should\n // have without repeated casts\n const maybeRoutes = routes as OpenmrsAppRoutes;\n\n if (hasOwnProperty.call(routes, 'pages')) {\n if (!Boolean(maybeRoutes.pages) || !Array.isArray(maybeRoutes.pages)) {\n return false;\n }\n }\n\n if (hasOwnProperty.call(routes, 'extensions')) {\n if (!Boolean(maybeRoutes.extensions) || !Array.isArray(maybeRoutes.extensions)) {\n return false;\n }\n }\n\n if (hasOwnProperty.call(routes, 'workspaces')) {\n if (!Boolean(maybeRoutes.workspaces) || !Array.isArray(maybeRoutes.workspaces)) {\n return false;\n }\n }\n\n if (hasOwnProperty.call(routes, 'modals')) {\n if (!Boolean(maybeRoutes.modals) || !Array.isArray(maybeRoutes.modals)) {\n return false;\n }\n }\n\n // Notice that we're essentially testing for things that cannot be treated as an OpenmrsAppRoutes\n // object. This is because a completely empty object is a valid OpenmrsAppRoutes object.\n return true;\n }\n\n return false;\n}\n\n/**\n * Simple type-predicate to ensure that the value can be treated as an OpenmrsRoutes\n * object.\n *\n * @internal\n * @param routes the object to check to see if it is an OpenmrsRoutes object\n * @returns true if the routes value is an OpenmrsRoutes\n */\nexport function isOpenmrsRoutes(routes: OpenmrsRoutes | unknown): routes is OpenmrsRoutes {\n if (routes && typeof routes === 'object') {\n const maybeRoutes = routes as OpenmrsRoutes;\n\n return Object.entries(maybeRoutes).every(([key, value]) => typeof key === 'string' && isOpenmrsAppRoutes(value));\n }\n\n return false;\n}\n"],"names":["module","exports","__WEBPACK_EXTERNAL_MODULE__824__","__WEBPACK_EXTERNAL_MODULE__758__","__WEBPACK_EXTERNAL_MODULE__45__","__WEBPACK_EXTERNAL_MODULE__708__","__WEBPACK_EXTERNAL_MODULE__618__","__WEBPACK_EXTERNAL_MODULE__645__","__webpack_module_cache__","__webpack_require__","moduleId","cachedModule","undefined","__webpack_modules__","d","definition","key","o","Object","defineProperty","enumerable","get","obj","prop","prototype","hasOwnProperty","call","r","Symbol","toStringTag","value","localStorageRoutesPrefix","emptyLifecycle","bootstrap","Promise","resolve","mount","unmount","initializedApps","Map","getLoader","routesAppName","fullComponentName","poundIndex","isNamespaced","appName","componentName","indexOf","substring","importDynamic","hasOwn","initializeApp","then","console","warn","_module","reject","startup","registerModuleLoad","catch","tryRegisterExtension","extension","name","slots","slot","component","load","loader","error","registerExtension","meta","order","moduleName","privileges","online","offline","featureFlag","attach","pages","getActivityFn","route","Array","isArray","activators","map","location","some","activator","pathToActiveWhen","window","getOpenmrsSpaBase","RegExp","regex","test","pathname","replace","routeRegex","registerApp","routes","registerModuleWithConfigSystem","availableExtensions","extensions","availableModals","modals","availableWorkspaces","workspaces","availableWorkspaceGroups","workspaceGroups","availableFeatureFlags","featureFlags","forEach","p","push","Number","MAX_SAFE_INTEGER","ext","modal","registerModal","tryRegisterModal","workspace","title","registerWorkspace","type","canHide","canMaximize","width","preferredWindowSize","groups","group","registerWorkspaceGroup","members","tryRegisterWorkspace","workspaceGroup","tryRegisterWorkspaceGroup","flagName","label","description","registerFeatureFlag","tryRegisterFeatureFlag","finishRegisteringAllApps","sort","a","b","localeCompare","appIndices","page","has","set","index","div","document","createElement","id","body","appendChild","tryRegisterPage","activityFn","offlineEnabled","navigator","onLine","getFeatureFlag","wrapPageActivityFn","registerApplication","isEnabled","canAccessStorage","addRoutesOverride","startsWith","addRouteOverrideInternal","maybeRoutes","JSON","parse","isOpenmrsAppRoutes","e","URL","toString","removeRoutesOverride","localStorage","removeItem","resetAllRoutesOverrides","i","length","setItem","stringify","Boolean","isOpenmrsRoutes","entries","every"],"sourceRoot":""}
|
package/jest.config.js
DELETED
package/webpack.config.js
DELETED
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
const ForkTsCheckerWebpackPlugin = require("fork-ts-checker-webpack-plugin");
|
|
2
|
-
const { resolve } = require("path");
|
|
3
|
-
const { CleanWebpackPlugin } = require("clean-webpack-plugin");
|
|
4
|
-
const { BundleAnalyzerPlugin } = require("webpack-bundle-analyzer");
|
|
5
|
-
|
|
6
|
-
const { peerDependencies } = require("./package.json");
|
|
7
|
-
|
|
8
|
-
module.exports = (env) => ({
|
|
9
|
-
entry: [resolve(__dirname, "src/index.ts")],
|
|
10
|
-
output: {
|
|
11
|
-
filename: "openmrs-esm-utils.js",
|
|
12
|
-
path: resolve(__dirname, "dist"),
|
|
13
|
-
library: { type: "system" },
|
|
14
|
-
},
|
|
15
|
-
devtool: "source-map",
|
|
16
|
-
module: {
|
|
17
|
-
rules: [
|
|
18
|
-
{
|
|
19
|
-
test: /\.m?(js|ts|tsx)$/,
|
|
20
|
-
exclude: /node_modules/,
|
|
21
|
-
use: "swc-loader",
|
|
22
|
-
},
|
|
23
|
-
],
|
|
24
|
-
},
|
|
25
|
-
externals: Object.keys(peerDependencies || {}),
|
|
26
|
-
resolve: {
|
|
27
|
-
extensions: [".ts", ".js", ".tsx", ".jsx"],
|
|
28
|
-
},
|
|
29
|
-
plugins: [
|
|
30
|
-
new CleanWebpackPlugin(),
|
|
31
|
-
new ForkTsCheckerWebpackPlugin(),
|
|
32
|
-
new BundleAnalyzerPlugin({
|
|
33
|
-
analyzerMode: env && env.analyze ? "static" : "disabled",
|
|
34
|
-
}),
|
|
35
|
-
],
|
|
36
|
-
devServer: {
|
|
37
|
-
disableHostCheck: true,
|
|
38
|
-
headers: {
|
|
39
|
-
"Access-Control-Allow-Origin": "*",
|
|
40
|
-
},
|
|
41
|
-
},
|
|
42
|
-
});
|