1 |
|
2 |
|
3 |
|
4 |
|
5 |
|
6 | declare module 'atma-io' {
|
7 | import { Io } from 'atma-io/IIo';
|
8 | const _default: Io;
|
9 | export = _default;
|
10 | }
|
11 |
|
12 | declare module 'atma-io/IIo' {
|
13 | import { class_Uri } from 'atma-utils';
|
14 | import { Watcher } from 'atma-io/Watcher';
|
15 | import { Directory } from 'atma-io/Directory';
|
16 | import { File } from 'atma-io/File';
|
17 | import { Glob } from 'atma-io/ExportsGlob';
|
18 | import { setSettings } from 'atma-io/ExportsSetts';
|
19 | export interface Io {
|
20 | env: {
|
21 | currentDir: class_Uri;
|
22 | applicationDir: class_Uri;
|
23 | appdataDir: class_Uri;
|
24 | tmpDir: class_Uri;
|
25 | newLine: string;
|
26 | settings: any;
|
27 | getTmpPath: (filename: string) => string;
|
28 | };
|
29 | watcher: typeof Watcher;
|
30 | glob: typeof Glob;
|
31 | settings: typeof setSettings;
|
32 | File: typeof File;
|
33 | Uri: typeof class_Uri;
|
34 | Directory: typeof Directory;
|
35 | }
|
36 | }
|
37 |
|
38 | declare module 'atma-io/Watcher' {
|
39 | export const Watcher: {
|
40 | watch: (path: string, callback: (path?: string) => any) => void;
|
41 | unwatch: (path: string, callback?: Function) => void;
|
42 | };
|
43 | }
|
44 |
|
45 | declare module 'atma-io/Directory' {
|
46 | import { class_Uri } from 'atma-utils';
|
47 | import { dir_symlink } from 'atma-io/transport/dir_transport';
|
48 | import { File } from 'atma-io/File';
|
49 | import { IDeferred } from 'atma-io/IDeferred';
|
50 | export class Directory {
|
51 | uri: class_Uri;
|
52 | files: File[];
|
53 | constructor(directory: string | Directory | class_Uri);
|
54 | exists(): boolean;
|
55 | static exists(path: string): boolean;
|
56 | existsAsync(): IDeferred<boolean>;
|
57 | static existsAsync(path: string): IDeferred<boolean>;
|
58 | ensure(): this;
|
59 | static ensure(path: string): Directory;
|
60 | ensureAsync(): IDeferred<Directory>;
|
61 | static ensureAsync(path: string): IDeferred<Directory>;
|
62 | readFiles(pattern?: string | RegExp | (string | RegExp)[], exclude?: string | RegExp | (string | RegExp)[]): File[];
|
63 | static readFiles(path: string, pattern?: string | RegExp | (string | RegExp)[], exclude?: string | RegExp | (string | RegExp)[]): File[];
|
64 | read(pattern?: string | RegExp | (string | RegExp)[], exclude?: string | RegExp | (string | RegExp)[]): (File | Directory)[];
|
65 | static read(path: string, pattern?: string | RegExp | (string | RegExp)[], exclude?: string | RegExp | (string | RegExp)[]): (File | Directory)[];
|
66 | readFilesAsync(pattern?: string | RegExp | (string | RegExp)[], exclude?: string | RegExp | (string | RegExp)[]): IDeferred<File[]>;
|
67 | static readFilesAsync(path: string, pattern?: string | RegExp | (string | RegExp)[], exclude?: string | RegExp | (string | RegExp)[]): IDeferred<File[]>;
|
68 | readAsync(pattern?: string | RegExp | (string | RegExp)[], exclude?: string | RegExp | (string | RegExp)[]): IDeferred<(File | Directory)[]>;
|
69 | static readAsync(path: string, pattern?: string | RegExp | (string | RegExp)[], exclude?: string | RegExp | (string | RegExp)[]): IDeferred<(File | Directory)[]>;
|
70 | copyTo(target: string, options?: {
|
71 | verbose?: boolean;
|
72 | }): IDeferred<void>;
|
73 | static copyTo(path: string, target: string, options?: {
|
74 | verbose?: boolean;
|
75 | }): IDeferred<void>;
|
76 | copyToAsync(target: string, options?: {
|
77 | verbose?: boolean;
|
78 | }): IDeferred<void>;
|
79 | static copyToAsync(path: string, target: string, options?: {
|
80 | verbose?: boolean;
|
81 | }): IDeferred<void>;
|
82 | getName(): string;
|
83 | rename(name: string): void;
|
84 | static rename(path: string, name: string): void;
|
85 | renameAsync(name: string): IDeferred<any>;
|
86 | static renameAsync(path: string, name: string): IDeferred<any>;
|
87 | remove(): void;
|
88 | static remove(path: string): void;
|
89 | removeAsync(): IDeferred<any>;
|
90 | static removeAsync(path: string): IDeferred<void>;
|
91 | watch(callback: (path?: string) => void | any): void;
|
92 | static watch(path: string, callback: (path?: string) => void | any): void;
|
93 | unwatch(callback?: (path: string) => void | any): void;
|
94 | static unwatch(path: string, callback?: (path?: string) => void | any): void;
|
95 | static symlink: typeof dir_symlink;
|
96 | }
|
97 | }
|
98 |
|
99 | declare module 'atma-io/File' {
|
100 | import { class_Uri } from 'atma-utils';
|
101 | import { IDeferred } from 'atma-io/IDeferred';
|
102 | import { Stats } from 'fs';
|
103 | import { FileFactory } from 'atma-io/FileFactory';
|
104 | import { FileHooks, IFileMiddleware } from 'atma-io/FileHooks';
|
105 | import { ITransport } from 'atma-io/transport/custom';
|
106 | export class File {
|
107 | uri: class_Uri;
|
108 | content: Buffer | string;
|
109 | sourceMap?: string;
|
110 | constructor(path: string | class_Uri, opts?: IFileSettings);
|
111 | read<T = string | Buffer>(mix?: IOperationOptions): T;
|
112 | static read<T = string | Buffer>(path: string, mix?: IOperationOptions): T;
|
113 | readAsync<T = string | Buffer>(mix?: IOperationOptions): IDeferred<T>;
|
114 | static readAsync<T = string | Buffer>(path: string, mix?: IOperationOptions): IDeferred<T>;
|
115 | write<T = string | Buffer | any>(content: T, mix?: IOperationOptions): this;
|
116 | static write<T = string | Buffer | any>(path: string, content: T, mix?: IOperationOptions): File;
|
117 | writeAsync<T = string | Buffer | any>(content: T, mix?: IOperationOptions): IDeferred<this>;
|
118 | static writeAsync<T = string | Buffer | any>(path: string, content: T, mix?: IOperationOptions): IDeferred<File>;
|
119 | copyTo(target: string, opts?: IFileCopyOpts): this;
|
120 | static copyTo(path: string, target: string, opts?: IFileCopyOpts): File;
|
121 | copyToAsync(target: string, opts?: IFileCopyOpts): IDeferred<this>;
|
122 | static copyToAsync(path: string, target: string, opts?: IFileCopyOpts): IDeferred<File>;
|
123 | exists(): boolean;
|
124 | static exists(path: string): boolean;
|
125 | existsAsync(): IDeferred<boolean>;
|
126 | static existsAsync(path: string): IDeferred<boolean>;
|
127 | rename(fileName: string): boolean;
|
128 | static rename(path: string, fileName: string): boolean;
|
129 | renameAsync(filename: any): IDeferred<boolean>;
|
130 | static renameAsync(path: string, fileName: string): IDeferred<boolean>;
|
131 | remove(): boolean;
|
132 | static remove(path: string): boolean;
|
133 | removeAsync(): IDeferred<boolean>;
|
134 | static removeAsync(path: string): IDeferred<boolean>;
|
135 | replace(a: string | RegExp, b: string | ((substring: string, ...args: any[]) => string), setts?: any): string;
|
136 | static replace(path: string, a: string | RegExp, b: string | ((substring: string, ...args: any[]) => string), setts?: any): string;
|
137 | replaceAsync(a: string | RegExp, b: string | ((substring: string, ...args: any[]) => string), setts?: any): IDeferred<string>;
|
138 | static replaceAsync(path: string, a: string | RegExp, b: string | ((substring: string, ...args: any[]) => string), setts?: any): IDeferred<string>;
|
139 | watch(callback: (path?: string) => void | any): void;
|
140 | static watch(path: string, callback: (path?: string) => void | any): void;
|
141 | unwatch(callback?: any): void;
|
142 | static unwatch(path: string, callback?: any): void;
|
143 | stats(): Stats;
|
144 | static stats(path: string): Stats;
|
145 | static clearCache(mix?: any): void;
|
146 | static disableCache(): void;
|
147 | static enableCache(): void;
|
148 | static registerFactory(factory: FileFactory): void;
|
149 | static getFactory(): FileFactory;
|
150 | static registerHookHandler(hook: FileHooks): void;
|
151 | static getHookHandler(): FileHooks;
|
152 | static registerTransport(protocol: string, transport: ITransport): void;
|
153 | static getTransports(): {
|
154 | [protocol: string]: ITransport;
|
155 | };
|
156 | static setTransports(repository: any): void;
|
157 | static get Factory(): FileFactory;
|
158 | static get Middleware(): FileHooks;
|
159 | static processHooks(method: any, file: any, config: any, onComplete: any): void;
|
160 | static middleware: {
|
161 | [name: string]: IFileMiddleware;
|
162 | };
|
163 | static registerExtensions(extensions: any, shouldCleanPrevious?: boolean, settings?: any): void;
|
164 | static setMiddlewares(extensions: any, settings?: any): void;
|
165 | }
|
166 | export interface IFileSettings {
|
167 | cached?: boolean;
|
168 | factory?: FileFactory;
|
169 | }
|
170 | export interface IFileCopyOpts {
|
171 | silent?: boolean;
|
172 | baseSource?: string;
|
173 | }
|
174 | export interface IOperationOptions {
|
175 | skipHooks?: boolean;
|
176 |
|
177 | encoding?: 'buffer' | 'utf8' | string;
|
178 | hooks?: FileHooks;
|
179 | [other: string]: any;
|
180 | }
|
181 | }
|
182 |
|
183 | declare module 'atma-io/ExportsGlob' {
|
184 | import { glob_matchPath } from 'atma-io/util/glob';
|
185 | import { Directory } from 'atma-io/Directory';
|
186 | import { File } from 'atma-io/File';
|
187 | import { IDeferred } from 'atma-io/IDeferred';
|
188 | export const Glob: {
|
189 | matchPath: typeof glob_matchPath;
|
190 | readFiles(path: string): File[];
|
191 | read(path: string): (File | Directory)[];
|
192 | readAsync: (path: string, cb?: (error: any, arr?: (File | Directory)[], dir?: Directory) => any) => IDeferred<(File | Directory)[]>;
|
193 | };
|
194 | }
|
195 |
|
196 | declare module 'atma-io/ExportsSetts' {
|
197 | export function setSettings(settings: {
|
198 | extensions?: any;
|
199 | }): void;
|
200 | }
|
201 |
|
202 | declare module 'atma-io/transport/dir_transport' {
|
203 | export function dir_ensure(path: any): string;
|
204 | export function dir_ensureAsync(path: any, cb: any): void;
|
205 | export function dir_exists(path: any): boolean;
|
206 | export function dir_existsAsync(path: any, cb: any): void;
|
207 | export function dir_files(path: any, patterns: any, excludes: any, data?: any): string[];
|
208 | export function dir_filesAsync(path: any, patternsOrCb?: any, excludesOrCb?: any, dataOrCb?: any, Cb?: any): any;
|
209 | export function dir_symlink(source: string, target: string): void;
|
210 | export function dir_remove(path: any): boolean;
|
211 | export function dir_removeAsync(path: any, cb: any): any;
|
212 | export function dir_rename(oldPath: string, newPath: string): any;
|
213 | export function dir_renameAsync(oldPath: string, newPath: string, cb: any): any;
|
214 | }
|
215 |
|
216 | declare module 'atma-io/IDeferred' {
|
217 | export interface IDeferred<T> extends PromiseLike<T> {
|
218 | done(done: (...args: any[]) => void | IDeferred<any>): this;
|
219 | fail(fail: (error: any | Error) => void): this;
|
220 | reject(error: any | Error): this;
|
221 | resolve(...args: any[]): this;
|
222 | always(always: Function): this;
|
223 | defer(): this;
|
224 | isResolved(): boolean;
|
225 | isRejected(): boolean;
|
226 | isBusy(): boolean;
|
227 | resolveDelegate(): (result: any) => void | any;
|
228 | rejectDelegate(): (result: Error | any) => void | any;
|
229 | }
|
230 | }
|
231 |
|
232 | declare module 'atma-io/FileFactory' {
|
233 | export class FileFactory {
|
234 | handlers: any[];
|
235 | registerHandler(regexp: RegExp, handler: any): void;
|
236 | unregisterHandler(regexp: any, handler: any): void;
|
237 | resolveHandler(uri: any): any;
|
238 | }
|
239 | }
|
240 |
|
241 | declare module 'atma-io/FileHooks' {
|
242 | import { File } from 'atma-io/File';
|
243 | export interface IFileMiddleware {
|
244 | name?: string;
|
245 | setOptions?(opts: any): void;
|
246 | setIo?(io: any): void;
|
247 | register?(io: any): void;
|
248 | read?(file: File, config: any): any;
|
249 | readAsync?(file: File, config: any, done: Function): any;
|
250 | write?(file: File, config: any): any;
|
251 | writeAsync?(file: File, config: any, done: Function): any;
|
252 | }
|
253 | export interface IHookFunction {
|
254 | (file: File, config?: any): void | any;
|
255 | }
|
256 | export class HookRunner {
|
257 | regexp: RegExp;
|
258 | method: 'read' | 'write';
|
259 | handler: IFileMiddleware | IHookFunction;
|
260 | zIndex: number;
|
261 | constructor(regexp: RegExp, method: 'read' | 'write', handler: IFileMiddleware | IHookFunction, zIndex: number);
|
262 | run(method: 'read' | 'write', file: File, config?: any): void;
|
263 | runAsync(method: any, file: any, config: any, done: any): void;
|
264 | canHandle(path: string, method: 'read' | 'write'): boolean;
|
265 | }
|
266 | export class FileHooks {
|
267 | hooks: HookRunner[];
|
268 | register(mix: RegExp | {
|
269 | regexp: RegExp;
|
270 | method: 'read' | 'write';
|
271 | handler: string | IFileMiddleware | IHookFunction;
|
272 | zIndex?: number;
|
273 | }, method: 'read' | 'write', handler: string | IFileMiddleware | IHookFunction, zIndex?: number): this;
|
274 | contains(method: 'read' | 'write', handler: IFileMiddleware | IHookFunction, regexp: RegExp): boolean;
|
275 | unregister(method: 'read' | 'write', handler: IFileMiddleware | string | IHookFunction): void;
|
276 | unregisterByRegexp(regexp: RegExp): void;
|
277 | trigger(method: 'read' | 'write', file: File, config?: any): void;
|
278 | triggerAsync(method: 'read' | 'write', file: File, config: any, cb: Function): void;
|
279 | clear(): this;
|
280 | getHooksForPath(path: string, method: 'read' | 'write'): HookRunner[];
|
281 | }
|
282 | }
|
283 |
|
284 | declare module 'atma-io/transport/custom' {
|
285 | export interface IFileTransport {
|
286 | save(path: string, content: any, options?: any): void;
|
287 | saveAsync(path: any, content: any, options: any, cb: any): void;
|
288 | copy(from: any, to: any): any;
|
289 | copyAsync(from: any, to: any, cb: (err: Error) => void): any;
|
290 | exists(path: any): boolean;
|
291 | existsAsync(path: any, cb: (err: Error, x: boolean) => void): any;
|
292 | read(path: any, encoding?: any): string | Buffer;
|
293 | readAsync(path: any, encoding: any, cb: (err: Error, x: string | Buffer) => void): any;
|
294 | remove(path: any): boolean;
|
295 | removeAsync(path: any, cb: (err: Error) => void): any;
|
296 | rename(path: any, filename: any): any;
|
297 | renameAsync(path: any, filename: any, cb: any): any;
|
298 | }
|
299 | export interface IDirectoryTransport {
|
300 | ensure(path: any): string;
|
301 | ensureAsync(path: any, cb: any): void;
|
302 | ceateSymlink(source: string, target: string): any;
|
303 | exists(path: any): boolean;
|
304 | existsAsync(path: any, cb: (err: Error, x: boolean) => void): any;
|
305 | readFiles(path: any, patterns?: any, excludes?: any, data?: any): string[];
|
306 | readFilesAsync(path: any, patternsOrCb?: any, excludesOrCb?: any, dataOrCb?: any, Cb?: any): any;
|
307 | remove(path: any): boolean;
|
308 | removeAsync(path: any, cb: (err: Error) => void): any;
|
309 | rename(oldPath: any, newPath: any): any;
|
310 | renameAsync(oldPath: any, newPath: any, cb: (err: Error) => void): any;
|
311 | }
|
312 | export interface ITransport {
|
313 | File: IFileTransport;
|
314 | Directory: IDirectoryTransport;
|
315 | }
|
316 | export const Repository: {
|
317 | [protocol: string]: ITransport;
|
318 | };
|
319 | export class CustomTransport {
|
320 | static register(protocol: string, transport: ITransport): void;
|
321 | static get(protocol: string): ITransport;
|
322 | static all(): {
|
323 | [protocol: string]: ITransport;
|
324 | };
|
325 | static set(repository: any): void;
|
326 | }
|
327 | }
|
328 |
|
329 | declare module 'atma-io/util/glob' {
|
330 | export function glob_getCalculatedPath(path: any, glob: any): any;
|
331 | export function glob_matchPath(pattern: any, path: any): boolean;
|
332 | export function glob_parsePatterns(mix: string | RegExp | (string | RegExp)[], out?: GlobRegExp[]): GlobRegExp[];
|
333 | export function glob_parseDirs(pattern: any): [number, number, string];
|
334 | export function glob_toRegExp(glob: any): GlobRegExp;
|
335 | |
336 |
|
337 |
|
338 | export function glob_getStrictPath(path: any): any;
|
339 | |
340 |
|
341 |
|
342 | export function glob_getRelativePath(path: any): any;
|
343 | export class GlobRegExp extends RegExp {
|
344 | depth: number;
|
345 | rootCount: number;
|
346 | root: string;
|
347 | }
|
348 | }
|
349 |
|