@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.
- package/lib/cjs/plugins/vite-plugin-block-studio.js +10 -24
- package/lib/cjs/plugins/vite-plugin-html-transform.js +10 -11
- package/lib/cjs/tsconfig.tsbuildinfo +1 -1
- package/lib/cjs/utils/build-lib.js +1 -1
- package/lib/esm/plugins/vite-plugin-block-studio.js +10 -24
- package/lib/esm/plugins/vite-plugin-html-transform.js +10 -11
- package/lib/esm/tsconfig.tsbuildinfo +1 -1
- package/lib/esm/utils/build-lib.js +1 -1
- package/lib/types/tsconfig.tsbuildinfo +1 -1
- package/package.json +1 -1
|
@@ -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
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
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
|
-
|
|
143
|
-
|
|
128
|
+
// Redirect 'react' imports to '@blocklet/pages-kit/builtin/react'
|
|
129
|
+
react: '@blocklet/pages-kit/builtin/react',
|
|
144
130
|
},
|
|
145
131
|
// 确保正确处理命名导出和默认导出
|
|
146
|
-
|
|
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
|
-
|
|
210
|
-
return `import
|
|
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
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
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() {
|