@blocklet/pages-kit-block-studio 0.6.15 → 0.6.17

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.
@@ -198,6 +198,40 @@ exports.initBlockStudioRouter.post('/', async (req, res) => {
198
198
  });
199
199
  }
200
200
  }
201
+ // check if the properties has mediaKitUrl
202
+ if ((0, helper_1.isMetadataFile)(filePath) && content.properties) {
203
+ const downloadPromises = [];
204
+ Object.keys(content.properties).forEach((key) => {
205
+ const property = content.properties[key].data;
206
+ if (property.type === 'url') {
207
+ Object.keys(property.locales).forEach((locale) => {
208
+ if (property.locales[locale].defaultValue?.mediaKitUrl?.startsWith('mediakit://')) {
209
+ const downloadPromise = (async () => {
210
+ try {
211
+ const fileName = path_1.default.basename(property.locales[locale].defaultValue.mediaKitUrl);
212
+ const targetPath = path_1.default.join(dir, (0, helper_1.getPreviewImageRelativePath)(fileName));
213
+ if (fs_1.default.existsSync(targetPath)) {
214
+ return;
215
+ }
216
+ await (0, helper_1.downloadAsset)({
217
+ asset: fileName,
218
+ savePath: targetPath,
219
+ componentDid: process.env.BLOCKLET_COMPONENT_DID || '',
220
+ });
221
+ }
222
+ catch (error) {
223
+ console.error('Download media kit file failed:', error.message);
224
+ }
225
+ })();
226
+ downloadPromises.push(downloadPromise);
227
+ }
228
+ });
229
+ }
230
+ });
231
+ if (downloadPromises.length > 0) {
232
+ await Promise.allSettled(downloadPromises);
233
+ }
234
+ }
201
235
  fs_1.default.writeFileSync(filePath, JSON.stringify(mergedContent, null, 2));
202
236
  return res.json({ success: true, content: mergedContent, message: 'Updated' });
203
237
  }