@e-mc/types 0.13.7 → 0.13.8

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/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # @e-mc/types
2
2
 
3
- * NodeJS 18.20.5 LTS
3
+ * NodeJS 18.20 LTS
4
4
  * ES2022
5
5
 
6
6
  ## General Usage
@@ -9,7 +9,7 @@
9
9
 
10
10
  ## Interface
11
11
 
12
- * [View Source](https://www.unpkg.com/@e-mc/types@0.13.7/index.d.ts)
12
+ * [View Source](https://www.unpkg.com/@e-mc/types@0.13.8/index.d.ts)
13
13
 
14
14
  ```typescript
15
15
  import type { LogArguments } from "./lib/logger";
@@ -81,6 +81,7 @@ function supported(major: number, minor: number, lts: boolean): boolean;
81
81
  function supported(major: number, minor?: number, patch?: number, lts?: boolean): boolean;
82
82
  function importESM(name: string | URL, isDefault: boolean, fromPath?: boolean): Promise<unknown>;
83
83
  function importESM(name: string | URL, options?: ImportAttributes, fromPath?: boolean): Promise<unknown>;
84
+ function requireESM(name: string, expect?: string): unknown;
84
85
  function purgeMemory(percent?: number): number;
85
86
 
86
87
  interface LOG_TYPE {
@@ -208,10 +209,10 @@ const IMPORT_MAP: Record<string, string | undefined>;
208
209
 
209
210
  ## References
210
211
 
211
- - https://www.unpkg.com/@e-mc/types@0.13.7/index.d.ts
212
- - https://www.unpkg.com/@e-mc/types@0.13.7/lib/logger.d.ts
213
- - https://www.unpkg.com/@e-mc/types@0.13.7/lib/module.d.ts
214
- - https://www.unpkg.com/@e-mc/types@0.13.7/lib/node.d.ts
212
+ - https://www.unpkg.com/@e-mc/types@0.13.8/index.d.ts
213
+ - https://www.unpkg.com/@e-mc/types@0.13.8/lib/logger.d.ts
214
+ - https://www.unpkg.com/@e-mc/types@0.13.8/lib/module.d.ts
215
+ - https://www.unpkg.com/@e-mc/types@0.13.8/lib/node.d.ts
215
216
 
216
217
  * https://developer.mozilla.org/en-US/docs/Web/API/DOMException
217
218
  * https://www.npmjs.com/package/@types/bytes
package/constant.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  export const enum INTERNAL {
2
- VERSION = '0.13.7',
2
+ VERSION = '0.13.8',
3
3
  TEMP_DIR = 'tmp',
4
4
  CJS = '__cjs__'
5
5
  }
package/index.d.ts CHANGED
@@ -350,6 +350,7 @@ declare namespace types {
350
350
  function supported(major: number, minor?: number, patch?: number, lts?: boolean): boolean;
351
351
  function importESM<T = unknown>(name: string | URL, isDefault: boolean, fromPath?: boolean): Promise<T>;
352
352
  function importESM<T = unknown>(name: string | URL, options?: ImportAttributes, fromPath?: boolean): Promise<T>;
353
+ function requireESM<T = unknown>(name: string, expect?: string): T;
353
354
  function purgeMemory(percent?: number): number;
354
355
  }
355
356
 
package/index.js CHANGED
@@ -48,6 +48,7 @@ exports.incrementUUID = incrementUUID;
48
48
  exports.hashKey = hashKey;
49
49
  exports.supported = supported;
50
50
  exports.importESM = importESM;
51
+ exports.requireESM = requireESM;
51
52
  const path = require("node:path");
52
53
  const fs = require("node:fs");
53
54
  const crypto = require("node:crypto");
@@ -57,6 +58,7 @@ const node_url_1 = require("node:url");
57
58
  const PATTERN_CHARS = {
58
59
  '&': '\\x26',
59
60
  '!': '\\x21',
61
+ '"': '\\x22',
60
62
  '#': '\\x23',
61
63
  '%': '\\x25',
62
64
  ',': '\\x2c',
@@ -102,6 +104,7 @@ let CACHE_COERCED = new WeakSet();
102
104
  let LOG_CURRENT = null;
103
105
  let SUPPORTED_HASHSINGLE = false;
104
106
  let SUPPORTED_IMPORTATTRIBUTES = false;
107
+ let SUPPORTED_REGEXPESCAPE = false;
105
108
  let TEMP_DIR = path.join(process.cwd(), "tmp");
106
109
  let INCREMENT_COUNT = 65536;
107
110
  let INCREMENT_PREFIX = '';
@@ -176,7 +179,7 @@ function fromObject(value, typedArray, structured, shared) {
176
179
  function trimQuote(value) {
177
180
  value = value.trim();
178
181
  const first = value[0];
179
- return first === value.at(-1) && (first === '"' || first === "'" || first === "`") ? value.substring(1, value.length - 1) : value;
182
+ return first === value.at(-1) && (first === '"' || first === "'" || first === "`") ? value.slice(1, -1) : value;
180
183
  }
181
184
  function checkCipherType(value) {
182
185
  switch (value) {
@@ -761,6 +764,9 @@ function hasGlob(value) {
761
764
  function escapePattern(value, symbols) {
762
765
  switch (typeof value) {
763
766
  case 'string': {
767
+ if (symbols && SUPPORTED_REGEXPESCAPE) {
768
+ return RegExp.escape(value);
769
+ }
764
770
  let result = '', j = 0;
765
771
  for (let i = 0, length = value.length, ch; i < length; ++i) {
766
772
  switch (ch = value[i]) {
@@ -1102,7 +1108,7 @@ function randomString(format, dictionary) {
1102
1108
  let length = 0, available;
1103
1109
  if (b.startsWith('[') && b.endsWith(']')) {
1104
1110
  length = 1;
1105
- available = b.substring(1, b.length - 1);
1111
+ available = b.slice(1, -1);
1106
1112
  }
1107
1113
  else {
1108
1114
  if (isNaN(length = +b)) {
@@ -1260,5 +1266,10 @@ async function importESM(name, isDefault, fromPath) {
1260
1266
  }
1261
1267
  return result;
1262
1268
  }
1269
+ function requireESM(name, expect) {
1270
+ const result = require(name);
1271
+ return process.features.require_module && isObject(result) && result.__esModule && 'default' in result && (!expect || typeof result.default === expect) ? result.default : result;
1272
+ }
1263
1273
  SUPPORTED_HASHSINGLE = supported(20, 12, true) || supported(21, 7);
1264
- SUPPORTED_IMPORTATTRIBUTES = supported(18, 20, 5, true) || supported(20, 18, 3, true) || supported(22, 12, true) || supported(23, 1);
1274
+ SUPPORTED_IMPORTATTRIBUTES = supported(18, 20, true) || supported(20, 10);
1275
+ SUPPORTED_REGEXPESCAPE = supported(24);
package/lib/dom.d.ts ADDED
@@ -0,0 +1,9 @@
1
+ interface EventListenerOptions {
2
+ capture?: boolean;
3
+ }
4
+
5
+ export interface AddEventListenerOptions extends EventListenerOptions {
6
+ once?: boolean;
7
+ passive?: boolean;
8
+ signal?: AbortSignal;
9
+ }
package/lib/index.d.ts CHANGED
@@ -14,7 +14,7 @@ import type { CommandData, CropData, QualityData, ResizeData, RotateData, Transf
14
14
  import type { ExecCommand, LOG_TYPE, LogArguments, LogComponent, LogDate, LogFailOptions, LogMessageOptions, LogOptions, LogProcessOptions, LogState, LogTime, LogType, LogValue, STATUS_TYPE, StatusType } from './logger';
15
15
  import type { AsHashOptions, CheckSemVerOptions, CopyDirOptions, CopyDirResult, CopyFileOptions, CreateDirOptions, DeleteFileOptions, DirectoryActionType, FileActionType, FileTypeFormat, GlobDirOptions, MoveFileOptions, PackageVersionOptions, ParseFunctionOptions, PermissionOptions, PermissionType, ProtocolType, ReadBufferOptions, ReadFileCallback, ReadFileOptions, ReadHashOptions, ReadTextOptions, RemoveDirOptions, TempDirOptions, WriteFileOptions } from './module';
16
16
  import type { ErrorCode, HighResolutionTime, RequestData, Settings } from './node';
17
- import type { ApplyOptions, Aria2Options, BufferFormat, DataEncodedResult, DataObjectResult, FormDataPart, HeadersOnCallback, HostConfig, IHttpAdapter, OpenOptions, PostOptions, ProxySettings, PutOptions, RcloneOptions, ReadExpectType, RequestInit, StatusOnCallback } from './request';
17
+ import type { ApplyOptions, Aria2Options, BufferFormat, DataEncodedResult, DataObjectResult, HeadersOnCallback, HostConfig, IHttpAdapter, OpenOptions, PostFileParts as PostFileParts, PostOptions, ProxySettings, PutOptions, RcloneOptions, ReadExpectType, RequestInit, StatusOnCallback } from './request';
18
18
  import type { ClientModule, CloudAuthSettings, CloudModule, CloudServiceOptions, CompressModule, CompressSettings, DbCoerceSettings, DbModule, DbSourceOptions, DnsLookupSettings, DocumentComponent, DocumentComponentOption, DocumentModule, HandlerSettings, HttpConnectSettings, HttpMemorySettings, ImageModule, LoggerFormat, LoggerFormatSettings, PoolConfig, RequestModule, RequestSettings, TaskModule, WatchModule } from './settings';
19
19
  import type { Command, SpawnResult } from './task';
20
20
  import type { IFileGroup, ModifiedPostFinalizeListener, SecureOptions, WatchInitResult } from './watch';
@@ -159,8 +159,8 @@ declare namespace functions {
159
159
  executeQuery(item: V, sessionKey: string): Promise<QueryResult>;
160
160
  executeQuery(item: V, options?: ExecuteQueryOptions | string): Promise<QueryResult>;
161
161
  executeBatchQuery(batch: V[], callback: ErrorQueryCallback, outResult?: BatchQueryResult): Promise<BatchQueryResult>;
162
- executeBatchQuery(batch: V[], sessionKey: string, outResult?: BatchQueryResult): Promise<BatchQueryResult>;
163
- executeBatchQuery(batch: V[], options?: ExecuteBatchQueryOptions | string, outResult?: BatchQueryResult): Promise<BatchQueryResult>;
162
+ executeBatchQuery(batch: V[], sessionKey: string | undefined, outResult?: BatchQueryResult): Promise<BatchQueryResult>;
163
+ executeBatchQuery(batch: V[], options?: ExecuteBatchQueryOptions, outResult?: BatchQueryResult): Promise<BatchQueryResult>;
164
164
  processRows(batch: V[], tasks: Promise<QueryResult | null>[], parallel: boolean): Promise<BatchQueryResult>;
165
165
  processRows(batch: V[], tasks: Promise<QueryResult | null>[], options?: ProcessRowsOptions | boolean, outResult?: BatchQueryResult): Promise<BatchQueryResult>;
166
166
  handleFail(err: unknown, item: V, options?: HandleFailOptions): boolean;
@@ -409,10 +409,10 @@ declare namespace functions {
409
409
  put<V extends PutOptions>(uri: string | URL, data: unknown, options: V): Promise<DataObjectResult<V>>;
410
410
  put<V extends PutOptions>(uri: string | URL, data: unknown, contentType?: string | V, options?: V): Promise<DataObjectResult<V>>;
411
411
  post<V extends { format: undefined; encoding: undefined }>(uri: string | URL, data: unknown, contentType: string): Promise<DataObjectResult<V>>;
412
- post<V extends { format: undefined; encoding: undefined }>(uri: string | URL, parts: FormDataPart[]): Promise<DataObjectResult<V>>;
413
- post<V extends { format: undefined; encoding: undefined }>(uri: string | URL, form: AnyObject, parts: FormDataPart[]): Promise<DataObjectResult<V>>;
412
+ post<V extends { format: undefined; encoding: undefined }>(uri: string | URL, parts: PostFileParts): Promise<DataObjectResult<V>>;
413
+ post<V extends { format: undefined; encoding: undefined }>(uri: string | URL, form: AnyObject, parts: PostFileParts): Promise<DataObjectResult<V>>;
414
414
  post<V extends PostOptions>(uri: string | URL, data: unknown, options: V): Promise<DataObjectResult<V>>;
415
- post<V extends PostOptions>(uri: string | URL, data: unknown, contentType?: string | FormDataPart[] | V, options?: V): Promise<DataObjectResult<V>>;
415
+ post<V extends PostOptions>(uri: string | URL, data: unknown, contentType?: string | PostFileParts | V, options?: V): Promise<DataObjectResult<V>>;
416
416
  get<V extends OpenOptions & { encoding: BufferEncoding }>(uri: string | URL, options: V): Promise<string>;
417
417
  get<V extends BufferFormat>(uri: string | URL, format: V): Promise<object | null>;
418
418
  get<V extends OpenOptions, W extends V | BufferFormat>(uri: string | URL, options?: W): Promise<W extends BufferFormat ? object | null : DataEncodedResult<V>>;
@@ -884,11 +884,17 @@ declare namespace functions {
884
884
  readBuffer(value: string | URL, cache?: boolean | ReadBufferOptions): Buffer | null;
885
885
  resolveMime(data: FileTypeFormat): Promise<FileTypeResult | undefined>;
886
886
  lookupMime(value: string, extension?: boolean): string;
887
- initCpuUsage(instance?: IModule): CpuUsage;
888
- getCpuUsage(start: CpuUsage, format: true): string;
889
- getCpuUsage(start: CpuUsage, format?: boolean): number;
887
+ /** @deprecated class */
888
+ initCpuUsage(instance?: IModule, thread?: boolean): CpuUsage;
889
+ /** @deprecated private */
890
+ getCpuUsage(start: CpuUsage, format: true, thread?: boolean): string;
891
+ /** @deprecated private */
892
+ getCpuUsage(start: CpuUsage, format?: boolean, thread?: boolean): number;
893
+ /** @deprecated private */
890
894
  getMemUsage(format: true | "%" | Unit, free?: boolean): string;
895
+ /** @deprecated private */
891
896
  getMemUsage(format?: boolean, free?: boolean): number;
897
+ /** @deprecated private */
892
898
  formatCpuMem(start: CpuUsage, all?: boolean): string;
893
899
  getPackageVersion(name: string | [string, string], options?: PackageVersionOptions): string;
894
900
  checkSemVer(name: string | [string, string], options: CheckSemVerOptions): boolean;
package/lib/module.d.ts CHANGED
@@ -57,6 +57,7 @@ export interface CopyFileOptions extends FileSystemOptions {
57
57
  overwrite?: boolean;
58
58
  createDir?: boolean;
59
59
  outSrc?: string;
60
+ mode?: number;
60
61
  }
61
62
 
62
63
  export interface RemoveDirOptions extends FileSystemOptions {
package/lib/object.d.ts CHANGED
@@ -34,4 +34,8 @@ interface MinMax<T = number> {
34
34
  }
35
35
 
36
36
  /** @deprecated lib/node **/
37
- type HighResolutionTime = bigint | [number, number];
37
+ type HighResolutionTime = bigint | [number, number];
38
+
39
+ interface RegExpConstructor {
40
+ escape(value: string): string;
41
+ }
package/lib/request.d.ts CHANGED
@@ -189,7 +189,7 @@ export interface PutOptions extends OpenOptions {
189
189
  }
190
190
 
191
191
  export interface PostOptions extends PutOptions {
192
- formData?: FormDataPart | FormDataPart[];
192
+ formData?: FormDataPart | File | PostFileParts;
193
193
  }
194
194
 
195
195
  export interface FormDataPart {
@@ -271,6 +271,7 @@ export interface AltSvcData {
271
271
  export type HttpMethod = "GET" | "POST" | "PUT" | "HEAD" | "DELETE";
272
272
  export type BufferFormat = "json" | "yaml" | "json5" | "xml" | "toml";
273
273
  export type ReadExpectType = "always" | "string" | "none";
274
+ export type PostFileParts = (File | FormDataPart)[];
274
275
  export type DataEncodedResult<T extends { encoding?: BufferEncoding }> = T extends { encoding: BufferEncoding } ? string : Bufferable | null;
275
276
  export type DataObjectResult<T extends { format?: unknown; encoding?: BufferEncoding }> = T extends { format: string | PlainObject } ? object | null : DataEncodedResult<T>;
276
277
  export type StatusOnCallback = (code: number, headers: IncomingHttpHeaders, url?: URL) => boolean | void;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@e-mc/types",
3
- "version": "0.13.7",
3
+ "version": "0.13.8",
4
4
  "description": "Type definitions for E-mc.",
5
5
  "main": "index.js",
6
6
  "types": "index.d.ts",