@e-mc/types 0.10.2 → 0.10.4

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/settings.d.ts CHANGED
@@ -5,7 +5,7 @@ import type { CloudSource } from './cloud';
5
5
  import type { PermissionAction, PermissionReadWrite, PermittedDirectories } from './core';
6
6
  import type { DbSource, TimeoutAction } from './db';
7
7
  import type { HttpOutgoingHeaders, SecureConfig, ServerPort } from './http';
8
- import type { BackgroundColor, BroadcastOutMethod, ErrorOutMethod, ForegroundColor, LoggerColor, LoggerStatus, TextAlign, TextWrapStyle } from './logger';
8
+ import type { BackgroundColor, BroadcastOutMethod, ErrorOutMethod, ForegroundColor, LoggerColor, LoggerStatus, TextAlign } from './logger';
9
9
  import type { ExecAction, IncludeAction } from './module';
10
10
 
11
11
  import type { SpawnOptions } from 'child_process';
@@ -13,7 +13,6 @@ import type { BinaryLike, CipherGCMTypes } from 'crypto';
13
13
  import type { LookupAddress } from 'dns';
14
14
  import type { BrotliOptions, ZlibOptions } from 'zlib';
15
15
 
16
- import type { BackgroundColor as IBackgroundColor } from 'chalk';
17
16
  // @ts-ignore
18
17
  import type { Unit } from 'bytes';
19
18
  // @ts-ignore
@@ -60,13 +59,13 @@ export interface ProcessModule<T = PlainObject> extends HandlerSettings<T> {
60
59
  private?: boolean;
61
60
  };
62
61
  queue?: {
63
- limit?: number | string;
64
- expires?: number | string;
65
- priority: { bypass?: number | string } & MinMax<number | string>;
62
+ limit?: NumString;
63
+ expires?: NumString;
64
+ priority: { bypass?: NumString } & MinMax<NumString>;
66
65
  };
67
- limit?: number | string;
68
- sub_limit?: number | string;
69
- expires?: number | string;
66
+ limit?: NumString;
67
+ sub_limit?: NumString;
68
+ expires?: NumString;
70
69
  };
71
70
  cipher?: CipherConfig;
72
71
  password?: string;
