@uniformdev/canvas 17.7.0 → 17.7.1-alpha.140
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 → chunk-TN3WBMTA.mjs} +1 -1
- package/dist/cli/cli.d.ts +2 -2
- package/dist/cli/cli.js +1 -1
- package/dist/cli/cli.mjs +1 -1
- package/dist/{createEventBus-bb2f5866.d.ts → createEventBus-025f310c.d.ts} +91 -133
- package/dist/index.d.ts +31 -39
- package/dist/index.esm.js +1 -1
- package/dist/index.js +1 -1
- package/dist/index.mjs +1 -1
- package/package.json +7 -7
@@ -1,4 +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}
|
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","fetch 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
2
|
${typeof s.error=="object"&&"stack"in s.error?s.error.stack:s.error}`).join(`
|
3
3
|
|
4
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,9 +1,9 @@
|
|
1
1
|
import { UniformCLIPlugin } from '@uniformdev/cli';
|
2
2
|
import { UniformPackage } from '@uniformdev/cli/sync';
|
3
|
-
import { a1 as CanvasDefinitions } from '../createEventBus-
|
3
|
+
import { a1 as CanvasDefinitions } from '../createEventBus-025f310c.js';
|
4
4
|
import 'pusher-js';
|
5
5
|
|
6
|
-
|
6
|
+
type CanvasPackage = UniformPackage & CanvasDefinitions;
|
7
7
|
declare function readCanvasPackage(filename: string, assertExists: boolean): CanvasPackage;
|
8
8
|
declare function writeCanvasPackage(filename: string, packageContents: CanvasPackage): void;
|
9
9
|
|
package/dist/cli/cli.js
CHANGED
@@ -116,7 +116,7 @@ ${g.join(`
|
|
116
116
|
`:""}var h5=f5,g5={dump:h5};function hr(e,a){return function(){throw new Error("Function yaml."+e+" is removed in js-yaml 4. Use yaml."+a+" instead, which is now safe by default.")}}var Bo=Do.load,gc=Do.loadAll,Ro=g5.dump;var vc=hr("safeLoad","load"),wc=hr("safeLoadAll","loadAll"),bc=hr("safeDump","dump");var jr=require("path"),xs=b1(require("fs"),1);function q1(){}q1.prototype={diff:function(a,t){var i=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{},p=i.callback;typeof i=="function"&&(p=i,i={}),this.options=i;var r=this;function d(v){return p?(setTimeout(function(){p(void 0,v)},0),!0):v}a=this.castInput(a),t=this.castInput(t),a=this.removeEmpty(this.tokenize(a)),t=this.removeEmpty(this.tokenize(t));var n=t.length,o=a.length,s=1,l=n+o;i.maxEditLength&&(l=Math.min(l,i.maxEditLength));var m=[{newPos:-1,components:[]}],c=this.extractCommon(m[0],t,a,0);if(m[0].newPos+1>=n&&c+1>=o)return d([{value:this.join(t),count:t.length}]);function u(){for(var v=-1*s;v<=s;v+=2){var h=void 0,C=m[v-1],x=m[v+1],I=(x?x.newPos:0)-v;C&&(m[v-1]=void 0);var j=C&&C.newPos+1<n,q=x&&0<=I&&I<o;if(!j&&!q){m[v]=void 0;continue}if(!j||q&&C.newPos<x.newPos?(h=w5(x),r.pushComponent(h.components,void 0,!0)):(h=C,h.newPos++,r.pushComponent(h.components,!0,void 0)),I=r.extractCommon(h,t,a,v),h.newPos+1>=n&&I+1>=o)return d(v5(r,h.components,t,a,r.useLongestToken));m[v]=h}s++}if(p)(function v(){setTimeout(function(){if(s>l)return p();u()||v()},0)})();else for(;s<=l;){var g=u();if(g)return g}},pushComponent:function(a,t,i){var p=a[a.length-1];p&&p.added===t&&p.removed===i?a[a.length-1]={count:p.count+1,added:t,removed:i}:a.push({count:1,added:t,removed:i})},extractCommon:function(a,t,i,p){for(var r=t.length,d=i.length,n=a.newPos,o=n-p,s=0;n+1<r&&o+1<d&&this.equals(t[n+1],i[o+1]);)n++,o++,s++;return s&&a.components.push({count:s}),a.newPos=n,o},equals:function(a,t){return this.options.comparator?this.options.comparator(a,t):a===t||this.options.ignoreCase&&a.toLowerCase()===t.toLowerCase()},removeEmpty:function(a){for(var t=[],i=0;i<a.length;i++)a[i]&&t.push(a[i]);return t},castInput:function(a){return a},tokenize:function(a){return a.split("")},join:function(a){return a.join("")}};function v5(e,a,t,i,p){for(var r=0,d=a.length,n=0,o=0;r<d;r++){var s=a[r];if(s.removed){if(s.value=e.join(i.slice(o,o+s.count)),o+=s.count,r&&a[r-1].added){var m=a[r-1];a[r-1]=a[r],a[r]=m}}else{if(!s.added&&p){var l=t.slice(n,n+s.count);l=l.map(function(u,g){var v=i[o+g];return v.length>u.length?v:u}),s.value=e.join(l)}else s.value=e.join(t.slice(n,n+s.count));n+=s.count,s.added||(o+=s.count)}}var c=a[d-1];return d>1&&typeof c.value=="string"&&(c.added||c.removed)&&e.equals("",c.value)&&(a[d-2].value+=c.value,a.pop()),a}function w5(e){return{newPos:e.newPos,components:e.components.slice(0)}}var _c=new q1;var Uo=/^[A-Za-z\xC0-\u02C6\u02C8-\u02D7\u02DE-\u02FF\u1E00-\u1EFF]+$/,ko=/\S/,$o=new q1;$o.equals=function(e,a){return this.options.ignoreCase&&(e=e.toLowerCase(),a=a.toLowerCase()),e===a||this.options.ignoreWhitespace&&!ko.test(e)&&!ko.test(a)};$o.tokenize=function(e){for(var a=e.split(/([^\S\r\n]+|[()[\]{}'"\r\n]|\b)/),t=0;t<a.length-1;t++)!a[t+1]&&a[t+2]&&Uo.test(a[t])&&Uo.test(a[t+2])&&(a[t]+=a[t+2],a.splice(t+1,2),t--);return a};var wr=new q1;wr.tokenize=function(e){var a=[],t=e.split(/(\n|\r\n)/);t[t.length-1]||t.pop();for(var i=0;i<t.length;i++){var p=t[i];i%2&&!this.options.newlineIsToken?a[a.length-1]+=p:(this.options.ignoreWhitespace&&(p=p.trim()),a.push(p))}return a};function br(e,a,t){return wr.diff(e,a,t)}var b5=new q1;b5.tokenize=function(e){return e.split(/(\S.+?[.!?])(?=\s+|$)/)};var y5=new q1;y5.tokenize=function(e){return e.split(/([{}:;,]|\s+)/)};function ep(e){return typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?ep=function(a){return typeof a}:ep=function(a){return a&&typeof Symbol=="function"&&a.constructor===Symbol&&a!==Symbol.prototype?"symbol":typeof a},ep(e)}var _5=Object.prototype.toString,yt=new q1;yt.useLongestToken=!0;yt.tokenize=wr.tokenize;yt.castInput=function(e){var a=this.options,t=a.undefinedReplacement,i=a.stringifyReplacer,p=i===void 0?function(r,d){return typeof d=="undefined"?t:d}:i;return typeof e=="string"?e:JSON.stringify(gr(e,null,null,p),p," ")};yt.equals=function(e,a){return q1.prototype.equals.call(yt,e.replace(/,([\r\n])/g,"$1"),a.replace(/,([\r\n])/g,"$1"))};function qo(e,a,t){return yt.diff(e,a,t)}function gr(e,a,t,i,p){a=a||[],t=t||[],i&&(e=i(p,e));var r;for(r=0;r<a.length;r+=1)if(a[r]===e)return t[r];var d;if(_5.call(e)==="[object Array]"){for(a.push(e),d=new Array(e.length),t.push(d),r=0;r<e.length;r+=1)d[r]=gr(e[r],a,t,i,p);return a.pop(),t.pop(),d}if(e&&e.toJSON&&(e=e.toJSON()),ep(e)==="object"&&e!==null){a.push(e),d={},t.push(d);var n=[],o;for(o in e)e.hasOwnProperty(o)&&n.push(o);for(n.sort(),r=0;r<n.length;r+=1)o=n[r],d[o]=gr(e[o],a,t,i,o);a.pop(),t.pop()}else d=e;return d}var vr=new q1;vr.tokenize=function(e){return e.slice()};vr.join=vr.removeEmpty=function(e){return e};var Ds=b1(bs(),1);async function c1({objects:e,selectIdentifier:a,selectDisplayName:t=a,onSyncComplete:i}){let p=e.reduce((n,o)=>{let s=a(o);if(n[s])throw new Error(`Identifier ${s} was not unique.`);return n[s]={id:s,object:o,providerId:s,displayName:t(o)},n},{});async function*r(){for(let n of Object.values(p))yield n}function d(){return Object.entries(p).sort((n,o)=>n[0].localeCompare(o[0])).map(n=>n[1].object)}return{objects:r(),deleteObject:async n=>{delete p[n]},writeObject:async n=>{let o=a(n.object);p[o]=n},extractCurrent:d,onSyncComplete:i?n=>i(n,d()):void 0}}var k3=Wp(Yp());function K(e){var a,t;return e.option("apiKey",{describe:"Uniform API key. Defaults to CANVAS_CLI_API_KEY or UNIFORM_API_KEY env. Supports dotenv.",default:(t=(a=process.env.CANVAS_CLI_API_KEY)!=null?a:process.env.UPM_CLI_API_KEY)!=null?t:process.env.UNIFORM_API_KEY,demandOption:!0,type:"string"}).option("apiHost",{describe:"Uniform host. Defaults to UNIFORM_CLI_BASE_URL env or https://uniform.app. Supports dotenv.",default:process.env.UNIFORM_CLI_BASE_URL||"https://uniform.app",demandOption:!0,type:"string"}).option("proxy",{describe:"HTTPS proxy to use for Uniform API calls. Defaults to HTTPS_PROXY, https_proxy, ALL_PROXY, or all_proxy env vars (in that order). Supports dotenv.",default:process.env.HTTPS_PROXY||process.env.https_proxy||process.env.ALL_PROXY||process.env.all_proxy,type:"string"})}function J(e){return e&&console.log(`\u{1F991} Using proxy ${e}`),(a,t)=>{if(e){let i={...t,agent:new Cs.HttpsProxyAgent(e)};return(0,Ir.default)(a,i)}return(0,Ir.default)(a,t)}}function Q(e){var a,t,i;return e.option("project",{describe:"Uniform project ID. Defaults to UNIFORM_CLI_PROJECT_ID or UNIFORM_PROJECT_ID env. Supports dotenv.",default:(i=(t=(a=process.env.UNIFORM_CLI_PROJECT_ID)!=null?a:process.env.CANVAS_CLI_PROJECT_ID)!=null?t:process.env.UPM_CLI_PROJECT_ID)!=null?i:process.env.UNIFORM_PROJECT_ID,demandOption:!0,type:"string",alias:["p"]})}function u1(e){return e.option("format",{alias:["f"],describe:"Output format",default:"yaml",choices:["yaml","json"],type:"string"}).option("filename",{alias:["o"],describe:"Output filename. If not specified, write to stdout.",type:"string"})}function $e(e){var a;return e.option("diff",{describe:"Whether to show diffs in stdout. off = no diffs; update = on for updates; on = updates, creates, deletes. Can be set by UNIFORM_CLI_DIFF_MODE environment variable.",default:(a=process.env.UNIFORM_CLI_DIFF_MODE)!=null?a:"off",type:"string",choices:["off","update","on"],alias:["d"]})}function f1(e){let a=(0,jr.extname)(e);return a===".yaml"||a===".yml"||a===".json"}function Me(e,a,t){let i;if(t&&!a){let p=(0,jr.extname)(t);p===".yaml"||p===".yml"?a="yaml":p===".json"&&(a="json")}else if(!a)throw new Error("Format must be specified when no filename is passed");switch(a){case"json":i=JSON.stringify(e,null,2);break;case"yaml":i=Ro(e);break;default:throw new Error(`Unsupported format: ${a}`)}t?(0,ys.writeFileSync)(t,i,"utf8"):console.log(i)}function ca(e){let a=(0,_s.readFileSync)(e,"utf8");return Bo(a,{filename:e,json:!0})}async function*up(e,a){let t=a.pageSize||100,i=0,p=[];do{p=await e(i,t);for(let r of p)yield r;i+=t}while(p.length===t)}async function h1({directory:e,format:a="yaml",selectIdentifier:t,selectDisplayName:i=t,selectFilename:p}){(0,mp.existsSync)(e)||(0,mp.mkdirSync)(e,{recursive:!0});let r=await(0,cp.readdir)(e,"utf-8"),d=new Set(r.filter(s=>{let l=(0,St.extname)(s);return l===".json"||l===".yaml"||l===".yml"})),n=s=>(0,St.join)(e,`${s}.${a}`);async function*o(){for(let s of d){let l=(0,St.join)(e,s);try{let m=await ca(l);yield{id:t(m),displayName:i(m),providerId:l,object:m}}catch(m){throw console.error(k3.default.red(`Failed to read ${l}, data is likely invalid.
|
117
117
|
${m==null?void 0:m.message}`)),m}}}return{objects:o(),deleteObject:async s=>{await(0,cp.unlink)(s)},writeObject:async s=>{p?Me(s.object,a,(0,St.join)(e,`${p(s.object)}.${a}`)):Me(s.object,a,n(s.id))}}}function As(e,a){if(!a&&!xs.default.existsSync(e))return{};let t=ca(e);if(typeof t!="object")throw new Error(`Package ${e} does not appear valid.`);return t}function Ss(e,a){Me(a,void 0,e)}async function qe({source:e,target:a,compareContents:t=(n,o)=>(0,Ds.default)(n.object,o.object,(s,l,m)=>m==="created"||m==="modified"?!0:void 0),mode:i,allowEmptySource:p=!1,whatIf:r=!1,log:d=()=>{}}){var n,o;let s=new Map;for await(let c of a.objects)s.set(c.id,c);let l=[],m=!1;for await(let c of e.objects){m=!0;let u=c.id,g=s.get(u);if(g){if(!t(c,g)&&(i==="createOrUpdate"||i==="mirror")){let v=async(h,C)=>{var x;if(!r)try{await a.writeObject(h,C)}catch(I){throw new lp(I,h)}d({action:"update",id:u,providerId:h.providerId,displayName:(x=h.displayName)!=null?x:h.providerId,whatIf:r,diff:qo(C.object,h.object)})};l.push(v(c,g))}s.delete(u)}else{let v=async(h,C)=>{var x;if(!r)try{await a.writeObject(h)}catch(I){throw new lp(I,h)}d({action:"create",id:C,providerId:C,displayName:(x=h.displayName)!=null?x:h.providerId,whatIf:r,diff:br("",JSON.stringify(h.object,null,2))})};l.push(v(c,u))}}if(await Promise.all(l),i==="mirror"){if(!m&&!p)throw new Error("Source is empty and mode is mirror. This would cause deletion of everything in the target, and most likely indicates an error in source definition.");let c=[];s.forEach(async u=>{let g=async v=>{var h;if(!r)try{await a.deleteObject(v.providerId,v)}catch(C){throw new lp(C,v)}d({action:"delete",id:v.id,providerId:v.providerId,displayName:(h=v.displayName)!=null?h:v.providerId,whatIf:r,diff:br(JSON.stringify(v.object,null,2),"")})};c.push(g(u))}),await Promise.all(c)}await Promise.all([(n=e.onSyncComplete)==null?void 0:n.call(e,!1),(o=a.onSyncComplete)==null?void 0:o.call(a,!0)])}var lp=class extends Error{constructor(e,a){var t;super(`Error syncing ${(t=a.displayName)!=null?t:a.providerId} (${a.providerId})
|
118
118
|
${e}`),this.stack=void 0,Object.setPrototypeOf(this,lp.prototype)}},At=Wp(Yp());function He(e){let{diffMode:a="off",indent:t,prefix:i}=e!=null?e:{};return function({action:p,displayName:r,whatIf:d,diff:n}){let o="";switch(p){case"create":o=At.default.green("[A]");break;case"update":o=At.default.white("[U]");break;case"delete":o=At.default.yellow("[D]");break}let s="";(a==="on"||a==="update"&&p==="update")&&(s=`
|
119
|
-
`+n.map(l=>l.added?At.default.green(l.value):l.removed?At.default.red(l.value):l.value).join("")),console.log(`${t!=null?t:""}${d?At.default.gray("[WHATIF]"):""}${o}${i!=null?i:""} ${r}${s}`)}}var Vs=require("@uniformdev/context/api");var Is=b1(Ps(),1),q3=new Set(["Failed to fetch","NetworkError when attempting to fetch resource.","The Internet connection appears to be offline.","Network request failed"]),Vr=class extends Error{constructor(a){super(),a instanceof Error?(this.originalError=a,{message:a}=a):(this.originalError=new Error(a),this.originalError.stack=this.stack),this.name="AbortError",this.message=a}},H3=(e,a,t)=>{let i=t.retries-(a-1);return e.attemptNumber=a,e.retriesLeft=i,e},G3=e=>q3.has(e),Fs=e=>globalThis.DOMException===void 0?new Error(e):new DOMException(e);async function Lr(e,a){return new Promise((t,i)=>{a={onFailedAttempt(){},retries:10,...a};let p=Is.default.operation(a);p.attempt(async r=>{try{t(await e(r))}catch(d){if(!(d instanceof Error)){i(new TypeError(`Non-error was thrown: "${d}". You should only throw errors.`));return}if(d instanceof Vr)p.stop(),i(d.originalError);else if(d instanceof TypeError&&!G3(d.message))p.stop(),i(d);else{H3(d,r,a);try{await a.onFailedAttempt(d)}catch(n){i(n);return}p.retry(d)||i(p.mainError())}}}),a.signal&&!a.signal.aborted&&a.signal.addEventListener("abort",()=>{p.stop();let r=a.signal.reason===void 0?Fs("The operation was aborted."):a.signal.reason;i(r instanceof Error?r:Fs(r))},{once:!0})})}var Mr=class extends Error{constructor(){super("Throttled function aborted"),this.name="AbortError"}};function Br({limit:e,interval:a,strict:t}){if(!Number.isFinite(e))throw new TypeError("Expected `limit` to be a finite number");if(!Number.isFinite(a))throw new TypeError("Expected `interval` to be a finite number");let i=new Map,p=0,r=0;function d(){let l=Date.now();return l-p>a?(r=1,p=l,0):(r<e?r++:(p+=a,r=1),p-l)}let n=[];function o(){let l=Date.now();if(n.length<e)return n.push(l),0;let m=n.shift()+a;return l>=m?(n.push(l),0):(n.push(m),m-l)}let s=t?o:d;return l=>{let m=function(...c){if(!m.isEnabled)return(async()=>l.apply(this,c))();let u;return new Promise((g,v)=>{u=setTimeout(()=>{g(l.apply(this,c)),i.delete(u)},s()),i.set(u,v)})};return m.abort=()=>{for(let c of i.keys())clearTimeout(c),i.get(c)(new Mr);i.clear(),n.splice(0,n.length)},m.isEnabled=!0,m}}function js({throttle:e={interval:1e3,limit:10},retry:a={retries:1,factor:1.66}}){let t=e?Br(e):null;return function(p){let r=async()=>await p();if(t&&(r=t(r)),a){let d=r;r=()=>Lr(d,a)}return r()}}var Rr=class extends Vs.ApiClient{constructor(t){t.limitPolicy||(t.limitPolicy=js({}));super(t);this.canvasUrl="/api/v1/canvas"}async getCompositionList(t){let{projectId:i}=this.options,p=this.createUrl(this.canvasUrl,{...t,projectId:i});return await this.apiClient(p)}unstable_getCompositionByNodePath(t){return this.getOneComposition(t)}unstable_getCompositionByNodeId(t){return this.getOneComposition(t)}getCompositionBySlug(t){return this.getOneComposition(t)}getCompositionById(t){return this.getOneComposition(t)}getOneComposition({unstable_resolveData:t,unstable_dynamicVariables:i,unstable_dataDiagnostics:p,...r}){let{projectId:d}=this.options,n=t?"/api/edge/v1/composition":this.canvasUrl,o={};return t&&(i&&(o.dynamicVariables=JSON.stringify(i)),p&&(o.dataDiagnostics="true")),this.apiClient(this.createUrl(n,{...r,...o,projectId:d}))}async updateComposition(t){let i=this.createUrl("/api/v1/canvas");await this.apiClient(i,{method:"PUT",body:JSON.stringify({...t,projectId:this.options.projectId}),expectNoContent:!0})}async removeComposition(t){let i=this.createUrl("/api/v1/canvas"),{projectId:p}=this.options;await this.apiClient(i,{method:"DELETE",body:JSON.stringify({...t,projectId:p}),expectNoContent:!0})}async getComponentDefinitions(t){let{projectId:i}=this.options,p=this.createUrl("/api/v1/canvas-definitions",{...t,projectId:i});return await this.apiClient(p)}async updateComponentDefinition(t){let i=this.createUrl("/api/v1/canvas-definitions");await this.apiClient(i,{method:"PUT",body:JSON.stringify({...t,projectId:this.options.projectId}),expectNoContent:!0})}async removeComponentDefinition(t){let i=this.createUrl("/api/v1/canvas-definitions");await this.apiClient(i,{method:"DELETE",body:JSON.stringify({...t,projectId:this.options.projectId}),expectNoContent:!0})}},ie=class extends Rr{constructor(a){super({...a,bypassCache:!0})}};var Ls={command:"get <id>",describe:"Fetch a component definition",builder:e=>u1(K(Q(e.positional("id",{demandOption:!0,describe:"Component definition public ID to fetch"})))),handler:async({apiHost:e,apiKey:a,proxy:t,id:i,format:p,project:r,filename:d})=>{let n=J(t),s=await new ie({apiKey:a,apiHost:e,fetch:n,projectId:r}).getComponentDefinitions({componentId:i,limit:1});s.componentDefinitions.length===0?(console.error("Component did not exist"),process.exit(1)):Me(s.componentDefinitions[0],p,d)}};var Ms={command:"list",describe:"List component definitions",aliases:["ls"],builder:e=>u1(K(Q(e.options({offset:{describe:"Number of rows to skip before fetching",type:"number",default:0},limit:{describe:"Number of rows to fetch",type:"number",default:20}})))),handler:async({apiHost:e,apiKey:a,proxy:t,limit:i,offset:p,format:r,filename:d,project:n})=>{let o=J(t),l=await new ie({apiKey:a,apiHost:e,fetch:o,projectId:n}).getComponentDefinitions({limit:i,offset:p});Me(l.componentDefinitions,r,d)}};var ua=e=>e.id,fa=e=>`${e.name} (pid: ${e.id})`;function fp({client:e}){async function*a(){let t=up(async(i,p)=>(await e.getComponentDefinitions({limit:p,offset:i})).componentDefinitions,{pageSize:100});for await(let i of t)yield{id:ua(i),displayName:fa(i),providerId:i.id,object:i}}return{objects:a(),deleteObject:async t=>{await e.removeComponentDefinition({componentId:t})},writeObject:async t=>{await e.updateComponentDefinition({componentDefinition:t.object})}}}function Xe(e,a){return As(e,a)}function za(e,a){Ss(e,a)}var Ur=class{constructor(a){yp(this,"value");yp(this,"next");this.value=a}},P1,Wa,Ya,ai=class{constructor(){Ja(this,P1,void 0);Ja(this,Wa,void 0);Ja(this,Ya,void 0);this.clear()}enqueue(a){let t=new Ur(a);e1(this,P1)?(e1(this,Wa).next=t,V1(this,Wa,t)):(V1(this,P1,t),V1(this,Wa,t)),_p(this,Ya)._++}dequeue(){let a=e1(this,P1);if(!!a)return V1(this,P1,e1(this,P1).next),_p(this,Ya)._--,a.value}clear(){V1(this,P1,void 0),V1(this,Wa,void 0),V1(this,Ya,0)}get size(){return e1(this,Ya)}*[Symbol.iterator](){let a=e1(this,P1);for(;a;)yield a.value,a=a.next}};P1=new WeakMap,Wa=new WeakMap,Ya=new WeakMap;function kr(e){if(!((Number.isInteger(e)||e===Number.POSITIVE_INFINITY)&&e>0))throw new TypeError("Expected `concurrency` to be a number from 1 and up");let a=new ai,t=0,i=()=>{t--,a.size>0&&a.dequeue()()},p=async(n,o,s)=>{t++;let l=(async()=>n(...s))();o(l);try{await l}catch(m){}i()},r=(n,o,s)=>{a.enqueue(p.bind(void 0,n,o,s)),(async()=>(await Promise.resolve(),t<e&&a.size>0&&a.dequeue()()))()},d=(n,...o)=>new Promise(s=>{r(n,s,o)});return Object.defineProperties(d,{activeCount:{get:()=>t},pendingCount:{get:()=>a.size},clearQueue:{value:()=>{a.clear()}}}),d}function hp(e){let a={...e};return delete a.projectId,delete a.state,a}function F1(e){return e.option("state",{type:"string",describe:"Composition state to fetch.",choices:["preview","published"],default:"preview"})}function ha(e){let a=Number(e);if(!isNaN(a))return a;if(!e)return 64;if(typeof e!="string")throw new Error('state must be "published", "preview", or a number');return e==="preview"?0:64}var Ge=kr(8);var Rs={command:"pull <directory>",describe:"Pulls all component definitions to local files in a directory",builder:e=>K(Q($e(e.positional("directory",{describe:"Directory to save the component definitions to. If a filename ending in yaml or json is used, a package file will be created instead of files in the directory.",type:"string"}).option("format",{alias:["f"],describe:"Output format",default:"yaml",choices:["yaml","json"],type:"string"}).option("what-if",{alias:["w"],describe:"What-if mode reports what would be done but changes no files",default:!1,type:"boolean"}).option("mode",{alias:["m"],describe:'What kind of changes can be made. "create" = create new files, update nothing. "createOrUpdate" = create new files, update existing, delete nothing. "mirror" = create, update, and delete to mirror state',choices:["create","createOrUpdate","mirror"],default:"mirror",type:"string"})))),handler:async({apiHost:e,apiKey:a,proxy:t,directory:i,format:p,mode:r,whatIf:d,project:n,diff:o})=>{var g;let s=J(t),l=new ie({apiKey:a,apiHost:e,fetch:s,projectId:n,limitPolicy:Ge}),m=fp({client:l}),c;if(f1(i)){let v=Xe(i,!1);c=await c1({objects:(g=v.components)!=null?g:[],selectIdentifier:ua,selectDisplayName:fa,onSyncComplete:async(h,C)=>{v.components=C,za(i,v)}})}else c=await h1({directory:i,selectIdentifier:ua,selectDisplayName:fa,format:p});await qe({source:m,target:c,mode:r,whatIf:d,log:He({diffMode:o})})}};var Us={command:"push <directory>",describe:"Pushes all component definitions from files in a directory to Uniform Canvas",builder:e=>K(Q($e(e.positional("directory",{describe:"Directory to read the component definitions from. If a filename is used, a package will be read instead.",type:"string"}).option("what-if",{alias:["w"],describe:"What-if mode reports what would be done but changes nothing",default:!1,type:"boolean"}).option("mode",{alias:["m"],describe:'What kind of changes can be made. "create" = create new, update nothing. "createOrUpdate" = create new, update existing, delete nothing. "mirror" = create, update, and delete',choices:["create","createOrUpdate","mirror"],default:"mirror",type:"string"})))),handler:async({apiHost:e,apiKey:a,proxy:t,directory:i,mode:p,whatIf:r,project:d,diff:n})=>{var u;let o=J(t),s=new ie({apiKey:a,apiHost:e,fetch:o,projectId:d,limitPolicy:Ge}),l;if(f1(i)){let g=Xe(i,!0);l=await c1({objects:(u=g.components)!=null?u:[],selectIdentifier:ua,selectDisplayName:fa})}else l=await h1({directory:i,selectIdentifier:ua,selectDisplayName:fa});let c=fp({client:s});await qe({source:l,target:c,mode:p,whatIf:r,log:He({diffMode:n})})}};var ks={command:"remove <id>",aliases:["delete","rm"],describe:"Delete a component definition",builder:e=>K(Q(e.positional("id",{demandOption:!0,describe:"Component definition public ID to delete"}))),handler:async({apiHost:e,apiKey:a,proxy:t,id:i,project:p})=>{let r=J(t);await new ie({apiKey:a,apiHost:e,fetch:r,projectId:p}).removeComponentDefinition({componentId:i})}};var $s={command:"update <filename>",aliases:["put"],describe:"Insert or update a component definition",builder:e=>K(Q(e.positional("filename",{demandOption:!0,describe:"Component definition file to put"}))),handler:async({apiHost:e,apiKey:a,proxy:t,filename:i,project:p})=>{let r=J(t),d=new ie({apiKey:a,apiHost:e,fetch:r,projectId:p}),n=ca(i);await d.updateComponentDefinition({componentDefinition:n})}};var qs={command:"component <command>",aliases:["def"],describe:"Commands for Canvas component definitions",builder:e=>e.command(Rs).command(Us).command(Ls).command(ks).command(Ms).command($s).demandCommand(),handler:()=>{Z1.help()}};var Hs={command:"get <id>",describe:"Fetch a composition",builder:e=>u1(K(Q(F1(e.positional("id",{demandOption:!0,describe:"Composition public ID to fetch"}).option({resolvePatterns:{type:"boolean",default:!1,describe:"Resolve pattern references in the composition"},componentIDs:{type:"boolean",default:!1,describe:"Include individual component UIDs"},unstableResolveData:{type:"boolean",default:!1,describe:"Resolve all data resources used by the composition"},unstableDataDiagnostics:{type:"boolean",default:!1,describe:"Include diagnostics information when resolving data"}}))))),handler:async({apiHost:e,apiKey:a,proxy:t,id:i,format:p,filename:r,state:d,project:n,resolvePatterns:o,componentIDs:s,unstableResolveData:l,unstableDataDiagnostics:m})=>{let c=J(t),u=new ie({apiKey:a,apiHost:e,fetch:c,projectId:n}),g=hp(await u.getCompositionById({compositionId:i,state:ha(d),skipPatternResolution:!o,withComponentIDs:s,unstable_resolveData:l,unstable_dataDiagnostics:m}));Me(g,p,r)}};var Gs=require("@uniformdev/context/api");var Dt,ti=class extends Gs.ApiClient{constructor(a){super(a)}async get(a){let{projectId:t}=this.options,i=this.createUrl(e1(ti,Dt),{...a,projectId:t});return await this.apiClient(i)}async upsert(a){let t=this.createUrl(e1(ti,Dt));await this.apiClient(t,{method:"PUT",body:JSON.stringify({...a,projectId:this.options.projectId}),expectNoContent:!0})}async remove(a){let t=this.createUrl(e1(ti,Dt));await this.apiClient(t,{method:"DELETE",body:JSON.stringify({...a,projectId:this.options.projectId}),expectNoContent:!0})}},Be=ti;Dt=new WeakMap,Ja(Be,Dt,"/api/v1/data-types");var zs={command:"list",describe:"List compositions",aliases:["ls"],builder:e=>u1(K(Q(F1(e.options({offset:{describe:"Number of rows to skip before fetching",type:"number",default:0},limit:{describe:"Number of rows to fetch",type:"number",default:20},resolvePatterns:{type:"boolean",default:!1,describe:"Resolve pattern references in the composition"},componentIDs:{type:"boolean",default:!1,describe:"Include individual component UIDs"}}))))),handler:async({apiHost:e,apiKey:a,proxy:t,limit:i,offset:p,format:r,filename:d,project:n,state:o,resolvePatterns:s,componentIDs:l})=>{let m=J(t),u=await new ie({apiKey:a,apiHost:e,fetch:m,projectId:n}).getCompositionList({limit:i,offset:p,state:ha(o),skipPatternResolution:!s,withComponentIDs:l});Me(u.compositions,r,d)}};var ga=e=>e.composition._id,va=e=>{var a,t;return`${(t=(a=e.composition._name)!=null?a:e.composition._slug)!=null?t:e.composition._id} (pid: ${e.composition._id})`};function Ka({client:e,state:a,...t}){let i=ha(a);async function*p(){let r=up(async(d,n)=>(await e.getCompositionList({...t,limit:n,offset:d,state:i,skipPatternResolution:!0,withComponentIDs:!0})).compositions,{pageSize:100});for await(let d of r)yield{id:ga(d),displayName:va(d),providerId:d.composition._id,object:hp(d)}}return{objects:p(),deleteObject:async r=>{await e.removeComposition({compositionId:r})},writeObject:async r=>{await e.updateComposition({...r.object,state:i})}}}var Ws={command:"publish [compositionIDs]",describe:"Publishes compositions",builder:e=>K(Q($e(e.positional("compositionIDs",{describe:"Publishes composition(s) by ID. Comma-separate multiple IDs. Use --all to publish all instead.",type:"string"}).option("all",{alias:["a"],describe:"Publishes all compositions. Use compositionId to publish one instead.",default:!1,type:"boolean"}).option("what-if",{alias:["w"],describe:"What-if mode reports what would be done but does not perform any publishing",default:!1,type:"boolean"})))),handler:async({apiHost:e,apiKey:a,proxy:t,compositionIDs:i,all:p,whatIf:r,project:d,diff:n})=>{(!p&&!i||p&&i)&&(console.error("Specify --all or composition ID(s) to publish."),process.exit(1));let o=i?i.split(",").map(u=>u.trim()):void 0,s=J(t),l=new ie({apiKey:a,apiHost:e,fetch:s,projectId:d,limitPolicy:Ge}),m=Ka({client:l,state:"preview",compositionIDs:o}),c=Ka({client:l,state:"published",compositionIDs:o});await qe({source:m,target:c,mode:"mirror",whatIf:r,log:He({diffMode:n})})}};var Ys={command:"pull <directory>",describe:"Pulls all compositions to local files in a directory",builder:e=>K(Q(F1($e(e.positional("directory",{describe:"Directory to save the component definitions to. If a filename ending in yaml or json is used, a package file will be created instead of files in the directory.",type:"string"}).option("format",{alias:["f"],describe:"Output format",default:"yaml",choices:["yaml","json"],type:"string"}).option("what-if",{alias:["w"],describe:"What-if mode reports what would be done but changes no files",default:!1,type:"boolean"}).option("mode",{alias:["m"],describe:'What kind of changes can be made. "create" = create new files, update nothing. "createOrUpdate" = create new files, update existing, delete nothing. "mirror" = create, update, and delete to mirror state',choices:["create","createOrUpdate","mirror"],default:"mirror",type:"string"}))))),handler:async({apiHost:e,apiKey:a,proxy:t,directory:i,format:p,mode:r,whatIf:d,state:n,project:o,diff:s})=>{var v;let l=J(t),m=new ie({apiKey:a,apiHost:e,fetch:l,projectId:o,limitPolicy:Ge}),c=Ka({client:m,state:n}),u=f1(i),g;if(u){let h=Xe(i,!1);g=await c1({objects:(v=h==null?void 0:h.compositions)!=null?v:[],selectIdentifier:ga,selectDisplayName:va,onSyncComplete:async(C,x)=>{h.compositions=x,za(i,h)}})}else g=await h1({directory:i,selectIdentifier:ga,selectDisplayName:va,format:p});await qe({source:c,target:g,mode:r,whatIf:d,log:He({diffMode:s})})}};var Ks={command:"push <directory>",describe:"Pushes all compositions from files in a directory to Uniform Canvas",builder:e=>K(Q(F1($e(e.positional("directory",{describe:"Directory to read the component definitions from. If a filename is used, a package will be read instead.",type:"string"}).option("what-if",{alias:["w"],describe:"What-if mode reports what would be done but changes nothing",default:!1,type:"boolean"}).option("mode",{alias:["m"],describe:'What kind of changes can be made. "create" = create new, update nothing. "createOrUpdate" = create new, update existing, delete nothing. "mirror" = create, update, and delete',choices:["create","createOrUpdate","mirror"],default:"mirror",type:"string"}))))),handler:async({apiHost:e,apiKey:a,proxy:t,directory:i,mode:p,whatIf:r,state:d,project:n,diff:o})=>{var g;let s=J(t),l=new ie({apiKey:a,apiHost:e,fetch:s,projectId:n,limitPolicy:Ge}),m;if(f1(i)){let v=Xe(i,!0);m=await c1({objects:(g=v.compositions)!=null?g:[],selectIdentifier:ga,selectDisplayName:va})}else m=await h1({directory:i,selectIdentifier:ga,selectDisplayName:va});let u=Ka({client:l,state:d});await qe({source:m,target:u,mode:p,whatIf:r,log:He({diffMode:o})})}};var Js={command:"remove <id>",aliases:["delete","rm"],describe:"Delete a composition",builder:e=>K(Q(e.positional("id",{demandOption:!0,describe:"Composition public ID to delete"}))),handler:async({apiHost:e,apiKey:a,proxy:t,id:i,project:p})=>{let r=J(t);await new ie({apiKey:a,apiHost:e,fetch:r,projectId:p}).removeComposition({compositionId:i})}};var Qs={command:"unpublish <id>",describe:"Unpublish a composition",builder:e=>K(Q(e.positional("id",{demandOption:!0,describe:"Composition public ID to unpublish"}))),handler:async({apiHost:e,apiKey:a,proxy:t,id:i,project:p})=>{let r=J(t);await new ie({apiKey:a,apiHost:e,fetch:r,projectId:p}).removeComposition({compositionId:i,state:64})}};var Zs={command:"update <filename>",aliases:["put"],describe:"Insert or update a composition",builder:e=>K(Q(F1(e.positional("filename",{demandOption:!0,describe:"Composition file to put"})))),handler:async({apiHost:e,apiKey:a,proxy:t,filename:i,project:p,state:r})=>{let d=J(t),n=new ie({apiKey:a,apiHost:e,fetch:d,projectId:p}),o=ca(i);await n.updateComposition({...o,state:ha(r)})}};var Xs={command:"composition <command>",describe:"Commands for Canvas compositions",aliases:["comp"],builder:e=>e.command(Ys).command(Ks).command(Hs).command(Js).command(zs).command(Zs).command(Ws).command(Qs).demandCommand(),handler:()=>{Z1.help()}};var e6={command:"get <id>",describe:"Get a data type",aliases:["ls"],builder:e=>u1(K(Q(e.positional("id",{demandOption:!0,describe:"Data type public ID to fetch"})))),handler:async({apiHost:e,apiKey:a,proxy:t,id:i,format:p,filename:r,project:d})=>{let n=J(t),l=(await new Be({apiKey:a,apiHost:e,fetch:n,projectId:d,bypassCache:!0}).get()).results.find(m=>m.id===i);if(!l)throw new Error(`Data type with ID ${i} not found`);Me(l,p,r)}};var a6={command:"list",describe:"List data types",aliases:["ls"],builder:e=>u1(K(Q(e))),handler:async({apiHost:e,apiKey:a,proxy:t,format:i,filename:p,project:r})=>{let d=J(t),o=await new Be({apiKey:a,apiHost:e,fetch:d,projectId:r,bypassCache:!0}).get();Me(o.results,i,p)}};var wa=e=>e.id,ba=e=>`${e.displayName} (pid: ${e.id})`;function gp({client:e}){async function*a(){let t=(await e.get()).results;for await(let i of t)yield{id:wa(i),displayName:ba(i),providerId:i.id,object:i}}return{objects:a(),deleteObject:async t=>{await e.remove({typeId:t})},writeObject:async t=>{await e.upsert({data:t.object})}}}var t6={command:"pull <directory>",describe:"Pulls all data types to local files in a directory",builder:e=>K(Q($e(e.positional("directory",{describe:"Directory to save the data types to. If a filename ending in yaml or json is used, a package file will be created instead of files in the directory.",type:"string"}).option("format",{alias:["f"],describe:"Output format",default:"yaml",choices:["yaml","json"],type:"string"}).option("what-if",{alias:["w"],describe:"What-if mode reports what would be done but changes no files",default:!1,type:"boolean"}).option("mode",{alias:["m"],describe:'What kind of changes can be made. "create" = create new files, update nothing. "createOrUpdate" = create new files, update existing, delete nothing. "mirror" = create, update, and delete to mirror state',choices:["create","createOrUpdate","mirror"],default:"mirror",type:"string"})))),handler:async({apiHost:e,apiKey:a,proxy:t,directory:i,format:p,mode:r,whatIf:d,project:n,diff:o})=>{var g;let s=J(t),l=new Be({apiKey:a,apiHost:e,fetch:s,projectId:n,limitPolicy:Ge,bypassCache:!0}),m=gp({client:l}),c;if(f1(i)){let v=Xe(i,!1);c=await c1({objects:(g=v.dataTypes)!=null?g:[],selectIdentifier:wa,selectDisplayName:ba,onSyncComplete:async(h,C)=>{v.dataTypes=C,za(i,v)}})}else c=await h1({directory:i,selectIdentifier:wa,selectDisplayName:ba,format:p});await qe({source:m,target:c,mode:r,whatIf:d,log:He({diffMode:o})})}};var i6={command:"push <directory>",describe:"Pushes all data types from files in a directory to Uniform",builder:e=>K(Q($e(e.positional("directory",{describe:"Directory to read the data types from. If a filename is used, a package will be read instead.",type:"string"}).option("what-if",{alias:["w"],describe:"What-if mode reports what would be done but changes nothing",default:!1,type:"boolean"}).option("mode",{alias:["m"],describe:'What kind of changes can be made. "create" = create new, update nothing. "createOrUpdate" = create new, update existing, delete nothing. "mirror" = create, update, and delete',choices:["create","createOrUpdate","mirror"],default:"mirror",type:"string"})))),handler:async({apiHost:e,apiKey:a,proxy:t,directory:i,mode:p,whatIf:r,project:d,diff:n})=>{var u;let o=J(t),s=new Be({apiKey:a,apiHost:e,fetch:o,projectId:d,limitPolicy:Ge,bypassCache:!0}),l;if(f1(i)){let g=Xe(i,!0);l=await c1({objects:(u=g.dataTypes)!=null?u:[],selectIdentifier:wa,selectDisplayName:ba})}else l=await h1({directory:i,selectIdentifier:wa,selectDisplayName:ba});let c=gp({client:s});await qe({source:l,target:c,mode:p,whatIf:r,log:He({diffMode:n})})}};var p6={command:"remove <id>",aliases:["delete","rm"],describe:"Delete a data type",builder:e=>K(Q(e.positional("id",{demandOption:!0,describe:"Data type public ID to delete"}))),handler:async({apiHost:e,apiKey:a,proxy:t,id:i,project:p})=>{let r=J(t);await new Be({apiKey:a,apiHost:e,fetch:r,projectId:p,bypassCache:!0}).remove({typeId:i})}};var d6={command:"update <filename>",aliases:["put"],describe:"Insert or update a data type",builder:e=>K(Q(e.positional("filename",{demandOption:!0,describe:"Data type file to put"}))),handler:async({apiHost:e,apiKey:a,proxy:t,filename:i,project:p})=>{let r=J(t),d=new Be({apiKey:a,apiHost:e,fetch:r,projectId:p,bypassCache:!0}),n=ca(i);await d.upsert({data:n})}};var r6={command:"datatype <command>",aliases:["dt"],describe:"Commands for Data Type definitions",builder:e=>e.command(e6).command(t6).command(i6).command(p6).command(a6).command(d6).demandCommand(),handler:()=>{Z1.help()}};var z3={commands:[{command:"canvas <command>",aliases:["cv","pm","presentation"],describe:"Uniform Canvas commands",builder:e=>e.command(Xs).command(qs).command(r6).demandCommand(),handler:()=>{Z1.showHelp()}}]};0&&(module.exports={readCanvasPackage,uniformCLI,writeCanvasPackage});
|
119
|
+
`+n.map(l=>l.added?At.default.green(l.value):l.removed?At.default.red(l.value):l.value).join("")),console.log(`${t!=null?t:""}${d?At.default.gray("[WHATIF]"):""}${o}${i!=null?i:""} ${r}${s}`)}}var Vs=require("@uniformdev/context/api");var Is=b1(Ps(),1),q3=new Set(["Failed to fetch","NetworkError when attempting to fetch resource.","The Internet connection appears to be offline.","Network request failed","fetch failed"]),Vr=class extends Error{constructor(a){super(),a instanceof Error?(this.originalError=a,{message:a}=a):(this.originalError=new Error(a),this.originalError.stack=this.stack),this.name="AbortError",this.message=a}},H3=(e,a,t)=>{let i=t.retries-(a-1);return e.attemptNumber=a,e.retriesLeft=i,e},G3=e=>q3.has(e),Fs=e=>globalThis.DOMException===void 0?new Error(e):new DOMException(e);async function Lr(e,a){return new Promise((t,i)=>{a={onFailedAttempt(){},retries:10,...a};let p=Is.default.operation(a);p.attempt(async r=>{try{t(await e(r))}catch(d){if(!(d instanceof Error)){i(new TypeError(`Non-error was thrown: "${d}". You should only throw errors.`));return}if(d instanceof Vr)p.stop(),i(d.originalError);else if(d instanceof TypeError&&!G3(d.message))p.stop(),i(d);else{H3(d,r,a);try{await a.onFailedAttempt(d)}catch(n){i(n);return}p.retry(d)||i(p.mainError())}}}),a.signal&&!a.signal.aborted&&a.signal.addEventListener("abort",()=>{p.stop();let r=a.signal.reason===void 0?Fs("The operation was aborted."):a.signal.reason;i(r instanceof Error?r:Fs(r))},{once:!0})})}var Mr=class extends Error{constructor(){super("Throttled function aborted"),this.name="AbortError"}};function Br({limit:e,interval:a,strict:t}){if(!Number.isFinite(e))throw new TypeError("Expected `limit` to be a finite number");if(!Number.isFinite(a))throw new TypeError("Expected `interval` to be a finite number");let i=new Map,p=0,r=0;function d(){let l=Date.now();return l-p>a?(r=1,p=l,0):(r<e?r++:(p+=a,r=1),p-l)}let n=[];function o(){let l=Date.now();if(n.length<e)return n.push(l),0;let m=n.shift()+a;return l>=m?(n.push(l),0):(n.push(m),m-l)}let s=t?o:d;return l=>{let m=function(...c){if(!m.isEnabled)return(async()=>l.apply(this,c))();let u;return new Promise((g,v)=>{u=setTimeout(()=>{g(l.apply(this,c)),i.delete(u)},s()),i.set(u,v)})};return m.abort=()=>{for(let c of i.keys())clearTimeout(c),i.get(c)(new Mr);i.clear(),n.splice(0,n.length)},m.isEnabled=!0,m}}function js({throttle:e={interval:1e3,limit:10},retry:a={retries:1,factor:1.66}}){let t=e?Br(e):null;return function(p){let r=async()=>await p();if(t&&(r=t(r)),a){let d=r;r=()=>Lr(d,a)}return r()}}var Rr=class extends Vs.ApiClient{constructor(t){t.limitPolicy||(t.limitPolicy=js({}));super(t);this.canvasUrl="/api/v1/canvas"}async getCompositionList(t){let{projectId:i}=this.options,p=this.createUrl(this.canvasUrl,{...t,projectId:i});return await this.apiClient(p)}unstable_getCompositionByNodePath(t){return this.getOneComposition(t)}unstable_getCompositionByNodeId(t){return this.getOneComposition(t)}getCompositionBySlug(t){return this.getOneComposition(t)}getCompositionById(t){return this.getOneComposition(t)}getOneComposition({unstable_resolveData:t,unstable_dynamicVariables:i,unstable_dataDiagnostics:p,...r}){let{projectId:d}=this.options,n=t?"/api/edge/v1/composition":this.canvasUrl,o={};return t&&(i&&(o.dynamicVariables=JSON.stringify(i)),p&&(o.dataDiagnostics="true")),this.apiClient(this.createUrl(n,{...r,...o,projectId:d}))}async updateComposition(t){let i=this.createUrl("/api/v1/canvas");await this.apiClient(i,{method:"PUT",body:JSON.stringify({...t,projectId:this.options.projectId}),expectNoContent:!0})}async removeComposition(t){let i=this.createUrl("/api/v1/canvas"),{projectId:p}=this.options;await this.apiClient(i,{method:"DELETE",body:JSON.stringify({...t,projectId:p}),expectNoContent:!0})}async getComponentDefinitions(t){let{projectId:i}=this.options,p=this.createUrl("/api/v1/canvas-definitions",{...t,projectId:i});return await this.apiClient(p)}async updateComponentDefinition(t){let i=this.createUrl("/api/v1/canvas-definitions");await this.apiClient(i,{method:"PUT",body:JSON.stringify({...t,projectId:this.options.projectId}),expectNoContent:!0})}async removeComponentDefinition(t){let i=this.createUrl("/api/v1/canvas-definitions");await this.apiClient(i,{method:"DELETE",body:JSON.stringify({...t,projectId:this.options.projectId}),expectNoContent:!0})}},ie=class extends Rr{constructor(a){super({...a,bypassCache:!0})}};var Ls={command:"get <id>",describe:"Fetch a component definition",builder:e=>u1(K(Q(e.positional("id",{demandOption:!0,describe:"Component definition public ID to fetch"})))),handler:async({apiHost:e,apiKey:a,proxy:t,id:i,format:p,project:r,filename:d})=>{let n=J(t),s=await new ie({apiKey:a,apiHost:e,fetch:n,projectId:r}).getComponentDefinitions({componentId:i,limit:1});s.componentDefinitions.length===0?(console.error("Component did not exist"),process.exit(1)):Me(s.componentDefinitions[0],p,d)}};var Ms={command:"list",describe:"List component definitions",aliases:["ls"],builder:e=>u1(K(Q(e.options({offset:{describe:"Number of rows to skip before fetching",type:"number",default:0},limit:{describe:"Number of rows to fetch",type:"number",default:20}})))),handler:async({apiHost:e,apiKey:a,proxy:t,limit:i,offset:p,format:r,filename:d,project:n})=>{let o=J(t),l=await new ie({apiKey:a,apiHost:e,fetch:o,projectId:n}).getComponentDefinitions({limit:i,offset:p});Me(l.componentDefinitions,r,d)}};var ua=e=>e.id,fa=e=>`${e.name} (pid: ${e.id})`;function fp({client:e}){async function*a(){let t=up(async(i,p)=>(await e.getComponentDefinitions({limit:p,offset:i})).componentDefinitions,{pageSize:100});for await(let i of t)yield{id:ua(i),displayName:fa(i),providerId:i.id,object:i}}return{objects:a(),deleteObject:async t=>{await e.removeComponentDefinition({componentId:t})},writeObject:async t=>{await e.updateComponentDefinition({componentDefinition:t.object})}}}function Xe(e,a){return As(e,a)}function za(e,a){Ss(e,a)}var Ur=class{constructor(a){yp(this,"value");yp(this,"next");this.value=a}},P1,Wa,Ya,ai=class{constructor(){Ja(this,P1,void 0);Ja(this,Wa,void 0);Ja(this,Ya,void 0);this.clear()}enqueue(a){let t=new Ur(a);e1(this,P1)?(e1(this,Wa).next=t,V1(this,Wa,t)):(V1(this,P1,t),V1(this,Wa,t)),_p(this,Ya)._++}dequeue(){let a=e1(this,P1);if(!!a)return V1(this,P1,e1(this,P1).next),_p(this,Ya)._--,a.value}clear(){V1(this,P1,void 0),V1(this,Wa,void 0),V1(this,Ya,0)}get size(){return e1(this,Ya)}*[Symbol.iterator](){let a=e1(this,P1);for(;a;)yield a.value,a=a.next}};P1=new WeakMap,Wa=new WeakMap,Ya=new WeakMap;function kr(e){if(!((Number.isInteger(e)||e===Number.POSITIVE_INFINITY)&&e>0))throw new TypeError("Expected `concurrency` to be a number from 1 and up");let a=new ai,t=0,i=()=>{t--,a.size>0&&a.dequeue()()},p=async(n,o,s)=>{t++;let l=(async()=>n(...s))();o(l);try{await l}catch(m){}i()},r=(n,o,s)=>{a.enqueue(p.bind(void 0,n,o,s)),(async()=>(await Promise.resolve(),t<e&&a.size>0&&a.dequeue()()))()},d=(n,...o)=>new Promise(s=>{r(n,s,o)});return Object.defineProperties(d,{activeCount:{get:()=>t},pendingCount:{get:()=>a.size},clearQueue:{value:()=>{a.clear()}}}),d}function hp(e){let a={...e};return delete a.projectId,delete a.state,a}function F1(e){return e.option("state",{type:"string",describe:"Composition state to fetch.",choices:["preview","published"],default:"preview"})}function ha(e){let a=Number(e);if(!isNaN(a))return a;if(!e)return 64;if(typeof e!="string")throw new Error('state must be "published", "preview", or a number');return e==="preview"?0:64}var Ge=kr(8);var Rs={command:"pull <directory>",describe:"Pulls all component definitions to local files in a directory",builder:e=>K(Q($e(e.positional("directory",{describe:"Directory to save the component definitions to. If a filename ending in yaml or json is used, a package file will be created instead of files in the directory.",type:"string"}).option("format",{alias:["f"],describe:"Output format",default:"yaml",choices:["yaml","json"],type:"string"}).option("what-if",{alias:["w"],describe:"What-if mode reports what would be done but changes no files",default:!1,type:"boolean"}).option("mode",{alias:["m"],describe:'What kind of changes can be made. "create" = create new files, update nothing. "createOrUpdate" = create new files, update existing, delete nothing. "mirror" = create, update, and delete to mirror state',choices:["create","createOrUpdate","mirror"],default:"mirror",type:"string"})))),handler:async({apiHost:e,apiKey:a,proxy:t,directory:i,format:p,mode:r,whatIf:d,project:n,diff:o})=>{var g;let s=J(t),l=new ie({apiKey:a,apiHost:e,fetch:s,projectId:n,limitPolicy:Ge}),m=fp({client:l}),c;if(f1(i)){let v=Xe(i,!1);c=await c1({objects:(g=v.components)!=null?g:[],selectIdentifier:ua,selectDisplayName:fa,onSyncComplete:async(h,C)=>{v.components=C,za(i,v)}})}else c=await h1({directory:i,selectIdentifier:ua,selectDisplayName:fa,format:p});await qe({source:m,target:c,mode:r,whatIf:d,log:He({diffMode:o})})}};var Us={command:"push <directory>",describe:"Pushes all component definitions from files in a directory to Uniform Canvas",builder:e=>K(Q($e(e.positional("directory",{describe:"Directory to read the component definitions from. If a filename is used, a package will be read instead.",type:"string"}).option("what-if",{alias:["w"],describe:"What-if mode reports what would be done but changes nothing",default:!1,type:"boolean"}).option("mode",{alias:["m"],describe:'What kind of changes can be made. "create" = create new, update nothing. "createOrUpdate" = create new, update existing, delete nothing. "mirror" = create, update, and delete',choices:["create","createOrUpdate","mirror"],default:"mirror",type:"string"})))),handler:async({apiHost:e,apiKey:a,proxy:t,directory:i,mode:p,whatIf:r,project:d,diff:n})=>{var u;let o=J(t),s=new ie({apiKey:a,apiHost:e,fetch:o,projectId:d,limitPolicy:Ge}),l;if(f1(i)){let g=Xe(i,!0);l=await c1({objects:(u=g.components)!=null?u:[],selectIdentifier:ua,selectDisplayName:fa})}else l=await h1({directory:i,selectIdentifier:ua,selectDisplayName:fa});let c=fp({client:s});await qe({source:l,target:c,mode:p,whatIf:r,log:He({diffMode:n})})}};var ks={command:"remove <id>",aliases:["delete","rm"],describe:"Delete a component definition",builder:e=>K(Q(e.positional("id",{demandOption:!0,describe:"Component definition public ID to delete"}))),handler:async({apiHost:e,apiKey:a,proxy:t,id:i,project:p})=>{let r=J(t);await new ie({apiKey:a,apiHost:e,fetch:r,projectId:p}).removeComponentDefinition({componentId:i})}};var $s={command:"update <filename>",aliases:["put"],describe:"Insert or update a component definition",builder:e=>K(Q(e.positional("filename",{demandOption:!0,describe:"Component definition file to put"}))),handler:async({apiHost:e,apiKey:a,proxy:t,filename:i,project:p})=>{let r=J(t),d=new ie({apiKey:a,apiHost:e,fetch:r,projectId:p}),n=ca(i);await d.updateComponentDefinition({componentDefinition:n})}};var qs={command:"component <command>",aliases:["def"],describe:"Commands for Canvas component definitions",builder:e=>e.command(Rs).command(Us).command(Ls).command(ks).command(Ms).command($s).demandCommand(),handler:()=>{Z1.help()}};var Hs={command:"get <id>",describe:"Fetch a composition",builder:e=>u1(K(Q(F1(e.positional("id",{demandOption:!0,describe:"Composition public ID to fetch"}).option({resolvePatterns:{type:"boolean",default:!1,describe:"Resolve pattern references in the composition"},componentIDs:{type:"boolean",default:!1,describe:"Include individual component UIDs"},unstableResolveData:{type:"boolean",default:!1,describe:"Resolve all data resources used by the composition"},unstableDataDiagnostics:{type:"boolean",default:!1,describe:"Include diagnostics information when resolving data"}}))))),handler:async({apiHost:e,apiKey:a,proxy:t,id:i,format:p,filename:r,state:d,project:n,resolvePatterns:o,componentIDs:s,unstableResolveData:l,unstableDataDiagnostics:m})=>{let c=J(t),u=new ie({apiKey:a,apiHost:e,fetch:c,projectId:n}),g=hp(await u.getCompositionById({compositionId:i,state:ha(d),skipPatternResolution:!o,withComponentIDs:s,unstable_resolveData:l,unstable_dataDiagnostics:m}));Me(g,p,r)}};var Gs=require("@uniformdev/context/api");var Dt,ti=class extends Gs.ApiClient{constructor(a){super(a)}async get(a){let{projectId:t}=this.options,i=this.createUrl(e1(ti,Dt),{...a,projectId:t});return await this.apiClient(i)}async upsert(a){let t=this.createUrl(e1(ti,Dt));await this.apiClient(t,{method:"PUT",body:JSON.stringify({...a,projectId:this.options.projectId}),expectNoContent:!0})}async remove(a){let t=this.createUrl(e1(ti,Dt));await this.apiClient(t,{method:"DELETE",body:JSON.stringify({...a,projectId:this.options.projectId}),expectNoContent:!0})}},Be=ti;Dt=new WeakMap,Ja(Be,Dt,"/api/v1/data-types");var zs={command:"list",describe:"List compositions",aliases:["ls"],builder:e=>u1(K(Q(F1(e.options({offset:{describe:"Number of rows to skip before fetching",type:"number",default:0},limit:{describe:"Number of rows to fetch",type:"number",default:20},resolvePatterns:{type:"boolean",default:!1,describe:"Resolve pattern references in the composition"},componentIDs:{type:"boolean",default:!1,describe:"Include individual component UIDs"}}))))),handler:async({apiHost:e,apiKey:a,proxy:t,limit:i,offset:p,format:r,filename:d,project:n,state:o,resolvePatterns:s,componentIDs:l})=>{let m=J(t),u=await new ie({apiKey:a,apiHost:e,fetch:m,projectId:n}).getCompositionList({limit:i,offset:p,state:ha(o),skipPatternResolution:!s,withComponentIDs:l});Me(u.compositions,r,d)}};var ga=e=>e.composition._id,va=e=>{var a,t;return`${(t=(a=e.composition._name)!=null?a:e.composition._slug)!=null?t:e.composition._id} (pid: ${e.composition._id})`};function Ka({client:e,state:a,...t}){let i=ha(a);async function*p(){let r=up(async(d,n)=>(await e.getCompositionList({...t,limit:n,offset:d,state:i,skipPatternResolution:!0,withComponentIDs:!0})).compositions,{pageSize:100});for await(let d of r)yield{id:ga(d),displayName:va(d),providerId:d.composition._id,object:hp(d)}}return{objects:p(),deleteObject:async r=>{await e.removeComposition({compositionId:r})},writeObject:async r=>{await e.updateComposition({...r.object,state:i})}}}var Ws={command:"publish [compositionIDs]",describe:"Publishes compositions",builder:e=>K(Q($e(e.positional("compositionIDs",{describe:"Publishes composition(s) by ID. Comma-separate multiple IDs. Use --all to publish all instead.",type:"string"}).option("all",{alias:["a"],describe:"Publishes all compositions. Use compositionId to publish one instead.",default:!1,type:"boolean"}).option("what-if",{alias:["w"],describe:"What-if mode reports what would be done but does not perform any publishing",default:!1,type:"boolean"})))),handler:async({apiHost:e,apiKey:a,proxy:t,compositionIDs:i,all:p,whatIf:r,project:d,diff:n})=>{(!p&&!i||p&&i)&&(console.error("Specify --all or composition ID(s) to publish."),process.exit(1));let o=i?i.split(",").map(u=>u.trim()):void 0,s=J(t),l=new ie({apiKey:a,apiHost:e,fetch:s,projectId:d,limitPolicy:Ge}),m=Ka({client:l,state:"preview",compositionIDs:o}),c=Ka({client:l,state:"published",compositionIDs:o});await qe({source:m,target:c,mode:"mirror",whatIf:r,log:He({diffMode:n})})}};var Ys={command:"pull <directory>",describe:"Pulls all compositions to local files in a directory",builder:e=>K(Q(F1($e(e.positional("directory",{describe:"Directory to save the component definitions to. If a filename ending in yaml or json is used, a package file will be created instead of files in the directory.",type:"string"}).option("format",{alias:["f"],describe:"Output format",default:"yaml",choices:["yaml","json"],type:"string"}).option("what-if",{alias:["w"],describe:"What-if mode reports what would be done but changes no files",default:!1,type:"boolean"}).option("mode",{alias:["m"],describe:'What kind of changes can be made. "create" = create new files, update nothing. "createOrUpdate" = create new files, update existing, delete nothing. "mirror" = create, update, and delete to mirror state',choices:["create","createOrUpdate","mirror"],default:"mirror",type:"string"}))))),handler:async({apiHost:e,apiKey:a,proxy:t,directory:i,format:p,mode:r,whatIf:d,state:n,project:o,diff:s})=>{var v;let l=J(t),m=new ie({apiKey:a,apiHost:e,fetch:l,projectId:o,limitPolicy:Ge}),c=Ka({client:m,state:n}),u=f1(i),g;if(u){let h=Xe(i,!1);g=await c1({objects:(v=h==null?void 0:h.compositions)!=null?v:[],selectIdentifier:ga,selectDisplayName:va,onSyncComplete:async(C,x)=>{h.compositions=x,za(i,h)}})}else g=await h1({directory:i,selectIdentifier:ga,selectDisplayName:va,format:p});await qe({source:c,target:g,mode:r,whatIf:d,log:He({diffMode:s})})}};var Ks={command:"push <directory>",describe:"Pushes all compositions from files in a directory to Uniform Canvas",builder:e=>K(Q(F1($e(e.positional("directory",{describe:"Directory to read the component definitions from. If a filename is used, a package will be read instead.",type:"string"}).option("what-if",{alias:["w"],describe:"What-if mode reports what would be done but changes nothing",default:!1,type:"boolean"}).option("mode",{alias:["m"],describe:'What kind of changes can be made. "create" = create new, update nothing. "createOrUpdate" = create new, update existing, delete nothing. "mirror" = create, update, and delete',choices:["create","createOrUpdate","mirror"],default:"mirror",type:"string"}))))),handler:async({apiHost:e,apiKey:a,proxy:t,directory:i,mode:p,whatIf:r,state:d,project:n,diff:o})=>{var g;let s=J(t),l=new ie({apiKey:a,apiHost:e,fetch:s,projectId:n,limitPolicy:Ge}),m;if(f1(i)){let v=Xe(i,!0);m=await c1({objects:(g=v.compositions)!=null?g:[],selectIdentifier:ga,selectDisplayName:va})}else m=await h1({directory:i,selectIdentifier:ga,selectDisplayName:va});let u=Ka({client:l,state:d});await qe({source:m,target:u,mode:p,whatIf:r,log:He({diffMode:o})})}};var Js={command:"remove <id>",aliases:["delete","rm"],describe:"Delete a composition",builder:e=>K(Q(e.positional("id",{demandOption:!0,describe:"Composition public ID to delete"}))),handler:async({apiHost:e,apiKey:a,proxy:t,id:i,project:p})=>{let r=J(t);await new ie({apiKey:a,apiHost:e,fetch:r,projectId:p}).removeComposition({compositionId:i})}};var Qs={command:"unpublish <id>",describe:"Unpublish a composition",builder:e=>K(Q(e.positional("id",{demandOption:!0,describe:"Composition public ID to unpublish"}))),handler:async({apiHost:e,apiKey:a,proxy:t,id:i,project:p})=>{let r=J(t);await new ie({apiKey:a,apiHost:e,fetch:r,projectId:p}).removeComposition({compositionId:i,state:64})}};var Zs={command:"update <filename>",aliases:["put"],describe:"Insert or update a composition",builder:e=>K(Q(F1(e.positional("filename",{demandOption:!0,describe:"Composition file to put"})))),handler:async({apiHost:e,apiKey:a,proxy:t,filename:i,project:p,state:r})=>{let d=J(t),n=new ie({apiKey:a,apiHost:e,fetch:d,projectId:p}),o=ca(i);await n.updateComposition({...o,state:ha(r)})}};var Xs={command:"composition <command>",describe:"Commands for Canvas compositions",aliases:["comp"],builder:e=>e.command(Ys).command(Ks).command(Hs).command(Js).command(zs).command(Zs).command(Ws).command(Qs).demandCommand(),handler:()=>{Z1.help()}};var e6={command:"get <id>",describe:"Get a data type",aliases:["ls"],builder:e=>u1(K(Q(e.positional("id",{demandOption:!0,describe:"Data type public ID to fetch"})))),handler:async({apiHost:e,apiKey:a,proxy:t,id:i,format:p,filename:r,project:d})=>{let n=J(t),l=(await new Be({apiKey:a,apiHost:e,fetch:n,projectId:d,bypassCache:!0}).get()).results.find(m=>m.id===i);if(!l)throw new Error(`Data type with ID ${i} not found`);Me(l,p,r)}};var a6={command:"list",describe:"List data types",aliases:["ls"],builder:e=>u1(K(Q(e))),handler:async({apiHost:e,apiKey:a,proxy:t,format:i,filename:p,project:r})=>{let d=J(t),o=await new Be({apiKey:a,apiHost:e,fetch:d,projectId:r,bypassCache:!0}).get();Me(o.results,i,p)}};var wa=e=>e.id,ba=e=>`${e.displayName} (pid: ${e.id})`;function gp({client:e}){async function*a(){let t=(await e.get()).results;for await(let i of t)yield{id:wa(i),displayName:ba(i),providerId:i.id,object:i}}return{objects:a(),deleteObject:async t=>{await e.remove({typeId:t})},writeObject:async t=>{await e.upsert({data:t.object})}}}var t6={command:"pull <directory>",describe:"Pulls all data types to local files in a directory",builder:e=>K(Q($e(e.positional("directory",{describe:"Directory to save the data types to. If a filename ending in yaml or json is used, a package file will be created instead of files in the directory.",type:"string"}).option("format",{alias:["f"],describe:"Output format",default:"yaml",choices:["yaml","json"],type:"string"}).option("what-if",{alias:["w"],describe:"What-if mode reports what would be done but changes no files",default:!1,type:"boolean"}).option("mode",{alias:["m"],describe:'What kind of changes can be made. "create" = create new files, update nothing. "createOrUpdate" = create new files, update existing, delete nothing. "mirror" = create, update, and delete to mirror state',choices:["create","createOrUpdate","mirror"],default:"mirror",type:"string"})))),handler:async({apiHost:e,apiKey:a,proxy:t,directory:i,format:p,mode:r,whatIf:d,project:n,diff:o})=>{var g;let s=J(t),l=new Be({apiKey:a,apiHost:e,fetch:s,projectId:n,limitPolicy:Ge,bypassCache:!0}),m=gp({client:l}),c;if(f1(i)){let v=Xe(i,!1);c=await c1({objects:(g=v.dataTypes)!=null?g:[],selectIdentifier:wa,selectDisplayName:ba,onSyncComplete:async(h,C)=>{v.dataTypes=C,za(i,v)}})}else c=await h1({directory:i,selectIdentifier:wa,selectDisplayName:ba,format:p});await qe({source:m,target:c,mode:r,whatIf:d,log:He({diffMode:o})})}};var i6={command:"push <directory>",describe:"Pushes all data types from files in a directory to Uniform",builder:e=>K(Q($e(e.positional("directory",{describe:"Directory to read the data types from. If a filename is used, a package will be read instead.",type:"string"}).option("what-if",{alias:["w"],describe:"What-if mode reports what would be done but changes nothing",default:!1,type:"boolean"}).option("mode",{alias:["m"],describe:'What kind of changes can be made. "create" = create new, update nothing. "createOrUpdate" = create new, update existing, delete nothing. "mirror" = create, update, and delete',choices:["create","createOrUpdate","mirror"],default:"mirror",type:"string"})))),handler:async({apiHost:e,apiKey:a,proxy:t,directory:i,mode:p,whatIf:r,project:d,diff:n})=>{var u;let o=J(t),s=new Be({apiKey:a,apiHost:e,fetch:o,projectId:d,limitPolicy:Ge,bypassCache:!0}),l;if(f1(i)){let g=Xe(i,!0);l=await c1({objects:(u=g.dataTypes)!=null?u:[],selectIdentifier:wa,selectDisplayName:ba})}else l=await h1({directory:i,selectIdentifier:wa,selectDisplayName:ba});let c=gp({client:s});await qe({source:l,target:c,mode:p,whatIf:r,log:He({diffMode:n})})}};var p6={command:"remove <id>",aliases:["delete","rm"],describe:"Delete a data type",builder:e=>K(Q(e.positional("id",{demandOption:!0,describe:"Data type public ID to delete"}))),handler:async({apiHost:e,apiKey:a,proxy:t,id:i,project:p})=>{let r=J(t);await new Be({apiKey:a,apiHost:e,fetch:r,projectId:p,bypassCache:!0}).remove({typeId:i})}};var d6={command:"update <filename>",aliases:["put"],describe:"Insert or update a data type",builder:e=>K(Q(e.positional("filename",{demandOption:!0,describe:"Data type file to put"}))),handler:async({apiHost:e,apiKey:a,proxy:t,filename:i,project:p})=>{let r=J(t),d=new Be({apiKey:a,apiHost:e,fetch:r,projectId:p,bypassCache:!0}),n=ca(i);await d.upsert({data:n})}};var r6={command:"datatype <command>",aliases:["dt"],describe:"Commands for Data Type definitions",builder:e=>e.command(e6).command(t6).command(i6).command(p6).command(a6).command(d6).demandCommand(),handler:()=>{Z1.help()}};var z3={commands:[{command:"canvas <command>",aliases:["cv","pm","presentation"],describe:"Uniform Canvas commands",builder:e=>e.command(Xs).command(qs).command(r6).demandCommand(),handler:()=>{Z1.showHelp()}}]};0&&(module.exports={readCanvasPackage,uniformCLI,writeCanvasPackage});
|
120
120
|
/*! js-yaml 4.1.0 https://github.com/nodeca/js-yaml @license MIT */
|
121
121
|
/**
|
122
122
|
* @fileoverview Main entrypoint for libraries using yargs-parser in Node.js
|
package/dist/cli/cli.mjs
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
import{I as As,J as ni,a as te,b as C2,c as H,d as x2,e as Gp,f as A2,g as di,h as wa,i as Yp,j as $1,k as ri,o as ie,q as Xe}from"../chunk-
|
1
|
+
import{I as As,J as ni,a as te,b as C2,c as H,d as x2,e as Gp,f as A2,g as di,h as wa,i as Yp,j as $1,k as ri,o as ie,q as Xe}from"../chunk-TN3WBMTA.mjs";var O0=H((N7,E0)=>{var Qa=1e3,Za=Qa*60,Xa=Za*60,Fa=Xa*24,j6=Fa*7,L6=Fa*365.25;E0.exports=function(e,a){a=a||{};var p=typeof e;if(p==="string"&&e.length>0)return M6(e);if(p==="number"&&isFinite(e))return a.long?R6(e):B6(e);throw new Error("val is not a non-empty string or a valid number. val="+JSON.stringify(e))};function M6(e){if(e=String(e),!(e.length>100)){var a=/^(-?(?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)?$/i.exec(e);if(!!a){var p=parseFloat(a[1]),t=(a[2]||"ms").toLowerCase();switch(t){case"years":case"year":case"yrs":case"yr":case"y":return p*L6;case"weeks":case"week":case"w":return p*j6;case"days":case"day":case"d":return p*Fa;case"hours":case"hour":case"hrs":case"hr":case"h":return p*Xa;case"minutes":case"minute":case"mins":case"min":case"m":return p*Za;case"seconds":case"second":case"secs":case"sec":case"s":return p*Qa;case"milliseconds":case"millisecond":case"msecs":case"msec":case"ms":return p;default:return}}}}function B6(e){var a=Math.abs(e);return a>=Fa?Math.round(e/Fa)+"d":a>=Xa?Math.round(e/Xa)+"h":a>=Za?Math.round(e/Za)+"m":a>=Qa?Math.round(e/Qa)+"s":e+"ms"}function R6(e){var a=Math.abs(e);return a>=Fa?ct(e,a,Fa,"day"):a>=Xa?ct(e,a,Xa,"hour"):a>=Za?ct(e,a,Za,"minute"):a>=Qa?ct(e,a,Qa,"second"):e+" ms"}function ct(e,a,p,t){var i=a>=p*1.5;return Math.round(e/p)+" "+t+(i?"s":"")}});var ji=H((E7,T0)=>{function U6(e){p.debug=p,p.default=p,p.coerce=o,p.disable=r,p.enable=i,p.enabled=d,p.humanize=O0(),p.destroy=s,Object.keys(e).forEach(l=>{p[l]=e[l]}),p.names=[],p.skips=[],p.formatters={};function a(l){let m=0;for(let c=0;c<l.length;c++)m=(m<<5)-m+l.charCodeAt(c),m|=0;return p.colors[Math.abs(m)%p.colors.length]}p.selectColor=a;function p(l){let m,c=null,u,g;function v(...h){if(!v.enabled)return;let C=v,x=Number(new Date),I=x-(m||x);C.diff=I,C.prev=m,C.curr=x,m=x,h[0]=p.coerce(h[0]),typeof h[0]!="string"&&h.unshift("%O");let V=0;h[0]=h[0].replace(/%([a-zA-Z%])/g,(L,T)=>{if(L==="%%")return"%";V++;let Y=p.formatters[T];if(typeof Y=="function"){let ae=h[V];L=Y.call(C,ae),h.splice(V,1),V--}return L}),p.formatArgs.call(C,h),(C.log||p.log).apply(C,h)}return v.namespace=l,v.useColors=p.useColors(),v.color=p.selectColor(l),v.extend=t,v.destroy=p.destroy,Object.defineProperty(v,"enabled",{enumerable:!0,configurable:!1,get:()=>c!==null?c:(u!==p.namespaces&&(u=p.namespaces,g=p.enabled(l)),g),set:h=>{c=h}}),typeof p.init=="function"&&p.init(v),v}function t(l,m){let c=p(this.namespace+(typeof m=="undefined"?":":m)+l);return c.log=this.log,c}function i(l){p.save(l),p.namespaces=l,p.names=[],p.skips=[];let m,c=(typeof l=="string"?l:"").split(/[\s,]+/),u=c.length;for(m=0;m<u;m++)!c[m]||(l=c[m].replace(/\*/g,".*?"),l[0]==="-"?p.skips.push(new RegExp("^"+l.slice(1)+"$")):p.names.push(new RegExp("^"+l+"$")))}function r(){let l=[...p.names.map(n),...p.skips.map(n).map(m=>"-"+m)].join(",");return p.enable(""),l}function d(l){if(l[l.length-1]==="*")return!0;let m,c;for(m=0,c=p.skips.length;m<c;m++)if(p.skips[m].test(l))return!1;for(m=0,c=p.names.length;m<c;m++)if(p.names[m].test(l))return!0;return!1}function n(l){return l.toString().substring(2,l.toString().length-2).replace(/\.\*\?$/,"*")}function o(l){return l instanceof Error?l.stack||l.message:l}function s(){console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.")}return p.enable(p.load()),p}T0.exports=U6});var P0=H((Je,ut)=>{Je.formatArgs=$6;Je.save=q6;Je.load=H6;Je.useColors=k6;Je.storage=z6();Je.destroy=(()=>{let e=!1;return()=>{e||(e=!0,console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`."))}})();Je.colors=["#0000CC","#0000FF","#0033CC","#0033FF","#0066CC","#0066FF","#0099CC","#0099FF","#00CC00","#00CC33","#00CC66","#00CC99","#00CCCC","#00CCFF","#3300CC","#3300FF","#3333CC","#3333FF","#3366CC","#3366FF","#3399CC","#3399FF","#33CC00","#33CC33","#33CC66","#33CC99","#33CCCC","#33CCFF","#6600CC","#6600FF","#6633CC","#6633FF","#66CC00","#66CC33","#9900CC","#9900FF","#9933CC","#9933FF","#99CC00","#99CC33","#CC0000","#CC0033","#CC0066","#CC0099","#CC00CC","#CC00FF","#CC3300","#CC3333","#CC3366","#CC3399","#CC33CC","#CC33FF","#CC6600","#CC6633","#CC9900","#CC9933","#CCCC00","#CCCC33","#FF0000","#FF0033","#FF0066","#FF0099","#FF00CC","#FF00FF","#FF3300","#FF3333","#FF3366","#FF3399","#FF33CC","#FF33FF","#FF6600","#FF6633","#FF9900","#FF9933","#FFCC00","#FFCC33"];function k6(){return typeof window!="undefined"&&window.process&&(window.process.type==="renderer"||window.process.__nwjs)?!0:typeof navigator!="undefined"&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/(edge|trident)\/(\d+)/)?!1:typeof document!="undefined"&&document.documentElement&&document.documentElement.style&&document.documentElement.style.WebkitAppearance||typeof window!="undefined"&&window.console&&(window.console.firebug||window.console.exception&&window.console.table)||typeof navigator!="undefined"&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/)&&parseInt(RegExp.$1,10)>=31||typeof navigator!="undefined"&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/)}function $6(e){if(e[0]=(this.useColors?"%c":"")+this.namespace+(this.useColors?" %c":" ")+e[0]+(this.useColors?"%c ":" ")+"+"+ut.exports.humanize(this.diff),!this.useColors)return;let a="color: "+this.color;e.splice(1,0,a,"color: inherit");let p=0,t=0;e[0].replace(/%[a-zA-Z%]/g,i=>{i!=="%%"&&(p++,i==="%c"&&(t=p))}),e.splice(t,0,a)}Je.log=console.debug||console.log||(()=>{});function q6(e){try{e?Je.storage.setItem("debug",e):Je.storage.removeItem("debug")}catch(a){}}function H6(){let e;try{e=Je.storage.getItem("debug")}catch(a){}return!e&&typeof process!="undefined"&&"env"in process&&(e=process.env.DEBUG),e}function z6(){try{return localStorage}catch(e){}}ut.exports=ji()(Je);var{formatters:W6}=ut.exports;W6.j=function(e){try{return JSON.stringify(e)}catch(a){return"[UnexpectedJSONParseError]: "+a.message}}});var I0=H((O7,F0)=>{"use strict";F0.exports=(e,a=process.argv)=>{let p=e.startsWith("-")?"":e.length===1?"-":"--",t=a.indexOf(p+e),i=a.indexOf("--");return t!==-1&&(i===-1||t<i)}});var L0=H((T7,j0)=>{"use strict";var G6=te("os"),V0=te("tty"),d1=I0(),{env:Ne}=process,J1;d1("no-color")||d1("no-colors")||d1("color=false")||d1("color=never")?J1=0:(d1("color")||d1("colors")||d1("color=true")||d1("color=always"))&&(J1=1);"FORCE_COLOR"in Ne&&(Ne.FORCE_COLOR==="true"?J1=1:Ne.FORCE_COLOR==="false"?J1=0:J1=Ne.FORCE_COLOR.length===0?1:Math.min(parseInt(Ne.FORCE_COLOR,10),3));function Li(e){return e===0?!1:{level:e,hasBasic:!0,has256:e>=2,has16m:e>=3}}function Mi(e,a){if(J1===0)return 0;if(d1("color=16m")||d1("color=full")||d1("color=truecolor"))return 3;if(d1("color=256"))return 2;if(e&&!a&&J1===void 0)return 0;let p=J1||0;if(Ne.TERM==="dumb")return p;if(process.platform==="win32"){let t=G6.release().split(".");return Number(t[0])>=10&&Number(t[2])>=10586?Number(t[2])>=14931?3:2:1}if("CI"in Ne)return["TRAVIS","CIRCLECI","APPVEYOR","GITLAB_CI","GITHUB_ACTIONS","BUILDKITE"].some(t=>t in Ne)||Ne.CI_NAME==="codeship"?1:p;if("TEAMCITY_VERSION"in Ne)return/^(9\.(0*[1-9]\d*)\.|\d{2,}\.)/.test(Ne.TEAMCITY_VERSION)?1:0;if(Ne.COLORTERM==="truecolor")return 3;if("TERM_PROGRAM"in Ne){let t=parseInt((Ne.TERM_PROGRAM_VERSION||"").split(".")[0],10);switch(Ne.TERM_PROGRAM){case"iTerm.app":return t>=3?3:2;case"Apple_Terminal":return 2}}return/-256(color)?$/i.test(Ne.TERM)?2:/^screen|^xterm|^vt100|^vt220|^rxvt|color|ansi|cygwin|linux/i.test(Ne.TERM)||"COLORTERM"in Ne?1:p}function Y6(e){let a=Mi(e,e&&e.isTTY);return Li(a)}j0.exports={supportsColor:Y6,stdout:Li(Mi(!0,V0.isatty(1))),stderr:Li(Mi(!0,V0.isatty(2)))}});var B0=H((Te,ht)=>{var K6=te("tty"),ft=te("util");Te.init=p4;Te.log=X6;Te.formatArgs=Q6;Te.save=e4;Te.load=a4;Te.useColors=J6;Te.destroy=ft.deprecate(()=>{},"Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.");Te.colors=[6,2,3,4,5,1];try{let e=L0();e&&(e.stderr||e).level>=2&&(Te.colors=[20,21,26,27,32,33,38,39,40,41,42,43,44,45,56,57,62,63,68,69,74,75,76,77,78,79,80,81,92,93,98,99,112,113,128,129,134,135,148,149,160,161,162,163,164,165,166,167,168,169,170,171,172,173,178,179,184,185,196,197,198,199,200,201,202,203,204,205,206,207,208,209,214,215,220,221])}catch(e){}Te.inspectOpts=Object.keys(process.env).filter(e=>/^debug_/i.test(e)).reduce((e,a)=>{let p=a.substring(6).toLowerCase().replace(/_([a-z])/g,(i,r)=>r.toUpperCase()),t=process.env[a];return/^(yes|on|true|enabled)$/i.test(t)?t=!0:/^(no|off|false|disabled)$/i.test(t)?t=!1:t==="null"?t=null:t=Number(t),e[p]=t,e},{});function J6(){return"colors"in Te.inspectOpts?Boolean(Te.inspectOpts.colors):K6.isatty(process.stderr.fd)}function Q6(e){let{namespace:a,useColors:p}=this;if(p){let t=this.color,i="\x1B[3"+(t<8?t:"8;5;"+t),r=` ${i};1m${a} \x1B[0m`;e[0]=r+e[0].split(`
|
2
2
|
`).join(`
|
3
3
|
`+r),e.push(i+"m+"+ht.exports.humanize(this.diff)+"\x1B[0m")}else e[0]=Z6()+a+" "+e[0]}function Z6(){return Te.inspectOpts.hideDate?"":new Date().toISOString()+" "}function X6(...e){return process.stderr.write(ft.format(...e)+`
|
4
4
|
`)}function e4(e){e?process.env.DEBUG=e:delete process.env.DEBUG}function a4(){return process.env.DEBUG}function p4(e){e.inspectOpts={};let a=Object.keys(Te.inspectOpts);for(let p=0;p<a.length;p++)e.inspectOpts[a[p]]=Te.inspectOpts[a[p]]}ht.exports=ji()(Te);var{formatters:M0}=ht.exports;M0.o=function(e){return this.inspectOpts.colors=this.useColors,ft.inspect(e,this.inspectOpts).split(`
|