@blocklet/pages-kit-block-studio 0.1.20 → 0.1.22

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.
@@ -109,18 +109,13 @@ function initBlockStudioPlugins(options) {
109
109
  formats: ['es', !multiMode ? 'umd' : 'cjs'],
110
110
  fileName: (format, entryName) => `${format}/${entryName}.js`,
111
111
  }, rollupOptions: {
112
- external: [
113
- 'react',
114
- 'react-router-dom',
115
- 'react-dom',
116
- 'react-is',
117
- 'react/jsx-runtime',
118
- 'crypto',
119
- // '@emotion/react',
120
- // '@emotion/styled',
121
- '@arcblock/ux',
122
- '@arcblock/did-connect',
123
- ],
112
+ external: (id) => {
113
+ const skip = ['react', 'crypto'];
114
+ if (skip.some((s) => id === s)) {
115
+ return true;
116
+ }
117
+ return false;
118
+ },
124
119
  output: {
125
120
  chunkFileNames: () => {
126
121
  return '[format]/_chunks/[name]-[hash].js';
@@ -128,22 +123,13 @@ function initBlockStudioPlugins(options) {
128
123
  // 为所有外部依赖提供全局变量
129
124
  globals: {
130
125
  react: 'React',
131
- 'react-dom': 'ReactDOM',
132
- 'react-is': 'ReactIs',
133
- 'react-router-dom': 'ReactRouterDOM',
134
- 'react/jsx-runtime': 'ReactJsxRuntime',
135
- // '@emotion/react': 'emotionReact',
136
- // '@emotion/styled': 'emotionStyled',
137
- '@mui/material': 'MUI',
138
- '@arcblock/ux': 'ArcBlockUX',
139
- '@arcblock/did-connect': 'ArcBlockDidConnect',
140
126
  },
141
127
  paths: {
142
- // Redirect 'react' imports to '@blocklet/pages-kit/builtin/react'
143
- // react: '@blocklet/pages-kit/builtin/react',
128
+ // Redirect 'react' imports to '@blocklet/pages-kit/builtin/react'
129
+ react: '@blocklet/pages-kit/builtin/react',
144
130
  },
145
131
  // 确保正确处理命名导出和默认导出
146
- // interop: 'auto',
132
+ interop: 'auto',
147
133
  },
148
134
  } }, _config === null || _config === void 0 ? void 0 : _config.build),
149
135
  };
@@ -206,8 +206,8 @@ ${content.trim()}`;
206
206
  }
207
207
  function generateComponent(content, _isDev = true) {
208
208
  const htmlContent = content.html;
209
- // const { name } = content;
210
- return `import React, { useEffect, useRef } from '@blocklet/pages-kit/builtin/react';
209
+ const { name } = content;
210
+ return `import { createElement, useEffect, useRef } from 'react';
211
211
 
212
212
 
213
213
  export default function HtmlPreview() {
@@ -230,15 +230,14 @@ export default function HtmlPreview() {
230
230
  return () => window.removeEventListener('message', handleMessage);
231
231
  }, []);
232
232
 
233
- return (
234
- <iframe
235
- ref={iframeRef}
236
- style={{ border: 'none', width: '100%', height: '0px', maxHeight: '100vh' }}
237
- sandbox="allow-scripts"
238
- title="HtmlPreview"
239
- srcDoc={${htmlContent}}
240
- />
241
- );
233
+ return createElement('iframe', {
234
+ ref: iframeRef,
235
+ style: { border: 'none', width: '100%', height: '100%', maxHeight: '100vh' },
236
+ sandbox: 'allow-scripts',
237
+ title: 'Preview ${name}',
238
+ srcDoc: ${htmlContent}
239
+ });
240
+
242
241
  }`;
243
242
  }
244
243
  function initHtmlPreviewTransformPlugin() {