@blocklet/pages-kit-block-studio 0.1.9 → 0.1.21

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.
@@ -73,18 +73,13 @@ export function initBlockStudioPlugins(options) {
73
73
  formats: ['es', !multiMode ? 'umd' : 'cjs'],
74
74
  fileName: (format, entryName) => `${format}/${entryName}.js`,
75
75
  }, rollupOptions: {
76
- external: [
77
- 'react',
78
- 'react-router-dom',
79
- 'react-dom',
80
- 'react-is',
81
- 'react/jsx-runtime',
82
- 'crypto',
83
- // '@emotion/react',
84
- // '@emotion/styled',
85
- '@arcblock/ux',
86
- '@arcblock/did-connect',
87
- ],
76
+ external: (id) => {
77
+ const skip = ['react', 'crypto'];
78
+ if (skip.some((s) => id === s)) {
79
+ return true;
80
+ }
81
+ return false;
82
+ },
88
83
  output: {
89
84
  chunkFileNames: () => {
90
85
  return '[format]/_chunks/[name]-[hash].js';
@@ -92,22 +87,13 @@ export function initBlockStudioPlugins(options) {
92
87
  // 为所有外部依赖提供全局变量
93
88
  globals: {
94
89
  react: 'React',
95
- 'react-dom': 'ReactDOM',
96
- 'react-is': 'ReactIs',
97
- 'react-router-dom': 'ReactRouterDOM',
98
- 'react/jsx-runtime': 'ReactJsxRuntime',
99
- // '@emotion/react': 'emotionReact',
100
- // '@emotion/styled': 'emotionStyled',
101
- '@mui/material': 'MUI',
102
- '@arcblock/ux': 'ArcBlockUX',
103
- '@arcblock/did-connect': 'ArcBlockDidConnect',
104
90
  },
105
91
  paths: {
106
- // Redirect 'react' imports to '@blocklet/pages-kit/builtin/react'
107
- // react: '@blocklet/pages-kit/builtin/react',
92
+ // Redirect 'react' imports to '@blocklet/pages-kit/builtin/react'
93
+ react: '@blocklet/pages-kit/builtin/react',
108
94
  },
109
95
  // 确保正确处理命名导出和默认导出
110
- // interop: 'auto',
96
+ interop: 'auto',
111
97
  },
112
98
  } }, _config === null || _config === void 0 ? void 0 : _config.build),
113
99
  };
@@ -200,8 +200,8 @@ ${content.trim()}`;
200
200
  }
201
201
  export function generateComponent(content, _isDev = true) {
202
202
  const htmlContent = content.html;
203
- // const { name } = content;
204
- return `import React, { useEffect, useRef } from 'react';
203
+ const { name } = content;
204
+ return `import { createElement, useEffect, useRef } from 'react';
205
205
 
206
206
 
207
207
  export default function HtmlPreview() {
@@ -224,15 +224,14 @@ export default function HtmlPreview() {
224
224
  return () => window.removeEventListener('message', handleMessage);
225
225
  }, []);
226
226
 
227
- return (
228
- <iframe
229
- ref={iframeRef}
230
- style={{ border: 'none', width: '100%', height: '0px', maxHeight: '100vh' }}
231
- sandbox="allow-scripts"
232
- title="HtmlPreview"
233
- srcDoc={${htmlContent}}
234
- />
235
- );
227
+ return createElement('iframe', {
228
+ ref: iframeRef,
229
+ style: { border: 'none', width: '100%', height: '0px', maxHeight: '100vh' },
230
+ sandbox: 'allow-scripts',
231
+ title: 'Preview ${name}',
232
+ srcDoc: ${htmlContent}
233
+ });
234
+
236
235
  }`;
237
236
  }
238
237
  export function initHtmlPreviewTransformPlugin() {