Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@uniformdev/context-react

Package Overview
Dependencies
Maintainers
10
Versions
637
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@uniformdev/context-react - npm Package Compare versions

Comparing version 16.1.0 to 16.1.1-alpha.139

2

dist/index.esm.js

@@ -1,1 +0,1 @@

import{useContext as G}from"react";import{createContext as N}from"react";var U=N(void 0),S=N({});function s(t={}){let{throwOnMissingProvider:e=!0}=t,o=G(U);if(e){if(o===void 0)throw new Error("useUniformContext must be used within a <UniformContext> provider");return o}return o}import{useEffect as K,useState as Y}from"react";function zt(){let{context:t}=s(),[e,o]=Y(t.quirks),r=n=>{o(n)};return K(()=>(t.events.on("quirksUpdated",r),()=>{t.events.off("quirksUpdated",r)}),[t]),e}import{useEffect as Z,useState as $}from"react";import{dequal as tt}from"dequal/lite";function H(){let{context:t}=s(),[e,o]=$(t.scores);return Z(()=>{let r=p=>{o(p)},n=t.scores;return tt(e,n)||o(n),t.events.on("scoresUpdated",r),()=>{t.events.off("scoresUpdated",r)}},[t]),e}import F from"react";import y,{useMemo as et}from"react";function M({variations:t,component:e,wrapperComponent:o,name:r,count:n=1}){let{context:p}=s(),i=H(),{variations:f,personalized:x}=et(()=>p.personalize({name:r,variations:t,take:n}),[i,p,n,r,t]),T=o!=null?o:({children:l})=>y.createElement(y.Fragment,null,l),E=e;return y.createElement(S.Provider,{value:{personalized:!0}},f.length?y.createElement(T,{personalizationOccurred:x},f.map(l=>y.createElement(E,{key:l.id,personalizationResult:{variation:l,personalizationOccurred:x},...l}))):null)}import{ScriptType as h}from"@uniformdev/context";import C,{Fragment as nt}from"react";import{EdgeNodeTagName as ot}from"@uniformdev/context";import{createElement as rt}from"react";var d=t=>rt(ot,t);function A(t){let{variations:e,count:o,component:r}=t,n={count:o!=null?o:1},p=r;return C.createElement(C.Fragment,null,C.createElement(d,{"data-type":h.ListStart,dangerouslySetInnerHTML:{__html:JSON.stringify(n)}}),e.map(i=>C.createElement(nt,{key:i.id},C.createElement(d,{"data-type":h.ListItemSettings,dangerouslySetInnerHTML:{__html:JSON.stringify({id:i.id,pz:i.pz||null})}}),C.createElement(d,{"data-type":h.ListItem},C.createElement(p,{key:i.id,personalizationResult:{variation:i,personalizationOccurred:!1},...i})))),C.createElement(d,{"data-type":h.ListEnd}))}var g=typeof window=="undefined";function Zt(t){let{outputType:e}=s();return!g||e==="standard"?F.createElement(M,{...t}):e==="edge"?F.createElement(A,{...t}):null}import q from"react";import{ScriptType as k}from"@uniformdev/context";import P,{Fragment as it}from"react";function R(t){let{name:e,variations:o,component:r}=t,n={name:e},p=r;return P.createElement(P.Fragment,null,P.createElement(d,{"data-type":k.TestStart,dangerouslySetInnerHTML:{__html:JSON.stringify(n)}}),o.map((i,f)=>P.createElement(it,{key:i.id},P.createElement(d,{"data-type":k.ListItemSettings,dangerouslySetInnerHTML:{__html:JSON.stringify({id:i.id})}}),P.createElement(d,{"data-type":k.ListItem},P.createElement(p,{key:f,...i})))),P.createElement(d,{"data-type":k.TestEnd}))}import st from"react";var D=({name:t,variations:e,component:o})=>{let{context:r}=s(),{result:n}=r.test({name:t,variations:e});return n?st.createElement(o,{...n}):null};var Ce=t=>{let{outputType:e}=s();return!g||e==="standard"?q.createElement(D,{...t}):e==="edge"?q.createElement(R,{...t}):null};import L,{useEffect as at}from"react";import{SERVER_STATE_ID as mt}from"@uniformdev/context";import pt from"cookie";var he=({context:t,children:e,outputType:o="standard",trackRouteOnRender:r=!0})=>(at(()=>{g||!r||t.update({url:new URL(window.location.href),cookies:pt.parse(document.cookie)})}),L.createElement(U.Provider,{value:{context:t,outputType:o}},e,g?L.createElement(ft,null):null));function ft(){let{context:t}=s(),e={quirks:t.storage.data.quirks,tests:t.storage.data.tests,ssv:t.scores};return L.createElement("script",{id:mt,type:"application/json",dangerouslySetInnerHTML:{__html:JSON.stringify(e)}})}import{createElement as ct,useEffect as J,useRef as b,useState as B}from"react";import{useContext as ut}from"react";var O=t=>{let{personalized:e}=ut(S);return typeof e!="undefined"?e:typeof(t==null?void 0:t.personalized)!="undefined"?t.personalized:!1};var He=({behavior:t,children:e,tagName:o="div",threshold:r=.5,disableVisibilityTrigger:n=typeof window=="undefined"||!("IntersectionObserver"in window),...p})=>{let i=typeof document=="undefined"?"__uniform_ssr_url":document.location.href,{context:f}=s(),x=O(),[T,E]=B(),[l,V]=B(!1),v=b(null),u=b();return J(()=>{T!==i&&(V(!1),E(i))},[i,T]),J(()=>{var I;let _=!t||Array.isArray(t)&&!t.length;if(x||_||!v.current)return;let X=Array.isArray(t)?t:[t],w=()=>{var c;l||(f.update({enrichments:X}),V(!0),(c=u.current)==null||c.call(u))};if(n)w();else{(I=u.current)==null||I.call(u);let c=new IntersectionObserver(([z])=>{z.isIntersecting&&w()},{threshold:r});c.observe(v.current),u.current=()=>{var z;return(z=c.disconnect)==null?void 0:z.call(c)}}return()=>{var c;(c=u.current)==null||c.call(u)}},[f,t,n,r,x,T,i,l]),ct(o,{...p,ref:v},e)};import Q from"react";import{useEffect as W,useState as j}from"react";var Je=({behavior:t,children:e})=>{let o=typeof document=="undefined"?"__uniform_ssr_url":document.location.href,{context:r}=s(),n=O(),[p,i]=j(),[f,x]=j(!1);return W(()=>{p!==o&&(x(!1),i(o))},[o,p]),W(()=>{let T=!t||Array.isArray(t)&&!t.length;if(n||T)return;(()=>{if(f)return;let V=Array.isArray(t)?t:[t];r.update({enrichments:V}),x(!0)})()},[r,t,n,f]),Q.createElement(Q.Fragment,null,e)};export{Zt as Personalize,Ce as Test,He as Track,Je as TrackFragment,he as UniformContext,zt as useQuirks,H as useScores,s as useUniformContext};
import{useContext as j}from"react";import{createContext as w}from"react";var V=w(void 0),z=w({});function s(t={}){let{throwOnMissingProvider:e=!0}=t,o=j(V);if(e){if(o===void 0)throw new Error("useUniformContext must be used within a <UniformContext> provider");return o}return o}import{useEffect as X,useState as G}from"react";function Et(){let{context:t}=s(),[e,o]=G(t.quirks),r=n=>{o(n)};return X(()=>(t.events.on("quirksUpdated",r),()=>{t.events.off("quirksUpdated",r)}),[t]),e}import{useEffect as K,useState as Y}from"react";import{dequal as Z}from"dequal/lite";function I(){let{context:t}=s(),[e,o]=Y(t.scores);return K(()=>{let r=a=>{o(a)},n=t.scores;return Z(e,n)||o(n),t.events.on("scoresUpdated",r),()=>{t.events.off("scoresUpdated",r)}},[t]),e}import M from"react";import P,{useMemo as $}from"react";function N({variations:t,component:e,wrapperComponent:o,name:r,count:n=1}){let{context:a}=s(),i=I(),{variations:m,personalized:d}=$(()=>a.personalize({name:r,variations:t,take:n}),[i,a,n,r,t]),l=o!=null?o:({children:c})=>P.createElement(P.Fragment,null,c),g=e;return P.createElement(z.Provider,{value:{personalized:!0}},m.length?P.createElement(l,{personalizationOccurred:d},m.map(c=>P.createElement(g,{key:c.id,personalizationResult:{variation:c,personalizationOccurred:d},...c}))):null)}import{ScriptType as U}from"@uniformdev/context";import x,{Fragment as ot}from"react";import{EdgeNodeTagName as tt}from"@uniformdev/context";import{createElement as et}from"react";var u=t=>et(tt,t);function H(t){let{variations:e,count:o,component:r}=t,n={count:o!=null?o:1},a=r;return x.createElement(x.Fragment,null,x.createElement(u,{"data-type":U.ListStart,dangerouslySetInnerHTML:{__html:JSON.stringify(n)}}),e.map(i=>x.createElement(ot,{key:i.id},x.createElement(u,{"data-type":U.ListItemSettings,dangerouslySetInnerHTML:{__html:JSON.stringify({id:i.id,pz:i.pz||null})}}),x.createElement(u,{"data-type":U.ListItem},x.createElement(a,{key:i.id,personalizationResult:{variation:i,personalizationOccurred:!1},...i})))),x.createElement(u,{"data-type":U.ListEnd}))}var C=typeof window=="undefined";function Kt(t){let{outputType:e}=s();return!C||e==="standard"?M.createElement(N,{...t}):e==="edge"?M.createElement(H,{...t}):null}import R from"react";import{ScriptType as S}from"@uniformdev/context";import T,{Fragment as rt}from"react";function A(t){let{name:e,variations:o,component:r}=t,n={name:e},a=r;return T.createElement(T.Fragment,null,T.createElement(u,{"data-type":S.TestStart,dangerouslySetInnerHTML:{__html:JSON.stringify(n)}}),o.map((i,m)=>T.createElement(rt,{key:i.id},T.createElement(u,{"data-type":S.ListItemSettings,dangerouslySetInnerHTML:{__html:JSON.stringify({id:i.id})}}),T.createElement(u,{"data-type":S.ListItem},T.createElement(a,{key:m,...i})))),T.createElement(u,{"data-type":S.TestEnd}))}import nt from"react";var F=({name:t,variations:e,component:o})=>{let{context:r}=s(),{result:n}=r.test({name:t,variations:e});return n?nt.createElement(o,{...n}):null};var xe=t=>{let{outputType:e}=s();return!C||e==="standard"?R.createElement(F,{...t}):e==="edge"?R.createElement(A,{...t}):null};import O,{useEffect as it}from"react";import{SERVER_STATE_ID as st}from"@uniformdev/context";import at from"cookie";var Ue=({context:t,children:e,outputType:o="standard",trackRouteOnRender:r=!0})=>(it(()=>{C||!r||t.update({url:new URL(window.location.href),cookies:at.parse(document.cookie)})}),O.createElement(V.Provider,{value:{context:t,outputType:o}},e,C?O.createElement(mt,null):null));function mt(){let{context:t}=s(),e={quirks:t.storage.data.quirks,tests:t.storage.data.tests,ssv:t.scores};return O.createElement("script",{id:st,type:"application/json",dangerouslySetInnerHTML:{__html:JSON.stringify(e)}})}import{createElement as ft,useEffect as D,useRef as q,useState as J}from"react";import{useContext as pt}from"react";var h=t=>{let{personalized:e}=pt(z);return typeof e!="undefined"?e:typeof(t==null?void 0:t.personalized)!="undefined"?t.personalized:!1};var Ie=({behavior:t,children:e,tagName:o="div",threshold:r=.5,disableVisibilityTrigger:n=typeof window=="undefined"||!("IntersectionObserver"in window),...a})=>{let i=typeof document=="undefined"?"__uniform_ssr_url":document.location.href,{context:m}=s(),d=h(),[l,g]=J(),[c,y]=J(!1),k=q(null),p=q();return D(()=>{l!==i&&(y(!1),g(i))},[i,l]),D(()=>{var _;let v=!t||Array.isArray(t)&&!t.length;if(d||v||!k.current)return;let W=Array.isArray(t)?t:[t],L=()=>{var f;c||(m.update({enrichments:W}),y(!0),(f=p.current)==null||f.call(p))};if(n)L();else{(_=p.current)==null||_.call(p);let f=new IntersectionObserver(([E])=>{E.isIntersecting&&L()},{threshold:r});f.observe(k.current),p.current=()=>{var E;return(E=f.disconnect)==null?void 0:E.call(f)}}return()=>{var f;(f=p.current)==null||f.call(p)}},[m,t,n,r,d,l,i,c]),ft(o,{...a,ref:k},e)};import b from"react";import{useEffect as B,useState as Q}from"react";var De=({behavior:t,children:e})=>{let o=typeof document=="undefined"?"__uniform_ssr_url":document.location.href,{context:r}=s(),n=h(),[a,i]=Q(),[m,d]=Q(!1);return B(()=>{a!==o&&(d(!1),i(o))},[o,a]),B(()=>{let l=!t||Array.isArray(t)&&!t.length;if(n||l)return;(()=>{if(m)return;let y=Array.isArray(t)?t:[t];r.update({enrichments:y}),d(!0)})()},[r,t,n,m]),b.createElement(b.Fragment,null,e)};export{Kt as Personalize,xe as Test,Ie as Track,De as TrackFragment,Ue as UniformContext,Et as useQuirks,I as useScores,s as useUniformContext};

