-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcommon.d.ts
103 lines (82 loc) · 3.49 KB
/
common.d.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
declare module 'common' {
import { EventEmitter } from 'events';
global {
export namespace KLF {
//#region Enums
/** Various level of logging detail */
export enum LogDetailLevel {
/** Provides the highest level of detail */
Verbose,
/** Debug provides slightly less detail than Verbose */
Debug,
/** Display errors and warnings */
Warnings,
/** Only display actual errors */
Errors,
/** No console logging at all */
None
}
//#endregion
//#region Types
/** A collection of all known component types */
export type ComponentCollection = Map<string, IComponentEntry>;
export type EnumType = 'bitflag'
| 'number'
| 'string';
/** Manager functions exposed to the outside world */
export type ExternalFunctionNames = 'add'
| 'ast'
| 'config'
| 'disable'
| 'enable'
| 'get'
| 'init'
| 'remove'
| 'update';
/** Human friendly version of LogDetailLevel */
export type LogDetailWord = 'None'
| 'Errors'
| 'Warnings'
| 'Debug'
| 'Verbose';
export type LogMessageCallback = (logEntry: LogMessageEventArgs) => void;
export type LoaderFilter = string | ((filename: string) => boolean);
export type LoaderFilterAction = 'Include' | 'Exclude';
export type LoaderFilterCallback = (filename: string, filter: LoaderFilter, action: LoaderFilterAction) => void;
export type LoaderFilterList = LoaderFilter[];
//#endregion
//#region Interfaces
export interface IComponent<TType extends new (...args: any[]) => any = any> {
/** Get the default config for the type */
getDefaultConfig(config: IModuleManager): Partial<TType>;
}
export interface IComponentEntry<TType extends new (...args: any[]) => any = any> {
/** Default configuration data to pass to a newly created instance of this type */
config: object,
/** The name for this component; May be different than the underlying type name */
name: string;
/** A reference to the actual implementing type */
type: IComponent<TType>;
}
/** Common interface inherited by various components in the library */
export interface IImportLogger extends EventEmitter {
/**
* Write a log message
* @param message The message to record
* @param detailLevel The severity of the message
* @param logData Additional logging information
*/
log(message: string, detailLevel: LogDetailLevel, logData?: Map<string, any>): this;
}
/** Event type emitted by logger */
export interface LogMessageEventArgs {
detailLevel: LogDetailLevel;
extension: string;
message: string;
timestamp: number;
args?: Map<string, any>;
}
//#endregion
}
}
}