@uniformdev/canvas 17.3.1-alpha.146 → 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.
@@ -378,14 +378,18 @@ interface external$4 {
378
378
  connectorType: string;
379
379
  /** @description Base resource URL of the data source. No trailing slash. */
380
380
  baseUrl: string;
381
- /** @description HTTP headers to pass with requests to the data source */
382
381
  headers?: {
383
382
  [key: string]: string;
384
- };
385
- /** @description Query String parameters to pass with requests to the data source */
383
+ } | {
384
+ key: string;
385
+ value: string;
386
+ }[];
386
387
  parameters?: {
387
388
  [key: string]: string;
388
- };
389
+ } | {
390
+ key: string;
391
+ value: string;
392
+ }[];
389
393
  /** @description Variables needed to make calls to the data source */
390
394
  variables?: {
391
395
  [key: string]: external$4["uniform-canvas-types.swagger.yml"]["components"]["schemas"]["DataVariableDefinition"];
@@ -415,14 +419,22 @@ interface external$4 {
415
419
  allowedOnComponents?: string[];
416
420
  /** @description Resource path, appended to the data source's baseUrl (e.g. baseUrl = https://base.url, path = /v1/endpoint -> final URL https://base.url/v1/endpoint). Must have leading slash. */
417
421
  path: string;
418
- /** @description HTTP headers to pass with requests to the data type. Merged with headers from the data source, overriding identical keys. */
422
+ /** @description Time-to-live for the resource data cache. */
423
+ ttl?: number;
424
+ /** @description A key for the resource data cache purging. */
425
+ purgeKey?: string;
419
426
  headers?: {
420
427
  [key: string]: string;
421
- };
422
- /** @description Query String parameters to pass with requests to the data type. Merged with parameters from the data source, overriding identical keys. */
428
+ } | {
429
+ key: string;
430
+ value: string;
431
+ }[];
423
432
  parameters?: {
424
433
  [key: string]: string;
425
- };
434
+ } | {
435
+ key: string;
436
+ value: string;
437
+ }[];
426
438
  /** @description Body to pass with requests to the data type (ignored unless method is POST) */
427
439
  body?: string;
428
440
  /**
@@ -729,14 +741,18 @@ interface components$1 {
729
741
  connectorType: string;
730
742
  /** @description Base resource URL of the data source. No trailing slash. */
731
743
  baseUrl: string;
732
- /** @description HTTP headers to pass with requests to the data source */
733
744
  headers?: {
734
745
  [key: string]: string;
735
- };
736
- /** @description Query String parameters to pass with requests to the data source */
746
+ } | {
747
+ key: string;
748
+ value: string;
749
+ }[];
737
750
  parameters?: {
738
751
  [key: string]: string;
739
- };
752
+ } | {
753
+ key: string;
754
+ value: string;
755
+ }[];
740
756
  /** @description Variables needed to make calls to the data source */
741
757
  variables?: {
742
758
  [key: string]: components$1["schemas"]["DataVariableDefinition"];
@@ -766,14 +782,22 @@ interface components$1 {
766
782
  allowedOnComponents?: string[];
767
783
  /** @description Resource path, appended to the data source's baseUrl (e.g. baseUrl = https://base.url, path = /v1/endpoint -> final URL https://base.url/v1/endpoint). Must have leading slash. */
768
784
  path: string;
769
- /** @description HTTP headers to pass with requests to the data type. Merged with headers from the data source, overriding identical keys. */
785
+ /** @description Time-to-live for the resource data cache. */
786
+ ttl?: number;
787
+ /** @description A key for the resource data cache purging. */
788
+ purgeKey?: string;
770
789
  headers?: {
771
790
  [key: string]: string;
772
- };
773
- /** @description Query String parameters to pass with requests to the data type. Merged with parameters from the data source, overriding identical keys. */
791
+ } | {
792
+ key: string;
793
+ value: string;
794
+ }[];
774
795
  parameters?: {
775
796
  [key: string]: string;
776
- };
797
+ } | {
798
+ key: string;
799
+ value: string;
800
+ }[];
777
801
  /** @description Body to pass with requests to the data type (ignored unless method is POST) */
778
802
  body?: string;
779
803
  /**
@@ -892,12 +916,12 @@ interface paths$3 {
892
916
  compositionIDs?: string[];
893
917
  /** Specify a single composition to fetch by slug. Changes response from list to single. */
894
918
  slug?: string;
895
- /** Specify a single composition to fetch by assodicated Sitemap Node ID. Changes response from list to single. */
896
- sitemapNodeId?: string;
897
- /** Specify a single composition to fetch by assodicated Sitemap Node path. Changes response from list to single. */
898
- sitemapNodePath?: string;
899
- /** Required when using sitemap node id or path for fetch. */
900
- sitemapId?: string;
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;
901
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. */
902
926
  type?: string[];
