chayns-api 2.6.0-beta.7 → 2.6.0-beta.8

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.
@@ -4,32 +4,13 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.collectCssChunks = void 0;
7
- const remoteInfoCache = {};
8
- const loadRemoteInfo = async url => {
9
- if (!url.endsWith('/mf-manifest.json')) {
10
- return null;
11
- }
12
- if (remoteInfoCache[url]) {
13
- return remoteInfoCache[url];
14
- }
15
- const res = await fetch(url);
16
- if (res.status === 200) {
17
- const info = await res.json();
18
- remoteInfoCache[url] = info;
19
- return info;
20
- }
21
- if (res.status === 404) {
22
- remoteInfoCache[url] = null;
23
- return null;
24
- }
25
- throw new Error(`Could not load remote info from ${url}`);
26
- };
27
7
  const collectCssChunks = async modules => {
28
- const p = Object.values(modules).map(async module => {
29
- const info = await loadRemoteInfo(module.url);
8
+ const instance = globalThis.moduleFederationRuntime.getInstance();
9
+ const p = Object.values(modules).map(module => {
10
+ const info = instance.snapshotHandler.manifestCache.get(module.url);
30
11
  const chunks = [];
31
12
  info === null || info === void 0 || info.exposes.forEach(exposes => {
32
- if (module.modules.has(exposes.path)) {
13
+ if (exposes.path && module.modules.has(exposes.path)) {
33
14
  var _exposes$assets$css, _exposes$assets;
34
15
  const {
35
16
  sync = [],
@@ -43,7 +24,6 @@ const collectCssChunks = async modules => {
43
24
  });
44
25
  return chunks;
45
26
  });
46
- const r = await Promise.allSettled(p);
47
- return r.flatMap(v => v.status === 'fulfilled' ? v.value : []).join('');
27
+ return p.flat().join('');
48
28
  };
49
29
  exports.collectCssChunks = collectCssChunks;
@@ -1,29 +1,10 @@
1
- const remoteInfoCache = {};
2
- const loadRemoteInfo = async url => {
3
- if (!url.endsWith('/mf-manifest.json')) {
4
- return null;
5
- }
6
- if (remoteInfoCache[url]) {
7
- return remoteInfoCache[url];
8
- }
9
- const res = await fetch(url);
10
- if (res.status === 200) {
11
- const info = await res.json();
12
- remoteInfoCache[url] = info;
13
- return info;
14
- }
15
- if (res.status === 404) {
16
- remoteInfoCache[url] = null;
17
- return null;
18
- }
19
- throw new Error(`Could not load remote info from ${url}`);
20
- };
21
1
  export const collectCssChunks = async modules => {
22
- const p = Object.values(modules).map(async module => {
23
- const info = await loadRemoteInfo(module.url);
2
+ const instance = globalThis.moduleFederationRuntime.getInstance();
3
+ const p = Object.values(modules).map(module => {
4
+ const info = instance.snapshotHandler.manifestCache.get(module.url);
24
5
  const chunks = [];
25
6
  info === null || info === void 0 || info.exposes.forEach(exposes => {
26
- if (module.modules.has(exposes.path)) {
7
+ if (exposes.path && module.modules.has(exposes.path)) {
27
8
  var _exposes$assets$css, _exposes$assets;
28
9
  const {
29
10
  sync = [],
@@ -37,6 +18,5 @@ export const collectCssChunks = async modules => {
37
18
  });
38
19
  return chunks;
39
20
  });
40
- const r = await Promise.allSettled(p);
41
- return r.flatMap(v => v.status === 'fulfilled' ? v.value : []).join('');
21
+ return p.flat().join('');
42
22
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "chayns-api",
3
- "version": "2.6.0-beta.7",
3
+ "version": "2.6.0-beta.8",
4
4
  "description": "new chayns api",
5
5
  "main": "dist/cjs/index.js",
6
6
  "module": "dist/esm/index.js",