-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.d.ts
100 lines (88 loc) · 2.6 KB
/
index.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
declare module 'immersive' {
const { Context } = require('node:vm');
interface ImmersiveEnvironment extends Record<string, any> {}
interface ImmersiveEnvironmentConfig extends ImmersiveEnvironment {
name: string;
}
type Helper = (envConfig: ImmersiveEnvironmentConfig) => any;
interface PromptConfiguration {
user?: string;
symbol?: string;
colors?: {
prompt?: string;
};
}
export interface ImmersiveCommand {
command: string;
description: string;
action: Function;
}
interface ImmersiveConfiguration {
projectName: string;
displayName?: string;
commands?: Record<string, ImmersiveCommand>;
commandsDirectory?: string;
helpers: Record<string, Helper>;
environments: Record<string, ImmersiveEnvironment>;
defaultEnvironment?: string;
defaultConfig?: PromptConfiguration;
disableBanner?: boolean;
}
interface Arguments {
/** Non-option arguments */
_: string[];
/** The script name or node command */
$0: string;
/** All remaining options */
[argName: string]: any;
}
type ImmersiveLevelLoger = (...args: string[]) => void;
interface ImmersiveLogger {
error: ImmersiveLevelLoger;
warn: ImmersiveLevelLoger;
info: ImmersiveLevelLoger;
debug: ImmersiveLevelLoger;
log: ImmersiveLevelLoger;
table: ImmersiveLevelLoger;
}
interface ImmersiveHistory {
addEntry: (command: string) => void;
getPreviousEntry: () => string;
getNextEntry: () => string;
clearHistory: () => void;
}
type ImmersiveActionInput<
Helpers,
EnvironmentNames = string,
EnvironmentConfig = ImmersiveEnvironment
> = Helpers & {
args: Arguments;
commands: Record<string, ImmersiveAction<Helpers, EnvironmentNames>>;
logger: ImmersiveLogger;
command: string;
history: ImmersiveHistory;
runCommand: (command: string, internal: boolean) => Promise<any | void>;
immersiveConfig: ImmersiveConfiguration;
config: PromptConfiguration;
env: EnvironmentNames;
envConfig: EnvironmentConfig;
};
type ImmersiveAction<
Helpers,
EnvironmentNames = string,
EnvironmentConfig = ImmersiveEnvironment,
ReturnType = any
> = (
actionInput: ImmersiveActionInput<
Helpers,
EnvironmentNames,
EnvironmentConfig
>,
) => ReturnType;
export function immersive(configuration: ImmersiveConfiguration): void;
export function repl(context: Context, customEval: any): Promise<void>;
export function mergeExport<
T extends Record<string, any> | Function,
U extends Record<string, any>
>(mainExport: T): (exports: U) => T & U;
}