@uniformdev/context-vue 16.0.1-alpha.128

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/README.md ADDED
@@ -0,0 +1,16 @@
1
+ # Vue 3 + TypeScript + Vite
2
+
3
+ This template should help get you started developing with Vue 3 and TypeScript in Vite. The template uses Vue 3 `<script setup>` SFCs, check out the [script setup docs](https://v3.vuejs.org/api/sfc-script-setup.html#sfc-script-setup) to learn more.
4
+
5
+ ## Recommended IDE Setup
6
+
7
+ - [VS Code](https://code.visualstudio.com/) + [Volar](https://marketplace.visualstudio.com/items?itemName=Vue.volar)
8
+
9
+ ## Type Support For `.vue` Imports in TS
10
+
11
+ Since TypeScript cannot handle type information for `.vue` imports, they are shimmed to be a generic Vue component type by default. In most cases this is fine if you don't really care about component prop types outside of templates. However, if you wish to get actual prop types in `.vue` imports (for example to get props validation when using manual `h(...)` calls), you can enable Volar's Take Over mode by following these steps:
12
+
13
+ 1. Run `Extensions: Show Built-in Extensions` from VS Code's command palette, look for `TypeScript and JavaScript Language Features`, then right click and select `Disable (Workspace)`. By default, Take Over mode will enable itself if the default TypeScript extension is disabled.
14
+ 2. Reload the VS Code window by running `Developer: Reload Window` from the command palette.
15
+
16
+ You can learn more about Take Over mode [here](https://github.com/johnsoncodehk/volar/discussions/471).
@@ -0,0 +1 @@
1
+ "use strict";var q=Object.defineProperty;var A=Object.getOwnPropertySymbols;var k=Object.prototype.hasOwnProperty,V=Object.prototype.propertyIsEnumerable;var L=(n,t,o)=>t in n?q(n,t,{enumerable:!0,configurable:!0,writable:!0,value:o}):n[t]=o,g=(n,t)=>{for(var o in t||(t={}))k.call(t,o)&&L(n,o,t[o]);if(A)for(var o of A(t))V.call(t,o)&&L(n,o,t[o]);return n};var P=(n,t)=>{var o={};for(var i in n)k.call(n,i)&&t.indexOf(i)<0&&(o[i]=n[i]);if(n!=null&&A)for(var i of A(n))t.indexOf(i)<0&&V.call(n,i)&&(o[i]=n[i]);return o};Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});var e=require("vue");const b=typeof window=="undefined",v=Symbol("uniformContextStore"),N=({context:n,outputType:t="standard"})=>{e.provide(v,{context:n,outputType:t})},h=(n,t)=>{const o=e.inject(n,t);if(!o)throw Error(`could not resolve ${n.description}`);return g({},o)},J=e.defineComponent({__name:"TestStandard",props:{name:null,variations:null,loadingMode:null,component:null},setup(n){const{name:t,variations:o,component:i}=n,{context:s}=h(v),{result:f}=s.test({name:t,variations:o});return(r,a)=>e.unref(f)?(e.openBlock(),e.createBlock(e.resolveDynamicComponent(n.component),e.normalizeProps(e.mergeProps({key:0},e.unref(f))),null,16)):e.createCommentVNode("",!0)}});/*! js-cookie v3.0.1 | MIT */function z(n){for(var t=1;t<arguments.length;t++){var o=arguments[t];for(var i in o)n[i]=o[i]}return n}var Q={read:function(n){return n[0]==='"'&&(n=n.slice(1,-1)),n.replace(/(%[\dA-F]{2})+/gi,decodeURIComponent)},write:function(n){return encodeURIComponent(n).replace(/%(2[346BF]|3[AC-F]|40|5[BDE]|60|7[BCD])/g,decodeURIComponent)}};function T(n,t){function o(s,f,r){if(typeof document!="undefined"){r=z({},t,r),typeof r.expires=="number"&&(r.expires=new Date(Date.now()+r.expires*864e5)),r.expires&&(r.expires=r.expires.toUTCString()),s=encodeURIComponent(s).replace(/%(2[346B]|5E|60|7C)/g,decodeURIComponent).replace(/[()]/g,escape);var a="";for(var c in r)!r[c]||(a+="; "+c,r[c]!==!0&&(a+="="+r[c].split(";")[0]));return document.cookie=s+"="+n.write(f,s)+a}}function i(s){if(!(typeof document=="undefined"||arguments.length&&!s)){for(var f=document.cookie?document.cookie.split("; "):[],r={},a=0;a<f.length;a++){var c=f[a].split("="),l=c.slice(1).join("=");try{var u=decodeURIComponent(c[0]);if(r[u]=n.read(l,u),s===u)break}catch{}}return s?r[s]:r}}return Object.create({set:o,get:i,remove:function(s,f){o(s,"",z({},f,{expires:-1}))},withAttributes:function(s){return T(this.converter,z({},this.attributes,s))},withConverter:function(s){return T(z({},this.converter,s),this.attributes)}},{attributes:{value:Object.freeze(t)},converter:{value:Object.freeze(n)}})}T(Q,{path:"/"});var D=G;function _(n){return n instanceof Buffer?Buffer.from(n):new n.constructor(n.buffer.slice(),n.byteOffset,n.length)}function G(n){if(n=n||{},n.circles)return W(n);return n.proto?i:o;function t(s,f){for(var r=Object.keys(s),a=new Array(r.length),c=0;c<r.length;c++){var l=r[c],u=s[l];typeof u!="object"||u===null?a[l]=u:u instanceof Date?a[l]=new Date(u):ArrayBuffer.isView(u)?a[l]=_(u):a[l]=f(u)}return a}function o(s){if(typeof s!="object"||s===null)return s;if(s instanceof Date)return new Date(s);if(Array.isArray(s))return t(s,o);if(s instanceof Map)return new Map(t(Array.from(s),o));if(s instanceof Set)return new Set(t(Array.from(s),o));var f={};for(var r in s)if(Object.hasOwnProperty.call(s,r)!==!1){var a=s[r];typeof a!="object"||a===null?f[r]=a:a instanceof Date?f[r]=new Date(a):a instanceof Map?f[r]=new Map(t(Array.from(a),o)):a instanceof Set?f[r]=new Set(t(Array.from(a),o)):ArrayBuffer.isView(a)?f[r]=_(a):f[r]=o(a)}return f}function i(s){if(typeof s!="object"||s===null)return s;if(s instanceof Date)return new Date(s);if(Array.isArray(s))return t(s,i);if(s instanceof Map)return new Map(t(Array.from(s),i));if(s instanceof Set)return new Set(t(Array.from(s),i));var f={};for(var r in s){var a=s[r];typeof a!="object"||a===null?f[r]=a:a instanceof Date?f[r]=new Date(a):a instanceof Map?f[r]=new Map(t(Array.from(a),i)):a instanceof Set?f[r]=new Set(t(Array.from(a),i)):ArrayBuffer.isView(a)?f[r]=_(a):f[r]=i(a)}return f}}function W(n){var t=[],o=[];return n.proto?f:s;function i(r,a){for(var c=Object.keys(r),l=new Array(c.length),u=0;u<c.length;u++){var d=c[u],p=r[d];if(typeof p!="object"||p===null)l[d]=p;else if(p instanceof Date)l[d]=new Date(p);else if(ArrayBuffer.isView(p))l[d]=_(p);else{var C=t.indexOf(p);C!==-1?l[d]=o[C]:l[d]=a(p)}}return l}function s(r){if(typeof r!="object"||r===null)return r;if(r instanceof Date)return new Date(r);if(Array.isArray(r))return i(r,s);if(r instanceof Map)return new Map(i(Array.from(r),s));if(r instanceof Set)return new Set(i(Array.from(r),s));var a={};t.push(r),o.push(a);for(var c in r)if(Object.hasOwnProperty.call(r,c)!==!1){var l=r[c];if(typeof l!="object"||l===null)a[c]=l;else if(l instanceof Date)a[c]=new Date(l);else if(l instanceof Map)a[c]=new Map(i(Array.from(l),s));else if(l instanceof Set)a[c]=new Set(i(Array.from(l),s));else if(ArrayBuffer.isView(l))a[c]=_(l);else{var u=t.indexOf(l);u!==-1?a[c]=o[u]:a[c]=s(l)}}return t.pop(),o.pop(),a}function f(r){if(typeof r!="object"||r===null)return r;if(r instanceof Date)return new Date(r);if(Array.isArray(r))return i(r,f);if(r instanceof Map)return new Map(i(Array.from(r),f));if(r instanceof Set)return new Set(i(Array.from(r),f));var a={};t.push(r),o.push(a);for(var c in r){var l=r[c];if(typeof l!="object"||l===null)a[c]=l;else if(l instanceof Date)a[c]=new Date(l);else if(l instanceof Map)a[c]=new Map(i(Array.from(l),f));else if(l instanceof Set)a[c]=new Set(i(Array.from(l),f));else if(ArrayBuffer.isView(l))a[c]=_(l);else{var u=t.indexOf(l);u!==-1?a[c]=o[u]:a[c]=f(l)}}return t.pop(),o.pop(),a}}var U="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",X=new Array(123);for(let n=0;n<U.length;n++)X[U.charCodeAt(n)]=n;D();D();D();var y=(n=>(n.ListStart="nesi-list-start",n.ListEnd="nesi-list-end",n.ListItem="nesi-list-item-html",n.ListItemSettings="nesi-list-item-settings",n.TestStart="nesi-test-start",n.TestEnd="nesi-test-end",n.Unknown="unknown",n))(y||{}),Y="nesitag";const w=n=>e.h(Y,n),Z=e.defineComponent({__name:"TestEdge",props:{name:null,variations:null,loadingMode:null,component:null},setup(n){const{name:t,variations:o,component:i}=n,s={name:t};return(f,r)=>(e.openBlock(),e.createElementBlock(e.Fragment,null,[e.createVNode(e.unref(w),{"data-type":e.unref(y).TestStart,innerHTML:JSON.stringify(s)},null,8,["data-type","innerHTML"]),(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(n.variations,(a,c)=>(e.openBlock(),e.createElementBlock(e.Fragment,{key:c},[e.createVNode(e.unref(w),{"data-type":e.unref(y).ListItemSettings,innerHTML:JSON.stringify({id:a.id})},null,8,["data-type","innerHTML"]),e.createVNode(e.unref(w),{"data-type":e.unref(y).ListItem},{default:e.withCtx(()=>[(e.openBlock(),e.createBlock(e.resolveDynamicComponent(f.renderComponent),e.normalizeProps(e.guardReactiveProps(a)),null,16))]),_:2},1032,["data-type"])],64))),128)),e.createVNode(e.unref(w),{"data-type":e.unref(y).TestEnd},null,8,["data-type"])],64))}}),K=e.defineComponent({__name:"Test",props:{name:null,variations:null,loadingMode:null,component:null},setup(n){const t=n,{outputType:o}=h(v),i=e.computed(()=>!b||o==="standard"?J:Z);return(s,f)=>(e.openBlock(),e.createBlock(e.resolveDynamicComponent(e.unref(i)),e.normalizeProps(e.guardReactiveProps(t)),null,16))}}),ee=e.defineComponent({__name:"UniformContextProvider",props:{context:null},setup(n){return N(g({},n)),(o,i)=>e.renderSlot(o.$slots,"default")}});var I=Object.prototype.hasOwnProperty;function x(n,t){var o,i;if(n===t)return!0;if(n&&t&&(o=n.constructor)===t.constructor){if(o===Date)return n.getTime()===t.getTime();if(o===RegExp)return n.toString()===t.toString();if(o===Array){if((i=n.length)===t.length)for(;i--&&x(n[i],t[i]););return i===-1}if(!o||typeof n=="object"){i=0;for(o in n)if(I.call(n,o)&&++i&&!I.call(t,o)||!(o in t)||!x(n[o],t[o]))return!1;return Object.keys(t).length===i}}return n!==n&&t!==t}const R=()=>{const{context:n}=h(v),t=e.ref(n.scores);return e.watchEffect(()=>{const o=s=>t.value=s,i=n.scores;return x(t,i)||(t.value=i),n.events.on("scoresUpdated",o),()=>{n.events.off("scoresUpdated",o)}}),t},M=Symbol("uniformIsPersonalizedStore"),$=({personalized:n=!1})=>{e.provide(M,{personalized:n})},E=(n,t)=>{const o=e.inject(n,t);return o?g({},o):{personalized:!1}},ne=e.defineComponent({__name:"PersonalizeProvider",props:{personalized:{type:Boolean}},setup(n){const{personalized:t}=n;return $({personalized:t}),(o,i)=>e.renderSlot(o.$slots,"default",e.normalizeProps(e.guardReactiveProps({personalized:n.personalized})))}}),te=e.defineComponent({__name:"PersonalizeStandard",props:{name:null,variations:null,component:null,count:null},setup(n){const{name:t,component:o,variations:i,count:s=1}=n,{context:f}=h(v),r=R(),a=e.computed(()=>{if(r.value,o){const{variations:c,personalized:l}=f.personalize({name:t,variations:i,take:s});return{personalizedVariations:c,personalizationOccurred:l}}});return(c,l)=>(e.openBlock(),e.createBlock(ne,{personalized:!0},{default:e.withCtx(()=>{var u;return[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList((u=e.unref(a))==null?void 0:u.personalizedVariations,d=>{var p;return e.openBlock(),e.createBlock(e.resolveDynamicComponent(n.component),e.normalizeProps(e.mergeProps({key:d.id},g({personalizationResult:{variation:d,personalizationOccurred:(p=e.unref(a))==null?void 0:p.personalizationOccurred}},d))),null,16)}),128))]}),_:1}))}}),re=e.defineComponent({__name:"PersonalizeEdge",props:{name:null,variations:null,component:null,count:null},setup(n){const{component:t,variations:o,count:i}=n,s=i!=null?i:1;return(f,r)=>{const a=e.resolveComponent("component");return e.openBlock(),e.createElementBlock(e.Fragment,null,[e.createVNode(e.unref(w),{"data-type":e.unref(y).ListStart,innerHTML:JSON.stringify(e.unref(s))},null,8,["data-type","innerHTML"]),(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(n.variations,c=>(e.openBlock(),e.createElementBlock(e.Fragment,{key:c.id},[e.createVNode(e.unref(w),{"data-type":e.unref(y).ListItemSettings,innerHTML:JSON.stringify({id:c.id,pz:c.pz||null})},null,8,["data-type","innerHTML"]),e.createVNode(e.unref(w),{"data-type":e.unref(y).ListItem},{default:e.withCtx(()=>[(e.openBlock(),e.createBlock(a,{key:c.id,personalizationResult:{variant:c,personalizationOccurred:!1}},null,8,["personalizationResult"]))]),_:2},1032,["data-type"])],64))),128)),e.createVNode(e.unref(w),{"data-type":e.unref(y).ListEnd},null,8,["data-type"])],64)}}}),oe=e.defineComponent({__name:"Personalize",props:{name:null,variations:null,component:null,count:null},setup(n){const t=n,{outputType:o}=h(v),i=e.computed(()=>!b||o==="standard"?te:re);return(s,f)=>(e.openBlock(),e.createBlock(e.resolveDynamicComponent(e.unref(i)),e.normalizeProps(e.guardReactiveProps(g({},t))),null,16))}}),ae=e.defineComponent({__name:"Track",props:{behavior:null,tagName:{default:"div"},disableVisibilityTrigger:{type:Boolean},threshold:{default:.5}},setup(n){const C=n,{behavior:t,tagName:o,threshold:i,disableVisibilityTrigger:s=typeof window=="undefined"||!("IntersectionObserver"in window)}=C,f=P(C,["behavior","tagName","threshold","disableVisibilityTrigger"]),r=typeof document=="undefined"?"__uniform_ssr_url":document.location.href,{context:a}=h(v),{personalized:c}=E(M),l=e.ref(""),u=e.ref(!1),d=e.ref(),p=e.ref();return e.watchEffect(()=>{l.value!==r&&(l.value=r,u.value=!1)}),e.watchEffect(()=>{var j;const S=!t||Array.isArray(t)&&!t.length;if(c||S||!d.value)return;const F=Array.isArray(t)?t:[t],O=()=>{var m;u.value||(a.update({enrichments:F}),u.value=!1,(m=p.value)==null||m.call(p))};if(s)O();else{(j=p.value)==null||j.call(p);const m=new IntersectionObserver(([B])=>{B.isIntersecting&&O()},{threshold:i});m.observe(d.value),p.value=()=>{var B;return(B=m.disconnect)==null?void 0:B.call(m)}}return()=>{var m;(m=p.value)==null||m.call(p)}}),(S,H)=>(e.openBlock(),e.createBlock(e.resolveDynamicComponent(o),e.mergeProps(g({},f),{ref_key:"wrapperEl",ref:d}),{default:e.withCtx(()=>[e.renderSlot(S.$slots,"default")]),_:3},16))}}),se=e.defineComponent({__name:"TrackSlot",props:{behavior:null},setup(n){const c=n,{behavior:t}=c,o=P(c,["behavior"]),i=typeof document=="undefined"?"__uniform_ssr_url":document.location.href,{context:s}=h(v),{personalized:f}=E(M),r=e.ref(""),a=e.ref(!1);return e.watchEffect(()=>{r.value!==i&&(r.value=i,a.value=!1)}),e.watchEffect(()=>{const l=!t||Array.isArray(t)&&!t.length;if(f||l)return;(()=>{if(a.value)return;const p=Array.isArray(t)?t:[t];s.update({enrichments:p}),a.value=!0})()}),(l,u)=>e.renderSlot(l.$slots,"default",e.normalizeProps(e.guardReactiveProps(g({},l.rest))))}}),ie=()=>{const{context:n}=h(v),t=e.ref(n.quirks),o=i=>{t.value=i};return e.watch(n,()=>(n.events.on("quirksUpdated",o),()=>{n.events.off("quirksUpdated",o)})),t};exports.Personalize=oe;exports.Test=K;exports.Track=ae;exports.TrackSlot=se;exports.UniformContextProvider=ee;exports.initPersonalizeStore=$;exports.initStore=N;exports.uniformContextStoreProps=v;exports.useIsPersonalized=E;exports.useQuirks=ie;exports.useScores=R;exports.useUniformContext=h;
@@ -0,0 +1,265 @@
1
+ import type { a0 } from '@uniformdev/context/dist/types-876fb8b8';
2
+ import type { AllowedComponentProps } from 'vue';
3
+ import { Component } from 'vue';
4
+ import type { ComponentCustomProps } from 'vue';
5
+ import type { ComponentOptionsMixin } from 'vue';
6
+ import type { ComputedOptions } from 'vue';
7
+ import type { ComputedRef } from 'vue';
8
+ import { Context } from '@uniformdev/context';
9
+ import type { d } from '@uniformdev/context/dist/types-876fb8b8';
10
+ import type { DefineComponent } from 'vue';
11
+ import { EdgeTestComponentOptions } from '@uniformdev/context';
12
+ import type { ExtractPropTypes } from 'vue';
13
+ import { InjectionKey } from 'vue';
14
+ import type { MethodOptions } from 'vue';
15
+ import type { PersonalizedVariant } from '@uniformdev/context';
16
+ import { Quirks } from '@uniformdev/context';
17
+ import type { Ref } from 'vue';
18
+ import type { RendererElement } from 'vue';
19
+ import type { RendererNode } from 'vue';
20
+ import { ScoreVector } from '@uniformdev/context';
21
+ import type { ScriptType } from '@uniformdev/context';
22
+ import { TestVariant } from '@uniformdev/context';
23
+ import type { VNode } from 'vue';
24
+ import type { VNodeProps } from 'vue';
25
+
26
+ export declare type EdgeTestListComponentOptions<TVariation extends TestVariant> = {
27
+ components?: Component<TVariation>[];
28
+ variations: TVariation[];
29
+ options: EdgeTestComponentOptions;
30
+ };
31
+
32
+ export declare const initPersonalizeStore: ({ personalized }: PersonalizationContextProps) => void;
33
+
34
+ export declare const initStore: ({ context, outputType }: UniformContextProps) => void;
35
+
36
+ export declare type PersonalizationContextProps = {
37
+ personalized?: boolean;
38
+ };
39
+
40
+ export declare const Personalize: DefineComponent<{
41
+ name: {
42
+ type: StringConstructor;
43
+ required: true;
44
+ };
45
+ variations: {
46
+ type: ArrayConstructor;
47
+ required: true;
48
+ };
49
+ component: {
50
+ type: null;
51
+ required: true;
52
+ };
53
+ count: {
54
+ type: NumberConstructor;
55
+ required: false;
56
+ };
57
+ }, {
58
+ outputType: VariantOutputType;
59
+ props: {
60
+ /**
61
+ * Name of the personalized placement. Should be unique to this placement location and set of variants.
62
+ * This name is emitted to analytics after personalization executes.
63
+ */
64
+ name: string;
65
+ /** The possible variations of the content to render depending on personalization conditions */
66
+ variations: PersonalizedVariant[];
67
+ /** A Vue component to use to render a selected variant. */
68
+ component: PersonalizedVariationComponent<PersonalizedVariant>;
69
+ /** A React component that will be used to wrap all personalized variants. If no variants match, the wrapper is not rendered. */
70
+ /** The number of variations to select. Use for personalized lists where the `count` most relevant should be shown. */
71
+ count?: number | undefined;
72
+ };
73
+ personalizeComponent: ComputedRef<DefineComponent<{
74
+ name: {
75
+ type: StringConstructor;
76
+ required: true;
77
+ };
78
+ variations: {
79
+ type: ArrayConstructor;
80
+ required: true;
81
+ };
82
+ component: {
83
+ type: null;
84
+ required: true;
85
+ };
86
+ count: {
87
+ type: NumberConstructor;
88
+ required: false; /** The number of variations to select. Use for personalized lists where the `count` most relevant should be shown. */
89
+ };
90
+ }, {
91
+ context: a0;
92
+ scores: Ref<d>;
93
+ personalized: ComputedRef<{
94
+ personalizedVariations: PersonalizedVariant[];
95
+ personalizationOccurred: boolean;
96
+ } | undefined>;
97
+ PersonalizeProvider: DefineComponent<{
98
+ personalized: {
99
+ type: BooleanConstructor;
100
+ required: false;
101
+ };
102
+ }, {}, unknown, {}, {}, ComponentOptionsMixin, ComponentOptionsMixin, Record<string, any>, string, VNodeProps & AllowedComponentProps & ComponentCustomProps, Readonly<ExtractPropTypes<{
103
+ personalized: {
104
+ type: BooleanConstructor;
105
+ required: false;
106
+ };
107
+ }>>, {
108
+ personalized: boolean;
109
+ }>;
110
+ }, unknown, {}, {}, ComponentOptionsMixin, ComponentOptionsMixin, Record<string, any>, string, VNodeProps & AllowedComponentProps & ComponentCustomProps, Readonly<ExtractPropTypes<{
111
+ name: {
112
+ type: StringConstructor;
113
+ required: true;
114
+ };
115
+ variations: {
116
+ type: ArrayConstructor;
117
+ required: true;
118
+ };
119
+ component: {
120
+ type: null;
121
+ required: true;
122
+ };
123
+ count: {
124
+ type: NumberConstructor;
125
+ required: false; /** The number of variations to select. Use for personalized lists where the `count` most relevant should be shown. */
126
+ };
127
+ }>>, {}> | DefineComponent<{
128
+ name: {
129
+ type: StringConstructor;
130
+ required: true; /** The number of variations to select. Use for personalized lists where the `count` most relevant should be shown. */
131
+ }; /** The number of variations to select. Use for personalized lists where the `count` most relevant should be shown. */
132
+ variations: {
133
+ type: ArrayConstructor;
134
+ required: true;
135
+ };
136
+ component: {
137
+ type: null;
138
+ required: true;
139
+ };
140
+ count: {
141
+ type: NumberConstructor;
142
+ required: false;
143
+ };
144
+ }, {
145
+ options: number;
146
+ ScriptType: typeof ScriptType;
147
+ /** The number of variations to select. Use for personalized lists where the `count` most relevant should be shown. */
148
+ EdgeTag: (props: Record<string, unknown>) => VNode<RendererNode, RendererElement, {
149
+ [key: string]: any;
150
+ }>;
151
+ }, unknown, {}, {}, ComponentOptionsMixin, ComponentOptionsMixin, Record<string, any>, string, VNodeProps & AllowedComponentProps & ComponentCustomProps, Readonly<ExtractPropTypes<{
152
+ name: {
153
+ type: StringConstructor;
154
+ required: true; /** The number of variations to select. Use for personalized lists where the `count` most relevant should be shown. */
155
+ }; /** The number of variations to select. Use for personalized lists where the `count` most relevant should be shown. */
156
+ variations: {
157
+ type: ArrayConstructor;
158
+ required: true;
159
+ };
160
+ component: {
161
+ type: null;
162
+ required: true;
163
+ };
164
+ count: {
165
+ type: NumberConstructor;
166
+ required: false;
167
+ };
168
+ }>>, {}>>;
169
+ }, unknown, {}, {}, ComponentOptionsMixin, ComponentOptionsMixin, Record<string, any>, string, VNodeProps & AllowedComponentProps & ComponentCustomProps, Readonly<ExtractPropTypes<{
170
+ name: {
171
+ type: StringConstructor;
172
+ required: true;
173
+ };
174
+ variations: {
175
+ type: ArrayConstructor;
176
+ required: true;
177
+ };
178
+ component: {
179
+ type: null;
180
+ required: true;
181
+ };
182
+ count: {
183
+ type: NumberConstructor;
184
+ required: false;
185
+ };
186
+ }>>, {}>;
187
+
188
+ declare type PersonalizedVariationComponent<TVariation> = Component<TVariation & {
189
+ personalizationResult: {
190
+ variation: PersonalizedVariant;
191
+ personalizationOccurred: boolean;
192
+ };
193
+ }>;
194
+
195
+ export declare const Test: DefineComponent<unknown, object, {}, ComputedOptions, MethodOptions, ComponentOptionsMixin, ComponentOptionsMixin, {}, string, VNodeProps & AllowedComponentProps & ComponentCustomProps, Readonly<unknown>, {}>;
196
+
197
+ export declare interface TestComponentProps {
198
+ /** Name of the test that is running. */
199
+ name: string;
200
+ /** Variation list that this test will selected from. */
201
+ variations: TestVariant[];
202
+ /**
203
+ * Determines what should be rendered if testing is in a "loading" state.
204
+ * default: shows the default variation while loading
205
+ * none: shows nothing while loading
206
+ * Vue component: shows the component while loading
207
+ */
208
+ loadingMode?: 'default' | 'none' | Component;
209
+ /** A Vue component to use to render the test variant. */
210
+ component?: Component<TestVariant>;
211
+ }
212
+
213
+ export declare type TestEdgeComponentProps = Omit<TestComponentProps, 'selectedVariantId'>;
214
+
215
+ export declare const Track: DefineComponent<unknown, object, {}, ComputedOptions, MethodOptions, ComponentOptionsMixin, ComponentOptionsMixin, {}, string, VNodeProps & AllowedComponentProps & ComponentCustomProps, Readonly<unknown>, {}>;
216
+
217
+ export declare const TrackSlot: DefineComponent<unknown, object, {}, ComputedOptions, MethodOptions, ComponentOptionsMixin, ComponentOptionsMixin, {}, string, VNodeProps & AllowedComponentProps & ComponentCustomProps, Readonly<unknown>, {}>;
218
+
219
+ export declare type UniformContextProps = {
220
+ context: Context;
221
+ outputType?: VariantOutputType;
222
+ };
223
+
224
+ export declare const UniformContextProvider: DefineComponent<{
225
+ context: {
226
+ type: null;
227
+ required: true;
228
+ };
229
+ }, {
230
+ props: {
231
+ context: Context;
232
+ };
233
+ }, unknown, {}, {}, ComponentOptionsMixin, ComponentOptionsMixin, Record<string, any>, string, VNodeProps & AllowedComponentProps & ComponentCustomProps, Readonly<ExtractPropTypes<{
234
+ context: {
235
+ type: null;
236
+ required: true;
237
+ };
238
+ }>>, {}>;
239
+
240
+ export declare const uniformContextStoreProps: InjectionKey<UniformContextProps>;
241
+
242
+ export declare const useIsPersonalized: (key: InjectionKey<PersonalizationContextProps>, fallback?: PersonalizationContextProps | undefined) => {
243
+ personalized?: boolean | undefined;
244
+ };
245
+
246
+ /**
247
+ * Provides reactive access to the Uniform Context's current visitor quirks values
248
+ * This can be used when you want to read current quirk values directly.
249
+ */
250
+ export declare const useQuirks: () => Ref<Quirks>;
251
+
252
+ /**
253
+ * Provides reactive access to the Uniform Context's current visitor scores values.
254
+ * This can be used when you want to read current score values directly.
255
+ */
256
+ export declare const useScores: () => Ref<ScoreVector>;
257
+
258
+ export declare const useUniformContext: (key: InjectionKey<UniformContextProps>, fallback?: UniformContextProps | undefined) => {
259
+ context: Context;
260
+ outputType?: VariantOutputType;
261
+ };
262
+
263
+ export declare type VariantOutputType = 'edge' | 'standard' | undefined;
264
+
265
+ export { }
@@ -0,0 +1,770 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __getOwnPropSymbols = Object.getOwnPropertySymbols;
3
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
4
+ var __propIsEnum = Object.prototype.propertyIsEnumerable;
5
+ var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
6
+ var __spreadValues = (a, b) => {
7
+ for (var prop in b || (b = {}))
8
+ if (__hasOwnProp.call(b, prop))
9
+ __defNormalProp(a, prop, b[prop]);
10
+ if (__getOwnPropSymbols)
11
+ for (var prop of __getOwnPropSymbols(b)) {
12
+ if (__propIsEnum.call(b, prop))
13
+ __defNormalProp(a, prop, b[prop]);
14
+ }
15
+ return a;
16
+ };
17
+ var __objRest = (source, exclude) => {
18
+ var target = {};
19
+ for (var prop in source)
20
+ if (__hasOwnProp.call(source, prop) && exclude.indexOf(prop) < 0)
21
+ target[prop] = source[prop];
22
+ if (source != null && __getOwnPropSymbols)
23
+ for (var prop of __getOwnPropSymbols(source)) {
24
+ if (exclude.indexOf(prop) < 0 && __propIsEnum.call(source, prop))
25
+ target[prop] = source[prop];
26
+ }
27
+ return target;
28
+ };
29
+ import { provide, inject, defineComponent, unref, openBlock, createBlock, resolveDynamicComponent, normalizeProps, mergeProps, createCommentVNode, h, createElementBlock, Fragment, createVNode, renderList, withCtx, guardReactiveProps, computed, renderSlot, ref, watchEffect, resolveComponent, watch } from "vue";
30
+ const isServer = typeof window === "undefined";
31
+ const uniformContextStoreProps = Symbol("uniformContextStore");
32
+ const initStore = ({ context, outputType = "standard" }) => {
33
+ provide(uniformContextStoreProps, {
34
+ context,
35
+ outputType
36
+ });
37
+ };
38
+ const useUniformContext = (key, fallback) => {
39
+ const resolved = inject(key, fallback);
40
+ if (!resolved) {
41
+ throw Error(`could not resolve ${key.description}`);
42
+ }
43
+ const value = resolved;
44
+ return __spreadValues({}, value);
45
+ };
46
+ const _sfc_main$9 = /* @__PURE__ */ defineComponent({
47
+ __name: "TestStandard",
48
+ props: {
49
+ name: null,
50
+ variations: null,
51
+ loadingMode: null,
52
+ component: null
53
+ },
54
+ setup(__props) {
55
+ const { name, variations, component } = __props;
56
+ const { context } = useUniformContext(uniformContextStoreProps);
57
+ const { result } = context.test({
58
+ name,
59
+ variations
60
+ });
61
+ return (_ctx, _cache) => {
62
+ return unref(result) ? (openBlock(), createBlock(resolveDynamicComponent(__props.component), normalizeProps(mergeProps({ key: 0 }, unref(result))), null, 16)) : createCommentVNode("", true);
63
+ };
64
+ }
65
+ });
66
+ /*! js-cookie v3.0.1 | MIT */
67
+ function assign(target) {
68
+ for (var i = 1; i < arguments.length; i++) {
69
+ var source = arguments[i];
70
+ for (var key in source) {
71
+ target[key] = source[key];
72
+ }
73
+ }
74
+ return target;
75
+ }
76
+ var defaultConverter = {
77
+ read: function(value) {
78
+ if (value[0] === '"') {
79
+ value = value.slice(1, -1);
80
+ }
81
+ return value.replace(/(%[\dA-F]{2})+/gi, decodeURIComponent);
82
+ },
83
+ write: function(value) {
84
+ return encodeURIComponent(value).replace(/%(2[346BF]|3[AC-F]|40|5[BDE]|60|7[BCD])/g, decodeURIComponent);
85
+ }
86
+ };
87
+ function init(converter, defaultAttributes) {
88
+ function set(key, value, attributes) {
89
+ if (typeof document === "undefined") {
90
+ return;
91
+ }
92
+ attributes = assign({}, defaultAttributes, attributes);
93
+ if (typeof attributes.expires === "number") {
94
+ attributes.expires = new Date(Date.now() + attributes.expires * 864e5);
95
+ }
96
+ if (attributes.expires) {
97
+ attributes.expires = attributes.expires.toUTCString();
98
+ }
99
+ key = encodeURIComponent(key).replace(/%(2[346B]|5E|60|7C)/g, decodeURIComponent).replace(/[()]/g, escape);
100
+ var stringifiedAttributes = "";
101
+ for (var attributeName in attributes) {
102
+ if (!attributes[attributeName]) {
103
+ continue;
104
+ }
105
+ stringifiedAttributes += "; " + attributeName;
106
+ if (attributes[attributeName] === true) {
107
+ continue;
108
+ }
109
+ stringifiedAttributes += "=" + attributes[attributeName].split(";")[0];
110
+ }
111
+ return document.cookie = key + "=" + converter.write(value, key) + stringifiedAttributes;
112
+ }
113
+ function get(key) {
114
+ if (typeof document === "undefined" || arguments.length && !key) {
115
+ return;
116
+ }
117
+ var cookies = document.cookie ? document.cookie.split("; ") : [];
118
+ var jar = {};
119
+ for (var i = 0; i < cookies.length; i++) {
120
+ var parts = cookies[i].split("=");
121
+ var value = parts.slice(1).join("=");
122
+ try {
123
+ var foundKey = decodeURIComponent(parts[0]);
124
+ jar[foundKey] = converter.read(value, foundKey);
125
+ if (key === foundKey) {
126
+ break;
127
+ }
128
+ } catch (e) {
129
+ }
130
+ }
131
+ return key ? jar[key] : jar;
132
+ }
133
+ return Object.create({
134
+ set,
135
+ get,
136
+ remove: function(key, attributes) {
137
+ set(key, "", assign({}, attributes, {
138
+ expires: -1
139
+ }));
140
+ },
141
+ withAttributes: function(attributes) {
142
+ return init(this.converter, assign({}, this.attributes, attributes));
143
+ },
144
+ withConverter: function(converter2) {
145
+ return init(assign({}, this.converter, converter2), this.attributes);
146
+ }
147
+ }, {
148
+ attributes: { value: Object.freeze(defaultAttributes) },
149
+ converter: { value: Object.freeze(converter) }
150
+ });
151
+ }
152
+ init(defaultConverter, { path: "/" });
153
+ var rfdc_1 = rfdc;
154
+ function copyBuffer(cur) {
155
+ if (cur instanceof Buffer) {
156
+ return Buffer.from(cur);
157
+ }
158
+ return new cur.constructor(cur.buffer.slice(), cur.byteOffset, cur.length);
159
+ }
160
+ function rfdc(opts) {
161
+ opts = opts || {};
162
+ if (opts.circles)
163
+ return rfdcCircles(opts);
164
+ return opts.proto ? cloneProto : clone;
165
+ function cloneArray(a, fn) {
166
+ var keys = Object.keys(a);
167
+ var a2 = new Array(keys.length);
168
+ for (var i = 0; i < keys.length; i++) {
169
+ var k = keys[i];
170
+ var cur = a[k];
171
+ if (typeof cur !== "object" || cur === null) {
172
+ a2[k] = cur;
173
+ } else if (cur instanceof Date) {
174
+ a2[k] = new Date(cur);
175
+ } else if (ArrayBuffer.isView(cur)) {
176
+ a2[k] = copyBuffer(cur);
177
+ } else {
178
+ a2[k] = fn(cur);
179
+ }
180
+ }
181
+ return a2;
182
+ }
183
+ function clone(o) {
184
+ if (typeof o !== "object" || o === null)
185
+ return o;
186
+ if (o instanceof Date)
187
+ return new Date(o);
188
+ if (Array.isArray(o))
189
+ return cloneArray(o, clone);
190
+ if (o instanceof Map)
191
+ return new Map(cloneArray(Array.from(o), clone));
192
+ if (o instanceof Set)
193
+ return new Set(cloneArray(Array.from(o), clone));
194
+ var o2 = {};
195
+ for (var k in o) {
196
+ if (Object.hasOwnProperty.call(o, k) === false)
197
+ continue;
198
+ var cur = o[k];
199
+ if (typeof cur !== "object" || cur === null) {
200
+ o2[k] = cur;
201
+ } else if (cur instanceof Date) {
202
+ o2[k] = new Date(cur);
203
+ } else if (cur instanceof Map) {
204
+ o2[k] = new Map(cloneArray(Array.from(cur), clone));
205
+ } else if (cur instanceof Set) {
206
+ o2[k] = new Set(cloneArray(Array.from(cur), clone));
207
+ } else if (ArrayBuffer.isView(cur)) {
208
+ o2[k] = copyBuffer(cur);
209
+ } else {
210
+ o2[k] = clone(cur);
211
+ }
212
+ }
213
+ return o2;
214
+ }
215
+ function cloneProto(o) {
216
+ if (typeof o !== "object" || o === null)
217
+ return o;
218
+ if (o instanceof Date)
219
+ return new Date(o);
220
+ if (Array.isArray(o))
221
+ return cloneArray(o, cloneProto);
222
+ if (o instanceof Map)
223
+ return new Map(cloneArray(Array.from(o), cloneProto));
224
+ if (o instanceof Set)
225
+ return new Set(cloneArray(Array.from(o), cloneProto));
226
+ var o2 = {};
227
+ for (var k in o) {
228
+ var cur = o[k];
229
+ if (typeof cur !== "object" || cur === null) {
230
+ o2[k] = cur;
231
+ } else if (cur instanceof Date) {
232
+ o2[k] = new Date(cur);
233
+ } else if (cur instanceof Map) {
234
+ o2[k] = new Map(cloneArray(Array.from(cur), cloneProto));
235
+ } else if (cur instanceof Set) {
236
+ o2[k] = new Set(cloneArray(Array.from(cur), cloneProto));
237
+ } else if (ArrayBuffer.isView(cur)) {
238
+ o2[k] = copyBuffer(cur);
239
+ } else {
240
+ o2[k] = cloneProto(cur);
241
+ }
242
+ }
243
+ return o2;
244
+ }
245
+ }
246
+ function rfdcCircles(opts) {
247
+ var refs = [];
248
+ var refsNew = [];
249
+ return opts.proto ? cloneProto : clone;
250
+ function cloneArray(a, fn) {
251
+ var keys = Object.keys(a);
252
+ var a2 = new Array(keys.length);
253
+ for (var i = 0; i < keys.length; i++) {
254
+ var k = keys[i];
255
+ var cur = a[k];
256
+ if (typeof cur !== "object" || cur === null) {
257
+ a2[k] = cur;
258
+ } else if (cur instanceof Date) {
259
+ a2[k] = new Date(cur);
260
+ } else if (ArrayBuffer.isView(cur)) {
261
+ a2[k] = copyBuffer(cur);
262
+ } else {
263
+ var index = refs.indexOf(cur);
264
+ if (index !== -1) {
265
+ a2[k] = refsNew[index];
266
+ } else {
267
+ a2[k] = fn(cur);
268
+ }
269
+ }
270
+ }
271
+ return a2;
272
+ }
273
+ function clone(o) {
274
+ if (typeof o !== "object" || o === null)
275
+ return o;
276
+ if (o instanceof Date)
277
+ return new Date(o);
278
+ if (Array.isArray(o))
279
+ return cloneArray(o, clone);
280
+ if (o instanceof Map)
281
+ return new Map(cloneArray(Array.from(o), clone));
282
+ if (o instanceof Set)
283
+ return new Set(cloneArray(Array.from(o), clone));
284
+ var o2 = {};
285
+ refs.push(o);
286
+ refsNew.push(o2);
287
+ for (var k in o) {
288
+ if (Object.hasOwnProperty.call(o, k) === false)
289
+ continue;
290
+ var cur = o[k];
291
+ if (typeof cur !== "object" || cur === null) {
292
+ o2[k] = cur;
293
+ } else if (cur instanceof Date) {
294
+ o2[k] = new Date(cur);
295
+ } else if (cur instanceof Map) {
296
+ o2[k] = new Map(cloneArray(Array.from(cur), clone));
297
+ } else if (cur instanceof Set) {
298
+ o2[k] = new Set(cloneArray(Array.from(cur), clone));
299
+ } else if (ArrayBuffer.isView(cur)) {
300
+ o2[k] = copyBuffer(cur);
301
+ } else {
302
+ var i = refs.indexOf(cur);
303
+ if (i !== -1) {
304
+ o2[k] = refsNew[i];
305
+ } else {
306
+ o2[k] = clone(cur);
307
+ }
308
+ }
309
+ }
310
+ refs.pop();
311
+ refsNew.pop();
312
+ return o2;
313
+ }
314
+ function cloneProto(o) {
315
+ if (typeof o !== "object" || o === null)
316
+ return o;
317
+ if (o instanceof Date)
318
+ return new Date(o);
319
+ if (Array.isArray(o))
320
+ return cloneArray(o, cloneProto);
321
+ if (o instanceof Map)
322
+ return new Map(cloneArray(Array.from(o), cloneProto));
323
+ if (o instanceof Set)
324
+ return new Set(cloneArray(Array.from(o), cloneProto));
325
+ var o2 = {};
326
+ refs.push(o);
327
+ refsNew.push(o2);
328
+ for (var k in o) {
329
+ var cur = o[k];
330
+ if (typeof cur !== "object" || cur === null) {
331
+ o2[k] = cur;
332
+ } else if (cur instanceof Date) {
333
+ o2[k] = new Date(cur);
334
+ } else if (cur instanceof Map) {
335
+ o2[k] = new Map(cloneArray(Array.from(cur), cloneProto));
336
+ } else if (cur instanceof Set) {
337
+ o2[k] = new Set(cloneArray(Array.from(cur), cloneProto));
338
+ } else if (ArrayBuffer.isView(cur)) {
339
+ o2[k] = copyBuffer(cur);
340
+ } else {
341
+ var i = refs.indexOf(cur);
342
+ if (i !== -1) {
343
+ o2[k] = refsNew[i];
344
+ } else {
345
+ o2[k] = cloneProto(cur);
346
+ }
347
+ }
348
+ }
349
+ refs.pop();
350
+ refsNew.pop();
351
+ return o2;
352
+ }
353
+ }
354
+ var ht = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/", jt = new Array(123);
355
+ for (let e = 0; e < ht.length; e++)
356
+ jt[ht.charCodeAt(e)] = e;
357
+ rfdc_1();
358
+ rfdc_1();
359
+ rfdc_1();
360
+ var Pe = ((u) => (u.ListStart = "nesi-list-start", u.ListEnd = "nesi-list-end", u.ListItem = "nesi-list-item-html", u.ListItemSettings = "nesi-list-item-settings", u.TestStart = "nesi-test-start", u.TestEnd = "nesi-test-end", u.Unknown = "unknown", u))(Pe || {}), Dr = "nesitag";
361
+ const EdgeTag = (props) => {
362
+ return h(Dr, props);
363
+ };
364
+ const _sfc_main$8 = /* @__PURE__ */ defineComponent({
365
+ __name: "TestEdge",
366
+ props: {
367
+ name: null,
368
+ variations: null,
369
+ loadingMode: null,
370
+ component: null
371
+ },
372
+ setup(__props) {
373
+ const { name, variations, component: renderComponent } = __props;
374
+ const options = {
375
+ name
376
+ };
377
+ return (_ctx, _cache) => {
378
+ return openBlock(), createElementBlock(Fragment, null, [
379
+ createVNode(unref(EdgeTag), {
380
+ "data-type": unref(Pe).TestStart,
381
+ innerHTML: JSON.stringify(options)
382
+ }, null, 8, ["data-type", "innerHTML"]),
383
+ (openBlock(true), createElementBlock(Fragment, null, renderList(__props.variations, (variation, index) => {
384
+ return openBlock(), createElementBlock(Fragment, { key: index }, [
385
+ createVNode(unref(EdgeTag), {
386
+ "data-type": unref(Pe).ListItemSettings,
387
+ innerHTML: JSON.stringify({ id: variation.id })
388
+ }, null, 8, ["data-type", "innerHTML"]),
389
+ createVNode(unref(EdgeTag), {
390
+ "data-type": unref(Pe).ListItem
391
+ }, {
392
+ default: withCtx(() => [
393
+ (openBlock(), createBlock(resolveDynamicComponent(_ctx.renderComponent), normalizeProps(guardReactiveProps(variation)), null, 16))
394
+ ]),
395
+ _: 2
396
+ }, 1032, ["data-type"])
397
+ ], 64);
398
+ }), 128)),
399
+ createVNode(unref(EdgeTag), {
400
+ "data-type": unref(Pe).TestEnd
401
+ }, null, 8, ["data-type"])
402
+ ], 64);
403
+ };
404
+ }
405
+ });
406
+ const _sfc_main$7 = /* @__PURE__ */ defineComponent({
407
+ __name: "Test",
408
+ props: {
409
+ name: null,
410
+ variations: null,
411
+ loadingMode: null,
412
+ component: null
413
+ },
414
+ setup(__props) {
415
+ const props = __props;
416
+ const { outputType } = useUniformContext(uniformContextStoreProps);
417
+ const testComponent = computed(() => !isServer || outputType === "standard" ? _sfc_main$9 : _sfc_main$8);
418
+ return (_ctx, _cache) => {
419
+ return openBlock(), createBlock(resolveDynamicComponent(unref(testComponent)), normalizeProps(guardReactiveProps(props)), null, 16);
420
+ };
421
+ }
422
+ });
423
+ const _sfc_main$6 = /* @__PURE__ */ defineComponent({
424
+ __name: "UniformContextProvider",
425
+ props: {
426
+ context: null
427
+ },
428
+ setup(__props) {
429
+ const props = __props;
430
+ initStore(__spreadValues({}, props));
431
+ return (_ctx, _cache) => {
432
+ return renderSlot(_ctx.$slots, "default");
433
+ };
434
+ }
435
+ });
436
+ var has = Object.prototype.hasOwnProperty;
437
+ function dequal(foo, bar) {
438
+ var ctor, len;
439
+ if (foo === bar)
440
+ return true;
441
+ if (foo && bar && (ctor = foo.constructor) === bar.constructor) {
442
+ if (ctor === Date)
443
+ return foo.getTime() === bar.getTime();
444
+ if (ctor === RegExp)
445
+ return foo.toString() === bar.toString();
446
+ if (ctor === Array) {
447
+ if ((len = foo.length) === bar.length) {
448
+ while (len-- && dequal(foo[len], bar[len]))
449
+ ;
450
+ }
451
+ return len === -1;
452
+ }
453
+ if (!ctor || typeof foo === "object") {
454
+ len = 0;
455
+ for (ctor in foo) {
456
+ if (has.call(foo, ctor) && ++len && !has.call(bar, ctor))
457
+ return false;
458
+ if (!(ctor in bar) || !dequal(foo[ctor], bar[ctor]))
459
+ return false;
460
+ }
461
+ return Object.keys(bar).length === len;
462
+ }
463
+ }
464
+ return foo !== foo && bar !== bar;
465
+ }
466
+ const useScores = () => {
467
+ const { context } = useUniformContext(uniformContextStoreProps);
468
+ const scores = ref(context.scores);
469
+ watchEffect(() => {
470
+ const scoringChangeListener = (updatedScores) => scores.value = updatedScores;
471
+ const currentScores = context.scores;
472
+ if (!dequal(scores, currentScores)) {
473
+ scores.value = currentScores;
474
+ }
475
+ context.events.on("scoresUpdated", scoringChangeListener);
476
+ return () => {
477
+ context.events.off("scoresUpdated", scoringChangeListener);
478
+ };
479
+ });
480
+ return scores;
481
+ };
482
+ const uniformPersonalizationContextProps = Symbol("uniformIsPersonalizedStore");
483
+ const initPersonalizeStore = ({ personalized = false }) => {
484
+ provide(uniformPersonalizationContextProps, {
485
+ personalized
486
+ });
487
+ };
488
+ const useIsPersonalized = (key, fallback) => {
489
+ const resolved = inject(key, fallback);
490
+ if (!resolved) {
491
+ return {
492
+ personalized: false
493
+ };
494
+ }
495
+ const value = resolved;
496
+ return __spreadValues({}, value);
497
+ };
498
+ const _sfc_main$5 = /* @__PURE__ */ defineComponent({
499
+ __name: "PersonalizeProvider",
500
+ props: {
501
+ personalized: { type: Boolean }
502
+ },
503
+ setup(__props) {
504
+ const { personalized } = __props;
505
+ initPersonalizeStore({
506
+ personalized
507
+ });
508
+ return (_ctx, _cache) => {
509
+ return renderSlot(_ctx.$slots, "default", normalizeProps(guardReactiveProps({ personalized: __props.personalized })));
510
+ };
511
+ }
512
+ });
513
+ const _sfc_main$4 = /* @__PURE__ */ defineComponent({
514
+ __name: "PersonalizeStandard",
515
+ props: {
516
+ name: null,
517
+ variations: null,
518
+ component: null,
519
+ count: null
520
+ },
521
+ setup(__props) {
522
+ const { name, component, variations, count = 1 } = __props;
523
+ const { context } = useUniformContext(uniformContextStoreProps);
524
+ const scores = useScores();
525
+ const personalized = computed(() => {
526
+ if (scores.value, component) {
527
+ const { variations: personalizedVariations, personalized: personalizationOccurred } = context.personalize({
528
+ name,
529
+ variations,
530
+ take: count
531
+ });
532
+ return {
533
+ personalizedVariations,
534
+ personalizationOccurred
535
+ };
536
+ }
537
+ });
538
+ return (_ctx, _cache) => {
539
+ return openBlock(), createBlock(_sfc_main$5, { personalized: true }, {
540
+ default: withCtx(() => {
541
+ var _a;
542
+ return [
543
+ (openBlock(true), createElementBlock(Fragment, null, renderList((_a = unref(personalized)) == null ? void 0 : _a.personalizedVariations, (item) => {
544
+ var _a2;
545
+ return openBlock(), createBlock(resolveDynamicComponent(__props.component), normalizeProps(mergeProps({
546
+ key: item.id
547
+ }, __spreadValues({
548
+ personalizationResult: {
549
+ variation: item,
550
+ personalizationOccurred: (_a2 = unref(personalized)) == null ? void 0 : _a2.personalizationOccurred
551
+ }
552
+ }, item))), null, 16);
553
+ }), 128))
554
+ ];
555
+ }),
556
+ _: 1
557
+ });
558
+ };
559
+ }
560
+ });
561
+ const _sfc_main$3 = /* @__PURE__ */ defineComponent({
562
+ __name: "PersonalizeEdge",
563
+ props: {
564
+ name: null,
565
+ variations: null,
566
+ component: null,
567
+ count: null
568
+ },
569
+ setup(__props) {
570
+ const { component, variations, count } = __props;
571
+ const options = count != null ? count : 1;
572
+ return (_ctx, _cache) => {
573
+ const _component_component = resolveComponent("component");
574
+ return openBlock(), createElementBlock(Fragment, null, [
575
+ createVNode(unref(EdgeTag), {
576
+ "data-type": unref(Pe).ListStart,
577
+ innerHTML: JSON.stringify(unref(options))
578
+ }, null, 8, ["data-type", "innerHTML"]),
579
+ (openBlock(true), createElementBlock(Fragment, null, renderList(__props.variations, (variant) => {
580
+ return openBlock(), createElementBlock(Fragment, {
581
+ key: variant.id
582
+ }, [
583
+ createVNode(unref(EdgeTag), {
584
+ "data-type": unref(Pe).ListItemSettings,
585
+ innerHTML: JSON.stringify({ id: variant.id, pz: variant.pz || null })
586
+ }, null, 8, ["data-type", "innerHTML"]),
587
+ createVNode(unref(EdgeTag), {
588
+ "data-type": unref(Pe).ListItem
589
+ }, {
590
+ default: withCtx(() => [
591
+ (openBlock(), createBlock(_component_component, {
592
+ key: variant.id,
593
+ personalizationResult: {
594
+ variant,
595
+ personalizationOccurred: false
596
+ }
597
+ }, null, 8, ["personalizationResult"]))
598
+ ]),
599
+ _: 2
600
+ }, 1032, ["data-type"])
601
+ ], 64);
602
+ }), 128)),
603
+ createVNode(unref(EdgeTag), {
604
+ "data-type": unref(Pe).ListEnd
605
+ }, null, 8, ["data-type"])
606
+ ], 64);
607
+ };
608
+ }
609
+ });
610
+ const _sfc_main$2 = /* @__PURE__ */ defineComponent({
611
+ __name: "Personalize",
612
+ props: {
613
+ name: null,
614
+ variations: null,
615
+ component: null,
616
+ count: null
617
+ },
618
+ setup(__props) {
619
+ const props = __props;
620
+ const { outputType } = useUniformContext(uniformContextStoreProps);
621
+ const personalizeComponent = computed(() => !isServer || outputType === "standard" ? _sfc_main$4 : _sfc_main$3);
622
+ return (_ctx, _cache) => {
623
+ return openBlock(), createBlock(resolveDynamicComponent(unref(personalizeComponent)), normalizeProps(guardReactiveProps(__spreadValues({}, props))), null, 16);
624
+ };
625
+ }
626
+ });
627
+ const _sfc_main$1 = /* @__PURE__ */ defineComponent({
628
+ __name: "Track",
629
+ props: {
630
+ behavior: null,
631
+ tagName: { default: "div" },
632
+ disableVisibilityTrigger: { type: Boolean },
633
+ threshold: { default: 0.5 }
634
+ },
635
+ setup(__props) {
636
+ const _a = __props, {
637
+ behavior,
638
+ tagName,
639
+ threshold,
640
+ disableVisibilityTrigger = typeof window === "undefined" || !("IntersectionObserver" in window)
641
+ } = _a, rest = __objRest(_a, [
642
+ "behavior",
643
+ "tagName",
644
+ "threshold",
645
+ "disableVisibilityTrigger"
646
+ ]);
647
+ const currentUrl = typeof document === "undefined" ? "__uniform_ssr_url" : document.location.href;
648
+ const { context } = useUniformContext(uniformContextStoreProps);
649
+ const { personalized: insidePersonalizeComponent } = useIsPersonalized(uniformPersonalizationContextProps);
650
+ const lastUrl = ref("");
651
+ const hasTracked = ref(false);
652
+ const wrapperEl = ref();
653
+ const disconnect = ref();
654
+ watchEffect(() => {
655
+ const urlHasChanged = lastUrl.value !== currentUrl;
656
+ if (urlHasChanged) {
657
+ lastUrl.value = currentUrl;
658
+ hasTracked.value = false;
659
+ }
660
+ });
661
+ watchEffect(() => {
662
+ var _a2;
663
+ const hasNoBehaviorValue = !behavior || Array.isArray(behavior) && !behavior.length;
664
+ const cannotTrack = insidePersonalizeComponent || hasNoBehaviorValue;
665
+ if (cannotTrack || !wrapperEl.value) {
666
+ return;
667
+ }
668
+ const enrichments = Array.isArray(behavior) ? behavior : [behavior];
669
+ const pushBehaviorEnrichment = () => {
670
+ var _a3;
671
+ if (hasTracked.value) {
672
+ return;
673
+ }
674
+ context.update({
675
+ enrichments
676
+ });
677
+ hasTracked.value = false;
678
+ (_a3 = disconnect.value) == null ? void 0 : _a3.call(disconnect);
679
+ };
680
+ if (disableVisibilityTrigger) {
681
+ pushBehaviorEnrichment();
682
+ } else {
683
+ (_a2 = disconnect.value) == null ? void 0 : _a2.call(disconnect);
684
+ const instance = new IntersectionObserver(([entry]) => {
685
+ if (entry.isIntersecting) {
686
+ pushBehaviorEnrichment();
687
+ }
688
+ }, {
689
+ threshold
690
+ });
691
+ instance.observe(wrapperEl.value);
692
+ disconnect.value = () => {
693
+ var _a3;
694
+ return (_a3 = instance.disconnect) == null ? void 0 : _a3.call(instance);
695
+ };
696
+ }
697
+ return () => {
698
+ var _a3;
699
+ (_a3 = disconnect.value) == null ? void 0 : _a3.call(disconnect);
700
+ };
701
+ });
702
+ return (_ctx, _cache) => {
703
+ return openBlock(), createBlock(resolveDynamicComponent(tagName), mergeProps(__spreadValues({}, rest), {
704
+ ref_key: "wrapperEl",
705
+ ref: wrapperEl
706
+ }), {
707
+ default: withCtx(() => [
708
+ renderSlot(_ctx.$slots, "default")
709
+ ]),
710
+ _: 3
711
+ }, 16);
712
+ };
713
+ }
714
+ });
715
+ const _sfc_main = /* @__PURE__ */ defineComponent({
716
+ __name: "TrackSlot",
717
+ props: {
718
+ behavior: null
719
+ },
720
+ setup(__props) {
721
+ const _a = __props, { behavior } = _a, rest = __objRest(_a, ["behavior"]);
722
+ const currentUrl = typeof document === "undefined" ? "__uniform_ssr_url" : document.location.href;
723
+ const { context } = useUniformContext(uniformContextStoreProps);
724
+ const { personalized: insidePersonalizeComponent } = useIsPersonalized(uniformPersonalizationContextProps);
725
+ const lastUrl = ref("");
726
+ const hasTracked = ref(false);
727
+ watchEffect(() => {
728
+ const urlHasChanged = lastUrl.value !== currentUrl;
729
+ if (urlHasChanged) {
730
+ lastUrl.value = currentUrl;
731
+ hasTracked.value = false;
732
+ }
733
+ });
734
+ watchEffect(() => {
735
+ const hasNoBehaviorValue = !behavior || Array.isArray(behavior) && !behavior.length;
736
+ const cannotTrack = insidePersonalizeComponent || hasNoBehaviorValue;
737
+ if (cannotTrack)
738
+ return;
739
+ const pushBehaviorEnrichment = () => {
740
+ if (hasTracked.value) {
741
+ return;
742
+ }
743
+ const enrichments = Array.isArray(behavior) ? behavior : [behavior];
744
+ context.update({
745
+ enrichments
746
+ });
747
+ hasTracked.value = true;
748
+ };
749
+ pushBehaviorEnrichment();
750
+ });
751
+ return (_ctx, _cache) => {
752
+ return renderSlot(_ctx.$slots, "default", normalizeProps(guardReactiveProps(__spreadValues({}, _ctx.rest))));
753
+ };
754
+ }
755
+ });
756
+ const useQuirks = () => {
757
+ const { context } = useUniformContext(uniformContextStoreProps);
758
+ const quirks = ref(context.quirks);
759
+ const quirkChangeListener = (updateQuirks) => {
760
+ quirks.value = updateQuirks;
761
+ };
762
+ watch(context, () => {
763
+ context.events.on("quirksUpdated", quirkChangeListener);
764
+ return () => {
765
+ context.events.off("quirksUpdated", quirkChangeListener);
766
+ };
767
+ });
768
+ return quirks;
769
+ };
770
+ export { _sfc_main$2 as Personalize, _sfc_main$7 as Test, _sfc_main$1 as Track, _sfc_main as TrackSlot, _sfc_main$6 as UniformContextProvider, initPersonalizeStore, initStore, uniformContextStoreProps, useIsPersonalized, useQuirks, useScores, useUniformContext };
package/package.json ADDED
@@ -0,0 +1,37 @@
1
+ {
2
+ "name": "@uniformdev/context-vue",
3
+ "version": "16.0.1-alpha.128+6cdb4ff33",
4
+ "description": "Uniform Context Vue integration package",
5
+ "license": "SEE LICENSE IN LICENSE.txt",
6
+ "main": "./dist/index.cjs.js",
7
+ "module": "./dist/index.es.js",
8
+ "exports": {
9
+ "import": "./dist/index.es.js",
10
+ "require": "./dist/index.cjs.js"
11
+ },
12
+ "types": "./dist/index.d.ts",
13
+ "scripts": {
14
+ "dev": "vue-tsc --noEmit && vite build --watch",
15
+ "build": "vue-tsc --noEmit && vite build",
16
+ "preview": "vite preview"
17
+ },
18
+ "dependencies": {
19
+ "@uniformdev/context": "^16.0.1-alpha.128+6cdb4ff33",
20
+ "vue": "^3.2.25"
21
+ },
22
+ "devDependencies": {
23
+ "@types/node": "^17.0.34",
24
+ "@vitejs/plugin-vue": "^2.3.3",
25
+ "typescript": "^4.5.4",
26
+ "vite": "^2.9.9",
27
+ "vite-plugin-dts": "^1.1.1",
28
+ "vue-tsc": "^0.34.15"
29
+ },
30
+ "files": [
31
+ "dist"
32
+ ],
33
+ "publishConfig": {
34
+ "access": "public"
35
+ },
36
+ "gitHead": "6cdb4ff331d6d0d9d5c154b7b342e7703067bfc3"
37
+ }