@uniformdev/context-vue 16.0.1-nuxt.166 → 16.0.1-nuxt.179
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.ts +7 -11
- package/dist/index.esm.js +1 -1
- package/dist/index.js +1 -1
- package/dist/index.mjs +1 -1
- package/package.json +4 -4
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import * as vue_demi from 'vue-demi';
|
|
2
|
-
import { Component
|
|
3
|
-
import { TestVariant, EdgeTestComponentOptions, Context } from '@uniformdev/context';
|
|
2
|
+
import { Component } from 'vue-demi';
|
|
3
|
+
import { TestVariant, EdgeTestComponentOptions, Context, Quirks, ScoreVector } from '@uniformdev/context';
|
|
4
4
|
|
|
5
5
|
declare const Test: Component;
|
|
6
6
|
|
|
@@ -61,9 +61,9 @@ declare type UniformContextProps = {
|
|
|
61
61
|
*/
|
|
62
62
|
trackRouteOnRender?: boolean;
|
|
63
63
|
};
|
|
64
|
-
declare const uniformContextInjectionKey
|
|
65
|
-
declare const provideUniformContext: ({ context, outputType, trackRouteOnRender,
|
|
66
|
-
|
|
64
|
+
declare const uniformContextInjectionKey = "uniformContextInjectionKey";
|
|
65
|
+
declare const provideUniformContext: ({ context, outputType, trackRouteOnRender, vueAppInstance, }: UniformContextProps & {
|
|
66
|
+
vueAppInstance?: vue_demi.App<any> | undefined;
|
|
67
67
|
}) => void;
|
|
68
68
|
declare function onRouteChange(context: Context): void;
|
|
69
69
|
declare const useUniformContext: () => UniformContextProps;
|
|
@@ -76,16 +76,12 @@ declare const useIsPersonalized: () => boolean;
|
|
|
76
76
|
* Provides reactive access to the Uniform Context's current visitor quirks values
|
|
77
77
|
* This can be used when you want to read current quirk values directly.
|
|
78
78
|
*/
|
|
79
|
-
declare const useQuirks: () => vue_demi.Ref<
|
|
80
|
-
[x: string]: string;
|
|
81
|
-
}>;
|
|
79
|
+
declare const useQuirks: () => vue_demi.Ref<Quirks>;
|
|
82
80
|
|
|
83
81
|
/**
|
|
84
82
|
* Provides reactive access to the Uniform Context's current visitor scores values.
|
|
85
83
|
* This can be used when you want to read current score values directly.
|
|
86
84
|
*/
|
|
87
|
-
declare const useScores: () => vue_demi.Ref<
|
|
88
|
-
[x: string]: number;
|
|
89
|
-
}>;
|
|
85
|
+
declare const useScores: () => vue_demi.Ref<ScoreVector>;
|
|
90
86
|
|
|
91
87
|
export { EdgeTestListComponentOptions, Personalize, PersonalizeStandard as PersonalizeEdge, Test, TestComponentProps, TestEdgeComponentProps, Track, TrackSlot, UniformContextProps, UniformContextProvider, VariantOutputType, isUsingUniformContext, onRouteChange, provideIsPersonalized, provideUniformContext, uniformContextInjectionKey, useIsPersonalized, useQuirks, useScores, useUniformContext };
|
package/dist/index.esm.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
import{defineComponent as Z,h as ee,computed as oe}from"vue-demi";var l=typeof window=="undefined";import{defineComponent as $,h as G,toRaw as q}from"vue-demi";import{inject as P,provide as K,getCurrentInstance as I}from"vue-demi";import{parse as Q}from"cookie-es";var d="uniformContextInjectionKey",b=({context:e,outputType:o="standard",trackRouteOnRender:t=!0,vueAppInstance:n})=>{var i;let a={context:e,outputType:o};console.log("provideUniformContext payload",a),console.log("provideUniformContext vueAppInstance",n==null?void 0:n._uid),console.log("provideUniformContext currentVueAppInstance",(i=I())==null?void 0:i.appContext.app._uid),n?n.provide(d,a):K(d,a),!l&&t&&R(e)};function R(e){e==null||e.update({url:new URL(window.location.href),cookies:Q(document.cookie)})}var r=()=>{let e=P(d);if(!e)throw Error("Could not inject Uniform's Context, make sure you're using <UniformContextProvider /> or the Uniform Nuxt module with a valid manifest.");return e};function J(){var o,t;let e=Boolean((o=I())==null?void 0:o.appContext.provides[d]);return console.log("isUsingUniformContext inject(uniformContextInjectionKey)",P(d)),console.log("isUsingUniformContext isUniformContextProvided",e),console.log("isUsingUniformContext inject(hello)",P("hello")),Boolean((t=P(d))==null?void 0:t.context)}var W=$({name:"TestStandard",inheritAttrs:!1,props:{name:{type:String,required:!0},variations:{type:Array,required:!0},loadingMode:{type:String,default:"default"},component:{type:[Object,Function],default:null}},setup(e){let{context:o}=r(),{result:t}=o.test({name:q(e.name),variations:q(e.variations)});return t?()=>G(e.component,{...t}):null}}),w=W;import{defineComponent as X,h as c}from"vue-demi";import{ScriptType as T,EdgeNodeTagName as v}from"@uniformdev/context";var Y=X({name:"TestEdge",inheritAttrs:!1,props:{name:{type:String,required:!0},variations:{type:Array,required:!0},loadingMode:{type:String,default:"default"},component:{type:[Object,Function],default:null}},setup(e){let o={name:e.name};return()=>[c(v,{"data-type":T.TestStart,innerHTML:JSON.stringify(o)}),e.variations.map(t=>[c(v,{"data-type":T.ListItemSettings,key:`LIS-${t.id}`,innerHTML:JSON.stringify({id:t.id})}),c(v,{"data-type":T.ListItem,key:`LI-${t.id}`},c(e.component,{...t}))]),c(v,{"data-type":T.TestEnd})]}}),L=Y;var te=Z({name:"Test",inheritAttrs:!1,props:{name:{type:String,required:!0},variations:{type:Array,required:!0},loadingMode:{type:String,default:"default"},component:{type:[Object,Function],default:null}},setup(e){let{outputType:o}=r(),t=oe(()=>!l||o==="standard"?w:L);return()=>ee(t.value,{...e})}}),ne=te;import{defineComponent as re,h as ae}from"vue-demi";var ie=re({name:"UniformContextProvider",inheritAttrs:!1,props:{context:{type:Object,required:!0},outputType:{type:String,default:"standard"},trackRouteOnRender:{type:Boolean,default:!0}},setup(e,o){return b(e),()=>ae(o.slots.default)}}),se=ie;import{defineComponent as be,h as Ue,computed as Se}from"vue-demi";import{defineComponent as ye,ref as Pe,watch as Te,h as M,onServerPrefetch as ve,onMounted as xe,toRaw as V}from"vue-demi";import{ref as pe,watchEffect as me}from"vue-demi";import{dequal as ue}from"dequal/lite";var U=()=>{let{context:e}=r(),o=pe(e.scores);return me(()=>{let t=a=>o.value=a,n=e.scores;return ue(o.value,n)||(o.value=n),e.events.on("scoresUpdated",t),()=>{e.events.off("scoresUpdated",t)}}),o};import{defineComponent as ce,h as fe}from"vue-demi";import{provide as de,inject as le}from"vue-demi";var j=Symbol("uniformIsPersonalized"),S=e=>{de(j,e)},f=()=>le(j,!1);var Ce=ce({name:"PersonalizeStandard",inheritAttrs:!1,props:{personalized:Boolean},setup(e,o){return S(e.personalized),()=>fe(o.slots.default,{...e})}}),N=Ce;var he=ye({name:"PersonalizeStandard",inheritAttrs:!1,props:{name:{type:String,required:!0},variations:{type:Array,required:!0},component:{type:[Function,Object],required:!0},count:{type:Number,default:1}},setup(e){let{context:o}=r(),t=U(),n=()=>o.personalize({name:V(e.name),variations:V(e.variations),take:V(e.count)}),a=Pe();return ve(async()=>{a.value=n()}),xe(async()=>{a.value||(a.value=n())}),Te([t,()=>e.name,()=>e.variations,()=>e.count],()=>{a.value=n()}),()=>M(N,{personalized:!0},()=>{var i;return(i=a.value)==null?void 0:i.variations.map(s=>{var u;return M(e.component,{key:s.id,personalizationResult:{variation:s,personalizationOccurred:(u=a.value)==null?void 0:u.personalized},...s})})})}}),H=he;import{EdgeNodeTagName as x,ScriptType as h}from"@uniformdev/context";import{defineComponent as ge,h as C}from"vue-demi";var ze=ge({name:"PersonalizeStandard",inheritAttrs:!1,props:{name:{type:String,required:!0},variations:{type:Array,required:!0},component:{type:[Object,Function],required:!0},count:{type:Number,default:1}},setup(e){var t;let o={count:(t=e.count)!=null?t:1};return()=>[C(x,{"data-type":h.ListStart,innerHTML:JSON.stringify(o)}),e.variations.map(n=>[C(x,{"data-type":h.ListItemSettings,innerHTML:JSON.stringify({id:n.id,pz:n.pz||null}),key:`LIS-${n.id}`}),C(x,{"data-type":h.ListItem,key:`LI-${n.id}`},C(e.component,{personalizationResult:{variation:n,personalizationOccurred:!1},...n}))]),C(x,{"data-type":h.ListEnd})]}}),k=ze;var Ve=be({name:"Personalize",inheritAttrs:!1,props:{name:{type:String,required:!0},variations:{type:Array,required:!0},component:{type:[Function,Object],required:!0},count:{type:Number,default:1}},setup(e){let{outputType:o}=r(),t=Se(()=>!l||o==="standard"?H:k);return()=>Ue(t.value,{...e})}}),ke=Ve;import{defineComponent as Oe,watchEffect as B,ref as g,h as Ee,toRaw as Ae}from"vue-demi";var Ie=Oe({name:"Track",inheritAttrs:!1,props:{behavior:{type:[Object,Array]},tagName:{type:String,default:"div"},disableVisibilityTrigger:{type:Boolean,default:typeof window=="undefined"||!("IntersectionObserver"in window)},threshold:{type:[Number,Array],default:.5}},setup(e,o){let t=typeof document=="undefined"?"__uniform_ssr_url":document.location.href,{context:n}=r(),a=f(),i=g(""),s=g(!1),u=g(),p=g();return B(()=>{i.value!==t&&(i.value=t,s.value=!1)}),B(()=>{var A;let z=!e.behavior||Array.isArray(e.behavior)&&!e.behavior.length;if(a||z||!u.value)return;let F=Array.isArray(e.behavior)?e.behavior:[e.behavior],E=()=>{var m;s.value||(n==null||n.update({enrichments:Ae(F)}),s.value=!1,(m=p.value)==null||m.call(p))};if(e.disableVisibilityTrigger)E();else{(A=p.value)==null||A.call(p);let m=new IntersectionObserver(([y])=>{y.isIntersecting&&E()},{threshold:e.threshold});m.observe(u.value),p.value=()=>{var y;return(y=m.disconnect)==null?void 0:y.call(m)}}return()=>{var m;(m=p.value)==null||m.call(p)}}),()=>Ee(e.tagName,{ref:u,...o.attrs},o.slots.default())}}),Re=Ie;import{defineComponent as qe,ref as _,watchEffect as D,h as we,toRaw as Le}from"vue-demi";var je=qe({name:"TrackSlot",inheritAttrs:!1,props:{behavior:{type:[Object,Array]}},setup(e,o){let t=typeof document=="undefined"?"__uniform_ssr_url":document.location.href,{context:n}=r(),a=f(),i=_(),s=_(!1);return D(()=>{i.value!==t&&(i.value=t,s.value=!1)}),D(()=>{let u=!e.behavior||Array.isArray(e.behavior)&&!e.behavior.length;if(a||u)return;(()=>{if(s.value)return;let O=Array.isArray(e.behavior)?e.behavior:[e.behavior];n==null||n.update({enrichments:Le(O)}),s.value=!0})()}),()=>we(o.slots.default,{...o.attrs})}}),Ne=je;import{ref as Me,watch as He}from"vue-demi";var Be=()=>{let{context:e}=r(),o=Me(e.quirks),t=n=>{o.value=n};return He(e,()=>(e.events.on("quirksUpdated",t),()=>{e.events.off("quirksUpdated",t)})),o};export{ke as Personalize,k as PersonalizeEdge,ne as Test,Re as Track,Ne as TrackSlot,se as UniformContextProvider,J as isUsingUniformContext,R as onRouteChange,S as provideIsPersonalized,b as provideUniformContext,d as uniformContextInjectionKey,f as useIsPersonalized,Be as useQuirks,U as useScores,r as useUniformContext};
|
package/dist/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var L=Object.defineProperty;var te=Object.getOwnPropertyDescriptor;var ne=Object.getOwnPropertyNames;var re=Object.prototype.hasOwnProperty;var ae=(e,o)=>{for(var t in o)L(e,t,{get:o[t],enumerable:!0})},ie=(e,o,t,n)=>{if(o&&typeof o=="object"||typeof o=="function")for(let r of ne(o))!re.call(e,r)&&r!==t&&L(e,r,{get:()=>o[r],enumerable:!(n=te(o,r))||n.enumerable});return e};var se=e=>ie(L({},"__esModule",{value:!0}),e);var Te={};ae(Te,{Personalize:()=>X,PersonalizeEdge:()=>R,Test:()=>K,Track:()=>Y,TrackSlot:()=>Z,UniformContextProvider:()=>Q,isUsingUniformContext:()=>
|
|
1
|
+
"use strict";var L=Object.defineProperty;var te=Object.getOwnPropertyDescriptor;var ne=Object.getOwnPropertyNames;var re=Object.prototype.hasOwnProperty;var ae=(e,o)=>{for(var t in o)L(e,t,{get:o[t],enumerable:!0})},ie=(e,o,t,n)=>{if(o&&typeof o=="object"||typeof o=="function")for(let r of ne(o))!re.call(e,r)&&r!==t&&L(e,r,{get:()=>o[r],enumerable:!(n=te(o,r))||n.enumerable});return e};var se=e=>ie(L({},"__esModule",{value:!0}),e);var Te={};ae(Te,{Personalize:()=>X,PersonalizeEdge:()=>R,Test:()=>K,Track:()=>Y,TrackSlot:()=>Z,UniformContextProvider:()=>Q,isUsingUniformContext:()=>_,onRouteChange:()=>j,provideIsPersonalized:()=>A,provideUniformContext:()=>S,uniformContextInjectionKey:()=>P,useIsPersonalized:()=>z,useQuirks:()=>ee,useScores:()=>O,useUniformContext:()=>a});module.exports=se(Te);var g=require("vue-demi");var h=typeof window=="undefined";var x=require("vue-demi");var c=require("vue-demi");var B=require("cookie-es"),P="uniformContextInjectionKey",S=({context:e,outputType:o="standard",trackRouteOnRender:t=!0,vueAppInstance:n})=>{var m;let r={context:e,outputType:o};console.log("provideUniformContext payload",r),console.log("provideUniformContext vueAppInstance",n==null?void 0:n._uid),console.log("provideUniformContext currentVueAppInstance",(m=(0,c.getCurrentInstance)())==null?void 0:m.appContext.app._uid),n?n.provide(P,r):(0,c.provide)(P,r),!h&&t&&j(e)};function j(e){e==null||e.update({url:new URL(window.location.href),cookies:(0,B.parse)(document.cookie)})}var a=()=>{let e=(0,c.inject)(P);if(!e)throw Error("Could not inject Uniform's Context, make sure you're using <UniformContextProvider /> or the Uniform Nuxt module with a valid manifest.");return e};function _(){var o,t;let e=Boolean((o=(0,c.getCurrentInstance)())==null?void 0:o.appContext.provides[P]);return console.log("isUsingUniformContext inject(uniformContextInjectionKey)",(0,c.inject)(P)),console.log("isUsingUniformContext isUniformContextProvided",e),console.log("isUsingUniformContext inject(hello)",(0,c.inject)("hello")),Boolean((t=(0,c.inject)(P))==null?void 0:t.context)}var pe=(0,x.defineComponent)({name:"TestStandard",inheritAttrs:!1,props:{name:{type:String,required:!0},variations:{type:Array,required:!0},loadingMode:{type:String,default:"default"},component:{type:[Object,Function],default:null}},setup(e){let{context:o}=a(),{result:t}=o.test({name:(0,x.toRaw)(e.name),variations:(0,x.toRaw)(e.variations)});return t?()=>(0,x.h)(e.component,{...t}):null}}),D=pe;var T=require("vue-demi"),f=require("@uniformdev/context"),me=(0,T.defineComponent)({name:"TestEdge",inheritAttrs:!1,props:{name:{type:String,required:!0},variations:{type:Array,required:!0},loadingMode:{type:String,default:"default"},component:{type:[Object,Function],default:null}},setup(e){let o={name:e.name};return()=>[(0,T.h)(f.EdgeNodeTagName,{"data-type":f.ScriptType.TestStart,innerHTML:JSON.stringify(o)}),e.variations.map(t=>[(0,T.h)(f.EdgeNodeTagName,{"data-type":f.ScriptType.ListItemSettings,key:`LIS-${t.id}`,innerHTML:JSON.stringify({id:t.id})}),(0,T.h)(f.EdgeNodeTagName,{"data-type":f.ScriptType.ListItem,key:`LI-${t.id}`},(0,T.h)(e.component,{...t}))]),(0,T.h)(f.EdgeNodeTagName,{"data-type":f.ScriptType.TestEnd})]}}),F=me;var ue=(0,g.defineComponent)({name:"Test",inheritAttrs:!1,props:{name:{type:String,required:!0},variations:{type:Array,required:!0},loadingMode:{type:String,default:"default"},component:{type:[Object,Function],default:null}},setup(e){let{outputType:o}=a(),t=(0,g.computed)(()=>!h||o==="standard"?D:F);return()=>(0,g.h)(t.value,{...e})}}),K=ue;var V=require("vue-demi");var de=(0,V.defineComponent)({name:"UniformContextProvider",inheritAttrs:!1,props:{context:{type:Object,required:!0},outputType:{type:String,default:"standard"},trackRouteOnRender:{type:Boolean,default:!0}},setup(e,o){return S(e),()=>(0,V.h)(o.slots.default)}}),Q=de;var b=require("vue-demi");var i=require("vue-demi");var k=require("vue-demi");var J=require("dequal/lite"),O=()=>{let{context:e}=a(),o=(0,k.ref)(e.scores);return(0,k.watchEffect)(()=>{let t=r=>o.value=r,n=e.scores;return(0,J.dequal)(o.value,n)||(o.value=n),e.events.on("scoresUpdated",t),()=>{e.events.off("scoresUpdated",t)}}),o};var I=require("vue-demi");var E=require("vue-demi"),$=Symbol("uniformIsPersonalized"),A=e=>{(0,E.provide)($,e)},z=()=>(0,E.inject)($,!1);var le=(0,I.defineComponent)({name:"PersonalizeStandard",inheritAttrs:!1,props:{personalized:Boolean},setup(e,o){return A(e.personalized),()=>(0,I.h)(o.slots.default,{...e})}}),G=le;var ce=(0,i.defineComponent)({name:"PersonalizeStandard",inheritAttrs:!1,props:{name:{type:String,required:!0},variations:{type:Array,required:!0},component:{type:[Function,Object],required:!0},count:{type:Number,default:1}},setup(e){let{context:o}=a(),t=O(),n=()=>o.personalize({name:(0,i.toRaw)(e.name),variations:(0,i.toRaw)(e.variations),take:(0,i.toRaw)(e.count)}),r=(0,i.ref)();return(0,i.onServerPrefetch)(async()=>{r.value=n()}),(0,i.onMounted)(async()=>{r.value||(r.value=n())}),(0,i.watch)([t,()=>e.name,()=>e.variations,()=>e.count],()=>{r.value=n()}),()=>(0,i.h)(G,{personalized:!0},()=>{var m;return(m=r.value)==null?void 0:m.variations.map(u=>{var y;return(0,i.h)(e.component,{key:u.id,personalizationResult:{variation:u,personalizationOccurred:(y=r.value)==null?void 0:y.personalized},...u})})})}}),W=ce;var C=require("@uniformdev/context"),v=require("vue-demi"),fe=(0,v.defineComponent)({name:"PersonalizeStandard",inheritAttrs:!1,props:{name:{type:String,required:!0},variations:{type:Array,required:!0},component:{type:[Object,Function],required:!0},count:{type:Number,default:1}},setup(e){var t;let o={count:(t=e.count)!=null?t:1};return()=>[(0,v.h)(C.EdgeNodeTagName,{"data-type":C.ScriptType.ListStart,innerHTML:JSON.stringify(o)}),e.variations.map(n=>[(0,v.h)(C.EdgeNodeTagName,{"data-type":C.ScriptType.ListItemSettings,innerHTML:JSON.stringify({id:n.id,pz:n.pz||null}),key:`LIS-${n.id}`}),(0,v.h)(C.EdgeNodeTagName,{"data-type":C.ScriptType.ListItem,key:`LI-${n.id}`},(0,v.h)(e.component,{personalizationResult:{variation:n,personalizationOccurred:!1},...n}))]),(0,v.h)(C.EdgeNodeTagName,{"data-type":C.ScriptType.ListEnd})]}}),R=fe;var Ce=(0,b.defineComponent)({name:"Personalize",inheritAttrs:!1,props:{name:{type:String,required:!0},variations:{type:Array,required:!0},component:{type:[Function,Object],required:!0},count:{type:Number,default:1}},setup(e){let{outputType:o}=a(),t=(0,b.computed)(()=>!h||o==="standard"?W:R);return()=>(0,b.h)(t.value,{...e})}}),X=Ce;var s=require("vue-demi");var ye=(0,s.defineComponent)({name:"Track",inheritAttrs:!1,props:{behavior:{type:[Object,Array]},tagName:{type:String,default:"div"},disableVisibilityTrigger:{type:Boolean,default:typeof window=="undefined"||!("IntersectionObserver"in window)},threshold:{type:[Number,Array],default:.5}},setup(e,o){let t=typeof document=="undefined"?"__uniform_ssr_url":document.location.href,{context:n}=a(),r=z(),m=(0,s.ref)(""),u=(0,s.ref)(!1),y=(0,s.ref)(),d=(0,s.ref)();return(0,s.watchEffect)(()=>{m.value!==t&&(m.value=t,u.value=!1)}),(0,s.watchEffect)(()=>{var H;let w=!e.behavior||Array.isArray(e.behavior)&&!e.behavior.length;if(r||w||!y.value)return;let oe=Array.isArray(e.behavior)?e.behavior:[e.behavior],M=()=>{var l;u.value||(n==null||n.update({enrichments:(0,s.toRaw)(oe)}),u.value=!1,(l=d.value)==null||l.call(d))};if(e.disableVisibilityTrigger)M();else{(H=d.value)==null||H.call(d);let l=new IntersectionObserver(([U])=>{U.isIntersecting&&M()},{threshold:e.threshold});l.observe(y.value),d.value=()=>{var U;return(U=l.disconnect)==null?void 0:U.call(l)}}return()=>{var l;(l=d.value)==null||l.call(d)}}),()=>(0,s.h)(e.tagName,{ref:y,...o.attrs},o.slots.default())}}),Y=ye;var p=require("vue-demi");var Pe=(0,p.defineComponent)({name:"TrackSlot",inheritAttrs:!1,props:{behavior:{type:[Object,Array]}},setup(e,o){let t=typeof document=="undefined"?"__uniform_ssr_url":document.location.href,{context:n}=a(),r=z(),m=(0,p.ref)(),u=(0,p.ref)(!1);return(0,p.watchEffect)(()=>{m.value!==t&&(m.value=t,u.value=!1)}),(0,p.watchEffect)(()=>{let y=!e.behavior||Array.isArray(e.behavior)&&!e.behavior.length;if(r||y)return;(()=>{if(u.value)return;let N=Array.isArray(e.behavior)?e.behavior:[e.behavior];n==null||n.update({enrichments:(0,p.toRaw)(N)}),u.value=!0})()}),()=>(0,p.h)(o.slots.default,{...o.attrs})}}),Z=Pe;var q=require("vue-demi");var ee=()=>{let{context:e}=a(),o=(0,q.ref)(e.quirks),t=n=>{o.value=n};return(0,q.watch)(e,()=>(e.events.on("quirksUpdated",t),()=>{e.events.off("quirksUpdated",t)})),o};0&&(module.exports={Personalize,PersonalizeEdge,Test,Track,TrackSlot,UniformContextProvider,isUsingUniformContext,onRouteChange,provideIsPersonalized,provideUniformContext,uniformContextInjectionKey,useIsPersonalized,useQuirks,useScores,useUniformContext});
|
package/dist/index.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
import{defineComponent as Z,h as ee,computed as oe}from"vue-demi";var l=typeof window=="undefined";import{defineComponent as $,h as G,toRaw as q}from"vue-demi";import{inject as P,provide as K,getCurrentInstance as I}from"vue-demi";import{parse as Q}from"cookie-es";var d="uniformContextInjectionKey",b=({context:e,outputType:o="standard",trackRouteOnRender:t=!0,vueAppInstance:n})=>{var i;let a={context:e,outputType:o};console.log("provideUniformContext payload",a),console.log("provideUniformContext vueAppInstance",n==null?void 0:n._uid),console.log("provideUniformContext currentVueAppInstance",(i=I())==null?void 0:i.appContext.app._uid),n?n.provide(d,a):K(d,a),!l&&t&&R(e)};function R(e){e==null||e.update({url:new URL(window.location.href),cookies:Q(document.cookie)})}var r=()=>{let e=P(d);if(!e)throw Error("Could not inject Uniform's Context, make sure you're using <UniformContextProvider /> or the Uniform Nuxt module with a valid manifest.");return e};function J(){var o,t;let e=Boolean((o=I())==null?void 0:o.appContext.provides[d]);return console.log("isUsingUniformContext inject(uniformContextInjectionKey)",P(d)),console.log("isUsingUniformContext isUniformContextProvided",e),console.log("isUsingUniformContext inject(hello)",P("hello")),Boolean((t=P(d))==null?void 0:t.context)}var W=$({name:"TestStandard",inheritAttrs:!1,props:{name:{type:String,required:!0},variations:{type:Array,required:!0},loadingMode:{type:String,default:"default"},component:{type:[Object,Function],default:null}},setup(e){let{context:o}=r(),{result:t}=o.test({name:q(e.name),variations:q(e.variations)});return t?()=>G(e.component,{...t}):null}}),w=W;import{defineComponent as X,h as c}from"vue-demi";import{ScriptType as T,EdgeNodeTagName as v}from"@uniformdev/context";var Y=X({name:"TestEdge",inheritAttrs:!1,props:{name:{type:String,required:!0},variations:{type:Array,required:!0},loadingMode:{type:String,default:"default"},component:{type:[Object,Function],default:null}},setup(e){let o={name:e.name};return()=>[c(v,{"data-type":T.TestStart,innerHTML:JSON.stringify(o)}),e.variations.map(t=>[c(v,{"data-type":T.ListItemSettings,key:`LIS-${t.id}`,innerHTML:JSON.stringify({id:t.id})}),c(v,{"data-type":T.ListItem,key:`LI-${t.id}`},c(e.component,{...t}))]),c(v,{"data-type":T.TestEnd})]}}),L=Y;var te=Z({name:"Test",inheritAttrs:!1,props:{name:{type:String,required:!0},variations:{type:Array,required:!0},loadingMode:{type:String,default:"default"},component:{type:[Object,Function],default:null}},setup(e){let{outputType:o}=r(),t=oe(()=>!l||o==="standard"?w:L);return()=>ee(t.value,{...e})}}),ne=te;import{defineComponent as re,h as ae}from"vue-demi";var ie=re({name:"UniformContextProvider",inheritAttrs:!1,props:{context:{type:Object,required:!0},outputType:{type:String,default:"standard"},trackRouteOnRender:{type:Boolean,default:!0}},setup(e,o){return b(e),()=>ae(o.slots.default)}}),se=ie;import{defineComponent as be,h as Ue,computed as Se}from"vue-demi";import{defineComponent as ye,ref as Pe,watch as Te,h as M,onServerPrefetch as ve,onMounted as xe,toRaw as V}from"vue-demi";import{ref as pe,watchEffect as me}from"vue-demi";import{dequal as ue}from"dequal/lite";var U=()=>{let{context:e}=r(),o=pe(e.scores);return me(()=>{let t=a=>o.value=a,n=e.scores;return ue(o.value,n)||(o.value=n),e.events.on("scoresUpdated",t),()=>{e.events.off("scoresUpdated",t)}}),o};import{defineComponent as ce,h as fe}from"vue-demi";import{provide as de,inject as le}from"vue-demi";var j=Symbol("uniformIsPersonalized"),S=e=>{de(j,e)},f=()=>le(j,!1);var Ce=ce({name:"PersonalizeStandard",inheritAttrs:!1,props:{personalized:Boolean},setup(e,o){return S(e.personalized),()=>fe(o.slots.default,{...e})}}),N=Ce;var he=ye({name:"PersonalizeStandard",inheritAttrs:!1,props:{name:{type:String,required:!0},variations:{type:Array,required:!0},component:{type:[Function,Object],required:!0},count:{type:Number,default:1}},setup(e){let{context:o}=r(),t=U(),n=()=>o.personalize({name:V(e.name),variations:V(e.variations),take:V(e.count)}),a=Pe();return ve(async()=>{a.value=n()}),xe(async()=>{a.value||(a.value=n())}),Te([t,()=>e.name,()=>e.variations,()=>e.count],()=>{a.value=n()}),()=>M(N,{personalized:!0},()=>{var i;return(i=a.value)==null?void 0:i.variations.map(s=>{var u;return M(e.component,{key:s.id,personalizationResult:{variation:s,personalizationOccurred:(u=a.value)==null?void 0:u.personalized},...s})})})}}),H=he;import{EdgeNodeTagName as x,ScriptType as h}from"@uniformdev/context";import{defineComponent as ge,h as C}from"vue-demi";var ze=ge({name:"PersonalizeStandard",inheritAttrs:!1,props:{name:{type:String,required:!0},variations:{type:Array,required:!0},component:{type:[Object,Function],required:!0},count:{type:Number,default:1}},setup(e){var t;let o={count:(t=e.count)!=null?t:1};return()=>[C(x,{"data-type":h.ListStart,innerHTML:JSON.stringify(o)}),e.variations.map(n=>[C(x,{"data-type":h.ListItemSettings,innerHTML:JSON.stringify({id:n.id,pz:n.pz||null}),key:`LIS-${n.id}`}),C(x,{"data-type":h.ListItem,key:`LI-${n.id}`},C(e.component,{personalizationResult:{variation:n,personalizationOccurred:!1},...n}))]),C(x,{"data-type":h.ListEnd})]}}),k=ze;var Ve=be({name:"Personalize",inheritAttrs:!1,props:{name:{type:String,required:!0},variations:{type:Array,required:!0},component:{type:[Function,Object],required:!0},count:{type:Number,default:1}},setup(e){let{outputType:o}=r(),t=Se(()=>!l||o==="standard"?H:k);return()=>Ue(t.value,{...e})}}),ke=Ve;import{defineComponent as Oe,watchEffect as B,ref as g,h as Ee,toRaw as Ae}from"vue-demi";var Ie=Oe({name:"Track",inheritAttrs:!1,props:{behavior:{type:[Object,Array]},tagName:{type:String,default:"div"},disableVisibilityTrigger:{type:Boolean,default:typeof window=="undefined"||!("IntersectionObserver"in window)},threshold:{type:[Number,Array],default:.5}},setup(e,o){let t=typeof document=="undefined"?"__uniform_ssr_url":document.location.href,{context:n}=r(),a=f(),i=g(""),s=g(!1),u=g(),p=g();return B(()=>{i.value!==t&&(i.value=t,s.value=!1)}),B(()=>{var A;let z=!e.behavior||Array.isArray(e.behavior)&&!e.behavior.length;if(a||z||!u.value)return;let F=Array.isArray(e.behavior)?e.behavior:[e.behavior],E=()=>{var m;s.value||(n==null||n.update({enrichments:Ae(F)}),s.value=!1,(m=p.value)==null||m.call(p))};if(e.disableVisibilityTrigger)E();else{(A=p.value)==null||A.call(p);let m=new IntersectionObserver(([y])=>{y.isIntersecting&&E()},{threshold:e.threshold});m.observe(u.value),p.value=()=>{var y;return(y=m.disconnect)==null?void 0:y.call(m)}}return()=>{var m;(m=p.value)==null||m.call(p)}}),()=>Ee(e.tagName,{ref:u,...o.attrs},o.slots.default())}}),Re=Ie;import{defineComponent as qe,ref as _,watchEffect as D,h as we,toRaw as Le}from"vue-demi";var je=qe({name:"TrackSlot",inheritAttrs:!1,props:{behavior:{type:[Object,Array]}},setup(e,o){let t=typeof document=="undefined"?"__uniform_ssr_url":document.location.href,{context:n}=r(),a=f(),i=_(),s=_(!1);return D(()=>{i.value!==t&&(i.value=t,s.value=!1)}),D(()=>{let u=!e.behavior||Array.isArray(e.behavior)&&!e.behavior.length;if(a||u)return;(()=>{if(s.value)return;let O=Array.isArray(e.behavior)?e.behavior:[e.behavior];n==null||n.update({enrichments:Le(O)}),s.value=!0})()}),()=>we(o.slots.default,{...o.attrs})}}),Ne=je;import{ref as Me,watch as He}from"vue-demi";var Be=()=>{let{context:e}=r(),o=Me(e.quirks),t=n=>{o.value=n};return He(e,()=>(e.events.on("quirksUpdated",t),()=>{e.events.off("quirksUpdated",t)})),o};export{ke as Personalize,k as PersonalizeEdge,ne as Test,Re as Track,Ne as TrackSlot,se as UniformContextProvider,J as isUsingUniformContext,R as onRouteChange,S as provideIsPersonalized,b as provideUniformContext,d as uniformContextInjectionKey,f as useIsPersonalized,Be as useQuirks,U as useScores,r as useUniformContext};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@uniformdev/context-vue",
|
|
3
|
-
"version": "16.0.1-nuxt.
|
|
3
|
+
"version": "16.0.1-nuxt.179+842199728",
|
|
4
4
|
"description": "Vue SDK for Uniform Context",
|
|
5
5
|
"license": "SEE LICENSE IN LICENSE.txt",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -23,7 +23,7 @@
|
|
|
23
23
|
"format": "prettier --write \"src/**/*.{js,ts,tsx}\""
|
|
24
24
|
},
|
|
25
25
|
"dependencies": {
|
|
26
|
-
"@uniformdev/context": "^16.0.1-nuxt.
|
|
26
|
+
"@uniformdev/context": "^16.0.1-nuxt.179+842199728",
|
|
27
27
|
"cookie-es": "^0.5.0",
|
|
28
28
|
"dequal": "^2.0.2",
|
|
29
29
|
"pascal-case": "3.1.2",
|
|
@@ -44,7 +44,7 @@
|
|
|
44
44
|
"@types/uuid": "8.3.4",
|
|
45
45
|
"@vue/server-test-utils": "1.3.0",
|
|
46
46
|
"@vue/test-utils": "1.3.0",
|
|
47
|
-
"vue": "3.2.
|
|
47
|
+
"vue": "3.2.37",
|
|
48
48
|
"vue-server-renderer": "2.6.14",
|
|
49
49
|
"vue-template-compiler": "2.6.14"
|
|
50
50
|
},
|
|
@@ -65,5 +65,5 @@
|
|
|
65
65
|
"last 2 versions",
|
|
66
66
|
"not dead"
|
|
67
67
|
],
|
|
68
|
-
"gitHead": "
|
|
68
|
+
"gitHead": "842199728b5d454c2ca7e82ef7d1fd208f835c4e"
|
|
69
69
|
}
|