@digipair/skill-pdf2pic 0.114.1 → 0.114.3

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/index.esm.js CHANGED
@@ -1,4 +1,4548 @@
1
- import { fromBuffer } from 'pdf2pic';
1
+ import require$$4 from 'stream';
2
+ import require$$1$1 from 'events';
3
+ import require$$1 from 'util';
4
+ import require$$0 from 'fs';
5
+ import require$$0$2 from 'child_process';
6
+ import require$$0$1 from 'path';
7
+ import require$$0$3 from 'tty';
8
+
9
+ var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};
10
+ function getDefaultExportFromCjs(x) {
11
+ return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x;
12
+ }
13
+
14
+ var gm = {
15
+ exports: {}
16
+ };
17
+
18
+ var options = {
19
+ exports: {}
20
+ };
21
+
22
+ var hasRequiredOptions;
23
+
24
+ function requireOptions () {
25
+ if (hasRequiredOptions) return options.exports;
26
+ hasRequiredOptions = 1;
27
+ (function (module, exports) {
28
+ module.exports = function exports1(proto) {
29
+ proto._options = {};
30
+ proto.options = function setOptions(options) {
31
+ var keys = Object.keys(options), i = keys.length, key;
32
+ while(i--){
33
+ key = keys[i];
34
+ this._options[key] = options[key];
35
+ }
36
+ return this;
37
+ };
38
+ };
39
+ } (options));
40
+ return options.exports;
41
+ }
42
+
43
+ /**
44
+ * Extend proto.
45
+ */
46
+
47
+ var getters;
48
+ var hasRequiredGetters;
49
+
50
+ function requireGetters () {
51
+ if (hasRequiredGetters) return getters;
52
+ hasRequiredGetters = 1;
53
+ getters = function(gm) {
54
+ var proto = gm.prototype;
55
+ /**
56
+ * `identify` states
57
+ */ var IDENTIFYING = 1;
58
+ var IDENTIFIED = 2;
59
+ /**
60
+ * Map getter functions to output names.
61
+ *
62
+ * - format: specifying the -format argument (see man gm)
63
+ * - verbose: use -verbose instead of -format (only if necessary b/c its slow)
64
+ * - helper: use the conversion helper
65
+ */ var map = {
66
+ 'format': {
67
+ key: 'format',
68
+ format: '%m ',
69
+ helper: 'Format'
70
+ },
71
+ 'depth': {
72
+ key: 'depth',
73
+ format: '%q'
74
+ },
75
+ 'filesize': {
76
+ key: 'Filesize',
77
+ format: '%b'
78
+ },
79
+ 'size': {
80
+ key: 'size',
81
+ format: '%wx%h ',
82
+ helper: 'Geometry'
83
+ },
84
+ 'color': {
85
+ key: 'color',
86
+ format: '%k',
87
+ helper: 'Colors'
88
+ },
89
+ 'orientation': {
90
+ key: 'Orientation',
91
+ format: '%[EXIF:Orientation]',
92
+ helper: 'Orientation'
93
+ },
94
+ 'res': {
95
+ key: 'Resolution',
96
+ verbose: true
97
+ }
98
+ };
99
+ /**
100
+ * Getter functions
101
+ */ Object.keys(map).forEach(function(getter) {
102
+ proto[getter] = function(opts, callback) {
103
+ if (!callback) callback = opts, opts = {};
104
+ if (!callback) return this;
105
+ var val = map[getter], key = val.key, self = this;
106
+ if (self.data[key]) {
107
+ callback.call(self, null, self.data[key]);
108
+ return self;
109
+ }
110
+ self.on(getter, callback);
111
+ self.bufferStream = !!opts.bufferStream;
112
+ if (val.verbose) {
113
+ self.identify(opts, function(err, stdout, stderr, cmd) {
114
+ if (err) {
115
+ self.emit(getter, err, self.data[key], stdout, stderr, cmd);
116
+ } else {
117
+ self.emit(getter, err, self.data[key]);
118
+ }
119
+ });
120
+ return self;
121
+ }
122
+ var args = makeArgs(self, val);
123
+ self._exec(args, function(err, stdout, stderr, cmd) {
124
+ if (err) {
125
+ self.emit(getter, err, self.data[key], stdout, stderr, cmd);
126
+ return;
127
+ }
128
+ var result = (stdout || '').trim();
129
+ if (val.helper in helper) {
130
+ helper[val.helper](self.data, result);
131
+ } else {
132
+ self.data[key] = result;
133
+ }
134
+ self.emit(getter, err, self.data[key]);
135
+ });
136
+ return self;
137
+ };
138
+ });
139
+ /**
140
+ * identify command
141
+ *
142
+ * Overwrites all internal data with the parsed output
143
+ * which is more accurate than the fast shortcut
144
+ * getters.
145
+ */ proto.identify = function identify(opts, callback) {
146
+ // identify with pattern
147
+ if (typeof opts === 'string') {
148
+ opts = {
149
+ format: opts
150
+ };
151
+ }
152
+ if (!callback) callback = opts, opts = {};
153
+ if (!callback) return this;
154
+ if (opts && opts.format) return identifyPattern.call(this, opts, callback);
155
+ var self = this;
156
+ if (IDENTIFIED === self._identifyState) {
157
+ callback.call(self, null, self.data);
158
+ return self;
159
+ }
160
+ self.on('identify', callback);
161
+ if (IDENTIFYING === self._identifyState) {
162
+ return self;
163
+ }
164
+ self._identifyState = IDENTIFYING;
165
+ self.bufferStream = !!opts.bufferStream;
166
+ var args = makeArgs(self, {
167
+ verbose: true
168
+ });
169
+ self._exec(args, function(err, stdout, stderr, cmd) {
170
+ if (err) {
171
+ self.emit('identify', err, self.data, stdout, stderr, cmd);
172
+ return;
173
+ }
174
+ err = parse(stdout, self);
175
+ if (err) {
176
+ self.emit('identify', err, self.data, stdout, stderr, cmd);
177
+ return;
178
+ }
179
+ self.data.path = self.source;
180
+ self.emit('identify', null, self.data);
181
+ self._identifyState = IDENTIFIED;
182
+ });
183
+ return self;
184
+ };
185
+ /**
186
+ * identify with pattern
187
+ *
188
+ * Execute `identify -format` with custom pattern
189
+ */ function identifyPattern(opts, callback) {
190
+ var self = this;
191
+ self.bufferStream = !!opts.bufferStream;
192
+ var args = makeArgs(self, opts);
193
+ self._exec(args, function(err, stdout, stderr, cmd) {
194
+ if (err) {
195
+ return callback.call(self, err, undefined, stdout, stderr, cmd);
196
+ }
197
+ callback.call(self, err, (stdout || '').trim());
198
+ });
199
+ return self;
200
+ }
201
+ /**
202
+ * Parses `identify` responses.
203
+ *
204
+ * @param {String} stdout
205
+ * @param {Gm} self
206
+ * @return {Error} [optionally]
207
+ */ function parse(stdout, self) {
208
+ // normalize
209
+ var parts = (stdout || "").trim().replace(/\r\n|\r/g, "\n").split("\n");
210
+ // skip the first line (its just the filename)
211
+ parts.shift();
212
+ try {
213
+ var len = parts.length, rgx1 = /^( *)(.+?): (.*)$/ // key: val
214
+ , rgx2 = /^( *)(.+?):$/ // key: begin nested object
215
+ , out = {
216
+ indent: {}
217
+ }, level = null, lastkey, i = 0, res, o;
218
+ for(; i < len; ++i){
219
+ res = rgx1.exec(parts[i]) || rgx2.exec(parts[i]);
220
+ if (!res) continue;
221
+ var indent = res[1].length, key = res[2] ? res[2].trim() : '';
222
+ if ('Image' == key || 'Warning' == key) continue;
223
+ var val = res[3] ? res[3].trim() : null;
224
+ // first iteration?
225
+ if (null === level) {
226
+ level = indent;
227
+ o = out.root = out.indent[level] = self.data;
228
+ } else if (indent < level) {
229
+ // outdent
230
+ if (!(indent in out.indent)) {
231
+ continue;
232
+ }
233
+ o = out.indent[indent];
234
+ } else if (indent > level) {
235
+ // dropping into a nested object
236
+ out.indent[level] = o;
237
+ // weird format, key/val pair with nested children. discard the val
238
+ o = o[lastkey] = {};
239
+ }
240
+ level = indent;
241
+ if (val) {
242
+ // if previous key was exist and we got the same key
243
+ // cast it to an array.
244
+ if (o.hasOwnProperty(key)) {
245
+ // cast it to an array and dont forget the previous value
246
+ if (!Array.isArray(o[key])) {
247
+ var tmp = o[key];
248
+ o[key] = [
249
+ tmp
250
+ ];
251
+ }
252
+ // set value
253
+ o[key].push(val);
254
+ } else {
255
+ o[key] = val;
256
+ }
257
+ if (key in helper) {
258
+ helper[key](o, val);
259
+ }
260
+ }
261
+ lastkey = key;
262
+ }
263
+ } catch (err) {
264
+ err.message = err.message + "\n\n Identify stdout:\n " + stdout;
265
+ return err;
266
+ }
267
+ }
268
+ /**
269
+ * Create an argument array for the identify command.
270
+ *
271
+ * @param {gm} self
272
+ * @param {Object} val
273
+ * @return {Array}
274
+ */ function makeArgs(self, val) {
275
+ var args = [
276
+ 'identify',
277
+ '-ping'
278
+ ];
279
+ if (val.format) {
280
+ args.push('-format', val.format);
281
+ }
282
+ if (val.verbose) {
283
+ args.push('-verbose');
284
+ }
285
+ args = args.concat(self.src());
286
+ return args;
287
+ }
288
+ /**
289
+ * Map exif orientation codes to orientation names.
290
+ */ var orientations = {
291
+ '1': 'TopLeft',
292
+ '2': 'TopRight',
293
+ '3': 'BottomRight',
294
+ '4': 'BottomLeft',
295
+ '5': 'LeftTop',
296
+ '6': 'RightTop',
297
+ '7': 'RightBottom',
298
+ '8': 'LeftBottom'
299
+ };
300
+ /**
301
+ * identify -verbose helpers
302
+ */ var helper = gm.identifyHelpers = {};
303
+ helper.Geometry = function Geometry(o, val) {
304
+ // We only want the size of the first frame.
305
+ // Each frame is separated by a space.
306
+ var split = val.split(" ").shift().split("x");
307
+ var width = parseInt(split[0], 10);
308
+ var height = parseInt(split[1], 10);
309
+ if (o.size && o.size.width && o.size.height) {
310
+ if (width > o.size.width) o.size.width = width;
311
+ if (height > o.size.height) o.size.height = height;
312
+ } else {
313
+ o.size = {
314
+ width: width,
315
+ height: height
316
+ };
317
+ }
318
+ };
319
+ helper.Format = function Format(o, val) {
320
+ o.format = val.split(" ")[0];
321
+ };
322
+ helper.Depth = function Depth(o, val) {
323
+ o.depth = parseInt(val, 10);
324
+ };
325
+ helper.Colors = function Colors(o, val) {
326
+ o.color = parseInt(val, 10);
327
+ };
328
+ helper.Orientation = function Orientation(o, val) {
329
+ if (val in orientations) {
330
+ o['Profile-EXIF'] || (o['Profile-EXIF'] = {});
331
+ o['Profile-EXIF'].Orientation = val;
332
+ o.Orientation = orientations[val];
333
+ } else {
334
+ o.Orientation = val || 'Unknown';
335
+ }
336
+ };
337
+ };
338
+ return getters;
339
+ }
340
+
341
+ var utils$7 = {};
342
+
343
+ /**
344
+ * Escape the given shell `arg`.
345
+ *
346
+ * @param {String} arg
347
+ * @return {String}
348
+ * @api public
349
+ */
350
+
351
+ var hasRequiredUtils;
352
+
353
+ function requireUtils () {
354
+ if (hasRequiredUtils) return utils$7;
355
+ hasRequiredUtils = 1;
356
+ utils$7.escape = function escape(arg) {
357
+ return '"' + String(arg).trim().replace(/"/g, '\\"') + '"';
358
+ };
359
+ utils$7.unescape = function escape(arg) {
360
+ return String(arg).trim().replace(/"/g, "");
361
+ };
362
+ utils$7.argsToArray = function(args) {
363
+ var arr = [];
364
+ for(var i = 0; i <= arguments.length; i++){
365
+ if ('undefined' != typeof arguments[i]) arr.push(arguments[i]);
366
+ }
367
+ return arr;
368
+ };
369
+ utils$7.isUtil = function(v) {
370
+ var ty = 'object';
371
+ switch(Object.prototype.toString.call(v)){
372
+ case '[object String]':
373
+ ty = 'String';
374
+ break;
375
+ case '[object Array]':
376
+ ty = 'Array';
377
+ break;
378
+ case '[object Boolean]':
379
+ ty = 'Boolean';
380
+ break;
381
+ }
382
+ return ty;
383
+ };
384
+ return utils$7;
385
+ }
386
+
387
+ /**
388
+ * Dependencies
389
+ */
390
+
391
+ var args;
392
+ var hasRequiredArgs;
393
+
394
+ function requireArgs () {
395
+ if (hasRequiredArgs) return args;
396
+ hasRequiredArgs = 1;
397
+ var argsToArray = requireUtils().argsToArray;
398
+ var isUtil = requireUtils().isUtil;
399
+ /**
400
+ * Extend proto
401
+ */ args = function(proto) {
402
+ // change the specified frame.
403
+ // See #202.
404
+ proto.selectFrame = function(frame) {
405
+ if (typeof frame === 'number') this.sourceFrames = '[' + frame + ']';
406
+ return this;
407
+ };
408
+ // define the sub-command to use, http://www.graphicsmagick.org/utilities.html
409
+ proto.command = proto.subCommand = function subCommand(name) {
410
+ this._subCommand = name;
411
+ return this;
412
+ };
413
+ // http://www.graphicsmagick.org/GraphicsMagick.html#details-adjoin
414
+ proto.adjoin = function adjoin() {
415
+ return this.out("-adjoin");
416
+ };
417
+ // http://www.graphicsmagick.org/GraphicsMagick.html#details-affine
418
+ proto.affine = function affine(matrix) {
419
+ return this.out("-affine", matrix);
420
+ };
421
+ proto.alpha = function alpha(type) {
422
+ if (!this._options.imageMagick) return new Error('Method -alpha is not supported by GraphicsMagick');
423
+ return this.out('-alpha', type);
424
+ };
425
+ /**
426
+ * Appends images to the list of "source" images.
427
+ *
428
+ * We may also specify either top-to-bottom or left-to-right
429
+ * behavior of the appending by passing a boolean argument.
430
+ *
431
+ * Examples:
432
+ *
433
+ * img = gm(src);
434
+ *
435
+ * // +append means left-to-right
436
+ * img.append(img1, img2) gm convert src img1 img2 -append
437
+ * img.append(img, true) gm convert src img +append
438
+ * img.append(img, false) gm convert src img -append
439
+ * img.append(img) gm convert src img -append
440
+ * img.append(img).append() gm convert src img -append
441
+ * img.append(img).append(true) gm convert src img +append
442
+ * img.append(img).append(true) gm convert src img +append
443
+ * img.append(img).background('#222) gm convert src img -background #222 +append
444
+ * img.append([img1,img2...],true)
445
+
446
+ * @param {String} or {Array} [img]
447
+ * @param {Boolean} [ltr]
448
+ * @see http://www.graphicsmagick.org/GraphicsMagick.html#details-append
449
+ */ proto.append = function append(img, ltr) {
450
+ if (!this._append) {
451
+ this._append = [];
452
+ this.addSrcFormatter(function(src) {
453
+ this.out(this._append.ltr ? '+append' : '-append');
454
+ src.push.apply(src, this._append);
455
+ });
456
+ }
457
+ if (0 === arguments.length) {
458
+ this._append.ltr = false;
459
+ return this;
460
+ }
461
+ for(var i = 0; i < arguments.length; ++i){
462
+ var arg = arguments[i];
463
+ switch(isUtil(arg)){
464
+ case 'Boolean':
465
+ this._append.ltr = arg;
466
+ break;
467
+ case 'String':
468
+ this._append.push(arg);
469
+ break;
470
+ case 'Array':
471
+ for(var j = 0, len = arg.length; j < len; j++){
472
+ if (isUtil(arg[j]) == 'String') {
473
+ this._append.push(arg[j]);
474
+ }
475
+ }
476
+ break;
477
+ }
478
+ }
479
+ return this;
480
+ };
481
+ // http://www.graphicsmagick.org/GraphicsMagick.html#details-authenticate
482
+ proto.authenticate = function authenticate(string) {
483
+ return this.out("-authenticate", string);
484
+ };
485
+ // http://www.graphicsmagick.org/GraphicsMagick.html#details-average
486
+ proto.average = function average() {
487
+ return this.out("-average");
488
+ };
489
+ // http://www.graphicsmagick.org/GraphicsMagick.html#details-backdrop
490
+ proto.backdrop = function backdrop() {
491
+ return this.out("-backdrop");
492
+ };
493
+ // http://www.graphicsmagick.org/GraphicsMagick.html#details-black-threshold
494
+ proto.blackThreshold = function blackThreshold(red, green, blue, opacity) {
495
+ return this.out("-black-threshold", argsToArray(red, green, blue, opacity).join(','));
496
+ };
497
+ // http://www.graphicsmagick.org/GraphicsMagick.html#details-blue-primary
498
+ proto.bluePrimary = function bluePrimary(x, y) {
499
+ return this.out("-blue-primary", argsToArray(x, y).join(','));
500
+ };
501
+ // http://www.graphicsmagick.org/GraphicsMagick.html#details-border
502
+ proto.border = function border(width, height) {
503
+ return this.out("-border", width + "x" + height);
504
+ };
505
+ // http://www.graphicsmagick.org/GraphicsMagick.html#details-bordercolor
506
+ proto.borderColor = function borderColor(color) {
507
+ return this.out("-bordercolor", color);
508
+ };
509
+ // http://www.graphicsmagick.org/GraphicsMagick.html#details-box
510
+ proto.box = function box(color) {
511
+ return this.out("-box", color);
512
+ };
513
+ // http://www.graphicsmagick.org/GraphicsMagick.html#details-channel
514
+ proto.channel = function channel(type) {
515
+ return this.out("-channel", type);
516
+ };
517
+ // http://www.graphicsmagick.org/GraphicsMagick.html#details-chop
518
+ proto.chop = function chop(w, h, x, y) {
519
+ return this.in("-chop", w + "x" + h + "+" + (x || 0) + "+" + (y || 0));
520
+ };
521
+ // http://www.graphicsmagick.org/GraphicsMagick.html#details-clip
522
+ proto.clip = function clip() {
523
+ return this.out("-clip");
524
+ };
525
+ // http://www.graphicsmagick.org/GraphicsMagick.html#details-coalesce
526
+ proto.coalesce = function coalesce() {
527
+ return this.out("-coalesce");
528
+ };
529
+ // http://www.graphicsmagick.org/GraphicsMagick.html#details-colorize
530
+ proto.colorize = function colorize(r, g, b) {
531
+ return this.out("-colorize", [
532
+ r,
533
+ g,
534
+ b
535
+ ].join(","));
536
+ };
537
+ // http://www.graphicsmagick.org/GraphicsMagick.html#details-colormap
538
+ proto.colorMap = function colorMap(type) {
539
+ return this.out("-colormap", type);
540
+ };
541
+ // http://www.graphicsmagick.org/GraphicsMagick.html#details-compose
542
+ proto.compose = function compose(operator) {
543
+ return this.out("-compose", operator);
544
+ };
545
+ // http://www.graphicsmagick.org/GraphicsMagick.html#details-compress
546
+ proto.compress = function compress(type) {
547
+ return this.out("-compress", type);
548
+ };
549
+ // http://www.graphicsmagick.org/GraphicsMagick.html#details-kernel
550
+ proto.convolve = function convolve(kernel) {
551
+ return this.out("-convolve", kernel);
552
+ };
553
+ // http://www.graphicsmagick.org/GraphicsMagick.html#details-create-directories
554
+ proto.createDirectories = function createDirectories() {
555
+ return this.out("-create-directories");
556
+ };
557
+ // http://www.graphicsmagick.org/GraphicsMagick.html#details-deconstruct
558
+ proto.deconstruct = function deconstruct() {
559
+ return this.out("-deconstruct");
560
+ };
561
+ // http://www.graphicsmagick.org/GraphicsMagick.html#details-define
562
+ proto.define = function define(value) {
563
+ return this.out("-define", value);
564
+ };
565
+ // http://www.graphicsmagick.org/GraphicsMagick.html#details-delay
566
+ proto.delay = function delay(value) {
567
+ return this.out("-delay", value);
568
+ };
569
+ // http://www.graphicsmagick.org/GraphicsMagick.html#details-displace
570
+ proto.displace = function displace(horizontalScale, verticalScale) {
571
+ return this.out("-displace", horizontalScale + 'x' + verticalScale);
572
+ };
573
+ // http://www.graphicsmagick.org/GraphicsMagick.html#details-display
574
+ proto.display = function display(value) {
575
+ return this.out("-display", value);
576
+ };
577
+ // http://www.graphicsmagick.org/GraphicsMagick.html#details-dispose
578
+ proto.dispose = function dispose(method) {
579
+ return this.out("-dispose", method);
580
+ };
581
+ // http://www.graphicsmagick.org/GraphicsMagick.html#details-dissolve
582
+ proto.dissolve = function dissolve(percent) {
583
+ return this.out("-dissolve", percent + '%');
584
+ };
585
+ // http://www.graphicsmagick.org/GraphicsMagick.html#details-encoding
586
+ proto.encoding = function encoding(type) {
587
+ return this.out("-encoding", type);
588
+ };
589
+ // http://www.graphicsmagick.org/GraphicsMagick.html#details-endian
590
+ proto.endian = function endian(type) {
591
+ return this.out("-endian", type);
592
+ };
593
+ // http://www.graphicsmagick.org/GraphicsMagick.html#details-file
594
+ proto.file = function file(filename) {
595
+ return this.out("-file", filename);
596
+ };
597
+ // http://www.graphicsmagick.org/GraphicsMagick.html#details-flatten
598
+ proto.flatten = function flatten() {
599
+ return this.out("-flatten");
600
+ };
601
+ // http://www.graphicsmagick.org/GraphicsMagick.html#details-foreground
602
+ proto.foreground = function foreground(color) {
603
+ return this.out("-foreground", color);
604
+ };
605
+ // http://www.graphicsmagick.org/GraphicsMagick.html#details-frame
606
+ proto.frame = function frame(width, height, outerBevelWidth, innerBevelWidth) {
607
+ if (arguments.length == 0) return this.out("-frame");
608
+ return this.out("-frame", width + 'x' + height + '+' + outerBevelWidth + '+' + innerBevelWidth);
609
+ };
610
+ // http://www.graphicsmagick.org/GraphicsMagick.html#details-fuzz
611
+ proto.fuzz = function fuzz(distance, percent) {
612
+ return this.out("-fuzz", distance + (percent ? '%' : ''));
613
+ };
614
+ // http://www.graphicsmagick.org/GraphicsMagick.html#details-gaussian
615
+ proto.gaussian = function gaussian(radius, sigma) {
616
+ return this.out("-gaussian", argsToArray(radius, sigma).join('x'));
617
+ };
618
+ // http://www.graphicsmagick.org/GraphicsMagick.html#details-geometry
619
+ proto.geometry = function geometry(width, height, arg) {
620
+ // If the first argument is a string, and there is only one argument, this is a custom geometry command.
621
+ if (arguments.length == 1 && typeof arguments[0] === "string") return this.out("-geometry", arguments[0]);
622
+ // Otherwise, return a resizing geometry command with an option alrgument.
623
+ return this.out("-geometry", width + 'x' + height + (arg || ''));
624
+ };
625
+ // http://www.graphicsmagick.org/GraphicsMagick.html#details-green-primary
626
+ proto.greenPrimary = function greenPrimary(x, y) {
627
+ return this.out("-green-primary", x + ',' + y);
628
+ };
629
+ // http://www.graphicsmagick.org/GraphicsMagick.html#details-highlight-color
630
+ proto.highlightColor = function highlightColor(color) {
631
+ return this.out("-highlight-color", color);
632
+ };
633
+ // http://www.graphicsmagick.org/GraphicsMagick.html#details-highlight-style
634
+ proto.highlightStyle = function highlightStyle(style) {
635
+ return this.out("-highlight-style", style);
636
+ };
637
+ // http://www.graphicsmagick.org/GraphicsMagick.html#details-iconGeometry
638
+ proto.iconGeometry = function iconGeometry(geometry) {
639
+ return this.out("-iconGeometry", geometry);
640
+ };
641
+ // http://www.graphicsmagick.org/GraphicsMagick.html#details-intent
642
+ proto.intent = function intent(type) {
643
+ return this.out("-intent", type);
644
+ };
645
+ // http://www.graphicsmagick.org/GraphicsMagick.html#details-lat
646
+ proto.lat = function lat(width, height, offset, percent) {
647
+ return this.out("-lat", width + 'x' + height + offset + (percent ? '%' : ''));
648
+ };
649
+ // http://www.graphicsmagick.org/GraphicsMagick.html#details-level
650
+ proto.level = function level(blackPoint, gamma, whitePoint, percent) {
651
+ return this.out("-level", argsToArray(blackPoint, gamma, whitePoint).join(',') + (percent ? '%' : ''));
652
+ };
653
+ // http://www.graphicsmagick.org/GraphicsMagick.html#details-list
654
+ proto.list = function list(type) {
655
+ return this.out("-list", type);
656
+ };
657
+ // http://www.graphicsmagick.org/GraphicsMagick.html#details-log
658
+ proto.log = function log(string) {
659
+ return this.out("-log", string);
660
+ };
661
+ // http://www.graphicsmagick.org/GraphicsMagick.html#details-loop
662
+ proto.loop = function loop(iterations) {
663
+ return this.out("-loop", iterations);
664
+ };
665
+ // http://www.graphicsmagick.org/GraphicsMagick.html#details-map
666
+ proto.map = function map(filename) {
667
+ return this.out("-map", filename);
668
+ };
669
+ // http://www.graphicsmagick.org/GraphicsMagick.html#details-mask
670
+ proto.mask = function mask(filename) {
671
+ return this.out("-mask", filename);
672
+ };
673
+ // http://www.graphicsmagick.org/GraphicsMagick.html#details-matte
674
+ proto.matte = function matte() {
675
+ return this.out("-matte");
676
+ };
677
+ // http://www.graphicsmagick.org/GraphicsMagick.html#details-mattecolor
678
+ proto.matteColor = function matteColor(color) {
679
+ return this.out("-mattecolor", color);
680
+ };
681
+ // http://www.graphicsmagick.org/GraphicsMagick.html#details-maximum-error
682
+ proto.maximumError = function maximumError(limit) {
683
+ return this.out("-maximum-error", limit);
684
+ };
685
+ // http://www.graphicsmagick.org/GraphicsMagick.html#details-mode
686
+ proto.mode = function mode(value) {
687
+ return this.out("-mode", value);
688
+ };
689
+ // http://www.graphicsmagick.org/GraphicsMagick.html#details-monitor
690
+ proto.monitor = function monitor() {
691
+ return this.out("-monitor");
692
+ };
693
+ // http://www.graphicsmagick.org/GraphicsMagick.html#details-mosaic
694
+ proto.mosaic = function mosaic() {
695
+ return this.out("-mosaic");
696
+ };
697
+ // http://www.graphicsmagick.org/GraphicsMagick.html#details-motion-blur
698
+ proto.motionBlur = function motionBlur(radius, sigma, angle) {
699
+ var arg = radius;
700
+ if (typeof sigma != 'undefined') arg += 'x' + sigma;
701
+ if (typeof angle != 'undefined') arg += '+' + angle;
702
+ return this.out("-motion-blur", arg);
703
+ };
704
+ // http://www.graphicsmagick.org/GraphicsMagick.html#details-name
705
+ proto.name = function name() {
706
+ return this.out("-name");
707
+ };
708
+ // http://www.graphicsmagick.org/GraphicsMagick.html#details-noop
709
+ proto.noop = function noop() {
710
+ return this.out("-noop");
711
+ };
712
+ // http://www.graphicsmagick.org/GraphicsMagick.html#details-normalize
713
+ proto.normalize = function normalize() {
714
+ return this.out("-normalize");
715
+ };
716
+ // http://www.graphicsmagick.org/GraphicsMagick.html#details-opaque
717
+ proto.opaque = function opaque(color) {
718
+ return this.out("-opaque", color);
719
+ };
720
+ // http://www.graphicsmagick.org/GraphicsMagick.html#details-operator
721
+ proto.operator = function operator(channel, operator, rvalue, percent) {
722
+ return this.out("-operator", channel, operator, rvalue + (percent ? '%' : ''));
723
+ };
724
+ // http://www.graphicsmagick.org/GraphicsMagick.html#details-ordered-dither
725
+ proto.orderedDither = function orderedDither(channeltype, NxN) {
726
+ return this.out("-ordered-dither", channeltype, NxN);
727
+ };
728
+ // http://www.graphicsmagick.org/GraphicsMagick.html#details-output-directory
729
+ proto.outputDirectory = function outputDirectory(directory) {
730
+ return this.out("-output-directory", directory);
731
+ };
732
+ // http://www.graphicsmagick.org/GraphicsMagick.html#details-page
733
+ proto.page = function page(width, height, arg) {
734
+ return this.out("-page", width + 'x' + height + (arg || ''));
735
+ };
736
+ // http://www.graphicsmagick.org/GraphicsMagick.html#details-pause
737
+ proto.pause = function pause(seconds) {
738
+ return this.out("-pause", seconds);
739
+ };
740
+ // http://www.graphicsmagick.org/GraphicsMagick.html#details-pen
741
+ proto.pen = function pen(color) {
742
+ return this.out("-pen", color);
743
+ };
744
+ // http://www.graphicsmagick.org/GraphicsMagick.html#details-ping
745
+ proto.ping = function ping() {
746
+ return this.out("-ping");
747
+ };
748
+ // http://www.graphicsmagick.org/GraphicsMagick.html#details-pointsize
749
+ proto.pointSize = function pointSize(value) {
750
+ return this.out("-pointsize", value);
751
+ };
752
+ // http://www.graphicsmagick.org/GraphicsMagick.html#details-preview
753
+ proto.preview = function preview(type) {
754
+ return this.out("-preview", type);
755
+ };
756
+ // http://www.graphicsmagick.org/GraphicsMagick.html#details-process
757
+ proto.process = function process(command) {
758
+ return this.out("-process", command);
759
+ };
760
+ // http://www.graphicsmagick.org/GraphicsMagick.html#details-profile
761
+ proto.profile = function profile(filename) {
762
+ return this.out("-profile", filename);
763
+ };
764
+ // http://www.graphicsmagick.org/GraphicsMagick.html#details-progress
765
+ proto.progress = function progress() {
766
+ return this.out("+progress");
767
+ };
768
+ // http://www.graphicsmagick.org/GraphicsMagick.html#details-random-threshold
769
+ proto.randomThreshold = function randomThreshold(channeltype, LOWxHIGH) {
770
+ return this.out("-random-threshold", channeltype, LOWxHIGH);
771
+ };
772
+ // http://www.graphicsmagick.org/GraphicsMagick.html#details-recolor
773
+ proto.recolor = function recolor(matrix) {
774
+ return this.out("-recolor", matrix);
775
+ };
776
+ // http://www.graphicsmagick.org/GraphicsMagick.html#details-red-primary
777
+ proto.redPrimary = function redPrimary(x, y) {
778
+ return this.out("-red-primary", x, y);
779
+ };
780
+ // http://www.graphicsmagick.org/GraphicsMagick.html#details-remote
781
+ proto.remote = function remote() {
782
+ return this.out("-remote");
783
+ };
784
+ // http://www.graphicsmagick.org/GraphicsMagick.html#details-render
785
+ proto.render = function render() {
786
+ return this.out("-render");
787
+ };
788
+ // http://www.graphicsmagick.org/GraphicsMagick.html#details-repage
789
+ proto.repage = function repage(width, height, xoff, yoff, arg) {
790
+ if (arguments[0] === "+") return this.out("+repage");
791
+ return this.out("-repage", width + 'x' + height + '+' + xoff + '+' + yoff + (arg || ''));
792
+ };
793
+ // http://www.graphicsmagick.org/GraphicsMagick.html#details-sample
794
+ proto.sample = function sample(geometry) {
795
+ return this.out("-sample", geometry);
796
+ };
797
+ // http://www.graphicsmagick.org/GraphicsMagick.html#details-sampling-factor
798
+ proto.samplingFactor = function samplingFactor(horizontalFactor, verticalFactor) {
799
+ return this.out("-sampling-factor", horizontalFactor + 'x' + verticalFactor);
800
+ };
801
+ // http://www.graphicsmagick.org/GraphicsMagick.html#details-scene
802
+ proto.scene = function scene(value) {
803
+ return this.out("-scene", value);
804
+ };
805
+ // http://www.graphicsmagick.org/GraphicsMagick.html#details-scenes
806
+ proto.scenes = function scenes(start, end) {
807
+ return this.out("-scenes", start + '-' + end);
808
+ };
809
+ // http://www.graphicsmagick.org/GraphicsMagick.html#details-screen
810
+ proto.screen = function screen() {
811
+ return this.out("-screen");
812
+ };
813
+ // http://www.graphicsmagick.org/GraphicsMagick.html#details-set
814
+ proto.set = function set(attribute, value) {
815
+ return this.out("-set", attribute, value);
816
+ };
817
+ // http://www.graphicsmagick.org/GraphicsMagick.html#details-segment
818
+ proto.segment = function segment(clusterThreshold, smoothingThreshold) {
819
+ return this.out("-segment", clusterThreshold + 'x' + smoothingThreshold);
820
+ };
821
+ // http://www.graphicsmagick.org/GraphicsMagick.html#details-shade
822
+ proto.shade = function shade(azimuth, elevation) {
823
+ return this.out("-shade", azimuth + 'x' + elevation);
824
+ };
825
+ // http://www.graphicsmagick.org/GraphicsMagick.html#details-shadow
826
+ proto.shadow = function shadow(radius, sigma) {
827
+ return this.out("-shadow", argsToArray(radius, sigma).join('x'));
828
+ };
829
+ // http://www.graphicsmagick.org/GraphicsMagick.html#details-shared-memory
830
+ proto.sharedMemory = function sharedMemory() {
831
+ return this.out("-shared-memory");
832
+ };
833
+ // http://www.graphicsmagick.org/GraphicsMagick.html#details-shave
834
+ proto.shave = function shave(width, height, percent) {
835
+ return this.out("-shave", width + 'x' + height + (percent ? '%' : ''));
836
+ };
837
+ // http://www.graphicsmagick.org/GraphicsMagick.html#details-shear
838
+ proto.shear = function shear(xDegrees, yDegreees) {
839
+ return this.out("-shear", xDegrees + 'x' + yDegreees);
840
+ };
841
+ // http://www.graphicsmagick.org/GraphicsMagick.html#details-silent
842
+ proto.silent = function silent(color) {
843
+ return this.out("-silent");
844
+ };
845
+ // http://www.graphicsmagick.org/GraphicsMagick.html#details-size
846
+ proto.rawSize = function rawSize(width, height, offset) {
847
+ var off = 'undefined' != typeof offset ? '+' + offset : '';
848
+ return this.out("-size", width + 'x' + height + off);
849
+ };
850
+ // http://www.graphicsmagick.org/GraphicsMagick.html#details-snaps
851
+ proto.snaps = function snaps(value) {
852
+ return this.out("-snaps", value);
853
+ };
854
+ // http://www.graphicsmagick.org/GraphicsMagick.html#details-stegano
855
+ proto.stegano = function stegano(offset) {
856
+ return this.out("-stegano", offset);
857
+ };
858
+ // http://www.graphicsmagick.org/GraphicsMagick.html#details-stereo
859
+ proto.stereo = function stereo() {
860
+ return this.out("-stereo");
861
+ };
862
+ // http://www.graphicsmagick.org/GraphicsMagick.html#details-text-font
863
+ proto.textFont = function textFont(name) {
864
+ return this.out("-text-font", name);
865
+ };
866
+ // http://www.graphicsmagick.org/GraphicsMagick.html#details-texture
867
+ proto.texture = function texture(filename) {
868
+ return this.out("-texture", filename);
869
+ };
870
+ // http://www.graphicsmagick.org/GraphicsMagick.html#details-threshold
871
+ proto.threshold = function threshold(value, percent) {
872
+ return this.out("-threshold", value + (percent ? '%' : ''));
873
+ };
874
+ // http://www.graphicsmagick.org/GraphicsMagick.html#details-thumbnail
875
+ proto.thumbnail = function thumbnail(w, h, options) {
876
+ options = options || "";
877
+ var geometry, wIsValid = Boolean(w || w === 0), hIsValid = Boolean(h || h === 0);
878
+ if (wIsValid && hIsValid) {
879
+ geometry = w + "x" + h + options;
880
+ } else if (wIsValid) {
881
+ // GraphicsMagick requires <width>x<options>, ImageMagick requires <width><options>
882
+ geometry = this._options.imageMagick ? w + options : w + 'x' + options;
883
+ } else if (hIsValid) {
884
+ geometry = 'x' + h + options;
885
+ } else {
886
+ return this;
887
+ }
888
+ return this.out("-thumbnail", geometry);
889
+ };
890
+ // http://www.graphicsmagick.org/GraphicsMagick.html#details-tile
891
+ proto.tile = function tile(filename) {
892
+ return this.out("-tile", filename);
893
+ };
894
+ // http://www.graphicsmagick.org/GraphicsMagick.html#details-title
895
+ proto.title = function title(string) {
896
+ return this.out("-title", string);
897
+ };
898
+ // http://www.graphicsmagick.org/GraphicsMagick.html#details-transform
899
+ proto.transform = function transform(color) {
900
+ return this.out("-transform", color);
901
+ };
902
+ // http://www.graphicsmagick.org/GraphicsMagick.html#details-transparent
903
+ proto.transparent = function transparent(color) {
904
+ return this.out("-transparent", color);
905
+ };
906
+ // http://www.graphicsmagick.org/GraphicsMagick.html#details-treedepth
907
+ proto.treeDepth = function treeDepth(value) {
908
+ return this.out("-treedepth", value);
909
+ };
910
+ // http://www.graphicsmagick.org/GraphicsMagick.html#details-update
911
+ proto.update = function update(seconds) {
912
+ return this.out("-update", seconds);
913
+ };
914
+ // http://www.graphicsmagick.org/GraphicsMagick.html#details-units
915
+ proto.units = function units(type) {
916
+ return this.out("-units", type);
917
+ };
918
+ // http://www.graphicsmagick.org/GraphicsMagick.html#details-unsharp
919
+ proto.unsharp = function unsharp(radius, sigma, amount, threshold) {
920
+ var arg = radius;
921
+ if (typeof sigma != 'undefined') arg += 'x' + sigma;
922
+ if (typeof amount != 'undefined') arg += '+' + amount;
923
+ if (typeof threshold != 'undefined') arg += '+' + threshold;
924
+ return this.out("-unsharp", arg);
925
+ };
926
+ // http://www.graphicsmagick.org/GraphicsMagick.html#details-use-pixmap
927
+ proto.usePixmap = function usePixmap() {
928
+ return this.out("-use-pixmap");
929
+ };
930
+ // http://www.graphicsmagick.org/GraphicsMagick.html#details-view
931
+ proto.view = function view(string) {
932
+ return this.out("-view", string);
933
+ };
934
+ // http://www.graphicsmagick.org/GraphicsMagick.html#details-virtual-pixel
935
+ proto.virtualPixel = function virtualPixel(method) {
936
+ return this.out("-virtual-pixel", method);
937
+ };
938
+ // http://www.graphicsmagick.org/GraphicsMagick.html#details-visual
939
+ proto.visual = function visual(type) {
940
+ return this.out("-visual", type);
941
+ };
942
+ // http://www.graphicsmagick.org/GraphicsMagick.html#details-watermark
943
+ proto.watermark = function watermark(brightness, saturation) {
944
+ return this.out("-watermark", brightness + 'x' + saturation);
945
+ };
946
+ // http://www.graphicsmagick.org/GraphicsMagick.html#details-wave
947
+ proto.wave = function wave(amplitude, wavelength) {
948
+ return this.out("-wave", amplitude + 'x' + wavelength);
949
+ };
950
+ // http://www.graphicsmagick.org/GraphicsMagick.html#details-white-point
951
+ proto.whitePoint = function whitePoint(x, y) {
952
+ return this.out("-white-point", x + 'x' + y);
953
+ };
954
+ // http://www.graphicsmagick.org/GraphicsMagick.html#details-white-threshold
955
+ proto.whiteThreshold = function whiteThreshold(red, green, blue, opacity) {
956
+ return this.out("-white-threshold", argsToArray(red, green, blue, opacity).join(','));
957
+ };
958
+ // http://www.graphicsmagick.org/GraphicsMagick.html#details-window
959
+ proto.window = function window(id) {
960
+ return this.out("-window", id);
961
+ };
962
+ // http://www.graphicsmagick.org/GraphicsMagick.html#details-window-group
963
+ proto.windowGroup = function windowGroup() {
964
+ return this.out("-window-group");
965
+ };
966
+ // http://www.graphicsmagick.org/GraphicsMagick.html#details-strip (graphicsMagick >= 1.3.15)
967
+ proto.strip = function strip() {
968
+ if (this._options.imageMagick) return this.out("-strip");
969
+ return this.noProfile().out("+comment"); //Equivalent to "-strip" for all versions of graphicsMagick
970
+ };
971
+ // http://www.graphicsmagick.org/GraphicsMagick.html#details-interlace
972
+ proto.interlace = function interlace(type) {
973
+ return this.out("-interlace", type || "None");
974
+ };
975
+ // force output format
976
+ proto.setFormat = function setFormat(format) {
977
+ if (format) this._outputFormat = format;
978
+ return this;
979
+ };
980
+ // http://www.graphicsmagick.org/GraphicsMagick.html#details-resize
981
+ proto.resize = function resize(w, h, options) {
982
+ options = options || "";
983
+ var geometry, wIsValid = Boolean(w || w === 0), hIsValid = Boolean(h || h === 0);
984
+ if (wIsValid && hIsValid) {
985
+ geometry = w + "x" + h + options;
986
+ } else if (wIsValid) {
987
+ // GraphicsMagick requires <width>x<options>, ImageMagick requires <width><options>
988
+ geometry = this._options.imageMagick ? w + options : w + 'x' + options;
989
+ } else if (hIsValid) {
990
+ geometry = 'x' + h + options;
991
+ } else {
992
+ return this;
993
+ }
994
+ return this.out("-resize", geometry);
995
+ };
996
+ // http://www.graphicsmagick.org/GraphicsMagick.html#details-resize with '!' option
997
+ proto.resizeExact = function resize(w, h) {
998
+ var options = "!";
999
+ return proto.resize.apply(this, [
1000
+ w,
1001
+ h,
1002
+ options
1003
+ ]);
1004
+ };
1005
+ // http://www.graphicsmagick.org/GraphicsMagick.html#details-scale
1006
+ proto.scale = function scale(w, h, options) {
1007
+ options = options || "";
1008
+ var geometry;
1009
+ if (w && h) {
1010
+ geometry = w + "x" + h + options;
1011
+ } else if (w && !h) {
1012
+ geometry = this._options.imageMagick ? w + options : w + 'x' + options;
1013
+ } else if (!w && h) {
1014
+ geometry = 'x' + h + options;
1015
+ }
1016
+ return this.out("-scale", geometry);
1017
+ };
1018
+ // http://www.graphicsmagick.org/GraphicsMagick.html#details-filter
1019
+ proto.filter = function filter(val) {
1020
+ return this.out("-filter", val);
1021
+ };
1022
+ // http://www.graphicsmagick.org/GraphicsMagick.html#details-density
1023
+ proto.density = function density(w, h) {
1024
+ if (w && !h && this._options.imageMagick) {
1025
+ // GraphicsMagick requires <width>x<height>y, ImageMagick may take dpi<resolution>
1026
+ // recommended 300dpi for higher quality
1027
+ return this.in("-density", w);
1028
+ }
1029
+ return this.in("-density", w + "x" + h);
1030
+ };
1031
+ // http://www.graphicsmagick.org/GraphicsMagick.html#details-profile
1032
+ proto.noProfile = function noProfile() {
1033
+ this.out('+profile', '"*"');
1034
+ return this;
1035
+ };
1036
+ // http://www.graphicsmagick.org/GraphicsMagick.html#details-resample
1037
+ proto.resample = function resample(w, h) {
1038
+ return this.out("-resample", w + "x" + h);
1039
+ };
1040
+ // http://www.graphicsmagick.org/GraphicsMagick.html#details-rotate
1041
+ proto.rotate = function rotate(color, deg) {
1042
+ return this.out("-background", color, "-rotate", String(deg || 0));
1043
+ };
1044
+ // http://www.graphicsmagick.org/GraphicsMagick.html#details-flip
1045
+ proto.flip = function flip() {
1046
+ return this.out("-flip");
1047
+ };
1048
+ // http://www.graphicsmagick.org/GraphicsMagick.html#details-flop
1049
+ proto.flop = function flop() {
1050
+ return this.out("-flop");
1051
+ };
1052
+ // http://www.graphicsmagick.org/GraphicsMagick.html#details-crop
1053
+ proto.crop = function crop(w, h, x, y, percent) {
1054
+ if (this.inputIs('jpg')) {
1055
+ // avoid error "geometry does not contain image (unable to crop image)" - gh-17
1056
+ var index = this._in.indexOf('-size');
1057
+ if (~index) {
1058
+ this._in.splice(index, 2);
1059
+ }
1060
+ }
1061
+ return this.out("-crop", w + "x" + h + "+" + (x || 0) + "+" + (y || 0) + (percent ? '%' : ''));
1062
+ };
1063
+ // http://www.graphicsmagick.org/GraphicsMagick.html#details-magnify
1064
+ proto.magnify = function magnify(factor) {
1065
+ return this.in("-magnify");
1066
+ };
1067
+ // http://www.graphicsmagick.org/GraphicsMagick.html
1068
+ proto.minify = function minify() {
1069
+ return this.in("-minify");
1070
+ };
1071
+ // http://www.graphicsmagick.org/GraphicsMagick.html#details-quality
1072
+ proto.quality = function quality(val) {
1073
+ return this.in("-quality", val || 75);
1074
+ };
1075
+ // http://www.graphicsmagick.org/GraphicsMagick.html#details-blur
1076
+ proto.blur = function blur(radius, sigma) {
1077
+ return this.out("-blur", radius + (sigma ? "x" + sigma : ""));
1078
+ };
1079
+ // http://www.graphicsmagick.org/convert.html
1080
+ proto.charcoal = function charcoal(factor) {
1081
+ return this.out("-charcoal", factor || 2);
1082
+ };
1083
+ // http://www.graphicsmagick.org/GraphicsMagick.html#details-modulate
1084
+ proto.modulate = function modulate(b, s, h) {
1085
+ return this.out("-modulate", [
1086
+ b,
1087
+ s,
1088
+ h
1089
+ ].join(","));
1090
+ };
1091
+ // http://www.graphicsmagick.org/GraphicsMagick.html#details-antialias
1092
+ // note: antialiasing is enabled by default
1093
+ proto.antialias = function antialias(disable) {
1094
+ return false === disable ? this.out("+antialias") : this;
1095
+ };
1096
+ // http://www.graphicsmagick.org/GraphicsMagick.html#details-depth
1097
+ proto.bitdepth = function bitdepth(val) {
1098
+ return this.out("-depth", val);
1099
+ };
1100
+ // http://www.graphicsmagick.org/GraphicsMagick.html#details-colors
1101
+ proto.colors = function colors(val) {
1102
+ return this.out("-colors", val || 128);
1103
+ };
1104
+ // http://www.graphicsmagick.org/GraphicsMagick.html#details-colorspace
1105
+ proto.colorspace = function colorspace(val) {
1106
+ return this.out("-colorspace", val);
1107
+ };
1108
+ // http://www.graphicsmagick.org/GraphicsMagick.html#details-comment
1109
+ proto.comment = comment("-comment");
1110
+ // http://www.graphicsmagick.org/GraphicsMagick.html#details-contrast
1111
+ proto.contrast = function contrast(mult) {
1112
+ var arg = (parseInt(mult, 10) || 0) > 0 ? "+contrast" : "-contrast";
1113
+ mult = Math.abs(mult) || 1;
1114
+ while(mult--){
1115
+ this.out(arg);
1116
+ }
1117
+ return this;
1118
+ };
1119
+ // http://www.graphicsmagick.org/GraphicsMagick.html#details-cycle
1120
+ proto.cycle = function cycle(amount) {
1121
+ return this.out("-cycle", amount || 2);
1122
+ };
1123
+ // http://www.graphicsmagick.org/GraphicsMagick.html
1124
+ proto.despeckle = function despeckle() {
1125
+ return this.out("-despeckle");
1126
+ };
1127
+ // http://www.graphicsmagick.org/GraphicsMagick.html#details-dither
1128
+ // note: either colors() or monochrome() must be used for this
1129
+ // to take effect.
1130
+ proto.dither = function dither(on) {
1131
+ var sign = false === on ? "+" : "-";
1132
+ return this.out(sign + "dither");
1133
+ };
1134
+ // http://www.graphicsmagick.org/GraphicsMagick.html
1135
+ proto.monochrome = function monochrome() {
1136
+ return this.out("-monochrome");
1137
+ };
1138
+ // http://www.graphicsmagick.org/GraphicsMagick.html
1139
+ proto.edge = function edge(radius) {
1140
+ return this.out("-edge", radius || 1);
1141
+ };
1142
+ // http://www.graphicsmagick.org/GraphicsMagick.html
1143
+ proto.emboss = function emboss(radius) {
1144
+ return this.out("-emboss", radius || 1);
1145
+ };
1146
+ // http://www.graphicsmagick.org/GraphicsMagick.html
1147
+ proto.enhance = function enhance() {
1148
+ return this.out("-enhance");
1149
+ };
1150
+ // http://www.graphicsmagick.org/GraphicsMagick.html
1151
+ proto.equalize = function equalize() {
1152
+ return this.out("-equalize");
1153
+ };
1154
+ // http://www.graphicsmagick.org/GraphicsMagick.html#details-gamma
1155
+ proto.gamma = function gamma(r, g, b) {
1156
+ return this.out("-gamma", [
1157
+ r,
1158
+ g,
1159
+ b
1160
+ ].join());
1161
+ };
1162
+ // http://www.graphicsmagick.org/GraphicsMagick.html
1163
+ proto.implode = function implode(factor) {
1164
+ return this.out("-implode", factor || 1);
1165
+ };
1166
+ // http://www.graphicsmagick.org/GraphicsMagick.html#details-comment
1167
+ proto.label = comment("-label");
1168
+ var limits = [
1169
+ "disk",
1170
+ "file",
1171
+ "map",
1172
+ "memory",
1173
+ "pixels",
1174
+ "threads"
1175
+ ];
1176
+ // http://www.graphicsmagick.org/GraphicsMagick.html#details-limit
1177
+ proto.limit = function limit(type, val) {
1178
+ type = type.toLowerCase();
1179
+ if (!~limits.indexOf(type)) {
1180
+ return this;
1181
+ }
1182
+ return this.out("-limit", type, val);
1183
+ };
1184
+ // http://www.graphicsmagick.org/GraphicsMagick.html
1185
+ proto.median = function median(radius) {
1186
+ return this.out("-median", radius || 1);
1187
+ };
1188
+ // http://www.graphicsmagick.org/GraphicsMagick.html#details-negate
1189
+ proto.negative = function negative(grayscale) {
1190
+ var sign = grayscale ? "+" : "-";
1191
+ return this.out(sign + "negate");
1192
+ };
1193
+ var noises = [
1194
+ "uniform",
1195
+ "gaussian",
1196
+ "multiplicative",
1197
+ "impulse",
1198
+ "laplacian",
1199
+ "poisson"
1200
+ ];
1201
+ // http://www.graphicsmagick.org/GraphicsMagick.html#details-noise
1202
+ proto.noise = function noise(radius) {
1203
+ radius = String(radius).toLowerCase();
1204
+ var sign = ~noises.indexOf(radius) ? "+" : "-";
1205
+ return this.out(sign + "noise", radius);
1206
+ };
1207
+ // http://www.graphicsmagick.org/GraphicsMagick.html#details-paint
1208
+ proto.paint = function paint(radius) {
1209
+ return this.out("-paint", radius);
1210
+ };
1211
+ // http://www.graphicsmagick.org/GraphicsMagick.html#details-raise
1212
+ proto.raise = function raise(w, h) {
1213
+ return this.out("-raise", (w || 0) + "x" + (h || 0));
1214
+ };
1215
+ // http://www.graphicsmagick.org/GraphicsMagick.html#details-raise
1216
+ proto.lower = function lower(w, h) {
1217
+ return this.out("+raise", (w || 0) + "x" + (h || 0));
1218
+ };
1219
+ // http://www.graphicsmagick.org/GraphicsMagick.html#details-region
1220
+ proto.region = function region(w, h, x, y) {
1221
+ w = w || 0;
1222
+ h = h || 0;
1223
+ x = x || 0;
1224
+ y = y || 0;
1225
+ return this.out("-region", w + "x" + h + "+" + x + "+" + y);
1226
+ };
1227
+ // http://www.graphicsmagick.org/GraphicsMagick.html#details-roll
1228
+ proto.roll = function roll(x, y) {
1229
+ x = ((x = parseInt(x, 10) || 0) >= 0 ? "+" : "") + x;
1230
+ y = ((y = parseInt(y, 10) || 0) >= 0 ? "+" : "") + y;
1231
+ return this.out("-roll", x + y);
1232
+ };
1233
+ // http://www.graphicsmagick.org/GraphicsMagick.html#details-sharpen
1234
+ proto.sharpen = function sharpen(radius, sigma) {
1235
+ sigma = sigma ? "x" + sigma : "";
1236
+ return this.out("-sharpen", radius + sigma);
1237
+ };
1238
+ // http://www.graphicsmagick.org/GraphicsMagick.html#details-solarize
1239
+ proto.solarize = function solarize(factor) {
1240
+ return this.out("-solarize", (factor || 1) + "%");
1241
+ };
1242
+ // http://www.graphicsmagick.org/GraphicsMagick.html#details-spread
1243
+ proto.spread = function spread(amount) {
1244
+ return this.out("-spread", amount || 5);
1245
+ };
1246
+ // http://www.graphicsmagick.org/GraphicsMagick.html#details-swirl
1247
+ proto.swirl = function swirl(degrees) {
1248
+ return this.out("-swirl", degrees || 180);
1249
+ };
1250
+ // http://www.graphicsmagick.org/GraphicsMagick.html#details-type
1251
+ proto.type = function type(type) {
1252
+ return this.in("-type", type);
1253
+ };
1254
+ // http://www.graphicsmagick.org/GraphicsMagick.html#details-trim
1255
+ proto.trim = function trim() {
1256
+ return this.out("-trim");
1257
+ };
1258
+ // http://www.graphicsmagick.org/GraphicsMagick.html#details-extent
1259
+ proto.extent = function extent(w, h, options) {
1260
+ options = options || "";
1261
+ var geometry;
1262
+ if (w && h) {
1263
+ geometry = w + "x" + h + options;
1264
+ } else if (w && !h) {
1265
+ geometry = this._options.imageMagick ? w + options : w + 'x' + options;
1266
+ } else if (!w && h) {
1267
+ geometry = 'x' + h + options;
1268
+ }
1269
+ return this.out("-extent", geometry);
1270
+ };
1271
+ // http://www.graphicsmagick.org/GraphicsMagick.html#details-gravity
1272
+ // Be sure to use gravity BEFORE extent
1273
+ proto.gravity = function gravity(type) {
1274
+ if (!type || !~gravity.types.indexOf(type)) {
1275
+ type = "NorthWest"; // Documented default.
1276
+ }
1277
+ return this.out("-gravity", type);
1278
+ };
1279
+ proto.gravity.types = [
1280
+ "NorthWest",
1281
+ "North",
1282
+ "NorthEast",
1283
+ "West",
1284
+ "Center",
1285
+ "East",
1286
+ "SouthWest",
1287
+ "South",
1288
+ "SouthEast"
1289
+ ];
1290
+ // http://www.graphicsmagick.org/GraphicsMagick.html#details-flatten
1291
+ proto.flatten = function flatten() {
1292
+ return this.out("-flatten");
1293
+ };
1294
+ // http://www.graphicsmagick.org/GraphicsMagick.html#details-background
1295
+ proto.background = function background(color) {
1296
+ return this.in("-background", color);
1297
+ };
1298
+ };
1299
+ /**
1300
+ * Generates a handler for comments/labels.
1301
+ */ function comment(arg) {
1302
+ return function(format) {
1303
+ format = String(format);
1304
+ format = "@" == format.charAt(0) ? format.substring(1) : format;
1305
+ return this.out(arg, '"' + format + '"');
1306
+ };
1307
+ }
1308
+ return args;
1309
+ }
1310
+
1311
+ /**
1312
+ * Module dependencies.
1313
+ */
1314
+
1315
+ var drawing;
1316
+ var hasRequiredDrawing;
1317
+
1318
+ function requireDrawing () {
1319
+ if (hasRequiredDrawing) return drawing;
1320
+ hasRequiredDrawing = 1;
1321
+ var escape = requireUtils().escape;
1322
+ /**
1323
+ * Extend proto.
1324
+ */ drawing = function(proto) {
1325
+ // http://www.graphicsmagick.org/GraphicsMagick.html#details-fill
1326
+ proto.fill = function fill(color) {
1327
+ return this.out("-fill", color || "none");
1328
+ };
1329
+ // http://www.graphicsmagick.org/GraphicsMagick.html#details-stroke
1330
+ proto.stroke = function stroke(color, width) {
1331
+ if (width) {
1332
+ this.strokeWidth(width);
1333
+ }
1334
+ return this.out("-stroke", color || "none");
1335
+ };
1336
+ // http://www.graphicsmagick.org/GraphicsMagick.html#details-strokewidth
1337
+ proto.strokeWidth = function strokeWidth(width) {
1338
+ return this.out("-strokewidth", width);
1339
+ };
1340
+ // http://www.graphicsmagick.org/GraphicsMagick.html#details-font
1341
+ proto.font = function font(font, size) {
1342
+ if (size) {
1343
+ this.fontSize(size);
1344
+ }
1345
+ return this.out("-font", font);
1346
+ };
1347
+ // http://www.graphicsmagick.org/GraphicsMagick.html
1348
+ proto.fontSize = function fontSize(size) {
1349
+ return this.out("-pointsize", size);
1350
+ };
1351
+ // http://www.graphicsmagick.org/GraphicsMagick.html#details-draw
1352
+ proto.draw = function draw(args) {
1353
+ return this.out("-draw", [].slice.call(arguments).join(" "));
1354
+ };
1355
+ // http://www.graphicsmagick.org/GraphicsMagick.html#details-draw
1356
+ proto.drawPoint = function drawPoint(x, y) {
1357
+ return this.draw("point", x + "," + y);
1358
+ };
1359
+ // http://www.graphicsmagick.org/GraphicsMagick.html#details-draw
1360
+ proto.drawLine = function drawLine(x0, y0, x1, y1) {
1361
+ return this.draw("line", x0 + "," + y0, x1 + "," + y1);
1362
+ };
1363
+ // http://www.graphicsmagick.org/GraphicsMagick.html#details-draw
1364
+ proto.drawRectangle = function drawRectangle(x0, y0, x1, y1, wc, hc) {
1365
+ var shape = "rectangle", lastarg;
1366
+ if ("undefined" !== typeof wc) {
1367
+ shape = "roundRectangle";
1368
+ if ("undefined" === typeof hc) {
1369
+ hc = wc;
1370
+ }
1371
+ lastarg = wc + "," + hc;
1372
+ }
1373
+ return this.draw(shape, x0 + "," + y0, x1 + "," + y1, lastarg);
1374
+ };
1375
+ // http://www.graphicsmagick.org/GraphicsMagick.html#details-draw
1376
+ proto.drawArc = function drawArc(x0, y0, x1, y1, a0, a1) {
1377
+ return this.draw("arc", x0 + "," + y0, x1 + "," + y1, a0 + "," + a1);
1378
+ };
1379
+ // http://www.graphicsmagick.org/GraphicsMagick.html#details-draw
1380
+ proto.drawEllipse = function drawEllipse(x0, y0, rx, ry, a0, a1) {
1381
+ if (a0 == undefined) a0 = 0;
1382
+ if (a1 == undefined) a1 = 360;
1383
+ return this.draw("ellipse", x0 + "," + y0, rx + "," + ry, a0 + "," + a1);
1384
+ };
1385
+ // http://www.graphicsmagick.org/GraphicsMagick.html#details-draw
1386
+ proto.drawCircle = function drawCircle(x0, y0, x1, y1) {
1387
+ return this.draw("circle", x0 + "," + y0, x1 + "," + y1);
1388
+ };
1389
+ // http://www.graphicsmagick.org/GraphicsMagick.html#details-draw
1390
+ proto.drawPolyline = function drawPolyline() {
1391
+ return this.draw("polyline", formatPoints(arguments));
1392
+ };
1393
+ // http://www.graphicsmagick.org/GraphicsMagick.html#details-draw
1394
+ proto.drawPolygon = function drawPolygon() {
1395
+ return this.draw("polygon", formatPoints(arguments));
1396
+ };
1397
+ // http://www.graphicsmagick.org/GraphicsMagick.html#details-draw
1398
+ proto.drawBezier = function drawBezier() {
1399
+ return this.draw("bezier", formatPoints(arguments));
1400
+ };
1401
+ proto._gravities = [
1402
+ "northwest",
1403
+ "north",
1404
+ "northeast",
1405
+ "west",
1406
+ "center",
1407
+ "east",
1408
+ "southwest",
1409
+ "south",
1410
+ "southeast"
1411
+ ];
1412
+ // http://www.graphicsmagick.org/GraphicsMagick.html#details-draw
1413
+ proto.drawText = function drawText(x0, y0, text, gravity) {
1414
+ var gravity = String(gravity || "").toLowerCase(), arg = [
1415
+ "text " + x0 + "," + y0 + " " + escape(text)
1416
+ ];
1417
+ if (~this._gravities.indexOf(gravity)) {
1418
+ arg.unshift("gravity", gravity);
1419
+ }
1420
+ return this.draw.apply(this, arg);
1421
+ };
1422
+ proto._drawProps = [
1423
+ "color",
1424
+ "matte"
1425
+ ];
1426
+ // http://www.graphicsmagick.org/GraphicsMagick.html#details-draw
1427
+ proto.setDraw = function setDraw(prop, x, y, method) {
1428
+ prop = String(prop || "").toLowerCase();
1429
+ if (!~this._drawProps.indexOf(prop)) {
1430
+ return this;
1431
+ }
1432
+ return this.draw(prop, x + "," + y, method);
1433
+ };
1434
+ };
1435
+ function formatPoints(points) {
1436
+ var len = points.length, result = [], i = 0;
1437
+ for(; i < len; ++i){
1438
+ result.push(points[i].join(","));
1439
+ }
1440
+ return result;
1441
+ }
1442
+ return drawing;
1443
+ }
1444
+
1445
+ /**
1446
+ * Extend proto.
1447
+ */
1448
+
1449
+ var thumb;
1450
+ var hasRequiredThumb;
1451
+
1452
+ function requireThumb () {
1453
+ if (hasRequiredThumb) return thumb;
1454
+ hasRequiredThumb = 1;
1455
+ thumb = function(proto) {
1456
+ proto.thumb = function thumb(w, h, name, quality, align, progressive, callback, opts) {
1457
+ var self = this, args = Array.prototype.slice.call(arguments);
1458
+ opts = args.pop();
1459
+ if (typeof opts === 'function') {
1460
+ callback = opts;
1461
+ opts = '';
1462
+ } else {
1463
+ callback = args.pop();
1464
+ }
1465
+ w = args.shift();
1466
+ h = args.shift();
1467
+ name = args.shift();
1468
+ quality = args.shift() || 63;
1469
+ align = args.shift() || 'topleft';
1470
+ var interlace = args.shift() ? 'Line' : 'None';
1471
+ self.size(function(err, size) {
1472
+ if (err) {
1473
+ return callback.apply(self, arguments);
1474
+ }
1475
+ w = parseInt(w, 10);
1476
+ h = parseInt(h, 10);
1477
+ var w1, h1;
1478
+ var xoffset = 0;
1479
+ var yoffset = 0;
1480
+ if (size.width < size.height) {
1481
+ w1 = w;
1482
+ h1 = Math.floor(size.height * (w / size.width));
1483
+ if (h1 < h) {
1484
+ w1 = Math.floor(w1 * ((h - h1) / h + 1));
1485
+ h1 = h;
1486
+ }
1487
+ } else if (size.width > size.height) {
1488
+ h1 = h;
1489
+ w1 = Math.floor(size.width * (h / size.height));
1490
+ if (w1 < w) {
1491
+ h1 = Math.floor(h1 * ((w - w1) / w + 1));
1492
+ w1 = w;
1493
+ }
1494
+ } else if (size.width == size.height) {
1495
+ var bigger = w > h ? w : h;
1496
+ w1 = bigger;
1497
+ h1 = bigger;
1498
+ }
1499
+ if (align == 'center') {
1500
+ if (w < w1) {
1501
+ xoffset = (w1 - w) / 2;
1502
+ }
1503
+ if (h < h1) {
1504
+ yoffset = (h1 - h) / 2;
1505
+ }
1506
+ }
1507
+ self.quality(quality).in("-size", w1 + "x" + h1).scale(w1, h1, opts).crop(w, h, xoffset, yoffset).interlace(interlace).noProfile().write(name, function() {
1508
+ callback.apply(self, arguments);
1509
+ });
1510
+ });
1511
+ return self;
1512
+ };
1513
+ proto.thumbExact = function() {
1514
+ var self = this, args = Array.prototype.slice.call(arguments);
1515
+ args.push('!');
1516
+ self.thumb.apply(self, args);
1517
+ };
1518
+ };
1519
+ return thumb;
1520
+ }
1521
+
1522
+ var arrayParallel;
1523
+ var hasRequiredArrayParallel;
1524
+
1525
+ function requireArrayParallel () {
1526
+ if (hasRequiredArrayParallel) return arrayParallel;
1527
+ hasRequiredArrayParallel = 1;
1528
+ arrayParallel = function parallel(fns, context, callback) {
1529
+ if (!callback) {
1530
+ if (typeof context === 'function') {
1531
+ callback = context;
1532
+ context = null;
1533
+ } else {
1534
+ callback = noop;
1535
+ }
1536
+ }
1537
+ var pending = fns && fns.length;
1538
+ if (!pending) return callback(null, []);
1539
+ var finished = false;
1540
+ var results = new Array(pending);
1541
+ fns.forEach(context ? function(fn, i) {
1542
+ fn.call(context, maybeDone(i));
1543
+ } : function(fn, i) {
1544
+ fn(maybeDone(i));
1545
+ });
1546
+ function maybeDone(i) {
1547
+ return function(err, result) {
1548
+ if (finished) return;
1549
+ if (err) {
1550
+ callback(err, results);
1551
+ finished = true;
1552
+ return;
1553
+ }
1554
+ results[i] = result;
1555
+ if (!--pending) callback(null, results);
1556
+ };
1557
+ }
1558
+ };
1559
+ function noop() {}
1560
+ return arrayParallel;
1561
+ }
1562
+
1563
+ /**
1564
+ * Module dependencies.
1565
+ */
1566
+
1567
+ var morph;
1568
+ var hasRequiredMorph;
1569
+
1570
+ function requireMorph () {
1571
+ if (hasRequiredMorph) return morph;
1572
+ hasRequiredMorph = 1;
1573
+ var fs = require$$0;
1574
+ var parallel = requireArrayParallel();
1575
+ /**
1576
+ * Extend proto.
1577
+ */ morph = function(proto) {
1578
+ /**
1579
+ * Do nothing.
1580
+ */ function noop() {}
1581
+ // http://www.graphicsmagick.org/GraphicsMagick.html#details-morph
1582
+ proto.morph = function morph(other, outname, callback) {
1583
+ if (!outname) {
1584
+ throw new Error("an output filename is required");
1585
+ }
1586
+ callback = (callback || noop).bind(this);
1587
+ var self = this;
1588
+ if (Array.isArray(other)) {
1589
+ other.forEach(function(img) {
1590
+ self.out(img);
1591
+ });
1592
+ self.out("-morph", other.length);
1593
+ } else {
1594
+ self.out(other, "-morph", 1);
1595
+ }
1596
+ self.write(outname, function(err, stdout, stderr, cmd) {
1597
+ if (err) return callback(err, stdout, stderr, cmd);
1598
+ // Apparently some platforms create the following temporary files.
1599
+ // Check if the output file exists, if it doesn't, then
1600
+ // work with temporary files.
1601
+ fs.exists(outname, function(exists) {
1602
+ if (exists) return callback(null, stdout, stderr, cmd);
1603
+ parallel([
1604
+ fs.unlink.bind(fs, outname + '.0'),
1605
+ fs.unlink.bind(fs, outname + '.2'),
1606
+ fs.rename.bind(fs, outname + '.1', outname)
1607
+ ], function(err) {
1608
+ callback(err, stdout, stderr, cmd);
1609
+ });
1610
+ });
1611
+ });
1612
+ return self;
1613
+ };
1614
+ };
1615
+ return morph;
1616
+ }
1617
+
1618
+ /**
1619
+ * Extend proto.
1620
+ */
1621
+
1622
+ var sepia;
1623
+ var hasRequiredSepia;
1624
+
1625
+ function requireSepia () {
1626
+ if (hasRequiredSepia) return sepia;
1627
+ hasRequiredSepia = 1;
1628
+ sepia = function(proto) {
1629
+ proto.sepia = function sepia() {
1630
+ return this.modulate(115, 0, 100).colorize(7, 21, 50);
1631
+ };
1632
+ };
1633
+ return sepia;
1634
+ }
1635
+
1636
+ /**
1637
+ * Extend proto.
1638
+ */
1639
+
1640
+ var autoOrient;
1641
+ var hasRequiredAutoOrient;
1642
+
1643
+ function requireAutoOrient () {
1644
+ if (hasRequiredAutoOrient) return autoOrient;
1645
+ hasRequiredAutoOrient = 1;
1646
+ autoOrient = function(proto) {
1647
+ var exifTransforms = {
1648
+ topleft: '',
1649
+ topright: [
1650
+ '-flop'
1651
+ ],
1652
+ bottomright: [
1653
+ '-rotate',
1654
+ 180
1655
+ ],
1656
+ bottomleft: [
1657
+ '-flip'
1658
+ ],
1659
+ lefttop: [
1660
+ '-flip',
1661
+ '-rotate',
1662
+ 90
1663
+ ],
1664
+ righttop: [
1665
+ '-rotate',
1666
+ 90
1667
+ ],
1668
+ rightbottom: [
1669
+ '-flop',
1670
+ '-rotate',
1671
+ 90
1672
+ ],
1673
+ leftbottom: [
1674
+ '-rotate',
1675
+ 270
1676
+ ]
1677
+ };
1678
+ proto.autoOrient = function autoOrient() {
1679
+ // Always strip EXIF data since we can't
1680
+ // change/edit it.
1681
+ // imagemagick has a native -auto-orient option
1682
+ // so does graphicsmagick, but in 1.3.18.
1683
+ // nativeAutoOrient option enables this if you know you have >= 1.3.18
1684
+ if (this._options.nativeAutoOrient || this._options.imageMagick) {
1685
+ this.out('-auto-orient');
1686
+ return this;
1687
+ }
1688
+ this.preprocessor(function(callback) {
1689
+ this.orientation({
1690
+ bufferStream: true
1691
+ }, function(err, orientation) {
1692
+ if (err) return callback(err);
1693
+ var transforms = exifTransforms[orientation.toLowerCase()];
1694
+ if (transforms) {
1695
+ // remove any existing transforms that might conflict
1696
+ var index = this._out.indexOf(transforms[0]);
1697
+ if (~index) {
1698
+ this._out.splice(index, transforms.length);
1699
+ }
1700
+ // repage to fix coordinates
1701
+ this._out.unshift.apply(this._out, transforms.concat('-page', '+0+0'));
1702
+ }
1703
+ callback();
1704
+ });
1705
+ });
1706
+ return this;
1707
+ };
1708
+ };
1709
+ return autoOrient;
1710
+ }
1711
+
1712
+ /**
1713
+ * Extend proto
1714
+ */
1715
+
1716
+ var convenience;
1717
+ var hasRequiredConvenience;
1718
+
1719
+ function requireConvenience () {
1720
+ if (hasRequiredConvenience) return convenience;
1721
+ hasRequiredConvenience = 1;
1722
+ convenience = function(proto) {
1723
+ requireThumb()(proto);
1724
+ requireMorph()(proto);
1725
+ requireSepia()(proto);
1726
+ requireAutoOrient()(proto);
1727
+ };
1728
+ return convenience;
1729
+ }
1730
+
1731
+ var crossSpawn = {
1732
+ exports: {}
1733
+ };
1734
+
1735
+ var windows;
1736
+ var hasRequiredWindows;
1737
+
1738
+ function requireWindows () {
1739
+ if (hasRequiredWindows) return windows;
1740
+ hasRequiredWindows = 1;
1741
+ windows = isexe;
1742
+ isexe.sync = sync;
1743
+ var fs = require$$0;
1744
+ function checkPathExt(path, options) {
1745
+ var pathext = options.pathExt !== undefined ? options.pathExt : process.env.PATHEXT;
1746
+ if (!pathext) {
1747
+ return true;
1748
+ }
1749
+ pathext = pathext.split(';');
1750
+ if (pathext.indexOf('') !== -1) {
1751
+ return true;
1752
+ }
1753
+ for(var i = 0; i < pathext.length; i++){
1754
+ var p = pathext[i].toLowerCase();
1755
+ if (p && path.substr(-p.length).toLowerCase() === p) {
1756
+ return true;
1757
+ }
1758
+ }
1759
+ return false;
1760
+ }
1761
+ function checkStat(stat, path, options) {
1762
+ if (!stat.isSymbolicLink() && !stat.isFile()) {
1763
+ return false;
1764
+ }
1765
+ return checkPathExt(path, options);
1766
+ }
1767
+ function isexe(path, options, cb) {
1768
+ fs.stat(path, function(er, stat) {
1769
+ cb(er, er ? false : checkStat(stat, path, options));
1770
+ });
1771
+ }
1772
+ function sync(path, options) {
1773
+ return checkStat(fs.statSync(path), path, options);
1774
+ }
1775
+ return windows;
1776
+ }
1777
+
1778
+ var mode;
1779
+ var hasRequiredMode;
1780
+
1781
+ function requireMode () {
1782
+ if (hasRequiredMode) return mode;
1783
+ hasRequiredMode = 1;
1784
+ mode = isexe;
1785
+ isexe.sync = sync;
1786
+ var fs = require$$0;
1787
+ function isexe(path, options, cb) {
1788
+ fs.stat(path, function(er, stat) {
1789
+ cb(er, er ? false : checkStat(stat, options));
1790
+ });
1791
+ }
1792
+ function sync(path, options) {
1793
+ return checkStat(fs.statSync(path), options);
1794
+ }
1795
+ function checkStat(stat, options) {
1796
+ return stat.isFile() && checkMode(stat, options);
1797
+ }
1798
+ function checkMode(stat, options) {
1799
+ var mod = stat.mode;
1800
+ var uid = stat.uid;
1801
+ var gid = stat.gid;
1802
+ var myUid = options.uid !== undefined ? options.uid : process.getuid && process.getuid();
1803
+ var myGid = options.gid !== undefined ? options.gid : process.getgid && process.getgid();
1804
+ var u = parseInt('100', 8);
1805
+ var g = parseInt('010', 8);
1806
+ var o = parseInt('001', 8);
1807
+ var ug = u | g;
1808
+ var ret = mod & o || mod & g && gid === myGid || mod & u && uid === myUid || mod & ug && myUid === 0;
1809
+ return ret;
1810
+ }
1811
+ return mode;
1812
+ }
1813
+
1814
+ var isexe_1;
1815
+ var hasRequiredIsexe;
1816
+
1817
+ function requireIsexe () {
1818
+ if (hasRequiredIsexe) return isexe_1;
1819
+ hasRequiredIsexe = 1;
1820
+ var core;
1821
+ if (process.platform === 'win32' || commonjsGlobal.TESTING_WINDOWS) {
1822
+ core = requireWindows();
1823
+ } else {
1824
+ core = requireMode();
1825
+ }
1826
+ isexe_1 = isexe;
1827
+ isexe.sync = sync;
1828
+ function isexe(path, options, cb) {
1829
+ if (typeof options === 'function') {
1830
+ cb = options;
1831
+ options = {};
1832
+ }
1833
+ if (!cb) {
1834
+ if (typeof Promise !== 'function') {
1835
+ throw new TypeError('callback not provided');
1836
+ }
1837
+ return new Promise(function(resolve, reject) {
1838
+ isexe(path, options || {}, function(er, is) {
1839
+ if (er) {
1840
+ reject(er);
1841
+ } else {
1842
+ resolve(is);
1843
+ }
1844
+ });
1845
+ });
1846
+ }
1847
+ core(path, options || {}, function(er, is) {
1848
+ // ignore EACCES because that just means we aren't allowed to run it
1849
+ if (er) {
1850
+ if (er.code === 'EACCES' || options && options.ignoreErrors) {
1851
+ er = null;
1852
+ is = false;
1853
+ }
1854
+ }
1855
+ cb(er, is);
1856
+ });
1857
+ }
1858
+ function sync(path, options) {
1859
+ // my kingdom for a filtered catch
1860
+ try {
1861
+ return core.sync(path, options || {});
1862
+ } catch (er) {
1863
+ if (options && options.ignoreErrors || er.code === 'EACCES') {
1864
+ return false;
1865
+ } else {
1866
+ throw er;
1867
+ }
1868
+ }
1869
+ }
1870
+ return isexe_1;
1871
+ }
1872
+
1873
+ var which_1;
1874
+ var hasRequiredWhich;
1875
+
1876
+ function requireWhich () {
1877
+ if (hasRequiredWhich) return which_1;
1878
+ hasRequiredWhich = 1;
1879
+ function _array_like_to_array(arr, len) {
1880
+ if (len == null || len > arr.length) len = arr.length;
1881
+ for(var i = 0, arr2 = new Array(len); i < len; i++)arr2[i] = arr[i];
1882
+ return arr2;
1883
+ }
1884
+ function _array_without_holes(arr) {
1885
+ if (Array.isArray(arr)) return _array_like_to_array(arr);
1886
+ }
1887
+ function _iterable_to_array(iter) {
1888
+ if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter);
1889
+ }
1890
+ function _non_iterable_spread() {
1891
+ throw new TypeError("Invalid attempt to spread non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
1892
+ }
1893
+ function _to_consumable_array(arr) {
1894
+ return _array_without_holes(arr) || _iterable_to_array(arr) || _unsupported_iterable_to_array(arr) || _non_iterable_spread();
1895
+ }
1896
+ function _unsupported_iterable_to_array(o, minLen) {
1897
+ if (!o) return;
1898
+ if (typeof o === "string") return _array_like_to_array(o, minLen);
1899
+ var n = Object.prototype.toString.call(o).slice(8, -1);
1900
+ if (n === "Object" && o.constructor) n = o.constructor.name;
1901
+ if (n === "Map" || n === "Set") return Array.from(n);
1902
+ if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array(o, minLen);
1903
+ }
1904
+ var isWindows = process.platform === 'win32' || process.env.OSTYPE === 'cygwin' || process.env.OSTYPE === 'msys';
1905
+ var path = require$$0$1;
1906
+ var COLON = isWindows ? ';' : ':';
1907
+ var isexe = requireIsexe();
1908
+ var getNotFoundError = function(cmd) {
1909
+ return Object.assign(new Error("not found: ".concat(cmd)), {
1910
+ code: 'ENOENT'
1911
+ });
1912
+ };
1913
+ var getPathInfo = function(cmd, opt) {
1914
+ var colon = opt.colon || COLON;
1915
+ // If it has a slash, then we don't bother searching the pathenv.
1916
+ // just check the file itself, and that's it.
1917
+ var pathEnv = cmd.match(/\//) || isWindows && cmd.match(/\\/) ? [
1918
+ ''
1919
+ ] : // windows always checks the cwd first
1920
+ _to_consumable_array(isWindows ? [
1921
+ process.cwd()
1922
+ ] : []).concat(_to_consumable_array((opt.path || process.env.PATH || /* istanbul ignore next: very unusual */ '').split(colon)));
1923
+ var pathExtExe = isWindows ? opt.pathExt || process.env.PATHEXT || '.EXE;.CMD;.BAT;.COM' : '';
1924
+ var pathExt = isWindows ? pathExtExe.split(colon) : [
1925
+ ''
1926
+ ];
1927
+ if (isWindows) {
1928
+ if (cmd.indexOf('.') !== -1 && pathExt[0] !== '') pathExt.unshift('');
1929
+ }
1930
+ return {
1931
+ pathEnv: pathEnv,
1932
+ pathExt: pathExt,
1933
+ pathExtExe: pathExtExe
1934
+ };
1935
+ };
1936
+ var which = function(cmd, opt, cb) {
1937
+ if (typeof opt === 'function') {
1938
+ cb = opt;
1939
+ opt = {};
1940
+ }
1941
+ if (!opt) opt = {};
1942
+ var _getPathInfo = getPathInfo(cmd, opt), pathEnv = _getPathInfo.pathEnv, pathExt = _getPathInfo.pathExt, pathExtExe = _getPathInfo.pathExtExe;
1943
+ var found = [];
1944
+ var step = function(i) {
1945
+ return new Promise(function(resolve, reject) {
1946
+ if (i === pathEnv.length) return opt.all && found.length ? resolve(found) : reject(getNotFoundError(cmd));
1947
+ var ppRaw = pathEnv[i];
1948
+ var pathPart = /^".*"$/.test(ppRaw) ? ppRaw.slice(1, -1) : ppRaw;
1949
+ var pCmd = path.join(pathPart, cmd);
1950
+ var p = !pathPart && /^\.[\\\/]/.test(cmd) ? cmd.slice(0, 2) + pCmd : pCmd;
1951
+ resolve(subStep(p, i, 0));
1952
+ });
1953
+ };
1954
+ var subStep = function(p, i, ii) {
1955
+ return new Promise(function(resolve, reject) {
1956
+ if (ii === pathExt.length) return resolve(step(i + 1));
1957
+ var ext = pathExt[ii];
1958
+ isexe(p + ext, {
1959
+ pathExt: pathExtExe
1960
+ }, function(er, is) {
1961
+ if (!er && is) {
1962
+ if (opt.all) found.push(p + ext);
1963
+ else return resolve(p + ext);
1964
+ }
1965
+ return resolve(subStep(p, i, ii + 1));
1966
+ });
1967
+ });
1968
+ };
1969
+ return cb ? step(0).then(function(res) {
1970
+ return cb(null, res);
1971
+ }, cb) : step(0);
1972
+ };
1973
+ var whichSync = function(cmd, opt) {
1974
+ opt = opt || {};
1975
+ var _getPathInfo = getPathInfo(cmd, opt), pathEnv = _getPathInfo.pathEnv, pathExt = _getPathInfo.pathExt, pathExtExe = _getPathInfo.pathExtExe;
1976
+ var found = [];
1977
+ for(var i = 0; i < pathEnv.length; i++){
1978
+ var ppRaw = pathEnv[i];
1979
+ var pathPart = /^".*"$/.test(ppRaw) ? ppRaw.slice(1, -1) : ppRaw;
1980
+ var pCmd = path.join(pathPart, cmd);
1981
+ var p = !pathPart && /^\.[\\\/]/.test(cmd) ? cmd.slice(0, 2) + pCmd : pCmd;
1982
+ for(var j = 0; j < pathExt.length; j++){
1983
+ var cur = p + pathExt[j];
1984
+ try {
1985
+ var is = isexe.sync(cur, {
1986
+ pathExt: pathExtExe
1987
+ });
1988
+ if (is) {
1989
+ if (opt.all) found.push(cur);
1990
+ else return cur;
1991
+ }
1992
+ } catch (ex) {}
1993
+ }
1994
+ }
1995
+ if (opt.all && found.length) return found;
1996
+ if (opt.nothrow) return null;
1997
+ throw getNotFoundError(cmd);
1998
+ };
1999
+ which_1 = which;
2000
+ which.sync = whichSync;
2001
+ return which_1;
2002
+ }
2003
+
2004
+ var pathKey = {
2005
+ exports: {}
2006
+ };
2007
+
2008
+ var hasRequiredPathKey;
2009
+
2010
+ function requirePathKey () {
2011
+ if (hasRequiredPathKey) return pathKey.exports;
2012
+ hasRequiredPathKey = 1;
2013
+ var pathKey$1 = function() {
2014
+ var options = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {};
2015
+ var environment = options.env || process.env;
2016
+ var platform = options.platform || process.platform;
2017
+ if (platform !== 'win32') {
2018
+ return 'PATH';
2019
+ }
2020
+ return Object.keys(environment).reverse().find(function(key) {
2021
+ return key.toUpperCase() === 'PATH';
2022
+ }) || 'Path';
2023
+ };
2024
+ pathKey.exports = pathKey$1;
2025
+ // TODO: Remove this for the next major release
2026
+ pathKey.exports.default = pathKey$1;
2027
+ return pathKey.exports;
2028
+ }
2029
+
2030
+ var resolveCommand_1;
2031
+ var hasRequiredResolveCommand;
2032
+
2033
+ function requireResolveCommand () {
2034
+ if (hasRequiredResolveCommand) return resolveCommand_1;
2035
+ hasRequiredResolveCommand = 1;
2036
+ var path = require$$0$1;
2037
+ var which = requireWhich();
2038
+ var getPathKey = requirePathKey();
2039
+ function resolveCommandAttempt(parsed, withoutPathExt) {
2040
+ var env = parsed.options.env || process.env;
2041
+ var cwd = process.cwd();
2042
+ var hasCustomCwd = parsed.options.cwd != null;
2043
+ // Worker threads do not have process.chdir()
2044
+ var shouldSwitchCwd = hasCustomCwd && process.chdir !== undefined && !process.chdir.disabled;
2045
+ // If a custom `cwd` was specified, we need to change the process cwd
2046
+ // because `which` will do stat calls but does not support a custom cwd
2047
+ if (shouldSwitchCwd) {
2048
+ try {
2049
+ process.chdir(parsed.options.cwd);
2050
+ } catch (err) {
2051
+ /* Empty */ }
2052
+ }
2053
+ var resolved;
2054
+ try {
2055
+ resolved = which.sync(parsed.command, {
2056
+ path: env[getPathKey({
2057
+ env: env
2058
+ })],
2059
+ pathExt: withoutPathExt ? path.delimiter : undefined
2060
+ });
2061
+ } catch (e) {
2062
+ /* Empty */ } finally{
2063
+ if (shouldSwitchCwd) {
2064
+ process.chdir(cwd);
2065
+ }
2066
+ }
2067
+ // If we successfully resolved, ensure that an absolute path is returned
2068
+ // Note that when a custom `cwd` was used, we need to resolve to an absolute path based on it
2069
+ if (resolved) {
2070
+ resolved = path.resolve(hasCustomCwd ? parsed.options.cwd : '', resolved);
2071
+ }
2072
+ return resolved;
2073
+ }
2074
+ function resolveCommand(parsed) {
2075
+ return resolveCommandAttempt(parsed) || resolveCommandAttempt(parsed, true);
2076
+ }
2077
+ resolveCommand_1 = resolveCommand;
2078
+ return resolveCommand_1;
2079
+ }
2080
+
2081
+ var _escape = {};
2082
+
2083
+ var hasRequired_escape;
2084
+
2085
+ function require_escape () {
2086
+ if (hasRequired_escape) return _escape;
2087
+ hasRequired_escape = 1;
2088
+ // See http://www.robvanderwoude.com/escapechars.php
2089
+ var metaCharsRegExp = /([()\][%!^"`<>&|;, *?])/g;
2090
+ function escapeCommand(arg) {
2091
+ // Escape meta chars
2092
+ arg = arg.replace(metaCharsRegExp, '^$1');
2093
+ return arg;
2094
+ }
2095
+ function escapeArgument(arg, doubleEscapeMetaChars) {
2096
+ // Convert to string
2097
+ arg = "".concat(arg);
2098
+ // Algorithm below is based on https://qntm.org/cmd
2099
+ // It's slightly altered to disable JS backtracking to avoid hanging on specially crafted input
2100
+ // Please see https://github.com/moxystudio/node-cross-spawn/pull/160 for more information
2101
+ // Sequence of backslashes followed by a double quote:
2102
+ // double up all the backslashes and escape the double quote
2103
+ arg = arg.replace(/(?=(\\+?)?)\1"/g, '$1$1\\"');
2104
+ // Sequence of backslashes followed by the end of the string
2105
+ // (which will become a double quote later):
2106
+ // double up all the backslashes
2107
+ arg = arg.replace(/(?=(\\+?)?)\1$/, '$1$1');
2108
+ // All other backslashes occur literally
2109
+ // Quote the whole thing:
2110
+ arg = '"'.concat(arg, '"');
2111
+ // Escape meta chars
2112
+ arg = arg.replace(metaCharsRegExp, '^$1');
2113
+ // Double escape meta chars if necessary
2114
+ if (doubleEscapeMetaChars) {
2115
+ arg = arg.replace(metaCharsRegExp, '^$1');
2116
+ }
2117
+ return arg;
2118
+ }
2119
+ _escape.command = escapeCommand;
2120
+ _escape.argument = escapeArgument;
2121
+ return _escape;
2122
+ }
2123
+
2124
+ var shebangRegex;
2125
+ var hasRequiredShebangRegex;
2126
+
2127
+ function requireShebangRegex () {
2128
+ if (hasRequiredShebangRegex) return shebangRegex;
2129
+ hasRequiredShebangRegex = 1;
2130
+ shebangRegex = /^#!(.*)/;
2131
+ return shebangRegex;
2132
+ }
2133
+
2134
+ var shebangCommand;
2135
+ var hasRequiredShebangCommand;
2136
+
2137
+ function requireShebangCommand () {
2138
+ if (hasRequiredShebangCommand) return shebangCommand;
2139
+ hasRequiredShebangCommand = 1;
2140
+ function _array_like_to_array(arr, len) {
2141
+ if (len == null || len > arr.length) len = arr.length;
2142
+ for(var i = 0, arr2 = new Array(len); i < len; i++)arr2[i] = arr[i];
2143
+ return arr2;
2144
+ }
2145
+ function _array_with_holes(arr) {
2146
+ if (Array.isArray(arr)) return arr;
2147
+ }
2148
+ function _iterable_to_array_limit(arr, i) {
2149
+ var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"];
2150
+ if (_i == null) return;
2151
+ var _arr = [];
2152
+ var _n = true;
2153
+ var _d = false;
2154
+ var _s, _e;
2155
+ try {
2156
+ for(_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true){
2157
+ _arr.push(_s.value);
2158
+ if (i && _arr.length === i) break;
2159
+ }
2160
+ } catch (err) {
2161
+ _d = true;
2162
+ _e = err;
2163
+ } finally{
2164
+ try {
2165
+ if (!_n && _i["return"] != null) _i["return"]();
2166
+ } finally{
2167
+ if (_d) throw _e;
2168
+ }
2169
+ }
2170
+ return _arr;
2171
+ }
2172
+ function _non_iterable_rest() {
2173
+ throw new TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
2174
+ }
2175
+ function _sliced_to_array(arr, i) {
2176
+ return _array_with_holes(arr) || _iterable_to_array_limit(arr, i) || _unsupported_iterable_to_array(arr, i) || _non_iterable_rest();
2177
+ }
2178
+ function _unsupported_iterable_to_array(o, minLen) {
2179
+ if (!o) return;
2180
+ if (typeof o === "string") return _array_like_to_array(o, minLen);
2181
+ var n = Object.prototype.toString.call(o).slice(8, -1);
2182
+ if (n === "Object" && o.constructor) n = o.constructor.name;
2183
+ if (n === "Map" || n === "Set") return Array.from(n);
2184
+ if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array(o, minLen);
2185
+ }
2186
+ var shebangRegex = requireShebangRegex();
2187
+ shebangCommand = function() {
2188
+ var string = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : '';
2189
+ var match = string.match(shebangRegex);
2190
+ if (!match) {
2191
+ return null;
2192
+ }
2193
+ var _match__replace_split = _sliced_to_array(match[0].replace(/#! ?/, '').split(' '), 2), path = _match__replace_split[0], argument = _match__replace_split[1];
2194
+ var binary = path.split('/').pop();
2195
+ if (binary === 'env') {
2196
+ return argument;
2197
+ }
2198
+ return argument ? "".concat(binary, " ").concat(argument) : binary;
2199
+ };
2200
+ return shebangCommand;
2201
+ }
2202
+
2203
+ var readShebang_1;
2204
+ var hasRequiredReadShebang;
2205
+
2206
+ function requireReadShebang () {
2207
+ if (hasRequiredReadShebang) return readShebang_1;
2208
+ hasRequiredReadShebang = 1;
2209
+ var fs = require$$0;
2210
+ var shebangCommand = requireShebangCommand();
2211
+ function readShebang(command) {
2212
+ // Read the first 150 bytes from the file
2213
+ var size = 150;
2214
+ var buffer = Buffer.alloc(size);
2215
+ var fd;
2216
+ try {
2217
+ fd = fs.openSync(command, 'r');
2218
+ fs.readSync(fd, buffer, 0, size, 0);
2219
+ fs.closeSync(fd);
2220
+ } catch (e) {}
2221
+ // Attempt to extract shebang (null is returned if not a shebang)
2222
+ return shebangCommand(buffer.toString());
2223
+ }
2224
+ readShebang_1 = readShebang;
2225
+ return readShebang_1;
2226
+ }
2227
+
2228
+ var parse_1;
2229
+ var hasRequiredParse;
2230
+
2231
+ function requireParse () {
2232
+ if (hasRequiredParse) return parse_1;
2233
+ hasRequiredParse = 1;
2234
+ var path = require$$0$1;
2235
+ var resolveCommand = requireResolveCommand();
2236
+ var escape = require_escape();
2237
+ var readShebang = requireReadShebang();
2238
+ var isWin = process.platform === 'win32';
2239
+ var isExecutableRegExp = /\.(?:com|exe)$/i;
2240
+ var isCmdShimRegExp = /node_modules[\\/].bin[\\/][^\\/]+\.cmd$/i;
2241
+ function detectShebang(parsed) {
2242
+ parsed.file = resolveCommand(parsed);
2243
+ var shebang = parsed.file && readShebang(parsed.file);
2244
+ if (shebang) {
2245
+ parsed.args.unshift(parsed.file);
2246
+ parsed.command = shebang;
2247
+ return resolveCommand(parsed);
2248
+ }
2249
+ return parsed.file;
2250
+ }
2251
+ function parseNonShell(parsed) {
2252
+ if (!isWin) {
2253
+ return parsed;
2254
+ }
2255
+ // Detect & add support for shebangs
2256
+ var commandFile = detectShebang(parsed);
2257
+ // We don't need a shell if the command filename is an executable
2258
+ var needsShell = !isExecutableRegExp.test(commandFile);
2259
+ // If a shell is required, use cmd.exe and take care of escaping everything correctly
2260
+ // Note that `forceShell` is an hidden option used only in tests
2261
+ if (parsed.options.forceShell || needsShell) {
2262
+ // Need to double escape meta chars if the command is a cmd-shim located in `node_modules/.bin/`
2263
+ // The cmd-shim simply calls execute the package bin file with NodeJS, proxying any argument
2264
+ // Because the escape of metachars with ^ gets interpreted when the cmd.exe is first called,
2265
+ // we need to double escape them
2266
+ var needsDoubleEscapeMetaChars = isCmdShimRegExp.test(commandFile);
2267
+ // Normalize posix paths into OS compatible paths (e.g.: foo/bar -> foo\bar)
2268
+ // This is necessary otherwise it will always fail with ENOENT in those cases
2269
+ parsed.command = path.normalize(parsed.command);
2270
+ // Escape command & arguments
2271
+ parsed.command = escape.command(parsed.command);
2272
+ parsed.args = parsed.args.map(function(arg) {
2273
+ return escape.argument(arg, needsDoubleEscapeMetaChars);
2274
+ });
2275
+ var shellCommand = [
2276
+ parsed.command
2277
+ ].concat(parsed.args).join(' ');
2278
+ parsed.args = [
2279
+ '/d',
2280
+ '/s',
2281
+ '/c',
2282
+ '"'.concat(shellCommand, '"')
2283
+ ];
2284
+ parsed.command = process.env.comspec || 'cmd.exe';
2285
+ parsed.options.windowsVerbatimArguments = true; // Tell node's spawn that the arguments are already escaped
2286
+ }
2287
+ return parsed;
2288
+ }
2289
+ function parse(command, args, options) {
2290
+ // Normalize arguments, similar to nodejs
2291
+ if (args && !Array.isArray(args)) {
2292
+ options = args;
2293
+ args = null;
2294
+ }
2295
+ args = args ? args.slice(0) : []; // Clone array to avoid changing the original
2296
+ options = Object.assign({}, options); // Clone object to avoid changing the original
2297
+ // Build our parsed object
2298
+ var parsed = {
2299
+ command: command,
2300
+ args: args,
2301
+ options: options,
2302
+ file: undefined,
2303
+ original: {
2304
+ command: command,
2305
+ args: args
2306
+ }
2307
+ };
2308
+ // Delegate further parsing to shell or non-shell
2309
+ return options.shell ? parsed : parseNonShell(parsed);
2310
+ }
2311
+ parse_1 = parse;
2312
+ return parse_1;
2313
+ }
2314
+
2315
+ var enoent;
2316
+ var hasRequiredEnoent;
2317
+
2318
+ function requireEnoent () {
2319
+ if (hasRequiredEnoent) return enoent;
2320
+ hasRequiredEnoent = 1;
2321
+ var isWin = process.platform === 'win32';
2322
+ function notFoundError(original, syscall) {
2323
+ return Object.assign(new Error("".concat(syscall, " ").concat(original.command, " ENOENT")), {
2324
+ code: 'ENOENT',
2325
+ errno: 'ENOENT',
2326
+ syscall: "".concat(syscall, " ").concat(original.command),
2327
+ path: original.command,
2328
+ spawnargs: original.args
2329
+ });
2330
+ }
2331
+ function hookChildProcess(cp, parsed) {
2332
+ if (!isWin) {
2333
+ return;
2334
+ }
2335
+ var originalEmit = cp.emit;
2336
+ cp.emit = function(name, arg1) {
2337
+ // If emitting "exit" event and exit code is 1, we need to check if
2338
+ // the command exists and emit an "error" instead
2339
+ // See https://github.com/IndigoUnited/node-cross-spawn/issues/16
2340
+ if (name === 'exit') {
2341
+ var err = verifyENOENT(arg1, parsed);
2342
+ if (err) {
2343
+ return originalEmit.call(cp, 'error', err);
2344
+ }
2345
+ }
2346
+ return originalEmit.apply(cp, arguments); // eslint-disable-line prefer-rest-params
2347
+ };
2348
+ }
2349
+ function verifyENOENT(status, parsed) {
2350
+ if (isWin && status === 1 && !parsed.file) {
2351
+ return notFoundError(parsed.original, 'spawn');
2352
+ }
2353
+ return null;
2354
+ }
2355
+ function verifyENOENTSync(status, parsed) {
2356
+ if (isWin && status === 1 && !parsed.file) {
2357
+ return notFoundError(parsed.original, 'spawnSync');
2358
+ }
2359
+ return null;
2360
+ }
2361
+ enoent = {
2362
+ hookChildProcess: hookChildProcess,
2363
+ verifyENOENT: verifyENOENT,
2364
+ verifyENOENTSync: verifyENOENTSync,
2365
+ notFoundError: notFoundError
2366
+ };
2367
+ return enoent;
2368
+ }
2369
+
2370
+ var hasRequiredCrossSpawn;
2371
+
2372
+ function requireCrossSpawn () {
2373
+ if (hasRequiredCrossSpawn) return crossSpawn.exports;
2374
+ hasRequiredCrossSpawn = 1;
2375
+ var cp = require$$0$2;
2376
+ var parse = requireParse();
2377
+ var enoent = requireEnoent();
2378
+ function spawn(command, args, options) {
2379
+ // Parse the arguments
2380
+ var parsed = parse(command, args, options);
2381
+ // Spawn the child process
2382
+ var spawned = cp.spawn(parsed.command, parsed.args, parsed.options);
2383
+ // Hook into child process "exit" event to emit an error if the command
2384
+ // does not exists, see: https://github.com/IndigoUnited/node-cross-spawn/issues/16
2385
+ enoent.hookChildProcess(spawned, parsed);
2386
+ return spawned;
2387
+ }
2388
+ function spawnSync(command, args, options) {
2389
+ // Parse the arguments
2390
+ var parsed = parse(command, args, options);
2391
+ // Spawn the child process
2392
+ var result = cp.spawnSync(parsed.command, parsed.args, parsed.options);
2393
+ // Analyze if the command does not exist, see: https://github.com/IndigoUnited/node-cross-spawn/issues/16
2394
+ result.error = result.error || enoent.verifyENOENTSync(result.status, parsed);
2395
+ return result;
2396
+ }
2397
+ crossSpawn.exports = spawn;
2398
+ crossSpawn.exports.spawn = spawn;
2399
+ crossSpawn.exports.sync = spawnSync;
2400
+ crossSpawn.exports._parse = parse;
2401
+ crossSpawn.exports._enoent = enoent;
2402
+ return crossSpawn.exports;
2403
+ }
2404
+
2405
+ var src = {
2406
+ exports: {}
2407
+ };
2408
+
2409
+ var browser$1 = {
2410
+ exports: {}
2411
+ };
2412
+
2413
+ /**
2414
+ * Helpers.
2415
+ */
2416
+
2417
+ var ms;
2418
+ var hasRequiredMs;
2419
+
2420
+ function requireMs () {
2421
+ if (hasRequiredMs) return ms;
2422
+ hasRequiredMs = 1;
2423
+ function _type_of(obj) {
2424
+ "@swc/helpers - typeof";
2425
+ return obj && typeof Symbol !== "undefined" && obj.constructor === Symbol ? "symbol" : typeof obj;
2426
+ }
2427
+ var s = 1000;
2428
+ var m = s * 60;
2429
+ var h = m * 60;
2430
+ var d = h * 24;
2431
+ var w = d * 7;
2432
+ var y = d * 365.25;
2433
+ /**
2434
+ * Parse or format the given `val`.
2435
+ *
2436
+ * Options:
2437
+ *
2438
+ * - `long` verbose formatting [false]
2439
+ *
2440
+ * @param {String|Number} val
2441
+ * @param {Object} [options]
2442
+ * @throws {Error} throw an error if val is not a non-empty string or a number
2443
+ * @return {String|Number}
2444
+ * @api public
2445
+ */ ms = function(val, options) {
2446
+ options = options || {};
2447
+ var type = typeof val === "undefined" ? "undefined" : _type_of(val);
2448
+ if (type === 'string' && val.length > 0) {
2449
+ return parse(val);
2450
+ } else if (type === 'number' && isFinite(val)) {
2451
+ return options.long ? fmtLong(val) : fmtShort(val);
2452
+ }
2453
+ throw new Error('val is not a non-empty string or a valid number. val=' + JSON.stringify(val));
2454
+ };
2455
+ /**
2456
+ * Parse the given `str` and return milliseconds.
2457
+ *
2458
+ * @param {String} str
2459
+ * @return {Number}
2460
+ * @api private
2461
+ */ function parse(str) {
2462
+ str = String(str);
2463
+ if (str.length > 100) {
2464
+ return;
2465
+ }
2466
+ var match = /^(-?(?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)?$/i.exec(str);
2467
+ if (!match) {
2468
+ return;
2469
+ }
2470
+ var n = parseFloat(match[1]);
2471
+ var type = (match[2] || 'ms').toLowerCase();
2472
+ switch(type){
2473
+ case 'years':
2474
+ case 'year':
2475
+ case 'yrs':
2476
+ case 'yr':
2477
+ case 'y':
2478
+ return n * y;
2479
+ case 'weeks':
2480
+ case 'week':
2481
+ case 'w':
2482
+ return n * w;
2483
+ case 'days':
2484
+ case 'day':
2485
+ case 'd':
2486
+ return n * d;
2487
+ case 'hours':
2488
+ case 'hour':
2489
+ case 'hrs':
2490
+ case 'hr':
2491
+ case 'h':
2492
+ return n * h;
2493
+ case 'minutes':
2494
+ case 'minute':
2495
+ case 'mins':
2496
+ case 'min':
2497
+ case 'm':
2498
+ return n * m;
2499
+ case 'seconds':
2500
+ case 'second':
2501
+ case 'secs':
2502
+ case 'sec':
2503
+ case 's':
2504
+ return n * s;
2505
+ case 'milliseconds':
2506
+ case 'millisecond':
2507
+ case 'msecs':
2508
+ case 'msec':
2509
+ case 'ms':
2510
+ return n;
2511
+ default:
2512
+ return undefined;
2513
+ }
2514
+ }
2515
+ /**
2516
+ * Short format for `ms`.
2517
+ *
2518
+ * @param {Number} ms
2519
+ * @return {String}
2520
+ * @api private
2521
+ */ function fmtShort(ms) {
2522
+ var msAbs = Math.abs(ms);
2523
+ if (msAbs >= d) {
2524
+ return Math.round(ms / d) + 'd';
2525
+ }
2526
+ if (msAbs >= h) {
2527
+ return Math.round(ms / h) + 'h';
2528
+ }
2529
+ if (msAbs >= m) {
2530
+ return Math.round(ms / m) + 'm';
2531
+ }
2532
+ if (msAbs >= s) {
2533
+ return Math.round(ms / s) + 's';
2534
+ }
2535
+ return ms + 'ms';
2536
+ }
2537
+ /**
2538
+ * Long format for `ms`.
2539
+ *
2540
+ * @param {Number} ms
2541
+ * @return {String}
2542
+ * @api private
2543
+ */ function fmtLong(ms) {
2544
+ var msAbs = Math.abs(ms);
2545
+ if (msAbs >= d) {
2546
+ return plural(ms, msAbs, d, 'day');
2547
+ }
2548
+ if (msAbs >= h) {
2549
+ return plural(ms, msAbs, h, 'hour');
2550
+ }
2551
+ if (msAbs >= m) {
2552
+ return plural(ms, msAbs, m, 'minute');
2553
+ }
2554
+ if (msAbs >= s) {
2555
+ return plural(ms, msAbs, s, 'second');
2556
+ }
2557
+ return ms + ' ms';
2558
+ }
2559
+ /**
2560
+ * Pluralization helper.
2561
+ */ function plural(ms, msAbs, n, name) {
2562
+ var isPlural = msAbs >= n * 1.5;
2563
+ return Math.round(ms / n) + ' ' + name + (isPlural ? 's' : '');
2564
+ }
2565
+ return ms;
2566
+ }
2567
+
2568
+ var common$1;
2569
+ var hasRequiredCommon;
2570
+
2571
+ function requireCommon () {
2572
+ if (hasRequiredCommon) return common$1;
2573
+ hasRequiredCommon = 1;
2574
+ function _instanceof(left, right) {
2575
+ if (right != null && typeof Symbol !== "undefined" && right[Symbol.hasInstance]) {
2576
+ return !!right[Symbol.hasInstance](left);
2577
+ } else {
2578
+ return left instanceof right;
2579
+ }
2580
+ }
2581
+ /**
2582
+ * This is the common logic for both the Node.js and web browser
2583
+ * implementations of `debug()`.
2584
+ */ function setup(env) {
2585
+ createDebug.debug = createDebug;
2586
+ createDebug.default = createDebug;
2587
+ createDebug.coerce = coerce;
2588
+ createDebug.disable = disable;
2589
+ createDebug.enable = enable;
2590
+ createDebug.enabled = enabled;
2591
+ createDebug.humanize = requireMs();
2592
+ Object.keys(env).forEach(function(key) {
2593
+ createDebug[key] = env[key];
2594
+ });
2595
+ /**
2596
+ * Active `debug` instances.
2597
+ */ createDebug.instances = [];
2598
+ /**
2599
+ * The currently active debug mode names, and names to skip.
2600
+ */ createDebug.names = [];
2601
+ createDebug.skips = [];
2602
+ /**
2603
+ * Map of special "%n" handling functions, for the debug "format" argument.
2604
+ *
2605
+ * Valid key names are a single, lower or upper-case letter, i.e. "n" and "N".
2606
+ */ createDebug.formatters = {};
2607
+ /**
2608
+ * Selects a color for a debug namespace
2609
+ * @param {String} namespace The namespace string for the for the debug instance to be colored
2610
+ * @return {Number|String} An ANSI color code for the given namespace
2611
+ * @api private
2612
+ */ function selectColor(namespace) {
2613
+ var hash = 0;
2614
+ for(var i = 0; i < namespace.length; i++){
2615
+ hash = (hash << 5) - hash + namespace.charCodeAt(i);
2616
+ hash |= 0; // Convert to 32bit integer
2617
+ }
2618
+ return createDebug.colors[Math.abs(hash) % createDebug.colors.length];
2619
+ }
2620
+ createDebug.selectColor = selectColor;
2621
+ /**
2622
+ * Create a debugger with the given `namespace`.
2623
+ *
2624
+ * @param {String} namespace
2625
+ * @return {Function}
2626
+ * @api public
2627
+ */ function createDebug(namespace) {
2628
+ var prevTime;
2629
+ function debug() {
2630
+ // Disabled?
2631
+ if (!debug.enabled) {
2632
+ return;
2633
+ }
2634
+ for(var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++){
2635
+ args[_key] = arguments[_key];
2636
+ }
2637
+ var self = debug; // Set `diff` timestamp
2638
+ var curr = Number(new Date());
2639
+ var ms = curr - (prevTime || curr);
2640
+ self.diff = ms;
2641
+ self.prev = prevTime;
2642
+ self.curr = curr;
2643
+ prevTime = curr;
2644
+ args[0] = createDebug.coerce(args[0]);
2645
+ if (typeof args[0] !== 'string') {
2646
+ // Anything else let's inspect with %O
2647
+ args.unshift('%O');
2648
+ } // Apply any `formatters` transformations
2649
+ var index = 0;
2650
+ args[0] = args[0].replace(/%([a-zA-Z%])/g, function(match, format) {
2651
+ // If we encounter an escaped % then don't increase the array index
2652
+ if (match === '%%') {
2653
+ return match;
2654
+ }
2655
+ index++;
2656
+ var formatter = createDebug.formatters[format];
2657
+ if (typeof formatter === 'function') {
2658
+ var val = args[index];
2659
+ match = formatter.call(self, val); // Now we need to remove `args[index]` since it's inlined in the `format`
2660
+ args.splice(index, 1);
2661
+ index--;
2662
+ }
2663
+ return match;
2664
+ }); // Apply env-specific formatting (colors, etc.)
2665
+ createDebug.formatArgs.call(self, args);
2666
+ var logFn = self.log || createDebug.log;
2667
+ logFn.apply(self, args);
2668
+ }
2669
+ debug.namespace = namespace;
2670
+ debug.enabled = createDebug.enabled(namespace);
2671
+ debug.useColors = createDebug.useColors();
2672
+ debug.color = selectColor(namespace);
2673
+ debug.destroy = destroy;
2674
+ debug.extend = extend; // Debug.formatArgs = formatArgs;
2675
+ // debug.rawLog = rawLog;
2676
+ // env-specific initialization logic for debug instances
2677
+ if (typeof createDebug.init === 'function') {
2678
+ createDebug.init(debug);
2679
+ }
2680
+ createDebug.instances.push(debug);
2681
+ return debug;
2682
+ }
2683
+ function destroy() {
2684
+ var index = createDebug.instances.indexOf(this);
2685
+ if (index !== -1) {
2686
+ createDebug.instances.splice(index, 1);
2687
+ return true;
2688
+ }
2689
+ return false;
2690
+ }
2691
+ function extend(namespace, delimiter) {
2692
+ return createDebug(this.namespace + (typeof delimiter === 'undefined' ? ':' : delimiter) + namespace);
2693
+ }
2694
+ /**
2695
+ * Enables a debug mode by namespaces. This can include modes
2696
+ * separated by a colon and wildcards.
2697
+ *
2698
+ * @param {String} namespaces
2699
+ * @api public
2700
+ */ function enable(namespaces) {
2701
+ createDebug.save(namespaces);
2702
+ createDebug.names = [];
2703
+ createDebug.skips = [];
2704
+ var i;
2705
+ var split = (typeof namespaces === 'string' ? namespaces : '').split(/[\s,]+/);
2706
+ var len = split.length;
2707
+ for(i = 0; i < len; i++){
2708
+ if (!split[i]) {
2709
+ continue;
2710
+ }
2711
+ namespaces = split[i].replace(/\*/g, '.*?');
2712
+ if (namespaces[0] === '-') {
2713
+ createDebug.skips.push(new RegExp('^' + namespaces.substr(1) + '$'));
2714
+ } else {
2715
+ createDebug.names.push(new RegExp('^' + namespaces + '$'));
2716
+ }
2717
+ }
2718
+ for(i = 0; i < createDebug.instances.length; i++){
2719
+ var instance = createDebug.instances[i];
2720
+ instance.enabled = createDebug.enabled(instance.namespace);
2721
+ }
2722
+ }
2723
+ /**
2724
+ * Disable debug output.
2725
+ *
2726
+ * @api public
2727
+ */ function disable() {
2728
+ createDebug.enable('');
2729
+ }
2730
+ /**
2731
+ * Returns true if the given mode name is enabled, false otherwise.
2732
+ *
2733
+ * @param {String} name
2734
+ * @return {Boolean}
2735
+ * @api public
2736
+ */ function enabled(name) {
2737
+ if (name[name.length - 1] === '*') {
2738
+ return true;
2739
+ }
2740
+ var i;
2741
+ var len;
2742
+ for(i = 0, len = createDebug.skips.length; i < len; i++){
2743
+ if (createDebug.skips[i].test(name)) {
2744
+ return false;
2745
+ }
2746
+ }
2747
+ for(i = 0, len = createDebug.names.length; i < len; i++){
2748
+ if (createDebug.names[i].test(name)) {
2749
+ return true;
2750
+ }
2751
+ }
2752
+ return false;
2753
+ }
2754
+ /**
2755
+ * Coerce `val`.
2756
+ *
2757
+ * @param {Mixed} val
2758
+ * @return {Mixed}
2759
+ * @api private
2760
+ */ function coerce(val) {
2761
+ if (_instanceof(val, Error)) {
2762
+ return val.stack || val.message;
2763
+ }
2764
+ return val;
2765
+ }
2766
+ createDebug.enable(createDebug.load());
2767
+ return createDebug;
2768
+ }
2769
+ common$1 = setup;
2770
+ return common$1;
2771
+ }
2772
+
2773
+ var hasRequiredBrowser$1;
2774
+
2775
+ function requireBrowser$1 () {
2776
+ if (hasRequiredBrowser$1) return browser$1.exports;
2777
+ hasRequiredBrowser$1 = 1;
2778
+ (function (module, exports) {
2779
+ function _type_of(obj) {
2780
+ "@swc/helpers - typeof";
2781
+ return obj && typeof Symbol !== "undefined" && obj.constructor === Symbol ? "symbol" : typeof obj;
2782
+ }
2783
+ function _typeof(obj) {
2784
+ if (typeof Symbol === "function" && _type_of(Symbol.iterator) === "symbol") {
2785
+ _typeof = function _typeof(obj) {
2786
+ return typeof obj === "undefined" ? "undefined" : _type_of(obj);
2787
+ };
2788
+ } else {
2789
+ _typeof = function _typeof(obj) {
2790
+ return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj === "undefined" ? "undefined" : _type_of(obj);
2791
+ };
2792
+ }
2793
+ return _typeof(obj);
2794
+ }
2795
+ /* eslint-env browser */ /**
2796
+ * This is the web browser implementation of `debug()`.
2797
+ */ exports.log = log;
2798
+ exports.formatArgs = formatArgs;
2799
+ exports.save = save;
2800
+ exports.load = load;
2801
+ exports.useColors = useColors;
2802
+ exports.storage = localstorage();
2803
+ /**
2804
+ * Colors.
2805
+ */ exports.colors = [
2806
+ '#0000CC',
2807
+ '#0000FF',
2808
+ '#0033CC',
2809
+ '#0033FF',
2810
+ '#0066CC',
2811
+ '#0066FF',
2812
+ '#0099CC',
2813
+ '#0099FF',
2814
+ '#00CC00',
2815
+ '#00CC33',
2816
+ '#00CC66',
2817
+ '#00CC99',
2818
+ '#00CCCC',
2819
+ '#00CCFF',
2820
+ '#3300CC',
2821
+ '#3300FF',
2822
+ '#3333CC',
2823
+ '#3333FF',
2824
+ '#3366CC',
2825
+ '#3366FF',
2826
+ '#3399CC',
2827
+ '#3399FF',
2828
+ '#33CC00',
2829
+ '#33CC33',
2830
+ '#33CC66',
2831
+ '#33CC99',
2832
+ '#33CCCC',
2833
+ '#33CCFF',
2834
+ '#6600CC',
2835
+ '#6600FF',
2836
+ '#6633CC',
2837
+ '#6633FF',
2838
+ '#66CC00',
2839
+ '#66CC33',
2840
+ '#9900CC',
2841
+ '#9900FF',
2842
+ '#9933CC',
2843
+ '#9933FF',
2844
+ '#99CC00',
2845
+ '#99CC33',
2846
+ '#CC0000',
2847
+ '#CC0033',
2848
+ '#CC0066',
2849
+ '#CC0099',
2850
+ '#CC00CC',
2851
+ '#CC00FF',
2852
+ '#CC3300',
2853
+ '#CC3333',
2854
+ '#CC3366',
2855
+ '#CC3399',
2856
+ '#CC33CC',
2857
+ '#CC33FF',
2858
+ '#CC6600',
2859
+ '#CC6633',
2860
+ '#CC9900',
2861
+ '#CC9933',
2862
+ '#CCCC00',
2863
+ '#CCCC33',
2864
+ '#FF0000',
2865
+ '#FF0033',
2866
+ '#FF0066',
2867
+ '#FF0099',
2868
+ '#FF00CC',
2869
+ '#FF00FF',
2870
+ '#FF3300',
2871
+ '#FF3333',
2872
+ '#FF3366',
2873
+ '#FF3399',
2874
+ '#FF33CC',
2875
+ '#FF33FF',
2876
+ '#FF6600',
2877
+ '#FF6633',
2878
+ '#FF9900',
2879
+ '#FF9933',
2880
+ '#FFCC00',
2881
+ '#FFCC33'
2882
+ ];
2883
+ /**
2884
+ * Currently only WebKit-based Web Inspectors, Firefox >= v31,
2885
+ * and the Firebug extension (any Firefox version) are known
2886
+ * to support "%c" CSS customizations.
2887
+ *
2888
+ * TODO: add a `localStorage` variable to explicitly enable/disable colors
2889
+ */ // eslint-disable-next-line complexity
2890
+ function useColors() {
2891
+ // NB: In an Electron preload script, document will be defined but not fully
2892
+ // initialized. Since we know we're in Chrome, we'll just detect this case
2893
+ // explicitly
2894
+ if (typeof window !== 'undefined' && window.process && (window.process.type === 'renderer' || window.process.__nwjs)) {
2895
+ return true;
2896
+ } // Internet Explorer and Edge do not support colors.
2897
+ if (typeof navigator !== 'undefined' && navigator.userAgent && navigator.userAgent.toLowerCase().match(/(edge|trident)\/(\d+)/)) {
2898
+ return false;
2899
+ } // Is webkit? http://stackoverflow.com/a/16459606/376773
2900
+ // document is undefined in react-native: https://github.com/facebook/react-native/pull/1632
2901
+ return typeof document !== 'undefined' && document.documentElement && document.documentElement.style && document.documentElement.style.WebkitAppearance || // Is firebug? http://stackoverflow.com/a/398120/376773
2902
+ typeof window !== 'undefined' && window.console && (window.console.firebug || window.console.exception && window.console.table) || // Is firefox >= v31?
2903
+ // https://developer.mozilla.org/en-US/docs/Tools/Web_Console#Styling_messages
2904
+ typeof navigator !== 'undefined' && navigator.userAgent && navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/) && parseInt(RegExp.$1, 10) >= 31 || // Double check webkit in userAgent just in case we are in a worker
2905
+ typeof navigator !== 'undefined' && navigator.userAgent && navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/);
2906
+ }
2907
+ /**
2908
+ * Colorize log arguments if enabled.
2909
+ *
2910
+ * @api public
2911
+ */ function formatArgs(args) {
2912
+ args[0] = (this.useColors ? '%c' : '') + this.namespace + (this.useColors ? ' %c' : ' ') + args[0] + (this.useColors ? '%c ' : ' ') + '+' + module.exports.humanize(this.diff);
2913
+ if (!this.useColors) {
2914
+ return;
2915
+ }
2916
+ var c = 'color: ' + this.color;
2917
+ args.splice(1, 0, c, 'color: inherit'); // The final "%c" is somewhat tricky, because there could be other
2918
+ // arguments passed either before or after the %c, so we need to
2919
+ // figure out the correct index to insert the CSS into
2920
+ var index = 0;
2921
+ var lastC = 0;
2922
+ args[0].replace(/%[a-zA-Z%]/g, function(match) {
2923
+ if (match === '%%') {
2924
+ return;
2925
+ }
2926
+ index++;
2927
+ if (match === '%c') {
2928
+ // We only are interested in the *last* %c
2929
+ // (the user may have provided their own)
2930
+ lastC = index;
2931
+ }
2932
+ });
2933
+ args.splice(lastC, 0, c);
2934
+ }
2935
+ /**
2936
+ * Invokes `console.log()` when available.
2937
+ * No-op when `console.log` is not a "function".
2938
+ *
2939
+ * @api public
2940
+ */ function log() {
2941
+ var _console;
2942
+ // This hackery is required for IE8/9, where
2943
+ // the `console.log` function doesn't have 'apply'
2944
+ return (typeof console === "undefined" ? "undefined" : _typeof(console)) === 'object' && console.log && (_console = console).log.apply(_console, arguments);
2945
+ }
2946
+ /**
2947
+ * Save `namespaces`.
2948
+ *
2949
+ * @param {String} namespaces
2950
+ * @api private
2951
+ */ function save(namespaces) {
2952
+ try {
2953
+ if (namespaces) {
2954
+ exports.storage.setItem('debug', namespaces);
2955
+ } else {
2956
+ exports.storage.removeItem('debug');
2957
+ }
2958
+ } catch (error) {
2959
+ // XXX (@Qix-) should we be logging these?
2960
+ }
2961
+ }
2962
+ /**
2963
+ * Load `namespaces`.
2964
+ *
2965
+ * @return {String} returns the previously persisted debug modes
2966
+ * @api private
2967
+ */ function load() {
2968
+ var r;
2969
+ try {
2970
+ r = exports.storage.getItem('debug');
2971
+ } catch (error) {} // Swallow
2972
+ // XXX (@Qix-) should we be logging these?
2973
+ // If debug isn't set in LS, and we're in Electron, try to load $DEBUG
2974
+ if (!r && typeof process !== 'undefined' && 'env' in process) {
2975
+ r = process.env.DEBUG;
2976
+ }
2977
+ return r;
2978
+ }
2979
+ /**
2980
+ * Localstorage attempts to return the localstorage.
2981
+ *
2982
+ * This is necessary because safari throws
2983
+ * when a user disables cookies/localstorage
2984
+ * and you attempt to access it.
2985
+ *
2986
+ * @return {LocalStorage}
2987
+ * @api private
2988
+ */ function localstorage() {
2989
+ try {
2990
+ // TVMLKit (Apple TV JS Runtime) does not have a window object, just localStorage in the global context
2991
+ // The Browser also has localStorage in the global context.
2992
+ return localStorage;
2993
+ } catch (error) {
2994
+ // XXX (@Qix-) should we be logging these?
2995
+ }
2996
+ }
2997
+ module.exports = requireCommon()(exports);
2998
+ var formatters = module.exports.formatters;
2999
+ /**
3000
+ * Map %j to `JSON.stringify()`, since no Web Inspectors do that by default.
3001
+ */ formatters.j = function(v) {
3002
+ try {
3003
+ return JSON.stringify(v);
3004
+ } catch (error) {
3005
+ return '[UnexpectedJSONParseError]: ' + error.message;
3006
+ }
3007
+ };
3008
+ } (browser$1, browser$1.exports));
3009
+ return browser$1.exports;
3010
+ }
3011
+
3012
+ var node = {
3013
+ exports: {}
3014
+ };
3015
+
3016
+ /* eslint-env browser */
3017
+
3018
+ var browser;
3019
+ var hasRequiredBrowser;
3020
+
3021
+ function requireBrowser () {
3022
+ if (hasRequiredBrowser) return browser;
3023
+ hasRequiredBrowser = 1;
3024
+ function getChromeVersion() {
3025
+ var matches = RegExp("(Chrome|Chromium)\\/(?<chromeVersion>\\d+)\\.").exec(navigator.userAgent);
3026
+ if (!matches) {
3027
+ return;
3028
+ }
3029
+ return Number.parseInt(matches.groups.chromeVersion, 10);
3030
+ }
3031
+ var colorSupport = getChromeVersion() >= 69 ? {
3032
+ level: 1,
3033
+ hasBasic: true,
3034
+ has256: false,
3035
+ has16m: false
3036
+ } : false;
3037
+ browser = {
3038
+ stdout: colorSupport,
3039
+ stderr: colorSupport
3040
+ };
3041
+ return browser;
3042
+ }
3043
+
3044
+ var hasRequiredNode;
3045
+
3046
+ function requireNode () {
3047
+ if (hasRequiredNode) return node.exports;
3048
+ hasRequiredNode = 1;
3049
+ (function (module, exports) {
3050
+ /**
3051
+ * Module dependencies.
3052
+ */ var tty = require$$0$3;
3053
+ var util = require$$1;
3054
+ /**
3055
+ * This is the Node.js implementation of `debug()`.
3056
+ */ exports.init = init;
3057
+ exports.log = log;
3058
+ exports.formatArgs = formatArgs;
3059
+ exports.save = save;
3060
+ exports.load = load;
3061
+ exports.useColors = useColors;
3062
+ /**
3063
+ * Colors.
3064
+ */ exports.colors = [
3065
+ 6,
3066
+ 2,
3067
+ 3,
3068
+ 4,
3069
+ 5,
3070
+ 1
3071
+ ];
3072
+ try {
3073
+ // Optional dependency (as in, doesn't need to be installed, NOT like optionalDependencies in package.json)
3074
+ // eslint-disable-next-line import/no-extraneous-dependencies
3075
+ var supportsColor = requireBrowser();
3076
+ if (supportsColor && (supportsColor.stderr || supportsColor).level >= 2) {
3077
+ exports.colors = [
3078
+ 20,
3079
+ 21,
3080
+ 26,
3081
+ 27,
3082
+ 32,
3083
+ 33,
3084
+ 38,
3085
+ 39,
3086
+ 40,
3087
+ 41,
3088
+ 42,
3089
+ 43,
3090
+ 44,
3091
+ 45,
3092
+ 56,
3093
+ 57,
3094
+ 62,
3095
+ 63,
3096
+ 68,
3097
+ 69,
3098
+ 74,
3099
+ 75,
3100
+ 76,
3101
+ 77,
3102
+ 78,
3103
+ 79,
3104
+ 80,
3105
+ 81,
3106
+ 92,
3107
+ 93,
3108
+ 98,
3109
+ 99,
3110
+ 112,
3111
+ 113,
3112
+ 128,
3113
+ 129,
3114
+ 134,
3115
+ 135,
3116
+ 148,
3117
+ 149,
3118
+ 160,
3119
+ 161,
3120
+ 162,
3121
+ 163,
3122
+ 164,
3123
+ 165,
3124
+ 166,
3125
+ 167,
3126
+ 168,
3127
+ 169,
3128
+ 170,
3129
+ 171,
3130
+ 172,
3131
+ 173,
3132
+ 178,
3133
+ 179,
3134
+ 184,
3135
+ 185,
3136
+ 196,
3137
+ 197,
3138
+ 198,
3139
+ 199,
3140
+ 200,
3141
+ 201,
3142
+ 202,
3143
+ 203,
3144
+ 204,
3145
+ 205,
3146
+ 206,
3147
+ 207,
3148
+ 208,
3149
+ 209,
3150
+ 214,
3151
+ 215,
3152
+ 220,
3153
+ 221
3154
+ ];
3155
+ }
3156
+ } catch (error) {} // Swallow - we only care if `supports-color` is available; it doesn't have to be.
3157
+ /**
3158
+ * Build up the default `inspectOpts` object from the environment variables.
3159
+ *
3160
+ * $ DEBUG_COLORS=no DEBUG_DEPTH=10 DEBUG_SHOW_HIDDEN=enabled node script.js
3161
+ */ exports.inspectOpts = Object.keys(process.env).filter(function(key) {
3162
+ return /^debug_/i.test(key);
3163
+ }).reduce(function(obj, key) {
3164
+ // Camel-case
3165
+ var prop = key.substring(6).toLowerCase().replace(/_([a-z])/g, function(_, k) {
3166
+ return k.toUpperCase();
3167
+ }); // Coerce string value into JS value
3168
+ var val = process.env[key];
3169
+ if (/^(yes|on|true|enabled)$/i.test(val)) {
3170
+ val = true;
3171
+ } else if (/^(no|off|false|disabled)$/i.test(val)) {
3172
+ val = false;
3173
+ } else if (val === 'null') {
3174
+ val = null;
3175
+ } else {
3176
+ val = Number(val);
3177
+ }
3178
+ obj[prop] = val;
3179
+ return obj;
3180
+ }, {});
3181
+ /**
3182
+ * Is stdout a TTY? Colored output is enabled when `true`.
3183
+ */ function useColors() {
3184
+ return 'colors' in exports.inspectOpts ? Boolean(exports.inspectOpts.colors) : tty.isatty(process.stderr.fd);
3185
+ }
3186
+ /**
3187
+ * Adds ANSI color escape codes if enabled.
3188
+ *
3189
+ * @api public
3190
+ */ function formatArgs(args) {
3191
+ var name = this.namespace, _$useColors = this.useColors;
3192
+ if (_$useColors) {
3193
+ var c = this.color;
3194
+ var colorCode = "\x1B[3" + (c < 8 ? c : '8;5;' + c);
3195
+ var prefix = " ".concat(colorCode, ";1m").concat(name, " \x1B[0m");
3196
+ args[0] = prefix + args[0].split('\n').join('\n' + prefix);
3197
+ args.push(colorCode + 'm+' + module.exports.humanize(this.diff) + "\x1B[0m");
3198
+ } else {
3199
+ args[0] = getDate() + name + ' ' + args[0];
3200
+ }
3201
+ }
3202
+ function getDate() {
3203
+ if (exports.inspectOpts.hideDate) {
3204
+ return '';
3205
+ }
3206
+ return new Date().toISOString() + ' ';
3207
+ }
3208
+ /**
3209
+ * Invokes `util.format()` with the specified arguments and writes to stderr.
3210
+ */ function log() {
3211
+ return process.stderr.write(util.format.apply(util, arguments) + '\n');
3212
+ }
3213
+ /**
3214
+ * Save `namespaces`.
3215
+ *
3216
+ * @param {String} namespaces
3217
+ * @api private
3218
+ */ function save(namespaces) {
3219
+ if (namespaces) {
3220
+ process.env.DEBUG = namespaces;
3221
+ } else {
3222
+ // If you set a process.env field to null or undefined, it gets cast to the
3223
+ // string 'null' or 'undefined'. Just delete instead.
3224
+ delete process.env.DEBUG;
3225
+ }
3226
+ }
3227
+ /**
3228
+ * Load `namespaces`.
3229
+ *
3230
+ * @return {String} returns the previously persisted debug modes
3231
+ * @api private
3232
+ */ function load() {
3233
+ return process.env.DEBUG;
3234
+ }
3235
+ /**
3236
+ * Init logic for `debug` instances.
3237
+ *
3238
+ * Create a new `inspectOpts` object in case `useColors` is set
3239
+ * differently for a particular `debug` instance.
3240
+ */ function init(debug) {
3241
+ debug.inspectOpts = {};
3242
+ var keys = Object.keys(exports.inspectOpts);
3243
+ for(var i = 0; i < keys.length; i++){
3244
+ debug.inspectOpts[keys[i]] = exports.inspectOpts[keys[i]];
3245
+ }
3246
+ }
3247
+ module.exports = requireCommon()(exports);
3248
+ var formatters = module.exports.formatters;
3249
+ /**
3250
+ * Map %o to `util.inspect()`, all on a single line.
3251
+ */ formatters.o = function(v) {
3252
+ this.inspectOpts.colors = this.useColors;
3253
+ return util.inspect(v, this.inspectOpts).split('\n').map(function(str) {
3254
+ return str.trim();
3255
+ }).join(' ');
3256
+ };
3257
+ /**
3258
+ * Map %O to `util.inspect()`, allowing multiple lines if needed.
3259
+ */ formatters.O = function(v) {
3260
+ this.inspectOpts.colors = this.useColors;
3261
+ return util.inspect(v, this.inspectOpts);
3262
+ };
3263
+ } (node, node.exports));
3264
+ return node.exports;
3265
+ }
3266
+
3267
+ var hasRequiredSrc;
3268
+
3269
+ function requireSrc () {
3270
+ if (hasRequiredSrc) return src.exports;
3271
+ hasRequiredSrc = 1;
3272
+ /**
3273
+ * Detect Electron renderer / nwjs process, which is node, but we should
3274
+ * treat as a browser.
3275
+ */ if (typeof process === 'undefined' || process.type === 'renderer' || process.browser === true || process.__nwjs) {
3276
+ src.exports = requireBrowser$1();
3277
+ } else {
3278
+ src.exports = requireNode();
3279
+ }
3280
+ return src.exports;
3281
+ }
3282
+
3283
+ var arraySeries;
3284
+ var hasRequiredArraySeries;
3285
+
3286
+ function requireArraySeries () {
3287
+ if (hasRequiredArraySeries) return arraySeries;
3288
+ hasRequiredArraySeries = 1;
3289
+ arraySeries = function series(fns, context, callback) {
3290
+ if (!callback) {
3291
+ if (typeof context === 'function') {
3292
+ callback = context;
3293
+ context = null;
3294
+ } else {
3295
+ callback = noop;
3296
+ }
3297
+ }
3298
+ if (!(fns && fns.length)) return callback();
3299
+ fns = fns.slice(0);
3300
+ var call = context ? function call() {
3301
+ fns.length ? fns.shift().call(context, next) : callback();
3302
+ } : function() {
3303
+ fns.length ? fns.shift()(next) : callback();
3304
+ };
3305
+ call();
3306
+ function next(err) {
3307
+ err ? callback(err) : call();
3308
+ }
3309
+ };
3310
+ function noop() {}
3311
+ return arraySeries;
3312
+ }
3313
+
3314
+ /**
3315
+ * Module dependencies.
3316
+ */
3317
+
3318
+ var command;
3319
+ var hasRequiredCommand;
3320
+
3321
+ function requireCommand () {
3322
+ if (hasRequiredCommand) return command;
3323
+ hasRequiredCommand = 1;
3324
+ var spawn = requireCrossSpawn();
3325
+ var utils = requireUtils();
3326
+ var debug = requireSrc()('gm');
3327
+ var series = requireArraySeries();
3328
+ var PassThrough = require$$4.PassThrough;
3329
+ /**
3330
+ * Error messaging.
3331
+ */ var noBufferConcat = 'gm v1.9.0+ required node v0.8+. Please update your version of node, downgrade gm < 1.9, or do not use `bufferStream`.';
3332
+ /**
3333
+ * Extend proto
3334
+ */ command = function(proto) {
3335
+ function args(prop) {
3336
+ return function args() {
3337
+ var len = arguments.length;
3338
+ var a = [];
3339
+ var i = 0;
3340
+ for(; i < len; ++i){
3341
+ a.push(arguments[i]);
3342
+ }
3343
+ this[prop] = this[prop].concat(a);
3344
+ return this;
3345
+ };
3346
+ }
3347
+ function streamToUnemptyBuffer(stream, callback) {
3348
+ var done = false;
3349
+ var buffers = [];
3350
+ stream.on('data', function(data) {
3351
+ buffers.push(data);
3352
+ });
3353
+ stream.on('end', function() {
3354
+ if (done) return;
3355
+ done = true;
3356
+ var result = Buffer.concat(buffers);
3357
+ buffers = null;
3358
+ if (result.length === 0) {
3359
+ var err = new Error("Stream yields empty buffer");
3360
+ callback(err, null);
3361
+ } else {
3362
+ callback(null, result);
3363
+ }
3364
+ });
3365
+ stream.on('error', function(err) {
3366
+ done = true;
3367
+ buffers = null;
3368
+ callback(err);
3369
+ });
3370
+ }
3371
+ proto.in = args('_in');
3372
+ proto.out = args('_out');
3373
+ proto._preprocessor = [];
3374
+ proto.preprocessor = args('_preprocessor');
3375
+ /**
3376
+ * Execute the command and write the image to the specified file name.
3377
+ *
3378
+ * @param {String} name
3379
+ * @param {Function} callback
3380
+ * @return {Object} gm
3381
+ */ proto.write = function write(name, callback) {
3382
+ if (!callback) callback = name, name = null;
3383
+ if ("function" !== typeof callback) {
3384
+ throw new TypeError("gm().write() expects a callback function");
3385
+ }
3386
+ if (!name) {
3387
+ return callback(TypeError("gm().write() expects a filename when writing new files"));
3388
+ }
3389
+ this.outname = name;
3390
+ var self = this;
3391
+ this._preprocess(function(err) {
3392
+ if (err) return callback(err);
3393
+ self._spawn(self.args(), true, callback);
3394
+ });
3395
+ };
3396
+ /**
3397
+ * Execute the command and return stdin and stderr
3398
+ * ReadableStreams providing the image data.
3399
+ * If no callback is passed, a "through" stream will be returned,
3400
+ * and stdout will be piped through, otherwise the error will be passed.
3401
+ *
3402
+ * @param {String} format (optional)
3403
+ * @param {Function} callback (optional)
3404
+ * @return {Stream}
3405
+ */ proto.stream = function stream(format, callback) {
3406
+ if (!callback && typeof format === 'function') {
3407
+ callback = format;
3408
+ format = null;
3409
+ }
3410
+ var throughStream;
3411
+ if ("function" !== typeof callback) {
3412
+ throughStream = new PassThrough();
3413
+ callback = function callback(err, stdout, stderr) {
3414
+ if (err) throughStream.emit('error', err);
3415
+ else stdout.pipe(throughStream);
3416
+ };
3417
+ }
3418
+ if (format) {
3419
+ format = format.split('.').pop();
3420
+ this.outname = format + ":-";
3421
+ }
3422
+ var self = this;
3423
+ this._preprocess(function(err) {
3424
+ if (err) return callback(err);
3425
+ return self._spawn(self.args(), false, callback);
3426
+ });
3427
+ return throughStream || this;
3428
+ };
3429
+ /**
3430
+ * Convenience function for `proto.stream`.
3431
+ * Simply returns the buffer instead of the stream.
3432
+ *
3433
+ * @param {String} format (optional)
3434
+ * @param {Function} callback
3435
+ * @return {null}
3436
+ */ proto.toBuffer = function toBuffer(format, callback) {
3437
+ if (!callback) callback = format, format = null;
3438
+ if ("function" !== typeof callback) {
3439
+ throw new Error('gm().toBuffer() expects a callback.');
3440
+ }
3441
+ return this.stream(format, function(err, stdout) {
3442
+ if (err) return callback(err);
3443
+ streamToUnemptyBuffer(stdout, callback);
3444
+ });
3445
+ };
3446
+ /**
3447
+ * Run any preProcessor functions in series. Used by autoOrient.
3448
+ *
3449
+ * @param {Function} callback
3450
+ * @return {Object} gm
3451
+ */ proto._preprocess = function _preprocess(callback) {
3452
+ series(this._preprocessor, this, callback);
3453
+ };
3454
+ /**
3455
+ * Execute the command, buffer input and output, return stdout and stderr buffers.
3456
+ *
3457
+ * @param {String} bin
3458
+ * @param {Array} args
3459
+ * @param {Function} callback
3460
+ * @return {Object} gm
3461
+ */ proto._exec = function _exec(args, callback) {
3462
+ return this._spawn(args, true, callback);
3463
+ };
3464
+ /**
3465
+ * Execute the command with stdin, returning stdout and stderr streams or buffers.
3466
+ * @param {String} bin
3467
+ * @param {Array} args
3468
+ * @param {ReadableStream} stream
3469
+ * @param {Boolean} shouldBuffer
3470
+ * @param {Function} callback, signature (err, stdout, stderr) -> *
3471
+ * @return {Object} gm
3472
+ * @TODO refactor this mess
3473
+ */ proto._spawn = function _spawn(args, bufferOutput, callback) {
3474
+ var appPath = this._options.appPath || '';
3475
+ var bin;
3476
+ // Resolve executable
3477
+ switch(this._options.imageMagick){
3478
+ // legacy behavior
3479
+ case true:
3480
+ bin = args.shift();
3481
+ break;
3482
+ // ImgeMagick >= 7
3483
+ case '7+':
3484
+ bin = 'magick';
3485
+ break;
3486
+ // GraphicsMagick
3487
+ default:
3488
+ bin = 'gm';
3489
+ break;
3490
+ }
3491
+ // Prepend app path
3492
+ bin = appPath + bin;
3493
+ var cmd = bin + ' ' + args.map(utils.escape).join(' '), self = this, proc, timeout = parseInt(this._options.timeout), disposers = this._options.disposers, timeoutId;
3494
+ debug(cmd);
3495
+ //imageMagick does not support minify (https://github.com/aheckmann/gm/issues/385)
3496
+ if (args.indexOf("-minify") > -1 && this._options.imageMagick) {
3497
+ return cb(new Error("imageMagick does not support minify, use -scale or -sample. Alternatively, use graphicsMagick"));
3498
+ }
3499
+ try {
3500
+ proc = spawn(bin, args);
3501
+ } catch (e) {
3502
+ return cb(e);
3503
+ }
3504
+ proc.stdin.once('error', cb);
3505
+ proc.on('error', function(err) {
3506
+ if (err.code === 'ENOENT') {
3507
+ cb(new Error('Could not execute GraphicsMagick/ImageMagick: ' + cmd + " this most likely means the gm/convert binaries can't be found"));
3508
+ } else {
3509
+ cb(err);
3510
+ }
3511
+ });
3512
+ if (timeout) {
3513
+ timeoutId = setTimeout(function() {
3514
+ dispose('gm() resulted in a timeout.');
3515
+ }, timeout);
3516
+ }
3517
+ if (disposers) {
3518
+ disposers.forEach(function(disposer) {
3519
+ disposer.events.forEach(function(event) {
3520
+ disposer.emitter.on(event, dispose);
3521
+ });
3522
+ });
3523
+ }
3524
+ if (self.sourceBuffer) {
3525
+ proc.stdin.write(this.sourceBuffer);
3526
+ proc.stdin.end();
3527
+ } else if (self.sourceStream) {
3528
+ if (!self.sourceStream.readable) {
3529
+ return cb(new Error("gm().stream() or gm().write() with a non-readable stream."));
3530
+ }
3531
+ self.sourceStream.pipe(proc.stdin);
3532
+ // bufferStream
3533
+ // We convert the input source from a stream to a buffer.
3534
+ if (self.bufferStream && !this._buffering) {
3535
+ if (!Buffer.concat) {
3536
+ throw new Error(noBufferConcat);
3537
+ }
3538
+ // Incase there are multiple processes in parallel,
3539
+ // we only need one
3540
+ self._buffering = true;
3541
+ streamToUnemptyBuffer(self.sourceStream, function(err, buffer) {
3542
+ self.sourceBuffer = buffer;
3543
+ self.sourceStream = null; // The stream is now dead
3544
+ });
3545
+ }
3546
+ }
3547
+ // for _exec operations (identify() mostly), we also
3548
+ // need to buffer the output stream before returning
3549
+ if (bufferOutput) {
3550
+ var stdout = '', stderr = '';
3551
+ proc.stdout.on('data', function onOut(data) {
3552
+ stdout += data;
3553
+ });
3554
+ proc.stderr.on('data', function onErr(data) {
3555
+ stderr += data;
3556
+ });
3557
+ proc.on('close', function(code, signal) {
3558
+ var err;
3559
+ if (code !== 0 || signal !== null) {
3560
+ err = new Error('Command failed: ' + stderr);
3561
+ err.code = code;
3562
+ err.signal = signal;
3563
+ }
3564
+ cb(err, stdout, stderr, cmd);
3565
+ stdout = stderr = null;
3566
+ });
3567
+ } else {
3568
+ cb(null, proc.stdout, proc.stderr, cmd);
3569
+ }
3570
+ return self;
3571
+ function cb(err, stdout, stderr, cmd) {
3572
+ if (cb.called) return;
3573
+ if (timeoutId) clearTimeout(timeoutId);
3574
+ cb.called = 1;
3575
+ if (args[0] !== 'identify' && bin !== 'identify') {
3576
+ self._in = [];
3577
+ self._out = [];
3578
+ }
3579
+ callback.call(self, err, stdout, stderr, cmd);
3580
+ }
3581
+ function dispose(msg) {
3582
+ var message = msg ? msg : 'gm() was disposed';
3583
+ var err = new Error(message);
3584
+ cb(err);
3585
+ if (proc.exitCode === null) {
3586
+ proc.stdin.pause();
3587
+ proc.kill();
3588
+ }
3589
+ }
3590
+ };
3591
+ /**
3592
+ * Returns arguments to be used in the command.
3593
+ *
3594
+ * @return {Array}
3595
+ */ proto.args = function args() {
3596
+ var outname = this.outname || "-";
3597
+ if (this._outputFormat) outname = this._outputFormat + ':' + outname;
3598
+ return [].concat(this._subCommand, this._in, this.src(), this._out, outname).filter(Boolean); // remove falsey
3599
+ };
3600
+ /**
3601
+ * Adds an img source formatter.
3602
+ *
3603
+ * `formatters` are passed an array of images which will be
3604
+ * used as 'input' images for the command. Useful for methods
3605
+ * like `.append()` where multiple source images may be used.
3606
+ *
3607
+ * @param {Function} formatter
3608
+ * @return {gm} this
3609
+ */ proto.addSrcFormatter = function addSrcFormatter(formatter) {
3610
+ if ('function' != typeof formatter) throw new TypeError('sourceFormatter must be a function');
3611
+ this._sourceFormatters || (this._sourceFormatters = []);
3612
+ this._sourceFormatters.push(formatter);
3613
+ return this;
3614
+ };
3615
+ /**
3616
+ * Applies all _sourceFormatters
3617
+ *
3618
+ * @return {Array}
3619
+ */ proto.src = function src() {
3620
+ var arr = [];
3621
+ for(var i = 0; i < this._sourceFormatters.length; ++i){
3622
+ this._sourceFormatters[i].call(this, arr);
3623
+ }
3624
+ return arr;
3625
+ };
3626
+ /**
3627
+ * Image types.
3628
+ */ var types = {
3629
+ 'jpg': /\.jpe?g$/i,
3630
+ 'png': /\.png$/i,
3631
+ 'gif': /\.gif$/i,
3632
+ 'tiff': /\.tif?f$/i,
3633
+ 'bmp': /(?:\.bmp|\.dib)$/i,
3634
+ 'webp': /\.webp$/i
3635
+ };
3636
+ types.jpeg = types.jpg;
3637
+ types.tif = types.tiff;
3638
+ types.dib = types.bmp;
3639
+ /**
3640
+ * Determine the type of source image.
3641
+ *
3642
+ * @param {String} type
3643
+ * @return {Boolean}
3644
+ * @example
3645
+ * if (this.inputIs('png')) ...
3646
+ */ proto.inputIs = function inputIs(type) {
3647
+ if (!type) return false;
3648
+ var rgx = types[type];
3649
+ if (!rgx) {
3650
+ if ('.' !== type[0]) type = '.' + type;
3651
+ rgx = new RegExp('\\' + type + '$', 'i');
3652
+ }
3653
+ return rgx.test(this.source);
3654
+ };
3655
+ /**
3656
+ * add disposer (like 'close' of http.IncomingMessage) in order to dispose gm() with any event
3657
+ *
3658
+ * @param {EventEmitter} emitter
3659
+ * @param {Array} events
3660
+ * @return {Object} gm
3661
+ * @example
3662
+ * command.addDisposer(req, ['close', 'end', 'finish']);
3663
+ */ proto.addDisposer = function addDisposer(emitter, events) {
3664
+ if (!this._options.disposers) {
3665
+ this._options.disposers = [];
3666
+ }
3667
+ this._options.disposers.push({
3668
+ emitter: emitter,
3669
+ events: events
3670
+ });
3671
+ return this;
3672
+ };
3673
+ };
3674
+ return command;
3675
+ }
3676
+
3677
+ var compare = {
3678
+ exports: {}
3679
+ };
3680
+
3681
+ var hasRequiredCompare;
3682
+
3683
+ function requireCompare () {
3684
+ if (hasRequiredCompare) return compare.exports;
3685
+ hasRequiredCompare = 1;
3686
+ (function (module, exports) {
3687
+ // compare
3688
+ function _type_of(obj) {
3689
+ "@swc/helpers - typeof";
3690
+ return obj && typeof Symbol !== "undefined" && obj.constructor === Symbol ? "symbol" : typeof obj;
3691
+ }
3692
+ var spawn = requireCrossSpawn();
3693
+ var debug = requireSrc()('gm');
3694
+ var utils = requireUtils();
3695
+ /**
3696
+ * Compare two images uses graphicsmagicks `compare` command.
3697
+ *
3698
+ * gm.compare(img1, img2, 0.4, function (err, equal, equality) {
3699
+ * if (err) return handle(err);
3700
+ * console.log('The images are equal: %s', equal);
3701
+ * console.log('There equality was %d', equality);
3702
+ * });
3703
+ *
3704
+ * @param {String} orig Path to an image.
3705
+ * @param {String} compareTo Path to another image to compare to `orig`.
3706
+ * @param {Number|Object} [options] Options object or the amount of difference to tolerate before failing - defaults to 0.4
3707
+ * @param {Function} cb(err, Boolean, equality, rawOutput)
3708
+ */ module.exports = function exports1(proto) {
3709
+ function compare(orig, compareTo, options, cb) {
3710
+ var isImageMagick = this._options && this._options.imageMagick;
3711
+ var appPath = this._options && this._options.appPath || '';
3712
+ var args = [
3713
+ '-metric',
3714
+ 'mse',
3715
+ orig,
3716
+ compareTo
3717
+ ];
3718
+ // Resove executable
3719
+ var bin;
3720
+ switch(isImageMagick){
3721
+ case true:
3722
+ bin = 'compare';
3723
+ break;
3724
+ case '7+':
3725
+ bin = 'magick';
3726
+ args.unshift('compare');
3727
+ break;
3728
+ default:
3729
+ bin = 'gm';
3730
+ args.unshift('compare');
3731
+ break;
3732
+ }
3733
+ // Prepend app path
3734
+ bin = appPath + bin;
3735
+ var tolerance = 0.4;
3736
+ // outputting the diff image
3737
+ if ((typeof options === "undefined" ? "undefined" : _type_of(options)) === 'object') {
3738
+ if (options.highlightColor && options.highlightColor.indexOf('"') < 0) {
3739
+ options.highlightColor = '"' + options.highlightColor + '"';
3740
+ }
3741
+ if (options.file) {
3742
+ if (typeof options.file !== 'string') {
3743
+ throw new TypeError('The path for the diff output is invalid');
3744
+ }
3745
+ // graphicsmagick defaults to red
3746
+ if (options.highlightColor) {
3747
+ args.push('-highlight-color');
3748
+ args.push(options.highlightColor);
3749
+ }
3750
+ if (options.highlightStyle) {
3751
+ args.push('-highlight-style');
3752
+ args.push(options.highlightStyle);
3753
+ }
3754
+ // For IM, filename is the last argument. For GM it's `-file <filename>`
3755
+ if (!isImageMagick) {
3756
+ args.push('-file');
3757
+ }
3758
+ args.push(options.file);
3759
+ }
3760
+ if (typeof options.tolerance != 'undefined') {
3761
+ if (typeof options.tolerance !== 'number') {
3762
+ throw new TypeError('The tolerance value should be a number');
3763
+ }
3764
+ tolerance = options.tolerance;
3765
+ }
3766
+ } else {
3767
+ // For ImageMagick diff file is required but we don't care about it, so null it out
3768
+ if (isImageMagick) {
3769
+ args.push('null:');
3770
+ }
3771
+ if (typeof options == 'function') {
3772
+ cb = options; // tolerance value not provided, flip the cb place
3773
+ } else {
3774
+ tolerance = options;
3775
+ }
3776
+ }
3777
+ var cmd = bin + ' ' + args.map(utils.escape).join(' ');
3778
+ debug(cmd);
3779
+ var proc = spawn(bin, args);
3780
+ var stdout = '';
3781
+ var stderr = '';
3782
+ proc.stdout.on('data', function(data) {
3783
+ stdout += data;
3784
+ });
3785
+ proc.stderr.on('data', function(data) {
3786
+ stderr += data;
3787
+ });
3788
+ proc.on('close', function(code) {
3789
+ // ImageMagick returns err code 2 if err, 0 if similar, 1 if dissimilar
3790
+ if (isImageMagick) {
3791
+ if (code === 0) {
3792
+ return cb(null, 0 <= tolerance, 0, stdout);
3793
+ } else if (code === 1) {
3794
+ stdout = stderr;
3795
+ } else {
3796
+ return cb(stderr);
3797
+ }
3798
+ } else {
3799
+ if (code !== 0) {
3800
+ return cb(stderr);
3801
+ }
3802
+ }
3803
+ // Since ImageMagick similar gives err code 0 and no stdout, there's really no matching
3804
+ // Otherwise, output format for IM is `12.00 (0.123)` and for GM it's `Total: 0.123`
3805
+ var regex = isImageMagick ? /\((\d+\.?[\d\-\+e]*)\)/m : /Total: (\d+\.?\d*)/m;
3806
+ var match = regex.exec(stdout);
3807
+ if (!match) {
3808
+ return cb(new Error('Unable to parse output.\nGot ' + stdout));
3809
+ }
3810
+ var equality = parseFloat(match[1]);
3811
+ cb(null, equality <= tolerance, equality, stdout, orig, compareTo);
3812
+ });
3813
+ }
3814
+ if (proto) {
3815
+ proto.compare = compare;
3816
+ }
3817
+ return compare;
3818
+ };
3819
+ } (compare));
3820
+ return compare.exports;
3821
+ }
3822
+
3823
+ var composite = {
3824
+ exports: {}
3825
+ };
3826
+
3827
+ var hasRequiredComposite;
3828
+
3829
+ function requireComposite () {
3830
+ if (hasRequiredComposite) return composite.exports;
3831
+ hasRequiredComposite = 1;
3832
+ (function (module, exports) {
3833
+ // composite
3834
+ /**
3835
+ * Composite images together using the `composite` command in graphicsmagick.
3836
+ *
3837
+ * gm('/path/to/image.jpg')
3838
+ * .composite('/path/to/second_image.jpg')
3839
+ * .geometry('+100+150')
3840
+ * .write('/path/to/composite.png', function(err) {
3841
+ * if(!err) console.log("Written composite image.");
3842
+ * });
3843
+ *
3844
+ * @param {String} other Path to the image that contains the changes.
3845
+ * @param {String} [mask] Path to the image with opacity informtion. Grayscale.
3846
+ */ module.exports = function exports1(proto) {
3847
+ proto.composite = function(other, mask) {
3848
+ this.in(other);
3849
+ // If the mask is defined, add it to the output.
3850
+ if (typeof mask !== "undefined") this.out(mask);
3851
+ this.subCommand("composite");
3852
+ return this;
3853
+ };
3854
+ };
3855
+ } (composite));
3856
+ return composite.exports;
3857
+ }
3858
+
3859
+ var montage = {
3860
+ exports: {}
3861
+ };
3862
+
3863
+ var hasRequiredMontage;
3864
+
3865
+ function requireMontage () {
3866
+ if (hasRequiredMontage) return montage.exports;
3867
+ hasRequiredMontage = 1;
3868
+ (function (module, exports) {
3869
+ // montage
3870
+ /**
3871
+ * Montage images next to each other using the `montage` command in graphicsmagick.
3872
+ *
3873
+ * gm('/path/to/image.jpg')
3874
+ * .montage('/path/to/second_image.jpg')
3875
+ * .geometry('+100+150')
3876
+ * .write('/path/to/montage.png', function(err) {
3877
+ * if(!err) console.log("Written montage image.");
3878
+ * });
3879
+ *
3880
+ * @param {String} other Path to the image that contains the changes.
3881
+ */ module.exports = function exports1(proto) {
3882
+ proto.montage = function(other) {
3883
+ this.in(other);
3884
+ this.subCommand("montage");
3885
+ return this;
3886
+ };
3887
+ };
3888
+ } (montage));
3889
+ return montage.exports;
3890
+ }
3891
+
3892
+ var version = "1.25.1";
3893
+ var require$$13 = {
3894
+ version: version};
3895
+
3896
+ /**
3897
+ * Module dependencies.
3898
+ */
3899
+
3900
+ (function (module, exports) {
3901
+ function _instanceof(left, right) {
3902
+ if (right != null && typeof Symbol !== "undefined" && right[Symbol.hasInstance]) {
3903
+ return !!right[Symbol.hasInstance](left);
3904
+ } else {
3905
+ return left instanceof right;
3906
+ }
3907
+ }
3908
+ var Stream = require$$4.Stream;
3909
+ var EventEmitter = require$$1$1.EventEmitter;
3910
+ var util = require$$1;
3911
+ util.inherits(gm, EventEmitter);
3912
+ /**
3913
+ * Constructor.
3914
+ *
3915
+ * @param {String|Number} path - path to img source or ReadableStream or width of img to create
3916
+ * @param {Number} [height] - optional filename of ReadableStream or height of img to create
3917
+ * @param {String} [color] - optional hex background color of created img
3918
+ */ function gm(source, height, color) {
3919
+ var width;
3920
+ if (!_instanceof(this, gm)) {
3921
+ return new gm(source, height, color);
3922
+ }
3923
+ EventEmitter.call(this);
3924
+ this._options = {};
3925
+ this.options(this.__proto__._options);
3926
+ this.data = {};
3927
+ this._in = [];
3928
+ this._out = [];
3929
+ this._outputFormat = null;
3930
+ this._subCommand = 'convert';
3931
+ if (_instanceof(source, Stream)) {
3932
+ this.sourceStream = source;
3933
+ source = height || 'unknown.jpg';
3934
+ } else if (Buffer.isBuffer(source)) {
3935
+ this.sourceBuffer = source;
3936
+ source = height || 'unknown.jpg';
3937
+ } else if (height) {
3938
+ // new images
3939
+ width = source;
3940
+ source = "";
3941
+ this.in("-size", width + "x" + height);
3942
+ if (color) {
3943
+ this.in("xc:" + color);
3944
+ }
3945
+ }
3946
+ if (typeof source === "string") {
3947
+ // then source is a path
3948
+ // parse out gif frame brackets from filename
3949
+ // since stream doesn't use source path
3950
+ // eg. "filename.gif[0]"
3951
+ var frames = source.match(/(\[.+\])$/);
3952
+ if (frames) {
3953
+ this.sourceFrames = source.substr(frames.index, frames[0].length);
3954
+ source = source.substr(0, frames.index);
3955
+ }
3956
+ }
3957
+ this.source = source;
3958
+ this.addSrcFormatter(function(src) {
3959
+ // must be first source formatter
3960
+ var inputFromStdin = this.sourceStream || this.sourceBuffer;
3961
+ var ret = inputFromStdin ? '-' : this.source;
3962
+ var fileNameProvied = typeof height === 'string';
3963
+ if (inputFromStdin && fileNameProvied && /\.ico$/i.test(this.source)) {
3964
+ ret = "ico:-";
3965
+ }
3966
+ if (ret && this.sourceFrames) ret += this.sourceFrames;
3967
+ src.length = 0;
3968
+ src[0] = ret;
3969
+ });
3970
+ }
3971
+ /**
3972
+ * Subclasses the gm constructor with custom options.
3973
+ *
3974
+ * @param {options} options
3975
+ * @return {gm} the subclasses gm constructor
3976
+ */ var parent = gm;
3977
+ gm.subClass = function subClass(options) {
3978
+ function gm(source, height, color) {
3979
+ if (!_instanceof(this, parent)) {
3980
+ return new gm(source, height, color);
3981
+ }
3982
+ parent.call(this, source, height, color);
3983
+ }
3984
+ gm.prototype.__proto__ = parent.prototype;
3985
+ gm.prototype._options = {};
3986
+ gm.prototype.options(options);
3987
+ return gm;
3988
+ };
3989
+ /**
3990
+ * Augment the prototype.
3991
+ */ requireOptions()(gm.prototype);
3992
+ requireGetters()(gm);
3993
+ requireArgs()(gm.prototype);
3994
+ requireDrawing()(gm.prototype);
3995
+ requireConvenience()(gm.prototype);
3996
+ requireCommand()(gm.prototype);
3997
+ requireCompare()(gm.prototype);
3998
+ requireComposite()(gm.prototype);
3999
+ requireMontage()(gm.prototype);
4000
+ /**
4001
+ * Expose.
4002
+ */ module.exports = gm;
4003
+ module.exports.utils = requireUtils();
4004
+ module.exports.compare = requireCompare()();
4005
+ module.exports.version = require$$13.version;
4006
+ } (gm));
4007
+
4008
+ var gmExports = gm.exports;
4009
+
4010
+ var fromBuffer;
4011
+ function _array_like_to_array(arr, len) {
4012
+ if (len == null || len > arr.length) len = arr.length;
4013
+ for(var i = 0, arr2 = new Array(len); i < len; i++)arr2[i] = arr[i];
4014
+ return arr2;
4015
+ }
4016
+ function _array_without_holes(arr) {
4017
+ if (Array.isArray(arr)) return _array_like_to_array(arr);
4018
+ }
4019
+ function _class_call_check(instance, Constructor) {
4020
+ if (!(instance instanceof Constructor)) {
4021
+ throw new TypeError("Cannot call a class as a function");
4022
+ }
4023
+ }
4024
+ function _defineProperties(target, props) {
4025
+ for(var i = 0; i < props.length; i++){
4026
+ var descriptor = props[i];
4027
+ descriptor.enumerable = descriptor.enumerable || false;
4028
+ descriptor.configurable = true;
4029
+ if ("value" in descriptor) descriptor.writable = true;
4030
+ Object.defineProperty(target, descriptor.key, descriptor);
4031
+ }
4032
+ }
4033
+ function _create_class(Constructor, protoProps, staticProps) {
4034
+ if (protoProps) _defineProperties(Constructor.prototype, protoProps);
4035
+ return Constructor;
4036
+ }
4037
+ function _instanceof$G(left, right) {
4038
+ if (right != null && typeof Symbol !== "undefined" && right[Symbol.hasInstance]) {
4039
+ return !!right[Symbol.hasInstance](left);
4040
+ } else {
4041
+ return left instanceof right;
4042
+ }
4043
+ }
4044
+ function _iterable_to_array(iter) {
4045
+ if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter);
4046
+ }
4047
+ function _non_iterable_spread() {
4048
+ throw new TypeError("Invalid attempt to spread non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
4049
+ }
4050
+ function _to_consumable_array(arr) {
4051
+ return _array_without_holes(arr) || _iterable_to_array(arr) || _unsupported_iterable_to_array(arr) || _non_iterable_spread();
4052
+ }
4053
+ function _type_of$2(obj) {
4054
+ "@swc/helpers - typeof";
4055
+ return obj && typeof Symbol !== "undefined" && obj.constructor === Symbol ? "symbol" : typeof obj;
4056
+ }
4057
+ function _unsupported_iterable_to_array(o, minLen) {
4058
+ if (!o) return;
4059
+ if (typeof o === "string") return _array_like_to_array(o, minLen);
4060
+ var n = Object.prototype.toString.call(o).slice(8, -1);
4061
+ if (n === "Object" && o.constructor) n = o.constructor.name;
4062
+ if (n === "Map" || n === "Set") return Array.from(n);
4063
+ if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array(o, minLen);
4064
+ }
4065
+ function _ts_generator(thisArg, body) {
4066
+ var f, y, t, g, _ = {
4067
+ label: 0,
4068
+ sent: function() {
4069
+ if (t[0] & 1) throw t[1];
4070
+ return t[1];
4071
+ },
4072
+ trys: [],
4073
+ ops: []
4074
+ };
4075
+ return g = {
4076
+ next: verb(0),
4077
+ "throw": verb(1),
4078
+ "return": verb(2)
4079
+ }, typeof Symbol === "function" && (g[Symbol.iterator] = function() {
4080
+ return this;
4081
+ }), g;
4082
+ function verb(n) {
4083
+ return function(v) {
4084
+ return step([
4085
+ n,
4086
+ v
4087
+ ]);
4088
+ };
4089
+ }
4090
+ function step(op) {
4091
+ if (f) throw new TypeError("Generator is already executing.");
4092
+ while(_)try {
4093
+ if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
4094
+ if (y = 0, t) op = [
4095
+ op[0] & 2,
4096
+ t.value
4097
+ ];
4098
+ switch(op[0]){
4099
+ case 0:
4100
+ case 1:
4101
+ t = op;
4102
+ break;
4103
+ case 4:
4104
+ _.label++;
4105
+ return {
4106
+ value: op[1],
4107
+ done: false
4108
+ };
4109
+ case 5:
4110
+ _.label++;
4111
+ y = op[1];
4112
+ op = [
4113
+ 0
4114
+ ];
4115
+ continue;
4116
+ case 7:
4117
+ op = _.ops.pop();
4118
+ _.trys.pop();
4119
+ continue;
4120
+ default:
4121
+ if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) {
4122
+ _ = 0;
4123
+ continue;
4124
+ }
4125
+ if (op[0] === 3 && (!t || op[1] > t[0] && op[1] < t[3])) {
4126
+ _.label = op[1];
4127
+ break;
4128
+ }
4129
+ if (op[0] === 6 && _.label < t[1]) {
4130
+ _.label = t[1];
4131
+ t = op;
4132
+ break;
4133
+ }
4134
+ if (t && _.label < t[2]) {
4135
+ _.label = t[2];
4136
+ _.ops.push(op);
4137
+ break;
4138
+ }
4139
+ if (t[2]) _.ops.pop();
4140
+ _.trys.pop();
4141
+ continue;
4142
+ }
4143
+ op = body.call(thisArg, _);
4144
+ } catch (e) {
4145
+ op = [
4146
+ 6,
4147
+ e
4148
+ ];
4149
+ y = 0;
4150
+ } finally{
4151
+ f = t = 0;
4152
+ }
4153
+ if (op[0] & 5) throw op[1];
4154
+ return {
4155
+ value: op[0] ? op[1] : void 0,
4156
+ done: true
4157
+ };
4158
+ }
4159
+ }
4160
+ var e = gmExports, t = require$$0$1, s = require$$0, i$2 = require$$4;
4161
+ var r = {
4162
+ quality: 0,
4163
+ format: "png",
4164
+ width: 768,
4165
+ height: 512,
4166
+ density: 72,
4167
+ preserveAspectRatio: false,
4168
+ savePath: "./",
4169
+ saveFilename: "untitled",
4170
+ compression: "jpeg",
4171
+ units: "PixelsPerInch"
4172
+ };
4173
+ function n(e, t, s, i) {
4174
+ return new (s || (s = Promise))(function(r, n) {
4175
+ function a(e) {
4176
+ try {
4177
+ h(i.next(e));
4178
+ } catch (e) {
4179
+ n(e);
4180
+ }
4181
+ }
4182
+ function o(e) {
4183
+ try {
4184
+ h(i.throw(e));
4185
+ } catch (e) {
4186
+ n(e);
4187
+ }
4188
+ }
4189
+ function h(e) {
4190
+ var _$t;
4191
+ e.done ? r(e.value) : (_$t = e.value, _instanceof$G(_$t, s) ? _$t : new s(function(e) {
4192
+ e(_$t);
4193
+ })).then(a, o);
4194
+ }
4195
+ h((i = i.apply(e, [])).next());
4196
+ });
4197
+ }
4198
+ "function" == typeof SuppressedError && SuppressedError;
4199
+ var a = /*#__PURE__*/ function() {
4200
+ function a() {
4201
+ _class_call_check(this, a);
4202
+ this.quality = 0, this.format = "png", this.width = 768, this.height = 512, this.preserveAspectRatio = false, this.density = 72, this.savePath = "./", this.saveFilename = "untitled", this.compression = "jpeg", this.units = "PixelsPerInch", this.gm = e.subClass({
4203
+ imageMagick: false
4204
+ });
4205
+ }
4206
+ _create_class(a, [
4207
+ {
4208
+ key: "generateValidFilename",
4209
+ value: function generateValidFilename(e) {
4210
+ var s = t.join(this.savePath, this.saveFilename);
4211
+ return this.savePath.startsWith("./") && (s = "./".concat(s)), "number" == typeof e && (s = "".concat(s, ".").concat(e + 1)), "".concat(s, ".").concat(this.format);
4212
+ }
4213
+ },
4214
+ {
4215
+ key: "gmBaseCommand",
4216
+ value: function gmBaseCommand(e, t) {
4217
+ return this.gm(e, t).density(this.density, this.density).units(this.units).resize(this.width, this.height, this.preserveAspectRatio ? "^" : "!").quality(this.quality).compress(this.compression);
4218
+ }
4219
+ },
4220
+ {
4221
+ key: "toBase64",
4222
+ value: function toBase64(e, t) {
4223
+ return n(this, void 0, void 0, function() {
4224
+ var _ref, s, i, r;
4225
+ return _ts_generator(this, function(_state) {
4226
+ switch(_state.label){
4227
+ case 0:
4228
+ return [
4229
+ 4,
4230
+ this.toBuffer(e, t)
4231
+ ];
4232
+ case 1:
4233
+ _ref = _state.sent(), s = _ref.buffer, i = _ref.size, r = _ref.page;
4234
+ return [
4235
+ 2,
4236
+ {
4237
+ base64: s.toString("base64"),
4238
+ size: i,
4239
+ page: r
4240
+ }
4241
+ ];
4242
+ }
4243
+ });
4244
+ });
4245
+ }
4246
+ },
4247
+ {
4248
+ key: "toBuffer",
4249
+ value: function toBuffer(e, t) {
4250
+ var _this = this;
4251
+ var s = "".concat(e.path, "[").concat(t, "]");
4252
+ return new Promise(function(i, r) {
4253
+ _this.gmBaseCommand(e, s).stream(_this.format, function(e, s) {
4254
+ var n = [];
4255
+ if (e) return r(e);
4256
+ s.on("data", function(e) {
4257
+ n.push(e);
4258
+ }).on("end", function() {
4259
+ return i({
4260
+ buffer: Buffer.concat(n),
4261
+ size: "".concat(_this.width, "x").concat(_this.height),
4262
+ page: t + 1
4263
+ });
4264
+ });
4265
+ });
4266
+ });
4267
+ }
4268
+ },
4269
+ {
4270
+ key: "writeImage",
4271
+ value: function writeImage(e, i) {
4272
+ var _this = this;
4273
+ var r = this.generateValidFilename(i), n = "".concat(e.path, "[").concat(i, "]");
4274
+ return new Promise(function(a, o) {
4275
+ _this.gmBaseCommand(e, n).write(r, function(e) {
4276
+ return e ? o(e) : a({
4277
+ name: t.basename(r),
4278
+ size: "".concat(_this.width, "x").concat(_this.height),
4279
+ fileSize: s.statSync(r).size / 1e3,
4280
+ path: r,
4281
+ page: i + 1
4282
+ });
4283
+ });
4284
+ });
4285
+ }
4286
+ },
4287
+ {
4288
+ key: "identify",
4289
+ value: function identify(e, t) {
4290
+ var s = this.gm(e);
4291
+ return new Promise(function(e, i) {
4292
+ t ? s.identify(t, function(t, s) {
4293
+ return t ? i(t) : e(s.replace(/^[\w\W]*?1/, "1"));
4294
+ }) : s.identify(function(t, s) {
4295
+ return t ? i(t) : e(s);
4296
+ });
4297
+ });
4298
+ }
4299
+ },
4300
+ {
4301
+ key: "setQuality",
4302
+ value: function setQuality(e) {
4303
+ return this.quality = e, this;
4304
+ }
4305
+ },
4306
+ {
4307
+ key: "setFormat",
4308
+ value: function setFormat(e) {
4309
+ return this.format = e, this;
4310
+ }
4311
+ },
4312
+ {
4313
+ key: "setSize",
4314
+ value: function setSize(e, t) {
4315
+ return this.width = e, this.height = this.preserveAspectRatio || t ? t : e, this;
4316
+ }
4317
+ },
4318
+ {
4319
+ key: "setPreserveAspectRatio",
4320
+ value: function setPreserveAspectRatio(e) {
4321
+ return this.preserveAspectRatio = e, this;
4322
+ }
4323
+ },
4324
+ {
4325
+ key: "setDensity",
4326
+ value: function setDensity(e) {
4327
+ return this.density = e, this;
4328
+ }
4329
+ },
4330
+ {
4331
+ key: "setSavePath",
4332
+ value: function setSavePath(e) {
4333
+ return this.savePath = e, this;
4334
+ }
4335
+ },
4336
+ {
4337
+ key: "setSaveFilename",
4338
+ value: function setSaveFilename(e) {
4339
+ return this.saveFilename = e, this;
4340
+ }
4341
+ },
4342
+ {
4343
+ key: "setUnits",
4344
+ value: function setUnits(e) {
4345
+ return this.units = e, this;
4346
+ }
4347
+ },
4348
+ {
4349
+ key: "setCompression",
4350
+ value: function setCompression(e) {
4351
+ return this.compression = e, this;
4352
+ }
4353
+ },
4354
+ {
4355
+ key: "setGMClass",
4356
+ value: function setGMClass(t) {
4357
+ return "boolean" == typeof t ? (this.gm = e.subClass({
4358
+ imageMagick: t
4359
+ }), this) : "imagemagick" === t.toLocaleLowerCase() ? (this.gm = e.subClass({
4360
+ imageMagick: true
4361
+ }), this) : (this.gm = e.subClass({
4362
+ appPath: t
4363
+ }), this);
4364
+ }
4365
+ },
4366
+ {
4367
+ key: "getOptions",
4368
+ value: function getOptions() {
4369
+ return {
4370
+ quality: this.quality,
4371
+ format: this.format,
4372
+ width: this.width,
4373
+ height: this.height,
4374
+ preserveAspectRatio: this.preserveAspectRatio,
4375
+ density: this.density,
4376
+ savePath: this.savePath,
4377
+ saveFilename: this.saveFilename,
4378
+ compression: this.compression,
4379
+ units: this.units
4380
+ };
4381
+ }
4382
+ }
4383
+ ]);
4384
+ return a;
4385
+ }();
4386
+ function o(e) {
4387
+ return new i$2.Readable({
4388
+ read: function read() {
4389
+ this.push(e), this.push(null);
4390
+ }
4391
+ });
4392
+ }
4393
+ function h(e, t) {
4394
+ return o(t);
4395
+ }
4396
+ function u(e, t) {
4397
+ var _this = this;
4398
+ var i = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : r;
4399
+ var u = new a;
4400
+ i = Object.assign(Object.assign({}, r), i);
4401
+ var c = function(e, t, s) {
4402
+ if (t < 1) throw new Error("Page number should be more than or equal 1");
4403
+ var i = function(e) {
4404
+ var _$t;
4405
+ if (e && "object" != (typeof e === "undefined" ? "undefined" : _type_of$2(e))) throw new Error("Invalid convertOptions type: ".concat(e));
4406
+ return null !== (_$t = null == e ? void 0 : e.responseType) && void 0 !== _$t ? _$t : "image";
4407
+ }(s);
4408
+ switch(i){
4409
+ case "base64":
4410
+ return u.toBase64(e, t - 1);
4411
+ case "image":
4412
+ return u.writeImage(e, t - 1);
4413
+ case "buffer":
4414
+ return u.toBuffer(e, t - 1);
4415
+ default:
4416
+ throw new Error("Invalid responseType: ".concat(i));
4417
+ }
4418
+ }, f = function(e, t, s) {
4419
+ return Promise.all(t.map(function(t) {
4420
+ return c(e, t, s);
4421
+ }));
4422
+ }, p = function() {
4423
+ var s = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : 1, i = arguments.length > 1 ? arguments[1] : void 0;
4424
+ var r = h(e, t);
4425
+ return c(r, s, i);
4426
+ };
4427
+ return p.bulk = function(i, r) {
4428
+ return n(_this, void 0, void 0, function() {
4429
+ var _c, a, h, c, _tmp, _$e, _, _1, _tmp1;
4430
+ return _ts_generator(this, function(_state) {
4431
+ switch(_state.label){
4432
+ case 0:
4433
+ return [
4434
+ 4,
4435
+ function(e, t) {
4436
+ return n(this, void 0, void 0, function() {
4437
+ return _ts_generator(this, function(_state) {
4438
+ switch(_state.label){
4439
+ case 0:
4440
+ return [
4441
+ 2,
4442
+ t
4443
+ ];
4444
+ case 1:
4445
+ return [
4446
+ 2,
4447
+ _state.sent()
4448
+ ];
4449
+ case 2:
4450
+ throw new Error("Cannot recognize specified source");
4451
+ }
4452
+ });
4453
+ });
4454
+ }(e, t)
4455
+ ];
4456
+ case 1:
4457
+ a = _state.sent();
4458
+ if (!(-1 === i)) return [
4459
+ 3,
4460
+ 3
4461
+ ];
4462
+ return [
4463
+ 4,
4464
+ function(e, t) {
4465
+ return n(this, void 0, void 0, function() {
4466
+ return _ts_generator(this, function(_state) {
4467
+ switch(_state.label){
4468
+ case 0:
4469
+ return [
4470
+ 4,
4471
+ e.identify(t, "%p ")
4472
+ ];
4473
+ case 1:
4474
+ return [
4475
+ 2,
4476
+ _state.sent().split(" ").map(function(e) {
4477
+ return parseInt(e, 10);
4478
+ })
4479
+ ];
4480
+ }
4481
+ });
4482
+ });
4483
+ }(u, o(a))
4484
+ ];
4485
+ case 2:
4486
+ _tmp = _state.sent();
4487
+ return [
4488
+ 3,
4489
+ 4
4490
+ ];
4491
+ case 3:
4492
+ _tmp = Array.isArray(i) ? i : [
4493
+ i
4494
+ ];
4495
+ _state.label = 4;
4496
+ case 4:
4497
+ h = _tmp, c = [];
4498
+ _$e = 0;
4499
+ _state.label = 5;
4500
+ case 5:
4501
+ if (!(_$e < h.length)) return [
4502
+ 3,
4503
+ 8
4504
+ ];
4505
+ _1 = (_ = (_c = c).push).apply;
4506
+ _tmp1 = [
4507
+ _c
4508
+ ];
4509
+ return [
4510
+ 4,
4511
+ f(o(a), h.slice(_$e, _$e + 10), r)
4512
+ ];
4513
+ case 6:
4514
+ _1.apply(_, _tmp1.concat([
4515
+ _to_consumable_array.apply(void 0, [
4516
+ _state.sent()
4517
+ ])
4518
+ ]));
4519
+ _state.label = 7;
4520
+ case 7:
4521
+ _$e += 10;
4522
+ return [
4523
+ 3,
4524
+ 5
4525
+ ];
4526
+ case 8:
4527
+ return [
4528
+ 2,
4529
+ c
4530
+ ];
4531
+ }
4532
+ });
4533
+ });
4534
+ }, p.setOptions = function() {
4535
+ return function(e, t) {
4536
+ return void e.setQuality(t.quality).setFormat(t.format).setPreserveAspectRatio(t.preserveAspectRatio).setSize(t.width, t.height).setDensity(t.density).setSavePath(t.savePath).setSaveFilename(t.saveFilename).setCompression(t.compression).setUnits(t.units);
4537
+ }(u, i);
4538
+ }, p.setGMClass = function(e) {
4539
+ u.setGMClass(e);
4540
+ }, p.setOptions(), p;
4541
+ }
4542
+ fromBuffer = function(e) {
4543
+ var t = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : r;
4544
+ return u("buffer", e, t);
4545
+ };
2
4546
 
3
4547
  /******************************************************************************
4
4548
  Copyright (c) Microsoft Corporation.
@@ -827,10 +5371,6 @@ var error = function error(msg) {
827
5371
  throw new Error(msg);
828
5372
  };
829
5373
 
830
- function getDefaultExportFromCjs(x) {
831
- return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x;
832
- }
833
-
834
5374
  var common = {};
835
5375
 
836
5376
  (function (exports) {