@uniformdev/canvas 17.1.1-alpha.498 → 17.1.1-alpha.752

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/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 DataConnectionGetParameters, h as DataConnectionsGetParameters, i as DataConnectionPutParameters, j as DataConnectionDeleteParameters, k as DataTypeGetParameters, l as DataTypeGetResponse, m as DataTypePutParameters, n as DataTypeDeleteParameters, R as RootComponentInstance, P as PreviewEventBus, o as CompositionGetResponse } from './createEventBus-6f48d55f.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, K as ComponentParameterBinding, H as CompositionAPIDeleteRequest, J as CompositionAPIOptions, G as CompositionAPIResponse, N as CompositionDataDefinition, M as CompositionDataDefinitions, L as CompositionDataVariables, 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, U as DataConnection, j as DataConnectionDeleteParameters, D as DataConnectionGetParameters, Q as DataConnectionGetResponse, V as DataConnectionInfo, i as DataConnectionPutParameters, h as DataConnectionsGetParameters, S as DataConnectionsGetResponse, T as DataType, n as DataTypeDeleteParameters, k as DataTypeGetParameters, l as DataTypeGetResponse, m as DataTypePutParameters, W as DataVariable, P as PreviewEventBus, R as RootComponentInstance, Y as createEventBus } from './createEventBus-6f48d55f.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';
@@ -280,7 +280,7 @@ declare class CanvasClient extends ApiClient<ClientOptions> {
280
280
  [key: string]: {
281
281
  value: unknown;
282
282
  type: string;
283
- binding?: {
283
+ connectedData?: {
284
284
  pointer: string;
285
285
  syntax: "jptr";
286
286
  required?: boolean | undefined;
@@ -295,7 +295,7 @@ declare class CanvasClient extends ApiClient<ClientOptions> {
295
295
  [key: string]: {
296
296
  value: unknown;
297
297
  type: string;
298
- binding?: {
298
+ connectedData?: {
299
299
  pointer: string;
300
300
  syntax: "jptr";
301
301
  required?: boolean | undefined;
@@ -308,7 +308,7 @@ declare class CanvasClient extends ApiClient<ClientOptions> {
308
308
  } | undefined;
309
309
  _id?: string | undefined;
310
310
  _pattern?: string | undefined;
311
- _data?: {
311
+ _dataResources?: {
312
312
  [key: string]: {
313
313
  type: string;
314
314
  isPatternParameter?: boolean | undefined;
@@ -317,7 +317,7 @@ declare class CanvasClient extends ApiClient<ClientOptions> {
317
317
  } | undefined;
318
318
  };
319
319
  } | undefined;
320
- _patternData?: {
320
+ _patternDataResources?: {
321
321
  [key: string]: {
322
322
  type: string;
323
323
  isPatternParameter?: boolean | undefined;
@@ -332,7 +332,7 @@ declare class CanvasClient extends ApiClient<ClientOptions> {
332
332
  _id: string;
333
333
  _slug?: string | null | undefined;
334
334
  _name: string;
335
- _data?: {
335
+ _dataResources?: {
336
336
  [key: string]: {
337
337
  type: string;
338
338
  isPatternParameter?: boolean | undefined;
@@ -345,6 +345,158 @@ declare class CanvasClient extends ApiClient<ClientOptions> {
345
345
  }[];
346
346
  totalCount?: number | undefined;
347
347
  }>;
348
+ getCompositionByProjectMapNodePath(options: Pick<CompositionGetParameters, 'projectMapNodePath' | 'projectMapId' | 'state' | 'skipEnhance' | 'skipPatternResolution' | 'withComponentIDs' | 'withUIStatus' | 'withTotalCount'>): Promise<{
349
+ state: number;
350
+ uiStatus?: "Draft" | "Modified" | "Published" | "Orphan" | undefined;
351
+ projectId: string;
352
+ created: string;
353
+ modified: string;
354
+ pattern: boolean;
355
+ composition: {
356
+ type: string;
357
+ parameters?: {
358
+ [key: string]: {
359
+ value: unknown;
360
+ type: string;
361
+ connectedData?: {
362
+ pointer: string;
363
+ syntax: "jptr";
364
+ required?: boolean | undefined;
365
+ } | undefined;
366
+ };
367
+ } | undefined;
368
+ variant?: string | undefined;
369
+ slots?: {
370
+ [key: string]: {
371
+ type: string;
372
+ parameters?: {
373
+ [key: string]: {
374
+ value: unknown;
375
+ type: string;
376
+ connectedData?: {
377
+ pointer: string;
378
+ syntax: "jptr";
379
+ required?: boolean | undefined;
380
+ } | undefined;
381
+ };
382
+ } | undefined;
383
+ variant?: string | undefined;
384
+ slots?: {
385
+ [key: string]: any[];
386
+ } | undefined;
387
+ _id?: string | undefined;
388
+ _pattern?: string | undefined;
389
+ _dataResources?: {
390
+ [key: string]: {
391
+ type: string;
392
+ isPatternParameter?: boolean | undefined;
393
+ variables?: {
394
+ [key: string]: string;
395
+ } | undefined;
396
+ };
397
+ } | undefined;
398
+ _patternDataResources?: {
399
+ [key: string]: {
400
+ type: string;
401
+ isPatternParameter?: boolean | undefined;
402
+ variables?: {
403
+ [key: string]: string;
404
+ } | undefined;
405
+ };
406
+ } | undefined;
407
+ _patternError?: "NOTFOUND" | "CYCLIC" | undefined;
408
+ }[];
409
+ } | undefined;
410
+ _id: string;
411
+ _slug?: string | null | undefined;
412
+ _name: string;
413
+ _dataResources?: {
414
+ [key: string]: {
415
+ type: string;
416
+ isPatternParameter?: boolean | undefined;
417
+ variables?: {
418
+ [key: string]: string;
419
+ } | undefined;
420
+ };
421
+ } | undefined;
422
+ };
423
+ }>;
424
+ getCompositionByProjectMapNodeId(options: Pick<CompositionGetParameters, 'projectMapNodeId' | 'projectMapId' | 'state' | 'skipEnhance' | 'skipPatternResolution' | 'withComponentIDs' | 'withUIStatus' | 'withTotalCount'>): Promise<{
425
+ state: number;
426
+ uiStatus?: "Draft" | "Modified" | "Published" | "Orphan" | undefined;
427
+ projectId: string;
428
+ created: string;
429
+ modified: string;
430
+ pattern: boolean;
431
+ composition: {
432
+ type: string;
433
+ parameters?: {
434
+ [key: string]: {
435
+ value: unknown;
436
+ type: string;
437
+ connectedData?: {
438
+ pointer: string;
439
+ syntax: "jptr";
440
+ required?: boolean | undefined;
441
+ } | undefined;
442
+ };
443
+ } | undefined;
444
+ variant?: string | undefined;
445
+ slots?: {
446
+ [key: string]: {
447
+ type: string;
448
+ parameters?: {
449
+ [key: string]: {
450
+ value: unknown;
451
+ type: string;
452
+ connectedData?: {
453
+ pointer: string;
454
+ syntax: "jptr";
455
+ required?: boolean | undefined;
456
+ } | undefined;
457
+ };
458
+ } | undefined;
459
+ variant?: string | undefined;
460
+ slots?: {
461
+ [key: string]: any[];
462
+ } | undefined;
463
+ _id?: string | undefined;
464
+ _pattern?: string | undefined;
465
+ _dataResources?: {
466
+ [key: string]: {
467
+ type: string;
468
+ isPatternParameter?: boolean | undefined;
469
+ variables?: {
470
+ [key: string]: string;
471
+ } | undefined;
472
+ };
473
+ } | undefined;
474
+ _patternDataResources?: {
475
+ [key: string]: {
476
+ type: string;
477
+ isPatternParameter?: boolean | undefined;
478
+ variables?: {
479
+ [key: string]: string;
480
+ } | undefined;
481
+ };
482
+ } | undefined;
483
+ _patternError?: "NOTFOUND" | "CYCLIC" | undefined;
484
+ }[];
485
+ } | undefined;
486
+ _id: string;
487
+ _slug?: string | null | undefined;
488
+ _name: string;
489
+ _dataResources?: {
490
+ [key: string]: {
491
+ type: string;
492
+ isPatternParameter?: boolean | undefined;
493
+ variables?: {
494
+ [key: string]: string;
495
+ } | undefined;
496
+ };
497
+ } | undefined;
498
+ };
499
+ }>;
348
500
  /** Fetches a Canvas composition by string name (slug) */
349
501
  getCompositionBySlug(options: Pick<CompositionGetParameters, 'slug' | 'state' | 'skipEnhance' | 'skipPatternResolution' | 'withComponentIDs' | 'withUIStatus' | 'withTotalCount'>): Promise<{
350
502
  state: number;
@@ -359,7 +511,7 @@ declare class CanvasClient extends ApiClient<ClientOptions> {
359
511
  [key: string]: {
360
512
  value: unknown;
361
513
  type: string;
362
- binding?: {
514
+ connectedData?: {
363
515
  pointer: string;
364
516
  syntax: "jptr";
365
517
  required?: boolean | undefined;
@@ -374,7 +526,7 @@ declare class CanvasClient extends ApiClient<ClientOptions> {
374
526
  [key: string]: {
375
527
  value: unknown;
376
528
  type: string;
377
- binding?: {
529
+ connectedData?: {
378
530
  pointer: string;
379
531
  syntax: "jptr";
380
532
  required?: boolean | undefined;
@@ -387,7 +539,7 @@ declare class CanvasClient extends ApiClient<ClientOptions> {
387
539
  } | undefined;
388
540
  _id?: string | undefined;
389
541
  _pattern?: string | undefined;
390
- _data?: {
542
+ _dataResources?: {
391
543
  [key: string]: {
392
544
  type: string;
393
545
  isPatternParameter?: boolean | undefined;
@@ -396,7 +548,7 @@ declare class CanvasClient extends ApiClient<ClientOptions> {
396
548
  } | undefined;
397
549
  };
398
550
  } | undefined;
399
- _patternData?: {
551
+ _patternDataResources?: {
400
552
  [key: string]: {
401
553
  type: string;
402
554
  isPatternParameter?: boolean | undefined;
@@ -411,7 +563,7 @@ declare class CanvasClient extends ApiClient<ClientOptions> {
411
563
  _id: string;
412
564
  _slug?: string | null | undefined;
413
565
  _name: string;
414
- _data?: {
566
+ _dataResources?: {
415
567
  [key: string]: {
416
568
  type: string;
417
569
  isPatternParameter?: boolean | undefined;
@@ -436,7 +588,7 @@ declare class CanvasClient extends ApiClient<ClientOptions> {
436
588
  [key: string]: {
437
589
  value: unknown;
438
590
  type: string;
439
- binding?: {
591
+ connectedData?: {
440
592
  pointer: string;
441
593
  syntax: "jptr";
442
594
  required?: boolean | undefined;
@@ -451,7 +603,7 @@ declare class CanvasClient extends ApiClient<ClientOptions> {
451
603
  [key: string]: {
452
604
  value: unknown;
453
605
  type: string;
454
- binding?: {
606
+ connectedData?: {
455
607
  pointer: string;
456
608
  syntax: "jptr";
457
609
  required?: boolean | undefined;
@@ -464,7 +616,7 @@ declare class CanvasClient extends ApiClient<ClientOptions> {
464
616
  } | undefined;
465
617
  _id?: string | undefined;
466
618
  _pattern?: string | undefined;
467
- _data?: {
619
+ _dataResources?: {
468
620
  [key: string]: {
469
621
  type: string;
470
622
  isPatternParameter?: boolean | undefined;
@@ -473,7 +625,7 @@ declare class CanvasClient extends ApiClient<ClientOptions> {
473
625
  } | undefined;
474
626
  };
475
627
  } | undefined;
476
- _patternData?: {
628
+ _patternDataResources?: {
477
629
  [key: string]: {
478
630
  type: string;
479
631
  isPatternParameter?: boolean | undefined;
@@ -488,7 +640,7 @@ declare class CanvasClient extends ApiClient<ClientOptions> {
488
640
  _id: string;
489
641
  _slug?: string | null | undefined;
490
642
  _name: string;
491
- _data?: {
643
+ _dataResources?: {
492
644
  [key: string]: {
493
645
  type: string;
494
646
  isPatternParameter?: boolean | undefined;
@@ -534,7 +686,7 @@ declare class CanvasClient extends ApiClient<ClientOptions> {
534
686
  }[] | undefined;
535
687
  slugSettings?: {
536
688
  required?: "no" | "yes" | "disabled" | undefined;
537
- unique?: "no" | "local" | "global" | undefined;
689
+ unique?: "global" | "no" | "local" | undefined;
538
690
  regularExpression?: string | undefined;
539
691
  regularExpressionMessage?: string | undefined;
540
692
  } | undefined;
@@ -544,7 +696,7 @@ declare class CanvasClient extends ApiClient<ClientOptions> {
544
696
  [key: string]: {
545
697
  value: unknown;
546
698
  type: string;
547
- binding?: {
699
+ connectedData?: {
548
700
  pointer: string;
549
701
  syntax: "jptr";
550
702
  required?: boolean | undefined;
@@ -557,7 +709,7 @@ declare class CanvasClient extends ApiClient<ClientOptions> {
557
709
  } | undefined;
558
710
  _id?: string | undefined;
559
711
  _pattern?: string | undefined;
560
- _data?: {
712
+ _dataResources?: {
561
713
  [key: string]: {
562
714
  type: string;
563
715
  isPatternParameter?: boolean | undefined;
@@ -566,7 +718,7 @@ declare class CanvasClient extends ApiClient<ClientOptions> {
566
718
  } | undefined;
567
719
  };
568
720
  } | undefined;
569
- _patternData?: {
721
+ _patternDataResources?: {
570
722
  [key: string]: {
571
723
  type: string;
572
724
  isPatternParameter?: boolean | undefined;
@@ -597,10 +749,10 @@ declare class UncachedCanvasClient extends CanvasClient {
597
749
  /**
598
750
  * @deprecated
599
751
  */
600
- declare class DataConnectionClient extends ApiClient {
752
+ declare class DataSourceClient extends ApiClient {
601
753
  constructor(options: ClientOptions);
602
- /** Fetches all DataConnections for a project */
603
- get(options?: ExceptProject<DataConnectionGetParameters>): Promise<{
754
+ /** Fetches all DataSources for a project */
755
+ get(options?: ExceptProject<DataSourceGetParameters>): Promise<{
604
756
  result: {
605
757
  id: string;
606
758
  displayName: string;
@@ -608,10 +760,16 @@ declare class DataConnectionClient extends ApiClient {
608
760
  baseUrl: string;
609
761
  headers?: {
610
762
  [key: string]: string;
611
- } | undefined;
763
+ } | {
764
+ key: string;
765
+ value: string;
766
+ }[] | undefined;
612
767
  parameters?: {
613
768
  [key: string]: string;
614
- } | undefined;
769
+ } | {
770
+ key: string;
771
+ value: string;
772
+ }[] | undefined;
615
773
  variables?: {
616
774
  [key: string]: {
617
775
  displayName?: string | undefined;
@@ -625,8 +783,8 @@ declare class DataConnectionClient extends ApiClient {
625
783
  } | undefined;
626
784
  };
627
785
  }>;
628
- /** Fetches all DataConnections for a project */
629
- getList(options?: ExceptProject<DataConnectionsGetParameters>): Promise<{
786
+ /** Fetches all DataSources for a project */
787
+ getList(options?: ExceptProject<DataSourcesGetParameters>): Promise<{
630
788
  results: {
631
789
  id: string;
632
790
  displayName: string;
@@ -634,10 +792,10 @@ declare class DataConnectionClient extends ApiClient {
634
792
  baseUrl: string;
635
793
  }[];
636
794
  }>;
637
- /** Updates or creates (based on id) a DataConnection */
638
- upsert(body: ExceptProject<DataConnectionPutParameters>): Promise<void>;
639
- /** Deletes a DataConnection */
640
- remove(body: ExceptProject<DataConnectionDeleteParameters>): Promise<void>;
795
+ /** Updates or creates (based on id) a DataSource */
796
+ upsert(body: ExceptProject<DataSourcePutParameters>): Promise<void>;
797
+ /** Deletes a DataSource */
798
+ remove(body: ExceptProject<DataSourceDeleteParameters>): Promise<void>;
641
799
  }
642
800
 
643
801
  /**
@@ -784,7 +942,7 @@ declare const createCanvasChannel: ({ listenTo, broadcastTo, }: {
784
942
  }) => Channel;
785
943
 
786
944
  /** Types of issue that can occur when fetching composition data */
787
- declare type CompositionIssue = CompositionPatternIssue | CompositionDataIssue | CompositionBindingIssue | CompositionVariableIssue;
945
+ declare type CompositionIssue = CompositionPatternIssue | DataResourceIssue | DataElementBindingIssue | DataResourceVariableIssue;
788
946
  declare type CompositionIssueCore = {
789
947
  componentPath: string;
790
948
  componentType: string;
@@ -795,19 +953,19 @@ declare type CompositionPatternIssue = CompositionIssueCore & {
795
953
  type: 'pattern';
796
954
  code: NonNullable<ComponentInstance['_patternError']>;
797
955
  };
798
- /** An error while binding a piece of data to a component parameter */
799
- declare type CompositionBindingIssue = CompositionIssueCore & {
956
+ /** An error while binding a data element from a data resource to a component parameter (i.e. a missing property in the data resource) */
957
+ declare type DataElementBindingIssue = CompositionIssueCore & {
800
958
  type: 'binding';
801
959
  parameterName: string;
802
960
  };
803
961
  /** An error that occurred fetching a data defined on the composition or a pattern within */
804
- declare type CompositionDataIssue = CompositionIssueCore & {
962
+ declare type DataResourceIssue = CompositionIssueCore & {
805
963
  type: 'data';
806
964
  dataName: string;
807
965
  dataType: string;
808
966
  };
809
- /** An issue that occurred while binding dynamic variables to composition data types */
810
- declare type CompositionVariableIssue = CompositionIssueCore & {
967
+ /** An issue that occurred while binding dynamic variables to composition data resources */
968
+ declare type DataResourceVariableIssue = CompositionIssueCore & {
811
969
  type: 'variable';
812
970
  variableName: string;
813
971
  };
@@ -862,4 +1020,4 @@ declare class EdgeCanvasClient extends ApiClient<ClientOptions> {
862
1020
 
863
1021
  declare const CanvasClientError: typeof ApiClientError;
864
1022
 
865
- 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, CompositionBindingIssue, CompositionDataDiagnostic, CompositionDataIssue, CompositionIssue, CompositionPatternIssue, CompositionVariableIssue, DataConnectionClient, 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 };
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 };
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-OT3KUGLJ.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 DataConnectionClient,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,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-YBMT3VRI.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};
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=(t,e)=>()=>(e||t((e={exports:{}}).exports,e),e.exports),Ce=(t,e)=>{for(var n in e)_(t,n,{get:e[n],enumerable:!0})},K=(t,e,n,o)=>{if(e&&typeof e=="object"||typeof e=="function")for(let r of de(e))!ye.call(t,r)&&r!==n&&_(t,r,{get:()=>e[r],enumerable:!(o=he(e,r))||o.enumerable});return t};var ge=(t,e,n)=>(n=t!=null?ue(fe(t)):{},K(e||!t||!t.__esModule?_(n,"default",{value:t,enumerable:!0}):n,t)),Ee=t=>K(_({},"__esModule",{value:!0}),t);var Pe=(t,e,n)=>{if(!e.has(t))throw TypeError("Cannot "+n)};var I=(t,e,n)=>(Pe(t,e,"read from private field"),n?n.call(t):e.get(t)),X=(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)};var te=M((it,ee)=>{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))}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(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 ne=M(P=>{var Te=te();P.operation=function(t){var e=P.timeouts(t);return new Te(e,{forever:t&&(t.forever||t.retries===1/0),unref:t&&t.unref,maxRetryTime:t&&t.maxRetryTime})};P.timeouts=function(t){if(t instanceof Array)return[].concat(t);var e={retries:10,factor:2,minTimeout:1*1e3,maxTimeout:1/0,randomize:!1};for(var n in t)e[n]=t[n];if(e.minTimeout>e.maxTimeout)throw new Error("minTimeout is greater than maxTimeout");for(var o=[],r=0;r<e.retries;r++)o.push(this.createTimeout(r,e));return t&&t.forever&&!o.length&&o.push(this.createTimeout(r,e)),o.sort(function(s,i){return s-i}),o};P.createTimeout=function(t,e){var n=e.randomize?Math.random()+1:1,o=Math.round(n*Math.max(e.minTimeout,1)*Math.pow(e.factor,t));return o=Math.min(o,e.maxTimeout),o};P.wrap=function(t,e,n){if(e instanceof Array&&(n=e,e=null),!n){n=[];for(var o in t)typeof t[o]=="function"&&n.push(o)}for(var r=0;r<n.length;r++){var s=n[r],i=t[s];t[s]=function(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(t,l)})}.bind(t,i),t[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:()=>St,CANVAS_TEST_SLOT:()=>Le,CANVAS_TEST_TYPE:()=>Ne,CANVAS_TEST_VARIANT_PARAM:()=>W,CanvasClient:()=>b,CanvasClientError:()=>Ke,ChildEnhancerBuilder:()=>A,DataConnectionClient:()=>$,DataTypeClient:()=>S,EdgeCanvasClient:()=>Y,EnhancerBuilder:()=>D,IN_CONTEXT_EDITOR_QUERY_STRING_PARAM:()=>Ve,UncachedCanvasClient:()=>k,UniqueBatchEntries:()=>N,compose:()=>be,createBatchEnhancer:()=>xe,createCanvasChannel:()=>Qe,createEventBus:()=>Fe,createLimitPolicy:()=>G,enhance:()=>Ie,extractLocales:()=>le,generateHash:()=>Z,getChannelName:()=>q,getComponentPath:()=>w,isAddComponentMessage:()=>qe,isMovingComponentMessage:()=>Ye,isReadyMessage:()=>We,isSelectComponentMessage:()=>He,isSystemComponentDefinition:()=>Ge,isUpdateCompositionMessage:()=>Ze,localize:()=>ze,mapSlotToPersonalizedVariations:()=>ke,mapSlotToTestVariations:()=>Be,nullLimitPolicy:()=>E,subscribeToComposition:()=>Je,walkComponentTree:()=>T});module.exports=Ee(Xe);function T(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 w(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 N=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 A=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}},D=class{constructor(){this._componentIndex={};this._rootBuilder=new A}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 A,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 R=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 xe({handleBatch:t,shouldQueue:e,limitPolicy:n}){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 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 U=class extends Error{constructor(){super("Throttled function aborted"),this.name="AbortError"}};function L({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 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"]),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}},ve=(t,e,n)=>{let o=n.retries-(e-1);return t.attemptNumber=e,t.retriesLeft=o,t},_e=t=>Ae.has(t),se=t=>globalThis.DOMException===void 0?new Error(t):new DOMException(t);async function V(t,e){return new Promise((n,o)=>{e={onFailedAttempt(){},retries:10,...e};let r=ie.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 j)r.stop(),o(i.originalError);else if(i instanceof TypeError&&!_e(i.message))r.stop(),o(i);else{ve(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 G({throttle:t={interval:1e3,limit:10},retry:e={retries:1,factor:1.66}}){let n=t?L(t):null;return function(r){let s=async()=>await r();if(n&&(s=n(s)),e){let i=s;s=()=>V(i,e)}return s()}}var E=async t=>await t();async function Ie({composition:t,enhancers:e,context:n,onErrors:o=r=>{throw new Error(r.map(s=>`${s.message}
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 O=(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=O((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=O(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=O((ct,oe)=>{oe.exports=ne()});var Xe={};Ce(Xe,{ApiClientError:()=>Q.ApiClientError,BatchEntry:()=>R,CANVAS_DRAFT_STATE:()=>bt,CANVAS_ENRICHMENT_TAG_PARAM:()=>Le,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:()=>Oe,CANVAS_PUBLISHED_STATE:()=>Mt,CANVAS_TEST_SLOT:()=>je,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 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),ve=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}},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 L)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?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 Ie({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(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(Re(c,h,u,f,p,n)))});let l=e.resolveComponentEnhancers(c);r.push(we(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: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(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?E:(i=s.limitPolicy)!=null?i:E)(async()=>s.enhanceOne({component:t,context:o}));c!=null&&(t.data[r]=c)}catch(a){let c=`Component ${w(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 Re(t,e,n,o,r,s){var i;try{let c=await(r.completeAll?E:(i=r.limitPolicy)!=null?i:E)(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 ${w(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 be=(t,...e)=>({enhanceOne:o=>{let r="enhanceOne"in t?t.enhanceOne(o):t(o);for(let s of e){let i=Se(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 Se(t){return!!t&&(typeof t=="object"||typeof t=="function")&&typeof t.then=="function"}var ae=require("@uniformdev/context/api"),b=class extends ae.ApiClient{constructor(n){n.limitPolicy||(n.limitPolicy=G({}));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 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})}},k=class extends b{constructor(e){super({...e,bypassCache:!0})}};var ce=require("@uniformdev/context/api"),B="/api/v1/data-connection",Oe="/api/v1/data-connections",$=class extends ce.ApiClient{constructor(e){super(e)}async get(e){let{projectId:n}=this.options,o=this.createUrl(B,{...e,projectId:n});return await this.apiClient(o)}async getList(e){let{projectId:n}=this.options,o=this.createUrl(Oe,{...e,projectId:n});return await this.apiClient(o)}async upsert(e){let n=this.createUrl(B);await this.apiClient(n,{method:"PUT",body:JSON.stringify({...e,projectId:this.options.projectId}),expectNoContent:!0})}async remove(e){let n=this.createUrl(B);await this.apiClient(n,{method:"DELETE",body:JSON.stringify({...e,projectId:this.options.projectId}),expectNoContent:!0})}};var pe=require("@uniformdev/context/api");var x,v=class extends pe.ApiClient{constructor(e){super(e)}async get(e){let{projectId:n}=this.options,o=this.createUrl(I(v,x),{...e,projectId:n});return await this.apiClient(o)}async upsert(e){let n=this.createUrl(I(v,x));await this.apiClient(n,{method:"PUT",body:JSON.stringify({...e,projectId:this.options.projectId}),expectNoContent:!0})}async remove(e){let n=this.createUrl(I(v,x));await this.apiClient(n,{method:"DELETE",body:JSON.stringify({...e,projectId:this.options.projectId}),expectNoContent:!0})}},S=v;x=new WeakMap,X(S,x,"/api/v1/data-types");var Me="$personalization",Ne="$test",F="$localization",De="intentTag",J="locale",Ue="pz",Le="test",z="localized",bt=0,St=64,H="$pzCrit",W="$tstVrnt",je="$enr",Ve="is_incontext_editing_mode";var Ge=t=>t.startsWith("$");function ke(t){return t?t.map((e,n)=>{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-${n}-${e.type}`;return{...e,id:r,pz:o}}):[]}function Be(t){return t?t.map((e,n)=>{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-${n}-${e.type}`;return{...e,id:r}}):[]}var Z=({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 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((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="${me}"><\/script> manually.`)},5e3),o=document.createElement("script");o.src=me,o.addEventListener("load",()=>{clearTimeout(n),t(window.Pusher)}),document.head.appendChild(o)})}async function Fe(){let t=await $e();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 q(t,e,n){return`${t}.${e}@${n}`}function Je({projectId:t,compositionId:e,compositionState:n=0,eventBus:{subscribe:o},callback:r,event:s="updated"}){let i=q(t,e,n),a=o(i),c=a.addEventHandler(s,r);return()=>{c(),a.unsubscribe()}}function le({component:t}){var o;let e={},n=(o=t.slots)==null?void 0:o[z];return n==null||n.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:t,locale:e}){T(t,(n,o,r)=>{if(n.type===F){let s=le({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 He=t=>t.type==="select-component"&&t.id!==void 0,We=t=>t.type==="ready",Ze=t=>t.type==="update-composition",qe=t=>t.type==="add-component",Ye=t=>t.type==="move-component",Qe=({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: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 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}};var O=require("@uniformdev/context/api"),Y=class extends O.ApiClient{constructor(n){n.limitPolicy||(n.limitPolicy=O.nullLimitPolicy);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)}};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,DataConnectionClient,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(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 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",Me="/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(Me,{...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 Oe="$personalization",Ne="$test",F="$localization",De="intentTag",J="locale",Ue="pz",je="test",z="localized",bt=0,Mt=64,H="$pzCrit",W="$tstVrnt",Le="$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 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"),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});
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-OT3KUGLJ.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 DataConnectionClient,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,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-YBMT3VRI.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};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@uniformdev/canvas",
3
- "version": "17.1.1-alpha.498+8b406a3f5",
3
+ "version": "17.1.1-alpha.752+3e63e24bd",
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,15 +49,15 @@
49
49
  "devDependencies": {
50
50
  "@types/retry": "0.12.1",
51
51
  "@types/yargs": "17.0.13",
52
- "@uniformdev/cli": "^17.1.1-alpha.498+8b406a3f5",
52
+ "@uniformdev/cli": "^17.1.1-alpha.752+3e63e24bd",
53
53
  "p-limit": "4.0.0",
54
54
  "p-retry": "5.1.1",
55
55
  "p-throttle": "5.0.0",
56
56
  "pusher-js": "7.4.0",
57
- "yargs": "17.5.1"
57
+ "yargs": "17.6.0"
58
58
  },
59
59
  "dependencies": {
60
- "@uniformdev/context": "^17.1.1-alpha.498+8b406a3f5"
60
+ "@uniformdev/context": "^17.1.1-alpha.752+3e63e24bd"
61
61
  },
62
62
  "files": [
63
63
  "/dist"
@@ -65,5 +65,5 @@
65
65
  "publishConfig": {
66
66
  "access": "public"
67
67
  },
68
- "gitHead": "8b406a3f5371b2910459a25883bd14ff5c94cd69"
68
+ "gitHead": "3e63e24bdfe658b80cc14a2dbc84748694637c52"
69
69
  }