@uniformdev/canvas 17.4.0 → 17.4.1-alpha.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/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-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';
1
+ import { C as ComponentInstance, a as ComponentParameter, b as CompositionGetParameters, c as CompositionGetByNodePathParameters, D as DataResolutionOptionNegative, d as CompositionGetResponse, e as DataResolutionOptionPositive, f as DataResolutionParameters, g as CompositionResolvedGetResponse, h as CompositionGetValidResponses, i as DataResolutionOption, j as CompositionGetByNodeIdParameters, k as CompositionGetBySlugParameters, l as CompositionGetByIdParameters, m as CompositionPutParameters, n as CompositionDeleteParameters, o as ComponentDefinitionGetParameters, p as ComponentDefinitionPutParameters, q as ComponentDefinitionDeleteParameters, r as DataSourceGetParameters, s as DataSourcesGetParameters, t as DataSourcePutParameters, u as DataSourceDeleteParameters, v as DataTypeGetParameters, w as DataTypeGetResponse, x as DataTypePutParameters, y as DataTypeDeleteParameters, R as RootComponentInstance, P as PreviewEventBus } from './createEventBus-f298dcef.js';
2
+ export { _ as CanvasDefinitions, ab as ChannelSubscription, L as ComponentDefinition, E as ComponentDefinitionAPIDeleteRequest, B as ComponentDefinitionAPIPutRequest, A as ComponentDefinitionAPIResponse, q as ComponentDefinitionDeleteParameters, o as ComponentDefinitionGetParameters, z as ComponentDefinitionGetResponse, F as ComponentDefinitionListAPIOptions, G as ComponentDefinitionParameter, K as ComponentDefinitionPermission, p as ComponentDefinitionPutParameters, J as ComponentDefinitionSlot, I as ComponentDefinitionSlugSettings, H as ComponentDefinitionVariant, C as ComponentInstance, a as ComponentParameter, T as CompositionAPIDeleteRequest, V as CompositionAPIOptions, S as CompositionAPIResponse, a4 as CompositionDataDiagnostic, n as CompositionDeleteParameters, l as CompositionGetByIdParameters, j as CompositionGetByNodeIdParameters, c as CompositionGetByNodePathParameters, k as CompositionGetBySlugParameters, Q as CompositionGetListResponse, N as CompositionGetOrderBy, b as CompositionGetParameters, d as CompositionGetResponse, h as CompositionGetValidResponses, $ as CompositionIssue, U as CompositionListAPIResponse, a0 as CompositionPatternIssue, m as CompositionPutParameters, g as CompositionResolvedGetResponse, O as CompositionUIStatus, M as CreatingComponentDefinition, a1 as DataElementBindingIssue, W as DataElementConnectionDefinition, i as DataResolutionOption, D as DataResolutionOptionNegative, e as DataResolutionOptionPositive, f as DataResolutionParameters, Z as DataResourceDefinition, Y as DataResourceDefinitions, a2 as DataResourceIssue, a3 as DataResourceVariableIssue, X as DataResourceVariables, a8 as DataSource, u as DataSourceDeleteParameters, r as DataSourceGetParameters, a5 as DataSourceGetResponse, a9 as DataSourceInfo, t as DataSourcePutParameters, s as DataSourcesGetParameters, a6 as DataSourcesGetResponse, a7 as DataType, y as DataTypeDeleteParameters, v as DataTypeGetParameters, w as DataTypeGetResponse, x as DataTypePutParameters, aa as DataVariableDefinition, P as PreviewEventBus, R as RootComponentInstance, ac as createEventBus } from './createEventBus-f298dcef.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';
@@ -349,312 +349,23 @@ declare class CanvasClient extends ApiClient<ClientOptions> {
349
349
  }[];
350
350
  totalCount?: number | undefined;
351
351
  }>;
