@blocklet/resolver 1.16.23-beta-abdda301 → 1.16.23-beta-035db744
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/index.js +12 -30
- package/package.json +7 -6
package/index.js
CHANGED
|
@@ -77,8 +77,7 @@ const validateBlockletMeta = (meta, opts = {}) => {
|
|
|
77
77
|
exports.validateBlockletMeta = validateBlockletMeta;
|
|
78
78
|
const getComponentConfig = (meta) => {
|
|
79
79
|
const components = meta.components || meta.children || [];
|
|
80
|
-
|
|
81
|
-
return [...components, ...staticComponents];
|
|
80
|
+
return components;
|
|
82
81
|
};
|
|
83
82
|
exports.getComponentConfig = getComponentConfig;
|
|
84
83
|
const parseComponents = async (component, context = {}, logger = console) => {
|
|
@@ -90,21 +89,10 @@ const parseComponents = async (component, context = {}, logger = console) => {
|
|
|
90
89
|
const configs = (0, exports.getComponentConfig)(component.meta) || [];
|
|
91
90
|
if (!configs || !configs.length) {
|
|
92
91
|
return {
|
|
93
|
-
staticComponents: [],
|
|
94
92
|
dynamicComponents,
|
|
95
93
|
};
|
|
96
94
|
}
|
|
97
|
-
const staticComponents = [];
|
|
98
|
-
for (const config of configs) {
|
|
99
|
-
const isStatic = !!config.static;
|
|
100
|
-
if (isStatic) {
|
|
101
|
-
if (!config.name) {
|
|
102
|
-
throw new Error(`Name does not found in child ${config.name}`);
|
|
103
|
-
}
|
|
104
|
-
}
|
|
105
|
-
}
|
|
106
95
|
await Promise.all(configs.map(async (config) => {
|
|
107
|
-
const isStatic = !!config.static;
|
|
108
96
|
const urls = (0, util_meta_1.getSourceUrlsFromConfig)(config);
|
|
109
97
|
let rawMeta;
|
|
110
98
|
try {
|
|
@@ -120,7 +108,7 @@ const parseComponents = async (component, context = {}, logger = console) => {
|
|
|
120
108
|
if ((0, util_1.hasStartEngine)(rawMeta) && !(0, util_1.findWebInterface)(rawMeta)) {
|
|
121
109
|
throw new Error(`Web interface does not found in component ${rawMeta.title || rawMeta.name}`);
|
|
122
110
|
}
|
|
123
|
-
const meta = (0, exports.ensureMeta)(rawMeta
|
|
111
|
+
const meta = (0, exports.ensureMeta)(rawMeta);
|
|
124
112
|
// check circular dependencies
|
|
125
113
|
if (ancestors.map((x) => x.meta?.bundleDid).indexOf(meta.bundleDid) > -1) {
|
|
126
114
|
throw new Error('Blocklet components have circular dependencies');
|
|
@@ -132,7 +120,7 @@ const parseComponents = async (component, context = {}, logger = console) => {
|
|
|
132
120
|
if (config.description) {
|
|
133
121
|
meta.description = await schema_1.descriptionSchema.validateAsync(config.description);
|
|
134
122
|
}
|
|
135
|
-
const mountPoint =
|
|
123
|
+
const mountPoint = config.mountPoint || `/${meta.did}`;
|
|
136
124
|
const child = {
|
|
137
125
|
mountPoint,
|
|
138
126
|
meta,
|
|
@@ -140,25 +128,19 @@ const parseComponents = async (component, context = {}, logger = console) => {
|
|
|
140
128
|
dependencies: [],
|
|
141
129
|
children: [],
|
|
142
130
|
};
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
did: child.meta.bundleDid,
|
|
152
|
-
required: !!config.required,
|
|
153
|
-
version: config.source.version || 'latest',
|
|
154
|
-
});
|
|
155
|
-
}
|
|
131
|
+
// @ts-ignore
|
|
132
|
+
dynamicComponents.push(child);
|
|
133
|
+
component.dependencies = component.dependencies || [];
|
|
134
|
+
component.dependencies.push({
|
|
135
|
+
did: child.meta.bundleDid,
|
|
136
|
+
required: !!config.required,
|
|
137
|
+
version: config.source.version || 'latest',
|
|
138
|
+
});
|
|
156
139
|
// @ts-ignore
|
|
157
140
|
await (0, exports.parseComponents)(child, { ancestors: [...ancestors, { meta }], dynamicComponents });
|
|
158
141
|
}));
|
|
159
|
-
component.children =
|
|
142
|
+
component.children = [];
|
|
160
143
|
return {
|
|
161
|
-
staticComponents,
|
|
162
144
|
dynamicComponents,
|
|
163
145
|
};
|
|
164
146
|
};
|
package/package.json
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
"publishConfig": {
|
|
4
4
|
"access": "public"
|
|
5
5
|
},
|
|
6
|
-
"version": "1.16.23-beta-
|
|
6
|
+
"version": "1.16.23-beta-035db744",
|
|
7
7
|
"description": "Blocklet meta resolver",
|
|
8
8
|
"main": "index.js",
|
|
9
9
|
"files": [
|
|
@@ -15,19 +15,20 @@
|
|
|
15
15
|
"test": "NODE_ENV=test node tools/jest.js",
|
|
16
16
|
"coverage": "npm run test -- --coverage",
|
|
17
17
|
"clean": "rm -f index.d.ts index.js",
|
|
18
|
+
"build:blocklet-resolver": "npm run build",
|
|
18
19
|
"build": "npm run clean && tsc"
|
|
19
20
|
},
|
|
20
21
|
"author": "wangshijun <wangshijun2010@gmail.com> (http://github.com/wangshijun)",
|
|
21
22
|
"license": "Apache-2.0",
|
|
22
23
|
"dependencies": {
|
|
23
|
-
"@arcblock/did": "^1.18.
|
|
24
|
-
"@blocklet/constant": "1.16.23-beta-
|
|
25
|
-
"@blocklet/meta": "1.16.23-beta-
|
|
24
|
+
"@arcblock/did": "^1.18.110",
|
|
25
|
+
"@blocklet/constant": "1.16.23-beta-035db744",
|
|
26
|
+
"@blocklet/meta": "1.16.23-beta-035db744",
|
|
26
27
|
"lru-cache": "^6.0.0",
|
|
27
28
|
"semver": "^7.3.8"
|
|
28
29
|
},
|
|
29
30
|
"devDependencies": {
|
|
30
|
-
"@abtnode/types": "1.16.23-beta-
|
|
31
|
+
"@abtnode/types": "1.16.23-beta-035db744",
|
|
31
32
|
"@arcblock/eslint-config-ts": "^0.2.4",
|
|
32
33
|
"@types/jest": "^29.5.11",
|
|
33
34
|
"@types/node": "^18.11.0",
|
|
@@ -39,5 +40,5 @@
|
|
|
39
40
|
"ts-jest": "^29.1.1",
|
|
40
41
|
"typescript": "^5.0.4"
|
|
41
42
|
},
|
|
42
|
-
"gitHead": "
|
|
43
|
+
"gitHead": "43b1f85fa413b81be8b8015031ac271a9d9f3456"
|
|
43
44
|
}
|