@uniformdev/canvas-vue 16.2.0 → 16.2.1-nuxt.274
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 +1 -1
- package/dist/index.d.ts +71 -46
- package/dist/index.esm.js +1 -1
- package/dist/index.js +1 -1
- package/dist/index.mjs +1 -1
- package/package.json +16 -17
- package/CHANGELOG.md +0 -65
package/README.md
CHANGED
package/dist/index.d.ts
CHANGED
|
@@ -1,12 +1,7 @@
|
|
|
1
|
-
import
|
|
1
|
+
import * as vue_demi from 'vue-demi';
|
|
2
|
+
import { ConcreteComponent, PropType, Ref } from 'vue-demi';
|
|
2
3
|
import { ComponentInstance, ComponentParameter, SubscribeToCompositionOptions } from '@uniformdev/canvas';
|
|
3
4
|
|
|
4
|
-
declare type MapComponentNameProps = {
|
|
5
|
-
name: string;
|
|
6
|
-
components: Array<ComponentInstance>;
|
|
7
|
-
};
|
|
8
|
-
declare type SlotDataProps = Record<string, any>;
|
|
9
|
-
declare type MapSlotDataResolve = Array<MapComponentNameProps>;
|
|
10
5
|
interface TestComponent {
|
|
11
6
|
slots?: {
|
|
12
7
|
test?: ComponentInstance[];
|
|
@@ -32,7 +27,7 @@ interface PersonalizeComponent {
|
|
|
32
27
|
declare type ComponentProps<TProps = unknown> = TProps & {
|
|
33
28
|
component: ComponentInstance;
|
|
34
29
|
};
|
|
35
|
-
declare type ResolveRenderer = (componentInstance: ComponentInstance) => ConcreteComponent
|
|
30
|
+
declare type ResolveRenderer = (componentInstance: ComponentInstance) => ConcreteComponent<any>;
|
|
36
31
|
|
|
37
32
|
declare type CompositionProps = {
|
|
38
33
|
/** A dynamic vue component that provides data to the Uniform Canvas SlotContent component via provide/inject */
|
|
@@ -51,7 +46,40 @@ declare type CompositionProps = {
|
|
|
51
46
|
*/
|
|
52
47
|
behaviorTracking?: 'onLoad' | 'onView';
|
|
53
48
|
};
|
|
54
|
-
declare const Composition:
|
|
49
|
+
declare const Composition: vue_demi.DefineComponent<{
|
|
50
|
+
data: {
|
|
51
|
+
type: PropType<ComponentInstance>;
|
|
52
|
+
required: true;
|
|
53
|
+
};
|
|
54
|
+
resolveRenderer: {
|
|
55
|
+
type: PropType<ResolveRenderer | undefined>;
|
|
56
|
+
default: () => ({ type }: ComponentInstance) => string | ConcreteComponent<{}, any, any, vue_demi.ComputedOptions, vue_demi.MethodOptions>;
|
|
57
|
+
};
|
|
58
|
+
behaviorTracking: {
|
|
59
|
+
type: PropType<"onLoad" | "onView" | undefined>;
|
|
60
|
+
default: string;
|
|
61
|
+
};
|
|
62
|
+
}, (() => vue_demi.VNode<vue_demi.RendererNode, vue_demi.RendererElement, {
|
|
63
|
+
[key: string]: any;
|
|
64
|
+
}>) | (() => vue_demi.VNode<vue_demi.RendererNode, vue_demi.RendererElement, {
|
|
65
|
+
[key: string]: any;
|
|
66
|
+
}>[] | undefined), unknown, {}, {}, vue_demi.ComponentOptionsMixin, vue_demi.ComponentOptionsMixin, Record<string, any>, string, vue_demi.VNodeProps & vue_demi.AllowedComponentProps & vue_demi.ComponentCustomProps, Readonly<vue_demi.ExtractPropTypes<{
|
|
67
|
+
data: {
|
|
68
|
+
type: PropType<ComponentInstance>;
|
|
69
|
+
required: true;
|
|
70
|
+
};
|
|
71
|
+
resolveRenderer: {
|
|
72
|
+
type: PropType<ResolveRenderer | undefined>;
|
|
73
|
+
default: () => ({ type }: ComponentInstance) => string | ConcreteComponent<{}, any, any, vue_demi.ComputedOptions, vue_demi.MethodOptions>;
|
|
74
|
+
};
|
|
75
|
+
behaviorTracking: {
|
|
76
|
+
type: PropType<"onLoad" | "onView" | undefined>;
|
|
77
|
+
default: string;
|
|
78
|
+
};
|
|
79
|
+
}>>, {
|
|
80
|
+
resolveRenderer: ResolveRenderer | undefined;
|
|
81
|
+
behaviorTracking: "onLoad" | "onView" | undefined;
|
|
82
|
+
}>;
|
|
55
83
|
|
|
56
84
|
declare type SlotComponentProps = {
|
|
57
85
|
/** Name of the slot to render */
|
|
@@ -66,46 +94,43 @@ declare type SlotComponentProps = {
|
|
|
66
94
|
* Renders the content of a Canvas composition's slot
|
|
67
95
|
* @vue-prop {String} name - name of the Uniform Canvas slot you wish to scope to
|
|
68
96
|
*/
|
|
69
|
-
declare const SlotContent:
|
|
97
|
+
declare const SlotContent: vue_demi.DefineComponent<{
|
|
98
|
+
name: {
|
|
99
|
+
type: PropType<string | undefined>;
|
|
100
|
+
};
|
|
101
|
+
resolveRenderer: {
|
|
102
|
+
type: PropType<ResolveRenderer | undefined>;
|
|
103
|
+
};
|
|
104
|
+
}, () => (ConcreteComponent<any, any, any, vue_demi.ComputedOptions, vue_demi.MethodOptions> | vue_demi.VNode<vue_demi.RendererNode, vue_demi.RendererElement, {
|
|
105
|
+
[key: string]: any;
|
|
106
|
+
}>[])[], unknown, {}, {}, vue_demi.ComponentOptionsMixin, vue_demi.ComponentOptionsMixin, Record<string, any>, string, vue_demi.VNodeProps & vue_demi.AllowedComponentProps & vue_demi.ComponentCustomProps, Readonly<vue_demi.ExtractPropTypes<{
|
|
107
|
+
name: {
|
|
108
|
+
type: PropType<string | undefined>;
|
|
109
|
+
};
|
|
110
|
+
resolveRenderer: {
|
|
111
|
+
type: PropType<ResolveRenderer | undefined>;
|
|
112
|
+
};
|
|
113
|
+
}>>, {}>;
|
|
70
114
|
|
|
71
115
|
declare type DefaultNotImplementedComponentProps = {
|
|
72
116
|
component: ComponentInstance;
|
|
73
117
|
};
|
|
74
|
-
declare const DefaultNotImplementedComponent:
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
*/
|
|
88
|
-
declare const mapSlotsData: (slots: SlotDataProps) => MapSlotDataResolve;
|
|
89
|
-
/**
|
|
90
|
-
*
|
|
91
|
-
* @param {Object} slotData - Takes an object with name and components as key value pair
|
|
92
|
-
* @returns {Array} - An array with key value pairs [{ name: 'string', components: [{ ... }], intentTag: {}}]
|
|
93
|
-
*/
|
|
94
|
-
declare const mapPzSlotToVariants: (slotData: MapComponentNameProps) => {
|
|
95
|
-
component: string;
|
|
96
|
-
intentTag: any;
|
|
97
|
-
}[];
|
|
98
|
-
/**
|
|
99
|
-
*
|
|
100
|
-
* @param {Object} slotData - Takes an object with name and components as key value pair
|
|
101
|
-
* @returns - An array with key value pairs [{ name: 'string', components: [{ ... }]}]
|
|
102
|
-
*/
|
|
103
|
-
declare const mapTestSlotToVariants: (slotData: MapComponentNameProps) => {
|
|
104
|
-
component: string;
|
|
105
|
-
}[];
|
|
118
|
+
declare const DefaultNotImplementedComponent: vue_demi.DefineComponent<{
|
|
119
|
+
component: {
|
|
120
|
+
type: PropType<ComponentInstance>;
|
|
121
|
+
required: true;
|
|
122
|
+
};
|
|
123
|
+
}, () => vue_demi.VNode<vue_demi.RendererNode, vue_demi.RendererElement, {
|
|
124
|
+
[key: string]: any;
|
|
125
|
+
}>, unknown, {}, {}, vue_demi.ComponentOptionsMixin, vue_demi.ComponentOptionsMixin, Record<string, any>, string, vue_demi.VNodeProps & vue_demi.AllowedComponentProps & vue_demi.ComponentCustomProps, Readonly<vue_demi.ExtractPropTypes<{
|
|
126
|
+
component: {
|
|
127
|
+
type: PropType<ComponentInstance>;
|
|
128
|
+
required: true;
|
|
129
|
+
};
|
|
130
|
+
}>>, {}>;
|
|
106
131
|
|
|
107
132
|
/**
|
|
108
|
-
* Converts a raw Canvas component instance to
|
|
133
|
+
* Converts a raw Canvas component instance to Vue component props format.
|
|
109
134
|
* This merges each parameter moved to the root object and removes the 'value' node,
|
|
110
135
|
* hugely simplifying rendering code. For example if the raw object has parameters.foo.value,
|
|
111
136
|
* then the final props have props.foo === raw.parameters.foo.value.
|
|
@@ -124,7 +149,7 @@ declare function useCompositionEventEffect({ enabled, projectId, compositionIdRe
|
|
|
124
149
|
declare const CANVAS_COMPOSITION_TYPE = "Composition";
|
|
125
150
|
/** Public ID of Canvas slot component component type */
|
|
126
151
|
declare const CANVAS_SLOT_CONTENT_TYPE = "SlotContent";
|
|
127
|
-
declare const compositionInjectionKey
|
|
128
|
-
declare const resolveRendererInjectionKey
|
|
152
|
+
declare const compositionInjectionKey = "uniformComposition";
|
|
153
|
+
declare const resolveRendererInjectionKey = "uniformResolveRenderer";
|
|
129
154
|
|
|
130
|
-
export { CANVAS_COMPOSITION_TYPE, CANVAS_SLOT_CONTENT_TYPE, ComponentProps, Composition, CompositionProps, DefaultNotImplementedComponent, DefaultNotImplementedComponentProps,
|
|
155
|
+
export { CANVAS_COMPOSITION_TYPE, CANVAS_SLOT_CONTENT_TYPE, ComponentProps, Composition, CompositionProps, DefaultNotImplementedComponent, DefaultNotImplementedComponentProps, PersonalizeComponent, ResolveRenderer, SlotComponentProps, SlotContent, TestComponent, UseCompositionEventEffectOptions, compositionInjectionKey, convertComponentToProps, resolveRendererInjectionKey, useCompositionEventEffect };
|
package/dist/index.esm.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
import{defineComponent as x,computed as T,h as A,provide as b,inject as I,resolveComponent as g}from"vue-demi";var R="Composition",S="SlotContent",f="uniformComposition",C="uniformResolveRenderer";import{CANVAS_ENRICHMENT_TAG_PARAM as O}from"@uniformdev/canvas";import{Track as _,TrackSlot as k,isUsingUniformContext as w}from"@uniformdev/context-vue";var E=x({name:R,inheritAttrs:!1,props:{data:{type:Object,required:!0},resolveRenderer:{type:Function,default:()=>({type:e})=>g(e)},behaviorTracking:{type:String,default:"onView"}},setup(e,t){var l,d,y;let o=T(()=>{var i,c;return(c=e.data)!=null?c:(i=I(f))==null?void 0:i.value}),n=(l=e.resolveRenderer)!=null?l:I(C);b(f,o),b(C,n);let s=T(()=>{var i,c;return(c=(i=o.value)==null?void 0:i.slots)!=null?c:{}}),p=T(()=>{var i,c;return(c=(i=o.value)==null?void 0:i.parameters)!=null?c:{}}),m=T(()=>JSON.stringify(o.value)),r=(y=(d=o.value.parameters)==null?void 0:d[O])==null?void 0:y.value,a=()=>{var i,c;return(c=(i=t.slots).default)==null?void 0:c.call(i,{slots:s.value,parameters:p.value})};if(w()){let i=e.behaviorTracking==="onLoad"?k:_;return()=>A(i,{behavior:r,key:m.value},a)}return a}});import{defineComponent as j,computed as z,h as v,inject as N}from"vue-demi";import{CANVAS_PERSONALIZE_TYPE as U,CANVAS_TEST_TYPE as K,mapSlotToPersonalizedVariations as L,mapSlotToTestVariations as Y}from"@uniformdev/canvas";import{Personalize as $,Test as D}from"@uniformdev/context-vue";function h(e){var s;let t=(s=e.parameters)!=null?s:{};return{...Object.entries(t).reduce((p,[m,{value:r}])=>({...p,[V(m)]:r}),{}),...e.data,component:e}}function V(e){return e.replace("$","")}var de=j({name:S,inheritAttrs:!1,props:{name:{type:String},resolveRenderer:{type:Function}},setup(e,t){var m;let o=N(f),n=(m=e.resolveRenderer)!=null?m:N(C);if(!o||!n)throw new Error("<SlotContent /> can only be used inside a <Composition />");let p=z(()=>{var r,a,l;return e.name?(a=(r=o==null?void 0:o.value.slots)==null?void 0:r[e.name])!=null?a:[]:Object.values((l=o==null?void 0:o.value.slots)!=null?l:{}).flat()}).value.map(r=>{let a=P({component:r,resolveRenderer:n});return t.slots.default?t.slots.default({child:a,component:r}):a});return()=>p}});function M(e,t){var p,m,r,a,l,d;let o=e==null?void 0:e.parameters,n=L((p=e.slots)==null?void 0:p.pz),s=(a=(r=(m=e.parameters)==null?void 0:m.trackingEventName)==null?void 0:r.value)!=null?a:"Untitled Personalization";return v($,{name:s,component:y=>t(y),variations:n,count:Number((d=(l=o==null?void 0:o.count)==null?void 0:l.value)!=null?d:1)})}function F(e,t){var p,m,r,a,l;let o=(m=(p=e==null?void 0:e.slots)==null?void 0:p.test)!=null?m:[],n=(l=(a=(r=e==null?void 0:e.parameters)==null?void 0:r.test)==null?void 0:a.value)!=null?l:"Untitled Test",s=Y(o);return v(D,{variations:s,name:n,component:d=>t(d)})}function P({component:e,resolveRenderer:t}){if(e.type===K)return F(e,n=>P({component:n,resolveRenderer:t}));if(e.type===U)return M(e,n=>P({component:n,resolveRenderer:t}));let o=t==null?void 0:t(e);if(o){let n=h(e);return v(E,{data:e,resolveRenderer:t},()=>v(o,n))}return console.warn(`[canvas] found component of type '${e.type}' which the 'resolveRenderer' prop returned no component for. Nothing will be rendered. The resolveRenderer function may need to be extended to handle the new type.`,e),v("")}import{defineComponent as q,h as u}from"vue-demi";var B={borderLeft:"10px solid #e42535",background:"rgba(122, 215, 218, 0.3)",color:"#1d3557",padding:"1rem",textAlign:"left",margin:"1rem 5vw"},J={margin:"0 0 1rem"},ve=q({name:"DefaultNotImplementedComponent",props:{component:{type:Object,required:!0}},setup(e,{attrs:t}){var n;let o=(n=e.component)==null?void 0:n.type;return()=>u("div",{key:"content",style:{...B}},[u("h2",{style:{...J}},`Component: ${o}`),u("p",[u("strong",`${o} has no Vue implementation. It may need to be added to your `),u("code",{},"resolveRenderer()"),u("strong",{}," function.")]),u("details",{},[u("summary",{},"props/attributes"),u("pre",{style:{overflowX:"auto"}},`${JSON.stringify(t)}`)])])}});import{CANVAS_DRAFT_STATE as G,createEventBus as H,subscribeToComposition as X}from"@uniformdev/canvas";import{watch as Z}from"vue-demi";async function Q({enabled:e,projectId:t,compositionIdRef:o,effect:n}){let s;Z([()=>e,()=>o.value,()=>t],async()=>{if(s==null||s(),!e||!o.value||!t)return;let p=await H();p&&(s=X({eventBus:p,compositionId:o.value,compositionState:G,projectId:t,callback:n,event:"updated"}))},{immediate:!0})}export{R as CANVAS_COMPOSITION_TYPE,S as CANVAS_SLOT_CONTENT_TYPE,E as Composition,ve as DefaultNotImplementedComponent,de as SlotContent,f as compositionInjectionKey,h as convertComponentToProps,C as resolveRendererInjectionKey,Q as useCompositionEventEffect};
|
package/dist/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var I=Object.defineProperty;var
|
|
1
|
+
"use strict";var I=Object.defineProperty;var k=Object.getOwnPropertyDescriptor;var w=Object.getOwnPropertyNames;var V=Object.prototype.hasOwnProperty;var j=(e,t)=>{for(var o in t)I(e,o,{get:t[o],enumerable:!0})},z=(e,t,o,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let r of w(t))!V.call(e,r)&&r!==o&&I(e,r,{get:()=>t[r],enumerable:!(n=k(t,r))||n.enumerable});return e};var U=e=>z(I({},"__esModule",{value:!0}),e);var q={};j(q,{CANVAS_COMPOSITION_TYPE:()=>E,CANVAS_SLOT_CONTENT_TYPE:()=>h,Composition:()=>N,DefaultNotImplementedComponent:()=>F,SlotContent:()=>L,compositionInjectionKey:()=>y,convertComponentToProps:()=>x,resolveRendererInjectionKey:()=>T,useCompositionEventEffect:()=>_});module.exports=U(q);var s=require("vue-demi");var E="Composition",h="SlotContent",y="uniformComposition",T="uniformResolveRenderer";var g=require("@uniformdev/canvas"),P=require("@uniformdev/context-vue");var N=(0,s.defineComponent)({name:E,inheritAttrs:!1,props:{data:{type:Object,required:!0},resolveRenderer:{type:Function,default:()=>({type:e})=>(0,s.resolveComponent)(e)},behaviorTracking:{type:String,default:"onView"}},setup(e,t){var d,v,S;let o=(0,s.computed)(()=>{var m,f;return(f=e.data)!=null?f:(m=(0,s.inject)(y))==null?void 0:m.value}),n=(d=e.resolveRenderer)!=null?d:(0,s.inject)(T);(0,s.provide)(y,o),(0,s.provide)(T,n);let r=(0,s.computed)(()=>{var m,f;return(f=(m=o.value)==null?void 0:m.slots)!=null?f:{}}),a=(0,s.computed)(()=>{var m,f;return(f=(m=o.value)==null?void 0:m.parameters)!=null?f:{}}),c=(0,s.computed)(()=>JSON.stringify(o.value)),p=(S=(v=o.value.parameters)==null?void 0:v[g.CANVAS_ENRICHMENT_TAG_PARAM])==null?void 0:S.value,i=()=>{var m,f;return(f=(m=t.slots).default)==null?void 0:f.call(m,{slots:r.value,parameters:a.value})};if((0,P.isUsingUniformContext)()){let m=e.behaviorTracking==="onLoad"?P.TrackSlot:P.Track;return()=>(0,s.h)(m,{behavior:p,key:c.value},i)}return i}});var l=require("vue-demi"),C=require("@uniformdev/canvas"),b=require("@uniformdev/context-vue");function x(e){var r;let t=(r=e.parameters)!=null?r:{};return{...Object.entries(t).reduce((a,[c,{value:p}])=>({...a,[K(c)]:p}),{}),...e.data,component:e}}function K(e){return e.replace("$","")}var L=(0,l.defineComponent)({name:h,inheritAttrs:!1,props:{name:{type:String},resolveRenderer:{type:Function}},setup(e,t){var c;let o=(0,l.inject)(y),n=(c=e.resolveRenderer)!=null?c:(0,l.inject)(T);if(!o||!n)throw new Error("<SlotContent /> can only be used inside a <Composition />");let a=(0,l.computed)(()=>{var p,i,d;return e.name?(i=(p=o==null?void 0:o.value.slots)==null?void 0:p[e.name])!=null?i:[]:Object.values((d=o==null?void 0:o.value.slots)!=null?d:{}).flat()}).value.map(p=>{let i=A({component:p,resolveRenderer:n});return t.slots.default?t.slots.default({child:i,component:p}):i});return()=>a}});function Y(e,t){var a,c,p,i,d,v;let o=e==null?void 0:e.parameters,n=(0,C.mapSlotToPersonalizedVariations)((a=e.slots)==null?void 0:a.pz),r=(i=(p=(c=e.parameters)==null?void 0:c.trackingEventName)==null?void 0:p.value)!=null?i:"Untitled Personalization";return(0,l.h)(b.Personalize,{name:r,component:S=>t(S),variations:n,count:Number((v=(d=o==null?void 0:o.count)==null?void 0:d.value)!=null?v:1)})}function $(e,t){var a,c,p,i,d;let o=(c=(a=e==null?void 0:e.slots)==null?void 0:a.test)!=null?c:[],n=(d=(i=(p=e==null?void 0:e.parameters)==null?void 0:p.test)==null?void 0:i.value)!=null?d:"Untitled Test",r=(0,C.mapSlotToTestVariations)(o);return(0,l.h)(b.Test,{variations:r,name:n,component:v=>t(v)})}function A({component:e,resolveRenderer:t}){if(e.type===C.CANVAS_TEST_TYPE)return $(e,n=>A({component:n,resolveRenderer:t}));if(e.type===C.CANVAS_PERSONALIZE_TYPE)return Y(e,n=>A({component:n,resolveRenderer:t}));let o=t==null?void 0:t(e);if(o){let n=x(e);return(0,l.h)(N,{data:e,resolveRenderer:t},()=>(0,l.h)(o,n))}return console.warn(`[canvas] found component of type '${e.type}' which the 'resolveRenderer' prop returned no component for. Nothing will be rendered. The resolveRenderer function may need to be extended to handle the new type.`,e),(0,l.h)("")}var u=require("vue-demi"),D={borderLeft:"10px solid #e42535",background:"rgba(122, 215, 218, 0.3)",color:"#1d3557",padding:"1rem",textAlign:"left",margin:"1rem 5vw"},M={margin:"0 0 1rem"},F=(0,u.defineComponent)({name:"DefaultNotImplementedComponent",props:{component:{type:Object,required:!0}},setup(e,{attrs:t}){var n;let o=(n=e.component)==null?void 0:n.type;return()=>(0,u.h)("div",{key:"content",style:{...D}},[(0,u.h)("h2",{style:{...M}},`Component: ${o}`),(0,u.h)("p",[(0,u.h)("strong",`${o} has no Vue implementation. It may need to be added to your `),(0,u.h)("code",{},"resolveRenderer()"),(0,u.h)("strong",{}," function.")]),(0,u.h)("details",{},[(0,u.h)("summary",{},"props/attributes"),(0,u.h)("pre",{style:{overflowX:"auto"}},`${JSON.stringify(t)}`)])])}});var R=require("@uniformdev/canvas"),O=require("vue-demi");async function _({enabled:e,projectId:t,compositionIdRef:o,effect:n}){let r;(0,O.watch)([()=>e,()=>o.value,()=>t],async()=>{if(r==null||r(),!e||!o.value||!t)return;let a=await(0,R.createEventBus)();a&&(r=(0,R.subscribeToComposition)({eventBus:a,compositionId:o.value,compositionState:R.CANVAS_DRAFT_STATE,projectId:t,callback:n,event:"updated"}))},{immediate:!0})}0&&(module.exports={CANVAS_COMPOSITION_TYPE,CANVAS_SLOT_CONTENT_TYPE,Composition,DefaultNotImplementedComponent,SlotContent,compositionInjectionKey,convertComponentToProps,resolveRendererInjectionKey,useCompositionEventEffect});
|
package/dist/index.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
import{defineComponent as x,computed as T,h as A,provide as b,inject as I,resolveComponent as g}from"vue-demi";var R="Composition",S="SlotContent",f="uniformComposition",C="uniformResolveRenderer";import{CANVAS_ENRICHMENT_TAG_PARAM as O}from"@uniformdev/canvas";import{Track as _,TrackSlot as k,isUsingUniformContext as w}from"@uniformdev/context-vue";var E=x({name:R,inheritAttrs:!1,props:{data:{type:Object,required:!0},resolveRenderer:{type:Function,default:()=>({type:e})=>g(e)},behaviorTracking:{type:String,default:"onView"}},setup(e,t){var l,d,y;let o=T(()=>{var i,c;return(c=e.data)!=null?c:(i=I(f))==null?void 0:i.value}),n=(l=e.resolveRenderer)!=null?l:I(C);b(f,o),b(C,n);let s=T(()=>{var i,c;return(c=(i=o.value)==null?void 0:i.slots)!=null?c:{}}),p=T(()=>{var i,c;return(c=(i=o.value)==null?void 0:i.parameters)!=null?c:{}}),m=T(()=>JSON.stringify(o.value)),r=(y=(d=o.value.parameters)==null?void 0:d[O])==null?void 0:y.value,a=()=>{var i,c;return(c=(i=t.slots).default)==null?void 0:c.call(i,{slots:s.value,parameters:p.value})};if(w()){let i=e.behaviorTracking==="onLoad"?k:_;return()=>A(i,{behavior:r,key:m.value},a)}return a}});import{defineComponent as j,computed as z,h as v,inject as N}from"vue-demi";import{CANVAS_PERSONALIZE_TYPE as U,CANVAS_TEST_TYPE as K,mapSlotToPersonalizedVariations as L,mapSlotToTestVariations as Y}from"@uniformdev/canvas";import{Personalize as $,Test as D}from"@uniformdev/context-vue";function h(e){var s;let t=(s=e.parameters)!=null?s:{};return{...Object.entries(t).reduce((p,[m,{value:r}])=>({...p,[V(m)]:r}),{}),...e.data,component:e}}function V(e){return e.replace("$","")}var de=j({name:S,inheritAttrs:!1,props:{name:{type:String},resolveRenderer:{type:Function}},setup(e,t){var m;let o=N(f),n=(m=e.resolveRenderer)!=null?m:N(C);if(!o||!n)throw new Error("<SlotContent /> can only be used inside a <Composition />");let p=z(()=>{var r,a,l;return e.name?(a=(r=o==null?void 0:o.value.slots)==null?void 0:r[e.name])!=null?a:[]:Object.values((l=o==null?void 0:o.value.slots)!=null?l:{}).flat()}).value.map(r=>{let a=P({component:r,resolveRenderer:n});return t.slots.default?t.slots.default({child:a,component:r}):a});return()=>p}});function M(e,t){var p,m,r,a,l,d;let o=e==null?void 0:e.parameters,n=L((p=e.slots)==null?void 0:p.pz),s=(a=(r=(m=e.parameters)==null?void 0:m.trackingEventName)==null?void 0:r.value)!=null?a:"Untitled Personalization";return v($,{name:s,component:y=>t(y),variations:n,count:Number((d=(l=o==null?void 0:o.count)==null?void 0:l.value)!=null?d:1)})}function F(e,t){var p,m,r,a,l;let o=(m=(p=e==null?void 0:e.slots)==null?void 0:p.test)!=null?m:[],n=(l=(a=(r=e==null?void 0:e.parameters)==null?void 0:r.test)==null?void 0:a.value)!=null?l:"Untitled Test",s=Y(o);return v(D,{variations:s,name:n,component:d=>t(d)})}function P({component:e,resolveRenderer:t}){if(e.type===K)return F(e,n=>P({component:n,resolveRenderer:t}));if(e.type===U)return M(e,n=>P({component:n,resolveRenderer:t}));let o=t==null?void 0:t(e);if(o){let n=h(e);return v(E,{data:e,resolveRenderer:t},()=>v(o,n))}return console.warn(`[canvas] found component of type '${e.type}' which the 'resolveRenderer' prop returned no component for. Nothing will be rendered. The resolveRenderer function may need to be extended to handle the new type.`,e),v("")}import{defineComponent as q,h as u}from"vue-demi";var B={borderLeft:"10px solid #e42535",background:"rgba(122, 215, 218, 0.3)",color:"#1d3557",padding:"1rem",textAlign:"left",margin:"1rem 5vw"},J={margin:"0 0 1rem"},ve=q({name:"DefaultNotImplementedComponent",props:{component:{type:Object,required:!0}},setup(e,{attrs:t}){var n;let o=(n=e.component)==null?void 0:n.type;return()=>u("div",{key:"content",style:{...B}},[u("h2",{style:{...J}},`Component: ${o}`),u("p",[u("strong",`${o} has no Vue implementation. It may need to be added to your `),u("code",{},"resolveRenderer()"),u("strong",{}," function.")]),u("details",{},[u("summary",{},"props/attributes"),u("pre",{style:{overflowX:"auto"}},`${JSON.stringify(t)}`)])])}});import{CANVAS_DRAFT_STATE as G,createEventBus as H,subscribeToComposition as X}from"@uniformdev/canvas";import{watch as Z}from"vue-demi";async function Q({enabled:e,projectId:t,compositionIdRef:o,effect:n}){let s;Z([()=>e,()=>o.value,()=>t],async()=>{if(s==null||s(),!e||!o.value||!t)return;let p=await H();p&&(s=X({eventBus:p,compositionId:o.value,compositionState:G,projectId:t,callback:n,event:"updated"}))},{immediate:!0})}export{R as CANVAS_COMPOSITION_TYPE,S as CANVAS_SLOT_CONTENT_TYPE,E as Composition,ve as DefaultNotImplementedComponent,de as SlotContent,f as compositionInjectionKey,h as convertComponentToProps,C as resolveRendererInjectionKey,Q as useCompositionEventEffect};
|
package/package.json
CHANGED
|
@@ -1,16 +1,15 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@uniformdev/canvas-vue",
|
|
3
|
-
"version": "16.2.
|
|
3
|
+
"version": "16.2.1-nuxt.274+0a8a48855",
|
|
4
4
|
"description": "Vue SDK for Uniform Canvas",
|
|
5
5
|
"license": "SEE LICENSE IN LICENSE.txt",
|
|
6
6
|
"main": "./dist/index.js",
|
|
7
7
|
"module": "./dist/index.esm.js",
|
|
8
8
|
"exports": {
|
|
9
|
-
"
|
|
10
|
-
"
|
|
11
|
-
"
|
|
12
|
-
}
|
|
13
|
-
"require": "./dist/index.js"
|
|
9
|
+
".": {
|
|
10
|
+
"import": "./dist/index.esm.js",
|
|
11
|
+
"require": "./dist/index.js"
|
|
12
|
+
}
|
|
14
13
|
},
|
|
15
14
|
"types": "./dist/index.d.ts",
|
|
16
15
|
"sideEffects": false,
|
|
@@ -23,14 +22,12 @@
|
|
|
23
22
|
"format": "prettier --write \"src/**/*.{js,ts,tsx}\""
|
|
24
23
|
},
|
|
25
24
|
"dependencies": {
|
|
26
|
-
"@uniformdev/canvas": "^16.2.
|
|
27
|
-
"@
|
|
28
|
-
"
|
|
29
|
-
"pascal-case": "3.1.2",
|
|
30
|
-
"uuid": "8.3.2",
|
|
31
|
-
"vue-demi": "^0.12.5"
|
|
25
|
+
"@uniformdev/canvas": "^16.2.1-nuxt.274+0a8a48855",
|
|
26
|
+
"@vue/test-utils": "2.0.2",
|
|
27
|
+
"vue-demi": "^0.13.0"
|
|
32
28
|
},
|
|
33
29
|
"peerDependencies": {
|
|
30
|
+
"@uniformdev/context-vue": "^16.2.4",
|
|
34
31
|
"@vue/composition-api": "^1.0.0-rc.1",
|
|
35
32
|
"vue": "^2.0.0 || >=3.0.0"
|
|
36
33
|
},
|
|
@@ -40,12 +37,13 @@
|
|
|
40
37
|
}
|
|
41
38
|
},
|
|
42
39
|
"devDependencies": {
|
|
43
|
-
"@testing-library/vue": "6.6.
|
|
40
|
+
"@testing-library/vue": "6.6.1",
|
|
44
41
|
"@types/uuid": "8.3.4",
|
|
42
|
+
"@uniformdev/context-vue": "^16.2.1-nuxt.274+0a8a48855",
|
|
45
43
|
"@vue/server-test-utils": "1.3.0",
|
|
46
|
-
"vue": "3.2.
|
|
47
|
-
"vue-server-renderer": "2.
|
|
48
|
-
"vue-template-compiler": "2.
|
|
44
|
+
"vue": "3.2.37",
|
|
45
|
+
"vue-server-renderer": "2.7.7",
|
|
46
|
+
"vue-template-compiler": "2.7.7"
|
|
49
47
|
},
|
|
50
48
|
"files": [
|
|
51
49
|
"dist",
|
|
@@ -63,5 +61,6 @@
|
|
|
63
61
|
"> 1%",
|
|
64
62
|
"last 2 versions",
|
|
65
63
|
"not dead"
|
|
66
|
-
]
|
|
64
|
+
],
|
|
65
|
+
"gitHead": "0a8a48855ef532336761a3872c3d515ab6b9113e"
|
|
67
66
|
}
|
package/CHANGELOG.md
DELETED
|
@@ -1,65 +0,0 @@
|
|
|
1
|
-
# Change Log
|
|
2
|
-
|
|
3
|
-
All notable changes to this project will be documented in this file.
|
|
4
|
-
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
|
-
|
|
6
|
-
## [16.2.0](https://github.com/uniformdev/platform/compare/v16.1.0...v16.2.0) (2022-06-30)
|
|
7
|
-
|
|
8
|
-
**Note:** Version bump only for package @uniformdev/canvas-vue
|
|
9
|
-
|
|
10
|
-
## [16.1.0](https://github.com/uniformdev/platform/compare/v16.0.0...v16.1.0) (2022-06-02)
|
|
11
|
-
|
|
12
|
-
**Note:** Version bump only for package @uniformdev/canvas-vue
|
|
13
|
-
|
|
14
|
-
## [16.0.0](https://github.com/uniformdev/platform/compare/v15.0.0...v16.0.0) (2022-04-26)
|
|
15
|
-
|
|
16
|
-
**Note:** Version bump only for package @uniformdev/canvas-vue
|
|
17
|
-
|
|
18
|
-
## [15.0.0](https://github.com/uniformdev/optimize/compare/v14.2.0...v15.0.0) (2022-03-28)
|
|
19
|
-
|
|
20
|
-
**Note:** Version bump only for package @uniformdev/canvas-vue
|
|
21
|
-
|
|
22
|
-
### [14.1.1](https://github.com/uniformdev/optimize-sdk-internal/compare/v14.1.0...v14.1.1) (2022-02-02)
|
|
23
|
-
|
|
24
|
-
**Note:** Version bump only for package @uniformdev/canvas-vue
|
|
25
|
-
|
|
26
|
-
## [14.1.0](https://github.com/uniformdev/optimize-sdk-internal/compare/v14.0.0...v14.1.0) (2022-02-02)
|
|
27
|
-
|
|
28
|
-
**Note:** Version bump only for package @uniformdev/canvas-vue
|
|
29
|
-
|
|
30
|
-
## [14.0.0](https://github.com/uniformdev/optimize-sdk-internal/compare/v13.0.0...v14.0.0) (2021-12-21)
|
|
31
|
-
|
|
32
|
-
### Bug Fixes
|
|
33
|
-
|
|
34
|
-
- **deps:** upgrade dependency versions ([2ed0022](https://github.com/uniformdev/optimize-sdk-internal/commit/2ed002274b06f06e13e0be1f3024a9b93a2f6d14))
|
|
35
|
-
|
|
36
|
-
## [13.0.0](https://github.com/uniformdev/optimize-sdk-internal/compare/v12.2.0...v13.0.0) (2021-11-24)
|
|
37
|
-
|
|
38
|
-
### ⚠ BREAKING CHANGES
|
|
39
|
-
|
|
40
|
-
- **npm:** Bundled ESM exports from npm packages have changed internal package structure
|
|
41
|
-
- **npm:** npm package files are now transpiled to target ES2018 instead of ES5, significantly reducing their size
|
|
42
|
-
|
|
43
|
-
### Features
|
|
44
|
-
|
|
45
|
-
- **npm:** update package build system for better ESM compatibility ([d66f998](https://github.com/uniformdev/optimize-sdk-internal/commit/d66f998e30e186dbe7886a9d4197c49a8b25b89c))
|
|
46
|
-
|
|
47
|
-
## [12.2.0](https://github.com/uniformdev/optimize-sdk-internal/compare/v12.0.0...v12.2.0) (2021-10-28)
|
|
48
|
-
|
|
49
|
-
### Features
|
|
50
|
-
|
|
51
|
-
- **canvas-vue:** add vetur support to canvas-vue package ([f4d6a28](https://github.com/uniformdev/optimize-sdk-internal/commit/f4d6a2831b436de432904b154555c27802e88731))
|
|
52
|
-
|
|
53
|
-
### Bug Fixes
|
|
54
|
-
|
|
55
|
-
- add conditional check for uniformOptimizeContext to prevent application error if the module was not installed ([0e91900](https://github.com/uniformdev/optimize-sdk-internal/commit/0e919002048c66ee5cb038c05f299ca46e0c4436))
|
|
56
|
-
|
|
57
|
-
## [12.0.0](https://github.com/uniformdev/optimize-sdk-internal/compare/v11.0.0...v12.0.0) (2021-10-05)
|
|
58
|
-
|
|
59
|
-
### ⚠ BREAKING CHANGES
|
|
60
|
-
|
|
61
|
-
- **canvas:** everything that was named 'UPM' at all is now equivalently titled 'Canvas' or 'CANVAS' depending on the context. Literally everything.
|
|
62
|
-
|
|
63
|
-
### Features
|
|
64
|
-
|
|
65
|
-
- **canvas:** farewell UPM, we hardly knew ye ([00997ae](https://github.com/uniformdev/optimize-sdk-internal/commit/00997aecd388403a0b98d0a919750b994d3794c1))
|