@abtnode/core 1.16.11-next-6f30b7db → 1.16.11-next-bd38e3c7

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.
@@ -134,7 +134,7 @@ class BlockletDownloader extends EventEmitter {
134
134
 
135
135
  const { preDownload = () => {}, postDownload = () => {}, skipCheckIntegrity, onProgress = () => {} } = options;
136
136
 
137
- const { downloadComponentIds, downloadList } = await this.getDownloadList({
137
+ const { downloadComponentIds, downloadList, skipList } = await this.getDownloadList({
138
138
  blocklet,
139
139
  skipCheckIntegrity,
140
140
  });
@@ -142,24 +142,35 @@ class BlockletDownloader extends EventEmitter {
142
142
  await preDownload({ downloadList, downloadComponentIds });
143
143
 
144
144
  try {
145
+ // Fake progress events for cached bundles
146
+ skipList.forEach((meta) => {
147
+ const info = pick(meta, ['title', 'name', 'did', 'version']);
148
+ onProgress({ status: 'downloading', component: info });
149
+ setTimeout(
150
+ () => {
151
+ onProgress({ status: 'completed', component: info });
152
+ },
153
+ process.env.NODE_ENV === 'test' ? 0 : Math.random() * 800
154
+ );
155
+ });
156
+
145
157
  this.logger.info('Start Download Blocklet', {
146
158
  name,
147
159
  did,
148
160
  bundles: downloadList.map((x) => get(x, 'dist.tarball')),
149
161
  });
150
- const tasks = [];
151
- for (const meta of downloadList) {
152
- const url = meta.dist.tarball;
153
- tasks.push(
154
- this.bundleDownloader.download(meta, did, url, {
162
+
163
+ const results = await Promise.all(
164
+ downloadList.map(async (meta) => {
165
+ const url = meta.dist.tarball;
166
+ return this.bundleDownloader.download(meta, did, url, {
155
167
  ...options,
156
168
  onProgress: (data) => {
157
169
  onProgress({ ...data, component: pick(meta, ['title', 'name', 'did', 'version']) });
158
170
  },
159
- })
160
- );
161
- }
162
- const results = await Promise.all(tasks);
171
+ });
172
+ })
173
+ );
163
174
 
164
175
  const isCancelled = results.some((x) => x.isCancelled);
165
176
 
@@ -187,19 +198,21 @@ class BlockletDownloader extends EventEmitter {
187
198
  * }}
188
199
  * @returns {{
189
200
  * downloadList: Array<import('@abtnode/client').BlockletMeta>;
201
+ * skipList: Array<import('@abtnode/client').BlockletMeta>;
190
202
  * downloadComponentIds: Array<string>; // like: "z8ia1i2yq67x39vruqQTbkVcwCnqRGx8zSPsJ/z8iZwubkNdA1BfEUwc5NJpY2Jnfm7yEbyvmKS"
191
203
  * }}
192
204
  */
193
205
  async getDownloadList({ blocklet, skipCheckIntegrity }) {
194
206
  const downloadComponentIds = [];
195
- const metas = {};
207
+ const scheduled = {};
208
+ const skipped = {};
196
209
 
197
210
  const cachedBundles = (await this.cache.get(CACHE_KEY)) || [];
198
211
 
199
212
  forEachComponentV2Sync(blocklet, (component) => {
200
213
  const bundleId = getComponentBundleId(component);
201
214
 
202
- if (metas[bundleId]) {
215
+ if (scheduled[bundleId]) {
203
216
  this.logger.info(`skip download duplicate bundle ${bundleId}`);
204
217
  return;
205
218
  }
@@ -210,6 +223,7 @@ class BlockletDownloader extends EventEmitter {
210
223
  skipCheckIntegrity,
211
224
  });
212
225
  if (!needComponentDownload) {
226
+ skipped[bundleId] = component.meta;
213
227
  this.logger.info(`skip download existed bundle ${bundleId}`, { source: component.source });
214
228
  return;
215
229
  }
@@ -222,13 +236,14 @@ class BlockletDownloader extends EventEmitter {
222
236
  return;
223
237
  }
224
238
 
225
- metas[bundleId] = component.meta;
239
+ scheduled[bundleId] = component.meta;
226
240
  downloadComponentIds.push(component.meta.did);
227
241
  });
228
242
 
229
- const downloadList = Object.values(metas);
243
+ const downloadList = Object.values(scheduled);
244
+ const skipList = Object.values(skipped);
230
245
 
231
- return { downloadList, downloadComponentIds };
246
+ return { downloadList, skipList, downloadComponentIds };
232
247
  }
233
248
  }
234
249
 
@@ -138,7 +138,7 @@ const setupAppOwner = async (node, sessionId) => {
138
138
  userDid: ownerDid,
139
139
  teamDid: appDid,
140
140
  }),
141
- ownerProfile: { ...appOwnerProfile, avatar: parseUserAvatar(user.avatar, { dataDir: serverDataDir }) },
141
+ ownerProfile: { ...appOwnerProfile, avatar: await parseUserAvatar(user.avatar, { dataDir: serverDataDir }) },
142
142
  preferredColor: 'default',
143
143
  expirationDate: undefined,
144
144
  });
