@uniformdev/canvas
Advanced tools
Comparing version 16.1.1-alpha.281 to 16.1.1-alpha.294
import { UniformCLIPlugin } from '@uniformdev/cli'; | ||
import { p as ComponentDefinition, d as CompositionAPIResponse } from '../createEventBus-d04d4bc7.js'; | ||
import { o as ComponentDefinition, d as CompositionAPIResponse } from '../createEventBus-a6696d11.js'; | ||
import { UniformPackage } from '@uniformdev/cli/sync'; | ||
@@ -4,0 +4,0 @@ import 'pusher-js'; |
@@ -1,3 +0,3 @@ | ||
import { C as ComponentInstance, a as ComponentParameter, b as CompositionAPIOptions, c as CompositionListAPIResponse, d as CompositionAPIResponse, e as CompositionAPIPutRequest, f as CompositionAPIDeleteRequest, g as ComponentDefinitionListAPIOptions, h as ComponentDefinitionAPIResponse, i as ComponentDefinitionAPIPutRequest, j as ComponentDefinitionAPIDeleteRequest, P as PreviewEventBus } from './createEventBus-d04d4bc7.js'; | ||
export { t as ChannelSubscription, p as ComponentDefinition, j as ComponentDefinitionAPIDeleteRequest, i as ComponentDefinitionAPIPutRequest, h as ComponentDefinitionAPIResponse, g as ComponentDefinitionListAPIOptions, k as ComponentDefinitionParameter, o as ComponentDefinitionPermission, n as ComponentDefinitionSlot, m as ComponentDefinitionSlugSettings, l as ComponentDefinitionVariant, C as ComponentInstance, a as ComponentParameter, f as CompositionAPIDeleteRequest, b as CompositionAPIOptions, e as CompositionAPIPutRequest, d as CompositionAPIResponse, r as CompositionFetchState, c as CompositionListAPIResponse, q as CreatingComponentDefinition, P as PreviewEventBus, s as RequestComponentInstance, R as RootComponentInstance, u as createEventBus } from './createEventBus-d04d4bc7.js'; | ||
import { C as ComponentInstance, a as ComponentParameter, b as CompositionAPIOptions, c as CompositionListAPIResponse, d as CompositionAPIResponse, e as CompositionAPIDeleteRequest, f as ComponentDefinitionListAPIOptions, g as ComponentDefinitionAPIResponse, h as ComponentDefinitionAPIPutRequest, i as ComponentDefinitionAPIDeleteRequest, P as PreviewEventBus } from './createEventBus-a6696d11.js'; | ||
export { r as ChannelSubscription, o as ComponentDefinition, i as ComponentDefinitionAPIDeleteRequest, h as ComponentDefinitionAPIPutRequest, g as ComponentDefinitionAPIResponse, f as ComponentDefinitionListAPIOptions, j as ComponentDefinitionParameter, n as ComponentDefinitionPermission, m as ComponentDefinitionSlot, l as ComponentDefinitionSlugSettings, k as ComponentDefinitionVariant, C as ComponentInstance, a as ComponentParameter, e as CompositionAPIDeleteRequest, b as CompositionAPIOptions, d as CompositionAPIResponse, q as CompositionFetchState, c as CompositionListAPIResponse, p as CreatingComponentDefinition, P as PreviewEventBus, R as RootComponentInstance, s as createEventBus } from './createEventBus-a6696d11.js'; | ||
import { Options } from 'p-throttle'; | ||
@@ -286,3 +286,3 @@ import { Options as Options$1 } from 'p-retry'; | ||
/** Updates or creates a Canvas component definition */ | ||
updateComposition(body: Omit<CompositionAPIPutRequest, 'projectId'>): Promise<void>; | ||
updateComposition(body: Omit<CompositionAPIResponse, 'projectId'>): Promise<void>; | ||
/** Deletes a Canvas component definition */ | ||
@@ -289,0 +289,0 @@ removeComposition(body: Omit<CompositionAPIDeleteRequest, 'projectId'>): Promise<void>; |
@@ -1,4 +0,4 @@ | ||
import{d as L,e as l,f as $,g as j,h as k,i as F,j as A,k as V,l as g,m as N,n as U,o as v,p as z,q as W,r as x,s as T,t as H}from"./chunk-TXMBPWVJ.mjs";function u(o,e){let t=[{ancestorsAndSelf:[{component:o,parentSlot:void 0,parentSlotIndex:void 0}]}];do{let n=t.pop();if(!n)continue;let r=n.ancestorsAndSelf[0];e(r.component,n.ancestorsAndSelf,{replaceComponent:i=>{Object.assign(r.component,i),["parameters","variant","slots","data","_pattern","_patternError"].forEach(s=>{i[s]||delete r.component[s]})},removeComponent:()=>{let{parentSlot:i,parentSlotIndex:c}=n.ancestorsAndSelf[0],s=n.ancestorsAndSelf[1];if(i&&typeof c!="undefined")s.component.slots[i].splice(c,1);else throw new Error("Unable to delete composition.")},insertAfter:i=>{let c=Array.isArray(i)?i:[i],{parentSlot:s,parentSlotIndex:p}=n.ancestorsAndSelf[0],m=n.ancestorsAndSelf[1];if(s&&typeof p!="undefined")m.component.slots[s].splice(p+1,0,...c);else throw new Error("Unable to insert after a component not in a slot.")}});let a=r.component.slots;if(a){let i=Object.keys(a);for(let c=i.length-1;c>=0;c--){let s=i[c],p=a[s];for(let m=p.length-1;m>=0;m--)t.push({ancestorsAndSelf:[{component:p[m],parentSlot:s,parentSlotIndex:m},...n.ancestorsAndSelf]})}}}while(t.length>0)}function y(o){let e=[];for(let t=o.length-1;t>=0;t--){let{parentSlot:n,parentSlotIndex:r}=o[t];n&&r!==void 0&&e.push(`${n}[${r}]`)}return`.${e.join(".")}`}var w=class{constructor(e,t){this.groups=e.reduce((n,r)=>{var i;let a=t(r.args);return n[a]=(i=n[a])!=null?i:[],n[a].push(r),n},{})}resolveKey(e,t){this.groups[e].forEach(n=>n.resolve(t))}resolveRemaining(e){Object.keys(this.groups).forEach(t=>{this.groups[t].forEach(n=>{n.isCompleted||n.resolve(e)})})}};var d=class{constructor(){this._paramMatches=Array();this._dataMatches=new Map}parameter(e){return this._paramMatches.push({enhancer:this._resolveParameterEnhancer(e)}),this}parameterName(e,t){return(Array.isArray(e)?e:[e]).forEach(r=>this._paramMatches.push({name:r,enhancer:this._resolveParameterEnhancer(t)})),this}parameterType(e,t){return(Array.isArray(e)?e:[e]).forEach(r=>this._paramMatches.push({type:r,enhancer:this._resolveParameterEnhancer(t)})),this}data(e,t){if(this._dataMatches.has(e))throw new Error(`${e} enhancer data key has been used more than once. This will cause data loss.`);return this._dataMatches.set(e,typeof t=="function"?{enhanceOne:t}:t),this}resolveParameterEnhancer(e,t){var n;return(n=this._paramMatches.find(r=>r.name&&r.name===e||r.type&&r.type===t.type||!r.type&&!r.name))==null?void 0:n.enhancer}resolveComponentEnhancers(){return this._dataMatches}_resolveParameterEnhancer(e){return typeof e=="function"?{enhanceOne:e}:e}},_=class{constructor(){this._componentIndex={};this._rootBuilder=new d}parameter(e){return this._rootBuilder.parameter(e),this}parameterName(e,t){return this._rootBuilder.parameterName(e,t),this}parameterType(e,t){return this._rootBuilder.parameterType(e,t),this}data(e,t){return this._rootBuilder.data(e,t),this}component(e,t){return(Array.isArray(e)?e:[e]).forEach(r=>{this._componentIndex[r]=this._componentIndex[r]||new d,t(this._componentIndex[r])}),this}resolveParameterEnhancer(e,t,n){let r=this._componentIndex[e.type];if(r){let a=r.resolveParameterEnhancer(t,n);if(a)return a}return this._rootBuilder.resolveParameterEnhancer(t,n)}resolveComponentEnhancers(e){let t=this._rootBuilder.resolveComponentEnhancers(),n=this._componentIndex[e.type];if(n){t=new Map(t);for(let[r,a]of n.resolveComponentEnhancers())t.set(r,a)}return t}};var C=class{constructor(e,t,n){this._resolve=e;this._reject=t;this.args=n;this._isCompleted=!1}resolve(e){this._resolve(e),this._isCompleted=!0}reject(e){this._reject(e),this._isCompleted=!0}get isCompleted(){return this._isCompleted}};function D({handleBatch:o,shouldQueue:e,limitPolicy:t}){let n=[];return{enhanceOne:async i=>{if(!e||e(i))return new Promise((c,s)=>{n.push(new C(c,s,i))})},completeAll:async()=>{if(n.length>0){try{await o(n)}catch(c){n.forEach(s=>s.reject(c))}if(n.some(c=>!c.isCompleted))throw new Error("The completeAll() function failed to resolve or reject all promises in the batch!")}let i=n.length;return n=[],i},limitPolicy:t}}async function X({composition:o,enhancers:e,context:t,onErrors:n=r=>{throw new Error(r.map(a=>`${a.message} | ||
import{d as L,e as l,f as $,g as j,h as k,i as F,j as A,k as V,l as g,m as N,n as U,o as v,p as z,q as W,r as x,s as T,t as H}from"./chunk-ADDR7SB6.mjs";function u(o,e){let t=[{ancestorsAndSelf:[{component:o,parentSlot:void 0,parentSlotIndex:void 0}]}];do{let n=t.pop();if(!n)continue;let r=n.ancestorsAndSelf[0];e(r.component,n.ancestorsAndSelf,{replaceComponent:i=>{Object.assign(r.component,i),["parameters","variant","slots","data","_pattern","_patternError"].forEach(s=>{i[s]||delete r.component[s]})},removeComponent:()=>{let{parentSlot:i,parentSlotIndex:c}=n.ancestorsAndSelf[0],s=n.ancestorsAndSelf[1];if(i&&typeof c!="undefined")s.component.slots[i].splice(c,1);else throw new Error("Unable to delete composition.")},insertAfter:i=>{let c=Array.isArray(i)?i:[i],{parentSlot:s,parentSlotIndex:p}=n.ancestorsAndSelf[0],m=n.ancestorsAndSelf[1];if(s&&typeof p!="undefined")m.component.slots[s].splice(p+1,0,...c);else throw new Error("Unable to insert after a component not in a slot.")}});let a=r.component.slots;if(a){let i=Object.keys(a);for(let c=i.length-1;c>=0;c--){let s=i[c],p=a[s];for(let m=p.length-1;m>=0;m--)t.push({ancestorsAndSelf:[{component:p[m],parentSlot:s,parentSlotIndex:m},...n.ancestorsAndSelf]})}}}while(t.length>0)}function y(o){let e=[];for(let t=o.length-1;t>=0;t--){let{parentSlot:n,parentSlotIndex:r}=o[t];n&&r!==void 0&&e.push(`${n}[${r}]`)}return`.${e.join(".")}`}var w=class{constructor(e,t){this.groups=e.reduce((n,r)=>{var i;let a=t(r.args);return n[a]=(i=n[a])!=null?i:[],n[a].push(r),n},{})}resolveKey(e,t){this.groups[e].forEach(n=>n.resolve(t))}resolveRemaining(e){Object.keys(this.groups).forEach(t=>{this.groups[t].forEach(n=>{n.isCompleted||n.resolve(e)})})}};var d=class{constructor(){this._paramMatches=Array();this._dataMatches=new Map}parameter(e){return this._paramMatches.push({enhancer:this._resolveParameterEnhancer(e)}),this}parameterName(e,t){return(Array.isArray(e)?e:[e]).forEach(r=>this._paramMatches.push({name:r,enhancer:this._resolveParameterEnhancer(t)})),this}parameterType(e,t){return(Array.isArray(e)?e:[e]).forEach(r=>this._paramMatches.push({type:r,enhancer:this._resolveParameterEnhancer(t)})),this}data(e,t){if(this._dataMatches.has(e))throw new Error(`${e} enhancer data key has been used more than once. This will cause data loss.`);return this._dataMatches.set(e,typeof t=="function"?{enhanceOne:t}:t),this}resolveParameterEnhancer(e,t){var n;return(n=this._paramMatches.find(r=>r.name&&r.name===e||r.type&&r.type===t.type||!r.type&&!r.name))==null?void 0:n.enhancer}resolveComponentEnhancers(){return this._dataMatches}_resolveParameterEnhancer(e){return typeof e=="function"?{enhanceOne:e}:e}},_=class{constructor(){this._componentIndex={};this._rootBuilder=new d}parameter(e){return this._rootBuilder.parameter(e),this}parameterName(e,t){return this._rootBuilder.parameterName(e,t),this}parameterType(e,t){return this._rootBuilder.parameterType(e,t),this}data(e,t){return this._rootBuilder.data(e,t),this}component(e,t){return(Array.isArray(e)?e:[e]).forEach(r=>{this._componentIndex[r]=this._componentIndex[r]||new d,t(this._componentIndex[r])}),this}resolveParameterEnhancer(e,t,n){let r=this._componentIndex[e.type];if(r){let a=r.resolveParameterEnhancer(t,n);if(a)return a}return this._rootBuilder.resolveParameterEnhancer(t,n)}resolveComponentEnhancers(e){let t=this._rootBuilder.resolveComponentEnhancers(),n=this._componentIndex[e.type];if(n){t=new Map(t);for(let[r,a]of n.resolveComponentEnhancers())t.set(r,a)}return t}};var C=class{constructor(e,t,n){this._resolve=e;this._reject=t;this.args=n;this._isCompleted=!1}resolve(e){this._resolve(e),this._isCompleted=!0}reject(e){this._reject(e),this._isCompleted=!0}get isCompleted(){return this._isCompleted}};function D({handleBatch:o,shouldQueue:e,limitPolicy:t}){let n=[];return{enhanceOne:async i=>{if(!e||e(i))return new Promise((c,s)=>{n.push(new C(c,s,i))})},completeAll:async()=>{if(n.length>0){try{await o(n)}catch(c){n.forEach(s=>s.reject(c))}if(n.some(c=>!c.isCompleted))throw new Error("The completeAll() function failed to resolve or reject all promises in the batch!")}let i=n.length;return n=[],i},limitPolicy:t}}async function X({composition:o,enhancers:e,context:t,onErrors:n=r=>{throw new Error(r.map(a=>`${a.message} | ||
${typeof a.error=="object"&&"stack"in a.error?a.error.stack:a.error}`).join(` | ||
`))}}){let r=[],a=new Set,i=new Set;u(o,(s,p)=>{var h;Object.entries((h=s.parameters)!=null?h:{}).forEach(([E,P])=>{let f=e.resolveParameterEnhancer(s,E,P);f&&(i.add(f),r.push(S(s,p,E,P,f,t)))});let m=e.resolveComponentEnhancers(s);r.push(R(s,p,m,t)),a.add(m)}),r.push(...Array.from(a).flatMap(s=>Array.from(s).map(async([,p])=>{var m;try{p.completeAll&&await((m=p.limitPolicy)!=null?m:l)(()=>p.completeAll())}catch(h){return{error:h,message:"Batch component enhancer failed. Individual failed components should receive their own rejections."}}}))),r.push(...Array.from(i).map(async s=>{var p;try{s.completeAll&&await((p=s.limitPolicy)!=null?p:l)(()=>s.completeAll())}catch(m){return{error:m,message:"Batch parameter enhancer failed. Individual failed parameters should receive their own rejections."}}}));let c=(await Promise.all(r)).flatMap(s=>Array.isArray(s)?s:[s]).filter(s=>s);c.length&&n(c)}async function R(o,e,t,n){return t.size&&(o.data={}),await Promise.all(Array.from(t).map(async([r,a])=>{var i;try{let s=await(a.completeAll?l:(i=a.limitPolicy)!=null?i:l)(async()=>a.enhanceOne({component:o,context:n}));s!=null&&(o.data[r]=s)}catch(c){let s=`Component ${y(e)} (type: ${o.type}): data.${r} enhancer threw exception. Data key will not be present.`;return delete o.data[r],{message:s,error:c}}}))}async function S(o,e,t,n,r,a){var i;try{let s=await(r.completeAll?l:(i=r.limitPolicy)!=null?i:l)(async()=>r.enhanceOne({parameter:n,parameterName:t,component:o,context:a}));s===null?delete o.parameters[t]:typeof s=="undefined"?o.parameters[t]={...n,value:n.value}:o.parameters[t]={...n,value:s}}catch(c){let s=`Component ${y(e)} (type: ${o.type}): enhancing parameter ${t} (type: ${n.type}) threw exception. Parameter will be removed.`;return delete o.parameters[t],{message:s,error:c}}}var ne=(o,...e)=>({enhanceOne:n=>{let r="enhanceOne"in o?o.enhanceOne(n):o(n);for(let a of e){let i=B(r)?r:Promise.resolve(r),c="enhanceOne"in a?a.enhanceOne:a;r=i.then(s=>c({...n,parameter:{type:n.parameter.type,value:s}}))}return r},completeAll:async()=>{var n,r;for(let a of e)if("completeAll"in a)throw new Error("Only the first enhancer in a compose chain can use the completeAll function (batching)");return(r="completeAll"in o?(n=o.completeAll)==null?void 0:n.call(o):0)!=null?r:0}});function B(o){return!!o&&(typeof o=="object"||typeof o=="function")&&typeof o.then=="function"}var re=o=>o.startsWith("$");function se(o){return o?o.map((e,t)=>{var a,i;let n=(i=(a=e.parameters)==null?void 0:a[x])==null?void 0:i.value,r="testId"in e?e.testId:`pz-${t}-${e.type}`;return{...e,id:r,pz:n}}):[]}function pe(o){return o?o.map((e,t)=>{var a,i,c;let n=(i=(a=e.parameters)==null?void 0:a[T])==null?void 0:i.value,r=(c=n==null?void 0:n.id)!=null?c:"testId"in e?e.testId:`ab-${t}-${e.type}`;return{...e,id:r}}):[]}var b="https://js.pusher.com/7.0.3/pusher.min.js";async function O(){if(!(typeof document=="undefined"||typeof window=="undefined"))return window.Pusher?window.Pusher:new Promise((o,e)=>{let t=setTimeout(()=>{window.Pusher&&o(window.Pusher),e(`Unable to load pusher.js; Uniform Canvas live preview disabled. Consider adding <script src="${b}"><\/script> manually.`)},5e3),n=document.createElement("script");n.src=b,n.addEventListener("load",()=>{clearTimeout(t),o(window.Pusher)}),document.head.appendChild(n)})}async function le(){let o=await O();if(!o)return;let e=window.__UNIFORM_EVENT_BUS__;if(!e){let t=new o("7b5f5abd160fea549ffe",{cluster:"mt1"});t.connect(),console.log("[canvas] \u{1F525} preview connected"),e=window.__UNIFORM_EVENT_BUS__={subscribe:n=>{let r=t.subscribe(n);return{unsubscribe:()=>t.unsubscribe(n),addEventHandler:(a,i)=>(r.bind(a,i),()=>r.unbind(a,i))}}}}return e}function I(o,e,t){return`${o}.${e}@${t}`}function fe({projectId:o,compositionId:e,compositionState:t=0,eventBus:{subscribe:n},callback:r,event:a="updated"}){let i=I(o,e,t),c=n(i),s=c.addEventHandler(a,r);return()=>{s(),c.unsubscribe()}}function M({component:o}){var n;let e={},t=(n=o.slots)==null?void 0:n[v];return t==null||t.forEach(r=>{var i;let a=(i=r.parameters)==null?void 0:i[g];(a==null?void 0:a.value)&&typeof a.value=="string"&&(e[a.value]=e[a.value]||[],e[a.value].push(r))}),e}function Pe({composition:o,locale:e}){u(o,(t,n,r)=>{if(t.type===A){let a=M({component:t}),i=typeof e=="string"?e:e({component:t,locales:a}),c;if(i&&(c=a[i]),c!=null&&c.length){let[s,...p]=c;r.replaceComponent(s),p.length&&r.insertAfter(p)}else r.removeComponent()}})}export{C as BatchEntry,z as CANVAS_DRAFT_STATE,H as CANVAS_ENRICHMENT_TAG_PARAM,V as CANVAS_INTENT_TAG_PARAM,g as CANVAS_LOCALE_TAG_PARAM,v as CANVAS_LOCALIZATION_SLOT,A as CANVAS_LOCALIZATION_TYPE,x as CANVAS_PERSONALIZATION_PARAM,N as CANVAS_PERSONALIZE_SLOT,k as CANVAS_PERSONALIZE_TYPE,W as CANVAS_PUBLISHED_STATE,U as CANVAS_TEST_SLOT,F as CANVAS_TEST_TYPE,T as CANVAS_TEST_VARIANT_PARAM,j as CanvasClient,$ as CanvasClientError,d as ChildEnhancerBuilder,_ as EnhancerBuilder,w as UniqueBatchEntries,ne as compose,D as createBatchEnhancer,le as createEventBus,L as createLimitPolicy,X as enhance,M as extractLocales,I as getChannelName,y as getComponentPath,re as isSystemComponentDefinition,Pe as localize,se as mapSlotToPersonalizedVariations,pe as mapSlotToTestVariations,l as nullLimitPolicy,fe as subscribeToComposition,u as walkComponentTree}; |
{ | ||
"name": "@uniformdev/canvas", | ||
"version": "16.1.1-alpha.281+1e3a525e6", | ||
"version": "16.1.1-alpha.294+787422ba9", | ||
"description": "Common functionality and types for Uniform Canvas", | ||
@@ -49,3 +49,3 @@ "license": "SEE LICENSE IN LICENSE.txt", | ||
"@types/yargs": "17.0.10", | ||
"@uniformdev/cli": "^16.1.1-alpha.281+1e3a525e6", | ||
"@uniformdev/cli": "^16.1.1-alpha.294+787422ba9", | ||
"pusher-js": "7.0.6", | ||
@@ -55,3 +55,3 @@ "yargs": "17.5.1" | ||
"dependencies": { | ||
"@uniformdev/context": "^16.1.1-alpha.281+1e3a525e6", | ||
"@uniformdev/context": "^16.1.1-alpha.294+787422ba9", | ||
"isomorphic-unfetch": "^3.1.0", | ||
@@ -68,3 +68,3 @@ "p-limit": "^3.1.0", | ||
}, | ||
"gitHead": "1e3a525e658169c20a3f3aa9f2603650543f1053" | ||
"gitHead": "787422ba907e4819d9d4243724c3c3286f3c9aed" | ||
} |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Manifest confusion
Supply chain riskThis package has inconsistent metadata. This could be malicious or caused by an error when publishing the package.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Manifest confusion
Supply chain riskThis package has inconsistent metadata. This could be malicious or caused by an error when publishing the package.
Found 1 instance in 1 package
434608
2325