@uniformdev/context-vue 17.5.1-alpha.7 → 17.6.1-alpha.106

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 CHANGED
@@ -1,106 +1,7 @@
1
1
  import * as vue_demi from 'vue-demi';
2
2
  import { ConcreteComponent, PropType, App } from 'vue-demi';
3
- import { TestVariant, Context, PersonalizedVariant, EnrichmentData, Quirks, ScoreVector } from '@uniformdev/context';
4
- import * as _uniformdev_context_dist_types_c398dba8 from '@uniformdev/context/dist/types-c398dba8';
5
-
6
- interface TestComponentProps {
7
- /** Name of the test that is running. */
8
- name: string;
9
- /** Variation list that this test will selected from. */
10
- variations: TestVariant[];
11
- /** A Vue component to use to render the test variant. */
12
- component: ConcreteComponent<TestVariant>;
13
- }
14
- declare const Test: vue_demi.DefineComponent<{
15
- name: {
16
- type: PropType<string>;
17
- required: true;
18
- };
19
- variations: {
20
- type: PropType<TestVariant[]>;
21
- required: true;
22
- };
23
- component: {
24
- type: PropType<ConcreteComponent<TestVariant, any, any, vue_demi.ComputedOptions, vue_demi.MethodOptions>>;
25
- required: true;
26
- };
27
- }, () => vue_demi.VNode<vue_demi.RendererNode, vue_demi.RendererElement, {
28
- [key: string]: any;
29
- }>, unknown, {}, {}, vue_demi.ComponentOptionsMixin, vue_demi.ComponentOptionsMixin, {}, string, vue_demi.VNodeProps & vue_demi.AllowedComponentProps & vue_demi.ComponentCustomProps, Readonly<vue_demi.ExtractPropTypes<{
30
- name: {
31
- type: PropType<string>;
32
- required: true;
33
- };
34
- variations: {
35
- type: PropType<TestVariant[]>;
36
- required: true;
37
- };
38
- component: {
39
- type: PropType<ConcreteComponent<TestVariant, any, any, vue_demi.ComputedOptions, vue_demi.MethodOptions>>;
40
- required: true;
41
- };
42
- }>>, {}>;
43
-
44
- declare type VariantOutputType = 'edge' | 'standard';
45
- declare type UniformContextProps = {
46
- /** The configured Uniform Context instance to provide */
47
- context: Context;
48
- /** The output type to emit.
49
- * - `standard` - Emits selected variants as HTML suitable for SSR or SSG
50
- * - `edge` - Emits all variants suitable for Edge-side personalization selection
51
- *
52
- * @default standard
53
- */
54
- outputType?: VariantOutputType;
55
- /**
56
- * Whether to track a route change to the current URL when this component is rendered.
57
- *
58
- * @default true
59
- */
60
- trackRouteOnRender?: boolean;
61
- };
62
- declare const uniformContextInjectionKey = "uniformContextInjectionKey";
63
- declare const provideUniformContext: ({ context, outputType, trackRouteOnRender, vueAppInstance, }: UniformContextProps & {
64
- vueAppInstance?: App<Element> | undefined;
65
- }) => void;
66
- declare function onRouteChange(context: Context): void;
67
- declare const useUniformContext: () => UniformContextProps;
68
- declare function isUsingUniformContext(): boolean;
69
-
70
- declare const UniformContextProvider: vue_demi.DefineComponent<{
71
- context: {
72
- type: PropType<Context>;
73
- required: true;
74
- };
75
- outputType: {
76
- type: PropType<VariantOutputType | undefined>;
77
- default: string;
78
- };
79
- trackRouteOnRender: {
80
- type: PropType<boolean | undefined>;
81
- default: boolean;
82
- };
83
- }, () => (vue_demi.VNode<vue_demi.RendererNode, vue_demi.RendererElement, {
84
- [key: string]: any;
85
- }> | (() => vue_demi.VNode<vue_demi.RendererNode, vue_demi.RendererElement, {
86
- [key: string]: any;
87
- }>))[], unknown, {}, {}, vue_demi.ComponentOptionsMixin, vue_demi.ComponentOptionsMixin, {}, string, vue_demi.VNodeProps & vue_demi.AllowedComponentProps & vue_demi.ComponentCustomProps, Readonly<vue_demi.ExtractPropTypes<{
88
- context: {
89
- type: PropType<Context>;
90
- required: true;
91
- };
92
- outputType: {
93
- type: PropType<VariantOutputType | undefined>;
94
- default: string;
95
- };
96
- trackRouteOnRender: {
97
- type: PropType<boolean | undefined>;
98
- default: boolean;
99
- };
100
- }>>, {
101
- outputType: VariantOutputType | undefined;
102
- trackRouteOnRender: boolean | undefined;
103
- }>;
3
+ import { PersonalizedVariant, TestVariant, EnrichmentData, Context, Quirks, ScoreVector } from '@uniformdev/context';
4
+ import * as _uniformdev_context_dist_types_cb64a6b4 from '@uniformdev/context/dist/types-cb64a6b4';
104
5
 
