@telia-ace/widget-site 1.0.8 → 1.0.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/index.js +1 -1
- package/index.mjs +1 -1
- package/index.umd.js +1 -1
- package/package.json +1 -1
package/index.js
CHANGED
|
@@ -24,4 +24,4 @@
|
|
|
24
24
|
* @license
|
|
25
25
|
* Copyright 2017 Google LLC
|
|
26
26
|
* SPDX-License-Identifier: BSD-3-Clause
|
|
27
|
-
*/function P(n){return v({...n,state:!0,attribute:!1})}var Mt=Object.defineProperty,It=Object.getOwnPropertyDescriptor,C=(n,t,e,i)=>{for(var s=i>1?void 0:i?It(t,e):t,r=n.length-1,o;r>=0;r--)(o=n[r])&&(s=(i?o(t,e,s):o(s))||s);return i&&s&&Mt(t,e,s),s};const rt="https://widgets.ace.teliacompany.net",ot="https://embed.webprovisions.io",Rt=()=>{if(typeof window<"u"){const n=history.pushState,t=history.replaceState;history.pushState=function(...e){n.apply(history,e),window.dispatchEvent(new Event("locationchange"))},history.replaceState=function(...e){t.apply(history,e),window.dispatchEvent(new Event("locationchange"))}}};class f extends E{constructor(){var t;super(...arguments),this.apiUrl=rt,this.embedUrl=ot,this._site=null,this._widgets={},this._path=((t=window==null?void 0:window.location)==null?void 0:t.pathname)||"",this.routeChangeListener=()=>{this._path=window.location.pathname,this.requestUpdate()}}async connectedCallback(){super.connectedCallback(),Rt(),await this.loadSite(),window.addEventListener("locationchange",this.routeChangeListener)}disconnectedCallback(){super.disconnectedCallback(),window.removeEventListener("locationchange",this.routeChangeListener)}async loadSite(){var i;const e=await(await fetch(`${this.apiUrl}/api/site/${this.siteId}`)).json();this._site=e,(((i=this._site)==null?void 0:i.widgets)||[]).forEach(async s=>{this.addWidgetEl(s.widgetId)})}addWidgetEl(t){const e=`ace-widget_${t}`;let i=document.getElementById(e);i||(i=document.createElement("ace-widget-wrapper"),i.setAttribute("id",e),i.setAttribute("widgetId",t),this.apiUrl!==rt&&i.setAttribute("apiUrl",this.apiUrl),this.embedUrl!==ot&&i.setAttribute("embedUrl",this.embedUrl),document.body.appendChild(i)),this._widgets={...this._widgets,[t]:i},window.ace=window.ace||{_c:[],_w:[],widget:function(s,r){window.ace._w.push([s,r])},configure:function(s){window.ace._c.push(s)}}}render(){if(console.log("path = ",this._path),!this._site)return l;const t=jt(this._site);for(const[e,i]of Object.entries(this._widgets)){const s=t.find(r=>r.widgetId===e);s&&!i.isActivated()?i.activate():!s&&i.isActivated()&&i.deactivate()}return l}}C([v({attribute:!0})],f.prototype,"siteId",2);C([v()],f.prototype,"apiUrl",2);C([v()],f.prototype,"embedUrl",2);C([P()],f.prototype,"_site",2);C([P()],f.prototype,"_widgets",2);C([P()],f.prototype,"_path",2);const jt=n=>{const t=[];return(n.triggers||[]).filter(e=>e.triggerType==="visit").forEach(e=>{const i=window.location.pathname,s=e.condition.outputs||[];e.condition.type==="url"&&s.forEach(r=>{const o=r.action.type==="render_widget";if((r.value===i||r.value==="*")&&o){let a={widgetId:""};try{a=JSON.parse(r.action.data)}catch{a={widgetId:""}}const d=t.findIndex(h=>h.widgetId===a.widgetId)>-1,p=((n==null?void 0:n.widgets)||[]).find(h=>h.widgetId===a.widgetId);p&&!d&&t.push(p)}})}),t};window.customElements.get("ace-site")||window.customElements.define("ace-site",f);var Lt=Object.defineProperty,Wt=Object.getOwnPropertyDescriptor,O=(n,t,e,i)=>{for(var s=i>1?void 0:i?Wt(t,e):t,r=n.length-1,o;r>=0;r--)(o=n[r])&&(s=(i?o(t,e,s):o(s))||s);return i&&s&&Lt(t,e,s),s};const kt="https://widgets.ace.teliacompany.net",zt="https://embed.webprovisions.io";class m extends E{constructor(){super(...arguments),this.apiUrl=kt,this.embedUrl=zt,this.widget=null,this.scriptEl=null,this.activated=!1}async connectedCallback(){super.connectedCallback(),this.widget=await this._loadWidget(this.widgetId)}async _loadWidget(t){return await(await fetch(`${this.apiUrl}/api/widget/${t}`)).json()}_createEmbedScript(){var e;if(!((e=this.widget)!=null&&e.distributionName))return;let t=document.createElement("script");t.setAttribute("type","module"),t.setAttribute("async","true"),t.setAttribute("src",`${this.embedUrl}/d/${this.widget.organization}/${this.widget.distributionName}@latest/index.js`),this.scriptEl=t}isActivated(){return this.activated}async activate(){this.widget||(this.widget=await this._loadWidget(this.widgetId)),this._createEmbedScript(),console.log("activating"),this.activated=!0;const t=window.ace.applications.find(e=>e.id===this.widgetId);t&&(t.
|
|
27
|
+
*/function P(n){return v({...n,state:!0,attribute:!1})}var Mt=Object.defineProperty,It=Object.getOwnPropertyDescriptor,C=(n,t,e,i)=>{for(var s=i>1?void 0:i?It(t,e):t,r=n.length-1,o;r>=0;r--)(o=n[r])&&(s=(i?o(t,e,s):o(s))||s);return i&&s&&Mt(t,e,s),s};const rt="https://widgets.ace.teliacompany.net",ot="https://embed.webprovisions.io",Rt=()=>{if(typeof window<"u"){const n=history.pushState,t=history.replaceState;history.pushState=function(...e){n.apply(history,e),window.dispatchEvent(new Event("locationchange"))},history.replaceState=function(...e){t.apply(history,e),window.dispatchEvent(new Event("locationchange"))}}};class f extends E{constructor(){var t;super(...arguments),this.apiUrl=rt,this.embedUrl=ot,this._site=null,this._widgets={},this._path=((t=window==null?void 0:window.location)==null?void 0:t.pathname)||"",this.routeChangeListener=()=>{this._path=window.location.pathname,this.requestUpdate()}}async connectedCallback(){super.connectedCallback(),Rt(),await this.loadSite(),window.addEventListener("locationchange",this.routeChangeListener)}disconnectedCallback(){super.disconnectedCallback(),window.removeEventListener("locationchange",this.routeChangeListener)}async loadSite(){var i;const e=await(await fetch(`${this.apiUrl}/api/site/${this.siteId}`)).json();this._site=e,(((i=this._site)==null?void 0:i.widgets)||[]).forEach(async s=>{this.addWidgetEl(s.widgetId)})}addWidgetEl(t){const e=`ace-widget_${t}`;let i=document.getElementById(e);i||(i=document.createElement("ace-widget-wrapper"),i.setAttribute("id",e),i.setAttribute("widgetId",t),this.apiUrl!==rt&&i.setAttribute("apiUrl",this.apiUrl),this.embedUrl!==ot&&i.setAttribute("embedUrl",this.embedUrl),document.body.appendChild(i)),this._widgets={...this._widgets,[t]:i},window.ace=window.ace||{_c:[],_w:[],widget:function(s,r){window.ace._w.push([s,r])},configure:function(s){window.ace._c.push(s)}}}render(){if(console.log("path = ",this._path),!this._site)return l;const t=jt(this._site);for(const[e,i]of Object.entries(this._widgets)){const s=t.find(r=>r.widgetId===e);s&&!i.isActivated()?i.activate():!s&&i.isActivated()&&i.deactivate()}return l}}C([v({attribute:!0})],f.prototype,"siteId",2);C([v()],f.prototype,"apiUrl",2);C([v()],f.prototype,"embedUrl",2);C([P()],f.prototype,"_site",2);C([P()],f.prototype,"_widgets",2);C([P()],f.prototype,"_path",2);const jt=n=>{const t=[];return(n.triggers||[]).filter(e=>e.triggerType==="visit").forEach(e=>{const i=window.location.pathname,s=e.condition.outputs||[];e.condition.type==="url"&&s.forEach(r=>{const o=r.action.type==="render_widget";if((r.value===i||r.value==="*")&&o){let a={widgetId:""};try{a=JSON.parse(r.action.data)}catch{a={widgetId:""}}const d=t.findIndex(h=>h.widgetId===a.widgetId)>-1,p=((n==null?void 0:n.widgets)||[]).find(h=>h.widgetId===a.widgetId);p&&!d&&t.push(p)}})}),t};window.customElements.get("ace-site")||window.customElements.define("ace-site",f);var Lt=Object.defineProperty,Wt=Object.getOwnPropertyDescriptor,O=(n,t,e,i)=>{for(var s=i>1?void 0:i?Wt(t,e):t,r=n.length-1,o;r>=0;r--)(o=n[r])&&(s=(i?o(t,e,s):o(s))||s);return i&&s&&Lt(t,e,s),s};const kt="https://widgets.ace.teliacompany.net",zt="https://embed.webprovisions.io";class m extends E{constructor(){super(...arguments),this.apiUrl=kt,this.embedUrl=zt,this.widget=null,this.scriptEl=null,this.activated=!1}async connectedCallback(){super.connectedCallback(),this.widget=await this._loadWidget(this.widgetId)}async _loadWidget(t){return await(await fetch(`${this.apiUrl}/api/widget/${t}`)).json()}_createEmbedScript(){var e;if(!((e=this.widget)!=null&&e.distributionName))return;let t=document.createElement("script");t.setAttribute("type","module"),t.setAttribute("async","true"),t.setAttribute("src",`${this.embedUrl}/d/${this.widget.organization}/${this.widget.distributionName}@latest/index.js`),this.scriptEl=t}isActivated(){return this.activated}async activate(){this.widget||(this.widget=await this._loadWidget(this.widgetId)),this._createEmbedScript(),console.log("activating"),this.activated=!0;const t=window.ace.applications.find(e=>e.id===this.widgetId);t&&(t.open(),t.trigger.showTrigger())}async deactivate(){console.log("deactivating"),this.activated=!1;const t=window.ace.applications.find(e=>e.id===this.widgetId);t&&(t.hide(),t.trigger.hideTrigger())}render(){return this.scriptEl?this.scriptEl:l}}O([v({attribute:!0})],m.prototype,"widgetId",2);O([v()],m.prototype,"apiUrl",2);O([v()],m.prototype,"embedUrl",2);O([P()],m.prototype,"widget",2);O([P()],m.prototype,"scriptEl",2);O([P()],m.prototype,"activated",2);customElements.get("ace-widget-wrapper")||customElements.define("ace-widget-wrapper",m);exports.SiteComponent=f;exports.WidgetComponent=m;
|
package/index.mjs
CHANGED
|
@@ -752,7 +752,7 @@ class v extends E {
|
|
|
752
752
|
const t = window.ace.applications.find(
|
|
753
753
|
(e) => e.id === this.widgetId
|
|
754
754
|
);
|
|
755
|
-
t && (t.
|
|
755
|
+
t && (t.open(), t.trigger.showTrigger());
|
|
756
756
|
}
|
|
757
757
|
async deactivate() {
|
|
758
758
|
console.log("deactivating"), this.activated = !1;
|
package/index.umd.js
CHANGED
|
@@ -24,4 +24,4 @@
|
|
|
24
24
|
* @license
|
|
25
25
|
* Copyright 2017 Google LLC
|
|
26
26
|
* SPDX-License-Identifier: BSD-3-Clause
|
|
27
|
-
*/function O(n){return E({...n,state:!0,attribute:!1})}var It=Object.defineProperty,Rt=Object.getOwnPropertyDescriptor,x=(n,t,e,i)=>{for(var s=i>1?void 0:i?Rt(t,e):t,o=n.length-1,r;o>=0;o--)(r=n[o])&&(s=(i?r(t,e,s):r(s))||s);return i&&s&&It(t,e,s),s};const lt="https://widgets.ace.teliacompany.net",pt="https://embed.webprovisions.io",jt=()=>{if(typeof window<"u"){const n=history.pushState,t=history.replaceState;history.pushState=function(...e){n.apply(history,e),window.dispatchEvent(new Event("locationchange"))},history.replaceState=function(...e){t.apply(history,e),window.dispatchEvent(new Event("locationchange"))}}};class _ extends C{constructor(){var t;super(...arguments),this.apiUrl=lt,this.embedUrl=pt,this._site=null,this._widgets={},this._path=((t=window==null?void 0:window.location)==null?void 0:t.pathname)||"",this.routeChangeListener=()=>{this._path=window.location.pathname,this.requestUpdate()}}async connectedCallback(){super.connectedCallback(),jt(),await this.loadSite(),window.addEventListener("locationchange",this.routeChangeListener)}disconnectedCallback(){super.disconnectedCallback(),window.removeEventListener("locationchange",this.routeChangeListener)}async loadSite(){var i;const e=await(await fetch(`${this.apiUrl}/api/site/${this.siteId}`)).json();this._site=e,(((i=this._site)==null?void 0:i.widgets)||[]).forEach(async s=>{this.addWidgetEl(s.widgetId)})}addWidgetEl(t){const e=`ace-widget_${t}`;let i=document.getElementById(e);i||(i=document.createElement("ace-widget-wrapper"),i.setAttribute("id",e),i.setAttribute("widgetId",t),this.apiUrl!==lt&&i.setAttribute("apiUrl",this.apiUrl),this.embedUrl!==pt&&i.setAttribute("embedUrl",this.embedUrl),document.body.appendChild(i)),this._widgets={...this._widgets,[t]:i},window.ace=window.ace||{_c:[],_w:[],widget:function(s,o){window.ace._w.push([s,o])},configure:function(s){window.ace._c.push(s)}}}render(){if(console.log("path = ",this._path),!this._site)return d;const t=Lt(this._site);for(const[e,i]of Object.entries(this._widgets)){const s=t.find(o=>o.widgetId===e);s&&!i.isActivated()?i.activate():!s&&i.isActivated()&&i.deactivate()}return d}}x([E({attribute:!0})],_.prototype,"siteId",2),x([E()],_.prototype,"apiUrl",2),x([E()],_.prototype,"embedUrl",2),x([O()],_.prototype,"_site",2),x([O()],_.prototype,"_widgets",2),x([O()],_.prototype,"_path",2);const Lt=n=>{const t=[];return(n.triggers||[]).filter(e=>e.triggerType==="visit").forEach(e=>{const i=window.location.pathname,s=e.condition.outputs||[];e.condition.type==="url"&&s.forEach(o=>{const r=o.action.type==="render_widget";if((o.value===i||o.value==="*")&&r){let a={widgetId:""};try{a=JSON.parse(o.action.data)}catch{a={widgetId:""}}const l=t.findIndex(h=>h.widgetId===a.widgetId)>-1,p=((n==null?void 0:n.widgets)||[]).find(h=>h.widgetId===a.widgetId);p&&!l&&t.push(p)}})}),t};window.customElements.get("ace-site")||window.customElements.define("ace-site",_);var Wt=Object.defineProperty,kt=Object.getOwnPropertyDescriptor,T=(n,t,e,i)=>{for(var s=i>1?void 0:i?kt(t,e):t,o=n.length-1,r;o>=0;o--)(r=n[o])&&(s=(i?r(t,e,s):r(s))||s);return i&&s&&Wt(t,e,s),s};const zt="https://widgets.ace.teliacompany.net",Bt="https://embed.webprovisions.io";class m extends C{constructor(){super(...arguments),this.apiUrl=zt,this.embedUrl=Bt,this.widget=null,this.scriptEl=null,this.activated=!1}async connectedCallback(){super.connectedCallback(),this.widget=await this._loadWidget(this.widgetId)}async _loadWidget(t){return await(await fetch(`${this.apiUrl}/api/widget/${t}`)).json()}_createEmbedScript(){var e;if(!((e=this.widget)!=null&&e.distributionName))return;let t=document.createElement("script");t.setAttribute("type","module"),t.setAttribute("async","true"),t.setAttribute("src",`${this.embedUrl}/d/${this.widget.organization}/${this.widget.distributionName}@latest/index.js`),this.scriptEl=t}isActivated(){return this.activated}async activate(){this.widget||(this.widget=await this._loadWidget(this.widgetId)),this._createEmbedScript(),console.log("activating"),this.activated=!0;const t=window.ace.applications.find(e=>e.id===this.widgetId);t&&(t.
|
|
27
|
+
*/function O(n){return E({...n,state:!0,attribute:!1})}var It=Object.defineProperty,Rt=Object.getOwnPropertyDescriptor,x=(n,t,e,i)=>{for(var s=i>1?void 0:i?Rt(t,e):t,o=n.length-1,r;o>=0;o--)(r=n[o])&&(s=(i?r(t,e,s):r(s))||s);return i&&s&&It(t,e,s),s};const lt="https://widgets.ace.teliacompany.net",pt="https://embed.webprovisions.io",jt=()=>{if(typeof window<"u"){const n=history.pushState,t=history.replaceState;history.pushState=function(...e){n.apply(history,e),window.dispatchEvent(new Event("locationchange"))},history.replaceState=function(...e){t.apply(history,e),window.dispatchEvent(new Event("locationchange"))}}};class _ extends C{constructor(){var t;super(...arguments),this.apiUrl=lt,this.embedUrl=pt,this._site=null,this._widgets={},this._path=((t=window==null?void 0:window.location)==null?void 0:t.pathname)||"",this.routeChangeListener=()=>{this._path=window.location.pathname,this.requestUpdate()}}async connectedCallback(){super.connectedCallback(),jt(),await this.loadSite(),window.addEventListener("locationchange",this.routeChangeListener)}disconnectedCallback(){super.disconnectedCallback(),window.removeEventListener("locationchange",this.routeChangeListener)}async loadSite(){var i;const e=await(await fetch(`${this.apiUrl}/api/site/${this.siteId}`)).json();this._site=e,(((i=this._site)==null?void 0:i.widgets)||[]).forEach(async s=>{this.addWidgetEl(s.widgetId)})}addWidgetEl(t){const e=`ace-widget_${t}`;let i=document.getElementById(e);i||(i=document.createElement("ace-widget-wrapper"),i.setAttribute("id",e),i.setAttribute("widgetId",t),this.apiUrl!==lt&&i.setAttribute("apiUrl",this.apiUrl),this.embedUrl!==pt&&i.setAttribute("embedUrl",this.embedUrl),document.body.appendChild(i)),this._widgets={...this._widgets,[t]:i},window.ace=window.ace||{_c:[],_w:[],widget:function(s,o){window.ace._w.push([s,o])},configure:function(s){window.ace._c.push(s)}}}render(){if(console.log("path = ",this._path),!this._site)return d;const t=Lt(this._site);for(const[e,i]of Object.entries(this._widgets)){const s=t.find(o=>o.widgetId===e);s&&!i.isActivated()?i.activate():!s&&i.isActivated()&&i.deactivate()}return d}}x([E({attribute:!0})],_.prototype,"siteId",2),x([E()],_.prototype,"apiUrl",2),x([E()],_.prototype,"embedUrl",2),x([O()],_.prototype,"_site",2),x([O()],_.prototype,"_widgets",2),x([O()],_.prototype,"_path",2);const Lt=n=>{const t=[];return(n.triggers||[]).filter(e=>e.triggerType==="visit").forEach(e=>{const i=window.location.pathname,s=e.condition.outputs||[];e.condition.type==="url"&&s.forEach(o=>{const r=o.action.type==="render_widget";if((o.value===i||o.value==="*")&&r){let a={widgetId:""};try{a=JSON.parse(o.action.data)}catch{a={widgetId:""}}const l=t.findIndex(h=>h.widgetId===a.widgetId)>-1,p=((n==null?void 0:n.widgets)||[]).find(h=>h.widgetId===a.widgetId);p&&!l&&t.push(p)}})}),t};window.customElements.get("ace-site")||window.customElements.define("ace-site",_);var Wt=Object.defineProperty,kt=Object.getOwnPropertyDescriptor,T=(n,t,e,i)=>{for(var s=i>1?void 0:i?kt(t,e):t,o=n.length-1,r;o>=0;o--)(r=n[o])&&(s=(i?r(t,e,s):r(s))||s);return i&&s&&Wt(t,e,s),s};const zt="https://widgets.ace.teliacompany.net",Bt="https://embed.webprovisions.io";class m extends C{constructor(){super(...arguments),this.apiUrl=zt,this.embedUrl=Bt,this.widget=null,this.scriptEl=null,this.activated=!1}async connectedCallback(){super.connectedCallback(),this.widget=await this._loadWidget(this.widgetId)}async _loadWidget(t){return await(await fetch(`${this.apiUrl}/api/widget/${t}`)).json()}_createEmbedScript(){var e;if(!((e=this.widget)!=null&&e.distributionName))return;let t=document.createElement("script");t.setAttribute("type","module"),t.setAttribute("async","true"),t.setAttribute("src",`${this.embedUrl}/d/${this.widget.organization}/${this.widget.distributionName}@latest/index.js`),this.scriptEl=t}isActivated(){return this.activated}async activate(){this.widget||(this.widget=await this._loadWidget(this.widgetId)),this._createEmbedScript(),console.log("activating"),this.activated=!0;const t=window.ace.applications.find(e=>e.id===this.widgetId);t&&(t.open(),t.trigger.showTrigger())}async deactivate(){console.log("deactivating"),this.activated=!1;const t=window.ace.applications.find(e=>e.id===this.widgetId);t&&(t.hide(),t.trigger.hideTrigger())}render(){return this.scriptEl?this.scriptEl:d}}T([E({attribute:!0})],m.prototype,"widgetId",2),T([E()],m.prototype,"apiUrl",2),T([E()],m.prototype,"embedUrl",2),T([O()],m.prototype,"widget",2),T([O()],m.prototype,"scriptEl",2),T([O()],m.prototype,"activated",2),customElements.get("ace-widget-wrapper")||customElements.define("ace-widget-wrapper",m),w.SiteComponent=_,w.WidgetComponent=m,Object.defineProperty(w,Symbol.toStringTag,{value:"Module"})});
|