@blocklet/resolver 1.16.27 → 1.16.28-beta-bfbab430

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 +21 -2
  2. package/package.json +5 -5
package/index.js CHANGED
@@ -15,6 +15,8 @@ const schema_1 = require("@blocklet/meta/lib/schema");
15
15
  const validate_1 = require("@blocklet/meta/lib/validate");
16
16
  const util_meta_1 = require("@blocklet/meta/lib/util-meta");
17
17
  const did_2 = __importDefault(require("@blocklet/meta/lib/did"));
18
+ const engine_1 = require("@blocklet/meta/lib/engine");
19
+ const url_path_friendly_1 = __importDefault(require("@blocklet/meta/lib/url-path-friendly"));
18
20
  const isDidMatchName = (did, name) => {
19
21
  if ((0, did_1.isValid)(did) && name === did) {
20
22
  return true;
@@ -77,6 +79,11 @@ const validateBlockletMeta = (meta, opts = {}) => {
77
79
  exports.validateBlockletMeta = validateBlockletMeta;
78
80
  const getComponentConfig = (meta) => {
79
81
  const components = meta.components || meta.children || [];
82
+ // treat engine as component
83
+ const engine = (0, engine_1.getBlockletEngine)(meta);
84
+ if (engine?.interpreter === 'blocklet') {
85
+ components.push({ source: engine.source, required: true });
86
+ }
80
87
  return components;
81
88
  };
82
89
  exports.getComponentConfig = getComponentConfig;
@@ -120,7 +127,7 @@ const parseComponents = async (component, context = {}, logger = console) => {
120
127
  if (config.description) {
121
128
  meta.description = await schema_1.descriptionSchema.validateAsync(config.description);
122
129
  }
123
- const mountPoint = config.mountPoint || `/${meta.did}`;
130
+ const mountPoint = config.mountPoint || `/${(0, url_path_friendly_1.default)(meta.title || meta.name || meta.did)}`.toLowerCase();
124
131
  const child = {
125
132
  mountPoint,
126
133
  meta,
@@ -136,6 +143,16 @@ const parseComponents = async (component, context = {}, logger = console) => {
136
143
  required: !!config.required,
137
144
  version: config.source.version || 'latest',
138
145
  });
146
+ // parse engine components recursively
147
+ const engine = (0, engine_1.getBlockletEngine)(meta);
148
+ if (engine?.interpreter === 'blocklet') {
149
+ await (0, exports.parseComponents)({
150
+ // @ts-ignore
151
+ meta: { components: [{ source: engine.source, required: true }] },
152
+ dependencies: [],
153
+ children: [],
154
+ }, { ancestors: [...ancestors, { meta }], dynamicComponents });
155
+ }
139
156
  // @ts-ignore
140
157
  await (0, exports.parseComponents)(child, { ancestors: [...ancestors, { meta }], dynamicComponents });
141
158
  }));
@@ -227,7 +244,9 @@ const parseOptionalComponents = async (blocklet, logger = console) => {
227
244
  }
228
245
  for (const component of dynamicComponents) {
229
246
  const { mountPoint, bundleSource, meta } = component;
230
- if ((optionalNames.has(meta.name) || optionalNames.has(meta.did)) === false || appendNames.has(meta.did) || appendNames.has(meta.name)) {
247
+ if ((optionalNames.has(meta.name) || optionalNames.has(meta.did)) === false ||
248
+ appendNames.has(meta.did) ||
249
+ appendNames.has(meta.name)) {
231
250
  // eslint-disable-next-line no-continue
232
251
  continue;
233
252
  }
package/package.json CHANGED
@@ -3,7 +3,7 @@
3
3
  "publishConfig": {
4
4
  "access": "public"
5
5
  },
6
- "version": "1.16.27",
6
+ "version": "1.16.28-beta-bfbab430",
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.123",
25
- "@blocklet/constant": "1.16.27",
26
- "@blocklet/meta": "1.16.27",
25
+ "@blocklet/constant": "1.16.28-beta-bfbab430",
26
+ "@blocklet/meta": "1.16.28-beta-bfbab430",
27
27
  "lru-cache": "^6.0.0",
28
28
  "semver": "^7.3.8"
29
29
  },
30
30
  "devDependencies": {
31
- "@abtnode/types": "1.16.27",
31
+ "@abtnode/types": "1.16.28-beta-bfbab430",
32
32
  "@arcblock/eslint-config-ts": "^0.3.0",
33
33
  "@types/jest": "^29.5.11",
34
34
  "@types/node": "^20.12.2",
@@ -40,5 +40,5 @@
40
40
  "ts-jest": "^29.1.1",
41
41
  "typescript": "^5.0.4"
42
42
  },
43
- "gitHead": "b7dcd46b040c5ad3a273b14b1a411fafc1390828"
43
+ "gitHead": "f1fbf0752de46be00d1faa0d54eb7d28016e0bb9"
44
44
  }