@openmrs/esm-routes 7.0.1-pre.3258 → 7.0.1-pre.3259
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.turbo/turbo-build.log +1 -1
- package/dist/loaders/pages.d.ts +2 -5
- package/dist/loaders/pages.js +17 -15
- package/package.json +7 -7
- package/src/loaders/pages.ts +20 -15
package/.turbo/turbo-build.log
CHANGED
package/dist/loaders/pages.d.ts
CHANGED
|
@@ -11,10 +11,7 @@ import { type OpenmrsAppRoutes } from '@openmrs/esm-globals';
|
|
|
11
11
|
export declare function registerApp(appName: string, routes: OpenmrsAppRoutes): void;
|
|
12
12
|
/**
|
|
13
13
|
* This is called by the app shell once all route entries have been processed.
|
|
14
|
-
* This
|
|
15
|
-
*
|
|
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.
|
|
14
|
+
* This registers the pages with the application, and creates the root div
|
|
15
|
+
* for each page in the DOM element specified by the page's containerDomId.
|
|
19
16
|
*/
|
|
20
17
|
export declare function finishRegisteringAllApps(): void;
|
package/dist/loaders/pages.js
CHANGED
|
@@ -77,7 +77,6 @@ const pages = [];
|
|
|
77
77
|
if (p && typeof p === 'object' && Object.hasOwn(p, 'component') && (Object.hasOwn(p, 'route') || Object.hasOwn(p, 'routeRegex') || Object.hasOwn(p, 'routes'))) {
|
|
78
78
|
pages.push({
|
|
79
79
|
...p,
|
|
80
|
-
order: p.order ?? Number.MAX_SAFE_INTEGER,
|
|
81
80
|
appName
|
|
82
81
|
});
|
|
83
82
|
} else {
|
|
@@ -123,22 +122,18 @@ const pages = [];
|
|
|
123
122
|
}
|
|
124
123
|
/**
|
|
125
124
|
* This is called by the app shell once all route entries have been processed.
|
|
126
|
-
* This
|
|
127
|
-
*
|
|
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.
|
|
125
|
+
* This registers the pages with the application, and creates the root div
|
|
126
|
+
* for each page in the DOM element specified by the page's containerDomId.
|
|
131
127
|
*/ export function finishRegisteringAllApps() {
|
|
132
128
|
pages.sort((a, b)=>{
|
|
133
|
-
let sort = a.order - b.order;
|
|
134
|
-
if (sort != 0) {
|
|
135
|
-
return sort;
|
|
136
|
-
}
|
|
137
129
|
return a.appName.localeCompare(b.appName, 'en');
|
|
138
130
|
});
|
|
139
|
-
// Create a div for each page
|
|
131
|
+
// Create a div for each page, unless the DOM already contains the div with
|
|
132
|
+
// the expected id for the page to be mounted on. See:
|
|
133
|
+
// https://single-spa.js.org/docs/configuration/#two-registered-applications-simultaneously
|
|
134
|
+
// The div is put inside the DOM element specified by the page's containerDomId.
|
|
140
135
|
// If we don't do this, Single-SPA 5 will create the DOM element only once
|
|
141
|
-
// the page becomes active,
|
|
136
|
+
// the page becomes active, at the end of <body>.
|
|
142
137
|
let appIndices = new Map();
|
|
143
138
|
for (let page of pages){
|
|
144
139
|
if (!appIndices.has(page.appName)) {
|
|
@@ -148,9 +143,16 @@ const pages = [];
|
|
|
148
143
|
}
|
|
149
144
|
const index = appIndices.get(page.appName);
|
|
150
145
|
const name = `${page.appName}-page-${index}`;
|
|
151
|
-
const
|
|
152
|
-
|
|
153
|
-
|
|
146
|
+
const containerDomId = page.containerDomId ?? 'omrs-apps-container';
|
|
147
|
+
const containerDiv = document.getElementById(containerDomId);
|
|
148
|
+
const appDomRootId = `single-spa-application:${name}`;
|
|
149
|
+
if (containerDiv) {
|
|
150
|
+
const div = document.createElement('div');
|
|
151
|
+
div.id = appDomRootId;
|
|
152
|
+
containerDiv?.appendChild(div);
|
|
153
|
+
} else {
|
|
154
|
+
throw new Error(`${page.appName} ${page.component} cannot be mounted to "${containerDomId}"; DOM element does not exist.`);
|
|
155
|
+
}
|
|
154
156
|
tryRegisterPage(name, page);
|
|
155
157
|
}
|
|
156
158
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@openmrs/esm-routes",
|
|
3
|
-
"version": "7.0.1-pre.
|
|
3
|
+
"version": "7.0.1-pre.3259",
|
|
4
4
|
"license": "MPL-2.0",
|
|
5
5
|
"description": "Utilities for working with the routes registry",
|
|
6
6
|
"type": "module",
|
|
@@ -54,12 +54,12 @@
|
|
|
54
54
|
"single-spa": "6.x"
|
|
55
55
|
},
|
|
56
56
|
"devDependencies": {
|
|
57
|
-
"@openmrs/esm-config": "7.0.1-pre.
|
|
58
|
-
"@openmrs/esm-dynamic-loading": "7.0.1-pre.
|
|
59
|
-
"@openmrs/esm-extensions": "7.0.1-pre.
|
|
60
|
-
"@openmrs/esm-feature-flags": "7.0.1-pre.
|
|
61
|
-
"@openmrs/esm-globals": "7.0.1-pre.
|
|
62
|
-
"@openmrs/esm-utils": "7.0.1-pre.
|
|
57
|
+
"@openmrs/esm-config": "7.0.1-pre.3259",
|
|
58
|
+
"@openmrs/esm-dynamic-loading": "7.0.1-pre.3259",
|
|
59
|
+
"@openmrs/esm-extensions": "7.0.1-pre.3259",
|
|
60
|
+
"@openmrs/esm-feature-flags": "7.0.1-pre.3259",
|
|
61
|
+
"@openmrs/esm-globals": "7.0.1-pre.3259",
|
|
62
|
+
"@openmrs/esm-utils": "7.0.1-pre.3259",
|
|
63
63
|
"@swc/cli": "^0.7.7",
|
|
64
64
|
"@swc/core": "^1.11.29",
|
|
65
65
|
"concurrently": "^9.1.2",
|
package/src/loaders/pages.ts
CHANGED
|
@@ -112,7 +112,6 @@ export function registerApp(appName: string, routes: OpenmrsAppRoutes) {
|
|
|
112
112
|
) {
|
|
113
113
|
pages.push({
|
|
114
114
|
...p,
|
|
115
|
-
order: p.order ?? Number.MAX_SAFE_INTEGER,
|
|
116
115
|
appName,
|
|
117
116
|
});
|
|
118
117
|
} else {
|
|
@@ -187,24 +186,20 @@ export function registerApp(appName: string, routes: OpenmrsAppRoutes) {
|
|
|
187
186
|
|
|
188
187
|
/**
|
|
189
188
|
* This is called by the app shell once all route entries have been processed.
|
|
190
|
-
* This
|
|
191
|
-
*
|
|
192
|
-
* order definition, especially because certain pages _must_ be first in the DOM.
|
|
193
|
-
*
|
|
194
|
-
* Each page is rendered into a div with an appropriate name.
|
|
189
|
+
* This registers the pages with the application, and creates the root div
|
|
190
|
+
* for each page in the DOM element specified by the page's containerDomId.
|
|
195
191
|
*/
|
|
196
192
|
export function finishRegisteringAllApps() {
|
|
197
193
|
pages.sort((a, b) => {
|
|
198
|
-
let sort = a.order - b.order;
|
|
199
|
-
if (sort != 0) {
|
|
200
|
-
return sort;
|
|
201
|
-
}
|
|
202
194
|
return a.appName.localeCompare(b.appName, 'en');
|
|
203
195
|
});
|
|
204
196
|
|
|
205
|
-
// Create a div for each page
|
|
197
|
+
// Create a div for each page, unless the DOM already contains the div with
|
|
198
|
+
// the expected id for the page to be mounted on. See:
|
|
199
|
+
// https://single-spa.js.org/docs/configuration/#two-registered-applications-simultaneously
|
|
200
|
+
// The div is put inside the DOM element specified by the page's containerDomId.
|
|
206
201
|
// If we don't do this, Single-SPA 5 will create the DOM element only once
|
|
207
|
-
// the page becomes active,
|
|
202
|
+
// the page becomes active, at the end of <body>.
|
|
208
203
|
let appIndices = new Map();
|
|
209
204
|
for (let page of pages) {
|
|
210
205
|
if (!appIndices.has(page.appName)) {
|
|
@@ -215,9 +210,19 @@ export function finishRegisteringAllApps() {
|
|
|
215
210
|
const index = appIndices.get(page.appName);
|
|
216
211
|
|
|
217
212
|
const name = `${page.appName}-page-${index}`;
|
|
218
|
-
const
|
|
219
|
-
|
|
220
|
-
|
|
213
|
+
const containerDomId = page.containerDomId ?? 'omrs-apps-container';
|
|
214
|
+
const containerDiv = document.getElementById(containerDomId);
|
|
215
|
+
const appDomRootId = `single-spa-application:${name}`;
|
|
216
|
+
|
|
217
|
+
if (containerDiv) {
|
|
218
|
+
const div = document.createElement('div');
|
|
219
|
+
div.id = appDomRootId;
|
|
220
|
+
containerDiv?.appendChild(div);
|
|
221
|
+
} else {
|
|
222
|
+
throw new Error(
|
|
223
|
+
`${page.appName} ${page.component} cannot be mounted to "${containerDomId}"; DOM element does not exist.`,
|
|
224
|
+
);
|
|
225
|
+
}
|
|
221
226
|
tryRegisterPage(name, page);
|
|
222
227
|
}
|
|
223
228
|
}
|