Leon4gr45 commited on
Commit
a8c0775
·
verified ·
1 Parent(s): 6992f5d

Upload folder using huggingface_hub (part 17)

Browse files
This view is limited to 50 files because it contains too many changes.   See raw diff
Files changed (50) hide show
  1. node_modules/@jimp/plugin-resize/node_modules/zod/v4-mini/index.cjs +17 -0
  2. node_modules/@jimp/plugin-resize/node_modules/zod/v4-mini/index.d.cts +1 -0
  3. node_modules/@jimp/plugin-resize/node_modules/zod/v4-mini/index.d.ts +1 -0
  4. node_modules/@jimp/plugin-resize/node_modules/zod/v4-mini/index.js +1 -0
  5. node_modules/@jimp/plugin-resize/package.json +67 -0
  6. node_modules/@jimp/plugin-resize/src/__snapshots__/index.test.ts.snap +445 -0
  7. node_modules/@jimp/plugin-resize/src/constants.ts +26 -0
  8. node_modules/@jimp/plugin-resize/src/index.test.ts +101 -0
  9. node_modules/@jimp/plugin-resize/src/index.ts +176 -0
  10. node_modules/@jimp/plugin-resize/src/modules/resize.ts +555 -0
  11. node_modules/@jimp/plugin-resize/src/modules/resize2.ts +327 -0
  12. node_modules/@jimp/plugin-resize/tsconfig.json +6 -0
  13. node_modules/@jimp/plugin-resize/vitest.config.browser.mjs +3 -0
  14. node_modules/@jimp/plugin-rotate/.tshy/build.json +8 -0
  15. node_modules/@jimp/plugin-rotate/.tshy/commonjs.json +17 -0
  16. node_modules/@jimp/plugin-rotate/.tshy/esm.json +16 -0
  17. node_modules/@jimp/plugin-rotate/CHANGELOG.md +64 -0
  18. node_modules/@jimp/plugin-rotate/LICENSE +21 -0
  19. node_modules/@jimp/plugin-rotate/README.md +10 -0
  20. node_modules/@jimp/plugin-rotate/dist/commonjs/index.d.ts +32 -0
  21. node_modules/@jimp/plugin-rotate/dist/commonjs/index.d.ts.map +1 -0
  22. node_modules/@jimp/plugin-rotate/dist/commonjs/index.js +201 -0
  23. node_modules/@jimp/plugin-rotate/dist/commonjs/index.js.map +1 -0
  24. node_modules/@jimp/plugin-rotate/dist/commonjs/package.json +3 -0
  25. node_modules/@jimp/plugin-rotate/dist/esm/index.d.ts +32 -0
  26. node_modules/@jimp/plugin-rotate/dist/esm/index.d.ts.map +1 -0
  27. node_modules/@jimp/plugin-rotate/dist/esm/index.js +198 -0
  28. node_modules/@jimp/plugin-rotate/dist/esm/index.js.map +1 -0
  29. node_modules/@jimp/plugin-rotate/dist/esm/package.json +3 -0
  30. node_modules/@jimp/plugin-rotate/eslint.config.mjs +2 -0
  31. node_modules/@jimp/plugin-rotate/node_modules/zod/LICENSE +21 -0
  32. node_modules/@jimp/plugin-rotate/node_modules/zod/README.md +208 -0
  33. node_modules/@jimp/plugin-rotate/node_modules/zod/index.cjs +33 -0
  34. node_modules/@jimp/plugin-rotate/node_modules/zod/index.d.cts +4 -0
  35. node_modules/@jimp/plugin-rotate/node_modules/zod/index.d.ts +4 -0
  36. node_modules/@jimp/plugin-rotate/node_modules/zod/index.js +4 -0
  37. node_modules/@jimp/plugin-rotate/node_modules/zod/package.json +118 -0
  38. node_modules/@jimp/plugin-rotate/node_modules/zod/src/index.ts +4 -0
  39. node_modules/@jimp/plugin-rotate/node_modules/zod/src/v3/ZodError.ts +330 -0
  40. node_modules/@jimp/plugin-rotate/node_modules/zod/src/v3/benchmarks/datetime.ts +58 -0
  41. node_modules/@jimp/plugin-rotate/node_modules/zod/src/v3/benchmarks/discriminatedUnion.ts +80 -0
  42. node_modules/@jimp/plugin-rotate/node_modules/zod/src/v3/benchmarks/index.ts +59 -0
  43. node_modules/@jimp/plugin-rotate/node_modules/zod/src/v3/benchmarks/ipv4.ts +57 -0
  44. node_modules/@jimp/plugin-rotate/node_modules/zod/src/v3/benchmarks/object.ts +69 -0
  45. node_modules/@jimp/plugin-rotate/node_modules/zod/src/v3/benchmarks/primitives.ts +162 -0
  46. node_modules/@jimp/plugin-rotate/node_modules/zod/src/v3/benchmarks/realworld.ts +63 -0
  47. node_modules/@jimp/plugin-rotate/node_modules/zod/src/v3/benchmarks/string.ts +55 -0
  48. node_modules/@jimp/plugin-rotate/node_modules/zod/src/v3/benchmarks/union.ts +80 -0
  49. node_modules/@jimp/plugin-rotate/node_modules/zod/src/v3/errors.ts +13 -0
  50. node_modules/@jimp/plugin-rotate/node_modules/zod/src/v3/external.ts +6 -0
