@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.
@@ -49,4 +49,5 @@ export const BuiltinModules = {
49
49
  '@blocklet/pages-kit/builtin/uploader': {},
50
50
  '@blocklet/pages-kit/builtin/color-picker': {},
51
51
  '@blocklet/pages-kit/builtin/markdown/index': {},
52
+ '@blocklet/pages-kit/builtin/event-bus': {},
52
53
  };
@@ -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;