903
927
  /** State of compositions to fetch. 0 = draft, 64 = published. */
@@ -1371,14 +1395,18 @@ interface external$3 {
1371
1395
  connectorType: string;
1372
1396
  /** @description Base resource URL of the data source. No trailing slash. */
1373
1397
  baseUrl: string;
1374
- /** @description HTTP headers to pass with requests to the data source */
1375
1398
  headers?: {
1376
1399
  [key: string]: string;
1377
- };
1378
- /** @description Query String parameters to pass with requests to the data source */
1400
+ } | {
1401
+ key: string;
1402
+ value: string;
1403
+ }[];
1379
1404
  parameters?: {
1380
1405
  [key: string]: string;
1381
- };
1406
+ } | {
1407
+ key: string;
1408
+ value: string;
1409
+ }[];
1382
1410
  /** @description Variables needed to make calls to the data source */
1383
1411
  variables?: {
1384
1412
  [key: string]: external$3["uniform-canvas-types.swagger.yml"]["components"]["schemas"]["DataVariableDefinition"];
@@ -1408,14 +1436,22 @@ interface external$3 {
1408
1436
  allowedOnComponents?: string[];
1409
1437
  /** @description Resource path, appended to the data source's baseUrl (e.g. baseUrl = https://base.url, path = /v1/endpoint -> final URL https://base.url/v1/endpoint). Must have leading slash. */
1410
1438
  path: string;
1411
- /** @description HTTP headers to pass with requests to the data type. Merged with headers from the data source, overriding identical keys. */
1439
+ /** @description Time-to-live for the resource data cache. */
1440
+ ttl?: number;
1441
+ /** @description A key for the resource data cache purging. */
1442
+ purgeKey?: string;
1412
1443
  headers?: {
1413
1444
  [key: string]: string;
1414
- };
1415
- /** @description Query String parameters to pass with requests to the data type. Merged with parameters from the data source, overriding identical keys. */
1445
+ } | {
1446
+ key: string;
1447
+ value: string;
1448
+ }[];
1416
1449
  parameters?: {
1417
1450
  [key: string]: string;
1418
- };
1451
+ } | {
1452
+ key: string;
1453
+ value: string;
1454
+ }[];
1419
1455
  /** @description Body to pass with requests to the data type (ignored unless method is POST) */
1420
1456
  body?: string;
1421
1457
  /**
@@ -1893,14 +1929,18 @@ interface external$2 {
1893
1929
  connectorType: string;
1894
1930
  /** @description Base resource URL of the data source. No trailing slash. */
1895
1931
  baseUrl: string;
1896
- /** @description HTTP headers to pass with requests to the data source */
1897
1932
  headers?: {
1898
1933
  [key: string]: string;
1899
- };
1900
- /** @description Query String parameters to pass with requests to the data source */
1934
+ } | {
1935
+ key: string;
1936
+ value: string;
1937
+ }[];
1901
1938
  parameters?: {
1902
1939
  [key: string]: string;
1903
- };
1940
+ } | {
1941
+ key: string;
1942
+ value: string;
1943
+ }[];
1904
1944
  /** @description Variables needed to make calls to the data source */
1905
1945
  variables?: {
1906
1946
  [key: string]: external$2["uniform-canvas-types.swagger.yml"]["components"]["schemas"]["DataVariableDefinition"];
@@ -1930,14 +1970,22 @@ interface external$2 {
1930
1970
  allowedOnComponents?: string[];
1931
1971
  /** @description Resource path, appended to the data source's baseUrl (e.g. baseUrl = https://base.url, path = /v1/endpoint -> final URL https://base.url/v1/endpoint). Must have leading slash. */
1932
1972
  path: string;
1933
- /** @description HTTP headers to pass with requests to the data type. Merged with headers from the data source, overriding identical keys. */
1973
+ /** @description Time-to-live for the resource data cache. */
1974
+ ttl?: number;
1975
+ /** @description A key for the resource data cache purging. */
1976
+ purgeKey?: string;
1934
1977
  headers?: {
1935
1978
  [key: string]: string;
1936
- };
1937
- /** @description Query String parameters to pass with requests to the data type. Merged with parameters from the data source, overriding identical keys. */
1979
+ } | {
1980
+ key: string;
1981
+ value: string;
1982
+ }[];
1938
1983
  parameters?: {
1939
1984
  [key: string]: string;
1940
- };
1985
+ } | {
1986
+ key: string;
1987
+ value: string;
1988
+ }[];
1941
1989
  /** @description Body to pass with requests to the data type (ignored unless method is POST) */
1942
1990
  body?: string;
1943
1991
  /**
@@ -2362,14 +2410,18 @@ interface external$1 {
2362
2410
  connectorType: string;
2363
2411
  /** @description Base resource URL of the data source. No trailing slash. */
