-
Notifications
You must be signed in to change notification settings - Fork 17
/
browser.js
705 lines (623 loc) · 23 KB
/
browser.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
(function(f){if(typeof exports==="object"&&typeof module!=="undefined"){module.exports=f()}else if(typeof define==="function"&&define.amd){define([],f)}else{var g;if(typeof window!=="undefined"){g=window}else if(typeof global!=="undefined"){g=global}else if(typeof self!=="undefined"){g=self}else{g=this}g.SvgSaver = f()}})(function(){var define,module,exports;return (function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s})({1:[function(require,module,exports){
'use strict';
Object.defineProperty(exports, '__esModule', {
value: true
});
var _createClass = (function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ('value' in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; })();
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function'); } }
var _computedStyles = require('computed-styles');
var _computedStyles2 = _interopRequireDefault(_computedStyles);
var _fileSaver = require('file-saver');
var _fileSaver2 = _interopRequireDefault(_fileSaver);
var svgStyles = { // Whitelist of CSS styles and default values
'alignment-baseline': 'auto',
'baseline-shift': 'baseline',
'clip': 'auto',
'clip-path': 'none',
'clip-rule': 'nonzero',
'color': 'rgb(51, 51, 51)',
'color-interpolation': 'srgb',
'color-interpolation-filters': 'linearrgb',
'color-profile': 'auto',
'color-rendering': 'auto',
'cursor': 'auto',
'direction': 'ltr',
'display': 'inline',
'dominant-baseline': 'auto',
'enable-background': '',
'fill': 'rgb(0, 0, 0)',
'fill-opacity': '1',
'fill-rule': 'nonzero',
'filter': 'none',
'flood-color': 'rgb(0, 0, 0)',
'flood-opacity': '1',
'font': '',
'font-family': 'normal',
'font-size': 'medium',
'font-size-adjust': 'auto',
'font-stretch': 'normal',
'font-style': 'normal',
'font-variant': 'normal',
'font-weight': '400',
'glyph-orientation-horizontal': '0deg',
'glyph-orientation-vertical': 'auto',
'image-rendering': 'auto',
'kerning': 'auto',
'letter-spacing': '0',
'lighting-color': 'rgb(255, 255, 255)',
'marker': '',
'marker-end': 'none',
'marker-mid': 'none',
'marker-start': 'none',
'mask': 'none',
'opacity': '1',
'overflow': 'visible',
'paint-order': 'fill',
'pointer-events': 'auto',
'shape-rendering': 'auto',
'stop-color': 'rgb(0, 0, 0)',
'stop-opacity': '1',
'stroke': 'none',
'stroke-dasharray': 'none',
'stroke-dashoffset': '0',
'stroke-linecap': 'butt',
'stroke-linejoin': 'miter',
'stroke-miterlimit': '4',
'stroke-opacity': '1',
'stroke-width': '1',
'text-anchor': 'start',
'text-decoration': 'none',
'text-rendering': 'auto',
'unicode-bidi': 'normal',
'visibility': 'visible',
'word-spacing': '0px',
'writing-mode': 'lr-tb'
};
var svgAttrs = [// white list of attributes
'id', 'xml: base', 'xml: lang', 'xml: space', // Core
'height', 'result', 'width', 'x', 'y', // Primitive
'xlink: href', // Xlink attribute
'href', 'style', 'class', 'd', 'pathLength', // Path
'x', 'y', 'dx', 'dy', 'glyphRef', 'format', 'x1', 'y1', 'x2', 'y2', 'rotate', 'textLength', 'cx', 'cy', 'r', 'rx', 'ry', 'fx', 'fy', 'width', 'height', 'refX', 'refY', 'orient', 'markerUnits', 'markerWidth', 'markerHeight', 'maskUnits', 'transform', 'viewBox', 'version', // Container
'preserveAspectRatio', 'xmlns', 'points', // Polygons
'offset', 'xlink:href'];
// http://www.w3.org/TR/SVG/propidx.html
// via https://github.com/svg/svgo/blob/master/plugins/_collections.js
var inheritableAttrs = ['clip-rule', 'color', 'color-interpolation', 'color-interpolation-filters', 'color-profile', 'color-rendering', 'cursor', 'direction', 'fill', 'fill-opacity', 'fill-rule', 'font', 'font-family', 'font-size', 'font-size-adjust', 'font-stretch', 'font-style', 'font-variant', 'font-weight', 'glyph-orientation-horizontal', 'glyph-orientation-vertical', 'image-rendering', 'kerning', 'letter-spacing', 'marker', 'marker-end', 'marker-mid', 'marker-start', 'pointer-events', 'shape-rendering', 'stroke', 'stroke-dasharray', 'stroke-dashoffset', 'stroke-linecap', 'stroke-linejoin', 'stroke-miterlimit', 'stroke-opacity', 'stroke-width', 'text-anchor', 'text-rendering', 'transform', 'visibility', 'white-space', 'word-spacing', 'writing-mode'];
/* Some simple utilities */
var isFunction = function isFunction(a) {
return typeof a === 'function';
};
var isDefined = function isDefined(a) {
return typeof a !== 'undefined';
};
var isUndefined = function isUndefined(a) {
return typeof a === 'undefined';
};
var isObject = function isObject(a) {
return a !== null && typeof a === 'object';
};
// from https://github.com/npm-dom/is-dom/blob/master/index.js
function isNode(val) {
if (!isObject(val)) {
return false;
}
if (isDefined(window) && isObject(window.Node)) {
return val instanceof window.Node;
}
return typeof val.nodeType === 'number' && typeof val.nodeName === 'string';
}
/* Some utilities for cloning SVGs with inline styles */
// Removes attributes that are not valid for SVGs
function cleanAttrs(el, attrs, styles) {
// attrs === false - remove all, attrs === true - allow all
if (attrs === true) {
return;
}
Array.prototype.slice.call(el.attributes).forEach(function (attr) {
// remove if it is not style nor on attrs whitelist
// keeping attributes that are also styles because attributes override
if (attr.specified) {
if (attrs === '' || attrs === false || isUndefined(styles[attr.name]) && attrs.indexOf(attr.name) < 0) {
el.removeAttribute(attr.name);
}
}
});
}
function cleanStyle(tgt, parentStyles) {
parentStyles = parentStyles || tgt.parentNode.style;
inheritableAttrs.forEach(function (key) {
if (tgt.style[key] === parentStyles[key]) {
tgt.style.removeProperty(key);
}
});
}
function domWalk(src, tgt, down, up) {
down(src, tgt);
var children = src.childNodes;
for (var i = 0; i < children.length; i++) {
domWalk(children[i], tgt.childNodes[i], down, up);
}
up(src, tgt);
}
// Clones an SVGElement, copies approprate atttributes and styles.
function cloneSvg(src, attrs, styles) {
var clonedSvg = src.cloneNode(true);
domWalk(src, clonedSvg, function (src, tgt) {
if (tgt.style) {
(0, _computedStyles2['default'])(src, tgt.style, styles);
}
}, function (src, tgt) {
if (tgt.style && tgt.parentNode) {
cleanStyle(tgt);
}
if (tgt.attributes) {
cleanAttrs(tgt, attrs, styles);
}
});
return clonedSvg;
}
/* global Image, MouseEvent */
/* Some simple utilities for saving SVGs, including an alternative to saveAs */
// detection
var DownloadAttributeSupport = typeof document !== 'undefined' && 'download' in document.createElement('a') && typeof MouseEvent === 'function';
function saveUri(uri, name) {
if (DownloadAttributeSupport) {
var dl = document.createElement('a');
dl.setAttribute('href', uri);
dl.setAttribute('download', name);
// firefox doesn't support `.click()`...
// from https://github.com/sindresorhus/multi-download/blob/gh-pages/index.js
dl.dispatchEvent(new MouseEvent('click'));
return true;
} else if (typeof window !== 'undefined') {
window.open(uri, '_blank', '');
return true;
}
return false;
}
function createCanvas(uri, name, cb) {
var canvas = document.createElement('canvas');
var context = canvas.getContext('2d');
var image = new Image();
image.onload = function () {
canvas.width = image.width;
canvas.height = image.height;
context.drawImage(image, 0, 0);
cb(canvas);
};
image.src = uri;
return true;
}
function savePng(uri, name) {
return createCanvas(uri, name, function (canvas) {
if (isDefined(canvas.toBlob)) {
canvas.toBlob(function (blob) {
_fileSaver2['default'].saveAs(blob, name);
});
} else {
saveUri(canvas.toDataURL('image/png'), name);
}
});
}
/* global Blob */
var isIE11 = !!window.MSInputMethodContext && !!document.documentMode;
// inheritable styles may be overridden by parent, always copy for now
inheritableAttrs.forEach(function (k) {
if (k in svgStyles) {
svgStyles[k] = true;
}
});
var SvgSaver = (function () {
_createClass(SvgSaver, null, [{
key: 'getSvg',
value: function getSvg(el) {
if (isUndefined(el) || el === '') {
el = document.body.querySelector('svg');
} else if (typeof el === 'string') {
el = document.body.querySelector(el);
}
if (el && el.tagName !== 'svg') {
el = el.querySelector('svg');
}
if (!isNode(el)) {
throw new Error('svgsaver: Can\'t find an svg element');
}
return el;
}
}, {
key: 'getFilename',
value: function getFilename(el, filename, ext) {
if (!filename || filename === '') {
filename = (el.getAttribute('title') || 'untitled') + '.' + ext;
}
return encodeURI(filename);
}
/**
* SvgSaver constructor.
* @constructs SvgSaver
* @api public
*
* @example
* var svgsaver = new SvgSaver(); // creates a new instance
* var svg = document.querySelector('#mysvg'); // find the SVG element
* svgsaver.asSvg(svg); // save as SVG
*/
}]);
function SvgSaver() {
var _ref = arguments.length <= 0 || arguments[0] === undefined ? {} : arguments[0];
var attrs = _ref.attrs;
var styles = _ref.styles;
_classCallCheck(this, SvgSaver);
this.attrs = attrs === undefined ? svgAttrs : attrs;
this.styles = styles === undefined ? svgStyles : styles;
}
/**
* Return the cloned SVG after cleaning
*
* @param {SVGElement} el The element to copy.
* @returns {SVGElement} SVG text after cleaning
* @api public
*/
_createClass(SvgSaver, [{
key: 'cloneSVG',
value: function cloneSVG(el) {
el = SvgSaver.getSvg(el);
var svg = cloneSvg(el, this.attrs, this.styles);
svg.setAttribute('xmlns', 'http://www.w3.org/2000/svg');
svg.setAttribute('xmlns:xlink', 'http://www.w3.org/1999/xlink');
svg.setAttribute('version', 1.1);
// height and width needed to download in FireFox
svg.setAttribute('width', svg.getAttribute('width') || '500');
svg.setAttribute('height', svg.getAttribute('height') || '900');
return svg;
}
/**
* Return the SVG HTML text after cleaning
*
* @param {SVGElement} el The element to copy.
* @returns {String} SVG text after cleaning
* @api public
*/
}, {
key: 'getHTML',
value: function getHTML(el) {
var svg = this.cloneSVG(el);
var html = svg.outerHTML;
if (html) {
return html;
}
// see http://stackoverflow.com/questions/19610089/unwanted-namespaces-on-svg-markup-when-using-xmlserializer-in-javascript-with-ie
svg.removeAttribute('xmlns');
svg.removeAttribute('xmlns:xlink');
svg.setAttributeNS('http://www.w3.org/2000/xmlns/', 'xmlns', 'http://www.w3.org/2000/svg');
svg.setAttributeNS('http://www.w3.org/2000/xmlns/', 'xmlns:xlink', 'http://www.w3.org/1999/xlink');
return new window.XMLSerializer().serializeToString(svg);
}
/**
* Return the SVG, after cleaning, as a text/xml Blob
*
* @param {SVGElement} el The element to copy.
* @returns {Blog} SVG as a text/xml Blob
* @api public
*/
}, {
key: 'getBlob',
value: function getBlob(el) {
var html = this.getHTML(el);
return new Blob([html], { type: 'text/xml' });
}
/**
* Return the SVG, after cleaning, as a image/svg+xml;base64 URI encoded string
*
* @param {SVGElement} el The element to copy.
* @returns {String} SVG as image/svg+xml;base64 URI encoded string
* @api public
*/
}, {
key: 'getUri',
value: function getUri(el) {
var html = encodeURIComponent(this.getHTML(el));
if (isDefined(window.btoa)) {
// see http://stackoverflow.com/questions/23223718/failed-to-execute-btoa-on-window-the-string-to-be-encoded-contains-characte
return 'data:image/svg+xml;base64,' + window.btoa(unescape(html));
}
return 'data:image/svg+xml,' + html;
}
/**
* Saves the SVG as a SVG file using method compatible with the browser
*
* @param {SVGElement} el The element to copy.
* @param {string} [filename] The filename to save, defaults to the SVG title or 'untitled.svg'
* @returns {SvgSaver} The SvgSaver instance
* @api public
*/
}, {
key: 'asSvg',
value: function asSvg(el, filename) {
el = SvgSaver.getSvg(el);
filename = SvgSaver.getFilename(el, filename, 'svg');
if (isFunction(Blob)) {
return _fileSaver2['default'].saveAs(this.getBlob(el), filename);
}
return saveUri(this.getUri(el), filename);
}
/**
* Gets the SVG as a PNG data URI.
*
* @param {SVGElement} el The element to copy.
* @param {Function} cb Call back called with the PNG data uri.
* @api public
*/
}, {
key: 'getPngUri',
value: function getPngUri(el, cb) {
if (isIE11) {
console.error('svgsaver: getPngUri not supported on IE11');
}
el = SvgSaver.getSvg(el);
var filename = SvgSaver.getFilename(el, null, 'png');
return createCanvas(this.getUri(el), filename, function (canvas) {
cb(canvas.toDataURL('image/png'));
});
}
/**
* Saves the SVG as a PNG file using method compatible with the browser
*
* @param {SVGElement} el The element to copy.
* @param {string} [filename] The filename to save, defaults to the SVG title or 'untitled.png'
* @returns {SvgSaver} The SvgSaver instance
* @api public
*/
}, {
key: 'asPng',
value: function asPng(el, filename) {
if (isIE11) {
console.error('svgsaver: asPng not supported on IE11');
}
el = SvgSaver.getSvg(el);
filename = SvgSaver.getFilename(el, filename, 'png');
return savePng(this.getUri(el), filename);
}
}]);
return SvgSaver;
})();
exports['default'] = SvgSaver;
module.exports = exports['default'];
},{"computed-styles":2,"file-saver":3}],2:[function(require,module,exports){
'use strict';
Object.defineProperty(exports, '__esModule', {
value: true
});
var isDefined = function isDefined(a) {
return typeof a !== 'undefined';
};
var isObject = function isObject(a) {
return a !== null && typeof a === 'object';
};
// from https://github.com/npm-dom/is-dom/blob/master/index.js
function isNode(val) {
if (!isObject(val)) return false;
if (isDefined(window) && isObject(window.Node)) return val instanceof window.Node;
return 'number' == typeof val.nodeType && 'string' == typeof val.nodeName;
}
var useComputedStyles = isDefined(window) && isDefined(window.getComputedStyle);
/**
* Returns a collection of CSS property-value pairs
* @param {Element} node A DOM element to copy styles from
* @param {Object} [target] An optional object to copy styles to
* @param {(Object|Boolean)} [default=true] A collection of CSS property-value pairs, false: copy none, true: copy all
* @return {object} collection of CSS property-value pairs
* @api public
*/
function computedStyles(node) {
var target = arguments.length <= 1 || arguments[1] === undefined ? {} : arguments[1];
var styleList = arguments.length <= 2 || arguments[2] === undefined ? true : arguments[2];
if (!isNode(node)) {
throw new Error('parameter 1 is not of type \'Element\'');
}
if (styleList === false) return target;
if (useComputedStyles) {
var computed = node.ownerDocument.defaultView.getComputedStyle(node, null);
var keysArray = styleList === true ? computed : Object.keys(styleList);
} else {
var computed = isDefined(node.currentStyle) ? node.currentStyle : node.style;
var keysArray = styleList === true ? Object.keys(computed) : Object.keys(styleList);
}
for (var i = 0, l = keysArray.length; i < l; i++) {
var key = keysArray[i];
var def = styleList === true || styleList[key];
if (def === false || !isDefined(def)) continue; // copy never
var value = useComputedStyles ? computed.getPropertyValue(key) : computed[key];
if (typeof value !== 'string' || value === '') continue; // invalid value
if (def === true || value !== def) {
// styleList === true || styleList[key] === true || styleList[key] !== value
target[key] = value;
}
}
return target;
}
exports['default'] = computedStyles;
module.exports = exports['default'];
},{}],3:[function(require,module,exports){
/* FileSaver.js
* A saveAs() FileSaver implementation.
* 1.3.2
* 2016-06-16 18:25:19
*
* By Eli Grey, http://eligrey.com
* License: MIT
* See https://github.com/eligrey/FileSaver.js/blob/master/LICENSE.md
*/
/*global self */
/*jslint bitwise: true, indent: 4, laxbreak: true, laxcomma: true, smarttabs: true, plusplus: true */
/*! @source http://purl.eligrey.com/github/FileSaver.js/blob/master/FileSaver.js */
var saveAs = saveAs || (function(view) {
"use strict";
// IE <10 is explicitly unsupported
if (typeof view === "undefined" || typeof navigator !== "undefined" && /MSIE [1-9]\./.test(navigator.userAgent)) {
return;
}
var
doc = view.document
// only get URL when necessary in case Blob.js hasn't overridden it yet
, get_URL = function() {
return view.URL || view.webkitURL || view;
}
, save_link = doc.createElementNS("http://www.w3.org/1999/xhtml", "a")
, can_use_save_link = "download" in save_link
, click = function(node) {
var event = new MouseEvent("click");
node.dispatchEvent(event);
}
, is_safari = /constructor/i.test(view.HTMLElement) || view.safari
, is_chrome_ios =/CriOS\/[\d]+/.test(navigator.userAgent)
, throw_outside = function(ex) {
(view.setImmediate || view.setTimeout)(function() {
throw ex;
}, 0);
}
, force_saveable_type = "application/octet-stream"
// the Blob API is fundamentally broken as there is no "downloadfinished" event to subscribe to
, arbitrary_revoke_timeout = 1000 * 40 // in ms
, revoke = function(file) {
var revoker = function() {
if (typeof file === "string") { // file is an object URL
get_URL().revokeObjectURL(file);
} else { // file is a File
file.remove();
}
};
setTimeout(revoker, arbitrary_revoke_timeout);
}
, dispatch = function(filesaver, event_types, event) {
event_types = [].concat(event_types);
var i = event_types.length;
while (i--) {
var listener = filesaver["on" + event_types[i]];
if (typeof listener === "function") {
try {
listener.call(filesaver, event || filesaver);
} catch (ex) {
throw_outside(ex);
}
}
}
}
, auto_bom = function(blob) {
// prepend BOM for UTF-8 XML and text/* types (including HTML)
// note: your browser will automatically convert UTF-16 U+FEFF to EF BB BF
if (/^\s*(?:text\/\S*|application\/xml|\S*\/\S*\+xml)\s*;.*charset\s*=\s*utf-8/i.test(blob.type)) {
return new Blob([String.fromCharCode(0xFEFF), blob], {type: blob.type});
}
return blob;
}
, FileSaver = function(blob, name, no_auto_bom) {
if (!no_auto_bom) {
blob = auto_bom(blob);
}
// First try a.download, then web filesystem, then object URLs
var
filesaver = this
, type = blob.type
, force = type === force_saveable_type
, object_url
, dispatch_all = function() {
dispatch(filesaver, "writestart progress write writeend".split(" "));
}
// on any filesys errors revert to saving with object URLs
, fs_error = function() {
if ((is_chrome_ios || (force && is_safari)) && view.FileReader) {
// Safari doesn't allow downloading of blob urls
var reader = new FileReader();
reader.onloadend = function() {
var url = is_chrome_ios ? reader.result : reader.result.replace(/^data:[^;]*;/, 'data:attachment/file;');
var popup = view.open(url, '_blank');
if(!popup) view.location.href = url;
url=undefined; // release reference before dispatching
filesaver.readyState = filesaver.DONE;
dispatch_all();
};
reader.readAsDataURL(blob);
filesaver.readyState = filesaver.INIT;
return;
}
// don't create more object URLs than needed
if (!object_url) {
object_url = get_URL().createObjectURL(blob);
}
if (force) {
view.location.href = object_url;
} else {
var opened = view.open(object_url, "_blank");
if (!opened) {
// Apple does not allow window.open, see https://developer.apple.com/library/safari/documentation/Tools/Conceptual/SafariExtensionGuide/WorkingwithWindowsandTabs/WorkingwithWindowsandTabs.html
view.location.href = object_url;
}
}
filesaver.readyState = filesaver.DONE;
dispatch_all();
revoke(object_url);
}
;
filesaver.readyState = filesaver.INIT;
if (can_use_save_link) {
object_url = get_URL().createObjectURL(blob);
setTimeout(function() {
save_link.href = object_url;
save_link.download = name;
click(save_link);
dispatch_all();
revoke(object_url);
filesaver.readyState = filesaver.DONE;
});
return;
}
fs_error();
}
, FS_proto = FileSaver.prototype
, saveAs = function(blob, name, no_auto_bom) {
return new FileSaver(blob, name || blob.name || "download", no_auto_bom);
}
;
// IE 10+ (native saveAs)
if (typeof navigator !== "undefined" && navigator.msSaveOrOpenBlob) {
return function(blob, name, no_auto_bom) {
name = name || blob.name || "download";
if (!no_auto_bom) {
blob = auto_bom(blob);
}
return navigator.msSaveOrOpenBlob(blob, name);
};
}
FS_proto.abort = function(){};
FS_proto.readyState = FS_proto.INIT = 0;
FS_proto.WRITING = 1;
FS_proto.DONE = 2;
FS_proto.error =
FS_proto.onwritestart =
FS_proto.onprogress =
FS_proto.onwrite =
FS_proto.onabort =
FS_proto.onerror =
FS_proto.onwriteend =
null;
return saveAs;
}(
typeof self !== "undefined" && self
|| typeof window !== "undefined" && window
|| this.content
));
// `self` is undefined in Firefox for Android content script context
// while `this` is nsIContentFrameMessageManager
// with an attribute `content` that corresponds to the window
if (typeof module !== "undefined" && module.exports) {
module.exports.saveAs = saveAs;
} else if ((typeof define !== "undefined" && define !== null) && (define.amd !== null)) {
define("FileSaver.js", function() {
return saveAs;
});
}
},{}]},{},[1])(1)
});