@blocklet/pages-kit-block-studio 0.0.5 → 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.
@@ -72,19 +72,16 @@ function generateWrapperCode(_a) {
72
72
  },
73
73
  }, null, 2);
74
74
  const index = `\
75
- import { ProjectRuntime } from '@blocklet/pages-kit-runtime/client';
75
+ import HomeComponent from '@blocklet/pages-kit-runtime/client';
76
76
  export * from '@blocklet/pages-kit-runtime/client';
77
+ import React from 'react';
77
78
 
78
79
  window.__PAGE_STATE__ = ${JSON.stringify(state, null, 2)};
79
80
  window.__PROJECT_ID__ = "${project.id}";
80
81
 
81
82
 
82
- const initProjectRuntime = new ProjectRuntime({
83
- state: window.__PAGE_STATE__,
84
- projectId: window.__PROJECT_ID__,
85
- });
86
-
87
- export default initProjectRuntime;
83
+ // 导出一个 React 组件而不是实例
84
+ export default HomeComponent;
88
85
  `;
89
86
  const client = index;
90
87
  const tsFiles = [
@@ -57,7 +57,7 @@ function initBlockStudioPlugins(options) {
57
57
  (0, utils_1.setBlockEntryFilesPattern)(entryFilesPattern);
58
58
  // fallback to __dirname if _theme.tsx not exists
59
59
  const pagesDir = (0, fs_1.existsSync)(path.join(workingDir, '_theme.tsx')) ? workingDir : __dirname.replace('cjs', 'esm');
60
- utils_1.logger.log('initBlockStudioPlugins options', {
60
+ utils_1.logger.log('initBlockStudioPlugins options: ', {
61
61
  cwd: workingDir,
62
62
  entryFilesPattern: (0, utils_1.getBlockEntryFilesPattern)(),
63
63
  pagesDir,
@@ -90,9 +90,7 @@ function initBlockStudioPlugins(options) {
90
90
  const multiMode = !!process.argv.includes('--multi');
91
91
  const name = yield Promise.resolve(`${`${workingDir}/package.json`}`).then(s => __importStar(require(s))).then((res) => res.name).catch(() => 'MyLib');
92
92
  return {
93
- build: {
94
- cssCodeSplit: false,
95
- lib: {
93
+ build: Object.assign({ cssCodeSplit: false, lib: {
96
94
  name,
97
95
  entry: Object.assign({}, Object.fromEntries((0, utils_1.findComponentFiles)({ cwd: workingDir })
98
96
  .map((entry) => {
@@ -109,40 +107,41 @@ function initBlockStudioPlugins(options) {
109
107
  // multiMode not support umd
110
108
  formats: ['es', multiMode ? 'umd' : 'cjs'],
111
109
  fileName: (format, entryName) => `${format}/${entryName}.js`,
112
- },
113
- rollupOptions: {
110
+ }, rollupOptions: {
114
111
  external: [
115
112
  'react',
116
113
  'react-router-dom',
117
114
  'react-dom',
115
+ 'react-is',
116
+ 'react/jsx-runtime',
118
117
  'crypto',
119
- '@emotion/react',
120
- '@emotion/styled',
118
+ // '@emotion/react',
119
+ // '@emotion/styled',
121
120
  '@arcblock/ux',
122
- /^@mui\/.*/, // 所有 MUI 相关包
123
- '@mui/material/styles', // 明确指定这个路径
121
+ '@arcblock/did-connect',
124
122
  ],
125
123
  output: {
126
124
  // 为所有外部依赖提供全局变量
127
125
  globals: {
128
126
  react: 'React',
129
127
  'react-dom': 'ReactDOM',
128
+ 'react-is': 'ReactIs',
130
129
  'react-router-dom': 'ReactRouterDOM',
131
- '@emotion/react': 'emotionReact',
132
- '@emotion/styled': 'emotionStyled',
130
+ 'react/jsx-runtime': 'ReactJsxRuntime',
131
+ // '@emotion/react': 'emotionReact',
132
+ // '@emotion/styled': 'emotionStyled',
133
133
  '@mui/material': 'MUI',
134
134
  '@arcblock/ux': 'ArcBlockUX',
135
+ '@arcblock/did-connect': 'ArcBlockDidConnect',
135
136
  },
136
137
  paths: {
137
138
  // Redirect 'react' imports to '@blocklet/pages-kit/builtin/react'
138
139
  // react: '@blocklet/pages-kit/builtin/react',
139
140
  },
140
141
  // 确保正确处理命名导出和默认导出
141
- interop: 'auto',
142
- preserveModules: true, // 保持模块结构
142
+ // interop: 'auto',
143
143
  },
144
- },
145
- },
144
+ } }, _config === null || _config === void 0 ? void 0 : _config.build),
146
145
  };
147
146
  });
148
147
  },