@twin.org/image 0.0.2-next.20 → 0.0.2-next.21
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/dist/cjs/index.cjs +13 -15
- package/dist/esm/index.mjs +13 -15
- package/dist/types/color.d.ts +4 -0
- package/dist/types/encoders/jpegEncoder.d.ts +4 -0
- package/docs/changelog.md +19 -0
- package/docs/reference/classes/Color.md +8 -0
- package/docs/reference/classes/JpegEncoder.md +8 -0
- package/locales/en.json +4 -0
- package/package.json +8 -4
package/dist/cjs/index.cjs
CHANGED
|
@@ -11,9 +11,8 @@ var core = require('@twin.org/core');
|
|
|
11
11
|
class Color {
|
|
12
12
|
/**
|
|
13
13
|
* Runtime name for the class.
|
|
14
|
-
* @internal
|
|
15
14
|
*/
|
|
16
|
-
static
|
|
15
|
+
static CLASS_NAME = "Color";
|
|
17
16
|
/**
|
|
18
17
|
* @internal
|
|
19
18
|
*/
|
|
@@ -38,30 +37,30 @@ class Color {
|
|
|
38
37
|
* @param blue The blue element of the color.
|
|
39
38
|
*/
|
|
40
39
|
constructor(alpha, red, green, blue) {
|
|
41
|
-
core.Guards.number(Color.
|
|
42
|
-
core.Guards.number(Color.
|
|
43
|
-
core.Guards.number(Color.
|
|
44
|
-
core.Guards.number(Color.
|
|
40
|
+
core.Guards.number(Color.CLASS_NAME, "alpha", alpha);
|
|
41
|
+
core.Guards.number(Color.CLASS_NAME, "red", red);
|
|
42
|
+
core.Guards.number(Color.CLASS_NAME, "green", green);
|
|
43
|
+
core.Guards.number(Color.CLASS_NAME, "blue", blue);
|
|
45
44
|
if (alpha < 0 || alpha > 255) {
|
|
46
|
-
throw new core.GeneralError(Color.
|
|
45
|
+
throw new core.GeneralError(Color.CLASS_NAME, "range", {
|
|
47
46
|
prop: "alpha",
|
|
48
47
|
value: alpha
|
|
49
48
|
});
|
|
50
49
|
}
|
|
51
50
|
if (red < 0 || red > 255) {
|
|
52
|
-
throw new core.GeneralError(Color.
|
|
51
|
+
throw new core.GeneralError(Color.CLASS_NAME, "range", {
|
|
53
52
|
prop: "red",
|
|
54
53
|
value: red
|
|
55
54
|
});
|
|
56
55
|
}
|
|
57
56
|
if (green < 0 || green > 255) {
|
|
58
|
-
throw new core.GeneralError(Color.
|
|
57
|
+
throw new core.GeneralError(Color.CLASS_NAME, "range", {
|
|
59
58
|
prop: "green",
|
|
60
59
|
value: green
|
|
61
60
|
});
|
|
62
61
|
}
|
|
63
62
|
if (blue < 0 || blue > 255) {
|
|
64
|
-
throw new core.GeneralError(Color.
|
|
63
|
+
throw new core.GeneralError(Color.CLASS_NAME, "range", {
|
|
65
64
|
prop: "blue",
|
|
66
65
|
value: blue
|
|
67
66
|
});
|
|
@@ -78,7 +77,7 @@ class Color {
|
|
|
78
77
|
* @throws Error if the format is incorrect.
|
|
79
78
|
*/
|
|
80
79
|
static fromHex(hex) {
|
|
81
|
-
core.Guards.stringValue(Color.
|
|
80
|
+
core.Guards.stringValue(Color.CLASS_NAME, "hex", hex);
|
|
82
81
|
let alpha;
|
|
83
82
|
let red;
|
|
84
83
|
let green;
|
|
@@ -112,7 +111,7 @@ class Color {
|
|
|
112
111
|
blue = hex.slice(7, 9);
|
|
113
112
|
}
|
|
114
113
|
else {
|
|
115
|
-
throw new core.GeneralError(Color.
|
|
114
|
+
throw new core.GeneralError(Color.CLASS_NAME, "hex", { hex });
|
|
116
115
|
}
|
|
117
116
|
return new Color(Number.parseInt(alpha, 16), Number.parseInt(red, 16), Number.parseInt(green, 16), Number.parseInt(blue, 16));
|
|
118
117
|
}
|
|
@@ -226,9 +225,8 @@ class Color {
|
|
|
226
225
|
class JpegEncoder {
|
|
227
226
|
/**
|
|
228
227
|
* Runtime name for the class.
|
|
229
|
-
* @internal
|
|
230
228
|
*/
|
|
231
|
-
static
|
|
229
|
+
static CLASS_NAME = "JpegEncoder";
|
|
232
230
|
/**
|
|
233
231
|
* @internal
|
|
234
232
|
*/
|
|
@@ -510,7 +508,7 @@ class JpegEncoder {
|
|
|
510
508
|
*/
|
|
511
509
|
setQuality(quality) {
|
|
512
510
|
if (quality <= 0 || quality > 100) {
|
|
513
|
-
throw new core.GeneralError(JpegEncoder.
|
|
511
|
+
throw new core.GeneralError(JpegEncoder.CLASS_NAME, "invalidQuality", { value: quality });
|
|
514
512
|
}
|
|
515
513
|
let sf = 0;
|
|
516
514
|
if (quality < 50) {
|
package/dist/esm/index.mjs
CHANGED
|
@@ -9,9 +9,8 @@ import { Guards, GeneralError, Is, Compression } from '@twin.org/core';
|
|
|
9
9
|
class Color {
|
|
10
10
|
/**
|
|
11
11
|
* Runtime name for the class.
|
|
12
|
-
* @internal
|
|
13
12
|
*/
|
|
14
|
-
static
|
|
13
|
+
static CLASS_NAME = "Color";
|
|
15
14
|
/**
|
|
16
15
|
* @internal
|
|
17
16
|
*/
|
|
@@ -36,30 +35,30 @@ class Color {
|
|
|
36
35
|
* @param blue The blue element of the color.
|
|
37
36
|
*/
|
|
38
37
|
constructor(alpha, red, green, blue) {
|
|
39
|
-
Guards.number(Color.
|
|
40
|
-
Guards.number(Color.
|
|
41
|
-
Guards.number(Color.
|
|
42
|
-
Guards.number(Color.
|
|
38
|
+
Guards.number(Color.CLASS_NAME, "alpha", alpha);
|
|
39
|
+
Guards.number(Color.CLASS_NAME, "red", red);
|
|
40
|
+
Guards.number(Color.CLASS_NAME, "green", green);
|
|
41
|
+
Guards.number(Color.CLASS_NAME, "blue", blue);
|
|
43
42
|
if (alpha < 0 || alpha > 255) {
|
|
44
|
-
throw new GeneralError(Color.
|
|
43
|
+
throw new GeneralError(Color.CLASS_NAME, "range", {
|
|
45
44
|
prop: "alpha",
|
|
46
45
|
value: alpha
|
|
47
46
|
});
|
|
48
47
|
}
|
|
49
48
|
if (red < 0 || red > 255) {
|
|
50
|
-
throw new GeneralError(Color.
|
|
49
|
+
throw new GeneralError(Color.CLASS_NAME, "range", {
|
|
51
50
|
prop: "red",
|
|
52
51
|
value: red
|
|
53
52
|
});
|
|
54
53
|
}
|
|
55
54
|
if (green < 0 || green > 255) {
|
|
56
|
-
throw new GeneralError(Color.
|
|
55
|
+
throw new GeneralError(Color.CLASS_NAME, "range", {
|
|
57
56
|
prop: "green",
|
|
58
57
|
value: green
|
|
59
58
|
});
|
|
60
59
|
}
|
|
61
60
|
if (blue < 0 || blue > 255) {
|
|
62
|
-
throw new GeneralError(Color.
|
|
61
|
+
throw new GeneralError(Color.CLASS_NAME, "range", {
|
|
63
62
|
prop: "blue",
|
|
64
63
|
value: blue
|
|
65
64
|
});
|
|
@@ -76,7 +75,7 @@ class Color {
|
|
|
76
75
|
* @throws Error if the format is incorrect.
|
|
77
76
|
*/
|
|
78
77
|
static fromHex(hex) {
|
|
79
|
-
Guards.stringValue(Color.
|
|
78
|
+
Guards.stringValue(Color.CLASS_NAME, "hex", hex);
|
|
80
79
|
let alpha;
|
|
81
80
|
let red;
|
|
82
81
|
let green;
|
|
@@ -110,7 +109,7 @@ class Color {
|
|
|
110
109
|
blue = hex.slice(7, 9);
|
|
111
110
|
}
|
|
112
111
|
else {
|
|
113
|
-
throw new GeneralError(Color.
|
|
112
|
+
throw new GeneralError(Color.CLASS_NAME, "hex", { hex });
|
|
114
113
|
}
|
|
115
114
|
return new Color(Number.parseInt(alpha, 16), Number.parseInt(red, 16), Number.parseInt(green, 16), Number.parseInt(blue, 16));
|
|
116
115
|
}
|
|
@@ -224,9 +223,8 @@ class Color {
|
|
|
224
223
|
class JpegEncoder {
|
|
225
224
|
/**
|
|
226
225
|
* Runtime name for the class.
|
|
227
|
-
* @internal
|
|
228
226
|
*/
|
|
229
|
-
static
|
|
227
|
+
static CLASS_NAME = "JpegEncoder";
|
|
230
228
|
/**
|
|
231
229
|
* @internal
|
|
232
230
|
*/
|
|
@@ -508,7 +506,7 @@ class JpegEncoder {
|
|
|
508
506
|
*/
|
|
509
507
|
setQuality(quality) {
|
|
510
508
|
if (quality <= 0 || quality > 100) {
|
|
511
|
-
throw new GeneralError(JpegEncoder.
|
|
509
|
+
throw new GeneralError(JpegEncoder.CLASS_NAME, "invalidQuality", { value: quality });
|
|
512
510
|
}
|
|
513
511
|
let sf = 0;
|
|
514
512
|
if (quality < 50) {
|
package/dist/types/color.d.ts
CHANGED
package/docs/changelog.md
CHANGED
|
@@ -1,5 +1,24 @@
|
|
|
1
1
|
# @twin.org/image - Changelog
|
|
2
2
|
|
|
3
|
+
## [0.0.2-next.21](https://github.com/twinfoundation/framework/compare/image-v0.0.2-next.20...image-v0.0.2-next.21) (2025-10-09)
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
### Features
|
|
7
|
+
|
|
8
|
+
* locales validation ([#197](https://github.com/twinfoundation/framework/issues/197)) ([55fdadb](https://github.com/twinfoundation/framework/commit/55fdadb13595ce0047f787bd1d4135d429a99f12))
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
### Dependencies
|
|
12
|
+
|
|
13
|
+
* The following workspace dependencies were updated
|
|
14
|
+
* dependencies
|
|
15
|
+
* @twin.org/core bumped from 0.0.2-next.20 to 0.0.2-next.21
|
|
16
|
+
* @twin.org/nameof bumped from 0.0.2-next.20 to 0.0.2-next.21
|
|
17
|
+
* devDependencies
|
|
18
|
+
* @twin.org/nameof-transformer bumped from 0.0.2-next.20 to 0.0.2-next.21
|
|
19
|
+
* @twin.org/nameof-vitest-plugin bumped from 0.0.2-next.20 to 0.0.2-next.21
|
|
20
|
+
* @twin.org/validate-locales bumped from 0.0.2-next.20 to 0.0.2-next.21
|
|
21
|
+
|
|
3
22
|
## [0.0.2-next.20](https://github.com/twinfoundation/framework/compare/image-v0.0.2-next.19...image-v0.0.2-next.20) (2025-10-02)
|
|
4
23
|
|
|
5
24
|
|
package/locales/en.json
CHANGED
|
@@ -2,6 +2,10 @@
|
|
|
2
2
|
"error": {
|
|
3
3
|
"jpegEncoder": {
|
|
4
4
|
"invalidQuality": "Quality must be between 1 and 100, it is \"{value}\""
|
|
5
|
+
},
|
|
6
|
+
"color": {
|
|
7
|
+
"range": "Value must be between 0 and 355, it is \"{value}\"",
|
|
8
|
+
"hex": "Value must be a valid hex color in one of the forms #RGB/#ARGB/#RRGGBB/#AARRGGBB, it is \"{hex}\""
|
|
5
9
|
}
|
|
6
10
|
}
|
|
7
11
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@twin.org/image",
|
|
3
|
-
"version": "0.0.2-next.
|
|
3
|
+
"version": "0.0.2-next.21",
|
|
4
4
|
"description": "Classes for image manipulation",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -14,8 +14,8 @@
|
|
|
14
14
|
"node": ">=20.0.0"
|
|
15
15
|
},
|
|
16
16
|
"dependencies": {
|
|
17
|
-
"@twin.org/core": "0.0.2-next.
|
|
18
|
-
"@twin.org/nameof": "0.0.2-next.
|
|
17
|
+
"@twin.org/core": "0.0.2-next.21",
|
|
18
|
+
"@twin.org/nameof": "0.0.2-next.21"
|
|
19
19
|
},
|
|
20
20
|
"main": "./dist/cjs/index.cjs",
|
|
21
21
|
"module": "./dist/esm/index.mjs",
|
|
@@ -40,5 +40,9 @@
|
|
|
40
40
|
"iota",
|
|
41
41
|
"framework",
|
|
42
42
|
"blockchain"
|
|
43
|
-
]
|
|
43
|
+
],
|
|
44
|
+
"bugs": {
|
|
45
|
+
"url": "git+https://github.com/twinfoundation/framework/issues"
|
|
46
|
+
},
|
|
47
|
+
"homepage": "https://twindev.org"
|
|
44
48
|
}
|