@blocklet/pages-kit 0.5.17 → 0.5.18
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/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/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/package.json +2 -1
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] = {
|
|
@@ -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;
|