@froomle/frontend-sdk 0.0.7 → 0.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/dist/froomle.global.js +3 -3
- package/dist/index.cjs +3 -3
- package/dist/index.d.cts +1 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +3 -3
- package/dist/testing/testing.cjs +5 -5
- package/dist/testing/testing.cjs.map +1 -1
- package/dist/testing/testing.d.cts +7 -2
- package/dist/testing/testing.d.ts +7 -2
- package/dist/testing/testing.js +5 -5
- package/dist/testing/testing.js.map +1 -1
- package/package.json +2 -1
|
@@ -40,12 +40,13 @@ declare class SimpleFuture<T> {
|
|
|
40
40
|
declare class RecoBackendV2 {
|
|
41
41
|
constructor()
|
|
42
42
|
protected static _environment: null | string
|
|
43
|
-
protected static _device_id:
|
|
43
|
+
protected static _device_id: string
|
|
44
44
|
protected static _user_id: null | string
|
|
45
45
|
protected static _consent: number
|
|
46
46
|
protected static _req_domain: string
|
|
47
47
|
protected static _page_visit: null | string
|
|
48
48
|
protected static _page_view: null | string
|
|
49
|
+
protected static _channel: string
|
|
49
50
|
protected static _requestUri(): string
|
|
50
51
|
protected static noConsentBody(): any
|
|
51
52
|
protected static buildRequestBody(lists: {
|
|
@@ -64,6 +65,7 @@ declare class RecoBackendV2 {
|
|
|
64
65
|
list_size: number
|
|
65
66
|
}[]): SimpleFuture<Recommendations>
|
|
66
67
|
static setConsent(consent: number): void
|
|
68
|
+
static setChannel(channel: string): void
|
|
67
69
|
static setPageVisit(page: string): void
|
|
68
70
|
static setEnvironment(env: string): void
|
|
69
71
|
static setDeviceId(id: string): void
|
|
@@ -74,8 +76,10 @@ declare class RecoBackendV2 {
|
|
|
74
76
|
static getEnvironment(): null | string
|
|
75
77
|
static getPageVisit(): null | string
|
|
76
78
|
static getUserId(): null | string
|
|
77
|
-
static getDeviceId():
|
|
79
|
+
static getDeviceId(): string
|
|
78
80
|
static getPageView(): null | string
|
|
81
|
+
static getConsent(): number
|
|
82
|
+
static getChannel(): string
|
|
79
83
|
}
|
|
80
84
|
|
|
81
85
|
declare class FroomleSdk {
|
|
@@ -84,6 +88,7 @@ declare class FroomleSdk {
|
|
|
84
88
|
protected static _page_view_set: boolean
|
|
85
89
|
protected static registered: boolean
|
|
86
90
|
protected static register(): void
|
|
91
|
+
static buildScriptTag(): string
|
|
87
92
|
static setEnvironment(env: string): void
|
|
88
93
|
static setDeviceId(id: string): void
|
|
89
94
|
static setUserId(id: string): void
|
|
@@ -40,12 +40,13 @@ declare class SimpleFuture<T> {
|
|
|
40
40
|
declare class RecoBackendV2 {
|
|
41
41
|
constructor()
|
|
42
42
|
protected static _environment: null | string
|
|
43
|
-
protected static _device_id:
|
|
43
|
+
protected static _device_id: string
|
|
44
44
|
protected static _user_id: null | string
|
|
45
45
|
protected static _consent: number
|
|
46
46
|
protected static _req_domain: string
|
|
47
47
|
protected static _page_visit: null | string
|
|
48
48
|
protected static _page_view: null | string
|
|
49
|
+
protected static _channel: string
|
|
49
50
|
protected static _requestUri(): string
|
|
50
51
|
protected static noConsentBody(): any
|
|
51
52
|
protected static buildRequestBody(lists: {
|
|
@@ -64,6 +65,7 @@ declare class RecoBackendV2 {
|
|
|
64
65
|
list_size: number
|
|
65
66
|
}[]): SimpleFuture<Recommendations>
|
|
66
67
|
static setConsent(consent: number): void
|
|
68
|
+
static setChannel(channel: string): void
|
|
67
69
|
static setPageVisit(page: string): void
|
|
68
70
|
static setEnvironment(env: string): void
|
|
69
71
|
static setDeviceId(id: string): void
|
|
@@ -74,8 +76,10 @@ declare class RecoBackendV2 {
|
|
|
74
76
|
static getEnvironment(): null | string
|
|
75
77
|
static getPageVisit(): null | string
|
|
76
78
|
static getUserId(): null | string
|
|
77
|
-
static getDeviceId():
|
|
79
|
+
static getDeviceId(): string
|
|
78
80
|
static getPageView(): null | string
|
|
81
|
+
static getConsent(): number
|
|
82
|
+
static getChannel(): string
|
|
79
83
|
}
|
|
80
84
|
|
|
81
85
|
declare class FroomleSdk {
|
|
@@ -84,6 +88,7 @@ declare class FroomleSdk {
|
|
|
84
88
|
protected static _page_view_set: boolean
|
|
85
89
|
protected static registered: boolean
|
|
86
90
|
protected static register(): void
|
|
91
|
+
static buildScriptTag(): string
|
|
87
92
|
static setEnvironment(env: string): void
|
|
88
93
|
static setDeviceId(id: string): void
|
|
89
94
|
static setUserId(id: string): void
|
package/dist/testing/testing.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
var s=class
|
|
2
|
-
`;t+=" ";let
|
|
3
|
-
`),l+=t+
|
|
4
|
-
`+t+"}",l;break;case"string":return e;default:return String(e)}}static get __name__(){return"js.Boot"}get __class__(){return Z}};ye.__toStr={}.toString;var Ut=s.$global,
|
|
5
|
-
`),I=[],_=0,g=c;for(;_<g.length;){let y=g[_];++_,y!=""&&I.push(y)}c=I;let w=new Be;r.responseHeaders=w;let x=0;for(;x<c.length;){let y=c[x];++x;let D=y.split(": "),V=D.shift(),b=D.length==1?D[0]:D.join(": ");b=j.ltrim(j.rtrim(b)),r.responseHeaders.inst.set(V,b)}r.success(J.ofData(t.response))}else if(u==null||u==0&&t.response==null)r.req=null,r.onError("Failed to connect or resolve host");else if(u==null){r.req=null;let c=t.response!=null?J.ofData(t.response):null;r.responseBytes=c,r.onError("Http Error #"+t.status)}else switch(u){case 12007:r.req=null,r.onError("Unknown host");break;case 12029:r.req=null,r.onError("Failed to connect to host");break;default:r.req=null;let c=t.response!=null?J.ofData(t.response):null;r.responseBytes=c,r.onError("Http Error #"+t.status)}};this.async&&(t.onreadystatechange=n);let l,o=this.postData,i=this.postBytes;if(o==null)if(i==null)l=null;else{let a=i;l=new Blob([a.b.bufferValue])}else i==null?l=o:l=null;if(l!=null)e=!0;else{let a=0,u=this.params;for(;a<u.length;){let c=u[a];++a,l==null?l="":l=(l==null?"null":C.string(l))+"&";let I=c.name,_=(l==null?"null":C.string(l))+encodeURIComponent(I)+"=",g=c.value;l=_+encodeURIComponent(g)}}try{if(e)t.open("POST",this.url,this.async);else if(l!=null){let a=this.url.split("?").length<=1;t.open("GET",this.url+(a?"?":"&")+(l==null?"null":C.string(l)),this.async),l=null}else t.open("GET",this.url,this.async);t.responseType="arraybuffer"}catch(a){let u=k.caught(a).unwrap();this.req=null,this.onError(u.toString());return}t.withCredentials=this.withCredentials,!Ve.exists(this.headers,function(a){return a.name=="Content-Type"})&&e&&this.postData==null&&t.setRequestHeader("Content-Type","application/x-www-form-urlencoded");let d=0,m=this.headers;for(;d<m.length;){let a=m[d];++d,t.setRequestHeader(a.name,a.value)}t.send(l),this.async||n(null)}static get __name__(){return"haxe.http.HttpJs"}static get __super__(){return F}get __class__(){return He}};K.prototype.async=null;K.prototype.withCredentials=null;K.prototype.responseHeaders=null;K.prototype.req=null;var kr=s.$global,U=s.global("$hxClasses").SimpleFuture=class Oe extends s.inherits(){[s.new](){this._isFinished=!1}trigger(e){this._result=e,this._isFinished=!0,this._callback!=null&&this._callback(this._result)}then(e){this._callback=e,this._isFinished&&e(this._result)}static get __name__(){return"SimpleFuture"}get __class__(){return Oe}};U.prototype._callback=null;U.prototype._result=null;U.prototype._isFinished=null;var Dr=s.$global,v=s.global("$hxClasses").Reflect=class Te{static field(e,t){try{return e[t]}catch{return null}}static getProperty(e,t){let r;if(e==null)return null;{let n;return e.__properties__?(r=e.__properties__["get_"+t],n=r):n=!1,n?e[r]():e[t]}}static setProperty(e,t,r){let n,l;e.__properties__?(n=e.__properties__["set_"+t],l=n):l=!1,l?e[n](r):e[t]=r}static fields(e){let t=[];if(e!=null){let n=Object.prototype.hasOwnProperty;for(var r in e)r!="__id__"&&r!="hx__closures__"&&n.call(e,r)&&t.push(r)}return t}static get __name__(){return"Reflect"}get __class__(){return Te}};var Tr=s.$global,p=s.global("$hxClasses")["internal.RecoBackendV2"]=class f extends s.inherits(){[s.new](){}static _requestUri(){return"https://"+f._req_domain+"/api/"+f._environment+"/recommendations/requests"}static noConsentBody(){return{device_id:"no-consent",user_group:"no-consent",version:"no-consent"}}static buildRequestBody(e){let t={lists:e,page_type:f._page_visit!=null?f._page_visit:f._page_view,channel:"www-desktop"};if(f._consent==0){let r=f.noConsentBody(),n=0,l=v.fields(r);for(;n<l.length;){let o=l[n];++n,t[o]=v.field(r,o)}}else f._user_id!=null?t.user_id=f._user_id:t.device_id=f._device_id;return t}static _requestRecos(e){let t=new U,r=null,n=new K(f._requestUri());n.setHeader("Content-Type","application/json"),n.setPostData(JSON.stringify(f.buildRequestBody(e))),n.onError=function(i){throw k.thrown("HTTP Request Error: "+i)},n.onStatus=function(i){if(i<200||i>=300)throw k.thrown("HTTP Status Error: "+i)};try{n.request(!1)}catch(i){let d=k.caught(i).unwrap();throw k.thrown("Failed to execute synchronous request: "+C.string(d))}let l=function(i){let d=JSON.parse(i),m=G.fromRequestData(d);t.trigger(m)},o=n.get_responseData();return o!=null?l(o):n.onData=l,t}static getRawRecommendations(e){return f._requestRecos(e)}static setConsent(e){e>2&&(e=2),f._consent=e}static setPageVisit(e){f._page_visit=e}static setEnvironment(e){f._environment=e}static setDeviceId(e){f._device_id=e}static setUserId(e){f._user_id=e}static setRequestDomain(e){f._req_domain=e}static setPageView(e){f._page_view=e}static getRequestDomain(){return f._req_domain}static getEnvironment(){return f._environment}static getPageVisit(){return f._page_visit}static getUserId(){return f._user_id}static getDeviceId(){return f._device_id}static getPageView(){return f._page_view}static get __name__(){return"internal.RecoBackendV2"}get __class__(){return f}};p._environment=null;p._device_id=null;p._user_id=null;p._consent=0;p._req_domain="europe-west1.froomle.com";p._page_visit=null;p._page_view=null;var Xe=function(){};Xe.__isInterface__=!0;var ze=function(){};ze.__isInterface__=!0;var G=s.global("$hxClasses")["internal._RecommendationsInternal"]=class we extends s.inherits(){[s.new](e,t,r,n,l){this.request_id=t,this.user_group=r,this.device_id=e,this.user_id=n,this._lists=l}items(){let e=[],t=0,r=this._lists;for(;t<r.length;){let n=r[t];++t;let l=0,o=n.items;for(;l<o.length;){let i=o[l];++l,e.push(i)}}return e}lists(){return this._lists}getItemsByListName(e){let t=0,r=this._lists;for(;t<r.length;){let n=r[t];if(++t,n.list_name==e)return n}return null}static fromRequestData(e){let t=v.getProperty(e,"lists"),r=[],n=0;for(;n<t.length;){let l=t[n];++n;let o=v.getProperty(l,"items"),i=[],d=0;for(;d<o.length;){let a=o[d];++d,i.push(new re(a))}let m=new W({limit:v.getProperty(l,"limit"),list_key:v.getProperty(l,"list_key"),list_name:v.getProperty(l,"list_name"),list_size:v.getProperty(l,"list_size"),items:i});r.push(m)}return new we(v.getProperty(e,"device_id"),v.getProperty(e,"request_id"),v.getProperty(e,"user_group"),v.getProperty(e,"user_id"),r)}static get __name__(){return"internal._RecommendationsInternal"}static get __interfaces__(){return[ne]}get __class__(){return we}};G.prototype.request_id=null;G.prototype.user_group=null;G.prototype.user_id=null;G.prototype.device_id=null;G.prototype._lists=null;var W=s.global("$hxClasses")["internal._RecommendationsListInternal"]=class Ue extends s.inherits(){[s.new](e){this.items=e.items,this.limit=e.limit,this.list_key=e.list_key,this.list_name=e.list_name,this.list_size=e.list_size}static get __name__(){return"internal._RecommendationsListInternal"}static get __interfaces__(){return[le]}get __class__(){return Ue}};W.prototype.limit=null;W.prototype.list_key=null;W.prototype.list_name=null;W.prototype.list_size=null;W.prototype.items=null;var re=s.global("$hxClasses")["internal._RecommendationItemInternal"]=class Le extends s.inherits(){[s.new](e){this._data={},this.Id=v.getProperty(e,"item_id"),this.RequestId=v.getProperty(e,"request_id"),this.UserGroup=v.getProperty(e,"user_group");let t=0,r=v.fields(e);for(;t<r.length;){let n=r[t];++t,this._data[n]=v.field(e,n)}}get(e){return this._data[e]}static get __name__(){return"internal._RecommendationItemInternal"}static get __interfaces__(){return[ie]}get __class__(){return Le}};re.prototype.Id=null;re.prototype.RequestId=null;re.prototype.UserGroup=null;re.prototype._data=null;var P=s.global("$hxClasses")["internal._RecoBackendV2.RecoBackendV2_Fields_"]=class Re{static getRawRecommendations(e){return p.getRawRecommendations(e)}static setConsent(e){p.setConsent(e)}static setPageVisit(e){p.setPageVisit(e)}static setEnvironment(e){p.setEnvironment(e)}static setDeviceId(e){p.setDeviceId(e)}static setUserId(e){p.setUserId(e)}static setRequestDomain(e){p.setRequestDomain(e)}static setPageView(e){p.setPageView(e)}static getConsent(){Re.getConsent()}static getPageVisit(){p.getPageVisit()}static getEnvironment(){p.getEnvironment()}static getDeviceId(){p.getDeviceId()}static getUserId(){p.getUserId()}static getPageView(){p.getPageView()}static get __name__(){return"internal._RecoBackendV2.RecoBackendV2_Fields_"}get __class__(){return Re}},Ur=P.getRawRecommendations,Lr=P.setConsent,Nr=P.setPageVisit,Mr=P.setEnvironment,jr=P.setDeviceId,Xr=P.setUserId,zr=P.setRequestDomain,Jr=P.setPageView,Kr=P.getConsent,Gr=P.getPageVisit,Wr=P.getEnvironment,Qr=P.getDeviceId,Yr=P.getUserId,Zr=P.getPageView;var ss=s.$global,N=s.global("$hxClasses").FroomleSdk=class q{static register(){q.registered||q._env_set&&(!q._page_visit_set&&!q._page_view_set||(q.registered=!0))}static setEnvironment(e){p.setEnvironment(e),q._env_set=!0,q.register()}static setDeviceId(e){p.setDeviceId(e)}static setUserId(e){p.setUserId(e)}static setConsent(e){p.setConsent(e)}static setPageView(e){p.setPageView(e),q._page_view_set=!0,q.register()}static setPageVisit(e){p.setPageVisit(e),q._page_visit_set=!0,q.register()}static setRequestDomain(e){p.setRequestDomain(e)}static getRawRecommendations(e){return p.getRawRecommendations(e)}static getVersion(){return"0.0.7"}static get __name__(){return"FroomleSdk"}get __class__(){return q}};N._env_set=!1;N._page_visit_set=!1;N._page_view_set=!1;N.registered=!1;var is=s.$global,ge=s.global("$hxClasses")["internal.domHandler.FroomleDomTree"]=class ce extends s.inherits(){[s.new](){}createElement(e){return window.document.createElement(e)}querySelectorAll(e){let t=this.root,r=[],n=t.querySelectorAll(e),l=0,o=n.length;for(;l<o;){let i=l++;r.push(n.item(i))}return r}getRoot(){return this.root}toString(){return this.root.outerHTML}static run(){}static fromHtml(e){return new ce}static fromDocument(){let e=new ce;return e.root=window.document,e}static get __name__(){return"internal.domHandler.FroomleDomTree"}get __class__(){return ce}};ge.prototype.root=null;var us=s.$global,O=s.global("$hxClasses")["internal._ADomNode.ADomNode"]=class ve{static _new(e){return e}static fromElement(e){return e}static create(e,t){return window.document.createElement(t)}static replaceChild(e,t,r){e.replaceChild(t,r)}static get attributes(){return this.get_attributes()}static get_attributes(e){let t=e,r=[],n=0,l=t.attributes.length;for(;n<l;){let o=n++,i=t.attributes.item(o);r.push({name:i.name,value:i.value})}return r}static addChild(e,t){e.appendChild(t)}static removeChild(e,t){e.removeChild(t)}static getAttribute(e,t){return e.getAttribute(t)}static setAttribute(e,t,r){e.setAttribute(t,r)}static getText(e){return e.textContent}static setText(e,t){e.textContent=t}static get children(){return this.get_children()}static get_children(e){let t=[],n=e.children,l=0,o=n.length;for(;l<o;){let i=l++;t.push(n[i])}return t}static querySelectorAll(e,t){let r=e,n=[],l=r.querySelectorAll(t),o=0,i=l.length;for(;o<i;){let d=o++;n.push(l.item(d))}return n}static getFilterKeyValue(e){let t=0,r=ve.get_attributes(e);for(;t<r.length;){let n=r[t];if(++t,n.name.startsWith("data-froomle-reco-filter-"))return{key:n.name.substring(25),value:n.value}}return{key:null,value:null}}static get __name__(){return"internal._ADomNode.ADomNode_Impl_"}get __class__(){return ve}};var ws=s.$global,Je=s.global("$hxClasses")["internal.domHandler.DomDomDom"]=class X extends s.inherits(){[s.new](){}static _fillRecoTargets(e){let t=new U;if(e==null)return t.trigger(!1),t;let r=[],n=e,l=[],o=n.querySelectorAll("*"),i=0,d=o.length;for(;i<d;){let h=i++;l.push(o.item(h))}let m=l,a=0;for(;a<m.length;){let h=m[a];++a;let $=0,R=O.get_attributes(h);for(;$<R.length;){let M=R[$];++$,M.name=="data-froomle-reco"&&r.push(h)}}let u=[],c=0;for(;c<r.length;){let h=r[c];++c,h.getAttribute("data-froomle-request-id")==null&&(h.getAttribute("data-froomle-id")==null||h.getAttribute("data-froomle-id")=="")&&u.push(h)}if(u.length<1)return new U;let I=[],_=[],g="",w="",x="",y=[],D=function(){let h={list_name:g,list_size:y.length,limit:y.length};w!=null&&v.setProperty(h,w,x),I.push(h),_.push(y)},V=function(h,$,R,M){g=h,w=$,x=R,y=[M]},b=0;for(;b<u.length;){let h=u[b];++b;let $=h.getAttribute("data-froomle-reco"),R=O.getFilterKeyValue(h);if(g==""){V($,R.key,R.value,h);continue}else if($==g&&R.key==w&&R.value==x){y.push(h);continue}else{D(),V($,R.key,R.value,h);continue}}return g!=""&&D(),P.getRawRecommendations(I).then(function(h){let $=0,R=h.lists();for(;$<R.length;){let M=R[$],L=$++,T=M,z=T.items.length!=_[L].length,Q=0,pe=T.items;for(;Q<pe.length;){let me=pe[Q],Me=Q++,je=me;X._fillParameters(_[L][Me],je,h.request_id)}}t.trigger(!0)}),t}static _fillParameters(e,t,r){let n=function(c,I,_,g){g==null&&(g="");let w=function(x,y,D){D==null&&(D="fgh");try{y=new te("\\\\[(\\\\w+)\\\\]","g").map(y,function(R){return"."+R.matched(1)}),y=j.replace(y,"[","."),y=j.replace(y,"]",""),B.cca(y,0)==46&&(y=B.substr(y,1,null));let b=y.split("."),S=x.get(b[0]),h=1,$=b.length;for(;h<$;){let R=h++;if(S==null)return null;S instanceof Array&&C.parseInt(b[R])!=null?S=S[C.parseInt(b[R])]:S=v.field(S,b[R])}return S}catch{return D}};try{let x=w(t,_,g);I=="inner"?c.textContent=x:c.setAttribute(I,x)}catch{}};e.setAttribute("data-froomle-id",t.Id),e.setAttribute("data-froomle-request-id",r);let l=e,o=[],i=l.querySelectorAll("*"),d=0,m=i.length;for(;d<m;){let c=d++;o.push(i.item(c))}let a=o,u=0;for(;u<a.length;){let c=a[u];++u;let I=0,_=O.get_attributes(c);for(;I<_.length;){let g=_[I];if(++I,g.name.startsWith("data-froomle-param-")){let w=j.replace(g.name,"data-froomle-param-",""),x=g.value;n(c,w,x)}}}}static _orderElements(e){let t=function(_,g,w){let x=[],y=O.get_children(_),D=0;for(;D<y.length;){let S=y[D];if(++D,S.getAttribute("data-froomle-ordervalue")!=null){x.push(S);let $=O.create(e,"span");$.setAttribute("data-froomle-tmp-node",""),O.replaceChild(_,$,S)}}let V=[],b=0;for(;b<x.length;){let S=x[b];++b,V.push(S.getAttribute("data-froomle-ordervalue"))}return{el:_,key:g,values:V,orderChildren:x,list_name:w}},r=new U,n=e.getRoot(),l=[],o=n.querySelectorAll("*"),i=0,d=o.length;for(;i<d;){let _=i++;l.push(o.item(_))}let m=l,a=[],u=0;for(;u<m.length;){let _=m[u];++u;let g=0,w=O.get_attributes(_);for(;g<w.length;){let x=w[g];++g,x.name.startsWith("data-froomle-order-")&&a.push(t(_,x.name.substring(19),x.value))}}if(a.length<1)return r.trigger(!1),r;let c=[],I=0;for(;I<a.length;){let _=a[I];++I;let g={list_name:_.list_name,limit:_.values.length,list_size:_.values.length},w={};v.setProperty(w,_.key,_.values),v.setProperty(g,"order",w),c.push(g)}return P.getRawRecommendations(c).then(function(_){let g=0,w=_.lists();for(;g<w.length;){let x=w[g],D=g++,V=x,b=a[D];b.el.setAttribute("data-froomle-request-id",_.request_id);let S=[],h=0,$=V.items;for(;h<$.length;){let se=$[h];++h;let L=se.get(b.key),T=0,z=b.values;for(;T<z.length;){let Q=z[T],me=T++;if(L==Q){S.push(b.orderChildren[me]);break}}}let R=0,M=S.length;for(;R<M;){let se=R++,L=0,T=O.get_children(b.el);for(;L<T.length;){let z=T[L];if(++L,z.getAttribute("data-froomle-tmp-node")==""){O.replaceChild(b.el,S[se],z);break}}}}r.trigger(!0)}),r}static domInit(e){X._orderElements(e).then(function(t){X._fillRecoTargets(e.getRoot())})}static fillElementRecos(e){X._fillRecoTargets(e)}static runFromHtml(e){let t=ge.fromHtml(e);return X.domInit(t),t.toString()}static get __name__(){return"internal.domHandler.DomDomDom"}get __class__(){return X}};var Es=s.$global;var As=N.setUserId,Fs=p.getUserId,Hs=N.setEnvironment,Os=p.getEnvironment,Ts=async()=>{throw new Error("Not implemented in V2")},Us=async()=>{console.warn("preloadRecommendations not implemented")},Ls=async()=>[],Ns=()=>[],Ms=()=>[],js=()=>[],Xs=()=>[],zs=async()=>{},Js=()=>{};export{Je as DomDomDom,ge as FroomleDomTree,N as FroomleSdk,p as RecoBackendV2,ie as RecommendationItem,le as RecommendationList,ne as Recommendations,Ie as Version,Ms as _getAllItemsFromCache,Xs as _getRawRecommendationCache,Ns as _getRecoQueue,js as _getRecommendedItemsCache,Os as getFroomleEnvironment,Fs as getFroomleUserId,Ts as getRecommendationItem,Ls as getRecommendations,Us as preloadRecommendations,zs as reset,Hs as setFroomleEnvironment,As as setFroomleUserId,Js as weirdReco};
|
|
1
|
+
var s=class I{static global(e){return I.globals[e]?I.globals[e]:I.globals[e]={}}static createStatic(e,t,r){let n=null;Object.defineProperty(e,t,{enumerable:!0,get:function(){return r!=null&&(n=r(),r=null),n},set:function(l){r!=null&&(n=r(),r=null),n=l}})}static iterator(e){if(Array.isArray(e)){let t=e;return function(){return I.mkIter(t)}}else return typeof e.iterator=="function"?e.iterator.bind(e):e.iterator}static getIterator(e){return Array.isArray(e)?I.mkIter(e):e.iterator()}static mkIter(e){return new he(e)}static extend(e){function t(){this[I.new].apply(this,arguments)}return Object.setPrototypeOf(t.prototype,e.prototype),t}static inherits(e,t){t==null&&(t=!1);function r(){t&&e&&r[I.init]&&r[I.init](),this[I.new].apply(this,arguments)}return t?r[I.init]=()=>{let n=e();n[I.init]&&n[I.init](),Object.setPrototypeOf(r.prototype,n.prototype),r[I.init]=void 0}:e&&e[I.init]?(t=!0,r[I.init]=()=>{e[I.init]&&e[I.init](),Object.setPrototypeOf(r.prototype,e.prototype),r[I.init]=void 0}):e&&Object.setPrototypeOf(r.prototype,e.prototype),r}static bind(e,t){if(t==null)return null;t.__id__==null&&(t.__id__=I.fid++);let r=null;return e.hx__closures__==null?e.hx__closures__={}:r=e.hx__closures__[t.__id__],r==null&&(r=t.bind(e),e.hx__closures__[t.__id__]=r),r}static get __name__(){return"genes.Register"}get __class__(){return I}};s.$global=typeof window!="undefined"?window:typeof global!="undefined"?global:typeof self!="undefined"?self:void 0;s.globals={};s.new=Symbol();s.init=Symbol();s.fid=0;var he=s.global("$hxClasses")["genes._Register.ArrayIterator"]=class ve extends s.inherits(){[s.new](e){this.current=0,this.array=e}hasNext(){return this.current<this.array.length}next(){return this.array[this.current++]}static get __name__(){return"genes._Register.ArrayIterator"}get __class__(){return ve}};he.prototype.array=null;he.prototype.current=null;var We=s.$global,Ie=s.global("$hxClasses").Version=class Ee{static get __name__(){return"Version"}get __class__(){return Ee}};Ie.CURRENT="0.0.9";var Ze=s.$global,ne=function(){};ne.__isInterface__=!0;var le=function(){};le.__isInterface__=!0;var ie=function(){};ie.__isInterface__=!0;var st=s.$global,oe=s.global("$hxClasses")["haxe.ValueException"]=class Ce extends s.inherits(()=>$,!0){[s.new](e,t,r){super[s.new](String(e),t,r),this.value=e}unwrap(){return this.value}static get __name__(){return"haxe.ValueException"}static get __super__(){return $}get __class__(){return Ce}};oe.prototype.value=null;var ot=s.$global,$=s.global("$hxClasses")["haxe.Exception"]=class Y extends s.inherits(()=>Error,!0){[s.new](e,t,r){Error.call(this,e),this.message=e,this.__previousException=t,this.__nativeException=r!=null?r:this}unwrap(){return this.__nativeException}get_native(){return this.__nativeException}static caught(e){return e instanceof Y?e:e instanceof Error?new Y(e.message,null,e):new oe(e,null,e)}static thrown(e){return e instanceof Y?e.get_native():e instanceof Error?e:new oe(e)}static get __name__(){return"haxe.Exception"}static get __super__(){return Error}get __class__(){return Y}};$.prototype.native=null;$.prototype.__skipStack=null;$.prototype.__nativeException=null;$.prototype.__previousException=null;var ct=s.$global,de=s.global("$hxClasses")["js.Browser"]=class $e{static get supported(){return this.get_supported()}static get_supported(){return typeof window!="undefined"&&typeof window.location!="undefined"?typeof window.location.protocol=="string":!1}static createXMLHttpRequest(){if(typeof XMLHttpRequest!="undefined")return new XMLHttpRequest;if(typeof ActiveXObject!="undefined")return new"ActiveXObject"("Microsoft.XMLHTTP");throw $.thrown("Unable to create XMLHttpRequest object.")}static get __name__(){return"js.Browser"}get __class__(){return $e}};var pt=s.$global,A=s.global("$hxEnums")["haxe.io.Error"]={__ename__:"haxe.io.Error",Blocked:{_hx_name:"Blocked",_hx_index:0,__enum__:"haxe.io.Error"},Overflow:{_hx_name:"Overflow",_hx_index:1,__enum__:"haxe.io.Error"},OutsideBounds:{_hx_name:"OutsideBounds",_hx_index:2,__enum__:"haxe.io.Error"},Custom:Object.assign(I=>({_hx_index:3,__enum__:"haxe.io.Error",e:I}),{_hx_name:"Custom",__params__:["e"]})};A.__constructs__=[A.Blocked,A.Overflow,A.OutsideBounds,A.Custom];A.__empty_constructs__=[A.Blocked,A.Overflow,A.OutsideBounds];var ft=s.$global,H=s.global("$hxEnums")["haxe.io.Encoding"]={__ename__:"haxe.io.Encoding",UTF8:{_hx_name:"UTF8",_hx_index:0,__enum__:"haxe.io.Encoding"},RawNative:{_hx_name:"RawNative",_hx_index:1,__enum__:"haxe.io.Encoding"}};H.__constructs__=[H.UTF8,H.RawNative];H.__empty_constructs__=[H.UTF8,H.RawNative];var vt=s.$global,J=s.global("$hxClasses")["haxe.io.Bytes"]=class fe extends s.inherits(){[s.new](e){this.length=e.byteLength,this.b=new Uint8Array(e),this.b.bufferValue=e,e.hxBytes=this,e.bytes=this.b}getString(e,t,r){if(e<0||t<0||e+t>this.length)throw $.thrown(A.OutsideBounds);r==null&&(r=H.UTF8);let n="",l=this.b,a=e,o=e+t;switch(r._hx_index){case 0:let f=e>0;for(;a<o;){let p=l[a++];if(p<128){if(p==0)break;n+=String.fromCodePoint(p)}else if(p<224){let u=(p&63)<<6|l[a++]&127;n+=String.fromCodePoint(u)}else if(p<240){let u=l[a++],_=(p&31)<<12|(u&127)<<6|l[a++]&127;n+=String.fromCodePoint(_)}else{let u=l[a++],_=l[a++],g=(p&15)<<18|(u&127)<<12|(_&127)<<6|l[a++]&127;n+=String.fromCodePoint(g)}}break;case 1:for(;a<o;){let p=l[a++]|l[a++]<<8;n+=String.fromCodePoint(p)}break}return n}static ofData(e){let t=e.hxBytes;return t!=null?t:new fe(e)}static get __name__(){return"haxe.io.Bytes"}get __class__(){return fe}};J.prototype.length=null;J.prototype.b=null;var $t=s.$global,F=s.global("$hxClasses")["haxe.http.HttpBase"]=class ke extends s.inherits(){[s.new](e){this.url=e,this.headers=[],this.params=[],this.emptyOnData=s.bind(this,this.onData)}get responseData(){return this.get_responseData()}setHeader(e,t){let r=0,n=this.headers.length;for(;r<n;){let l=r++;if(this.headers[l].name==e){this.headers[l]={name:e,value:t};return}}this.headers.push({name:e,value:t})}setPostData(e){this.postData=e,this.postBytes=null}onData(e){}onBytes(e){}onError(e){}onStatus(e){}hasOnData(){return s.bind(this,this.onData)!=this.emptyOnData}success(e){this.responseBytes=e,this.responseAsString=null,this.hasOnData()&&this.onData(this.get_responseData()),this.onBytes(this.responseBytes)}get_responseData(){return this.responseAsString==null&&this.responseBytes!=null&&(this.responseAsString=this.responseBytes.getString(0,this.responseBytes.length,H.UTF8)),this.responseAsString}static get __name__(){return"haxe.http.HttpBase"}get __class__(){return ke}};F.prototype.url=null;F.prototype.responseBytes=null;F.prototype.responseAsString=null;F.prototype.postData=null;F.prototype.postBytes=null;F.prototype.headers=null;F.prototype.params=null;F.prototype.emptyOnData=null;var St=s.$global,ae=s.global("$hxClasses")["haxe.iterators.MapKeyValueIterator"]=class De extends s.inherits(){[s.new](e){this.map=e,this.keys=e.keys()}hasNext(){return this.keys.hasNext()}next(){let e=this.keys.next();return{value:this.map.get(e),key:e}}static get __name__(){return"haxe.iterators.MapKeyValueIterator"}get __class__(){return De}};ae.prototype.map=null;ae.prototype.keys=null;var Bt=s.$global,xe=function(){};xe.__isInterface__=!0;var Ft=s.$global,ye=s.global("$hxClasses")["js.Boot"]=class Z{static __string_rec(e,t){if(e==null)return"null";if(t.length>=5)return"<...>";let r=typeof e;switch(r=="function"&&(e.__name__||e.__ename__)&&(r="object"),r){case"function":return"<function>";case"object":if(e.__enum__){let p=s.global("$hxEnums")[e.__enum__].__constructs__[e._hx_index],u=p._hx_name;return p.__params__?(t=t+" ",u+"("+(function(_){var g;let E=[];{let c=0,m=p.__params__;for(;c<m.length;){let w=m[c];c=c+1,E.push(Z.__string_rec(e[w],t))}}return g=E,g})(this).join(",")+")"):u}if(e instanceof Array){let f="[";t+=" ";let p=0,u=e.length;for(;p<u;){let _=p++;f+=(_>0?",":"")+Z.__string_rec(e[_],t)}return f+="]",f}let n;try{n=e.toString}catch{return"???"}if(n!=null&&n!=Object.toString&&typeof n=="function"){let f=e.toString();if(f!="[object Object]")return f}let l=`{
|
|
2
|
+
`;t+=" ";let a=e.hasOwnProperty!=null,o=null;for(o in e)a&&!e.hasOwnProperty(o)||o=="prototype"||o=="__class__"||o=="__super__"||o=="__interfaces__"||o=="__properties__"||(l.length!=2&&(l+=`,
|
|
3
|
+
`),l+=t+o+" : "+Z.__string_rec(e[o],t));return t=t.substring(1),l+=`
|
|
4
|
+
`+t+"}",l;break;case"string":return e;default:return String(e)}}static get __name__(){return"js.Boot"}get __class__(){return Z}};ye.__toStr={}.toString;var Ut=s.$global,S=s.global("$hxClasses").Std=class Se{static string(e){return ye.__string_rec(e,"")}static parseInt(e){let t=parseInt(e);return isNaN(t)?null:t}static get __name__(){return"Std"}get __class__(){return Se}};String.__name__=!0,Array.__name__=!0;var Mt=s.$global,ue=s.global("$hxClasses")["genes.util.EsMap"]=class ee extends s.inherits(){[s.new](){this.inst=new Map}set(e,t){this.inst.set(e,t)}get(e){return this.inst.get(e)}remove(e){return this.inst.delete(e)}exists(e){return this.inst.has(e)}keys(){return ee.adaptIterator(this.inst.keys())}iterator(){return ee.adaptIterator(this.inst.values())}toString(){let e=[],t=ee.adaptIterator(this.inst.keys());for(;t.hasNext();){let r=t.next();e.push(""+S.string(r)+" => "+S.string(this.inst.get(r)))}return"{"+e.join(", ")+"}"}clear(){this.inst.clear()}static adaptIterator(e){let t,r,n=function(){let l=e.next();t=l.value,r=l.done};return{hasNext:function(){return r==null&&n(),!r},next:function(){r==null&&n();let l=t;return n(),l}}}static get __name__(){return"genes.util.EsMap"}get __class__(){return ee}};ue.prototype.inst=null;var Wt=s.$global,Pe=s.global("$hxClasses")["haxe.ds.StringMap"]=class be extends s.inherits(ue){[s.new](){super[s.new]()}copy(){let e=new be;return e.inst=new Map(this.inst),e}keyValueIterator(){return new ae(this)}static get __name__(){return"haxe.ds.StringMap"}static get __interfaces__(){return[xe]}static get __super__(){return ue}get __class__(){return be}};var Zt=s.$global,q=s.global("$hxClasses").HxOverrides=class qe{static cca(e,t){let r=e.charCodeAt(t);if(r==r)return r}static substr(e,t,r){if(r==null)r=e.length;else if(r<0)if(t==0)r=e.length+r;else return"";return e.substr(t,r)}static now(){return Date.now()}static get __name__(){return"HxOverrides"}get __class__(){return qe}};typeof performance!="undefined"&&typeof performance.now=="function"&&(q.now=performance.now.bind(performance));var sr=s.$global,M=s.global("$hxClasses").StringTools=class _e{static isSpace(e,t){let r=q.cca(e,t);return r>8&&r<14?!0:r==32}static ltrim(e){let t=e.length,r=0;for(;r<t&&_e.isSpace(e,r);)++r;return r>0?q.substr(e,r,t-r):e}static rtrim(e){let t=e.length,r=0;for(;r<t&&_e.isSpace(e,t-r-1);)++r;return r>0?q.substr(e,0,t-r):e}static replace(e,t,r){return e.split(t).join(r)}static get __name__(){return"StringTools"}get __class__(){return _e}};var ir=s.$global,Be=s.global("$hxClasses").Lambda=class Ve{static exists(e,t){let r=s.getIterator(e);for(;r.hasNext();){let n=r.next();if(t(n))return!0}return!1}static get __name__(){return"Lambda"}get __class__(){return Ve}};var gr=s.$global,te=s.global("$hxClasses").EReg=class Ae extends s.inherits(){[s.new](e,t){this.r=new RegExp(e,t.split("u").join(""))}match(e){return this.r.global&&(this.r.lastIndex=0),this.r.m=this.r.exec(e),this.r.s=e,this.r.m!=null}matched(e){if(this.r.m!=null&&e>=0&&e<this.r.m.length)return this.r.m[e];throw $.thrown("EReg::matched")}matchedPos(){if(this.r.m==null)throw $.thrown("No string matched");return{pos:this.r.m.index,len:this.r.m[0].length}}matchSub(e,t,r){if(r==null&&(r=-1),this.r.global){this.r.lastIndex=t,this.r.m=this.r.exec(r<0?e:q.substr(e,0,t+r));let n=this.r.m!=null;return n&&(this.r.s=e),n}else{let n=this.match(r<0?q.substr(e,t,null):q.substr(e,t,r));return n&&(this.r.s=e,this.r.m.index+=t),n}}map(e,t){let r=0,n="";do{if(r>=e.length)break;if(!this.matchSub(e,r)){n+=S.string(q.substr(e,r,null));break}let l=this.matchedPos();n+=S.string(q.substr(e,r,l.pos-r)),n+=S.string(t(this)),l.len==0?(n+=S.string(q.substr(e,l.pos,1)),r=l.pos+1):r=l.pos+l.len}while(this.r.global);return!this.r.global&&r>0&&r<e.length&&(n+=S.string(q.substr(e,r,null))),n}static get __name__(){return"EReg"}get __class__(){return Ae}};te.prototype.r=null;var Ir=s.$global,K=s.global("$hxClasses")["haxe.http.HttpJs"]=class Fe extends s.inherits(F){[s.new](e){this.async=!0,this.withCredentials=!1,super[s.new](e)}request(e){this.responseAsString=null,this.responseBytes=null,this.responseHeaders=null;let t=this.req=de.createXMLHttpRequest(),r=this,n=function(u){if(t.readyState!=4)return;let _;try{_=t.status}catch{_=null}if(_==0&&de.get_supported()&&s.$global.location!=null){let g=s.$global.location.protocol.toLowerCase();new te("^(?:about|app|app-storage|.+-extension|file|res|widget):$","").match(g)&&(_=t.response!=null?200:404)}if(_==null&&(_=null),_!=null&&r.onStatus(_),_!=null&&_>=200&&_<400){r.req=null;let g=t.getAllResponseHeaders().split(`\r
|
|
5
|
+
`),E=[],c=0,m=g;for(;c<m.length;){let y=m[c];++c,y!=""&&E.push(y)}g=E;let w=new Pe;r.responseHeaders=w;let x=0;for(;x<g.length;){let y=g[x];++x;let P=y.split(": "),V=P.shift(),b=P.length==1?P[0]:P.join(": ");b=M.ltrim(M.rtrim(b)),r.responseHeaders.inst.set(V,b)}r.success(J.ofData(t.response))}else if(_==null||_==0&&t.response==null)r.req=null,r.onError("Failed to connect or resolve host");else if(_==null){r.req=null;let g=t.response!=null?J.ofData(t.response):null;r.responseBytes=g,r.onError("Http Error #"+t.status)}else switch(_){case 12007:r.req=null,r.onError("Unknown host");break;case 12029:r.req=null,r.onError("Failed to connect to host");break;default:r.req=null;let g=t.response!=null?J.ofData(t.response):null;r.responseBytes=g,r.onError("Http Error #"+t.status)}};this.async&&(t.onreadystatechange=n);let l,a=this.postData,o=this.postBytes;if(a==null)if(o==null)l=null;else{let u=o;l=new Blob([u.b.bufferValue])}else o==null?l=a:l=null;if(l!=null)e=!0;else{let u=0,_=this.params;for(;u<_.length;){let g=_[u];++u,l==null?l="":l=(l==null?"null":S.string(l))+"&";let E=g.name,c=(l==null?"null":S.string(l))+encodeURIComponent(E)+"=",m=g.value;l=c+encodeURIComponent(m)}}try{if(e)t.open("POST",this.url,this.async);else if(l!=null){let u=this.url.split("?").length<=1;t.open("GET",this.url+(u?"?":"&")+(l==null?"null":S.string(l)),this.async),l=null}else t.open("GET",this.url,this.async);t.responseType="arraybuffer"}catch(u){let _=$.caught(u).unwrap();this.req=null,this.onError(_.toString());return}t.withCredentials=this.withCredentials,!Be.exists(this.headers,function(u){return u.name=="Content-Type"})&&e&&this.postData==null&&t.setRequestHeader("Content-Type","application/x-www-form-urlencoded");let f=0,p=this.headers;for(;f<p.length;){let u=p[f];++f,t.setRequestHeader(u.name,u.value)}t.send(l),this.async||n(null)}static get __name__(){return"haxe.http.HttpJs"}static get __super__(){return F}get __class__(){return Fe}};K.prototype.async=null;K.prototype.withCredentials=null;K.prototype.responseHeaders=null;K.prototype.req=null;var $r=s.$global,U=s.global("$hxClasses").SimpleFuture=class He extends s.inherits(){[s.new](){this._isFinished=!1}trigger(e){this._result=e,this._isFinished=!0,this._callback!=null&&this._callback(this._result)}then(e){this._callback=e,this._isFinished&&e(this._result)}static get __name__(){return"SimpleFuture"}get __class__(){return He}};U.prototype._callback=null;U.prototype._result=null;U.prototype._isFinished=null;var Sr=s.$global,v=s.global("$hxClasses").Reflect=class Oe{static field(e,t){try{return e[t]}catch{return null}}static getProperty(e,t){let r;if(e==null)return null;{let n;return e.__properties__?(r=e.__properties__["get_"+t],n=r):n=!1,n?e[r]():e[t]}}static setProperty(e,t,r){let n,l;e.__properties__?(n=e.__properties__["set_"+t],l=n):l=!1,l?e[n](r):e[t]=r}static fields(e){let t=[];if(e!=null){let n=Object.prototype.hasOwnProperty;for(var r in e)r!="__id__"&&r!="hx__closures__"&&n.call(e,r)&&t.push(r)}return t}static get __name__(){return"Reflect"}get __class__(){return Oe}};var Tr=s.$global,i=s.global("$hxClasses")["internal.RecoBackendV2"]=class d extends s.inherits(){[s.new](){}static _requestUri(){return"https://"+d._req_domain+"/api/"+d._environment+"/recommendations/requests"}static noConsentBody(){return{device_id:"no-consent",user_group:"no-consent",version:"no-consent"}}static buildRequestBody(e){let t={lists:e,page_type:d._page_visit!=null?d._page_visit:d._page_view,channel:"www-desktop"};if(d._consent==0){let r=d.noConsentBody(),n=0,l=v.fields(r);for(;n<l.length;){let a=l[n];++n,t[a]=v.field(r,a)}}else d._user_id!=null?t.user_id=d._user_id:t.device_id=d._device_id;return t}static _requestRecos(e){let t=new U,r=null,n=new K(d._requestUri());n.setHeader("Content-Type","application/json"),n.setPostData(JSON.stringify(d.buildRequestBody(e))),n.onError=function(o){throw $.thrown("HTTP Request Error: "+o)},n.onStatus=function(o){if(o<200||o>=300)throw $.thrown("HTTP Status Error: "+o)};try{n.request(!1)}catch(o){let f=$.caught(o).unwrap();throw $.thrown("Failed to execute synchronous request: "+S.string(f))}let l=function(o){let f=JSON.parse(o),p=G.fromRequestData(f);t.trigger(p)},a=n.get_responseData();return a!=null?l(a):n.onData=l,t}static getRawRecommendations(e){return d._requestRecos(e)}static setConsent(e){e>2&&(e=2),d._consent=e}static setChannel(e){d._channel=e}static setPageVisit(e){d._page_visit=e}static setEnvironment(e){d._environment=e}static setDeviceId(e){d._device_id=e}static setUserId(e){d._user_id=e}static setRequestDomain(e){d._req_domain=e}static setPageView(e){d._page_view=e}static getRequestDomain(){return d._req_domain}static getEnvironment(){return d._environment}static getPageVisit(){return d._page_visit}static getUserId(){return d._user_id}static getDeviceId(){return d._device_id}static getPageView(){return d._page_view}static getConsent(){return d._consent}static getChannel(){return d._channel}static get __name__(){return"internal.RecoBackendV2"}get __class__(){return d}};i._environment=null;i._device_id="no-consent";i._user_id=null;i._consent=0;i._req_domain="europe-west1.froomle.com";i._page_visit=null;i._page_view=null;i._channel="www-desktop";var Xe=function(){};Xe.__isInterface__=!0;var ze=function(){};ze.__isInterface__=!0;var G=s.global("$hxClasses")["internal._RecommendationsInternal"]=class we extends s.inherits(){[s.new](e,t,r,n,l){this.request_id=t,this.user_group=r,this.device_id=e,this.user_id=n,this._lists=l}items(){let e=[],t=0,r=this._lists;for(;t<r.length;){let n=r[t];++t;let l=0,a=n.items;for(;l<a.length;){let o=a[l];++l,e.push(o)}}return e}lists(){return this._lists}getItemsByListName(e){let t=0,r=this._lists;for(;t<r.length;){let n=r[t];if(++t,n.list_name==e)return n}return null}static fromRequestData(e){let t=v.getProperty(e,"lists"),r=[],n=0;for(;n<t.length;){let l=t[n];++n;let a=v.getProperty(l,"items"),o=[],f=0;for(;f<a.length;){let u=a[f];++f,o.push(new re(u))}let p=new W({limit:v.getProperty(l,"limit"),list_key:v.getProperty(l,"list_key"),list_name:v.getProperty(l,"list_name"),list_size:v.getProperty(l,"list_size"),items:o});r.push(p)}return new we(v.getProperty(e,"device_id"),v.getProperty(e,"request_id"),v.getProperty(e,"user_group"),v.getProperty(e,"user_id"),r)}static get __name__(){return"internal._RecommendationsInternal"}static get __interfaces__(){return[ne]}get __class__(){return we}};G.prototype.request_id=null;G.prototype.user_group=null;G.prototype.user_id=null;G.prototype.device_id=null;G.prototype._lists=null;var W=s.global("$hxClasses")["internal._RecommendationsListInternal"]=class Te extends s.inherits(){[s.new](e){this.items=e.items,this.limit=e.limit,this.list_key=e.list_key,this.list_name=e.list_name,this.list_size=e.list_size}static get __name__(){return"internal._RecommendationsListInternal"}static get __interfaces__(){return[le]}get __class__(){return Te}};W.prototype.limit=null;W.prototype.list_key=null;W.prototype.list_name=null;W.prototype.list_size=null;W.prototype.items=null;var re=s.global("$hxClasses")["internal._RecommendationItemInternal"]=class Ue extends s.inherits(){[s.new](e){this._data={},this.Id=v.getProperty(e,"item_id"),this.RequestId=v.getProperty(e,"request_id"),this.UserGroup=v.getProperty(e,"user_group");let t=0,r=v.fields(e);for(;t<r.length;){let n=r[t];++t,this._data[n]=v.field(e,n)}}get(e){return this._data[e]}static get __name__(){return"internal._RecommendationItemInternal"}static get __interfaces__(){return[ie]}get __class__(){return Ue}};re.prototype.Id=null;re.prototype.RequestId=null;re.prototype.UserGroup=null;re.prototype._data=null;var k=s.global("$hxClasses")["internal._RecoBackendV2.RecoBackendV2_Fields_"]=class Le{static getRawRecommendations(e){return i.getRawRecommendations(e)}static setConsent(e){i.setConsent(e)}static setPageVisit(e){i.setPageVisit(e)}static setEnvironment(e){i.setEnvironment(e)}static setDeviceId(e){i.setDeviceId(e)}static setUserId(e){i.setUserId(e)}static setRequestDomain(e){i.setRequestDomain(e)}static setPageView(e){i.setPageView(e)}static setChannel(e){i.setChannel(e)}static getRequestDomain(){i.getRequestDomain()}static getConsent(){i.getConsent()}static getPageVisit(){i.getPageVisit()}static getEnvironment(){i.getEnvironment()}static getDeviceId(){i.getDeviceId()}static getUserId(){i.getUserId()}static getPageView(){i.getPageView()}static getChannel(){i.getChannel()}static get __name__(){return"internal._RecoBackendV2.RecoBackendV2_Fields_"}get __class__(){return Le}},Ur=k.getRawRecommendations,Lr=k.setConsent,Nr=k.setPageVisit,jr=k.setEnvironment,Mr=k.setDeviceId,Xr=k.setUserId,zr=k.setRequestDomain,Jr=k.setPageView,Kr=k.setChannel,Gr=k.getRequestDomain,Wr=k.getConsent,Qr=k.getPageVisit,Yr=k.getEnvironment,Zr=k.getDeviceId,es=k.getUserId,ts=k.getPageView,rs=k.getChannel;var is=s.$global,N=s.global("$hxClasses").FroomleSdk=class B{static register(){B.registered||B._env_set&&(!B._page_visit_set&&!B._page_view_set||(B.registered=!0))}static buildScriptTag(){let e='<script src="https://cdn.froomle.com/reco-backend-v2/0.0.9/reco-backend-v2.min.js" data-froomle-env="'+i.getEnvironment()+'" ';return i.getPageVisit()!=null&&(e+='data-froomle-page-visit="'+i.getPageVisit()+'" '),i.getPageView()!=null&&(e+='data-froomle-page-view="'+i.getPageView()+'" '),i.getDeviceId()!=null&&(e+='data-froomle-device-id="'+i.getDeviceId()+'" '),i.getUserId()!=null&&(e+='data-froomle-user-id="'+i.getUserId()+'" '),i.getConsent()>0&&(e+='data-froomle-consent="'+i.getConsent()+'" '),i.getRequestDomain()!=null&&(e+='data-froomle-request-domain="'+i.getRequestDomain()+'" '),e+="><\/script>",e}static setEnvironment(e){i.setEnvironment(e),B._env_set=!0,B.register()}static setDeviceId(e){i.setDeviceId(e)}static setUserId(e){i.setUserId(e)}static setConsent(e){i.setConsent(e)}static setPageView(e){i.setPageView(e),B._page_view_set=!0,B.register()}static setPageVisit(e){i.setPageVisit(e),B._page_visit_set=!0,B.register()}static setRequestDomain(e){i.setRequestDomain(e)}static getRawRecommendations(e){return i.getRawRecommendations(e)}static getVersion(){return"0.0.9"}static get __name__(){return"FroomleSdk"}get __class__(){return B}};N._env_set=!1;N._page_visit_set=!1;N._page_view_set=!1;N.registered=!1;var us=s.$global,ge=s.global("$hxClasses")["internal.domHandler.FroomleDomTree"]=class ce extends s.inherits(){[s.new](){}createElement(e){return window.document.createElement(e)}querySelectorAll(e){let t=this.root,r=[],n=t.querySelectorAll(e),l=0,a=n.length;for(;l<a;){let o=l++;r.push(n.item(o))}return r}getRoot(){return this.root}toString(){return this.root.outerHTML}static run(){}static fromHtml(e){return new ce}static fromDocument(){let e=new ce;return e.root=window.document,e}static get __name__(){return"internal.domHandler.FroomleDomTree"}get __class__(){return ce}};ge.prototype.root=null;var gs=s.$global,O=s.global("$hxClasses")["internal._ADomNode.ADomNode"]=class Re{static _new(e){return e}static fromElement(e){return e}static create(e,t){return window.document.createElement(t)}static replaceChild(e,t,r){e.replaceChild(t,r)}static get attributes(){return this.get_attributes()}static get_attributes(e){let t=e,r=[],n=0,l=t.attributes.length;for(;n<l;){let a=n++,o=t.attributes.item(a);r.push({name:o.name,value:o.value})}return r}static addChild(e,t){e.appendChild(t)}static removeChild(e,t){e.removeChild(t)}static getAttribute(e,t){return e.getAttribute(t)}static setAttribute(e,t,r){e.setAttribute(t,r)}static getText(e){return e.textContent}static setText(e,t){e.textContent=t}static get children(){return this.get_children()}static get_children(e){let t=[],n=e.children,l=0,a=n.length;for(;l<a;){let o=l++;t.push(n[o])}return t}static querySelectorAll(e,t){let r=e,n=[],l=r.querySelectorAll(t),a=0,o=l.length;for(;a<o;){let f=a++;n.push(l.item(f))}return n}static getFilterKeyValue(e){let t=0,r=Re.get_attributes(e);for(;t<r.length;){let n=r[t];if(++t,n.name.startsWith("data-froomle-reco-filter-"))return{key:n.name.substring(25),value:n.value}}return{key:null,value:null}}static get __name__(){return"internal._ADomNode.ADomNode_Impl_"}get __class__(){return Re}};var Is=s.$global,Je=s.global("$hxClasses")["internal.domHandler.DomDomDom"]=class X extends s.inherits(){[s.new](){}static _fillRecoTargets(e){let t=new U;if(e==null)return t.trigger(!1),t;let r=[],n=e,l=[],a=n.querySelectorAll("*"),o=0,f=a.length;for(;o<f;){let h=o++;l.push(a.item(h))}let p=l,u=0;for(;u<p.length;){let h=p[u];++u;let C=0,R=O.get_attributes(h);for(;C<R.length;){let j=R[C];++C,j.name=="data-froomle-reco"&&r.push(h)}}let _=[],g=0;for(;g<r.length;){let h=r[g];++g,h.getAttribute("data-froomle-request-id")==null&&(h.getAttribute("data-froomle-id")==null||h.getAttribute("data-froomle-id")=="")&&_.push(h)}if(_.length<1)return new U;let E=[],c=[],m="",w="",x="",y=[],P=function(){let h={list_name:m,list_size:y.length,limit:y.length};w!=null&&v.setProperty(h,w,x),E.push(h),c.push(y)},V=function(h,C,R,j){m=h,w=C,x=R,y=[j]},b=0;for(;b<_.length;){let h=_[b];++b;let C=h.getAttribute("data-froomle-reco"),R=O.getFilterKeyValue(h);if(m==""){V(C,R.key,R.value,h);continue}else if(C==m&&R.key==w&&R.value==x){y.push(h);continue}else{P(),V(C,R.key,R.value,h);continue}}return m!=""&&P(),k.getRawRecommendations(E).then(function(h){let C=0,R=h.lists();for(;C<R.length;){let j=R[C],L=C++,T=j,z=T.items.length!=c[L].length,Q=0,me=T.items;for(;Q<me.length;){let pe=me[Q],je=Q++,Me=pe;X._fillParameters(c[L][je],Me,h.request_id)}}t.trigger(!0)}),t}static _fillParameters(e,t,r){let n=function(g,E,c,m){m==null&&(m="");let w=function(x,y,P){P==null&&(P="fgh");try{y=new te("\\\\[(\\\\w+)\\\\]","g").map(y,function(R){return"."+R.matched(1)}),y=M.replace(y,"[","."),y=M.replace(y,"]",""),q.cca(y,0)==46&&(y=q.substr(y,1,null));let b=y.split("."),D=x.get(b[0]),h=1,C=b.length;for(;h<C;){let R=h++;if(D==null)return null;D instanceof Array&&S.parseInt(b[R])!=null?D=D[S.parseInt(b[R])]:D=v.field(D,b[R])}return D}catch{return P}};try{let x=w(t,c,m);E=="inner"?g.textContent=x:g.setAttribute(E,x)}catch{}};e.setAttribute("data-froomle-id",t.Id),e.setAttribute("data-froomle-request-id",r);let l=e,a=[],o=l.querySelectorAll("*"),f=0,p=o.length;for(;f<p;){let g=f++;a.push(o.item(g))}let u=a,_=0;for(;_<u.length;){let g=u[_];++_;let E=0,c=O.get_attributes(g);for(;E<c.length;){let m=c[E];if(++E,m.name.startsWith("data-froomle-param-")){let w=M.replace(m.name,"data-froomle-param-",""),x=m.value;n(g,w,x)}}}}static _orderElements(e){let t=function(c,m,w){let x=[],y=O.get_children(c),P=0;for(;P<y.length;){let D=y[P];if(++P,D.getAttribute("data-froomle-ordervalue")!=null){x.push(D);let C=O.create(e,"span");C.setAttribute("data-froomle-tmp-node",""),O.replaceChild(c,C,D)}}let V=[],b=0;for(;b<x.length;){let D=x[b];++b,V.push(D.getAttribute("data-froomle-ordervalue"))}return{el:c,key:m,values:V,orderChildren:x,list_name:w}},r=new U,n=e.getRoot(),l=[],a=n.querySelectorAll("*"),o=0,f=a.length;for(;o<f;){let c=o++;l.push(a.item(c))}let p=l,u=[],_=0;for(;_<p.length;){let c=p[_];++_;let m=0,w=O.get_attributes(c);for(;m<w.length;){let x=w[m];++m,x.name.startsWith("data-froomle-order-")&&u.push(t(c,x.name.substring(19),x.value))}}if(u.length<1)return r.trigger(!1),r;let g=[],E=0;for(;E<u.length;){let c=u[E];++E;let m={list_name:c.list_name,limit:c.values.length,list_size:c.values.length},w={};v.setProperty(w,c.key,c.values),v.setProperty(m,"order",w),g.push(m)}return k.getRawRecommendations(g).then(function(c){let m=0,w=c.lists();for(;m<w.length;){let x=w[m],P=m++,V=x,b=u[P];b.el.setAttribute("data-froomle-request-id",c.request_id);let D=[],h=0,C=V.items;for(;h<C.length;){let se=C[h];++h;let L=se.get(b.key),T=0,z=b.values;for(;T<z.length;){let Q=z[T],pe=T++;if(L==Q){D.push(b.orderChildren[pe]);break}}}let R=0,j=D.length;for(;R<j;){let se=R++,L=0,T=O.get_children(b.el);for(;L<T.length;){let z=T[L];if(++L,z.getAttribute("data-froomle-tmp-node")==""){O.replaceChild(b.el,D[se],z);break}}}}r.trigger(!0)}),r}static domInit(e){X._orderElements(e).then(function(t){X._fillRecoTargets(e.getRoot())})}static fillElementRecos(e){X._fillRecoTargets(e)}static runFromHtml(e){if(e=="")return"";let t=ge.fromHtml(e);return X.domInit(t),t.toString()}static get __name__(){return"internal.domHandler.DomDomDom"}get __class__(){return X}};var $s=s.$global;var Os=N.setUserId,Ts=i.getUserId,Us=N.setEnvironment,Ls=i.getEnvironment,Ns=async()=>{throw new Error("Not implemented in V2")},js=async()=>{console.warn("preloadRecommendations not implemented")},Ms=async()=>[],Xs=()=>[],zs=()=>[],Js=()=>[],Ks=()=>[],Gs=async()=>{},Ws=()=>{};export{Je as DomDomDom,ge as FroomleDomTree,N as FroomleSdk,i as RecoBackendV2,ie as RecommendationItem,le as RecommendationList,ne as Recommendations,Ie as Version,zs as _getAllItemsFromCache,Ks as _getRawRecommendationCache,Xs as _getRecoQueue,Js as _getRecommendedItemsCache,Ls as getFroomleEnvironment,Ts as getFroomleUserId,Ns as getRecommendationItem,Ms as getRecommendations,js as preloadRecommendations,Gs as reset,Us as setFroomleEnvironment,Os as setFroomleUserId,Ws as weirdReco};
|
|
6
6
|
//# sourceMappingURL=testing.js.map
|