next-image-transformer 0.2.3 → 0.2.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/server.js +113 -4128
- package/package.json +4 -3
package/dist/server.js
CHANGED
|
@@ -1,4213 +1,198 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { z as
|
|
3
|
-
import
|
|
4
|
-
import
|
|
5
|
-
import
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
import Yr from "fs";
|
|
9
|
-
import Kr from "node:child_process";
|
|
10
|
-
import Jr from "node:events";
|
|
11
|
-
import Zr from "node:os";
|
|
12
|
-
function et({
|
|
13
|
-
canonicalUrl: e
|
|
1
|
+
import h from "node:path";
|
|
2
|
+
import { z as C, c as B } from "./index-C4FbrW_M.js";
|
|
3
|
+
import { createHash as U } from "node:crypto";
|
|
4
|
+
import m from "node:fs/promises";
|
|
5
|
+
import b from "sharp";
|
|
6
|
+
function j({
|
|
7
|
+
canonicalUrl: r
|
|
14
8
|
}) {
|
|
15
|
-
return
|
|
9
|
+
return U("sha256").update(r).digest("hex");
|
|
16
10
|
}
|
|
17
|
-
function
|
|
18
|
-
cacheKey:
|
|
19
|
-
cacheDir:
|
|
11
|
+
function P({
|
|
12
|
+
cacheKey: r,
|
|
13
|
+
cacheDir: n
|
|
20
14
|
}) {
|
|
21
|
-
const
|
|
15
|
+
const s = r.slice(0, 2), a = r.slice(2), e = h.join(n, s);
|
|
22
16
|
return {
|
|
23
|
-
dir:
|
|
24
|
-
bodyPath:
|
|
25
|
-
metaPath:
|
|
17
|
+
dir: e,
|
|
18
|
+
bodyPath: h.join(e, `${a}.bin`),
|
|
19
|
+
metaPath: h.join(e, `${a}.json`)
|
|
26
20
|
};
|
|
27
21
|
}
|
|
28
|
-
async function
|
|
29
|
-
cacheKey:
|
|
30
|
-
cacheDir:
|
|
22
|
+
async function q({
|
|
23
|
+
cacheKey: r,
|
|
24
|
+
cacheDir: n
|
|
31
25
|
}) {
|
|
32
|
-
const { bodyPath:
|
|
26
|
+
const { bodyPath: s, metaPath: a } = P({ cacheKey: r, cacheDir: n });
|
|
33
27
|
try {
|
|
34
|
-
const [
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
]),
|
|
28
|
+
const [e, u] = await Promise.all([
|
|
29
|
+
m.readFile(s),
|
|
30
|
+
m.readFile(a, "utf8")
|
|
31
|
+
]), o = (() => {
|
|
38
32
|
try {
|
|
39
|
-
const
|
|
40
|
-
contentType:
|
|
41
|
-
}).loose().safeParse(
|
|
42
|
-
return
|
|
33
|
+
const i = JSON.parse(u), t = C.object({
|
|
34
|
+
contentType: C.string()
|
|
35
|
+
}).loose().safeParse(i);
|
|
36
|
+
return t.success ? t.data : null;
|
|
43
37
|
} catch {
|
|
44
38
|
return null;
|
|
45
39
|
}
|
|
46
40
|
})();
|
|
47
|
-
return
|
|
48
|
-
} catch (
|
|
49
|
-
if (
|
|
41
|
+
return o ? { body: new Uint8Array(e), contentType: o.contentType } : null;
|
|
42
|
+
} catch (e) {
|
|
43
|
+
if (e instanceof Error && "code" in e && e.code === "ENOENT")
|
|
50
44
|
return null;
|
|
51
|
-
throw
|
|
45
|
+
throw e;
|
|
52
46
|
}
|
|
53
47
|
}
|
|
54
|
-
function
|
|
55
|
-
return e && e.__esModule && Object.prototype.hasOwnProperty.call(e, "default") ? e.default : e;
|
|
56
|
-
}
|
|
57
|
-
var he, Ze;
|
|
58
|
-
function ee() {
|
|
59
|
-
if (Ze) return he;
|
|
60
|
-
Ze = 1;
|
|
61
|
-
const e = (u) => typeof u < "u" && u !== null;
|
|
62
|
-
return he = {
|
|
63
|
-
defined: e,
|
|
64
|
-
object: (u) => typeof u == "object",
|
|
65
|
-
plainObject: (u) => Object.prototype.toString.call(u) === "[object Object]",
|
|
66
|
-
fn: (u) => typeof u == "function",
|
|
67
|
-
bool: (u) => typeof u == "boolean",
|
|
68
|
-
buffer: (u) => u instanceof Buffer,
|
|
69
|
-
typedArray: (u) => {
|
|
70
|
-
if (e(u))
|
|
71
|
-
switch (u.constructor) {
|
|
72
|
-
case Uint8Array:
|
|
73
|
-
case Uint8ClampedArray:
|
|
74
|
-
case Int8Array:
|
|
75
|
-
case Uint16Array:
|
|
76
|
-
case Int16Array:
|
|
77
|
-
case Uint32Array:
|
|
78
|
-
case Int32Array:
|
|
79
|
-
case Float32Array:
|
|
80
|
-
case Float64Array:
|
|
81
|
-
return !0;
|
|
82
|
-
}
|
|
83
|
-
return !1;
|
|
84
|
-
},
|
|
85
|
-
arrayBuffer: (u) => u instanceof ArrayBuffer,
|
|
86
|
-
string: (u) => typeof u == "string" && u.length > 0,
|
|
87
|
-
number: (u) => typeof u == "number" && !Number.isNaN(u),
|
|
88
|
-
integer: (u) => Number.isInteger(u),
|
|
89
|
-
inRange: (u, I, $) => u >= I && u <= $,
|
|
90
|
-
inArray: (u, I) => I.includes(u),
|
|
91
|
-
invalidParameterError: (u, I, $) => new Error(
|
|
92
|
-
`Expected ${I} for ${u} but received ${$} of type ${typeof $}`
|
|
93
|
-
),
|
|
94
|
-
nativeError: (u, I) => (I.message = u.message, I)
|
|
95
|
-
}, he;
|
|
96
|
-
}
|
|
97
|
-
function ie(e) {
|
|
98
|
-
throw new Error('Could not dynamically require "' + e + '". Please configure the dynamicRequireTargets or/and ignoreDynamicRequires option of @rollup/plugin-commonjs appropriately for this require call to work.');
|
|
99
|
-
}
|
|
100
|
-
var ue = { exports: {} }, de, er;
|
|
101
|
-
function it() {
|
|
102
|
-
if (er) return de;
|
|
103
|
-
er = 1;
|
|
104
|
-
const e = () => process.platform === "linux";
|
|
105
|
-
let i = null;
|
|
106
|
-
return de = { isLinux: e, getReport: () => {
|
|
107
|
-
if (!i)
|
|
108
|
-
if (e() && process.report) {
|
|
109
|
-
const y = process.report.excludeNetwork;
|
|
110
|
-
process.report.excludeNetwork = !0, i = process.report.getReport(), process.report.excludeNetwork = y;
|
|
111
|
-
} else
|
|
112
|
-
i = {};
|
|
113
|
-
return i;
|
|
114
|
-
} }, de;
|
|
115
|
-
}
|
|
116
|
-
var me, rr;
|
|
117
|
-
function nt() {
|
|
118
|
-
if (rr) return me;
|
|
119
|
-
rr = 1;
|
|
120
|
-
const e = Yr, i = "/usr/bin/ldd", P = "/proc/self/exe", y = 2048;
|
|
121
|
-
return me = {
|
|
122
|
-
LDD_PATH: i,
|
|
123
|
-
SELF_PATH: P,
|
|
124
|
-
readFileSync: (R) => {
|
|
125
|
-
const w = e.openSync(R, "r"), d = Buffer.alloc(y), g = e.readSync(w, d, 0, y, 0);
|
|
126
|
-
return e.close(w, () => {
|
|
127
|
-
}), d.subarray(0, g);
|
|
128
|
-
},
|
|
129
|
-
readFile: (R) => new Promise((w, d) => {
|
|
130
|
-
e.open(R, "r", (g, c) => {
|
|
131
|
-
if (g)
|
|
132
|
-
d(g);
|
|
133
|
-
else {
|
|
134
|
-
const p = Buffer.alloc(y);
|
|
135
|
-
e.read(c, p, 0, y, 0, (n, k) => {
|
|
136
|
-
w(p.subarray(0, k)), e.close(c, () => {
|
|
137
|
-
});
|
|
138
|
-
});
|
|
139
|
-
}
|
|
140
|
-
});
|
|
141
|
-
})
|
|
142
|
-
}, me;
|
|
143
|
-
}
|
|
144
|
-
var ge, tr;
|
|
145
|
-
function at() {
|
|
146
|
-
return tr || (tr = 1, ge = {
|
|
147
|
-
interpreterPath: (i) => {
|
|
148
|
-
if (i.length < 64 || i.readUInt32BE(0) !== 2135247942 || i.readUInt8(4) !== 2 || i.readUInt8(5) !== 1)
|
|
149
|
-
return null;
|
|
150
|
-
const P = i.readUInt32LE(32), y = i.readUInt16LE(54), b = i.readUInt16LE(56);
|
|
151
|
-
for (let S = 0; S < b; S++) {
|
|
152
|
-
const R = P + S * y;
|
|
153
|
-
if (i.readUInt32LE(R) === 3) {
|
|
154
|
-
const d = i.readUInt32LE(R + 8), g = i.readUInt32LE(R + 32);
|
|
155
|
-
return i.subarray(d, d + g).toString().replace(/\0.*$/g, "");
|
|
156
|
-
}
|
|
157
|
-
}
|
|
158
|
-
return null;
|
|
159
|
-
}
|
|
160
|
-
}), ge;
|
|
161
|
-
}
|
|
162
|
-
var be, ir;
|
|
163
|
-
function Qe() {
|
|
164
|
-
if (ir) return be;
|
|
165
|
-
ir = 1;
|
|
166
|
-
const e = Qr, { isLinux: i, getReport: P } = it(), { LDD_PATH: y, SELF_PATH: b, readFile: S, readFileSync: R } = nt(), { interpreterPath: w } = at();
|
|
167
|
-
let d, g, c;
|
|
168
|
-
const p = "getconf GNU_LIBC_VERSION 2>&1 || true; ldd --version 2>&1 || true";
|
|
169
|
-
let n = "";
|
|
170
|
-
const k = () => n || new Promise((m) => {
|
|
171
|
-
e.exec(p, (L, M) => {
|
|
172
|
-
n = L ? " " : M, m(n);
|
|
173
|
-
});
|
|
174
|
-
}), h = () => {
|
|
175
|
-
if (!n)
|
|
176
|
-
try {
|
|
177
|
-
n = e.execSync(p, { encoding: "utf8" });
|
|
178
|
-
} catch {
|
|
179
|
-
n = " ";
|
|
180
|
-
}
|
|
181
|
-
return n;
|
|
182
|
-
}, u = "glibc", I = /LIBC[a-z0-9 \-).]*?(\d+\.\d+)/i, $ = "musl", z = (m) => m.includes("libc.musl-") || m.includes("ld-musl-"), O = () => {
|
|
183
|
-
const m = P();
|
|
184
|
-
return m.header && m.header.glibcVersionRuntime ? u : Array.isArray(m.sharedObjects) && m.sharedObjects.some(z) ? $ : null;
|
|
185
|
-
}, H = (m) => {
|
|
186
|
-
const [L, M] = m.split(/[\r\n]+/);
|
|
187
|
-
return L && L.includes(u) ? u : M && M.includes($) ? $ : null;
|
|
188
|
-
}, W = (m) => {
|
|
189
|
-
if (m) {
|
|
190
|
-
if (m.includes("/ld-musl-"))
|
|
191
|
-
return $;
|
|
192
|
-
if (m.includes("/ld-linux-"))
|
|
193
|
-
return u;
|
|
194
|
-
}
|
|
195
|
-
return null;
|
|
196
|
-
}, Q = (m) => (m = m.toString(), m.includes("musl") ? $ : m.includes("GNU C Library") ? u : null), Y = async () => {
|
|
197
|
-
if (g !== void 0)
|
|
198
|
-
return g;
|
|
199
|
-
g = null;
|
|
200
|
-
try {
|
|
201
|
-
const m = await S(y);
|
|
202
|
-
g = Q(m);
|
|
203
|
-
} catch {
|
|
204
|
-
}
|
|
205
|
-
return g;
|
|
206
|
-
}, V = () => {
|
|
207
|
-
if (g !== void 0)
|
|
208
|
-
return g;
|
|
209
|
-
g = null;
|
|
210
|
-
try {
|
|
211
|
-
const m = R(y);
|
|
212
|
-
g = Q(m);
|
|
213
|
-
} catch {
|
|
214
|
-
}
|
|
215
|
-
return g;
|
|
216
|
-
}, f = async () => {
|
|
217
|
-
if (d !== void 0)
|
|
218
|
-
return d;
|
|
219
|
-
d = null;
|
|
220
|
-
try {
|
|
221
|
-
const m = await S(b), L = w(m);
|
|
222
|
-
d = W(L);
|
|
223
|
-
} catch {
|
|
224
|
-
}
|
|
225
|
-
return d;
|
|
226
|
-
}, N = () => {
|
|
227
|
-
if (d !== void 0)
|
|
228
|
-
return d;
|
|
229
|
-
d = null;
|
|
230
|
-
try {
|
|
231
|
-
const m = R(b), L = w(m);
|
|
232
|
-
d = W(L);
|
|
233
|
-
} catch {
|
|
234
|
-
}
|
|
235
|
-
return d;
|
|
236
|
-
}, G = async () => {
|
|
237
|
-
let m = null;
|
|
238
|
-
if (i() && (m = await f(), !m && (m = await Y(), m || (m = O()), !m))) {
|
|
239
|
-
const L = await k();
|
|
240
|
-
m = H(L);
|
|
241
|
-
}
|
|
242
|
-
return m;
|
|
243
|
-
}, K = () => {
|
|
244
|
-
let m = null;
|
|
245
|
-
if (i() && (m = N(), !m && (m = V(), m || (m = O()), !m))) {
|
|
246
|
-
const L = h();
|
|
247
|
-
m = H(L);
|
|
248
|
-
}
|
|
249
|
-
return m;
|
|
250
|
-
}, re = async () => i() && await G() !== u, A = () => i() && K() !== u, j = async () => {
|
|
251
|
-
if (c !== void 0)
|
|
252
|
-
return c;
|
|
253
|
-
c = null;
|
|
254
|
-
try {
|
|
255
|
-
const L = (await S(y)).match(I);
|
|
256
|
-
L && (c = L[1]);
|
|
257
|
-
} catch {
|
|
258
|
-
}
|
|
259
|
-
return c;
|
|
260
|
-
}, F = () => {
|
|
261
|
-
if (c !== void 0)
|
|
262
|
-
return c;
|
|
263
|
-
c = null;
|
|
264
|
-
try {
|
|
265
|
-
const L = R(y).match(I);
|
|
266
|
-
L && (c = L[1]);
|
|
267
|
-
} catch {
|
|
268
|
-
}
|
|
269
|
-
return c;
|
|
270
|
-
}, T = () => {
|
|
271
|
-
const m = P();
|
|
272
|
-
return m.header && m.header.glibcVersionRuntime ? m.header.glibcVersionRuntime : null;
|
|
273
|
-
}, B = (m) => m.trim().split(/\s+/)[1], _ = (m) => {
|
|
274
|
-
const [L, M, U] = m.split(/[\r\n]+/);
|
|
275
|
-
return L && L.includes(u) ? B(L) : M && U && M.includes($) ? B(U) : null;
|
|
276
|
-
};
|
|
277
|
-
return be = {
|
|
278
|
-
GLIBC: u,
|
|
279
|
-
MUSL: $,
|
|
280
|
-
family: G,
|
|
281
|
-
familySync: K,
|
|
282
|
-
isNonGlibcLinux: re,
|
|
283
|
-
isNonGlibcLinuxSync: A,
|
|
284
|
-
version: async () => {
|
|
285
|
-
let m = null;
|
|
286
|
-
if (i() && (m = await j(), m || (m = T()), !m)) {
|
|
287
|
-
const L = await k();
|
|
288
|
-
m = _(L);
|
|
289
|
-
}
|
|
290
|
-
return m;
|
|
291
|
-
},
|
|
292
|
-
versionSync: () => {
|
|
293
|
-
let m = null;
|
|
294
|
-
if (i() && (m = F(), m || (m = T()), !m)) {
|
|
295
|
-
const L = h();
|
|
296
|
-
m = _(L);
|
|
297
|
-
}
|
|
298
|
-
return m;
|
|
299
|
-
}
|
|
300
|
-
}, be;
|
|
301
|
-
}
|
|
302
|
-
var pe, nr;
|
|
303
|
-
function le() {
|
|
304
|
-
return nr || (nr = 1, pe = typeof process == "object" && process.env && process.env.NODE_DEBUG && /\bsemver\b/i.test(process.env.NODE_DEBUG) ? (...i) => console.error("SEMVER", ...i) : () => {
|
|
305
|
-
}), pe;
|
|
306
|
-
}
|
|
307
|
-
var we, ar;
|
|
308
|
-
function Ye() {
|
|
309
|
-
if (ar) return we;
|
|
310
|
-
ar = 1;
|
|
311
|
-
const e = "2.0.0", i = 256, P = Number.MAX_SAFE_INTEGER || /* istanbul ignore next */
|
|
312
|
-
9007199254740991, y = 16, b = i - 6;
|
|
313
|
-
return we = {
|
|
314
|
-
MAX_LENGTH: i,
|
|
315
|
-
MAX_SAFE_COMPONENT_LENGTH: y,
|
|
316
|
-
MAX_SAFE_BUILD_LENGTH: b,
|
|
317
|
-
MAX_SAFE_INTEGER: P,
|
|
318
|
-
RELEASE_TYPES: [
|
|
319
|
-
"major",
|
|
320
|
-
"premajor",
|
|
321
|
-
"minor",
|
|
322
|
-
"preminor",
|
|
323
|
-
"patch",
|
|
324
|
-
"prepatch",
|
|
325
|
-
"prerelease"
|
|
326
|
-
],
|
|
327
|
-
SEMVER_SPEC_VERSION: e,
|
|
328
|
-
FLAG_INCLUDE_PRERELEASE: 1,
|
|
329
|
-
FLAG_LOOSE: 2
|
|
330
|
-
}, we;
|
|
331
|
-
}
|
|
332
|
-
var oe = { exports: {} }, sr;
|
|
333
|
-
function ce() {
|
|
334
|
-
return sr || (sr = 1, (function(e, i) {
|
|
335
|
-
const {
|
|
336
|
-
MAX_SAFE_COMPONENT_LENGTH: P,
|
|
337
|
-
MAX_SAFE_BUILD_LENGTH: y,
|
|
338
|
-
MAX_LENGTH: b
|
|
339
|
-
} = Ye(), S = le();
|
|
340
|
-
i = e.exports = {};
|
|
341
|
-
const R = i.re = [], w = i.safeRe = [], d = i.src = [], g = i.safeSrc = [], c = i.t = {};
|
|
342
|
-
let p = 0;
|
|
343
|
-
const n = "[a-zA-Z0-9-]", k = [
|
|
344
|
-
["\\s", 1],
|
|
345
|
-
["\\d", b],
|
|
346
|
-
[n, y]
|
|
347
|
-
], h = (I) => {
|
|
348
|
-
for (const [$, z] of k)
|
|
349
|
-
I = I.split(`${$}*`).join(`${$}{0,${z}}`).split(`${$}+`).join(`${$}{1,${z}}`);
|
|
350
|
-
return I;
|
|
351
|
-
}, u = (I, $, z) => {
|
|
352
|
-
const O = h($), H = p++;
|
|
353
|
-
S(I, H, $), c[I] = H, d[H] = $, g[H] = O, R[H] = new RegExp($, z ? "g" : void 0), w[H] = new RegExp(O, z ? "g" : void 0);
|
|
354
|
-
};
|
|
355
|
-
u("NUMERICIDENTIFIER", "0|[1-9]\\d*"), u("NUMERICIDENTIFIERLOOSE", "\\d+"), u("NONNUMERICIDENTIFIER", `\\d*[a-zA-Z-]${n}*`), u("MAINVERSION", `(${d[c.NUMERICIDENTIFIER]})\\.(${d[c.NUMERICIDENTIFIER]})\\.(${d[c.NUMERICIDENTIFIER]})`), u("MAINVERSIONLOOSE", `(${d[c.NUMERICIDENTIFIERLOOSE]})\\.(${d[c.NUMERICIDENTIFIERLOOSE]})\\.(${d[c.NUMERICIDENTIFIERLOOSE]})`), u("PRERELEASEIDENTIFIER", `(?:${d[c.NONNUMERICIDENTIFIER]}|${d[c.NUMERICIDENTIFIER]})`), u("PRERELEASEIDENTIFIERLOOSE", `(?:${d[c.NONNUMERICIDENTIFIER]}|${d[c.NUMERICIDENTIFIERLOOSE]})`), u("PRERELEASE", `(?:-(${d[c.PRERELEASEIDENTIFIER]}(?:\\.${d[c.PRERELEASEIDENTIFIER]})*))`), u("PRERELEASELOOSE", `(?:-?(${d[c.PRERELEASEIDENTIFIERLOOSE]}(?:\\.${d[c.PRERELEASEIDENTIFIERLOOSE]})*))`), u("BUILDIDENTIFIER", `${n}+`), u("BUILD", `(?:\\+(${d[c.BUILDIDENTIFIER]}(?:\\.${d[c.BUILDIDENTIFIER]})*))`), u("FULLPLAIN", `v?${d[c.MAINVERSION]}${d[c.PRERELEASE]}?${d[c.BUILD]}?`), u("FULL", `^${d[c.FULLPLAIN]}$`), u("LOOSEPLAIN", `[v=\\s]*${d[c.MAINVERSIONLOOSE]}${d[c.PRERELEASELOOSE]}?${d[c.BUILD]}?`), u("LOOSE", `^${d[c.LOOSEPLAIN]}$`), u("GTLT", "((?:<|>)?=?)"), u("XRANGEIDENTIFIERLOOSE", `${d[c.NUMERICIDENTIFIERLOOSE]}|x|X|\\*`), u("XRANGEIDENTIFIER", `${d[c.NUMERICIDENTIFIER]}|x|X|\\*`), u("XRANGEPLAIN", `[v=\\s]*(${d[c.XRANGEIDENTIFIER]})(?:\\.(${d[c.XRANGEIDENTIFIER]})(?:\\.(${d[c.XRANGEIDENTIFIER]})(?:${d[c.PRERELEASE]})?${d[c.BUILD]}?)?)?`), u("XRANGEPLAINLOOSE", `[v=\\s]*(${d[c.XRANGEIDENTIFIERLOOSE]})(?:\\.(${d[c.XRANGEIDENTIFIERLOOSE]})(?:\\.(${d[c.XRANGEIDENTIFIERLOOSE]})(?:${d[c.PRERELEASELOOSE]})?${d[c.BUILD]}?)?)?`), u("XRANGE", `^${d[c.GTLT]}\\s*${d[c.XRANGEPLAIN]}$`), u("XRANGELOOSE", `^${d[c.GTLT]}\\s*${d[c.XRANGEPLAINLOOSE]}$`), u("COERCEPLAIN", `(^|[^\\d])(\\d{1,${P}})(?:\\.(\\d{1,${P}}))?(?:\\.(\\d{1,${P}}))?`), u("COERCE", `${d[c.COERCEPLAIN]}(?:$|[^\\d])`), u("COERCEFULL", d[c.COERCEPLAIN] + `(?:${d[c.PRERELEASE]})?(?:${d[c.BUILD]})?(?:$|[^\\d])`), u("COERCERTL", d[c.COERCE], !0), u("COERCERTLFULL", d[c.COERCEFULL], !0), u("LONETILDE", "(?:~>?)"), u("TILDETRIM", `(\\s*)${d[c.LONETILDE]}\\s+`, !0), i.tildeTrimReplace = "$1~", u("TILDE", `^${d[c.LONETILDE]}${d[c.XRANGEPLAIN]}$`), u("TILDELOOSE", `^${d[c.LONETILDE]}${d[c.XRANGEPLAINLOOSE]}$`), u("LONECARET", "(?:\\^)"), u("CARETTRIM", `(\\s*)${d[c.LONECARET]}\\s+`, !0), i.caretTrimReplace = "$1^", u("CARET", `^${d[c.LONECARET]}${d[c.XRANGEPLAIN]}$`), u("CARETLOOSE", `^${d[c.LONECARET]}${d[c.XRANGEPLAINLOOSE]}$`), u("COMPARATORLOOSE", `^${d[c.GTLT]}\\s*(${d[c.LOOSEPLAIN]})$|^$`), u("COMPARATOR", `^${d[c.GTLT]}\\s*(${d[c.FULLPLAIN]})$|^$`), u("COMPARATORTRIM", `(\\s*)${d[c.GTLT]}\\s*(${d[c.LOOSEPLAIN]}|${d[c.XRANGEPLAIN]})`, !0), i.comparatorTrimReplace = "$1$2$3", u("HYPHENRANGE", `^\\s*(${d[c.XRANGEPLAIN]})\\s+-\\s+(${d[c.XRANGEPLAIN]})\\s*$`), u("HYPHENRANGELOOSE", `^\\s*(${d[c.XRANGEPLAINLOOSE]})\\s+-\\s+(${d[c.XRANGEPLAINLOOSE]})\\s*$`), u("STAR", "(<|>)?=?\\s*\\*"), u("GTE0", "^\\s*>=\\s*0\\.0\\.0\\s*$"), u("GTE0PRE", "^\\s*>=\\s*0\\.0\\.0-0\\s*$");
|
|
356
|
-
})(oe, oe.exports)), oe.exports;
|
|
357
|
-
}
|
|
358
|
-
var ve, or;
|
|
359
|
-
function Ke() {
|
|
360
|
-
if (or) return ve;
|
|
361
|
-
or = 1;
|
|
362
|
-
const e = Object.freeze({ loose: !0 }), i = Object.freeze({});
|
|
363
|
-
return ve = (y) => y ? typeof y != "object" ? e : y : i, ve;
|
|
364
|
-
}
|
|
365
|
-
var Ee, lr;
|
|
366
|
-
function st() {
|
|
367
|
-
if (lr) return Ee;
|
|
368
|
-
lr = 1;
|
|
369
|
-
const e = /^[0-9]+$/, i = (y, b) => {
|
|
370
|
-
if (typeof y == "number" && typeof b == "number")
|
|
371
|
-
return y === b ? 0 : y < b ? -1 : 1;
|
|
372
|
-
const S = e.test(y), R = e.test(b);
|
|
373
|
-
return S && R && (y = +y, b = +b), y === b ? 0 : S && !R ? -1 : R && !S ? 1 : y < b ? -1 : 1;
|
|
374
|
-
};
|
|
375
|
-
return Ee = {
|
|
376
|
-
compareIdentifiers: i,
|
|
377
|
-
rcompareIdentifiers: (y, b) => i(b, y)
|
|
378
|
-
}, Ee;
|
|
379
|
-
}
|
|
380
|
-
var ye, cr;
|
|
381
|
-
function se() {
|
|
382
|
-
if (cr) return ye;
|
|
383
|
-
cr = 1;
|
|
384
|
-
const e = le(), { MAX_LENGTH: i, MAX_SAFE_INTEGER: P } = Ye(), { safeRe: y, t: b } = ce(), S = Ke(), { compareIdentifiers: R } = st();
|
|
385
|
-
class w {
|
|
386
|
-
constructor(g, c) {
|
|
387
|
-
if (c = S(c), g instanceof w) {
|
|
388
|
-
if (g.loose === !!c.loose && g.includePrerelease === !!c.includePrerelease)
|
|
389
|
-
return g;
|
|
390
|
-
g = g.version;
|
|
391
|
-
} else if (typeof g != "string")
|
|
392
|
-
throw new TypeError(`Invalid version. Must be a string. Got type "${typeof g}".`);
|
|
393
|
-
if (g.length > i)
|
|
394
|
-
throw new TypeError(
|
|
395
|
-
`version is longer than ${i} characters`
|
|
396
|
-
);
|
|
397
|
-
e("SemVer", g, c), this.options = c, this.loose = !!c.loose, this.includePrerelease = !!c.includePrerelease;
|
|
398
|
-
const p = g.trim().match(c.loose ? y[b.LOOSE] : y[b.FULL]);
|
|
399
|
-
if (!p)
|
|
400
|
-
throw new TypeError(`Invalid Version: ${g}`);
|
|
401
|
-
if (this.raw = g, this.major = +p[1], this.minor = +p[2], this.patch = +p[3], this.major > P || this.major < 0)
|
|
402
|
-
throw new TypeError("Invalid major version");
|
|
403
|
-
if (this.minor > P || this.minor < 0)
|
|
404
|
-
throw new TypeError("Invalid minor version");
|
|
405
|
-
if (this.patch > P || this.patch < 0)
|
|
406
|
-
throw new TypeError("Invalid patch version");
|
|
407
|
-
p[4] ? this.prerelease = p[4].split(".").map((n) => {
|
|
408
|
-
if (/^[0-9]+$/.test(n)) {
|
|
409
|
-
const k = +n;
|
|
410
|
-
if (k >= 0 && k < P)
|
|
411
|
-
return k;
|
|
412
|
-
}
|
|
413
|
-
return n;
|
|
414
|
-
}) : this.prerelease = [], this.build = p[5] ? p[5].split(".") : [], this.format();
|
|
415
|
-
}
|
|
416
|
-
format() {
|
|
417
|
-
return this.version = `${this.major}.${this.minor}.${this.patch}`, this.prerelease.length && (this.version += `-${this.prerelease.join(".")}`), this.version;
|
|
418
|
-
}
|
|
419
|
-
toString() {
|
|
420
|
-
return this.version;
|
|
421
|
-
}
|
|
422
|
-
compare(g) {
|
|
423
|
-
if (e("SemVer.compare", this.version, this.options, g), !(g instanceof w)) {
|
|
424
|
-
if (typeof g == "string" && g === this.version)
|
|
425
|
-
return 0;
|
|
426
|
-
g = new w(g, this.options);
|
|
427
|
-
}
|
|
428
|
-
return g.version === this.version ? 0 : this.compareMain(g) || this.comparePre(g);
|
|
429
|
-
}
|
|
430
|
-
compareMain(g) {
|
|
431
|
-
return g instanceof w || (g = new w(g, this.options)), this.major < g.major ? -1 : this.major > g.major ? 1 : this.minor < g.minor ? -1 : this.minor > g.minor ? 1 : this.patch < g.patch ? -1 : this.patch > g.patch ? 1 : 0;
|
|
432
|
-
}
|
|
433
|
-
comparePre(g) {
|
|
434
|
-
if (g instanceof w || (g = new w(g, this.options)), this.prerelease.length && !g.prerelease.length)
|
|
435
|
-
return -1;
|
|
436
|
-
if (!this.prerelease.length && g.prerelease.length)
|
|
437
|
-
return 1;
|
|
438
|
-
if (!this.prerelease.length && !g.prerelease.length)
|
|
439
|
-
return 0;
|
|
440
|
-
let c = 0;
|
|
441
|
-
do {
|
|
442
|
-
const p = this.prerelease[c], n = g.prerelease[c];
|
|
443
|
-
if (e("prerelease compare", c, p, n), p === void 0 && n === void 0)
|
|
444
|
-
return 0;
|
|
445
|
-
if (n === void 0)
|
|
446
|
-
return 1;
|
|
447
|
-
if (p === void 0)
|
|
448
|
-
return -1;
|
|
449
|
-
if (p === n)
|
|
450
|
-
continue;
|
|
451
|
-
return R(p, n);
|
|
452
|
-
} while (++c);
|
|
453
|
-
}
|
|
454
|
-
compareBuild(g) {
|
|
455
|
-
g instanceof w || (g = new w(g, this.options));
|
|
456
|
-
let c = 0;
|
|
457
|
-
do {
|
|
458
|
-
const p = this.build[c], n = g.build[c];
|
|
459
|
-
if (e("build compare", c, p, n), p === void 0 && n === void 0)
|
|
460
|
-
return 0;
|
|
461
|
-
if (n === void 0)
|
|
462
|
-
return 1;
|
|
463
|
-
if (p === void 0)
|
|
464
|
-
return -1;
|
|
465
|
-
if (p === n)
|
|
466
|
-
continue;
|
|
467
|
-
return R(p, n);
|
|
468
|
-
} while (++c);
|
|
469
|
-
}
|
|
470
|
-
// preminor will bump the version up to the next minor release, and immediately
|
|
471
|
-
// down to pre-release. premajor and prepatch work the same way.
|
|
472
|
-
inc(g, c, p) {
|
|
473
|
-
if (g.startsWith("pre")) {
|
|
474
|
-
if (!c && p === !1)
|
|
475
|
-
throw new Error("invalid increment argument: identifier is empty");
|
|
476
|
-
if (c) {
|
|
477
|
-
const n = `-${c}`.match(this.options.loose ? y[b.PRERELEASELOOSE] : y[b.PRERELEASE]);
|
|
478
|
-
if (!n || n[1] !== c)
|
|
479
|
-
throw new Error(`invalid identifier: ${c}`);
|
|
480
|
-
}
|
|
481
|
-
}
|
|
482
|
-
switch (g) {
|
|
483
|
-
case "premajor":
|
|
484
|
-
this.prerelease.length = 0, this.patch = 0, this.minor = 0, this.major++, this.inc("pre", c, p);
|
|
485
|
-
break;
|
|
486
|
-
case "preminor":
|
|
487
|
-
this.prerelease.length = 0, this.patch = 0, this.minor++, this.inc("pre", c, p);
|
|
488
|
-
break;
|
|
489
|
-
case "prepatch":
|
|
490
|
-
this.prerelease.length = 0, this.inc("patch", c, p), this.inc("pre", c, p);
|
|
491
|
-
break;
|
|
492
|
-
// If the input is a non-prerelease version, this acts the same as
|
|
493
|
-
// prepatch.
|
|
494
|
-
case "prerelease":
|
|
495
|
-
this.prerelease.length === 0 && this.inc("patch", c, p), this.inc("pre", c, p);
|
|
496
|
-
break;
|
|
497
|
-
case "release":
|
|
498
|
-
if (this.prerelease.length === 0)
|
|
499
|
-
throw new Error(`version ${this.raw} is not a prerelease`);
|
|
500
|
-
this.prerelease.length = 0;
|
|
501
|
-
break;
|
|
502
|
-
case "major":
|
|
503
|
-
(this.minor !== 0 || this.patch !== 0 || this.prerelease.length === 0) && this.major++, this.minor = 0, this.patch = 0, this.prerelease = [];
|
|
504
|
-
break;
|
|
505
|
-
case "minor":
|
|
506
|
-
(this.patch !== 0 || this.prerelease.length === 0) && this.minor++, this.patch = 0, this.prerelease = [];
|
|
507
|
-
break;
|
|
508
|
-
case "patch":
|
|
509
|
-
this.prerelease.length === 0 && this.patch++, this.prerelease = [];
|
|
510
|
-
break;
|
|
511
|
-
// This probably shouldn't be used publicly.
|
|
512
|
-
// 1.0.0 'pre' would become 1.0.0-0 which is the wrong direction.
|
|
513
|
-
case "pre": {
|
|
514
|
-
const n = Number(p) ? 1 : 0;
|
|
515
|
-
if (this.prerelease.length === 0)
|
|
516
|
-
this.prerelease = [n];
|
|
517
|
-
else {
|
|
518
|
-
let k = this.prerelease.length;
|
|
519
|
-
for (; --k >= 0; )
|
|
520
|
-
typeof this.prerelease[k] == "number" && (this.prerelease[k]++, k = -2);
|
|
521
|
-
if (k === -1) {
|
|
522
|
-
if (c === this.prerelease.join(".") && p === !1)
|
|
523
|
-
throw new Error("invalid increment argument: identifier already exists");
|
|
524
|
-
this.prerelease.push(n);
|
|
525
|
-
}
|
|
526
|
-
}
|
|
527
|
-
if (c) {
|
|
528
|
-
let k = [c, n];
|
|
529
|
-
p === !1 && (k = [c]), R(this.prerelease[0], c) === 0 ? isNaN(this.prerelease[1]) && (this.prerelease = k) : this.prerelease = k;
|
|
530
|
-
}
|
|
531
|
-
break;
|
|
532
|
-
}
|
|
533
|
-
default:
|
|
534
|
-
throw new Error(`invalid increment argument: ${g}`);
|
|
535
|
-
}
|
|
536
|
-
return this.raw = this.format(), this.build.length && (this.raw += `+${this.build.join(".")}`), this;
|
|
537
|
-
}
|
|
538
|
-
}
|
|
539
|
-
return ye = w, ye;
|
|
540
|
-
}
|
|
541
|
-
var Pe, fr;
|
|
542
|
-
function ot() {
|
|
543
|
-
if (fr) return Pe;
|
|
544
|
-
fr = 1;
|
|
545
|
-
const e = se();
|
|
546
|
-
return Pe = (P, y, b = !1) => {
|
|
547
|
-
if (P instanceof e)
|
|
548
|
-
return P;
|
|
549
|
-
try {
|
|
550
|
-
return new e(P, y);
|
|
551
|
-
} catch (S) {
|
|
552
|
-
if (!b)
|
|
553
|
-
return null;
|
|
554
|
-
throw S;
|
|
555
|
-
}
|
|
556
|
-
}, Pe;
|
|
557
|
-
}
|
|
558
|
-
var Re, hr;
|
|
559
|
-
function lt() {
|
|
560
|
-
if (hr) return Re;
|
|
561
|
-
hr = 1;
|
|
562
|
-
const e = se(), i = ot(), { safeRe: P, t: y } = ce();
|
|
563
|
-
return Re = (S, R) => {
|
|
564
|
-
if (S instanceof e)
|
|
565
|
-
return S;
|
|
566
|
-
if (typeof S == "number" && (S = String(S)), typeof S != "string")
|
|
567
|
-
return null;
|
|
568
|
-
R = R || {};
|
|
569
|
-
let w = null;
|
|
570
|
-
if (!R.rtl)
|
|
571
|
-
w = S.match(R.includePrerelease ? P[y.COERCEFULL] : P[y.COERCE]);
|
|
572
|
-
else {
|
|
573
|
-
const k = R.includePrerelease ? P[y.COERCERTLFULL] : P[y.COERCERTL];
|
|
574
|
-
let h;
|
|
575
|
-
for (; (h = k.exec(S)) && (!w || w.index + w[0].length !== S.length); )
|
|
576
|
-
(!w || h.index + h[0].length !== w.index + w[0].length) && (w = h), k.lastIndex = h.index + h[1].length + h[2].length;
|
|
577
|
-
k.lastIndex = -1;
|
|
578
|
-
}
|
|
579
|
-
if (w === null)
|
|
580
|
-
return null;
|
|
581
|
-
const d = w[2], g = w[3] || "0", c = w[4] || "0", p = R.includePrerelease && w[5] ? `-${w[5]}` : "", n = R.includePrerelease && w[6] ? `+${w[6]}` : "";
|
|
582
|
-
return i(`${d}.${g}.${c}${p}${n}`, R);
|
|
583
|
-
}, Re;
|
|
584
|
-
}
|
|
585
|
-
var xe, ur;
|
|
586
|
-
function ne() {
|
|
587
|
-
if (ur) return xe;
|
|
588
|
-
ur = 1;
|
|
589
|
-
const e = se();
|
|
590
|
-
return xe = (P, y, b) => new e(P, b).compare(new e(y, b)), xe;
|
|
591
|
-
}
|
|
592
|
-
var Ie, dr;
|
|
593
|
-
function Mr() {
|
|
594
|
-
if (dr) return Ie;
|
|
595
|
-
dr = 1;
|
|
596
|
-
const e = ne();
|
|
597
|
-
return Ie = (P, y, b) => e(P, y, b) >= 0, Ie;
|
|
598
|
-
}
|
|
599
|
-
var $e, mr;
|
|
600
|
-
function ct() {
|
|
601
|
-
if (mr) return $e;
|
|
602
|
-
mr = 1;
|
|
603
|
-
class e {
|
|
604
|
-
constructor() {
|
|
605
|
-
this.max = 1e3, this.map = /* @__PURE__ */ new Map();
|
|
606
|
-
}
|
|
607
|
-
get(P) {
|
|
608
|
-
const y = this.map.get(P);
|
|
609
|
-
if (y !== void 0)
|
|
610
|
-
return this.map.delete(P), this.map.set(P, y), y;
|
|
611
|
-
}
|
|
612
|
-
delete(P) {
|
|
613
|
-
return this.map.delete(P);
|
|
614
|
-
}
|
|
615
|
-
set(P, y) {
|
|
616
|
-
if (!this.delete(P) && y !== void 0) {
|
|
617
|
-
if (this.map.size >= this.max) {
|
|
618
|
-
const S = this.map.keys().next().value;
|
|
619
|
-
this.delete(S);
|
|
620
|
-
}
|
|
621
|
-
this.map.set(P, y);
|
|
622
|
-
}
|
|
623
|
-
return this;
|
|
624
|
-
}
|
|
625
|
-
}
|
|
626
|
-
return $e = e, $e;
|
|
627
|
-
}
|
|
628
|
-
var je, gr;
|
|
629
|
-
function ft() {
|
|
630
|
-
if (gr) return je;
|
|
631
|
-
gr = 1;
|
|
632
|
-
const e = ne();
|
|
633
|
-
return je = (P, y, b) => e(P, y, b) === 0, je;
|
|
634
|
-
}
|
|
635
|
-
var Ae, br;
|
|
636
|
-
function ht() {
|
|
637
|
-
if (br) return Ae;
|
|
638
|
-
br = 1;
|
|
639
|
-
const e = ne();
|
|
640
|
-
return Ae = (P, y, b) => e(P, y, b) !== 0, Ae;
|
|
641
|
-
}
|
|
642
|
-
var Le, pr;
|
|
643
|
-
function ut() {
|
|
644
|
-
if (pr) return Le;
|
|
645
|
-
pr = 1;
|
|
646
|
-
const e = ne();
|
|
647
|
-
return Le = (P, y, b) => e(P, y, b) > 0, Le;
|
|
648
|
-
}
|
|
649
|
-
var Se, wr;
|
|
650
|
-
function dt() {
|
|
651
|
-
if (wr) return Se;
|
|
652
|
-
wr = 1;
|
|
653
|
-
const e = ne();
|
|
654
|
-
return Se = (P, y, b) => e(P, y, b) < 0, Se;
|
|
655
|
-
}
|
|
656
|
-
var ke, vr;
|
|
657
|
-
function mt() {
|
|
658
|
-
if (vr) return ke;
|
|
659
|
-
vr = 1;
|
|
660
|
-
const e = ne();
|
|
661
|
-
return ke = (P, y, b) => e(P, y, b) <= 0, ke;
|
|
662
|
-
}
|
|
663
|
-
var Ne, Er;
|
|
664
|
-
function gt() {
|
|
665
|
-
if (Er) return Ne;
|
|
666
|
-
Er = 1;
|
|
667
|
-
const e = ft(), i = ht(), P = ut(), y = Mr(), b = dt(), S = mt();
|
|
668
|
-
return Ne = (w, d, g, c) => {
|
|
669
|
-
switch (d) {
|
|
670
|
-
case "===":
|
|
671
|
-
return typeof w == "object" && (w = w.version), typeof g == "object" && (g = g.version), w === g;
|
|
672
|
-
case "!==":
|
|
673
|
-
return typeof w == "object" && (w = w.version), typeof g == "object" && (g = g.version), w !== g;
|
|
674
|
-
case "":
|
|
675
|
-
case "=":
|
|
676
|
-
case "==":
|
|
677
|
-
return e(w, g, c);
|
|
678
|
-
case "!=":
|
|
679
|
-
return i(w, g, c);
|
|
680
|
-
case ">":
|
|
681
|
-
return P(w, g, c);
|
|
682
|
-
case ">=":
|
|
683
|
-
return y(w, g, c);
|
|
684
|
-
case "<":
|
|
685
|
-
return b(w, g, c);
|
|
686
|
-
case "<=":
|
|
687
|
-
return S(w, g, c);
|
|
688
|
-
default:
|
|
689
|
-
throw new TypeError(`Invalid operator: ${d}`);
|
|
690
|
-
}
|
|
691
|
-
}, Ne;
|
|
692
|
-
}
|
|
693
|
-
var Ce, yr;
|
|
694
|
-
function bt() {
|
|
695
|
-
if (yr) return Ce;
|
|
696
|
-
yr = 1;
|
|
697
|
-
const e = /* @__PURE__ */ Symbol("SemVer ANY");
|
|
698
|
-
class i {
|
|
699
|
-
static get ANY() {
|
|
700
|
-
return e;
|
|
701
|
-
}
|
|
702
|
-
constructor(c, p) {
|
|
703
|
-
if (p = P(p), c instanceof i) {
|
|
704
|
-
if (c.loose === !!p.loose)
|
|
705
|
-
return c;
|
|
706
|
-
c = c.value;
|
|
707
|
-
}
|
|
708
|
-
c = c.trim().split(/\s+/).join(" "), R("comparator", c, p), this.options = p, this.loose = !!p.loose, this.parse(c), this.semver === e ? this.value = "" : this.value = this.operator + this.semver.version, R("comp", this);
|
|
709
|
-
}
|
|
710
|
-
parse(c) {
|
|
711
|
-
const p = this.options.loose ? y[b.COMPARATORLOOSE] : y[b.COMPARATOR], n = c.match(p);
|
|
712
|
-
if (!n)
|
|
713
|
-
throw new TypeError(`Invalid comparator: ${c}`);
|
|
714
|
-
this.operator = n[1] !== void 0 ? n[1] : "", this.operator === "=" && (this.operator = ""), n[2] ? this.semver = new w(n[2], this.options.loose) : this.semver = e;
|
|
715
|
-
}
|
|
716
|
-
toString() {
|
|
717
|
-
return this.value;
|
|
718
|
-
}
|
|
719
|
-
test(c) {
|
|
720
|
-
if (R("Comparator.test", c, this.options.loose), this.semver === e || c === e)
|
|
721
|
-
return !0;
|
|
722
|
-
if (typeof c == "string")
|
|
723
|
-
try {
|
|
724
|
-
c = new w(c, this.options);
|
|
725
|
-
} catch {
|
|
726
|
-
return !1;
|
|
727
|
-
}
|
|
728
|
-
return S(c, this.operator, this.semver, this.options);
|
|
729
|
-
}
|
|
730
|
-
intersects(c, p) {
|
|
731
|
-
if (!(c instanceof i))
|
|
732
|
-
throw new TypeError("a Comparator is required");
|
|
733
|
-
return this.operator === "" ? this.value === "" ? !0 : new d(c.value, p).test(this.value) : c.operator === "" ? c.value === "" ? !0 : new d(this.value, p).test(c.semver) : (p = P(p), p.includePrerelease && (this.value === "<0.0.0-0" || c.value === "<0.0.0-0") || !p.includePrerelease && (this.value.startsWith("<0.0.0") || c.value.startsWith("<0.0.0")) ? !1 : !!(this.operator.startsWith(">") && c.operator.startsWith(">") || this.operator.startsWith("<") && c.operator.startsWith("<") || this.semver.version === c.semver.version && this.operator.includes("=") && c.operator.includes("=") || S(this.semver, "<", c.semver, p) && this.operator.startsWith(">") && c.operator.startsWith("<") || S(this.semver, ">", c.semver, p) && this.operator.startsWith("<") && c.operator.startsWith(">")));
|
|
734
|
-
}
|
|
735
|
-
}
|
|
736
|
-
Ce = i;
|
|
737
|
-
const P = Ke(), { safeRe: y, t: b } = ce(), S = gt(), R = le(), w = se(), d = Dr();
|
|
738
|
-
return Ce;
|
|
739
|
-
}
|
|
740
|
-
var _e, Pr;
|
|
741
|
-
function Dr() {
|
|
742
|
-
if (Pr) return _e;
|
|
743
|
-
Pr = 1;
|
|
744
|
-
const e = /\s+/g;
|
|
745
|
-
class i {
|
|
746
|
-
constructor(j, F) {
|
|
747
|
-
if (F = b(F), j instanceof i)
|
|
748
|
-
return j.loose === !!F.loose && j.includePrerelease === !!F.includePrerelease ? j : new i(j.raw, F);
|
|
749
|
-
if (j instanceof S)
|
|
750
|
-
return this.raw = j.value, this.set = [[j]], this.formatted = void 0, this;
|
|
751
|
-
if (this.options = F, this.loose = !!F.loose, this.includePrerelease = !!F.includePrerelease, this.raw = j.trim().replace(e, " "), this.set = this.raw.split("||").map((T) => this.parseRange(T.trim())).filter((T) => T.length), !this.set.length)
|
|
752
|
-
throw new TypeError(`Invalid SemVer Range: ${this.raw}`);
|
|
753
|
-
if (this.set.length > 1) {
|
|
754
|
-
const T = this.set[0];
|
|
755
|
-
if (this.set = this.set.filter((B) => !u(B[0])), this.set.length === 0)
|
|
756
|
-
this.set = [T];
|
|
757
|
-
else if (this.set.length > 1) {
|
|
758
|
-
for (const B of this.set)
|
|
759
|
-
if (B.length === 1 && I(B[0])) {
|
|
760
|
-
this.set = [B];
|
|
761
|
-
break;
|
|
762
|
-
}
|
|
763
|
-
}
|
|
764
|
-
}
|
|
765
|
-
this.formatted = void 0;
|
|
766
|
-
}
|
|
767
|
-
get range() {
|
|
768
|
-
if (this.formatted === void 0) {
|
|
769
|
-
this.formatted = "";
|
|
770
|
-
for (let j = 0; j < this.set.length; j++) {
|
|
771
|
-
j > 0 && (this.formatted += "||");
|
|
772
|
-
const F = this.set[j];
|
|
773
|
-
for (let T = 0; T < F.length; T++)
|
|
774
|
-
T > 0 && (this.formatted += " "), this.formatted += F[T].toString().trim();
|
|
775
|
-
}
|
|
776
|
-
}
|
|
777
|
-
return this.formatted;
|
|
778
|
-
}
|
|
779
|
-
format() {
|
|
780
|
-
return this.range;
|
|
781
|
-
}
|
|
782
|
-
toString() {
|
|
783
|
-
return this.range;
|
|
784
|
-
}
|
|
785
|
-
parseRange(j) {
|
|
786
|
-
const T = ((this.options.includePrerelease && k) | (this.options.loose && h)) + ":" + j, B = y.get(T);
|
|
787
|
-
if (B)
|
|
788
|
-
return B;
|
|
789
|
-
const _ = this.options.loose, r = _ ? d[g.HYPHENRANGELOOSE] : d[g.HYPHENRANGE];
|
|
790
|
-
j = j.replace(r, K(this.options.includePrerelease)), R("hyphen replace", j), j = j.replace(d[g.COMPARATORTRIM], c), R("comparator trim", j), j = j.replace(d[g.TILDETRIM], p), R("tilde trim", j), j = j.replace(d[g.CARETTRIM], n), R("caret trim", j);
|
|
791
|
-
let C = j.split(" ").map((U) => z(U, this.options)).join(" ").split(/\s+/).map((U) => G(U, this.options));
|
|
792
|
-
_ && (C = C.filter((U) => (R("loose invalid filter", U, this.options), !!U.match(d[g.COMPARATORLOOSE])))), R("range list", C);
|
|
793
|
-
const m = /* @__PURE__ */ new Map(), L = C.map((U) => new S(U, this.options));
|
|
794
|
-
for (const U of L) {
|
|
795
|
-
if (u(U))
|
|
796
|
-
return [U];
|
|
797
|
-
m.set(U.value, U);
|
|
798
|
-
}
|
|
799
|
-
m.size > 1 && m.has("") && m.delete("");
|
|
800
|
-
const M = [...m.values()];
|
|
801
|
-
return y.set(T, M), M;
|
|
802
|
-
}
|
|
803
|
-
intersects(j, F) {
|
|
804
|
-
if (!(j instanceof i))
|
|
805
|
-
throw new TypeError("a Range is required");
|
|
806
|
-
return this.set.some((T) => $(T, F) && j.set.some((B) => $(B, F) && T.every((_) => B.every((r) => _.intersects(r, F)))));
|
|
807
|
-
}
|
|
808
|
-
// if ANY of the sets match ALL of its comparators, then pass
|
|
809
|
-
test(j) {
|
|
810
|
-
if (!j)
|
|
811
|
-
return !1;
|
|
812
|
-
if (typeof j == "string")
|
|
813
|
-
try {
|
|
814
|
-
j = new w(j, this.options);
|
|
815
|
-
} catch {
|
|
816
|
-
return !1;
|
|
817
|
-
}
|
|
818
|
-
for (let F = 0; F < this.set.length; F++)
|
|
819
|
-
if (re(this.set[F], j, this.options))
|
|
820
|
-
return !0;
|
|
821
|
-
return !1;
|
|
822
|
-
}
|
|
823
|
-
}
|
|
824
|
-
_e = i;
|
|
825
|
-
const P = ct(), y = new P(), b = Ke(), S = bt(), R = le(), w = se(), {
|
|
826
|
-
safeRe: d,
|
|
827
|
-
t: g,
|
|
828
|
-
comparatorTrimReplace: c,
|
|
829
|
-
tildeTrimReplace: p,
|
|
830
|
-
caretTrimReplace: n
|
|
831
|
-
} = ce(), { FLAG_INCLUDE_PRERELEASE: k, FLAG_LOOSE: h } = Ye(), u = (A) => A.value === "<0.0.0-0", I = (A) => A.value === "", $ = (A, j) => {
|
|
832
|
-
let F = !0;
|
|
833
|
-
const T = A.slice();
|
|
834
|
-
let B = T.pop();
|
|
835
|
-
for (; F && T.length; )
|
|
836
|
-
F = T.every((_) => B.intersects(_, j)), B = T.pop();
|
|
837
|
-
return F;
|
|
838
|
-
}, z = (A, j) => (A = A.replace(d[g.BUILD], ""), R("comp", A, j), A = Q(A, j), R("caret", A), A = H(A, j), R("tildes", A), A = V(A, j), R("xrange", A), A = N(A, j), R("stars", A), A), O = (A) => !A || A.toLowerCase() === "x" || A === "*", H = (A, j) => A.trim().split(/\s+/).map((F) => W(F, j)).join(" "), W = (A, j) => {
|
|
839
|
-
const F = j.loose ? d[g.TILDELOOSE] : d[g.TILDE];
|
|
840
|
-
return A.replace(F, (T, B, _, r, C) => {
|
|
841
|
-
R("tilde", A, T, B, _, r, C);
|
|
842
|
-
let m;
|
|
843
|
-
return O(B) ? m = "" : O(_) ? m = `>=${B}.0.0 <${+B + 1}.0.0-0` : O(r) ? m = `>=${B}.${_}.0 <${B}.${+_ + 1}.0-0` : C ? (R("replaceTilde pr", C), m = `>=${B}.${_}.${r}-${C} <${B}.${+_ + 1}.0-0`) : m = `>=${B}.${_}.${r} <${B}.${+_ + 1}.0-0`, R("tilde return", m), m;
|
|
844
|
-
});
|
|
845
|
-
}, Q = (A, j) => A.trim().split(/\s+/).map((F) => Y(F, j)).join(" "), Y = (A, j) => {
|
|
846
|
-
R("caret", A, j);
|
|
847
|
-
const F = j.loose ? d[g.CARETLOOSE] : d[g.CARET], T = j.includePrerelease ? "-0" : "";
|
|
848
|
-
return A.replace(F, (B, _, r, C, m) => {
|
|
849
|
-
R("caret", A, B, _, r, C, m);
|
|
850
|
-
let L;
|
|
851
|
-
return O(_) ? L = "" : O(r) ? L = `>=${_}.0.0${T} <${+_ + 1}.0.0-0` : O(C) ? _ === "0" ? L = `>=${_}.${r}.0${T} <${_}.${+r + 1}.0-0` : L = `>=${_}.${r}.0${T} <${+_ + 1}.0.0-0` : m ? (R("replaceCaret pr", m), _ === "0" ? r === "0" ? L = `>=${_}.${r}.${C}-${m} <${_}.${r}.${+C + 1}-0` : L = `>=${_}.${r}.${C}-${m} <${_}.${+r + 1}.0-0` : L = `>=${_}.${r}.${C}-${m} <${+_ + 1}.0.0-0`) : (R("no pr"), _ === "0" ? r === "0" ? L = `>=${_}.${r}.${C}${T} <${_}.${r}.${+C + 1}-0` : L = `>=${_}.${r}.${C}${T} <${_}.${+r + 1}.0-0` : L = `>=${_}.${r}.${C} <${+_ + 1}.0.0-0`), R("caret return", L), L;
|
|
852
|
-
});
|
|
853
|
-
}, V = (A, j) => (R("replaceXRanges", A, j), A.split(/\s+/).map((F) => f(F, j)).join(" ")), f = (A, j) => {
|
|
854
|
-
A = A.trim();
|
|
855
|
-
const F = j.loose ? d[g.XRANGELOOSE] : d[g.XRANGE];
|
|
856
|
-
return A.replace(F, (T, B, _, r, C, m) => {
|
|
857
|
-
R("xRange", A, T, B, _, r, C, m);
|
|
858
|
-
const L = O(_), M = L || O(r), U = M || O(C), J = U;
|
|
859
|
-
return B === "=" && J && (B = ""), m = j.includePrerelease ? "-0" : "", L ? B === ">" || B === "<" ? T = "<0.0.0-0" : T = "*" : B && J ? (M && (r = 0), C = 0, B === ">" ? (B = ">=", M ? (_ = +_ + 1, r = 0, C = 0) : (r = +r + 1, C = 0)) : B === "<=" && (B = "<", M ? _ = +_ + 1 : r = +r + 1), B === "<" && (m = "-0"), T = `${B + _}.${r}.${C}${m}`) : M ? T = `>=${_}.0.0${m} <${+_ + 1}.0.0-0` : U && (T = `>=${_}.${r}.0${m} <${_}.${+r + 1}.0-0`), R("xRange return", T), T;
|
|
860
|
-
});
|
|
861
|
-
}, N = (A, j) => (R("replaceStars", A, j), A.trim().replace(d[g.STAR], "")), G = (A, j) => (R("replaceGTE0", A, j), A.trim().replace(d[j.includePrerelease ? g.GTE0PRE : g.GTE0], "")), K = (A) => (j, F, T, B, _, r, C, m, L, M, U, J) => (O(T) ? F = "" : O(B) ? F = `>=${T}.0.0${A ? "-0" : ""}` : O(_) ? F = `>=${T}.${B}.0${A ? "-0" : ""}` : r ? F = `>=${F}` : F = `>=${F}${A ? "-0" : ""}`, O(L) ? m = "" : O(M) ? m = `<${+L + 1}.0.0-0` : O(U) ? m = `<${L}.${+M + 1}.0-0` : J ? m = `<=${L}.${M}.${U}-${J}` : A ? m = `<${L}.${M}.${+U + 1}-0` : m = `<=${m}`, `${F} ${m}`.trim()), re = (A, j, F) => {
|
|
862
|
-
for (let T = 0; T < A.length; T++)
|
|
863
|
-
if (!A[T].test(j))
|
|
864
|
-
return !1;
|
|
865
|
-
if (j.prerelease.length && !F.includePrerelease) {
|
|
866
|
-
for (let T = 0; T < A.length; T++)
|
|
867
|
-
if (R(A[T].semver), A[T].semver !== S.ANY && A[T].semver.prerelease.length > 0) {
|
|
868
|
-
const B = A[T].semver;
|
|
869
|
-
if (B.major === j.major && B.minor === j.minor && B.patch === j.patch)
|
|
870
|
-
return !0;
|
|
871
|
-
}
|
|
872
|
-
return !1;
|
|
873
|
-
}
|
|
874
|
-
return !0;
|
|
875
|
-
};
|
|
876
|
-
return _e;
|
|
877
|
-
}
|
|
878
|
-
var qe, Rr;
|
|
879
|
-
function pt() {
|
|
880
|
-
if (Rr) return qe;
|
|
881
|
-
Rr = 1;
|
|
882
|
-
const e = Dr();
|
|
883
|
-
return qe = (P, y, b) => {
|
|
884
|
-
try {
|
|
885
|
-
y = new e(y, b);
|
|
886
|
-
} catch {
|
|
887
|
-
return !1;
|
|
888
|
-
}
|
|
889
|
-
return y.test(P);
|
|
890
|
-
}, qe;
|
|
891
|
-
}
|
|
892
|
-
const wt = "0.34.5", vt = { "@img/sharp-darwin-arm64": "0.34.5", "@img/sharp-darwin-x64": "0.34.5", "@img/sharp-libvips-darwin-arm64": "1.2.4", "@img/sharp-libvips-darwin-x64": "1.2.4", "@img/sharp-libvips-linux-arm": "1.2.4", "@img/sharp-libvips-linux-arm64": "1.2.4", "@img/sharp-libvips-linux-ppc64": "1.2.4", "@img/sharp-libvips-linux-riscv64": "1.2.4", "@img/sharp-libvips-linux-s390x": "1.2.4", "@img/sharp-libvips-linux-x64": "1.2.4", "@img/sharp-libvips-linuxmusl-arm64": "1.2.4", "@img/sharp-libvips-linuxmusl-x64": "1.2.4", "@img/sharp-linux-arm": "0.34.5", "@img/sharp-linux-arm64": "0.34.5", "@img/sharp-linux-ppc64": "0.34.5", "@img/sharp-linux-riscv64": "0.34.5", "@img/sharp-linux-s390x": "0.34.5", "@img/sharp-linux-x64": "0.34.5", "@img/sharp-linuxmusl-arm64": "0.34.5", "@img/sharp-linuxmusl-x64": "0.34.5", "@img/sharp-wasm32": "0.34.5", "@img/sharp-win32-arm64": "0.34.5", "@img/sharp-win32-ia32": "0.34.5", "@img/sharp-win32-x64": "0.34.5" }, Et = { node: "^18.17.0 || ^20.3.0 || >=21.0.0" }, yt = { libvips: ">=8.17.3" }, Or = {
|
|
893
|
-
version: wt,
|
|
894
|
-
optionalDependencies: vt,
|
|
895
|
-
engines: Et,
|
|
896
|
-
config: yt
|
|
897
|
-
};
|
|
898
|
-
var Te, xr;
|
|
899
|
-
function Ur() {
|
|
900
|
-
if (xr) return Te;
|
|
901
|
-
xr = 1;
|
|
902
|
-
const { spawnSync: e } = Kr, { createHash: i } = Hr, P = lt(), y = Mr(), b = pt(), S = Qe(), { config: R, engines: w, optionalDependencies: d } = Or, g = process.env.npm_package_config_libvips || R.libvips, c = P(g).version, p = [
|
|
903
|
-
"darwin-arm64",
|
|
904
|
-
"darwin-x64",
|
|
905
|
-
"linux-arm",
|
|
906
|
-
"linux-arm64",
|
|
907
|
-
"linux-ppc64",
|
|
908
|
-
"linux-riscv64",
|
|
909
|
-
"linux-s390x",
|
|
910
|
-
"linux-x64",
|
|
911
|
-
"linuxmusl-arm64",
|
|
912
|
-
"linuxmusl-x64",
|
|
913
|
-
"win32-arm64",
|
|
914
|
-
"win32-ia32",
|
|
915
|
-
"win32-x64"
|
|
916
|
-
], n = {
|
|
917
|
-
encoding: "utf8",
|
|
918
|
-
shell: !0
|
|
919
|
-
}, k = (A) => {
|
|
920
|
-
A instanceof Error ? console.error(`sharp: Installation error: ${A.message}`) : console.log(`sharp: ${A}`);
|
|
921
|
-
}, h = () => S.isNonGlibcLinuxSync() ? S.familySync() : "", u = () => `${process.platform}${h()}-${process.arch}`, I = () => {
|
|
922
|
-
if (W())
|
|
923
|
-
return "wasm32";
|
|
924
|
-
const { npm_config_arch: A, npm_config_platform: j, npm_config_libc: F } = process.env, T = typeof F == "string" ? F : h();
|
|
925
|
-
return `${j || process.platform}${T}-${A || process.arch}`;
|
|
926
|
-
}, $ = () => {
|
|
927
|
-
try {
|
|
928
|
-
return ie(`@img/sharp-libvips-dev-${I()}/include`);
|
|
929
|
-
} catch {
|
|
930
|
-
try {
|
|
931
|
-
return require("@img/sharp-libvips-dev/include");
|
|
932
|
-
} catch {
|
|
933
|
-
}
|
|
934
|
-
}
|
|
935
|
-
return "";
|
|
936
|
-
}, z = () => {
|
|
937
|
-
try {
|
|
938
|
-
return require("@img/sharp-libvips-dev/cplusplus");
|
|
939
|
-
} catch {
|
|
940
|
-
}
|
|
941
|
-
return "";
|
|
942
|
-
}, O = () => {
|
|
943
|
-
try {
|
|
944
|
-
return ie(`@img/sharp-libvips-dev-${I()}/lib`);
|
|
945
|
-
} catch {
|
|
946
|
-
try {
|
|
947
|
-
return ie(`@img/sharp-libvips-${I()}/lib`);
|
|
948
|
-
} catch {
|
|
949
|
-
}
|
|
950
|
-
}
|
|
951
|
-
return "";
|
|
952
|
-
}, H = () => {
|
|
953
|
-
if (process.release?.name === "node" && process.versions && !b(process.versions.node, w.node))
|
|
954
|
-
return { found: process.versions.node, expected: w.node };
|
|
955
|
-
}, W = () => {
|
|
956
|
-
const { CC: A } = process.env;
|
|
957
|
-
return !!A?.endsWith("/emcc");
|
|
958
|
-
}, Q = () => process.platform === "darwin" && process.arch === "x64" ? (e("sysctl sysctl.proc_translated", n).stdout || "").trim() === "sysctl.proc_translated: 1" : !1, Y = (A) => i("sha512").update(A).digest("hex"), V = () => {
|
|
959
|
-
try {
|
|
960
|
-
const A = Y(`imgsharp-libvips-${I()}`), j = P(d[`@img/sharp-libvips-${I()}`], {
|
|
961
|
-
includePrerelease: !0
|
|
962
|
-
}).version;
|
|
963
|
-
return Y(`${A}npm:${j}`).slice(0, 10);
|
|
964
|
-
} catch {
|
|
965
|
-
}
|
|
966
|
-
return "";
|
|
967
|
-
}, f = () => e(`node-gyp rebuild --directory=src ${W() ? "--nodedir=emscripten" : ""}`, {
|
|
968
|
-
...n,
|
|
969
|
-
stdio: "inherit"
|
|
970
|
-
}).status, N = () => process.platform !== "win32" ? (e("pkg-config --modversion vips-cpp", {
|
|
971
|
-
...n,
|
|
972
|
-
env: {
|
|
973
|
-
...process.env,
|
|
974
|
-
PKG_CONFIG_PATH: G()
|
|
975
|
-
}
|
|
976
|
-
}).stdout || "").trim() : "", G = () => process.platform !== "win32" ? [
|
|
977
|
-
(e(
|
|
978
|
-
'which brew >/dev/null 2>&1 && brew environment --plain | grep PKG_CONFIG_LIBDIR | cut -d" " -f2',
|
|
979
|
-
n
|
|
980
|
-
).stdout || "").trim(),
|
|
981
|
-
process.env.PKG_CONFIG_PATH,
|
|
982
|
-
"/usr/local/lib/pkgconfig",
|
|
983
|
-
"/usr/lib/pkgconfig",
|
|
984
|
-
"/usr/local/libdata/pkgconfig",
|
|
985
|
-
"/usr/libdata/pkgconfig"
|
|
986
|
-
].filter(Boolean).join(":") : "", K = (A, j, F) => (F && F(`Detected ${j}, skipping search for globally-installed libvips`), A);
|
|
987
|
-
return Te = {
|
|
988
|
-
minimumLibvipsVersion: c,
|
|
989
|
-
prebuiltPlatforms: p,
|
|
990
|
-
buildPlatformArch: I,
|
|
991
|
-
buildSharpLibvipsIncludeDir: $,
|
|
992
|
-
buildSharpLibvipsCPlusPlusDir: z,
|
|
993
|
-
buildSharpLibvipsLibDir: O,
|
|
994
|
-
isUnsupportedNodeRuntime: H,
|
|
995
|
-
runtimePlatformArch: u,
|
|
996
|
-
log: k,
|
|
997
|
-
yarnLocator: V,
|
|
998
|
-
spawnRebuild: f,
|
|
999
|
-
globalLibvipsVersion: N,
|
|
1000
|
-
pkgConfigPath: G,
|
|
1001
|
-
useGlobalLibvips: (A) => {
|
|
1002
|
-
if (process.env.SHARP_IGNORE_GLOBAL_LIBVIPS)
|
|
1003
|
-
return K(!1, "SHARP_IGNORE_GLOBAL_LIBVIPS", A);
|
|
1004
|
-
if (process.env.SHARP_FORCE_GLOBAL_LIBVIPS)
|
|
1005
|
-
return K(!0, "SHARP_FORCE_GLOBAL_LIBVIPS", A);
|
|
1006
|
-
if (Q())
|
|
1007
|
-
return K(!1, "Rosetta", A);
|
|
1008
|
-
const j = N();
|
|
1009
|
-
return !!j && y(j, c);
|
|
1010
|
-
}
|
|
1011
|
-
}, Te;
|
|
1012
|
-
}
|
|
1013
|
-
var Ir;
|
|
1014
|
-
function fe() {
|
|
1015
|
-
if (Ir) return ue.exports;
|
|
1016
|
-
Ir = 1;
|
|
1017
|
-
const { familySync: e, versionSync: i } = Qe(), { runtimePlatformArch: P, isUnsupportedNodeRuntime: y, prebuiltPlatforms: b, minimumLibvipsVersion: S } = Ur(), R = P(), w = [
|
|
1018
|
-
`../src/build/Release/sharp-${R}.node`,
|
|
1019
|
-
"../src/build/Release/sharp-wasm32.node",
|
|
1020
|
-
`@img/sharp-${R}/sharp.node`,
|
|
1021
|
-
"@img/sharp-wasm32/sharp.node"
|
|
1022
|
-
];
|
|
1023
|
-
let d, g;
|
|
1024
|
-
const c = [];
|
|
1025
|
-
for (d of w)
|
|
1026
|
-
try {
|
|
1027
|
-
g = ie(d);
|
|
1028
|
-
break;
|
|
1029
|
-
} catch (p) {
|
|
1030
|
-
c.push(p);
|
|
1031
|
-
}
|
|
1032
|
-
if (g && d.startsWith("@img/sharp-linux-x64") && !g._isUsingX64V2()) {
|
|
1033
|
-
const p = new Error("Prebuilt binaries for linux-x64 require v2 microarchitecture");
|
|
1034
|
-
p.code = "Unsupported CPU", c.push(p), g = null;
|
|
1035
|
-
}
|
|
1036
|
-
if (g)
|
|
1037
|
-
ue.exports = g;
|
|
1038
|
-
else {
|
|
1039
|
-
const [p, n, k] = ["linux", "darwin", "win32"].map((I) => R.startsWith(I)), h = [`Could not load the "sharp" module using the ${R} runtime`];
|
|
1040
|
-
c.forEach((I) => {
|
|
1041
|
-
I.code !== "MODULE_NOT_FOUND" && h.push(`${I.code}: ${I.message}`);
|
|
1042
|
-
});
|
|
1043
|
-
const u = c.map((I) => I.message).join(" ");
|
|
1044
|
-
if (h.push("Possible solutions:"), y()) {
|
|
1045
|
-
const { found: I, expected: $ } = y();
|
|
1046
|
-
h.push(
|
|
1047
|
-
"- Please upgrade Node.js:",
|
|
1048
|
-
` Found ${I}`,
|
|
1049
|
-
` Requires ${$}`
|
|
1050
|
-
);
|
|
1051
|
-
} else if (b.includes(R)) {
|
|
1052
|
-
const [I, $] = R.split("-"), z = I.endsWith("musl") ? " --libc=musl" : "";
|
|
1053
|
-
h.push(
|
|
1054
|
-
"- Ensure optional dependencies can be installed:",
|
|
1055
|
-
" npm install --include=optional sharp",
|
|
1056
|
-
"- Ensure your package manager supports multi-platform installation:",
|
|
1057
|
-
" See https://sharp.pixelplumbing.com/install#cross-platform",
|
|
1058
|
-
"- Add platform-specific dependencies:",
|
|
1059
|
-
` npm install --os=${I.replace("musl", "")}${z} --cpu=${$} sharp`
|
|
1060
|
-
);
|
|
1061
|
-
} else
|
|
1062
|
-
h.push(
|
|
1063
|
-
`- Manually install libvips >= ${S}`,
|
|
1064
|
-
"- Add experimental WebAssembly-based dependencies:",
|
|
1065
|
-
" npm install --cpu=wasm32 sharp",
|
|
1066
|
-
" npm install @img/sharp-wasm32"
|
|
1067
|
-
);
|
|
1068
|
-
if (p && /(symbol not found|CXXABI_)/i.test(u))
|
|
1069
|
-
try {
|
|
1070
|
-
const { config: I } = ie(`@img/sharp-libvips-${R}/package`), $ = `${e()} ${i()}`, z = `${I.musl ? "musl" : "glibc"} ${I.musl || I.glibc}`;
|
|
1071
|
-
h.push(
|
|
1072
|
-
"- Update your OS:",
|
|
1073
|
-
` Found ${$}`,
|
|
1074
|
-
` Requires ${z}`
|
|
1075
|
-
);
|
|
1076
|
-
} catch {
|
|
1077
|
-
}
|
|
1078
|
-
throw p && /\/snap\/core[0-9]{2}/.test(u) && h.push(
|
|
1079
|
-
"- Remove the Node.js Snap, which does not support native modules",
|
|
1080
|
-
" snap remove node"
|
|
1081
|
-
), n && /Incompatible library version/.test(u) && h.push(
|
|
1082
|
-
"- Update Homebrew:",
|
|
1083
|
-
" brew update && brew upgrade vips"
|
|
1084
|
-
), c.some((I) => I.code === "ERR_DLOPEN_DISABLED") && h.push("- Run Node.js without using the --no-addons flag"), k && /The specified procedure could not be found/.test(u) && h.push(
|
|
1085
|
-
"- Using the canvas package on Windows?",
|
|
1086
|
-
" See https://sharp.pixelplumbing.com/install#canvas-and-windows",
|
|
1087
|
-
"- Check for outdated versions of sharp in the dependency tree:",
|
|
1088
|
-
" npm ls sharp"
|
|
1089
|
-
), h.push(
|
|
1090
|
-
"- Consult the installation documentation:",
|
|
1091
|
-
" See https://sharp.pixelplumbing.com/install"
|
|
1092
|
-
), new Error(h.join(`
|
|
1093
|
-
`));
|
|
1094
|
-
}
|
|
1095
|
-
return ue.exports;
|
|
1096
|
-
}
|
|
1097
|
-
var Fe, $r;
|
|
1098
|
-
function Pt() {
|
|
1099
|
-
if ($r) return Fe;
|
|
1100
|
-
$r = 1;
|
|
1101
|
-
const e = Xr, i = Vr, P = ee();
|
|
1102
|
-
fe();
|
|
1103
|
-
const y = e.debuglog("sharp"), b = (w) => {
|
|
1104
|
-
S.queue.emit("change", w);
|
|
1105
|
-
}, S = function(w, d) {
|
|
1106
|
-
if (arguments.length === 1 && !P.defined(w))
|
|
1107
|
-
throw new Error("Invalid input");
|
|
1108
|
-
return this instanceof S ? (i.Duplex.call(this), this.options = {
|
|
1109
|
-
// resize options
|
|
1110
|
-
topOffsetPre: -1,
|
|
1111
|
-
leftOffsetPre: -1,
|
|
1112
|
-
widthPre: -1,
|
|
1113
|
-
heightPre: -1,
|
|
1114
|
-
topOffsetPost: -1,
|
|
1115
|
-
leftOffsetPost: -1,
|
|
1116
|
-
widthPost: -1,
|
|
1117
|
-
heightPost: -1,
|
|
1118
|
-
width: -1,
|
|
1119
|
-
height: -1,
|
|
1120
|
-
canvas: "crop",
|
|
1121
|
-
position: 0,
|
|
1122
|
-
resizeBackground: [0, 0, 0, 255],
|
|
1123
|
-
angle: 0,
|
|
1124
|
-
rotationAngle: 0,
|
|
1125
|
-
rotationBackground: [0, 0, 0, 255],
|
|
1126
|
-
rotateBefore: !1,
|
|
1127
|
-
orientBefore: !1,
|
|
1128
|
-
flip: !1,
|
|
1129
|
-
flop: !1,
|
|
1130
|
-
extendTop: 0,
|
|
1131
|
-
extendBottom: 0,
|
|
1132
|
-
extendLeft: 0,
|
|
1133
|
-
extendRight: 0,
|
|
1134
|
-
extendBackground: [0, 0, 0, 255],
|
|
1135
|
-
extendWith: "background",
|
|
1136
|
-
withoutEnlargement: !1,
|
|
1137
|
-
withoutReduction: !1,
|
|
1138
|
-
affineMatrix: [],
|
|
1139
|
-
affineBackground: [0, 0, 0, 255],
|
|
1140
|
-
affineIdx: 0,
|
|
1141
|
-
affineIdy: 0,
|
|
1142
|
-
affineOdx: 0,
|
|
1143
|
-
affineOdy: 0,
|
|
1144
|
-
affineInterpolator: this.constructor.interpolators.bilinear,
|
|
1145
|
-
kernel: "lanczos3",
|
|
1146
|
-
fastShrinkOnLoad: !0,
|
|
1147
|
-
// operations
|
|
1148
|
-
tint: [-1, 0, 0, 0],
|
|
1149
|
-
flatten: !1,
|
|
1150
|
-
flattenBackground: [0, 0, 0],
|
|
1151
|
-
unflatten: !1,
|
|
1152
|
-
negate: !1,
|
|
1153
|
-
negateAlpha: !0,
|
|
1154
|
-
medianSize: 0,
|
|
1155
|
-
blurSigma: 0,
|
|
1156
|
-
precision: "integer",
|
|
1157
|
-
minAmpl: 0.2,
|
|
1158
|
-
sharpenSigma: 0,
|
|
1159
|
-
sharpenM1: 1,
|
|
1160
|
-
sharpenM2: 2,
|
|
1161
|
-
sharpenX1: 2,
|
|
1162
|
-
sharpenY2: 10,
|
|
1163
|
-
sharpenY3: 20,
|
|
1164
|
-
threshold: 0,
|
|
1165
|
-
thresholdGrayscale: !0,
|
|
1166
|
-
trimBackground: [],
|
|
1167
|
-
trimThreshold: -1,
|
|
1168
|
-
trimLineArt: !1,
|
|
1169
|
-
dilateWidth: 0,
|
|
1170
|
-
erodeWidth: 0,
|
|
1171
|
-
gamma: 0,
|
|
1172
|
-
gammaOut: 0,
|
|
1173
|
-
greyscale: !1,
|
|
1174
|
-
normalise: !1,
|
|
1175
|
-
normaliseLower: 1,
|
|
1176
|
-
normaliseUpper: 99,
|
|
1177
|
-
claheWidth: 0,
|
|
1178
|
-
claheHeight: 0,
|
|
1179
|
-
claheMaxSlope: 3,
|
|
1180
|
-
brightness: 1,
|
|
1181
|
-
saturation: 1,
|
|
1182
|
-
hue: 0,
|
|
1183
|
-
lightness: 0,
|
|
1184
|
-
booleanBufferIn: null,
|
|
1185
|
-
booleanFileIn: "",
|
|
1186
|
-
joinChannelIn: [],
|
|
1187
|
-
extractChannel: -1,
|
|
1188
|
-
removeAlpha: !1,
|
|
1189
|
-
ensureAlpha: -1,
|
|
1190
|
-
colourspace: "srgb",
|
|
1191
|
-
colourspacePipeline: "last",
|
|
1192
|
-
composite: [],
|
|
1193
|
-
// output
|
|
1194
|
-
fileOut: "",
|
|
1195
|
-
formatOut: "input",
|
|
1196
|
-
streamOut: !1,
|
|
1197
|
-
keepMetadata: 0,
|
|
1198
|
-
withMetadataOrientation: -1,
|
|
1199
|
-
withMetadataDensity: 0,
|
|
1200
|
-
withIccProfile: "",
|
|
1201
|
-
withExif: {},
|
|
1202
|
-
withExifMerge: !0,
|
|
1203
|
-
withXmp: "",
|
|
1204
|
-
resolveWithObject: !1,
|
|
1205
|
-
loop: -1,
|
|
1206
|
-
delay: [],
|
|
1207
|
-
// output format
|
|
1208
|
-
jpegQuality: 80,
|
|
1209
|
-
jpegProgressive: !1,
|
|
1210
|
-
jpegChromaSubsampling: "4:2:0",
|
|
1211
|
-
jpegTrellisQuantisation: !1,
|
|
1212
|
-
jpegOvershootDeringing: !1,
|
|
1213
|
-
jpegOptimiseScans: !1,
|
|
1214
|
-
jpegOptimiseCoding: !0,
|
|
1215
|
-
jpegQuantisationTable: 0,
|
|
1216
|
-
pngProgressive: !1,
|
|
1217
|
-
pngCompressionLevel: 6,
|
|
1218
|
-
pngAdaptiveFiltering: !1,
|
|
1219
|
-
pngPalette: !1,
|
|
1220
|
-
pngQuality: 100,
|
|
1221
|
-
pngEffort: 7,
|
|
1222
|
-
pngBitdepth: 8,
|
|
1223
|
-
pngDither: 1,
|
|
1224
|
-
jp2Quality: 80,
|
|
1225
|
-
jp2TileHeight: 512,
|
|
1226
|
-
jp2TileWidth: 512,
|
|
1227
|
-
jp2Lossless: !1,
|
|
1228
|
-
jp2ChromaSubsampling: "4:4:4",
|
|
1229
|
-
webpQuality: 80,
|
|
1230
|
-
webpAlphaQuality: 100,
|
|
1231
|
-
webpLossless: !1,
|
|
1232
|
-
webpNearLossless: !1,
|
|
1233
|
-
webpSmartSubsample: !1,
|
|
1234
|
-
webpSmartDeblock: !1,
|
|
1235
|
-
webpPreset: "default",
|
|
1236
|
-
webpEffort: 4,
|
|
1237
|
-
webpMinSize: !1,
|
|
1238
|
-
webpMixed: !1,
|
|
1239
|
-
gifBitdepth: 8,
|
|
1240
|
-
gifEffort: 7,
|
|
1241
|
-
gifDither: 1,
|
|
1242
|
-
gifInterFrameMaxError: 0,
|
|
1243
|
-
gifInterPaletteMaxError: 3,
|
|
1244
|
-
gifKeepDuplicateFrames: !1,
|
|
1245
|
-
gifReuse: !0,
|
|
1246
|
-
gifProgressive: !1,
|
|
1247
|
-
tiffQuality: 80,
|
|
1248
|
-
tiffCompression: "jpeg",
|
|
1249
|
-
tiffBigtiff: !1,
|
|
1250
|
-
tiffPredictor: "horizontal",
|
|
1251
|
-
tiffPyramid: !1,
|
|
1252
|
-
tiffMiniswhite: !1,
|
|
1253
|
-
tiffBitdepth: 8,
|
|
1254
|
-
tiffTile: !1,
|
|
1255
|
-
tiffTileHeight: 256,
|
|
1256
|
-
tiffTileWidth: 256,
|
|
1257
|
-
tiffXres: 1,
|
|
1258
|
-
tiffYres: 1,
|
|
1259
|
-
tiffResolutionUnit: "inch",
|
|
1260
|
-
heifQuality: 50,
|
|
1261
|
-
heifLossless: !1,
|
|
1262
|
-
heifCompression: "av1",
|
|
1263
|
-
heifEffort: 4,
|
|
1264
|
-
heifChromaSubsampling: "4:4:4",
|
|
1265
|
-
heifBitdepth: 8,
|
|
1266
|
-
jxlDistance: 1,
|
|
1267
|
-
jxlDecodingTier: 0,
|
|
1268
|
-
jxlEffort: 7,
|
|
1269
|
-
jxlLossless: !1,
|
|
1270
|
-
rawDepth: "uchar",
|
|
1271
|
-
tileSize: 256,
|
|
1272
|
-
tileOverlap: 0,
|
|
1273
|
-
tileContainer: "fs",
|
|
1274
|
-
tileLayout: "dz",
|
|
1275
|
-
tileFormat: "last",
|
|
1276
|
-
tileDepth: "last",
|
|
1277
|
-
tileAngle: 0,
|
|
1278
|
-
tileSkipBlanks: -1,
|
|
1279
|
-
tileBackground: [255, 255, 255, 255],
|
|
1280
|
-
tileCentre: !1,
|
|
1281
|
-
tileId: "https://example.com/iiif",
|
|
1282
|
-
tileBasename: "",
|
|
1283
|
-
timeoutSeconds: 0,
|
|
1284
|
-
linearA: [],
|
|
1285
|
-
linearB: [],
|
|
1286
|
-
pdfBackground: [255, 255, 255, 255],
|
|
1287
|
-
// Function to notify of libvips warnings
|
|
1288
|
-
debuglog: (g) => {
|
|
1289
|
-
this.emit("warning", g), y(g);
|
|
1290
|
-
},
|
|
1291
|
-
// Function to notify of queue length changes
|
|
1292
|
-
queueListener: b
|
|
1293
|
-
}, this.options.input = this._createInputDescriptor(w, d, { allowStream: !0 }), this) : new S(w, d);
|
|
1294
|
-
};
|
|
1295
|
-
Object.setPrototypeOf(S.prototype, i.Duplex.prototype), Object.setPrototypeOf(S, i.Duplex);
|
|
1296
|
-
function R() {
|
|
1297
|
-
const w = this.constructor.call(), { debuglog: d, queueListener: g, ...c } = this.options;
|
|
1298
|
-
return w.options = structuredClone(c), w.options.debuglog = d, w.options.queueListener = g, this._isStreamInput() && this.on("finish", () => {
|
|
1299
|
-
this._flattenBufferIn(), w.options.input.buffer = this.options.input.buffer, w.emit("finish");
|
|
1300
|
-
}), w;
|
|
1301
|
-
}
|
|
1302
|
-
return Object.assign(S.prototype, { clone: R }), Fe = S, Fe;
|
|
1303
|
-
}
|
|
1304
|
-
var Be, jr;
|
|
1305
|
-
function Rt() {
|
|
1306
|
-
if (jr) return Be;
|
|
1307
|
-
jr = 1;
|
|
1308
|
-
const e = ee(), i = fe(), P = {
|
|
1309
|
-
left: "low",
|
|
1310
|
-
top: "low",
|
|
1311
|
-
low: "low",
|
|
1312
|
-
center: "centre",
|
|
1313
|
-
centre: "centre",
|
|
1314
|
-
right: "high",
|
|
1315
|
-
bottom: "high",
|
|
1316
|
-
high: "high"
|
|
1317
|
-
}, y = [
|
|
1318
|
-
// Limits and error handling
|
|
1319
|
-
"failOn",
|
|
1320
|
-
"limitInputPixels",
|
|
1321
|
-
"unlimited",
|
|
1322
|
-
// Format-generic
|
|
1323
|
-
"animated",
|
|
1324
|
-
"autoOrient",
|
|
1325
|
-
"density",
|
|
1326
|
-
"ignoreIcc",
|
|
1327
|
-
"page",
|
|
1328
|
-
"pages",
|
|
1329
|
-
"sequentialRead",
|
|
1330
|
-
// Format-specific
|
|
1331
|
-
"jp2",
|
|
1332
|
-
"openSlide",
|
|
1333
|
-
"pdf",
|
|
1334
|
-
"raw",
|
|
1335
|
-
"svg",
|
|
1336
|
-
"tiff",
|
|
1337
|
-
// Deprecated
|
|
1338
|
-
"failOnError",
|
|
1339
|
-
"openSlideLevel",
|
|
1340
|
-
"pdfBackground",
|
|
1341
|
-
"tiffSubifd"
|
|
1342
|
-
];
|
|
1343
|
-
function b(p) {
|
|
1344
|
-
const n = y.filter((k) => e.defined(p[k])).map((k) => [k, p[k]]);
|
|
1345
|
-
return n.length ? Object.fromEntries(n) : void 0;
|
|
1346
|
-
}
|
|
1347
|
-
function S(p, n, k) {
|
|
1348
|
-
const h = {
|
|
1349
|
-
autoOrient: !1,
|
|
1350
|
-
failOn: "warning",
|
|
1351
|
-
limitInputPixels: 268402689,
|
|
1352
|
-
ignoreIcc: !1,
|
|
1353
|
-
unlimited: !1,
|
|
1354
|
-
sequentialRead: !0
|
|
1355
|
-
};
|
|
1356
|
-
if (e.string(p))
|
|
1357
|
-
h.file = p;
|
|
1358
|
-
else if (e.buffer(p)) {
|
|
1359
|
-
if (p.length === 0)
|
|
1360
|
-
throw Error("Input Buffer is empty");
|
|
1361
|
-
h.buffer = p;
|
|
1362
|
-
} else if (e.arrayBuffer(p)) {
|
|
1363
|
-
if (p.byteLength === 0)
|
|
1364
|
-
throw Error("Input bit Array is empty");
|
|
1365
|
-
h.buffer = Buffer.from(p, 0, p.byteLength);
|
|
1366
|
-
} else if (e.typedArray(p)) {
|
|
1367
|
-
if (p.length === 0)
|
|
1368
|
-
throw Error("Input Bit Array is empty");
|
|
1369
|
-
h.buffer = Buffer.from(p.buffer, p.byteOffset, p.byteLength);
|
|
1370
|
-
} else if (e.plainObject(p) && !e.defined(n))
|
|
1371
|
-
n = p, b(n) && (h.buffer = []);
|
|
1372
|
-
else if (!e.defined(p) && !e.defined(n) && e.object(k) && k.allowStream)
|
|
1373
|
-
h.buffer = [];
|
|
1374
|
-
else if (Array.isArray(p))
|
|
1375
|
-
if (p.length > 1)
|
|
1376
|
-
if (!this.options.joining)
|
|
1377
|
-
this.options.joining = !0, this.options.join = p.map((u) => this._createInputDescriptor(u));
|
|
1378
|
-
else
|
|
1379
|
-
throw new Error("Recursive join is unsupported");
|
|
1380
|
-
else
|
|
1381
|
-
throw new Error("Expected at least two images to join");
|
|
1382
|
-
else
|
|
1383
|
-
throw new Error(`Unsupported input '${p}' of type ${typeof p}${e.defined(n) ? ` when also providing options of type ${typeof n}` : ""}`);
|
|
1384
|
-
if (e.object(n)) {
|
|
1385
|
-
if (e.defined(n.failOnError))
|
|
1386
|
-
if (e.bool(n.failOnError))
|
|
1387
|
-
h.failOn = n.failOnError ? "warning" : "none";
|
|
1388
|
-
else
|
|
1389
|
-
throw e.invalidParameterError("failOnError", "boolean", n.failOnError);
|
|
1390
|
-
if (e.defined(n.failOn))
|
|
1391
|
-
if (e.string(n.failOn) && e.inArray(n.failOn, ["none", "truncated", "error", "warning"]))
|
|
1392
|
-
h.failOn = n.failOn;
|
|
1393
|
-
else
|
|
1394
|
-
throw e.invalidParameterError("failOn", "one of: none, truncated, error, warning", n.failOn);
|
|
1395
|
-
if (e.defined(n.autoOrient))
|
|
1396
|
-
if (e.bool(n.autoOrient))
|
|
1397
|
-
h.autoOrient = n.autoOrient;
|
|
1398
|
-
else
|
|
1399
|
-
throw e.invalidParameterError("autoOrient", "boolean", n.autoOrient);
|
|
1400
|
-
if (e.defined(n.density))
|
|
1401
|
-
if (e.inRange(n.density, 1, 1e5))
|
|
1402
|
-
h.density = n.density;
|
|
1403
|
-
else
|
|
1404
|
-
throw e.invalidParameterError("density", "number between 1 and 100000", n.density);
|
|
1405
|
-
if (e.defined(n.ignoreIcc))
|
|
1406
|
-
if (e.bool(n.ignoreIcc))
|
|
1407
|
-
h.ignoreIcc = n.ignoreIcc;
|
|
1408
|
-
else
|
|
1409
|
-
throw e.invalidParameterError("ignoreIcc", "boolean", n.ignoreIcc);
|
|
1410
|
-
if (e.defined(n.limitInputPixels))
|
|
1411
|
-
if (e.bool(n.limitInputPixels))
|
|
1412
|
-
h.limitInputPixels = n.limitInputPixels ? 16383 ** 2 : 0;
|
|
1413
|
-
else if (e.integer(n.limitInputPixels) && e.inRange(n.limitInputPixels, 0, Number.MAX_SAFE_INTEGER))
|
|
1414
|
-
h.limitInputPixels = n.limitInputPixels;
|
|
1415
|
-
else
|
|
1416
|
-
throw e.invalidParameterError("limitInputPixels", "positive integer", n.limitInputPixels);
|
|
1417
|
-
if (e.defined(n.unlimited))
|
|
1418
|
-
if (e.bool(n.unlimited))
|
|
1419
|
-
h.unlimited = n.unlimited;
|
|
1420
|
-
else
|
|
1421
|
-
throw e.invalidParameterError("unlimited", "boolean", n.unlimited);
|
|
1422
|
-
if (e.defined(n.sequentialRead))
|
|
1423
|
-
if (e.bool(n.sequentialRead))
|
|
1424
|
-
h.sequentialRead = n.sequentialRead;
|
|
1425
|
-
else
|
|
1426
|
-
throw e.invalidParameterError("sequentialRead", "boolean", n.sequentialRead);
|
|
1427
|
-
if (e.defined(n.raw)) {
|
|
1428
|
-
if (e.object(n.raw) && e.integer(n.raw.width) && n.raw.width > 0 && e.integer(n.raw.height) && n.raw.height > 0 && e.integer(n.raw.channels) && e.inRange(n.raw.channels, 1, 4))
|
|
1429
|
-
switch (h.rawWidth = n.raw.width, h.rawHeight = n.raw.height, h.rawChannels = n.raw.channels, p.constructor) {
|
|
1430
|
-
case Uint8Array:
|
|
1431
|
-
case Uint8ClampedArray:
|
|
1432
|
-
h.rawDepth = "uchar";
|
|
1433
|
-
break;
|
|
1434
|
-
case Int8Array:
|
|
1435
|
-
h.rawDepth = "char";
|
|
1436
|
-
break;
|
|
1437
|
-
case Uint16Array:
|
|
1438
|
-
h.rawDepth = "ushort";
|
|
1439
|
-
break;
|
|
1440
|
-
case Int16Array:
|
|
1441
|
-
h.rawDepth = "short";
|
|
1442
|
-
break;
|
|
1443
|
-
case Uint32Array:
|
|
1444
|
-
h.rawDepth = "uint";
|
|
1445
|
-
break;
|
|
1446
|
-
case Int32Array:
|
|
1447
|
-
h.rawDepth = "int";
|
|
1448
|
-
break;
|
|
1449
|
-
case Float32Array:
|
|
1450
|
-
h.rawDepth = "float";
|
|
1451
|
-
break;
|
|
1452
|
-
case Float64Array:
|
|
1453
|
-
h.rawDepth = "double";
|
|
1454
|
-
break;
|
|
1455
|
-
default:
|
|
1456
|
-
h.rawDepth = "uchar";
|
|
1457
|
-
break;
|
|
1458
|
-
}
|
|
1459
|
-
else
|
|
1460
|
-
throw new Error("Expected width, height and channels for raw pixel input");
|
|
1461
|
-
if (h.rawPremultiplied = !1, e.defined(n.raw.premultiplied))
|
|
1462
|
-
if (e.bool(n.raw.premultiplied))
|
|
1463
|
-
h.rawPremultiplied = n.raw.premultiplied;
|
|
1464
|
-
else
|
|
1465
|
-
throw e.invalidParameterError("raw.premultiplied", "boolean", n.raw.premultiplied);
|
|
1466
|
-
if (h.rawPageHeight = 0, e.defined(n.raw.pageHeight))
|
|
1467
|
-
if (e.integer(n.raw.pageHeight) && n.raw.pageHeight > 0 && n.raw.pageHeight <= n.raw.height) {
|
|
1468
|
-
if (n.raw.height % n.raw.pageHeight !== 0)
|
|
1469
|
-
throw new Error(`Expected raw.height ${n.raw.height} to be a multiple of raw.pageHeight ${n.raw.pageHeight}`);
|
|
1470
|
-
h.rawPageHeight = n.raw.pageHeight;
|
|
1471
|
-
} else
|
|
1472
|
-
throw e.invalidParameterError("raw.pageHeight", "positive integer", n.raw.pageHeight);
|
|
1473
|
-
}
|
|
1474
|
-
if (e.defined(n.animated))
|
|
1475
|
-
if (e.bool(n.animated))
|
|
1476
|
-
h.pages = n.animated ? -1 : 1;
|
|
1477
|
-
else
|
|
1478
|
-
throw e.invalidParameterError("animated", "boolean", n.animated);
|
|
1479
|
-
if (e.defined(n.pages))
|
|
1480
|
-
if (e.integer(n.pages) && e.inRange(n.pages, -1, 1e5))
|
|
1481
|
-
h.pages = n.pages;
|
|
1482
|
-
else
|
|
1483
|
-
throw e.invalidParameterError("pages", "integer between -1 and 100000", n.pages);
|
|
1484
|
-
if (e.defined(n.page))
|
|
1485
|
-
if (e.integer(n.page) && e.inRange(n.page, 0, 1e5))
|
|
1486
|
-
h.page = n.page;
|
|
1487
|
-
else
|
|
1488
|
-
throw e.invalidParameterError("page", "integer between 0 and 100000", n.page);
|
|
1489
|
-
if (e.object(n.openSlide) && e.defined(n.openSlide.level))
|
|
1490
|
-
if (e.integer(n.openSlide.level) && e.inRange(n.openSlide.level, 0, 256))
|
|
1491
|
-
h.openSlideLevel = n.openSlide.level;
|
|
1492
|
-
else
|
|
1493
|
-
throw e.invalidParameterError("openSlide.level", "integer between 0 and 256", n.openSlide.level);
|
|
1494
|
-
else if (e.defined(n.level))
|
|
1495
|
-
if (e.integer(n.level) && e.inRange(n.level, 0, 256))
|
|
1496
|
-
h.openSlideLevel = n.level;
|
|
1497
|
-
else
|
|
1498
|
-
throw e.invalidParameterError("level", "integer between 0 and 256", n.level);
|
|
1499
|
-
if (e.object(n.tiff) && e.defined(n.tiff.subifd))
|
|
1500
|
-
if (e.integer(n.tiff.subifd) && e.inRange(n.tiff.subifd, -1, 1e5))
|
|
1501
|
-
h.tiffSubifd = n.tiff.subifd;
|
|
1502
|
-
else
|
|
1503
|
-
throw e.invalidParameterError("tiff.subifd", "integer between -1 and 100000", n.tiff.subifd);
|
|
1504
|
-
else if (e.defined(n.subifd))
|
|
1505
|
-
if (e.integer(n.subifd) && e.inRange(n.subifd, -1, 1e5))
|
|
1506
|
-
h.tiffSubifd = n.subifd;
|
|
1507
|
-
else
|
|
1508
|
-
throw e.invalidParameterError("subifd", "integer between -1 and 100000", n.subifd);
|
|
1509
|
-
if (e.object(n.svg)) {
|
|
1510
|
-
if (e.defined(n.svg.stylesheet))
|
|
1511
|
-
if (e.string(n.svg.stylesheet))
|
|
1512
|
-
h.svgStylesheet = n.svg.stylesheet;
|
|
1513
|
-
else
|
|
1514
|
-
throw e.invalidParameterError("svg.stylesheet", "string", n.svg.stylesheet);
|
|
1515
|
-
if (e.defined(n.svg.highBitdepth))
|
|
1516
|
-
if (e.bool(n.svg.highBitdepth))
|
|
1517
|
-
h.svgHighBitdepth = n.svg.highBitdepth;
|
|
1518
|
-
else
|
|
1519
|
-
throw e.invalidParameterError("svg.highBitdepth", "boolean", n.svg.highBitdepth);
|
|
1520
|
-
}
|
|
1521
|
-
if (e.object(n.pdf) && e.defined(n.pdf.background) ? h.pdfBackground = this._getBackgroundColourOption(n.pdf.background) : e.defined(n.pdfBackground) && (h.pdfBackground = this._getBackgroundColourOption(n.pdfBackground)), e.object(n.jp2) && e.defined(n.jp2.oneshot))
|
|
1522
|
-
if (e.bool(n.jp2.oneshot))
|
|
1523
|
-
h.jp2Oneshot = n.jp2.oneshot;
|
|
1524
|
-
else
|
|
1525
|
-
throw e.invalidParameterError("jp2.oneshot", "boolean", n.jp2.oneshot);
|
|
1526
|
-
if (e.defined(n.create))
|
|
1527
|
-
if (e.object(n.create) && e.integer(n.create.width) && n.create.width > 0 && e.integer(n.create.height) && n.create.height > 0 && e.integer(n.create.channels)) {
|
|
1528
|
-
if (h.createWidth = n.create.width, h.createHeight = n.create.height, h.createChannels = n.create.channels, h.createPageHeight = 0, e.defined(n.create.pageHeight))
|
|
1529
|
-
if (e.integer(n.create.pageHeight) && n.create.pageHeight > 0 && n.create.pageHeight <= n.create.height) {
|
|
1530
|
-
if (n.create.height % n.create.pageHeight !== 0)
|
|
1531
|
-
throw new Error(`Expected create.height ${n.create.height} to be a multiple of create.pageHeight ${n.create.pageHeight}`);
|
|
1532
|
-
h.createPageHeight = n.create.pageHeight;
|
|
1533
|
-
} else
|
|
1534
|
-
throw e.invalidParameterError("create.pageHeight", "positive integer", n.create.pageHeight);
|
|
1535
|
-
if (e.defined(n.create.noise)) {
|
|
1536
|
-
if (!e.object(n.create.noise))
|
|
1537
|
-
throw new Error("Expected noise to be an object");
|
|
1538
|
-
if (n.create.noise.type !== "gaussian")
|
|
1539
|
-
throw new Error("Only gaussian noise is supported at the moment");
|
|
1540
|
-
if (h.createNoiseType = n.create.noise.type, !e.inRange(n.create.channels, 1, 4))
|
|
1541
|
-
throw e.invalidParameterError("create.channels", "number between 1 and 4", n.create.channels);
|
|
1542
|
-
if (h.createNoiseMean = 128, e.defined(n.create.noise.mean))
|
|
1543
|
-
if (e.number(n.create.noise.mean) && e.inRange(n.create.noise.mean, 0, 1e4))
|
|
1544
|
-
h.createNoiseMean = n.create.noise.mean;
|
|
1545
|
-
else
|
|
1546
|
-
throw e.invalidParameterError("create.noise.mean", "number between 0 and 10000", n.create.noise.mean);
|
|
1547
|
-
if (h.createNoiseSigma = 30, e.defined(n.create.noise.sigma))
|
|
1548
|
-
if (e.number(n.create.noise.sigma) && e.inRange(n.create.noise.sigma, 0, 1e4))
|
|
1549
|
-
h.createNoiseSigma = n.create.noise.sigma;
|
|
1550
|
-
else
|
|
1551
|
-
throw e.invalidParameterError("create.noise.sigma", "number between 0 and 10000", n.create.noise.sigma);
|
|
1552
|
-
} else if (e.defined(n.create.background)) {
|
|
1553
|
-
if (!e.inRange(n.create.channels, 3, 4))
|
|
1554
|
-
throw e.invalidParameterError("create.channels", "number between 3 and 4", n.create.channels);
|
|
1555
|
-
h.createBackground = this._getBackgroundColourOption(n.create.background);
|
|
1556
|
-
} else
|
|
1557
|
-
throw new Error("Expected valid noise or background to create a new input image");
|
|
1558
|
-
delete h.buffer;
|
|
1559
|
-
} else
|
|
1560
|
-
throw new Error("Expected valid width, height and channels to create a new input image");
|
|
1561
|
-
if (e.defined(n.text))
|
|
1562
|
-
if (e.object(n.text) && e.string(n.text.text)) {
|
|
1563
|
-
if (h.textValue = n.text.text, e.defined(n.text.height) && e.defined(n.text.dpi))
|
|
1564
|
-
throw new Error("Expected only one of dpi or height");
|
|
1565
|
-
if (e.defined(n.text.font))
|
|
1566
|
-
if (e.string(n.text.font))
|
|
1567
|
-
h.textFont = n.text.font;
|
|
1568
|
-
else
|
|
1569
|
-
throw e.invalidParameterError("text.font", "string", n.text.font);
|
|
1570
|
-
if (e.defined(n.text.fontfile))
|
|
1571
|
-
if (e.string(n.text.fontfile))
|
|
1572
|
-
h.textFontfile = n.text.fontfile;
|
|
1573
|
-
else
|
|
1574
|
-
throw e.invalidParameterError("text.fontfile", "string", n.text.fontfile);
|
|
1575
|
-
if (e.defined(n.text.width))
|
|
1576
|
-
if (e.integer(n.text.width) && n.text.width > 0)
|
|
1577
|
-
h.textWidth = n.text.width;
|
|
1578
|
-
else
|
|
1579
|
-
throw e.invalidParameterError("text.width", "positive integer", n.text.width);
|
|
1580
|
-
if (e.defined(n.text.height))
|
|
1581
|
-
if (e.integer(n.text.height) && n.text.height > 0)
|
|
1582
|
-
h.textHeight = n.text.height;
|
|
1583
|
-
else
|
|
1584
|
-
throw e.invalidParameterError("text.height", "positive integer", n.text.height);
|
|
1585
|
-
if (e.defined(n.text.align))
|
|
1586
|
-
if (e.string(n.text.align) && e.string(this.constructor.align[n.text.align]))
|
|
1587
|
-
h.textAlign = this.constructor.align[n.text.align];
|
|
1588
|
-
else
|
|
1589
|
-
throw e.invalidParameterError("text.align", "valid alignment", n.text.align);
|
|
1590
|
-
if (e.defined(n.text.justify))
|
|
1591
|
-
if (e.bool(n.text.justify))
|
|
1592
|
-
h.textJustify = n.text.justify;
|
|
1593
|
-
else
|
|
1594
|
-
throw e.invalidParameterError("text.justify", "boolean", n.text.justify);
|
|
1595
|
-
if (e.defined(n.text.dpi))
|
|
1596
|
-
if (e.integer(n.text.dpi) && e.inRange(n.text.dpi, 1, 1e6))
|
|
1597
|
-
h.textDpi = n.text.dpi;
|
|
1598
|
-
else
|
|
1599
|
-
throw e.invalidParameterError("text.dpi", "integer between 1 and 1000000", n.text.dpi);
|
|
1600
|
-
if (e.defined(n.text.rgba))
|
|
1601
|
-
if (e.bool(n.text.rgba))
|
|
1602
|
-
h.textRgba = n.text.rgba;
|
|
1603
|
-
else
|
|
1604
|
-
throw e.invalidParameterError("text.rgba", "bool", n.text.rgba);
|
|
1605
|
-
if (e.defined(n.text.spacing))
|
|
1606
|
-
if (e.integer(n.text.spacing) && e.inRange(n.text.spacing, -1e6, 1e6))
|
|
1607
|
-
h.textSpacing = n.text.spacing;
|
|
1608
|
-
else
|
|
1609
|
-
throw e.invalidParameterError("text.spacing", "integer between -1000000 and 1000000", n.text.spacing);
|
|
1610
|
-
if (e.defined(n.text.wrap))
|
|
1611
|
-
if (e.string(n.text.wrap) && e.inArray(n.text.wrap, ["word", "char", "word-char", "none"]))
|
|
1612
|
-
h.textWrap = n.text.wrap;
|
|
1613
|
-
else
|
|
1614
|
-
throw e.invalidParameterError("text.wrap", "one of: word, char, word-char, none", n.text.wrap);
|
|
1615
|
-
delete h.buffer;
|
|
1616
|
-
} else
|
|
1617
|
-
throw new Error("Expected a valid string to create an image with text.");
|
|
1618
|
-
if (e.defined(n.join))
|
|
1619
|
-
if (e.defined(this.options.join)) {
|
|
1620
|
-
if (e.defined(n.join.animated))
|
|
1621
|
-
if (e.bool(n.join.animated))
|
|
1622
|
-
h.joinAnimated = n.join.animated;
|
|
1623
|
-
else
|
|
1624
|
-
throw e.invalidParameterError("join.animated", "boolean", n.join.animated);
|
|
1625
|
-
if (e.defined(n.join.across))
|
|
1626
|
-
if (e.integer(n.join.across) && e.inRange(n.join.across, 1, 1e6))
|
|
1627
|
-
h.joinAcross = n.join.across;
|
|
1628
|
-
else
|
|
1629
|
-
throw e.invalidParameterError("join.across", "integer between 1 and 100000", n.join.across);
|
|
1630
|
-
if (e.defined(n.join.shim))
|
|
1631
|
-
if (e.integer(n.join.shim) && e.inRange(n.join.shim, 0, 1e6))
|
|
1632
|
-
h.joinShim = n.join.shim;
|
|
1633
|
-
else
|
|
1634
|
-
throw e.invalidParameterError("join.shim", "integer between 0 and 100000", n.join.shim);
|
|
1635
|
-
if (e.defined(n.join.background) && (h.joinBackground = this._getBackgroundColourOption(n.join.background)), e.defined(n.join.halign))
|
|
1636
|
-
if (e.string(n.join.halign) && e.string(this.constructor.align[n.join.halign]))
|
|
1637
|
-
h.joinHalign = this.constructor.align[n.join.halign];
|
|
1638
|
-
else
|
|
1639
|
-
throw e.invalidParameterError("join.halign", "valid alignment", n.join.halign);
|
|
1640
|
-
if (e.defined(n.join.valign))
|
|
1641
|
-
if (e.string(n.join.valign) && e.string(this.constructor.align[n.join.valign]))
|
|
1642
|
-
h.joinValign = this.constructor.align[n.join.valign];
|
|
1643
|
-
else
|
|
1644
|
-
throw e.invalidParameterError("join.valign", "valid alignment", n.join.valign);
|
|
1645
|
-
} else
|
|
1646
|
-
throw new Error("Expected input to be an array of images to join");
|
|
1647
|
-
} else if (e.defined(n))
|
|
1648
|
-
throw new Error(`Invalid input options ${n}`);
|
|
1649
|
-
return h;
|
|
1650
|
-
}
|
|
1651
|
-
function R(p, n, k) {
|
|
1652
|
-
Array.isArray(this.options.input.buffer) ? e.buffer(p) ? (this.options.input.buffer.length === 0 && this.on("finish", () => {
|
|
1653
|
-
this.streamInFinished = !0;
|
|
1654
|
-
}), this.options.input.buffer.push(p), k()) : k(new Error("Non-Buffer data on Writable Stream")) : k(new Error("Unexpected data on Writable Stream"));
|
|
1655
|
-
}
|
|
1656
|
-
function w() {
|
|
1657
|
-
this._isStreamInput() && (this.options.input.buffer = Buffer.concat(this.options.input.buffer));
|
|
1658
|
-
}
|
|
1659
|
-
function d() {
|
|
1660
|
-
return Array.isArray(this.options.input.buffer);
|
|
1661
|
-
}
|
|
1662
|
-
function g(p) {
|
|
1663
|
-
const n = Error();
|
|
1664
|
-
return e.fn(p) ? (this._isStreamInput() ? this.on("finish", () => {
|
|
1665
|
-
this._flattenBufferIn(), i.metadata(this.options, (k, h) => {
|
|
1666
|
-
k ? p(e.nativeError(k, n)) : p(null, h);
|
|
1667
|
-
});
|
|
1668
|
-
}) : i.metadata(this.options, (k, h) => {
|
|
1669
|
-
k ? p(e.nativeError(k, n)) : p(null, h);
|
|
1670
|
-
}), this) : this._isStreamInput() ? new Promise((k, h) => {
|
|
1671
|
-
const u = () => {
|
|
1672
|
-
this._flattenBufferIn(), i.metadata(this.options, (I, $) => {
|
|
1673
|
-
I ? h(e.nativeError(I, n)) : k($);
|
|
1674
|
-
});
|
|
1675
|
-
};
|
|
1676
|
-
this.writableFinished ? u() : this.once("finish", u);
|
|
1677
|
-
}) : new Promise((k, h) => {
|
|
1678
|
-
i.metadata(this.options, (u, I) => {
|
|
1679
|
-
u ? h(e.nativeError(u, n)) : k(I);
|
|
1680
|
-
});
|
|
1681
|
-
});
|
|
1682
|
-
}
|
|
1683
|
-
function c(p) {
|
|
1684
|
-
const n = Error();
|
|
1685
|
-
return e.fn(p) ? (this._isStreamInput() ? this.on("finish", () => {
|
|
1686
|
-
this._flattenBufferIn(), i.stats(this.options, (k, h) => {
|
|
1687
|
-
k ? p(e.nativeError(k, n)) : p(null, h);
|
|
1688
|
-
});
|
|
1689
|
-
}) : i.stats(this.options, (k, h) => {
|
|
1690
|
-
k ? p(e.nativeError(k, n)) : p(null, h);
|
|
1691
|
-
}), this) : this._isStreamInput() ? new Promise((k, h) => {
|
|
1692
|
-
this.on("finish", function() {
|
|
1693
|
-
this._flattenBufferIn(), i.stats(this.options, (u, I) => {
|
|
1694
|
-
u ? h(e.nativeError(u, n)) : k(I);
|
|
1695
|
-
});
|
|
1696
|
-
});
|
|
1697
|
-
}) : new Promise((k, h) => {
|
|
1698
|
-
i.stats(this.options, (u, I) => {
|
|
1699
|
-
u ? h(e.nativeError(u, n)) : k(I);
|
|
1700
|
-
});
|
|
1701
|
-
});
|
|
1702
|
-
}
|
|
1703
|
-
return Be = (p) => {
|
|
1704
|
-
Object.assign(p.prototype, {
|
|
1705
|
-
// Private
|
|
1706
|
-
_inputOptionsFromObject: b,
|
|
1707
|
-
_createInputDescriptor: S,
|
|
1708
|
-
_write: R,
|
|
1709
|
-
_flattenBufferIn: w,
|
|
1710
|
-
_isStreamInput: d,
|
|
1711
|
-
// Public
|
|
1712
|
-
metadata: g,
|
|
1713
|
-
stats: c
|
|
1714
|
-
}), p.align = P;
|
|
1715
|
-
}, Be;
|
|
1716
|
-
}
|
|
1717
|
-
var Me, Ar;
|
|
1718
|
-
function xt() {
|
|
1719
|
-
if (Ar) return Me;
|
|
1720
|
-
Ar = 1;
|
|
1721
|
-
const e = ee(), i = {
|
|
1722
|
-
center: 0,
|
|
1723
|
-
centre: 0,
|
|
1724
|
-
north: 1,
|
|
1725
|
-
east: 2,
|
|
1726
|
-
south: 3,
|
|
1727
|
-
west: 4,
|
|
1728
|
-
northeast: 5,
|
|
1729
|
-
southeast: 6,
|
|
1730
|
-
southwest: 7,
|
|
1731
|
-
northwest: 8
|
|
1732
|
-
}, P = {
|
|
1733
|
-
top: 1,
|
|
1734
|
-
right: 2,
|
|
1735
|
-
bottom: 3,
|
|
1736
|
-
left: 4,
|
|
1737
|
-
"right top": 5,
|
|
1738
|
-
"right bottom": 6,
|
|
1739
|
-
"left bottom": 7,
|
|
1740
|
-
"left top": 8
|
|
1741
|
-
}, y = {
|
|
1742
|
-
background: "background",
|
|
1743
|
-
copy: "copy",
|
|
1744
|
-
repeat: "repeat",
|
|
1745
|
-
mirror: "mirror"
|
|
1746
|
-
}, b = {
|
|
1747
|
-
entropy: 16,
|
|
1748
|
-
attention: 17
|
|
1749
|
-
}, S = {
|
|
1750
|
-
nearest: "nearest",
|
|
1751
|
-
linear: "linear",
|
|
1752
|
-
cubic: "cubic",
|
|
1753
|
-
mitchell: "mitchell",
|
|
1754
|
-
lanczos2: "lanczos2",
|
|
1755
|
-
lanczos3: "lanczos3",
|
|
1756
|
-
mks2013: "mks2013",
|
|
1757
|
-
mks2021: "mks2021"
|
|
1758
|
-
}, R = {
|
|
1759
|
-
contain: "contain",
|
|
1760
|
-
cover: "cover",
|
|
1761
|
-
fill: "fill",
|
|
1762
|
-
inside: "inside",
|
|
1763
|
-
outside: "outside"
|
|
1764
|
-
}, w = {
|
|
1765
|
-
contain: "embed",
|
|
1766
|
-
cover: "crop",
|
|
1767
|
-
fill: "ignore_aspect",
|
|
1768
|
-
inside: "max",
|
|
1769
|
-
outside: "min"
|
|
1770
|
-
};
|
|
1771
|
-
function d(h) {
|
|
1772
|
-
return h.angle % 360 !== 0 || h.rotationAngle !== 0;
|
|
1773
|
-
}
|
|
1774
|
-
function g(h) {
|
|
1775
|
-
return h.width !== -1 || h.height !== -1;
|
|
1776
|
-
}
|
|
1777
|
-
function c(h, u, I) {
|
|
1778
|
-
if (g(this.options) && this.options.debuglog("ignoring previous resize options"), this.options.widthPost !== -1 && this.options.debuglog("operation order will be: extract, resize, extract"), e.defined(h))
|
|
1779
|
-
if (e.object(h) && !e.defined(I))
|
|
1780
|
-
I = h;
|
|
1781
|
-
else if (e.integer(h) && h > 0)
|
|
1782
|
-
this.options.width = h;
|
|
1783
|
-
else
|
|
1784
|
-
throw e.invalidParameterError("width", "positive integer", h);
|
|
1785
|
-
else
|
|
1786
|
-
this.options.width = -1;
|
|
1787
|
-
if (e.defined(u))
|
|
1788
|
-
if (e.integer(u) && u > 0)
|
|
1789
|
-
this.options.height = u;
|
|
1790
|
-
else
|
|
1791
|
-
throw e.invalidParameterError("height", "positive integer", u);
|
|
1792
|
-
else
|
|
1793
|
-
this.options.height = -1;
|
|
1794
|
-
if (e.object(I)) {
|
|
1795
|
-
if (e.defined(I.width))
|
|
1796
|
-
if (e.integer(I.width) && I.width > 0)
|
|
1797
|
-
this.options.width = I.width;
|
|
1798
|
-
else
|
|
1799
|
-
throw e.invalidParameterError("width", "positive integer", I.width);
|
|
1800
|
-
if (e.defined(I.height))
|
|
1801
|
-
if (e.integer(I.height) && I.height > 0)
|
|
1802
|
-
this.options.height = I.height;
|
|
1803
|
-
else
|
|
1804
|
-
throw e.invalidParameterError("height", "positive integer", I.height);
|
|
1805
|
-
if (e.defined(I.fit)) {
|
|
1806
|
-
const $ = w[I.fit];
|
|
1807
|
-
if (e.string($))
|
|
1808
|
-
this.options.canvas = $;
|
|
1809
|
-
else
|
|
1810
|
-
throw e.invalidParameterError("fit", "valid fit", I.fit);
|
|
1811
|
-
}
|
|
1812
|
-
if (e.defined(I.position)) {
|
|
1813
|
-
const $ = e.integer(I.position) ? I.position : b[I.position] || P[I.position] || i[I.position];
|
|
1814
|
-
if (e.integer($) && (e.inRange($, 0, 8) || e.inRange($, 16, 17)))
|
|
1815
|
-
this.options.position = $;
|
|
1816
|
-
else
|
|
1817
|
-
throw e.invalidParameterError("position", "valid position/gravity/strategy", I.position);
|
|
1818
|
-
}
|
|
1819
|
-
if (this._setBackgroundColourOption("resizeBackground", I.background), e.defined(I.kernel))
|
|
1820
|
-
if (e.string(S[I.kernel]))
|
|
1821
|
-
this.options.kernel = S[I.kernel];
|
|
1822
|
-
else
|
|
1823
|
-
throw e.invalidParameterError("kernel", "valid kernel name", I.kernel);
|
|
1824
|
-
e.defined(I.withoutEnlargement) && this._setBooleanOption("withoutEnlargement", I.withoutEnlargement), e.defined(I.withoutReduction) && this._setBooleanOption("withoutReduction", I.withoutReduction), e.defined(I.fastShrinkOnLoad) && this._setBooleanOption("fastShrinkOnLoad", I.fastShrinkOnLoad);
|
|
1825
|
-
}
|
|
1826
|
-
return d(this.options) && g(this.options) && (this.options.rotateBefore = !0), this;
|
|
1827
|
-
}
|
|
1828
|
-
function p(h) {
|
|
1829
|
-
if (e.integer(h) && h > 0)
|
|
1830
|
-
this.options.extendTop = h, this.options.extendBottom = h, this.options.extendLeft = h, this.options.extendRight = h;
|
|
1831
|
-
else if (e.object(h)) {
|
|
1832
|
-
if (e.defined(h.top))
|
|
1833
|
-
if (e.integer(h.top) && h.top >= 0)
|
|
1834
|
-
this.options.extendTop = h.top;
|
|
1835
|
-
else
|
|
1836
|
-
throw e.invalidParameterError("top", "positive integer", h.top);
|
|
1837
|
-
if (e.defined(h.bottom))
|
|
1838
|
-
if (e.integer(h.bottom) && h.bottom >= 0)
|
|
1839
|
-
this.options.extendBottom = h.bottom;
|
|
1840
|
-
else
|
|
1841
|
-
throw e.invalidParameterError("bottom", "positive integer", h.bottom);
|
|
1842
|
-
if (e.defined(h.left))
|
|
1843
|
-
if (e.integer(h.left) && h.left >= 0)
|
|
1844
|
-
this.options.extendLeft = h.left;
|
|
1845
|
-
else
|
|
1846
|
-
throw e.invalidParameterError("left", "positive integer", h.left);
|
|
1847
|
-
if (e.defined(h.right))
|
|
1848
|
-
if (e.integer(h.right) && h.right >= 0)
|
|
1849
|
-
this.options.extendRight = h.right;
|
|
1850
|
-
else
|
|
1851
|
-
throw e.invalidParameterError("right", "positive integer", h.right);
|
|
1852
|
-
if (this._setBackgroundColourOption("extendBackground", h.background), e.defined(h.extendWith))
|
|
1853
|
-
if (e.string(y[h.extendWith]))
|
|
1854
|
-
this.options.extendWith = y[h.extendWith];
|
|
1855
|
-
else
|
|
1856
|
-
throw e.invalidParameterError("extendWith", "one of: background, copy, repeat, mirror", h.extendWith);
|
|
1857
|
-
} else
|
|
1858
|
-
throw e.invalidParameterError("extend", "integer or object", h);
|
|
1859
|
-
return this;
|
|
1860
|
-
}
|
|
1861
|
-
function n(h) {
|
|
1862
|
-
const u = g(this.options) || this.options.widthPre !== -1 ? "Post" : "Pre";
|
|
1863
|
-
return this.options[`width${u}`] !== -1 && this.options.debuglog("ignoring previous extract options"), ["left", "top", "width", "height"].forEach(function(I) {
|
|
1864
|
-
const $ = h[I];
|
|
1865
|
-
if (e.integer($) && $ >= 0)
|
|
1866
|
-
this.options[I + (I === "left" || I === "top" ? "Offset" : "") + u] = $;
|
|
1867
|
-
else
|
|
1868
|
-
throw e.invalidParameterError(I, "integer", $);
|
|
1869
|
-
}, this), d(this.options) && !g(this.options) && (this.options.widthPre === -1 || this.options.widthPost === -1) && (this.options.rotateBefore = !0), this.options.input.autoOrient && (this.options.orientBefore = !0), this;
|
|
1870
|
-
}
|
|
1871
|
-
function k(h) {
|
|
1872
|
-
if (this.options.trimThreshold = 10, e.defined(h))
|
|
1873
|
-
if (e.object(h)) {
|
|
1874
|
-
if (e.defined(h.background) && this._setBackgroundColourOption("trimBackground", h.background), e.defined(h.threshold))
|
|
1875
|
-
if (e.number(h.threshold) && h.threshold >= 0)
|
|
1876
|
-
this.options.trimThreshold = h.threshold;
|
|
1877
|
-
else
|
|
1878
|
-
throw e.invalidParameterError("threshold", "positive number", h.threshold);
|
|
1879
|
-
e.defined(h.lineArt) && this._setBooleanOption("trimLineArt", h.lineArt);
|
|
1880
|
-
} else
|
|
1881
|
-
throw e.invalidParameterError("trim", "object", h);
|
|
1882
|
-
return d(this.options) && (this.options.rotateBefore = !0), this;
|
|
1883
|
-
}
|
|
1884
|
-
return Me = (h) => {
|
|
1885
|
-
Object.assign(h.prototype, {
|
|
1886
|
-
resize: c,
|
|
1887
|
-
extend: p,
|
|
1888
|
-
extract: n,
|
|
1889
|
-
trim: k
|
|
1890
|
-
}), h.gravity = i, h.strategy = b, h.kernel = S, h.fit = R, h.position = P;
|
|
1891
|
-
}, Me;
|
|
1892
|
-
}
|
|
1893
|
-
var De, Lr;
|
|
1894
|
-
function It() {
|
|
1895
|
-
if (Lr) return De;
|
|
1896
|
-
Lr = 1;
|
|
1897
|
-
const e = ee(), i = {
|
|
1898
|
-
clear: "clear",
|
|
1899
|
-
source: "source",
|
|
1900
|
-
over: "over",
|
|
1901
|
-
in: "in",
|
|
1902
|
-
out: "out",
|
|
1903
|
-
atop: "atop",
|
|
1904
|
-
dest: "dest",
|
|
1905
|
-
"dest-over": "dest-over",
|
|
1906
|
-
"dest-in": "dest-in",
|
|
1907
|
-
"dest-out": "dest-out",
|
|
1908
|
-
"dest-atop": "dest-atop",
|
|
1909
|
-
xor: "xor",
|
|
1910
|
-
add: "add",
|
|
1911
|
-
saturate: "saturate",
|
|
1912
|
-
multiply: "multiply",
|
|
1913
|
-
screen: "screen",
|
|
1914
|
-
overlay: "overlay",
|
|
1915
|
-
darken: "darken",
|
|
1916
|
-
lighten: "lighten",
|
|
1917
|
-
"colour-dodge": "colour-dodge",
|
|
1918
|
-
"color-dodge": "colour-dodge",
|
|
1919
|
-
"colour-burn": "colour-burn",
|
|
1920
|
-
"color-burn": "colour-burn",
|
|
1921
|
-
"hard-light": "hard-light",
|
|
1922
|
-
"soft-light": "soft-light",
|
|
1923
|
-
difference: "difference",
|
|
1924
|
-
exclusion: "exclusion"
|
|
1925
|
-
};
|
|
1926
|
-
function P(y) {
|
|
1927
|
-
if (!Array.isArray(y))
|
|
1928
|
-
throw e.invalidParameterError("images to composite", "array", y);
|
|
1929
|
-
return this.options.composite = y.map((b) => {
|
|
1930
|
-
if (!e.object(b))
|
|
1931
|
-
throw e.invalidParameterError("image to composite", "object", b);
|
|
1932
|
-
const S = this._inputOptionsFromObject(b), R = {
|
|
1933
|
-
input: this._createInputDescriptor(b.input, S, { allowStream: !1 }),
|
|
1934
|
-
blend: "over",
|
|
1935
|
-
tile: !1,
|
|
1936
|
-
left: 0,
|
|
1937
|
-
top: 0,
|
|
1938
|
-
hasOffset: !1,
|
|
1939
|
-
gravity: 0,
|
|
1940
|
-
premultiplied: !1
|
|
1941
|
-
};
|
|
1942
|
-
if (e.defined(b.blend))
|
|
1943
|
-
if (e.string(i[b.blend]))
|
|
1944
|
-
R.blend = i[b.blend];
|
|
1945
|
-
else
|
|
1946
|
-
throw e.invalidParameterError("blend", "valid blend name", b.blend);
|
|
1947
|
-
if (e.defined(b.tile))
|
|
1948
|
-
if (e.bool(b.tile))
|
|
1949
|
-
R.tile = b.tile;
|
|
1950
|
-
else
|
|
1951
|
-
throw e.invalidParameterError("tile", "boolean", b.tile);
|
|
1952
|
-
if (e.defined(b.left))
|
|
1953
|
-
if (e.integer(b.left))
|
|
1954
|
-
R.left = b.left;
|
|
1955
|
-
else
|
|
1956
|
-
throw e.invalidParameterError("left", "integer", b.left);
|
|
1957
|
-
if (e.defined(b.top))
|
|
1958
|
-
if (e.integer(b.top))
|
|
1959
|
-
R.top = b.top;
|
|
1960
|
-
else
|
|
1961
|
-
throw e.invalidParameterError("top", "integer", b.top);
|
|
1962
|
-
if (e.defined(b.top) !== e.defined(b.left))
|
|
1963
|
-
throw new Error("Expected both left and top to be set");
|
|
1964
|
-
if (R.hasOffset = e.integer(b.top) && e.integer(b.left), e.defined(b.gravity))
|
|
1965
|
-
if (e.integer(b.gravity) && e.inRange(b.gravity, 0, 8))
|
|
1966
|
-
R.gravity = b.gravity;
|
|
1967
|
-
else if (e.string(b.gravity) && e.integer(this.constructor.gravity[b.gravity]))
|
|
1968
|
-
R.gravity = this.constructor.gravity[b.gravity];
|
|
1969
|
-
else
|
|
1970
|
-
throw e.invalidParameterError("gravity", "valid gravity", b.gravity);
|
|
1971
|
-
if (e.defined(b.premultiplied))
|
|
1972
|
-
if (e.bool(b.premultiplied))
|
|
1973
|
-
R.premultiplied = b.premultiplied;
|
|
1974
|
-
else
|
|
1975
|
-
throw e.invalidParameterError("premultiplied", "boolean", b.premultiplied);
|
|
1976
|
-
return R;
|
|
1977
|
-
}), this;
|
|
1978
|
-
}
|
|
1979
|
-
return De = (y) => {
|
|
1980
|
-
y.prototype.composite = P, y.blend = i;
|
|
1981
|
-
}, De;
|
|
1982
|
-
}
|
|
1983
|
-
var Oe, Sr;
|
|
1984
|
-
function $t() {
|
|
1985
|
-
if (Sr) return Oe;
|
|
1986
|
-
Sr = 1;
|
|
1987
|
-
const e = ee(), i = {
|
|
1988
|
-
integer: "integer",
|
|
1989
|
-
float: "float",
|
|
1990
|
-
approximate: "approximate"
|
|
1991
|
-
};
|
|
1992
|
-
function P(f, N) {
|
|
1993
|
-
if (!e.defined(f))
|
|
1994
|
-
return this.autoOrient();
|
|
1995
|
-
if ((this.options.angle || this.options.rotationAngle) && (this.options.debuglog("ignoring previous rotate options"), this.options.angle = 0, this.options.rotationAngle = 0), e.integer(f) && !(f % 90))
|
|
1996
|
-
this.options.angle = f;
|
|
1997
|
-
else if (e.number(f))
|
|
1998
|
-
this.options.rotationAngle = f, e.object(N) && N.background && this._setBackgroundColourOption("rotationBackground", N.background);
|
|
1999
|
-
else
|
|
2000
|
-
throw e.invalidParameterError("angle", "numeric", f);
|
|
2001
|
-
return this;
|
|
2002
|
-
}
|
|
2003
|
-
function y() {
|
|
2004
|
-
return this.options.input.autoOrient = !0, this;
|
|
2005
|
-
}
|
|
2006
|
-
function b(f) {
|
|
2007
|
-
return this.options.flip = e.bool(f) ? f : !0, this;
|
|
2008
|
-
}
|
|
2009
|
-
function S(f) {
|
|
2010
|
-
return this.options.flop = e.bool(f) ? f : !0, this;
|
|
2011
|
-
}
|
|
2012
|
-
function R(f, N) {
|
|
2013
|
-
const G = [].concat(...f);
|
|
2014
|
-
if (G.length === 4 && G.every(e.number))
|
|
2015
|
-
this.options.affineMatrix = G;
|
|
2016
|
-
else
|
|
2017
|
-
throw e.invalidParameterError("matrix", "1x4 or 2x2 array", f);
|
|
2018
|
-
if (e.defined(N))
|
|
2019
|
-
if (e.object(N)) {
|
|
2020
|
-
if (this._setBackgroundColourOption("affineBackground", N.background), e.defined(N.idx))
|
|
2021
|
-
if (e.number(N.idx))
|
|
2022
|
-
this.options.affineIdx = N.idx;
|
|
2023
|
-
else
|
|
2024
|
-
throw e.invalidParameterError("options.idx", "number", N.idx);
|
|
2025
|
-
if (e.defined(N.idy))
|
|
2026
|
-
if (e.number(N.idy))
|
|
2027
|
-
this.options.affineIdy = N.idy;
|
|
2028
|
-
else
|
|
2029
|
-
throw e.invalidParameterError("options.idy", "number", N.idy);
|
|
2030
|
-
if (e.defined(N.odx))
|
|
2031
|
-
if (e.number(N.odx))
|
|
2032
|
-
this.options.affineOdx = N.odx;
|
|
2033
|
-
else
|
|
2034
|
-
throw e.invalidParameterError("options.odx", "number", N.odx);
|
|
2035
|
-
if (e.defined(N.ody))
|
|
2036
|
-
if (e.number(N.ody))
|
|
2037
|
-
this.options.affineOdy = N.ody;
|
|
2038
|
-
else
|
|
2039
|
-
throw e.invalidParameterError("options.ody", "number", N.ody);
|
|
2040
|
-
if (e.defined(N.interpolator))
|
|
2041
|
-
if (e.inArray(N.interpolator, Object.values(this.constructor.interpolators)))
|
|
2042
|
-
this.options.affineInterpolator = N.interpolator;
|
|
2043
|
-
else
|
|
2044
|
-
throw e.invalidParameterError("options.interpolator", "valid interpolator name", N.interpolator);
|
|
2045
|
-
} else
|
|
2046
|
-
throw e.invalidParameterError("options", "object", N);
|
|
2047
|
-
return this;
|
|
2048
|
-
}
|
|
2049
|
-
function w(f, N, G) {
|
|
2050
|
-
if (!e.defined(f))
|
|
2051
|
-
this.options.sharpenSigma = -1;
|
|
2052
|
-
else if (e.bool(f))
|
|
2053
|
-
this.options.sharpenSigma = f ? -1 : 0;
|
|
2054
|
-
else if (e.number(f) && e.inRange(f, 0.01, 1e4)) {
|
|
2055
|
-
if (this.options.sharpenSigma = f, e.defined(N))
|
|
2056
|
-
if (e.number(N) && e.inRange(N, 0, 1e4))
|
|
2057
|
-
this.options.sharpenM1 = N;
|
|
2058
|
-
else
|
|
2059
|
-
throw e.invalidParameterError("flat", "number between 0 and 10000", N);
|
|
2060
|
-
if (e.defined(G))
|
|
2061
|
-
if (e.number(G) && e.inRange(G, 0, 1e4))
|
|
2062
|
-
this.options.sharpenM2 = G;
|
|
2063
|
-
else
|
|
2064
|
-
throw e.invalidParameterError("jagged", "number between 0 and 10000", G);
|
|
2065
|
-
} else if (e.plainObject(f)) {
|
|
2066
|
-
if (e.number(f.sigma) && e.inRange(f.sigma, 1e-6, 10))
|
|
2067
|
-
this.options.sharpenSigma = f.sigma;
|
|
2068
|
-
else
|
|
2069
|
-
throw e.invalidParameterError("options.sigma", "number between 0.000001 and 10", f.sigma);
|
|
2070
|
-
if (e.defined(f.m1))
|
|
2071
|
-
if (e.number(f.m1) && e.inRange(f.m1, 0, 1e6))
|
|
2072
|
-
this.options.sharpenM1 = f.m1;
|
|
2073
|
-
else
|
|
2074
|
-
throw e.invalidParameterError("options.m1", "number between 0 and 1000000", f.m1);
|
|
2075
|
-
if (e.defined(f.m2))
|
|
2076
|
-
if (e.number(f.m2) && e.inRange(f.m2, 0, 1e6))
|
|
2077
|
-
this.options.sharpenM2 = f.m2;
|
|
2078
|
-
else
|
|
2079
|
-
throw e.invalidParameterError("options.m2", "number between 0 and 1000000", f.m2);
|
|
2080
|
-
if (e.defined(f.x1))
|
|
2081
|
-
if (e.number(f.x1) && e.inRange(f.x1, 0, 1e6))
|
|
2082
|
-
this.options.sharpenX1 = f.x1;
|
|
2083
|
-
else
|
|
2084
|
-
throw e.invalidParameterError("options.x1", "number between 0 and 1000000", f.x1);
|
|
2085
|
-
if (e.defined(f.y2))
|
|
2086
|
-
if (e.number(f.y2) && e.inRange(f.y2, 0, 1e6))
|
|
2087
|
-
this.options.sharpenY2 = f.y2;
|
|
2088
|
-
else
|
|
2089
|
-
throw e.invalidParameterError("options.y2", "number between 0 and 1000000", f.y2);
|
|
2090
|
-
if (e.defined(f.y3))
|
|
2091
|
-
if (e.number(f.y3) && e.inRange(f.y3, 0, 1e6))
|
|
2092
|
-
this.options.sharpenY3 = f.y3;
|
|
2093
|
-
else
|
|
2094
|
-
throw e.invalidParameterError("options.y3", "number between 0 and 1000000", f.y3);
|
|
2095
|
-
} else
|
|
2096
|
-
throw e.invalidParameterError("sigma", "number between 0.01 and 10000", f);
|
|
2097
|
-
return this;
|
|
2098
|
-
}
|
|
2099
|
-
function d(f) {
|
|
2100
|
-
if (!e.defined(f))
|
|
2101
|
-
this.options.medianSize = 3;
|
|
2102
|
-
else if (e.integer(f) && e.inRange(f, 1, 1e3))
|
|
2103
|
-
this.options.medianSize = f;
|
|
2104
|
-
else
|
|
2105
|
-
throw e.invalidParameterError("size", "integer between 1 and 1000", f);
|
|
2106
|
-
return this;
|
|
2107
|
-
}
|
|
2108
|
-
function g(f) {
|
|
2109
|
-
let N;
|
|
2110
|
-
if (e.number(f))
|
|
2111
|
-
N = f;
|
|
2112
|
-
else if (e.plainObject(f)) {
|
|
2113
|
-
if (!e.number(f.sigma))
|
|
2114
|
-
throw e.invalidParameterError("options.sigma", "number between 0.3 and 1000", N);
|
|
2115
|
-
if (N = f.sigma, "precision" in f)
|
|
2116
|
-
if (e.string(i[f.precision]))
|
|
2117
|
-
this.options.precision = i[f.precision];
|
|
2118
|
-
else
|
|
2119
|
-
throw e.invalidParameterError("precision", "one of: integer, float, approximate", f.precision);
|
|
2120
|
-
if ("minAmplitude" in f)
|
|
2121
|
-
if (e.number(f.minAmplitude) && e.inRange(f.minAmplitude, 1e-3, 1))
|
|
2122
|
-
this.options.minAmpl = f.minAmplitude;
|
|
2123
|
-
else
|
|
2124
|
-
throw e.invalidParameterError("minAmplitude", "number between 0.001 and 1", f.minAmplitude);
|
|
2125
|
-
}
|
|
2126
|
-
if (!e.defined(f))
|
|
2127
|
-
this.options.blurSigma = -1;
|
|
2128
|
-
else if (e.bool(f))
|
|
2129
|
-
this.options.blurSigma = f ? -1 : 0;
|
|
2130
|
-
else if (e.number(N) && e.inRange(N, 0.3, 1e3))
|
|
2131
|
-
this.options.blurSigma = N;
|
|
2132
|
-
else
|
|
2133
|
-
throw e.invalidParameterError("sigma", "number between 0.3 and 1000", N);
|
|
2134
|
-
return this;
|
|
2135
|
-
}
|
|
2136
|
-
function c(f) {
|
|
2137
|
-
if (!e.defined(f))
|
|
2138
|
-
this.options.dilateWidth = 1;
|
|
2139
|
-
else if (e.integer(f) && f > 0)
|
|
2140
|
-
this.options.dilateWidth = f;
|
|
2141
|
-
else
|
|
2142
|
-
throw e.invalidParameterError("dilate", "positive integer", c);
|
|
2143
|
-
return this;
|
|
2144
|
-
}
|
|
2145
|
-
function p(f) {
|
|
2146
|
-
if (!e.defined(f))
|
|
2147
|
-
this.options.erodeWidth = 1;
|
|
2148
|
-
else if (e.integer(f) && f > 0)
|
|
2149
|
-
this.options.erodeWidth = f;
|
|
2150
|
-
else
|
|
2151
|
-
throw e.invalidParameterError("erode", "positive integer", p);
|
|
2152
|
-
return this;
|
|
2153
|
-
}
|
|
2154
|
-
function n(f) {
|
|
2155
|
-
return this.options.flatten = e.bool(f) ? f : !0, e.object(f) && this._setBackgroundColourOption("flattenBackground", f.background), this;
|
|
2156
|
-
}
|
|
2157
|
-
function k() {
|
|
2158
|
-
return this.options.unflatten = !0, this;
|
|
2159
|
-
}
|
|
2160
|
-
function h(f, N) {
|
|
2161
|
-
if (!e.defined(f))
|
|
2162
|
-
this.options.gamma = 2.2;
|
|
2163
|
-
else if (e.number(f) && e.inRange(f, 1, 3))
|
|
2164
|
-
this.options.gamma = f;
|
|
2165
|
-
else
|
|
2166
|
-
throw e.invalidParameterError("gamma", "number between 1.0 and 3.0", f);
|
|
2167
|
-
if (!e.defined(N))
|
|
2168
|
-
this.options.gammaOut = this.options.gamma;
|
|
2169
|
-
else if (e.number(N) && e.inRange(N, 1, 3))
|
|
2170
|
-
this.options.gammaOut = N;
|
|
2171
|
-
else
|
|
2172
|
-
throw e.invalidParameterError("gammaOut", "number between 1.0 and 3.0", N);
|
|
2173
|
-
return this;
|
|
2174
|
-
}
|
|
2175
|
-
function u(f) {
|
|
2176
|
-
if (this.options.negate = e.bool(f) ? f : !0, e.plainObject(f) && "alpha" in f)
|
|
2177
|
-
if (e.bool(f.alpha))
|
|
2178
|
-
this.options.negateAlpha = f.alpha;
|
|
2179
|
-
else
|
|
2180
|
-
throw e.invalidParameterError("alpha", "should be boolean value", f.alpha);
|
|
2181
|
-
return this;
|
|
2182
|
-
}
|
|
2183
|
-
function I(f) {
|
|
2184
|
-
if (e.plainObject(f)) {
|
|
2185
|
-
if (e.defined(f.lower))
|
|
2186
|
-
if (e.number(f.lower) && e.inRange(f.lower, 0, 99))
|
|
2187
|
-
this.options.normaliseLower = f.lower;
|
|
2188
|
-
else
|
|
2189
|
-
throw e.invalidParameterError("lower", "number between 0 and 99", f.lower);
|
|
2190
|
-
if (e.defined(f.upper))
|
|
2191
|
-
if (e.number(f.upper) && e.inRange(f.upper, 1, 100))
|
|
2192
|
-
this.options.normaliseUpper = f.upper;
|
|
2193
|
-
else
|
|
2194
|
-
throw e.invalidParameterError("upper", "number between 1 and 100", f.upper);
|
|
2195
|
-
}
|
|
2196
|
-
if (this.options.normaliseLower >= this.options.normaliseUpper)
|
|
2197
|
-
throw e.invalidParameterError(
|
|
2198
|
-
"range",
|
|
2199
|
-
"lower to be less than upper",
|
|
2200
|
-
`${this.options.normaliseLower} >= ${this.options.normaliseUpper}`
|
|
2201
|
-
);
|
|
2202
|
-
return this.options.normalise = !0, this;
|
|
2203
|
-
}
|
|
2204
|
-
function $(f) {
|
|
2205
|
-
return this.normalise(f);
|
|
2206
|
-
}
|
|
2207
|
-
function z(f) {
|
|
2208
|
-
if (e.plainObject(f)) {
|
|
2209
|
-
if (e.integer(f.width) && f.width > 0)
|
|
2210
|
-
this.options.claheWidth = f.width;
|
|
2211
|
-
else
|
|
2212
|
-
throw e.invalidParameterError("width", "integer greater than zero", f.width);
|
|
2213
|
-
if (e.integer(f.height) && f.height > 0)
|
|
2214
|
-
this.options.claheHeight = f.height;
|
|
2215
|
-
else
|
|
2216
|
-
throw e.invalidParameterError("height", "integer greater than zero", f.height);
|
|
2217
|
-
if (e.defined(f.maxSlope))
|
|
2218
|
-
if (e.integer(f.maxSlope) && e.inRange(f.maxSlope, 0, 100))
|
|
2219
|
-
this.options.claheMaxSlope = f.maxSlope;
|
|
2220
|
-
else
|
|
2221
|
-
throw e.invalidParameterError("maxSlope", "integer between 0 and 100", f.maxSlope);
|
|
2222
|
-
} else
|
|
2223
|
-
throw e.invalidParameterError("options", "plain object", f);
|
|
2224
|
-
return this;
|
|
2225
|
-
}
|
|
2226
|
-
function O(f) {
|
|
2227
|
-
if (!e.object(f) || !Array.isArray(f.kernel) || !e.integer(f.width) || !e.integer(f.height) || !e.inRange(f.width, 3, 1001) || !e.inRange(f.height, 3, 1001) || f.height * f.width !== f.kernel.length)
|
|
2228
|
-
throw new Error("Invalid convolution kernel");
|
|
2229
|
-
return e.integer(f.scale) || (f.scale = f.kernel.reduce((N, G) => N + G, 0)), f.scale < 1 && (f.scale = 1), e.integer(f.offset) || (f.offset = 0), this.options.convKernel = f, this;
|
|
2230
|
-
}
|
|
2231
|
-
function H(f, N) {
|
|
2232
|
-
if (!e.defined(f))
|
|
2233
|
-
this.options.threshold = 128;
|
|
2234
|
-
else if (e.bool(f))
|
|
2235
|
-
this.options.threshold = f ? 128 : 0;
|
|
2236
|
-
else if (e.integer(f) && e.inRange(f, 0, 255))
|
|
2237
|
-
this.options.threshold = f;
|
|
2238
|
-
else
|
|
2239
|
-
throw e.invalidParameterError("threshold", "integer between 0 and 255", f);
|
|
2240
|
-
return !e.object(N) || N.greyscale === !0 || N.grayscale === !0 ? this.options.thresholdGrayscale = !0 : this.options.thresholdGrayscale = !1, this;
|
|
2241
|
-
}
|
|
2242
|
-
function W(f, N, G) {
|
|
2243
|
-
if (this.options.boolean = this._createInputDescriptor(f, G), e.string(N) && e.inArray(N, ["and", "or", "eor"]))
|
|
2244
|
-
this.options.booleanOp = N;
|
|
2245
|
-
else
|
|
2246
|
-
throw e.invalidParameterError("operator", "one of: and, or, eor", N);
|
|
2247
|
-
return this;
|
|
2248
|
-
}
|
|
2249
|
-
function Q(f, N) {
|
|
2250
|
-
if (!e.defined(f) && e.number(N) ? f = 1 : e.number(f) && !e.defined(N) && (N = 0), !e.defined(f))
|
|
2251
|
-
this.options.linearA = [];
|
|
2252
|
-
else if (e.number(f))
|
|
2253
|
-
this.options.linearA = [f];
|
|
2254
|
-
else if (Array.isArray(f) && f.length && f.every(e.number))
|
|
2255
|
-
this.options.linearA = f;
|
|
2256
|
-
else
|
|
2257
|
-
throw e.invalidParameterError("a", "number or array of numbers", f);
|
|
2258
|
-
if (!e.defined(N))
|
|
2259
|
-
this.options.linearB = [];
|
|
2260
|
-
else if (e.number(N))
|
|
2261
|
-
this.options.linearB = [N];
|
|
2262
|
-
else if (Array.isArray(N) && N.length && N.every(e.number))
|
|
2263
|
-
this.options.linearB = N;
|
|
2264
|
-
else
|
|
2265
|
-
throw e.invalidParameterError("b", "number or array of numbers", N);
|
|
2266
|
-
if (this.options.linearA.length !== this.options.linearB.length)
|
|
2267
|
-
throw new Error("Expected a and b to be arrays of the same length");
|
|
2268
|
-
return this;
|
|
2269
|
-
}
|
|
2270
|
-
function Y(f) {
|
|
2271
|
-
if (!Array.isArray(f))
|
|
2272
|
-
throw e.invalidParameterError("inputMatrix", "array", f);
|
|
2273
|
-
if (f.length !== 3 && f.length !== 4)
|
|
2274
|
-
throw e.invalidParameterError("inputMatrix", "3x3 or 4x4 array", f.length);
|
|
2275
|
-
const N = f.flat().map(Number);
|
|
2276
|
-
if (N.length !== 9 && N.length !== 16)
|
|
2277
|
-
throw e.invalidParameterError("inputMatrix", "cardinality of 9 or 16", N.length);
|
|
2278
|
-
return this.options.recombMatrix = N, this;
|
|
2279
|
-
}
|
|
2280
|
-
function V(f) {
|
|
2281
|
-
if (!e.plainObject(f))
|
|
2282
|
-
throw e.invalidParameterError("options", "plain object", f);
|
|
2283
|
-
if ("brightness" in f)
|
|
2284
|
-
if (e.number(f.brightness) && f.brightness >= 0)
|
|
2285
|
-
this.options.brightness = f.brightness;
|
|
2286
|
-
else
|
|
2287
|
-
throw e.invalidParameterError("brightness", "number above zero", f.brightness);
|
|
2288
|
-
if ("saturation" in f)
|
|
2289
|
-
if (e.number(f.saturation) && f.saturation >= 0)
|
|
2290
|
-
this.options.saturation = f.saturation;
|
|
2291
|
-
else
|
|
2292
|
-
throw e.invalidParameterError("saturation", "number above zero", f.saturation);
|
|
2293
|
-
if ("hue" in f)
|
|
2294
|
-
if (e.integer(f.hue))
|
|
2295
|
-
this.options.hue = f.hue % 360;
|
|
2296
|
-
else
|
|
2297
|
-
throw e.invalidParameterError("hue", "number", f.hue);
|
|
2298
|
-
if ("lightness" in f)
|
|
2299
|
-
if (e.number(f.lightness))
|
|
2300
|
-
this.options.lightness = f.lightness;
|
|
2301
|
-
else
|
|
2302
|
-
throw e.invalidParameterError("lightness", "number", f.lightness);
|
|
2303
|
-
return this;
|
|
2304
|
-
}
|
|
2305
|
-
return Oe = (f) => {
|
|
2306
|
-
Object.assign(f.prototype, {
|
|
2307
|
-
autoOrient: y,
|
|
2308
|
-
rotate: P,
|
|
2309
|
-
flip: b,
|
|
2310
|
-
flop: S,
|
|
2311
|
-
affine: R,
|
|
2312
|
-
sharpen: w,
|
|
2313
|
-
erode: p,
|
|
2314
|
-
dilate: c,
|
|
2315
|
-
median: d,
|
|
2316
|
-
blur: g,
|
|
2317
|
-
flatten: n,
|
|
2318
|
-
unflatten: k,
|
|
2319
|
-
gamma: h,
|
|
2320
|
-
negate: u,
|
|
2321
|
-
normalise: I,
|
|
2322
|
-
normalize: $,
|
|
2323
|
-
clahe: z,
|
|
2324
|
-
convolve: O,
|
|
2325
|
-
threshold: H,
|
|
2326
|
-
boolean: W,
|
|
2327
|
-
linear: Q,
|
|
2328
|
-
recomb: Y,
|
|
2329
|
-
modulate: V
|
|
2330
|
-
});
|
|
2331
|
-
}, Oe;
|
|
2332
|
-
}
|
|
2333
|
-
var Ue, kr;
|
|
2334
|
-
function jt() {
|
|
2335
|
-
if (kr) return Ue;
|
|
2336
|
-
kr = 1;
|
|
2337
|
-
var e = Object.defineProperty, i = Object.getOwnPropertyDescriptor, P = Object.getOwnPropertyNames, y = Object.prototype.hasOwnProperty, b = (t, a) => {
|
|
2338
|
-
for (var s in a)
|
|
2339
|
-
e(t, s, { get: a[s], enumerable: !0 });
|
|
2340
|
-
}, S = (t, a, s, o) => {
|
|
2341
|
-
if (a && typeof a == "object" || typeof a == "function")
|
|
2342
|
-
for (let l of P(a))
|
|
2343
|
-
!y.call(t, l) && l !== s && e(t, l, { get: () => a[l], enumerable: !(o = i(a, l)) || o.enumerable });
|
|
2344
|
-
return t;
|
|
2345
|
-
}, R = (t) => S(e({}, "__esModule", { value: !0 }), t), w = {};
|
|
2346
|
-
b(w, {
|
|
2347
|
-
default: () => J
|
|
2348
|
-
}), Ue = R(w);
|
|
2349
|
-
var d = {
|
|
2350
|
-
aliceblue: [240, 248, 255],
|
|
2351
|
-
antiquewhite: [250, 235, 215],
|
|
2352
|
-
aqua: [0, 255, 255],
|
|
2353
|
-
aquamarine: [127, 255, 212],
|
|
2354
|
-
azure: [240, 255, 255],
|
|
2355
|
-
beige: [245, 245, 220],
|
|
2356
|
-
bisque: [255, 228, 196],
|
|
2357
|
-
black: [0, 0, 0],
|
|
2358
|
-
blanchedalmond: [255, 235, 205],
|
|
2359
|
-
blue: [0, 0, 255],
|
|
2360
|
-
blueviolet: [138, 43, 226],
|
|
2361
|
-
brown: [165, 42, 42],
|
|
2362
|
-
burlywood: [222, 184, 135],
|
|
2363
|
-
cadetblue: [95, 158, 160],
|
|
2364
|
-
chartreuse: [127, 255, 0],
|
|
2365
|
-
chocolate: [210, 105, 30],
|
|
2366
|
-
coral: [255, 127, 80],
|
|
2367
|
-
cornflowerblue: [100, 149, 237],
|
|
2368
|
-
cornsilk: [255, 248, 220],
|
|
2369
|
-
crimson: [220, 20, 60],
|
|
2370
|
-
cyan: [0, 255, 255],
|
|
2371
|
-
darkblue: [0, 0, 139],
|
|
2372
|
-
darkcyan: [0, 139, 139],
|
|
2373
|
-
darkgoldenrod: [184, 134, 11],
|
|
2374
|
-
darkgray: [169, 169, 169],
|
|
2375
|
-
darkgreen: [0, 100, 0],
|
|
2376
|
-
darkgrey: [169, 169, 169],
|
|
2377
|
-
darkkhaki: [189, 183, 107],
|
|
2378
|
-
darkmagenta: [139, 0, 139],
|
|
2379
|
-
darkolivegreen: [85, 107, 47],
|
|
2380
|
-
darkorange: [255, 140, 0],
|
|
2381
|
-
darkorchid: [153, 50, 204],
|
|
2382
|
-
darkred: [139, 0, 0],
|
|
2383
|
-
darksalmon: [233, 150, 122],
|
|
2384
|
-
darkseagreen: [143, 188, 143],
|
|
2385
|
-
darkslateblue: [72, 61, 139],
|
|
2386
|
-
darkslategray: [47, 79, 79],
|
|
2387
|
-
darkslategrey: [47, 79, 79],
|
|
2388
|
-
darkturquoise: [0, 206, 209],
|
|
2389
|
-
darkviolet: [148, 0, 211],
|
|
2390
|
-
deeppink: [255, 20, 147],
|
|
2391
|
-
deepskyblue: [0, 191, 255],
|
|
2392
|
-
dimgray: [105, 105, 105],
|
|
2393
|
-
dimgrey: [105, 105, 105],
|
|
2394
|
-
dodgerblue: [30, 144, 255],
|
|
2395
|
-
firebrick: [178, 34, 34],
|
|
2396
|
-
floralwhite: [255, 250, 240],
|
|
2397
|
-
forestgreen: [34, 139, 34],
|
|
2398
|
-
fuchsia: [255, 0, 255],
|
|
2399
|
-
gainsboro: [220, 220, 220],
|
|
2400
|
-
ghostwhite: [248, 248, 255],
|
|
2401
|
-
gold: [255, 215, 0],
|
|
2402
|
-
goldenrod: [218, 165, 32],
|
|
2403
|
-
gray: [128, 128, 128],
|
|
2404
|
-
green: [0, 128, 0],
|
|
2405
|
-
greenyellow: [173, 255, 47],
|
|
2406
|
-
grey: [128, 128, 128],
|
|
2407
|
-
honeydew: [240, 255, 240],
|
|
2408
|
-
hotpink: [255, 105, 180],
|
|
2409
|
-
indianred: [205, 92, 92],
|
|
2410
|
-
indigo: [75, 0, 130],
|
|
2411
|
-
ivory: [255, 255, 240],
|
|
2412
|
-
khaki: [240, 230, 140],
|
|
2413
|
-
lavender: [230, 230, 250],
|
|
2414
|
-
lavenderblush: [255, 240, 245],
|
|
2415
|
-
lawngreen: [124, 252, 0],
|
|
2416
|
-
lemonchiffon: [255, 250, 205],
|
|
2417
|
-
lightblue: [173, 216, 230],
|
|
2418
|
-
lightcoral: [240, 128, 128],
|
|
2419
|
-
lightcyan: [224, 255, 255],
|
|
2420
|
-
lightgoldenrodyellow: [250, 250, 210],
|
|
2421
|
-
lightgray: [211, 211, 211],
|
|
2422
|
-
lightgreen: [144, 238, 144],
|
|
2423
|
-
lightgrey: [211, 211, 211],
|
|
2424
|
-
lightpink: [255, 182, 193],
|
|
2425
|
-
lightsalmon: [255, 160, 122],
|
|
2426
|
-
lightseagreen: [32, 178, 170],
|
|
2427
|
-
lightskyblue: [135, 206, 250],
|
|
2428
|
-
lightslategray: [119, 136, 153],
|
|
2429
|
-
lightslategrey: [119, 136, 153],
|
|
2430
|
-
lightsteelblue: [176, 196, 222],
|
|
2431
|
-
lightyellow: [255, 255, 224],
|
|
2432
|
-
lime: [0, 255, 0],
|
|
2433
|
-
limegreen: [50, 205, 50],
|
|
2434
|
-
linen: [250, 240, 230],
|
|
2435
|
-
magenta: [255, 0, 255],
|
|
2436
|
-
maroon: [128, 0, 0],
|
|
2437
|
-
mediumaquamarine: [102, 205, 170],
|
|
2438
|
-
mediumblue: [0, 0, 205],
|
|
2439
|
-
mediumorchid: [186, 85, 211],
|
|
2440
|
-
mediumpurple: [147, 112, 219],
|
|
2441
|
-
mediumseagreen: [60, 179, 113],
|
|
2442
|
-
mediumslateblue: [123, 104, 238],
|
|
2443
|
-
mediumspringgreen: [0, 250, 154],
|
|
2444
|
-
mediumturquoise: [72, 209, 204],
|
|
2445
|
-
mediumvioletred: [199, 21, 133],
|
|
2446
|
-
midnightblue: [25, 25, 112],
|
|
2447
|
-
mintcream: [245, 255, 250],
|
|
2448
|
-
mistyrose: [255, 228, 225],
|
|
2449
|
-
moccasin: [255, 228, 181],
|
|
2450
|
-
navajowhite: [255, 222, 173],
|
|
2451
|
-
navy: [0, 0, 128],
|
|
2452
|
-
oldlace: [253, 245, 230],
|
|
2453
|
-
olive: [128, 128, 0],
|
|
2454
|
-
olivedrab: [107, 142, 35],
|
|
2455
|
-
orange: [255, 165, 0],
|
|
2456
|
-
orangered: [255, 69, 0],
|
|
2457
|
-
orchid: [218, 112, 214],
|
|
2458
|
-
palegoldenrod: [238, 232, 170],
|
|
2459
|
-
palegreen: [152, 251, 152],
|
|
2460
|
-
paleturquoise: [175, 238, 238],
|
|
2461
|
-
palevioletred: [219, 112, 147],
|
|
2462
|
-
papayawhip: [255, 239, 213],
|
|
2463
|
-
peachpuff: [255, 218, 185],
|
|
2464
|
-
peru: [205, 133, 63],
|
|
2465
|
-
pink: [255, 192, 203],
|
|
2466
|
-
plum: [221, 160, 221],
|
|
2467
|
-
powderblue: [176, 224, 230],
|
|
2468
|
-
purple: [128, 0, 128],
|
|
2469
|
-
rebeccapurple: [102, 51, 153],
|
|
2470
|
-
red: [255, 0, 0],
|
|
2471
|
-
rosybrown: [188, 143, 143],
|
|
2472
|
-
royalblue: [65, 105, 225],
|
|
2473
|
-
saddlebrown: [139, 69, 19],
|
|
2474
|
-
salmon: [250, 128, 114],
|
|
2475
|
-
sandybrown: [244, 164, 96],
|
|
2476
|
-
seagreen: [46, 139, 87],
|
|
2477
|
-
seashell: [255, 245, 238],
|
|
2478
|
-
sienna: [160, 82, 45],
|
|
2479
|
-
silver: [192, 192, 192],
|
|
2480
|
-
skyblue: [135, 206, 235],
|
|
2481
|
-
slateblue: [106, 90, 205],
|
|
2482
|
-
slategray: [112, 128, 144],
|
|
2483
|
-
slategrey: [112, 128, 144],
|
|
2484
|
-
snow: [255, 250, 250],
|
|
2485
|
-
springgreen: [0, 255, 127],
|
|
2486
|
-
steelblue: [70, 130, 180],
|
|
2487
|
-
tan: [210, 180, 140],
|
|
2488
|
-
teal: [0, 128, 128],
|
|
2489
|
-
thistle: [216, 191, 216],
|
|
2490
|
-
tomato: [255, 99, 71],
|
|
2491
|
-
turquoise: [64, 224, 208],
|
|
2492
|
-
violet: [238, 130, 238],
|
|
2493
|
-
wheat: [245, 222, 179],
|
|
2494
|
-
white: [255, 255, 255],
|
|
2495
|
-
whitesmoke: [245, 245, 245],
|
|
2496
|
-
yellow: [255, 255, 0],
|
|
2497
|
-
yellowgreen: [154, 205, 50]
|
|
2498
|
-
}, g = /* @__PURE__ */ Object.create(null);
|
|
2499
|
-
for (const t in d)
|
|
2500
|
-
Object.hasOwn(d, t) && (g[d[t]] = t);
|
|
2501
|
-
var c = {
|
|
2502
|
-
to: {},
|
|
2503
|
-
get: {}
|
|
2504
|
-
};
|
|
2505
|
-
c.get = function(t) {
|
|
2506
|
-
const a = t.slice(0, 3).toLowerCase();
|
|
2507
|
-
let s, o;
|
|
2508
|
-
switch (a) {
|
|
2509
|
-
case "hsl": {
|
|
2510
|
-
s = c.get.hsl(t), o = "hsl";
|
|
2511
|
-
break;
|
|
2512
|
-
}
|
|
2513
|
-
case "hwb": {
|
|
2514
|
-
s = c.get.hwb(t), o = "hwb";
|
|
2515
|
-
break;
|
|
2516
|
-
}
|
|
2517
|
-
default: {
|
|
2518
|
-
s = c.get.rgb(t), o = "rgb";
|
|
2519
|
-
break;
|
|
2520
|
-
}
|
|
2521
|
-
}
|
|
2522
|
-
return s ? { model: o, value: s } : null;
|
|
2523
|
-
}, c.get.rgb = function(t) {
|
|
2524
|
-
if (!t)
|
|
2525
|
-
return null;
|
|
2526
|
-
const a = /^#([a-f\d]{3,4})$/i, s = /^#([a-f\d]{6})([a-f\d]{2})?$/i, o = /^rgba?\(\s*([+-]?\d+)(?=[\s,])\s*(?:,\s*)?([+-]?\d+)(?=[\s,])\s*(?:,\s*)?([+-]?\d+)\s*(?:[\s,|/]\s*([+-]?[\d.]+)(%?)\s*)?\)$/, l = /^rgba?\(\s*([+-]?[\d.]+)%\s*,?\s*([+-]?[\d.]+)%\s*,?\s*([+-]?[\d.]+)%\s*(?:[\s,|/]\s*([+-]?[\d.]+)(%?)\s*)?\)$/, E = /^(\w+)$/;
|
|
2527
|
-
let v = [0, 0, 0, 1], x, q, D;
|
|
2528
|
-
if (x = t.match(s)) {
|
|
2529
|
-
for (D = x[2], x = x[1], q = 0; q < 3; q++) {
|
|
2530
|
-
const X = q * 2;
|
|
2531
|
-
v[q] = Number.parseInt(x.slice(X, X + 2), 16);
|
|
2532
|
-
}
|
|
2533
|
-
D && (v[3] = Number.parseInt(D, 16) / 255);
|
|
2534
|
-
} else if (x = t.match(a)) {
|
|
2535
|
-
for (x = x[1], D = x[3], q = 0; q < 3; q++)
|
|
2536
|
-
v[q] = Number.parseInt(x[q] + x[q], 16);
|
|
2537
|
-
D && (v[3] = Number.parseInt(D + D, 16) / 255);
|
|
2538
|
-
} else if (x = t.match(o)) {
|
|
2539
|
-
for (q = 0; q < 3; q++)
|
|
2540
|
-
v[q] = Number.parseInt(x[q + 1], 10);
|
|
2541
|
-
x[4] && (v[3] = x[5] ? Number.parseFloat(x[4]) * 0.01 : Number.parseFloat(x[4]));
|
|
2542
|
-
} else if (x = t.match(l)) {
|
|
2543
|
-
for (q = 0; q < 3; q++)
|
|
2544
|
-
v[q] = Math.round(Number.parseFloat(x[q + 1]) * 2.55);
|
|
2545
|
-
x[4] && (v[3] = x[5] ? Number.parseFloat(x[4]) * 0.01 : Number.parseFloat(x[4]));
|
|
2546
|
-
} else return (x = t.match(E)) ? x[1] === "transparent" ? [0, 0, 0, 0] : Object.hasOwn(d, x[1]) ? (v = d[x[1]], v[3] = 1, v) : null : null;
|
|
2547
|
-
for (q = 0; q < 3; q++)
|
|
2548
|
-
v[q] = p(v[q], 0, 255);
|
|
2549
|
-
return v[3] = p(v[3], 0, 1), v;
|
|
2550
|
-
}, c.get.hsl = function(t) {
|
|
2551
|
-
if (!t)
|
|
2552
|
-
return null;
|
|
2553
|
-
const a = /^hsla?\(\s*([+-]?(?:\d{0,3}\.)?\d+)(?:deg)?\s*,?\s*([+-]?[\d.]+)%\s*,?\s*([+-]?[\d.]+)%\s*(?:[,|/]\s*([+-]?(?=\.\d|\d)(?:0|[1-9]\d*)?(?:\.\d*)?(?:[eE][+-]?\d+)?)\s*)?\)$/, s = t.match(a);
|
|
2554
|
-
if (s) {
|
|
2555
|
-
const o = Number.parseFloat(s[4]), l = (Number.parseFloat(s[1]) % 360 + 360) % 360, E = p(Number.parseFloat(s[2]), 0, 100), v = p(Number.parseFloat(s[3]), 0, 100), x = p(Number.isNaN(o) ? 1 : o, 0, 1);
|
|
2556
|
-
return [l, E, v, x];
|
|
2557
|
-
}
|
|
2558
|
-
return null;
|
|
2559
|
-
}, c.get.hwb = function(t) {
|
|
2560
|
-
if (!t)
|
|
2561
|
-
return null;
|
|
2562
|
-
const a = /^hwb\(\s*([+-]?\d{0,3}(?:\.\d+)?)(?:deg)?\s*[\s,]\s*([+-]?[\d.]+)%\s*[\s,]\s*([+-]?[\d.]+)%\s*(?:[\s,]\s*([+-]?(?=\.\d|\d)(?:0|[1-9]\d*)?(?:\.\d*)?(?:[eE][+-]?\d+)?)\s*)?\)$/, s = t.match(a);
|
|
2563
|
-
if (s) {
|
|
2564
|
-
const o = Number.parseFloat(s[4]), l = (Number.parseFloat(s[1]) % 360 + 360) % 360, E = p(Number.parseFloat(s[2]), 0, 100), v = p(Number.parseFloat(s[3]), 0, 100), x = p(Number.isNaN(o) ? 1 : o, 0, 1);
|
|
2565
|
-
return [l, E, v, x];
|
|
2566
|
-
}
|
|
2567
|
-
return null;
|
|
2568
|
-
}, c.to.hex = function(...t) {
|
|
2569
|
-
return "#" + n(t[0]) + n(t[1]) + n(t[2]) + (t[3] < 1 ? n(Math.round(t[3] * 255)) : "");
|
|
2570
|
-
}, c.to.rgb = function(...t) {
|
|
2571
|
-
return t.length < 4 || t[3] === 1 ? "rgb(" + Math.round(t[0]) + ", " + Math.round(t[1]) + ", " + Math.round(t[2]) + ")" : "rgba(" + Math.round(t[0]) + ", " + Math.round(t[1]) + ", " + Math.round(t[2]) + ", " + t[3] + ")";
|
|
2572
|
-
}, c.to.rgb.percent = function(...t) {
|
|
2573
|
-
const a = Math.round(t[0] / 255 * 100), s = Math.round(t[1] / 255 * 100), o = Math.round(t[2] / 255 * 100);
|
|
2574
|
-
return t.length < 4 || t[3] === 1 ? "rgb(" + a + "%, " + s + "%, " + o + "%)" : "rgba(" + a + "%, " + s + "%, " + o + "%, " + t[3] + ")";
|
|
2575
|
-
}, c.to.hsl = function(...t) {
|
|
2576
|
-
return t.length < 4 || t[3] === 1 ? "hsl(" + t[0] + ", " + t[1] + "%, " + t[2] + "%)" : "hsla(" + t[0] + ", " + t[1] + "%, " + t[2] + "%, " + t[3] + ")";
|
|
2577
|
-
}, c.to.hwb = function(...t) {
|
|
2578
|
-
let a = "";
|
|
2579
|
-
return t.length >= 4 && t[3] !== 1 && (a = ", " + t[3]), "hwb(" + t[0] + ", " + t[1] + "%, " + t[2] + "%" + a + ")";
|
|
2580
|
-
}, c.to.keyword = function(...t) {
|
|
2581
|
-
return g[t.slice(0, 3)];
|
|
2582
|
-
};
|
|
2583
|
-
function p(t, a, s) {
|
|
2584
|
-
return Math.min(Math.max(a, t), s);
|
|
2585
|
-
}
|
|
2586
|
-
function n(t) {
|
|
2587
|
-
const a = Math.round(t).toString(16).toUpperCase();
|
|
2588
|
-
return a.length < 2 ? "0" + a : a;
|
|
2589
|
-
}
|
|
2590
|
-
var k = c, h = {};
|
|
2591
|
-
for (const t of Object.keys(d))
|
|
2592
|
-
h[d[t]] = t;
|
|
2593
|
-
var u = {
|
|
2594
|
-
rgb: { channels: 3, labels: "rgb" },
|
|
2595
|
-
hsl: { channels: 3, labels: "hsl" },
|
|
2596
|
-
hsv: { channels: 3, labels: "hsv" },
|
|
2597
|
-
hwb: { channels: 3, labels: "hwb" },
|
|
2598
|
-
cmyk: { channels: 4, labels: "cmyk" },
|
|
2599
|
-
xyz: { channels: 3, labels: "xyz" },
|
|
2600
|
-
lab: { channels: 3, labels: "lab" },
|
|
2601
|
-
oklab: { channels: 3, labels: ["okl", "oka", "okb"] },
|
|
2602
|
-
lch: { channels: 3, labels: "lch" },
|
|
2603
|
-
oklch: { channels: 3, labels: ["okl", "okc", "okh"] },
|
|
2604
|
-
hex: { channels: 1, labels: ["hex"] },
|
|
2605
|
-
keyword: { channels: 1, labels: ["keyword"] },
|
|
2606
|
-
ansi16: { channels: 1, labels: ["ansi16"] },
|
|
2607
|
-
ansi256: { channels: 1, labels: ["ansi256"] },
|
|
2608
|
-
hcg: { channels: 3, labels: ["h", "c", "g"] },
|
|
2609
|
-
apple: { channels: 3, labels: ["r16", "g16", "b16"] },
|
|
2610
|
-
gray: { channels: 1, labels: ["gray"] }
|
|
2611
|
-
}, I = u, $ = (6 / 29) ** 3;
|
|
2612
|
-
function z(t) {
|
|
2613
|
-
const a = t > 31308e-7 ? 1.055 * t ** 0.4166666666666667 - 0.055 : t * 12.92;
|
|
2614
|
-
return Math.min(Math.max(0, a), 1);
|
|
2615
|
-
}
|
|
2616
|
-
function O(t) {
|
|
2617
|
-
return t > 0.04045 ? ((t + 0.055) / 1.055) ** 2.4 : t / 12.92;
|
|
2618
|
-
}
|
|
2619
|
-
for (const t of Object.keys(u)) {
|
|
2620
|
-
if (!("channels" in u[t]))
|
|
2621
|
-
throw new Error("missing channels property: " + t);
|
|
2622
|
-
if (!("labels" in u[t]))
|
|
2623
|
-
throw new Error("missing channel labels property: " + t);
|
|
2624
|
-
if (u[t].labels.length !== u[t].channels)
|
|
2625
|
-
throw new Error("channel and label counts mismatch: " + t);
|
|
2626
|
-
const { channels: a, labels: s } = u[t];
|
|
2627
|
-
delete u[t].channels, delete u[t].labels, Object.defineProperty(u[t], "channels", { value: a }), Object.defineProperty(u[t], "labels", { value: s });
|
|
2628
|
-
}
|
|
2629
|
-
u.rgb.hsl = function(t) {
|
|
2630
|
-
const a = t[0] / 255, s = t[1] / 255, o = t[2] / 255, l = Math.min(a, s, o), E = Math.max(a, s, o), v = E - l;
|
|
2631
|
-
let x, q;
|
|
2632
|
-
switch (E) {
|
|
2633
|
-
case l: {
|
|
2634
|
-
x = 0;
|
|
2635
|
-
break;
|
|
2636
|
-
}
|
|
2637
|
-
case a: {
|
|
2638
|
-
x = (s - o) / v;
|
|
2639
|
-
break;
|
|
2640
|
-
}
|
|
2641
|
-
case s: {
|
|
2642
|
-
x = 2 + (o - a) / v;
|
|
2643
|
-
break;
|
|
2644
|
-
}
|
|
2645
|
-
case o: {
|
|
2646
|
-
x = 4 + (a - s) / v;
|
|
2647
|
-
break;
|
|
2648
|
-
}
|
|
2649
|
-
}
|
|
2650
|
-
x = Math.min(x * 60, 360), x < 0 && (x += 360);
|
|
2651
|
-
const D = (l + E) / 2;
|
|
2652
|
-
return E === l ? q = 0 : D <= 0.5 ? q = v / (E + l) : q = v / (2 - E - l), [x, q * 100, D * 100];
|
|
2653
|
-
}, u.rgb.hsv = function(t) {
|
|
2654
|
-
let a, s, o, l, E;
|
|
2655
|
-
const v = t[0] / 255, x = t[1] / 255, q = t[2] / 255, D = Math.max(v, x, q), X = D - Math.min(v, x, q), Z = function(zr) {
|
|
2656
|
-
return (D - zr) / 6 / X + 1 / 2;
|
|
2657
|
-
};
|
|
2658
|
-
if (X === 0)
|
|
2659
|
-
l = 0, E = 0;
|
|
2660
|
-
else {
|
|
2661
|
-
switch (E = X / D, a = Z(v), s = Z(x), o = Z(q), D) {
|
|
2662
|
-
case v: {
|
|
2663
|
-
l = o - s;
|
|
2664
|
-
break;
|
|
2665
|
-
}
|
|
2666
|
-
case x: {
|
|
2667
|
-
l = 1 / 3 + a - o;
|
|
2668
|
-
break;
|
|
2669
|
-
}
|
|
2670
|
-
case q: {
|
|
2671
|
-
l = 2 / 3 + s - a;
|
|
2672
|
-
break;
|
|
2673
|
-
}
|
|
2674
|
-
}
|
|
2675
|
-
l < 0 ? l += 1 : l > 1 && (l -= 1);
|
|
2676
|
-
}
|
|
2677
|
-
return [
|
|
2678
|
-
l * 360,
|
|
2679
|
-
E * 100,
|
|
2680
|
-
D * 100
|
|
2681
|
-
];
|
|
2682
|
-
}, u.rgb.hwb = function(t) {
|
|
2683
|
-
const a = t[0], s = t[1];
|
|
2684
|
-
let o = t[2];
|
|
2685
|
-
const l = u.rgb.hsl(t)[0], E = 1 / 255 * Math.min(a, Math.min(s, o));
|
|
2686
|
-
return o = 1 - 1 / 255 * Math.max(a, Math.max(s, o)), [l, E * 100, o * 100];
|
|
2687
|
-
}, u.rgb.oklab = function(t) {
|
|
2688
|
-
const a = O(t[0] / 255), s = O(t[1] / 255), o = O(t[2] / 255), l = Math.cbrt(0.4122214708 * a + 0.5363325363 * s + 0.0514459929 * o), E = Math.cbrt(0.2119034982 * a + 0.6806995451 * s + 0.1073969566 * o), v = Math.cbrt(0.0883024619 * a + 0.2817188376 * s + 0.6299787005 * o), x = 0.2104542553 * l + 0.793617785 * E - 0.0040720468 * v, q = 1.9779984951 * l - 2.428592205 * E + 0.4505937099 * v, D = 0.0259040371 * l + 0.7827717662 * E - 0.808675766 * v;
|
|
2689
|
-
return [x * 100, q * 100, D * 100];
|
|
2690
|
-
}, u.rgb.cmyk = function(t) {
|
|
2691
|
-
const a = t[0] / 255, s = t[1] / 255, o = t[2] / 255, l = Math.min(1 - a, 1 - s, 1 - o), E = (1 - a - l) / (1 - l) || 0, v = (1 - s - l) / (1 - l) || 0, x = (1 - o - l) / (1 - l) || 0;
|
|
2692
|
-
return [E * 100, v * 100, x * 100, l * 100];
|
|
2693
|
-
};
|
|
2694
|
-
function H(t, a) {
|
|
2695
|
-
return (t[0] - a[0]) ** 2 + (t[1] - a[1]) ** 2 + (t[2] - a[2]) ** 2;
|
|
2696
|
-
}
|
|
2697
|
-
u.rgb.keyword = function(t) {
|
|
2698
|
-
const a = h[t];
|
|
2699
|
-
if (a)
|
|
2700
|
-
return a;
|
|
2701
|
-
let s = Number.POSITIVE_INFINITY, o;
|
|
2702
|
-
for (const l of Object.keys(d)) {
|
|
2703
|
-
const E = d[l], v = H(t, E);
|
|
2704
|
-
v < s && (s = v, o = l);
|
|
2705
|
-
}
|
|
2706
|
-
return o;
|
|
2707
|
-
}, u.keyword.rgb = function(t) {
|
|
2708
|
-
return d[t];
|
|
2709
|
-
}, u.rgb.xyz = function(t) {
|
|
2710
|
-
const a = O(t[0] / 255), s = O(t[1] / 255), o = O(t[2] / 255), l = a * 0.4124564 + s * 0.3575761 + o * 0.1804375, E = a * 0.2126729 + s * 0.7151522 + o * 0.072175, v = a * 0.0193339 + s * 0.119192 + o * 0.9503041;
|
|
2711
|
-
return [l * 100, E * 100, v * 100];
|
|
2712
|
-
}, u.rgb.lab = function(t) {
|
|
2713
|
-
const a = u.rgb.xyz(t);
|
|
2714
|
-
let s = a[0], o = a[1], l = a[2];
|
|
2715
|
-
s /= 95.047, o /= 100, l /= 108.883, s = s > $ ? s ** (1 / 3) : 7.787 * s + 16 / 116, o = o > $ ? o ** (1 / 3) : 7.787 * o + 16 / 116, l = l > $ ? l ** (1 / 3) : 7.787 * l + 16 / 116;
|
|
2716
|
-
const E = 116 * o - 16, v = 500 * (s - o), x = 200 * (o - l);
|
|
2717
|
-
return [E, v, x];
|
|
2718
|
-
}, u.hsl.rgb = function(t) {
|
|
2719
|
-
const a = t[0] / 360, s = t[1] / 100, o = t[2] / 100;
|
|
2720
|
-
let l, E;
|
|
2721
|
-
if (s === 0)
|
|
2722
|
-
return E = o * 255, [E, E, E];
|
|
2723
|
-
const v = o < 0.5 ? o * (1 + s) : o + s - o * s, x = 2 * o - v, q = [0, 0, 0];
|
|
2724
|
-
for (let D = 0; D < 3; D++)
|
|
2725
|
-
l = a + 1 / 3 * -(D - 1), l < 0 && l++, l > 1 && l--, 6 * l < 1 ? E = x + (v - x) * 6 * l : 2 * l < 1 ? E = v : 3 * l < 2 ? E = x + (v - x) * (2 / 3 - l) * 6 : E = x, q[D] = E * 255;
|
|
2726
|
-
return q;
|
|
2727
|
-
}, u.hsl.hsv = function(t) {
|
|
2728
|
-
const a = t[0];
|
|
2729
|
-
let s = t[1] / 100, o = t[2] / 100, l = s;
|
|
2730
|
-
const E = Math.max(o, 0.01);
|
|
2731
|
-
o *= 2, s *= o <= 1 ? o : 2 - o, l *= E <= 1 ? E : 2 - E;
|
|
2732
|
-
const v = (o + s) / 2, x = o === 0 ? 2 * l / (E + l) : 2 * s / (o + s);
|
|
2733
|
-
return [a, x * 100, v * 100];
|
|
2734
|
-
}, u.hsv.rgb = function(t) {
|
|
2735
|
-
const a = t[0] / 60, s = t[1] / 100;
|
|
2736
|
-
let o = t[2] / 100;
|
|
2737
|
-
const l = Math.floor(a) % 6, E = a - Math.floor(a), v = 255 * o * (1 - s), x = 255 * o * (1 - s * E), q = 255 * o * (1 - s * (1 - E));
|
|
2738
|
-
switch (o *= 255, l) {
|
|
2739
|
-
case 0:
|
|
2740
|
-
return [o, q, v];
|
|
2741
|
-
case 1:
|
|
2742
|
-
return [x, o, v];
|
|
2743
|
-
case 2:
|
|
2744
|
-
return [v, o, q];
|
|
2745
|
-
case 3:
|
|
2746
|
-
return [v, x, o];
|
|
2747
|
-
case 4:
|
|
2748
|
-
return [q, v, o];
|
|
2749
|
-
case 5:
|
|
2750
|
-
return [o, v, x];
|
|
2751
|
-
}
|
|
2752
|
-
}, u.hsv.hsl = function(t) {
|
|
2753
|
-
const a = t[0], s = t[1] / 100, o = t[2] / 100, l = Math.max(o, 0.01);
|
|
2754
|
-
let E, v;
|
|
2755
|
-
v = (2 - s) * o;
|
|
2756
|
-
const x = (2 - s) * l;
|
|
2757
|
-
return E = s * l, E /= x <= 1 ? x : 2 - x, E = E || 0, v /= 2, [a, E * 100, v * 100];
|
|
2758
|
-
}, u.hwb.rgb = function(t) {
|
|
2759
|
-
const a = t[0] / 360;
|
|
2760
|
-
let s = t[1] / 100, o = t[2] / 100;
|
|
2761
|
-
const l = s + o;
|
|
2762
|
-
let E;
|
|
2763
|
-
l > 1 && (s /= l, o /= l);
|
|
2764
|
-
const v = Math.floor(6 * a), x = 1 - o;
|
|
2765
|
-
E = 6 * a - v, (v & 1) !== 0 && (E = 1 - E);
|
|
2766
|
-
const q = s + E * (x - s);
|
|
2767
|
-
let D, X, Z;
|
|
2768
|
-
switch (v) {
|
|
2769
|
-
default:
|
|
2770
|
-
case 6:
|
|
2771
|
-
case 0: {
|
|
2772
|
-
D = x, X = q, Z = s;
|
|
2773
|
-
break;
|
|
2774
|
-
}
|
|
2775
|
-
case 1: {
|
|
2776
|
-
D = q, X = x, Z = s;
|
|
2777
|
-
break;
|
|
2778
|
-
}
|
|
2779
|
-
case 2: {
|
|
2780
|
-
D = s, X = x, Z = q;
|
|
2781
|
-
break;
|
|
2782
|
-
}
|
|
2783
|
-
case 3: {
|
|
2784
|
-
D = s, X = q, Z = x;
|
|
2785
|
-
break;
|
|
2786
|
-
}
|
|
2787
|
-
case 4: {
|
|
2788
|
-
D = q, X = s, Z = x;
|
|
2789
|
-
break;
|
|
2790
|
-
}
|
|
2791
|
-
case 5: {
|
|
2792
|
-
D = x, X = s, Z = q;
|
|
2793
|
-
break;
|
|
2794
|
-
}
|
|
2795
|
-
}
|
|
2796
|
-
return [D * 255, X * 255, Z * 255];
|
|
2797
|
-
}, u.cmyk.rgb = function(t) {
|
|
2798
|
-
const a = t[0] / 100, s = t[1] / 100, o = t[2] / 100, l = t[3] / 100, E = 1 - Math.min(1, a * (1 - l) + l), v = 1 - Math.min(1, s * (1 - l) + l), x = 1 - Math.min(1, o * (1 - l) + l);
|
|
2799
|
-
return [E * 255, v * 255, x * 255];
|
|
2800
|
-
}, u.xyz.rgb = function(t) {
|
|
2801
|
-
const a = t[0] / 100, s = t[1] / 100, o = t[2] / 100;
|
|
2802
|
-
let l, E, v;
|
|
2803
|
-
return l = a * 3.2404542 + s * -1.5371385 + o * -0.4985314, E = a * -0.969266 + s * 1.8760108 + o * 0.041556, v = a * 0.0556434 + s * -0.2040259 + o * 1.0572252, l = z(l), E = z(E), v = z(v), [l * 255, E * 255, v * 255];
|
|
2804
|
-
}, u.xyz.lab = function(t) {
|
|
2805
|
-
let a = t[0], s = t[1], o = t[2];
|
|
2806
|
-
a /= 95.047, s /= 100, o /= 108.883, a = a > $ ? a ** (1 / 3) : 7.787 * a + 16 / 116, s = s > $ ? s ** (1 / 3) : 7.787 * s + 16 / 116, o = o > $ ? o ** (1 / 3) : 7.787 * o + 16 / 116;
|
|
2807
|
-
const l = 116 * s - 16, E = 500 * (a - s), v = 200 * (s - o);
|
|
2808
|
-
return [l, E, v];
|
|
2809
|
-
}, u.xyz.oklab = function(t) {
|
|
2810
|
-
const a = t[0] / 100, s = t[1] / 100, o = t[2] / 100, l = Math.cbrt(0.8189330101 * a + 0.3618667424 * s - 0.1288597137 * o), E = Math.cbrt(0.0329845436 * a + 0.9293118715 * s + 0.0361456387 * o), v = Math.cbrt(0.0482003018 * a + 0.2643662691 * s + 0.633851707 * o), x = 0.2104542553 * l + 0.793617785 * E - 0.0040720468 * v, q = 1.9779984951 * l - 2.428592205 * E + 0.4505937099 * v, D = 0.0259040371 * l + 0.7827717662 * E - 0.808675766 * v;
|
|
2811
|
-
return [x * 100, q * 100, D * 100];
|
|
2812
|
-
}, u.oklab.oklch = function(t) {
|
|
2813
|
-
return u.lab.lch(t);
|
|
2814
|
-
}, u.oklab.xyz = function(t) {
|
|
2815
|
-
const a = t[0] / 100, s = t[1] / 100, o = t[2] / 100, l = (0.999999998 * a + 0.396337792 * s + 0.215803758 * o) ** 3, E = (1.000000008 * a - 0.105561342 * s - 0.063854175 * o) ** 3, v = (1.000000055 * a - 0.089484182 * s - 1.291485538 * o) ** 3, x = 1.227013851 * l - 0.55779998 * E + 0.281256149 * v, q = -0.040580178 * l + 1.11225687 * E - 0.071676679 * v, D = -0.076381285 * l - 0.421481978 * E + 1.58616322 * v;
|
|
2816
|
-
return [x * 100, q * 100, D * 100];
|
|
2817
|
-
}, u.oklab.rgb = function(t) {
|
|
2818
|
-
const a = t[0] / 100, s = t[1] / 100, o = t[2] / 100, l = (a + 0.3963377774 * s + 0.2158037573 * o) ** 3, E = (a - 0.1055613458 * s - 0.0638541728 * o) ** 3, v = (a - 0.0894841775 * s - 1.291485548 * o) ** 3, x = z(4.0767416621 * l - 3.3077115913 * E + 0.2309699292 * v), q = z(-1.2684380046 * l + 2.6097574011 * E - 0.3413193965 * v), D = z(-0.0041960863 * l - 0.7034186147 * E + 1.707614701 * v);
|
|
2819
|
-
return [x * 255, q * 255, D * 255];
|
|
2820
|
-
}, u.oklch.oklab = function(t) {
|
|
2821
|
-
return u.lch.lab(t);
|
|
2822
|
-
}, u.lab.xyz = function(t) {
|
|
2823
|
-
const a = t[0], s = t[1], o = t[2];
|
|
2824
|
-
let l, E, v;
|
|
2825
|
-
E = (a + 16) / 116, l = s / 500 + E, v = E - o / 200;
|
|
2826
|
-
const x = E ** 3, q = l ** 3, D = v ** 3;
|
|
2827
|
-
return E = x > $ ? x : (E - 16 / 116) / 7.787, l = q > $ ? q : (l - 16 / 116) / 7.787, v = D > $ ? D : (v - 16 / 116) / 7.787, l *= 95.047, E *= 100, v *= 108.883, [l, E, v];
|
|
2828
|
-
}, u.lab.lch = function(t) {
|
|
2829
|
-
const a = t[0], s = t[1], o = t[2];
|
|
2830
|
-
let l;
|
|
2831
|
-
l = Math.atan2(o, s) * 360 / 2 / Math.PI, l < 0 && (l += 360);
|
|
2832
|
-
const v = Math.sqrt(s * s + o * o);
|
|
2833
|
-
return [a, v, l];
|
|
2834
|
-
}, u.lch.lab = function(t) {
|
|
2835
|
-
const a = t[0], s = t[1], l = t[2] / 360 * 2 * Math.PI, E = s * Math.cos(l), v = s * Math.sin(l);
|
|
2836
|
-
return [a, E, v];
|
|
2837
|
-
}, u.rgb.ansi16 = function(t, a = null) {
|
|
2838
|
-
const [s, o, l] = t;
|
|
2839
|
-
let E = a === null ? u.rgb.hsv(t)[2] : a;
|
|
2840
|
-
if (E = Math.round(E / 50), E === 0)
|
|
2841
|
-
return 30;
|
|
2842
|
-
let v = 30 + (Math.round(l / 255) << 2 | Math.round(o / 255) << 1 | Math.round(s / 255));
|
|
2843
|
-
return E === 2 && (v += 60), v;
|
|
2844
|
-
}, u.hsv.ansi16 = function(t) {
|
|
2845
|
-
return u.rgb.ansi16(u.hsv.rgb(t), t[2]);
|
|
2846
|
-
}, u.rgb.ansi256 = function(t) {
|
|
2847
|
-
const a = t[0], s = t[1], o = t[2];
|
|
2848
|
-
return a >> 4 === s >> 4 && s >> 4 === o >> 4 ? a < 8 ? 16 : a > 248 ? 231 : Math.round((a - 8) / 247 * 24) + 232 : 16 + 36 * Math.round(a / 255 * 5) + 6 * Math.round(s / 255 * 5) + Math.round(o / 255 * 5);
|
|
2849
|
-
}, u.ansi16.rgb = function(t) {
|
|
2850
|
-
t = t[0];
|
|
2851
|
-
let a = t % 10;
|
|
2852
|
-
if (a === 0 || a === 7)
|
|
2853
|
-
return t > 50 && (a += 3.5), a = a / 10.5 * 255, [a, a, a];
|
|
2854
|
-
const s = (Math.trunc(t > 50) + 1) * 0.5, o = (a & 1) * s * 255, l = (a >> 1 & 1) * s * 255, E = (a >> 2 & 1) * s * 255;
|
|
2855
|
-
return [o, l, E];
|
|
2856
|
-
}, u.ansi256.rgb = function(t) {
|
|
2857
|
-
if (t = t[0], t >= 232) {
|
|
2858
|
-
const E = (t - 232) * 10 + 8;
|
|
2859
|
-
return [E, E, E];
|
|
2860
|
-
}
|
|
2861
|
-
t -= 16;
|
|
2862
|
-
let a;
|
|
2863
|
-
const s = Math.floor(t / 36) / 5 * 255, o = Math.floor((a = t % 36) / 6) / 5 * 255, l = a % 6 / 5 * 255;
|
|
2864
|
-
return [s, o, l];
|
|
2865
|
-
}, u.rgb.hex = function(t) {
|
|
2866
|
-
const s = (((Math.round(t[0]) & 255) << 16) + ((Math.round(t[1]) & 255) << 8) + (Math.round(t[2]) & 255)).toString(16).toUpperCase();
|
|
2867
|
-
return "000000".slice(s.length) + s;
|
|
2868
|
-
}, u.hex.rgb = function(t) {
|
|
2869
|
-
const a = t.toString(16).match(/[a-f\d]{6}|[a-f\d]{3}/i);
|
|
2870
|
-
if (!a)
|
|
2871
|
-
return [0, 0, 0];
|
|
2872
|
-
let s = a[0];
|
|
2873
|
-
a[0].length === 3 && (s = [...s].map((x) => x + x).join(""));
|
|
2874
|
-
const o = Number.parseInt(s, 16), l = o >> 16 & 255, E = o >> 8 & 255, v = o & 255;
|
|
2875
|
-
return [l, E, v];
|
|
2876
|
-
}, u.rgb.hcg = function(t) {
|
|
2877
|
-
const a = t[0] / 255, s = t[1] / 255, o = t[2] / 255, l = Math.max(Math.max(a, s), o), E = Math.min(Math.min(a, s), o), v = l - E;
|
|
2878
|
-
let x;
|
|
2879
|
-
const q = v < 1 ? E / (1 - v) : 0;
|
|
2880
|
-
return v <= 0 ? x = 0 : l === a ? x = (s - o) / v % 6 : l === s ? x = 2 + (o - a) / v : x = 4 + (a - s) / v, x /= 6, x %= 1, [x * 360, v * 100, q * 100];
|
|
2881
|
-
}, u.hsl.hcg = function(t) {
|
|
2882
|
-
const a = t[1] / 100, s = t[2] / 100, o = s < 0.5 ? 2 * a * s : 2 * a * (1 - s);
|
|
2883
|
-
let l = 0;
|
|
2884
|
-
return o < 1 && (l = (s - 0.5 * o) / (1 - o)), [t[0], o * 100, l * 100];
|
|
2885
|
-
}, u.hsv.hcg = function(t) {
|
|
2886
|
-
const a = t[1] / 100, s = t[2] / 100, o = a * s;
|
|
2887
|
-
let l = 0;
|
|
2888
|
-
return o < 1 && (l = (s - o) / (1 - o)), [t[0], o * 100, l * 100];
|
|
2889
|
-
}, u.hcg.rgb = function(t) {
|
|
2890
|
-
const a = t[0] / 360, s = t[1] / 100, o = t[2] / 100;
|
|
2891
|
-
if (s === 0)
|
|
2892
|
-
return [o * 255, o * 255, o * 255];
|
|
2893
|
-
const l = [0, 0, 0], E = a % 1 * 6, v = E % 1, x = 1 - v;
|
|
2894
|
-
let q = 0;
|
|
2895
|
-
switch (Math.floor(E)) {
|
|
2896
|
-
case 0: {
|
|
2897
|
-
l[0] = 1, l[1] = v, l[2] = 0;
|
|
2898
|
-
break;
|
|
2899
|
-
}
|
|
2900
|
-
case 1: {
|
|
2901
|
-
l[0] = x, l[1] = 1, l[2] = 0;
|
|
2902
|
-
break;
|
|
2903
|
-
}
|
|
2904
|
-
case 2: {
|
|
2905
|
-
l[0] = 0, l[1] = 1, l[2] = v;
|
|
2906
|
-
break;
|
|
2907
|
-
}
|
|
2908
|
-
case 3: {
|
|
2909
|
-
l[0] = 0, l[1] = x, l[2] = 1;
|
|
2910
|
-
break;
|
|
2911
|
-
}
|
|
2912
|
-
case 4: {
|
|
2913
|
-
l[0] = v, l[1] = 0, l[2] = 1;
|
|
2914
|
-
break;
|
|
2915
|
-
}
|
|
2916
|
-
default:
|
|
2917
|
-
l[0] = 1, l[1] = 0, l[2] = x;
|
|
2918
|
-
}
|
|
2919
|
-
return q = (1 - s) * o, [
|
|
2920
|
-
(s * l[0] + q) * 255,
|
|
2921
|
-
(s * l[1] + q) * 255,
|
|
2922
|
-
(s * l[2] + q) * 255
|
|
2923
|
-
];
|
|
2924
|
-
}, u.hcg.hsv = function(t) {
|
|
2925
|
-
const a = t[1] / 100, s = t[2] / 100, o = a + s * (1 - a);
|
|
2926
|
-
let l = 0;
|
|
2927
|
-
return o > 0 && (l = a / o), [t[0], l * 100, o * 100];
|
|
2928
|
-
}, u.hcg.hsl = function(t) {
|
|
2929
|
-
const a = t[1] / 100, o = t[2] / 100 * (1 - a) + 0.5 * a;
|
|
2930
|
-
let l = 0;
|
|
2931
|
-
return o > 0 && o < 0.5 ? l = a / (2 * o) : o >= 0.5 && o < 1 && (l = a / (2 * (1 - o))), [t[0], l * 100, o * 100];
|
|
2932
|
-
}, u.hcg.hwb = function(t) {
|
|
2933
|
-
const a = t[1] / 100, s = t[2] / 100, o = a + s * (1 - a);
|
|
2934
|
-
return [t[0], (o - a) * 100, (1 - o) * 100];
|
|
2935
|
-
}, u.hwb.hcg = function(t) {
|
|
2936
|
-
const a = t[1] / 100, o = 1 - t[2] / 100, l = o - a;
|
|
2937
|
-
let E = 0;
|
|
2938
|
-
return l < 1 && (E = (o - l) / (1 - l)), [t[0], l * 100, E * 100];
|
|
2939
|
-
}, u.apple.rgb = function(t) {
|
|
2940
|
-
return [t[0] / 65535 * 255, t[1] / 65535 * 255, t[2] / 65535 * 255];
|
|
2941
|
-
}, u.rgb.apple = function(t) {
|
|
2942
|
-
return [t[0] / 255 * 65535, t[1] / 255 * 65535, t[2] / 255 * 65535];
|
|
2943
|
-
}, u.gray.rgb = function(t) {
|
|
2944
|
-
return [t[0] / 100 * 255, t[0] / 100 * 255, t[0] / 100 * 255];
|
|
2945
|
-
}, u.gray.hsl = function(t) {
|
|
2946
|
-
return [0, 0, t[0]];
|
|
2947
|
-
}, u.gray.hsv = u.gray.hsl, u.gray.hwb = function(t) {
|
|
2948
|
-
return [0, 100, t[0]];
|
|
2949
|
-
}, u.gray.cmyk = function(t) {
|
|
2950
|
-
return [0, 0, 0, t[0]];
|
|
2951
|
-
}, u.gray.lab = function(t) {
|
|
2952
|
-
return [t[0], 0, 0];
|
|
2953
|
-
}, u.gray.hex = function(t) {
|
|
2954
|
-
const a = Math.round(t[0] / 100 * 255) & 255, o = ((a << 16) + (a << 8) + a).toString(16).toUpperCase();
|
|
2955
|
-
return "000000".slice(o.length) + o;
|
|
2956
|
-
}, u.rgb.gray = function(t) {
|
|
2957
|
-
return [(t[0] + t[1] + t[2]) / 3 / 255 * 100];
|
|
2958
|
-
};
|
|
2959
|
-
function W() {
|
|
2960
|
-
const t = {}, a = Object.keys(I);
|
|
2961
|
-
for (let { length: s } = a, o = 0; o < s; o++)
|
|
2962
|
-
t[a[o]] = {
|
|
2963
|
-
// http://jsperf.com/1-vs-infinity
|
|
2964
|
-
// micro-opt, but this is simple.
|
|
2965
|
-
distance: -1,
|
|
2966
|
-
parent: null
|
|
2967
|
-
};
|
|
2968
|
-
return t;
|
|
2969
|
-
}
|
|
2970
|
-
function Q(t) {
|
|
2971
|
-
const a = W(), s = [t];
|
|
2972
|
-
for (a[t].distance = 0; s.length > 0; ) {
|
|
2973
|
-
const o = s.pop(), l = Object.keys(I[o]);
|
|
2974
|
-
for (let { length: E } = l, v = 0; v < E; v++) {
|
|
2975
|
-
const x = l[v], q = a[x];
|
|
2976
|
-
q.distance === -1 && (q.distance = a[o].distance + 1, q.parent = o, s.unshift(x));
|
|
2977
|
-
}
|
|
2978
|
-
}
|
|
2979
|
-
return a;
|
|
2980
|
-
}
|
|
2981
|
-
function Y(t, a) {
|
|
2982
|
-
return function(s) {
|
|
2983
|
-
return a(t(s));
|
|
2984
|
-
};
|
|
2985
|
-
}
|
|
2986
|
-
function V(t, a) {
|
|
2987
|
-
const s = [a[t].parent, t];
|
|
2988
|
-
let o = I[a[t].parent][t], l = a[t].parent;
|
|
2989
|
-
for (; a[l].parent; )
|
|
2990
|
-
s.unshift(a[l].parent), o = Y(I[a[l].parent][l], o), l = a[l].parent;
|
|
2991
|
-
return o.conversion = s, o;
|
|
2992
|
-
}
|
|
2993
|
-
function f(t) {
|
|
2994
|
-
const a = Q(t), s = {}, o = Object.keys(a);
|
|
2995
|
-
for (let { length: l } = o, E = 0; E < l; E++) {
|
|
2996
|
-
const v = o[E];
|
|
2997
|
-
a[v].parent !== null && (s[v] = V(v, a));
|
|
2998
|
-
}
|
|
2999
|
-
return s;
|
|
3000
|
-
}
|
|
3001
|
-
var N = f, G = {}, K = Object.keys(I);
|
|
3002
|
-
function re(t) {
|
|
3003
|
-
const a = function(...s) {
|
|
3004
|
-
const o = s[0];
|
|
3005
|
-
return o == null ? o : (o.length > 1 && (s = o), t(s));
|
|
3006
|
-
};
|
|
3007
|
-
return "conversion" in t && (a.conversion = t.conversion), a;
|
|
3008
|
-
}
|
|
3009
|
-
function A(t) {
|
|
3010
|
-
const a = function(...s) {
|
|
3011
|
-
const o = s[0];
|
|
3012
|
-
if (o == null)
|
|
3013
|
-
return o;
|
|
3014
|
-
o.length > 1 && (s = o);
|
|
3015
|
-
const l = t(s);
|
|
3016
|
-
if (typeof l == "object")
|
|
3017
|
-
for (let { length: E } = l, v = 0; v < E; v++)
|
|
3018
|
-
l[v] = Math.round(l[v]);
|
|
3019
|
-
return l;
|
|
3020
|
-
};
|
|
3021
|
-
return "conversion" in t && (a.conversion = t.conversion), a;
|
|
3022
|
-
}
|
|
3023
|
-
for (const t of K) {
|
|
3024
|
-
G[t] = {}, Object.defineProperty(G[t], "channels", { value: I[t].channels }), Object.defineProperty(G[t], "labels", { value: I[t].labels });
|
|
3025
|
-
const a = N(t), s = Object.keys(a);
|
|
3026
|
-
for (const o of s) {
|
|
3027
|
-
const l = a[o];
|
|
3028
|
-
G[t][o] = A(l), G[t][o].raw = re(l);
|
|
3029
|
-
}
|
|
3030
|
-
}
|
|
3031
|
-
var j = G, F = [
|
|
3032
|
-
// To be honest, I don't really feel like keyword belongs in color convert, but eh.
|
|
3033
|
-
"keyword",
|
|
3034
|
-
// Gray conflicts with some method names, and has its own method defined.
|
|
3035
|
-
"gray",
|
|
3036
|
-
// Shouldn't really be in color-convert either...
|
|
3037
|
-
"hex"
|
|
3038
|
-
], T = {};
|
|
3039
|
-
for (const t of Object.keys(j))
|
|
3040
|
-
T[[...j[t].labels].sort().join("")] = t;
|
|
3041
|
-
var B = {};
|
|
3042
|
-
function _(t, a) {
|
|
3043
|
-
if (!(this instanceof _))
|
|
3044
|
-
return new _(t, a);
|
|
3045
|
-
if (a && a in F && (a = null), a && !(a in j))
|
|
3046
|
-
throw new Error("Unknown model: " + a);
|
|
3047
|
-
let s, o;
|
|
3048
|
-
if (t == null)
|
|
3049
|
-
this.model = "rgb", this.color = [0, 0, 0], this.valpha = 1;
|
|
3050
|
-
else if (t instanceof _)
|
|
3051
|
-
this.model = t.model, this.color = [...t.color], this.valpha = t.valpha;
|
|
3052
|
-
else if (typeof t == "string") {
|
|
3053
|
-
const l = k.get(t);
|
|
3054
|
-
if (l === null)
|
|
3055
|
-
throw new Error("Unable to parse color from string: " + t);
|
|
3056
|
-
this.model = l.model, o = j[this.model].channels, this.color = l.value.slice(0, o), this.valpha = typeof l.value[o] == "number" ? l.value[o] : 1;
|
|
3057
|
-
} else if (t.length > 0) {
|
|
3058
|
-
this.model = a || "rgb", o = j[this.model].channels;
|
|
3059
|
-
const l = Array.prototype.slice.call(t, 0, o);
|
|
3060
|
-
this.color = U(l, o), this.valpha = typeof t[o] == "number" ? t[o] : 1;
|
|
3061
|
-
} else if (typeof t == "number")
|
|
3062
|
-
this.model = "rgb", this.color = [
|
|
3063
|
-
t >> 16 & 255,
|
|
3064
|
-
t >> 8 & 255,
|
|
3065
|
-
t & 255
|
|
3066
|
-
], this.valpha = 1;
|
|
3067
|
-
else {
|
|
3068
|
-
this.valpha = 1;
|
|
3069
|
-
const l = Object.keys(t);
|
|
3070
|
-
"alpha" in t && (l.splice(l.indexOf("alpha"), 1), this.valpha = typeof t.alpha == "number" ? t.alpha : 0);
|
|
3071
|
-
const E = l.sort().join("");
|
|
3072
|
-
if (!(E in T))
|
|
3073
|
-
throw new Error("Unable to parse color from object: " + JSON.stringify(t));
|
|
3074
|
-
this.model = T[E];
|
|
3075
|
-
const { labels: v } = j[this.model], x = [];
|
|
3076
|
-
for (s = 0; s < v.length; s++)
|
|
3077
|
-
x.push(t[v[s]]);
|
|
3078
|
-
this.color = U(x);
|
|
3079
|
-
}
|
|
3080
|
-
if (B[this.model])
|
|
3081
|
-
for (o = j[this.model].channels, s = 0; s < o; s++) {
|
|
3082
|
-
const l = B[this.model][s];
|
|
3083
|
-
l && (this.color[s] = l(this.color[s]));
|
|
3084
|
-
}
|
|
3085
|
-
this.valpha = Math.max(0, Math.min(1, this.valpha)), Object.freeze && Object.freeze(this);
|
|
3086
|
-
}
|
|
3087
|
-
_.prototype = {
|
|
3088
|
-
toString() {
|
|
3089
|
-
return this.string();
|
|
3090
|
-
},
|
|
3091
|
-
toJSON() {
|
|
3092
|
-
return this[this.model]();
|
|
3093
|
-
},
|
|
3094
|
-
string(t) {
|
|
3095
|
-
let a = this.model in k.to ? this : this.rgb();
|
|
3096
|
-
a = a.round(typeof t == "number" ? t : 1);
|
|
3097
|
-
const s = a.valpha === 1 ? a.color : [...a.color, this.valpha];
|
|
3098
|
-
return k.to[a.model](...s);
|
|
3099
|
-
},
|
|
3100
|
-
percentString(t) {
|
|
3101
|
-
const a = this.rgb().round(typeof t == "number" ? t : 1), s = a.valpha === 1 ? a.color : [...a.color, this.valpha];
|
|
3102
|
-
return k.to.rgb.percent(...s);
|
|
3103
|
-
},
|
|
3104
|
-
array() {
|
|
3105
|
-
return this.valpha === 1 ? [...this.color] : [...this.color, this.valpha];
|
|
3106
|
-
},
|
|
3107
|
-
object() {
|
|
3108
|
-
const t = {}, { channels: a } = j[this.model], { labels: s } = j[this.model];
|
|
3109
|
-
for (let o = 0; o < a; o++)
|
|
3110
|
-
t[s[o]] = this.color[o];
|
|
3111
|
-
return this.valpha !== 1 && (t.alpha = this.valpha), t;
|
|
3112
|
-
},
|
|
3113
|
-
unitArray() {
|
|
3114
|
-
const t = this.rgb().color;
|
|
3115
|
-
return t[0] /= 255, t[1] /= 255, t[2] /= 255, this.valpha !== 1 && t.push(this.valpha), t;
|
|
3116
|
-
},
|
|
3117
|
-
unitObject() {
|
|
3118
|
-
const t = this.rgb().object();
|
|
3119
|
-
return t.r /= 255, t.g /= 255, t.b /= 255, this.valpha !== 1 && (t.alpha = this.valpha), t;
|
|
3120
|
-
},
|
|
3121
|
-
round(t) {
|
|
3122
|
-
return t = Math.max(t || 0, 0), new _([...this.color.map(C(t)), this.valpha], this.model);
|
|
3123
|
-
},
|
|
3124
|
-
alpha(t) {
|
|
3125
|
-
return t !== void 0 ? new _([...this.color, Math.max(0, Math.min(1, t))], this.model) : this.valpha;
|
|
3126
|
-
},
|
|
3127
|
-
// Rgb
|
|
3128
|
-
red: m("rgb", 0, L(255)),
|
|
3129
|
-
green: m("rgb", 1, L(255)),
|
|
3130
|
-
blue: m("rgb", 2, L(255)),
|
|
3131
|
-
hue: m(["hsl", "hsv", "hsl", "hwb", "hcg"], 0, (t) => (t % 360 + 360) % 360),
|
|
3132
|
-
saturationl: m("hsl", 1, L(100)),
|
|
3133
|
-
lightness: m("hsl", 2, L(100)),
|
|
3134
|
-
saturationv: m("hsv", 1, L(100)),
|
|
3135
|
-
value: m("hsv", 2, L(100)),
|
|
3136
|
-
chroma: m("hcg", 1, L(100)),
|
|
3137
|
-
gray: m("hcg", 2, L(100)),
|
|
3138
|
-
white: m("hwb", 1, L(100)),
|
|
3139
|
-
wblack: m("hwb", 2, L(100)),
|
|
3140
|
-
cyan: m("cmyk", 0, L(100)),
|
|
3141
|
-
magenta: m("cmyk", 1, L(100)),
|
|
3142
|
-
yellow: m("cmyk", 2, L(100)),
|
|
3143
|
-
black: m("cmyk", 3, L(100)),
|
|
3144
|
-
x: m("xyz", 0, L(95.047)),
|
|
3145
|
-
y: m("xyz", 1, L(100)),
|
|
3146
|
-
z: m("xyz", 2, L(108.833)),
|
|
3147
|
-
l: m("lab", 0, L(100)),
|
|
3148
|
-
a: m("lab", 1),
|
|
3149
|
-
b: m("lab", 2),
|
|
3150
|
-
keyword(t) {
|
|
3151
|
-
return t !== void 0 ? new _(t) : j[this.model].keyword(this.color);
|
|
3152
|
-
},
|
|
3153
|
-
hex(t) {
|
|
3154
|
-
return t !== void 0 ? new _(t) : k.to.hex(...this.rgb().round().color);
|
|
3155
|
-
},
|
|
3156
|
-
hexa(t) {
|
|
3157
|
-
if (t !== void 0)
|
|
3158
|
-
return new _(t);
|
|
3159
|
-
const a = this.rgb().round().color;
|
|
3160
|
-
let s = Math.round(this.valpha * 255).toString(16).toUpperCase();
|
|
3161
|
-
return s.length === 1 && (s = "0" + s), k.to.hex(...a) + s;
|
|
3162
|
-
},
|
|
3163
|
-
rgbNumber() {
|
|
3164
|
-
const t = this.rgb().color;
|
|
3165
|
-
return (t[0] & 255) << 16 | (t[1] & 255) << 8 | t[2] & 255;
|
|
3166
|
-
},
|
|
3167
|
-
luminosity() {
|
|
3168
|
-
const t = this.rgb().color, a = [];
|
|
3169
|
-
for (const [s, o] of t.entries()) {
|
|
3170
|
-
const l = o / 255;
|
|
3171
|
-
a[s] = l <= 0.04045 ? l / 12.92 : ((l + 0.055) / 1.055) ** 2.4;
|
|
3172
|
-
}
|
|
3173
|
-
return 0.2126 * a[0] + 0.7152 * a[1] + 0.0722 * a[2];
|
|
3174
|
-
},
|
|
3175
|
-
contrast(t) {
|
|
3176
|
-
const a = this.luminosity(), s = t.luminosity();
|
|
3177
|
-
return a > s ? (a + 0.05) / (s + 0.05) : (s + 0.05) / (a + 0.05);
|
|
3178
|
-
},
|
|
3179
|
-
level(t) {
|
|
3180
|
-
const a = this.contrast(t);
|
|
3181
|
-
return a >= 7 ? "AAA" : a >= 4.5 ? "AA" : "";
|
|
3182
|
-
},
|
|
3183
|
-
isDark() {
|
|
3184
|
-
const t = this.rgb().color;
|
|
3185
|
-
return (t[0] * 2126 + t[1] * 7152 + t[2] * 722) / 1e4 < 128;
|
|
3186
|
-
},
|
|
3187
|
-
isLight() {
|
|
3188
|
-
return !this.isDark();
|
|
3189
|
-
},
|
|
3190
|
-
negate() {
|
|
3191
|
-
const t = this.rgb();
|
|
3192
|
-
for (let a = 0; a < 3; a++)
|
|
3193
|
-
t.color[a] = 255 - t.color[a];
|
|
3194
|
-
return t;
|
|
3195
|
-
},
|
|
3196
|
-
lighten(t) {
|
|
3197
|
-
const a = this.hsl();
|
|
3198
|
-
return a.color[2] += a.color[2] * t, a;
|
|
3199
|
-
},
|
|
3200
|
-
darken(t) {
|
|
3201
|
-
const a = this.hsl();
|
|
3202
|
-
return a.color[2] -= a.color[2] * t, a;
|
|
3203
|
-
},
|
|
3204
|
-
saturate(t) {
|
|
3205
|
-
const a = this.hsl();
|
|
3206
|
-
return a.color[1] += a.color[1] * t, a;
|
|
3207
|
-
},
|
|
3208
|
-
desaturate(t) {
|
|
3209
|
-
const a = this.hsl();
|
|
3210
|
-
return a.color[1] -= a.color[1] * t, a;
|
|
3211
|
-
},
|
|
3212
|
-
whiten(t) {
|
|
3213
|
-
const a = this.hwb();
|
|
3214
|
-
return a.color[1] += a.color[1] * t, a;
|
|
3215
|
-
},
|
|
3216
|
-
blacken(t) {
|
|
3217
|
-
const a = this.hwb();
|
|
3218
|
-
return a.color[2] += a.color[2] * t, a;
|
|
3219
|
-
},
|
|
3220
|
-
grayscale() {
|
|
3221
|
-
const t = this.rgb().color, a = t[0] * 0.3 + t[1] * 0.59 + t[2] * 0.11;
|
|
3222
|
-
return _.rgb(a, a, a);
|
|
3223
|
-
},
|
|
3224
|
-
fade(t) {
|
|
3225
|
-
return this.alpha(this.valpha - this.valpha * t);
|
|
3226
|
-
},
|
|
3227
|
-
opaquer(t) {
|
|
3228
|
-
return this.alpha(this.valpha + this.valpha * t);
|
|
3229
|
-
},
|
|
3230
|
-
rotate(t) {
|
|
3231
|
-
const a = this.hsl();
|
|
3232
|
-
let s = a.color[0];
|
|
3233
|
-
return s = (s + t) % 360, s = s < 0 ? 360 + s : s, a.color[0] = s, a;
|
|
3234
|
-
},
|
|
3235
|
-
mix(t, a) {
|
|
3236
|
-
if (!t || !t.rgb)
|
|
3237
|
-
throw new Error('Argument to "mix" was not a Color instance, but rather an instance of ' + typeof t);
|
|
3238
|
-
const s = t.rgb(), o = this.rgb(), l = a === void 0 ? 0.5 : a, E = 2 * l - 1, v = s.alpha() - o.alpha(), x = ((E * v === -1 ? E : (E + v) / (1 + E * v)) + 1) / 2, q = 1 - x;
|
|
3239
|
-
return _.rgb(
|
|
3240
|
-
x * s.red() + q * o.red(),
|
|
3241
|
-
x * s.green() + q * o.green(),
|
|
3242
|
-
x * s.blue() + q * o.blue(),
|
|
3243
|
-
s.alpha() * l + o.alpha() * (1 - l)
|
|
3244
|
-
);
|
|
3245
|
-
}
|
|
3246
|
-
};
|
|
3247
|
-
for (const t of Object.keys(j)) {
|
|
3248
|
-
if (F.includes(t))
|
|
3249
|
-
continue;
|
|
3250
|
-
const { channels: a } = j[t];
|
|
3251
|
-
_.prototype[t] = function(...s) {
|
|
3252
|
-
return this.model === t ? new _(this) : s.length > 0 ? new _(s, t) : new _([...M(j[this.model][t].raw(this.color)), this.valpha], t);
|
|
3253
|
-
}, _[t] = function(...s) {
|
|
3254
|
-
let o = s[0];
|
|
3255
|
-
return typeof o == "number" && (o = U(s, a)), new _(o, t);
|
|
3256
|
-
};
|
|
3257
|
-
}
|
|
3258
|
-
function r(t, a) {
|
|
3259
|
-
return Number(t.toFixed(a));
|
|
3260
|
-
}
|
|
3261
|
-
function C(t) {
|
|
3262
|
-
return function(a) {
|
|
3263
|
-
return r(a, t);
|
|
3264
|
-
};
|
|
3265
|
-
}
|
|
3266
|
-
function m(t, a, s) {
|
|
3267
|
-
t = Array.isArray(t) ? t : [t];
|
|
3268
|
-
for (const o of t)
|
|
3269
|
-
(B[o] ||= [])[a] = s;
|
|
3270
|
-
return t = t[0], function(o) {
|
|
3271
|
-
let l;
|
|
3272
|
-
return o !== void 0 ? (s && (o = s(o)), l = this[t](), l.color[a] = o, l) : (l = this[t]().color[a], s && (l = s(l)), l);
|
|
3273
|
-
};
|
|
3274
|
-
}
|
|
3275
|
-
function L(t) {
|
|
3276
|
-
return function(a) {
|
|
3277
|
-
return Math.max(0, Math.min(t, a));
|
|
3278
|
-
};
|
|
3279
|
-
}
|
|
3280
|
-
function M(t) {
|
|
3281
|
-
return Array.isArray(t) ? t : [t];
|
|
3282
|
-
}
|
|
3283
|
-
function U(t, a) {
|
|
3284
|
-
for (let s = 0; s < a; s++)
|
|
3285
|
-
typeof t[s] != "number" && (t[s] = 0);
|
|
3286
|
-
return t;
|
|
3287
|
-
}
|
|
3288
|
-
var J = _;
|
|
3289
|
-
return Ue;
|
|
3290
|
-
}
|
|
3291
|
-
var ze, Nr;
|
|
3292
|
-
function At() {
|
|
3293
|
-
return Nr || (Nr = 1, ze = jt().default), ze;
|
|
3294
|
-
}
|
|
3295
|
-
var Ge, Cr;
|
|
3296
|
-
function Lt() {
|
|
3297
|
-
if (Cr) return Ge;
|
|
3298
|
-
Cr = 1;
|
|
3299
|
-
const e = At(), i = ee(), P = {
|
|
3300
|
-
multiband: "multiband",
|
|
3301
|
-
"b-w": "b-w",
|
|
3302
|
-
bw: "b-w",
|
|
3303
|
-
cmyk: "cmyk",
|
|
3304
|
-
srgb: "srgb"
|
|
3305
|
-
};
|
|
3306
|
-
function y(n) {
|
|
3307
|
-
return this._setBackgroundColourOption("tint", n), this;
|
|
3308
|
-
}
|
|
3309
|
-
function b(n) {
|
|
3310
|
-
return this.options.greyscale = i.bool(n) ? n : !0, this;
|
|
3311
|
-
}
|
|
3312
|
-
function S(n) {
|
|
3313
|
-
return this.greyscale(n);
|
|
3314
|
-
}
|
|
3315
|
-
function R(n) {
|
|
3316
|
-
if (!i.string(n))
|
|
3317
|
-
throw i.invalidParameterError("colourspace", "string", n);
|
|
3318
|
-
return this.options.colourspacePipeline = n, this;
|
|
3319
|
-
}
|
|
3320
|
-
function w(n) {
|
|
3321
|
-
return this.pipelineColourspace(n);
|
|
3322
|
-
}
|
|
3323
|
-
function d(n) {
|
|
3324
|
-
if (!i.string(n))
|
|
3325
|
-
throw i.invalidParameterError("colourspace", "string", n);
|
|
3326
|
-
return this.options.colourspace = n, this;
|
|
3327
|
-
}
|
|
3328
|
-
function g(n) {
|
|
3329
|
-
return this.toColourspace(n);
|
|
3330
|
-
}
|
|
3331
|
-
function c(n) {
|
|
3332
|
-
if (i.object(n) || i.string(n) && n.length >= 3 && n.length <= 200) {
|
|
3333
|
-
const k = e(n);
|
|
3334
|
-
return [
|
|
3335
|
-
k.red(),
|
|
3336
|
-
k.green(),
|
|
3337
|
-
k.blue(),
|
|
3338
|
-
Math.round(k.alpha() * 255)
|
|
3339
|
-
];
|
|
3340
|
-
} else
|
|
3341
|
-
throw i.invalidParameterError("background", "object or string", n);
|
|
3342
|
-
}
|
|
3343
|
-
function p(n, k) {
|
|
3344
|
-
i.defined(k) && (this.options[n] = c(k));
|
|
3345
|
-
}
|
|
3346
|
-
return Ge = (n) => {
|
|
3347
|
-
Object.assign(n.prototype, {
|
|
3348
|
-
// Public
|
|
3349
|
-
tint: y,
|
|
3350
|
-
greyscale: b,
|
|
3351
|
-
grayscale: S,
|
|
3352
|
-
pipelineColourspace: R,
|
|
3353
|
-
pipelineColorspace: w,
|
|
3354
|
-
toColourspace: d,
|
|
3355
|
-
toColorspace: g,
|
|
3356
|
-
// Private
|
|
3357
|
-
_getBackgroundColourOption: c,
|
|
3358
|
-
_setBackgroundColourOption: p
|
|
3359
|
-
}), n.colourspace = P, n.colorspace = P;
|
|
3360
|
-
}, Ge;
|
|
3361
|
-
}
|
|
3362
|
-
var He, _r;
|
|
3363
|
-
function St() {
|
|
3364
|
-
if (_r) return He;
|
|
3365
|
-
_r = 1;
|
|
3366
|
-
const e = ee(), i = {
|
|
3367
|
-
and: "and",
|
|
3368
|
-
or: "or",
|
|
3369
|
-
eor: "eor"
|
|
3370
|
-
};
|
|
3371
|
-
function P() {
|
|
3372
|
-
return this.options.removeAlpha = !0, this;
|
|
3373
|
-
}
|
|
3374
|
-
function y(w) {
|
|
3375
|
-
if (e.defined(w))
|
|
3376
|
-
if (e.number(w) && e.inRange(w, 0, 1))
|
|
3377
|
-
this.options.ensureAlpha = w;
|
|
3378
|
-
else
|
|
3379
|
-
throw e.invalidParameterError("alpha", "number between 0 and 1", w);
|
|
3380
|
-
else
|
|
3381
|
-
this.options.ensureAlpha = 1;
|
|
3382
|
-
return this;
|
|
3383
|
-
}
|
|
3384
|
-
function b(w) {
|
|
3385
|
-
const d = { red: 0, green: 1, blue: 2, alpha: 3 };
|
|
3386
|
-
if (Object.keys(d).includes(w) && (w = d[w]), e.integer(w) && e.inRange(w, 0, 4))
|
|
3387
|
-
this.options.extractChannel = w;
|
|
3388
|
-
else
|
|
3389
|
-
throw e.invalidParameterError("channel", "integer or one of: red, green, blue, alpha", w);
|
|
3390
|
-
return this;
|
|
3391
|
-
}
|
|
3392
|
-
function S(w, d) {
|
|
3393
|
-
return Array.isArray(w) ? w.forEach(function(g) {
|
|
3394
|
-
this.options.joinChannelIn.push(this._createInputDescriptor(g, d));
|
|
3395
|
-
}, this) : this.options.joinChannelIn.push(this._createInputDescriptor(w, d)), this;
|
|
3396
|
-
}
|
|
3397
|
-
function R(w) {
|
|
3398
|
-
if (e.string(w) && e.inArray(w, ["and", "or", "eor"]))
|
|
3399
|
-
this.options.bandBoolOp = w;
|
|
3400
|
-
else
|
|
3401
|
-
throw e.invalidParameterError("boolOp", "one of: and, or, eor", w);
|
|
3402
|
-
return this;
|
|
3403
|
-
}
|
|
3404
|
-
return He = (w) => {
|
|
3405
|
-
Object.assign(w.prototype, {
|
|
3406
|
-
// Public instance functions
|
|
3407
|
-
removeAlpha: P,
|
|
3408
|
-
ensureAlpha: y,
|
|
3409
|
-
extractChannel: b,
|
|
3410
|
-
joinChannel: S,
|
|
3411
|
-
bandbool: R
|
|
3412
|
-
}), w.bool = i;
|
|
3413
|
-
}, He;
|
|
3414
|
-
}
|
|
3415
|
-
var We, qr;
|
|
3416
|
-
function kt() {
|
|
3417
|
-
if (qr) return We;
|
|
3418
|
-
qr = 1;
|
|
3419
|
-
const e = ae, i = ee(), P = fe(), y = /* @__PURE__ */ new Map([
|
|
3420
|
-
["heic", "heif"],
|
|
3421
|
-
["heif", "heif"],
|
|
3422
|
-
["avif", "avif"],
|
|
3423
|
-
["jpeg", "jpeg"],
|
|
3424
|
-
["jpg", "jpeg"],
|
|
3425
|
-
["jpe", "jpeg"],
|
|
3426
|
-
["tile", "tile"],
|
|
3427
|
-
["dz", "tile"],
|
|
3428
|
-
["png", "png"],
|
|
3429
|
-
["raw", "raw"],
|
|
3430
|
-
["tiff", "tiff"],
|
|
3431
|
-
["tif", "tiff"],
|
|
3432
|
-
["webp", "webp"],
|
|
3433
|
-
["gif", "gif"],
|
|
3434
|
-
["jp2", "jp2"],
|
|
3435
|
-
["jpx", "jp2"],
|
|
3436
|
-
["j2k", "jp2"],
|
|
3437
|
-
["j2c", "jp2"],
|
|
3438
|
-
["jxl", "jxl"]
|
|
3439
|
-
]), b = /\.(jp[2x]|j2[kc])$/i, S = () => new Error("JP2 output requires libvips with support for OpenJPEG"), R = (r) => 1 << 31 - Math.clz32(Math.ceil(Math.log2(r)));
|
|
3440
|
-
function w(r, C) {
|
|
3441
|
-
let m;
|
|
3442
|
-
if (i.string(r) ? i.string(this.options.input.file) && e.resolve(this.options.input.file) === e.resolve(r) ? m = new Error("Cannot use same file for input and output") : b.test(e.extname(r)) && !this.constructor.format.jp2k.output.file && (m = S()) : m = new Error("Missing output file path"), m)
|
|
3443
|
-
if (i.fn(C))
|
|
3444
|
-
C(m);
|
|
3445
|
-
else
|
|
3446
|
-
return Promise.reject(m);
|
|
3447
|
-
else {
|
|
3448
|
-
this.options.fileOut = r;
|
|
3449
|
-
const L = Error();
|
|
3450
|
-
return this._pipeline(C, L);
|
|
3451
|
-
}
|
|
3452
|
-
return this;
|
|
3453
|
-
}
|
|
3454
|
-
function d(r, C) {
|
|
3455
|
-
i.object(r) ? this._setBooleanOption("resolveWithObject", r.resolveWithObject) : this.options.resolveWithObject && (this.options.resolveWithObject = !1), this.options.fileOut = "";
|
|
3456
|
-
const m = Error();
|
|
3457
|
-
return this._pipeline(i.fn(r) ? r : C, m);
|
|
3458
|
-
}
|
|
3459
|
-
function g() {
|
|
3460
|
-
return this.options.keepMetadata |= 1, this;
|
|
3461
|
-
}
|
|
3462
|
-
function c(r) {
|
|
3463
|
-
if (i.object(r))
|
|
3464
|
-
for (const [C, m] of Object.entries(r))
|
|
3465
|
-
if (i.object(m))
|
|
3466
|
-
for (const [L, M] of Object.entries(m))
|
|
3467
|
-
if (i.string(M))
|
|
3468
|
-
this.options.withExif[`exif-${C.toLowerCase()}-${L}`] = M;
|
|
3469
|
-
else
|
|
3470
|
-
throw i.invalidParameterError(`${C}.${L}`, "string", M);
|
|
3471
|
-
else
|
|
3472
|
-
throw i.invalidParameterError(C, "object", m);
|
|
3473
|
-
else
|
|
3474
|
-
throw i.invalidParameterError("exif", "object", r);
|
|
3475
|
-
return this.options.withExifMerge = !1, this.keepExif();
|
|
3476
|
-
}
|
|
3477
|
-
function p(r) {
|
|
3478
|
-
return this.withExif(r), this.options.withExifMerge = !0, this;
|
|
3479
|
-
}
|
|
3480
|
-
function n() {
|
|
3481
|
-
return this.options.keepMetadata |= 8, this;
|
|
3482
|
-
}
|
|
3483
|
-
function k(r, C) {
|
|
3484
|
-
if (i.string(r))
|
|
3485
|
-
this.options.withIccProfile = r;
|
|
3486
|
-
else
|
|
3487
|
-
throw i.invalidParameterError("icc", "string", r);
|
|
3488
|
-
if (this.keepIccProfile(), i.object(C) && i.defined(C.attach))
|
|
3489
|
-
if (i.bool(C.attach))
|
|
3490
|
-
C.attach || (this.options.keepMetadata &= -9);
|
|
3491
|
-
else
|
|
3492
|
-
throw i.invalidParameterError("attach", "boolean", C.attach);
|
|
3493
|
-
return this;
|
|
3494
|
-
}
|
|
3495
|
-
function h() {
|
|
3496
|
-
return this.options.keepMetadata |= 2, this;
|
|
3497
|
-
}
|
|
3498
|
-
function u(r) {
|
|
3499
|
-
if (i.string(r) && r.length > 0)
|
|
3500
|
-
this.options.withXmp = r, this.options.keepMetadata |= 2;
|
|
3501
|
-
else
|
|
3502
|
-
throw i.invalidParameterError("xmp", "non-empty string", r);
|
|
3503
|
-
return this;
|
|
3504
|
-
}
|
|
3505
|
-
function I() {
|
|
3506
|
-
return this.options.keepMetadata = 31, this;
|
|
3507
|
-
}
|
|
3508
|
-
function $(r) {
|
|
3509
|
-
if (this.keepMetadata(), this.withIccProfile("srgb"), i.object(r)) {
|
|
3510
|
-
if (i.defined(r.orientation))
|
|
3511
|
-
if (i.integer(r.orientation) && i.inRange(r.orientation, 1, 8))
|
|
3512
|
-
this.options.withMetadataOrientation = r.orientation;
|
|
3513
|
-
else
|
|
3514
|
-
throw i.invalidParameterError("orientation", "integer between 1 and 8", r.orientation);
|
|
3515
|
-
if (i.defined(r.density))
|
|
3516
|
-
if (i.number(r.density) && r.density > 0)
|
|
3517
|
-
this.options.withMetadataDensity = r.density;
|
|
3518
|
-
else
|
|
3519
|
-
throw i.invalidParameterError("density", "positive number", r.density);
|
|
3520
|
-
i.defined(r.icc) && this.withIccProfile(r.icc), i.defined(r.exif) && this.withExifMerge(r.exif);
|
|
3521
|
-
}
|
|
3522
|
-
return this;
|
|
3523
|
-
}
|
|
3524
|
-
function z(r, C) {
|
|
3525
|
-
const m = y.get((i.object(r) && i.string(r.id) ? r.id : r).toLowerCase());
|
|
3526
|
-
if (!m)
|
|
3527
|
-
throw i.invalidParameterError("format", `one of: ${[...y.keys()].join(", ")}`, r);
|
|
3528
|
-
return this[m](C);
|
|
3529
|
-
}
|
|
3530
|
-
function O(r) {
|
|
3531
|
-
if (i.object(r)) {
|
|
3532
|
-
if (i.defined(r.quality))
|
|
3533
|
-
if (i.integer(r.quality) && i.inRange(r.quality, 1, 100))
|
|
3534
|
-
this.options.jpegQuality = r.quality;
|
|
3535
|
-
else
|
|
3536
|
-
throw i.invalidParameterError("quality", "integer between 1 and 100", r.quality);
|
|
3537
|
-
if (i.defined(r.progressive) && this._setBooleanOption("jpegProgressive", r.progressive), i.defined(r.chromaSubsampling))
|
|
3538
|
-
if (i.string(r.chromaSubsampling) && i.inArray(r.chromaSubsampling, ["4:2:0", "4:4:4"]))
|
|
3539
|
-
this.options.jpegChromaSubsampling = r.chromaSubsampling;
|
|
3540
|
-
else
|
|
3541
|
-
throw i.invalidParameterError("chromaSubsampling", "one of: 4:2:0, 4:4:4", r.chromaSubsampling);
|
|
3542
|
-
const C = i.bool(r.optimizeCoding) ? r.optimizeCoding : r.optimiseCoding;
|
|
3543
|
-
if (i.defined(C) && this._setBooleanOption("jpegOptimiseCoding", C), i.defined(r.mozjpeg))
|
|
3544
|
-
if (i.bool(r.mozjpeg))
|
|
3545
|
-
r.mozjpeg && (this.options.jpegTrellisQuantisation = !0, this.options.jpegOvershootDeringing = !0, this.options.jpegOptimiseScans = !0, this.options.jpegProgressive = !0, this.options.jpegQuantisationTable = 3);
|
|
3546
|
-
else
|
|
3547
|
-
throw i.invalidParameterError("mozjpeg", "boolean", r.mozjpeg);
|
|
3548
|
-
const m = i.bool(r.trellisQuantization) ? r.trellisQuantization : r.trellisQuantisation;
|
|
3549
|
-
i.defined(m) && this._setBooleanOption("jpegTrellisQuantisation", m), i.defined(r.overshootDeringing) && this._setBooleanOption("jpegOvershootDeringing", r.overshootDeringing);
|
|
3550
|
-
const L = i.bool(r.optimizeScans) ? r.optimizeScans : r.optimiseScans;
|
|
3551
|
-
i.defined(L) && (this._setBooleanOption("jpegOptimiseScans", L), L && (this.options.jpegProgressive = !0));
|
|
3552
|
-
const M = i.number(r.quantizationTable) ? r.quantizationTable : r.quantisationTable;
|
|
3553
|
-
if (i.defined(M))
|
|
3554
|
-
if (i.integer(M) && i.inRange(M, 0, 8))
|
|
3555
|
-
this.options.jpegQuantisationTable = M;
|
|
3556
|
-
else
|
|
3557
|
-
throw i.invalidParameterError("quantisationTable", "integer between 0 and 8", M);
|
|
3558
|
-
}
|
|
3559
|
-
return this._updateFormatOut("jpeg", r);
|
|
3560
|
-
}
|
|
3561
|
-
function H(r) {
|
|
3562
|
-
if (i.object(r)) {
|
|
3563
|
-
if (i.defined(r.progressive) && this._setBooleanOption("pngProgressive", r.progressive), i.defined(r.compressionLevel))
|
|
3564
|
-
if (i.integer(r.compressionLevel) && i.inRange(r.compressionLevel, 0, 9))
|
|
3565
|
-
this.options.pngCompressionLevel = r.compressionLevel;
|
|
3566
|
-
else
|
|
3567
|
-
throw i.invalidParameterError("compressionLevel", "integer between 0 and 9", r.compressionLevel);
|
|
3568
|
-
i.defined(r.adaptiveFiltering) && this._setBooleanOption("pngAdaptiveFiltering", r.adaptiveFiltering);
|
|
3569
|
-
const C = r.colours || r.colors;
|
|
3570
|
-
if (i.defined(C))
|
|
3571
|
-
if (i.integer(C) && i.inRange(C, 2, 256))
|
|
3572
|
-
this.options.pngBitdepth = R(C);
|
|
3573
|
-
else
|
|
3574
|
-
throw i.invalidParameterError("colours", "integer between 2 and 256", C);
|
|
3575
|
-
if (i.defined(r.palette) ? this._setBooleanOption("pngPalette", r.palette) : [r.quality, r.effort, r.colours, r.colors, r.dither].some(i.defined) && this._setBooleanOption("pngPalette", !0), this.options.pngPalette) {
|
|
3576
|
-
if (i.defined(r.quality))
|
|
3577
|
-
if (i.integer(r.quality) && i.inRange(r.quality, 0, 100))
|
|
3578
|
-
this.options.pngQuality = r.quality;
|
|
3579
|
-
else
|
|
3580
|
-
throw i.invalidParameterError("quality", "integer between 0 and 100", r.quality);
|
|
3581
|
-
if (i.defined(r.effort))
|
|
3582
|
-
if (i.integer(r.effort) && i.inRange(r.effort, 1, 10))
|
|
3583
|
-
this.options.pngEffort = r.effort;
|
|
3584
|
-
else
|
|
3585
|
-
throw i.invalidParameterError("effort", "integer between 1 and 10", r.effort);
|
|
3586
|
-
if (i.defined(r.dither))
|
|
3587
|
-
if (i.number(r.dither) && i.inRange(r.dither, 0, 1))
|
|
3588
|
-
this.options.pngDither = r.dither;
|
|
3589
|
-
else
|
|
3590
|
-
throw i.invalidParameterError("dither", "number between 0.0 and 1.0", r.dither);
|
|
3591
|
-
}
|
|
3592
|
-
}
|
|
3593
|
-
return this._updateFormatOut("png", r);
|
|
3594
|
-
}
|
|
3595
|
-
function W(r) {
|
|
3596
|
-
if (i.object(r)) {
|
|
3597
|
-
if (i.defined(r.quality))
|
|
3598
|
-
if (i.integer(r.quality) && i.inRange(r.quality, 1, 100))
|
|
3599
|
-
this.options.webpQuality = r.quality;
|
|
3600
|
-
else
|
|
3601
|
-
throw i.invalidParameterError("quality", "integer between 1 and 100", r.quality);
|
|
3602
|
-
if (i.defined(r.alphaQuality))
|
|
3603
|
-
if (i.integer(r.alphaQuality) && i.inRange(r.alphaQuality, 0, 100))
|
|
3604
|
-
this.options.webpAlphaQuality = r.alphaQuality;
|
|
3605
|
-
else
|
|
3606
|
-
throw i.invalidParameterError("alphaQuality", "integer between 0 and 100", r.alphaQuality);
|
|
3607
|
-
if (i.defined(r.lossless) && this._setBooleanOption("webpLossless", r.lossless), i.defined(r.nearLossless) && this._setBooleanOption("webpNearLossless", r.nearLossless), i.defined(r.smartSubsample) && this._setBooleanOption("webpSmartSubsample", r.smartSubsample), i.defined(r.smartDeblock) && this._setBooleanOption("webpSmartDeblock", r.smartDeblock), i.defined(r.preset))
|
|
3608
|
-
if (i.string(r.preset) && i.inArray(r.preset, ["default", "photo", "picture", "drawing", "icon", "text"]))
|
|
3609
|
-
this.options.webpPreset = r.preset;
|
|
3610
|
-
else
|
|
3611
|
-
throw i.invalidParameterError("preset", "one of: default, photo, picture, drawing, icon, text", r.preset);
|
|
3612
|
-
if (i.defined(r.effort))
|
|
3613
|
-
if (i.integer(r.effort) && i.inRange(r.effort, 0, 6))
|
|
3614
|
-
this.options.webpEffort = r.effort;
|
|
3615
|
-
else
|
|
3616
|
-
throw i.invalidParameterError("effort", "integer between 0 and 6", r.effort);
|
|
3617
|
-
i.defined(r.minSize) && this._setBooleanOption("webpMinSize", r.minSize), i.defined(r.mixed) && this._setBooleanOption("webpMixed", r.mixed);
|
|
3618
|
-
}
|
|
3619
|
-
return V(r, this.options), this._updateFormatOut("webp", r);
|
|
3620
|
-
}
|
|
3621
|
-
function Q(r) {
|
|
3622
|
-
if (i.object(r)) {
|
|
3623
|
-
i.defined(r.reuse) && this._setBooleanOption("gifReuse", r.reuse), i.defined(r.progressive) && this._setBooleanOption("gifProgressive", r.progressive);
|
|
3624
|
-
const C = r.colours || r.colors;
|
|
3625
|
-
if (i.defined(C))
|
|
3626
|
-
if (i.integer(C) && i.inRange(C, 2, 256))
|
|
3627
|
-
this.options.gifBitdepth = R(C);
|
|
3628
|
-
else
|
|
3629
|
-
throw i.invalidParameterError("colours", "integer between 2 and 256", C);
|
|
3630
|
-
if (i.defined(r.effort))
|
|
3631
|
-
if (i.number(r.effort) && i.inRange(r.effort, 1, 10))
|
|
3632
|
-
this.options.gifEffort = r.effort;
|
|
3633
|
-
else
|
|
3634
|
-
throw i.invalidParameterError("effort", "integer between 1 and 10", r.effort);
|
|
3635
|
-
if (i.defined(r.dither))
|
|
3636
|
-
if (i.number(r.dither) && i.inRange(r.dither, 0, 1))
|
|
3637
|
-
this.options.gifDither = r.dither;
|
|
3638
|
-
else
|
|
3639
|
-
throw i.invalidParameterError("dither", "number between 0.0 and 1.0", r.dither);
|
|
3640
|
-
if (i.defined(r.interFrameMaxError))
|
|
3641
|
-
if (i.number(r.interFrameMaxError) && i.inRange(r.interFrameMaxError, 0, 32))
|
|
3642
|
-
this.options.gifInterFrameMaxError = r.interFrameMaxError;
|
|
3643
|
-
else
|
|
3644
|
-
throw i.invalidParameterError("interFrameMaxError", "number between 0.0 and 32.0", r.interFrameMaxError);
|
|
3645
|
-
if (i.defined(r.interPaletteMaxError))
|
|
3646
|
-
if (i.number(r.interPaletteMaxError) && i.inRange(r.interPaletteMaxError, 0, 256))
|
|
3647
|
-
this.options.gifInterPaletteMaxError = r.interPaletteMaxError;
|
|
3648
|
-
else
|
|
3649
|
-
throw i.invalidParameterError("interPaletteMaxError", "number between 0.0 and 256.0", r.interPaletteMaxError);
|
|
3650
|
-
if (i.defined(r.keepDuplicateFrames))
|
|
3651
|
-
if (i.bool(r.keepDuplicateFrames))
|
|
3652
|
-
this._setBooleanOption("gifKeepDuplicateFrames", r.keepDuplicateFrames);
|
|
3653
|
-
else
|
|
3654
|
-
throw i.invalidParameterError("keepDuplicateFrames", "boolean", r.keepDuplicateFrames);
|
|
3655
|
-
}
|
|
3656
|
-
return V(r, this.options), this._updateFormatOut("gif", r);
|
|
3657
|
-
}
|
|
3658
|
-
function Y(r) {
|
|
3659
|
-
if (!this.constructor.format.jp2k.output.buffer)
|
|
3660
|
-
throw S();
|
|
3661
|
-
if (i.object(r)) {
|
|
3662
|
-
if (i.defined(r.quality))
|
|
3663
|
-
if (i.integer(r.quality) && i.inRange(r.quality, 1, 100))
|
|
3664
|
-
this.options.jp2Quality = r.quality;
|
|
3665
|
-
else
|
|
3666
|
-
throw i.invalidParameterError("quality", "integer between 1 and 100", r.quality);
|
|
3667
|
-
if (i.defined(r.lossless))
|
|
3668
|
-
if (i.bool(r.lossless))
|
|
3669
|
-
this.options.jp2Lossless = r.lossless;
|
|
3670
|
-
else
|
|
3671
|
-
throw i.invalidParameterError("lossless", "boolean", r.lossless);
|
|
3672
|
-
if (i.defined(r.tileWidth))
|
|
3673
|
-
if (i.integer(r.tileWidth) && i.inRange(r.tileWidth, 1, 32768))
|
|
3674
|
-
this.options.jp2TileWidth = r.tileWidth;
|
|
3675
|
-
else
|
|
3676
|
-
throw i.invalidParameterError("tileWidth", "integer between 1 and 32768", r.tileWidth);
|
|
3677
|
-
if (i.defined(r.tileHeight))
|
|
3678
|
-
if (i.integer(r.tileHeight) && i.inRange(r.tileHeight, 1, 32768))
|
|
3679
|
-
this.options.jp2TileHeight = r.tileHeight;
|
|
3680
|
-
else
|
|
3681
|
-
throw i.invalidParameterError("tileHeight", "integer between 1 and 32768", r.tileHeight);
|
|
3682
|
-
if (i.defined(r.chromaSubsampling))
|
|
3683
|
-
if (i.string(r.chromaSubsampling) && i.inArray(r.chromaSubsampling, ["4:2:0", "4:4:4"]))
|
|
3684
|
-
this.options.jp2ChromaSubsampling = r.chromaSubsampling;
|
|
3685
|
-
else
|
|
3686
|
-
throw i.invalidParameterError("chromaSubsampling", "one of: 4:2:0, 4:4:4", r.chromaSubsampling);
|
|
3687
|
-
}
|
|
3688
|
-
return this._updateFormatOut("jp2", r);
|
|
3689
|
-
}
|
|
3690
|
-
function V(r, C) {
|
|
3691
|
-
if (i.object(r) && i.defined(r.loop))
|
|
3692
|
-
if (i.integer(r.loop) && i.inRange(r.loop, 0, 65535))
|
|
3693
|
-
C.loop = r.loop;
|
|
3694
|
-
else
|
|
3695
|
-
throw i.invalidParameterError("loop", "integer between 0 and 65535", r.loop);
|
|
3696
|
-
if (i.object(r) && i.defined(r.delay))
|
|
3697
|
-
if (i.integer(r.delay) && i.inRange(r.delay, 0, 65535))
|
|
3698
|
-
C.delay = [r.delay];
|
|
3699
|
-
else if (Array.isArray(r.delay) && r.delay.every(i.integer) && r.delay.every((m) => i.inRange(m, 0, 65535)))
|
|
3700
|
-
C.delay = r.delay;
|
|
3701
|
-
else
|
|
3702
|
-
throw i.invalidParameterError("delay", "integer or an array of integers between 0 and 65535", r.delay);
|
|
3703
|
-
}
|
|
3704
|
-
function f(r) {
|
|
3705
|
-
if (i.object(r)) {
|
|
3706
|
-
if (i.defined(r.quality))
|
|
3707
|
-
if (i.integer(r.quality) && i.inRange(r.quality, 1, 100))
|
|
3708
|
-
this.options.tiffQuality = r.quality;
|
|
3709
|
-
else
|
|
3710
|
-
throw i.invalidParameterError("quality", "integer between 1 and 100", r.quality);
|
|
3711
|
-
if (i.defined(r.bitdepth))
|
|
3712
|
-
if (i.integer(r.bitdepth) && i.inArray(r.bitdepth, [1, 2, 4, 8]))
|
|
3713
|
-
this.options.tiffBitdepth = r.bitdepth;
|
|
3714
|
-
else
|
|
3715
|
-
throw i.invalidParameterError("bitdepth", "1, 2, 4 or 8", r.bitdepth);
|
|
3716
|
-
if (i.defined(r.tile) && this._setBooleanOption("tiffTile", r.tile), i.defined(r.tileWidth))
|
|
3717
|
-
if (i.integer(r.tileWidth) && r.tileWidth > 0)
|
|
3718
|
-
this.options.tiffTileWidth = r.tileWidth;
|
|
3719
|
-
else
|
|
3720
|
-
throw i.invalidParameterError("tileWidth", "integer greater than zero", r.tileWidth);
|
|
3721
|
-
if (i.defined(r.tileHeight))
|
|
3722
|
-
if (i.integer(r.tileHeight) && r.tileHeight > 0)
|
|
3723
|
-
this.options.tiffTileHeight = r.tileHeight;
|
|
3724
|
-
else
|
|
3725
|
-
throw i.invalidParameterError("tileHeight", "integer greater than zero", r.tileHeight);
|
|
3726
|
-
if (i.defined(r.miniswhite) && this._setBooleanOption("tiffMiniswhite", r.miniswhite), i.defined(r.pyramid) && this._setBooleanOption("tiffPyramid", r.pyramid), i.defined(r.xres))
|
|
3727
|
-
if (i.number(r.xres) && r.xres > 0)
|
|
3728
|
-
this.options.tiffXres = r.xres;
|
|
3729
|
-
else
|
|
3730
|
-
throw i.invalidParameterError("xres", "number greater than zero", r.xres);
|
|
3731
|
-
if (i.defined(r.yres))
|
|
3732
|
-
if (i.number(r.yres) && r.yres > 0)
|
|
3733
|
-
this.options.tiffYres = r.yres;
|
|
3734
|
-
else
|
|
3735
|
-
throw i.invalidParameterError("yres", "number greater than zero", r.yres);
|
|
3736
|
-
if (i.defined(r.compression))
|
|
3737
|
-
if (i.string(r.compression) && i.inArray(r.compression, ["none", "jpeg", "deflate", "packbits", "ccittfax4", "lzw", "webp", "zstd", "jp2k"]))
|
|
3738
|
-
this.options.tiffCompression = r.compression;
|
|
3739
|
-
else
|
|
3740
|
-
throw i.invalidParameterError("compression", "one of: none, jpeg, deflate, packbits, ccittfax4, lzw, webp, zstd, jp2k", r.compression);
|
|
3741
|
-
if (i.defined(r.bigtiff) && this._setBooleanOption("tiffBigtiff", r.bigtiff), i.defined(r.predictor))
|
|
3742
|
-
if (i.string(r.predictor) && i.inArray(r.predictor, ["none", "horizontal", "float"]))
|
|
3743
|
-
this.options.tiffPredictor = r.predictor;
|
|
3744
|
-
else
|
|
3745
|
-
throw i.invalidParameterError("predictor", "one of: none, horizontal, float", r.predictor);
|
|
3746
|
-
if (i.defined(r.resolutionUnit))
|
|
3747
|
-
if (i.string(r.resolutionUnit) && i.inArray(r.resolutionUnit, ["inch", "cm"]))
|
|
3748
|
-
this.options.tiffResolutionUnit = r.resolutionUnit;
|
|
3749
|
-
else
|
|
3750
|
-
throw i.invalidParameterError("resolutionUnit", "one of: inch, cm", r.resolutionUnit);
|
|
3751
|
-
}
|
|
3752
|
-
return this._updateFormatOut("tiff", r);
|
|
3753
|
-
}
|
|
3754
|
-
function N(r) {
|
|
3755
|
-
return this.heif({ ...r, compression: "av1" });
|
|
3756
|
-
}
|
|
3757
|
-
function G(r) {
|
|
3758
|
-
if (i.object(r)) {
|
|
3759
|
-
if (i.string(r.compression) && i.inArray(r.compression, ["av1", "hevc"]))
|
|
3760
|
-
this.options.heifCompression = r.compression;
|
|
3761
|
-
else
|
|
3762
|
-
throw i.invalidParameterError("compression", "one of: av1, hevc", r.compression);
|
|
3763
|
-
if (i.defined(r.quality))
|
|
3764
|
-
if (i.integer(r.quality) && i.inRange(r.quality, 1, 100))
|
|
3765
|
-
this.options.heifQuality = r.quality;
|
|
3766
|
-
else
|
|
3767
|
-
throw i.invalidParameterError("quality", "integer between 1 and 100", r.quality);
|
|
3768
|
-
if (i.defined(r.lossless))
|
|
3769
|
-
if (i.bool(r.lossless))
|
|
3770
|
-
this.options.heifLossless = r.lossless;
|
|
3771
|
-
else
|
|
3772
|
-
throw i.invalidParameterError("lossless", "boolean", r.lossless);
|
|
3773
|
-
if (i.defined(r.effort))
|
|
3774
|
-
if (i.integer(r.effort) && i.inRange(r.effort, 0, 9))
|
|
3775
|
-
this.options.heifEffort = r.effort;
|
|
3776
|
-
else
|
|
3777
|
-
throw i.invalidParameterError("effort", "integer between 0 and 9", r.effort);
|
|
3778
|
-
if (i.defined(r.chromaSubsampling))
|
|
3779
|
-
if (i.string(r.chromaSubsampling) && i.inArray(r.chromaSubsampling, ["4:2:0", "4:4:4"]))
|
|
3780
|
-
this.options.heifChromaSubsampling = r.chromaSubsampling;
|
|
3781
|
-
else
|
|
3782
|
-
throw i.invalidParameterError("chromaSubsampling", "one of: 4:2:0, 4:4:4", r.chromaSubsampling);
|
|
3783
|
-
if (i.defined(r.bitdepth))
|
|
3784
|
-
if (i.integer(r.bitdepth) && i.inArray(r.bitdepth, [8, 10, 12])) {
|
|
3785
|
-
if (r.bitdepth !== 8 && this.constructor.versions.heif)
|
|
3786
|
-
throw i.invalidParameterError("bitdepth when using prebuilt binaries", 8, r.bitdepth);
|
|
3787
|
-
this.options.heifBitdepth = r.bitdepth;
|
|
3788
|
-
} else
|
|
3789
|
-
throw i.invalidParameterError("bitdepth", "8, 10 or 12", r.bitdepth);
|
|
3790
|
-
} else
|
|
3791
|
-
throw i.invalidParameterError("options", "Object", r);
|
|
3792
|
-
return this._updateFormatOut("heif", r);
|
|
3793
|
-
}
|
|
3794
|
-
function K(r) {
|
|
3795
|
-
if (i.object(r)) {
|
|
3796
|
-
if (i.defined(r.quality))
|
|
3797
|
-
if (i.integer(r.quality) && i.inRange(r.quality, 1, 100))
|
|
3798
|
-
this.options.jxlDistance = r.quality >= 30 ? 0.1 + (100 - r.quality) * 0.09 : 53 / 3e3 * r.quality * r.quality - 23 / 20 * r.quality + 25;
|
|
3799
|
-
else
|
|
3800
|
-
throw i.invalidParameterError("quality", "integer between 1 and 100", r.quality);
|
|
3801
|
-
else if (i.defined(r.distance))
|
|
3802
|
-
if (i.number(r.distance) && i.inRange(r.distance, 0, 15))
|
|
3803
|
-
this.options.jxlDistance = r.distance;
|
|
3804
|
-
else
|
|
3805
|
-
throw i.invalidParameterError("distance", "number between 0.0 and 15.0", r.distance);
|
|
3806
|
-
if (i.defined(r.decodingTier))
|
|
3807
|
-
if (i.integer(r.decodingTier) && i.inRange(r.decodingTier, 0, 4))
|
|
3808
|
-
this.options.jxlDecodingTier = r.decodingTier;
|
|
3809
|
-
else
|
|
3810
|
-
throw i.invalidParameterError("decodingTier", "integer between 0 and 4", r.decodingTier);
|
|
3811
|
-
if (i.defined(r.lossless))
|
|
3812
|
-
if (i.bool(r.lossless))
|
|
3813
|
-
this.options.jxlLossless = r.lossless;
|
|
3814
|
-
else
|
|
3815
|
-
throw i.invalidParameterError("lossless", "boolean", r.lossless);
|
|
3816
|
-
if (i.defined(r.effort))
|
|
3817
|
-
if (i.integer(r.effort) && i.inRange(r.effort, 1, 9))
|
|
3818
|
-
this.options.jxlEffort = r.effort;
|
|
3819
|
-
else
|
|
3820
|
-
throw i.invalidParameterError("effort", "integer between 1 and 9", r.effort);
|
|
3821
|
-
}
|
|
3822
|
-
return V(r, this.options), this._updateFormatOut("jxl", r);
|
|
3823
|
-
}
|
|
3824
|
-
function re(r) {
|
|
3825
|
-
if (i.object(r) && i.defined(r.depth))
|
|
3826
|
-
if (i.string(r.depth) && i.inArray(
|
|
3827
|
-
r.depth,
|
|
3828
|
-
["char", "uchar", "short", "ushort", "int", "uint", "float", "complex", "double", "dpcomplex"]
|
|
3829
|
-
))
|
|
3830
|
-
this.options.rawDepth = r.depth;
|
|
3831
|
-
else
|
|
3832
|
-
throw i.invalidParameterError("depth", "one of: char, uchar, short, ushort, int, uint, float, complex, double, dpcomplex", r.depth);
|
|
3833
|
-
return this._updateFormatOut("raw");
|
|
3834
|
-
}
|
|
3835
|
-
function A(r) {
|
|
3836
|
-
if (i.object(r)) {
|
|
3837
|
-
if (i.defined(r.size))
|
|
3838
|
-
if (i.integer(r.size) && i.inRange(r.size, 1, 8192))
|
|
3839
|
-
this.options.tileSize = r.size;
|
|
3840
|
-
else
|
|
3841
|
-
throw i.invalidParameterError("size", "integer between 1 and 8192", r.size);
|
|
3842
|
-
if (i.defined(r.overlap))
|
|
3843
|
-
if (i.integer(r.overlap) && i.inRange(r.overlap, 0, 8192)) {
|
|
3844
|
-
if (r.overlap > this.options.tileSize)
|
|
3845
|
-
throw i.invalidParameterError("overlap", `<= size (${this.options.tileSize})`, r.overlap);
|
|
3846
|
-
this.options.tileOverlap = r.overlap;
|
|
3847
|
-
} else
|
|
3848
|
-
throw i.invalidParameterError("overlap", "integer between 0 and 8192", r.overlap);
|
|
3849
|
-
if (i.defined(r.container))
|
|
3850
|
-
if (i.string(r.container) && i.inArray(r.container, ["fs", "zip"]))
|
|
3851
|
-
this.options.tileContainer = r.container;
|
|
3852
|
-
else
|
|
3853
|
-
throw i.invalidParameterError("container", "one of: fs, zip", r.container);
|
|
3854
|
-
if (i.defined(r.layout))
|
|
3855
|
-
if (i.string(r.layout) && i.inArray(r.layout, ["dz", "google", "iiif", "iiif3", "zoomify"]))
|
|
3856
|
-
this.options.tileLayout = r.layout;
|
|
3857
|
-
else
|
|
3858
|
-
throw i.invalidParameterError("layout", "one of: dz, google, iiif, iiif3, zoomify", r.layout);
|
|
3859
|
-
if (i.defined(r.angle))
|
|
3860
|
-
if (i.integer(r.angle) && !(r.angle % 90))
|
|
3861
|
-
this.options.tileAngle = r.angle;
|
|
3862
|
-
else
|
|
3863
|
-
throw i.invalidParameterError("angle", "positive/negative multiple of 90", r.angle);
|
|
3864
|
-
if (this._setBackgroundColourOption("tileBackground", r.background), i.defined(r.depth))
|
|
3865
|
-
if (i.string(r.depth) && i.inArray(r.depth, ["onepixel", "onetile", "one"]))
|
|
3866
|
-
this.options.tileDepth = r.depth;
|
|
3867
|
-
else
|
|
3868
|
-
throw i.invalidParameterError("depth", "one of: onepixel, onetile, one", r.depth);
|
|
3869
|
-
if (i.defined(r.skipBlanks))
|
|
3870
|
-
if (i.integer(r.skipBlanks) && i.inRange(r.skipBlanks, -1, 65535))
|
|
3871
|
-
this.options.tileSkipBlanks = r.skipBlanks;
|
|
3872
|
-
else
|
|
3873
|
-
throw i.invalidParameterError("skipBlanks", "integer between -1 and 255/65535", r.skipBlanks);
|
|
3874
|
-
else i.defined(r.layout) && r.layout === "google" && (this.options.tileSkipBlanks = 5);
|
|
3875
|
-
const C = i.bool(r.center) ? r.center : r.centre;
|
|
3876
|
-
if (i.defined(C) && this._setBooleanOption("tileCentre", C), i.defined(r.id))
|
|
3877
|
-
if (i.string(r.id))
|
|
3878
|
-
this.options.tileId = r.id;
|
|
3879
|
-
else
|
|
3880
|
-
throw i.invalidParameterError("id", "string", r.id);
|
|
3881
|
-
if (i.defined(r.basename))
|
|
3882
|
-
if (i.string(r.basename))
|
|
3883
|
-
this.options.tileBasename = r.basename;
|
|
3884
|
-
else
|
|
3885
|
-
throw i.invalidParameterError("basename", "string", r.basename);
|
|
3886
|
-
}
|
|
3887
|
-
if (i.inArray(this.options.formatOut, ["jpeg", "png", "webp"]))
|
|
3888
|
-
this.options.tileFormat = this.options.formatOut;
|
|
3889
|
-
else if (this.options.formatOut !== "input")
|
|
3890
|
-
throw i.invalidParameterError("format", "one of: jpeg, png, webp", this.options.formatOut);
|
|
3891
|
-
return this._updateFormatOut("dz");
|
|
3892
|
-
}
|
|
3893
|
-
function j(r) {
|
|
3894
|
-
if (!i.plainObject(r))
|
|
3895
|
-
throw i.invalidParameterError("options", "object", r);
|
|
3896
|
-
if (i.integer(r.seconds) && i.inRange(r.seconds, 0, 3600))
|
|
3897
|
-
this.options.timeoutSeconds = r.seconds;
|
|
3898
|
-
else
|
|
3899
|
-
throw i.invalidParameterError("seconds", "integer between 0 and 3600", r.seconds);
|
|
3900
|
-
return this;
|
|
3901
|
-
}
|
|
3902
|
-
function F(r, C) {
|
|
3903
|
-
return i.object(C) && C.force === !1 || (this.options.formatOut = r), this;
|
|
3904
|
-
}
|
|
3905
|
-
function T(r, C) {
|
|
3906
|
-
if (i.bool(C))
|
|
3907
|
-
this.options[r] = C;
|
|
3908
|
-
else
|
|
3909
|
-
throw i.invalidParameterError(r, "boolean", C);
|
|
3910
|
-
}
|
|
3911
|
-
function B() {
|
|
3912
|
-
if (!this.options.streamOut) {
|
|
3913
|
-
this.options.streamOut = !0;
|
|
3914
|
-
const r = Error();
|
|
3915
|
-
this._pipeline(void 0, r);
|
|
3916
|
-
}
|
|
3917
|
-
}
|
|
3918
|
-
function _(r, C) {
|
|
3919
|
-
return typeof r == "function" ? (this._isStreamInput() ? this.on("finish", () => {
|
|
3920
|
-
this._flattenBufferIn(), P.pipeline(this.options, (m, L, M) => {
|
|
3921
|
-
m ? r(i.nativeError(m, C)) : r(null, L, M);
|
|
3922
|
-
});
|
|
3923
|
-
}) : P.pipeline(this.options, (m, L, M) => {
|
|
3924
|
-
m ? r(i.nativeError(m, C)) : r(null, L, M);
|
|
3925
|
-
}), this) : this.options.streamOut ? (this._isStreamInput() ? (this.once("finish", () => {
|
|
3926
|
-
this._flattenBufferIn(), P.pipeline(this.options, (m, L, M) => {
|
|
3927
|
-
m ? this.emit("error", i.nativeError(m, C)) : (this.emit("info", M), this.push(L)), this.push(null), this.on("end", () => this.emit("close"));
|
|
3928
|
-
});
|
|
3929
|
-
}), this.streamInFinished && this.emit("finish")) : P.pipeline(this.options, (m, L, M) => {
|
|
3930
|
-
m ? this.emit("error", i.nativeError(m, C)) : (this.emit("info", M), this.push(L)), this.push(null), this.on("end", () => this.emit("close"));
|
|
3931
|
-
}), this) : this._isStreamInput() ? new Promise((m, L) => {
|
|
3932
|
-
this.once("finish", () => {
|
|
3933
|
-
this._flattenBufferIn(), P.pipeline(this.options, (M, U, J) => {
|
|
3934
|
-
M ? L(i.nativeError(M, C)) : this.options.resolveWithObject ? m({ data: U, info: J }) : m(U);
|
|
3935
|
-
});
|
|
3936
|
-
});
|
|
3937
|
-
}) : new Promise((m, L) => {
|
|
3938
|
-
P.pipeline(this.options, (M, U, J) => {
|
|
3939
|
-
M ? L(i.nativeError(M, C)) : this.options.resolveWithObject ? m({ data: U, info: J }) : m(U);
|
|
3940
|
-
});
|
|
3941
|
-
});
|
|
3942
|
-
}
|
|
3943
|
-
return We = (r) => {
|
|
3944
|
-
Object.assign(r.prototype, {
|
|
3945
|
-
// Public
|
|
3946
|
-
toFile: w,
|
|
3947
|
-
toBuffer: d,
|
|
3948
|
-
keepExif: g,
|
|
3949
|
-
withExif: c,
|
|
3950
|
-
withExifMerge: p,
|
|
3951
|
-
keepIccProfile: n,
|
|
3952
|
-
withIccProfile: k,
|
|
3953
|
-
keepXmp: h,
|
|
3954
|
-
withXmp: u,
|
|
3955
|
-
keepMetadata: I,
|
|
3956
|
-
withMetadata: $,
|
|
3957
|
-
toFormat: z,
|
|
3958
|
-
jpeg: O,
|
|
3959
|
-
jp2: Y,
|
|
3960
|
-
png: H,
|
|
3961
|
-
webp: W,
|
|
3962
|
-
tiff: f,
|
|
3963
|
-
avif: N,
|
|
3964
|
-
heif: G,
|
|
3965
|
-
jxl: K,
|
|
3966
|
-
gif: Q,
|
|
3967
|
-
raw: re,
|
|
3968
|
-
tile: A,
|
|
3969
|
-
timeout: j,
|
|
3970
|
-
// Private
|
|
3971
|
-
_updateFormatOut: F,
|
|
3972
|
-
_setBooleanOption: T,
|
|
3973
|
-
_read: B,
|
|
3974
|
-
_pipeline: _
|
|
3975
|
-
});
|
|
3976
|
-
}, We;
|
|
3977
|
-
}
|
|
3978
|
-
var Xe, Tr;
|
|
3979
|
-
function Nt() {
|
|
3980
|
-
if (Tr) return Xe;
|
|
3981
|
-
Tr = 1;
|
|
3982
|
-
const e = Jr, i = Qe(), P = ee(), { runtimePlatformArch: y } = Ur(), b = fe(), S = y(), R = b.libvipsVersion(), w = b.format();
|
|
3983
|
-
w.heif.output.alias = ["avif", "heic"], w.jpeg.output.alias = ["jpe", "jpg"], w.tiff.output.alias = ["tif"], w.jp2k.output.alias = ["j2c", "j2k", "jp2", "jpx"];
|
|
3984
|
-
const d = {
|
|
3985
|
-
/** [Nearest neighbour interpolation](http://en.wikipedia.org/wiki/Nearest-neighbor_interpolation). Suitable for image enlargement only. */
|
|
3986
|
-
nearest: "nearest",
|
|
3987
|
-
/** [Bilinear interpolation](http://en.wikipedia.org/wiki/Bilinear_interpolation). Faster than bicubic but with less smooth results. */
|
|
3988
|
-
bilinear: "bilinear",
|
|
3989
|
-
/** [Bicubic interpolation](http://en.wikipedia.org/wiki/Bicubic_interpolation) (the default). */
|
|
3990
|
-
bicubic: "bicubic",
|
|
3991
|
-
/** [LBB interpolation](https://github.com/libvips/libvips/blob/master/libvips/resample/lbb.cpp#L100). Prevents some "[acutance](http://en.wikipedia.org/wiki/Acutance)" but typically reduces performance by a factor of 2. */
|
|
3992
|
-
locallyBoundedBicubic: "lbb",
|
|
3993
|
-
/** [Nohalo interpolation](http://eprints.soton.ac.uk/268086/). Prevents acutance but typically reduces performance by a factor of 3. */
|
|
3994
|
-
nohalo: "nohalo",
|
|
3995
|
-
/** [VSQBS interpolation](https://github.com/libvips/libvips/blob/master/libvips/resample/vsqbs.cpp#L48). Prevents "staircasing" when enlarging. */
|
|
3996
|
-
vertexSplitQuadraticBasisSpline: "vsqbs"
|
|
3997
|
-
};
|
|
3998
|
-
let g = {
|
|
3999
|
-
vips: R.semver
|
|
4000
|
-
};
|
|
4001
|
-
if (!R.isGlobal)
|
|
4002
|
-
if (R.isWasm)
|
|
4003
|
-
try {
|
|
4004
|
-
g = require("@img/sharp-wasm32/versions");
|
|
4005
|
-
} catch {
|
|
4006
|
-
}
|
|
4007
|
-
else
|
|
4008
|
-
try {
|
|
4009
|
-
g = ie(`@img/sharp-${S}/versions`);
|
|
4010
|
-
} catch {
|
|
4011
|
-
try {
|
|
4012
|
-
g = ie(`@img/sharp-libvips-${S}/versions`);
|
|
4013
|
-
} catch {
|
|
4014
|
-
}
|
|
4015
|
-
}
|
|
4016
|
-
g.sharp = Or.version, g.heif && w.heif && (w.heif.input.fileSuffix = [".avif"], w.heif.output.alias = ["avif"]);
|
|
4017
|
-
function c($) {
|
|
4018
|
-
return P.bool($) ? $ ? b.cache(50, 20, 100) : b.cache(0, 0, 0) : P.object($) ? b.cache($.memory, $.files, $.items) : b.cache();
|
|
4019
|
-
}
|
|
4020
|
-
c(!0);
|
|
4021
|
-
function p($) {
|
|
4022
|
-
return b.concurrency(P.integer($) ? $ : null);
|
|
4023
|
-
}
|
|
4024
|
-
i.familySync() === i.GLIBC && !b._isUsingJemalloc() ? b.concurrency(1) : i.familySync() === i.MUSL && b.concurrency() === 1024 && b.concurrency(Zr.availableParallelism());
|
|
4025
|
-
const n = new e.EventEmitter();
|
|
4026
|
-
function k() {
|
|
4027
|
-
return b.counters();
|
|
4028
|
-
}
|
|
4029
|
-
function h($) {
|
|
4030
|
-
return b.simd(P.bool($) ? $ : null);
|
|
4031
|
-
}
|
|
4032
|
-
function u($) {
|
|
4033
|
-
if (P.object($))
|
|
4034
|
-
if (Array.isArray($.operation) && $.operation.every(P.string))
|
|
4035
|
-
b.block($.operation, !0);
|
|
4036
|
-
else
|
|
4037
|
-
throw P.invalidParameterError("operation", "Array<string>", $.operation);
|
|
4038
|
-
else
|
|
4039
|
-
throw P.invalidParameterError("options", "object", $);
|
|
4040
|
-
}
|
|
4041
|
-
function I($) {
|
|
4042
|
-
if (P.object($))
|
|
4043
|
-
if (Array.isArray($.operation) && $.operation.every(P.string))
|
|
4044
|
-
b.block($.operation, !1);
|
|
4045
|
-
else
|
|
4046
|
-
throw P.invalidParameterError("operation", "Array<string>", $.operation);
|
|
4047
|
-
else
|
|
4048
|
-
throw P.invalidParameterError("options", "object", $);
|
|
4049
|
-
}
|
|
4050
|
-
return Xe = ($) => {
|
|
4051
|
-
$.cache = c, $.concurrency = p, $.counters = k, $.simd = h, $.format = w, $.interpolators = d, $.versions = g, $.queue = n, $.block = u, $.unblock = I;
|
|
4052
|
-
}, Xe;
|
|
4053
|
-
}
|
|
4054
|
-
var Ve, Fr;
|
|
4055
|
-
function Ct() {
|
|
4056
|
-
if (Fr) return Ve;
|
|
4057
|
-
Fr = 1;
|
|
4058
|
-
const e = Pt();
|
|
4059
|
-
return Rt()(e), xt()(e), It()(e), $t()(e), Lt()(e), St()(e), kt()(e), Nt()(e), Ve = e, Ve;
|
|
4060
|
-
}
|
|
4061
|
-
var _t = Ct();
|
|
4062
|
-
const qt = /* @__PURE__ */ tt(_t);
|
|
4063
|
-
function Tt(e, i, P, y, b, S, R, w, d) {
|
|
48
|
+
function x(r, n, s, a, e, u, o, i, t) {
|
|
4064
49
|
switch (arguments.length) {
|
|
4065
50
|
case 1:
|
|
4066
|
-
return
|
|
51
|
+
return r;
|
|
4067
52
|
case 2:
|
|
4068
|
-
return
|
|
53
|
+
return n(r);
|
|
4069
54
|
case 3:
|
|
4070
|
-
return
|
|
55
|
+
return s(n(r));
|
|
4071
56
|
case 4:
|
|
4072
|
-
return
|
|
57
|
+
return a(s(n(r)));
|
|
4073
58
|
case 5:
|
|
4074
|
-
return
|
|
59
|
+
return e(a(s(n(r))));
|
|
4075
60
|
case 6:
|
|
4076
|
-
return
|
|
61
|
+
return u(e(a(s(n(r)))));
|
|
4077
62
|
case 7:
|
|
4078
|
-
return
|
|
63
|
+
return o(u(e(a(s(n(r))))));
|
|
4079
64
|
case 8:
|
|
4080
|
-
return
|
|
65
|
+
return i(o(u(e(a(s(n(r)))))));
|
|
4081
66
|
case 9:
|
|
4082
|
-
return
|
|
67
|
+
return t(i(o(u(e(a(s(n(r))))))));
|
|
4083
68
|
default: {
|
|
4084
|
-
for (var
|
|
4085
|
-
|
|
4086
|
-
return
|
|
69
|
+
for (var c = arguments[0], f = 1; f < arguments.length; f++)
|
|
70
|
+
c = arguments[f](c);
|
|
71
|
+
return c;
|
|
4087
72
|
}
|
|
4088
73
|
}
|
|
4089
74
|
}
|
|
4090
|
-
async function
|
|
4091
|
-
cacheKey:
|
|
4092
|
-
body:
|
|
4093
|
-
meta:
|
|
4094
|
-
cacheDir:
|
|
75
|
+
async function A({
|
|
76
|
+
cacheKey: r,
|
|
77
|
+
body: n,
|
|
78
|
+
meta: s,
|
|
79
|
+
cacheDir: a
|
|
4095
80
|
}) {
|
|
4096
|
-
const { dir:
|
|
4097
|
-
cacheKey:
|
|
4098
|
-
cacheDir:
|
|
81
|
+
const { dir: e, bodyPath: u, metaPath: o } = P({
|
|
82
|
+
cacheKey: r,
|
|
83
|
+
cacheDir: a
|
|
4099
84
|
});
|
|
4100
|
-
await
|
|
4101
|
-
const
|
|
85
|
+
await m.mkdir(e, { recursive: !0 });
|
|
86
|
+
const i = `${process.pid}-${Date.now()}-${Math.random().toString(16).slice(2)}`, t = `${u}.${i}.tmp`, c = `${o}.${i}.tmp`;
|
|
4102
87
|
await Promise.all([
|
|
4103
|
-
|
|
4104
|
-
|
|
88
|
+
m.writeFile(t, n),
|
|
89
|
+
m.writeFile(c, JSON.stringify(s), "utf8")
|
|
4105
90
|
]), await Promise.all([
|
|
4106
|
-
|
|
4107
|
-
|
|
91
|
+
m.rename(t, u),
|
|
92
|
+
m.rename(c, o)
|
|
4108
93
|
]);
|
|
4109
94
|
}
|
|
4110
|
-
const
|
|
4111
|
-
apiRouteUrl:
|
|
4112
|
-
cacheDir:
|
|
4113
|
-
cacheControl:
|
|
4114
|
-
allowedHosts:
|
|
95
|
+
const O = ({
|
|
96
|
+
apiRouteUrl: r,
|
|
97
|
+
cacheDir: n = h.join(process.cwd(), ".transform-cache"),
|
|
98
|
+
cacheControl: s = "public, max-age=31536000, immutable",
|
|
99
|
+
allowedHosts: a
|
|
4115
100
|
}) => {
|
|
4116
|
-
const
|
|
4117
|
-
if (!
|
|
4118
|
-
const
|
|
4119
|
-
return
|
|
4120
|
-
if (
|
|
4121
|
-
return
|
|
4122
|
-
const
|
|
4123
|
-
return
|
|
101
|
+
const e = B({ apiRouteUrl: r }), u = (o) => {
|
|
102
|
+
if (!a) return !0;
|
|
103
|
+
const i = o.hostname.toLowerCase(), t = o.host.toLowerCase();
|
|
104
|
+
return a.some((c) => {
|
|
105
|
+
if (c instanceof RegExp)
|
|
106
|
+
return c.test(i) || c.test(t);
|
|
107
|
+
const f = c.toLowerCase();
|
|
108
|
+
return f.includes(":") ? t === f : i === f;
|
|
4124
109
|
});
|
|
4125
110
|
};
|
|
4126
|
-
return async function(
|
|
4127
|
-
const { data:
|
|
4128
|
-
if (
|
|
111
|
+
return async function(i) {
|
|
112
|
+
const { data: t, error: c } = e.safeDecode(i.url);
|
|
113
|
+
if (c)
|
|
4129
114
|
return new Response("Bad Request", { status: 400 });
|
|
4130
|
-
const
|
|
115
|
+
const f = e.encode(
|
|
4131
116
|
// encode() accepts the decoded transform config shape; we only call this
|
|
4132
117
|
// after decoding has succeeded.
|
|
4133
|
-
|
|
4134
|
-
),
|
|
4135
|
-
if (
|
|
4136
|
-
return new Response(
|
|
118
|
+
t
|
|
119
|
+
), y = t.q ?? 100, g = j({ canonicalUrl: f }), d = await q({ cacheKey: g, cacheDir: n });
|
|
120
|
+
if (d)
|
|
121
|
+
return new Response(d.body, {
|
|
4137
122
|
headers: {
|
|
4138
|
-
"Content-Type":
|
|
4139
|
-
"Cache-Control":
|
|
123
|
+
"Content-Type": d.contentType,
|
|
124
|
+
"Cache-Control": s
|
|
4140
125
|
}
|
|
4141
126
|
});
|
|
4142
|
-
let
|
|
127
|
+
let l;
|
|
4143
128
|
try {
|
|
4144
|
-
|
|
129
|
+
l = new URL(t.source);
|
|
4145
130
|
} catch {
|
|
4146
131
|
return new Response("Bad Request", { status: 400 });
|
|
4147
132
|
}
|
|
4148
|
-
if (
|
|
133
|
+
if (l.protocol !== "http:" && l.protocol !== "https:")
|
|
4149
134
|
return new Response("Bad Request", { status: 400 });
|
|
4150
|
-
if (
|
|
135
|
+
if (l.username || l.password)
|
|
4151
136
|
return new Response("Bad Request", { status: 400 });
|
|
4152
|
-
if (!
|
|
137
|
+
if (!u(l))
|
|
4153
138
|
return new Response("Forbidden", { status: 403 });
|
|
4154
|
-
const
|
|
4155
|
-
if (!
|
|
139
|
+
const w = await fetch(l);
|
|
140
|
+
if (!w.ok)
|
|
4156
141
|
return new Response("Upstream fetch failed", { status: 502 });
|
|
4157
|
-
const
|
|
4158
|
-
|
|
142
|
+
const v = b(Buffer.from(await w.arrayBuffer())), R = await x(
|
|
143
|
+
v,
|
|
4159
144
|
/**
|
|
4160
145
|
* auto-orient: read's the image's EXIF data and rotates it to the correct
|
|
4161
146
|
* orientation.
|
|
4162
147
|
*/
|
|
4163
|
-
(
|
|
148
|
+
(p) => p.rotate(),
|
|
4164
149
|
/**
|
|
4165
150
|
* Resize
|
|
4166
151
|
*/
|
|
4167
|
-
(
|
|
4168
|
-
width:
|
|
4169
|
-
height:
|
|
152
|
+
(p) => t.w || t.h ? p.resize({
|
|
153
|
+
width: t.w,
|
|
154
|
+
height: t.h,
|
|
4170
155
|
fit: "inside",
|
|
4171
156
|
withoutEnlargement: !0
|
|
4172
|
-
}) :
|
|
157
|
+
}) : p,
|
|
4173
158
|
/**
|
|
4174
159
|
* Change format
|
|
4175
160
|
*/
|
|
4176
|
-
(
|
|
4177
|
-
switch (
|
|
161
|
+
(p) => {
|
|
162
|
+
switch (t.fmt) {
|
|
4178
163
|
case "preserve":
|
|
4179
|
-
return
|
|
164
|
+
return p;
|
|
4180
165
|
case "avif":
|
|
4181
|
-
return
|
|
166
|
+
return p.avif({ quality: y });
|
|
4182
167
|
case "webp":
|
|
4183
|
-
return
|
|
168
|
+
return p.webp({ quality: y });
|
|
4184
169
|
default:
|
|
4185
|
-
throw new Error(`Unreachable case: ${
|
|
170
|
+
throw new Error(`Unreachable case: ${t.fmt}`);
|
|
4186
171
|
}
|
|
4187
172
|
}
|
|
4188
|
-
).toBuffer(),
|
|
4189
|
-
switch (
|
|
173
|
+
).toBuffer(), $ = new Uint8Array(R), T = (() => {
|
|
174
|
+
switch (t.fmt) {
|
|
4190
175
|
case "preserve":
|
|
4191
|
-
return
|
|
176
|
+
return w.headers.get("content-type") ?? "application/octet-stream";
|
|
4192
177
|
case "avif":
|
|
4193
178
|
return "image/avif";
|
|
4194
179
|
case "webp":
|
|
4195
180
|
return "image/webp";
|
|
4196
181
|
}
|
|
4197
182
|
})();
|
|
4198
|
-
return await
|
|
4199
|
-
cacheKey:
|
|
4200
|
-
body:
|
|
4201
|
-
meta: { contentType:
|
|
4202
|
-
cacheDir:
|
|
4203
|
-
}), new Response(
|
|
183
|
+
return await A({
|
|
184
|
+
cacheKey: g,
|
|
185
|
+
body: R,
|
|
186
|
+
meta: { contentType: T },
|
|
187
|
+
cacheDir: n
|
|
188
|
+
}), new Response($, {
|
|
4204
189
|
headers: {
|
|
4205
|
-
"Content-Type":
|
|
4206
|
-
"Cache-Control":
|
|
190
|
+
"Content-Type": T,
|
|
191
|
+
"Cache-Control": s
|
|
4207
192
|
}
|
|
4208
193
|
});
|
|
4209
194
|
};
|
|
4210
195
|
};
|
|
4211
196
|
export {
|
|
4212
|
-
|
|
197
|
+
O as createImageTransformRouteHandler
|
|
4213
198
|
};
|