UNPKG

@lxlib/seed

Version:

This library was generated with [Angular CLI](https://github.com/angular/angular-cli) version 9.1.1.

16 lines (14 loc) 3.77 kB
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("@angular/core"),require("@angular/common/http"),require("@lxlib/util"),require("file-saver"),require("@angular/common")):"function"==typeof define&&define.amd?define("@lxlib/seed/zip",["exports","@angular/core","@angular/common/http","@lxlib/util","file-saver","@angular/common"],t):t(((e=e||self).lxlib=e.lxlib||{},e.lxlib.seed=e.lxlib.seed||{},e.lxlib.seed.zip={}),e.ng.core,e.ng.common.http,e.lxlib.util,e.saveAs,e.ng.common)}(this,(function(e,t,n,r,o,i){"use strict"; /*! ***************************************************************************** Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE, MERCHANTABLITY OR NON-INFRINGEMENT. See the Apache Version 2.0 License for specific language governing permissions and limitations under the License. ***************************************************************************** */var c=function(){return(c=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var o in t=arguments[n])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e}).apply(this,arguments)};var u=function(){function e(){this.url="//cdn.bootcss.com/jszip/3.1.5/jszip.min.js",this.utils=[]}return e.decorators=[{type:t.Injectable,args:[{providedIn:"root"}]}],e.ɵprov=t.ɵɵdefineInjectable({factory:function(){return new e},token:e,providedIn:"root"}),e}();var a=function(){function e(e,t,n){this.cog=e,this.http=t,this.lazy=n}return e.prototype.init=function(){return this.lazy.load([this.cog.url].concat(this.cog.utils))},e.prototype.check=function(e){if(!e)throw new Error("get instance via `ZipService.create()`")},e.prototype.read=function(e,t){var n=this;return new Promise((function(r,o){n.init().then((function(){if("string"!=typeof e){var i=new FileReader;i.onload=function(e){JSZip.loadAsync(e.target.result,t).then((function(e){return r(e)}))},i.readAsBinaryString(e)}else n.http.request("GET",e,{responseType:"arraybuffer"}).subscribe((function(e){JSZip.loadAsync(e,t).then((function(e){return r(e)}))}),(function(e){o(e)}))}))}))},e.prototype.create=function(){var e=this;return new Promise((function(t){e.init().then((function(){var e=new JSZip;t(e)}))}))},e.prototype.pushUrl=function(e,t,n){var r=this;return this.check(e),new Promise((function(o,i){r.http.request("GET",n,{responseType:"arraybuffer"}).subscribe((function(n){e.file(t,n),o()}),(function(e){i({url:n,error:e})}))}))},e.prototype.save=function(e,t){this.check(e);var n=c({},t);return new Promise((function(t,r){e.generateAsync(c({type:"blob"},n.options),n.update).then((function(e){n.callback&&n.callback(e),o.saveAs(e,n.filename||"download.zip"),t()}),(function(e){r(e)}))}))},e.decorators=[{type:t.Injectable,args:[{providedIn:"root"}]}],e.ctorParameters=function(){return[{type:u},{type:n.HttpClient},{type:r.LazyService}]},e.ɵprov=t.ɵɵdefineInjectable({factory:function(){return new e(t.ɵɵinject(u),t.ɵɵinject(n.HttpClient),t.ɵɵinject(r.LazyService))},token:e,providedIn:"root"}),e}();var s=function(){function e(){}return e.decorators=[{type:t.NgModule,args:[{imports:[i.CommonModule,r.LxlibUtilModule]}]}],e}();e.ZipConfig=u,e.ZipModule=s,e.ZipService=a,Object.defineProperty(e,"__esModule",{value:!0})})); //# sourceMappingURL=zip.umd.min.js.map