@e-mc/image 0.8.7 → 0.9.0

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,11 @@
1
- Copyright 2024 An Pham
2
-
3
- Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
4
-
5
- 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
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
-
1
+ Copyright 2024 An Pham
2
+
3
+ Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
4
+
5
+ 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
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
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.
package/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # @e-mc/image
2
2
 
3
- * NodeJS 14
3
+ * NodeJS 14/16
4
4
  * ES2020
5
5
 
6
6
  ## General Usage
@@ -9,7 +9,7 @@
9
9
 
10
10
  ## Interface
11
11
 
12
- - https://www.unpkg.com/@e-mc/types@0.8.7/lib/index.d.ts
12
+ * [View Source](https://www.unpkg.com/@e-mc/types@0.9.0/lib/index.d.ts)
13
13
 
14
14
  ```typescript
15
15
  import type { IHost, ModuleConstructor } from "./index";
@@ -39,22 +39,72 @@ interface IImage extends IClient<IHost, ImageModule> {
39
39
 
40
40
  interface ImageConstructor extends ModuleConstructor {
41
41
  readonly REGEXP_SIZERANGE: RegExp;
42
- transform(file: string, command: string, options?: TransformOptions): Promise<Buffer | string | null>;
42
+ transform(file: string, command: string, options: { tempFile: true }): Promise<string>;
43
+ transform(file: string, command: string, options?: TransformOptions): Promise<Buffer | null>;
43
44
  clamp(value: unknown, min?: number, max?: number): number;
44
45
  isBinary(mime: unknown): mime is string;
45
46
  toABGR(buffer: Uint8Array | Buffer): Buffer;
46
- /* @deprecated - IImage.using */
47
- using?(this: IHost, instance: IImage, data: IFileThread, command: string): Promise<unknown>;
48
47
  readonly prototype: IImage;
49
- new(module?: ImageModule): IImage;
48
+ new(module?: ImageModule, ...args: unknown[]): IImage;
50
49
  }
51
50
  ```
52
51
 
52
+ ## Settings
53
+
54
+ ```typescript
55
+ import type { PermittedDirectories } from "./core";
56
+
57
+ interface ImageModule {
58
+ // handler: "@pi-r/jimp";
59
+ webp?: string;
60
+ settings?: {
61
+ broadcast_id?: string | string[];
62
+ cache?: boolean;
63
+ jimp?: {
64
+ exec?: {
65
+ uid?: number;
66
+ gid?: number;
67
+ };
68
+ cache_expires?: number | string;
69
+ rotate_clockwise?: boolean;
70
+ };
71
+ webp?: {
72
+ path?: string;
73
+ cwebp?: string[];
74
+ gif2webp?: string[];
75
+ };
76
+ };
77
+ permission?: PermittedDirectories;
78
+ }
79
+ ```
80
+
81
+ ### Example usage
82
+
83
+ - [@pi-r/jimp](https://e-mc.readthedocs.io/en/latest/image/index.html)
84
+
85
+ NOTE: Usage without a **Host** is conducted through static methods. The **using** class method is called by the **Host** to perform the transformation.
86
+
87
+ ## NodeJS 14 LTS
88
+
89
+ Any optional fail safe dependencies were removed as of `E-mc 0.9`. The code itself will still be *ES2020* and will continue to work equivalently when self-installing these dependencies:
90
+
91
+ ### Under 15.4 + 16.0
92
+
93
+ ```sh
94
+ npm i abort-controller event-target-shim
95
+ ```
96
+
97
+ ### Under 14.17 + 15.6
98
+
99
+ ```sh
100
+ npm i uuid
101
+ ```
102
+
53
103
  ## References
54
104
 
55
- - https://www.unpkg.com/@e-mc/types@0.8.7/lib/asset.d.ts
56
- - https://www.unpkg.com/@e-mc/types@0.8.7/lib/image.d.ts
57
- - https://www.unpkg.com/@e-mc/types@0.8.7/lib/settings.d.ts
105
+ - https://www.unpkg.com/@e-mc/types@0.9.0/lib/asset.d.ts
106
+ - https://www.unpkg.com/@e-mc/types@0.9.0/lib/image.d.ts
107
+ - https://www.unpkg.com/@e-mc/types@0.9.0/lib/settings.d.ts
58
108
 
59
109
  ## LICENSE
60
110
 
package/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
- import type { ImageConstructor } from '../types/lib';
2
-
3
- declare const Image: ImageConstructor;
4
-
1
+ import type { ImageConstructor } from '../types/lib';
2
+
3
+ declare const Image: ImageConstructor;
4
+
5
5
  export = Image;
package/index.js CHANGED
@@ -1,6 +1,5 @@
1
1
  "use strict";
2
2
  var _a, _b;
3
- Object.defineProperty(exports, "__esModule", { value: true });
4
3
  const core_1 = require("@e-mc/core");
5
4
  const kCommand = Symbol('command');
6
5
  const kOutputAs = Symbol('outputAs');
@@ -332,9 +331,5 @@ class Image extends core_1.Client {
332
331
  }
333
332
  }
334
333
  _a = kCommand, _b = kOutputAs;
335
- exports.default = Image;
336
334
 
337
- if (exports.default) {
338
- module.exports = exports.default;
339
- module.exports.default = exports.default;
340
- }
335
+ module.exports = Image;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@e-mc/image",
3
- "version": "0.8.7",
3
+ "version": "0.9.0",
4
4
  "description": "Image constructor for E-mc.",
5
5
  "main": "index.js",
6
6
  "types": "index.d.ts",
@@ -20,6 +20,6 @@
20
20
  "license": "BSD 3-Clause",
21
21
  "homepage": "https://github.com/anpham6/e-mc#readme",
22
22
  "dependencies": {
23
- "@e-mc/core": "0.8.7"
23
+ "@e-mc/core": "0.9.0"
24
24
  }
25
25
  }
package/types/index.d.ts CHANGED
@@ -25,7 +25,7 @@ export interface WebpMuxFrame extends Dimension, Point {
25
25
  export interface WebpMuxImage extends Readonly<Dimension> {
26
26
  readonly anim: { loops: number; bgColor: [number, number, number, number] };
27
27
  initLib(): Promise<void>;
28
- load(value: BufferContent): Promise<void>;
28
+ load(value: Bufferable): Promise<void>;
29
29
  demux(options: { path?: string; prefix?: string; buffers?: boolean }): Promise<void>;
30
30
  getImageData(): Promise<Uint8Array>;
31
31
  getFrameData(frame: number): Promise<Uint8Array>;