@digipair/skill-pdf2pic 0.94.0-0 → 0.94.0-1

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