@e-mc/types 0.9.17 → 0.9.19

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/LICENSE CHANGED
@@ -1,11 +1,7 @@
1
- Copyright 2024 An Pham
1
+ Copyright 2025 An Pham
2
2
 
3
- Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
3
+ Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
4
4
 
5
- 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
5
+ The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
6
6
 
7
- 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
8
-
9
- 3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
10
-
11
- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
7
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
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.9.17/index.d.ts)
12
+ * [View Source](https://www.unpkg.com/@e-mc/types@0.9.19/index.d.ts)
13
13
 
14
14
  ```typescript
15
15
  import type { LogArguments } from "./lib/logger";
@@ -194,8 +194,8 @@ const IMPORT_MAP: Record<string, string | undefined>;
194
194
 
195
195
  ## References
196
196
 
197
- - https://www.unpkg.com/@e-mc/types@0.9.17/lib/logger.d.ts
198
- - https://www.unpkg.com/@e-mc/types@0.9.17/lib/module.d.ts
197
+ - https://www.unpkg.com/@e-mc/types@0.9.19/lib/logger.d.ts
198
+ - https://www.unpkg.com/@e-mc/types@0.9.19/lib/module.d.ts
199
199
 
200
200
  * https://nodejs.org/api/perf_hooks.html
201
201
  * 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.9.17',
2
+ VERSION = '0.9.19',
3
3
  TEMP_DIR = 'tmp',
4
4
  CJS = '__cjs__'
5
5
  }
package/index.js CHANGED
@@ -205,7 +205,6 @@ function getProperties(obj, inherited, nonenumerable, symbol) {
205
205
  }
206
206
  return symbol ? attrs.concat(Object.getOwnPropertySymbols(obj)) : attrs;
207
207
  }
208
- const convertScrypt = (key, iv, data) => crypto.scryptSync(key, iv, Math.ceil(data.length / 16) * 16);
209
208
  const isFunction = (value) => typeof value === 'function';
210
209
  var LOG_TYPE;
211
210
  (function (LOG_TYPE) {
@@ -680,7 +679,7 @@ function alignSize(value, kb = 0, factor = 0) {
680
679
  }
681
680
  if (kb > 0) {
682
681
  kb = Math.ceil(kb) * 1024;
683
- return Math.ceil(result / kb) * kb;
682
+ return Math.ceil(Math.max(result, 1) / kb) * kb;
684
683
  }
685
684
  return result;
686
685
  }
@@ -820,8 +819,10 @@ function coerceObject(data, parseString, cache) {
820
819
  const removeQuotes = (content) => content.trim().replace(/^["']/g, '').replace(/["']$/g, '').trim();
821
820
  const errorCreate = () => errorValue("Invalid parameters", match[2].trim());
822
821
  switch (match[1]) {
823
- case 'Date':
824
- return new Date(match[2].replace(/["']/g, '').trim());
822
+ case 'Date': {
823
+ const text = match[2].replace(/["']/g, '').trim();
824
+ return text ? new Date(text) : new Date();
825
+ }
825
826
  case 'URL':
826
827
  case 'RegExp': {
827
828
  const pattern = /^("[^"]+"|'[^']+'|[^\s,]+)(?:\s*,\s*("[^"]+"|'[^']+'|\S+))?$/.exec(match[2].trim());
@@ -945,23 +946,29 @@ function getEncoding(value, fallback = 'utf-8') {
945
946
  exports.getEncoding = getEncoding;
946
947
  function encryptUTF8(algorithm, key, iv, data, encoding = 'hex') {
947
948
  if (checkCipherType(algorithm) && isString(data)) {
949
+ let result;
948
950
  try {
949
- const gcm = crypto.createCipheriv(algorithm, convertScrypt(key, iv, data), iv);
950
- return gcm.update(data, 'utf-8', encoding) + gcm.final(encoding);
951
+ const gcm = crypto.createCipheriv(algorithm, crypto.scryptSync(key, iv, 32), iv);
952
+ result = gcm.update(data, 'utf8', encoding);
953
+ result += gcm.final(encoding);
951
954
  }
952
955
  catch {
953
956
  }
957
+ return result;
954
958
  }
955
959
  }
956
960
  exports.encryptUTF8 = encryptUTF8;
957
961
  function decryptUTF8(algorithm, key, iv, data, encoding = 'hex') {
958
962
  if (checkCipherType(algorithm) && isString(data)) {
963
+ let result;
959
964
  try {
960
- const gcm = crypto.createDecipheriv(algorithm, convertScrypt(key, iv, data), iv);
961
- return gcm.update(data, encoding, 'utf-8') + gcm.final('utf-8');
965
+ const gcm = crypto.createDecipheriv(algorithm, crypto.scryptSync(key, iv, 32), iv);
966
+ result = gcm.update(data, encoding, 'utf8');
967
+ result += gcm.final('utf8');
962
968
  }
963
969
  catch {
964
970
  }
971
+ return result;
965
972
  }
966
973
  }
967
974
  exports.decryptUTF8 = decryptUTF8;
package/lib/index.d.ts CHANGED
@@ -106,6 +106,7 @@ declare namespace functions {
106
106
  }
107
107
 
108
108
  interface ImageConstructor<T extends IHost = IHost, U extends ImageModule = ImageModule> extends ModuleConstructor {
109
+ /** @deprecated */
109
110
  readonly REGEXP_SIZERANGE: RegExp;
110
111
  transform<V extends TransformOptions>(file: string, command: string, options?: V): Promise<V extends { tempFile: true } ? string : Null<Buffer>>;
111
112
  clamp(value: unknown, min?: number, max?: number): number;
@@ -297,7 +298,7 @@ declare namespace functions {
297
298
  createServer(port: number, secure?: Null<SecureOptions>, active?: boolean): Null<ws.Server>;
298
299
  shutdown(): void;
299
300
  setTimeout(value: NumString): void;
300
- checkTimeout(client: ws): boolean;
301
+ checkTimeout(client: ws.WebSocket): boolean;
301
302
  readonly prototype: IWatch<T, U, V, W>;
302
303
  new(module?: V): IWatch<T, U, V, W>;
303
304
  new(interval?: number, port?: number, securePort?: number, extensions?: unknown[]): IWatch<T, U, V, W>;
package/lib/watch.d.ts CHANGED
@@ -58,8 +58,8 @@ export interface IFileGroup<T extends ExternalAsset = ExternalAsset> extends IAb
58
58
 
59
59
  export interface FileGroupConstructor<T extends ExternalAsset = ExternalAsset> {
60
60
  CONNECTION_TIMEOUT: number;
61
- CLIENT_SESSION: Map<ws, number>;
62
- checkTimeout(client: ws): boolean;
61
+ CLIENT_SESSION: Map<ws.WebSocket, number>;
62
+ checkTimeout(client: ws.WebSocket): boolean;
63
63
  cloneAsset(asset: T): T;
64
64
  readonly prototype: IFileGroup<T>;
65
65
  new(uri: string, assets: T[], abortable: boolean): IFileGroup<T>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@e-mc/types",
3
- "version": "0.9.17",
3
+ "version": "0.9.19",
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": "MIT",
21
21
  "homepage": "https://github.com/anpham6/e-mc#readme",
22
22
  "dependencies": {
23
23
  "bytes": "^3.1.2",