Update type signatures
This commit is contained in:
parent
4ae1c90f1a
commit
21c7998294
2 changed files with 46 additions and 21 deletions
|
@ -5,7 +5,7 @@
|
|||
},
|
||||
"type": "module",
|
||||
"license": "MIT",
|
||||
"version": "0.0.2",
|
||||
"version": "0.0.3",
|
||||
"url": "https://git.but.gay/darkwiiplayer/controller-registry",
|
||||
"scripts": {
|
||||
"definitions": "tsc src/*.js --declaration --allowJs --emitDeclarationOnly"
|
||||
|
|
65
src/controller-registry.d.ts
vendored
65
src/controller-registry.d.ts
vendored
|
@ -1,48 +1,73 @@
|
|||
/** @typedef {Promise & {signal: AbortSignal}} PromiseWithSignal */
|
||||
/** @typedef {(element: HTMLElement, detached: PromiseWithSignal) => void} Callback */
|
||||
/** @typedef {new (element: HTMLElement, detached: PromiseWithSignal) => Object} ControllerClass */
|
||||
/** @typedef {Callback|ControllerClass} Controller */
|
||||
export class ControllerList {
|
||||
/**
|
||||
* @param {HTMLElement} element
|
||||
* @param {String} attribute
|
||||
* */
|
||||
* @param {HTMLElement} element
|
||||
* @param {string} attribute
|
||||
* */
|
||||
constructor(element: HTMLElement, attribute?: string);
|
||||
/** @param {String} name */
|
||||
/** @param {string} name */
|
||||
contains(name: string): any;
|
||||
/** @param {String} name */
|
||||
/** @param {string} name */
|
||||
add(name: string): void;
|
||||
/** @param {String} name */
|
||||
/** @param {string} name */
|
||||
remove(name: string): void;
|
||||
/**
|
||||
* @param {String} name
|
||||
* @param {String} replacement
|
||||
* @param {string} name
|
||||
* @param {string} replacement
|
||||
*/
|
||||
replace(name: string, replacement: string): boolean;
|
||||
/**
|
||||
* @param {String} name
|
||||
* @param {string} name
|
||||
* @param {Boolean} force
|
||||
*/
|
||||
toggle(name: string, force: boolean): void;
|
||||
#private;
|
||||
}
|
||||
export class ControllerRegistry {
|
||||
/** @typedef {HTMLElement} Root */
|
||||
/** @typedef {Document|DocumentFragment|HTMLElement} Root */
|
||||
/**
|
||||
* @param {Root} root
|
||||
* @param {String} attribute
|
||||
* @param {string} attribute
|
||||
*/
|
||||
constructor(root: HTMLElement, attribute?: string);
|
||||
constructor(root: Document | HTMLElement | DocumentFragment, attribute?: string);
|
||||
/**
|
||||
* @param {Root} root
|
||||
*/
|
||||
upgrade(root: HTMLElement): void;
|
||||
upgrade(root: Document | HTMLElement | DocumentFragment): void;
|
||||
/**
|
||||
* @param {String} name
|
||||
* @param {Function} callback
|
||||
* @param {string} name
|
||||
* @param {Controller} callback
|
||||
*/
|
||||
define(name: string, callback: Function): void;
|
||||
get(name: any): any;
|
||||
list(element: any): any;
|
||||
getName(controller: any): void;
|
||||
whenDefined(name: any): void;
|
||||
define(name: string, callback: Controller): void;
|
||||
/** Gets a controller associated with a given name
|
||||
* @param {string} name
|
||||
*/
|
||||
get(name: string): any;
|
||||
/** Gets the name a controller is registered with
|
||||
* @param {Controller} controller
|
||||
*/
|
||||
getName(controller: Controller): any;
|
||||
/**
|
||||
* @param {string} name
|
||||
*/
|
||||
whenDefined(name: string): any;
|
||||
/**
|
||||
* @param {HTMLElement} element
|
||||
* @return {ControllerList}
|
||||
*/
|
||||
list(element: HTMLElement): ControllerList;
|
||||
/** @param {HTMLElement} element */
|
||||
attached(element: HTMLElement): any[];
|
||||
#private;
|
||||
}
|
||||
declare const _default: ControllerRegistry;
|
||||
export default _default;
|
||||
export type PromiseWithSignal = Promise<any> & {
|
||||
signal: AbortSignal;
|
||||
};
|
||||
export type Callback = (element: HTMLElement, detached: PromiseWithSignal) => void;
|
||||
export type ControllerClass = new (element: HTMLElement, detached: PromiseWithSignal) => any;
|
||||
export type Controller = Callback | ControllerClass;
|
||||
|
|
Loading…
Reference in a new issue