@blocklet/pages-kit 0.4.11 → 0.4.13-beta.20250227
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/api/pages-kit.js +4 -2
- package/lib/cjs/components/CustomComponentRenderer/index.js +12 -7
- package/lib/cjs/components/CustomComponentRenderer/state.js +33 -4
- package/lib/cjs/tsconfig.tsbuildinfo +1 -1
- package/lib/cjs/utils/inject-global-components.js +18 -3
- package/lib/cjs/utils/property.js +4 -2
- package/lib/esm/api/pages-kit.js +4 -2
- package/lib/esm/components/CustomComponentRenderer/index.js +12 -7
- package/lib/esm/components/CustomComponentRenderer/state.js +33 -4
- package/lib/esm/tsconfig.tsbuildinfo +1 -1
- package/lib/esm/utils/inject-global-components.js +18 -3
- package/lib/esm/utils/property.js +4 -2
- package/lib/types/components/CustomComponentRenderer/index.d.ts +1 -0
- package/lib/types/components/CustomComponentRenderer/state.d.ts +1 -0
- package/lib/types/tsconfig.tsbuildinfo +1 -1
- package/lib/types/types/core.d.ts +2 -1
- package/package.json +10 -10
|
@@ -33,20 +33,21 @@ function injectGlobalComponents() {
|
|
|
33
33
|
'@blocklet/pages-kit/builtin/pages-kit': { CustomComponentRenderer },
|
|
34
34
|
'@blocklet/pages-kit/builtin/dayjs': dayjs,
|
|
35
35
|
'@blocklet/pages-kit/builtin/utils': utils,
|
|
36
|
+
'@blocklet/pages-kit/builtin/stream': stream,
|
|
36
37
|
'@blocklet/pages-kit/builtin/react': react,
|
|
37
38
|
'@blocklet/pages-kit/builtin/emotion/css': emotionCss,
|
|
38
39
|
'@blocklet/pages-kit/builtin/mui/material': muiMaterial,
|
|
39
40
|
'@blocklet/pages-kit/builtin/mui/lab': muiLab,
|
|
40
41
|
'@blocklet/pages-kit/builtin/react-hook-form': reactHookForm,
|
|
41
42
|
'@blocklet/pages-kit/builtin/iconify/react': iconifyReact,
|
|
43
|
+
//
|
|
42
44
|
'@blocklet/pages-kit/builtin/zustand': zustand,
|
|
43
45
|
'@blocklet/pages-kit/builtin/zustand/middleware/immer': zustandMiddlewareImmer,
|
|
44
46
|
'@blocklet/pages-kit/builtin/immer': immer,
|
|
45
47
|
'@blocklet/pages-kit/builtin/react-wrap-balancer': reactWrapBalancer,
|
|
46
|
-
'@blocklet/pages-kit/builtin/
|
|
48
|
+
'@blocklet/pages-kit/builtin/react-router-dom': reactRouterDOM,
|
|
47
49
|
'@blocklet/pages-kit/builtin/session': session,
|
|
48
50
|
'@blocklet/pages-kit/builtin/locale': locale,
|
|
49
|
-
'@blocklet/pages-kit/builtin/react-router-dom': reactRouterDOM,
|
|
50
51
|
'@blocklet/pages-kit/builtin/arcblock/ux': arcblockUx,
|
|
51
52
|
'@blocklet/pages-kit/builtin/page/header': pageHeader,
|
|
52
53
|
'@blocklet/pages-kit/builtin/components': components,
|
|
@@ -58,7 +59,21 @@ function injectGlobalComponents() {
|
|
|
58
59
|
'@blocklet/pages-kit/builtin/async/ai-runtime': aiRuntime,
|
|
59
60
|
},
|
|
60
61
|
require(module) {
|
|
61
|
-
|
|
62
|
+
var _a;
|
|
63
|
+
if ((_a = win[BuiltinModulesGlobalVariableName]) === null || _a === void 0 ? void 0 : _a.modules[module]) {
|
|
64
|
+
return win[BuiltinModulesGlobalVariableName].modules[module];
|
|
65
|
+
}
|
|
66
|
+
// Try loading from CDN or dynamic import
|
|
67
|
+
try {
|
|
68
|
+
// TODO: 需要支持动态加载
|
|
69
|
+
// const module = await import(/* webpackIgnore: true */ `https://cdn.jsdelivr.net/npm/${moduleName}`);
|
|
70
|
+
// return module;
|
|
71
|
+
return null;
|
|
72
|
+
}
|
|
73
|
+
catch (err) {
|
|
74
|
+
console.warn(`Failed to load module ${module}`, err);
|
|
75
|
+
return null;
|
|
76
|
+
}
|
|
62
77
|
},
|
|
63
78
|
};
|
|
64
79
|
win.React = React;
|
|
@@ -13,13 +13,15 @@ export function mergeComponent({ componentId, getComponent, locale, defaultLocal
|
|
|
13
13
|
const property = (_b = (_a = component === null || component === void 0 ? void 0 : component.properties) === null || _a === void 0 ? void 0 : _a[id]) === null || _b === void 0 ? void 0 : _b.data;
|
|
14
14
|
if (!property)
|
|
15
15
|
return [];
|
|
16
|
-
|
|
16
|
+
// // if key is undefined, use id
|
|
17
|
+
return [property.key || property.id, parsePropertyValue(property, value, { locale, defaultLocale })];
|
|
17
18
|
}));
|
|
18
19
|
while (component) {
|
|
19
20
|
assignNullableFields(properties, Object.fromEntries(Object.values((_a = component.properties) !== null && _a !== void 0 ? _a : {}).map(({ data }) => {
|
|
20
21
|
var _a, _b, _c, _d, _e;
|
|
21
22
|
return [
|
|
22
|
-
|
|
23
|
+
// if key is undefined, use id
|
|
24
|
+
data.key || data.id,
|
|
23
25
|
parsePropertyValue(data, (_c = (_b = (_a = data.locales) === null || _a === void 0 ? void 0 : _a[locale]) === null || _b === void 0 ? void 0 : _b.defaultValue) !== null && _c !== void 0 ? _c : (_e = (_d = data.locales) === null || _d === void 0 ? void 0 : _d[defaultLocale]) === null || _e === void 0 ? void 0 : _e.defaultValue, { locale, defaultLocale }),
|
|
24
26
|
];
|
|
25
27
|
})));
|
|
@@ -32,5 +32,6 @@ export interface CustomComponentRendererProps {
|
|
|
32
32
|
dev?: CustomComponentRendererDevProps;
|
|
33
33
|
fallbackRender?: any;
|
|
34
34
|
ErrorBoundaryProps?: ComponentProps<typeof ErrorBoundary>;
|
|
35
|
+
renderType?: 'view' | 'setting';
|
|
35
36
|
}
|
|
36
37
|
export default function CustomComponentRenderer({ dev, ...props }: CustomComponentRendererProps): import("react/jsx-runtime").JSX.Element;
|
|
@@ -27,6 +27,7 @@ export declare const customComponentStates: () => UseBoundStore<StoreApi<CustomC
|
|
|
27
27
|
export declare function useComponent({ instanceId, componentId, properties, locale, dev }: CustomComponentRendererProps): {
|
|
28
28
|
error?: Error;
|
|
29
29
|
Component?: CustomComponentType;
|
|
30
|
+
EditComponent?: CustomComponentType;
|
|
30
31
|
props?: {
|
|
31
32
|
[key: string]: any;
|
|
32
33
|
};
|