@uniformdev/canvas 17.1.1-alpha.152 → 17.1.1-alpha.231

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,8 +1,8 @@
1
- import { C as ComponentInstance, a as ComponentParameter, c as components, b as CompositionGetParameters, d as CompositionPutParameters, e as CompositionDeleteParameters, f as ComponentDefinitionGetParameters, g as ComponentDefinitionPutParameters, h as ComponentDefinitionDeleteParameters, P as PreviewEventBus } from './createEventBus-b9cdb6ff.js';
2
- export { H as CanvasDefinitions, I as ChannelSubscription, s as ComponentDefinition, l as ComponentDefinitionAPIDeleteRequest, k as ComponentDefinitionAPIPutRequest, j as ComponentDefinitionAPIResponse, h as ComponentDefinitionDeleteParameters, f as ComponentDefinitionGetParameters, i as ComponentDefinitionGetResponse, m as ComponentDefinitionListAPIOptions, n as ComponentDefinitionParameter, r as ComponentDefinitionPermission, g as ComponentDefinitionPutParameters, q as ComponentDefinitionSlot, p as ComponentDefinitionSlugSettings, o as ComponentDefinitionVariant, C as ComponentInstance, a as ComponentParameter, D as ComponentParameterBinding, z as CompositionAPIDeleteRequest, B as CompositionAPIOptions, y as CompositionAPIResponse, G as CompositionDataDefinition, F as CompositionDataDefinitions, E as CompositionDataVariables, e as CompositionDeleteParameters, x as CompositionGetListResponse, u as CompositionGetOrderBy, b as CompositionGetParameters, v as CompositionGetResponse, A as CompositionListAPIResponse, d as CompositionPutParameters, w as CompositionUIStatus, t as CreatingComponentDefinition, P as PreviewEventBus, R as RootComponentInstance, J as createEventBus } from './createEventBus-b9cdb6ff.js';
1
+ import { C as ComponentInstance, a as ComponentParameter, c as components, b as CompositionGetParameters, d as CompositionPutParameters, e as CompositionDeleteParameters, f as ComponentDefinitionGetParameters, g as ComponentDefinitionPutParameters, h as ComponentDefinitionDeleteParameters, R as RootComponentInstance, P as PreviewEventBus, i as CompositionGetResponse } from './createEventBus-e386fc9c.js';
2
+ export { H as CanvasDefinitions, I as ChannelSubscription, t as ComponentDefinition, m as ComponentDefinitionAPIDeleteRequest, l as ComponentDefinitionAPIPutRequest, k as ComponentDefinitionAPIResponse, h as ComponentDefinitionDeleteParameters, f as ComponentDefinitionGetParameters, j as ComponentDefinitionGetResponse, n as ComponentDefinitionListAPIOptions, o as ComponentDefinitionParameter, s as ComponentDefinitionPermission, g as ComponentDefinitionPutParameters, r as ComponentDefinitionSlot, q as ComponentDefinitionSlugSettings, p as ComponentDefinitionVariant, C as ComponentInstance, a as ComponentParameter, D as ComponentParameterBinding, z as CompositionAPIDeleteRequest, B as CompositionAPIOptions, y as CompositionAPIResponse, G as CompositionDataDefinition, F as CompositionDataDefinitions, E as CompositionDataVariables, e as CompositionDeleteParameters, x as CompositionGetListResponse, v as CompositionGetOrderBy, b as CompositionGetParameters, i as CompositionGetResponse, A as CompositionListAPIResponse, d as CompositionPutParameters, w as CompositionUIStatus, u as CreatingComponentDefinition, P as PreviewEventBus, R as RootComponentInstance, J as createEventBus } from './createEventBus-e386fc9c.js';
3
3
  import { Options } from 'p-throttle';
4
4
  import { Options as Options$1 } from 'p-retry';
5
- import { ClientOptions, ApiClient, ExceptProject, ApiClientError } from '@uniformdev/context/api';
5
+ import { ApiClient, ClientOptions, ExceptProject, ApiClientError } from '@uniformdev/context/api';
6
6
  export { ApiClientError } from '@uniformdev/context/api';
7
7
  import { PersonalizedVariant, TestVariant } from '@uniformdev/context';
8
8
  import 'pusher-js';
