@pi-r/jimp 0.6.8 → 0.6.9

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,7 @@
1
- Copyright 2024 An Pham
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:
4
-
5
- The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
6
-
1
+ Copyright 2023 An Pham
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:
4
+
5
+ The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
6
+
7
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
@@ -1,10 +1,10 @@
1
- # @pi-r/jimp
2
-
3
- ## Documentation
4
-
5
- - [E-mc](https://e-mc.readthedocs.io/en/latest/image/index.html)
6
- - [squared](https://squared.readthedocs.io)
7
-
8
- ## LICENSE
9
-
1
+ # @pi-r/jimp
2
+
3
+ ## Documentation
4
+
5
+ - [E-mc](https://e-mc.readthedocs.io/en/latest/image/index.html)
6
+ - [squared](https://squared.readthedocs.io)
7
+
8
+ ## LICENSE
9
+
10
10
  MIT
package/index.js CHANGED
@@ -67,17 +67,17 @@ const METHOD_ALIAS = {
67
67
  threshold: 'th'
68
68
  };
69
69
  function getMethodName(value) {
70
- const name = value.toLowerCase();
71
- if (METHOD_ALIAS[name]) {
72
- return name;
73
- }
74
- if (name.length === 2) {
70
+ if (value.length === 2) {
71
+ value = value.toLowerCase();
75
72
  for (const alias in METHOD_ALIAS) {
76
- if (METHOD_ALIAS[alias] === name) {
73
+ if (METHOD_ALIAS[alias] === value) {
77
74
  return alias;
78
75
  }
79
76
  }
80
77
  }
78
+ else if (METHOD_ALIAS[value] || METHOD_ALIAS[value = value.toLowerCase()]) {
79
+ return value;
80
+ }
81
81
  }
82
82
  async function performCommand(host, instance, localUri, command, outputType, finalAs, buffer, parent) {
83
83
  return jimp.read((buffer || localUri))
@@ -121,9 +121,9 @@ async function transformCommand(localFile, handler, command, outputType, outputA
121
121
  default:
122
122
  return handler.rotate(localFile, (err, result) => {
123
123
  var _a;
124
- if (!err && ((_a = handler.host) === null || _a === void 0 ? void 0 : _a.moduleName) === 'filemanager') {
124
+ if (!err) {
125
125
  try {
126
- handler.host.add(result, parent);
126
+ (_a = handler.host) === null || _a === void 0 ? void 0 : _a.add(result, parent);
127
127
  }
128
128
  catch {
129
129
  }
package/package.json CHANGED
@@ -1,29 +1,29 @@
1
- {
2
- "name": "@pi-r/jimp",
3
- "version": "0.6.8",
4
- "description": "Jimp image constructor for E-mc.",
5
- "main": "index.js",
6
- "publishConfig": {
7
- "access": "public"
8
- },
9
- "repository": {
10
- "type": "git",
11
- "url": "git+https://github.com/anpham6/pi-r.git",
12
- "directory": "src/module/jimp"
13
- },
14
- "keywords": [
15
- "squared",
16
- "e-mc",
17
- "squared-functions"
18
- ],
19
- "author": "An Pham <anpham6@gmail.com>",
20
- "license": "MIT",
21
- "homepage": "https://github.com/anpham6/pi-r#readme",
22
- "dependencies": {
23
- "@e-mc/image": "^0.8.14",
24
- "@e-mc/types": "^0.8.14",
25
- "bmp-js": "^0.1.0",
26
- "gifwrap": "^0.10.1",
27
- "jimp": "^0.22.12"
28
- }
29
- }
1
+ {
2
+ "name": "@pi-r/jimp",
3
+ "version": "0.6.9",
4
+ "description": "Jimp image constructor for E-mc.",
5
+ "main": "index.js",
6
+ "publishConfig": {
7
+ "access": "public"
8
+ },
9
+ "repository": {
10
+ "type": "git",
11
+ "url": "git+https://github.com/anpham6/pi-r.git",
12
+ "directory": "src/module/jimp"
13
+ },
14
+ "keywords": [
15
+ "squared",
16
+ "e-mc",
17
+ "squared-functions"
18
+ ],
19
+ "author": "An Pham <anpham6@gmail.com>",
20
+ "license": "MIT",
21
+ "homepage": "https://github.com/anpham6/pi-r#readme",
22
+ "dependencies": {
23
+ "@e-mc/image": "^0.8.24",
24
+ "@e-mc/types": "^0.8.24",
25
+ "bmp-js": "^0.1.0",
26
+ "gifwrap": "^0.10.1",
27
+ "jimp": "^0.22.12"
28
+ }
29
+ }
package/types/index.d.ts CHANGED
@@ -1,19 +1,19 @@
1
- import type { IHost, IImage, ImageConstructor } from '@e-mc/types/lib';
2
- import type { ImageModule } from '@e-mc/types/lib/settings';
3
-
4
- import type { ImageHandler } from '@e-mc/image/types';
5
-
6
- import type * as jimp from 'jimp';
7
-
8
- export interface IJimpHandler<T extends IHost = IHost, U extends ImageModule = ImageModule> extends ImageHandler<jimp, T, IImage<T, U>> {
9
- method(): Promise<void>;
10
- rotate(localFile?: string, callback?: ResultCallback<string>): Promise<this>;
11
- background(value: number | [number, number, number, number]): void;
12
- writeAsync(output: string, callback?: ResultCallback): Promise<void>;
13
- }
14
-
15
- export interface JimpImageConstructor extends ImageConstructor {
16
- new(handler: jimp, instance: IImage, host?: Null<IHost>): IJimpHandler;
17
- }
18
-
1
+ import type { IHost, IImage, ImageConstructor } from '@e-mc/types/lib';
2
+ import type { ImageModule } from '@e-mc/types/lib/settings';
3
+
4
+ import type { ImageHandler } from '@e-mc/image/types';
5
+
6
+ import type * as jimp from 'jimp';
7
+
8
+ export interface IJimpHandler<T extends IHost = IHost, U extends ImageModule = ImageModule> extends ImageHandler<jimp, T, IImage<T, U>> {
9
+ method(): Promise<void>;
10
+ rotate(localFile?: string, callback?: ResultCallback<string>): Promise<this>;
11
+ background(value: number | [number, number, number, number]): void;
12
+ writeAsync(output: string, callback?: ResultCallback): Promise<void>;
13
+ }
14
+
15
+ export interface JimpImageConstructor extends ImageConstructor {
16
+ new(handler: jimp, instance: IImage, host?: Null<IHost>): IJimpHandler;
17
+ }
18
+
19
19
  export type ResultCallback<T = unknown, U = void, V = unknown> = (err: V, result: T) => U;
package/util.d.ts CHANGED
@@ -1,10 +1,10 @@
1
- declare namespace util {
2
- function parseFormat(command: string, mimeType?: string, gif?: boolean): [string, string, string];
3
- function renameExt(output: string, ext: string, replace?: boolean): string;
4
- function normalizePath(value: string): string;
5
- function getWebP_bin(name: string, pathname: string | undefined): string;
6
- function showInputType(value: string | undefined, outputType: string, finalAs: string): string;
7
- function showOutputType(value: string | undefined, outputType: string, finalAs: string): string;
8
- }
9
-
1
+ declare namespace util {
2
+ function parseFormat(command: string, mimeType?: string, gif?: boolean): [string, string, string];
3
+ function renameExt(output: string, ext: string, replace?: boolean): string;
4
+ function normalizePath(value: string): string;
5
+ function getWebP_bin(name: string, pathname: string | undefined): string;
6
+ function showInputType(value: string | undefined, outputType: string, finalAs: string): string;
7
+ function showOutputType(value: string | undefined, outputType: string, finalAs: string): string;
8
+ }
9
+
10
10
  export = util;