105
6
  declare type PersonalizedVariationComponentProps = PersonalizedVariant & {
106
7
  personalizationResult: {
@@ -168,7 +69,7 @@ declare const PersonalizeStandard: vue_demi.DefineComponent<{
168
69
  required: true;
169
70
  };
170
71
  variations: {
171
- type: PropType<_uniformdev_context_dist_types_c398dba8.ad[]>;
72
+ type: PropType<_uniformdev_context_dist_types_cb64a6b4.a2[]>;
172
73
  required: true;
173
74
  };
174
75
  component: {
@@ -189,7 +90,7 @@ declare const PersonalizeStandard: vue_demi.DefineComponent<{
189
90
  required: true;
190
91
  };
191
92
  variations: {
192
- type: PropType<_uniformdev_context_dist_types_c398dba8.ad[]>;
93
+ type: PropType<_uniformdev_context_dist_types_cb64a6b4.a2[]>;
193
94
  required: true;
194
95
  };
195
96
  component: {
@@ -204,6 +105,44 @@ declare const PersonalizeStandard: vue_demi.DefineComponent<{
204
105
  count: number | undefined;
205
106
  }>;
206
107
 
108
+ interface TestComponentProps {
109
+ /** Name of the test that is running. */
110
+ name: string;
111
+ /** Variation list that this test will selected from. */
112
+ variations: TestVariant[];
113
+ /** A Vue component to use to render the test variant. */
114
+ component: ConcreteComponent<TestVariant>;
115
+ }
116
+ declare const Test: vue_demi.DefineComponent<{
117
+ name: {
118
+ type: PropType<string>;
119
+ required: true;
120
+ };
121
+ variations: {
122
+ type: PropType<TestVariant[]>;
123
+ required: true;
124
+ };
125
+ component: {
126
+ type: PropType<ConcreteComponent<TestVariant, any, any, vue_demi.ComputedOptions, vue_demi.MethodOptions>>;
127
+ required: true;
128
+ };
129
+ }, () => vue_demi.VNode<vue_demi.RendererNode, vue_demi.RendererElement, {
130
+ [key: string]: any;
131
+ }>, unknown, {}, {}, vue_demi.ComponentOptionsMixin, vue_demi.ComponentOptionsMixin, {}, string, vue_demi.VNodeProps & vue_demi.AllowedComponentProps & vue_demi.ComponentCustomProps, Readonly<vue_demi.ExtractPropTypes<{
132
+ name: {
133
+ type: PropType<string>;
134
+ required: true;
135
+ };
136
+ variations: {
137
+ type: PropType<TestVariant[]>;
138
+ required: true;
139
+ };
140
+ component: {
141
+ type: PropType<ConcreteComponent<TestVariant, any, any, vue_demi.ComputedOptions, vue_demi.MethodOptions>>;
142
+ required: true;
143
+ };
144
+ }>>, {}>;
145
+
207
146
  /**
208
147
  * Tracks visitor behavior by adding enrichment score when they view content wrapped in this component.
209
148
  * When the Track component is sufficiently in the viewport, it will trigger the enrichment values specified
@@ -272,6 +211,67 @@ declare const TrackSlot: vue_demi.DefineComponent<{
272
211
  };
273
212
  }>>, {}>;
274
213
 
214
+ declare type VariantOutputType = 'edge' | 'standard';
215
+ declare type UniformContextProps = {
216
+ /** The configured Uniform Context instance to provide */
217
+ context: Context;
218
+ /** The output type to emit.
219
+ * - `standard` - Emits selected variants as HTML suitable for SSR or SSG
220
+ * - `edge` - Emits all variants suitable for Edge-side personalization selection
221
+ *
222
+ * @default standard
223
+ */
224
+ outputType?: VariantOutputType;
225
+ /**
226
+ * Whether to track a route change to the current URL when this component is rendered.
227
+ *
228
+ * @default true
229
+ */
230
+ trackRouteOnRender?: boolean;
231
+ };
232
+ declare const uniformContextInjectionKey = "uniformContextInjectionKey";
233
+ declare const provideUniformContext: ({ context, outputType, trackRouteOnRender, vueAppInstance, }: UniformContextProps & {
234
+ vueAppInstance?: App<Element> | undefined;
235
+ }) => void;
236
+ declare function onRouteChange(context: Context): void;
237
+ declare const useUniformContext: () => UniformContextProps;
238
+ declare function isUsingUniformContext(): boolean;
239
+
240
+ declare const UniformContextProvider: vue_demi.DefineComponent<{
241
+ context: {
242
+ type: PropType<Context>;
243
+ required: true;
244
+ };
245
+ outputType: {
246
+ type: PropType<VariantOutputType | undefined>;
247
+ default: string;
248
+ };
249
+ trackRouteOnRender: {
250
+ type: PropType<boolean | undefined>;
251
+ default: boolean;
252
+ };
253
+ }, () => (vue_demi.VNode<vue_demi.RendererNode, vue_demi.RendererElement, {
254
+ [key: string]: any;
255
+ }> | (() => vue_demi.VNode<vue_demi.RendererNode, vue_demi.RendererElement, {
256
+ [key: string]: any;
257
+ }>))[], unknown, {}, {}, vue_demi.ComponentOptionsMixin, vue_demi.ComponentOptionsMixin, {}, string, vue_demi.VNodeProps & vue_demi.AllowedComponentProps & vue_demi.ComponentCustomProps, Readonly<vue_demi.ExtractPropTypes<{
258
+ context: {
259
+ type: PropType<Context>;
260
+ required: true;
261
+ };
262
+ outputType: {
263
+ type: PropType<VariantOutputType | undefined>;
264
+ default: string;
265
+ };
266
+ trackRouteOnRender: {
267
+ type: PropType<boolean | undefined>;
268
+ default: boolean;
269
+ };
270
+ }>>, {
271
+ outputType: VariantOutputType | undefined;
272
+ trackRouteOnRender: boolean | undefined;
273
+ }>;
274
+
275
275
  declare const provideIsPersonalized: (isPersonalized?: boolean) => void;
276
276
  declare const useIsPersonalized: () => boolean;
277
277
 
package/dist/index.esm.js CHANGED
@@ -1 +1 @@
1
- import{defineComponent as te,h as L}from"vue-demi";var d=typeof window=="undefined";import{defineComponent as W,h as X,toRaw as V}from"vue-demi";import{inject as J,provide as K,getCurrentInstance as Q}from"vue-demi";import{parse as $}from"cookie-es";var l="uniformContextInjectionKey",g=({context:e,outputType:t="standard",trackRouteOnRender:o=!0,vueAppInstance:r})=>{let i={context:e,outputType:t};r?r.provide(l,i):K(l,i),o&&I(e)};function I(e){d||e==null||e.update({url:new URL(window.location.href),cookies:$(document.cookie)})}var n=()=>{let e=J(l);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 G(){var t;return Boolean((t=Q())==null?void 0:t.appContext.provides[l])}var Y=W({name:"TestStandard",inheritAttrs:!1,props:{name:{type:String,required:!0},variations:{type:Array,required:!0},component:{type:[Object,Function],required:!0}},setup(e){let{context:t}=n(),{result:o}=t.test({name:V(e.name),variations:V(e.variations)});return o?()=>X(e.component,{...o}):()=>null}}),q=Y;import{defineComponent as Z,h as c}from"vue-demi";import{ScriptType as T,EdgeNodeTagName as C}from"@uniformdev/context";var ee=Z({name:"TestEdge",inheritAttrs:!1,props:{name:{type:String,required:!0},variations:{type:Array,required:!0},component:{type:[Object,Function],required:!0}},setup(e){let t={name:e.name};return()=>[c(C,{"data-type":T.TestStart,innerHTML:JSON.stringify(t)}),e.variations.map(o=>[c(C,{"data-type":T.ListItemSettings,key:`LIS-${o.id}`,innerHTML:JSON.stringify({id:o.id})}),c(C,{"data-type":T.ListItem,key:`LI-${o.id}`},c(e.component,{...o}))]),c(C,{"data-type":T.TestEnd})]}}),w=ee;var oe=te({name:"Test",inheritAttrs:!1,props:{name:{type:String,required:!0},variations:{type:Array,required:!0},component:{type:[Object,Function],required:!0}},setup(e){let{outputType:t}=n();return()=>!d||t==="standard"?L(q,{...e}):L(w,{...e})}}),re=oe;import{defineComponent as ne,h as N}from"vue-demi";import{SERVER_STATE_ID as ie}from"@uniformdev/context";var ae=ne({name:"UniformContextProvider",inheritAttrs:!1,props:{context:{type:Object,required:!0},outputType:{type:String,default:"standard"},trackRouteOnRender:{type:Boolean,default:!0}},setup(e,t){return g(e),()=>[N(t.slots.default),pe(e.context)]}}),se=ae;function pe(e){let t=e.getServerToClientTransitionState();return()=>N("script",{id:ie,type:"application/json",innerHTML:JSON.stringify(t)})}import{defineComponent as ge,h as be}from"vue-demi";import{defineComponent as Te,ref as Ce,watch as ve,h as H,toRaw as U}from"vue-demi";import{ref as me,watchEffect as ue}from"vue-demi";import{dequal as de}from"dequal/lite";var b=()=>{let{context:e}=n(),t=me(e.scores);return ue(()=>{let o=i=>t.value=i,r=e.scores;return de(t.value,r)||(t.value=r),e.events.on("scoresUpdated",o),()=>{e.events.off("scoresUpdated",o)}}),t};import{defineComponent as fe,h as ye}from"vue-demi";import{provide as le,inject as ce}from"vue-demi";var R=Symbol("uniformIsPersonalized"),S=e=>{le(R,e)},f=()=>ce(R,!1);var Pe=fe({name:"PersonalizeProvider",inheritAttrs:!1,props:{personalized:Boolean},setup(e,t){return S(e.personalized),()=>ye(t.slots.default,{...e})}}),j=Pe;var he=Te({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:t}=n(),o=b(),r=()=>{var a;return t.personalize({name:U(e.name),variations:U(e.variations),take:(a=U(e.count))!=null?a:1})},i=Ce(r());return ve([o,()=>e.name,()=>e.variations,()=>e.count],()=>{i.value=r()}),()=>H(j,{personalized:!0},()=>{var a;return(a=i.value)==null?void 0:a.variations.map(s=>{var u;return H(e.component,{key:s.id,personalizationResult:{variation:s,personalizationOccurred:(u=i.value)==null?void 0:u.personalized},...s})})})}}),D=he;import{EdgeNodeTagName as v,ScriptType as h}from"@uniformdev/context";import{defineComponent as xe,h as y}from"vue-demi";var ze=xe({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){var o;let t={name:e.name,count:(o=e.count)!=null?o:1};return()=>[y(v,{"data-type":h.ListStart,innerHTML:JSON.stringify(t)}),e.variations.map(r=>[y(v,{"data-type":h.ListItemSettings,innerHTML:JSON.stringify({id:r.id,pz:r.pz||null}),key:`LIS-${r.id}`}),y(v,{"data-type":h.ListItem,key:`LI-${r.id}`},y(e.component,{personalizationResult:{variation:r,personalizationOccurred:!1},...r}))]),y(v,{"data-type":h.ListEnd})]}}),k=ze;var Se=ge({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:t}=n();return()=>be(!d||t==="standard"?D:k,{...e})}}),Ue=Se;import{defineComponent as ke,watchEffect as _,ref as x,h as Ee,toRaw as Ae}from"vue-demi";var Oe=ke({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,t){let o=typeof document=="undefined"?"__uniform_ssr_url":document.location.href,{context:r}=n(),i=f(),a=x(""),s=x(!1),u=x(),p=x();return _(()=>{a.value!==o&&(a.value=o,s.value=!1)}),_(()=>{var O;let z=!e.behavior||Array.isArray(e.behavior)&&!e.behavior.length;if(i||z||!u.value)return;let M=Array.isArray(e.behavior)?e.behavior:[e.behavior],A=()=>{var m;s.value||(r==null||r.update({enrichments:Ae(M)}),s.value=!1,(m=p.value)==null||m.call(p))};if(e.disableVisibilityTrigger)A();else{(O=p.value)==null||O.call(p);let m=new IntersectionObserver(([P])=>{P.isIntersecting&&A()},{threshold:e.threshold});m.observe(u.value),p.value=()=>{var P;return(P=m.disconnect)==null?void 0:P.call(m)}}return()=>{var m;(m=p.value)==null||m.call(p)}}),()=>Ee(e.tagName,{ref:u,...t.attrs},t.slots.default())}}),Ie=Oe;import{defineComponent as Ve,ref as B,watchEffect as F,h as qe,toRaw as we}from"vue-demi";var Le=Ve({name:"TrackSlot",inheritAttrs:!1,props:{behavior:{type:[Object,Array]}},setup(e,t){let o=typeof document=="undefined"?"__uniform_ssr_url":document.location.href,{context:r}=n(),i=f(),a=B(),s=B(!1);return F(()=>{a.value!==o&&(a.value=o,s.value=!1)}),F(()=>{let u=!e.behavior||Array.isArray(e.behavior)&&!e.behavior.length;if(i||u)return;(()=>{if(s.value)return;let E=Array.isArray(e.behavior)?e.behavior:[e.behavior];r==null||r.update({enrichments:we(E)}),s.value=!0})()}),()=>qe(t.slots.default,{...t.attrs})}}),Ne=Le;import{ref as Re,watch as je}from"vue-demi";var He=()=>{let{context:e}=n(),t=Re(e.quirks),o=r=>{t.value=r};return je(e,()=>(e.events.on("quirksUpdated",o),()=>{e.events.off("quirksUpdated",o)})),t};export{Ue as Personalize,k as PersonalizeEdge,re as Test,Ie as Track,Ne as TrackSlot,se as UniformContextProvider,G as isUsingUniformContext,I as onRouteChange,S as provideIsPersonalized,g as provideUniformContext,l as uniformContextInjectionKey,f as useIsPersonalized,He as useQuirks,b as useScores,n as useUniformContext};
1
+ import{defineComponent as ue,h as de}from"vue-demi";import{parse as J}from"cookie-es";import{getCurrentInstance as K,inject as Q,provide as $}from"vue-demi";var d=typeof window=="undefined";var l="uniformContextInjectionKey",g=({context:e,outputType:t="standard",trackRouteOnRender:o=!0,vueAppInstance:r})=>{let i={context:e,outputType:t};r?r.provide(l,i):$(l,i),o&&I(e)};function I(e){d||e==null||e.update({url:new URL(window.location.href),cookies:J(document.cookie)})}var n=()=>{let e=Q(l);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 G(){var t;return Boolean((t=K())==null?void 0:t.appContext.provides[l])}import{EdgeNodeTagName as T,ScriptType as C}from"@uniformdev/context";import{defineComponent as W,h as c}from"vue-demi";var X=W({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){var o;let t={name:e.name,count:(o=e.count)!=null?o:1};return()=>[c(T,{"data-type":C.ListStart,innerHTML:JSON.stringify(t)}),e.variations.map(r=>[c(T,{"data-type":C.ListItemSettings,innerHTML:JSON.stringify({id:r.id,pz:r.pz||null}),key:`LIS-${r.id}`}),c(T,{"data-type":C.ListItem,key:`LI-${r.id}`},c(e.component,{personalizationResult:{variation:r,personalizationOccurred:!1},...r}))]),c(T,{"data-type":C.ListEnd})]}}),b=X;import{defineComponent as ae,h as w,ref as se,toRaw as k,watch as pe}from"vue-demi";import{dequal as Y}from"dequal/lite";import{ref as Z,watchEffect as ee}from"vue-demi";var S=()=>{let{context:e}=n(),t=Z(e.scores);return ee(()=>{let o=i=>t.value=i,r=e.scores;return Y(t.value,r)||(t.value=r),e.events.on("scoresUpdated",o),()=>{e.events.off("scoresUpdated",o)}}),t};import{defineComponent as re,h as ne}from"vue-demi";import{inject as te,provide as oe}from"vue-demi";var V=Symbol("uniformIsPersonalized"),U=e=>{oe(V,e)},f=()=>te(V,!1);var ie=re({name:"PersonalizeProvider",inheritAttrs:!1,props:{personalized:Boolean},setup(e,t){return U(e.personalized),()=>ne(t.slots.default,{...e})}}),q=ie;var me=ae({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:t}=n(),o=S(),r=()=>{var a;return t.personalize({name:k(e.name),variations:k(e.variations),take:(a=k(e.count))!=null?a:1})},i=se(r());return pe([o,()=>e.name,()=>e.variations,()=>e.count],()=>{i.value=r()}),()=>w(q,{personalized:!0},()=>{var a;return(a=i.value)==null?void 0:a.variations.map(s=>{var u;return w(e.component,{key:s.id,personalizationResult:{variation:s,personalizationOccurred:(u=i.value)==null?void 0:u.personalized},...s})})})}}),L=me;var le=ue({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:t}=n();return()=>de(!d||t==="standard"?L:b,{...e})}}),ce=le;import{defineComponent as ve,h as H}from"vue-demi";import{EdgeNodeTagName as v,ScriptType as h}from"@uniformdev/context";import{defineComponent as fe,h as y}from"vue-demi";var ye=fe({name:"TestEdge",inheritAttrs:!1,props:{name:{type:String,required:!0},variations:{type:Array,required:!0},component:{type:[Object,Function],required:!0}},setup(e){let t={name:e.name};return()=>[y(v,{"data-type":h.TestStart,innerHTML:JSON.stringify(t)}),e.variations.map(o=>[y(v,{"data-type":h.ListItemSettings,key:`LIS-${o.id}`,innerHTML:JSON.stringify({id:o.id})}),y(v,{"data-type":h.ListItem,key:`LI-${o.id}`},y(e.component,{...o}))]),y(v,{"data-type":h.TestEnd})]}}),N=ye;import{defineComponent as Pe,h as Te,toRaw as R}from"vue-demi";var Ce=Pe({name:"TestStandard",inheritAttrs:!1,props:{name:{type:String,required:!0},variations:{type:Array,required:!0},component:{type:[Object,Function],required:!0}},setup(e){let{context:t}=n(),{result:o}=t.test({name:R(e.name),variations:R(e.variations)});return o?()=>Te(e.component,{...o}):()=>null}}),j=Ce;var he=ve({name:"Test",inheritAttrs:!1,props:{name:{type:String,required:!0},variations:{type:Array,required:!0},component:{type:[Object,Function],required:!0}},setup(e){let{outputType:t}=n();return()=>!d||t==="standard"?H(j,{...e}):H(N,{...e})}}),xe=he;import{defineComponent as ze,h as ge,ref as x,toRaw as be,watchEffect as D}from"vue-demi";var Se=ze({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,t){let o=typeof document=="undefined"?"__uniform_ssr_url":document.location.href,{context:r}=n(),i=f(),a=x(""),s=x(!1),u=x(),p=x();return D(()=>{a.value!==o&&(a.value=o,s.value=!1)}),D(()=>{var O;let z=!e.behavior||Array.isArray(e.behavior)&&!e.behavior.length;if(i||z||!u.value)return;let M=Array.isArray(e.behavior)?e.behavior:[e.behavior],A=()=>{var m;s.value||(r==null||r.update({enrichments:be(M)}),s.value=!1,(m=p.value)==null||m.call(p))};if(e.disableVisibilityTrigger)A();else{(O=p.value)==null||O.call(p);let m=new IntersectionObserver(([P])=>{P.isIntersecting&&A()},{threshold:e.threshold});m.observe(u.value),p.value=()=>{var P;return(P=m.disconnect)==null?void 0:P.call(m)}}return()=>{var m;(m=p.value)==null||m.call(p)}}),()=>ge(e.tagName,{ref:u,...t.attrs},t.slots.default())}}),Ue=Se;import{defineComponent as ke,h as Ee,ref as _,toRaw as Ae,watchEffect as B}from"vue-demi";var Oe=ke({name:"TrackSlot",inheritAttrs:!1,props:{behavior:{type:[Object,Array]}},setup(e,t){let o=typeof document=="undefined"?"__uniform_ssr_url":document.location.href,{context:r}=n(),i=f(),a=_(),s=_(!1);return B(()=>{a.value!==o&&(a.value=o,s.value=!1)}),B(()=>{let u=!e.behavior||Array.isArray(e.behavior)&&!e.behavior.length;if(i||u)return;(()=>{if(s.value)return;let E=Array.isArray(e.behavior)?e.behavior:[e.behavior];r==null||r.update({enrichments:Ae(E)}),s.value=!0})()}),()=>Ee(t.slots.default,{...t.attrs})}}),Ie=Oe;import{SERVER_STATE_ID as Ve}from"@uniformdev/context";import{defineComponent as qe,h as F}from"vue-demi";var we=qe({name:"UniformContextProvider",inheritAttrs:!1,props:{context:{type:Object,required:!0},outputType:{type:String,default:"standard"},trackRouteOnRender:{type:Boolean,default:!0}},setup(e,t){return g(e),()=>[F(t.slots.default),Ne(e.context)]}}),Le=we;function Ne(e){let t=e.getServerToClientTransitionState();return()=>F("script",{id:Ve,type:"application/json",innerHTML:JSON.stringify(t)})}import{ref as Re,watch as je}from"vue-demi";var He=()=>{let{context:e}=n(),t=Re(e.quirks),o=r=>{t.value=r};return je(e,()=>(e.events.on("quirksUpdated",o),()=>{e.events.off("quirksUpdated",o)})),t};export{ce as Personalize,b as PersonalizeEdge,xe as Test,Ue as Track,Ie as TrackSlot,Le as UniformContextProvider,G as isUsingUniformContext,I as onRouteChange,U as provideIsPersonalized,g as provideUniformContext,l as uniformContextInjectionKey,f as useIsPersonalized,He as useQuirks,S as useScores,n as useUniformContext};
package/dist/index.js CHANGED
@@ -1 +1 @@
1
- "use strict";var N=Object.defineProperty;var re=Object.getOwnPropertyDescriptor;var ne=Object.getOwnPropertyNames;var ie=Object.prototype.hasOwnProperty;var ae=(e,t)=>{for(var o in t)N(e,o,{get:t[o],enumerable:!0})},se=(e,t,o,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let n of ne(t))!ie.call(e,n)&&n!==o&&N(e,n,{get:()=>t[n],enumerable:!(r=re(t,n))||r.enumerable});return e};var pe=e=>se(N({},"__esModule",{value:!0}),e);var he={};ae(he,{Personalize:()=>Y,PersonalizeEdge:()=>V,Test:()=>J,Track:()=>Z,TrackSlot:()=>ee,UniformContextProvider:()=>Q,isUsingUniformContext:()=>B,onRouteChange:()=>R,provideIsPersonalized:()=>O,provideUniformContext:()=>U,uniformContextInjectionKey:()=>h,useIsPersonalized:()=>z,useQuirks:()=>te,useScores:()=>E,useUniformContext:()=>i});module.exports=pe(he);var g=require("vue-demi");var v=typeof window=="undefined";var C=require("vue-demi");var x=require("vue-demi");var _=require("cookie-es"),h="uniformContextInjectionKey",U=({context:e,outputType:t="standard",trackRouteOnRender:o=!0,vueAppInstance:r})=>{let n={context:e,outputType:t};r?r.provide(h,n):(0,x.provide)(h,n),o&&R(e)};function R(e){v||e==null||e.update({url:new URL(window.location.href),cookies:(0,_.parse)(document.cookie)})}var i=()=>{let e=(0,x.inject)(h);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 B(){var t;return Boolean((t=(0,x.getCurrentInstance)())==null?void 0:t.appContext.provides[h])}var me=(0,C.defineComponent)({name:"TestStandard",inheritAttrs:!1,props:{name:{type:String,required:!0},variations:{type:Array,required:!0},component:{type:[Object,Function],required:!0}},setup(e){let{context:t}=i(),{result:o}=t.test({name:(0,C.toRaw)(e.name),variations:(0,C.toRaw)(e.variations)});return o?()=>(0,C.h)(e.component,{...o}):()=>null}}),F=me;var P=require("vue-demi"),c=require("@uniformdev/context"),ue=(0,P.defineComponent)({name:"TestEdge",inheritAttrs:!1,props:{name:{type:String,required:!0},variations:{type:Array,required:!0},component:{type:[Object,Function],required:!0}},setup(e){let t={name:e.name};return()=>[(0,P.h)(c.EdgeNodeTagName,{"data-type":c.ScriptType.TestStart,innerHTML:JSON.stringify(t)}),e.variations.map(o=>[(0,P.h)(c.EdgeNodeTagName,{"data-type":c.ScriptType.ListItemSettings,key:`LIS-${o.id}`,innerHTML:JSON.stringify({id:o.id})}),(0,P.h)(c.EdgeNodeTagName,{"data-type":c.ScriptType.ListItem,key:`LI-${o.id}`},(0,P.h)(e.component,{...o}))]),(0,P.h)(c.EdgeNodeTagName,{"data-type":c.ScriptType.TestEnd})]}}),M=ue;var de=(0,g.defineComponent)({name:"Test",inheritAttrs:!1,props:{name:{type:String,required:!0},variations:{type:Array,required:!0},component:{type:[Object,Function],required:!0}},setup(e){let{outputType:t}=i();return()=>!v||t==="standard"?(0,g.h)(F,{...e}):(0,g.h)(M,{...e})}}),J=de;var b=require("vue-demi"),K=require("@uniformdev/context");var le=(0,b.defineComponent)({name:"UniformContextProvider",inheritAttrs:!1,props:{context:{type:Object,required:!0},outputType:{type:String,default:"standard"},trackRouteOnRender:{type:Boolean,default:!0}},setup(e,t){return U(e),()=>[(0,b.h)(t.slots.default),ce(e.context)]}}),Q=le;function ce(e){let t=e.getServerToClientTransitionState();return()=>(0,b.h)("script",{id:K.SERVER_STATE_ID,type:"application/json",innerHTML:JSON.stringify(t)})}var q=require("vue-demi");var s=require("vue-demi");var k=require("vue-demi");var $=require("dequal/lite"),E=()=>{let{context:e}=i(),t=(0,k.ref)(e.scores);return(0,k.watchEffect)(()=>{let o=n=>t.value=n,r=e.scores;return(0,$.dequal)(t.value,r)||(t.value=r),e.events.on("scoresUpdated",o),()=>{e.events.off("scoresUpdated",o)}}),t};var I=require("vue-demi");var A=require("vue-demi"),G=Symbol("uniformIsPersonalized"),O=e=>{(0,A.provide)(G,e)},z=()=>(0,A.inject)(G,!1);var fe=(0,I.defineComponent)({name:"PersonalizeProvider",inheritAttrs:!1,props:{personalized:Boolean},setup(e,t){return O(e.personalized),()=>(0,I.h)(t.slots.default,{...e})}}),W=fe;var ye=(0,s.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:t}=i(),o=E(),r=()=>{var m;return t.personalize({name:(0,s.toRaw)(e.name),variations:(0,s.toRaw)(e.variations),take:(m=(0,s.toRaw)(e.count))!=null?m:1})},n=(0,s.ref)(r());return(0,s.watch)([o,()=>e.name,()=>e.variations,()=>e.count],()=>{n.value=r()}),()=>(0,s.h)(W,{personalized:!0},()=>{var m;return(m=n.value)==null?void 0:m.variations.map(u=>{var y;return(0,s.h)(e.component,{key:u.id,personalizationResult:{variation:u,personalizationOccurred:(y=n.value)==null?void 0:y.personalized},...u})})})}}),X=ye;var f=require("@uniformdev/context"),T=require("vue-demi"),Pe=(0,T.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){var o;let t={name:e.name,count:(o=e.count)!=null?o:1};return()=>[(0,T.h)(f.EdgeNodeTagName,{"data-type":f.ScriptType.ListStart,innerHTML:JSON.stringify(t)}),e.variations.map(r=>[(0,T.h)(f.EdgeNodeTagName,{"data-type":f.ScriptType.ListItemSettings,innerHTML:JSON.stringify({id:r.id,pz:r.pz||null}),key:`LIS-${r.id}`}),(0,T.h)(f.EdgeNodeTagName,{"data-type":f.ScriptType.ListItem,key:`LI-${r.id}`},(0,T.h)(e.component,{personalizationResult:{variation:r,personalizationOccurred:!1},...r}))]),(0,T.h)(f.EdgeNodeTagName,{"data-type":f.ScriptType.ListEnd})]}}),V=Pe;var Te=(0,q.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:t}=i();return()=>(0,q.h)(!v||t==="standard"?X:V,{...e})}}),Y=Te;var a=require("vue-demi");var Ce=(0,a.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,t){let o=typeof document=="undefined"?"__uniform_ssr_url":document.location.href,{context:r}=i(),n=z(),m=(0,a.ref)(""),u=(0,a.ref)(!1),y=(0,a.ref)(),d=(0,a.ref)();return(0,a.watchEffect)(()=>{m.value!==o&&(m.value=o,u.value=!1)}),(0,a.watchEffect)(()=>{var D;let L=!e.behavior||Array.isArray(e.behavior)&&!e.behavior.length;if(n||L||!y.value)return;let oe=Array.isArray(e.behavior)?e.behavior:[e.behavior],H=()=>{var l;u.value||(r==null||r.update({enrichments:(0,a.toRaw)(oe)}),u.value=!1,(l=d.value)==null||l.call(d))};if(e.disableVisibilityTrigger)H();else{(D=d.value)==null||D.call(d);let l=new IntersectionObserver(([S])=>{S.isIntersecting&&H()},{threshold:e.threshold});l.observe(y.value),d.value=()=>{var S;return(S=l.disconnect)==null?void 0:S.call(l)}}return()=>{var l;(l=d.value)==null||l.call(d)}}),()=>(0,a.h)(e.tagName,{ref:y,...t.attrs},t.slots.default())}}),Z=Ce;var p=require("vue-demi");var ve=(0,p.defineComponent)({name:"TrackSlot",inheritAttrs:!1,props:{behavior:{type:[Object,Array]}},setup(e,t){let o=typeof document=="undefined"?"__uniform_ssr_url":document.location.href,{context:r}=i(),n=z(),m=(0,p.ref)(),u=(0,p.ref)(!1);return(0,p.watchEffect)(()=>{m.value!==o&&(m.value=o,u.value=!1)}),(0,p.watchEffect)(()=>{let y=!e.behavior||Array.isArray(e.behavior)&&!e.behavior.length;if(n||y)return;(()=>{if(u.value)return;let j=Array.isArray(e.behavior)?e.behavior:[e.behavior];r==null||r.update({enrichments:(0,p.toRaw)(j)}),u.value=!0})()}),()=>(0,p.h)(t.slots.default,{...t.attrs})}}),ee=ve;var w=require("vue-demi");var te=()=>{let{context:e}=i(),t=(0,w.ref)(e.quirks),o=r=>{t.value=r};return(0,w.watch)(e,()=>(e.events.on("quirksUpdated",o),()=>{e.events.off("quirksUpdated",o)})),t};0&&(module.exports={Personalize,PersonalizeEdge,Test,Track,TrackSlot,UniformContextProvider,isUsingUniformContext,onRouteChange,provideIsPersonalized,provideUniformContext,uniformContextInjectionKey,useIsPersonalized,useQuirks,useScores,useUniformContext});
1
+ "use strict";var N=Object.defineProperty;var re=Object.getOwnPropertyDescriptor;var ne=Object.getOwnPropertyNames;var ie=Object.prototype.hasOwnProperty;var ae=(e,t)=>{for(var o in t)N(e,o,{get:t[o],enumerable:!0})},se=(e,t,o,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let n of ne(t))!ie.call(e,n)&&n!==o&&N(e,n,{get:()=>t[n],enumerable:!(r=re(t,n))||r.enumerable});return e};var pe=e=>se(N({},"__esModule",{value:!0}),e);var he={};ae(he,{Personalize:()=>Q,PersonalizeEdge:()=>k,Test:()=>W,Track:()=>X,TrackSlot:()=>Y,UniformContextProvider:()=>ee,isUsingUniformContext:()=>B,onRouteChange:()=>R,provideIsPersonalized:()=>I,provideUniformContext:()=>U,uniformContextInjectionKey:()=>h,useIsPersonalized:()=>z,useQuirks:()=>te,useScores:()=>A,useUniformContext:()=>i});module.exports=pe(he);var q=require("vue-demi");var _=require("cookie-es"),x=require("vue-demi");var v=typeof window=="undefined";var h="uniformContextInjectionKey",U=({context:e,outputType:t="standard",trackRouteOnRender:o=!0,vueAppInstance:r})=>{let n={context:e,outputType:t};r?r.provide(h,n):(0,x.provide)(h,n),o&&R(e)};function R(e){v||e==null||e.update({url:new URL(window.location.href),cookies:(0,_.parse)(document.cookie)})}var i=()=>{let e=(0,x.inject)(h);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 B(){var t;return Boolean((t=(0,x.getCurrentInstance)())==null?void 0:t.appContext.provides[h])}var c=require("@uniformdev/context"),P=require("vue-demi"),me=(0,P.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){var o;let t={name:e.name,count:(o=e.count)!=null?o:1};return()=>[(0,P.h)(c.EdgeNodeTagName,{"data-type":c.ScriptType.ListStart,innerHTML:JSON.stringify(t)}),e.variations.map(r=>[(0,P.h)(c.EdgeNodeTagName,{"data-type":c.ScriptType.ListItemSettings,innerHTML:JSON.stringify({id:r.id,pz:r.pz||null}),key:`LIS-${r.id}`}),(0,P.h)(c.EdgeNodeTagName,{"data-type":c.ScriptType.ListItem,key:`LI-${r.id}`},(0,P.h)(e.component,{personalizationResult:{variation:r,personalizationOccurred:!1},...r}))]),(0,P.h)(c.EdgeNodeTagName,{"data-type":c.ScriptType.ListEnd})]}}),k=me;var s=require("vue-demi");var F=require("dequal/lite"),E=require("vue-demi");var A=()=>{let{context:e}=i(),t=(0,E.ref)(e.scores);return(0,E.watchEffect)(()=>{let o=n=>t.value=n,r=e.scores;return(0,F.dequal)(t.value,r)||(t.value=r),e.events.on("scoresUpdated",o),()=>{e.events.off("scoresUpdated",o)}}),t};var V=require("vue-demi");var O=require("vue-demi"),M=Symbol("uniformIsPersonalized"),I=e=>{(0,O.provide)(M,e)},z=()=>(0,O.inject)(M,!1);var ue=(0,V.defineComponent)({name:"PersonalizeProvider",inheritAttrs:!1,props:{personalized:Boolean},setup(e,t){return I(e.personalized),()=>(0,V.h)(t.slots.default,{...e})}}),J=ue;var de=(0,s.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:t}=i(),o=A(),r=()=>{var m;return t.personalize({name:(0,s.toRaw)(e.name),variations:(0,s.toRaw)(e.variations),take:(m=(0,s.toRaw)(e.count))!=null?m:1})},n=(0,s.ref)(r());return(0,s.watch)([o,()=>e.name,()=>e.variations,()=>e.count],()=>{n.value=r()}),()=>(0,s.h)(J,{personalized:!0},()=>{var m;return(m=n.value)==null?void 0:m.variations.map(u=>{var y;return(0,s.h)(e.component,{key:u.id,personalizationResult:{variation:u,personalizationOccurred:(y=n.value)==null?void 0:y.personalized},...u})})})}}),K=de;var le=(0,q.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:t}=i();return()=>(0,q.h)(!v||t==="standard"?K:k,{...e})}}),Q=le;var g=require("vue-demi");var f=require("@uniformdev/context"),T=require("vue-demi"),ce=(0,T.defineComponent)({name:"TestEdge",inheritAttrs:!1,props:{name:{type:String,required:!0},variations:{type:Array,required:!0},component:{type:[Object,Function],required:!0}},setup(e){let t={name:e.name};return()=>[(0,T.h)(f.EdgeNodeTagName,{"data-type":f.ScriptType.TestStart,innerHTML:JSON.stringify(t)}),e.variations.map(o=>[(0,T.h)(f.EdgeNodeTagName,{"data-type":f.ScriptType.ListItemSettings,key:`LIS-${o.id}`,innerHTML:JSON.stringify({id:o.id})}),(0,T.h)(f.EdgeNodeTagName,{"data-type":f.ScriptType.ListItem,key:`LI-${o.id}`},(0,T.h)(e.component,{...o}))]),(0,T.h)(f.EdgeNodeTagName,{"data-type":f.ScriptType.TestEnd})]}}),$=ce;var C=require("vue-demi");var fe=(0,C.defineComponent)({name:"TestStandard",inheritAttrs:!1,props:{name:{type:String,required:!0},variations:{type:Array,required:!0},component:{type:[Object,Function],required:!0}},setup(e){let{context:t}=i(),{result:o}=t.test({name:(0,C.toRaw)(e.name),variations:(0,C.toRaw)(e.variations)});return o?()=>(0,C.h)(e.component,{...o}):()=>null}}),G=fe;var ye=(0,g.defineComponent)({name:"Test",inheritAttrs:!1,props:{name:{type:String,required:!0},variations:{type:Array,required:!0},component:{type:[Object,Function],required:!0}},setup(e){let{outputType:t}=i();return()=>!v||t==="standard"?(0,g.h)(G,{...e}):(0,g.h)($,{...e})}}),W=ye;var a=require("vue-demi");var Pe=(0,a.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,t){let o=typeof document=="undefined"?"__uniform_ssr_url":document.location.href,{context:r}=i(),n=z(),m=(0,a.ref)(""),u=(0,a.ref)(!1),y=(0,a.ref)(),d=(0,a.ref)();return(0,a.watchEffect)(()=>{m.value!==o&&(m.value=o,u.value=!1)}),(0,a.watchEffect)(()=>{var D;let L=!e.behavior||Array.isArray(e.behavior)&&!e.behavior.length;if(n||L||!y.value)return;let oe=Array.isArray(e.behavior)?e.behavior:[e.behavior],H=()=>{var l;u.value||(r==null||r.update({enrichments:(0,a.toRaw)(oe)}),u.value=!1,(l=d.value)==null||l.call(d))};if(e.disableVisibilityTrigger)H();else{(D=d.value)==null||D.call(d);let l=new IntersectionObserver(([S])=>{S.isIntersecting&&H()},{threshold:e.threshold});l.observe(y.value),d.value=()=>{var S;return(S=l.disconnect)==null?void 0:S.call(l)}}return()=>{var l;(l=d.value)==null||l.call(d)}}),()=>(0,a.h)(e.tagName,{ref:y,...t.attrs},t.slots.default())}}),X=Pe;var p=require("vue-demi");var Te=(0,p.defineComponent)({name:"TrackSlot",inheritAttrs:!1,props:{behavior:{type:[Object,Array]}},setup(e,t){let o=typeof document=="undefined"?"__uniform_ssr_url":document.location.href,{context:r}=i(),n=z(),m=(0,p.ref)(),u=(0,p.ref)(!1);return(0,p.watchEffect)(()=>{m.value!==o&&(m.value=o,u.value=!1)}),(0,p.watchEffect)(()=>{let y=!e.behavior||Array.isArray(e.behavior)&&!e.behavior.length;if(n||y)return;(()=>{if(u.value)return;let j=Array.isArray(e.behavior)?e.behavior:[e.behavior];r==null||r.update({enrichments:(0,p.toRaw)(j)}),u.value=!0})()}),()=>(0,p.h)(t.slots.default,{...t.attrs})}}),Y=Te;var Z=require("@uniformdev/context"),b=require("vue-demi");var Ce=(0,b.defineComponent)({name:"UniformContextProvider",inheritAttrs:!1,props:{context:{type:Object,required:!0},outputType:{type:String,default:"standard"},trackRouteOnRender:{type:Boolean,default:!0}},setup(e,t){return U(e),()=>[(0,b.h)(t.slots.default),ve(e.context)]}}),ee=Ce;function ve(e){let t=e.getServerToClientTransitionState();return()=>(0,b.h)("script",{id:Z.SERVER_STATE_ID,type:"application/json",innerHTML:JSON.stringify(t)})}var w=require("vue-demi");var te=()=>{let{context:e}=i(),t=(0,w.ref)(e.quirks),o=r=>{t.value=r};return(0,w.watch)(e,()=>(e.events.on("quirksUpdated",o),()=>{e.events.off("quirksUpdated",o)})),t};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
- import{defineComponent as te,h as L}from"vue-demi";var d=typeof window=="undefined";import{defineComponent as W,h as X,toRaw as V}from"vue-demi";import{inject as J,provide as K,getCurrentInstance as Q}from"vue-demi";import{parse as $}from"cookie-es";var l="uniformContextInjectionKey",g=({context:e,outputType:t="standard",trackRouteOnRender:o=!0,vueAppInstance:r})=>{let i={context:e,outputType:t};r?r.provide(l,i):K(l,i),o&&I(e)};function I(e){d||e==null||e.update({url:new URL(window.location.href),cookies:$(document.cookie)})}var n=()=>{let e=J(l);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 G(){var t;return Boolean((t=Q())==null?void 0:t.appContext.provides[l])}var Y=W({name:"TestStandard",inheritAttrs:!1,props:{name:{type:String,required:!0},variations:{type:Array,required:!0},component:{type:[Object,Function],required:!0}},setup(e){let{context:t}=n(),{result:o}=t.test({name:V(e.name),variations:V(e.variations)});return o?()=>X(e.component,{...o}):()=>null}}),q=Y;import{defineComponent as Z,h as c}from"vue-demi";import{ScriptType as T,EdgeNodeTagName as C}from"@uniformdev/context";var ee=Z({name:"TestEdge",inheritAttrs:!1,props:{name:{type:String,required:!0},variations:{type:Array,required:!0},component:{type:[Object,Function],required:!0}},setup(e){let t={name:e.name};return()=>[c(C,{"data-type":T.TestStart,innerHTML:JSON.stringify(t)}),e.variations.map(o=>[c(C,{"data-type":T.ListItemSettings,key:`LIS-${o.id}`,innerHTML:JSON.stringify({id:o.id})}),c(C,{"data-type":T.ListItem,key:`LI-${o.id}`},c(e.component,{...o}))]),c(C,{"data-type":T.TestEnd})]}}),w=ee;var oe=te({name:"Test",inheritAttrs:!1,props:{name:{type:String,required:!0},variations:{type:Array,required:!0},component:{type:[Object,Function],required:!0}},setup(e){let{outputType:t}=n();return()=>!d||t==="standard"?L(q,{...e}):L(w,{...e})}}),re=oe;import{defineComponent as ne,h as N}from"vue-demi";import{SERVER_STATE_ID as ie}from"@uniformdev/context";var ae=ne({name:"UniformContextProvider",inheritAttrs:!1,props:{context:{type:Object,required:!0},outputType:{type:String,default:"standard"},trackRouteOnRender:{type:Boolean,default:!0}},setup(e,t){return g(e),()=>[N(t.slots.default),pe(e.context)]}}),se=ae;function pe(e){let t=e.getServerToClientTransitionState();return()=>N("script",{id:ie,type:"application/json",innerHTML:JSON.stringify(t)})}import{defineComponent as ge,h as be}from"vue-demi";import{defineComponent as Te,ref as Ce,watch as ve,h as H,toRaw as U}from"vue-demi";import{ref as me,watchEffect as ue}from"vue-demi";import{dequal as de}from"dequal/lite";var b=()=>{let{context:e}=n(),t=me(e.scores);return ue(()=>{let o=i=>t.value=i,r=e.scores;return de(t.value,r)||(t.value=r),e.events.on("scoresUpdated",o),()=>{e.events.off("scoresUpdated",o)}}),t};import{defineComponent as fe,h as ye}from"vue-demi";import{provide as le,inject as ce}from"vue-demi";var R=Symbol("uniformIsPersonalized"),S=e=>{le(R,e)},f=()=>ce(R,!1);var Pe=fe({name:"PersonalizeProvider",inheritAttrs:!1,props:{personalized:Boolean},setup(e,t){return S(e.personalized),()=>ye(t.slots.default,{...e})}}),j=Pe;var he=Te({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:t}=n(),o=b(),r=()=>{var a;return t.personalize({name:U(e.name),variations:U(e.variations),take:(a=U(e.count))!=null?a:1})},i=Ce(r());return ve([o,()=>e.name,()=>e.variations,()=>e.count],()=>{i.value=r()}),()=>H(j,{personalized:!0},()=>{var a;return(a=i.value)==null?void 0:a.variations.map(s=>{var u;return H(e.component,{key:s.id,personalizationResult:{variation:s,personalizationOccurred:(u=i.value)==null?void 0:u.personalized},...s})})})}}),D=he;import{EdgeNodeTagName as v,ScriptType as h}from"@uniformdev/context";import{defineComponent as xe,h as y}from"vue-demi";var ze=xe({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){var o;let t={name:e.name,count:(o=e.count)!=null?o:1};return()=>[y(v,{"data-type":h.ListStart,innerHTML:JSON.stringify(t)}),e.variations.map(r=>[y(v,{"data-type":h.ListItemSettings,innerHTML:JSON.stringify({id:r.id,pz:r.pz||null}),key:`LIS-${r.id}`}),y(v,{"data-type":h.ListItem,key:`LI-${r.id}`},y(e.component,{personalizationResult:{variation:r,personalizationOccurred:!1},...r}))]),y(v,{"data-type":h.ListEnd})]}}),k=ze;var Se=ge({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:t}=n();return()=>be(!d||t==="standard"?D:k,{...e})}}),Ue=Se;import{defineComponent as ke,watchEffect as _,ref as x,h as Ee,toRaw as Ae}from"vue-demi";var Oe=ke({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,t){let o=typeof document=="undefined"?"__uniform_ssr_url":document.location.href,{context:r}=n(),i=f(),a=x(""),s=x(!1),u=x(),p=x();return _(()=>{a.value!==o&&(a.value=o,s.value=!1)}),_(()=>{var O;let z=!e.behavior||Array.isArray(e.behavior)&&!e.behavior.length;if(i||z||!u.value)return;let M=Array.isArray(e.behavior)?e.behavior:[e.behavior],A=()=>{var m;s.value||(r==null||r.update({enrichments:Ae(M)}),s.value=!1,(m=p.value)==null||m.call(p))};if(e.disableVisibilityTrigger)A();else{(O=p.value)==null||O.call(p);let m=new IntersectionObserver(([P])=>{P.isIntersecting&&A()},{threshold:e.threshold});m.observe(u.value),p.value=()=>{var P;return(P=m.disconnect)==null?void 0:P.call(m)}}return()=>{var m;(m=p.value)==null||m.call(p)}}),()=>Ee(e.tagName,{ref:u,...t.attrs},t.slots.default())}}),Ie=Oe;import{defineComponent as Ve,ref as B,watchEffect as F,h as qe,toRaw as we}from"vue-demi";var Le=Ve({name:"TrackSlot",inheritAttrs:!1,props:{behavior:{type:[Object,Array]}},setup(e,t){let o=typeof document=="undefined"?"__uniform_ssr_url":document.location.href,{context:r}=n(),i=f(),a=B(),s=B(!1);return F(()=>{a.value!==o&&(a.value=o,s.value=!1)}),F(()=>{let u=!e.behavior||Array.isArray(e.behavior)&&!e.behavior.length;if(i||u)return;(()=>{if(s.value)return;let E=Array.isArray(e.behavior)?e.behavior:[e.behavior];r==null||r.update({enrichments:we(E)}),s.value=!0})()}),()=>qe(t.slots.default,{...t.attrs})}}),Ne=Le;import{ref as Re,watch as je}from"vue-demi";var He=()=>{let{context:e}=n(),t=Re(e.quirks),o=r=>{t.value=r};return je(e,()=>(e.events.on("quirksUpdated",o),()=>{e.events.off("quirksUpdated",o)})),t};export{Ue as Personalize,k as PersonalizeEdge,re as Test,Ie as Track,Ne as TrackSlot,se as UniformContextProvider,G as isUsingUniformContext,I as onRouteChange,S as provideIsPersonalized,g as provideUniformContext,l as uniformContextInjectionKey,f as useIsPersonalized,He as useQuirks,b as useScores,n as useUniformContext};
1
+ import{defineComponent as ue,h as de}from"vue-demi";import{parse as J}from"cookie-es";import{getCurrentInstance as K,inject as Q,provide as $}from"vue-demi";var d=typeof window=="undefined";var l="uniformContextInjectionKey",g=({context:e,outputType:t="standard",trackRouteOnRender:o=!0,vueAppInstance:r})=>{let i={context:e,outputType:t};r?r.provide(l,i):$(l,i),o&&I(e)};function I(e){d||e==null||e.update({url:new URL(window.location.href),cookies:J(document.cookie)})}var n=()=>{let e=Q(l);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 G(){var t;return Boolean((t=K())==null?void 0:t.appContext.provides[l])}import{EdgeNodeTagName as T,ScriptType as C}from"@uniformdev/context";import{defineComponent as W,h as c}from"vue-demi";var X=W({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){var o;let t={name:e.name,count:(o=e.count)!=null?o:1};return()=>[c(T,{"data-type":C.ListStart,innerHTML:JSON.stringify(t)}),e.variations.map(r=>[c(T,{"data-type":C.ListItemSettings,innerHTML:JSON.stringify({id:r.id,pz:r.pz||null}),key:`LIS-${r.id}`}),c(T,{"data-type":C.ListItem,key:`LI-${r.id}`},c(e.component,{personalizationResult:{variation:r,personalizationOccurred:!1},...r}))]),c(T,{"data-type":C.ListEnd})]}}),b=X;import{defineComponent as ae,h as w,ref as se,toRaw as k,watch as pe}from"vue-demi";import{dequal as Y}from"dequal/lite";import{ref as Z,watchEffect as ee}from"vue-demi";var S=()=>{let{context:e}=n(),t=Z(e.scores);return ee(()=>{let o=i=>t.value=i,r=e.scores;return Y(t.value,r)||(t.value=r),e.events.on("scoresUpdated",o),()=>{e.events.off("scoresUpdated",o)}}),t};import{defineComponent as re,h as ne}from"vue-demi";import{inject as te,provide as oe}from"vue-demi";var V=Symbol("uniformIsPersonalized"),U=e=>{oe(V,e)},f=()=>te(V,!1);var ie=re({name:"PersonalizeProvider",inheritAttrs:!1,props:{personalized:Boolean},setup(e,t){return U(e.personalized),()=>ne(t.slots.default,{...e})}}),q=ie;var me=ae({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:t}=n(),o=S(),r=()=>{var a;return t.personalize({name:k(e.name),variations:k(e.variations),take:(a=k(e.count))!=null?a:1})},i=se(r());return pe([o,()=>e.name,()=>e.variations,()=>e.count],()=>{i.value=r()}),()=>w(q,{personalized:!0},()=>{var a;return(a=i.value)==null?void 0:a.variations.map(s=>{var u;return w(e.component,{key:s.id,personalizationResult:{variation:s,personalizationOccurred:(u=i.value)==null?void 0:u.personalized},...s})})})}}),L=me;var le=ue({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:t}=n();return()=>de(!d||t==="standard"?L:b,{...e})}}),ce=le;import{defineComponent as ve,h as H}from"vue-demi";import{EdgeNodeTagName as v,ScriptType as h}from"@uniformdev/context";import{defineComponent as fe,h as y}from"vue-demi";var ye=fe({name:"TestEdge",inheritAttrs:!1,props:{name:{type:String,required:!0},variations:{type:Array,required:!0},component:{type:[Object,Function],required:!0}},setup(e){let t={name:e.name};return()=>[y(v,{"data-type":h.TestStart,innerHTML:JSON.stringify(t)}),e.variations.map(o=>[y(v,{"data-type":h.ListItemSettings,key:`LIS-${o.id}`,innerHTML:JSON.stringify({id:o.id})}),y(v,{"data-type":h.ListItem,key:`LI-${o.id}`},y(e.component,{...o}))]),y(v,{"data-type":h.TestEnd})]}}),N=ye;import{defineComponent as Pe,h as Te,toRaw as R}from"vue-demi";var Ce=Pe({name:"TestStandard",inheritAttrs:!1,props:{name:{type:String,required:!0},variations:{type:Array,required:!0},component:{type:[Object,Function],required:!0}},setup(e){let{context:t}=n(),{result:o}=t.test({name:R(e.name),variations:R(e.variations)});return o?()=>Te(e.component,{...o}):()=>null}}),j=Ce;var he=ve({name:"Test",inheritAttrs:!1,props:{name:{type:String,required:!0},variations:{type:Array,required:!0},component:{type:[Object,Function],required:!0}},setup(e){let{outputType:t}=n();return()=>!d||t==="standard"?H(j,{...e}):H(N,{...e})}}),xe=he;import{defineComponent as ze,h as ge,ref as x,toRaw as be,watchEffect as D}from"vue-demi";var Se=ze({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,t){let o=typeof document=="undefined"?"__uniform_ssr_url":document.location.href,{context:r}=n(),i=f(),a=x(""),s=x(!1),u=x(),p=x();return D(()=>{a.value!==o&&(a.value=o,s.value=!1)}),D(()=>{var O;let z=!e.behavior||Array.isArray(e.behavior)&&!e.behavior.length;if(i||z||!u.value)return;let M=Array.isArray(e.behavior)?e.behavior:[e.behavior],A=()=>{var m;s.value||(r==null||r.update({enrichments:be(M)}),s.value=!1,(m=p.value)==null||m.call(p))};if(e.disableVisibilityTrigger)A();else{(O=p.value)==null||O.call(p);let m=new IntersectionObserver(([P])=>{P.isIntersecting&&A()},{threshold:e.threshold});m.observe(u.value),p.value=()=>{var P;return(P=m.disconnect)==null?void 0:P.call(m)}}return()=>{var m;(m=p.value)==null||m.call(p)}}),()=>ge(e.tagName,{ref:u,...t.attrs},t.slots.default())}}),Ue=Se;import{defineComponent as ke,h as Ee,ref as _,toRaw as Ae,watchEffect as B}from"vue-demi";var Oe=ke({name:"TrackSlot",inheritAttrs:!1,props:{behavior:{type:[Object,Array]}},setup(e,t){let o=typeof document=="undefined"?"__uniform_ssr_url":document.location.href,{context:r}=n(),i=f(),a=_(),s=_(!1);return B(()=>{a.value!==o&&(a.value=o,s.value=!1)}),B(()=>{let u=!e.behavior||Array.isArray(e.behavior)&&!e.behavior.length;if(i||u)return;(()=>{if(s.value)return;let E=Array.isArray(e.behavior)?e.behavior:[e.behavior];r==null||r.update({enrichments:Ae(E)}),s.value=!0})()}),()=>Ee(t.slots.default,{...t.attrs})}}),Ie=Oe;import{SERVER_STATE_ID as Ve}from"@uniformdev/context";import{defineComponent as qe,h as F}from"vue-demi";var we=qe({name:"UniformContextProvider",inheritAttrs:!1,props:{context:{type:Object,required:!0},outputType:{type:String,default:"standard"},trackRouteOnRender:{type:Boolean,default:!0}},setup(e,t){return g(e),()=>[F(t.slots.default),Ne(e.context)]}}),Le=we;function Ne(e){let t=e.getServerToClientTransitionState();return()=>F("script",{id:Ve,type:"application/json",innerHTML:JSON.stringify(t)})}import{ref as Re,watch as je}from"vue-demi";var He=()=>{let{context:e}=n(),t=Re(e.quirks),o=r=>{t.value=r};return je(e,()=>(e.events.on("quirksUpdated",o),()=>{e.events.off("quirksUpdated",o)})),t};export{ce as Personalize,b as PersonalizeEdge,xe as Test,Ue as Track,Ie as TrackSlot,Le as UniformContextProvider,G as isUsingUniformContext,I as onRouteChange,U as provideIsPersonalized,g as provideUniformContext,l as uniformContextInjectionKey,f as useIsPersonalized,He as useQuirks,S as useScores,n as useUniformContext};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@uniformdev/context-vue",
3
- "version": "17.5.1-alpha.7+ab97e4ba9",
3
+ "version": "17.6.1-alpha.106+a085c31c8",
4
4
  "description": "Vue SDK for Uniform Context",
