@blocklet/pages-kit-block-studio 0.0.17 → 0.0.18

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.
@@ -158,3 +158,21 @@ export function getBlockStudioInfo() {
158
158
  return config.components.find((c) => c.did === PAGES_KIT_BLOCK_STUDIO_DID);
159
159
  }
160
160
  export const isPagesKitBlockStudio = process.env.BLOCKLET_COMPONENT_DID === PAGES_KIT_BLOCK_STUDIO_DID;
161
+ export const getBlockCode = (filePath) => {
162
+ var _a;
163
+ // Check path safety first
164
+ if (!isPathSafe(filePath)) {
165
+ throw new Error('Invalid file path: path traversal detected');
166
+ }
167
+ const blockName = getBlockName(filePath);
168
+ // Find the actual code file using the block entry pattern
169
+ const files = findComponentFiles({ filter: [blockName] });
170
+ if (!files.length) {
171
+ throw new Error(`No code file found for block: ${blockName}`);
172
+ }
173
+ const codeFile = (_a = files[0]) === null || _a === void 0 ? void 0 : _a.fullPath;
174
+ if (!codeFile) {
175
+ throw new Error(`No code file found for block: ${blockName}`);
176
+ }
177
+ return fs.readFileSync(codeFile, 'utf8');
178
+ };
@@ -1,5 +1,19 @@
1
1
  import { Plugin } from 'vite';
2
2
  export declare const VIRTUAL_MODULE_ID = "virtual:html-preview";
3
3
  export declare const RESOLVED_VIRTUAL_MODULE_ID = "\0virtual:html-preview";
4
+ interface HtmlContent {
5
+ html: string;
6
+ css: string[];
7
+ js: string[];
8
+ cssFiles: string[];
9
+ jsFiles: string[];
10
+ external: {
11
+ js: string[];
12
+ css: string[];
13
+ };
14
+ name: string;
15
+ }
16
+ export declare function readHtmlFiles(dirPath: string): HtmlContent;
17
+ export declare function generateComponent(content: HtmlContent, _isDev?: boolean): string;
4
18
  export declare function initHtmlPreviewTransformPlugin(): Plugin;
5
19
  export default initHtmlPreviewTransformPlugin;