mirror of
https://github.com/sern-handler/handler
synced 2026-06-25 01:02:17 +00:00
update onError to be record
This commit is contained in:
@@ -12,12 +12,12 @@ interface MetadataAccess {
|
||||
}
|
||||
|
||||
interface OnErrorAccess {
|
||||
getErrorCallback(m: Module): Function|undefined;
|
||||
setErrorCallback(m: Module, c: Function): void;
|
||||
getErrorCallback(m: Module): Record<string,Function>|undefined;
|
||||
setErrorCallback(m: Module, c: Record<string,Function>): void;
|
||||
}
|
||||
/**
|
||||
* @since 2.0.0
|
||||
* @deprecated - direct access to the module manager will be removed in version 4
|
||||
* @internal - direct access to the module manager will be removed in version 4
|
||||
*/
|
||||
export interface ModuleManager extends MetadataAccess, OnErrorAccess {
|
||||
get(id: string): string | undefined;
|
||||
|
||||
@@ -6,5 +6,5 @@ import type { CommandMeta, Module } from '../../types/core-modules';
|
||||
export interface CoreModuleStore {
|
||||
commands: Map<string, string>;
|
||||
metadata: WeakMap<Module, CommandMeta>;
|
||||
onError: WeakMap<Module, Function>;
|
||||
onError: WeakMap<Module, Record<string,Function>>;
|
||||
}
|
||||
|
||||
@@ -37,7 +37,7 @@ export async function importModule<T>(absPath: string) {
|
||||
.unwrapOr({ module: commandModule, onError }) as T;
|
||||
}
|
||||
interface FileExtras {
|
||||
onError : Function
|
||||
onError : Record<string, Function>|undefined
|
||||
}
|
||||
|
||||
export async function defaultModuleLoader<T extends Module>(absPath: string): ModuleResult<T> {
|
||||
|
||||
@@ -7,7 +7,7 @@ import { CoreModuleStore } from '../contracts';
|
||||
* For interacting with modules, use the ModuleManager instead.
|
||||
*/
|
||||
export class ModuleStore implements CoreModuleStore {
|
||||
onError = new WeakMap<Module, Function>();
|
||||
onError = new WeakMap<Module, Record<string, Function>>();
|
||||
metadata = new WeakMap<Module, CommandMeta>();
|
||||
commands = new Map<string, string>();
|
||||
}
|
||||
|
||||
@@ -11,10 +11,11 @@ import { CommandType } from '../enums';
|
||||
export class DefaultModuleManager implements ModuleManager {
|
||||
constructor(private moduleStore: CoreModuleStore) {}
|
||||
|
||||
getErrorCallback(m: Module): Function | undefined {
|
||||
|
||||
getErrorCallback(m: Module): Record<string, Function> | undefined {
|
||||
return this.moduleStore.onError.get(m);
|
||||
}
|
||||
setErrorCallback(m: Module, c: Function): void {
|
||||
setErrorCallback(m: Module, c: Record<string, Function>): void {
|
||||
this.moduleStore.onError.set(m, c);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user