@uniformdev/context-react
Advanced tools
Comparing version 14.2.1-alpha.145 to 14.2.1-alpha.177
@@ -1,2 +0,2 @@ | ||
import { Context, Quirks, ScoreVector, PersonalizedVariant, TestVariant, EnrichmentData, TaggedContent } from '@uniformdev/context'; | ||
import { Context, Quirks, ScoreVector, PersonalizedVariant, TestVariant, EnrichmentData } from '@uniformdev/context'; | ||
import * as react from 'react'; | ||
@@ -98,7 +98,17 @@ import react__default, { ReactNode, ReactElement, HTMLAttributes } from 'react'; | ||
declare type TrackProps = HTMLAttributes<HTMLElement> & { | ||
declare type TrackFragmentProps = { | ||
/** Behavior that will be pushed when tracking occurs. */ | ||
behavior: EnrichmentData | EnrichmentData[] | TaggedContent | undefined; | ||
behavior: EnrichmentData | EnrichmentData[] | undefined; | ||
/** Nested elements that are related to the behavior specified. */ | ||
children: ReactNode; | ||
}; | ||
/** | ||
* Tracks visitor behavior by adding enrichment score when they are shown a route with this component on it. | ||
* | ||
* NOTE: if you wish to track on the visitor seeing the content in the browser viewport instead, | ||
* use Track instead of TrackFragment. | ||
*/ | ||
declare const TrackFragment: ({ behavior, children }: TrackFragmentProps) => JSX.Element; | ||
declare type TrackProps = TrackFragmentProps & HTMLAttributes<HTMLElement> & { | ||
/** | ||
@@ -123,2 +133,12 @@ * Element tag that will be used for tracking. | ||
}; | ||
/** | ||
* Tracks visitor behavior by adding enrichment score when they view content wrapped in this component. | ||
* When the Track component is sufficiently in the viewport, it will trigger the enrichment values specified | ||
* in `behavior` to the current visitor. If the browser does not support IntersectionObserver, the behavior will | ||
* be triggered immediately on page load instead. | ||
* | ||
* NOTE: this component necessarily renders a wrapping tag to attach the IntersectionObserver to; this can result | ||
* in DOM changes when personalization is added. If that's undesirable use TrackFragment instead which tracks | ||
* only on page load, but does not render a wrapping tag. | ||
*/ | ||
declare const Track: ({ behavior, children, tagName, threshold, disableVisibilityTrigger, ...rest }: TrackProps) => react.DOMElement<{ | ||
@@ -383,2 +403,2 @@ ref: react.RefObject<HTMLElement>; | ||
export { Personalize, PersonalizeComponentProps, PersonalizeWrapperComponent, PersonalizedVariationComponent, Test, TestComponentProps, Track, TrackProps, UniformContext, UniformContextProps$1 as UniformContextProps, VariantOutputType, useQuirks, useScores, useUniformContext }; | ||
export { Personalize, PersonalizeComponentProps, PersonalizeWrapperComponent, PersonalizedVariationComponent, Test, TestComponentProps, Track, TrackFragment, TrackFragmentProps, TrackProps, UniformContext, UniformContextProps$1 as UniformContextProps, VariantOutputType, useQuirks, useScores, useUniformContext }; |
@@ -1,1 +0,1 @@ | ||
import{useContext as R}from"react";import{createContext as h}from"react";var V=h(void 0),z=h({});var s=()=>{let e=R(V);if(!e)throw new Error("useUniformContext must be used within a <UniformContext> provider");return e};import{useEffect as J,useState as A}from"react";function fe(){let{context:e}=s(),[t,o]=A(e.storage.data.quirks),r=n=>{o(n)};return J(()=>(e.events.on("quirksUpdated",r),()=>{e.events.off("quirksUpdated",r)}),[e]),t}import{useEffect as D,useState as Q}from"react";import{dequal as W}from"dequal/lite";function L(){let{context:e}=s(),[t,o]=Q(e.scores),r=n=>{o(n)};return D(()=>{let n=e.scores;return W(t,n)||o(n),e.events.on("scoresUpdated",r),()=>{e.events.off("scoresUpdated",r)}},[e]),t}import N from"react";import y,{useEffect as j,useState as B}from"react";function I({variations:e,component:t,wrapperComponent:o,name:r,count:n=1}){let{context:c}=s(),[,m]=B(-1);j(()=>{m(1)},[]),L();let{variations:T,personalized:P}=c.personalize({name:r,variations:e,take:n}),k=o!=null?o:({children:i})=>y.createElement(y.Fragment,null,i),g=t;return y.createElement(z.Provider,{value:{personalized:!0}},T.length?y.createElement(k,{personalizationOccurred:P},T.map(i=>y.createElement(g,{key:i.id,personalizationResult:{variation:i,personalizationOccurred:P},...i}))):null)}import{ScriptType as E}from"@uniformdev/context";import f from"react";import{EdgeNodeTagName as F}from"@uniformdev/context";import{createElement as X}from"react";var u=e=>X(F,e);function b(e){let{variations:t,count:o,component:r}=e,n={count:o!=null?o:1},c=r;return f.createElement(f.Fragment,null,f.createElement(u,{"data-type":E.ListStart,dangerouslySetInnerHTML:{__html:JSON.stringify(n)}}),t.map(m=>f.createElement(f.Fragment,null,f.createElement(u,{"data-type":E.ListItemSettings,dangerouslySetInnerHTML:{__html:JSON.stringify({id:m.id,pz:m.pz||null})}}),f.createElement(u,{"data-type":E.ListItem},f.createElement(c,{key:m.id,personalizationResult:{variation:m,personalizationOccurred:!1},...m})))),f.createElement(u,{"data-type":E.ListEnd}))}var C=typeof window=="undefined";function Ae(e){let{outputType:t}=s();return!C||t==="standard"?N.createElement(I,{...e}):t==="edge"?N.createElement(b,{...e}):null}import H from"react";import{ScriptType as S}from"@uniformdev/context";import l from"react";function _(e){let{name:t,variations:o,component:r}=e,n={name:t},c=r;return l.createElement(l.Fragment,null,l.createElement(u,{"data-type":S.TestStart,dangerouslySetInnerHTML:{__html:JSON.stringify(n)}}),o.map((m,T)=>l.createElement(l.Fragment,null,l.createElement(u,{"data-type":S.ListItemSettings,dangerouslySetInnerHTML:{__html:JSON.stringify({id:m.id})}}),l.createElement(u,{"data-type":S.ListItem},l.createElement(c,{key:T,...m})))),l.createElement(u,{"data-type":S.TestEnd}))}import G from"react";var w=({name:e,variations:t,component:o})=>{let{context:r}=s(),{result:n}=r.test({name:e,variations:t});return n?G.createElement(o,{...n}):null};var st=e=>{let{outputType:t}=s();return!C||t==="standard"?H.createElement(w,{...e}):t==="edge"?H.createElement(_,{...e}):null};import U,{useEffect as K}from"react";import{SERVER_STATE_ID as Y}from"@uniformdev/context";import Z from"cookie";var Tt=({context:e,children:t,outputType:o="standard",trackRouteOnRender:r=!0})=>(K(()=>{C||!r||e.update({url:new URL(window.location.href),cookies:Z.parse(document.cookie)})}),U.createElement(V.Provider,{value:{context:e,outputType:o}},t,C?U.createElement($,null):null));function $(){let{context:e}=s(),t={quirks:e.storage.data.quirks,tests:e.storage.data.tests,ssv:e.scores};return U.createElement("script",{id:Y,type:"application/json",dangerouslySetInnerHTML:{__html:JSON.stringify(t)}})}import{createElement as te,useEffect as oe,useRef as q,useState as re}from"react";import{useContext as ee}from"react";var M=e=>{let{personalized:t}=ee(z);return typeof t!="undefined"?t:typeof(e==null?void 0:e.personalized)!="undefined"?e.personalized:!1};var kt=({behavior:e,children:t,tagName:o="div",threshold:r=.5,disableVisibilityTrigger:n=typeof window=="undefined"||!("IntersectionObserver"in window),...c})=>{let{context:m}=s(),T=M(),[P,k]=re(!1),g=q(null),i=q();return oe(()=>{var v;if(!g.current||T)return;let O=()=>{var x;if(P||!e)return;let d="beh"in e?e.beh:Array.isArray(e)?e:[e];m.update({enrichments:d}),k(!0),(x=i.current)==null||x.call(i)};if(n)O();else{(v=i.current)==null||v.call(i);let d=new IntersectionObserver(([x])=>{x.isIntersecting&&O()},{threshold:r});d.observe(g.current),i.current=()=>{var x;return(x=d.disconnect)==null?void 0:x.call(d)}}return()=>{var d;(d=i.current)==null||d.call(i)}},[m,e,n,r,T,P]),te(o,{...c,ref:g},t)};export{Ae as Personalize,st as Test,kt as Track,Tt as UniformContext,fe as useQuirks,L as useScores,s as useUniformContext}; | ||
import{useContext as F}from"react";import{createContext as I}from"react";var z=I(void 0),V=I({});var i=()=>{let t=F(z);if(!t)throw new Error("useUniformContext must be used within a <UniformContext> provider");return t};import{useEffect as J,useState as K}from"react";function xt(){let{context:t}=i(),[e,o]=K(t.storage.data.quirks),r=n=>{o(n)};return J(()=>(t.events.on("quirksUpdated",r),()=>{t.events.off("quirksUpdated",r)}),[t]),e}import{useEffect as Q,useState as W}from"react";import{dequal as B}from"dequal/lite";function N(){let{context:t}=i(),[e,o]=W(t.scores);return Q(()=>{let r=m=>{o(m)},n=t.scores;return B(e,n)||o(n),t.events.on("scoresUpdated",r),()=>{t.events.off("scoresUpdated",r)}},[t]),e}import H from"react";import E,{useMemo as j}from"react";function w({variations:t,component:e,wrapperComponent:o,name:r,count:n=1}){let{context:m}=i(),s=N(),{variations:T,personalized:y}=j(()=>m.personalize({name:r,variations:t,take:n}),[s,m,n,r,t]),P=o!=null?o:({children:d})=>E.createElement(E.Fragment,null,d),U=e;return E.createElement(V.Provider,{value:{personalized:!0}},T.length?E.createElement(P,{personalizationOccurred:y},T.map(d=>E.createElement(U,{key:d.id,personalizationResult:{variation:d,personalizationOccurred:y},...d}))):null)}import{ScriptType as S}from"@uniformdev/context";import f from"react";import{EdgeNodeTagName as X}from"@uniformdev/context";import{createElement as G}from"react";var c=t=>G(X,t);function M(t){let{variations:e,count:o,component:r}=t,n={count:o!=null?o:1},m=r;return f.createElement(f.Fragment,null,f.createElement(c,{"data-type":S.ListStart,dangerouslySetInnerHTML:{__html:JSON.stringify(n)}}),e.map(s=>f.createElement(f.Fragment,null,f.createElement(c,{"data-type":S.ListItemSettings,dangerouslySetInnerHTML:{__html:JSON.stringify({id:s.id,pz:s.pz||null})}}),f.createElement(c,{"data-type":S.ListItem},f.createElement(m,{key:s.id,personalizationResult:{variation:s,personalizationOccurred:!1},...s})))),f.createElement(c,{"data-type":S.ListEnd}))}var C=typeof window=="undefined";function Qt(t){let{outputType:e}=i();return!C||e==="standard"?H.createElement(w,{...t}):e==="edge"?H.createElement(M,{...t}):null}import A from"react";import{ScriptType as k}from"@uniformdev/context";import l from"react";function b(t){let{name:e,variations:o,component:r}=t,n={name:e},m=r;return l.createElement(l.Fragment,null,l.createElement(c,{"data-type":k.TestStart,dangerouslySetInnerHTML:{__html:JSON.stringify(n)}}),o.map((s,T)=>l.createElement(l.Fragment,null,l.createElement(c,{"data-type":k.ListItemSettings,dangerouslySetInnerHTML:{__html:JSON.stringify({id:s.id})}}),l.createElement(c,{"data-type":k.ListItem},l.createElement(m,{key:T,...s})))),l.createElement(c,{"data-type":k.TestEnd}))}import Y from"react";var q=({name:t,variations:e,component:o})=>{let{context:r}=i(),{result:n}=r.test({name:t,variations:e});return n?Y.createElement(o,{...n}):null};var ue=t=>{let{outputType:e}=i();return!C||e==="standard"?A.createElement(q,{...t}):e==="edge"?A.createElement(b,{...t}):null};import O,{useEffect as Z}from"react";import{SERVER_STATE_ID as $}from"@uniformdev/context";import tt from"cookie";var Pe=({context:t,children:e,outputType:o="standard",trackRouteOnRender:r=!0})=>(Z(()=>{C||!r||t.update({url:new URL(window.location.href),cookies:tt.parse(document.cookie)})}),O.createElement(z.Provider,{value:{context:t,outputType:o}},e,C?O.createElement(et,null):null));function et(){let{context:t}=i(),e={quirks:t.storage.data.quirks,tests:t.storage.data.tests,ssv:t.scores};return O.createElement("script",{id:$,type:"application/json",dangerouslySetInnerHTML:{__html:JSON.stringify(e)}})}import{createElement as rt,useEffect as nt,useRef as D,useState as it}from"react";import{useContext as ot}from"react";var h=t=>{let{personalized:e}=ot(V);return typeof e!="undefined"?e:typeof(t==null?void 0:t.personalized)!="undefined"?t.personalized:!1};var Oe=({behavior:t,children:e,tagName:o="div",threshold:r=.5,disableVisibilityTrigger:n=typeof window=="undefined"||!("IntersectionObserver"in window),...m})=>{let s=typeof document=="undefined"?"__uniform_track_key_ssr":document.location.href,{context:T}=i(),y=h(),[P,U]=it(),d=D(null),u=D();return nt(()=>{var v;if(!d.current||y)return;let _=()=>{var L;if(!(P!==s)||!t)return;let g=Array.isArray(t)?t:[t];T.update({enrichments:g}),U(s),(L=u.current)==null||L.call(u)};if(n)_();else{(v=u.current)==null||v.call(u);let x=new IntersectionObserver(([g])=>{g.isIntersecting&&_()},{threshold:r});x.observe(d.current),u.current=()=>{var g;return(g=x.disconnect)==null?void 0:g.call(x)}}return()=>{var x;(x=u.current)==null||x.call(u)}},[T,t,n,r,y,P,s]),rt(o,{...m,ref:d},e)};import R from"react";import{useEffect as st,useState as at}from"react";var Me=({behavior:t,children:e})=>{let o=typeof document=="undefined"?"__uniform_track_key_ssr":document.location.href,{context:r}=i(),n=h(),[m,s]=at();return st(()=>{if(n)return;(()=>{if(!(m!==o)||!t)return;let P=Array.isArray(t)?t:[t];r.update({enrichments:P}),s(o)})()},[r,t,n,m,o]),R.createElement(R.Fragment,null,e)};export{Qt as Personalize,ue as Test,Oe as Track,Me as TrackFragment,Pe as UniformContext,xt as useQuirks,N as useScores,i as useUniformContext}; |
@@ -1,1 +0,1 @@ | ||
var Z=Object.create;var k=Object.defineProperty;var $=Object.getOwnPropertyDescriptor;var ee=Object.getOwnPropertyNames;var te=Object.getPrototypeOf,oe=Object.prototype.hasOwnProperty;var M=e=>k(e,"__esModule",{value:!0});var re=(e,t)=>{for(var o in t)k(e,o,{get:t[o],enumerable:!0})},q=(e,t,o,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let r of ee(t))!oe.call(e,r)&&(o||r!=="default")&&k(e,r,{get:()=>t[r],enumerable:!(n=$(t,r))||n.enumerable});return e},x=(e,t)=>q(M(k(e!=null?Z(te(e)):{},"default",!t&&e&&e.__esModule?{get:()=>e.default,enumerable:!0}:{value:e,enumerable:!0})),e),ne=(e=>(t,o)=>e&&e.get(t)||(o=q(M({}),t,1),e&&e.set(t,o),o))(typeof WeakMap!="undefined"?new WeakMap:0);var de={};re(de,{Personalize:()=>se,Test:()=>ae,Track:()=>ue,UniformContext:()=>pe,useQuirks:()=>ie,useScores:()=>b,useUniformContext:()=>i});var R=require("react");var I=require("react"),U=(0,I.createContext)(void 0),O=(0,I.createContext)({});var i=()=>{let e=(0,R.useContext)(U);if(!e)throw new Error("useUniformContext must be used within a <UniformContext> provider");return e};var v=require("react");function ie(){let{context:e}=i(),[t,o]=(0,v.useState)(e.storage.data.quirks),n=r=>{o(r)};return(0,v.useEffect)(()=>(e.events.on("quirksUpdated",n),()=>{e.events.off("quirksUpdated",n)}),[e]),t}var h=require("react");var J=require("dequal/lite");function b(){let{context:e}=i(),[t,o]=(0,h.useState)(e.scores),n=r=>{o(r)};return(0,h.useEffect)(()=>{let r=e.scores;return(0,J.dequal)(t,r)||o(r),e.events.on("scoresUpdated",n),()=>{e.events.off("scoresUpdated",n)}},[e]),t}var N=x(require("react"));var m=x(require("react"));function A({variations:e,component:t,wrapperComponent:o,name:n,count:r=1}){let{context:T}=i(),[,p]=(0,m.useState)(-1);(0,m.useEffect)(()=>{p(1)},[]),b();let{variations:C,personalized:V}=T.personalize({name:n,variations:e,take:r}),L=o!=null?o:({children:s})=>m.default.createElement(m.default.Fragment,null,s),z=t;return m.default.createElement(O.Provider,{value:{personalized:!0}},C.length?m.default.createElement(L,{personalizationOccurred:V},C.map(s=>m.default.createElement(z,{key:s.id,personalizationResult:{variation:s,personalizationOccurred:V},...s}))):null)}var E=require("@uniformdev/context"),d=x(require("react"));var D=require("@uniformdev/context"),Q=require("react"),u=e=>(0,Q.createElement)(D.EdgeNodeTagName,e);function W(e){let{variations:t,count:o,component:n}=e,r={count:o!=null?o:1},T=n;return d.default.createElement(d.default.Fragment,null,d.default.createElement(u,{"data-type":E.ScriptType.ListStart,dangerouslySetInnerHTML:{__html:JSON.stringify(r)}}),t.map(p=>d.default.createElement(d.default.Fragment,null,d.default.createElement(u,{"data-type":E.ScriptType.ListItemSettings,dangerouslySetInnerHTML:{__html:JSON.stringify({id:p.id,pz:p.pz||null})}}),d.default.createElement(u,{"data-type":E.ScriptType.ListItem},d.default.createElement(T,{key:p.id,personalizationResult:{variation:p,personalizationOccurred:!1},...p})))),d.default.createElement(u,{"data-type":E.ScriptType.ListEnd}))}var g=typeof window=="undefined";function se(e){let{outputType:t}=i();return!g||t==="standard"?N.default.createElement(A,{...e}):t==="edge"?N.default.createElement(W,{...e}):null}var _=x(require("react"));var S=require("@uniformdev/context"),f=x(require("react"));function j(e){let{name:t,variations:o,component:n}=e,r={name:t},T=n;return f.default.createElement(f.default.Fragment,null,f.default.createElement(u,{"data-type":S.ScriptType.TestStart,dangerouslySetInnerHTML:{__html:JSON.stringify(r)}}),o.map((p,C)=>f.default.createElement(f.default.Fragment,null,f.default.createElement(u,{"data-type":S.ScriptType.ListItemSettings,dangerouslySetInnerHTML:{__html:JSON.stringify({id:p.id})}}),f.default.createElement(u,{"data-type":S.ScriptType.ListItem},f.default.createElement(T,{key:C,...p})))),f.default.createElement(u,{"data-type":S.ScriptType.TestEnd}))}var B=x(require("react"));var F=({name:e,variations:t,component:o})=>{let{context:n}=i(),{result:r}=n.test({name:e,variations:t});return r?B.default.createElement(o,{...r}):null};var ae=e=>{let{outputType:t}=i();return!g||t==="standard"?_.default.createElement(F,{...e}):t==="edge"?_.default.createElement(j,{...e}):null};var y=x(require("react")),X=require("@uniformdev/context");var G=x(require("cookie")),pe=({context:e,children:t,outputType:o="standard",trackRouteOnRender:n=!0})=>((0,y.useEffect)(()=>{g||!n||e.update({url:new URL(window.location.href),cookies:G.default.parse(document.cookie)})}),y.default.createElement(U.Provider,{value:{context:e,outputType:o}},t,g?y.default.createElement(me,null):null));function me(){let{context:e}=i(),t={quirks:e.storage.data.quirks,tests:e.storage.data.tests,ssv:e.scores};return y.default.createElement("script",{id:X.SERVER_STATE_ID,type:"application/json",dangerouslySetInnerHTML:{__html:JSON.stringify(t)}})}var c=require("react");var K=require("react");var Y=e=>{let{personalized:t}=(0,K.useContext)(O);return typeof t!="undefined"?t:typeof(e==null?void 0:e.personalized)!="undefined"?e.personalized:!1};var ue=({behavior:e,children:t,tagName:o="div",threshold:n=.5,disableVisibilityTrigger:r=typeof window=="undefined"||!("IntersectionObserver"in window),...T})=>{let{context:p}=i(),C=Y(),[V,L]=(0,c.useState)(!1),z=(0,c.useRef)(null),s=(0,c.useRef)();return(0,c.useEffect)(()=>{var H;if(!z.current||C)return;let w=()=>{var P;if(V||!e)return;let l="beh"in e?e.beh:Array.isArray(e)?e:[e];p.update({enrichments:l}),L(!0),(P=s.current)==null||P.call(s)};if(r)w();else{(H=s.current)==null||H.call(s);let l=new IntersectionObserver(([P])=>{P.isIntersecting&&w()},{threshold:n});l.observe(z.current),s.current=()=>{var P;return(P=l.disconnect)==null?void 0:P.call(l)}}return()=>{var l;(l=s.current)==null||l.call(s)}},[p,e,r,n,C,V]),(0,c.createElement)(o,{...T,ref:z},t)};module.exports=ne(de);0&&(module.exports={Personalize,Test,Track,UniformContext,useQuirks,useScores,useUniformContext}); | ||
var ot=Object.create;var h=Object.defineProperty;var rt=Object.getOwnPropertyDescriptor;var nt=Object.getOwnPropertyNames;var it=Object.getPrototypeOf,st=Object.prototype.hasOwnProperty;var F=t=>h(t,"__esModule",{value:!0});var at=(t,e)=>{for(var o in e)h(t,o,{get:e[o],enumerable:!0})},J=(t,e,o,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let r of nt(e))!st.call(t,r)&&(o||r!=="default")&&h(t,r,{get:()=>e[r],enumerable:!(n=rt(e,r))||n.enumerable});return t},l=(t,e)=>J(F(h(t!=null?ot(it(t)):{},"default",!e&&t&&t.__esModule?{get:()=>t.default,enumerable:!0}:{value:t,enumerable:!0})),t),pt=(t=>(e,o)=>t&&t.get(e)||(o=J(F({}),e,1),t&&t.set(e,o),o))(typeof WeakMap!="undefined"?new WeakMap:0);var xt={};at(xt,{Personalize:()=>ut,Test:()=>ct,Track:()=>lt,TrackFragment:()=>Tt,UniformContext:()=>dt,useQuirks:()=>mt,useScores:()=>M,useUniformContext:()=>i});var K=require("react");var w=require("react"),U=(0,w.createContext)(void 0),O=(0,w.createContext)({});var i=()=>{let t=(0,K.useContext)(U);if(!t)throw new Error("useUniformContext must be used within a <UniformContext> provider");return t};var _=require("react");function mt(){let{context:t}=i(),[e,o]=(0,_.useState)(t.storage.data.quirks),n=r=>{o(r)};return(0,_.useEffect)(()=>(t.events.on("quirksUpdated",n),()=>{t.events.off("quirksUpdated",n)}),[t]),e}var v=require("react");var Q=require("dequal/lite");function M(){let{context:t}=i(),[e,o]=(0,v.useState)(t.scores);return(0,v.useEffect)(()=>{let n=p=>{o(p)},r=t.scores;return(0,Q.dequal)(e,r)||o(r),t.events.on("scoresUpdated",n),()=>{t.events.off("scoresUpdated",n)}},[t]),e}var H=l(require("react"));var y=l(require("react"));function W({variations:t,component:e,wrapperComponent:o,name:n,count:r=1}){let{context:p}=i(),s=M(),{variations:x,personalized:g}=(0,y.useMemo)(()=>p.personalize({name:n,variations:t,take:r}),[s,p,r,n,t]),E=o!=null?o:({children:f})=>y.default.createElement(y.default.Fragment,null,f),N=e;return y.default.createElement(O.Provider,{value:{personalized:!0}},x.length?y.default.createElement(E,{personalizationOccurred:g},x.map(f=>y.default.createElement(N,{key:f.id,personalizationResult:{variation:f,personalizationOccurred:g},...f}))):null)}var S=require("@uniformdev/context"),c=l(require("react"));var B=require("@uniformdev/context"),j=require("react"),u=t=>(0,j.createElement)(B.EdgeNodeTagName,t);function X(t){let{variations:e,count:o,component:n}=t,r={count:o!=null?o:1},p=n;return c.default.createElement(c.default.Fragment,null,c.default.createElement(u,{"data-type":S.ScriptType.ListStart,dangerouslySetInnerHTML:{__html:JSON.stringify(r)}}),e.map(s=>c.default.createElement(c.default.Fragment,null,c.default.createElement(u,{"data-type":S.ScriptType.ListItemSettings,dangerouslySetInnerHTML:{__html:JSON.stringify({id:s.id,pz:s.pz||null})}}),c.default.createElement(u,{"data-type":S.ScriptType.ListItem},c.default.createElement(p,{key:s.id,personalizationResult:{variation:s,personalizationOccurred:!1},...s})))),c.default.createElement(u,{"data-type":S.ScriptType.ListEnd}))}var P=typeof window=="undefined";function ut(t){let{outputType:e}=i();return!P||e==="standard"?H.default.createElement(W,{...t}):e==="edge"?H.default.createElement(X,{...t}):null}var b=l(require("react"));var k=require("@uniformdev/context"),d=l(require("react"));function G(t){let{name:e,variations:o,component:n}=t,r={name:e},p=n;return d.default.createElement(d.default.Fragment,null,d.default.createElement(u,{"data-type":k.ScriptType.TestStart,dangerouslySetInnerHTML:{__html:JSON.stringify(r)}}),o.map((s,x)=>d.default.createElement(d.default.Fragment,null,d.default.createElement(u,{"data-type":k.ScriptType.ListItemSettings,dangerouslySetInnerHTML:{__html:JSON.stringify({id:s.id})}}),d.default.createElement(u,{"data-type":k.ScriptType.ListItem},d.default.createElement(p,{key:x,...s})))),d.default.createElement(u,{"data-type":k.ScriptType.TestEnd}))}var Y=l(require("react"));var Z=({name:t,variations:e,component:o})=>{let{context:n}=i(),{result:r}=n.test({name:t,variations:e});return r?Y.default.createElement(o,{...r}):null};var ct=t=>{let{outputType:e}=i();return!P||e==="standard"?b.default.createElement(Z,{...t}):e==="edge"?b.default.createElement(G,{...t}):null};var V=l(require("react")),$=require("@uniformdev/context");var tt=l(require("cookie")),dt=({context:t,children:e,outputType:o="standard",trackRouteOnRender:n=!0})=>((0,V.useEffect)(()=>{P||!n||t.update({url:new URL(window.location.href),cookies:tt.default.parse(document.cookie)})}),V.default.createElement(U.Provider,{value:{context:t,outputType:o}},e,P?V.default.createElement(ft,null):null));function ft(){let{context:t}=i(),e={quirks:t.storage.data.quirks,tests:t.storage.data.tests,ssv:t.scores};return V.default.createElement("script",{id:$.SERVER_STATE_ID,type:"application/json",dangerouslySetInnerHTML:{__html:JSON.stringify(e)}})}var T=require("react");var et=require("react");var L=t=>{let{personalized:e}=(0,et.useContext)(O);return typeof e!="undefined"?e:typeof(t==null?void 0:t.personalized)!="undefined"?t.personalized:!1};var lt=({behavior:t,children:e,tagName:o="div",threshold:n=.5,disableVisibilityTrigger:r=typeof window=="undefined"||!("IntersectionObserver"in window),...p})=>{let s=typeof document=="undefined"?"__uniform_track_key_ssr":document.location.href,{context:x}=i(),g=L(),[E,N]=(0,T.useState)(),f=(0,T.useRef)(null),m=(0,T.useRef)();return(0,T.useEffect)(()=>{var D;if(!f.current||g)return;let A=()=>{var R;if(!(E!==s)||!t)return;let z=Array.isArray(t)?t:[t];x.update({enrichments:z}),N(s),(R=m.current)==null||R.call(m)};if(r)A();else{(D=m.current)==null||D.call(m);let C=new IntersectionObserver(([z])=>{z.isIntersecting&&A()},{threshold:n});C.observe(f.current),m.current=()=>{var z;return(z=C.disconnect)==null?void 0:z.call(C)}}return()=>{var C;(C=m.current)==null||C.call(m)}},[x,t,r,n,g,E,s]),(0,T.createElement)(o,{...p,ref:f},e)};var q=l(require("react")),I=require("react");var Tt=({behavior:t,children:e})=>{let o=typeof document=="undefined"?"__uniform_track_key_ssr":document.location.href,{context:n}=i(),r=L(),[p,s]=(0,I.useState)();return(0,I.useEffect)(()=>{if(r)return;(()=>{if(!(p!==o)||!t)return;let E=Array.isArray(t)?t:[t];n.update({enrichments:E}),s(o)})()},[n,t,r,p,o]),q.default.createElement(q.default.Fragment,null,e)};module.exports=pt(xt);0&&(module.exports={Personalize,Test,Track,TrackFragment,UniformContext,useQuirks,useScores,useUniformContext}); |
{ | ||
"name": "@uniformdev/context-react", | ||
"version": "14.2.1-alpha.145+a3b9cfa67", | ||
"version": "14.2.1-alpha.177+e3102741f", | ||
"description": "Uniform Context React integration package", | ||
@@ -29,3 +29,3 @@ "license": "SEE LICENSE IN LICENSE.txt", | ||
"dependencies": { | ||
"@uniformdev/context": "^14.2.1-alpha.145+a3b9cfa67", | ||
"@uniformdev/context": "^14.2.1-alpha.177+e3102741f", | ||
"cookie": "^0.4.1", | ||
@@ -40,3 +40,3 @@ "dequal": "^2.0.2" | ||
], | ||
"gitHead": "a3b9cfa674c238d67d33e04527fc43f97cc1a20e" | ||
"gitHead": "e3102741f79fa495dba2796f59e3b2a6734c3c7e" | ||
} |
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
Manifest confusion
Supply chain riskThis package has inconsistent metadata. This could be malicious or caused by an error when publishing the package.
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
Manifest confusion
Supply chain riskThis package has inconsistent metadata. This could be malicious or caused by an error when publishing the package.
Found 1 instance in 1 package
41039
457