@jitsu/js 1.9.0-canary.581.20240115194116 → 1.9.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/.turbo/turbo-build.log +4 -4
- package/.turbo/turbo-clean.log +1 -1
- package/.turbo/turbo-test.log +1359 -125
- package/__tests__/playwright/cases/callbacks.html +21 -0
- package/__tests__/playwright/integration.test.ts +26 -2
- package/dist/browser.d.ts +1 -1
- package/dist/jitsu.cjs.js +514 -36
- package/dist/jitsu.d.ts +4 -0
- package/dist/jitsu.es.js +514 -36
- package/dist/version.d.ts +1 -1
- package/dist/web/p.js.txt +532 -37
- package/package.json +3 -2
- package/src/analytics-plugin.ts +26 -1
- package/src/browser.ts +17 -2
- package/src/destination-plugins/gtm.ts +19 -30
- package/src/index.ts +10 -10
- package/src/jitsu.ts +5 -0
- package/src/version.ts +2 -2
package/dist/jitsu.es.js
CHANGED
|
@@ -278,7 +278,6 @@ var __awaiter$3 = (undefined && undefined.__awaiter) || function (thisArg, _argu
|
|
|
278
278
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
279
279
|
});
|
|
280
280
|
};
|
|
281
|
-
const defaultScriptSrc$1 = "https://www.googletagmanager.com/gtag/js";
|
|
282
281
|
const gtmPlugin = {
|
|
283
282
|
id: "gtm",
|
|
284
283
|
handle(config, payload) {
|
|
@@ -326,31 +325,27 @@ function initGtmIfNeeded(config, payload) {
|
|
|
326
325
|
}
|
|
327
326
|
setGtmState("loading");
|
|
328
327
|
const dlName = config.dataLayerName || "dataLayer";
|
|
329
|
-
const dlParam = dlName !== "dataLayer" ? "&l=" + dlName : "";
|
|
330
|
-
const previewParams = config.preview
|
|
331
|
-
? `>m_preview=${config.preview}>m_auth=${config.auth}>m_cookies_win=x`
|
|
332
|
-
: "";
|
|
333
328
|
const tagId = config.containerId;
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
});
|
|
329
|
+
(function (w, l, i) {
|
|
330
|
+
w[l] = w[l] || [];
|
|
331
|
+
w[l].push({
|
|
332
|
+
user_id: payload.userId,
|
|
333
|
+
});
|
|
334
|
+
w[l].push({
|
|
335
|
+
"gtm.start": new Date().getTime(),
|
|
336
|
+
event: "gtm.js",
|
|
337
|
+
});
|
|
338
|
+
const dl = l != "dataLayer" ? "&l=" + l : "";
|
|
339
|
+
const scriptSrc = "https://www.googletagmanager.com/gtm.js?id=" + i + dl;
|
|
340
|
+
loadScript(scriptSrc)
|
|
341
|
+
.then(() => {
|
|
342
|
+
setGtmState("loaded");
|
|
343
|
+
})
|
|
344
|
+
.catch(e => {
|
|
345
|
+
console.warn(`GTM (containerId=${tagId}) init failed: ${e.message}`, e);
|
|
346
|
+
setGtmState("failed");
|
|
347
|
+
});
|
|
348
|
+
})(window, dlName, tagId);
|
|
354
349
|
});
|
|
355
350
|
}
|
|
356
351
|
|
|
@@ -482,8 +477,7 @@ const internalDestinationPlugins = {
|
|
|
482
477
|
[logrocketPlugin.id]: logrocketPlugin,
|
|
483
478
|
};
|
|
484
479
|
|
|
485
|
-
|
|
486
|
-
const jitsuVersion = "0.0.0";
|
|
480
|
+
const jitsuVersion = "2.0.0";
|
|
487
481
|
const jitsuLibraryName = "@jitsu/js";
|
|
488
482
|
|
|
489
483
|
const publicSuffixes = "ac,com.ac,edu.ac,gov.ac,net.ac,mil.ac,org.ac,ad,nom.ad,ae,co.ae,net.ae,org.ae,sch.ae,ac.ae,gov.ae,mil.ae,aero,af,gov.af,com.af,org.af,net.af,edu.af,ag,com.ag,org.ag,net.ag,co.ag,nom.ag,ai,off.ai,com.ai,net.ai,org.ai,al,com.al,edu.al,gov.al,mil.al,net.al,org.al,am,co.am,com.am,commune.am,net.am,org.am,ao,ed.ao,gv.ao,og.ao,co.ao,pb.ao,it.ao,aq,ar,bet.ar,com.ar,coop.ar,edu.ar,gob.ar,gov.ar,int.ar,mil.ar,musica.ar,mutual.ar,net.ar,org.ar,senasa.ar,tur.ar,arpa,e164.arpa,in-addr.arpa,ip6.arpa,iris.arpa,uri.arpa,urn.arpa,as,gov.as,asia,at,ac.at,co.at,gv.at,or.at,sth.ac.at,au,com.au,net.au,org.au,edu.au,gov.au,asn.au,id.au,act.au,nsw.au,nt.au,qld.au,sa.au,tas.au,vic.au,wa.au,aw,com.aw,ax,az,com.az,net.az,int.az,gov.az,org.az,edu.az,info.az,pp.az,mil.az,name.az,pro.az,biz.az,ba,com.ba,edu.ba,gov.ba,mil.ba,net.ba,org.ba,bb,biz.bb,co.bb,com.bb,edu.bb,gov.bb,info.bb,net.bb,org.bb,store.bb,tv.bb,bd,be,ac.be,bf,gov.bf,bg,a.bg,b.bg,c.bg,d.bg,e.bg,f.bg,g.bg,h.bg,i.bg,j.bg,k.bg,l.bg,m.bg,n.bg,o.bg,p.bg,q.bg,r.bg,s.bg,t.bg,u.bg,v.bg,w.bg,x.bg,y.bg,z.bg,0.bg,1.bg,2.bg,3.bg,4.bg,5.bg,6.bg,7.bg,8.bg,9.bg,bh,com.bh,edu.bh,net.bh,org.bh,gov.bh,bi,co.bi,com.bi,edu.bi,or.bi,org.bi,biz,bj,africa.bj,agro.bj,architectes.bj,assur.bj,avocats.bj,co.bj,com.bj,eco.bj,econo.bj,edu.bj,info.bj,loisirs.bj,money.bj,net.bj,org.bj,ote.bj,resto.bj,restaurant.bj,tourism.bj,univ.bj,bm,com.bm,edu.bm,gov.bm,net.bm,org.bm,bn,com.bn,edu.bn,gov.bn,net.bn,org.bn,bo,com.bo,edu.bo,gob.bo,int.bo,org.bo,net.bo,mil.bo,tv.bo,web.bo,br,9guacu.br,abc.br,adm.br,adv.br,agr.br,aju.br,am.br,anani.br,aparecida.br,app.br,arq.br,art.br,ato.br,b.br,barueri.br,belem.br,bhz.br,bib.br,bio.br,blog.br,bmd.br,boavista.br,bsb.br,campinagrande.br,campinas.br,caxias.br,cim.br,cng.br,cnt.br,com.br,contagem.br,coop.br,coz.br,cri.br,cuiaba.br,curitiba.br,def.br,des.br,det.br,dev.br,ecn.br,eco.br,edu.br,emp.br,enf.br,eng.br,esp.br,etc.br,eti.br,far.br,feira.br,flog.br,floripa.br,fm.br,fnd.br,fortal.br,fot.br,foz.br,fst.br,g12.br,geo.br,ggf.br,goiania.br,gov.br,gru.br,imb.br,ind.br,inf.br,jab.br,jampa.br,jdf.br,joinville.br,jor.br,jus.br,leg.br,lel.br,log.br,londrina.br,macapa.br,maceio.br,manaus.br,maringa.br,mat.br,med.br,mil.br,morena.br,mp.br,mus.br,natal.br,net.br,niteroi.br,nom.br,not.br,ntr.br,odo.br,ong.br,org.br,osasco.br,palmas.br,poa.br,ppg.br,pro.br,psc.br,psi.br,pvh.br,qsl.br,radio.br,rec.br,recife.br,rep.br,ribeirao.br,rio.br,riobranco.br,riopreto.br,salvador.br,sampa.br,santamaria.br,santoandre.br,saobernardo.br,saogonca.br,seg.br,sjc.br,slg.br,slz.br,sorocaba.br,srv.br,taxi.br,tc.br,tec.br,teo.br,the.br,tmp.br,trd.br,tur.br,tv.br,udi.br,vet.br,vix.br,vlog.br,wiki.br,zlg.br,bs,com.bs,net.bs,org.bs,edu.bs,gov.bs,bt,com.bt,edu.bt,gov.bt,net.bt,org.bt,bv,bw,co.bw,org.bw,by,gov.by,mil.by,com.by,of.by,bz,com.bz,net.bz,org.bz,edu.bz,gov.bz,ca,ab.ca,bc.ca,mb.ca,nb.ca,nf.ca,nl.ca,ns.ca,nt.ca,nu.ca,on.ca,pe.ca,qc.ca,sk.ca,yk.ca,gc.ca,cat,cc,cd,gov.cd,cf,cg,ch,ci,org.ci,or.ci,com.ci,co.ci,edu.ci,ed.ci,ac.ci,net.ci,go.ci,asso.ci,aéroport.ci,int.ci,presse.ci,md.ci,gouv.ci,ck,cl,co.cl,gob.cl,gov.cl,mil.cl,cm,co.cm,com.cm,gov.cm,net.cm,cn,ac.cn,com.cn,edu.cn,gov.cn,net.cn,org.cn,mil.cn,co,arts.co,com.co,edu.co,firm.co,gov.co,info.co,int.co,mil.co,net.co,nom.co,org.co,rec.co,web.co,com,coop,cr,ac.cr,co.cr,ed.cr,fi.cr,go.cr,or.cr,sa.cr,cu,com.cu,edu.cu,org.cu,net.cu,gov.cu,inf.cu,cv,com.cv,edu.cv,int.cv,nome.cv,org.cv,cw,com.cw,edu.cw,net.cw,org.cw,cx,gov.cx,cy,ac.cy,biz.cy,com.cy,ekloges.cy,gov.cy,ltd.cy,mil.cy,net.cy,org.cy,press.cy,pro.cy,tm.cy,cz,de,dj,dk,dm,com.dm,net.dm,org.dm,edu.dm,gov.dm,do,art.do,com.do,edu.do,gob.do,gov.do,mil.do,net.do,org.do,sld.do,web.do,dz,art.dz,asso.dz,com.dz,edu.dz,gov.dz,org.dz,net.dz,pol.dz,soc.dz,tm.dz,ec,com.ec,info.ec,net.ec,fin.ec,k12.ec,med.ec,pro.ec,org.ec,edu.ec,gov.ec,gob.ec,mil.ec,edu,ee,edu.ee,gov.ee,riik.ee,lib.ee,med.ee,com.ee,pri.ee,aip.ee,org.ee,fie.ee,eg,com.eg,edu.eg,eun.eg,gov.eg,mil.eg,name.eg,net.eg,org.eg,sci.eg,er,es,com.es,nom.es,org.es,gob.es,edu.es,et,com.et,gov.et,org.et,edu.et,biz.et,name.et,info.et,net.et,eu,fi,aland.fi,fj,ac.fj,biz.fj,com.fj,gov.fj,info.fj,mil.fj,name.fj,net.fj,org.fj,pro.fj,fk,com.fm,edu.fm,net.fm,org.fm,fm,fo,fr,asso.fr,com.fr,gouv.fr,nom.fr,prd.fr,tm.fr,aeroport.fr,avocat.fr,avoues.fr,cci.fr,chambagri.fr,chirurgiens-dentistes.fr,experts-comptables.fr,geometre-expert.fr,greta.fr,huissier-justice.fr,medecin.fr,notaires.fr,pharmacien.fr,port.fr,veterinaire.fr,ga,gb,edu.gd,gov.gd,gd,ge,com.ge,edu.ge,gov.ge,org.ge,mil.ge,net.ge,pvt.ge,gf,gg,co.gg,net.gg,org.gg,gh,com.gh,edu.gh,gov.gh,org.gh,mil.gh,gi,com.gi,ltd.gi,gov.gi,mod.gi,edu.gi,org.gi,gl,co.gl,com.gl,edu.gl,net.gl,org.gl,gm,gn,ac.gn,com.gn,edu.gn,gov.gn,org.gn,net.gn,gov,gp,com.gp,net.gp,mobi.gp,edu.gp,org.gp,asso.gp,gq,gr,com.gr,edu.gr,net.gr,org.gr,gov.gr,gs,gt,com.gt,edu.gt,gob.gt,ind.gt,mil.gt,net.gt,org.gt,gu,com.gu,edu.gu,gov.gu,guam.gu,info.gu,net.gu,org.gu,web.gu,gw,gy,co.gy,com.gy,edu.gy,gov.gy,net.gy,org.gy,hk,com.hk,edu.hk,gov.hk,idv.hk,net.hk,org.hk,hm,hn,com.hn,edu.hn,org.hn,net.hn,mil.hn,gob.hn,hr,iz.hr,from.hr,name.hr,com.hr,ht,com.ht,shop.ht,firm.ht,info.ht,adult.ht,net.ht,pro.ht,org.ht,med.ht,art.ht,coop.ht,pol.ht,asso.ht,edu.ht,rel.ht,gouv.ht,perso.ht,hu,co.hu,info.hu,org.hu,priv.hu,sport.hu,tm.hu,2000.hu,agrar.hu,bolt.hu,casino.hu,city.hu,erotica.hu,erotika.hu,film.hu,forum.hu,games.hu,hotel.hu,ingatlan.hu,jogasz.hu,konyvelo.hu,lakas.hu,media.hu,news.hu,reklam.hu,sex.hu,shop.hu,suli.hu,szex.hu,tozsde.hu,utazas.hu,video.hu,id,ac.id,biz.id,co.id,desa.id,go.id,mil.id,my.id,net.id,or.id,ponpes.id,sch.id,web.id,ie,gov.ie,il,ac.il,co.il,gov.il,idf.il,k12.il,muni.il,net.il,org.il,im,ac.im,co.im,com.im,ltd.co.im,net.im,org.im,plc.co.im,tt.im,tv.im,in,5g.in,6g.in,ac.in,ai.in,am.in,bihar.in,biz.in,business.in,ca.in,cn.in,co.in,com.in,coop.in,cs.in,delhi.in,dr.in,edu.in,er.in,firm.in,gen.in,gov.in,gujarat.in,ind.in,info.in,int.in,internet.in,io.in,me.in,mil.in,net.in,nic.in,org.in,pg.in,post.in,pro.in,res.in,travel.in,tv.in,uk.in,up.in,us.in,info,int,eu.int,io,com.io,iq,gov.iq,edu.iq,mil.iq,com.iq,org.iq,net.iq,ir,ac.ir,co.ir,gov.ir,id.ir,net.ir,org.ir,sch.ir,is,net.is,com.is,edu.is,gov.is,org.is,int.is,it,gov.it,edu.it,je,co.je,net.je,org.je,jm,jo,com.jo,org.jo,net.jo,edu.jo,sch.jo,gov.jo,mil.jo,name.jo,jobs,jp,ac.jp,ad.jp,co.jp,ed.jp,go.jp,gr.jp,lg.jp,ne.jp,or.jp,ke,ac.ke,co.ke,go.ke,info.ke,me.ke,mobi.ke,ne.ke,or.ke,sc.ke,kg,org.kg,net.kg,com.kg,edu.kg,gov.kg,mil.kg,kh,ki,edu.ki,biz.ki,net.ki,org.ki,gov.ki,info.ki,com.ki,km,org.km,nom.km,gov.km,prd.km,tm.km,edu.km,mil.km,ass.km,com.km,kn,net.kn,org.kn,edu.kn,gov.kn,kp,com.kp,edu.kp,gov.kp,org.kp,rep.kp,tra.kp,kr,ac.kr,co.kr,es.kr,go.kr,hs.kr,kg.kr,mil.kr,ms.kr,ne.kr,or.kr,pe.kr,re.kr,sc.kr,kw,com.kw,edu.kw,emb.kw,gov.kw,ind.kw,net.kw,org.kw,ky,com.ky,edu.ky,net.ky,org.ky,kz,org.kz,edu.kz,net.kz,gov.kz,mil.kz,com.kz,la,int.la,net.la,info.la,edu.la,gov.la,per.la,com.la,org.la,lb,com.lb,edu.lb,gov.lb,net.lb,org.lb,lc,com.lc,net.lc,co.lc,org.lc,edu.lc,gov.lc,li,lk,gov.lk,sch.lk,net.lk,int.lk,com.lk,org.lk,edu.lk,ngo.lk,soc.lk,web.lk,ltd.lk,assn.lk,grp.lk,hotel.lk,ac.lk,lr,com.lr,edu.lr,gov.lr,org.lr,net.lr,ls,ac.ls,biz.ls,co.ls,edu.ls,gov.ls,info.ls,net.ls,org.ls,sc.ls,lt,gov.lt,lu,lv,com.lv,edu.lv,gov.lv,org.lv,mil.lv,id.lv,net.lv,asn.lv,conf.lv,ly,com.ly,net.ly,gov.ly,plc.ly,edu.ly,sch.ly,med.ly,org.ly,id.ly,ma,co.ma,net.ma,gov.ma,org.ma,ac.ma,press.ma,mc,tm.mc,asso.mc,md,me,co.me,net.me,org.me,edu.me,ac.me,gov.me,its.me,priv.me,mg,org.mg,nom.mg,gov.mg,prd.mg,tm.mg,edu.mg,mil.mg,com.mg,co.mg,mh,mil,mk,com.mk,org.mk,net.mk,edu.mk,gov.mk,inf.mk,name.mk,ml,com.ml,edu.ml,gouv.ml,gov.ml,net.ml,org.ml,presse.ml,mm,mn,gov.mn,edu.mn,org.mn,mo,com.mo,net.mo,org.mo,edu.mo,gov.mo,mobi,mp,mq,mr,gov.mr,ms,com.ms,edu.ms,gov.ms,net.ms,org.ms,mt,com.mt,edu.mt,net.mt,org.mt,mu,com.mu,net.mu,org.mu,gov.mu,ac.mu,co.mu,or.mu,museum,mv,aero.mv,biz.mv,com.mv,coop.mv,edu.mv,gov.mv,info.mv,int.mv,mil.mv,museum.mv,name.mv,net.mv,org.mv,pro.mv,mw,ac.mw,biz.mw,co.mw,com.mw,coop.mw,edu.mw,gov.mw,int.mw,museum.mw,net.mw,org.mw,mx,com.mx,org.mx,gob.mx,edu.mx,net.mx,my,biz.my,com.my,edu.my,gov.my,mil.my,name.my,net.my,org.my,mz,ac.mz,adv.mz,co.mz,edu.mz,gov.mz,mil.mz,net.mz,org.mz,na,info.na,pro.na,name.na,school.na,or.na,dr.na,us.na,mx.na,ca.na,in.na,cc.na,tv.na,ws.na,mobi.na,co.na,com.na,org.na,name,nc,asso.nc,nom.nc,ne,net,nf,com.nf,net.nf,per.nf,rec.nf,web.nf,arts.nf,firm.nf,info.nf,other.nf,store.nf,ng,com.ng,edu.ng,gov.ng,i.ng,mil.ng,mobi.ng,name.ng,net.ng,org.ng,sch.ng,ni,ac.ni,biz.ni,co.ni,com.ni,edu.ni,gob.ni,in.ni,info.ni,int.ni,mil.ni,net.ni,nom.ni,org.ni,web.ni,nl,no,fhs.no,vgs.no,fylkesbibl.no,folkebibl.no,museum.no,idrett.no,priv.no,mil.no,stat.no,dep.no,kommune.no,herad.no,np,nr,biz.nr,info.nr,gov.nr,edu.nr,org.nr,net.nr,com.nr,nu,nz,ac.nz,co.nz,cri.nz,geek.nz,gen.nz,govt.nz,health.nz,iwi.nz,kiwi.nz,maori.nz,mil.nz,māori.nz,net.nz,org.nz,parliament.nz,school.nz,om,co.om,com.om,edu.om,gov.om,med.om,museum.om,net.om,org.om,pro.om,onion,org,pa,ac.pa,gob.pa,com.pa,org.pa,sld.pa,edu.pa,net.pa,ing.pa,abo.pa,med.pa,nom.pa,pe,edu.pe,gob.pe,nom.pe,mil.pe,org.pe,com.pe,net.pe,pf,com.pf,org.pf,edu.pf,pg,ph,com.ph,net.ph,org.ph,gov.ph,edu.ph,ngo.ph,mil.ph,i.ph,pk,com.pk,net.pk,edu.pk,org.pk,fam.pk,biz.pk,web.pk,gov.pk,gob.pk,gok.pk,gon.pk,gop.pk,gos.pk,info.pk,pl,com.pl,net.pl,org.pl,aid.pl,agro.pl,atm.pl,auto.pl,biz.pl,edu.pl,gmina.pl,gsm.pl,info.pl,mail.pl,miasta.pl,media.pl,mil.pl,nieruchomosci.pl,nom.pl,pc.pl,powiat.pl,priv.pl,realestate.pl,rel.pl,sex.pl,shop.pl,sklep.pl,sos.pl,szkola.pl,targi.pl,tm.pl,tourism.pl,travel.pl,turystyka.pl,pm,pn,gov.pn,co.pn,org.pn,edu.pn,net.pn,post,pr,com.pr,net.pr,org.pr,gov.pr,edu.pr,isla.pr,pro.pr,biz.pr,info.pr,name.pr,est.pr,prof.pr,ac.pr,pro,aaa.pro,aca.pro,acct.pro,avocat.pro,bar.pro,cpa.pro,eng.pro,jur.pro,law.pro,med.pro,recht.pro,ps,edu.ps,gov.ps,sec.ps,plo.ps,com.ps,org.ps,net.ps,pt,net.pt,gov.pt,org.pt,edu.pt,int.pt,publ.pt,com.pt,nome.pt,pw,co.pw,ne.pw,or.pw,ed.pw,go.pw,belau.pw,py,com.py,coop.py,edu.py,gov.py,mil.py,net.py,org.py,qa,com.qa,edu.qa,gov.qa,mil.qa,name.qa,net.qa,org.qa,sch.qa,re,asso.re,com.re,nom.re,ro,arts.ro,com.ro,firm.ro,info.ro,nom.ro,nt.ro,org.ro,rec.ro,store.ro,tm.ro,www.ro,rs,ac.rs,co.rs,edu.rs,gov.rs,in.rs,org.rs,ru,rw,ac.rw,co.rw,coop.rw,gov.rw,mil.rw,net.rw,org.rw,sa,com.sa,net.sa,org.sa,gov.sa,med.sa,pub.sa,edu.sa,sch.sa,sb,com.sb,edu.sb,gov.sb,net.sb,org.sb,sc,com.sc,gov.sc,net.sc,org.sc,edu.sc,sd,com.sd,net.sd,org.sd,edu.sd,med.sd,tv.sd,gov.sd,info.sd,se,a.se,ac.se,b.se,bd.se,brand.se,c.se,d.se,e.se,f.se,fh.se,fhsk.se,fhv.se,g.se,h.se,i.se,k.se,komforb.se,kommunalforbund.se,komvux.se,l.se,lanbib.se,m.se,n.se,naturbruksgymn.se,o.se,org.se,p.se,parti.se,pp.se,press.se,r.se,s.se,t.se,tm.se,u.se,w.se,x.se,y.se,z.se,sg,com.sg,net.sg,org.sg,gov.sg,edu.sg,per.sg,sh,com.sh,net.sh,gov.sh,org.sh,mil.sh,si,sj,sk,sl,com.sl,net.sl,edu.sl,gov.sl,org.sl,sm,sn,art.sn,com.sn,edu.sn,gouv.sn,org.sn,perso.sn,univ.sn,so,com.so,edu.so,gov.so,me.so,net.so,org.so,sr,ss,biz.ss,com.ss,edu.ss,gov.ss,me.ss,net.ss,org.ss,sch.ss,st,co.st,com.st,consulado.st,edu.st,embaixada.st,mil.st,net.st,org.st,principe.st,saotome.st,store.st,su,sv,com.sv,edu.sv,gob.sv,org.sv,red.sv,sx,gov.sx,sy,edu.sy,gov.sy,net.sy,mil.sy,com.sy,org.sy,sz,co.sz,ac.sz,org.sz,tc,td,tel,tf,tg,th,ac.th,co.th,go.th,in.th,mi.th,net.th,or.th,tj,ac.tj,biz.tj,co.tj,com.tj,edu.tj,go.tj,gov.tj,int.tj,mil.tj,name.tj,net.tj,nic.tj,org.tj,test.tj,web.tj,tk,tl,gov.tl,tm,com.tm,co.tm,org.tm,net.tm,nom.tm,gov.tm,mil.tm,edu.tm,tn,com.tn,ens.tn,fin.tn,gov.tn,ind.tn,info.tn,intl.tn,mincom.tn,nat.tn,net.tn,org.tn,perso.tn,tourism.tn,to,com.to,gov.to,net.to,org.to,edu.to,mil.to,tr,av.tr,bbs.tr,bel.tr,biz.tr,com.tr,dr.tr,edu.tr,gen.tr,gov.tr,info.tr,mil.tr,k12.tr,kep.tr,name.tr,net.tr,org.tr,pol.tr,tel.tr,tsk.tr,tv.tr,web.tr,nc.tr,tt,co.tt,com.tt,org.tt,net.tt,biz.tt,info.tt,pro.tt,int.tt,coop.tt,jobs.tt,mobi.tt,travel.tt,museum.tt,aero.tt,name.tt,gov.tt,edu.tt,tv,tw,edu.tw,gov.tw,mil.tw,com.tw,net.tw,org.tw,idv.tw,game.tw,ebiz.tw,club.tw,tz,ac.tz,co.tz,go.tz,hotel.tz,info.tz,me.tz,mil.tz,mobi.tz,ne.tz,or.tz,sc.tz,tv.tz,ua,com.ua,edu.ua,gov.ua,in.ua,net.ua,org.ua,ug,co.ug,or.ug,ac.ug,sc.ug,go.ug,ne.ug,com.ug,org.ug,uk,ac.uk,co.uk,gov.uk,ltd.uk,me.uk,net.uk,nhs.uk,org.uk,plc.uk,police.uk,us,dni.us,fed.us,isa.us,kids.us,nsn.us,ak.us,al.us,ar.us,as.us,az.us,ca.us,co.us,ct.us,dc.us,de.us,fl.us,ga.us,gu.us,hi.us,ia.us,id.us,il.us,in.us,ks.us,ky.us,la.us,ma.us,md.us,me.us,mi.us,mn.us,mo.us,ms.us,mt.us,nc.us,nd.us,ne.us,nh.us,nj.us,nm.us,nv.us,ny.us,oh.us,ok.us,or.us,pa.us,pr.us,ri.us,sc.us,sd.us,tn.us,tx.us,ut.us,vi.us,vt.us,va.us,wa.us,wi.us,wv.us,wy.us,uy,com.uy,edu.uy,gub.uy,mil.uy,net.uy,org.uy,uz,co.uz,com.uz,net.uz,org.uz,va,vc,com.vc,net.vc,org.vc,gov.vc,mil.vc,edu.vc,ve,arts.ve,bib.ve,co.ve,com.ve,e12.ve,edu.ve,firm.ve,gob.ve,gov.ve,info.ve,int.ve,mil.ve,net.ve,nom.ve,org.ve,rar.ve,rec.ve,store.ve,tec.ve,web.ve,vg,vi,co.vi,com.vi,k12.vi,net.vi,org.vi,vn,ac.vn,ai.vn,biz.vn,com.vn,edu.vn,gov.vn,health.vn,id.vn,info.vn,int.vn,io.vn,name.vn,net.vn,org.vn,pro.vn,vu,com.vu,edu.vu,net.vu,org.vu,wf,ws,com.ws,net.ws,org.ws,gov.ws,edu.ws,yt,ye,com.ye,edu.ye,gov.ye,net.ye,mil.ye,org.ye,ac.za,agric.za,alt.za,co.za,edu.za,gov.za,grondar.za,law.za,mil.za,net.za,ngo.za,nic.za,nis.za,nom.za,org.za,school.za,tm.za,web.za,zm,ac.zm,biz.zm,co.zm,com.zm,edu.zm,gov.zm,info.zm,mil.zm,net.zm,org.zm,sch.zm,zw,ac.zw,co.zw,gov.zw,mil.zw,org.zw".split(",");
|
|
@@ -510,6 +504,469 @@ function getTopLevelDomain(hostname) {
|
|
|
510
504
|
}
|
|
511
505
|
}
|
|
512
506
|
|
|
507
|
+
class Processor {
|
|
508
|
+
constructor(options) {
|
|
509
|
+
this.selfOptions = options || {};
|
|
510
|
+
this.pipes = {};
|
|
511
|
+
}
|
|
512
|
+
options(options) {
|
|
513
|
+
if (options) {
|
|
514
|
+
this.selfOptions = options;
|
|
515
|
+
}
|
|
516
|
+
return this.selfOptions;
|
|
517
|
+
}
|
|
518
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
519
|
+
pipe(name, pipeArg) {
|
|
520
|
+
let pipe = pipeArg;
|
|
521
|
+
if (typeof name === "string") {
|
|
522
|
+
if (typeof pipe === "undefined") {
|
|
523
|
+
return this.pipes[name];
|
|
524
|
+
}
|
|
525
|
+
else {
|
|
526
|
+
this.pipes[name] = pipe;
|
|
527
|
+
}
|
|
528
|
+
}
|
|
529
|
+
if (name && name.name) {
|
|
530
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
531
|
+
pipe = name;
|
|
532
|
+
if (pipe.processor === this) {
|
|
533
|
+
return pipe;
|
|
534
|
+
}
|
|
535
|
+
this.pipes[pipe.name] = pipe;
|
|
536
|
+
}
|
|
537
|
+
pipe.processor = this;
|
|
538
|
+
return pipe;
|
|
539
|
+
}
|
|
540
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
541
|
+
process(input, pipe) {
|
|
542
|
+
let context = input;
|
|
543
|
+
context.options = this.options();
|
|
544
|
+
let nextPipe = pipe || input.pipe || "default";
|
|
545
|
+
let lastPipe;
|
|
546
|
+
while (nextPipe) {
|
|
547
|
+
if (typeof context.nextAfterChildren !== "undefined") {
|
|
548
|
+
// children processed and coming back to parent
|
|
549
|
+
context.next = context.nextAfterChildren;
|
|
550
|
+
context.nextAfterChildren = null;
|
|
551
|
+
}
|
|
552
|
+
if (typeof nextPipe === "string") {
|
|
553
|
+
nextPipe = this.pipe(nextPipe);
|
|
554
|
+
}
|
|
555
|
+
nextPipe.process(context);
|
|
556
|
+
lastPipe = nextPipe;
|
|
557
|
+
nextPipe = null;
|
|
558
|
+
if (context) {
|
|
559
|
+
if (context.next) {
|
|
560
|
+
context = context.next;
|
|
561
|
+
nextPipe = context.pipe || lastPipe;
|
|
562
|
+
}
|
|
563
|
+
}
|
|
564
|
+
}
|
|
565
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-return
|
|
566
|
+
return context.hasResult ? context.result : undefined;
|
|
567
|
+
}
|
|
568
|
+
}
|
|
569
|
+
|
|
570
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
571
|
+
class Pipe {
|
|
572
|
+
constructor(name) {
|
|
573
|
+
this.name = name;
|
|
574
|
+
this.filters = [];
|
|
575
|
+
}
|
|
576
|
+
process(input) {
|
|
577
|
+
if (!this.processor) {
|
|
578
|
+
throw new Error("add this pipe to a processor before using it");
|
|
579
|
+
}
|
|
580
|
+
const debug = this.debug;
|
|
581
|
+
const length = this.filters.length;
|
|
582
|
+
const context = input;
|
|
583
|
+
for (let index = 0; index < length; index++) {
|
|
584
|
+
const filter = this.filters[index];
|
|
585
|
+
if (debug) {
|
|
586
|
+
this.log(`filter: ${filter.filterName}`);
|
|
587
|
+
}
|
|
588
|
+
filter(context);
|
|
589
|
+
if (typeof context === "object" && context.exiting) {
|
|
590
|
+
context.exiting = false;
|
|
591
|
+
break;
|
|
592
|
+
}
|
|
593
|
+
}
|
|
594
|
+
if (!context.next && this.resultCheck) {
|
|
595
|
+
this.resultCheck(context);
|
|
596
|
+
}
|
|
597
|
+
}
|
|
598
|
+
log(msg) {
|
|
599
|
+
console.log(`[jsondiffpatch] ${this.name} pipe, ${msg}`);
|
|
600
|
+
}
|
|
601
|
+
append(...args) {
|
|
602
|
+
this.filters.push(...args);
|
|
603
|
+
return this;
|
|
604
|
+
}
|
|
605
|
+
prepend(...args) {
|
|
606
|
+
this.filters.unshift(...args);
|
|
607
|
+
return this;
|
|
608
|
+
}
|
|
609
|
+
indexOf(filterName) {
|
|
610
|
+
if (!filterName) {
|
|
611
|
+
throw new Error("a filter name is required");
|
|
612
|
+
}
|
|
613
|
+
for (let index = 0; index < this.filters.length; index++) {
|
|
614
|
+
const filter = this.filters[index];
|
|
615
|
+
if (filter.filterName === filterName) {
|
|
616
|
+
return index;
|
|
617
|
+
}
|
|
618
|
+
}
|
|
619
|
+
throw new Error(`filter not found: ${filterName}`);
|
|
620
|
+
}
|
|
621
|
+
list() {
|
|
622
|
+
return this.filters.map(f => f.filterName);
|
|
623
|
+
}
|
|
624
|
+
after(filterName, ...params) {
|
|
625
|
+
const index = this.indexOf(filterName);
|
|
626
|
+
this.filters.splice(index + 1, 0, ...params);
|
|
627
|
+
return this;
|
|
628
|
+
}
|
|
629
|
+
before(filterName, ...params) {
|
|
630
|
+
const index = this.indexOf(filterName);
|
|
631
|
+
this.filters.splice(index, 0, ...params);
|
|
632
|
+
return this;
|
|
633
|
+
}
|
|
634
|
+
replace(filterName, ...params) {
|
|
635
|
+
const index = this.indexOf(filterName);
|
|
636
|
+
this.filters.splice(index, 1, ...params);
|
|
637
|
+
return this;
|
|
638
|
+
}
|
|
639
|
+
remove(filterName) {
|
|
640
|
+
const index = this.indexOf(filterName);
|
|
641
|
+
this.filters.splice(index, 1);
|
|
642
|
+
return this;
|
|
643
|
+
}
|
|
644
|
+
clear() {
|
|
645
|
+
this.filters.length = 0;
|
|
646
|
+
return this;
|
|
647
|
+
}
|
|
648
|
+
shouldHaveResult(should) {
|
|
649
|
+
if (should === false) {
|
|
650
|
+
this.resultCheck = null;
|
|
651
|
+
return;
|
|
652
|
+
}
|
|
653
|
+
if (this.resultCheck) {
|
|
654
|
+
return;
|
|
655
|
+
}
|
|
656
|
+
this.resultCheck = context => {
|
|
657
|
+
if (!context.hasResult) {
|
|
658
|
+
console.log(context);
|
|
659
|
+
const error = new Error(`${this.name} failed`);
|
|
660
|
+
error.noResult = true;
|
|
661
|
+
throw error;
|
|
662
|
+
}
|
|
663
|
+
};
|
|
664
|
+
return this;
|
|
665
|
+
}
|
|
666
|
+
}
|
|
667
|
+
|
|
668
|
+
class Context {
|
|
669
|
+
setResult(result) {
|
|
670
|
+
this.result = result;
|
|
671
|
+
this.hasResult = true;
|
|
672
|
+
return this;
|
|
673
|
+
}
|
|
674
|
+
exit() {
|
|
675
|
+
this.exiting = true;
|
|
676
|
+
return this;
|
|
677
|
+
}
|
|
678
|
+
push(child, name) {
|
|
679
|
+
child.parent = this;
|
|
680
|
+
if (typeof name !== "undefined") {
|
|
681
|
+
child.childName = name;
|
|
682
|
+
}
|
|
683
|
+
child.root = this.root || this;
|
|
684
|
+
child.options = child.options || this.options;
|
|
685
|
+
if (!this.children) {
|
|
686
|
+
this.children = [child];
|
|
687
|
+
this.nextAfterChildren = this.next || null;
|
|
688
|
+
this.next = child;
|
|
689
|
+
}
|
|
690
|
+
else {
|
|
691
|
+
this.children[this.children.length - 1].next = child;
|
|
692
|
+
this.children.push(child);
|
|
693
|
+
}
|
|
694
|
+
child.next = this;
|
|
695
|
+
return this;
|
|
696
|
+
}
|
|
697
|
+
}
|
|
698
|
+
|
|
699
|
+
class DiffContext extends Context {
|
|
700
|
+
constructor(left, right) {
|
|
701
|
+
super();
|
|
702
|
+
this.left = left;
|
|
703
|
+
this.right = right;
|
|
704
|
+
this.pipe = "diff";
|
|
705
|
+
}
|
|
706
|
+
setResult(result) {
|
|
707
|
+
return super.setResult(result);
|
|
708
|
+
}
|
|
709
|
+
}
|
|
710
|
+
|
|
711
|
+
class PatchContext extends Context {
|
|
712
|
+
constructor(left, delta) {
|
|
713
|
+
super();
|
|
714
|
+
this.left = left;
|
|
715
|
+
this.delta = delta;
|
|
716
|
+
this.pipe = "patch";
|
|
717
|
+
}
|
|
718
|
+
}
|
|
719
|
+
|
|
720
|
+
function arrayEquals(a, b) {
|
|
721
|
+
if (a.length !== b.length) {
|
|
722
|
+
return false;
|
|
723
|
+
}
|
|
724
|
+
for (let i = 0; i < a.length; i++) {
|
|
725
|
+
if (a[i] !== b[i]) {
|
|
726
|
+
return false;
|
|
727
|
+
}
|
|
728
|
+
}
|
|
729
|
+
return true;
|
|
730
|
+
}
|
|
731
|
+
const diffFilter$1 = function trivialMatchesDiffFilter(context) {
|
|
732
|
+
if (context.left === context.right) {
|
|
733
|
+
context.setResult(undefined).exit();
|
|
734
|
+
return;
|
|
735
|
+
}
|
|
736
|
+
if (typeof context.left === "undefined") {
|
|
737
|
+
if (typeof context.right === "function") {
|
|
738
|
+
throw new Error("functions are not supported");
|
|
739
|
+
}
|
|
740
|
+
context.setResult([context.right]).exit();
|
|
741
|
+
return;
|
|
742
|
+
}
|
|
743
|
+
if (typeof context.right === "undefined") {
|
|
744
|
+
context.setResult([context.left, 0, 0]).exit();
|
|
745
|
+
return;
|
|
746
|
+
}
|
|
747
|
+
if (typeof context.left === "function" || typeof context.right === "function") {
|
|
748
|
+
throw new Error("functions are not supported");
|
|
749
|
+
}
|
|
750
|
+
context.leftType = context.left === null ? "null" : typeof context.left;
|
|
751
|
+
context.rightType = context.right === null ? "null" : typeof context.right;
|
|
752
|
+
if (context.leftType !== context.rightType) {
|
|
753
|
+
context.setResult([context.left, context.right]).exit();
|
|
754
|
+
return;
|
|
755
|
+
}
|
|
756
|
+
if (context.leftType === "boolean" || context.leftType === "number" || context.leftType === "string") {
|
|
757
|
+
context.setResult([context.left, context.right]).exit();
|
|
758
|
+
return;
|
|
759
|
+
}
|
|
760
|
+
if (context.leftType === "object") {
|
|
761
|
+
context.leftIsArray = Array.isArray(context.left);
|
|
762
|
+
}
|
|
763
|
+
if (context.rightType === "object") {
|
|
764
|
+
context.rightIsArray = Array.isArray(context.right);
|
|
765
|
+
}
|
|
766
|
+
if (context.leftIsArray !== context.rightIsArray) {
|
|
767
|
+
context.setResult([context.left, context.right]).exit();
|
|
768
|
+
return;
|
|
769
|
+
}
|
|
770
|
+
if (context.leftIsArray && context.rightIsArray) {
|
|
771
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-call
|
|
772
|
+
if (arrayEquals(context.left, context.right)) {
|
|
773
|
+
context.setResult(undefined).exit();
|
|
774
|
+
return;
|
|
775
|
+
}
|
|
776
|
+
else {
|
|
777
|
+
context.setResult([context.left, context.right]).exit();
|
|
778
|
+
return;
|
|
779
|
+
}
|
|
780
|
+
}
|
|
781
|
+
if (context.left instanceof RegExp) {
|
|
782
|
+
if (context.right instanceof RegExp) {
|
|
783
|
+
context.setResult([context.left.toString(), context.right.toString()]).exit();
|
|
784
|
+
}
|
|
785
|
+
else {
|
|
786
|
+
context.setResult([context.left, context.right]).exit();
|
|
787
|
+
}
|
|
788
|
+
}
|
|
789
|
+
};
|
|
790
|
+
diffFilter$1.filterName = "trivial";
|
|
791
|
+
const patchFilter$1 = function trivialMatchesPatchFilter(context) {
|
|
792
|
+
if (typeof context.delta === "undefined") {
|
|
793
|
+
context.setResult(context.left).exit();
|
|
794
|
+
return;
|
|
795
|
+
}
|
|
796
|
+
context.nested = !Array.isArray(context.delta);
|
|
797
|
+
if (context.nested) {
|
|
798
|
+
return;
|
|
799
|
+
}
|
|
800
|
+
const nonNestedDelta = context.delta;
|
|
801
|
+
if (nonNestedDelta.length === 1) {
|
|
802
|
+
context.setResult(nonNestedDelta[0]).exit();
|
|
803
|
+
return;
|
|
804
|
+
}
|
|
805
|
+
if (nonNestedDelta.length === 2) {
|
|
806
|
+
if (context.left instanceof RegExp) {
|
|
807
|
+
const regexArgs = /^\/(.*)\/([gimyu]+)$/.exec(nonNestedDelta[1]);
|
|
808
|
+
if (regexArgs) {
|
|
809
|
+
context.setResult(new RegExp(regexArgs[1], regexArgs[2])).exit();
|
|
810
|
+
return;
|
|
811
|
+
}
|
|
812
|
+
}
|
|
813
|
+
context.setResult(nonNestedDelta[1]).exit();
|
|
814
|
+
return;
|
|
815
|
+
}
|
|
816
|
+
if (nonNestedDelta.length === 3 && nonNestedDelta[2] === 0) {
|
|
817
|
+
context.setResult(undefined).exit();
|
|
818
|
+
}
|
|
819
|
+
};
|
|
820
|
+
patchFilter$1.filterName = "trivial";
|
|
821
|
+
|
|
822
|
+
const collectChildrenDiffFilter = context => {
|
|
823
|
+
if (!context || !context.children) {
|
|
824
|
+
return;
|
|
825
|
+
}
|
|
826
|
+
const length = context.children.length;
|
|
827
|
+
let child;
|
|
828
|
+
let result = context.result;
|
|
829
|
+
for (let index = 0; index < length; index++) {
|
|
830
|
+
child = context.children[index];
|
|
831
|
+
if (typeof child.result === "undefined") {
|
|
832
|
+
continue;
|
|
833
|
+
}
|
|
834
|
+
result = result || {};
|
|
835
|
+
result[child.childName] = child.result;
|
|
836
|
+
}
|
|
837
|
+
if (result && context.leftIsArray) {
|
|
838
|
+
result._t = "a";
|
|
839
|
+
}
|
|
840
|
+
context.setResult(result).exit();
|
|
841
|
+
};
|
|
842
|
+
collectChildrenDiffFilter.filterName = "collectChildren";
|
|
843
|
+
const objectsDiffFilter = context => {
|
|
844
|
+
if (context.leftIsArray || context.leftType !== "object") {
|
|
845
|
+
return;
|
|
846
|
+
}
|
|
847
|
+
const left = context.left;
|
|
848
|
+
const right = context.right;
|
|
849
|
+
let name;
|
|
850
|
+
let child;
|
|
851
|
+
const propertyFilter = context.options.propertyFilter;
|
|
852
|
+
for (name in left) {
|
|
853
|
+
if (!Object.prototype.hasOwnProperty.call(left, name)) {
|
|
854
|
+
continue;
|
|
855
|
+
}
|
|
856
|
+
if (propertyFilter && !propertyFilter(name, context)) {
|
|
857
|
+
continue;
|
|
858
|
+
}
|
|
859
|
+
child = new DiffContext(left[name], right[name]);
|
|
860
|
+
context.push(child, name);
|
|
861
|
+
}
|
|
862
|
+
for (name in right) {
|
|
863
|
+
if (!Object.prototype.hasOwnProperty.call(right, name)) {
|
|
864
|
+
continue;
|
|
865
|
+
}
|
|
866
|
+
if (propertyFilter && !propertyFilter(name, context)) {
|
|
867
|
+
continue;
|
|
868
|
+
}
|
|
869
|
+
if (typeof left[name] === "undefined") {
|
|
870
|
+
child = new DiffContext(undefined, right[name]);
|
|
871
|
+
context.push(child, name);
|
|
872
|
+
}
|
|
873
|
+
}
|
|
874
|
+
if (!context.children || context.children.length === 0) {
|
|
875
|
+
context.setResult(undefined).exit();
|
|
876
|
+
return;
|
|
877
|
+
}
|
|
878
|
+
context.exit();
|
|
879
|
+
};
|
|
880
|
+
objectsDiffFilter.filterName = "objects";
|
|
881
|
+
const patchFilter = function nestedPatchFilter(context) {
|
|
882
|
+
if (!context.nested) {
|
|
883
|
+
return;
|
|
884
|
+
}
|
|
885
|
+
const nestedDelta = context.delta;
|
|
886
|
+
if (nestedDelta._t) {
|
|
887
|
+
return;
|
|
888
|
+
}
|
|
889
|
+
const objectDelta = nestedDelta;
|
|
890
|
+
let name;
|
|
891
|
+
let child;
|
|
892
|
+
for (name in objectDelta) {
|
|
893
|
+
child = new PatchContext(context.left[name], objectDelta[name]);
|
|
894
|
+
context.push(child, name);
|
|
895
|
+
}
|
|
896
|
+
context.exit();
|
|
897
|
+
};
|
|
898
|
+
patchFilter.filterName = "objects";
|
|
899
|
+
const collectChildrenPatchFilter = function collectChildrenPatchFilter(context) {
|
|
900
|
+
if (!context || !context.children) {
|
|
901
|
+
return;
|
|
902
|
+
}
|
|
903
|
+
const deltaWithChildren = context.delta;
|
|
904
|
+
if (deltaWithChildren._t) {
|
|
905
|
+
return;
|
|
906
|
+
}
|
|
907
|
+
const object = context.left;
|
|
908
|
+
const length = context.children.length;
|
|
909
|
+
let child;
|
|
910
|
+
for (let index = 0; index < length; index++) {
|
|
911
|
+
child = context.children[index];
|
|
912
|
+
const property = child.childName;
|
|
913
|
+
if (Object.prototype.hasOwnProperty.call(context.left, property) && child.result === undefined) {
|
|
914
|
+
delete object[property];
|
|
915
|
+
}
|
|
916
|
+
else if (object[property] !== child.result) {
|
|
917
|
+
object[property] = child.result;
|
|
918
|
+
}
|
|
919
|
+
}
|
|
920
|
+
context.setResult(object).exit();
|
|
921
|
+
};
|
|
922
|
+
collectChildrenPatchFilter.filterName = "collectChildren";
|
|
923
|
+
|
|
924
|
+
const diffFilter = function datesDiffFilter(context) {
|
|
925
|
+
if (context.left instanceof Date) {
|
|
926
|
+
if (context.right instanceof Date) {
|
|
927
|
+
if (context.left.getTime() !== context.right.getTime()) {
|
|
928
|
+
context.setResult([context.left, context.right]);
|
|
929
|
+
}
|
|
930
|
+
else {
|
|
931
|
+
context.setResult(undefined);
|
|
932
|
+
}
|
|
933
|
+
}
|
|
934
|
+
else {
|
|
935
|
+
context.setResult([context.left, context.right]);
|
|
936
|
+
}
|
|
937
|
+
context.exit();
|
|
938
|
+
}
|
|
939
|
+
else if (context.right instanceof Date) {
|
|
940
|
+
context.setResult([context.left, context.right]).exit();
|
|
941
|
+
}
|
|
942
|
+
};
|
|
943
|
+
diffFilter.filterName = "dates";
|
|
944
|
+
|
|
945
|
+
class DiffPatcher {
|
|
946
|
+
constructor(options) {
|
|
947
|
+
this.processor = new Processor(options);
|
|
948
|
+
this.processor.pipe(new Pipe("diff")
|
|
949
|
+
.append(collectChildrenDiffFilter, diffFilter$1, diffFilter, objectsDiffFilter)
|
|
950
|
+
.shouldHaveResult());
|
|
951
|
+
this.processor.pipe(new Pipe("patch")
|
|
952
|
+
.append(collectChildrenPatchFilter, patchFilter$1, patchFilter)
|
|
953
|
+
.shouldHaveResult());
|
|
954
|
+
}
|
|
955
|
+
options(options) {
|
|
956
|
+
return this.processor.options(options);
|
|
957
|
+
}
|
|
958
|
+
diff(left, right) {
|
|
959
|
+
return this.processor.process(new DiffContext(left, right));
|
|
960
|
+
}
|
|
961
|
+
patch(left, delta) {
|
|
962
|
+
return this.processor.process(new PatchContext(left, delta));
|
|
963
|
+
}
|
|
964
|
+
}
|
|
965
|
+
|
|
966
|
+
function create(options) {
|
|
967
|
+
return new DiffPatcher(options);
|
|
968
|
+
}
|
|
969
|
+
|
|
513
970
|
/* global analytics */
|
|
514
971
|
var __awaiter$1 = (undefined && undefined.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
515
972
|
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
@@ -520,6 +977,7 @@ var __awaiter$1 = (undefined && undefined.__awaiter) || function (thisArg, _argu
|
|
|
520
977
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
521
978
|
});
|
|
522
979
|
};
|
|
980
|
+
const diff = create();
|
|
523
981
|
const defaultConfig = {
|
|
524
982
|
/* Your segment writeKey */
|
|
525
983
|
writeKey: null,
|
|
@@ -530,6 +988,7 @@ const defaultConfig = {
|
|
|
530
988
|
echoEvents: false,
|
|
531
989
|
cookieDomain: undefined,
|
|
532
990
|
runtime: undefined,
|
|
991
|
+
fetchTimeoutMs: undefined,
|
|
533
992
|
s2s: undefined,
|
|
534
993
|
};
|
|
535
994
|
const parseQuery = (qs) => {
|
|
@@ -830,13 +1289,22 @@ function adjustPayload(payload, config, storage, s2s) {
|
|
|
830
1289
|
delete withContext.options;
|
|
831
1290
|
return withContext;
|
|
832
1291
|
}
|
|
1292
|
+
function isDiff(obj) {
|
|
1293
|
+
const keys = Object.keys(obj);
|
|
1294
|
+
return keys.length === 1 && keys[0] === "__diff";
|
|
1295
|
+
}
|
|
833
1296
|
function processDestinations(destinations, method, originalEvent, debug, analyticsInstance) {
|
|
834
1297
|
return __awaiter$1(this, void 0, void 0, function* () {
|
|
835
1298
|
const promises = [];
|
|
836
1299
|
for (const destination of destinations) {
|
|
837
1300
|
let newEvents = [originalEvent];
|
|
838
1301
|
if (destination.newEvents) {
|
|
839
|
-
|
|
1302
|
+
try {
|
|
1303
|
+
newEvents = destination.newEvents.map(e => e === "same" ? originalEvent : isDiff(e) ? diff.patch(originalEvent, e.__diff) : e);
|
|
1304
|
+
}
|
|
1305
|
+
catch (e) {
|
|
1306
|
+
console.error(`[JITSU] Error applying '${destination.id}' changes to event: ${e === null || e === void 0 ? void 0 : e.message}`, e);
|
|
1307
|
+
}
|
|
840
1308
|
}
|
|
841
1309
|
const credentials = Object.assign(Object.assign({}, destination.credentials), destination.options);
|
|
842
1310
|
if (destination.deviceOptions.type === "internal-plugin") {
|
|
@@ -939,6 +1407,12 @@ function send(method, payload, jitsuConfig, instance, store) {
|
|
|
939
1407
|
// console.log(`[JITSU] Sending event to ${url}: `, JSON.stringify(payload, null, 2));
|
|
940
1408
|
// }
|
|
941
1409
|
const adjustedPayload = adjustPayload(payload, jitsuConfig, store, s2s);
|
|
1410
|
+
const abortController = jitsuConfig.fetchTimeoutMs ? new AbortController() : undefined;
|
|
1411
|
+
const abortTimeout = jitsuConfig.fetchTimeoutMs
|
|
1412
|
+
? setTimeout(() => {
|
|
1413
|
+
abortController.abort();
|
|
1414
|
+
}, jitsuConfig.fetchTimeoutMs)
|
|
1415
|
+
: undefined;
|
|
942
1416
|
const authHeader = jitsuConfig.writeKey ? { "X-Write-Key": jitsuConfig.writeKey } : {};
|
|
943
1417
|
let fetchResult;
|
|
944
1418
|
try {
|
|
@@ -946,7 +1420,11 @@ function send(method, payload, jitsuConfig, instance, store) {
|
|
|
946
1420
|
method: "POST",
|
|
947
1421
|
headers: Object.assign(Object.assign({ "Content-Type": "application/json" }, authHeader), debugHeader),
|
|
948
1422
|
body: JSON.stringify(adjustedPayload),
|
|
1423
|
+
signal: abortController === null || abortController === void 0 ? void 0 : abortController.signal,
|
|
949
1424
|
});
|
|
1425
|
+
if (abortTimeout) {
|
|
1426
|
+
clearTimeout(abortTimeout);
|
|
1427
|
+
}
|
|
950
1428
|
}
|
|
951
1429
|
catch (e) {
|
|
952
1430
|
throw new Error(`Calling ${url} failed: ${e.message}`);
|
|
@@ -1183,15 +1661,15 @@ function createUnderlyingAnalyticsInstance(opts, rt, plugins = []) {
|
|
|
1183
1661
|
}, setAnonymousId: (id) => {
|
|
1184
1662
|
if (opts.debug) {
|
|
1185
1663
|
console.log("[JITSU DEBUG] Setting anonymous id to " + id);
|
|
1186
|
-
//Workaround for analytics.js bug. Underlying setAnonymousId doesn't work set the id immediately,
|
|
1187
|
-
//so we got to it manually here. See https://github.com/jitsucom/jitsu/issues/1060
|
|
1188
|
-
storage.setItem("__anon_id", id);
|
|
1189
|
-
const userState = analytics.user();
|
|
1190
|
-
if (userState) {
|
|
1191
|
-
userState.anonymousId = id;
|
|
1192
|
-
}
|
|
1193
|
-
analytics.setAnonymousId(id);
|
|
1194
1664
|
}
|
|
1665
|
+
//Workaround for analytics.js bug. Underlying setAnonymousId doesn't work set the id immediately,
|
|
1666
|
+
//so we got to it manually here. See https://github.com/jitsucom/jitsu/issues/1060
|
|
1667
|
+
storage.setItem("__anon_id", id);
|
|
1668
|
+
const userState = analytics.user();
|
|
1669
|
+
if (userState) {
|
|
1670
|
+
userState.anonymousId = id;
|
|
1671
|
+
}
|
|
1672
|
+
analytics.setAnonymousId(id);
|
|
1195
1673
|
}, group(groupId, traits, options, callback) {
|
|
1196
1674
|
return __awaiter(this, void 0, void 0, function* () {
|
|
1197
1675
|
const results = [];
|
package/dist/version.d.ts
CHANGED