@uniformdev/canvas 16.2.0 → 16.2.1-alpha.60
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/cli/cli.js +37 -37
- package/dist/cli/cli.mjs +36 -36
- package/dist/index.js +1 -1
- package/package.json +4 -4
package/dist/index.js
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
var B=Object.create;var C=Object.defineProperty;var M=Object.getOwnPropertyDescriptor;var U=Object.getOwnPropertyNames;var F=Object.getPrototypeOf,D=Object.prototype.hasOwnProperty;var z=(r,e)=>{for(var n in e)C(r,n,{get:e[n],enumerable:!0})},L=(r,e,n,t)=>{if(e&&typeof e=="object"||typeof e=="function")for(let o of U(e))!D.call(r,o)&&o!==n&&C(r,o,{get:()=>e[o],enumerable:!(t=M(e,o))||t.enumerable});return r};var N=(r,e,n)=>(n=r!=null?B(F(r)):{},L(e||!r||!r.__esModule?C(n,"default",{value:r,enumerable:!0}):n,r)),H=r=>L(C({},"__esModule",{value:!0}),r);var me={};z(me,{BatchEntry:()=>P,CANVAS_DRAFT_STATE:()=>we,CANVAS_ENRICHMENT_TAG_PARAM:()=>te,CANVAS_INTENT_TAG_PARAM:()=>X,CANVAS_LOCALE_TAG_PARAM:()=>R,CANVAS_LOCALIZATION_SLOT:()=>x,CANVAS_LOCALIZATION_TYPE:()=>v,CANVAS_PERSONALIZATION_PARAM:()=>w,CANVAS_PERSONALIZE_SLOT:()=>ee,CANVAS_PERSONALIZE_TYPE:()=>W,CANVAS_PUBLISHED_STATE:()=>_e,CANVAS_TEST_SLOT:()=>ne,CANVAS_TEST_TYPE:()=>Q,CANVAS_TEST_VARIANT_PARAM:()=>_,CanvasClient:()=>y,CanvasClientError:()=>u,ChildEnhancerBuilder:()=>f,EnhancerBuilder:()=>I,UniqueBatchEntries:()=>g,compose:()=>Y,createBatchEnhancer:()=>q,createEventBus:()=>ae,createLimitPolicy:()=>T,enhance:()=>K,extractLocales:()=>k,getChannelName:()=>b,getComponentPath:()=>A,isSystemComponentDefinition:()=>oe,localize:()=>pe,mapSlotToPersonalizedVariations:()=>re,mapSlotToTestVariations:()=>ie,nullLimitPolicy:()=>l,subscribeToComposition:()=>ce,walkComponentTree:()=>d});module.exports=H(me);function d(r,e){let n=[{ancestorsAndSelf:[{component:r,parentSlot:void 0,parentSlotIndex:void 0}]}];do{let t=n.pop();if(!t)continue;let o=t.ancestorsAndSelf[0];e(o.component,t.ancestorsAndSelf,{replaceComponent:s=>{Object.assign(o.component,s),["parameters","variant","slots","data","_pattern","_patternError"].forEach(a=>{s[a]||delete o.component[a]})},removeComponent:()=>{let{parentSlot:s,parentSlotIndex:c}=t.ancestorsAndSelf[0],a=t.ancestorsAndSelf[1];if(s&&typeof c!="undefined")a.component.slots[s].splice(c,1);else throw new Error("Unable to delete composition.")},insertAfter:s=>{let c=Array.isArray(s)?s:[s],{parentSlot:a,parentSlotIndex:p}=t.ancestorsAndSelf[0],m=t.ancestorsAndSelf[1];if(a&&typeof p!="undefined")m.component.slots[a].splice(p+1,0,...c);else throw new Error("Unable to insert after a component not in a slot.")}});let i=o.component.slots;if(i){let s=Object.keys(i);for(let c=s.length-1;c>=0;c--){let a=s[c],p=i[a];for(let m=p.length-1;m>=0;m--)n.push({ancestorsAndSelf:[{component:p[m],parentSlot:a,parentSlotIndex:m},...t.ancestorsAndSelf]})}}}while(n.length>0)}function A(r){let e=[];for(let n=r.length-1;n>=0;n--){let{parentSlot:t,parentSlotIndex:o}=r[n];t&&o!==void 0&&e.push(`${t}[${o}]`)}return`.${e.join(".")}`}var g=class{constructor(e,n){this.groups=e.reduce((t,o)=>{var s;let i=n(o.args);return t[i]=(s=t[i])!=null?s:[],t[i].push(o),t},{})}resolveKey(e,n){this.groups[e].forEach(t=>t.resolve(n))}resolveRemaining(e){Object.keys(this.groups).forEach(n=>{this.groups[n].forEach(t=>{t.isCompleted||t.resolve(e)})})}};var f=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(o=>this._paramMatches.push({name:o,enhancer:this._resolveParameterEnhancer(n)})),this}parameterType(e,n){return(Array.isArray(e)?e:[e]).forEach(o=>this._paramMatches.push({type:o,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 t;return(t=this._paramMatches.find(o=>o.name&&o.name===e||o.type&&o.type===n.type||!o.type&&!o.name))==null?void 0:t.enhancer}resolveComponentEnhancers(){return this._dataMatches}_resolveParameterEnhancer(e){return typeof e=="function"?{enhanceOne:e}:e}},I=class{constructor(){this._componentIndex={};this._rootBuilder=new f}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(o=>{this._componentIndex[o]=this._componentIndex[o]||new f,n(this._componentIndex[o])}),this}resolveParameterEnhancer(e,n,t){let o=this._componentIndex[e.type];if(o){let i=o.resolveParameterEnhancer(n,t);if(i)return i}return this._rootBuilder.resolveParameterEnhancer(n,t)}resolveComponentEnhancers(e){let n=this._rootBuilder.resolveComponentEnhancers(),t=this._componentIndex[e.type];if(t){n=new Map(n);for(let[o,i]of t.resolveComponentEnhancers())n.set(o,i)}return n}};var P=class{constructor(e,n,t){this._resolve=e;this._reject=n;this.args=t;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 q({handleBatch:r,shouldQueue:e,limitPolicy:n}){let t=[];return{enhanceOne:async s=>{if(!e||e(s))return new Promise((c,a)=>{t.push(new P(c,a,s))})},completeAll:async()=>{if(t.length>0){try{await r(t)}catch(c){t.forEach(a=>a.reject(c))}if(t.some(c=>!c.isCompleted))throw new Error("The completeAll() function failed to resolve or reject all promises in the batch!")}let s=t.length;return t=[],s},limitPolicy:n}}var j=N(require("p-throttle")),V=N(require("p-retry"));function T({throttle:r={interval:1e3,limit:10},retry:e={retries:1,factor:1.66}}){let n=r?(0,j.default)(r):null;return function(o){let i=async()=>await o();if(n&&(i=n(i)),e){let s=i;i=()=>(0,V.default)(s,e)}return i()}}var l=async r=>await r();async function K({composition:r,enhancers:e,context:n,onErrors:t=o=>{throw new Error(o.map(i=>`${i.message}
|
1
|
+
"use strict";var B=Object.create;var C=Object.defineProperty;var M=Object.getOwnPropertyDescriptor;var U=Object.getOwnPropertyNames;var F=Object.getPrototypeOf,D=Object.prototype.hasOwnProperty;var z=(r,e)=>{for(var n in e)C(r,n,{get:e[n],enumerable:!0})},L=(r,e,n,t)=>{if(e&&typeof e=="object"||typeof e=="function")for(let o of U(e))!D.call(r,o)&&o!==n&&C(r,o,{get:()=>e[o],enumerable:!(t=M(e,o))||t.enumerable});return r};var N=(r,e,n)=>(n=r!=null?B(F(r)):{},L(e||!r||!r.__esModule?C(n,"default",{value:r,enumerable:!0}):n,r)),H=r=>L(C({},"__esModule",{value:!0}),r);var me={};z(me,{BatchEntry:()=>P,CANVAS_DRAFT_STATE:()=>we,CANVAS_ENRICHMENT_TAG_PARAM:()=>te,CANVAS_INTENT_TAG_PARAM:()=>X,CANVAS_LOCALE_TAG_PARAM:()=>R,CANVAS_LOCALIZATION_SLOT:()=>x,CANVAS_LOCALIZATION_TYPE:()=>v,CANVAS_PERSONALIZATION_PARAM:()=>w,CANVAS_PERSONALIZE_SLOT:()=>ee,CANVAS_PERSONALIZE_TYPE:()=>W,CANVAS_PUBLISHED_STATE:()=>_e,CANVAS_TEST_SLOT:()=>ne,CANVAS_TEST_TYPE:()=>Q,CANVAS_TEST_VARIANT_PARAM:()=>_,CanvasClient:()=>y,CanvasClientError:()=>u,ChildEnhancerBuilder:()=>f,EnhancerBuilder:()=>I,UniqueBatchEntries:()=>g,compose:()=>Y,createBatchEnhancer:()=>q,createEventBus:()=>ae,createLimitPolicy:()=>T,enhance:()=>K,extractLocales:()=>k,getChannelName:()=>b,getComponentPath:()=>A,isSystemComponentDefinition:()=>oe,localize:()=>pe,mapSlotToPersonalizedVariations:()=>re,mapSlotToTestVariations:()=>ie,nullLimitPolicy:()=>l,subscribeToComposition:()=>ce,walkComponentTree:()=>d});module.exports=H(me);function d(r,e){let n=[{ancestorsAndSelf:[{component:r,parentSlot:void 0,parentSlotIndex:void 0}]}];do{let t=n.pop();if(!t)continue;let o=t.ancestorsAndSelf[0];e(o.component,t.ancestorsAndSelf,{replaceComponent:s=>{Object.assign(o.component,s),["parameters","variant","slots","data","_pattern","_patternError"].forEach(a=>{s[a]||delete o.component[a]})},removeComponent:()=>{let{parentSlot:s,parentSlotIndex:c}=t.ancestorsAndSelf[0],a=t.ancestorsAndSelf[1];if(s&&typeof c!="undefined")a.component.slots[s].splice(c,1);else throw new Error("Unable to delete composition.")},insertAfter:s=>{let c=Array.isArray(s)?s:[s],{parentSlot:a,parentSlotIndex:p}=t.ancestorsAndSelf[0],m=t.ancestorsAndSelf[1];if(a&&typeof p!="undefined")m.component.slots[a].splice(p+1,0,...c);else throw new Error("Unable to insert after a component not in a slot.")}});let i=o.component.slots;if(i){let s=Object.keys(i);for(let c=s.length-1;c>=0;c--){let a=s[c],p=i[a];for(let m=p.length-1;m>=0;m--)n.push({ancestorsAndSelf:[{component:p[m],parentSlot:a,parentSlotIndex:m},...t.ancestorsAndSelf]})}}}while(n.length>0)}function A(r){let e=[];for(let n=r.length-1;n>=0;n--){let{parentSlot:t,parentSlotIndex:o}=r[n];t&&o!==void 0&&e.push(`${t}[${o}]`)}return`.${e.join(".")}`}var g=class{constructor(e,n){this.groups=e.reduce((t,o)=>{var s;let i=n(o.args);return t[i]=(s=t[i])!=null?s:[],t[i].push(o),t},{})}resolveKey(e,n){this.groups[e].forEach(t=>t.resolve(n))}resolveRemaining(e){Object.keys(this.groups).forEach(n=>{this.groups[n].forEach(t=>{t.isCompleted||t.resolve(e)})})}};var f=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(o=>this._paramMatches.push({name:o,enhancer:this._resolveParameterEnhancer(n)})),this}parameterType(e,n){return(Array.isArray(e)?e:[e]).forEach(o=>this._paramMatches.push({type:o,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 t;return(t=this._paramMatches.find(o=>o.name&&o.name===e||o.type&&o.type===n.type||!o.type&&!o.name))==null?void 0:t.enhancer}resolveComponentEnhancers(){return this._dataMatches}_resolveParameterEnhancer(e){return typeof e=="function"?{enhanceOne:e}:e}},I=class{constructor(){this._componentIndex={};this._rootBuilder=new f}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(o=>{this._componentIndex[o]=this._componentIndex[o]||new f,n(this._componentIndex[o])}),this}resolveParameterEnhancer(e,n,t){let o=this._componentIndex[e.type];if(o){let i=o.resolveParameterEnhancer(n,t);if(i)return i}return this._rootBuilder.resolveParameterEnhancer(n,t)}resolveComponentEnhancers(e){let n=this._rootBuilder.resolveComponentEnhancers(),t=this._componentIndex[e.type];if(t){n=new Map(n);for(let[o,i]of t.resolveComponentEnhancers())n.set(o,i)}return n}};var P=class{constructor(e,n,t){this._resolve=e;this._reject=n;this.args=t;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 q({handleBatch:r,shouldQueue:e,limitPolicy:n}){let t=[];return{enhanceOne:async s=>{if(!e||e(s))return new Promise((c,a)=>{t.push(new P(c,a,s))})},completeAll:async()=>{if(t.length>0){try{await r(t)}catch(c){t.forEach(a=>a.reject(c))}if(t.some(c=>!c.isCompleted))throw new Error("The completeAll() function failed to resolve or reject all promises in the batch!")}let s=t.length;return t=[],s},limitPolicy:n}}var j=N(require("p-throttle")),V=N(require("p-retry"));function T({throttle:r={interval:1e3,limit:10},retry:e={retries:1,factor:1.66}}){let n=r?(0,j.default)(r):null;return function(o){let i=async()=>await o();if(n&&(i=n(i)),e){let s=i;i=()=>(0,V.default)(s,e)}return i()}}var l=async r=>await r();async function K({composition:r,enhancers:e,context:n,onErrors:t=o=>{throw new Error(o.map(i=>`${i.message}
|
2
2
|
${typeof i.error=="object"&&"stack"in i.error?i.error.stack:i.error}`).join(`
|
3
3
|
|
4
4
|
`))}}){let o=[],i=new Set,s=new Set;d(r,(a,p)=>{var h;Object.entries((h=a.parameters)!=null?h:{}).forEach(([S,O])=>{let E=e.resolveParameterEnhancer(a,S,O);E&&(s.add(E),o.push(G(a,p,S,O,E,n)))});let m=e.resolveComponentEnhancers(a);o.push(Z(a,p,m,n)),i.add(m)}),o.push(...Array.from(i).flatMap(a=>Array.from(a).map(async([,p])=>{var m;try{p.completeAll&&await((m=p.limitPolicy)!=null?m:l)(()=>p.completeAll())}catch(h){return{error:h,message:"Batch component enhancer failed. Individual failed components should receive their own rejections."}}}))),o.push(...Array.from(s).map(async a=>{var p;try{a.completeAll&&await((p=a.limitPolicy)!=null?p:l)(()=>a.completeAll())}catch(m){return{error:m,message:"Batch parameter enhancer failed. Individual failed parameters should receive their own rejections."}}}));let c=(await Promise.all(o)).flatMap(a=>Array.isArray(a)?a:[a]).filter(a=>a);c.length&&t(c)}async function Z(r,e,n,t){return n.size&&(r.data={}),await Promise.all(Array.from(n).map(async([o,i])=>{var s;try{let a=await(i.completeAll?l:(s=i.limitPolicy)!=null?s:l)(async()=>i.enhanceOne({component:r,context:t}));a!=null&&(r.data[o]=a)}catch(c){let a=`Component ${A(e)} (type: ${r.type}): data.${o} enhancer threw exception. Data key will not be present.`;return delete r.data[o],{message:a,error:c}}}))}async function G(r,e,n,t,o,i){var s;try{let a=await(o.completeAll?l:(s=o.limitPolicy)!=null?s:l)(async()=>o.enhanceOne({parameter:t,parameterName:n,component:r,context:i}));a===null?delete r.parameters[n]:typeof a=="undefined"?r.parameters[n]={...t,value:t.value}:r.parameters[n]={...t,value:a}}catch(c){let a=`Component ${A(e)} (type: ${r.type}): enhancing parameter ${n} (type: ${t.type}) threw exception. Parameter will be removed.`;return delete r.parameters[n],{message:a,error:c}}}var Y=(r,...e)=>({enhanceOne:t=>{let o="enhanceOne"in r?r.enhanceOne(t):r(t);for(let i of e){let s=J(o)?o:Promise.resolve(o),c="enhanceOne"in i?i.enhanceOne:i;o=s.then(a=>c({...t,parameter:{type:t.parameter.type,value:a}}))}return o},completeAll:async()=>{var t,o;for(let i of e)if("completeAll"in i)throw new Error("Only the first enhancer in a compose chain can use the completeAll function (batching)");return(o="completeAll"in r?(t=r.completeAll)==null?void 0:t.call(r):0)!=null?o:0}});function J(r){return!!r&&(typeof r=="object"||typeof r=="function")&&typeof r.then=="function"}var u=class extends Error{constructor(n,t,o,i,s,c){super(`${n}
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@uniformdev/canvas",
|
3
|
-
"version": "16.2.
|
3
|
+
"version": "16.2.1-alpha.60+4d040ee77",
|
4
4
|
"description": "Common functionality and types for Uniform Canvas",
|
5
5
|
"license": "SEE LICENSE IN LICENSE.txt",
|
6
6
|
"main": "./dist/index.js",
|
@@ -46,12 +46,12 @@
|
|
46
46
|
"devDependencies": {
|
47
47
|
"@types/retry": "0.12.1",
|
48
48
|
"@types/yargs": "17.0.10",
|
49
|
-
"@uniformdev/cli": "^16.2.
|
49
|
+
"@uniformdev/cli": "^16.2.1-alpha.60+4d040ee77",
|
50
50
|
"pusher-js": "7.0.6",
|
51
51
|
"yargs": "17.5.1"
|
52
52
|
},
|
53
53
|
"dependencies": {
|
54
|
-
"@uniformdev/context": "^16.2.
|
54
|
+
"@uniformdev/context": "^16.2.1-alpha.60+4d040ee77",
|
55
55
|
"isomorphic-unfetch": "^3.1.0",
|
56
56
|
"p-limit": "^3.1.0",
|
57
57
|
"p-retry": "^4.6.2",
|
@@ -63,5 +63,5 @@
|
|
63
63
|
"publishConfig": {
|
64
64
|
"access": "public"
|
65
65
|
},
|
66
|
-
"gitHead": "
|
66
|
+
"gitHead": "4d040ee77ebb1baf10bc23fff43b367100350e44"
|
67
67
|
}
|