@e-mc/image 0.8.5 → 0.8.7
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 +8 -4
- package/README.md +56 -2
- package/index.js +12 -12
- package/package.json +3 -3
package/LICENSE
CHANGED
|
@@ -1,7 +1,11 @@
|
|
|
1
|
-
Copyright 2024
|
|
1
|
+
Copyright 2024 An Pham
|
|
2
2
|
|
|
3
|
-
|
|
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
|
-
|
|
5
|
+
1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
|
|
6
6
|
|
|
7
|
-
|
|
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,61 @@
|
|
|
1
1
|
# @e-mc/image
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
* NodeJS 14
|
|
4
|
+
* ES2020
|
|
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.7/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.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
|
|
4
58
|
|
|
5
59
|
## LICENSE
|
|
6
60
|
|
|
7
|
-
|
|
61
|
+
BSD 3-Clause
|
package/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
var _a, _b;
|
|
3
3
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
-
const core_1 = require("
|
|
4
|
+
const core_1 = require("@e-mc/core");
|
|
5
5
|
const kCommand = Symbol('command');
|
|
6
6
|
const kOutputAs = Symbol('outputAs');
|
|
7
7
|
const REGEXP_CROP = /\(\s*([+-]?\d+)\s*,\s*([+-]?\d+)\s*\|\s*(\d+)\s*[xX]\s*(\d+)\s*\)/;
|
|
@@ -170,26 +170,26 @@ class Image extends core_1.Client {
|
|
|
170
170
|
case "'":
|
|
171
171
|
case '"':
|
|
172
172
|
if (type === 0) {
|
|
173
|
-
type = 3
|
|
173
|
+
type = 3;
|
|
174
174
|
stringType = ch;
|
|
175
175
|
continue;
|
|
176
176
|
}
|
|
177
|
-
else if (type === 3
|
|
177
|
+
else if (type === 3 && ch === stringType && !isEscaped(false)) {
|
|
178
178
|
addArg(current);
|
|
179
179
|
continue;
|
|
180
180
|
}
|
|
181
181
|
break;
|
|
182
182
|
case '[':
|
|
183
183
|
if (type === 0) {
|
|
184
|
-
type = 1
|
|
184
|
+
type = 1;
|
|
185
185
|
arrayCount = 1;
|
|
186
186
|
}
|
|
187
|
-
else if (type === 1
|
|
187
|
+
else if (type === 1 && !isEscaped()) {
|
|
188
188
|
++arrayCount;
|
|
189
189
|
}
|
|
190
190
|
break;
|
|
191
191
|
case ']':
|
|
192
|
-
if (type === 1
|
|
192
|
+
if (type === 1 && !isEscaped() && --arrayCount === 0) {
|
|
193
193
|
try {
|
|
194
194
|
addArg(JSON.parse(current + ']'));
|
|
195
195
|
continue;
|
|
@@ -201,15 +201,15 @@ class Image extends core_1.Client {
|
|
|
201
201
|
break;
|
|
202
202
|
case '{':
|
|
203
203
|
if (type === 0) {
|
|
204
|
-
type = 2
|
|
204
|
+
type = 2;
|
|
205
205
|
objectCount = 1;
|
|
206
206
|
}
|
|
207
|
-
else if (type === 2
|
|
207
|
+
else if (type === 2 && !isEscaped()) {
|
|
208
208
|
++objectCount;
|
|
209
209
|
}
|
|
210
210
|
break;
|
|
211
211
|
case '}':
|
|
212
|
-
if (type === 2
|
|
212
|
+
if (type === 2 && !isEscaped() && --objectCount === 0) {
|
|
213
213
|
try {
|
|
214
214
|
addArg(JSON.parse(current + '}'));
|
|
215
215
|
continue;
|
|
@@ -273,14 +273,14 @@ class Image extends core_1.Client {
|
|
|
273
273
|
case '-':
|
|
274
274
|
case '+':
|
|
275
275
|
if (isNumber(value[i + 1])) {
|
|
276
|
-
type = 4
|
|
276
|
+
type = 4;
|
|
277
277
|
current += ch;
|
|
278
278
|
continue;
|
|
279
279
|
}
|
|
280
280
|
break invalid;
|
|
281
281
|
default:
|
|
282
282
|
if (isNumber(ch)) {
|
|
283
|
-
type = 4
|
|
283
|
+
type = 4;
|
|
284
284
|
current += ch;
|
|
285
285
|
continue;
|
|
286
286
|
}
|
|
@@ -291,7 +291,7 @@ class Image extends core_1.Client {
|
|
|
291
291
|
break invalid;
|
|
292
292
|
}
|
|
293
293
|
else {
|
|
294
|
-
if (type === 4
|
|
294
|
+
if (type === 4 && !(ch === '.' && decimal++ === 0)) {
|
|
295
295
|
if (isSpace || ch === ',' || ch === ')') {
|
|
296
296
|
addArg(+current);
|
|
297
297
|
switch (ch) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@e-mc/image",
|
|
3
|
-
"version": "0.8.
|
|
3
|
+
"version": "0.8.7",
|
|
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": "
|
|
20
|
+
"license": "BSD 3-Clause",
|
|
21
21
|
"homepage": "https://github.com/anpham6/e-mc#readme",
|
|
22
22
|
"dependencies": {
|
|
23
|
-
"@e-mc/core": "0.8.
|
|
23
|
+
"@e-mc/core": "0.8.7"
|
|
24
24
|
}
|
|
25
25
|
}
|