@e-mc/image 0.8.10 → 0.9.1

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,7 +1,11 @@
1
1
  Copyright 2024 An Pham
2
2
 
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:
3
+ Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
4
4
 
5
- The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
5
+ 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
6
6
 
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.
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.
package/README.md CHANGED
@@ -1,7 +1,7 @@
1
1
  # @e-mc/image
2
2
 
3
- * NodeJS 14
4
- * ES2019
3
+ * NodeJS 16
4
+ * ES2020
5
5
 
6
6
  ## General Usage
7
7
 
@@ -9,7 +9,7 @@
9
9
 
10
10
  ## Interface
11
11
 
12
- - https://www.unpkg.com/@e-mc/types@0.8.10/lib/index.d.ts
12
+ * [View Source](https://www.unpkg.com/@e-mc/types@0.9.1/lib/index.d.ts)
13
13
 
14
14
  ```typescript
15
15
  import type { IHost, ModuleConstructor } from "./index";
@@ -39,23 +39,57 @@ 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
+
53
87
  ## References
54
88
 
55
- - https://www.unpkg.com/@e-mc/types@0.8.10/lib/asset.d.ts
56
- - https://www.unpkg.com/@e-mc/types@0.8.10/lib/image.d.ts
57
- - https://www.unpkg.com/@e-mc/types@0.8.10/lib/settings.d.ts
89
+ - https://www.unpkg.com/@e-mc/types@0.9.1/lib/asset.d.ts
90
+ - https://www.unpkg.com/@e-mc/types@0.9.1/lib/image.d.ts
91
+ - https://www.unpkg.com/@e-mc/types@0.9.1/lib/settings.d.ts
58
92
 
59
93
  ## LICENSE
60
94
 
61
- MIT
95
+ BSD 3-Clause
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');
@@ -22,7 +21,7 @@ class Image extends core_1.Client {
22
21
  }
23
22
  static get REGEXP_SIZERANGE() { return REGEXP_SIZERANGE; }
24
23
  static async transform(file, command, options) {
25
- return (options === null || options === void 0 ? void 0 : options.tempFile) ? '' : null;
24
+ return options?.tempFile ? '' : null;
26
25
  }
27
26
  static clamp(value, min = 0, max = 1) {
28
27
  switch (typeof value) {
@@ -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.10",
3
+ "version": "0.9.1",
4
4
  "description": "Image constructor for E-mc.",
5
5
  "main": "index.js",
6
6
  "types": "index.d.ts",
@@ -17,9 +17,9 @@
17
17
  "squared-functions"
18
18
  ],
19
19
  "author": "An Pham <anpham6@gmail.com>",
20
- "license": "MIT",
20
+ "license": "BSD 3-Clause",
21
21
  "homepage": "https://github.com/anpham6/e-mc#readme",
22
22
  "dependencies": {
23
- "@e-mc/core": "0.8.10"
23
+ "@e-mc/core": "0.9.1"
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>;