@blocklet/pages-kit-block-studio 0.4.64 → 0.4.66

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.
@@ -1,4 +1,502 @@
1
- import { jsx as _jsx } from "react/jsx-runtime";
2
- export default function Theme() {
3
- return _jsx("div", { children: "Theme" });
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ /* eslint-disable */
3
+ // @ts-nocheck
4
+ import { createAuthServiceSessionContext } from '@arcblock/did-connect/lib/Session';
5
+ import { LocaleProvider, useLocaleContext } from '@arcblock/ux/lib/Locale/context';
6
+ import Toast, { ToastProvider } from '@arcblock/ux/lib/Toast';
7
+ import { createAxios } from '@blocklet/js-sdk';
8
+ // @ts-ignore
9
+ import { pagesTheme, theme } from '@blocklet/pages-kit-inner-components/theme';
10
+ // @ts-ignore
11
+ import { BasicInfo, ParametersConfig, PropertiesConfig } from '@blocklet/pages-kit-runtime/components';
12
+ // @ts-ignore
13
+ import { translations } from '@blocklet/pages-kit-runtime/locales';
14
+ import { CustomComponentRenderer } from '@blocklet/pages-kit/components';
15
+ // @ts-ignore
16
+ import { Dashboard } from '@blocklet/studio-ui';
17
+ import { BlockletStudio } from '@blocklet/ui-react';
18
+ import AddIcon from '@mui/icons-material/Add';
19
+ import { Alert, Box, Button, CircularProgress, Dialog, DialogContent, DialogTitle, Drawer, List, ListItem, ListItemButton, Stack, StyledEngineProvider, TextField, ThemeProvider, Tooltip, Typography, backdropClasses, circularProgressClasses, styled, } from '@mui/material';
20
+ import { useDebounceFn, useReactive } from 'ahooks';
21
+ import cloneDeep from 'lodash/cloneDeep';
22
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
23
+ import { Suspense, useCallback, useEffect, useMemo } from 'react';
24
+ import { DndProvider } from 'react-dnd';
25
+ import { HTML5Backend } from 'react-dnd-html5-backend';
26
+ import { Navigate, useLocation, useNavigate } from 'react-router-dom';
27
+ import { joinURL } from 'ufo';
28
+ // eslint-disable-next-line import/no-extraneous-dependencies
29
+ import { useStaticData } from 'vite-plugin-react-pages/client';
30
+ // @ts-ignore
31
+ const basename = window.blocklet?.prefix || '/';
32
+ const PAGES_KIT_BLOCK_STUDIO_BLOCKLET_DID = 'z2qa7rr3eUyVnWp2PCxEVARuUfLFh6cE5V2xV';
33
+ const api = createAxios({
34
+ timeout: 200000,
35
+ }, {
36
+ componentDid: PAGES_KIT_BLOCK_STUDIO_BLOCKLET_DID,
37
+ });
38
+ const { SessionProvider, SessionContext, SessionConsumer, withSession } = createAuthServiceSessionContext();
39
+ const LEFT_DRAWER_WIDTH = 200;
40
+ const RIGHT_DRAWER_WIDTH = 300;
41
+ const ComparisonPreviewDialog = ({ open, title, leftTitle, leftContent, rightTitle, rightContent, description = '确认后将更新配置。', loading, onConfirm, onClose, }) => {
42
+ const handleConfirm = async () => {
43
+ try {
44
+ await onConfirm();
45
+ }
46
+ catch (error) {
47
+ console.error('执行操作失败:', error);
48
+ Toast.error('执行操作失败');
49
+ }
50
+ };
51
+ return (_jsxs(Dialog, { open: open, onClose: onClose, maxWidth: "md", fullWidth: true, children: [_jsx(DialogTitle, { children: title }), _jsx(DialogContent, { children: _jsxs(Box, { children: [_jsxs(Box, { sx: { display: 'flex', flexDirection: 'row', mb: 2 }, children: [_jsxs(Box, { sx: { flex: 1, mr: 1 }, children: [_jsx(Typography, { variant: "subtitle2", sx: { mb: 1 }, children: leftTitle }), _jsx(TextField, { multiline: true, fullWidth: true, rows: 10, InputProps: {
52
+ readOnly: true,
53
+ }, value: leftContent, sx: {
54
+ '& .MuiOutlinedInput-root': {
55
+ fontFamily: 'monospace',
56
+ fontSize: '0.875rem',
57
+ },
58
+ } })] }), _jsxs(Box, { sx: { flex: 1, ml: 1 }, children: [_jsx(Typography, { variant: "subtitle2", sx: { mb: 1 }, children: rightTitle }), _jsx(TextField, { multiline: true, fullWidth: true, rows: 10, InputProps: {
59
+ readOnly: true,
60
+ }, value: rightContent, sx: {
61
+ '& .MuiOutlinedInput-root': {
62
+ fontFamily: 'monospace',
63
+ fontSize: '0.875rem',
64
+ },
65
+ } })] })] }), _jsx(Typography, { variant: "body2", sx: { mt: 2, color: 'text.secondary' }, children: description })] }) }), _jsxs(Box, { sx: { display: 'flex', justifyContent: 'flex-end', p: 2 }, children: [_jsx(Button, { variant: "outlined", onClick: onClose, sx: { mr: 1 }, children: "\u53D6\u6D88" }), _jsx(Button, { variant: "contained", onClick: handleConfirm, disabled: loading, children: loading ? _jsx(CircularProgress, { size: 24 }) : '确认更新' })] })] }));
66
+ };
67
+ function Layout({ loadState, loadedData }) {
68
+ const state = useReactive({
69
+ injectBlocks: [],
70
+ selectingParam: null,
71
+ componentSelectOpen: false,
72
+ createResourceOpen: false,
73
+ createBlockOpen: false,
74
+ metadata: {
75
+ id: '',
76
+ createdAt: '',
77
+ updatedAt: '',
78
+ },
79
+ data: {},
80
+ allBlocks: {},
81
+ searchValue: '',
82
+ newBlockParams: {
83
+ name: '',
84
+ description: '',
85
+ },
86
+ previewDialog: {
87
+ open: false,
88
+ title: '',
89
+ leftTitle: '',
90
+ leftContent: '',
91
+ rightTitle: '',
92
+ rightContent: '',
93
+ description: '',
94
+ loading: false,
95
+ onConfirm: async () => { },
96
+ },
97
+ });
98
+ const { locale } = useLocaleContext();
99
+ const location = useLocation();
100
+ const navigate = useNavigate();
101
+ const staticData = useStaticData();
102
+ const { routes, firstRoute, currentPage } = useMemo(() => {
103
+ const routes = Object.keys(staticData).sort((a, b) => a.localeCompare(b));
104
+ return {
105
+ routes,
106
+ firstRoute: routes.find((route) => route !== '404' && route !== '*'),
107
+ currentPage: {
108
+ ...staticData[location.pathname]?.main,
109
+ pageId: location.pathname,
110
+ },
111
+ };
112
+ }, [staticData, location.pathname]);
113
+ const getStaticData = useCallback(() => {
114
+ return staticData[location.pathname]?.main || {};
115
+ }, [staticData, location.pathname]);
116
+ const getBlockMetadata = async (metadataPath) => {
117
+ if (!metadataPath)
118
+ return {};
119
+ const response = await api.get(`/api/blocks?path=${encodeURIComponent(metadataPath)}`);
120
+ return response.data || {};
121
+ };
122
+ const getAllBlocks = async () => {
123
+ const response = await api.get('/api/blocks/all');
124
+ return response.data || [];
125
+ };
126
+ const debouncedUpdateMetadata = useDebounceFn(async (metadata) => {
127
+ const { metadataPath } = getStaticData() || {};
128
+ if (metadataPath) {
129
+ try {
130
+ const metdadataWithoutRenderer = cloneDeep(metadata);
131
+ delete metdadataWithoutRenderer.renderer;
132
+ await api.post('/api/blocks', {
133
+ path: metadataPath,
134
+ content: metdadataWithoutRenderer,
135
+ });
136
+ }
137
+ catch (error) {
138
+ console.error('Failed to write metadata:', error);
139
+ }
140
+ }
141
+ }, { wait: 500 });
142
+ useEffect(() => {
143
+ debouncedUpdateMetadata.run(state.metadata);
144
+ }, [state.metadata, debouncedUpdateMetadata]);
145
+ useEffect(() => {
146
+ if (currentPage && state.injectBlocks.length === 0) {
147
+ state.injectBlocks.push({
148
+ ...currentPage,
149
+ level: 0,
150
+ });
151
+ }
152
+ }, [currentPage]);
153
+ // Add new effect to fetch metadata when page changes
154
+ useEffect(() => {
155
+ const fetchMetadata = async () => {
156
+ const { metadataPath, code } = getStaticData() || {};
157
+ if (metadataPath) {
158
+ try {
159
+ const metadata = await getBlockMetadata(metadataPath);
160
+ state.metadata = {
161
+ ...metadata,
162
+ renderer: {
163
+ script: code,
164
+ type: 'react-component',
165
+ },
166
+ };
167
+ }
168
+ catch (error) {
169
+ console.error('Failed to fetch metadata:', error);
170
+ }
171
+ }
172
+ };
173
+ const fetchAllBlocks = async () => {
174
+ const allBlocks = await getAllBlocks();
175
+ state.allBlocks = allBlocks;
176
+ };
177
+ fetchMetadata();
178
+ fetchAllBlocks();
179
+ }, [location.pathname]); // 当路由变化时重新获取
180
+ const mergedAllBlocks = useMemo(() => {
181
+ // Add all staticData code and importPath mappings
182
+ if (import.meta.env.DEV) {
183
+ const win = window;
184
+ win.__BLOCK_STUDIO__ = win.__BLOCK_STUDIO__ || {};
185
+ win.__BLOCK_STUDIO__.codeImportPathMap = win.__BLOCK_STUDIO__.codeImportPathMap || {};
186
+ Object.entries(staticData).forEach(([_, pageData]) => {
187
+ const { code, importPath } = pageData?.main || {};
188
+ if (code && importPath) {
189
+ win.__BLOCK_STUDIO__.codeImportPathMap[code] = joinURL(window.blocklet?.prefix, importPath);
190
+ }
191
+ });
192
+ win.__BLOCK_STUDIO__.getCodeImportPath = (code) => {
193
+ return win.__BLOCK_STUDIO__?.codeImportPathMap?.[code];
194
+ };
195
+ }
196
+ return {
197
+ ...state.allBlocks,
198
+ [state.metadata.id]: {
199
+ ...state.allBlocks[state.metadata.id],
200
+ data: state.metadata,
201
+ },
202
+ };
203
+ }, [state.allBlocks, state.metadata, staticData]);
204
+ const onCloseCreateBlock = () => {
205
+ state.createBlockOpen = false;
206
+ state.newBlockParams = {
207
+ name: '',
208
+ description: '',
209
+ };
210
+ };
211
+ const getRenderContent = useCallback(() => {
212
+ if (loadState.type === '404') {
213
+ return null;
214
+ }
215
+ if (['load-error', 'loading'].includes(loadState.type)) {
216
+ return (_jsx(Box, { width: "100%", height: "100%", display: "flex", justifyContent: "center", alignItems: "center", children: loadState.type === 'load-error' ? (_jsx(Alert, { severity: "error", variant: "filled", children: "Failed to load component code" })) : (_jsx(CircularProgress, {})) }));
217
+ }
218
+ // const pageData = loadedData[loadState.routePath];
219
+ // const Component = pageData.main.default;
220
+ // return <Component {...state.data} />;
221
+ return [
222
+ _jsx(CustomComponentRenderer, { locale: locale, componentId: state.metadata.id, dev: { mode: 'draft', components: mergedAllBlocks, defaultLocale: 'en' }, props: state.data }, "custom"),
223
+ // <Component key="original" {...state.data} />,
224
+ ];
225
+ }, [loadedData, loadState, locale, state.injectBlocks, state.metadata, mergedAllBlocks]);
226
+ // add auto redirect to first route
227
+ if (loadState.type === '404' &&
228
+ !routes.includes(location.pathname) &&
229
+ !location.search.includes('no-redirect=true')) {
230
+ return _jsx(Navigate, { to: `${firstRoute ?? '/'}`, replace: true });
231
+ }
232
+ return (_jsx(StyledEngineProvider, { injectFirst: true, children: _jsx(ThemeProvider, { theme: theme, children: _jsx(SessionProvider, { serviceHost: basename, protectedRoutes: [`${basename}/*`], children: _jsx(DndProvider, { backend: HTML5Backend, children: _jsxs(StyledDashboard, { HeaderProps: {
233
+ // @ts-ignore
234
+ homeLink: joinURL(basename),
235
+ addons: (addons) => {
236
+ return [
237
+ _jsx(Button, { onClick: () => (state.createResourceOpen = true), children: "Create Resource" }, "logout"),
238
+ ...addons,
239
+ ];
240
+ },
241
+ }, MenusDrawerProps: { sx: { [`.${backdropClasses.root}`]: { top: 64 } } }, children: [_jsxs(Drawer, { variant: "permanent", sx: {
242
+ width: LEFT_DRAWER_WIDTH,
243
+ flexShrink: 0,
244
+ zIndex: 1000,
245
+ '& .MuiDrawer-paper': {
246
+ width: LEFT_DRAWER_WIDTH,
247
+ boxSizing: 'border-box',
248
+ position: 'relative',
249
+ height: '100%',
250
+ },
251
+ }, children: [_jsxs(Stack, { gap: 1, direction: "row", alignItems: "center", sx: { py: 2, pr: 1, pl: 0.5 }, children: [_jsx(TextField, { placeholder: "Search Blocks...", sx: { minWidth: 120 }, onChange: (e) => {
252
+ state.searchValue = e.target.value;
253
+ } }), _jsx(Button, { variant: "contained", sx: { minWidth: 'auto' }, onClick: () => {
254
+ state.createBlockOpen = true;
255
+ }, children: _jsx(AddIcon, { fontSize: "small" }) })] }), _jsx(List, { sx: { pr: 1, overflowY: 'auto' }, children: routes
256
+ .map((route) => {
257
+ const routeName = route;
258
+ const staticDataInRoute = staticData[route]?.main;
259
+ if (state.searchValue && !routeName?.toLowerCase().includes(state.searchValue?.toLowerCase())) {
260
+ return null;
261
+ }
262
+ return (_jsx(ListItem, { disablePadding: true, children: _jsx(ListItemButton, { selected: currentPage.pageId === route, onClick: () => {
263
+ navigate(route);
264
+ }, sx: {
265
+ borderRadius: 1,
266
+ mb: 1,
267
+ width: '100%',
268
+ textOverflow: 'ellipsis',
269
+ whiteSpace: 'nowrap',
270
+ overflowX: 'hidden',
271
+ transition: 'all 0.3s ease',
272
+ '&.Mui-selected': {
273
+ backgroundColor: 'primary.main',
274
+ color: 'white',
275
+ '&:hover': {
276
+ backgroundColor: 'primary.main',
277
+ },
278
+ },
279
+ fontSize: '14px',
280
+ }, children: _jsx(Tooltip, { title: staticDataInRoute.blockName || routeName, children: _jsx("div", { style: {
281
+ width: '100%',
282
+ overflow: 'hidden',
283
+ textOverflow: 'ellipsis',
284
+ }, children: staticDataInRoute.blockName || routeName }) }) }) }, route));
285
+ })
286
+ .filter(Boolean) })] }), _jsx(Box, { sx: { flex: 1, overflowX: 'hidden', overflowY: getStaticData()?.isHtml ? 'hidden' : 'auto' }, children: _jsx(ThemeProvider, { theme: pagesTheme, children: _jsx(Suspense, { children: getRenderContent() }) }) }), _jsx(Drawer, { variant: "permanent", anchor: "right", sx: {
287
+ width: RIGHT_DRAWER_WIDTH,
288
+ flexShrink: 0,
289
+ zIndex: 1000,
290
+ '& .MuiDrawer-paper': {
291
+ width: RIGHT_DRAWER_WIDTH,
292
+ boxSizing: 'border-box',
293
+ position: 'relative',
294
+ height: '100%',
295
+ },
296
+ }, children: _jsxs(List, { sx: { display: 'flex', flexDirection: 'column', gap: 1 }, children: [_jsx(ListItem, { children: _jsx(Box, { sx: { width: '100%' }, children: _jsx(BasicInfo, { config: state.metadata }) }) }), _jsx(ListItem, { children: _jsxs(Box, { sx: { width: '100%' }, children: [_jsx(PropertiesConfig, { config: state.metadata, currentLocale: locale, defaultLocale: "en", allComponents: mergedAllBlocks, onUpdateConfig: (updater) => {
297
+ updater(state.metadata);
298
+ }, useI18nEditor: false }), _jsxs(Stack, { direction: "column", spacing: 1, sx: { mt: 1 }, children: [_jsx(Button, { variant: "contained", size: "small", color: "primary", onClick: async () => {
299
+ try {
300
+ const { dataPath } = getStaticData() || {};
301
+ if (!dataPath) {
302
+ Toast.error('无法找到组件路径');
303
+ return;
304
+ }
305
+ Toast.info('正在分析组件接口...');
306
+ const response = await api.post('/api/blocks/interface-to-properties', {
307
+ componentPath: dataPath,
308
+ });
309
+ if (response.data.success) {
310
+ const { currentProperties, newProperties } = response.data;
311
+ state.previewDialog = {
312
+ open: true,
313
+ title: 'Interface → Properties 预览',
314
+ leftTitle: '当前 Properties',
315
+ leftContent: JSON.stringify(currentProperties, null, 2),
316
+ rightTitle: '新 Properties',
317
+ rightContent: JSON.stringify(newProperties, null, 2),
318
+ description: '确认后将更新metadata文件。这将保留现有配置值,但可能更改属性结构。',
319
+ loading: false,
320
+ onConfirm: async () => {
321
+ state.previewDialog.loading = true;
322
+ try {
323
+ const updateResponse = await api.post('/api/blocks/interface-to-properties', {
324
+ componentPath: dataPath,
325
+ write: true,
326
+ });
327
+ if (updateResponse.data.success) {
328
+ Toast.success('Metadata生成成功!');
329
+ // 更新当前的metadata状态
330
+ state.metadata = {
331
+ ...updateResponse.data.metadata,
332
+ renderer: state.metadata.renderer,
333
+ };
334
+ state.previewDialog.open = false;
335
+ }
336
+ else {
337
+ throw new Error(updateResponse.data.error || '生成失败');
338
+ }
339
+ }
340
+ finally {
341
+ state.previewDialog.loading = false;
342
+ }
343
+ },
344
+ };
345
+ }
346
+ else {
347
+ Toast.error(response.data.error || '预览失败');
348
+ }
349
+ }
350
+ catch (error) {
351
+ console.error('生成预览失败:', error);
352
+ Toast.error('生成预览失败');
353
+ }
354
+ }, children: "Interface \u2192 Properties" }), _jsx(Button, { variant: "outlined", size: "small", color: "primary", onClick: async () => {
355
+ try {
356
+ const { dataPath } = getStaticData() || {};
357
+ if (!dataPath) {
358
+ Toast.error('无法找到组件路径');
359
+ return;
360
+ }
361
+ Toast.info('正在生成TypeScript接口预览...');
362
+ const response = await api.post('/api/blocks/properties-to-interface', {
363
+ componentPath: dataPath,
364
+ });
365
+ if (response.data.success) {
366
+ const { currentInterface, newInterface } = response.data;
367
+ state.previewDialog = {
368
+ open: true,
369
+ title: 'Properties → Interface 预览',
370
+ leftTitle: '当前接口',
371
+ leftContent: currentInterface,
372
+ rightTitle: '新接口',
373
+ rightContent: newInterface,
374
+ description: '确认后将更新TypeScript接口。这将覆盖当前的接口定义。',
375
+ loading: false,
376
+ onConfirm: async () => {
377
+ state.previewDialog.loading = true;
378
+ try {
379
+ const updateResponse = await api.post('/api/blocks/properties-to-interface', {
380
+ componentPath: dataPath,
381
+ write: true,
382
+ });
383
+ if (updateResponse.data.success) {
384
+ Toast.success('TypeScript接口生成成功!');
385
+ state.previewDialog.open = false;
386
+ }
387
+ else {
388
+ throw new Error(updateResponse.data.error || '生成失败');
389
+ }
390
+ }
391
+ finally {
392
+ state.previewDialog.loading = false;
393
+ }
394
+ },
395
+ };
396
+ }
397
+ else {
398
+ Toast.error(response.data.error || '预览失败');
399
+ }
400
+ }
401
+ catch (error) {
402
+ console.error('生成接口预览失败:', error);
403
+ Toast.error('生成接口预览失败');
404
+ }
405
+ }, children: "Properties \u2192 Interface" })] })] }) }), state.metadata.id && (_jsx(ListItem, { children: _jsx(Box, { sx: { width: '100%' }, children: _jsx(ParametersConfig, { config: state.metadata, allComponents: mergedAllBlocks, defaultLocale: "en", locale: locale,
406
+ // 不需要 propertiesValue
407
+ // propertiesValue={{}}
408
+ onChange: ({ key, value }) => {
409
+ state.data = {
410
+ ...state.data,
411
+ [key]: value.value,
412
+ };
413
+ }, props: {
414
+ ...state.data,
415
+ } }) }) }))] }) }), _jsx(CreateResource, { open: state.createResourceOpen, onClose: () => {
416
+ state.createResourceOpen = false;
417
+ } }), _jsxs(Dialog, { open: state.createBlockOpen, onClose: onCloseCreateBlock, children: [_jsx(DialogTitle, { children: "Create New Block" }), _jsx(DialogContent, { children: _jsxs(Stack, { spacing: 2, sx: { pt: 1, minWidth: 300 }, children: [_jsx(TextField, { autoFocus: true, required: true, label: "Name", fullWidth: true, value: state.newBlockParams.name, onChange: (e) => {
418
+ state.newBlockParams.name = e.target.value.replace(/[^a-zA-Z0-9-]/g, '');
419
+ } }), _jsx(TextField, { label: "Description", fullWidth: true, multiline: true, rows: 3, value: state.newBlockParams.description, onChange: (e) => {
420
+ state.newBlockParams.description = e.target.value;
421
+ } }), _jsx(Button, { variant: "contained", fullWidth: true, onClick: async () => {
422
+ if (!state.newBlockParams.name) {
423
+ Toast.warning('Block name is required');
424
+ return;
425
+ }
426
+ if (routes.some((route) => {
427
+ const staticDataInRoute = staticData[route]?.main;
428
+ return (staticDataInRoute?.blockName?.toLowerCase() === state.newBlockParams.name.toLowerCase());
429
+ })) {
430
+ Toast.warning('Block name already exists, please change it');
431
+ return;
432
+ }
433
+ try {
434
+ await api.post('/api/blocks/create', state.newBlockParams);
435
+ navigate(`/${state.newBlockParams.name}?no-redirect=true`);
436
+ // wait for the file to be created
437
+ setTimeout(() => {
438
+ window.location.reload();
439
+ }, 100);
440
+ onCloseCreateBlock();
441
+ }
442
+ catch (error) {
443
+ console.error('Failed to create block:', error);
444
+ Toast.error('Failed to create block');
445
+ }
446
+ }, children: "Create" })] }) })] }), _jsx(ComparisonPreviewDialog, { open: state.previewDialog.open, title: state.previewDialog.title, leftTitle: state.previewDialog.leftTitle, leftContent: state.previewDialog.leftContent, rightTitle: state.previewDialog.rightTitle, rightContent: state.previewDialog.rightContent, description: state.previewDialog.description, loading: state.previewDialog.loading, onConfirm: state.previewDialog.onConfirm, onClose: () => {
447
+ state.previewDialog.open = false;
448
+ } })] }) }) }) }) }));
449
+ }
450
+ const StyledDashboard = styled(Dashboard) `
451
+ .dashboard-content {
452
+ display: flex;
453
+ flex-direction: row;
454
+ gap: ${({ theme }) => theme.spacing(1)};
455
+ padding: 0 ${({ theme }) => theme.spacing(1)};
456
+ width: 100vw;
457
+ height: calc(100vh - 64px - 1px);
458
+ }
459
+
460
+ .header-container {
461
+ padding-left: ${({ theme }) => theme.spacing(3)};
462
+ padding-right: ${({ theme }) => theme.spacing(3)};
463
+
464
+ ${({ theme }) => theme.breakpoints.down('md')} {
465
+ padding-left: ${({ theme }) => theme.spacing(2)};
466
+ padding-right: ${({ theme }) => theme.spacing(2)};
467
+
468
+ .header-addons {
469
+ button {
470
+ svg,
471
+ .${circularProgressClasses.root} {
472
+ font-size: 1.25rem !important;
473
+ width: 1.25rem !important;
474
+ height: 1.25rem !important;
475
+ }
476
+ }
477
+ }
478
+ }
479
+
480
+ .locales {
481
+ border-radius: ${({ theme }) => theme.shape.borderRadius}px;
482
+ box-shadow: ${({ theme }) => theme.shadows[1]};
483
+ margin-top: ${({ theme }) => theme.spacing(1.5)}px;
484
+ }
485
+ }
486
+ `;
487
+ function LayoutWrapper({ loadState, loadedData, ...rest }) {
488
+ return (_jsx(ToastProvider, { children: _jsx(LocaleProvider, { translations: translations, fallbackLocale: "en", children: _jsx(Layout, { loadState: loadState, loadedData: loadedData }) }) }));
489
+ }
490
+ export default LayoutWrapper;
491
+ function CreateResource({ open, onClose }) {
492
+ if (!open) {
493
+ return null;
494
+ }
495
+ const tenantScope = 'pages-kit-block-studio';
496
+ return (_jsx(Suspense, { children: _jsx(BlockletStudio, { mode: "dialog", tenantScope: tenantScope, title: "Pages Kit Blocks", description: "", note: "", introduction: "", logo: "", componentDid: PAGES_KIT_BLOCK_STUDIO_BLOCKLET_DID,
497
+ // 透传到 get blocklet resource 的参数
498
+ resourcesParams: {}, dependentComponentsMode: "readonly", open: true, setOpen: () => onClose(), onConnected: () => { }, onUploaded: () => { }, onReleased: () => { },
499
+ // onOpened={() => onOpened?.()}
500
+ // 默认选中的资源
501
+ resources: {} }) }));
4
502
  }
@@ -14,8 +14,8 @@ import { nodePolyfills } from 'vite-plugin-node-polyfills';
14
14
  import pages, { DefaultPageStrategy } from 'vite-plugin-react-pages';
15
15
  import { findComponentFiles, setBlockEntryFilesPattern, getBlockEntryFilesPattern, getBlockName, logger, } from '../utils/helper';
16
16
  import { initHtmlPreviewTransformPlugin, VIRTUAL_MODULE_ID, readHtmlFiles, generateComponent, } from './vite-plugin-html-transform';
17
- const BUILTIN_MODULES_VAR = '__PAGES_KIT_BUILTIN_MODULES__';
18
- logger.log('BUILTIN_MODULES_VAR', BUILTIN_MODULES_VAR);
17
+ // const BUILTIN_MODULES_VAR = '__PAGES_KIT_BUILTIN_MODULES__';
18
+ // logger.log('BUILTIN_MODULES_VAR', BUILTIN_MODULES_VAR);
19
19
  const defaultBlockExternals = {
20
20
  // 核心 React 相关
21
21
  react: '@blocklet/pages-kit/builtin/react',