@blocklet/pages-kit-block-studio 0.0.4 → 0.0.6

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.
@@ -36,19 +36,16 @@ export function generateWrapperCode(_a) {
36
36
  },
37
37
  }, null, 2);
38
38
  const index = `\
39
- import { ProjectRuntime } from '@blocklet/pages-kit-runtime/client';
39
+ import HomeComponent from '@blocklet/pages-kit-runtime/client';
40
40
  export * from '@blocklet/pages-kit-runtime/client';
41
+ import React from 'react';
41
42
 
42
43
  window.__PAGE_STATE__ = ${JSON.stringify(state, null, 2)};
43
44
  window.__PROJECT_ID__ = "${project.id}";
44
45
 
45
46
 
46
- const initProjectRuntime = new ProjectRuntime({
47
- state: window.__PAGE_STATE__,
48
- projectId: window.__PROJECT_ID__,
49
- });
50
-
51
- export default initProjectRuntime;
47
+ // 导出一个 React 组件而不是实例
48
+ export default HomeComponent;
52
49
  `;
53
50
  const client = index;
54
51
  const tsFiles = [
@@ -21,7 +21,7 @@ export function initBlockStudioPlugins(options) {
21
21
  setBlockEntryFilesPattern(entryFilesPattern);
22
22
  // fallback to __dirname if _theme.tsx not exists
23
23
  const pagesDir = existsSync(path.join(workingDir, '_theme.tsx')) ? workingDir : __dirname.replace('cjs', 'esm');
24
- logger.log('initBlockStudioPlugins options', {
24
+ logger.log('initBlockStudioPlugins options: ', {
25
25
  cwd: workingDir,
26
26
  entryFilesPattern: getBlockEntryFilesPattern(),
27
27
  pagesDir,
@@ -54,9 +54,7 @@ export function initBlockStudioPlugins(options) {
54
54
  const multiMode = !!process.argv.includes('--multi');
55
55
  const name = yield import(`${workingDir}/package.json`).then((res) => res.name).catch(() => 'MyLib');
56
56
  return {
57
- build: {
58
- cssCodeSplit: false,
59
- lib: {
57
+ build: Object.assign({ cssCodeSplit: false, lib: {
60
58
  name,
61
59
  entry: Object.assign({}, Object.fromEntries(findComponentFiles({ cwd: workingDir })
62
60
  .map((entry) => {
@@ -73,36 +71,41 @@ export function initBlockStudioPlugins(options) {
73
71
  // multiMode not support umd
74
72
  formats: ['es', multiMode ? 'umd' : 'cjs'],
75
73
  fileName: (format, entryName) => `${format}/${entryName}.js`,
76
- },
77
- rollupOptions: {
74
+ }, rollupOptions: {
78
75
  external: [
79
76
  'react',
80
77
  'react-router-dom',
81
78
  'react-dom',
79
+ 'react-is',
80
+ 'react/jsx-runtime',
82
81
  'crypto',
83
- '@emotion/react',
84
- '@emotion/styled',
82
+ // '@emotion/react',
83
+ // '@emotion/styled',
85
84
  '@arcblock/ux',
86
- /^@mui\/.*/, // 所有 MUI 相关包
85
+ '@arcblock/did-connect',
87
86
  ],
88
87
  output: {
89
88
  // 为所有外部依赖提供全局变量
90
89
  globals: {
91
90
  react: 'React',
92
91
  'react-dom': 'ReactDOM',
92
+ 'react-is': 'ReactIs',
93
93
  'react-router-dom': 'ReactRouterDOM',
94
- '@emotion/react': 'emotionReact',
95
- '@emotion/styled': 'emotionStyled',
94
+ 'react/jsx-runtime': 'ReactJsxRuntime',
95
+ // '@emotion/react': 'emotionReact',
96
+ // '@emotion/styled': 'emotionStyled',
96
97
  '@mui/material': 'MUI',
97
98
  '@arcblock/ux': 'ArcBlockUX',
99
+ '@arcblock/did-connect': 'ArcBlockDidConnect',
98
100
  },
99
101
  paths: {
100
102
  // Redirect 'react' imports to '@blocklet/pages-kit/builtin/react'
101
103
  // react: '@blocklet/pages-kit/builtin/react',
102
104
  },
105
+ // 确保正确处理命名导出和默认导出
106
+ // interop: 'auto',
103
107
  },
104
- },
105
- },
108
+ } }, _config === null || _config === void 0 ? void 0 : _config.build),
106
109
  };
107
110
  });
108
111
  },