@blocklet/pages-kit-block-studio 0.1.2 → 0.1.4

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.
@@ -43,11 +43,6 @@ exports.initBlockStudioRouter.get('/', (req, res) => __awaiter(void 0, void 0, v
43
43
  return fs_1.default.createReadStream(filePath).pipe(res);
44
44
  }
45
45
  const metadata = (0, helper_1.initializeMetadata)(filePath);
46
- const code = (0, helper_1.getBlockCode)(filePath);
47
- if (code) {
48
- (0, lodash_1.set)(metadata, 'renderer.script', code);
49
- (0, lodash_1.set)(metadata, 'renderer.type', 'react-component');
50
- }
51
46
  return res.json(metadata);
52
47
  }
53
48
  catch (error) {
@@ -87,11 +82,8 @@ exports.initBlockStudioRouter.post('/', (req, res) => __awaiter(void 0, void 0,
87
82
  });
88
83
  }
89
84
  }
90
- res.json({ success: true, content: mergedContent, message: 'Updated' });
91
- // save metadata without renderer after response
92
- delete mergedContent.renderer;
93
85
  fs_1.default.writeFileSync(filePath, JSON.stringify(mergedContent, null, 2));
94
- return null;
86
+ return res.json({ success: true, content: mergedContent, message: 'Updated' });
95
87
  }
96
88
  catch (error) {
97
89
  return res.status(500).json({ error: 'Failed to write file' });
@@ -47,6 +47,7 @@ exports.initBlockStudioPlugins = initBlockStudioPlugins;
47
47
  // import typescript from '@rollup/plugin-typescript';
48
48
  const fs_1 = require("fs");
49
49
  const path = __importStar(require("path"));
50
+ const ufo_1 = require("ufo");
50
51
  const vite_plugin_react_pages_1 = __importStar(require("vite-plugin-react-pages"));
51
52
  const helper_1 = require("../utils/helper");
52
53
  const vite_plugin_html_transform_1 = require("./vite-plugin-html-transform");
@@ -162,21 +163,23 @@ function initBlockStudioPlugins(options) {
162
163
  const pageId = `/${blockName}`;
163
164
  const dirPath = path.dirname(filePath);
164
165
  const metadataPath = path.join(dirPath, '@metadata.json');
166
+ const dataPath = isHtml ? `${vite_plugin_html_transform_1.VIRTUAL_MODULE_ID}?dir=${dirPath}` : filePath;
165
167
  api.addPageData({
166
168
  pageId,
167
- dataPath: isHtml ? `${vite_plugin_html_transform_1.VIRTUAL_MODULE_ID}?dir=${dirPath}` : filePath,
169
+ dataPath,
168
170
  staticData: isHtml
169
171
  ? {
170
- isHtmlPreview: true,
171
- dataPath: filePath,
172
+ isHtml: true,
173
+ dataPath,
172
174
  code: (0, vite_plugin_html_transform_1.generateComponent)((0, vite_plugin_html_transform_1.readHtmlFiles)(dirPath)),
173
175
  blockName,
174
176
  dirPath,
177
+ importPath: (0, ufo_1.joinURL)('@id', dataPath),
175
178
  metadataPath,
176
179
  }
177
- : Object.assign(Object.assign({}, (yield helpers.extractStaticData(file))), { code: (0, fs_1.readFileSync)(file.path, 'utf-8'), dataPath: filePath, blockName,
178
- dirPath,
179
- metadataPath }),
180
+ : Object.assign(Object.assign({}, (yield helpers.extractStaticData(file))), { code: (0, fs_1.readFileSync)(file.path, 'utf-8'), dataPath,
181
+ blockName,
182
+ dirPath, importPath: (0, ufo_1.joinURL)('@fs', dataPath), metadataPath }),
180
183
  });
181
184
  });
182
185
  });