@@ -273,11 +273,11 @@ interface external$2 {
273
273
  roleId: external$2["uniform-canvas-types.swagger.yml"]["components"]["schemas"]["PublicIdProperty"];
274
274
  /**
275
275
  * @description Permission type for this permission ComponentDefinition:
276
- * read | write | delete
276
+ * read | write | create | delete
277
277
  *
278
278
  * @enum {string}
279
279
  */
280
- permission: "read" | "write" | "delete";
280
+ permission: "read" | "write" | "create" | "delete";
281
281
  /** @description State of the component that this permission applies to */
282
282
  state: number;
283
283
  };
@@ -429,23 +429,23 @@ interface external$2 {
429
429
  * @description An instance of an integration data connector (i.e. "Master environment of the stable space", "Yelp API", "Sanity dev dataset"). These are created in the UI and shared across a whole project.
430
430
  */
431
431
  DataConnection: {
432
- /** @description Public ID of the data connector */
432
+ /** @description Public ID of the data connection */
433
433
  id: string;
434
- /** @description Display name of the data connector */
434
+ /** @description Display name of the data connection */
435
435
  displayName: string;
436
436
  /** @description The type of data connector this connects to (e.g. 'cms-items', provided by an intalled integration) */
437
437
  connectorType: string;
438
- /** @description Base resource URL of the data connector. No trailing slash. */
438
+ /** @description Base resource URL of the data connection. No trailing slash. */
439
439
  baseUrl: string;
440
- /** @description HTTP headers to pass with requests to the data connector */
440
+ /** @description HTTP headers to pass with requests to the data connection */
441
441
  headers?: {
442
442
  [key: string]: string;
443
443
  };
444
- /** @description Query String parameters to pass with requests to the data connector */
444
+ /** @description Query String parameters to pass with requests to the data connection */
445
445
  parameters?: {
446
446
  [key: string]: string;
447
447
  };
448
- /** @description Variables needed to make calls to the data connector */
448
+ /** @description Variables needed to make calls to the data connection */
449
449
  variables?: {
450
450
  [key: string]: external$2["uniform-canvas-types.swagger.yml"]["components"]["schemas"]["DataVariable"];
451
451
  };
@@ -459,11 +459,11 @@ interface external$2 {
459
459
  * @description A specific type of data that a Data Connection can provide (i.e. "Recipe", "Recipes List by Tag", "Yelp Reviews of My Restaurant"). These are created in the UI and shared a whole project.
460
460
  */
461
461
  DataType: {
462
- /** @description Public ID of the data connector */
462
+ /** @description Public ID of the data type */
463
463
  id: string;
464
- /** @description Display name of the data connector */
464
+ /** @description Display name of the data type */
465
465
  displayName: string;
466
- /** @description Public ID of the associated data connector */
466
+ /** @description Public ID of the associated data connection */
467
467
  connectionId: string;
468
468
  /**
469
469
  * @description A connector-specific archetype for this data type; used to select UI as well as perform any
@@ -473,23 +473,23 @@ interface external$2 {
473
473
  archetype?: string;
474
474
  /** @description Resource path, appended to the data connection's baseUrl (e.g. baseUrl = https://base.url, path = /v1/endpoint -> final URL https://base.url/v1/endpoint). Must have leading slash. */
475
475
  path: string;
476
- /** @description HTTP headers to pass with requests to the data connector */
476
+ /** @description HTTP headers to pass with requests to the data type. Merged with headers from the data connection, overriding identical keys. */
477
477
  headers?: {
478
478
  [key: string]: string;
479
479
  };
480
- /** @description Query String parameters to pass with requests to the data connector */
480
+ /** @description Query String parameters to pass with requests to the data type. Merged with parameters from the data connection, overriding identical keys. */
481
481
  parameters?: {
482
482
  [key: string]: string;
483
483
  };
484
- /** @description Body to pass with requests to the data connector */
484
+ /** @description Body to pass with requests to the data type (ignored unless method is POST) */
485
485
  body?: string;
486
486
  /**
487
- * @description HTTP method to use with requests to the data connector.
487
+ * @description HTTP method to use with requests to the data type.
488
488
  * @default GET
489
489
  * @enum {string}
490
490
  */
491
491
  method: "GET" | "POST" | "HEAD";
492
- /** @description Variables needed to make calls to the data connector */
492
+ /** @description Variables needed to make calls to the data type. Merged with variables from the data connection, overriding identical keys. */
493
493
  variables?: {
494
494
  [key: string]: external$2["uniform-canvas-types.swagger.yml"]["components"]["schemas"]["DataVariable"];
495
495
  };
@@ -741,11 +741,11 @@ interface external$1 {
741
741
  roleId: external$1["uniform-canvas-types.swagger.yml"]["components"]["schemas"]["PublicIdProperty"];
742
742
  /**
743
743
  * @description Permission type for this permission ComponentDefinition:
744
- * read | write | delete
744
+ * read | write | create | delete
745
745
  *
746
746
  * @enum {string}
747
747
  */
748
- permission: "read" | "write" | "delete";
748
+ permission: "read" | "write" | "create" | "delete";
749
749
  /** @description State of the component that this permission applies to */
750
750
  state: number;
751
751
  };
@@ -897,23 +897,23 @@ interface external$1 {
897
897
  * @description An instance of an integration data connector (i.e. "Master environment of the stable space", "Yelp API", "Sanity dev dataset"). These are created in the UI and shared across a whole project.
898
898
  */
899
899
  DataConnection: {
900
- /** @description Public ID of the data connector */
900
+ /** @description Public ID of the data connection */
901
901
  id: string;
902
- /** @description Display name of the data connector */
902
+ /** @description Display name of the data connection */
903
903
  displayName: string;
904
904
  /** @description The type of data connector this connects to (e.g. 'cms-items', provided by an intalled integration) */
905
905
  connectorType: string;
906
- /** @description Base resource URL of the data connector. No trailing slash. */
906
+ /** @description Base resource URL of the data connection. No trailing slash. */
907
907
  baseUrl: string;
908
- /** @description HTTP headers to pass with requests to the data connector */
908
+ /** @description HTTP headers to pass with requests to the data connection */
909
909
  headers?: {
910
910
  [key: string]: string;
911
911
  };
912
- /** @description Query String parameters to pass with requests to the data connector */
912
+ /** @description Query String parameters to pass with requests to the data connection */
913
913
  parameters?: {
914
914
  [key: string]: string;
915
915
  };
916
- /** @description Variables needed to make calls to the data connector */
916
+ /** @description Variables needed to make calls to the data connection */
917
917
  variables?: {
918
918
  [key: string]: external$1["uniform-canvas-types.swagger.yml"]["components"]["schemas"]["DataVariable"];
919
919
  };
@@ -927,11 +927,11 @@ interface external$1 {
927
927
  * @description A specific type of data that a Data Connection can provide (i.e. "Recipe", "Recipes List by Tag", "Yelp Reviews of My Restaurant"). These are created in the UI and shared a whole project.
928
928
  */
929
929
  DataType: {
930
- /** @description Public ID of the data connector */
930
+ /** @description Public ID of the data type */
931
931
  id: string;
932
- /** @description Display name of the data connector */
932
+ /** @description Display name of the data type */
933
933
  displayName: string;
934
- /** @description Public ID of the associated data connector */
934
+ /** @description Public ID of the associated data connection */
935
935
  connectionId: string;
936
936
  /**
937
937
  * @description A connector-specific archetype for this data type; used to select UI as well as perform any
@@ -941,23 +941,23 @@ interface external$1 {
941
941
  archetype?: string;
942
942
  /** @description Resource path, appended to the data connection's baseUrl (e.g. baseUrl = https://base.url, path = /v1/endpoint -> final URL https://base.url/v1/endpoint). Must have leading slash. */
943
943
  path: string;
944
- /** @description HTTP headers to pass with requests to the data connector */
944
+ /** @description HTTP headers to pass with requests to the data type. Merged with headers from the data connection, overriding identical keys. */
945
945
  headers?: {
946
946
  [key: string]: string;
947
947
  };
948
- /** @description Query String parameters to pass with requests to the data connector */
948
+ /** @description Query String parameters to pass with requests to the data type. Merged with parameters from the data connection, overriding identical keys. */
949
949
  parameters?: {
950
950
  [key: string]: string;
951
951
  };
952
- /** @description Body to pass with requests to the data connector */
952
+ /** @description Body to pass with requests to the data type (ignored unless method is POST) */
953
953
  body?: string;
954
954
  /**
955
- * @description HTTP method to use with requests to the data connector.
955
+ * @description HTTP method to use with requests to the data type.
956
956
  * @default GET
957
957
  * @enum {string}
958
958
  */
959
959
  method: "GET" | "POST" | "HEAD";
960
- /** @description Variables needed to make calls to the data connector */
960
+ /** @description Variables needed to make calls to the data type. Merged with variables from the data connection, overriding identical keys. */
961
961
  variables?: {
962
962
  [key: string]: external$1["uniform-canvas-types.swagger.yml"]["components"]["schemas"]["DataVariable"];
963
963
  };
@@ -1166,11 +1166,11 @@ interface external {
1166
1166
  roleId: external["uniform-canvas-types.swagger.yml"]["components"]["schemas"]["PublicIdProperty"];
1167
1167
  /**
1168
1168
  * @description Permission type for this permission ComponentDefinition:
1169
- * read | write | delete
1169
+ * read | write | create | delete
1170
1170
  *
1171
1171
  * @enum {string}
1172
1172
  */
1173
- permission: "read" | "write" | "delete";
1173
+ permission: "read" | "write" | "create" | "delete";
1174
1174
  /** @description State of the component that this permission applies to */
1175
1175
  state: number;
1176
1176
  };
@@ -1322,23 +1322,23 @@ interface external {
1322
1322
  * @description An instance of an integration data connector (i.e. "Master environment of the stable space", "Yelp API", "Sanity dev dataset"). These are created in the UI and shared across a whole project.
1323
1323
  */
1324
1324
  DataConnection: {
1325
- /** @description Public ID of the data connector */
1325
+ /** @description Public ID of the data connection */
1326
1326
  id: string;
1327
- /** @description Display name of the data connector */
1327
+ /** @description Display name of the data connection */
1328
1328
  displayName: string;
1329
1329
  /** @description The type of data connector this connects to (e.g. 'cms-items', provided by an intalled integration) */
1330
1330
  connectorType: string;
1331
- /** @description Base resource URL of the data connector. No trailing slash. */
1331
+ /** @description Base resource URL of the data connection. No trailing slash. */
1332
1332
  baseUrl: string;
1333
- /** @description HTTP headers to pass with requests to the data connector */
1333
+ /** @description HTTP headers to pass with requests to the data connection */
1334
1334
  headers?: {
1335
1335
  [key: string]: string;
1336
1336
  };
1337
- /** @description Query String parameters to pass with requests to the data connector */
1337
+ /** @description Query String parameters to pass with requests to the data connection */
1338
1338
  parameters?: {
1339
1339
  [key: string]: string;
1340
1340
  };
1341
- /** @description Variables needed to make calls to the data connector */
1341
+ /** @description Variables needed to make calls to the data connection */
1342
1342
  variables?: {
1343
1343
  [key: string]: external["uniform-canvas-types.swagger.yml"]["components"]["schemas"]["DataVariable"];
1344
1344
  };
@@ -1352,11 +1352,11 @@ interface external {
1352
1352
  * @description A specific type of data that a Data Connection can provide (i.e. "Recipe", "Recipes List by Tag", "Yelp Reviews of My Restaurant"). These are created in the UI and shared a whole project.
1353
1353
  */
1354
1354
  DataType: {
1355
- /** @description Public ID of the data connector */
1355
+ /** @description Public ID of the data type */
1356
1356
  id: string;
1357
- /** @description Display name of the data connector */
1357
+ /** @description Display name of the data type */
1358
1358
  displayName: string;
1359
- /** @description Public ID of the associated data connector */
1359
+ /** @description Public ID of the associated data connection */
1360
1360
  connectionId: string;
1361
1361
  /**
1362
1362
  * @description A connector-specific archetype for this data type; used to select UI as well as perform any
@@ -1366,23 +1366,23 @@ interface external {
1366
1366
  archetype?: string;
1367
1367
  /** @description Resource path, appended to the data connection's baseUrl (e.g. baseUrl = https://base.url, path = /v1/endpoint -> final URL https://base.url/v1/endpoint). Must have leading slash. */
1368
1368
  path: string;
1369
- /** @description HTTP headers to pass with requests to the data connector */
1369
+ /** @description HTTP headers to pass with requests to the data type. Merged with headers from the data connection, overriding identical keys. */
1370
1370
  headers?: {
1371
1371
  [key: string]: string;
1372
1372
  };
1373
- /** @description Query String parameters to pass with requests to the data connector */
1373
+ /** @description Query String parameters to pass with requests to the data type. Merged with parameters from the data connection, overriding identical keys. */
1374
1374
  parameters?: {
1375
1375
  [key: string]: string;
1376
1376
  };
1377
- /** @description Body to pass with requests to the data connector */
1377
+ /** @description Body to pass with requests to the data type (ignored unless method is POST) */
1378
1378
  body?: string;
1379
1379
  /**
1380
- * @description HTTP method to use with requests to the data connector.
1380
+ * @description HTTP method to use with requests to the data type.
1381
1381
  * @default GET
1382
1382
  * @enum {string}
1383
1383
  */
1384
1384
  method: "GET" | "POST" | "HEAD";
1385
- /** @description Variables needed to make calls to the data connector */
1385
+ /** @description Variables needed to make calls to the data type. Merged with variables from the data connection, overriding identical keys. */
1386
1386
  variables?: {
1387
1387
  [key: string]: external["uniform-canvas-types.swagger.yml"]["components"]["schemas"]["DataVariable"];
1388
1388
  };
@@ -1476,7 +1476,7 @@ declare type ComponentLocationReference = {
1476
1476
  parentSlot?: string;
1477
1477
  parentSlotIndex?: number;
1478
1478
  };
1479
- declare type WalkComponentTreeActions = {
1479
+ declare type WalkComponentTreeActions<TContext> = {
1480
1480
  /** Replaces the component being visited with a new object */
1481
1481
  replaceComponent: (replacementComponent: ComponentInstance) => void;
1482
1482
  /** Removes the component being visited from the composition */
@@ -1485,9 +1485,17 @@ declare type WalkComponentTreeActions = {
1485
1485
  insertAfter: (components: ComponentInstance | ComponentInstance[]) => void;
1486
1486
  /** Aborts visitation of components that are in child slots of the current component */
1487
1487
  stopProcessingDescendants: () => void;
1488
+ /**
1489
+ * Set a new traversal context for descendants of this node.
1490
+ * If this is not called, `context` will automatically pass through.
1491
+ */
1492
+ setDescendantsContext: (context: TContext) => void;
1493
+ setChildContext: (child: ComponentInstance, context: TContext) => void;
1488
1494
  };
1489
1495
  /** Walks a composition's component tree, visiting each component instance depth-first, in order. */
1490
- declare function walkComponentTree(component: ComponentInstance, visitor: (component: ComponentInstance, ancestorsAndSelf: Array<ComponentLocationReference>, actions: WalkComponentTreeActions) => void): void;
1496
+ declare function walkComponentTree<TContext = unknown>(component: ComponentInstance, visitor: (component: ComponentInstance, ancestorsAndSelf: Array<ComponentLocationReference>, actions: WalkComponentTreeActions<TContext>,
1497
+ /** Traversal context for this node */
1498
+ currentContext: TContext | undefined) => void, initialContext?: TContext): void;
1491
1499
  declare function getComponentPath(ancestorsAndSelf: Array<ComponentLocationReference>): string;
1492
1500
 
1493
1501
  /** A single entry in a batch of queued enhancements. */
@@ -1640,15 +1648,11 @@ declare function createLimitPolicy({ throttle, retry, }: {
1640
1648
  }): LimitPolicy;
1641
1649
  declare const nullLimitPolicy: LimitPolicy;
1642
1650
 
1643
- declare type CanvasClientOptions = ClientOptions & {
1644
- /** @deprecated do not use */
1645
- experiment14?: boolean;
1646
- };
1647
- declare class CanvasClient extends ApiClient<CanvasClientOptions> {
1648
- constructor(options: CanvasClientOptions);
1649
- private get canvasUrl();
1651
+ declare class CanvasClient extends ApiClient<ClientOptions> {
1652
+ constructor(options: ClientOptions);
1653
+ private canvasUrl;
1650
1654
  /** Fetches lists of Canvas compositions, optionally by type */
1651
- getCompositionList(options?: Omit<CompositionGetParameters, 'projectId' | 'compositionId'>): Promise<{
1655
+ getCompositionList(options?: Omit<CompositionGetParameters, 'projectId' | 'compositionId' | 'slug'>): Promise<{
1652
1656
  compositions: {
1653
1657
  state: number;
1654
1658
  uiStatus?: "Draft" | "Modified" | "Published" | "Orphan" | undefined;
@@ -1902,7 +1906,7 @@ declare class CanvasClient extends ApiClient<CanvasClientOptions> {
1902
1906
  useTeamPermissions?: boolean | undefined;
1903
1907
  permissions?: {
1904
1908
  roleId: string;
1905
- permission: "read" | "write" | "delete";
1909
+ permission: "read" | "write" | "create" | "delete";
1906
1910
  state: number;
1907
1911
  }[] | undefined;
1908
1912
  slots?: {
@@ -1915,7 +1919,7 @@ declare class CanvasClient extends ApiClient<CanvasClientOptions> {
1915
1919
  }[] | undefined;
1916
1920
  slugSettings?: {
1917
1921
  required?: "no" | "yes" | "disabled" | undefined;
1918
- unique?: "no" | "local" | "global" | undefined;
1922
+ unique?: "global" | "no" | "local" | undefined;
1919
1923
  regularExpression?: string | undefined;
1920
1924
  regularExpressionMessage?: string | undefined;
1921
1925
  } | undefined;
@@ -1972,7 +1976,7 @@ declare class CanvasClient extends ApiClient<CanvasClientOptions> {
1972
1976
  removeComponentDefinition(body: Omit<ComponentDefinitionDeleteParameters, 'projectId'>): Promise<void>;
1973
1977
  }
1974
1978
  declare class UncachedCanvasClient extends CanvasClient {
1975
- constructor(options: Omit<CanvasClientOptions, 'bypassCache'>);
1979
+ constructor(options: Omit<ClientOptions, 'bypassCache'>);
1976
1980
  }
1977
1981
 
1978
1982
  /**
@@ -2061,6 +2065,8 @@ declare const CANVAS_PERSONALIZATION_PARAM = "$pzCrit";
2061
2065
  declare const CANVAS_TEST_VARIANT_PARAM = "$tstVrnt";
2062
2066
  /** Public ID of the Uniform Context enrichment tag parameter on Canvas components */
2063
2067
  declare const CANVAS_ENRICHMENT_TAG_PARAM = "$enr";
2068
+ /** The name of the query string used to detect if we are in in-context editing mode */
2069
+ declare const IN_CONTEXT_EDITOR_QUERY_STRING_PARAM = "is_incontext_editing_mode";
2064
2070
 
2065
2071
  /** Determines if a given Canvas component type is a system-defined type */
2066
2072
  declare const isSystemComponentDefinition: (componentType: string) => boolean;
@@ -2077,6 +2083,11 @@ declare function mapSlotToPersonalizedVariations(slot: ComponentInstance[] | und
2077
2083
  */
2078
2084
  declare function mapSlotToTestVariations(slot: ComponentInstance[] | undefined): Array<ComponentInstance & TestVariant>;
2079
2085
 
2086
+ declare const generateHash: ({ composition, secret, }: {
2087
+ composition: RootComponentInstance;
2088
+ secret: string | undefined;
2089
+ }) => number | undefined;
2090
+
2080
2091
  declare function getChannelName(projectId: string, compositionId: string, state: number): string;
2081
2092
 
2082
2093
  declare type EventNames = 'updated';
@@ -2104,6 +2115,126 @@ declare function localize({ composition, locale, }: {
2104
2115
  }) => string | undefined);
2105
2116
  }): void;
2106
2117
 
2107
- declare type CanvasClientError = ApiClientError;
2118
+ declare type SelectComponentMessage = {
2119
+ type: 'select-component';
2120
+ id: string;
2121
+ };
2122
+ declare type ReadyMessage = {
2123
+ type: 'ready';
2124
+ };
2125
+ declare type UpdateCompositionMessage = {
2126
+ type: 'update-composition';
2127
+ composition: RootComponentInstance;
2128
+ hash: number | undefined;
2129
+ };
2130
+ declare type AddComponentMessage = {
2131
+ type: 'add-component';
2132
+ componentId: string;
2133
+ slotName: string;
2134
+ index: number;
2135
+ };
2136
+ declare type MoveComponentMessage = {
2137
+ type: 'move-component';
2138
+ componentId: string;
2139
+ slotName: string;
2140
+ index: number;
2141
+ };
2142
+ declare const isSelectComponentMessage: (message: ChannelMessage) => message is SelectComponentMessage;
2143
+ declare const isReadyMessage: (message: ChannelMessage) => message is ReadyMessage;
2144
+ declare const isUpdateCompositionMessage: (message: ChannelMessage) => message is UpdateCompositionMessage;
2145
+ declare const isAddComponentMessage: (message: ChannelMessage) => message is AddComponentMessage;
2146
+ declare const isMovingComponentMessage: (message: ChannelMessage) => message is MoveComponentMessage;
2147
+ declare type ChannelMessage = SelectComponentMessage | ReadyMessage | UpdateCompositionMessage | AddComponentMessage | MoveComponentMessage;
2148
+ declare type MessageHandler = (message: ChannelMessage, originalEvent: MessageEvent) => void;
2149
+ declare type Channel = {
2150
+ ready: () => void;
2151
+ destroy: () => void;
2152
+ selectComponent: (id: string) => void;
2153
+ updateComposition: (component: RootComponentInstance, secret?: string) => void;
2154
+ on: (types: ChannelMessage['type'][] | ChannelMessage['type'], handler: MessageHandler) => () => void;
2155
+ addComponent: (options: {
2156
+ componentId: string;
2157
+ slotName: string;
2158
+ index: number;
2159
+ }) => void;
2160
+ moveComponent: (options: {
2161
+ componentId: string;
2162
+ slotName: string;
2163
+ index: number;
2164
+ }) => void;
2165
+ };
2166
+ declare const createCanvasChannel: ({ listenTo, broadcastTo, }: {
2167
+ listenTo: Window[];
2168
+ broadcastTo: Window[];
2169
+ }) => Channel;
2170
+
2171
+ declare type CompositionIssue = CompositionPatternIssue | CompositionDataIssue | CompositionBindingIssue;
2172
+ declare type CompositionIssueCore = {
2173
+ componentPath: string;
2174
+ componentType: string;
2175
+ message: string;
2176
+ };
2177
+ declare type CompositionPatternIssue = CompositionIssueCore & {
2178
+ type: 'pattern';
2179
+ code: NonNullable<ComponentInstance['_patternError']>;
2180
+ };
2181
+ declare type CompositionBindingIssue = CompositionIssueCore & {
2182
+ type: 'binding';
2183
+ parameterName: string;
2184
+ };
2185
+ declare type CompositionDataIssue = CompositionIssueCore & {
2186
+ type: 'data';
2187
+ dataName: string;
2188
+ dataType: string;
2189
+ };
2190
+ declare type CompositionDataDiagnostic = {
2191
+ componentPath: string;
2192
+ dataType: string;
2193
+ dataName: string;
2194
+ performance: number;
2195
+ data: unknown;
2196
+ };
2197
+ declare type CommonCompositionGetParameters = Pick<CompositionGetParameters, 'state' | 'skipPatternResolution' | 'withComponentIDs' | 'withUIStatus'> & {
2198
+ /**
2199
+ * Adds additional diagnostics (`dataDiagnostics`) to the response containing timings and resolved datas for the composition.
2200
+ * Because this adds a lot of data to the response, we do not recommend using this unless diagnosing performance issues.
2201
+ */
2202
+ dataDiagnostics?: boolean;
2203
+ /**
2204
+ * Pass dynamic variables to the composition that are required for resolving bindings and datas,
2205
+ * such as language, detail page ID, etc.
2206
+ */
2207
+ dynamicVariables?: Record<string, string>;
2208
+ };
2209
+ /** @deprecated do not use */
2210
+ declare type EdgeCompositionGetResponse = CompositionGetResponse & {
2211
+ /**
2212
+ * Copies of resolved data and how long it took to resolve each data.
2213
+ * Only set when dataDiagnostics=true is passed to the options.
2214
+ */
2215
+ dataDiagnostics?: Array<CompositionDataDiagnostic>;
2216
+ /**
2217
+ * Any failures to bind to data that occured on bindings marked 'must exist'.
2218
+ * If no failures occurred, this will be undefined.
2219
+ * NOTE: No exception will be thrown if this type of error occurs. You must inspect this property if you care to cause client errors.
2220
+ */
2221
+ errors?: Array<CompositionIssue>;
2222
+ /**
2223
+ * 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)
2224
+ * If no failures occurred, this will be undefined.
2225
+ */
2226
+ warnings?: Array<CompositionIssue>;
2227
+ };
2228
+ /** @deprecated do not use */
2229
+ declare class EdgeCanvasClient extends ApiClient<ClientOptions> {
2230
+ constructor(options: ClientOptions);
2231
+ private canvasUrl;
2232
+ /** Fetches a Canvas composition by string name (slug) */
2233
+ getCompositionBySlug(options: Pick<CompositionGetParameters, 'slug'> & CommonCompositionGetParameters): Promise<EdgeCompositionGetResponse>;
2234
+ /** Fetches a Canvas composition by its public UUID */
2235
+ getCompositionById(options: Pick<CompositionGetParameters, 'compositionId'> & CommonCompositionGetParameters): Promise<EdgeCompositionGetResponse>;
2236
+ }
2237
+
2238
+ declare const CanvasClientError: typeof ApiClientError;
2108
2239
 
2109
- export { 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, CanvasClientOptions, CanvasDataConnectionClient, CanvasDataTypeClient, ChildEnhancerBuilder, ComponentEnhancer, ComponentEnhancerFunction, ComponentEnhancerOptions, ComponentLocationReference, ComponentParameterEnhancer, ComponentParameterEnhancerFunction, ComponentParameterEnhancerOptions, DataConnection, DataConnectionDeleteParameters, DataConnectionGetParameters, DataConnectionGetResponse, DataConnectionInfo, DataConnectionPutParameters, DataConnectionsGetParameters, DataConnectionsGetResponse, DataType, DataTypeDeleteParameters, DataTypeGetParameters, DataTypeGetResponse, DataTypePutParameters, DataVariable, EnhancerBuilder, EnhancerContext, EnhancerError, EventNames, LimitPolicy, SubscribeToCompositionOptions, UncachedCanvasClient, UniqueBatchEntries, UnsubscribeCallback, WalkComponentTreeActions, compose, createBatchEnhancer, createLimitPolicy, enhance, extractLocales, getChannelName, getComponentPath, isSystemComponentDefinition, localize, mapSlotToPersonalizedVariations, mapSlotToTestVariations, nullLimitPolicy, subscribeToComposition, walkComponentTree };
2240
+ 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, CanvasDataConnectionClient, CanvasDataTypeClient, Channel, ChannelMessage, ChildEnhancerBuilder, ComponentEnhancer, ComponentEnhancerFunction, ComponentEnhancerOptions, ComponentLocationReference, ComponentParameterEnhancer, ComponentParameterEnhancerFunction, ComponentParameterEnhancerOptions, CompositionBindingIssue, CompositionDataDiagnostic, CompositionDataIssue, CompositionIssue, CompositionPatternIssue, DataConnection, DataConnectionDeleteParameters, DataConnectionGetParameters, DataConnectionGetResponse, DataConnectionInfo, DataConnectionPutParameters, DataConnectionsGetParameters, DataConnectionsGetResponse, DataType, DataTypeDeleteParameters, DataTypeGetParameters, DataTypeGetResponse, DataTypePutParameters, DataVariable, 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{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,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-PFL3XEAQ.mjs";export{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,n as CanvasDataConnectionClient,o as CanvasDataTypeClient,d as ChildEnhancerBuilder,e as EnhancerBuilder,m as UncachedCanvasClient,c as UniqueBatchEntries,k as compose,g as createBatchEnhancer,F as createEventBus,h as createLimitPolicy,j as enhance,I as extractLocales,G as getChannelName,b as getComponentPath,C as isSystemComponentDefinition,J as localize,D as mapSlotToPersonalizedVariations,E as mapSlotToTestVariations,i as nullLimitPolicy,H 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-2XL2NAQJ.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,n as CanvasDataConnectionClient,o as CanvasDataTypeClient,d as ChildEnhancerBuilder,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};