-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.d.ts
310 lines (310 loc) · 9.5 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
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
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
declare module "lib/blueprint/$require" {
export type DependenciesMap = {
[x: string]: string[];
};
export type ScriptMode = ('commonjs' | 'esm' | undefined);
/**
* @param {...string} importPath
*/
export function $require(...importPath: string[]): {
(_eval: any): string;
toString(): string;
is$require: boolean;
};
/**
*
* @param {{dependencies: {}, declarations: {}}} param0
* @param {'commonjs'|'esm'} mode
*/
export function composeImports({ dependencies, declarations }: {
dependencies: {};
declarations: {};
}, mode?: 'commonjs' | 'esm'): {
imports: any[];
declarations: any[];
};
/**
* replaces $require placeholders with actual calls and
* returns the body and a list of aliased dependencies found
* @param {string} body
* @returns {{body: string, dependencies: string[]}}
*/
export function parse$requires(body: string): {
body: string;
dependencies: string[];
};
/**
*
* @param {string} content
* @param {DependenciesMap} dependenciesMap
* @param {ScriptMode} mode
*/
export function parseImports(content: string, dependenciesMap: DependenciesMap, mode: ScriptMode): {
body: string;
imports: any[];
declarations: any[];
};
/**
*
* @param {Object.<string, string[]>} dependencyMap
* @param {string[]} presentDependencies
*/
export function mapDependenciesToVariables(dependencyMap: {
[x: string]: string[];
}, presentDependencies: string[]): {
dependencies: {};
declarations: {};
};
}
declare module "lib/Template" {
export class Template {
constructor(template?: string, options?: {});
_options: {};
_template: string;
_placeholders: {
[x: string]: Placeholder;
};
/**
* gets placeholders from a template
* @param {string} content
* @returns {Object<string, Placeholder>}
*/
_getPlaceholdersFromTemplate(content: string): {
[x: string]: Placeholder;
};
/**
* creates a new placeholder
* @param {string} name
* @param {Placeholder} sibling
* @param {'before'|'after'|'first'|'last'} order
*/
_create(name: string, sibling: Placeholder, order: 'before' | 'after' | 'first' | 'last'): boolean;
/**
* returns a populated and sanitized template
*/
_getOutput(): Promise<string>;
prepend(name: any): void;
append(name: any): void;
}
class Placeholder {
constructor(parent: any, name: any);
parent: any;
name: any;
inlineName: string;
parts: any[];
push(...parts: any[]): void;
unshift(...parts: any[]): void;
prepend(name: any): void;
append(name: any): void;
}
export {};
}
declare module "lib/Template.spec" {
export {};
}
declare module "lib/utils/index" {
/**
* @template {{}} T
* @template {{}} T2
* @param {T} target
* @param {...T2} sources
* @return {T&Partial<T2>} //jsdoc unaware of mutation - incorrectly wants partial T2
*/
export function deepAssign<T extends {}, T2 extends {}>(target: T, ...sources: T2[]): T & Partial<T2>;
export function isObject(v: any): boolean;
export function isObjectOrArray(v: any): boolean;
/**
* Like JSON.stringify, but unquotes all values
* @param {*} obj
*/
export function stringify(obj: any, level?: number): any;
export function emptyDirPartial(output: any, ignore: any): void;
export function verifyPathExists(path: any): void;
}
declare module "lib/filePatcher" {
/**
*
* @param {string} filepath
* @param {string[]} folders
* @param {string} output
* @param {Object.<string, any>} configs
* @param {*} imports
*/
export function patchFile(filepath: string, folders: string[], output: string, configs: {
[x: string]: any;
}, imports: any): Promise<boolean>;
}
declare module "lib/blueprint/$require.spec" {
export {};
}
declare module "lib/blueprint/configHelpers" {
export namespace blueprintHelpers {
/**
* returns a root config
* @param {string} name
*/
export function getConfig(name: string): {
__symlink: string;
};
/**
* returns a root config
* @param {string} name
*/
export function getConfig(name: string): {
__symlink: string;
};
/**
* returns a stringified root config
* unlike JSON.stringify, values are not stringified
* @param {string} name
*/
export function getConfigString(name: string): string;
/**
* returns a stringified root config
* unlike JSON.stringify, values are not stringified
* @param {string} name
*/
export function getConfigString(name: string): string;
export { $require };
export { stringify };
}
import { $require } from "lib/blueprint/$require";
import { stringify } from "lib/utils";
}
declare module "lib/utils/fileWalker" {
export function fileWalker(dirs: any, cb: any, ignore: any, root: any): Promise<void>;
}
declare module "lib/blueprint/hookHelpers" {
export type HookHelperContext = {
output: string;
configs: {
[x: string]: any;
};
imports: {
[x: string]: Import;
};
fragments: any;
blueprint: any;
};
export type Import = string[];
/**
* @typedef {object} HookHelperContext
* @prop {string} output
* @prop {Object.<string, any>} configs
* @prop {Object.<string, Import>} imports
* @prop {any} fragments
* @prop {any} blueprint
*/
/**
* @typedef {string[]} Import
*/
export class HookHelpers {
/** @param {HookHelperContext} ctx */
constructor(ctx: HookHelperContext);
output: string;
configs: {
[x: string]: any;
};
imports: {
[x: string]: Import;
};
fragments: any;
blueprint: any;
stringify: typeof stringify;
fileWalker: (callback: any) => Promise<void>;
/**
* transforms a file
* @param {string} filename
* @param {function} transformFn
*/
transform: (filename: string, transformFn: Function) => void;
/**
* creates a file
* @param {string} filename
* @param {string} content
*/
writeTo: (filename: string, content: string) => void;
/**
*
* @param {string} content
* @param {("commonjs"|"esm"|undefined)} mode
* @returns {{body: string, imports: string[], declarations: string[]}}
*/
parseImports: (content: string, mode: ("commonjs" | "esm" | undefined)) => {
body: string;
imports: string[];
declarations: string[];
};
removeFile: (filename: any) => void;
moveFile: (target: any, destination: any) => void;
}
import { stringify } from "lib/utils";
}
type Fragment = {
blueprint: object;
template: object;
path: string;
name: string;
};
type Blueprint = {
type: 'base' | 'feature' | 'template' | string;
imports?: {
[x: string]: Import;
} | undefined;
configs?: ConfigsCallBack | undefined;
hooks: BlueprintHooks;
};
type BlueprintHooks = {
beforeConfig: BlueprintHookCallback;
afterConfig: BlueprintHookCallback;
beforeCopy: BlueprintHookCallback;
afterCopy: BlueprintHookCallback;
beforePatch: BlueprintHookCallback;
afterPatch: BlueprintHookCallback;
};
type BlueprintHookCallback = (BlueprintHook: typeof import("lib/blueprint/hookHelpers")['HookHelpers']['prototype']) => any;
type Import = {
entry: string[];
};
type ConfigsCallBack = (helpers: typeof import("lib/blueprint/configHelpers")['blueprintHelpers']) => any;
declare module "lib/blueprint/fragmentMapper" {
/**
* Curried function: fragmentMapper(basepath)(path)
*
*
* @param {string} basepath
*/
export function fragmentMapper(basepath: string): (path: string) => Fragment[] | false;
}
declare module "lib/blueprint/populateConfig" {
/**
* walks through fragments to build a config
// * @param {{}[]} fragments
// * @param {Object.<string, {}>} configs
*/
export function populateConfigs(fragments: any, configs: any): any;
}
declare module "default.config" {
export const output: string;
export const include: any[];
export const basepath: any;
export const watch: boolean;
export const exec: any;
export const ignore: any[];
export const prettier: boolean;
export const hooks: {};
}
declare module "canvasit" {
/**
*
* @param {string[]|string} paths
* @param {string} output
* @param {any} options
*/
export function merge(paths: string[] | string, output: string, options?: any): Promise<{
configs: {};
fragments: any;
}>;
/** @type {Blueprint} */
export let Blueprint: Blueprint;
}