@@ -1,1 +0,1 @@

var nt=Object.create;var v=Object.defineProperty;var it=Object.getOwnPropertyDescriptor;var st=Object.getOwnPropertyNames;var at=Object.getPrototypeOf,mt=Object.prototype.hasOwnProperty;var pt=(t,e)=>{for(var o in e)v(t,o,{get:e[o],enumerable:!0})},B=(t,e,o,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let r of st(e))!mt.call(t,r)&&r!==o&&v(t,r,{get:()=>e[r],enumerable:!(n=it(e,r))||n.enumerable});return t};var C=(t,e,o)=>(o=t!=null?nt(at(t)):{},B(e||!t||!t.__esModule?v(o,"default",{value:t,enumerable:!0}):o,t)),ft=t=>B(v({},"__esModule",{value:!0}),t);var Pt={};pt(Pt,{Personalize:()=>ct,Test:()=>dt,Track:()=>Tt,TrackFragment:()=>Ct,UniformContext:()=>lt,useQuirks:()=>ut,useScores:()=>A,useUniformContext:()=>s});module.exports=ft(Pt);var Q=require("react");var M=require("react"),L=(0,M.createContext)(void 0),_=(0,M.createContext)({});function s(t={}){let{throwOnMissingProvider:e=!0}=t,o=(0,Q.useContext)(L);if(e){if(o===void 0)throw new Error("useUniformContext must be used within a <UniformContext> provider");return o}return o}var w=require("react");function ut(){let{context:t}=s(),[e,o]=(0,w.useState)(t.quirks),n=r=>{o(r)};return(0,w.useEffect)(()=>(t.events.on("quirksUpdated",n),()=>{t.events.off("quirksUpdated",n)}),[t]),e}var I=require("react");var W=require("dequal/lite");function A(){let{context:t}=s(),[e,o]=(0,I.useState)(t.scores);return(0,I.useEffect)(()=>{let n=m=>{o(m)},r=t.scores;return(0,W.dequal)(e,r)||o(r),t.events.on("scoresUpdated",n),()=>{t.events.off("scoresUpdated",n)}},[t]),e}var F=C(require("react"));var y=C(require("react"));function j({variations:t,component:e,wrapperComponent:o,name:n,count:r=1}){let{context:m}=s(),i=A(),{variations:c,personalized:P}=(0,y.useMemo)(()=>m.personalize({name:n,variations:t,take:r}),[i,m,r,n,t]),g=o!=null?o:({children:T})=>y.default.createElement(y.default.Fragment,null,T),h=e;return y.default.createElement(_.Provider,{value:{personalized:!0}},c.length?y.default.createElement(g,{personalizationOccurred:P},c.map(T=>y.default.createElement(h,{key:T.id,personalizationResult:{variation:T,personalizationOccurred:P},...T}))):null)}var U=require("@uniformdev/context"),p=C(require("react"));var X=require("@uniformdev/context"),G=require("react"),x=t=>(0,G.createElement)(X.EdgeNodeTagName,t);function K(t){let{variations:e,count:o,component:n}=t,r={count:o!=null?o:1},m=n;return p.default.createElement(p.default.Fragment,null,p.default.createElement(x,{"data-type":U.ScriptType.ListStart,dangerouslySetInnerHTML:{__html:JSON.stringify(r)}}),e.map(i=>p.default.createElement(p.Fragment,{key:i.id},p.default.createElement(x,{"data-type":U.ScriptType.ListItemSettings,dangerouslySetInnerHTML:{__html:JSON.stringify({id:i.id,pz:i.pz||null})}}),p.default.createElement(x,{"data-type":U.ScriptType.ListItem},p.default.createElement(m,{key:i.id,personalizationResult:{variation:i,personalizationOccurred:!1},...i})))),p.default.createElement(x,{"data-type":U.ScriptType.ListEnd}))}var E=typeof window=="undefined";function ct(t){let{outputType:e}=s();return!E||e==="standard"?F.default.createElement(j,{...t}):e==="edge"?F.default.createElement(K,{...t}):null}var R=C(require("react"));var S=require("@uniformdev/context"),f=C(require("react"));function Y(t){let{name:e,variations:o,component:n}=t,r={name:e},m=n;return f.default.createElement(f.default.Fragment,null,f.default.createElement(x,{"data-type":S.ScriptType.TestStart,dangerouslySetInnerHTML:{__html:JSON.stringify(r)}}),o.map((i,c)=>f.default.createElement(f.Fragment,{key:i.id},f.default.createElement(x,{"data-type":S.ScriptType.ListItemSettings,dangerouslySetInnerHTML:{__html:JSON.stringify({id:i.id})}}),f.default.createElement(x,{"data-type":S.ScriptType.ListItem},f.default.createElement(m,{key:c,...i})))),f.default.createElement(x,{"data-type":S.ScriptType.TestEnd}))}var Z=C(require("react"));var $=({name:t,variations:e,component:o})=>{let{context:n}=s(),{result:r}=n.test({name:t,variations:e});return r?Z.default.createElement(o,{...r}):null};var dt=t=>{let{outputType:e}=s();return!E||e==="standard"?R.default.createElement($,{...t}):e==="edge"?R.default.createElement(Y,{...t}):null};var V=C(require("react")),tt=require("@uniformdev/context");var et=C(require("cookie")),lt=({context:t,children:e,outputType:o="standard",trackRouteOnRender:n=!0})=>((0,V.useEffect)(()=>{E||!n||t.update({url:new URL(window.location.href),cookies:et.default.parse(document.cookie)})}),V.default.createElement(L.Provider,{value:{context:t,outputType:o}},e,E?V.default.createElement(xt,null):null));function xt(){let{context:t}=s(),e={quirks:t.storage.data.quirks,tests:t.storage.data.tests,ssv:t.scores};return V.default.createElement("script",{id:tt.SERVER_STATE_ID,type:"application/json",dangerouslySetInnerHTML:{__html:JSON.stringify(e)}})}var u=require("react");var ot=require("react");var N=t=>{let{personalized:e}=(0,ot.useContext)(_);return typeof e!="undefined"?e:typeof(t==null?void 0:t.personalized)!="undefined"?t.personalized:!1};var Tt=({behavior:t,children:e,tagName:o="div",threshold:n=.5,disableVisibilityTrigger:r=typeof window=="undefined"||!("IntersectionObserver"in window),...m})=>{let i=typeof document=="undefined"?"__uniform_ssr_url":document.location.href,{context:c}=s(),P=N(),[g,h]=(0,u.useState)(),[T,k]=(0,u.useState)(!1),H=(0,u.useRef)(null),d=(0,u.useRef)();return(0,u.useEffect)(()=>{g!==i&&(k(!1),h(i))},[i,g]),(0,u.useEffect)(()=>{var b;let q=!t||Array.isArray(t)&&!t.length;if(P||q||!H.current)return;let rt=Array.isArray(t)?t:[t],J=()=>{var l;T||(c.update({enrichments:rt}),k(!0),(l=d.current)==null||l.call(d))};if(r)J();else{(b=d.current)==null||b.call(d);let l=new IntersectionObserver(([O])=>{O.isIntersecting&&J()},{threshold:n});l.observe(H.current),d.current=()=>{var O;return(O=l.disconnect)==null?void 0:O.call(l)}}return()=>{var l;(l=d.current)==null||l.call(d)}},[c,t,r,n,P,g,i,T]),(0,u.createElement)(o,{...m,ref:H},e)};var D=C(require("react")),z=require("react");var Ct=({behavior:t,children:e})=>{let o=typeof document=="undefined"?"__uniform_ssr_url":document.location.href,{context:n}=s(),r=N(),[m,i]=(0,z.useState)(),[c,P]=(0,z.useState)(!1);return(0,z.useEffect)(()=>{m!==o&&(P(!1),i(o))},[o,m]),(0,z.useEffect)(()=>{let g=!t||Array.isArray(t)&&!t.length;if(r||g)return;(()=>{if(c)return;let k=Array.isArray(t)?t:[t];n.update({enrichments:k}),P(!0)})()},[n,t,r,c]),D.default.createElement(D.default.Fragment,null,e)};0&&(module.exports={Personalize,Test,Track,TrackFragment,UniformContext,useQuirks,useScores,useUniformContext});
var rt=Object.create;var O=Object.defineProperty;var nt=Object.getOwnPropertyDescriptor;var it=Object.getOwnPropertyNames;var st=Object.getPrototypeOf,at=Object.prototype.hasOwnProperty;var mt=(t,e)=>{for(var o in e)O(t,o,{get:e[o],enumerable:!0})},b=(t,e,o,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let r of it(e))!at.call(t,r)&&r!==o&&O(t,r,{get:()=>e[r],enumerable:!(n=nt(e,r))||n.enumerable});return t};var T=(t,e,o)=>(o=t!=null?rt(st(t)):{},b(e||!t||!t.__esModule?O(o,"default",{value:t,enumerable:!0}):o,t)),pt=t=>b(O({},"__esModule",{value:!0}),t);var Ct={};mt(Ct,{Personalize:()=>ut,Test:()=>ct,Track:()=>xt,TrackFragment:()=>Tt,UniformContext:()=>dt,useQuirks:()=>ft,useScores:()=>M,useUniformContext:()=>s});module.exports=pt(Ct);var B=require("react");var H=require("react"),v=(0,H.createContext)(void 0),L=(0,H.createContext)({});function s(t={}){let{throwOnMissingProvider:e=!0}=t,o=(0,B.useContext)(v);if(e){if(o===void 0)throw new Error("useUniformContext must be used within a <UniformContext> provider");return o}return o}var _=require("react");function ft(){let{context:t}=s(),[e,o]=(0,_.useState)(t.quirks),n=r=>{o(r)};return(0,_.useEffect)(()=>(t.events.on("quirksUpdated",n),()=>{t.events.off("quirksUpdated",n)}),[t]),e}var w=require("react");var Q=require("dequal/lite");function M(){let{context:t}=s(),[e,o]=(0,w.useState)(t.scores);return(0,w.useEffect)(()=>{let n=a=>{o(a)},r=t.scores;return(0,Q.dequal)(e,r)||o(r),t.events.on("scoresUpdated",n),()=>{t.events.off("scoresUpdated",n)}},[t]),e}var A=T(require("react"));var g=T(require("react"));function W({variations:t,component:e,wrapperComponent:o,name:n,count:r=1}){let{context:a}=s(),i=M(),{variations:u,personalized:C}=(0,g.useMemo)(()=>a.personalize({name:n,variations:t,take:r}),[i,a,r,n,t]),P=o!=null?o:({children:x})=>g.default.createElement(g.default.Fragment,null,x),S=e;return g.default.createElement(L.Provider,{value:{personalized:!0}},u.length?g.default.createElement(P,{personalizationOccurred:C},u.map(x=>g.default.createElement(S,{key:x.id,personalizationResult:{variation:x,personalizationOccurred:C},...x}))):null)}var z=require("@uniformdev/context"),m=T(require("react"));var j=require("@uniformdev/context"),X=require("react"),l=t=>(0,X.createElement)(j.EdgeNodeTagName,t);function G(t){let{variations:e,count:o,component:n}=t,r={count:o!=null?o:1},a=n;return m.default.createElement(m.default.Fragment,null,m.default.createElement(l,{"data-type":z.ScriptType.ListStart,dangerouslySetInnerHTML:{__html:JSON.stringify(r)}}),e.map(i=>m.default.createElement(m.Fragment,{key:i.id},m.default.createElement(l,{"data-type":z.ScriptType.ListItemSettings,dangerouslySetInnerHTML:{__html:JSON.stringify({id:i.id,pz:i.pz||null})}}),m.default.createElement(l,{"data-type":z.ScriptType.ListItem},m.default.createElement(a,{key:i.id,personalizationResult:{variation:i,personalizationOccurred:!1},...i})))),m.default.createElement(l,{"data-type":z.ScriptType.ListEnd}))}var y=typeof window=="undefined";function ut(t){let{outputType:e}=s();return!y||e==="standard"?A.default.createElement(W,{...t}):e==="edge"?A.default.createElement(G,{...t}):null}var F=T(require("react"));var U=require("@uniformdev/context"),p=T(require("react"));function K(t){let{name:e,variations:o,component:n}=t,r={name:e},a=n;return p.default.createElement(p.default.Fragment,null,p.default.createElement(l,{"data-type":U.ScriptType.TestStart,dangerouslySetInnerHTML:{__html:JSON.stringify(r)}}),o.map((i,u)=>p.default.createElement(p.Fragment,{key:i.id},p.default.createElement(l,{"data-type":U.ScriptType.ListItemSettings,dangerouslySetInnerHTML:{__html:JSON.stringify({id:i.id})}}),p.default.createElement(l,{"data-type":U.ScriptType.ListItem},p.default.createElement(a,{key:u,...i})))),p.default.createElement(l,{"data-type":U.ScriptType.TestEnd}))}var Y=T(require("react"));var Z=({name:t,variations:e,component:o})=>{let{context:n}=s(),{result:r}=n.test({name:t,variations:e});return r?Y.default.createElement(o,{...r}):null};var ct=t=>{let{outputType:e}=s();return!y||e==="standard"?F.default.createElement(Z,{...t}):e==="edge"?F.default.createElement(K,{...t}):null};var E=T(require("react")),$=require("@uniformdev/context");var tt=T(require("cookie")),dt=({context:t,children:e,outputType:o="standard",trackRouteOnRender:n=!0})=>((0,E.useEffect)(()=>{y||!n||t.update({url:new URL(window.location.href),cookies:tt.default.parse(document.cookie)})}),E.default.createElement(v.Provider,{value:{context:t,outputType:o}},e,y?E.default.createElement(lt,null):null));function lt(){let{context:t}=s(),e={quirks:t.storage.data.quirks,tests:t.storage.data.tests,ssv:t.scores};return E.default.createElement("script",{id:$.SERVER_STATE_ID,type:"application/json",dangerouslySetInnerHTML:{__html:JSON.stringify(e)}})}var f=require("react");var et=require("react");var I=t=>{let{personalized:e}=(0,et.useContext)(L);return typeof e!="undefined"?e:typeof(t==null?void 0:t.personalized)!="undefined"?t.personalized:!1};var xt=({behavior:t,children:e,tagName:o="div",threshold:n=.5,disableVisibilityTrigger:r=typeof window=="undefined"||!("IntersectionObserver"in window),...a})=>{let i=typeof document=="undefined"?"__uniform_ssr_url":document.location.href,{context:u}=s(),C=I(),[P,S]=(0,f.useState)(),[x,h]=(0,f.useState)(!1),N=(0,f.useRef)(null),c=(0,f.useRef)();return(0,f.useEffect)(()=>{P!==i&&(h(!1),S(i))},[i,P]),(0,f.useEffect)(()=>{var J;let D=!t||Array.isArray(t)&&!t.length;if(C||D||!N.current)return;let ot=Array.isArray(t)?t:[t],q=()=>{var d;x||(u.update({enrichments:ot}),h(!0),(d=c.current)==null||d.call(c))};if(r)q();else{(J=c.current)==null||J.call(c);let d=new IntersectionObserver(([k])=>{k.isIntersecting&&q()},{threshold:n});d.observe(N.current),c.current=()=>{var k;return(k=d.disconnect)==null?void 0:k.call(d)}}return()=>{var d;(d=c.current)==null||d.call(c)}},[u,t,r,n,C,P,i,x]),(0,f.createElement)(o,{...a,ref:N},e)};var R=T(require("react")),V=require("react");var Tt=({behavior:t,children:e})=>{let o=typeof document=="undefined"?"__uniform_ssr_url":document.location.href,{context:n}=s(),r=I(),[a,i]=(0,V.useState)(),[u,C]=(0,V.useState)(!1);return(0,V.useEffect)(()=>{a!==o&&(C(!1),i(o))},[o,a]),(0,V.useEffect)(()=>{let P=!t||Array.isArray(t)&&!t.length;if(r||P)return;(()=>{if(u)return;let h=Array.isArray(t)?t:[t];n.update({enrichments:h}),C(!0)})()},[n,t,r,u]),R.default.createElement(R.default.Fragment,null,e)};0&&(module.exports={Personalize,Test,Track,TrackFragment,UniformContext,useQuirks,useScores,useUniformContext});
{
"name": "@uniformdev/context-react",
"version": "16.1.0",
"version": "16.1.1-alpha.139+190bc76f4",
"description": "Uniform Context React integration package",

@@ -27,3 +27,3 @@ "license": "SEE LICENSE IN LICENSE.txt",

"@types/cookie": "0.5.1",
"@types/react": "18.0.9",
"@types/react": "18.0.12",
"react": "18.1.0",

@@ -33,3 +33,3 @@ "react-dom": "18.1.0"

"dependencies": {
"@uniformdev/context": "^16.1.0",
"@uniformdev/context": "^16.1.1-alpha.139+190bc76f4",
"cookie": "0.5.0",

@@ -48,3 +48,3 @@ "dequal": "2.0.2"

},
"gitHead": "18a24d68a80d079bfdf74b52ccf352fc2f8a2821"
"gitHead": "190bc76f4f0d6e3c1a61fbbd8e9abe8a0571f85a"
}

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc