@makano/rew 1.2.4 → 1.2.6
Sign up to get free protection for your applications and to get access to all the features.
- package/lib/civet/main.js +17239 -0
- package/lib/rew/cli/cli.js +57 -5
- package/lib/rew/cli/log.js +5 -1
- package/lib/rew/cli/run.js +2 -2
- package/lib/rew/cli/utils.js +147 -60
- package/lib/rew/const/default.js +5 -1
- package/lib/rew/const/ext.js +5 -0
- package/lib/rew/const/opt.js +7 -2
- package/lib/rew/const/usage.js +15 -0
- package/lib/rew/functions/exec.js +2 -2
- package/lib/rew/functions/export.js +1 -1
- package/lib/rew/functions/fs.js +6 -1
- package/lib/rew/functions/id.js +2 -2
- package/lib/rew/functions/import.js +34 -13
- package/lib/rew/functions/require.js +17 -1
- package/lib/rew/functions/stdout.js +4 -0
- package/lib/rew/main.js +1 -13
- package/lib/rew/modules/compiler.js +122 -26
- package/lib/rew/modules/context.js +13 -1
- package/lib/rew/modules/runtime.js +37 -20
- package/lib/rew/pkgs/conf.js +1 -1
- package/lib/rew/pkgs/rune.js +8 -1
- package/lib/rew/pkgs/serve.js +373 -0
- package/lib/rew/pkgs/stream.js +10 -0
- package/lib/rew/pkgs/web.js +504 -0
- package/package.json +10 -5
- package/runtime.d.ts +943 -0
- package/lib/coffeescript/browser.js +0 -156
- package/lib/coffeescript/cake.js +0 -134
- package/lib/coffeescript/coffeescript.js +0 -465
- package/lib/coffeescript/command.js +0 -832
- package/lib/coffeescript/grammar.js +0 -1930
- package/lib/coffeescript/helpers.js +0 -513
- package/lib/coffeescript/index.js +0 -230
- package/lib/coffeescript/lexer.js +0 -2316
- package/lib/coffeescript/nodes.js +0 -9784
- package/lib/coffeescript/optparse.js +0 -258
- package/lib/coffeescript/parser.js +0 -20384
- package/lib/coffeescript/register.js +0 -120
- package/lib/coffeescript/repl.js +0 -328
- package/lib/coffeescript/rewriter.js +0 -1448
- package/lib/coffeescript/scope.js +0 -191
- package/lib/coffeescript/sourcemap.js +0 -244
package/runtime.d.ts
ADDED
@@ -0,0 +1,943 @@
|
|
1
|
+
|
2
|
+
|
3
|
+
interface ImportOptions {
|
4
|
+
/**
|
5
|
+
* Determines how to import the given module
|
6
|
+
*/
|
7
|
+
type: "js" | "coffee" | "yaml" | "json" | "qrew" | "text";
|
8
|
+
[key: string]: any;
|
9
|
+
}
|
10
|
+
|
11
|
+
interface ModuleConfOptionCenter {
|
12
|
+
/**
|
13
|
+
* Get a config key
|
14
|
+
* @param key The key of the config to get
|
15
|
+
* @param defaultValue The default value ig null
|
16
|
+
* @returns The value of the key or the defaultValue if it's null.
|
17
|
+
*/
|
18
|
+
get: <T = any>(key: string, defaultValue?: T) => T;
|
19
|
+
/**
|
20
|
+
* Set a config key
|
21
|
+
* @param key The key of the config to set
|
22
|
+
* @param value The value to set it to
|
23
|
+
* @returns true if it was a success
|
24
|
+
*/
|
25
|
+
set: <T = any>(key: string, value: T) => boolean;
|
26
|
+
/**
|
27
|
+
* Removes a key from the config
|
28
|
+
* @param key The key of the config to remove
|
29
|
+
* @returns true if it was a success
|
30
|
+
*/
|
31
|
+
remove: (key: string) => boolean;
|
32
|
+
/**
|
33
|
+
* Resets the entire config option center to it's default value
|
34
|
+
*/
|
35
|
+
reset: () => boolean;
|
36
|
+
/**
|
37
|
+
* Get all values in an option center
|
38
|
+
* @param str
|
39
|
+
* @returns
|
40
|
+
*/
|
41
|
+
getAll: (() => string) | ((str?: false) => Record<string, any>);
|
42
|
+
}
|
43
|
+
|
44
|
+
interface ModuleConf extends ModuleConfOptionCenter {
|
45
|
+
/**
|
46
|
+
* A separate options file for a related set of options
|
47
|
+
* @param name The option center full path
|
48
|
+
* @param defaults The default values
|
49
|
+
*
|
50
|
+
* @example
|
51
|
+
* conf = imp 'conf'
|
52
|
+
*
|
53
|
+
* animations = conf.optionCenter 'animations', enable: false, speed: '1x'
|
54
|
+
*
|
55
|
+
* if animations.get 'enable'
|
56
|
+
* animate animations.get 'speed'
|
57
|
+
*/
|
58
|
+
optionCenter: (name: string, defaults?: any) => ModuleConfOptionCenter;
|
59
|
+
/**
|
60
|
+
* Manage Static files
|
61
|
+
*/
|
62
|
+
staticFile: (
|
63
|
+
name: string,
|
64
|
+
defaults?: any
|
65
|
+
) => {
|
66
|
+
write: (value: any, ifExists?: boolean) => any;
|
67
|
+
// @ts-ignore
|
68
|
+
read: (to?: string | object) => string | object | Buffer;
|
69
|
+
fileRoot: string;
|
70
|
+
exists: boolean;
|
71
|
+
};
|
72
|
+
}
|
73
|
+
|
74
|
+
interface ModuleEnv {
|
75
|
+
has: (key: string) => boolean;
|
76
|
+
get: (key: string) => string;
|
77
|
+
set: (key: string, value: string) => boolean;
|
78
|
+
rm: (key: string) => boolean;
|
79
|
+
is: (key: string, value: string) => boolean;
|
80
|
+
}
|
81
|
+
|
82
|
+
interface ModuleRuneDBCollcetion {
|
83
|
+
insert(record: object): any;
|
84
|
+
read(id: string | object, evaluate?: boolean): any;
|
85
|
+
update(caseRecord: string | object, newRecord: object): any;
|
86
|
+
remove(id: string | object): boolean;
|
87
|
+
find(criteria: string | object): any;
|
88
|
+
map(cb: (data: any[]) => any[], mutate?: boolean): any[];
|
89
|
+
transform(cb: (data: any[]) => any[], mutate?: boolean): any[];
|
90
|
+
filter(cb: (data: any[]) => boolean, mutate?: boolean): any[];
|
91
|
+
sort(cb: (a: any, b: any) => number, mutate?: boolean): any[];
|
92
|
+
list(): any[];
|
93
|
+
}
|
94
|
+
|
95
|
+
interface ModuleRuneDBMap {
|
96
|
+
set(key: string, value: any): void;
|
97
|
+
get(key: string): any | null;
|
98
|
+
remove(key: string): boolean;
|
99
|
+
transform(cb: (data: any) => any, mutate?: boolean): any;
|
100
|
+
list(): { [key: string]: any };
|
101
|
+
}
|
102
|
+
|
103
|
+
interface ModuleRuneDB {
|
104
|
+
collection: (name: string) => ModuleRuneDBCollcetion;
|
105
|
+
map: (name: string) => ModuleRuneDBMap;
|
106
|
+
findRef: (ref: string) => any;
|
107
|
+
setData: (data: Record<string, any>) => void;
|
108
|
+
getData: () => Record<string, any>;
|
109
|
+
makeRef(value: object, props?: string): string | null;
|
110
|
+
}
|
111
|
+
|
112
|
+
interface ModuleRune {
|
113
|
+
db(dbname: string, data?: object, encryptionKey?: string): ModuleRuneDB;
|
114
|
+
genKey(secret: string): string;
|
115
|
+
push(...values: any[]): any;
|
116
|
+
pop(...values: any[]): any;
|
117
|
+
}
|
118
|
+
|
119
|
+
interface ModuleThreads {
|
120
|
+
thread: (cb: Function) => {
|
121
|
+
stopAll: () => void;
|
122
|
+
start: (context: Record<string, any>) => {
|
123
|
+
on: (event: string, callback: (data) => void) => void;
|
124
|
+
off: (event: string, callback: (data) => void) => void;
|
125
|
+
emit: (event: string, data: any) => void;
|
126
|
+
get: () => Promise<any>;
|
127
|
+
stop: () => void;
|
128
|
+
};
|
129
|
+
};
|
130
|
+
}
|
131
|
+
|
132
|
+
|
133
|
+
type _Request = typeof globalThis extends { onmessage: any } ? {} : import("undici-types").Request;
|
134
|
+
type _Response = typeof globalThis extends { onmessage: any } ? {} : import("undici-types").Response;
|
135
|
+
type _FormData = typeof globalThis extends { onmessage: any } ? {} : import("undici-types").FormData;
|
136
|
+
type _Headers = typeof globalThis extends { onmessage: any } ? {} : import("undici-types").Headers;
|
137
|
+
type _RequestInit = typeof globalThis extends { onmessage: any } ? {}
|
138
|
+
: import("undici-types").RequestInit;
|
139
|
+
type _ResponseInit = typeof globalThis extends { onmessage: any } ? {}
|
140
|
+
: import("undici-types").ResponseInit;
|
141
|
+
// @ts-ignore
|
142
|
+
type _File = typeof globalThis extends { onmessage: any } ? {} : import("node:buffer").File;
|
143
|
+
|
144
|
+
interface Request {}
|
145
|
+
declare var Request: typeof globalThis extends {
|
146
|
+
onmessage: any;
|
147
|
+
Request: infer T;
|
148
|
+
} ? T
|
149
|
+
: typeof import("undici-types").Request;
|
150
|
+
|
151
|
+
interface ResponseInit extends _ResponseInit {}
|
152
|
+
|
153
|
+
interface Response extends _Response {}
|
154
|
+
declare var Response: typeof globalThis extends {
|
155
|
+
onmessage: any;
|
156
|
+
Response: infer T;
|
157
|
+
} ? T
|
158
|
+
: typeof import("undici-types").Response;
|
159
|
+
|
160
|
+
type GenericTraps = Record<string, any>;
|
161
|
+
|
162
|
+
type IRequestStrict = {
|
163
|
+
route: string;
|
164
|
+
params: {
|
165
|
+
[key: string]: string;
|
166
|
+
};
|
167
|
+
query: {
|
168
|
+
[key: string]: string | string[] | undefined;
|
169
|
+
};
|
170
|
+
proxy?: any;
|
171
|
+
} & Request;
|
172
|
+
|
173
|
+
type IRequest = IRequestStrict & GenericTraps;
|
174
|
+
|
175
|
+
type RequestHandler<RequestType = IRequest, Args extends Array<any> = any[]> = (
|
176
|
+
request: RequestType,
|
177
|
+
...args: Args
|
178
|
+
) => any;
|
179
|
+
|
180
|
+
type ResponseHandler<
|
181
|
+
ResponseType = any,
|
182
|
+
RequestType = IRequest,
|
183
|
+
Args extends any[] = any[]
|
184
|
+
> = (response: ResponseType, request: RequestType, ...args: Args) => any;
|
185
|
+
|
186
|
+
type StatusErrorObject = {
|
187
|
+
error?: string;
|
188
|
+
[key: string]: any;
|
189
|
+
};
|
190
|
+
|
191
|
+
interface StatusError extends Error {
|
192
|
+
status: number;
|
193
|
+
[key: string]: any;
|
194
|
+
constructor(status?: number, body?: StatusErrorObject | string);
|
195
|
+
}
|
196
|
+
|
197
|
+
type ErrorHandler<
|
198
|
+
ErrorType extends Error = StatusError,
|
199
|
+
RequestType = IRequest,
|
200
|
+
Args extends any[] = any[]
|
201
|
+
> = (error: ErrorType, request: RequestType, ...args: Args) => any;
|
202
|
+
|
203
|
+
type RouteEntry<RequestType = IRequest, Args extends any[] = any[]> = [
|
204
|
+
httpMethod: string,
|
205
|
+
match: RegExp,
|
206
|
+
handlers: RequestHandler<RequestType, Args>[],
|
207
|
+
path?: string
|
208
|
+
];
|
209
|
+
|
210
|
+
type IttyRouterOptions = {
|
211
|
+
base?: string;
|
212
|
+
routes?: RouteEntry[];
|
213
|
+
} & GenericTraps;
|
214
|
+
|
215
|
+
type RouterOptions<RequestType = IRequest, Args extends any[] = []> = {
|
216
|
+
before?: RequestHandler<RequestType, Args>[];
|
217
|
+
catch?: ErrorHandler<StatusError, RequestType, Args>;
|
218
|
+
finally?: ResponseHandler<any, RequestType, Args>[];
|
219
|
+
} & IttyRouterOptions;
|
220
|
+
|
221
|
+
type AutoRouterOptions<RequestType, Args extends any[]> = {
|
222
|
+
missing?: RequestHandler<RequestType, Args>;
|
223
|
+
format?: ResponseHandler;
|
224
|
+
} & RouterOptions<RequestType, Args>;
|
225
|
+
|
226
|
+
type RequestLike = {
|
227
|
+
method: string;
|
228
|
+
url: string;
|
229
|
+
} & GenericTraps;
|
230
|
+
|
231
|
+
type Route<R = IRequest, A extends Array<any> = any[]> = <
|
232
|
+
RequestType = R,
|
233
|
+
Args extends Array<any> = A
|
234
|
+
>(
|
235
|
+
path: string,
|
236
|
+
...handlers: RequestHandler<RequestType, Args>[]
|
237
|
+
) => IttyRouterType<R, A>;
|
238
|
+
|
239
|
+
type CustomRoutes<R = Route> = {
|
240
|
+
[key: string]: R;
|
241
|
+
};
|
242
|
+
|
243
|
+
type IttyRouterType<
|
244
|
+
RequestType = IRequest,
|
245
|
+
Args extends any[] = any[],
|
246
|
+
ResponseType = any
|
247
|
+
> = {
|
248
|
+
__proto__: IttyRouterType<RequestType, Args, ResponseType>;
|
249
|
+
routes: RouteEntry[];
|
250
|
+
fetch: <A extends any[] = Args>(
|
251
|
+
request: RequestLike,
|
252
|
+
...extra: A
|
253
|
+
) => Promise<ResponseType>;
|
254
|
+
all: Route<RequestType, Args>;
|
255
|
+
delete: Route<RequestType, Args>;
|
256
|
+
get: Route<RequestType, Args>;
|
257
|
+
head: Route<RequestType, Args>;
|
258
|
+
options: Route<RequestType, Args>;
|
259
|
+
patch: Route<RequestType, Args>;
|
260
|
+
post: Route<RequestType, Args>;
|
261
|
+
put: Route<RequestType, Args>;
|
262
|
+
} & CustomRoutes<Route<RequestType, Args>> &
|
263
|
+
GenericTraps;
|
264
|
+
|
265
|
+
type RouterType<
|
266
|
+
RequestType = IRequest,
|
267
|
+
Args extends any[] = any[],
|
268
|
+
ResponseType = any
|
269
|
+
> = {
|
270
|
+
before?: RequestHandler<RequestType, Args>[];
|
271
|
+
catch?: ErrorHandler<StatusError, RequestType, Args>;
|
272
|
+
finally?: ResponseHandler<any, RequestType, Args>[];
|
273
|
+
} & IttyRouterType<RequestType, Args, ResponseType>;
|
274
|
+
|
275
|
+
type AutoRouterType<
|
276
|
+
RequestType = IRequest,
|
277
|
+
Args extends any[] = any[],
|
278
|
+
ResponseType = any
|
279
|
+
> = {
|
280
|
+
missing?: RequestHandler<RequestType, Args>;
|
281
|
+
format?: ResponseHandler;
|
282
|
+
} & RouterType<RequestType, Args, ResponseType>;
|
283
|
+
|
284
|
+
type HasContent<ContentType> = {
|
285
|
+
content: ContentType;
|
286
|
+
} & IRequestStrict;
|
287
|
+
|
288
|
+
type ResponseFormatter = (body?: any, options?: ResponseInit) => Response;
|
289
|
+
|
290
|
+
interface ErrorLike extends Error {
|
291
|
+
status?: number;
|
292
|
+
[any: string]: any;
|
293
|
+
}
|
294
|
+
type ErrorBody = string | object;
|
295
|
+
interface ErrorFormatter {
|
296
|
+
(statusCode?: number, body?: ErrorBody): Response;
|
297
|
+
}
|
298
|
+
|
299
|
+
type IttyRouter = <
|
300
|
+
RequestType extends IRequest = IRequest,
|
301
|
+
Args extends any[] = any[],
|
302
|
+
ResponseType = any
|
303
|
+
>({
|
304
|
+
base,
|
305
|
+
routes,
|
306
|
+
...other
|
307
|
+
}?: IttyRouterOptions) => IttyRouterType<RequestType, Args, ResponseType>;
|
308
|
+
|
309
|
+
type Router = <
|
310
|
+
RequestType = IRequest,
|
311
|
+
Args extends any[] = any[],
|
312
|
+
ResponseType = any
|
313
|
+
>({
|
314
|
+
base,
|
315
|
+
routes,
|
316
|
+
...other
|
317
|
+
}?: RouterOptions<RequestType, Args>) => RouterType<
|
318
|
+
RequestType,
|
319
|
+
Args,
|
320
|
+
ResponseType
|
321
|
+
>;
|
322
|
+
|
323
|
+
type AutoRouter = <
|
324
|
+
RequestType extends IRequest = IRequest,
|
325
|
+
Args extends any[] = any[],
|
326
|
+
ResponseType = any
|
327
|
+
>({
|
328
|
+
format,
|
329
|
+
missing,
|
330
|
+
finally: f,
|
331
|
+
before,
|
332
|
+
...options
|
333
|
+
}?: AutoRouterOptions<RequestType, Args>) => AutoRouterType<
|
334
|
+
RequestType,
|
335
|
+
Args,
|
336
|
+
ResponseType
|
337
|
+
>;
|
338
|
+
|
339
|
+
type createResponse = (
|
340
|
+
format?: string,
|
341
|
+
transform?: ((body: any) => any) | undefined
|
342
|
+
) => ResponseFormatter;
|
343
|
+
|
344
|
+
type statusR = (status: number, options?: ResponseInit) => Response;
|
345
|
+
|
346
|
+
type withContent = (request: IRequest) => Promise<void>;
|
347
|
+
|
348
|
+
type withCookies = (r: IRequest) => void;
|
349
|
+
|
350
|
+
type withParams = (request: IRequest) => void;
|
351
|
+
|
352
|
+
type CorsOptions = {
|
353
|
+
credentials?: true;
|
354
|
+
origin?:
|
355
|
+
| boolean
|
356
|
+
| string
|
357
|
+
| string[]
|
358
|
+
| RegExp
|
359
|
+
| ((origin: string) => string | void);
|
360
|
+
maxAge?: number;
|
361
|
+
allowMethods?: string | string[];
|
362
|
+
allowHeaders?: any;
|
363
|
+
exposeHeaders?: string | string[];
|
364
|
+
};
|
365
|
+
type Preflight = (request: IRequest) => Response | void;
|
366
|
+
type Corsify = (response: Response, request?: IRequest) => Response;
|
367
|
+
type CorsPair = {
|
368
|
+
preflight: Preflight;
|
369
|
+
corsify: Corsify;
|
370
|
+
};
|
371
|
+
type cors = (options?: CorsOptions) => {
|
372
|
+
corsify: (response: Response, request?: Request) => Response;
|
373
|
+
preflight: (request: Request) => Response | undefined;
|
374
|
+
};
|
375
|
+
|
376
|
+
interface ModuleServeRouter extends RouterType {
|
377
|
+
to(server: ModuleServeServer): any;
|
378
|
+
}
|
379
|
+
|
380
|
+
interface ResponseType{}
|
381
|
+
|
382
|
+
declare class ModuleServeServerOptions {
|
383
|
+
handler?: (req: RequestLike, res: ResponseType) => any;
|
384
|
+
routers?: ModuleServeRouter[];
|
385
|
+
fetch?: (req: RequestLike) => ResponseType | Promise<ResponseType>;
|
386
|
+
}
|
387
|
+
|
388
|
+
interface ModuleServeServer {
|
389
|
+
_server: any;
|
390
|
+
routers: Record<string, ModuleServeRouter>;
|
391
|
+
|
392
|
+
handleRequest: typeof ModuleServeServerOptions.prototype.handler;
|
393
|
+
listen: this;
|
394
|
+
port: (port: number) => this;
|
395
|
+
log: (string: string) => this;
|
396
|
+
}
|
397
|
+
|
398
|
+
interface ModuleServeFileRouterOptions {
|
399
|
+
root: string;
|
400
|
+
basePath?: string;
|
401
|
+
resolveExtensions?: string[];
|
402
|
+
bundlerOptions?: Record<string, any>;
|
403
|
+
bundlerEntry?: (file: string, layouts?: string[]) => string;
|
404
|
+
ssrBundlerEntry?: (file: string, layouts?: string[]) => string;
|
405
|
+
onError?: () => any;
|
406
|
+
}
|
407
|
+
|
408
|
+
declare class ModuleServe {
|
409
|
+
router({
|
410
|
+
id,
|
411
|
+
type,
|
412
|
+
}: {
|
413
|
+
id?: string;
|
414
|
+
type?: "auto" | "normal" | "default";
|
415
|
+
[key: string]: any;
|
416
|
+
}): ModuleServeRouter;
|
417
|
+
create(o: ModuleServeServerOptions): ModuleServeServer;
|
418
|
+
|
419
|
+
createFileRouter(
|
420
|
+
o: ModuleServeFileRouterOptions
|
421
|
+
): (req: RequestLike) => ResponseType | Promise<ResponseType>;
|
422
|
+
|
423
|
+
cors: cors;
|
424
|
+
json: ResponseFormatter;
|
425
|
+
error: ResponseFormatter;
|
426
|
+
png: ResponseFormatter;
|
427
|
+
jpeg: ResponseFormatter;
|
428
|
+
webp: ResponseFormatter;
|
429
|
+
text: ResponseFormatter;
|
430
|
+
html: ResponseFormatter;
|
431
|
+
status: statusR;
|
432
|
+
|
433
|
+
createResponse: createResponse;
|
434
|
+
|
435
|
+
withContent: withContent;
|
436
|
+
withCookies: withCookies;
|
437
|
+
withParams: withParams;
|
438
|
+
|
439
|
+
// @ts-ignore
|
440
|
+
Request = Request;
|
441
|
+
// @ts-ignore
|
442
|
+
Response = Response;
|
443
|
+
}
|
444
|
+
|
445
|
+
// @ts-ignore
|
446
|
+
type nodable = Element | Node | any;
|
447
|
+
interface Node {
|
448
|
+
type: string;
|
449
|
+
props: {
|
450
|
+
children: nodable[];
|
451
|
+
[key: string]: any;
|
452
|
+
};
|
453
|
+
}
|
454
|
+
interface ElementNode extends Node {}
|
455
|
+
|
456
|
+
interface ModuleWebPageOptions {
|
457
|
+
viewportMeta?: string | boolean;
|
458
|
+
title?: string | boolean;
|
459
|
+
}
|
460
|
+
|
461
|
+
interface ModuleWebPage {
|
462
|
+
root: nodable;
|
463
|
+
body: nodable;
|
464
|
+
head: nodable;
|
465
|
+
|
466
|
+
find(key: string, value?: string): Node;
|
467
|
+
add(...children: nodable[]): typeof this.body;
|
468
|
+
|
469
|
+
script(script: string): ReturnType<typeof this.add>;
|
470
|
+
|
471
|
+
serializeState(): string;
|
472
|
+
|
473
|
+
render(static?: boolean): string;
|
474
|
+
|
475
|
+
clone(): ModuleWebPage;
|
476
|
+
}
|
477
|
+
|
478
|
+
interface ModuleWebState {
|
479
|
+
value: any;
|
480
|
+
_value: any;
|
481
|
+
subscribe(callback: CallableFunction): this;
|
482
|
+
}
|
483
|
+
|
484
|
+
declare class ModuleWeb {
|
485
|
+
create(options: ModuleWebPageOptions): ModuleWebPage;
|
486
|
+
isNode(node: any): boolean;
|
487
|
+
isTextNode(node: any): boolean;
|
488
|
+
isElementNode(node: any): boolean;
|
489
|
+
|
490
|
+
createText(text: string): Node;
|
491
|
+
createElement(...args: any[]): ElementNode;
|
492
|
+
|
493
|
+
state(value): ModuleWebState | any;
|
494
|
+
// @ts-ignore
|
495
|
+
invokeState(states: State[], callback: CallableFunction): any;
|
496
|
+
|
497
|
+
bundle(filePath: string, options?: Record<string, any>): string;
|
498
|
+
}
|
499
|
+
|
500
|
+
declare class Stack<T = any> {
|
501
|
+
constructor();
|
502
|
+
push(item: T): void;
|
503
|
+
pop(): T | undefined;
|
504
|
+
isEmpty(): boolean;
|
505
|
+
peek(): T | undefined;
|
506
|
+
toArray(): T[];
|
507
|
+
}
|
508
|
+
|
509
|
+
declare class Queue<T = any> {
|
510
|
+
constructor();
|
511
|
+
enqueue(item: T): void;
|
512
|
+
dequeue(): T | undefined;
|
513
|
+
isEmpty(): boolean;
|
514
|
+
peek(): T | undefined;
|
515
|
+
toArray(): T[];
|
516
|
+
}
|
517
|
+
|
518
|
+
declare class LinkedList<T = any> {
|
519
|
+
constructor();
|
520
|
+
append(value: T): void;
|
521
|
+
prepend(value: T): void;
|
522
|
+
find(value: T): LinkedList.Node<T> | null;
|
523
|
+
delete(value: T): void;
|
524
|
+
toArray(): T[];
|
525
|
+
}
|
526
|
+
|
527
|
+
declare namespace LinkedList {
|
528
|
+
class Node<T = any> {
|
529
|
+
constructor(value: T);
|
530
|
+
value: T;
|
531
|
+
next: Node<T> | null;
|
532
|
+
}
|
533
|
+
}
|
534
|
+
|
535
|
+
declare class BinaryTree<T = any> {
|
536
|
+
constructor();
|
537
|
+
insert(value: T): void;
|
538
|
+
find(value: T): BinaryTree.Node<T> | null;
|
539
|
+
toArray(): T[];
|
540
|
+
}
|
541
|
+
|
542
|
+
declare namespace BinaryTree {
|
543
|
+
class Node<T = any> {
|
544
|
+
constructor(value: T);
|
545
|
+
value: T;
|
546
|
+
left: Node<T> | null;
|
547
|
+
right: Node<T> | null;
|
548
|
+
}
|
549
|
+
}
|
550
|
+
|
551
|
+
declare class DoublyLinkedList<T = any> {
|
552
|
+
constructor();
|
553
|
+
append(value: T): void;
|
554
|
+
prepend(value: T): void;
|
555
|
+
find(value: T): DoublyLinkedList.Node<T> | null;
|
556
|
+
delete(value: T): void;
|
557
|
+
toArray(): T[];
|
558
|
+
}
|
559
|
+
|
560
|
+
declare namespace DoublyLinkedList {
|
561
|
+
class Node<T = any> {
|
562
|
+
constructor(value: T);
|
563
|
+
value: T;
|
564
|
+
next: Node<T> | null;
|
565
|
+
prev: Node<T> | null;
|
566
|
+
}
|
567
|
+
}
|
568
|
+
|
569
|
+
declare interface ModuleData {
|
570
|
+
Stack: typeof Stack;
|
571
|
+
Queue: typeof Queue;
|
572
|
+
BinaryTree: typeof BinaryTree;
|
573
|
+
DoublyLinkedList: typeof DoublyLinkedList;
|
574
|
+
LinkedList: typeof LinkedList;
|
575
|
+
}
|
576
|
+
|
577
|
+
interface ModuleStream {
|
578
|
+
// @ts-ignore
|
579
|
+
Readable: Readable,
|
580
|
+
// @ts-ignore
|
581
|
+
Writable: Writable,
|
582
|
+
// @ts-ignore
|
583
|
+
Transform: Transform,
|
584
|
+
// @ts-ignore
|
585
|
+
Duplex: Duplex,
|
586
|
+
// @ts-ignore
|
587
|
+
pipeline: pipeline,
|
588
|
+
// @ts-ignore
|
589
|
+
finished: finished
|
590
|
+
}
|
591
|
+
|
592
|
+
declare function imp(path: "conf", options?: ImportOptions): ModuleConf;
|
593
|
+
declare function imp(path: "env", options?: ImportOptions): ModuleEnv;
|
594
|
+
declare function imp(path: "rune", options?: ImportOptions): ModuleRune;
|
595
|
+
declare function imp(path: "threads", options?: ImportOptions): ModuleThreads;
|
596
|
+
declare function imp(
|
597
|
+
path: "serve",
|
598
|
+
options?: ImportOptions
|
599
|
+
): typeof ModuleServe;
|
600
|
+
declare function imp(path: "web", options?: ImportOptions): typeof ModuleWeb;
|
601
|
+
declare function imp(path: "data", options?: ImportOptions): ModuleData;
|
602
|
+
declare function imp(path: "stream", options?: ImportOptions): ModuleStream;
|
603
|
+
declare function imp(path: string, options?: ImportOptions): any;
|
604
|
+
|
605
|
+
declare const inc: typeof imp;
|
606
|
+
|
607
|
+
// @ts-ignore
|
608
|
+
declare function require(moduleName: string): any;
|
609
|
+
|
610
|
+
interface Module {
|
611
|
+
exports: any;
|
612
|
+
filepath: string;
|
613
|
+
main: boolean;
|
614
|
+
impots: string[];
|
615
|
+
compiled: string;
|
616
|
+
}
|
617
|
+
|
618
|
+
// @ts-ignore
|
619
|
+
declare const module: Module;
|
620
|
+
|
621
|
+
interface Imports {
|
622
|
+
meta: {
|
623
|
+
// @ts-ignore
|
624
|
+
url: URL,
|
625
|
+
main: boolean
|
626
|
+
};
|
627
|
+
assets: any;
|
628
|
+
}
|
629
|
+
|
630
|
+
declare const imports: Imports;
|
631
|
+
|
632
|
+
// @ts-ignore
|
633
|
+
declare const process: {
|
634
|
+
argv: string[];
|
635
|
+
target: ReturnType<typeof emitter>;
|
636
|
+
__execFile: string;
|
637
|
+
env: Record<string, any>;
|
638
|
+
cwd: () => string;
|
639
|
+
arch: string;
|
640
|
+
exit: () => void;
|
641
|
+
};
|
642
|
+
|
643
|
+
interface AppConfig {
|
644
|
+
manifest: {
|
645
|
+
package: string;
|
646
|
+
[key: string]: any;
|
647
|
+
};
|
648
|
+
}
|
649
|
+
|
650
|
+
declare const app: {
|
651
|
+
path: string;
|
652
|
+
config: AppConfig;
|
653
|
+
};
|
654
|
+
|
655
|
+
declare function read(filepath: string, options?: { encoding: string }): string;
|
656
|
+
|
657
|
+
declare function realpath(
|
658
|
+
filepath: string,
|
659
|
+
options?: { encoding: string }
|
660
|
+
): string;
|
661
|
+
|
662
|
+
declare function write(filepath: string, content: any, options?: any): void;
|
663
|
+
|
664
|
+
declare function exists(filepath: string, options?: any): boolean;
|
665
|
+
|
666
|
+
declare function fstat(filepath: string, options?: any): any;
|
667
|
+
|
668
|
+
declare function rm(filepath: string, options?: any): void;
|
669
|
+
|
670
|
+
declare function chmod(filepath: string, mode: any, options?: any): void;
|
671
|
+
|
672
|
+
declare function mkdir(filepath: string, options?: any): void;
|
673
|
+
|
674
|
+
declare function ls(filepath: string, options?: any): string[];
|
675
|
+
|
676
|
+
declare function struct(template: {
|
677
|
+
[key: string]: any;
|
678
|
+
}): (...args: any[]) => any;
|
679
|
+
|
680
|
+
declare function future(
|
681
|
+
callback: (resolve: (data: any) => void, reject: (data: any) => void) => void,
|
682
|
+
timeout?: number,
|
683
|
+
defData?: any
|
684
|
+
): {
|
685
|
+
pipe(callback: (data: any) => any): Promise<any>;
|
686
|
+
last(callback: (data: any) => any): Promise<any>;
|
687
|
+
catch(callback: (data: any) => any): Promise<any>;
|
688
|
+
resolve(data: any): void;
|
689
|
+
reject(data: any): void;
|
690
|
+
wait(): Promise<any>;
|
691
|
+
};
|
692
|
+
declare namespace future {
|
693
|
+
function promise(
|
694
|
+
promse: Promise<any>,
|
695
|
+
timeout?: number,
|
696
|
+
defData?: any
|
697
|
+
): ReturnType<typeof future>;
|
698
|
+
}
|
699
|
+
|
700
|
+
declare function emitter(): {
|
701
|
+
on(
|
702
|
+
event: string | string[],
|
703
|
+
callback: (...args: any[]) => void,
|
704
|
+
props?: {}
|
705
|
+
): ReturnType<typeof emitter>;
|
706
|
+
off(
|
707
|
+
event: string | string[],
|
708
|
+
callback: (...args: any[]) => void,
|
709
|
+
removable?: (event: any) => void
|
710
|
+
): ReturnType<typeof emitter>;
|
711
|
+
emit(event: string | string[], ...data: any[]): ReturnType<typeof emitter>;
|
712
|
+
};
|
713
|
+
declare function exec(command: string, options?: { output?: boolean }): any;
|
714
|
+
declare namespace exec {
|
715
|
+
function background(
|
716
|
+
command: string,
|
717
|
+
options?: any,
|
718
|
+
callback?: (...args: any[]) => void
|
719
|
+
): any;
|
720
|
+
}
|
721
|
+
declare function spawn(command: string, ...args: any[]): any;
|
722
|
+
|
723
|
+
declare function typedef(
|
724
|
+
value: any,
|
725
|
+
strict?: boolean
|
726
|
+
): {
|
727
|
+
strict: boolean;
|
728
|
+
defaultValue: any;
|
729
|
+
class: Function;
|
730
|
+
type: string;
|
731
|
+
isConstucted: boolean;
|
732
|
+
isEmpty: boolean;
|
733
|
+
};
|
734
|
+
|
735
|
+
declare function typeis(obj: any, typeDef: any): boolean;
|
736
|
+
|
737
|
+
declare function typex(child: any, parent: any): boolean;
|
738
|
+
|
739
|
+
declare function typei(child: any, parent: any): boolean;
|
740
|
+
|
741
|
+
declare function int(v: any): number;
|
742
|
+
|
743
|
+
declare namespace int {
|
744
|
+
const type: {
|
745
|
+
strict: boolean;
|
746
|
+
defaultValue: number;
|
747
|
+
class: Function;
|
748
|
+
type: string;
|
749
|
+
isConstucted: boolean;
|
750
|
+
isEmpty: boolean;
|
751
|
+
};
|
752
|
+
}
|
753
|
+
declare function float(v: any): number;
|
754
|
+
declare namespace float {
|
755
|
+
const type: {
|
756
|
+
strict: boolean;
|
757
|
+
defaultValue: number;
|
758
|
+
class: Function;
|
759
|
+
type: string;
|
760
|
+
isConstucted: boolean;
|
761
|
+
isEmpty: boolean;
|
762
|
+
};
|
763
|
+
}
|
764
|
+
declare function num(v: any): number;
|
765
|
+
declare namespace num {
|
766
|
+
const type: {
|
767
|
+
strict: boolean;
|
768
|
+
defaultValue: number;
|
769
|
+
class: Function;
|
770
|
+
type: string;
|
771
|
+
isConstucted: boolean;
|
772
|
+
isEmpty: boolean;
|
773
|
+
};
|
774
|
+
}
|
775
|
+
declare function str(str: any): string;
|
776
|
+
declare namespace str {
|
777
|
+
const type: {
|
778
|
+
strict: boolean;
|
779
|
+
defaultValue: string;
|
780
|
+
class: Function;
|
781
|
+
type: string;
|
782
|
+
isConstucted: boolean;
|
783
|
+
isEmpty: boolean;
|
784
|
+
};
|
785
|
+
}
|
786
|
+
declare function bool(value: any): boolean;
|
787
|
+
declare namespace bool {
|
788
|
+
const type: {
|
789
|
+
strict: boolean;
|
790
|
+
defaultValue: boolean;
|
791
|
+
class: Function;
|
792
|
+
type: string;
|
793
|
+
isConstucted: boolean;
|
794
|
+
isEmpty: boolean;
|
795
|
+
};
|
796
|
+
}
|
797
|
+
declare function isEmpty(value: any): boolean;
|
798
|
+
declare function clone(value: any): any;
|
799
|
+
declare function deepClone(value: any): any;
|
800
|
+
declare function merge(obj1: any, obj2: any): any;
|
801
|
+
declare const uniqueId: () => string;
|
802
|
+
declare function filter(arr: any[], fn: (value: any) => boolean): any[];
|
803
|
+
declare function reduce(
|
804
|
+
arr: any[],
|
805
|
+
fn: (acc: any, value: any) => any,
|
806
|
+
initial: any
|
807
|
+
): any;
|
808
|
+
declare function compose(...fns: Function[]): (initialValue: any) => any;
|
809
|
+
declare function curry(fn: Function): (...args: any[]) => any;
|
810
|
+
declare function json(thing: string): any;
|
811
|
+
declare function jsons(thing: any): string;
|
812
|
+
declare function yaml(thing: any): any;
|
813
|
+
declare function yamls(thing: any): string;
|
814
|
+
|
815
|
+
/**
|
816
|
+
* Makes a HTTP request to the specified URL.
|
817
|
+
* @param url The URL to request.
|
818
|
+
* @param options The options for the request.
|
819
|
+
* @returns A promise resolving to the response or other specified output based on the options.
|
820
|
+
*/
|
821
|
+
declare function curl(
|
822
|
+
url: string,
|
823
|
+
options: {
|
824
|
+
/**
|
825
|
+
* Indicates whether to return a promise.
|
826
|
+
*/
|
827
|
+
a: true;
|
828
|
+
/**
|
829
|
+
* Indicates whether to return the response as plain text.
|
830
|
+
*/
|
831
|
+
text: true;
|
832
|
+
o?: string;
|
833
|
+
}
|
834
|
+
): Promise<string>;
|
835
|
+
/**
|
836
|
+
* Makes a HTTP request to the specified URL.
|
837
|
+
* @param url The URL to request.
|
838
|
+
* @param options The options for the request.
|
839
|
+
* @returns A promise resolving to the response or other specified output based on the options.
|
840
|
+
*/
|
841
|
+
declare function curl(
|
842
|
+
url: string,
|
843
|
+
options: {
|
844
|
+
/**
|
845
|
+
* Indicates whether to return a promise.
|
846
|
+
*/
|
847
|
+
a: true;
|
848
|
+
/**
|
849
|
+
* Indicates whether to return the response as JSON.
|
850
|
+
*/
|
851
|
+
json: true;
|
852
|
+
/**
|
853
|
+
* The file path to output the response.
|
854
|
+
*/
|
855
|
+
o?: string;
|
856
|
+
}
|
857
|
+
): Promise<object>;
|
858
|
+
/**
|
859
|
+
* Makes a HTTP request to the specified URL.
|
860
|
+
* @param url The URL to request.
|
861
|
+
* @param options The options for the request.
|
862
|
+
* @returns A promise resolving to the response or other specified output based on the options.
|
863
|
+
*/
|
864
|
+
declare function curl(
|
865
|
+
url: string,
|
866
|
+
options: {
|
867
|
+
/**
|
868
|
+
* Indicates whether to return a promise.
|
869
|
+
*/
|
870
|
+
a: true;
|
871
|
+
/**
|
872
|
+
* The file path to output the response.
|
873
|
+
*/
|
874
|
+
o?: string;
|
875
|
+
}
|
876
|
+
// @ts-ignore
|
877
|
+
): Promise<Response>;
|
878
|
+
|
879
|
+
/**
|
880
|
+
* Makes a HTTP request to the specified URL.
|
881
|
+
* @param url The URL to request.
|
882
|
+
* @param options The options for the request.
|
883
|
+
* @returns A promise resolving to the response or other specified output based on the options.
|
884
|
+
*/
|
885
|
+
declare function curl(
|
886
|
+
url: string,
|
887
|
+
options?: {
|
888
|
+
/**
|
889
|
+
* Indicates whether to return a promise.
|
890
|
+
*/
|
891
|
+
a?: boolean;
|
892
|
+
/**
|
893
|
+
* The file path to output the response.
|
894
|
+
*/
|
895
|
+
o?: string;
|
896
|
+
/**
|
897
|
+
* Indicates whether to return the response as JSON.
|
898
|
+
*/
|
899
|
+
json?: boolean;
|
900
|
+
/**
|
901
|
+
* Indicates whether to return the response as plain text.
|
902
|
+
*/
|
903
|
+
text?: boolean;
|
904
|
+
}
|
905
|
+
): ReturnType<typeof future>;
|
906
|
+
|
907
|
+
declare function print(...args: any[]): void;
|
908
|
+
declare namespace print {
|
909
|
+
// @ts-ignore
|
910
|
+
const stdout: WriteStream;
|
911
|
+
// @ts-ignore
|
912
|
+
const stdin: ReadStream;
|
913
|
+
}
|
914
|
+
|
915
|
+
declare function input(prompt: string): string;
|
916
|
+
|
917
|
+
declare const basename: (path: string) => string;
|
918
|
+
declare const dirname: (path: string) => string;
|
919
|
+
declare const extname: (path: string) => string;
|
920
|
+
declare const pjoin: (...paths: string[]) => string;
|
921
|
+
declare const presolve: (...paths: string[]) => string;
|
922
|
+
|
923
|
+
// @ts-ignore
|
924
|
+
declare function exports(value: any): any;
|
925
|
+
|
926
|
+
|
927
|
+
declare function pub(value: any): any;
|
928
|
+
declare function pub(name: string, value: any): any;
|
929
|
+
|
930
|
+
declare const opt: {
|
931
|
+
set: (key: string, value: any) => void;
|
932
|
+
get: (key: string) => any;
|
933
|
+
push: (key: string, value: any) => any;
|
934
|
+
pop: (key: string) => any;
|
935
|
+
};
|
936
|
+
|
937
|
+
declare const JSX: any;
|
938
|
+
declare const TYPES: any;
|
939
|
+
declare const DECORATORS: any;
|
940
|
+
declare function using(fn: any, ...args: any[]): any;
|
941
|
+
|
942
|
+
declare function wait(fn: CallableFunction, ...args: any[]): any;
|
943
|
+
declare function clear(): void;
|