@braze/web-sdk 4.0.5 → 4.2.0
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.d.ts +18 -3
- package/package.json +1 -1
- package/shared-lib/braze-shared-lib.js +1 -1
- package/shared-lib/encoding-utils.js +1 -1
- package/shared-lib/event-types.js +1 -1
- package/shared-lib/guid.js +1 -1
- package/shared-lib/indexed-db-adapter.js +1 -1
- package/shared-lib/logger.js +1 -1
- package/shared-lib/supported-options.js +1 -1
- package/src/Card/display/card-display.js +1 -1
- package/src/Card/index.js +1 -1
- package/src/Card/log-content-card-impressions.js +1 -0
- package/src/Card/models/captioned-image.js +1 -1
- package/src/Card/models/card.js +1 -1
- package/src/Card/models/classic-card.js +1 -1
- package/src/Card/models/control-card.js +1 -1
- package/src/Card/util/card-factory.js +1 -1
- package/src/ContentCards/content-cards-provider.js +1 -1
- package/src/ContentCards/get-cached-content-cards.js +1 -1
- package/src/ContentCards/log-content-cards-displayed.js +1 -1
- package/src/ContentCards/request-content-cards-refresh.js +1 -1
- package/src/ContentCards/subscribe-to-content-cards-updates.js +1 -1
- package/src/ContentCards/ui/show-content-cards.js +1 -1
- package/src/Core/add-sdk-metadata.js +1 -1
- package/src/Core/disable-sdk.js +1 -1
- package/src/Core/enable-sdk.js +1 -1
- package/src/Core/handle-braze-action.js +1 -1
- package/src/Core/is-disabled.js +1 -1
- package/src/Core/log-custom-event.js +1 -1
- package/src/Core/log-purchase.js +1 -1
- package/src/Core/open-session.js +1 -1
- package/src/Core/set-sdk-authentication-signature.js +1 -1
- package/src/Core/subscribe-to-sdk-authentication-failures.js +1 -1
- package/src/Core/wipe-data.js +1 -1
- package/src/Feed/feed-provider.js +1 -1
- package/src/Feed/get-cached-feed.js +1 -1
- package/src/Feed/request-feed-refresh.js +1 -1
- package/src/Feed/subscribe-to-feed-updates.js +1 -1
- package/src/Feed/ui/show-feed.js +1 -1
- package/src/InAppMessage/display/html-message-to-html.js +1 -1
- package/src/InAppMessage/display/in-app-message-to-html.js +1 -1
- package/src/InAppMessage/in-app-message-manager.js +1 -1
- package/src/InAppMessage/log-in-app-message-button-click.js +1 -1
- package/src/InAppMessage/log-in-app-message-click.js +1 -1
- package/src/InAppMessage/log-in-app-message-html-click.js +1 -1
- package/src/InAppMessage/log-in-app-message-impression.js +1 -1
- package/src/InAppMessage/models/html-message.js +1 -1
- package/src/InAppMessage/models/in-app-message-button.js +1 -1
- package/src/InAppMessage/models/in-app-message.js +1 -1
- package/src/InAppMessage/models/modal-message.js +1 -1
- package/src/InAppMessage/models/slide-up-message.js +1 -1
- package/src/InAppMessage/models/templated-in-app-message.js +1 -1
- package/src/InAppMessage/subscribe-to-in-app-message.js +1 -1
- package/src/InAppMessage/ui/automatically-show-in-app-messages.js +1 -1
- package/src/InAppMessage/ui/show-in-app-message.js +1 -1
- package/src/Push/is-push-blocked.js +1 -1
- package/src/Push/is-push-permission-granted.js +1 -1
- package/src/Push/is-push-supported.js +1 -1
- package/src/Push/push-manager-factory.js +1 -1
- package/src/Push/push-manager.js +1 -1
- package/src/Push/request-push-permission.js +1 -1
- package/src/Push/unregister-push.js +1 -1
- package/src/User/user-manager.js +1 -1
- package/src/User/user.js +1 -1
- package/src/common/base-feed.js +1 -1
- package/src/common/base-provider.js +1 -1
- package/src/common/feed-display.js +1 -1
- package/src/l10n/l10n-manager-factory.js +1 -1
- package/src/managers/auth-manager.js +1 -1
- package/src/managers/braze-instance.js +1 -1
- package/src/managers/device-manager.js +1 -1
- package/src/managers/network-manager.js +1 -1
- package/src/managers/server-config-manager.js +1 -1
- package/src/managers/session-manager.js +1 -1
- package/src/managers/storage-manager-factory.js +1 -1
- package/src/managers/storage-manager.js +1 -1
- package/src/managers/subscription-manager.js +1 -1
- package/src/models/backend-errors.js +1 -1
- package/src/models/braze-event.js +1 -1
- package/src/models/device.js +1 -1
- package/src/models/identifier.js +1 -1
- package/src/models/push-token.js +1 -1
- package/src/models/server-config.js +1 -1
- package/src/request-controller.js +1 -1
- package/src/triggers/models/filter-set.js +1 -1
- package/src/triggers/models/filter.js +1 -1
- package/src/triggers/models/in-app-message-click-data.js +1 -1
- package/src/triggers/models/push-click-data.js +1 -1
- package/src/triggers/models/trigger-condition.js +1 -1
- package/src/triggers/models/trigger.js +1 -1
- package/src/triggers/triggers-provider-factory.js +1 -1
- package/src/triggers/triggers-provider.js +1 -1
- package/src/ui/js/attach-css.js +1 -1
- package/src/ui/js/load-font-awesome.js +1 -1
- package/src/util/base-device-parser.js +1 -1
- package/src/util/braze-actions.js +1 -1
- package/src/util/browser-detector.js +1 -1
- package/src/util/client-hints-parser.js +1 -1
- package/src/util/dom-utils.js +1 -1
- package/src/util/key-codes.js +1 -1
- package/src/util/net.js +1 -1
- package/src/util/user-agent-parser.js +1 -1
- package/src/util/validation-utils.js +1 -1
- package/src/util/window-utils.js +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
import xt from"./custom-event-data.js";import Mt from"./custom-event-property-data.js";import Bt from"./filter-set.js";import Ft from"./in-app-message-click-data.js";import Gt from"./purchase-data.js";import Kt from"./purchase-property-data.js";import Qt from"./push-click-data.js";import
|
|
1
|
+
import xt from"./custom-event-data.js";import Mt from"./custom-event-property-data.js";import Bt from"./filter-set.js";import Ft from"./in-app-message-click-data.js";import Gt from"./purchase-data.js";import Kt from"./purchase-property-data.js";import Qt from"./push-click-data.js";import V from"./trigger-events.js";import r from"../../../shared-lib/braze-shared-lib.js";export default class Dt{constructor(e,t){this.type=e,this.data=t}ec(e,t){return Dt.tc[this.type]===e&&(null==this.data||this.data.zl(t))}static ou(e,t){let a=null;try{a=window.atob(e)}catch(t){return r.D.info("Failed to unencode analytics id "+e+": "+t.message),!1}return t===a.split("_")[0]}static fromJson(e){const t=e.type;let r;switch(t){case Dt.rc.OPEN:r=null;break;case Dt.rc.Rr:r=Gt.fromJson(e.data);break;case Dt.rc.ac:r=Kt.fromJson(e.data);break;case Dt.rc.vr:r=Qt.fromJson(e.data);break;case Dt.rc.be:r=xt.fromJson(e.data);break;case Dt.rc.sc:r=Mt.fromJson(e.data);break;case Dt.rc.Ar:r=Ft.fromJson(e.data);break;case Dt.rc.ks:r=null}return new Dt(t,r)}ss(){return{t:this.type,d:this.data?this.data.ss():null}}static En(e){let t,r;switch(e.t){case Dt.rc.OPEN:t=null;break;case Dt.rc.Rr:t=new Gt(e.d);break;case Dt.rc.ac:r=e.d||{},t=new Kt(r.id,Bt.En(r.pf||[]));break;case Dt.rc.vr:t=new Qt(e.d);break;case Dt.rc.be:t=new xt(e.d);break;case Dt.rc.sc:r=e.d||{},t=new Mt(r.e,Bt.En(r.pf||[]));break;case Dt.rc.Ar:t=new Ft(e.d);break;case Dt.rc.ks:t=null}return new Dt(e.t,t)}}Dt.rc={OPEN:"open",Rr:"purchase",ac:"purchase_property",vr:"push_click",be:"custom_event",sc:"custom_event_property",Ar:"iam_click",ks:"test"},Dt.tc={},Dt.tc[Dt.rc.OPEN]=V.OPEN,Dt.tc[Dt.rc.Rr]=V.Rr,Dt.tc[Dt.rc.ac]=V.Rr,Dt.tc[Dt.rc.vr]=V.vr,Dt.tc[Dt.rc.be]=V.be,Dt.tc[Dt.rc.sc]=V.be,Dt.tc[Dt.rc.Ar]=V.Ar,Dt.tc[Dt.rc.ks]=V.ks;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{dateFromUnixTimestamp as h,rehydrateDateAfterJsonization as w}from"../../util/date-utils.js";import r from"../../../shared-lib/braze-shared-lib.js";import Dt from"./trigger-condition.js";import{validateValueIsFromEnum as
|
|
1
|
+
import{dateFromUnixTimestamp as h,rehydrateDateAfterJsonization as w}from"../../util/date-utils.js";import r from"../../../shared-lib/braze-shared-lib.js";import Dt from"./trigger-condition.js";import{validateValueIsFromEnum as F}from"../../util/code-utils.js";export default class ut{constructor(t,i,s,e,r,l,o,n,h,a,u,d){this.id=t,this.Th=i||[],void 0===s&&(s=null),this.startTime=s,void 0===e&&(e=null),this.endTime=e,this.priority=r||0,this.type=l,this.Ph=n||0,null==a&&(a=1e3*(this.Ph+30)),this.yi=a,this.data=o,null==h&&(h=ut.yh),this.Ah=h,this.Ih=u,this.$h=d||null}Mh(t){return null==this.$h||this.Ah!==ut.yh&&t-this.$h>=1e3*this.Ah}Bh(t){this.$h=t}Jh(t){const i=t+1e3*this.Ph;return Math.max(i-(new Date).valueOf(),0)}Lh(t){const i=(new Date).valueOf()-t,s=null==t||isNaN(i)||null==this.yi||i<this.yi;return s||r.D.info(`Trigger action ${this.type} is no longer eligible for display - fired ${i}ms ago and has a timeout of ${this.yi}ms.`),!s}static fromJson(t){const i=t.id,s=[];for(let i=0;i<t.trigger_condition.length;i++)s.push(Dt.fromJson(t.trigger_condition[i]));const e=h(t.start_time),r=h(t.end_time),l=t.priority,o=t.type,n=t.delay,a=t.re_eligibility,u=t.timeout,d=t.data,m=t.min_seconds_since_last_trigger;return F(ut.gi,o,"Could not construct Trigger from server data","Trigger.Types")?new ut(i,s,e,r,l,o,d,n,a,u,m):null}ss(){const t=[];for(let i=0;i<this.Th.length;i++)t.push(this.Th[i].ss());return{i:this.id,c:t,s:this.startTime,e:this.endTime,p:this.priority,t:this.type,da:this.data,d:this.Ph,r:this.Ah,tm:this.yi,ss:this.Ih,ld:this.$h}}static En(t){const i=[];for(let s=0;s<t.c.length;s++)i.push(Dt.En(t.c[s]));return new ut(t.i,i,w(t.s),w(t.e),t.p,t.t,t.da,t.d,t.r,t.tm,t.ss,t.ld)}}ut.yh=-1,ut.gi={ci:"inapp",Rh:"templated_iam"};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import pe from"../InAppMessage/in-app-message-manager-factory.js";import e,{OPTIONS as
|
|
1
|
+
import pe from"../InAppMessage/in-app-message-manager-factory.js";import e,{OPTIONS as T}from"../managers/braze-instance.js";import ir from"./triggers-provider.js";export const TriggersProviderFactory={t:!1,provider:null,er:()=>(TriggersProviderFactory.init(),TriggersProviderFactory.provider),rg:()=>{if(!TriggersProviderFactory.provider){const r=e.nn(T.So);TriggersProviderFactory.provider=new ir(null!=r?r:30,pe.m().Be(),e.l(),e.mr(),pe.m()),e.ar(TriggersProviderFactory.provider)}},init:()=>{TriggersProviderFactory.t||(TriggersProviderFactory.rg(),e.u(TriggersProviderFactory),TriggersProviderFactory.t=!0)},destroy:()=>{TriggersProviderFactory.provider=null,TriggersProviderFactory.t=!1}};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import
|
|
1
|
+
import y from"../common/base-provider.js";import{newInAppMessageFromJson as it}from"../InAppMessage/in-app-message-factory.js";import ue from"../models/braze-event.js";import{InAppMessage}from"../InAppMessage/index.js";import{isArray as p,isEqual as ii,validateValueIsFromEnum as F}from"../util/code-utils.js";import{STORAGE_KEYS as o}from"../managers/storage-manager.js";import ft from"../InAppMessage/models/templated-in-app-message.js";import ut from"./models/trigger.js";import V from"./models/trigger-events.js";import r from"../../shared-lib/braze-shared-lib.js";export default class ir extends y{constructor(t,i,s,e,r){super(),this.Oh=t,this.yt=i,this.h=s,this.si=e,this.Uh=r,this.Kh=[],this.Qh=[],this.Vh=null,this.Xh={},this.Yh={},this.Zh(),this.tg()}ig(){this.Vh=this.h.I(o.q.va)||this.Vh,this.Xh=this.h.I(o.q.Ca)||this.Xh,this.Yh=this.h.I(o.q.Na)||this.Yh;for(let t=0;t<this.sg.length;t++){const i=this.sg[t];null!=this.Yh[i.id]&&i.Bh(this.Yh[i.id])}}Zh(){this.eg=this.h.I(o.q.Ga)||0;const t=this.h.I(o.q.Ya)||[],i=[];for(let s=0;s<t.length;s++)i.push(ut.En(t[s]));this.sg=i,this.ig()}tg(){const t=this,i=function(i,s,e,r,h){return function(){t.hg(i,s,e,r,h)}},s={};for(let t=0;t<this.sg.length;t++)s[this.sg[t].id]=this.sg[t];let e=!1;for(let t=0;t<this.sg.length;t++){const r=this.sg[t];if(null!=this.Xh[r.id]){const t=this.Xh[r.id],h=[];for(let e=0;e<t.length;e++){const o=t[e],n=r.Jh(o.vi);if(n>0){let t,e;h.push(o),null!=o.og&&(t=o.og),null!=o.ng&&ue.Fa(o.ng)&&(e=ue.En(o.ng));const l=[];if(p(o.lg))for(let t=0;t<o.lg.length;t++){const i=s[o.lg[t]];null!=i&&l.push(i)}this.Qh.push(setTimeout(i(r,o.vi,t,e,l),n))}}this.Xh[r.id].length>h.length&&(this.Xh[r.id]=h,e=!0,0===this.Xh[r.id].length&&delete this.Xh[r.id])}}e&&this.h.B(o.q.Ca,this.Xh)}ag(){const t=[];for(let i=0;i<this.sg.length;i++)t.push(this.sg[i].ss());this.eg=(new Date).valueOf(),this.h.B(o.q.Ya,t),this.h.B(o.q.Ga,this.eg)}gg(){(this.h.I(o.q.Ga)||0)>this.eg?this.Zh():this.ig()}Rs(t){let i=!1;if(null!=t&&t.triggers){this.ig();const s={},e={};this.sg=[];for(let r=0;r<t.triggers.length;r++){const h=ut.fromJson(t.triggers[r]);null!=this.Yh[h.id]&&(h.Bh(this.Yh[h.id]),s[h.id]=this.Yh[h.id]),null!=this.Xh[h.id]&&(e[h.id]=this.Xh[h.id]);for(let t=0;t<h.Th.length;t++)if(h.Th[t].ec(V.ks,null)){i=!0;break}null!=h&&this.sg.push(h)}ii(this.Yh,s)||(this.Yh=s,this.h.B(o.q.Na,this.Yh)),ii(this.Xh,e)||(this.Xh=e,this.h.B(o.q.Ca,this.Xh)),this.ag(),i&&(r.D.info("Trigger with test condition found, firing test."),this.je(V.ks)),this.je(V.OPEN);const h=this.Kh;this.Kh=[];for(let t=0;t<h.length;t++)this.je.apply(this,h[t])}}async hg(t,i,s,e,h){const o=e=>{this.ig();const h=(new Date).valueOf();if(!t.Lh(i))return!1===navigator.onLine&&t.type===ut.gi.ci&&e.imageUrl?(r.D.info(`Not showing ${t.type} trigger action ${t.id} due to offline state.`),void this.Uh.qe(t.id,InAppMessage.Oe.Yi)):void(t.Mh(h)&&this.fg(t,h,s)?(this.yt.St([e]),this.cg(t,h)):r.D.info(`Not displaying trigger ${t.id} because display time fell outside of the acceptable time window.`));t.type===ut.gi.Rh?this.Uh.qe(t.id,InAppMessage.Oe.pi):this.Uh.qe(t.id,InAppMessage.Oe.Xi)},n=()=>{this.ig();const o=h.pop();if(null!=o)if(this.ug(o,i,s,e,h),o.Lh(i)){let t=`Server aborted in-app message display, but the timeout on fallback trigger ${o.id} has already elapsed.`;h.length>0&&(t+=" Continuing to fall back."),r.D.info(t),this.Uh.qe(o.id,InAppMessage.Oe.Xi),n()}else{r.D.info(`Server aborted in-app message display. Falling back to lower priority ${o.type} trigger action ${t.id}.`);const n=1e3*o.Ph-((new Date).valueOf()-i);n>0?this.Qh.push(setTimeout((()=>{this.hg(o,i,s,e,h)}),n)):this.hg(o,i,s,e,h)}};switch(t.type){case ut.gi.ci:const h=it(t.data);if(null==h){r.D.error(`Could not parse trigger data for trigger ${t.id}, ignoring.`),this.Uh.qe(t.id,InAppMessage.Oe.fi);break}let l=await this.Uh.Ve(h);if(l){r.D.error(l),n();break}o(h);break;case ut.gi.Rh:const a=ft.fromJson(t.data,o,n,i,t.yi);if(null==a){r.D.error(`Could not parse trigger data for trigger ${t.id}, ignoring.`),this.Uh.qe(t.id,InAppMessage.Oe.fi);break}this.Uh.ni(a,s,e);break;default:r.D.error(`Trigger ${t.id} was of unexpected type ${t.type}, ignoring.`),this.Uh.qe(t.id,InAppMessage.Oe.fi)}}je(t,i,s){if(!F(V,t,"Cannot fire trigger action.","TriggerEvents"))return;if(this.si.yl())return r.D.info("Trigger sync is currently in progress, awaiting sync completion before firing trigger event."),void this.Kh.push(arguments);this.gg();const e=(new Date).valueOf(),h=e-this.Vh;let o=!0,n=!0;const l=[];for(let s=0;s<this.sg.length;s++){const r=this.sg[s],h=e+1e3*r.Ph;if(r.Mh(h)&&(null==r.startTime||r.startTime<=e)&&(null==r.endTime||r.endTime>=e)){let s=!1;for(let e=0;e<r.Th.length;e++)if(r.Th[e].ec(t,i)){s=!0;break}s&&(o=!1,this.fg(r,h,t)&&(n=!1,l.push(r)))}}if(o)return void r.D.info(`Trigger event ${t} did not match any trigger conditions.`);if(n)return void r.D.info(`Ignoring ${t} trigger event because a trigger was displayed ${h/1e3}s ago.`);l.sort(((t,i)=>t.priority-i.priority));const a=l.pop();null!=a&&(r.D.info(`Firing ${a.type} trigger action ${a.id} from trigger event ${t}.`),this.ug(a,e,t,s,l),0===a.Ph?this.hg(a,e,t,s,l):this.Qh.push(setTimeout((()=>{this.hg(a,e,t,s,l)}),1e3*a.Ph)))}changeUser(t){if(this.sg=[],this.h.Xs(o.q.Ya),!t){this.Kh=[],this.Vh=null,this.Yh={},this.Xh={};for(let t=0;t<this.Qh.length;t++)clearTimeout(this.Qh[t]);this.Qh=[],this.h.Xs(o.q.va),this.h.Xs(o.q.Na),this.h.Xs(o.q.Ca)}}clearData(){this.sg=[],this.Vh=null,this.Yh={},this.Xh={};for(let t=0;t<this.Qh.length;t++)clearTimeout(this.Qh[t]);this.Qh=[]}fg(t,i,s){if(null==this.Vh)return!0;if(s===V.ks)return r.D.info("Ignoring minimum interval between trigger because it is a test type."),!0;let e=t.Ih;return null==e&&(e=this.Oh),i-this.Vh>=1e3*e}ug(t,i,s,e,r){this.ig(),this.Xh[t.id]=this.Xh[t.id]||[];const h={};let n;h.vi=i,h.og=s,null!=e&&(n=e.ss()),h.ng=n;const l=[];for(let t=0;t<r.length;t++)l.push(r[t].id);h.lg=l,this.Xh[t.id].push(h),this.h.B(o.q.Ca,this.Xh)}cg(t,i){this.ig(),t.Bh(i),this.Vh=i,this.h.B(o.q.va,i),this.Yh[t.id]=i,this.h.B(o.q.Na,this.Yh)}}
|
package/src/ui/js/attach-css.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import e,{OPTIONS as
|
|
1
|
+
import e,{OPTIONS as T}from"../../managers/braze-instance.js";export function attachCSS(n,t,o){const c=n||document.querySelector("head"),s=`ab-${t}-css-definitions-${"4.2.0".replace(/\./g,"-")}`,a=c.ownerDocument||document;if(null==a.getElementById(s)){const n=a.createElement("style");n.innerHTML=o,n.id=s;const t=e.nn(T.ao);null!=t&&n.setAttribute("nonce",t),c.appendChild(n)}}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import e,{OPTIONS as
|
|
1
|
+
import e,{OPTIONS as T}from"../../managers/braze-instance.js";export function loadFontAwesome(){if(e.nn(T.vo))return;const t="https://use.fontawesome.com/7f85a56ba4.css";if(!(null!==document.querySelector('link[rel=stylesheet][href="'+t+'"]'))){const e=document.createElement("link");e.setAttribute("rel","stylesheet"),e.setAttribute("href",t),document.getElementsByTagName("head")[0].appendChild(e)}}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{isArray as p}from"./code-utils.js";export default class Yt{constructor(){}tf(){}ef(){}
|
|
1
|
+
import{isArray as p}from"./code-utils.js";export default class Yt{constructor(){}tf(){}ef(){}Zo(t){}static rf(t,e){if(t&&e)if(t=t.toLowerCase(),p(e.if)){for(let r=0;r<e.if.length;r++)if(-1!==t.indexOf(e.if[r].toLowerCase()))return e.identity}else if(-1!==t.indexOf(e.if.toLowerCase()))return e.identity}}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import r from"../../shared-lib/braze-shared-lib.js";import{decodeBrazeActions as Zt}from"./string-utils.js";import{BRAZE_ACTION_URI_REGEX as
|
|
1
|
+
import r from"../../shared-lib/braze-shared-lib.js";import{decodeBrazeActions as Zt}from"./string-utils.js";import{BRAZE_ACTION_URI_REGEX as O,isValidBrazeActionType as $t,isValidBrazeActionJson as P}from"./validation-utils.js";export const BRAZE_ACTIONS={types:{ue:"container",logCustomEvent:"logCustomEvent",setEmailNotificationSubscriptionType:"setEmailNotificationSubscriptionType",setPushNotificationSubscriptionType:"setPushNotificationSubscriptionType",setCustomUserAttribute:"setCustomUserAttribute",requestPushPermission:"requestPushPermission",addToSubscriptionGroup:"addToSubscriptionGroup",removeFromSubscriptionGroup:"removeFromSubscriptionGroup",addToCustomAttributeArray:"addToCustomAttributeArray",removeFromCustomAttributeArray:"removeFromCustomAttributeArray",de:"openLink",pe:"openLinkInWebView"},properties:{type:"type",me:"steps",fe:"args"}};export const INELIGIBLE_BRAZE_ACTION_URL_ERROR_TYPES={We:"unknownBrazeAction",Ze:"noPushPrompt"};export const ineligibleBrazeActionURLErrorMessage=(t,o)=>{switch(t){case INELIGIBLE_BRAZE_ACTION_URL_ERROR_TYPES.We:return`${o} contains an unknown braze action type and will not be displayed.`;case INELIGIBLE_BRAZE_ACTION_URL_ERROR_TYPES.Ze:return`${o} contains a push prompt braze action, but is not eligible for a push prompt. Ignoring.`;default:return""}};export function getDecodedBrazeAction(t){try{let o=t.match(O)[0].length;const e=t.substring(o);if(o>t.length-1||!e)return void r.D.error(`Did not find base64 encoded brazeAction in url to process : ${t}`);const n=Zt(e);return n?JSON.parse(n):void r.D.error(`Failed to decode base64 encoded brazeAction: ${e}`)}catch(o){return void r.D.error(`Failed to process brazeAction URL ${t} : ${o.message}`)}}function to(t,o){let r=!1;for(const e of o)if(r=r||t(e),r)return!0;return!1}export function containsUnknownBrazeAction(t){try{const o=t[BRAZE_ACTIONS.properties.type];return o===BRAZE_ACTIONS.types.ue?to(containsUnknownBrazeAction,t[BRAZE_ACTIONS.properties.me]):!$t(o)}catch(t){return!0}}export function containsPushPrimerBrazeAction(t){if(!P(t))return!1;const o=t[BRAZE_ACTIONS.properties.type];return o===BRAZE_ACTIONS.types.ue?to(containsPushPrimerBrazeAction,t[BRAZE_ACTIONS.properties.me]):o===BRAZE_ACTIONS.types.requestPushPermission}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import ti from"./client-hints-parser.js";import ni from"./user-agent-parser.js";import{Browsers as ri,OperatingSystems as ot}from"./device-constants.js";class si{constructor(){const t=navigator.userAgentData?ti:ni;this.dg=new t,this.userAgent=navigator.userAgent,this.browser=this.dg.tf(),this.version=this.dg.ef(),this.
|
|
1
|
+
import ti from"./client-hints-parser.js";import ni from"./user-agent-parser.js";import{Browsers as ri,OperatingSystems as ot}from"./device-constants.js";class si{constructor(){const t=navigator.userAgentData?ti:ni;this.dg=new t,this.userAgent=navigator.userAgent,this.browser=this.dg.tf(),this.version=this.dg.ef(),this.Zo().then((t=>this.OS=t)),this.language=(navigator.userLanguage||navigator.language||navigator.browserLanguage||navigator.systemLanguage||"").toLowerCase(),this.Vo=si.Sg(this.userAgent)}bg(){return this.browser!==ri.vg||this.version>8}ka(){return this.browser===ri.yg}Xo(){return this.OS||null}Zo(){return this.OS?Promise.resolve(this.OS):this.dg.Zo(si.pg).then((t=>(this.OS=t,t)))}static Sg(t){t=t.toLowerCase();const i=["googlebot","bingbot","slurp","duckduckbot","baiduspider","yandex","facebookexternalhit","sogou","ia_archiver","https://github.com/prerender/prerender","aolbuild","bingpreview","msnbot","adsbot","mediapartners-google","teoma"];for(let n=0;n<i.length;n++)if(-1!==t.indexOf(i[n]))return!0;return!1}}si.pg=[{string:navigator.platform,if:"Win",identity:ot.mg},{string:navigator.platform,if:"Mac",identity:ot.Bg},{string:navigator.platform,if:"BlackBerry",identity:"BlackBerry"},{string:navigator.platform,if:"FreeBSD",identity:"FreeBSD"},{string:navigator.platform,if:"OpenBSD",identity:"OpenBSD"},{string:navigator.platform,if:"Nintendo",identity:"Nintendo"},{string:navigator.platform,if:"SunOS",identity:"SunOS"},{string:navigator.platform,if:"PlayStation",identity:"PlayStation"},{string:navigator.platform,if:"X11",identity:"X11"},{string:navigator.userAgent,if:["iPhone","iPad","iPod"],identity:ot.ln},{string:navigator.platform,if:"Pike v",identity:ot.ln},{string:navigator.userAgent,if:["Web0S"],identity:"WebOS"},{string:navigator.platform,if:["Linux armv7l","Android"],identity:ot.Og},{string:navigator.userAgent,if:["Android"],identity:ot.Og},{string:navigator.platform,if:"Linux",identity:"Linux"}];const et=new si;export{et as default,si as BrowserDetector};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import Yt from"./base-device-parser.js";import{Browsers as ri}from"./device-constants.js";export default class ti extends Yt{constructor(){if(super(),this.userAgentData=navigator.userAgentData,this.userAgentData){const t=this.
|
|
1
|
+
import Yt from"./base-device-parser.js";import{Browsers as ri}from"./device-constants.js";export default class ti extends Yt{constructor(){if(super(),this.userAgentData=navigator.userAgentData,this.userAgentData){const t=this.ic();this.browser=t.browser||"Unknown Browser",this.version=t.version||"Unknown Version"}}tf(){return this.browser}ef(){return this.version}Zo(t){if(this.OS)return Promise.resolve(this.OS);const r=r=>{for(let s=0;s<t.length;s++){const e=ti.rf(r,t[s]);if(e)return this.OS=e,this.OS}return r};return this.userAgentData.platform?Promise.resolve(r(this.userAgentData.platform)):this.nc().then((t=>r(t.platform))).catch((()=>navigator.platform))}ic(){const t={},r=this.userAgentData.brands;if(r&&r.length)for(const s of r){const r=this.oc(ri),e=s.brand.match(r);if(e&&e.length>0){t.browser=e[0],t.version=s.version;break}}return t}oc(t){const r=[];for(const s in t)t[s]!==ri.vg&&r.push(t[s]);return new RegExp("("+r.join("|")+")","i")}nc(){return this.userAgentData.getHighEntropyValues?this.userAgentData.getHighEntropyValues(["platform"]):Promise.reject()}}
|
package/src/util/dom-utils.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export function _isInView(t,n,e,s){if(null==t)return!1;n=n||!1,e=e||!1;const i=t.getBoundingClientRect();return null!=i&&((i.top>=0&&i.top<=(window.innerHeight||document.documentElement.clientHeight)||!n)&&(i.left>=0||!s)&&(i.bottom>=0&&i.bottom<=(window.innerHeight||document.documentElement.clientHeight)||!e)&&(i.right<=(window.innerWidth||document.documentElement.clientWidth)||!s))}export const DOMUtils={
|
|
1
|
+
export function _isInView(t,n,e,s){if(null==t)return!1;n=n||!1,e=e||!1;const i=t.getBoundingClientRect();return null!=i&&((i.top>=0&&i.top<=(window.innerHeight||document.documentElement.clientHeight)||!n)&&(i.left>=0||!s)&&(i.bottom>=0&&i.bottom<=(window.innerHeight||document.documentElement.clientHeight)||!e)&&(i.right<=(window.innerWidth||document.documentElement.clientWidth)||!s))}export const DOMUtils={cu:null,eo:_isInView};export const DIRECTIONS={Te:"up",$e:"down",ot:"left",et:"right"};export function supportsPassive(){if(null==DOMUtils.cu){DOMUtils.cu=!1;try{const t=Object.defineProperty({},"passive",{get:()=>{DOMUtils.cu=!0}});window.addEventListener("testPassive",null,t),window.removeEventListener("testPassive",null,t)}catch(t){}}return DOMUtils.cu}export function addPassiveEventListener(t,n,e){t.addEventListener(n,e,!!supportsPassive()&&{passive:!0})}export function topIsInView(t){return DOMUtils.eo(t,!0,!1,!1)}export function bottomIsInView(t){return DOMUtils.eo(t,!1,!0,!1)}export function clickElement(t){if(t.onclick){const n=document.createEvent("MouseEvents");n.initEvent("click",!0,!0),t.onclick.apply(t,[n])}}export function detectSwipe(t,n,e){let s=null,i=null;addPassiveEventListener(t,"touchstart",(t=>{s=t.touches[0].clientX,i=t.touches[0].clientY})),addPassiveEventListener(t,"touchmove",(o=>{if(null==s||null==i)return;const l=s-o.touches[0].clientX,u=i-o.touches[0].clientY;Math.abs(l)>Math.abs(u)&&Math.abs(l)>=25?((l>0&&n===DIRECTIONS.ot||l<0&&n===DIRECTIONS.et)&&e(o),s=null,i=null):Math.abs(u)>=25&&((u>0&&n===DIRECTIONS.Te&&t.scrollTop===t.scrollHeight-t.offsetHeight||u<0&&n===DIRECTIONS.$e&&0===t.scrollTop)&&e(o),s=null,i=null)}))}export function buildSvg(t,n,e){const s="http://www.w3.org/2000/svg",i=document.createElementNS(s,"svg");i.setAttribute("viewBox",t),i.setAttribute("xmlns",s);const o=document.createElementNS(s,"path");return o.setAttribute("d",n),null!=e&&o.setAttribute("fill",e),i.appendChild(o),i}
|
package/src/util/key-codes.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export const KeyCodes={fo:32,oo:9,co:13,
|
|
1
|
+
export const KeyCodes={fo:32,oo:9,co:13,Ci:27};
|
package/src/util/net.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import r from"../../shared-lib/braze-shared-lib.js";import Rt from"../models/backend-errors.js";const b={
|
|
1
|
+
import r from"../../shared-lib/braze-shared-lib.js";import Rt from"../models/backend-errors.js";const b={Hs:t=>{let e,o;try{const n=()=>{r.D.error("This browser does not have any supported ajax options!")};if(window.XMLHttpRequest?(e=new XMLHttpRequest,e||n()):n(),null!=e){const r=()=>{"function"==typeof t.error&&t.error(e.status),"function"==typeof t.kl&&t.kl(!1)};e.onload=()=>{let o=!1;if(4===e.readyState)if(o=e.status>=200&&e.status<300||304===e.status,o){if("function"==typeof t.S){let o,r;try{o=JSON.parse(e.responseText),r=e.getAllResponseHeaders()}catch(o){const n={error:""===e.responseText?Rt.fa:Rt.ma,response:e.responseText};t.S(n,r)}o&&t.S(o,r)}"function"==typeof t.kl&&t.kl(!0)}else r()},e.onerror=()=>{r()},e.ontimeout=()=>{r()},o=JSON.stringify(t.data),e.open("POST",t.url,!0),e.setRequestHeader("Content-type","application/json"),e.setRequestHeader("X-Requested-With","XMLHttpRequest");const n=t.headers||[];for(const t of n)e.setRequestHeader(t[0],t[1]);e.send(o)}}catch(t){r.D.error(`Network request error: ${t.message}`)}}};export const readResponseHeaders=t=>{let e={};const o=t.toString().split("\r\n");if(!o)return e;let r,n;for(const t of o)t&&(r=t.slice(0,t.indexOf(":")).toLowerCase().trim(),n=t.slice(t.indexOf(":")+1).trim(),e[r]=n);return e};export default b;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import Yt from"./base-device-parser.js";import{Browsers as ri,OperatingSystems as ot}from"./device-constants.js";export default class ni extends Yt{constructor(){super(),this.
|
|
1
|
+
import Yt from"./base-device-parser.js";import{Browsers as ri,OperatingSystems as ot}from"./device-constants.js";export default class ni extends Yt{constructor(){super(),this.au=ni.du(navigator.userAgent||"")}tf(){return this.au[0]||"Unknown Browser"}ef(){return this.au[1]||"Unknown Version"}Zo(r){for(let e=0;e<r.length;e++){let n=r[e].string,i=ni.rf(n,r[e]);if(i)return i===ot.Bg&&navigator.maxTouchPoints>1&&(i=ot.ln),Promise.resolve(i)}return Promise.resolve(navigator.platform)}static du(r){let e,n=r.match(/(samsungbrowser|tizen|roku|konqueror|icab|crios|opera|ucbrowser|chrome|safari|firefox|camino|msie|trident(?=\/))\/?\s*(\.?\d+(\.\d+)*)/i)||[];if(/trident/i.test(n[1]))return e=/\brv[ :]+(\.?\d+(\.\d+)*)/g.exec(r)||[],[ri.vg,e[1]||""];if(-1!==r.indexOf("(Web0S; Linux/SmartTV)"))return["LG Smart TV",null];if(-1!==r.indexOf("CrKey"))return["Chromecast",null];if(-1!==r.indexOf("BRAVIA")||-1!==r.indexOf("SonyCEBrowser")||-1!==r.indexOf("SonyDTV"))return["Sony Smart TV",null];if(-1!==r.indexOf("PhilipsTV"))return["Philips Smart TV",null];if(r.match(/\b(Roku)\b/))return["Roku",null];if(r.match(/\bAFTM\b/))return["Amazon Fire Stick",null];if(n[1]===ri.rE&&(e=r.match(/\b(OPR|Edge|EdgA|Edg|UCBrowser)\/(\.?\d+(\.\d+)*)/),null!=e))return e=e.slice(1),e[0]=e[0].replace("OPR",ri.EE),e[0]=e[0].replace("EdgA",ri.eE),"Edg"===e[0]&&(e[0]=ri.eE),[e[0],e[1]];if(n[1]===ri.yg&&(e=r.match(/\b(EdgiOS)\/(\.?\d+(\.\d+)*)/),null!=e))return e=e.slice(1),e[0]=e[0].replace("EdgiOS",ri.eE),[e[0],e[1]];if(n=n[2]?[n[1],n[2]]:[null,null],n[0]===ri.yg&&null!=(e=r.match(/version\/(\.?\d+(\.\d+)*)/i))&&n.splice(1,1,e[1]),null!=(e=r.match(/\b(UCBrowser)\/(\.?\d+(\.\d+)*)/))&&n.splice(1,1,e[2]),n[0]===ri.EE&&null!=(e=r.match(/mini\/(\.?\d+(\.\d+)*)/i)))return["Opera Mini",e[1]||""];if(n[0]){const r=n[0].toLowerCase();"msie"===r&&(n[0]=ri.vg),"crios"===r&&(n[0]=ri.rE),"tizen"===r&&(n[0]="Samsung Smart TV",n[1]=null),"samsungbrowser"===r&&(n[0]="Samsung Browser")}return n}}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{isArray as p,isDate as yt,isObject as Jt,keys as
|
|
1
|
+
import{isArray as p,isDate as yt,isObject as Jt,keys as rr}from"./code-utils.js";import{getByteLength as U}from"./string-utils.js";import r from"../../shared-lib/braze-shared-lib.js";import{toValidBackendTimeString as Nt}from"./date-utils.js";import{BRAZE_ACTIONS as _}from"./braze-actions.js";export const CUSTOM_DATA_REGEX=/^[^\x00-\x1F\x22]+$/;export const EMAIL_ADDRESS_REGEX=new RegExp(/^.+@.+\..+$/);export const CUSTOM_PROPERTIES_MAX_SIZE_BYTES=51200;export const CUSTOM_PROPERTIES_MAX_SIZE_STRING="50KB";export const BRAZE_ACTION_URI_REGEX=/^brazeActions:\/\/v\d+\//;export function _validatePropertyType(e){const t=typeof e;return null==e||"number"===t||"boolean"===t||yt(e)||"string"===t}export function _validateNestedProperties(e,t){if(p(e)&&p(t)){for(let r=0;r<e.length&&r<t.length;r++)if(yt(e[r])&&(t[r]=Nt(e[r])),!_validateNestedProperties(e[r],t[r]))return!1}else{if(!Jt(e))return _validatePropertyType(e);for(const r of rr(e))if(yt(e[r])&&(t[r]=Nt(e[r])),!_validateNestedProperties(e[r],t[r]))return!1}return!0}export function _validateEventPropertyValue(e,t,n,o){let i;return i=Jt(e)||p(e)?_validateNestedProperties(e,t):_validatePropertyType(e),i||r.D.error(`Cannot ${n} because ${o} "${e}" is invalid.`),i}export function validateStandardString(e,t,n,o){const i="string"==typeof e||null===e&&o;return i||r.D.error(`Cannot ${t} because ${n} "${e}" is invalid.`),i}export function validateCustomString(e,t,n){const o=null!=e&&"string"==typeof e&&(""===e||e.match(CUSTOM_DATA_REGEX));return o||r.D.error(`Cannot ${t} because ${n} "${e}" is invalid.`),o}export function validateCustomProperties(e,t,n,o,i){if(null==e&&(e={}),"object"!=typeof e||p(e))return r.D.error(`${t} requires that ${n} be an object. Ignoring ${i}.`),[!1,null];const a=JSON.stringify(e);if(U(a)>51200)return r.D.error(`Could not ${o} because ${n} was greater than the max size of 50KB.`),[!1,null];let s;try{s=JSON.parse(a)}catch(e){return r.D.error(`Could not ${o} because ${n} did not contain valid JSON.`),[!1,null]}for(let t in e){if(!validateCustomString(t,o,`the ${i} property name`))return[!1,null];const r=e[t];if(null==r){delete e[t],delete s[t];continue}yt(r)&&(s[t]=Nt(r));if(!_validateEventPropertyValue(r,s[t],o,`the ${i} property "${t}"`))return[!1,null]}return[!0,s]}export function isValidEmail(e){return"string"==typeof e&&null!=e.toLowerCase().match(EMAIL_ADDRESS_REGEX)}export function isValidBrazeActionJson(e){if(!(_.properties.type in e))return!1;switch(e[_.properties.type]){case _.types.ue:if(_.properties.me in e)return!0;break;case _.types.logCustomEvent:case _.types.setEmailNotificationSubscriptionType:case _.types.setPushNotificationSubscriptionType:case _.types.setCustomUserAttribute:case _.types.addToSubscriptionGroup:case _.types.removeFromSubscriptionGroup:case _.types.addToCustomAttributeArray:case _.types.removeFromCustomAttributeArray:case _.types.de:case _.types.pe:if(_.properties.fe in e)return!0;break;case _.types.requestPushPermission:return!0;default:return!1}return!1}export function isValidBrazeActionType(e){let t=!1;return Object.keys(_.types).forEach((r=>{_.types[r]!==e.toString()||(t=!0)})),t}
|
package/src/util/window-utils.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export const ORIENTATION={PORTRAIT:0,LANDSCAPE:1};export function _isPhone(){return screen.width<=600}export function _getOrientation(){if("orientation"in window)return 90===Math.abs(window.orientation)||270===window.orientation?ORIENTATION.LANDSCAPE:ORIENTATION.PORTRAIT;if("screen"in window){let n=window.screen.orientation||screen.mozOrientation||screen.msOrientation;return null!=n&&"object"==typeof n&&(n=n.type),"landscape-primary"===n||"landscape-secondary"===n?ORIENTATION.LANDSCAPE:ORIENTATION.PORTRAIT}return ORIENTATION.PORTRAIT}export function _openUri(n,e,r){e||null!=r&&r.metaKey?window.open(n):window.location=n}export function _getCurrentUrl(){return window.location.href}export const WindowUtils={openUri:_openUri,so:_isPhone,io:_getOrientation,
|
|
1
|
+
export const ORIENTATION={PORTRAIT:0,LANDSCAPE:1};export function _isPhone(){return screen.width<=600}export function _getOrientation(){if("orientation"in window)return 90===Math.abs(window.orientation)||270===window.orientation?ORIENTATION.LANDSCAPE:ORIENTATION.PORTRAIT;if("screen"in window){let n=window.screen.orientation||screen.mozOrientation||screen.msOrientation;return null!=n&&"object"==typeof n&&(n=n.type),"landscape-primary"===n||"landscape-secondary"===n?ORIENTATION.LANDSCAPE:ORIENTATION.PORTRAIT}return ORIENTATION.PORTRAIT}export function _openUri(n,e,r){e||null!=r&&r.metaKey?window.open(n):window.location=n}export function _getCurrentUrl(){return window.location.href}export const WindowUtils={openUri:_openUri,so:_isPhone,io:_getOrientation,Tn:_getCurrentUrl};
|