@makano/rew 1.2.5 → 1.2.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/civet/main.js +17239 -0
- package/lib/rew/cli/cli.js +34 -5
- package/lib/rew/cli/utils.js +43 -12
- package/lib/rew/const/default.js +2 -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/export.js +1 -1
- package/lib/rew/functions/fs.js +6 -1
- package/lib/rew/functions/import.js +17 -12
- 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 +103 -34
- package/lib/rew/modules/context.js +13 -1
- package/lib/rew/modules/runtime.js +37 -20
- 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 +7 -5
- package/runtime.d.ts +718 -146
- package/jsconfig.json +0 -13
- 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
CHANGED
@@ -1,9 +1,10 @@
|
|
1
1
|
|
2
|
+
|
2
3
|
interface ImportOptions {
|
3
4
|
/**
|
4
5
|
* Determines how to import the given module
|
5
6
|
*/
|
6
|
-
type:
|
7
|
+
type: "js" | "coffee" | "yaml" | "json" | "qrew" | "text";
|
7
8
|
[key: string]: any;
|
8
9
|
}
|
9
10
|
|
@@ -14,30 +15,30 @@ interface ModuleConfOptionCenter {
|
|
14
15
|
* @param defaultValue The default value ig null
|
15
16
|
* @returns The value of the key or the defaultValue if it's null.
|
16
17
|
*/
|
17
|
-
get: <T = any>(key: string, defaultValue?: T) => T
|
18
|
+
get: <T = any>(key: string, defaultValue?: T) => T;
|
18
19
|
/**
|
19
20
|
* Set a config key
|
20
21
|
* @param key The key of the config to set
|
21
22
|
* @param value The value to set it to
|
22
23
|
* @returns true if it was a success
|
23
24
|
*/
|
24
|
-
set: <T = any>(key: string, value: T) => boolean
|
25
|
+
set: <T = any>(key: string, value: T) => boolean;
|
25
26
|
/**
|
26
27
|
* Removes a key from the config
|
27
28
|
* @param key The key of the config to remove
|
28
29
|
* @returns true if it was a success
|
29
30
|
*/
|
30
|
-
remove: (key: string) => boolean
|
31
|
+
remove: (key: string) => boolean;
|
31
32
|
/**
|
32
33
|
* Resets the entire config option center to it's default value
|
33
34
|
*/
|
34
|
-
reset: () => boolean
|
35
|
+
reset: () => boolean;
|
35
36
|
/**
|
36
37
|
* Get all values in an option center
|
37
|
-
* @param str
|
38
|
-
* @returns
|
38
|
+
* @param str
|
39
|
+
* @returns
|
39
40
|
*/
|
40
|
-
getAll: (() => string) | ((str?: false) => Record<string, any>)
|
41
|
+
getAll: (() => string) | ((str?: false) => Record<string, any>);
|
41
42
|
}
|
42
43
|
|
43
44
|
interface ModuleConf extends ModuleConfOptionCenter {
|
@@ -45,12 +46,12 @@ interface ModuleConf extends ModuleConfOptionCenter {
|
|
45
46
|
* A separate options file for a related set of options
|
46
47
|
* @param name The option center full path
|
47
48
|
* @param defaults The default values
|
48
|
-
*
|
49
|
-
* @example
|
49
|
+
*
|
50
|
+
* @example
|
50
51
|
* conf = imp 'conf'
|
51
|
-
*
|
52
|
+
*
|
52
53
|
* animations = conf.optionCenter 'animations', enable: false, speed: '1x'
|
53
|
-
*
|
54
|
+
*
|
54
55
|
* if animations.get 'enable'
|
55
56
|
* animate animations.get 'speed'
|
56
57
|
*/
|
@@ -58,32 +59,36 @@ interface ModuleConf extends ModuleConfOptionCenter {
|
|
58
59
|
/**
|
59
60
|
* Manage Static files
|
60
61
|
*/
|
61
|
-
staticFile: (
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
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
|
+
};
|
67
72
|
}
|
68
73
|
|
69
74
|
interface ModuleEnv {
|
70
|
-
has: (key: string) => boolean
|
71
|
-
get: (key: string) => string
|
72
|
-
set: (key: string, value: string) => boolean
|
73
|
-
rm: (key: string) => boolean
|
74
|
-
is: (key: string, value: string) => boolean
|
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;
|
75
80
|
}
|
76
81
|
|
77
82
|
interface ModuleRuneDBCollcetion {
|
78
|
-
insert(record: object): any;
|
79
|
-
read(id: string | object, evaluate?: boolean): any;
|
80
|
-
update(caseRecord: string | object, newRecord: object): any;
|
83
|
+
insert(record: object): any;
|
84
|
+
read(id: string | object, evaluate?: boolean): any;
|
85
|
+
update(caseRecord: string | object, newRecord: object): any;
|
81
86
|
remove(id: string | object): boolean;
|
82
|
-
find(criteria: string | object): any;
|
83
|
-
map(cb: (data: any[]) => any[], mutate?: boolean): any[];
|
84
|
-
transform(cb: (data: any[]) => any[], mutate?: boolean): any[];
|
85
|
-
filter(cb: (data: any[]) => boolean, mutate?: boolean): any[];
|
86
|
-
sort(cb: (a: any, b: any) => number, mutate?: boolean): any[];
|
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[];
|
87
92
|
list(): any[];
|
88
93
|
}
|
89
94
|
|
@@ -96,42 +101,510 @@ interface ModuleRuneDBMap {
|
|
96
101
|
}
|
97
102
|
|
98
103
|
interface ModuleRuneDB {
|
99
|
-
collection: (name: string) => ModuleRuneDBCollcetion
|
100
|
-
map: (name: string) => ModuleRuneDBMap
|
101
|
-
findRef: (ref: string) => any
|
102
|
-
setData: (data: Record<string, any>) => void
|
103
|
-
getData: () => Record<string, any
|
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>;
|
104
109
|
makeRef(value: object, props?: string): string | null;
|
105
110
|
}
|
106
111
|
|
107
112
|
interface ModuleRune {
|
108
113
|
db(dbname: string, data?: object, encryptionKey?: string): ModuleRuneDB;
|
109
114
|
genKey(secret: string): string;
|
110
|
-
push(...values: any[]):
|
111
|
-
pop(...values: any[]):
|
115
|
+
push(...values: any[]): any;
|
116
|
+
pop(...values: any[]): any;
|
112
117
|
}
|
113
118
|
|
114
119
|
interface ModuleThreads {
|
115
120
|
thread: (cb: Function) => {
|
116
|
-
stopAll: () => void
|
121
|
+
stopAll: () => void;
|
117
122
|
start: (context: Record<string, any>) => {
|
118
123
|
on: (event: string, callback: (data) => void) => void;
|
119
124
|
off: (event: string, callback: (data) => void) => void;
|
120
125
|
emit: (event: string, data: any) => void;
|
121
|
-
get: () => Promise
|
122
|
-
stop: () => void
|
123
|
-
}
|
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;
|
124
532
|
}
|
125
533
|
}
|
126
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
|
+
|
127
592
|
declare function imp(path: "conf", options?: ImportOptions): ModuleConf;
|
128
593
|
declare function imp(path: "env", options?: ImportOptions): ModuleEnv;
|
129
594
|
declare function imp(path: "rune", options?: ImportOptions): ModuleRune;
|
130
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;
|
131
603
|
declare function imp(path: string, options?: ImportOptions): any;
|
132
604
|
|
133
|
-
declare const inc
|
605
|
+
declare const inc: typeof imp;
|
134
606
|
|
607
|
+
// @ts-ignore
|
135
608
|
declare function require(moduleName: string): any;
|
136
609
|
|
137
610
|
interface Module {
|
@@ -139,49 +612,58 @@ interface Module {
|
|
139
612
|
filepath: string;
|
140
613
|
main: boolean;
|
141
614
|
impots: string[];
|
142
|
-
compiled: string
|
615
|
+
compiled: string;
|
143
616
|
}
|
144
617
|
|
618
|
+
// @ts-ignore
|
145
619
|
declare const module: Module;
|
146
620
|
|
147
621
|
interface Imports {
|
148
|
-
meta: {
|
149
|
-
|
622
|
+
meta: {
|
623
|
+
// @ts-ignore
|
624
|
+
url: URL,
|
625
|
+
main: boolean
|
626
|
+
};
|
627
|
+
assets: any;
|
150
628
|
}
|
151
629
|
|
152
630
|
declare const imports: Imports;
|
153
631
|
|
632
|
+
// @ts-ignore
|
154
633
|
declare const process: {
|
155
|
-
argv: string[]
|
156
|
-
target: ReturnType<typeof emitter
|
157
|
-
__execFile: string
|
158
|
-
env: Record<string, any
|
159
|
-
cwd: () => string
|
160
|
-
arch: string
|
161
|
-
exit: () => void
|
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;
|
162
641
|
};
|
163
642
|
|
164
643
|
interface AppConfig {
|
165
644
|
manifest: {
|
166
|
-
package: string
|
167
|
-
|
645
|
+
package: string;
|
646
|
+
[key: string]: any;
|
647
|
+
};
|
168
648
|
}
|
169
649
|
|
170
650
|
declare const app: {
|
171
|
-
path: string
|
172
|
-
config: AppConfig
|
173
|
-
}
|
174
|
-
|
651
|
+
path: string;
|
652
|
+
config: AppConfig;
|
653
|
+
};
|
175
654
|
|
176
655
|
declare function read(filepath: string, options?: { encoding: string }): string;
|
177
656
|
|
178
|
-
declare function realpath(
|
657
|
+
declare function realpath(
|
658
|
+
filepath: string,
|
659
|
+
options?: { encoding: string }
|
660
|
+
): string;
|
179
661
|
|
180
662
|
declare function write(filepath: string, content: any, options?: any): void;
|
181
663
|
|
182
664
|
declare function exists(filepath: string, options?: any): boolean;
|
183
665
|
|
184
|
-
declare function fstat(filepath: string, options?: any): any;
|
666
|
+
declare function fstat(filepath: string, options?: any): any;
|
185
667
|
|
186
668
|
declare function rm(filepath: string, options?: any): void;
|
187
669
|
|
@@ -191,9 +673,15 @@ declare function mkdir(filepath: string, options?: any): void;
|
|
191
673
|
|
192
674
|
declare function ls(filepath: string, options?: any): string[];
|
193
675
|
|
194
|
-
declare function struct(template: {
|
676
|
+
declare function struct(template: {
|
677
|
+
[key: string]: any;
|
678
|
+
}): (...args: any[]) => any;
|
195
679
|
|
196
|
-
declare function future(
|
680
|
+
declare function future(
|
681
|
+
callback: (resolve: (data: any) => void, reject: (data: any) => void) => void,
|
682
|
+
timeout?: number,
|
683
|
+
defData?: any
|
684
|
+
): {
|
197
685
|
pipe(callback: (data: any) => any): Promise<any>;
|
198
686
|
last(callback: (data: any) => any): Promise<any>;
|
199
687
|
catch(callback: (data: any) => any): Promise<any>;
|
@@ -202,21 +690,47 @@ declare function future(callback: (resolve: (data: any) => void, reject: (data:
|
|
202
690
|
wait(): Promise<any>;
|
203
691
|
};
|
204
692
|
declare namespace future {
|
205
|
-
function promise(
|
693
|
+
function promise(
|
694
|
+
promse: Promise<any>,
|
695
|
+
timeout?: number,
|
696
|
+
defData?: any
|
697
|
+
): ReturnType<typeof future>;
|
206
698
|
}
|
207
699
|
|
208
700
|
declare function emitter(): {
|
209
|
-
on(
|
210
|
-
|
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>;
|
211
711
|
emit(event: string | string[], ...data: any[]): ReturnType<typeof emitter>;
|
212
712
|
};
|
213
|
-
declare function exec(command: string, options?: { output?: boolean }): any;
|
713
|
+
declare function exec(command: string, options?: { output?: boolean }): any;
|
214
714
|
declare namespace exec {
|
215
|
-
function background(
|
715
|
+
function background(
|
716
|
+
command: string,
|
717
|
+
options?: any,
|
718
|
+
callback?: (...args: any[]) => void
|
719
|
+
): any;
|
216
720
|
}
|
217
|
-
declare function spawn(command: string, ...args: any[]): any;
|
218
|
-
|
219
|
-
declare function typedef(
|
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
|
+
};
|
220
734
|
|
221
735
|
declare function typeis(obj: any, typeDef: any): boolean;
|
222
736
|
|
@@ -224,26 +738,61 @@ declare function typex(child: any, parent: any): boolean;
|
|
224
738
|
|
225
739
|
declare function typei(child: any, parent: any): boolean;
|
226
740
|
|
227
|
-
declare function int(
|
741
|
+
declare function int(v: any): number;
|
228
742
|
|
229
743
|
declare namespace int {
|
230
|
-
const type: {
|
744
|
+
const type: {
|
745
|
+
strict: boolean;
|
746
|
+
defaultValue: number;
|
747
|
+
class: Function;
|
748
|
+
type: string;
|
749
|
+
isConstucted: boolean;
|
750
|
+
isEmpty: boolean;
|
751
|
+
};
|
231
752
|
}
|
232
|
-
declare function float(
|
753
|
+
declare function float(v: any): number;
|
233
754
|
declare namespace float {
|
234
|
-
const type: {
|
755
|
+
const type: {
|
756
|
+
strict: boolean;
|
757
|
+
defaultValue: number;
|
758
|
+
class: Function;
|
759
|
+
type: string;
|
760
|
+
isConstucted: boolean;
|
761
|
+
isEmpty: boolean;
|
762
|
+
};
|
235
763
|
}
|
236
|
-
declare function num(
|
764
|
+
declare function num(v: any): number;
|
237
765
|
declare namespace num {
|
238
|
-
const type: {
|
766
|
+
const type: {
|
767
|
+
strict: boolean;
|
768
|
+
defaultValue: number;
|
769
|
+
class: Function;
|
770
|
+
type: string;
|
771
|
+
isConstucted: boolean;
|
772
|
+
isEmpty: boolean;
|
773
|
+
};
|
239
774
|
}
|
240
775
|
declare function str(str: any): string;
|
241
776
|
declare namespace str {
|
242
|
-
const type: {
|
777
|
+
const type: {
|
778
|
+
strict: boolean;
|
779
|
+
defaultValue: string;
|
780
|
+
class: Function;
|
781
|
+
type: string;
|
782
|
+
isConstucted: boolean;
|
783
|
+
isEmpty: boolean;
|
784
|
+
};
|
243
785
|
}
|
244
786
|
declare function bool(value: any): boolean;
|
245
787
|
declare namespace bool {
|
246
|
-
const type: {
|
788
|
+
const type: {
|
789
|
+
strict: boolean;
|
790
|
+
defaultValue: boolean;
|
791
|
+
class: Function;
|
792
|
+
type: string;
|
793
|
+
isConstucted: boolean;
|
794
|
+
isEmpty: boolean;
|
795
|
+
};
|
247
796
|
}
|
248
797
|
declare function isEmpty(value: any): boolean;
|
249
798
|
declare function clone(value: any): any;
|
@@ -251,7 +800,11 @@ declare function deepClone(value: any): any;
|
|
251
800
|
declare function merge(obj1: any, obj2: any): any;
|
252
801
|
declare const uniqueId: () => string;
|
253
802
|
declare function filter(arr: any[], fn: (value: any) => boolean): any[];
|
254
|
-
declare function reduce(
|
803
|
+
declare function reduce(
|
804
|
+
arr: any[],
|
805
|
+
fn: (acc: any, value: any) => any,
|
806
|
+
initial: any
|
807
|
+
): any;
|
255
808
|
declare function compose(...fns: Function[]): (initialValue: any) => any;
|
256
809
|
declare function curry(fn: Function): (...args: any[]) => any;
|
257
810
|
declare function json(thing: string): any;
|
@@ -259,60 +812,69 @@ declare function jsons(thing: any): string;
|
|
259
812
|
declare function yaml(thing: any): any;
|
260
813
|
declare function yamls(thing: any): string;
|
261
814
|
|
262
|
-
|
263
815
|
/**
|
264
816
|
* Makes a HTTP request to the specified URL.
|
265
817
|
* @param url The URL to request.
|
266
818
|
* @param options The options for the request.
|
267
819
|
* @returns A promise resolving to the response or other specified output based on the options.
|
268
820
|
*/
|
269
|
-
declare function curl(
|
270
|
-
|
271
|
-
|
272
|
-
|
273
|
-
|
274
|
-
|
275
|
-
|
276
|
-
|
277
|
-
|
278
|
-
|
279
|
-
|
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>;
|
280
835
|
/**
|
281
836
|
* Makes a HTTP request to the specified URL.
|
282
837
|
* @param url The URL to request.
|
283
838
|
* @param options The options for the request.
|
284
839
|
* @returns A promise resolving to the response or other specified output based on the options.
|
285
840
|
*/
|
286
|
-
declare function curl(
|
287
|
-
|
288
|
-
|
289
|
-
|
290
|
-
|
291
|
-
|
292
|
-
|
293
|
-
|
294
|
-
|
295
|
-
|
296
|
-
|
297
|
-
|
298
|
-
|
299
|
-
|
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>;
|
300
858
|
/**
|
301
859
|
* Makes a HTTP request to the specified URL.
|
302
860
|
* @param url The URL to request.
|
303
861
|
* @param options The options for the request.
|
304
862
|
* @returns A promise resolving to the response or other specified output based on the options.
|
305
863
|
*/
|
306
|
-
declare function curl(
|
307
|
-
|
308
|
-
|
309
|
-
|
310
|
-
|
311
|
-
|
312
|
-
|
313
|
-
|
314
|
-
|
315
|
-
|
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>;
|
316
878
|
|
317
879
|
/**
|
318
880
|
* Makes a HTTP request to the specified URL.
|
@@ -320,52 +882,62 @@ declare function curl(url: string, options: {
|
|
320
882
|
* @param options The options for the request.
|
321
883
|
* @returns A promise resolving to the response or other specified output based on the options.
|
322
884
|
*/
|
323
|
-
declare function curl(
|
324
|
-
|
325
|
-
|
326
|
-
|
327
|
-
|
328
|
-
|
329
|
-
|
330
|
-
|
331
|
-
|
332
|
-
|
333
|
-
|
334
|
-
|
335
|
-
|
336
|
-
|
337
|
-
|
338
|
-
|
339
|
-
|
340
|
-
|
341
|
-
|
342
|
-
|
343
|
-
|
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>;
|
344
906
|
|
345
907
|
declare function print(...args: any[]): void;
|
346
908
|
declare namespace print {
|
909
|
+
// @ts-ignore
|
347
910
|
const stdout: WriteStream;
|
911
|
+
// @ts-ignore
|
348
912
|
const stdin: ReadStream;
|
349
|
-
}
|
913
|
+
}
|
350
914
|
|
351
915
|
declare function input(prompt: string): string;
|
352
916
|
|
353
|
-
|
354
917
|
declare const basename: (path: string) => string;
|
355
918
|
declare const dirname: (path: string) => string;
|
356
919
|
declare const extname: (path: string) => string;
|
357
920
|
declare const pjoin: (...paths: string[]) => string;
|
358
921
|
declare const presolve: (...paths: string[]) => string;
|
359
922
|
|
360
|
-
|
923
|
+
// @ts-ignore
|
924
|
+
declare function exports(value: any): any;
|
925
|
+
|
361
926
|
|
362
|
-
declare function pub(value: any)
|
363
|
-
declare function pub(name: string, value: any)
|
927
|
+
declare function pub(value: any): any;
|
928
|
+
declare function pub(name: string, value: any): any;
|
364
929
|
|
365
930
|
declare const opt: {
|
366
931
|
set: (key: string, value: any) => void;
|
367
|
-
get: (key: string) => any
|
368
|
-
push: (key: string, value: any) => any
|
369
|
-
pop: (key: string) => any
|
370
|
-
}
|
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;
|
371
941
|
|
942
|
+
declare function wait(fn: CallableFunction, ...args: any[]): any;
|
943
|
+
declare function clear(): void;
|