@openmrs/esm-app-shell 10.0.1-pre.5158 → 10.0.1-pre.5199

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@openmrs/esm-app-shell",
3
- "version": "10.0.1-pre.5158",
3
+ "version": "10.0.1-pre.5199",
4
4
  "license": "MPL-2.0",
5
5
  "main": "dist/openmrs.js",
6
6
  "scripts": {
@@ -35,8 +35,8 @@
35
35
  "dependencies": {
36
36
  "@carbon/react": "^1.92.1",
37
37
  "@internationalized/date": "^3.8.0",
38
- "@openmrs/esm-framework": "10.0.1-pre.5158",
39
- "@openmrs/esm-styleguide": "10.0.1-pre.5158",
38
+ "@openmrs/esm-framework": "10.0.1-pre.5199",
39
+ "@openmrs/esm-styleguide": "10.0.1-pre.5199",
40
40
  "@rspack/cli": "1.7.9",
41
41
  "@rspack/core": "1.7.9",
42
42
  "dayjs": "^1.11.13",
package/rspack.config.js CHANGED
@@ -432,7 +432,7 @@ module.exports = (env, argv = []) => {
432
432
  openmrsEnvironment,
433
433
  openmrsConfigUrls,
434
434
  openmrsCoreImportmap: appPatterns.length > 0 && JSON.stringify(coreImportmap),
435
- openmrsCoreRoutes: Object.keys(coreRoutes).length > 0 && JSON.stringify(coreRoutes),
435
+ openmrsCoreRoutes: Object.keys(coreRoutes).length > 0 && JSON.stringify({ routes: coreRoutes }),
436
436
  openmrsCssFilename,
437
437
  openmrsExtraAssets: openmrsJsCssAssets.map((fileName) => 'assets/' + basename(fileName)),
438
438
  },
package/src/run.ts CHANGED
@@ -2,12 +2,14 @@ import { start, triggerAppChange } from 'single-spa';
2
2
  import { type CalendarIdentifier } from '@internationalized/date';
3
3
  import {
4
4
  activateOfflineCapability,
5
+ type Config,
5
6
  dispatchConnectivityChanged,
6
7
  dispatchPrecacheStaticDependencies,
7
8
  type ExtensionDefinition,
8
9
  finishRegisteringAllApps,
9
10
  fireOpenmrsEvent,
10
11
  getConfig,
12
+ getCoreTranslation,
11
13
  getCurrentPageMap,
12
14
  getCurrentRouteMap,
13
15
  getCurrentUser,
@@ -15,6 +17,7 @@ import {
15
17
  interpolateUrl,
16
18
  messageOmrsServiceWorker,
17
19
  openmrsFetch,
20
+ type OpenmrsRoutes,
18
21
  provide,
19
22
  registerApp,
20
23
  registerDefaultCalendar,
@@ -41,9 +44,8 @@ import {
41
44
  subscribePrecacheStaticDependencies,
42
45
  subscribeSnackbarShown,
43
46
  subscribeToastShown,
44
- tryRegisterExtension,
45
- type Config,
46
47
  type StyleguideConfigObject,
48
+ tryRegisterExtension,
47
49
  } from '@openmrs/esm-framework/src/internal';
48
50
  import { setupI18n } from './locale';
49
51
  import './routing-events';
@@ -56,6 +58,8 @@ import { setupCoreConfig } from './core-config';
56
58
  // so we can pre-load all modules
57
59
  const REGISTRATION_PROMISES = Symbol('openmrs_registration_promises');
58
60
 
61
+ let initialRouteMap: OpenmrsRoutes;
62
+
59
63
  /**
60
64
  * Sets up the frontend modules (apps). Uses the defined export
61
65
  * from the root modules of the apps. This is done by reading the
@@ -64,10 +68,10 @@ const REGISTRATION_PROMISES = Symbol('openmrs_registration_promises');
64
68
  */
65
69
  async function setupApps() {
66
70
  await setupRouteMapOverrides();
67
- const routes = await getCurrentRouteMap();
71
+ const routes = (initialRouteMap = await getCurrentRouteMap());
68
72
 
69
73
  const modules: typeof window.installedModules = [];
70
- const registrationPromises = Object.entries(routes).map(async ([module, appRoutes]) => {
74
+ const registrationPromises = Object.entries(routes.routes).map(async ([module, appRoutes]) => {
71
75
  modules.push([module, appRoutes]);
72
76
  registerApp(module, appRoutes);
73
77
  });
@@ -114,16 +118,40 @@ function connectivityChanged() {
114
118
  * Runs the shell by importing the translations and starting single SPA.
115
119
  */
116
120
  async function runShell() {
117
- return setupI18n()
118
- .catch((err) => console.error(`Failed to initialize translations`, err))
119
- .then(async () => {
120
- const { preferredCalendar } = await getConfig<StyleguideConfigObject>('@openmrs/esm-styleguide');
121
+ try {
122
+ await setupI18n();
123
+ } catch (err) {
124
+ console.error(`Failed to initialize translation system`, err);
125
+ }
121
126
 
122
- for (const entry of Object.entries(preferredCalendar)) {
123
- registerDefaultCalendar(entry[0], entry[1] as CalendarIdentifier);
124
- }
125
- })
126
- .then(() => start());
127
+ const applicationVersion = initialRouteMap.version;
128
+ if (applicationVersion === undefined || applicationVersion === null || applicationVersion.trim().length === 0) {
129
+ Object.defineProperty(window, 'applicationVersion', {
130
+ value: undefined,
131
+ writable: false,
132
+ configurable: false,
133
+ });
134
+ } else if (applicationVersion === 'prerelease') {
135
+ Object.defineProperty(window, 'applicationVersion', {
136
+ value:
137
+ window.spaVersion === 'local' ? getCoreTranslation('localVersion') : getCoreTranslation('prereleaseVersion'),
138
+ writable: false,
139
+ configurable: false,
140
+ });
141
+ } else {
142
+ Object.defineProperty(window, 'applicationVersion', {
143
+ value: applicationVersion,
144
+ writable: false,
145
+ configurable: false,
146
+ });
147
+ }
148
+
149
+ const { preferredCalendar } = await getConfig<StyleguideConfigObject>('@openmrs/esm-styleguide');
150
+ for (const entry of Object.entries(preferredCalendar)) {
151
+ registerDefaultCalendar(entry[0], entry[1] as CalendarIdentifier);
152
+ }
153
+
154
+ start();
127
155
  }
128
156
 
129
157
  function handleInitFailure(e: Error) {