@uniformdev/canvas 17.3.1-alpha.194 → 17.4.0
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-O4RYVPVV.mjs +4 -0
- package/dist/cli/cli.d.ts +1 -1
- package/dist/cli/cli.js +52 -52
- package/dist/cli/cli.mjs +1 -1
- package/dist/{createEventBus-33bac5ac.d.ts → createEventBus-a8e85b6e.d.ts} +6 -6
- package/dist/index.d.ts +9 -5
- package/dist/index.esm.js +1 -1
- package/dist/index.js +2 -2
- package/dist/index.mjs +1 -1
- package/package.json +4 -4
- package/dist/chunk-IK3FODEI.mjs +0 -4
package/dist/cli/cli.mjs
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
import{
|
1
|
+
import{A as Xe,J as y6,K as ni,a as te,b as w2,c as H,d as b2,e as Gp,f as y2,g as di,h as wa,i as Yp,j as $1,k as ri,y as ie}from"../chunk-O4RYVPVV.mjs";var cr=H((E7,mr)=>{var ap=1e3,pp=ap*60,tp=pp*60,Va=tp*24,Xl=Va*7,e8=Va*365.25;mr.exports=function(e,a){a=a||{};var p=typeof e;if(p==="string"&&e.length>0)return a8(e);if(p==="number"&&isFinite(e))return a.long?t8(e):p8(e);throw new Error("val is not a non-empty string or a valid number. val="+JSON.stringify(e))};function a8(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*e8;case"weeks":case"week":case"w":return p*Xl;case"days":case"day":case"d":return p*Va;case"hours":case"hour":case"hrs":case"hr":case"h":return p*tp;case"minutes":case"minute":case"mins":case"min":case"m":return p*pp;case"seconds":case"second":case"secs":case"sec":case"s":return p*ap;case"milliseconds":case"millisecond":case"msecs":case"msec":case"ms":return p;default:return}}}}function p8(e){var a=Math.abs(e);return a>=Va?Math.round(e/Va)+"d":a>=tp?Math.round(e/tp)+"h":a>=pp?Math.round(e/pp)+"m":a>=ap?Math.round(e/ap)+"s":e+"ms"}function t8(e){var a=Math.abs(e);return a>=Va?wt(e,a,Va,"day"):a>=tp?wt(e,a,tp,"hour"):a>=pp?wt(e,a,pp,"minute"):a>=ap?wt(e,a,ap,"second"):e+" ms"}function wt(e,a,p,t){var i=a>=p*1.5;return Math.round(e/p)+" "+t+(i?"s":"")}});var zi=H((O7,ur)=>{function i8(e){p.debug=p,p.default=p,p.coerce=o,p.disable=r,p.enable=i,p.enabled=d,p.humanize=cr(),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}ur.exports=i8});var fr=H((Je,bt)=>{Je.formatArgs=r8;Je.save=n8;Je.load=o8;Je.useColors=d8;Je.storage=s8();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 d8(){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 r8(e){if(e[0]=(this.useColors?"%c":"")+this.namespace+(this.useColors?" %c":" ")+e[0]+(this.useColors?"%c ":" ")+"+"+bt.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 n8(e){try{e?Je.storage.setItem("debug",e):Je.storage.removeItem("debug")}catch(a){}}function o8(){let e;try{e=Je.storage.getItem("debug")}catch(a){}return!e&&typeof process!="undefined"&&"env"in process&&(e=process.env.DEBUG),e}function s8(){try{return localStorage}catch(e){}}bt.exports=zi()(Je);var{formatters:l8}=bt.exports;l8.j=function(e){try{return JSON.stringify(e)}catch(a){return"[UnexpectedJSONParseError]: "+a.message}}});var gr=H((T7,hr)=>{"use strict";hr.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 br=H((P7,wr)=>{"use strict";var m8=te("os"),vr=te("tty"),d1=gr(),{env:Ne}=process,Z1;d1("no-color")||d1("no-colors")||d1("color=false")||d1("color=never")?Z1=0:(d1("color")||d1("colors")||d1("color=true")||d1("color=always"))&&(Z1=1);"FORCE_COLOR"in Ne&&(Ne.FORCE_COLOR==="true"?Z1=1:Ne.FORCE_COLOR==="false"?Z1=0:Z1=Ne.FORCE_COLOR.length===0?1:Math.min(parseInt(Ne.FORCE_COLOR,10),3));function Wi(e){return e===0?!1:{level:e,hasBasic:!0,has256:e>=2,has16m:e>=3}}function Gi(e,a){if(Z1===0)return 0;if(d1("color=16m")||d1("color=full")||d1("color=truecolor"))return 3;if(d1("color=256"))return 2;if(e&&!a&&Z1===void 0)return 0;let p=Z1||0;if(Ne.TERM==="dumb")return p;if(process.platform==="win32"){let t=m8.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 c8(e){let a=Gi(e,e&&e.isTTY);return Wi(a)}wr.exports={supportsColor:c8,stdout:Wi(Gi(!0,vr.isatty(1))),stderr:Wi(Gi(!0,vr.isatty(2)))}});var _r=H((Te,_t)=>{var u8=te("tty"),yt=te("util");Te.init=y8;Te.log=v8;Te.formatArgs=h8;Te.save=w8;Te.load=b8;Te.useColors=f8;Te.destroy=yt.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=br();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 f8(){return"colors"in Te.inspectOpts?Boolean(Te.inspectOpts.colors):u8.isatty(process.stderr.fd)}function h8(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+"+_t.exports.humanize(this.diff)+"\x1B[0m")}else e[0]=g8()+a+" "+e[0]}function g8(){return Te.inspectOpts.hideDate?"":new Date().toISOString()+" "}function v8(...e){return process.stderr.write(yt.format(...e)+`
|
4
4
|
`)}function w8(e){e?process.env.DEBUG=e:delete process.env.DEBUG}function b8(){return process.env.DEBUG}function y8(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]]}_t.exports=zi()(Te);var{formatters:yr}=_t.exports;yr.o=function(e){return this.inspectOpts.colors=this.useColors,yt.inspect(e,this.inspectOpts).split(`
|
@@ -916,12 +916,12 @@ interface paths$3 {
|
|
916
916
|
compositionIDs?: string[];
|
917
917
|
/** Specify a single composition to fetch by slug. Changes response from list to single. */
|
918
918
|
slug?: string;
|
919
|
-
/** Specify a single composition to fetch by assodicated
|
920
|
-
|
921
|
-
/** Specify a single composition to fetch by assodicated
|
922
|
-
|
923
|
-
/** Required when using
|
924
|
-
|
919
|
+
/** Specify a single composition to fetch by assodicated project map node ID. Changes response from list to single. */
|
920
|
+
projectMapNodeId?: string;
|
921
|
+
/** Specify a single composition to fetch by assodicated project map node path. Changes response from list to single. */
|
922
|
+
projectMapNodePath?: string;
|
923
|
+
/** Required when using project map node id or path for fetch. */
|
924
|
+
projectMapId?: string;
|
925
925
|
/** The component type (by public ID) to filter by. Note that this filters the root composition type only; components in slots are not matched by this filter. */
|
926
926
|
type?: string[];
|
927
927
|
/** State of compositions to fetch. 0 = draft, 64 = published. */
|
package/dist/index.d.ts
CHANGED
@@ -1,5 +1,5 @@
|
|
1
|
-
import { C as ComponentInstance, a as ComponentParameter, b as CompositionGetParameters, c as CompositionPutParameters, d as CompositionDeleteParameters, e as ComponentDefinitionGetParameters, f as ComponentDefinitionPutParameters, g as ComponentDefinitionDeleteParameters, D as DataSourceGetParameters, h as DataSourcesGetParameters, i as DataSourcePutParameters, j as DataSourceDeleteParameters, k as DataTypeGetParameters, l as DataTypeGetResponse, m as DataTypePutParameters, n as DataTypeDeleteParameters, R as RootComponentInstance, P as PreviewEventBus, o as CompositionGetResponse } from './createEventBus-
|
2
|
-
export { O as CanvasDefinitions, X as ChannelSubscription, z as ComponentDefinition, s as ComponentDefinitionAPIDeleteRequest, r as ComponentDefinitionAPIPutRequest, q as ComponentDefinitionAPIResponse, g as ComponentDefinitionDeleteParameters, e as ComponentDefinitionGetParameters, p as ComponentDefinitionGetResponse, t as ComponentDefinitionListAPIOptions, u as ComponentDefinitionParameter, y as ComponentDefinitionPermission, f as ComponentDefinitionPutParameters, x as ComponentDefinitionSlot, w as ComponentDefinitionSlugSettings, v as ComponentDefinitionVariant, C as ComponentInstance, a as ComponentParameter, H as CompositionAPIDeleteRequest, J as CompositionAPIOptions, G as CompositionAPIResponse, d as CompositionDeleteParameters, F as CompositionGetListResponse, B as CompositionGetOrderBy, b as CompositionGetParameters, o as CompositionGetResponse, I as CompositionListAPIResponse, c as CompositionPutParameters, E as CompositionUIStatus, A as CreatingComponentDefinition, K as DataElementConnectionDefinition, N as DataResourceDefinition, M as DataResourceDefinitions, L as DataResourceVariables, U as DataSource, j as DataSourceDeleteParameters, D as DataSourceGetParameters, Q as DataSourceGetResponse, V as DataSourceInfo, i as DataSourcePutParameters, h as DataSourcesGetParameters, S as DataSourcesGetResponse, T as DataType, n as DataTypeDeleteParameters, k as DataTypeGetParameters, l as DataTypeGetResponse, m as DataTypePutParameters, W as DataVariableDefinition, P as PreviewEventBus, R as RootComponentInstance, Y as createEventBus } from './createEventBus-
|
1
|
+
import { C as ComponentInstance, a as ComponentParameter, b as CompositionGetParameters, c as CompositionPutParameters, d as CompositionDeleteParameters, e as ComponentDefinitionGetParameters, f as ComponentDefinitionPutParameters, g as ComponentDefinitionDeleteParameters, D as DataSourceGetParameters, h as DataSourcesGetParameters, i as DataSourcePutParameters, j as DataSourceDeleteParameters, k as DataTypeGetParameters, l as DataTypeGetResponse, m as DataTypePutParameters, n as DataTypeDeleteParameters, R as RootComponentInstance, P as PreviewEventBus, o as CompositionGetResponse } from './createEventBus-a8e85b6e.js';
|
2
|
+
export { O as CanvasDefinitions, X as ChannelSubscription, z as ComponentDefinition, s as ComponentDefinitionAPIDeleteRequest, r as ComponentDefinitionAPIPutRequest, q as ComponentDefinitionAPIResponse, g as ComponentDefinitionDeleteParameters, e as ComponentDefinitionGetParameters, p as ComponentDefinitionGetResponse, t as ComponentDefinitionListAPIOptions, u as ComponentDefinitionParameter, y as ComponentDefinitionPermission, f as ComponentDefinitionPutParameters, x as ComponentDefinitionSlot, w as ComponentDefinitionSlugSettings, v as ComponentDefinitionVariant, C as ComponentInstance, a as ComponentParameter, H as CompositionAPIDeleteRequest, J as CompositionAPIOptions, G as CompositionAPIResponse, d as CompositionDeleteParameters, F as CompositionGetListResponse, B as CompositionGetOrderBy, b as CompositionGetParameters, o as CompositionGetResponse, I as CompositionListAPIResponse, c as CompositionPutParameters, E as CompositionUIStatus, A as CreatingComponentDefinition, K as DataElementConnectionDefinition, N as DataResourceDefinition, M as DataResourceDefinitions, L as DataResourceVariables, U as DataSource, j as DataSourceDeleteParameters, D as DataSourceGetParameters, Q as DataSourceGetResponse, V as DataSourceInfo, i as DataSourcePutParameters, h as DataSourcesGetParameters, S as DataSourcesGetResponse, T as DataType, n as DataTypeDeleteParameters, k as DataTypeGetParameters, l as DataTypeGetResponse, m as DataTypePutParameters, W as DataVariableDefinition, P as PreviewEventBus, R as RootComponentInstance, Y as createEventBus } from './createEventBus-a8e85b6e.js';
|
3
3
|
import { Options } from 'p-throttle';
|
4
4
|
import { Options as Options$1 } from 'p-retry';
|
5
5
|
import { ApiClient, ClientOptions, ExceptProject, ApiClientError } from '@uniformdev/context/api';
|
@@ -111,6 +111,10 @@ declare function walkComponentTree<TContext = unknown>(component: ComponentInsta
|
|
111
111
|
/** Traversal context for this node */
|
112
112
|
currentContext: TContext | undefined) => void, initialContext?: TContext): void;
|
113
113
|
declare function getComponentPath(ancestorsAndSelf: Array<ComponentLocationReference>): string;
|
114
|
+
/** Returns the JSON pointer of a component based on its location */
|
115
|
+
declare function getComponentJsonPointer(ancestorsAndSelf: Array<ComponentLocationReference>, { withSlots }?: {
|
116
|
+
withSlots?: boolean | undefined;
|
117
|
+
}): string;
|
114
118
|
|
115
119
|
/** A single entry in a batch of queued enhancements. */
|
116
120
|
declare class BatchEntry<TArgs, TResult> {
|
@@ -345,7 +349,7 @@ declare class CanvasClient extends ApiClient<ClientOptions> {
|
|
345
349
|
}[];
|
346
350
|
totalCount?: number | undefined;
|
347
351
|
}>;
|
348
|
-
|
352
|
+
getCompositionByProjectMapNodePath(options: Pick<CompositionGetParameters, 'projectMapNodePath' | 'projectMapId' | 'state' | 'skipEnhance' | 'skipPatternResolution' | 'withComponentIDs' | 'withUIStatus' | 'withTotalCount'>): Promise<{
|
349
353
|
state: number;
|
350
354
|
uiStatus?: "Draft" | "Modified" | "Published" | "Orphan" | undefined;
|
351
355
|
projectId: string;
|
@@ -421,7 +425,7 @@ declare class CanvasClient extends ApiClient<ClientOptions> {
|
|
421
425
|
} | undefined;
|
422
426
|
};
|
423
427
|
}>;
|
424
|
-
|
428
|
+
getCompositionByProjectMapNodeId(options: Pick<CompositionGetParameters, 'projectMapNodeId' | 'projectMapId' | 'state' | 'skipEnhance' | 'skipPatternResolution' | 'withComponentIDs' | 'withUIStatus' | 'withTotalCount'>): Promise<{
|
425
429
|
state: number;
|
426
430
|
uiStatus?: "Draft" | "Modified" | "Published" | "Orphan" | undefined;
|
427
431
|
projectId: string;
|
@@ -1020,4 +1024,4 @@ declare class EdgeCanvasClient extends ApiClient<ClientOptions> {
|
|
1020
1024
|
|
1021
1025
|
declare const CanvasClientError: typeof ApiClientError;
|
1022
1026
|
|
1023
|
-
export { AddComponentMessage, BatchEnhancer, BatchEntry, CANVAS_DRAFT_STATE, CANVAS_ENRICHMENT_TAG_PARAM, CANVAS_INTENT_TAG_PARAM, CANVAS_LOCALE_TAG_PARAM, CANVAS_LOCALIZATION_SLOT, CANVAS_LOCALIZATION_TYPE, CANVAS_PERSONALIZATION_PARAM, CANVAS_PERSONALIZE_SLOT, CANVAS_PERSONALIZE_TYPE, CANVAS_PUBLISHED_STATE, CANVAS_TEST_SLOT, CANVAS_TEST_TYPE, CANVAS_TEST_VARIANT_PARAM, CanvasClient, CanvasClientError, Channel, ChannelMessage, ChildEnhancerBuilder, ComponentEnhancer, ComponentEnhancerFunction, ComponentEnhancerOptions, ComponentLocationReference, ComponentParameterEnhancer, ComponentParameterEnhancerFunction, ComponentParameterEnhancerOptions, CompositionDataDiagnostic, CompositionIssue, CompositionPatternIssue, DataElementBindingIssue, DataResourceIssue, DataResourceVariableIssue, DataSourceClient, DataTypeClient, EdgeCanvasClient, EdgeCompositionGetResponse, EnhancerBuilder, EnhancerContext, EnhancerError, EventNames, IN_CONTEXT_EDITOR_QUERY_STRING_PARAM, LimitPolicy, MessageHandler, MoveComponentMessage, ReadyMessage, SelectComponentMessage, SubscribeToCompositionOptions, UncachedCanvasClient, UniqueBatchEntries, UnsubscribeCallback, UpdateCompositionMessage, WalkComponentTreeActions, compose, createBatchEnhancer, createCanvasChannel, createLimitPolicy, enhance, extractLocales, generateHash, getChannelName, getComponentPath, isAddComponentMessage, isMovingComponentMessage, isReadyMessage, isSelectComponentMessage, isSystemComponentDefinition, isUpdateCompositionMessage, localize, mapSlotToPersonalizedVariations, mapSlotToTestVariations, nullLimitPolicy, subscribeToComposition, walkComponentTree };
|
1027
|
+
export { AddComponentMessage, BatchEnhancer, BatchEntry, CANVAS_DRAFT_STATE, CANVAS_ENRICHMENT_TAG_PARAM, CANVAS_INTENT_TAG_PARAM, CANVAS_LOCALE_TAG_PARAM, CANVAS_LOCALIZATION_SLOT, CANVAS_LOCALIZATION_TYPE, CANVAS_PERSONALIZATION_PARAM, CANVAS_PERSONALIZE_SLOT, CANVAS_PERSONALIZE_TYPE, CANVAS_PUBLISHED_STATE, CANVAS_TEST_SLOT, CANVAS_TEST_TYPE, CANVAS_TEST_VARIANT_PARAM, CanvasClient, CanvasClientError, Channel, ChannelMessage, ChildEnhancerBuilder, ComponentEnhancer, ComponentEnhancerFunction, ComponentEnhancerOptions, ComponentLocationReference, ComponentParameterEnhancer, ComponentParameterEnhancerFunction, ComponentParameterEnhancerOptions, CompositionDataDiagnostic, CompositionIssue, CompositionPatternIssue, DataElementBindingIssue, DataResourceIssue, DataResourceVariableIssue, DataSourceClient, DataTypeClient, EdgeCanvasClient, EdgeCompositionGetResponse, EnhancerBuilder, EnhancerContext, EnhancerError, EventNames, IN_CONTEXT_EDITOR_QUERY_STRING_PARAM, LimitPolicy, MessageHandler, MoveComponentMessage, ReadyMessage, SelectComponentMessage, SubscribeToCompositionOptions, UncachedCanvasClient, UniqueBatchEntries, UnsubscribeCallback, UpdateCompositionMessage, WalkComponentTreeActions, compose, createBatchEnhancer, createCanvasChannel, createLimitPolicy, enhance, extractLocales, generateHash, getChannelName, getComponentJsonPointer, getComponentPath, isAddComponentMessage, isMovingComponentMessage, isReadyMessage, isSelectComponentMessage, isSystemComponentDefinition, isUpdateCompositionMessage, localize, mapSlotToPersonalizedVariations, mapSlotToTestVariations, nullLimitPolicy, subscribeToComposition, walkComponentTree };
|
package/dist/index.esm.js
CHANGED
@@ -1 +1 @@
|
|
1
|
-
import{$ as Q,A as p,B as q,C as r,D as s,E as t,F as u,G as v,H as w,I as x,J as y,K as z,L as A,M as B,N as C,O as D,P as E,Q as F,R as G,S as H,T as I,U as J,V as K,W as L,X as M,Y as N,Z as O,_ as P,aa as R,ba as S,ca as T,da as U,l as a,m as b,n as c,o as d,p as e,q as f,r as g,s as h,t as i,u as j,v as k,w as l,x as m,y as n,z as o}from"./chunk-
|
1
|
+
import{$ as Q,A as p,B as q,C as r,D as s,E as t,F as u,G as v,H as w,I as x,J as y,K as z,L as A,M as B,N as C,O as D,P as E,Q as F,R as G,S as H,T as I,U as J,V as K,W as L,X as M,Y as N,Z as O,_ as P,aa as R,ba as S,ca as T,da as U,ea as V,l as a,m as b,n as c,o as d,p as e,q as f,r as g,s as h,t as i,u as j,v as k,w as l,x as m,y as n,z as o}from"./chunk-O4RYVPVV.mjs";export{U as ApiClientError,g as BatchEntry,y as CANVAS_DRAFT_STATE,C as CANVAS_ENRICHMENT_TAG_PARAM,t as CANVAS_INTENT_TAG_PARAM,u as CANVAS_LOCALE_TAG_PARAM,x as CANVAS_LOCALIZATION_SLOT,s as CANVAS_LOCALIZATION_TYPE,A as CANVAS_PERSONALIZATION_PARAM,v as CANVAS_PERSONALIZE_SLOT,q as CANVAS_PERSONALIZE_TYPE,z as CANVAS_PUBLISHED_STATE,w as CANVAS_TEST_SLOT,r as CANVAS_TEST_TYPE,B as CANVAS_TEST_VARIANT_PARAM,m as CanvasClient,V as CanvasClientError,e as ChildEnhancerBuilder,o as DataSourceClient,p as DataTypeClient,T as EdgeCanvasClient,f as EnhancerBuilder,D as IN_CONTEXT_EDITOR_QUERY_STRING_PARAM,n as UncachedCanvasClient,d as UniqueBatchEntries,l as compose,h as createBatchEnhancer,S as createCanvasChannel,I as createEventBus,i as createLimitPolicy,k as enhance,L as extractLocales,H as generateHash,J as getChannelName,c as getComponentJsonPointer,b as getComponentPath,Q as isAddComponentMessage,R as isMovingComponentMessage,O as isReadyMessage,N as isSelectComponentMessage,E as isSystemComponentDefinition,P as isUpdateCompositionMessage,M as localize,F as mapSlotToPersonalizedVariations,G as mapSlotToTestVariations,j as nullLimitPolicy,K as subscribeToComposition,a as walkComponentTree};
|
package/dist/index.js
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
"use strict";var ue=Object.create;var _=Object.defineProperty;var he=Object.getOwnPropertyDescriptor;var de=Object.getOwnPropertyNames;var fe=Object.getPrototypeOf,ye=Object.prototype.hasOwnProperty;var M=(n,e)=>()=>(e||n((e={exports:{}}).exports,e),e.exports),Ce=(n,e)=>{for(var t in e)_(n,t,{get:e[t],enumerable:!0})},K=(n,e,t,o)=>{if(e&&typeof e=="object"||typeof e=="function")for(let r of de(e))!ye.call(n,r)&&r!==t&&_(n,r,{get:()=>e[r],enumerable:!(o=he(e,r))||o.enumerable});return n};var ge=(n,e,t)=>(t=n!=null?ue(fe(n)):{},K(e||!n||!n.__esModule?_(t,"default",{value:n,enumerable:!0}):t,n)),Ee=n=>K(_({},"__esModule",{value:!0}),n);var Pe=(n,e,t)=>{if(!e.has(n))throw TypeError("Cannot "+t)};var I=(n,e,t)=>(Pe(n,e,"read from private field"),t?t.call(n):e.get(n)),X=(n,e,t)=>{if(e.has(n))throw TypeError("Cannot add the same private member more than once");e instanceof WeakSet?e.add(n):e.set(n,t)};var te=M((it,ee)=>{function C(n,e){typeof e=="boolean"&&(e={forever:e}),this._originalTimeouts=JSON.parse(JSON.stringify(n)),this._timeouts=n,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))}ee.exports=C;C.prototype.reset=function(){this._attempts=1,this._timeouts=this._originalTimeouts.slice(0)};C.prototype.stop=function(){this._timeout&&clearTimeout(this._timeout),this._timer&&clearTimeout(this._timer),this._timeouts=[],this._cachedTimeouts=null};C.prototype.retry=function(n){if(this._timeout&&clearTimeout(this._timeout),!n)return!1;var e=new Date().getTime();if(n&&e-this._operationStart>=this._maxRetryTime)return this._errors.push(n),this._errors.unshift(new Error("RetryOperation timeout occurred")),!1;this._errors.push(n);var t=this._timeouts.shift();if(t===void 0)if(this._cachedTimeouts)this._errors.splice(0,this._errors.length-1),t=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)},t),this._options.unref&&this._timer.unref(),!0};C.prototype.attempt=function(n,e){this._fn=n,e&&(e.timeout&&(this._operationTimeout=e.timeout),e.cb&&(this._operationTimeoutCb=e.cb));var t=this;this._operationTimeoutCb&&(this._timeout=setTimeout(function(){t._operationTimeoutCb()},t._operationTimeout)),this._operationStart=new Date().getTime(),this._fn(this._attempts)};C.prototype.try=function(n){console.log("Using RetryOperation.try() is deprecated"),this.attempt(n)};C.prototype.start=function(n){console.log("Using RetryOperation.start() is deprecated"),this.attempt(n)};C.prototype.start=C.prototype.try;C.prototype.errors=function(){return this._errors};C.prototype.attempts=function(){return this._attempts};C.prototype.mainError=function(){if(this._errors.length===0)return null;for(var n={},e=null,t=0,o=0;o<this._errors.length;o++){var r=this._errors[o],s=r.message,i=(n[s]||0)+1;n[s]=i,i>=t&&(e=r,t=i)}return e}});var ne=M(P=>{var Te=te();P.operation=function(n){var e=P.timeouts(n);return new Te(e,{forever:n&&(n.forever||n.retries===1/0),unref:n&&n.unref,maxRetryTime:n&&n.maxRetryTime})};P.timeouts=function(n){if(n instanceof Array)return[].concat(n);var e={retries:10,factor:2,minTimeout:1*1e3,maxTimeout:1/0,randomize:!1};for(var t in n)e[t]=n[t];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 n&&n.forever&&!o.length&&o.push(this.createTimeout(r,e)),o.sort(function(s,i){return s-i}),o};P.createTimeout=function(n,e){var t=e.randomize?Math.random()+1:1,o=Math.round(t*Math.max(e.minTimeout,1)*Math.pow(e.factor,n));return o=Math.min(o,e.maxTimeout),o};P.wrap=function(n,e,t){if(e instanceof Array&&(t=e,e=null),!t){t=[];for(var o in n)typeof n[o]=="function"&&t.push(o)}for(var r=0;r<t.length;r++){var s=t[r],i=n[s];n[s]=function(c){var h=P.operation(e),l=Array.prototype.slice.call(arguments,1),m=l.pop();l.push(function(u){h.retry(u)||(u&&(arguments[0]=h.mainError()),m.apply(this,arguments))}),h.attempt(function(){c.apply(n,l)})}.bind(n,i),n[s].options=e}}});var re=M((ct,oe)=>{oe.exports=ne()});var Xe={};Ce(Xe,{ApiClientError:()=>Q.ApiClientError,BatchEntry:()=>R,CANVAS_DRAFT_STATE:()=>bt,CANVAS_ENRICHMENT_TAG_PARAM:()=>je,CANVAS_INTENT_TAG_PARAM:()=>De,CANVAS_LOCALE_TAG_PARAM:()=>J,CANVAS_LOCALIZATION_SLOT:()=>z,CANVAS_LOCALIZATION_TYPE:()=>F,CANVAS_PERSONALIZATION_PARAM:()=>H,CANVAS_PERSONALIZE_SLOT:()=>Ue,CANVAS_PERSONALIZE_TYPE:()=>Me,CANVAS_PUBLISHED_STATE:()=>Ot,CANVAS_TEST_SLOT:()=>Le,CANVAS_TEST_TYPE:()=>Ne,CANVAS_TEST_VARIANT_PARAM:()=>W,CanvasClient:()=>S,CanvasClientError:()=>Ke,ChildEnhancerBuilder:()=>v,DataSourceClient:()=>$,DataTypeClient:()=>b,EdgeCanvasClient:()=>Y,EnhancerBuilder:()=>D,IN_CONTEXT_EDITOR_QUERY_STRING_PARAM:()=>Ge,UncachedCanvasClient:()=>k,UniqueBatchEntries:()=>N,compose:()=>Se,createBatchEnhancer:()=>xe,createCanvasChannel:()=>Qe,createEventBus:()=>Fe,createLimitPolicy:()=>V,enhance:()=>Ie,extractLocales:()=>le,generateHash:()=>Z,getChannelName:()=>q,getComponentPath:()=>w,isAddComponentMessage:()=>qe,isMovingComponentMessage:()=>Ye,isReadyMessage:()=>We,isSelectComponentMessage:()=>He,isSystemComponentDefinition:()=>Ve,isUpdateCompositionMessage:()=>Ze,localize:()=>ze,mapSlotToPersonalizedVariations:()=>ke,mapSlotToTestVariations:()=>Be,nullLimitPolicy:()=>E,subscribeToComposition:()=>Je,walkComponentTree:()=>T});module.exports=Ee(Xe);function T(n,e,t){var s;let o=[{ancestorsAndSelf:[{component:n,parentSlot:void 0,parentSlotIndex:void 0}],context:t}],r=new Map;do{let i=o.pop();if(!i)continue;let a=i.ancestorsAndSelf[0],c=!0,h=(s=r.get(a.component))!=null?s:i.context;e(a.component,i.ancestorsAndSelf,{replaceComponent:m=>{Object.assign(a.component,m),["parameters","variant","slots","data","_pattern","_patternError"].forEach(f=>{m[f]||delete a.component[f]})},removeComponent:()=>{let{parentSlot:m,parentSlotIndex:u}=i.ancestorsAndSelf[0],f=i.ancestorsAndSelf[1];if(m&&typeof u!="undefined")f.component.slots[m].splice(u,1);else throw new Error("Unable to delete composition.")},insertAfter:m=>{let u=Array.isArray(m)?m:[m],{parentSlot:f,parentSlotIndex:p}=i.ancestorsAndSelf[0],d=i.ancestorsAndSelf[1];if(f&&typeof p!="undefined")d.component.slots[f].splice(p+1,0,...u),o.unshift(...u.map(y=>({ancestorsAndSelf:[{component:y,parentSlot:f,get parentSlotIndex(){return d.component.slots[f].findIndex(g=>g===y)}},...i.ancestorsAndSelf],context:h})));else throw new Error("Unable to insert after a component not in a slot.")},stopProcessingDescendants(){c=!1},setDescendantsContext(m){h=m},setChildContext(m,u){r.set(m,u)}},h);let l=a.component.slots;if(c&&l){let m=Object.keys(l);for(let u=m.length-1;u>=0;u--){let f=m[u],p=l[f];for(let d=p.length-1;d>=0;d--){let y=p[d];o.push({ancestorsAndSelf:[{component:y,parentSlot:f,get parentSlotIndex(){return a.component.slots[f].findIndex(g=>g===y)}},...i.ancestorsAndSelf],context:h})}}}}while(o.length>0)}function w(n){let e=[];for(let t=n.length-1;t>=0;t--){let{parentSlot:o,parentSlotIndex:r}=n[t];o&&r!==void 0&&e.push(`${o}[${r}]`)}return`.${e.join(".")}`}var N=class{constructor(e,t){this.groups=e.reduce((o,r)=>{var i;let s=t(r.args);return o[s]=(i=o[s])!=null?i:[],o[s].push(r),o},{})}resolveKey(e,t){this.groups[e].forEach(o=>o.resolve(t))}resolveRemaining(e){Object.keys(this.groups).forEach(t=>{this.groups[t].forEach(o=>{o.isCompleted||o.resolve(e)})})}};var v=class{constructor(){this._paramMatches=Array();this._dataMatches=new Map}parameter(e){return this._paramMatches.push({enhancer:this._resolveParameterEnhancer(e)}),this}parameterName(e,t){return(Array.isArray(e)?e:[e]).forEach(r=>this._paramMatches.push({name:r,enhancer:this._resolveParameterEnhancer(t)})),this}parameterType(e,t){return(Array.isArray(e)?e:[e]).forEach(r=>this._paramMatches.push({type:r,enhancer:this._resolveParameterEnhancer(t)})),this}data(e,t){if(this._dataMatches.has(e))throw new Error(`${e} enhancer data key has been used more than once. This will cause data loss.`);return this._dataMatches.set(e,typeof t=="function"?{enhanceOne:t}:t),this}resolveParameterEnhancer(e,t){var o;return(o=this._paramMatches.find(r=>r.name&&r.name===e||r.type&&r.type===t.type||!r.type&&!r.name))==null?void 0:o.enhancer}resolveComponentEnhancers(){return this._dataMatches}_resolveParameterEnhancer(e){return typeof e=="function"?{enhanceOne:e}:e}},D=class{constructor(){this._componentIndex={};this._rootBuilder=new v}parameter(e){return this._rootBuilder.parameter(e),this}parameterName(e,t){return this._rootBuilder.parameterName(e,t),this}parameterType(e,t){return this._rootBuilder.parameterType(e,t),this}data(e,t){return this._rootBuilder.data(e,t),this}component(e,t){return(Array.isArray(e)?e:[e]).forEach(r=>{this._componentIndex[r]=this._componentIndex[r]||new v,t(this._componentIndex[r])}),this}resolveParameterEnhancer(e,t,o){let r=this._componentIndex[e.type];if(r){let s=r.resolveParameterEnhancer(t,o);if(s)return s}return this._rootBuilder.resolveParameterEnhancer(t,o)}resolveComponentEnhancers(e){let t=this._rootBuilder.resolveComponentEnhancers(),o=this._componentIndex[e.type];if(o){t=new Map(t);for(let[r,s]of o.resolveComponentEnhancers())t.set(r,s)}return t}};var R=class{constructor(e,t,o){this._resolve=e;this._reject=t;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 xe({handleBatch:n,shouldQueue:e,limitPolicy:t}){let o=[];return{enhanceOne:async i=>{if(!e||e(i))return new Promise((a,c)=>{o.push(new R(a,c,i))})},completeAll:async()=>{if(o.length>0){try{await n(o)}catch(a){o.forEach(c=>c.reject(a))}if(o.some(a=>!a.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:t}}var U=class extends Error{constructor(){super("Throttled function aborted"),this.name="AbortError"}};function L({limit:n,interval:e,strict:t}){if(!Number.isFinite(n))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<n?s++:(r+=e,s=1),r-l)}let a=[];function c(){let l=Date.now();if(a.length<n)return a.push(l),0;let m=a.shift()+e;return l>=m?(a.push(l),0):(a.push(m),m-l)}let h=t?c:i;return l=>{let m=function(...u){if(!m.isEnabled)return(async()=>l.apply(this,u))();let f;return new Promise((p,d)=>{f=setTimeout(()=>{p(l.apply(this,u)),o.delete(f)},h()),o.set(f,d)})};return m.abort=()=>{for(let u of o.keys())clearTimeout(u),o.get(u)(new U);o.clear(),a.splice(0,a.length)},m.isEnabled=!0,m}}var ie=ge(re(),1),ve=new Set(["Failed to fetch","NetworkError when attempting to fetch resource.","The Internet connection appears to be offline.","Network request failed"]),j=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}},Ae=(n,e,t)=>{let o=t.retries-(e-1);return n.attemptNumber=e,n.retriesLeft=o,n},_e=n=>ve.has(n),se=n=>globalThis.DOMException===void 0?new Error(n):new DOMException(n);async function G(n,e){return new Promise((t,o)=>{e={onFailedAttempt(){},retries:10,...e};let r=ie.default.operation(e);r.attempt(async s=>{try{t(await n(s))}catch(i){if(!(i instanceof Error)){o(new TypeError(`Non-error was thrown: "${i}". You should only throw errors.`));return}if(i instanceof j)r.stop(),o(i.originalError);else if(i instanceof TypeError&&!_e(i.message))r.stop(),o(i);else{Ae(i,s,e);try{await e.onFailedAttempt(i)}catch(a){o(a);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?se("The operation was aborted."):e.signal.reason;o(s instanceof Error?s:se(s))},{once:!0})})}function V({throttle:n={interval:1e3,limit:10},retry:e={retries:1,factor:1.66}}){let t=n?L(n):null;return function(r){let s=async()=>await r();if(t&&(s=t(s)),e){let i=s;s=()=>G(i,e)}return s()}}var E=async n=>await n();async function Ie({composition:n,enhancers:e,context:t,onErrors:o=r=>{throw new Error(r.map(s=>`${s.message}
|
1
|
+
"use strict";var ue=Object.create;var I=Object.defineProperty;var he=Object.getOwnPropertyDescriptor;var de=Object.getOwnPropertyNames;var fe=Object.getPrototypeOf,ye=Object.prototype.hasOwnProperty;var O=(n,e)=>()=>(e||n((e={exports:{}}).exports,e),e.exports),Ce=(n,e)=>{for(var t in e)I(n,t,{get:e[t],enumerable:!0})},K=(n,e,t,o)=>{if(e&&typeof e=="object"||typeof e=="function")for(let r of de(e))!ye.call(n,r)&&r!==t&&I(n,r,{get:()=>e[r],enumerable:!(o=he(e,r))||o.enumerable});return n};var ge=(n,e,t)=>(t=n!=null?ue(fe(n)):{},K(e||!n||!n.__esModule?I(t,"default",{value:n,enumerable:!0}):t,n)),Ee=n=>K(I({},"__esModule",{value:!0}),n);var Pe=(n,e,t)=>{if(!e.has(n))throw TypeError("Cannot "+t)};var _=(n,e,t)=>(Pe(n,e,"read from private field"),t?t.call(n):e.get(n)),X=(n,e,t)=>{if(e.has(n))throw TypeError("Cannot add the same private member more than once");e instanceof WeakSet?e.add(n):e.set(n,t)};var te=O((at,ee)=>{function C(n,e){typeof e=="boolean"&&(e={forever:e}),this._originalTimeouts=JSON.parse(JSON.stringify(n)),this._timeouts=n,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))}ee.exports=C;C.prototype.reset=function(){this._attempts=1,this._timeouts=this._originalTimeouts.slice(0)};C.prototype.stop=function(){this._timeout&&clearTimeout(this._timeout),this._timer&&clearTimeout(this._timer),this._timeouts=[],this._cachedTimeouts=null};C.prototype.retry=function(n){if(this._timeout&&clearTimeout(this._timeout),!n)return!1;var e=new Date().getTime();if(n&&e-this._operationStart>=this._maxRetryTime)return this._errors.push(n),this._errors.unshift(new Error("RetryOperation timeout occurred")),!1;this._errors.push(n);var t=this._timeouts.shift();if(t===void 0)if(this._cachedTimeouts)this._errors.splice(0,this._errors.length-1),t=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)},t),this._options.unref&&this._timer.unref(),!0};C.prototype.attempt=function(n,e){this._fn=n,e&&(e.timeout&&(this._operationTimeout=e.timeout),e.cb&&(this._operationTimeoutCb=e.cb));var t=this;this._operationTimeoutCb&&(this._timeout=setTimeout(function(){t._operationTimeoutCb()},t._operationTimeout)),this._operationStart=new Date().getTime(),this._fn(this._attempts)};C.prototype.try=function(n){console.log("Using RetryOperation.try() is deprecated"),this.attempt(n)};C.prototype.start=function(n){console.log("Using RetryOperation.start() is deprecated"),this.attempt(n)};C.prototype.start=C.prototype.try;C.prototype.errors=function(){return this._errors};C.prototype.attempts=function(){return this._attempts};C.prototype.mainError=function(){if(this._errors.length===0)return null;for(var n={},e=null,t=0,o=0;o<this._errors.length;o++){var r=this._errors[o],s=r.message,i=(n[s]||0)+1;n[s]=i,i>=t&&(e=r,t=i)}return e}});var ne=O(P=>{var ve=te();P.operation=function(n){var e=P.timeouts(n);return new ve(e,{forever:n&&(n.forever||n.retries===1/0),unref:n&&n.unref,maxRetryTime:n&&n.maxRetryTime})};P.timeouts=function(n){if(n instanceof Array)return[].concat(n);var e={retries:10,factor:2,minTimeout:1*1e3,maxTimeout:1/0,randomize:!1};for(var t in n)e[t]=n[t];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 n&&n.forever&&!o.length&&o.push(this.createTimeout(r,e)),o.sort(function(s,i){return s-i}),o};P.createTimeout=function(n,e){var t=e.randomize?Math.random()+1:1,o=Math.round(t*Math.max(e.minTimeout,1)*Math.pow(e.factor,n));return o=Math.min(o,e.maxTimeout),o};P.wrap=function(n,e,t){if(e instanceof Array&&(t=e,e=null),!t){t=[];for(var o in n)typeof n[o]=="function"&&t.push(o)}for(var r=0;r<t.length;r++){var s=t[r],i=n[s];n[s]=function(c){var h=P.operation(e),l=Array.prototype.slice.call(arguments,1),m=l.pop();l.push(function(u){h.retry(u)||(u&&(arguments[0]=h.mainError()),m.apply(this,arguments))}),h.attempt(function(){c.apply(n,l)})}.bind(n,i),n[s].options=e}}});var re=O((pt,oe)=>{oe.exports=ne()});var et={};Ce(et,{ApiClientError:()=>Q.ApiClientError,BatchEntry:()=>R,CANVAS_DRAFT_STATE:()=>Mt,CANVAS_ENRICHMENT_TAG_PARAM:()=>Ge,CANVAS_INTENT_TAG_PARAM:()=>Ue,CANVAS_LOCALE_TAG_PARAM:()=>J,CANVAS_LOCALIZATION_SLOT:()=>z,CANVAS_LOCALIZATION_TYPE:()=>F,CANVAS_PERSONALIZATION_PARAM:()=>H,CANVAS_PERSONALIZE_SLOT:()=>je,CANVAS_PERSONALIZE_TYPE:()=>Ne,CANVAS_PUBLISHED_STATE:()=>Ot,CANVAS_TEST_SLOT:()=>Le,CANVAS_TEST_TYPE:()=>De,CANVAS_TEST_VARIANT_PARAM:()=>W,CanvasClient:()=>S,CanvasClientError:()=>Xe,ChildEnhancerBuilder:()=>v,DataSourceClient:()=>$,DataTypeClient:()=>b,EdgeCanvasClient:()=>Y,EnhancerBuilder:()=>D,IN_CONTEXT_EDITOR_QUERY_STRING_PARAM:()=>Ve,UncachedCanvasClient:()=>k,UniqueBatchEntries:()=>N,compose:()=>be,createBatchEnhancer:()=>Te,createCanvasChannel:()=>Ke,createEventBus:()=>Je,createLimitPolicy:()=>V,enhance:()=>we,extractLocales:()=>le,generateHash:()=>Z,getChannelName:()=>q,getComponentJsonPointer:()=>xe,getComponentPath:()=>w,isAddComponentMessage:()=>Ye,isMovingComponentMessage:()=>Qe,isReadyMessage:()=>Ze,isSelectComponentMessage:()=>We,isSystemComponentDefinition:()=>ke,isUpdateCompositionMessage:()=>qe,localize:()=>He,mapSlotToPersonalizedVariations:()=>Be,mapSlotToTestVariations:()=>$e,nullLimitPolicy:()=>E,subscribeToComposition:()=>ze,walkComponentTree:()=>T});module.exports=Ee(et);function T(n,e,t){var s;let o=[{ancestorsAndSelf:[{component:n,parentSlot:void 0,parentSlotIndex:void 0}],context:t}],r=new Map;do{let i=o.pop();if(!i)continue;let a=i.ancestorsAndSelf[0],c=!0,h=(s=r.get(a.component))!=null?s:i.context;e(a.component,i.ancestorsAndSelf,{replaceComponent:m=>{Object.assign(a.component,m),["parameters","variant","slots","data","_pattern","_patternError"].forEach(f=>{m[f]||delete a.component[f]})},removeComponent:()=>{let{parentSlot:m,parentSlotIndex:u}=i.ancestorsAndSelf[0],f=i.ancestorsAndSelf[1];if(m&&typeof u!="undefined")f.component.slots[m].splice(u,1);else throw new Error("Unable to delete composition.")},insertAfter:m=>{let u=Array.isArray(m)?m:[m],{parentSlot:f,parentSlotIndex:p}=i.ancestorsAndSelf[0],d=i.ancestorsAndSelf[1];if(f&&typeof p!="undefined")d.component.slots[f].splice(p+1,0,...u),o.unshift(...u.map(y=>({ancestorsAndSelf:[{component:y,parentSlot:f,get parentSlotIndex(){return d.component.slots[f].findIndex(g=>g===y)}},...i.ancestorsAndSelf],context:h})));else throw new Error("Unable to insert after a component not in a slot.")},stopProcessingDescendants(){c=!1},setDescendantsContext(m){h=m},setChildContext(m,u){r.set(m,u)}},h);let l=a.component.slots;if(c&&l){let m=Object.keys(l);for(let u=m.length-1;u>=0;u--){let f=m[u],p=l[f];for(let d=p.length-1;d>=0;d--){let y=p[d];o.push({ancestorsAndSelf:[{component:y,parentSlot:f,get parentSlotIndex(){return a.component.slots[f].findIndex(g=>g===y)}},...i.ancestorsAndSelf],context:h})}}}}while(o.length>0)}function w(n){let e=[];for(let t=n.length-1;t>=0;t--){let{parentSlot:o,parentSlotIndex:r}=n[t];o&&r!==void 0&&e.push(`${o}[${r}]`)}return`.${e.join(".")}`}function xe(n,{withSlots:e=!1}={}){let t=[];for(let o=n.length-1;o>=0;o--){let{parentSlot:r,parentSlotIndex:s}=n[o];r&&s!==void 0&&t.push(`${r}/${s}`)}return e?`/slots/${t.join("/slots/")}`:`/${t.join("/")}`}var N=class{constructor(e,t){this.groups=e.reduce((o,r)=>{var i;let s=t(r.args);return o[s]=(i=o[s])!=null?i:[],o[s].push(r),o},{})}resolveKey(e,t){this.groups[e].forEach(o=>o.resolve(t))}resolveRemaining(e){Object.keys(this.groups).forEach(t=>{this.groups[t].forEach(o=>{o.isCompleted||o.resolve(e)})})}};var v=class{constructor(){this._paramMatches=Array();this._dataMatches=new Map}parameter(e){return this._paramMatches.push({enhancer:this._resolveParameterEnhancer(e)}),this}parameterName(e,t){return(Array.isArray(e)?e:[e]).forEach(r=>this._paramMatches.push({name:r,enhancer:this._resolveParameterEnhancer(t)})),this}parameterType(e,t){return(Array.isArray(e)?e:[e]).forEach(r=>this._paramMatches.push({type:r,enhancer:this._resolveParameterEnhancer(t)})),this}data(e,t){if(this._dataMatches.has(e))throw new Error(`${e} enhancer data key has been used more than once. This will cause data loss.`);return this._dataMatches.set(e,typeof t=="function"?{enhanceOne:t}:t),this}resolveParameterEnhancer(e,t){var o;return(o=this._paramMatches.find(r=>r.name&&r.name===e||r.type&&r.type===t.type||!r.type&&!r.name))==null?void 0:o.enhancer}resolveComponentEnhancers(){return this._dataMatches}_resolveParameterEnhancer(e){return typeof e=="function"?{enhanceOne:e}:e}},D=class{constructor(){this._componentIndex={};this._rootBuilder=new v}parameter(e){return this._rootBuilder.parameter(e),this}parameterName(e,t){return this._rootBuilder.parameterName(e,t),this}parameterType(e,t){return this._rootBuilder.parameterType(e,t),this}data(e,t){return this._rootBuilder.data(e,t),this}component(e,t){return(Array.isArray(e)?e:[e]).forEach(r=>{this._componentIndex[r]=this._componentIndex[r]||new v,t(this._componentIndex[r])}),this}resolveParameterEnhancer(e,t,o){let r=this._componentIndex[e.type];if(r){let s=r.resolveParameterEnhancer(t,o);if(s)return s}return this._rootBuilder.resolveParameterEnhancer(t,o)}resolveComponentEnhancers(e){let t=this._rootBuilder.resolveComponentEnhancers(),o=this._componentIndex[e.type];if(o){t=new Map(t);for(let[r,s]of o.resolveComponentEnhancers())t.set(r,s)}return t}};var R=class{constructor(e,t,o){this._resolve=e;this._reject=t;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 Te({handleBatch:n,shouldQueue:e,limitPolicy:t}){let o=[];return{enhanceOne:async i=>{if(!e||e(i))return new Promise((a,c)=>{o.push(new R(a,c,i))})},completeAll:async()=>{if(o.length>0){try{await n(o)}catch(a){o.forEach(c=>c.reject(a))}if(o.some(a=>!a.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:t}}var U=class extends Error{constructor(){super("Throttled function aborted"),this.name="AbortError"}};function j({limit:n,interval:e,strict:t}){if(!Number.isFinite(n))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<n?s++:(r+=e,s=1),r-l)}let a=[];function c(){let l=Date.now();if(a.length<n)return a.push(l),0;let m=a.shift()+e;return l>=m?(a.push(l),0):(a.push(m),m-l)}let h=t?c:i;return l=>{let m=function(...u){if(!m.isEnabled)return(async()=>l.apply(this,u))();let f;return new Promise((p,d)=>{f=setTimeout(()=>{p(l.apply(this,u)),o.delete(f)},h()),o.set(f,d)})};return m.abort=()=>{for(let u of o.keys())clearTimeout(u),o.get(u)(new U);o.clear(),a.splice(0,a.length)},m.isEnabled=!0,m}}var ie=ge(re(),1),Ae=new Set(["Failed to fetch","NetworkError when attempting to fetch resource.","The Internet connection appears to be offline.","Network request failed"]),L=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}},Ie=(n,e,t)=>{let o=t.retries-(e-1);return n.attemptNumber=e,n.retriesLeft=o,n},_e=n=>Ae.has(n),se=n=>globalThis.DOMException===void 0?new Error(n):new DOMException(n);async function G(n,e){return new Promise((t,o)=>{e={onFailedAttempt(){},retries:10,...e};let r=ie.default.operation(e);r.attempt(async s=>{try{t(await n(s))}catch(i){if(!(i instanceof Error)){o(new TypeError(`Non-error was thrown: "${i}". You should only throw errors.`));return}if(i instanceof L)r.stop(),o(i.originalError);else if(i instanceof TypeError&&!_e(i.message))r.stop(),o(i);else{Ie(i,s,e);try{await e.onFailedAttempt(i)}catch(a){o(a);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?se("The operation was aborted."):e.signal.reason;o(s instanceof Error?s:se(s))},{once:!0})})}function V({throttle:n={interval:1e3,limit:10},retry:e={retries:1,factor:1.66}}){let t=n?j(n):null;return function(r){let s=async()=>await r();if(t&&(s=t(s)),e){let i=s;s=()=>G(i,e)}return s()}}var E=async n=>await n();async function we({composition:n,enhancers:e,context:t,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
|
-
`))}}){let r=[],s=new Set,i=new Set;T(n,(c,h)=>{var m;Object.entries((m=c.parameters)!=null?m:{}).forEach(([u,f])=>{let p=e.resolveParameterEnhancer(c,u,f);p&&(i.add(p),r.push(Re(c,h,u,f,p,t)))});let l=e.resolveComponentEnhancers(c);r.push(we(c,h,l,t)),s.add(l)}),r.push(...Array.from(s).flatMap(c=>Array.from(c).map(async([,h])=>{var l;try{h.completeAll&&await((l=h.limitPolicy)!=null?l:E)(()=>h.completeAll())}catch(m){return{error:m,message:"Batch component enhancer failed. Individual failed components should receive their own rejections."}}}))),r.push(...Array.from(i).map(async c=>{var h;try{c.completeAll&&await((h=c.limitPolicy)!=null?h:E)(()=>c.completeAll())}catch(l){return{error:l,message:"Batch parameter enhancer failed. Individual failed parameters should receive their own rejections."}}}));let a=(await Promise.all(r)).flatMap(c=>Array.isArray(c)?c:[c]).filter(c=>c);a.length&&o(a)}async function we(n,e,t,o){return t.size&&(n.data={}),await Promise.all(Array.from(t).map(async([r,s])=>{var i;try{let c=await(s.completeAll?E:(i=s.limitPolicy)!=null?i:E)(async()=>s.enhanceOne({component:n,context:o}));c!=null&&(n.data[r]=c)}catch(a){let c=`Component ${w(e)} (type: ${n.type}): data.${r} enhancer threw exception. Data key will not be present.`;return delete n.data[r],{message:c,error:a}}}))}async function Re(n,e,t,o,r,s){var i;try{let c=await(r.completeAll?E:(i=r.limitPolicy)!=null?i:E)(async()=>r.enhanceOne({parameter:o,parameterName:t,component:n,context:s}));c===null?delete n.parameters[t]:typeof c=="undefined"?n.parameters[t]={...o,value:o.value}:n.parameters[t]={...o,value:c}}catch(a){let c=`Component ${w(e)} (type: ${n.type}): enhancing parameter ${t} (type: ${o.type}) threw exception. Parameter will be removed.`;return delete n.parameters[t],{message:c,error:a}}}var Se=(n,...e)=>({enhanceOne:o=>{let r="enhanceOne"in n?n.enhanceOne(o):n(o);for(let s of e){let i=be(r)?r:Promise.resolve(r),a="enhanceOne"in s?s.enhanceOne:s;r=i.then(c=>a({...o,parameter:{type:o.parameter.type,value:c}}))}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 n?(o=n.completeAll)==null?void 0:o.call(n):0)!=null?r:0}});function be(n){return!!n&&(typeof n=="object"||typeof n=="function")&&typeof n.then=="function"}var ae=require("@uniformdev/context/api"),S=class extends ae.ApiClient{constructor(t){t.limitPolicy||(t.limitPolicy=V({}));super(t);this.canvasUrl="/api/v1/canvas"}async getCompositionList(t){let{projectId:o}=this.options,r=this.createUrl(this.canvasUrl,{...t,projectId:o});return await this.apiClient(r)}async getCompositionBySitemapNodePath(t){let{projectId:o}=this.options,r=this.createUrl(this.canvasUrl,{...t,projectId:o});return await this.apiClient(r)}async getCompositionBySitemapNodeId(t){let{projectId:o}=this.options,r=this.createUrl(this.canvasUrl,{...t,projectId:o});return await this.apiClient(r)}async getCompositionBySlug(t){let{projectId:o}=this.options,r=this.createUrl(this.canvasUrl,{...t,projectId:o});return await this.apiClient(r)}async getCompositionById(t){let{projectId:o}=this.options,r=this.createUrl(this.canvasUrl,{...t,projectId:o});return await this.apiClient(r)}async updateComposition(t){let o=this.createUrl("/api/v1/canvas");await this.apiClient(o,{method:"PUT",body:JSON.stringify({...t,projectId:this.options.projectId}),expectNoContent:!0})}async removeComposition(t){let o=this.createUrl("/api/v1/canvas"),{projectId:r}=this.options;await this.apiClient(o,{method:"DELETE",body:JSON.stringify({...t,projectId:r}),expectNoContent:!0})}async getComponentDefinitions(t){let{projectId:o}=this.options,r=this.createUrl("/api/v1/canvas-definitions",{...t,projectId:o});return await this.apiClient(r)}async updateComponentDefinition(t){let o=this.createUrl("/api/v1/canvas-definitions");await this.apiClient(o,{method:"PUT",body:JSON.stringify({...t,projectId:this.options.projectId}),expectNoContent:!0})}async removeComponentDefinition(t){let o=this.createUrl("/api/v1/canvas-definitions");await this.apiClient(o,{method:"DELETE",body:JSON.stringify({...t,projectId:this.options.projectId}),expectNoContent:!0})}},k=class extends S{constructor(e){super({...e,bypassCache:!0})}};var ce=require("@uniformdev/context/api"),B="/api/v1/data-source",Oe="/api/v1/data-sources",$=class extends ce.ApiClient{constructor(e){super(e)}async get(e){let{projectId:t}=this.options,o=this.createUrl(B,{...e,projectId:t});return await this.apiClient(o)}async getList(e){let{projectId:t}=this.options,o=this.createUrl(Oe,{...e,projectId:t});return await this.apiClient(o)}async upsert(e){let t=this.createUrl(B);await this.apiClient(t,{method:"PUT",body:JSON.stringify({...e,projectId:this.options.projectId}),expectNoContent:!0})}async remove(e){let t=this.createUrl(B);await this.apiClient(t,{method:"DELETE",body:JSON.stringify({...e,projectId:this.options.projectId}),expectNoContent:!0})}};var pe=require("@uniformdev/context/api");var x,A=class extends pe.ApiClient{constructor(e){super(e)}async get(e){let{projectId:t}=this.options,o=this.createUrl(I(A,x),{...e,projectId:t});return await this.apiClient(o)}async upsert(e){let t=this.createUrl(I(A,x));await this.apiClient(t,{method:"PUT",body:JSON.stringify({...e,projectId:this.options.projectId}),expectNoContent:!0})}async remove(e){let t=this.createUrl(I(A,x));await this.apiClient(t,{method:"DELETE",body:JSON.stringify({...e,projectId:this.options.projectId}),expectNoContent:!0})}},b=A;x=new WeakMap,X(b,x,"/api/v1/data-types");var Me="$personalization",Ne="$test",F="$localization",De="intentTag",J="locale",Ue="pz",Le="test",z="localized",bt=0,Ot=64,H="$pzCrit",W="$tstVrnt",je="$enr",Ge="is_incontext_editing_mode";var Ve=n=>n.startsWith("$");function ke(n){return n?n.map((e,t)=>{var s,i;let o=(i=(s=e.parameters)==null?void 0:s[H])==null?void 0:i.value,r=(o==null?void 0:o.name)||`pz-${t}-${e.type}`;return{...e,id:r,pz:o}}):[]}function Be(n){return n?n.map((e,t)=>{var s,i,a;let o=(i=(s=e.parameters)==null?void 0:s[W])==null?void 0:i.value,r=(a=o==null?void 0:o.id)!=null?a:"testId"in e?e.testId:`ab-${t}-${e.type}`;return{...e,id:r}}):[]}var Z=({composition:n,secret:e})=>{if(!e)return;let t=`${JSON.stringify(n)}-${e}`,o=0;for(let r=0;r<t.length;r++){let s=t.charCodeAt(r);o=(o<<5)-o+s,o|=0}return o};var me="https://js.pusher.com/7.0.3/pusher.min.js";async function $e(){if(!(typeof document=="undefined"||typeof window=="undefined"))return window.Pusher?window.Pusher:new Promise((n,e)=>{let t=setTimeout(()=>{window.Pusher&&n(window.Pusher),e(`Unable to load pusher.js; Uniform Canvas live preview disabled. Consider adding <script src="${me}"><\/script> manually.`)},5e3),o=document.createElement("script");o.src=me,o.addEventListener("load",()=>{clearTimeout(t),n(window.Pusher)}),document.head.appendChild(o)})}async function Fe(){let n=await $e();if(!n)return;let e=window.__UNIFORM_EVENT_BUS__;if(!e){let t=new n("7b5f5abd160fea549ffe",{cluster:"mt1"});t.connect(),console.log("[canvas] \u{1F525} preview connected"),e=window.__UNIFORM_EVENT_BUS__={subscribe:o=>{let r=t.subscribe(o);return{unsubscribe:()=>t.unsubscribe(o),addEventHandler:(s,i)=>(r.bind(s,i),()=>r.unbind(s,i))}}}}return e}function q(n,e,t){return`${n}.${e}@${t}`}function Je({projectId:n,compositionId:e,compositionState:t=0,eventBus:{subscribe:o},callback:r,event:s="updated"}){let i=q(n,e,t),a=o(i),c=a.addEventHandler(s,r);return()=>{c(),a.unsubscribe()}}function le({component:n}){var o;let e={},t=(o=n.slots)==null?void 0:o[z];return t==null||t.forEach(r=>{var i;let s=(i=r.parameters)==null?void 0:i[J];(s==null?void 0:s.value)&&typeof s.value=="string"&&(e[s.value]=e[s.value]||[],e[s.value].push(r))}),e}function ze({composition:n,locale:e}){T(n,(t,o,r)=>{if(t.type===F){let s=le({component:t}),i=typeof e=="string"?e:e({component:t,locales:s}),a;if(i&&(a=s[i]),a!=null&&a.length){let[c,...h]=a;r.replaceComponent(c),h.length&&r.insertAfter(h)}else r.removeComponent()}})}var He=n=>n.type==="select-component"&&n.id!==void 0,We=n=>n.type==="ready",Ze=n=>n.type==="update-composition",qe=n=>n.type==="add-component",Ye=n=>n.type==="move-component",Qe=({listenTo:n,broadcastTo:e})=>{let t=0,o={},r=[...e],s=p=>{r.forEach(d=>d.postMessage(JSON.stringify(p),"*"))},i=p=>{s({type:"select-component",id:p})},a=()=>{s({type:"ready"})},c=(p,d)=>{let y=++t;return o[y]={types:Array.isArray(p)?p:[p],handler:d},()=>{delete o[y]}},h=(p,d)=>{let y={type:"update-composition",composition:p,hash:Z({composition:p,secret:d})};s(y)},l=({componentId:p,index:d,slotName:y})=>{s({type:"add-component",componentId:p,slotName:y,index:d})},m=({componentId:p,index:d,slotName:y})=>{s({type:"move-component",componentId:p,slotName:y,index:d})},u=p=>{if(typeof p.data!="string"||p.source===window)return;let d=null;try{let y=JSON.parse(p.data);Object.hasOwn(y,"type")&&(d=y)}catch(y){}if(!!d)for(let y in o){let g=o[y];g.types.includes(d.type)&&g.handler(d,p)}};return n.forEach(p=>p.addEventListener("message",u)),{ready:a,destroy:()=>{n.forEach(p=>p.removeEventListener("message",u))},selectComponent:i,updateComposition:h,on:c,addComponent:l,moveComponent:m}};var O=require("@uniformdev/context/api"),Y=class extends O.ApiClient{constructor(t){t.limitPolicy||(t.limitPolicy=O.nullLimitPolicy);super(t);this.canvasUrl="/api/edge/v1/composition"}async getCompositionBySlug(t){let{projectId:o}=this.options,{dynamicVariables:r,...s}=t,i=this.createUrl(this.canvasUrl,{...s,projectId:o,dynamicVariables:JSON.stringify(r)});return await this.apiClient(i)}async getCompositionById(t){let{projectId:o}=this.options,{dynamicVariables:r,...s}=t,i=this.createUrl(this.canvasUrl,{...s,projectId:o,dynamicVariables:JSON.stringify(r)});return await this.apiClient(i)}};var Q=require("@uniformdev/context/api"),Ke=Q.ApiClientError;0&&(module.exports={ApiClientError,BatchEntry,CANVAS_DRAFT_STATE,CANVAS_ENRICHMENT_TAG_PARAM,CANVAS_INTENT_TAG_PARAM,CANVAS_LOCALE_TAG_PARAM,CANVAS_LOCALIZATION_SLOT,CANVAS_LOCALIZATION_TYPE,CANVAS_PERSONALIZATION_PARAM,CANVAS_PERSONALIZE_SLOT,CANVAS_PERSONALIZE_TYPE,CANVAS_PUBLISHED_STATE,CANVAS_TEST_SLOT,CANVAS_TEST_TYPE,CANVAS_TEST_VARIANT_PARAM,CanvasClient,CanvasClientError,ChildEnhancerBuilder,DataSourceClient,DataTypeClient,EdgeCanvasClient,EnhancerBuilder,IN_CONTEXT_EDITOR_QUERY_STRING_PARAM,UncachedCanvasClient,UniqueBatchEntries,compose,createBatchEnhancer,createCanvasChannel,createEventBus,createLimitPolicy,enhance,extractLocales,generateHash,getChannelName,getComponentPath,isAddComponentMessage,isMovingComponentMessage,isReadyMessage,isSelectComponentMessage,isSystemComponentDefinition,isUpdateCompositionMessage,localize,mapSlotToPersonalizedVariations,mapSlotToTestVariations,nullLimitPolicy,subscribeToComposition,walkComponentTree});
|
4
|
+
`))}}){let r=[],s=new Set,i=new Set;T(n,(c,h)=>{var m;Object.entries((m=c.parameters)!=null?m:{}).forEach(([u,f])=>{let p=e.resolveParameterEnhancer(c,u,f);p&&(i.add(p),r.push(Se(c,h,u,f,p,t)))});let l=e.resolveComponentEnhancers(c);r.push(Re(c,h,l,t)),s.add(l)}),r.push(...Array.from(s).flatMap(c=>Array.from(c).map(async([,h])=>{var l;try{h.completeAll&&await((l=h.limitPolicy)!=null?l:E)(()=>h.completeAll())}catch(m){return{error:m,message:"Batch component enhancer failed. Individual failed components should receive their own rejections."}}}))),r.push(...Array.from(i).map(async c=>{var h;try{c.completeAll&&await((h=c.limitPolicy)!=null?h:E)(()=>c.completeAll())}catch(l){return{error:l,message:"Batch parameter enhancer failed. Individual failed parameters should receive their own rejections."}}}));let a=(await Promise.all(r)).flatMap(c=>Array.isArray(c)?c:[c]).filter(c=>c);a.length&&o(a)}async function Re(n,e,t,o){return t.size&&(n.data={}),await Promise.all(Array.from(t).map(async([r,s])=>{var i;try{let c=await(s.completeAll?E:(i=s.limitPolicy)!=null?i:E)(async()=>s.enhanceOne({component:n,context:o}));c!=null&&(n.data[r]=c)}catch(a){let c=`Component ${w(e)} (type: ${n.type}): data.${r} enhancer threw exception. Data key will not be present.`;return delete n.data[r],{message:c,error:a}}}))}async function Se(n,e,t,o,r,s){var i;try{let c=await(r.completeAll?E:(i=r.limitPolicy)!=null?i:E)(async()=>r.enhanceOne({parameter:o,parameterName:t,component:n,context:s}));c===null?delete n.parameters[t]:typeof c=="undefined"?n.parameters[t]={...o,value:o.value}:n.parameters[t]={...o,value:c}}catch(a){let c=`Component ${w(e)} (type: ${n.type}): enhancing parameter ${t} (type: ${o.type}) threw exception. Parameter will be removed.`;return delete n.parameters[t],{message:c,error:a}}}var be=(n,...e)=>({enhanceOne:o=>{let r="enhanceOne"in n?n.enhanceOne(o):n(o);for(let s of e){let i=Me(r)?r:Promise.resolve(r),a="enhanceOne"in s?s.enhanceOne:s;r=i.then(c=>a({...o,parameter:{type:o.parameter.type,value:c}}))}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 n?(o=n.completeAll)==null?void 0:o.call(n):0)!=null?r:0}});function Me(n){return!!n&&(typeof n=="object"||typeof n=="function")&&typeof n.then=="function"}var ae=require("@uniformdev/context/api"),S=class extends ae.ApiClient{constructor(t){t.limitPolicy||(t.limitPolicy=V({}));super(t);this.canvasUrl="/api/v1/canvas"}async getCompositionList(t){let{projectId:o}=this.options,r=this.createUrl(this.canvasUrl,{...t,projectId:o});return await this.apiClient(r)}async getCompositionByProjectMapNodePath(t){let{projectId:o}=this.options,r=this.createUrl(this.canvasUrl,{...t,projectId:o});return await this.apiClient(r)}async getCompositionByProjectMapNodeId(t){let{projectId:o}=this.options,r=this.createUrl(this.canvasUrl,{...t,projectId:o});return await this.apiClient(r)}async getCompositionBySlug(t){let{projectId:o}=this.options,r=this.createUrl(this.canvasUrl,{...t,projectId:o});return await this.apiClient(r)}async getCompositionById(t){let{projectId:o}=this.options,r=this.createUrl(this.canvasUrl,{...t,projectId:o});return await this.apiClient(r)}async updateComposition(t){let o=this.createUrl("/api/v1/canvas");await this.apiClient(o,{method:"PUT",body:JSON.stringify({...t,projectId:this.options.projectId}),expectNoContent:!0})}async removeComposition(t){let o=this.createUrl("/api/v1/canvas"),{projectId:r}=this.options;await this.apiClient(o,{method:"DELETE",body:JSON.stringify({...t,projectId:r}),expectNoContent:!0})}async getComponentDefinitions(t){let{projectId:o}=this.options,r=this.createUrl("/api/v1/canvas-definitions",{...t,projectId:o});return await this.apiClient(r)}async updateComponentDefinition(t){let o=this.createUrl("/api/v1/canvas-definitions");await this.apiClient(o,{method:"PUT",body:JSON.stringify({...t,projectId:this.options.projectId}),expectNoContent:!0})}async removeComponentDefinition(t){let o=this.createUrl("/api/v1/canvas-definitions");await this.apiClient(o,{method:"DELETE",body:JSON.stringify({...t,projectId:this.options.projectId}),expectNoContent:!0})}},k=class extends S{constructor(e){super({...e,bypassCache:!0})}};var ce=require("@uniformdev/context/api"),B="/api/v1/data-source",Oe="/api/v1/data-sources",$=class extends ce.ApiClient{constructor(e){super(e)}async get(e){let{projectId:t}=this.options,o=this.createUrl(B,{...e,projectId:t});return await this.apiClient(o)}async getList(e){let{projectId:t}=this.options,o=this.createUrl(Oe,{...e,projectId:t});return await this.apiClient(o)}async upsert(e){let t=this.createUrl(B);await this.apiClient(t,{method:"PUT",body:JSON.stringify({...e,projectId:this.options.projectId}),expectNoContent:!0})}async remove(e){let t=this.createUrl(B);await this.apiClient(t,{method:"DELETE",body:JSON.stringify({...e,projectId:this.options.projectId}),expectNoContent:!0})}};var pe=require("@uniformdev/context/api");var x,A=class extends pe.ApiClient{constructor(e){super(e)}async get(e){let{projectId:t}=this.options,o=this.createUrl(_(A,x),{...e,projectId:t});return await this.apiClient(o)}async upsert(e){let t=this.createUrl(_(A,x));await this.apiClient(t,{method:"PUT",body:JSON.stringify({...e,projectId:this.options.projectId}),expectNoContent:!0})}async remove(e){let t=this.createUrl(_(A,x));await this.apiClient(t,{method:"DELETE",body:JSON.stringify({...e,projectId:this.options.projectId}),expectNoContent:!0})}},b=A;x=new WeakMap,X(b,x,"/api/v1/data-types");var Ne="$personalization",De="$test",F="$localization",Ue="intentTag",J="locale",je="pz",Le="test",z="localized",Mt=0,Ot=64,H="$pzCrit",W="$tstVrnt",Ge="$enr",Ve="is_incontext_editing_mode";var ke=n=>n.startsWith("$");function Be(n){return n?n.map((e,t)=>{var s,i;let o=(i=(s=e.parameters)==null?void 0:s[H])==null?void 0:i.value,r=(o==null?void 0:o.name)||`pz-${t}-${e.type}`;return{...e,id:r,pz:o}}):[]}function $e(n){return n?n.map((e,t)=>{var s,i,a;let o=(i=(s=e.parameters)==null?void 0:s[W])==null?void 0:i.value,r=(a=o==null?void 0:o.id)!=null?a:"testId"in e?e.testId:`ab-${t}-${e.type}`;return{...e,id:r}}):[]}var Z=({composition:n,secret:e})=>{if(!e)return;let t=`${JSON.stringify(n)}-${e}`,o=0;for(let r=0;r<t.length;r++){let s=t.charCodeAt(r);o=(o<<5)-o+s,o|=0}return o};var me="https://js.pusher.com/7.0.3/pusher.min.js";async function Fe(){if(!(typeof document=="undefined"||typeof window=="undefined"))return window.Pusher?window.Pusher:new Promise((n,e)=>{let t=setTimeout(()=>{window.Pusher&&n(window.Pusher),e(`Unable to load pusher.js; Uniform Canvas live preview disabled. Consider adding <script src="${me}"><\/script> manually.`)},5e3),o=document.createElement("script");o.src=me,o.addEventListener("load",()=>{clearTimeout(t),n(window.Pusher)}),document.head.appendChild(o)})}async function Je(){let n=await Fe();if(!n)return;let e=window.__UNIFORM_EVENT_BUS__;if(!e){let t=new n("7b5f5abd160fea549ffe",{cluster:"mt1"});t.connect(),console.log("[canvas] \u{1F525} preview connected"),e=window.__UNIFORM_EVENT_BUS__={subscribe:o=>{let r=t.subscribe(o);return{unsubscribe:()=>t.unsubscribe(o),addEventHandler:(s,i)=>(r.bind(s,i),()=>r.unbind(s,i))}}}}return e}function q(n,e,t){return`${n}.${e}@${t}`}function ze({projectId:n,compositionId:e,compositionState:t=0,eventBus:{subscribe:o},callback:r,event:s="updated"}){let i=q(n,e,t),a=o(i),c=a.addEventHandler(s,r);return()=>{c(),a.unsubscribe()}}function le({component:n}){var o;let e={},t=(o=n.slots)==null?void 0:o[z];return t==null||t.forEach(r=>{var i;let s=(i=r.parameters)==null?void 0:i[J];(s==null?void 0:s.value)&&typeof s.value=="string"&&(e[s.value]=e[s.value]||[],e[s.value].push(r))}),e}function He({composition:n,locale:e}){T(n,(t,o,r)=>{if(t.type===F){let s=le({component:t}),i=typeof e=="string"?e:e({component:t,locales:s}),a;if(i&&(a=s[i]),a!=null&&a.length){let[c,...h]=a;r.replaceComponent(c),h.length&&r.insertAfter(h)}else r.removeComponent()}})}var We=n=>n.type==="select-component"&&n.id!==void 0,Ze=n=>n.type==="ready",qe=n=>n.type==="update-composition",Ye=n=>n.type==="add-component",Qe=n=>n.type==="move-component",Ke=({listenTo:n,broadcastTo:e})=>{let t=0,o={},r=[...e],s=p=>{r.forEach(d=>d.postMessage(JSON.stringify(p),"*"))},i=p=>{s({type:"select-component",id:p})},a=()=>{s({type:"ready"})},c=(p,d)=>{let y=++t;return o[y]={types:Array.isArray(p)?p:[p],handler:d},()=>{delete o[y]}},h=(p,d)=>{let y={type:"update-composition",composition:p,hash:Z({composition:p,secret:d})};s(y)},l=({componentId:p,index:d,slotName:y})=>{s({type:"add-component",componentId:p,slotName:y,index:d})},m=({componentId:p,index:d,slotName:y})=>{s({type:"move-component",componentId:p,slotName:y,index:d})},u=p=>{if(typeof p.data!="string"||p.source===window)return;let d=null;try{let y=JSON.parse(p.data);Object.hasOwn(y,"type")&&(d=y)}catch(y){}if(!!d)for(let y in o){let g=o[y];g.types.includes(d.type)&&g.handler(d,p)}};return n.forEach(p=>p.addEventListener("message",u)),{ready:a,destroy:()=>{n.forEach(p=>p.removeEventListener("message",u))},selectComponent:i,updateComposition:h,on:c,addComponent:l,moveComponent:m}};var M=require("@uniformdev/context/api"),Y=class extends M.ApiClient{constructor(t){t.limitPolicy||(t.limitPolicy=M.nullLimitPolicy);super(t);this.canvasUrl="/api/edge/v1/composition"}async getCompositionBySlug(t){let{projectId:o}=this.options,{dynamicVariables:r,...s}=t,i=this.createUrl(this.canvasUrl,{...s,projectId:o,dynamicVariables:JSON.stringify(r)});return await this.apiClient(i)}async getCompositionById(t){let{projectId:o}=this.options,{dynamicVariables:r,...s}=t,i=this.createUrl(this.canvasUrl,{...s,projectId:o,dynamicVariables:JSON.stringify(r)});return await this.apiClient(i)}};var Q=require("@uniformdev/context/api"),Xe=Q.ApiClientError;0&&(module.exports={ApiClientError,BatchEntry,CANVAS_DRAFT_STATE,CANVAS_ENRICHMENT_TAG_PARAM,CANVAS_INTENT_TAG_PARAM,CANVAS_LOCALE_TAG_PARAM,CANVAS_LOCALIZATION_SLOT,CANVAS_LOCALIZATION_TYPE,CANVAS_PERSONALIZATION_PARAM,CANVAS_PERSONALIZE_SLOT,CANVAS_PERSONALIZE_TYPE,CANVAS_PUBLISHED_STATE,CANVAS_TEST_SLOT,CANVAS_TEST_TYPE,CANVAS_TEST_VARIANT_PARAM,CanvasClient,CanvasClientError,ChildEnhancerBuilder,DataSourceClient,DataTypeClient,EdgeCanvasClient,EnhancerBuilder,IN_CONTEXT_EDITOR_QUERY_STRING_PARAM,UncachedCanvasClient,UniqueBatchEntries,compose,createBatchEnhancer,createCanvasChannel,createEventBus,createLimitPolicy,enhance,extractLocales,generateHash,getChannelName,getComponentJsonPointer,getComponentPath,isAddComponentMessage,isMovingComponentMessage,isReadyMessage,isSelectComponentMessage,isSystemComponentDefinition,isUpdateCompositionMessage,localize,mapSlotToPersonalizedVariations,mapSlotToTestVariations,nullLimitPolicy,subscribeToComposition,walkComponentTree});
|
package/dist/index.mjs
CHANGED
@@ -1 +1 @@
|
|
1
|
-
import{$ as Q,A as p,B as q,C as r,D as s,E as t,F as u,G as v,H as w,I as x,J as y,K as z,L as A,M as B,N as C,O as D,P as E,Q as F,R as G,S as H,T as I,U as J,V as K,W as L,X as M,Y as N,Z as O,_ as P,aa as R,ba as S,ca as T,da as U,l as a,m as b,n as c,o as d,p as e,q as f,r as g,s as h,t as i,u as j,v as k,w as l,x as m,y as n,z as o}from"./chunk-
|
1
|
+
import{$ as Q,A as p,B as q,C as r,D as s,E as t,F as u,G as v,H as w,I as x,J as y,K as z,L as A,M as B,N as C,O as D,P as E,Q as F,R as G,S as H,T as I,U as J,V as K,W as L,X as M,Y as N,Z as O,_ as P,aa as R,ba as S,ca as T,da as U,ea as V,l as a,m as b,n as c,o as d,p as e,q as f,r as g,s as h,t as i,u as j,v as k,w as l,x as m,y as n,z as o}from"./chunk-O4RYVPVV.mjs";export{U as ApiClientError,g as BatchEntry,y as CANVAS_DRAFT_STATE,C as CANVAS_ENRICHMENT_TAG_PARAM,t as CANVAS_INTENT_TAG_PARAM,u as CANVAS_LOCALE_TAG_PARAM,x as CANVAS_LOCALIZATION_SLOT,s as CANVAS_LOCALIZATION_TYPE,A as CANVAS_PERSONALIZATION_PARAM,v as CANVAS_PERSONALIZE_SLOT,q as CANVAS_PERSONALIZE_TYPE,z as CANVAS_PUBLISHED_STATE,w as CANVAS_TEST_SLOT,r as CANVAS_TEST_TYPE,B as CANVAS_TEST_VARIANT_PARAM,m as CanvasClient,V as CanvasClientError,e as ChildEnhancerBuilder,o as DataSourceClient,p as DataTypeClient,T as EdgeCanvasClient,f as EnhancerBuilder,D as IN_CONTEXT_EDITOR_QUERY_STRING_PARAM,n as UncachedCanvasClient,d as UniqueBatchEntries,l as compose,h as createBatchEnhancer,S as createCanvasChannel,I as createEventBus,i as createLimitPolicy,k as enhance,L as extractLocales,H as generateHash,J as getChannelName,c as getComponentJsonPointer,b as getComponentPath,Q as isAddComponentMessage,R as isMovingComponentMessage,O as isReadyMessage,N as isSelectComponentMessage,E as isSystemComponentDefinition,P as isUpdateCompositionMessage,M as localize,F as mapSlotToPersonalizedVariations,G as mapSlotToTestVariations,j as nullLimitPolicy,K as subscribeToComposition,a as walkComponentTree};
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@uniformdev/canvas",
|
3
|
-
"version": "17.
|
3
|
+
"version": "17.4.0",
|
4
4
|
"description": "Common functionality and types for Uniform Canvas",
|
5
5
|
"license": "SEE LICENSE IN LICENSE.txt",
|
6
6
|
"main": "./dist/index.js",
|
@@ -49,7 +49,7 @@
|
|
49
49
|
"devDependencies": {
|
50
50
|
"@types/retry": "0.12.1",
|
51
51
|
"@types/yargs": "17.0.13",
|
52
|
-
"@uniformdev/cli": "^17.
|
52
|
+
"@uniformdev/cli": "^17.4.0",
|
53
53
|
"p-limit": "4.0.0",
|
54
54
|
"p-retry": "5.1.1",
|
55
55
|
"p-throttle": "5.0.0",
|
@@ -57,7 +57,7 @@
|
|
57
57
|
"yargs": "17.6.0"
|
58
58
|
},
|
59
59
|
"dependencies": {
|
60
|
-
"@uniformdev/context": "^17.
|
60
|
+
"@uniformdev/context": "^17.4.0"
|
61
61
|
},
|
62
62
|
"files": [
|
63
63
|
"/dist"
|
@@ -65,5 +65,5 @@
|
|
65
65
|
"publishConfig": {
|
66
66
|
"access": "public"
|
67
67
|
},
|
68
|
-
"gitHead": "
|
68
|
+
"gitHead": "77580d40fbad3c838310f09824d29c067686fa64"
|
69
69
|
}
|
package/dist/chunk-IK3FODEI.mjs
DELETED
@@ -1,4 +0,0 @@
|
|
1
|
-
var ae=Object.create;var T=Object.defineProperty;var ce=Object.getOwnPropertyDescriptor;var pe=Object.getOwnPropertyNames;var me=Object.getPrototypeOf,le=Object.prototype.hasOwnProperty;var ue=(t,e,n)=>e in t?T(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n;var Oe=(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 Me=(t,e)=>()=>(t&&(e=t(t=0)),e);var w=(t,e)=>()=>(e||t((e={exports:{}}).exports,e),e.exports),Ne=(t,e)=>{for(var n in e)T(t,n,{get:e[n],enumerable:!0})},j=(t,e,n,o)=>{if(e&&typeof e=="object"||typeof e=="function")for(let r of pe(e))!le.call(t,r)&&r!==n&&T(t,r,{get:()=>e[r],enumerable:!(o=ce(e,r))||o.enumerable});return t};var he=(t,e,n)=>(n=t!=null?ae(me(t)):{},j(e||!t||!t.__esModule?T(n,"default",{value:t,enumerable:!0}):n,t)),De=t=>j(T({},"__esModule",{value:!0}),t);var Ue=(t,e,n)=>(ue(t,typeof e!="symbol"?e+"":e,n),n),G=(t,e,n)=>{if(!e.has(t))throw TypeError("Cannot "+n)};var v=(t,e,n)=>(G(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)},de=(t,e,n,o)=>(G(t,e,"write to private field"),o?o.call(t,n):e.set(t,n),n),Le=(t,e,n,o)=>({set _(r){de(t,e,r,n)},get _(){return v(t,e,o)}});var F=w((Je,$)=>{function C(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=C;C.prototype.reset=function(){this._attempts=1,this._timeouts=this._originalTimeouts.slice(0)};C.prototype.stop=function(){this._timeout&&clearTimeout(this._timeout),this._timer&&clearTimeout(this._timer),this._timeouts=[],this._cachedTimeouts=null};C.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};C.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)};C.prototype.try=function(t){console.log("Using RetryOperation.try() is deprecated"),this.attempt(t)};C.prototype.start=function(t){console.log("Using RetryOperation.start() is deprecated"),this.attempt(t)};C.prototype.start=C.prototype.try;C.prototype.errors=function(){return this._errors};C.prototype.attempts=function(){return this._attempts};C.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 J=w(E=>{var fe=F();E.operation=function(t){var e=E.timeouts(t);return new fe(e,{forever:t&&(t.forever||t.retries===1/0),unref:t&&t.unref,maxRetryTime:t&&t.maxRetryTime})};E.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};E.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};E.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(c){var h=E.operation(e),l=Array.prototype.slice.call(arguments,1),m=l.pop();l.push(function(u){h.retry(u)||(u&&(arguments[0]=h.mainError()),m.apply(this,arguments))}),h.attempt(function(){c.apply(t,l)})}.bind(t,i),t[s].options=e}}});var H=w((He,z)=>{z.exports=J()});function _(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 a=i.ancestorsAndSelf[0],c=!0,h=(s=r.get(a.component))!=null?s:i.context;e(a.component,i.ancestorsAndSelf,{replaceComponent:m=>{Object.assign(a.component,m),["parameters","variant","slots","data","_pattern","_patternError"].forEach(f=>{m[f]||delete a.component[f]})},removeComponent:()=>{let{parentSlot:m,parentSlotIndex:u}=i.ancestorsAndSelf[0],f=i.ancestorsAndSelf[1];if(m&&typeof u!="undefined")f.component.slots[m].splice(u,1);else throw new Error("Unable to delete composition.")},insertAfter:m=>{let u=Array.isArray(m)?m:[m],{parentSlot:f,parentSlotIndex:p}=i.ancestorsAndSelf[0],d=i.ancestorsAndSelf[1];if(f&&typeof p!="undefined")d.component.slots[f].splice(p+1,0,...u),o.unshift(...u.map(y=>({ancestorsAndSelf:[{component:y,parentSlot:f,get parentSlotIndex(){return d.component.slots[f].findIndex(g=>g===y)}},...i.ancestorsAndSelf],context:h})));else throw new Error("Unable to insert after a component not in a slot.")},stopProcessingDescendants(){c=!1},setDescendantsContext(m){h=m},setChildContext(m,u){r.set(m,u)}},h);let l=a.component.slots;if(c&&l){let m=Object.keys(l);for(let u=m.length-1;u>=0;u--){let f=m[u],p=l[f];for(let d=p.length-1;d>=0;d--){let y=p[d];o.push({ancestorsAndSelf:[{component:y,parentSlot:f,get parentSlotIndex(){return a.component.slots[f].findIndex(g=>g===y)}},...i.ancestorsAndSelf],context:h})}}}}while(o.length>0)}function R(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(".")}`}var k=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 I=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}},B=class{constructor(){this._componentIndex={};this._rootBuilder=new I}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 I,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 S=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 Be({handleBatch:t,shouldQueue:e,limitPolicy:n}){let o=[];return{enhanceOne:async i=>{if(!e||e(i))return new Promise((a,c)=>{o.push(new S(a,c,i))})},completeAll:async()=>{if(o.length>0){try{await t(o)}catch(a){o.forEach(c=>c.reject(a))}if(o.some(a=>!a.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 b=class extends Error{constructor(){super("Throttled function aborted"),this.name="AbortError"}};function O({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 a=[];function c(){let l=Date.now();if(a.length<t)return a.push(l),0;let m=a.shift()+e;return l>=m?(a.push(l),0):(a.push(m),m-l)}let h=n?c:i;return l=>{let m=function(...u){if(!m.isEnabled)return(async()=>l.apply(this,u))();let f;return new Promise((p,d)=>{f=setTimeout(()=>{p(l.apply(this,u)),o.delete(f)},h()),o.set(f,d)})};return m.abort=()=>{for(let u of o.keys())clearTimeout(u),o.get(u)(new b);o.clear(),a.splice(0,a.length)},m.isEnabled=!0,m}}var Z=he(H(),1),ye=new Set(["Failed to fetch","NetworkError when attempting to fetch resource.","The Internet connection appears to be offline.","Network request failed"]),M=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),W=t=>globalThis.DOMException===void 0?new Error(t):new DOMException(t);async function N(t,e){return new Promise((n,o)=>{e={onFailedAttempt(){},retries:10,...e};let r=Z.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 M)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(a){o(a);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?W("The operation was aborted."):e.signal.reason;o(s instanceof Error?s:W(s))},{once:!0})})}function q({throttle:t={interval:1e3,limit:10},retry:e={retries:1,factor:1.66}}){let n=t?O(t):null;return function(r){let s=async()=>await r();if(n&&(s=n(s)),e){let i=s;s=()=>N(i,e)}return s()}}var P=async t=>await t();async function nt({composition:t,enhancers:e,context:n,onErrors:o=r=>{throw new Error(r.map(s=>`${s.message}
|
2
|
-
${typeof s.error=="object"&&"stack"in s.error?s.error.stack:s.error}`).join(`
|
3
|
-
|
4
|
-
`))}}){let r=[],s=new Set,i=new Set;_(t,(c,h)=>{var m;Object.entries((m=c.parameters)!=null?m:{}).forEach(([u,f])=>{let p=e.resolveParameterEnhancer(c,u,f);p&&(i.add(p),r.push(Pe(c,h,u,f,p,n)))});let l=e.resolveComponentEnhancers(c);r.push(Ee(c,h,l,n)),s.add(l)}),r.push(...Array.from(s).flatMap(c=>Array.from(c).map(async([,h])=>{var l;try{h.completeAll&&await((l=h.limitPolicy)!=null?l:P)(()=>h.completeAll())}catch(m){return{error:m,message:"Batch component enhancer failed. Individual failed components should receive their own rejections."}}}))),r.push(...Array.from(i).map(async c=>{var h;try{c.completeAll&&await((h=c.limitPolicy)!=null?h:P)(()=>c.completeAll())}catch(l){return{error:l,message:"Batch parameter enhancer failed. Individual failed parameters should receive their own rejections."}}}));let a=(await Promise.all(r)).flatMap(c=>Array.isArray(c)?c:[c]).filter(c=>c);a.length&&o(a)}async function Ee(t,e,n,o){return n.size&&(t.data={}),await Promise.all(Array.from(n).map(async([r,s])=>{var i;try{let c=await(s.completeAll?P:(i=s.limitPolicy)!=null?i:P)(async()=>s.enhanceOne({component:t,context:o}));c!=null&&(t.data[r]=c)}catch(a){let c=`Component ${R(e)} (type: ${t.type}): data.${r} enhancer threw exception. Data key will not be present.`;return delete t.data[r],{message:c,error:a}}}))}async function Pe(t,e,n,o,r,s){var i;try{let c=await(r.completeAll?P:(i=r.limitPolicy)!=null?i:P)(async()=>r.enhanceOne({parameter:o,parameterName:n,component:t,context:s}));c===null?delete t.parameters[n]:typeof c=="undefined"?t.parameters[n]={...o,value:o.value}:t.parameters[n]={...o,value:c}}catch(a){let c=`Component ${R(e)} (type: ${t.type}): enhancing parameter ${n} (type: ${o.type}) threw exception. Parameter will be removed.`;return delete t.parameters[n],{message:c,error:a}}}var rt=(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),a="enhanceOne"in s?s.enhanceOne:s;r=i.then(c=>a({...o,parameter:{type:o.parameter.type,value:c}}))}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"}import{ApiClient as Te}from"@uniformdev/context/api";var D=class extends Te{constructor(n){n.limitPolicy||(n.limitPolicy=q({}));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)}async getCompositionBySitemapNodePath(n){let{projectId:o}=this.options,r=this.createUrl(this.canvasUrl,{...n,projectId:o});return await this.apiClient(r)}async getCompositionBySitemapNodeId(n){let{projectId:o}=this.options,r=this.createUrl(this.canvasUrl,{...n,projectId:o});return await this.apiClient(r)}async getCompositionBySlug(n){let{projectId:o}=this.options,r=this.createUrl(this.canvasUrl,{...n,projectId:o});return await this.apiClient(r)}async getCompositionById(n){let{projectId:o}=this.options,r=this.createUrl(this.canvasUrl,{...n,projectId:o});return await this.apiClient(r)}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 D{constructor(e){super({...e,bypassCache:!0})}};import{ApiClient as ve}from"@uniformdev/context/api";var U="/api/v1/data-source",Ae="/api/v1/data-sources",Q=class extends ve{constructor(e){super(e)}async get(e){let{projectId:n}=this.options,o=this.createUrl(U,{...e,projectId:n});return await this.apiClient(o)}async getList(e){let{projectId:n}=this.options,o=this.createUrl(Ae,{...e,projectId:n});return await this.apiClient(o)}async upsert(e){let n=this.createUrl(U);await this.apiClient(n,{method:"PUT",body:JSON.stringify({...e,projectId:this.options.projectId}),expectNoContent:!0})}async remove(e){let n=this.createUrl(U);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 x,A=class extends _e{constructor(e){super(e)}async get(e){let{projectId:n}=this.options,o=this.createUrl(v(A,x),{...e,projectId:n});return await this.apiClient(o)}async upsert(e){let n=this.createUrl(v(A,x));await this.apiClient(n,{method:"PUT",body:JSON.stringify({...e,projectId:this.options.projectId}),expectNoContent:!0})}async remove(e){let n=this.createUrl(v(A,x));await this.apiClient(n,{method:"DELETE",body:JSON.stringify({...e,projectId:this.options.projectId}),expectNoContent:!0})}},L=A;x=new WeakMap,V(L,x,"/api/v1/data-types");var Et="$personalization",Pt="$test",K="$localization",xt="intentTag",X="locale",Tt="pz",vt="test",ee="localized",At=0,_t=64,te="$pzCrit",ne="$tstVrnt",It="$enr",wt="is_incontext_editing_mode";var St=t=>t.startsWith("$");function Mt(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 Ut(t){return t?t.map((e,n)=>{var s,i,a;let o=(i=(s=e.parameters)==null?void 0:s[ne])==null?void 0:i.value,r=(a=o==null?void 0:o.id)!=null?a:"testId"in e?e.testId:`ab-${n}-${e.type}`;return{...e,id:r}}):[]}var oe=({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 re="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="${re}"><\/script> manually.`)},5e3),o=document.createElement("script");o.src=re,o.addEventListener("load",()=>{clearTimeout(n),t(window.Pusher)}),document.head.appendChild(o)})}async function Gt(){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 se(t,e,n){return`${t}.${e}@${n}`}function $t({projectId:t,compositionId:e,compositionState:n=0,eventBus:{subscribe:o},callback:r,event:s="updated"}){let i=se(t,e,n),a=o(i),c=a.addEventHandler(s,r);return()=>{c(),a.unsubscribe()}}function we({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[X];(s==null?void 0:s.value)&&typeof s.value=="string"&&(e[s.value]=e[s.value]||[],e[s.value].push(r))}),e}function Ht({composition:t,locale:e}){_(t,(n,o,r)=>{if(n.type===K){let s=we({component:n}),i=typeof e=="string"?e:e({component:n,locales:s}),a;if(i&&(a=s[i]),a!=null&&a.length){let[c,...h]=a;r.replaceComponent(c),h.length&&r.insertAfter(h)}else r.removeComponent()}})}var qt=t=>t.type==="select-component"&&t.id!==void 0,Yt=t=>t.type==="ready",Qt=t=>t.type==="update-composition",Kt=t=>t.type==="add-component",Xt=t=>t.type==="move-component",en=({listenTo:t,broadcastTo:e})=>{let n=0,o={},r=[...e],s=p=>{r.forEach(d=>d.postMessage(JSON.stringify(p),"*"))},i=p=>{s({type:"select-component",id:p})},a=()=>{s({type:"ready"})},c=(p,d)=>{let y=++n;return o[y]={types:Array.isArray(p)?p:[p],handler:d},()=>{delete o[y]}},h=(p,d)=>{let y={type:"update-composition",composition:p,hash:oe({composition:p,secret:d})};s(y)},l=({componentId:p,index:d,slotName:y})=>{s({type:"add-component",componentId:p,slotName:y,index:d})},m=({componentId:p,index:d,slotName:y})=>{s({type:"move-component",componentId:p,slotName:y,index:d})},u=p=>{if(typeof p.data!="string"||p.source===window)return;let d=null;try{let y=JSON.parse(p.data);Object.hasOwn(y,"type")&&(d=y)}catch(y){}if(!!d)for(let y in o){let g=o[y];g.types.includes(d.type)&&g.handler(d,p)}};return t.forEach(p=>p.addEventListener("message",u)),{ready:a,destroy:()=>{t.forEach(p=>p.removeEventListener("message",u))},selectComponent:i,updateComposition:h,on:c,addComponent:l,moveComponent:m}};import{ApiClient as Re,nullLimitPolicy as Se}from"@uniformdev/context/api";var ie=class extends Re{constructor(n){n.limitPolicy||(n.limitPolicy=Se);super(n);this.canvasUrl="/api/edge/v1/composition"}async getCompositionBySlug(n){let{projectId:o}=this.options,{dynamicVariables:r,...s}=n,i=this.createUrl(this.canvasUrl,{...s,projectId:o,dynamicVariables:JSON.stringify(r)});return await this.apiClient(i)}async getCompositionById(n){let{projectId:o}=this.options,{dynamicVariables:r,...s}=n,i=this.createUrl(this.canvasUrl,{...s,projectId:o,dynamicVariables:JSON.stringify(r)});return await this.apiClient(i)}};import{ApiClientError as be}from"@uniformdev/context/api";var an=be;export{Oe as a,Me as b,w as c,Ne as d,he as e,De as f,Ue as g,v as h,V as i,de as j,Le as k,_ as l,R as m,k as n,I as o,B as p,S as q,Be as r,q as s,P as t,nt as u,rt as v,D as w,Y as x,Q as y,L as z,Et as A,Pt as B,K as C,xt as D,X as E,Tt as F,vt as G,ee as H,At as I,_t as J,te as K,ne as L,It as M,wt as N,St as O,Mt as P,Ut as Q,oe as R,Gt as S,se as T,$t as U,we as V,Ht as W,qt as X,Yt as Y,Qt as Z,Kt as _,Xt as $,en as aa,ie as ba,be as ca,an as da};
|