@blocklet/pages-kit-block-studio 0.1.3 → 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.
@@ -11,6 +11,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
11
11
  // import typescript from '@rollup/plugin-typescript';
12
12
  import { readFileSync, existsSync } from 'fs';
13
13
  import * as path from 'path';
14
+ import { joinURL } from 'ufo';
14
15
  import pages, { DefaultPageStrategy } from 'vite-plugin-react-pages';
15
16
  import { findComponentFiles, setBlockEntryFilesPattern, getBlockEntryFilesPattern, getBlockName, logger, } from '../utils/helper';
16
17
  import { initHtmlPreviewTransformPlugin, VIRTUAL_MODULE_ID, readHtmlFiles, generateComponent, } from './vite-plugin-html-transform';
@@ -126,21 +127,23 @@ export function initBlockStudioPlugins(options) {
126
127
  const pageId = `/${blockName}`;
127
128
  const dirPath = path.dirname(filePath);
128
129
  const metadataPath = path.join(dirPath, '@metadata.json');
130
+ const dataPath = isHtml ? `${VIRTUAL_MODULE_ID}?dir=${dirPath}` : filePath;
129
131
  api.addPageData({
130
132
  pageId,
131
- dataPath: isHtml ? `${VIRTUAL_MODULE_ID}?dir=${dirPath}` : filePath,
133
+ dataPath,
132
134
  staticData: isHtml
133
135
  ? {
134
- isHtmlPreview: true,
135
- dataPath: filePath,
136
+ isHtml: true,
137
+ dataPath,
136
138
  code: generateComponent(readHtmlFiles(dirPath)),
137
139
  blockName,
138
140
  dirPath,
141
+ importPath: joinURL('@id', dataPath),
139
142
  metadataPath,
140
143
  }
141
- : Object.assign(Object.assign({}, (yield helpers.extractStaticData(file))), { code: readFileSync(file.path, 'utf-8'), dataPath: filePath, blockName,
142
- dirPath,
143
- metadataPath }),
144
+ : Object.assign(Object.assign({}, (yield helpers.extractStaticData(file))), { code: readFileSync(file.path, 'utf-8'), dataPath,
145
+ blockName,
146
+ dirPath, importPath: joinURL('@fs', dataPath), metadataPath }),
144
147
  });
145
148
  });
146
149
  });