@makano/rew 1.2.52 → 1.2.54
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/import.js +1 -1
- 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 +347 -0
- package/lib/rew/pkgs/stream.js +10 -0
- package/lib/rew/pkgs/web.js +476 -0
- package/package.json +5 -5
- package/runtime.d.ts +675 -147
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,30 +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>)
|
|
39
|
+
getAll: (() => string) | ((str?: false) => Record<string, any>);
|
|
41
40
|
}
|
|
42
41
|
|
|
43
42
|
interface ModuleConf extends ModuleConfOptionCenter {
|
|
@@ -45,12 +44,12 @@ interface ModuleConf extends ModuleConfOptionCenter {
|
|
|
45
44
|
* A separate options file for a related set of options
|
|
46
45
|
* @param name The option center full path
|
|
47
46
|
* @param defaults The default values
|
|
48
|
-
*
|
|
49
|
-
* @example
|
|
47
|
+
*
|
|
48
|
+
* @example
|
|
50
49
|
* conf = imp 'conf'
|
|
51
|
-
*
|
|
50
|
+
*
|
|
52
51
|
* animations = conf.optionCenter 'animations', enable: false, speed: '1x'
|
|
53
|
-
*
|
|
52
|
+
*
|
|
54
53
|
* if animations.get 'enable'
|
|
55
54
|
* animate animations.get 'speed'
|
|
56
55
|
*/
|
|
@@ -58,32 +57,35 @@ interface ModuleConf extends ModuleConfOptionCenter {
|
|
|
58
57
|
/**
|
|
59
58
|
* Manage Static files
|
|
60
59
|
*/
|
|
61
|
-
staticFile: (
|
|
62
|
-
|
|
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;
|
|
68
|
+
};
|
|
67
69
|
}
|
|
68
70
|
|
|
69
71
|
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
|
|
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;
|
|
75
77
|
}
|
|
76
78
|
|
|
77
79
|
interface ModuleRuneDBCollcetion {
|
|
78
|
-
insert(record: object): any;
|
|
79
|
-
read(id: string | object, evaluate?: boolean): any;
|
|
80
|
-
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;
|
|
81
83
|
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[];
|
|
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[];
|
|
87
89
|
list(): any[];
|
|
88
90
|
}
|
|
89
91
|
|
|
@@ -96,11 +98,11 @@ interface ModuleRuneDBMap {
|
|
|
96
98
|
}
|
|
97
99
|
|
|
98
100
|
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
|
|
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>;
|
|
104
106
|
makeRef(value: object, props?: string): string | null;
|
|
105
107
|
}
|
|
106
108
|
|
|
@@ -113,21 +115,464 @@ interface ModuleRune {
|
|
|
113
115
|
|
|
114
116
|
interface ModuleThreads {
|
|
115
117
|
thread: (cb: Function) => {
|
|
116
|
-
stopAll: () => void
|
|
118
|
+
stopAll: () => void;
|
|
117
119
|
start: (context: Record<string, any>) => {
|
|
118
120
|
on: (event: string, callback: (data) => void) => void;
|
|
119
121
|
off: (event: string, callback: (data) => void) => void;
|
|
120
122
|
emit: (event: string, data: any) => void;
|
|
121
|
-
get: () => Promise
|
|
122
|
-
stop: () => void
|
|
123
|
-
}
|
|
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;
|
|
124
511
|
}
|
|
125
512
|
}
|
|
126
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
|
+
|
|
127
565
|
declare function imp(path: "conf", options?: ImportOptions): ModuleConf;
|
|
128
566
|
declare function imp(path: "env", options?: ImportOptions): ModuleEnv;
|
|
129
567
|
declare function imp(path: "rune", options?: ImportOptions): ModuleRune;
|
|
130
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;
|
|
131
576
|
declare function imp(path: string, options?: ImportOptions): any;
|
|
132
577
|
|
|
133
578
|
declare const inc = imp;
|
|
@@ -139,49 +584,55 @@ interface Module {
|
|
|
139
584
|
filepath: string;
|
|
140
585
|
main: boolean;
|
|
141
586
|
impots: string[];
|
|
142
|
-
compiled: string
|
|
587
|
+
compiled: string;
|
|
143
588
|
}
|
|
144
589
|
|
|
145
590
|
declare const module: Module;
|
|
146
591
|
|
|
147
592
|
interface Imports {
|
|
148
|
-
meta: {
|
|
149
|
-
|
|
593
|
+
meta: {
|
|
594
|
+
url: URL,
|
|
595
|
+
main: boolean
|
|
596
|
+
};
|
|
597
|
+
assets: any;
|
|
150
598
|
}
|
|
151
599
|
|
|
152
600
|
declare const imports: Imports;
|
|
153
601
|
|
|
154
602
|
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
|
|
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;
|
|
162
610
|
};
|
|
163
611
|
|
|
164
612
|
interface AppConfig {
|
|
165
613
|
manifest: {
|
|
166
|
-
package: string
|
|
167
|
-
|
|
614
|
+
package: string;
|
|
615
|
+
[key: string]: any;
|
|
616
|
+
};
|
|
168
617
|
}
|
|
169
618
|
|
|
170
619
|
declare const app: {
|
|
171
|
-
path: string
|
|
172
|
-
config: AppConfig
|
|
173
|
-
}
|
|
174
|
-
|
|
620
|
+
path: string;
|
|
621
|
+
config: AppConfig;
|
|
622
|
+
};
|
|
175
623
|
|
|
176
624
|
declare function read(filepath: string, options?: { encoding: string }): string;
|
|
177
625
|
|
|
178
|
-
declare function realpath(
|
|
626
|
+
declare function realpath(
|
|
627
|
+
filepath: string,
|
|
628
|
+
options?: { encoding: string }
|
|
629
|
+
): string;
|
|
179
630
|
|
|
180
631
|
declare function write(filepath: string, content: any, options?: any): void;
|
|
181
632
|
|
|
182
633
|
declare function exists(filepath: string, options?: any): boolean;
|
|
183
634
|
|
|
184
|
-
declare function fstat(filepath: string, options?: any): any;
|
|
635
|
+
declare function fstat(filepath: string, options?: any): any;
|
|
185
636
|
|
|
186
637
|
declare function rm(filepath: string, options?: any): void;
|
|
187
638
|
|
|
@@ -191,9 +642,15 @@ declare function mkdir(filepath: string, options?: any): void;
|
|
|
191
642
|
|
|
192
643
|
declare function ls(filepath: string, options?: any): string[];
|
|
193
644
|
|
|
194
|
-
declare function struct(template: {
|
|
645
|
+
declare function struct(template: {
|
|
646
|
+
[key: string]: any;
|
|
647
|
+
}): (...args: any[]) => any;
|
|
195
648
|
|
|
196
|
-
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
|
+
): {
|
|
197
654
|
pipe(callback: (data: any) => any): Promise<any>;
|
|
198
655
|
last(callback: (data: any) => any): Promise<any>;
|
|
199
656
|
catch(callback: (data: any) => any): Promise<any>;
|
|
@@ -202,21 +659,47 @@ declare function future(callback: (resolve: (data: any) => void, reject: (data:
|
|
|
202
659
|
wait(): Promise<any>;
|
|
203
660
|
};
|
|
204
661
|
declare namespace future {
|
|
205
|
-
function promise(
|
|
662
|
+
function promise(
|
|
663
|
+
promse: Promise<any>,
|
|
664
|
+
timeout?: number,
|
|
665
|
+
defData?: any
|
|
666
|
+
): ReturnType<typeof future>;
|
|
206
667
|
}
|
|
207
668
|
|
|
208
669
|
declare function emitter(): {
|
|
209
|
-
on(
|
|
210
|
-
|
|
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>;
|
|
211
680
|
emit(event: string | string[], ...data: any[]): ReturnType<typeof emitter>;
|
|
212
681
|
};
|
|
213
|
-
declare function exec(command: string, options?: { output?: boolean }): any;
|
|
682
|
+
declare function exec(command: string, options?: { output?: boolean }): any;
|
|
214
683
|
declare namespace exec {
|
|
215
|
-
function background(
|
|
684
|
+
function background(
|
|
685
|
+
command: string,
|
|
686
|
+
options?: any,
|
|
687
|
+
callback?: (...args: any[]) => void
|
|
688
|
+
): any;
|
|
216
689
|
}
|
|
217
|
-
declare function spawn(command: string, ...args: any[]): any;
|
|
218
|
-
|
|
219
|
-
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
|
+
};
|
|
220
703
|
|
|
221
704
|
declare function typeis(obj: any, typeDef: any): boolean;
|
|
222
705
|
|
|
@@ -224,26 +707,61 @@ declare function typex(child: any, parent: any): boolean;
|
|
|
224
707
|
|
|
225
708
|
declare function typei(child: any, parent: any): boolean;
|
|
226
709
|
|
|
227
|
-
declare function int(
|
|
710
|
+
declare function int(v: any): number;
|
|
228
711
|
|
|
229
712
|
declare namespace int {
|
|
230
|
-
const type: {
|
|
713
|
+
const type: {
|
|
714
|
+
strict: boolean;
|
|
715
|
+
defaultValue: number;
|
|
716
|
+
class: Function;
|
|
717
|
+
type: string;
|
|
718
|
+
isConstucted: boolean;
|
|
719
|
+
isEmpty: boolean;
|
|
720
|
+
};
|
|
231
721
|
}
|
|
232
|
-
declare function float(
|
|
722
|
+
declare function float(v: any): number;
|
|
233
723
|
declare namespace float {
|
|
234
|
-
const type: {
|
|
724
|
+
const type: {
|
|
725
|
+
strict: boolean;
|
|
726
|
+
defaultValue: number;
|
|
727
|
+
class: Function;
|
|
728
|
+
type: string;
|
|
729
|
+
isConstucted: boolean;
|
|
730
|
+
isEmpty: boolean;
|
|
731
|
+
};
|
|
235
732
|
}
|
|
236
|
-
declare function num(
|
|
733
|
+
declare function num(v: any): number;
|
|
237
734
|
declare namespace num {
|
|
238
|
-
const type: {
|
|
735
|
+
const type: {
|
|
736
|
+
strict: boolean;
|
|
737
|
+
defaultValue: number;
|
|
738
|
+
class: Function;
|
|
739
|
+
type: string;
|
|
740
|
+
isConstucted: boolean;
|
|
741
|
+
isEmpty: boolean;
|
|
742
|
+
};
|
|
239
743
|
}
|
|
240
744
|
declare function str(str: any): string;
|
|
241
745
|
declare namespace str {
|
|
242
|
-
const type: {
|
|
746
|
+
const type: {
|
|
747
|
+
strict: boolean;
|
|
748
|
+
defaultValue: string;
|
|
749
|
+
class: Function;
|
|
750
|
+
type: string;
|
|
751
|
+
isConstucted: boolean;
|
|
752
|
+
isEmpty: boolean;
|
|
753
|
+
};
|
|
243
754
|
}
|
|
244
755
|
declare function bool(value: any): boolean;
|
|
245
756
|
declare namespace bool {
|
|
246
|
-
const type: {
|
|
757
|
+
const type: {
|
|
758
|
+
strict: boolean;
|
|
759
|
+
defaultValue: boolean;
|
|
760
|
+
class: Function;
|
|
761
|
+
type: string;
|
|
762
|
+
isConstucted: boolean;
|
|
763
|
+
isEmpty: boolean;
|
|
764
|
+
};
|
|
247
765
|
}
|
|
248
766
|
declare function isEmpty(value: any): boolean;
|
|
249
767
|
declare function clone(value: any): any;
|
|
@@ -251,7 +769,11 @@ declare function deepClone(value: any): any;
|
|
|
251
769
|
declare function merge(obj1: any, obj2: any): any;
|
|
252
770
|
declare const uniqueId: () => string;
|
|
253
771
|
declare function filter(arr: any[], fn: (value: any) => boolean): any[];
|
|
254
|
-
declare function reduce(
|
|
772
|
+
declare function reduce(
|
|
773
|
+
arr: any[],
|
|
774
|
+
fn: (acc: any, value: any) => any,
|
|
775
|
+
initial: any
|
|
776
|
+
): any;
|
|
255
777
|
declare function compose(...fns: Function[]): (initialValue: any) => any;
|
|
256
778
|
declare function curry(fn: Function): (...args: any[]) => any;
|
|
257
779
|
declare function json(thing: string): any;
|
|
@@ -259,60 +781,68 @@ declare function jsons(thing: any): string;
|
|
|
259
781
|
declare function yaml(thing: any): any;
|
|
260
782
|
declare function yamls(thing: any): string;
|
|
261
783
|
|
|
262
|
-
|
|
263
784
|
/**
|
|
264
785
|
* Makes a HTTP request to the specified URL.
|
|
265
786
|
* @param url The URL to request.
|
|
266
787
|
* @param options The options for the request.
|
|
267
788
|
* @returns A promise resolving to the response or other specified output based on the options.
|
|
268
789
|
*/
|
|
269
|
-
declare function curl(
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
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>;
|
|
280
804
|
/**
|
|
281
805
|
* Makes a HTTP request to the specified URL.
|
|
282
806
|
* @param url The URL to request.
|
|
283
807
|
* @param options The options for the request.
|
|
284
808
|
* @returns A promise resolving to the response or other specified output based on the options.
|
|
285
809
|
*/
|
|
286
|
-
declare function curl(
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
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>;
|
|
300
827
|
/**
|
|
301
828
|
* Makes a HTTP request to the specified URL.
|
|
302
829
|
* @param url The URL to request.
|
|
303
830
|
* @param options The options for the request.
|
|
304
831
|
* @returns A promise resolving to the response or other specified output based on the options.
|
|
305
832
|
*/
|
|
306
|
-
declare function curl(
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
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>;
|
|
316
846
|
|
|
317
847
|
/**
|
|
318
848
|
* Makes a HTTP request to the specified URL.
|
|
@@ -320,55 +850,53 @@ declare function curl(url: string, options: {
|
|
|
320
850
|
* @param options The options for the request.
|
|
321
851
|
* @returns A promise resolving to the response or other specified output based on the options.
|
|
322
852
|
*/
|
|
323
|
-
declare function curl(
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
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>;
|
|
344
874
|
|
|
345
875
|
declare function print(...args: any[]): void;
|
|
346
876
|
declare namespace print {
|
|
347
877
|
const stdout: WriteStream;
|
|
348
878
|
const stdin: ReadStream;
|
|
349
|
-
}
|
|
879
|
+
}
|
|
350
880
|
|
|
351
881
|
declare function input(prompt: string): string;
|
|
352
882
|
|
|
353
|
-
|
|
354
883
|
declare const basename: (path: string) => string;
|
|
355
884
|
declare const dirname: (path: string) => string;
|
|
356
885
|
declare const extname: (path: string) => string;
|
|
357
886
|
declare const pjoin: (...paths: string[]) => string;
|
|
358
887
|
declare const presolve: (...paths: string[]) => string;
|
|
359
888
|
|
|
360
|
-
declare function exports(value: any)
|
|
361
|
-
|
|
362
|
-
declare function clear() : void;
|
|
889
|
+
declare function exports(value: any): any;
|
|
363
890
|
|
|
364
|
-
|
|
365
|
-
declare function pub(value: any)
|
|
366
|
-
declare function pub(name: string, value: any) : any;
|
|
891
|
+
declare function pub(value: any): any;
|
|
892
|
+
declare function pub(name: string, value: any): any;
|
|
367
893
|
|
|
368
894
|
declare const opt: {
|
|
369
895
|
set: (key: string, value: any) => void;
|
|
370
|
-
get: (key: string) => any
|
|
371
|
-
push: (key: string, value: any) => any
|
|
372
|
-
pop: (key: string) => any
|
|
373
|
-
}
|
|
896
|
+
get: (key: string) => any;
|
|
897
|
+
push: (key: string, value: any) => any;
|
|
898
|
+
pop: (key: string) => any;
|
|
899
|
+
};
|
|
374
900
|
|
|
901
|
+
declare function wait(fn: CallableFunction, ...args: any[]): any;
|
|
902
|
+
declare function clear(): void;
|