@uniformdev/canvas 16.0.1-nuxt.166 → 16.0.1-nuxt.179

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.
@@ -0,0 +1,2 @@
1
+ var k=Object.create;var _=Object.defineProperty;var U=Object.getOwnPropertyDescriptor;var V=Object.getOwnPropertyNames;var M=Object.getPrototypeOf,$=Object.prototype.hasOwnProperty;var j=(e,t,i)=>t in e?_(e,t,{enumerable:!0,configurable:!0,writable:!0,value:i}):e[t]=i;var B=(e=>typeof require!="undefined"?require:typeof Proxy!="undefined"?new Proxy(e,{get:(t,i)=>(typeof require!="undefined"?require:t)[i]}):e)(function(e){if(typeof require!="undefined")return require.apply(this,arguments);throw new Error('Dynamic require of "'+e+'" is not supported')});var A=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports);var q=(e,t,i,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of V(t))!$.call(e,o)&&o!==i&&_(e,o,{get:()=>t[o],enumerable:!(r=U(t,o))||r.enumerable});return e};var F=(e,t,i)=>(i=e!=null?k(M(e)):{},q(t||!e||!e.__esModule?_(i,"default",{value:e,enumerable:!0}):i,e));var W=(e,t,i)=>(j(e,typeof t!="symbol"?t+"":t,i),i),R=(e,t,i)=>{if(!t.has(e))throw TypeError("Cannot "+i)};var z=(e,t,i)=>(R(e,t,"read from private field"),i?i.call(e):t.get(e)),Q=(e,t,i)=>{if(t.has(e))throw TypeError("Cannot add the same private member more than once");t instanceof WeakSet?t.add(e):t.set(e,i)},H=(e,t,i,r)=>(R(e,t,"write to private field"),r?r.call(e,i):t.set(e,i),i),X=(e,t,i,r)=>({set _(o){H(e,t,o,i)},get _(){return z(e,t,r)}});var P=A((it,w)=>{function p(e,t){typeof t=="boolean"&&(t={forever:t}),this._originalTimeouts=JSON.parse(JSON.stringify(e)),this._timeouts=e,this._options=t||{},this._maxRetryTime=t&&t.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))}w.exports=p;p.prototype.reset=function(){this._attempts=1,this._timeouts=this._originalTimeouts.slice(0)};p.prototype.stop=function(){this._timeout&&clearTimeout(this._timeout),this._timer&&clearTimeout(this._timer),this._timeouts=[],this._cachedTimeouts=null};p.prototype.retry=function(e){if(this._timeout&&clearTimeout(this._timeout),!e)return!1;var t=new Date().getTime();if(e&&t-this._operationStart>=this._maxRetryTime)return this._errors.push(e),this._errors.unshift(new Error("RetryOperation timeout occurred")),!1;this._errors.push(e);var i=this._timeouts.shift();if(i===void 0)if(this._cachedTimeouts)this._errors.splice(0,this._errors.length-1),i=this._cachedTimeouts.slice(-1);else return!1;var r=this;return this._timer=setTimeout(function(){r._attempts++,r._operationTimeoutCb&&(r._timeout=setTimeout(function(){r._operationTimeoutCb(r._attempts)},r._operationTimeout),r._options.unref&&r._timeout.unref()),r._fn(r._attempts)},i),this._options.unref&&this._timer.unref(),!0};p.prototype.attempt=function(e,t){this._fn=e,t&&(t.timeout&&(this._operationTimeout=t.timeout),t.cb&&(this._operationTimeoutCb=t.cb));var i=this;this._operationTimeoutCb&&(this._timeout=setTimeout(function(){i._operationTimeoutCb()},i._operationTimeout)),this._operationStart=new Date().getTime(),this._fn(this._attempts)};p.prototype.try=function(e){console.log("Using RetryOperation.try() is deprecated"),this.attempt(e)};p.prototype.start=function(e){console.log("Using RetryOperation.start() is deprecated"),this.attempt(e)};p.prototype.start=p.prototype.try;p.prototype.errors=function(){return this._errors};p.prototype.attempts=function(){return this._attempts};p.prototype.mainError=function(){if(this._errors.length===0)return null;for(var e={},t=null,i=0,r=0;r<this._errors.length;r++){var o=this._errors[r],n=o.message,s=(e[n]||0)+1;e[n]=s,s>=i&&(t=o,i=s)}return t}});var x=A(h=>{var J=P();h.operation=function(e){var t=h.timeouts(e);return new J(t,{forever:e&&(e.forever||e.retries===1/0),unref:e&&e.unref,maxRetryTime:e&&e.maxRetryTime})};h.timeouts=function(e){if(e instanceof Array)return[].concat(e);var t={retries:10,factor:2,minTimeout:1*1e3,maxTimeout:1/0,randomize:!1};for(var i in e)t[i]=e[i];if(t.minTimeout>t.maxTimeout)throw new Error("minTimeout is greater than maxTimeout");for(var r=[],o=0;o<t.retries;o++)r.push(this.createTimeout(o,t));return e&&e.forever&&!r.length&&r.push(this.createTimeout(o,t)),r.sort(function(n,s){return n-s}),r};h.createTimeout=function(e,t){var i=t.randomize?Math.random()+1:1,r=Math.round(i*Math.max(t.minTimeout,1)*Math.pow(t.factor,e));return r=Math.min(r,t.maxTimeout),r};h.wrap=function(e,t,i){if(t instanceof Array&&(i=t,t=null),!i){i=[];for(var r in e)typeof e[r]=="function"&&i.push(r)}for(var o=0;o<i.length;o++){var n=i[o],s=e[n];e[n]=function(l){var m=h.operation(t),c=Array.prototype.slice.call(arguments,1),u=c.pop();c.push(function(f){m.retry(f)||(f&&(arguments[0]=m.mainError()),u.apply(this,arguments))}),m.attempt(function(){l.apply(e,c)})}.bind(e,s),e[n].options=t}}});var O=A((ot,v)=>{v.exports=x()});var g=class extends Error{constructor(){super("Throttled function aborted"),this.name="AbortError"}};function C({limit:e,interval:t,strict:i}){if(!Number.isFinite(e))throw new TypeError("Expected `limit` to be a finite number");if(!Number.isFinite(t))throw new TypeError("Expected `interval` to be a finite number");let r=new Map,o=0,n=0;function s(){let c=Date.now();return c-o>t?(n=1,o=c,0):(n<e?n++:(o+=t,n=1),o-c)}let a=[];function l(){let c=Date.now();if(a.length<e)return a.push(c),0;let u=a.shift()+t;return c>=u?(a.push(c),0):(a.push(u),u-c)}let m=i?l:s;return c=>{let u=function(...f){if(!u.isEnabled)return(async()=>c.apply(this,f))();let T;return new Promise((L,D)=>{T=setTimeout(()=>{L(c.apply(this,f)),r.delete(T)},m()),r.set(T,D)})};return u.abort=()=>{for(let f of r.keys())clearTimeout(f),r.get(f)(new g);r.clear(),a.splice(0,a.length)},u.isEnabled=!0,u}}var N=F(O(),1),K=new Set(["Failed to fetch","NetworkError when attempting to fetch resource.","The Internet connection appears to be offline.","Network request failed"]),I=class extends Error{constructor(t){super(),t instanceof Error?(this.originalError=t,{message:t}=t):(this.originalError=new Error(t),this.originalError.stack=this.stack),this.name="AbortError",this.message=t}},Y=(e,t,i)=>{let r=i.retries-(t-1);return e.attemptNumber=t,e.retriesLeft=r,e},G=e=>K.has(e),b=e=>globalThis.DOMException===void 0?new Error(e):new DOMException(e);async function E(e,t){return new Promise((i,r)=>{t={onFailedAttempt(){},retries:10,...t};let o=N.default.operation(t);o.attempt(async n=>{try{i(await e(n))}catch(s){if(!(s instanceof Error)){r(new TypeError(`Non-error was thrown: "${s}". You should only throw errors.`));return}if(s instanceof I)o.stop(),r(s.originalError);else if(s instanceof TypeError&&!G(s.message))o.stop(),r(s);else{Y(s,n,t);try{await t.onFailedAttempt(s)}catch(a){r(a);return}o.retry(s)||r(o.mainError())}}}),t.signal&&!t.signal.aborted&&t.signal.addEventListener("abort",()=>{o.stop();let n=t.signal.reason===void 0?b("The operation was aborted."):t.signal.reason;r(n instanceof Error?n:b(n))},{once:!0})})}function S({throttle:e={interval:1e3,limit:10},retry:t={retries:1,factor:1.66}}){let i=e?C(e):null;return function(o){let n=async()=>await o();if(i&&(n=i(n)),t){let s=n;n=()=>E(s,t)}return n()}}var ut=async e=>await e();var y=class extends Error{constructor(i,r,o,n,s,a){super(`${i}
2
+ ${n}${s?" "+s:""} (${r} ${o}${a?` Request ID: ${a}`:""})`);this.errorMessage=i;this.fetchMethod=r;this.fetchUri=o;this.statusCode=n;this.statusText=s;this.requestId=a;Object.setPrototypeOf(this,y.prototype)}},d=class{constructor(t){var r,o,n,s,a;if(!t.apiKey&&!t.bearerToken)throw new Error("You must provide an API key or a bearer token");let i=t.fetch;if(!i)if(typeof globalThis!="undefined"&&typeof globalThis.fetch!="undefined")i=globalThis.fetch.bind(globalThis);else if(typeof fetch!="undefined")i=fetch;else throw new Error("You must provide or polyfill a fetch implementation when not in a browser");this.options={...t,fetch:i,apiHost:(r=t.apiHost)!=null?r:"https://uniform.app",apiKey:(o=t.apiKey)!=null?o:null,projectId:(n=t.projectId)!=null?n:null,bearerToken:(s=t.bearerToken)!=null?s:null,limitPolicy:(a=t.limitPolicy)!=null?a:S({})}}async getCompositionList(t){let{projectId:i}=this.options,r=this.createUrl("/api/v1/canvas",{...t,projectId:i});return await this.apiClient(r)}async getCompositionBySlug(t){let{projectId:i}=this.options,r=this.createUrl("/api/v1/canvas",{...t,projectId:i});return await this.apiClient(r)}async getCompositionById(t){let{projectId:i}=this.options,r=this.createUrl("/api/v1/canvas",{...t,projectId:i});return await this.apiClient(r)}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:r}=this.options;await this.apiClient(i,{method:"DELETE",body:JSON.stringify({...t,projectId:r}),expectNoContent:!0})}async getComponentDefinitions(t){let{projectId:i}=this.options,r=this.createUrl("/api/v1/canvas-definitions",{...t,projectId:i});return await this.apiClient(r)}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})}async apiClient(t,i){return this.options.limitPolicy(async()=>{var n;let r=this.options.apiKey?{"x-api-key":this.options.apiKey}:{Authorization:`Bearer ${this.options.bearerToken}`},o=await this.options.fetch(t.toString(),{...i,headers:{...i==null?void 0:i.headers,...r}});if(!o.ok){let s="";try{let a=await o.text();try{let l=JSON.parse(a);l.errorMessage?s=Array.isArray(l.errorMessage)?l.errorMessage.join(", "):l.errorMessage:s=a}catch(l){s=a}}catch(a){s="General error"}throw new y(s,(n=i==null?void 0:i.method)!=null?n:"GET",t.toString(),o.status,o.statusText,d.getRequestId(o))}return i!=null&&i.expectNoContent?null:await o.json()})}createUrl(t,i){let r=new URL(`${this.options.apiHost}${t}`);return Object.entries(i!=null?i:{}).forEach(([o,n])=>{var s;typeof n!==void 0&&n!==null&&r.searchParams.append(o,(s=n==null?void 0:n.toString())!=null?s:"")}),r}static getRequestId(t){let i=t.headers.get("x-nf-request-id");if(i)return i}};var yt="$personalization",dt="$test",Tt="$localization",_t="intentTag",At="locale",gt="pz",Ct="test",It="localized",Et=0,Rt=64,wt="$pzCrit",Pt="$tstVrnt",xt="$enr";export{B as a,A as b,F as c,W as d,z as e,Q as f,H as g,X as h,S as i,ut as j,y as k,d as l,yt as m,dt as n,Tt as o,_t as p,At as q,gt as r,Ct as s,It as t,Et as u,Rt as v,wt as w,Pt as x,xt as y};