@blocklet/pages-kit 0.5.17 → 0.5.19
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/builtin/event-bus.js +42 -0
- package/lib/cjs/tsconfig.tsbuildinfo +1 -1
- package/lib/cjs/utils/builtin.js +1 -0
- package/lib/cjs/utils/inject-global-components.js +2 -0
- package/lib/cjs/utils/property.js +5 -2
- package/lib/esm/builtin/event-bus.js +35 -0
- package/lib/esm/tsconfig.tsbuildinfo +1 -1
- package/lib/esm/utils/builtin.js +1 -0
- package/lib/esm/utils/inject-global-components.js +2 -0
- package/lib/esm/utils/property.js +4 -1
- package/lib/types/builtin/event-bus.d.ts +18 -0
- package/lib/types/tsconfig.tsbuildinfo +1 -1
- package/lib/types/utils/builtin.d.ts +1 -0
- package/lib/types/utils/property.d.ts +2 -1
- package/package.json +8 -6
package/lib/esm/utils/builtin.js
CHANGED
|
@@ -10,6 +10,7 @@ import * as colorPicker from '../builtin/color-picker';
|
|
|
10
10
|
import * as components from '../builtin/components';
|
|
11
11
|
import * as dayjs from '../builtin/dayjs';
|
|
12
12
|
import * as emotionCss from '../builtin/emotion/css';
|
|
13
|
+
import * as eventBus from '../builtin/event-bus';
|
|
13
14
|
import * as iconifyReact from '../builtin/iconify/react';
|
|
14
15
|
import * as immer from '../builtin/immer';
|
|
15
16
|
import * as locale from '../builtin/locale';
|
|
@@ -79,6 +80,7 @@ export function injectGlobalComponents() {
|
|
|
79
80
|
'@blocklet/pages-kit/builtin/async/react-syntax-highlighter': reactSyntaxHighlighter,
|
|
80
81
|
'@blocklet/pages-kit/builtin/async/image-preview': imagePreview,
|
|
81
82
|
'@blocklet/pages-kit/builtin/async/ai-runtime': import('../builtin/async/ai-runtime'),
|
|
83
|
+
'@blocklet/pages-kit/builtin/event-bus': eventBus,
|
|
82
84
|
};
|
|
83
85
|
// set global variable
|
|
84
86
|
win[BuiltinModulesGlobalVariableName] = {
|
|
@@ -1,6 +1,8 @@
|
|
|
1
|
+
import { initSanitize } from '@blocklet/xss';
|
|
1
2
|
import snakeCase from 'lodash/snakeCase';
|
|
2
3
|
import * as yaml from 'yaml';
|
|
3
4
|
import { isBrowserEnv, COLOR_CONVERT_FUNCTION_NAME } from './common';
|
|
5
|
+
export const sanitize = initSanitize();
|
|
4
6
|
export function componentUMDName({ componentId }) {
|
|
5
7
|
return `PagesCustomComponent${snakeCase(componentId)}`;
|
|
6
8
|
}
|
|
@@ -92,12 +94,13 @@ export const initDynamicParsePropertyValueHandlers = () => {
|
|
|
92
94
|
return initDynamicPropertyHandlersPromise;
|
|
93
95
|
};
|
|
94
96
|
initDynamicParsePropertyValueHandlers();
|
|
95
|
-
export function parsePropertyValue(property,
|
|
97
|
+
export function parsePropertyValue(property, inputValue, { locale, defaultLocale, propertyHandlers, }) {
|
|
96
98
|
// 混合动态和自定义的属性处理函数,这个需要放在最前面,因为有可能存在覆盖下面的处理
|
|
97
99
|
const mixedPropertyHandlers = {
|
|
98
100
|
...(dynamicPropertyHandlers ?? {}),
|
|
99
101
|
...(propertyHandlers ?? {}),
|
|
100
102
|
};
|
|
103
|
+
const value = inputValue;
|
|
101
104
|
if (mixedPropertyHandlers && property.type && typeof mixedPropertyHandlers[property.type] === 'function') {
|
|
102
105
|
try {
|
|
103
106
|
const handler = mixedPropertyHandlers[property.type];
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { Emitter } from 'mitt';
|
|
2
|
+
interface EventCallBack<T> {
|
|
3
|
+
(args: T): void;
|
|
4
|
+
}
|
|
5
|
+
export declare const eventBus: Emitter<Record<string, any>>;
|
|
6
|
+
export declare const useEventBus: <T>(eventName?: string, eventCallBack?: EventCallBack<T>, deps?: any[]) => {
|
|
7
|
+
emit: <K>(name: string, data: K) => void;
|
|
8
|
+
off: {
|
|
9
|
+
<Key extends string>(type: Key, handler?: import("mitt").Handler<any> | undefined): void;
|
|
10
|
+
(type: "*", handler: import("mitt").WildcardHandler<Record<string, any>>): void;
|
|
11
|
+
};
|
|
12
|
+
on: {
|
|
13
|
+
<Key extends string>(type: Key, handler: import("mitt").Handler<any>): void;
|
|
14
|
+
(type: "*", handler: import("mitt").WildcardHandler<Record<string, any>>): void;
|
|
15
|
+
};
|
|
16
|
+
all: import("mitt").EventHandlerMap<Record<string, any>>;
|
|
17
|
+
};
|
|
18
|
+
export default useEventBus;
|