@aurigma/ui-framework
Version:
A platform which allows building print product personalization editors based on Aurigma's Customer's Canvas.
1 lines • 12.6 kB
JavaScript
(window.multistep_editor_jsonpFunction=window.multistep_editor_jsonpFunction||[]).push([[44],{541:function(e,t,n){n.d(t,"a",function(){return i});var r,t=n(26),n=n(127),i=(r=n.a,Object(t.a)(s,r),Object.defineProperty(s.prototype,"value",{get:function(){return this.getValue()},enumerable:!1,configurable:!0}),s.prototype._subscribe=function(e){var t=r.prototype._subscribe.call(this,e);return t.closed||e.next(this._value),t},s.prototype.getValue=function(){var e=this,t=e.hasError,n=e._value;if(t)throw e.thrownError;return this._throwIfClosed(),n},s.prototype.next=function(e){r.prototype.next.call(this,this._value=e)},s);function s(e){var t=r.call(this)||this;return t._value=e,t}},866:function(e,t){e.exports='<style>\n :host {\n width: 100%;\n height: 100%;\n }\n</style>\n\n<iframe id="frameID" width="100%" height="100%" style="border: none;" onload="{{_initIFrame}}"></iframe>\n\n'},939:function(e,t,n){n.r(t),n.d(t,"AuWidgetPreflight",function(){return c}),n.d(t,"widget",function(){return c});var r,d=n(0),t=n(2),i=n(160),s=function(e,t){this.errors=e,this.warnings=t},a=n(14),p=n(1),o=n(541),n=n(866),c=(r=i.c,Object(d.d)(l,r),l.prototype.languageObserver=function(e){r.prototype.languageObserver.call(this,e),this._element&&this._element.setLanguage(e)},l.prototype.updateParams=function(e,t){e.onPageChange&&(this.onPageChange=p.a.functionWrapperConstructor(e.onPageChange)),e.onError&&(this.onError=p.a.functionWrapperConstructor(e.onError))},Object.defineProperty(l.prototype,"pages",{get:function(){return this._element?this._element.pages:0},enumerable:!1,configurable:!0}),l.prototype.updateParamsAsync=function(s,t){return Object(d.b)(this,void 0,void 0,function(){var i=this;return Object(d.e)(this,function(e){switch(e.label){case 0:return[4,r.prototype.updateParamsAsync.call(this,s,t)];case 1:return e.sent(),this._lastUpdateParamsFunc.next(function(){var e=i.driver.backOffice,t=e.tenantId,e=e.token,n=p.a.removeTrailingSlash(null==(n=i.driver.backOffice)?void 0:n.designAtomsApiUrl),r=p.a.removeTrailingSlash(null==(r=i.driver.backOffice)?void 0:r.designAtomsApiUrl);i._element.configuration=Object.assign({language:i.language,services:{designAtoms:{url:n,token:e},assetStorage:{url:r,token:e},tenantId:t}},s.config),i._element.files=s.files,i.updatePreflightStyles()}),[4,this._itemPromise()];case 2:return e.sent(),[2]}})})},l.prototype.setStep=function(t){return Object(d.b)(this,void 0,void 0,function(){return Object(d.e)(this,function(e){switch(e.label){case 0:return[4,this._itemInitedPromise()];case 1:return e.sent().setStep(t),this.emitChange(),[2]}})})},l.prototype.setFiles=function(t){return Object(d.b)(this,void 0,void 0,function(){return Object(d.e)(this,function(e){switch(e.label){case 0:return[4,this._itemInitedPromise()];case 1:return e.sent().files=t,[2]}})})},l.prototype.getResults=function(){return Object(d.b)(this,void 0,void 0,function(){var t;return Object(d.e)(this,function(e){switch(e.label){case 0:return[4,this._itemInitedPromise()];case 1:return[4,e.sent().finish()];case 2:return t=e.sent(),this.hires=t.hires,this.previews=t.previews,this.origins=t.origins,this.preview=t.previews.map(function(e){return e.url}),this.stateId=t.stateId,this.emitChange(),[2,t]}})})},l.prototype._itemPromise=function(){var t=this;return new Promise(function(n,e){var r;t._element?n(t._element):(r=function(){setTimeout(function(){return Object(d.b)(t,void 0,void 0,function(){var t;return Object(d.e)(this,function(e){switch(e.label){case 0:return this._iframeDoc?(t=this._iframeDoc.querySelector("au-preflight-tool"))?(this._element=t,window.Aurigma=Object.assign(window.Aurigma,this._iframeWin.Aurigma),[4,this._getLocales(t)]):[3,3]:[3,3];case 1:return e.sent(),[4,this._initSubscribers(this._element)];case 2:e.sent(),this.showPreloader(!1),this._lastUpdateParamsFunc.value&&this._lastUpdateParamsFunc.value(),n(t),e.label=3;case 3:return this._element||r(),[2]}})})},200)})()})},l.prototype._itemInitedPromise=function(){var t=this;return new Promise(function(n,e){return Object(d.b)(t,void 0,void 0,function(){var t;return Object(d.e)(this,function(e){switch(e.label){case 0:return[4,this._itemPromise()];case 1:return(t=e.sent()).isInited&&n(t),t.addEventListener("inited",function(e){n(t)}),[2]}})})})},l.prototype._initSubscribers=function(n){return Object(d.b)(this,void 0,void 0,function(){var t=this;return Object(d.e)(this,function(e){return this._eventsInited||(this._eventsInited=!0,n.addEventListener("hasFiles",function(e){t.hasFiles=e.detail,t.emitChange()}),n.addEventListener("hasEmptyPages",function(e){t.hasEmptyPages=e.detail,t.emitChange()}),n.addEventListener("failedChecks",function(e){t.failedChecks=e.detail,t.emitChange()}),n.addEventListener("stepChanged",function(e){t.page=e.detail,t.emitChange(),t.onPageChange&&t.onPageChange(t.page),p.a.setTimeoutWrapper(function(){t.onPageChange&&(t.emitChange(),t.onPageChange(t.page))},100,5)}),n.addEventListener("error",function(e){t.onError&&t.onError(e.detail)})),[2]})})},l.prototype._getLocales=function(u){var h;return Object(d.b)(this,void 0,void 0,function(){var t,n,r,i,s,a,o,c,l;return Object(d.e)(this,function(e){switch(e.label){case 0:if(this.__isLocalesInited)return[2];if(t=null==(h=null==(h=this.driver)?void 0:h.localization)?void 0:h.find(function(e){return"preflight"===e.app}),n={},!t||"string"!=typeof t.url||""===t.url)return[3,6];e.label=1;case 1:return e.trys.push([1,3,,5]),[4,p.a.loadJson(t.url+"?ts="+Date.now())];case 2:return n=e.sent(),[3,5];case 3:return r=e.sent(),console.error(r),[4,this._getPreflightLocalesFile()];case 4:return n=e.sent(),[3,5];case 5:return[3,8];case 6:return[4,this._getPreflightLocalesFile()];case 7:n=e.sent(),r=t&&"object"==typeof t.data,o=t&&0!==Object.keys(t.data).length,t&&r&&o&&(n=-1!==Object.keys(t.data).indexOf(this.language)?p.a.DeepMerge(n,t.data):p.a.DeepMerge(n,((o={})[this.language]=t.data,o))),e.label=8;case 8:if(u){try{for(i=Object(d.k)(Object.keys(n)),s=i.next();!s.done;s=i.next())a=s.value,u.addLocalization(a,n[a],!1)}catch(e){c={error:e}}finally{try{s&&!s.done&&(l=i.return)&&l.call(i)}finally{if(c)throw c.error}}u.setLanguage(this.language)}return this.__isLocalesInited=!0,[2]}})})},l.prototype.updatePreflightStyles=function(){var n=this;this.params.style&&Object.keys(this.params.style).forEach(function(e){var t=n._computeValue(n.params.style[e]);n._iframeDoc.documentElement.style.setProperty(e,t)})},l.prototype._initIFrame=function(){return Object(d.b)(this,void 0,void 0,function(){var t,n,r,i,s,a,o,c,l,u;return Object(d.e)(this,function(e){switch(e.label){case 0:this.showPreloader(!0),this.driver.config,n=this.querySelectorShadow("#frameID"),t=n.contentWindow||n,n=n.contentDocument||t.document,o=p.a.getDocumentCustomStyles(),r="<style> html {";try{for(i=Object(d.k)(Object.entries(o)),s=i.next();!s.done;s=i.next())a=s.value,r+=a[0]+":"+a[1]+";"}catch(e){l={error:e}}finally{try{s&&!s.done&&(u=i.return)&&u.call(i)}finally{if(l)throw l.error}}return r+="}</style>",[4,this._getPreflightDistFiles()];case 1:return o=e.sent(),n.write(o.script),n.write(o.styles),n.write(o.customStyles),n.write(r),n.write('<div class="iconset" style="display:none;">'.concat(document.querySelector('[name="custom-icons"]').innerHTML,"</div>")),this._replacePreloader(n),c=document.querySelector("iron-iconset-svg[name='custom-icons']")._icons.preloader,c=c.getAttribute("viewBox"),n.write('<script> window.AuPreloaderSize = "'.concat(c,'"; <\/script>')),n.write('\n <script>\n document.addEventListener("DOMContentLoaded", () => {\n const svgs = Array.from(document.querySelectorAll("div.icon-preflight-logo svg"));\n svgs.forEach(svg => svg.setAttribute("viewBox", "'.concat(c,'"));\n });\n <\/script>')),n.write('<au-preflight-tool id="preflight"></au-preflight-tool>'),this._iframeDoc=n,this._iframeWin=t,[2]}})})},l.prototype._replacePreloader=function(e){var t;null!=(t=this.driver.config.icons)&&t.preloader&&((e=(t=e.getElementById("preloader")).parentNode).removeChild(t),(t=(new DOMParser).parseFromString(this.driver.config.icons.preloader,"image/svg+xml").children.item(0)).id="preloader",e.appendChild(t))},l.prototype._getPreflightLocalesFile=function(){return Object(d.b)(this,void 0,void 0,function(){var t,n,r;return Object(d.e)(this,function(e){switch(e.label){case 0:t=p.a.ensureEndsWith(this._getBackendUrl(),"/"),t=t+"static/locales.json?t="+Date.now(),n={},e.label=1;case 1:return e.trys.push([1,3,,5]),[4,p.a.loadJson(t)];case 2:return n=e.sent(),[3,5];case 3:return e.sent(),console.warn("Failed to load locales from Preflight Backend: ".concat(t)),[4,p.a.loadJson("static/preflight/locales.json?t="+Date.now())];case 4:return[2,e.sent()];case 5:return[4,p.a.loadJson("static/preflight/locales.json?t="+Date.now())];case 6:return r=e.sent(),[2,p.a.DeepMerge(n,r)]}})})},l.prototype._getPreflightDistFiles=function(){return Object(d.b)(this,void 0,void 0,function(){var t,n,r,i,s,a;return Object(d.e)(this,function(e){switch(e.label){case 0:r=p.a.ensureEndsWith(this._getBackendUrl(),"/"),t=r+"static/script.html?t="+Date.now(),n=r+"static/style.html?t="+Date.now(),r=r+"static/customStyles.html?t="+Date.now(),a=s=i="",e.label=1;case 1:return e.trys.push([1,9,,13]),[4,p.a.loadHtml(n)];case 2:return i=e.sent(),[4,p.a.loadHtml(t)];case 3:a=e.sent(),e.label=4;case 4:return e.trys.push([4,6,,8]),[4,p.a.loadHtml(r)];case 5:return s=e.sent(),[3,8];case 6:return e.sent(),[4,p.a.loadHtml("static/preflight/customStyles.html?t="+Date.now())];case 7:return s=e.sent(),[3,8];case 8:return[3,13];case 9:return e.sent(),console.warn("Failed to load Preflight scripts from backend ".concat(t)),[4,p.a.loadHtml(p.a.getPatchedUrl("static/preflight/style.html?t="+Date.now()))];case 10:return i=e.sent(),[4,p.a.loadHtml(p.a.getPatchedUrl("static/preflight/customStyles.html?t="+Date.now()))];case 11:return s=e.sent(),[4,p.a.loadHtml(p.a.getPatchedUrl("static/preflight/script.html?t="+Date.now()))];case 12:return a=e.sent(),[3,13];case 13:return[2,{script:a,styles:i,customStyles:s}]}})})},l.prototype._getBackendUrl=function(){var e,t=this.paramsRaw;return(void 0!==t.config.backendUrl&&-1===t.config.backendUrl.indexOf("{{")?t:((e=this.jsonParamsFetcher.scope).self=this,t[a.a.SCOPE_HEAD_KEY]=this.jsonParamsFetcher.head,this._jsonProcessor.process(t,e))).config.backendUrl},l.prototype.exportWidgetData=function(n){return Object(d.b)(this,void 0,void 0,function(){var t;return Object(d.e)(this,function(e){switch(e.label){case 0:return n?[4,this.getResults()]:[3,2];case 1:t=e.sent(),this.stateId=t.stateId,e.label=2;case 2:return[2,{stateId:this.stateId,page:this.page}]}})})},l.prototype.restoreWidgetFromData=function(n,e){return Object(d.b)(this,void 0,void 0,function(){var t;return Object(d.e)(this,function(e){switch(e.label){case 0:return(this._isRestoring=!0,this.stateId=n.stateId,"firefox"!==p.a.getBrowser())?[3,1]:(this._itemInitedPromise().then(function(e){e.setState(n.stateId).then(function(){n.page&&e.setStep(n.page)})}),[3,4]);case 1:return[4,this._itemInitedPromise()];case 2:return[4,(t=e.sent()).setState(n.stateId)];case 3:e.sent(),n.page&&t.setStep(n.page),e.label=4;case 4:return this._isRestoring=!1,[2]}})})},Object(d.c)([Object(t.c)(),Object(d.g)("design:type",Boolean)],l.prototype,"hasFiles",void 0),Object(d.c)([Object(t.c)(),Object(d.g)("design:type",Boolean)],l.prototype,"hasEmptyPages",void 0),Object(d.c)([Object(t.c)(),Object(d.g)("design:type",Array)],l.prototype,"hires",void 0),Object(d.c)([Object(t.c)(),Object(d.g)("design:type",Array)],l.prototype,"preview",void 0),Object(d.c)([Object(t.c)(),Object(d.g)("design:type",Array)],l.prototype,"previews",void 0),Object(d.c)([Object(t.c)(),Object(d.g)("design:type",Array)],l.prototype,"origins",void 0),Object(d.c)([Object(t.c)(),Object(d.g)("design:type",String)],l.prototype,"page",void 0),Object(d.c)([Object(t.c)(),Object(d.g)("design:type",s)],l.prototype,"failedChecks",void 0),Object(d.c)([Object(t.c)(),Object(d.g)("design:type",String)],l.prototype,"stateId",void 0),Object(d.c)([Object(t.a)("au-widget-preflight",n),Object(d.g)("design:paramtypes",[])],l));function l(){var e,t=r.call(this)||this;return t._eventsInited=!1,t._lastUpdateParamsFunc=new o.a(null),t.hasFiles=!1,t.hasEmptyPages=!1,t.hires=[],t.preview=[],t.previews=[],t.origins=[],t.page="",t.failedChecks=new s([],[]),t.stateId="",t.onPageChange=null,t.onError=null,t.__isLocalesInited=!1,t._initIFrame=t._initIFrame.bind(t),null!=(e=t._lastUpdateParamsFunc)&&e.asObservable().subscribe(function(e){t._element&&e()}),t}}}]);