5
5
  "license": "SEE LICENSE IN LICENSE.txt",
6
6
  "main": "./dist/index.js",
@@ -22,7 +22,7 @@
22
22
  "format": "prettier --write \"src/**/*.{js,ts,tsx}\""
23
23
  },
24
24
  "dependencies": {
25
- "@uniformdev/context": "^17.5.1-alpha.7+ab97e4ba9",
25
+ "@uniformdev/context": "^17.6.1-alpha.106+a085c31c8",
26
26
  "cookie-es": "^0.5.0",
27
27
  "dequal": "^2.0.2",
28
28
  "uuid": "9.0.0",
@@ -41,10 +41,10 @@
41
41
  "@testing-library/vue": "6.6.1",
42
42
  "@types/uuid": "8.3.4",
43
43
  "@vue/server-test-utils": "1.3.0",
44
- "@vue/test-utils": "2.2.1",
44
+ "@vue/test-utils": "2.2.6",
45
45
  "vue": "3.2.45",
46
- "vue-server-renderer": "2.7.13",
47
- "vue-template-compiler": "2.7.13"
46
+ "vue-server-renderer": "2.7.14",
47
+ "vue-template-compiler": "2.7.14"
48
48
  },
49
49
  "files": [
50
50
  "dist",
@@ -63,5 +63,5 @@
63
63
  "last 2 versions",
64
64
  "not dead"
65
65
  ],
66
- "gitHead": "ab97e4ba97e3842e6c7f208c4c96be3f9f74337e"
66
+ "gitHead": "a085c31c8c2e927cbe2b2332854a199a75198542"
67
67
  }