@blocklet/resolver 1.16.25-beta-4f765cf3 → 1.16.25-beta-708d1e12

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.
Files changed (2) hide show
  1. package/index.js +15 -7
  2. package/package.json +5 -5
package/index.js CHANGED
@@ -172,6 +172,9 @@ const filterRequiredComponents = (component, children) => {
172
172
  };
173
173
  exports.filterRequiredComponents = filterRequiredComponents;
174
174
  const dynamicComponentsCache = new lru_cache_1.default({ max: 300, maxAge: 60 * 60 * 1000 * 3 }); // 3 hours
175
+ const getComponentName = (component) => {
176
+ return component.source?.name || component.name;
177
+ };
175
178
  const parseOptionalComponents = async (blocklet, logger = console) => {
176
179
  const { children } = blocklet || {};
177
180
  if (!children || !children.length) {
@@ -185,13 +188,14 @@ const parseOptionalComponents = async (blocklet, logger = console) => {
185
188
  const dependenciesMap = {};
186
189
  children.forEach((child) => {
187
190
  child.meta.components?.forEach((component) => {
188
- if (!childrenNames.has(component.name)) {
191
+ const name = getComponentName(component);
192
+ if (!childrenNames.has(name)) {
189
193
  hasOptionalChildren.add(child.meta.did);
190
- optionalNames.add(component.name);
191
- if (!dependenciesMap[component.name]) {
192
- dependenciesMap[component.name] = [];
194
+ optionalNames.add(name);
195
+ if (!dependenciesMap[name]) {
196
+ dependenciesMap[name] = [];
193
197
  }
194
- dependenciesMap[component.name].push({
198
+ dependenciesMap[name].push({
195
199
  parentDid: child.meta.did,
196
200
  parentName: child.meta.name,
197
201
  parentTitle: child.meta.title,
@@ -206,7 +210,10 @@ const parseOptionalComponents = async (blocklet, logger = console) => {
206
210
  // eslint-disable-next-line no-continue
207
211
  continue;
208
212
  }
209
- const hasNotFetchChild = child.meta.components.find((component) => !childrenNames.has(component.name) && !appendNames.has(component.name));
213
+ const hasNotFetchChild = child.meta.components.find((component) => {
214
+ const name = getComponentName(component);
215
+ return !childrenNames.has(name) && !appendNames.has(name);
216
+ });
210
217
  if (!hasNotFetchChild) {
211
218
  // eslint-disable-next-line no-continue
212
219
  continue;
@@ -220,7 +227,7 @@ const parseOptionalComponents = async (blocklet, logger = console) => {
220
227
  }
221
228
  for (const component of dynamicComponents) {
222
229
  const { mountPoint, bundleSource, meta } = component;
223
- if (!optionalNames.has(meta.name) || appendNames.has(meta.name)) {
230
+ if ((optionalNames.has(meta.name) || optionalNames.has(meta.did)) === false || appendNames.has(meta.did) || appendNames.has(meta.name)) {
224
231
  // eslint-disable-next-line no-continue
225
232
  continue;
226
233
  }
@@ -232,6 +239,7 @@ const parseOptionalComponents = async (blocklet, logger = console) => {
232
239
  meta,
233
240
  };
234
241
  appendNames.add(optionalChild.meta.name);
242
+ appendNames.add(optionalChild.meta.did);
235
243
  optionalComponents.push(optionalChild);
236
244
  }
237
245
  }
package/package.json CHANGED
@@ -3,7 +3,7 @@
3
3
  "publishConfig": {
4
4
  "access": "public"
5
5
  },
6
- "version": "1.16.25-beta-4f765cf3",
6
+ "version": "1.16.25-beta-708d1e12",
7
7
  "description": "Blocklet meta resolver",
8
8
  "main": "index.js",
9
9
  "files": [
@@ -22,13 +22,13 @@
22
22
  "license": "Apache-2.0",
23
23
  "dependencies": {
24
24
  "@arcblock/did": "^1.18.113",
25
- "@blocklet/constant": "1.16.25-beta-4f765cf3",
26
- "@blocklet/meta": "1.16.25-beta-4f765cf3",
25
+ "@blocklet/constant": "1.16.25-beta-708d1e12",
26
+ "@blocklet/meta": "1.16.25-beta-708d1e12",
27
27
  "lru-cache": "^6.0.0",
28
28
  "semver": "^7.3.8"
29
29
  },
30
30
  "devDependencies": {
31
- "@abtnode/types": "1.16.25-beta-4f765cf3",
31
+ "@abtnode/types": "1.16.25-beta-708d1e12",
32
32
  "@arcblock/eslint-config-ts": "^0.2.4",
33
33
  "@types/jest": "^29.5.11",
34
34
  "@types/node": "^18.11.0",
@@ -40,5 +40,5 @@
40
40
  "ts-jest": "^29.1.1",
41
41
  "typescript": "^5.0.4"
42
42
  },
43
- "gitHead": "7783a4bf883bb44b4266651b04008ef65bf6c2ce"
43
+ "gitHead": "2abdc1c1a5c3c74926052acee6fed3cb99e96714"
44
44
  }