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