352
- getCompositionByProjectMapNodePath(options: Pick<CompositionGetParameters, 'projectMapNodePath' | 'projectMapId' | 'state' | 'skipEnhance' | 'skipPatternResolution' | 'withComponentIDs' | 'withUIStatus' | 'withTotalCount'>): Promise<{
353
- state: number;
354
- uiStatus?: "Draft" | "Modified" | "Published" | "Orphan" | undefined;
355
- projectId: string;
356
- created: string;
357
- modified: string;
358
- pattern: boolean;
359
- composition: {
360
- type: string;
361
- parameters?: {
362
- [key: string]: {
363
- value: unknown;
364
- type: string;
365
- connectedData?: {
366
- pointer: string;
367
- syntax: "jptr";
368
- required?: boolean | undefined;
369
- } | undefined;
370
- };
371
- } | undefined;
372
- variant?: string | undefined;
373
- slots?: {
374
- [key: string]: {
375
- type: string;
376
- parameters?: {
377
- [key: string]: {
378
- value: unknown;
379
- type: string;
380
- connectedData?: {
381
- pointer: string;
382
- syntax: "jptr";
383
- required?: boolean | undefined;
384
- } | undefined;
385
- };
386
- } | undefined;
387
- variant?: string | undefined;
388
- slots?: {
389
- [key: string]: any[];
390
- } | undefined;
391
- _id?: string | undefined;
392
- _pattern?: string | undefined;
393
- _dataResources?: {
394
- [key: string]: {
395
- type: string;
396
- isPatternParameter?: boolean | undefined;
397
- variables?: {
398
- [key: string]: string;
399
- } | undefined;
400
- };
401
- } | undefined;
402
- _patternDataResources?: {
403
- [key: string]: {
404
- type: string;
405
- isPatternParameter?: boolean | undefined;
406
- variables?: {
407
- [key: string]: string;
408
- } | undefined;
409
- };
410
- } | undefined;
411
- _patternError?: "NOTFOUND" | "CYCLIC" | undefined;
412
- }[];
413
- } | undefined;
414
- _id: string;
415
- _slug?: string | null | undefined;
416
- _name: string;
417
- _dataResources?: {
418
- [key: string]: {
419
- type: string;
420
- isPatternParameter?: boolean | undefined;
421
- variables?: {
422
- [key: string]: string;
423
- } | undefined;
424
- };
425
- } | undefined;
426
- };
427
- }>;
428
- getCompositionByProjectMapNodeId(options: Pick<CompositionGetParameters, 'projectMapNodeId' | 'projectMapId' | 'state' | 'skipEnhance' | 'skipPatternResolution' | 'withComponentIDs' | 'withUIStatus' | 'withTotalCount'>): Promise<{
429
- state: number;
430
- uiStatus?: "Draft" | "Modified" | "Published" | "Orphan" | undefined;
431
- projectId: string;
432
- created: string;
433
- modified: string;
434
- pattern: boolean;
435
- composition: {
436
- type: string;
437
- parameters?: {
438
- [key: string]: {
439
- value: unknown;
440
- type: string;
441
- connectedData?: {
442
- pointer: string;
443
- syntax: "jptr";
444
- required?: boolean | undefined;
445
- } | undefined;
446
- };
447
- } | undefined;
448
- variant?: string | undefined;
449
- slots?: {
450
- [key: string]: {
451
- type: string;
452
- parameters?: {
453
- [key: string]: {
454
- value: unknown;
455
- type: string;
456
- connectedData?: {
457
- pointer: string;
458
- syntax: "jptr";
459
- required?: boolean | undefined;
460
- } | undefined;
461
- };
462
- } | undefined;
463
- variant?: string | undefined;
464
- slots?: {
465
- [key: string]: any[];
466
- } | undefined;
467
- _id?: string | undefined;
468
- _pattern?: string | undefined;
469
- _dataResources?: {
470
- [key: string]: {
471
- type: string;
472
- isPatternParameter?: boolean | undefined;
473
- variables?: {
474
- [key: string]: string;
475
- } | undefined;
476
- };
477
- } | undefined;
478
- _patternDataResources?: {
479
- [key: string]: {
480
- type: string;
481
- isPatternParameter?: boolean | undefined;
482
- variables?: {
483
- [key: string]: string;
484
- } | undefined;
485
- };
486
- } | undefined;
487
- _patternError?: "NOTFOUND" | "CYCLIC" | undefined;
488
- }[];
489
- } | undefined;
490
- _id: string;
491
- _slug?: string | null | undefined;
492
- _name: string;
493
- _dataResources?: {
494
- [key: string]: {
495
- type: string;
496
- isPatternParameter?: boolean | undefined;
497
- variables?: {
498
- [key: string]: string;
499
- } | undefined;
500
- };
501
- } | undefined;
502
- };
503
- }>;
504
- /** Fetches a Canvas composition by string name (slug) */
505
- getCompositionBySlug(options: Pick<CompositionGetParameters, 'slug' | 'state' | 'skipEnhance' | 'skipPatternResolution' | 'withComponentIDs' | 'withUIStatus' | 'withTotalCount'>): Promise<{
506
- state: number;
507
- uiStatus?: "Draft" | "Modified" | "Published" | "Orphan" | undefined;
508
- projectId: string;
509
- created: string;
510
- modified: string;
511
- pattern: boolean;
512
- composition: {
513
- type: string;
514
- parameters?: {
515
- [key: string]: {
516
- value: unknown;
517
- type: string;
518
- connectedData?: {
519
- pointer: string;
520
- syntax: "jptr";
521
- required?: boolean | undefined;
522
- } | undefined;
523
- };
524
- } | undefined;
525
- variant?: string | undefined;
526
- slots?: {
527
- [key: string]: {
528
- type: string;
529
- parameters?: {
530
- [key: string]: {
531
- value: unknown;
532
- type: string;
533
- connectedData?: {
534
- pointer: string;
535
- syntax: "jptr";
536
- required?: boolean | undefined;
537
- } | undefined;
538
- };
539
- } | undefined;
540
- variant?: string | undefined;
541
- slots?: {
542
- [key: string]: any[];
543
- } | undefined;
544
- _id?: string | undefined;
545
- _pattern?: string | undefined;
546
- _dataResources?: {
547
- [key: string]: {
548
- type: string;
549
- isPatternParameter?: boolean | undefined;
550
- variables?: {
551
- [key: string]: string;
552
- } | undefined;
553
- };
554
- } | undefined;
555
- _patternDataResources?: {
556
- [key: string]: {
557
- type: string;
558
- isPatternParameter?: boolean | undefined;
559
- variables?: {
560
- [key: string]: string;
561
- } | undefined;
562
- };
563
- } | undefined;
564
- _patternError?: "NOTFOUND" | "CYCLIC" | undefined;
565
- }[];
566
- } | undefined;
567
- _id: string;
568
- _slug?: string | null | undefined;
569
- _name: string;
570
- _dataResources?: {
571
- [key: string]: {
572
- type: string;
573
- isPatternParameter?: boolean | undefined;
574
- variables?: {
575
- [key: string]: string;
576
- } | undefined;
577
- };
578
- } | undefined;
579
- };
580
- }>;
581
- /** Fetches a Canvas composition by its public UUID */
582
- getCompositionById(options: Pick<CompositionGetParameters, 'compositionId' | 'state' | 'skipEnhance' | 'skipPatternResolution' | 'withComponentIDs' | 'withUIStatus' | 'withTotalCount'>): Promise<{
583
- state: number;
584
- uiStatus?: "Draft" | "Modified" | "Published" | "Orphan" | undefined;
585
- projectId: string;
586
- created: string;
587
- modified: string;
588
- pattern: boolean;
589
- composition: {
590
- type: string;
591
- parameters?: {
592
- [key: string]: {
593
- value: unknown;
594
- type: string;
595
- connectedData?: {
596
- pointer: string;
597
- syntax: "jptr";
598
- required?: boolean | undefined;
599
- } | undefined;
600
- };
601
- } | undefined;
602
- variant?: string | undefined;
603
- slots?: {
604
- [key: string]: {
605
- type: string;
606
- parameters?: {
607
- [key: string]: {
608
- value: unknown;
609
- type: string;
610
- connectedData?: {
611
- pointer: string;
612
- syntax: "jptr";
613
- required?: boolean | undefined;
614
- } | undefined;
615
- };
616
- } | undefined;
617
- variant?: string | undefined;
618
- slots?: {
619
- [key: string]: any[];
620
- } | undefined;
621
- _id?: string | undefined;
622
- _pattern?: string | undefined;
623
- _dataResources?: {
624
- [key: string]: {
625
- type: string;
626
- isPatternParameter?: boolean | undefined;
627
- variables?: {
628
- [key: string]: string;
629
- } | undefined;
630
- };
631
- } | undefined;
632
- _patternDataResources?: {
633
- [key: string]: {
634
- type: string;
635
- isPatternParameter?: boolean | undefined;
636
- variables?: {
637
- [key: string]: string;
638
- } | undefined;
639
- };
640
- } | undefined;
641
- _patternError?: "NOTFOUND" | "CYCLIC" | undefined;
642
- }[];
643
- } | undefined;
644
- _id: string;
645
- _slug?: string | null | undefined;
646
- _name: string;
647
- _dataResources?: {
648
- [key: string]: {
649
- type: string;
650
- isPatternParameter?: boolean | undefined;
651
- variables?: {
652
- [key: string]: string;
653
- } | undefined;
654
- };
655
- } | undefined;
656
- };
657
- }>;
352
+ /** Fetches one composition by its project map node path */
353
+ getCompositionByNodePath(options: CompositionGetByNodePathParameters & DataResolutionOptionNegative): Promise<CompositionGetResponse>;
354
+ getCompositionByNodePath(options: CompositionGetByNodePathParameters & DataResolutionOptionPositive & DataResolutionParameters): Promise<CompositionResolvedGetResponse>;
355
+ getCompositionByNodePath<T extends CompositionGetResponse = CompositionGetValidResponses>(options: CompositionGetByNodePathParameters & DataResolutionOption & DataResolutionParameters): Promise<T>;
356
+ /** Fetches one composition by its project map node ID */
357
+ getCompositionByNodeId(options: CompositionGetByNodeIdParameters & DataResolutionOptionNegative): Promise<CompositionGetResponse>;
358
+ getCompositionByNodeId(options: CompositionGetByNodeIdParameters & DataResolutionOptionPositive & DataResolutionParameters): Promise<CompositionResolvedGetResponse>;
359
+ getCompositionByNodeId<T extends CompositionGetResponse = CompositionGetValidResponses>(options: CompositionGetByNodeIdParameters & DataResolutionOption & DataResolutionParameters): Promise<T>;
360
+ /** Fetches one composition by its slug */
361
+ getCompositionBySlug(options: CompositionGetBySlugParameters & DataResolutionOptionNegative): Promise<CompositionGetResponse>;
362
+ getCompositionBySlug(options: CompositionGetBySlugParameters & DataResolutionOptionPositive & DataResolutionParameters): Promise<CompositionResolvedGetResponse>;
363
+ getCompositionBySlug<T extends CompositionGetResponse = CompositionGetValidResponses>(options: CompositionGetBySlugParameters & DataResolutionOption & DataResolutionParameters): Promise<T>;
364
+ /** Fetches one composition by its ID */
365
+ getCompositionById(options: CompositionGetByIdParameters & DataResolutionOptionNegative): Promise<CompositionGetResponse>;
366
+ getCompositionById(options: CompositionGetByIdParameters & DataResolutionOptionPositive & DataResolutionParameters): Promise<CompositionResolvedGetResponse>;
367
+ getCompositionById<T extends CompositionGetResponse = CompositionGetValidResponses>(options: CompositionGetByIdParameters & DataResolutionOption & DataResolutionParameters): Promise<T>;
368
+ private getOneComposition;
658
369
  /** Updates or creates a Canvas component definition */
