38 Commits
Author SHA1 Message Date
Eli Grey 6356c3f6f6 Set target="_blank" on save link
Also normalize setImmediate usage

Fixes #408
2018-03-16 14:45:20 -07:00
Eli GreyandGitHub 24f9aaca80 Merge pull request #397 from Rillke/patch-1
Update @source in FileSaver.js
2018-01-25 01:46:34 -08:00
Rainer RillkeandGitHub f1959c87cd Update @source in FileSaver.js 2018-01-25 01:54:51 +01:00
Eli GreyandGitHub dfd58561fb Use export default 2018-01-22 15:53:17 -08:00
Eli GreyandGitHub a5dbf55c17 Merge pull request #391 from ogonkov/use_babel
Run build via `babel`. More changes and cleanup to come
2018-01-22 14:49:06 -08:00
Alexey 5978f3c577 Avoid using window in export 2018-01-23 00:12:19 +03:00
Alexey 9570cf7362 Update readme 2018-01-14 08:50:55 +00:00
Alexey b1158d0c33 Update main in bower.json 2018-01-14 08:44:50 +00:00
Alexey b6c236d96d Add check for window.saveAs 2018-01-14 08:43:44 +00:00
Alexey 164deec5ab Build to dist folder 2018-01-13 09:01:32 +00:00
Alexey 99a89750b0 Update prepublish script name 2018-01-13 08:39:48 +00:00
Alexey ff675f8052 Change to named export 2018-01-13 08:37:02 +00:00
Alexey 17d5c67eb3 Fix files section in package.json 2018-01-13 08:37:02 +00:00
Alexey 70bb521e5d Preserve generated files location 2018-01-13 08:37:02 +00:00
Alexey b4c11367c0 Build minified version 2018-01-13 08:37:02 +00:00
Alexey 281a1c1a93 Run build before publishing 2018-01-13 08:37:02 +00:00
Alexey d02373e40d Preserve source file for npm 2018-01-13 08:37:02 +00:00
Alexey d7f5db3244 Run build via babel 2018-01-13 08:37:02 +00:00
Eli Grey b4a918669a Update version number for #387 2018-01-12 05:03:49 -08:00
Eli Grey 5733e40e5a Fixes #387 2018-01-12 05:00:59 -08:00
Eli GreyandGitHub 74f089808e Merge pull request #387 from arasabbasi/patch-1
Fix RollUp-Error because of This is Undefined Rewrite
2018-01-12 04:56:18 -08:00
Aras AbbasiandGitHub fe42ec4055 Update FileSaver.js 2018-01-12 13:46:49 +01:00
Aras AbbasiandGitHub 0b90542535 Update FileSaver.js 2018-01-12 13:14:59 +01:00
JoshuaandJimmy Wärting c3e4a45021 Fix typo (#378)
Fix typo
2017-12-06 12:47:35 +01:00
Aras AbbasiandGitHub db089ce81e Update FileSaver.js 2017-12-04 19:42:44 +01:00
Aras AbbasiandGitHub 1bf9b35b54 Fix RollUp-Error because of This is Undefined Rewrite
make it compatible with RollUp
rollup/rollup#759
MrRio/jsPDF#1533
2017-12-04 19:40:44 +01:00
Eli GreyandGitHub c347c51f6e Merge pull request #374 from thijstriemstra/patch-1
fix typo
2017-09-29 17:53:01 -07:00
Thijs TriemstraandGitHub 945f08bc74 fix typo 2017-09-30 02:10:23 +02:00
Jimmy Karl Roland WärtingandGitHub dffa3a4989 Updated browser support
closes #12
2017-06-22 09:01:12 +02:00
Jimmy Karl Roland WärtingandGitHub 4db4a78aad Merge pull request #310 from marvinscharle/master
Include informations for how to get Typescript definitions into README.md
2017-03-09 16:01:41 +01:00
Marvin Scharle d89ed13171 Updated README to include information about typescript definitions eligrey/FileSaver.js#277 2017-02-15 17:24:53 +01:00
Jimmy Karl Roland WärtingandGitHub aa9f4e0e03 Merge pull request #273 from Amitesh/require-syntax-usage
Saving text using with require statement
2016-10-14 10:54:05 +02:00
Amitesh KumarandGitHub cafa1bfebb Saving text using with require statement 2016-10-14 12:09:50 +05:30
Jimmy Wärting 5ed507ef8a constructor test in safari 10 has nuked 2016-10-05 12:47:35 +02:00
Eli Grey eb8d76f845 Closes #257 2016-09-01 15:09:41 -07:00
Eli GreyandGitHub 8739c467c6 Merge pull request #159 from zky829/patch-1
Add safe module name to avoid requireJS errors
2016-08-29 15:01:25 -07:00
zky829 d8870ded68 Resolve conflicts 2016-08-28 19:42:48 +01:00
z.ky 7b242c2d78 Add safe module name to avoid requireJS errors
If a safe module name is not defined for requireJS, it will throw a "Mismatched anonymous define() modules..." error in the browser.
2015-07-15 14:23:01 +01:00
9 changed files with 2856 additions and 44 deletions
+19
View File
@@ -0,0 +1,19 @@
{
"presets": [
["env", {
"targets": {
"browsers": [
"ie > 9"
]
}
}]
],
"plugins": [
"transform-es2015-modules-umd"
],
"env": {
"production": {
"presets": ["minify"]
}
}
}
+6
View File
@@ -0,0 +1,6 @@
node_modules/
.DS_Store
.idea/
# Generated files
/dist/
-2
View File
@@ -1,2 +0,0 @@
/*! @source http://purl.eligrey.com/github/FileSaver.js/blob/master/FileSaver.js */
var saveAs=saveAs||function(e){"use strict";if(typeof e==="undefined"||typeof navigator!=="undefined"&&/MSIE [1-9]\./.test(navigator.userAgent)){return}var t=e.document,n=function(){return e.URL||e.webkitURL||e},r=t.createElementNS("http://www.w3.org/1999/xhtml","a"),o="download"in r,i=function(e){var t=new MouseEvent("click");e.dispatchEvent(t)},a=/constructor/i.test(e.HTMLElement),f=/CriOS\/[\d]+/.test(navigator.userAgent),u=function(t){(e.setImmediate||e.setTimeout)(function(){throw t},0)},d="application/octet-stream",s=1e3*40,c=function(e){var t=function(){if(typeof e==="string"){n().revokeObjectURL(e)}else{e.remove()}};setTimeout(t,s)},l=function(e,t,n){t=[].concat(t);var r=t.length;while(r--){var o=e["on"+t[r]];if(typeof o==="function"){try{o.call(e,n||e)}catch(i){u(i)}}}},p=function(e){if(/^\s*(?:text\/\S*|application\/xml|\S*\/\S*\+xml)\s*;.*charset\s*=\s*utf-8/i.test(e.type)){return new Blob([String.fromCharCode(65279),e],{type:e.type})}return e},v=function(t,u,s){if(!s){t=p(t)}var v=this,w=t.type,m=w===d,y,h=function(){l(v,"writestart progress write writeend".split(" "))},S=function(){if((f||m&&a)&&e.FileReader){var r=new FileReader;r.onloadend=function(){var t=f?r.result:r.result.replace(/^data:[^;]*;/,"data:attachment/file;");var n=e.open(t,"_blank");if(!n)e.location.href=t;t=undefined;v.readyState=v.DONE;h()};r.readAsDataURL(t);v.readyState=v.INIT;return}if(!y){y=n().createObjectURL(t)}if(m){e.location.href=y}else{var o=e.open(y,"_blank");if(!o){e.location.href=y}}v.readyState=v.DONE;h();c(y)};v.readyState=v.INIT;if(o){y=n().createObjectURL(t);setTimeout(function(){r.href=y;r.download=u;i(r);h();c(y);v.readyState=v.DONE});return}S()},w=v.prototype,m=function(e,t,n){return new v(e,t||e.name||"download",n)};if(typeof navigator!=="undefined"&&navigator.msSaveOrOpenBlob){return function(e,t,n){t=t||e.name||"download";if(!n){e=p(e)}return navigator.msSaveOrOpenBlob(e,t)}}w.abort=function(){};w.readyState=w.INIT=0;w.WRITING=1;w.DONE=2;w.error=w.onwritestart=w.onprogress=w.onwrite=w.onabort=w.onerror=w.onwriteend=null;return m}(typeof self!=="undefined"&&self||typeof window!=="undefined"&&window||this.content);if(typeof module!=="undefined"&&module.exports){module.exports.saveAs=saveAs}else if(typeof define!=="undefined"&&define!==null&&define.amd!==null){define([],function(){return saveAs})}
+2
View File
@@ -1,3 +1,5 @@
The MIT License
Copyright © 2016 [Eli Grey][1]. Copyright © 2016 [Eli Grey][1].
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
+16 -15
View File
@@ -32,6 +32,7 @@ Supported browsers
| Opera < 15 | data: URI | No | n/a | [Blob.js](https://github.com/eligrey/Blob.js) | | Opera < 15 | data: URI | No | n/a | [Blob.js](https://github.com/eligrey/Blob.js) |
| Safari 6.1+* | Blob | No | ? | None | | Safari 6.1+* | Blob | No | ? | None |
| Safari < 6 | data: URI | No | n/a | [Blob.js](https://github.com/eligrey/Blob.js) | | Safari < 6 | data: URI | No | n/a | [Blob.js](https://github.com/eligrey/Blob.js) |
| Safari 10.1+   | Blob         | Yes         | n/a           | None |
Feature detection is possible: Feature detection is possible:
@@ -67,11 +68,18 @@ Pass `true` for `disableAutoBOM` if you don't want FileSaver.js to automatically
Examples Examples
-------- --------
### Saving text using require
```js
var FileSaver = require('file-saver');
var blob = new Blob(["Hello, world!"], {type: "text/plain;charset=utf-8"});
FileSaver.saveAs(blob, "hello world.txt");
```
### Saving text ### Saving text
```js ```js
var blob = new Blob(["Hello, world!"], {type: "text/plain;charset=utf-8"}); var blob = new Blob(["Hello, world!"], {type: "text/plain;charset=utf-8"});
saveAs(blob, "hello world.txt"); FileSaver.saveAs(blob, "hello world.txt");
``` ```
The standard W3C File API [`Blob`][4] interface is not available in all browsers. The standard W3C File API [`Blob`][4] interface is not available in all browsers.
@@ -99,7 +107,7 @@ But if you still want to change the name, then you can change it in the 2nd argu
```js ```js
var file = new File(["Hello, world!"], "hello world.txt", {type: "text/plain;charset=utf-8"}); var file = new File(["Hello, world!"], "hello world.txt", {type: "text/plain;charset=utf-8"});
saveAs(file); FileSaver.saveAs(file);
``` ```
@@ -113,19 +121,6 @@ saveAs(file);
[5]: https://github.com/eligrey/Blob.js [5]: https://github.com/eligrey/Blob.js
[6]: https://github.com/eligrey/canvas-toBlob.js [6]: https://github.com/eligrey/canvas-toBlob.js
Contributing
------------
The `FileSaver.js` distribution file is compiled with Uglify.js like so:
```bash
uglifyjs FileSaver.js --mangle --comments /@source/ > FileSaver.min.js
# or simply:
npm run build
```
Please make sure you build a production version before submitting a pull request.
Installation Installation
------------------ ------------------
@@ -133,3 +128,9 @@ Installation
npm install file-saver --save npm install file-saver --save
bower install file-saver bower install file-saver
``` ```
Additionally, TypeScript definitions can be installed via:
```bash
npm install @types/file-saver --save-dev
```
+2 -2
View File
@@ -1,7 +1,7 @@
{ {
"name": "file-saver", "name": "file-saver",
"main": "FileSaver.js", "main": "dist/FileSaver.js",
"version": "1.3.2", "version": "1.3.3",
"homepage": "https://github.com/eligrey/FileSaver.js", "homepage": "https://github.com/eligrey/FileSaver.js",
"authors": [ "authors": [
"Eli Grey <[email protected]>" "Eli Grey <[email protected]>"
+2783
View File
File diff suppressed because it is too large Load Diff
+14 -4
View File
@@ -1,11 +1,18 @@
{ {
"name": "file-saver", "name": "file-saver",
"version": "1.3.2", "version": "1.3.4",
"description": "An HTML5 saveAs() FileSaver implementation", "description": "An HTML5 saveAs() FileSaver implementation",
"main": "FileSaver.js", "main": "dist/FileSaver.js",
"module": "src/FileSaver.js",
"files": [
"dist/FileSaver.min.js"
],
"scripts": { "scripts": {
"test": "echo \"Error: no test specified\" && exit 0", "test": "echo \"Error: no test specified\" && exit 0",
"build": "node_modules/.bin/uglifyjs FileSaver.js --mangle --comments /@source/ > FileSaver.min.js" "build:development": "mkdir -p dist && babel src/FileSaver.js --out-file=dist/FileSaver.js",
"build:production": "NODE_ENV=production npm run build:development -- --out-file=dist/FileSaver.min.js",
"build": "npm run build:development && npm run build:production",
"prepublishOnly": "npm run build"
}, },
"repository": { "repository": {
"type": "git", "type": "git",
@@ -23,6 +30,9 @@
}, },
"homepage": "https://github.com/eligrey/FileSaver.js#readme", "homepage": "https://github.com/eligrey/FileSaver.js#readme",
"devDependencies": { "devDependencies": {
"uglify-js": "^2.6.2" "babel-cli": "^6.26.0",
"babel-plugin-transform-es2015-modules-umd": "^6.24.1",
"babel-preset-env": "^1.6.1",
"babel-preset-minify": "^0.2.0"
} }
} }
+14 -21
View File
@@ -1,9 +1,9 @@
/* FileSaver.js /* FileSaver.js
* A saveAs() FileSaver implementation. * A saveAs() FileSaver implementation.
* 1.3.2 * 1.3.6
* 2016-06-16 18:25:19 * 2018-03-16 14:39:40
* *
* By Eli Grey, http://eligrey.com * By Eli Grey, https://eligrey.com
* License: MIT * License: MIT
* See https://github.com/eligrey/FileSaver.js/blob/master/LICENSE.md * See https://github.com/eligrey/FileSaver.js/blob/master/LICENSE.md
*/ */
@@ -11,9 +11,9 @@
/*global self */ /*global self */
/*jslint bitwise: true, indent: 4, laxbreak: true, laxcomma: true, smarttabs: true, plusplus: true */ /*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 */ /*! @source http://purl.eligrey.com/github/FileSaver.js/blob/master/src/FileSaver.js */
var saveAs = saveAs || (function(view) { export default var saveAs = saveAs || (function(view) {
"use strict"; "use strict";
// IE <10 is explicitly unsupported // IE <10 is explicitly unsupported
if (typeof view === "undefined" || typeof navigator !== "undefined" && /MSIE [1-9]\./.test(navigator.userAgent)) { if (typeof view === "undefined" || typeof navigator !== "undefined" && /MSIE [1-9]\./.test(navigator.userAgent)) {
@@ -31,10 +31,11 @@ var saveAs = saveAs || (function(view) {
var event = new MouseEvent("click"); var event = new MouseEvent("click");
node.dispatchEvent(event); node.dispatchEvent(event);
} }
, is_safari = /constructor/i.test(view.HTMLElement) , is_safari = /constructor/i.test(view.HTMLElement) || view.safari
, is_chrome_ios =/CriOS\/[\d]+/.test(navigator.userAgent) , is_chrome_ios =/CriOS\/[\d]+/.test(navigator.userAgent)
, setImmediate = view.setImmediate || view.setTimeout
, throw_outside = function(ex) { , throw_outside = function(ex) {
(view.setImmediate || view.setTimeout)(function() { setImmediate(function() {
throw ex; throw ex;
}, 0); }, 0);
} }
@@ -125,14 +126,14 @@ var saveAs = saveAs || (function(view) {
if (can_use_save_link) { if (can_use_save_link) {
object_url = get_URL().createObjectURL(blob); object_url = get_URL().createObjectURL(blob);
setTimeout(function() { setImmediate(function() {
save_link.href = object_url; save_link.href = object_url;
save_link.download = name; save_link.download = name;
click(save_link); click(save_link);
dispatch_all(); dispatch_all();
revoke(object_url); revoke(object_url);
filesaver.readyState = filesaver.DONE; filesaver.readyState = filesaver.DONE;
}); }, 0);
return; return;
} }
@@ -143,6 +144,7 @@ var saveAs = saveAs || (function(view) {
return new FileSaver(blob, name || blob.name || "download", no_auto_bom); return new FileSaver(blob, name || blob.name || "download", no_auto_bom);
} }
; ;
// IE 10+ (native saveAs) // IE 10+ (native saveAs)
if (typeof navigator !== "undefined" && navigator.msSaveOrOpenBlob) { if (typeof navigator !== "undefined" && navigator.msSaveOrOpenBlob) {
return function(blob, name, no_auto_bom) { return function(blob, name, no_auto_bom) {
@@ -155,6 +157,8 @@ var saveAs = saveAs || (function(view) {
}; };
} }
save_link.target = "_blank";
FS_proto.abort = function(){}; FS_proto.abort = function(){};
FS_proto.readyState = FS_proto.INIT = 0; FS_proto.readyState = FS_proto.INIT = 0;
FS_proto.WRITING = 1; FS_proto.WRITING = 1;
@@ -173,16 +177,5 @@ var saveAs = saveAs || (function(view) {
}( }(
typeof self !== "undefined" && self typeof self !== "undefined" && self
|| typeof window !== "undefined" && window || typeof window !== "undefined" && window
|| this.content || this
)); ));
// `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([], function() {
return saveAs;
});
}