package/package.json CHANGED
@@ -3,7 +3,7 @@
3
3
  "publishConfig": {
4
4
  "access": "public"
5
5
  },
6
- "version": "1.16.11-next-6f30b7db",
6
+ "version": "1.16.11-next-bd38e3c7",
7
7
  "description": "",
8
8
  "main": "lib/index.js",
9
9
  "files": [
@@ -19,18 +19,18 @@
19
19
  "author": "wangshijun <wangshijun2010@gmail.com> (http://github.com/wangshijun)",
20
20
  "license": "Apache-2.0",
21
21
  "dependencies": {
22
- "@abtnode/auth": "1.16.11-next-6f30b7db",
23
- "@abtnode/certificate-manager": "1.16.11-next-6f30b7db",
24
- "@abtnode/constant": "1.16.11-next-6f30b7db",
25
- "@abtnode/cron": "1.16.11-next-6f30b7db",
26
- "@abtnode/logger": "1.16.11-next-6f30b7db",
27
- "@abtnode/models": "1.16.11-next-6f30b7db",
28
- "@abtnode/queue": "1.16.11-next-6f30b7db",
29
- "@abtnode/rbac": "1.16.11-next-6f30b7db",
30
- "@abtnode/router-provider": "1.16.11-next-6f30b7db",
31
- "@abtnode/static-server": "1.16.11-next-6f30b7db",
32
- "@abtnode/timemachine": "1.16.11-next-6f30b7db",
33
- "@abtnode/util": "1.16.11-next-6f30b7db",
22
+ "@abtnode/auth": "1.16.11-next-bd38e3c7",
23
+ "@abtnode/certificate-manager": "1.16.11-next-bd38e3c7",
24
+ "@abtnode/constant": "1.16.11-next-bd38e3c7",
25
+ "@abtnode/cron": "1.16.11-next-bd38e3c7",
26
+ "@abtnode/logger": "1.16.11-next-bd38e3c7",
27
+ "@abtnode/models": "1.16.11-next-bd38e3c7",
28
+ "@abtnode/queue": "1.16.11-next-bd38e3c7",
29
+ "@abtnode/rbac": "1.16.11-next-bd38e3c7",
30
+ "@abtnode/router-provider": "1.16.11-next-bd38e3c7",
31
+ "@abtnode/static-server": "1.16.11-next-bd38e3c7",
32
+ "@abtnode/timemachine": "1.16.11-next-bd38e3c7",
33
+ "@abtnode/util": "1.16.11-next-bd38e3c7",
34
34
  "@arcblock/did": "1.18.80",
35
35
  "@arcblock/did-auth": "1.18.80",
36
36
  "@arcblock/did-ext": "^1.18.80",
@@ -41,9 +41,9 @@
41
41
  "@arcblock/pm2-events": "^0.0.5",
42
42
  "@arcblock/validator": "^1.18.80",
43
43
  "@arcblock/vc": "1.18.80",
44
- "@blocklet/constant": "1.16.11-next-6f30b7db",
45
- "@blocklet/meta": "1.16.11-next-6f30b7db",
46
- "@blocklet/sdk": "1.16.11-next-6f30b7db",
44
+ "@blocklet/constant": "1.16.11-next-bd38e3c7",
45
+ "@blocklet/meta": "1.16.11-next-bd38e3c7",
46
+ "@blocklet/sdk": "1.16.11-next-bd38e3c7",
47
47
  "@did-space/client": "^0.2.113",
48
48
  "@fidm/x509": "^1.2.1",
49
49
  "@ocap/mcrypto": "1.18.80",
@@ -96,5 +96,5 @@
96
96
  "express": "^4.18.2",
97
97
  "jest": "^27.5.1"
98
98
  },
99
- "gitHead": "e54aafa5516a086257a94e4b162cb8dcd047531a"
99
+ "gitHead": "d42f3cbfe1702f0dfa184e1db1587f26a05804aa"
100
100
  }