node_modules/@jimp/plugin-resize/node_modules/zod/v4-mini/index.cjs ADDED
@@ -0,0 +1,17 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("../v4/mini/index.cjs"), exports);
node_modules/@jimp/plugin-resize/node_modules/zod/v4-mini/index.d.cts ADDED
@@ -0,0 +1 @@
 
 
1
+ export * from "../v4/mini/index.cjs";
node_modules/@jimp/plugin-resize/node_modules/zod/v4-mini/index.d.ts ADDED
@@ -0,0 +1 @@
 
 
1
+ export * from "../v4/mini/index.js";
node_modules/@jimp/plugin-resize/node_modules/zod/v4-mini/index.js ADDED
@@ -0,0 +1 @@
 
 
1
+ export * from "../v4/mini/index.js";
node_modules/@jimp/plugin-resize/package.json ADDED
@@ -0,0 +1,67 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "name": "@jimp/plugin-resize",
3
+ "version": "1.6.1",
4
+ "repository": "jimp-dev/jimp",
5
+ "engines": {
6
+ "node": ">=18"
7
+ },
8
+ "scripts": {
9
+ "lint": "eslint .",
10
+ "test": "vitest",
11
+ "test:browser": "vitest --config vitest.config.browser.mjs",
12
+ "build": "tshy",
13
+ "dev": "tshy --watch",
14
+ "clean": "rm -rf node_modules .tshy .tshy-build dist .turbo"
15
+ },
16
+ "author": "Andrew Lisowski <lisowski54@gmail.com>",
17
+ "license": "MIT",
18
+ "dependencies": {
19
+ "@jimp/core": "1.6.1",
20
+ "@jimp/types": "1.6.1",
21
+ "zod": "^3.23.8"
22
+ },
23
+ "devDependencies": {
24
+ "@jimp/config-eslint": "1.6.1",
25
+ "@jimp/config-typescript": "1.6.1",
26
+ "@jimp/config-vitest": "1.6.1",
27
+ "@jimp/test-utils": "1.6.1",
28
+ "@types/node": "^18.19.48",
29
+ "@vitest/browser": "^2.0.5",
30
+ "eslint": "^9.9.1",
31
+ "tshy": "^3.0.2",
32
+ "typescript": "^5.5.4",
33
+ "vite-plugin-node-polyfills": "^0.22.0",
34
+ "vitest": "^2.0.5"
35
+ },
36
+ "tshy": {
37
+ "exclude": [
38
+ "**/*.test.ts"
39
+ ],
40
+ "exports": {
41
+ "./package.json": "./package.json",
42
+ ".": "./src/index.ts"
43
+ }
44
+ },
45
+ "exports": {
46
+ "./package.json": "./package.json",
47
+ ".": {
48
+ "import": {
49
+ "types": "./dist/esm/index.d.ts",
50
+ "default": "./dist/esm/index.js"
51
+ },
52
+ "require": {
53
+ "types": "./dist/commonjs/index.d.ts",
54
+ "default": "./dist/commonjs/index.js"
55
+ }
56
+ }
57
+ },
58
+ "main": "./dist/commonjs/index.js",
59
+ "types": "./dist/commonjs/index.d.ts",
60
+ "type": "module",
61
+ "publishConfig": {
62
+ "access": "public"
63
+ },
64
+ "sideEffects": false,
65
+ "module": "./dist/esm/index.js",
66
+ "gitHead": "7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
3
+ exports[`Resize images > max contrast 8x8 > to BEZIER 2x5 1`] = `
4
+ Visualization:
5
+
6
+ ■▩
7
+ ■▩
8
+ ■▩
9
+ □D
10
+ □D
11
+
12
+ Data:
13
+
14
+ 00-00-00ᶠᶠ DF-DF-DFᶠᶠ
15
+ 00-00-00ᶠᶠ DF-DF-DFᶠᶠ
16
+ 00-00-00ᶠᶠ DF-DF-DFᶠᶠ
17
+ FF-FF-FFᶠᶠ 20-20-20ᶠᶠ
18
+ FF-FF-FFᶠᶠ 20-20-20ᶠᶠ
19
+ `;
20
+
21
+ exports[`Resize images > max contrast 8x8 > to BEZIER 4x4 1`] = `
22
+ Visualization:
23
+
24
+ ■■D□
25
+ ■■D□
26
+ DD3▩
27
+ □□▩■
28
+
29
+ Data:
30
+
31
+ 00-00-00ᶠᶠ 00-00-00ᶠᶠ C0-C0-C0ᶠᶠ FF-FF-FFᶠᶠ
32
+ 00-00-00ᶠᶠ 00-00-00ᶠᶠ C0-C0-C0ᶠᶠ FF-FF-FFᶠᶠ
33
+ C0-C0-C0ᶠᶠ C0-C0-C0ᶠᶠ 60-60-60ᶠᶠ 40-40-40ᶠᶠ
34
+ FF-FF-FFᶠᶠ FF-FF-FFᶠᶠ 40-40-40ᶠᶠ 00-00-00ᶠᶠ
35
+ `;
36
+
37
+ exports[`Resize images > max contrast 8x8 > to BICUBIC 2x5 1`] = `
38
+ Visualization:
39
+
40
+ ■▩
41
+ ■▩
42
+ ■▩
43
+ □D
44
+ □D
45
+
46
+ Data:
47
+
48
+ 00-00-00ᶠᶠ DF-DF-DFᶠᶠ
49
+ 00-00-00ᶠᶠ DF-DF-DFᶠᶠ
50
+ 00-00-00ᶠᶠ DF-DF-DFᶠᶠ
51
+ FF-FF-FFᶠᶠ 20-20-20ᶠᶠ
52
+ FF-FF-FFᶠᶠ 20-20-20ᶠᶠ
53
+ `;
54
+
55
+ exports[`Resize images > max contrast 8x8 > to BICUBIC 4x4 1`] = `
56
+ Visualization:
57
+
58
+ ■■▥□
59
+ ■■▥□
60
+ ▥▥!▩
61
+ □□▩■
62
+
63
+ Data:
64
+
65
+ 00-00-00ᶠᶠ 00-00-00ᶠᶠ BF-BF-BFᶠᶠ FF-FF-FFᶠᶠ
66
+ 00-00-00ᶠᶠ 00-00-00ᶠᶠ BF-BF-BFᶠᶠ FF-FF-FFᶠᶠ
67
+ BF-BF-BFᶠᶠ BF-BF-BFᶠᶠ 5F-5F-5Fᶠᶠ 40-40-40ᶠᶠ
68
+ FF-FF-FFᶠᶠ FF-FF-FFᶠᶠ 40-40-40ᶠᶠ 00-00-00ᶠᶠ
69
+ `;
70
+
71
+ exports[`Resize images > max contrast 8x8 > to BILINEAR 2x5 1`] = `
72
+ Visualization:
73
+
74
+ ■□
75
+ ■□
76
+ 3C
77
+ □■
78
+ □■
79
+
80
+ Data:
81
+
82
+ 00-00-00ᶠᶠ FF-FF-FFᶠᶠ
83
+ 00-00-00ᶠᶠ FF-FF-FFᶠᶠ
84
+ 33-33-33ᶠᶠ CC-CC-CCᶠᶠ
85
+ FF-FF-FFᶠᶠ 00-00-00ᶠᶠ
86
+ FF-FF-FFᶠᶠ 00-00-00ᶠᶠ
87
+ `;
88
+
89
+ exports[`Resize images > max contrast 8x8 > to BILINEAR 4x4 1`] = `
90
+ Visualization:
91
+
92
+ ■■□□
93
+ ■■□□
94
+ □□■■
95
+ □□■■
96
+
97
+ Data:
98
+
99
+ 00-00-00ᶠᶠ 00-00-00ᶠᶠ FF-FF-FFᶠᶠ FF-FF-FFᶠᶠ
100
+ 00-00-00ᶠᶠ 00-00-00ᶠᶠ FF-FF-FFᶠᶠ FF-FF-FFᶠᶠ
101
+ FF-FF-FFᶠᶠ FF-FF-FFᶠᶠ 00-00-00ᶠᶠ 00-00-00ᶠᶠ
102
+ FF-FF-FFᶠᶠ FF-FF-FFᶠᶠ 00-00-00ᶠᶠ 00-00-00ᶠᶠ
103
+ `;
104
+
105
+ exports[`Resize images > max contrast 8x8 > to HERMITE 2x5 1`] = `
106
+ Visualization:
107
+
108
+ ■▩
109
+ ■▩
110
+ ■▩
111
+ □D
112
+ □D
113
+
114
+ Data:
115
+
116
+ 00-00-00ᶠᶠ DF-DF-DFᶠᶠ
117
+ 00-00-00ᶠᶠ DF-DF-DFᶠᶠ
118
+ 00-00-00ᶠᶠ DF-DF-DFᶠᶠ
119
+ FF-FF-FFᶠᶠ 20-20-20ᶠᶠ
120
+ FF-FF-FFᶠᶠ 20-20-20ᶠᶠ
121
+ `;
122
+
123
+ exports[`Resize images > max contrast 8x8 > to HERMITE 4x4 1`] = `
124
+ Visualization:
125
+
126
+ ■■D□
127
+ ■■D□
128
+ DD3▩
129
+ □□▩■
130
+
131
+ Data:
132
+
133
+ 00-00-00ᶠᶠ 00-00-00ᶠᶠ C0-C0-C0ᶠᶠ FF-FF-FFᶠᶠ
134
+ 00-00-00ᶠᶠ 00-00-00ᶠᶠ C0-C0-C0ᶠᶠ FF-FF-FFᶠᶠ
135
+ C0-C0-C0ᶠᶠ C0-C0-C0ᶠᶠ 60-60-60ᶠᶠ 40-40-40ᶠᶠ
136
+ FF-FF-FFᶠᶠ FF-FF-FFᶠᶠ 40-40-40ᶠᶠ 00-00-00ᶠᶠ
137
+ `;
138
+
139
+ exports[`Resize images > max contrast 8x8 > to NEAREST_NEIGHBOR 2x5 1`] = `
140
+ Visualization:
141
+
142
+ ■□
143
+ ■□
144
+ ■□
145
+ □■
146
+ □■
147
+
148
+ Data:
149
+
150
+ 00-00-00ᶠᶠ FF-FF-FFᶠᶠ
151
+ 00-00-00ᶠᶠ FF-FF-FFᶠᶠ
152
+ 00-00-00ᶠᶠ FF-FF-FFᶠᶠ
153
+ FF-FF-FFᶠᶠ 00-00-00ᶠᶠ
154
+ FF-FF-FFᶠᶠ 00-00-00ᶠᶠ
155
+ `;
156
+
157
+ exports[`Resize images > max contrast 8x8 > to NEAREST_NEIGHBOR 4x4 1`] = `
158
+ Visualization:
159
+
160
+ ■■□□
161
+ ■■□□
162
+ □□■■
163
+ □□■■
164
+
165
+ Data:
166
+
167
+ 00-00-00ᶠᶠ 00-00-00ᶠᶠ FF-FF-FFᶠᶠ FF-FF-FFᶠᶠ
168
+ 00-00-00ᶠᶠ 00-00-00ᶠᶠ FF-FF-FFᶠᶠ FF-FF-FFᶠᶠ
169
+ FF-FF-FFᶠᶠ FF-FF-FFᶠᶠ 00-00-00ᶠᶠ 00-00-00ᶠᶠ
170
+ FF-FF-FFᶠᶠ FF-FF-FFᶠᶠ 00-00-00ᶠᶠ 00-00-00ᶠᶠ
171
+ `;
172
+
173
+ exports[`Resize images > max contrast 8x8 > to default 2x5 1`] = `
174
+ Visualization:
175
+
176
+ ■□
177
+ ■□
178
+ ▦▦
179
+ □■
180
+ □■
181
+
182
+ Data:
183
+
184
+ 00-00-00ᶠᶠ FF-FF-FFᶠᶠ
185
+ 00-00-00ᶠᶠ FF-FF-FFᶠᶠ
186
+ 80-80-80ᶠᶠ 80-80-80ᶠᶠ
187
+ FF-FF-FFᶠᶠ 00-00-00ᶠᶠ
188
+ FF-FF-FFᶠᶠ 00-00-00ᶠᶠ
189
+ `;
190
+
191
+ exports[`Resize images > max contrast 8x8 > to default 4x4 1`] = `
192
+ Visualization:
193
+
194
+ ■■□□
195
+ ■■□□
196
+ □□■■
197
+ □□■■
198
+
199
+ Data:
200
+
201
+ 00-00-00ᶠᶠ 00-00-00ᶠᶠ FF-FF-FFᶠᶠ FF-FF-FFᶠᶠ
202
+ 00-00-00ᶠᶠ 00-00-00ᶠᶠ FF-FF-FFᶠᶠ FF-FF-FFᶠᶠ
203
+ FF-FF-FFᶠᶠ FF-FF-FFᶠᶠ 00-00-00ᶠᶠ 00-00-00ᶠᶠ
204
+ FF-FF-FFᶠᶠ FF-FF-FFᶠᶠ 00-00-00ᶠᶠ 00-00-00ᶠᶠ
205
+ `;
206
+
207
+ exports[`Resize images > max contrast 12x12 with dots > to BEZIER 6x6 1`] = `
208
+ Visualization:
209
+
210
+ ■■■D□□
211
+ ■4◇D◇□
212
+ ■■■D□□
213
+ DDD3▩▩
214
+ □▴◇▩3■
215
+ □D▩▩▴■
216
+
217
+ Data:
218
+
219
+ 00-00-00ᶠᶠ 00-00-00ᶠᶠ 00-00-00ᶠᶠ C0-C0-C0ᶠᶠ FF-FF-FFᶠᶠ FF-FF-FFᶠᶠ
220
+ 00-00-00ᶠᶠ 44-44-44ᶠᶠ 1D-1D-1Dᶠᶠ C0-C0-C0ᶠᶠ 9F-9F-9Fᶠᶠ FF-FF-FFᶠᶠ
221
+ 00-00-00ᶠᶠ 00-00-00ᶠᶠ 00-00-00ᶠᶠ C0-C0-C0ᶠᶠ FF-FF-FFᶠᶠ FF-FF-FFᶠᶠ
222
+ C0-C0-C0ᶠᶠ C0-C0-C0ᶠᶠ C0-C0-C0ᶠᶠ 60-60-60ᶠᶠ 40-40-40ᶠᶠ 40-40-40ᶠᶠ
223
+ FF-FF-FFᶠᶠ F0-F0-F0ᶠᶠ F9-F9-F9ᶠᶠ 40-40-40ᶠᶠ 15-15-15ᶠᶠ 00-00-00ᶠᶠ
224
+ FF-FF-FFᶠᶠ CA-CA-CAᶠᶠ E9-E9-E9ᶠᶠ 40-40-40ᶠᶠ 4B-4B-4Bᶠᶠ 00-00-00ᶠᶠ
225
+ `;
226
+
227
+ exports[`Resize images > max contrast 12x12 with dots > to BICUBIC 6x6 1`] = `
228
+ Visualization:
229
+
230
+ ■■■▥□□
231
+ ■3D▥3□
232
+ ■■■▥□□
233
+ ▥▥▥!▩▩
234
+ □ED▩◇■
235
+ □3▴▩▩■
236
+
237
+ Data:
238
+
239
+ 00-00-00ᶠᶠ 00-00-00ᶠᶠ 00-00-00ᶠᶠ BF-BF-BFᶠᶠ FF-FF-FFᶠᶠ FF-FF-FFᶠᶠ
240
+ 00-00-00ᶠᶠ 47-47-47ᶠᶠ 20-20-20ᶠᶠ BF-BF-BFᶠᶠ 97-97-97ᶠᶠ FF-FF-FFᶠᶠ
241
+ 00-00-00ᶠᶠ 00-00-00ᶠᶠ 00-00-00ᶠᶠ BF-BF-BFᶠᶠ FF-FF-FFᶠᶠ FF-FF-FFᶠᶠ
242
+ BF-BF-BFᶠᶠ BF-BF-BFᶠᶠ BF-BF-BFᶠᶠ 5F-5F-5Fᶠᶠ 40-40-40ᶠᶠ 40-40-40ᶠᶠ
243
+ FF-FF-FFᶠᶠ EE-EE-EEᶠᶠ F7-F7-F7ᶠᶠ 40-40-40ᶠᶠ 18-18-18ᶠᶠ 00-00-00ᶠᶠ
244
+ FF-FF-FFᶠᶠ C9-C9-C9ᶠᶠ E6-E6-E6ᶠᶠ 40-40-40ᶠᶠ 4E-4E-4Eᶠᶠ 00-00-00ᶠᶠ
245
+ `;
246
+
247
+ exports[`Resize images > max contrast 12x12 with dots > to BILINEAR 6x6 1`] = `
248
+ Visualization:
249
+
250
+ ■■■□□□
251
+ ■■■□■□
252
+ ■■■□□□
253
+ □□□■■■
254
+ □□□■■■
255
+ □□□■■■
256
+
257
+ Data:
258
+
259
+ 00-00-00ᶠᶠ 00-00-00ᶠᶠ 00-00-00ᶠᶠ FF-FF-FFᶠᶠ FF-FF-FFᶠᶠ FF-FF-FFᶠᶠ
260
+ 00-00-00ᶠᶠ 00-00-00ᶠᶠ 00-00-00ᶠᶠ FF-FF-FFᶠᶠ 00-00-00ᶠᶠ FF-FF-FFᶠᶠ
261
+ 00-00-00ᶠᶠ 00-00-00ᶠᶠ 00-00-00ᶠᶠ FF-FF-FFᶠᶠ FF-FF-FFᶠᶠ FF-FF-FFᶠᶠ
262
+ FF-FF-FFᶠᶠ FF-FF-FFᶠᶠ FF-FF-FFᶠᶠ 00-00-00ᶠᶠ 00-00-00ᶠᶠ 00-00-00ᶠᶠ
263
+ FF-FF-FFᶠᶠ FF-FF-FFᶠᶠ FF-FF-FFᶠᶠ 00-00-00ᶠᶠ 00-00-00ᶠᶠ 00-00-00ᶠᶠ
264
+ FF-FF-FFᶠᶠ FF-FF-FFᶠᶠ FF-FF-FFᶠᶠ 00-00-00ᶠᶠ 00-00-00ᶠᶠ 00-00-00ᶠᶠ
265
+ `;
266
+
267
+ exports[`Resize images > max contrast 12x12 with dots > to HERMITE 6x6 1`] = `
268
+ Visualization:
269
+
270
+ ■■■D□□
271
+ ■▩▴D3□
272
+ ■■■D□□
273
+ DDD3▩▩
274
+ □▩▴▩1■
275
+ □▩▴▩D■
276
+
277
+ Data:
278
+
279
+ 00-00-00ᶠᶠ 00-00-00ᶠᶠ 00-00-00ᶠᶠ C0-C0-C0ᶠᶠ FF-FF-FFᶠᶠ FF-FF-FFᶠᶠ
280
+ 00-00-00ᶠᶠ 40-40-40ᶠᶠ 19-19-19ᶠᶠ C0-C0-C0ᶠᶠ A6-A6-A6ᶠᶠ FF-FF-FFᶠᶠ
281
+ 00-00-00ᶠᶠ 00-00-00ᶠᶠ 00-00-00ᶠᶠ C0-C0-C0ᶠᶠ FF-FF-FFᶠᶠ FF-FF-FFᶠᶠ
282
+ C0-C0-C0ᶠᶠ C0-C0-C0ᶠᶠ C0-C0-C0ᶠᶠ 60-60-60ᶠᶠ 40-40-40ᶠᶠ 40-40-40ᶠᶠ
283
+ FF-FF-FFᶠᶠ F3-F3-F3ᶠᶠ FA-FA-FAᶠᶠ 40-40-40ᶠᶠ 11-11-11ᶠᶠ 00-00-00ᶠᶠ
284
+ FF-FF-FFᶠᶠ CB-CB-CBᶠᶠ EB-EB-EBᶠᶠ 40-40-40ᶠᶠ 48-48-48ᶠᶠ 00-00-00ᶠᶠ
285
+ `;
286
+
287
+ exports[`Resize images > max contrast 12x12 with dots > to NEAREST_NEIGHBOR 6x6 1`] = `
288
+ Visualization:
289
+
290
+ ■■■□□□
291
+ ■■■□■□
292
+ ■■■□□□
293
+ □□□■■■
294
+ □□□■■■
295
+ □□□■■■
296
+
297
+ Data:
298
+
299
+ 00-00-00ᶠᶠ 00-00-00ᶠᶠ 00-00-00ᶠᶠ FF-FF-FFᶠᶠ FF-FF-FFᶠᶠ FF-FF-FFᶠᶠ
300
+ 00-00-00ᶠᶠ 00-00-00ᶠᶠ 00-00-00ᶠᶠ FF-FF-FFᶠᶠ 00-00-00ᶠᶠ FF-FF-FFᶠᶠ
301
+ 00-00-00ᶠᶠ 00-00-00ᶠᶠ 00-00-00ᶠᶠ FF-FF-FFᶠᶠ FF-FF-FFᶠᶠ FF-FF-FFᶠᶠ
302
+ FF-FF-FFᶠᶠ FF-FF-FFᶠᶠ FF-FF-FFᶠᶠ 00-00-00ᶠᶠ 00-00-00ᶠᶠ 00-00-00ᶠᶠ
303
+ FF-FF-FFᶠᶠ FF-FF-FFᶠᶠ FF-FF-FFᶠᶠ 00-00-00ᶠᶠ 00-00-00ᶠᶠ 00-00-00ᶠᶠ
304
+ FF-FF-FFᶠᶠ FF-FF-FFᶠᶠ FF-FF-FFᶠᶠ 00-00-00ᶠᶠ 00-00-00ᶠᶠ 00-00-00ᶠᶠ
305
+ `;
306
+
307
+ exports[`Resize images > max contrast 12x12 with dots > to default 6x6 1`] = `
308
+ Visualization:
309
+
310
+ ■■■□□□
311
+ ■▩■□▥□
312
+ ■■■□□□
313
+ □□□■■■
314
+ □▥□■▩■
315
+ □□□■■■
316
+
317
+ Data:
318
+
319
+ 00-00-00ᶠᶠ 00-00-00ᶠᶠ 00-00-00ᶠᶠ FF-FF-FFᶠᶠ FF-FF-FFᶠᶠ FF-FF-FFᶠᶠ
320
+ 00-00-00ᶠᶠ 40-40-40ᶠᶠ 00-00-00ᶠᶠ FF-FF-FFᶠᶠ BF-BF-BFᶠᶠ FF-FF-FFᶠᶠ
321
+ 00-00-00ᶠᶠ 00-00-00ᶠᶠ 00-00-00ᶠᶠ FF-FF-FFᶠᶠ FF-FF-FFᶠᶠ FF-FF-FFᶠᶠ
322
+ FF-FF-FFᶠᶠ FF-FF-FFᶠᶠ FF-FF-FFᶠᶠ 00-00-00ᶠᶠ 00-00-00ᶠᶠ 00-00-00ᶠᶠ
323
+ FF-FF-FFᶠᶠ BF-BF-BFᶠᶠ FF-FF-FFᶠᶠ 00-00-00ᶠᶠ 40-40-40ᶠᶠ 00-00-00ᶠᶠ
324
+ FF-FF-FFᶠᶠ FF-FF-FFᶠᶠ FF-FF-FFᶠᶠ 00-00-00ᶠᶠ 00-00-00ᶠᶠ 00-00-00ᶠᶠ
325
+ `;
326
+
327
+ exports[`Resize images > mutch contrast 4x4 > to BEZIER 6x6 1`] = `
328
+ Visualization:
329
+
330
+ ▩D▩▦▥▩
331
+ D▩D▦▩D
332
+ ▩D▩▦▥▩
333
+ ▦▦▦▦▦▦
334
+ ▥▩▥▦▩D
335
+ ▩D▩▦D▩
336
+
337
+ Data:
338
+
339
+ 40-40-40ᶠᶠ 34-34-34ᶠᶠ 40-40-40ᶠᶠ 80-80-80ᶠᶠ BF-BF-BFᶠᶠ CB-CB-CBᶠᶠ
340
+ 34-34-34ᶠᶠ 26-26-26ᶠᶠ 34-34-34ᶠᶠ 80-80-80ᶠᶠ CB-CB-CBᶠᶠ D9-D9-D9ᶠᶠ
341
+ 40-40-40ᶠᶠ 34-34-34ᶠᶠ 40-40-40ᶠᶠ 80-80-80ᶠᶠ BF-BF-BFᶠᶠ CB-CB-CBᶠᶠ
342
+ 80-80-80ᶠᶠ 80-80-80ᶠᶠ 80-80-80ᶠᶠ 80-80-80ᶠᶠ 80-80-80ᶠᶠ 80-80-80ᶠᶠ
343
+ BF-BF-BFᶠᶠ CB-CB-CBᶠᶠ BF-BF-BFᶠᶠ 80-80-80ᶠᶠ 40-40-40ᶠᶠ 34-34-34ᶠᶠ
344
+ CB-CB-CBᶠᶠ D9-D9-D9ᶠᶠ CB-CB-CBᶠᶠ 80-80-80ᶠᶠ 34-34-34ᶠᶠ 26-26-26ᶠᶠ
345
+ `;
346
+
347
+ exports[`Resize images > mutch contrast 4x4 > to BICUBIC 6x6 1`] = `
348
+ Visualization:
349
+
350
+ ▩▩▩D▥3
351
+ ▩▩▩D3▴
352
+ ▩▩▩D▥3
353
+ DDDDDD
354
+ ▥3▥D▩▩
355
+ 3▴3D▩▩
356
+
357
+ Data:
358
+
359
+ 40-40-40ᶠᶠ 30-30-30ᶠᶠ 40-40-40ᶠᶠ 7F-7F-7Fᶠᶠ BF-BF-BFᶠᶠ CE-CE-CEᶠᶠ
360
+ 30-30-30ᶠᶠ 1C-1C-1Cᶠᶠ 30-30-30ᶠᶠ 7F-7F-7Fᶠᶠ CE-CE-CEᶠᶠ E1-E1-E1ᶠᶠ
361
+ 40-40-40ᶠᶠ 30-30-30ᶠᶠ 40-40-40ᶠᶠ 7F-7F-7Fᶠᶠ BF-BF-BFᶠᶠ CE-CE-CEᶠᶠ
362
+ 7F-7F-7Fᶠᶠ 7F-7F-7Fᶠᶠ 7F-7F-7Fᶠᶠ 7F-7F-7Fᶠᶠ 7F-7F-7Fᶠᶠ 7F-7F-7Fᶠᶠ
363
+ BF-BF-BFᶠᶠ CE-CE-CEᶠᶠ BF-BF-BFᶠᶠ 7F-7F-7Fᶠᶠ 40-40-40ᶠᶠ 30-30-30ᶠᶠ
364
+ CE-CE-CEᶠᶠ E1-E1-E1ᶠᶠ CE-CE-CEᶠᶠ 7F-7F-7Fᶠᶠ 30-30-30ᶠᶠ 1C-1C-1Cᶠᶠ
365
+ `;
366
+
367
+ exports[`Resize images > mutch contrast 4x4 > to BILINEAR 6x6 1`] = `
368
+ Visualization:
369
+
370
+ ▩▩3▥▥▥
371
+ ▩▩3▥▥▥
372
+ 33▴◇◇◇
373
+ ▥▥◇▩▩▩
374
+ ▥▥◇▩▩▩
375
+ ▥▥◇▩▩▩
376
+
377
+ Data:
378
+
379
+ 40-40-40ᶠᶠ 40-40-40ᶠᶠ 6A-6A-6Aᶠᶠ BF-BF-BFᶠᶠ BF-BF-BFᶠᶠ BF-BF-BFᶠᶠ
380
+ 40-40-40ᶠᶠ 40-40-40ᶠᶠ 6A-6A-6Aᶠᶠ BF-BF-BFᶠᶠ BF-BF-BFᶠᶠ BF-BF-BFᶠᶠ
381
+ 6A-6A-6Aᶠᶠ 6A-6A-6Aᶠᶠ 78-78-78ᶠᶠ 95-95-95ᶠᶠ 95-95-95ᶠᶠ 95-95-95ᶠᶠ
382
+ BF-BF-BFᶠᶠ BF-BF-BFᶠᶠ 95-95-95ᶠᶠ 40-40-40ᶠᶠ 40-40-40ᶠᶠ 40-40-40ᶠᶠ
383
+ BF-BF-BFᶠᶠ BF-BF-BFᶠᶠ 95-95-95ᶠᶠ 40-40-40ᶠᶠ 40-40-40ᶠᶠ 40-40-40ᶠᶠ
384
+ BF-BF-BFᶠᶠ BF-BF-BFᶠᶠ 95-95-95ᶠᶠ 40-40-40ᶠᶠ 40-40-40ᶠᶠ 40-40-40ᶠᶠ
385
+ `;
386
+
387
+ exports[`Resize images > mutch contrast 4x4 > to HERMITE 6x6 1`] = `
388
+ Visualization:
389
+
390
+ ▩3▩▦▥◇
391
+ 3D3▦◇▩
392
+ ▩3▩▦▥◇
393
+ ▦▦▦▦▦▦
394
+ ▥◇▥▦▩3
395
+ ◇▩◇▦3D
396
+
397
+ Data:
398
+
399
+ 40-40-40ᶠᶠ 38-38-38ᶠᶠ 40-40-40ᶠᶠ 80-80-80ᶠᶠ BF-BF-BFᶠᶠ C7-C7-C7ᶠᶠ
400
+ 38-38-38ᶠᶠ 2F-2F-2Fᶠᶠ 38-38-38ᶠᶠ 80-80-80ᶠᶠ C7-C7-C7ᶠᶠ D0-D0-D0ᶠᶠ
401
+ 40-40-40ᶠᶠ 38-38-38ᶠᶠ 40-40-40ᶠᶠ 80-80-80ᶠᶠ BF-BF-BFᶠᶠ C7-C7-C7ᶠᶠ
402
+ 80-80-80ᶠᶠ 80-80-80ᶠᶠ 80-80-80ᶠᶠ 80-80-80ᶠᶠ 80-80-80ᶠᶠ 80-80-80ᶠᶠ
403
+ BF-BF-BFᶠᶠ C7-C7-C7ᶠᶠ BF-BF-BFᶠᶠ 80-80-80ᶠᶠ 40-40-40ᶠᶠ 38-38-38ᶠᶠ
404
+ C7-C7-C7ᶠᶠ D0-D0-D0ᶠᶠ C7-C7-C7ᶠᶠ 80-80-80ᶠᶠ 38-38-38ᶠᶠ 2F-2F-2Fᶠᶠ
405
+ `;
406
+
407
+ exports[`Resize images > mutch contrast 4x4 > to NEAREST_NEIGHBOR 6x6 1`] = `
408
+ Visualization:
409
+
410
+ ▩▩▩▥▥▥
411
+ ▩▩▩▥▥▥
412
+ ▩▩▩▥▥▥
413
+ ▥▥▥▩▩▩
414
+ ▥▥▥▩▩▩
415
+ ▥▥▥▩▩▩
416
+
417
+ Data:
418
+
419
+ 40-40-40ᶠᶠ 40-40-40ᶠᶠ 40-40-40ᶠᶠ BF-BF-BFᶠᶠ BF-BF-BFᶠᶠ BF-BF-BFᶠᶠ
420
+ 40-40-40ᶠᶠ 40-40-40ᶠᶠ 40-40-40ᶠᶠ BF-BF-BFᶠᶠ BF-BF-BFᶠᶠ BF-BF-BFᶠᶠ
421
+ 40-40-40ᶠᶠ 40-40-40ᶠᶠ 40-40-40ᶠᶠ BF-BF-BFᶠᶠ BF-BF-BFᶠᶠ BF-BF-BFᶠᶠ
422
+ BF-BF-BFᶠᶠ BF-BF-BFᶠᶠ BF-BF-BFᶠᶠ 40-40-40ᶠᶠ 40-40-40ᶠᶠ 40-40-40ᶠᶠ
423
+ BF-BF-BFᶠᶠ BF-BF-BFᶠᶠ BF-BF-BFᶠᶠ 40-40-40ᶠᶠ 40-40-40ᶠᶠ 40-40-40ᶠᶠ
424
+ BF-BF-BFᶠᶠ BF-BF-BFᶠᶠ BF-BF-BFᶠᶠ 40-40-40ᶠᶠ 40-40-40ᶠᶠ 40-40-40ᶠᶠ
425
+ `;
426
+
427
+ exports[`Resize images > mutch contrast 4x4 > to default 6x6 1`] = `
428
+ Visualization:
429
+
430
+ ▩▩▩◇▥▥
431
+ ▩▩▩◇▥▥
432
+ ▩▩▩◇▥▥
433
+ ◇◇◇▴33
434
+ ▥▥▥3▩▩
435
+ ▥▥▥3▩▩
436
+
437
+ Data:
438
+
439
+ 40-40-40ᶠᶠ 40-40-40ᶠᶠ 40-40-40ᶠᶠ 95-95-95ᶠᶠ BF-BF-BFᶠᶠ BF-BF-BFᶠᶠ
440
+ 40-40-40ᶠᶠ 40-40-40ᶠᶠ 40-40-40ᶠᶠ 95-95-95ᶠᶠ BF-BF-BFᶠᶠ BF-BF-BFᶠᶠ
441
+ 40-40-40ᶠᶠ 40-40-40ᶠᶠ 40-40-40ᶠᶠ 95-95-95ᶠᶠ BF-BF-BFᶠᶠ BF-BF-BFᶠᶠ
442
+ 95-95-95ᶠᶠ 95-95-95ᶠᶠ 95-95-95ᶠᶠ 78-78-78ᶠᶠ 6A-6A-6Aᶠᶠ 6A-6A-6Aᶠᶠ
443
+ BF-BF-BFᶠᶠ BF-BF-BFᶠᶠ BF-BF-BFᶠᶠ 6A-6A-6Aᶠᶠ 40-40-40ᶠᶠ 40-40-40ᶠᶠ
444
+ BF-BF-BFᶠᶠ BF-BF-BFᶠᶠ BF-BF-BFᶠᶠ 6A-6A-6Aᶠᶠ 40-40-40ᶠᶠ 40-40-40ᶠᶠ
445
+ `;
node_modules/@jimp/plugin-resize/src/constants.ts ADDED
@@ -0,0 +1,26 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /**
2
+ * What resizing algorithm to use.
3
+ */
4
+ export enum ResizeStrategy {
5
+ /**
6
+ * Nearest Neighbor resizing is a method used in image processing that assigns the value of the nearest pixel to the output pixel when resizing an image.
7
+ * While fast, it can lead to lower quality outputs with noticeable pixelation, especially at larger scaling factors.
8
+ */
9
+ NEAREST_NEIGHBOR = "nearestNeighbor",
10
+ /**
11
+ * Bilinear resizing is an image scaling method that uses the weighted average of the four nearest pixel values, providing smoother gradients than nearest neighbor resizing.
12
+ * It's computationally more intense than nearest neighbor but results in images of higher quality and fewer artifacts.
13
+ */
14
+ BILINEAR = "bilinearInterpolation",
15
+ /**
16
+ * Bicubic resizing is an image interpolation method that uses the values of the nearest 16 pixels in the input image to calculate the output pixel value, providing even more smoothness and sharpness than bilinear resizing.
17
+ * Although it's computationally more expensive than bilinear and nearest neighbor, it produces higher quality images, making it ideal for photographic image scaling.
18
+ */
19
+ BICUBIC = "bicubicInterpolation",
20
+ /**
21
+ * Hermite resizing is an image resizing method that uses Hermite interpolation, a mathematical formula, to determine the values of output pixels based on a weighted average of the surrounding pixels.
22
+ * Although slower than some simpler techniques like bilinear or nearest neighbor, Hermite resizing can produce higher quality visuals and detailed renderings with less blurring.
23
+ */
24
+ HERMITE = "hermiteInterpolation",
25
+ BEZIER = "bezierInterpolation",
26
+ }
node_modules/@jimp/plugin-resize/src/index.test.ts ADDED
@@ -0,0 +1,101 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import { expect, test, describe } from "vitest";
2
+
3
+ import { makeTestImage } from "@jimp/test-utils";
4
+ import { createJimp } from "@jimp/core";
5
+
6
+ import { methods, ResizeStrategy } from "./index.js";
7
+
8
+ const jimp = createJimp({ plugins: [methods], formats: [] });
9
+
10
+ describe("Resize images", () => {
11
+ const testImages = [
12
+ {
13
+ title: "max contrast 8x8",
14
+ src: jimp.fromBitmap(
15
+ makeTestImage(
16
+ "■■■■□□□□",
17
+ "■■■■□□□□",
18
+ "■■■■□□□□",
19
+ "■■■■□□□□",
20
+ "□□□□■■■■",
21
+ "□□□□■■■■",
22
+ "□□□□■■■■",
23
+ "□□□□■■■■"
24
+ )
25
+ ),
26
+ tests: [
27
+ { mode: "default", size: { height: 4, width: 4 } },
28
+ { mode: "NEAREST_NEIGHBOR", size: { height: 4, width: 4 } },
29
+ { mode: "BILINEAR", size: { height: 4, width: 4 } },
30
+ { mode: "BICUBIC", size: { height: 4, width: 4 } },
31
+ { mode: "HERMITE", size: { height: 4, width: 4 } },
32
+ { mode: "BEZIER", size: { height: 4, width: 4 } },
33
+ { mode: "default", size: { height: 5, width: 2 } },
34
+ { mode: "NEAREST_NEIGHBOR", size: { height: 5, width: 2 } },
35
+ { mode: "BILINEAR", size: { height: 5, width: 2 } },
36
+ { mode: "BICUBIC", size: { height: 5, width: 2 } },
37
+ { mode: "HERMITE", size: { height: 5, width: 2 } },
38
+ { mode: "BEZIER", size: { height: 5, width: 2 } },
39
+ ],
40
+ },
41
+ /**********************************************************************/
42
+ {
43
+ title: "max contrast 12x12 with dots",
44
+ src: jimp.fromBitmap(
45
+ makeTestImage(
46
+ "■■■■■■□□□□□□",
47
+ "■■■■■■□□□□□□",
48
+ "■■■□■■□□■□□□",
49
+ "■■■■■■□□□□□□",
50
+ "■■■■■■□□□□□□",
51
+ "■■■■■■□□□□□□",
52
+ "□□□□□□■■■■■■",
53
+ "□□□□□□■■■■■■",
54
+ "□□□□□□■■■■■■",
55
+ "□□□■□□■■□■■■",
56
+ "□□□□□□■■■■■■",
57
+ "□□□□□□■■■■■■"
58
+ )
59
+ ),
60
+ tests: [
61
+ { mode: "default", size: { height: 6, width: 6 } },
62
+ { mode: "NEAREST_NEIGHBOR", size: { height: 6, width: 6 } },
63
+ { mode: "BILINEAR", size: { height: 6, width: 6 } },
64
+ { mode: "BICUBIC", size: { height: 6, width: 6 } },
65
+ { mode: "HERMITE", size: { height: 6, width: 6 } },
66
+ { mode: "BEZIER", size: { height: 6, width: 6 } },
67
+ ],
68
+ },
69
+ /**********************************************************************/
70
+ {
71
+ title: "mutch contrast 4x4",
72
+ src: jimp.fromBitmap(makeTestImage("▩▩▥▥", "▩▩▥▥", "▥▥▩▩", "▥▥▩▩")),
73
+ tests: [
74
+ { mode: "default", size: { height: 6, width: 6 } },
75
+ { mode: "NEAREST_NEIGHBOR", size: { height: 6, width: 6 } },
76
+ { mode: "BILINEAR", size: { height: 6, width: 6 } },
77
+ { mode: "BICUBIC", size: { height: 6, width: 6 } },
78
+ { mode: "HERMITE", size: { height: 6, width: 6 } },
79
+ { mode: "BEZIER", size: { height: 6, width: 6 } },
80
+ ],
81
+ },
82
+ ];
83
+
84
+ testImages.forEach((image) => {
85
+ describe(image.title, () => {
86
+ image.tests.forEach(({ mode: modeType, size }) => {
87
+ test(`to ${modeType} ${size.width}x${size.height}`, () => {
88
+ const mode = ResizeStrategy[modeType as keyof typeof ResizeStrategy];
89
+
90
+ expect(
91
+ image.src.clone().resize({
92
+ w: size.width,
93
+ h: size.height,
94
+ mode,
95
+ })
96
+ ).toMatchSnapshot();
97
+ });
98
+ });
99
+ });
100
+ });
101
+ });
node_modules/@jimp/plugin-resize/src/index.ts ADDED
@@ -0,0 +1,176 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import { JimpClass } from "@jimp/types";
2
+ import { ResizeStrategy } from "./constants.js";
3
+ import { z } from "zod";
4
+
5
+ import Resize from "./modules/resize.js";
6
+ import { operations as Resize2 } from "./modules/resize2.js";
7
+
8
+ export * from "./constants.js";
9
+
10
+ interface ResizeClass {
11
+ // eslint-disable-next-line @typescript-eslint/no-misused-new
12
+ new (
13
+ widthOriginal: number,
14
+ heightOriginal: number,
15
+ targetWidth: number,
16
+ targetHeight: number,
17
+ blendAlpha: boolean,
18
+ interpolationPass: boolean,
19
+ resizeCallback: (buffer: Buffer) => void
20
+ ): ResizeClass;
21
+ resize(buffer: Buffer): void;
22
+ }
23
+
24
+ type Constructable<T> = new (...args: unknown[]) => T;
25
+
26
+ const ResizeOptionsSchema = z.union([
27
+ z.object({
28
+ /** the width to resize the image to */
29
+ w: z.number().min(0),
30
+ /** the height to resize the image to */
31
+ h: z.number().min(0).optional(),
32
+ /** a scaling method (e.g. ResizeStrategy.BEZIER) */
33
+ mode: z.nativeEnum(ResizeStrategy).optional(),
34
+ }),
35
+ z.object({
36
+ /** the width to resize the image to */
37
+ w: z.number().min(0).optional(),
38
+ /** the height to resize the image to */
39
+ h: z.number().min(0),
40
+ /** a scaling method (e.g. ResizeStrategy.BEZIER) */
41
+ mode: z.nativeEnum(ResizeStrategy).optional(),
42
+ }),
43
+ ]);
44
+
45
+ export type ResizeOptions = z.infer<typeof ResizeOptionsSchema>;
46
+
47
+ const ScaleToFitOptionsSchema = z.object({
48
+ /** the width to resize the image to */
49
+ w: z.number().min(0),
50
+ /** the height to resize the image to */
51
+ h: z.number().min(0),
52
+ /** a scaling method (e.g. Jimp.RESIZE_BEZIER) */
53
+ mode: z.nativeEnum(ResizeStrategy).optional(),
54
+ });
55
+
56
+ export type ScaleToFitOptions = z.infer<typeof ScaleToFitOptionsSchema>;
57
+
58
+ const ScaleComplexOptionsSchema = z.object({
59
+ /** the width to resize the image to */
60
+ f: z.number().min(0),
61
+ /** a scaling method (e.g. Jimp.RESIZE_BEZIER) */
62
+ mode: z.nativeEnum(ResizeStrategy).optional(),
63
+ });
64
+
65
+ export type ScaleComplexOptions = z.infer<typeof ScaleComplexOptionsSchema>;
66
+ export type ScaleOptions = number | ScaleComplexOptions;
67
+
68
+ export const methods = {
69
+ /**
70
+ * Resizes the image to a set width and height using a 2-pass bilinear algorithm
71
+ * @example
72
+ * ```ts
73
+ * import { Jimp } from "jimp";
74
+ *
75
+ * const image = await Jimp.read("test/image.png");
76
+ *
77
+ * image.resize({ w: 150 });
78
+ * ```
79
+ */
80
+ resize<I extends JimpClass>(image: I, options: ResizeOptions) {
81
+ const { mode } = ResizeOptionsSchema.parse(options);
82
+
83
+ let w: number;
84
+ let h: number;
85
+
86
+ if (typeof options.w === "number") {
87
+ w = options.w;
88
+ h = options.h ?? image.bitmap.height * (w / image.bitmap.width);
89
+ } else if (typeof options.h === "number") {
90
+ h = options.h;
91
+ w = options.w ?? image.bitmap.width * (h / image.bitmap.height);
92
+ } else {
93
+ throw new Error("w must be a number");
94
+ }
95
+
96
+ // round inputs
97
+ w = Math.round(w) || 1;
98
+ h = Math.round(h) || 1;
99
+
100
+ if (mode && typeof Resize2[mode] === "function") {
101
+ const dst = {
102
+ data: Buffer.alloc(w * h * 4),
103
+ width: w,
104
+ height: h,
105
+ };
106
+ Resize2[mode](image.bitmap, dst);
107
+ image.bitmap = dst;
108
+ } else {
109
+ const resize = new (Resize as unknown as Constructable<ResizeClass>)(
110
+ image.bitmap.width,
111
+ image.bitmap.height,
112
+ w,
113
+ h,
114
+ true,
115
+ true,
116
+ (buffer: Buffer) => {
117
+ image.bitmap.data = Buffer.from(buffer);
118
+ image.bitmap.width = w;
119
+ image.bitmap.height = h;
120
+ }
121
+ );
122
+
123
+ resize.resize(image.bitmap.data);
124
+ }
125
+
126
+ return image;
127
+ },
128
+
129
+ /**
130
+ * Uniformly scales the image by a factor.
131
+ * @param f the factor to scale the image by
132
+ * @param mode (optional) a scaling method (e.g. Jimp.RESIZE_BEZIER)
133
+ * @example
134
+ * ```ts
135
+ * import { Jimp } from "jimp";
136
+ *
137
+ * const image = await Jimp.read("test/image.png");
138
+ *
139
+ * image.scale(0.5);
140
+ * ```
141
+ */
142
+ scale<I extends JimpClass>(image: I, options: ScaleOptions) {
143
+ const { f, mode } =
144
+ typeof options === "number"
145
+ ? ({ f: options } as ScaleComplexOptions)
146
+ : ScaleComplexOptionsSchema.parse(options);
147
+ const w = image.bitmap.width * f;
148
+ const h = image.bitmap.height * f;
149
+
150
+ return this.resize(image, { w, h, mode: mode });
151
+ },
152
+
153
+ /**
154
+ * Scale the image to the largest size that fits inside the rectangle that has the given width and height.
155
+ * @param w the width to resize the image to
156
+ * @param h the height to resize the image to
157
+ * @param mode a scaling method (e.g. ResizeStrategy.BEZIER)
158
+ * @example
159
+ * ```ts
160
+ * import { Jimp } from "jimp";
161
+ *
162
+ * const image = await Jimp.read("test/image.png");
163
+ *
164
+ * image.scaleToFit(100, 100);
165
+ * ```
166
+ */
167
+ scaleToFit<I extends JimpClass>(image: I, options: ScaleToFitOptions) {
168
+ const { h, w, mode } = ScaleToFitOptionsSchema.parse(options);
169
+ const f =
170
+ w / h > image.bitmap.width / image.bitmap.height
171
+ ? h / image.bitmap.height
172
+ : w / image.bitmap.width;
173
+
174
+ return this.scale(image, { f, mode: mode });
175
+ },
176
+ };
node_modules/@jimp/plugin-resize/src/modules/resize.ts ADDED
@@ -0,0 +1,555 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ // eslint-disable-next-line @typescript-eslint/ban-ts-comment
2
+ // @ts-nocheck
3
+
4
+ // JavaScript Image Resizer (c) 2012 - Grant Galitz
5
+ // Released to public domain 29 July 2013: https://github.com/grantgalitz/JS-Image-Resizer/issues/4
6
+
7
+ function Resize(
8
+ widthOriginal,
9
+ heightOriginal,
10
+ targetWidth,
11
+ targetHeight,
12
+ blendAlpha,
13
+ interpolationPass,
14
+ resizeCallback
15
+ ) {
16
+ this.widthOriginal = Math.abs(Math.floor(widthOriginal) || 0);
17
+ this.heightOriginal = Math.abs(Math.floor(heightOriginal) || 0);
18
+ this.targetWidth = Math.abs(Math.floor(targetWidth) || 0);
19
+ this.targetHeight = Math.abs(Math.floor(targetHeight) || 0);
20
+ this.colorChannels = blendAlpha ? 4 : 3;
21
+ this.interpolationPass = Boolean(interpolationPass);
22
+ this.resizeCallback =
23
+ typeof resizeCallback === "function" ? resizeCallback : function () {};
24
+
25
+ this.targetWidthMultipliedByChannels = this.targetWidth * this.colorChannels;
26
+ this.originalWidthMultipliedByChannels =
27
+ this.widthOriginal * this.colorChannels;
28
+ this.originalHeightMultipliedByChannels =
29
+ this.heightOriginal * this.colorChannels;
30
+ this.widthPassResultSize =
31
+ this.targetWidthMultipliedByChannels * this.heightOriginal;
32
+ this.finalResultSize =
33
+ this.targetWidthMultipliedByChannels * this.targetHeight;
34
+ this.initialize();
35
+ }
36
+
37
+ Resize.prototype.initialize = function () {
38
+ // Perform some checks:
39
+ if (
40
+ this.widthOriginal > 0 &&
41
+ this.heightOriginal > 0 &&
42
+ this.targetWidth > 0 &&
43
+ this.targetHeight > 0
44
+ ) {
45
+ this.configurePasses();
46
+ } else {
47
+ console.log(this);
48
+ throw new Error("Invalid settings specified for the resizer.");
49
+ }
50
+ };
51
+
52
+ Resize.prototype.configurePasses = function () {
53
+ if (this.widthOriginal === this.targetWidth) {
54
+ // Bypass the width resizer pass:
55
+ this.resizeWidth = this.bypassResizer;
56
+ } else {
57
+ // Setup the width resizer pass:
58
+ this.ratioWeightWidthPass = this.widthOriginal / this.targetWidth;
59
+ if (this.ratioWeightWidthPass < 1 && this.interpolationPass) {
60
+ this.initializeFirstPassBuffers(true);
61
+ this.resizeWidth =
62
+ this.colorChannels === 4
63
+ ? this.resizeWidthInterpolatedRGBA
64
+ : this.resizeWidthInterpolatedRGB;
65
+ } else {
66
+ this.initializeFirstPassBuffers(false);
67
+ this.resizeWidth =
68
+ this.colorChannels === 4 ? this.resizeWidthRGBA : this.resizeWidthRGB;
69
+ }
70
+ }
71
+
72
+ if (this.heightOriginal === this.targetHeight) {
73
+ // Bypass the height resizer pass:
74
+ this.resizeHeight = this.bypassResizer;
75
+ } else {
76
+ // Setup the height resizer pass:
77
+ this.ratioWeightHeightPass = this.heightOriginal / this.targetHeight;
78
+ if (this.ratioWeightHeightPass < 1 && this.interpolationPass) {
79
+ this.initializeSecondPassBuffers(true);
80
+ this.resizeHeight = this.resizeHeightInterpolated;
81
+ } else {
82
+ this.initializeSecondPassBuffers(false);
83
+ this.resizeHeight =
84
+ this.colorChannels === 4 ? this.resizeHeightRGBA : this.resizeHeightRGB;
85
+ }
86
+ }
87
+ };
88
+
89
+ Resize.prototype._resizeWidthInterpolatedRGBChannels = function (
90
+ buffer,
91
+ fourthChannel
92
+ ) {
93
+ const channelsNum = fourthChannel ? 4 : 3;
94
+ const ratioWeight = this.ratioWeightWidthPass;
95
+ const outputBuffer = this.widthBuffer;
96
+
97
+ let weight = 0;
98
+ let finalOffset = 0;
99
+ let pixelOffset = 0;
100
+ let firstWeight = 0;
101
+ let secondWeight = 0;
102
+ let targetPosition;
103
+
104
+ // Handle for only one interpolation input being valid for start calculation:
105
+ for (
106
+ targetPosition = 0;
107
+ weight < 1 / 3;
108
+ targetPosition += channelsNum, weight += ratioWeight
109
+ ) {
110
+ for (
111
+ finalOffset = targetPosition, pixelOffset = 0;
112
+ finalOffset < this.widthPassResultSize;
113
+ pixelOffset += this.originalWidthMultipliedByChannels,
114
+ finalOffset += this.targetWidthMultipliedByChannels
115
+ ) {
116
+ outputBuffer[finalOffset] = buffer[pixelOffset];
117
+ outputBuffer[finalOffset + 1] = buffer[pixelOffset + 1];
118
+ outputBuffer[finalOffset + 2] = buffer[pixelOffset + 2];
119
+ if (fourthChannel)
120
+ outputBuffer[finalOffset + 3] = buffer[pixelOffset + 3];
121
+ }
122
+ }
123
+
124
+ // Adjust for overshoot of the last pass's counter:
125
+ weight -= 1 / 3;
126
+ let interpolationWidthSourceReadStop;
127
+
128
+ for (
129
+ interpolationWidthSourceReadStop = this.widthOriginal - 1;
130
+ weight < interpolationWidthSourceReadStop;
131
+ targetPosition += channelsNum, weight += ratioWeight
132
+ ) {
133
+ // Calculate weightings:
134
+ secondWeight = weight % 1;
135
+ firstWeight = 1 - secondWeight;
136
+ // Interpolate:
137
+ for (
138
+ finalOffset = targetPosition,
139
+ pixelOffset = Math.floor(weight) * channelsNum;
140
+ finalOffset < this.widthPassResultSize;
141
+ pixelOffset += this.originalWidthMultipliedByChannels,
142
+ finalOffset += this.targetWidthMultipliedByChannels
143
+ ) {
144
+ outputBuffer[finalOffset + 0] =
145
+ buffer[pixelOffset + 0] * firstWeight +
146
+ buffer[pixelOffset + channelsNum + 0] * secondWeight;
147
+ outputBuffer[finalOffset + 1] =
148
+ buffer[pixelOffset + 1] * firstWeight +
149
+ buffer[pixelOffset + channelsNum + 1] * secondWeight;
150
+ outputBuffer[finalOffset + 2] =
151
+ buffer[pixelOffset + 2] * firstWeight +
152
+ buffer[pixelOffset + channelsNum + 2] * secondWeight;
153
+ if (fourthChannel)
154
+ outputBuffer[finalOffset + 3] =
155
+ buffer[pixelOffset + 3] * firstWeight +
156
+ buffer[pixelOffset + channelsNum + 3] * secondWeight;
157
+ }
158
+ }
159
+
160
+ // Handle for only one interpolation input being valid for end calculation:
161
+ for (
162
+ interpolationWidthSourceReadStop =
163
+ this.originalWidthMultipliedByChannels - channelsNum;
164
+ targetPosition < this.targetWidthMultipliedByChannels;
165
+ targetPosition += channelsNum
166
+ ) {
167
+ for (
168
+ finalOffset = targetPosition,
169
+ pixelOffset = interpolationWidthSourceReadStop;
170
+ finalOffset < this.widthPassResultSize;
171
+ pixelOffset += this.originalWidthMultipliedByChannels,
172
+ finalOffset += this.targetWidthMultipliedByChannels
173
+ ) {
174
+ outputBuffer[finalOffset] = buffer[pixelOffset];
175
+ outputBuffer[finalOffset + 1] = buffer[pixelOffset + 1];
176
+ outputBuffer[finalOffset + 2] = buffer[pixelOffset + 2];
177
+ if (fourthChannel)
178
+ outputBuffer[finalOffset + 3] = buffer[pixelOffset + 3];
179
+ }
180
+ }
181
+
182
+ return outputBuffer;
183
+ };
184
+
185
+ Resize.prototype._resizeWidthRGBChannels = function (buffer, fourthChannel) {
186
+ const channelsNum = fourthChannel ? 4 : 3;
187
+ const ratioWeight = this.ratioWeightWidthPass;
188
+ const ratioWeightDivisor = 1 / ratioWeight;
189
+ const nextLineOffsetOriginalWidth =
190
+ this.originalWidthMultipliedByChannels - channelsNum + 1;
191
+ const nextLineOffsetTargetWidth =
192
+ this.targetWidthMultipliedByChannels - channelsNum + 1;
193
+ const output = this.outputWidthWorkBench;
194
+ const outputBuffer = this.widthBuffer;
195
+ const trustworthyColorsCount = this.outputWidthWorkBenchOpaquePixelsCount;
196
+
197
+ let weight = 0;
198
+ let amountToNext = 0;
199
+ let actualPosition = 0;
200
+ let currentPosition = 0;
201
+ let line = 0;
202
+ let pixelOffset = 0;
203
+ let outputOffset = 0;
204
+ let multiplier = 1;
205
+ let r = 0;
206
+ let g = 0;
207
+ let b = 0;
208
+ let a = 0;
209
+
210
+ do {
211
+ for (line = 0; line < this.originalHeightMultipliedByChannels; ) {
212
+ output[line++] = 0;
213
+ output[line++] = 0;
214
+ output[line++] = 0;
215
+ if (fourthChannel) {
216
+ output[line++] = 0;
217
+ trustworthyColorsCount[line / channelsNum - 1] = 0;
218
+ }
219
+ }
220
+
221
+ weight = ratioWeight;
222
+
223
+ do {
224
+ amountToNext = 1 + actualPosition - currentPosition;
225
+ multiplier = Math.min(weight, amountToNext);
226
+ for (
227
+ line = 0, pixelOffset = actualPosition;
228
+ line < this.originalHeightMultipliedByChannels;
229
+ pixelOffset += nextLineOffsetOriginalWidth
230
+ ) {
231
+ r = buffer[pixelOffset];
232
+ g = buffer[++pixelOffset];
233
+ b = buffer[++pixelOffset];
234
+ a = fourthChannel ? buffer[++pixelOffset] : 255;
235
+ // Ignore RGB values if pixel is completely transparent
236
+ output[line++] += (a ? r : 0) * multiplier;
237
+ output[line++] += (a ? g : 0) * multiplier;
238
+ output[line++] += (a ? b : 0) * multiplier;
239
+ if (fourthChannel) {
240
+ output[line++] += a * multiplier;
241
+ trustworthyColorsCount[line / channelsNum - 1] += a ? multiplier : 0;
242
+ }
243
+ }
244
+
245
+ if (weight >= amountToNext) {
246
+ actualPosition += channelsNum;
247
+ currentPosition = actualPosition;
248
+ weight -= amountToNext;
249
+ } else {
250
+ currentPosition += weight;
251
+ break;
252
+ }
253
+ } while (
254
+ weight > 0 &&
255
+ actualPosition < this.originalWidthMultipliedByChannels
256
+ );
257
+
258
+ for (
259
+ line = 0, pixelOffset = outputOffset;
260
+ line < this.originalHeightMultipliedByChannels;
261
+ pixelOffset += nextLineOffsetTargetWidth
262
+ ) {
263
+ weight = fourthChannel ? trustworthyColorsCount[line / channelsNum] : 1;
264
+ multiplier = fourthChannel
265
+ ? weight
266
+ ? 1 / weight
267
+ : 0
268
+ : ratioWeightDivisor;
269
+ outputBuffer[pixelOffset] = output[line++] * multiplier;
270
+ outputBuffer[++pixelOffset] = output[line++] * multiplier;
271
+ outputBuffer[++pixelOffset] = output[line++] * multiplier;
272
+ if (fourthChannel)
273
+ outputBuffer[++pixelOffset] = output[line++] * ratioWeightDivisor;
274
+ }
275
+
276
+ outputOffset += channelsNum;
277
+ } while (outputOffset < this.targetWidthMultipliedByChannels);
278
+
279
+ return outputBuffer;
280
+ };
281
+
282
+ Resize.prototype._resizeHeightRGBChannels = function (buffer, fourthChannel) {
283
+ const ratioWeight = this.ratioWeightHeightPass;
284
+ const ratioWeightDivisor = 1 / ratioWeight;
285
+ const output = this.outputHeightWorkBench;
286
+ const outputBuffer = this.heightBuffer;
287
+ const trustworthyColorsCount = this.outputHeightWorkBenchOpaquePixelsCount;
288
+
289
+ let weight = 0;
290
+ let amountToNext = 0;
291
+ let actualPosition = 0;
292
+ let currentPosition = 0;
293
+ let pixelOffset = 0;
294
+ let outputOffset = 0;
295
+ let caret = 0;
296
+ let multiplier = 1;
297
+ let r = 0;
298
+ let g = 0;
299
+ let b = 0;
300
+ let a = 0;
301
+
302
+ do {
303
+ for (
304
+ pixelOffset = 0;
305
+ pixelOffset < this.targetWidthMultipliedByChannels;
306
+
307
+ ) {
308
+ output[pixelOffset++] = 0;
309
+ output[pixelOffset++] = 0;
310
+ output[pixelOffset++] = 0;
311
+
312
+ if (fourthChannel) {
313
+ output[pixelOffset++] = 0;
314
+ trustworthyColorsCount[pixelOffset / 4 - 1] = 0;
315
+ }
316
+ }
317
+
318
+ weight = ratioWeight;
319
+
320
+ do {
321
+ amountToNext = 1 + actualPosition - currentPosition;
322
+ multiplier = Math.min(weight, amountToNext);
323
+ caret = actualPosition;
324
+
325
+ for (
326
+ pixelOffset = 0;
327
+ pixelOffset < this.targetWidthMultipliedByChannels;
328
+
329
+ ) {
330
+ r = buffer[caret++];
331
+ g = buffer[caret++];
332
+ b = buffer[caret++];
333
+ a = fourthChannel ? buffer[caret++] : 255;
334
+ // Ignore RGB values if pixel is completely transparent
335
+ output[pixelOffset++] += (a ? r : 0) * multiplier;
336
+ output[pixelOffset++] += (a ? g : 0) * multiplier;
337
+ output[pixelOffset++] += (a ? b : 0) * multiplier;
338
+
339
+ if (fourthChannel) {
340
+ output[pixelOffset++] += a * multiplier;
341
+ trustworthyColorsCount[pixelOffset / 4 - 1] += a ? multiplier : 0;
342
+ }
343
+ }
344
+
345
+ if (weight >= amountToNext) {
346
+ actualPosition = caret;
347
+ currentPosition = actualPosition;
348
+ weight -= amountToNext;
349
+ } else {
350
+ currentPosition += weight;
351
+ break;
352
+ }
353
+ } while (weight > 0 && actualPosition < this.widthPassResultSize);
354
+
355
+ for (
356
+ pixelOffset = 0;
357
+ pixelOffset < this.targetWidthMultipliedByChannels;
358
+
359
+ ) {
360
+ weight = fourthChannel ? trustworthyColorsCount[pixelOffset / 4] : 1;
361
+ multiplier = fourthChannel
362
+ ? weight
363
+ ? 1 / weight
364
+ : 0
365
+ : ratioWeightDivisor;
366
+ outputBuffer[outputOffset++] = Math.round(
367
+ output[pixelOffset++] * multiplier
368
+ );
369
+ outputBuffer[outputOffset++] = Math.round(
370
+ output[pixelOffset++] * multiplier
371
+ );
372
+ outputBuffer[outputOffset++] = Math.round(
373
+ output[pixelOffset++] * multiplier
374
+ );
375
+
376
+ if (fourthChannel) {
377
+ outputBuffer[outputOffset++] = Math.round(
378
+ output[pixelOffset++] * ratioWeightDivisor
379
+ );
380
+ }
381
+ }
382
+ } while (outputOffset < this.finalResultSize);
383
+
384
+ return outputBuffer;
385
+ };
386
+
387
+ Resize.prototype.resizeWidthInterpolatedRGB = function (buffer) {
388
+ return this._resizeWidthInterpolatedRGBChannels(buffer, false);
389
+ };
390
+
391
+ Resize.prototype.resizeWidthInterpolatedRGBA = function (buffer) {
392
+ return this._resizeWidthInterpolatedRGBChannels(buffer, true);
393
+ };
394
+
395
+ Resize.prototype.resizeWidthRGB = function (buffer) {
396
+ return this._resizeWidthRGBChannels(buffer, false);
397
+ };
398
+
399
+ Resize.prototype.resizeWidthRGBA = function (buffer) {
400
+ return this._resizeWidthRGBChannels(buffer, true);
401
+ };
402
+
403
+ Resize.prototype.resizeHeightInterpolated = function (buffer) {
404
+ const ratioWeight = this.ratioWeightHeightPass;
405
+ const outputBuffer = this.heightBuffer;
406
+
407
+ let weight = 0;
408
+ let finalOffset = 0;
409
+ let pixelOffset = 0;
410
+ let pixelOffsetAccumulated = 0;
411
+ let pixelOffsetAccumulated2 = 0;
412
+ let firstWeight = 0;
413
+ let secondWeight = 0;
414
+ let interpolationHeightSourceReadStop;
415
+
416
+ // Handle for only one interpolation input being valid for start calculation:
417
+ for (; weight < 1 / 3; weight += ratioWeight) {
418
+ for (
419
+ pixelOffset = 0;
420
+ pixelOffset < this.targetWidthMultipliedByChannels;
421
+
422
+ ) {
423
+ outputBuffer[finalOffset++] = Math.round(buffer[pixelOffset++]);
424
+ }
425
+ }
426
+
427
+ // Adjust for overshoot of the last pass's counter:
428
+ weight -= 1 / 3;
429
+
430
+ for (
431
+ interpolationHeightSourceReadStop = this.heightOriginal - 1;
432
+ weight < interpolationHeightSourceReadStop;
433
+ weight += ratioWeight
434
+ ) {
435
+ // Calculate weightings:
436
+ secondWeight = weight % 1;
437
+ firstWeight = 1 - secondWeight;
438
+ // Interpolate:
439
+ pixelOffsetAccumulated =
440
+ Math.floor(weight) * this.targetWidthMultipliedByChannels;
441
+ pixelOffsetAccumulated2 =
442
+ pixelOffsetAccumulated + this.targetWidthMultipliedByChannels;
443
+ for (
444
+ pixelOffset = 0;
445
+ pixelOffset < this.targetWidthMultipliedByChannels;
446
+ ++pixelOffset
447
+ ) {
448
+ outputBuffer[finalOffset++] = Math.round(
449
+ buffer[pixelOffsetAccumulated++] * firstWeight +
450
+ buffer[pixelOffsetAccumulated2++] * secondWeight
451
+ );
452
+ }
453
+ }
454
+
455
+ // Handle for only one interpolation input being valid for end calculation:
456
+ while (finalOffset < this.finalResultSize) {
457
+ for (
458
+ pixelOffset = 0,
459
+ pixelOffsetAccumulated =
460
+ interpolationHeightSourceReadStop *
461
+ this.targetWidthMultipliedByChannels;
462
+ pixelOffset < this.targetWidthMultipliedByChannels;
463
+ ++pixelOffset
464
+ ) {
465
+ outputBuffer[finalOffset++] = Math.round(
466
+ buffer[pixelOffsetAccumulated++]
467
+ );
468
+ }
469
+ }
470
+
471
+ return outputBuffer;
472
+ };
473
+
474
+ Resize.prototype.resizeHeightRGB = function (buffer) {
475
+ return this._resizeHeightRGBChannels(buffer, false);
476
+ };
477
+
478
+ Resize.prototype.resizeHeightRGBA = function (buffer) {
479
+ return this._resizeHeightRGBChannels(buffer, true);
480
+ };
481
+
482
+ Resize.prototype.resize = function (buffer) {
483
+ this.resizeCallback(this.resizeHeight(this.resizeWidth(buffer)));
484
+ };
485
+
486
+ Resize.prototype.bypassResizer = function (buffer) {
487
+ // Just return the buffer passed:
488
+ return buffer;
489
+ };
490
+
491
+ Resize.prototype.initializeFirstPassBuffers = function (BILINEARAlgo) {
492
+ // Initialize the internal width pass buffers:
493
+ this.widthBuffer = this.generateFloatBuffer(this.widthPassResultSize);
494
+
495
+ if (!BILINEARAlgo) {
496
+ this.outputWidthWorkBench = this.generateFloatBuffer(
497
+ this.originalHeightMultipliedByChannels
498
+ );
499
+
500
+ if (this.colorChannels > 3) {
501
+ this.outputWidthWorkBenchOpaquePixelsCount = this.generateFloat64Buffer(
502
+ this.heightOriginal
503
+ );
504
+ }
505
+ }
506
+ };
507
+
508
+ Resize.prototype.initializeSecondPassBuffers = function (BILINEARAlgo) {
509
+ // Initialize the internal height pass buffers:
510
+ this.heightBuffer = this.generateUint8Buffer(this.finalResultSize);
511
+
512
+ if (!BILINEARAlgo) {
513
+ this.outputHeightWorkBench = this.generateFloatBuffer(
514
+ this.targetWidthMultipliedByChannels
515
+ );
516
+
517
+ if (this.colorChannels > 3) {
518
+ this.outputHeightWorkBenchOpaquePixelsCount = this.generateFloat64Buffer(
519
+ this.targetWidth
520
+ );
521
+ }
522
+ }
523
+ };
524
+
525
+ Resize.prototype.generateFloatBuffer = function (bufferLength) {
526
+ // Generate a float32 typed array buffer:
527
+ try {
528
+ return new Float32Array(bufferLength);
529
+ } catch (error) {
530
+ console.error(error);
531
+ return [];
532
+ }
533
+ };
534
+
535
+ Resize.prototype.generateFloat64Buffer = function (bufferLength) {
536
+ // Generate a float64 typed array buffer:
537
+ try {
538
+ return new Float64Array(bufferLength);
539
+ } catch (error) {
540
+ console.error(error);
541
+ return [];
542
+ }
543
+ };
544
+
545
+ Resize.prototype.generateUint8Buffer = function (bufferLength) {
546
+ // Generate a uint8 typed array buffer:
547
+ try {
548
+ return new Uint8Array(bufferLength);
549
+ } catch (error) {
550
+ console.error(error);
551
+ return [];
552
+ }
553
+ };
554
+
555
+ export default Resize;
node_modules/@jimp/plugin-resize/src/modules/resize2.ts ADDED
@@ -0,0 +1,327 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /* eslint-disable @typescript-eslint/no-explicit-any */
2
+ /**
3
+ * Copyright (c) 2015 Guyon Roche
4
+ *
5
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ * of this software and associated documentation files (the "Software"), to deal
7
+ * in the Software without restriction, including without limitation the rights
8
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ * copies of the Software, and to permit persons to whom the Software is
10
+ * furnished to do so, subject to the following conditions:</p>
11
+ *
12
+ * The above copyright notice and this permission notice shall be included in
13
+ * all copies or substantial portions of the Software.
14
+ *
15
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ * THE SOFTWARE.
22
+ */
23
+
24
+ export const operations = {
25
+ nearestNeighbor(src: any, dst: any) {
26
+ const wSrc = src.width;
27
+ const hSrc = src.height;
28
+
29
+ const wDst = dst.width;
30
+ const hDst = dst.height;
31
+
32
+ const bufSrc = src.data;
33
+ const bufDst = dst.data;
34
+
35
+ for (let i = 0; i < hDst; i++) {
36
+ for (let j = 0; j < wDst; j++) {
37
+ let posDst = (i * wDst + j) * 4;
38
+
39
+ const iSrc = Math.floor((i * hSrc) / hDst);
40
+ const jSrc = Math.floor((j * wSrc) / wDst);
41
+ let posSrc = (iSrc * wSrc + jSrc) * 4;
42
+
43
+ bufDst[posDst++] = bufSrc[posSrc++];
44
+ bufDst[posDst++] = bufSrc[posSrc++];
45
+ bufDst[posDst++] = bufSrc[posSrc++];
46
+ bufDst[posDst++] = bufSrc[posSrc++];
47
+ }
48
+ }
49
+ },
50
+
51
+ bilinearInterpolation(src: any, dst: any) {
52
+ const wSrc = src.width;
53
+ const hSrc = src.height;
54
+
55
+ const wDst = dst.width;
56
+ const hDst = dst.height;
57
+
58
+ const bufSrc = src.data;
59
+ const bufDst = dst.data;
60
+
61
+ const interpolate = function (
62
+ k: number,
63
+ kMin: number,
64
+ vMin: number,
65
+ kMax: number,
66
+ vMax: number,
67
+ ) {
68
+ // special case - k is integer
69
+ if (kMin === kMax) {
70
+ return vMin;
71
+ }
72
+
73
+ return Math.round((k - kMin) * vMax + (kMax - k) * vMin);
74
+ };
75
+
76
+ const assign = function (
77
+ pos: number,
78
+ offset: number,
79
+ x: number,
80
+ xMin: number,
81
+ xMax: number,
82
+ y: number,
83
+ yMin: number,
84
+ yMax: number,
85
+ ) {
86
+ let posMin = (yMin * wSrc + xMin) * 4 + offset;
87
+ let posMax = (yMin * wSrc + xMax) * 4 + offset;
88
+ const vMin = interpolate(x, xMin, bufSrc[posMin], xMax, bufSrc[posMax]);
89
+
90
+ // special case, y is integer
91
+ if (yMax === yMin) {
92
+ bufDst[pos + offset] = vMin;
93
+ } else {
94
+ posMin = (yMax * wSrc + xMin) * 4 + offset;
95
+ posMax = (yMax * wSrc + xMax) * 4 + offset;
96
+ const vMax = interpolate(x, xMin, bufSrc[posMin], xMax, bufSrc[posMax]);
97
+
98
+ bufDst[pos + offset] = interpolate(y, yMin, vMin, yMax, vMax);
99
+ }
100
+ };
101
+
102
+ for (let i = 0; i < hDst; i++) {
103
+ for (let j = 0; j < wDst; j++) {
104
+ const posDst = (i * wDst + j) * 4;
105
+ // x & y in src coordinates
106
+ const x = (j * wSrc) / wDst;
107
+ const xMin = Math.floor(x);
108
+ const xMax = Math.min(Math.ceil(x), wSrc - 1);
109
+
110
+ const y = (i * hSrc) / hDst;
111
+ const yMin = Math.floor(y);
112
+ const yMax = Math.min(Math.ceil(y), hSrc - 1);
113
+
114
+ assign(posDst, 0, x, xMin, xMax, y, yMin, yMax);
115
+ assign(posDst, 1, x, xMin, xMax, y, yMin, yMax);
116
+ assign(posDst, 2, x, xMin, xMax, y, yMin, yMax);
117
+ assign(posDst, 3, x, xMin, xMax, y, yMin, yMax);
118
+ }
119
+ }
120
+ },
121
+
122
+ _interpolate2D(src: any, dst: any, options?: any, interpolate?: any) {
123
+ const bufSrc = src.data;
124
+ const bufDst = dst.data;
125
+
126
+ const wSrc = src.width;
127
+ const hSrc = src.height;
128
+
129
+ const wDst = dst.width;
130
+ const hDst = dst.height;
131
+
132
+ // when dst smaller than src/2, interpolate first to a multiple between 0.5 and 1.0 src, then sum squares
133
+ const wM = Math.max(1, Math.floor(wSrc / wDst));
134
+ const wDst2 = wDst * wM;
135
+ const hM = Math.max(1, Math.floor(hSrc / hDst));
136
+ const hDst2 = hDst * hM;
137
+
138
+ // ===========================================================
139
+ // Pass 1 - interpolate rows
140
+ // buf1 has width of dst2 and height of src
141
+ const buf1 = Buffer.alloc(wDst2 * hSrc * 4);
142
+ for (let i = 0; i < hSrc; i++) {
143
+ for (let j = 0; j < wDst2; j++) {
144
+ // i in src coords, j in dst coords
145
+
146
+ // calculate x in src coords
147
+ // this interpolation requires 4 sample points and the two inner ones must be real
148
+ // the outer points can be fudged for the edges.
149
+ // therefore (wSrc-1)/wDst2
150
+ const x = (j * (wSrc - 1)) / wDst2;
151
+ const xPos = Math.floor(x);
152
+ const t = x - xPos;
153
+ const srcPos = (i * wSrc + xPos) * 4;
154
+ const buf1Pos = (i * wDst2 + j) * 4;
155
+
156
+ for (let k = 0; k < 4; k++) {
157
+ const kPos = srcPos + k;
158
+ const x0 =
159
+ xPos > 0 ? bufSrc[kPos - 4] : 2 * bufSrc[kPos] - bufSrc[kPos + 4];
160
+ const x1 = bufSrc[kPos];
161
+ const x2 = bufSrc[kPos + 4];
162
+ const x3 =
163
+ xPos < wSrc - 2
164
+ ? bufSrc[kPos + 8]
165
+ : 2 * bufSrc[kPos + 4] - bufSrc[kPos];
166
+ buf1[buf1Pos + k] = interpolate(x0, x1, x2, x3, t);
167
+ }
168
+ }
169
+ }
170
+ // this._writeFile(wDst2, hSrc, buf1, "out/buf1.jpg");
171
+
172
+ // ===========================================================
173
+ // Pass 2 - interpolate columns
174
+ // buf2 has width and height of dst2
175
+ const buf2 = Buffer.alloc(wDst2 * hDst2 * 4);
176
+ for (let i = 0; i < hDst2; i++) {
177
+ for (let j = 0; j < wDst2; j++) {
178
+ // i&j in dst2 coords
179
+
180
+ // calculate y in buf1 coords
181
+ // this interpolation requires 4 sample points and the two inner ones must be real
182
+ // the outer points can be fudged for the edges.
183
+ // therefore (hSrc-1)/hDst2
184
+ const y = (i * (hSrc - 1)) / hDst2;
185
+ const yPos = Math.floor(y);
186
+ const t = y - yPos;
187
+ const buf1Pos = (yPos * wDst2 + j) * 4;
188
+ const buf2Pos = (i * wDst2 + j) * 4;
189
+ for (let k = 0; k < 4; k++) {
190
+ const kPos = buf1Pos + k;
191
+ const y0 =
192
+ yPos > 0
193
+ ? buf1[kPos - wDst2 * 4]
194
+ : 2 * buf1[kPos]! - buf1[kPos + wDst2 * 4]!;
195
+ const y1 = buf1[kPos];
196
+ const y2 = buf1[kPos + wDst2 * 4];
197
+ const y3 =
198
+ yPos < hSrc - 2
199
+ ? buf1[kPos + wDst2 * 8]
200
+ : 2 * buf1[kPos + wDst2 * 4]! - buf1[kPos]!;
201
+
202
+ buf2[buf2Pos + k] = interpolate(y0, y1, y2, y3, t);
203
+ }
204
+ }
205
+ }
206
+ // this._writeFile(wDst2, hDst2, buf2, "out/buf2.jpg");
207
+
208
+ // ===========================================================
209
+ // Pass 3 - scale to dst
210
+ const m = wM * hM;
211
+ if (m > 1) {
212
+ for (let i = 0; i < hDst; i++) {
213
+ for (let j = 0; j < wDst; j++) {
214
+ // i&j in dst bounded coords
215
+ let r = 0;
216
+ let g = 0;
217
+ let b = 0;
218
+ let a = 0;
219
+ let realColors = 0;
220
+
221
+ for (let y = 0; y < hM; y++) {
222
+ const yPos = i * hM + y;
223
+
224
+ for (let x = 0; x < wM; x++) {
225
+ const xPos = j * wM + x;
226
+ const xyPos = (yPos * wDst2 + xPos) * 4;
227
+ const pixelAlpha = buf2[xyPos + 3]!;
228
+
229
+ if (pixelAlpha) {
230
+ r += buf2[xyPos]!;
231
+ g += buf2[xyPos + 1]!;
232
+ b += buf2[xyPos + 2]!;
233
+ realColors++;
234
+ }
235
+
236
+ a += pixelAlpha;
237
+ }
238
+ }
239
+
240
+ const pos = (i * wDst + j) * 4;
241
+ bufDst[pos] = realColors ? Math.round(r / realColors) : 0;
242
+ bufDst[pos + 1] = realColors ? Math.round(g / realColors) : 0;
243
+ bufDst[pos + 2] = realColors ? Math.round(b / realColors) : 0;
244
+ bufDst[pos + 3] = Math.round(a / m);
245
+ }
246
+ }
247
+ } else {
248
+ // replace dst buffer with buf2
249
+ dst.data = buf2;
250
+ }
251
+ },
252
+
253
+ bicubicInterpolation(src: any, dst: any, options?: any) {
254
+ const interpolateCubic = function (
255
+ x0: number,
256
+ x1: number,
257
+ x2: number,
258
+ x3: number,
259
+ t: number,
260
+ ) {
261
+ const a0 = x3 - x2 - x0 + x1;
262
+ const a1 = x0 - x1 - a0;
263
+ const a2 = x2 - x0;
264
+ const a3 = x1;
265
+ return Math.max(
266
+ 0,
267
+ Math.min(255, a0 * (t * t * t) + a1 * (t * t) + a2 * t + a3),
268
+ );
269
+ };
270
+
271
+ return this._interpolate2D(src, dst, options, interpolateCubic);
272
+ },
273
+
274
+ hermiteInterpolation(src: any, dst: any, options?: any) {
275
+ const interpolateHermite = function (
276
+ x0: number,
277
+ x1: number,
278
+ x2: number,
279
+ x3: number,
280
+ t: number,
281
+ ) {
282
+ const c0 = x1;
283
+ const c1 = 0.5 * (x2 - x0);
284
+ const c2 = x0 - 2.5 * x1 + 2 * x2 - 0.5 * x3;
285
+ const c3 = 0.5 * (x3 - x0) + 1.5 * (x1 - x2);
286
+ return Math.max(
287
+ 0,
288
+ Math.min(255, Math.round(((c3 * t + c2) * t + c1) * t + c0)),
289
+ );
290
+ };
291
+
292
+ return this._interpolate2D(src, dst, options, interpolateHermite);
293
+ },
294
+
295
+ bezierInterpolation(src: any, dst: any, options?: any) {
296
+ // between 2 points y(n), y(n+1), use next points out, y(n-1), y(n+2)
297
+ // to predict control points (a & b) to be placed at n+0.5
298
+ // ya(n) = y(n) + (y(n+1)-y(n-1))/4
299
+ // yb(n) = y(n+1) - (y(n+2)-y(n))/4
300
+ // then use std bezier to interpolate [n,n+1)
301
+ // y(n+t) = y(n)*(1-t)^3 + 3 * ya(n)*(1-t)^2*t + 3 * yb(n)*(1-t)*t^2 + y(n+1)*t^3
302
+ // note the 3* factor for the two control points
303
+ // for edge cases, can choose:
304
+ // y(-1) = y(0) - 2*(y(1)-y(0))
305
+ // y(w) = y(w-1) + 2*(y(w-1)-y(w-2))
306
+ // but can go with y(-1) = y(0) and y(w) = y(w-1)
307
+ const interpolateBezier = function (
308
+ x0: number,
309
+ x1: number,
310
+ x2: number,
311
+ x3: number,
312
+ t: number,
313
+ ) {
314
+ // x1, x2 are the knots, use x0 and x3 to calculate control points
315
+ const cp1 = x1 + (x2 - x0) / 4;
316
+ const cp2 = x2 - (x3 - x1) / 4;
317
+ const nt = 1 - t;
318
+ const c0 = x1 * nt * nt * nt;
319
+ const c1 = 3 * cp1 * nt * nt * t;
320
+ const c2 = 3 * cp2 * nt * t * t;
321
+ const c3 = x2 * t * t * t;
322
+ return Math.max(0, Math.min(255, Math.round(c0 + c1 + c2 + c3)));
323
+ };
324
+
325
+ return this._interpolate2D(src, dst, options, interpolateBezier);
326
+ },
327
+ };
node_modules/@jimp/plugin-resize/tsconfig.json ADDED
@@ -0,0 +1,6 @@
 
 
 
 
 
 
 