659
370
  updateComposition(body: Omit<CompositionPutParameters, 'projectId'>): Promise<void>;
660
371
  /** Deletes a Canvas component definition */
@@ -668,6 +379,7 @@ declare class CanvasClient extends ApiClient<ClientOptions> {
668
379
  titleParameter?: string | null | undefined;
669
380
  canBeComposition?: boolean | undefined;
670
381
  parameters?: {
382
+ /** Updates or creates a Canvas component definition */
671
383
  id: string;
672
384
  name: string;
673
385
  helpText?: string | undefined;
@@ -780,6 +492,7 @@ declare class DataSourceClient extends ApiClient {
780
492
  type: string;
781
493
  default: string;
782
494
  setBy: "static" | "dynamic";
495
+ order?: number | undefined;
783
496
  };
784
497
  } | undefined;
785
498
  custom?: {
@@ -844,6 +557,8 @@ declare const CANVAS_TEST_VARIANT_PARAM = "$tstVrnt";
844
557
  declare const CANVAS_ENRICHMENT_TAG_PARAM = "$enr";
845
558
  /** The name of the query string used to detect if we are in in-context editing mode */
846
559
  declare const IN_CONTEXT_EDITOR_QUERY_STRING_PARAM = "is_incontext_editing_mode";
560
+ /** The name of the query string used to detect if we are in in-context editing mode */
561
+ declare const IN_CONTEXT_EDITOR_COMPONENT_START_ROLE = "uniform-component-start";
847
562
 
848
563
  /** Determines if a given Canvas component type is a system-defined type */
849
564
  declare const isSystemComponentDefinition: (componentType: string) => boolean;
@@ -906,7 +621,7 @@ declare type UpdateCompositionMessage = {
906
621
  };
907
622
  declare type AddComponentMessage = {
908
623
  type: 'add-component';
909
- componentId: string;
624
+ parentId: string;
910
625
  slotName: string;
911
626
  index: number;
912
627
  };
@@ -916,12 +631,18 @@ declare type MoveComponentMessage = {
916
631
  slotName: string;
917
632
  index: number;
918
633
  };
634
+ declare type DismissPlaceholderMessage = {
635
+ type: 'dismiss-placeholder';
636
+ parentId: string;
637
+ slotName: string;
638
+ };
639
+ declare type ChannelMessage = SelectComponentMessage | ReadyMessage | UpdateCompositionMessage | AddComponentMessage | MoveComponentMessage | DismissPlaceholderMessage;
919
640
  declare const isSelectComponentMessage: (message: ChannelMessage) => message is SelectComponentMessage;
920
641
  declare const isReadyMessage: (message: ChannelMessage) => message is ReadyMessage;
921
642
  declare const isUpdateCompositionMessage: (message: ChannelMessage) => message is UpdateCompositionMessage;
922
643
  declare const isAddComponentMessage: (message: ChannelMessage) => message is AddComponentMessage;
923
644
  declare const isMovingComponentMessage: (message: ChannelMessage) => message is MoveComponentMessage;
924
- declare type ChannelMessage = SelectComponentMessage | ReadyMessage | UpdateCompositionMessage | AddComponentMessage | MoveComponentMessage;
645
+ declare const isDismissPlaceholderMessage: (message: ChannelMessage) => message is DismissPlaceholderMessage;
925
646
  declare type MessageHandler = (message: ChannelMessage, originalEvent: MessageEvent) => void;
926
647
  declare type Channel = {
927
648
  ready: () => void;
@@ -929,99 +650,15 @@ declare type Channel = {
929
650
  selectComponent: (id: string) => void;
930
651
  updateComposition: (component: RootComponentInstance, secret?: string) => void;
931
652
  on: (types: ChannelMessage['type'][] | ChannelMessage['type'], handler: MessageHandler) => () => void;
932
- addComponent: (options: {
933
- componentId: string;
934
- slotName: string;
935
- index: number;
936
- }) => void;
937
- moveComponent: (options: {
938
- componentId: string;
939
- slotName: string;
940
- index: number;
941
- }) => void;
653
+ addComponent: (options: Omit<AddComponentMessage, 'type'>) => void;
654
+ moveComponent: (options: Omit<MoveComponentMessage, 'type'>) => void;
655
+ dismissPlaceholder: (options: Omit<DismissPlaceholderMessage, 'type'>) => void;
942
656
  };
943
657
  declare const createCanvasChannel: ({ listenTo, broadcastTo, }: {
944
658
  listenTo: Window[];
945
659
  broadcastTo: Window[];
946
660
  }) => Channel;
947
661
 
948
- /** Types of issue that can occur when fetching composition data */
949
- declare type CompositionIssue = CompositionPatternIssue | DataResourceIssue | DataElementBindingIssue | DataResourceVariableIssue;
950
- declare type CompositionIssueCore = {
951
- componentPath: string;
952
- componentType: string;
953
- message: string;
954
- };
955
- /** An error that occured resolving a pattern that is referenced on the composition */
956
- declare type CompositionPatternIssue = CompositionIssueCore & {
957
- type: 'pattern';
958
- code: NonNullable<ComponentInstance['_patternError']>;
959
- };
960
- /** An error while binding a data element from a data resource to a component parameter (i.e. a missing property in the data resource) */
961
- declare type DataElementBindingIssue = CompositionIssueCore & {
962
- type: 'binding';
963
- parameterName: string;
964
- };
965
- /** An error that occurred fetching a data defined on the composition or a pattern within */
966
- declare type DataResourceIssue = CompositionIssueCore & {
967
- type: 'data';
968
- dataName: string;
969
- dataType: string;
970
- };
971
- /** An issue that occurred while binding dynamic variables to composition data resources */
972
- declare type DataResourceVariableIssue = CompositionIssueCore & {
973
- type: 'variable';
974
- variableName: string;
975
- };
976
- /** Diagnostic data about the load performance of attached composition datas */
977
- declare type CompositionDataDiagnostic = {
978
- componentPath: string;
979
- dataType: string;
980
- dataName: string;
981
- performance: number;
982
- data: unknown;
983
- };
984
- declare type CommonCompositionGetParameters = Pick<CompositionGetParameters, 'state' | 'skipPatternResolution' | 'withComponentIDs' | 'withUIStatus'> & {
985
- /**
986
- * Adds additional diagnostics (`dataDiagnostics`) to the response containing timings and resolved datas for the composition.
987
- * Because this adds a lot of data to the response, we do not recommend using this unless diagnosing performance issues.
988
- */
989
- dataDiagnostics?: boolean;
990
- /**
991
- * Pass dynamic variables to the composition that are required for resolving bindings and datas,
992
- * such as language, detail page ID, etc.
993
- */
994
- dynamicVariables?: Record<string, string>;
995
- };
996
- /** @deprecated do not use */
997
- declare type EdgeCompositionGetResponse = CompositionGetResponse & {
998
- /**
999
- * Copies of resolved data and how long it took to resolve each data.
1000
- * Only set when dataDiagnostics=true is passed to the options.
1001
- */
1002
- dataDiagnostics?: Array<CompositionDataDiagnostic>;
1003
- /**
1004
- * Any failures to bind to data that occured on bindings marked 'must exist'.
1005
- * If no failures occurred, this will be undefined.
1006
- * NOTE: No exception will be thrown if this type of error occurs. You must inspect this property if you care to cause client errors.
1007
- */
1008
- errors?: Array<CompositionIssue>;
1009
- /**
1010
- * Any failures to bind to data that occurred on optional bindings. In most cases, these are only informational (i.e. data is bound to a property that does not always exist)
1011
- * If no failures occurred, this will be undefined.
1012
- */
1013
- warnings?: Array<CompositionIssue>;
1014
- };
1015
- /** @deprecated do not use */
1016
- declare class EdgeCanvasClient extends ApiClient<ClientOptions> {
1017
- constructor(options: ClientOptions);
1018
- private canvasUrl;
1019
- /** Fetches a Canvas composition by string name (slug) */
1020
- getCompositionBySlug(options: Pick<CompositionGetParameters, 'slug'> & CommonCompositionGetParameters): Promise<EdgeCompositionGetResponse>;
1021
- /** Fetches a Canvas composition by its public UUID */
1022
- getCompositionById(options: Pick<CompositionGetParameters, 'compositionId'> & CommonCompositionGetParameters): Promise<EdgeCompositionGetResponse>;
1023
- }
1024
-
1025
662
  declare const CanvasClientError: typeof ApiClientError;
1026
663
 
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 };
664
+ 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, DataSourceClient, DataTypeClient, DismissPlaceholderMessage, EnhancerBuilder, EnhancerContext, EnhancerError, EventNames, IN_CONTEXT_EDITOR_COMPONENT_START_ROLE, 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, isDismissPlaceholderMessage, 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,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};
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,fa as W,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-YWIQN37J.mjs";export{V 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,W as CanvasClientError,e as ChildEnhancerBuilder,o as DataSourceClient,p as DataTypeClient,f as EnhancerBuilder,E as IN_CONTEXT_EDITOR_COMPONENT_START_ROLE,D as IN_CONTEXT_EDITOR_QUERY_STRING_PARAM,n as UncachedCanvasClient,d as UniqueBatchEntries,l as compose,h as createBatchEnhancer,U as createCanvasChannel,J as createEventBus,i as createLimitPolicy,k as enhance,M as extractLocales,I as generateHash,K as getChannelName,c as getComponentJsonPointer,b as getComponentPath,R as isAddComponentMessage,T as isDismissPlaceholderMessage,S as isMovingComponentMessage,P as isReadyMessage,O as isSelectComponentMessage,F as isSystemComponentDefinition,Q as isUpdateCompositionMessage,N as localize,G as mapSlotToPersonalizedVariations,H as mapSlotToTestVariations,j as nullLimitPolicy,L as subscribeToComposition,a as walkComponentTree};
package/dist/index.js CHANGED
@@ -1,4 +1,4 @@
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}
1
+ "use strict";var le=Object.create;var _=Object.defineProperty;var ue=Object.getOwnPropertyDescriptor;var de=Object.getOwnPropertyNames;var he=Object.getPrototypeOf,fe=Object.prototype.hasOwnProperty;var D=(t,e)=>()=>(e||t((e={exports:{}}).exports,e),e.exports),ye=(t,e)=>{for(var n in e)_(t,n,{get:e[n],enumerable:!0})},Q=(t,e,n,o)=>{if(e&&typeof e=="object"||typeof e=="function")for(let r of de(e))!fe.call(t,r)&&r!==n&&_(t,r,{get:()=>e[r],enumerable:!(o=ue(e,r))||o.enumerable});return t};var Ce=(t,e,n)=>(n=t!=null?le(he(t)):{},Q(e||!t||!t.__esModule?_(n,"default",{value:t,enumerable:!0}):n,t)),ge=t=>Q(_({},"__esModule",{value:!0}),t);var Pe=(t,e,n)=>{if(!e.has(t))throw TypeError("Cannot "+n)};var R=(t,e,n)=>(Pe(t,e,"read from private field"),n?n.call(t):e.get(t)),K=(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 ee=D((pt,X)=>{function g(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))}X.exports=g;g.prototype.reset=function(){this._attempts=1,this._timeouts=this._originalTimeouts.slice(0)};g.prototype.stop=function(){this._timeout&&clearTimeout(this._timeout),this._timer&&clearTimeout(this._timer),this._timeouts=[],this._cachedTimeouts=null};g.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};g.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)};g.prototype.try=function(t){console.log("Using RetryOperation.try() is deprecated"),this.attempt(t)};g.prototype.start=function(t){console.log("Using RetryOperation.start() is deprecated"),this.attempt(t)};g.prototype.start=g.prototype.try;g.prototype.errors=function(){return this._errors};g.prototype.attempts=function(){return this._attempts};g.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 te=D(E=>{var xe=ee();E.operation=function(t){var e=E.timeouts(t);return new xe(e,{forever:t&&(t.forever||t.retries===1/0),unref:t&&t.unref,maxRetryTime:t&&t.maxRetryTime})};E.timeouts=function(t){if(t instanceof Array)return[].concat(t);var e={retries:10,factor:2,minTimeout:1*1e3,maxTimeout:1/0,randomize:!1};for(var n in t)e[n]=t[n];if(e.minTimeout>e.maxTimeout)throw new Error("minTimeout is greater than maxTimeout");for(var o=[],r=0;r<e.retries;r++)o.push(this.createTimeout(r,e));return t&&t.forever&&!o.length&&o.push(this.createTimeout(r,e)),o.sort(function(s,i){return s-i}),o};E.createTimeout=function(t,e){var n=e.randomize?Math.random()+1:1,o=Math.round(n*Math.max(e.minTimeout,1)*Math.pow(e.factor,t));return o=Math.min(o,e.maxTimeout),o};E.wrap=function(t,e,n){if(e instanceof Array&&(n=e,e=null),!n){n=[];for(var o in t)typeof t[o]=="function"&&n.push(o)}for(var r=0;r<n.length;r++){var s=n[r],i=t[s];t[s]=function(a){var d=E.operation(e),l=Array.prototype.slice.call(arguments,1),c=l.pop();l.push(function(u){d.retry(u)||(u&&(arguments[0]=d.mainError()),c.apply(this,arguments))}),d.attempt(function(){a.apply(t,l)})}.bind(t,i),t[s].options=e}}});var oe=D((mt,ne)=>{ne.exports=te()});var tt={};ye(tt,{ApiClientError:()=>Y.ApiClientError,BatchEntry:()=>w,CANVAS_DRAFT_STATE:()=>bt,CANVAS_ENRICHMENT_TAG_PARAM:()=>Le,CANVAS_INTENT_TAG_PARAM:()=>Ne,CANVAS_LOCALE_TAG_PARAM:()=>k,CANVAS_LOCALIZATION_SLOT:()=>J,CANVAS_LOCALIZATION_TYPE:()=>F,CANVAS_PERSONALIZATION_PARAM:()=>z,CANVAS_PERSONALIZE_SLOT:()=>Be,CANVAS_PERSONALIZE_TYPE:()=>be,CANVAS_PUBLISHED_STATE:()=>Mt,CANVAS_TEST_SLOT:()=>Ge,CANVAS_TEST_TYPE:()=>Me,CANVAS_TEST_VARIANT_PARAM:()=>H,CanvasClient:()=>S,CanvasClientError:()=>et,ChildEnhancerBuilder:()=>v,DataSourceClient:()=>$,DataTypeClient:()=>O,EnhancerBuilder:()=>M,IN_CONTEXT_EDITOR_COMPONENT_START_ROLE:()=>je,IN_CONTEXT_EDITOR_QUERY_STRING_PARAM:()=>Ue,UncachedCanvasClient:()=>j,UniqueBatchEntries:()=>b,compose:()=>Se,createBatchEnhancer:()=>Te,createCanvasChannel:()=>Xe,createEventBus:()=>Je,createLimitPolicy:()=>U,enhance:()=>Re,extractLocales:()=>me,generateHash:()=>W,getChannelName:()=>Z,getComponentJsonPointer:()=>Ee,getComponentPath:()=>I,isAddComponentMessage:()=>qe,isDismissPlaceholderMessage:()=>Ke,isMovingComponentMessage:()=>Qe,isReadyMessage:()=>Ze,isSelectComponentMessage:()=>We,isSystemComponentDefinition:()=>Ve,isUpdateCompositionMessage:()=>Ye,localize:()=>He,mapSlotToPersonalizedVariations:()=>$e,mapSlotToTestVariations:()=>Fe,nullLimitPolicy:()=>P,subscribeToComposition:()=>ze,walkComponentTree:()=>x});module.exports=ge(tt);function x(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 p=i.ancestorsAndSelf[0],a=!0,d=(s=r.get(p.component))!=null?s:i.context;e(p.component,i.ancestorsAndSelf,{replaceComponent:c=>{Object.assign(p.component,c),["parameters","variant","slots","data","_pattern","_patternError"].forEach(f=>{c[f]||delete p.component[f]})},removeComponent:()=>{let{parentSlot:c,parentSlotIndex:u}=i.ancestorsAndSelf[0],f=i.ancestorsAndSelf[1];if(c&&typeof u!="undefined")f.component.slots[c].splice(u,1);else throw new Error("Unable to delete composition.")},insertAfter:c=>{let u=Array.isArray(c)?c:[c],{parentSlot:f,parentSlotIndex:C}=i.ancestorsAndSelf[0],m=i.ancestorsAndSelf[1];if(f&&typeof C!="undefined")m.component.slots[f].splice(C+1,0,...u),o.unshift(...u.map(h=>({ancestorsAndSelf:[{component:h,parentSlot:f,get parentSlotIndex(){return m.component.slots[f].findIndex(y=>y===h)}},...i.ancestorsAndSelf],context:d})));else throw new Error("Unable to insert after a component not in a slot.")},stopProcessingDescendants(){a=!1},setDescendantsContext(c){d=c},setChildContext(c,u){r.set(c,u)}},d);let l=p.component.slots;if(a&&l){let c=Object.keys(l);for(let u=c.length-1;u>=0;u--){let f=c[u],C=l[f];for(let m=C.length-1;m>=0;m--){let h=C[m];o.push({ancestorsAndSelf:[{component:h,parentSlot:f,get parentSlotIndex(){return p.component.slots[f].findIndex(y=>y===h)}},...i.ancestorsAndSelf],context:d})}}}}while(o.length>0)}function I(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(".")}`}function Ee(t,{withSlots:e=!1}={}){let n=[];for(let o=t.length-1;o>=0;o--){let{parentSlot:r,parentSlotIndex:s}=t[o];r&&s!==void 0&&n.push(`${r}/${s}`)}return e?`/slots/${n.join("/slots/")}`:`/${n.join("/")}`}var b=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 v=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}},M=class{constructor(){this._componentIndex={};this._rootBuilder=new v}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 v,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 w=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 Te({handleBatch:t,shouldQueue:e,limitPolicy:n}){let o=[];return{enhanceOne:async i=>{if(!e||e(i))return new Promise((p,a)=>{o.push(new w(p,a,i))})},completeAll:async()=>{if(o.length>0){try{await t(o)}catch(p){o.forEach(a=>a.reject(p))}if(o.some(p=>!p.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 N=class extends Error{constructor(){super("Throttled function aborted"),this.name="AbortError"}};function B({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 p=[];function a(){let l=Date.now();if(p.length<t)return p.push(l),0;let c=p.shift()+e;return l>=c?(p.push(l),0):(p.push(c),c-l)}let d=n?a:i;return l=>{let c=function(...u){if(!c.isEnabled)return(async()=>l.apply(this,u))();let f;return new Promise((C,m)=>{f=setTimeout(()=>{C(l.apply(this,u)),o.delete(f)},d()),o.set(f,m)})};return c.abort=()=>{for(let u of o.keys())clearTimeout(u),o.get(u)(new N);o.clear(),p.splice(0,p.length)},c.isEnabled=!0,c}}var se=Ce(oe(),1),ve=new Set(["Failed to fetch","NetworkError when attempting to fetch resource.","The Internet connection appears to be offline.","Network request failed"]),G=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=(t,e,n)=>{let o=n.retries-(e-1);return t.attemptNumber=e,t.retriesLeft=o,t},_e=t=>ve.has(t),re=t=>globalThis.DOMException===void 0?new Error(t):new DOMException(t);async function L(t,e){return new Promise((n,o)=>{e={onFailedAttempt(){},retries:10,...e};let r=se.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 G)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(p){o(p);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?re("The operation was aborted."):e.signal.reason;o(s instanceof Error?s:re(s))},{once:!0})})}function U({throttle:t={interval:1e3,limit:10},retry:e={retries:1,factor:1.66}}){let n=t?B(t):null;return function(r){let s=async()=>await r();if(n&&(s=n(s)),e){let i=s;s=()=>L(i,e)}return s()}}var P=async t=>await t();async function Re({composition:t,enhancers:e,context:n,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(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});
4
+ `))}}){let r=[],s=new Set,i=new Set;x(t,(a,d)=>{var c;Object.entries((c=a.parameters)!=null?c:{}).forEach(([u,f])=>{let C=e.resolveParameterEnhancer(a,u,f);C&&(i.add(C),r.push(we(a,d,u,f,C,n)))});let l=e.resolveComponentEnhancers(a);r.push(Ie(a,d,l,n)),s.add(l)}),r.push(...Array.from(s).flatMap(a=>Array.from(a).map(async([,d])=>{var l;try{d.completeAll&&await((l=d.limitPolicy)!=null?l:P)(()=>d.completeAll())}catch(c){return{error:c,message:"Batch component enhancer failed. Individual failed components should receive their own rejections."}}}))),r.push(...Array.from(i).map(async a=>{var d;try{a.completeAll&&await((d=a.limitPolicy)!=null?d:P)(()=>a.completeAll())}catch(l){return{error:l,message:"Batch parameter enhancer failed. Individual failed parameters should receive their own rejections."}}}));let p=(await Promise.all(r)).flatMap(a=>Array.isArray(a)?a:[a]).filter(a=>a);p.length&&o(p)}async function Ie(t,e,n,o){return n.size&&(t.data={}),await Promise.all(Array.from(n).map(async([r,s])=>{var i;try{let a=await(s.completeAll?P:(i=s.limitPolicy)!=null?i:P)(async()=>s.enhanceOne({component:t,context:o}));a!=null&&(t.data[r]=a)}catch(p){let a=`Component ${I(e)} (type: ${t.type}): data.${r} enhancer threw exception. Data key will not be present.`;return delete t.data[r],{message:a,error:p}}}))}async function we(t,e,n,o,r,s){var i;try{let a=await(r.completeAll?P:(i=r.limitPolicy)!=null?i:P)(async()=>r.enhanceOne({parameter:o,parameterName:n,component:t,context:s}));a===null?delete t.parameters[n]:typeof a=="undefined"?t.parameters[n]={...o,value:o.value}:t.parameters[n]={...o,value:a}}catch(p){let a=`Component ${I(e)} (type: ${t.type}): enhancing parameter ${n} (type: ${o.type}) threw exception. Parameter will be removed.`;return delete t.parameters[n],{message:a,error:p}}}var Se=(t,...e)=>({enhanceOne:o=>{let r="enhanceOne"in t?t.enhanceOne(o):t(o);for(let s of e){let i=Oe(r)?r:Promise.resolve(r),p="enhanceOne"in s?s.enhanceOne:s;r=i.then(a=>p({...o,parameter:{type:o.parameter.type,value:a}}))}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 Oe(t){return!!t&&(typeof t=="object"||typeof t=="function")&&typeof t.then=="function"}var ie=require("@uniformdev/context/api"),S=class extends ie.ApiClient{constructor(n){n.limitPolicy||(n.limitPolicy=U({}));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)}getCompositionByNodePath(n){return this.getOneComposition(n)}getCompositionByNodeId(n){return this.getOneComposition(n)}getCompositionBySlug(n){return this.getOneComposition(n)}getCompositionById(n){return this.getOneComposition(n)}getOneComposition({unstable_resolveData:n,unstable_dynamicVariables:o,unstable_dataDiagnostics:r,...s}){let{projectId:i}=this.options,p=n?"/api/edge/v1/composition":this.canvasUrl,a={};return n&&(o&&(a.dynamicVariables=JSON.stringify(o)),r&&(a.dataDiagnostics="true")),this.apiClient(this.createUrl(p,{...s,...a,projectId:i}))}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})}},j=class extends S{constructor(e){super({...e,bypassCache:!0})}};var ae=require("@uniformdev/context/api"),V="/api/v1/data-source",De="/api/v1/data-sources",$=class extends ae.ApiClient{constructor(e){super(e)}async get(e){let{projectId:n}=this.options,o=this.createUrl(V,{...e,projectId:n});return await this.apiClient(o)}async getList(e){let{projectId:n}=this.options,o=this.createUrl(De,{...e,projectId:n});return await this.apiClient(o)}async upsert(e){let n=this.createUrl(V);await this.apiClient(n,{method:"PUT",body:JSON.stringify({...e,projectId:this.options.projectId}),expectNoContent:!0})}async remove(e){let n=this.createUrl(V);await this.apiClient(n,{method:"DELETE",body:JSON.stringify({...e,projectId:this.options.projectId}),expectNoContent:!0})}};var pe=require("@uniformdev/context/api");var T,A=class extends pe.ApiClient{constructor(e){super(e)}async get(e){let{projectId:n}=this.options,o=this.createUrl(R(A,T),{...e,projectId:n});return await this.apiClient(o)}async upsert(e){let n=this.createUrl(R(A,T));await this.apiClient(n,{method:"PUT",body:JSON.stringify({...e,projectId:this.options.projectId}),expectNoContent:!0})}async remove(e){let n=this.createUrl(R(A,T));await this.apiClient(n,{method:"DELETE",body:JSON.stringify({...e,projectId:this.options.projectId}),expectNoContent:!0})}},O=A;T=new WeakMap,K(O,T,"/api/v1/data-types");var be="$personalization",Me="$test",F="$localization",Ne="intentTag",k="locale",Be="pz",Ge="test",J="localized",bt=0,Mt=64,z="$pzCrit",H="$tstVrnt",Le="$enr",Ue="is_incontext_editing_mode",je="uniform-component-start";var Ve=t=>t.startsWith("$");function $e(t){return t?t.map((e,n)=>{var s,i;let o=(i=(s=e.parameters)==null?void 0:s[z])==null?void 0:i.value,r=(o==null?void 0:o.name)||`pz-${n}-${e.type}`;return{...e,id:r,pz:o}}):[]}function Fe(t){return t?t.map((e,n)=>{var s,i,p;let o=(i=(s=e.parameters)==null?void 0:s[H])==null?void 0:i.value,r=(p=o==null?void 0:o.id)!=null?p:"testId"in e?e.testId:`ab-${n}-${e.type}`;return{...e,id:r}}):[]}var W=({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 ce="https://js.pusher.com/7.0.3/pusher.min.js";async function ke(){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="${ce}"><\/script> manually.`)},5e3),o=document.createElement("script");o.src=ce,o.addEventListener("load",()=>{clearTimeout(n),t(window.Pusher)}),document.head.appendChild(o)})}async function Je(){let t=await ke();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 Z(t,e,n){return`${t}.${e}@${n}`}function ze({projectId:t,compositionId:e,compositionState:n=0,eventBus:{subscribe:o},callback:r,event:s="updated"}){let i=Z(t,e,n),p=o(i),a=p.addEventHandler(s,r);return()=>{a(),p.unsubscribe()}}function me({component:t}){var o;let e={},n=(o=t.slots)==null?void 0:o[J];return n==null||n.forEach(r=>{var i;let s=(i=r.parameters)==null?void 0:i[k];(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:t,locale:e}){x(t,(n,o,r)=>{if(n.type===F){let s=me({component:n}),i=typeof e=="string"?e:e({component:n,locales:s}),p;if(i&&(p=s[i]),p!=null&&p.length){let[a,...d]=p;r.replaceComponent(a),d.length&&r.insertAfter(d)}else r.removeComponent()}})}var We=t=>t.type==="select-component"&&t.id!==void 0,Ze=t=>t.type==="ready",Ye=t=>t.type==="update-composition",qe=t=>t.type==="add-component",Qe=t=>t.type==="move-component",Ke=t=>t.type==="dismiss-placeholder",Xe=({listenTo:t,broadcastTo:e})=>{let n=0,o={},r=[...e],s=m=>{r.forEach(h=>h.postMessage(JSON.stringify(m),"*"))},i=m=>{s({type:"select-component",id:m})},p=()=>{s({type:"ready"})},a=(m,h)=>{let y=++n;return o[y]={types:Array.isArray(m)?m:[m],handler:h},()=>{delete o[y]}},d=(m,h)=>{let y={type:"update-composition",composition:m,hash:W({composition:m,secret:h})};s(y)},l=m=>{let h={...m,type:"add-component"};s(h)},c=m=>{let h={...m,type:"move-component"};s(h)},u=m=>{let h={...m,type:"dismiss-placeholder"};s(h)},f=m=>{if(typeof m.data!="string"||m.source===window)return;let h=null;try{let y=JSON.parse(m.data);Object.hasOwn(y,"type")&&(h=y)}catch(y){}if(!!h)for(let y in o){let q=o[y];q.types.includes(h.type)&&q.handler(h,m)}};return t.forEach(m=>m.addEventListener("message",f)),{ready:p,destroy:()=>{t.forEach(m=>m.removeEventListener("message",f))},selectComponent:i,updateComposition:d,on:a,addComponent:l,moveComponent:c,dismissPlaceholder:u}};var Y=require("@uniformdev/context/api"),et=Y.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,EnhancerBuilder,IN_CONTEXT_EDITOR_COMPONENT_START_ROLE,IN_CONTEXT_EDITOR_QUERY_STRING_PARAM,UncachedCanvasClient,UniqueBatchEntries,compose,createBatchEnhancer,createCanvasChannel,createEventBus,createLimitPolicy,enhance,extractLocales,generateHash,getChannelName,getComponentJsonPointer,getComponentPath,isAddComponentMessage,isDismissPlaceholderMessage,isMovingComponentMessage,isReadyMessage,isSelectComponentMessage,isSystemComponentDefinition,isUpdateCompositionMessage,localize,mapSlotToPersonalizedVariations,mapSlotToTestVariations,nullLimitPolicy,subscribeToComposition,walkComponentTree});