mirror of
https://gitee.com/beijing_hongye_huicheng/lilishop-ui.git
synced 2025-12-17 16:35:53 +08:00
c
This commit is contained in:
21
node_modules/_downloadjs@1.4.7@downloadjs/LICENSE.md
generated
vendored
Normal file
21
node_modules/_downloadjs@1.4.7@downloadjs/LICENSE.md
generated
vendored
Normal file
@@ -0,0 +1,21 @@
|
||||
MIT License
|
||||
|
||||
Copyright (c) 2016 dandavis
|
||||
|
||||
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:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
123
node_modules/_downloadjs@1.4.7@downloadjs/README.md
generated
vendored
Normal file
123
node_modules/_downloadjs@1.4.7@downloadjs/README.md
generated
vendored
Normal file
@@ -0,0 +1,123 @@
|
||||
# download
|
||||
========
|
||||
|
||||
## Summary
|
||||
---------
|
||||
The download() function is used to trigger a file download from JavaScript.
|
||||
|
||||
It specifies the contents and name of a new file placed in the browser's download directory. The input can be a URL, String, Blob, or Typed Array of data, or via a dataURL representing the file's data as base64 or url-encoded string. No matter the input format, download() saves a file using the specified file name and mime information in the same manner as a server using a Content-Disposition HTTP header.
|
||||
|
||||
## Getting and Using
|
||||
---------
|
||||
|
||||
### Via NPM/Bower
|
||||
`npm install downloadjs` <br />
|
||||
`bower install downloadjs`
|
||||
|
||||
`require("downloadjs")(data, strFileName, strMimeType);`
|
||||
|
||||
### Simple global `download` function via `<script>` include
|
||||
download(data, strFileName, strMimeType);
|
||||
|
||||
### Included via AMD
|
||||
require(['path/to/file'], function(download) {
|
||||
download(data, strFileName, strMimeType);
|
||||
});
|
||||
|
||||
|
||||
### Parameters
|
||||
---------
|
||||
* **data** - The Blob, File, String, or dataURL containing the soon-to-be File's contents.
|
||||
* **strFileName** - The name of the file to be created. Note that older browsers (like FF3.5, Ch5) don't honor the file name you provide, instead they automatically name the downloaded file.
|
||||
* **strMimeType** - The MIME content-type of the file to download. While optional, it helps the browser present friendlier information about the download to the user, encouraging them to accept the download.
|
||||
|
||||
|
||||
|
||||
## Example Usage
|
||||
---------
|
||||
|
||||
|
||||
### Plain Text
|
||||
#### text string - [live demo](http://pagedemos.com/hw24em95rsfq/output/)
|
||||
download("hello world", "dlText.txt", "text/plain");
|
||||
|
||||
#### text dataURL - [live demo](http://pagedemos.com/r9ywm98s6b29/output/)
|
||||
download("data:text/plain,hello%20world", "dlDataUrlText.txt", "text/plain");
|
||||
|
||||
#### text blob - [live demo](http://pagedemos.com/ckcah2vp8kza/output/)
|
||||
download(new Blob(["hello world"]), "dlTextBlob.txt", "text/plain");
|
||||
|
||||
#### text url - [live demo](http://pagedemos.com/pz6hkyqutjtw/output/)
|
||||
download("/robots.txt");
|
||||
|
||||
|
||||
#### text UInt8 Array - [live demo](http://pagedemos.com/zuyk46wbkktq/output/)
|
||||
var str= "hello world", arr= new Uint8Array(str.length);
|
||||
str.split("").forEach(function(a,b){
|
||||
arr[b]=a.charCodeAt();
|
||||
});
|
||||
|
||||
download( arr, "textUInt8Array.txt", "text/plain" );
|
||||
|
||||
### HTML
|
||||
#### html string - [live demo](http://pagedemos.com/k7rwq7msu3eb/output/)
|
||||
download(document.documentElement.outerHTML, "dlHTML.html", "text/html");
|
||||
|
||||
#### html Blob - [live demo](http://pagedemos.com/bxehm2fdf3g4/output/)
|
||||
download(new Blob(["hello world".bold()]), "dlHtmlBlob.html", "text/html");
|
||||
|
||||
#### ajax callback - [live demo](http://pagedemos.com/arr2ym74aw8t/output/)
|
||||
(note that callback mode won't work on vanilla ajax or with binary files)
|
||||
|
||||
$.ajax({
|
||||
url: "/download.html",
|
||||
success: download.bind(true, "text/html", "dlAjaxCallback.html")
|
||||
});
|
||||
|
||||
|
||||
### Binary Files
|
||||
#### image from URL - [live demo](http://pagedemos.com/yvvmxbjrwq7u/output/)
|
||||
download("/diff6.png");
|
||||
|
||||
#### Image via ajax for custom filename - [live demo](http://pagedemos.com/v2848zfgwrju/output/)
|
||||
var x=new XMLHttpRequest();
|
||||
x.open( "GET", "/diff6.png" , true);
|
||||
x.responseType="blob";
|
||||
x.onload= function(e){download(e.target.response, "awesomesauce.png", "image/png");};
|
||||
x.send();
|
||||
|
||||
|
||||
## Compatibility
|
||||
---------
|
||||
download.js works with a wide range of devices and browsers.
|
||||
|
||||
You can expect it to work for the vast majority of your users, with some common-sense limits:
|
||||
|
||||
* Devices without file systems like iPhone, iPad, Wii, et al. have nowhere to save the file to, sorry.
|
||||
* Android support starts at 4.2 for the built-in browser, though chrome 36+ and firefox 20+ on android 2.3+ work well.
|
||||
* Devices without Blob support won't be able to download Blobs or TypedArrays
|
||||
* Legacy devices (no a[download]) support can only download a few hundred kilobytes of data, and can't give the file a custom name.
|
||||
* Devices without window.URL support can only download a couple megabytes of data
|
||||
* IE versions of 9 and before are NOT supported because the don't support a[download] or dataURL frame locations.
|
||||
|
||||
|
||||
## FAQ
|
||||
---------
|
||||
|
||||
* `Can I tell when a download is done/canceled?` No.
|
||||
* `How can I style the temporary download link?` Define CSS class styles for `.download-js-link`.
|
||||
* `What's up with Safari?` I don't know either but pull requests that improve the situation are welcome.
|
||||
* `Why is my binary file corrupted?` Likely: an incorrect MIME or using jQuery ajax, which has no bin support.
|
||||
* `How big of files work?` Depends, try yourself: [File Echo Demo](http://pagedemos.com/gqs6hbmjcpem/)... I do a 1GB dl routinely on a thinkpad...
|
||||
|
||||
|
||||
## Change Log (v4.1)
|
||||
---------
|
||||
* 2008 :: landed a FF+Chrome compat way of downloading strings to local un-named files, upgraded to use a hidden frame and optional mime
|
||||
* 2012 :: added named files via a[download], msSaveBlob() for IE (10+) support, and window.URL support for larger+faster saves than dataURLs
|
||||
* 2014 :: added dataURL and Blob Input, bind-toggle arity, and legacy dataURL fallback was improved with force-download mime and base64 support
|
||||
* 2015 :: converted to amd/commonJS module with browser-friendly fallback
|
||||
* 2015 :: 4.1 added direct URL downloading via a single URL argument.
|
||||
* 2016 :: 4.2 added large dataURL support, a more semantic codebase, and hidden temp links
|
||||
* 2017 :: added support for empty dataURLs
|
||||
* 20XX :: ???? Considering Zip, Tar, and other multi-file outputs, Blob.prototype.download option, and more, stay tuned folks.
|
||||
167
node_modules/_downloadjs@1.4.7@downloadjs/download.js
generated
vendored
Normal file
167
node_modules/_downloadjs@1.4.7@downloadjs/download.js
generated
vendored
Normal file
@@ -0,0 +1,167 @@
|
||||
//download.js v4.2, by dandavis; 2008-2016. [MIT] see http://danml.com/download.html for tests/usage
|
||||
// v1 landed a FF+Chrome compat way of downloading strings to local un-named files, upgraded to use a hidden frame and optional mime
|
||||
// v2 added named files via a[download], msSaveBlob, IE (10+) support, and window.URL support for larger+faster saves than dataURLs
|
||||
// v3 added dataURL and Blob Input, bind-toggle arity, and legacy dataURL fallback was improved with force-download mime and base64 support. 3.1 improved safari handling.
|
||||
// v4 adds AMD/UMD, commonJS, and plain browser support
|
||||
// v4.1 adds url download capability via solo URL argument (same domain/CORS only)
|
||||
// v4.2 adds semantic variable names, long (over 2MB) dataURL support, and hidden by default temp anchors
|
||||
// https://github.com/rndme/download
|
||||
|
||||
(function (root, factory) {
|
||||
if (typeof define === 'function' && define.amd) {
|
||||
// AMD. Register as an anonymous module.
|
||||
define([], factory);
|
||||
} else if (typeof exports === 'object') {
|
||||
// Node. Does not work with strict CommonJS, but
|
||||
// only CommonJS-like environments that support module.exports,
|
||||
// like Node.
|
||||
module.exports = factory();
|
||||
} else {
|
||||
// Browser globals (root is window)
|
||||
root.download = factory();
|
||||
}
|
||||
}(this, function () {
|
||||
|
||||
return function download(data, strFileName, strMimeType) {
|
||||
|
||||
var self = window, // this script is only for browsers anyway...
|
||||
defaultMime = "application/octet-stream", // this default mime also triggers iframe downloads
|
||||
mimeType = strMimeType || defaultMime,
|
||||
payload = data,
|
||||
url = !strFileName && !strMimeType && payload,
|
||||
anchor = document.createElement("a"),
|
||||
toString = function(a){return String(a);},
|
||||
myBlob = (self.Blob || self.MozBlob || self.WebKitBlob || toString),
|
||||
fileName = strFileName || "download",
|
||||
blob,
|
||||
reader;
|
||||
myBlob= myBlob.call ? myBlob.bind(self) : Blob ;
|
||||
|
||||
if(String(this)==="true"){ //reverse arguments, allowing download.bind(true, "text/xml", "export.xml") to act as a callback
|
||||
payload=[payload, mimeType];
|
||||
mimeType=payload[0];
|
||||
payload=payload[1];
|
||||
}
|
||||
|
||||
|
||||
if(url && url.length< 2048){ // if no filename and no mime, assume a url was passed as the only argument
|
||||
fileName = url.split("/").pop().split("?")[0];
|
||||
anchor.href = url; // assign href prop to temp anchor
|
||||
if(anchor.href.indexOf(url) !== -1){ // if the browser determines that it's a potentially valid url path:
|
||||
var ajax=new XMLHttpRequest();
|
||||
ajax.open( "GET", url, true);
|
||||
ajax.responseType = 'blob';
|
||||
ajax.onload= function(e){
|
||||
download(e.target.response, fileName, defaultMime);
|
||||
};
|
||||
setTimeout(function(){ ajax.send();}, 0); // allows setting custom ajax headers using the return:
|
||||
return ajax;
|
||||
} // end if valid url?
|
||||
} // end if url?
|
||||
|
||||
|
||||
//go ahead and download dataURLs right away
|
||||
if(/^data:([\w+-]+\/[\w+.-]+)?[,;]/.test(payload)){
|
||||
|
||||
if(payload.length > (1024*1024*1.999) && myBlob !== toString ){
|
||||
payload=dataUrlToBlob(payload);
|
||||
mimeType=payload.type || defaultMime;
|
||||
}else{
|
||||
return navigator.msSaveBlob ? // IE10 can't do a[download], only Blobs:
|
||||
navigator.msSaveBlob(dataUrlToBlob(payload), fileName) :
|
||||
saver(payload) ; // everyone else can save dataURLs un-processed
|
||||
}
|
||||
|
||||
}else{//not data url, is it a string with special needs?
|
||||
if(/([\x80-\xff])/.test(payload)){
|
||||
var i=0, tempUiArr= new Uint8Array(payload.length), mx=tempUiArr.length;
|
||||
for(i;i<mx;++i) tempUiArr[i]= payload.charCodeAt(i);
|
||||
payload=new myBlob([tempUiArr], {type: mimeType});
|
||||
}
|
||||
}
|
||||
blob = payload instanceof myBlob ?
|
||||
payload :
|
||||
new myBlob([payload], {type: mimeType}) ;
|
||||
|
||||
|
||||
function dataUrlToBlob(strUrl) {
|
||||
var parts= strUrl.split(/[:;,]/),
|
||||
type= parts[1],
|
||||
decoder= parts[2] == "base64" ? atob : decodeURIComponent,
|
||||
binData= decoder( parts.pop() ),
|
||||
mx= binData.length,
|
||||
i= 0,
|
||||
uiArr= new Uint8Array(mx);
|
||||
|
||||
for(i;i<mx;++i) uiArr[i]= binData.charCodeAt(i);
|
||||
|
||||
return new myBlob([uiArr], {type: type});
|
||||
}
|
||||
|
||||
function saver(url, winMode){
|
||||
|
||||
if ('download' in anchor) { //html5 A[download]
|
||||
anchor.href = url;
|
||||
anchor.setAttribute("download", fileName);
|
||||
anchor.className = "download-js-link";
|
||||
anchor.innerHTML = "downloading...";
|
||||
anchor.style.display = "none";
|
||||
document.body.appendChild(anchor);
|
||||
setTimeout(function() {
|
||||
anchor.click();
|
||||
document.body.removeChild(anchor);
|
||||
if(winMode===true){setTimeout(function(){ self.URL.revokeObjectURL(anchor.href);}, 250 );}
|
||||
}, 66);
|
||||
return true;
|
||||
}
|
||||
|
||||
// handle non-a[download] safari as best we can:
|
||||
if(/(Version)\/(\d+)\.(\d+)(?:\.(\d+))?.*Safari\//.test(navigator.userAgent)) {
|
||||
if(/^data:/.test(url)) url="data:"+url.replace(/^data:([\w\/\-\+]+)/, defaultMime);
|
||||
if(!window.open(url)){ // popup blocked, offer direct download:
|
||||
if(confirm("Displaying New Document\n\nUse Save As... to download, then click back to return to this page.")){ location.href=url; }
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
//do iframe dataURL download (old ch+FF):
|
||||
var f = document.createElement("iframe");
|
||||
document.body.appendChild(f);
|
||||
|
||||
if(!winMode && /^data:/.test(url)){ // force a mime that will download:
|
||||
url="data:"+url.replace(/^data:([\w\/\-\+]+)/, defaultMime);
|
||||
}
|
||||
f.src=url;
|
||||
setTimeout(function(){ document.body.removeChild(f); }, 333);
|
||||
|
||||
}//end saver
|
||||
|
||||
|
||||
|
||||
|
||||
if (navigator.msSaveBlob) { // IE10+ : (has Blob, but not a[download] or URL)
|
||||
return navigator.msSaveBlob(blob, fileName);
|
||||
}
|
||||
|
||||
if(self.URL){ // simple fast and modern way using Blob and URL:
|
||||
saver(self.URL.createObjectURL(blob), true);
|
||||
}else{
|
||||
// handle non-Blob()+non-URL browsers:
|
||||
if(typeof blob === "string" || blob.constructor===toString ){
|
||||
try{
|
||||
return saver( "data:" + mimeType + ";base64," + self.btoa(blob) );
|
||||
}catch(y){
|
||||
return saver( "data:" + mimeType + "," + encodeURIComponent(blob) );
|
||||
}
|
||||
}
|
||||
|
||||
// Blob but not URL support:
|
||||
reader=new FileReader();
|
||||
reader.onload=function(e){
|
||||
saver(this.result);
|
||||
};
|
||||
reader.readAsDataURL(blob);
|
||||
}
|
||||
return true;
|
||||
}; /* end download() */
|
||||
}));
|
||||
2
node_modules/_downloadjs@1.4.7@downloadjs/download.min.js
generated
vendored
Normal file
2
node_modules/_downloadjs@1.4.7@downloadjs/download.min.js
generated
vendored
Normal file
@@ -0,0 +1,2 @@
|
||||
//download.js v4.2, by dandavis; 2008-2017. [MIT] see http://danml.com/download.html for tests/usage
|
||||
;(function(r,l){"function"==typeof define&&define.amd?define([],l):"object"==typeof exports?module.exports=l():r.download=l()})(this,function(){return function l(a,e,k){function q(a){var h=a.split(/[:;,]/);a=h[1];var h=("base64"==h[2]?atob:decodeURIComponent)(h.pop()),d=h.length,b=0,c=new Uint8Array(d);for(b;b<d;++b)c[b]=h.charCodeAt(b);return new f([c],{type:a})}function m(a,b){if("download"in d)return d.href=a,d.setAttribute("download",n),d.className="download-js-link",d.innerHTML="downloading...",d.style.display="none",document.body.appendChild(d),setTimeout(function(){d.click(),document.body.removeChild(d),!0===b&&setTimeout(function(){g.URL.revokeObjectURL(d.href)},250)},66),!0;if(/(Version)\/(\d+)\.(\d+)(?:\.(\d+))?.*Safari\//.test(navigator.userAgent))return/^data:/.test(a)&&(a="data:"+a.replace(/^data:([\w\/\-\+]+)/,"application/octet-stream")),!window.open(a)&&confirm("Displaying New Document\n\nUse Save As... to download, then click back to return to this page.")&&(location.href=a),!0;var c=document.createElement("iframe");document.body.appendChild(c),!b&&/^data:/.test(a)&&(a="data:"+a.replace(/^data:([\w\/\-\+]+)/,"application/octet-stream")),c.src=a,setTimeout(function(){document.body.removeChild(c)},333)}var g=window,b=k||"application/octet-stream",c=!e&&!k&&a,d=document.createElement("a");k=function(a){return String(a)};var f=g.Blob||g.MozBlob||g.WebKitBlob||k,n=e||"download",f=f.call?f.bind(g):Blob;"true"===String(this)&&(a=[a,b],b=a[0],a=a[1]);if(c&&2048>c.length&&(n=c.split("/").pop().split("?")[0],d.href=c,-1!==d.href.indexOf(c))){var p=new XMLHttpRequest;return p.open("GET",c,!0),p.responseType="blob",p.onload=function(a){l(a.target.response,n,"application/octet-stream")},setTimeout(function(){p.send()},0),p}if(/^data:([\w+-]+\/[\w+.-]+)?[,;]/.test(a)){if(!(2096103.424<a.length&&f!==k))return navigator.msSaveBlob?navigator.msSaveBlob(q(a),n):m(a);a=q(a),b=a.type||"application/octet-stream"}else if(/([\x80-\xff])/.test(a)){e=0;var c=new Uint8Array(a.length),t=c.length;for(e;e<t;++e)c[e]=a.charCodeAt(e);a=new f([c],{type:b})}a=a instanceof f?a:new f([a],{type:b});if(navigator.msSaveBlob)return navigator.msSaveBlob(a,n);if(g.URL)m(g.URL.createObjectURL(a),!0);else{if("string"==typeof a||a.constructor===k)try{return m("data:"+b+";base64,"+g.btoa(a))}catch(h){return m("data:"+b+","+encodeURIComponent(a))}b=new FileReader,b.onload=function(a){m(this.result)},b.readAsDataURL(a)}return!0}});
|
||||
42
node_modules/_downloadjs@1.4.7@downloadjs/package.json
generated
vendored
Normal file
42
node_modules/_downloadjs@1.4.7@downloadjs/package.json
generated
vendored
Normal file
@@ -0,0 +1,42 @@
|
||||
{
|
||||
"name": "downloadjs",
|
||||
"main": "download.js",
|
||||
"version": "1.4.7",
|
||||
"description": "file downloading using client-side javascript",
|
||||
"keywords": [
|
||||
"files",
|
||||
"dataURL",
|
||||
"blob",
|
||||
"download"
|
||||
],
|
||||
"homepage": "http://danml.com/download.html",
|
||||
"license": "MIT",
|
||||
"author": {
|
||||
"name": "dandavis",
|
||||
"email": "rndme@users.noreply.github.com",
|
||||
"url": "http://danml.com/"
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/rndme/download.git"
|
||||
},
|
||||
"bugs": {
|
||||
"email": "rndme@users.noreply.github.com"
|
||||
},
|
||||
"files": [
|
||||
"download.js",
|
||||
"download.min.js"
|
||||
],
|
||||
"npmName": "downloadjs",
|
||||
"npmFileMap": [
|
||||
{
|
||||
"basePath": "/",
|
||||
"files": [
|
||||
"*.js"
|
||||
]
|
||||
}
|
||||
],
|
||||
"__npminstall_done": "Thu Jun 03 2021 11:07:53 GMT+0800 (中国标准时间)",
|
||||
"_from": "downloadjs@1.4.7",
|
||||
"_resolved": "https://registry.nlark.com/downloadjs/download/downloadjs-1.4.7.tgz"
|
||||
}
|
||||
Reference in New Issue
Block a user