@openmrs/esm-dynamic-loading 6.3.1-pre.3105 → 6.3.1-pre.3119

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.
@@ -1,3 +1,3 @@
1
- [0] Successfully compiled: 3 files with swc (160.08ms)
1
+ [0] Successfully compiled: 3 files with swc (212.99ms)
2
2
  [0] swc --strip-leading-paths src -d dist exited with code 0
3
3
  [1] tsc --project tsconfig.build.json exited with code 0
@@ -41,7 +41,9 @@ import { getCoreTranslation } from "@openmrs/esm-translations";
41
41
  }, maxLoadingTime);
42
42
  })
43
43
  ]);
44
- timeout && clearTimeout(timeout);
44
+ if (timeout) {
45
+ clearTimeout(timeout);
46
+ }
45
47
  const jsPackageSlug = slugify(jsPackage);
46
48
  const container = window[jsPackageSlug];
47
49
  if (!isFederatedModule(container)) {
@@ -169,8 +171,12 @@ const OPENMRS_SCRIPT_LOADING = Symbol('__openmrs_script_loading');
169
171
  finishScriptLoading = ()=>{
170
172
  clearTimeout(loadTimeout);
171
173
  scriptLoading.delete(url);
172
- loadFn && element.removeEventListener('load', loadFn);
173
- errFn && element.removeEventListener('error', errFn);
174
+ if (loadFn) {
175
+ element.removeEventListener('load', loadFn);
176
+ }
177
+ if (errFn) {
178
+ element.removeEventListener('error', errFn);
179
+ }
174
180
  };
175
181
  loadFn = ()=>{
176
182
  finishScriptLoading();
@@ -189,8 +195,12 @@ const OPENMRS_SCRIPT_LOADING = Symbol('__openmrs_script_loading');
189
195
  if (scriptLoading.has(url)) {
190
196
  let loadFn, errFn, finishScriptLoading;
191
197
  finishScriptLoading = ()=>{
192
- loadFn && scriptElement.removeEventListener('load', loadFn);
193
- errFn && scriptElement.removeEventListener('error', errFn);
198
+ if (loadFn) {
199
+ scriptElement.removeEventListener('load', loadFn);
200
+ }
201
+ if (errFn) {
202
+ scriptElement.removeEventListener('error', errFn);
203
+ }
194
204
  };
195
205
  loadFn = ()=>{
196
206
  finishScriptLoading();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@openmrs/esm-dynamic-loading",
3
- "version": "6.3.1-pre.3105",
3
+ "version": "6.3.1-pre.3119",
4
4
  "license": "MPL-2.0",
5
5
  "description": "Utilities for dynamically loading code in OpenMRS",
6
6
  "type": "module",
@@ -52,8 +52,8 @@
52
52
  "@openmrs/esm-translations": "6.x"
53
53
  },
54
54
  "devDependencies": {
55
- "@openmrs/esm-globals": "6.3.1-pre.3105",
56
- "@openmrs/esm-translations": "6.3.1-pre.3105",
55
+ "@openmrs/esm-globals": "6.3.1-pre.3119",
56
+ "@openmrs/esm-translations": "6.3.1-pre.3119",
57
57
  "@swc/cli": "^0.7.7",
58
58
  "@swc/core": "^1.11.29",
59
59
  "concurrently": "^9.1.2",
@@ -57,7 +57,9 @@ export async function importDynamic<T = any>(
57
57
  }),
58
58
  ]);
59
59
 
60
- timeout && clearTimeout(timeout);
60
+ if (timeout) {
61
+ clearTimeout(timeout);
62
+ }
61
63
 
62
64
  const jsPackageSlug = slugify(jsPackage);
63
65
 
@@ -209,7 +211,7 @@ function loadScript(
209
211
  reject: (reason?: any) => void,
210
212
  ) {
211
213
  const scriptElement = document.head.querySelector(`script[src="${url}"]`);
212
- let scriptLoading: Set<String> = window[OPENMRS_SCRIPT_LOADING];
214
+ let scriptLoading: Set<string> = window[OPENMRS_SCRIPT_LOADING];
213
215
  if (!scriptLoading) {
214
216
  scriptLoading = window[OPENMRS_SCRIPT_LOADING] = new Set([]);
215
217
  }
@@ -233,8 +235,14 @@ function loadScript(
233
235
  finishScriptLoading = () => {
234
236
  clearTimeout(loadTimeout);
235
237
  scriptLoading.delete(url);
236
- loadFn && element.removeEventListener('load', loadFn);
237
- errFn && element.removeEventListener('error', errFn);
238
+
239
+ if (loadFn) {
240
+ element.removeEventListener('load', loadFn);
241
+ }
242
+
243
+ if (errFn) {
244
+ element.removeEventListener('error', errFn);
245
+ }
238
246
  };
239
247
 
240
248
  loadFn = () => {
@@ -258,8 +266,13 @@ function loadScript(
258
266
  let loadFn: () => void, errFn: (ev: ErrorEvent) => void, finishScriptLoading: () => void;
259
267
 
260
268
  finishScriptLoading = () => {
261
- loadFn && scriptElement.removeEventListener('load', loadFn);
262
- errFn && scriptElement.removeEventListener('error', errFn);
269
+ if (loadFn) {
270
+ scriptElement.removeEventListener('load', loadFn);
271
+ }
272
+
273
+ if (errFn) {
274
+ scriptElement.removeEventListener('error', errFn);
275
+ }
263
276
  };
264
277
 
265
278
  loadFn = () => {