@uniformdev/canvas 17.5.1-alpha.7 → 17.6.1-alpha.106
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/chunk-PVRSC7Y6.mjs +4 -0
- package/dist/cli/cli.d.ts +1 -1
- package/dist/cli/cli.js +41 -41
- package/dist/cli/cli.mjs +36 -36
- package/dist/{createEventBus-ae757f10.d.ts → createEventBus-bb2f5866.d.ts} +758 -781
- package/dist/index.d.ts +464 -426
- package/dist/index.esm.js +1 -1
- package/dist/index.js +2 -2
- package/dist/index.mjs +1 -1
- package/package.json +6 -6
- package/dist/chunk-3DNK2OLJ.mjs +0 -4
@@ -0,0 +1,4 @@
|
|
1
|
+
var ae=Object.create;var _=Object.defineProperty;var pe=Object.getOwnPropertyDescriptor;var ce=Object.getOwnPropertyNames;var me=Object.getPrototypeOf,le=Object.prototype.hasOwnProperty;var ue=(t,e,n)=>e in t?_(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n;var Se=(t=>typeof require!="undefined"?require:typeof Proxy!="undefined"?new Proxy(t,{get:(e,n)=>(typeof require!="undefined"?require:e)[n]}):t)(function(t){if(typeof require!="undefined")return require.apply(this,arguments);throw new Error('Dynamic require of "'+t+'" is not supported')});var Oe=(t,e)=>()=>(t&&(e=t(t=0)),e);var I=(t,e)=>()=>(e||t((e={exports:{}}).exports,e),e.exports),De=(t,e)=>{for(var n in e)_(t,n,{get:e[n],enumerable:!0})},U=(t,e,n,o)=>{if(e&&typeof e=="object"||typeof e=="function")for(let r of ce(e))!le.call(t,r)&&r!==n&&_(t,r,{get:()=>e[r],enumerable:!(o=pe(e,r))||o.enumerable});return t};var de=(t,e,n)=>(n=t!=null?ae(me(t)):{},U(e||!t||!t.__esModule?_(n,"default",{value:t,enumerable:!0}):n,t)),be=t=>U(_({},"__esModule",{value:!0}),t);var Me=(t,e,n)=>(ue(t,typeof e!="symbol"?e+"":e,n),n),j=(t,e,n)=>{if(!e.has(t))throw TypeError("Cannot "+n)};var x=(t,e,n)=>(j(t,e,"read from private field"),n?n.call(t):e.get(t)),V=(t,e,n)=>{if(e.has(t))throw TypeError("Cannot add the same private member more than once");e instanceof WeakSet?e.add(t):e.set(t,n)},he=(t,e,n,o)=>(j(t,e,"write to private field"),o?o.call(t,n):e.set(t,n),n),Ne=(t,e,n,o)=>({set _(r){he(t,e,r,n)},get _(){return x(t,e,o)}});var F=I((Be,$)=>{function g(t,e){typeof e=="boolean"&&(e={forever:e}),this._originalTimeouts=JSON.parse(JSON.stringify(t)),this._timeouts=t,this._options=e||{},this._maxRetryTime=e&&e.maxRetryTime||1/0,this._fn=null,this._errors=[],this._attempts=1,this._operationTimeout=null,this._operationTimeoutCb=null,this._timeout=null,this._operationStart=null,this._timer=null,this._options.forever&&(this._cachedTimeouts=this._timeouts.slice(0))}$.exports=g;g.prototype.reset=function(){this._attempts=1,this._timeouts=this._originalTimeouts.slice(0)};g.prototype.stop=function(){this._timeout&&clearTimeout(this._timeout),this._timer&&clearTimeout(this._timer),this._timeouts=[],this._cachedTimeouts=null};g.prototype.retry=function(t){if(this._timeout&&clearTimeout(this._timeout),!t)return!1;var e=new Date().getTime();if(t&&e-this._operationStart>=this._maxRetryTime)return this._errors.push(t),this._errors.unshift(new Error("RetryOperation timeout occurred")),!1;this._errors.push(t);var n=this._timeouts.shift();if(n===void 0)if(this._cachedTimeouts)this._errors.splice(0,this._errors.length-1),n=this._cachedTimeouts.slice(-1);else return!1;var o=this;return this._timer=setTimeout(function(){o._attempts++,o._operationTimeoutCb&&(o._timeout=setTimeout(function(){o._operationTimeoutCb(o._attempts)},o._operationTimeout),o._options.unref&&o._timeout.unref()),o._fn(o._attempts)},n),this._options.unref&&this._timer.unref(),!0};g.prototype.attempt=function(t,e){this._fn=t,e&&(e.timeout&&(this._operationTimeout=e.timeout),e.cb&&(this._operationTimeoutCb=e.cb));var n=this;this._operationTimeoutCb&&(this._timeout=setTimeout(function(){n._operationTimeoutCb()},n._operationTimeout)),this._operationStart=new Date().getTime(),this._fn(this._attempts)};g.prototype.try=function(t){console.log("Using RetryOperation.try() is deprecated"),this.attempt(t)};g.prototype.start=function(t){console.log("Using RetryOperation.start() is deprecated"),this.attempt(t)};g.prototype.start=g.prototype.try;g.prototype.errors=function(){return this._errors};g.prototype.attempts=function(){return this._attempts};g.prototype.mainError=function(){if(this._errors.length===0)return null;for(var t={},e=null,n=0,o=0;o<this._errors.length;o++){var r=this._errors[o],s=r.message,i=(t[s]||0)+1;t[s]=i,i>=n&&(e=r,n=i)}return e}});var k=I(P=>{var fe=F();P.operation=function(t){var e=P.timeouts(t);return new fe(e,{forever:t&&(t.forever||t.retries===1/0),unref:t&&t.unref,maxRetryTime:t&&t.maxRetryTime})};P.timeouts=function(t){if(t instanceof Array)return[].concat(t);var e={retries:10,factor:2,minTimeout:1*1e3,maxTimeout:1/0,randomize:!1};for(var n in t)e[n]=t[n];if(e.minTimeout>e.maxTimeout)throw new Error("minTimeout is greater than maxTimeout");for(var o=[],r=0;r<e.retries;r++)o.push(this.createTimeout(r,e));return t&&t.forever&&!o.length&&o.push(this.createTimeout(r,e)),o.sort(function(s,i){return s-i}),o};P.createTimeout=function(t,e){var n=e.randomize?Math.random()+1:1,o=Math.round(n*Math.max(e.minTimeout,1)*Math.pow(e.factor,t));return o=Math.min(o,e.maxTimeout),o};P.wrap=function(t,e,n){if(e instanceof Array&&(n=e,e=null),!n){n=[];for(var o in t)typeof t[o]=="function"&&n.push(o)}for(var r=0;r<n.length;r++){var s=n[r],i=t[s];t[s]=function(a){var d=P.operation(e),l=Array.prototype.slice.call(arguments,1),c=l.pop();l.push(function(u){d.retry(u)||(u&&(arguments[0]=d.mainError()),c.apply(this,arguments))}),d.attempt(function(){a.apply(t,l)})}.bind(t,i),t[s].options=e}}});var J=I((Ue,H)=>{H.exports=k()});import{ApiClient as Pe}from"@uniformdev/context/api";var W=de(J(),1),ye=new Set(["Failed to fetch","NetworkError when attempting to fetch resource.","The Internet connection appears to be offline.","Network request failed"]),w=class extends Error{constructor(e){super(),e instanceof Error?(this.originalError=e,{message:e}=e):(this.originalError=new Error(e),this.originalError.stack=this.stack),this.name="AbortError",this.message=e}},Ce=(t,e,n)=>{let o=n.retries-(e-1);return t.attemptNumber=e,t.retriesLeft=o,t},ge=t=>ye.has(t),z=t=>globalThis.DOMException===void 0?new Error(t):new DOMException(t);async function S(t,e){return new Promise((n,o)=>{e={onFailedAttempt(){},retries:10,...e};let r=W.default.operation(e);r.attempt(async s=>{try{n(await t(s))}catch(i){if(!(i instanceof Error)){o(new TypeError(`Non-error was thrown: "${i}". You should only throw errors.`));return}if(i instanceof w)r.stop(),o(i.originalError);else if(i instanceof TypeError&&!ge(i.message))r.stop(),o(i);else{Ce(i,s,e);try{await e.onFailedAttempt(i)}catch(p){o(p);return}r.retry(i)||o(r.mainError())}}}),e.signal&&!e.signal.aborted&&e.signal.addEventListener("abort",()=>{r.stop();let s=e.signal.reason===void 0?z("The operation was aborted."):e.signal.reason;o(s instanceof Error?s:z(s))},{once:!0})})}var O=class extends Error{constructor(){super("Throttled function aborted"),this.name="AbortError"}};function D({limit:t,interval:e,strict:n}){if(!Number.isFinite(t))throw new TypeError("Expected `limit` to be a finite number");if(!Number.isFinite(e))throw new TypeError("Expected `interval` to be a finite number");let o=new Map,r=0,s=0;function i(){let l=Date.now();return l-r>e?(s=1,r=l,0):(s<t?s++:(r+=e,s=1),r-l)}let p=[];function a(){let l=Date.now();if(p.length<t)return p.push(l),0;let c=p.shift()+e;return l>=c?(p.push(l),0):(p.push(c),c-l)}let d=n?a:i;return l=>{let c=function(...u){if(!c.isEnabled)return(async()=>l.apply(this,u))();let f;return new Promise((C,m)=>{f=setTimeout(()=>{C(l.apply(this,u)),o.delete(f)},d()),o.set(f,m)})};return c.abort=()=>{for(let u of o.keys())clearTimeout(u),o.get(u)(new O);o.clear(),p.splice(0,p.length)},c.isEnabled=!0,c}}function Z({throttle:t={interval:1e3,limit:10},retry:e={retries:1,factor:1.66}}){let n=t?D(t):null;return function(r){let s=async()=>await r();if(n&&(s=n(s)),e){let i=s;s=()=>S(i,e)}return s()}}var E=async t=>await t();var b=class extends Pe{constructor(n){n.limitPolicy||(n.limitPolicy=Z({}));super(n);this.canvasUrl="/api/v1/canvas"}async getCompositionList(n){let{projectId:o}=this.options,r=this.createUrl(this.canvasUrl,{...n,projectId:o});return await this.apiClient(r)}unstable_getCompositionByNodePath(n){return this.getOneComposition(n)}unstable_getCompositionByNodeId(n){return this.getOneComposition(n)}getCompositionBySlug(n){return this.getOneComposition(n)}getCompositionById(n){return this.getOneComposition(n)}getOneComposition({unstable_resolveData:n,unstable_dynamicVariables:o,unstable_dataDiagnostics:r,...s}){let{projectId:i}=this.options,p=n?"/api/edge/v1/composition":this.canvasUrl,a={};return n&&(o&&(a.dynamicVariables=JSON.stringify(o)),r&&(a.dataDiagnostics="true")),this.apiClient(this.createUrl(p,{...s,...a,projectId:i}))}async updateComposition(n){let o=this.createUrl("/api/v1/canvas");await this.apiClient(o,{method:"PUT",body:JSON.stringify({...n,projectId:this.options.projectId}),expectNoContent:!0})}async removeComposition(n){let o=this.createUrl("/api/v1/canvas"),{projectId:r}=this.options;await this.apiClient(o,{method:"DELETE",body:JSON.stringify({...n,projectId:r}),expectNoContent:!0})}async getComponentDefinitions(n){let{projectId:o}=this.options,r=this.createUrl("/api/v1/canvas-definitions",{...n,projectId:o});return await this.apiClient(r)}async updateComponentDefinition(n){let o=this.createUrl("/api/v1/canvas-definitions");await this.apiClient(o,{method:"PUT",body:JSON.stringify({...n,projectId:this.options.projectId}),expectNoContent:!0})}async removeComponentDefinition(n){let o=this.createUrl("/api/v1/canvas-definitions");await this.apiClient(o,{method:"DELETE",body:JSON.stringify({...n,projectId:this.options.projectId}),expectNoContent:!0})}},Y=class extends b{constructor(e){super({...e,bypassCache:!0})}};import{ApiClient as Ee}from"@uniformdev/context/api";var M="/api/v1/data-source",Te="/api/v1/data-sources",q=class extends Ee{constructor(e){super(e)}async get(e){let{projectId:n}=this.options,o=this.createUrl(M,{...e,projectId:n});return await this.apiClient(o)}async getList(e){let{projectId:n}=this.options,o=this.createUrl(Te,{...e,projectId:n});return await this.apiClient(o)}async upsert(e){let n=this.createUrl(M);await this.apiClient(n,{method:"PUT",body:JSON.stringify({...e,projectId:this.options.projectId}),expectNoContent:!0})}async remove(e){let n=this.createUrl(M);await this.apiClient(n,{method:"DELETE",body:JSON.stringify({...e,projectId:this.options.projectId}),expectNoContent:!0})}};import{ApiClient as _e}from"@uniformdev/context/api";var T,v=class extends _e{constructor(e){super(e)}async get(e){let{projectId:n}=this.options,o=this.createUrl(x(v,T),{...e,projectId:n});return await this.apiClient(o)}async upsert(e){let n=this.createUrl(x(v,T));await this.apiClient(n,{method:"PUT",body:JSON.stringify({...e,projectId:this.options.projectId}),expectNoContent:!0})}async remove(e){let n=this.createUrl(x(v,T));await this.apiClient(n,{method:"DELETE",body:JSON.stringify({...e,projectId:this.options.projectId}),expectNoContent:!0})}},N=v;T=new WeakMap,V(N,T,"/api/v1/data-types");var G=class{constructor(e,n,o){this._resolve=e;this._reject=n;this.args=o;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 st({handleBatch:t,shouldQueue:e,limitPolicy:n}){let o=[];return{enhanceOne:async i=>{if(!e||e(i))return new Promise((p,a)=>{o.push(new G(p,a,i))})},completeAll:async()=>{if(o.length>0){try{await t(o)}catch(p){o.forEach(a=>a.reject(p))}if(o.some(p=>!p.isCompleted))throw new Error("The completeAll() function failed to resolve or reject all promises in the batch!")}let i=o.length;return o=[],i},limitPolicy:n}}var at=(t,...e)=>({enhanceOne:o=>{let r="enhanceOne"in t?t.enhanceOne(o):t(o);for(let s of e){let i=xe(r)?r:Promise.resolve(r),p="enhanceOne"in s?s.enhanceOne:s;r=i.then(a=>p({...o,parameter:{type:o.parameter.type,value:a}}))}return r},completeAll:async()=>{var o,r;for(let s of e)if("completeAll"in s)throw new Error("Only the first enhancer in a compose chain can use the completeAll function (batching)");return(r="completeAll"in t?(o=t.completeAll)==null?void 0:o.call(t):0)!=null?r:0}});function xe(t){return!!t&&(typeof t=="object"||typeof t=="function")&&typeof t.then=="function"}function A(t,e,n){var s;let o=[{ancestorsAndSelf:[{component:t,parentSlot:void 0,parentSlotIndex:void 0}],context:n}],r=new Map;do{let i=o.pop();if(!i)continue;let p=i.ancestorsAndSelf[0],a=!0,d=(s=r.get(p.component))!=null?s:i.context;e(p.component,i.ancestorsAndSelf,{replaceComponent:c=>{Object.assign(p.component,c),["parameters","variant","slots","data","_pattern","_patternError"].forEach(f=>{c[f]||delete p.component[f]})},removeComponent:()=>{let{parentSlot:c,parentSlotIndex:u}=i.ancestorsAndSelf[0],f=i.ancestorsAndSelf[1];if(c&&typeof u!="undefined")f.component.slots[c].splice(u,1);else throw new Error("Unable to delete composition.")},insertAfter:c=>{let u=Array.isArray(c)?c:[c],{parentSlot:f,parentSlotIndex:C}=i.ancestorsAndSelf[0],m=i.ancestorsAndSelf[1];if(f&&typeof C!="undefined")m.component.slots[f].splice(C+1,0,...u),o.unshift(...u.map(h=>({ancestorsAndSelf:[{component:h,parentSlot:f,get parentSlotIndex(){return m.component.slots[f].findIndex(y=>y===h)}},...i.ancestorsAndSelf],context:d})));else throw new Error("Unable to insert after a component not in a slot.")},stopProcessingDescendants(){a=!1},setDescendantsContext(c){d=c},setChildContext(c,u){r.set(c,u)}},d);let l=p.component.slots;if(a&&l){let c=Object.keys(l);for(let u=c.length-1;u>=0;u--){let f=c[u],C=l[f];for(let m=C.length-1;m>=0;m--){let h=C[m];o.push({ancestorsAndSelf:[{component:h,parentSlot:f,get parentSlotIndex(){return p.component.slots[f].findIndex(y=>y===h)}},...i.ancestorsAndSelf],context:d})}}}}while(o.length>0)}function B(t){let e=[];for(let n=t.length-1;n>=0;n--){let{parentSlot:o,parentSlotIndex:r}=t[n];o&&r!==void 0&&e.push(`${o}[${r}]`)}return`.${e.join(".")}`}function ct(t,{withSlots:e=!1}={}){let n=[];for(let o=t.length-1;o>=0;o--){let{parentSlot:r,parentSlotIndex:s}=t[o];r&&s!==void 0&&n.push(`${r}/${s}`)}return e?`/slots/${n.join("/slots/")}`:`/${n.join("/")}`}async function ht({composition:t,enhancers:e,context:n,onErrors:o=r=>{throw new Error(r.map(s=>`${s.message}
|
2
|
+
${typeof s.error=="object"&&"stack"in s.error?s.error.stack:s.error}`).join(`
|
3
|
+
|
4
|
+
`))}}){let r=[],s=new Set,i=new Set;A(t,(a,d)=>{var c;Object.entries((c=a.parameters)!=null?c:{}).forEach(([u,f])=>{let C=e.resolveParameterEnhancer(a,u,f);C&&(i.add(C),r.push(Ae(a,d,u,f,C,n)))});let l=e.resolveComponentEnhancers(a);r.push(ve(a,d,l,n)),s.add(l)}),r.push(...Array.from(s).flatMap(a=>Array.from(a).map(async([,d])=>{var l;try{d.completeAll&&await((l=d.limitPolicy)!=null?l:E)(()=>d.completeAll())}catch(c){return{error:c,message:"Batch component enhancer failed. Individual failed components should receive their own rejections."}}}))),r.push(...Array.from(i).map(async a=>{var d;try{a.completeAll&&await((d=a.limitPolicy)!=null?d:E)(()=>a.completeAll())}catch(l){return{error:l,message:"Batch parameter enhancer failed. Individual failed parameters should receive their own rejections."}}}));let p=(await Promise.all(r)).flatMap(a=>Array.isArray(a)?a:[a]).filter(a=>a);p.length&&o(p)}async function ve(t,e,n,o){return n.size&&(t.data={}),await Promise.all(Array.from(n).map(async([r,s])=>{var i;try{let a=await(s.completeAll?E:(i=s.limitPolicy)!=null?i:E)(async()=>s.enhanceOne({component:t,context:o}));a!=null&&(t.data[r]=a)}catch(p){let a=`Component ${B(e)} (type: ${t.type}): data.${r} enhancer threw exception. Data key will not be present.`;return delete t.data[r],{message:a,error:p}}}))}async function Ae(t,e,n,o,r,s){var i;try{let a=await(r.completeAll?E:(i=r.limitPolicy)!=null?i:E)(async()=>r.enhanceOne({parameter:o,parameterName:n,component:t,context:s}));a===null?delete t.parameters[n]:typeof a=="undefined"?t.parameters[n]={...o,value:o.value}:t.parameters[n]={...o,value:a}}catch(p){let a=`Component ${B(e)} (type: ${t.type}): enhancing parameter ${n} (type: ${o.type}) threw exception. Parameter will be removed.`;return delete t.parameters[n],{message:a,error:p}}}var R=class{constructor(){this._paramMatches=Array();this._dataMatches=new Map}parameter(e){return this._paramMatches.push({enhancer:this._resolveParameterEnhancer(e)}),this}parameterName(e,n){return(Array.isArray(e)?e:[e]).forEach(r=>this._paramMatches.push({name:r,enhancer:this._resolveParameterEnhancer(n)})),this}parameterType(e,n){return(Array.isArray(e)?e:[e]).forEach(r=>this._paramMatches.push({type:r,enhancer:this._resolveParameterEnhancer(n)})),this}data(e,n){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 n=="function"?{enhanceOne:n}:n),this}resolveParameterEnhancer(e,n){var o;return(o=this._paramMatches.find(r=>r.name&&r.name===e||r.type&&r.type===n.type||!r.type&&!r.name))==null?void 0:o.enhancer}resolveComponentEnhancers(){return this._dataMatches}_resolveParameterEnhancer(e){return typeof e=="function"?{enhanceOne:e}:e}},Q=class{constructor(){this._componentIndex={};this._rootBuilder=new R}parameter(e){return this._rootBuilder.parameter(e),this}parameterName(e,n){return this._rootBuilder.parameterName(e,n),this}parameterType(e,n){return this._rootBuilder.parameterType(e,n),this}data(e,n){return this._rootBuilder.data(e,n),this}component(e,n){return(Array.isArray(e)?e:[e]).forEach(r=>{this._componentIndex[r]=this._componentIndex[r]||new R,n(this._componentIndex[r])}),this}resolveParameterEnhancer(e,n,o){let r=this._componentIndex[e.type];if(r){let s=r.resolveParameterEnhancer(n,o);if(s)return s}return this._rootBuilder.resolveParameterEnhancer(n,o)}resolveComponentEnhancers(e){let n=this._rootBuilder.resolveComponentEnhancers(),o=this._componentIndex[e.type];if(o){n=new Map(n);for(let[r,s]of o.resolveComponentEnhancers())n.set(r,s)}return n}};var Ct="$personalization",gt="$test",X="$localization",Pt="intentTag",K="locale",Et="pz",Tt="test",ee="localized",_t=0,xt=64,te="$pzCrit",ne="$tstVrnt",vt="$enr",At="is_incontext_editing_mode",Rt="uniform-component-start",It="placeholder",wt=15,St=600,Ot=30,Dt=-1,bt=1,Mt=672,Nt=24;function Re({component:t}){var o;let e={},n=(o=t.slots)==null?void 0:o[ee];return n==null||n.forEach(r=>{var i;let s=(i=r.parameters)==null?void 0:i[K];(s==null?void 0:s.value)&&typeof s.value=="string"&&(e[s.value]=e[s.value]||[],e[s.value].push(r))}),e}function Ut({composition:t,locale:e}){A(t,(n,o,r)=>{if(n.type===X){let s=Re({component:n}),i=typeof e=="string"?e:e({component:n,locales:s}),p;if(i&&(p=s[i]),p!=null&&p.length){let[a,...d]=p;r.replaceComponent(a),d.length&&r.insertAfter(d)}else r.removeComponent()}})}var oe=class{constructor(e,n){this.groups=e.reduce((o,r)=>{var i;let s=n(r.args);return o[s]=(i=o[s])!=null?i:[],o[s].push(r),o},{})}resolveKey(e,n){this.groups[e].forEach(o=>o.resolve(n))}resolveRemaining(e){Object.keys(this.groups).forEach(n=>{this.groups[n].forEach(o=>{o.isCompleted||o.resolve(e)})})}};var re=({composition:t,secret:e})=>{if(!e)return;let n=`${JSON.stringify(t)}-${e}`,o=0;for(let r=0;r<n.length;r++){let s=n.charCodeAt(r);o=(o<<5)-o+s,o|=0}return o};var kt=t=>t.type==="select-component"&&t.id!==void 0,Ht=t=>t.type==="ready",Jt=t=>t.type==="update-composition",zt=t=>t.type==="add-component",Wt=t=>t.type==="move-component",Zt=t=>t.type==="dismiss-placeholder",Yt=({listenTo:t,broadcastTo:e})=>{let n=0,o={},r=[...e],s=m=>{r.forEach(h=>h.postMessage(JSON.stringify(m),"*"))},i=m=>{s({type:"select-component",id:m})},p=()=>{s({type:"ready"})},a=(m,h)=>{let y=++n;return o[y]={types:Array.isArray(m)?m:[m],handler:h},()=>{delete o[y]}},d=(m,h)=>{let y={type:"update-composition",composition:m,hash:re({composition:m,secret:h})};s(y)},l=m=>{let h={...m,type:"add-component"};s(h)},c=m=>{let h={...m,type:"move-component"};s(h)},u=m=>{let h={...m,type:"dismiss-placeholder"};s(h)},f=m=>{if(typeof m.data!="string"||m.source===window)return;let h=null;try{let y=JSON.parse(m.data);Object.hasOwn(y,"type")&&(h=y)}catch(y){}if(!!h)for(let y in o){let L=o[y];L.types.includes(h.type)&&L.handler(h,m)}};return t.forEach(m=>m.addEventListener("message",f)),{ready:p,destroy:()=>{t.forEach(m=>m.removeEventListener("message",f))},selectComponent:i,updateComposition:d,on:a,addComponent:l,moveComponent:c,dismissPlaceholder:u}};var se="https://js.pusher.com/7.0.3/pusher.min.js";async function Ie(){if(!(typeof document=="undefined"||typeof window=="undefined"))return window.Pusher?window.Pusher:new Promise((t,e)=>{let n=setTimeout(()=>{window.Pusher&&t(window.Pusher),e(`Unable to load pusher.js; Uniform Canvas live preview disabled. Consider adding <script src="${se}"><\/script> manually.`)},5e3),o=document.createElement("script");o.src=se,o.addEventListener("load",()=>{clearTimeout(n),t(window.Pusher)}),document.head.appendChild(o)})}async function Qt(){let t=await Ie();if(!t)return;let e=window.__UNIFORM_EVENT_BUS__;if(!e){let n=new t("7b5f5abd160fea549ffe",{cluster:"mt1"});n.connect(),console.log("[canvas] \u{1F525} preview connected"),e=window.__UNIFORM_EVENT_BUS__={subscribe:o=>{let r=n.subscribe(o);return{unsubscribe:()=>n.unsubscribe(o),addEventHandler:(s,i)=>(r.bind(s,i),()=>r.unbind(s,i))}}}}return e}function ie(t,e,n){return`${t}.${e}@${n}`}function tn({projectId:t,compositionId:e,compositionState:n=0,eventBus:{subscribe:o},callback:r,event:s="updated"}){let i=ie(t,e,n),p=o(i),a=p.addEventHandler(s,r);return()=>{a(),p.unsubscribe()}}var on=t=>t.startsWith("$");function an(t){return t?t.map((e,n)=>{var s,i;let o=(i=(s=e.parameters)==null?void 0:s[te])==null?void 0:i.value,r=(o==null?void 0:o.name)||`pz-${n}-${e.type}`;return{...e,id:r,pz:o}}):[]}function mn(t){return t?t.map((e,n)=>{var s,i,p;let o=(i=(s=e.parameters)==null?void 0:s[ne])==null?void 0:i.value,r=(p=o==null?void 0:o.id)!=null?p:"testId"in e?e.testId:`ab-${n}-${e.type}`;return{...e,id:r}}):[]}import{ApiClientError as we}from"@uniformdev/context/api";var dn=we;export{Se as a,Oe as b,I as c,De as d,de as e,be as f,Me as g,x as h,V as i,he as j,Ne as k,Z as l,E as m,b as n,Y as o,q as p,N as q,G as r,st as s,at as t,A as u,B as v,ct as w,ht as x,R as y,Q as z,Ct as A,gt as B,X as C,Pt as D,K as E,Et as F,Tt as G,ee as H,_t as I,xt as J,te as K,ne as L,vt as M,At as N,Rt as O,It as P,wt as Q,St as R,Ot as S,Dt as T,bt as U,Mt as V,Nt as W,Re as X,Ut as Y,oe as Z,re as _,kt as $,Ht as aa,Jt as ba,zt as ca,Wt as da,Zt as ea,Yt as fa,Qt as ga,ie as ha,tn as ia,on as ja,an as ka,mn as la,we as ma,dn as na};
|
package/dist/cli/cli.d.ts
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
import { UniformCLIPlugin } from '@uniformdev/cli';
|
2
|
-
import { $ as CanvasDefinitions } from '../createEventBus-ae757f10.js';
|
3
2
|
import { UniformPackage } from '@uniformdev/cli/sync';
|
3
|
+
import { a1 as CanvasDefinitions } from '../createEventBus-bb2f5866.js';
|
4
4
|
import 'pusher-js';
|
5
5
|
|
6
6
|
declare type CanvasPackage = UniformPackage & CanvasDefinitions;
|