From b8e1c89f8a40643ae6992fba46b3118f09cb3c82 Mon Sep 17 00:00:00 2001 From: Lukas Bestle Date: Sat, 12 Nov 2022 17:42:32 +0100 Subject: [PATCH] Update version number and dist files --- assets/configurator.js | 6 ++-- composer.json | 2 +- composer.lock | 62 +++++++++++++++++++++--------------------- 3 files changed, 35 insertions(+), 35 deletions(-) diff --git a/assets/configurator.js b/assets/configurator.js index df45012..9070e71 100644 --- a/assets/configurator.js +++ b/assets/configurator.js @@ -1,11 +1,11 @@ -var m=(t,e,s)=>new Promise((r,i)=>{var o=c=>{try{a(s.next(c))}catch(l){i(l)}},n=c=>{try{a(s.throw(c))}catch(l){i(l)}},a=c=>c.done?r(c.value):Promise.resolve(c.value).then(o,n);a((s=s.apply(t,e)).next())});var y=class{constructor(e,s,r,i){this._outgoingMessageBus=null,this._execMessage=null,this._side=e,this._incomingMessageBus=s,this._outgoingMessageBus=r,this._execMessage=i,this._incomingMessageBus.addEventListener("message",this._handleMessage.bind(this))}setOutgoingMessageBus(e){this._outgoingMessageBus=e}setMessageExecution(e){this._execMessage=e}sendMessage(e,s=[]){return new Promise((r,i)=>{let o=new MessageChannel;o.port1.onmessage=a=>{if(!a||!a.data)return o.port1.close(),o.port2.close(),i(new Error(this._side+" received message but response can not be interpreted"));let c;try{c=JSON.parse(a.data)}catch(l){return o.port1.close(),o.port2.close(),this._prepareError(l),i(l)}c.error?i(c.error):c.result!==void 0?r(c.result):r(),o.port1.close(),o.port2.close()};let n="";try{n=JSON.stringify({message:e,args:s})}catch(a){return i(new Error(this._side+": can not create command because it is not JSON.stringify able"))}if(!this._outgoingMessageBus)return i(new Error(this._side+": outgoing bus not set yet"));this._outgoingMessageBus.postMessage(n,"*",[o.port2])})}_handleMessage(e){let s=e.ports&&Array.isArray(e.ports)&&e.ports.length>0?e.ports[0]:null;if(e.data&&s)try{let r=JSON.parse(e.data);if(!this._execMessage)return s.postMessage(JSON.stringify({error:this._side+" is not ready to handle messages"}));Array.isArray(r.args)||(r.args=[r.args]);let i=this._execMessage(r,e);if(i===void 0)return;i.then((o={})=>{let n,a;typeof o=="object"&&o!==null&&(n=o.error,a=o.result),n?s.postMessage(JSON.stringify({error:n})):a!==void 0?s.postMessage(JSON.stringify({result:a})):s.postMessage(JSON.stringify({result:o}))},o=>{s.postMessage(JSON.stringify({error:this._prepareError(o)}))})}catch(r){s.postMessage(JSON.stringify({error:this._prepareError(r)}))}}_prepareError(e){if(typeof e=="string"){let s=this._side+": "+e;return console.error(s),s}return e.message=this._side+": "+e.message,console.error(e),e.message}},w=".",I={REQUEST_BOOT:"requestBoot",SETUP:"setup",WEBSITE_READY:"websiteReady"},C=(t,e)=>m(void 0,null,function*(){if(typeof t!="string")throw new Error('Configurator ID is not a string type: "'+typeof t+'"');let s=e.customApiUrl?e.customApiUrl:"https://api.roomle.com/v2",r=e.overrideTenant||9,i=s+"/configurators/"+t,o="roomle_portal_v2",n="03-"+window.btoa(new Date().toISOString()+";anonymous;"+o),a=()=>{let h={apiKey:o,currentTenant:r,locale:"en",language:"en",device:1,token:n,platform:"web"};return new Headers(h)},c=new Request(i,{method:"GET",headers:a(),mode:"cors",cache:"default"}),l=yield fetch(c),{configurator:g}=yield l.json();return g}),U=()=>{try{return window.self!==window.top}catch(t){return!0}},D=["127.0.0.1","localhost","0.0.0.0"],F=()=>{let t=U(),e=window.location.href;if(t){if(!document.referrer)return null;e=document.referrer}let{hostname:s}=new URL(e);return s},H=t=>!!(D.includes(t)||t.endsWith("roomle.com")||t.endsWith("gitlab.io")||t.endsWith("gitlab.com")),k=(t,e)=>{let s=JSON.parse(JSON.stringify(t));return b(s,e)},b=(t,e)=>{for(let s in e)try{e[s].constructor===Object?t[s]=b(t[s],e[s]):t[s]=e[s]}catch(r){t[s]=e[s]}return t},A=["language","browserLanguage","userLanguage","systemLanguage"],B=(t=null)=>{let e=window.navigator;if(t)return t.substr(0,2);if(Array.isArray(e.languages)&&e.languages.length>0)return e.languages[0].substr(0,2);for(let s=0,r=A.length;s(O(t),t!=null&&t.customApiUrl&&(t.customApiUrl=decodeURIComponent(t.customApiUrl)),t.shareUrl&&(t.deeplink=t.shareUrl.replace(G,$)),t),O=t=>{if(!t)return;let e=Object.keys(t);for(let s of e){let r=t[s];if(!Array.isArray(r)&&typeof r=="object"&&r!==null)return O(r);if(Array.isArray(r)){for(let i of r)O(i);return}(r==="true"||r==="false")&&(t[s]=r==="true")}},J=(t,e)=>{e.configuratorId=t.id;let s=t.settings||{};return!e.overrideTenant&&t.tenant&&(e.overrideTenant=t.tenant),k(s,e)},V=()=>{let t={};t.locale||(t.locale=B()),t.id===x&&delete t.id;let e=F();return e&&H(e)&&(t.configuratorId="demoConfigurator"),t.customApiUrl="https://www.roomle.com/api/v2",t.emails=!1,t},G="",$="#CONFIGURATIONID#",v=()=>/(android)/i.test(navigator.userAgent),R=(t,e,s)=>{let r=null;Object.defineProperty(t,e,{get(){return r||s},set(i){i!=null&&i.mute?r=i.value:(console.warn("You override Roomle defined behaviour. To disalbe this warning pass in an object with the following properties"),console.warn("{ mute: true, value: () => void }"),r=i)}})},N=()=>window.innerHeight*.01+"px",L=t=>{!t||setTimeout(()=>t.style.setProperty(S,N()),0)},T="rml-styles",q=450,S="--rml-full-height",u={CONTAINER:"rml-container",FILL:"rml-fill",POSITION:"rml-pos",TRANSITION:"rml-transition",ANDROID_HEIGHT:"rml-android-height",OVERFLOW_HIDDEN:"rml-overflow-hidden"},E=new Map,_=class{constructor(e,s,r,i){if(this.ui={callbacks:null},this.extended={callbacks:null},this.analytics={callbacks:{}},this.global={callbacks:{}},this._initData={},!e||typeof e.id!="string")throw new Error("Please provide a correct configuratorId, you get the correct ID from your Roomle Contact Person");if(E.has(s))throw new Error("There is already an instance on this DOM element");if(!!!document.getElementById(T)){let a=r.zIndex||9999999,c=document.createElement("style");c.type="text/css",c.id=T;let l="transition:all ease-in-out "+q+"ms;",g=["-webkit-","-o-"].reduce((f,d)=>f+=d+l,"")+l,h=N();c.innerHTML=` +var g=(t,e,s)=>new Promise((r,i)=>{var o=c=>{try{a(s.next(c))}catch(l){i(l)}},n=c=>{try{a(s.throw(c))}catch(l){i(l)}},a=c=>c.done?r(c.value):Promise.resolve(c.value).then(o,n);a((s=s.apply(t,e)).next())});var y=class{constructor(e,s,r,i){this._outgoingMessageBus=null,this._execMessage=null,this._side=e,this._incomingMessageBus=s,this._outgoingMessageBus=r,this._execMessage=i,this._incomingMessageBus.addEventListener("message",this._handleMessage.bind(this))}setOutgoingMessageBus(e){this._outgoingMessageBus=e}setMessageExecution(e){this._execMessage=e}sendMessage(e,s=[]){return new Promise((r,i)=>{let o=new MessageChannel;o.port1.onmessage=a=>{if(!a||!a.data)return o.port1.close(),o.port2.close(),i(new Error(this._side+" received message but response can not be interpreted"));let c;try{c=JSON.parse(a.data)}catch(l){return o.port1.close(),o.port2.close(),this._prepareError(l),i(l)}c.error?i(c.error):c.result!==void 0?r(c.result):r(),o.port1.close(),o.port2.close()};let n="";try{n=JSON.stringify({message:e,args:s})}catch(a){return i(new Error(this._side+": can not create command because it is not JSON.stringify able"))}if(!this._outgoingMessageBus)return i(new Error(this._side+": outgoing bus not set yet"));this._outgoingMessageBus.postMessage(n,"*",[o.port2])})}_handleMessage(e){let s=e.ports&&Array.isArray(e.ports)&&e.ports.length>0?e.ports[0]:null;if(e.data&&s)try{let r=JSON.parse(e.data);if(!this._execMessage)return s.postMessage(JSON.stringify({error:this._side+" is not ready to handle messages"}));Array.isArray(r.args)||(r.args=[r.args]);let i=this._execMessage(r,e);if(i===void 0)return;i.then((o={})=>{let n,a;typeof o=="object"&&o!==null&&(n=o.error,a=o.result),n?s.postMessage(JSON.stringify({error:n})):a!==void 0?s.postMessage(JSON.stringify({result:a})):s.postMessage(JSON.stringify({result:o}))},o=>{s.postMessage(JSON.stringify({error:this._prepareError(o)}))})}catch(r){s.postMessage(JSON.stringify({error:this._prepareError(r)}))}}_prepareError(e){if(typeof e=="string"){let s=this._side+": "+e;return console.error(s),s}return e.message=this._side+": "+e.message,console.error(e),e.message}},I=".",E={REQUEST_BOOT:"requestBoot",SETUP:"setup",WEBSITE_READY:"websiteReady"},C=(t,e)=>g(void 0,null,function*(){if(typeof t!="string")throw new Error('Configurator ID is not a string type: "'+typeof t+'"');let s=e.customApiUrl?e.customApiUrl:"https://api.roomle.com/v2",r=e.overrideTenant||9,i=s+"/configurators/"+t,o="roomle_portal_v2",n="03-"+window.btoa(new Date().toISOString()+";anonymous;"+o),a=()=>{let h={apiKey:o,currentTenant:r,locale:"en",language:"en",device:1,token:n,platform:"web"};return new Headers(h)},c=new Request(i,{method:"GET",headers:a(),mode:"cors",cache:"default"}),l=yield fetch(c),{configurator:m}=yield l.json();return m}),U=()=>{try{return window.self!==window.top}catch(t){return!0}},D=["127.0.0.1","localhost","0.0.0.0"],H=()=>{let t=U(),e=window.location.href;if(t){if(!document.referrer)return null;e=document.referrer}let{hostname:s}=new URL(e);return s},F=t=>!!(D.includes(t)||t.endsWith("roomle.com")||t.endsWith("gitlab.io")||t.endsWith("gitlab.com")),k=(t,e)=>{let s=JSON.parse(JSON.stringify(t));return A(s,e)},A=(t,e)=>{for(let s in e)try{e[s].constructor===Object?t[s]=A(t[s],e[s]):t[s]=e[s]}catch(r){t[s]=e[s]}return t},b=["language","browserLanguage","userLanguage","systemLanguage"],B=(t=null)=>{let e=window.navigator;if(t)return t.substr(0,2);if(Array.isArray(e.languages)&&e.languages.length>0)return e.languages[0].substr(0,2);for(let s=0,r=b.length;s(O(t),t!=null&&t.customApiUrl&&(t.customApiUrl=decodeURIComponent(t.customApiUrl)),t.shareUrl&&(t.deeplink=t.shareUrl.replace(V,$)),t),O=t=>{if(!t)return;let e=Object.keys(t);for(let s of e){let r=t[s];if(!Array.isArray(r)&&typeof r=="object"&&r!==null)return O(r);if(Array.isArray(r)){for(let i of r)O(i);return}(r==="true"||r==="false")&&(t[s]=r==="true")}},G=(t,e)=>{e.configuratorId=t.id;let s=t.settings||{};return!e.overrideTenant&&t.tenant&&(e.overrideTenant=t.tenant),k(s,e)},J=()=>{let t={};t.locale||(t.locale=B()),t.id===x&&delete t.id;let e=H();return e&&F(e)&&(t.configuratorId="demoConfigurator"),t.customApiUrl="https://www.roomle.com/api/v2",t.emails=!1,t},V="",$="#CONFIGURATIONID#",R=()=>/(android)/i.test(navigator.userAgent),L=(t,e,s)=>{let r=null;Object.defineProperty(t,e,{get(){return r||s},set(i){i!=null&&i.mute?r=i.value:(console.warn("You override Roomle defined behaviour. To disalbe this warning pass in an object with the following properties"),console.warn("{ mute: true, value: () => void }"),r=i)}})},N=()=>window.innerHeight*.01+"px",v=t=>{!t||setTimeout(()=>t.style.setProperty(S,N()),0)},T="rml-styles",q=450,S="--rml-full-height",u={CONTAINER:"rml-container",FILL:"rml-fill",POSITION:"rml-pos",TRANSITION:"rml-transition",ANDROID_HEIGHT:"rml-android-height",OVERFLOW_HIDDEN:"rml-overflow-hidden"},w=new Map,_=class{constructor(e,s,r,i){if(this.ui={callbacks:null},this.extended={callbacks:null},this.analytics={callbacks:{}},this.global={callbacks:{}},this._initData={},!e||typeof e.id!="string")throw new Error("Please provide a correct configuratorId, you get the correct ID from your Roomle Contact Person");if(w.has(s))throw new Error("There is already an instance on this DOM element");if(!!!document.getElementById(T)){let a=r.zIndex||9999999,c=document.createElement("style");c.type="text/css",c.id=T;let l="transition:all ease-in-out "+q+"ms;",m=["-webkit-","-o-"].reduce((f,d)=>f+=d+l,"")+l,h=N();c.innerHTML=` .${u.CONTAINER}{${S}:${h};} .${u.POSITION}{position:fixed;top:0;left:0;z-index:${a};opacity:0} - .${u.TRANSITION}{${g}} + .${u.TRANSITION}{${m}} .${u.FILL}{width:100%;height:100%;opacity:1} .${u.ANDROID_HEIGHT}{height:calc(var(${S},1vh)*100)} .${u.OVERFLOW_HIDDEN}{overflow:hidden} - `,document.head.appendChild(c)}this._onResize=this._onResize.bind(this),v()&&window.addEventListener("resize",this._onResize),this._container=s,this._initData=r,this._configuratorSettings=e;let n=this._createIframe();this._onUseFullPage=this._onUseFullPage.bind(this),this._executeMessage=this._executeMessage.bind(this),this._onBackToWebsite=this._onBackToWebsite.bind(this),this._messageHandler=new y("website",window,null,this._executeMessage),this._waitForIframe=i,this._container.appendChild(n),this._iframe=n,E.set(s,!0)}static createPlanner(e,s,r){return this._create(e,s,r)}static createConfigurator(e,s,r){return this._create(e,s,r)}static create(e,s,r){return this._create(e,s,r)}static createViewer(e,s,r){return this._create(e,s,r)}static _create(e,s,r){return new Promise((i,o)=>m(this,null,function*(){try{let n=b(V(),W(r));n.featureFlags||(n.featureFlags={}),typeof n.featureFlags.realPartList!="boolean"&&(n.featureFlags.realPartList=!0),typeof n.featureFlags.globalCallbacks!="boolean"&&(n.featureFlags.globalCallbacks=!0);let a=yield C(e,n);return r=J(a,n),new this(a,s,r,i)}catch(n){return o(n)}}))}teardown(){this._container&&E.delete(this._container);let e=this._container.querySelector("iframe");e&&this._container.removeChild(e),window.removeEventListener("resize",this._onResize)}_createIframe(){var e;let s=document.createElement("iframe"),r=((e=this._configuratorSettings)===null||e===void 0?void 0:e.url)||"https://www.roomle.com/t/cp/";return this._initData.useLocalRoomle&&(r=location.href.replace("embedding.html","")),location.href.includes("roomle.gitlab.io")&&(r=location.href.replace("embedding.html","index.html")),this._initData.overrideServerUrl&&(r=this._initData.overrideServerUrl),s.src=r,s.classList.add(u.CONTAINER),s.classList.add(u.FILL),s}_onResize(){L(this._iframe)}_onUseFullPage(){this._iframe.classList.add(u.POSITION),document.documentElement.classList.add(u.OVERFLOW_HIDDEN),window.document.body.classList.add(u.OVERFLOW_HIDDEN),v()&&(L(this._iframe),this._iframe.classList.add(u.ANDROID_HEIGHT))}_onBackToWebsite(){this._iframe.classList.remove(u.POSITION),this._iframe.classList.remove(u.ANDROID_HEIGHT),document.documentElement.classList.remove(u.OVERFLOW_HIDDEN),window.document.body.classList.remove(u.OVERFLOW_HIDDEN)}_executeMessage({message:e,args:s},r){var i;if(!r.source||r.source!==((i=this._iframe)===null||i===void 0?void 0:i.contentWindow))return;if(e===I.REQUEST_BOOT)return this._messageHandler.setOutgoingMessageBus(r.source),Promise.resolve({result:this._initData});if(e===I.SETUP){let{methods:l,callbacks:g}=s[0];return l.forEach(h=>{let f=h.split(w),d=f[0],p=f[1];this[d]||(this[d]={}),this[d][p]=function(){return this._messageHandler.sendMessage(h,[...arguments])}.bind(this)}),g.forEach(h=>{let f=h.split(w),d=f[0],p=f[1],P=f[2];this[d]||(this[d]={}),this[d][p]||(this[d][p]={}),this[d][p][P]=()=>{}}),R(this.ui.callbacks,"onUseFullPage",this._onUseFullPage),R(this.ui.callbacks,"onBackToWebsite",this._onBackToWebsite),this._waitForIframe(this),setTimeout(()=>this._messageHandler.sendMessage(I.WEBSITE_READY),0),Promise.resolve({result:null})}let o=e.split(w),n=o[0],a=o[1],c=o.length===3?o[2]:null;if(c&&this[n][a][c]){let l=this[n][a][c](...s);return l instanceof Promise?l.then(g=>({result:g})):l!==void 0?Promise.resolve({result:l}):Promise.resolve({result:null})}return Promise.reject('Message "'+e+'" is unkown')}};var M=class{constructor(t){this.props=t,this.variantSelector="#"+t.htmlId+" .roomle-configurator-variants input",this.currentId=this.idFromUrl()||t.options.id}init(){return m(this,null,function*(){if(this.configurator)return;document.querySelectorAll(this.variantSelector).forEach(e=>{e.addEventListener("change",this.onVariantSelect.bind(this))}),window.addEventListener("popstate",this.onUrlChange.bind(this)),this.updateVariants(this.currentId);let t=this.props.options;t.id=this.currentId,this.configurator=yield _.createConfigurator(this.props.configuratorId,document.getElementById(this.props.htmlId+"-container"),t),this.currentId!==t.id&&this.load(this.currentId),this.props.targetUrl&&(this.configurator.ui.callbacks.onRequestProduct=this.onRequestProduct.bind(this))})}idFromUrl(){return new URLSearchParams(window.location.search).get(this.props.htmlId)}idToUrl(t,e=!1){let s=new URL(window.location.href);return s.searchParams.set(this.props.htmlId,t),e===!0&&(s.hash=this.props.htmlId),s}load(t){return m(this,null,function*(){return this.currentId=t,this.updateVariants(t),this.configurator?(yield this.configurator.ui.loadObject(t),!0):!1})}onRequestProduct(t,e,s,r,i,o){let n={catalog:o.catalog,configuratorUrl:this.idToUrl(t,!0),depth:o.depth,height:o.height,id:t,label:o.label,parts:s.fullList,perspectiveImage:o.perspectiveImage,rootComponentId:o.rootComponentId,topImage:o.topImage,width:o.width},a=document.createElement("form");a.action=this.props.targetUrl,a.method="POST",a.style.display="none";let c=document.createElement("input");c.name="roomle-configuration",c.value=JSON.stringify(n),a.appendChild(c),document.body.appendChild(a),a.submit()}onUrlChange(){let t=this.idFromUrl();t?this.load(t):this.load(this.props.options.id)}onVariantSelect(t){let e=this.idToUrl(t.target.value);window.history.pushState(null,"",e),this.load(t.target.value)}updateVariants(t){let e=document.querySelector(this.variantSelector+"[checked]"),s=document.querySelector(this.variantSelector+'[value="'+CSS.escape(t)+'"]');e&&(e.removeAttribute("checked"),e.checked=!1),s&&(s.checked=!0,s.setAttribute("checked","true"))}};export{M as default}; + `,document.head.appendChild(c)}this._onResize=this._onResize.bind(this),R()&&window.addEventListener("resize",this._onResize),this._container=s,this._initData=r,this._configuratorSettings=e;let n=this._createIframe();this._onUseFullPage=this._onUseFullPage.bind(this),this._executeMessage=this._executeMessage.bind(this),this._onBackToWebsite=this._onBackToWebsite.bind(this),this._messageHandler=new y("website",window,null,this._executeMessage),this._waitForIframe=i,this._container.appendChild(n),this._iframe=n,w.set(s,!0)}static createPlanner(e,s,r){return this._create(e,s,r)}static createConfigurator(e,s,r){return this._create(e,s,r)}static create(e,s,r){return this._create(e,s,r)}static createViewer(e,s,r){return this._create(e,s,r)}static _create(e,s,r){return new Promise((i,o)=>g(this,null,function*(){try{let n=A(J(),W(r));n.featureFlags||(n.featureFlags={}),typeof n.featureFlags.realPartList!="boolean"&&(n.featureFlags.realPartList=!0),typeof n.featureFlags.globalCallbacks!="boolean"&&(n.featureFlags.globalCallbacks=!0);let a=yield C(e,n);return r=G(a,n),new this(a,s,r,i)}catch(n){return o(n)}}))}teardown(){this._container&&w.delete(this._container);let e=this._container.querySelector("iframe");e&&this._container.removeChild(e),window.removeEventListener("resize",this._onResize)}_createIframe(){var e;let s=document.createElement("iframe"),r=((e=this._configuratorSettings)===null||e===void 0?void 0:e.url)||"https://www.roomle.com/t/cp/";return this._initData.useLocalRoomle&&(r=location.href.replace("embedding.html","")),location.href.includes("roomle.gitlab.io")&&(r=location.href.replace("embedding.html","index.html")),this._initData.overrideServerUrl&&(r=this._initData.overrideServerUrl),s.src=r,s.classList.add(u.CONTAINER),s.classList.add(u.FILL),s}_onResize(){v(this._iframe)}_onUseFullPage(){this._iframe.classList.add(u.POSITION),document.documentElement.classList.add(u.OVERFLOW_HIDDEN),window.document.body.classList.add(u.OVERFLOW_HIDDEN),R()&&(v(this._iframe),this._iframe.classList.add(u.ANDROID_HEIGHT))}_onBackToWebsite(){this._iframe.classList.remove(u.POSITION),this._iframe.classList.remove(u.ANDROID_HEIGHT),document.documentElement.classList.remove(u.OVERFLOW_HIDDEN),window.document.body.classList.remove(u.OVERFLOW_HIDDEN)}_executeMessage({message:e,args:s},r){var i;if(!r.source||r.source!==((i=this._iframe)===null||i===void 0?void 0:i.contentWindow))return;if(e===E.REQUEST_BOOT)return this._messageHandler.setOutgoingMessageBus(r.source),Promise.resolve({result:this._initData});if(e===E.SETUP){let{methods:l,callbacks:m}=s[0];return l.forEach(h=>{let f=h.split(I),d=f[0],p=f[1];this[d]||(this[d]={}),this[d][p]=function(){return this._messageHandler.sendMessage(h,[...arguments])}.bind(this)}),m.forEach(h=>{let f=h.split(I),d=f[0],p=f[1],P=f[2];this[d]||(this[d]={}),this[d][p]||(this[d][p]={}),this[d][p][P]=()=>{}}),L(this.ui.callbacks,"onUseFullPage",this._onUseFullPage),L(this.ui.callbacks,"onBackToWebsite",this._onBackToWebsite),this._waitForIframe(this),setTimeout(()=>this._messageHandler.sendMessage(E.WEBSITE_READY),0),Promise.resolve({result:null})}let o=e.split(I),n=o[0],a=o[1],c=o.length===3?o[2]:null;if(c&&this[n][a][c]){let l=this[n][a][c](...s);return l instanceof Promise?l.then(m=>({result:m})):l!==void 0?Promise.resolve({result:l}):Promise.resolve({result:null})}return Promise.reject('Message "'+e+'" is unkown')}};var M=class{constructor(t){this.props=t,this.variantSelector="#"+t.htmlId+" .roomle-configurator-variants input",this.currentId=this.idFromUrl()||t.options.id}init(){return g(this,null,function*(){if(this.configurator)return;document.querySelectorAll(this.variantSelector).forEach(e=>{e.addEventListener("change",this.onVariantSelect.bind(this))}),window.addEventListener("popstate",this.onUrlChange.bind(this)),this.updateVariants(this.currentId);let t=this.props.options;t.id=this.currentId,t.deeplink=this.idToUrl(this.props.htmlId+"-PLACEHOLDER",!0).href.replace(this.props.htmlId+"-PLACEHOLDER","#CONFIGURATIONID#"),this.configurator=yield _.createConfigurator(this.props.configuratorId,document.getElementById(this.props.htmlId+"-container"),t),this.currentId!==t.id&&this.load(this.currentId),this.props.targetUrl&&(this.configurator.ui.callbacks.onRequestProduct=this.onRequestProduct.bind(this))})}idFromUrl(){return new URLSearchParams(window.location.search).get(this.props.htmlId)}idToUrl(t,e=!1){let s=new URL(window.location.href);return s.searchParams.set(this.props.htmlId,t),e===!0&&(s.hash=this.props.htmlId),s}load(t){return g(this,null,function*(){return this.currentId=t,this.updateVariants(t),this.configurator?(yield this.configurator.ui.loadObject(t),!0):!1})}onRequestProduct(t,e,s,r,i,o){let n={catalog:o.catalog,configuratorUrl:this.idToUrl(t,!0),depth:o.depth,height:o.height,id:t,label:o.label,parts:s.fullList,perspectiveImage:o.perspectiveImage,rootComponentId:o.rootComponentId,topImage:o.topImage,width:o.width},a=document.createElement("form");a.action=this.props.targetUrl,a.method="POST",a.style.display="none";let c=document.createElement("input");c.name="roomle-configuration",c.value=JSON.stringify(n),a.appendChild(c),document.body.appendChild(a),a.submit()}onUrlChange(){let t=this.idFromUrl();t?this.load(t):this.load(this.props.options.id)}onVariantSelect(t){let e=this.idToUrl(t.target.value);window.history.pushState(null,"",e),this.load(t.target.value)}updateVariants(t){let e=document.querySelector(this.variantSelector+"[checked]"),s=document.querySelector(this.variantSelector+'[value="'+CSS.escape(t)+'"]');e&&(e.removeAttribute("checked"),e.checked=!1),s&&(s.checked=!0,s.setAttribute("checked","true"))}};export{M as default}; /** * Configurator * diff --git a/composer.json b/composer.json index b1c89e8..f5cb77e 100644 --- a/composer.json +++ b/composer.json @@ -3,7 +3,7 @@ "description": "Roomle Plugin for Kirby 3", "license": "MIT", "type": "kirby-plugin", - "version": "1.0.1", + "version": "1.0.2", "authors": [ { "name": "Lukas Bestle", diff --git a/composer.lock b/composer.lock index d7d2478..690eb77 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "4f42801935a8f6011a7f73f443b8b13a", + "content-hash": "645836ec94d7570404b2a347a152eeb8", "packages": [ { "name": "claviska/simpleimage", @@ -209,16 +209,16 @@ }, { "name": "getkirby/cms", - "version": "3.8.0-rc.2", + "version": "3.8.2-rc.1", "source": { "type": "git", "url": "https://github.com/getkirby/kirby.git", - "reference": "cfdba1b81fc68d5bdf6561fc47858f6c966100d3" + "reference": "c8f05fff4d32ce5a2a2a15e18b80ca763cc27dc4" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/getkirby/kirby/zipball/cfdba1b81fc68d5bdf6561fc47858f6c966100d3", - "reference": "cfdba1b81fc68d5bdf6561fc47858f6c966100d3", + "url": "https://api.github.com/repos/getkirby/kirby/zipball/c8f05fff4d32ce5a2a2a15e18b80ca763cc27dc4", + "reference": "c8f05fff4d32ce5a2a2a15e18b80ca763cc27dc4", "shasum": "" }, "require": { @@ -237,10 +237,10 @@ "ext-simplexml": "*", "filp/whoops": "2.14.5", "getkirby/composer-installer": "^1.2.1", - "laminas/laminas-escaper": "2.10.0", + "laminas/laminas-escaper": "2.12.0", "michelf/php-smartypants": "1.8.1", "php": ">=8.0.0 <8.2.0", - "phpmailer/phpmailer": "6.6.4", + "phpmailer/phpmailer": "6.6.5", "symfony/polyfill-intl-idn": "1.26.0", "symfony/polyfill-mbstring": "1.26.0" }, @@ -305,7 +305,7 @@ "type": "custom" } ], - "time": "2022-09-29T08:46:04+00:00" + "time": "2022-11-08T10:07:46+00:00" }, { "name": "getkirby/composer-installer", @@ -356,32 +356,32 @@ }, { "name": "laminas/laminas-escaper", - "version": "2.10.0", + "version": "2.12.0", "source": { "type": "git", "url": "https://github.com/laminas/laminas-escaper.git", - "reference": "58af67282db37d24e584a837a94ee55b9c7552be" + "reference": "ee7a4c37bf3d0e8c03635d5bddb5bb3184ead490" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/laminas/laminas-escaper/zipball/58af67282db37d24e584a837a94ee55b9c7552be", - "reference": "58af67282db37d24e584a837a94ee55b9c7552be", + "url": "https://api.github.com/repos/laminas/laminas-escaper/zipball/ee7a4c37bf3d0e8c03635d5bddb5bb3184ead490", + "reference": "ee7a4c37bf3d0e8c03635d5bddb5bb3184ead490", "shasum": "" }, "require": { "ext-ctype": "*", "ext-mbstring": "*", - "php": "^7.4 || ~8.0.0 || ~8.1.0" + "php": "^7.4 || ~8.0.0 || ~8.1.0 || ~8.2.0" }, "conflict": { "zendframework/zend-escaper": "*" }, "require-dev": { "infection/infection": "^0.26.6", - "laminas/laminas-coding-standard": "~2.3.0", + "laminas/laminas-coding-standard": "~2.4.0", "maglnet/composer-require-checker": "^3.8.0", "phpunit/phpunit": "^9.5.18", - "psalm/plugin-phpunit": "^0.16.1", + "psalm/plugin-phpunit": "^0.17.0", "vimeo/psalm": "^4.22.0" }, "type": "library", @@ -414,7 +414,7 @@ "type": "community_bridge" } ], - "time": "2022-03-08T20:15:36+00:00" + "time": "2022-10-10T10:11:09+00:00" }, { "name": "league/color-extractor", @@ -530,16 +530,16 @@ }, { "name": "phpmailer/phpmailer", - "version": "v6.6.4", + "version": "v6.6.5", "source": { "type": "git", "url": "https://github.com/PHPMailer/PHPMailer.git", - "reference": "a94fdebaea6bd17f51be0c2373ab80d3d681269b" + "reference": "8b6386d7417526d1ea4da9edb70b8352f7543627" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/PHPMailer/PHPMailer/zipball/a94fdebaea6bd17f51be0c2373ab80d3d681269b", - "reference": "a94fdebaea6bd17f51be0c2373ab80d3d681269b", + "url": "https://api.github.com/repos/PHPMailer/PHPMailer/zipball/8b6386d7417526d1ea4da9edb70b8352f7543627", + "reference": "8b6386d7417526d1ea4da9edb70b8352f7543627", "shasum": "" }, "require": { @@ -563,8 +563,8 @@ "hayageek/oauth2-yahoo": "Needed for Yahoo XOAUTH2 authentication", "league/oauth2-google": "Needed for Google XOAUTH2 authentication", "psr/log": "For optional PSR-3 debug logging", - "stevenmaguire/oauth2-microsoft": "Needed for Microsoft XOAUTH2 authentication", - "symfony/polyfill-mbstring": "To support UTF-8 if the Mbstring PHP extension is not enabled (^1.2)" + "symfony/polyfill-mbstring": "To support UTF-8 if the Mbstring PHP extension is not enabled (^1.2)", + "thenetworg/oauth2-azure": "Needed for Microsoft XOAUTH2 authentication" }, "type": "library", "autoload": { @@ -596,7 +596,7 @@ "description": "PHPMailer is a full-featured email creation and transfer class for PHP", "support": { "issues": "https://github.com/PHPMailer/PHPMailer/issues", - "source": "https://github.com/PHPMailer/PHPMailer/tree/v6.6.4" + "source": "https://github.com/PHPMailer/PHPMailer/tree/v6.6.5" }, "funding": [ { @@ -604,7 +604,7 @@ "type": "github" } ], - "time": "2022-08-22T09:22:00+00:00" + "time": "2022-10-07T12:23:10+00:00" }, { "name": "psr/log", @@ -745,16 +745,16 @@ }, { "name": "symfony/polyfill-intl-normalizer", - "version": "v1.26.0", + "version": "v1.27.0", "source": { "type": "git", "url": "https://github.com/symfony/polyfill-intl-normalizer.git", - "reference": "219aa369ceff116e673852dce47c3a41794c14bd" + "reference": "19bd1e4fcd5b91116f14d8533c57831ed00571b6" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/polyfill-intl-normalizer/zipball/219aa369ceff116e673852dce47c3a41794c14bd", - "reference": "219aa369ceff116e673852dce47c3a41794c14bd", + "url": "https://api.github.com/repos/symfony/polyfill-intl-normalizer/zipball/19bd1e4fcd5b91116f14d8533c57831ed00571b6", + "reference": "19bd1e4fcd5b91116f14d8533c57831ed00571b6", "shasum": "" }, "require": { @@ -766,7 +766,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-main": "1.26-dev" + "dev-main": "1.27-dev" }, "thanks": { "name": "symfony/polyfill", @@ -809,7 +809,7 @@ "shim" ], "support": { - "source": "https://github.com/symfony/polyfill-intl-normalizer/tree/v1.26.0" + "source": "https://github.com/symfony/polyfill-intl-normalizer/tree/v1.27.0" }, "funding": [ { @@ -825,7 +825,7 @@ "type": "tidelift" } ], - "time": "2022-05-24T11:49:31+00:00" + "time": "2022-11-03T14:55:06+00:00" }, { "name": "symfony/polyfill-mbstring",