@lxlib/seed
Version:
This library was generated with [Angular CLI](https://github.com/angular/angular-cli) version 9.1.1.
16 lines (14 loc) • 5.63 kB
JavaScript
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("@angular/core"),require("@lxlib/util"),require("rxjs")):"function"==typeof define&&define.amd?define("@lxlib/seed/lodop",["exports","@angular/core","@lxlib/util","rxjs"],t):t(((e=e||self).lxlib=e.lxlib||{},e.lxlib.seed=e.lxlib.seed||{},e.lxlib.seed.lodop={}),e.ng.core,e.lxlib.util,e.rxjs)}(this,(function(e,t,o,r){"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 n=function(){return(n=Object.assign||function(e){for(var t,o=1,r=arguments.length;o<r;o++)for(var n in t=arguments[o])Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n]);return e}).apply(this,arguments)};function i(e,t){var o="function"==typeof Symbol&&e[Symbol.iterator];if(!o)return e;var r,n,i=o.call(e),c=[];try{for(;(void 0===t||t-- >0)&&!(r=i.next()).done;)c.push(r.value)}catch(e){n={error:e}}finally{try{r&&!r.done&&(o=i.return)&&o.call(i)}finally{if(n)throw n.error}}return c}var c=function(){function e(){}return e.decorators=[{type:t.Injectable,args:[{providedIn:"root"}]}],e.ɵprov=t.ɵɵdefineInjectable({factory:function(){return new e},token:e,providedIn:"root"}),e}();var u=function(){function e(e,t){this.defCog=e,this.scriptSrv=t,this.pending=!1,this._lodop=null,this._init=new r.Subject,this._events=new r.Subject,this.printBuffer=[],this.cog=e}return Object.defineProperty(e.prototype,"cog",{get:function(){return this._cog},set:function(e){this._cog=n(n({url:"https://localhost:8443/CLodopfuncs.js",name:"CLODOP",companyName:"",checkMaxCount:100},this.defCog),e)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"events",{get:function(){return this._events.asObservable()},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"lodop",{get:function(){return this._lodop?r.of({ok:!0,lodop:this._lodop}):(this.pending||this.request(),this._init.asObservable())},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"printer",{get:function(){this.check();for(var e=[],t=this._lodop.GET_PRINTER_COUNT(),o=0;o<t;o++)e.push(this._lodop.GET_PRINTER_NAME(o));return e},enumerable:!0,configurable:!0}),e.prototype.check=function(){if(!this._lodop)throw new Error("请务必先调用 lodop 获取对象")},e.prototype.request=function(){var e=this;this.pending=!0;var t=this.cog.url+"?name="+this.cog.name,o=this.cog.checkMaxCount,r=function(t,o){e._init.next({ok:"ok"===t,status:t,error:o,lodop:e._lodop})},n=function(){if(--o,e._lodop.webskt&&1===e._lodop.webskt.readyState)r("ok");else{if(o<0)return void r("check-limit");setTimeout((function(){return n()}),100)}};this.scriptSrv.loadScript(t).then((function(t){if("ok"!==t.status)return e.pending=!1,void r("script-load-error",t[0]);var o=window;o.hasOwnProperty(e.cog.name)&&(e._lodop=o[e.cog.name]),null!==e._lodop?(e._lodop.SET_LICENSES(e.cog.companyName,e.cog.license,e.cog.licenseA,e.cog.licenseB),n()):r("load-variable-name-error",{name:e.cog.name})}))},e.prototype.reset=function(){this._lodop=null,this.pending=!1,this.request()},e.prototype.attachCode=function(e,t,o){var r=this;this.check(),o||(o=/LODOP\.([^(]+)\(([^\n]+)\);/i),e.split("\n").forEach((function(e){var n=o.exec(e.trim());if(n){var i=r._lodop[n[1]];if(i){var c=null;try{c=new Function("return ["+n[2]+"]")()}catch(e){}if(null!=c&&Array.isArray(c)&&t)for(var u=0;u<c.length;u++)"string"==typeof c[u]&&(c[u]=c[u].replace(/{{(.*?)}}/g,(function(e,o){return t[o.trim()]||""})));i.apply(r._lodop,c)}}}))},e.prototype.design=function(){var e=this;this.check();var t=this._lodop.PRINT_DESIGN();return new Promise((function(o){e._lodop.On_Return=function(r,n){t===r&&(e._lodop.On_Return=null,o(""+n))}}))},e.prototype.printDo=function(){var e=this,t=this.printBuffer.shift();if(t){this.attachCode(t.code,t.item,t.parser);var o=this._lodop.PRINT();this._lodop.On_Return=function(r,i){o===r&&(e._lodop.On_Return=null,e._events.next(n({ok:!0===i,error:!0===i?null:i},t)),e.printDo())}}},e.prototype.print=function(e,t,o){var r;this.check(),t&&(r=this.printBuffer).push.apply(r,function(){for(var e=[],t=0;t<arguments.length;t++)e=e.concat(i(arguments[t]));return e}((Array.isArray(t)?t:[t]).map((function(t){return{code:e,parser:o,item:t}})))),this.printDo()},e.prototype.ngOnDestroy=function(){this._init.unsubscribe(),this._events.unsubscribe()},e.decorators=[{type:t.Injectable,args:[{providedIn:"root"}]}],e.ctorParameters=function(){return[{type:c},{type:o.LazyService}]},e.ɵprov=t.ɵɵdefineInjectable({factory:function(){return new e(t.ɵɵinject(c),t.ɵɵinject(o.LazyService))},token:e,providedIn:"root"}),e}();var l=function(){function e(){}return e.decorators=[{type:t.NgModule,args:[{imports:[o.LxlibUtilModule]}]}],e}();e.LodopConfig=c,e.LodopModule=l,e.LodopService=u,Object.defineProperty(e,"__esModule",{value:!0})}));
//# sourceMappingURL=lodop.umd.min.js.map