@e-mc/image 0.8.17 → 0.8.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 +6 -6
- package/README.md +60 -60
- package/index.d.ts +4 -4
- package/index.js +3 -2
- package/package.json +25 -25
- package/types/index.d.ts +39 -39
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 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
|
+
|
|
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,61 +1,61 @@
|
|
|
1
|
-
# @e-mc/image
|
|
2
|
-
|
|
3
|
-
* NodeJS 14
|
|
4
|
-
* ES2019
|
|
5
|
-
|
|
6
|
-
## General Usage
|
|
7
|
-
|
|
8
|
-
* [Read the Docs](https://e-mc.readthedocs.io)
|
|
9
|
-
|
|
10
|
-
## Interface
|
|
11
|
-
|
|
12
|
-
- https://www.unpkg.com/@e-mc/types@0.8.
|
|
13
|
-
|
|
14
|
-
```typescript
|
|
15
|
-
import type { IHost, ModuleConstructor } from "./index";
|
|
16
|
-
import type { IFileThread } from "./asset";
|
|
17
|
-
import type { CommandData, CropData, QualityData, ResizeData, RotateData, TransformOptions } from "./image";
|
|
18
|
-
import type { ImageModule } from "./settings";
|
|
19
|
-
|
|
20
|
-
interface IImage extends IClient<IHost, ImageModule> {
|
|
21
|
-
resizeData?: ResizeData;
|
|
22
|
-
cropData?: CropData;
|
|
23
|
-
rotateData?: RotateData;
|
|
24
|
-
qualityData?: QualityData;
|
|
25
|
-
methodData?: [string, unknown[]?][];
|
|
26
|
-
opacityValue?: number;
|
|
27
|
-
setCommand(value: string | CommandData, outputAs?: string): void;
|
|
28
|
-
getCommand(): string;
|
|
29
|
-
parseCommand(value: string): CommandData;
|
|
30
|
-
parseMethod(value: string): [string, unknown[]?][] | undefined;
|
|
31
|
-
parseResize(value: string): ResizeData | undefined;
|
|
32
|
-
parseCrop(value: string): CropData | undefined;
|
|
33
|
-
parseRotate(value: string): RotateData | undefined;
|
|
34
|
-
parseQuality(value: string): QualityData | undefined;
|
|
35
|
-
parseOpacity(value: string): number;
|
|
36
|
-
using?(data: IFileThread, command: string): Promise<unknown>;
|
|
37
|
-
get outputAs(): string;
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
interface ImageConstructor extends ModuleConstructor {
|
|
41
|
-
readonly REGEXP_SIZERANGE: RegExp;
|
|
42
|
-
transform(file: string, command: string, options?: TransformOptions): Promise<Buffer | string | null>;
|
|
43
|
-
clamp(value: unknown, min?: number, max?: number): number;
|
|
44
|
-
isBinary(mime: unknown): mime is string;
|
|
45
|
-
toABGR(buffer: Uint8Array | Buffer): Buffer;
|
|
46
|
-
/* @deprecated - IImage.using */
|
|
47
|
-
using?(this: IHost, instance: IImage, data: IFileThread, command: string): Promise<unknown>;
|
|
48
|
-
readonly prototype: IImage;
|
|
49
|
-
new(module?: ImageModule): IImage;
|
|
50
|
-
}
|
|
51
|
-
```
|
|
52
|
-
|
|
53
|
-
## References
|
|
54
|
-
|
|
55
|
-
- https://www.unpkg.com/@e-mc/types@0.8.
|
|
56
|
-
- https://www.unpkg.com/@e-mc/types@0.8.
|
|
57
|
-
- https://www.unpkg.com/@e-mc/types@0.8.
|
|
58
|
-
|
|
59
|
-
## LICENSE
|
|
60
|
-
|
|
1
|
+
# @e-mc/image
|
|
2
|
+
|
|
3
|
+
* NodeJS 14
|
|
4
|
+
* ES2019
|
|
5
|
+
|
|
6
|
+
## General Usage
|
|
7
|
+
|
|
8
|
+
* [Read the Docs](https://e-mc.readthedocs.io)
|
|
9
|
+
|
|
10
|
+
## Interface
|
|
11
|
+
|
|
12
|
+
- https://www.unpkg.com/@e-mc/types@0.8.19/lib/index.d.ts
|
|
13
|
+
|
|
14
|
+
```typescript
|
|
15
|
+
import type { IHost, ModuleConstructor } from "./index";
|
|
16
|
+
import type { IFileThread } from "./asset";
|
|
17
|
+
import type { CommandData, CropData, QualityData, ResizeData, RotateData, TransformOptions } from "./image";
|
|
18
|
+
import type { ImageModule } from "./settings";
|
|
19
|
+
|
|
20
|
+
interface IImage extends IClient<IHost, ImageModule> {
|
|
21
|
+
resizeData?: ResizeData;
|
|
22
|
+
cropData?: CropData;
|
|
23
|
+
rotateData?: RotateData;
|
|
24
|
+
qualityData?: QualityData;
|
|
25
|
+
methodData?: [string, unknown[]?][];
|
|
26
|
+
opacityValue?: number;
|
|
27
|
+
setCommand(value: string | CommandData, outputAs?: string): void;
|
|
28
|
+
getCommand(): string;
|
|
29
|
+
parseCommand(value: string): CommandData;
|
|
30
|
+
parseMethod(value: string): [string, unknown[]?][] | undefined;
|
|
31
|
+
parseResize(value: string): ResizeData | undefined;
|
|
32
|
+
parseCrop(value: string): CropData | undefined;
|
|
33
|
+
parseRotate(value: string): RotateData | undefined;
|
|
34
|
+
parseQuality(value: string): QualityData | undefined;
|
|
35
|
+
parseOpacity(value: string): number;
|
|
36
|
+
using?(data: IFileThread, command: string): Promise<unknown>;
|
|
37
|
+
get outputAs(): string;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
interface ImageConstructor extends ModuleConstructor {
|
|
41
|
+
readonly REGEXP_SIZERANGE: RegExp;
|
|
42
|
+
transform(file: string, command: string, options?: TransformOptions): Promise<Buffer | string | null>;
|
|
43
|
+
clamp(value: unknown, min?: number, max?: number): number;
|
|
44
|
+
isBinary(mime: unknown): mime is string;
|
|
45
|
+
toABGR(buffer: Uint8Array | Buffer): Buffer;
|
|
46
|
+
/* @deprecated - IImage.using */
|
|
47
|
+
using?(this: IHost, instance: IImage, data: IFileThread, command: string): Promise<unknown>;
|
|
48
|
+
readonly prototype: IImage;
|
|
49
|
+
new(module?: ImageModule): IImage;
|
|
50
|
+
}
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
## References
|
|
54
|
+
|
|
55
|
+
- https://www.unpkg.com/@e-mc/types@0.8.19/lib/asset.d.ts
|
|
56
|
+
- https://www.unpkg.com/@e-mc/types@0.8.19/lib/image.d.ts
|
|
57
|
+
- https://www.unpkg.com/@e-mc/types@0.8.19/lib/settings.d.ts
|
|
58
|
+
|
|
59
|
+
## LICENSE
|
|
60
|
+
|
|
61
61
|
MIT
|
package/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type { ImageConstructor } from '
|
|
2
|
-
|
|
3
|
-
declare const Image: ImageConstructor;
|
|
4
|
-
|
|
1
|
+
import type { ImageConstructor } from '@e-mc/types/lib';
|
|
2
|
+
|
|
3
|
+
declare const Image: ImageConstructor;
|
|
4
|
+
|
|
5
5
|
export = Image;
|
package/index.js
CHANGED
|
@@ -27,11 +27,12 @@ class Image extends core_1.Client {
|
|
|
27
27
|
static clamp(value, min = 0, max = 1) {
|
|
28
28
|
switch (typeof value) {
|
|
29
29
|
case 'string':
|
|
30
|
-
if (!value) {
|
|
30
|
+
if (!value.trim()) {
|
|
31
31
|
break;
|
|
32
32
|
}
|
|
33
|
+
value = +value;
|
|
33
34
|
case 'number':
|
|
34
|
-
return Math.min(Math.max(min,
|
|
35
|
+
return Math.min(Math.max(min, value), max);
|
|
35
36
|
}
|
|
36
37
|
return NaN;
|
|
37
38
|
}
|
package/package.json
CHANGED
|
@@ -1,25 +1,25 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "@e-mc/image",
|
|
3
|
-
"version": "0.8.
|
|
4
|
-
"description": "Image constructor for E-mc.",
|
|
5
|
-
"main": "index.js",
|
|
6
|
-
"types": "index.d.ts",
|
|
7
|
-
"publishConfig": {
|
|
8
|
-
"access": "public"
|
|
9
|
-
},
|
|
10
|
-
"repository": {
|
|
11
|
-
"type": "git",
|
|
12
|
-
"url": "git+https://github.com/anpham6/e-mc.git",
|
|
13
|
-
"directory": "src/image"
|
|
14
|
-
},
|
|
15
|
-
"keywords": [
|
|
16
|
-
"squared",
|
|
17
|
-
"squared-functions"
|
|
18
|
-
],
|
|
19
|
-
"author": "An Pham <anpham6@gmail.com>",
|
|
20
|
-
"license": "MIT",
|
|
21
|
-
"homepage": "https://github.com/anpham6/e-mc#readme",
|
|
22
|
-
"dependencies": {
|
|
23
|
-
"@e-mc/core": "0.8.
|
|
24
|
-
}
|
|
25
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"name": "@e-mc/image",
|
|
3
|
+
"version": "0.8.19",
|
|
4
|
+
"description": "Image constructor for E-mc.",
|
|
5
|
+
"main": "index.js",
|
|
6
|
+
"types": "index.d.ts",
|
|
7
|
+
"publishConfig": {
|
|
8
|
+
"access": "public"
|
|
9
|
+
},
|
|
10
|
+
"repository": {
|
|
11
|
+
"type": "git",
|
|
12
|
+
"url": "git+https://github.com/anpham6/e-mc.git",
|
|
13
|
+
"directory": "src/image"
|
|
14
|
+
},
|
|
15
|
+
"keywords": [
|
|
16
|
+
"squared",
|
|
17
|
+
"squared-functions"
|
|
18
|
+
],
|
|
19
|
+
"author": "An Pham <anpham6@gmail.com>",
|
|
20
|
+
"license": "MIT",
|
|
21
|
+
"homepage": "https://github.com/anpham6/e-mc#readme",
|
|
22
|
+
"dependencies": {
|
|
23
|
+
"@e-mc/core": "0.8.19"
|
|
24
|
+
}
|
|
25
|
+
}
|
package/types/index.d.ts
CHANGED
|
@@ -1,40 +1,40 @@
|
|
|
1
|
-
/// <reference path="
|
|
2
|
-
|
|
3
|
-
export interface ImageHandler<T, U, V> {
|
|
4
|
-
readonly handler: T;
|
|
5
|
-
host: U | null;
|
|
6
|
-
instance: V;
|
|
7
|
-
method(): void;
|
|
8
|
-
resize(): void;
|
|
9
|
-
crop(): void;
|
|
10
|
-
opacity(): void;
|
|
11
|
-
quality(): void;
|
|
12
|
-
rotate(...args: unknown[]): unknown;
|
|
13
|
-
background?(value: unknown): void;
|
|
14
|
-
write(output: string, callback?: (err: unknown, result: string) => void): void;
|
|
15
|
-
getBuffer(tempFile?: boolean, saveAs?: string): Promise<string | Buffer | null>;
|
|
16
|
-
finalize(output: string, callback: (err: unknown, result: string) => void): void;
|
|
17
|
-
get rotateCount(): number;
|
|
18
|
-
get aborted(): boolean;
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
export interface WebpMuxFrame extends Dimension, Point {
|
|
22
|
-
delay: number;
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
export interface WebpMuxImage extends Readonly<Dimension> {
|
|
26
|
-
readonly anim: { loops: number; bgColor: [number, number, number, number] };
|
|
27
|
-
initLib(): Promise<void>;
|
|
28
|
-
load(value: BufferContent): Promise<void>;
|
|
29
|
-
demux(options: { path?: string; prefix?: string; buffers?: boolean }): Promise<void>;
|
|
30
|
-
getImageData(): Promise<Uint8Array>;
|
|
31
|
-
getFrameData(frame: number): Promise<Uint8Array>;
|
|
32
|
-
setFrameData(frame: number, source: Buffer, options: Dimension & { preset?: string; quality?: number; exact?: boolean; lossless?: number; method?: number }): Promise<void>;
|
|
33
|
-
save(path: string, options: Dimension & { bgColor?: number[] }): Promise<void>;
|
|
34
|
-
get hasAnim(): boolean;
|
|
35
|
-
get frames(): WebpMuxFrame[];
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
export interface WebpMux {
|
|
39
|
-
Image: new() => WebpMuxImage;
|
|
1
|
+
/// <reference path="@e-mc/types/index.d.ts" />
|
|
2
|
+
|
|
3
|
+
export interface ImageHandler<T, U, V> {
|
|
4
|
+
readonly handler: T;
|
|
5
|
+
host: U | null;
|
|
6
|
+
instance: V;
|
|
7
|
+
method(): void;
|
|
8
|
+
resize(): void;
|
|
9
|
+
crop(): void;
|
|
10
|
+
opacity(): void;
|
|
11
|
+
quality(): void;
|
|
12
|
+
rotate(...args: unknown[]): unknown;
|
|
13
|
+
background?(value: unknown): void;
|
|
14
|
+
write(output: string, callback?: (err: unknown, result: string) => void): void;
|
|
15
|
+
getBuffer(tempFile?: boolean, saveAs?: string): Promise<string | Buffer | null>;
|
|
16
|
+
finalize(output: string, callback: (err: unknown, result: string) => void): void;
|
|
17
|
+
get rotateCount(): number;
|
|
18
|
+
get aborted(): boolean;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export interface WebpMuxFrame extends Dimension, Point {
|
|
22
|
+
delay: number;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
export interface WebpMuxImage extends Readonly<Dimension> {
|
|
26
|
+
readonly anim: { loops: number; bgColor: [number, number, number, number] };
|
|
27
|
+
initLib(): Promise<void>;
|
|
28
|
+
load(value: BufferContent): Promise<void>;
|
|
29
|
+
demux(options: { path?: string; prefix?: string; buffers?: boolean }): Promise<void>;
|
|
30
|
+
getImageData(): Promise<Uint8Array>;
|
|
31
|
+
getFrameData(frame: number): Promise<Uint8Array>;
|
|
32
|
+
setFrameData(frame: number, source: Buffer, options: Dimension & { preset?: string; quality?: number; exact?: boolean; lossless?: number; method?: number }): Promise<void>;
|
|
33
|
+
save(path: string, options: Dimension & { bgColor?: number[] }): Promise<void>;
|
|
34
|
+
get hasAnim(): boolean;
|
|
35
|
+
get frames(): WebpMuxFrame[];
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
export interface WebpMux {
|
|
39
|
+
Image: new() => WebpMuxImage;
|
|
40
40
|
}
|