@blocklet/pages-kit-block-studio 0.4.70 → 0.4.71

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.
@@ -39,7 +39,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
39
39
  return (mod && mod.__esModule) ? mod : { "default": mod };
40
40
  };
41
41
  Object.defineProperty(exports, "__esModule", { value: true });
42
- exports.safeParse = exports.getBlockCode = exports.isPagesKitBlockStudio = exports.getPreviewImageRelativePath = exports.downloadAsset = exports.isMetadataFile = exports.isDev = exports.isPathSafe = exports.logger = void 0;
42
+ exports.safeParse = exports.getBlockCode = exports.getPreviewImageRelativePath = exports.downloadAsset = exports.isMetadataFile = exports.isDev = exports.isPathSafe = exports.logger = void 0;
43
43
  exports.setBlockEntryFilesPattern = setBlockEntryFilesPattern;
44
44
  exports.getBlockEntryFilesPattern = getBlockEntryFilesPattern;
45
45
  exports.findComponentFiles = findComponentFiles;
@@ -130,7 +130,7 @@ const downloadAsset = async ({ asset, savePath, componentDid, }) => {
130
130
  await (0, promises_1.mkdir)(path_1.default.dirname(savePath), { recursive: true });
131
131
  // download asset from pages-kit's /uploads
132
132
  const res = await (0, component_1.call)({
133
- name: process.env.BLOCKLET_COMPONENT_DID,
133
+ name: componentDid,
134
134
  path: (0, ufo_1.joinURL)('/uploads', fileName),
135
135
  responseType: 'stream',
136
136
  method: 'GET',
@@ -158,7 +158,7 @@ function initializeMetadata(tempFilePath) {
158
158
  if (!filePath) {
159
159
  throw new Error('File path is required');
160
160
  }
161
- if (exports.isPagesKitBlockStudio && fs_1.default.existsSync(filePath)) {
161
+ if (fs_1.default.existsSync(filePath)) {
162
162
  content = fs_1.default.readFileSync(filePath, 'utf-8');
163
163
  }
164
164
  let metadata = {};
@@ -186,7 +186,7 @@ function initializeMetadata(tempFilePath) {
186
186
  if (!metadata.name) {
187
187
  metadata.name = getBlockName(filePath);
188
188
  }
189
- if (exports.isPagesKitBlockStudio && !fs_1.default.existsSync(filePath)) {
189
+ if (!fs_1.default.existsSync(filePath)) {
190
190
  fs_1.default.writeFileSync(filePath, JSON.stringify(metadata, null, 2));
191
191
  }
192
192
  return metadata;
@@ -197,7 +197,6 @@ function generateYaml(metadata) {
197
197
  function getBlockStudioInfo() {
198
198
  return config_1.default.components.find((c) => c.did === constants_1.PAGES_KIT_BLOCK_STUDIO_DID);
199
199
  }
200
- exports.isPagesKitBlockStudio = process.env.BLOCKLET_COMPONENT_DID === constants_1.PAGES_KIT_BLOCK_STUDIO_DID;
201
200
  const getBlockCode = (filePath) => {
202
201
  // Check path safety first
203
202
  if (!(0, exports.isPathSafe)(filePath)) {
@@ -98,6 +98,7 @@ initBlockStudioRouter.post('/', async (req, res) => {
98
98
  await downloadAsset({
99
99
  asset: content.previewImage,
100
100
  savePath: previewImagePath,
101
+ // current blocklet did
101
102
  componentDid: process.env.BLOCKLET_COMPONENT_DID || '',
102
103
  });
103
104
  }