@e-mc/image 0.10.6 → 0.11.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 +1 -1
- package/README.md +7 -7
- package/index.js +23 -10
- package/package.json +2 -2
- package/types/index.d.ts +1 -9
package/LICENSE
CHANGED
|
@@ -8,4 +8,4 @@ Redistribution and use in source and binary forms, with or without modification,
|
|
|
8
8
|
|
|
9
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
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.
|
|
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 16
|
|
4
|
-
*
|
|
3
|
+
* NodeJS 16 LTS
|
|
4
|
+
* ES2021
|
|
5
5
|
|
|
6
6
|
## General Usage
|
|
7
7
|
|
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
|
|
10
10
|
## Interface
|
|
11
11
|
|
|
12
|
-
* [View Source](https://www.unpkg.com/@e-mc/types@0.
|
|
12
|
+
* [View Source](https://www.unpkg.com/@e-mc/types@0.11.1/lib/index.d.ts)
|
|
13
13
|
|
|
14
14
|
```typescript
|
|
15
15
|
import type { IHost, ModuleConstructor } from "./index";
|
|
@@ -87,10 +87,10 @@ NOTE: Usage without a **Host** is conducted through static methods. The **using*
|
|
|
87
87
|
|
|
88
88
|
## References
|
|
89
89
|
|
|
90
|
-
- https://www.unpkg.com/@e-mc/types@0.
|
|
91
|
-
- https://www.unpkg.com/@e-mc/types@0.
|
|
92
|
-
- https://www.unpkg.com/@e-mc/types@0.
|
|
90
|
+
- https://www.unpkg.com/@e-mc/types@0.11.1/lib/asset.d.ts
|
|
91
|
+
- https://www.unpkg.com/@e-mc/types@0.11.1/lib/image.d.ts
|
|
92
|
+
- https://www.unpkg.com/@e-mc/types@0.11.1/lib/settings.d.ts
|
|
93
93
|
|
|
94
94
|
## LICENSE
|
|
95
95
|
|
|
96
|
-
BSD 3-Clause
|
|
96
|
+
BSD 3-Clause
|
package/index.js
CHANGED
|
@@ -29,7 +29,6 @@ const parseHexDecimal = (value) => value ? +('0x' + value.toUpperCase().padEnd(8
|
|
|
29
29
|
class Image extends core_1.Client {
|
|
30
30
|
constructor() {
|
|
31
31
|
super(...arguments);
|
|
32
|
-
this.opacityValue = NaN;
|
|
33
32
|
this[_a] = '';
|
|
34
33
|
this[_b] = '';
|
|
35
34
|
}
|
|
@@ -66,12 +65,24 @@ class Image extends core_1.Client {
|
|
|
66
65
|
}
|
|
67
66
|
reset() {
|
|
68
67
|
super.reset();
|
|
69
|
-
this
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
this
|
|
73
|
-
|
|
74
|
-
|
|
68
|
+
if (Object.hasOwn(this, 'resizeData')) {
|
|
69
|
+
this.resizeData = null;
|
|
70
|
+
}
|
|
71
|
+
if (Object.hasOwn(this, 'cropData')) {
|
|
72
|
+
this.cropData = null;
|
|
73
|
+
}
|
|
74
|
+
if (Object.hasOwn(this, 'rotateData')) {
|
|
75
|
+
this.rotateData = null;
|
|
76
|
+
}
|
|
77
|
+
if (Object.hasOwn(this, 'qualityData')) {
|
|
78
|
+
this.qualityData = null;
|
|
79
|
+
}
|
|
80
|
+
if (Object.hasOwn(this, 'methodData')) {
|
|
81
|
+
this.methodData = null;
|
|
82
|
+
}
|
|
83
|
+
if (Object.hasOwn(this, 'opacityValue')) {
|
|
84
|
+
this.opacityValue = NaN;
|
|
85
|
+
}
|
|
75
86
|
this[kCommand] = '';
|
|
76
87
|
this[kOutputAs] = '';
|
|
77
88
|
}
|
|
@@ -114,6 +125,7 @@ class Image extends core_1.Client {
|
|
|
114
125
|
if (match) {
|
|
115
126
|
return { x: +match[1], y: +match[2], width: +match[3], height: +match[4] };
|
|
116
127
|
}
|
|
128
|
+
return null;
|
|
117
129
|
}
|
|
118
130
|
parseOpacity(value) {
|
|
119
131
|
const match = REGEXP_OPACITY.exec(value);
|
|
@@ -124,12 +136,14 @@ class Image extends core_1.Client {
|
|
|
124
136
|
if (match) {
|
|
125
137
|
return { value: match[1] ? Image.clamp(match[1], 0, 100) : NaN, preset: match[2], nearLossless: match[3] ? Image.clamp(match[3], 0, 100) : NaN, method: match[4] ? Image.clamp(match[4], 0, 6) : NaN };
|
|
126
138
|
}
|
|
139
|
+
return null;
|
|
127
140
|
}
|
|
128
141
|
parseResize(value) {
|
|
129
142
|
const match = REGEXP_RESIZE.exec(value.toLowerCase());
|
|
130
143
|
if (match) {
|
|
131
144
|
return { width: match[1] === 'auto' ? Infinity : +match[1], height: match[2] === 'auto' ? Infinity : +match[2], mode: match[4] || 'resize', algorithm: match[3], align: [match[5], match[6]], color: parseHexDecimal(match[7]) };
|
|
132
145
|
}
|
|
146
|
+
return null;
|
|
133
147
|
}
|
|
134
148
|
parseRotate(value) {
|
|
135
149
|
const match = REGEXP_ROTATE.exec(value);
|
|
@@ -145,6 +159,7 @@ class Image extends core_1.Client {
|
|
|
145
159
|
return { values: Array.from(result), color: parseHexDecimal(match[2]) };
|
|
146
160
|
}
|
|
147
161
|
}
|
|
162
|
+
return null;
|
|
148
163
|
}
|
|
149
164
|
parseMethod(value) {
|
|
150
165
|
const result = [];
|
|
@@ -320,9 +335,7 @@ class Image extends core_1.Client {
|
|
|
320
335
|
REGEXP_METHOD.lastIndex = i;
|
|
321
336
|
}
|
|
322
337
|
REGEXP_METHOD.lastIndex = 0;
|
|
323
|
-
|
|
324
|
-
return result;
|
|
325
|
-
}
|
|
338
|
+
return result.length > 0 ? result : null;
|
|
326
339
|
}
|
|
327
340
|
get outputAs() {
|
|
328
341
|
return this[kOutputAs];
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@e-mc/image",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.11.1",
|
|
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.
|
|
23
|
+
"@e-mc/core": "0.11.1"
|
|
24
24
|
}
|
|
25
25
|
}
|
package/types/index.d.ts
CHANGED
|
@@ -1,12 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
x: number;
|
|
3
|
-
y: number;
|
|
4
|
-
}
|
|
5
|
-
|
|
6
|
-
export interface Dimension {
|
|
7
|
-
width: number;
|
|
8
|
-
height: number;
|
|
9
|
-
}
|
|
1
|
+
import type { Dimension, Point } from '@e-mc/types/lib/image';
|
|
10
2
|
|
|
11
3
|
export interface ImageHandler<T, U, V, W = void> {
|
|
12
4
|
readonly handler: T;
|