1
+ {
2
+ "extends": "@jimp/config-typescript/base.json",
3
+ "compilerOptions": {
4
+ "outDir": "dist"
5
+ }
6
+ }
node_modules/@jimp/plugin-resize/vitest.config.browser.mjs ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ import config from "@jimp/config-vitest/browser";
2
+
3
+ export default config;
node_modules/@jimp/plugin-rotate/.tshy/build.json ADDED
@@ -0,0 +1,8 @@
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "extends": "../tsconfig.json",
3
+ "compilerOptions": {
4
+ "rootDir": "../src",
5
+ "module": "nodenext",
6
+ "moduleResolution": "nodenext"
7
+ }
8
+ }
node_modules/@jimp/plugin-rotate/.tshy/commonjs.json ADDED
@@ -0,0 +1,17 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "extends": "./build.json",
3
+ "include": [
4
+ "../src/**/*.ts",
5
+ "../src/**/*.cts",
6
+ "../src/**/*.tsx",
7
+ "../src/**/*.json"
8
+ ],
9
+ "exclude": [
10
+ "../**/*.test.ts",
11
+ "../src/**/*.mts",
12
+ "../src/package.json"
13
+ ],
14
+ "compilerOptions": {
15
+ "outDir": "../.tshy-build/commonjs"
16
+ }
17
+ }
node_modules/@jimp/plugin-rotate/.tshy/esm.json ADDED
@@ -0,0 +1,16 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "extends": "./build.json",
3
+ "include": [
4
+ "../src/**/*.ts",
5
+ "../src/**/*.mts",
6
+ "../src/**/*.tsx",
7
+ "../src/**/*.json"
8
+ ],
9
+ "exclude": [
10
+ "../**/*.test.ts",
11
+ "../src/package.json"
12
+ ],
13
+ "compilerOptions": {
14
+ "outDir": "../.tshy-build/esm"
15
+ }
16
+ }
node_modules/@jimp/plugin-rotate/CHANGELOG.md ADDED
@@ -0,0 +1,64 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # v1.1.3 (Mon Sep 02 2024)
2
+
3
+ #### 🐛 Bug Fix
4
+
5
+ - Update deps [#1319](https://github.com/jimp-dev/jimp/pull/1319) ([@hipstersmoothie](https://github.com/hipstersmoothie))
6
+
7
+ #### Authors: 1
8
+
9
+ - Andrew Lisowski ([@hipstersmoothie](https://github.com/hipstersmoothie))
10
+
11
+ ---
12
+
13
+ # v1.1.2 (Mon Sep 02 2024)
14
+
15
+ #### 🐛 Bug Fix
16
+
17
+ - Rotate short circuit [#1317](https://github.com/jimp-dev/jimp/pull/1317) ([@hipstersmoothie](https://github.com/hipstersmoothie))
18
+
19
+ #### Authors: 1
20
+
21
+ - Andrew Lisowski ([@hipstersmoothie](https://github.com/hipstersmoothie))
22
+
23
+ ---
24
+
25
+ # v1.1.0 (Sun Sep 01 2024)
26
+
27
+ #### ⚠️ Pushed to `main`
28
+
29
+ - upgrade tshy ([@hipstersmoothie](https://github.com/hipstersmoothie))
30
+ - update more docs ([@hipstersmoothie](https://github.com/hipstersmoothie))
31
+
32
+ #### Authors: 1
33
+
34
+ - Andrew Lisowski ([@hipstersmoothie](https://github.com/hipstersmoothie))
35
+
36
+ ---
37
+
38
+ # v1.0.3 (Sat Aug 31 2024)
39
+
40
+ #### 🐛 Bug Fix
41
+
42
+ - Fix build [#1303](https://github.com/jimp-dev/jimp/pull/1303) ([@hipstersmoothie](https://github.com/hipstersmoothie))
43
+
44
+ #### ⚠️ Pushed to `main`
45
+
46
+ - add clean script ([@hipstersmoothie](https://github.com/hipstersmoothie))
47
+
48
+ #### Authors: 1
49
+
50
+ - Andrew Lisowski ([@hipstersmoothie](https://github.com/hipstersmoothie))
51
+
52
+ ---
53
+
54
+ # v1.0.2 (Sat Aug 31 2024)
55
+
56
+ #### ⚠️ Pushed to `main`
57
+
58
+ - set side effects ([@hipstersmoothie](https://github.com/hipstersmoothie))
59
+ - fix versions ([@hipstersmoothie](https://github.com/hipstersmoothie))
60
+ - add publish config ([@hipstersmoothie](https://github.com/hipstersmoothie))
61
+
62
+ #### Authors: 1
63
+
64
+ - Andrew Lisowski ([@hipstersmoothie](https://github.com/hipstersmoothie))
node_modules/@jimp/plugin-rotate/LICENSE ADDED
@@ -0,0 +1,21 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ MIT License
2
+
3
+ Copyright (c) 2018 Oliver Moran
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
node_modules/@jimp/plugin-rotate/README.md ADDED
@@ -0,0 +1,10 @@
 
 
 
 
 
 
 
 
 
 
 
1
+ <div align="center">
2
+ <img width="200" height="200"
3
+ src="https://s3.amazonaws.com/pix.iemoji.com/images/emoji/apple/ios-11/256/crayon.png">
4
+ <h1>@jimp/plugin-rotate</h1>
5
+ <p>Rotate an image.</p>
6
+ </div>
7
+
8
+ Rotates the image counter-clockwise by a number of degrees. By default the width and height of the image will be resized appropriately.
9
+
10
+ - [rotate](http://jimp-dev.github.io/jimp/api/jimp/classes/jimp#rotate)
node_modules/@jimp/plugin-rotate/dist/commonjs/index.d.ts ADDED
@@ -0,0 +1,32 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import { ResizeStrategy } from "@jimp/plugin-resize";
2
+ import { JimpClass } from "@jimp/types";
3
+ import { z } from "zod";
4
+ declare const RotateOptionsSchema: z.ZodUnion<[z.ZodNumber, z.ZodObject<{
5
+ /** the number of degrees to rotate the image by */
6
+ deg: z.ZodNumber;
7
+ /** resize mode or a boolean, if false then the width and height of the image will not be changed */
8
+ mode: z.ZodOptional<z.ZodUnion<[z.ZodBoolean, z.ZodNativeEnum<typeof ResizeStrategy>]>>;
9
+ }, "strip", z.ZodTypeAny, {
10
+ deg: number;
11
+ mode?: boolean | ResizeStrategy | undefined;
12
+ }, {
13
+ deg: number;
14
+ mode?: boolean | ResizeStrategy | undefined;
15
+ }>]>;
16
+ export type RotateOptions = z.infer<typeof RotateOptionsSchema>;
17
+ export declare const methods: {
18
+ /**
19
+ * Rotates the image counter-clockwise by a number of degrees. By default the width and height of the image will be resized appropriately.
20
+ * @example
21
+ * ```ts
22
+ * import { Jimp } from "jimp";
23
+ *
24
+ * const image = await Jimp.read("test/image.png");
25
+ *
26
+ * image.rotate(90);
27
+ * ```
28
+ */
29
+ rotate<I extends JimpClass>(image: I, options: RotateOptions): I;
30
+ };
31
+ export {};
32
+ //# sourceMappingURL=index.d.ts.map
node_modules/@jimp/plugin-rotate/dist/commonjs/index.d.ts.map ADDED
@@ -0,0 +1 @@
 
 
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAA4B,MAAM,qBAAqB,CAAC;AAC/E,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAIxC,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,QAAA,MAAM,mBAAmB;IAGrB,mDAAmD;;IAEnD,oGAAoG;;;;;;;;IAGtG,CAAC;AAEH,MAAM,MAAM,aAAa,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,mBAAmB,CAAC,CAAC;AAuMhE,eAAO,MAAM,OAAO;IAClB;;;;;;;;;;OAUG;WACI,CAAC,SAAS,SAAS,SAAS,CAAC,WAAW,aAAa;CA2B7D,CAAC"}
node_modules/@jimp/plugin-rotate/dist/commonjs/index.js ADDED
@@ -0,0 +1,201 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.methods = void 0;
4
+ const plugin_resize_1 = require("@jimp/plugin-resize");
5
+ const utils_1 = require("@jimp/utils");
6
+ const core_1 = require("@jimp/core");
7
+ const plugin_crop_1 = require("@jimp/plugin-crop");
8
+ const zod_1 = require("zod");
9
+ const RotateOptionsSchema = zod_1.z.union([
10
+ zod_1.z.number(),
11
+ zod_1.z.object({
12
+ /** the number of degrees to rotate the image by */
13
+ deg: zod_1.z.number(),
14
+ /** resize mode or a boolean, if false then the width and height of the image will not be changed */
15
+ mode: zod_1.z.union([zod_1.z.boolean(), zod_1.z.nativeEnum(plugin_resize_1.ResizeStrategy)]).optional(),
16
+ }),
17
+ ]);
18
+ /** function to translate the x, y coordinate to the index of the pixel in the buffer */
19
+ function createIdxTranslationFunction(w) {
20
+ return function (x, y) {
21
+ return (y * w + x) << 2;
22
+ };
23
+ }
24
+ /**
25
+ * Rotates an image counter-clockwise by multiple of 90 degrees. NB: 'this' must be a Jimp object.
26
+ *
27
+ * This function is based on matrix rotation. Check this to get an initial idea how it works: https://stackoverflow.com/a/8664879/10561909
28
+ *
29
+ * @param deg the number of degrees to rotate the image by, it should be a multiple of 90
30
+ */
31
+ function matrixRotate(image, deg) {
32
+ if (Math.abs(deg) % 90 !== 0) {
33
+ throw new Error("Unsupported matrix rotation degree");
34
+ }
35
+ const w = image.bitmap.width;
36
+ const h = image.bitmap.height;
37
+ // decide which rotation angle to use
38
+ let angle;
39
+ switch (deg) {
40
+ // 90 degree & -270 degree are same
41
+ case 90:
42
+ case -270:
43
+ angle = 90;
44
+ break;
45
+ case 180:
46
+ case -180:
47
+ angle = 180;
48
+ break;
49
+ case 270:
50
+ case -90:
51
+ angle = -90;
52
+ break;
53
+ default:
54
+ throw new Error("Unsupported matrix rotation degree");
55
+ }
56
+ // After this switch block, angle will be 90, 180 or -90
57
+ // calculate the new width and height
58
+ const nW = angle === 180 ? w : h;
59
+ const nH = angle === 180 ? h : w;
60
+ const dstBuffer = Buffer.alloc(image.bitmap.data.length);
61
+ const srcIdxFunction = createIdxTranslationFunction(w);
62
+ const dstIdxFunction = createIdxTranslationFunction(nW);
63
+ for (let x = 0; x < w; x++) {
64
+ for (let y = 0; y < h; y++) {
65
+ const srcIdx = srcIdxFunction(x, y);
66
+ const pixelRGBA = image.bitmap.data.readUInt32BE(srcIdx);
67
+ let dstIdx;
68
+ switch (angle) {
69
+ case 90:
70
+ dstIdx = dstIdxFunction(y, w - x - 1);
71
+ break;
72
+ case -90:
73
+ dstIdx = dstIdxFunction(h - y - 1, x);
74
+ break;
75
+ case 180:
76
+ dstIdx = dstIdxFunction(w - x - 1, h - y - 1);
77
+ break;
78
+ default:
79
+ throw new Error("Unsupported matrix rotation angle");
80
+ }
81
+ dstBuffer.writeUInt32BE(pixelRGBA, dstIdx);
82
+ }
83
+ }
84
+ image.bitmap.data = dstBuffer;
85
+ image.bitmap.width = nW;
86
+ image.bitmap.height = nH;
87
+ }
88
+ function createTranslationFunction(deltaX, deltaY) {
89
+ return function (x, y) {
90
+ return {
91
+ x: x + deltaX,
92
+ y: y + deltaY,
93
+ };
94
+ };
95
+ }
96
+ /**
97
+ * Rotates an image counter-clockwise by an arbitrary number of degrees. NB: 'this' must be a Jimp object.
98
+ * @param {number} deg the number of degrees to rotate the image by
99
+ */
100
+ function advancedRotate(image, deg, mode) {
101
+ const rad = (deg * Math.PI) / 180;
102
+ const cosine = Math.cos(rad);
103
+ const sine = Math.sin(rad);
104
+ // the final width and height will change if resize == true
105
+ let w = image.bitmap.width;
106
+ let h = image.bitmap.height;
107
+ if (mode === true || typeof mode === "string") {
108
+ // resize the image to it maximum dimension and blit the existing image
109
+ // onto the center so that when it is rotated the image is kept in bounds
110
+ // http://stackoverflow.com/questions/3231176/how-to-get-size-of-a-rotated-rectangle
111
+ // Plus 1 border pixel to ensure to show all rotated result for some cases.
112
+ w =
113
+ Math.ceil(Math.abs(image.bitmap.width * cosine) +
114
+ Math.abs(image.bitmap.height * sine)) + 1;
115
+ h =
116
+ Math.ceil(Math.abs(image.bitmap.width * sine) +
117
+ Math.abs(image.bitmap.height * cosine)) + 1;
118
+ // Ensure destination to have even size to a better result.
119
+ if (w % 2 !== 0) {
120
+ w++;
121
+ }
122
+ if (h % 2 !== 0) {
123
+ h++;
124
+ }
125
+ const c = (0, utils_1.clone)(image);
126
+ image.scan((_, __, idx) => {
127
+ image.bitmap.data.writeUInt32BE(image.background, idx);
128
+ });
129
+ const max = Math.max(w, h, image.bitmap.width, image.bitmap.height);
130
+ image = plugin_resize_1.methods.resize(image, {
131
+ h: max,
132
+ w: max,
133
+ mode: mode === true ? undefined : mode,
134
+ });
135
+ image = (0, core_1.composite)(image, c, image.bitmap.width / 2 - c.bitmap.width / 2, image.bitmap.height / 2 - c.bitmap.height / 2);
136
+ }
137
+ const bW = image.bitmap.width;
138
+ const bH = image.bitmap.height;
139
+ const dstBuffer = Buffer.alloc(image.bitmap.data.length);
140
+ const translate2Cartesian = createTranslationFunction(-(bW / 2), -(bH / 2));
141
+ const translate2Screen = createTranslationFunction(bW / 2 + 0.5, bH / 2 + 0.5);
142
+ for (let y = 1; y <= bH; y++) {
143
+ for (let x = 1; x <= bW; x++) {
144
+ const cartesian = translate2Cartesian(x, y);
145
+ const source = translate2Screen(cosine * cartesian.x - sine * cartesian.y, cosine * cartesian.y + sine * cartesian.x);
146
+ const dstIdx = (bW * (y - 1) + x - 1) << 2;
147
+ if (source.x >= 0 && source.x < bW && source.y >= 0 && source.y < bH) {
148
+ const srcIdx = ((bW * (source.y | 0) + source.x) | 0) << 2;
149
+ const pixelRGBA = image.bitmap.data.readUInt32BE(srcIdx);
150
+ dstBuffer.writeUInt32BE(pixelRGBA, dstIdx);
151
+ }
152
+ else {
153
+ // reset off-image pixels
154
+ dstBuffer.writeUInt32BE(image.background, dstIdx);
155
+ }
156
+ }
157
+ }
158
+ image.bitmap.data = dstBuffer;
159
+ if (mode === true || typeof mode === "string") {
160
+ // now crop the image to the final size
161
+ const x = Math.max(bW / 2 - w / 2, 0);
162
+ const y = Math.max(bH / 2 - h / 2, 0);
163
+ image = plugin_crop_1.methods.crop(image, { x, y, w, h });
164
+ }
165
+ }
166
+ exports.methods = {
167
+ /**
168
+ * Rotates the image counter-clockwise by a number of degrees. By default the width and height of the image will be resized appropriately.
169
+ * @example
170
+ * ```ts
171
+ * import { Jimp } from "jimp";
172
+ *
173
+ * const image = await Jimp.read("test/image.png");
174
+ *
175
+ * image.rotate(90);
176
+ * ```
177
+ */
178
+ rotate(image, options) {
179
+ const parsed = RotateOptionsSchema.parse(options);
180
+ const actualOptions = typeof parsed === "number" ? { deg: parsed } : parsed;
181
+ const { mode = true } = actualOptions;
182
+ let { deg } = actualOptions;
183
+ // No need to do extra rotation
184
+ deg %= 360;
185
+ // no rotation for 0, 360, -360, 720, -720, ...
186
+ if (deg % 360 === 0) {
187
+ return image;
188
+ }
189
+ // use matrixRotate if the angle is a multiple of 90 degrees (eg: 180 or -90) and resize is allowed or not needed.
190
+ const matrixRotateAllowed = deg % 90 === 0 &&
191
+ (mode || image.bitmap.width === image.bitmap.height || deg % 180 === 0);
192
+ if (matrixRotateAllowed) {
193
+ matrixRotate(image, deg);
194
+ }
195
+ else {
196
+ advancedRotate(image, deg, mode);
197
+ }
198
+ return image;
199
+ },
200
+ };
201
+ //# sourceMappingURL=index.js.map
node_modules/@jimp/plugin-rotate/dist/commonjs/index.js.map ADDED
@@ -0,0 +1 @@
 
 
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";;;AAAA,uDAA+E;AAE/E,uCAAoC;AACpC,qCAAuC;AACvC,mDAA2D;AAC3D,6BAAwB;AAExB,MAAM,mBAAmB,GAAG,OAAC,CAAC,KAAK,CAAC;IAClC,OAAC,CAAC,MAAM,EAAE;IACV,OAAC,CAAC,MAAM,CAAC;QACP,mDAAmD;QACnD,GAAG,EAAE,OAAC,CAAC,MAAM,EAAE;QACf,oGAAoG;QACpG,IAAI,EAAE,OAAC,CAAC,KAAK,CAAC,CAAC,OAAC,CAAC,OAAO,EAAE,EAAE,OAAC,CAAC,UAAU,CAAC,8BAAc,CAAC,CAAC,CAAC,CAAC,QAAQ,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QAEX,+CAA+C;QAC/C,IAAI,GAAG,GAAG,GAAG,KAAK,CAAC,EAAE,CAAC;YACpB,OAAO,KAAK,CAAC;QACf,CAAC;QAED,kHAAkH;QAClH,MAAM,mBAAmB,GACvB,GAAG,GAAG,EAAE,KAAK,CAAC;YACd,CAAC,IAAI,IAAI,KAAK,CAAC,MAAM,CAAC,KAAK,KAAK,KAAK,CAAC,MAAM,CAAC,MAAM,IAAI,GAAG,GAAG,GAAG,KAAK,CAAC,CAAC,CAAC;QAE1E,IAAI,mBAAmB,EAAE,CAAC;YACxB,YAAY,CAAC,KAAK,EAAE,GAAG,CAAC,CAAC;QAC3B,CAAC;aAAM,CAAC;YACN,cAAc,CAAC,KAAK,EAAE,GAAG,EAAE,IAAI,CAAC,CAAC;QACnC,CAAC;QAED,OAAO,KAAK,CAAC;IACf,CAAC;CACF,CAAC"}
node_modules/@jimp/plugin-rotate/dist/commonjs/package.json ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ {
2
+ "type": "commonjs"
3
+ }
node_modules/@jimp/plugin-rotate/dist/esm/index.d.ts ADDED
@@ -0,0 +1,32 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import { ResizeStrategy } from "@jimp/plugin-resize";
2
+ import { JimpClass } from "@jimp/types";
3
+ import { z } from "zod";
4
+ declare const RotateOptionsSchema: z.ZodUnion<[z.ZodNumber, z.ZodObject<{
5
+ /** the number of degrees to rotate the image by */
6
+ deg: z.ZodNumber;
7
+ /** resize mode or a boolean, if false then the width and height of the image will not be changed */
8
+ mode: z.ZodOptional<z.ZodUnion<[z.ZodBoolean, z.ZodNativeEnum<typeof ResizeStrategy>]>>;
9
+ }, "strip", z.ZodTypeAny, {
10
+ deg: number;
11
+ mode?: boolean | ResizeStrategy | undefined;
12
+ }, {
13
+ deg: number;
14
+ mode?: boolean | ResizeStrategy | undefined;
15
+ }>]>;
16
+ export type RotateOptions = z.infer<typeof RotateOptionsSchema>;
17
+ export declare const methods: {
18
+ /**
19
+ * Rotates the image counter-clockwise by a number of degrees. By default the width and height of the image will be resized appropriately.
20
+ * @example
21
+ * ```ts
22
+ * import { Jimp } from "jimp";
23
+ *
24
+ * const image = await Jimp.read("test/image.png");
25
+ *
26
+ * image.rotate(90);
27
+ * ```
28
+ */
29
+ rotate<I extends JimpClass>(image: I, options: RotateOptions): I;
30
+ };
31
+ export {};
32
+ //# sourceMappingURL=index.d.ts.map
node_modules/@jimp/plugin-rotate/dist/esm/index.d.ts.map ADDED
@@ -0,0 +1 @@
 
 
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAA4B,MAAM,qBAAqB,CAAC;AAC/E,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAIxC,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,QAAA,MAAM,mBAAmB;IAGrB,mDAAmD;;IAEnD,oGAAoG;;;;;;;;IAGtG,CAAC;AAEH,MAAM,MAAM,aAAa,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,mBAAmB,CAAC,CAAC;AAuMhE,eAAO,MAAM,OAAO;IAClB;;;;;;;;;;OAUG;WACI,CAAC,SAAS,SAAS,SAAS,CAAC,WAAW,aAAa;CA2B7D,CAAC"}
node_modules/@jimp/plugin-rotate/dist/esm/index.js ADDED
@@ -0,0 +1,198 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import { ResizeStrategy, methods as resizeMethods } from "@jimp/plugin-resize";
2
+ import { clone } from "@jimp/utils";
3
+ import { composite } from "@jimp/core";
4
+ import { methods as cropMethods } from "@jimp/plugin-crop";
5
+ import { z } from "zod";
6
+ const RotateOptionsSchema = z.union([
7
+ z.number(),
8
+ z.object({
9
+ /** the number of degrees to rotate the image by */
10
+ deg: z.number(),
11
+ /** resize mode or a boolean, if false then the width and height of the image will not be changed */
12
+ mode: z.union([z.boolean(), z.nativeEnum(ResizeStrategy)]).optional(),
13
+ }),
14
+ ]);
15
+ /** function to translate the x, y coordinate to the index of the pixel in the buffer */
16
+ function createIdxTranslationFunction(w) {
17
+ return function (x, y) {
18
+ return (y * w + x) << 2;
19
+ };
20
+ }
21
+ /**
22
+ * Rotates an image counter-clockwise by multiple of 90 degrees. NB: 'this' must be a Jimp object.
23
+ *
24
+ * This function is based on matrix rotation. Check this to get an initial idea how it works: https://stackoverflow.com/a/8664879/10561909
25
+ *
26
+ * @param deg the number of degrees to rotate the image by, it should be a multiple of 90
27
+ */
28
+ function matrixRotate(image, deg) {
29
+ if (Math.abs(deg) % 90 !== 0) {
30
+ throw new Error("Unsupported matrix rotation degree");
31
+ }
32
+ const w = image.bitmap.width;
33
+ const h = image.bitmap.height;
34
+ // decide which rotation angle to use
35
+ let angle;
36
+ switch (deg) {
37
+ // 90 degree & -270 degree are same
38
+ case 90:
39
+ case -270:
40
+ angle = 90;
41
+ break;
42
+ case 180:
43
+ case -180:
44
+ angle = 180;
45
+ break;
46
+ case 270:
47
+ case -90:
48
+ angle = -90;
49
+ break;
50
+ default:
51
+ throw new Error("Unsupported matrix rotation degree");
52
+ }
53
+ // After this switch block, angle will be 90, 180 or -90
54
+ // calculate the new width and height
55
+ const nW = angle === 180 ? w : h;
56
+ const nH = angle === 180 ? h : w;
57
+ const dstBuffer = Buffer.alloc(image.bitmap.data.length);
58
+ const srcIdxFunction = createIdxTranslationFunction(w);
59
+ const dstIdxFunction = createIdxTranslationFunction(nW);
60
+ for (let x = 0; x < w; x++) {
61
+ for (let y = 0; y < h; y++) {
62
+ const srcIdx = srcIdxFunction(x, y);
63
+ const pixelRGBA = image.bitmap.data.readUInt32BE(srcIdx);
64
+ let dstIdx;
65
+ switch (angle) {
66
+ case 90:
67
+ dstIdx = dstIdxFunction(y, w - x - 1);
68
+ break;
69
+ case -90:
70
+ dstIdx = dstIdxFunction(h - y - 1, x);
71
+ break;
72
+ case 180:
73
+ dstIdx = dstIdxFunction(w - x - 1, h - y - 1);
74
+ break;
75
+ default:
76
+ throw new Error("Unsupported matrix rotation angle");
77
+ }
78
+ dstBuffer.writeUInt32BE(pixelRGBA, dstIdx);
79
+ }
80
+ }
81
+ image.bitmap.data = dstBuffer;
82
+ image.bitmap.width = nW;
83
+ image.bitmap.height = nH;
84
+ }
85
+ function createTranslationFunction(deltaX, deltaY) {
86
+ return function (x, y) {
87
+ return {
88
+ x: x + deltaX,
89
+ y: y + deltaY,
90
+ };
91
+ };
92
+ }
93
+ /**
94
+ * Rotates an image counter-clockwise by an arbitrary number of degrees. NB: 'this' must be a Jimp object.
95
+ * @param {number} deg the number of degrees to rotate the image by
96
+ */
97
+ function advancedRotate(image, deg, mode) {
98
+ const rad = (deg * Math.PI) / 180;
99
+ const cosine = Math.cos(rad);
100
+ const sine = Math.sin(rad);
101
+ // the final width and height will change if resize == true
102
+ let w = image.bitmap.width;
103
+ let h = image.bitmap.height;
104
+ if (mode === true || typeof mode === "string") {
105
+ // resize the image to it maximum dimension and blit the existing image
106
+ // onto the center so that when it is rotated the image is kept in bounds
107
+ // http://stackoverflow.com/questions/3231176/how-to-get-size-of-a-rotated-rectangle
108
+ // Plus 1 border pixel to ensure to show all rotated result for some cases.
109
+ w =
110
+ Math.ceil(Math.abs(image.bitmap.width * cosine) +
111
+ Math.abs(image.bitmap.height * sine)) + 1;
112
+ h =
113
+ Math.ceil(Math.abs(image.bitmap.width * sine) +
114
+ Math.abs(image.bitmap.height * cosine)) + 1;
115
+ // Ensure destination to have even size to a better result.
116
+ if (w % 2 !== 0) {
117
+ w++;
118
+ }
119
+ if (h % 2 !== 0) {
120
+ h++;
121
+ }
122
+ const c = clone(image);
123
+ image.scan((_, __, idx) => {
124
+ image.bitmap.data.writeUInt32BE(image.background, idx);
125
+ });
126
+ const max = Math.max(w, h, image.bitmap.width, image.bitmap.height);
127
+ image = resizeMethods.resize(image, {
128
+ h: max,
129
+ w: max,
130
+ mode: mode === true ? undefined : mode,
131
+ });
132
+ image = composite(image, c, image.bitmap.width / 2 - c.bitmap.width / 2, image.bitmap.height / 2 - c.bitmap.height / 2);
133
+ }
134
+ const bW = image.bitmap.width;
135
+ const bH = image.bitmap.height;
136
+ const dstBuffer = Buffer.alloc(image.bitmap.data.length);
137
+ const translate2Cartesian = createTranslationFunction(-(bW / 2), -(bH / 2));
138
+ const translate2Screen = createTranslationFunction(bW / 2 + 0.5, bH / 2 + 0.5);
139
+ for (let y = 1; y <= bH; y++) {
140
+ for (let x = 1; x <= bW; x++) {
141
+ const cartesian = translate2Cartesian(x, y);
142
+ const source = translate2Screen(cosine * cartesian.x - sine * cartesian.y, cosine * cartesian.y + sine * cartesian.x);
143
+ const dstIdx = (bW * (y - 1) + x - 1) << 2;
144
+ if (source.x >= 0 && source.x < bW && source.y >= 0 && source.y < bH) {
145
+ const srcIdx = ((bW * (source.y | 0) + source.x) | 0) << 2;
146
+ const pixelRGBA = image.bitmap.data.readUInt32BE(srcIdx);
147
+ dstBuffer.writeUInt32BE(pixelRGBA, dstIdx);
148
+ }
149
+ else {
150
+ // reset off-image pixels
151
+ dstBuffer.writeUInt32BE(image.background, dstIdx);
152
+ }
153
+ }
154
+ }
155
+ image.bitmap.data = dstBuffer;
156
+ if (mode === true || typeof mode === "string") {
157
+ // now crop the image to the final size
158
+ const x = Math.max(bW / 2 - w / 2, 0);
159
+ const y = Math.max(bH / 2 - h / 2, 0);
160
+ image = cropMethods.crop(image, { x, y, w, h });
161
+ }
162
+ }
163
+ export const methods = {
164
+ /**
165
+ * Rotates the image counter-clockwise by a number of degrees. By default the width and height of the image will be resized appropriately.
166
+ * @example
167
+ * ```ts
168
+ * import { Jimp } from "jimp";
169
+ *
170
+ * const image = await Jimp.read("test/image.png");
171
+ *
172
+ * image.rotate(90);
173
+ * ```
174
+ */
175
+ rotate(image, options) {
176
+ const parsed = RotateOptionsSchema.parse(options);
177
+ const actualOptions = typeof parsed === "number" ? { deg: parsed } : parsed;
178
+ const { mode = true } = actualOptions;
179
+ let { deg } = actualOptions;
180
+ // No need to do extra rotation
181
+ deg %= 360;
182
+ // no rotation for 0, 360, -360, 720, -720, ...
183
+ if (deg % 360 === 0) {
184
+ return image;
185
+ }
186
+ // use matrixRotate if the angle is a multiple of 90 degrees (eg: 180 or -90) and resize is allowed or not needed.
187
+ const matrixRotateAllowed = deg % 90 === 0 &&
188
+ (mode || image.bitmap.width === image.bitmap.height || deg % 180 === 0);
189
+ if (matrixRotateAllowed) {
190
+ matrixRotate(image, deg);
191
+ }
192
+ else {
193
+ advancedRotate(image, deg, mode);
194
+ }
195
+ return image;
196
+ },
197
+ };
198
+ //# sourceMappingURL=index.js.map
node_modules/@jimp/plugin-rotate/dist/esm/index.js.map ADDED
@@ -0,0 +1 @@
 
 
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,OAAO,IAAI,aAAa,EAAE,MAAM,qBAAqB,CAAC;AAE/E,OAAO,EAAE,KAAK,EAAE,MAAM,aAAa,CAAC;AACpC,OAAO,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AACvC,OAAO,EAAE,OAAO,IAAI,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAC3D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B;QAC1D,MAAM,MAAM,GAAG,mBAAmB,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC;QAClD,MAAM,aAAa,GAAG,OAAO,MAAM,KAAK,QAAQ,CAAC,CAAC,CAAC,EAAE,GAAG,EAAE,MAAM,EAAE,CAAC,CAAC,CAAC,MAAM,CAAC;QAC5E,MAAM,EAAE,IAAI,GAAG,IAAI,EAAE,GAAG,aAAa,CAAC;QACtC,IAAI,EAAE,GAAG,EAAE,GAAG,aAAa,CAAC;QAE5B,+BAA+B;QAC/B,GAAG,IAAI,GAAG,CAAC;QAEX,+CAA+C;QAC/C,IAAI,GAAG,GAAG,GAAG,KAAK,CAAC,EAAE,CAAC;YACpB,OAAO,KAAK,CAAC;QACf,CAAC;QAED,kHAAkH;QAClH,MAAM,mBAAmB,GACvB,GAAG,GAAG,EAAE,KAAK,CAAC;YACd,CAAC,IAAI,IAAI,KAAK,CAAC,MAAM,CAAC,KAAK,KAAK,KAAK,CAAC,MAAM,CAAC,MAAM,IAAI,GAAG,GAAG,GAAG,KAAK,CAAC,CAAC,CAAC;QAE1E,IAAI,mBAAmB,EAAE,CAAC;YACxB,YAAY,CAAC,KAAK,EAAE,GAAG,CAAC,CAAC;QAC3B,CAAC;aAAM,CAAC;YACN,cAAc,CAAC,KAAK,EAAE,GAAG,EAAE,IAAI,CAAC,CAAC;QACnC,CAAC;QAED,OAAO,KAAK,CAAC;IACf,CAAC;CACF,CAAC"}
node_modules/@jimp/plugin-rotate/dist/esm/package.json ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ {
2
+ "type": "module"
3
+ }
node_modules/@jimp/plugin-rotate/eslint.config.mjs ADDED
@@ -0,0 +1,2 @@
 
 
 
1
+ import shared from "@jimp/config-eslint/base.js";
2
+ export default [...shared];
node_modules/@jimp/plugin-rotate/node_modules/zod/LICENSE ADDED
@@ -0,0 +1,21 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ MIT License
2
+
3
+ Copyright (c) 2025 Colin McDonnell
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
node_modules/@jimp/plugin-rotate/node_modules/zod/README.md ADDED
@@ -0,0 +1,208 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <p align="center">
2
+ <img src="logo.svg" width="200px" align="center" alt="Zod logo" />
3
+ <h1 align="center">Zod</h1>
4
+ <p align="center">
5
+ TypeScript-first schema validation with static type inference
6
+ <br/>
7
+ by <a href="https://x.com/colinhacks">@colinhacks</a>
8
+ </p>
9
+ </p>
10
+ <br/>
11
+
12
+ <p align="center">
13
+ <a href="https://github.com/colinhacks/zod/actions?query=branch%3Amaster"><img src="https://github.com/colinhacks/zod/actions/workflows/test.yml/badge.svg?event=push&branch=master" alt="Zod CI status" /></a>
14
+ <a href="https://opensource.org/licenses/MIT" rel="nofollow"><img src="https://img.shields.io/github/license/colinhacks/zod" alt="License"></a>
15
+ <a href="https://www.npmjs.com/package/zod" rel="nofollow"><img src="https://img.shields.io/npm/dw/zod.svg" alt="npm"></a>
16
+ <a href="https://discord.gg/KaSRdyX2vc" rel="nofollow"><img src="https://img.shields.io/discord/893487829802418277?label=Discord&logo=discord&logoColor=white" alt="discord server"></a>
17
+ <a href="https://github.com/colinhacks/zod" rel="nofollow"><img src="https://img.shields.io/github/stars/colinhacks/zod" alt="stars"></a>
18
+ </p>
19
+
20
+ <div align="center">
21
+ <a href="https://zod.dev/api">Docs</a>
22
+ <span>&nbsp;&nbsp;•&nbsp;&nbsp;</span>
23
+ <a href="https://discord.gg/RcG33DQJdf">Discord</a>
24
+ <span>&nbsp;&nbsp;•&nbsp;&nbsp;</span>
25
+ <a href="https://twitter.com/colinhacks">𝕏</a>
26
+ <span>&nbsp;&nbsp;•&nbsp;&nbsp;</span>
27
+ <a href="https://bsky.app/profile/zod.dev">Bluesky</a>
28
+ <br />
29
+ </div>
30
+
31
+ <br/>
32
+ <br/>
33
+
34
+ <h2 align="center">Featured sponsor: Jazz</h2>
35
+
36
+ <div align="center">
37
+ <a href="https://jazz.tools/?utm_source=zod">
38
+ <picture width="85%" >
39
+ <source media="(prefers-color-scheme: dark)" srcset="https://raw.githubusercontent.com/garden-co/jazz/938f6767e46cdfded60e50d99bf3b533f4809c68/homepage/homepage/public/Zod%20sponsor%20message.png">
40
+ <img alt="jazz logo" src="https://raw.githubusercontent.com/garden-co/jazz/938f6767e46cdfded60e50d99bf3b533f4809c68/homepage/homepage/public/Zod%20sponsor%20message.png" width="85%">
41
+ </picture>
42
+ </a>
43
+ <br/>
44
+ <p><sub>Learn more about <a target="_blank" rel="noopener noreferrer" href="mailto:sponsorship@colinhacks.com">featured sponsorships</a></sub></p>
45
+ </div>
46
+
47
+ <br/>
48
+ <br/>
49
+ <br/>
50
+
51
+ ### [Read the docs →](https://zod.dev/api)
52
+
53
+ <br/>
54
+ <br/>
55
+
56
+ ## What is Zod?
57
+
58
+ Zod is a TypeScript-first validation library. Define a schema and parse some data with it. You'll get back a strongly typed, validated result.
59
+
60
+ ```ts
61
+ import * as z from "zod/v4";
62
+
63
+ const User = z.object({
64
+ name: z.string(),
65
+ });
66
+
67
+ // some untrusted data...
68
+ const input = {
69
+ /* stuff */
70
+ };
71
+
72
+ // the parsed result is validated and type safe!
73
+ const data = User.parse(input);
74
+
75
+ // so you can use it with confidence :)
76
+ console.log(data.name);
77
+ ```
78
+
79
+ <br/>
80
+
81
+ ## Features
82
+
83
+ - Zero external dependencies
84
+ - Works in Node.js and all modern browsers
85
+ - Tiny: `2kb` core bundle (gzipped)
86
+ - Immutable API: methods return a new instance
87
+ - Concise interface
88
+ - Works with TypeScript and plain JS
89
+ - Built-in JSON Schema conversion
90
+ - Extensive ecosystem
91
+
92
+ <br/>
93
+
94
+ ## Installation
95
+
96
+ ```sh
97
+ npm install zod
98
+ ```
99
+
100
+ <br/>
101
+
102
+ ## Basic usage
103
+
104
+ Before you can do anything else, you need to define a schema. For the purposes of this guide, we'll use a simple object schema.
105
+
106
+ ```ts
107
+ import * as z from "zod/v4";
108
+
109
+ const Player = z.object({
110
+ username: z.string(),
111
+ xp: z.number(),
112
+ });
113
+ ```
114
+
115
+ ### Parsing data
116
+
117
+ Given any Zod schema, use `.parse` to validate an input. If it's valid, Zod returns a strongly-typed _deep clone_ of the input.
118
+
119
+ ```ts
120
+ Player.parse({ username: "billie", xp: 100 });
121
+ // => returns { username: "billie", xp: 100 }
122
+ ```
123
+
124
+ **Note** — If your schema uses certain asynchronous APIs like `async` [refinements](#refine) or [transforms](#transform), you'll need to use the `.parseAsync()` method instead.
125
+
126
+ ```ts
127
+ const schema = z.string().refine(async (val) => val.length <= 8);
128
+
129
+ await schema.parseAsync("hello");
130
+ // => "hello"
131
+ ```
132
+
133
+ ### Handling errors
134
+
135
+ When validation fails, the `.parse()` method will throw a `ZodError` instance with granular information about the validation issues.
136
+
137
+ ```ts
138
+ try {
139
+ Player.parse({ username: 42, xp: "100" });
140
+ } catch (err) {
141
+ if (err instanceof z.ZodError) {
142
+ err.issues;
143
+ /* [
144
+ {
145
+ expected: 'string',
146
+ code: 'invalid_type',
147
+ path: [ 'username' ],
148
+ message: 'Invalid input: expected string'
149
+ },
150
+ {
151
+ expected: 'number',
152
+ code: 'invalid_type',
153
+ path: [ 'xp' ],
154
+ message: 'Invalid input: expected number'
155
+ }
156
+ ] */
157
+ }
158
+ }
159
+ ```
160
+
161
+ To avoid a `try/catch` block, you can use the `.safeParse()` method to get back a plain result object containing either the successfully parsed data or a `ZodError`. The result type is a [discriminated union](https://www.typescriptlang.org/docs/handbook/2/narrowing.html#discriminated-unions), so you can handle both cases conveniently.
162
+
163
+ ```ts
164
+ const result = Player.safeParse({ username: 42, xp: "100" });
165
+ if (!result.success) {
166
+ result.error; // ZodError instance
167
+ } else {
168
+ result.data; // { username: string; xp: number }
169
+ }
170
+ ```
171
+
172
+ **Note** — If your schema uses certain asynchronous APIs like `async` [refinements](#refine) or [transforms](#transform), you'll need to use the `.safeParseAsync()` method instead.
173
+
174
+ ```ts
175
+ const schema = z.string().refine(async (val) => val.length <= 8);
176
+
177
+ await schema.safeParseAsync("hello");
178
+ // => { success: true; data: "hello" }
179
+ ```
180
+
181
+ ### Inferring types
182
+
183
+ Zod infers a static type from your schema definitions. You can extract this type with the `z.infer<>` utility and use it however you like.
184
+
185
+ ```ts
186
+ const Player = z.object({
187
+ username: z.string(),
188
+ xp: z.number(),
189
+ });
190
+
191
+ // extract the inferred type
192
+ type Player = z.infer<typeof Player>;
193
+
194
+ // use it in your code
195
+ const player: Player = { username: "billie", xp: 100 };
196
+ ```
197
+
198
+ In some cases, the input & output types of a schema can diverge. For instance, the `.transform()` API can convert the input from one type to another. In these cases, you can extract the input and output types independently:
199
+
200
+ ```ts
201
+ const mySchema = z.string().transform((val) => val.length);
202
+
203
+ type MySchemaIn = z.input<typeof mySchema>;
204
+ // => string
205
+
206
+ type MySchemaOut = z.output<typeof mySchema>; // equivalent to z.infer<typeof mySchema>
207
+ // number
208
+ ```
node_modules/@jimp/plugin-rotate/node_modules/zod/index.cjs ADDED
@@ -0,0 +1,33 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || function (mod) {
19
+ if (mod && mod.__esModule) return mod;
20
+ var result = {};
21
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
+ __setModuleDefault(result, mod);
23
+ return result;
24
+ };
25
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
26
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
27
+ };
28
+ Object.defineProperty(exports, "__esModule", { value: true });
29
+ exports.z = void 0;
30
+ const z = __importStar(require("./v3/external.cjs"));
31
+ exports.z = z;
32
+ __exportStar(require("./v3/external.cjs"), exports);
33
+ exports.default = z;
node_modules/@jimp/plugin-rotate/node_modules/zod/index.d.cts ADDED
@@ -0,0 +1,4 @@
 
 
 
 
 
1
+ import * as z from "./v3/external.cjs";
2
+ export * from "./v3/external.cjs";
3
+ export { z };
4
+ export default z;
node_modules/@jimp/plugin-rotate/node_modules/zod/index.d.ts ADDED
@@ -0,0 +1,4 @@
 
 
 
 
 
1
+ import * as z from "./v3/external.js";
2
+ export * from "./v3/external.js";
3
+ export { z };
4
+ export default z;
node_modules/@jimp/plugin-rotate/node_modules/zod/index.js ADDED
@@ -0,0 +1,4 @@
 
 
 
 
 
1
+ import * as z from "./v3/external.js";
2
+ export * from "./v3/external.js";
3
+ export { z };
4
+ export default z;
node_modules/@jimp/plugin-rotate/node_modules/zod/package.json ADDED
@@ -0,0 +1,118 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "name": "zod",
3
+ "version": "3.25.76",
4
+ "type": "module",
5
+ "author": "Colin McDonnell <zod@colinhacks.com>",
6
+ "description": "TypeScript-first schema declaration and validation library with static type inference",
7
+ "files": [
8
+ "src",
9
+ "**/*.js",
10
+ "**/*.mjs",
11
+ "**/*.cjs",
12
+ "**/*.d.ts",
13
+ "**/*.d.mts",
14
+ "**/*.d.cts"
15
+ ],
16
+ "funding": "https://github.com/sponsors/colinhacks",
17
+ "homepage": "https://zod.dev",
18
+ "keywords": [
19
+ "typescript",
20
+ "schema",
21
+ "validation",
22
+ "type",
23
+ "inference"
24
+ ],
25
+ "license": "MIT",
26
+ "sideEffects": false,
27
+ "main": "./index.cjs",
28
+ "types": "./index.d.cts",
29
+ "module": "./index.js",
30
+ "zshy": {
31
+ "exports": {
32
+ "./package.json": "./package.json",
33
+ ".": "./src/index.ts",
34
+ "./v3": "./src/v3/index.ts",
35
+ "./v4": "./src/v4/index.ts",
36
+ "./v4-mini": "./src/v4-mini/index.ts",
37
+ "./v4/mini": "./src/v4/mini/index.ts",
38
+ "./v4/core": "./src/v4/core/index.ts",
39
+ "./v4/locales": "./src/v4/locales/index.ts",
40
+ "./v4/locales/*": "./src/v4/locales/*"
41
+ },
42
+ "sourceDialects": [
43
+ "@zod/source"
44
+ ]
45
+ },
46
+ "exports": {
47
+ "./package.json": "./package.json",
48
+ ".": {
49
+ "@zod/source": "./src/index.ts",
50
+ "types": "./index.d.cts",
51
+ "import": "./index.js",
52
+ "require": "./index.cjs"
53
+ },
54
+ "./v3": {
55
+ "@zod/source": "./src/v3/index.ts",
56
+ "types": "./v3/index.d.cts",
57
+ "import": "./v3/index.js",
58
+ "require": "./v3/index.cjs"
59
+ },
60
+ "./v4": {
61
+ "@zod/source": "./src/v4/index.ts",
62
+ "types": "./v4/index.d.cts",
63
+ "import": "./v4/index.js",
64
+ "require": "./v4/index.cjs"
65
+ },
66
+ "./v4-mini": {
67
+ "@zod/source": "./src/v4-mini/index.ts",
68
+ "types": "./v4-mini/index.d.cts",
69
+ "import": "./v4-mini/index.js",
70
+ "require": "./v4-mini/index.cjs"
71
+ },
72
+ "./v4/mini": {
73
+ "@zod/source": "./src/v4/mini/index.ts",
74
+ "types": "./v4/mini/index.d.cts",
75
+ "import": "./v4/mini/index.js",
76
+ "require": "./v4/mini/index.cjs"
77
+ },
78
+ "./v4/core": {
79
+ "@zod/source": "./src/v4/core/index.ts",
80
+ "types": "./v4/core/index.d.cts",
81
+ "import": "./v4/core/index.js",
82
+ "require": "./v4/core/index.cjs"
83
+ },
84
+ "./v4/locales": {
85
+ "@zod/source": "./src/v4/locales/index.ts",
86
+ "types": "./v4/locales/index.d.cts",
87
+ "import": "./v4/locales/index.js",
88
+ "require": "./v4/locales/index.cjs"
89
+ },
90
+ "./v4/locales/*": {
91
+ "@zod/source": "./src/v4/locales/*",
92
+ "types": "./v4/locales/*",
93
+ "import": "./v4/locales/*",
94
+ "require": "./v4/locales/*"
95
+ }
96
+ },
97
+ "repository": {
98
+ "type": "git",
99
+ "url": "git+https://github.com/colinhacks/zod.git"
100
+ },
101
+ "bugs": {
102
+ "url": "https://github.com/colinhacks/zod/issues"
103
+ },
104
+ "support": {
105
+ "backing": {
106
+ "npm-funding": true
107
+ }
108
+ },
109
+ "scripts": {
110
+ "clean": "git clean -xdf . -e node_modules",
111
+ "build": "zshy --project tsconfig.build.json",
112
+ "postbuild": "pnpm biome check --write .",
113
+ "test:watch": "pnpm vitest",
114
+ "test": "pnpm vitest run",
115
+ "bump:beta": "pnpm version \"v$(pnpm pkg get version | jq -r)-beta.$(date +%Y%m%dT%H%M%S)\"",
116
+ "pub:beta": "pnpm bump:beta && pnpm publish --tag next --publish-branch v4 --no-git-checks --dry-run"
117
+ }
118
+ }
node_modules/@jimp/plugin-rotate/node_modules/zod/src/index.ts ADDED
@@ -0,0 +1,4 @@
 
 
 
 
 
1
+ import * as z from "./v3/external.js";
2
+ export * from "./v3/external.js";
3
+ export { z };
4
+ export default z;
node_modules/@jimp/plugin-rotate/node_modules/zod/src/v3/ZodError.ts ADDED
@@ -0,0 +1,330 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import type { Primitive } from "./helpers/typeAliases.js";
2
+ import { util, type ZodParsedType } from "./helpers/util.js";
3
+ import type { TypeOf, ZodType } from "./index.js";
4
+
5
+ type allKeys<T> = T extends any ? keyof T : never;
6
+
7
+ export type inferFlattenedErrors<T extends ZodType<any, any, any>, U = string> = typeToFlattenedError<TypeOf<T>, U>;
8
+ export type typeToFlattenedError<T, U = string> = {
9
+ formErrors: U[];
10
+ fieldErrors: {
11
+ [P in allKeys<T>]?: U[];
12
+ };
13
+ };
14
+
15
+ export const ZodIssueCode = util.arrayToEnum([
16
+ "invalid_type",
17
+ "invalid_literal",
18
+ "custom",
19
+ "invalid_union",
20
+ "invalid_union_discriminator",
21
+ "invalid_enum_value",
22
+ "unrecognized_keys",
23
+ "invalid_arguments",
24
+ "invalid_return_type",
25
+ "invalid_date",
26
+ "invalid_string",
27
+ "too_small",
28
+ "too_big",
29
+ "invalid_intersection_types",
30
+ "not_multiple_of",
31
+ "not_finite",
32
+ ]);
33
+
34
+ export type ZodIssueCode = keyof typeof ZodIssueCode;
35
+
36
+ export type ZodIssueBase = {
37
+ path: (string | number)[];
38
+ message?: string | undefined;
39
+ };
40
+
41
+ export interface ZodInvalidTypeIssue extends ZodIssueBase {
42
+ code: typeof ZodIssueCode.invalid_type;
43
+ expected: ZodParsedType;
44
+ received: ZodParsedType;
45
+ }
46
+
47
+ export interface ZodInvalidLiteralIssue extends ZodIssueBase {
48
+ code: typeof ZodIssueCode.invalid_literal;
49
+ expected: unknown;
50
+ received: unknown;
51
+ }
52
+
53
+ export interface ZodUnrecognizedKeysIssue extends ZodIssueBase {
54
+ code: typeof ZodIssueCode.unrecognized_keys;
55
+ keys: string[];
56
+ }
57
+
58
+ export interface ZodInvalidUnionIssue extends ZodIssueBase {
59
+ code: typeof ZodIssueCode.invalid_union;
60
+ unionErrors: ZodError[];
61
+ }
62
+
63
+ export interface ZodInvalidUnionDiscriminatorIssue extends ZodIssueBase {
64
+ code: typeof ZodIssueCode.invalid_union_discriminator;
65
+ options: Primitive[];
66
+ }
67
+
68
+ export interface ZodInvalidEnumValueIssue extends ZodIssueBase {
69
+ received: string | number;
70
+ code: typeof ZodIssueCode.invalid_enum_value;
71
+ options: (string | number)[];
72
+ }
73
+
74
+ export interface ZodInvalidArgumentsIssue extends ZodIssueBase {
75
+ code: typeof ZodIssueCode.invalid_arguments;
76
+ argumentsError: ZodError;
77
+ }
78
+
79
+ export interface ZodInvalidReturnTypeIssue extends ZodIssueBase {
80
+ code: typeof ZodIssueCode.invalid_return_type;
81
+ returnTypeError: ZodError;
82
+ }
83
+
84
+ export interface ZodInvalidDateIssue extends ZodIssueBase {
85
+ code: typeof ZodIssueCode.invalid_date;
86
+ }
87
+
88
+ export type StringValidation =
89
+ | "email"
90
+ | "url"
91
+ | "emoji"
92
+ | "uuid"
93
+ | "nanoid"
94
+ | "regex"
95
+ | "cuid"
96
+ | "cuid2"
97
+ | "ulid"
98
+ | "datetime"
99
+ | "date"
100
+ | "time"
101
+ | "duration"
102
+ | "ip"
103
+ | "cidr"
104
+ | "base64"
105
+ | "jwt"
106
+ | "base64url"
107
+ | { includes: string; position?: number | undefined }
108
+ | { startsWith: string }
109
+ | { endsWith: string };
110
+
111
+ export interface ZodInvalidStringIssue extends ZodIssueBase {
112
+ code: typeof ZodIssueCode.invalid_string;
113
+ validation: StringValidation;
114
+ }
115
+
116
+ export interface ZodTooSmallIssue extends ZodIssueBase {
117
+ code: typeof ZodIssueCode.too_small;
118
+ minimum: number | bigint;
119
+ inclusive: boolean;
120
+ exact?: boolean;
121
+ type: "array" | "string" | "number" | "set" | "date" | "bigint";
122
+ }
123
+
124
+ export interface ZodTooBigIssue extends ZodIssueBase {
125
+ code: typeof ZodIssueCode.too_big;
126
+ maximum: number | bigint;
127
+ inclusive: boolean;
128
+ exact?: boolean;
129
+ type: "array" | "string" | "number" | "set" | "date" | "bigint";
130
+ }
131
+
132
+ export interface ZodInvalidIntersectionTypesIssue extends ZodIssueBase {
133
+ code: typeof ZodIssueCode.invalid_intersection_types;
134
+ }
135
+
136
+ export interface ZodNotMultipleOfIssue extends ZodIssueBase {
137
+ code: typeof ZodIssueCode.not_multiple_of;
138
+ multipleOf: number | bigint;
139
+ }
140
+
141
+ export interface ZodNotFiniteIssue extends ZodIssueBase {
142
+ code: typeof ZodIssueCode.not_finite;
143
+ }
144
+
145
+ export interface ZodCustomIssue extends ZodIssueBase {
146
+ code: typeof ZodIssueCode.custom;
147
+ params?: { [k: string]: any };
148
+ }
149
+
150
+ export type DenormalizedError = { [k: string]: DenormalizedError | string[] };
151
+
152
+ export type ZodIssueOptionalMessage =
153
+ | ZodInvalidTypeIssue
154
+ | ZodInvalidLiteralIssue
155
+ | ZodUnrecognizedKeysIssue
156
+ | ZodInvalidUnionIssue
157
+ | ZodInvalidUnionDiscriminatorIssue
158
+ | ZodInvalidEnumValueIssue
159
+ | ZodInvalidArgumentsIssue
160
+ | ZodInvalidReturnTypeIssue
161
+ | ZodInvalidDateIssue
162
+ | ZodInvalidStringIssue
163
+ | ZodTooSmallIssue
164
+ | ZodTooBigIssue
165
+ | ZodInvalidIntersectionTypesIssue
166
+ | ZodNotMultipleOfIssue
167
+ | ZodNotFiniteIssue
168
+ | ZodCustomIssue;
169
+
170
+ export type ZodIssue = ZodIssueOptionalMessage & {
171
+ fatal?: boolean | undefined;
172
+ message: string;
173
+ };
174
+
175
+ export const quotelessJson = (obj: any) => {
176
+ const json = JSON.stringify(obj, null, 2);
177
+ return json.replace(/"([^"]+)":/g, "$1:");
178
+ };
179
+
180
+ type recursiveZodFormattedError<T> = T extends [any, ...any[]]
181
+ ? { [K in keyof T]?: ZodFormattedError<T[K]> }
182
+ : T extends any[]
183
+ ? { [k: number]: ZodFormattedError<T[number]> }
184
+ : T extends object
185
+ ? { [K in keyof T]?: ZodFormattedError<T[K]> }
186
+ : unknown;
187
+
188
+ export type ZodFormattedError<T, U = string> = {
189
+ _errors: U[];
190
+ } & recursiveZodFormattedError<NonNullable<T>>;
191
+
192
+ export type inferFormattedError<T extends ZodType<any, any, any>, U = string> = ZodFormattedError<TypeOf<T>, U>;
193
+
194
+ export class ZodError<T = any> extends Error {
195
+ issues: ZodIssue[] = [];
196
+
197
+ get errors() {
198
+ return this.issues;
199
+ }
200
+
201
+ constructor(issues: ZodIssue[]) {
202
+ super();
203
+
204
+ const actualProto = new.target.prototype;
205
+ if (Object.setPrototypeOf) {
206
+ // eslint-disable-next-line ban/ban
207
+ Object.setPrototypeOf(this, actualProto);
208
+ } else {
209
+ (this as any).__proto__ = actualProto;
210
+ }
211
+ this.name = "ZodError";
212
+ this.issues = issues;
213
+ }
214
+
215
+ format(): ZodFormattedError<T>;
216
+ format<U>(mapper: (issue: ZodIssue) => U): ZodFormattedError<T, U>;
217
+ format(_mapper?: any) {
218
+ const mapper: (issue: ZodIssue) => any =
219
+ _mapper ||
220
+ function (issue: ZodIssue) {
221
+ return issue.message;
222
+ };
223
+ const fieldErrors: ZodFormattedError<T> = { _errors: [] } as any;
224
+ const processError = (error: ZodError) => {
225
+ for (const issue of error.issues) {
226
+ if (issue.code === "invalid_union") {
227
+ issue.unionErrors.map(processError);
228
+ } else if (issue.code === "invalid_return_type") {
229
+ processError(issue.returnTypeError);
230
+ } else if (issue.code === "invalid_arguments") {
231
+ processError(issue.argumentsError);
232
+ } else if (issue.path.length === 0) {
233
+ (fieldErrors as any)._errors.push(mapper(issue));
234
+ } else {
235
+ let curr: any = fieldErrors;
236
+ let i = 0;
237
+ while (i < issue.path.length) {
238
+ const el = issue.path[i]!;
239
+ const terminal = i === issue.path.length - 1;
240
+
241
+ if (!terminal) {
242
+ curr[el] = curr[el] || { _errors: [] };
243
+ // if (typeof el === "string") {
244
+ // curr[el] = curr[el] || { _errors: [] };
245
+ // } else if (typeof el === "number") {
246
+ // const errorArray: any = [];
247
+ // errorArray._errors = [];
248
+ // curr[el] = curr[el] || errorArray;
249
+ // }
250
+ } else {
251
+ curr[el] = curr[el] || { _errors: [] };
252
+ curr[el]._errors.push(mapper(issue));
253
+ }
254
+
255
+ curr = curr[el];
256
+ i++;
257
+ }
258
+ }
259
+ }
260
+ };
261
+
262
+ processError(this);
263
+ return fieldErrors;
264
+ }
265
+
266
+ static create = (issues: ZodIssue[]) => {
267
+ const error = new ZodError(issues);
268
+ return error;
269
+ };
270
+
271
+ static assert(value: unknown): asserts value is ZodError {
272
+ if (!(value instanceof ZodError)) {
273
+ throw new Error(`Not a ZodError: ${value}`);
274
+ }
275
+ }
276
+
277
+ override toString() {
278
+ return this.message;
279
+ }
280
+ override get message() {
281
+ return JSON.stringify(this.issues, util.jsonStringifyReplacer, 2);
282
+ }
283
+
284
+ get isEmpty(): boolean {
285
+ return this.issues.length === 0;
286
+ }
287
+
288
+ addIssue = (sub: ZodIssue) => {
289
+ this.issues = [...this.issues, sub];
290
+ };
291
+
292
+ addIssues = (subs: ZodIssue[] = []) => {
293
+ this.issues = [...this.issues, ...subs];
294
+ };
295
+
296
+ flatten(): typeToFlattenedError<T>;
297
+ flatten<U>(mapper?: (issue: ZodIssue) => U): typeToFlattenedError<T, U>;
298
+ flatten<U = string>(mapper: (issue: ZodIssue) => U = (issue: ZodIssue) => issue.message as any): any {
299
+ const fieldErrors: any = {};
300
+ const formErrors: U[] = [];
301
+ for (const sub of this.issues) {
302
+ if (sub.path.length > 0) {
303
+ const firstEl = sub.path[0]!;
304
+ fieldErrors[firstEl] = fieldErrors[firstEl] || [];
305
+ fieldErrors[firstEl].push(mapper(sub));
306
+ } else {
307
+ formErrors.push(mapper(sub));
308
+ }
309
+ }
310
+ return { formErrors, fieldErrors };
311
+ }
312
+
313
+ get formErrors() {
314
+ return this.flatten();
315
+ }
316
+ }
317
+
318
+ type stripPath<T extends object> = T extends any ? util.OmitKeys<T, "path"> : never;
319
+
320
+ export type IssueData = stripPath<ZodIssueOptionalMessage> & {
321
+ path?: (string | number)[];
322
+ fatal?: boolean | undefined;
323
+ };
324
+
325
+ export type ErrorMapCtx = {
326
+ defaultError: string;
327
+ data: any;
328
+ };
329
+
330
+ export type ZodErrorMap = (issue: ZodIssueOptionalMessage, _ctx: ErrorMapCtx) => { message: string };
node_modules/@jimp/plugin-rotate/node_modules/zod/src/v3/benchmarks/datetime.ts ADDED
@@ -0,0 +1,58 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import Benchmark from "benchmark";
2
+
3
+ const datetimeValidationSuite = new Benchmark.Suite("datetime");
4
+
5
+ const DATA = "2021-01-01";
6
+ const MONTHS_31 = new Set([1, 3, 5, 7, 8, 10, 12]);
7
+ const MONTHS_30 = new Set([4, 6, 9, 11]);
8
+
9
+ const simpleDatetimeRegex = /^(\d{4})-(\d{2})-(\d{2})$/;
10
+ const datetimeRegexNoLeapYearValidation =
11
+ /^\d{4}-((0[13578]|10|12)-31|(0[13-9]|1[0-2])-30|(0[1-9]|1[0-2])-(0[1-9]|1\d|2\d))$/;
12
+ const datetimeRegexWithLeapYearValidation =
13
+ /^((\d\d[2468][048]|\d\d[13579][26]|\d\d0[48]|[02468][048]00|[13579][26]00)-02-29|\d{4}-((0[13578]|1[02])-(0[1-9]|[12]\d|3[01])|(0[469]|11)-(0[1-9]|[12]\d|30)|(02)-(0[1-9]|1\d|2[0-8])))$/;
14
+
15
+ datetimeValidationSuite
16
+ .add("new Date()", () => {
17
+ return !Number.isNaN(new Date(DATA).getTime());
18
+ })
19
+ .add("regex (no validation)", () => {
20
+ return simpleDatetimeRegex.test(DATA);
21
+ })
22
+ .add("regex (no leap year)", () => {
23
+ return datetimeRegexNoLeapYearValidation.test(DATA);
24
+ })
25
+ .add("regex (w/ leap year)", () => {
26
+ return datetimeRegexWithLeapYearValidation.test(DATA);
27
+ })
28
+ .add("capture groups + code", () => {
29
+ const match = DATA.match(simpleDatetimeRegex);
30
+ if (!match) return false;
31
+
32
+ // Extract year, month, and day from the capture groups
33
+ const year = Number.parseInt(match[1], 10);
34
+ const month = Number.parseInt(match[2], 10); // month is 0-indexed in JavaScript Date, so subtract 1
35
+ const day = Number.parseInt(match[3], 10);
36
+
37
+ if (month === 2) {
38
+ if ((year % 4 === 0 && year % 100 !== 0) || year % 400 === 0) {
39
+ return day <= 29;
40
+ }
41
+ return day <= 28;
42
+ }
43
+ if (MONTHS_30.has(month)) {
44
+ return day <= 30;
45
+ }
46
+ if (MONTHS_31.has(month)) {
47
+ return day <= 31;
48
+ }
49
+ return false;
50
+ })
51
+
52
+ .on("cycle", (e: Benchmark.Event) => {
53
+ console.log(`${datetimeValidationSuite.name!}: ${e.target}`);
54
+ });
55
+
56
+ export default {
57
+ suites: [datetimeValidationSuite],
58
+ };
node_modules/@jimp/plugin-rotate/node_modules/zod/src/v3/benchmarks/discriminatedUnion.ts ADDED
@@ -0,0 +1,80 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import Benchmark from "benchmark";
2
+
3
+ import { z } from "zod/v3";
4
+
5
+ const doubleSuite = new Benchmark.Suite("z.discriminatedUnion: double");
6
+ const manySuite = new Benchmark.Suite("z.discriminatedUnion: many");
7
+
8
+ const aSchema = z.object({
9
+ type: z.literal("a"),
10
+ });
11
+ const objA = {
12
+ type: "a",
13
+ };
14
+
15
+ const bSchema = z.object({
16
+ type: z.literal("b"),
17
+ });
18
+ const objB = {
19
+ type: "b",
20
+ };
21
+
22
+ const cSchema = z.object({
23
+ type: z.literal("c"),
24
+ });
25
+ const objC = {
26
+ type: "c",
27
+ };
28
+
29
+ const dSchema = z.object({
30
+ type: z.literal("d"),
31
+ });
32
+
33
+ const double = z.discriminatedUnion("type", [aSchema, bSchema]);
34
+ const many = z.discriminatedUnion("type", [aSchema, bSchema, cSchema, dSchema]);
35
+
36
+ doubleSuite
37
+ .add("valid: a", () => {
38
+ double.parse(objA);
39
+ })
40
+ .add("valid: b", () => {
41
+ double.parse(objB);
42
+ })
43
+ .add("invalid: null", () => {
44
+ try {
45
+ double.parse(null);
46
+ } catch (_err) {}
47
+ })
48
+ .add("invalid: wrong shape", () => {
49
+ try {
50
+ double.parse(objC);
51
+ } catch (_err) {}
52
+ })
53
+ .on("cycle", (e: Benchmark.Event) => {
54
+ console.log(`${(doubleSuite as any).name}: ${e.target}`);
55
+ });
56
+
57
+ manySuite
58
+ .add("valid: a", () => {
59
+ many.parse(objA);
60
+ })
61
+ .add("valid: c", () => {
62
+ many.parse(objC);
63
+ })
64
+ .add("invalid: null", () => {
65
+ try {
66
+ many.parse(null);
67
+ } catch (_err) {}
68
+ })
69
+ .add("invalid: wrong shape", () => {
70
+ try {
71
+ many.parse({ type: "unknown" });
72
+ } catch (_err) {}
73
+ })
74
+ .on("cycle", (e: Benchmark.Event) => {
75
+ console.log(`${(manySuite as any).name}: ${e.target}`);
76
+ });
77
+
78
+ export default {
79
+ suites: [doubleSuite, manySuite],
80
+ };
node_modules/@jimp/plugin-rotate/node_modules/zod/src/v3/benchmarks/index.ts ADDED
@@ -0,0 +1,59 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import type Benchmark from "benchmark";
2
+
3
+ import datetimeBenchmarks from "./datetime.js";
4
+ import discriminatedUnionBenchmarks from "./discriminatedUnion.js";
5
+ import ipv4Benchmarks from "./ipv4.js";
6
+ import objectBenchmarks from "./object.js";
7
+ import primitiveBenchmarks from "./primitives.js";
8
+ import realworld from "./realworld.js";
9
+ import stringBenchmarks from "./string.js";
10
+ import unionBenchmarks from "./union.js";
11
+
12
+ const argv = process.argv.slice(2);
13
+ let suites: Benchmark.Suite[] = [];
14
+
15
+ if (!argv.length) {
16
+ suites = [
17
+ ...realworld.suites,
18
+ ...primitiveBenchmarks.suites,
19
+ ...stringBenchmarks.suites,
20
+ ...objectBenchmarks.suites,
21
+ ...unionBenchmarks.suites,
22
+ ...discriminatedUnionBenchmarks.suites,
23
+ ];
24
+ } else {
25
+ if (argv.includes("--realworld")) {
26
+ suites.push(...realworld.suites);
27
+ }
28
+ if (argv.includes("--primitives")) {
29
+ suites.push(...primitiveBenchmarks.suites);
30
+ }
31
+ if (argv.includes("--string")) {
32
+ suites.push(...stringBenchmarks.suites);
33
+ }
34
+ if (argv.includes("--object")) {
35
+ suites.push(...objectBenchmarks.suites);
36
+ }
37
+ if (argv.includes("--union")) {
38
+ suites.push(...unionBenchmarks.suites);
39
+ }
40
+ if (argv.includes("--discriminatedUnion")) {
41
+ suites.push(...datetimeBenchmarks.suites);
42
+ }
43
+ if (argv.includes("--datetime")) {
44
+ suites.push(...datetimeBenchmarks.suites);
45
+ }
46
+ if (argv.includes("--ipv4")) {
47
+ suites.push(...ipv4Benchmarks.suites);
48
+ }
49
+ }
50
+
51
+ for (const suite of suites) {
52
+ suite.run({});
53
+ }
54
+
55
+ // exit on Ctrl-C
56
+ process.on("SIGINT", function () {
57
+ console.log("Exiting...");
58
+ process.exit();
59
+ });
node_modules/@jimp/plugin-rotate/node_modules/zod/src/v3/benchmarks/ipv4.ts ADDED
@@ -0,0 +1,57 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import Benchmark from "benchmark";
2
+
3
+ const suite = new Benchmark.Suite("ipv4");
4
+
5
+ const DATA = "127.0.0.1";
6
+ const ipv4RegexA =
7
+ /^(((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2}))\.){3}((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2}))$/;
8
+ const ipv4RegexB =
9
+ /^(?:(?:(?=(25[0-5]))\1|(?=(2[0-4][0-9]))\2|(?=(1[0-9]{2}))\3|(?=([0-9]{1,2}))\4)\.){3}(?:(?=(25[0-5]))\5|(?=(2[0-4][0-9]))\6|(?=(1[0-9]{2}))\7|(?=([0-9]{1,2}))\8)$/;
10
+ const ipv4RegexC = /^(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)\.){3}(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)$/;
11
+ const ipv4RegexD = /^(\b25[0-5]|\b2[0-4][0-9]|\b[01]?[0-9][0-9]?)(\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)){3}$/;
12
+ const ipv4RegexE = /^((25[0-5]|(2[0-4]|1\d|[1-9]|)\d)\.){3}(25[0-5]|(2[0-4]|1\d|[1-9]|)\d)$/;
13
+ const ipv4RegexF = /^((25[0-5]|(2[0-4]|1\d|[1-9]|)\d)\.?\b){4}$/;
14
+ const ipv4RegexG = /^((25[0-5]|(2[0-4]|1\d|[1-9]|)\d)(\.(?!$)|$)){4}$/;
15
+ const ipv4RegexH = /^((25[0-5]|(2[0-4]|1[0-9]|[1-9]|)[0-9])(\.(?!$)|$)){4}$/;
16
+ const ipv4RegexI =
17
+ /^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/;
18
+
19
+ suite
20
+ .add("A", () => {
21
+ return ipv4RegexA.test(DATA);
22
+ })
23
+ .add("B", () => {
24
+ return ipv4RegexB.test(DATA);
25
+ })
26
+ .add("C", () => {
27
+ return ipv4RegexC.test(DATA);
28
+ })
29
+ .add("D", () => {
30
+ return ipv4RegexD.test(DATA);
31
+ })
32
+ .add("E", () => {
33
+ return ipv4RegexE.test(DATA);
34
+ })
35
+ .add("F", () => {
36
+ return ipv4RegexF.test(DATA);
37
+ })
38
+ .add("G", () => {
39
+ return ipv4RegexG.test(DATA);
40
+ })
41
+ .add("H", () => {
42
+ return ipv4RegexH.test(DATA);
43
+ })
44
+ .add("I", () => {
45
+ return ipv4RegexI.test(DATA);
46
+ })
47
+ .on("cycle", (e: Benchmark.Event) => {
48
+ console.log(`${suite.name!}: ${e.target}`);
49
+ });
50
+
51
+ export default {
52
+ suites: [suite],
53
+ };
54
+
55
+ if (require.main === module) {
56
+ suite.run();
57
+ }
node_modules/@jimp/plugin-rotate/node_modules/zod/src/v3/benchmarks/object.ts ADDED
@@ -0,0 +1,69 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import Benchmark from "benchmark";
2
+
3
+ import { z } from "zod/v3";
4
+
5
+ const emptySuite = new Benchmark.Suite("z.object: empty");
6
+ const shortSuite = new Benchmark.Suite("z.object: short");
7
+ const longSuite = new Benchmark.Suite("z.object: long");
8
+
9
+ const empty = z.object({});
10
+ const short = z.object({
11
+ string: z.string(),
12
+ });
13
+ const long = z.object({
14
+ string: z.string(),
15
+ number: z.number(),
16
+ boolean: z.boolean(),
17
+ });
18
+
19
+ emptySuite
20
+ .add("valid", () => {
21
+ empty.parse({});
22
+ })
23
+ .add("valid: extra keys", () => {
24
+ empty.parse({ string: "string" });
25
+ })
26
+ .add("invalid: null", () => {
27
+ try {
28
+ empty.parse(null);
29
+ } catch (_err) {}
30
+ })
31
+ .on("cycle", (e: Benchmark.Event) => {
32
+ console.log(`${(emptySuite as any).name}: ${e.target}`);
33
+ });
34
+
35
+ shortSuite
36
+ .add("valid", () => {
37
+ short.parse({ string: "string" });
38
+ })
39
+ .add("valid: extra keys", () => {
40
+ short.parse({ string: "string", number: 42 });
41
+ })
42
+ .add("invalid: null", () => {
43
+ try {
44
+ short.parse(null);
45
+ } catch (_err) {}
46
+ })
47
+ .on("cycle", (e: Benchmark.Event) => {
48
+ console.log(`${(shortSuite as any).name}: ${e.target}`);
49
+ });
50
+
51
+ longSuite
52
+ .add("valid", () => {
53
+ long.parse({ string: "string", number: 42, boolean: true });
54
+ })
55
+ .add("valid: extra keys", () => {
56
+ long.parse({ string: "string", number: 42, boolean: true, list: [] });
57
+ })
58
+ .add("invalid: null", () => {
59
+ try {
60
+ long.parse(null);
61
+ } catch (_err) {}
62
+ })
63
+ .on("cycle", (e: Benchmark.Event) => {
64
+ console.log(`${(longSuite as any).name}: ${e.target}`);
65
+ });
66
+
67
+ export default {
68
+ suites: [emptySuite, shortSuite, longSuite],
69
+ };
node_modules/@jimp/plugin-rotate/node_modules/zod/src/v3/benchmarks/primitives.ts ADDED
@@ -0,0 +1,162 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import Benchmark from "benchmark";
2
+
3
+ import { z } from "zod/v3";
4
+ import { Mocker } from "../tests/Mocker.js";
5
+
6
+ const val = new Mocker();
7
+
8
+ const enumSuite = new Benchmark.Suite("z.enum");
9
+ const enumSchema = z.enum(["a", "b", "c"]);
10
+
11
+ enumSuite
12
+ .add("valid", () => {
13
+ enumSchema.parse("a");
14
+ })
15
+ .add("invalid", () => {
16
+ try {
17
+ enumSchema.parse("x");
18
+ } catch (_e: any) {}
19
+ })
20
+ .on("cycle", (e: Benchmark.Event) => {
21
+ console.log(`z.enum: ${e.target}`);
22
+ });
23
+
24
+ const longEnumSuite = new Benchmark.Suite("long z.enum");
25
+ const longEnumSchema = z.enum([
26
+ "one",
27
+ "two",
28
+ "three",
29
+ "four",
30
+ "five",
31
+ "six",
32
+ "seven",
33
+ "eight",
34
+ "nine",
35
+ "ten",
36
+ "eleven",
37
+ "twelve",
38
+ "thirteen",
39
+ "fourteen",
40
+ "fifteen",
41
+ "sixteen",
42
+ "seventeen",
43
+ ]);
44
+
45
+ longEnumSuite
46
+ .add("valid", () => {
47
+ longEnumSchema.parse("five");
48
+ })
49
+ .add("invalid", () => {
50
+ try {
51
+ longEnumSchema.parse("invalid");
52
+ } catch (_e: any) {}
53
+ })
54
+ .on("cycle", (e: Benchmark.Event) => {
55
+ console.log(`long z.enum: ${e.target}`);
56
+ });
57
+
58
+ const undefinedSuite = new Benchmark.Suite("z.undefined");
59
+ const undefinedSchema = z.undefined();
60
+
61
+ undefinedSuite
62
+ .add("valid", () => {
63
+ undefinedSchema.parse(undefined);
64
+ })
65
+ .add("invalid", () => {
66
+ try {
67
+ undefinedSchema.parse(1);
68
+ } catch (_e: any) {}
69
+ })
70
+ .on("cycle", (e: Benchmark.Event) => {
71
+ console.log(`z.undefined: ${e.target}`);
72
+ });
73
+
74
+ const literalSuite = new Benchmark.Suite("z.literal");
75
+ const short = "short";
76
+ const bad = "bad";
77
+ const literalSchema = z.literal("short");
78
+
79
+ literalSuite
80
+ .add("valid", () => {
81
+ literalSchema.parse(short);
82
+ })
83
+ .add("invalid", () => {
84
+ try {
85
+ literalSchema.parse(bad);
86
+ } catch (_e: any) {}
87
+ })
88
+ .on("cycle", (e: Benchmark.Event) => {
89
+ console.log(`z.literal: ${e.target}`);
90
+ });
91
+
92
+ const numberSuite = new Benchmark.Suite("z.number");
93
+ const numberSchema = z.number().int();
94
+
95
+ numberSuite
96
+ .add("valid", () => {
97
+ numberSchema.parse(1);
98
+ })
99
+ .add("invalid type", () => {
100
+ try {
101
+ numberSchema.parse("bad");
102
+ } catch (_e: any) {}
103
+ })
104
+ .add("invalid number", () => {
105
+ try {
106
+ numberSchema.parse(0.5);
107
+ } catch (_e: any) {}
108
+ })
109
+ .on("cycle", (e: Benchmark.Event) => {
110
+ console.log(`z.number: ${e.target}`);
111
+ });
112
+
113
+ const dateSuite = new Benchmark.Suite("z.date");
114
+
115
+ const plainDate = z.date();
116
+ const minMaxDate = z.date().min(new Date("2021-01-01")).max(new Date("2030-01-01"));
117
+
118
+ dateSuite
119
+ .add("valid", () => {
120
+ plainDate.parse(new Date());
121
+ })
122
+ .add("invalid", () => {
123
+ try {
124
+ plainDate.parse(1);
125
+ } catch (_e: any) {}
126
+ })
127
+ .add("valid min and max", () => {
128
+ minMaxDate.parse(new Date("2023-01-01"));
129
+ })
130
+ .add("invalid min", () => {
131
+ try {
132
+ minMaxDate.parse(new Date("2019-01-01"));
133
+ } catch (_e: any) {}
134
+ })
135
+ .add("invalid max", () => {
136
+ try {
137
+ minMaxDate.parse(new Date("2031-01-01"));
138
+ } catch (_e: any) {}
139
+ })
140
+ .on("cycle", (e: Benchmark.Event) => {
141
+ console.log(`z.date: ${e.target}`);
142
+ });
143
+
144
+ const symbolSuite = new Benchmark.Suite("z.symbol");
145
+ const symbolSchema = z.symbol();
146
+
147
+ symbolSuite
148
+ .add("valid", () => {
149
+ symbolSchema.parse(val.symbol);
150
+ })
151
+ .add("invalid", () => {
152
+ try {
153
+ symbolSchema.parse(1);
154
+ } catch (_e: any) {}
155
+ })
156
+ .on("cycle", (e: Benchmark.Event) => {
157
+ console.log(`z.symbol: ${e.target}`);
158
+ });
159
+
160
+ export default {
161
+ suites: [enumSuite, longEnumSuite, undefinedSuite, literalSuite, numberSuite, dateSuite, symbolSuite],
162
+ };
node_modules/@jimp/plugin-rotate/node_modules/zod/src/v3/benchmarks/realworld.ts ADDED
@@ -0,0 +1,63 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import Benchmark from "benchmark";
2
+
3
+ import { z } from "zod/v3";
4
+
5
+ const shortSuite = new Benchmark.Suite("realworld");
6
+
7
+ const People = z.array(
8
+ z.object({
9
+ type: z.literal("person"),
10
+ hair: z.enum(["blue", "brown"]),
11
+ active: z.boolean(),
12
+ name: z.string(),
13
+ age: z.number().int(),
14
+ hobbies: z.array(z.string()),
15
+ address: z.object({
16
+ street: z.string(),
17
+ zip: z.string(),
18
+ country: z.string(),
19
+ }),
20
+ })
21
+ );
22
+
23
+ let i = 0;
24
+
25
+ function num() {
26
+ return ++i;
27
+ }
28
+
29
+ function str() {
30
+ return (++i % 100).toString(16);
31
+ }
32
+
33
+ function array<T>(fn: () => T): T[] {
34
+ return Array.from({ length: ++i % 10 }, () => fn());
35
+ }
36
+
37
+ const people = Array.from({ length: 100 }, () => {
38
+ return {
39
+ type: "person",
40
+ hair: i % 2 ? "blue" : "brown",
41
+ active: !!(i % 2),
42
+ name: str(),
43
+ age: num(),
44
+ hobbies: array(str),
45
+ address: {
46
+ street: str(),
47
+ zip: str(),
48
+ country: str(),
49
+ },
50
+ };
51
+ });
52
+
53
+ shortSuite
54
+ .add("valid", () => {
55
+ People.parse(people);
56
+ })
57
+ .on("cycle", (e: Benchmark.Event) => {
58
+ console.log(`${(shortSuite as any).name}: ${e.target}`);
59
+ });
60
+
61
+ export default {
62
+ suites: [shortSuite],
63
+ };
node_modules/@jimp/plugin-rotate/node_modules/zod/src/v3/benchmarks/string.ts ADDED
@@ -0,0 +1,55 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import Benchmark from "benchmark";
2
+
3
+ import { z } from "zod/v3";
4
+
5
+ const SUITE_NAME = "z.string";
6
+ const suite = new Benchmark.Suite(SUITE_NAME);
7
+
8
+ const empty = "";
9
+ const short = "short";
10
+ const long = "long".repeat(256);
11
+ const manual = (str: unknown) => {
12
+ if (typeof str !== "string") {
13
+ throw new Error("Not a string");
14
+ }
15
+
16
+ return str;
17
+ };
18
+ const stringSchema = z.string();
19
+ const optionalStringSchema = z.string().optional();
20
+ const optionalNullableStringSchema = z.string().optional().nullable();
21
+
22
+ suite
23
+ .add("empty string", () => {
24
+ stringSchema.parse(empty);
25
+ })
26
+ .add("short string", () => {
27
+ stringSchema.parse(short);
28
+ })
29
+ .add("long string", () => {
30
+ stringSchema.parse(long);
31
+ })
32
+ .add("optional string", () => {
33
+ optionalStringSchema.parse(long);
34
+ })
35
+ .add("nullable string", () => {
36
+ optionalNullableStringSchema.parse(long);
37
+ })
38
+ .add("nullable (null) string", () => {
39
+ optionalNullableStringSchema.parse(null);
40
+ })
41
+ .add("invalid: null", () => {
42
+ try {
43
+ stringSchema.parse(null);
44
+ } catch (_err) {}
45
+ })
46
+ .add("manual parser: long", () => {
47
+ manual(long);
48
+ })
49
+ .on("cycle", (e: Benchmark.Event) => {
50
+ console.log(`${SUITE_NAME}: ${e.target}`);
51
+ });
52
+
53
+ export default {
54
+ suites: [suite],
55
+ };
node_modules/@jimp/plugin-rotate/node_modules/zod/src/v3/benchmarks/union.ts ADDED
@@ -0,0 +1,80 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import Benchmark from "benchmark";
2
+
3
+ import { z } from "zod/v3";
4
+
5
+ const doubleSuite = new Benchmark.Suite("z.union: double");
6
+ const manySuite = new Benchmark.Suite("z.union: many");
7
+
8
+ const aSchema = z.object({
9
+ type: z.literal("a"),
10
+ });
11
+ const objA = {
12
+ type: "a",
13
+ };
14
+
15
+ const bSchema = z.object({
16
+ type: z.literal("b"),
17
+ });
18
+ const objB = {
19
+ type: "b",
20
+ };
21
+
22
+ const cSchema = z.object({
23
+ type: z.literal("c"),
24
+ });
25
+ const objC = {
26
+ type: "c",
27
+ };
28
+
29
+ const dSchema = z.object({
30
+ type: z.literal("d"),
31
+ });
32
+
33
+ const double = z.union([aSchema, bSchema]);
34
+ const many = z.union([aSchema, bSchema, cSchema, dSchema]);
35
+
36
+ doubleSuite
37
+ .add("valid: a", () => {
38
+ double.parse(objA);
39
+ })
40
+ .add("valid: b", () => {
41
+ double.parse(objB);
42
+ })
43
+ .add("invalid: null", () => {
44
+ try {
45
+ double.parse(null);
46
+ } catch (_err) {}
47
+ })
48
+ .add("invalid: wrong shape", () => {
49
+ try {
50
+ double.parse(objC);
51
+ } catch (_err) {}
52
+ })
53
+ .on("cycle", (e: Benchmark.Event) => {
54
+ console.log(`${(doubleSuite as any).name}: ${e.target}`);
55
+ });
56
+
57
+ manySuite
58
+ .add("valid: a", () => {
59
+ many.parse(objA);
60
+ })
61
+ .add("valid: c", () => {
62
+ many.parse(objC);
63
+ })
64
+ .add("invalid: null", () => {
65
+ try {
66
+ many.parse(null);
67
+ } catch (_err) {}
68
+ })
69
+ .add("invalid: wrong shape", () => {
70
+ try {
71
+ many.parse({ type: "unknown" });
72
+ } catch (_err) {}
73
+ })
74
+ .on("cycle", (e: Benchmark.Event) => {
75
+ console.log(`${(manySuite as any).name}: ${e.target}`);
76
+ });
77
+
78
+ export default {
79
+ suites: [doubleSuite, manySuite],
80
+ };
node_modules/@jimp/plugin-rotate/node_modules/zod/src/v3/errors.ts ADDED
@@ -0,0 +1,13 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import type { ZodErrorMap } from "./ZodError.js";
2
+ import defaultErrorMap from "./locales/en.js";
3
+
4
+ let overrideErrorMap = defaultErrorMap;
5
+ export { defaultErrorMap };
6
+
7
+ export function setErrorMap(map: ZodErrorMap) {
8
+ overrideErrorMap = map;
9
+ }
10
+
11
+ export function getErrorMap() {
12
+ return overrideErrorMap;
13
+ }
node_modules/@jimp/plugin-rotate/node_modules/zod/src/v3/external.ts ADDED
@@ -0,0 +1,6 @@
 
 
 
 
 
 
 
1
+ export * from "./errors.js";
2
+ export * from "./helpers/parseUtil.js";
3
+ export * from "./helpers/typeAliases.js";
4
+ export * from "./helpers/util.js";
5
+ export * from "./types.js";
6
+ export * from "./ZodError.js";