@@ -78,7 +77,6 @@ export interface ProcessEnvConfig {
78
77
 
79
78
  export interface TempModule<T = PlainObject> extends HandlerSettings<T> {
80
79
  dir?: string;
81
- env?: string;
82
80
  write?: boolean;
83
81
  }
84
82
 
@@ -94,20 +92,19 @@ export interface PermissionSettings extends PlainObject {
94
92
  }
95
93
 
96
94
  export interface DownloadModule<T = PlainObject> extends HandlerSettings<T> {
97
- expires?: number | string;
95
+ expires?: NumString;
98
96
  aria2?: {
99
97
  bin?: string | false;
100
98
  exec?: ExecAction;
101
- check_integrity?: boolean;
102
- update_status?: number | string | { interval?: number | string; broadcast_only?: boolean };
103
- max_concurrent_downloads?: number | string;
104
- max_connection_per_server?: number | string;
105
- bt_stop_timeout?: number | string;
106
- bt_tracker_connect_timeout?: number | string;
107
- bt_tracker_timeout?: number | string;
99
+ update_status?: NumString | { interval?: NumString; broadcast_only?: boolean };
100
+ max_concurrent_downloads?: NumString;
101
+ max_connection_per_server?: NumString;
102
+ bt_stop_timeout?: NumString;
103
+ bt_tracker_connect_timeout?: NumString;
104
+ bt_tracker_timeout?: NumString;
108
105
  min_split_size?: string;
109
- disk_cache?: number | string;
110
- lowest_speed_limit?: number | string;
106
+ disk_cache?: NumString;
107
+ lowest_speed_limit?: NumString;
111
108
  always_resume?: boolean;
112
109
  file_allocation?: "none" | "prealloc" | "trunc" | "falloc";
113
110
  conf_path?: string;
@@ -147,13 +144,13 @@ export interface DocumentComponentOption<T = unknown> {
147
144
  cache?: T;
148
145
  coerce?: boolean;
149
146
  abort?: boolean;
150
- local_file?: number | string;
147
+ local_file?: NumString;
151
148
  }
152
149
 
153
- export interface DocumentSettings<T extends DocumentUserSettings = DocumentUserSettings> extends DocumentGroup, PurgeAction, ClientSettings<T>, PlainObject {
150
+ export interface DocumentSettings extends DocumentGroup, PurgeAction, ClientSettings<DocumentUserSettings>, PlainObject {
151
+ imports_strict?: boolean;
154
152
  directory?: DocumentDirectory;
155
153
  options?: DocumentComponentOptions;
156
- imports_strict?: boolean;
157
154
  }
158
155
 
159
156
  export interface DocumentDirectory extends StringMap {
@@ -175,7 +172,7 @@ export interface MemorySettings extends PlainObject {
175
172
  cache_disk?: MemoryCacheDiskSettings;
176
173
  }
177
174
 
178
- export interface MemoryCacheDiskSettings<T = number | string> extends IncludeAction<Null<string[]>> {
175
+ export interface MemoryCacheDiskSettings<T = NumString> extends IncludeAction<Null<string[]>> {
179
176
  enabled?: boolean;
180
177
  min_size?: T;
181
178
  max_size?: T;
@@ -192,12 +189,12 @@ export interface DbUserSettings extends DbSourceDataType<{ commands?: ObjectMap<
192
189
 
193
190
  export interface DbCacheSettings extends TimeoutAction {
194
191
  dir?: string;
195
- purge?: number | string;
192
+ purge?: NumString;
196
193
  when_empty?: boolean;
197
194
  }
198
195
 
199
196
  export interface DbSourceOptions {
200
- pool?: PoolConfig<number | string>;
197
+ pool?: PoolConfig<NumString>;
201
198
  cache?: DbCacheValue;
202
199
  coerce?: DbCoerceValue;
203
200
  }
@@ -207,20 +204,20 @@ export interface DbCoerceSettings<T = boolean> {
207
204
  options?: T;
208
205
  }
209
206
 
210
- export interface PurgeBase<T = number | string> extends MinMax {
207
+ export interface PurgeBase<T = NumString> extends MinMax {
211
208
  enabled?: boolean;
212
209
  percent?: T;
213
210
  limit?: number;
214
211
  }
215
212
 
216
213
  export interface PurgeComponent extends PurgeBase {
217
- interval?: number | string;
214
+ interval?: NumString;
218
215
  all?: boolean | number;
219
216
  log?: boolean;
220
217
  prefix?: string;
221
218
  }
222
219
 
223
- export type DbCacheValue = number | string | DbCacheSettings;
220
+ export type DbCacheValue = NumString | DbCacheSettings;
224
221
  export type DbCoerceValue = boolean | DbCoerceSettings;
225
222
  export type DbSourceDataType<T = unknown> = {
226
223
  [K in DbSource]?: T;
@@ -237,42 +234,35 @@ export interface ImageSettings extends PlainObject {
237
234
  };
238
235
  }
239
236
 
240
- export interface RequestModule<T = RequestSettings> extends HandlerSettings<T>, HttpHostSettings {
241
- timeout?: number | string;
242
- read_timeout?: number | string;
237
+ export interface RequestModule<T = RequestSettings> extends HandlerSettings<T> {
238
+ timeout?: NumString;
239
+ read_timeout?: NumString;
243
240
  agent?: {
244
241
  keep_alive?: boolean;
245
- timeout?: number | string;
242
+ timeout?: NumString;
246
243
  };
247
244
  disk?: HttpDiskSettings;
248
245
  buffer?: HttpMemorySettings;
249
246
  connect?: HttpConnectSettings;
250
247
  dns?: DnsLookupSettings;
251
248
  use?: {
252
- http_version?: number | string;
249
+ http_version?: NumString;
253
250
  accept_encoding?: boolean;
254
251
  };
255
- proxy?: HttpProxySettings;
252
+ proxy?: AuthValue & IncludeAction & {
253
+ address?: string;
254
+ port?: NumString;
255
+ keep_alive?: boolean;
256
+ };
256
257
  headers?: HttpOutgoingHeaders;
257
258
  certs?: ObjectMap<SecureConfig<ArrayOf<string>>>;
258
- post_limit?: number | string;
259
- }
260
-
261
- export interface HttpProxySettings extends AuthValue, IncludeAction {
262
- address?: string;
263
- port?: number | string;
264
- origin?: string;
265
- keep_alive?: boolean;
266
- }
267
-
268
- export interface HttpHostSettings {
269
259
  localhost?: string[];
270
260
  protocol?: {
271
261
  "http/1.1"?: string[];
272
262
  h2c?: string[];
273
263
  h2?: string[];
274
264
  };
275
- write_stream?: ObjectMap<number | string>;
265
+ post_limit?: NumString;
276
266
  }
277
267
 
278
268
  export interface RequestSettings extends PurgeAction, PlainObject {
@@ -280,7 +270,7 @@ export interface RequestSettings extends PurgeAction, PlainObject {
280
270
  }
281
271
 
282
272
  export interface WatchModule<T = WatchSettings> extends HandlerModule<T>, ServerInfo {
283
- interval?: number | string;
273
+ interval?: NumString;
284
274
  }
285
275
 
286
276
  export interface WatchSettings<T = WatchUserSettings> extends ClientSettings<ObjectMap<T>>, PlainObject {}
@@ -289,15 +279,19 @@ export interface CompressModule<U = CompressSettings> extends HandlerSettings<U>
289
279
  gzip?: ZlibOptions;
290
280
  brotli?: BrotliOptions;
291
281
  zopfli?: ZopfliOptions;
282
+ tinify?: {
283
+ api_key?: string;
284
+ proxy?: string;
285
+ };
292
286
  }
293
287
 
294
288
  export interface CompressSettings extends PlainObject {
295
289
  cache?: boolean;
296
- cache_expires?: number | string;
297
- gzip_level?: number | string;
298
- brotli_quality?: number | string;
299
- zopfli_iterations?: number | string;
300
- chunk_size?: number | string;
290
+ cache_expires?: NumString;
291
+ gzip_level?: NumString;
292
+ brotli_quality?: NumString;
293
+ zopfli_iterations?: NumString;
294
+ chunk_size?: NumString;
301
295
  }
302
296
 
303
297
  export interface TaskModule<T = PlainObject> extends ClientModule<T>, PlainObject {}
@@ -325,24 +319,14 @@ export interface ErrorModule extends HandlerModule {
325
319
  out?: string | ErrorOutMethod;
326
320
  abort?: string[];
327
321
  fatal?: boolean;
328
- recursion_limit?: number | string;
329
- }
330
-
331
- export interface LoggerProgress extends LoggerFormatColor {
332
- scroll_buffer?: number | string;
333
- max_width?: number | string;
334
- use_color?: boolean;
335
- text_wrap?: TextWrapStyle;
336
- box_char?: string;
337
- raw_mode?: boolean;
322
+ recursion_limit?: NumString;
338
323
  }
339
324
 
340
- export interface LoggerModule<T = number | string, U = boolean | T, V = LoggerFormat<T>> {
325
+ export interface LoggerModule<T = NumString, U = boolean | T, V = LoggerFormat<T>> {
341
326
  enabled?: boolean;
342
- level?: number | string;
327
+ level?: NumString;
343
328
  production?: string[];
344
329
  format?: LoggerFormatSettings<V>;
345
- progress?: LoggerProgress;
346
330
  meter?: LoggerMeterSettings<T>;
347
331
  broadcast?: BroadcastServer & { color?: boolean };
348
332
  status?: boolean | LoggerStatus;
@@ -375,10 +359,9 @@ export interface LoggerFormatSettings<T = PlainObject> {
375
359
  session_id?: T;
376
360
  message?: T;
377
361
  meter?: T;
378
- error?: T;
379
362
  }
380
363
 
381
- export interface LoggerMeterSettings<T = number | string> {
364
+ export interface LoggerMeterSettings<T = NumString> {
382
365
  http?: T;
383
366
  image?: T;
384
367
  compress?: T;
@@ -388,58 +371,52 @@ export interface LoggerMeterSettings<T = number | string> {
388
371
  export interface LoggerProcessSettings extends LoggerColor {
389
372
  cpu?: boolean;
390
373
  cpu_bar?: boolean | ArrayOf<number>;
391
- cpu_bar_color?: [typeof IBackgroundColor, typeof IBackgroundColor, typeof IBackgroundColor];
392
374
  cpu_single_core?: boolean;
393
375
  mem?: boolean;
394
376
  mem_format?: "%" | Unit;
395
377
  }
396
378
 
397
- export interface LoggerFormatColor {
379
+ export interface LoggerFormat<T = NumString> {
380
+ width?: T;
398
381
  color?: ForegroundColor;
399
382
  bg_color?: BackgroundColor;
400
- }
401
-
402
- export interface LoggerFormat<T = number | string> extends LoggerFormatColor {
403
- width?: T;
404
- alt_color?: ForegroundColor;
405
383
  bg_alt_color?: BackgroundColor;
406
384
  bold?: boolean;
407
385
  justify?: TextAlign;
408
386
  unit?: string;
409
387
  as?: StringMap;
410
- braces?: string | TupleOf<string>;
411
388
  }
412
389
 
413
390
  export interface HttpSettings {
414
- version?: number | string;
415
- timeout?: number | string;
391
+ version?: NumString;
392
+ timeout?: NumString;
416
393
  headers?: HttpOutgoingHeaders;
417
394
  certs?: ObjectMap<SecureConfig<ArrayOf<string>>>;
418
395
  }
419
396
 
420
397
  export interface HttpDiskSettings extends IncludeAction {
421
398
  enabled?: boolean;
422
- limit?: number | string;
423
- expires?: number | string;
399
+ limit?: NumString;
400
+ expires?: NumString;
424
401
  }
425
402
 
426
403
  export interface HttpMemorySettings extends HttpDiskSettings {
427
- limit_all?: number | string;
428
- to_disk?: number | string | [number | string, (number | string)?];
429
- purge_amount?: number | string;
404
+ limit_all?: NumString;
405
+ to_disk?: NumString | [NumString, NumString?];
406
+ purge_amount?: NumString;
430
407
  }
431
408
 
432
409
  export interface HttpConnectSettings {
433
- timeout?: number | string;
434
- retry_wait?: number | string;
435
- retry_after?: number | string;
436
- retry_limit?: number | string;
437
- redirect_limit?: number | string;
410
+ timeout?: NumString;
411
+ retry_wait?: NumString;
412
+ retry_after?: NumString;
413
+ retry_limit?: NumString;
414
+ redirect_limit?: NumString;
438
415
  }
439
416
 
440
417
  export interface DnsLookupSettings {
441
- family?: number | string;
442
- expires?: number | string;
418
+ family?: NumString;
419
+ expires?: NumString;
443
420
  resolve?: ObjectMap<Partial<LookupAddress>>;
444
421
  }
445
422
 
@@ -447,12 +424,12 @@ export interface HashConfig extends IncludeAction<ObjectMap<string[] | "*">> {
447
424
  enabled?: boolean;
448
425
  algorithm?: HashAlgorithm;
449
426
  etag?: boolean;
450
- expires?: number | string;
427
+ expires?: NumString;
451
428
  renew?: boolean;
452
- limit?: number | string;
429
+ limit?: NumString;
453
430
  }
454
431
 
455
- export interface BroadcastServer extends ServerInfo<ArrayOf<number | string>> {
432
+ export interface BroadcastServer extends ServerInfo<ArrayOf<NumString>> {
456
433
  out?: string | BroadcastOutMethod;
457
434
  }
458
435
 
@@ -480,7 +457,7 @@ export interface CipherConfig {
480
457
  iv?: BinaryLike;
481
458
  }
482
459
 
483
- export interface ServerInfo<T = number | string> extends ServerPort<T> {
460
+ export interface ServerInfo<T = NumString> extends ServerPort<T> {
484
461
  enabled?: boolean;
485
462
  secure?: SecureConfig & ServerPort<T>;
486
463
  }
package/lib/squared.d.ts CHANGED
@@ -23,6 +23,18 @@ interface BlobValue extends KeyValue<string, unknown> {
23
23
  filename?: string;
24
24
  }
25
25
 
26
+ interface BoxRect<T = number> {
27
+ top: T;
28
+ right: T;
29
+ bottom: T;
30
+ left: T;
31
+ }
32
+
33
+ interface BoxRectDimension extends BoxRect, Dimension {
34
+ numberOfLines?: number;
35
+ overflow?: boolean;
36
+ }
37
+
26
38
  export interface FileAsset extends TextAsset, OutputAction, DocumentAction, MultipartAction, ResourceAction, IncrementalAction, ChecksumAction {
27
39
  format?: ArrayOf<string>;
28
40
  dataView?: NodeJS.ArrayBufferView;
@@ -41,7 +53,7 @@ export interface DataSource<T = unknown> extends DocumentAction {
41
53
  preRender?: string | FunctionType;
42
54
  whenEmpty?: string | FunctionType;
43
55
  removeEmpty?: boolean;
44
- ignoreCache?: IntBool | FirstOf<number, number>;
56
+ ignoreCache?: boolean | 0 | 1 | [number, number?, number?];
45
57
  transactionState?: number;
46
58
  transactionFail?: boolean;
47
59
  }
@@ -54,7 +66,6 @@ export interface DbDataSource<T = unknown, U = unknown, V = unknown, W = unknown
54
66
  update?: V;
55
67
  withCommand?: string | TupleOf<string>;
56
68
  parallel?: boolean;
57
- flat?: number;
58
69
  willAbort?: boolean;
59
70
  streamRow?: Null<boolean | string | ((row: unknown) => Void<Error | false>)>;
60
71
  usePool?: boolean | X;
@@ -80,7 +91,7 @@ export interface WatchAction {
80
91
  }
81
92
 
82
93
  export interface BundleAction<T = unknown> {
83
- bundleId?: number | string;
94
+ bundleId?: NumString;
84
95
  bundleIndex?: number;
85
96
  bundleReplace?: T;
86
97
  bundleQueue?: Promise<unknown>[];
@@ -214,7 +225,7 @@ export interface CompressFormat extends CompressLevel {
214
225
  condition?: string;
215
226
  plugin?: string;
216
227
  timeout?: number;
217
- options?: PlainObject;
228
+ options?: PlainObject & { apiKey?: string };
218
229
  }
219
230
 
220
231
  export interface WatchInterval<T = FileAsset> extends TaskBase {
@@ -257,7 +268,7 @@ export interface BroadcastResponse extends WebSocketResponse {
257
268
 
258
269
  export interface FileInfo {
259
270
  name: string;
260
- size: number | string;
271
+ size: NumString;
261
272
  }
262
273
 
263
274
  export interface RequestBase<T = PlainObject> {
@@ -311,7 +322,32 @@ export interface ResponseError {
311
322
 
312
323
  export interface RequestObserve extends WebSocketClient {
313
324
  action?: string;
314
- expires?: number | string;
325
+ expires?: NumString;
326
+ }
327
+
328
+ export interface FinalizedElement {
329
+ documentId: string;
330
+ bounds: BoxRectDimension;
331
+ css: PlainObject;
332
+ outerWrapperIds?: string[];
333
+ }
334
+
335
+ export interface ConditionProperty {
336
+ conditionText: string;
337
+ }
338
+
339
+ export interface CssConditionData extends ConditionProperty {
340
+ name?: string;
341
+ conditionText: string;
342
+ }
343
+
344
+ export interface ControllerSettingsDirectoryUI {
345
+ layout: string;
346
+ string: string;
347
+ font: string;
348
+ image: string;
349
+ video: string;
350
+ audio: string;
315
351
  }
316
352
 
317
353
  export interface ChecksumBase<T = BinaryToTextEncoding> {
@@ -327,9 +363,9 @@ export interface ChecksumOutput<T = BinaryToTextEncoding> extends ChecksumBase<T
327
363
  }
328
364
 
329
365
  export interface TaskBase {
330
- interval?: number | string;
331
- start?: number | string;
332
- expires?: number | string;
366
+ interval?: NumString;
367
+ start?: NumString;
368
+ expires?: NumString;
333
369
  }
334
370
 
335
371
  export type WebSocketEvent = "close" | "error";
package/lib/type.d.ts CHANGED
@@ -1,36 +1,31 @@
1
- /** @deprecated */
1
+ /* eslint @typescript-eslint/no-explicit-any: "off", @typescript-eslint/no-redeclare: "off" */
2
+
2
3
  type Undef<T> = T | undefined;
3
- /** @deprecated */
4
4
  type Null<T> = T | null;
5
5
  type Void<T> = T | void;
6
6
  type Optional<T> = T | null | undefined;
7
7
  type Nullable<T> = { [P in keyof T]: T[P] | null; };
8
- type Writable<T> = { -readonly [P in keyof T]: T[P] };
8
+ type Writeable<T> = { -readonly [P in keyof T]: T[P] };
9
9
  type KeyOfType<T, U = any, V = any> = { [K in keyof T]: K extends U ? T[K] extends V ? K : never : never }[keyof T];
10
10
  type MapOfType<T, U = any, V = any> = { [K in KeyOfType<T, U, V>]: K extends U ? T[K] extends V ? T[K] : never : never };
11
11
 
12
12
  type Constructor<out T> = new(...args: any[]) => T;
13
- type ConstructorDerived<T> = Pick<T, { [K in keyof T]: T[K] extends new() => any ? never : K }[keyof T]>;
14
13
 
15
14
  type FunctionType<T = unknown, U = unknown> = (...args: U[]) => T;
16
15
  type FunctionArgs<T extends unknown[], U = unknown> = (...args: T) => U;
17
16
 
18
- /** @deprecated */
19
17
  type NumString = number | string;
20
- type IntBool = boolean | 0 | 1;
21
18
  type ArrayOf<T> = T | T[];
22
- /** @deprecated */
23
19
  type TupleOf<T> = [T, T];
24
- type FirstOf<T, U = boolean> = T extends U ? [T, ...T[]] : T[] | [U, T, ...T[]];
20
+ type FirstOf<T, U = boolean> = T[] | [U, ...T[]];
25
21
  type Bufferable = string | Buffer;
26
22
 
27
23
  type AnyObject = Record<string, unknown>;
28
24
  type PlainObject = Record<string | number | symbol, unknown>;
29
25
 
30
26
  type StandardMap = Record<string, any>;
31
- type StringMap = Record<string, string | undefined>;
32
- type ObjectMap<T> = Record<string, T | undefined>;
33
- type IterableMap<T> = Record<string, T>;
27
+ type StringMap = Record<string, Undef<string>>;
28
+ type ObjectMap<T> = Record<string, Undef<T>>;
34
29
 
35
30
  type PropertyAction<T, U extends string, V extends boolean = false> = {
36
31
  [K in keyof T as `${U}${V extends true ? string & K : Capitalize<string & K>}`]: T[K];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@e-mc/types",
3
- "version": "0.10.2",
3
+ "version": "0.10.4",
4
4
  "description": "Type definitions for E-mc.",
5
5
  "main": "index.js",
6
6
  "types": "index.d.ts",
@@ -17,7 +17,7 @@
17
17
  "squared-functions"
18
18
  ],
19
19
  "author": "An Pham <anpham6@gmail.com>",
20
- "license": "BSD 3-Clause",
20
+ "license": "BSD-3-Clause",
21
21
  "homepage": "https://github.com/anpham6/e-mc#readme",
22
22
  "dependencies": {
23
23
  "bytes": "^3.1.2"
package/lib/dom.d.ts DELETED
@@ -1,9 +0,0 @@
1
- interface EventListenerOptions {
2
- capture?: boolean;
3
- }
4
-
5
- export interface AddEventListenerOptions extends EventListenerOptions {
6
- once?: boolean;
7
- passive?: boolean;
8
- signal?: AbortSignal;
9
- }