@e-mc/types 0.12.4 → 0.12.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +8 -6
- package/constant.d.ts +2 -1
- package/index.d.ts +4 -1
- package/index.js +15 -2
- package/lib/core.d.ts +5 -5
- package/lib/index.d.ts +0 -6
- package/lib/settings.d.ts +1 -1
- package/lib/task.d.ts +9 -9
- package/package.json +2 -3
package/README.md
CHANGED
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
|
|
10
10
|
## Interface
|
|
11
11
|
|
|
12
|
-
* [View Source](https://www.unpkg.com/@e-mc/types@0.12.
|
|
12
|
+
* [View Source](https://www.unpkg.com/@e-mc/types@0.12.6/index.d.ts)
|
|
13
13
|
|
|
14
14
|
```typescript
|
|
15
15
|
import type { LogArguments } from "./lib/logger";
|
|
@@ -74,7 +74,8 @@ function errorValue(value: string, hint?: string): Error;
|
|
|
74
74
|
function errorMessage(title: number | string, value: string, hint?: string): Error;
|
|
75
75
|
function supported(major: number, minor: number, lts: boolean): boolean;
|
|
76
76
|
function supported(major: number, minor?: number, patch?: number, lts?: boolean): boolean;
|
|
77
|
-
function importESM
|
|
77
|
+
function importESM(name: string | URL, isDefault: boolean, fromPath?: boolean): Promise<unknown>;
|
|
78
|
+
function importESM(name: string | URL, options?: ImportAttributes, fromPath?: boolean): Promise<unknown>;
|
|
78
79
|
function purgeMemory(percent?: number): number;
|
|
79
80
|
|
|
80
81
|
interface LOG_TYPE {
|
|
@@ -137,6 +138,7 @@ interface ACTION_FLAG {
|
|
|
137
138
|
|
|
138
139
|
interface ERR_CODE {
|
|
139
140
|
MODULE_NOT_FOUND: "MODULE_NOT_FOUND";
|
|
141
|
+
ERR_MODULE_NOT_FOUND: "ERR_MODULE_NOT_FOUND";
|
|
140
142
|
}
|
|
141
143
|
|
|
142
144
|
interface DOWNLOAD_TYPE {
|
|
@@ -201,10 +203,10 @@ const IMPORT_MAP: Record<string, string | undefined>;
|
|
|
201
203
|
|
|
202
204
|
## References
|
|
203
205
|
|
|
204
|
-
- https://www.unpkg.com/@e-mc/types@0.12.
|
|
205
|
-
- https://www.unpkg.com/@e-mc/types@0.12.
|
|
206
|
-
- https://www.unpkg.com/@e-mc/types@0.12.
|
|
207
|
-
- https://www.unpkg.com/@e-mc/types@0.12.
|
|
206
|
+
- https://www.unpkg.com/@e-mc/types@0.12.6/index.d.ts
|
|
207
|
+
- https://www.unpkg.com/@e-mc/types@0.12.6/lib/logger.d.ts
|
|
208
|
+
- https://www.unpkg.com/@e-mc/types@0.12.6/lib/module.d.ts
|
|
209
|
+
- https://www.unpkg.com/@e-mc/types@0.12.6/lib/node.d.ts
|
|
208
210
|
|
|
209
211
|
* https://developer.mozilla.org/en-US/docs/Web/API/DOMException
|
|
210
212
|
* 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.12.
|
|
2
|
+
VERSION = '0.12.6',
|
|
3
3
|
TEMP_DIR = 'tmp',
|
|
4
4
|
CJS = '__cjs__'
|
|
5
5
|
}
|
|
@@ -78,6 +78,7 @@ export const enum ERR_MESSAGE {
|
|
|
78
78
|
UNSUPPORTED_READ = 'Not permitted to read file',
|
|
79
79
|
UNSUPPORTED_WRITE = 'Not permitted to write file',
|
|
80
80
|
UNSUPPORTED_OVERWRITE = 'Not permitted to overwrite file',
|
|
81
|
+
UNSUPPORTED_PATH = 'Not permitted to set absolute path',
|
|
81
82
|
NOTFOUND_PATH = 'Path not found',
|
|
82
83
|
NOTFOUND_FILE = 'File not found',
|
|
83
84
|
NOTFOUND_BINARY = 'Binary not found',
|
package/index.d.ts
CHANGED
|
@@ -145,6 +145,7 @@ declare namespace types {
|
|
|
145
145
|
|
|
146
146
|
const ERR_CODE: {
|
|
147
147
|
MODULE_NOT_FOUND: string;
|
|
148
|
+
ERR_MODULE_NOT_FOUND: string;
|
|
148
149
|
};
|
|
149
150
|
|
|
150
151
|
interface DOWNLOAD_TYPE {
|
|
@@ -281,6 +282,7 @@ declare namespace types {
|
|
|
281
282
|
preserve?: boolean;
|
|
282
283
|
}
|
|
283
284
|
|
|
285
|
+
type ImportAttributes = { with: { type: "json" } };
|
|
284
286
|
type MergeArrayMethod = "concat" | "concat-pre" | "includes" | "unshift" | "push" | "flat" | "join" | "slice" | "reverse" | ["flat", number] | ["join", string] | ["slice", number, number?];
|
|
285
287
|
type WatchEventValue = WATCH_EVENT[keyof WATCH_EVENT];
|
|
286
288
|
|
|
@@ -340,7 +342,8 @@ declare namespace types {
|
|
|
340
342
|
function errorMessage(title: number | string, value: string, hint?: string): Error;
|
|
341
343
|
function supported(major: number, minor: number, lts: boolean): boolean;
|
|
342
344
|
function supported(major: number, minor?: number, patch?: number, lts?: boolean): boolean;
|
|
343
|
-
function importESM<T = unknown>(name: string, isDefault
|
|
345
|
+
function importESM<T = unknown>(name: string | URL, isDefault: boolean, fromPath?: boolean): Promise<T>;
|
|
346
|
+
function importESM<T = unknown>(name: string | URL, options?: ImportAttributes, fromPath?: boolean): Promise<T>;
|
|
344
347
|
function purgeMemory(percent?: number): number;
|
|
345
348
|
}
|
|
346
349
|
|
package/index.js
CHANGED
|
@@ -100,6 +100,7 @@ const RESERVED_SHELL = [
|
|
|
100
100
|
let CACHE_COERCED = new WeakSet();
|
|
101
101
|
let LOG_CURRENT = null;
|
|
102
102
|
let SUPPORTED_HASHSINGLE = false;
|
|
103
|
+
let SUPPORTED_IMPORTATTRIBUTES = false;
|
|
103
104
|
let TEMP_DIR = path.join(process.cwd(), "tmp");
|
|
104
105
|
let INCREMENT_COUNT = 65536;
|
|
105
106
|
let INCREMENT_PREFIX = '';
|
|
@@ -1188,10 +1189,21 @@ function supported(major, minor = 0, patch = 0, lts = false) {
|
|
|
1188
1189
|
return !lts;
|
|
1189
1190
|
}
|
|
1190
1191
|
async function importESM(name, isDefault, fromPath) {
|
|
1191
|
-
|
|
1192
|
+
let options;
|
|
1193
|
+
if (name instanceof URL) {
|
|
1194
|
+
name = (0, node_url_1.fileURLToPath)(name);
|
|
1195
|
+
}
|
|
1196
|
+
else if (fromPath && path.isAbsolute(name)) {
|
|
1192
1197
|
name = (0, node_url_1.pathToFileURL)(name).toString();
|
|
1193
1198
|
}
|
|
1194
|
-
|
|
1199
|
+
if (isObject(isDefault)) {
|
|
1200
|
+
options = isDefault;
|
|
1201
|
+
if (!SUPPORTED_IMPORTATTRIBUTES && options.with?.type === 'json') {
|
|
1202
|
+
return JSON.parse(fs.readFileSync(name, 'utf8'));
|
|
1203
|
+
}
|
|
1204
|
+
isDefault = true;
|
|
1205
|
+
}
|
|
1206
|
+
const result = import(name, options);
|
|
1195
1207
|
if (isDefault) {
|
|
1196
1208
|
const out = await result;
|
|
1197
1209
|
if (isObject(out) && 'default' in out) {
|
|
@@ -1201,3 +1213,4 @@ async function importESM(name, isDefault, fromPath) {
|
|
|
1201
1213
|
return result;
|
|
1202
1214
|
}
|
|
1203
1215
|
SUPPORTED_HASHSINGLE = supported(20, 12, true) || supported(21, 7);
|
|
1216
|
+
SUPPORTED_IMPORTATTRIBUTES = supported(18, 20, 5, true) || supported(20, 18, 3, true) || supported(22, 12, true) || supported(23, 1);
|
package/lib/core.d.ts
CHANGED
|
@@ -6,7 +6,7 @@ import type { StatusType } from '@e-mc/types/lib/logger';
|
|
|
6
6
|
import type { Settings } from './node';
|
|
7
7
|
import type { ClientDbSettings, ClientModule, DbCacheValue, DbCoerceSettings, DbSourceOptions } from './settings';
|
|
8
8
|
|
|
9
|
-
import type {
|
|
9
|
+
import type { Transferable, Worker, WorkerOptions } from 'node:worker_threads';
|
|
10
10
|
|
|
11
11
|
import type * as EventEmitter from 'node:events';
|
|
12
12
|
|
|
@@ -108,9 +108,9 @@ export interface WorkerGroupConstructor {
|
|
|
108
108
|
|
|
109
109
|
export interface IWorkerChannel<T = unknown> extends EventEmitter, Iterable<Worker>, WorkerInfo {
|
|
110
110
|
[Symbol.iterator](): IteratorObject<Worker, BuiltinIteratorReturn>;
|
|
111
|
-
sendObject(data: unknown, transferList?:
|
|
111
|
+
sendObject(data: unknown, transferList?: Transferable[], callback?: WorkerChannelResponse<T>, ...returnArgs: unknown[]): Worker;
|
|
112
112
|
sendBuffer(data: Buffer, shared?: boolean, callback?: WorkerChannelResponse<T>, ...returnArgs: unknown[]): Worker | null;
|
|
113
|
-
send(data: unknown, transferList?:
|
|
113
|
+
send(data: unknown, transferList?: Transferable[]): Promise<T>;
|
|
114
114
|
drop(count?: number): number;
|
|
115
115
|
join(group: IWorkerGroup, label?: string): void;
|
|
116
116
|
quit(): void;
|
|
@@ -141,13 +141,13 @@ export interface IWorkerChannel<T = unknown> extends EventEmitter, Iterable<Work
|
|
|
141
141
|
on(event: "online", listener: () => void): this;
|
|
142
142
|
on(event: "message", listener: (value: any) => void): this;
|
|
143
143
|
on(event: "data", listener: (data: T) => void): this;
|
|
144
|
-
on(event: "pass", listener: (data: unknown, transferList:
|
|
144
|
+
on(event: "pass", listener: (data: unknown, transferList: Transferable[] | undefined) => void): this;
|
|
145
145
|
once(event: "error" | "messageerror" | "abort", listener: (err: Error) => void): this;
|
|
146
146
|
once(event: "exit", listener: (exitCode: number) => void): this;
|
|
147
147
|
once(event: "online", listener: () => void): this;
|
|
148
148
|
once(event: "message", listener: (value: any) => void): this;
|
|
149
149
|
once(event: "data", listener: (data: T) => void): this;
|
|
150
|
-
once(event: "pass", listener: (data: unknown, transferList:
|
|
150
|
+
once(event: "pass", listener: (data: unknown, transferList: Transferable[] | undefined) => void): this;
|
|
151
151
|
}
|
|
152
152
|
|
|
153
153
|
export interface WorkerChannelConstructor<T = unknown> {
|
package/lib/index.d.ts
CHANGED
|
@@ -822,15 +822,9 @@ declare namespace functions {
|
|
|
822
822
|
getMemUsage(format?: boolean, free?: boolean): number;
|
|
823
823
|
formatCpuMem(start: CpuUsage, all?: boolean): string;
|
|
824
824
|
getPackageVersion(name: string | [string, string], options?: PackageVersionOptions): string;
|
|
825
|
-
/** @deprecated */
|
|
826
|
-
getPackageVersion(name: string | [string, string], startDir: string, baseDir?: string): string;
|
|
827
|
-
/** @deprecated */
|
|
828
|
-
getPackageVersion(name: string | [string, string], unstable?: boolean, startDir?: string, baseDir?: string): string;
|
|
829
825
|
checkSemVer(name: string | [string, string], options: CheckSemVerOptions): boolean;
|
|
830
826
|
checkSemVer(name: string | [string, string], min: number | string, max?: number | string): boolean;
|
|
831
827
|
checkSemVer(name: string | [string, string], min: number | string, max: number | string, options?: Omit<CheckSemVerOptions, "min" | "max" | "equals">): boolean;
|
|
832
|
-
/** @deprecated */
|
|
833
|
-
checkSemVer(name: string | [string, string], min: number | string, max?: number | string, unstable?: boolean, startDir?: string): boolean;
|
|
834
828
|
/** @deprecated @e-mc/types */
|
|
835
829
|
sanitizeCmd(value: string, ...args: unknown[]): string;
|
|
836
830
|
/** @deprecated @e-mc/types */
|
package/lib/settings.d.ts
CHANGED
|
@@ -272,7 +272,7 @@ export interface DbCoerceSettings<T = boolean> {
|
|
|
272
272
|
export interface PurgeBase<T = number | string> extends MinMax {
|
|
273
273
|
enabled?: boolean;
|
|
274
274
|
percent?: T;
|
|
275
|
-
limit?:
|
|
275
|
+
limit?: T;
|
|
276
276
|
}
|
|
277
277
|
|
|
278
278
|
export interface PurgeComponent extends PurgeBase {
|
package/lib/task.d.ts
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
export interface Command<T = unknown> extends PlainObject {
|
|
2
|
-
task: string;
|
|
3
|
-
origDir: string;
|
|
4
|
-
data: T;
|
|
5
|
-
}
|
|
6
|
-
|
|
7
|
-
export interface SpawnResult {
|
|
8
|
-
added?: string[];
|
|
9
|
-
deleted?: string[];
|
|
1
|
+
export interface Command<T = unknown> extends PlainObject {
|
|
2
|
+
task: string;
|
|
3
|
+
origDir: string;
|
|
4
|
+
data: T;
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
export interface SpawnResult {
|
|
8
|
+
added?: string[];
|
|
9
|
+
deleted?: string[];
|
|
10
10
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@e-mc/types",
|
|
3
|
-
"version": "0.12.
|
|
3
|
+
"version": "0.12.6",
|
|
4
4
|
"description": "Type definitions for E-mc.",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"types": "index.d.ts",
|
|
@@ -13,8 +13,7 @@
|
|
|
13
13
|
"directory": "src/types"
|
|
14
14
|
},
|
|
15
15
|
"keywords": [
|
|
16
|
-
"squared"
|
|
17
|
-
"squared-functions"
|
|
16
|
+
"squared"
|
|
18
17
|
],
|
|
19
18
|
"author": "An Pham <anpham6@gmail.com>",
|
|
20
19
|
"license": "BSD-3-Clause",
|