HumanBreak/src/types/plugin.d.ts

91 lines
2.4 KiB
TypeScript
Raw Normal View History

2022-11-13 18:02:05 +08:00
// 这里包含所有插件导出的函数及变量声明声明的函数会在类型标注中标注到core上
2022-11-14 17:11:23 +08:00
type Ref<T> = {
value: T;
};
2022-11-16 23:01:23 +08:00
interface PluginDeclaration extends PluginUtils {
2022-11-13 18:02:05 +08:00
/**
* 使core.addPop或core.plugin.addPop调用
* @param px
* @param py
* @param value
*/
addPop(px: number, py: number, value: string): void;
/** 添加变量 例所有的正在弹出的文字像这个就可以使用core.plugin.pop获取 */
pop: any[];
2022-11-14 17:11:23 +08:00
/** 手册是否打开 */
readonly bookOpened: Ref<boolean>;
/** 手册详细信息 */
readonly bookDetail: Ref<boolean>;
/** ui栈 */
readonly uiStack: Ref<Component[]>;
2022-11-16 23:01:23 +08:00
/** 是否是移动设备 */
readonly isMobile: boolean;
2022-11-14 17:11:23 +08:00
/**
*
* @param ele
* @param fn x y和鼠标事件或点击事件
* @param ondown
* @param global
*/
useDrag(
ele: HTMLElement,
fn: (x: number, y: number, e: MouseEvent | TouchEvent) => void,
ondown?: (x: number, y: number, e: MouseEvent | TouchEvent) => void,
global: boolean = false
): void;
/**
*
* @param ele
* @param fn
*/
useWheel(
ele: HTMLElement,
fn: (x: number, y: number, z: number, e: WheelEvent) => void
): void;
2022-11-16 23:01:23 +08:00
/**
*
* @param fn
*/
addAnimate(fn: (time: number) => void);
/**
*
* @param fn
*/
removeAnimate(fn: (time: number) => void);
}
interface PluginUtils {
/**
* undefined或null
* @param value
*/
has<T>(value: T): value is NonNullable<T>;
/**
*
* @param damage
*/
getDamageColor(damage: number): string;
2022-11-13 18:02:05 +08:00
}
type Forward<T> = {
[K in keyof T as T[K] extends Function
? K extends `_${string}`
? never
: K
: never]: T[K];
};
type ForwardKeys<T> = keyof Forward<T>;