2364
2412
  baseUrl: string;
2365
- /** @description HTTP headers to pass with requests to the data source */
2366
2413
  headers?: {
2367
2414
  [key: string]: string;
2368
- };
2369
- /** @description Query String parameters to pass with requests to the data source */
2415
+ } | {
2416
+ key: string;
2417
+ value: string;
2418
+ }[];
2370
2419
  parameters?: {
2371
2420
  [key: string]: string;
2372
- };
2421
+ } | {
2422
+ key: string;
2423
+ value: string;
2424
+ }[];
2373
2425
  /** @description Variables needed to make calls to the data source */
2374
2426
  variables?: {
2375
2427
  [key: string]: external$1["uniform-canvas-types.swagger.yml"]["components"]["schemas"]["DataVariableDefinition"];
@@ -2399,14 +2451,22 @@ interface external$1 {
2399
2451
  allowedOnComponents?: string[];
2400
2452
  /** @description Resource path, appended to the data source's baseUrl (e.g. baseUrl = https://base.url, path = /v1/endpoint -> final URL https://base.url/v1/endpoint). Must have leading slash. */
2401
2453
  path: string;
2402
- /** @description HTTP headers to pass with requests to the data type. Merged with headers from the data source, overriding identical keys. */
2454
+ /** @description Time-to-live for the resource data cache. */
2455
+ ttl?: number;
2456
+ /** @description A key for the resource data cache purging. */
2457
+ purgeKey?: string;
2403
2458
  headers?: {
2404
2459
  [key: string]: string;
2405
- };
2406
- /** @description Query String parameters to pass with requests to the data type. Merged with parameters from the data source, overriding identical keys. */
2460
+ } | {
2461
+ key: string;
2462
+ value: string;
2463
+ }[];
2407
2464
  parameters?: {
2408
2465
  [key: string]: string;
2409
- };
2466
+ } | {
2467
+ key: string;
2468
+ value: string;
2469
+ }[];
2410
2470
  /** @description Body to pass with requests to the data type (ignored unless method is POST) */
2411
2471
  body?: string;
2412
2472
  /**
@@ -2788,14 +2848,18 @@ interface external {
2788
2848
  connectorType: string;
2789
2849
  /** @description Base resource URL of the data source. No trailing slash. */
2790
2850
  baseUrl: string;
2791
- /** @description HTTP headers to pass with requests to the data source */
2792
2851
  headers?: {
2793
2852
  [key: string]: string;
2794
- };
2795
- /** @description Query String parameters to pass with requests to the data source */
2853
+ } | {
2854
+ key: string;
2855
+ value: string;
2856
+ }[];
2796
2857
  parameters?: {
2797
2858
  [key: string]: string;
2798
- };
2859
+ } | {
2860
+ key: string;
2861
+ value: string;
2862
+ }[];
2799
2863
  /** @description Variables needed to make calls to the data source */
2800
2864
  variables?: {
2801
2865
  [key: string]: external["uniform-canvas-types.swagger.yml"]["components"]["schemas"]["DataVariableDefinition"];
@@ -2825,14 +2889,22 @@ interface external {
2825
2889
  allowedOnComponents?: string[];
2826
2890
  /** @description Resource path, appended to the data source's baseUrl (e.g. baseUrl = https://base.url, path = /v1/endpoint -> final URL https://base.url/v1/endpoint). Must have leading slash. */
2827
2891
  path: string;
2828
- /** @description HTTP headers to pass with requests to the data type. Merged with headers from the data source, overriding identical keys. */
2892
+ /** @description Time-to-live for the resource data cache. */
2893
+ ttl?: number;
2894
+ /** @description A key for the resource data cache purging. */
2895
+ purgeKey?: string;
2829
2896
  headers?: {
2830
2897
  [key: string]: string;
2831
- };
2832
- /** @description Query String parameters to pass with requests to the data type. Merged with parameters from the data source, overriding identical keys. */
2898
+ } | {
2899
+ key: string;
2900
+ value: string;
2901
+ }[];
2833
2902
  parameters?: {
2834
2903
  [key: string]: string;
2835
- };
2904
+ } | {
2905
+ key: string;
2906
+ value: string;
2907
+ }[];
2836
2908
  /** @description Body to pass with requests to the data type (ignored unless method is POST) */
2837
2909
  body?: string;
