@nectary/components 5.14.4 → 5.14.6

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": "@nectary/components",
3
- "version": "5.14.4",
3
+ "version": "5.14.6",
4
4
  "files": [
5
5
  "**/*/*.css",
6
6
  "**/*/*.json",
@@ -24,7 +24,7 @@
24
24
  },
25
25
  "dependencies": {
26
26
  "@babel/runtime": "^7.22.15",
27
- "@nectary/assets": "3.4.0"
27
+ "@nectary/assets": "3.4.2"
28
28
  },
29
29
  "devDependencies": {
30
30
  "@babel/cli": "^7.22.15",
@@ -43,27 +43,39 @@ class GlobalElementsManager {
43
43
  const store = getStore(this.config.storeKey);
44
44
  const importPath = this.getImportPath(store.cdnUrl, modulePath);
45
45
  const fallbackImportPath = this.getImportPath(store.fallbackCdnUrl, modulePath);
46
- try {
47
- const module = await import(
46
+ const promises = [
47
+ import(
48
48
  /* webpackIgnore: true */
49
49
  importPath
50
+ )
51
+ ];
52
+ let timeoutId = null;
53
+ const FALLBACK_DELAY_MS = 2e3;
54
+ if (fallbackImportPath !== null) {
55
+ promises.push(
56
+ new Promise((resolve) => {
57
+ timeoutId = setTimeout(() => resolve(import(
58
+ /* webpackIgnore: true */
59
+ fallbackImportPath
60
+ )), FALLBACK_DELAY_MS);
61
+ })
50
62
  );
63
+ }
64
+ try {
65
+ const module = await Promise.any(promises);
66
+ if (timeoutId !== null) {
67
+ clearTimeout(timeoutId);
68
+ }
51
69
  return module;
52
70
  } catch (error) {
53
- if (fallbackImportPath !== null) {
54
- try {
55
- const fallbackModule = await import(
56
- /* webpackIgnore: true */
57
- fallbackImportPath
58
- );
59
- return fallbackModule;
60
- } catch (fallbackError) {
61
- console.error(`Nectary Primary load failed: ${importPath}`, error);
62
- console.error(`Nectary fallback load failed: ${fallbackImportPath}`, fallbackError);
63
- throw fallbackError;
71
+ if (error instanceof AggregateError) {
72
+ console.error(`Nectary Primary load failed: ${importPath}`, error.errors[0]);
73
+ if (fallbackImportPath !== null) {
74
+ console.error(`Nectary fallback load failed: ${fallbackImportPath}`, error.errors[1]);
64
75
  }
76
+ } else {
77
+ console.error(`Nectary failed to load module: ${importPath}`, error);
65
78
  }
66
- console.error(`Nectary failed to load module: ${importPath}`, error);
67
79
  throw error;
68
80
  }
69
81
  }
@@ -122,12 +134,13 @@ class GlobalElementsManager {
122
134
  });
123
135
  };
124
136
  setDefinitions();
125
- if (store.targetlibVersion.length === 0) {
137
+ const host = new URL(store.cdnUrl).host;
138
+ if (host === "esm.sh" && store.targetlibVersion.length === 0 && store.preload === false) {
126
139
  const registry = await fetch(`${this.config.registryUrl}/latest`);
127
140
  const registryData = await registry.json();
128
141
  store.targetlibVersion = registryData.version;
142
+ setDefinitions();
129
143
  }
130
- setDefinitions();
131
144
  }
132
145
  } finally {
133
146
  store.loadPromise.resolve();