-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtypes.d.ts
More file actions
160 lines (132 loc) · 3.5 KB
/
Copy pathtypes.d.ts
File metadata and controls
160 lines (132 loc) · 3.5 KB
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
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
import Sitcom from './src/core/Sitcom';
import {MarkedOptions, TokensList} from 'marked';
import Bundle from './src/core/Bundle';
declare function sitcom(silent: boolean = false): sitcom.Sitcom;
namespace sitcom {
import {MarkedOptions, TokensList} from 'marked';
interface Plugin {
name?: string;
setOptions?(options: MarkedOptions): void;
tokenize?(tokens: TokensList): TokensList;
transform?(tokens: TokensList): string;
[key: string]: any;
}
type Heading = {
title: string;
level: number;
id?: string;
[key: string]: any;
}
type WrapData = {
headings: Heading[];
result: string;
times?: number;
maxTimes?: number;
[key: string]: any;
};
interface WrapFunction {
(data: WrapData): any;
}
type InputMapping = Record<string, string[]>;
interface InputOptions {
input?: string | string[];
root?: string;
declare?: string;
plugins?: Plugin[];
mapping?: InputMapping;
layouts?: string | Record<string, string>;
}
interface OutputOptions {
intro?: string | WrapFunction;
outro?: string | WrapFunction;
file?: string;
dist?: string;
data?: Record<string, any>;
// runtime properties
layout?: string;
}
type StdoutLogType = 'tip' | 'err' | 'warn' | 'ok' | 'log';
interface StdoutLogHandle {
/**
* 是否换行结束
* @returns {boolean}
*/
(): boolean;
/**
* 直接换行
* @param {boolean} newline
*/
(newline: boolean): void;
/**
* log类型日志、不换行
* @param {string} message
*/
(message: string): void;
/**
* 指定类型日志、不换行
* @param {string} message
* @param {string} type
*/
(message: string, type: StdoutLogType): void;
/**
* log类型日志、换行
* @param {string} message
* @param {boolean} newline
*/
(message: string, newline: boolean): void;
/**
* 指定类型日志、换行
* @param {string} message
* @param {string} [type]
* @param {boolean} [newline]
*/
(message: string, type: StdoutLogType, newline: boolean): void;
}
interface SitcomOptions extends InputOptions {
marked?: MarkedOptions;
output?: OutputOptions;
stdout?: StdoutLogHandle;
silent?: boolean;
}
type DependencyData = {
from: string;
to?: string;
hash?: string;
regex?: RegExp;
via?: string;
isMaster?: boolean;
isMarked?: boolean;
};
class Dependency {
readonly size: number;
master?: Dependency;
set(key: string, data: DependencyData): this;
add(origin:string, data?: string | DependencyData): this;
forEach(fn: (value: DependencyData, hash: string, dep: DependencyData) => void, thisArg: any = this): void;
map<T = any>(fn: (value: DependencyData, hash: string, dep: DependencyData) => T, thisArg: any = this): T[];
}
type GeneratedData = {
html: string;
headings: Heading[];
dependency: Dependency;
};
class Bundle {
dependency: Dependency;
outfile?: string;
sitcom: Sitcom;
inputOptions: InputOptions;
outputOptions: OutputOptions;
markedOptions: MarkedOptions;
generate(outputOptions?: OutputOptions): Promise<GeneratedData>;
write(outputOptions?: OutputOptions): Promise<void>;
}
class Sitcom {
dependency: Dependency;
stdout: StdoutLogHandle;
options: SitcomOptions;
silent: boolean;
constructor(silent?: boolean);
make(options: SitcomOptions): Promise<Bundle>;
}
}
export = sitcom;