@uniformdev/context-react
Advanced tools
Comparing version 17.0.0 to 17.1.0
@@ -1,1 +0,1 @@ | ||
import{useContext as j}from"react";import{createContext as w}from"react";var E=w(void 0),z=w({});function s(t={}){let{throwOnMissingProvider:e=!0}=t,o=j(E);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 Vt(){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 h}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":h.TestStart,dangerouslySetInnerHTML:{__html:JSON.stringify(n)}}),o.map((i,m)=>T.createElement(rt,{key:i.id},T.createElement(u,{"data-type":h.ListItemSettings,dangerouslySetInnerHTML:{__html:JSON.stringify({id:i.id})}}),T.createElement(u,{"data-type":h.ListItem},T.createElement(a,{key:m,...i})))),T.createElement(u,{"data-type":h.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(E.Provider,{value:{context:t,outputType:o}},e,C?O.createElement(mt,null):null));function mt(){let{context:t}=s(),e=t.getServerToClientTransitionState();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 S=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=S(),[l,g]=J(),[c,y]=J(!1),k=q(null),p=q();return D(()=>{l!==i&&(y(!1),g(i))},[i,l]),D(()=>{var v;let L=!t||Array.isArray(t)&&!t.length;if(d||L||!k.current)return;let W=Array.isArray(t)?t:[t],_=()=>{var f;c||(m.update({enrichments:W}),y(!0),(f=p.current)==null||f.call(p))};if(n)_();else{(v=p.current)==null||v.call(p);let f=new IntersectionObserver(([V])=>{V.isIntersecting&&_()},{threshold:r});f.observe(k.current),p.current=()=>{var V;return(V=f.disconnect)==null?void 0:V.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=S(),[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,Vt as useQuirks,I as useScores,s as useUniformContext}; | ||
import{useContext as j}from"react";import{createContext as _}from"react";var V=_(void 0),U=_({});function s(e={}){let{throwOnMissingProvider:o=!0}=e,t=j(V);if(o){if(t===void 0)throw new Error("useUniformContext must be used within a <UniformContext> provider");return t}return t}import{useEffect as X,useState as G}from"react";function Ee(){let{context:e}=s(),[o,t]=G(e.quirks),r=n=>{t(n)};return X(()=>(e.events.on("quirksUpdated",r),()=>{e.events.off("quirksUpdated",r)}),[e]),o}import{useEffect as K,useState as Y}from"react";import{dequal as Z}from"dequal/lite";function I(){let{context:e}=s(),[o,t]=Y(e.scores);return K(()=>{let r=a=>{t(a)},n=e.scores;return Z(o,n)||t(n),e.events.on("scoresUpdated",r),()=>{e.events.off("scoresUpdated",r)}},[e]),o}import H from"react";import P,{useMemo as $}from"react";function M({variations:e,component:o,wrapperComponent:t,name:r,count:n=1}){let{context:a}=s(),i=I(),{variations:m,personalized:d}=$(()=>a.personalize({name:r,variations:e,take:n}),[i,a,n,r,e]),l=t!=null?t:({children:c})=>P.createElement(P.Fragment,null,c),g=o;return P.createElement(U.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 z}from"@uniformdev/context";import x,{Fragment as oe}from"react";import{EdgeNodeTagName as ee}from"@uniformdev/context";import{createElement as te}from"react";var u=e=>te(ee,e);function N(e){let{variations:o,count:t,component:r}=e,n={count:t!=null?t:1},a=r;return x.createElement(x.Fragment,null,x.createElement(u,{"data-type":z.ListStart,dangerouslySetInnerHTML:{__html:JSON.stringify(n)}}),o.map(i=>x.createElement(oe,{key:i.id},x.createElement(u,{"data-type":z.ListItemSettings,dangerouslySetInnerHTML:{__html:JSON.stringify({id:i.id,pz:i.pz||null})}}),x.createElement(u,{"data-type":z.ListItem},x.createElement(a,{key:i.id,personalizationResult:{variation:i,personalizationOccurred:!1},...i})))),x.createElement(u,{"data-type":z.ListEnd}))}var C=typeof window=="undefined";function Ke(e){var t;let{outputType:o}=(t=s({throwOnMissingProvider:!1}))!=null?t:{};if(!o)throw new Error("Using the <Personalize /> component requires the <UniformContext> provider to be present.");return!C||o==="standard"?H.createElement(M,{...e}):o==="edge"?H.createElement(N,{...e}):null}import R from"react";import{ScriptType as h}from"@uniformdev/context";import T,{Fragment as re}from"react";function A(e){let{name:o,variations:t,component:r}=e,n={name:o},a=r;return T.createElement(T.Fragment,null,T.createElement(u,{"data-type":h.TestStart,dangerouslySetInnerHTML:{__html:JSON.stringify(n)}}),t.map((i,m)=>T.createElement(re,{key:i.id},T.createElement(u,{"data-type":h.ListItemSettings,dangerouslySetInnerHTML:{__html:JSON.stringify({id:i.id})}}),T.createElement(u,{"data-type":h.ListItem},T.createElement(a,{key:m,...i})))),T.createElement(u,{"data-type":h.TestEnd}))}import ne from"react";var F=({name:e,variations:o,component:t})=>{let{context:r}=s(),{result:n}=r.test({name:e,variations:o});return n?ne.createElement(t,{...n}):null};var xt=e=>{var t;let{outputType:o}=(t=s({throwOnMissingProvider:!1}))!=null?t:{};if(!o)throw new Error("Using the <Test /> component requires the <UniformContext> provider to be present.");return!C||o==="standard"?R.createElement(F,{...e}):o==="edge"?R.createElement(A,{...e}):null};import k,{useEffect as ie}from"react";import{SERVER_STATE_ID as se}from"@uniformdev/context";import ae from"cookie";var zt=({context:e,children:o,outputType:t="standard",trackRouteOnRender:r=!0})=>(ie(()=>{C||!r||e.update({url:new URL(window.location.href),cookies:ae.parse(document.cookie)})}),k.createElement(V.Provider,{value:{context:e,outputType:t}},o,C?k.createElement(me,null):null));function me(){let{context:e}=s(),o=e.getServerToClientTransitionState();return k.createElement("script",{id:se,type:"application/json",dangerouslySetInnerHTML:{__html:JSON.stringify(o)}})}import{createElement as fe,useEffect as D,useRef as q,useState as b}from"react";import{useContext as pe}from"react";var S=e=>{let{personalized:o}=pe(U);return typeof o!="undefined"?o:typeof(e==null?void 0:e.personalized)!="undefined"?e.personalized:!1};var It=({behavior:e,children:o,tagName:t="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=S(),[l,g]=b(),[c,y]=b(!1),O=q(null),p=q();return D(()=>{l!==i&&(y(!1),g(i))},[i,l]),D(()=>{var L;let w=!e||Array.isArray(e)&&!e.length;if(d||w||!O.current)return;let W=Array.isArray(e)?e:[e],v=()=>{var f;c||(m.update({enrichments:W}),y(!0),(f=p.current)==null||f.call(p))};if(n)v();else{(L=p.current)==null||L.call(p);let f=new IntersectionObserver(([E])=>{E.isIntersecting&&v()},{threshold:r});f.observe(O.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,e,n,r,d,l,i,c]),fe(t,{...a,ref:O},o)};import J from"react";import{useEffect as B,useState as Q}from"react";var Dt=({behavior:e,children:o})=>{let t=typeof document=="undefined"?"__uniform_ssr_url":document.location.href,{context:r}=s(),n=S(),[a,i]=Q(),[m,d]=Q(!1);return B(()=>{a!==t&&(d(!1),i(t))},[t,a]),B(()=>{let l=!e||Array.isArray(e)&&!e.length;if(n||l)return;(()=>{if(m)return;let y=Array.isArray(e)?e:[e];r.update({enrichments:y}),d(!0)})()},[r,e,n,m]),J.createElement(J.Fragment,null,o)};export{Ke as Personalize,xt as Test,It as Track,Dt as TrackFragment,zt as UniformContext,Ee as useQuirks,I as useScores,s as useUniformContext}; |
@@ -1,1 +0,1 @@ | ||
"use strict";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"),L=(0,H.createContext)(void 0),_=(0,H.createContext)({});function s(t={}){let{throwOnMissingProvider:e=!0}=t,o=(0,B.useContext)(L);if(e){if(o===void 0)throw new Error("useUniformContext must be used within a <UniformContext> provider");return o}return o}var v=require("react");function ft(){let{context:t}=s(),[e,o]=(0,v.useState)(t.quirks),n=r=>{o(r)};return(0,v.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),h=e;return g.default.createElement(_.Provider,{value:{personalized:!0}},u.length?g.default.createElement(P,{personalizationOccurred:C},u.map(x=>g.default.createElement(h,{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 V=T(require("react")),$=require("@uniformdev/context");var tt=T(require("cookie")),dt=({context:t,children:e,outputType:o="standard",trackRouteOnRender:n=!0})=>((0,V.useEffect)(()=>{y||!n||t.update({url:new URL(window.location.href),cookies:tt.default.parse(document.cookie)})}),V.default.createElement(L.Provider,{value:{context:t,outputType:o}},e,y?V.default.createElement(lt,null):null));function lt(){let{context:t}=s(),e=t.getServerToClientTransitionState();return V.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)(_);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,h]=(0,f.useState)(),[x,S]=(0,f.useState)(!1),N=(0,f.useRef)(null),c=(0,f.useRef)();return(0,f.useEffect)(()=>{P!==i&&(S(!1),h(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}),S(!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")),E=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,E.useState)(),[u,C]=(0,E.useState)(!1);return(0,E.useEffect)(()=>{a!==o&&(C(!1),i(o))},[o,a]),(0,E.useEffect)(()=>{let P=!t||Array.isArray(t)&&!t.length;if(r||P)return;(()=>{if(u)return;let S=Array.isArray(t)?t:[t];n.update({enrichments:S}),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}); | ||
"use strict";var re=Object.create;var k=Object.defineProperty;var ne=Object.getOwnPropertyDescriptor;var ie=Object.getOwnPropertyNames;var se=Object.getPrototypeOf,ae=Object.prototype.hasOwnProperty;var me=(e,t)=>{for(var o in t)k(e,o,{get:t[o],enumerable:!0})},J=(e,t,o,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let r of ie(t))!ae.call(e,r)&&r!==o&&k(e,r,{get:()=>t[r],enumerable:!(n=ne(t,r))||n.enumerable});return e};var T=(e,t,o)=>(o=e!=null?re(se(e)):{},J(t||!e||!e.__esModule?k(o,"default",{value:e,enumerable:!0}):o,e)),pe=e=>J(k({},"__esModule",{value:!0}),e);var Ce={};me(Ce,{Personalize:()=>ue,Test:()=>ce,Track:()=>xe,TrackFragment:()=>Te,UniformContext:()=>de,useQuirks:()=>fe,useScores:()=>H,useUniformContext:()=>s});module.exports=pe(Ce);var B=require("react");var N=require("react"),w=(0,N.createContext)(void 0),v=(0,N.createContext)({});function s(e={}){let{throwOnMissingProvider:t=!0}=e,o=(0,B.useContext)(w);if(t){if(o===void 0)throw new Error("useUniformContext must be used within a <UniformContext> provider");return o}return o}var L=require("react");function fe(){let{context:e}=s(),[t,o]=(0,L.useState)(e.quirks),n=r=>{o(r)};return(0,L.useEffect)(()=>(e.events.on("quirksUpdated",n),()=>{e.events.off("quirksUpdated",n)}),[e]),t}var _=require("react");var Q=require("dequal/lite");function H(){let{context:e}=s(),[t,o]=(0,_.useState)(e.scores);return(0,_.useEffect)(()=>{let n=a=>{o(a)},r=e.scores;return(0,Q.dequal)(t,r)||o(r),e.events.on("scoresUpdated",n),()=>{e.events.off("scoresUpdated",n)}},[e]),t}var A=T(require("react"));var g=T(require("react"));function W({variations:e,component:t,wrapperComponent:o,name:n,count:r=1}){let{context:a}=s(),i=H(),{variations:u,personalized:C}=(0,g.useMemo)(()=>a.personalize({name:n,variations:e,take:r}),[i,a,r,n,e]),P=o!=null?o:({children:x})=>g.default.createElement(g.default.Fragment,null,x),h=t;return g.default.createElement(v.Provider,{value:{personalized:!0}},u.length?g.default.createElement(P,{personalizationOccurred:C},u.map(x=>g.default.createElement(h,{key:x.id,personalizationResult:{variation:x,personalizationOccurred:C},...x}))):null)}var U=require("@uniformdev/context"),m=T(require("react"));var j=require("@uniformdev/context"),X=require("react"),l=e=>(0,X.createElement)(j.EdgeNodeTagName,e);function G(e){let{variations:t,count:o,component:n}=e,r={count:o!=null?o:1},a=n;return m.default.createElement(m.default.Fragment,null,m.default.createElement(l,{"data-type":U.ScriptType.ListStart,dangerouslySetInnerHTML:{__html:JSON.stringify(r)}}),t.map(i=>m.default.createElement(m.Fragment,{key:i.id},m.default.createElement(l,{"data-type":U.ScriptType.ListItemSettings,dangerouslySetInnerHTML:{__html:JSON.stringify({id:i.id,pz:i.pz||null})}}),m.default.createElement(l,{"data-type":U.ScriptType.ListItem},m.default.createElement(a,{key:i.id,personalizationResult:{variation:i,personalizationOccurred:!1},...i})))),m.default.createElement(l,{"data-type":U.ScriptType.ListEnd}))}var y=typeof window=="undefined";function ue(e){var o;let{outputType:t}=(o=s({throwOnMissingProvider:!1}))!=null?o:{};if(!t)throw new Error("Using the <Personalize /> component requires the <UniformContext> provider to be present.");return!y||t==="standard"?A.default.createElement(W,{...e}):t==="edge"?A.default.createElement(G,{...e}):null}var F=T(require("react"));var z=require("@uniformdev/context"),p=T(require("react"));function K(e){let{name:t,variations:o,component:n}=e,r={name:t},a=n;return p.default.createElement(p.default.Fragment,null,p.default.createElement(l,{"data-type":z.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":z.ScriptType.ListItemSettings,dangerouslySetInnerHTML:{__html:JSON.stringify({id:i.id})}}),p.default.createElement(l,{"data-type":z.ScriptType.ListItem},p.default.createElement(a,{key:u,...i})))),p.default.createElement(l,{"data-type":z.ScriptType.TestEnd}))}var Y=T(require("react"));var Z=({name:e,variations:t,component:o})=>{let{context:n}=s(),{result:r}=n.test({name:e,variations:t});return r?Y.default.createElement(o,{...r}):null};var ce=e=>{var o;let{outputType:t}=(o=s({throwOnMissingProvider:!1}))!=null?o:{};if(!t)throw new Error("Using the <Test /> component requires the <UniformContext> provider to be present.");return!y||t==="standard"?F.default.createElement(Z,{...e}):t==="edge"?F.default.createElement(K,{...e}):null};var E=T(require("react")),$=require("@uniformdev/context");var ee=T(require("cookie")),de=({context:e,children:t,outputType:o="standard",trackRouteOnRender:n=!0})=>((0,E.useEffect)(()=>{y||!n||e.update({url:new URL(window.location.href),cookies:ee.default.parse(document.cookie)})}),E.default.createElement(w.Provider,{value:{context:e,outputType:o}},t,y?E.default.createElement(le,null):null));function le(){let{context:e}=s(),t=e.getServerToClientTransitionState();return E.default.createElement("script",{id:$.SERVER_STATE_ID,type:"application/json",dangerouslySetInnerHTML:{__html:JSON.stringify(t)}})}var f=require("react");var te=require("react");var I=e=>{let{personalized:t}=(0,te.useContext)(v);return typeof t!="undefined"?t:typeof(e==null?void 0:e.personalized)!="undefined"?e.personalized:!1};var xe=({behavior:e,children:t,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,h]=(0,f.useState)(),[x,S]=(0,f.useState)(!1),M=(0,f.useRef)(null),c=(0,f.useRef)();return(0,f.useEffect)(()=>{P!==i&&(S(!1),h(i))},[i,P]),(0,f.useEffect)(()=>{var b;let D=!e||Array.isArray(e)&&!e.length;if(C||D||!M.current)return;let oe=Array.isArray(e)?e:[e],q=()=>{var d;x||(u.update({enrichments:oe}),S(!0),(d=c.current)==null||d.call(c))};if(r)q();else{(b=c.current)==null||b.call(c);let d=new IntersectionObserver(([O])=>{O.isIntersecting&&q()},{threshold:n});d.observe(M.current),c.current=()=>{var O;return(O=d.disconnect)==null?void 0:O.call(d)}}return()=>{var d;(d=c.current)==null||d.call(c)}},[u,e,r,n,C,P,i,x]),(0,f.createElement)(o,{...a,ref:M},t)};var R=T(require("react")),V=require("react");var Te=({behavior:e,children:t})=>{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=!e||Array.isArray(e)&&!e.length;if(r||P)return;(()=>{if(u)return;let S=Array.isArray(e)?e:[e];n.update({enrichments:S}),C(!0)})()},[n,e,r,u]),R.default.createElement(R.default.Fragment,null,t)};0&&(module.exports={Personalize,Test,Track,TrackFragment,UniformContext,useQuirks,useScores,useUniformContext}); |
{ | ||
"name": "@uniformdev/context-react", | ||
"version": "17.0.0", | ||
"version": "17.1.0", | ||
"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.15", | ||
"@types/react": "18.0.17", | ||
"react": "18.2.0", | ||
@@ -33,3 +33,3 @@ "react-dom": "18.2.0" | ||
"dependencies": { | ||
"@uniformdev/context": "^17.0.0", | ||
"@uniformdev/context": "^17.1.0", | ||
"cookie": "0.5.0", | ||
@@ -48,3 +48,3 @@ "dequal": "2.0.3" | ||
}, | ||
"gitHead": "d15f59e5cc80184d983b8c1ca67b1ee390158672" | ||
"gitHead": "47c6abcea06f19dcd2e723bbee79da32e7c395e5" | ||
} |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
43093
474
Updated@uniformdev/context@^17.1.0