@blocklet/pages-kit-block-studio 0.5.54 → 0.5.56
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/middlewares/init-block-studio-router.js +9 -9
- package/lib/cjs/middlewares/init-resource-router.js +1 -1
- package/lib/cjs/plugins/_theme.js +16 -11
- package/lib/cjs/tsconfig.tsbuildinfo +1 -1
- package/lib/cjs/utils/generate-wrapper-code.js +1 -1
- package/lib/esm/middlewares/init-block-studio-router.js +9 -9
- package/lib/esm/middlewares/init-resource-router.js +1 -1
- package/lib/esm/plugins/_theme.js +17 -14
- package/lib/esm/tsconfig.tsbuildinfo +1 -1
- package/lib/esm/utils/generate-wrapper-code.js +1 -1
- package/lib/types/tsconfig.tsbuildinfo +1 -1
- package/package.json +3 -3
|
@@ -154,7 +154,7 @@ exports.initBlockStudioRouter.get('/', async (req, res) => {
|
|
|
154
154
|
return res.json(metadata);
|
|
155
155
|
}
|
|
156
156
|
catch (error) {
|
|
157
|
-
return res.status(
|
|
157
|
+
return res.status(400).json({ error: 'Failed to read file' });
|
|
158
158
|
}
|
|
159
159
|
});
|
|
160
160
|
exports.initBlockStudioRouter.post('/', async (req, res) => {
|
|
@@ -202,7 +202,7 @@ exports.initBlockStudioRouter.post('/', async (req, res) => {
|
|
|
202
202
|
return res.json({ success: true, content: mergedContent, message: 'Updated' });
|
|
203
203
|
}
|
|
204
204
|
catch (error) {
|
|
205
|
-
return res.status(
|
|
205
|
+
return res.status(400).json({ error: 'Failed to write file' });
|
|
206
206
|
}
|
|
207
207
|
});
|
|
208
208
|
exports.initBlockStudioRouter.post('/create', async (req, res) => {
|
|
@@ -264,7 +264,7 @@ exports.initBlockStudioRouter.post('/create', async (req, res) => {
|
|
|
264
264
|
}
|
|
265
265
|
catch (error) {
|
|
266
266
|
console.error('Failed to create block:', error);
|
|
267
|
-
return res.status(
|
|
267
|
+
return res.status(400).json({ error: 'Failed to create block' });
|
|
268
268
|
}
|
|
269
269
|
});
|
|
270
270
|
exports.initBlockStudioRouter.get('/resources', async (req, res) => {
|
|
@@ -358,7 +358,7 @@ exports.initBlockStudioRouter.post('/properties-to-interface', async (req, res)
|
|
|
358
358
|
}
|
|
359
359
|
catch (conversionError) {
|
|
360
360
|
console.error('Failed to convert properties to interface:', conversionError);
|
|
361
|
-
return res.status(
|
|
361
|
+
return res.status(400).json({
|
|
362
362
|
success: false,
|
|
363
363
|
error: `Failed to convert properties to interface: ${conversionError.message}`,
|
|
364
364
|
});
|
|
@@ -366,7 +366,7 @@ exports.initBlockStudioRouter.post('/properties-to-interface', async (req, res)
|
|
|
366
366
|
}
|
|
367
367
|
catch (error) {
|
|
368
368
|
console.error('Failed to generate interface:', error);
|
|
369
|
-
return res.status(
|
|
369
|
+
return res.status(400).json({
|
|
370
370
|
success: false,
|
|
371
371
|
error: `Failed to generate interface: ${error.message}`,
|
|
372
372
|
});
|
|
@@ -424,7 +424,7 @@ exports.initBlockStudioRouter.post('/interface-to-properties', async (req, res)
|
|
|
424
424
|
}
|
|
425
425
|
catch (conversionError) {
|
|
426
426
|
console.error('Failed to convert interface to properties:', conversionError);
|
|
427
|
-
return res.status(
|
|
427
|
+
return res.status(400).json({
|
|
428
428
|
success: false,
|
|
429
429
|
error: `Failed to convert interface to properties: ${conversionError.message}`,
|
|
430
430
|
});
|
|
@@ -432,7 +432,7 @@ exports.initBlockStudioRouter.post('/interface-to-properties', async (req, res)
|
|
|
432
432
|
}
|
|
433
433
|
catch (error) {
|
|
434
434
|
console.error('Failed to generate metadata:', error);
|
|
435
|
-
return res.status(
|
|
435
|
+
return res.status(400).json({
|
|
436
436
|
success: false,
|
|
437
437
|
error: `Failed to generate metadata: ${error.message}`,
|
|
438
438
|
});
|
|
@@ -494,7 +494,7 @@ exports.initBlockStudioRouter.delete('/delete', async (req, res) => {
|
|
|
494
494
|
}
|
|
495
495
|
catch (deleteError) {
|
|
496
496
|
console.error('Failed to delete component directory:', deleteError);
|
|
497
|
-
return res.status(
|
|
497
|
+
return res.status(400).json({
|
|
498
498
|
success: false,
|
|
499
499
|
error: `Failed to delete component directory: ${deleteError.message}`,
|
|
500
500
|
});
|
|
@@ -502,7 +502,7 @@ exports.initBlockStudioRouter.delete('/delete', async (req, res) => {
|
|
|
502
502
|
}
|
|
503
503
|
catch (error) {
|
|
504
504
|
console.error('Failed to delete component:', error);
|
|
505
|
-
return res.status(
|
|
505
|
+
return res.status(400).json({
|
|
506
506
|
success: false,
|
|
507
507
|
error: `Failed to delete component: ${error.message}`,
|
|
508
508
|
});
|
|
@@ -292,7 +292,7 @@ exports.initResourceRouter.post('/', async (req, res) => {
|
|
|
292
292
|
}
|
|
293
293
|
catch (error) {
|
|
294
294
|
console.error('Build failed:', error);
|
|
295
|
-
res.status(
|
|
295
|
+
res.status(400).json({ error: 'Build failed' });
|
|
296
296
|
}
|
|
297
297
|
});
|
|
298
298
|
exports.default = exports.initResourceRouter;
|
|
@@ -46,7 +46,6 @@ const jsx_runtime_1 = require("react/jsx-runtime");
|
|
|
46
46
|
const Session_1 = require("@arcblock/did-connect/lib/Session");
|
|
47
47
|
const Config_1 = require("@arcblock/ux/lib/Config");
|
|
48
48
|
const context_1 = require("@arcblock/ux/lib/Locale/context");
|
|
49
|
-
const Theme_1 = require("@arcblock/ux/lib/Theme");
|
|
50
49
|
const Toast_1 = __importStar(require("@arcblock/ux/lib/Toast"));
|
|
51
50
|
const js_sdk_1 = require("@blocklet/js-sdk");
|
|
52
51
|
const theme_1 = require("@blocklet/pages-kit-inner-components/theme");
|
|
@@ -91,6 +90,14 @@ const api = (0, js_sdk_1.createAxios)({
|
|
|
91
90
|
componentDid: PAGES_KIT_BLOCK_STUDIO_BLOCKLET_DID,
|
|
92
91
|
});
|
|
93
92
|
const { SessionProvider, SessionContext } = (0, Session_1.createAuthServiceSessionContext)();
|
|
93
|
+
function useIsInsideIframe() {
|
|
94
|
+
const location = (0, react_router_dom_1.useLocation)();
|
|
95
|
+
const isInsideIframe = (0, react_1.useMemo)(() => {
|
|
96
|
+
const url = new URL(window.location.href);
|
|
97
|
+
return url.searchParams.get('simulator') === '1';
|
|
98
|
+
}, [location.href]);
|
|
99
|
+
return isInsideIframe;
|
|
100
|
+
}
|
|
94
101
|
function useSessionContext() {
|
|
95
102
|
const info = (0, react_1.useContext)(SessionContext);
|
|
96
103
|
return info;
|
|
@@ -310,10 +317,7 @@ function Layout({ loadState, loadedData }) {
|
|
|
310
317
|
const navigate = (0, react_router_dom_1.useNavigate)();
|
|
311
318
|
const staticData = (0, client_1.useStaticData)();
|
|
312
319
|
// 获取当前URL参数判断是否是在iframe内
|
|
313
|
-
const isInsideIframe = (
|
|
314
|
-
const url = new URL(window.location.href);
|
|
315
|
-
return url.searchParams.get('simulator') === '1';
|
|
316
|
-
}, [window.location.href]);
|
|
320
|
+
const isInsideIframe = useIsInsideIframe();
|
|
317
321
|
(0, ahooks_2.useUpdateEffect)(() => {
|
|
318
322
|
const iframe = document.querySelector('#preview-iframe');
|
|
319
323
|
if (iframe && iframe.contentWindow) {
|
|
@@ -675,11 +679,11 @@ function Layout({ loadState, loadedData }) {
|
|
|
675
679
|
const url = new URL(window.location.href);
|
|
676
680
|
const initialComponentId = url.searchParams.get('componentId') || state.metadata.id;
|
|
677
681
|
const initialLocale = url.searchParams.get('locale') || locale || 'en';
|
|
678
|
-
return ((0, jsx_runtime_1.jsx)(material_1.Box, { className: "custom-component-root", sx: { height: '100vh', width: '100vw', overflow: 'auto' }, children: (0, jsx_runtime_1.jsx)(
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
682
|
+
return ((0, jsx_runtime_1.jsx)(material_1.Box, { className: "custom-component-root", sx: { height: '100vh', width: '100vw', overflow: 'auto' }, children: (0, jsx_runtime_1.jsx)(components_2.CustomComponentRenderer, { locale: initialLocale, componentId: initialComponentId || state.metadata.id, dev: {
|
|
683
|
+
mode: 'draft',
|
|
684
|
+
components: mergedAllBlocks,
|
|
685
|
+
defaultLocale,
|
|
686
|
+
}, properties: mergedPropertiesValues }, `custom-${renderComponentTrigger}`) }));
|
|
683
687
|
}
|
|
684
688
|
// 没有匹配到路由,使用欢迎页面
|
|
685
689
|
if (notSelectedBlock) {
|
|
@@ -1164,7 +1168,8 @@ const StyledDashboard = (0, material_1.styled)(studio_ui_1.Dashboard) `
|
|
|
1164
1168
|
}
|
|
1165
1169
|
`;
|
|
1166
1170
|
function LayoutWrapper({ loadState, loadedData, ...rest }) {
|
|
1167
|
-
|
|
1171
|
+
const isInsideIframe = useIsInsideIframe();
|
|
1172
|
+
return ((0, jsx_runtime_1.jsx)(material_1.StyledEngineProvider, { injectFirst: true, children: (0, jsx_runtime_1.jsx)(theme_1.PagesKitThemeProvider, { isDashboard: isInsideIframe, children: (0, jsx_runtime_1.jsx)(Toast_1.ToastProvider, { children: (0, jsx_runtime_1.jsx)(context_1.LocaleProvider, { translations: locales_1.translations, fallbackLocale: "en", children: (0, jsx_runtime_1.jsx)(SessionProvider, { serviceHost: basename, protectedRoutes: [`${basename}/*`], children: (0, jsx_runtime_1.jsx)(Layout, { loadState: loadState, loadedData: loadedData }) }) }) }) }) }));
|
|
1168
1173
|
}
|
|
1169
1174
|
exports.default = LayoutWrapper;
|
|
1170
1175
|
function CreateResource({ open, onClose }) {
|