2838
2910
  /**
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-4b8ecb61.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-4b8ecb61.js';
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
- getCompositionBySitemapNodePath(options: Pick<CompositionGetParameters, 'sitemapNodePath' | 'sitemapId' | 'state' | 'skipEnhance' | 'skipPatternResolution' | 'withComponentIDs' | 'withUIStatus' | 'withTotalCount'>): Promise<{
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
- getCompositionBySitemapNodeId(options: Pick<CompositionGetParameters, 'sitemapNodeId' | 'sitemapId' | 'state' | 'skipEnhance' | 'skipPatternResolution' | 'withComponentIDs' | 'withUIStatus' | 'withTotalCount'>): Promise<{
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;
@@ -760,10 +764,16 @@ declare class DataSourceClient extends ApiClient {
760
764
  baseUrl: string;
761
765
  headers?: {
762
766
  [key: string]: string;
763
- } | undefined;
767
+ } | {
768
+ key: string;
769
+ value: string;
770
+ }[] | undefined;
764
771
  parameters?: {
765
772
  [key: string]: string;
766
- } | undefined;
773
+ } | {
774
+ key: string;
775
+ value: string;
776
+ }[] | undefined;
767
777
  variables?: {
768
778
  [key: string]: {
769
779
  displayName?: string | undefined;
@@ -1014,4 +1024,4 @@ declare class EdgeCanvasClient extends ApiClient<ClientOptions> {
1014
1024
 
1015
1025
  declare const CanvasClientError: typeof ApiClientError;
1016
1026
 
1017
- 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-IK3FODEI.mjs";export{T as ApiClientError,f as BatchEntry,x as CANVAS_DRAFT_STATE,B as CANVAS_ENRICHMENT_TAG_PARAM,s as CANVAS_INTENT_TAG_PARAM,t as CANVAS_LOCALE_TAG_PARAM,w as CANVAS_LOCALIZATION_SLOT,r as CANVAS_LOCALIZATION_TYPE,z as CANVAS_PERSONALIZATION_PARAM,u as CANVAS_PERSONALIZE_SLOT,p as CANVAS_PERSONALIZE_TYPE,y as CANVAS_PUBLISHED_STATE,v as CANVAS_TEST_SLOT,q as CANVAS_TEST_TYPE,A as CANVAS_TEST_VARIANT_PARAM,l as CanvasClient,U as CanvasClientError,d as ChildEnhancerBuilder,n as DataSourceClient,o as DataTypeClient,S as EdgeCanvasClient,e as EnhancerBuilder,C as IN_CONTEXT_EDITOR_QUERY_STRING_PARAM,m as UncachedCanvasClient,c as UniqueBatchEntries,k as compose,g as createBatchEnhancer,R as createCanvasChannel,H as createEventBus,h as createLimitPolicy,j as enhance,K as extractLocales,G as generateHash,I as getChannelName,b as getComponentPath,P as isAddComponentMessage,Q as isMovingComponentMessage,N as isReadyMessage,M as isSelectComponentMessage,D as isSystemComponentDefinition,O as isUpdateCompositionMessage,L as localize,E as mapSlotToPersonalizedVariations,F as mapSlotToTestVariations,i as nullLimitPolicy,J as subscribeToComposition,a as walkComponentTree};
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-IK3FODEI.mjs";export{T as ApiClientError,f as BatchEntry,x as CANVAS_DRAFT_STATE,B as CANVAS_ENRICHMENT_TAG_PARAM,s as CANVAS_INTENT_TAG_PARAM,t as CANVAS_LOCALE_TAG_PARAM,w as CANVAS_LOCALIZATION_SLOT,r as CANVAS_LOCALIZATION_TYPE,z as CANVAS_PERSONALIZATION_PARAM,u as CANVAS_PERSONALIZE_SLOT,p as CANVAS_PERSONALIZE_TYPE,y as CANVAS_PUBLISHED_STATE,v as CANVAS_TEST_SLOT,q as CANVAS_TEST_TYPE,A as CANVAS_TEST_VARIANT_PARAM,l as CanvasClient,U as CanvasClientError,d as ChildEnhancerBuilder,n as DataSourceClient,o as DataTypeClient,S as EdgeCanvasClient,e as EnhancerBuilder,C as IN_CONTEXT_EDITOR_QUERY_STRING_PARAM,m as UncachedCanvasClient,c as UniqueBatchEntries,k as compose,g as createBatchEnhancer,R as createCanvasChannel,H as createEventBus,h as createLimitPolicy,j as enhance,K as extractLocales,G as generateHash,I as getChannelName,b as getComponentPath,P as isAddComponentMessage,Q as isMovingComponentMessage,N as isReadyMessage,M as isSelectComponentMessage,D as isSystemComponentDefinition,O as isUpdateCompositionMessage,L as localize,E as mapSlotToPersonalizedVariations,F as mapSlotToTestVariations,i as nullLimitPolicy,J as subscribeToComposition,a as walkComponentTree};
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.1-alpha.146+33ba1d5c7",
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.3.1-alpha.146+33ba1d5c7",
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.3.1-alpha.146+33ba1d5c7"
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": "33ba1d5c7cf8aca1d9d5c7c14e0d97c0805f6840"
68
+ "gitHead": "77580d40fbad3c838310f09824d29c067686fa64"
69
69
  }